PageSourceSearch

https://app.solvitmoney.com/assets/AdminLeadIntake-CBsNFlI6.js

js solvitmoney.com collected 2026-10-05 22:39:34 UTC 763,436 bytes, 1,198 lines download raw bytes

1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-7KGHoeDr.js","assets/index-CMA0U84g.css","assets/index.es-KvqBBZhb.js","assets/AdminLayout-CaUScEvc.js","assets/leadLifecycleStatus-Cpf6DILn.js","assets/useIntakeSettings-D556_ZIX.js","assets/useRefiOpportunities-xnqZhytL.js","assets/useLenders-BSWto4wD.js","assets/AdminUserSelect-DcgwlQt2.js","assets/useAdminUsers-6aRPF9xY.js"])))=>i.map(i=>d[i]);
2var Tg=Object.defineProperty;var Dg=(e,t,n)=>t in e?Tg(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var mn=(e,t,n)=>Dg(e,typeof t!="symbol"?t+"":t,n);import{d as zd,u as vi,aC as ha,aB as ys,aD as Bs,s as nt,b as J,cu as am,c0 as sm,j as a,C as rn,F as on,cv as Rg,L as Kr,aR as _i,aT as wi,f as $s,aS as lo,g as Hs,a9 as Et,O as xn,aU as Ys,aV as Ni,c9 as zo,V as Bg,bY as Kl,aN as im,e as Ir,$ as Ql,a0 as Jl,a1 as Xl,a3 as Zl,a4 as ec,a5 as tc,a6 as om,a7 as Og,cw as ud,o as Ke,S as Ka,p as Qa,q as Ja,t as Xa,v as Mr,B as st,c8 as Dt,b1 as hd,b2 as Ol,b3 as ql,b5 as zl,cs as gi,I as Wt,ah as Us,as as Vs,cx as qg,bv as zg,br as Ga,c7 as Er,a8 as $g,cy as fd,cz as Hg,aH as $d,aI as Hd,aK as Ud,cm as lm,bq as cm,c4 as qu,c5 as zu,ab as md,ac as pd,at as dm,ad as gd,cc as Za,Y as nc,P as rc,cb as fi,cd as $u,cg as Vd,cA as Ug,cB as Vg,T as $o,G as Ho,H as Yr,J as In,K as Uo,M as Ut,cC as Hu,bg as um,bh as hm,bi as eo,cD as Wg,aM as Gg,bn as Yg,cE as Kg,_ as Lc,aE as fm,aF as ji,cF as Qg,D as Jg,k as Xg,l as Zg,m as e0,n as t0,ap as mm,b0 as n0,be as Uu,cj as qs,ck as Io,cl as ps,U as r0,a2 as pm,h as Cl,bV as gm,bW as To,aa as Ac,cG as kc,bj as ac,bS as Wd,cH as $i,cI as xm,cJ as a0,cK as s0,Z as i0,X as o0,cL as l0,cM as c0,cN as d0,cO as u0,cP as h0,cQ as f0,bf as ms,bk as Pl,Q as Vu,aJ as Wu,cR as xd,cS as m0,cT as Fs,aQ as ym,cU as Gu,cV as p0,av as g0,au as x0,aX as y0,aY as b0,aZ as v0,a_ as _0,bK as bm,a$ as w0,cW as vm,ce as sc,cX as N0,aj as j0,ai as S0,cY as So,ag as Hi,cZ as L0,c_ as A0,c$ as k0,W as C0,af as P0,bm as ml,d0 as E0}from"./index-7KGHoeDr.js";import{U as _m,A as Ui}from"./AdminLayout-CaUScEvc.js";import{i as El,P as M0,u as I0,a as F0}from"./leadLifecycleStatus-Cpf6DILn.js";import{u as co}from"./useIntakeSettings-D556_ZIX.js";import{l as wm,L as T0,m as Nm,n as Gd,p as jm,q as Sm,d as Yd,r as D0,s as R0,I as B0,a as O0,t as q0,b as z0,v as Yu,w as Lm,k as Am,i as $0,x as H0,y as U0,z as V0,A as W0}from"./useRefiOpportunities-xnqZhytL.js";import{P as G0,u as Y0}from"./useLenders-BSWto4wD.js";import{A as Ku}from"./AdminUserSelect-DcgwlQt2.js";/**
3 * @license lucide-react v0.462.0 - ISC
4 *
5 * This source code is licensed under the ISC license.
6 * See the LICENSE file in the root directory of this source tree.
7 */const K0=zd("CircleDot",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]]);/**
8 * @license lucide-react v0.462.0 - ISC
9 *
10 * This source code is licensed under the ISC license.
11 * See the LICENSE file in the root directory of this source tree.
12 */const Q0=zd("Leaf",[["path",{d:"M11 20A7 7 0 0 1 9.8 6.1C15.5 5 17 4.48 19 2c1 2 2 4.18 2 8 0 5.5-4.78 10-10 10Z",key:"nnexq3"}],["path",{d:"M2 21c0-3 1.85-5.36 5.08-6C9.5 14.52 12 13 13 12",key:"mt58a7"}]]);/**
13 * @license lucide-react v0.462.0 - ISC
14 *
15 * This source code is licensed under the ISC license.
16 * See the LICENSE file in the root directory of this source tree.
17 */const J0=zd("Share2",[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]]),X0=e=>{const{user:t}=vi();return ha({queryKey:["lead-intake-scenarios",e],queryFn:async()=>{const{data:n,error:r}=await nt.from("lead_intake_scenarios").select("*").eq("lead_id",e).order("sort_order",{ascending:!0}).order("created_at",{ascending:!0});if(r)throw r;return n??[]},enabled:!!t&&!!e})},Z0=(e,t)=>{const{user:n}=vi(),r=ys(),{settings:s}=co(),i=!!n&&!!e&&!!t,c=ha({queryKey:["lead-assessment",e,t],queryFn:async()=>{const{data:$,error:D}=await nt.from("lead_financial_assessment").select("*").eq("lead_id",e).eq("scenario_id",t).maybeSingle();if(D)throw D;return $},enabled:i}),l=ha({queryKey:["lead-properties",e,t],queryFn:async()=>{const{data:$,error:D}=await nt.from("lead_properties").select("*").eq("lead_id",e).eq("scenario_id",t);if(D)throw D;return $},enabled:i}),d=ha({queryKey:["lead-debts",e,t],queryFn:async()=>{const{data:$,error:D}=await nt.from("lead_debts").select("*").eq("lead_id",e).eq("scenario_id",t);if(D)throw D;return $},enabled:i}),h=ha({queryKey:["lead-expenses",e,t],queryFn:async()=>{const{data:$,error:D}=await nt.from("lead_expenses").select("*").eq("lead_id",e).eq("scenario_id",t);if(D)throw D;return $},enabled:i}),f=()=>{r.invalidateQueries({queryKey:["lead-intake-scenarios",e]}
17),r.invalidateQueries({queryKey:["lead-assessment",e,t]}),r.invalidateQueries({queryKey:["lead-properties",e]}),r.invalidateQueries({queryKey:["lead-debts",e]}),r.invalidateQueries({queryKey:["lead-expenses",e]})},x=()=>{r.invalidateQueries({queryKey:["lead-intake-scenarios",e]}),r.invalidateQueries({queryKey:["lead-properties",e]}),r.invalidateQueries({queryKey:["lead-debts",e]}),r.invalidateQueries({queryKey:["lead-expenses",e]})},b=Bs({mutationFn:async $=>{if(!t)throw new Error("scenarioId is required");const D=r.getQueryData(["lead-assessment",e,t]);if(!(D!=null&&D.id)){const{data:I,error:k}=await nt.from("lead_financial_assessment").insert({lead_id:e,scenario_id:t,...$}).select("*").maybeSingle();if(k)throw k;if(!I)throw new Error("lead_financial_assessment insert did not return a row");return I}const{data:Y,error:N}=await nt.from("lead_financial_assessment").update($).eq("lead_id",e).eq("scenario_id",t).select("*").maybeSingle();if(N)throw N;if(!Y)throw new Error("No lead_financial_assessment row was updated — check RLS or that this scenario has an assessment row.");return Y},onSuccess:$=>{r.setQueryData(["lead-assessment",e,t],$),x()}}),m=Bs({mutationFn:async $=>{var se;if(!t)throw new Error("scenarioId is required");const D=e,Y=t,{data:N,error:I}=await nt.from("lead_properties").select("id, is_focus_property").eq("lead_id",D).eq("scenario_id",Y);if(I)throw I;const k=new Set((N??[]).map(K=>K.id)),L=(se=(N??[]).find(K=>K.is_focus_property))==null?void 0:se.id;if($.length===0){const{error:K}=await nt.from("lead_properties").delete().eq("lead_id",D).eq("scenario_id",Y);if(K)throw K;return}const H=new Set;for(const K of $){const{id:ae,...be}=K,Ne={lead_id:D,scenario_id:Y,property_type:be.property_type,classification:be.classification,estimated_value:Number(be.estimated_value),original_mortgage_balance:Number(be.original_mortgage_balance),outstanding_mortgage_balance:Number(be.outstanding_mortgage_balance),mortgage_payment:Number(be.mortgage_payment),mortgage_interest_rate:Number(be.mortgage_interest_rate),mortgage_term_years:Number(be.mortgage_term_years),rental_income:Number(be.rental_income),rental_expenses:Number(be.rental_expenses??0),monthly_taxes:Number(be.monthly_taxes??0),monthly_insurance:Number(be.monthly_insurance??0),monthly_pmi:Number(be.monthly_pmi??0),monthly_hoa:Number(be.monthly_hoa)||0,street_address:be.street_address,city:be.city,state:be.state,zip_code:be.zip_code,is_consolidated:!!be.is_consolidated,ignored:!!be.ignored};if(ae&&k.has(ae)){const{error:A}=await nt.from("lead_properties").update(Ne).eq("id",ae).eq("lead_id",D).eq("scenario_id",Y);if(A)throw A;H.add(ae)}else{const{data:A,error:E}=await nt.from("lead_properties").insert({...Ne,is_focus_property:k.size===0&&H.size===0}).select("id").single();if(E)throw E;A!=null&&A.id&&H.add(A.id)}}const te=[...k].filter(K=>!H.has(K));if(te.length>0){const{error:K}=await nt.from("lead_properties").delete().in("id",te).eq("lead_id",D).eq("scenario_id",Y);if(K)throw K}if(!L||!H.has(L)){const K=H.values().next().value;if(K){const{error:ae}=await nt.rpc("set_lead_intake_focus_property",{p_scenario_id:Y,p_property_id:K});if(ae)throw ae}}},onSuccess:f}),w=Bs({mutationFn:async $=>{if(!t)throw new Error("scenarioId is required");const{error:D}=await nt.rpc("set_lead_intake_focus_property",{p_scenario_id:t,p_property_id:$});if(D)throw D},onSuccess:()=>{r.invalidateQueries({queryKey:["lead-properties",e,t]}),r.invalidateQueries({queryKey:["lead-intake-scenario-versions",t]})}}),v=Bs({mutationFn:async $=>{if(!t)throw new Error("scenarioId is required");const D=e,Y=t,{data:N,error:I}=await nt.from("lead_debts").select("id").eq("lead_id",D).eq("scenario_id",Y);if(I)throw I;const k=new Set((N??[]).map(te=>te.id));if($.length===0){const{error:te}=await nt.from("lead_debts").delete().eq("lead_id",D).eq("scenario_id",Y);if(te)throw te;return}const L=new Set;for(const te of $){const{id:se,...K}=te,ae={lead_id:D,scenario_id:Y,debt_name:K.debt_name,debt_type:K.debt_type,current_balance:Number(K.current_balance),monthly_payment:Number(K.monthly_payment),interest_rate:Number(K.interest_rate),is_consolidated:!!K.is_consolidated,ignored:!!(K.ignored??!1)};if(se&&k.has(se)){const{error:be}=await nt.from("lead_debts").update(ae).eq("id",se).eq("lead_id",D).eq("scenario_id",Y);if(be)throw be;L.add(se)}else{const{data:be,error:Ne}=await nt.from("lead_debts").insert(ae).select("id").single();if(Ne)throw Ne;be!=null&&be.id&&L.add(be.id)}}const H=[...k].filter(te=>!L.has(te));if(H.length>0){const{error:te}=await nt.from("lead_debts").delete().in("id",H).eq("lead_id",D).eq("scenario_id",Y);if(te)throw te}},onSuccess:f}),P=Bs({mutationFn:async $=>{if(!t)throw new Error("scenarioId is required");await nt.from("lead_expenses").delete().eq("lead_id",e).eq("scenario_id",t);const D=$.filter(Y=>Y.amount>0);if(D.length>0){const Y=D.map(I=>({...I,lead_id:e,scenario_id:t})),{error:N}=await nt.from("lead_expenses").insert(Y);if(N)throw N}},onSuccess:f}),_=c.data??null,q=l.data??[],T=d.data??[],B=J.useMemo(()=>{const $=h.data??[];return am($,sm).filter(Y=>Number(Y.amount)>0).map(Y=>{var N;return{id:((N=$.find(I=>I.category===Y.category))==null?void 0:N.id)??`normalized-${Y.category}`,lead_id:e??"",scenario_id:t,category:Y.category,amount:Y.amount}})},[h.data,e,t]),me=wm(_,q,T,B,s,void 0,{cashflowDeploymentFraction:1,helocTermYearsDefault:10,chunkCadenceDays:30,maxSimulationMonths:600}),ce=i&&(c.isLoading||l.isLoading||d.isLoading||h.isLoading);return{assessment:_,properties:q,debts:T,expenses:B,metrics:me,isLoading:ce,updateAssessment:b,upsertProperties:m,setFocusProperty:w,upsertDebts:v,upsertExpenses:P}};function km(e,t){return`${e}:${t??""}`}function Cm(e,t){var r;const n=(r=e.program)==null?void 0:r.id;return n?km(e.lender.id,n):`${e.lender.id}:idx-${t??0}`}function e1(e){return e>=1?"bg-success/10 text-success border-success/20":e>=.7?"bg-warning/10 text-warning border-warning/20":"bg-destructive/10 text-destructive border-destructive/20"}function t1(e){return e>=1?"Full Match":e>=.7?"Partial Match":"Does Not Qualify"}
17const n1={heloc:"HELOC",ploc:"PLOC",home_equity_loan:"Home Equity Loan",other:"Other"},r1=({matches:e,leadStatus:t,selectionEnabled:n=!1,selectedKeys:r,onSelectionChange:s,selectionSaving:i=!1})=>{const[c,l]=J.useState(null),[d,h]=J.useState(new Set),f=El(t),x=(w,v)=>{v.stopPropagation(),h(P=>{const _=new Set(P);return _.has(w)?_.delete(w):_.add(w),_})};if(e.length===0)return a.jsx(rn,{children:a.jsx(on,{className:"py-8 text-center text-muted-foreground",children:"No active lender programs to match against. Add lenders and programs in the Lender Directory first."})});const b=n&&f&&!!s,m=new Set(e.filter(w=>w.lender.is_pinned&&w.lender.id!=null&&w.score>=T0).map(w=>w.lender.id));return a.jsxs("div",{className:"space-y-3",children:[!f&&a.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground px-1",children:[a.jsx(Rg,{className:"w-3.5 h-3.5"}),a.jsx("span",{children:"Lender names are hidden. Click a name to reveal it. Names auto-reveal when the record is a client."})]}),b&&a.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md border border-primary/20 bg-primary/5 px-3 py-2 text-xs text-muted-foreground",children:[a.jsxs("span",{children:["Check lenders to include them in the strategy report under ",a.jsx("strong",{className:"text-foreground",children:"Suggested Lenders"}),". Contact details come from the lender directory notes field."]}),i?a.jsx(Kr,{className:"h-3.5 w-3.5 shrink-0 animate-spin text-primary"}):null]}),e.map((w,v)=>{var me,ce,$,D;const P=Cm(w,v),_=(me=w.program)==null?void 0:me.id,q=((ce=w.program)==null?void 0:ce.program_name)??"Default",T=(($=w.program)==null?void 0:$.program_type)??"",B=f||d.has(P),Q=!!w.program.is_pinned||!!w.lender.is_pinned&&w.lender.id!=null&&m.has(w.lender.id);return a.jsx(rn,{children:a.jsxs(_i,{open:c===P,onOpenChange:Y=>l(Y?P:null),children:[a.jsx(wi,{className:"w-full",children:a.jsx($s,{className:"pb-2",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[b&&_?a.jsx(lo,{checked:(r==null?void 0:r.has(P))??!1,disabled:i,onCheckedChange:Y=>{s==null||s(w,v,Y===!0)},onClick:Y=>Y.stopPropagation(),"aria-label":`Include ${w.lender.name} in strategy report`,className:"shrink-0"}):null,a.jsx(Hs,{className:Et("text-base transition-all cursor-pointer",!B&&"blur-sm hover:blur-[3px] select-none"),onClick:Y=>{f||x(P,Y)},title:f?void 0:B?"Click to hide lender name":"Click to reveal lender name",children:w.lender.name}),a.jsxs(xn,{variant:"outline",className:"text-xs",children:[q," — ",n1[T]||T]}),Q?a.jsxs(xn,{variant:"secondary",className:"text-xs gap-1",children:[a.jsx(G0,{className:"w-3 h-3"}),"Pinned"]}):null,a.jsxs(xn,{className:e1(w.score),children:[t1(w.score)," (",w.metCriteria,"/",w.totalCriteria,")"]})]}),a.jsx(Ys,{className:`w-4 h-4 transition-transform flex-shrink-0 ${c===P?"rotate-180":""}`})]})})}),a.jsx(Ni,{children:a.jsxs(on,{className:"pt-0",children:[a.jsx("div",{className:"space-y-1",children:w.details.map((Y,N)=>a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[Y.informational?a.jsx(zo,{className:"w-4 h-4 text-muted-foreground flex-shrink-0"}):Y.passed?a.jsx(Bg,{className:"w-4 h-4 text-success flex-shrink-0"}):a.jsx(Kl,{className:"w-4 h-4 text-destructive flex-shrink-0"}),a.jsxs("span",{className:"font-medium w-28",children:[Y.criterion,":"]}),a.jsx("span",{className:"text-muted-foreground",children:Y.reason})]},N))}),w.lender.website_url&&a.jsxs("a",{href:w.lender.website_url,target:"_blank",rel:"noopener noreferrer",className:Et("inline-flex items-center gap-1 text-xs text-primary hover:underline mt-3",!B&&"blur-sm select-none pointer-events-none"),children:[a.jsx(im,{className:"w-3 h-3"}),"Visit Lender Website"]}),((D=w.program)==null?void 0:D.notes)&&a.jsx("p",{className:"text-xs text-muted-foreground mt-2 italic",children:w.program.notes})]})})]})},P)})]})},a1=({open:e,onOpenChange:t,lead:n,intakeScenarioId:r})=>{const[s,i]=J.useState(!1),{toast:c}=Ir(),l=ys(),d=async()=>{if(!r){c({title:"No scenario selected",description:"Select an intake scenario before promoting.",variant:"destructive"});return}i(!0);try{const{error:h}=await nt.functions.invoke("promote-lead-to-client",{body:{leadId:n.id,intakeScenarioId:r}});if(h)throw h;c({title:"Lead approved for signup!",description:`${n.first_name} ${n.last_name} can now sign up — their intake data will merge automatically.`}
17),l.invalidateQueries({queryKey:["leads"]}),t(!1)}catch(h){c({title:"Failed to promote lead",description:h.message,variant:"destructive"})}finally{i(!1)}};return a.jsx(Ql,{open:e,onOpenChange:t,children:a.jsxs(Jl,{children:[a.jsxs(Xl,{children:[a.jsx(Zl,{children:"Promote Lead to Client"}),a.jsxs(ec,{className:"space-y-2",children:[a.jsx("p",{children:"This will:"}),a.jsxs("ul",{className:"list-disc pl-5 space-y-1 text-sm",children:[a.jsxs("li",{children:["Approve ",a.jsx("strong",{children:n.email})," for signup"]}),a.jsxs("li",{children:["When they sign up, the financial snapshot for the ",a.jsx("strong",{children:"currently selected intake scenario"})," will be merged into their account (other scenarios stay for internal comparison only)."]}),a.jsxs("li",{children:["Mark this record as a ",a.jsx("strong",{children:"Client"})," (pending signup until they complete registration)"]})]}),a.jsx("p",{className:"text-sm mt-2",children:"No account is created yet — the client will sign up normally and their assessment data will be pre-populated automatically."}),a.jsxs("p",{className:"text-sm font-medium text-foreground pt-2 border-t border-border mt-3",children:["Are you sure you want to promote ",a.jsxs("strong",{children:[n.first_name," ",n.last_name]})," to a client now?"]})]})]}),a.jsxs(tc,{children:[a.jsx(om,{disabled:s,children:"Cancel"}),a.jsxs(Og,{onClick:d,disabled:s||!r,className:"bg-success hover:bg-success/90",children:[s?a.jsx(Kr,{className:"w-4 h-4 animate-spin mr-2"}):null,"Promote to Client"]})]})]})})},s1=new Set(["refer_pending","referred","sent_to_arive"]);function i1(e){var i;const t=[e.street_address,e.city].filter(Boolean).join(", "),n=((i=e.property_type)==null?void 0:i.replace(/_/g," "))||"property",r=Number(e.outstanding_mortgage_balance)||0,s=r>0?` · ${Dt(r)} bal`:"";return`${t||n}${s}`}function o1(e){if(!e.length)return"";const t=e.filter(s=>(Number(s.outstanding_mortgage_balance)||0)>=1e3),n=t.length?t:e;return(n.find(s=>s.property_type==="primary_residence")??n[0]).id}function l1({open:e,onOpenChange:t,product:n,lead:r,scenarioId:s,properties:i}){const{toast:c}=Ir(),{settings:l}=co(),{settings:d}=Nm(),{data:h=[]}=Gd({leadId:r.id}),f=jm(),x=Sm(),b=Yd(),[m,w]=J.useState(""),[v,P]=J.useState(!1);J.useEffect(()=>{e&&w(o1(i))},[e,i,n]);const _=J.useMemo(()=>{if(n)return h.find($=>$.source==="intake"&&($.referral_product??"refi")===n)},[h,n]),q=n==="hecm"?!!ud(l.hecm_partner_redirect_url):!!ud((d==null?void 0:d.partner_redirect_url)??""),T=J.useMemo(()=>{var D;const $=[];return(D=r.email)!=null&&D.trim()||$.push("Lead email is required to send the information-release."),s||$.push("Select an intake scenario before referring."),q||$.push(n==="hecm"?"Set the HECM post-signature redirect URL in Intake Settings.":"Set the refinance partner redirect URL in partner settings."),n==="refi"&&i.length===0&&$.push("Add at least one property before a refinance referral."),n==="hecm"&&i.length===0&&$.push("Add a primary residence before a HECM referral."),_&&s1.has(_.status)&&$.push(`A ${n==="hecm"?"HECM":"refinance"} referral is already ${_.status.replace(/_/g," ")}.`),$},[r.email,s,q,n,i.length,_]),B=n==="hecm"?"HECM":"refinance",Q=v||f.isPending||x.isPending||b.isPending,me=!!n&&T.length===0&&!Q&&(n!=="refi"||!!m),ce=async()=>{var $,D;if(!(!n||!s||!me)){P(!0);try{let Y;if(n==="refi"?Y=(($=(await f.mutateAsync({leadId:r.id,scenarioId:s,propertyId:m||void 0,manual:!0,quiet:!0})).opportunities[0])==null?void 0:$.id)??(_==null?void 0:_.id):Y=((D=(await x.mutateAsync({leadId:r.id,scenarioId:s,propertyId:m||void 0,snapshot:{manual:!0}})).opportunities[0])==null?void 0:D.id)??(_==null?void 0:_.id),!Y)throw new Error("Opportunity was not created.");await b.mutateAsync(Y),c({title:"Information-release email sent",description:`Manual ${B} referral started for ${r.first_name} ${r.last_name}.`}),t(!1)}catch(Y){c({title:"Manual refer failed",description:Y instanceof Error?Y.message:String(Y),variant:"destructive"})}finally{P(!1)}}};return a.jsx(Ql,{open:e,onOpenChange:t,children:a.jsxs(Jl,{children:[a.jsxs(Xl,{children:[a.jsxs(Zl,{children:["Are you sure you want to manually refer to ",B,"?"]}),a.jsx(ec,{asChild:!0,children:a.jsxs("div",{className:"space-y-3 text-sm text-muted-foreground",children:[a.jsx("p",{children:"This is a discretionary referral. Auto-screening may not have flagged this lead."}),a.jsxs("div",{className:"space-y-2 rounded-md border border-border/60 bg-muted/40 p-3 text-foreground",children:[a.jsx("p",{className:"font-medium",children:"What happens next"}),a.jsxs("ul",{className:"list-disc space-y-1.5 pl-5 text-muted-foreground",children:[a.jsxs("li",{children:[a.jsx("span",{className:"font-medium text-foreground",children:"You:"})," we email the information-release link to the lead and mark this ",B," referral as pending signature."]}),a.jsxs("li",{children:[a.jsx("span",{className:"font-medium text-foreground",children:"Prospect:"})," they open the email, review and sign the release, then continue to the"," ",B," partner."]})]})]}),n==="refi"&&i.length>1?a.jsxs("div",{className:"space-y-2 text-foreground",children:[a.jsx(Ke,{htmlFor:"manual-refer-property",children:"Property"}),a.jsxs(Ka,{value:m,onValueChange:w,children:[a.jsx(Qa,{id:"manual-refer-property",children:a.jsx(Ja,{placeholder:"Select property"})}),a.jsx(Xa,{children:i.map($=>a.jsx(Mr,{value:$.id,children:i1($)},$.id))})]})]}):null,T.length>0?a.jsx("ul",{className:"list-disc space-y-1 pl-5 text-destructive",children:T.map($=>a.jsx("li",{children:$},$))}):a.jsxs("p",{className:"text-foreground",children:["Send to ",a.jsx("strong",{children:r.email})," for"," ",a.jsxs("strong",{children:[r.first_name," ",r.last_name]}),"."]})]})})]}),a.jsxs(tc,{children:[a.jsx(om,{disabled:Q,children:"Cancel"}),a.jsxs(st,{type:"button",disabled:!me,onClick:()=>void ce(),children:[Q?a.jsx(Kr,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Send Information Release Email"]})]})]})})}function c1({leadId:e,disabled:t=!1}){var l;const n=D0(e),r=R0(),s=((l=n.data)==null?void 0:l.intake_status)??null,i=n.isError,c=d=>{q0(d)&&(d===s||r.isPending||r.mutate({leadId:e,intakeStatus:d}))};return a.jsxs(Ka,{value:s??void 0,onValueChange:c,disabled:t||n.isLoading||i||r.isPending||!s,children:[a.jsx(Qa,{"aria-label":"Intake status",className:"h-10 w-[168px] bg-background/90 shadow-sm","data-testid":"lead-intake-status",title:i?"Intake status is unavailable until the opportunities ownership migration is applied":"Sales intake status. Does not change the lead owner.",children:a.jsx(Ja,{placeholder:i?"Unavailable":"Intake status"})}),a.jsx(Xa,{children:B0.map(d=>a.jsx(Mr,{value:d,children:O0[d]},d))})]})}const Pm=J.createContext(null);function Kd(){return J.useContext(Pm)}function Ws(e,t,n,r){const s=Kd(),i=J.useRef(n),c=J.useRef(r);i.current=n,c.current=r,J.useEffect(()=>{if(!(!s||!t))return s.register(e,{save:()=>i.current(),discard:()=>c.current()})},[s,t,e])}function d1({children:e}){const t=J.useRef(new Map),n=J.useRef(null),[r,s]=J.useState(!1),[i,c]=J.useState(!1),l=J.useCallback((w,v)=>(t.current.set(w,v),()=>{t.current.delete(w)}),[]),d=J.useCallback(()=>t.current.size>0,[]),h=J.useCallback(()=>t.current.size===0?Promise.resolve(!0):(s(!0),new Promise(w=>{n.current=w})),[]),f=w=>{var v;(v=n.current)==null||v.call(n,w),n.current=null,s(!1),c(!1)},x=async()=>{c(!0);try{await Promise.all([...t.current.values()].map(w=>w.save())),f(!0)}catch{c(!1)}},b=()=>{for(const w of t.current.values())w.discard();f(!0)},m=J.useMemo(()=>({register:l,hasDirty:d,confirmLeave:h}),[l,d,h]);return a.jsxs(Pm.Provider,{value:m,children:[e,a.jsx(Ql,{open:r,onOpenChange:w=>!w&&!i&&f(!1),children:a.jsxs(Jl,{children:[a.jsxs(Xl,{children:[a.jsx(Zl,{children:"Unsaved intake edits"}),a.jsx(ec,{children:"Save or discard the section you are editing before leaving this scenario. Versions only capture what is already saved."})]}),a.jsxs(tc,{children:[a.jsx(st,{type:"button",variant:"ghost",disabled:i,onClick:()=>f(!1),children:"Stay"}),a.jsx(st,{type:"button",variant:"outline",disabled:i,onClick:b,children:"Discard"}),a.jsx(st,{type:"button",disabled:i,onClick:()=>void x(),children:"Save"})]})]})})]})}function mi(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Fo(e){return Array.isArray(e)?e.filter(mi):[]}function u1(e){return mi(e)?{id:String(e.id??""),name:String(e.name??""),selected_heloc_type:typeof e.selected_heloc_type=="string"?e.selected_heloc_type:null}:null}function Qu(e){const t=mi(e)?e:{};
17return{scenario:u1(t.scenario),assessment:mi(t.assessment)?t.assessment:null,properties:Fo(t.properties),debts:Fo(t.debts),expenses:Fo(t.expenses),calculator_results:Fo(t.calculator_results),ai_analysis:mi(t.ai_analysis)?t.ai_analysis:null}}function h1(e,t){if(!mi(e))return null;const n=mi(e.lead_contact)?{first_name:typeof e.lead_contact.first_name=="string"?e.lead_contact.first_name:null,last_name:typeof e.lead_contact.last_name=="string"?e.lead_contact.last_name:null,email:typeof e.lead_contact.email=="string"?e.lead_contact.email:null,phone:typeof e.lead_contact.phone=="string"?e.lead_contact.phone:null,notes:typeof e.lead_contact.notes=="string"?e.lead_contact.notes:null}:null,r=Array.isArray(e.scenarios)?e.scenarios.map(Qu):void 0,s=t&&r?r.find(l=>{var d;return((d=l.scenario)==null?void 0:d.id)===t}):void 0,i=Qu(e);return{...s??i,lead_contact:n,additional_clients:Fo(e.additional_clients),scenarios:r}}function f1(){return{scenario:null,assessment:null,properties:[],debts:[],expenses:[],calculator_results:[],ai_analysis:null,lead_contact:null,additional_clients:[]}}const m1=new Set(["created_at","updated_at","lead_id","scenario_id","admin_id","sort_order"]);function Ju(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Xu(e){return e===void 0||typeof e=="number"&&Number.isNaN(e)?null:e}function p1(e,t){const n=Xu(e),r=Xu(t);if(n===r||n==null&&r==null)return!0;if(typeof n=="number"||typeof r=="number"){const s=Number(n),i=Number(r);if(Number.isFinite(s)&&Number.isFinite(i)&&s===i)return!0}if(typeof n=="boolean"||typeof r=="boolean")return!!n==!!r&&n!=null&&r!=null;try{return JSON.stringify(n)===JSON.stringify(r)}catch{return!1}}function to(e,t,n){for(const[r,s]of Object.entries(t)){if(m1.has(r)||r==="id")continue;const i=e?`${e}.${r}`:r;if(r==="financial_deal_breakers"&&Ju(s)){for(const[c,l]of Object.entries(s))n.set(`${i}.${c}`,l??null);continue}if(Ju(s)&&r!=="debt_payoff_order"&&r!=="risks"&&r!=="recommendations"){to(i,s,n);continue}n.set(i,s??null)}}function pl(e,t,n,r="id"){for(const s of t){const i=s[r];i==null||String(i).length===0||to(`${e}[${String(i)}]`,s,n)}}function g1(e,t){var r;const n=new Map;for(const s of e){const i=String(s.category??""),c=n.get(i)??[];c.push(s),n.set(i,c)}for(const[s,i]of n){if(s&&i.length===1){t.set(`expenses[${s}]`,((r=i[0])==null?void 0:r.amount)??null);continue}for(const c of i){const l=c.id!=null?String(c.id):"";l&&t.set(`expenses[${l}]`,c.amount??null)}}}function Zu(e){const t=e??f1(),n=new Map;return t.scenario&&to("scenario",t.scenario,n),t.assessment&&to("assessment",t.assessment,n),pl("properties",t.properties,n),pl("debts",t.debts,n),g1(t.expenses,n),pl("calculator_results",t.calculator_results,n),t.ai_analysis&&to("ai_analysis",t.ai_analysis,n),t.lead_contact&&to("lead_contact",t.lead_contact,n),pl("additional_clients",t.additional_clients,n),n}function x1(e,t){const n=Zu(e),r=Zu(t),s=new Set([...n.keys(),...r.keys()]),i=[];for(const c of[...s].sort()){const l=n.has(c)?n.get(c):void 0,d=r.has(c)?r.get(c):void 0;p1(l,d)||i.push({path:c,oldValue:l,newValue:d})}return i}function y1(e){return new Map(e.map(t=>[t.path,t]))}function eh(e,t){return e.filter(n=>n.path===t||n.path.startsWith(`${t}.`)||n.path.startsWith(`${t}[`))}function th(e){if(e===void 0)return"(missing)";if(e===null||e==="")return"(empty)";if(typeof e=="boolean")return e?"Yes":"No";if(typeof e=="number")return Number.isFinite(e)?String(e):"(empty)";if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return String(e)}}function Kt({path:e,highlights:t,children:n,className:r}){const s=t==null?void 0:t.get(e);return s?a.jsx(hd,{delayDuration:200,children:a.jsxs(Ol,{children:[a.jsx(ql,{asChild:!0,children:a.jsx("div",{className:Et("rounded-sm bg-warning/20 ring-1 ring-warning/40",r),"data-intake-highlight":e,children:n})}),a.jsxs(zl,{className:"max-w-xs text-xs",children:["was ",th(s.oldValue)," → now ",th(s.newValue)]})]})}):a.jsx(a.Fragment,{children:n})}const b1=({lead:e,statusBadge:t,readOnly:n=!1,highlights:r})=>{const[s,i]=J.useState(!1),[c,l]=J.useState(e.first_name),[d,h]=J.useState(e.last_name),[f,x]=J.useState(e.email),[b,m]=J.useState(e.phone??""),[w,v]=J.useState(!1),P=ys(),{toast:_}=Ir(),q=()=>{l(e.first_name),h(e.last_name),x(e.email),m(e.phone??""),i(!0)},T=async()=>{var Q;const B=qg.safeParse({firstName:c,lastName:d,email:f,phone:b});if(!B.success){_({title:"Validation error",description:((Q=B.error.issues[0])==null?void 0:Q.message)??"Invalid input",variant:"destructive"});return}v(!0);try{const{error:me}=await nt.from("leads").update({first_name:c,last_name:d,email:f,phone:b||null}).eq("id",e.id);if(me)throw me;P.invalidateQueries({queryKey:["leads"]}),i(!1),_({title:"Contact info updated"})}catch(me){_({title:"Failed to save",description:me.message,variant:"destructive"})}finally{v(!1)}};return Ws("contact",s,T,()=>i(!1)),s?a.jsxs("div",{className:"flex-1 space-y-2",children:[a.jsxs("div",{className:"grid grid-cols-2 gap-2 max-w-md",children:[a.jsxs("div",{children:[a.jsx(Ke,{className:"text-xs",children:"First Name"}),a.jsx(Wt,{value:c,onChange:B=>l(B.target.value),className:"h-8"})]}),a.jsxs("div",{children:[a.jsx(Ke,{className:"text-xs",children:"Last Name"}),a.jsx(Wt,{value:d,onChange:B=>h(B.target.value),className:"h-8"})]}),a.jsxs("div",{children:[a.jsx(Ke,{className:"text-xs",children:"Email"}),a.jsx(Wt,{type:"email",value:f,onChange:B=>x(B.target.value),className:"h-8"})]}),a.jsxs("div",{children:[a.jsx(Ke,{className:"text-xs",children:"Phone"}),a.jsx(Wt,{type:"tel",value:b,onChange:B=>m(B.target.value),className:"h-8"})]})]}),a.jsxs("div",{className:"flex gap-1",children:[a.jsxs(st,{size:"sm",className:"h-7 text-xs",onClick:T,disabled:w,children:[a.jsx(Us,{className:"w-3 h-3 mr-1"})," Save"]}),a.jsxs(st,{size:"sm",variant:"ghost",className:"h-7 text-xs",onClick:()=>i(!1),children:[a.jsx(Vs,{className:"w-3 h-3 mr-1"})," Cancel"]})]})]}):a.jsxs("div",{className:"flex-1",children:[a.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a.jsx(Kt,{path:"lead_contact.first_name",highlights:r,children:a.jsxs("h1",{className:"text-2xl font-bold text-foreground",children:[e.first_name," ",e.last_name]})}),t,!n&&a.jsx(st,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:q,children:a.jsx(gi,{className:"w-3.5 h-3.5 text-muted-foreground"})})]}),a.jsx(Kt,{path:"lead_contact.email",highlights:r,children:a.jsxs("p",{className:"text-sm text-muted-foreground",children:[e.email," ",e.phone?`• ${e.phone}`:""]})})]})},nh=e=>e.firstName||e.lastName?`${e.firstName} ${e.lastName}`.trim():e.relationship,v1="Most HELOC guidelines require full documentation, with limited statement-based options. Verify income using two-year tax history AGI and applicable Add Backs.",_1="Most HELOC guidelines require full documentation, verify income using W2 income documents or tax returns for the last 2 years.";function rh({selfEmployed:e}){const t=e?v1:_1;return a.jsxs("div",{role:"note",className:"mb-3 flex gap-2.5 rounded-lg border border-blue-200 bg-blue-50 p-3 text-sm font-normal text-blue-950 shadow-sm dark:border-blue-800/80 dark:bg-blue-950/35 dar
17k:text-blue-50",children:[a.jsx(zo,{className:"mt-0.5 size-4 shrink-0 text-blue-600 dark:text-blue-400","aria-hidden":!0}),a.jsx("p",{className:"min-w-0 leading-snug",children:t})]})}function ah({baseMonthly:e,formatCurrency:t,className:n}){return a.jsxs("div",{className:Et("text-sm",n),children:[a.jsx("p",{className:"text-muted-foreground text-xs",children:"Adjusted Monthly Gross (for DTI)"}),a.jsxs("p",{className:"font-bold text-primary tabular-nums",children:[t(e),"/mo"]})]})}const w1=({assessment:e,onSave:t,formatCurrency:n,primaryClientName:r="Primary",additionalClients:s=[],onSaveClientFields:i,readOnly:c=!1,highlights:l})=>{const[d,h]=J.useState(!1),[f,x]=J.useState(!1),{toast:b}=Ir(),[m,w]=J.useState({is_self_employed:(e==null?void 0:e.is_self_employed)??!1,most_recent_year_gross:(e==null?void 0:e.most_recent_year_gross)??(e==null?void 0:e.yearly_gross_income)??0,prior_year_gross:(e==null?void 0:e.prior_year_gross)??(e==null?void 0:e.yearly_gross_income)??0,added_gross_income:(e==null?void 0:e.added_gross_income)??0,monthly_net_income:(e==null?void 0:e.monthly_net_income)??0,savings_balance:(e==null?void 0:e.savings_balance)??0,retirement_balance:(e==null?void 0:e.retirement_balance)??0,additional_notes:(e==null?void 0:e.additional_notes)??""}),[v,P]=J.useState({}),_=J.useMemo(()=>(m.most_recent_year_gross+m.prior_year_gross)/24,[m.most_recent_year_gross,m.prior_year_gross]),q=J.useMemo(()=>_+m.added_gross_income,[_,m.added_gross_income]),T=(e==null?void 0:e.most_recent_year_gross)??(e==null?void 0:e.yearly_gross_income)??0,B=(e==null?void 0:e.prior_year_gross)??(e==null?void 0:e.yearly_gross_income)??0,Q=(e==null?void 0:e.added_gross_income)??0,me=(T+B)/24,ce=me+Q,$=s.length>0,D=((e==null?void 0:e.monthly_net_income)??0)+s.reduce((H,te)=>H+te.monthlyNetIncome,0),Y=()=>{w({is_self_employed:(e==null?void 0:e.is_self_employed)??!1,most_recent_year_gross:(e==null?void 0:e.most_recent_year_gross)??(e==null?void 0:e.yearly_gross_income)??0,prior_year_gross:(e==null?void 0:e.prior_year_gross)??(e==null?void 0:e.yearly_gross_income)??0,added_gross_income:(e==null?void 0:e.added_gross_income)??0,monthly_net_income:(e==null?void 0:e.monthly_net_income)??0,savings_balance:(e==null?void 0:e.savings_balance)??0,retirement_balance:(e==null?void 0:e.retirement_balance)??0,additional_notes:(e==null?void 0:e.additional_notes)??""});const H={};s.forEach(te=>{H[te.id]={income:te.monthlyNetIncome,savings:te.savingsBalance,retirement:te.retirementBalance}}),P(H),h(!0)},N=async()=>{x(!0);try{const H=q*12;if(await t({is_self_employed:m.is_self_employed,yearly_gross_income:H,most_recent_year_gross:m.most_recent_year_gross,prior_year_gross:m.prior_year_gross,added_gross_income:m.added_gross_income,monthly_net_income:m.monthly_net_income,savings_balance:m.savings_balance,retirement_balance:m.retirement_balance,additional_notes:m.additional_notes||null}),i)for(const[te,se]of Object.entries(v)){const K=s.find(ae=>ae.id===te);K&&(K.monthlyNetIncome!==se.income||K.savingsBalance!==se.savings||K.retirementBalance!==se.retirement)&&await i(te,{monthly_net_income:se.income,savings_balance:se.savings,retirement_balance:se.retirement})}h(!1),b({title:"Income & Assets updated"})}catch(H){b({title:"Failed to save",description:H instanceof Error?H.message:"Something went wrong",variant:"destructive"})}finally{x(!1)}};Ws("income-assets",d,N,()=>h(!1));const I=(H,te)=>w(se=>({...se,[H]:te})),k=(H,te,se)=>P(K=>({...K,[H]:{...K[H],[te]:se}})),L=m.monthly_net_income+Object.values(v).reduce((H,te)=>H+(Number(te.income)||0),0);return a.jsxs("section",{children:[a.jsxs("h2",{className:"mb-3 flex items-center gap-2 text-xl font-semibold tracking-tight text-foreground",children:[a.jsx(zg,{className:"w-5 h-5 text-primary"}),"Income & Assets",!d&&!c&&a.jsx(st,{variant:"ghost",size:"icon",className:"ml-auto h-7 w-7",onClick:Y,"aria-label":"Edit income and assets",children:a.jsx(gi,{className:"w-3.5 h-3.5 text-muted-foreground"})})]}),a.jsx(rn,{className:"rounded-2xl border-border/70 shadow-sm",children:a.jsx(on,{className:"p-4",children:d?a.jsxs("div",{className:"space-y-3",children:[a.jsx(rh,{selfEmployed:m.is_self_employed}),a.jsxs("div",{className:"flex items-center justify-between gap-4 pb-3 border-b border-border",children:[a.jsx(Ke,{htmlFor:"income-assets-self-employed",className:"text-sm font-medium cursor-pointer",children:"Self-Employed?"}),a.jsx(Ga,{id:"income-assets-self-employed",checked:m.is_self_employed,onCheckedChange:H=>I("is_self_employed",H)})]}),a.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:[a.jsxs("div",{children:[a.jsx(Ke,{className:"text-xs",children:"Most Recent Year Gross ($)"}),a.jsx(Er,{className:"h-8",value:m.most_recent_year_gross,onValueChange:H=>I("most_recent_year_gross",H)})]}),a.jsxs("div",{children:[a.jsx(Ke,{className:"text-xs",children:"Prior Year Gross ($)"}),a.jsx(Er,{className:"h-8",value:m.prior_year_gross,onValueChange:H=>I("prior_year_gross",H)})]}),a.jsxs("div",{children:[a.jsxs(Ke,{className:"text-xs flex items-center gap-1",children:["24-Mo Avg Monthly Gross",a.jsx(xn,{variant:"secondary",className:"text-[10px] px-1 py-0 h-4",children:"Auto"})]}),a.jsx(Wt,{type:"text",className:"h-8 bg-muted tabular-nums",value:Dt(_),readOnly:!0,disabled:!0})]}),a.jsxs("div",{children:[a.jsx(hd,{children:a.jsxs(Ol,{children:[a.jsx(ql,{asChild:!0,children:a.jsxs(Ke,{className:"text-xs flex items-center gap-1 cursor-help",children:["Additional Qualifiable Income ($/mo)",a.jsx(zo,{className:"w-3 h-3 text-muted-foreground"})]})}),a.jsx(zl,{className:"max-w-xs text-xs",children:"Use this field to add qualifying income not reflected in tax returns — such as business add-backs and non-taxable income. Year-gross is Line 11 AGI as-is. Do not add property rent again for DTI. Rent fields stay for cashflow and for rental housing costs on the DTI debt side."})]})}),a.jsx(Er,{className:"h-8",value:m.added_gross_income,onValueChange:H=>I("added_gross_income",H)})]})]}),a.jsx("div",{className:"p-2 bg-muted rounded-md",children:a.jsx(ah,{baseMonthly:q,formatCurrency:Dt})}),a.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[a.jsxs("div",{children:[a.jsxs(Ke,{className:"text-xs",children:[r,"'s Net Income ($)"]}),a.jsx(Er,{className:"h-8",value:m.monthly_net_income,onValueChange:H=>I("monthly_net_income",H)})]}),a.jsxs("div",{children:[a.jsxs(Ke,{className:"text-xs",children:["Savings (",r.split(" ")[0],") ($)"]}),a.jsx(Er,{className:"h-8",value:m.savings_balance,onValueChange:H=>I("savings_balance",H)})]}),a.jsxs("div",{children:[a.jsxs(Ke,{className:"text-xs",children:["Retirement (",r.split(" ")[0],") ($)"]}),a.jsx(Er,{className:"h-8",value:m.retirement_balance,onValueChange:H=>I("retirement_balance",H)})]})]}),s.map(H=>{const te=nh(H),se=H.firstName||H.relationship,K=v[H.id]??{income:H.monthlyNetIncome,savings:H.savingsBalance,retirement:H.retirementBalance};return a.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[a.jsxs("div",{children:[a.jsxs(Ke,{className:"text-xs",children:[te,"'s Net Income ($)"]}),a.jsx(Er,{className:"h-8",value:K.income,onValueChange:ae=>k(H.id,"income",ae)})]}),a.jsxs("div",{children:[a.jsxs(Ke,{className:"text-xs",children:["Savings (",se,") ($)"]}),a.jsx(Er,{className:"h-8",value:K.savings,onValueChange:ae=>k(H.id,"savings",ae)})]}),a.jsxs("div",{children:[a.jsxs(Ke,{className:"text-xs",children:["Retirement (",se,") ($)"]}),a.jsx(Er,{className:"h-8",value:K.retirement,onValueChange:ae=>k(H.id,"retirement",ae)})]})]},H.id)}),$&&a.jsx("div",{className:"grid grid-cols-3 gap-3",children:a.jsxs("div",{children:[a.jsxs(Ke,{className:"text-xs flex items-center gap-1",children:["Total Avg Monthly Net Income",a.jsx(xn,{variant:"secondary",className:"text-[10px] px-1 py-0 h-4",children:"Auto"})]}),a.jsx(Wt,{type:"text",className:"h-8 bg-muted tabular-nums",value:Dt(L),readOnly:!0,disabled:!0})]})}),a.jsxs("div",{className:"border-t pt-4 mt-2 space-y-2",children:[a.jsx(Ke,{className:"text-sm font-medium",children:"Additional notes"}),a.jsxs("p",{className:"text-xs text-muted-foreground",children:['Same field as the public financial assessment ("Anything else we should know…"). Saved with'," ",a.jsx("span",{className:"font-medium text-foreground",children:"Save"})," below."]}),a.jsx($g,{value:m.additional_notes,onChange:H=>I("additional_notes",H.target.value),placeholder:"Anything else we should know about your financial situation?",rows:4})]}),a.jsxs("div",{className:"flex gap-1 pt-2",children:[a.jsxs(st,{size:"sm",className:"h-7 text-xs",onClick:N,disabled:f,children:[a.jsx(Us,{className:"w-3 h-3 mr-1"})," Save"]}),a.jsxs(st,{size:"sm",variant:"ghost",className:"h-7 text-xs",onClick:()=>h(!1),children:[a.jsx(Vs,{className:"w-3 h-3 mr-1"})," Cancel"]})]})]}):a.jsxs(a.Fragment,{children:[a.jsx(rh,{selfEmployed:!!(e!=null&&e.is_self_employed)}),a.jsxs("div",{className:"flex items-center justify-between gap-4 pb-3 mb-3 border-b border-border text-sm",children:[a.jsx("span",{className:"text-muted-foreground",children:"Self-Employed"}),a.jsx(Kt,{path:"assessment.is_self_employed",highlights:l,children:a.jsx("span",{className:"font-semibold text-foreground",children:e!=null&&e.is_self_employed?"Yes":"No"})})]}),a.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 text-sm",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-muted-foreground",children:"Most Recent Year Gross"}),a.jsx(Kt,{path:"assessment.most_recent_year_gross",highlights:l,children:a.jsx("p",{className:"font-semibold",children:n(T)})})]}),a.jsxs("div",{children:[a.jsx("p",{className:"text-muted-foreground",children:"Prior Year Gross"}),a.jsx(Kt,{path:"assessment.prior_year_gross",highlights:l,children:a.jsx("p",{className:"font-semibold",children:n(B)})})]}),a.jsxs("div",{children:[a.jsxs("p",{className:"text-muted-foreground flex items-center gap-1",children:["24-Mo Avg Monthly Gross",a.jsx(xn,{variant:"secondary",className:"text-[10px] px-1 py-0 h-4",children:"Auto"})]}),a.jsx("p",{className:"font-semibold",children:n(me)})]}),a.jsxs("div",{children:[a.jsx(hd,{children:a.jsxs(Ol,{children:[a.jsx(ql,{asChild:!0,children:a.jsxs("p",{className:"text-muted-foreground flex items-center gap-1 cursor-help",children:["Additional Qualifiable Income",a.jsx(zo,{className:"w-3 h-3"})]})}),a.jsx(zl,{className:"max-w-xs text-xs",children:"Use this field to add qualifying income not reflected in tax returns — such as business add-backs and non-taxable income. Year-gross is Line 11 AGI as-is. Do not add property rent again for DTI. Rent fields stay for cashflow and for rental housing costs on the DTI debt side."})]})}),a.jsx(Kt,{path:"assessment.added_gross_income",highlights:l,children:a.jsxs("p",{className:"font-semibold",children:[n(Q),"/mo"]})})]})]}),a.jsx("div",{className:"border-t pt-2 mt-3 mb-3",children:a.jsx(ah,{baseMonthly:ce,formatCurrency:n})}),a.jsxs("div",{className:"space-y-3 text-sm",children:[a.jsx("div",{className:"border-t pt-2",children:a.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[a.jsxs("div",{children:[a.jsxs("p",{className:"text-muted-foreground",children:[r,"'s Net Income"]}),a.jsx(Kt,{path:"assessment.monthly_net_income",highlights:l,children:a.jsx("p",{className:"font-semibold",children:n((e==null?void 0:e.monthly_net_income)??0)})})]}),a.jsxs("div",{children:[a.jsxs("p",{className:"text-muted-foreground",children:["Savings (",r.split(" ")[0],")"]}),a.jsx(Kt,{path:"assessment.savings_balance",highlights:l,children:a.jsx("p",{className:"font-semibold",children:n((e==null?void 0:e.savings_balance)??0)})})]}),a.jsxs("div",{children:[a.jsxs("p",{className:"text-muted-foreground",children:["Retirement (",r.split(" ")[0],")"]}),a.jsx(Kt,{path:"assessment.retirement_balance",highlights:l,children:a.jsx("p",{className:"font-semibold",children:n((e==null?void 0:e.retirement_balance)??0)})})]})]})}),s.map(H=>{const te=nh(H),se=H.firstName||H.relationship;return a.jsx("div",{className:"border-t pt-2",children:a.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[a.jsxs("div",{children:[a.jsxs("p",{className:"text-muted-foreground",children:[te,"'s Net Income"]}),a.jsx(Kt,{path:`additional_clients[${H.id}].monthly_net_income`,highlights:l,children:a.jsx("p",{className:"font-semibold",children:n(H.monthlyNetIncome)})})]}),a.jsxs("div",{children:[a.jsxs("p",{className:"text-muted-foreground",children:["Savings (",se,")"]}),a.jsx(Kt,{path:`additional_clients[${H.id}].savings_balance`,highlights:l,children:a.jsx("p",{className:"font-semibold",children:n(H.savingsBalance)})})]}),a.jsxs("div",{children:[a.jsxs("p",{className:"text-muted-foreground",children:["Retirement (",se,")"]}),a.jsx(Kt,{path:`additional_clients[${H.id}].retirement_balance`,highlights:l,children:a.jsx("p",{className:"font-semibold",children:n(H.retirementBalance)})})]})]})},H.id)}),$&&a.jsx("div",{className:"border-t pt-2",children:a.jsx("div",{className:"grid grid-cols-3 gap-4",children:a.jsxs("div",{children:[a.jsxs("p",{className:"text-muted-foreground flex items-center gap-1",children:["Total Avg Monthly Net Income",a.jsx(xn,{variant:"secondary",className:"text-[10px] px-1 py-0 h-4",children:"Auto"})]}),a.jsx("p",{className:"font-bold text-primary",children:n(D)})]})})})]}),(e==null?void 0:e.additional_notes)&&a.jsxs("div",{className:"mt-4 p-3 bg-muted rounded-lg",children:[a.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Additional notes"}),a.jsx(Kt,{path:"assessment.additional_notes",highlights:l,children:a.jsx("p",{className:"text-sm whitespace-pre-wrap",children:e.additional_notes})})]})]})})})]})},N1="https://developers.google.com/static/maps/documentation/images/powered_by_google_on_white.png";function yd(e){const t=e.context;return t&&typeof t=="object"&&"name"in t&&t.name==="AbortError"?!0:t instanceof DOMException&&t.name==="AbortError"}function Cc(e){if(e instanceof fd){if(yd(e))return"";const t=e.context;return t instanceof Error?`${e.message}: ${t.message}`:t&&typeof t=="object"&&"message"in t&&typeof t.message=="string"?`${e.message}: ${t.message}`:e.message}if(e instanceof Hg){const t=e.context,n=t==null?void 0:t.status;return typeof n=="number"?`${e.message} (HTTP ${n})`:e.message}return e instanceof Error?e.message:"Could not load suggestions"}function j1({id:e,label:t,street:n,onStreetChange:r,onPlaceResolved:s,placeholder:i="Optional",className:c,inputClassName:l}){const{toast:d}=Ir(),h=J.useRef(null),f=J.useRef(null),x=J.useRef(null),b=J.useRef(0),m=J.useRef(null),w=J.useRef(null),[v,P]=J.useState(!1),[_,q]=J.useState(!1),[T,B]=J.useState([]),Q=J.useCallback(()=>{x.current||(x.current=crypto.randomUUID())},[]),me=J.useCallback(()=>{x.current=crypto.randomUUID()},[]),ce=J.useCallback(async Y=>{var L;const N=Y.trim();if(N.length<3){B([]);return}(L=m.current)==null||L.abort();const I=new AbortController;m.current=I;const k=++b.current;Q(),q(!0);try{const{data:H,error:te}=await nt.functions.invoke("places-address",{body:{action:"suggest",input:N,sessionToken:x.current},signal:I.signal});if(k!==b.current)return;if(te){if(te instanceof fd&&yd(te))return;throw te}if(H!=null&&H.error){if(String(H.error).includes("GOOGLE_MAPS_API_KEY")){B([]);return}throw new Error(String(H.error))}const se=(H==null?void 0:H.suggestions)??[];B(Array.isArray(se)?se:[])}catch(H){if(k!==b.current)return;console.error("places suggest:",H),B([]);const te=Cc(H);if(!te)return;const se=`Address lookup failed|${te}`,K=Date.now(),ae=w.current;if((ae==null?void 0:ae.key)===se&&K-ae.at<2800)return;w.current={key:se,at:K},d({title:"Address lookup failed",description:te,variant:"destructive"})}finally{k===b.current&&q(!1)}},[Q,d]);J.useEffect(()=>()=>{f.current&&clearTimeout(f.current)},[]),J.useEffect(()=>{if(!v)return;const Y=N=>{h.current&&!h.current.contains(N.target)&&P(!1)};return document.addEventListener("mousedown",Y),()=>document.removeEventListener("mousedown",Y)},[v]);const $=Y=>{r(Y),P(!0),f.current&&clearTimeout(f.current),f.current=setTimeout(()=>void ce(Y),350)},D=async Y=>{P(!1),B([]);try{const{data:N,error:I}=await nt.functions.invoke("places-address",{body:{action:"details",placeId:Y.placeId}});if(I){if(I instanceof fd&&yd(I))return;throw new Error(Cc(I))}if(N!=null&&N.error)throw new Error(String(N.error));const k=String((N==null?void 0:N.street_address)??"").trim(),L=String((N==null?void 0:N.city)??"").trim(),H=String((N==null?void 0:N.state)?
17?"").trim(),te=String((N==null?void 0:N.zip_code)??"").trim();if(!k&&!L&&!H&&!te){d({title:"Could not read address",description:"Try another result or enter manually.",variant:"destructive"});return}s({street_address:k||n,city:L,state:H,zip_code:te}),me()}catch(N){console.error("places details:",N);const I=Cc(N)||"Could not load place details";d({title:"Address details failed",description:I,variant:"destructive"})}};return a.jsxs("div",{ref:h,className:Et("relative min-w-0",c),children:[t?a.jsx(Ke,{htmlFor:e,className:"text-xs",children:t}):null,a.jsx(Wt,{id:e,className:Et("h-8",l),placeholder:i,value:n,autoComplete:"off",onChange:Y=>$(Y.target.value),onFocus:()=>{Q(),P(!0),n.trim().length>=3&&ce(n)},onKeyDown:Y=>{Y.key==="Escape"&&P(!1)}}),v&&(_||T.length>0)&&a.jsxs("div",{className:"absolute z-50 mt-1 w-full min-w-[260px] max-w-[min(100vw-2rem,28rem)] rounded-md border border-border bg-popover text-popover-foreground shadow-md",role:"listbox","aria-label":"Address suggestions",children:[_&&a.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-xs text-muted-foreground",children:[a.jsx(Kr,{className:"h-3.5 w-3.5 animate-spin"}),"Searching…"]}),a.jsx("ul",{className:"max-h-56 overflow-y-auto py-1",children:T.map(Y=>a.jsx("li",{children:a.jsx("button",{type:"button",role:"option",className:"w-full px-3 py-2 text-left text-xs hover:bg-muted",onMouseDown:N=>N.preventDefault(),onClick:()=>void D(Y),children:Y.description})},Y.placeId))}),a.jsx("div",{className:"border-t border-border px-2 py-1.5",children:a.jsx("img",{src:N1,alt:"Powered by Google",className:"h-3.5 w-auto opacity-90",width:72,height:12})})]})]})}const Em={secondHomeBps:50,investmentBps:100};function S1(e,t){const n=`${t??""} ${e??""}`.toLowerCase().trim();return n.includes("invest")||n.includes("rental")||n.includes("commercial")?"investment":n.includes("second")||n.includes("vacation")||n.includes("secondary")?"second_home":"primary"}function L1(e,t=Em){return e==="second_home"?Math.max(0,Number(t.secondHomeBps)||0):e==="investment"?Math.max(0,Number(t.investmentBps)||0):0}function sh(e,t,n){if(e<=0||n<=0)return 0;const r=t/100/12;if(r<=0)return e/n;const s=Math.pow(1+r,n);return e*r*s/(s-1)}function A1(e,t,n){const r=e>0&&e<=180,s=t.find(l=>l.productKey==="15YRFRM"),i=t.find(l=>l.productKey==="30YRVA"),c=t.find(l=>l.productKey==="30YRFRM");return r&&s?s:n!=null&&n.preferVa&&i?i:c||s||(t[0]??null)}function k1(e,t,n,r){if(e<=0)return 0;const s=t/100/12;if(n>.01&&s>0&&n>e*s){const c=Math.log(n/(n-s*e))/Math.log(1+s);if(Number.isFinite(c)&&c>0&&c<600)return Math.ceil(c)}const i=Math.max(1,Number(r)||30);return Math.round(i*12)}function C1(e,t,n,r="and"){const s=e>=n.minMonthlySavings,i=t>=n.minRateSpread;return r==="or"?s||i:s&&i}function P1(e){const t=(e.property_type||"property").replace(/_/g," "),n=[e.street_address,e.city,e.state].filter(Boolean).join(", ");return n?`${t} — ${n}`:t}function E1(e,t,n,r){const s=Math.max(0,Number(e.outstanding_mortgage_balance)||0),i=Math.max(0,Number(e.mortgage_interest_rate)||0),c=Math.max(0,Number(e.mortgage_payment)||0);if(s<1e3||i<=0)return null;const l=k1(s,i,c,e.mortgage_term_years),d=A1(l,t,r);if(!d)return null;const h=(r==null?void 0:r.occupancy)??S1(e.property_type,e.classification),f=(r==null?void 0:r.occupancyAddons)??Em,x=L1(h,f),b=d.rate+x/100,m=sh(s,b,l),w=c>.01?c:sh(s,i,l),v=w-m,P=i-b,_=C1(v,P,n,(r==null?void 0:r.thresholdMode)??"and");return{propertyId:e.id,propertyType:e.property_type,propertyClassification:e.classification,currentBalance:Lo(s),currentRate:Pc(i),currentPayment:Lo(w),remainingTermMonths:l,marketProductKey:d.productKey,marketProductName:d.productName,marketRate:Pc(b),baseMarketRate:Pc(d.rate),marketRateAddonBps:Lo(x),estimatedRefiPayment:Lo(m),estimatedMonthlySavings:Lo(v),meetsThreshold:_,label:P1(e)}}function Lo(e){return Math.round(e*100)/100}function Pc(e){return Math.round(e*1e4)/1e4}function M1({property:e,leadId:t,scenarioId:n,isMilitaryVeteran:r=!1}){const{data:s}=z0(),{settings:i}=Nm(),{data:c=[]}=Gd({leadId:t}),l=jm(),d=Yd(),[h,f]=J.useState(!1),x=Math.max(0,Number(e.mortgage_interest_rate)||0),m=Math.max(0,Number(e.outstanding_mortgage_balance)||0)>=1e3&&x>0,w=J.useMemo(()=>((s==null?void 0:s.rates)??[]).map(ce=>({productKey:ce.product_key,productName:ce.product_name,rate:Number(ce.rate)})),[s==null?void 0:s.rates]),v=J.useMemo(()=>({minMonthlySavings:Number((i==null?void 0:i.min_monthly_savings)??100),minRateSpread:Number((i==null?void 0:i.min_rate_spread)??.5)}),[i]),P=J.useMemo(()=>({secondHomeBps:Number((i==null?void 0:i.second_home_rate_addon_bps)??50),investmentBps:Number((i==null?void 0:i.investment_rate_addon_bps)??100)}),[i]),_=J.useMemo(()=>!m||w.length===0?null:E1(e,w,v,{preferVa:r,occupancyAddons:P}),[m,w,e,v,P,r]),q=J.useMemo(()=>c.find(ce=>ce.source==="intake"&&(ce.referral_product??"refi")==="refi"),[c]);if(!_||_.estimatedMonthlySavings<=0)return null;const T=`Save ~${Dt(_.estimatedMonthlySavings)}/mo @ ${_.marketRate.toFixed(2)}%`,B=l.isPending||d.isPending,Q=B||!n||(q==null?void 0:q.status)==="sent_to_arive"||(q==null?void 0:q.status)==="refer_pending",me=async()=>{var D;if(!n)return;const $=((D=(await l.mutateAsync({leadId:t,scenarioId:n,propertyId:e.id,quiet
17:!0})).opportunities[0])==null?void 0:D.id)??(q==null?void 0:q.id);$&&(await d.mutateAsync($),f(!1))};return a.jsxs($d,{open:h,onOpenChange:f,children:[a.jsx(Hd,{asChild:!0,children:a.jsx("button",{type:"button",className:"outline-none",children:a.jsx(xn,{variant:"outline",className:Et("cursor-pointer rounded-full px-2.5 py-0.5 text-xs font-medium transition-colors hover:opacity-90",_.meetsThreshold?"border-emerald-500/30 bg-emerald-500/10 text-emerald-800 dark:text-emerald-200":"border-border bg-muted/60 text-muted-foreground"),children:T})})}),a.jsxs(Ud,{align:"start",className:"w-80 space-y-3",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm font-semibold text-foreground",children:"Refinance snapshot"}),a.jsxs("p",{className:"text-xs text-muted-foreground",children:[s!=null&&s.asOfDate?`Market rates as of ${s.asOfDate}`:"Market rates",_.meetsThreshold?" · meets referral threshold":" · below threshold"]})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-2 text-xs",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-muted-foreground",children:"Current"}),a.jsxs("p",{className:"font-medium",children:[_.currentRate.toFixed(2),"% · ",Dt(_.currentPayment),"/mo"]})]}),a.jsxs("div",{children:[a.jsxs("p",{className:"text-muted-foreground",children:["At market (",_.marketProductName,")"]}),a.jsxs("p",{className:"font-medium",children:[_.marketRate.toFixed(2),"% · ",Dt(_.estimatedRefiPayment),"/mo"]})]}),a.jsxs("div",{className:"col-span-2",children:[a.jsx("p",{className:"text-muted-foreground",children:"Est. monthly savings"}),a.jsx("p",{className:"text-sm font-semibold text-emerald-700 dark:text-emerald-300",children:Dt(_.estimatedMonthlySavings)})]})]}),(q==null?void 0:q.status)==="refer_pending"?a.jsx("p",{className:"text-xs text-muted-foreground",children:"Waiver email already sent — awaiting signature."}):(q==null?void 0:q.status)==="sent_to_arive"?a.jsx("p",{className:"text-xs text-muted-foreground",children:"Already referred to ARIVE."}):a.jsxs(st,{size:"sm",className:"w-full gap-1.5",disabled:Q,onClick:()=>void me(),children:[B?a.jsx(Kr,{className:"h-3.5 w-3.5 animate-spin"}):a.jsx(lm,{className:"h-3.5 w-3.5"}),"Refer Out"]})]})]})}function bd({result:e,leadId:t,scenarioId:n,propertyId:r}){const[s,i]=J.useState(!1),{settings:c}=co(),{data:l=[]}=Gd({leadId:t}),d=Sm(),h=Yd();if(!e.eligible)return null;const f=!!ud(c.hecm_partner_redirect_url),x=l.find(v=>v.source==="intake"&&v.referral_product==="hecm"),b=d.isPending||h.isPending,m=b||!t||!n||!f||(x==null?void 0:x.status)==="refer_pending"||(x==null?void 0:x.status)==="referred"||(x==null?void 0:x.status)==="sent_to_arive",w=async()=>{var _;if(!t||!n)return;const P=((_=(await d.mutateAsync({leadId:t,scenarioId:n,...r?{propertyId:r}:{},snapshot:{equityPct:e.equityPct,youngestAge:e.youngestAge,reasons:e.reasons}})).opportunities[0])==null?void 0:_.id)??(x==null?void 0:x.id);P&&(await h.mutateAsync(P),i(!1))};return a.jsxs($d,{open:s,onOpenChange:i,children:[a.jsx(Hd,{asChild:!0,children:a.jsx("button",{type:"button",className:"outline-none","aria-label":"Possible HECM candidate details",children:a.jsx(xn,{variant:"outline",className:Et("cursor-pointer rounded-full px-2.5 py-0.5 text-xs font-medium transition-colors hover:opacity-90","border-emerald-500/30 bg-emerald-500/10 text-emerald-800 dark:text-emerald-200"),children:"HECM candidate"})})}),a.jsxs(Ud,{align:"start",className:"w-80 space-y-3",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm font-semibold text-foreground",children:"Possible HECM candidate"}),a.jsx("p",{className:"text-xs text-muted-foreground",children:"Screening hint only — not a credit decision"})]}),e.reasons.length>0&&a.jsx("ul",{className:"list-disc space-y-0.5 pl-4 text-sm text-foreground",children:e.reasons.map(v=>a.jsx("li",{children:v},v))}),a.jsx("p",{className:"text-xs leading-snug text-muted-foreground",children:"Confirm occupancy, HUD counseling, and lending limits with the borrower before treating this as a reverse-mortgage path."}),(x==null?void 0:x.status)==="refer_pending"?a.jsx("p",{className:"text-xs text-muted-foreground",children:"Waiver email already sent — awaiting signature."}):(x==null?void 0:x.status)==="referred"?a.jsx("p",{className:"text-xs text-muted-foreground",children:"Information release signed — referred to the HECM partner."}):f?a.jsxs(st,{size:"sm",className:"w-full gap-1.5",disabled:m,onClick:()=>void w(),children:[b?a.jsx(Kr,{className:"h-3.5 w-3.5 animate-spin"}):a.jsx(lm,{className:"h-3.5 w-3.5"}),"Refer Out"]}):a.jsx("p",{className:"text-xs text-muted-foreground",children:"Set the HECM post-signature redirect URL in Intake Settings to enable Refer Out."})]})]})}const I1=new Set(["rental","vacation_rental","secondary_residence"]);function Do(e){return I1.has((e??"").toLowerCase())}function Ec(e){const t=(e??"").toLowerCase();return t==="primary_residence"||Do(t)}function Vi(e){return`property_mortgage_${e}`}function Vo(e){return e.find(t=>t.is_focus_property===!0)??e.find(t=>{var n;return((n=t.property_type)==null?void 0:n.toLowerCase())==="primary_residence"})??e[0]??null}function Ml(e){return Do(e.property_type)&&!e.ignored&&Number(e.outstanding_mortgage_balance??0)>0}function $l(e){return Ml(e)&&e.is_consolidated===!0}const F1=["AL","AK","AZ","AR","CA","CO","CT","DE","FL","GA","HI","ID","IL","IN","IA","KS","KY","LA","ME","MD","MA","MI","MN","MS","MO","MT","NE","NV","NH","NJ","NM","NY","NC","ND","OH","OK","OR","PA","RI","SC","SD","TN","TX","UT","VT","VA","WA","WV","WI","WY","DC"],T1=["Single-Family Home","Townhome","Condominium","Multi-Family Home","Cooperative (Co-op)","Manufactured (Mobile) Home","Apartment"];function ih(e){const t=Vo(e);return t?[t,...e.filter(n=>n.id!==t.id)]:e}const D1=new Set(["primary_residence","rental","secondary_residence","vacation_rental"]);function oh(e){return e!=null&&D1.has(e)?e:"primary_residence"}const lh=()=>({property_type:"rental",classification:"",estimated_value:0,original_mortgage_balance:0,outstanding_mortgage_balance:0,mortgage_payment:0,mortgage_interest_rate:0,mortgage_term_years:30,rental_income:0,rental_expenses:0,monthly_taxes:0,monthly_insurance:0,monthly_pmi:0,monthly_hoa:0,street_address:"",city:"",state:"",zip_code:"",is_consolidated:!1,ignored:!1}
17),R1=({properties:e,onSave:t,leadId:n,scenarioId:r,isMilitaryVeteran:s=!1,onToggleConsolidation:i,onToggleIgnoreInStrategy:c,onSetFocusProperty:l,hecmOpportunity:d=null,readOnly:h=!1,highlights:f})=>{var I;const[x,b]=J.useState(!1),[m,w]=J.useState(!1),[v,P]=J.useState(null),[_,q]=J.useState([]),{toast:T}=Ir(),B=J.useMemo(()=>ih(e),[e]),Q=((I=Vo(B))==null?void 0:I.id)??null,me=()=>{const k=ih(e);q(k.length>0?k.map(L=>({id:L.id,property_type:oh(L.property_type),classification:L.classification??"",estimated_value:Number(L.estimated_value),original_mortgage_balance:Number(L.original_mortgage_balance),outstanding_mortgage_balance:Number(L.outstanding_mortgage_balance),mortgage_payment:Number(L.mortgage_payment),mortgage_interest_rate:Number(L.mortgage_interest_rate),mortgage_term_years:Number(L.mortgage_term_years),rental_income:Number(L.rental_income),rental_expenses:Number(L.rental_expenses??0),monthly_taxes:Number(L.monthly_taxes??0),monthly_insurance:Number(L.monthly_insurance??0),monthly_pmi:Number(L.monthly_pmi??0),monthly_hoa:Number(L.monthly_hoa??0),street_address:L.street_address??"",city:L.city??"",state:L.state??"",zip_code:L.zip_code??"",is_consolidated:L.is_consolidated??!1,ignored:L.ignored??!1})):[{...lh(),property_type:"primary_residence"}]),b(!0)},ce=async()=>{var L;const k=Vd(Ug).safeParse(_);if(!k.success){T({title:"Validation error",description:((L=k.error.issues[0])==null?void 0:L.message)??"Invalid property data",variant:"destructive"});return}w(!0);try{await t(_),b(!1),T({title:"Properties updated"})}catch(H){T({title:"Failed to save",description:H.message,variant:"destructive"})}finally{w(!1)}};Ws("properties",x,ce,()=>b(!1));const $=(k,L,H)=>{q(te=>te.map((se,K)=>{if(K!==k)return se;const ae={...se,[L]:H};return L==="ignored"&&H===!0&&(ae.is_consolidated=!1),L==="is_consolidated"&&H===!0&&(ae.ignored=!1),L==="property_type"&&(Do(String(H))||(ae.is_consolidated=!1),Ec(String(H))||(ae.ignored=!1)),ae}))},D=async(k,L)=>{if(i)try{await i(k,L)}catch(H){T({title:"Failed to update consolidation",description:H instanceof Error?H.message:"Please try again.",variant:"destructive"})}},Y=async(k,L)=>{if(c)try{await c(k,L)}catch(H){T({title:"Failed to update payoff strategy",description:H instanceof Error?H.message:"Please try again.",variant:"destructive"})}},N=async k=>{if(l){P(k);try{await l(k),T({title:"Focus property updated",description:"Qualification, calculator, and amortization views now use this property."})}catch(L){T({title:"Failed to update focus property",description:L instanceof Error?L.message:"Please try again.",variant:"destructive"})}finally{P(null)}}};return a.jsxs("section",{children:[a.jsxs("h2",{className:"mb-3 flex items-center gap-2 text-xl font-semibold tracking-tight text-foreground",children:[a.jsx(cm,{className:"w-5 h-5 text-primary"}),"Property Information (",x?_.length:e.length,")",!x&&!h&&a.jsx(st,{variant:"ghost",size:"icon",className:"ml-auto h-7 w-7",onClick:me,children:a.jsx(gi,{className:"w-3.5 h-3.5 text-muted-foreground"})})]}),x?a.jsxs("div",{className:"space-y-3",children:[_.map((k,L)=>{const H=k.original_mortgage_balance||0,te=k.mortgage_interest_rate||0,se=k.mortgage_term_years||30,K=k.mortgage_payment||0,ae=k.outstanding_mortgage_balance||0,be=k.monthly_taxes||0,Ne=k.monthly_insurance||0,A=k.monthly_pmi||0,E=be+Ne+A,z=qu({outstandingBalance:ae,originalPrincipal:H,annualRatePercent:te,termYears:se,totalMonthlyPayment:K}),X=z!==null&&K>0?fi(Math.max(0,K-z)):E>0&&K>0?fi(Math.min(E,K)):null,Z=z!==null&&ae>0?$u(ae,te,z):null,le=Z!==null?Za(Z):"—",fe=zu(Z),ue=["rental","vacation_rental"].includes(k.property_type),_e=Do(k.property_type),Ce=Ec(k.property_type);return a.jsx(rn,{className:"rounded-2xl border-border/70 shadow-sm",children:a.jsxs(on,{className:`relative space-y-3 p-4 ${_.length>1?"pr-10":""}`,children:[_.length>1&&a.jsx(st,{type:"button",variant:"ghost",size:"icon",className:"absolute top-1 right-1 h-6 w-6",onClick:()=>q(ve=>ve.filter((we,De)=>De!==L)),children:a.jsx(nc,{className:"w-3 h-3 text-destructive"})}),a.jsxs("div",{children:[a.jsx(Ke,{className:"text-[11px] text-muted-foreground italic mb-1 block",children:"Property Address (optional)"}),a.jsxs("div",{className:"grid grid-cols-4 gap-2",children:[a.jsxs("div",{children:[a.jsx(Ke,{htmlFor:`intake-property-street-${L}`,className:"text-xs",children:"Street"}),a.jsx(j1,{id:`intake-property-street-${L}`,street:k.street_address,onStreetChange:ve=>$(L,"street_address",ve),onPlaceResolved:ve=>{$(L,"street_address",ve.street_address),$(L,"city",ve.city),$(L,"state",ve.state),$(L,"zip_code",ve.zip_code)}})]}),a.jsxs("div",{children:[a.jsx(Ke,{className:"text-xs",children:"City"}),a.jsx(Wt,{className:"h-8",placeholder:"Optional",value:k.city,onChange:ve=>$(L,"city",ve.target.value)})]}),a.jsxs("div",{children:[a.jsx(Ke,{className:"text-xs",children:"State"}),a.jsxs(Ka,{value:k.state||void 0,onValueChange:ve=>$(L,"state",ve),children:[a.jsx(Qa,{className:"h-8",children:a.jsx(Ja,{placeholder:"Select"})}),a.jsx(Xa,{children:F1.map(ve=>a.jsx(Mr,{value:ve,children:ve},ve))})]})]}),a.jsxs("div",{children:[a.jsx(Ke,{className:"text-xs",children:"ZIP"}),a.jsx(Wt,{className:"h-8",placeholder:"Optional",value:k.zip_code,onChange:ve=>$(L,"zip_code",ve.target.value)})]})]})]}),a.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[a.jsxs("div",{children:[a.jsx(Ke,{className:"text-xs",children:"Property Type"}),a.jsxs(Ka,{value:oh(k.property_type),onValueChange:ve=>$(L,"property_type",ve),children:[a.jsx(Qa,{className:"h-8",children:a.jsx(Ja,{})}),a.jsxs(Xa,{children:[a.jsx(Mr,{value:"primary_residence",children:"Primary Residence"}),a.jsx(Mr,{value:"rental",children:"Rental Property"}),a.jsx(Mr,{value:"secondary_residence",children:"Secondary Residence"}),a.jsx(Mr,{value:"vacation_rental",children:"Vacation Rental"})]})]})]}),a.jsxs("div",{children:[a.jsx(Ke,{className:"text-xs",children:"Classification"}),a.jsxs(Ka,{value:k.classification||void 0,onValueChange:ve=>$(L,"classification",ve),children:[a.jsx(Qa,{className:"h-8",children:a.jsx(Ja,{placeholder:"Select"})}),a.jsx(Xa,{children:T1.map(ve=>a.jsx(Mr,{value:ve,children:ve},ve))})]})]}),a.jsxs("div",{children:[a.jsx(Ke,{className:"text-xs",children:"Estimated Value ($)"}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Er,{className:"h-8 min-w-0 flex-1",value:k.estimated_value,onValueChange:ve=>$(L,"estimated_value",ve)}),a.jsx(M0,{address:{street_address:k.street_address,city:k.city,state:k.state,zip_code:k.zip_code}})]})]})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[a.jsxs("div",{children:[a.jsx(Ke,{className:"text-xs",children:"Original Mortgage ($)"}),a.jsx(Er,{className:"h-8",value:k.original_mortgage_balance,onValueChange:ve=>$(L,"original_mortgage_balance",ve)})]}),a.jsxs("div",{children:[a.jsx(Ke,{className:"text-xs",children:"Outstanding Mortgage ($)"}),a.jsx(Er,{className:"h-8",value:k.outstanding_mortgage_balance,onValueChange:ve=>$(L,"outstanding_mortgage_balance",ve)})]})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[a.jsxs("div",{children:[a.jsx(Ke,{className:"text-xs",children:"Interest Rate (%)"}),a.jsx(Wt,{type:"number",step:"0.001",className:"h-8",value:k.mortgage_interest_rate,onChange:ve=>$(L,"mortgage_interest_rate",Number(ve.target.value))})]}),a.jsxs("div",{children:[a.jsx(Ke,{className:"text-xs",children:"Term (years)"}),a.jsx(Wt,{type:"number",className:"h-8",value:k.mortgage_term_years,onChange:ve=>$(L,"mortgage_term_years",Number(ve.target.value))})]})]}),a.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:[a.jsxs("div",{children:[a.jsx(Ke,{className:"text-xs text-primary font-medium",children:"Total Monthly Payment — Including Escrow ($)"}),a.jsx(Er,{className:"h-8",value:k.mortgage_payment,onValueChange:ve=>$(L,"mortgage_payment",ve)})]}),a.jsxs("div",{children:[a.jsx(Ke,{className:"text-xs",children:"Monthly HOA / condo dues ($)"}),a.jsx(Er,{className:"h-8",value:k.monthly_hoa,onValueChange:ve=>$(L,"monthly_hoa",ve)}),a.jsx("p",{className:"text-[10px] text-muted-foreground mt-0.5",children:"Separate from PITI; included in cashflow and DTI."})]})]}),a.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-2",children:[a.jsxs("div",{children:[a.jsx(Ke,{className:"text-[11px] text-muted-foreground",children:"Principal & Interest"}),a.jsx("div",{className:"h-8 flex items-center px-3 bg-muted rounded-md text-xs font-semibold text-foreground",children:z!==null?Dt(z):"—"}),a.jsx("p",{className:"text-[10px] text-muted-foreground mt-0.5",children:"From balance, rate & term"})]}),a.jsxs("div",{children:[a.jsx(Ke,{className:"text-[11px] text-muted-foreground",children:"Escrow (Taxes, Insurance, PMI)"}),a.jsx("div",{className:"h-8 flex items-center px-3 bg-muted rounded-md text-xs font-semibold text-foreground",children:X!==null?Dt(X):"—"}),a.jsx("p",{className:"text-[10px] text-muted-foreground mt-0.5",children:"PITI minus P&I"})]}),a.jsxs("div",{children:[a.jsx(Ke,{className:"text-[11px] text-muted-foreground",children:"Years Remaining"}),a.jsx("div",{className:"h-8 flex items-center px-3 bg-muted rounded-md text-xs font-semibold text-foreground",children:le}),fe&&a.jsx("p",{className:"text-[10px] text-muted-foreground mt-0.5",children:fe})]})]}),ue&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[a.jsxs("div",{children:[a.jsx(Ke,{className:"text-xs",children:"Monthly Gross Rental Income ($)"}),a.jsx(Er,{className:"h-8",value:k.rental_income,onValueChange:ve=>$(L,"rental_income",ve)})]}),a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx(Ke,{className:"text-xs",children:"Additional Monthly Expenses ($)"}),a.jsxs(Ol,{children:[a.jsx(ql,{asChild:!0,children:a.jsx(zo,{className:"w-3 h-3 text-muted-foreground cursor-help"})}),a.jsx(zl,{className:"max-w-xs text-xs",children:"Maintenance, management, utilities, software, etc."})]})]}),a.jsx(Er,{className:"h-8",value:k.rental_expenses,onValueChange:ve=>$(L,"rental_expenses",ve)})]})]}),(()=>{const ve=k.rental_income||0,we=k.rental_expenses||0,De=k.mortgage_payment||0,R=k.monthly_hoa||0,ze=ve-we-De-R;return a.jsxs("div",{className:"max-w-[220px]",children:[a.jsx(Ke,{className:"text-[11px] text-muted-foreground",children:"Property Cashflow"}),a.jsx("div",{className:`h-8 flex items-center px-3 bg-muted rounded-md text-xs font-semibold ${ze>=0?"text-success":"text-destructive"}`,children:ve>0||we>0||De>0||R>0?Dt(ze):"—"}),a.jsx("p",{className:"text-[10px] text-muted-foreground mt-0.5",children:"Income − Expenses − PITI − HOA"})]})})()]}),Ce&&a.jsxs("div",{className:"flex flex-wrap items-center gap-5 rounded-md border border-border bg-muted/20 px-3 py-2",children:[_e&&a.jsxs("div",{className:"flex items-center gap-2 text-xs font-medium",children:[a.jsx(Ga,{checked:k.is_consolidated,disabled:k.ignored,onCheckedChange:ve=>$(L,"is_consolidated",ve),"aria-label":"Consolidate property mortgage",className:"scale-90"}),"Consolidate mortgage into HELOC"]}),a.jsxs("div",{className:"flex items-center gap-2 text-xs font-medium",children:[a.jsx(Ga,{checked:k.ignored,onCheckedChange:ve=>$(L,"ignored",ve),"aria-label":"Ignore property mortgage in payoff strategy",className:"scale-90"}),"Ignore in payoff strategy"]}
17),a.jsxs("p",{className:"basis-full text-[10px] text-muted-foreground",children:["Ignoring excludes only this mortgage from payoff calculations;",ue?" rental income, mortgage payment, cashflow, and DTI remain included.":" mortgage payment, cashflow, and DTI remain included."]})]})]})},L)}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs(st,{size:"sm",variant:"outline",className:"h-7 text-xs",onClick:()=>q(k=>[...k,lh()]),children:[a.jsx(rc,{className:"w-3 h-3 mr-1"})," Add Property"]}),a.jsx("div",{className:"flex-1"}),a.jsxs(st,{size:"sm",className:"h-7 text-xs",onClick:ce,disabled:m,children:[a.jsx(Us,{className:"w-3 h-3 mr-1"})," Save"]}),a.jsxs(st,{size:"sm",variant:"ghost",className:"h-7 text-xs",onClick:()=>b(!1),children:[a.jsx(Vs,{className:"w-3 h-3 mr-1"})," Cancel"]})]})]}):e.length===0?a.jsx(rn,{className:"rounded-2xl border-border/70 shadow-sm",children:a.jsx(on,{className:"py-8 text-center text-muted-foreground",children:"No properties reported."})}):a.jsx("div",{className:"space-y-3",children:B.map((k,L)=>{const H=Number(k.outstanding_mortgage_balance)||0,te=Number(k.mortgage_interest_rate)||0,se=Number(k.mortgage_term_years)||30,K=Number(k.mortgage_payment)||0,ae=Number(k.monthly_taxes)||0,be=Number(k.monthly_insurance)||0,Ne=Number(k.monthly_pmi)||0,A=ae+be+Ne,E=qu({outstandingBalance:H,originalPrincipal:Number(k.original_mortgage_balance)||0,annualRatePercent:te,termYears:se,totalMonthlyPayment:K}),z=E!==null&&K>0?fi(Math.max(0,K-E)):A>0&&K>0?fi(Math.min(A,K)):null,X=E!==null&&H>0?$u(H,te,E):null,Z=zu(X),le=["rental","vacation_rental"].includes(k.property_type),fe=Do(k.property_type),ue=Ec(k.property_type),_e=k.id===Q;return a.jsx(rn,{"data-focus-property":_e?"true":"false",className:Et("rounded-2xl shadow-sm",_e?"border-primary/70 ring-1 ring-primary/20":"border-border/70"),children:a.jsxs(on,{className:"p-4",children:[a.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[a.jsx(xn,{variant:"secondary",className:"capitalize",children:String(k.property_type??"property").replace(/_/g," ")}),k.classification&&a.jsx(xn,{variant:"outline",className:"text-xs",children:k.classification}),n?a.jsx(M1,{property:k,leadId:n,scenarioId:r,isMilitaryVeteran:s}):null,d&&k.property_type==="primary_residence"?a.jsx(bd,{result:d,leadId:n,scenarioId:r,propertyId:k.id}):null,k.city&&k.state&&a.jsxs("span",{className:"text-xs text-muted-foreground",children:[k.city,", ",k.state," ",k.zip_code]}),k.is_consolidated&&a.jsx(xn,{variant:"outline",className:"border-primary/40 text-xs text-primary",children:"Consolidate to HELOC"}),k.ignored&&a.jsx(xn,{variant:"outline",className:"text-xs text-muted-foreground",children:"Ignored"}),a.jsxs("div",{className:"ml-auto flex items-center gap-1.5",children:[a.jsxs(st,{type:"button",size:"sm",variant:_e?"default":"outline",className:"h-7 gap-1.5 text-xs",disabled:h||!l||_e||v!==null,onClick:()=>void N(k.id),"aria-label":_e?"Current focus property":`Use property ${L+1} as focus`,children:[a.jsx(K0,{className:"h-3.5 w-3.5"}),v===k.id?"Switching…":_e?"Focus property":"Use as focus"]}),ue&&a.jsxs(md,{children:[a.jsx(pd,{asChild:!0,children:a.jsx(st,{type:"button",size:"icon",variant:"ghost",className:"h-7 w-7 text-muted-foreground hover:text-foreground",disabled:h,"aria-label":`Property ${L+1} mortgage strategy`,children:a.jsx(dm,{className:"h-4 w-4"})})}),a.jsxs(gd,{align:"end",className:"w-80 p-2",children:[a.jsxs("div",{className:"px-2 pb-2 pt-1",children:[a.jsx("p",{className:"text-xs font-semibold tracking-tight text-foreground",children:"Payoff strategy"}),a.jsx("p",{className:"mt-0.5 text-[11px] leading-snug text-muted-foreground",children:"Choose how this mortgage participates in the accelerated plan."})]}),a.jsxs("div",{className:"space-y-1",children:[fe&&a.jsxs("div",{className:Et("flex items-start justify-between gap-3 rounded-lg border border-transparent px-2 py-2.5 transition-colors","hover:border-border hover:bg-muted/40",k.is_consolidated&&"border-primary/20 bg-primary/5",(k.ignored||!i)&&"opacity-60"),children:[a.jsxs("span",{className:"min-w-0 space-y-0.5",children:[a.jsx("span",{className:"block text-sm font-medium leading-snug",children:"Consolidate into HELOC"}),a.jsx("span",{className:"block text-[11px] leading-snug text-muted-foreground",children:"Fold this balance into the opening line draw."})]}),a.jsx(Ga,{checked:!!k.is_consolidated,disabled:h||!!k.ignored||!i,onCheckedChange:Ce=>void D(k.id,Ce),"aria-label":"Consolidate property mortgage",className:"mt-0.5 shrink-0 scale-90"})]}),a.jsxs("div",{className:Et("flex items-start justify-between gap-3 rounded-lg border border-transparent px-2 py-2.5 transition-colors","hover:border-border hover:bg-muted/40",k.ignored&&"border-border bg-muted/30",!c&&"opacity-60"),children:[a.jsxs("span",{className:"min-w-0 space-y-0.5",children:[a.jsx("span",{className:"block text-sm font-medium leading-snug",children:"Ignore in payoff strategy"}),a.jsxs("span",{className:"block text-[11px] leading-snug text-muted-foreground",children:["Keep income, payment, cashflow, and DTI; skip payoff chunks",le?" for this rental mortgage.":" for this mortgage."]})]}),a.jsx(Ga,{checked:!!k.ignored,disabled:h||!c,onCheckedChange:Ce=>void Y(k.id,Ce),"aria-label":"Ignore property mortgage in payoff strategy",className:"mt-0.5 shrink-0 scale-90"})]})]})]})]})]})]}),a.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3 text-sm",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-muted-foreground",children:"Est. Value"}),a.jsx(Kt,{path:`properties[${k.id}].estimated_value`,highlights:f,children:a.jsx("p",{className:"font-semibold",children:Dt(Number(k.estimated_value))})})]}),a.jsxs("div",{children:[a.jsx("p",{className:"text-muted-foreground",children:"Outstanding Mortgage"}),a.jsx(Kt,{path:`properties[${k.id}].outstanding_mortgage_balance`,highlights:f,children:a.jsx("p",{className:"font-semibold",children:Dt(Number(k.outstanding_mortgage_balance))})})]}),a.jsxs("div",{children:[a.jsx("p",{className:"text-muted-foreground",children:"Total Payment (w/ Escrow)"}),a.jsx(Kt,{path:`properties[${k.id}].mortgage_payment`,highlights:f,children:a.jsx("p",{className:"font-semibold",children:Dt(Number(k.mortgage_payment))})})]}),a.jsxs("div",{children:[a.jsx("p",{className:"text-muted-foreground",children:"Interest Rate"}),a.jsx(Kt,{path:`properties[${k.id}].mortgage_interest_rate`,highlights:f,children:a.jsxs("p",{className:"font-semibold",children:[k.mortgage_interest_rate,"%"]})})]}),E!==null&&a.jsxs("div",{children:[a.jsx("p",{className:"text-muted-foreground",children:"P&I"}),a.jsx("p",{className:"font-semibold",children:Dt(E)})]}),z!==null&&z>0&&a.jsxs("div",{children:[a.jsx("p",{className:"text-muted-foreground",children:"Escrow"}),a.jsx("p",{className:"font-semibold",children:Dt(z)})]}),E!==null&&a.jsxs("div",{children:[a.jsx("p",{className:"text-muted-foreground",children:"Years Remaining"}),a.jsx("p",{className:"font-semibold",children:X!==null?Za(X):"—"}),Z&&a.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:Z})]}),Number(k.monthly_hoa??0)>0&&a.jsxs("div",{children:[a.jsx("p",{className:"text-muted-foreground",children:"HOA / condo dues"}),a.jsx(Kt,{path:`properties[${k.id}].monthly_hoa`,highlights:f,children:a.jsx("p",{className:"font-semibold",children:Dt(Number(k.monthly_hoa))})})]}),le&&k.rental_income>0&&a.jsxs("div",{children:[a.jsx("p",{className:"text-muted-foreground",children:"Rental Income"}),a.jsx(Kt,{path:`properties[${k.id}].rental_income`,highlights:f,children:a.jsxs("p",{className:"font-semibold",children:[Dt(Number(k.rental_income)),"/mo"]})})]})]})]})},k.id)})})]})},B1=[...sm],O1=({expenses:e,onSave:t,formatCurrency:n,readOnly:r=!1,highlights:s})=>{const[i,c]=J.useState(!1),[l,d]=J.useState(!1),[h,f]=J.useState([]),[x,b]=J.useState("line_item"),[m,w]=J.useState(0),{toast:v}=Ir(),P=()=>{const q=e.reduce((Q,me)=>Q+Number(me.amount),0);f(am(e,B1));const T=e.filter(Q=>Number(Q.amount)>0),B=T.length===1&&T[0].category==="miscellaneous";b(T.length===0||B?"estimated":"line_item"),w(q),c(!0)},_=async()=>{var q;if(x==="line_item"){const T=Vd(Wg).safeParse(h);if(!T.success){v({title:"Validation error",description:((q=T.error.issues[0])==null?void 0:q.message)??"Invalid expense data",variant:"destructive"});return}}d(!0);try{x==="estimated"?await t([{category:"miscellaneous",amount:m}]):await t(h),c(!1),v({title:"Expenses updated"})}catch(T){v({title:"Failed to save",description:T.message,variant:"destructive"})}finally{d(!1)}};return Ws("expenses",i,_,()=>c(!1)),a.jsxs("section",{children:[a.jsxs("h2",{className:"mb-3 flex items-center gap-2 text-xl font-semibold tracking-tight text-foreground",children:[a.jsx(Vg,{className:"w-5 h-5 text-primary"}),"Monthly Expenses (",e.length,")",!i&&!r&&a.jsx(st,{variant:"ghost",size:"icon",className:"ml-auto h-7 w-7",onClick:P,children:a.jsx(gi,{className:"w-3.5 h-3.5 text-muted-foreground"})})]}),i?a.jsx(rn,{className:"rounded-2xl border-border/70 shadow-sm",children:a.jsxs(on,{className:"space-y-4 p-4",children:[a.jsx(um,{value:x,onValueChange:q=>b(q),children:a.jsxs(hm,{className:"grid w-full grid-cols-2",children:[a.jsx(eo,{value:"estimated",children:"Estimated Total"}),a.jsx(eo,{value:"line_item",children:"Per Line Item"})]})}),x==="estimated"?a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(Ke,{className:"text-sm shrink-0",children:"Total Monthly Expenses"}),a.jsx(Wt,{type:"number",step:"0.01",min:"0",className:"h-9 w-40",value:m,onChange:q=>w(Number(q.target.value))})]}):a.jsxs("div",{className:"space-y-3",children:[a.jsx("div",{className:"grid grid-cols-2 gap-x-6 gap-y-2",style:{gridAutoFlow:"column",gridTemplateRows:`repeat(${Math.ceil(h.length/2)}, minmax(0, 1fr))`},children:h.map((q,T)=>a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Ke,{className:"w-32 text-xs shrink-0",children:Hu(q.category)}),a.jsx(Wt,{type:"number",step:"0.01",min:"0",className:"h-8 w-24",value:q.amount,onChange:B=>f(Q=>Q.map((me,ce)=>ce===T?{...me,amount:Number(B.target.value)}:me))})]},q.category))}),a.jsxs("div",{className:"flex items-center justify-end gap-2 pt-2 border-t",children:[a.jsx(Ke,{className:"text-xs font-semibold",children:"Total Amount:"}),a.jsxs("span",{className:"text-sm font-semibold",children:["$",h.reduce((q,T)=>
17q+(Number(T.amount)||0),0).toLocaleString()]})]})]}),a.jsxs("div",{className:"flex gap-1",children:[a.jsxs(st,{size:"sm",className:"h-7 text-xs",onClick:_,disabled:l,children:[a.jsx(Us,{className:"w-3 h-3 mr-1"})," Save"]}),a.jsxs(st,{size:"sm",variant:"ghost",className:"h-7 text-xs",onClick:()=>c(!1),children:[a.jsx(Vs,{className:"w-3 h-3 mr-1"})," Cancel"]})]})]})}):e.length===0?a.jsx(rn,{className:"rounded-2xl border-border/70 shadow-sm",children:a.jsx(on,{className:"py-8 text-center text-muted-foreground",children:"No expenses reported."})}):a.jsx(rn,{className:"overflow-hidden rounded-2xl border-border/70 shadow-sm",children:a.jsx("div",{className:"overflow-auto",children:a.jsxs($o,{children:[a.jsx(Ho,{children:a.jsxs(Yr,{children:[a.jsx(In,{children:"Category"}),a.jsx(In,{className:"text-right",children:"Amount"})]})}),a.jsxs(Uo,{children:[e.map(q=>a.jsxs(Yr,{children:[a.jsx(Ut,{children:Hu(q.category)}),a.jsx(Ut,{className:"text-right",children:a.jsx(Kt,{path:`expenses[${q.category}]`,highlights:s,children:n(q.amount)})})]},q.id)),a.jsxs(Yr,{className:"font-semibold bg-muted/50",children:[a.jsx(Ut,{children:"Total"}),a.jsx(Ut,{className:"text-right",children:n(e.reduce((q,T)=>q+Number(T.amount),0))})]})]})]})})})]})},vd=80;function Mm(e){if(e==null||e==="")return vd;const t=Number(e);return Number.isFinite(t)?Math.min(100,Math.max(0,t)):vd}const Im=[{value:"credit_card",label:"Credit Card"},{value:"auto_loan",label:"Auto Loan"},{value:"student_loan",label:"Student Loan"},{value:"personal_loan",label:"Personal Loan"},{value:"other",label:"Other"}],q1=new Set(Im.map(e=>e.value)),ch="grid w-full min-w-[42rem] grid-cols-[minmax(5.5rem,9.5rem)_minmax(6.75rem,8.5rem)_minmax(5.75rem,7.5rem)_minmax(5.75rem,7.5rem)_minmax(3.75rem,5rem)_3rem_3.25rem_2.25rem] gap-x-2.5 gap-y-0 items-center";function dh(e){return e==null||e===""?"other":e==="auto"?"auto_loan":e==="student"?"student_loan":q1.has(e)?e:"other"}function z1(e){return String(e??"other").replace(/_/g," ")}const $1=({debts:e,onSave:t,onToggleIgnoreInStrategy:n,onToggleConsolidation:r,onConsolidateAll:s,onEditConsolidationChange:i,formatCurrency:c,metrics:l,displayedMonthlyCashflow:d,baseMonthlyCashflow:h,reservesForPaydown:f=0,consolidationLtvPercent:x=vd,onSaveConsolidationLtv:b,primaryPropertyValue:m=0,primaryMortgageBalance:w=0,forceShowConsolidation:v=!1,properties:P=[],readOnly:_=!1,highlights:q})=>{const[T,B]=J.useState(!1),[Q,me]=J.useState(!1),[ce,$]=J.useState([]),{toast:D}=Ir(),[Y,N]=J.useState(x),[I,k]=J.useState(!1),[L,H]=J.useState(!1);J.useEffect(()=>{N(x)},[x]);const te=async ye=>{const Ee=Mm(ye);if(N(Ee),!(Ee===x||!b)){k(!0);try{await b(Ee)}catch(de){N(x),D({title:"Failed to save LTV",description:de instanceof Error?de.message:"Please try again.",variant:"destructive"})}finally{k(!1)}}},se=e.filter(ye=>!ye.ignored&&ye.is_consolidated),K=P.filter($l),ae=l&&(se.length>0||K.length>0||v),be=d??(l==null?void 0:l.adjustedMonthlyCashFlow)??0,Ne=h??(l==null?void 0:l.monthlyCashFlow)??0,A=J.useMemo(()=>m<=0?0:Math.max(0,m*Y/100-w),[m,Y,w]),E=(l==null?void 0:l.consolidatedBalance)??0,z=Math.max(0,E-f),X=A>0?Math.min(100,z/A*100):0,Z=z>A&&A>0,le=()=>{$(e.map(ye=>({id:ye.id,debt_name:ye.debt_name,debt_type:dh(ye.debt_type),current_balance:Number(ye.current_balance),monthly_payment:Number(ye.monthly_payment),interest_rate:Number(ye.interest_rate),is_consolidated:ye.is_consolidated??!1,ignored:ye.ignored??!1}))),B(!0)},fe=async()=>{var Ee;const ye=Vd(Kg).safeParse(ce);if(!ye.success){D({title:"Validation error",description:((Ee=ye.error.issues[0])==null?void 0:Ee.message)??"Invalid debt data",variant:"destructive"});return}me(!0);try{await t(ce),B(!1),D({title:"Debts updated"})}catch(de){D({title:"Failed to save",description:de.message,variant:"destructive"})}finally{me(!1)}};Ws("debts",T,fe,()=>{B(!1),i==null||i(null)});const ue=(ye,Ee,de)=>{$(Ue=>{const qe=Ue.map(($e,Ge)=>{if(Ge!==ye)return $e;const bt={...$e,[Ee]:de};return Ee==="ignored"&&de===!0&&(bt.is_consolidated=!1),bt});return Ee==="is_consolidated"&&(i==null||i(qe.some($e=>$e.is_consolidated))),qe})},_e=()=>{$(ye=>{const Ee=ye.map(de=>de.ignored?de:{...de,is_consolidated:!0});return i==null||i(Ee.some(de=>de.is_consolidated)),Ee})},Ce=e.filter(ye=>!ye.ignored),ve=Ce.length>0&&Ce.every(ye=>ye.is_consolidated),we=async()=>
17{if(!ve){H(!0);try{if(s)await s();else if(r)await Promise.all(Ce.filter(ye=>!ye.is_consolidated).map(ye=>r(ye.id,!0)));else return;i==null||i(!0),D({title:"All debts marked for consolidation"})}catch(ye){D({title:"Failed to consolidate debts",description:ye instanceof Error?ye.message:"Please try again.",variant:"destructive"})}finally{H(!1)}}},De=(l==null?void 0:l.consolidatedBalance)??0,R=(l==null?void 0:l.consolidatedPayments)??0,ze=(l==null?void 0:l.consolidatedWeightedRate)??0;return a.jsxs("section",{children:[a.jsxs("h2",{className:"mb-3 flex items-center gap-2 text-xl font-semibold tracking-tight text-foreground",children:[a.jsx(Gg,{className:"w-5 h-5 text-primary"}),"Debts (",e.length,")",!T&&!_&&a.jsx(st,{variant:"ghost",size:"icon",className:"ml-auto h-7 w-7",onClick:le,children:a.jsx(gi,{className:"w-3.5 h-3.5 text-muted-foreground"})})]}),T?a.jsx(rn,{className:"rounded-2xl border-border/70 shadow-sm",children:a.jsxs(on,{className:"overflow-x-auto px-3 py-3 sm:px-4",children:[ce.length===0?a.jsx("p",{className:"text-xs text-muted-foreground text-center py-3",children:'No debts. Click "Add Debt" to add one.'}):a.jsxs("div",{className:"space-y-1",children:[a.jsx("div",{className:"mb-2 flex justify-end",children:a.jsx(st,{type:"button",variant:"outline",size:"sm",className:"h-8 text-xs",disabled:ce.length===0||ce.every(ye=>ye.ignored||ye.is_consolidated),onClick:_e,children:"Consolidate All"})}),a.jsxs("div",{className:Et(ch,"border-b border-border pb-2 text-xs font-medium text-muted-foreground"),role:"row",children:[a.jsx("div",{className:"pl-0.5",children:"Name"}),a.jsx("div",{children:"Type"}),a.jsx("div",{className:"text-right tabular-nums",children:"Balance ($)"}),a.jsx("div",{className:"text-right tabular-nums",children:"Payment ($)"}),a.jsx("div",{className:"text-right",children:"Rate (%)"}),a.jsx("div",{className:"text-center",title:"Consolidated into payoff strategy",children:"Consol."}),a.jsx("div",{className:"text-center",title:"Excluded from payoff strategy only; payment still counts in DTI",children:"Ignore"}),a.jsx("div",{className:"h-4 w-8 shrink-0 justify-self-center","aria-hidden":!0})]}),ce.map((ye,Ee)=>a.jsxs("div",{className:Et(ch,"py-0.5"),role:"row",children:[a.jsx(Wt,{className:"h-8 text-sm",value:ye.debt_name,onChange:de=>ue(Ee,"debt_name",de.target.value),"aria-label":"Debt name"}),a.jsxs(Ka,{value:dh(ye.debt_type),onValueChange:de=>ue(Ee,"debt_type",de),children:[a.jsx(Qa,{className:"h-8 w-full min-w-0 text-sm","aria-label":"Debt type",children:a.jsx(Ja,{})}),a.jsx(Xa,{children:Im.map(de=>a.jsx(Mr,{value:de.value,children:de.label},de.value))})]}),a.jsx(Wt,{type:"number",step:"0.01",min:"0",className:"h-8 px-2.5 text-sm tabular-nums text-right",value:ye.current_balance,onChange:de=>ue(Ee,"current_balance",Number(de.target.value)),"aria-label":"Balance"}),a.jsx(Wt,{type:"number",step:"0.01",min:"0",className:"h-8 px-2.5 text-sm tabular-nums text-right",value:ye.monthly_payment,onChange:de=>ue(Ee,"monthly_payment",Number(de.target.value)),"aria-label":"Monthly payment"}),a.jsx(Wt,{type:"number",step:"0.001",className:"h-8 px-2.5 text-sm tabular-nums text-right",value:ye.interest_rate,onChange:de=>ue(Ee,"interest_rate",Number(de.target.value)),"aria-label":"Interest rate percent"}),a.jsx("div",{className:"flex justify-center",children:a.jsx(lo,{checked:ye.is_consolidated,disabled:ye.ignored,onCheckedChange:de=>ue(Ee,"is_consolidated",!!de),"aria-label":"Consolidated"})}),a.jsx("div",{className:"flex justify-center",children:a.jsx(Ga,{checked:ye.ignored,title:"Excluded from payoff strategy only. Monthly payment still counts toward DTI.",onCheckedChange:de=>ue(Ee,"ignored",de),className:"scale-90","aria-label":"Ignore in strategy"})}),a.jsx("div",{className:"flex justify-center",children:a.jsx(st,{type:"button",variant:"ghost",size:"icon",className:"h-8 w-8 shrink-0",onClick:()=>$(de=>de.filter((Ue,qe)=>qe!==Ee)),"aria-label":"Remove debt",children:a.jsx(nc,{className:"w-3.5 h-3.5 text-destructive"})})})]},Ee))]}),a.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2 border-t border-border pt-3",children:[a.jsxs(st,{size:"sm",variant:"outline",className:"h-8 text-xs",onClick:()=>$(ye=>[...ye,{debt_name:"",debt_type:"credit_card",current_balance:0,monthly_payment:0,interest_rate:0,is_consolidated:!1,ignored:!1}]),children:[a.jsx(rc,{className:"w-3 h-3 mr-1"})," Add Debt"]}),a.jsx("div",{className:"flex-1 min-w-[1rem]"}),a.jsxs(st,{size:"sm",className:"h-8 text-xs",onClick:fe,disabled:Q,children:[a.jsx(Us,{className:"w-3 h-3 mr-1"})," Save"]}),a.jsxs(st,{size:"sm",variant:"ghost",className:"h-8 text-xs",onClick:()=>{B(!1),i==null||i(null)},children:[a.jsx(Vs,{className:"w-3 h-3 mr-1"})," Cancel"]})]})]})}):e.length===0?a.jsx(rn,{className:"rounded-2xl border-border/70 shadow-sm",children:a.jsx(on,{className:"py-8 text-center text-muted-foreground",children:"No additional debts reported."})}):a.jsxs(rn,{className:"overflow-hidden rounded-2xl border-border/70 shadow-sm",children:[a.jsx("div",{className:"flex items-center justify-end border-b border-border px-3 py-2",children:a.jsx(st,{type:"button",variant:"outline",size:"sm",className:"h-8 text-xs",disabled:_||L||ve||Ce.length===0||!s&&!r,onClick:()=>void we(),children:"Consolidate All"})}),a.jsx("div",{className:"overflow-auto",children:a.jsxs($o,{children:[a.jsx(Ho,{children:a.jsxs(Yr,{children:[a.jsx(In,{className:"w-10",children:"Consol."}),a.jsx(In,{className:"w-[72px] text-center",title:"Excluded from payoff strategy only; payment still counts in DTI",children:"Ignore"}),a.jsx(In,{children:"Name"}),a.jsx(In,{children:"Type"}),a.jsx(In,{className:"text-right",children:"Balance"}),a.jsx(In,{className:"text-right",children:"Monthly Payment"}),a.jsx(In,{className:"text-right",children:"Rate"})]})}),a.jsxs(Uo,{children:[e.map(ye=>a.jsxs(Yr,{className:Et(ye.is_consolidated?"bg-primary/5":"",ye.ignored&&"opacity-60"),children:[a.jsx(Ut,{className:"text-center",children:a.jsx(lo,{checked:ye.is_consolidated,disabled:_||!!ye.ignored,onCheckedChange:Ee=>r==null?void 0:r(ye.id,!!Ee),className:"mx-auto h-5 w-5"})}),a.jsx(Ut,{className:"text-center",children:a.jsx(Ga,{checked:!!ye.ignored,disabled:_||!n,title:"When on, this debt is excluded from payoff order and consolidation; its minimum payment is still counted as living expenses in the strategy simulation.",onCheckedChange:Ee=>
17void(n==null?void 0:n(ye.id,Ee)),className:"mx-auto scale-90"})}),a.jsx(Ut,{className:"font-medium",children:a.jsx(Kt,{path:`debts[${ye.id}].debt_name`,highlights:q,children:ye.debt_name})}),a.jsx(Ut,{className:"capitalize text-muted-foreground",children:a.jsx(Kt,{path:`debts[${ye.id}].debt_type`,highlights:q,children:z1(ye.debt_type)})}),a.jsx(Ut,{className:"text-right",children:a.jsx(Kt,{path:`debts[${ye.id}].current_balance`,highlights:q,children:c(ye.current_balance)})}),a.jsx(Ut,{className:"text-right",children:a.jsx(Kt,{path:`debts[${ye.id}].monthly_payment`,highlights:q,children:c(ye.monthly_payment)})}),a.jsx(Ut,{className:"text-right",children:a.jsxs(Kt,{path:`debts[${ye.id}].interest_rate`,highlights:q,children:[ye.interest_rate,"%"]})})]},ye.id)),a.jsxs(Yr,{className:"font-semibold bg-muted/50",children:[a.jsx(Ut,{}),a.jsx(Ut,{}),a.jsx(Ut,{colSpan:2,children:"Total"}),a.jsx(Ut,{className:"text-right",children:c(e.reduce((ye,Ee)=>ye+Number(Ee.current_balance),0))}),a.jsx(Ut,{className:"text-right",children:c(e.reduce((ye,Ee)=>ye+Number(Ee.monthly_payment),0))}),a.jsx(Ut,{})]})]})]})}),ae&&a.jsxs(on,{className:"pt-0 pb-4 space-y-4 border-t border-border mt-0",children:[a.jsx("h3",{className:"pt-3 text-lg font-semibold tracking-tight text-foreground",children:"Assumed Consolidation"}),m>0&&a.jsxs("div",{className:"space-y-2 p-3 bg-muted/30 rounded-lg border border-border",children:[a.jsxs("div",{className:"flex items-center gap-4 flex-wrap",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Ke,{className:"text-xs font-medium whitespace-nowrap",children:"LTV %"}),a.jsx(Wt,{type:"number",min:0,max:100,step:5,className:"h-7 w-20 text-xs",value:Y,disabled:I,onChange:ye=>N(Number(ye.target.value)),onBlur:()=>void te(Y),onKeyDown:ye=>{ye.key==="Enter"&&ye.currentTarget.blur()}})]}),a.jsxs("div",{className:"text-xs text-muted-foreground",children:["Property: ",a.jsx("span",{className:"font-medium text-foreground",children:c(m)})," · ","Mortgage: ",a.jsx("span",{className:"font-medium text-foreground",children:c(w)})," · ","Max Line: ",a.jsx("span",{className:"font-semibold text-primary",children:c(A)})]})]}),A>0&&a.jsxs("div",{className:"space-y-1",children:[a.jsxs("div",{className:"flex justify-between text-xs",children:[a.jsxs("span",{className:"text-muted-foreground",children:["Net Consolidated: ",a.jsx("span",{className:`font-semibold ${Z?"text-destructive":"text-foreground"}`,children:c(z)}),f>0&&a.jsxs("span",{className:"text-muted-foreground",children:[" (",c(E)," − ",c(f)," reserves)"]})," / ",c(A)]}),a.jsxs("span",{className:`font-medium ${Z?"text-destructive":X>80?"text-amber-600":"text-primary"}`,children:[X.toFixed(0),"%"]})]}),a.jsx(Yg,{value:Math.min(X,100),className:`h-2 ${Z?"[&>div]:bg-destructive":X>80?"[&>div]:bg-amber-500":""}`}),Z&&a.jsxs("p",{className:"text-xs text-destructive font-medium",children:["⚠ Net consolidated balance exceeds max line by ",c(z-A)]})]})]}),a.jsx("div",{className:"border border-border rounded-lg overflow-auto",children:a.jsxs($o,{children:[a.jsx(Ho,{children:a.jsxs(Yr,{children:[a.jsx(In,{children:"Payment Title"}),a.jsx(In,{className:"text-right",children:"Monthly Obligation"}),a.jsx(In,{className:"text-right",children:"Balance Remaining"}),a.jsx(In,{className:"text-right",children:"Interest Rate"})]})}),a.jsxs(Uo,{children:[se.map(ye=>a.jsxs(Yr,{children:[a.jsx(Ut,{className:"font-medium",children:ye.debt_name}),a.jsx(Ut,{className:"text-right",children:c(ye.monthly_payment)}),a.jsx(Ut,{className:"text-right",children:c(ye.current_balance)}),a.jsxs(Ut,{className:"text-right",children:[ye.interest_rate,"%"]})]},ye.id)),K.map(ye=>a.jsxs(Yr,{children:[a.jsxs(Ut,{className:"font-medium",children:[String(ye.property_type).replace(/_/g," ")," mortgage"]}),a.jsx(Ut,{className:"text-right",children:c(Number(ye.mortgage_payment))}),a.jsx(Ut,{className:"text-right",children:c(Number(ye.outstanding_mortgage_balance))}),a.jsxs(Ut,{className:"text-right",children:[Number(ye.mortgage_interest_rate).toFixed(2),"%"]})]},ye.id)),a.jsxs(Yr,{className:"font-semibold bg-muted/50",children:[a.jsx(Ut,{children:"Total"}),a.jsx(Ut,{className:"text-right",children:c(R)}),a.jsx(Ut,{className:"text-right",children:c(De)}),a.jsxs(Ut,{className:"text-right",children:[ze.toFixed(2),"%"]})]})]})]})}),a.jsx("div",{className:"grid grid-cols-1 gap-4 text-sm sm:grid-cols-2",children:a.jsxs("div",{children:[a.jsx("p",{className:"text-muted-foreground",children:"Total Consolidated Balance"}),a.jsx("p",{className:"font-semibold",children:c(De)})]})}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 text-sm border-t border-border pt-3",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-muted-foreground",children:"Adjusted Back-End DTI"}),a.jsxs("p",{className:"font-semibold",children:[l.adjustedBackEndDti!=null?`${l.adjustedBackEndDti.toFixed(2)}%`:"N/A",a.jsxs("span",{className:"text-xs text-muted-foreground ml-1",children:["(was ",l.backEndDti!=null?`${l.backEndDti.toFixed(2)}%`:"N/A",")"]})]})]}),a.jsxs("div",{children:[a.jsx("p",{className:"text-muted-foreground",children:"Adjusted Monthly Cashflow"}),a.jsxs("p",{className:`font-semibold ${be>=0?"text-success":"text-destructive"}`,children:[c(be),a.jsxs("span",{className:"text-xs text-muted-foreground ml-1",children:["(was ",c(Ne),")"]})]})]})]})]})]})]})};function pn(e){"@babel/helpers - typeof";return pn=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},pn(e)}var Ta=Uint8Array,fa=Uint16Array,Qd=Int32Array,Jd=new Ta([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Xd=new Ta([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),uh=new Ta([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Fm=function(e,t){for(var n=new fa(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];for(var s=new Qd(n[30]),r=1;r<30;++r)for(var i=n[r];i<n[r+1];++i)s[i]=i-n[r]<<5|r;return{b:n,r:s}},Tm=Fm(Jd,2),H1=Tm.b,_d=Tm.r;H1[28]=258,_d[258]=28;var U1=Fm(Xd,0),hh=U1.r,wd=new fa(32768);for(var Cn=0;Cn<32768;++Cn){var Ts=(Cn&43690)>>1|(Cn&21845)<<1;Ts=(Ts&52428)>>2|(Ts&13107)<<2,Ts=(Ts&61680)>>4|(Ts&3855)<<4,wd[Cn]=((Ts&65280)>>8|(Ts&255)<<8)>>1}var Ro=function(e,t,n){for(var r=e.length,s=0,i=new fa(t);s<r;++s)e[s]&&++i[e[s]-1];var c=new fa(t);for(s=1;s<t;++s)c[s]=c[s-1]+i[s-1]<<1;var l;
vendor: 1,867 bytes, line 17
17if(n){l=new fa(1<<t);var d=15-t;for(s=0;s<r;++s)if(e[s])for(var h=s<<4|e[s],f=t-e[s],x=c[e[s]-1]++<<f,b=x|(1<<f)-1;x<=b;++x)l[wd[x]>>d]=h}else for(l=new fa(r),s=0;s<r;++s)e[s]&&(l[s]=wd[c[e[s]-1]++]>>15-e[s]);return l},xi=new Ta(288);for(var Cn=0;Cn<144;++Cn)xi[Cn]=8;for(var Cn=144;Cn<256;++Cn)xi[Cn]=9;for(var Cn=256;Cn<280;++Cn)xi[Cn]=7;for(var Cn=280;Cn<288;++Cn)xi[Cn]=8;var Hl=new Ta(32);for(var Cn=0;Cn<32;++Cn)Hl[Cn]=5;var V1=Ro(xi,9,0),W1=Ro(Hl,5,0),Dm=function(e){return(e+7)/8|0},G1=function(e,t,n){return(n==null||n>e.length)&&(n=e.length),new Ta(e.subarray(t,n))},ds=function(e,t,n){n<<=t&7;var r=t/8|0;e[r]|=n,e[r+1]|=n>>8},Ao=function(e,t,n){n<<=t&7;var r=t/8|0;e[r]|=n,e[r+1]|=n>>8,e[r+2]|=n>>16},Mc=function(e,t){for(var n=[],r=0;r<e.length;++r)e[r]&&n.push({s:r,f:e[r]});var s=n.length,i=n.slice();if(!s)return{t:Bm,l:0};if(s==1){var c=new Ta(n[0].s+1);return c[n[0].s]=1,{t:c,l:1}}n.sort(function(Q,me){return Q.f-me.f}),n.push({s:-1,f:25001});var l=n[0],d=n[1],h=0,f=1,x=2;for(n[0]={s:-1,f:l.f+d.f,l,r:d};f!=s-1;)l=n[n[h].f<n[x].f?h++:x++],d=n[h!=f&&n[h].f<n[x].f?h++:x++],n[f++]={s:-1,f:l.f+d.f,l,r:d};for(var b=i[0].s,r=1;r<s;++r)i[r].s>b&&(b=i[r].s);var m=new fa(b+1),w=Nd(n[f-1],m,0);if(w>t){var r=0,v=0,P=w-t,_=1<<P;for(i.sort(function(me,ce){return m[ce.s]-m[me.s]||me.f-ce.f});r<s;++r){var q=i[r].s;if(m[q]>t)v+=_-(1<<w-m[q]),m[q]=t;else break}for(v>>=P;v>0;){var T=i[r].s;m[T]<t?v-=1<<t-m[T]++-1:++r}for(;r>=0&&v;--r){var B=i[r].s;m[B]==t&&(--m[B],++v)}w=t}return{t:new Ta(m),l:w}},Nd=function(e,t,n){return e.s==-1?Math.max(Nd(e.l,t,n+1),Nd(e.r,t,n+1)):t[e.s]=n},fh=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new fa(++t),r=0,s=e[0],i=1,c=function(d){n[r++]=d},l=1;l<=t;++l)if(e[l]==s&&l!=t)++i;else{if(!s&&i>2){for(;i>138;i-=138)c(32754);i>2&&(c(i>10?i-11<<5|28690:i-3<<5|12305),i=0)}else if(i>3){for(c(s),--i;i>6;i-=6)c(8304);
vendor: 11,341 bytes, lines 17-18
17i>2&&(c(i-3<<5|8208),i=0)}for(;i--;)c(s);i=1,s=e[l]}return{c:n.subarray(0,r),n:t}},ko=function(e,t){for(var n=0,r=0;r<t.length;++r)n+=e[r]*t[r];return n},Rm=function(e,t,n){var r=n.length,s=Dm(t+2);e[s]=r&255,e[s+1]=r>>8,e[s+2]=e[s]^255,e[s+3]=e[s+1]^255;for(var i=0;i<r;++i)e[s+i+4]=n[i];return(s+4+r)*8},mh=function(e,t,n,r,s,i,c,l,d,h,f){ds(t,f++,n),++s[256];for(var x=Mc(s,15),b=x.t,m=x.l,w=Mc(i,15),v=w.t,P=w.l,_=fh(b),q=_.c,T=_.n,B=fh(v),Q=B.c,me=B.n,ce=new fa(19),$=0;$<q.length;++$)++ce[q[$]&31];for(var $=0;$<Q.length;++$)++ce[Q[$]&31];for(var D=Mc(ce,7),Y=D.t,N=D.l,I=19;I>4&&!Y[uh[I-1]];--I);var k=h+5<<3,L=ko(s,xi)+ko(i,Hl)+c,H=ko(s,b)+ko(i,v)+c+14+3*I+ko(ce,Y)+2*ce[16]+3*ce[17]+7*ce[18];if(d>=0&&k<=L&&k<=H)return Rm(t,f,e.subarray(d,d+h));var te,se,K,ae;if(ds(t,f,1+(H<L)),f+=2,H<L){te=Ro(b,m,0),se=b,K=Ro(v,P,0),ae=v;var be=Ro(Y,N,0);ds(t,f,T-257),ds(t,f+5,me-1),ds(t,f+10,I-4),f+=14;for(var $=0;$<I;++$)ds(t,f+3*$,Y[uh[$]]);f+=3*I;for(var Ne=[q,Q],A=0;A<2;++A)for(var E=Ne[A],$=0;$<E.length;++$){var z=E[$]&31;ds(t,f,be[z]),f+=Y[z],z>15&&(ds(t,f,E[$]>>5&127),f+=E[$]>>12)}}else te=V1,se=xi,K=W1,ae=Hl;for(var $=0;$<l;++$){var X=r[$];if(X>255){var z=X>>18&31;Ao(t,f,te[z+257]),f+=se[z+257],z>7&&(ds(t,f,X>>23&31),f+=Jd[z]);var Z=X&31;Ao(t,f,K[Z]),f+=ae[Z],Z>3&&(Ao(t,f,X>>5&8191),f+=Xd[Z])}else Ao(t,f,te[X]),f+=se[X]}return Ao(t,f,te[256]),f+se[256]},Y1=new Qd([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Bm=new Ta(0),K1=function(e,t,n,r,s,i){var c=i.z||e.length,l=new Ta(r+c+5*(1+Math.ceil(c/7e3))+s),d=l.subarray(r,l.length-s),h=i.l,f=(i.r||0)&7;if(t){f&&(d[0]=i.r>>3);for(var x=Y1[t-1],b=x>>13,m=x&8191,w=(1<<n)-1,v=i.p||new fa(32768),P=i.h||new fa(w+1),_=Math.ceil(n/3),q=2*_,T=function(De){return(e[De]^e[De+1]<<_^e[De+2]<<q)&w},B=new Qd(25e3),Q=new fa(288),me=new fa(32),ce=0,$=0,D=i.i||0,Y=0,N=i.w||0,I=0;D+2<c;++D){var k=T(D),L=D&32767,H=P[k];if(v[L]=H,P[k]=L,N<=D){var te=c-D;if((ce>7e3||Y>24576)&&(te>423||!h)){f=mh(e,d,0,B,Q,me,$,Y,I,D-I,f),Y=ce=$=0,I=D;for(var se=0;se<286;++se)Q[se]=0;for(var se=0;se<30;++se)me[se]=0}var K=2,ae=0,be=m,Ne=L-H&32767;if(te>2&&k==T(D-Ne))for(var A=Math.min(b,te)-1,E=Math.min(32767,D),z=Math.min(258,te);Ne<=E&&--be&&L!=H;){if(e[D+K]==e[D+K-Ne]){for(var X=0;X<z&&e[D+X]==e[D+X-Ne];++X);if(X>K){if(K=X,ae=Ne,X>A)break;for(var Z=Math.min(Ne,X-2),le=0,se=0;se<Z;++se){var fe=D-Ne+se&32767,ue=v[fe],_e=fe-ue&32767;_e>le&&(le=_e,H=fe)}}}L=H,H=v[L],Ne+=L-H&32767}if(ae){B[Y++]=268435456|_d[K]<<18|hh[ae];var Ce=_d[K]&31,ve=hh[ae]&31;$+=Jd[Ce]+Xd[ve],++Q[257+Ce],++me[ve],N=D+K,++ce}else B[Y++]=e[D],++Q[e[D]]}}for(D=Math.max(D,N);D<c;++D)B[Y++]=e[D],++Q[e[D]];f=mh(e,d,h,B,Q,me,$,Y,I,D-I,f),h||(i.r=f&7|d[f/8|0]<<3,f-=7,i.h=P,i.p=v,i.i=D,i.w=N)}else{for(var D=i.w||0;D<c+h;D+=65535){var we=D+65535;we>=c&&(d[f/8|0]=h,we=c),f=Rm(d,f+1,e.subarray(D,we))}i.i=c}return G1(l,0,r+Dm(f)+s)},Om=function(){var e=1,t=0;return{p:function(n){for(var r=e,s=t,i=n.length|0,c=0;c!=i;){for(var l=Math.min(c+2655,i);c<l;++c)s+=r+=n[c];r=(r&65535)+15*(r>>16),s=(s&65535)+15*(s>>16)}e=r,t=s},d:function(){return e%=65521,t%=65521,(e&255)<<24|(e&65280)<<8|(t&255)<<8|t>>8}}},Q1=function(e,t,n,r,s){if(!s&&(s={l:1},t.dictionary)){var i=t.dictionary.subarray(-32768),c=new Ta(i.length+e.length);c.set(i),c.set(e,i.length),e=c,s.w=i.length}return K1(e,t.level==null?6:t.level,t.mem==null?s.l?Math.ceil(Math.max(8,Math.min(13,Math.log(e.length)))*1.5):20:12+t.mem,n,r,s)},qm=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8},J1=function(e,t){var n=t.level,r=n==0?0:n<6?1:n==9?3:2;if(e[0]=120,e[1]=r<<6|(t.dictionary&&32),e[1]|=31-(e[0]<<8|e[1])%31,t.dictionary){var s=Om();s.p(t.dictionary),qm(e,2,s.d())}};function jd(e,t){t||(t={});var n=Om();n.p(e);var r=Q1(e,t,t.dictionary?6:2,4);return J1(r,t),qm(r,r.length-4,n.d()),r}var X1=typeof TextDecoder<"u"&&new TextDecoder,Z1=0;try{X1.decode(Bm,{stream:!0}),Z1=1}catch{}function e2(e){if(Array.isArray(e))return e}function t2(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,s,i,c,l=[],d=!0,h=!1;try{if(i=(n=n.call(e)).next,t!==0)for(;!(d=(r=i.call(n)).done)&&(l.push(r.value),l.length!==t);d=!0);}catch(f){h=!0,s=f}finally{try{if(!d&&n.return!=null&&(c=n.return(),Object(c)!==c))return}finally{if(h)throw s}}return l}}function ph(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function n2(e,t){if(e){if(typeof e=="string")return ph(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?ph(e,t):void 0}}function r2(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
18In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function gh(e,t){return e2(e)||t2(e,t)||n2(e,t)||r2()}function xh(e,t="utf8"){return new TextDecoder(t).decode(e)}const a2=new TextEncoder;function s2(e){return a2.encode(e)}const i2=1024*8,o2=(()=>{const e=new Uint8Array(4),t=new Uint32Array(e.buffer);return!((t[0]=1)&e[0])})(),Ic={int8:globalThis.Int8Array,uint8:globalThis.Uint8Array,int16:globalThis.Int16Array,uint16:globalThis.Uint16Array,int32:globalThis.Int32Array,uint32:globalThis.Uint32Array,uint64:globalThis.BigUint64Array,int64:globalThis.BigInt64Array,float32:globalThis.Float32Array,float64:globalThis.Float64Array};class Zd{constructor(t=i2,n={}){mn(this,"buffer");mn(this,"byteLength");mn(this,"byteOffset");mn(this,"length");mn(this,"offset");mn(this,"lastWrittenByte");mn(this,"littleEndian");mn(this,"_data");mn(this,"_mark");mn(this,"_marks");let r=!1;typeof t=="number"?t=new ArrayBuffer(t):(r=!0,this.lastWrittenByte=t.byteLength);const s=n.offset?n.offset>>>0:0,i=t.byteLength-s;let c=s;(ArrayBuffer.isView(t)||t instanceof Zd)&&(t.byteLength!==t.buffer.byteLength&&(c=t.byteOffset+s),t=t.buffer),r?this.lastWrittenByte=i:this.lastWrittenByte=0,this.buffer=t,this.length=i,this.byteLength=i,this.byteOffset=c,this.offset=0,this.littleEndian=!0,this._data=new DataView(this.buffer,c,i),this._mark=0,this._marks=[]}available(t=1){return this.offset+t<=this.length}isLittleEndian(){return this.littleEndian}setLittleEndian(){return this.littleEndian=!0,this}isBigEndian(){return!this.littleEndian}setBigEndian(){return this.littleEndian=!1,this}skip(t=1){return this.offset+=t,this}back(t=1){return this.offset-=t,this}seek(t){return this.offset=t,this}mark(){return this._mark=this.offset,this}reset(){return this.offset=this._mark,this}pushMark(){return this._marks.push(this.offset),this}popMark(){const t=this._marks.pop();if(t===void 0)throw new Error("Mark stack empty");return this.seek(t),this}rewind(){return this.offset=0,this}ensureAvailable(t=1){if(!this.available(t)){const r=(this.offset+t)*2,s=new Uint8Array(r);s.set(new Uint8Array(this.buffer)),this.buffer=s.buffer,this.length=r,this.byteLength=r,this._data=new DataView(this.buffer)}return this}readBoolean(){return this.readUint8()!==0}readInt8(){return this._data.getInt8(this.offset++)}readUint8(){return this._data.getUint8(this.offset++)}readByte(){return this.readUint8()}readBytes(t=1){return this.readArray(t,"uint8")}readArray(t,n){const r=Ic[n].BYTES_PER_ELEMENT*t,s=this.byteOffset+this.offset,i=this.buffer.slice(s,s+r);if(this.littleEndian===o2&&n!=="uint8"&&n!=="int8"){const l=new Uint8Array(this.buffer.slice(s,s+r));l.reverse();const d=new Ic[n](l.buffer);return this.offset+=r,d.reverse(),d}const c=new Ic[n](i);return this.offset+=r,c}readInt16(){const t=this._data.getInt16(this.offset,this.littleEndian);return this.offset+=2,t}readUint16(){const t=this._data.getUint16(this.offset,this.littleEndian);return this.offset+=2,t}readInt32(){const t=this._data.getInt32(this.offset,this.littleEndian);return this.offset+=4,t}readUint32(){const t=this._data.getUint32(this.offset,this.littleEndian);return this.offset+=4,t}readFloat32(){const t=this._data.getFloat32(this.offset,this.littleEndian);return this.offset+=4,t}readFloat64(){const t=this._data.getFloat64(this.offset,this.littleEndian);return this.offset+=8,t}readBigInt64(){const t=this._data.getBigInt64(this.offset,this.littleEndian);return this.offset+=8,t}readBigUint64(){const t=this._data.getBigUint64(this.offset,this.littleEndian);return this.offset+=8,t}readChar(){return String.fromCharCode(this.readInt8())}readChars(t=1){let n="";for(let r=0;r<t;r++)n+=this.readChar();return n}readUtf8(t=1){return xh(this.readBytes(t))}decodeText(t=1,n="utf8"){return xh(this.readBytes(t),n)}writeBoolean(t){return this.writeUint8(t?255:0),this}writeInt8(t){return this.ensureAvailable(1),this._data.setInt8(this.offset++,t),this._updateLastWrittenByte(),this}writeUint8(t){return this.ensureAvailable(1),this._data.setUint8(this.offset++,t),this._updateLastWrittenByte(),this}writeByte(t){return this.writeUint8(t)}writeBytes(t){this.ensureAvailable(t.length);for(let n=0;n<t.length;n++)this._data.setUint8(this.offset++,t[n]);return this._updateLastWrittenByte(),this}writeInt16(t){return this.ensureAvailable(2),this._data.setInt16(this.offset,t,this.littleEndian),this.offset+=2,this._updateLastWrittenByte(),this}writeUint16(t){return this.ensureAvailable(2),this._data.setUint16(this.offset,t,this.littleEndian),this.offset+=2,this._updateLastWrittenByte(),this}writeInt32(t){return this.ensureAvailable(4),this._data.setInt32(this.offset,t,this.littleEndian),this.offset+=4,this._updateLastWrittenByte(),this}writeUint32(t){return this.ensureAvailable(4),this._data.setUint32(this.offset,t,this.littleEndian),this.offset+=4,this._updateLastWrittenByte(),this}writeFloat32(t){return this.ensureAvailable(4),this._data.setFloat32(this.offset,t,this.littleEndian),this.offset+=4,this._updateLastWrittenByte(),this}writeFloat64(t){return this.ensureAvailable(8),this._data.setFloat64(this.offset,t,this.littleEndian),this.offset+=8,this._updateLastWrittenByte(),this}writeBigInt64(t){return this.ensureAvailable(8),this._data.setBigInt64(this.offset,t,this.littleEndian),this.offset+=8,this._updateLastWrittenByte(),this}writeBigUint64(t){return this.ensureAvailable(8),this._data.setBigUint64(this.offset,t,this.littleEndian),this.offset+=8,this._updateLastWrittenByte(),this}writeChar(t){return this.writeUint8(t.charCodeAt(0))}writeChars(t){for(let n=0;n<t.length;n++)this.writeUint8(t.charCodeAt(n));return this}writeUtf8(t){return this.writeBytes(s2(t))}toArray(){return new Uint8Array(this.buffer,this.byteOffset,this.lastWrittenByte)}getWrittenByteLength(){return this.lastWrittenByte-this.byteOffset}_updateLastWrittenByte(){this.offset>this.lastWrittenByte&&(this.lastWrittenByte=this.offset)}}function uo(e){let t=e.length;for(;--t>=0;)e[t]=0}const l2=3,c2=258,zm=29,d2=256,u2=d2+1+zm,$m=30,h2=512,f2=new Array((u2+2)*2);uo(f2);const m2=new Array($m*2);uo(m2);const p2=new Array(h2);uo(p2);const g2=new Array(c2-l2+1);uo(g2);const x2=new Array(zm);uo(x2);const y2=new Array($m);uo(y2);const b2=(e,t,n,r)=>{let s=e&65535|0,i=e>>>16&65535|0,c=0;for(;n!==0;){c=n>2e3?2e3:n,n-=c;do s=s+t[r++]|0,i=i+s|0;while(--c);s%=65521,i%=65521}return s|i<<16|0};var Sd=b2;const v2=()=>{let e,t=[];for(var n=0;n<256;n++){e=n;for(var r=0;r<8;r++)e=e&1?3988292384^e>>>1:e>>>1;t[n]=e}return t},_2=new Uint32Array(v2()),w2=(e,t,n,r)=>{const s=_2,i=r+n;e^=-1;for(let c=r;c<i;c++)e=e>>>8^s[(e^t[c])&255];return e^-1};
vendor: 17,835 bytes, line 18
18var Va=w2,Ld={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},Hm={Z_NO_FLUSH:0,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_DEFLATED:8};const N2=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var j2=function(e){const t=Array.prototype.slice.call(arguments,1);for(;t.length;){const n=t.shift();if(n){if(typeof n!="object")throw new TypeError(n+"must be non-object");for(const r in n)N2(n,r)&&(e[r]=n[r])}}return e},S2=e=>{let t=0;for(let r=0,s=e.length;r<s;r++)t+=e[r].length;const n=new Uint8Array(t);for(let r=0,s=0,i=e.length;r<i;r++){let c=e[r];n.set(c,s),s+=c.length}return n},Um={assign:j2,flattenChunks:S2};let Vm=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{Vm=!1}const Wo=new Uint8Array(256);for(let e=0;e<256;e++)Wo[e]=e>=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;Wo[254]=Wo[254]=1;var L2=e=>{if(typeof TextEncoder=="function"&&TextEncoder.prototype.encode)return new TextEncoder().encode(e);let t,n,r,s,i,c=e.length,l=0;for(s=0;s<c;s++)n=e.charCodeAt(s),(n&64512)===55296&&s+1<c&&(r=e.charCodeAt(s+1),(r&64512)===56320&&(n=65536+(n-55296<<10)+(r-56320),s++)),l+=n<128?1:n<2048?2:n<65536?3:4;for(t=new Uint8Array(l),i=0,s=0;i<l;s++)n=e.charCodeAt(s),(n&64512)===55296&&s+1<c&&(r=e.charCodeAt(s+1),(r&64512)===56320&&(n=65536+(n-55296<<10)+(r-56320),s++)),n<128?t[i++]=n:n<2048?(t[i++]=192|n>>>6,t[i++]=128|n&63):n<65536?(t[i++]=224|n>>>12,t[i++]=128|n>>>6&63,t[i++]=128|n&63):(t[i++]=240|n>>>18,t[i++]=128|n>>>12&63,t[i++]=128|n>>>6&63,t[i++]=128|n&63);return t};const A2=(e,t)=>{if(t<65534&&e.subarray&&Vm)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));let n="";for(let r=0;r<t;r++)n+=String.fromCharCode(e[r]);return n};var k2=(e,t)=>{const n=t||e.length;if(typeof TextDecoder=="function"&&TextDecoder.prototype.decode)return new TextDecoder().decode(e.subarray(0,t));let r,s;const i=new Array(n*2);for(s=0,r=0;r<n;){let c=e[r++];if(c<128){i[s++]=c;continue}let l=Wo[c];if(l>4){i[s++]=65533,r+=l-1;continue}for(c&=l===2?31:l===3?15:7;l>1&&r<n;)c=c<<6|e[r++]&63,l--;if(l>1){i[s++]=65533;continue}c<65536?i[s++]=c:(c-=65536,i[s++]=55296|c>>10&1023,i[s++]=56320|c&1023)}return A2(i,s)},C2=(e,t)=>{t=t||e.length,t>e.length&&(t=e.length);let n=t-1;for(;n>=0&&(e[n]&192)===128;)n--;return n<0||n===0?t:n+Wo[e[n]]>t?n:t},Ad={string2buf:L2,buf2string:k2,utf8border:C2};function P2(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}var E2=P2;const gl=16209,M2=16191;var I2=function(t,n){let r,s,i,c,l,d,h,f,x,b,m,w,v,P,_,q,T,B,Q,me,ce,$,D,Y;const N=t.state;r=t.next_in,D=t.input,s=r+(t.avail_in-5),i=t.next_out,Y=t.output,c=i-(n-t.avail_out),l=i+(t.avail_out-257),d=N.dmax,h=N.wsize,f=N.whave,x=N.wnext,b=N.window,m=N.hold,w=N.bits,v=N.lencode,P=N.distcode,_=(1<<N.lenbits)-1,q=(1<<N.distbits)-1;e:do{w<15&&(m+=D[r++]<<w,w+=8,m+=D[r++]<<w,w+=8),T=v[m&_];t:for(;;){if(B=T>>>24,m>>>=B,w-=B,B=T>>>16&255,B===0)Y[i++]=T&65535;else if(B&16){Q=T&65535,B&=15,B&&(w<B&&(m+=D[r++]<<w,w+=8),Q+=m&(1<<B)-1,m>>>=B,w-=B),w<15&&(m+=D[r++]<<w,w+=8,m+=D[r++]<<w,w+=8),T=P[m&q];n:for(;;){if(B=T>>>24,m>>>=B,w-=B,B=T>>>16&255,B&16){if(me=T&65535,B&=15,w<B&&(m+=D[r++]<<w,w+=8,w<B&&(m+=D[r++]<<w,w+=8)),me+=m&(1<<B)-1,me>d){t.msg="invalid distance too far back",N.mode=gl;break e}if(m>>>=B,w-=B,B=i-c,me>B){if(B=me-B,B>f&&N.sane){t.msg="invalid distance too far back",N.mode=gl;break e}if(ce=0,$=b,x===0){if(ce+=h-B,B<Q){Q-=B;do Y[i++]=b[ce++];while(--B);ce=i-me,$=Y}}else if(x<B){if(ce+=h+x-B,B-=x,B<Q){Q-=B;do Y[i++]=b[ce++];while(--B);if(ce=0,x<Q){B=x,Q-=B;do Y[i++]=b[ce++];while(--B);ce=i-me,$=Y}}}else if(ce+=x-B,B<Q){Q-=B;do Y[i++]=b[ce++];while(--B);ce=i-me,$=Y}for(;Q>2;)Y[i++]=$[ce++],Y[i++]=$[ce++],Y[i++]=$[ce++],Q-=3;Q&&(Y[i++]=$[ce++],Q>1&&(Y[i++]=$[ce++]))}else{ce=i-me;do Y[i++]=Y[ce++],Y[i++]=Y[ce++],Y[i++]=Y[ce++],Q-=3;while(Q>2);Q&&(Y[i++]=Y[ce++],Q>1&&(Y[i++]=Y[ce++]))}}else if(B&64){t.msg="invalid distance code",N.mode=gl;break e}else{T=P[(T&65535)+(m&(1<<B)-1)];continue n}break}}else if(B&64)if(B&32){N.mode=M2;break e}else{t.msg="invalid literal/length code",N.mode=gl;break e}else{T=v[(T&65535)+(m&(1<<B)-1)];continue t}break}}while(r<s&&i<l);Q=w>>3,r-=Q,w-=Q<<3,m&=(1<<w)-1,t.next_in=r,t.next_out=i,t.avail_in=r<s?5+(s-r):5-(r-s),t.avail_out=i<l?257+(l-i):257-(i-l),N.hold=m,N.bits=w};const Wi=15,yh=852,bh=592,vh=0,Fc=1,_h=2,F2=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),T2=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),D2=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),R2=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]),B2=(e,t,n,r,s,i,c,l)=>{const d=l.bits;let h=0,f=0,x=0,b=0,m=0,w=0,v=0,P=0,_=0,q=0,T,B,Q,me,ce,$=null,D;const Y=new Uint16Array(Wi+1),N=new Uint16Array(Wi+1);let I=null,k,L,H;for(h=0;h<=Wi;h++)Y[h]=0;for(f=0;f<r;f++)Y[t[n+f]]++;for(m=d,b=Wi;b>=1&&Y[b]===0;b--);if(m>b&&(m=b),b===0)return s[i++]=1<<24|64<<16|0,s[i++]=1<<24|64<<16|0,l.bits=1,0;for(x=1;x<b&&Y[x]===0;x++);for(m<x&&(m=x),P=1,h=1;h<=Wi;h++)if(P<<=1,P-=Y[h],P<0)return-1;if(P>0&&(e===vh||b!==1))return-1;for(N[1]=0,h=1;h<Wi;h++)N[h+1]=N[h]+Y[h];for(f=0;f<r;f++)t[n+f]!==0&&(c[N[t[n+f]]++]=f);if(e===vh?($=I=c,D=20):e===Fc?($=F2,I=T2,D=257):($=D2,I=R2,D=0),q=0,f=0,h=x,ce=i,w=m,v=0,Q=-1,_=1<<m,me=_-1,e===Fc&&_>yh||e===_h&&_>bh)return 1;for(;;){k=h-v,c[f]+1<D?(L=0,H=c[f]):c[f]>=D?(L=I[c[f]-D],H=$[c[f]-D]):(L=96,H=0),T=1<<h-v,B=1<<w,x=B;do B-=T,s[ce+(q>>v)+B]=k<<24|L<<16|H|0;while(B!==0);for(T=1<<h-1;q&T;)T>>=1;if(T!==0?(q&=T-1,q+=T):q=0,f++,--Y[h]===0){if(h===b)break;h=t[n+c[f]]}if(h>m&&(q&me)!==Q){for(v===0&&(v=m),ce+=x,w=h-v,P=1<<w;w+v<b&&(P-=Y[w+v],!(P<=0));)w++,P<<=1;if(_+=1<<w,e===Fc&&_>yh||e===_h&&_>bh)return 1;Q=q&me,s[Q]=m<<24|w<<16|ce-i|0}}return q!==0&&(s[ce+q]=h-v<<24|64<<16|0),l.bits=m,0};var Bo=B2;const O2=0,Wm=1,Gm=2,{Z_FINISH:wh,Z_BLOCK:q2,Z_TREES:xl,Z_OK:yi,Z_STREAM_END:z2,Z_NEED_DICT:$2,Z_STREAM_ERROR:ja,Z_DATA_ERROR:Ym,Z_MEM_ERROR:Km,Z_BUF_ERROR:H2,Z_DEFLATED:Nh}=Hm,ic=16180,jh=16181,Sh=16182,Lh=16183,Ah=16184,kh=16185,Ch=16186,Ph=16187,Eh=16188,Mh=16189,Ul=16190,us=16191,Tc=16192,Ih=16193,Dc=16194,Fh=16195,Th=16196,Dh=16197,Rh=16198,yl=16199,bl=16200,Bh=16201,Oh=16202,qh=16203,zh=16204,$h=16205,Rc=16206,Hh=16207,Uh=16208,Mn=16209,Qm=16210,Jm=16211,U2=852,V2=592,W2=15,G2=W2,Vh=e=>(e>>>24&255)+(e>>>8&65280)+((e&65280)<<8)+((e&255)<<24);function Y2(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const Si=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.mode<ic||t.mode>Jm?1:0},Xm=e=>{if(Si(e))return ja;const t=e.state;return e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=t.wrap&1),t.mode=ic,t.last=0,t.havedict=0,t.flags=-1,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(U2),t.distcode=t.distdyn=new Int32Array(V2),t.sane=1,t.back=-1,yi},Zm=e=>{if(Si(e))return ja;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,Xm(e)},ep=(e,t)=>{let n;if(Si(e))return ja;const r=e.state;return t<0?(n=0,t=-t):(n=(t>>4)+5,t<48&&(t&=15)),t&&(t<8||t>15)?ja:(r.window!==null&&r.wbits!==t&&(r.window=null),r.wrap=n,r.wbits=t,Zm(e))},tp=(e,t)=>{if(!e)return ja;const n=new Y2;e.state=n,n.strm=e,n.window=null,n.mode=ic;const r=ep(e,t);return r!==yi&&(e.state=null),r},K2=e=>tp(e,G2);let Wh=!0,Bc,Oc;const Q2=e=>{if(Wh){Bc=new Int32Array(512),Oc=new Int32Array(32);let t=0;for(;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(Bo(Wm,e.lens,0,288,Bc,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;Bo(Gm,e.lens,0,32,Oc,0,e.work,{bits:5}),Wh=!1}e.lencode=Bc,e.lenbits=9,e.distcode=Oc,e.distbits=5},np=(e,t,n,r)=>{let s;const i=e.state;return i.window===null&&(i.wsize=1<<i.wbits,i.wnext=0,i.whave=0,i.window=new Uint8Array(i.wsize)),r>=i.wsize?(i.window.set(t.subarray(n-i.wsize,n),0),i.wnext=0,i.whave=i.wsize):(s=i.wsize-i.wnext,s>r&&(s=r),i.window.set(t.subarray(n-r,n-r+s),i.wnext),r-=s,r?(i.window.set(t.subarray(n-r,n),0),i.wnext=r,i.whave=i.wsize):(i.wnext+=s,i.wnext===i.wsize&&(i.wnext=0),i.whave<i.wsize&&(i.whave+=s))),0},J2=(e,t)=>{let n,r,s,i,c,l,d,h,f,x,b,m,w,v,P=0,_,q,T,B,Q,me,ce,$;const D=new Uint8Array(4);let Y,N;const I=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(Si(e)||!e.output||!e.input&&e.avail_in!==0)return ja;n=e.state,n.mode===us&&(n.mode=Tc),c=e.next_out,s=e.output,d=e.avail_out,i=e.next_in,r=e.input,l=e.avail_in,h=n.hold,f=n.bits,x=l,b=d,$=yi;e:for(;;)switch(n.mode){case ic:if(n.wrap===0){n.mode=Tc;break}for(;f<16;){if(l===0)break e;l--,h+=r[i++]<<f,f+=8}if(n.wrap&2&&h===35615){n.wbits===0&&(n.wbits=15),n.check=0,D[0]=h&255,D[1]=h>>>8&255,n.check=Va(n.check,D,2,0),h=0,f=0,n.mode=jh;break}if(n.head&&(n.head.done=!1),!(n.wrap&1)||(((h&255)<<8)+(h>>8))%31){e.msg="incorrect header check",n.mode=Mn;break}if((h&15)!==Nh){e.msg="unknown compression method",n.mode=Mn;break}if(h>>>=4,f-=4,ce=(h&15)+8,n.wbits===0&&(n.wbits=ce),ce>15||ce>n.wbits){e.msg="invalid window size",n.mode=Mn;break}n.dmax=1<<n.wbits,n.flags=0,e.adler=n.check=1,n.mode=h&512?Mh:us,h=0,f=0;break;case jh:for(;f<16;){if(l===0)break e;l--,h+=r[i++]<<f,f+=8}if(n.flags=h,(n.flags&255)!==Nh){e.msg="unknown compression method",n.mode=Mn;break}if(n.flags&57344){e.msg="unknown header flags set",n.mode=Mn;break}n.head&&(n.head.text=h>>8&1),n.flags&512&&n.wrap&4&&(D[0]=h&255,D[1]=h>>>8&255,n.check=Va(n.check,D,2,0)),h=0,f=0,n.mode=Sh;case Sh:for(;f<32;){if(l===0)break e;l--,h+=r[i++]<<f,f+=8}n.head&&(n.head.time=h),n.flags&512&&n.wrap&4&&(D[0]=h&255,D[1]=h>>>8&255,D[2]=h>>>16&255,D[3]=h>>>24&255,n.check=Va(n.check,D,4,0)),h=0,f=0,n.mode=Lh;case Lh:for(;f<16;){if(l===0)break e;l--,h+=r[i++]<<f,f+=8}n.head&&(n.head.xflags=h&255,n.head.os=h>>8),n.flags&512&&n.wrap&4&&(D[0]=h&255,D[1]=h>>>8&255,n.check=Va(n.check,D,2,0)),h=0,f=0,n.mode=Ah;case Ah:if(n.flags&1024){for(;f<16;){if(l===0)break e;l--,h+=r[i++]<<f,f+=8}n.length=h,n.head&&(n.head.extra_len=h),n.flags&512&&n.wrap&4&&(D[0]=h&255,D[1]=h>>>8&255,n.check=Va(n.check,D,2,0)),h=0,f=0}else n.head&&(n.head.extra=null);n.mode=kh;case kh:if(n.flags&1024&&(m=n.length,m>l&&(m=l),m&&(n.head&&(ce=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Uint8Array(n.head.extra_len)),n.head.extra.set(r.subarray(i,i+m),ce)),n.flags&512&&n.wrap&4&&(n.check=Va(n.check,r,m,i)),l-=m,i+=m,n.length-=m),n.length))break e;n.length=0,n.mode=Ch;case Ch:if(n.flags&2048){if(l===0)break e;m=0;do ce=r[i+m++],n.head&&ce&&n.length<65536&&(n.head.name+=String.fromCharCode(ce));while(ce&&m<l);if(n.flags&512&&n.wrap&4&&(n.check=Va(n.check,r,m,i)),l-=m,i+=m,ce)break e}else n.head&&(n.head.name=null);n.length=0,n.mode=Ph;case Ph:if(n.flags&4096){if(l===0)break e;m=0;do ce=r[i+m++],n.head&&ce&&n.length<65536&&(n.head.comment+=String.fromCharCode(ce));while(ce&&m<l);if(n.flags&512&&n.wrap&4&&(n.check=Va(n.check,r,m,i)),l-=m,i+=m,ce)break e}else n.head&&(n.head.comment=null);n.mode=Eh;case Eh:if(n.flags&512){for(;f<16;){if(l===0)break e;l--,h+=r[i++]<<f,f+=8}if(n.wrap&4&&h!==(n.check&65535)){e.msg="header crc mismatch",n.mode=Mn;break}h=0,f=0}n.head&&(n.head.hcrc=n.flags>>9&1,n.head.done=!0),e.adler=n.check=0,n.mode=us;break;case Mh:for(;f<32;){if(l===0)break e;l--,h+=r[i++]<<f,f+=8}e.adler=n.check=Vh(h),h=0,f=0,n.mode=Ul;case Ul:if(n.havedict===0)return e.next_out=c,e.avail_out=d,e.next_in=i,e.avail_in=l,n.hold=h,n.bits=f,$2;e.adler=n.check=1,n.mode=us;case us:if(t===q2||t===xl)break e;case Tc:if(n.last){h>>>=f&7,f-=f&7,n.mode=Rc;break}for(;f<3;){if(l===0)break e;l--,h+=r[i++]<<f,f+=8}switch(n.last=h&1,h>>>=1,f-=1,h&3){case 0:n.mode=Ih;break;case 1:if(Q2(n),n.mode=yl,t===xl){h>>>=2,f-=2;break e}break;case 2:n.mode=Th;break;case 3:e.msg="invalid block type",n.mode=Mn}h>>>=2,f-=2;break;case Ih:for(h>>>=f&7,f-=f&7;f<32;){if(l===0)break e;l--,h+=r[i++]<<f,f+=8}if((h&65535)!==(h>>>16^65535)){e.msg="invalid stored block lengths",n.mode=Mn;break}if(n.length=h&65535,h=0,f=0,n.mode=Dc,t===xl)break e;case Dc:n.mode=Fh;case Fh:if(m=n.length,m){if(m>l&&(m=l),m>d&&(m=d),m===0)break e;s.set(r.subarray(i,i+m),c),l-=m,i+=m,d-=m,c+=m,n.length-=m;break}n.mode=us;break;case Th:for(;f<14;){if(l===0)break e;l--,h+=r[i++]<<f,f+=8}if(n.nlen=(h&31)+257,h>>>=5,f-=5,n.ndist=(h&31)+1,h>>>=5,f-=5,n.ncode=(h&15)+4,h>>>=4,f-=4,n.nlen>286||n.ndist>30){e.msg="too many length or distance symbols",n.mode=Mn;break}n.have=0,n.mode=Dh;case Dh:for(;n.have<n.ncode;){for(;f<3;){if(l===0)break e;l--,h+=r[i++]<<f,f+=8}n.lens[I[n.have++]]=h&7,h>>>=3,f-=3}for(;n.have<19;)n.lens[I[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,Y={bits:n.lenbits},$=Bo(O2,n.lens,0,19,n.lencode,0,n.work,Y),n.lenbits=Y.bits,$){e.msg="invalid code lengths set",n.mode=Mn;break}n.have=0,n.mode=Rh;case Rh:for(;n.have<n.nlen+n.ndist;){for(;P=n.lencode[h&(1<<n.lenbits)-1],_=P>>>24,q=P>>>16&255,T=P&65535,!(_<=f);){if(l===0)break e;l--,h+=r[i++]<<f,f+=8}if(T<16)h>>>=_,f-=_,n.lens[n.have++]=T;else{if(T===16){for(N=_+2;f<N;){if(l===0)break e;l--,h+=r[i++]<<f,f+=8}if(h>>>=_,f-=_,n.have===0){e.msg="invalid bit length repeat",n.mode=Mn;break}ce=n.lens[n.have-1],m=3+(h&3),h>>>=2,f-=2}else if(T===17){for(N=_+3;f<N;){if(l===0)break e;l--,h+=r[i++]<<f,f+=8}h>>>=_,f-=_,ce=0,m=3+(h&7),h>>>=3,f-=3}else{for(N=_+7;f<N;){if(l===0)break e;l--,h+=r[i++]<<f,f+=8}h>>>=_,f-=_,ce=0,m=11+(h&127),h>>>=7,f-=7}if(n.have+m>n.nlen+n.ndist){e.msg="invalid bit length repeat",n.mode=Mn;break}for(;m--;)n.lens[n.have++]=ce}}if(n.mode===Mn)break;if(n.lens[256]===0){e.msg="invalid code -- missing end-of-block",n.mode=Mn;break}if(n.lenbits=9,Y={bits:n.lenbits},$=Bo(Wm,n.lens,0,n.nlen,n.lencode,0,n.work,Y),n.lenbits=Y.bits,$){e.msg="invalid literal/lengths set",n.mode=Mn;break}if(n.distbits=6,n.distcode=n.distdyn,Y={bits:n.distbits},$=Bo(Gm,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,Y),n.distbits=Y.bits,$){e.msg="invalid distances set",n.mode=Mn;break}if(n.mode=yl,t===xl)break e;case yl:n.mode=bl;case bl:if(l>=6&&d>=258){e.next_out=c,e.avail_out=d,e.next_in=i,e.avail_in=l,n.hold=h,n.bits=f,I2(e,b),c=e.next_out,s=e.output,d=e.avail_out,i=e.next_in,r=e.input,l=e.avail_in,h=n.hold,f=n.bits,n.mode===us&&(n.back=-1);break}for(n.back=0;P=n.lencode[h&(1<<n.lenbits)-1],_=P>>>24,q=P>>>16&255,T=P&65535,!(_<=f);){if(l===0)break e;l--,h+=r[i++]<<f,f+=8}if(q&&!(q&240)){for(B=_,Q=q,me=T;P=n.lencode[me+((h&(1<<B+Q)-1)>>B)],_=P>>>24,q=P>>>16&255,T=P&65535,!(B+_<=f);){if(l===0)break e;l--,h+=r[i++]<<f,f+=8}h>>>=B,f-=B,n.back+=B}if(h>>>=_,f-=_,n.back+=_,n.length=T,q===0){n.mode=$h;break}if(q&32){n.back=-1,n.mode=us;break}if(q&64){e.msg="invalid literal/length code",n.mode=Mn;break}n.extra=q&15,n.mode=Bh;case Bh:if(n.extra){for(N=n.extra;f<N;){if(l===0)break e;l--,h+=r[i++]<<f,f+=8}n.length+=h&(1<<n.extra)-1,h>>>=n.extra,f-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=Oh;case Oh:for(;P=n.distcode[h&(1<<n.distbits)-1],_=P>>>24,q=P>>>16&255,T=P&65535,!(_<=f);){if(l===0)break e;l--,h+=r[i++]<<f,f+=8}if(!(q&240)){for(B=_,Q=q,me=T;P=n.distcode[me+((h&(1<<B+Q)-1)>>B)],_=P>>>24,q=P>>>16&255,T=P&65535,!(B+_<=f);){if(l===0)break e;l--,h+=r[i++]<<f,f+=8}h>>>=B,f-=B,n.back+=B}if(h>>>=_,f-=_,n.back+=_,q&64){e.msg="invalid distance code",n.mode=Mn;break}n.offset=T,n.extra=q&15,n.mode=qh;case qh:if(n.extra){for(N=n.extra;f<N;){if(l===0)break e;l--,h+=r[i++]<<f,f+=8}n.offset+=h&(1<<n.extra)-1,h>>>=n.extra,f-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){e.msg="invalid distance too far back",n.mode=Mn;break}n.mode=zh;case zh:if(d===0)break e;if(m=b-d,n.offset>m){if(m=n.offset-m,m>n.whave&&n.sane){e.msg="invalid distance too far back",n.mode=Mn;break}m>n.wnext?(m-=n.wnext,w=n.wsize-m):w=n.wnext-m,m>n.length&&(m=n.length),v=n.window}else v=s,w=c-n.offset,m=n.length;m>d&&(m=d),d-=m,n.length-=m;do s[c++]=v[w++];while(--m);n.length===0&&(n.mode=bl);break;case $h:if(d===0)break e;s[c++]=n.length,d--,n.mode=bl;break;case Rc:if(n.wrap){for(;f<32;){if(l===0)break e;l--,h|=r[i++]<<f,f+=8}if(b-=d,e.total_out+=b,n.total+=b,n.wrap&4&&b&&(e.adler=n.check=n.flags?Va(n.check,s,b,c-b):Sd(n.check,s,b,c-b)),b=d,n.wrap&4&&(n.flags?h:Vh(h))!==n.check){e.msg="incorrect data check",n.mode=Mn;break}h=0,f=0}n.mode=Hh;case Hh:if(n.wrap&&n.flags){for(;f<32;){if(l===0)break e;l--,h+=r[i++]<<f,f+=8}if(n.wrap&4&&h!==(n.total&4294967295)){e.msg="incorrect length check",n.mode=Mn;break}h=0,f=0}n.mode=Uh;case Uh:$=z2;break e;case Mn:$=Ym;break e;case Qm:return Km;case Jm:default:return ja}return e.next_out=c,e.avail_out=d,e.next_in=i,e.avail_in=l,n.hold=h,n.bits=f,(n.wsize||b!==e.avail_out&&n.mode<Mn&&(n.mode<Rc||t!==wh))&&np(e,e.output,e.next_out,b-e.avail_out),x-=e.avail_in,b-=e.avail_out,e.total_in+=x,e.total_out+=b,n.total+=b,n.wrap&4&&b&&(e.adler=n.check=n.flags?Va(n.check,s,b,e.next_out-b):Sd(n.check,s,b,e.next_out-b)),e.data_type=n.bits+(n.last?64:0)+(n.mode===us?128:0)+(n.mode===yl||n.mode===Dc?256:0),(x===0&&b===0||t===wh)&&$===yi&&($=H2),$},X2=e=>{if(Si(e))return ja;let t=e.state;return t.window&&(t.window=null),e.state=null,yi}
vendor: 11,895 bytes, line 18
18,Z2=(e,t)=>{if(Si(e))return ja;const n=e.state;return n.wrap&2?(n.head=t,t.done=!1,yi):ja},e5=(e,t)=>{const n=t.length;let r,s,i;return Si(e)||(r=e.state,r.wrap!==0&&r.mode!==Ul)?ja:r.mode===Ul&&(s=1,s=Sd(s,t,n,0),s!==r.check)?Ym:(i=np(e,t,n,n),i?(r.mode=Qm,Km):(r.havedict=1,yi))};var t5=Zm,n5=ep,r5=Xm,a5=K2,s5=tp,i5=J2,o5=X2,l5=Z2,c5=e5,d5="pako inflate (from Nodeca project)",fs={inflateReset:t5,inflateReset2:n5,inflateResetKeep:r5,inflateInit:a5,inflateInit2:s5,inflate:i5,inflateEnd:o5,inflateGetHeader:l5,inflateSetDictionary:c5,inflateInfo:d5};function u5(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}var h5=u5;const rp=Object.prototype.toString,{Z_NO_FLUSH:f5,Z_FINISH:m5,Z_OK:Go,Z_STREAM_END:qc,Z_NEED_DICT:zc,Z_STREAM_ERROR:p5,Z_DATA_ERROR:Gh,Z_MEM_ERROR:g5}=Hm;function Yo(e){this.options=Um.assign({chunkSize:1024*64,windowBits:15,to:""},e||{});const t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,t.windowBits===0&&(t.windowBits=-15)),t.windowBits>=0&&t.windowBits<16&&!(e&&e.windowBits)&&(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&(t.windowBits&15||(t.windowBits|=15)),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new E2,this.strm.avail_out=0;let n=fs.inflateInit2(this.strm,t.windowBits);if(n!==Go)throw new Error(Ld[n]);if(this.header=new h5,fs.inflateGetHeader(this.strm,this.header),t.dictionary&&(typeof t.dictionary=="string"?t.dictionary=Ad.string2buf(t.dictionary):rp.call(t.dictionary)==="[object ArrayBuffer]"&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(n=fs.inflateSetDictionary(this.strm,t.dictionary),n!==Go)))throw new Error(Ld[n])}Yo.prototype.push=function(e,t){const n=this.strm,r=this.options.chunkSize,s=this.options.dictionary;let i,c,l;if(this.ended)return!1;for(t===~~t?c=t:c=t===!0?m5:f5,rp.call(e)==="[object ArrayBuffer]"?n.input=new Uint8Array(e):n.input=e,n.next_in=0,n.avail_in=n.input.length;;){for(n.avail_out===0&&(n.output=new Uint8Array(r),n.next_out=0,n.avail_out=r),i=fs.inflate(n,c),i===zc&&s&&(i=fs.inflateSetDictionary(n,s),i===Go?i=fs.inflate(n,c):i===Gh&&(i=zc));n.avail_in>0&&i===qc&&n.state.wrap>0&&e[n.next_in]!==0;)fs.inflateReset(n),i=fs.inflate(n,c);switch(i){case p5:case Gh:case zc:case g5:return this.onEnd(i),this.ended=!0,!1}if(l=n.avail_out,n.next_out&&(n.avail_out===0||i===qc))if(this.options.to==="string"){let d=Ad.utf8border(n.output,n.next_out),h=n.next_out-d,f=Ad.buf2string(n.output,d);n.next_out=h,n.avail_out=r-h,h&&n.output.set(n.output.subarray(d,d+h),0),this.onData(f)}else this.onData(n.output.length===n.next_out?n.output:n.output.subarray(0,n.next_out));if(!(i===Go&&l===0)){if(i===qc)return i=fs.inflateEnd(this.strm),this.onEnd(i),this.ended=!0,!0;if(n.avail_in===0)break}}return!0};Yo.prototype.onData=function(e){this.chunks.push(e)};Yo.prototype.onEnd=function(e){e===Go&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=Um.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function x5(e,t){const n=new Yo(t);if(n.push(e),n.err)throw n.msg||Ld[n.err];return n.result}var y5=Yo,b5=x5,v5={Inflate:y5,inflate:b5};const{Inflate:_5,inflate:w5}=v5;var Yh=_5,N5=w5;const ap=[];for(let e=0;e<256;e++){let t=e;for(let n=0;n<8;n++)t&1?t=3988292384^t>>>1:t=t>>>1;ap[e]=t}const Kh=4294967295;function j5(e,t,n){let r=e;for(let s=0;s<n;s++)r=ap[(r^t[s])&255]^r>>>8;return r}function S5(e,t){return(j5(Kh,e,t)^Kh)>>>0}function Qh(e,t,n){const r=e.readUint32(),s=S5(new Uint8Array(e.buffer,e.byteOffset+e.offset-t-4,t),t);if(s!==r)throw new Error(`CRC mismatch for chunk ${n}. Expected ${r}, found ${s}`)}function sp(e,t,n){for(let r=0;r<n;r++)t[r]=e[r]}function ip(e,t,n,r){let s=0;for(;s<r;s++)t[s]=e[s];for(;s<n;s++)t[s]=e[s]+t[s-r]&255}function op(e,t,n,r){let s=0;if(n.length===0)for(;s<r;s++)t[s]=e[s];else for(;s<r;s++)t[s]=e[s]+n[s]&255}function lp(e,t,n,r,s){let i=0;if(n.length===0){for(;i<s;i++)t[i]=e[i];for(;i<r;i++)t[i]=e[i]+(t[i-s]>>1)&255}else{for(;i<s;i++)t[i]=e[i]+(n[i]>>1)&255;for(;i<r;i++)t[i]=e[i]+(t[i-s]+n[i]>>1)&255}}function cp(e,t,n,r,s){let i=0;if(n.length===0){for(;i<s;i++)t[i]=e[i];for(;i<r;i++)t[i]=e[i]+t[i-s]&255}else{for(;i<s;i++)t[i]=e[i]+n[i]&255;for(;i<r;i++)t[i]=e[i]+L5(t[i-s],n[i],n[i-s])&255}}function L5(e,t,n){const r=e+t-n,s=Math.abs(r-e),i=Math.abs(r-t),c=Math.abs(r-n);return s<=i&&s<=c?e:i<=c?t:n}function A5(e,t,n,r,s,i){switch(e){case 0:sp(t,n,s);break;case 1:ip(t,n,s,i);break;case 2:op(t,n,r,s);break;case 3:lp(t,n,r,s,i);break;case 4:cp(t,n,r,s,i);break;default:throw new Error(`Unsupported filter: ${e}`)}}const k5=new Uint16Array([255]),C5=new Uint8Array(k5.buffer),P5=C5[0]===255;function E5(e){const{data:t,width:n,height:r,channels:s,depth:i}=e,c=[{x:0,y:0,xStep:8,yStep:8},{x:4,y:0,xStep:8,yStep:8},{x:0,y:4,xStep:4,yStep:8},{x:2,y:0,xStep:4,yStep:4},{x:0,y:2,xStep:2,yStep:4},{x:1,y:0,xStep:2,yStep:2},{x:0,y:1,xStep:1,yStep:2}],l=Math.ceil(i/8)*s,d=new Uint8Array(r*n*l);let h=0;for(let f=0;f<7;f++){const x=c[f],b=Math.ceil((n-x.x)/x.xStep),m=Math.ceil((r-x.y)/x.yStep);if(b<=0||m<=0)continue;const w=b*l,v=new Uint8Array(w);for(let P=0;P<m;P++){const _=t[h++],q=t.subarray(h,h+w);h+=w;const T=new Uint8Array(w);A5(_,q,T,v,w,l),v.set(T);for(let B=0;B<b;B++){const Q=x.x+B*x.xStep,me=x.y+P*x.yStep;if(!(Q>=n||me>=r))for(let ce=0;ce<l;ce++)d[(me*n+Q)*l+ce]=T[B*l+ce]}}}if(i===16){const f=new Uint16Array(d.buffer);if(P5)for(let x=0;x<f.length;x++)f[x]=M5(f[x]);return f}else return d}function M5(e){return(e&255)<<8|e>>8&255}const I5=new Uint16Array([255]),F5=new Uint8Array(I5.buffer),T5=F5[0]===255,D5=new Uint8Array(0);function Jh(e){const{data:t,width:n,height:r,channels:s,depth:i}=e,c=Math.ceil(i/8)*s,l=Math.ceil(i/8*s*n),d=new Uint8Array(r*l);let h=D5,f=0,x,b;for(let m=0;m<r;m++){switch(x=t.subarray(f+1,f+1+l),b=d.subarray(m*l,(m+1)*l),t[f]){case 0:sp(x,b,l);break;case 1:ip(x,b,l,c);break;case 2:op(x,b,h,l);break;case 3:lp(x,b,h,l,c);break;case 4:cp(x,b,h,l,c);break;default:throw new Error(`Unsupported filter: ${t[f]}`)}h=b,f+=l+1}if(i===16){const m=new Uint16Array(d.buffer);if(T5)for(let w=0;w<m.length;w++)m[w]=R5(m[w]);return m}else return d}function R5(e){return(e&255)<<8|e>>8&255}const Il=Uint8Array.of(137,80,78,71,13,10,26,10);function Xh(e){if(!B5(e.readBytes(Il.length)))throw new Error("wrong PNG signature")}function B5(e){if(e.length<Il.length)return!1;for(let t=0;t<Il.length;t++)if(e[t]!==Il[t])return!1;return!0}const O5="tEXt",q5=0,dp=new TextDecoder("latin1");function z5(e){if(H5(e),e.length===0||e.length>79)throw new Error("keyword length must be between 1 and 79")}const $5=/^[\u0000-\u00FF]*$/;function H5(e){if(!$5.test(e))throw new Error("invalid latin1 text")}function U5(e,t,n){const r=up(t);e[r]=V5(t,n-r.length-1)}function up(e){for(e.mark();e.readByte()!==q5;);const t=e.offset;e.reset();const n=dp.decode(e.readBytes(t-e.offset-1));return e.skip(1),z5(n),n}function V5(e,t){return dp.decode(e.readBytes(t))}const ca={UNKNOWN:-1,GREYSCALE:0,TRUECOLOUR:2,INDEXED_COLOUR:3,GREYSCALE_ALPHA:4,TRUECOLOUR_ALPHA:6},$c={UNKNOWN:-1,DEFLATE:0},Zh={UNKNOWN:-1,ADAPTIVE:0},Hc={UNKNOWN:-1,NO_INTERLACE:0,ADAM7:1},vl={NONE:0,BACKGROUND:1,PREVIOUS:2},Uc={SOURCE:0,OVER:1};class W5 extends Zd{constructor(n,r={}){super(n);mn(this,"_checkCrc");mn(this,"_inflator");mn(this,"_png");mn(this,"_apng");mn(this,"_end");mn(this,"_hasPalette");mn(this,"_palette");mn(this,"_hasTransparency");mn(this,"_transparency");mn(this,"_compressionMethod");mn(this,"_filterMethod");mn(this,"_interlaceMethod");mn(this,"_colorType");mn(this,"_isAnimated");mn(this,"_numberOfFrames");mn(this,"_numberOfPlays");mn(this,"_frames");mn(this,"_writingDataChunks");const{checkCrc:s=!1}=r;this._checkCrc=s,this._inflator=new Yh,this._png={width:-1,height:-1,channels:-1,data:new Uint8Array(0),depth:1,text:{}},this._apng={width:-1,height:-1,channels:-1,depth:1,numberOfFrames:1,numberOfPlays:0,text:{},frames:[]},this._end=!1,this._hasPalette=!1,this._palette=[],this._hasTransparency=!1,this._transparency=new Uint16Array(0),this._compressionMethod=$c.UNKNOWN,this._filterMethod=Zh.UNKNOWN,this._interlaceMethod=Hc.UNKNOWN,this._colorType=ca.UNKNOWN,this._isAnimated=!1,this._numberOfFrames=1,this._numberOfPlays=0,this._frames=[],this._writingDataChunks=!1,this.setBigEndian()}decode(){for(Xh(this);!this._end;){const n=this.readUint32(),r=this.readChars(4);this.decodeChunk(n,r)}return this.decodeImage(),this._png}decodeApng(){for(Xh(this);!this._end;){const n=this.readUint32(),r=this.readChars(4);this.decodeApngChunk(n,r)}return this.decodeApngImage(),this._apng}decodeChunk(n,r){const s=this.offset;switch(r){case"IHDR":this.decodeIHDR();break;case"PLTE":this.decodePLTE(n);break;case"IDAT":this.decodeIDAT(n);break;case"IEND":this._end=!0;break;case"tRNS":this.decodetRNS(n);break;case"iCCP":this.decodeiCCP(n);break;case O5:U5(this._png.text,this,n);break;case"pHYs":this.decodepHYs();break;default:this.skip(n);break}if(this.offset-s!==n)throw new Error(`Length mismatch while decoding chunk ${r}`);this._checkCrc?Qh(this,n+4,r):this.skip(4)}decodeApngChunk(n,r){const s=this.offset;switch(r!=="fdAT"&&r!=="IDAT"&&this._writingDataChunks&&this.pushDataToFrame(),r){case"acTL":this.decodeACTL();break;case"fcTL":this.decodeFCTL();break;case"fdAT":this.decodeFDAT(n);break;default:this.decodeChunk(n,r),this.offset=s+n;break}if(this.offset-s!==n)throw new Error(`Length mismatch while decoding chunk ${r}`);this._checkCrc?Qh(this,n+4,r):this.skip(4)}decodeIHDR(){const n=this._png;n.width=this.readUint32(),n.height=this.readUint32(),n.depth=G5(this.readUint8());const r=this.readUint8();this._colorType=r;let s;switch(r){case ca.GREYSCALE:s=1;break;case ca.TRUECOLOUR:s=3;break;case ca.INDEXED_COLOUR:s=1;break;case ca.GREYSCALE_ALPHA:s=2;break;case ca.TRUECOLOUR_ALPHA:s=4;break;case ca.UNKNOWN:default:throw new Error(`Unknown color type: ${r}`)}if(this._png.channels=s,this._compressionMethod=this.readUint8(),this._compressionMethod!==$c.DEFLATE)throw new Error(`Unsupported compression method: ${this._compressionMethod}`);this._filterMethod=this.readUint8(),this._interlaceMethod=this.readUint8()}decodeACTL(){this._numberOfFrames=this.readUint32(),this._numberOfPlays=this.readUint32(),this._isAnimated=!0}decodeFCTL(){const n={sequenceNumber:this.readUint32(),width:this.readUint32(),height:this.readUint32(),xOffset:this.readUint32(),yOffset:this.readUint32(),delayNumber:this.readUint16(),delayDenominator:this.readUint16(),disposeOp:this.readUint8(),blendOp:this.readUint8(),data:new Uint8Array(0)};this._frames.push(n)}decodePLTE(n){if(n%3!==0)throw new RangeError(`PLTE field length must be a multiple of 3. Got ${n}`);const r=n/3;this._hasPalette=!0;const s=[];this._palette=s;for(let i=0;i<r;i++)s.push([this.readUint8(),this.readUint8(),this.readUint8()])}decodeIDAT(n){this._writingDataChunks=!0;const r=n,s=this.offset+this.byteOffset;if(this._inflator.push(new Uint8Array(this.buffer,s,r)),this._inflator.err)throw new Error(`Error while decompressing the data: ${this._inflator.err}`);this.skip(n)}decodeFDAT(n){this._writingDataChunks=!0;let r=n,s=this.offset+this.byteOffset;if(s+=4,r-=4,this._inflator.push(new Uint8Array(this.buffer,s,r)),this._inflator.err)throw new Error(`Error while decompressing the data: ${this._inflator.err}`);this.skip(n)}decodetRNS(n){switch(this._colorType){case ca.GREYSCALE:case ca.TRUECOLOUR:{if(n%2!==0)throw new RangeError(`tRNS chunk length must be a multiple of 2. Got ${n}`);if(n/2>this._png.width*this._png.height)throw new Error(`tRNS chunk contains more alpha values than there are pixels (${n/2} vs ${this._png.width*this._png.height})`);this._hasTransparency=!0,this._transparency=new Uint16Array(n/2);for(let r=0;r<n/2;r++)this._transparency[r]=this.readUint16();break}case ca.INDEXED_COLOUR:{if(n>this._palette.length)throw new Error(`tRNS chunk contains more alph
18a values than there are palette colors (${n} vs ${this._palette.length})`);let r=0;for(;r<n;r++){const s=this.readByte();this._palette[r].push(s)}for(;r<this._palette.length;r++)this._palette[r].push(255);break}case ca.UNKNOWN:case ca.GREYSCALE_ALPHA:case ca.TRUECOLOUR_ALPHA:default:throw new Error(`tRNS chunk is not supported for color type ${this._colorType}`)}}decodeiCCP(n){const r=up(this),s=this.readUint8();if(s!==$c.DEFLATE)throw new Error(`Unsupported iCCP compression method: ${s}`);const i=this.readBytes(n-r.length-2);this._png.iccEmbeddedProfile={name:r,profile:N5(i)}}decodepHYs(){const n=this.readUint32(),r=this.readUint32(),s=this.readByte();this._png.resolution={x:n,y:r,unit:s}}decodeApngImage(){this._apng.width=this._png.width,this._apng.height=this._png.height,this._apng.channels=this._png.channels,this._apng.depth=this._png.depth,this._apng.numberOfFrames=this._numberOfFrames,this._apng.numberOfPlays=this._numberOfPlays,this._apng.text=this._png.text,this._apng.resolution=this._png.resolution;for(let n=0;n<this._numberOfFrames;n++){const r={sequenceNumber:this._frames[n].sequenceNumber,delayNumber:this._frames[n].delayNumber,delayDenominator:this._frames[n].delayDenominator,data:this._apng.depth===8?new Uint8Array(this._apng.width*this._apng.height*this._apng.channels):new Uint16Array(this._apng.width*this._apng.height*this._apng.channels)},s=this._frames.at(n);if(s){if(s.data=Jh({data:s.data,width:s.width,height:s.height,channels:this._apng.channels,depth:this._apng.depth}),this._hasPalette&&(this._apng.palette=this._palette),this._hasTransparency&&(this._apng.transparency=this._transparency),n===0||s.xOffset===0&&s.yOffset===0&&s.width===this._png.width&&s.height===this._png.height)r.data=s.data;else{const i=this._apng.frames.at(n-1);this.disposeFrame(s,i,r),this.addFrameDataToCanvas(r,s)}this._apng.frames.push(r)}}return this._apng}disposeFrame(n,r,s){switch(n.disposeOp){case vl.NONE:break;case vl.BACKGROUND:for(let i=0;i<this._png.height;i++)for(let c=0;c<this._png.width;c++){const l=(i*n.width+c)*this._png.channels;for(let d=0;d<this._png.channels;d++)s.data[l+d]=0}break;case vl.PREVIOUS:s.data.set(r.data);break;default:throw new Error("Unknown disposeOp")}}addFrameDataToCanvas(n,r){const s=1<<this._png.depth,i=(c,l)=>{const d=((c+r.yOffset)*this._png.width+r.xOffset+l)*this._png.channels,h=(c*r.width+l)*this._png.channels;return{index:d,frameIndex:h}};switch(r.blendOp){case Uc.SOURCE:for(let c=0;c<r.height;c++)for(let l=0;l<r.width;l++){const{index:d,frameIndex:h}=i(c,l);for(let f=0;f<this._png.channels;f++)n.data[d+f]=r.data[h+f]}break;case Uc.OVER:for(let c=0;c<r.height;c++)for(let l=0;l<r.width;l++){const{index:d,frameIndex:h}=i(c,l);for(let f=0;f<this._png.channels;f++){const x=r.data[h+this._png.channels-1]/s,b=f%(this._png.channels-1)===0?1:r.data[h+f],m=Math.floor(x*b+(1-x)*n.data[d+f]);n.data[d+f]+=m}}break;default:throw new Error("Unknown blendOp")}}decodeImage(){var r;if(this._inflator.err)throw new Error(`Error while decompressing the data: ${this._inflator.err}`);const n=this._isAnimated?((r=this._frames)==null?void 0:r.at(0)).data:this._inflator.result;if(this._filterMethod!==Zh.ADAPTIVE)throw new Error(`Filter method ${this._filterMethod} not supported`);if(this._interlaceMethod===Hc.NO_INTERLACE)this._png.data=Jh({data:n,width:this._png.width,height:this._png.height,channels:this._png.channels,depth:this._png.depth});else if(this._interlaceMethod===Hc.ADAM7)this._png.data=E5({data:n,width:this._png.width,height:this._png.height,channels:this._png.channels,depth:this._png.depth});else throw new Error(`Interlace method ${this._interlaceMethod} not supported`);this._hasPalette&&(this._png.palette=this._palette),this._hasTransparency&&(this._png.transparency=this._transparency)}pushDataToFrame(){const n=this._inflator.result,r=this._frames.at(-1);r?r.data=n:this._frames.push({sequenceNumber:0,width:this._png.width,height:this._png.height,xOffset:0,yOffset:0,delayNumber:0,delayDenominator:0,disposeOp:vl.NONE,blendOp:Uc.SOURCE,data:n}),this._inflator=new Yh,this._writingDataChunks=!1}}function G5(e){if(e!==1&&e!==2&&e!==4&&e!==8&&e!==16)throw new Error(`invalid bit depth: ${e}`);return e}var ef;(function(e){e[e.UNKNOWN=0]="UNKNOWN",e[e.METRE=1]="METRE"})(ef||(ef={}));function Y5(e,t){return new W5(e,t).decode()}var Mt=function(){return typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:this}();function Vc(){Mt.console&&typeof Mt.console.log=="function"&&Mt.console.log.apply(Mt.console,arguments)}var wn={log:Vc,warn:function(e){Mt.console&&(typeof Mt.console.warn=="function"?Mt.console.warn.apply(Mt.console,arguments):Vc.call(null,arguments))},error:function(e){Mt.console&&(typeof Mt.console.error=="function"?Mt.console.error.apply(Mt.console,arguments):Vc(e))}};
vendor: 3,820 bytes, lines 18-23
18function Wc(e,t,n){var r=new XMLHttpRequest;r.open("GET",e),r.responseType="blob",r.onload=function(){ci(r.response,t,n)},r.onerror=function(){wn.error("could not download file")},r.send()}function tf(e){var t=new XMLHttpRequest;t.open("HEAD",e,!1);try{t.send()}catch{}return t.status>=200&&t.status<=299}function _l(e){try{e.dispatchEvent(new MouseEvent("click"))}catch{var t=document.createEvent("MouseEvents");t.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),e.dispatchEvent(t)}}var ci=Mt.saveAs||((typeof window>"u"?"undefined":pn(window))!=="object"||window!==Mt?function(){}:typeof HTMLAnchorElement<"u"&&"download"in HTMLAnchorElement.prototype?function(e,t,n){var r=Mt.URL||Mt.webkitURL,s=document.createElement("a");t=t||e.name||"download",s.download=t,s.rel="noopener",typeof e=="string"?(s.href=e,s.origin!==location.origin?tf(s.href)?Wc(e,t,n):_l(s,s.target="_blank"):_l(s)):(s.href=r.createObjectURL(e),setTimeout(function(){r.revokeObjectURL(s.href)},4e4),setTimeout(function(){_l(s)},0))}:"msSaveOrOpenBlob"in navigator?function(e,t,n){if(t=t||e.name||"download",typeof e=="string")if(tf(e))Wc(e,t,n);else{var r=document.createElement("a");r.href=e,r.target="_blank",setTimeout(function(){_l(r)})}else navigator.msSaveOrOpenBlob(function(s,i){return i===void 0?i={autoBom:!1}:pn(i)!=="object"&&(wn.warn("Deprecated: Expected third argument to be a object"),i={autoBom:!i}),i.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(s.type)?new Blob(["\uFEFF",s],{type:s.type}):s}(e,n),t)}:function(e,t,n,r){if((r=r||open("","_blank"))&&(r.document.title=r.document.body.innerText="downloading..."),typeof e=="string")return Wc(e,t,n);var s=e.type==="application/octet-stream",i=/constructor/i.test(Mt.HTMLElement)||Mt.safari,c=/CriOS\/[\d]+/.test(navigator.userAgent);if((c||s&&i)&&(typeof FileReader>"u"?"undefined":pn(FileReader))==="object"){var l=new FileReader;l.onloadend=function(){var f=l.result;f=c?f:f.replace(/^data:[^;]*;/,"data:attachment/file;"),r?r.location.href=f:location=f,r=null},l.readAsDataURL(e)}else{var d=Mt.URL||Mt.webkitURL,h=d.createObjectURL(e);r?r.location=h:location.href=h,r=null,setTimeout(function(){d.revokeObjectURL(h)},4e4)}});/**
19 * A class to parse color values
20 * @author Stoyan Stefanov <[email protected]>
21 * {@link   http://www.phpied.com/rgb-color-parser-in-javascript/}
22 * @license Use it if you like it
23 */function hp(e){var t;e=e||"",this.ok=!1,e.charAt(0)=="#"&&(e=e.substr(1,6)),e={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"00ffff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000000",blanchedalmond:"ffebcd",blue:"0000ff",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"00ffff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dodgerblue:"1e90ff",feldspar:"d19275",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"ff00ff",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgrey:"d3d3d3",lightgreen:"90ee9
230",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslateblue:"8470ff",lightslategray:"778899",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"00ff00",limegreen:"32cd32",linen:"faf0e6",magenta:"ff00ff",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370d8",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"d87093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",red:"ff0000",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",violetred:"d02090",wheat:"f5deb3",white:"ffffff",whitesmoke:"f5f5f5",yellow:"ffff00",yellowgreen:"9acd32"}[e=(e=e.replace(/ /g,"")).toLowerCase()]||e;for(var n=[{re:/^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/,example:["rgb(123, 234, 45)","rgb(255,234,245)"],process:function(l){return[parseInt(l[1]),parseInt(l[2]),parseInt(l[3])]}},{re:/^(\w{2})(\w{2})(\w{2})$/,example:["#00ff00","336699"],process:function(l){return[parseInt(l[1],16),parseInt(l[2],16),parseInt(l[3],16)]}},{re:/^(\w{1})(\w{1})(\w{1})$/,example:["#fb0","f0f"],process:function(l){return[parseInt(l[1]+l[1],16),parseInt(l[2]+l[2],16),parseInt(l[3]+l[3],16)]}}],r=0;r<n.length;r++){var s=n[r].re,i=n[r].process,c=s.exec(e);c&&(t=i(c),this.r=t[0],this.g=t[1],this.b=t[2],this.ok=!0)}this.r=this.r<0||isNaN(this.r)?0:this.r>255?255:this.r,this.g=this.g<0||isNaN(this.g)?0:this.g>255?255:this.g,this.b=this.b<0||isNaN(this.b)?0:this.b>255?255:this.b,this.toRGB=function(){return"rgb("+this.r+", "+this.g+", "+this.b+")"},this.toHex=function(){var l=this.r.toString(16),d=this.g.toString(16),h=this.b.toString(16);return l.length==1&&(l="0"+l),d.length==1&&(d="0"+d),h.length==1&&(h="0"+h),"#"+l+d+h}}var Fl=Mt.atob.bind(Mt),nf=Mt.btoa.bind(Mt);/**
24 * @license
25 * Joseph Myers does not specify a particular license for his work.
26 *
27 * Author: Joseph Myers
28 * Accessed from: http://www.myersdaily.org/joseph/javascript/md5.js
29 *
30 * Modified by: Owen Leong
31 */function Gc(e,t){var n=e[0],r=e[1],s=e[2],i=e[3];n=Ar(n,r,s,i,t[0],7,-680876936),i=Ar(i,n,r,s,t[1],12,-389564586),s=Ar(s,i,n,r,t[2],17,606105819),r=Ar(r,s,i,n,t[3],22,-1044525330),n=Ar(n,r,s,i,t[4],7,-176418897),i=Ar(i,n,r,s,t[5],12,1200080426),s=Ar(s,i,n,r,t[6],17,-1473231341),r=Ar(r,s,i,n,t[7],22,-45705983),n=Ar(n,r,s,i,t[8],7,1770035416),i=Ar(i,n,r,s,t[9],12,-1958414417),s=Ar(s,i,n,r,t[10],17,-42063),r=Ar(r,s,i,n,t[11],22,-1990404162),n=Ar(n,r,s,i,t[12],7,1804603682),i=Ar(i,n,r,s,t[13],12,-40341101),s=Ar(s,i,n,r,t[14],17,-1502002290),n=kr(n,r=Ar(r,s,i,n,t[15],22,1236535329),s,i,t[1],5,-165796510),i=kr(i,n,r,s,t[6],9,-1069501632),s=kr(s,i,n,r,t[11],14,643717713),r=kr(r,s,i,n,t[0],20,-373897302),n=kr(n,r,s,i,t[5],5,-701558691),i=kr(i,n,r,s,t[10],9,38016083),s=kr(s,i,n,r,t[15],14,-660478335),r=kr(r,s,i,n,t[4],20,-405537848),n=kr(n,r,s,i,t[9],5,568446438),i=kr(i,n,r,s,t[14],9,-1019803690),s=kr(s,i,n,r,t[3],14,-187363961),r=kr(r,s,i,n,t[8],20,1163531501),n=kr(n,r,s,i,t[13],5,-1444681467),i=kr(i,n,r,s,t[2],9,-51403784),s=kr(s,i,n,r,t[7],14,1735328473),n=Cr(n,r=kr(r,s,i,n,t[12],20,-1926607734),s,i,t[5],4,-378558),i=Cr(i,n,r,s,t[8],11,-2022574463),s=Cr(s,i,n,r,t[11],16,1839030562),r=Cr(r,s,i,n,t[14],23,-35309556),n=Cr(n,r,s,i,t[1],4,-1530992060),i=Cr(i,n,r,s,t[4],11,1272893353),s=Cr(s,i,n,r,t[7],16,-155497632),r=Cr(r,s,i,n,t[10],23,-1094730640),n=Cr(n,r,s,i,t[13],4,681279174),i=Cr(i,n,r,s,t[0],11,-358537222),s=Cr(s,i,n,r,t[3],16,-722521979),r=Cr(r,s,i,n,t[6],23,76029189),n=Cr(n,r,s,i,t[9],4,-640364487),i=Cr(i,n,r,s,t[12],11,-421815835),s=Cr(s,i,n,r,t[15],16,530742520),n=Pr(n,r=Cr(r,s,i,n,t[2],23,-995338651),s,i,t[0],6,-198630844),i=Pr(i,n,r,s,t[7],10,1126891415),s=Pr(s,i,n,r,t[14],15,-1416354905),r=Pr(r,s,i,n,t[5],21,-57434055),n=Pr(n,r,s,i,t[12],6,1700485571),i=Pr(i,n,r,s,t[3],10,-1894986606),s=Pr(s,i,n,r,t[10],15,-1051523),r=Pr(r,s,i,n,t[1],21,-2054922799),n=Pr(n,r,s,i,t[8],6,1873313359),i=Pr(i,n,r,s,t[15],10,-30611744),s=Pr(s,i,n,r,t[6],15,-1560198380),r=Pr(r,s,i,n,t[13],21,1309151649),n=Pr(n,r,s,i,t[4],6,-145523070),i=Pr(i,n,r,s,t[11],10,-1120210379),s=Pr(s,i,n,r,t[2],15,718787259),r=Pr(r,s,i,n,t[9],21,-343485551),e[0]=zs(n,e[0]),e[1]=zs(r,e[1]),e[2]=zs(s,e[2]),e[3]=zs(i,e[3])}function oc(e,t,n,r,s,i){return t=zs(zs(t,e),zs(r,i)),zs(t<<s|t>>>32-s,n)}function Ar(e,t,n,r,s,i,c){return oc(t&n|~t&r,e,t,s,i,c)}function kr(e,t,n,r,s,i,c){return oc(t&r|n&~r,e,t,s,i,c)}function Cr(e,t,n,r,s,i,c){return oc(t^n^r,e,t,s,i,c)}function Pr(e,t,n,r,s,i,c){return oc(n^(t|~r),e,t,s,i,c)}function fp(e){var t,n=e.length,r=[1732584193,-271733879,-1732584194,271733878];for(t=64;t<=e.length;t+=64)Gc(r,K5(e.substring(t-64,t)));e=e.substring(t-64);var s=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(t=0;t<e.length;t++)s[t>>2]|=e.charCodeAt(t)<<(t%4<<3);if(s[t>>2]|=128<<(t%4<<3),t>55)for(Gc(r,s),t=0;t<16;t++)s[t]=0;return s[14]=8*n,Gc(r,s),r}function K5(e){var t,n=[];for(t=0;t<64;t+=4)n[t>>2]=e.charCodeAt(t)+(e.charCodeAt(t+1)<<8)+(e.charCodeAt(t+2)<<16)+(e.charCodeAt(t+3)<<24);return n}var rf="0123456789abcdef".split("");function Q5(e){for(var t="",n=0;n<4;n++)t+=rf[e>>8*n+4&15]+rf[e>>8*n&15];return t}function J5(e){return String.fromCharCode(255&e,(65280&e)>>8,(16711680&e)>>16,(4278190080&e)>>24)}function kd(e){return fp(e).map(J5).join("")}var X5=function(e){for(var t=0;t<e.length;t++)e[t]=Q5(e[t]);return e.join("")}(fp("hello"))!="5d41402abc4b2a76b9719d911017c592";function zs(e,t){if(X5){var n=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(n>>16)<<16|65535&n}return e+t&4294967295}/**
32 * @license
33 * FPDF is released under a permissive license: there is no usage restriction.
34 * You may embed it freely in your application (commercial or not), with or
35 * without modifications.
36 *
37 * Reference: http://www.fpdf.org/en/script/script37.php
38 */function Cd(e,t){var n,r,s,i;if(e!==n){for(var c=(s=e,i=1+(256/e.length|0),new Array(i+1).join(s)),l=[],d=0;d<256;d++)l[d]=d;var h=0;for(d=0;d<256;d++){var f=l[d];h=(h+f+c.charCodeAt(d))%256,l[d]=l[h],l[h]=f}n=e,r=l}else l=r;var x=t.length,b=0,m=0,w="";for(d=0;d<x;
vendor: 5,655 bytes, lines 38-48
38d++)m=(m+(f=l[b=(b+1)%256]))%256,l[b]=l[m],l[m]=f,c=l[(l[b]+l[m])%256],w+=String.fromCharCode(t.charCodeAt(d)^c);return w}/**
39 * @license
40 * Licensed under the MIT License.
41 * http://opensource.org/licenses/mit-license
42 * Author: Owen Leong (@owenl131)
43 * Date: 15 Oct 2020
44 * References:
45 * https://www.cs.cmu.edu/~dst/Adobe/Gallery/anon21jul01-pdf-encryption.txt
46 * https://github.com/foliojs/pdfkit/blob/master/lib/security.js
47 * http://www.fpdf.org/en/script/script37.php
48 */var af={print:4,modify:8,copy:16,"annot-forms":32};function Xi(e,t,n,r){this.v=1,this.r=2;var s=192;e.forEach(function(l){if(af.perm!==void 0)throw new Error("Invalid permission: "+l);s+=af[l]}),this.padding="(¿N^NuŠAd\0NVÿú�\b..\0¶Ðh>€/\f©þdSiz";var i=(t+this.padding).substr(0,32),c=(n+this.padding).substr(0,32);this.O=this.processOwnerPassword(i,c),this.P=-(1+(255^s)),this.encryptionKey=kd(i+this.O+this.lsbFirstWord(this.P)+this.hexToBytes(r)).substr(0,5),this.U=Cd(this.encryptionKey,this.padding)}function Zi(e){if(/[^\u0000-\u00ff]/.test(e))throw new Error("Invalid PDF Name Object: "+e+", Only accept ASCII characters.");for(var t="",n=e.length,r=0;r<n;r++){var s=e.charCodeAt(r);t+=s<33||s===35||s===37||s===40||s===41||s===47||s===60||s===62||s===91||s===93||s===123||s===125||s>126?"#"+("0"+s.toString(16)).slice(-2):e[r]}return t}function sf(e){if(pn(e)!=="object")throw new Error("Invalid Context passed to initialize PubSub (jsPDF-module)");var t={};this.subscribe=function(n,r,s){if(s=s||!1,typeof n!="string"||typeof r!="function"||typeof s!="boolean")throw new Error("Invalid arguments passed to PubSub.subscribe (jsPDF-module)");t.hasOwnProperty(n)||(t[n]={});var i=Math.random().toString(35);return t[n][i]=[r,!!s],i},this.unsubscribe=function(n){for(var r in t)if(t[r][n])return delete t[r][n],Object.keys(t[r]).length===0&&delete t[r],!0;return!1},this.publish=function(n){if(t.hasOwnProperty(n)){var r=Array.prototype.slice.call(arguments,1),s=[];for(var i in t[n]){var c=t[n][i];try{c[0].apply(e,r)}catch(l){Mt.console&&wn.error("jsPDF PubSub Error",l.message,l)}c[1]&&s.push(i)}s.length&&s.forEach(this.unsubscribe)}},this.getTopics=function(){return t}}function Vl(e){if(!(this instanceof Vl))return new Vl(e);var t="opacity,stroke-opacity".split(",");for(var n in e)e.hasOwnProperty(n)&&t.indexOf(n)>=0&&(this[n]=e[n]);this.id="",this.objectNumber=-1}function mp(e,t){this.gState=e,this.matrix=t,this.id="",this.objectNumber=-1}function di(e,t,n,r,s){if(!(this instanceof di))return new di(e,t,n,r,s);this.type=e==="axial"?2:3,this.coords=t,this.colors=n,mp.call(this,r,s)}function no(e,t,n,r,s){if(!(this instanceof no))return new no(e,t,n,r,s);this.boundingBox=e,this.xStep=t,this.yStep=n,this.stream="",this.cloneIndex=0,mp.call(this,r,s)}function yt(e){var t,n=typeof arguments[0]=="string"?arguments[0]:"p",r=arguments[1],s=arguments[2],i=arguments[3],c=[],l=1,d=16,h="S",f=null;pn(e=e||{})==="object"&&(n=e.orientation,r=e.unit||r,s=e.format||s,i=e.compress||e.compressPdf||i,(f=e.encryption||null)!==null&&(f.userPassword=f.userPassword||"",f.ownerPassword=f.ownerPassword||"",f.userPermissions=f.userPermissions||[]),l=typeof e.userUnit=="number"?Math.abs(e.userUnit):1,e.precision!==void 0&&(t=e.precision),e.floatPrecision!==void 0&&(d=e.floatPrecision),h=e.defaultPathOperation||"S"),c=e.filters||(i===!0?["FlateEncode"]:c),r=r||"mm",n=(""+(n||"P")).toLowerCase();var x=e.putOnlyUsedFonts||!1,b={},m={internal:{},__private__:{}};m.__private__.PubSub=sf;var w="1.3",v=m.__private__.getPdfVersion=function(){return w};m.__private__.setPdfVersion=function(p){w=p};var P={a0:[2383.94,3370.39],a1:[1683.78,2383.94],a2:[1190.55,1683.78],a3:[841.89,1190.55],a4:[595.28,841.89],a5:[419.53,595.28],a6:[297.64,419.53],a7:[209.76,297.64],a8:[147.4,209.76],a9:[104.88,147.4],a10:[73.7,104.88],b0:[2834.65,4008.19],b1:[2004.09,2834.65],b2:[1417.32,2004.09],b3:[1000.63,1417.32],b4:[708.66,1000.63],b5:[498.9,708.66],b6:[354.33,498.9],b7:[249.45,354.33],b8:[175.75,249.45],b9:[124.72,175.75],b10:[87.87,124.72],c0:[2599.37,3676.54],c1:[1836.85,2599.37],c2:[1298.27,1836.85],c3:[918.43,1298.27],c4:[649.13,918.43],c5:[459.21,649.13],c6:[323.15,459.21],c7:[229.61,323.15],c8:[161.57,229.61],c9:[113.39,161.57],c10:[79.37,113.39],dl:[311.81,623.62],letter:[612,792],"government-letter":[576,756],legal:[612,1008],"junior-legal":[576,360],ledger:[1224,792],tabloid:[792,1224],"credit-card":[153,243]};m.__private__.getPageFormats=function(){return P};var _=m.__private__.getPageFormat=function(p){return P[p]};s=s||"a4";var q="compat",T="advanced",B=q;function Q(){this.saveGraphicsState(),R(new lt(_t,0,0,-_t,0,Vt()*_t).toString()+" cm"),this.setFontSize(this.getFontSize()/_t),h="n",B=T}function me(){this.restoreGraphicsState(),h="S",B=q}var ce=m.__private__.combineFontStyleAndFontWeight=function(p,j){if(p=="bold"&&j=="normal"||p=="bold"&&j==400||p=="normal"&&j=="italic"||p=="bold"&&j=="italic")throw new Error("Invalid Combination of fontweight and fontstyle");return j&&(p=j==400||j==="normal"?p==="italic"?"italic":"normal":j!=700&&j!=="bold"||p!=="normal"?(j==700?"bold":j)+""+p:"bold"),p};m.advancedAPI=function(p){var j=B===q;return j&&Q.call(this),typeof p!="function"||(p(this),j&&me.call(this)),this},m.compatAPI=function(p){var j=B===T;return j&&me.call(this),typeof p!="function"||(p(this),j&&Q.call(this)),this},m.isAdvancedAPI=function(){return B===T};var $,D=function(p){if(B!==T)throw new Error(p+" is only available in 'advanced' API mode. You need to call advancedAPI() first.")},Y=m.roundToPrecision=m.__private__.roundToPrecision=function(p,j){var U=t||j;if(isNaN(p)||isNaN(U))throw new Error("Invalid argument passed to 
48jsPDF.roundToPrecision");return p.toFixed(U).replace(/0+$/,"")};$=m.hpf=m.__private__.hpf=typeof d=="number"?function(p){if(isNaN(p))throw new Error("Invalid argument passed to jsPDF.hpf");return Y(p,d)}:d==="smart"?function(p){if(isNaN(p))throw new Error("Invalid argument passed to jsPDF.hpf");return Y(p,p>-1&&p<1?16:5)}:function(p){if(isNaN(p))throw new Error("Invalid argument passed to jsPDF.hpf");return Y(p,16)};var N=m.f2=m.__private__.f2=function(p){if(isNaN(p))throw new Error("Invalid argument passed to jsPDF.f2");return Y(p,2)},I=m.__private__.f3=function(p){if(isNaN(p))throw new Error("Invalid argument passed to jsPDF.f3");return Y(p,3)},k=m.scale=m.__private__.scale=function(p){if(isNaN(p))throw new Error("Invalid argument passed to jsPDF.scale");return B===q?p*_t:B===T?p:void 0},L=function(p){return k(function(j){return B===q?Vt()-j:B===T?j:void 0}(p))};m.__private__.setPrecision=m.setPrecision=function(p){typeof parseInt(p,10)=="number"&&(t=parseInt(p,10))};var H,te="00000000000000000000000000000000",se=m.__private__.getFileId=function(){return te},K=m.__private__.setFileId=function(p){return te=p!==void 0&&/^[a-fA-F0-9]{32}$/.test(p)?p.toUpperCase():te.split("").map(function(){return"ABCDEF0123456789".charAt(Math.floor(16*Math.random()))}).join(""),f!==null&&(xe=new Xi(f.userPermissions,f.userPassword,f.ownerPassword,te)),te};m.setFileId=function(p){return K(p),this},m.getFileId=function(){return se()};var ae=m.__private__.convertDateToPDFDate=function(p){var j=p.getTimezoneOffset(),U=j<0?"+":"-",ee=Math.floor(Math.abs(j/60)),oe=Math.abs(j%60),Se=[U,z(ee),"'",z(oe),"'"].join("");return["D:",p.getFullYear(),z(p.getMonth()+1),z(p.getDate()),z(p.getHours()),z(p.getMinutes()),z(p.getSeconds()),Se].join("")},be=m.__private__.convertPDFDateToDate=function(p){var j=parseInt(p.substr(2,4),10),U=parseInt(p.substr(6,2),10)-1,ee=parseInt(p.substr(8,2),10),oe=parseInt(p.substr(10,2),10),Se=parseInt(p.substr(12,2),10),Ie=parseInt(p.substr(14,2),10);return new Date(j,U,ee,oe,Se,Ie,0)},Ne=m.__private__.setCreationDate=function(p){var j;if(p===void 0&&(p=new Date),p instanceof Date)j=ae(p);else{if(!/^D:(20[0-2][0-9]|203[0-7]|19[7-9][0-9])(0[0-9]|1[0-2])([0-2][0-9]|3[0-1])(0[0-9]|1[0-9]|2[0-3])(0[0-9]|[1-5][0-9])(0[0-9]|[1-5][0-9])(\+0[0-9]|\+1[0-4]|-0[0-9]|-1[0-1])'(0[0-9]|[1-5][0-9])'?$/.test(p))throw new Error("Invalid argument passed to jsPDF.setCreationDate");j=p}return H=j},A=m.__private__.getCreationDate=function(p){var j=H;return p==="jsDate"&&(j=be(H)),j};m.setCreationDate=function(p){return Ne(p),this},m.getCreationDate=function(p){return A(p)};var E,z=m.__private__.padd2=function(p){return("0"+parseInt(p)).slice(-2)},X=m.__private__.padd2Hex=function(p){return("00"+(p=p.toString())).substr(p.length)},Z=0,le=[],fe=[],ue=0,_e=[],Ce=[],ve=!1,we=fe;m.__private__.setCustomOutputDestination=function(p){ve=!0,we=p};var De=function(p){ve||(we=p)};m.__private__.resetCustomOutputDestination=function(){ve=!1,we=fe};var R=m.__private__.out=function(p){return p=p.toString(),ue+=p.length+1,we.pu
vendor: 8,523 bytes, lines 48-49
48sh(p),we},ze=m.__private__.write=function(p){return R(arguments.length===1?p.toString():Array.prototype.join.call(arguments," "))},ye=m.__private__.getArrayBuffer=function(p){for(var j=p.length,U=new ArrayBuffer(j),ee=new Uint8Array(U);j--;)ee[j]=p.charCodeAt(j);return U},Ee=[["Helvetica","helvetica","normal","WinAnsiEncoding"],["Helvetica-Bold","helvetica","bold","WinAnsiEncoding"],["Helvetica-Oblique","helvetica","italic","WinAnsiEncoding"],["Helvetica-BoldOblique","helvetica","bolditalic","WinAnsiEncoding"],["Courier","courier","normal","WinAnsiEncoding"],["Courier-Bold","courier","bold","WinAnsiEncoding"],["Courier-Oblique","courier","italic","WinAnsiEncoding"],["Courier-BoldOblique","courier","bolditalic","WinAnsiEncoding"],["Times-Roman","times","normal","WinAnsiEncoding"],["Times-Bold","times","bold","WinAnsiEncoding"],["Times-Italic","times","italic","WinAnsiEncoding"],["Times-BoldItalic","times","bolditalic","WinAnsiEncoding"],["ZapfDingbats","zapfdingbats","normal",null],["Symbol","symbol","normal",null]];m.__private__.getStandardFonts=function(){return Ee};var de=e.fontSize||16;m.__private__.setFontSize=m.setFontSize=function(p){return de=B===T?p/_t:p,this};var Ue,qe=m.__private__.getFontSize=m.getFontSize=function(){return B===q?de:de*_t},$e=e.R2L||!1;m.__private__.setR2L=m.setR2L=function(p){return $e=p,this},m.__private__.getR2L=m.getR2L=function(){return $e};var Ge,bt=m.__private__.setZoomMode=function(p){if(/^(?:\d+\.\d*|\d*\.\d+|\d+)%$/.test(p))Ue=p;else if(isNaN(p)){if([void 0,null,"fullwidth","fullheight","fullpage","original"].indexOf(p)===-1)throw new Error('zoom must be Integer (e.g. 2), a percentage Value (e.g. 300%) or fullwidth, fullheight, fullpage, original. "'+p+'" is not recognized.');Ue=p}else Ue=parseInt(p,10)};m.__private__.getZoomMode=function(){return Ue};var et,Me=m.__private__.setPageMode=function(p){if([void 0,null,"UseNone","UseOutlines","UseThumbs","FullScreen"].indexOf(p)==-1)throw new Error('Page mode must be one of UseNone, UseOutlines, UseThumbs, or FullScreen. "'+p+'" is not recognized.');Ge=p};m.__private__.getPageMode=function(){return Ge};var vt=m.__private__.setLayoutMode=function(p){if([void 0,null,"continuous","single","twoleft","tworight","two"].indexOf(p)==-1)throw new Error('Layout mode must be one of continuous, single, twoleft, tworight. "'+p+'" is not recognized.');et=p};m.__private__.getLayoutMode=function(){return et},m.__private__.setDisplayMode=m.setDisplayMode=function(p,j,U){return bt(p),vt(j),Me(U),this};var St={title:"",subject:"",author:"",keywords:"",creator:""};m.__private__.getDocumentProperty=function(p){if(Object.keys(St).indexOf(p)===-1)throw new Error("Invalid argument passed to jsPDF.getDocumentProperty");return St[p]},m.__private__.getDocumentProperties=function(){return St},m.__private__.setDocumentProperties=m.setProperties=m.setDocumentProperties=function(p){for(var j in St)St.hasOwnProperty(j)&&p[j]&&(St[j]=p[j]);return this},m.__private__.setDocumentProperty=function(p,j){if(Object.keys(St).indexOf(p)===-1)throw new Error("Invalid arguments passed to jsPDF.setDocumentProperty");return St[p]=j};var Oe,_t,Xe,Ht,Lt,At={},kt={},an=[],it={},at={},Ve={},ft={},wt=null,Nt=0,Qe=[],Ze=new sf(m),Ae=e.hotfixes||[],Re={},Gt={},yn=[],lt=function p(j,U,ee,oe,Se,Ie){if(!(this instanceof p))return new p(j,U,ee,oe,Se,Ie);isNaN(j)&&(j=1),isNaN(U)&&(U=0),isNaN(ee)&&(ee=0),isNaN(oe)&&(oe=1),isNaN(Se)&&(Se=0),isNaN(Ie)&&(Ie=0),this._matrix=[j,U,ee,oe,Se,Ie]};Object.defineProperty(lt.prototype,"sx",{get:function(){return this._matrix[0]},set:function(p){this._matrix[0]=p}}),Object.defineProperty(lt.prototype,"shy",{get:function(){return this._matrix[1]},set:function(p){this._matrix[1]=p}}),Object.defineProperty(lt.prototype,"shx",{get:function(){return this._matrix[2]},set:function(p){this._matrix[2]=p}}),Object.defineProperty(lt.prototype,"sy",{get:function(){return this._matrix[3]},set:function(p){this._matrix[3]=p}}),Object.defineProperty(lt.prototype,"tx",{get:function(){return this._matrix[4]},set:function(p){this._matrix[4]=p}}),Object.defineProperty(lt.prototype,"ty",{get:function(){return this._matrix[5]},set:function(p){this._matrix[5]=p}}),Object.defineProperty(lt.prototype,"a",{get:function(){return this._matrix[0]},set:function(p){this._matrix[0]=p}}),Object.defineProperty(lt.prototype,"b",{get:function(){return this._matrix[1]},set:function(p){this._matrix[1]=p}}),Object.defineProperty(lt.prototype,"c",{get:function(){return this._matrix[2]},set:function(p){this._matrix[2]=p}}),Object.defineProperty(lt.prototype,"d",{get:function(){return this._matrix[3]},set:function(p){this._matrix[3]=p}}),Object.defineProperty(lt.prototype,"e",{get:function(){return this._matrix[4]},set:function(p){this._matrix[4]=p}}),Object.defineProperty(lt.prototype,"f",{get:function(){return this._matrix[5]},set:function(p){this._matrix[5]=p}}),Object.defineProperty(lt.prototype,"rotation",{get:function(){return Math.atan2(this.shx,this.sx)}}),Object.defineProperty(lt.prototype,"scaleX",{get:function(){return this.decompose().scale.sx}}),Object.defineProperty(lt.prototype,"scaleY",{get:function(){return this.decompose().scale.sy}}),Object.defineProperty(lt.prototype,"isIdentity",{get:function(){return this.sx===1&&this.shy===0&&this.shx===0&&this.sy===1&&this.tx===0&&this.ty===0}}),lt.prototype.join=function(p){return[this.sx,this.shy,this.shx,this.sy,this.tx,this.ty].map($).join(p)},lt.prototype.multiply=function(p){var j=p.sx*this.sx+p.shy*this.shx,U=p.sx*this.shy+p.shy*this.sy,ee=p.shx*this.sx+p.sy*this.shx,oe=p.shx*this.shy+p.sy*this.sy,Se=p.tx*this.sx+p.ty*this.shx+this.tx,Ie=p.tx*this.shy+p.ty*this.sy+this.ty;return new lt(j,U,ee,oe,Se,Ie)},lt.prototype.decompose=function(){var p=this.sx,j=this.shy,U=this.shx,ee=this.sy,oe=this.tx,Se=this.ty,Ie=Math.sqrt(p*p+j*j),ht=(p/=Ie)*U+(j/=Ie)*ee;U-=p*ht,ee-=j*ht;var ut=Math.sqrt(U*U+ee*ee);return ht/=ut,p*(ee/=ut)<j*(U/=ut)&&(p=-p,j=-j,ht=-ht,Ie=-Ie),{scale:new lt(Ie,0,0,ut,0,0),translate:new lt(1,0,0,1,oe,Se),rotate:new lt(p,j,-j,p,0,0),skew:new lt(1,0,ht,1,0,0)}},lt.prototype.toString=function(p){return this.join(" ")},lt.prototype.inversed=function(){var p=this.sx,j=this.shy,U=this.shx,ee=this.sy,oe=this.tx,Se=this.ty,Ie=1/(p*ee-j*U),ht=ee*Ie,ut=-j*Ie,It=-U*Ie,Bt=p*Ie;return new lt(ht,ut,It,Bt,-ht*oe-It*Se,-ut*oe-Bt*Se)},lt.prototype.applyToPoint=function(p){var j=p.x*this.sx+p.y*this.shx+this.tx,U=p.x*this.shy+p.y*this.sy+this.ty;return new Ca(j,U)},lt.prototype.applyToRectangle=function(p){var j=this.applyToPoint(p),U=this.applyToPoint(new Ca(p.x+p.w,p.y+p.h));return new rs(j.x,j.y,U.x-j.x,U.y-j.y)},lt.prototype.clone=function(){var p=this.sx,j=this.shy,U=this.shx,ee=this.sy,oe=this.tx,Se=this.ty;return new lt(p,j,U,ee,oe,Se)},m.Matrix=lt;var hr=m.matrixMult=function(p,j){return j.multiply(p)},sn=new lt(1,0,0,1,0,0);m.unitMatrix=m.identityMatrix=sn;var br=function(p,j){if(!at[p]){var U=(j instanceof di?"Sh":"P")+(Object.keys(it).length+1).toString(10);j.id=U,at[p]=U,it[U]=j,Ze.publish("addPattern",j)}};m.ShadingPattern=di,m.TilingPattern=no,m.addShadingPattern=function(p,j){return D("addShadingPattern()"),br(p,j),this},m.beginTilingPattern=function(p){D("beginTilingPattern()"),_s(p.boundingBox[0],p.boundingBox[1],p.boundingBox[2]-p.boundingBox[0],p.boundingBox[3]-p.boundingBox[1],p.matrix)},m.endTilingPattern=function(p,j){D("endTilingPattern()"),j.stream=Ce[E].join(`
49`),br(p,j),Ze.publish("endTilingPattern",j),yn.pop().restore()};var bn,Nn=m.__private__.newObject=function(){var p=Pn();return Fn(p,!0),p},Pn=m.__private__.newObjectDeferred=function(){return Z++,le[Z]=function(){return ue},Z},Fn=function(p,j){return j=typeof j=="boolean"&&j,le[p]=ue,j&&R(p+" 0 obj"),p},Jr=m.__private__.newAdditionalObject=function(){var p={objId:Pn(),content:""};return _e.push(p),p},vr=Pn(),Un=Pn(),_r=m.__private__.decodeColorString=function(p){var j=p.split(" ");if(j.length!==2||j[1]!=="g"&&j[1]!=="G")j.length!==5||j[4]!=="k"&&j[4]!=="K"||(j=[(1-j[0])*(1-j[3]),(1-j[1])*(1-j[3]),(1-j[2])*(1-j[3]),"r"]);else{var U=parseFloat(j[0]);j=[U,U,U,"r"]}for(var ee="#",oe=0;oe<3;oe++)ee+=("0"+Math.floor(255*parseFloat(j[oe])).toString(16)).slice(-2);return ee},lr=m.__private__.encodeColorString=function(p){var j;typeof p=="string"&&(p={ch1:p});var U=p.ch1,ee=p.ch2,oe=p.ch3,Se=p.ch4,Ie=p.pdfColorType==="draw"?["G","RG","K"]:["g","rg","k"];if(typeof U=="string"&&U.charAt(0)!=="#"){var ht=new hp(U);if(ht.ok)U=ht.toHex();else if(!/^\d*\.?\d*$/.test(U))throw new Error('Invalid color "'+U+'" passed to 
49jsPDF.encodeColorString.')}if(typeof U=="string"&&/^#[0-9A-Fa-f]{3}$/.test(U)&&(U="#"+U[1]+U[1]+U[2]+U[2]+U[3]+U[3]),typeof U=="string"&&/^#[0-9A-Fa-f]{6}$/.test(U)){var ut=parseInt(U.substr(1),16);U=ut>>16&255,ee=ut>>8&255,oe=255&ut}if(ee===void 0||Se===void 0&&U===ee&&ee===oe)j=typeof U=="string"?U+" "+Ie[0]:p.precision===2?N(U/255)+" "+Ie[0]:I(U/255)+" "+Ie[0];else if(Se===void 0||pn(Se)==="object"){if(Se&&!isNaN(Se.a)&&Se.a===0)return["1.","1.","1.",Ie[1]].join(" ");j=typeof U=="string"?[U,ee,oe,Ie[1]].join(" "):p.precision===2?[N(U/255),N(ee/255),N(oe/255),Ie[1]].join(" "):[I(U/255),I(ee/255),I(oe/255),Ie[1]].join(" ")}else j=typeof U=="string"?[U,ee,oe,Se,Ie[2]].join(" "):p.precision===2?[N(U),N(ee),N(oe),N(Se),Ie[2]].join(" "):[I(U),I(ee),I(oe),I(Se),Ie[2]].join(" ");return j},Xn=m.__private__.getFilters=function(){return c},Zn=m.__private__.putStream=function(p){var j=(p=p||{}).data||"",U=p.filters||Xn(),ee=p.alreadyAppliedFilters||[],oe=p.addLength1||!1,Se=j.length,Ie=p.objectId,ht=function(An){return An};if(f!==null&&Ie===void 0)throw new Error("ObjectId must be passed to putStream for file encryption");f!==null&&(ht=xe.encryptor(Ie,0));var ut={};U===!0&&(U=["FlateEncode"]);var It=p.additionalKeyValues||[],Bt=(ut=yt.API.processDataByFilters!==void 0?yt.API.processDataByFilters(j,U):{data:j,reverseChain:[]}).reverseChain+(Array.isArray(ee)?ee.join(" "):ee.toString());if(ut.data.length!==0&&(It.push({key:"Length",value:ut.data.length}),oe===!0&&It.push({key:"Length1",value:Se})),Bt.length!=0)if(Bt.split("/").length-1==1)It.push({key:"Filter",value:Bt});else{It.push({key:"Filter",value:"["+Bt+"]"});for(var Jt=0;Jt<It.length;Jt+=1)if(It[Jt].key==="DecodeParms"){for(var er=[],vn=0;vn<ut.reverseChain.split("/").length-1;vn+=1)er.push("null");er.push(It[Jt].value),It[Jt].value="["+er.join(" ")+"]"}}R("<<");for(var gn=0;gn<It.length;gn++)R("/"+It[gn].key+" "+It[gn].value);R(">>"),ut.data.length!==0&&(R("stream"),R(ht(ut.data)),R("endstream"))},fr=m.__private__.putPage=function(p){var j=p.number,U=p.data,ee=p.objId,oe=p.contentsObjId;Fn(ee,!0),R("<</Type /Page"),R("/Parent "+p.rootDictionaryObjId+" 0 R"),R("/Resources "+p.resourceDictionaryObjId+" 0 R"),R("/MediaBox ["+parseFloat($(p.mediaBox.bottomLeftX))+" "+parseFloat($(p.mediaBox.bottomLeftY))+" "+$(p.mediaBox.topRightX)+" "+$(p.mediaBox.topRightY)+"]"),p.cropBox!==null&&R("/CropBox ["+$(p.cropBox.bottomLeftX)+" "+$(p.cropBox.bottomLeftY)+" "+$(p.cropBox.topRightX)+" "+$(p.cropBox.topRightY)+"]"),p.bleedBox!==null&&R("/BleedBox ["+$(p.bleedBox.bottomLeftX)+" "+$(p.bleedBox.bottomLeftY)+" "+$(p.bleedBox.topRightX)+" "+$(p.bleedBox.topRightY)+"]"),p.trimBox!==null&&R("/TrimBox ["+$(p.trimBox.bottomLeftX)+" "+$(p.trimBox.bottomLeftY)+" "+$(p.trimBox.topRightX)+" "+$(p.trimBox.topRightY)+"]"),p.artBox!==null&&R("/ArtBox ["+$(p.artBox.bottomLeftX)+" "+$(p.artBox.bottomLeftY)+" "+$(p.artBox.topRightX)+" "+$(p.artBox.topRightY)+"]"),typeof p.userUnit=="number"&&p.userUnit!==1&&R("/UserUnit "+p.userUnit),Ze.publish("putPage",{objId:ee,pageContext:Qe[j],pageNumber:j,page:U}),R("/Contents "+oe+" 0 R"),R(">>"),R("endobj");var Se=U.join(`
50`);return B===T&&(Se+=`
51Q`),Fn(oe,!0),Zn({data:Se,filters:Xn(),objectId:oe}),R("endobj"),ee},nr=m.__private__.putPages=function(){var p,j,U=[];for(p=1;p<=Nt;p++)Qe[p].objId=Pn(),Qe[p].contentsObjId=Pn();for(p=1;p<=Nt;p++)U.push(fr({number:p,data:Ce[p],objId:Qe[p].objId,contentsObjId:Qe[p].contentsObjId,mediaBox:Qe[p].mediaBox,cropBox:Qe[p].cropBox,bleedBox:Qe[p].bleedBox,trimBox:Qe[p].trimBox,artBox:Qe[p].artBox,userUnit:Qe[p].userUnit,rootDictionaryObjId:vr,resourceDictionaryObjId:Un}));Fn(vr,!0),R("<</Type /Pages");var ee="/Kids [";for(j=0;j<Nt;j++)ee+=U[j]+" 0 R ";R(ee+"]"),R("/Count "+Nt),R(">>"),R("endobj"),Ze.publish("postPutPages")},qr=function(p){Ze.publish("putFont",{font:p,out:R,newObject:Nn,putStream:Zn}),p.isAlreadyPutted!==!0&&(p.objectNumber=Nn(),R("<<"),R("/Type /Font"),R("/BaseFont /"+Zi(p.postScriptName)),R("/Subtype /Type1"),typeof p.encoding=="string"&&R("/Encoding /"+p.encoding),R("/FirstChar 32"),R("/LastChar 255"),R(">>"),R("endobj"))},wr=function(p){p.objectNumber=Nn();var j=[];j.push({key:"Type",value:"/XObject"}),j.push({key:"Subtype",value:"/Form"}),j.push({key:"BBox",value:"["+[$(p.x),$(p.y),$(p.x+p.width),$(p.y+p.height)].join(" ")+"]"}),j.push({key:"Matrix",value:"["+p.matrix.toString()+"]"});var U=p.pages[1].join(`
52`);Zn({data:U,additionalKeyValues:j,objectId:p.objectNumber}),R("endobj")},Sa=function(p,j){j||(j=21);var U=Nn(),ee=function(Ie,ht){var ut,It=[],Bt=1/(ht-1);for(ut=0;ut<1;ut+=Bt)It.push(ut);if(It.push(1),Ie[0].offset!=0){var Jt={offset:0,color:Ie[0].color};Ie.unshift(Jt)}if(Ie[Ie.length-1].offset!=1){var er={offset:1,color:Ie[Ie.length-1].color};Ie.push(er)}for(var vn="",gn=0,An=0;An<It.length;An++){for(ut=It[An];ut>Ie[gn+1].offset;)gn++;var Dn=Ie[gn].offset,Rn=(ut-Dn)/(Ie[gn+1].offset-Dn),Nr=Ie[gn].color,as=Ie[gn+1].color;vn+=X(Math.round((1-Rn)*Nr[0]+Rn*as[0]).toString(16))+X(Math.round((1-Rn)*Nr[1]+Rn*as[1]).toString(16))+X(Math.round((1-Rn)*Nr[2]+Rn*as[2]).toString(16))}return vn.trim()}(p.colors,j),oe=[];
vendor: 5,472 bytes, line 52
52oe.push({key:"FunctionType",value:"0"}),oe.push({key:"Domain",value:"[0.0 1.0]"}),oe.push({key:"Size",value:"["+j+"]"}),oe.push({key:"BitsPerSample",value:"8"}),oe.push({key:"Range",value:"[0.0 1.0 0.0 1.0 0.0 1.0]"}),oe.push({key:"Decode",value:"[0.0 1.0 0.0 1.0 0.0 1.0]"}),Zn({data:ee,additionalKeyValues:oe,alreadyAppliedFilters:["/ASCIIHexDecode"],objectId:U}),R("endobj"),p.objectNumber=Nn(),R("<< /ShadingType "+p.type),R("/ColorSpace /DeviceRGB");var Se="/Coords ["+$(parseFloat(p.coords[0]))+" "+$(parseFloat(p.coords[1]))+" ";p.type===2?Se+=$(parseFloat(p.coords[2]))+" "+$(parseFloat(p.coords[3])):Se+=$(parseFloat(p.coords[2]))+" "+$(parseFloat(p.coords[3]))+" "+$(parseFloat(p.coords[4]))+" "+$(parseFloat(p.coords[5])),R(Se+="]"),p.matrix&&R("/Matrix ["+p.matrix.toString()+"]"),R("/Function "+U+" 0 R"),R("/Extend [true true]"),R(">>"),R("endobj")},qt=function(p,j){var U=Pn(),ee=Nn();j.push({resourcesOid:U,objectOid:ee}),p.objectNumber=ee;var oe=[];oe.push({key:"Type",value:"/Pattern"}),oe.push({key:"PatternType",value:"1"}),oe.push({key:"PaintType",value:"1"}),oe.push({key:"TilingType",value:"1"}),oe.push({key:"BBox",value:"["+p.boundingBox.map($).join(" ")+"]"}),oe.push({key:"XStep",value:$(p.xStep)}),oe.push({key:"YStep",value:$(p.yStep)}),oe.push({key:"Resources",value:U+" 0 R"}),p.matrix&&oe.push({key:"Matrix",value:"["+p.matrix.toString()+"]"}),Zn({data:p.stream,additionalKeyValues:oe,objectId:p.objectNumber}),R("endobj")},zr=function(p){for(var j in p.objectNumber=Nn(),R("<<"),p)switch(j){case"opacity":R("/ca "+N(p[j]));break;case"stroke-opacity":R("/CA "+N(p[j]))}R(">>"),R("endobj")},ma=function(p){Fn(p.resourcesOid,!0),R("<<"),R("/ProcSet [/PDF /Text /ImageB /ImageC /ImageI]"),function(){for(var j in R("/Font <<"),At)At.hasOwnProperty(j)&&(x===!1||x===!0&&b.hasOwnProperty(j))&&R("/"+j+" "+At[j].objectNumber+" 0 R");R(">>")}(),function(){if(Object.keys(it).length>0){for(var j in R("/Shading <<"),it)it.hasOwnProperty(j)&&it[j]instanceof di&&it[j].objectNumber>=0&&R("/"+j+" "+it[j].objectNumber+" 0 R");Ze.publish("putShadingPatternDict"),R(">>")}}(),function(j){if(Object.keys(it).length>0){for(var U in R("/Pattern <<"),it)it.hasOwnProperty(U)&&it[U]instanceof m.TilingPattern&&it[U].objectNumber>=0&&it[U].objectNumber<j&&R("/"+U+" "+it[U].objectNumber+" 0 R");Ze.publish("putTilingPatternDict"),R(">>")}}(p.objectOid),function(){if(Object.keys(Ve).length>0){var j;for(j in R("/ExtGState <<"),Ve)Ve.hasOwnProperty(j)&&Ve[j].objectNumber>=0&&R("/"+j+" "+Ve[j].objectNumber+" 0 R");Ze.publish("putGStateDict"),R(">>")}}(),function(){for(var j in R("/XObject <<"),Re)Re.hasOwnProperty(j)&&Re[j].objectNumber>=0&&R("/"+j+" "+Re[j].objectNumber+" 0 R");Ze.publish("putXobjectDict"),R(">>")}(),R(">>"),R("endobj")},Ct=function(p){kt[p.fontName]=kt[p.fontName]||{},kt[p.fontName][p.fontStyle]=p.id},ts=function(p,j,U,ee,oe){var Se={id:"F"+(Object.keys(At).length+1).toString(10),postScriptName:p,fontName:j,fontStyle:U,encoding:ee,isStandardFont:oe||!1,metadata:{}};return Ze.publish("addFont",{font:Se,instance:this}),At[Se.id]=Se,Ct(Se),Se.id},cn=m.__private__.pdfEscape=m.pdfEscape=function(p,j){return function(U,ee){var oe,Se,Ie,ht,ut,It,Bt,Jt,er;if(Ie=(ee=ee||{}).sourceEncoding||"Unicode",ut=ee.outputEncoding,(ee.autoencode||ut)&&At[Oe].metadata&&At[Oe].metadata[Ie]&&At[Oe].metadata[Ie].encoding&&(ht=At[Oe].metadata[Ie].encoding,!ut&&At[Oe].encoding&&(ut=At[Oe].encoding),!ut&&ht.codePages&&(ut=ht.codePages[0]),typeof ut=="string"&&(ut=ht[ut]),ut)){for(Bt=!1,It=[],oe=0,Se=U.length;oe<Se;oe++)(Jt=ut[U.charCodeAt(oe)])?It.push(String.fromCharCode(Jt)):It.push(U[oe]),It[oe].charCodeAt(0)>>8&&(Bt=!0);U=It.join("")}for(oe=U.length;Bt===void 0&&oe!==0;)U.charCodeAt(oe-1)>>8&&(Bt=!0),oe--;if(!Bt)return U;for(It=ee.noBOM?[]:[254,255],oe=0,Se=U.length;oe<Se;oe++){if((er=(Jt=U.charCodeAt(oe))>>8)>>8)throw new Error("Character at position "+oe+" of string '"+U+"' exceeds 16bits. Cannot be encoded into UCS-2 BE");It.push(er),It.push(Jt-(er<<8))}return String.fromCharCode.apply(void 0,It)}(p,j).replace(/\\/g,"\\\\").replace(/\(/g,"\\(").replace(/\)/g,"\\)")},pa=m.__private__.beginPage=function(p){Ce[++Nt]=[],Qe[Nt]={objId:0,contentsObjId:0,userUnit:Number(l),artBox:null,bleedBox:null,cropBox:null,trimBox:null,mediaBox:{bottomLeftX:0,bottomLeftY:0,topRightX:Number(p[0]),topRightY:Number(p[1])}},Xr(Nt),De(Ce[E])},ga=function(p,j){var U,ee,oe;switch(n=j||n,typeof p=="string"&&(U=_(p.toLowerCase()),Array.isArray(U)&&(ee=U[0],oe=U[1])),Array.isArray(p)&&(ee=p[0]*_t,oe=p[1]*_t),isNaN(ee)&&(ee=s[0],oe=s[1]),(ee>14400||oe>14400)&&(wn.warn("A page in a PDF can not be wider or taller than 14400 userUnit. jsPDF limits the width/height to 14400"),ee=Math.min(14400,ee),oe=Math.min(14400,oe)),s=[ee,oe],n.substr(0,1)){case"l":oe>ee&&(s=[oe,ee]);break;case"p":ee>oe&&(s=[oe,ee])}pa(s),On(Te),R(qa),Qs!==0&&R(Qs+" J"),ka!==0&&R(ka+" j"),Ze.publish("addPage",{pageNumber:Nt})},cr=function(p){p>0&&p<=Nt&&(Ce.splice(p,1),Qe.splice(p,1),Nt--,E>Nt&&(E=Nt),this.setPage(E))},Xr=function(p){p>0&&p<=Nt&&(E=p)},La=m.__private__.getNumberOfPages=m.getNumberOfPages=function(){return Ce.length-1},xa=function(p,j,U){var ee,oe=void 0;return U=U||{},p=p!==void 0?p:At[Oe].fontName,j=j!==void 0?j:At[Oe].fontStyle,ee=p.toLowerCase(),kt[ee]!==void 0&&kt[ee][j]!==void 0?oe=kt[ee][j]:kt[p]!==void 0&&kt[p][j]!==void 0?oe=kt[p][j]:U.disableWarning===!1&&wn.warn("Unable to look up font label for font '"+p+"', '"+j+"'. Refer to getFontList(
52) for available fonts."),oe||U.noFallback||(oe=kt.times[j])==null&&(oe=kt.times.normal),oe},$r=m.__private__.putInfo=function(){var p=Nn(),j=function(ee){return ee};for(var U in f!==null&&(j=xe.encryptor(p,0)),R("<<"),R("/Producer ("+cn(j("jsPDF "+yt.version))+")"),St)St.hasOwnProperty(U)&&St[U]&&R("/"+U.substr(0,1).toUpperCase()+U.substr(1)+" ("+cn(j(St[U]))+")");R("/CreationDate ("+cn(j(H))+")"),R(">>"),R("endobj")},Ba=m.__private__.putCatalog=function(p){var j=(p=p||{}).rootDictionaryObjId||vr;switch(Nn(),R("<<"),R("/Type /Catalog"),R("/Pages "+j+" 0 R"),Ue||(Ue="fullwidth"),Ue){case"fullwidth":R("/OpenAction [3 0 R /FitH null]");break;case"fullheight":R("/OpenAction [3 0 R /FitV null]");break;case"fullpage":R("/OpenAction [3 0 R /Fit]");break;case"original":R("/OpenAction [3 0 R /XYZ null null 1]");break;default:var U=""+Ue;U.substr(U.length-1)==="%"&&(Ue=parseInt(Ue)/100),typeof Ue=="number"&&R("/OpenAction [3 0 R /XYZ null null "+N(Ue)+"]")}switch(et||(et="continuous"),et){case"continuous":R("/PageLayout /OneColumn");break;case"single":R("/PageLayout /SinglePage");break;case"two":case"twoleft":R("/PageLayout /TwoColumnLeft");break;case"tworight":R("/PageLayout /TwoColumnRight")}Ge&&R("/PageMode /"+Ge),Ze.publish("putCatalog"),R(">>"),R("endobj")},bs=m.__private__.putTrailer=function(){R("trailer"),R("<<"),R("/Size "+(Z+1)),R("/Root "+Z+" 0 R"),R("/Info "+(Z-1)+" 0 R"),f!==null&&R("/Encrypt "+xe.oid+" 0 R"),R("/ID [ <"+te+"> <"+te+"> ]"),R(">>")},Qt=m.__private__.putHeader=function(){R("%PDF-"+w),R("%ºß¬à")},vs=m.__private__.putXRef=function(){var p="0000000000";R("xref"),R("0 "+(Z+1)),R("0000000000 65535 f ");for(var j=1;j<=Z;j++)typeof le[j]=="function"?R((p+le[j]()).slice(-10)+" 00000 n "):le[j]!==void 0?R((p+le[j]).slice(-10)+" 00000 n "):R("0000000000 00000 n ")},rr=m.__private__.buildDocument=function(){var p;Z=0,ue=0,fe=[],le=[],_e=[],vr=Pn(),Un=Pn(),De(fe),Ze.publish("buildDocument"),Qt(),nr(),function(){Ze.publish("putAdditionalObjects");for(var U=0;U<_e.length;U++){var ee=_e[U];Fn(ee.objId,!0),R(ee.content),R("endobj")}Ze.publish("postPutAdditionalObjects")}(),p=[],function(){for(var U in At)At.hasOwnProperty(U)&&(x===!1||x===!0&&b.hasOwnProperty(U))&&qr(At[U])}(),function(){var U;for(U in Ve)Ve.hasOwnProperty(U)&&zr(Ve[U])}(),function(){for(var U in Re)Re.hasOwnProperty(U)&&wr(Re[U])}(),function(U){var ee;for(ee in it)it.hasOwnProperty(ee)&&(it[ee]instanceof di?Sa(it[ee]):it[ee]instanceof no&&qt(it[ee],U))}(p),Ze.publish("putResources"),p.forEach(ma),ma({resourcesOid:Un,objectOid:Number.MAX_SAFE_INTEGER}),Ze.publish("postPutResources"),f!==null&&(xe.oid=Nn(),R("<<"),R("/Filter /Standard"),R("/V "+xe.v),R("/R "+xe.r),R("/U <"+xe.toHexString(xe.U)+">"),R("/O <"+xe.toHexString(xe.O)+">"),R("/P "+xe.P),R(">>"),R("endobj")),$r(),Ba();var j=ue;return vs(),bs(),R("startxref"),R(""+j),R("%%EOF"),De(Ce[E]),fe.join(`
53`)},Oa=m.__private__.getBlob=function(p){return new Blob([ye(p)],{type:"application/pdf"})},Hr=function(p){for(;p.firstChild;)p.removeChild(p.firstChild)},Bn=function(p){var j,U=p.document,ee=U.documentElement,oe=U.head,Se=U.body;return oe||(oe=U.createElement("head"),ee.appendChild(oe)),Se||(Se=U.createElement("body"),ee.appendChild(Se)),Hr(oe),Hr(Se),(j=U.createElement("style")).appendChild(U.createTextNode("html, body { padding: 0; margin: 0; } iframe { width: 100%; height: 100%; border: 0;}")),oe.appendChild(j),{document:U,body:Se}},ya=m.output=m.__private__.output=(bn=function(p,j){switch(typeof(j=j||{})=="string"?j={filename:j}:j.filename=j.filename||"generated.pdf",p){case void 0:return rr();case"save":m.save(j.filename);break;case"arraybuffer":return ye(rr());case"blob":return Oa(rr());case"bloburi":case"bloburl":if(Mt.URL!==void 0&&typeof Mt.URL.createObjectURL=="function")return Mt.URL&&Mt.URL.createObjectURL(Oa(rr()))||void 0;wn.warn("bloburl is not supported by your system, because URL.createObjectURL is not supported by your browser.");break;case"datauristring":case"dataurlstring":var U="",ee=rr();try{U=nf(ee)}catch{U=nf(unescape(encodeURIComponent(ee)))}return"data:application/pdf;filename="+encodeURIComponent(j.filename)+";base64,"+U;case"pdfobjectnewwindow":if(Object.prototype.toString.call(Mt)==="[object Window]"){var oe="https://cdnjs.cloudflare.com/ajax/libs/pdfobject/2.1.1/pdfobject.min.js",Se=!j.pdfObjectUrl;Se||(oe=j.pdfObjectUrl);var Ie=Mt.open();if(Ie!==null){var ht=Bn(Ie),ut=ht.document.createElement("script"),It=this;ut.src=oe,Se&&(ut.integrity="sha512-4ze/a9/4jqu+tX9dfOqJYSvyYd5M6qum/3HpCLr+/Jqf0whc37VUbkpNGHR7/8pSnCFw47T1fmIpwBV7UySh3g==",ut.crossOrigin="anonymous"),ut.onload=function(){Ie.PDFObject.embed(It.output("dataurlstring"),j)},ht.body.appendChild(ut)}return Ie}throw new Error("The option pdfobjectnewwindow just works in a browser-environment.");case"pdfjsnewwindow":if(Object.prototype.toString.call(Mt)==="[object Window]"){var Bt=j.pdfJsUrl||"examples/PDF.js/web/viewer.html",Jt=Mt.open();if(Jt!==null){var er=Bn(Jt),vn=er.document.createElement("iframe"),gn=Bt.indexOf("?")===-1?"?":"&";It=this,vn.id="pdfViewer",vn.width="500px",vn.height="400px",vn.src=Bt+gn+"file=&downloadName="+encodeURIComponent(j.filename),vn.onload=function(){Jt.document.title=j.filename,vn.contentWindow.PDFViewerApplication.open(It.output("bloburl"))},er.body.appendChild(vn)}return Jt}throw new Error("The option pdfjsnewwindow just works in a browser-environment.");case"dataurlnewwindow":if(Object.prototype.toString.call(Mt)!=="[object Window]")throw new Error("The option dataurlnewwindow just works in a browser-environment.");var An=Mt.open();if(An!==null){var Dn=Bn(An),Rn=Dn.document.createElement("iframe");Rn.src=this.output("datauristring",j),Dn.body.appendChild(Rn),An.document.title=j.filename}if(An||typeof safari>"u")return An;break;case"datauri":case"dataurl":return Mt.document.location.href=this.output("datauristring",j);default:return null}},bn.foo=function(){try{return bn.apply(this,arguments)}catch(U){var p=U.stack||"";~p.indexOf(" at ")&&(p=p.split(" at ")[1]);var j="Error in function "+p.split(`
54`)[0].split("<")[0]+": "+U.message;if(!Mt.console)throw new Error(j);Mt.console.error(j,U),Mt.alert&&alert(j)}},bn.foo.bar=bn,bn.foo),ie=function(p){return Array.isArray(Ae)===!0&&Ae.indexOf(p)>-1};switch(r){case"pt":_t=1;break;case"mm":_t=72/25.4;break;case"cm":_t=72/2.54;break;case"in":_t=72;break;case"px":_t=ie("px_scaling")==1?.75:96/72;break;case"pc":case"em":_t=12;break;case"ex":_t=6;break;default:if(typeof r!="number")throw new Error("Invalid unit: "+r);_t=r}var xe=null;Ne(),K();var He=m.__private__.getPageInfo=m.getPageInfo=function(p){if(isNaN(p)||p%1!=0)throw new Error("Invalid argument passed to 
54jsPDF.getPageInfo");return{objId:Qe[p].objId,pageNumber:p,pageContext:Qe[p]}},rt=m.__private__.getPageInfoByObjId=function(p){if(isNaN(p)||p%1!=0)throw new Error("Invalid argument passed to jsPDF.getPageInfoByObjId");for(var j in Qe)if(Qe[j].objId===p)break;return He(j)},mt=m.__private__.getCurrentPageInfo=m.getCurrentPageInfo=function(){return{objId:Qe[E].objId,pageNumber:E,pageContext:Qe[E]}};m.addPage=function(){return ga.apply(this,arguments),this},m.setPage=function(){return Xr.apply(this,arguments),De.call(this,Ce[E]),this},m.insertPage=function(p){return this.addPage(),this.movePage(E,p),this},m.movePage=function(p,j){var U,ee;if(p>j){U=Ce[p],ee=Qe[p];for(var oe=p;oe>j;oe--)Ce[oe]=Ce[oe-1],Qe[oe]=Qe[oe-1];Ce[j]=U,Qe[j]=ee,this.setPage(j)}else if(p<j){U=Ce[p],ee=Qe[p];for(var Se=p;Se<j;Se++)Ce[Se]=Ce[Se+1],Qe[Se]=Qe[Se+1];Ce[j]=U,Qe[j]=ee,this.setPage(j)}return this},m.deletePage=function(){return cr.apply(this,arguments),this},m.__private__.text=m.text=function(p,j,U,ee,oe){var Se,Ie,ht,ut,It,Bt,Jt,er,vn,gn=(ee=ee||{}).scope||this;if(typeof p=="number"&&typeof j=="number"&&(typeof U=="string"||Array.isArray(U))){var An=U;U=j,j=p,p=An}if(arguments[3]instanceof lt==0?(ht=arguments[4],ut=arguments[5],pn(Jt=arguments[3])==="object"&&Jt!==null||(typeof ht=="string"&&(ut=ht,ht=null),typeof Jt=="string"&&(ut=Jt,Jt=null),typeof Jt=="number"&&(ht=Jt,Jt=null),ee={flags:Jt,angle:ht,align:ut})):(D("The transform parameter of text() with a Matrix value"),vn=oe),isNaN(j)||isNaN(U)||p==null)throw new Error("Invalid arguments passed to jsPDF.text");if(p.length===0)return gn;var Dn,Rn="",Nr=typeof ee.lineHeightFactor=="number"?ee.lineHeightFactor:Pt,as=gn.internal.scaleFactor;function ho(jn){return jn=jn.split("	").join(Array(ee.TabLen||9).join(" ")),cn(jn,Jt)}function Js(jn){for(var Sn,Wn=jn.concat(),ar=[],is=Wn.length;is--;)typeof(Sn=Wn.shift())=="string"?ar.push(Sn):Array.isArray(jn)&&(Sn.length===1||Sn[1]===void 0&&Sn[2]===void 0)?ar.push(Sn[0]):ar.push([Sn[0],Sn[1],Sn[2]]);return ar}function Xs(jn,Sn){var Wn;if(typeof jn=="string")Wn=Sn(jn)[0];else if(Array.isArray(jn)){for(var ar,is,yo=jn.concat(),qi=[],Jo=yo.length;Jo--;)typeof(ar=yo.shift())=="string"?qi.push(Sn(ar)[0]):Array.isArray(ar)&&typeof ar[0]=="string"&&(is=Sn(ar[0],ar[1],ar[2]),qi.push([is[0],is[1],is[2]]));Wn=qi}return Wn}var Ns=!1,Zs=!0;if(typeof p=="string")Ns=!0;else if(Array.isArray(p)){var Mi=p.concat();Ie=[];for(var Ii,jr=Mi.length;jr--;)(typeof(Ii=Mi.shift())!="string"||Array.isArray(Ii)&&typeof Ii[0]!="string")&&(Zs=!1);Ns=Zs}if(Ns===!1)throw new Error('Type of text must be string or Array. "'+p+'" is not recognized.');typeof p=="string"&&(p=p.match(/[\r?\n]/)?p.split(/\r\n|\r|\n/g):[p]);var ei=de/gn.internal.scaleFactor,ti=ei*(Nr-1);switch(ee.baseline){case"bottom":U-=ti;break;case"top":U+=ei-ti;break;case"hanging":U+=ei-2*ti;break;case"middle":U+=ei/2-ti}if((Bt=ee.maxWidth||0)>0&&(typeof p=="string"?p=gn.splitTextToSize(p,Bt):Object.prototype.toString.call(p)==="[object Array]"&&(p=p.reduce(function(jn,Sn){return jn.concat(gn.splitTextToSize(Sn,Bt))},[]))),Se={text:p,x:j,y:U,options:ee,mutex:{pdfEscape:cn,activeFontKey:Oe,fonts:At,activeFontSize:de}},Ze.publish("preProcessText",Se),p=Se.text,ht=(ee=Se.options).angle,vn instanceof lt==0&&ht&&typeof ht=="number"){ht*=Math.PI/180,ee.rotationDirection===0&&(ht=-ht),B===T&&(ht=-ht);var fo=Math.cos(ht),$a=Math.sin(ht);vn=new lt(fo,$a,-$a,fo,0,0)}else ht&&ht instanceof lt&&(vn=ht);B!==T||vn||(vn=sn),(It=ee.charSpace||ns)!==void 0&&(Rn+=$(k(It))+` Tc
55`,this.setCharSpace(this.getCharSpace()||0)),(er=ee.horizontalScale)!==void 0&&(Rn+=$(100*er)+` Tz
56`),ee.lang;var Tr=-1,Ko=ee.renderingMode!==void 0?ee.renderingMode:ee.stroke,Fi=gn.internal.getCurrentPageInfo().pageContext;switch(Ko){case 0:case!1:case"fill":Tr=0;break;case 1:case!0:case"stroke":Tr=1;break;case 2:case"fillThenStroke":Tr=2;break;case 3:case"invisible":Tr=3;break;case 4:case"fillAndAddForClipping":Tr=4;break;case 5:case"strokeAndAddPathForClipping":Tr=5;break;case 6:case"fillThenStrokeAndAddToPathForClipping":Tr=6;break;case 7:case"addToPathForClipping":Tr=7}var Qo=Fi.usedRenderingMode!==void 0?Fi.usedRenderingMode:-1;Tr!==-1?Rn+=Tr+` Tr
57`:Qo!==-1&&(Rn+=`0 Tr
58`),Tr!==-1&&(Fi.usedRenderingMode=Tr),ut=ee.align||"left";var _a,ni=de*Nr,mo=gn.internal.pageSize.getWidth(),Ti=At[Oe];It=ee.charSpace||ns,Bt=ee.maxWidth||0,Jt=Object.assign({autoencode:!0,noBOM:!0},ee.flags);var ri=[],po=function(jn){return gn.getStringUnitWidth(jn,{font:Ti,charSpace:It,fontSize:de,doKerning:!1})*de/as};if(Object.prototype.toString.call(p)==="[object Array]"){var Dr;Ie=Js(p),ut!=="left"&&(_a=Ie.map(po));var Vr,Di=0;if(ut==="right"){j-=_a[0],p=[],jr=Ie.length;for(var js=0;js<jr;js++)js===0?(Vr=Rt(j),Dr=mr(U)):(Vr=k(Di-_a[js]),Dr=-ni),p.push([Ie[js],Vr,Dr]),Di=_a[js]}else if(ut==="center"){j-=_a[0]/2,p=[],jr=Ie.length;for(var Ss=0;Ss<jr;Ss++)Ss===0?(Vr=Rt(j),Dr=mr(U)):(Vr=k((Di-_a[Ss])/2),Dr=-ni),p.push([Ie[Ss],Vr,Dr]),Di=_a[Ss]}else if(ut==="left"){p=[],jr=Ie.length;for(var Ri=0;Ri<jr;Ri++)p.push(Ie[Ri])}else if(ut==="justify"&&Ti.encoding==="Identity-H"){p=[],jr=Ie.length,Bt=Bt!==0?Bt:mo;for(var ai=0,tr=0;tr<jr;tr++)if(Dr=tr===0?mr(U):-ni,Vr=tr===0?Rt(j):ai,tr<jr-1){var cc=k((Bt-_a[tr])/(Ie[tr].split(" ").length-1)),Ha=Ie[tr].split(" ");p.push([Ha[0]+" ",Vr,Dr]),ai=0;for(var Pa=1;Pa<Ha.length;Pa++){var si=(po(Ha[Pa-1]+" "+Ha[Pa])-po(Ha[Pa]))*as+cc;Pa==Ha.length-1?p.push([Ha[Pa],si,0]):p.push([Ha[Pa]+" ",si,0]),ai-=si}}else p.push([Ie[tr],Vr,Dr]);p.push(["",ai,0])}else{if(ut!=="justify")throw new Error('Unrecognized alignment option, use "left", "center", "right" or "justify".');for(p=[],jr=Ie.length,Bt=Bt!==0?Bt:mo,tr=0;tr<jr;tr++){Dr=tr===0?mr(U):-ni,Vr=tr===0?Rt(j):0;var go=Ie[tr].split(" ").length-1,xo=go>0?(Bt-_a[tr])/go:0;tr<jr-1?ri.push($(k(xo))):ri.push(0),p.push([Ie[tr],Vr,Dr])}}}(typeof ee.R2L=="boolean"?ee.R2L:$e)===!0&&(p=Xs(p,function(jn,Sn,Wn){return[jn.split("").reverse().join(""),Sn,Wn]})),Se={text:p,x:j,y:U,options:ee,mutex:{pdfEscape:cn,activeFontKey:Oe,fonts:At,activeFontSize:de}},Ze.publish("postProcessText",Se),p=Se.text,Dn=Se.mutex.isHex||!1;var Bi=At[Oe].encoding;Bi!=="WinAnsiEncoding"&&Bi!=="StandardEncoding"||(p=Xs(p,function(jn,Sn,Wn){return[ho(jn),Sn,Wn]})),Ie=Js(p),p=[];for(var ii,oi,Ls,ss=Array.isArray(Ie[0])?1:0,As="",Oi=function(jn,Sn,Wn){var ar="";return Wn instanceof lt?(Wn=typeof ee.angle=="number"?hr(Wn,new lt(1,0,0,1,jn,Sn)):hr(new lt(1,0,0,1,jn,Sn),Wn),B===T&&(Wn=hr(new lt(1,0,0,-1,0,0),Wn)),ar=Wn.join(" ")+` Tm
59`):ar=$(jn)+" "+$(Sn)+` Td
60`,ar},Sr=0;Sr<Ie.length;Sr++){switch(As="",ss){case 1:Ls=(Dn?"<":"(")+Ie[Sr][0]+(Dn?">":")"),ii=parseFloat(Ie[Sr][1]),oi=parseFloat(Ie[Sr][2]);break;case 0:Ls=(Dn?"<":"(")+Ie[Sr]+(Dn?">":")"),ii=Rt(j),oi=mr(U)}ri!==void 0&&ri[Sr]!==void 0&&(As=ri[Sr]+` Tw
61`),Sr===0?p.push(As+Oi(ii,oi,vn)+Ls):ss===0?p.push(As+Ls):ss===1&&p.push(As+Oi(ii,oi,vn)+Ls)}p=ss===0?p.join(` Tj
62T* `):p.join(` Tj
63`),p+=` Tj
64`;var Ua=`BT
65/`;return Ua+=Oe+" "+de+` Tf
66`,Ua+=$(de*Nr)+` TL
67`,Ua+=tn+`
68`,Ua+=Rn,Ua+=p,R(Ua+="ET"),b[Oe]=!0,gn};var Ft=m.__private__.clip=m.clip=function(p){return R(p==="evenodd"?"W*":"W"),this};m.clipEvenOdd=function(){return Ft("evenodd")},m.__private__.discardPath=m.discardPath=function(){return R("n"),this};var tt=m.__private__.isValidStyle=function(p){var j=!1;return[void 0,null,"S","D","F","DF","FD","f","f*","B","B*","n"].indexOf(p)!==-1&&(j=!0),j};m.__private__.setDefaultPathOperation=m.setDefaultPathOperation=function(p){return tt(p)&&(h=p),this};var Vn=m.__private__.getStyle=m.getStyle=function(p){var j=h;switch(p){case"D":case"S":j="S";break;case"F":j="f";break;case"FD":case"DF":j="B";break;case"f":case"f*":case"B":case"B*":j=p}return j},En=m.close=function(){return R("h"),this};m.stroke=function(){return R("S"),this},m.fill=function(p){return Zt("f",p),this},m.fillEvenOdd=function(p){return Zt("f*",p),this},m.fillStroke=function(p){return Zt("B",p),this},m.fillStrokeEvenOdd=function(p){return Zt("B*",p),this};var Zt=function(p,j){pn(j)==="object"?Tn(j,p):R(p)},en=function(p){p===null||B===T&&p===void 0||(p=Vn(p),R(p))};function Zr(p,j,U,ee,oe){var Se=new no(j||this.boundingBox,U||this.xStep,ee||this.yStep,this.gState,oe||this.matrix
vendor: 4,452 bytes, line 68
68);Se.stream=this.stream;var Ie=p+"$$"+this.cloneIndex+++"$$";return br(Ie,Se),Se}var Tn=function(p,j){var U=at[p.key],ee=it[U];if(ee instanceof di)R("q"),R(G(j)),ee.gState&&m.setGState(ee.gState),R(p.matrix.toString()+" cm"),R("/"+U+" sh"),R("Q");else if(ee instanceof no){var oe=new lt(1,0,0,-1,0,Vt());p.matrix&&(oe=oe.multiply(p.matrix||sn),U=Zr.call(ee,p.key,p.boundingBox,p.xStep,p.yStep,oe).id),R("q"),R("/Pattern cs"),R("/"+U+" scn"),ee.gState&&m.setGState(ee.gState),R(j),R("Q")}},G=function(p){switch(p){case"f":case"F":case"n":return"W n";case"f*":return"W* n";case"B":case"S":return"W S";case"B*":return"W* S"}},je=m.moveTo=function(p,j){return R($(k(p))+" "+$(L(j))+" m"),this},ct=m.lineTo=function(p,j){return R($(k(p))+" "+$(L(j))+" l"),this},Ye=m.curveTo=function(p,j,U,ee,oe,Se){return R([$(k(p)),$(L(j)),$(k(U)),$(L(ee)),$(k(oe)),$(L(Se)),"c"].join(" ")),this};m.__private__.line=m.line=function(p,j,U,ee,oe){if(isNaN(p)||isNaN(j)||isNaN(U)||isNaN(ee)||!tt(oe))throw new Error("Invalid arguments passed to jsPDF.line");return B===q?this.lines([[U-p,ee-j]],p,j,[1,1],oe||"S"):this.lines([[U-p,ee-j]],p,j,[1,1]).stroke()},m.__private__.lines=m.lines=function(p,j,U,ee,oe,Se){var Ie,ht,ut,It,Bt,Jt,er,vn,gn,An,Dn,Rn;if(typeof p=="number"&&(Rn=U,U=j,j=p,p=Rn),ee=ee||[1,1],Se=Se||!1,isNaN(j)||isNaN(U)||!Array.isArray(p)||!Array.isArray(ee)||!tt(oe)||typeof Se!="boolean")throw new Error("Invalid arguments passed to jsPDF.lines");for(je(j,U),Ie=ee[0],ht=ee[1],It=p.length,An=j,Dn=U,ut=0;ut<It;ut++)(Bt=p[ut]).length===2?(An=Bt[0]*Ie+An,Dn=Bt[1]*ht+Dn,ct(An,Dn)):(Jt=Bt[0]*Ie+An,er=Bt[1]*ht+Dn,vn=Bt[2]*Ie+An,gn=Bt[3]*ht+Dn,An=Bt[4]*Ie+An,Dn=Bt[5]*ht+Dn,Ye(Jt,er,vn,gn,An,Dn));return Se&&En(),en(oe),this},m.path=function(p){for(var j=0;j<p.length;j++){var U=p[j],ee=U.c;switch(U.op){case"m":je(ee[0],ee[1]);break;case"l":ct(ee[0],ee[1]);break;case"c":Ye.apply(this,ee);break;case"h":En()}}return this},m.__private__.rect=m.rect=function(p,j,U,ee,oe){if(isNaN(p)||isNaN(j)||isNaN(U)||isNaN(ee)||!tt(oe))throw new Error("Invalid arguments passed to jsPDF.rect");return B===q&&(ee=-ee),R([$(k(p)),$(L(j)),$(k(U)),$(k(ee)),"re"].join(" ")),en(oe),this},m.__private__.triangle=m.triangle=function(p,j,U,ee,oe,Se,Ie){if(isNaN(p)||isNaN(j)||isNaN(U)||isNaN(ee)||isNaN(oe)||isNaN(Se)||!tt(Ie))throw new Error("Invalid arguments passed to jsPDF.triangle");return this.lines([[U-p,ee-j],[oe-U,Se-ee],[p-oe,j-Se]],p,j,[1,1],Ie,!0),this},m.__private__.roundedRect=m.roundedRect=function(p,j,U,ee,oe,Se,Ie){if(isNaN(p)||isNaN(j)||isNaN(U)||isNaN(ee)||isNaN(oe)||isNaN(Se)||!tt(Ie))throw new Error("Invalid arguments passed to jsPDF.roundedRect");var ht=4/3*(Math.SQRT2-1);return oe=Math.min(oe,.5*U),Se=Math.min(Se,.5*ee),this.lines([[U-2*oe,0],[oe*ht,0,oe,Se-Se*ht,oe,Se],[0,ee-2*Se],[0,Se*ht,-oe*ht,Se,-oe,Se],[2*oe-U,0],[-oe*ht,0,-oe,-Se*ht,-oe,-Se],[0,2*Se-ee],[0,-Se*ht,oe*ht,-Se,oe,-Se]],p+oe,j,[1,1],Ie,!0),this},m.__private__.ellipse=m.ellipse=function(p,j,U,ee,oe){if(isNaN(p)||isNaN(j)||isNaN(U)||isNaN(ee)||!tt(oe))throw new Error("Invalid arguments passed to jsPDF.ellipse");var Se=4/3*(Math.SQRT2-1)*U,Ie=4/3*(Math.SQRT2-1)*ee;return je(p+U,j),Ye(p+U,j-Ie,p+Se,j-ee,p,j-ee),Ye(p-Se,j-ee,p-U,j-Ie,p-U,j),Ye(p-U,j+Ie,p-Se,j+ee,p,j+ee),Ye(p+Se,j+ee,p+U,j+Ie,p+U,j),en(oe),this},m.__private__.circle=m.circle=function(p,j,U,ee){if(isNaN(p)||isNaN(j)||isNaN(U)||!tt(ee))throw new Error("Invalid arguments passed to jsPDF.circle");return this.ellipse(p,j,U,U,ee)},m.setFont=function(p,j,U){return U&&(j=ce(j,U)),Oe=xa(p,j,{disableWarning:!1}),this};var jt=m.__private__.getFont=m.getFont=function(){return At[xa.apply(m,arguments)]};m.__private__.getFontList=m.getFontList=function(){var p,j,U={};for(p in kt)if(kt.hasOwnProperty(p))for(j in U[p]=[],kt[p])kt[p].hasOwnProperty(j)&&U[p].push(j);return U},m.addFont=function(p,j,U,ee,oe){var Se=["StandardEncoding","MacRomanEncoding","Identity-H","WinAnsiEncoding"];return arguments[3]&&Se.indexOf(arguments[3])!==-1?oe=arguments[3]:arguments[3]&&Se.indexOf(arguments[3])==-1&&(U=ce(U,ee)),ts.call(this,p,j,U,oe=oe||"Identity-H")};var Pt,Te=e.lineWidth||.200025,un=m.__private__.getLineWidth=m.getLineWidth=function(){return Te},On=m.__private__.setLineWidth=m.setLineWidth=function(p){return Te=p,R($(k(p))+" w"),this};m.__private__.setLineDash=yt.API.setLineDash=yt.API.setLineDashPattern=function(p,j){if(p=p||[],j=j||0,isNaN(j)||!Array.isArray(p))throw new Error("Invalid arguments passed to 
68jsPDF.setLineDash");return p=p.map(function(U){return $(k(U))}).join(" "),j=$(k(j)),R("["+p+"] "+j+" d"),this};var Fr=m.__private__.getLineHeight=m.getLineHeight=function(){return de*Pt};m.__private__.getLineHeight=m.getLineHeight=function(){return de*Pt};var ea=m.__private__.setLineHeightFactor=m.setLineHeightFactor=function(p){return typeof(p=p||1.15)=="number"&&(Pt=p),this},ba=m.__private__.getLineHeightFactor=m.getLineHeightFactor=function(){return Pt};ea(e.lineHeight);var Rt=m.__private__.getHorizontalCoordinate=function(p){return k(p)},mr=m.__private__.getVerticalCoordinate=function(p){return B===T?p:Qe[E].mediaBox.topRightY-Qe[E].mediaBox.bottomLeftY-k(p)},Aa=m.__private__.getHorizontalCoordinateString=m.getHorizontalCoordinateString=function(p){return $(Rt(p))},Ks=m.__private__.getVerticalCoordinateString=m.getVerticalCoordinateString=function(p){return $(mr(p))},qa=e.strokeColor||"0 G";m.__private__.getStrokeColor=m.getDrawColor=function(){return _r(qa)},m.__private__.setStrokeColor=m.setDrawColor=function(p,j,U,ee){return qa=lr({ch1:p,ch2:j,ch3:U,ch4:ee,pdfColorType:"draw",precision:2}),R(qa),this};var ta=e.fillColor||"0 g";m.__private__.getFillColor=m.getFillColor=function(){return _r(ta)},m.__private__.setFillColor=m.setFillColor=function(p,j,U,ee){return ta=lr({ch1:p,ch2:j,ch3:U,ch4:ee,pdfColorType:"fill",precision:2}),R(ta),this};var tn=e.textColor||"0 g",pr=m.__private__.getTextColor=m.getTextColor=function(){return _r(tn)};m.__private__.setTextColor=m.setTextColor=function(p,j,U,ee){return tn=lr({ch1:p,ch2:j,ch3:U,ch4:ee,pdfColorType:"text",precision:3}),this};var ns=e.charSpace,Ai=m.__private__.getCharSpace=m.getCharSpace=function(){return parseFloat(ns||0)};m.__private__.setCharSpace=m.setCharSpace=function(p){if(isNaN(p))throw new Error("Invalid argument passed to jsPDF.setCharSpace");return ns=p,this};var Qs=0;m.CapJoinStyles={0:0,butt:0,but:0,miter:0,1:1,round:1,rounded:1,circle:1,2:2,projecting:2,project:2,square:2,bevel:2},m.__private__.setLineCap=m.setLineCap=function(p){var j=m.CapJoinStyles[p];if(j===void 0)throw new Error("Line cap style of '"+p+"' is not recognized. See or extend .CapJoinStyles property for valid styles");return Qs=j,R(j+" J"),this};var ka=0;m.__private__.setLineJoin=m.setLineJoin=function(p){var j=m.CapJoinStyles[p];if(j===void 0)throw new Error("Line join style of '"+p+"' is not recognized. See or extend .CapJoinStyles property for valid styles");return ka=j,R(j+" j"),this},m.__private__.setLineMiterLimit=m.__private__.setMiterLimit=m.setLineMiterLimit=m.setMiterLimit=function(p){if(p=p||0,isNaN(p))throw new Error("Invalid argument passed to jsPDF.setLineMiterLimit");return R($(k(p))+" M"),this},m.GState=Vl,m.setGState=function(p){(p=typeof p=="string"?Ve[ft[p]]:va(null,p)).equals(wt)||(R("/"+p.id+" gs"),wt=p)};var va=function(p,j){if(!p||!ft[p]){var U=!1;for(var ee in Ve)if(Ve.hasOwnProperty(ee)&&Ve[ee].equals(j)){U=!0;break}if(U)j=Ve[ee];else{var oe="GS"+(Object.keys(Ve).length+1).toString(10);Ve[oe]=j,j.id=oe}return p&&(ft[p]=j.id),Ze.publish("addGState",j),j}};m.addGState=function(p,j){return va(p,j),this},m.saveGraphicsState=function(){return R("q"),an.push({key:Oe,size:de,color:tn}),this},m.restoreGraphicsState=function(){R("Q");var p=an.pop();return Oe=p.key,de=p.size,tn=p.color,wt=null,this},m.setCurrentTransformationMatrix=function(p){return R(p.toString()+" cm"),this},m.comment=function(p){return R("#"+p),this};var Ca=function(p,j){var U=p||0;Object.defineProperty(this,"x",{enumerable:!0,get:function(){return U},set:function(Se){isNaN(Se)||(U=parseFloat(Se))}});var ee=j||0;Object.defineProperty(this,"y",{enumerable:!0,get:function(){return ee},set:function(Se){isNaN(Se)||(ee=parseFloat(Se))}});var oe="pt";return Object.defineProperty(this,"type",{enumerable:!0,get:function(){return oe},set:function(Se){oe=Se.toString()}}),this},rs=function(p,j,U,ee){Ca.call(this,p,j),this.type="rect";var oe=U||0;Object.defineProperty(this,"w",{enumerable:!0,get:function(){return oe},set:function(Ie){isNaN(Ie)||(oe=parseFloat(Ie))}});var Se=ee||0;return Object.defineProperty(this,"h",{enumerable:!0,get:function(){return Se},set:function(Ie){isNaN(Ie)||(Se=parseFloat(Ie))}}),this},za=function(){this.page=Nt,this.currentPage=E,this.pages=Ce.slice(0),this.pagesContext=Qe.slice(0),this.x=Xe,this.y=Ht,this.matrix=Lt,this.width=ki(E),this.height=Ur(E),this.outputDestination=we,this.id="",this.objectNumber=-1};za.prototype.restore=function(){Nt=this.page,E=this.currentPage,Qe=this.pagesContext,Ce=this.pages,Xe=this.x,Ht=this.y,Lt=this.matrix,na(E,this.width),Ci(E,this.height),we=this.outputDestination};
vendor: 4,982 bytes, line 68
68var _s=function(p,j,U,ee,oe){yn.push(new za),Nt=E=0,Ce=[],Xe=p,Ht=j,Lt=oe,pa([U,ee])};for(var ws in m.beginFormObject=function(p,j,U,ee,oe){return _s(p,j,U,ee,oe),this},m.endFormObject=function(p){return function(j){if(Gt[j])yn.pop().restore();else{var U=new za,ee="Xo"+(Object.keys(Re).length+1).toString(10);U.id=ee,Gt[j]=ee,Re[ee]=U,Ze.publish("addFormObject",U),yn.pop().restore()}}(p),this},m.doFormObject=function(p,j){var U=Re[Gt[p]];return R("q"),R(j.toString()+" cm"),R("/"+U.id+" Do"),R("Q"),this},m.getFormObject=function(p){var j=Re[Gt[p]];return{x:j.x,y:j.y,width:j.width,height:j.height,matrix:j.matrix}},m.save=function(p,j){return p=p||"generated.pdf",(j=j||{}).returnPromise=j.returnPromise||!1,j.returnPromise===!1?(ci(Oa(rr()),p),typeof ci.unload=="function"&&Mt.setTimeout&&setTimeout(ci.unload,911),this):new Promise(function(U,ee){try{var oe=ci(Oa(rr()),p);typeof ci.unload=="function"&&Mt.setTimeout&&setTimeout(ci.unload,911),U(oe)}catch(Se){ee(Se.message)}})},yt.API)yt.API.hasOwnProperty(ws)&&(ws==="events"&&yt.API.events.length?function(p,j){var U,ee,oe;for(oe=j.length-1;oe!==-1;oe--)U=j[oe][0],ee=j[oe][1],p.subscribe.apply(p,[U].concat(typeof ee=="function"?[ee]:ee))}(Ze,yt.API.events):m[ws]=yt.API[ws]);function ki(p){return Qe[p].mediaBox.topRightX-Qe[p].mediaBox.bottomLeftX}function na(p,j){Qe[p].mediaBox.topRightX=j+Qe[p].mediaBox.bottomLeftX}function Ur(p){return Qe[p].mediaBox.topRightY-Qe[p].mediaBox.bottomLeftY}function Ci(p,j){Qe[p].mediaBox.topRightY=j+Qe[p].mediaBox.bottomLeftY}var Pi=m.getPageWidth=function(p){return ki(p=p||E)/_t},Ei=m.setPageWidth=function(p,j){na(p,j*_t)},Vt=m.getPageHeight=function(p){return Ur(p=p||E)/_t},dr=m.setPageHeight=function(p,j){Ci(p,j*_t)};return m.internal={pdfEscape:cn,getStyle:Vn,getFont:jt,getFontSize:qe,getCharSpace:Ai,getTextColor:pr,getLineHeight:Fr,getLineHeightFactor:ba,getLineWidth:un,write:ze,getHorizontalCoordinate:Rt,getVerticalCoordinate:mr,getCoordinateString:Aa,getVerticalCoordinateString:Ks,collections:{},newObject:Nn,newAdditionalObject:Jr,newObjectDeferred:Pn,newObjectDeferredBegin:Fn,getFilters:Xn,putStream:Zn,events:Ze,scaleFactor:_t,pageSize:{getWidth:function(){return Pi(E)},setWidth:function(p){Ei(E,p)},getHeight:function(){return Vt(E)},setHeight:function(p){dr(E,p)}},encryptionOptions:f,encryption:xe,getEncryptor:function(p){return f!==null?xe.encryptor(p,0):function(j){return j}},output:ya,getNumberOfPages:La,get pages(){return Ce},out:R,f2:N,f3:I,getPageInfo:He,getPageInfoByObjId:rt,getCurrentPageInfo:mt,getPDFVersion:v,Point:Ca,Rectangle:rs,Matrix:lt,hasHotfix:ie},Object.defineProperty(m.internal.pageSize,"width",{get:function(){return Pi(E)},set:function(p){Ei(E,p)},enumerable:!0,configurable:!0}),Object.defineProperty(m.internal.pageSize,"height",{get:function(){return Vt(E)},set:function(p){dr(E,p)},enumerable:!0,configurable:!0}),(function(p){for(var j=0,U=Ee.length;j<U;j++){var ee=ts.call(this,p[j][0],p[j][1],p[j][2],Ee[j][3],!0);x===!1&&(b[ee]=!0);var oe=p[j][0].split("-");Ct({id:ee,fontName:oe[0],fontStyle:oe[1]||""})}Ze.publish("addFonts",{fonts:At,dictionary:kt})}).call(m,Ee),Oe="F1",ga(s,n),Ze.publish("initialized"),m}Xi.prototype.lsbFirstWord=function(e){return String.fromCharCode(255&e,e>>8&255,e>>16&255,e>>24&255)},Xi.prototype.toHexString=function(e){return e.split("").map(function(t){return("0"+(255&t.charCodeAt(0)).toString(16)).slice(-2)}).join("")},Xi.prototype.hexToBytes=function(e){for(var t=[],n=0;n<e.length;n+=2)t.push(String.fromCharCode(parseInt(e.substr(n,2),16)));return t.join("")},Xi.prototype.processOwnerPassword=function(e,t){return Cd(kd(t).substr(0,5),e)},Xi.prototype.encryptor=function(e,t){var n=kd(this.encryptionKey+String.fromCharCode(255&e,e>>8&255,e>>16&255,255&t,t>>8&255)).substr(0,10);return function(r){return Cd(n,r)}},Vl.prototype.equals=function(e){var t,n="id,objectNumber,equals";if(!e||pn(e)!==pn(this))return!1;var r=0;for(t in this)if(!(n.indexOf(t)>=0)){if(this.hasOwnProperty(t)&&!e.hasOwnProperty(t)||this[t]!==e[t])return!1;r++}for(t in e)e.hasOwnProperty(t)&&n.indexOf(t)<0&&r--;return r===0},yt.API={events:[]},yt.version="4.2.1";var $n=yt.API,eu=1,Li=function(e){return e.replace(/\\/g,"\\\\").replace(/\(/g,"\\(").replace(/\)/g,"\\)")},Gi=function(e){return e.replace(/\\\\/g,"\\").replace(/\\\(/g,"(").replace(/\\\)/g,")")},bi=function(e){return e.toString().replace(/#/g,"#23").replace(/[\s\n\r()<>[\]{}\/%]/g,function(t){var n=t.charCodeAt(0).toString(16).toUpperCase();return"#"+(n.length===1?"0"+n:n)})},Tt=function(e){return e.toFixed(2)},Ds=function(e){return e.toFixed(5)};$n.__acroform__={};var Qr=function(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e},of=function(e){return e*eu},Wa=function(e){var t=new gp,n=dt.internal.getHeight(e)||0,r=dt.internal.getWidth(e)||0;return t.BBox=[0,0,Number(Tt(r)),Number(Tt(n))],t},Z5=$n.__acroform__.setBit=function(e,t){if(e=e||0,t=t||0,isNaN(e)||isNaN(t))throw new Error("Invalid arguments passed to 
68jsPDF.API.__acroform__.setBit");return e|1<<t},ex=$n.__acroform__.clearBit=function(e,t){if(e=e||0,t=t||0,isNaN(e)||isNaN(t))throw new Error("Invalid arguments passed to jsPDF.API.__acroform__.clearBit");return e&~(1<<t)},tx=$n.__acroform__.getBit=function(e,t){if(isNaN(e)||isNaN(t))throw new Error("Invalid arguments passed to jsPDF.API.__acroform__.getBit");return e&1<<t?1:0},Kn=$n.__acroform__.getBitForPdf=function(e,t){if(isNaN(e)||isNaN(t))throw new Error("Invalid arguments passed to jsPDF.API.__acroform__.getBitForPdf");return tx(e,t-1)},Qn=$n.__acroform__.setBitForPdf=function(e,t){if(isNaN(e)||isNaN(t))throw new Error("Invalid arguments passed to jsPDF.API.__acroform__.setBitForPdf");return Z5(e,t-1)},Jn=$n.__acroform__.clearBitForPdf=function(e,t){if(isNaN(e)||isNaN(t))throw new Error("Invalid arguments passed to jsPDF.API.__acroform__.clearBitForPdf");return ex(e,t-1)},nx=$n.__acroform__.calculateCoordinates=function(e,t){var n=t.internal.getHorizontalCoordinate,r=t.internal.getVerticalCoordinate,s=e[0],i=e[1],c=e[2],l=e[3],d={};return d.lowerLeft_X=n(s)||0,d.lowerLeft_Y=r(i+l)||0,d.upperRight_X=n(s+c)||0,d.upperRight_Y=r(i)||0,[Number(Tt(d.lowerLeft_X)),Number(Tt(d.lowerLeft_Y)),Number(Tt(d.upperRight_X)),Number(Tt(d.upperRight_Y))]},rx=function(e){if(e.appearanceStreamContent)return e.appearanceStreamContent;if(e.V||e.DV){var t=[],n=e._V||e.DV,r=Pd(e,n),s=e.scope.internal.getFont(e.fontName,e.fontStyle).id;t.push("/Tx BMC"),t.push("q"),t.push("BT"),t.push(e.scope.__private__.encodeColorString(e.color)),t.push("/"+s+" "+Tt(r.fontSize)+" Tf"),t.push("1 0 0 1 0 0 Tm"),t.push(r.text),t.push("ET"),t.push("Q"),t.push("EMC");var i=Wa(e);return i.scope=e.scope,i.stream=t.join(`
69`),i}},Pd=function(e,t){var n=e.fontSize===0?e.maxFontSize:e.fontSize,r={text:"",fontSize:""},s=(t=(t=t.substr(0,1)=="("?t.substr(1):t).substr(t.length-1)==")"?t.substr(0,t.length-1):t).split(" ");s=e.multiline?s.map(function(N){return N.split(`
70`)}):s.map(function(N){return[N]});var i=n,c=dt.internal.getHeight(e)||0;c=c<0?-c:c;var l=dt.internal.getWidth(e)||0;l=l<0?-l:l;var d=function(N,I,k){if(N+1<s.length){var L=I+" "+s[N+1][0];return wl(L,e,k).width<=l-4}return!1};i++;e:for(;i>0;){t="",i--;var h,f,x=wl("3",e,i).height,b=e.multiline?c-i:(c-x)/2,m=b+=2,w=0,v=0,P=0;if(i<=0){t=`(...) Tj
71`,t+="% Width of Text: "+wl(t,e,i=12).width+", FieldWidth:"+l+`
72`;break}for(var _="",q=0,T=0;T<s.length;T++)if(s.hasOwnProperty(T)){var B=!1;if(s[T].length!==1&&P!==s[T].length-1){if((x+2)*(q+2)+2>c)continue e;_+=s[T][P],B=!0,v=T,T--}else{_=(_+=s[T][P]+" ").substr(_.length-1)==" "?_.substr(0,_.length-1):_;var Q=parseInt(T),me=d(Q,_,i),ce=T>=s.length-1;if(me&&!ce){_+=" ",P=0;continue}if(me||ce){if(ce)v=Q;else if(e.multiline&&(x+2)*(q+2)+2>c)continue e}else{if(!e.multiline||(x+2)*(q+2)+2>c)continue e;v=Q}}for(var $="",D=w;D<=v;D++){var Y=s[D];if(e.multiline){if(D===v){$+=Y[P]+" ",P=(P+1)%Y.length;continue}if(D===w){$+=Y[Y.length-1]+" ";continue}}$+=Y[0]+" "}switch($=$.substr($.length-1)==" "?$.substr(0,$.length-1):$,f=wl($,e,i).width,e.textAlign){case"right":h=l-f-2;break;case"center":h=(l-f)/2;break;default:h=2}t+=Tt(h)+" "+Tt(m)+` Td
73`,t+="("+Li($)+`) Tj
74`,t+=-Tt(h)+` 0 Td
75`,m=-(i+2),f=0,w=B?v:v+1,q++,_=""}break}return r.text=t,r.fontSize=i,r},wl=function(e,t,n){var r=t.scope.internal.getFont(t.fontName,t.fontStyle),s=t.scope.getStringUnitWidth(e,{font:r,fontSize:parseFloat(n),charSpace:0})*parseFloat(n);return{height:t.scope.getStringUnitWidth("3",{font:r,fontSize:parseFloat(n),charSpace:0})*parseFloat(n)*1.5,width:s}},ax={fields:[],xForms:[],acroFormDictionaryRoot:null,printedOut:!1,internal:null,isInitialized:!1},sx=function(e,t){var n={type:"reference",object:e};t.internal.getPageInfo(e.page).pageContext.annotations.find(function(r){return r.type===n.type&&r.object===n.object})===void 0&&t.internal.getPageInfo(e.page).pageContext.annotations.push(n)},ix=function(e,t){if(t.scope=e,e.internal!==void 0&&(e.internal.acroformPlugin===void 0||e.internal.acroformPlugin.isInitialized===!1)){if(Da.FieldNum=0,e.internal.acroformPlugin=JSON.parse(JSON.stringify(ax)),e.internal.acroformPlugin.acroFormDictionaryRoot)throw new Error("Exception while creating AcroformDictionary");eu=e.internal.scaleFactor,e.internal.acroformPlugin.acroFormDictionaryRoot=new xp,e.internal.acroformPlugin.acroFormDictionaryRoot.scope=e,e.internal.acroformPlugin.acroFormDictionaryRoot._eventID=e.internal.events.subscribe("postPutResources",function(){(function(n){n.internal.events.unsubscribe(n.internal.acroformPlugin.acroFormDictionaryRoot._eventID),delete n.internal.acroformPlugin.acroFormDictionaryRoot._eventID,n.internal.acroformPlugin.printedOut=!0})(e)}),e.internal.events.subscribe("buildDocument",function(){(function(n){n.internal.acroformPlugin.acroFormDictionaryRoot.objId=void 0;var r=n.internal.acroformPlugin.acroFormDictionaryRoot.Fields;for(var s in r)if(r.hasOwnProperty(s)){var i=r[s];
vendor: 91,470 bytes, lines 75-124
75i.objId=void 0,i.hasAnnotation&&sx(i,n)}})(e)}),e.internal.events.subscribe("putCatalog",function(){(function(n){if(n.internal.acroformPlugin.acroFormDictionaryRoot===void 0)throw new Error("putCatalogCallback: Root missing.");n.internal.write("/AcroForm "+n.internal.acroformPlugin.acroFormDictionaryRoot.objId+" 0 R")})(e)}),e.internal.events.subscribe("postPutPages",function(n){(function(r,s){var i=!r;for(var c in r||(s.internal.newObjectDeferredBegin(s.internal.acroformPlugin.acroFormDictionaryRoot.objId,!0),s.internal.acroformPlugin.acroFormDictionaryRoot.putStream()),r=r||s.internal.acroformPlugin.acroFormDictionaryRoot.Kids)if(r.hasOwnProperty(c)){var l=r[c],d=[],h=l.Rect;if(l.Rect&&(l.Rect=nx(l.Rect,s)),s.internal.newObjectDeferredBegin(l.objId,!0),l.DA=dt.createDefaultAppearanceStream(l),pn(l)==="object"&&typeof l.getKeyValueListForStream=="function"&&(d=l.getKeyValueListForStream()),l.Rect=h,l.hasAppearanceStream&&!l.appearanceStreamContent){var f=rx(l);d.push({key:"AP",value:"<</N "+f+">>"}),s.internal.acroformPlugin.xForms.push(f)}if(l.appearanceStreamContent){var x="";for(var b in l.appearanceStreamContent)if(l.appearanceStreamContent.hasOwnProperty(b)){var m=l.appearanceStreamContent[b];if(x+="/"+b+" ",x+="<<",Object.keys(m).length>=1||Array.isArray(m)){for(var c in m)if(m.hasOwnProperty(c)){var w=m[c];typeof w=="function"&&(w=w.call(s,l)),x+="/"+c+" "+w+" ",s.internal.acroformPlugin.xForms.indexOf(w)>=0||s.internal.acroformPlugin.xForms.push(w)}}else typeof(w=m)=="function"&&(w=w.call(s,l)),x+="/"+c+" "+w,s.internal.acroformPlugin.xForms.indexOf(w)>=0||s.internal.acroformPlugin.xForms.push(w);x+=">>"}d.push({key:"AP",value:`<<
76`+x+">>"})}s.internal.putStream({additionalKeyValues:d,objectId:l.objId}),s.internal.out("endobj")}i&&function(v,P){for(var _ in v)if(v.hasOwnProperty(_)){var q=_,T=v[_];P.internal.newObjectDeferredBegin(T.objId,!0),pn(T)==="object"&&typeof T.putStream=="function"&&T.putStream(),delete v[q]}}(s.internal.acroformPlugin.xForms,s)})(n,e)}),e.internal.acroformPlugin.isInitialized=!0}},pp=$n.__acroform__.arrayToPdfArray=function(e,t,n){var r=function(c){return c};if(Array.isArray(e)){for(var s="[",i=0;i<e.length;i++)switch(i!==0&&(s+=" "),pn(e[i])){case"boolean":case"number":case"object":s+=e[i].toString();break;case"string":e[i].substr(0,1)==="/"?s+="/"+bi(e[i].substr(1)):(t!==void 0&&n&&(r=n.internal.getEncryptor(t)),s+="("+Li(r(e[i].toString()))+")")}return s+"]"}throw new Error("Invalid argument passed to jsPDF.__acroform__.arrayToPdfArray")},Yc=function(e,t,n){var r=function(s){return s};return t!==void 0&&n&&(r=n.internal.getEncryptor(t)),(e=e||"").toString(),"("+Li(r(e))+")"},Ya=function(){this._objId=void 0,this._scope=void 0,Object.defineProperty(this,"objId",{get:function(){if(this._objId===void 0){if(this.scope===void 0)return;this._objId=this.scope.internal.newObjectDeferred()}return this._objId},set:function(e){this._objId=e}}),Object.defineProperty(this,"scope",{value:this._scope,writable:!0})};Ya.prototype.toString=function(){return this.objId+" 0 R"},Ya.prototype.putStream=function(){var e=this.getKeyValueListForStream();this.scope.internal.putStream({data:this.stream,additionalKeyValues:e,objectId:this.objId}),this.scope.internal.out("endobj")},Ya.prototype.getKeyValueListForStream=function(){var e=[],t=Object.getOwnPropertyNames(this).filter(function(i){return i!="content"&&i!="appearanceStreamContent"&&i!="scope"&&i!="objId"&&i.substring(0,1)!="_"});for(var n in t)if(Object.getOwnPropertyDescriptor(this,t[n]).configurable===!1){var r=t[n],s=this[r];s&&(Array.isArray(s)?e.push({key:r,value:pp(s,this.objId,this.scope)}):s instanceof Ya?(s.scope=this.scope,e.push({key:r,value:s.objId+" 0 R"})):typeof s!="function"&&e.push({key:r,value:s}))}return e};var gp=function(){Ya.call(this),Object.defineProperty(this,"Type",{value:"/XObject",configurable:!1,writable:!0}),Object.defineProperty(this,"Subtype",{value:"/Form",configurable:!1,writable:!0}),Object.defineProperty(this,"FormType",{value:1,configurable:!1,writable:!0});var e,t=[];Object.defineProperty(this,"BBox",{configurable:!1,get:function(){return t},set:function(n){t=n}}),Object.defineProperty(this,"Resources",{value:"2 0 R",configurable:!1,writable:!0}),Object.defineProperty(this,"stream",{enumerable:!1,configurable:!0,set:function(n){e=n.trim()},get:function(){return e||null}})};Qr(gp,Ya);var xp=function(){Ya.call(this);var e,t=[];Object.defineProperty(this,"Kids",{enumerable:!1,configurable:!0,get:function(){return t.length>0?t:void 0}}),Object.defineProperty(this,"Fields",{enumerable:!1,configurable:!1,get:function(){return t}}),Object.defineProperty(this,"DA",{enumerable:!1,configurable:!1,get:function(){if(e){var n=function(r){return r};return this.scope&&(n=this.scope.internal.getEncryptor(this.objId)),"("+Li(n(e))+")"}},set:function(n){e=n}})};Qr(xp,Ya);var Da=function e(){Ya.call(this);var t=4;Object.defineProperty(this,"F",{enumerable:!1,configurable:!1,get:function(){return t},set:function(_){if(isNaN(_))throw new Error('Invalid value "'+_+'" for attribute F supplied.');t=_}}),Object.defineProperty(this,"showWhenPrinted",{enumerable:!0,configurable:!0,get:function(){return!!Kn(t,3)},set:function(_){_?this.F=Qn(t,3):this.F=Jn(t,3)}});var n=0;Object.defineProperty(this,"Ff",{enumerable:!1,configurable:!1,get:function(){return n},set:function(_){if(isNaN(_))throw new Error('Invalid value "'+_+'" for attribute Ff supplied.');n=_}});var r=[];Object.defineProperty(this,"Rect",{enumerable:!1,configurable:!1,get:function(){if(r.length!==0)return r},set:function(_){r=_!==void 0?_:[]}}),Object.defineProperty(this,"x",{enumerable:!0,configurable:!0,get:function(){return!r||isNaN(r[0])?0:r[0]},set:function(_){r[0]=_}}),Object.defineProperty(this,"y",{enumerable:!0,configurable:!0,get:function(){return!r||isNaN(r[1])?0:r[1]},set:function(_){r[1]=_}}),Object.defineProperty(this,"width",{enumerable:!0,configurable:!0,get:function(){return!r||isNaN(r[2])?0:r[2]},set:function(_){r[2]=_}}),Object.defineProperty(this,"height",{enumerable:!0,configurable:!0,get:function(){return!r||isNaN(r[3])?0:r[3]},set:function(_){r[3]=_}});var s="";Object.defineProperty(this,"FT",{enumerable:!0,configurable:!1,get:function(){return s},set:function(_){switch(_){case"/Btn":case"/Tx":case"/Ch":case"/Sig":s=_;break;default:throw new Error('Invalid value "'+_+'" for attribute FT supplied.')}}});var i=null;Object.defineProperty(this,"T",{enumerable:!0,configurable:!1,get:function(){if(!i||i.length<1){if(this instanceof Wl)return;i="FieldObject"+e.FieldNum++}var _=function(q){return q};return this.scope&&(_=this.scope.internal.getEncryptor(this.objId)),"("+Li(_(i))+")"},set:function(_){i=_.toString()}}),Object.defineProperty(this,"fieldName",{configurable:!0,enumerable:!0,get:function(){return i},set:function(_){i=_}});var c="helvetica";Object.defineProperty(this,"fontName",{enumerable:!0,configurable:!0,get:function(){return c},set:function(_){c=_}});var l="normal";Object.defineProperty(this,"fontStyle",{enumerable:!0,configurable:!0,get:function(){return l},set:function(_){l=_}});var d=0;Object.defineProperty(this,"fontSize",{enumerable:!0,configurable:!0,get:function(){return d},set:function(_){d=_}});var h=void 0;Object.defineProperty(this,"maxFontSize",{enumerable:!0,configurable:!0,get:function(){return h===void 0?50/eu:h},set:function(_){h=_}});var f="black";Object.defineProperty(this,"color",{enumerable:!0,configurable:!0,get:function(){return f},set:function(_){f=_}});var x="/F1 0 Tf 0 g";Object.defineProperty(this,"DA",{enumerable:!0,configurable:!1,get:function(){if(!(!x||this instanceof Wl||this instanceof pi))return Yc(x,this.objId,this.scope)},set:function(_){_=_.toString(),x=_}});var b=null;Object.defineProperty(this,"DV",{enumerable:!1,configurable:!1,get:function(){if(b)return this instanceof ur==0?Yc(b,this.objId,this.scope):b},set:function(_){_=_.toString(),b=this instanceof ur==0?_.substr(0,1)==="("?Gi(_.substr(1,_.length-2)):Gi(_):_}}),Object.defineProperty(this,"defaultValue",{enumerable:!0,configurable:!0,get:function(){return this instanceof ur==1?Gi(b.substr(1,b.length-1)):b},set:function(_){_=_.toString(),b=this instanceof ur==1?"/"+bi(_):_}});var m=null;Object.defineProperty(this,"_V",{enumerable:!1,configurable:!1,get:function(){if(m)return m},set:function(_){this.V=_}}),Object.defineProperty(this,"V",{enumerable:!1,configurable:!1,get:function(){if(m)return this instanceof ur==0?Yc(m,this.objId,this.scope):m},set:function(_){_=_.toString(),m=this instanceof ur==0?_.substr(0,1)==="("?Gi(_.substr(1,_.length-2)):Gi(_):_}}),Object.defineProperty(this,"value",{enumerable:!0,configurable:!0,get:function(){return this instanceof ur==1?Gi(m.substr(1,m.length-1)):m},set:function(_){_=_.toString(),m=this instanceof ur==1?"/"+bi(_):_}}),Object.defineProperty(this,"hasAnnotation",{enumerable:!0,configurable:!0,get:function(){return this.Rect}}),Object.defineProperty(this,"Type",{enumerable:!0,configurable:!1,get:function(){return this.hasAnnotation?"/Annot":null}}),Object.defineProperty(this,"Subtype",{enumerable:!0,configurable:!1,get:function(){return this.hasAnnotation?"/Widget":null}});var w,v=!1;Object.defineProperty(this,"hasAppearanceStream",{enumerable:!0,configurable:!0,get:function(){return v},set:function(_){_=!!_,v=_}}),Object.defineProperty(this,"page",{enumerable:!0,configurable:!0,get:function(){if(w)return w},set:function(_){w=_}}),Object.defineProperty(this,"readOnly",{enumerable:!0,configurable:!0,get:function(){return!!Kn(this.Ff,1)},set:function(_){_?this.Ff=Qn(this.Ff,1):this.Ff=Jn(this.Ff,1)}}),Object.defineProperty(this,"required",{enumerable:!0,configurable:!0,get:function(){return!!Kn(this.Ff,2)},set:function(_){_?this.Ff=Qn(this.Ff,2):this.Ff=Jn(this.Ff,2)}}),Object.defineProperty(this,"noExport",{enumerable:!0,configurable:!0,get:function(){return!!Kn(this.Ff,3)},set:function(_){_?this.Ff=Qn(this.Ff,3):this.Ff=Jn(this.Ff,3)}});var P=null;Object.defineProperty(this,"Q",{enumerable:!0,configurable:!1,get:function(){if(P!==null)return P},set:function(_){if([0,1,2].indexOf(_)===-1)throw new Error('Invalid value "'+_+'" for attribute Q supplied.');P=_}}),Object.defineProperty(this,"textAlign",{get:function(){var _;switch(P){case 0:default:_="left";break;case 1:_="center";break;case 2:_="right"}return _},configurable:!0,enumerable:!0,set:function(_){switch(_){case"right":case 2:P=2;break;case"center":case 1:P=1;break;default:P=0}}})};Qr(Da,Ya);var ro=function(){Da.call(this),this.FT="/Ch",this.V="()",this.fontName="zapfdingbats";var e=0;Object.defineProperty(this,"TI",{enumerable:!0,configurable:!1,get:function(){return e},set:function(n){e=n}}),Object.defineProperty(this,"topIndex",{enumerable:!0,configurable:!0,get:function(){return e},set:function(n){e=n}});var t=[];Object.defineProperty(this,"Opt",{enumerable:!0,configurable:!1,get:function(){return pp(t,this.objId,this.scope)},set:function(n){var r,s;s=[],typeof(r=n)=="string"&&(s=function(i,c,l){l||(l=1);for(var d,h=[];d=c.exec(i);)h.push(d[l]);return h}(r,/\((.*?)\)/g)),t=s}}),this.getOptions=function(){return t},this.setOptions=function(n){t=n,this.sort&&t.sort()},this.addOption=function(n){n=(n=n||"").toString(),t.push(n),this.sort&&t.sort()},this.removeOption=function(n,r){for(r=r||!1,n=(n=n||"").toString();t.indexOf(n)!==-1&&(t.splice(t.indexOf(n),1),r!==!1););},Object.defineProperty(this,"combo",{enumerable:!0,configurable:!0,get:function(){return!!Kn(this.Ff,18)},set:function(n){n?this.Ff=Qn(this.Ff,18):this.Ff=Jn(this.Ff,18)}}),Object.defineProperty(this,"edit",{enumerable:!0,configurable:!0,get:function(){return!!Kn(this.Ff,19)},set:function(n){this.combo===!0&&(n?this.Ff=Qn(this.Ff,19):this.Ff=Jn(this.Ff,19))}}),Object.defineProperty(this,"sort",{enumerable:!0,configurable:!0,get:function(){return!!Kn(this.Ff,20)},set:function(n){n?(this.Ff=Qn(this.Ff,20),t.sort()):this.Ff=Jn(this.Ff,20)}}),Object.defineProperty(this,"multiSelect",{enumerable:!0,configurable:!0,get:function(){return!!Kn(this.Ff,22)},set:function(n){n?this.Ff=Qn(this.Ff,22):this.Ff=Jn(this.Ff,22)}}),Object.defineProperty(this,"doNotSpellCheck",{enumerable:!0,configurable:!0,get:function(){return!!Kn(this.Ff,23)},set:function(n){n?this.Ff=Qn(this.Ff,23):this.Ff=Jn(this.Ff,23)}}),Object.defineProperty(this,"commitOnSelChange",{enumerable:!0,configurable:!0,get:function(){return!!Kn(this.Ff,27)},set:function(n){n?this.Ff=Qn(this.Ff,27):this.Ff=Jn(this.Ff,27)}}),this.hasAppearanceStream=!1};Qr(ro,Da);var ao=function(){ro.call(this),this.fontName="helvetica",this.combo=!1};Qr(ao,ro);var so=function(){ao.call(this),this.combo=!0};Qr(so,ao);var Tl=function(){so.call(this),this.edit=!0};Qr(Tl,so);var ur=function(){Da.call(this),this.FT="/Btn",Object.defineProperty(this,"noToggleToOff",{enumerable:!0,configurable:!0,get:function(){return!!Kn(this.Ff,15)},set:function(n){n?this.Ff=Qn(this.Ff,15):this.Ff=Jn(this.Ff,15)}}),Object.defineProperty(this,"radio",{enumerable:!0,configurable:!0,get:function(){return!!Kn(this.Ff,16)},set:function(n){n?this.Ff=Qn(this.Ff,16):this.Ff=Jn(this.Ff,16)}}),Object.defineProperty(this,"pushButton",{enumerable:!0,configurable:!0,get:function(){return!!Kn(this.Ff,17)},set:function(n){n?this.Ff=Qn(this.Ff,17):this.Ff=Jn(this.Ff,17)}}),Object.defineProperty(this,"radioIsUnison",{enumerable:!0,configurable:!0,get:function(){return!!Kn(this.Ff,26)},set:function(n){n?this.Ff=Qn(this.Ff,26):this.Ff=Jn(this.Ff,26)}});var e,t={};Object.defineProperty(this,"MK",{enumerable:!1,configurable:!1,get:function(){var n=function(i){return i};if(this.scope&&(n=this.scope.internal.getEncryptor(this.objId)),Object.keys(t).length!==0){var r,s=[];for(r in s.push("<<"),t)s.push("/"+r+" ("+Li(n(t[r]))+")");return s.push(">>"),s.join(`
77`)}},set:function(n){pn(n)==="object"&&(t=n)}}),Object.defineProperty(this,"caption",{enumerable:!0,configurable:!0,get:function(){return t.CA||""},set:function(n){typeof n=="string"&&(t.CA=n)}}),Object.defineProperty(this,"AS",{enumerable:!1,configurable:!1,get:function(){return e},set:function(n){var r=n==null?"":n.toString();r.substr(0,1)==="/"&&(r=r.substr(1)),e="/"+bi(r)}}),Object.defineProperty(this,"appearanceState",{enumerable:!0,configurable:!0,get:function(){return e.substr(1,e.length-1)},set:function(n){e="/"+bi(n)}})};Qr(ur,Da);var Dl=function(){ur.call(this),this.pushButton=!0};Qr(Dl,ur);var io=function(){ur.call(this),this.radio=!0,this.pushButton=!1;var e=[];Object.defineProperty(this,"Kids",{enumerable:!0,configurable:!1,get:function(){return e},set:function(t){e=t!==void 0?t:[]}})};Qr(io,ur);var Wl=function(){var e,t;Da.call(this),Object.defineProperty(this,"Parent",{enumerable:!1,configurable:!1,get:function(){return e},set:function(s){e=s}}),Object.defineProperty(this,"optionName",{enumerable:!1,configurable:!0,get:function(){return t},set:function(s){t=s}});var n,r={};Object.defineProperty(this,"MK",{enumerable:!1,configurable:!1,get:function(){var s=function(l){return l};this.scope&&(s=this.scope.internal.getEncryptor(this.objId));var i,c=[];for(i in c.push("<<"),r)c.push("/"+i+" ("+Li(s(r[i]))+")");return c.push(">>"),c.join(`
78`)},set:function(s){pn(s)==="object"&&(r=s)}}),Object.defineProperty(this,"caption",{enumerable:!0,configurable:!0,get:function(){return r.CA||""},set:function(s){typeof s=="string"&&(r.CA=s)}}),Object.defineProperty(this,"AS",{enumerable:!1,configurable:!1,get:function(){return n},set:function(s){var i=s==null?"":s.toString();i.substr(0,1)==="/"&&(i=i.substr(1)),n="/"+bi(i)}}),Object.defineProperty(this,"appearanceState",{enumerable:!0,configurable:!0,get:function(){return n.substr(1,n.length-1)},set:function(s){var i=s==null?"":s.toString();i.substr(0,1)==="/"&&(i=i.substr(1)),n="/"+bi(i)}}),this.caption="l",this.appearanceState="Off",this._AppearanceType=dt.RadioButton.Circle,this.appearanceStreamContent=this._AppearanceType.createAppearanceStream(this.optionName)};Qr(Wl,Da),io.prototype.setAppearance=function(e){if(!("createAppearanceStream"in e)||!("getCA"in e))throw new Error("Couldn't assign Appearance to RadioButton. Appearance was Invalid!");for(var t in this.Kids)if(this.Kids.hasOwnProperty(t)){var n=this.Kids[t];n.appearanceStreamContent=e.createAppearanceStream(n.optionName),n.caption=e.getCA()}},io.prototype.createOption=function(e){var t=new Wl;return t.Parent=this,t.optionName=e,this.Kids.push(t),ox.call(this.scope,t),t};var Rl=function(){ur.call(this),this.fontName="zapfdingbats",this.caption="3",this.appearanceState="On",this.value="On",this.textAlign="center",this.appearanceStreamContent=dt.CheckBox.createAppearanceStream()};Qr(Rl,ur);var pi=function(){Da.call(this),this.FT="/Tx",Object.defineProperty(this,"multiline",{enumerable:!0,configurable:!0,get:function(){return!!Kn(this.Ff,13)},set:function(t){t?this.Ff=Qn(this.Ff,13):this.Ff=Jn(this.Ff,13)}}),Object.defineProperty(this,"fileSelect",{enumerable:!0,configurable:!0,get:function(){return!!Kn(this.Ff,21)},set:function(t){t?this.Ff=Qn(this.Ff,21):this.Ff=Jn(this.Ff,21)}}),Object.defineProperty(this,"doNotSpellCheck",{enumerable:!0,configurable:!0,get:function(){return!!Kn(this.Ff,23)},set:function(t){t?this.Ff=Qn(this.Ff,23):this.Ff=Jn(this.Ff,23)}}),Object.defineProperty(this,"doNotScroll",{enumerable:!0,configurable:!0,get:function(){return!!Kn(this.Ff,24)},set:function(t){t?this.Ff=Qn(this.Ff,24):this.Ff=Jn(this.Ff,24)}}),Object.defineProperty(this,"comb",{enumerable:!0,configurable:!0,get:function(){return!!Kn(this.Ff,25)},set:function(t){t?this.Ff=Qn(this.Ff,25):this.Ff=Jn(this.Ff,25)}}),Object.defineProperty(this,"richText",{enumerable:!0,configurable:!0,get:function(){return!!Kn(this.Ff,26)},set:function(t){t?this.Ff=Qn(this.Ff,26):this.Ff=Jn(this.Ff,26)}});var e=null;Object.defineProperty(this,"MaxLen",{enumerable:!0,configurable:!1,get:function(){return e},set:function(t){e=t}}),Object.defineProperty(this,"maxLength",{enumerable:!0,configurable:!0,get:function(){return e},set:function(t){Number.isInteger(t)&&(e=t)}}),Object.defineProperty(this,"hasAppearanceStream",{enumerable:!0,configurable:!0,get:function(){return this.V||this.DV}})};Qr(pi,Da);var Bl=function(){pi.call(this),Object.defineProperty(this,"password",{enumerable:!0,configurable:!0,get:function(){return!!Kn(this.Ff,14)},set:function(e){e?this.Ff=Qn(this.Ff,14):this.Ff=Jn(this.Ff,14)}}),this.password=!0};Qr(Bl,pi);var dt={CheckBox:{createAppearanceStream:function(){return{N:{On:dt.CheckBox.YesNormal},D:{On:dt.CheckBox.YesPushDown,Off:dt.CheckBox.OffPushDown}}},YesPushDown:function(e){var t=Wa(e);t.scope=e.scope;var n=[],r=e.scope.internal.getFont(e.fontName,e.fontStyle).id,s=e.scope.__private__.encodeColorString(e.color),i=Pd(e,e.caption);return n.push("0.749023 g"),n.push("0 0 "+Tt(dt.internal.getWidth(e))+" "+Tt(dt.internal.getHeight(e))+" re"),n.push("f"),n.push("BMC"),n.push("q"),n.push("0 0 1 rg"),n.push("/"+r+" "+Tt(i.fontSize)+" Tf "+s),n.push("BT"),n.push(i.text),n.push("ET"),n.push("Q"),n.push("EMC"),t.stream=n.join(`
79`),t},YesNormal:function(e){var t=Wa(e);t.scope=e.scope;var n=e.scope.internal.getFont(e.fontName,e.fontStyle).id,r=e.scope.__private__.encodeColorString(e.color),s=[],i=dt.internal.getHeight(e),c=dt.internal.getWidth(e),l=Pd(e,e.caption);return s.push("1 g"),s.push("0 0 "+Tt(c)+" "+Tt(i)+" re"),s.push("f"),s.push("q"),s.push("0 0 1 rg"),s.push("0 0 "+Tt(c-1)+" "+Tt(i-1)+" re"),s.push("W"),s.push("n"),s.push("0 g"),s.push("BT"),s.push("/"+n+" "+Tt(l.fontSize)+" Tf "+r),s.push(l.text),s.push("ET"),s.push("Q"),t.stream=s.join(`
80`),t},OffPushDown:function(e){var t=Wa(e);t.scope=e.scope;var n=[];return n.push("0.749023 g"),n.push("0 0 "+Tt(dt.internal.getWidth(e))+" "+Tt(dt.internal.getHeight(e))+" re"),n.push("f"),t.stream=n.join(`
81`),t}},RadioButton:{Circle:{createAppearanceStream:function(e){var t={D:{Off:dt.RadioButton.Circle.OffPushDown},N:{}};return t.N[e]=dt.RadioButton.Circle.YesNormal,t.D[e]=dt.RadioButton.Circle.YesPushDown,t},getCA:function(){return"l"},YesNormal:function(e){var t=Wa(e);t.scope=e.scope;var n=[],r=dt.internal.getWidth(e)<=dt.internal.getHeight(e)?dt.internal.getWidth(e)/4:dt.internal.getHeight(e)/4;r=Number((.9*r).toFixed(5));var s=dt.internal.Bezier_C,i=Number((r*s).toFixed(5));return n.push("q"),n.push("1 0 0 1 "+Ds(dt.internal.getWidth(e)/2)+" "+Ds(dt.internal.getHeight(e)/2)+" cm"),n.push(r+" 0 m"),n.push(r+" "+i+" "+i+" "+r+" 0 "+r+" c"),n.push("-"+i+" "+r+" -"+r+" "+i+" -"+r+" 0 c"),n.push("-"+r+" -"+i+" -"+i+" -"+r+" 0 -"+r+" c"),n.push(i+" -"+r+" "+r+" -"+i+" "+r+" 0 c"),n.push("f"),n.push("Q"),t.stream=n.join(`
82`),t},YesPushDown:function(e){var t=Wa(e);t.scope=e.scope;var n=[],r=dt.internal.getWidth(e)<=dt.internal.getHeight(e)?dt.internal.getWidth(e)/4:dt.internal.getHeight(e)/4;r=Number((.9*r).toFixed(5));var s=Number((2*r).toFixed(5)),i=Number((s*dt.internal.Bezier_C).toFixed(5)),c=Number((r*dt.internal.Bezier_C).toFixed(5));return n.push("0.749023 g"),n.push("q"),n.push("1 0 0 1 "+Ds(dt.internal.getWidth(e)/2)+" "+Ds(dt.internal.getHeight(e)/2)+" cm"),n.push(s+" 0 m"),n.push(s+" "+i+" "+i+" "+s+" 0 "+s+" c"),n.push("-"+i+" "+s+" -"+s+" "+i+" -"+s+" 0 c"),n.push("-"+s+" -"+i+" -"+i+" -"+s+" 0 -"+s+" c"),n.push(i+" -"+s+" "+s+" -"+i+" "+s+" 0 c"),n.push("f"),n.push("Q"),n.push("0 g"),n.push("q"),n.push("1 0 0 1 "+Ds(dt.internal.getWidth(e)/2)+" "+Ds(dt.internal.getHeight(e)/2)+" cm"),n.push(r+" 0 m"),n.push(r+" "+c+" "+c+" "+r+" 0 "+r+" c"),n.push("-"+c+" "+r+" -"+r+" "+c+" -"+r+" 0 c"),n.push("-"+r+" -"+c+" -"+c+" -"+r+" 0 -"+r+" c"),n.push(c+" -"+r+" "+r+" -"+c+" "+r+" 0 c"),n.push("f"),n.push("Q"),t.stream=n.join(`
83`),t},OffPushDown:function(e){var t=Wa(e);t.scope=e.scope;var n=[],r=dt.internal.getWidth(e)<=dt.internal.getHeight(e)?dt.internal.getWidth(e)/4:dt.internal.getHeight(e)/4;r=Number((.9*r).toFixed(5));var s=Number((2*r).toFixed(5)),i=Number((s*dt.internal.Bezier_C).toFixed(5));return n.push("0.749023 g"),n.push("q"),n.push("1 0 0 1 "+Ds(dt.internal.getWidth(e)/2)+" "+Ds(dt.internal.getHeight(e)/2)+" cm"),n.push(s+" 0 m"),n.push(s+" "+i+" "+i+" "+s+" 0 "+s+" c"),n.push("-"+i+" "+s+" -"+s+" "+i+" -"+s+" 0 c"),n.push("-"+s+" -"+i+" -"+i+" -"+s+" 0 -"+s+" c"),n.push(i+" -"+s+" "+s+" -"+i+" "+s+" 0 c"),n.push("f"),n.push("Q"),t.stream=n.join(`
84`),t}},Cross:{createAppearanceStream:function(e){var t={D:{Off:dt.RadioButton.Cross.OffPushDown},N:{}};return t.N[e]=dt.RadioButton.Cross.YesNormal,t.D[e]=dt.RadioButton.Cross.YesPushDown,t},getCA:function(){return"8"},YesNormal:function(e){var t=Wa(e);t.scope=e.scope;var n=[],r=dt.internal.calculateCross(e);return n.push("q"),n.push("1 1 "+Tt(dt.internal.getWidth(e)-2)+" "+Tt(dt.internal.getHeight(e)-2)+" re"),n.push("W"),n.push("n"),n.push(Tt(r.x1.x)+" "+Tt(r.x1.y)+" m"),n.push(Tt(r.x2.x)+" "+Tt(r.x2.y)+" l"),n.push(Tt(r.x4.x)+" "+Tt(r.x4.y)+" m"),n.push(Tt(r.x3.x)+" "+Tt(r.x3.y)+" l"),n.push("s"),n.push("Q"),t.stream=n.join(`
85`),t},YesPushDown:function(e){var t=Wa(e);t.scope=e.scope;var n=dt.internal.calculateCross(e),r=[];return r.push("0.749023 g"),r.push("0 0 "+Tt(dt.internal.getWidth(e))+" "+Tt(dt.internal.getHeight(e))+" re"),r.push("f"),r.push("q"),r.push("1 1 "+Tt(dt.internal.getWidth(e)-2)+" "+Tt(dt.internal.getHeight(e)-2)+" re"),r.push("W"),r.push("n"),r.push(Tt(n.x1.x)+" "+Tt(n.x1.y)+" m"),r.push(Tt(n.x2.x)+" "+Tt(n.x2.y)+" l"),r.push(Tt(n.x4.x)+" "+Tt(n.x4.y)+" m"),r.push(Tt(n.x3.x)+" "+Tt(n.x3.y)+" l"),r.push("s"),r.push("Q"),t.stream=r.join(`
86`),t},OffPushDown:function(e){var t=Wa(e);t.scope=e.scope;var n=[];return n.push("0.749023 g"),n.push("0 0 "+Tt(dt.internal.getWidth(e))+" "+Tt(dt.internal.getHeight(e))+" re"),n.push("f"),t.stream=n.join(`
87`),t}}},createDefaultAppearanceStream:function(e){var t=e.scope.internal.getFont(e.fontName,e.fontStyle).id,n=e.scope.__private__.encodeColorString(e.color);return"/"+t+" "+e.fontSize+" Tf "+n}};dt.internal={Bezier_C:.551915024494,calculateCross:function(e){var t=dt.internal.getWidth(e),n=dt.internal.getHeight(e),r=Math.min(t,n);return{x1:{x:(t-r)/2,y:(n-r)/2+r},x2:{x:(t-r)/2+r,y:(n-r)/2},x3:{x:(t-r)/2,y:(n-r)/2},x4:{x:(t-r)/2+r,y:(n-r)/2+r}}}},dt.internal.getWidth=function(e){var t=0;return pn(e)==="object"&&(t=of(e.Rect[2])),t},dt.internal.getHeight=function(e){var t=0;return pn(e)==="object"&&(t=of(e.Rect[3])),t};var ox=$n.addField=function(e){if(ix(this,e),!(e instanceof Da))throw new Error("Invalid argument passed to jsPDF.addField.");var t;return(t=e).scope.internal.acroformPlugin.printedOut&&(t.scope.internal.acroformPlugin.printedOut=!1,t.scope.internal.acroformPlugin.acroFormDictionaryRoot=null),t.scope.internal.acroformPlugin.acroFormDictionaryRoot.Fields.push(t),e.page=e.scope.internal.getCurrentPageInfo().pageNumber,this};$n.AcroFormChoiceField=ro,$n.AcroFormListBox=ao,$n.AcroFormComboBox=so,$n.AcroFormEditBox=Tl,$n.AcroFormButton=ur,$n.AcroFormPushButton=Dl,$n.AcroFormRadioButton=io,$n.AcroFormCheckBox=Rl,$n.AcroFormTextField=pi,$n.AcroFormPasswordField=Bl,$n.AcroFormAppearance=dt,$n.AcroForm={ChoiceField:ro,ListBox:ao,ComboBox:so,EditBox:Tl,Button:ur,PushButton:Dl,RadioButton:io,CheckBox:Rl,TextField:pi,PasswordField:Bl,Appearance:dt},yt.AcroForm={ChoiceField:ro,ListBox:ao,ComboBox:so,EditBox:Tl,Button:ur,PushButton:Dl,RadioButton:io,CheckBox:Rl,TextField:pi,PasswordField:Bl,Appearance:dt};yt.AcroForm;function yp(e){return e.reduce(function(t,n,r){return t[n]=r,t},{})}(function(e){var t="addImage_";e.__addimage__={};var n="UNKNOWN",r={PNG:[[137,80,78,71]],TIFF:[[77,77,0,42],[73,73,42,0]],JPEG:[[255,216,255,224,void 0,void 0,74,70,73,70,0],[255,216,255,225,void 0,void 0,69,120,105,102,0,0],[255,216,255,219],[255,216,255,238]],JPEG2000:[[0,0,0,12,106,80,32,32]],GIF87a:[[71,73,70,56,55,97]],GIF89a:[[71,73,70,56,57,97]],WEBP:[[82,73,70,70,void 0,void 0,void 0,void 0,87,69,66,80]],BMP:[[66,77],[66,65],[67,73],[67,80],[73,67],[80,84]]},s=e.__addimage__.getImageFileTypeByImageData=function(N,I){var k,L,H,te,se,K=n;if((I=I||n)==="RGBA"||N.data!==void 0&&N.data instanceof Uint8ClampedArray&&"height"in N&&"width"in N)return"RGBA";if(me(N))for(se in r)for(H=r[se],k=0;k<H.length;k+=1){for(te=!0,L=0;L<H[k].length;L+=1)if(H[k][L]!==void 0&&H[k][L]!==N[L]){te=!1;break}if(te===!0){K=se;break}}else for(se in r)for(H=r[se],k=0;k<H.length;k+=1){for(te=!0,L=0;L<H[k].length;L+=1)if(H[k][L]!==void 0&&H[k][L]!==N.charCodeAt(L)){te=!1;break}if(te===!0){K=se;break}}return K===n&&I!==n&&(K=I),K},i=function N(I){for(var k=this.internal.write,L=this.internal.putStream,H=(0,this.internal.getFilters)();H.indexOf("FlateEncode")!==-1;)H.splice(H.indexOf("FlateEncode"),1);I.objectId=this.internal.newObject();var te=[];if(te.push({key:"Type",value:"/XObject"}),te.push({key:"Subtype",value:"/Image"}),te.push({key:"Width",value:I.width}),te.push({key:"Height",value:I.height}),I.colorSpace===_.INDEXED?te.push({key:"ColorSpace",value:"[/Indexed /DeviceRGB "+(I.palette.length/3-1)+" "+("sMask"in I&&I.sMask!==void 0?I.objectId+2:I.objectId+1)+" 0 R]"}):(te.push({key:"ColorSpace",value:"/"+I.colorSpace}),I.colorSpace===_.DEVICE_CMYK&&te.push({key:"Decode",value:"[1 0 1 0 1 0 1 0]"})),te.push({key:"BitsPerComponent",value:I.bitsPerComponent}),"decodeParameters"in I&&I.decodeParameters!==void 0&&te.push({key:"DecodeParms",value:"<<"+I.decodeParameters+">>"}),"transparency"in I&&Array.isArray(I.transparency)&&I.transparency.length>0){for(var se="",K=0,ae=I.transparency.length;K<ae;K++)se+=I.transparency[K]+" "+I.transparency[K]+" ";te.push({key:"Mask",value:"["+se+"]"})}I.sMask!==void 0&&te.push({key:"SMask",value:I.objectId+1+" 0 R"});var be=I.filter!==void 0?["/"+I.filter]:void 0;if(L({data:I.data,additionalKeyValues:te,alreadyAppliedFilters:be,objectId:I.objectId}),k("endobj"),"sMask"in I&&I.sMask!==void 0){var Ne,A=(Ne=I.sMaskBitsPerComponent)!==null&&Ne!==void 0?Ne:I.bitsPerComponent,E={width:I.width,height:I.height,colorSpace:"DeviceGray",bitsPerComponent:A,data:I.sMask};"filter"in I&&(E.decodeParameters="/Predictor ".concat(I.predictor," /Colors 1 /BitsPerComponent ").concat(A," /Columns ").concat(I.width),E.filter=I.filter),N.call(this,E)}if(I.colorSpace===_.INDEXED){var z=this.internal.newObject();L({data:$(new Uint8Array(I.palette)),objectId:z}),k("endobj")}},c=function(){var N=this.internal.collections[t+"images"];for(var I in N)i.call(this,N[I])},l=function(){var N,I=this.internal.collections[t+"images"],k=this.internal.write;for(var L in I)k("/I"+(N=I[L]).index,N.objectId,"0","R")},d=function(){this.internal.collections[t+"images"]||(this.internal.collections[t+"images"]={},this.internal.events.subscribe("putResources",c),this.internal.events.subscribe("putXobjectDict",l))},h=function(){var N=this.internal.collections[t+"images"];return d.call(this),N},f=function(){return Object.keys(this.internal.collections[t+"images"]).length},x=function(N){return typeof e["process"+N.toUpperCase()]=="function"},b=function(N){return pn(N)==="object"&&N.nodeType===1},m=function(N,I){if(N.nodeName==="IMG"&&N.hasAttribute("src")){var k=""+N.getAttribute("src");if(k.indexOf("data:image/")===0)return Fl(unescape(k).split("base64,").pop());var L=e.loadFile(k,!0);if(L!==void 0)return L}if(N.nodeName==="CANVAS"){if(N.width===0||N.height===0)throw new Error("Given canvas must have data. Canvas width: "+N.width+", height: "+N.height);var H;switch(I){case"PNG":H="image/png";break;case"WEBP":H="image/webp";break;default:H="image/jpeg"}return Fl(N.toDataURL(H,1).split("base64,").pop())}},w=function(N){var I=this.internal.collections[t+"images"];if(I){for(var k in I)if(N===I[k].alias)return I[k]}},v=function(N,I,k){return N||I||(N=-96,I=-96),N<0&&(N=-1*k.width*72/N/this.internal.scaleFactor),I<0&&(I=-1*k.height*72/I/this.internal.scaleFactor),N===0&&(N=I*k.width/k.height),I===0&&(I=N*k.height/k.width),[N,I]},P=function(N,I,k,L,H,te){var se=v.call(this,k,L,H),K=this.internal.getCoordinateString,ae=this.internal.getVerticalCoordinateString,be=h.call(this);if(k=se[0],L=se[1],be[H.index]=H,te){te*=Math.PI/180;var Ne=Math.cos(te),A=Math.sin(te),E=function(X){return X.toFixed(4)},z=[E(Ne),E(A),E(-1*A),E(Ne),0,0,"cm"]}this.internal.write("q"),te?(this.internal.write([1,"0","0",1,K(N),ae(I+L),"cm"].join(" ")),this.internal.write(z.join(" ")),this.internal.write([K(k),"0","0",K(L),"0","0","cm"].join(" "))):this.internal.write([K(k),"0","0",K(L),K(N),ae(I+L),"cm"].join(" ")),this.isAdvancedAPI()&&this.internal.write([1,0,0,-1,0,0,"cm"].join(" ")),this.internal.write("/I"+H.index+" Do"),this.internal.write("Q")},_=e.color_spaces={DEVICE_RGB:"DeviceRGB",DEVICE_GRAY:"DeviceGray",DEVICE_CMYK:"DeviceCMYK",CAL_GREY:"CalGray",CAL_RGB:"CalRGB",LAB:"Lab",ICC_BASED:"ICCBased",INDEXED:"Indexed",PATTERN:"Pattern",SEPARATION:"Separation",DEVICE_N:"DeviceN"};e.decode={DCT_DECODE:"DCTDecode",FLATE_DECODE:"FlateDecode",LZW_DECODE:"LZWDecode",JPX_DECODE:"JPXDecode",JBIG2_DECODE:"JBIG2Decode",ASCII85_DECODE:"ASCII85Decode",ASCII_HEX_DECODE:"ASCIIHexDecode",RUN_LENGTH_DECODE:"RunLengthDecode",CCITT_FAX_DECODE:"CCITTFaxDecode"};var q=e.image_compression={NONE:"NONE",FAST:"FAST",MEDIUM:"MEDIUM",SLOW:"SLOW"},T=e.__addimage__.sHashCode=function(N){var I,k,L=0;if(typeof N=="string")for(k=N.length,I=0;I<k;I++)L=(L<<5)-L+N.charCodeAt(I),L|=0;else if(me(N))for(k=N.byteLength/2,I=0;I<k;I++)L=(L<<5)-L+N[I],L|=0;return L},B=e.__addimage__.validateStringAsBase64=function(N){(N=N||"").toString().trim();var I=!0;return N.length===0&&(I=!1),N.length%4!=0&&(I=!1),/^[A-Za-z0-9+/]+$/.test(N.substr(0,N.length-2))===!1&&(I=!1),/^[A-Za-z0-9/][A-Za-z0-9+/]|[A-Za-z0-9+/]=|==$/.test(N.substr(-2))===!1&&(I=!1),I},Q=e.__addimage__.extractImageFromDataUrl=function(N){if(N==null||!(N=N.trim()).startsWith("data:"))return null;var I=N.indexOf(",");return I<0?null:N.substring(0,I).trim().endsWith("base64")?N.substring(I+1):null};e.__addimage__.isArrayBuffer=function(N){return N instanceof ArrayBuffer};var me=e.__addimage__.isArrayBufferView=function(N){return N instanceof Int8Array||N instanceof Uint8Array||N instanceof Uint8ClampedArray||N instanceof Int16Array||N instanceof Uint16Array||N instanceof Int32Array||N instanceof Uint32Array||N instanceof Float32Array||N instanceof Float64Array},ce=e.__addimage__.binaryStringToUint8Array=function(N){for(var I=N.length,k=new Uint8Array(I),L=0;L<I;L++)k[L]=N.charCodeAt(L);return k},$=e.__addimage__.arrayBufferToBinaryString=function(N){for(var I="",k=me(N)?N:new Uint8Array(N),L=0;L<k.length;L+=8192)I+=String.fromCharCode.apply(null,k.subarray(L,L+8192));return I};e.addImage=function(){var N,I,k,L,H,te,se,K,ae;if(typeof arguments[1]=="number"?(I=n,k=arguments[1],L=arguments[2],H=arguments[3],te=arguments[4],se=arguments[5],K=arguments[6],ae=arguments[7]):(I=arguments[1],k=arguments[2],L=arguments[3],H=arguments[4],te=arguments[5],se=arguments[6],K=arguments[7],ae=arguments[8]),pn(N=arguments[0])==="object"&&!b(N)&&"imageData"in N){var be=N;N=be.imageData,I=be.format||I||n,k=be.x||k||0,L=be.y||L||0,H=be.w||be.width||H,te=be.h||be.height||te,se=be.alias||se,K=be.compression||K,ae=be.rotation||be.angle||ae}var Ne=this.internal.getFilters();if(K===void 0&&Ne.indexOf("FlateEncode")!==-1&&(K="SLOW"),isNaN(k)||isNaN(L))throw new Error("Invalid coordinates passed to jsPDF.addImage");d.call(this);var A=D.call(this,N,I,se,K);return P.call(this,k,L,H,te,A,ae),this};var D=function(N,I,k,L){var H,te,se;if(typeof N=="string"&&s(N)===n){N=unescape(N);var K=Y(N,!1);(K!==""||(K=e.loadFile(N,!0))!==void 0)&&(N=K)}if(b(N)&&(N=m(N,I)),I=s(N,I),!x(I))throw new Error("addImage does not support files of type '"+I+"', please ensure that a plugin for '"+I+"' support is added.");if(((se=k)==null||se.length===0)&&(k=function(ae){return typeof ae=="string"||me(ae)?T(ae):me(ae.data)?T(ae.data):null}(N)),(H=w.call(this,k))||(N instanceof Uint8Array||I==="RGBA"||(te=N,N=ce(N)),H=this["process"+I.toUpperCase()](N,f.call(this),k,function(ae){return ae&&typeof ae=="string"&&(ae=ae.toUpperCase()),ae in e.image_compression?ae:q.NONE}(L),te)),!H)throw new Error("An unknown error occurred whilst processing the image.");return H},Y=e.__addimage__.convertBase64ToBinaryString=function(N,I){I=typeof I!="boolean"||I;var k,L="";if(typeof N=="string"){var H;k=(H=Q(N))!==null&&H!==void 0?H:N;try{L=Fl(k)}catch(te){if(I)throw B(k)?new Error("atob-Error in jsPDF.convertBase64ToBinaryString "+te.message):new Error("Supplied Data is not a valid base64-String jsPDF.convertBase64ToBinaryString ")}}return L};e.getImageProperties=function(N){var I,k,L="";if(b(N)&&(N=m(N)),typeof N=="string"&&s(N)===n&&((L=Y(N,!1))===""&&(L=e.loadFile(N)||""),N=L),k=s(N),!x(k))throw new Error("addImage does not support files of type '"+k+"', please ensure that a plugin for '"+k+"' support is added.");if(N instanceof Uint8Array||(N=ce(N)),!(I=this["process"+k.toUpperCase()](N)))throw new Error("An unknown error occurred whilst processing the image");return I.fileType=k,I}})(yt.API),function(e){var t=function(n){if(n!==void 0&&n!="")return!0};yt.API.events.push(["addPage",function(n){this.internal.getPageInfo(n.pageNumber).pageContext.annotations=[]}]),e.events.push(["putPage",function(n){for(var r,s,i,c=this.internal.getCoordinateString,l=this.internal.getVerticalCoordinateString,d=this.internal.getPageInfoByObjId(n.objId),h=n.pageContext.annotations,f=!1,x=0;x<h.length&&!f;x++)switch((r=h[x]).type){case"link":(t(r.options.url)||t(r.options.pageNumber))&&(f=!0);break;case"reference":case"text":case"freetext":f=!0}if(f!=0){this.internal.write("/Annots [");for(var b=0;b<h.length;b++){r=h[b];var m=this.internal.pdfEscape,w=this.internal.getEncryptor(n.objId);switch(r.type){case"reference":this.internal.write(" "+r.object.objId+" 0 R ");break;case"text":var v=this.internal.newAdditionalObject(),P=this.internal.newAdditionalObject(),_=this.internal.getEncryptor(v.objId),q=r.title||"Note";i="<</Type /Annot /Subtype /Text "+(s="/Rect ["+c(r.bounds.x)+" "+l(r.bounds.y+r.bounds.h)+" "+c(r.bounds.x+r.bounds.w)+" "+l(r.bounds.y)+"] ")+"/Contents ("+m(_(r.contents))+")",i+=" /Popup "+P.objId+" 0 R",i+=" /P "+d.objId+" 0 R",i+=" /T ("+m(_(q))+") >>",v.content=i;var T=v.objId+" 0 R";i="<</Type /Annot /Subtype /Popup "+(s="/Rect ["+c(r.bounds.x+30)+" "+l(r.bounds.y+r.bounds.h)+" "+c(r.bounds.x+r.bounds.w+30)+" "+l(r.bounds.y)+"] ")+" /Parent "+T,r.open&&(i+=" /Open true"),i+=" >>",P.content=i,this.internal.write(v.objId,"0 R",P.objId,"0 R");break;case"freetext":s="/Rect ["+c(r.bounds.x)+" "+l(r.bounds.y)+" "+c(r.bounds.x+r.bounds.w)+" "+l(r.bounds.y+r.bounds.h)+"] ";var B="font: Helvetica,sans-serif 12.0pt; text-align:left; color:#"+(r.color||"#000000");i="<</Type /Annot /Subtype /FreeText "+s+"/Contents ("+m(w(r.contents))+")",i+=" /DS("+m(w(B))+")",i+=" /Border [0 0 0]",i+=" >>",this.internal.write(i);break;case"link":if(r.options.name){var Q=this.annotations._nameMap[r.options.name];r.options.pageNumber=Q.page,r.options.top=Q.y}else r.options.top||(r.options.top=0);if(s="/Rect ["+r.finalBounds.x+" "+r.finalBounds.y+" "+r.finalBounds.w+" "+r.finalBounds.h+"] ",i="",r.options.url)i="<</Type /Annot /Subtype /Link "+s+"/Border [0 0 0] /A <</S /URI /URI ("+m(w(r.options.url))+") >>";else if(r.options.pageNumber)switch(i="<</Type /Annot /Subtype /Link "+s+"/Border [0 0 0] /Dest ["+this.internal.getPageInfo(r.options.pageNumber).objId+" 0 R",r.options.magFactor=r.options.magFactor||"XYZ",r.options.magFactor){case"Fit":i+=" /Fit]";break;case"FitH":i+=" /FitH "+r.options.top+"]";break;case"FitV":r.options.left=r.options.left||0,i+=" /FitV "+r.options.left+"]";break;default:var me=l(r.options.top);r.options.left=r.options.left||0,r.options.zoom===void 0&&(r.options.zoom=0),i+=" /XYZ "+r.options.left+" "+me+" "+r.options.zoom+"]"}i!=""&&(i+=" >>",this.internal.write(i))}}this.internal.write("]")}}]),e.createAnnotation=function(n){var r=this.internal.getCurrentPageInfo();switch(n.type){case"link":this.link(n.bounds.x,n.bounds.y,n.bounds.w,n.bounds.h,n);break;case"text":case"freetext":r.pageContext.annotations.push(n)}},e.link=function(n,r,s,i,c){var l=this.internal.getCurrentPageInfo(),d=this.internal.getCoordinateString,h=this.internal.getVerticalCoordinateString;l.pageContext.annotations.push({finalBounds:{x:d(n),y:h(r),w:d(n+s),h:h(r+i)},options:c,type:"link"})},e.textWithLink=function(n,r,s,i){var c,l,d=this.getTextWidth(n),h=this.internal.getLineHeight()/this.internal.scaleFactor;if(i.maxWidth!==void 0){l=i.maxWidth;var f=this.splitTextToSize(n,l).length;c=Math.ceil(h*f)}else l=d,c=h;return this.text(n,r,s,i),s+=.2*h,i.align==="center"&&(r-=d/2),i.align==="right"&&(r-=d),this.link(r,s-h,l,c,i),d},e.getTextWidth=function(n){var r=this.internal.getFontSize();return this.getStringUnitWidth(n)*r/this.internal.scaleFactor}}(yt.API),function(e){var t={1569:[65152],1570:[65153,65154],1571:[65155,65156],1572:[65157,65158],1573:[65159,65160],1574:[65161,65162,65163,65164],1575:[65165,65166],1576:[65167,65168,65169,65170],1577:[65171,65172],1578:[65173,65174,65175,65176],1579:[65177,65178,65179,65180],1580:[65181,65182,65183,65184],1581:[65185,65186,65187,65188],1582:[65189,65190,65191,65192],1583:[65193,65194],1584:[65195,65196],1585:[65197,65198],1586:[65199,65200],1587:[65201,65202,65203,65204],1588:[65205,65206,65207,65208],1589:[65209,65210,65211,65212],1590:[65213,65214,65215,65216],1591:[65217,65218,65219,65220],1592:[65221,65222,65223,65224],1593:[65225,65226,65227,65228],1594:[65229,65230,65231,65232],1601:[65233,65234,65235,65236],1602:[65237,65238,65239,65240],1603:[65241,65242,65243,65244],1604:[65245,65246,65247,65248],1605:[65249,65250,65251,65252],1606:[65253,65254,65255,65256],1607:[65257,65258,65259,65260],1608:[65261,65262],1609:[65263,65264,64488,64489],1610:[65265,65266,65267,65268],1649:[64336,64337],1655:[64477],1657:[64358,64359,64360,64361],1658:[64350,64351,64352,64353],1659:[64338,64339,64340,64341],1662:[64342,64343,64344,64345],1663:[64354,64355,64356,64357],1664:[64346,64347,64348,64349],1667:[64374,64375,64376,64377],1668:[64370,64371,64372,64373],1670:[64378,64379,64380,64381],1671:[64382,64383,64384,64385],1672:[64392,64393],1676:[64388,64389],1677:[64386,64387],1678:[64390,64391],1681:[64396,64397],1688:[64394,64395],1700:[64362,64363,64364,64365],1702:[64366,64367,64368,64369],1705:[64398,64399,64400,64401],1709:[64467,64468,64469,64470],1711:[64402,64403,64404,64405],1713:[64410,64411,64412,64413],1715:[64406,64407,64408,64409],1722:[64414,64415],1723:[64416,64417,64418,64419],1726:[64426,64427,64428,64429],1728:[64420,64421],1729:[64422,64423,64424,64425],1733:[64480,64481],1734:[64473,64474],1735:[64471,64472],1736:[64475,64476],1737:[64482,64483],1739:[64478,64479],1740:[64508,64509,64510,64511],1744:[64484,64485,64486,64487],1746:[64430,64431],1747:[64432,64433]},n={65247:{65154:65269,65156:65271,65160:65273,65166:65275},65248:{65154:65270,65156:65272,65160:65274,65166:65276},65165:{65247:{65248:{65258:65010}}},1617:{1612:64606,1613:64607,1614:64608,1615:64609,1616:64610}},r={1612:64606,1613:64607,1614:64608,1615:64609,1616:64610},s=[1570,1571,1573,1575];e.__arabicParser__={};var i=e.__arabicParser__.isInArabicSubstitutionA=function(v){return t[v.charCodeAt(0)]!==void 0},c=e.__arabicParser__.isArabicLetter=function(v){return typeof v=="string"&&/^[\u0600-\u06FF\u0750-\u077F\u08A0-\u08FF\uFB50-\uFDFF\uFE70-\uFEFF]+$/.test(v)},l=e.__arabicParser__.isArabicEndLetter=function(v){return c(v)&&i(v)&&t[v.charCodeAt(0)].length<=2},d=e.__arabicParser__.isArabicAlfLetter=function(v){return c(v)&&s.indexOf(v.charCodeAt(0))>=0};e.__arabicParser__.arabicLetterHasIsolatedForm=function(v){return c(v)&&i(v)&&t[v.charCodeAt(0)].length>=1};var h=e.__arabicParser__.arabicLetterHasFinalForm=function(v){return c(v)&&i(v)&&t[v.charCodeAt(0)].length>=2};e.__arabicParser__.arabicLetterHasInitialForm=function(v){return c(v)&&i(v)&&t[v.charCodeAt(0)].length>=3};var f=e.__arabicParser__.arabicLetterHasMedialForm=function(v){return c(v)&&i(v)&&t[v.charCodeAt(0)].length==4},x=e.__arabicParser__.resolveLigatures=function(v){var P=0,_=n,q="",T=0;for(P=0;P<v.length;P+=1)_[v.charCodeAt(P)]!==void 0?(T++,typeof(_=_[v.charCodeAt(P)])=="number"&&(q+=String.fromCharCode(_),_=n,T=0),P===v.length-1&&(_=n,q+=v.charAt(P-(T-1)),P-=T-1,T=0)):(_=n,q+=v.charAt(P-T),P-=T,T=0);return q};e.__arabicParser__.isArabicDiacritic=function(v){return v!==void 0&&r[v.charCodeAt(0)]!==void 0};var b=e.__arabicParser__.getCorrectForm=function(v,P,_){return c(v)?i(v)===!1?-1:!h(v)||!c(P)&&!c(_)||!c(_)&&l(P)||l(v)&&!c(P)||l(v)&&d(P)||l(v)&&l(P)?0:f(v)&&c(P)&&!l(P)&&c(_)&&h(_)?3:l(v)||!c(_)?1:2:-1},m=function(v){var P=0,_=0,q=0,T="",B="",Q="",me=(v=v||"").split("\\s+"),ce=[];for(P=0;P<me.length;P+=1){for(ce.push(""),_=0;_<me[P].length;_+=1)T=me[P][_],B=me[P][_-1],Q=me[P][_+1],c(T)?(q=b(T,B,Q),ce[P]+=q!==-1?String.fromCharCode(t[T.charCodeAt(0)][q]):T):ce[P]+=T;ce[P]=x(ce[P])}return ce.join(" ")},w=e.__arabicParser__.processArabic=e.processArabic=function(){var v,P=typeof arguments[0]=="string"?arguments[0]:arguments[0].text,_=[];if(Array.isArray(P)){var q=0;for(_=[],q=0;q<P.length;q+=1)Array.isArray(P[q])?_.push([m(P[q][0]),P[q][1],P[q][2]]):_.push([m(P[q])]);v=_}else v=m(P);return typeof arguments[0]=="string"?v:(arguments[0].text=v,arguments[0])};e.events.push(["preProcessText",w])}(yt.API),yt.API.autoPrint=function(e){var t;return(e=e||{}).variant=e.variant||"non-conform",e.variant==="javascript"?this.addJS("print({});"):(this.internal.events.subscribe("postPutResources",function(){t=this.internal.newObject(),this.internal.out("<<"),this.internal.out("/S /Named"),this.internal.out("/Type /Action"),this.internal.out("/N /Print"),this.internal.out(">>"),this.internal.out("endobj")}),this.internal.events.subscribe("putCatalog",function(){this.internal.out("/OpenAction "+t+" 0 R")})),this},function(e){var t=function(){var n=void 0;Object.defineProperty(this,"pdf",{get:function(){return n},set:function(l){n=l}});var r=150;Object.defineProperty(this,"width",{get:function(){return r},set:function(l){r=isNaN(l)||Number.isInteger(l)===!1||l<0?150:l,this.getContext("2d").pageWrapXEnabled&&(this.getContext("2d").pageWrapX=r+1)}});var s=300;Object.defineProperty(this,"height",{get:function(){return s},set:function(l){s=isNaN(l)||Number.isInteger(l)===!1||l<0?300:l,this.getContext("2d").pageWrapYEnabled&&(this.getContext("2d").pageWrapY=s+1)}});var i=[];Object.defineProperty(this,"childNodes",{get:function(){return i},set:function(l){i=l}});var c={};Object.defineProperty(this,"style",{get:function(){return c},set:function(l){c=l}}),Object.defineProperty(this,"parentNode",{})};t.prototype.getContext=function(n,r){var s;if((n=n||"2d")!=="2d")return null;for(s in r)this.pdf.context2d.hasOwnProperty(s)&&(this.pdf.context2d[s]=r[s]);return this.pdf.context2d._canvas=this,this.pdf.context2d},t.prototype.toDataURL=function(){throw new Error("toDataURL is not implemented.")},e.events.push(["initialized",function(){this.canvas=new t,this.canvas.pdf=this}])}(yt.API),function(e){var t={left:0,top:0,bottom:0,right:0},n=!1,r=function(){this.internal.__cell__===void 0&&(this.internal.__cell__={},this.internal.__cell__.padding=3,this.internal.__cell__.headerFunction=void 0,this.internal.__cell__.margins=Object.assign({},t),this.internal.__cell__.margins.width=this.getPageWidth(),s.call(this))},s=function(){this.internal.__cell__.lastCell=new i,this.internal.__cell__.pages=1},i=function(){var d=arguments[0];Object.defineProperty(this,"x",{enumerable:!0,get:function(){return d},set:function(v){d=v}});var h=arguments[1];Object.defineProperty(this,"y",{enumerable:!0,get:function(){return h},set:function(v){h=v}});var f=arguments[2];Object.defineProperty(this,"width",{enumerable:!0,get:function(){return f},set:function(v){f=v}});var x=arguments[3];Object.defineProperty(this,"height",{enumerable:!0,get:function(){return x},set:function(v){x=v}});var b=arguments[4];Object.defineProperty(this,"text",{enumerable:!0,get:function(){return b},set:function(v){b=v}});var m=arguments[5];Object.defineProperty(this,"lineNumber",{enumerable:!0,get:function(){return m},set:function(v){m=v}});var w=arguments[6];return Object.defineProperty(this,"align",{enumerable:!0,get:function(){return w},set:function(v){w=v}}),this};i.prototype.clone=function(){return new i(this.x,this.y,this.width,this.height,this.text,this.lineNumber,this.align)},i.prototype.toArray=function(){return[this.x,this.y,this.width,this.height,this.text,this.lineNumber,this.align]},e.setHeaderFunction=function(d){return r.call(this),this.internal.__cell__.headerFunction=typeof d=="function"?d:void 0,this},e.getTextDimensions=function(d,h){r.call(this);var f=(h=h||{}).fontSize||this.getFontSize(),x=h.font||this.getFont(),b=h.scaleFactor||this.internal.scaleFactor,m=0,w=0,v=0,P=this;if(!Array.isArray(d)&&typeof d!="string"){if(typeof d!="number")throw new Error("getTextDimensions expects text-parameter to be of type String or type Number or an Array of Strings.");d=String(d)}var _=h.maxWidth;_>0?typeof d=="string"?d=this.splitTextToSize(d,_):Object.prototype.toString.call(d)==="[object Array]"&&(d=d.reduce(function(T,B){return T.concat(P.splitTextToSize(B,_))},[])):d=Array.isArray(d)?d:[d];for(var q=0;q<d.length;q++)m<(v=this.getStringUnitWidth(d[q],{font:x})*f)&&(m=v);return m!==0&&(w=d.length),{w:m/=b,h:Math.max((w*f*this.getLineHeightFactor()-f*(this.getLineHeightFactor()-1))/b,0)}},e.cellAddPage=function(){r.call(this),this.addPage();var d=this.internal.__cell__.margins||t;return this.internal.__cell__.lastCell=new i(d.left,d.top,void 0,void 0),this.internal.__cell__.pages+=1,this};var c=e.cell=function(){var d;d=arguments[0]instanceof i?arguments[0]:new i(arguments[0],arguments[1],arguments[2],arguments[3],arguments[4],arguments[5],arguments[6]),r.call(this);var h=this.internal.__cell__.lastCell,f=this.internal.__cell__.padding,x=this.internal.__cell__.margins||t,b=this.internal.__cell__.tableHeaderRow,m=this.internal.__cell__.printHeaders;return h.lineNumber!==void 0&&(h.lineNumber===d.lineNumber?(d.x=(h.x||0)+(h.width||0),d.y=h.y||0):h.y+h.height+d.height+x.bottom>this.getPageHeight()?(this.cellAddPage(),d.y=x.top,m&&b&&(this.printHeaderRow(d.lineNumber,!0),d.y+=b[0].height)):d.y=h.y+h.height||d.y),d.text[0]!==void 0&&(this.rect(d.x,d.y,d.width,d.height,n===!0?"FD":void 0),d.align==="right"?this.text(d.text,d.x+d.width-f,d.y+f,{align:"right",baseline:"top"}):d.align==="center"?this.text(d.text,d.x+d.width/2,d.y+f,{align:"center",baseline:"top",maxWidth:d.width-f-f}):this.text(d.text,d.x+f,d.y+f,{align:"left",baseline:"top",maxWidth:d.width-f-f})),this.internal.__cell__.lastCell=d,this};e.table=function(d,h,f,x,b){if(r.call(this),!f)throw new Error("No data for PDF table.");var m,w,v,P,_=[],q=[],T=[],B={},Q={},me=[],ce=[],$=(b=b||{}).autoSize||!1,D=b.printHeaders!==!1,Y=b.css&&b.css["font-size"]!==void 0?16*b.css["font-size"]:b.fontSize||12,N=b.margins||Object.assign({width:this.getPageWidth()},t),I=typeof b.padding=="number"?b.padding:3,k=b.headerBackgroundColor||"#c8c8c8",L=b.headerTextColor||"#000";if(s.call(this),this.internal.__cell__.printHeaders=D,this.internal.__cell__.margins=N,this.internal.__cell__.table_font_size=Y,this.internal.__cell__.padding=I,this.internal.__cell__.headerBackgroundColor=k,this.internal.__cell__.headerTextColor=L,this.setFontSize(Y),x==null)q=_=Object.keys(f[0]),T=_.map(function(){return"left"});else if(Array.isArray(x)&&pn(x[0])==="object")for(_=x.map(function(be){return be.name}),q=x.map(function(be){return be.prompt||be.name||""}),T=x.map(function(be){return be.align||"left"}),m=0;m<x.length;m+=1)Q[x[m].name]=.7499990551181103*x[m].width;else Array.isArray(x)&&typeof x[0]=="string"&&(q=_=x,T=_.map(function(){return"left"}));if($||Array.isArray(x)&&typeof x[0]=="string")for(m=0;m<_.length;m+=1){for(B[P=_[m]]=f.map(function(be){return be[P]}),this.setFont(void 0,"bold"),me.push(this.getTextDimensions(q[m],{fontSize:this.internal.__cell__.table_font_size,scaleFactor:this.internal.scaleFactor}).w),w=B[P],this.setFont(void 0,"normal"),v=0;v<w.length;v+=1)me.push(this.getTextDimensions(w[v],{fontSize:this.internal.__cell__.table_font_size,scaleFactor:this.internal.scaleFactor}).w);Q[P]=Math.max.apply(null,me)+I+I,me=[]}if(D){var H={};for(m=0;m<_.length;m+=1)H[_[m]]={},H[_[m]].text=q[m],H[_[m]].align=T[m];var te=l.call(this,H,Q);ce=_.map(function(be){return new i(d,h,Q[be],te,H[be].text,void 0,H[be].align)}),this.setTableHeaderRow(ce),this.printHeaderRow(1,!1)}var se=x.reduce(function(be,Ne){return be[Ne.name]=Ne.align,be},{});for(m=0;m<f.length;m+=1){"rowStart"in b&&b.rowStart instanceof Function&&b.rowStart({row:m,data:f[m]},this);var K=l.call(this,f[m],Q);for(v=0;v<_.length;v+=1){var ae=f[m][_[v]];"cellStart"in b&&b.cellStart instanceof Function&&b.cellStart({row:m,col:v,data:ae},this),c.call(this,new i(d,h,Q[_[v]],K,ae,m+2,se[_[v]]))}}return this.internal.__cell__.table_x=d,this.internal.__cell__.table_y=h,this};var l=function(d,h){var f=this.internal.__cell__.padding,x=this.internal.__cell__.table_font_size,b=this.internal.scaleFactor;return Object.keys(d).map(function(m){var w=d[m];return this.splitTextToSize(w.hasOwnProperty("text")?w.text:w,h[m]-f-f)},this).map(function(m){return this.getLineHeightFactor()*m.length*x/b+f+f},this).reduce(function(m,w){return Math.max(m,w)},0)};e.setTableHeaderRow=function(d){r.call(this),this.internal.__cell__.tableHeaderRow=d},e.printHeaderRow=function(d,h){if(r.call(this),!this.internal.__cell__.tableHeaderRow)throw new Error("Property tableHeaderRow does not exist.");var f;if(n=!0,typeof this.internal.__cell__.headerFunction=="function"){var x=this.internal.__cell__.headerFunction(this,this.internal.__cell__.pages);this.internal.__cell__.lastCell=new i(x[0],x[1],x[2],x[3],void 0,-1)}this.setFont(void 0,"bold");for(var b=[],m=0;m<this.internal.__cell__.tableHeaderRow.length;m+=1){f=this.internal.__cell__.tableHeaderRow[m].clone(),h&&(f.y=this.internal.__cell__.margins.top||0,b.push(f)),f.lineNumber=d;var w=this.getTextColor();this.setTextColor(this.internal.__cell__.headerTextColor),this.setFillColor(this.internal.__cell__.headerBackgroundColor),c.call(this,f),this.setTextColor(w)}b.length>0&&this.setTableHeaderRow(b),this.setFont(void 0,"normal"),n=!1}}(yt.API);var bp={italic:["italic","oblique","normal"],oblique:["oblique","italic","normal"],normal:["normal","oblique","italic"]},vp=["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded"],Ed=yp(vp),_p=[100,200,300,400,500,600,700,800,900],lx=yp(_p);function Kc(e){var t=e.family.replace(/"|'/g,"").toLowerCase(),n=function(i){return bp[i=i||"normal"]?i:"normal"}(e.style),r=function(i){return i?typeof i=="number"?i>=100&&i<=900&&i%100==0?i:400:/^\d00$/.test(i)?parseInt(i):i==="bold"?700:400:400}(e.weight),s=function(i){return typeof Ed[i=i||"normal"]=="number"?i:"normal"}(e.stretch);return{family:t,style:n,weight:r,stretch:s,src:e.src||[],ref:e.ref||{name:t,style:[s,n,r].join(" ")}}}function lf(e,t,n,r){var s;for(s=n;s>=0&&s<t.length;s+=r)if(e[t[s]])return e[t[s]];for(s=n;s>=0&&s<t.length;s-=r)if(e[t[s]])return e[t[s]]}var cx={"sans-serif":"helvetica",fixed:"courier",monospace:"courier",terminal:"courier",cursive:"times",fantasy:"times",serif:"times"},cf={caption:"times",icon:"times",menu:"times","message-box":"times","small-caption":"times","status-bar":"times"};function df(e){return[e.stretch,e.style,e.weight,e.family].join(" ")}function uf(e){return e.trimLeft()}function dx(e,t){for(var n=0;n<e.length;){if(e.charAt(n)===t)return[e.substring(0,n),e.substring(n+1)];n+=1}return null}function ux(e){var t=e.match(/^(-[a-z_]|[a-z_])[a-z0-9_-]*/i);return t===null?null:[t[0],e.substring(t[0].length)]}var Yi,Nl,hf,ff,mf,Qc=["times"];function pf(e,t,n,r,s){var i=4,c=xf;switch(s){case yt.API.image_compression.FAST:i=1,c=gf;break;case yt.API.image_compression.MEDIUM:i=6,c=yf;break;case yt.API.image_compression.SLOW:i=9,c=bf}e=function(d,h,f,x){for(var b,m=d.length/h,w=new Uint8Array(d.length+m),v=[hx,gf,xf,yf,bf],P=0;P<m;P+=1){var _=P*h,q=d.subarray(_,_+h);if(x)w.set(x(q,f,b),_+P);else{for(var T=v.length,B=[],Q=0;Q<T;Q+=1)B[Q]=v[Q](q,f,b);var me=mx(B.concat());w.set(B[me],_+P)}b=q}return w}(e,t,Math.ceil(n*r/8),c);var l=jd(e,{level:i});return yt.API.__addimage__.arrayBufferToBinaryString(l)}function hx(e){var t=Array.apply([],e);return t.unshift(0),t}function gf(e,t){var n=e.length,r=[];r[0]=1;for(var s=0;s<n;s+=1){var i=e[s-t]||0;r[s+1]=e[s]-i+256&255}return r}function xf(e,t,n){var r=e.length,s=[];s[0]=2;for(var i=0;i<r;i+=1){var c=n&&n[i]||0;s[i+1]=e[i]-c+256&255}return s}function yf(e,t,n){var r=e.length,s=[];s[0]=3;for(var i=0;i<r;i+=1){var c=e[i-t]||0,l=n&&n[i]||0;s[i+1]=e[i]+256-(c+l>>>1)&255}return s}function bf(e,t,n){var r=e.length,s=[];s[0]=4;for(var i=0;i<r;i+=1){var c=fx(e[i-t]||0,n&&n[i]||0,n&&n[i-t]||0);s[i+1]=e[i]-c+256&255}return s}function fx(e,t,n){if(e===t&&t===n)return e;var r=Math.abs(t-n),s=Math.abs(e-n),i=Math.abs(e+t-n-n);return r<=s&&r<=i?e:s<=i?t:n}function mx(e){var t=e.map(function(n){return n.reduce(function(r,s){return r+Math.abs(s)},0)});return t.indexOf(Math.min.apply(null,t))}function Jc(e,t,n){var r=t*n,s=Math.floor(r/8),i=16-(r-8*s+n),c=(1<<n)-1;return wp(e,s)>>i&c}function vf(e,t,n,r){var s=n*r,i=Math.floor(s/8),c=16-(s-8*i+r),l=(1<<r)-1,d=(t&l)<<c;(function(h,f,x){if(f+1<h.byteLength)h.setUint16(f,x,!1);else{var b=x>>8&255;h.setUint8(f,b)}})(e,i,wp(e,i)&~(l<<c)&65535|d)}function wp(e,t){return t+1<e.byteLength?e.getUint16(t,!1):e.getUint8(t)<<8}function px(e){var t=0;if(e[t++]!==71||e[t++]!==73||e[t++]!==70||e[t++]!==56||(e[t++]+1&253)!=56||e[t++]!==97)throw new Error("Invalid GIF 87a/89a header.");var n=e[t++]|e[t++]<<8,r=e[t++]|e[t++]<<8,s=e[t++],i=s>>7,c=1<<1+(7&s);e[t++],e[t++];var l=null,d=null;i&&(l=t,d=c,t+=3*c);var h=!0,f=[],x=0,b=null,m=0,w=null;for(this.width=n,this.height=r;h&&t<e.length;)switch(e[t++]){case 33:switch(e[t++]){case 255:if(e[t]!==11||e[t+1]==78&&e[t+2]==69&&e[t+3]==84&&e[t+4]==83&&e[t+5]==67&&e[t+6]==65&&e[t+7]==80&&e[t+8]==69&&e[t+9]==50&&e[t+10]==46&&e[t+11]==48&&e[t+12]==3&&e[t+13]==1&&e[t+16]==0)t+=14,w=e[t++]|e[t++]<<8,t++;else for(t+=12;;){if(!((N=e[t++])>=0))throw Error("Invalid block size");if(N===0)break;t+=N}break;case 249:if(e[t++]!==4||e[t+4]!==0)throw new Error("Invalid graphics extension block.");var v=e[t++];x=e[t++]|e[t++]<<8,b=e[t++],1&v||(b=null),m=v>>2&7,t++;break;case 254:for(;;){if(!((N=e[t++])>=0))throw Error("Invalid block size");if(N===0)break;t+=N}break;default:throw new Error("Unknown graphic control label: 0x"+e[t-1].toString(16))}break;case 44:var P=e[t++]|e[t++]<<8,_=e[t++]|e[t++]<<8,q=e[t++]|e[t++]<<8,T=e[t++]|e[t++]<<8,B=e[t++],Q=B>>6&1,me=1<<1+(7&B),ce=l,$=d,D=!1;B>>7&&(D=!0,ce=t,$=me,t+=3*me);var Y=t;for(t++;;){var N;if(!((N=e[t++])>=0))throw Error("Invalid block size");if(N===0)break;t+=N}f.push({x:P,y:_,width:q,height:T,has_local_palette:D,palette_offset:ce,palette_size:$,data_offset:Y,data_length:t-Y,transparent_index:b,interlaced:!!Q,delay:x,disposal:m});break;case 59:h=!1;break;default:throw new Error("Unknown gif block: 0x"+e[t-1].toString(16))}this.numFrames=function(){return f.length},this.loopCount=function(){return w},this.frameInfo=function(I){if(I<0||I>=f.length)throw new Error("Frame index out of range.");return f[I]},this.decodeAndBlitFrameBGRA=function(I,k){var L=this.frameInfo(I),H=L.width*L.height;if(H>536870912)throw new Error("Image dimensions exceed 512MB, which is too large.");var te=new Uint8Array(H);_f(e,L.data_offset,te,H);var se=L.palette_offset,K=L.transparent_index;K===null&&(K=256);var ae=L.width,be=n-ae,Ne=ae,A=4*(L.y*n+L.x),E=4*((L.y+L.height)*n+L.x),z=A,X=4*be;L.interlaced===!0&&(X+=4*n*7);for(var Z=8,le=0,fe=te.length;le<fe;++le){var ue=te[le];if(Ne===0&&(Ne=ae,(z+=X)>=E&&(X=4*be+4*n*(Z-1),z=A+(ae+be)*(Z<<1),Z>>=1)),ue===K)z+=4;else{var _e=e[se+3*ue],Ce=e[se+3*ue+1],ve=e[se+3*ue+2];k[z++]=ve,k[z++]=Ce,k[z++]=_e,k[z++]=255}--Ne}},this.decodeAndBlitFrameRGBA=function(I,k){var L=this.frameInfo(I),H=L.width*L.height;if(H>536870912)throw new Error("Image dimensions exceed 512MB, which is too large.");var te=new Uint8Array(H);_f(e,L.data_offset,te,H);var se=L.palette_offset,K=L.transparent_index;K===null&&(K=256);var ae=L.width,be=n-ae,Ne=ae,A=4*(L.y*n+L.x),E=4*((L.y+L.height)*n+L.x),z=A,X=4*be;L.interlaced===!0&&(X+=4*n*7);for(var Z=8,le=0,fe=te.length;le<fe;++le){var ue=te[le];if(Ne===0&&(Ne=ae,(z+=X)>=E&&(X=4*be+4*n*(Z-1),z=A+(ae+be)*(Z<<1),Z>>=1)),ue===K)z+=4;else{var _e=e[se+3*ue],Ce=e[se+3*ue+1],ve=e[se+3*ue+2];k[z++]=_e,k[z++]=Ce,k[z++]=ve,k[z++]=255}--Ne}}}function _f(e,t,n,r){for(var s=e[t++],i=1<<s,c=i+1,l=c+1,d=s+1,h=(1<<d)-1,f=0,x=0,b=0,m=e[t++],w=new Int32Array(4096),v=null;;){for(;f<16&&m!==0;)x|=e[t++]<<f,f+=8,m===1?m=e[t++]:--m;if(f<d)break;var P=x&h;if(x>>=d,f-=d,P!==i){if(P===c)break;for(var _=P<l?P:v,q=0,T=_;T>i;)T=w[T]>>8,++q;var B=T;if(b+q+(_!==P?1:0)>r)return void wn.log("Warning, gif stream longer than expected.");n[b++]=B;var Q=b+=q;for(_!==P&&(n[b++]=B),T=_;q--;)T=w[T],n[--Q]=255&T,T>>=8;v!==null&&l<4096&&(w[l++]=v<<8|B,l>=h+1&&d<12&&(++d,h=h<<1|1)),v=P}else l=c+1,h=(1<<(d=s+1))-1,v=null}return b!==r&&wn.log("Warning, gif stream shorter than expected."),n}/**
88 * @license
89  Copyright (c) 2008, Adobe Systems Incorporated
90  All rights reserved.
91
92  Redistribution and use in source and binary forms, with or without 
93  modification, are permitted provided that the following conditions are
94  met:
95
96  * Redistributions of source code must retain the above copyright notice, 
97    this list of conditions and the following disclaimer.
98  
99  * Redistributions in binary form must reproduce the above copyright
100    notice, this list of conditions and the following disclaimer in the 
101    documentation and/or other materials provided with the distribution.
102  
103  * Neither the name of Adobe Systems Incorporated nor the names of its 
104    contributors may be used to endorse or promote products derived from 
105    this software without specific prior written permission.
106
107  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
108  IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
109  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
110  PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 
111  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
112  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
113  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
114  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
115  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
116  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
117  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
118*/function Xc(e){var t,n,r,s,i,c=Math.floor,l=new Array(64),d=new Array(64),h=new Array(64),f=new Array(64),x=new Array(65535),b=new Array(65535),m=new Array(64),w=new Array(64),v=[],P=0,_=7,q=new Array(64),T=new Array(64),B=new Array(64),Q=new Array(256),me=new Array(2048),ce=[0,1,5,6,14,15,27,28,2,4,7,13,16,26,29,42,3,8,12,17,25,30,41,43,9,11,18,24,31,40,44,53,10,19,23,32,39,45,52,54,20,22,33,38,46,51,55,60,21,34,37,47,50,56,59,61,35,36,48,49,57,58,62,63],$=[0,0,1,5,1,1,1,1,1,1,0,0,0,0,0,0,0],D=[0,1,2,3,4,5,6,7,8,9,10,11],Y=[0,0,2,1,3,3,2,4,3,5,5,4,4,0,0,1,125],N=[1,2,3,0,4,17,5,18,33,49,65,6,19,81,97,7,34,113,20,50,129,145,161,8,35,66,177,193,21,82,209,240,36,51,98,114,130,9,10,22,23,24,25,26,37,38,39,40,41,42,52,53,54,55,56,57,58,67,68,69,70,71,72,73,74,83,84,85,86,87,88,89,90,99,100,101,102,103,104,105,106,115,116,117,118,119,120,121,122,131,132,133,134,135,136,137,138,146,147,148,149,150,151,152,153,154,162,163,164,165,166,167,168,169,170,178,179,180,181,182,183,184,185,186,194,195,196,197,198,199,200,201,202,210,211,212,213,214,215,216,217,218,225,226,227,228,229,230,231,232,233,234,241,242,243,244,245,246,247,248,249,250],I=[0,0,3,1,1,1,1,1,1,1,1,1,0,0,0,0,0],k=[0,1,2,3,4,5,6,7,8,9,10,11],L=[0,0,2,1,2,4,4,3,4,7,5,4,4,0,1,2,119],H=[0,1,2,3,17,4,5,33,49,6,18,65,81,7,97,113,19,34,50,129,8,20,66,145,161,177,193,9,35,51,82,240,21,98,114,209,10,22,36,52,225,37,241,23,24,25,26,38,39,40,41,42,53,54,55,56,57,58,67,68,69,70,71,72,73,74,83,84,85,86,87,88,89,90,99,100,101,102,103,104,105,106,115,116,117,118,119,120,121,122,130,131,132,133,134,135,136,137,138,146,147,148,149,150,151,152,153,154,162,163,164,165,166,167,168,169,170,178,179,180,181,182,183,184,185,186,194,195,196,197,198,199,200,201,202,210,211,212,213,214,215,216,217,218,226,227,228,229,230,231,232,233,234,242,243,244,245,246,247,248,249,250];function te(A,E){for(var z=0,X=0,Z=new Array,le=1;le<=16;le++){for(var fe=1;fe<=A[le];fe++)Z[E[X]]=[],Z[E[X]][0]=z,Z[E[X]][1]=le,X++,z++;z*=2}return Z}function se(A){for(var E=A[0],z=A[1]-1;z>=0;)E&1<<z&&(P|=1<<_),z--,--_<0&&(P==255?(K(255),K(0)):K(P),_=7,P=0)}function K(A){v.push(A)}function ae(A){K(A>>8&255),K(255&A)}function be(A,E,z,X,Z){for(var le,fe=Z[0],ue=Z[240],_e=function(de,Ue){var qe,$e,Ge,bt,et,Me,vt,St,Oe,_t,Xe=0;for(Oe=0;Oe<8;++Oe){qe=de[Xe],$e=de[Xe+1],Ge=de[Xe+2],bt=de[Xe+3],et=de[Xe+4],Me=de[Xe+5],vt=de[Xe+6];var Ht=qe+(St=de[Xe+7]),Lt=qe-St,At=$e+vt,kt=$e-vt,an=Ge+Me,it=Ge-Me,at=bt+et,Ve=bt-et,ft=Ht+at,wt=Ht-at,Nt=At+an,Qe=At-an;de[Xe]=ft+Nt,de[Xe+4]=ft-Nt;var Ze=.707106781*(Qe+wt);de[Xe+2]=wt+Ze,de[Xe+6]=wt-Ze;var Ae=.382683433*((ft=Ve+it)-(Qe=kt+Lt)),Re=.5411961*ft+Ae,Gt=1.306562965*Qe+Ae,yn=.707106781*(Nt=it+kt),lt=Lt+yn,hr=Lt-yn;de[Xe+5]=hr+Re,de[Xe+3]=hr-Re,de[Xe+1]=lt+Gt,de[Xe+7]=lt-Gt,Xe+=8}for(Xe=0,Oe=0;Oe<8;++Oe){qe=de[Xe],$e=de[Xe+8],Ge=de[Xe+16],bt=de[Xe+24],et=de[Xe+32],Me=de[Xe+40],vt=de[Xe+48];var sn=qe+(St=de[Xe+56]),br=qe-St,bn=$e+vt,Nn=$e-vt,Pn=Ge+Me,Fn=Ge-Me,Jr=bt+et,vr=bt-et,Un=sn+Jr,_r=sn-Jr,lr=bn+Pn,Xn=bn-Pn;de[Xe]=Un+lr,de[Xe+32]=Un-lr;var Zn=.707106781*(Xn+_r);de[Xe+16]=_r+Zn,de[Xe+48]=_r-Zn;var fr=.382683433*((Un=vr+Fn)-(Xn=Nn+br)),nr=.5411961*Un+fr,qr=1.306562965*Xn+fr,wr=.707106781*(lr=Fn+Nn),Sa=br+wr,qt=br-wr;de[Xe+40]=qt+nr,de[Xe+24]=qt-nr,de[Xe+8]=Sa+qr,de[Xe+56]=Sa-qr,Xe++}for(Oe=0;Oe<64;++Oe)_t=de[Oe]*Ue[Oe],m[Oe]=_t>0?_t+.5|0:_t-.5|0;return m}(A,E),Ce=0;Ce<64;++Ce)w[ce[Ce]]=_e[Ce];var ve=w[0]-z;z=w[0],ve==0?se(X[0]):(se(X[b[le=32767+ve]]),se(x[le]));for(var we=63;we>0&&w[we]==0;)we--;if(we==0)return se(fe),z;for(var De,R=1;R<=we;){for(var ze=R;w[R]==0&&R<=we;)++R;var ye=R-ze;if(ye>=16){De=ye>>4;for(var Ee=1;Ee<=De;++Ee)se(ue);ye&=15}le=32767+w[R],se(Z[(ye<<4)+b[le]]),se(x[le]),R++}return we!=63&&se(fe),z}function Ne(A){A=Math.min(Math.max(A,1),100),i!=A&&(function(E){for(var z=[16,11,10,16,24,40,51,61,12,12,14,19,26,58,60,55,14,13,16,24,40,57,69,56,14,17,22,29,51,87,80,62,18,22,37,56,68,109,103,77,24,35,55,64,81,104,113,92,49,64,78,87,103,121,120,101,72,92,95,98,112,100,103,99],X=0;X<64;X++){var Z=c((z[X]*E+50)/100);Z=Math.min(Math.max(Z,1),255),l[ce[X]]=Z}for(var le=[17,18,24,47,99,99,99,99,18,21,26,66,99,99,99,99,24,26,56,99,99,99,99,99,47,66,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99],fe=0;fe<64;fe++){var ue=c((le[fe]*E+50)/100);ue=Math.min(Math.max(ue,1),255),d[ce[fe]]=ue}for(var _e=[1,1.387039845,1.306562965,1.175875602,1,.785694958,.5411961,.275899379],Ce=0,ve=0;ve<8;ve++)for(var we=0;we<8;we++)h[Ce]=1/(l[ce[Ce]]*_e[ve]*_e[we]*8),f[Ce]=1/(d[ce[Ce]]*_e[ve]*_e[we]*8),Ce++}(A<50?Math.floor(5e3/A):Math.floor(200-2*A)),i=A)}this.encode=function(A,E){E&&Ne(E),v=new Array,P=0,_=7,ae(65496),ae(65504),ae(16),K(74),K(70),K(73),K(70),K(0),K(1),K(1),K(0),ae(1),ae(1),K(0),K(0),function(){ae(65499),ae(132),K(0);for(var $e=0;$e<64;$e++)K(l[$e]);K(1);for(var Ge=0;Ge<64;Ge++)K(d[Ge])}(),function($e,Ge){ae(65472),ae(17),K(8),ae(Ge),ae($e),K(3),K(1),K(17),K(0),K(2),K(17),K(1),K(3),K(17),K(1)}(A.width,A.height),function(){ae(65476),ae(418),K(0);for(var $e=0;$e<16;$e++)K($[$e+1]);for(var Ge=0;Ge<=11;Ge++)K(D[Ge]);K(16);for(var bt=0;bt<16;bt++)K(Y[bt+1]);for(var et=0;et<=161;et++)K(N[et]);K(1);for(var Me=0;Me<16;Me++)K(I[Me+1]);for(var vt=0;vt<=11;vt++)K(k[vt]);K(17);for(var St=0;St<16;St++)K(L[St+1]);for(var Oe=0;Oe<=161;Oe++)K(H[Oe])}(),ae(65498),ae(12),K(3),K(1),K(0),K(2),K(17),K(3),K(17),K(0),K(63),K(0);var z=0,X=0,Z=0;P=0,_=7,this.encode.displayName="_encode_";for(var le,fe,ue,_e,Ce,ve,we,De,R,ze=A.data,ye=A.width,Ee=A.height,de=4*ye,Ue=0;Ue<Ee;){for(le=0;le<de;){for(Ce=de*Ue+le,we=-1,De=0,R=0;R<64;R++)ve=Ce+(De=R>>3)*de+(we=4*(7&R)),Ue+De>=Ee&&(ve-=de*(Ue+1+De-Ee)),le+we>=de&&(ve-=le+we-de+4),fe=ze[ve++],ue=ze[ve++],_e=ze[ve++],q[R]=(me[fe]+me[ue+256|0]+me[_e+512|0]>>16)-128,T[R]=(me[fe+768|0]+me[ue+1024|0]+me[_e+1280|0]>>16)-128,B[R]=(me[fe+1280|0]+me[ue+1536|0]+me[_e+1792|0]>>16)-128;z=be(q,h,z,t,r),X=be(T,f,X,n,s),Z=be(B,f,Z,n,s),le+=32}Ue+=8}if(_>=0){var qe=[];qe[1]=_+1,qe[0]=(1<<_+1)-1,se(qe)}return ae(65497),new Uint8Array(v)},e=e||50,function(){for(var A=String.fromCharCode,E=0;E<256;E++)Q[E]=A(E)}(),t=te($,D),n=te(I,k),r=te(Y,N),s=te(L,H),function(){for(var A=1,E=2,z=1;z<=15;z++){for(var X=A;X<E;X++)b[32767+X]=z,x[32767+X]=[],x[32767+X][1]=z,x[32767+X][0]=X;for(var Z=-(E-1);Z<=-A;Z++)b[32767+Z]=z,x[32767+Z]=[],x[32767+Z][1]=z,x[32767+Z][0]=E-1+Z;A<<=1,E<<=1}}(),function(){for(var A=0;A<256;A++)me[A]=19595*A,me[A+256|0]=38470*A,me[A+512|0]=7471*A+32768,me[A+768|0]=-11059*A,me[A+1024|0]=-21709*A,me[A+1280|0]=32768*A+8421375,me[A+1536|0]=-27439*A,me[A+1792|0]=-5329*A}(),Ne(e)}/**
119 * @license
120 * Copyright (c) 2017 Aras Abbasi
121 *
122 * Licensed under the MIT License.
123 * http://opensource.org/licenses/mit-license
124 */function Fa(e,t){if(this.pos=0,this.buffer=e,this.datav=new DataView(e.buffer),this.is_with_alpha=!!t,this.bottom_up=!0,this.flag=String.fromCharCode(this.buffer[0])+String.fromCharCode(this.buffer[1]),this.pos+=2,["BM","BA","CI","CP","IC","PT"].indexOf(this.flag)===-1)throw new Error("Invalid BMP File");this.parseHeader(),this.parseBGR()}function wf(e){function t(D){if(!D)throw Error("assert :P")}function n(D,Y,N){for(var I=0;4>I;I++)if(D[Y+I]!=N.charCodeAt(I))return!0;return!1}function r(D,Y,N,I,k){for(var L=0;L<k;L++)D[Y+L]=N[I+L]}function s(D,Y,N,I){for(var k=0;k<I;k++)D[Y+k]=N}function i(D){return new Int32Array(D)}function c(D,Y){for(var N=[],I=0;I<D;I++)N.push(new Y);return N}function l(D,Y){var N=[];return function I(k,L,H){for(var te=H[L],se=0;se<te&&(k.push(H.length>L+1?[]:new Y),!(H.length<L+1));se++)I(k[se],L+1,H)}(N,0,D),N}var d=function(){var D=this;function Y(o,u){for(var g=1<<u-1>>>0;o&g;)g>>>=1;return g?(o&g-1)+g:o}function N(o,u,g,y,S){t(!(y%g));do o[u+(y-=g)]=S;while(0<y)}function I(o,u,g,y,S){if(t(2328>=S),512>=S)var C=i(512);else if((C=i(S))==null)return 0;return function(M,F,O,V,ne,ge){var W,re,he=F,Le=1<<O,pe=i(16),ke=i(16);for(t(ne!=0),t(V!=null),t(M!=null),t(0<O),re=0;re<ne;++re){if(15<V[re])return 0;++pe[V[re]]}if(pe[0]==ne)return 0;for(ke[1]=0,W=1;15>W;++W){if(pe[W]>1<<W)return 0;ke[W+1]=ke[W]+pe[W]}for(re=0;re<ne;++re)W=V[re],0<V[re]&&(ge[ke[W]++]=re);if(ke[15]==1)return(V=new k).g=0,V.value=ge[0],N(M,he,1,Le,V),Le;var Pe,Be=-1,Fe=Le-1,xt=0,ot=1,zt=1,pt=1<<O;for(re=0,W=1,ne=2;W<=O;++W,ne<<=1){if(ot+=zt<<=1,0>(zt-=pe[W]))return 0;for(;0<pe[W];--pe[W])(V=new k).g=W,V.value=ge[re++],N(M,he+xt,ne,pt,V),xt=Y(xt,W)}for(W=O+1,ne=2;15>=W;++W,ne<<=1){if(ot+=zt<<=1,0>(zt-=pe[W]))return 0;for(;0<pe[W];--pe[W]){if(V=new k,(xt&Fe)!=Be){for(he+=pt,Pe=1<<(Be=W)-O;15>Be&&!(0>=(Pe-=pe[Be]));)++Be,Pe<<=1;Le+=pt=1<<(Pe=Be-O),M[F+(Be=xt&Fe)].g=Pe+O,M[F+Be].value=he-F-Be}V.g=W-O,V.value=ge[re++],N(M,he+(xt>>O),ne,pt,V),xt=Y(xt,W)}}return ot!=2*ke[15]-1?0:Le}(o,u,g,y,S,C)}function k(){this.value=this.g=0}function L(){this.value=this.g=0}function H(){this.G=c(5,k),this.H=i(5),this.jc=this.Qb=this.qb=this.nd=0,this.pd=c(Ti,L)}function te(o,u,g,y){t(o!=null),t(u!=null),t(2147483648>y),o.Ca=254,o.I=0,o.b=-8,o.Ka=0,o.oa=u,o.pa=g,o.Jd=u,o.Yc=g+y,o.Zc=4<=y?g+y-4+1:g,fe(o)}function se(o,u){for(var g=0;0<u--;)g|=_e(o,128)<<u;return g}function K(o,u){var g=se(o,u);return ue(o)?-g:g}function ae(o,u,g,y){var S,C=0;for(t(o!=null),t(u!=null),t(4294967288>y),o.Sb=y,o.Ra=0,o.u=0,o.h=0,4<y&&(y=4),S=0;S<y;++S)C+=u[g+S]<<8*S;o.Ra=C,o.bb=y,o.oa=u,o.pa=g}function be(o){for(;8<=o.u&&o.bb<o.Sb;)o.Ra>>>=8,o.Ra+=o.oa[o.pa+o.bb]<<Dr-8>>>0,++o.bb,o.u-=8;X(o)&&(o.h=1,o.u=0)}function Ne(o,u){if(t(0<=u),!o.h&&u<=po){var g=z(o)&ri[u];return o.u+=u,be(o),g}return o.h=1,o.u=0}function A(){this.b=this.Ca=this.I=0,this.oa=[],this.pa=0,this.Jd=[],this.Yc=0,this.Zc=[],this.Ka=0}function E(){this.Ra=0,this.oa=[],this.h=this.u=this.bb=this.Sb=this.pa=0}function z(o){return o.Ra>>>(o.u&Dr-1)>>>0}function X(o){return t(o.bb<=o.Sb),o.h||o.bb==o.Sb&&o.u>Dr}function Z(o,u){o.u=u,o.h=X(o)}function le(o){o.u>=Vr&&(t(o.u>=Vr),be(o))}function fe(o){t(o!=null&&o.oa!=null),o.pa<o.Zc?(o.I=(o.oa[o.pa++]|o.I<<8)>>>0,o.b+=8):(t(o!=null&&o.oa!=null),o.pa<o.Yc?(o.b+=8,o.I=o.oa[o.pa++]|o.I<<8):o.Ka?o.b=0:(o.I<<=8,o.b+=8,o.Ka=1))}function ue(o){return se(o,1)}function _e(o,u){var g=o.Ca;0>o.b&&fe(o);var y=o.b,S=g*u>>>8,C=(o.I>>>y>S)+0;for(C?(g-=S,o.I-=S+1<<y>>>0):g=S+1,y=g,S=0;256<=y;)S+=8,y>>=8;return y=7^S+Di[y],o.b-=y,o.Ca=(g<<y)-1,C}function Ce(o,u,g){o[u+0]=g>>24&255,o[u+1]=g>>16&255,o[u+2]=g>>8&255,o[u+3]=255&g}function ve(o,u){return o[u+0]|o[u+1]<<8}function we(o,u){return ve(o,u)|o[u+2]<<16}function De(o,u){return ve(o,u)|ve(o,u+2)<<16}function R(o,u){var g=1<<u;return t(o!=null),t(0<u),o.X=i(g),o.X==null?0:(o.Mb=32-u,o.Xa=u,1)}function ze(o,u){t(o!=null),t(u!=null),t(o.Xa==u.Xa),r(u.X,0,o.X,0,1<<u.Xa)}function ye(){this.X=[],this.Xa=this.Mb=0}function Ee(o,u,g,y){t(g!=null),t(y!=null);var S=g[0],C=y[0];return S==0&&(S=(o*C+u/2)/u),C==0&&(C=(u*S+o/2)/o),0>=S||0>=C?0:(g[0]=S,y[0]=C,1)}function de(o,u){return o+(1<<u)-1>>>u}function Ue(o,u){return((4278255360&o)+(4278255360&u)>>>0&4278255360)+((16711935&o)+(16711935&u)>>>0&16711935)>>>0}function qe(o,u){D[u]=function(g,y,S,C,M,F,O){var V;for(V=0;V<M;++V){var ne=D[o](F[O+V-1],S,C+V);F[O+V]=Ue(g[y+V],ne)}}}function $e(){this.ud=this.hd=this.jd=0}function Ge(o,u){return((4278124286&(o^u))>>>1)+(o&u)>>>0}function bt(o){return 0<=o&&256>o?o:0>o?0:255<o?255:void 0}function et(o,u){return bt(o+(o-u+.5>>1))}function Me(o,u,g){return Math.abs(u-g)-Math.abs(o-g)}function vt(o,u,g,y,S,C,M){for(y=C[M-1],g=0;g<S;++g)C[M+g]=y=Ue(o[u+g],y)}function St(o,u,g,y,S){var C;for(C=0;C<g;++C){var M=o[u+C],F=M>>8&255,O=16711935&(O=(O=16711935&M)+((F<<16)+F));y[S+C]=(4278255360&M)+O>>>0}}function Oe(o,u){u.jd=255&o,u.hd=o>>8&255,u.ud=o>>16&255}function _t(o,u,g,y,S,C){var M;for(M=0;M<y;++M){var F=u[g+M],O=F>>>8,V=F,ne=255&(ne=(ne=F>>>16)+((o.jd<<24>>24)*(O<<24>>24)>>>5));V=255&(V=(V+=(o.hd<<24>>24)*(O<<24>>24)>>>5)+((o.ud<<24>>24)*(ne<<24>>24)>>>5)),S[C+M]=(4278255360&F)+(ne<<16)+V}}function Xe(o,u,g,y,S){D[u]=function(C,M,F,O,V,ne,ge,W,re){for(O=ge;O<W;++O)for(ge=0;ge<re;++ge)V[ne++]=S(F[y(C[M++])])},D[o]=function(C,M,F,O,V,ne,ge){var W=8>>C.b,re=C.Ea,he=C.K[0],Le=C.w;if(8>W)for(C=(1<<C.b)-1,Le=(1<<W)-1;M<F;++M){var pe,ke=0;for(pe=0;pe<re;++pe)pe&C||(ke=y(O[V++])),ne[ge++]=S(he[ke&Le]),ke>>=W}else D["VP8LMapColor"+g](O,V,he,Le,ne,ge,M,F,re)}}function Ht(o,u,g,y,S){for(g=u+g;u<g;){var C=o[u++];y[S++]=C>>16&255,y[S++]=C>>8&255,y[S++]=255&C}}function Lt(o,u,g,y,S){for(g=u+g;u<g;){var C=o[u++];y[S++]=C>>16&255,y[S++]=C>>8&255,y[S++]=255&C,y[S++]=C>>24&255}}function At(o,u,g,y,S){for(g=u+g;u<g;){var C=(M=o[u++])>>16&240|M>>12&15,M=240&M|M>>28&15;y[S++]=C,y[S++]=M}}function kt(o,u,g,y,S){for(g=u+g;u<g;){var C=(M=o[u++])>>16&248|M>>13&7,M=M>>5&224|M>>3&31;y[S++]=C,y[S++]=M}}function an(o,u,g,y,S){for(g=u+g;u<g;){var C=o[u++];y[S++]=255&C,y[S++]=C>>8&255,y[S++]=C>>16&255}}function it(o,u,g,y,S,C){if(C==0)for(g=u+g;u<g;)Ce(y,((C=o[u++])[0]>>24|C[1]>>8&65280|C[2]<<8&16711680|C[3]<<24)>>>0),S+=32;else r(y,S,o,u,g)}function at(o,u){D[u][0]=D[o+"0"],D[u][1]=D[o+"1"],D[u][2]=D[o+"2"],D[u][3]=D[o+"3"],D[u][4]=D[o+"4"],D[u][5]=D[o+"5"],D[u][6]=D[o+"6"],D[u][7]=D[o+"7"],D[u][8]=D[o+"8"],D[u][9]=D[o+"9"],D[u][10]=D[o+"10"],D[u][11]=D[o+"11"],D[u][12]=D[o+"12"],D[u][13]=D[o+"13"],D[u][14]=D[o+"0"],D[u][15]=D[o+"0"]}function Ve(o){return o==hc||o==fc||o==rl||o==mc}function ft(){this.eb=[],this.size=this.A=this.fb=0}function wt(){this.y=[],this.f=[],this.ea=[],this.F=[],this.Tc=this.Ed=this.Cd=this.Fd=this.lb=this.Db=this.Ab=this.fa=this.J=this.W=this.N=this.O=0}function Nt(){this.Rd=this.height=this.width=this.S=0,this.f={},this.f.RGBA=new ft,this.f.kb=new wt,this.sd=null}function Qe(){this.width=[0],this.height=[0],this.Pd=[0],this.Qd=[0],this.format=[0]}function Ze(){this.Id=this.fd=this.Md=this.hb=this.ib=this.da=this.bd=this.cd=this.j=this.v=this.Da=this.Sd=this.ob=0}function Ae(o){return alert("todo:WebPSamplerProcessPlane"),o.T}function Re(o,u){var g=o.T,y=u.ba.f.RGBA,S=y.eb,C=y.fb+o.ka*y.A,M=Na[u.ba.S],F=o.y,O=o.O,V=o.f,ne=o.N,ge=o.ea,W=o.W,re=u.cc,he=u.dc,Le=u.Mc,pe=u.Nc,ke=o.ka,Pe=o.ka+o.T,Be=o.U,Fe=Be+1>>1;for(ke==0?M(F,O,null,null,V,ne,ge,W,V,ne,ge,W,S,C,null,null,Be):(M(u.ec,u.fc,F,O,re,he,Le,pe,V,ne,ge,W,S,C-y.A,S,C,Be),++g);ke+2<Pe;ke+=2)re=V,he=ne,Le=ge,pe=W,ne+=o.Rc,W+=o.Rc,C+=2*y.A,M(F,(O+=2*o.fa)-o.fa,F,O,re,he,Le,pe,V,ne,ge,W,S,C-y.A,S,C,Be);return O+=o.fa,o.j+Pe<o.o?(r(u.ec,u.fc,F,O,Be),r(u.cc,u.dc,V,ne,Fe),r(u.Mc,u.Nc,ge,W,Fe),g--):1&Pe||M(F,O,null,null,V,ne,ge,W,V,ne,ge,W,S,C+y.A,null,null,Be),g}function Gt(o,u,g){var y=o.F,S=[o.J];if(y!=null){var C=o.U,M=u.ba.S,F=M==nl||M==rl;u=u.ba.f.RGBA;var O=[0],V=o.ka;O[0]=o.T,o.Kb&&(V==0?--O[0]:(--V,S[0]-=o.width),o.j+o.ka+o.T==o.o&&(O[0]=o.o-o.j-V));var ne=u.eb;V=u.fb+V*u.A,o=du(y,S[0],o.width,C,O,ne,V+(F?0:3),u.A),t(g==O),o&&Ve(M)&&bo(ne,V,F,C,O,u.A)}return 0}function yn(o){var u=o.ma,g=u.ba.S,y=11>g,S=g==el||g==tl||g==nl||g==uc||g==12||Ve(g);if(u.memory=null,u.Ib=null,u.Jb=null,u.Nd=null,!_a(u.Oa,o,S?11:12))return 0;if(S&&Ve(g)&&as(),o.da)alert("todo:use_scaling");else{if(y){if(u.Ib=Ae,o.Kb){if(g=o.U+1>>1,u.memory=i(o.U+2*g),u.memory==null)return 0;u.ec=u.memory,u.fc=0,u.cc=u.ec,u.dc=u.fc+o.U,u.Mc=u.cc,u.Nc=u.dc+g,u.Ib=Re,as()}}else alert("todo:EmitYUV");S&&(u.Jb=Gt,y&&Rn())}if(y&&!Lu){for(o=0;256>o;++o)gg[o]=89858*(o-128)+sl>>al,bg[o]=-22014*(o-128)+sl,yg[o]=-45773*(o-128),xg[o]=113618*(o-128)+sl>>al;for(o=_o;o<xc;++o)u=76283*(o-16)+sl>>al,vg[o-_o]=$r(u,255),_g[o-_o]=$r(u+8>>4,15);Lu=1}return 1}function lt(o){var u=o.ma,g=o.U,y=o.T;return t(!(1&o.ka)),0>=g||0>=y?0:(g=u.Ib(o,u),u.Jb!=null&&u.Jb(o,u,g),u.Dc+=g,1)}function hr(o){o.ma.memory=null}function sn(o,u,g,y){return Ne(o,8)!=47?0:(u[0]=Ne(o,14)+1,g[0]=Ne(o,14)+1,y[0]=Ne(o,1),Ne(o,3)!=0?0:!o.h)}function br(o,u){if(4>o)return o+1;var g=o-2>>1;return(2+(1&o)<<g)+Ne(u,g)+1}function bn(o,u){return 120<u?u-120:1<=(g=((g=ng[u-1])>>4)*o+(8-(15&g)))?g:1;var g}function Nn(o,u,g){var y=z(g),S=o[u+=255&y].g-8;return 0<S&&(Z(g,g.u+8),y=z(g),u+=o[u].value,u+=y&(1<<S)-1),Z(g,g.u+o[u].g),o[u].value}function Pn(o,u,g){return g.g+=o.g,g.value+=o.value<<u>>>0,t(8>=g.g),o.g}function Fn(o,u,g){var y=o.xc;return t((u=y==0?0:o.vc[o.md*(g>>y)+(u>>y)])<o.Wb),o.Ya[u]}function Jr(o,u,g,y){var S=o.ab,C=o.c*u,M=o.C;u=M+u;var F=g,O=y;for(y=o.Ta,g=o.Ua;0<S--;){var V=o.gc[S],ne=M,ge=u,W=F,re=O,he=(O=y,F=g,V.Ea);switch(t(ne<ge),t(ge<=V.nc),V.hc){case 2:Ri(W,re,(ge-ne)*he,O,F);break;case 0:var Le=ne,pe=ge,ke=O,Pe=F,Be=(pt=V).Ea;Le==0&&(js(W,re,null,null,1,ke,Pe),vt(W,re+1,0,0,Be-1,ke,Pe+1),re+=Be,Pe+=Be,++Le);for(var Fe=1<<pt.b,xt=Fe-1,ot=de(Be,pt.b),zt=pt.K,pt=pt.w+(Le>>pt.b)*ot;Le<pe;){var Yt=zt,sr=pt,$t=1;for(Ss(W,re,ke,Pe-Be,1,ke,Pe);$t<Be;){var gt=($t&~xt)+Fe;gt>Be&&(gt=Be),(0,Pa[Yt[sr++]>>8&15])(W,re+ +$t,ke,Pe+$t-Be,gt-$t,ke,Pe+$t),$t=gt}re+=Be,Pe+=Be,++Le&xt||(pt+=ot)}ge!=V.nc&&r(O,F-he,O,F+(ge-ne-1)*he,he);break;case 1:for(he=W,pe=re,Be=(W=V.Ea)-(Pe=W&~(ke=(re=1<<V.b)-1)),Le=de(W,V.b),Fe=V.K,V=V.w+(ne>>V.b)*Le;ne<ge;){for(xt=Fe,ot=V,zt=new $e,pt=pe+Pe,Yt=pe+W;pe<pt;)Oe(xt[ot++],zt),si(zt,he,pe,re,O,F),pe+=re,F+=re;pe<Yt&&(Oe(xt[ot++],zt),si(zt,he,pe,Be,O,F),pe+=Be,F+=Be),++ne&ke||(V+=Le)}break;case 3:if(W==O&&re==F&&0<V.b){for(pe=O,W=he=F+(ge-ne)*he-(Pe=(ge-ne)*de(V.Ea,V.b)),re=O,ke=F,Le=[],Pe=(Be=Pe)-1;0<=Pe;--Pe)Le[Pe]=re[ke+Pe];for(Pe=Be-1;0<=Pe;--Pe)pe[W+Pe]=Le[Pe];ai(V,ne,ge,O,he,O,F)}else ai(V,ne,ge,W,re,O,F)}F=y,O=g}O!=g&&r(y,g,F,O,C)}function vr(o,u){var g=o.V,y=o.Ba+o.c*o.C,S=u-o.C;if(t(u<=o.l.o),t(16>=S),0<S){var C=o.l,M=o.Ta,F=o.Ua,O=C.width;if(Jr(o,S,g,y),S=F=[F],t((g=o.C)<(y=u)),t(C.v<C.va),y>C.o&&(y=C.o),g<C.j){var V=C.j-g;g=C.j,S[0]+=V*O}if(g>=y?g=0:(S[0]+=4*C.v,C.ka=g-C.j,C.U=C.va-C.v,C.T=y-g,g=1),g){if(F=F[0],11>(g=o.ca).S){var ne=g.f.RGBA,ge=(y=g.S,S=C.U,C=C.T,V=ne.eb,ne.A),W=C;for(ne=ne.fb+o.Ma*ne.A;0<W--;){var re=M,he=F,Le=S,pe=V,ke=ne;switch(y){case Zo:go(re,he,Le,pe,ke);break;case el:xo(re,he,Le,pe,ke);break;case hc:xo(re,he,Le,pe,ke),bo(pe,ke,0,Le,1,0);break;case xu:oi(re,he,Le,pe,ke);break;case tl:it(re,he,Le,pe,ke,1);break;case fc:it(re,he,Le,pe,ke,1),bo(pe,ke,0,Le,1,0);break;case nl:it(re,he,Le,pe,ke,0);break;case rl:it(re,he,Le,pe,ke,0),bo(pe,ke,1,Le,1,0);break;case uc:Bi(re,he,Le,pe,ke);break;case mc:Bi(re,he,Le,pe,ke),cu(pe,ke,Le,1,0);break;case yu:ii(re,he,Le,pe,ke);break;default:t(0)}F+=O,ne+=ge}o.Ma+=C}else alert("todo:EmitRescaledRowsYUVA");t(o.Ma<=g.height)}}o.C=u,t(o.C<=o.i)}function Un(o){var u;if(0<o.ua)return 0;for(u=0;u<o.Wb;++u){var g=o.Ya[u].G,y=o.Ya[u].H;if(0<g[1][y[1]+0].g||0<g[2][y[2]+0].g||0<g[3][y[3]+0].g)return 0}return 1}function _r(o,u,g,y,S,C){if(o.Z!=0){var M=o.qd,F=o.rd;for(t(Cs[o.Z]!=null);u<g;++u)Cs[o.Z](M,F,y,S,y,S,C),M=y,F=S,S+=C;o.qd=M,o.rd=F}}function lr(o,u){var g=o.l.ma,y=g.Z==0||g.Z==1?o.l.j:o.C;if(y=o.C<y?y:o.C,t(u<=o.l.o),u>y){var S=o.l.width,C=g.ca,M=g.tb+S*y,F=o.V,O=o.Ba+o.c*y,V=o.gc;t(o.ab==1),t(V[0].hc==3),cc(V[0],y,u,F,O,C,M),_r(g,y,u,C,M,S)}o.C=o.Ma=u}function Xn(o,u,g,y,S,C,M){var F=o.$/y,O=o.$%y,V=o.m,ne=o.s,ge=g+o.$,W=ge;S=g+y*S;var re=g+y*C,he=280+ne.ua,Le=o.Pb?F:16777216,pe=0<ne.ua?ne.Wa:null,ke=ne.wc,Pe=ge<re?Fn(ne,O,F):null;t(o.C<C),t(re<=S);var Be=!1;e:for(;;){for(;Be||ge<re;){var Fe=0;if(F>=Le){var xt=ge-g;t((Le=o).Pb),Le.wd=Le.m,Le.xd=xt,0<Le.s.ua&&ze(Le.s.Wa,Le.s.vb),Le=F+ag}if(O&ke||(Pe=Fn(ne,O,F)),t(Pe!=null),Pe.Qb&&(u[ge]=Pe.qb,Be=!0),!Be)if(le(V),Pe.jc){Fe=V,xt=u;var ot=ge,zt=Pe.pd[z(Fe)&Ti-1];t(Pe.jc),256>zt.g?(Z(Fe,Fe.u+zt.g),xt[ot]=zt.value,Fe=0):(Z(Fe,Fe.u+zt.g-256),t(256<=zt.value),Fe=zt.value),Fe==0&&(Be=!0)}else Fe=Nn(Pe.G[0],Pe.H[0],V);if(V.h)break;if(Be||256>Fe){if(!Be)if(Pe.nd)u[ge]=(Pe.qb|Fe<<8)>>>0;else{if(le(V),Be=Nn(Pe.G[1],Pe.H[1],V),le(V),xt=Nn(Pe.G[2],Pe.H[2],V),ot=Nn(Pe.G[3],Pe.H[3],V),V.h)break;u[ge]=(ot<<24|Be<<16|Fe<<8|xt)>>>0}if(Be=!1,++ge,++O>=y&&(O=0,++F,M!=null&&F<=C&&!(F%16)&&M(o,F),pe!=null))for(;W<ge;)Fe=u[W++],pe.X[(506832829*Fe&4294967295)>>>pe.Mb]=Fe}else if(280>Fe){if(Fe=br(Fe-256,V),xt=Nn(Pe.G[4],Pe.H[4],V),le(V),xt=bn(y,xt=br(xt,V)),V.h)break;if(ge-g<xt||S-ge<Fe)break e;for(ot=0;ot<Fe;++ot)u[ge+ot]=u[ge+ot-xt];for(ge+=Fe,O+=Fe;O>=y;)O-=y,++F,M!=null&&F<=C&&!(F%16)&&M(o,F);if(t(ge<=S),O&ke&&(Pe=Fn(ne,O,F)),pe!=null)for(;W<ge;)Fe=u[W++],pe.X[(506832829*Fe&4294967295)>>>pe.Mb]=Fe}else{if(!(Fe<he))break e;for(Be=Fe-280,t(pe!=null);W<ge;)Fe=u[W++],pe.X[(506832829*Fe&4294967295)>>>pe.Mb]=Fe;Fe=ge,t(!(Be>>>(xt=pe).Xa)),u[Fe]=xt.X[Be],Be=!0}Be||t(V.h==X(V))}if(o.Pb&&V.h&&ge<S)t(o.m.h),o.a=5,o.m=o.wd,o.$=o.xd,0<o.s.ua&&ze(o.s.vb,o.s.Wa);else{if(V.h)break e;M!=null&&M(o,F>C?C:F),o.a=0,o.$=ge-g}return 1}return o.a=3,0}function Zn(o){t(o!=null),o.vc=null,o.yc=null,o.Ya=null;var u=o.Wa;u!=null&&(u.X=null),o.vb=null,t(o!=null)}function fr(){var o=new ht;return o==null?null:(o.a=0,o.xb=_u,at("Predictor","VP8LPredictors"),at("Predictor","VP8LPredictors_C"),at("PredictorAdd","VP8LPredictorsAdd"),at("PredictorAdd","VP8LPredictorsAdd_C"),Ri=St,si=_t,go=Ht,xo=Lt,Bi=At,ii=kt,oi=an,D.VP8LMapColor32b=tr,D.VP8LMapColor8b=Ha,o)}function nr(o,u,g,y,S){var C=1,M=[o],F=[u],O=y.m,V=y.s,ne=null,ge=0;e:for(;;){if(g)for(;C&&Ne(O,1);){var W=M,re=F,he=y,Le=1,pe=he.m,ke=he.gc[he.ab],Pe=Ne(pe,2);if(he.Oc&1<<Pe)C=0;else{switch(he.Oc|=1<<Pe,ke.hc=Pe,ke.Ea=W[0],ke.nc=re[0],ke.K=[null],++he.ab,t(4>=he.ab),Pe){case 0:case 1:ke.b=Ne(pe,3)+2,Le=nr(de(ke.Ea,ke.b),de(ke.nc,ke.b),0,he,ke.K),ke.K=ke.K[0];break;case 3:var Be,Fe=Ne(pe,8)+1,xt=16<Fe?0:4<Fe?1:2<Fe?2:3;if(W[0]=de(ke.Ea,xt),ke.b=xt,Be=Le=nr(Fe,1,0,he,ke.K)){var ot,zt=Fe,pt=ke,Yt=1<<(8>>pt.b),sr=i(Yt);if(sr==null)Be=0;else{var $t=pt.K[0],gt=pt.w;for(sr[0]=pt.K[0][0],ot=1;ot<1*zt;++ot)sr[ot]=Ue($t[gt+ot],sr[ot-1]);for(;ot<4*Yt;++ot)sr[ot]=0;pt.K[0]=null,pt.K[0]=sr,Be=1}}Le=Be;break;case 2:break;default:t(0)}C=Le}}if(M=M[0],F=F[0],C&&Ne(O,1)&&!(C=1<=(ge=Ne(O,4))&&11>=ge)){y.a=3;break e}var We;if(We=C)t:{var Gn,Ot,Xt,kn=y,gr=M,Rr=F,qn=ge,Lr=g,Br=kn.m,ir=kn.s,nn=[null],hn=1,zn=0,fn=rg[qn];n:for(;;){if(Lr&&Ne(Br,1)){var xr=Ne(Br,3)+2,Ma=de(gr,xr),Yn=de(Rr,xr),Wr=Ma*Yn;if(!nr(Ma,Yn,0,kn,nn))break n;for(nn=nn[0],ir.xc=xr,Gn=0;Gn<Wr;++Gn){var _n=nn[Gn]>>8&65535;nn[Gn]=_n,_n>=hn&&(hn=_n+1)}}if(Br.h)break n;for(Ot=0;5>Ot;++Ot){var or=bu[Ot];!Ot&&0<qn&&(or+=1<<qn),zn<or&&(zn=or)}var aa=c(hn*fn,k),Or=hn,sa=c(Or,H);if(sa==null)var ia=null;else t(65536>=Or),ia=sa;var Gr=i(zn);if(ia==null||Gr==null||aa==null){kn.a=1;break n}var oa=aa;for(Gn=Xt=0;Gn<hn;++Gn){var Ln=ia[Gn],la=Ln.G,Ia=Ln.H,li=0,ls=1,yr=0;for(Ot=0;5>Ot;++Ot){or=bu[Ot],la[Ot]=oa,Ia[Ot]=Xt,!Ot&&0<qn&&(or+=1<<qn);a:{var ol,yc=or,ll=kn,wo=Gr,jg=oa,Sg=Xt,bc=0,Ps=ll.m,Lg=Ne(Ps,1);if(s(wo,0,0,yc),Lg){var Ag=Ne(Ps,1)+1,kg=Ne(Ps,1),Cu=Ne(Ps,kg==0?1:8);wo[Cu]=1,Ag==2&&(wo[Cu=Ne(Ps,8)]=1);var cl=1}else{var Pu=i(19),Eu=Ne(Ps,4)+4;if(19<Eu){ll.a=3;var dl=0;break a}for(ol=0;ol<Eu;++ol)Pu[tg[ol]]=Ne(Ps,3);var vc=void 0,No=void 0,Mu=ll,Cg=Pu,ul=yc,Iu=wo,_c=0,Es=Mu.m,Fu=8,Tu=c(128,k);r:for(;I(Tu,0,7,Cg,19);){if(Ne(Es,1)){var Pg=2+2*Ne(Es,3);if((vc=2+Ne(Es,Pg))>ul)break r}else vc=ul;for(No=0;No<ul&&vc--;){le(Es);var Du=Tu[0+(127&z(Es))];Z(Es,Es.u+Du.g);var zi=Du.value;if(16>zi)Iu[No++]=zi,zi!=0&&(Fu=zi);else{var Eg=zi==16,Ru=zi-16,Mg=Zp[Ru],Bu=Ne(Es,Xp[Ru])+Mg;if(No+Bu>ul)break r;for(var Ig=Eg?Fu:0;0<Bu--;)Iu[No++]=Ig}}_c=1;break r}_c||(Mu.a=3),cl=_c}(cl=cl&&!Ps.h)&&(bc=I(jg,Sg,8,wo,yc)),cl&&bc!=0?dl=bc:(ll.a=3,dl=0)}if(dl==0)break n;if(ls&&eg[Ot]==1&&(ls=oa[Xt].g==0),li+=oa[Xt].g,Xt+=dl,3>=Ot){var jo,wc=Gr[0];for(jo=1;jo<or;++jo)Gr[jo]>wc&&(wc=Gr[jo]);yr+=wc}}if(Ln.nd=ls,Ln.Qb=0,ls&&(Ln.qb=(la[3][Ia[3]+0].value<<24|la[1][Ia[1]+0].value<<16|la[2][Ia[2]+0].value)>>>0,li==0&&256>la[0][Ia[0]+0].value&&(Ln.Qb=1,Ln.qb+=la[0][Ia[0]+0].value<<8)),Ln.jc=!Ln.Qb&&6>yr,Ln.jc){var hl,cs=Ln;for(hl=0;hl<Ti;++hl){var Ms=hl,Is=cs.pd[Ms],fl=cs.G[0][cs.H[0]+Ms];256<=fl.value?(Is.g=fl.g+256,Is.value=fl.value):(Is.g=0,Is.value=0,Ms>>=Pn(fl,8,Is),Ms>>=Pn(cs.G[1][cs.H[1]+Ms],16,Is),Ms>>=Pn(cs.G[2][cs.H[2]+Ms],0,Is),Pn(cs.G[3][cs.H[3]+Ms],24,Is))}}}ir.vc=nn,ir.Wb=hn,ir.Ya=ia,ir.yc=aa,We=1;break t}We=0}if(!(C=We)){y.a=3;break e}if(0<ge){if(V.ua=1<<ge,!R(V.Wa,ge)){y.a=1,C=0;break e}}else V.ua=0;var Nc=y,Ou=M,Fg=F,jc=Nc.s,Sc=jc.xc;if(Nc.c=Ou,Nc.i=Fg,jc.md=de(Ou,Sc),jc.wc=Sc==0?-1:(1<<Sc)-1,g){y.xb=ug;break e}if((ne=i(M*F))==null){y.a=1,C=0;break e}C=(C=Xn(y,ne,0,M,F,F,null))&&!O.h;break e}return C?(S!=null?S[0]=ne:(t(ne==null),t(g)),y.$=0,g||Zn(V)):Zn(V),C}function qr(o,u){var g=o.c*o.i,y=g+u+16*u;return t(o.c<=u),o.V=i(y),o.V==null?(o.Ta=null,o.Ua=0,o.a=1,0):(o.Ta=o.V,o.Ua=o.Ba+g+u,1)}function wr(o,u){var g=o.C,y=u-g,S=o.V,C=o.Ba+o.c*g;for(t(u<=o.l.o);0<y;){var M=16<y?16:y,F=o.l.ma,O=o.l.width,V=O*M,ne=F.ca,ge=F.tb+O*g,W=o.Ta,re=o.Ua;Jr(o,M,S,C),uu(W,re,ne,ge,V),_r(F,g,g+M,ne,ge,O),y-=M,S+=M*o.c,g+=M}t(g==u),o.C=o.Ma=u}function Sa(){this.ub=this.yd=this.td=this.Rb=0}function qt(){this.Kd=this.Ld=this.Ud=this.Td=this.i=this.c=0}function zr(){this.Fb=this.Bb=this.Cb=0,this.Zb=i(4),this.Lb=i(4)}function ma(){this.Yb=function(){var o=[];return function u(g,y,S){for(var C=S[y],M=0;M<C&&(g.push(S.length>y+1?[]:0),!(S.length<y+1));M++)u(g[M],y+1,S)}(o,0,[3,11]),o}()}function Ct(){this.jb=i(3),this.Wc=l([4,8],ma),this.Xc=l([4,17],ma)}function ts(){this.Pc=this.wb=this.Tb=this.zd=0,this.vd=new i(4),this.od=new i(4)}function cn(){this.ld=this.La=this.dd=this.tc=0}function pa(){this.Na=this.la=0}function ga(){this.Sc=[0,0],this.Eb=[0,0],this.Qc=[0,0],this.ia=this.lc=0}function cr(){this.ad=i(384),this.Za=0,this.Ob=i(16),this.$b=this.Ad=this.ia=this.Gc=this.Hc=this.Dd=0}function Xr(){this.uc=this.M=this.Nb=0,this.wa=Array(new cn),this.Y=0,this.ya=Array(new cr),this.aa=0,this.l=new Ba}function La(){this.y=i(16),this.f=i(8),this.ea=i(8)}function xa(){this.cb=this.a=0,this.sc="",this.m=new A,this.Od=new Sa,this.Kc=new qt,this.ed=new ts,this.Qa=new zr,this.Ic=this.$c=this.Aa=0,this.D=new Xr,this.Xb=this.Va=this.Hb=this.zb=this.yb=this.Ub=this.za=0,this.Jc=c(8,A),this.ia=0,this.pb=c(4,ga),this.Pa=new Ct,this.Bd=this.kc=0,this.Ac=[],this.Bc=0,this.zc=[0,0,0,0],this.Gd=Array(new La),this.Hd=0,this.rb=Array(new pa),this.sb=0,this.wa=Array(new cn),this.Y=0,this.oc=[],this.pc=0,this.sa=[],this.ta=0,this.qa=[],this.ra=0,this.Ha=[],this.B=this.R=this.Ia=0,this.Ec=[],this.M=this.ja=this.Vb=this.Fc=0,this.ya=Array(new cr),this.L=this.aa=0,this.gd=l([4,2],cn),this.ga=null,this.Fa=[],this.Cc=this.qc=this.P=0,this.Gb=[],this.Uc=0,this.mb=[],this.nb=0,this.rc=[],this.Ga=this.Vc=0}function $r(o,u){return 0>o?0:o>u?u:o}function Ba(){this.T=this.U=this.ka=this.height=this.width=0,this.y=[],this.f=[],this.ea=[],this.Rc=this.fa=this.W=this.N=this.O=0,this.ma="void",this.put="VP8IoPutHook",this.ac="VP8IoSetupHook",this.bc="VP8IoTeardownHook",this.ha=this.Kb=0,this.data=[],this.hb=this.ib=this.da=this.o=this.j=this.va=this.v=this.Da=this.ob=this.w=0,this.F=[],this.J=0}function bs(){var o=new xa;return o!=null&&(o.a=0,o.sc="OK",o.cb=0,o.Xb=0,vo||(vo=Oa)),o}function Qt(o,u,g){return o.a==0&&(o.a=u,o.sc=g,o.cb=0),0}function vs(o,u,g){return 3<=g&&o[u+0]==157&&o[u+1]==1&&o[u+2]==42}function rr(o,u){if(o==null)return 0;if(o.a=0,o.sc="OK",u==null)return Qt(o,2,"null VP8Io passed to VP8GetHeaders()");var g=u.data,y=u.w,S=u.ha;if(4>S)return Qt(o,7,"Truncated header.");var C=g[y+0]|g[y+1]<<8|g[y+2]<<16,M=o.Od;if(M.Rb=!(1&C),M.td=C>>1&7,M.yd=C>>4&1,M.ub=C>>5,3<M.td)return Qt(o,3,"Incorrect keyframe parameters.");if(!M.yd)return Qt(o,4,"Frame not displayable.");y+=3,S-=3;var F=o.Kc;if(M.Rb){if(7>S)return Qt(o,7,"cannot parse picture header");if(!vs(g,y,S))return Qt(o,3,"Bad code word");F.c=16383&(g[y+4]<<8|g[y+3]),F.Td=g[y+4]>>6,F.i=16383&(g[y+6]<<8|g[y+5]),F.Ud=g[y+6]>>6,y+=7,S-=7,o.za=F.c+15>>4,o.Ub=F.i+15>>4,u.width=F.c,u.height=F.i,u.Da=0,u.j=0,u.v=0,u.va=u.width,u.o=u.height,u.da=0,u.ib=u.width,u.hb=u.height,u.U=u.width,u.T=u.height,s((C=o.Pa).jb,0,255,C.jb.length),t((C=o.Qa)!=null),C.Cb=0,C.Bb=0,C.Fb=1,s(C.Zb,0,0,C.Zb.length),s(C.Lb,0,0,C.Lb)}if(M.ub>S)return Qt(o,7,"bad partition length");te(C=o.m,g,y,M.ub),y+=M.ub,S-=M.ub,M.Rb&&(F.Ld=ue(C),F.Kd=ue(C)),F=o.Qa;var O,V=o.Pa;if(t(C!=null),t(F!=null),F.Cb=ue(C),F.Cb){if(F.Bb=ue(C),ue(C)){for(F.Fb=ue(C),O=0;4>O;++O)F.Zb[O]=ue(C)?K(C,7):0;for(O=0;4>O;++O)F.Lb[O]=ue(C)?K(C,6):0}if(F.Bb)for(O=0;3>O;++O)V.jb[O]=ue(C)?se(C,8):255}else F.Bb=0;if(C.Ka)return Qt(o,3,"cannot parse segment header");if((F=o.ed).zd=ue(C),F.Tb=se(C,6),F.wb=se(C,3),F.Pc=ue(C),F.Pc&&ue(C)){for(V=0;4>V;++V)ue(C)&&(F.vd[V]=K(C,6));for(V=0;4>V;++V)ue(C)&&(F.od[V]=K(C,6))}if(o.L=F.Tb==0?0:F.zd?1:2,C.Ka)return Qt(o,3,"cannot parse filter header");var ne=S;if(S=O=y,y=O+ne,F=ne,o.Xb=(1<<se(o.m,2))-1,ne<3*(V=o.Xb))g=7;else{for(O+=3*V,F-=3*V,ne=0;ne<V;++ne){var ge=g[S+0]|g[S+1]<<8|g[S+2]<<16;ge>F&&(ge=F),te(o.Jc[+ne],g,O,ge),O+=ge,F-=ge,S+=3}te(o.Jc[+V],g,O,F),g=O<y?0:5}if(g!=0)return Qt(o,g,"cannot parse partitions");for(g=se(O=o.m,7),S=ue(O)?K(O,4):0,y=ue(O)?K(O,4):0,F=ue(O)?K(O,4):0,V=ue(O)?K(O,4):0,O=ue(O)?K(O,4):0,ne=o.Qa,ge=0;4>ge;++ge){if(ne.Cb){var W=ne.Zb[ge];ne.Fb||(W+=g)}else{if(0<ge){o.pb[ge]=o.pb[0];continue}W=g}var re=o.pb[ge];re.Sc[0]=pc[$r(W+S,127)],re.Sc[1]=gc[$r(W+0,127)],re.Eb[0]=2*pc[$r(W+y,127)],re.Eb[1]=101581*gc[$r(W+F,127)]>>16,8>re.Eb[1]&&(re.Eb[1]=8),re.Qc[0]=pc[$r(W+V,117)],re.Qc[1]=gc[$r(W+O,127)],re.lc=W+O}if(!M.Rb)return Qt(o,4,"Not a key frame.");for(ue(C),M=o.Pa,g=0;4>g;++g){for(S=0;8>S;++S)for(y=0;3>y;++y)for(F=0;11>F;++F)V=_e(C,cg[g][S][y][F])?se(C,8):og[g][S][y][F],M.Wc[g][S].Yb[y][F]=V;for(S=0;17>S;++S)M.Xc[g][S]=M.Wc[g][dg[S]]}return o.kc=ue(C),o.kc&&(o.Bd=se(C,8)),o.cb=1}function Oa(o,u,g,y,S,C,M){var F=u[S].Yb[g];for(g=0;16>S;++S){if(!_e(o,F[g+0]))return S;for(;!_e(o,F[g+1]);)if(F=u[++S].Yb[0],g=0,S==16)return 16;var O=u[S+1].Yb;if(_e(o,F[g+2])){var V=o,ne=0;if(_e(V,(W=F)[(ge=g)+3]))if(_e(V,W[ge+6])){for(F=0,ge=2*(ne=_e(V,W[ge+8]))+(W=_e(V,W[ge+9+ne])),ne=0,W=sg[ge];W[F];++F)ne+=ne+_e(V,W[F]);ne+=3+(8<<ge)}else _e(V,W[ge+7])?(ne=7+2*_e(V,165),ne+=_e(V,145)):ne=5+_e(V,159);else ne=_e(V,W[ge+4])?3+_e(V,W[ge+5]):2;F=O[2]}else ne=1,F=O[1];O=M+ig[S],0>(V=o).b&&fe(V);var ge,W=V.b,re=(ge=V.Ca>>1)-(V.I>>W)>>31;--V.b,V.Ca+=re,V.Ca|=1,V.I-=(ge+1&re)<<W,C[O]=((ne^re)-re)*y[(0<S)+0]}return 16}function Hr(o){var u=o.rb[o.sb-1];u.la=0,u.Na=0,s(o.zc,0,0,o.zc.length),o.ja=0}function Bn(o,u,g,y,S){S=o[u+g+32*y]+(S>>3),o[u+g+32*y]=-256&S?0>S?0:255:S}function ya(o,u,g,y,S,C){Bn(o,u,0,g,y+S),Bn(o,u,1,g,y+C),Bn(o,u,2,g,y-C),Bn(o,u,3,g,y-S)}function ie(o){return(20091*o>>16)+o}function xe(o,u,g,y){var S,C=0,M=i(16);for(S=0;4>S;++S){var F=o[u+0]+o[u+8],O=o[u+0]-o[u+8],V=(35468*o[u+4]>>16)-ie(o[u+12]),ne=ie(o[u+4])+(35468*o[u+12]>>16);M[C+0]=F+ne,M[C+1]=O+V,M[C+2]=O-V,M[C+3]=F-ne,C+=4,u++}for(S=C=0;4>S;++S)F=(o=M[C+0]+4)+M[C+8],O=o-M[C+8],V=(35468*M[C+4]>>16)-ie(M[C+12]),Bn(g,y,0,0,F+(ne=ie(M[C+4])+(35468*M[C+12]>>16))),Bn(g,y,1,0,O+V),Bn(g,y,2,0,O-V),Bn(g,y,3,0,F-ne),C++,y+=32}function He(o,u,g,y){var S=o[u+0]+4,C=35468*o[u+4]>>16,M=ie(o[u+4]),F=35468*o[u+1]>>16;ya(g,y,0,S+M,o=ie(o[u+1]),F),ya(g,y,1,S+C,o,F),ya(g,y,2,S-C,o,F),ya(g,y,3,S-M,o,F)}function rt(o,u,g,y,S){xe(o,u,g,y),S&&xe(o,u+16,g,y+4)}
vendor: 2,245 bytes, line 124
124function mt(o,u,g,y){ss(o,u+0,g,y,1),ss(o,u+32,g,y+128,1)}function Ft(o,u,g,y){var S;for(o=o[u+0]+4,S=0;4>S;++S)for(u=0;4>u;++u)Bn(g,y,u,S,o)}function tt(o,u,g,y){o[u+0]&&Sr(o,u+0,g,y),o[u+16]&&Sr(o,u+16,g,y+4),o[u+32]&&Sr(o,u+32,g,y+128),o[u+48]&&Sr(o,u+48,g,y+128+4)}function Vn(o,u,g,y){var S,C=i(16);for(S=0;4>S;++S){var M=o[u+0+S]+o[u+12+S],F=o[u+4+S]+o[u+8+S],O=o[u+4+S]-o[u+8+S],V=o[u+0+S]-o[u+12+S];C[0+S]=M+F,C[8+S]=M-F,C[4+S]=V+O,C[12+S]=V-O}for(S=0;4>S;++S)M=(o=C[0+4*S]+3)+C[3+4*S],F=C[1+4*S]+C[2+4*S],O=C[1+4*S]-C[2+4*S],V=o-C[3+4*S],g[y+0]=M+F>>3,g[y+16]=V+O>>3,g[y+32]=M-F>>3,g[y+48]=V-O>>3,y+=64}function En(o,u,g){var y,S=u-32,C=ra,M=255-o[S-1];for(y=0;y<g;++y){var F,O=C,V=M+o[u-1];for(F=0;F<g;++F)o[u+F]=O[V+o[S+F]];u+=32}}function Zt(o,u){En(o,u,4)}function en(o,u){En(o,u,8)}function Zr(o,u){En(o,u,16)}function Tn(o,u){var g;for(g=0;16>g;++g)r(o,u+32*g,o,u-32,16)}function G(o,u){var g;for(g=16;0<g;--g)s(o,u,o[u-1],16),u+=32}function je(o,u,g){var y;for(y=0;16>y;++y)s(u,g+32*y,o,16)}function ct(o,u){var g,y=16;for(g=0;16>g;++g)y+=o[u-1+32*g]+o[u+g-32];je(y>>5,o,u)}function Ye(o,u){var g,y=8;for(g=0;16>g;++g)y+=o[u-1+32*g];je(y>>4,o,u)}function jt(o,u){var g,y=8;for(g=0;16>g;++g)y+=o[u+g-32];je(y>>4,o,u)}function Pt(o,u){je(128,o,u)}function Te(o,u,g){return o+2*u+g+2>>2}function un(o,u){var g,y=u-32;for(y=new Uint8Array([Te(o[y-1],o[y+0],o[y+1]),Te(o[y+0],o[y+1],o[y+2]),Te(o[y+1],o[y+2],o[y+3]),Te(o[y+2],o[y+3],o[y+4])]),g=0;4>g;++g)r(o,u+32*g,y,0,y.length)}function On(o,u){var g=o[u-1],y=o[u-1+32],S=o[u-1+64],C=o[u-1+96];Ce(o,u+0,16843009*Te(o[u-1-32],g,y)),Ce(o,u+32,16843009*Te(g,y,S)),Ce(o,u+64,16843009*Te(y,S,C)),Ce(o,u+96,16843009*Te(S,C,C))}function Fr(o,u){var g,y=4;for(g=0;4>g;++g)y+=o[u+g-32]+o[u-1+32*g];for(y>>=3,g=0;4>g;++g)s(o,u+32*g,y,4)}function ea(o,u){var g=o[u-1+0],y=o[u-1+32],S=o[u-1+64],C=o[u-1-32],M=o[u+0-32],F=o[u+1-32],O=o[u+2-32],V=o[u+3-32];o[u+0+96]=Te(y,S,o[u-1+96]),o[u+1+96]=o[u+0+64]=Te(g,y,S),o[u+2+96]=o[u+1+64]=o[u+0+32]=Te(C,g,y),o[u+3+96]=o[u+2+64]=o[u+1+32]=o[u+0+0]=Te(M,C,g),o[u+3+64]=o[u+2+32]=o[u+1+0]=Te(F,M,C),o[u+3+32]=o[u+2+0]=Te(O,F,M),o[u+3+0]=Te(V,O,F)}function ba(o,u){var g=o[u+1-32],y=o[u+2-32],S=o[u+3-32],C=o[u+4-32],M=o[u+5-32],F=o[u+6-32],O=o[u+7-32];
vendor: 16,774 bytes, line 124
124o[u+0+0]=Te(o[u+0-32],g,y),o[u+1+0]=o[u+0+32]=Te(g,y,S),o[u+2+0]=o[u+1+32]=o[u+0+64]=Te(y,S,C),o[u+3+0]=o[u+2+32]=o[u+1+64]=o[u+0+96]=Te(S,C,M),o[u+3+32]=o[u+2+64]=o[u+1+96]=Te(C,M,F),o[u+3+64]=o[u+2+96]=Te(M,F,O),o[u+3+96]=Te(F,O,O)}function Rt(o,u){var g=o[u-1+0],y=o[u-1+32],S=o[u-1+64],C=o[u-1-32],M=o[u+0-32],F=o[u+1-32],O=o[u+2-32],V=o[u+3-32];o[u+0+0]=o[u+1+64]=C+M+1>>1,o[u+1+0]=o[u+2+64]=M+F+1>>1,o[u+2+0]=o[u+3+64]=F+O+1>>1,o[u+3+0]=O+V+1>>1,o[u+0+96]=Te(S,y,g),o[u+0+64]=Te(y,g,C),o[u+0+32]=o[u+1+96]=Te(g,C,M),o[u+1+32]=o[u+2+96]=Te(C,M,F),o[u+2+32]=o[u+3+96]=Te(M,F,O),o[u+3+32]=Te(F,O,V)}function mr(o,u){var g=o[u+0-32],y=o[u+1-32],S=o[u+2-32],C=o[u+3-32],M=o[u+4-32],F=o[u+5-32],O=o[u+6-32],V=o[u+7-32];o[u+0+0]=g+y+1>>1,o[u+1+0]=o[u+0+64]=y+S+1>>1,o[u+2+0]=o[u+1+64]=S+C+1>>1,o[u+3+0]=o[u+2+64]=C+M+1>>1,o[u+0+32]=Te(g,y,S),o[u+1+32]=o[u+0+96]=Te(y,S,C),o[u+2+32]=o[u+1+96]=Te(S,C,M),o[u+3+32]=o[u+2+96]=Te(C,M,F),o[u+3+64]=Te(M,F,O),o[u+3+96]=Te(F,O,V)}function Aa(o,u){var g=o[u-1+0],y=o[u-1+32],S=o[u-1+64],C=o[u-1+96];o[u+0+0]=g+y+1>>1,o[u+2+0]=o[u+0+32]=y+S+1>>1,o[u+2+32]=o[u+0+64]=S+C+1>>1,o[u+1+0]=Te(g,y,S),o[u+3+0]=o[u+1+32]=Te(y,S,C),o[u+3+32]=o[u+1+64]=Te(S,C,C),o[u+3+64]=o[u+2+64]=o[u+0+96]=o[u+1+96]=o[u+2+96]=o[u+3+96]=C}function Ks(o,u){var g=o[u-1+0],y=o[u-1+32],S=o[u-1+64],C=o[u-1+96],M=o[u-1-32],F=o[u+0-32],O=o[u+1-32],V=o[u+2-32];o[u+0+0]=o[u+2+32]=g+M+1>>1,o[u+0+32]=o[u+2+64]=y+g+1>>1,o[u+0+64]=o[u+2+96]=S+y+1>>1,o[u+0+96]=C+S+1>>1,o[u+3+0]=Te(F,O,V),o[u+2+0]=Te(M,F,O),o[u+1+0]=o[u+3+32]=Te(g,M,F),o[u+1+32]=o[u+3+64]=Te(y,g,M),o[u+1+64]=o[u+3+96]=Te(S,y,g),o[u+1+96]=Te(C,S,y)}function qa(o,u){var g;for(g=0;8>g;++g)r(o,u+32*g,o,u-32,8)}function ta(o,u){var g;for(g=0;8>g;++g)s(o,u,o[u-1],8),u+=32}function tn(o,u,g){var y;for(y=0;8>y;++y)s(u,g+32*y,o,8)}function pr(o,u){var g,y=8;for(g=0;8>g;++g)y+=o[u+g-32]+o[u-1+32*g];tn(y>>4,o,u)}function ns(o,u){var g,y=4;for(g=0;8>g;++g)y+=o[u+g-32];tn(y>>3,o,u)}function Ai(o,u){var g,y=4;for(g=0;8>g;++g)y+=o[u-1+32*g];tn(y>>3,o,u)}function Qs(o,u){tn(128,o,u)}function ka(o,u,g){var y=o[u-g],S=o[u+0],C=3*(S-y)+dc[1020+o[u-2*g]-o[u+g]],M=Xo[112+(C+4>>3)];o[u-g]=ra[255+y+Xo[112+(C+3>>3)]],o[u+0]=ra[255+S-M]}function va(o,u,g,y){var S=o[u+0],C=o[u+g];return wa[255+o[u-2*g]-o[u-g]]>y||wa[255+C-S]>y}function Ca(o,u,g,y){return 4*wa[255+o[u-g]-o[u+0]]+wa[255+o[u-2*g]-o[u+g]]<=y}function rs(o,u,g,y,S){var C=o[u-3*g],M=o[u-2*g],F=o[u-g],O=o[u+0],V=o[u+g],ne=o[u+2*g],ge=o[u+3*g];return 4*wa[255+F-O]+wa[255+M-V]>y?0:wa[255+o[u-4*g]-C]<=S&&wa[255+C-M]<=S&&wa[255+M-F]<=S&&wa[255+ge-ne]<=S&&wa[255+ne-V]<=S&&wa[255+V-O]<=S}function za(o,u,g,y){var S=2*y+1;for(y=0;16>y;++y)Ca(o,u+y,g,S)&&ka(o,u+y,g)}function _s(o,u,g,y){var S=2*y+1;for(y=0;16>y;++y)Ca(o,u+y*g,1,S)&&ka(o,u+y*g,1)}function ws(o,u,g,y){var S;for(S=3;0<S;--S)za(o,u+=4*g,g,y)}function ki(o,u,g,y){var S;for(S=3;0<S;--S)_s(o,u+=4,g,y)}function na(o,u,g,y,S,C,M,F){for(C=2*C+1;0<S--;){if(rs(o,u,g,C,M))if(va(o,u,g,F))ka(o,u,g);else{var O=o,V=u,ne=g,ge=O[V-2*ne],W=O[V-ne],re=O[V+0],he=O[V+ne],Le=O[V+2*ne],pe=27*(Pe=dc[1020+3*(re-W)+dc[1020+ge-he]])+63>>7,ke=18*Pe+63>>7,Pe=9*Pe+63>>7;O[V-3*ne]=ra[255+O[V-3*ne]+Pe],O[V-2*ne]=ra[255+ge+ke],O[V-ne]=ra[255+W+pe],O[V+0]=ra[255+re-pe],O[V+ne]=ra[255+he-ke],O[V+2*ne]=ra[255+Le-Pe]}u+=y}}function Ur(o,u,g,y,S,C,M,F){for(C=2*C+1;0<S--;){if(rs(o,u,g,C,M))if(va(o,u,g,F))ka(o,u,g);else{var O=o,V=u,ne=g,ge=O[V-ne],W=O[V+0],re=O[V+ne],he=Xo[112+(4+(Le=3*(W-ge))>>3)],Le=Xo[112+(Le+3>>3)],pe=he+1>>1;O[V-2*ne]=ra[255+O[V-2*ne]+pe],O[V-ne]=ra[255+ge+Le],O[V+0]=ra[255+W-he],O[V+ne]=ra[255+re-pe]}u+=y}}function Ci(o,u,g,y,S,C){na(o,u,g,1,16,y,S,C)}function Pi(o,u,g,y,S,C){na(o,u,1,g,16,y,S,C)}function Ei(o,u,g,y,S,C){var M;for(M=3;0<M;--M)Ur(o,u+=4*g,g,1,16,y,S,C)}function Vt(o,u,g,y,S,C){var M;for(M=3;0<M;--M)Ur(o,u+=4,1,g,16,y,S,C)}function dr(o,u,g,y,S,C,M,F){na(o,u,S,1,8,C,M,F),na(g,y,S,1,8,C,M,F)}function p(o,u,g,y,S,C,M,F){na(o,u,1,S,8,C,M,F),na(g,y,1,S,8,C,M,F)}function j(o,u,g,y,S,C,M,F){Ur(o,u+4*S,S,1,8,C,M,F),Ur(g,y+4*S,S,1,8,C,M,F)}function U(o,u,g,y,S,C,M,F){Ur(o,u+4,1,S,8,C,M,F),Ur(g,y+4,1,S,8,C,M,F)}function ee(){this.ba=new Nt,this.ec=[],this.cc=[],this.Mc=[],this.Dc=this.Nc=this.dc=this.fc=0,this.Oa=new Ze,this.memory=0,this.Ib="OutputFunc",this.Jb="OutputAlphaFunc",this.Nd="OutputRowFunc"}function oe(){this.data=[],this.offset=this.kd=this.ha=this.w=0,this.na=[],this.xa=this.gb=this.Ja=this.Sa=this.P=0}function Se(){this.nc=this.Ea=this.b=this.hc=0,this.K=[],this.w=0}function Ie(){this.ua=0,this.Wa=new ye,this.vb=new ye,this.md=this.xc=this.wc=0,this.vc=[],this.Wb=0,this.Ya=new H,this.yc=new k}function ht(){this.xb=this.a=0,this.l=new Ba,this.ca=new Nt,this.V=[],this.Ba=0,this.Ta=[],this.Ua=0,this.m=new E,this.Pb=0,this.wd=new E,this.Ma=this.$=this.C=this.i=this.c=this.xd=0,this.s=new Ie,this.ab=0,this.gc=c(4,Se),this.Oc=0}function ut(){this.Lc=this.Z=this.$a=this.i=this.c=0,this.l=new Ba,this.ic=0,this.ca=[],this.tb=0,this.qd=null,this.rd=0}function It(o,u,g,y,S,C,M){for(o=o==null?0:o[u+0],u=0;u<M;++u)S[C+u]=o+g[y+u]&255,o=S[C+u]}function Bt(o,u,g,y,S,C,M){var F;if(o==null)It(null,null,g,y,S,C,M);else for(F=0;F<M;++F)S[C+F]=o[u+F]+g[y+F]&255}function Jt(o,u,g,y,S,C,M){if(o==null)It(null,null,g,y,S,C,M);else{var F,O=o[u+0],V=O,ne=O;for(F=0;F<M;++F)V=ne+(O=o[u+F])-V,ne=g[y+F]+(-256&V?0>V?0:255:V)&255,V=O,S[C+F]=ne}}function er(o,u,g,y){var S=u.width,C=u.o;if(t(o!=null&&u!=null),0>g||0>=y||g+y>C)return null;if(!o.Cc){if(o.ga==null){var M;if(o.ga=new ut,(M=o.ga==null)||(M=u.width*u.o,t(o.Gb.length==0),o.Gb=i(M),o.Uc=0,o.Gb==null?M=0:(o.mb=o.Gb,o.nb=o.Uc,o.rc=null,M=1),M=!M),!M){M=o.ga;var F=o.Fa,O=o.P,V=o.qc,ne=o.mb,ge=o.nb,W=O+1,re=V-1,he=M.l;if(t(F!=null&&ne!=null&&u!=null),Cs[0]=null,Cs[1]=It,Cs[2]=Bt,Cs[3]=Jt,M.ca=ne,M.tb=ge,M.c=u.width,M.i=u.height,t(0<M.c&&0<M.i),1>=V)u=0;else if(M.$a=3&F[O+0],M.Z=F[O+0]>>2&3,M.Lc=F[O+0]>>4&3,O=F[O+0]>>6&3,0>M.$a||1<M.$a||4<=M.Z||1<M.Lc||O)u=0;else if(he.put=lt,he.ac=yn,he.bc=hr,he.ma=M,he.width=u.width,he.height=u.height,he.Da=u.Da,he.v=u.v,he.va=u.va,he.j=u.j,he.o=u.o,M.$a)e:{t(M.$a==1),u=fr();t:for(;;){if(u==null){u=0;break e}if(t(M!=null),M.mc=u,u.c=M.c,u.i=M.i,u.l=M.l,u.l.ma=M,u.l.width=M.c,u.l.height=M.i,u.a=0,ae(u.m,F,W,re),!nr(M.c,M.i,1,u,null)||(u.ab==1&&u.gc[0].hc==3&&Un(u.s)?(M.ic=1,F=u.c*u.i,u.Ta=null,u.Ua=0,u.V=i(F),u.Ba=0,u.V==null?(u.a=1,u=0):u=1):(M.ic=0,u=qr(u,M.c)),!u))break t;u=1;break e}M.mc=null,u=0}else u=re>=M.c*M.i;M=!u}if(M)return null;o.ga.Lc!=1?o.Ga=0:y=C-g}t(o.ga!=null),t(g+y<=C);e:{if(u=(F=o.ga).c,C=F.l.o,F.$a==0){if(W=o.rc,re=o.Vc,he=o.Fa,O=o.P+1+g*u,V=o.mb,ne=o.nb+g*u,t(O<=o.P+o.qc),F.Z!=0)for(t(Cs[F.Z]!=null),M=0;M<y;++M)Cs[F.Z](W,re,he,O,V,ne,u),W=V,re=ne,ne+=u,O+=u;else for(M=0;M<y;++M)r(V,ne,he,O,u),W=V,re=ne,ne+=u,O+=u;o.rc=W,o.Vc=re}else{if(t(F.mc!=null),u=g+y,t((M=F.mc)!=null),t(u<=M.i),M.C>=u)u=1;else if(F.ic||Rn(),F.ic){F=M.V,W=M.Ba,re=M.c;var Le=M.i,pe=(he=1,O=M.$/re,V=M.$%re,ne=M.m,ge=M.s,M.$),ke=re*Le,Pe=re*u,Be=ge.wc,Fe=pe<Pe?Fn(ge,V,O):null;t(pe<=ke),t(u<=Le),t(Un(ge));t:for(;;){for(;!ne.h&&pe<Pe;){if(V&Be||(Fe=Fn(ge,V,O)),t(Fe!=null),le(ne),256>(Le=Nn(Fe.G[0],Fe.H[0],ne)))F[W+pe]=Le,++pe,++V>=re&&(V=0,++O<=u&&!(O%16)&&lr(M,O));else{if(!(280>Le)){he=0;break t}Le=br(Le-256,ne);var xt,ot=Nn(Fe.G[4],Fe.H[4],ne);if(le(ne),!(pe>=(ot=bn(re,ot=br(ot,ne)))&&ke-pe>=Le)){he=0;break t}for(xt=0;xt<Le;++xt)F[W+pe+xt]=F[W+pe+xt-ot];for(pe+=Le,V+=Le;V>=re;)V-=re,++O<=u&&!(O%16)&&lr(M,O);pe<Pe&&V&Be&&(Fe=Fn(ge,V,O))}t(ne.h==X(ne))}lr(M,O>u?u:O);break t}!he||ne.h&&pe<ke?(he=0,M.a=ne.h?5:3):M.$=pe,u=he}else u=Xn(M,M.V,M.Ba,M.c,M.i,u,wr);if(!u){y=0;break e}}g+y>=C&&(o.Cc=1),y=1}if(!y)return null;if(o.Cc&&((y=o.ga)!=null&&(y.mc=null),o.ga=null,0<o.Ga))return alert("todo:WebPDequantizeLevels"),null}return o.nb+g*S}function vn(o,u,g,y,S,C){for(;0<S--;){var M,F=o,O=u+(g?1:0),V=o,ne=u+(g?0:3);for(M=0;M<y;++M){var ge=V[ne+4*M];ge!=255&&(ge*=32897,F[O+4*M+0]=F[O+4*M+0]*ge>>23,F[O+4*M+1]=F[O+4*M+1]*ge>>23,F[O+4*M+2]=F[O+4*M+2]*ge>>23)}u+=C}}function gn(o,u,g,y,S){for(;0<y--;){var C;for(C=0;C<g;++C){var M=o[u+2*C+0],F=15&(V=o[u+2*C+1]),O=4369*F,V=(240&V|V>>4)*O>>16;o[u+2*C+0]=(240&M|M>>4)*O>>16&240|(15&M|M<<4)*O>>16>>4&15,o[u+2*C+1]=240&V|F}u+=S}}function An(o,u,g,y,S,C,M,F){var O,V,ne=255;for(V=0;V<S;++V){for(O=0;O<y;++O){var ge=o[u+O];C[M+4*O]=ge,ne&=ge}u+=g,M+=F}return ne!=255}function Dn(o,u,g,y,S){var C;for(C=0;C<S;++C)g[y+C]=o[u+C]>>8}function Rn(){bo=vn,cu=gn,du=An,uu=Dn}function Nr(o,u,g){D[o]=function(y,S,C,M,F,O,V,ne,ge,W,re,he,Le,pe,ke,Pe,Be){var Fe,xt=Be-1>>1,ot=F[O+0]|V[ne+0]<<16,zt=ge[W+0]|re[he+0]<<16;t(y!=null);var pt=3*ot+zt+131074>>2;for(u(y[S+0],255&pt,pt>>16,Le,pe),C!=null&&(pt=3*zt+ot+131074>>2,u(C[M+0],255&pt,pt>>16,ke,Pe)),Fe=1;Fe<=xt;++Fe){var Yt=F[O+Fe]|V[ne+Fe]<<16,sr=ge[W+Fe]|re[he+Fe]<<16,$t=ot+Yt+zt+sr+524296,gt=$t+2*(Yt+zt)>>3;pt=gt+ot>>1,ot=($t=$t+2*(ot+sr)>>3)+Yt>>1,u(y[S+2*Fe-1],255&pt,pt>>16,Le,pe+(2*Fe-1)*g),u(y[S+2*Fe-0],255&ot,ot>>16,Le,pe+(2*Fe-0)*g),C!=null&&(pt=$t+zt>>1,ot=gt+sr>>1,u(C[M+2*Fe-1],255&pt,pt>>16,ke,Pe+(2*Fe-1)*g),u(C[M+2*Fe+0],255&ot,ot>>16,ke,Pe+(2*Fe+0)*g)),ot=Yt,zt=sr}1&Be||(pt=3*ot+zt+131074>>2,u(y[S+Be-1],255&pt,pt>>16,Le,pe+(Be-1)*g),C!=null&&(pt=3*zt+ot+131074>>2,u(C[M+Be-1],255&pt,pt>>16,ke,Pe+(Be-1)*g)))}}function as(){Na[Zo]=hg,Na[el]=wu,Na[xu]=fg,Na[tl]=Nu,Na[nl]=ju,Na[uc]=Su,Na[yu]=mg,Na[hc]=wu,Na[fc]=Nu,Na[rl]=ju,Na[mc]=Su}function ho(o){return o&-16384?0>o?0:255:o>>pg}function Js(o,u){return ho((19077*o>>8)+(26149*u>>8)-14234)}function Xs(o,u,g){return ho((19077*o>>8)-(6419*u>>8)-(13320*g>>8)+8708)}function Ns(o,u){return ho((19077*o>>8)+(33050*u>>8)-17685)}function Zs(o,u,g,y,S){y[S+0]=Js(o,g),y[S+1]=Xs(o,u,g),y[S+2]=Ns(o,u)}function Mi(o,u,g,y,S){y[S+0]=Ns(o,u),y[S+1]=Xs(o,u,g),y[S+2]=Js(o,g)}function Ii(o,u,g,y,S){var C=Xs(o,u,g);u=C<<3&224|Ns(o,u)>>3,y[S+0]=248&Js(o,g)|C>>5,y[S+1]=u}function jr(o,u,g,y,S){var C=240&Ns(o,u)|15;y[S+0]=240&Js(o,g)|Xs(o,u,g)>>4,y[S+1]=C}function ei(o,u,g,y,S){y[S+0]=255,Zs(o,u,g,y,S+1)}function ti(o,u,g,y,S){Mi(o,u,g,y,S),y[S+3]=255}function fo(o,u,g,y,S){Zs(o,u,g,y,S),y[S+3]=255}function $a(o,u,g){D[o]=function(y,S,C,M,F,O,V,ne,ge){for(var W=ne+(-2&ge)*g;ne!=W;)u(y[S+0],C[M+0],F[O+0],V,ne),u(y[S+1],C[M+0],F[O+0],V,ne+g),S+=2,++M,++O,ne+=2*g;1&ge&&u(y[S+0],C[M+0],F[O+0],V,ne)}}function Tr(o,u,g){return g==0?o==0?u==0?6:5:u==0?4:0:g}function Ko(o,u,g,y,S){switch(o>>>30){case 3:ss(u,g,y,S,0);break;case 2:As(u,g,y,S);break;case 1:Sr(u,g,y,S)}}function Fi(o,u){var g,y,S=u.M,C=u.Nb,M=o.oc,F=o.pc+40,O=o.oc,V=o.pc+584,ne=o.oc,ge=o.pc+600;for(g=0;16>g;++g)M[F+32*g-1]=129;for(g=0;8>g;++g)O[V+32*g-1]=129,ne[ge+32*g-1]=129;for(0<S?M[F-1-32]=O[V-1-32]=ne[ge-1-32]=129:(s(M,F-32-1,127,21),s(O,V-32-1,127,9),s(ne,ge-32-1,127,9)),y=0;y<o.za;++y){var W=u.ya[u.aa+y];if(0<y){for(g=-1;16>g;++g)r(M,F+32*g-4,M,F+32*g+12,4);for(g=-1;8>g;++g)r(O,V+32*g-4,O,V+32*g+4,4),r(ne,ge+32*g-4,ne,ge+32*g+4,4)}var re=o.Gd,he=o.Hd+y,Le=W.ad,pe=W.Hc;if(0<S&&(r(M,F-32,re[he].y,0,16),r(O,V-32,re[he].f,0,8),r(ne,ge-32,re[he].ea,0,8)),W.Za){var ke=M,Pe=F-32+16;for(0<S&&(y>=o.za-1?s(ke,Pe,re[he].y[15],4):r(ke,Pe,re[he+1].y,0,4)),g=0;4>g;g++)ke[Pe+128+g]=ke[Pe+256+g]=ke[Pe+384+g]=ke[Pe+0+g];for(g=0;16>g;++g,pe<<=2)ke=M,Pe=F+Au[g],Ea[W.Ob[g]](ke,Pe),Ko(pe,Le,16*+g,ke,Pe)}else if(ke=Tr(y,S,W.Ob[0]),ks[ke](M,F),pe!=0)for(g=0;16>g;++g,pe<<=2)Ko(pe,Le,16*+g,M,F+Au[g]);for(g=W.Gc,ke=Tr(y,S,W.Dd),os[ke](O,V),os[ke](ne,ge),pe=Le,ke=O,Pe=V,255&(W=0|g)&&(170&W?Oi(pe,256,ke,Pe):Ua(pe,256,ke,Pe)),W=ne,pe=ge,255&(g>>=8)&&(170&g?Oi(Le,320,W,pe):Ua(Le,320,W,pe)),S<o.Ub-1&&(r(re[he].y,0,M,F+480,16),r(re[he].f,0,O,V+224,8),r(re[he].ea,0,ne,ge+224,8)),g=8*C*o.B,re=o.sa,he=o.ta+16*y+16*C*o.R,Le=o.qa,W=o.ra+8*y+g,pe=o.Ha,ke=o.Ia+8*y+g,g=0;16>g;++g)r(re,he+g*o.R,M,F+32*g,16);for(g=0;8>g;++g)r(Le,W+g*o.B,O,V+32*g,8),r(pe,ke+g*o.B,ne,ge+32*g,8)}}function Qo(o,u,g,y,S,C,M,F,O){var V=[0],ne=[0],ge=0,W=O!=null?O.kd:0,re=O??new oe;if(o==null||12>g)return 7;re.data=o,re.w=u,re.ha=g,u=[u],g=[g],re.gb=[re.gb];e:{var he=u,Le=g,pe=re.gb;if(t(o!=null),t(Le!=null),t(pe!=null),pe[0]=0,12<=Le[0]&&!n(o,he[0],"RIFF")){if(n(o,he[0]+8,"WEBP")){pe=3;break e}var ke=De(o,he[0]+4);if(12>ke||4294967286<ke){pe=3;break e}if(W&&ke>Le[0]-8){pe=7;break e}pe[0]=ke,he[0]+=12,Le[0]-=12}pe=0}if(pe!=0)return pe;for(ke=0<re.gb[0],g=g[0];;){e:{var Pe=o;Le=u,pe=g;var Be=V,Fe=ne,xt=he=[0];if((pt=ge=[ge])[0]=0,8>pe[0])pe=7;else{if(!n(Pe,Le[0],"VP8X")){if(De(Pe,Le[0]+4)!=10){pe=3;break e}if(18>pe[0]){pe=7;break e}var ot=De(Pe,Le[0]+8),zt=1+we(Pe,Le[0]+12);if(2147483648<=zt*(Pe=1+we(Pe,Le[0]+15))){pe=3;break e}xt!=null&&(xt[0]=ot),Be!=null&&(Be[0]=zt),Fe!=null&&(Fe[0]=Pe),Le[0]+=18,pe[0]-=18,pt[0]=1}pe=0}}if(ge=ge[0],he=he[0],pe!=0)return pe;if(Le=!!(2&he),!ke&&ge)return 3;if(C!=null&&(C[0]=!!(16&he)),M!=null&&(M[0]=Le),F!=null&&(F[0]=0),M=V[0],he=ne[0],ge&&Le&&O==null){pe=0;break}if(4>g){pe=7;break}if(ke&&ge||!ke&&!ge&&!n(o,u[0],"ALPH")){g=[g],re.na=[re.na],re.P=[re.P],re.Sa=[re.Sa];e:{ot=o,pe=u,ke=g;var pt=re.gb;Be=re.na,Fe=re.P,xt=re.Sa,zt=22,t(ot!=null),t(ke!=null),Pe=pe[0];var Yt=ke[0];for(t(Be!=null),t(xt!=null),Be[0]=null,Fe[0]=null,xt[0]=0;;){if(pe[0]=Pe,ke[0]=Yt,8>Yt){pe=7;break e}var sr=De(ot,Pe+4);if(4294967286<sr){pe=3;break e}var $t=8+sr+1&-2;if(zt+=$t,0<pt&&zt>pt){pe=3;break e}if(!n(ot,Pe,"VP8 ")||!n(ot,Pe,"VP8L")){pe=0;break e}if(Yt[0]<$t){pe=7;break e}n(ot,Pe,"ALPH")||(Be[0]=ot,Fe[0]=Pe+8,xt[0]=sr),Pe+=$t,Yt-=$t}}if(g=g[0],re.na=re.na[0],re.P=re.P[0],re.Sa=re.Sa[0],pe!=0)break}g=[g],re.Ja=[re.Ja],re.xa=[re.xa];e:if(pt=o,pe=u,ke=g,Be=re.gb[0],Fe=re.Ja,xt=re.xa,ot=pe[0],Pe=!n(pt,ot,"VP8 "),zt=!n(pt,ot,"VP8L"),t(pt!=null),t(ke!=null),t(Fe!=null),t(xt!=null),8>ke[0])pe=7;else{if(Pe||zt){if(pt=De(pt,ot+4),12<=Be&&pt>Be-12){pe=3;break e}if(W&&pt>ke[0]-8){pe=7;break e}Fe[0]=pt,pe[0]+=8,ke[0]-=8,xt[0]=zt}else xt[0]=5<=ke[0]&&pt[ot+0]==47&&!(pt[ot+4]>>5),Fe[0]=ke[0];pe=0}if(g=g[0],re.Ja=re.Ja[0],re.xa=re.xa[0],u=u[0],pe!=0)break;if(4294967286<re.Ja)return 3;if(F==null||Le||(F[0]=re.xa?2:1),M=[M],he=[he],re.xa){if(5>g){pe=7;break}F=M,W=he,Le=C,o==null||5>g?o=0:5<=g&&o[u+0]==47&&!(o[u+4]>>5)?(ke=[0],pt=[0],Be=[0],ae(Fe=new E,o,u,g),sn(Fe,ke,pt,Be)?(F!=null&&(F[0]=ke[0]),W!=null&&(W[0]=pt[0]),Le!=null&&(Le[0]=Be[0]),o=1):o=0):o=0}else{if(10>g){pe=7;break}F=he,o==null||10>g||!vs(o,u+3,g-3)?o=0:(W=o[u+0]|o[u+1]<<8|o[u+2]<<16,Le=16383&(o[u+7]<<8|o[u+6]),o=16383&(o[u+9]<<8|o[u+8]),1&W||3<(W>>1&7)||!(W>>4&1)||W>>5>=re.Ja||!Le||!o?o=0:(M&&(M[0]=Le),F&&(F[0]=o),o=1))}if(!o||(M=M[0],he=he[0],ge&&(V[0]!=M||ne[0]!=he)))return 3;O!=null&&(O[0]=re,O.offset=u-O.w,t(4294967286>u-O.w),t(O.offset==O.ha-g));break}return pe==0||pe==7&&ge&&O==null?(C!=null&&(C[0]|=re.na!=null&&0<re.na.length),y!=null&&(y[0]=M),S!=null&&(S[0]=he),0):pe}function _a(o,u,g){var y=u.width,S=u.height,C=0,M=0,F=y,O=S;if(u.Da=o!=null&&0<o.Da,u.Da&&(F=o.cd,O=o.bd,C=o.v,M=o.j,11>g||(C&=-2,M&=-2),0>C||0>M||0>=F||0>=O||C+F>y||M+O>S))return 0;if(u.v=C,u.j=M,u.va=C+F,u.o=M+O,u.U=F,u.T=O,u.da=o!=null&&0<o.da,u.da){if(!Ee(F,O,g=[o.ib],C=[o.hb]))return 0;u.ib=g[0],u.hb=C[0]}return u.ob=o!=null&&o.ob,u.Kb=o==null||!o.Sd,u.da&&(u.ob=u.ib<3*y/4&&u.hb<3*S/4,u.Kb=0),1}function ni(o){if(o==null)return 2;if(11>o.S){var u=o.f.RGBA;u.fb+=(o.height-1)*u.A,u.A=-u.A}else u=o.f.kb,o=o.height,u.O+=(o-1)*u.fa,u.fa=-u.fa,u.N+=(o-1>>1)*u.Ab,u.Ab=-u.Ab,u.W+=(o-1>>1)*u.Db,u.Db=-u.Db,u.F!=null&&(u.J+=(o-1)*u.lb,u.lb=-u.lb);return 0}function mo(o,u,g,y){if(y==null||0>=o||0>=u)return 2;if(g!=null){if(g.Da){var S=g.cd,C=g.bd,M=-2&g.v,F=-2&g.j;if(0>M||0>F||0>=S||0>=C||M+S>o||F+C>u)return 2;o=S,u=C}if(g.da){if(!Ee(o,u,S=[g.ib],C=[g.hb]))return 2;o=S[0],u=C[0]}}y.width=o,y.height=u;e:{var O=y.width,V=y.height;if(o=y.S,0>=O||0>=V||!(o>=Zo&&13>o))o=2;else{if(0>=y.Rd&&y.sd==null){M=C=S=u=0;var ne=(F=O*ku[o])*V;if(11>o||(C=(V+1)/2*(u=(O+1)/2),o==12&&(M=(S=O)*V)),(V=i(ne+2*C+M))==null){o=1;break e}y.sd=V,11>o?((O=y.f.RGBA).eb=V,O.fb=0,O.A=F,O.size=ne):((O=y.f.kb).y=V,O.O=0,O.fa=F,O.Fd=ne,O.f=V,O.N=0+ne,O.Ab=u,O.Cd=C,O.ea=V,O.W=0+ne+C,O.Db=u,O.Ed=C,o==12&&(O.F=V,O.J=0+ne+2*C),O.Tc=M,O.lb=S)}if(u=1,S=y.S,C=y.width,M=y.height,S>=Zo&&13>S)if(11>S)o=y.f.RGBA,u&=(F=Math.abs(o.A))*(M-1)+C<=o.size,u&=F>=C*ku[S],u&=o.eb!=null;else{o=y.f.kb,F=(C+1)/2,ne=(M+1)/2,O=Math.abs(o.fa),V=Math.abs(o.Ab);var ge=Math.abs(o.Db),W=Math.abs(o.lb),re=W*(M-1)+C;u&=O*(M-1)+C<=o.Fd,u&=V*(ne-1)+F<=o.Cd,u=(u&=ge*(ne-1)+F<=o.Ed)&O>=C&V>=F&ge>=F,u&=o.y!=null,u&=o.f!=null,u&=o.ea!=null,S==12&&(u&=W>=C,u&=re<=o.Tc,u&=o.F!=null)}else u=0;o=u?0:2}}return o!=0||g!=null&&g.fd&&(o=ni(y)),o}var Ti=64,ri=[0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535,131071,262143,524287,1048575,2097151,4194303,8388607,16777215],po=24,Dr=32,Vr=8,Di=[0,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
vendor: 4,755 bytes, line 124
1246,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7];qe("Predictor0","PredictorAdd0"),D.Predictor0=function(){return 4278190080},D.Predictor1=function(o){return o},D.Predictor2=function(o,u,g){return u[g+0]},D.Predictor3=function(o,u,g){return u[g+1]},D.Predictor4=function(o,u,g){return u[g-1]},D.Predictor5=function(o,u,g){return Ge(Ge(o,u[g+1]),u[g+0])},D.Predictor6=function(o,u,g){return Ge(o,u[g-1])},D.Predictor7=function(o,u,g){return Ge(o,u[g+0])},D.Predictor8=function(o,u,g){return Ge(u[g-1],u[g+0])},D.Predictor9=function(o,u,g){return Ge(u[g+0],u[g+1])},D.Predictor10=function(o,u,g){return Ge(Ge(o,u[g-1]),Ge(u[g+0],u[g+1]))},D.Predictor11=function(o,u,g){var y=u[g+0];return 0>=Me(y>>24&255,o>>24&255,(u=u[g-1])>>24&255)+Me(y>>16&255,o>>16&255,u>>16&255)+Me(y>>8&255,o>>8&255,u>>8&255)+Me(255&y,255&o,255&u)?y:o},D.Predictor12=function(o,u,g){var y=u[g+0];return(bt((o>>24&255)+(y>>24&255)-((u=u[g-1])>>24&255))<<24|bt((o>>16&255)+(y>>16&255)-(u>>16&255))<<16|bt((o>>8&255)+(y>>8&255)-(u>>8&255))<<8|bt((255&o)+(255&y)-(255&u)))>>>0},D.Predictor13=function(o,u,g){var y=u[g-1];return(et((o=Ge(o,u[g+0]))>>24&255,y>>24&255)<<24|et(o>>16&255,y>>16&255)<<16|et(o>>8&255,y>>8&255)<<8|et(255&o,255&y))>>>0};var js=D.PredictorAdd0;D.PredictorAdd1=vt,qe("Predictor2","PredictorAdd2"),qe("Predictor3","PredictorAdd3"),qe("Predictor4","PredictorAdd4"),qe("Predictor5","PredictorAdd5"),qe("Predictor6","PredictorAdd6"),qe("Predictor7","PredictorAdd7"),qe("Predictor8","PredictorAdd8"),qe("Predictor9","PredictorAdd9"),qe("Predictor10","PredictorAdd10"),qe("Predictor11","PredictorAdd11"),qe("Predictor12","PredictorAdd12"),qe("Predictor13","PredictorAdd13");var Ss=D.PredictorAdd2;Xe("ColorIndexInverseTransform","MapARGB","32b",function(o){return o>>8&255},function(o){return o}),Xe("VP8LColorIndexInverseTransformAlpha","MapAlpha","8b",function(o){return o},function(o){return o>>8&255});var Ri,ai=D.ColorIndexInverseTransform,tr=D.MapARGB,cc=D.VP8LColorIndexInverseTransformAlpha,Ha=D.MapAlpha,Pa=D.VP8LPredictorsAdd=[];Pa.length=16,(D.VP8LPredictors=[]).length=16,(D.VP8LPredictorsAdd_C=[]).length=16,(D.VP8LPredictors_C=[]).length=16;var si,go,xo,Bi,ii,oi,Ls,ss,As,Oi,Sr,Ua,jn,Sn,Wn,ar,is,yo,qi,Jo,su,iu,ou,lu,bo,cu,du,uu,hu=i(511),fu=i(2041),mu=i(225),pu=i(767),gu=0,dc=fu,Xo=mu,ra=pu,wa=hu,Zo=0,el=1,xu=2,tl=3,nl=4,uc=5,yu=6,hc=7,fc=8,rl=9,mc=10,Xp=[2,3,7],Zp=[3,3,11],bu=[280,256,256,256,40],eg=[0,1,1,1,0],tg=[17,18,0,1,2,3,4,5,16,6,7,8,9,10,11,12,13,14,15],ng=[24,7,23,25,40,6,39,41,22,26,38,42,56,5,55,57,21,27,54,58,37,43,72,4,71,73,20,28,53,59,70,74,36,44,88,69,75,52,60,3,87,89,19,29,86,90,35,45,68,76,85,91,51,61,104,2,103,105,18,30,102,106,34,46,84,92,67,77,101,107,50,62,120,1,119,121,83,93,17,31,100,108,66,78,118,122,33,47,117,123,49,63,99,109,82,94,0,116,124,65,79,16,32,98,110,48,115,125,81,95,64,114,126,97,111,80,113,127,96,112],rg=[2954,2956,2958,2962,2970,2986,3018,3082,3212,3468,3980,5004],ag=8,pc=[4,5,6,7,8,9,10,10,11,12,13,14,15,16,17,17,18,19,20,20,21,21,22,22,23,23,24,25,25,26,27,28,29,30,31,32,33,34,35,36,37,37,38,39,40,41,42,43,44,45,46,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,76,77,78,79,80,81,82,83,84,85,86,87,88,89,91,93,95,96,98,100,101,102,104,106,108,110,112,114,116,118,122,124,126,128,130,132,134,136,138,140,143,145,148,151,154,157],gc=[4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,60,62,64,66,68,70,72,74,76,78,80,82,84,86,88,90,92,94,96,98,100,102,104,106,108,110,112,114,116,119,122,125,128,131,134,137,140,143,146,149,152,155,158,161,164,167,170,173,177,181,185,189,193,197,201,205,209,213,217,221,225,229,234,239,245,249,254,259,264,269,274,279,284],vo=null,sg=[[173,148,140,0],[176,155,140,135,0],[180,157,141,134,130,0],[254,254,243,230,196,177,153,140,133,130,129,0]],ig=[0,1,4,8,5,2,3,6,9,12,13,10,7,11,14,15],vu=[-0,1,-1,2,-2,3,4,6,-3,5,-4,-5,-6,7,-7,8,-8,-9],og=[[[[128,128,128,128,128,128,128,128,128,128,128],[128,128,128,128,128,128,128,128,128,128,128],[128,128,128,128,128,128,128,128,128,128,128]],[[253,136,254,255,228,219,128,128,128,128,128],[189,129,242,255,227,213,255,219,128,128,128],[106,126,227,252,214,209,255,255,128,128,128]],[[1,98,248,255,236,226,255,255,128,128,128],[181,133,238,254,221,234,255,154,128,128,128],[78,134,202,247,198,180,255,219,128,128,128]],[[1,185,249,25
1245,243,255,128,128,128,128,128],[184,150,247,255,236,224,128,128,128,128,128],[77,110,216,255,236,230,128,128,128,128,128]],[[1,101,251,255,241,255,128,128,128,128,128],[170,139,241,252,236,209,255,255,128,128,128],[37,116,196,243,228,255,255,255,128,128,128]],[[1,204,254,255,245,255,128,128,128,128,128],[207,160,250,255,238,128,128,128,128,128,128],[102,103,231,255,211,171,128,128,128,128,128]],[[1,152,252,255,240,255,128,128,128,128,128],[177,135,243,255,234,225,128,128,128,128,128],[80,129,211,255,194,224,128,128,128,128,128]],[[1,1,255,128,128,128,128,128,128,128,128],[246,1,255,128,128,128,128,128,128,128,128],[255,128,128,128,128,128,128,128,128,128,128]]],[[[198,35,237,223,193,187,162,160,145,155,62],[131,45,198,221,172,176,220,157,252,221,1],[68,47,146,208,149,167,221,162,255,223,128]],[[1,149,241,255,221,224,255,255,128,128,128],[184,141,234,253,222,220,255,199,128,128,128],[81,99,181,242,176,190,249,202,255,255,128]],[[1,129,232,253,214,197,242,196,255,255,128],[99,121,210,250,201,198,255,202,128,128,128],[23,91,163,242,170,187,247,210,255,255,128]],[[1,200,246,255,234,255,128,128,128,128,128],[109,178,241,255,231,245,255,255,128,128,128],[44,130,201,253,205,192,255,255,128,128,128]],[[1,132,239,251,219,209,255,165,128,128,128],[94,136,225,251,218,190,255,255,128,128,128],[22,100,174,245,186,161,255,199,128,128,128]],[[1,182,249,255,232,235,128,128,128,128,128],[124,143,241,255,227,234,128,128,128,128,128],[35,77,181,251,193,211,255,205,128,128,128]],[[1,157,247,255,236,231,255,255,128,128,128],[121,141,235,255,225,227,255,255,128,128,128],[45,99,188,251,195,217,255,224,128,128,128]],[[1,1,251,255,213,255,128,128,128,128,128],[203,1,248,255,255,128,128,128,128,128,128],[137,1,177,255,224,255,128,128,128,128,128]]],[[[253,9,248,251,207,208,255,192,128,128,128],[175,13,224,243,193,185,249,198,255,255,128],[73,17,171,221,161,179,236,167,255,234,128]],[[1,95,247,253,212,183,255,255,128,128,128],[239,90,244,250,211,209,255,255,128,128,128],[155,77,195,248,188,195,255,255,128,128,128]],[[1,24,239,251,218,219,255,205,128,128,128],[201,51,219,255,196,186,128,128,128,128,128],[69,46,190,239,201,218,255,228,128,128,128]],[[1,191,251,255,255,128,128,128,128,128,128],[223,165,249,255,213,255,128,128,128,128,128],[141,124,248,255,255,128,128,128,128,128,128]],[[1,16,248,255,255,128,128,128,128,128,128],[190,36,230,255,236,255,128,128,128,128,128],[149,1,255,128,128,128,128,128,128,128,128]],[[1,226,255,128,128,128,128,128,128,128,128],[247,192,255,128,128,128,128,128,128,128,128],[240,128,255,128,128,128,128,128,128,128,128]],[[1,134,252,255,255,128,128,128,128,128,128],[213,62,250,255,255,128,128,128,128,128,128],[55,93,255,128,128,128,128,128,128,128,128]],[[128,128,128,128,128,128,128,128,128,128,128],[128,128,128,128,128,128,128,128,128,128,128],[128,128,128,128,128,128,128,128,128,128,128]]],[[[202,24,213,235,186,191,220,160,240,175,255],[126,38,182,232,169,184,228,174,255,187,128],[61,46,138,219,151,178,240,170,255,216,128]],[[1,112,230,250,199,191,247,159,255,255,128],[166,109,228,252,211,215,255,174,128,128,128],[39,77,162,232,172,180,245,178,255,255,128]],[[1,52,220,246,198,199,249,220,255,255,128],[124,74,191,243,183,193,250,221,255,255,128],[24,71,130,219,154,170,243,182,255,255,128]],[[1,182,225,249,219,240,255,224,128,128,128],[149,150,226,252,216,205,255,171,128,128,128],[28,108,170,242,183,194,254,223,255,255,128]],[[1,81,230,252,204,203,255,192,128,128,128],[123,102,209,247,188,196,255,233,128,128,128],[20,95,153,243,164,173,255,203,128,128,128]],[[1,222,248,255,216,213,128,128,128,128,128],[168,175,246,252,235,205,255,255,128,128,128],[47,116,215,255,211,212,255,255,128,128,128]],[[1,121,236,253,212,214,255,255,128,128,128],[141,84,213,252,201,202,255,219,128,128,128],[42,80,160,240,162,185,255,205,128,128,128]],[[1,1,255,128,128,128,128,128,128,128,128],[244,1,255,128,128,128,128,128,128,128,128],[238,1,255,128,128,128,128,128,128,128,128]]]],lg=[[[231,120,48,89,115,113,120,152,112],[152,179,64,126,170,118,46,70,95],[175,69,143,80,85,82,72,155,103],[56,58,10,171,218,189,17,13,152],[114,26,17,163,44,195,21,10,173],[121,24,80,195,26,62,44,64,85],[144,71,10,38,171,213,144,34,26],[170,46,55,19,136,160,33,206,71],[63,20,8,114,114,208,12,9,226],[81,40,11,96,182,84,29,16,36]],[[134,183,89,137,98,101,106,165,148],[72,187,100,130,157,111,32,75,80],[66,102,167,99,74,62,40,234,128],[41,53,9,178,241,141,26,8,107],[74,43,26,146,73,166,49,23,157],[65,38,105,160,51,52,31,115,128],[104,79,12,27,217,255,87,17,7],[87,68,71,44,114,51,15,186,23],[47,41,14,110,182,183,21,17,194],[66,45,25,102,197,189,23,18,22]],[[88,88,147,150,42,46,45,196,205],[43,97,183,117,85,38,35,179,61],[39,53,200,87,26,21,43,232,171],[56,34,51,104,114,102,29,93,77],[39,28,85,171,58,165,90,98,64],[34,22,116,206,23,34,43,166,73],[107,54,32,26,51,1,81,43,31],[68,25,106,22,64,171,36,225,114],[34,19,21,102,132,188,16,76,124],[62,18,78,95,85,57,50,48,51]],[[193,101,35,159,215,111,89,46,111],[60,148,31,172,219,228,21,18,111],[112,113,77,85,179,255,38,120,114],[40,42,1,196,245,209,10,25,109],[88,43,29,140,166,213,37,43,154],[61,63,30,155,67,45,68,1,209],[100,80,8,43,154,1,51,26,71],[142,78,78,16,255,128,34,197,171],[41,40,5,102,211,183,4,1,221],[51,50,17,168,209,192,23,25,82]],[[138,31,36,171,27,166,38,44,229],[67,87,58,169,82,115,26,59,179],[63,59,90,180,59,166,93,73,154],[40,40,21,116,143,209,34,39,175],[47,15,16,183,34,223,49,45,183],[46,17,33,183,6,98,15,32,183],[57,46,22,24,128,1,54,17,37],[65,32,73,115,28,128,23,128,205],[40,3,9,115,51,192,18,6,223],[87,37,9,115,59,77,64,21,47]],[[104,55,44,218,9,54,53,130,226],[64,90,70,205,40,41,23,26,57],[54,57,112,184,5,41,38,166,213],[30,34,26,133,152,116,10,32,134],[39,19,53,221,26,114,32,73,255],[31,9,65,234,2,15,1,118,73],[75,32,12,51,192,255,160,43,51],[88,31,35,67,102,85,55,186,85],[56,21,23,111,59,205,45,37,192],[55,38,70,124,73,102,1,34,98]],[[125,98,42,88,104,85,117,175,82],[95,84,53,89,128,100,113,101,45],[75,79,123,47,51,128,81,171,1],[57,17,5,71,102,57,53,41,49],[38,33,13,121,57,73,26,1,85],[41,10,67,138,77,110,90,47,114],[115,21,2,10,102,255,166,23,6],[101,29,16,10,85,128,101,196,26],[57,18,10,102,102,213,34,20,43],[117,20,15,36,163,128,68,1,26]],[[102,61,71,37,34,53,31,243,192],[69,60,71,38,73,119,28,222,37],[68,45,128,34,1,47,11,245,171],[62,17,19,70,146,85,55,62,70],[37,43,37,154,100,163,85,160,1],[63,9,92,136,28,64,32,201,85],[75,15,9,9,64,255,184,119,16],[86,6,28,5,64,25
1245,25,248,1],[56,8,17,132,137,255,55,116,128],[58,15,20,82,135,57,26,121,40]],[[164,50,31,137,154,133,25,35,218],[51,103,44,131,131,123,31,6,158],[86,40,64,135,148,224,45,183,128],[22,26,17,131,240,154,14,1,209],[45,16,21,91,64,222,7,1,197],[56,21,39,155,60,138,23,102,213],[83,12,13,54,192,255,68,47,28],[85,26,85,85,128,128,32,146,171],[18,11,7,63,144,171,4,4,246],[35,27,10,146,174,171,12,26,128]],[[190,80,35,99,180,80,126,54,45],[85,126,47,87,176,51,41,20,32],[101,75,128,139,118,146,116,128,85],[56,41,15,176,236,85,37,9,62],[71,30,17,119,118,255,17,18,138],[101,38,60,138,55,70,43,26,142],[146,36,19,30,171,255,97,27,20],[138,45,61,62,219,1,81,188,64],[32,41,20,117,151,142,20,21,163],[112,19,12,61,195,128,48,4,24]]],cg=[[[[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[176,246,255,255,255,255,255,255,255,255,255],[223,241,252,255,255,255,255,255,255,255,255],[249,253,253,255,255,255,255,255,255,255,255]],[[255,244,252,255,255,255,255,255,255,255,255],[234,254,254,255,255,255,255,255,255,255,255],[253,255,255,255,255,255,255,255,255,255,255]],[[255,246,254,255,255,255,255,255,255,255,255],[239,253,254,255,255,255,255,255,255,255,255],[254,255,254,255,255,255,255,255,255,255,255]],[[255,248,254,255,255,255,255,255,255,255,255],[251,255,254,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,253,254,255,255,255,255,255,255,255,255],[251,254,254,255,255,255,255,255,255,255,255],[254,255,254,255,255,255,255,255,255,255,255]],[[255,254,253,255,254,255,255,255,255,255,255],[250,255,254,255,254,255,255,255,255,255,255],[254,255,255,255,255,255,255,255,255,255,255]],[[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]]],[[[217,255,255,255,255,255,255,255,255,255,255],[225,252,241,253,255,255,254,255,255,255,255],[234,250,241,250,253,255,253,254,255,255,255]],[[255,254,255,255,255,255,255,255,255,255,255],[223,254,254,255,255,255,255,255,255,255,255],[238,253,254,254,255,255,255,255,255,255,255]],[[255,248,254,255,255,255,255,255,255,255,255],[249,254,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,253,255,255,255,255,255,255,255,255,255],[247,254,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,253,254,255,255,255,255,255,255,255,255],[252,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,254,254,255,255,255,255,255,255,255,255],[253,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,254,253,255,255,255,255,255,255,255,255],[250,255,255,255,255,255,255,255,255,255,255],[254,255,255,255,255,255,255,255,255,255,255]],[[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]]],[[[186,251,250,255,255,255,255,255,255,255,255],[234,251,244,254,255,255,255,255,255,255,255],[251,251,243,253,254,255,254,255,255,255,255]],[[255,253,254,255,255,255,255,255,255,255,255],[236,253,254,255,255,255,255,255,255,255,255],[251,253,253,254,254,255,255,255,255,255,255]],[[255,254,254,255,255,255,255,255,255,255,255],[254,254,254,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,254,255,255,255,255,255,255,255,255,255],[254,254,255,255,255,255,255,255,255,255,255],[254,255,255,255,255,255,255,255,255,255,255]],[[255,255,255,255,255,255,255,255,255,255,255],[254,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]]],[[[248,255,255,255,255,255,255,255,255,255,255],[250,254,252,254,255,255,255,255,255,255,255],[248,254,249,253,255,255,255,255,255,255,255]],[[255,253,253,255,255,255,255,255,255,255,255],[246,253,253,255,255,255,255,255,255,255,255],[252,254,251,254,254,255,255,255,255,255,255]],[[255,254,252,25
vendor: 23,735 bytes, lines 124-148
1245,255,255,255,255,255,255,255],[248,254,253,255,255,255,255,255,255,255,255],[253,255,254,254,255,255,255,255,255,255,255]],[[255,251,254,255,255,255,255,255,255,255,255],[245,251,254,255,255,255,255,255,255,255,255],[253,253,254,255,255,255,255,255,255,255,255]],[[255,251,253,255,255,255,255,255,255,255,255],[252,253,254,255,255,255,255,255,255,255,255],[255,254,255,255,255,255,255,255,255,255,255]],[[255,252,255,255,255,255,255,255,255,255,255],[249,255,254,255,255,255,255,255,255,255,255],[255,255,254,255,255,255,255,255,255,255,255]],[[255,255,253,255,255,255,255,255,255,255,255],[250,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,255,255,255,255,255,255,255,255,255,255],[254,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]]]],dg=[0,1,2,3,6,4,5,6,6,6,6,6,6,6,6,7,0],ks=[],Ea=[],os=[],ug=1,_u=2,Cs=[],Na=[];Nr("UpsampleRgbLinePair",Zs,3),Nr("UpsampleBgrLinePair",Mi,3),Nr("UpsampleRgbaLinePair",fo,4),Nr("UpsampleBgraLinePair",ti,4),Nr("UpsampleArgbLinePair",ei,4),Nr("UpsampleRgba4444LinePair",jr,2),Nr("UpsampleRgb565LinePair",Ii,2);var hg=D.UpsampleRgbLinePair,fg=D.UpsampleBgrLinePair,wu=D.UpsampleRgbaLinePair,Nu=D.UpsampleBgraLinePair,ju=D.UpsampleArgbLinePair,Su=D.UpsampleRgba4444LinePair,mg=D.UpsampleRgb565LinePair,al=16,sl=1<<al-1,_o=-227,xc=482,pg=6,Lu=0,gg=i(256),xg=i(256),yg=i(256),bg=i(256),vg=i(xc-_o),_g=i(xc-_o);$a("YuvToRgbRow",Zs,3),$a("YuvToBgrRow",Mi,3),$a("YuvToRgbaRow",fo,4),$a("YuvToBgraRow",ti,4),$a("YuvToArgbRow",ei,4),$a("YuvToRgba4444Row",jr,2),$a("YuvToRgb565Row",Ii,2);var Au=[0,4,8,12,128,132,136,140,256,260,264,268,384,388,392,396],il=[0,2,8],wg=[8,7,6,4,4,2,2,2,1,1,1,1],Ng=1;this.WebPDecodeRGBA=function(o,u,g,y,S){var C=el,M=new ee,F=new Nt;M.ba=F,F.S=C,F.width=[F.width],F.height=[F.height];var O=F.width,V=F.height,ne=new Qe;if(ne==null||o==null)var ge=2;else t(ne!=null),ge=Qo(o,u,g,ne.width,ne.height,ne.Pd,ne.Qd,ne.format,null);if(ge!=0?O=0:(O!=null&&(O[0]=ne.width[0]),V!=null&&(V[0]=ne.height[0]),O=1),O){F.width=F.width[0],F.height=F.height[0],y!=null&&(y[0]=F.width),S!=null&&(S[0]=F.height);e:{if(y=new Ba,(S=new oe).data=o,S.w=u,S.ha=g,S.kd=1,u=[0],t(S!=null),((o=Qo(S.data,S.w,S.ha,null,null,null,u,null,S))==0||o==7)&&u[0]&&(o=4),(u=o)==0){if(t(M!=null),y.data=S.data,y.w=S.w+S.offset,y.ha=S.ha-S.offset,y.put=lt,y.ac=yn,y.bc=hr,y.ma=M,S.xa){if((o=fr())==null){M=1;break e}if(function(W,re){var he=[0],Le=[0],pe=[0];t:for(;;){if(W==null)return 0;if(re==null)return W.a=2,0;if(W.l=re,W.a=0,ae(W.m,re.data,re.w,re.ha),!sn(W.m,he,Le,pe)){W.a=3;break t}if(W.xb=_u,re.width=he[0],re.height=Le[0],!nr(he[0],Le[0],1,W,null))break t;return 1}return t(W.a!=0),0}(o,y)){if(y=(u=mo(y.width,y.height,M.Oa,M.ba))==0){t:{y=o;n:for(;;){if(y==null){y=0;break t}if(t(y.s.yc!=null),t(y.s.Ya!=null),t(0<y.s.Wb),t((g=y.l)!=null),t((S=g.ma)!=null),y.xb!=0){if(y.ca=S.ba,y.tb=S.tb,t(y.ca!=null),!_a(S.Oa,g,tl)){y.a=2;break n}if(!qr(y,g.width)||g.da)break n;if((g.da||Ve(y.ca.S))&&Rn(),11>y.ca.S||(alert("todo:WebPInitConvertARGBToYUV"),y.ca.f.kb.F!=null&&Rn()),y.Pb&&0<y.s.ua&&y.s.vb.X==null&&!R(y.s.vb,y.s.Wa.Xa)){y.a=1;break n}y.xb=0}if(!Xn(y,y.V,y.Ba,y.c,y.i,g.o,vr))break n;S.Dc=y.Ma,y=1;break t}t(y.a!=0),y=0}y=!y}y&&(u=o.a)}else u=o.a}else{if((o=new bs)==null){M=1;break e}if(o.Fa=S.na,o.P=S.P,o.qc=S.Sa,rr(o,y)){if((u=mo(y.width,y.height,M.Oa,M.ba))==0){if(o.Aa=0,g=M.Oa,t((S=o)!=null),g!=null){if(0<(O=0>(O=g.Md)?0:100<O?255:255*O/100)){for(V=ne=0;4>V;++V)12>(ge=S.pb[V]).lc&&(ge.ia=O*wg[0>ge.lc?0:ge.lc]>>3),ne|=ge.ia;ne&&(alert("todo:VP8InitRandom"),S.ia=1)}S.Ga=g.Id,100<S.Ga?S.Ga=100:0>S.Ga&&(S.Ga=0)}(function(W,re){if(W==null)return 0;if(re==null)return Qt(W,2,"NULL VP8Io parameter in VP8Decode().");if(!W.cb&&!rr(W,re))return 0;if(t(W.cb),re.ac==null||re.ac(re)){re.ob&&(W.L=0);var he=il[W.L];if(W.L==2?(W.yb=0,W.zb=0):(W.yb=re.v-he>>4,W.zb=re.j-he>>4,0>W.yb&&(W.yb=0),0>W.zb&&(W.zb=0)),W.Va=re.o+15+he>>4,W.Hb=re.va+15+he>>4,W.Hb>W.za&&(W.Hb=W.za),W.Va>W.Ub&&(W.Va=W.Ub),0<W.L){var Le=W.ed;for(he=0;4>he;++he){var pe;if(W.Qa.Cb){var ke=W.Qa.Lb[he];W.Qa.Fb||(ke+=Le.Tb)}else ke=Le.Tb;for(pe=0;1>=pe;++pe){var Pe=W.gd[he][pe],Be=ke;if(Le.Pc&&(Be+=Le.vd[0],pe&&(Be+=Le.od[0])),0<(Be=0>Be?0:63<Be?63:Be)){var Fe=Be;0<Le.wb&&(Fe=4<Le.wb?Fe>>2:Fe>>1)>9-Le.wb&&(Fe=9-Le.wb),1>Fe&&(Fe=1),Pe.dd=Fe,Pe.tc=2*Be+Fe,Pe.ld=40<=Be?2:15<=Be?1:0}else Pe.tc=0;Pe.La=pe}}}he=0}else Qt(W,6,"Frame setup failed"),he=W.a;if(he=he==0){if(he){W.$c=0,0<W.Aa||(W.Ic=Ng);t:{he=W.Ic,Le=4*(Fe=W.za);var xt=32*Fe,ot=Fe+1,zt=0<W.L?Fe*(0<W.Aa?2:1):0,pt=(W.Aa==2?2:1)*Fe;if((Pe=Le+832+(pe=3*(16*he+il[W.L])/2*xt)+(ke=W.Fa!=null&&0<W.Fa.length?W.Kc.c*W.Kc.i:0))!=Pe)he=0;else{if(Pe>W.Vb){if(W.Vb=0,W.Ec=i(Pe),W.Fc=0,W.Ec==null){he=Qt(W,1,"no memory during frame initialization.");break t}W.Vb=Pe}Pe=W.Ec,Be=W.Fc,W.Ac=Pe,W.Bc=Be,Be+=Le,W.Gd=c(xt,La),W.Hd=0,W.rb=c(ot+1,pa),W.sb=1,W.wa=zt?c(zt,cn):null,W.Y=0,W.D.Nb=0,W.D.wa=W.wa,W.D.Y=W.Y,0<W.Aa&&(W.D.Y+=Fe),t(!0),W.oc=Pe,W.pc=Be,Be+=832,W.ya=c(pt,cr),W.aa=0,W.D.ya=W.ya,W.D.aa=W.aa,W.Aa==2&&(W.D.aa+=Fe),W.R=16*Fe,W.B=8*Fe,Fe=(xt=il[W.L])*W.R,xt=xt/2*W.B,W.sa=Pe,W.ta=Be+Fe,W.qa=W.sa,W.ra=W.ta+16*he*W.R+xt,W.Ha=W.qa,W.Ia=W.ra+8*he*W.B+xt,W.$c=0,Be+=pe,W.mb=ke?Pe:null,W.nb=ke?Be:null,t(Be+ke<=W.Fc+W.Vb),Hr(W),s(W.Ac,W.Bc,0,Le),he=1}}if(he){if(re.ka=0,re.y=W.sa,re.O=W.ta,re.f=W.qa,re.N=W.ra,re.ea=W.Ha,re.Vd=W.Ia,re.fa=W.R,re.Rc=W.B,re.F=null,re.J=0,!gu){for(he=-255;255>=he;++he)hu[255+he]=0>he?-he:he;for(he=-1020;1020>=he;++he)fu[1020+he]=-128>he?-128:127<he?127:he;for(he=-112;112>=he;++he)mu[112+he]=-16>he?-16:15<he?15:he;for(he=-255;510>=he;++he)pu[255+he]=0>he?0:255<he?255:he;gu=1}Ls=Vn,ss=rt,Oi=mt,Sr=Ft,Ua=tt,As=He,jn=Ci,Sn=Pi,Wn=dr,ar=p,is=Ei,yo=Vt,qi=j,Jo=U,su=za,iu=_s,ou=ws,lu=ki,Ea[0]=Fr,Ea[1]=Zt,Ea[2]=un,Ea[3]=On,Ea[4]=ea,Ea[5]=Rt,Ea[6]=ba,Ea[7]=mr,Ea[8]=Ks,Ea[9]=Aa,ks[0]=ct,ks[1]=Zr,ks[2]=Tn,ks[3]=G,ks[4]=Ye,ks[5]=jt,ks[6]=Pt,os[0]=pr,os[1]=en,os[2]=qa,os[3]=ta,os[4]=Ai,os[5]=ns,os[6]=Qs,he=1}else he=0}he&&(he=function(Yt,sr){for(Yt.M=0;Yt.M<Yt.Va;++Yt.M){var $t,gt=Yt.Jc[Yt.M&Yt.Xb],We=Yt.m,Gn=Yt;for($t=0;$t<Gn.za;++$t){var Ot=We,Xt=Gn,kn=Xt.Ac,gr=Xt.Bc+4*$t,Rr=Xt.zc,qn=Xt.ya[Xt.aa+$t];if(Xt.Qa.Bb?qn.$b=_e(Ot,Xt.Pa.jb[0])?2+_e(Ot,Xt.Pa.jb[2]):_e(Ot,Xt.Pa.jb[1]):qn.$b=0,Xt.kc&&(qn.Ad=_e(Ot,Xt.Bd)),qn.Za=!_e(Ot,145)+0,qn.Za){var Lr=qn.Ob,Br=0;for(Xt=0;4>Xt;++Xt){var ir,nn=Rr[0+Xt];for(ir=0;4>ir;++ir){nn=lg[kn[gr+ir]][nn];for(var hn=vu[_e(Ot,nn[0])];0<hn;)hn=vu[2*hn+_e(Ot,nn[hn])];nn=-hn,kn[gr+ir]=nn}r(Lr,Br,kn,gr,4),Br+=4,Rr[0+Xt]=nn}}else nn=_e(Ot,156)?_e(Ot,128)?1:3:_e(Ot,163)?2:0,qn.Ob[0]=nn,s(kn,gr,nn,4),s(Rr,0,nn,4);qn.Dd=_e(Ot,142)?_e(Ot,114)?_e(Ot,183)?1:3:2:0}if(Gn.m.Ka)return Qt(Yt,7,"Premature end-of-partition0 encountered.");for(;Yt.ja<Yt.za;++Yt.ja){if(Gn=gt,Ot=(We=Yt).rb[We.sb-1],kn=We.rb[We.sb+We.ja],$t=We.ya[We.aa+We.ja],gr=We.kc?$t.Ad:0)Ot.la=kn.la=0,$t.Za||(Ot.Na=kn.Na=0),$t.Hc=0,$t.Gc=0,$t.ia=0;else{var zn,fn;if(Ot=kn,kn=Gn,gr=We.Pa.Xc,Rr=We.ya[We.aa+We.ja],qn=We.pb[Rr.$b],Xt=Rr.ad,Lr=0,Br=We.rb[We.sb-1],nn=ir=0,s(Xt,Lr,0,384),Rr.Za)var xr=0,Ma=gr[3];else{hn=i(16);var Yn=Ot.Na+Br.Na;if(Yn=vo(kn,gr[1],Yn,qn.Eb,0,hn,0),Ot.Na=Br.Na=(0<Yn)+0,1<Yn)Ls(hn,0,Xt,Lr);else{var Wr=hn[0]+3>>3;for(hn=0;256>hn;hn+=16)Xt[Lr+hn]=Wr}xr=1,Ma=gr[0]}var _n=15&Ot.la,or=15&Br.la;for(hn=0;4>hn;++hn){var aa=1&or;for(Wr=fn=0;4>Wr;++Wr)_n=_n>>1|(aa=(Yn=vo(kn,Ma,Yn=aa+(1&_n),qn.Sc,xr,Xt,Lr))>xr)<<7,fn=fn<<2|(3<Yn?3:1<Yn?2:Xt[Lr+0]!=0),Lr+=16;_n>>=4,or=or>>1|aa<<7,ir=(ir<<8|fn)>>>0}for(Ma=_n,xr=or>>4,zn=0;4>zn;zn+=2){for(fn=0,_n=Ot.la>>4+zn,or=Br.la>>4+zn,hn=0;2>hn;++hn){for(aa=1&or,Wr=0;2>Wr;++Wr)Yn=aa+(1&_n),_n=_n>>1|(aa=0<(Yn=vo(kn,gr[2],Yn,qn.Qc,0,Xt,Lr)))<<3,fn=fn<<2|(3<Yn?3:1<Yn?2:Xt[Lr+0]!=0),Lr+=16;_n>>=2,or=or>>1|aa<<5}nn|=fn<<4*zn,Ma|=_n<<4<<zn,xr|=(240&or)<<zn}Ot.la=Ma,Br.la=xr,Rr.Hc=ir,Rr.Gc=nn,Rr.ia=43690&nn?0:qn.ia,gr=!(ir|nn)}if(0<We.L&&(We.wa[We.Y+We.ja]=We.gd[$t.$b][$t.Za],We.wa[We.Y+We.ja].La|=!gr),Gn.Ka)return Qt(Yt,7,"Premature end-of-file encountered.")}if(Hr(Yt),We=sr,Gn=1,$t=(gt=Yt).D,Ot=0<gt.L&&gt.M>=gt.zb&&gt.M<=gt.Va,gt.Aa==0)t:{if($t.M=gt.M,$t.uc=Ot,Fi(gt,$t),Gn=1,$t=(fn=gt.D).Nb,Ot=(nn=il[gt.L])*gt.R,kn=nn/2*gt.B,hn=16*$t*gt.R,Wr=8*$t*gt.B,gr=gt.sa,Rr=gt.ta-Ot+hn,qn=gt.qa,Xt=gt.ra-kn+Wr,Lr=gt.Ha,Br=gt.Ia-kn+Wr,or=(_n=fn.M)==0,ir=_n>=gt.Va-1,gt.Aa==2&&Fi(gt,fn),fn.uc)for(aa=(Yn=gt).D.M,t(Yn.D.uc),fn=Yn.yb;fn<Yn.Hb;++fn){xr=fn,Ma=aa;var Or=(sa=(yr=Yn).D).Nb;zn=yr.R;var sa=sa.wa[sa.Y+xr],ia=yr.sa,Gr=yr.ta+16*Or*zn+16*xr,oa=sa.dd,Ln=sa.tc;if(Ln!=0)if(t(3<=Ln),yr.L==1)0<xr&&iu(ia,Gr,zn,Ln+4),sa.La&&lu(ia,Gr,zn,Ln),0<Ma&&su(ia,Gr,zn,Ln+4),sa.La&&ou(ia,Gr,zn,Ln);else{var la=yr.B,Ia=yr.qa,li=yr.ra+8*Or*la+8*xr,ls=yr.Ha,yr=yr.Ia+8*Or*la+8*xr;Or=sa.ld,0<xr&&(Sn(ia,Gr,zn,Ln+4,oa,Or),ar(Ia,li,ls,yr,la,Ln+4,oa,Or)),sa.La&&(yo(ia,Gr,zn,Ln,oa,Or),Jo(Ia,li,ls,yr,la,Ln,oa,Or)),0<Ma&&(jn(ia,Gr,zn,Ln+4,oa,Or),Wn(Ia,li,ls,yr,la,Ln+4,oa,Or)),sa.La&&(is(ia,Gr,zn,Ln,oa,Or),qi(Ia,li,ls,yr,la,Ln,oa,Or))}}if(gt.ia&&alert("todo:DitherRow"),We.put!=null){if(fn=16*_n,_n=16*(_n+1),or?(We.y=gt.sa,We.O=gt.ta+hn,We.f=gt.qa,We.N=gt.ra+Wr,We.ea=gt.Ha,We.W=gt.Ia+Wr):(fn-=nn,We.y=gr,We.O=Rr,We.f=qn,We.N=Xt,We.ea=Lr,We.W=Br),ir||(_n-=nn),_n>We.o&&(_n=We.o),We.F=null,We.J=null,gt.Fa!=null&&0<gt.Fa.length&&fn<_n&&(We.J=er(gt,We,fn,_n-fn),We.F=gt.mb,We.F==null&&We.F.length==0)){Gn=Qt(gt,3,"Could not decode alpha data.");break t}fn<We.j&&(nn=We.j-fn,fn=We.j,t(!(1&nn)),We.O+=gt.R*nn,We.N+=gt.B*(nn>>1),We.W+=gt.B*(nn>>1),We.F!=null&&(We.J+=We.width*nn)),fn<_n&&(We.O+=We.v,We.N+=We.v>>1,We.W+=We.v>>1,We.F!=null&&(We.J+=We.v),We.ka=fn-We.j,We.U=We.va-We.v,We.T=_n-fn,Gn=We.put(We))}$t+1!=gt.Ic||ir||(r(gt.sa,gt.ta-Ot,gr,Rr+16*gt.R,Ot),r(gt.qa,gt.ra-kn,qn,Xt+8*gt.B,kn),r(gt.Ha,gt.Ia-kn,Lr,Br+8*gt.B,kn))}if(!Gn)return Qt(Yt,6,"Output aborted.")}return 1}(W,re)),re.bc!=null&&re.bc(re),he&=1}return he?(W.cb=0,he):0})(o,y)||(u=o.a)}}else u=o.a}u==0&&M.Oa!=null&&M.Oa.fd&&(u=ni(M.ba))}M=u}C=M!=0?null:11>C?F.f.RGBA.eb:F.f.kb.y}else C=null;return C};var ku=[3,4,3,4,4,2,2,4,4,4,2,1,1]};function h(D,Y){for(var N="",I=0;I<4;I++)N+=String.fromCharCode(D[Y++]);return N}function f(D,Y){return D[Y+0]|D[Y+1]<<8}function x(D,Y){return(D[Y+0]|D[Y+1]<<8|D[Y+2]<<16)>>>0}function b(D,Y){return(D[Y+0]|D[Y+1]<<8|D[Y+2]<<16|D[Y+3]<<24)>>>0}new d;var m=[0],w=[0],v=[],P=new d,_=e,q=function(D,Y){var N={},I=0,k=!1,L=0,H=0;if(N.frames=[],!function(A,E){for(var z=0;z<4;z++)if(A[E+z]!="RIFF".charCodeAt(z))return!0;return!1}(D,Y)){for(b(D,Y+=4),Y+=8;Y<D.length;){var te=h(D,Y),se=b(D,Y+=4);Y+=4;var K=se+(1&se);switch(te){case"VP8 ":case"VP8L":N.frames[I]===void 0&&(N.frames[I]={}),(Ne=N.frames[I]).src_off=k?H:Y-8,Ne.src_size=L+se+8,I++,k&&(k=!1,L=0,H=0);break;case"VP8X":(Ne=N.header={}).feature_flags=D[Y];var ae=Y+4;Ne.canvas_width=1+x(D,ae),ae+=3,Ne.canvas_height=1+x(D,ae),ae+=3;break;case"ALPH":k=!0,L=K+8,H=Y-8;break;case"ANIM":(Ne=N.header).bgcolor=b(D,Y),ae=Y+4,Ne.loop_count=f(D,ae),ae+=2;break;case"ANMF":var be,Ne;(Ne=N.frames[I]={}).offset_x=2*x(D,Y),Y+=3,Ne.offset_y=2*x(D,Y),Y+=3,Ne.width=1+x(D,Y),Y+=3,Ne.height=1+x(D,Y),Y+=3,Ne.duration=x(D,Y),Y+=3,be=D[Y++],Ne.dispose=1&be,Ne.blend=be>>1&1}te!="ANMF"&&(Y+=K)}return N}}(_,0);q.response=_,q.rgbaoutput=!0,q.dataurl=!1;var T=q.header?q.header:null,B=q.frames?q.frames:null;if(T){T.loop_counter=T.loop_count,m=[T.canvas_height],w=[T.canvas_width];for(var Q=0;Q<B.length&&B[Q].blend!=0;Q++);}var me=B[0],ce=P.WebPDecodeRGBA(_,me.src_off,me.src_size,w,m);me.rgba=ce,me.imgwidth=w[0],me.imgheight=m[0];for(var $=0;$<w[0]*m[0]*4;$++)v[$]=ce[$];return this.width=w,this.height=m,this.data=v,this}/** ====================================================================
125 * @license
126 * jsPDF XMP metadata plugin
127 * Copyright (c) 2016 Jussi Utunen, [email protected]
128 *
129 * Permission is hereby granted, free of charge, to any person obtaining
130 * a copy of this software and associated documentation files (the
131 * "Software"), to deal in the Software without restriction, including
132 * without limitation the rights to use, copy, modify, merge, publish,
133 * distribute, sublicense, and/or sell copies of the Software, and to
134 * permit persons to whom the Software is furnished to do so, subject to
135 * the following conditions:
136 *
137 * The above copyright notice and this permission notice shall be
138 * included in all copies or substantial portions of the Software.
139 *
140 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
141 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
142 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
143 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
144 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
145 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
146 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
147 * ====================================================================
148 */function gx(){var e,t=this.internal.__metadata__.metadata,n=unescape(encodeURIComponent(t));e=this.internal.__metadata__.rawXml?n:'<x:xmpmeta xmlns:x="adobe:ns:meta/"><rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"><rdf:Description rdf:about="" xmlns:jspdf="'+this.internal.__metadata__.namespaceUri+'"><jspdf:metadata>'+n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")+"</jspdf:metadata></rdf:Description></rdf:RDF></x:xmpmeta>",this.internal.__metadata__.metadataObjectNumber=this.internal.newObject(),this.internal.write("<< /Type /Metadata /Subtype /XML /Length "+e.length+" >>"),this.internal.write("stream"),this.internal.write(e),this.internal.write("endstream"),this.internal.write("endobj")}function xx(){this.internal.__metadata__.metadataObjectNumber&&this.internal.write("/Metadata "+this.internal.__metadata__.metadataObjectNumber+" 0 R")}(function(e){var t,n,r,s,i,c,l,d,h,f=function(A){return A=A||{},this.isStrokeTransparent=A.isStrokeTransparent||!1,this.strokeOpacity=A.strokeOpacity||1,this.strokeStyle=A.strokeStyle||"#000000",this.fillStyle=A.fillStyle||"#000000",this.isFillTransparent=A.isFillTransparent||!1,this.fillOpacity=A.fillOpacity||1,this.font=A.font||"10px sans-serif",this.textBaseline=A.textBaseline||"alphabetic",this.textAlign=A.textAlign||"left",this.lineWidth=A.lineWidth||1,this.lineJoin=A.lineJoin||"miter",this.lineCap=A.lineCap||"butt",this.path=A.path||[],this.transform=A.transform!==void 0?A.transform.clone():new d,this.globalCompositeOperation=A.globalCompositeOperation||"normal",this.globalAlpha=A.globalAlpha||1,this.clip_path=A.clip_path||[],this.currentPoint=A.currentPoint||new c,this.miterLimit=A.miterLimit||10,this.lastPoint=A.lastPoint||new c,this.lineDashOffset=A.lineDashOffset||0,this.lineDash=A.lineDash||[],this.margin=A.margin||[0,0,0,0],this.prevPageLastElemOffset=A.prevPageLastElemOffset||0,this.ignoreClearRect=typeof A.ignoreClearRect!="boolean"||A.ignoreClearRect,this};e.events.push(["initialized",function(){this.context2d=new x(this),t=this.internal.f2,n=this.internal.getCoordinateString,r=this.internal.getVerticalCoordinateString,s=this.internal.getHorizontalCoordinate,i=this.internal.getVerticalCoordinate,c=this.internal.Point,l=this.internal.Rectangle,d=this.internal.Matrix,h=new f}]);var x=function(A){Object.defineProperty(this,"canvas",{get:function(){return{parentNode:!1,style:!1}}});var E=A;Object.defineProperty(this,"pdf",{get:function(){return E}});var z=!1;Object.defineProperty(this,"pageWrapXEnabled",{get:function(){return z},set:function(R){z=!!R}});var X=!1;Object.defineProperty(this,"pageWrapYEnabled",{get:function(){return X},set:function(R){X=!!R}});var Z=0;Object.defineProperty(this,"posX",{get:function(){return Z},set:function(R){isNaN(R)||(Z=R)}});var le=0;Object.defineProperty(this,"posY",{get:function(){return le},set:function(R){isNaN(R)||(le=R)}}),Object.defineProperty(this,"margin",{get:function(){return h.margin},set:function(R){var ze;typeof R=="number"?ze=[R,R,R,R]:((ze=new Array(4))[0]=R[0],ze[1]=R.length>=2?R[1]:ze[0],ze[2]=R.length>=3?R[2]:ze[0],ze[3]=R.length>=4?R[3]:ze[1]),h.margin=ze}});var fe=!1;Object.defineProperty(this,"autoPaging",{get:function(){return fe},set:function(R){fe=R}});var ue=0;Object.defineProperty(this,"lastBreak",{get:function(){return ue},set:function(R){ue=R}});var _e=[];Object.defineProperty(this,"pageBreaks",{get:function(){return _e},set:function(R){_e=R}}),Object.defineProperty(this,"ctx",{get:function(){return h},set:function(R){R instanceof f&&(h=R)}}),Object.defineProperty(this,"path",{get:function(){return h.path},set:function(R){h.path=R}});var Ce=[];Object.defineProperty(this,"ctxStack",{get:function(){return Ce},set:function(R){Ce=R}}),Object.defineProperty(this,"fillStyle",{get:function(){return this.ctx.fillStyle},set:function(R){var ze;ze=b(R),this.ctx.fillStyle=ze.style,this.ctx.isFillTransparent=ze.a===0,this.ctx.fillOpacity=ze.a,this.pdf.setFillColor(ze.r,ze.g,ze.b,{a:ze.a}),this.pdf.setTextColor(ze.r,ze.g,ze.b,{a:ze.a})}}),Object.defineProperty(this,"strokeStyle",{get:function(){return this.ctx.strokeStyle},set:function(R){var ze=b(R);this.ctx.strokeStyle=ze.style,this.ctx.isStrokeTransparent=ze.a===0,this.ctx.strokeOpacity=ze.a,ze.a===0?this.pdf.setDrawColor(255,255,255):(ze.a,this.pdf.setDrawColor(ze.r,ze.g,ze.b))}}),Object.defineProperty(this,"lineCap",{get:function(){return this.ctx.lineCap},set:function(R){["butt","round","square"].indexOf(R)!==-1&&(this.ctx.lineCap=R,this.pdf.setLineCap(R))}}),Object.defineProperty(this,"lineWidth",{get:function(){return this.ctx.lineWidth},set:function(R){isNaN(R)||(this.ctx.lineWidth=R,this.pdf.setLineWidth(R))}}),Object.defineProperty(this,"lineJoin",{get:function(){return this.ctx.lineJoin},set:function(R){["bevel","round","miter"].indexOf(R)!==-1&&(this.ctx.lineJoin=R,this.pdf.setLineJoin(R))}}),Object.defineProperty(this,"miterLimit",{get:function(){return this.ctx.miterLimit},set:function(R){isNaN(R)||(this.ctx.miterLimit=R,this.pdf.setMiterLimit(R))}}),Object.defineProperty(this,"textBaseline",{get:function(){return this.ctx.textBaseline},set:function(R){this.ctx.textBaseline=R}}),Object.defineProperty(this,"textAlign",{get:function(){return this.ctx.textAlign},set:function(R){["right","end","center","left","start"].indexOf(R)!==-1&&(this.ctx.textAlign=R)}});var ve=null,we=null,De=null;Object.defineProperty(this,"fontFaces",{get:function(){return De},set:function(R){ve=null,we=null,De=R}}),Object.defineProperty(this,"font",{get:function(){return this.ctx.font},set:function(R){var ze;if(this.ctx.font=R,(ze=/^\s*(?=(?:(?:[-a-z]+\s*){0,2}(italic|oblique))?)(?=(?:(?:[-a-z]+\s*){0,2}(small-caps))?)(?=(?:(?:[-a-z]+\s*){0,2}(bold(?:er)?|lighter|[1-9]00))?)(?:(?:normal|\1|\2|\3)\s*){0,3}((?:xx?-)?(?:small|large)|medium|smaller|larger|[.\d]+(?:\%|in|[cem]m|ex|p[ctx]))(?:\s*\/\s*(normal|[.\d]+(?:\%|in|[cem]m|ex|p[ctx])))?\s*([-_,\"\'\sa-z0-9]+?)\s*$/i.exec(R))!==null){var ye=ze[1];ze[2];var Ee=ze[3],de=ze[4];ze[5];var Ue=ze[6],qe=/^([.\d]+)((?:%|in|[cem]m|ex|p[ctx]))$/i.exec(de)[2];de=Math.floor(qe==="px"?parseFloat(de)*this.pdf.internal.scaleFactor:qe==="em"?parseFloat(de)*this.pdf.getFontSize():parseFloat(de)*this.pdf.internal.scaleFactor),this.pdf.setFontSize(de);var $e=function(Xe){var Ht,Lt,At=[],kt=Xe.trim();if(kt==="")return Qc;if(kt in cf)return[cf[kt]];for(;kt!=="";){switch(Lt=null,Ht=(kt=uf(kt)).charAt(0)){case'"':case"'":Lt=dx(kt.substring(1),Ht);break;default:Lt=ux(kt)}if(Lt===null||(At.push(Lt[0]),(kt=uf(Lt[1]))!==""&&kt.charAt(0)!==","))return Qc;kt=kt.replace(/^,/,"")}return At}(Ue);if(this.fontFaces){var Ge=function(Xe,Ht){var Lt=Xe.getFontList(),At=JSON.stringify(Lt);if(ve===null||we!==At){var kt=function(an){var it=[];return Object.keys(an).forEach(function(at){an[at].forEach(function(Ve){var ft=null;switch(Ve){case"bold":ft={family:at,weight:"bold"};break;case"italic":ft={family:at,style:"italic"};break;case"bolditalic":ft={family:at,weight:"bold",style:"italic"};break;case"":case"normal":ft={family:at}}ft!==null&&(ft.ref={name:at,style:Ve},it.push(ft))})}),it}(Lt);ve=function(an){for(var it={},at=0;at<an.length;++at){var Ve=Kc(an[at]),ft=Ve.family,wt=Ve.stretch,Nt=Ve.style,Qe=Ve.weight;it[ft]=it[ft]||{},it[ft][wt]=it[ft][wt]||{},it[ft][wt][Nt]=it[ft][wt][Nt]||{},it[ft][wt][Nt][Qe]=Ve}return it}(kt.concat(Ht)),we=At}return ve}(this.pdf,this.fontFaces),bt=$e.map(function(Xe){return{family:Xe,stretch:"normal",weight:Ee,style:ye}}),et=function(Xe,Ht,Lt){for(var At=(Lt=Lt||{}).defaultFontFamily||"times",kt=Object.assign({},cx,Lt.genericFontFamilies||{}),an=null,it=null,at=0;at<Ht.length;++at)if(kt[(an=Kc(Ht[at])).family]&&(an.family=kt[an.family]),Xe.hasOwnProperty(an.family)){it=Xe[an.family];break}if(!(it=it||Xe[At]))throw new Error("Could not find a font-family for the rule '"+df(an)+"' and default family '"+At+"'.");if(it=function(Ve,ft){if(ft[Ve])return ft[Ve];var wt=Ed[Ve],Nt=wt<=Ed.normal?-1:1,Qe=lf(ft,vp,wt,Nt);if(!Qe)throw new Error("Could not find a matching font-stretch value for "+Ve);return Qe}(an.stretch,it),it=function(Ve,ft){if(ft[Ve])return ft[Ve];for(var wt=bp[Ve],Nt=0;Nt<wt.length;++Nt)if(ft[wt[Nt]])return ft[wt[Nt]];throw new Error("Could not find a matching font-style for "+Ve)}(an.style,it),!(it=function(Ve,ft){if(ft[Ve])return ft[Ve];if(Ve===400&&ft[500])return ft[500];if(Ve===500&&ft[400])return ft[400];var wt=lx[Ve],Nt=lf(ft,_p,wt,Ve<400?-1:1);if(!Nt)throw new Error("Could not find a matching font-weight for value "+Ve);return Nt}(an.weight,it)))throw new Error("Failed to resolve a font for the rule '"+df(an)+"'.");return it}(Ge,bt);this.pdf.setFont(et.ref.name,et.ref.style)}else{var Me="";(Ee==="bold"||parseInt(Ee,10)>=700||ye==="bold")&&(Me="bold"),ye==="italic"&&(Me+="italic"),Me.length===0&&(Me="normal");for(var vt="",St={arial:"Helvetica",Arial:"Helvetica",verdana:"Helvetica",Verdana:"Helvetica",helvetica:"Helvetica",Helvetica:"Helvetica","sans-serif":"Helvetica",fixed:"Courier",monospace:"Courier",terminal:"Courier",cursive:"Times",fantasy:"Times",serif:"Times"},Oe=0;Oe<$e.length;Oe++){if(this.pdf.internal.getFont($e[Oe],Me,{noFallback:!0,disableWarning:!0})!==void 0){vt=$e[Oe];break}if(Me==="bolditalic"&&this.pdf.internal.getFont($e[Oe],"bold",{noFallback:!0,disableWarning:!0})!==void 0)vt=$e[Oe],Me="bold";else if(this.pdf.internal.getFont($e[Oe],"normal",{noFallback:!0,disableWarning:!0})!==void 0){vt=$e[Oe],Me="normal";break}}if(vt===""){for(var _t=0;_t<$e.length;_t++)if(St[$e[_t]]){vt=St[$e[_t]];break}}vt=vt===""?"Times":vt,this.pdf.setFont(vt,Me)}}}}),Object.defineProperty(this,"globalCompositeOperation",{get:function(){return this.ctx.globalCompositeOperation},set:function(R){this.ctx.globalCompositeOperation=R}}),Object.defineProperty(this,"globalAlpha",{get:function(){return this.ctx.globalAlpha},set:function(R){this.ctx.globalAlpha=R}}),Object.defineProperty(this,"lineDashOffset",{get:function(){return this.ctx.lineDashOffset},set:function(R){this.ctx.lineDashOffset=R,Ne.call(this)}}),Object.defineProperty(this,"lineDash",{get:function(){return this.ctx.lineDash},set:function(R){this.ctx.lineDash=R,Ne.call(this)}}),Object.defineProperty(this,"ignoreClearRect",{get:function(){return this.ctx.ignoreClearRect},set:function(R){this.ctx.ignoreClearRect=!!R}})};x.prototype.setLineDash=function(A){this.lineDash=A},x.prototype.getLineDash=function(){return this.lineDash.length%2?this.lineDash.concat(this.lineDash):this.lineDash.slice()},x.prototype.fill=function(){B.call(this,"fill",!1)},x.prototype.stroke=function(){B.call(this,"stroke",!1)},x.prototype.beginPath=function(){this.path=[{type:"begin"}]},x.prototype.moveTo=function(A,E){if(isNaN(A)||isNaN(E))throw wn.error("jsPDF.context2d.moveTo: Invalid arguments",arguments),new Error("Invalid arguments passed to 
148jsPDF.context2d.moveTo");var z=this.ctx.transform.applyToPoint(new c(A,E));this.path.push({type:"mt",x:z.x,y:z.y}),this.ctx.lastPoint=new c(A,E)},x.prototype.closePath=function(){var A=new c(0,0),E=0;for(E=this.path.length-1;E!==-1;E--)if(this.path[E].type==="begin"&&pn(this.path[E+1])==="object"&&typeof this.path[E+1].x=="number"){A=new c(this.path[E+1].x,this.path[E+1].y);break}this.path.push({type:"close"}),this.ctx.lastPoint=new c(A.x,A.y)},x.prototype.lineTo=function(A,E){if(isNaN(A)||isNaN(E))throw wn.error("jsPDF.context2d.lineTo: Invalid arguments",arguments),new Error("Invalid arguments passed to jsPDF.context2d.lineTo");var z=this.ctx.transform.applyToPoint(new c(A,E));this.path.push({type:"lt",x:z.x,y:z.y}),this.ctx.lastPoint=new c(z.x,z.y)},x.prototype.clip=function(){this.ctx.clip_path=JSON.parse(JSON.stringify(this.path)),B.call(this,null,!0)},x.prototype.quadraticCurveTo=function(A,E,z,X){if(isNaN(z)||isNaN(X)||isNaN(A)||isNaN(E))throw wn.error("jsPDF.context2d.quadraticCurveTo: Invalid arguments",arguments),new Error("Invalid arguments passed to jsPDF.context2d.quadraticCurveTo");var Z=this.ctx.transform.applyToPoint(new c(z,X)),le=this.ctx.transform.applyToPoint(new c(A,E));this.path.push({type:"qct",x1:le.x,y1:le.y,x:Z.x,y:Z.y}),this.ctx.lastPoint=new c(Z.x,Z.y)},x.prototype.bezierCurveTo=function(A,E,z,X,Z,le){if(isNaN(Z)||isNaN(le)||isNaN(A)||isNaN(E)||isNaN(z)||isNaN(X))throw wn.error("jsPDF.context2d.bezierCurveTo: Invalid arguments",arguments),new Error("Invalid arguments passed to jsPDF.context2d.bezierCurveTo");var fe=this.ctx.transform.applyToPoint(new c(Z,le)),ue=this.ctx.transform.applyToPoint(new c(A,E)),_e=this.ctx.transform.applyToPoint(new c(z,X));this.path.push({type:"bct",x1:ue.x,y1:ue.y,x2:_e.x,y2:_e.y,x:fe.x,y:fe.y}),this.ctx.lastPoint=new c(fe.x,fe.y)},x.prototype.arc=function(A,E,z,X,Z,le){if(isNaN(A)||isNaN(E)||isNaN(z)||isNaN(X)||isNaN(Z))throw wn.error("jsPDF.context2d.arc: Invalid arguments",arguments),new Error("Invalid arguments passed to jsPDF.context2d.arc");if(le=!!le,!this.ctx.transform.isIdentity){var fe=this.ctx.transform.applyToPoint(new c(A,E));A=fe.x,E=fe.y;var ue=this.ctx.transform.applyToPoint(new c(0,z)),_e=this.ctx.transform.applyToPoint(new c(0,0));z=Math.sqrt(Math.pow(ue.x-_e.x,2)+Math.pow(ue.y-_e.y,2))}Math.abs(Z-X)>=2*Math.PI&&(X=0,Z=2*Math.PI),this.path.push({type:"arc",x:A,y:E,radius:z,startAngle:X,endAngle:Z,counterclockwise:le})},x.prototype.arcTo=function(A,E,z,X,Z){throw new Error("arcTo not implemented.")},x.prototype.rect=function(A,E,z,X){if(isNaN(A)||isNaN(E)||isNaN(z)||isNaN(X))throw wn.error("jsPDF.context2d.rect: Invalid arguments",arguments),new Error("Invalid arguments passed to jsPDF.context2d.rect");this.moveTo(A,E),this.lineTo(A+z,E),this.lineTo(A+z,E+X),this.lineTo(A,E+X),this.lineTo(A,E),this.lineTo(A+z,E),this.lineTo(A,E)},x.prototype.fillRect=function(A,E,z,X){if(isNaN(A)||isNaN(E)||isNaN(z)||isNaN(X))throw wn.error("jsPDF.context2d.fillRect: Invalid arguments",arguments),new Error("Invalid arguments passed to jsPDF.context2d.fillRect");if(!m.call(this)){var Z={};this.lineCap!=="butt"&&(Z.lineCap=this.lineCap,this.lineCap="butt"),this.lineJoin!=="miter"&&(Z.lineJoin=this.lineJoin,this.lineJoin="miter"),this.beginPath(),this.rect(A,E,z,X),this.fill(),Z.hasOwnProperty("lineCap")&&(this.lineCap=Z.lineCap),Z.hasOwnProperty("lineJoin")&&(this.lineJoin=Z.lineJoin)}},x.prototype.strokeRect=function(A,E,z,X){if(isNaN(A)||isNaN(E)||isNaN(z)||isNaN(X))throw wn.error("jsPDF.context2d.strokeRect: Invalid arguments",arguments),new Error("Invalid arguments passed to jsPDF.context2d.strokeRect");w.call(this)||(this.beginPath(),this.rect(A,E,z,X),this.stroke())},x.prototype.clearRect=function(A,E,z,X){if(isNaN(A)||isNaN(E)||isNaN(z)||isNaN(X))throw wn.error("jsPDF.context2d.clearRect: Invalid arguments",arguments),new Error("Invalid arguments passed to jsPDF.context2d.clearRect");this.ignoreClearRect||(this.fillStyle="#ffffff",this.fillRect(A,E,z,X))},x.prototype.save=function(A){A=typeof A!="boolean"||A;for(var E=this.pdf.internal.getCurrentPageInfo().pageNumber,z=0;z<this.pdf.internal.getNumberOfPages();z++)this.pdf.setPage(z+1),this.pdf.internal.out("q");
vendor: 4,149 bytes, line 148
148if(this.pdf.setPage(E),A){this.ctx.fontSize=this.pdf.internal.getFontSize();var X=new f(this.ctx);this.ctxStack.push(this.ctx),this.ctx=X}},x.prototype.restore=function(A){A=typeof A!="boolean"||A;for(var E=this.pdf.internal.getCurrentPageInfo().pageNumber,z=0;z<this.pdf.internal.getNumberOfPages();z++)this.pdf.setPage(z+1),this.pdf.internal.out("Q");this.pdf.setPage(E),A&&this.ctxStack.length!==0&&(this.ctx=this.ctxStack.pop(),this.fillStyle=this.ctx.fillStyle,this.strokeStyle=this.ctx.strokeStyle,this.font=this.ctx.font,this.lineCap=this.ctx.lineCap,this.lineWidth=this.ctx.lineWidth,this.lineJoin=this.ctx.lineJoin,this.lineDash=this.ctx.lineDash,this.lineDashOffset=this.ctx.lineDashOffset)},x.prototype.toDataURL=function(){throw new Error("toDataUrl not implemented.")};var b=function(A){var E,z,X,Z;if(A.isCanvasGradient===!0&&(A=A.getColor()),!A)return{r:0,g:0,b:0,a:0,style:A};if(/transparent|rgba\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*0+\s*\)/.test(A))E=0,z=0,X=0,Z=0;else{var le=/rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/.exec(A);if(le!==null)E=parseInt(le[1]),z=parseInt(le[2]),X=parseInt(le[3]),Z=1;else if((le=/rgba\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*([\d.]+)\s*\)/.exec(A))!==null)E=parseInt(le[1]),z=parseInt(le[2]),X=parseInt(le[3]),Z=parseFloat(le[4]);else{if(Z=1,typeof A=="string"&&A.charAt(0)!=="#"){var fe=new hp(A);A=fe.ok?fe.toHex():"#000000"}A.length===4?(E=A.substring(1,2),E+=E,z=A.substring(2,3),z+=z,X=A.substring(3,4),X+=X):(E=A.substring(1,3),z=A.substring(3,5),X=A.substring(5,7)),E=parseInt(E,16),z=parseInt(z,16),X=parseInt(X,16)}}return{r:E,g:z,b:X,a:Z,style:A}},m=function(){return this.ctx.isFillTransparent||this.globalAlpha==0},w=function(){return!!(this.ctx.isStrokeTransparent||this.globalAlpha==0)};x.prototype.fillText=function(A,E,z,X){if(isNaN(E)||isNaN(z)||typeof A!="string")throw wn.error("jsPDF.context2d.fillText: Invalid arguments",arguments),new Error("Invalid arguments passed to jsPDF.context2d.fillText");if(X=isNaN(X)?void 0:X,!m.call(this)){var Z=K(this.ctx.transform.rotation),le=this.ctx.transform.scaleX;I.call(this,{text:A,x:E,y:z,scale:le,angle:Z,align:this.textAlign,maxWidth:X})}},x.prototype.strokeText=function(A,E,z,X){if(isNaN(E)||isNaN(z)||typeof A!="string")throw wn.error("jsPDF.context2d.strokeText: Invalid arguments",arguments),new Error("Invalid arguments passed to jsPDF.context2d.strokeText");if(!w.call(this)){X=isNaN(X)?void 0:X;var Z=K(this.ctx.transform.rotation),le=this.ctx.transform.scaleX;I.call(this,{text:A,x:E,y:z,scale:le,renderingMode:"stroke",angle:Z,align:this.textAlign,maxWidth:X})}},x.prototype.measureText=function(A){if(typeof A!="string")throw wn.error("jsPDF.context2d.measureText: Invalid arguments",arguments),new Error("Invalid arguments passed to jsPDF.context2d.measureText");var E=this.pdf,z=this.pdf.internal.scaleFactor,X=E.internal.getFontSize(),Z=E.getStringUnitWidth(A)*X/E.internal.scaleFactor;return new function(le){var fe=(le=le||{}).width||0;return Object.defineProperty(this,"width",{get:function(){return fe}}),this}({width:Z*=Math.round(96*z/72*1e4)/1e4})},x.prototype.scale=function(A,E){if(isNaN(A)||isNaN(E))throw wn.error("jsPDF.context2d.scale: Invalid arguments",arguments),new Error("Invalid arguments passed to jsPDF.context2d.scale");var z=new d(A,0,0,E,0,0);this.ctx.transform=this.ctx.transform.multiply(z)},x.prototype.rotate=function(A){if(isNaN(A))throw wn.error("jsPDF.context2d.rotate: Invalid arguments",arguments),new Error("Invalid arguments passed to jsPDF.context2d.rotate");var E=new d(Math.cos(A),Math.sin(A),-Math.sin(A),Math.cos(A),0,0);this.ctx.transform=this.ctx.transform.multiply(E)},x.prototype.translate=function(A,E){if(isNaN(A)||isNaN(E))throw wn.error("jsPDF.context2d.translate: Invalid arguments",arguments),new Error("Invalid arguments passed to jsPDF.context2d.translate");var z=new d(1,0,0,1,A,E);this.ctx.transform=this.ctx.transform.multiply(z)},x.prototype.transform=function(A,E,z,X,Z,le){if(isNaN(A)||isNaN(E)||isNaN(z)||isNaN(X)||isNaN(Z)||isNaN(le))throw wn.error("jsPDF.context2d.transform: Invalid arguments",arguments),new Error("Invalid arguments passed to 
148jsPDF.context2d.transform");var fe=new d(A,E,z,X,Z,le);this.ctx.transform=this.ctx.transform.multiply(fe)},x.prototype.setTransform=function(A,E,z,X,Z,le){A=isNaN(A)?1:A,E=isNaN(E)?0:E,z=isNaN(z)?0:z,X=isNaN(X)?1:X,Z=isNaN(Z)?0:Z,le=isNaN(le)?0:le,this.ctx.transform=new d(A,E,z,X,Z,le)};var v=function(){return this.margin[0]>0||this.margin[1]>0||this.margin[2]>0||this.margin[3]>0};x.prototype.drawImage=function(A,E,z,X,Z,le,fe,ue,_e){var Ce=this.pdf.getImageProperties(A),ve=1,we=1,De=1,R=1;X!==void 0&&ue!==void 0&&(De=ue/X,R=_e/Z,ve=Ce.width/X*ue/X,we=Ce.height/Z*_e/Z),le===void 0&&(le=E,fe=z,E=0,z=0),X!==void 0&&ue===void 0&&(ue=X,_e=Z),X===void 0&&ue===void 0&&(ue=Ce.width,_e=Ce.height);var ze=this.ctx.transform.decompose(),ye=K(ze.rotate.shx),Ee=new d,de=(Ee=(Ee=(Ee=Ee.multiply(ze.translate)).multiply(ze.skew)).multiply(ze.scale)).applyToRectangle(new l(le-E*De,fe-z*R,X*ve,Z*we));if(this.autoPaging){for(var Ue,qe=P.call(this,de),$e=[],Ge=0;Ge<qe.length;Ge+=1)$e.indexOf(qe[Ge])===-1&&$e.push(qe[Ge]);T($e);for(var bt=$e[0],et=$e[$e.length-1],Me=bt;Me<et+1;Me++){this.pdf.setPage(Me);var vt=this.pdf.internal.pageSize.width-this.margin[3]-this.margin[1],St=Me===1?this.posY+this.margin[0]:this.margin[0],Oe=this.pdf.internal.pageSize.height-this.posY-this.margin[0]-this.margin[2],_t=this.pdf.internal.pageSize.height-this.margin[0]-this.margin[2],Xe=Me===1?0:Oe+(Me-2)*_t;if(this.ctx.clip_path.length!==0){var Ht=this.path;Ue=JSON.parse(JSON.stringify(this.ctx.clip_path)),this.path=q(Ue,this.posX+this.margin[3],-Xe+St+this.ctx.prevPageLastElemOffset),Q.call(this,"fill",!0),this.path=Ht}var Lt=JSON.parse(JSON.stringify(de));Lt=q([Lt],this.posX+this.margin[3],-Xe+St+this.ctx.prevPageLastElemOffset)[0];var At=(Me>bt||Me<et)&&v.call(this);At&&(this.pdf.saveGraphicsState(),this.pdf.rect(this.margin[3],this.margin[0],vt,_t,null).clip().discardPath()),this.pdf.addImage(A,"JPEG",Lt.x,Lt.y,Lt.w,Lt.h,null,null,ye),At&&this.pdf.restoreGraphicsState()}}else this.pdf.addImage(A,"JPEG",de.x,de.y,de.w,de.h,null,null,ye)};var P=function(A,E,z){var X=[];E=E||this.pdf.internal.pageSize.width,z=z||this.pdf.internal.pageSize.height-this.margin[0]-this.margin[2];var Z=this.posY+this.ctx.prevPageLastElemOffset;switch(A.type){default:case"mt":case"lt":X.push(Math.floor((A.y+Z)/z)+1);break;case"arc":X.push(Math.floor((A.y+Z-A.radius)/z)+1),X.push(Math.floor((A.y+Z+A.radius)/z)+1);break;case"qct":var le=ae(this.ctx.lastPoint.x,this.ctx.lastPoint.y,A.x1,A.y1,A.x,A.y);X.push(Math.floor((le.y+Z)/z)+1),X.push(Math.floor((le.y+le.h+Z)/z)+1);break;case"bct":var fe=be(this.ctx.lastPoint.x,this.ctx.lastPoint.y,A.x1,A.y1,A.x2,A.y2,A.x,A.y);X.push(Math.floor((fe.y+Z)/z)+1),X.push(Math.floor((fe.y+fe.h+Z)/z)+1);break;case"rect":X.push(Math.floor((A.y+Z)/z)+1),X.push(Math.floor((A.y+A.h+Z)/z)+1)}for(var ue=0;ue<X.length;ue+=1)for(;this.pdf.internal.getNumberOfPages()<X[ue];)_.call(this);return X},_=function(){var A=this.fillStyle,E=this.strokeStyle,z=this.font,X=this.lineCap,Z=this.lineWidth,le=this.lineJoin;this.pdf.addPage(),this.fillStyle=A,this.strokeStyle=E,this.font=z,this.lineCap=X,this.lineWidth=Z,this.lineJoin=le},q=function(A,E,z){for(var X=0;X<A.length;X++)switch(A[X].type){case"bct":A[X].x2+=E,A[X].y2+=z;case"qct":A[X].x1+=E,A[X].y1+=z;default:A[X].x+=E,A[X].y+=z}return A},T=function(A){return A.sort(function(E,z){return E-z})},B=function(A,E){var z=this.fillStyle,X=this.strokeStyle,Z=this.lineCap,le=this.lineWidth,fe=Math.abs(le*this.ctx.transform.scaleX),ue=this.lineJoin;if(this.autoPaging){for(var _e,Ce,ve=JSON.parse(JSON.stringify(this.path)),we=JSON.parse(JSON.stringify(this.path)),De=[],R=0;R<we.length;R++)if(we[R].x!==void 0)for(var ze=P.call(this,we[R]),ye=0;ye<ze.length;ye+=1)De.indexOf(ze[ye])===-1&&De.push(ze[ye]);for(var Ee=0;Ee<De.length;Ee++)for(;this.pdf.internal.getNumberOfPages()<De[Ee];)_.call(this);T(De);for(var de=De[0],Ue=De[De.length-1],qe=de;qe<Ue+1;qe++){this.pdf.setPage(qe),this.fillStyle=z,this.strokeStyle=X,this.lineCap=Z,this.lineWidth=fe,this.lineJoin=ue;var $e=this.pdf.internal.pageSize.width-this.margin[3]-this.margin[1],Ge=qe===1?this.posY+this.margin[0]:this.margin[0],bt=this.pdf.internal.pageSize.height-this.posY-this.margin[0]-this.margin[2],et=this.pdf.internal.pageSize.height-this.margin[0]-this.margin[2],Me=qe===1?0:bt+(qe-2)*et;if(this.ctx.clip_path.length!==0){var vt=this.path;_e=JSON.parse(JSON.stringify(this.ctx.clip_path)),this.path=q(_e,this.posX+this.margin[3],-Me+Ge+this.ctx.prevPageLastElemOffset),Q.call(this,A,!0),this.path=vt}if(Ce=JSON.parse(JSON.stringify(ve)),this.path=q(Ce,this.posX+this.margin[3],-Me+Ge+this.ctx.prevPageLastElemOffset),E===!1||qe===0){var St=(qe>de||qe<Ue)&&v.call(this);St&&(this.pdf.saveGraphicsState(),this.pdf.rect(this.margin[3],this.margin[0],$e,et,null).clip().discardPath()),Q.call(this,A,E),St&&this.pdf.restoreGraphicsState()}this.lineWidth=le}this.path=ve}else this.lineWidth=fe,Q.call(this,A,E),this.lineWidth=le},Q=function(A,E){if((A!=="stroke"||E||!w.call(this))&&(A==="stroke"||E||!m.call(this))){for(var z,X,Z=[],le=this.path,fe=0;fe<le.length;fe++){var ue=le[fe];switch(ue.type){case"begin":Z.push({begin:!0}
vendor: 36,377 bytes, lines 148-154
148);break;case"close":Z.push({close:!0});break;case"mt":Z.push({start:ue,deltas:[],abs:[]});break;case"lt":var _e=Z.length;if(le[fe-1]&&!isNaN(le[fe-1].x)&&(z=[ue.x-le[fe-1].x,ue.y-le[fe-1].y],_e>0)){for(;_e>=0;_e--)if(Z[_e-1].close!==!0&&Z[_e-1].begin!==!0){Z[_e-1].deltas.push(z),Z[_e-1].abs.push(ue);break}}break;case"bct":z=[ue.x1-le[fe-1].x,ue.y1-le[fe-1].y,ue.x2-le[fe-1].x,ue.y2-le[fe-1].y,ue.x-le[fe-1].x,ue.y-le[fe-1].y],Z[Z.length-1].deltas.push(z);break;case"qct":var Ce=le[fe-1].x+2/3*(ue.x1-le[fe-1].x),ve=le[fe-1].y+2/3*(ue.y1-le[fe-1].y),we=ue.x+2/3*(ue.x1-ue.x),De=ue.y+2/3*(ue.y1-ue.y),R=ue.x,ze=ue.y;z=[Ce-le[fe-1].x,ve-le[fe-1].y,we-le[fe-1].x,De-le[fe-1].y,R-le[fe-1].x,ze-le[fe-1].y],Z[Z.length-1].deltas.push(z);break;case"arc":Z.push({deltas:[],abs:[],arc:!0}),Array.isArray(Z[Z.length-1].abs)&&Z[Z.length-1].abs.push(ue)}}X=E?null:A==="stroke"?"stroke":"fill";for(var ye=!1,Ee=0;Ee<Z.length;Ee++)if(Z[Ee].arc)for(var de=Z[Ee].abs,Ue=0;Ue<de.length;Ue++){var qe=de[Ue];qe.type==="arc"?$.call(this,qe.x,qe.y,qe.radius,qe.startAngle,qe.endAngle,qe.counterclockwise,void 0,E,!ye):k.call(this,qe.x,qe.y),ye=!0}else if(Z[Ee].close===!0)this.pdf.internal.out("h"),ye=!1;else if(Z[Ee].begin!==!0){var $e=Z[Ee].start.x,Ge=Z[Ee].start.y;L.call(this,Z[Ee].deltas,$e,Ge),ye=!0}X&&D.call(this,X),E&&Y.call(this)}},me=function(A){var E=this.pdf.internal.getFontSize()/this.pdf.internal.scaleFactor,z=E*(this.pdf.internal.getLineHeightFactor()-1);switch(this.ctx.textBaseline){case"bottom":return A-z;case"top":return A+E-z;case"hanging":return A+E-2*z;case"middle":return A+E/2-z;default:return A}},ce=function(A){return A+this.pdf.internal.getFontSize()/this.pdf.internal.scaleFactor*(this.pdf.internal.getLineHeightFactor()-1)};x.prototype.createLinearGradient=function(){var A=function(){};return A.colorStops=[],A.addColorStop=function(E,z){this.colorStops.push([E,z])},A.getColor=function(){return this.colorStops.length===0?"#000000":this.colorStops[0][1]},A.isCanvasGradient=!0,A},x.prototype.createPattern=function(){return this.createLinearGradient()},x.prototype.createRadialGradient=function(){return this.createLinearGradient()};var $=function(A,E,z,X,Z,le,fe,ue,_e){for(var Ce=te.call(this,z,X,Z,le),ve=0;ve<Ce.length;ve++){var we=Ce[ve];ve===0&&(_e?N.call(this,we.x1+A,we.y1+E):k.call(this,we.x1+A,we.y1+E)),H.call(this,A,E,we.x2,we.y2,we.x3,we.y3,we.x4,we.y4)}ue?Y.call(this):D.call(this,fe)},D=function(A){switch(A){case"stroke":this.pdf.internal.out("S");break;case"fill":this.pdf.internal.out("f")}},Y=function(){this.pdf.clip(),this.pdf.discardPath()},N=function(A,E){this.pdf.internal.out(n(A)+" "+r(E)+" m")},I=function(A){var E;switch(A.align){case"right":case"end":E="right";break;case"center":E="center";break;default:E="left"}var z,X,Z,le=this.pdf.getTextDimensions(A.text),fe=me.call(this,A.y),ue=ce.call(this,fe)-le.h,_e=this.ctx.transform.applyToPoint(new c(A.x,fe));if(this.autoPaging){var Ce=this.ctx.transform.decompose(),ve=new d;ve=(ve=(ve=ve.multiply(Ce.translate)).multiply(Ce.skew)).multiply(Ce.scale);for(var we=this.ctx.transform.applyToRectangle(new l(A.x,fe,le.w,le.h)),De=ve.applyToRectangle(new l(A.x,ue,le.w,le.h)),R=P.call(this,De),ze=[],ye=0;ye<R.length;ye+=1)ze.indexOf(R[ye])===-1&&ze.push(R[ye]);T(ze);for(var Ee=ze[0],de=ze[ze.length-1],Ue=Ee;Ue<de+1;Ue++){this.pdf.setPage(Ue);var qe=Ue===1?this.posY+this.margin[0]:this.margin[0],$e=this.pdf.internal.pageSize.height-this.posY-this.margin[0]-this.margin[2],Ge=this.pdf.internal.pageSize.height-this.margin[2],bt=Ge-this.margin[0],et=this.pdf.internal.pageSize.width-this.margin[1],Me=et-this.margin[3],vt=Ue===1?0:$e+(Ue-2)*bt;if(this.ctx.clip_path.length!==0){var St=this.path;z=JSON.parse(JSON.stringify(this.ctx.clip_path)),this.path=q(z,this.posX+this.margin[3],-1*vt+qe),Q.call(this,"fill",!0),this.path=St}var Oe=q([JSON.parse(JSON.stringify(De))],this.posX+this.margin[3],-vt+qe+this.ctx.prevPageLastElemOffset)[0];A.scale>=.01&&(X=this.pdf.internal.getFontSize(),this.pdf.setFontSize(X*A.scale),Z=this.lineWidth,this.lineWidth=Z*A.scale);var _t=this.autoPaging!=="text";if(_t||Oe.y+Oe.h<=Ge){if(_t||Oe.y>=qe&&Oe.x<=et){var Xe=_t?A.text:this.pdf.splitTextToSize(A.text,A.maxWidth||et-Oe.x)[0],Ht=q([JSON.parse(JSON.stringify(we))],this.posX+this.margin[3],-vt+qe+this.ctx.prevPageLastElemOffset)[0],Lt=_t&&(Ue>Ee||Ue<de)&&v.call(this);Lt&&(this.pdf.saveGraphicsState(),this.pdf.rect(this.margin[3],this.margin[0],Me,bt,null).clip().discardPath()),this.pdf.text(Xe,Ht.x,Ht.y,{angle:A.angle,align:E,renderingMode:A.renderingMode}),Lt&&this.pdf.restoreGraphicsState()}}else Oe.y<Ge&&(this.ctx.prevPageLastElemOffset+=Ge-Oe.y);A.scale>=.01&&(this.pdf.setFontSize(X),this.lineWidth=Z)}}else A.scale>=.01&&(X=this.pdf.internal.getFontSize(),this.pdf.setFontSize(X*A.scale),Z=this.lineWidth,this.lineWidth=Z*A.scale),this.pdf.text(A.text,_e.x+this.posX,_e.y+this.posY,{angle:A.angle,align:E,renderingMode:A.renderingMode,maxWidth:A.maxWidth}),A.scale>=.01&&(this.pdf.setFontSize(X),this.lineWidth=Z)},k=function(A,E,z,X){z=z||0,X=X||0,this.pdf.internal.out(n(A+z)+" "+r(E+X)+" l")},L=function(A,E,z){return this.pdf.lines(A,E,z,null,null)},H=function(A,E,z,X,Z,le,fe,ue){this.pdf.internal.out([t(s(z+A)),t(i(X+E)),t(s(Z+A)),t(i(le+E)),t(s(fe+A)),t(i(ue+E)),"c"].join(" "))},te=function(A,E,z,X){for(var Z=2*Math.PI,le=Math.PI/2;E>z;)E-=Z;var fe=Math.abs(z-E);fe<Z&&X&&(fe=Z-fe);for(var ue=[],_e=X?-1:1,Ce=E;fe>1e-5;){var ve=Ce+_e*Math.min(fe,le);ue.push(se.call(this,A,Ce,ve)),fe-=Math.abs(ve-Ce),Ce=ve}return ue},se=function(A,E,z){var X=(z-E)/2,Z=A*Math.cos(X),le=A*Math.sin(X),fe=Z,ue=-le,_e=fe*fe+ue*ue,Ce=_e+fe*Z+ue*le,ve=4/3*(Math.sqrt(2*_e*Ce)-Ce)/(fe*le-ue*Z),we=fe-ve*ue,De=ue+ve*fe,R=we,ze=-De,ye=X+E,Ee=Math.cos(ye),de=Math.sin(ye);return{x1:A*Math.cos(E),y1:A*Math.sin(E),x2:we*Ee-De*de,y2:we*de+De*Ee,x3:R*Ee-ze*de,y3:R*de+ze*Ee,x4:A*Math.cos(z),y4:A*Math.sin(z)}},K=function(A){return 180*A/Math.PI},ae=function(A,E,z,X,Z,le){var fe=A+.5*(z-A),ue=E+.5*(X-E),_e=Z+.5*(z-Z),Ce=le+.5*(X-le),ve=Math.min(A,Z,fe,_e),we=Math.max(A,Z,fe,_e),De=Math.min(E,le,ue,Ce),R=Math.max(E,le,ue,Ce);return new l(ve,De,we-ve,R-De)},be=function(A,E,z,X,Z,le,fe,ue){var _e,Ce,ve,we,De,R,ze,ye,Ee,de,Ue,qe,$e,Ge,bt=z-A,et=X-E,Me=Z-z,vt=le-X,St=fe-Z,Oe=ue-le;for(Ce=0;Ce<41;Ce++)Ee=(ze=(ve=A+(_e=Ce/40)*bt)+_e*((De=z+_e*Me)-ve))+_e*(De+_e*(Z+_e*St-De)-ze),de=(ye=(we=E+_e*et)+_e*((R=X+_e*vt)-we))+_e*(R+_e*(le+_e*Oe-R)-ye),Ce==0?(Ue=Ee,qe=de,$e=Ee,Ge=de):(Ue=Math.min(Ue,Ee),qe=Math.min(qe,de),$e=Math.max($e,Ee),Ge=Math.max(Ge,de));return new l(Math.round(Ue),Math.round(qe),Math.round($e-Ue),Math.round(Ge-qe))},Ne=function(){if(this.prevLineDash||this.ctx.lineDash.length||this.ctx.lineDashOffset){var A,E,z=(A=this.ctx.lineDash,E=this.ctx.lineDashOffset,JSON.stringify({lineDash:A,lineDashOffset:E}));this.prevLineDash!==z&&(this.pdf.setLineDash(this.ctx.lineDash,this.ctx.lineDashOffset),this.prevLineDash=z)}}})(yt.API),function(e){var t=function(c){var l,d,h,f,x,b,m,w,v,P;for(d=[],h=0,f=(c+=l="\0\0\0\0".slice(c.length%4||4)).length;f>h;h+=4)(x=(c.charCodeAt(h)<<24)+(c.charCodeAt(h+1)<<16)+(c.charCodeAt(h+2)<<8)+c.charCodeAt(h+3))!==0?(b=(x=((x=((x=((x=(x-(P=x%85))/85)-(v=x%85))/85)-(w=x%85))/85)-(m=x%85))/85)%85,d.push(b+33,m+33,w+33,v+33,P+33)):d.push(122);return function(_,q){for(var T=q;T>0;T--)_.pop()}(d,l.length),String.fromCharCode.apply(String,d)+"~>"},n=function(c){var l,d,h,f,x,b=String,m="length",w=255,v="charCodeAt",P="slice",_="replace";for(c[P](-2),c=c[P](0,-2)[_](/\s/g,"")[_]("z","!!!!!"),h=[],f=0,x=(c+=l="uuuuu"[P](c[m]%5||5))[m];x>f;f+=5)d=52200625*(c[v](f)-33)+614125*(c[v](f+1)-33)+7225*(c[v](f+2)-33)+85*(c[v](f+3)-33)+(c[v](f+4)-33),h.push(w&d>>24,w&d>>16,w&d>>8,w&d);return function(q,T){for(var B=T;B>0;B--)q.pop()}(h,l[m]),b.fromCharCode.apply(b,h)},r=function(c){return c.split("").map(function(l){return("0"+l.charCodeAt().toString(16)).slice(-2)}).join("")+">"},s=function(c){var l=new RegExp(/^([0-9A-Fa-f]{2})+$/);if((c=c.replace(/\s/g,"")).indexOf(">")!==-1&&(c=c.substr(0,c.indexOf(">"))),c.length%2&&(c+="0"),l.test(c)===!1)return"";for(var d="",h=0;h<c.length;h+=2)d+=String.fromCharCode("0x"+(c[h]+c[h+1]));return d},i=function(c){for(var l=new Uint8Array(c.length),d=c.length;d--;)l[d]=c.charCodeAt(d);return(l=jd(l)).reduce(function(h,f){return h+String.fromCharCode(f)},"")};e.processDataByFilters=function(c,l){var d=0,h=c||"",f=[];for(typeof(l=l||[])=="string"&&(l=[l]),d=0;d<l.length;d+=1)switch(l[d]){case"ASCII85Decode":case"/ASCII85Decode":h=n(h),f.push("/ASCII85Encode");break;case"ASCII85Encode":case"/ASCII85Encode":h=t(h),f.push("/ASCII85Decode");break;case"ASCIIHexDecode":case"/ASCIIHexDecode":h=s(h),f.push("/ASCIIHexEncode");break;case"ASCIIHexEncode":case"/ASCIIHexEncode":h=r(h),f.push("/ASCIIHexDecode");break;case"FlateEncode":case"/FlateEncode":h=i(h),f.push("/FlateDecode");break;default:throw new Error('The filter: "'+l[d]+'" is not implemented')}return{data:h,reverseChain:f.reverse().join(" ")}}}(yt.API),function(e){e.loadFile=function(t,n,r){return function(s,i,c){i=i!==!1,c=typeof c=="function"?c:function(){};var l=void 0;try{l=function(d,h,f){var x=new XMLHttpRequest,b=0,m=function(w){var v=w.length,P=[],_=String.fromCharCode;for(b=0;b<v;b+=1)P.push(_(255&w.charCodeAt(b)));return P.join("")};if(x.open("GET",d,!h),x.overrideMimeType("text/plain; charset=x-user-defined"),h===!1&&(x.onload=function(){x.status===200?f(m(this.responseText)):f(void 0)}),x.send(null),h&&x.status===200)return m(x.responseText)}(s,i,c)}catch{}return l}(t,n,r)},e.allowFsRead=void 0,e.loadImageFile=e.loadFile}(yt.API),function(e){function t(){return(Mt.html2canvas?Promise.resolve(Mt.html2canvas):Lc(()=>import("./html2canvas.esm-CBrSDip1.js"),[])).catch(function(l){return Promise.reject(new Error("Could not load html2canvas: "+l))}).then(function(l){return l.default?l.default:l})}function n(){return(Mt.DOMPurify?Promise.resolve(Mt.DOMPurify):Lc(()=>import("./index-7KGHoeDr.js").then(l=>l.dl),__vite__mapDeps([0,1]))).catch(function(l){return Promise.reject(new Error("Could not load dompurify: "+l))}).then(function(l){return l.default?l.default:l})}var r=function(l){var d=pn(l);return d==="undefined"?"undefined":d==="string"||l instanceof String?"string":d==="number"||l instanceof Number?"number":d==="function"||l instanceof Function?"function":l&&l.constructor===Array?"array":l&&l.nodeType===1?"element":d==="object"?"object":"unknown"},s=function(l,d){var h=document.createElement(l);for(var f in d.className&&(h.className=d.className),d.innerHTML&&d.dompurify&&(h.innerHTML=d.dompurify.sanitize(d.innerHTML)),d.style)h.style[f]=d.style[f];return h},i=function l(d,h){for(var f=d.nodeType===3?document.createTextNode(d.nodeValue):d.cloneNode(!1),x=d.firstChild;x;x=x.nextSibling)h!==!0&&x.nodeType===1&&x.nodeName==="SCRIPT"||f.appendChild(l(x,h));return d.nodeType===1&&(d.nodeName==="CANVAS"?(f.width=d.width,f.height=d.height,f.getContext("2d").drawImage(d,0,0)):d.nodeName!=="TEXTAREA"&&d.nodeName!=="SELECT"||(f.value=d.value),f.addEventListener("load",function(){f.scrollTop=d.scrollTop,f.scrollLeft=d.scrollLeft},!0)),f},c=function l(d){var h=Object.assign(l.convert(Promise.resolve()),JSON.parse(JSON.stringify(l.template))),f=l.convert(Promise.resolve(),h);return(f=f.setProgress(1,l,1,[l])).set(d)};(c.prototype=Object.create(Promise.prototype)).constructor=c,c.convert=function(l,d){return l.__proto__=d||c.prototype,l},c.template={prop:{src:null,container:null,overlay:null,canvas:null,img:null,pdf:null,pageSize:null,callback:function(){}},progress:{val:0,state:null,n:0,stack:[]},opt:{filename:"file.pdf",margin:[0,0,0,0],enableLinks:!0,x:0,y:0,html2canvas:{},jsPDF:{},backgroundColor:"transparent"}},c.prototype.from=function(l,d){return this.then(function(){switch(d=d||function(h){switch(r(h)){case"string":return"string";case"element":return h.nodeName.toLowerCase()==="canvas"?"canvas":"element";default:return"unknown"}}(l),d){case"string":return this.then(n).then(function(h){return this.set({src:s("div",{innerHTML:l,dompurify:h})})});case"element":return this.set({src:l});case"canvas":return this.set({canvas:l});case"img":return this.set({img:l});default:return this.error("Unknown source type.")}})},c.prototype.to=function(l){switch(l){case"container":return this.toContainer();case"canvas":return this.toCanvas();case"img":return this.toImg();case"pdf":return this.toPdf();default:return this.error("Invalid target.")}},c.prototype.toContainer=function(){return this.thenList([function(){return this.prop.src||this.error("Cannot duplicate - no source HTML.")},function(){return this.prop.pageSize||this.setPageSize()}]).then(function(){var l={position:"relative",display:"inline-block",width:(typeof this.opt.width!="number"||isNaN(this.opt.width)||typeof this.opt.windowWidth!="number"||isNaN(this.opt.windowWidth)?Math.max(this.prop.src.clientWidth,this.prop.src.scrollWidth,this.prop.src.offsetWidth):this.opt.windowWidth)+"px",left:0,right:0,top:0,margin:"auto",backgroundColor:this.opt.backgroundColor},d=i(this.prop.src,this.opt.html2canvas.javascriptEnabled);d.tagName==="BODY"&&(l.height=Math.max(document.body.scrollHeight,document.body.offsetHeight,document.documentElement.clientHeight,document.documentElement.scrollHeight,document.documentElement.offsetHeight)+"px"),this.prop.overlay=s("div",{className:"html2pdf__overlay",style:{position:"fixed",overflow:"hidden",zIndex:1e3,left:"-100000px",right:0,bottom:0,top:0}}),this.prop.container=s("div",{className:"html2pdf__container",style:l}),this.prop.container.appendChild(d),this.prop.container.firstChild.appendChild(s("div",{style:{clear:"both",border:"0 none transparent",margin:0,padding:0,height:0}})),this.prop.container.style.float="none",this.prop.overlay.appendChild(this.prop.container),document.body.appendChild(this.prop.overlay),this.prop.container.firstChild.style.position="relative",this.prop.container.height=Math.max(this.prop.container.firstChild.clientHeight,this.prop.container.firstChild.scrollHeight,this.prop.container.firstChild.offsetHeight)+"px"})},c.prototype.toCanvas=function(){var l=[function(){return document.body.contains(this.prop.container)||this.toContainer()}];return this.thenList(l).then(t).then(function(d){var h=Object.assign({},this.opt.html2canvas);return delete h.onrendered,d(this.prop.container,h)}).then(function(d){(this.opt.html2canvas.onrendered||function(){})(d),this.prop.canvas=d,document.body.removeChild(this.prop.overlay)})},c.prototype.toContext2d=function(){var l=[function(){return document.body.contains(this.prop.container)||this.toContainer()}];return this.thenList(l).then(t).then(function(d){var h=this.opt.jsPDF,f=this.opt.fontFaces,x=typeof this.opt.width!="number"||isNaN(this.opt.width)||typeof this.opt.windowWidth!="number"||isNaN(this.opt.windowWidth)?1:this.opt.width/this.opt.windowWidth,b=Object.assign({async:!0,allowTaint:!0,scale:x,scrollX:this.opt.scrollX||0,scrollY:this.opt.scrollY||0,backgroundColor:"#ffffff",imageTimeout:15e3,logging:!0,proxy:null,removeContainer:!0,foreignObjectRendering:!1,useCORS:!1},this.opt.html2canvas);if(delete b.onrendered,h.context2d.autoPaging=this.opt.autoPaging===void 0||this.opt.autoPaging,h.context2d.posX=this.opt.x,h.context2d.posY=this.opt.y,h.context2d.margin=this.opt.margin,h.context2d.fontFaces=f,f)for(var m=0;m<f.length;++m){var w=f[m],v=w.src.find(function(P){return P.format==="truetype"});v&&h.addFont(v.url,w.ref.name,w.ref.style)}return b.windowHeight=b.windowHeight||0,b.windowHeight=b.windowHeight==0?Math.max(this.prop.container.clientHeight,this.prop.container.scrollHeight,this.prop.container.offsetHeight):b.windowHeight,h.context2d.save(!0),d(this.prop.container,b)}).then(function(d){this.opt.jsPDF.context2d.restore(!0),(this.opt.html2canvas.onrendered||function(){})(d),this.prop.canvas=d,document.body.removeChild(this.prop.overlay)})},c.prototype.toImg=function(){return this.thenList([function(){return this.prop.canvas||this.toCanvas()}]).then(function(){var l=this.prop.canvas.toDataURL("image/"+this.opt.image.type,this.opt.image.quality);this.prop.img=document.createElement("img"),this.prop.img.src=l})},c.prototype.toPdf=function(){return this.thenList([function(){return this.toContext2d()}]).then(function(){this.prop.pdf=this.prop.pdf||this.opt.jsPDF})},c.prototype.output=function(l,d,h){return(h=h||"pdf").toLowerCase()==="img"||h.toLowerCase()==="image"?this.outputImg(l,d):this.outputPdf(l,d)},c.prototype.outputPdf=function(l,d){return this.thenList([function(){return this.prop.pdf||this.toPdf()}]).then(function(){return this.prop.pdf.output(l,d)})},c.prototype.outputImg=function(l){return this.thenList([function(){return this.prop.img||this.toImg()}]).then(function(){switch(l){case void 0:case"img":return this.prop.img;case"datauristring":case"dataurlstring":return this.prop.img.src;case"datauri":case"dataurl":return document.location.href=this.prop.img.src;default:throw'Image output type "'+l+'" is not supported.'}})},c.prototype.save=function(l){return this.thenList([function(){return this.prop.pdf||this.toPdf()}]).set(l?{filename:l}:null).then(function(){this.prop.pdf.save(this.opt.filename)})},c.prototype.doCallback=function(){return this.thenList([function(){return this.prop.pdf||this.toPdf()}]).then(function(){this.prop.callback(this.prop.pdf)})},c.prototype.set=function(l){if(r(l)!=="object")return this;var d=Object.keys(l||{}).map(function(h){if(h in c.template.prop)return function(){this.prop[h]=l[h]};switch(h){case"margin":return this.setMargin.bind(this,l.margin);case"jsPDF":return function(){return this.opt.jsPDF=l.jsPDF,this.setPageSize()};case"pageSize":return this.setPageSize.bind(this,l.pageSize);default:return function(){this.opt[h]=l[h]}}},this);return this.then(function(){return this.thenList(d)})},c.prototype.get=function(l,d){return this.then(function(){var h=l in c.template.prop?this.prop[l]:this.opt[l];return d?d(h):h})},c.prototype.setMargin=function(l){return this.then(function(){switch(r(l)){case"number":l=[l,l,l,l];case"array":if(l.length===2&&(l=[l[0],l[1],l[0],l[1]]),l.length===4)break;default:return this.error("Invalid margin array.")}this.opt.margin=l}).then(this.setPageSize)},c.prototype.setPageSize=function(l){function d(h,f){return Math.floor(h*f/72*96)}return this.then(function(){(l=l||yt.getPageSize(this.opt.jsPDF)).hasOwnProperty("inner")||(l.inner={width:l.width-this.opt.margin[1]-this.opt.margin[3],height:l.height-this.opt.margin[0]-this.opt.margin[2]},l.inner.px={width:d(l.inner.width,l.k),height:d(l.inner.height,l.k)},l.inner.ratio=l.inner.height/l.inner.width),this.prop.pageSize=l})},c.prototype.setProgress=function(l,d,h,f){return l!=null&&(this.progress.val=l),d!=null&&(this.progress.state=d),h!=null&&(this.progress.n=h),f!=null&&(this.progress.stack=f),this.progress.ratio=this.progress.val/this.progress.state,this},c.prototype.updateProgress=function(l,d,h,f){return this.setProgress(l?this.progress.val+l:null,d||null,h?this.progress.n+h:null,f?this.progress.stack.concat(f):null)},c.prototype.then=function(l,d){var h=this;return this.thenCore(l,d,function(f,x){return h.updateProgress(null,null,1,[f]),Promise.prototype.then.call(this,function(b){return h.updateProgress(null,f),b}).then(f,x).then(function(b){return h.updateProgress(1),b})})},c.prototype.thenCore=function(l,d,h){h=h||Promise.prototype.then;var f=this;l&&(l=l.bind(f)),d&&(d=d.bind(f));var x=Promise.toString().indexOf("[native code]")!==-1&&Promise.name==="Promise"?f:c.convert(Object.assign({},f),Promise.prototype),b=h.call(x,l,d);return c.convert(b,f.__proto__)},c.prototype.thenExternal=function(l,d){return Promise.prototype.then.call(this,l,d)},c.prototype.thenList=function(l){var d=this;return l.forEach(function(h){d=d.thenCore(h)}),d},c.prototype.catch=function(l){l&&(l=l.bind(this));var d=Promise.prototype.catch.call(this,l);return c.convert(d,this)},c.prototype.catchExternal=function(l){return Promise.prototype.catch.call(this,l)},c.prototype.error=function(l){return this.then(function(){throw new Error(l)})},c.prototype.using=c.prototype.set,c.prototype.saveAs=c.prototype.save,c.prototype.export=c.prototype.output,c.prototype.run=c.prototype.then,yt.getPageSize=function(l,d,h){if(pn(l)==="object"){var f=l;l=f.orientation,d=f.unit||d,h=f.format||h}d=d||"mm",h=h||"a4",l=(""+(l||"P")).toLowerCase();var x,b=(""+h).toLowerCase(),m={a0:[2383.94,3370.39],a1:[1683.78,2383.94],a2:[1190.55,1683.78],a3:[841.89,1190.55],a4:[595.28,841.89],a5:[419.53,595.28],a6:[297.64,419.53],a7:[209.76,297.64],a8:[147.4,209.76],a9:[104.88,147.4],a10:[73.7,104.88],b0:[2834.65,4008.19],b1:[2004.09,2834.65],b2:[1417.32,2004.09],b3:[1000.63,1417.32],b4:[708.66,1000.63],b5:[498.9,708.66],b6:[354.33,498.9],b7:[249.45,354.33],b8:[175.75,249.45],b9:[124.72,175.75],b10:[87.87,124.72],c0:[2599.37,3676.54],c1:[1836.85,2599.37],c2:[1298.27,1836.85],c3:[918.43,1298.27],c4:[649.13,918.43],c5:[459.21,649.13],c6:[323.15,459.21],c7:[229.61,323.15],c8:[161.57,229.61],c9:[113.39,161.57],c10:[79.37,113.39],dl:[311.81,623.62],letter:[612,792],"government-letter":[576,756],legal:[612,1008],"junior-legal":[576,360],ledger:[1224,792],tabloid:[792,1224],"credit-card":[153,243]};switch(d){case"pt":x=1;break;case"mm":x=72/25.4;break;case"cm":x=72/2.54;break;case"in":x=72;break;case"px":x=.75;break;case"pc":case"em":x=12;break;case"ex":x=6;break;default:throw"Invalid unit: "+d}var w,v=0,P=0;if(m.hasOwnProperty(b))v=m[b][1]/x,P=m[b][0]/x;else try{v=h[1],P=h[0]}catch{throw new Error("Invalid format: "+h)}if(l==="p"||l==="portrait")l="p",P>v&&(w=P,P=v,v=w);else{if(l!=="l"&&l!=="landscape")throw"Invalid orientation: "+l;l="l",v>P&&(w=P,P=v,v=w)}return{width:P,height:v,unit:d,k:x,orientation:l}},e.html=function(l,d){(d=d||{}).callback=d.callback||function(){},d.html2canvas=d.html2canvas||{},d.html2canvas.canvas=d.html2canvas.canvas||this.canvas,d.jsPDF=d.jsPDF||this,d.fontFaces=d.fontFaces?d.fontFaces.map(Kc):null;var h=new c(d);return d.worker?h:h.from(l).doCallback()}}(yt.API),yt.API.addJS=function(e){var t,n,r=function(s){for(var i="",c=0;c<s.length;c++){var l=s[c];if(l==="("||l===")"){for(var d=0,h=c-1;h>=0&&s[h]==="\\";h--)d++;i+=d%2==0?"\\"+l:l}else i+=l}return i}(e);return this.internal.events.subscribe("postPutResources",function(){t=this.internal.newObject(),this.internal.out("<<"),this.internal.out("/Names [(EmbeddedJS) "+(t+1)+" 0 R]"),this.internal.out(">>"),this.internal.out("endobj"),n=this.internal.newObject(),this.internal.out("<<"),this.internal.out("/S /JavaScript"),this.internal.out("/JS ("+r+")"),this.internal.out(">>"),this.internal.out("endobj")}),this.internal.events.subscribe("putCatalog",function(){t!==void 0&&n!==void 0&&this.internal.out("/Names <</JavaScript "+t+" 0 R>>")}),this},function(e){var t;e.events.push(["postPutResources",function(){var n=this,r=/^(\d+) 0 obj$/;if(this.outline.root.children.length>0)for(var s=n.outline.render().split(/\r\n/),i=0;i<s.length;i++){var c=s[i],l=r.exec(c);if(l!=null){var d=l[1];n.internal.newObjectDeferredBegin(d,!1)}n.internal.write(c)}if(this.outline.createNamedDestinations){var h=this.internal.pages.length,f=[];for(i=0;i<h;i++){var x=n.internal.newObject();f.push(x);var b=n.internal.getPageInfo(i+1);n.internal.write("<< /D["+b.objId+" 0 R /XYZ null null null]>> endobj")}var m=n.internal.newObject();for(n.internal.write("<< /Names [ "),i=0;i<f.length;i++)n.internal.write("(page_"+(i+1)+")"+f[i]+" 0 R");n.internal.write(" ] >>","endobj"),t=n.internal.newObject(),n.internal.write("<< /Dests "+m+" 0 R"),n.internal.write(">>","endobj")}}]),e.events.push(["putCatalog",function(){var n=this;n.outline.root.children.length>0&&(n.internal.write("/Outlines",this.outline.makeRef(this.outline.root)),this.outline.createNamedDestinations&&n.internal.write("/Names "+t+" 0 R"))}]),e.events.push(["initialized",function(){var n=this;n.outline={createNamedDestinations:!1,root:{children:[]}},n.outline.add=function(r,s,i){var c={title:s,options:i,children:[]};return r==null&&(r=this.root),r.children.push(c),c},n.outline.render=function(){return this.ctx={},this.ctx.val="",this.ctx.pdf=n,this.genIds_r(this.root),this.renderRoot(this.root),this.renderItems(this.root),this.ctx.val},n.outline.genIds_r=function(r){r.id=n.internal.newObjectDeferred();for(var s=0;s<r.children.length;s++)this.genIds_r(r.children[s])},n.outline.renderRoot=function(r){this.objStart(r),this.line("/Type /Outlines"),r.children.length>0&&(this.line("/First "+this.makeRef(r.children[0])),this.line("/Last "+this.makeRef(r.children[r.children.length-1]))),this.line("/Count "+this.count_r({count:0},r)),this.objEnd()},n.outline.renderItems=function(r){for(var s=this.ctx.pdf.internal.getVerticalCoordinateString,i=0;i<r.children.length;i++){var c=r.children[i];this.objStart(c),this.line("/Title "+this.makeString(c.title)),this.line("/Parent "+this.makeRef(r)),i>0&&this.line("/Prev "+this.makeRef(r.children[i-1])),i<r.children.length-1&&this.line("/Next "+this.makeRef(r.children[i+1])),c.children.length>0&&(this.line("/First "+this.makeRef(c.children[0])),this.line("/Last "+this.makeRef(c.children[c.children.length-1])));var l=this.count=this.count_r({count:0},c);if(l>0&&this.line("/Count "+l),c.options&&c.options.pageNumber){var d=n.internal.getPageInfo(c.options.pageNumber);this.line("/Dest ["+d.objId+" 0 R /XYZ 0 "+s(0)+" 0]")}this.objEnd()}for(var h=0;h<r.children.length;h++)this.renderItems(r.children[h])},n.outline.line=function(r){this.ctx.val+=r+`\r
149`},n.outline.makeRef=function(r){return r.id+" 0 R"},n.outline.makeString=function(r){return"("+n.internal.pdfEscape(r)+")"},n.outline.objStart=function(r){this.ctx.val+=`\r
150`+r.id+` 0 obj\r
151<<\r
152`},n.outline.objEnd=function(){this.ctx.val+=`>> \r
153endobj\r
154`},n.outline.count_r=function(r,s){for(var i=0;i<s.children.length;i++)r.count++,this.count_r(r,s.children[i]);return r.count}}])}(yt.API),function(e){var t=[192,193,194,195,196,197,198,199];e.processJPEG=function(n,r,s,i,c,l){var d,h=this.decode.DCT_DECODE,f=null;if(typeof n=="string"||this.__addimage__.isArrayBuffer(n)||this.__addimage__.isArrayBufferView(n)){switch(n=c||n,n=this.__addimage__.isArrayBuffer(n)?new Uint8Array(n):n,d=function(x){for(var b,m=256*x.charCodeAt(4)+x.charCodeAt(5),w=x.length,v={width:0,height:0,numcomponents:1},P=4;P<w;P+=2){if(P+=m,t.indexOf(x.charCodeAt(P+1))!==-1){b=256*x.charCodeAt(P+5)+x.charCodeAt(P+6),v={width:256*x.charCodeAt(P+7)+x.charCodeAt(P+8),height:b,numcomponents:x.charCodeAt(P+9)};break}m=256*x.charCodeAt(P+2)+x.charCodeAt(P+3)}return v}(n=this.__addimage__.isArrayBufferView(n)?this.__addimage__.arrayBufferToBinaryString(n):n),d.numcomponents){case 1:l=this.color_spaces.DEVICE_GRAY;break;case 4:l=this.color_spaces.DEVICE_CMYK;break;case 3:l=this.color_spaces.DEVICE_RGB}f={data:n,width:d.width,height:d.height,colorSpace:l,bitsPerComponent:8,filter:h,index:r,alias:s}}return f}}(yt.API),yt.API.processPNG=function(e,t,n,r){if(this.__addimage__.isArrayBuffer(e)&&(e=new Uint8Array(e)),this.__addimage__.isArrayBufferView(e)){var s,i=Y5(e,{checkCrc:!0}),c=i.width,l=i.height,d=i.channels,h=i.palette,f=i.depth;s=h&&d===1?function($){for(var D=$.width,Y=$.height,N=$.data,I=$.palette,k=$.depth,L=!1,H=[],te=[],se=void 0,K=!1,ae=0,be=0;be<I.length;be++){var Ne=gh(I[be],4),A=Ne[0],E=Ne[1],z=Ne[2],X=Ne[3];H.push(A,E,z),X!=null&&(X===0?(ae++,te.length<1&&te.push(be)):X<255&&(K=!0))}if(K||ae>1){L=!0,te=void 0;var Z=D*Y;se=new Uint8Array(Z);for(var le=new DataView(N.buffer),fe=0;fe<Z;fe++){var ue=Jc(le,fe,k),_e=gh(I[ue],4)[3];se[fe]=_e}}else ae===0&&(te=void 0);return{colorSpace:"Indexed",colorsPerPixel:1,sMaskBitsPerComponent:L?8:void 0,colorBytes:N,alphaBytes:se,needSMask:L,palette:H,mask:te}}(i):d===2||d===4?function($){for(var D=$.data,Y=$.width,N=$.height,I=$.channels,k=$.depth,L=I===2?"DeviceGray":"DeviceRGB",H=I-1,te=Y*N,se=H,K=te*se,ae=1*te,be=Math.ceil(K*k/8),Ne=Math.ceil(ae*k/8),A=new Uint8Array(be),E=new Uint8Array(Ne),z=new DataView(D.buffer),X=new DataView(A.buffer),Z=new DataView(E.buffer),le=!1,fe=0;fe<te;fe++){for(var ue=fe*I,_e=0;_e<se;_e++)vf(X,Jc(z,ue+_e,k),fe*se+_e,k);var Ce=Jc(z,ue+se,k);Ce<(1<<k)-1&&(le=!0),vf(Z,Ce,1*fe,k)}return{colorSpace:L,colorsPerPixel:H,sMaskBitsPerComponent:le?k:void 0,colorBytes:A,alphaBytes:E,needSMask:le}}(i):function($){var D=$.data,Y=$.channels===1?"DeviceGray":"DeviceRGB";return{colorSpace:Y,colorsPerPixel:Y==="DeviceGray"?1:3,colorBytes:D instanceof Uint16Array?function(N){for(var I=N.length,k=new Uint8Array(2*I),L=new DataView(k.buffer,k.byteOffset,k.byteLength),H=0;H<I;H++)L.setUint16(2*H,N[H],!1);return k}(D):D,needSMask:!1}}(i);var x,b,m,w=s,v=w.colorSpace,P=w.colorsPerPixel,_=w.sMaskBitsPerComponent,q=w.colorBytes,T=w.alphaBytes,B=w.needSMask,Q=w.palette,me=w.mask,ce=null;return r!==yt.API.image_compression.NONE&&typeof jd=="function"?(ce=function($){var D;switch($){case yt.API.image_compression.FAST:D=11;break;case yt.API.image_compression.MEDIUM:D=13;break;case yt.API.image_compression.SLOW:D=14;break;default:D=12}return D}(r),x=this.decode.FLATE_DECODE,b="/Predictor ".concat(ce," /Colors ").concat(P," /BitsPerComponent ").concat(f," /Columns ").concat(c),e=pf(q,Math.ceil(c*P*f/8),P,f,r),B&&(m=pf(T,Math.ceil(c*_/8),1,_,r))):(x=void 0,b=void 0,e=q,B&&(m=T)),(this.__addimage__.isArrayBuffer(e)||this.__addimage__.isArrayBufferView(e))&&(e=this.__addimage__.arrayBufferToBinaryString(e)),(m&&this.__addimage__.isArrayBuffer(m)||this.__addimage__.isArrayBufferView(m))&&(m=this.__addimage__.arrayBufferToBinaryString(m)),{alias:n,data:e,index:t,filter:x,decodeParameters:b,transparency:me,palette:Q,sMask:m,predictor:ce,width:c,height:l,bitsPerComponent:f,sMaskBitsPerComponent:_,colorSpace:v}}},function(e){e.processGIF89A=function(t,n,r,s){var i=new px(t),c=i.width,l=i.height,d=[];i.decodeAndBlitFrameRGBA(0,d);var h={data:d,width:c,height:l},f=new Xc(100).encode(h,100);return e.processJPEG.call(this,f,n,r,s)},e.processGIF87A=e.processGIF89A}(yt.API),Fa.prototype.parseHeader=function(){if(this.fileSize=this.datav.getUint32(this.pos,!0),this.pos+=4,this.reserved=this.datav.getUint32(this.pos,!0),this.pos+=4,this.offset=this.datav.getUint32(this.pos,!0),this.pos+=4,this.headerSize=this.datav.getUint32(this.pos,!0),this.pos+=4,this.width=this.datav.getUint32(this.pos,!0),this.pos+=4,this.height=this.datav.getInt32(this.pos,!0),this.pos+=4,this.planes=this.datav.getUint16(this.pos,!0),this.pos+=2,this.bitPP=this.datav.getUint16(this.pos,!0),this.pos+=2,this.compress=this.datav.getUint32(this.pos,!0),this.pos+=4,this.rawSize=this.datav.getUint32(this.pos,!0),this.pos+=4,this.hr=this.datav.getUint32(this.pos,!0),this.pos+=4,this.vr=this.datav.getUint32(this.pos,!0),this.pos+=4,this.colors=this.datav.getUint32(this.pos,!0),this.pos+=4,this.importantColors=this.datav.getUint32(this.pos,!0),this.pos+=4,this.bitPP===16&&this.is_with_alpha&&(this.bitPP=15),this.bitPP<15){var e=this.colors===0?1<<this.bitPP:this.colors;this.palette=new Array(e);for(var t=0;t<e;t++){var n=this.datav.getUint8(this.pos++,!0),r=this.datav.getUint8(this.pos++,!0),s=this.datav.getUint8(this.pos++,!0),i=this.datav.getUint8(this.pos++,!0);this.palette[t]={red:s,green:r,blue:n,quad:i}}}this.height<0&&(this.height*=-1,this.bottom_up=!1)},Fa.prototype.parseBGR=function(){this.pos=this.offset;var e="bit"+this.bitPP,t=this.width*this.height*4;if(t>536870912)throw new Error("Image dimensions exceed 512MB, which is too large.");this.data=new Uint8Array(t);try{this[e]()}catch(n){wn.log("bit decode error:"+n)}},Fa.prototype.bit1=function(){var e,t=Math.ceil(this.width/8),n=t%4;for(e=this.height-1;e>=0;e--){for(var r=this.bottom_up?e:this.height-1-e,s=0;s<t;s++)for(var i=this.datav.getUint8(this.pos++,!0),c=r*this.width*4+8*s*4,l=0;l<8&&8*s+l<this.width;l++){var d=this.palette[i>>7-l&1];this.data[c+4*l]=d.blue,this.data[c+4*l+1]=d.green,this.data[c+4*l+2]=d.red,this.data[c+4*l+3]=255}n!==0&&(this.pos+=4-n)}},Fa.prototype.bit4=function(){for(var e=Math.ceil(this.width/2),t=e%4,n=this.height-1;n>=0;n--){for(var r=this.bottom_up?n:this.height-1-n,s=0;s<e;s++){var i=this.datav.getUint8(this.pos++,!0),c=r*this.width*4+2*s*4,l=i>>4,d=15&i,h=this.palette[l];if(this.data[c]=h.blue,this.data[c+1]=h.green,this.data[c+2]=h.red,this.data[c+3]=255,2*s+1>=this.width)break;h=this.palette[d],this.data[c+4]=h.blue,this.data[c+4+1]=h.green,this.data[c+4+2]=h.red,this.data[c+4+3]=255}t!==0&&(this.pos+=4-t)}},Fa.prototype.bit8=function(){for(var e=this.width%4,t=this.height-1;t>=0;t--){for(var n=this.bottom_up?t:this.height-1-t,r=0;r<this.width;r++){var s=this.datav.getUint8(this.pos++,!0),i=n*this.width*4+4*r;if(s<this.palette.length){var c=this.palette[s];this.data[i]=c.red,this.data[i+1]=c.green,this.data[i+2]=c.blue,this.data[i+3]=255}else this.data[i]=255,this.data[i+1]=255,this.data[i+2]=255,this.data[i+3]=255}e!==0&&(this.pos+=4-e)}},Fa.prototype.bit15=function(){for(var e=this.width%3,t=parseInt("11111",2),n=this.height-1;n>=0;n--){for(var r=this.bottom_up?n:this.height-1-n,s=0;s<this.width;s++){var i=this.datav.getUint16(this.pos,!0);this.pos+=2;var c=(i&t)/t*255|0,l=(i>>5&t)/t*255|0,d=(i>>10&t)/t*255|0,h=i>>15?255:0,f=r*this.width*4+4*s;this.data[f]=d,this.data[f+1]=l,this.data[f+2]=c,this.data[f+3]=h}this.pos+=e}},Fa.prototype.bit16=function(){for(var e=this.width%3,t=parseInt("11111",2),n=parseInt("111111",2),r=this.height-1;r>=0;r--){for(var s=this.bottom_up?r:this.height-1-r,i=0;i<this.width;i++){var c=this.datav.getUint16(this.pos,!0);this.pos+=2;var l=(c&t)/t*255|0,d=(c>>5&n)/n*255|0,h=(c>>11)/t*255|0,f=s*this.width*4+4*i;this.data[f]=h,this.data[f+1]=d,this.data[f+2]=l,this.data[f+3]=255}this.pos+=e}},Fa.prototype.bit24=function(){for(var e=this.height-1;e>=0;e--){for(var t=this.bottom_up?e:this.height-1-e,n=0;n<this.width;n++){var r=this.datav.getUint8(this.pos++,!0),s=this.datav.getUint8(this.pos++,!0),i=this.datav.getUint8(this.pos++,!0),c=t*this.width*4+4*n;this.data[c]=i,this.data[c+1]=s,this.data[c+2]=r,this.data[c+3]=255}this.pos+=this.width%4}},Fa.prototype.bit32=function(){for(var e=this.height-1;e>=0;e--)for(var t=this.bottom_up?e:this.height-1-e,n=0;n<this.width;n++){var r=this.datav.getUint8(this.pos++,!0),s=this.datav.getUint8(this.pos++,!0),i=this.datav.getUint8(this.pos++,!0),c=this.datav.getUint8(this.pos++,!0),l=t*this.width*4+4*n;this.data[l]=i,this.data[l+1]=s,this.data[l+2]=r,this.data[l+3]=c}},Fa.prototype.getData=function(){return this.data},function(e){e.processBMP=function(t,n,r,s){var i=new Fa(t,!1),c=i.width,l=i.height,d={data:i.getData(),width:c,height:l},h=new Xc(100).encode(d,100);return e.processJPEG.call(this,h,n,r,s)}}(yt.API),wf.prototype.getData=function(){return this.data},function(e){e.processWEBP=function(t,n,r,s){var i=new wf(t),c=i.width,l=i.height,d={data:i.getData(),width:c,height:l},h=new Xc(100).encode(d,100);return e.processJPEG.call(this,h,n,r,s)}}(yt.API),yt.API.processRGBA=function(e,t,n){for(var r=e.data,s=r.length,i=new Uint8Array(s/4*3),c=new Uint8Array(s/4),l=0,d=0,h=0;h<s;h+=4){var f=r[h],x=r[h+1],b=r[h+2],m=r[h+3];i[l++]=f,i[l++]=x,i[l++]=b,c[d++]=m}var w=this.__addimage__.arrayBufferToBinaryString(i);return{alpha:this.__addimage__.arrayBufferToBinaryString(c),data:w,index:t,alias:n,colorSpace:"DeviceRGB",bitsPerComponent:8,width:e.width,height:e.height}},yt.API.setLanguage=function(e){return this.internal.languageSettings===void 0&&(this.internal.languageSettings={},this.internal.languageSettings.isSubscribed=!1),{af:"Afrikaans",sq:"Albanian",ar:"Arabic (Standard)","ar-DZ":"Arabic (Algeria)","ar-BH":"Arabic (Bahrain)","ar-EG":"Arabic (Egypt)","ar-IQ":"Arabic (Iraq)","ar-JO":"Arabic (Jordan)","ar-KW":"Arabic (Kuwait)","ar-LB":"Arabic (Lebanon)","ar-LY":"Arabic (Libya)","ar-MA":"Arabic (Morocco)","ar-OM":"Arabic (Oman)","ar-QA":"Arabic (Qatar)","ar-SA":"Arabic (Saudi Arabia)","ar-SY":"Arabic (Syria)","ar-TN":"Arabic (Tunisia)","ar-AE":"Arabic (U.A.E.)","ar-YE":"Arabic (Yemen)",an:"Aragonese",hy:"Armenian",as:"Assamese",ast:"Asturian",az:"Azerbaijani",eu:"Basque",be:"Belarusian",bn:"Bengali",bs:"Bosnian",br:"Breton",bg:"Bulgarian",my:"Burmese",ca:"Catalan",ch:"Chamorro",ce:"Chechen",zh:"Chinese","zh-HK":"Chinese (Hong Kong)","zh-CN":"Chinese (PRC)","zh-SG":"Chinese (Singapore)","zh-TW":"Chinese (Taiwan)",cv:"Chuvash",co:"Corsican",cr:"Cree",hr:"Croatian",cs:"Czech",da:"Danish",nl:"Dutch (Standard)","nl-BE":"Dutch (Belgian)",en:"English","en-AU":"English (Australia)","en-BZ":"English (Belize)","en-CA":"English (Canad
154a)","en-IE":"English (Ireland)","en-JM":"English (Jamaica)","en-NZ":"English (New Zealand)","en-PH":"English (Philippines)","en-ZA":"English (South Africa)","en-TT":"English (Trinidad & Tobago)","en-GB":"English (United Kingdom)","en-US":"English (United States)","en-ZW":"English (Zimbabwe)",eo:"Esperanto",et:"Estonian",fo:"Faeroese",fj:"Fijian",fi:"Finnish",fr:"French (Standard)","fr-BE":"French (Belgium)","fr-CA":"French (Canada)","fr-FR":"French (France)","fr-LU":"French (Luxembourg)","fr-MC":"French (Monaco)","fr-CH":"French (Switzerland)",fy:"Frisian",fur:"Friulian",gd:"Gaelic (Scots)","gd-IE":"Gaelic (Irish)",gl:"Galacian",ka:"Georgian",de:"German (Standard)","de-AT":"German (Austria)","de-DE":"German (Germany)","de-LI":"German (Liechtenstein)","de-LU":"German (Luxembourg)","de-CH":"German (Switzerland)",el:"Greek",gu:"Gujurati",ht:"Haitian",he:"Hebrew",hi:"Hindi",hu:"Hungarian",is:"Icelandic",id:"Indonesian",iu:"Inuktitut",ga:"Irish",it:"Italian (Standard)","it-CH":"Italian (Switzerland)",ja:"Japanese",kn:"Kannada",ks:"Kashmiri",kk:"Kazakh",km:"Khmer",ky:"Kirghiz",tlh:"Klingon",ko:"Korean","ko-KP":"Korean (North Korea)","ko-KR":"Korean (South Korea)",la:"Latin",lv:"Latvian",lt:"Lithuanian",lb:"Luxembourgish",mk:"North Macedonia",ms:"Malay",ml:"Malayalam",mt:"Maltese",mi:"Maori",mr:"Marathi",mo:"Moldavian",nv:"Navajo",ng:"Ndonga",ne:"Nepali",no:"Norwegian",nb:"Norwegian (Bokmal)",nn:"Norwegian (Nynorsk)",oc:"Occitan",or:"Oriya",om:"Oromo",fa:"Persian","fa-IR":"Persian/Iran",pl:"Polish",pt:"Portuguese","pt-BR":"Portuguese (Brazil)",pa:"Punjabi","pa-IN":"Punjabi (India)","pa-PK":"Punjabi (Pakistan)",qu:"Quechua",rm:"Rhaeto-Romanic",ro:"Romanian","ro-MO":"Romanian (Moldavia)",ru:"Russian","ru-MO":"Russian (Moldavia)",sz:"Sami (Lappish)",sg:"Sango",sa:"Sanskrit",sc:"Sardinian",sd:"Sindhi",si:"Singhalese",sr:"Serbian",sk:"Slovak",sl:"Slovenian",so:"Somani",sb:"Sorbian",es:"Spanish","es-AR":"Spanish (Argentina)","es-BO":"Spanish (Bolivia)","es-CL":"Spanish (Chile)","es-CO":"Spanish (Colombia)","es-CR":"Spanish (Costa Rica)","es-DO":"Spanish (Dominican Republic)","es-EC":"Spanish (Ecuador)","es-SV":"Spanish (El Salvador)","es-GT":"Spanish (Guatemala)","es-HN":"Spanish (Honduras)","es-MX":"Spanish (Mexico)","es-NI":"Spanish (Nicaragua)","es-PA":"Spanish (Panama)","es-PY":"Spanish (Paraguay)","es-PE":"Spanish (Peru)","es-PR":"Spanish (Puerto Rico)","es-ES":"Spanish (Spain)","es-UY":"Spanish (Uruguay)","es-VE":"Spanish (Venezuela)",sx:"Sutu",sw:"Swahili",sv:"Swedish","sv-FI":"Swedish (Finland)","sv-SV":"Swedish (Sweden)",ta:"Tamil",tt:"Tatar",te:"Teluga",th:"Thai",tig:"Tigre",ts:"Tsonga",tn:"Tswana",tr:"Turkish",tk:"Turkmen",uk:"Ukrainian",hsb:"Upper Sorbian",ur:"Urdu",ve:"Venda",vi:"Vietnamese",vo:"Volapuk",wa:"Walloon",cy:"Welsh",xh:"Xhosa",ji:"Yiddish",zu:"Zulu"}[e]!==void 0&&(this.internal.languageSettings.languageCode=e,this.internal.languageSettings.isSubscribed===!1&&(this.internal.events.subscribe("putCatalog",function(){this.internal.write("/Lang ("+this.internal.languageSettings.languageCode+")")}),this.internal.languageSettings.isSubscribed=!0)),this},Yi=yt.API,Nl=Yi.getCharWidthsArray=function(e,t){var n,r,s=(t=t||{}).font||this.internal.getFont(),i=t.fontSize||this.internal.getFontSize(),c=t.charSpace||this.internal.getCharSpace(),l=t.widths?t.widths:s.metadata.Unicode.widths,d=l.fof?l.fof:1,h=t.kerning?t.kerning:s.metadata.Unicode.kerning,f=h.fof?h.fof:1,x=t.doKerning!==!1,b=0,m=e.length,w=0,v=l[0]||d,P=[];for(n=0;n<m;n++)r=e.charCodeAt(n),typeof s.metadata.widthOfString=="function"?P.push((s.metadata.widthOfGlyph(s.metadata.characterToGlyph(r))+c*(1e3/i)||0)/1e3):(b=x&&pn(h[r])==="object"&&!isNaN(parseInt(h[r][w],10))?h[r][w]/f:0,P.push((l[r]||v)/d+b)),w=r;return P},hf=Yi.getStringUnitWidth=function(e,t){var n=(t=t||{}).fontSize||this.internal.getFontSize(),r=t.font||this.internal.getFont(),s=t.charSpace||this.internal.getCharSpace();return Yi.processArabic&&(e=Yi.processArabic(e)),typeof r.metadata.widthOfString=="function"?r.metadata.widthOfString(e,n,s)/n:Nl.apply(this,arguments).reduce(function(i,c){return i+c},0)},ff=function(e,t,n,r){for(var s=[],i=0,c=e.length,l=0;i!==c&&l+t[i]<n;)l+=t[i],i++;s.push(e.slice(0,i));var d=i;for(l=0;i!==c;)l+t[i]>
vendor: 4,400 bytes, lines 154-156
154r&&(s.push(e.slice(d,i)),l=0,d=i),l+=t[i],i++;return d!==i&&s.push(e.slice(d,i)),s},mf=function(e,t,n){n||(n={});var r,s,i,c,l,d,h,f=[],x=[f],b=n.textIndent||0,m=0,w=0,v=e.split(" "),P=Nl.apply(this,[" ",n])[0];if(d=n.lineIndent===-1?v[0].length+2:n.lineIndent||0){var _=Array(d).join(" "),q=[];v.map(function(B){(B=B.split(/\s*\n/)).length>1?q=q.concat(B.map(function(Q,me){return(me&&Q.length?`
155`:"")+Q})):q.push(B[0])}),v=q,d=hf.apply(this,[_,n])}for(i=0,c=v.length;i<c;i++){var T=0;if(r=v[i],d&&r[0]==`
156`&&(r=r.substr(1),T=1),b+m+(w=(s=Nl.apply(this,[r,n])).reduce(function(B,Q){return B+Q},0))>t||T){if(w>t){for(l=ff.apply(this,[r,s,t-(b+m),t]),f.push(l.shift()),f=[l.pop()];l.length;)x.push([l.shift()]);w=s.slice(r.length-(f[0]?f[0].length:0)).reduce(function(B,Q){return B+Q},0)}else f=[r];x.push(f),b=w+d,m=P}else f.push(r),b+=m+w,m=P}return h=d?function(B,Q){return(Q?_:"")+B.join(" ")}:function(B){return B.join(" ")},x.map(h)},Yi.splitTextToSize=function(e,t,n){var r,s=(n=n||{}).fontSize||this.internal.getFontSize(),i=(function(f){if(f.widths&&f.kerning)return{widths:f.widths,kerning:f.kerning};var x=this.internal.getFont(f.fontName,f.fontStyle),b="Unicode";return x.metadata[b]?{widths:x.metadata[b].widths||{0:1},kerning:x.metadata[b].kerning||{}}:{font:x.metadata,fontSize:this.internal.getFontSize(),charSpace:this.internal.getCharSpace()}}).call(this,n);r=Array.isArray(e)?e:String(e).split(/\r?\n/);var c=1*this.internal.scaleFactor*t/s;i.textIndent=n.textIndent?1*n.textIndent*this.internal.scaleFactor/s:0,i.lineIndent=n.lineIndent;var l,d,h=[];for(l=0,d=r.length;l<d;l++)h=h.concat(mf.apply(this,[r[l],c,i]));return h},function(e){e.__fontmetrics__=e.__fontmetrics__||{};for(var t="0123456789abcdef",n="klmnopqrstuvwxyz",r={},s={},i=0;i<16;i++)r[n[i]]=t[i],s[t[i]]=n[i];var c=function(b){return"0x"+parseInt(b,10).toString(16)},l=e.__fontmetrics__.compress=function(b){var m,w,v,P,_=["{"];for(var q in b){if(m=b[q],isNaN(parseInt(q,10))?w="'"+q+"'":(q=parseInt(q,10),w=(w=c(q).slice(2)).slice(0,-1)+s[w.slice(-1)]),typeof m=="number")m<0?(v=c(m).slice(3),P="-"):(v=c(m).slice(2),P=""),v=P+v.slice(0,-1)+s[v.slice(-1)];else{if(pn(m)!=="object")throw new Error("Don't know what to do with value type "+pn(m)+".");v=l(m)}_.push(w+v)}return _.push("}"),_.join("")},d=e.__fontmetrics__.uncompress=function(b){if(typeof b!="string")throw new Error("Invalid argument passed to uncompress.");for(var m,w,v,P,_={},q=1,T=_,B=[],Q="",me="",ce=b.length-1,$=1;$<ce;$+=1)(P=b[$])=="'"?m?(v=m.join(""),m=void 0):m=[]:m?m.push(P):P=="{"?(B.push([T,v]),T={},v=void 0):P=="}"?((w=B.pop())[0][w[1]]=T,v=void 0,T=w[0]):P=="-"?q=-1:v===void 0?r.hasOwnProperty(P)?(Q+=r[P],v=parseInt(Q,16)*q,q=1,Q=""):Q+=P:r.hasOwnProperty(P)?(me+=r[P],T[v]=parseInt(me,16)*q,q=1,v=void 0,me=""):me+=P;return _},h={codePages:["WinAnsiEncoding"],WinAnsiEncoding:d("{19m8n201n9q201o9r201s9l201t9m201u8m201w9n201x9o201y8o202k8q202l8r202m9p202q8p20aw8k203k8t203t8v203u9v2cq8s212m9t15m8w15n9w2dw9s16k8u16l9u17s9z17x8y17y9y}")},f={Unicode:{Courier:h,"Courier-Bold":h,"Courier-BoldOblique":h,"Courier-Oblique":h,Helvetica:h,"Helvetica-Bold":h,"Helvetica-BoldOblique":h,"Helvetica-Oblique":h,"Times-Roman":h,"Times-Bold":h,"Times-BoldItalic":h,"Times-Italic":h}},x={Unicode:{"Courier-Oblique":d("{'widths'{k3w'fof'6o}'kerning'{'fof'-6o}}"),"Times-BoldItalic":d("{'widths'{k3o2q4ycx2r201n3m201o6o201s2l201t2l201u2l201w3m201x3m201y3m2k1t2l2r202m2n2n3m2o3m2p5n202q6o2r1w2s2l2t2l2u3m2v3t2w1t2x2l2y1t2z1w3k3m3l3m3m3m3n3m3o3m3p3m3q3m3r3m3s3m203t2l203u2l3v2l3w3t3x3t3y3t3z3m4k5n4l4m4m4m4n4m4o4s4p4m4q4m4r4s4s4y4t2r4u3m4v4m4w3x4x5t4y4s4z4s5k3x5l4s5m4m5n3r5o3x5p4s5q4m5r5t5s4m5t3x5u3x5v2l5w1w5x2l5y3t5z3m6k2l6l3m6m3m6n2w6o3m6p2w6q2l6r3m6s3r6t1w6u1w6v3m6w1w6x4y6y3r6z3m7k3m7l3m7m2r7n2r7o1w7p3r7q2w7r4m7s3m7t2w7u2r7v2n7w1q7x2n7y3t202l3mcl4mal2ram3man3mao3map3mar3mas2lat4uau1uav3maw3way4uaz2lbk2sbl3t'fof'6obo2lbp3tbq3mbr1tbs2lbu1ybv3mbz3mck4m202k3mcm4mcn4mco4mcp4mcq5ycr4mcs4mct4mcu4mcv4mcw2r2m3rcy2rcz2rdl4sdm4sdn4sdo4sdp4sdq4sds4sdt4sdu4sdv4sdw4sdz3mek3mel3mem3men3meo3mep3meq4ser2wes2wet2weu2wev2wew1wex1wey1wez1wfl3rfm3mfn3mfo3mfp3mfq3mfr3tfs3mft3rfu3rfv3rfw3rfz2w203k6o212m6o2dw2l2cq2l3t3m3u2l17s3x19m3m}'kerning'{cl{4qu5kt5qt5rs17ss5ts}201s{201ss}201t{cks4lscmscnscoscpscls2wu2yu201ts}201x{2wu2yu}2k{201ts}2w{4qx5kx5ou5qx5rs17su5tu}2x{17su5tu5ou}2y{4qx5kx5ou5qx5rs17ss5ts}'fof'-6ofn{17sw5tw5ou5qw5rs}7t{cksclscmscnscoscps4ls}
1563u{17su5tu5os5qs}3v{17su5tu5os5qs}7p{17su5tu}ck{4qu5kt5qt5rs17ss5ts}4l{4qu5kt5qt5rs17ss5ts}cm{4qu5kt5qt5rs17ss5ts}cn{4qu5kt5qt5rs17ss5ts}co{4qu5kt5qt5rs17ss5ts}cp{4qu5kt5qt5rs17ss5ts}6l{4qu5ou5qw5rt17su5tu}5q{ckuclucmucnucoucpu4lu}5r{ckuclucmucnucoucpu4lu}7q{cksclscmscnscoscps4ls}6p{4qu5ou5qw5rt17sw5tw}ek{4qu5ou5qw5rt17su5tu}el{4qu5ou5qw5rt17su5tu}em{4qu5ou5qw5rt17su5tu}en{4qu5ou5qw5rt17su5tu}eo{4qu5ou5qw5rt17su5tu}ep{4qu5ou5qw5rt17su5tu}es{17ss5ts5qs4qu}et{4qu5ou5qw5rt17sw5tw}eu{4qu5ou5qw5rt17ss5ts}ev{17ss5ts5qs4qu}6z{17sw5tw5ou5qw5rs}fm{17sw5tw5ou5qw5rs}7n{201ts}fo{17sw5tw5ou5qw5rs}fp{17sw5tw5ou5qw5rs}fq{17sw5tw5ou5qw5rs}7r{cksclscmscnscoscps4ls}fs{17sw5tw5ou5qw5rs}ft{17su5tu}fu{17su5tu}fv{17su5tu}fw{17su5tu}fz{cksclscmscnscoscps4ls}}}"),"Helvetica-Bold":d("{'widths'{k3s2q4scx1w201n3r201o6o201s1w201t1w201u1w201w3m201x3m201y3m2k1w2l2l202m2n2n3r2o3r2p5t202q6o2r1s2s2l2t2l2u2r2v3u2w1w2x2l2y1w2z1w3k3r3l3r3m3r3n3r3o3r3p3r3q3r3r3r3s3r203t2l203u2l3v2l3w3u3x3u3y3u3z3x4k6l4l4s4m4s4n4s4o4s4p4m4q3x4r4y4s4s4t1w4u3r4v4s4w3x4x5n4y4s4z4y5k4m5l4y5m4s5n4m5o3x5p4s5q4m5r5y5s4m5t4m5u3x5v2l5w1w5x2l5y3u5z3r6k2l6l3r6m3x6n3r6o3x6p3r6q2l6r3x6s3x6t1w6u1w6v3r6w1w6x5t6y3x6z3x7k3x7l3x7m2r7n3r7o2l7p3x7q3r7r4y7s3r7t3r7u3m7v2r7w1w7x2r7y3u202l3rcl4sal2lam3ran3rao3rap3rar3ras2lat4tau2pav3raw3uay4taz2lbk2sbl3u'fof'6obo2lbp3xbq3rbr1wbs2lbu2obv3rbz3xck4s202k3rcm4scn4sco4scp4scq6ocr4scs4mct4mcu4mcv4mcw1w2m2zcy1wcz1wdl4sdm4y
156dn4ydo4ydp4ydq4yds4ydt4sdu4sdv4sdw4sdz3xek3rel3rem3ren3reo3rep3req5ter3res3ret3reu3rev3rew1wex1wey1wez1wfl3xfm3xfn3xfo3xfp3xfq3xfr3ufs3xft3xfu3xfv3xfw3xfz3r203k6o212m6o2dw2l2cq2l3t3r3u2l17s4m19m3r}'kerning'{cl{4qs5ku5ot5qs17sv5tv}201t{2ww4wy2yw}201w{2ks}201x{2ww4wy2yw}2k{201ts201xs}2w{7qs4qu5kw5os5qw5rs17su5tu7tsfzs}2x{5ow5qs}2y{7qs4qu5kw5os5qw5rs17su5tu7tsfzs}'fof'-6o7p{17su5tu5ot}ck{4qs5ku5ot5qs17sv5tv}4l{4qs5ku5ot5qs17sv5tv}cm{4qs5ku5ot5qs17sv5tv}cn{4qs5ku5ot5qs17sv5tv}co{4qs5ku5ot5qs17sv5tv}cp{4qs5ku5ot5qs17sv5tv}6l{17st5tt5os}17s{2kwclvcmvcnvcovcpv4lv4wwckv}5o{2kucltcmtcntcotcpt4lt4wtckt}5q{2ksclscmscnscoscps4ls4wvcks}5r{2ks4ws}5t{2kwclvcmvcnvcovcpv4lv4wwckv}eo{17st5tt5os}fu{17su5tu5ot}6p{17ss5ts}ek{17st5tt5os}el{17st5tt5os}em{17st5tt5os}en{17st5tt5os}6o{201ts}ep{17st5tt5os}es{17ss5ts}et{17ss5ts}eu{17ss5ts}ev{17ss5ts}6z{17su5tu5os5qt}fm{17su5tu5os5qt}fn{17su5tu5os5qt}fo{17su5tu5os5qt}fp{17su5tu5os5qt}fq{17su5tu5os5qt}fs{17su5tu5os5qt}ft{17su5tu5ot}7m{5os}fv{17su5tu5ot}fw{17su5tu5ot}}}"),Courier:d("{'widths'{k3w'fof'6o}'kerning'{'fof'-6o}}"),"Courier-BoldOblique":d("{'widths'{k3w'fof'6o}'kerning'{'fof'-6o}}"),"Times-Bold":d("{'widths'{k3q2q5ncx2r201n3m201o6o201s2l201t2l201u2l201w3m201x3m201y3m2k1t2l2l202m2n2n3m2o3m2p6o202q6o2r1w2s2l2t2l2u3m2v3t2w1t2x2l2y1t2z1w3k3m3l3m3m3m3n3m3o3m3p3m3q3m3r3m3s3m203t2l203u2l3v2l3w3t3x3t3y3t3z3m4k5x4l4s4m4m4n4s4o4s4p4m4q3x4r4y4s4y4t2r4u3m4v4y4w4m4x5y4y4s4z4y5k3x5l4y5m4s5n3r5o4m5p4s5q4s5r6o5s4s5t4s5u4m5v2l5w1w5x2l5y3u5z3m6k2l6l3m6m3r6n2w6o3r6p2w6q2l6r3m6s3r6t1w6u2l6v3r6w1w6x5n6y3r6z3m7k3r7l3r7m2w7n2r7o2l7p3r7q3m7r4s7s3m7t3m7u2w7v2r7w1q7x2r7y3o202l3mcl4sal2lam3man3mao3map3mar3mas2lat4uau1yav3maw3tay4uaz2lbk2sbl3t'fof'6obo2lbp3rbr1tbs2lbu2lbv3mbz3mck4s202k3mcm4scn4sco4scp4scq6ocr4scs4mct4mcu4mcv4mcw2r2m3rcy2rcz2rdl4sdm4ydn4ydo4ydp4ydq4yds4ydt4sdu4sdv4sdw4sdz3rek3mel3mem3men3meo3mep3meq4ser2wes2wet2weu2wev2wew1wex1wey1wez1wfl3rfm3mfn3mfo3mfp3mfq3mfr3tfs3mft3rfu3rfv3rfw3rfz3m203k6o212m6o2dw2l2cq2l3t3m3u2l17s4s19m3m}'kerning'{cl{4qt5ks5ot5qy5rw17sv5tv}201t{cks4lscmscnscoscpscls4wv}2k{201ts}2w{4qu5ku7mu5os5qx5ru17su5tu}2x{17su5tu5ou5qs}2y{4qv5kv7mu5ot5qz5ru17su5tu}'fof'-6o7t{cksclscmscnscoscps4ls}3u{17su5tu5os5qu}3v{17su5tu5os5qu}fu{17su5tu5ou5qu}7p{17su5tu5ou5qu}ck{4qt5ks5ot5qy5rw17sv5tv}4l{4qt5ks5ot5qy5rw17sv5tv}cm{4qt5ks5ot5qy5rw17sv5tv}cn{4qt5ks5ot5qy5rw17sv5tv}co{4qt5ks5ot5qy5rw17sv5tv}cp{4qt5ks5ot5qy5rw17sv5tv}6l{17st5tt5ou5qu}17s{ckuclucmucnucoucpu4lu4wu}5o{ckuclucmucnucoucpu4lu4wu}5q{ckzclzcmzcnzcozcpz4lz4wu}5r{ckxclxcmxcnxcoxcpx4lx4wu}5t{ckuclucmucnucoucpu4lu4wu}7q{ckuclucmucnucoucpu4lu}6p{17sw5tw5ou5qu}ek{17st5tt5qu}el{17st5tt5ou5qu}em{17st5tt5qu}en{17st5tt5qu}eo{17st5tt5qu}ep{17st5tt5ou5qu}es{17ss5ts5qu}et{17sw5tw5ou5qu}eu{17sw5tw5ou5qu}ev{17ss5ts5qu}6z{17sw5tw5ou5qu5rs}fm{17sw5tw5ou5qu5rs}fn{17sw5tw5ou5qu5rs}fo{17sw5tw5ou5qu5rs}fp{17sw5tw5ou5qu5rs}fq{17sw5tw5ou5qu5rs}7r{cktcltcmtcntcotcpt4lt5os}fs{17sw5tw5ou5qu5rs}ft{17su5tu5ou5qu}7m{5os}fv{17su5tu5ou5qu}fw{17su5tu5ou5qu}fz{cksclscmscnscoscps4ls}}}"),Symbol:d("{'widths'{k3uaw4r19m3m2k1t2l2l202m2y2n3m2p5n202q6o3k3m2s2l2t2l2v3r2w1t3m3m2y1t2z1wbk2sbl3r'fof'6o3n3m3o3m3p3m3q3m3r3m3s3m3t3m3u1w3v1w3w3r3x3r3y3r3z2wbp3t3l3m5v2l5x2l5z3m2q4yfr3r7v3k7w1o7x3k}'kerning'{'fof'-6o}}"),Helvetica:d("{'widths'{k3p2q4mcx1w201n3r201o6o201s1q201t1q201u1q201w2l201x2l201y2l2k1w2l1w202m2n2n3r2o3r2p5t202q6o2r1n2s2l2t2l2u2r2v3u2w1w2x2l2y1w2z1w3k3r3l3r3m3r3n3r3o3r3p3r3q3r3r3r3s3r203t2l203u2l3v1w3w3u3x3u3y3u3z3r4k6p4l4m4m4m4n4s4o4s4p4m4q3x4r4y4s4s4t1w4u3m4v4m4w3r4x5n4y4s4z4y5k4m5l4y5m4s5n4m5o3x5p4s5q4m5r5y5s4m5t4m5u3x5v1w5w1w5x1w5y2z5z3r6k2l6l3r6m3r6n3m6o3r6p3r6q1w6r3r6s3r6t1q6u1q6v3m6w1q6x5n6y3r6z3r7k3r7l3r7m2l7n3m7o1w7p3r7q3m7r4s7s3m7t3m7u3m7v2l7w1u7x2l7y3u202l3rcl4mal2lam3ran3rao3rap3rar3ras2lat4tau2pav3raw3uay4taz2lbk2sbl3u'fof'6obo2lbp3rbr1wbs2lbu2obv3rbz3xck4m202k3rcm4mcn4mco4mcp4mcq6ocr4scs4mct4mcu4mcv4mcw1w2m2ncy1wcz1wdl4sdm4y
156dn4ydo4ydp4ydq4yds4ydt4sdu4sdv4sdw4sdz3xek3rel3rem3ren3reo3rep3req5ter3mes3ret3reu3rev3rew1wex1wey1wez1wfl3rfm3rfn3rfo3rfp3rfq3rfr3ufs3xft3rfu3rfv3rfw3rfz3m203k6o212m6o2dw2l2cq2l3t3r3u1w17s4m19m3r}'kerning'{5q{4wv}cl{4qs5kw5ow5qs17sv5tv}201t{2wu4w1k2yu}201x{2wu4wy2yu}17s{2ktclucmucnu4otcpu4lu4wycoucku}2w{7qs4qz5k1m17sy5ow5qx5rsfsu5ty7tufzu}2x{17sy5ty5oy5qs}2y{7qs4qz5k1m17sy5ow5qx5rsfsu5ty7tufzu}'fof'-6o7p{17sv5tv5ow}ck{4qs5kw5ow5qs17sv5tv}4l{4qs5kw5ow5qs17sv5tv}cm{4qs5kw5ow5qs17sv5tv}cn{4qs5kw5ow5qs17sv5tv}co{4qs5kw5ow5qs17sv5tv}cp{4qs5kw5ow5qs17sv5tv}6l{17sy5ty5ow}do{17st5tt}4z{17st5tt}7s{fst}dm{17st5tt}dn{17st5tt}5o{ckwclwcmwcnwcowcpw4lw4wv}dp{17st5tt}dq{17st5tt}7t{5ow}ds{17st5tt}5t{2ktclucmucnu4otcpu4lu4wycoucku}fu{17sv5tv5ow}6p{17sy5ty5ow5qs}ek{17sy5ty5ow}el{17sy5ty5ow}em{17sy5ty5ow}en{5ty}eo{17sy5ty5ow}ep{17sy5ty5ow}es{17sy5ty5qs}et{17sy5ty5ow5qs}eu{17sy5ty5ow5qs}ev{17sy5ty5ow5qs}6z{17sy5ty5ow5qs}fm{17sy5ty5ow5qs}fn{17sy5ty5ow5qs}fo{17sy5ty5ow5qs}fp{17sy5ty5qs}fq{17sy5ty5ow5qs}7r{5ow}fs{17sy5ty5ow5qs}ft{17sv5tv5ow}7m{5ow}fv{17sv5tv5ow}fw{17sv5tv5ow}}}"),"Helvetica-BoldOblique":d("{'widths'{k3s2q4scx1w201n3r201o6o201s1w201t1w201u1w201w3m201x3m201y3m2k1w2l2l202m2n2n3r2o3r2p5t202q6o2r1s2s2l2t2l2u2r2v3u2w1w2x2l2y1w2z1w3k3r3l3r3m3r3n3r3o3r3p3r3q3r3r3r3s3r203t2l203u2l3v2l3w3u3x3u3y3u3z3x4k6l4l4s4m4s4n4s4o4s4p4m4q3x4r4y4s4s4t1w4u3r4v4s4w3x4x5n4y4s4z4y5k4m5l4y5m4s5n4m5o3x5p4s5q4m5r5y5s4m5t4m5u3x5v2l5w1w5x2l5y3u5z3r6k2l6l3r6m3x6n3r6o3x6p3r6q2l6r3x6s3x6t1w6u1w6v3r6w1w6x5t6y3x6z3x7k3x7l3x7m2r7n3r7o2l7p3x7q3r7r4y7s3r7t3r7u3m7v2r7w1w7x2r7y3u202l3rcl4sal2lam3ran3rao3rap3rar3ras2lat4tau2pav3raw3uay4taz2lbk2sbl3u'fof'6obo2lbp3xbq3rbr1wbs2lbu2obv3rbz3xck4s202k3rcm4scn4sco4scp4scq6ocr4scs4mct4mcu4mcv4mcw1w2m2zcy1wcz1wdl4sdm4y
156dn4ydo4ydp4ydq4yds4ydt4sdu4sdv4sdw4sdz3xek3rel3rem3ren3reo3rep3req5ter3res3ret3reu3rev3rew1wex1wey1wez1wfl3xfm3xfn3xfo3xfp3xfq3xfr3ufs3xft3xfu3xfv3xfw3xfz3r203k6o212m6o2dw2l2cq2l3t3r3u2l17s4m19m3r}'kerning'{cl{4qs5ku5ot5qs17sv5tv}201t{2ww4wy2yw}201w{2ks}201x{2ww4wy2yw}2k{201ts201xs}2w{7qs4qu5kw5os5qw5rs17su5tu7tsfzs}2x{5ow5qs}2y{7qs4qu5kw5os5qw5rs17su5tu7tsfzs}'fof'-6o7p{17su5tu5ot}ck{4qs5ku5ot5qs17sv5tv}4l{4qs5ku5ot5qs17sv5tv}cm{4qs5ku5ot5qs17sv5tv}cn{4qs5ku5ot5qs17sv5tv}co{4qs5ku5ot5qs17sv5tv}cp{4qs5ku5ot5qs17sv5tv}6l{17st5tt5os}17s{2kwclvcmvcnvcovcpv4lv4wwckv}5o{2kucltcmtcntcotcpt4lt4wtckt}5q{2ksclscmscnscoscps4ls4wvcks}5r{2ks4ws}5t{2kwclvcmvcnvcovcpv4lv4wwckv}eo{17st5tt5os}fu{17su5tu5ot}6p{17ss5ts}ek{17st5tt5os}el{17st5tt5os}em{17st5tt5os}en{17st5tt5os}6o{201ts}ep{17st5tt5os}es{17ss5ts}et{17ss5ts}eu{17ss5ts}ev{17ss5ts}6z{17su5tu5os5qt}fm{17su5tu5os5qt}fn{17su5tu5os5qt}fo{17su5tu5os5qt}fp{17su5tu5os5qt}fq{17su5tu5os5qt}fs{17su5tu5os5qt}ft{17su5tu5ot}7m{5os}fv{17su5tu5ot}fw{17su5tu5ot}}}"),ZapfDingbats:d("{'widths'{k4u2k1w'fof'6o}'kerning'{'fof'-6o}}"),"Courier-Bold":d("{'widths'{k3w'fof'6o}'kerning'{'fof'-6o}}"),"Times-Italic":d("{'widths'{k3n2q4ycx2l201n3m201o5t201s2l201t2l201u2l201w3r201x3r201y3r2k1t2l2l202m2n2n3m2o3m2p5n202q5t2r1p2s2l2t2l2u3m2v4n2w1t2x2l2y1t2z1w3k3m3l3m3m3m3n3m3o3m3p3m3q3m3r3m3s3m203t2l203u2l3v2l3w4n3x4n3y4n3z3m4k5w4l3x4m3x4n4m4o4s4p3x4q3x4r4s4s4s4t2l4u2w4v4m4w3r4x5n4y4m4z4s5k3x5l4s5m3x5n3m5o3r5p4s5q3x5r5n5s3x5t3r5u3r5v2r5w1w5x2r5y2u5z3m6k2l6l3m6m3m6n2w6o3m6p2w6q1w6r3m6s3m6t1w6u1w6v2w6w1w6x4s6y3m6z3m7k3m7l3m7m2r7n2r7o1w7p3m7q2w7r4m7s2w7t2w7u2r7v2s7w1v7x2s7y3q202l3mcl3xal2ram3man3mao3map3mar3mas2lat4wau1vav3maw4nay4waz2lbk2sbl4n'fof'6obo2lbp3mbq3obr1tbs2lbu1zbv3mbz3mck3x202k3mcm3xcn3xco3xcp3xcq5tcr4mcs3xct3xcu3xcv3xcw2l2m2ucy2lcz2ldl4mdm4sdn4sdo4sdp4sdq4sds4sdt4sdu4sdv4sdw4sdz3mek3mel3mem3men3meo3mep3meq4mer2wes2wet2weu2wev2wew1wex1wey1wez1wfl3mfm3mfn3mfo3mfp3mfq3mfr4nfs3mft3mfu3mfv3mfw3mfz2w203k6o212m6m2dw2l2cq2l3t3m3u2l17s3r19m3m}'kerning'{cl{5kt4qw}201s{201sw}201t{201tw2wy2yy6q-t}201x{2wy2yy}2k{201tw}2w{7qs4qy7rs5ky7mw5os5qx5ru17su5tu}2x{17ss5ts5os}2y{7qs4qy7rs5ky7mw5os5qx5ru17su5tu}'fof'-6o6t{17ss5ts5qs}7t{5os}3v{5qs}7p{17su5tu5qs}ck{5kt4qw}4l{5kt4qw}cm{5kt4qw}cn{5kt4qw}co{5kt4qw}cp{5kt4qw}6l{4qs5ks5ou5qw5ru17su5tu}17s{2ks}5q{ckvclvcmvcnvcovcpv4lv}5r{ckuclucmucnucoucpu4lu}5t{2ks}6p{4qs5ks5ou5qw5ru17su5tu}ek{4qs5ks5ou5qw5ru17su5tu}el{4qs5ks5ou5qw5ru17su5tu}em{4qs5ks5ou5qw5ru17su5tu}en{4qs5ks5ou5qw5ru17su5tu}eo{4qs5ks5ou5qw5ru17su5tu}ep{4qs5ks5ou5qw5ru17su5tu}es{5ks5qs4qs}et{4qs5ks5ou5qw5ru17su5tu}eu{4qs5ks5qw5ru17su5tu}ev{5ks5qs4qs}ex{17ss5ts5qs}6z{4qv5ks5ou5qw5ru17su5tu}fm{4qv5ks5ou5qw5ru17su5tu}fn{4qv5ks5ou5qw5ru17su5tu}fo{4qv5ks5ou5qw5ru17su5tu}fp{4qv5ks5ou5qw5ru17su5tu}fq{4qv5ks5ou5qw5ru17su5tu}7r{5os}fs{4qv5ks5ou5qw5ru17su5tu}ft{17su5tu5qs}fu{17su5tu5qs}
156fv{17su5tu5qs}fw{17su5tu5qs}}}"),"Times-Roman":d("{'widths'{k3n2q4ycx2l201n3m201o6o201s2l201t2l201u2l201w2w201x2w201y2w2k1t2l2l202m2n2n3m2o3m2p5n202q6o2r1m2s2l2t2l2u3m2v3s2w1t2x2l2y1t2z1w3k3m3l3m3m3m3n3m3o3m3p3m3q3m3r3m3s3m203t2l203u2l3v1w3w3s3x3s3y3s3z2w4k5w4l4s4m4m4n4m4o4s4p3x4q3r4r4s4s4s4t2l4u2r4v4s4w3x4x5t4y4s4z4s5k3r5l4s5m4m5n3r5o3x5p4s5q4s5r5y5s4s5t4s5u3x5v2l5w1w5x2l5y2z5z3m6k2l6l2w6m3m6n2w6o3m6p2w6q2l6r3m6s3m6t1w6u1w6v3m6w1w6x4y6y3m6z3m7k3m7l3m7m2l7n2r7o1w7p3m7q3m7r4s7s3m7t3m7u2w7v3k7w1o7x3k7y3q202l3mcl4sal2lam3man3mao3map3mar3mas2lat4wau1vav3maw3say4waz2lbk2sbl3s'fof'6obo2lbp3mbq2xbr1tbs2lbu1zbv3mbz2wck4s202k3mcm4scn4sco4scp4scq5tcr4mcs3xct3xcu3xcv3xcw2l2m2tcy2lcz2ldl4sdm4sdn4sdo4sdp4sdq4sds4sdt4sdu4sdv4sdw4sdz3mek2wel2wem2wen2weo2wep2weq4mer2wes2wet2weu2wev2wew1wex1wey1wez1wfl3mfm3mfn3mfo3mfp3mfq3mfr3sfs3mft3mfu3mfv3mfw3mfz3m203k6o212m6m2dw2l2cq2l3t3m3u1w17s4s19m3m}'kerning'{cl{4qs5ku17sw5ou5qy5rw201ss5tw201ws}201s{201ss}201t{ckw4lwcmwcnwcowcpwclw4wu201ts}2k{201ts}2w{4qs5kw5os5qx5ru17sx5tx}2x{17sw5tw5ou5qu}2y{4qs5kw5os5qx5ru17sx5tx}'fof'-6o7t{ckuclucmucnucoucpu4lu5os5rs}3u{17su5tu5qs}3v{17su5tu5qs}7p{17sw5tw5qs}ck{4qs5ku17sw5ou5qy5rw201ss5tw201ws}4l{4qs5ku17sw5ou5qy5rw201ss5tw201ws}cm{4qs5ku17sw5ou5qy5rw201ss5tw201ws}cn{4qs5ku17sw5ou5qy5rw201ss5tw201ws}co{4qs5ku17sw5ou5qy5rw201ss5tw201ws}cp{4qs5ku17sw5ou5qy5rw201ss5tw201ws}6l{17su5tu5os5qw5rs}17s{2ktclvcmvcnvcovcpv4lv4wuckv}5o{ckwclwcmwcnwcowcpw4lw4wu}5q{ckyclycmycnycoycpy4ly4wu5ms}5r{cktcltcmtcntcotcpt4lt4ws}5t{2ktclvcmvcnvcovcpv4lv4wuckv}7q{cksclscmscnscoscps4ls}6p{17su5tu5qw5rs}ek{5qs5rs}el{17su5tu5os5qw5rs}em{17su5tu5os5qs5rs}en{17su5qs5rs}eo{5qs5rs}ep{17su5tu5os5qw5rs}es{5qs}et{17su5tu5qw5rs}eu{17su5tu5qs5rs}ev{5qs}6z{17sv5tv5os5qx5rs}fm{5os5qt5rs}fn{17sv5tv5os5qx5rs}fo{17sv5tv5os5qx5rs}fp{5os5qt5rs}fq{5os5qt5rs}7r{ckuclucmucnucoucpu4lu5os}fs{17sv5tv5os5qx5rs}ft{17ss5ts5qs}fu{17sw5tw5qs}fv{17sw5tw5qs}fw{17ss5ts5qs}fz{ckuclucmucnucoucpu4lu5os5rs}}}"),"Helvetica-Oblique":d("{'widths'{k3p2q4mcx1w201n3r201o6o201s1q201t1q201u1q201w2l201x2l201y2l2k1w2l1w202m2n2n3r2o3r2p5t202q6o2r1n2s2l2t2l2u2r2v3u2w1w2x2l2y1w2z1w3k3r3l3r3m3r3n3r3o3r3p3r3q3r3r3r3s3r203t2l203u2l3v1w3w3u3x3u3y3u3z3r4k6p4l4m4m4m4n4s4o4s4p4m4q3x4r4y4s4s4t1w4u3m4v4m4w3r4x5n4y4s4z4y5k4m5l4y5m4s5n4m5o3x5p4s5q4m5r5y5s4m5t4m5u3x5v1w5w1w5x1w5y2z5z3r6k2l6l3r6m3r6n3m6o3r6p3r6q1w6r3r6s3r6t1q6u1q6v3m6w1q6x5n6y3r6z3r7k3r7l3r7m2l7n3m7o1w7p3r7q3m7r4s7s3m7t3m7u3m7v2l7w1u7x2l7y3u202l3rcl4mal2lam3ran3rao3rap3rar3ras2lat4tau2pav3raw3uay4taz2lbk2sbl3u'fof'6obo2lbp3rbr1wbs2lbu2obv3rbz3xck4m202k3rcm4mcn4mco4mcp4mcq6ocr4scs4mct4mcu4mcv4mcw1w2m2ncy1wcz1wdl4sdm4y
156dn4ydo4ydp4ydq4yds4ydt4sdu4sdv4sdw4sdz3xek3rel3rem3ren3reo3rep3req5ter3mes3ret3reu3rev3rew1wex1wey1wez1wfl3rfm3rfn3rfo3rfp3rfq3rfr3ufs3xft3rfu3rfv3rfw3rfz3m203k6o212m6o2dw2l2cq2l3t3r3u1w17s4m19m3r}'kerning'{5q{4wv}cl{4qs5kw5ow5qs17sv5tv}201t{2wu4w1k2yu}201x{2wu4wy2yu}17s{2ktclucmucnu4otcpu4lu4wycoucku}2w{7qs4qz5k1m17sy5ow5qx5rsfsu5ty7tufzu}2x{17sy5ty5oy5qs}2y{7qs4qz5k1m17sy5ow5qx5rsfsu5ty7tufzu}'fof'-6o7p{17sv5tv5ow}ck{4qs5kw5ow5qs17sv5tv}4l{4qs5kw5ow5qs17sv5tv}cm{4qs5kw5ow5qs17sv5tv}cn{4qs5kw5ow5qs17sv5tv}co{4qs5kw5ow5qs17sv5tv}cp{4qs5kw5ow5qs17sv5tv}6l{17sy5ty5ow}do{17st5tt}4z{17st5tt}7s{fst}dm{17st5tt}dn{17st5tt}5o{ckwclwcmwcnwcowcpw4lw4wv}dp{17st5tt}dq{17st5tt}7t{5ow}ds{17st5tt}5t{2ktclucmucnu4otcpu4lu4wycoucku}fu{17sv5tv5ow}6p{17sy5ty5ow5qs}ek{17sy5ty5ow}el{17sy5ty5ow}em{17sy5ty5ow}en{5ty}eo{17sy5ty5ow}ep{17sy5ty5ow}es{17sy5ty5qs}et{17sy5ty5ow5qs}eu{17sy5ty5ow5qs}ev{17sy5ty5ow5qs}6z{17sy5ty5ow5qs}fm{17sy5ty5ow5qs}fn{17sy5ty5ow5qs}fo{17sy5ty5ow5qs}fp{17sy5ty5qs}fq{17sy5ty5ow5qs}7r{5ow}fs{17sy5ty5ow5qs}ft{17sv5tv5ow}7m{5ow}fv{17sv5tv5ow}fw{17sv5tv5ow}}}")}};e.events.push(["addFont",function(b){var m=b.font,w=x.Unicode[m.postScriptName];w&&(m.metadata.Unicode={},m.metadata.Unicode.widths=w.widths,m.metadata.Unicode.kerning=w.kerning);var v=f.Unicode[m.postScriptName];v&&(m.metadata.Unicode.encoding=v,m.encoding=v.codePages[0])}])}(yt.API),function(e){var t=function(n){for(var r=n.length,s=new Uint8Array(r),i=0;i<r;i++)s[i]=n.charCodeAt(i);return s};e.API.events.push(["addFont",function(n){var r=void 0,s=n.font,i=n.instance;if(!s.isStandardFont){if(i===void 0)throw new Error("Font does not exist in vFS, import fonts or remove declaration doc.addFont('"+s.postScriptName+"').");if(typeof(r=i.existsFileInVFS(s.postScriptName)===!1?i.loadFile(s.postScriptName):i.getFileFromVFS(s.postScriptName))!="string")throw new Error("Font is not stored as string-data in vFS, import fonts or remove declaration doc.addFont('"+s.postScriptName+"').");(function(c,l){l=/^\x00\x01\x00\x00/.test(l)?t(l):t(Fl(l)),c.metadata=e.API.TTFFont.open(l),c.metadata.Unicode=c.metadata.Unicode||{encoding:{},kerning:{},widths:[]},c.metadata.glyIdsUsed=[0]})(s,r)}}])}(yt),yt.API.addSvgAsImage=function(e,t,n,r,s,i,c,l){if(isNaN(t)||isNaN(n))throw wn.error("jsPDF.addSvgAsImage: Invalid coordinates",arguments),new Error("Invalid coordinates passed to jsPDF.addSvgAsImage");if(isNaN(r)||isNaN(s))throw wn.error("jsPDF.addSvgAsImage: Invalid measurements",arguments),new Error("Invalid measurements (width and/or height) passed to jsPDF.addSvgAsImage");var d=document.createElement("canvas");d.width=r,d.height=s;var h=d.getContext("2d");h.fillStyle="#fff",h.fillRect(0,0,d.width,d.height);var f={ignoreMouse:!0,ignoreAnimation:!0,ignoreDimensions:!0},x=this;return(Mt.canvg?Promise.resolve(Mt.canvg):Lc(()=>import("./index.es-KvqBBZhb.js"),__vite__mapDeps([2,0,1,3,4,5,6,7,8,9]))).catch(function(b){return Promise.reject(new Error("Could not load canvg: "+b))}).then(function(b){return b.default?b.default:b}).then(function(b){return b.fromString(h,e,f)},function(){return Promise.reject(new Error("Could not load canvg."))}).then(function(b){return b.render(f)}).then(function(){x.addImage(d.toDataURL("image/jpeg",1),t,n,r,s,c,l)})},yt.API.putTotalPages=function(e){var t,n=0;parseInt(this.internal.getFont().id.substr(1),10)<15?(t=new RegExp(e,"g"),n=this.internal.getNumberOfPages()):(t=new RegExp(this.pdfEscape16(e,this.internal.getFont()),"g"),n=this.pdfEscape16(this.internal.getNumberOfPages()+"",this.internal.getFont()));for(var r=1;r<=this.internal.getNumberOfPages();r++)for(var s=0;s<this.internal.pages[r].length;s++)this.internal.pages[r][s]=this.internal.pages[r][s].replace(t,n);return this},yt.API.viewerPreferences=function(e,t){var n;e=e||{},t=t||!1;var r,s,i,c={HideToolbar:{defaultValue:!1,value:!1,type:"boolean",explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.3},HideMenubar:{defaultValue:!1,value:!1,type:"boolean",explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.3},HideWindowUI:{defaultValue:!1,value:!1,type:"boolean",explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.3},FitWindow:{defaultValue:!1,value:!1,type:"boolean",explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.3},CenterWindow:{defaultValue:!1,value:!1,type:"boolean",explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.3},DisplayDocTitle:{defaultValue:!1,value:!1,type:"boolean",explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.4},NonFullScreenPageMode:{defaultValue:"UseNone",value:"UseNone",type:"name",explicitSet:!1,valueSet:["UseNone","UseOutlines","UseThumbs","UseOC"],pdfVersion:1.3},Direction:{defaultValue:"L2R",value:"L2R",type:"name",explicitSet:!1,valueSet:["L2R","R2L"],pdfVersion:1.3},ViewArea:{defaultValue:"CropBox",value:"CropBox",type:"name",explicitSet:!1,valueSet:["MediaBox","CropBox","TrimBox","BleedBox","ArtBox"],pdfVersion:1.4},ViewClip:{defaultValue:"CropBox",value:"CropBox",type:"name",explicitSet:!1,valueSet:["MediaBox","CropBox","TrimBox","BleedBox","ArtBox"],pdfVersion:1.4},PrintArea:{defaultValue:"CropBox",value:"CropBox",type:"name",explicitSet:!1,valueSet:["MediaBox","CropBox","TrimBox","BleedBox","ArtBox"],pdfVersion:1.4},PrintClip:{defaultValue:"CropBox",value:"CropBox",type:"name",explicitSet:!1,valueSet:["MediaBox","CropBox","TrimBox","BleedBox","ArtBox"],pdfVersion:1.4},PrintScaling:{defaultValue:"AppDefault",value:"AppDefault",type:"name",explicitSet:!1,valueSet:["AppDefault","None"],pdfVersion:1.6},Duplex:{defaultValue:"",value:"none",type:"name",explicitSet:!1,valueSet:["Simplex","DuplexFlipShortEdge","DuplexFlipLongEdge","none"],pdfVersion:1.7},PickTrayByPDFSize:{defaultValue:!1,value:!1,type:"boolean",explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.7},PrintPageRange:{defaultValue:"",value:"",type:"array",explicitSet:!1,valueSet:null,pdfVersion:1.7},NumCopies:{defaultValue:1,value:1,type:"integer",explicitSet:!1,valueSet:null,pdfVersion:1.7}},l=Object.keys(c),d=[],h=0,f=0,x=0;function b(w,v){var P,_=!1;for(P=0;P<w.length;P+=1)w[P]===v&&(_=!0);return _}if(this.internal.viewerpreferences===void 0&&(this.internal.viewerpreferences={},this.internal.viewerpreferences.configuration=JSON.parse(JSON.stringify(c)),this.internal.viewerpreferences.isSubscribed=!1),n=this.internal.viewerpreferences.configuration,e==="reset"||t===!0){var m=l.length;for(x=0;x<m;x+=1)n[l[x]].value=n[l[x]].defaultValue,n[l[x]].explicitSet=!1}if(pn(e)==="object"){for(s in e)if(i=e[s],b(l,s)&&i!==void 0){if(n[s].type==="boolean"&&typeof i=="boolean")n[s].value=i;else if(n[s].type==="name"&&b(n[s].valueSet,i))n[s].value=i;else if(n[s].type==="integer"&&Number.isInteger(i))n[s].value=i;else if(n[s].type==="array"){for(h=0;h<i.length;h+=1)if(r=!0,i[h].length===1&&typeof i[h][0]=="number")d.push(String(i[h]-1));else if(i[h].length>1){for(f=0;f<i[h].length;f+=1)typeof i[h][f]!="number"&&(r=!1);r===!0&&d.push([i[h][0]-1,i[h][1]-1].join(" "))}n[s].value="["+d.join(" ")+"]"}else n[s].value=n[s].defaultValue;n[s].explicitSet=!0}}return this.internal.viewerpreferences.isSubscribed===!1&&(this.internal.events.subscribe("putCatalog",function(){var w,v=[];for(w in n)n[w].explicitSet===!0&&(n[w].type==="name"?v.push("/"+w+" /"+n[w].value):v.push("/"+w+" "+n[w].value));v.length!==0&&this.internal.write(`/ViewerPreferences
157<<
158`+v.join(`
159`)+`
160>>`)}),this.internal.viewerpreferences.isSubscribed=!0),this.internal.viewerpreferences.configuration=n,this},yt.API.addMetadata=function(e,t){return this.internal.__metadata__===void 0&&(this.internal.__metadata__={metadata:e,namespaceUri:t??"http://jspdf.default.namespaceuri/",rawXml:typeof t=="boolean"&&t},this.internal.events.subscribe("putCatalog",xx),this.internal.events.subscribe("postPutResources",gx)),this},function(e){var t=e.API,n=t.pdfEscape16=function(i,c){for(var l,d=c.metadata.Unicode.widths,h=["","0","00","000","0000"],f=[""],x=0,b=i.length;x<b;
vendor: 38,297 bytes, lines 160-184
160++x){if(l=c.metadata.characterToGlyph(i.charCodeAt(x)),c.metadata.glyIdsUsed.push(l),c.metadata.toUnicode[l]=i.charCodeAt(x),d.indexOf(l)==-1&&(d.push(l),d.push([parseInt(c.metadata.widthOfGlyph(l),10)])),l=="0")return f.join("");l=l.toString(16),f.push(h[4-l.length],l)}return f.join("")},r=function(i){var c,l,d,h,f,x,b;for(f=`/CIDInit /ProcSet findresource begin
16112 dict begin
162begincmap
163/CIDSystemInfo <<
164  /Registry (Adobe)
165  /Ordering (UCS)
166  /Supplement 0
167>> def
168/CMapName /Adobe-Identity-UCS def
169/CMapType 2 def
1701 begincodespacerange
171<0000><ffff>
172endcodespacerange`,d=[],x=0,b=(l=Object.keys(i).sort(function(m,w){return m-w})).length;x<b;x++)c=l[x],d.length>=100&&(f+=`
173`+d.length+` beginbfchar
174`+d.join(`
175`)+`
176endbfchar`,d=[]),i[c]!==void 0&&i[c]!==null&&typeof i[c].toString=="function"&&(h=("0000"+i[c].toString(16)).slice(-4),c=("0000"+(+c).toString(16)).slice(-4),d.push("<"+c+"><"+h+">"));return d.length&&(f+=`
177`+d.length+` beginbfchar
178`+d.join(`
179`)+`
180endbfchar
181`),f+`endcmap
182CMapName currentdict /CMap defineresource pop
183end
184end`};t.events.push(["putFont",function(i){(function(c){var l=c.font,d=c.out,h=c.newObject,f=c.putStream;if(l.metadata instanceof e.API.TTFFont&&l.encoding==="Identity-H"){for(var x=l.metadata.Unicode.widths,b=l.metadata.subset.encode(l.metadata.glyIdsUsed,1),m="",w=0;w<b.length;w++)m+=String.fromCharCode(b[w]);var v=h();f({data:m,addLength1:!0,objectId:v}),d("endobj");var P=h();f({data:r(l.metadata.toUnicode),addLength1:!0,objectId:P}),d("endobj");var _=h();d("<<"),d("/Type /FontDescriptor"),d("/FontName /"+Zi(l.fontName)),d("/FontFile2 "+v+" 0 R"),d("/FontBBox "+e.API.PDFObject.convert(l.metadata.bbox)),d("/Flags "+l.metadata.flags),d("/StemV "+l.metadata.stemV),d("/ItalicAngle "+l.metadata.italicAngle),d("/Ascent "+l.metadata.ascender),d("/Descent "+l.metadata.decender),d("/CapHeight "+l.metadata.capHeight),d(">>"),d("endobj");var q=h();d("<<"),d("/Type /Font"),d("/BaseFont /"+Zi(l.fontName)),d("/FontDescriptor "+_+" 0 R"),d("/W "+e.API.PDFObject.convert(x)),d("/CIDToGIDMap /Identity"),d("/DW 1000"),d("/Subtype /CIDFontType2"),d("/CIDSystemInfo"),d("<<"),d("/Supplement 0"),d("/Registry (Adobe)"),d("/Ordering ("+l.encoding+")"),d(">>"),d(">>"),d("endobj"),l.objectNumber=h(),d("<<"),d("/Type /Font"),d("/Subtype /Type0"),d("/ToUnicode "+P+" 0 R"),d("/BaseFont /"+Zi(l.fontName)),d("/Encoding /"+l.encoding),d("/DescendantFonts ["+q+" 0 R]"),d(">>"),d("endobj"),l.isAlreadyPutted=!0}})(i)}]),t.events.push(["putFont",function(i){(function(c){var l=c.font,d=c.out,h=c.newObject,f=c.putStream;if(l.metadata instanceof e.API.TTFFont&&l.encoding==="WinAnsiEncoding"){for(var x=l.metadata.rawData,b="",m=0;m<x.length;m++)b+=String.fromCharCode(x[m]);var w=h();f({data:b,addLength1:!0,objectId:w}),d("endobj");var v=h();f({data:r(l.metadata.toUnicode),addLength1:!0,objectId:v}),d("endobj");var P=h();d("<<"),d("/Descent "+l.metadata.decender),d("/CapHeight "+l.metadata.capHeight),d("/StemV "+l.metadata.stemV),d("/Type /FontDescriptor"),d("/FontFile2 "+w+" 0 R"),d("/Flags 96"),d("/FontBBox "+e.API.PDFObject.convert(l.metadata.bbox)),d("/FontName /"+Zi(l.fontName)),d("/ItalicAngle "+l.metadata.italicAngle),d("/Ascent "+l.metadata.ascender),d(">>"),d("endobj"),l.objectNumber=h();for(var _=0;_<l.metadata.hmtx.widths.length;_++)l.metadata.hmtx.widths[_]=parseInt(l.metadata.hmtx.widths[_]*(1e3/l.metadata.head.unitsPerEm));d("<</Subtype/TrueType/Type/Font/ToUnicode "+v+" 0 R/BaseFont/"+Zi(l.fontName)+"/FontDescriptor "+P+" 0 R/Encoding/"+l.encoding+" /FirstChar 29 /LastChar 255 /Widths "+e.API.PDFObject.convert(l.metadata.hmtx.widths)+">>"),d("endobj"),l.isAlreadyPutted=!0}})(i)}]);var s=function(i){var c,l=i.text||"",d=i.x,h=i.y,f=i.options||{},x=i.mutex||{},b=x.pdfEscape,m=x.activeFontKey,w=x.fonts,v=m,P="",_=0,q="",T=w[v].encoding;if(w[v].encoding!=="Identity-H")return{text:l,x:d,y:h,options:f,mutex:x};for(q=l,v=m,Array.isArray(l)&&(q=l[0]),_=0;_<q.length;_+=1)w[v].metadata.hasOwnProperty("cmap")&&(c=w[v].metadata.cmap.unicode.codeMap[q[_].charCodeAt(0)]),c||q[_].charCodeAt(0)<256&&w[v].metadata.hasOwnProperty("Unicode")?P+=q[_]:P+="";var B="";return parseInt(v.slice(1))<14||T==="WinAnsiEncoding"?B=b(P,v).split("").map(function(Q){return Q.charCodeAt(0).toString(16)}).join(""):T==="Identity-H"&&(B=n(P,w[v])),x.isHex=!0,{text:B,x:d,y:h,options:f,mutex:x}};t.events.push(["postProcessText",function(i){var c=i.text||"",l=[],d={text:c,x:i.x,y:i.y,options:i.options,mutex:i.mutex};if(Array.isArray(c)){var h=0;for(h=0;h<c.length;h+=1)Array.isArray(c[h])&&c[h].length===3?l.push([s(Object.assign({},d,{text:c[h][0]})).text,c[h][1],c[h][2]]):l.push(s(Object.assign({},d,{text:c[h]})).text);i.text=l}else i.text=s(Object.assign({},d,{text:c})).text}])}(yt),function(e){var t=function(){return this.internal.vFS===void 0&&(this.internal.vFS={}),!0};e.existsFileInVFS=function(n){return t.call(this),this.internal.vFS[n]!==void 0},e.addFileToVFS=function(n,r){return t.call(this),this.internal.vFS[n]=r,this},e.getFileFromVFS=function(n){return t.call(this),this.internal.vFS[n]!==void 0?this.internal.vFS[n]:null}}(yt.API),function(e){e.__bidiEngine__=e.prototype.__bidiEngine__=function(r){var s,i,c,l,d,h,f,x=t,b=[[0,3,0,1,0,0,0],[0,3,0,1,2,2,0],[0,3,0,17,2,0,1],[0,3,5,5,4,1,0],[0,3,21,21,4,0,1],[0,3,5,5,4,2,0]],m=[[2,0,1,1,0,1,0],[2,0,1,1,0,2,0],[2,0,2,1,3,2,0],[2,0,2,33,3,1,1]],w={L:0,R:1,EN:2,AN:3,N:4,B:5,S:6},v={0:0,5:1,6:2,7:3,32:4,251:5,254:6,255:7},P=["(",")","(","<",">","<","[","]","[","{","}","{","«","»","«","‹","›","‹","⁅","⁆","⁅","⁽","⁾","⁽","₍","₎","₍","≤","≥","≤","〈","〉","〈","﹙","﹚","﹙","﹛","﹜","﹛","﹝","﹞","﹝","﹤","﹥","﹤"],_=new RegExp(/^([1-4|9]|1[0-9]|2[0-9]|3[0168]|4[04589]|5[012]|7[78]|159|16[0-9]|17[0-2]|21[569]|22[03489]|250)$/),q=!1,T=0;this.__bidiEngine__={};var B=function(N){var I=N.charCodeAt(),k=I>>8,L=v[k];return L!==void 0?x[256*L+(255&I)]:k===252||k===253?"AL":_.test(k)?"L":k===8?"R":"N"},Q=function(N){for(var I,k=0;k<N.length;k++){if((I=B(N.charAt(k)))==="L")return!1;if(I==="R")return!0}return!1},me=function(N,I,k,L){var H,te,se,K,ae=I[L];switch(ae){case"L":case"R":case"LRE":case"RLE":case"LRO":case"RLO":case"PDF":q=!1;break;case"N":case"AN":break;case"EN":q&&(ae="AN");break;case"AL":q=!0,ae="R";break;case"WS":case"BN":ae="N";break;case"CS":L<1||L+1>=I.length||(H=k[L-1])!=="EN"&&H!=="AN"||(te=I[L+1])!=="EN"&&te!=="AN"?ae="N":q&&(te="AN"),ae=te===H?te:"N";break;case"ES":ae=(H=L>0?k[L-1]:"B")==="EN"&&L+1<I.length&&I[L+1]==="EN"?"EN":"N";break;case"ET":if(L>0&&k[L-1]==="EN"){ae="EN";break}if(q){ae="N";break}for(se=L+1,K=I.length;se<K&&I[se]==="ET";)se++;ae=se<K&&I[se]==="EN"?"EN":"N";break;case"NSM":if(c&&!l){for(K=I.length,se=L+1;se<K&&I[se]==="NSM";)se++;if(se<K){var be=N[L],Ne=be>=1425&&be<=2303||be===64286;if(H=I[se],Ne&&(H==="R"||H==="AL")){ae="R";break}}}ae=L<1||(H=I[L-1])==="B"?"N":k[L-1];break;case"B":q=!1,s=!0,ae=T;break;case"S":i=!0,ae="N"}return ae},ce=function(N,I,k){var L=N.split("");return k&&$(L,k,{hiLevel:T}),L.reverse(),I&&I.reverse(),L.join("")},$=function(N,I,k){var L,H,te,se,K,ae=-1,be=N.length,Ne=0,A=[],E=T?m:b,z=[];for(q=!1,s=!1,i=!1,H=0;H<be;H++)z[H]=B(N[H]);for(te=0;te<be;te++){if(K=Ne,A[te]=me(N,z,A,te),L=240&(Ne=E[K][w[A[te]]]),Ne&=15,I[te]=se=E[Ne][5],L>0)if(L===16){for(H=ae;H<te;H++)I[H]=1;ae=-1}else ae=-1;if(E[Ne][6])ae===-1&&(ae=te);else if(ae>-1){for(H=ae;H<te;H++)I[H]=se;ae=-1}z[te]==="B"&&(I[te]=0),k.hiLevel|=se}i&&function(X,Z,le){for(var fe=0;fe<le;fe++)if(X[fe]==="S"){Z[fe]=T;for(var ue=fe-1;ue>=0&&X[ue]==="WS";ue--)Z[ue]=T}}(z,I,be)},D=function(N,I,k,L,H){if(!(H.hiLevel<N)){if(N===1&&T===1&&!s)return I.reverse(),void(k&&k.reverse());for(var te,se,K,ae,be=I.length,Ne=0;Ne<be;){if(L[Ne]>=N){for(K=Ne+1;K<be&&L[K]>=N;)K++;for(ae=Ne,se=K-1;ae<se;ae++,se--)te=I[ae],I[ae]=I[se],I[se]=te,k&&(te=k[ae],k[ae]=k[se],k[se]=te);Ne=K}Ne++}}},Y=function(N,I,k){var L=N.split(""),H={hiLevel:T};return k||(k=[]),$(L,k,H),function(te,se,K){if(K.hiLevel!==0&&f)for(var ae,be=0;be<te.length;be++)se[be]===1&&(ae=P.indexOf(te[be]))>=0&&(te[be]=P[ae+1])}(L,k,H),D(2,L,I,k,H),D(1,L,I,k,H),L.join("")};return this.__bidiEngine__.doBidiReorder=function(N,I,k){if(function(H,te){if(te)for(var se=0;se<H.length;se++)te[se]=se;l===void 0&&(l=Q(H)),h===void 0&&(h=Q(H))}(N,I),c||!d||h)if(c&&d&&l^h)T=l?1:0,N=ce(N,I,k);else if(!c&&d&&h)T=l?1:0,N=Y(N,I,k),N=ce(N,I);else if(!c||l||d||h){if(c&&!d&&l^h)N=ce(N,I),l?(T=0,N=Y(N,I,k)):(T=1,N=Y(N,I,k),N=ce(N,I));else if(c&&l&&!d&&h)T=1,N=Y(N,I,k),N=ce(N,I);else if(!c&&!d&&l^h){var L=f;l?(T=1,N=Y(N,I,k),T=0,f=!1,N=Y(N,I,k),f=L):(T=0,N=Y(N,I,k),N=ce(N,I),T=1,f=!1,N=Y(N,I,k),f=L,N=ce(N,I))}}else T=0,N=Y(N,I,k);else T=l?1:0,N=Y(N,I,k);return N},this.__bidiEngine__.setOptions=function(N){N&&(c=N.isInputVisual,d=N.isOutputVisual,l=N.isInputRtl,h=N.isOutputRtl,f=N.isSymmetricSwapping)},this.__bidiEngine__.setOptions(r),this.__bidiEngine__};var t=["BN","BN","BN","BN","BN","BN","BN","BN","BN","S","B","S","WS","B","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","B","B","B","S","WS","N","N","ET","ET","ET","N","N","N","N","N","ES","CS","ES","CS","CS","EN","EN","EN","EN","EN","EN","EN","EN","EN","EN","CS","N","N","N","N","N","N","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","N","N","N","N","N","N","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","N","N","N","N","BN","BN","BN","BN","BN","BN","B","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","CS","N","ET","ET","ET","ET","N","N","N","N","L","N","N","BN","N","N","ET","ET","EN","EN","N","L","N","N","N","EN","L","N","N","N","N","N","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","N","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","N","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","N","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","N","N","L","L","L","L","L","L","L","N","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","N","L","N","N","N","N","N","ET","N","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","R","NSM","R","NSM","NSM","R","NSM","NSM","R","NSM","N","N","N","N","N","N","N","N","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","N","N","N","N","N","R","R","R","R","R","N","N","N","N","N","N","N","N","N","N","N","AN","AN","AN","AN","AN","AN","N","N","AL","ET","ET","AL","CS","AL","N","N","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","AL","AL","N","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","AN","AN","AN","AN","AN","AN","AN","AN","AN","AN","ET","AN","AN","AL","AL","AL","NSM","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","NSM","NSM","NSM","NSM","NSM","NSM","NSM","AN","N","NSM","NSM","NSM","NSM","NSM","NSM","AL","AL","NSM","NSM","N","NSM","NSM","NSM","NSM","AL","AL","EN","EN","EN","EN","EN","EN","EN","EN","EN","EN","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","N","AL","AL","NSM","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","N","N","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","AL","N","N","N","N","N","N","N","N","N","N","N","N","N","N","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","R","R","N","N","N","N","R","N","N","N","N","N","WS","WS","WS","WS","WS","WS","WS","WS","WS","WS","WS","BN","BN","BN","L","R","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","WS","B","LRE","RLE","PDF","LRO","RLO","CS","ET","ET","ET","ET","ET","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","CS","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","WS","BN","BN","BN","BN","BN","N","LRI","RLI","FSI","PDI","BN","BN","BN","BN","BN","BN","EN","L","N","N","EN","EN","EN","EN","EN","EN","ES","ES","N","N","N","L","EN","EN","EN","EN","EN","EN","EN","EN","EN","EN","ES","ES","N","N","N","N","L","L","L","L","L","L","L","L","L","L","L","L","L","N","N","N","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","L","L","L","L","L","L","L","N","N","N","N","N","N","N","N","N","N","N","N","L","L","L","L","L","N","N","N","N","N","R","NSM","R","R","R","R","R","R","R","R","R","R","ES","R","R","R","R","R","R","R","R","R","R","R","R","R","N","R","R","R","R","R","N","R","N","R","R","N","R","R","N","R","R","R","R","R","R","R","R","R","R","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","CS","N","CS","N","N","CS","N","N","N","N","N","N","N","N","N","ET","N","N","ES","ES","N","N","N","N","N","ET","ET","N","N","N","N","N","AL","AL","AL","AL","AL","N","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","N","N","BN","N","N","N","ET","ET","ET","N","N","N","N","N","ES","CS","ES","CS","CS","EN","EN","EN","EN","EN","EN","EN","EN","EN","EN","CS","N","N","N","N","N","N","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","N","N","N","N","N","N","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","N","N","N","N","N","N","N","N","N","N","N","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","N","N","N","L","L","L","L","L","L","N","N","L","L","L","L","L","L","N","N","L","L","L","L","L","L","N","N","L","L","L","N","N","N","ET","ET","N","N","N","ET","ET","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N"],n=new e.__bidiEngine__({isInputVisual:!0});e.API.events.push(["postProcessText",function(r){var s=r.text;r.x,r.y;var i=r.options||{};r.mutex,i.lang;var c=[];if(i.isInputVisual=typeof i.isInputVisual!="boolean"||i.isInputVisual,n.setOptions(i),Object.prototype.toString.call(s)==="[object Array]"){var l=0;for(c=[],l=0;l<s.length;l+=1)Object.prototype.toString.call(s[l])==="[object Array]"?c.push([n.doBidiReorder(s[l][0]),s[l][1],s[l][2]]):c.push([n.doBidiReorder(s[l])]);r.text=c}else r.text=n.doBidiReorder(s);n.setOptions({isInputVisual:!0})}])}(yt),yt.API.TTFFont=function(){function e(t){var n;if(this.rawData=t,n=this.contents=new Gs(t),this.contents.pos=4,n.readString(4)==="ttcf")throw new Error("TTCF not supported.");n.pos=0,this.parse(),this.subset=new Mx(this),this.registerTTF()}return e.open=function(t){return new e(t)},e.prototype.parse=function(){return this.directory=new yx(this.contents),this.head=new vx(this),this.name=new Sx(this),this.cmap=new Np(this),this.toUnicode={},this.hhea=new _x(this),this.maxp=new Lx(this),this.hmtx=new Ax(this),this.post=new Nx(this),this.os2=new wx(this),this.loca=new Ex(this),this.glyf=new kx(this),this.ascender=this.os2.exists&&this.os2.ascender||this.hhea.ascender,this.decender=this.os2.exists&&this.os2.decender||this.hhea.decender,this.lineGap=this.os2.exists&&this.os2.lineGap||this.hhea.lineGap,this.bbox=[this.head.xMin,this.head.yMin,this.head.xMax,this.head.yMax]},e.prototype.registerTTF=function(){var t,n,r,s,i;if(this.scaleFactor=1e3/this.head.unitsPerEm,this.bbox=(function(){var c,l,d,h;for(h=[],c=0,l=(d=this.bbox).length;c<l;c++)t=d[c],h.push(Math.round(t*this.scaleFactor));return h}).call(this),this.stemV=0,this.post.exists?(r=255&(s=this.post.italic_angle),32768&(n=s>>16)&&(n=-(1+(65535^n))),this.italicAngle=+(n+"."+r)):this.italicAngle=0,this.ascender=Math.round(this.ascender*this.scaleFactor),this.decender=Math.round(this.decender*this.scaleFactor),this.lineGap=Math.round(this.lineGap*this.scaleFactor),this.capHeight=this.os2.exists&&this.os2.capHeight||this.ascender,this.xHeight=this.os2.exists&&this.os2.xHeight||0,this.familyClass=(this.os2.exists&&this.os2.familyClass||0)>>8,this.isSerif=(i=this.familyClass)===1||i===2||i===3||i===4||i===5||i===7,this.isScript=this.familyClass===10,this.flags=0,this.post.isFixedPitch&&(this.flags|=1),this.isSerif&&(this.flags|=2),this.isScript&&(this.flags|=8),this.italicAngle!==0&&(this.flags|=64),this.flags|=32,!this.cmap.unicode)throw new Error("No unicode cmap for font")},e.prototype.characterToGlyph=function(t){var n;return((n=this.cmap.unicode)!=null?n.codeMap[t]:void 0)||0},e.prototype.widthOfGlyph=function(t){var n;return n=1e3/this.head.unitsPerEm,this.hmtx.forGlyph(t).advance*n},e.prototype.widthOfString=function(t,n,r){var s,i,c,l;for(c=0,i=0,l=(t=""+t).length;0<=l?i<l:i>l;i=0<=l?++i:--i)s=t.charCodeAt(i),c+=this.widthOfGlyph(this.characterToGlyph(s))+r*(1e3/n)||0;return c*(n/1e3)},e.prototype.lineHeight=function(t,n){var r;return n==null&&(n=!1),r=n?this.lineGap:0,(this.ascender+r-this.decender)/1e3*t},e}();var Ra,Gs=function(){function e(t){this.data=t??[],this.pos=0,this.length=this.data.length}return e.prototype.readByte=function(){return this.data[this.pos++]},e.prototype.writeByte=function(t){return this.data[this.pos++]=t},e.prototype.readUInt32=function(){return 16777216*this.readByte()+(this.readByte()<<16)+(this.readByte()<<8)+this.readByte()},e.prototype.writeUInt32=function(t){return this.writeByte(t>>>24&255),this.writeByte(t>>16&255),this.writeByte(t>>8&255),this.writeByte(255&t)},e.prototype.readInt32=function(){var t;return(t=this.readUInt32())>=2147483648?t-4294967296:t},e.prototype.writeInt32=function(t){return t<0&&(t+=4294967296),this.writeUInt32(t)},e.prototype.readUInt16=function(){return this.readByte()<<8|this.readByte()},e.prototype.writeUInt16=function(t){return this.writeByte(t>>8&255),this.writeByte(255&t)},e.prototype.readInt16=function(){var t;return(t=this.readUInt16())>=32768?t-65536:t},e.prototype.writeInt16=function(t){return t<0&&(t+=65536),this.writeUInt16(t)},e.prototype.readString=function(t){var n,r;for(r=[],n=0;0<=t?n<t:n>t;n=0<=t?++n:--n)r[n]=String.fromCharCode(this.readByte());return r.join("")},e.prototype.writeString=function(t){var n,r,s;for(s=[],n=0,r=t.length;0<=r?n<r:n>r;n=0<=r?++n:--n)s.push(this.writeByte(t.charCodeAt(n)));return s},e.prototype.readShort=function(){return this.readInt16()},e.prototype.writeShort=function(t){return this.writeInt16(t)},e.prototype.readLongLong=function(){var t,n,r,s,i,c,l,d;return t=this.readByte(),n=this.readByte(),r=this.readByte(),s=this.readByte(),i=this.readByte(),c=this.readByte(),l=this.readByte(),d=this.readByte(),128&t?-1*(72057594037927940*(255^t)+281474976710656*(255^n)+1099511627776*(255^r)+4294967296*(255^s)+16777216*(255^i)+65536*(255^c)+256*(255^l)+(255^d)+1):72057594037927940*t+281474976710656*n+1099511627776*r+4294967296*s+16777216*i+65536*c+256*l+d},e.prototype.writeLongLong=function(t){var n,r;return n=Math.floor(t/4294967296),r=4294967295&t,this.writeByte(n>>24&255),this.writeByte(n>>16&255),this.writeByte(n>>8&255),this.writeByte(255&n),this.writeByte(r>>24&255),this.writeByte(r>>16&255),this.writeByte(r>>8&255),this.writeByte(255&r)},e.prototype.readInt=function(){return this.readInt32()},e.prototype.writeInt=function(t){return this.writeInt32(t)},e.prototype.read=function(t){var n,r;for(n=[],r=0;0<=t?r<t:r>t;r=0<=t?++r:--r)n.push(this.readByte());return n},e.prototype.write=function(t){var n,r,s,i;for(i=[],r=0,s=t.length;r<s;r++)n=t[r],i.push(this.writeByte(n));return i},e}(),yx=function(){var e;function t(n){var r,s,i;for(this.scalarType=n.readInt(),this.tableCount=n.readShort(),this.searchRange=n.readShort(),this.entrySelector=n.readShort(),this.rangeShift=n.readShort(),this.tables={},s=0,i=this.tableCount;0<=i?s<i:s>i;s=0<=i?++s:--s)r={tag:n.readString(4),checksum:n.readInt(),offset:n.readInt(),length:n.readInt()},this.tables[r.tag]=r}return t.prototype.encode=function(n){var r,s,i,c,l,d,h,f,x,b,m,w,v;for(v in m=Object.keys(n).length,d=Math.log(2),x=16*Math.floor(Math.log(m)/d),c=Math.floor(x/d),f=16*m-x,(s=new Gs).writeInt(this.scalarType),s.writeShort(m),s.writeShort(x),s.writeShort(c),s.writeShort(f),i=16*m,h=s.pos+i,l=null,w=[],n)for(b=n[v],s.writeString(v),s.writeInt(e(b)),s.writeInt(h),s.writeInt(b.length),w=w.concat(b),v==="head"&&(l=h),h+=b.length;h%4;)w.push(0),h++;return s.write(w),r=2981146554-e(s.data),s.pos=l+8,s.writeUInt32(r),s.data},e=function(n){var r,s,i,c;for(n=jp.call(n);n.length%4;)n.push(0);for(i=new Gs(n),s=0,r=0,c=n.length;r<c;r=r+=4)s+=i.readUInt32();return 4294967295&s},t}(),bx={}.hasOwnProperty,es=function(e,t){for(var n in t)bx.call(t,n)&&(e[n]=t[n]);function r(){this.constructor=e}return r.prototype=t.prototype,e.prototype=new r,e.__super__=t.prototype,e};Ra=function(){function e(t){var n;this.file=t,n=this.file.directory.tables[this.tag],this.exists=!!n,n&&(this.offset=n.offset,this.length=n.length,this.parse(this.file.contents))}return e.prototype.parse=function(){},e.prototype.encode=function(){},e.prototype.raw=function(){return this.exists?(this.file.contents.pos=this.offset,this.file.contents.read(this.length)):null},e}();var vx=function(){function e(){return e.__super__.constructor.apply(this,arguments)}return es(e,Ra),e.prototype.tag="head",e.prototype.parse=function(t){return t.pos=this.offset,this.version=t.readInt(),this.revision=t.readInt(),this.checkSumAdjustment=t.readInt(),this.magicNumber=t.readInt(),this.flags=t.readShort(),this.unitsPerEm=t.readShort(),this.created=t.readLongLong(),this.modified=t.readLongLong(),this.xMin=t.readShort(),this.yMin=t.readShort(),this.xMax=t.readShort(),this.yMax=t.readShort(),this.macStyle=t.readShort(),this.lowestRecPPEM=t.readShort(),this.fontDirectionHint=t.readShort(),this.indexToLocFormat=t.readShort(),this.glyphDataFormat=t.readShort()},e.prototype.encode=function(t){var n;return(n=new Gs).writeInt(this.version),n.writeInt(this.revision),n.writeInt(this.checkSumAdjustment),n.writeInt(this.magicNumber),n.writeShort(this.flags),n.writeShort(this.unitsPerEm),n.writeLongLong(this.created),n.writeLongLong(this.modified),n.writeShort(this.xMin),n.writeShort(this.yMin),n.writeShort(this.xMax),n.writeShort(this.yMax),n.writeShort(this.macStyle),n.writeShort(this.lowestRecPPEM),n.writeShort(this.fontDirectionHint),n.writeShort(t),n.writeShort(this.glyphDataFormat),n.data},e}(),Nf=function(){function e(t,n){var r,s,i,c,l,d,h,f,x,b,m,w,v,P,_,q,T;switch(this.platformID=t.readUInt16(),this.encodingID=t.readShort(),this.offset=n+t.readInt(),x=t.pos,t.pos=this.offset,this.format=t.readUInt16(),this.length=t.readUInt16(),this.language=t.readUInt16(),this.isUnicode=this.platformID===3&&this.encodingID===1&&this.format===4||this.platformID===0&&this.format===4,this.codeMap={},this.format){case 0:for(d=0;d<256;++d)this.codeMap[d]=t.readByte();break;case 4:for(m=t.readUInt16(),b=m/2,t.pos+=6,i=function(){var B,Q;for(Q=[],d=B=0;0<=b?B<b:B>b;d=0<=b?++B:--B)Q.push(t.readUInt16());return Q}(),t.pos+=2,v=function(){var B,Q;for(Q=[],d=B=0;0<=b?B<b:B>b;d=0<=b?++B:--B)Q.push(t.readUInt16());return Q}(),h=function(){var B,Q;for(Q=[],d=B=0;0<=b?B<b:B>b;d=0<=b?++B:--B)Q.push(t.readUInt16());return Q}(),f=function(){var B,Q;for(Q=[],d=B=0;0<=b?B<b:B>b;d=0<=b?++B:--B)Q.push(t.readUInt16());return Q}(),s=(this.length-t.pos+this.offset)/2,l=function(){var B,Q;for(Q=[],d=B=0;0<=s?B<s:B>s;d=0<=s?++B:--B)Q.push(t.readUInt16());return Q}(),d=_=0,T=i.length;_<T;d=++_)for(P=i[d],r=q=w=v[d];w<=P?q<=P:q>=P;r=w<=P?++q:--q)f[d]===0?c=r+h[d]:(c=l[f[d]/2+(r-w)-(b-d)]||0)!==0&&(c+=h[d]),this.codeMap[r]=65535&c}t.pos=x}return e.encode=function(t,n){var r,s,i,c,l,d,h,f,x,b,m,w,v,P,_,q,T,B,Q,me,ce,$,D,Y,N,I,k,L,H,te,se,K,ae,be,Ne,A,E,z,X,Z,le,fe,ue,_e,Ce,ve;switch(L=new Gs,c=Object.keys(t).sort(function(we,De){return we-De}),n){case"macroman":for(v=0,P=function(){var we=[];for(w=0;w<256;++w)we.push(0);return we}(),q={0:0},i={},H=0,ae=c.length;H<ae;H++)q[ue=t[s=c[H]]]==null&&(q[ue]=++v),i[s]={old:t[s],new:q[t[s]]},P[s]=q[t[s]];return L.writeUInt16(1),L.writeUInt16(0),L.writeUInt32(12),L.writeUInt16(0),L.writeUInt16(262),L.writeUInt16(0),L.write(P),{charMap:i,subtable:L.data,maxGlyphID:v+1};case"unicode":for(I=[],x=[],T=0,q={},r={},_=h=null,te=0,be=c.length;te<be;te++)q[Q=t[s=c[te]]]==null&&(q[Q]=++T),r[s]={old:Q,new:q[Q]},l=q[Q]-s,_!=null&&l===h||(_&&x.push(_),I.push(s),h=l),_=s;for(_&&x.push(_),x.push(65535),I.push(65535),Y=2*(D=I.length),$=2*Math.pow(Math.log(D)/Math.LN2,2),b=Math.log($/2)/Math.LN2,ce=2*D-$,d=[],me=[],m=[],w=se=0,Ne=I.length;se<Ne;w=++se){if(N=I[w],f=x[w],N===65535){d.push(0),me.push(0);break}if(N-(k=r[N].new)>=32768)for(d.push(0),me.push(2*(m.length+D-w)),s=K=N;N<=f?K<=f:K>=f;s=N<=f?++K:--K)m.push(r[s].new);else d.push(k-N),me.push(0)}for(L.writeUInt16(3),L.writeUInt16(1),L.writeUInt32(12),L.writeUInt16(4),L.writeUInt16(16+8*D+2*m.length),L.writeUInt16(0),L.writeUInt16(Y),L.writeUInt16($),L.writeUInt16(b),L.writeUInt16(ce),le=0,A=x.length;le<A;le++)s=x[le],L.writeUInt16(s);for(L.writeUInt16(0),fe=0,E=I.length;fe<E;fe++)s=I[fe],L.writeUInt16(s);for(_e=0,z=d.length;_e<z;_e++)l=d[_e],L.writeUInt16(l);for(Ce=0,X=me.length;Ce<X;Ce++)B=me[Ce],L.writeUInt16(B);for(ve=0,Z=m.length;ve<Z;ve++)v=m[ve],L.writeUInt16(v);return{charMap:r,subtable:L.data,maxGlyphID:T+1}}},e}(),Np=function(){function e(){return e.__super__.constructor.apply(this,arguments)}return es(e,Ra),e.prototype.tag="cmap",e.prototype.parse=function(t){var n,r,s;for(t.pos=this.offset,this.version=t.readUInt16(),s=t.readUInt16(),this.tables=[],this.unicode=null,r=0;0<=s?r<s:r>s;r=0<=s?++r:--r)n=new Nf(t,this.offset),this.tables.push(n),n.isUnicode&&this.unicode==null&&(this.unicode=n);return!0},e.encode=function(t,n){var r,s;return n==null&&(n="macroman"),r=Nf.encode(t,n),(s=new Gs).writeUInt16(0),s.writeUInt16(1),r.table=s.data.concat(r.subtable),r},e}(),_x=function(){function e(){return e.__super__.constructor.apply(this,arguments)}return es(e,Ra),e.prototype.tag="hhea",e.prototype.parse=function(t){return t.pos=this.offset,this.version=t.readInt(),this.ascender=t.readShort(),this.decender=t.readShort(),this.lineGap=t.readShort(),this.advanceWidthMax=t.readShort(),this.minLeftSideBearing=t.readShort(),this.minRightSideBearing=t.readShort(),this.xMaxExtent=t.readShort(),this.caretSlopeRise=t.readShort(),this.caretSlopeRun=t.readShort(),this.caretOffset=t.readShort(),t.pos+=8,this.metricDataFormat=t.readShort(),this.numberOfMetrics=t.readUInt16()},e}(),wx=function(){function e(){return e.__super__.constructor.apply(this,arguments)}return es(e,Ra),e.prototype.tag="OS/2",e.prototype.parse=function(t){if(t.pos=this.offset,this.version=t.readUInt16(),this.averageCharWidth=t.readShort(),this.weightClass=t.readUInt16(),this.widthClass=t.readUInt16(),this.type=t.readShort(),this.ySubscriptXSize=t.readShort(),this.ySubscriptYSize=t.readShort(),this.ySubscriptXOffset=t.readShort(),this.ySubscriptYOffset=t.readShort(),this.ySuperscriptXSize=t.readShort(),this.ySuperscriptYSize=t.readShort(),this.ySuperscriptXOffset=t.readShort(),this.ySuperscriptYOffset=t.readShort(),this.yStrikeoutSize=t.readShort(),this.yStrikeoutPosition=t.readShort(),this.familyClass=t.readShort(),this.panose=function(){var n,r;for(r=[],n=0;n<10;++n)r.push(t.readByte());return r}(),this.charRange=function(){var n,r;for(r=[],n=0;n<4;++n)r.push(t.readInt());return r}(),this.vendorID=t.readString(4),this.selection=t.readShort(),this.firstCharIndex=t.readShort(),this.lastCharIndex=t.readShort(),this.version>0&&(this.ascent=t.readShort(),this.descent=t.readShort(),this.lineGap=t.readShort(),this.winAscent=t.readShort(),this.winDescent=t.readShort(),this.codePageRange=function(){var n,r;for(r=[],n=0;n<2;n=++n)r.push(t.readInt());return r}(),this.version>1))return this.xHeight=t.readShort(),this.capHeight=t.readShort(),this.defaultChar=t.readShort(),this.breakChar=t.readShort(),this.maxContext=t.readShort()},e}(),Nx=function(){function e(){return e.__super__.constructor.apply(this,arguments)}return es(e,Ra),e.prototype.tag="post",e.prototype.parse=function(t){var n,r,s;switch(t.pos=this.offset,this.format=t.readInt(),this.italicAngle=t.readInt(),this.underlinePosition=t.readShort(),this.underlineThickness=t.readShort(),this.isFixedPitch=t.readInt(),this.minMemType42=t.readInt(),this.maxMemType42=t.readInt(),this.minMemType1=t.readInt(),this.maxMemType1=t.readInt(),this.format){case 65536:case 196608:break;case 131072:var i;for(r=t.readUInt16(),this.glyphNameIndex=[],i=0;0<=r?i<r:i>r;i=0<=r?++i:--i)this.glyphNameIndex.push(t.readUInt16());for(this.names=[],s=[];t.pos<this.offset+this.length;)n=t.readByte(),s.push(this.names.push(t.readString(n)));return s;case 151552:return r=t.readUInt16(),this.offsets=t.read(r);case 262144:return this.map=(function(){var c,l,d;for(d=[],i=c=0,l=this.file.maxp.numGlyphs;0<=l?c<l:c>l;i=0<=l?++c:--c)d.push(t.readUInt32());return d}).call(this)}},e}(),jx=function(e,t){this.raw=e,this.length=e.length,this.platformID=t.platformID,this.encodingID=t.encodingID,this.languageID=t.languageID},Sx=function(){function e(){return e.__super__.constructor.apply(this,arguments)}return es(e,Ra),e.prototype.tag="name",e.prototype.parse=function(t){var n,r,s,i,c,l,d,h,f,x,b;for(t.pos=this.offset,t.readShort(),n=t.readShort(),l=t.readShort(),r=[],i=0;0<=n?i<n:i>n;i=0<=n?++i:--i)r.push({platformID:t.readShort(),encodingID:t.readShort(),languageID:t.readShort(),nameID:t.readShort(),length:t.readShort(),offset:this.offset+l+t.readShort()});for(d={},i=f=0,x=r.length;f<x;i=++f)s=r[i],t.pos=s.offset,h=t.readString(s.length),c=new jx(h,s),d[b=s.nameID]==null&&(d[b]=[]),d[s.nameID].push(c);this.strings=d,this.copyright=d[0],this.fontFamily=d[1],this.fontSubfamily=d[2],this.uniqueSubfamily=d[3],this.fontName=d[4],this.version=d[5];try{this.postscriptName=d[6][0].raw.replace(/[\x00-\x19\x80-\xff]/g,"")}catch{this.postscriptName=d[4][0].raw.replace(/[\x00-\x19\x80-\xff]/g,"")}return this.trademark=d[7],this.manufacturer=d[8],this.designer=d[9],this.description=d[10],this.vendorUrl=d[11],this.designerUrl=d[12],this.license=d[13],this.licenseUrl=d[14],this.preferredFamily=d[15],this.preferredSubfamily=d[17],this.compatibleFull=d[18],this.sampleText=d[19]},e}(),Lx=function(){function e(){return e.__super__.constructor.apply(this,arguments)}return es(e,Ra),e.prototype.tag="maxp",e.prototype.parse=function(t){return t.pos=this.offset,this.version=t.readInt(),this.numGlyphs=t.readUInt16(),this.maxPoints=t.readUInt16(),this.maxContours=t.readUInt16(),this.maxCompositePoints=t.readUInt16(),this.maxComponentContours=t.readUInt16(),this.maxZones=t.readUInt16(),this.maxTwilightPoints=t.readUInt16(),this.maxStorage=t.readUInt16(),this.maxFunctionDefs=t.readUInt16(),this.maxInstructionDefs=t.readUInt16(),this.maxStackElements=t.readUInt16(),this.maxSizeOfInstructions=t.readUInt16(),this.maxComponentElements=t.readUInt16(),this.maxComponentDepth=t.readUInt16()},e}(),Ax=function(){function e(){return e.__super__.constructor.apply(this,arguments)}return es(e,Ra),e.prototype.tag="hmtx",e.prototype.parse=function(t){var n,r,s,i,c,l,d;for(t.pos=this.offset,this.metrics=[],n=0,l=this.file.hhea.numberOfMetrics;0<=l?n<l:n>l;n=0<=l?++n:--n)this.metrics.push({advance:t.readUInt16(),lsb:t.readInt16()});for(s=this.file.maxp.numGlyphs-this.file.hhea.numberOfMetrics,this.leftSideBearings=function(){var h,f;for(f=[],n=h=0;0<=s?h<s:h>s;n=0<=s?++h:--h)f.push(t.readInt16());return f}(),this.widths=(function(){var h,f,x,b;for(b=[],h=0,f=(x=this.metrics).length;h<f;h++)i=x[h],b.push(i.advance);return b}).call(this),r=this.widths[this.widths.length-1],d=[],n=c=0;0<=s?c<s:c>s;n=0<=s?++c:--c)d.push(this.widths.push(r));return d},e.prototype.forGlyph=function(t){return t in this.metrics?this.metrics[t]:{advance:this.metrics[this.metrics.length-1].advance,lsb:this.leftSideBearings[t-this.metrics.length]}},e}(),jp=[].slice,kx=function(){function e(){return e.__super__.constructor.apply(this,arguments)}return es(e,Ra),e.prototype.tag="glyf",e.prototype.parse=function(){return this.cache={}},e.prototype.glyphFor=function(t){var n,r,s,i,c,l,d,h,f,x;return t in this.cache?this.cache[t]:(i=this.file.loca,n=this.file.contents,r=i.indexOf(t),(s=i.lengthOf(t))===0?this.cache[t]=null:(n.pos=this.offset+r,c=(l=new Gs(n.read(s))).readShort(),h=l.readShort(),x=l.readShort(),d=l.readShort(),f=l.readShort(),this.cache[t]=c===-1?new Px(l,h,x,d,f):new Cx(l,c,h,x,d,f),this.cache[t]))},e.prototype.encode=function(t,n,r){var s,i,c,l,d;for(c=[],i=[],l=0,d=n.length;l<d;l++)s=t[n[l]],i.push(c.length),s&&(c=c.concat(s.encode(r)));return i.push(c.length),{table:c,offsets:i}},e}(),Cx=function(){function e(t,n,r,s,i,c){this.raw=t,this.numberOfContours=n,this.xMin=r,this.yMin=s,this.xMax=i,this.yMax=c,this.compound=!1}return e.prototype.encode=function(){return this.raw.data},e}(),Px=function(){function e(t,n,r,s,i){var c,l;for(this.raw=t,this.xMin=n,this.yMin=r,this.xMax=s,this.yMax=i,this.compound=!0,this.glyphIDs=[],this.glyphOffsets=[],c=this.raw;l=c.readShort(),this.glyphOffsets.push(c.pos),this.glyphIDs.push(c.readUInt16()),32&l;)c.pos+=1&l?4:2,128&l?c.pos+=8:64&l?c.pos+=4:8&l&&(c.pos+=2)}return e.prototype.encode=function(){var t,n,r;for(n=new Gs(jp.call(this.raw.data)),t=0,r=this.glyphIDs.length;t<r;++t)n.pos=this.glyphOffsets[t];return n.data},e}(),Ex=function(){function e(){return e.__super__.constructor.apply(this,arguments)}return es(e,Ra),e.prototype.tag="loca",e.prototype.parse=function(t){var n,r;return t.pos=this.offset,n=this.file.head.indexToLocFormat,this.offsets=n===0?(function(){var s,i;for(i=[],r=0,s=this.length;r<s;r+=2)i.push(2*t.readUInt16());return i}).call(this):(function(){var s,i;for(i=[],r=0,s=this.length;r<s;r+=4)i.push(t.readUInt32());return i}).call(this)},e.prototype.indexOf=function(t){return this.offsets[t]},e.prototype.lengthOf=function(t){return this.offsets[t+1]-this.offsets[t]}
184,e.prototype.encode=function(t,n){for(var r=new Uint32Array(this.offsets.length),s=0,i=0,c=0;c<r.length;++c)if(r[c]=s,i<n.length&&n[i]==c){++i,r[c]=s;var l=this.offsets[c],d=this.offsets[c+1]-l;d>0&&(s+=d)}for(var h=new Array(4*r.length),f=0;f<r.length;++f)h[4*f+3]=255&r[f],h[4*f+2]=(65280&r[f])>>8,h[4*f+1]=(16711680&r[f])>>16,h[4*f]=(4278190080&r[f])>>24;return h},e}(),Mx=function(){function e(t){this.font=t,this.subset={},this.unicodes={},this.next=33}return e.prototype.generateCmap=function(){var t,n,r,s,i;for(n in s=this.font.cmap.tables[0].codeMap,t={},i=this.subset)r=i[n],t[n]=s[r];return t},e.prototype.glyphsFor=function(t){var n,r,s,i,c,l,d;for(s={},c=0,l=t.length;c<l;c++)s[i=t[c]]=this.font.glyf.glyphFor(i);for(i in n=[],s)(r=s[i])!=null&&r.compound&&n.push.apply(n,r.glyphIDs);if(n.length>0)for(i in d=this.glyphsFor(n))r=d[i],s[i]=r;return s},e.prototype.encode=function(t,n){var r,s,i,c,l,d,h,f,x,b,m,w,v,P,_;for(s in r=Np.encode(this.generateCmap(),"unicode"),c=this.glyphsFor(t),m={0:0},_=r.charMap)m[(d=_[s]).old]=d.new;for(w in b=r.maxGlyphID,c)w in m||(m[w]=b++);return f=function(q){var T,B;for(T in B={},q)B[q[T]]=T;return B}(m),x=Object.keys(f).sort(function(q,T){return q-T}),v=function(){var q,T,B;for(B=[],q=0,T=x.length;q<T;q++)l=x[q],B.push(f[l]);return B}(),i=this.font.glyf.encode(c,v,m),h=this.font.loca.encode(i.offsets,v),P={cmap:this.font.cmap.raw(),glyf:i.table,loca:h,hmtx:this.font.hmtx.raw(),hhea:this.font.hhea.raw(),maxp:this.font.maxp.raw(),post:this.font.post.raw(),name:this.font.name.raw(),head:this.font.head.encode(n)},this.font.os2.exists&&(P["OS/2"]=this.font.os2.raw()),this.font.directory.encode(P)},e}();yt.API.PDFObject=function(){var e;function t(){}return e=function(n,r){return(Array(r+1).join("0")+n).slice(-r)},t.convert=function(n){var r,s,i,c;if(Array.isArray(n))return"["+function(){var l,d,h;for(h=[],l=0,d=n.length;l<d;l++)r=n[l],h.push(t.convert(r));return h}().join(" ")+"]";if(typeof n=="string")return"/"+n;if(n!=null&&n.isString)return"("+n+")";if(n instanceof Date)return"(D:"+e(n.getUTCFullYear(),4)+e(n.getUTCMonth(),2)+e(n.getUTCDate(),2)+e(n.getUTCHours(),2)+e(n.getUTCMinutes(),2)+e(n.getUTCSeconds(),2)+"Z)";if({}.toString.call(n)==="[object Object]"){for(s in i=["<<"],n)c=n[s],i.push("/"+s+" "+t.convert(c));return i.push(">>"),i.join(`
185`)}return""+n},t}();function Sp(e,t,n,r,s){r=r||{};var i=1.15,c=s.internal.scaleFactor,l=s.internal.getFontSize()/c,d=s.getLineHeightFactor?s.getLineHeightFactor():i,h=l*d,f=/\r\n|\r|\n/g,x="",b=1;if((r.valign==="middle"||r.valign==="bottom"||r.halign==="center"||r.halign==="right")&&(x=typeof e=="string"?e.split(f):e,b=x.length||1),n+=l*(2-i),r.valign==="middle"?n-=b/2*h:r.valign==="bottom"&&(n-=b*h),r.halign==="center"||r.halign==="right"){var m=l;if(r.halign==="center"&&(m*=.5),x&&b>=1){for(var w=0;w<x.length;w++)s.text(x[w],t-s.getStringUnitWidth(x[w])*m,n),n+=h;return s}t-=s.getStringUnitWidth(e)*m}return r.halign==="justify"?s.text(e,t,n,{maxWidth:r.maxWidth||100,align:"justify"}):s.text(e,t,n),s}var jf={},oo=function(){function e(t){this.jsPDFDocument=t,this.userStyles={textColor:t.getTextColor?this.jsPDFDocument.getTextColor():0,fontSize:t.internal.getFontSize(),fontStyle:t.internal.getFont().fontStyle,font:t.internal.getFont().fontName,lineWidth:t.getLineWidth?this.jsPDFDocument.getLineWidth():0,lineColor:t.getDrawColor?this.jsPDFDocument.getDrawColor():0}}return e.setDefaults=function(t,n){n===void 0&&(n=null),n?n.__autoTableDocumentDefaults=t:jf=t},e.unifyColor=function(t){return Array.isArray(t)?t:typeof t=="number"?[t,t,t]:typeof t=="string"?[t]:null},e.prototype.applyStyles=function(t,n){var r,s,i;n===void 0&&(n=!1),t.fontStyle&&this.jsPDFDocument.setFontStyle&&this.jsPDFDocument.setFontStyle(t.fontStyle);var c=this.jsPDFDocument.internal.getFont(),l=c.fontStyle,d=c.fontName;if(t.font&&(d=t.font),t.fontStyle){l=t.fontStyle;var h=this.getFontList()[d];h&&h.indexOf(l)===-1&&this.jsPDFDocument.setFontStyle&&(this.jsPDFDocument.setFontStyle(h[0]),l=h[0])}if(this.jsPDFDocument.setFont(d,l),t.fontSize&&this.jsPDFDocument.setFontSize(t.fontSize),!n){var f=e.unifyColor(t.fillColor);f&&(r=this.jsPDFDocument).setFillColor.apply(r,f),f=e.unifyColor(t.textColor),f&&(s=this.jsPDFDocument).setTextColor.apply(s,f),f=e.unifyColor(t.lineColor),f&&(i=this.jsPDFDocument).setDrawColor.apply(i,f),typeof t.lineWidth=="number"&&this.jsPDFDocument.setLineWidth(t.lineWidth)}},e.prototype.splitTextToSize=function(t,n,r){return this.jsPDFDocument.splitTextToSize(t,n,r)},e.prototype.rect=function(t,n,r,s,i){return this.jsPDFDocument.rect(t,n,r,s,i)},e.prototype.getLastAutoTable=function(){return this.jsPDFDocument.lastAutoTable||null},e.prototype.getTextWidth=function(t){return this.jsPDFDocument.getTextWidth(t)},e.prototype.getDocument=function(){return this.jsPDFDocument},e.prototype.setPage=function(t){this.jsPDFDocument.setPage(t)},e.prototype.addPage=function(){return this.jsPDFDocument.addPage()},e.prototype.getFontList=function(){return this.jsPDFDocument.getFontList(
185)},e.prototype.getGlobalOptions=function(){return jf||{}},e.prototype.getDocumentOptions=function(){return this.jsPDFDocument.__autoTableDocumentDefaults||{}},e.prototype.pageSize=function(){var t=this.jsPDFDocument.internal.pageSize;return t.width==null&&(t={width:t.getWidth(),height:t.getHeight()}),t},e.prototype.scaleFactor=function(){return this.jsPDFDocument.internal.scaleFactor},e.prototype.getLineHeightFactor=function(){var t=this.jsPDFDocument;return t.getLineHeightFactor?t.getLineHeightFactor():1.15},e.prototype.getLineHeight=function(t){return t/this.scaleFactor()*this.getLineHeightFactor()},e.prototype.pageNumber=function(){var t=this.jsPDFDocument.internal.getCurrentPageInfo();return t?t.pageNumber:this.jsPDFDocument.internal.getNumberOfPages()},e}(),Md=function(e,t){return Md=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(n[s]=r[s])},Md(e,t)};function Lp(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");Md(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var Ap=function(e){Lp(t,e);function t(n){var r=e.call(this)||this;return r._element=n,r}return t}(Array);function Ix(e){return{font:"helvetica",fontStyle:"normal",overflow:"linebreak",fillColor:!1,textColor:20,halign:"left",valign:"top",fontSize:10,cellPadding:5/e,lineColor:200,lineWidth:0,cellWidth:"auto",minCellHeight:0,minCellWidth:0}}function Fx(e){var t={striped:{table:{fillColor:255,textColor:80,fontStyle:"normal"},head:{textColor:255,fillColor:[41,128,185],fontStyle:"bold"},body:{},foot:{textColor:255,fillColor:[41,128,185],fontStyle:"bold"},alternateRow:{fillColor:245}},grid:{table:{fillColor:255,textColor:80,fontStyle:"normal",lineWidth:.1},head:{textColor:255,fillColor:[26,188,156],fontStyle:"bold",lineWidth:0},body:{},foot:{textColor:255,fillColor:[26,188,156],fontStyle:"bold",lineWidth:0},alternateRow:{}},plain:{head:{fontStyle:"bold"},foot:{fontStyle:"bold"}}};return t[e]}function Gl(e,t,n){n.applyStyles(t,!0);var r=Array.isArray(e)?e:[e],s=r.map(function(i){return n.getTextWidth(i)}).reduce(function(i,c){return Math.max(i,c)},0);return s}function kp(e,t,n,r){var s=t.settings.tableLineWidth,i=t.settings.tableLineColor;e.applyStyles({lineWidth:s,lineColor:i});var c=Cp(s,!1);c&&e.rect(n.x,n.y,t.getWidth(e.pageSize().width),r.y-n.y,c)}function Cp(e,t){var n=e>0,r=t||t===0;return n&&r?"DF":n?"S":r?"F":null}function lc(e,t){var n,r,s,i;if(e=e||t,Array.isArray(e)){if(e.length>=4)return{top:e[0],right:e[1],bottom:e[2],left:e[3]};if(e.length===3)return{top:e[0],right:e[1],bottom:e[2],left:e[1]};if(e.length===2)return{top:e[0],right:e[1],bottom:e[0],left:e[1]};e.length===1?e=e[0]:e=t}return typeof e=="object"?(typeof e.vertical=="number"&&(e.top=e.vertical,e.bottom=e.vertical),typeof e.horizontal=="number"&&(e.right=e.horizontal,e.left=e.horizontal),{left:(n=e.left)!==null&&n!==void 0?n:t,top:(r=e.top)!==null&&r!==void 0?r:t,right:(s=e.right)!==null&&s!==void 0?s:t,bottom:(i=e.bottom)!==null&&i!==void 0?i:t}):(typeof e!="number"&&(e=t),{top:e,right:e,bottom:e,left:e})}function Pp(e,t){var n=lc(t.settings.margin,0);return e.pageSize().width-(n.left+n.right)}function Tx(e,t,n,r,s){var i={},c=1.3333333333333333,l=Zc(t,function(T){return s.getComputedStyle(T).backgroundColor});l!=null&&(i.fillColor=l);var d=Zc(t,function(T){return s.getComputedStyle(T).color});d!=null&&(i.textColor=d);var h=Rx(r,n);h&&(i.cellPadding=h);var f="borderTopColor",x=c*n,b=r.borderTopWidth;if(r.borderBottomWidth===b&&r.borderRightWidth===b&&r.borderLeftWidth===b){var m=(parseFloat(b)||0)/x;m&&(i.lineWidth=m)}else i.lineWidth={top:(parseFloat(r.borderTopWidth)||0)/x,right:(parseFloat(r.borderRightWidth)||0)/x,bottom:(parseFloat(r.borderBottomWidth)||0)/x,left:(parseFloat(r.borderLeftWidth)||0)/x},i.lineWidth.top||(i.lineWidth.right?f="borderRightColor":i.lineWidth.bottom?f="borderBottomColor":i.lineWidth.left&&(f="borderLeftColor"));var w=Zc(t,function(T){return s.getComputedStyle(T)[f]});w!=null&&(i.lineColor=w);var v=["left","right","center","justify"];v.indexOf(r.textAlign)!==-1&&(i.halign=r.textAlign),v=["middle","bottom","top"],v.indexOf(r.verticalAlign)!==-1&&(i.valign=r.verticalAlign);var P=parseInt(r.fontSize||"");isNaN(P)||(i.fontSize=P/c);var _=Dx(r);_&&(i.fontStyle=_);var q=(r.fontFamily||"").toLowerCase();return e.indexOf(q)!==-1&&(i.font=q),i}function Dx(e){var t="";return(e.fontWeight==="bold"||e.fontWeight==="bolder"||parseInt(e.fontWeight)>=700)&&(t="bold"),(e.fontStyle==="italic"||e.fontStyle==="oblique")&&(t+="italic"),t}function Zc(e,t){var n=Ep(e,t);if(!n)return null;var r=n.match(/^rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d*\.?\d*))?\)$/);if(!r||!Array.isArray(r))return null;var s=[parseInt(r[1]),parseInt(r[2]),parseInt(r[3])],i=parseInt(r[4]);return i===0||isNaN(s[0])||isNaN(s[1])||isNaN(s[2])?null:s}function Ep(e,t){var n=t(e);return n==="rgba(0, 0, 0, 0)"||n==="transparent"||n==="initial"||n==="inherit"?e.parentElement==null?null:Ep(e.parentElement,t):n}function Rx(e,t){var n=[e.paddingTop,e.paddingRight,e.paddingBottom,e.paddingLeft],r=96/(72/t),s=(p
185arseInt(e.lineHeight)-parseInt(e.fontSize))/t/2,i=n.map(function(l){return parseInt(l||"0")/r}),c=lc(i,0);return s>c.top&&(c.top=s),s>c.bottom&&(c.bottom=s),c}function Mp(e,t,n,r,s){var i,c;r===void 0&&(r=!1),s===void 0&&(s=!1);var l;typeof t=="string"?l=n.document.querySelector(t):l=t;var d=Object.keys(e.getFontList()),h=e.scaleFactor(),f=[],x=[],b=[];if(!l)return console.error("Html table could not be found with input: ",t),{head:f,body:x,foot:b};for(var m=0;m<l.rows.length;m++){var w=l.rows[m],v=(c=(i=w==null?void 0:w.parentElement)===null||i===void 0?void 0:i.tagName)===null||c===void 0?void 0:c.toLowerCase(),P=Bx(d,h,n,w,r,s);P&&(v==="thead"?f.push(P):v==="tfoot"?b.push(P):x.push(P))}return{head:f,body:x,foot:b}}function Bx(e,t,n,r,s,i){for(var c=new Ap(r),l=0;l<r.cells.length;l++){var d=r.cells[l],h=n.getComputedStyle(d);if(s||h.display!=="none"){var f=void 0;i&&(f=Tx(e,d,t,h,n)),c.push({rowSpan:d.rowSpan,colSpan:d.colSpan,styles:f,_element:d,content:Ox(d)})}}var x=n.getComputedStyle(r);if(c.length>0&&(s||x.display!=="none"))return c}function Ox(e){var t=e.cloneNode(!0);return t.innerHTML=t.innerHTML.replace(/\n/g,"").replace(/ +/g," "),t.innerHTML=t.innerHTML.split(/<br.*?>/).map(function(n){return n.trim()}).join(`
186`),t.innerText||t.textContent||""}function qx(e,t,n){for(var r=0,s=[e,t,n];r<s.length;r++){var i=s[r];i&&typeof i!="object"&&console.error("The options parameter should be of type object, is: "+typeof i),i.startY&&typeof i.startY!="number"&&(console.error("Invalid value for startY option",i.startY),delete i.startY)}}function gs(e,t,n,r,s){if(e==null)throw new TypeError("Cannot convert undefined or null to object");for(var i=Object(e),c=1;c<arguments.length;c++){var l=arguments[c];if(l!=null)for(var d in l)Object.prototype.hasOwnProperty.call(l,d)&&(i[d]=l[d])}return i}function zx(e,t){var n=new oo(e),r=n.getDocumentOptions(),s=n.getGlobalOptions();qx(s,r,t);var i=gs({},s,r,t),c;typeof window<"u"&&(c=window);var l=$x(s,r,t),d=Hx(s,r,t),h=Ux(n,i),f=Wx(n,i,c);return{id:t.tableId,content:f,hooks:d,styles:l,settings:h}}function $x(e,t,n){for(var r={styles:{},headStyles:{},bodyStyles:{},footStyles:{},alternateRowStyles:{},columnStyles:{}},s=function(d){if(d==="columnStyles"){var h=e[d],f=t[d],x=n[d];r.columnStyles=gs({},h,f,x)}else{var b=[e,t,n],m=b.map(function(w){return w[d]||{}});r[d]=gs({},m[0],m[1],m[2])}},i=0,c=Object.keys(r);i<c.length;i++){var l=c[i];s(l)}return r}function Hx(e,t,n){for(var r=[e,t,n],s={didParseCell:[],willDrawCell:[],didDrawCell:[],willDrawPage:[],didDrawPage:[]},i=0,c=r;i<c.length;i++){var l=c[i];l.didParseCell&&s.didParseCell.push(l.didParseCell),l.willDrawCell&&s.willDrawCell.push(l.willDrawCell),l.didDrawCell&&s.didDrawCell.push(l.didDrawCell),l.willDrawPage&&s.willDrawPage.push(l.willDrawPage),l.didDrawPage&&s.didDrawPage.push(l.didDrawPage)}return s}function Ux(e,t){var n,r,s,i,c,l,d,h,f,x,b,m,w=lc(t.margin,40/e.scaleFactor()),v=(n=Vx(e,t.startY))!==null&&n!==void 0?n:w.top,P;t.showFoot===!0?P="everyPage":t.showFoot===!1?P="never":P=(r=t.showFoot)!==null&&r!==void 0?r:"everyPage";var _;t.showHead===!0?_="everyPage":t.showHead===!1?_="never":_=(s=t.showHead)!==null&&s!==void 0?s:"everyPage";var q=(i=t.useCss)!==null&&i!==void 0?i:!1,T=t.theme||(q?"plain":"striped"),B=!!t.horizontalPageBreak,Q=(c=t.horizontalPageBreakRepeat)!==null&&c!==void 0?c:null;return{includeHiddenHtml:(l=t.includeHiddenHtml)!==null&&l!==void 0?l:!1,useCss:q,theme:T,startY:v,margin:w,pageBreak:(d=t.pageBreak)!==null&&d!==void 0?d:"auto",rowPageBreak:(h=t.rowPageBreak)!==null&&h!==void 0?h:"auto",tableWidth:(f=t.tableWidth)!==null&&f!==void 0?f:"auto",showHead:_,showFoot:P,tableLineWidth:(x=t.tableLineWidth)!==null&&x!==void 0?x:0,tableLineColor:(b=t.tableLineColor)!==null&&b!==void 0?b:200,horizontalPageBreak:B,horizontalPageBreakRepeat:Q,horizontalPageBreakBehaviour:(m=t.horizontalPageBreakBehaviour)!==null&&m!==void 0?m:"afterAllRows"}}function Vx(e,t){var n=e.getLastAutoTable(),r=e.scaleFactor(),s=e.pageNumber(),i=!1;if(n&&n.startPageNumber){var c=n.startPageNumber+n.pageNumber-1;i=c===s}return typeof t=="number"?t:(t==null||t===!1)&&i&&(n==null?void 0:n.finalY)!=null?n.finalY+20/r:null}function Wx(e,t,n){var r=t.head||[],s=t.body||[],i=t.foot||[];if(t.html){var c=t.includeHiddenHtml;if(n){var l=Mp(e,t.html,n,c,t.useCss)||{};r=l.head||r,s=l.body||r,i=l.foot||r}else console.error("Cannot parse html in non browser environment")}var d=t.columns||Gx(r,s,i);return{columns:d,head:r,body:s,foot:i}}function Gx(e,t,n){var r=e[0]||t[0]||n[0]||[],s=[];return Object.keys(r).filter(function(i){return i!=="_element"}
186).forEach(function(i){var c=1,l;Array.isArray(r)?l=r[parseInt(i)]:l=r[i],typeof l=="object"&&!Array.isArray(l)&&(c=(l==null?void 0:l.colSpan)||1);for(var d=0;d<c;d++){var h=void 0;Array.isArray(r)?h=s.length:h=i+(d>0?"_".concat(d):"");var f={dataKey:h};s.push(f)}}),s}var Id=function(){function e(t,n,r){this.table=n,this.pageNumber=n.pageNumber,this.settings=n.settings,this.cursor=r,this.doc=t.getDocument()}return e}(),Yx=function(e){Lp(t,e);function t(n,r,s,i,c,l){var d=e.call(this,n,r,l)||this;return d.cell=s,d.row=i,d.column=c,d.section=i.section,d}return t}(Id),Kx=function(){function e(t,n){this.pageNumber=1,this.id=t.id,this.settings=t.settings,this.styles=t.styles,this.hooks=t.hooks,this.columns=n.columns,this.head=n.head,this.body=n.body,this.foot=n.foot}return e.prototype.getHeadHeight=function(t){return this.head.reduce(function(n,r){return n+r.getMaxCellHeight(t)},0)},e.prototype.getFootHeight=function(t){return this.foot.reduce(function(n,r){return n+r.getMaxCellHeight(t)},0)},e.prototype.allRows=function(){return this.head.concat(this.body).concat(this.foot)},e.prototype.callCellHooks=function(t,n,r,s,i,c){for(var l=0,d=n;l<d.length;l++){var h=d[l],f=new Yx(t,this,r,s,i,c),x=h(f)===!1;if(r.text=Array.isArray(r.text)?r.text:[r.text],x)return!1}return!0},e.prototype.callEndPageHooks=function(t,n){t.applyStyles(t.userStyles);for(var r=0,s=this.hooks.didDrawPage;r<s.length;r++){var i=s[r];i(new Id(t,this,n))}},e.prototype.callWillDrawPageHooks=function(t,n){for(var r=0,s=this.hooks.willDrawPage;r<s.length;r++){var i=s[r];i(new Id(t,this,n))}},e.prototype.getWidth=function(t){if(typeof this.settings.tableWidth=="number")return this.settings.tableWidth;if(this.settings.tableWidth==="wrap"){var n=this.columns.reduce(function(s,i){return s+i.wrappedWidth},0);return n}else{var r=this.settings.margin;return t-r.left-r.right}},e}(),Ip=function(){function e(t,n,r,s,i){i===void 0&&(i=!1),this.height=0,this.raw=t,t instanceof Ap&&(this.raw=t._element,this.element=t._element),this.index=n,this.section=r,this.cells=s,this.spansMultiplePages=i}return e.prototype.getMaxCellHeight=function(t){var n=this;return t.reduce(function(r,s){var i;return Math.max(r,((i=n.cells[s.index])===null||i===void 0?void 0:i.height)||0)},0)},e.prototype.hasRowSpan=function(t){var n=this;return t.filter(function(r){var s=n.cells[r.index];return s?s.rowSpan>1:!1}).length>0},e.prototype.canEntireRowFit=function(t,n){return this.getMaxCellHeight(n)<=t},e.prototype.getMinimumRowHeight=function(t,n){var r=this;return t.reduce(function(s,i){var c=r.cells[i.index];if(!c)return 0;var l=n.getLineHeight(c.styles.fontSize),d=c.padding("vertical"),h=d+l;return h>s?h:s},0)},e}(),Fp=function(){function e(t,n,r){var s;this.contentHeight=0,this.contentWidth=0,this.wrappedWidth=0,this.minReadableWidth=0,this.minWidth=0,this.width=0,this.height=0,this.x=0,this.y=0,this.styles=n,this.section=r,this.raw=t;var i=t;t!=null&&typeof t=="object"&&!Array.isArray(t)?(this.rowSpan=t.rowSpan||1,this.colSpan=t.colSpan||1,i=(s=t.content)!==null&&s!==void 0?s:t,t._element&&(this.raw=t._element)):(this.rowSpan=1,this.colSpan=1);var c=i!=null?""+i:"",l=/\r\n|\r|\n/g;this.text=c.split(l)}return e.prototype.getTextPos=function(){var t;if(this.styles.valign==="top")t=this.y+this.padding("top");else if(this.styles.valign==="bottom")t=this.y+this.height-this.padding("bottom");else{var n=this.height-this.padding("vertical");t=this.y+n/2+this.padding("top")}var r;if(this.styles.halign==="right")r=this.x+this.width-this.padding("right");else if(this.styles.halign==="center"){var s=this.width-this.padding("horizontal");r=this.x+s/2+this.padding("left")}else r=this.x+this.padding("left");return{x:r,y:t}},e.prototype.getContentHeight=function(t,n){n===void 0&&(n=1.15);var r=Array.isArray(this.text)?this.text.length:1,s=this.styles.fontSize/t*n,i=r*s+this.padding("vertical");return Math.max(i,this.styles.minCellHeight)},e.prototype.padding=function(t){var n=lc(this.styles.cellPadding,0);return t==="vertical"?n.top+n.bottom:t==="horizontal"?n.left+n.right:n[t]},e}(),Qx=function(){function e(t,n,r){this.wrappedWidth=0,this.minReadableWidth=0,this.minWidth=0,this.width=0,this.dataKey=t,this.raw=n,this.index=r}return e.prototype.getMaxCustomCellWidth=function(t){for(var n=0,r=0,s=t.allRows();r<s.length;r++){var i=s[r],c=i.cells[this.index];c&&typeof c.styles.cellWidth=="number"&&(n=Math.max(n,c.styles.cellWidth))}return n},e}();function Jx(e,t){Xx(e,t);var n=[],r=0;t.columns.forEach(function(i){var c=i.getMaxCustomCellWidth(t);c?i.width=c:(i.width=i.wrappedWidth,n.push(i)),r+=i.width});var s=t.getWidth(e.pageSize().width)-r;s&&(s=Fd(n,s,function(i){return Math.max(i.minReadableWidth,i.minWidth)})),s&&(s=Fd(n,s,function(i){return i.minWidth})),s=Math.abs(s),!t.settings.horizontalPageBreak&&s>.1/e.scaleFactor()&&(s=s<1?s:Math.round(s),console.log("Of the table content, ".concat(s," units width could not fit page"))),ey(t),ty(t,e),Zx(t)}function Xx(e,t){var n=e.scaleFactor(),r=t.settings.horizontalPageBreak,s=Pp(e,t);
186t.allRows().forEach(function(i){for(var c=0,l=t.columns;c<l.length;c++){var d=l[c],h=i.cells[d.index];if(h){var f=t.hooks.didParseCell;t.callCellHooks(e,f,h,i,d,null);var x=h.padding("horizontal");h.contentWidth=Gl(h.text,h.styles,e)+x;var b=Gl(h.text.join(" ").split(/[^\S\u00A0]+/),h.styles,e);if(h.minReadableWidth=b+h.padding("horizontal"),typeof h.styles.cellWidth=="number")h.minWidth=h.styles.cellWidth,h.wrappedWidth=h.styles.cellWidth;else if(h.styles.cellWidth==="wrap"||r===!0)h.contentWidth>s?(h.minWidth=s,h.wrappedWidth=s):(h.minWidth=h.contentWidth,h.wrappedWidth=h.contentWidth);else{var m=10/n;h.minWidth=h.styles.minCellWidth||m,h.wrappedWidth=h.contentWidth,h.minWidth>h.wrappedWidth&&(h.wrappedWidth=h.minWidth)}}}}),t.allRows().forEach(function(i){for(var c=0,l=t.columns;c<l.length;c++){var d=l[c],h=i.cells[d.index];if(h&&h.colSpan===1)d.wrappedWidth=Math.max(d.wrappedWidth,h.wrappedWidth),d.minWidth=Math.max(d.minWidth,h.minWidth),d.minReadableWidth=Math.max(d.minReadableWidth,h.minReadableWidth);else{var f=t.styles.columnStyles[d.dataKey]||t.styles.columnStyles[d.index]||{},x=f.cellWidth||f.minCellWidth;x&&typeof x=="number"&&(d.minWidth=x,d.wrappedWidth=x)}h&&(h.colSpan>1&&!d.minWidth&&(d.minWidth=h.minWidth),h.colSpan>1&&!d.wrappedWidth&&(d.wrappedWidth=h.minWidth))}})}function Fd(e,t,n){for(var r=t,s=e.reduce(function(m,w){return m+w.wrappedWidth},0),i=0;i<e.length;i++){var c=e[i],l=c.wrappedWidth/s,d=r*l,h=c.width+d,f=n(c),x=h<f?f:h;t-=x-c.width,c.width=x}if(t=Math.round(t*1e10)/1e10,t){var b=e.filter(function(m){return t<0?m.width>n(m):!0});b.length&&(t=Fd(b,t,n))}return t}function Zx(e){for(var t={},n=1,r=e.allRows(),s=0;s<r.length;s++)for(var i=r[s],c=0,l=e.columns;c<l.length;c++){var d=l[c],h=t[d.index];if(n>1)n--,delete i.cells[d.index];else if(h)h.cell.height+=i.height,n=h.cell.colSpan,delete i.cells[d.index],h.left--,h.left<=1&&delete t[d.index];else{var f=i.cells[d.index];if(!f)continue;if(f.height=i.height,f.rowSpan>1){var x=r.length-s,b=f.rowSpan>x?x:f.rowSpan;t[d.index]={cell:f,left:b,row:i}}}}}function ey(e){for(var t=e.allRows(),n=0;n<t.length;n++)for(var r=t[n],s=null,i=0,c=0,l=0;l<e.columns.length;l++){var d=e.columns[l];if(c-=1,c>1&&e.columns[l+1])i+=d.width,delete r.cells[d.index];else if(s){var h=s;delete r.cells[d.index],s=null,h.width=d.width+i}else{var h=r.cells[d.index];if(!h)continue;if(c=h.colSpan,i=0,h.colSpan>1){s=h,i+=d.width;continue}h.width=d.width+i}}}function ty(e,t){for(var n={count:0,height:0},r=0,s=e.allRows();r<s.length;r++){for(var i=s[r],c=0,l=e.columns;c<l.length;c++){var d=l[c],h=i.cells[d.index];if(h){t.applyStyles(h.styles,!0);var f=h.width-h.padding("horizontal");if(h.styles.overflow==="linebreak")h.text=t.splitTextToSize(h.text,f+1/t.scaleFactor(),{fontSize:h.styles.fontSize});else if(h.styles.overflow==="ellipsize")h.text=Sf(h.text,f,h.styles,t,"...");else if(h.styles.overflow==="hidden")h.text=Sf(h.text,f,h.styles,t,"");else if(typeof h.styles.overflow=="function"){var x=h.styles.overflow(h.text,f);typeof x=="string"?h.text=[x]:h.text=x}h.contentHeight=h.getContentHeight(t.scaleFactor(),t.getLineHeightFactor());var b=h.contentHeight/h.rowSpan;h.rowSpan>1&&n.count*n.height<b*h.rowSpan?n={height:b,count:h.rowSpan}:n&&n.count>0&&n.height>b&&(b=n.height),b>i.height&&(i.height=b)}}n.count--}}function Sf(e,t,n,r,s){return e.map(function(i){return ny(i,t,n,r,s)})}function ny(e,t,n,r,s){var i=1e4*r.scaleFactor();if(t=Math.ceil(t*i)/i,t>=Gl(e,n,r))return e;for(;t<Gl(e+s,n,r)&&!(e.length<=1);)e=e.substring(0,e.length-1);return e.trim()+s}function ry(e,t){var n=new oo(e),r=ay(t,n.scaleFactor()),s=new Kx(t,r);return Jx(n,s),n.applyStyles(n.userStyles),s}function ay(e,t){var n=e.content,r=iy(n.columns);if(n.head.length===0){var s=Lf(r,"head");s&&n.head.push(s)}if(n.foot.length===0){var s=Lf(r,"foot");s&&n.foot.push(s)}var i=e.settings.theme,c=e.styles;return{columns:r,head:ed("head",n.head,r,c,i,t),body:ed("body",n.body,r,c,i,t),foot:ed("foot",n.foot,r,c,i,t)}}function ed(e,t,n,r,s,i){var c={},l=t.map(function(d,h){for(var f=0,x={},b=0,m=0,w=0,v=n;w<v.length;w++){var P=v[w];if(c[P.index]==null||c[P.index].left===0)if(m===0){var _=void 0;Array.isArray(d)?_=d[P.index-b-f]:_=d[P.dataKey];var q={};typeof _=="object"&&!Array.isArray(_)&&(q=(_==null?void 0:_.styles)||{});var T=oy(e,P,h,s,r,i,q),B=new Fp(_,T,e);
186x[P.dataKey]=B,x[P.index]=B,m=B.colSpan-1,c[P.index]={left:B.rowSpan-1,times:m}}else m--,b++;else c[P.index].left--,m=c[P.index].times,f++}return new Ip(d,h,e,x)});return l}function Lf(e,t){var n={};return e.forEach(function(r){if(r.raw!=null){var s=sy(t,r.raw);s!=null&&(n[r.dataKey]=s)}}),Object.keys(n).length>0?n:null}function sy(e,t){if(e==="head"){if(typeof t=="object")return t.header||null;if(typeof t=="string"||typeof t=="number")return t}else if(e==="foot"&&typeof t=="object")return t.footer;return null}function iy(e){return e.map(function(t,n){var r,s;return typeof t=="object"?s=(r=t.dataKey)!==null&&r!==void 0?r:n:s=n,new Qx(s,t,n)})}function oy(e,t,n,r,s,i,c){var l=Fx(r),d;e==="head"?d=s.headStyles:e==="body"?d=s.bodyStyles:e==="foot"&&(d=s.footStyles);var h=gs({},l.table,l[e],s.styles,d),f=s.columnStyles[t.dataKey]||s.columnStyles[t.index]||{},x=e==="body"?f:{},b=e==="body"&&n%2===0?gs({},l.alternateRow,s.alternateRowStyles):{},m=Ix(i),w=gs({},m,h,b,x);return gs(w,c)}function ly(e,t,n){var r;n===void 0&&(n={});var s=Pp(e,t),i=new Map,c=[],l=[],d=[];Array.isArray(t.settings.horizontalPageBreakRepeat)?d=t.settings.horizontalPageBreakRepeat:(typeof t.settings.horizontalPageBreakRepeat=="string"||typeof t.settings.horizontalPageBreakRepeat=="number")&&(d=[t.settings.horizontalPageBreakRepeat]),d.forEach(function(b){var m=t.columns.find(function(w){return w.dataKey===b||w.index===b});m&&!i.has(m.index)&&(i.set(m.index,!0),c.push(m.index),l.push(t.columns[m.index]),s-=m.wrappedWidth)});for(var h=!0,f=(r=n==null?void 0:n.start)!==null&&r!==void 0?r:0;f<t.columns.length;){if(i.has(f)){f++;continue}var x=t.columns[f].wrappedWidth;if(h||s>=x)h=!1,c.push(f),l.push(t.columns[f]),s-=x;else break;f++}return{colIndexes:c,columns:l,lastIndex:f-1}}function cy(e,t){for(var n=[],r=0;r<t.columns.length;r++){var s=ly(e,t,{start:r});s.columns.length&&(n.push(s),r=s.lastIndex)}return n}function dy(e,t){var n=t.settings,r=n.startY,s=n.margin,i={x:s.left,y:r},c=t.getHeadHeight(t.columns)+t.getFootHeight(t.columns),l=r+s.bottom+c;if(n.pageBreak==="avoid"){var d=t.body,h=d.reduce(function(b,m){return b+m.height},0);l+=h}var f=new oo(e);(n.pageBreak==="always"||n.startY!=null&&l>f.pageSize().height)&&(Dp(f),i.y=s.top),t.callWillDrawPageHooks(f,i);var x=gs({},i);t.startPageNumber=f.pageNumber(),n.horizontalPageBreak?uy(f,t,x,i):(f.applyStyles(f.userStyles),(n.showHead==="firstPage"||n.showHead==="everyPage")&&t.head.forEac
vendor: 1,098 bytes, line 186
186h(function(b){return xs(f,t,b,i,t.columns)}),f.applyStyles(f.userStyles),t.body.forEach(function(b,m){var w=m===t.body.length-1;Yl(f,t,b,w,x,i,t.columns)}),f.applyStyles(f.userStyles),(n.showFoot==="lastPage"||n.showFoot==="everyPage")&&t.foot.forEach(function(b){return xs(f,t,b,i,t.columns)})),kp(f,t,x,i),t.callEndPageHooks(f,i),t.finalY=i.y,e.lastAutoTable=t,f.applyStyles(f.userStyles)}function uy(e,t,n,r){var s=cy(e,t),i=t.settings;if(i.horizontalPageBreakBehaviour==="afterAllRows")s.forEach(function(h,f){e.applyStyles(e.userStyles),f>0?Oo(e,t,n,r,h.columns,!0):Af(e,t,r,h.columns),hy(e,t,n,r,h.columns),td(e,t,r,h.columns)});else for(var c=-1,l=s[0],d=function(){var h=c;if(l){e.applyStyles(e.userStyles);var f=l.columns;c>=0?Oo(e,t,n,r,f,!0):Af(e,t,r,f),h=kf(e,t,c+1,r,f),td(e,t,r,f)}var x=h-c;s.slice(1).forEach(function(b){e.applyStyles(e.userStyles),Oo(e,t,n,r,b.columns,!0),kf(e,t,c+1,r,b.columns,x),td(e,t,r,b.columns)}),c=h};c<t.body.length-1;)d()}function Af(e,t,n,r){var s=t.settings;e.applyStyles(e.userStyles),(s.showHead==="firstPage"||s.showHead==="everyPage")&&t.head.forEac
186h(function(i){return xs(e,t,i,n,r)})}function hy(e,t,n,r,s){e.applyStyles(e.userStyles),t.body.forEach(function(i,c){var l=c===t.body.length-1;Yl(e,t,i,l,n,r,s)})}function kf(e,t,n,r,s,i){e.applyStyles(e.userStyles),i=i??t.body.length;for(var c=Math.min(n+i,t.body.length),l=-1,d=t.body.slice(n,c),h=0;h<d.length;h++){var f=d[h],x=n+h===t.body.length-1,b=Tp(e,t,x,r);if(f.canEntireRowFit(b,s))xs(e,t,f,r,s),l=n+h;else break}return l}function td(e,t,n,r){var s=t.settings;e.applyStyles(e.userStyles),(s.showFoot==="lastPage"||s.showFoot==="everyPage")&&t.foot.forEach(function(i){return xs(e,t,i,n,r)})}function fy(e,t,n){var r=n.getLineHeight(e.styles.fontSize),s=e.padding("vertical"),i=Math.floor((t-s)/r);return Math.max(0,i)}function my(e,t,n,r){var s={};e.spansMultiplePages=!0,e.height=0;for(var i=0,c=0,l=n.columns;c<l.length;c++){var d=l[c],h=e.cells[d.index];if(h){Array.isArray(h.text)||(h.text=[h.text]);var f=new Fp(h.raw,h.styles,h.section);f=gs(f,h),f.text=[];var x=fy(h,t,r);h.text.length>x&&(f.text=h.text.splice(x,h.text.length));var b=r.scaleFactor(),m=r.getLineHeightFactor();h.contentHeight=h.getContentHeight(b,m),h.contentHeight>=t&&(h.contentHeight=t,f.styles.minCellHeight-=t),h.contentHeight>e.height&&(e.height=h.contentHeight),f.contentHeight=f.getContentHeight(b,m),f.contentHeight>i&&(i=f.contentHeight),s[d.index]=f}}var w=new Ip(e.raw,-1,e.section,s,!0);w.height=i;for(var v=0,P=n.columns;v<P.length;v++){var d=P[v],f=w.cells[d.index];f&&(f.height=w.height);var h=e.cells[d.index];h&&(h.height=e.height)}return w}function py(e,t,n,r){var s=e.pageSize().height,i=r.settings.margin,c=i.top+i.bottom,l=s-c;t.section==="body"&&(l-=r.getHeadHeight(r.columns)+r.getFootHeight(r.columns));var d=t.getMinimumRowHeight(r.columns,e),h=d<n;if(d>l)return console.log("Will not be able to print row ".concat(t.index," correctly since it's minimum height is larger than page height")),!0;if(!h)return!1;var f=t.hasRowSpan(r.columns),x=t.getMaxCellHeight(r.columns)>l;return x?(f&&console.log("The content of row ".concat(t.index," will not be drawn correctly since drawing rows with a height larger than the page height and has cells with rowspans is not supported.")),!0):!(f||r.settings.rowPageBreak==="avoid")}function Yl(e,t,n,r,s,i,c){var l=Tp(e,t,r,i);if(n.canEntireRowFit(l,c))xs(e,t,n,i,c);else if(py(e,n,l,t)){var d=my(n,l,t,e);xs(e,t,n,i,c),Oo(e,t,s,i,c),Yl(e,t,d,r,s,i,c)}else Oo(e,t,s,i,c),Yl(e,t,n,r,s,i,c)}function xs(e,t,n,r,s){r.x=t.settings.margin.left;for(var i=0,c=s;i<c.length;i++){var l=c[i],d=n.cells[l.index];if(!d){r.x+=l.width;continue}e.applyStyles(d.styles),d.x=r.x,d.y=r.y;var h=t.callCellHooks(e,t.hooks.willDrawCell,d,n,l,r);if(h===!1){r.x+=l.width;continue}gy(e,d,r);var f=d.getTextPos();Sp(d.text,f.x,f.y,{halign:d.styles.halign,valign:d.styles.valign,maxWidth:Math.ceil(d.width-d.padding("left")-d.padding("right"))},e.getDocument()),t.callCellHooks(e,t.hooks.didDrawCell,d,n,l,r),r.x+=l.width}r.y+=n.height}function gy(e,t,n){var r=t.styles;if(e.getDocument().setFillColor(e.getDocument().getFillColor()),typeof r.lineWidth=="number"){var s=Cp(r.lineWidth,r.fillColor);s&&e.rect(t.x,n.y,t.width,t.height,s)}else typeof r.lineWidth=="object"&&(r.fillColor&&e.rect(t.x,n.y,t.width,t.height,"F"),xy(e,t,n,r.lineWidth))}function xy(e,t,n,r){var s,i,c,l;r.top&&(s=n.x,i=n.y,c=n.x+t.width,l=n.y,r.right&&(c+=.5*r.right),r.left&&(s-=.5*r.left),d(r.top,s,i,c,l)),r.bottom&&(s=n.x,i=n.y+t.height,c=n.x+t.width,l=n.y+t.height,r.right&&(c+=.5*r.right),r.left&&(s-=.5*r.left),d(r.bottom,s,i,c,l)),r.left&&(s=n.x,i=n.y,c=n.x,l=n.y+t.height,r.top&&(i-=.5*r.top),r.bottom&&(l+=.5*r.bottom),d(r.left,s,i,c,l)),r.right&&(s=n.x+t.width,i=n.y,c=n.x+t.width,l=n.y+t.height,r.top&&(i-=.5*r.top),r.bottom&&(l+=.5*r.bottom),d(r.right,s,i,c,l));function d(h,f,x,b,m){e.getDocument().setLineWidth(h),e.getDocument().line(f,x,b,m,"S")}}function Tp(e,t,n,r){var s=t.settings.margin.bottom,i=t.settings.showFoot;return(i==="everyPage"||i==="lastPage"&&n)&&(s+=t.getFootHeight(t.columns)),e.pageSize().height-r.y-s}function Oo(e,t,n,r,s,i){s===void 0&&(s=[]),i===void 0&&(i=!1),e.applyStyles(e.userStyles),t.settings.showFoot==="everyPage"&&!i&&t.foot.forEach(function(l){return xs(e,t,l,r,s)}),t.callEndPageHooks(e,r);var c=t.settings.margin;kp(e,t,n,r),Dp(e),t.pageNumber++,r.x=c.left,r.y=c.top,n.y=c.top,t.callWillDrawPageHooks(e,r),t.settings.showHead==="everyPage"&&(t.head.forEac
186h(function(l){return xs(e,t,l,r,s)}),e.applyStyles(e.userStyles))}function Dp(e){var t=e.pageNumber();e.setPage(t+1);var n=e.pageNumber();return n===t?(e.addPage(),!0):!1}function yy(e){e.API.autoTable=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var r=t[0],s=zx(this,r),i=ry(this,s);return dy(this,i),this},e.API.lastAutoTable=!1,e.API.autoTableText=function(t,n,r,s){Sp(t,n,r,s,this)},e.API.autoTableSetDefaults=function(t){return oo.setDefaults(t,this),this},e.autoTableSetDefaults=function(t,n){oo.setDefaults(t,n)},e.API.autoTableHtmlToJson=function(t,n){var r;if(n===void 0&&(n=!1),typeof window>"u")return console.error("Cannot run autoTableHtmlToJson in non browser environment"),null;var s=new oo(this),i=Mp(s,t,window,n,!1),c=i.head,l=i.body,d=((r=c[0])===null||r===void 0?void 0:r.map(function(h){return h.content}))||[];return{columns:d,rows:l,data:l}}}var nd;try{if(typeof window<"u"&&window){var Cf=window,Pf=Cf.jsPDF||((nd=Cf.jspdf)===null||nd===void 0?void 0:nd.jsPDF);Pf&&yy(Pf)}}catch(e){console.error("Could not apply autoTable plugin",e)}const dn={primary:[46,180,105],primarySoft:[236,253,245],sectionPanelBg:[240,253,246],sectionPanelBorder:[209,226,216],headerBand:[255,255,255],reportHeading:[30,41,59],reportMuted:[71,85,105],accent:[59,130,246],text:[15,23,42],muted:[71,85,105],border:[226,232,240],surface:[255,255,255],surfaceAlt:[241,245,249],disclaimerTint:[254,252,232],warning:[245,158,11],tileMuted:[250,250,252],baselineCompareBg:[254,242,242],baselineCompareLabel:[185,28,28],baselineCompareValue:[175,32,32],acceleratedCompareBg:[240,253,244],acceleratedCompareLabel:[22,101,52],acceleratedCompareValue:[22,163,74],aiQualPanelBg:[239,246,255],aiQualSummaryCard:[255,255,255]},by="This summary is for informational purposes only and is not financial, tax, or legal advice. Actual results depend on many factors. Consult qualified professionals before making financial decisions.",Ef="https://acceleratedstrategies.com/questions",vy="https://acceleratedstrategies.com/terms-of-service",_y="https://acceleratedstrategies.com/financial-disclosure",wy="https://www.trustpilot.com/review/acceleratedstrategies.com",Ny="https://www.bbb.org/us/il/saint-charles/profile/financial-consultants/accelerated-strategies-0654-1000017204",jy="This Snapshot is designed for quick reading — your Intake Numbers at a glance, plus how an Accelerated Payoff Path may compare to a baseline.",Td="Illustrative Purposes Only — the following estimates are not to be construed as guarantees or promises of results. The estimate serves only as a potential outcome given the specific parameters you've provided to Accelerated Strategies. Outcomes and results may change with changing circumstances in the future.",Sy=937/1024,Os={cardRadius:10,headingPadX:14,cardStroke:.28};function Ly(e,t){if(!e||e.size===0)return 0;let n=0;return e.forEach(r=>{if(!r.length)return;const s=r.find(c=>c.month===t);if(s){n+=s.balance;return}const i=r[r.length-1];n+=t>i.month?0:i.balance}),n}function Ay(e,t,n){const r=e==null?void 0:e.planMilestones,s=e==null?void 0:e.baseline.scheduleByDebt;if(r&&r.length>1){const m=[],w=[],v=[];for(const P of r)m.push(P.month),w.push(Math.max(0,P.expectedTotalDebtBalance+P.expectedLocBalance)),v.push(Math.max(0,Ly(s,P.month)));return{months:m,baseline:v,accelerated:w}}const i=t;if(!i||i.baseline.monthsToPayoff==null||i.accelerated.monthsToPayoff==null)return null;const c=Math.max(1,i.baseline.monthsToPayoff),l=Math.max(1,i.accelerated.monthsToPayoff),d=Math.min(600,Math.max(c,l)+6),h=[],f=[],x=[],b=Math.max(n,1);for(let m=0;m<=d;m+=1){h.push(m),f.push(Math.max(0,b*(1-m/c)));const w=b*(1-m/l),v=3,P=b*.06*(m%v)/v;x.push(Math.max(0,w+P))}return{months:h,baseline:f,accelerated:x}}function ky(e,t,n){if(n<=0)return 0;const r=n-1,s=Math.max(250,t*.002);let i=-1;for(let c=0;c<n;c+=1)e[c]>s&&(i=c);return i<0?r:Math.min(r,i+1)}const Mf=[40,167,69],Cy=[220,53,69],Py=[233,246,236];function Ey(e){if(!Number.isFinite(e)||e<=0)return{axisMax:1,yTicks:[0,1]};const t=e*1.045;
186if(t<=36e4){const s=Math.max(6e4,Math.ceil(t/6e4)*6e4),i=[];for(let c=0;c<=s+.5;c+=6e4)i.push(Math.round(c));return{axisMax:s,yTicks:i}}if(t<=9e5){const s=Math.max(1e5,Math.ceil(t/1e5)*1e5),i=[];for(let c=0;c<=s+.5;c+=1e5)i.push(Math.round(c));return{axisMax:s,yTicks:i}}const n=My(e);return{axisMax:n,yTicks:[0,n/4,n/2,3*n/4,n]}}function My(e){if(!Number.isFinite(e)||e<=0)return 1;const t=e*1.06,n=t>=2e6?25e4:t>=8e5?1e5:t>=4e5?5e4:t>=15e4?25e3:t>=6e4?1e4:t>=25e3?5e3:1e3;return Math.max(Math.ceil(t/n)*n,n)}function Iy(e,t){const n=e.length,r=[...e],s=[...t];if(n===0)return{acc:r,base:s};const i=Math.max(1,...r,...s),c=Math.max(250,i*.002);let l=0;for(let d=0;d<n;d+=1){const h=r[d]??0,f=s[d]??0;if(h>c||f>c){l=Math.max(h,f);break}}return l<=c?{acc:r,base:s}:((r[0]??0)<=c&&(r[0]=l),(s[0]??0)<=c&&(s[0]=l),{acc:r,base:s})}const Fy="The sawtooth rhythm reflects the chunking cycle: each spike is a chunk applied to the mortgage, followed by monthly deposits paying the HELOC back down before the next cycle begins.";function Ty(e,t){let n=0;for(let s=1;s<e.length;s++){const i=e[s]-e[s-1];i>n&&(n=i)}const r=Math.max(400,t*.012);return n<r?"Green shows projected total debt under the accelerated strategy; the dashed red line is the minimum-payment baseline. When the curve declines smoothly, the model is using a simplified paydown path rather than each chunk-and-deposit cycle.":Fy}function Ki(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function Dy(e){const t=e.trim();return t?/^https?:\/\//i.test(t)?t:`https://${t}`:""}function Ry(e){return e.length===0?"":`<section class="sr-card sr-card--intake sr-suggested-section">
187  <div class="sr-section-title">Suggested Lenders</div>
188  <p class="sr-suggested-intro">Selected by your strategist from product match results. Programs and terms are subject to lender approval.</p>
189  <div class="sr-suggested-grid">${e.map(n=>{const r=n.contactInfo?`<p class="sr-suggested-contact">${Ki(n.contactInfo).replace(/\n/g,"<br/>")}</p>`:'<p class="sr-suggested-contact sr-suggested-contact--muted">Contact information not on file.</p>',s=n.websiteUrl?`<a class="sr-suggested-website" href="${Ki(Dy(n.websiteUrl))}" target="_blank" rel="noopener noreferrer">Visit lender website</a>`:"";return`<article class="sr-suggested-card">
190        <div class="sr-suggested-head">
191          <h3 class="sr-suggested-name">${Ki(n.lenderName)}</h3>
192          <span class="sr-suggested-program">${Ki(n.programName)} — ${Ki(n.programTypeLabel)}</span>
193          <span class="sr-suggested-match">${Ki(n.matchSummary)}</span>
194        </div>
195        ${r}
196        ${s}
197      </article>`}).join("")}</div>
198</section>`}function By(){return`
199  .sr-suggested-section { margin-top: 12pt; }
200  .sr-suggested-intro { margin: 0 0 10pt; font-size: calc(8.5pt * var(--sr-fs-mul)); color: var(--sr-muted); }
201  .sr-suggested-grid { display: flex; flex-direction: column; gap: 10pt; }
202  .sr-suggested-card {
203    border: 0.75pt solid var(--sr-border);
204    border-radius: 6pt;
205    padding: 10pt 12pt;
206    background: var(--sr-surface);
207  }
208  .sr-suggested-head { margin-bottom: 6pt; }
209  .sr-suggested-name { margin: 0 0 4pt; font-size: calc(11pt * var(--sr-fs-mul)); font-weight: 700; color: var(--sr-heading); }
210  .sr-suggested-program { display: block; font-size: calc(8.5pt * var(--sr-fs-mul)); color: var(--sr-muted); margin-bottom: 4pt; }
211  .sr-suggested-match { display: inline-block; font-size: calc(8pt * var(--sr-fs-mul)); font-weight: 600; color: var(--sr-accent); }
212  .sr-suggested-contact { margin: 0 0 8pt; font-size: calc(9pt * var(--sr-fs-mul)); line-height: 1.45; white-space: pre-wrap; }
213  .sr-suggested-contact--muted { color: var(--sr-muted); font-style: italic; }
214  .sr-suggested-website {
215    display: inline-block;
216    font-size: calc(8.5pt * var(--sr-fs-mul));
217    font-weight: 600;
218    color: var(--sr-accent);
219    text-decoration: none;
220    padding: 4pt 10pt;
221    border: 0.75pt solid var(--sr-accent);
222    border-radius: 4pt;
223  }
224  `}function Oy(e){var t;return((t=e.sectionOptions)==null?void 0:t.includeAiSummary)!==!1}
224function qy(e){var t;return((t=e.sectionOptions)==null?void 0:t.includeSuggestedLenders)!==!1}function zy(e,t){const n=t.replace(/[^\w-]+/g,"_").slice(0,80),r=URL.createObjectURL(e),s=document.createElement("a");s.href=r,s.download=`Accelerated_Strategies_strategy_summary_${n}.pdf`,s.rel="noopener",document.body.appendChild(s),s.click(),s.remove(),window.setTimeout(()=>URL.revokeObjectURL(r),2e3)}async function $y(e){const t=await e.arrayBuffer(),n=new Uint8Array(t);let r="";for(let s=0;s<n.length;s++)r+=String.fromCharCode(n[s]);return btoa(r)}async function Hy(e){try{const n=await(await fetch(e)).blob();return await new Promise((r,s)=>{const i=new FileReader;i.onload=()=>r(typeof i.result=="string"?i.result:null),i.onerror=()=>s(new Error("read failed")),i.readAsDataURL(n)})}catch{return null}}function Uy(e,t=26){return new Promise(n=>{const r=new Image;r.onload=()=>{try{const s=r.naturalWidth,i=r.naturalHeight;if(!s||!i){n(e);return}const c=document.createElement("canvas");c.width=s,c.height=i;const l=c.getContext("2d",{willReadFrequently:!0});if(!l){n(e);return}l.drawImage(r,0,0);const d=l.getImageData(0,0,s,i),h=d.data;for(let f=0;f<h.length;f+=4){const x=h[f],b=h[f+1],m=h[f+2];x<=t&&b<=t&&m<=t&&(h[f+3]=0)}l.putImageData(d,0,0),n(c.toDataURL("image/png"))}catch{n(e)}},r.onerror=()=>n(e),r.crossOrigin="anonymous",r.src=e})}const hs={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1,VITE_APP_BASE_URL:"https://app.solvitmoney.com",VITE_APP_TARGET:"full",VITE_GOOGLE_MAPS_API_KEY:"AIzaSyAwRuN5htBKWS9zKilk8cCczL19uAHaKzA",VITE_STRIPE_FC_PUBLISHABLE_KEY_LIVE:"pk_live_51SYgSc2dJmIUYYQm8xPNsBl8bWvwC0yaFRdsQRam6n8qQAbj4nWtM5HwaiTcqvRx6UEaOJJ65MlCKRiF8cr5ff6400x7K01FVo",VITE_STRIPE_PUBLISHABLE_KEY:"pk_live_51MHZtaGu9Sl59h4Lz5TOolNYTuL70YdSArFLZuQI59xUytb24JmZRKJcdzc8Qb0TN4GOzZp1po9xU3fd9aOSGuPX00TL70y6H4",VITE_STRIPE_PUBLISHABLE_KEY_LIVE:"pk_live_51MHZtaGu9Sl59h4Lz5TOolNYTuL70YdSArFLZuQI59xUytb24JmZRKJcdzc8Qb0TN4GOzZp1po9xU3fd9aOSGuPX00TL70y6H4",VITE_SUPABASE_ANON_KEY:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InJoaHJpanF5eXZ0b2VxZnV4am91Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjQ4MzY1NzcsImV4cCI6MjA4MDQxMjU3N30.Y4C9KNoRN_2KtVQhw-HyeE_VkjenlZD907Ww48HcH5Y",VITE_SUPABASE_PROJECT_ID:"rhhrijqyyvtoeqfuxjou",VITE_SUPABASE_PUBLISHABLE_KEY:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InJoaHJpanF5eXZ0b2VxZnV4am91Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjQ4MzY1NzcsImV4cCI6MjA4MDQxMjU3N30.Y4C9KNoRN_2KtVQhw-HyeE_VkjenlZD907Ww48HcH5Y",VITE_SUPABASE_URL:"https://rhhrijqyyvtoeqfuxjou.supabase.co",VITE_VAPID_PUBLIC_KEY:"BBh5m2Z-kzAev6YaoDgDKkPSdDvhw7XdH32bHaeuSTAAzWYuxC6OUx22S99LZlVA4tn2uKH1BMAXOywtvKCVoMA",VITE_VERCEL_BRANCH_URL:"solvit-prod-git-main-acceleratedstrategies.vercel.app",VITE_VERCEL_DEPLOYMENT_ID:"dpl_CEmWggpiLXskD4seHWuguZLRpKTN",VITE_VERCEL_ENV:"production",VITE_VERCEL_GIT_COMMIT_AUTHOR_LOGIN:"thekwakbrothers",VITE_VERCEL_GIT_COMMIT_AUTHOR_NAME:"The Kwak Brothers",VITE_VERCEL_GIT_COMMIT_MESSAGE:`Merge pull request #568 from The-Kwak-Brothers/staging
225
226chore(release): promote staging to main (assessment FICO, loan terms, expenses, layout)`,VITE_VERCEL_GIT_COMMIT_REF:"main",VITE_VERCEL_GIT_COMMIT_SHA:"275b1e9a299e0167453449df7bb87857527398e9",VITE_VERCEL_GIT_PREVIOUS_SHA:"",VITE_VERCEL_GIT_PROVIDER:"github",VITE_VERCEL_GIT_PULL_REQUEST_ID:"",VITE_VERCEL_GIT_REPO_ID:"1110046369",VITE_VERCEL_GIT_REPO_OWNER:"The-Kwak-Brothers",VITE_VERCEL_GIT_REPO_SLUG:"solvit-prod",VITE_VERCEL_OBSERVABILITY_CLIENT_CONFIG:'{"analytics":{"scriptSrc":"a290cf257bb1d904/script.js","viewEndpoint":"a290cf257bb1d904/view","eventEndpoint":"a290cf257bb1d904/event","sessionEndpoint":"a290cf257bb1d904/session"},"speedInsights":{"scriptSrc":"4d0b9ab0dc92b07e/script.js","endpoint":"4d0b9ab0dc92b07e/vitals"}}',VITE_VERCEL_PROJECT_ID:"prj_XHwcFZCGiswp9YLDokK5SrdZLn2J",VITE_VERCEL_PROJECT_PRODUCTION_URL:"app.solvitmoney.com",VITE_VERCEL_TARGET_ENV:"production",VITE_VERCEL_URL:"solvit-prod-e9d0uui8d-acceleratedstrategies.vercel.app"};function ua(e){return`rgb(${e[0]},${e[1]},${e[2]})`}function Vy(){const e=t=>ua(t);return`:root {
227  --sr-text: ${e(dn.text)};
228  --sr-muted: ${e(dn.muted)};
229  --sr-heading: ${e(dn.reportHeading)};
230  --sr-border: ${e(dn.border)};
231  --sr-surface: ${e(dn.surface)};
232  --sr-surface-alt: ${e(dn.surfaceAlt)};
233  --sr-tile-muted: ${e(dn.tileMuted)};
234  --sr-accent: ${e(dn.accent)};
235  --sr-primary: ${e(dn.primary)};
236  --sr-primary-soft: ${e(dn.primarySoft)};
237  --sr-section-panel-bg: ${e(dn.sectionPanelBg)};
238  --sr-section-panel-border: ${e(dn.sectionPanelBorder)};
239  --sr-val-green: ${e(dn.acceleratedCompareValue)};
240  --sr-val-red: ${e(dn.baselineCompareValue)};
241  --sr-baseline-bg: ${e(dn.baselineCompareBg)};
242  --sr-baseline-label: ${e(dn.baselineCompareLabel)};
243  --sr-accel-bg: ${e(dn.acceleratedCompareBg)};
244  --sr-accel-label: ${e(dn.acceleratedCompareLabel)};
245  --sr-warning: ${e(dn.warning)};
246  --sr-disclaimer-tint: ${e(dn.disclaimerTint)};
247  --sr-ai-panel: ${e(dn.aiQualPanelBg)};
248  --sr-payoff-head-bg: ${e(dn.aiQualPanelBg)};
249  --sr-trust-tp: rgb(0, 182, 122);
250  --sr-trust-bbb: rgb(44, 98, 180);
251  --sr-pad-x: ${Os.headingPadX}pt;
252  --sr-card-radius: ${Os.cardRadius}pt;
253  --sr-line: ${Os.cardStroke}pt;
254  /* Uniform scale for report body copy (preview + HTML→PDF). */
255  --sr-fs-mul: 1.14;
256}
257${By()}`}function Je(e){return(e==null?"":String(e)).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function Wy(e){const t="Based on intake data & current lender criteria",n=e==null?void 0:e.trim();if(!n)return t;const r=n.indexOf("·");if(r>=0){const s=n.slice(r+1).trim();if(s.length>0)return s}return t}function Gy(e){const t=e.match(/^(.*?)(\bis a strong candidate\b)(.*)$/is);if(t)return{highlight:`${t[1]??""}${t[2]??""}`.trim(),rest:(t[3]??"").trim()};const n=e.indexOf(". ");return n>=30&&n<320?{highlight:e.slice(0,n+1).trim(),rest:e.slice(n+2).trim()}:{highlight:"",rest:e}}function Yy(e){const t=[];let n=0;const r=/\*\*([^*]+)\*\*/g;let s;for(;(s=r.exec(e))!==null;)t.push(Je(e.slice(n,s.index))),t.push(`<strong class="sr-ai-narrative-strong">${Je(s[1]??"")}</strong>`),n=s.index+s[0].length;return t.push(Je(e.slice(n))),t.join("").replace(/\n/g,"<br/>")}function Ky(e){const t=e.split(/\n\n+/).map(n=>
257n.trim()).filter(Boolean);return t.length===0?"":`<div class="sr-ai-narrative-wrap">${t.map(n=>`<p class="sr-ai-narrative-p">${Yy(n)}</p>`).join("")}</div>`}function Qy(e){var _,q,T;const t=e.aiAnalysis,n=e.metrics,r=(_=e.assessment)==null?void 0:_.fico_score;let s=((q=t==null?void 0:t.summary)==null?void 0:q.trim())??"";const i=((T=t==null?void 0:t.narrative)==null?void 0:T.trim())??"";let c=!1;!s&&!i&&(c=!0,s="Run AI Qualification Analysis on the lead intake page to generate a narrative summary for this PDF. Key qualification metrics are shown in the cards below.");const l=Wy(t==null?void 0:t.headline).toUpperCase(),{highlight:d,rest:h}=Gy(s),f=r!=null&&r>0?r:null,x=f==null?"primary borrower":f>=740?"excellent tier":f>=670?"strong tier":"primary borrower",m=[{title:"DTI RATIO",value:n.backEndDti!=null?`${n.backEndDti.toFixed(0)}%`:"—",sub:"vs 43% max"},{title:"LOAN-TO-VALUE",value:n.ltv!=null?`${n.ltv.toFixed(0)}%`:"—",sub:"vs 80% max"},{title:"MONTHLY SURPLUS",value:Dt(n.adjustedMonthlyCashFlow),sub:"post-consolidation"},{title:"FICO SCORE",value:f!=null?String(f):"—",sub:x}].map(B=>`<div class="sr-ai-kpi-tile"><div class="sr-ai-kpi-title">${Je(B.title)}</div><div class="sr-ai-kpi-val">${Je(B.value)}</div><div class="sr-ai-kpi-sub">${Je(B.sub)}</div></div>`).join(""),w=i?Ky(i):"";let v="";d.length>0?(v+=`<span class="sr-ai-summary-highlight">${Je(d)}</span>`,h.length>0&&(v+=` <span class="${c?"sr-ai-summary-placeholder":"sr-ai-summary-rest"}">${Je(h)}</span>`)):h.length>0&&(v+=`<span class="${c?"sr-ai-summary-placeholder":"sr-ai-summary-rest"}">${Je(h)}</span>`);const P=v.trim().length>0?`<div class="sr-ai-summary-card"><div class="sr-ai-summary-card__body"><p class="sr-ai-summary-line">${v}</p></div></div>`:"";return`<section class="sr-ai-section">
258  <div class="sr-ai-header-band"><h2 class="sr-ai-main-title">AI Analysis</h2></div>
259  <div class="sr-ai-inner">
260    <div class="sr-ai-qual-intro">
261      <div class="sr-ai-badge" aria-hidden="true"><span class="sr-ai-badge-text">AI</span></div>
262      <div class="sr-ai-qual-titles">
263        <div class="sr-ai-qual-heading">Qualification Summary</div>
264        <div class="sr-ai-qual-caps">${Je(l)}</div>
265      </div>
266    </div>
267    ${P}
268    ${w}
269    <div class="sr-ai-kpi-grid">${m}</div>
270  </div>
271</section>`}function jl(e){return`${e.first_name??""} ${e.last_name??""}`.trim()||"Lead"}function Rp(e){return[e.street_address,e.city,e.state].filter(Boolean).join(", ")||e.property_type.replace(/_/g," ")}function Hn(e){const t=Number(e);return Number.isFinite(t)?t:0}function Jy(e){return e==null?null:e==="go"?"Viable":e==="conditional"?"Conditional":"Needs review"}function Xy(e){const t=Math.floor(e/12),n=e%12,r=[];return t>0&&r.push(`${t} year${t!==1?"s":""}`),n>0&&r.push(`${n} month${n!==1?"s":""}`),r.join(" ").trim()||"0 months"}function If(e){if(e==null||!Number.isFinite(e))return"—";const t=Math.max(0,Math.ceil(e));return ji(fm(new Date,t),"MMM yyyy")}function Co(e){return e==null||!Number.isFinite(e)?"—":`$${Math.round(e).toLocaleString("en-US")}`}function Zy(e){return e?e instanceof Map?[...e.entries()]:Object.entries(e):[]}function eb(e,t,n){const r=t.find(i=>i.id===e);if(r)return(r.debt_name||"Debt").trim()||"Debt";const s=/^property_mortgage_(.+)$/.exec(e);if(s){const i=n.find(c=>String(c.id)===s[1]);return i?`Mortgage (${Rp(i)})`:"Mortgage"}return e.length>36?`${e.slice(0,33)}…`:e}function tb(e){return e.reduce((t,n)=>t+(Number(n.interest)||0),0)}function nb(e){var t;return e.length===0?0:((t=e[e.length-1])==null?void 0:t.month)??0}function rb(e,t){return e.filter(n=>!n.ignored).length+t.filter(n=>Hn(n.outstanding_mortgage_balance)>0).length}const da={dollar:'<svg class="sr-ap-ico" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><line x1="12" y1="1" x2="12" y2="23"/><path d="M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6"/></svg>',clock:'<svg class="sr-ap-ico" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="10"/><polyline points="12 6 12 12 16 14"/></svg>',calendar:'<svg class="sr-ap-ico" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="3" y="4" width="18" height="18" rx="2" ry="2"/><line x1="16" y1="2" x2="16" y2="6"/><line x1="8" y1="2" x2="8" y2="6"/><line x1="3" y1="10" x2="21" y2="10"/></svg>',trend:'<svg class="sr-ap-ico" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="23 6 13.5 15.5 8.5 10.5 1 18"/><polyline points="17 6 23 6 23 12"/></svg>',file:'<svg class="sr-ap-ico" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><polyline points="14 2 14 8 20 8"/><line x1="16" y1="13" x2="8" y2="13"/><line x1="16" y1="17" x2="8" y2="17"/><polyline points="10 9 9 9 8 9"/></svg>',list:'<svg class="sr-ap-ico" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><line x1="8" y1="6" x2="21" y2="6"/><line x1="8" y1="12" x2="21" y2="12"/><line x1="8" y1="18" x2="21" y2="18"/><line x1="3" y1="6" x2="3.01" y2="6"/>
271<line x1="3" y1="12" x2="3.01" y2="12"/><line x1="3" y1="18" x2="3.01" y2="18"/></svg>',leaf:'<svg class="sr-ap-badge-leaf" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M11 20A7 7 0 0 1 9.8 6.1C15.5 5 17 4.48 17 6a7 7 0 0 1-6 14"/></svg>'};function ab(e){const t=e.properties.find(s=>s.property_type==="primary_residence"),n=Hn(t==null?void 0:t.outstanding_mortgage_balance),r=e.debts.filter(s=>!s.ignored).reduce((s,i)=>s+Hn(i.current_balance),0);return Math.max(1,n+r)}function sb(e){return e.selectedHelocType==="1st_lien"||e.selectedHelocType==="2nd_lien"}function ib(e){const t=e.filter(n=>["rental","vacation_rental"].includes(n.property_type));return t.length===0?!1:t.some(n=>Number(n.rental_income)>0||Number(n.rental_expenses)>0||Number(n.mortgage_payment??0)>0)}function ob(e,t){const n=Dt,r=sb(e),s=ib(t);if(!r){const _=e.estimatedMonthlyCashFlow,q=e.hasConsolidation?"ADJUSTED MONTHLY CASHFLOW":"EST. MONTHLY CASHFLOW";return[{title:"MONTHLY NET INCOME",value:n(e.combinedNetIncome),tone:"green"},{title:"MONTHLY EXPENSES (CATEGORIES)",value:`-${n(e.totalMonthlyExpenses)}`,tone:"red"},{title:q,value:`${_>=0?"":"-"}${n(Math.abs(_))}`,tone:_>=0?"green":"red",highlight:_>=0}]}const i=e.selectedHelocType==="1st_lien",c=Number(i?e.primaryTaxesInsurance??0:e.primaryMortgagePayment??0),l=Number(e.hoaMonthly??0),d=Number(e.selectedHelocPayment??0),h=i||e.hasConsolidation===!0,f=[];if(f.push({title:s?"NET INCOME (INCL. RENTAL)":"MONTHLY NET INCOME",value:n(e.combinedNetIncome),tone:"green",sub:s?`${n(e.monthlyNetIncome)} primary + ${n(e.netRentalCf??0)} rental`:void 0}),f.push({title:i?"TAXES & INSURANCE":"PITI PAYMENT",value:c>0?`-${n(c)}`:n(0),tone:c>0?"red":"neutral"}),f.push({title:"HOA / CONDO DUES",value:l>0?`-${n(l)}`:n(0),tone:l>0?"red":"neutral"}),h){const _=i?"1ST LIEN HELOC PMT":"2ND LIEN HELOC PMT",q=!i&&e.heloc1st!=null&&e.heloc1st>0?`vs. 1st lien: -${n(e.heloc1st)}`:void 0,T=e.helocPaymentSub?q?`${e.helocPaymentSub} · ${q}`:e.helocPaymentSub:q;f.push({title:_,value:d>0?`-${n(d)}`:n(0),tone:d>0?"red":"neutral",sub:T})}const x=e.hasConsolidation?"NON-MORTGAGE DEBTS":"NON-MORTGAGE DEBT PMT",b=Number(e.nonConsolidatedDebtPayments??0),m=Number(e.totalMinimumDebtPayments??0),w=e.hasConsolidation===!0?b>0?`-${n(b)}`:n(0):`-${n(m)}`;f.push({title:x,value:w,tone:"red"}),f.push({title:"MONTHLY EXPENSES (CATEGORIES)",value:`-${n(e.totalMonthlyExpenses)}`,tone:"red"});const v=e.estimatedMonthlyCashFlow,P=e.hasConsolidation?"ADJUSTED MONTHLY CASHFLOW":"EST. MONTHLY CASHFLOW";return f.push({title:P,value:`${v>=0?"":"-"}${n(Math.abs(v))}`,tone:v>=0?"green":"red",highlight:v>=0,sub:e.hasConsolidation===!0&&e.baseCashflow!=null?`Was ${n(e.baseCashflow)}`:void 0}),f}function lb(e){return e.map(([t,n])=>({title:t,value:n,tone:"neutral"}))}function cb(e){return e==="green"?"cf-val cf-val--green":e==="red"?"cf-val cf-val--red":"cf-val cf-val--neutral"}function db(e){return!Number.isFinite(e)||e<=0?"$0":e>=1e6?`$${(e/1e6).toFixed(1)}M`:e>=1e3?`$${Math.round(e/1e3)}K`:`$${Math.round(e)}`}function ub(e){if(e<=2400)return Array.from({length:e},(s,i)=>i);const n=Math.ceil(e/2400),r=[];for(let s=0;s<e;s+=n)r.push(s);return r[r.length-1]!==e-1&&r.push(e-1),r}function hb(e,t){const{months:n,baseline:r,accelerated:s}=e,i=n.length;if(i<2)return"";const c=720,l=368,d=82,h=22,f=24,x=c-d-h,b=220,m=d,w=f,v=w+b,P=(w+v)/2,_=m-54,q=Math.max(1,...r,...s),{acc:T,base:B}=Iy(s,r),{axisMax:Q,yTicks:me}=Ey(Math.max(1,...T,...B)),ce=i-1,$=n[ce]??0,D=Math.max(1,$),Y=Math.max(1,Math.ceil($/12)),N=at=>m+Math.min(1,Math.max(0,at)/D)*x,I=at=>v-Math.min(at,Q)/Q*b,k=ub(i),L=k.map(at=>N(n[at])),H=k.map(at=>I(T[at])),te=k.map(at=>N(n[at])),se=k.map(at=>I(B[at])),K=(at,Ve)=>at.map((ft,wt)=>`${ft.toFixed(2)},${Ve[wt].toFixed(2)}`).join(" "),ae=K(L,H),be=K(te,se),Ne=`${K(L,H)} ${L[L.length-1].toFixed(2)},${v.toFixed(2)} ${L[0].toFixed(2)},${v.toFixed(2)}`,A=[];for(const at of me){const Ve=I(at);A.push(`<line class="sr-tl-grid" x1="${m.toFixed(2)}" y1="${Ve.toFixed(2)}" x2="${(m+x).toFixed(2)}" y2="${Ve.toFixed(2)}" />`),A.push(`<text class="sr-tl-axislbl" x="${(m-8).toFixed(2)}" y="${(Ve+3).toFixed(2)}" text-anchor="end">${Je(db(at))}</text>`)}const E=ky(s,q,i),z=Math.max(250,q*.002),X=(s[E]??0)<=z,Z=I(s[E]??0),le=T[0]??0,fe=le>z,ue=t&&!Number.isNaN(t.getTime())?`$0 - ${ji(t,"MMM yyyy")}`:"$0",_e=(n[E]??0)/D;let Ce=0,ve=0,we="start";if(X){const at=ue.length*5.6;if(_e>.68)we="end",Ce=m+x-8,ve=Math.min(Z-12,v-28);else{ve=Math.min(Z-15,v-26);const Ve=N(n[E])+8;Ce=Math.min(Ve,m+x-at-4)}}const De=ua(Cy),R=ua(Mf),ze=ua(Mf),ye=ua(Py),Ee=ua(dn.reportMuted),de=ua(dn.text);let Ue="";if(i>12){let at="",Ve=0,ft=0,wt=0;for(let Re=1;Re<i;Re+=1)T[Re]<=T[Re-1]+1e-6&&(Re-1-wt>ft-Ve&&(Ve=wt,ft=Re-1),wt=Re);if(i-1-wt>ft-Ve&&(Ve=wt,ft=i-1),ft>Ve+2){const Re=(N(n[Ve])+N(n[ft]))/2;if((Re-m)/x<.62){const yn=(I(T[Ve])+I(T[ft]))/2,lt=yn-30;at=`<line class="sr-tl-annotline" x1="${Re.toFixed(2)}" y1="${(lt+14).toFixed(2)}" x2="${Re.toFixed(2)}" y2="${(yn+6).toFixed(2)}" />
272        <text class="sr-tl-annot sr-tl-annot--mid" x="${Re.toFixed(2)}" y="${lt.toFixed(2)}" text-anchor="middle" dominant-baseline="auto">Deposits paying down HELOC</text>`}}let Nt="",Qe=0,Ze=-1;for(let Re=1;Re<i;Re+=1){const Gt=T[Re-1]-T[Re];Gt>Qe&&(Qe=Gt,Ze=Re)}const Ae=Ze>0?(n[Ze]??0)/D:0;if(Ze>0&&Qe>Q*.012&&Ae<.52){const Re=N(n[Ze]),Gt=I(T[Ze-1]),yn=I(T[Ze]),lt=(Gt+yn)/2,hr=lt-24;Nt=`<line class="sr-tl-annotline" x1="${Re.toFixed(2)}" y1="${(hr+12).toFixed(2)}" x2="${Re.toFixed(2)}" y2="${lt.toFixed(2)}" />
273        <text class="sr-tl-annot" x="${(Re+5).toFixed(2)}" y="${hr.toFixed(2)}" dominant-baseline="auto">Chunk applied</text>`}Ue=at+Nt}const qe=Math.min(i-1,Math.max(0,Math.round((i-1)*.82))),$e=I(B[qe])+10,Ge=Y<=15?1:Y<=30?2:5,bt=[];for(let at=0;at<=Y;at+=Ge)bt.push(at);bt[bt.length-1]!==Y&&bt.push(Y);const et=bt.map(at=>{const Ve=m+Math.min(1,at*12/D)*x;return`<line class="sr-tl-axis" x1="${Ve.toFixed(2)}" y1="${v.toFixed(2)}" x2="${Ve.toFixed(2)}" y2="${(v+5).toFixed(2)}" />
274        <text class="sr-tl-axislbl" x="${Ve.toFixed(2)}" y="${(v+14).toFixed(2)}" text-anchor="middle" dominant-baseline="hanging">Year ${at}</text>`}).join(""),Me=N(n[0]),vt=I(T[0]),St=N(n[E]),Oe=Math.max(w+10,vt-16),_t=fe?`<text class="sr-tl-balstart" x="${(Me+8).toFixed(2)}" y="${Oe.toFixed(2)}" text-anchor="start" dominant-baseline="alphabetic" fill="${de}" font-weight="700" font-size="10">${Je(Dt(le))}</text>`:"",Xe=X?`<text class="sr-tl-balend" x="${Ce.toFixed(2)}" y="${ve.toFixed(2)}" text-anchor="${we}" dominant-baseline="auto" fill="${R}" font-weight="700" font-size="10">${Je(ue)}
274</text>`:"",Ht=X?`<circle class="sr-tl-dot" cx="${St.toFixed(2)}" cy="${Z.toFixed(2)}" r="3.2" fill="${R}" />`:"",Lt=at=>`<svg class="sr-tl-pin" width="11" height="12" viewBox="0 0 11 12" aria-hidden="true"><rect x="1" y="0.5" width="1.1" height="9.5" fill="${at}"/><polygon points="2.3,1 8.2,3.2 2.3,5.4" fill="${at}"/></svg>`,At=fe?`<circle class="sr-tl-dot" cx="${Me.toFixed(2)}" cy="${vt.toFixed(2)}" r="3.2" fill="${R}" />`:"",kt=`<svg class="sr-timeline-svg" viewBox="0 0 ${c} ${l}" xmlns="http://www.w3.org/2000/svg" role="img" aria-label="Payoff timeline comparing baseline minimum payments to accelerated strategy">
275  <defs>
276    <clipPath id="srPlotClip"><rect x="${m.toFixed(2)}" y="${w.toFixed(2)}" width="${x.toFixed(2)}" height="${b.toFixed(2)}"/></clipPath>
277    <linearGradient id="srAccelFillGrad" x1="0%" y1="0%" x2="0%" y2="100%">
278      <stop offset="0%" stop-color="${ze}" stop-opacity="0.14"/>
279      <stop offset="100%" stop-color="${ye}" stop-opacity="0.45"/>
280    </linearGradient>
281  </defs>
282  <rect class="sr-tl-plotbg" fill="${ua(dn.surface)}" x="${m.toFixed(2)}" y="${w.toFixed(2)}" width="${x.toFixed(2)}" height="${b.toFixed(2)}" />
283  ${A.join("")}
284  <line class="sr-tl-axis" x1="${m.toFixed(2)}" y1="${v.toFixed(2)}" x2="${(m+x).toFixed(2)}" y2="${v.toFixed(2)}" />
285  <line class="sr-tl-axis" x1="${m.toFixed(2)}" y1="${w.toFixed(2)}" x2="${m.toFixed(2)}" y2="${v.toFixed(2)}" />
286  <text class="sr-tl-ylbl" transform="rotate(-90 ${_.toFixed(2)} ${P.toFixed(2)})" x="${_.toFixed(2)}" y="${P.toFixed(2)}" text-anchor="middle" fill="${Ee}">Total Debt Balance</text>
287  <g clip-path="url(#srPlotClip)">
288  <polygon class="sr-tl-fill" points="${Ne}" fill="url(#srAccelFillGrad)" />
289  <polyline class="sr-tl-line sr-tl-line--base" points="${be}" fill="none" stroke="${De}" stroke-width="1.35" stroke-dasharray="5 4" stroke-linecap="round" stroke-linejoin="round" />
290  <polyline class="sr-tl-line sr-tl-line--accel" points="${ae}" fill="none" stroke="${R}" stroke-width="3.1" stroke-linecap="square" stroke-linejoin="miter" />
291  </g>
292  ${At}
293  ${Ht}
294  ${_t}
295  ${Xe}
296  <text class="sr-tl-baselbl" x="${N(n[qe]).toFixed(2)}" y="${$e.toFixed(2)}" text-anchor="middle" dominant-baseline="hanging" fill="${De}" font-size="7">Baseline</text>
297  ${Ue}
298  ${et}
299  <text class="sr-tl-xcap" x="${(m+x/2).toFixed(2)}" y="${(v+32).toFixed(2)}" text-anchor="middle" dominant-baseline="hanging" fill="${Ee}" font-size="9.5">Years from Strategy Start</text>
300</svg>`,an=`<div class="sr-timeline-legend" role="list">
301    <span class="sr-timeline-legend-item" role="listitem">${Lt(R)}<span>Accelerated Payoff</span></span>
302    <span class="sr-timeline-legend-item" role="listitem">${Lt(De)}<span>Baseline (Min. Payments)</span></span>
303  </div>`,it=`<p class="sr-timeline-foot">${Je(Ty(T,Q))}</p>`;return`<section class="sr-timeline-card">
304    <div class="sr-timeline-headband"><h2 class="sr-timeline-title">Payoff Timeline</h2></div>
305    <div class="sr-timeline-body">${kt}${an}${it}</div>
306  </section>`}function fb(e){const t=e.payoffDate?`<div class="sr-years-date">${Je(e.payoffDate)}</div>`:"";return`<div class="sr-years-stack"><div class="sr-years-primary">${Je(e.years)}</div>${t}</div>`}function mb(e){if(!e)return[["Record","No property on file yet."]];const t=Hn(e.monthly_taxes)+Hn(e.monthly_insurance)+Hn(e.monthly_pmi)+Hn(e.monthly_hoa),n=Hn(e.mortgage_payment),r=n+t,s=`${e.property_type.replace(/_/g," ")}${e.classification?` · ${e.classification}`:""}`,i={outstandingBalance:Hn(e.outstanding_mortgage_balance),originalPrincipal:Hn(e.original_mortgage_balance),annualRatePercent:Hn(e.mortgage_interest_rate),termYears:Hn(e.mortgage_term_years)||30,totalMonthlyPayment:n,monthlyTaxes:e.monthly_taxes,monthlyInsurance:e.monthly_insurance,monthlyPmi:e.monthly_pmi},c=Qg(i),l=c!=null?["Years Remaining",{kind:"html",html:fb(c),labelClass:"sr-label--years"}]:["Years Remaining","—"];return[["Address / label",Rp(e)],["Type",s],["Estimated Value",Dt(e.estimated_value)],["Outstanding Mortgage",Dt(e.outstanding_mortgage_balance)],["Interest Rate",`${Hn(e.mortgage_interest_rate).toFixed(2)}%`],["Total Payment (w/ Escrow)",Dt(r)],["Principal & Interest",Dt(n)],["Escrow (taxes / ins. / PMI / HOA)",t>0?Dt(t):"—"],l]}function Ff(e,t){return e.map(n=>{const r=n.sub?`<div class="cf-sub">${Je(n.sub)}</div>`:"",s=n.highlight?"cf-card cf-card--hi":"cf-card",i=t?n.title.toUpperCase():n.title;return`<div class="${s}"><div class="${t?"cf-title cf-title--caps":"cf-title"}">${Je(i)}</div><div class="${cb(n.tone)}">${Je(n.value)}</div>${r}</div>`}).join("")}function Tf(e,t){const n=t.map(([r,s])=>{const i=typeof s=="object"&&s.kind==="html"&&s.labelClass?`sr-label ${s.labelClass}`:"sr-label";return typeof s=="object"&&s.kind==="html"?`<tr><th class="${i}">${Je(r)}</th><td class="num sr-val sr-years-val-cell">${s.html}</td></tr>`:`<tr><th class="sr-label">${Je(r)}</th><td class="num sr-val">${Je(s)}</td></tr>`}).join("");return`<section class="sr-card sr-card--intake"><div class="sr-section-title">${Je(e)}</div><table class="tbl tbl-stripe-alt"><tbody>${n}</tbody></table></section>`}function Df(e,t,n,r){return`<section class="sr-card sr-card--mock">
307    <div class="sr-mock-title">${Je(e)}</div>
308    <div class="sr-mock-colhead"><span>${Je(t)}</span><span class="num">${Je(n)}</span></div>
309    <table class="tbl tbl-stripe-muted"><tbody>${r}</tbody></table>
310  </section>`}function pb(e){var Ce,ve;
310const{lead:t,scenarioName:n,assessment:r,properties:s,debts:i,expenses:c,metrics:l,cashflow:d,additionalClients:h,logoDataUrl:f,calculatorPayoffComparison:x,helocTermsRows:b}=e,m=s.find(we=>we.property_type==="primary_residence")??s[0]??null,w=[["Name",jl(t)],["Email",t.email||"—"],["Phone",t.phone||"—"]];r!=null&&r.citizenship_status?w.push(["Citizenship / Residency",r.citizenship_status]):(r==null?void 0:r.is_us_citizen)!=null&&w.push(["U.S. Citizen",r.is_us_citizen?"Yes":"No"]),(r==null?void 0:r.is_military_veteran)!=null&&w.push(["Military / Veteran",r.is_military_veteran?"Yes":"No"]),(r==null?void 0:r.fico_score)!=null&&r.fico_score>0&&w.push(["Credit Score",String(r.fico_score)]);const v=i.filter(we=>!we.ignored),_=`<section class="sr-card sr-card--intake"><div class="sr-section-title">Debts</div><table class="tbl tbl-wide tbl-stripe-alt tbl-debts">${v.length>0?`<thead><tr><th>Name</th><th>Type</th><th class="num">Balance</th><th class="num">Min Pmt</th><th class="num">Rate</th></tr></thead><tbody>${v.map(we=>`<tr><td>${Je(we.debt_name||"Debt")}</td><td>${Je((we.debt_type||"other").replace(/_/g," "))}</td><td class="num">${Je(Dt(we.current_balance))}</td><td class="num">${Je(Dt(we.monthly_payment))}</td><td class="num">${Je(`${Number(we.interest_rate).toFixed(2)}%`)}</td></tr>`).join("")}</tbody>`:'<tbody><tr><td colspan="5" class="sr-empty-msg">No debts in this scenario.</td></tr></tbody>'}</table></section>`,q=c.reduce((we,De)=>we+Hn(De.amount),0),T=c.length>0?c.map(we=>`<tr><th class="sr-mock-body-label">${Je(we.category.replace(/_/g," "))}</th><td class="num sr-mock-body-val">${Je(Dt(we.amount))}</td></tr>`).join("")+`<tr class="sr-total-row"><th class="sr-mock-body-label">Total</th><td class="num sr-mock-body-val">${Je(Dt(q))}</td></tr>`:'<tr><td colspan="2" class="sr-empty-msg">No Expense Categories Yet — totals may read high until you add living costs.</td></tr>',B=Df("Monthly Expenses","Category","Amount / Month",T),Q=r,me=(Q==null?void 0:Q.most_recent_year_gross)??(Q==null?void 0:Q.yearly_gross_income),ce=(Q==null?void 0:Q.prior_year_gross)??(Q==null?void 0:Q.yearly_gross_income),$=me!=null&&ce!=null?(Hn(me)+Hn(ce))/24:Q?Hn(Q.yearly_gross_income)/12:0,Y=[["Most Recent Year Gross",Q?Dt(Hn(me)):"—"],["Prior Year Gross",Q?Dt(Hn(ce)):"—"],["24-Mo Avg Monthly Gross",Q?Dt($):"—"],["Net Monthly Income",Q?Dt(Q.monthly_net_income):"—"],["Savings",Q?Dt(Q.savings_balance):"—"],["Retirement",Q?Dt(Q.retirement_balance):"—"],["Other Assets",Q?Dt(Q.other_assets):"—"],["Reserves For Paydown",Q?Dt(Q.reserves_for_paydown):"—"]].map(([we,De])=>{const R=we==="24-Mo Avg Monthly Gross";return`<tr><th class="sr-mock-body-label">${Je(we)}</th><td class="num sr-mock-body-val${R?" sr-mock-body-val--accent":""}">${Je(De)}</td></tr>`}).join(""),N=Df("Income & Assets","Category","Amount",Y),I=ob(d,s),k=b!=null&&b.length?`<section class="sr-card sr-cf-block"><div class="sr-block-title">Simulated HELOC Terms</div><div class="cf-row">${Ff(lb(b),!1)}</div></section>`:"",L=`<section class="sr-card sr-cf-block"><div class="sr-block-title">Cash Flow Summary</div><div class="cf-row">${Ff(I,!0)}</div></section>`,H=l.payoffComparison;let te="";if(H){const we=H.baseline.totalInterest,De=H.accelerated.totalInterest,R=Co(we),ze=Co(De),ye=H.baseline.monthsToPayoff,Ee=H.accelerated.monthsToPayoff,de=ye!=null&&Ee!=null?Math.max(0,ye-Ee):Math.max(0,H.timeSavedMonths??0),Ue=H.interestSavedDollars??(we!=null&&De!=null?Math.max(0,Math.round(we-De)):null),qe=Ue!=null?`$${Math.round(Ue).toLocaleString()}`:"—",$e=H.tipSavedPct,Ge=$e!=null&&Number.isFinite($e)&&$e>=0,bt=$e==null||!Number.isFinite($e)?"—":Ge?`${Math.round($e)}% saved`:`${Math.round(Math.abs($e))}% higher`,et=$e==null||!Number.isFinite($e)?"sr-ap-acc-val sr-ap-acc-val--muted":Ge?"sr-ap-acc-val sr-ap-acc-val--green":"sr-ap-acc-val sr-ap-acc-val--red",Me="TIP uses the primary mortgage balance as the percentage basis. For 1st-lien HELOCs, LOC interest is allocated to the mortgage share of the opening HELOC balance so consolidated consumer debt does not inflate the mortgage comparison.",vt=H.monthlyPaymentSavingsDollars,St=vt!=null&&Number.isFinite(vt)&&vt>0,Oe=St?`${Co(vt)} / mo`:"—",_t=St?"sr-ap-acc-val sr-ap-acc-val--green":"sr-ap-acc-val sr-ap-acc-val--muted",Xe="Sum of debt payments plus mortgage P&I and PMI that go away after payoff. Property taxes and homeowners insurance remain due and are excluded.",Ht=(Ce=l.strategyDecision)==null?void 0:Ce.status,Lt=Jy(Ht),At=Ht==="go"?"sr-pay-qual-badge sr-pay-qual-badge--go":Ht==="conditional"?"sr-pay-qual-badge sr-pay-qual-badge--conditional":"sr-pay-qual-badge sr-pay-qual-badge--review",kt=Ht==="go"&&Lt?`${da.leaf}<span>${Je(Lt)}</span>`:Lt?`<span>${Je(Lt)}</span>`:"",an=Lt?`<span class="${At}" role="status">${kt}</span>`:"",it=(ve=x==null?void 0:x.baseline)==null?void 0:ve.scheduleByDebt,at=[];for(const[Ae,Re]of Zy(it))!Re||Re.length<2||at.push({label:eb(Ae,i,s),months:nb(Re),interest:Math.round(tb(Re))});const Ve=at.length>0?`<table class="tbl sr-ap-inner-tbl"><thead><tr><th>
310Debt</th><th class="num">Months to payoff</th><th class="num">Interest (baseline)</th></tr></thead><tbody>${at.map(Ae=>`<tr><td>${Je(Ae.label)}</td><td class="num">${Je(Za(Ae.months))}</td><td class="num">${Je(Co(Ae.interest))}</td></tr>`).join("")}</tbody></table>`:'<p class="sr-ap-acc-empty">Run and save the Calculator tab on this lead for per-debt baseline detail.</p>',ft=rb(i,s),wt=[...i.filter(Ae=>!Ae.ignored).map(Ae=>({name:Ae.debt_name||"Debt",type:(Ae.debt_type||"other").replace(/_/g," "),balance:Hn(Ae.current_balance)})),...s.filter(Ae=>Hn(Ae.outstanding_mortgage_balance)>0).map(Ae=>({name:Ae.property_type==="primary_residence"?"Primary Mortgage":Ae.property_type==="rental"?"Rental Mortgage":Ae.property_type==="vacation_rental"?"Vacation Rental Mortgage":"Secondary Mortgage",type:"mortgage",balance:Hn(Ae.outstanding_mortgage_balance)}))],Nt=wt.length>0?`<div class="sr-ap-debt-list">${wt.map(Ae=>`<div class="sr-ap-debt-row"><span class="sr-ap-debt-name">${Je(Ae.name)} <span class="sr-ap-debt-type">${Je(Ae.type)}</span></span><span class="num sr-ap-debt-bal">${Je(Co(Ae.balance))}</span></div>`).join("")}</div>`:'<p class="sr-ap-acc-empty">No debts in this scenario.</p>';te=`
311    <section class="sr-payoff-card">
312      <div class="sr-payoff-headband">
313        <div class="sr-payoff-head-row">
314          <h2 class="sr-payoff-card-title">Accelerated Payoff Analysis</h2>
315          ${an}
316        </div>
317        <p class="sr-payoff-card-compliance">${Je(Td)}</p>
318      </div>
319      <div class="sr-ap-body">
320        <div class="sr-ap-columns">
321          <div class="sr-ap-card sr-ap-card--baseline">
322            <p class="sr-ap-card-h">Baseline (Min. Payments)</p>
323            <div class="sr-ap-metric">
324              ${da.dollar}
325              <div class="sr-ap-metric-text">
326                <p class="sr-ap-metric-lbl">Total interest (including estimated consumer debt interest)</p>
327                <p class="sr-ap-metric-val sr-ap-metric-val--red">${Je(R)}</p>
328              </div>
329            </div>
330            <div class="sr-ap-metric">
331              ${da.clock}
332              <div class="sr-ap-metric-text">
333                <p class="sr-ap-metric-lbl">Time left</p>
334                <p class="sr-ap-metric-val sr-ap-metric-val--red">${Je(ye==null?"—":Za(ye))}</p>
335              </div>
336            </div>
337            <div class="sr-ap-metric">
338              ${da.calendar}
339              <div class="sr-ap-metric-text">
340                <p class="sr-ap-metric-lbl">Paid off in</p>
341                <p class="sr-ap-metric-val sr-ap-metric-val--red">${Je(If(ye))}</p>
342              </div>
343            </div>
344          </div>
345          <div class="sr-ap-card sr-ap-card--accel">
346            <p class="sr-ap-card-h sr-ap-card-h--green">Accelerated Payoff</p>
347            <div class="sr-ap-metric">
348              ${da.dollar}
349              <div class="sr-ap-metric-text">
350                <p class="sr-ap-metric-lbl sr-ap-metric-lbl--green">New total interest (including all consumer debt being paid)</p>
351                <p class="sr-ap-metric-val sr-ap-metric-val--green">${Je(ze)}</p>
352              </div>
353            </div>
354            <div class="sr-ap-metric">
355              ${da.clock}
356              <div class="sr-ap-metric-text">
357                <p class="sr-ap-metric-lbl sr-ap-metric-lbl--green">Time left</p>
358                <p class="sr-ap-metric-val sr-ap-metric-val--green">${Je(Ee==null?"—":Za(Ee))}</p>
359              </div>
360            </div>
361            <div class="sr-ap-metric">
362              ${da.calendar}
363              <div class="sr-ap-metric-text">
364                <p class="sr-ap-metric-lbl sr-ap-metric-lbl--green">Paid off in</p>
365                <p class="sr-ap-metric-val sr-ap-metric-val--green">${Je(If(Ee))}</p>
366              </div>
367            </div>
368          </div>
369        </div>
370        <div class="sr-ap-acc-list">
371          <details class="sr-ap-acc">
372            <summary class="sr-ap-acc-sum"><span class="sr-ap-chev" aria-hidden="true"></span>${da.trend}<span class="sr-ap-acc-lbl">Time Saved</span><span class="sr-ap-acc-val sr-ap-acc-val--green">${Je(Xy(de))}</span></summary>
373            <div class="sr-ap-acc-body">${Je("Total calendar time saved: baseline minimum-payment payoff minus accelerated strategy payoff (all debts in this analysis).")}</div>
374          </details>
375          <details class="sr-ap-acc">
376            <summary class="sr-ap-acc-sum"><span class="sr-ap-chev" aria-hidden="true"></span>${da.dollar}<span class="sr-ap-acc-lbl">Interest Saved</span><span class="sr-ap-acc-val sr-ap-acc-val--green">${Je(qe)}</span></summary>
377            <div class="sr-ap-acc-body">${Je("Total interest saved: baseline minimum-payment interest minus total interest under the accelerated strategy (including HELOC interest).")}</div>
378          </details>
379          <details class="sr-ap-acc">
380            <summary class="sr-ap-acc-sum"><span class="sr-ap-chev" aria-hidden="true"></span>${da.file}<span class="sr-ap-acc-lbl">Total Monthly Payment Savings</span><span class="${_t}">${Je(Oe)}</span></summary>
381            <div class="sr-ap-acc-body">${Je(Xe)}</div>
382          </details>
383          <details class="sr-ap-acc">
384            <summary class="sr-ap-acc-sum"><span class="sr-ap-chev" aria-hidden="true"></span>${da.trend}<span class="sr-ap-acc-lbl">Total Interest Percentage Savings (TIP)</span><span class="${et}">${Je(bt)}</span></summary>
385            <div class="sr-ap-acc-body">${Je(Me)}</div>
386          </details>
387          <details class="sr-ap-acc">
388            <summary class="sr-ap-acc-sum"><span class="sr-ap-chev" aria-hidden="true"></span>${da.list}<span class="sr-ap-acc-lbl">Baseline by Debt (minimum payments)</span><span class="sr-ap-acc-link">View detail</span></summary>
389            <div class="sr-ap-acc-panel">${Ve}</div>
390          </details>
391          <details class="sr-ap-acc">
392            <summary class="sr-ap-acc-sum"><span class="sr-ap-chev" aria-hidden="true"></span>${da.list}<span class="sr-ap-acc-lbl">Debts included in this analysis (${ft})</span><span class="sr-ap-acc-link">View detail</span></summary>
393            <div class="sr-ap-acc-panel">${Nt}</div>
394          </details>
395        </div>
396      </div>
397    </section>`}else te=`
398    <section class="sr-payoff-card">
399      <div class="sr-payoff-headband">
400        <div class="sr-payoff-head-row">
401          <h2 class="sr-payoff-card-title">Accelerated Payoff Analysis</h2>
402        </div>
403        <p class="sr-payoff-card-compliance">${Je(Td)}</p>
404      </div>
405      <div class="sr-ap-body">
406        <p class="sr-ap-acc-empty" style="margin:0;">Payoff comparison not available — add debts or complete intake to model baseline vs. accelerated timing.</p>
407      </div>
408    </section>`;
408const se=ab(e),K=Ay(x??null,H??null,se),ae=(x==null?void 0:x.accelerated.payoffDate)??((H==null?void 0:H.accelerated.monthsToPayoff)!=null?fm(new Date,Math.max(0,Math.ceil(H.accelerated.monthsToPayoff))):null),be=K&&K.months.length>1?hb(K,ae):'<section class="sr-card"><p class="sr-empty-msg">Payoff timeline appears when comparison data is available.</p></section>',Ne=Oy(e)?Qy(e):"",A=qy(e)?Ry(e.suggestedLenders??[]):"",E=h!=null&&h.length?`<section class="sr-card sr-card--intake"><div class="sr-section-title">Household Members</div><table class="tbl tbl-wide tbl-stripe-alt"><thead><tr><th>Borrower / Member</th><th class="num">Monthly Net</th></tr></thead><tbody>${h.map(we=>{const De=`${we.first_name??""} ${we.last_name??""}`.trim()||"Household member";return`<tr><td>${Je(De)}</td><td class="num">${Je(Dt(Number(we.monthly_net_income??0)))} / mo</td></tr>`}).join("")}</tbody></table></section>`:"",z=!!f,X=Math.round(50*Sy),Z=z?`<img class="logo" src="${f}" alt="" width="${X}" height="50" />`:"",le=z?`<div class="sr-titles"><h1 class="sr-h1">Strategy Summary</h1><div class="sr-scenario">${Je(n)} · ${Je(jl(t))}</div></div>`:`<div class="sr-titles"><div class="sr-brand">Accelerated Strategies</div><h1 class="sr-h1">Strategy Summary</h1><div class="sr-scenario">${Je(n)} · ${Je(jl(t))}</div></div>`,fe=Je(new Date().toLocaleString()),ue=`<section class="sr-disclaimer-wrap" aria-labelledby="sr-disc-heading">
409  <div class="sr-disclaimer-card">
410    <div class="sr-disclaimer-bar" aria-hidden="true"></div>
411    <div class="sr-disclaimer-amber">
412      <div class="sr-disclaimer-important" id="sr-disc-heading">Important</div>
413      <p class="sr-disclaimer-body">${Je(by)}</p>
414      <div class="sr-disclaimer-legal-label">Legal &amp; disclosures:</div>
415      <a class="sr-link" href="${Je(vy)}">Terms of Service</a>
416      <a class="sr-link" href="${Je(_y)}">Financial Disclosure</a>
417    </div>
418  </div>
419</section>`,_e=`<section class="sr-questions-card">
420  <div class="sr-questions-title">Still Have Questions?</div>
421  <p class="sr-questions-lead">Check out our Common Questions Page:</p>
422  <a class="sr-questions-url" href="${Je(Ef)}">${Je(Ef)}</a>
423</section>`;return`<!DOCTYPE html>
424<html lang="en">
425<head>
426<meta charset="utf-8"/>
427<meta name="viewport" content="width=device-width, initial-scale=1"/>
428<title>${Je(`Strategy Summary — ${jl(t)}`)}</title>
429<style>
430${Vy()}
431  @page { size: letter; margin: 0; }
432  * { box-sizing: border-box; }
433  html {
434    font-family: Helvetica, Arial, sans-serif;
435    color: var(--sr-text);
436    font-size: calc(9pt * var(--sr-fs-mul));
437    line-height: 1.35;
438    -webkit-print-color-adjust: exact;
439    print-color-adjust: exact;
440  }
441  body { margin: 0; padding: 0; background: var(--sr-surface); }
442  .sr-header {
443    background: ${ua(dn.headerBand)};
444    min-height: 96pt;
445    padding: 8pt ${Os.headingPadX+22}pt 0 ${Os.headingPadX+22}pt;
446    border-bottom: 0.75pt solid var(--sr-border);
447  }
448  .sr-header-main {
449    display: flex;
450    align-items: flex-start;
451    justify-content: space-between;
452    gap: 12pt;
453    flex-wrap: wrap;
454    max-width: 100%;
455  }
456  .sr-header-left { display: flex; align-items: center; gap: 14pt; min-width: 0; flex: 1 1 auto; }
457  .logo { display: block; flex-shrink: 0; }
458  .sr-brand { font-weight: 700; font-size: calc(13pt * var(--sr-fs-mul)); color: var(--sr-heading); margin: 0 0 2pt; }
459  .sr-h1 { margin: 0; font-size: calc(17pt * var(--sr-fs-mul)); font-weight: 700; color: var(--sr-heading); letter-spacing: -0.02em; }
460  .sr-scenario { margin-top: 4pt; font-size: calc(9pt * var(--sr-fs-mul)); color: var(--sr-muted); }
461  .sr-trust-col { flex: 0 0 auto; text-align: right; min-width: 140pt; }
462  .sr-trust-row { display: flex; justify-content: flex-end; gap: 8pt; flex-wrap: wrap; margin-bottom: 10pt; }
463  .sr-badge {
464    display: inline-block;
465    width: 108pt;
466    min-height: 26pt;
467    border-radius: 4pt;
468    padding: 5pt 8pt;
469    text-decoration: none;
470    color: #fff;
471    vertical-align: top;
472  }
473  .sr-badge--tp { background: var(--sr-trust-tp); }
474  .sr-badge--bbb { background: var(--sr-trust-bbb); }
475  .sr-badge-title { display: block; font-weight: 700; font-size: calc(8pt * var(--sr-fs-mul)); line-height: 1.2; }
476  .sr-badge-sub { display: block; font-weight: 400; font-size: calc(7pt * var(--sr-fs-mul)); opacity: 0.95; margin-top: 2pt; }
477  .sr-prepared-label { font-weight: 700; font-size: calc(7.5pt * var(--sr-fs-mul)); color: var(--sr-muted); }
478  .sr-prepared-date { font-size: calc(9pt * var(--sr-fs-mul)); color: var(--sr-heading); margin-top: 4pt; }
479  .sr-header-sub {
480    margin: 10pt 0 0;
481    padding-bottom: 10pt;
482    font-size: calc(8.5pt * var(--sr-fs-mul));
483    font-style: italic;
484    color: var(--sr-muted);
485  }
486  .sr-content { padding: 16pt ${Os.headingPadX+22}pt 36pt; }
487  .intro {
488    margin: 0 0 14pt;
489    font-size: calc(8pt * var(--sr-fs-mul));
490    font-style: italic;
491    color: var(--sr-muted);
492    line-height: 1.45;
493    max-width: 100%;
494  }
495  .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10pt; margin-bottom: 10pt; }
496  @media (max-width: 720px) { .grid2 { grid-template-columns: 1fr; } }
497  .sr-card {
498    border: var(--sr-line) solid var(--sr-border);
499    border-radius: var(--sr-card-radius);
500    background: var(--sr-surface);
501    margin-bottom: 10pt;
502    overflow: hidden;
503  }
504  .sr-section-title {
505    margin: 0;
506    padding: 12pt var(--sr-pad-x) 8pt;
507    font-size: calc(11pt * var(--sr-fs-mul));
508    font-weight: 700;
509    color: var(--sr-heading);
510    background: var(--sr-surface);
511  }
512  .sr-mock-title {
513    margin: 0;
514    padding: 14pt var(--sr-pad-x) 10pt;
515    font-size: calc(12pt * var(--sr-fs-mul));
516    font-weight: 700;
517    color: var(--sr-heading);
518    background: var(--sr-surface);
519  }
520  .sr-mock-colhead {
521    display: flex;
522    justify-content: space-between;
523    align-items: center;
524    padding: 8pt var(--sr-pad-x);
525    font-size: calc(8.5pt * var(--sr-fs-mul));
526    font-weight: 700;
527    color: var(--sr-heading);
528    background: var(--sr-surface-alt);
529    border-bottom: 0.15pt solid var(--sr-border);
530  }
531  .tbl { width: 100%; border-collapse: collapse; font-size: calc(9pt * var(--sr-fs-mul)); color: var(--sr-text); }
532  .tbl-stripe-alt tbody tr:nth-child(odd) { background: var(--sr-surface); }
533  .tbl-stripe-alt tbody tr:nth-child(even) { background: var(--sr-surface-alt); }
534  .tbl-stripe-muted tbody tr:nth-child(odd) { background: var(--sr-surface); }
535  .tbl-stripe-muted tbody tr:nth-child(even) { background: var(--sr-tile-muted); }
536  .tbl th,
537  .tbl td {
538    padding: 6pt var(--sr-pad-x);
539    border-bottom: 0.15pt solid var(--sr-border);
540    vertical-align: middle;
541  }
542  .tbl thead th {
543    font-size: calc(8.5pt * var(--sr-fs-mul));
544    font-weight: 700;
545    color: var(--sr-heading);
546    background: var(--sr-surface-alt);
547    text-align: left;
548  }
549  .tbl-debts tbody { font-size: calc(8.5pt * var(--sr-fs-mul)); }
550  .sr-label {
551    width: 42%;
552    font-weight: 700;
553    color: var(--sr-muted);
554    text-align: left;
555  }
556  .sr-label.sr-label--years {
557    font-weight: 400;
558    vertical-align: top;
559    padding-top: 7pt;
560  }
561  .sr-years-stack {
562    display: flex;
563    flex-direction: column;
564    align-items: flex-end;
565    gap: 2pt;
566    line-height: 1.25;
567  }
568  .sr-years-primary {
569    font-weight: 700;
570    font-size: calc(10pt * var(--sr-fs-mul));
571    color: var(--sr-text);
572  }
573  .sr-years-date {
574    font-weight: 400;
575    font-size: calc(8pt * var(--sr-fs-mul));
576    color: var(--sr-muted);
577  }
578  .sr-years-val-cell {
579    vertical-align: top;
580    padding-top: 6pt;
581  }
582  .sr-val { font-weight: 400; color: var(--sr-text); }
583  .sr-mock-body-label { font-weight: 400; color: var(--sr-heading); text-align: left; }
584  .sr-mock-body-val { font-weight: 400; color: var(--sr-text); }
585  .sr-mock-body-val--accent { color: var(--sr-val-green); }
586  .sr-total-row th,
587  .sr-total-row td { background: var(--sr-surface-alt); font-weight: 700; color: var(--sr-heading); }
588  .num { text-align: right; font-variant-numeric: tabular-nums; }
589  .sr-empty-msg {
590    padding: 12pt var(--sr-pad-x) 14pt;
591    font-style: italic;
592    color: var(--sr-muted);
593    font-size: calc(9pt * var(--sr-fs-mul));
594  }
595  .sr-block-title {
596    margin: 0;
597    padding: 10pt var(--sr-pad-x) 0;
598    font-size: calc(12pt * var(--sr-fs-mul));
599    font-weight: 700;
600    color: var(--sr-heading);
601  }
602  .sr-cf-block .cf-row { padding: 0 var(--sr-pad-x) 12pt; margin-top: 8pt; }
603  .cf-row { display: flex; flex-wrap: wrap; gap: 8pt; }
604  .cf-card {
605    flex: 1 1 120pt;
606    border: var(--sr-line) solid var(--sr-border);
607    border-radius: 6pt;
608    padding: 8pt 6pt 10pt;
609    background: var(--sr-surface);
610  }
611  .cf-card--hi { background: var(--sr-section-panel-bg); border-color: var(--sr-section-panel-border); }
612  .cf-title {
613    font-size: calc(6.5pt * var(--sr-fs-mul));
614    font-weight: 400;
615    color: var(--sr-muted);
616    letter-spacing: 0.02em;
617    margin-bottom: 4pt;
618    line-height: 1.25;
619  }
620  .cf-title--caps { text-transform: uppercase; letter-spacing: 0.04em; }
621  .cf-val { font-size: calc(10.5pt * var(--sr-fs-mul)); font-weight: 700; line-height: 1.2; }
622  .cf-val--green { color: var(--sr-val-green); }
623  .cf-val--red { color: var(--sr-val-red); }
624  .cf-val--neutral { color: var(--sr-text); }
625  .cf-sub { font-size: calc(7pt * var(--sr-fs-mul)); color: var(--sr-muted); margin-top: 4pt; line-height: 1.3; }
626  .sr-payoff-card {
627    border: var(--sr-line) solid var(--sr-border);
628    border-radius: var(--sr-card-radius);
629    background: var(--sr-surface);
630    margin-bottom: 10pt;
631    overflow: hidden;
632  }
633  .sr-payoff-headband {
634    background: var(--sr-payoff-head-bg);
635    padding: 11pt var(--sr-pad-x) 12pt;
636    border-bottom: var(--sr-line) solid var(--sr-border);
637  }
638  .sr-payoff-card-title {
639    margin: 0;
640    font-size: calc(11pt * var(--sr-fs-mul));
641    font-weight: 700;
642    color: var(--sr-heading);
643    letter-spacing: -0.01em;
644  }
645  .sr-payoff-card-compliance {
646    margin: 5pt 0 0;
647    font-size: calc(8pt * var(--sr-fs-mul));
648    font-style: italic;
649    font-weight: 400;
650    color: var(--sr-muted);
651    line-height: 1.4;
652  }
653  .sr-payoff-head-row {
654    display: flex;
655    flex-wrap: wrap;
656    align-items: flex-start;
657    justify-content: space-between;
658    gap: 8pt 12pt;
659  }
660  .sr-payoff-head-row .sr-payoff-card-title {
661    margin: 0;
662    flex: 1 1 auto;
663    min-width: 0;
664  }
665  .sr-pay-qual-badge {
666    display: inline-block;
667    flex-shrink: 0;
668    padding: 4pt 11pt;
669    border-radius: 8pt;
670    font-size: calc(8pt * var(--sr-fs-mul));
671    font-weight: 700;
672    border: var(--sr-line) solid var(--sr-border);
673    white-space: nowrap;
674  }
675  .sr-pay-qual-badge--go {
676    display: inline-flex;
677    align-items: center;
678    gap: 5pt;
679    background: var(--sr-primary-soft);
680    border-color: var(--sr-section-panel-border);
681    color: var(--sr-accel-label);
682  }
683  .sr-ap-badge-leaf {
684    flex-shrink: 0;
685    display: block;
686  }
687  .sr-pay-qual-badge--conditional {
688    background: rgb(255, 251, 235);
689    border-color: rgb(253, 224, 71);
690    color: rgb(146, 64, 14);
691  }
692  .sr-pay-qual-badge--review {
693    background: var(--sr-surface-alt);
694    color: var(--sr-muted);
695  }
696  .sr-ap-body {
697    padding: 12pt var(--sr-pad-x) 14pt;
698    background: var(--sr-surface);
699  }
700  .sr-ap-columns {
701    display: grid;
702    grid-template-columns: 1fr 1fr;
703    gap: 10pt;
704    margin-bottom: 12pt;
705  }
706  .sr-ap-card {
707    border-radius: 8pt;
708    padding: 14pt;
709  }
710  .sr-ap-card--baseline {
711    border: 0.35pt solid rgba(220, 53, 69, 0.38);
712    background: rgba(220, 53, 69, 0.06);
713  }
714  .sr-ap-card--accel {
715    border: 0.35pt solid rgba(40, 167, 69, 0.38);
716    background: rgba(40, 167, 69, 0.07);
717  }
718  .sr-ap-card-h {
719    margin: 0 0 12pt;
720    font-size: calc(8.75pt * var(--sr-fs-mul));
721    font-weight: 700;
722    color: #dc3545;
723    letter-spacing: -0.01em;
724  }
725  .sr-ap-card-h--green {
726    color: #28a745;
727  }
728  .sr-ap-metric {
729    display: flex;
730    gap: 11pt;
731    margin-bottom: 12pt;
732    align-items: flex-start;
733  }
734  .sr-ap-metric:last-child {
735    margin-bottom: 0;
736  }
737  .sr-ap-ico {
738    flex-shrink: 0;
739    color: var(--sr-text);
740    margin-top: 2pt;
741  }
742  .sr-ap-metric-text {
743    min-width: 0;
744  }
745  .sr-ap-metric-lbl {
746    margin: 0 0 4pt;
747    font-size: calc(8.25pt * var(--sr-fs-mul));
748    line-height: 1.38;
749    color: rgba(220, 53, 69, 0.82);
750  }
751  .sr-ap-metric-lbl--green {
752    color: rgba(40, 167, 69, 0.82);
753  }
754  .sr-ap-metric-val {
755    margin: 0;
756    font-size: calc(15pt * var(--sr-fs-mul));
757    font-weight: 700;
758    font-variant-numeric: tabular-nums;
759    letter-spacing: -0.02em;
760    line-height: 1.15;
761  }
762  .sr-ap-metric-val--red {
763    color: #dc3545;
764  }
765  .sr-ap-metric-val--green {
766    color: #28a745;
767  }
768  .sr-ap-acc-list {
769    display: flex;
770    flex-direction: column;
771    gap: 5pt;
772  }
773  details.sr-ap-acc {
774    border: 0.35pt solid var(--sr-border);
775    border-radius: 6pt;
776    background: var(--sr-surface);
777    overflow: hidden;
778  }
779  details.sr-ap-acc > summary {
780    list-style: none;
781    display: flex;
782    align-items: center;
783    gap: 7pt;
784    padding: 9pt 11pt;
785    cursor: pointer;
786    font-family: Helvetica, Arial, sans-serif;
787  }
788  details.sr-ap-acc > summary .sr-ap-ico {
789    flex-shrink: 0;
790    color: var(--sr-text);
791  }
792  details.sr-ap-acc > summary::-webkit-details-marker {
793    display: none;
794  }
795  .sr-ap-chev {
796    flex-shrink: 0;
797    width: 9pt;
798    text-align: center;
799    font-size: calc(7.5pt * var(--sr-fs-mul));
800    color: var(--sr-muted);
801    line-height: 1;
802  }
803  details.sr-ap-acc:not([open]) > summary .sr-ap-chev::before {
804    content: "▸";
805  }
806  details.sr-ap-acc[open] > summary .sr-ap-chev::before {
807    content: "▾";
808  }
809  .sr-ap-acc-lbl {
810    flex: 1;
811    min-width: 0;
812    font-weight: 700;
813    font-size: calc(8.75pt * var(--sr-fs-mul));
814    color: var(--sr-heading);
815    text-align: left;
816  }
817  .sr-ap-acc-val {
818    flex-shrink: 0;
819    font-weight: 700;
820    font-size: calc(9.5pt * var(--sr-fs-mul));
821    font-variant-numeric: tabular-nums;
822    text-align: right;
823  }
824  .sr-ap-acc-val--green {
825    color: #28a745;
826  }
827  .sr-ap-acc-val--red {
828    color: #dc3545;
829  }
830  .sr-ap-acc-val--muted {
831    color: var(--sr-muted);
832  }
833  .sr-ap-acc-link {
834    flex-shrink: 0;
835    font-weight: 700;
836    font-size: calc(8.75pt * var(--sr-fs-mul));
837    color: var(--sr-muted);
838  }
839  .sr-ap-acc-body {
840    border-top: 0.35pt solid var(--sr-border);
841    padding: 8pt 11pt 9pt;
842    font-size: calc(8pt * var(--sr-fs-mul));
843    line-height: 1.45;
844    color: var(--sr-muted);
845    background: rgba(0, 0, 0, 0.02);
846  }
847  .sr-ap-acc-panel {
848    border-top: 0.35pt solid var(--sr-border);
849    padding: 8pt 10pt 9pt;
850    background: rgba(0, 0, 0, 0.02);
851  }
852  .sr-ap-inner-tbl {
853    width: 100%;
854    font-size: calc(8pt * var(--sr-fs-mul));
855  }
856  .sr-ap-acc-empty {
857    margin: 0;
858    font-style: italic;
859    font-size: calc(8pt * var(--sr-fs-mul));
860    color: var(--sr-muted);
861    line-height: 1.4;
862  }
863  .sr-ap-debt-list {
864    display: flex;
865    flex-direction: column;
866  }
867  .sr-ap-debt-row {
868    display: flex;
869    justify-content: space-between;
870    align-items: baseline;
871    gap: 8pt;
872    padding: 5pt 0;
873    border-bottom: 0.35pt solid var(--sr-border);
874    font-size: calc(8.25pt * var(--sr-fs-mul));
875  }
876  .sr-ap-debt-row:last-child {
877    border-bottom: none;
878  }
879  .sr-ap-debt-name {
880    font-weight: 700;
881    color: var(--sr-text);
882  }
883  .sr-ap-debt-type {
884    font-size: calc(7.5pt * var(--sr-fs-mul));
885    font-weight: 500;
886    color: var(--sr-muted);
887    text-transform: capitalize;
888  }
889  .sr-ap-debt-bal {
890    font-weight: 700;
891    color: var(--sr-text);
892  }
893  .sr-timeline-card {
894    border: var(--sr-line) solid var(--sr-border);
895    border-radius: var(--sr-card-radius);
896    background: var(--sr-surface);
897    margin-bottom: 10pt;
898    overflow: hidden;
899  }
900  .sr-timeline-headband {
901    background: var(--sr-payoff-head-bg);
902    padding: 10pt var(--sr-pad-x) 11pt;
903    border-bottom: var(--sr-line) solid var(--sr-border);
904  }
905  .sr-timeline-title {
906    margin: 0;
907    font-size: calc(11pt * var(--sr-fs-mul));
908    font-weight: 700;
909    color: var(--sr-heading);
910    letter-spacing: -0.01em;
911  }
912  .sr-timeline-body { background: var(--sr-surface); padding: 12pt var(--sr-pad-x) 4pt; }
913  .sr-timeline-svg {
914    width: 100%;
915    max-width: 720pt;
916    height: auto;
917    display: block;
918    margin: 0 auto;
919  }
920  .sr-timeline-svg text { font-family: Helvetica, Arial, sans-serif; }
921  .sr-tl-grid { stroke: rgb(226, 232, 240); stroke-width: 1; fill: none; }
922  .sr-tl-axis { stroke: var(--sr-border); stroke-width: 1.1; fill: none; }
923  .sr-tl-axislbl { font-family: Helvetica, Arial, sans-serif; font-size: calc(9px * var(--sr-fs-mul)); fill: var(--sr-muted); }
924  .sr-tl-ylbl { font-family: Helvetica, Arial, sans-serif; font-size: calc(10px * var(--sr-fs-mul)); }
925  .sr-tl-annotline { stroke: var(--sr-val-green); stroke-width: 1; stroke-dasharray: 2 3; fill: none; }
926  .sr-tl-annot { font-family: Helvetica, Arial, sans-serif; font-size: calc(8.5px * var(--sr-fs-mul)); fill: var(--sr-val-green); }
927  .sr-tl-annot--mid { font-size: calc(8.5px * var(--sr-fs-mul)); }
928  .sr-timeline-legend {
929    display: flex;
930    flex-wrap: wrap;
931    align-items: center;
932    justify-content: center;
933    gap: 10pt 28pt;
934    padding: 6pt var(--sr-pad-x) 0;
935    font-size: calc(7.5pt * var(--sr-fs-mul));
936    color: var(--sr-text);
937  }
938  .sr-timeline-legend-item {
939    display: inline-flex;
940    align-items: center;
941    gap: 7pt;
942  }
943  .sr-tl-pin { display: block; flex-shrink: 0; }
944  .sr-timeline-foot {
945    margin: 0;
946    padding: 0 var(--sr-pad-x) 8pt;
947    font-size: calc(7.75pt * var(--sr-fs-mul));
948    font-style: italic;
949    color: var(--sr-muted);
950    text-align: center;
951    line-height: 1.42;
952  }
953  .sr-ai-section {
954    margin-bottom: 12pt;
955    border: var(--sr-line) solid var(--sr-border);
956    border-radius: var(--sr-card-radius);
957    background: var(--sr-surface);
958    overflow: hidden;
959  }
960  .sr-ai-header-band {
961    padding: 12pt ${Os.headingPadX+22}pt 11pt;
962    background: var(--sr-surface);
963    border-bottom: var(--sr-line) solid var(--sr-border);
964  }
965  .sr-ai-main-title {
966    margin: 0;
967    font-size: calc(14pt * var(--sr-fs-mul));
968    font-weight: 700;
969    color: var(--sr-heading);
970    letter-spacing: -0.02em;
971  }
972  .sr-ai-inner {
973    background: var(--sr-ai-panel);
974    padding: 14pt ${Os.headingPadX+22}pt 16pt;
975  }
976  .sr-ai-qual-intro {
977    display: flex;
978    align-items: flex-start;
979    gap: 10pt;
980    margin-bottom: 12pt;
981  }
982  .sr-ai-badge {
983    flex-shrink: 0;
984    width: 20pt;
985    height: 20pt;
986    border-radius: 4pt;
987    background: ${ua(dn.primary)};
988    display: flex;
989    align-items: center;
990    justify-content: center;
991  }
992  .sr-ai-badge-text {
993    font-size: calc(9pt * var(--sr-fs-mul));
994    font-weight: 700;
995    color: #fff;
996    line-height: 1;
997  }
998  .sr-ai-qual-titles {
999    min-width: 0;
1000    flex: 1;
1001  }
1002  .sr-ai-qual-heading {
1003    font-size: calc(11pt * var(--sr-fs-mul));
1004    font-weight: 700;
1005    color: var(--sr-heading);
1006    letter-spacing: -0.01em;
1007  }
1008  .sr-ai-qual-caps {
1009    margin-top: 5pt;
1010    font-size: calc(7pt * var(--sr-fs-mul));
1011    font-weight: 600;
1012    letter-spacing: 0.06em;
1013    color: var(--sr-muted);
1014    text-transform: uppercase;
1015    line-height: 1.35;
1016  }
1017  .sr-ai-summary-card {
1018    background: ${ua(dn.aiQualSummaryCard)};
1019    border: var(--sr-line) solid var(--sr-border);
1020    border-radius: 8pt;
1021    border-left: 5pt solid ${ua(dn.primary)};
1022    margin-bottom: 12pt;
1023    box-shadow: 0 1pt 2pt rgba(15, 23, 42, 0.04);
1024  }
1025  .sr-ai-summary-card__body {
1026    padding: 12pt 14pt 12pt 12pt;
1027  }
1028  .sr-ai-summary-line {
1029    margin: 0;
1030    font-size: calc(9pt * var(--sr-fs-mul));
1031    line-height: 1.55;
1032    color: var(--sr-text);
1033  }
1034  .sr-ai-summary-highlight {
1035    font-weight: 700;
1036    color: var(--sr-val-green);
1037  }
1038  .sr-ai-summary-rest {
1039    font-weight: 400;
1040    color: var(--sr-text);
1041  }
1042  .sr-ai-summary-placeholder {
1043    font-style: italic;
1044    color: var(--sr-muted);
1045  }
1046  .sr-ai-narrative-wrap {
1047    margin-bottom: 14pt;
1048  }
1049  .sr-ai-narrative-p {
1050    margin: 0 0 10pt;
1051    font-size: calc(9pt * var(--sr-fs-mul));
1052    line-height: 1.52;
1053    color: var(--sr-text);
1054  }
1055  .sr-ai-narrative-p:last-child {
1056    margin-bottom: 0;
1057  }
1058  .sr-ai-narrative-strong {
1059    font-weight: 700;
1060    color: var(--sr-val-green);
1061  }
1062  .sr-ai-kpi-grid {
1063    display: grid;
1064    grid-template-columns: repeat(4, 1fr);
1065    gap: 8pt;
1066  }
1067  @media (max-width: 640px) {
1068    .sr-ai-kpi-grid {
1069      grid-template-columns: repeat(2, 1fr);
1070    }
1071  }
1072  .sr-ai-kpi-tile {
1073    background: ${ua(dn.aiQualSummaryCard)};
1074    border: var(--sr-line) solid var(--sr-border);
1075    border-radius: 8pt;
1076    padding: 9pt 8pt 10pt;
1077    min-height: 52pt;
1078  }
1079  .sr-ai-kpi-title {
1080    font-size: calc(6.5pt * var(--sr-fs-mul));
1081    font-weight: 700;
1082    letter-spacing: 0.05em;
1083    text-transform: uppercase;
1084    color: var(--sr-muted);
1085    line-height: 1.25;
1086    margin-bottom: 6pt;
1087  }
1088  .sr-ai-kpi-val {
1089    font-size: calc(12pt * var(--sr-fs-mul));
1090    font-weight: 700;
1091    font-variant-numeric: tabular-nums;
1092    color: var(--sr-val-green);
1093    line-height: 1.15;
1094    margin-bottom: 5pt;
1095  }
1096  .sr-ai-kpi-sub {
1097    font-size: calc(6.5pt * var(--sr-fs-mul));
1098    color: var(--sr-muted);
1099    line-height: 1.3;
1100  }
1101  .sr-disclaimer-wrap { margin-top: 14pt; }
1102  .sr-disclaimer-card {
1103    position: relative;
1104    border: var(--sr-line) solid var(--sr-border);
1105    border-radius: var(--sr-card-radius);
1106    background: var(--sr-surface);
1107    padding: 14pt;
1108    display: flex;
1109    gap: 10pt;
1110    align-items: stretch;
1111  }
1112  .sr-disclaimer-bar {
1113    flex: 0 0 4pt;
1114    background: var(--sr-warning);
1115    border-radius: 1pt;
1116    margin-top: 4pt;
1117    margin-bottom: 4pt;
1118  }
1119  .sr-disclaimer-amber {
1120    flex: 1;
1121    min-width: 0;
1122    background: var(--sr-disclaimer-tint);
1123    border: 0.35pt solid var(--sr-warning);
1124    border-radius: 6pt;
1125    padding: 10pt 12pt 12pt;
1126  }
1127  .sr-disclaimer-important { font-weight: 700; font-size: calc(9pt * var(--sr-fs-mul)); color: var(--sr-heading); margin-bottom: 8pt; }
1128  .sr-disclaimer-body {
1129    margin: 0 0 10pt;
1130    font-size: calc(8pt * var(--sr-fs-mul));
1131    line-height: 1.2;
1132    color: var(--sr-muted);
1133  }
1134  .sr-disclaimer-legal-label { font-size: calc(7.5pt * var(--sr-fs-mul)); color: var(--sr-muted); margin-bottom: 6pt; }
1135  .sr-link { display: inline-block; font-size: calc(8pt * var(--sr-fs-mul)); color: var(--sr-accent); margin-right: 12pt; text-decoration: underline; }
1136  .sr-questions-card {
1137    margin-top: 12pt;
1138    border: var(--sr-line) solid var(--sr-border);
1139    border-radius: var(--sr-card-radius);
1140    background: var(--sr-surface-alt);
1141    padding: 10pt 12pt 12pt;
1142  }
1143  .sr-questions-title { font-weight: 700; font-size: calc(9pt * var(--sr-fs-mul)); color: var(--sr-heading); margin-bottom: 6pt; }
1144  .sr-questions-lead { margin: 0 0 6pt; font-size: calc(8pt * var(--sr-fs-mul)); color: var(--sr-muted); }
1145  .sr-questions-url { font-size: calc(8.5pt * var(--sr-fs-mul)); color: var(--sr-accent); text-decoration: underline; word-break: break-all; }
1146</style>
1147</head>
1148<body>
1149  <header class="sr-header">
1150    <div class="sr-header-main">
1151      <div class="sr-header-left">
1152        ${Z}
1153        ${le}
1154      </div>
1155      <div class="sr-trust-col">
1156        <div class="sr-trust-row">
1157          <a class="sr-badge sr-badge--tp" href="${Je(wy)}" target="_blank" rel="noopener noreferrer">
1158            <span class="sr-badge-title">Trustpilot</span>
1159            <span class="sr-badge-sub">4.9 · Reviews</span>
1160          </a>
1161          <a class="sr-badge sr-badge--bbb" href="${Je(Ny)}" target="_blank" rel="noopener noreferrer">
1162            <span class="sr-badge-title">BBB</span>
1163            <span class="sr-badge-sub">Accredited Business</span>
1164          </a>
1165        </div>
1166        <div class="sr-prepared">
1167          <div class="sr-prepared-label">PREPARED</div>
1168          <div class="sr-prepared-date">${fe}</div>
1169        </div>
1170      </div>
1171    </div>
1172    <p class="sr-header-sub">Accelerated Strategies Summary - Not A Commitment &amp; Not a Loan or Credit Application</p>
1173  </header>
1174  <div class="sr-content">
1175  <p class="intro">${Je(jy)}</p>
1176  <div class="grid2">
1177    ${Tf("Client Information",w)}
1178    ${Tf("Property Information",mb(m??void 0))}
1179  </div>
1180  ${E}
1181  ${_}
1182  <div class="grid2">
1183    ${B}
1184    ${N}
1185  </div>
1186  ${L}
1187  ${k}
1188  ${te}
1189  ${be}
1190  ${Ne}
1191  ${A}
1192  ${ue}
1193  ${_e}
1194  </div>
1195</body>
1196</html>`}const Dd="/api/strategy-report-pdf",gb=8787;function Rf(e){const t=e.trim();return t&&(t.endsWith("/")?t:`${t}/`)}function rd(){try{const e=typeof(hs==null?void 0:hs.VITE_STRATEGY_REPORT_PDF_RENDERER_URL)=="string"?(void 0).trim():"";if(e.length>0)return Rf(e);const t=(hs==null?void 0:hs.VITE_STRATEGY_REPORT_PDF_RENDERER_SKIP_DEV_AUTO)==="1"||(hs==null?void 0:hs.VITE_STRATEGY_REPORT_PDF_RENDERER_SKIP_DEV_AUTO)==="true";return typeof window>"u"?void 0:Rf(new URL(Dd,window.location.origin).href)}catch{return}}async function ad(e,t,n){const r=(n==null?void 0:n.timeoutMs)??3e4,s=new AbortController,i=setTimeout(()=>s.abort(),r);try{const c=await fetch(t,{method:"POST",headers:{"Content-Type":"text/html;charset=utf-8",Accept:"application/pdf",...n==null?void 0:n.headers},body:e,signal:s.signal});if(!c.ok){const h=(await c.text().catch(()=>"")).trim();throw c.status===500&&h.includes('"Server misconfigured"')?new Error("PDF route is missing server secrets on Vercel for this deployment. Add SUPABASE_SERVICE_ROLE_KEY (Preview + Production). Usually also set SUPABASE_URL and SUPABASE_ANON_KEY to match your Supabase project, or rely on VITE_SUPABASE_URL / VITE_SUPABASE_PUBLISHABLE_KEY if exposed to Functions. See docs/integrations/vercel.md (Strategy Summary PDF)."):new Error(h||`PDF renderer failed (${c.status})`)}if(!(c.headers.get("content-type")??"").includes("pdf"))throw new Error("PDF renderer did not return application/pdf");return await c.blob()}finally{clearTimeout(i)}}const xb="/assets/accelerated-strategies-logo-DTdTl65o.png",Sl=12e4;async function sd(){var r;const{data:e}=await nt.auth.getSession(),t=(r=e.session)==null?void 0:r.access_token,n={};return t&&(n.Authorization=`Bearer ${t}`),n}function yb({open:e,onOpenChange:t,lead:n,scenarioName:r,assessment:s,properties:i,debts:c,expenses:l,metrics:d,cashflow:h,additionalClients:f,calculatorPayoffComparison:x,aiAnalysis:b,helocTermsRows:m,suggestedLenders:w}){var ye,Ee;const{toast:v}=Ir(),[P,_]=J.useState(""),[q,T]=J.useState(!1),[B,Q]=J.useState(!1),[me,ce]=J.useState(!1),[$,D]=J.useState(null),[Y,N]=J.useState(null),[I,k]=J.useState(null),[L,H]=J.useState(!1),[te,se]=J.useState(null),[K,ae]=J.useState(null),[be,Ne]=J.useState(0),[A,E]=J.useState(!0),[z,X]=J.useState(!0),Z=J.useRef(null),le=((w==null?void 0:w.length)??0)>0;J.useEffect(()=>{e&&(n!=null&&n.email)&&_(n.email),e&&!(n!=null&&n.email)&&_("")},[e,n==null?void 0:n.email]),J.useEffect(()=>{e||T(!1)},[e]),J.useEffect(()=>{e&&(E(!0),X(!0))},[e,n==null?void 0:n.id,r]);const fe=J.useCallback(async()=>{if(!n)throw new Error("No lead");const de=await Hy(xb),Ue=de?await Uy(de):null;return{lead:n,scenarioName:r,assessment:s,properties:i,debts:c,expenses:l,metrics:d,cashflow:h,additionalClients:f,calculatorPayoffComparison:x??null,aiAnalysis:b??null,helocTermsRows:m??null,suggestedLenders:w??[],sectionOptions:{includeAiSummary:A,includeSuggestedLenders:z},logoDataUrl:Ue}},[n,r,s,i,c,l,d,h,f,x,b,m,w,A,z]),ue=J.useMemo(()=>{var de,Ue,qe,$e;if(!e||!n)return"";try{return JSON.stringify({lead:n,scenarioName:r,assessment:s,properties:i,debts:c,expenses:l,metrics:d,cashflow:h,additionalClients:f??[],calcSig:x?[x.baseline.totalMonths,x.accelerated.totalMonths,((de=x.accelerated.trackerData)==null?void 0:de.length)??0,((Ue=x.planMilestones)==null?void 0:Ue.length)??0].join(":"):null,aiSig:b?`${(qe=b.summary)==null?void 0:qe.slice(0,40)}:${(($e=b.narrative)==null?void 0:$e.length)??0}`:null,helocSig:m?JSON.stringify(m):null,suggestedLendersSig:w!=null&&w.length?w.map(Ge=>`${Ge.lenderName}:${Ge.programName}`).join("|"):null,showAiSummary:A,showSuggestedLenders:z})}catch{return`${n.id}:${r}`}},[e,n,r,s,i,c,l,d,h,f,x,b,m,w,A,z]),_e=J.useRef(fe);_e.current=fe,J.useEffect(()=>{var Ue,qe;if(!e||!n){(Ue=Z.current)==null||Ue.call(Z),Z.current=null,D(null),N(null),k(null),H(!1),se(null),ae(null);return}let de=!1;return(qe=Z.current)==null||qe.call(Z),Z.current=null,D(null),N(null),k(null),se(null),ae(null),H(!0),(async()=>{var bt;let $e=null;try{const et=await _e.current();if($e=pb(et),de)return;const Me=URL.createObjectURL(new Blob([$e],{type:"text/html;charset=utf-8"}));Z.current=()=>URL.revokeObjectURL(Me),D($e),N(Me),k(null),ae(null)}catch(et){de||((bt=Z.current)==null||bt.call(Z),Z.current=null,D(null),N(null),se(et instanceof Error?et.message:"Could not build preview"))}finally{de||H(!1)}if(de||!$e)return;const Ge=rd();if(Ge)try{const et=await sd(),Me=await ad($e,Ge,{timeoutMs:Sl,headers:et});de||(k(Me),ae(null))}catch(et){if(!de){k(null);const Me=Sl/1e3,St=et instanceof DOMException&&et.name==="AbortError"||et instanceof Error&&et.name==="AbortError"?`PDF service did not respond within ${Me}s. On Vercel, confirm /api/strategy-report-pdf deploy and logs. Locally run npm run strategy-report:pdf-server (port ${gb}).`:et instanceof Error?et.message:"PDF renderer failed";ae(St)}}})(),()=>{var $e;de=!0,($e=Z.current)==null||$e.call(Z),Z.current=null,D(null),N(null),k(null),ae(null)}},[e,n,ue,be]);const Ce=()=>{!e||!n||Ne(de=>de+1)},ve=async()=>
1196{if(!n||!$)return;if(K){v({title:"PDF unavailable",description:"Fix the PDF renderer issue before downloading, or use printable HTML in a new tab.",variant:"destructive"});return}const de=rd();if(!de){v({title:"PDF export disabled",description:`Sign in and ensure ${Dd} is reachable (Vercel deploy). Locally run npm run strategy-report:pdf-server.`,variant:"destructive"});return}ce(!0);try{const Ue=await sd();if(!Ue.Authorization){v({title:"Sign in required",description:"PDF export requires an authenticated admin session.",variant:"destructive"});return}const qe=I??await ad($,de,{timeoutMs:Sl,headers:Ue});k(qe),ae(null),zy(qe,`${n.first_name}_${n.last_name}`),v({title:"Report downloaded"})}catch(Ue){v({title:"Could not generate PDF",description:Ue instanceof Error?Ue.message:"Unknown error",variant:"destructive"})}finally{ce(!1)}},we=async()=>{if(!n)return;if(K){v({title:"PDF unavailable",description:"Fix the PDF renderer issue before sending email, or use printable HTML in a new tab.",variant:"destructive"});return}const de=P.trim().toLowerCase(),Ue=(n.email??"").trim().toLowerCase();if(!de||!Ue){v({title:"Missing email",description:"This lead has no email on file.",variant:"destructive"});return}if(de!==Ue){v({title:"Email must match lead",description:"For compliance, the report can only be sent to the lead's email on file.",variant:"destructive"});return}Q(!0);try{if(!$)throw new Error("Preview is not ready yet.");const qe=rd();if(!qe)throw new Error(`PDF export is not configured (${Dd} or override URL). Locally run npm run strategy-report:pdf-server.`);const $e=await sd();if(!$e.Authorization)throw new Error("Sign in required to generate PDF.");const Ge=I??await ad($,qe,{timeoutMs:Sl,headers:$e});k(Ge),ae(null);const bt=await $y(Ge),{data:et,error:Me}=await nt.functions.invoke("send-lead-strategy-report",{body:{leadId:n.id,pdfBase64:bt}}),vt=et&&typeof et=="object"&&typeof et.error=="string"&&et.error.trim()?et.error.trim():null;if(Me)throw new Error(vt??Me.message);if(vt)throw new Error(vt);v({title:"Report sent",description:`Delivered to ${n.email}`}),T(!1),t(!1)}catch(qe){v({title:"Send failed",description:qe instanceof Error?qe.message:"Unknown error",variant:"destructive"})}finally{Q(!1)}},De=!!($&&!L&&!te),R=!!((ye=n.email)!=null&&ye.trim())&&De&&!K,ze=De&&!K;return n?a.jsx(Jg,{open:e,onOpenChange:t,children:a.jsxs(Xg,{className:Et("!flex w-[min(96vw,1280px)] max-w-[min(96vw,1280px)] flex-col gap-0 overflow-hidden p-0 sm:rounded-lg","h-[min(92dvh,calc(100dvh-3rem))] max-h-[min(92dvh,calc(100dvh-3rem))]"),children:[a.jsxs(Zg,{className:"shrink-0 space-y-0 border-b border-border px-4 pb-3 pt-3 text-left sm:px-5 sm:pr-14",children:[a.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[a.jsxs("div",{className:"min-w-0 flex-1 pr-2",children:[a.jsx(e0,{className:"text-base sm:text-lg",children:"Generate Strategy Summary"}),a.jsxs(t0,{className:"mt-1 text-xs sm:text-sm",children:["Preview the full strategy summary for"," ",a.jsx("span",{className:"font-medium text-foreground",children:r}),". Check numbers and narrative here, then download a PDF copy for your records or send it to the lead by email when their address is on file."]})]}),a.jsxs("div",{className:"flex shrink-0 flex-wrap items-center justify-end gap-2 sm:flex-nowrap",children:[a.jsxs(st,{type:"button",variant:"outline",size:"icon",className:"h-9 w-9 shrink-0",title:"Refresh preview",disabled:L||!e,onClick:()=>Ce(),children:[a.jsx(mm,{className:Et("h-4 w-4",L&&"animate-spin")}),a.jsx("span",{className:"sr-only",children:"Refresh preview"})]}),a.jsxs(st,{type:"button",size:"sm",className:"h-9 gap-1.5 bg-success px-3 hover:bg-success/90",disabled:me||!ze,title:K?"PDF export is unavailable until the renderer issue is resolved":void 0,onClick:()=>void ve(),children:[me?a.jsx(Kr,{className:"h-4 w-4 animate-spin"}):a.jsx(n0,{className:"h-4 w-4"}),"Download"]}),a.jsxs($d,{open:q,onOpenChange:de=>{T(de),de&&(n!=null&&n.email)&&_(n.email)},children:[a.jsx(Hd,{asChild:!0,children:a.jsxs(st,{type:"button",variant:"outline",size:"sm",className:"h-9 gap-1.5 px-3",disabled:!R,title:K?"PDF export is unavailable until the renderer issue is resolved":(Ee=n.email)!=null&&Ee.trim()?De?void 0:"Wait for preview":"Lead has no email on file",children:[a.jsx(Uu,{className:"h-4 w-4"}),"Email"]})}),a.jsx(Ud,{className:"w-80",align:"end",side:"bottom",sideOffset:8,children:a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{className:"space-y-1.5",children:[a.jsx("p",{className:"text-sm font-medium",children:"Send to lead"}),a.jsx("p",{className:"text-xs text-muted-foreground",children:"Delivery is restricted to the email on file. You can download the PDF and share it yourself if needed."})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(Ke,{htmlFor:"report-email-popover",children:"Lead email"}),a.jsx(Wt,{id:"report-email-popover",type:"email",autoComplete:"email",value:P,onChange:de=>_(de.target.value),placeholder:n.email||"No email on file"})]}),a.jsxs(st,{type:"button",className:"w-full gap-2 bg-success hover:bg-success/90",disabled:B||!R,onClick:()=>void we(),children:[B?a.jsx(Kr,{className:"h-4 w-4 animate-spin"}):a.jsx(Uu,{className:"h-4 w-4"}),"Send email"]})]})})]})]})]}),a.jsxs("div",{className:"flex flex-wrap items-center gap-x-6 gap-y-2 border-t border-border/60 pt-3",role:"group","aria-label":"Report sections",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Ga,{id:"strategy-report-show-ai",checked:A,onCheckedChange:E}),a.jsx(Ke,{htmlFor:"strategy-report-show-ai",className:"cursor-pointer text-xs font-medium",children:"AI Summary"})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Ga,{id:"strategy-report-show-lenders",checked:z,onCheckedChange:X,disabled:!le}),a.jsxs(Ke,{htmlFor:"strategy-report-show-lenders",className:Et("text-xs font-medium",le?"curs
1196or-pointer":"cursor-not-allowed text-muted-foreground"),children:["Lender suggestion list",le?null:a.jsx("span",{className:"ml-1 font-normal text-muted-foreground",children:"(none selected)"})]})]})]})]}),a.jsx("div",{className:"relative flex min-h-0 flex-1 flex-col bg-muted/40",children:L?a.jsxs("div",{className:"flex min-h-[min(60vh,480px)] flex-1 flex-col items-center justify-center gap-3 text-muted-foreground",children:[a.jsx(Kr,{className:"h-10 w-10 animate-spin text-primary"}),a.jsx("p",{className:"text-sm",children:"Building preview…"})]}):te?a.jsxs("div",{className:"flex min-h-[min(60vh,480px)] flex-1 flex-col items-center justify-center gap-2 p-6 text-center text-sm text-destructive",children:[a.jsx("p",{className:"font-medium",children:"Could not load preview"}),a.jsx("p",{className:"text-muted-foreground",children:te})]}):$?a.jsxs("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:[K?a.jsxs(qs,{variant:"destructive",className:"mx-3 mt-3 shrink-0 rounded-md border text-sm sm:mx-4",children:[a.jsx(Io,{children:"PDF export unavailable"}),a.jsx(ps,{children:K}),a.jsxs(ps,{className:"mt-2 text-muted-foreground",children:["The HTML preview below is still accurate. The PDF renderer has a problem right now, so"," ",a.jsx("span",{className:"font-medium text-foreground",children:"Download"})," and"," ",a.jsx("span",{className:"font-medium text-foreground",children:"Send email"})," are turned off until PDFs work again. Use ",a.jsx("span",{className:"font-medium text-foreground",children:"Open printable HTML in new tab"})," to print or save from your browser."]})]}):null,a.jsx("iframe",{title:`Strategy Summary preview for ${n.first_name} ${n.last_name}`,srcDoc:$,sandbox:"allow-same-origin allow-popups allow-popups-to-escape-sandbox",className:"min-h-0 w-full flex-1 border-0 bg-background"}),a.jsx("div",{className:"flex shrink-0 items-center justify-center gap-2 border-t border-border bg-background px-3 py-2",children:Y?a.jsxs("a",{href:Y,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1.5 text-sm font-medium text-primary underline-offset-4 hover:underline",children:[a.jsx(im,{className:"h-3.5 w-3.5","aria-hidden":!0}),"Open printable HTML in new tab"]}):null})]}):a.jsx("div",{className:"flex min-h-[min(60vh,480px)] flex-1 items-center justify-center text-sm text-muted-foreground",children:"No preview available."})})]})}):null}const bb=["us_citizen","permanent_resident_alien","non_permanent_resident_alien"],id="__unset__",Bp=[{value:"us_citizen",label:"U.S. citizen"},{value:"permanent_resident_alien",label:"permanent resident alien"},{value:"non_permanent_resident_alien",label:"non-permanent resident alien"}];function Rs(e){return e!=null&&bb.includes(e)?e:null}function Qi(e,t){const n=Rs(e);return n??(t===!0?"us_citizen":null)}function Bf(e){var t;return e==null?"Not specified":((t=Bp.find(n=>n.value===e))==null?void 0:t.label)??e}function ui(e){return e?e.slice(0,10):""}function Of(e){return ui(e)||"—"}function Op(e){const t=e.trim();return/^\d{4}-\d{2}-\d{2}$/.test(t)?t:null}const vb=[{value:"spouse",label:"Spouse"},{value:"partner",label:"Partner"}],Po=()=>({relationship:"spouse",first_name:"",last_name:"",email:null,phone:null,fico_score:null,date_of_birth:null,citizenship_status:null,is_us_citizen:!1,is_military_veteran:!1});function qp({id:e,value:t,onChange:n}){return a.jsxs("div",{className:"min-w-[220px] flex-1",children:[a.jsx(Ke,{htmlFor:e,className:"text-xs",children:"Citizenship / residency *"}),a.jsxs(Ka,{value:t??id,onValueChange:r=>n(r===id?null:r),children:[a.jsx(Qa,{id:e,className:"mt-1 h-8 text-xs",children:a.jsx(Ja,{placeholder:"Select an option"})}),a.jsxs(Xa,{children:[a.jsx(Mr,{value:id,className:"text-muted-foreground",children:"Select an option"}),Bp.map(r=>a.jsx(Mr,{value:r.value,children:r.label},r.value))]})]})]})}const qf=({values:e,onChange:t})=>{const n=J.useId();return a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-4 md:grid-cols-4 md:gap-x-6",children:[a.jsxs("div",{children:[a.jsx(Ke,{className:"text-xs",children:"Relationship"}),a.jsxs(Ka,{value:e.relationship,onValueChange:r=>t({...e,relationship:r}),children:[a.jsx(Qa,{className:"h-8 text-xs",children:a.jsx(Ja,{})}),a.jsx(Xa,{children:vb.map(r=>a.jsx(Mr,{value:r.value,children:r.label},r.value))})]})]}),a.jsxs("div",{className:"min-w-0",children:[a.jsx(Ke,{className:"text-xs",children:"First Name *"}),a.jsx(Wt,{className:"h-8 text-sm",value:e.first_name,onChange:r=>t({...e,first_name:r.target.value})})]}),a.jsxs("div",{className:"min-w-0",children:[a.jsx(Ke,{className:"text-xs",children:"Last Name *"}),a.jsx(Wt,{className:"h-8 text-sm",value:e.last_name,onChange:r=>t({...e,last_name:r.target.value})})]}),a.jsxs("div",{className:"min-w-0",children:[a.jsx(Ke,{className:"text-xs",children:"Email"}),a.jsx(Wt,{className:"h-8 text-sm",type:"email",value:e.email??"",onChange:r=>t({...e,email:r.target.value})})]}),a.jsxs("div",{className:"min-w-0",children:[a.jsx(Ke,{className:"text-xs",children:"Phone"}),a.jsx(Wt,{className:"h-8 text-sm",type:"tel",value:e.phone??"",onChange:r=>t({...e,phone:r.target.value})})]}),a.jsxs("div",{className:"min-w-0",children:[a.jsx(Ke,{className:"text-xs",children:"Credit Score"}),a.jsx(Wt,{className:"h-8 text-sm",type:"number",value:e.fico_score??"",onChange:r=>t({...e,fico_score:r.target.value?Number(r.target.value):null}),placeholder:"---"})]}),a.jsxs("div",{className:"min-w-0",children:[a.jsx(Ke,{className:"text-xs",children:"Date of birth"}),a.jsx(Wt,{className:"h-8 text-sm",type:"date",value:ui(e.date_of_birth),onChange:r=>t({...e,date_of_birth:Op(r.target.value)})})]})]}),a.jsxs("div",{className:"flex flex-wrap items-end gap-x-8 gap-y-4 border-t border-border/60 pt-4",children:[a.jsx(qp,{id:`${n}-cit`,value:Rs(e.citizenship_status),onChange:r=>t({...e,citizenship_status:r,is_us_citizen:r==="us_citizen"})}),a.jsxs("div",{className:"flex items-center gap-2 pb-0.5",children:[a.jsx(lo,{id:`${n}-mil`,checked:e.is_military_veteran,onCheckedChange:r=>t({...e,is_military_veteran:r===!0})}),a.jsx(Ke,{htmlFor:`${n}-mil`,className:"cursor-pointer text-xs font-normal",children:"Military/Veteran?"})]})]})]})},_b=({lead:e,scenarioId:t,ficoScore:n,citizenshipStatus:r,legacyIsUsCitizen:s,isMilitaryVeteran:i,hecmOpportunity:c=null,hecmPropertyId:l=null,onLeadUpdated:d,readOnly:h=!1,highlights:f,previewAdditionalClients:x=null})=>{const b=J.useId(),[m,w]=J.useState([]),[v,P]=J.useState(!1),[_,q]=J.useState(Po()),[T,B]=J.useState(null),[Q,me]=J.useState(Po()),[ce,$]=J.useState(!1),[D,Y]=J.useState(!1),[N,I]=J.useState({first_name:e.first_name,last_name:e.last_name,email:e.email,phone:e.phone||"",fico_score:n,date_of_birth:ui(e.date_of_birth)||null,citizenship_status:Qi(r,s),is_military_veteran:i}),k=ys(),{toast:L}=Ir(),H=J.useCallback(async()=>
1196{if(!e.id||x)return;const{data:E}=await nt.from("lead_additional_clients").select("*").eq("lead_id",e.id).order("created_at",{ascending:!0});E&&w(E)},[e.id,x]);J.useEffect(()=>{H()},[H]),J.useEffect(()=>{D||I({first_name:e.first_name,last_name:e.last_name,email:e.email,phone:e.phone||"",fico_score:n,date_of_birth:ui(e.date_of_birth)||null,citizenship_status:Qi(r,s),is_military_veteran:i})},[e.first_name,e.last_name,e.email,e.phone,e.date_of_birth,n,r,s,i,D]);const te=()=>{I({first_name:e.first_name,last_name:e.last_name,email:e.email,phone:e.phone||"",fico_score:n,date_of_birth:ui(e.date_of_birth)||null,citizenship_status:Qi(r,s),is_military_veteran:i}),Y(!0)},se=async()=>{if(!N.first_name.trim()||!N.last_name.trim()||!N.email.trim()){L({title:"Name and email are required",variant:"destructive"});return}if(N.citizenship_status==null){L({title:"Citizenship / residency is required",variant:"destructive"});return}$(!0);try{const{error:E}=await nt.from("leads").update({first_name:N.first_name.trim(),last_name:N.last_name.trim(),email:N.email.trim(),phone:N.phone.trim()||null,date_of_birth:N.date_of_birth}).eq("id",e.id);if(E)throw E;const{error:z}=await nt.from("lead_financial_assessment").upsert({lead_id:e.id,scenario_id:t,fico_score:N.fico_score,citizenship_status:N.citizenship_status,is_us_citizen:N.citizenship_status==="us_citizen",is_military_veteran:N.is_military_veteran},{onConflict:"scenario_id"});if(z)throw z;k.invalidateQueries({queryKey:["leads"]}),k.invalidateQueries({queryKey:["lead-assessment",e.id,t]}),d==null||d(),Y(!1),L({title:"Primary client updated"})}catch(E){L({title:"Failed to update",description:E.message,variant:"destructive"})}finally{$(!1)}},K=async()=>{var E,z;if(!_.first_name.trim()||!_.last_name.trim()){L({title:"First and last name are required",variant:"destructive"});return}if(Rs(_.citizenship_status)==null){L({title:"Citizenship / residency is required",variant:"destructive"});return}$(!0);try{const{error:X}=await nt.from("lead_additional_clients").insert({lead_id:e.id,relationship:_.relationship,first_name:_.first_name.trim(),last_name:_.last_name.trim(),email:((E=_.email)==null?void 0:E.trim())||null,phone:((z=_.phone)==null?void 0:z.trim())||null,fico_score:_.fico_score||null,date_of_birth:_.date_of_birth,citizenship_status:Rs(_.citizenship_status),is_us_citizen:Rs(_.citizenship_status)==="us_citizen",is_military_veteran:_.is_military_veteran});if(X)throw X;P(!1),q(Po()),await k.invalidateQueries({queryKey:["lead-additional-clients",e.id]}),H(),L({title:"Additional client added"})}catch(X){L({title:"Failed to add client",description:X.message,variant:"destructive"})}finally{$(!1)}},ae=async E=>{var z,X;if(!Q.first_name.trim()||!Q.last_name.trim()){L({title:"First and last name are required",variant:"destructive"});return}if(Rs(Q.citizenship_status)==null){L({title:"Citizenship / residency is required",variant:"destructive"});return}$(!0);try{const{error:Z}=await nt.from("lead_additional_clients").update({relationship:Q.relationship,first_name:Q.first_name.trim(),last_name:Q.last_name.trim(),email:((z=Q.email)==null?void 0:z.trim())||null,phone:((X=Q.phone)==null?void 0:X.trim())||null,fico_score:Q.fico_score||null,date_of_birth:Q.date_of_birth,citizenship_status:Rs(Q.citizenship_status),is_us_citizen:Rs(Q.citizenship_status)==="us_citizen",is_military_veteran:Q.is_military_veteran}).eq("id",E);if(Z)throw Z;B(null),await k.invalidateQueries({queryKey:["lead-additional-clients",e.id]}),H(),L({title:"Client updated"})}catch(Z){L({title:"Failed to update",description:Z.message,variant:"destructive"})}finally{$(!1)}},be=async E=>{const{error:z}=await nt.from("lead_additional_clients").delete().eq("id",E);if(z){L({title:"Failed to delete",description:z.message,variant:"destructive"});return}await k.invalidateQueries({queryKey:["lead-additional-clients",e.id]}),H(),L({title:"Client removed"})};Ws("client-primary",D,se,()=>Y(!1)),Ws(T?`client-${T}`:"client-additional",!!T,()=>T?ae(T):Promise.resolve(),()=>B(null)),Ws("client-new",v,K,()=>{P(!1),q(Po())});const Ne=x??m,A=E=>{B(E.id),me({relationship:E.relationship,first_name:E.first_name,last_name:E.last_name,email:E.email,phone:E.phone,fico_score:E.fico_score,date_of_birth:ui(E.date_of_birth)||null,citizenship_status:Qi(E.citizenship_status,E.is_us_citizen),is_us_citizen:E.is_us_citizen??!1,is_military_veteran:E.is_military_veteran??!1})};return a.jsxs("section",{children:[a.jsxs("h2",{className:"mb-3 flex items-center gap-2 text-xl font-semibold tracking-tight text-foreground",children:[a.jsx(r0,{className:"w-5 h-5 text-primary"}),"Client Information",!v&&!h&&a.jsxs(st,{variant:"outline",size:"sm",className:"h-7 text-xs ml-auto",onClick:()=>P(!0),children:[a.jsx(_m,{className:"w-3 h-3 mr-1"})," Add Client"]})]}),a.jsxs("div",{className:"space-y-3",children:[a.jsx(rn,{className:"rounded-2xl border-border/70 shadow-sm",children:a.jsx(on,{className:"p-4",children:D?a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[a.jsx(xn,{variant:"secondary",className:"text-xs",children:"Primary"}),c?a.jsx(bd,{result:c,leadId:e.id,scenarioId:t,propertyId:l}):null]}),a.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-4 md:grid-cols-4 md:gap-x-6",children:[a.jsxs("div",{className:"min-w-0",children:[a.jsx(Ke,{className:"text-xs",children:"First Name *"}),a.jsx(Wt,{className:"h-8 text-sm",value:N.first_name,onChange:E=>I(z=>({...z,first_name:E.target.value}))})]}),a.jsxs("div",{className:"min-w-0",children:[a.jsx(Ke,{className:"text-xs",children:"Last Name *"}),a.jsx(Wt,{className:"h-8 text-sm",value:N.last_name,onChange:E=>I(z=>({...z,last_name:E.target.value}))})]}),a.jsxs("div",{className:"min-w-0",children:[a.jsx(Ke,{className:"text-xs",children:"Email *"}),a.jsx(Wt,{className:"h-8 text-sm",type:"email",value:N.email,onChange:E=>I(z=>({...z,email:E.target.value}))})]}),a.jsxs("div",{className:"min-w-0",children:[a.jsx(Ke,{className:"text-xs",children:"Phone"}),a.jsx(Wt,{className:"h-8 text-sm",type:"tel",value:N.phone,onChange:E=>I(z=>({...z,phone:E.target.value}))})]}),a.jsxs("div",{className:"min-w-0",children:[a.jsx(Ke,{className:"text-xs",children:"Credit Score"}),a.jsx(Wt,{className:"h-8 text-sm",type:"number",value:N.fico_score??"",onChange:E=>I(z=>({...z,fico_score:E.target.value?Number(E.target.value):null})),placeholder:"---"})]}),a.jsxs("div",{className:"min-w-0",children:[a.jsx(Ke,{className:"text-xs",children:"Date of birth"}),a.jsx(Wt,{className:"h-8 text-sm",type:"date",value:ui(N.date_of_birth),onChange:E=>I(z=>({...z,date_of_birth:Op(E.target.value)}))})]})]}),a.jsxs("div",{className:"flex flex-wrap items-end gap-x-8 gap-y-4 border-t border-border/60 pt-4",children:[a.jsx(qp,{id:`${b}-cit`,value:N.citizenship_status,onChange:E=>I(z=>({...z,citizenship_status:E}))}),a.jsxs("div",{className:"flex items-center gap-2 pb-0.5",children:[a.jsx(lo,{id:`${b}-mil`,checked:N.is_military_veteran,onCheckedChange:E=>I(z=>({...z,is_military_veteran:E===!0}))}),a.jsx(Ke,{htmlFor:`${b}-mil`,className:"cursor-pointer text-xs font-normal",children:"Military/Veteran?"})]})]}),a.jsxs("div",{className:"flex gap-1",children:[a.jsxs(st,{size:"sm",className:"h-7 text-xs",onClick:se,disabled:ce,children:[a.jsx(Us,{className:"w-3 h-3 mr-1"})," Save"]}),a.jsxs(st,{size:"sm",variant:"ghost",className:"h-7 text-xs",onClick:()=>Y(!1),children:[a.jsx(Vs,{className:"w-3 h-3 mr-1"})," Cancel"]})]})]}):a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a.jsx(xn,{variant:"secondary",className:"text-xs",children:"Primary"}),c?a.jsx(bd,{result:c,leadId:e.id,scenarioId:t,propertyId:l}):null]}),!h&&a.jsx(st,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:te,children:a.jsx(gi,{className:"w-3 h-3 text-muted-foreground"})})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-6 text-sm md:grid-cols-4 md:gap-x-6",children:[a.jsxs("div",{className:"min-w-0",children:[a.jsx("p",{className:"text-xs text-muted-foreground",children:"Name"}),a.jsx(Kt,{path:"lead_contact.first_name",highlights:f,children:a.jsxs("p",{className:"mt-1 font-semibold leading-snug",children:[e.first_name," ",e.last_name]})})]}),a.jsxs("div",{className:"min-w-0",children:[a.jsx("p",{className:"text-xs text-muted-foreground",children:"Email"}),a.jsx(Kt,{path:"lead_contact.email",highlights:f,children:a.jsx("p",{className:"mt-1 break-words font-semibold leading-snug",children:e.email})})]}),a.jsxs("div",{className:"min-w-0",children:[a.jsx("p",{className:"text-xs text-muted-foreground",children:"Phone"}),a.jsx(Kt,{path:"lead_contact.phone",highlights:f,children:a.jsx("p",{className:"mt-1 font-semibold leading-snug",children:e.phone||"—"})})]}),a.jsxs("div",{className:"min-w-0",children:[a.jsx("p",{className:"text-xs text-muted-foreground",children:"Credit Score"}),a.jsx(Kt,{path:"assessment.fico_score",highlights:f,children:a.jsx("p",{className:Et("mt-1 font-semibold leading-snug",n&&n>=700?"text-success":n&&n<620?"text-destructive":""),children:n??"—"})})]}),a.jsxs("div",{className:"min-w-0",children:[a.jsx("p",{className:"text-xs text-muted-foreground",children:"Date of birth"}),a.jsx("p",{className:"mt-1 font-semibold leading-snug",children:Of(e.date_of_birth)})]}),a.jsxs("div",{className:"min-w-0 md:col-span-2",children:[a.jsx("p",{className:"text-xs text-muted-foreground",children:"Citizenship / residency"}),a.jsx(Kt,{path:"assessment.citizenship_status",highlights:f,children:a.jsx("p",{className:"mt-1 font-semibold leading-snug",children:Bf(Qi(r,s))})})]}),a.jsxs("div",{className:"min-w-0",children:[a.jsx("p",{className:"text-xs text-muted-foreground",children:"Military/Veteran?"}),a.jsx(Kt,{path:"assessment.is_military_veteran",highlights:f,children:a.jsx("p",{className:"mt-1 font-semibold leading-snug",children:i?"Yes":"No"})})]})]})]})})}),Ne.map(E=>
1196a.jsx(rn,{className:"rounded-2xl border-border/70 shadow-sm",children:a.jsx(on,{className:"p-4",children:T===E.id?a.jsxs("div",{className:"space-y-3",children:[a.jsx(qf,{values:Q,onChange:me}),a.jsxs("div",{className:"flex gap-1",children:[a.jsxs(st,{size:"sm",className:"h-7 text-xs",onClick:()=>ae(E.id),disabled:ce,children:[a.jsx(Us,{className:"w-3 h-3 mr-1"})," Save"]}),a.jsxs(st,{size:"sm",variant:"ghost",className:"h-7 text-xs",onClick:()=>B(null),children:[a.jsx(Vs,{className:"w-3 h-3 mr-1"})," Cancel"]})]})]}):a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsx("div",{className:"flex items-center gap-2",children:a.jsx(xn,{variant:"outline",className:"text-xs capitalize",children:String(E.relationship??"other").replace(/_/g," ")})}),a.jsx("div",{className:"flex gap-1",children:!h&&a.jsxs(a.Fragment,{children:[a.jsx(st,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>A(E),children:a.jsx(gi,{className:"w-3 h-3 text-muted-foreground"})}),a.jsx(st,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>be(E.id),children:a.jsx(nc,{className:"w-3 h-3 text-destructive"})})]})})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-6 text-sm md:grid-cols-4 md:gap-x-6",children:[a.jsxs("div",{className:"min-w-0",children:[a.jsx("p",{className:"text-xs text-muted-foreground",children:"Name"}),a.jsx(Kt,{path:`additional_clients[${E.id}].first_name`,highlights:f,children:a.jsxs("p",{className:"mt-1 font-semibold leading-snug",children:[E.first_name," ",E.last_name]})})]}),a.jsxs("div",{className:"min-w-0",children:[a.jsx("p",{className:"text-xs text-muted-foreground",children:"Email"}),a.jsx(Kt,{path:`additional_clients[${E.id}].email`,highlights:f,children:a.jsx("p",{className:"mt-1 break-words font-semibold leading-snug",children:E.email||"—"})})]}),a.jsxs("div",{className:"min-w-0",children:[a.jsx("p",{className:"text-xs text-muted-foreground",children:"Phone"}),a.jsx(Kt,{path:`additional_clients[${E.id}].phone`,highlights:f,children:a.jsx("p",{className:"mt-1 font-semibold leading-snug",children:E.phone||"—"})})]}),a.jsxs("div",{className:"min-w-0",children:[a.jsx("p",{className:"text-xs text-muted-foreground",children:"Credit Score"}),a.jsx("p",{className:Et("mt-1 font-semibold leading-snug",E.fico_score&&E.fico_score>=700?"text-success":E.fico_score&&E.fico_score<620?"text-destructive":""),children:E.fico_score??"—"})]}),a.jsxs("div",{className:"min-w-0",children:[a.jsx("p",{className:"text-xs text-muted-foreground",children:"Date of birth"}),a.jsx("p",{className:"mt-1 font-semibold leading-snug",children:Of(E.date_of_birth)})]}),a.jsxs("div",{className:"min-w-0 md:col-span-2",children:[a.jsx("p",{className:"text-xs text-muted-foreground",children:"Citizenship / residency"}),a.jsx("p",{className:"mt-1 font-semibold leading-snug",children:Bf(Qi(E.citizenship_status,E.is_us_citizen))})]}),a.jsxs("div",{className:"min-w-0",children:[a.jsx("p",{className:"text-xs text-muted-foreground",children:"Military/Veteran?"}),a.jsx("p",{className:"mt-1 font-semibold leading-snug",children:E.is_military_veteran??!1?"Yes":"No"})]})]})]})})},E.id)),v&&!h&&a.jsx(rn,{className:"rounded-2xl border-dashed border-primary/40 bg-primary/5 shadow-sm",children:a.jsxs(on,{className:"space-y-3 p-4",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[a.jsx(rc,{className:"w-4 h-4 text-primary"}),a.jsx("span",{className:"text-sm font-semibold",children:"New Additional Client"})]}),a.jsx(qf,{values:_,onChange:q}),a.jsxs("div",{className:"flex gap-1",children:[a.jsxs(st,{size:"sm",className:"h-7 text-xs",onClick:K,disabled:ce,children:[a.jsx(Us,{className:"w-3 h-3 mr-1"})," Add"]}),a.jsxs(st,{size:"sm",variant:"ghost",className:"h-7 text-xs",onClick:()=>{P(!1),q(Po())},children:[a.jsx(Vs,{className:"w-3 h-3 mr-1"})," Cancel"]})]})]})})]})]})},zp=["late_mortgage_payments_12m","loan_modifications_12m","bankruptcy_4y","foreclosure_short_sale_7y","outstanding_judgments","property_llc_irrevocable_trust","listed_for_sale_6m"],wb=[{id:"late_mortgage_payments_12m",label:"Any late mortgage payments in the last 12 months?",yesDetail:"Disqualified for HELOC if Yes"},{id:"loan_modifications_12m",label:"Any loan modifications in the last 12 months?",yesDetail:"Needs at least 12 on-time payments with loan mod"},{id:"bankruptcy_4y",label:"Have you declared bankruptcy within the past 4 years?",yesDetail:"Needs 4 years seasoning period"},{id:"foreclosure_short_sale_7y",label:"Have you had property foreclosed upon or short sale in the last 7 years?",yesDetail:"Needs 7 years seasoning period"},{id:"outstanding_judgments",label:"Are there any outstanding judgments against you?",yesDetail:"Need to be settled or paid off at closing"},{id:"property_llc_irrevocable_trust",label:"Is the property we are planning to pay off in an irrevocable trust or an LLC?",yesDetail:"Unable to do HELOC in LLC or irrevocable trust"},{id:"listed_for_sale_6m",label:"Has the property been listed for sale in the last six months?",yesDetail:"Needs 6 month seasoning period if listed for sale"}];function Nb(e){if(e===!0||e==="true"||e===1||e==="1")return!0;
1196if(e===!1||e==="false"||e===0||e==="0")return!1}function Rd(e){if(!e||typeof e!="object"||Array.isArray(e))return{};const t={};for(const n of zp){const r=Nb(e[n]);r===!0?t[n]=!0:r===!1&&(t[n]=!1)}return t}function $p(e){return zp.some(t=>e[t]===!0)}function jb(e,t){return t in e?e[t]?"yes":"no":"unset"}function Sb(e){if(e instanceof Error&&e.message.trim())return e.message.trim();if(e&&typeof e=="object"&&"message"in e){const t=e.message;if(typeof t=="string"&&t.trim())return t.trim()}return"Could not save to the database."}const Lb=({rawBreakers:e,scenarioSyncKey:t,disabled:n,isSaving:r,onPatch:s,highlights:i})=>{const{toast:c}=Ir(),[l,d]=J.useState(()=>Rd(e)),h=J.useRef(t);J.useEffect(()=>{const w=Rd(e);if(h.current!==t){h.current=t,d(w);return}r||d(w)},[e,t,r]);const f=J.useMemo(()=>$p(l),[l]),[x,b]=J.useState(!1),m=async(w,v)=>{const P={...l};v==="unset"?delete P[w]:P[w]=v==="yes";const _=l;d(P);try{await s(P)}catch(q){d(_),c({title:"Financial deal breakers could not be saved",description:Sb(q),variant:"destructive"})}};return a.jsx("section",{"aria-label":"Financial deal breakers",children:a.jsx(_i,{open:x,onOpenChange:b,className:"group",children:a.jsxs(rn,{className:Et("overflow-hidden rounded-2xl border-border/70 shadow-sm",f&&"border-destructive/40 bg-destructive/[0.03]"),children:[a.jsx(wi,{asChild:!0,children:a.jsxs("button",{type:"button",disabled:n,className:Et("flex w-full items-start gap-3 p-4 text-left outline-none transition-colors","hover:bg-muted/50 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",n&&"cursor-not-allowed opacity-60"),children:[a.jsxs("span",{className:"sr-only",children:[x?"Collapse":"Expand"," financial deal breakers questionnaire"]}),a.jsx(Ys,{className:Et("mt-0.5 h-5 w-5 shrink-0 text-muted-foreground transition-transform duration-200",x&&"rotate-180"),"aria-hidden":!0}),a.jsxs("div",{className:"min-w-0 flex-1 space-y-1.5",children:[a.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a.jsx(pm,{className:Et("h-5 w-5 shrink-0",f?"text-destructive":"text-amber-600")}),a.jsx("span",{id:"financial-deal-breakers-heading",className:"text-xl font-semibold tracking-tight text-foreground",children:"Financial Deal Breakers"}),f&&a.jsx("span",{className:"rounded-full bg-destructive/15 px-2 py-0.5 text-[11px] font-semibold uppercase tracking-wide text-destructive",children:"Yes on file"})]}),a.jsxs(Cl,{className:"text-left",children:["HELOC & credit qualification flags — expand to answer. Any ",a.jsx("span",{className:"font-medium text-foreground",children:"Yes"})," marks the prospect as ",a.jsx("span",{className:"font-medium text-foreground",children:"not eligible"})," for Accelerated Payoff in AI qualification until the issue is cleared (re-run analysis after updates)."]})]})]})}),a.jsx(Ni,{children:a.jsx(on,{className:"space-y-6 border-t border-border/60 px-4 pb-4 pt-4",children:wb.map(w=>{const v=jb(l,w.id),P=l[w.id]===!0;return a.jsxs("div",{className:"space-y-2 border-b border-border/60 pb-4 last:border-0 last:pb-0",children:[a.jsx(Kt,{path:`assessment.financial_deal_breakers.${w.id}`,highlights:i,children:a.jsx(Ke,{className:"text-sm font-medium leading-snug text-foreground",children:w.label})}),a.jsxs(gm,{name:w.id,value:v,onValueChange:_=>void m(w.id,_),disabled:n||r,className:"flex flex-wrap items-center gap-4",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(To,{value:"yes",id:`${w.id}-yes`}),a.jsx(Ke,{htmlFor:`${w.id}-yes`,className:"cursor-pointer text-sm font-normal",children:"Yes"})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(To,{value:"no",id:`${w.id}-no`}),a.jsx(Ke,{htmlFor:`${w.id}-no`,className:"cursor-pointer text-sm font-normal",children:"No"})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(To,{value:"unset",id:`${w.id}-unset`}),a.jsx(Ke,{htmlFor:`${w.id}-unset`,className:"cursor-pointer text-sm font-normal text-muted-foreground",children:"Not answered"})]})]}),P&&a.jsx("p",{className:"rounded-md border border-amber-200/80 bg-amber-50 px-3 py-2 text-xs leading-snug text-amber-950 dar
1196k:border-amber-900/60 dark:bg-amber-950/35 dark:text-amber-50",children:w.yesDetail})]},w.id)})})})]})})})};function Ab(e,t){return t.hasConsolidation?t.displayedMonthlyCashflow:e.monthlyCashFlow}function kb(e,t){return t.hasConsolidation?t.assumedHelocDti!=null?t.assumedHelocDti:e.adjustedBackEndDti??e.backEndDti:e.backEndDti}function Cb(e,t){return t.hasConsolidation?t.assumedHelocDti!=null?t.assumedHelocDti:e.adjustedBackEndDti??e.qualifyingBackEndDti:e.qualifyingBackEndDti}function Pb(e,t){const n=t.dtiPassThreshold??50,r=Ab(e,t),s=kb(e,t),i=Cb(e,t),c=s!=null?s<=n:!1,l=i!=null?i<=n:!1,d=r>=0&&c&&l&&(s!=null?s<=n+5:!0);return{...e,adjustedMonthlyCashFlow:t.hasConsolidation?t.displayedMonthlyCashflow:e.adjustedMonthlyCashFlow,cashflowReliable:d,dtiWithinGuidelines:c,qualifyingDtiWithinGuidelines:l}}function Eb(e){return e.consolidatedBalance>0||e.consolidatedPayments>0?e.adjustedMonthlyCashFlow>=0:e.monthlyCashFlow>=0}const Hp=680,Mb=.7;function Up(e,t){var s,i;const n=((s=e.payoffComparison)==null?void 0:s.interestSavedDollars)??0,r=((i=e.payoffComparison)==null?void 0:i.timeSavedMonths)??0;return t==="viable"?!0:n>=1e3&&r>=12}function Vp(e){return e.some(t=>t.metCriteria===t.totalCriteria||t.totalCriteria>0&&t.score>=Mb)}function Ib(e,t){const n=t!=null&&t>=Hp,r=e.cashflowReliable===!0,s=e.dtiWithinGuidelines===!0&&e.qualifyingDtiWithinGuidelines===!0,i=e.stressTestPassed!==!1;return n&&r&&s&&i}function Fb(e,t,n,r){var i;const s=[];return Up(e,r)||((((i=e.payoffComparison)==null?void 0:i.interestSavedDollars)??0)<=0?s.push("Run or update the Lead Calculator to confirm projected interest and time savings"):s.push("Modeled savings are present but below the strong-savings threshold—validate chunk and surplus assumptions")),(n==null||n<Hp)&&s.push(n!=null?`FICO ${n} may limit HELOC approval—consider PLOC, HSF, or bridge timing`:"FICO not on file—confirm credit before HELOC-first enrollment"),Eb(e)?!e.dtiWithinGuidelines||!e.qualifyingDtiWithinGuidelines?s.push("DTI is near or above guidelines—HELOC qualification may require consolidation or alternative line structure"):e.stressTestPassed===!1&&s.push("Stress-tested DTI is elevated—confirm surplus under rate stress before HELOC-first chunking"):s.push("Monthly cash flow is tight after housing and debt obligations—PLOC, HSF, or bridge funding may be needed first"),Vp(t)||s.push("No strong lender product match yet—explore alternative lines (PLOC, savings-secured) or adjust consolidation"),s}function Tb(e){const t=Rd(e.dealBreakersRaw);if($p(t))return{tier:"not_eligible",acceleratedPayoffEligible:!1,conditionalReasons:["One or more financial deal breakers is answered Yes—Accelerated Payoff is not available until resolved"]};const n=Ib(e.metrics,e.ficoScore),r=Up(e.metrics,e.calculatorViability),s=Vp(e.lenderMatches);return n&&r&&s?{tier:"eligible",acceleratedPayoffEligible:!0,conditionalReasons:[]}:{tier:"conditional",acceleratedPayoffEligible:!0,conditionalReasons:Fb(e.metrics,e.lenderMatches,e.ficoScore,e.calculatorViability)}}function Db(e){switch(e){case"eligible":return{label:"Eligible",className:"bg-success/10 text-success border-success/20"};case"conditional":return{label:"Conditional",className:"bg-warning/10 text-warning border-warning/20"};case"not_eligible":return{label:"Not Eligible",className:"bg-destructive/10 text-destructive border-destructive/20"}}}function Rb(e,t){const[n,r]=J.useState(null),[s,i]=J.useState(!1),[c,l]=J.useState(!0);return J.useEffect(()=>{if(!e||!t){r(null),l(!1);return}let h=!1;return l(!0),r(null),(async()=>{try{const{data:f}=await nt.from("lead_ai_analysis").select("*").eq("scenario_id",t).maybeSingle();if(h)return;f&&r({accelerated_payoff_eligible:f.accelerated_payoff_eligible,confidence:f.confidence,summary:f.summary,confidence_rationale:f.confidence_rationale??"",strategy_enablers:f.strategy_enablers??[]})}catch(f){console.error("Failed to load saved analysis:",f)}finally{h||l(!1)}})(),()=>{h=!0}},[e,t]),{result:n,isLoading:s,isLoadingSaved:c,generateAnalysis:async h=>{var f;if(!e||!t){$i({title:"Select a scenario",description:"Choose an intake scenario before running AI analysis.",variant:"destructive"});return}i(!0),r(null);try{const{data:{session:x}}=await nt.auth.getSession();if(!x){$i({title:"Not authenticated",variant:"destructive"});return}const b=await nt.functions.invoke("analyze-lead-qualification",{body:{assessment:h.assessment,properties:h.properties,debts:h.debts,expenses:h.expenses,metrics:h.metrics,lenderMatches:h.lenderMatches,ficoScore:(f=h.assessment)==null?void 0:f.fico_score,calculatorViability:h.calculatorViability??null,leadId:e,scenarioId:t}});if(b.error)throw new Error(b.error.message||"Analysis failed");const m=b.data;if(m!=null&&m.error){m.error.includes("Rate limit")?$i({title:"Rate Limited",description:"Please wait a moment and try again.",variant:"destructive"}):m.error.includes("credits")?$i({title:"Credits Exhausted",description:"Please add AI credits to your workspace.",variant:"destructive"}):$i({title:"Analysis Error",description:m.error,variant:"destructive"});return}const w=m;r({...w,confidence_rationale:w.confidence_rationale??"",strategy_enablers:Array.isArray(w.strategy_enablers)?w.strategy_enablers:[]})}catch(x){console.error("AI analysis error:",x),$i({title:"Analysis Failed",description:x instanceof Error?x.message:"Could not generate analysis",variant:"destructive"})}finally{i(!1)}}}}function Bb(e){switch(e){case"eligible":return Wd;case"conditional":return pm;case"not_eligible":return Kl}}const Ob=({result:e,isLoading:t,onReanalyze:n,eligibilityTier:r})=>{const[s,i]=J.useState(!0);if(t)return a.jsx(rn,{className:"border-2",children:a.jsxs(on,{className:"space-y-4 py-6",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(Kr,{className:"h-5 w-5 animate-spin text-primary"}),a.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Analyzing qualification..."})]}),a.jsx(Ac,{className:"h-4 w-3/4"}),a.jsx(Ac,{className:"h-4 w-full"}),a.jsx(Ac,{className:"h-4 w-5/6"})]})});if(!e)return a.jsx(rn,{className:"border-2 border-dashed",children:a.jsxs(on,{className:"flex flex-col items-start gap-3 py-6 sm:flex-row sm:items-center sm:justify-between",children:[a.jsxs("div",{className:"space-y-1",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(kc,{className:"h-5 w-5 text-primary"}),a.jsx("h3",{className:"text-sm font-semibold text-foreground",children:"AI Qualification Analysis"})]}),a.jsx("p",{className:"text-sm text-muted-foreground",children:"Run AI analysis to generate eligibility summary and talking points for this scenario."})]}),a.jsxs(st,{onClick:n,className:"gap-1.5 shrink-0",children:[a.jsx(kc,{className:"h-4 w-4"}),"AI Analysis"]})]})});const c=Db(r),l=Bb(r);return a.jsx(_i,{open:s,onOpenChange:i,children:a.jsx(rn,{className:"border-2",children:a.jsxs(on,{className:"space-y-4 py-4",children:[a.jsxs("div",{className:"flex items-center justify-between gap-2",children:[a.jsxs(wi,{className:"flex items-center gap-3 transition-opacity hover:opacity-80",children:[a.jsx(Ys,{className:`h-4 w-4 text-muted-foreground transition-transform ${s?"rotate-180":""}`}),a.jsx(kc,{className:"h-5 w-5 text-primary"}),a.jsx("h3",{className:"text-sm font-semibold text-foreground",children:"AI Qualification Analysis"}),!s&&a.jsx(xn,{variant:"outline",className:`ml-1 px-2 py-0.5 text-xs ${c.className}`,children:c.label})]}),a.jsxs(st,{variant:"outline",size:"sm",onClick:d=>{d.stopPropagation(),n()},className:"gap-1.5 shrink-0 text-xs",children:[a.jsx(mm,{className:"h-3.5 w-3.5"}),"Re-analyze"]})]}),a.jsxs(Ni,{className:"space-y-4",children:[a.jsxs(xn,{variant:"outline",className:`gap-1.5 px-3 py-1 text-sm ${c.className}`,children:[a.jsx(l,{className:"h-4 w-4"}),c.label]}),a.jsx("p",{className:"text-sm leading-relaxed text-foreground",children:e.summary}),e.confidence_rationale.trim().length>0&&a.jsxs("div",{className:"space-y-2 rounded-md border border-border bg-muted/30 px-3 py-2.5",children:[a.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wide text-foreground",children:"Why this profile fits"}),a.jsx("p",{className:"text-sm leading-relaxed text-foreground",children:e.confidence_rationale}),a.jsx("p",{className:"text-xs text-muted-foreground",children:"Written for both the qualification specialist and the prospect—use as talking points, not a script."})]}),e.strategy_enablers.length>0&&a.jsxs("div",{className:"space-y-2",children:[a.jsxs("h4",{className:"flex items-center gap-1.5 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:[a.jsx(ac,{className:"h-3.5 w-3.5"}),"How the plan can work"]}),a.jsx("ul",{className:"space-y-1.5",children:e.strategy_enablers.map((d,h)=>a.jsxs("li",{className:"flex items-start gap-2 text-sm",children:[a.jsx(Wd,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-success"}),a.jsx("span",{className:"text-muted-foreground",children:d})]},h))})]})]})]})})})};function zf(e,t){var f,x,b,m;
1196const n=Math.max(0,Number(((f=t.primaryProperty)==null?void 0:f.outstanding_mortgage_balance)??0)),r=(x=t.primaryProperty)!=null&&x.id?`property_mortgage_${t.primaryProperty.id}`:null,s=r?(b=e.baseline.scheduleByDebt)==null?void 0:b.get(r):void 0,i=(s==null?void 0:s.reduce((w,v)=>w+v.interest,0))??0,c=((m=e.accelerated.trackerData.at(-1))==null?void 0:m.cumulativeLocInterest)??0,l=Math.max(0,t.firstLienOpeningLocBalance),d=t.helocTypeForScenario==="1st_lien"&&l>0&&n>0?Math.min(1,n/l):1,h=t.helocTypeForScenario==="1st_lien"?c*d:c;if(!(n<=0||i<=0))return{mortgageTipPct:i/n*100,helocTipPct:h/n*100,tipSavedPct:(i-h)/n*100}}function Eo(e){return Math.round(e*100)/100}function qb(e,{reserves:t,debtsToConsolidate:n,helocType:r,firstLienMortgageDebtId:s}){const i=Math.max(0,Number(t)||0);if(i<=0||n.length===0)return e.map(_=>({..._}));const c=s?String(s):null,l=n.filter(_=>{const q=String(_);return!(r==="1st_lien"&&c&&q===c)});if(l.length===0)return e.map(_=>({..._}));const d=new Set(l.map(String));let h=0;for(const _ of e)d.has(String(_.id))&&(h+=Math.max(0,Number(_.current_balance)||0));if(h<=0)return e.map(_=>({..._}));const f=Math.min(i,h),x=h-f,b=x/h,m=e.map(_=>{if(!d.has(String(_.id)))return{..._};const q=Math.max(0,Number(_.current_balance)||0),T=Eo(q*b),B=Math.max(0,Number(_.minimum_payment)||0),Q=_.monthly_payment!=null?Math.max(0,Number(_.monthly_payment)):B;return{..._,current_balance:T,original_amount:T,originial_loan_amount:T,minimum_payment:Eo(B*b),monthly_payment:_.monthly_payment!=null?Eo(Q*b):null}});let w=0;const v=[];for(let _=0;_<m.length;_++)d.has(String(m[_].id))&&(v.push(_),w+=Math.max(0,Number(m[_].current_balance)||0));const P=Eo(x-w);if(Math.abs(P)>=.01&&v.length>0){let _=v[0],q=Math.max(0,Number(m[_].current_balance)||0);for(const Q of v){const me=Math.max(0,Number(m[Q].current_balance)||0);me>q&&(q=me,_=Q)}const T=m[_],B=Math.max(0,Eo(Math.max(0,Number(T.current_balance)||0)+P));m[_]={...T,current_balance:B,original_amount:B,originial_loan_amount:B}}return m}const zb=[70,75,80,85,90,100];function $b(e){return e.firstLienDtiOtherLiabilitiesMonthly+e.primaryMonthlyEscrow+e.primaryMonthlyHoa}function Hb(e){return e.primaryMortgagePayment+e.totalMonthlyHoa+e.secondLienDtiOtherLiabilitiesMonthly}function Ub(e,t,n,r){const s=n.intakeHelocDtiQualifyingMonthlyIncome,i=n.primaryPropertyValue;if(s<=0||i<=0)return null;const c=i*(t/100);if(e==="1st_lien"){const f=Math.max(c,n.firstLienComputedBalance);if(n.firstLienAssumedDti!=null&&f===n.firstLienQualifyingBalance)return n.firstLienAssumedDti;const x=Yu(f,r);return($b(n)+x)/s*100}const l=Math.max(0,c-n.totalLienBalance),d=Yu(l,r);return n.secondLienAssumedDti!=null&&Math.abs(d-n.helocInterestOnlyPayment2nd)<.01?n.secondLienAssumedDti:(Hb(n)+d)/s*100}const Vb=({helocType:e,qualificationMetrics:t})=>{const{settings:n}=co(),r=Number(n.stress_test_rate)||8,s=Number(n.dti_pass_threshold)||50,i=Dt,c=f=>`${f.toFixed(1)}%`,{primaryPropertyValue:l,totalLienBalance:d}=t,h=e==="1st_lien"?"Est. 1st Lien DTI":"Est. 2nd Lien DTI";return a.jsxs(rn,{children:[a.jsx($s,{className:"pb-2",children:a.jsx(Hs,{className:"text-base",children:"LTV Cheat Sheet"})}),a.jsxs(on,{children:[l>0?a.jsxs($o,{children:[a.jsx(Ho,{children:a.jsxs(Yr,{children:[a.jsx(In,{children:"Target LTV"}),a.jsx(In,{className:"text-right",children:"Max Lien Amount"}),a.jsx(In,{className:"text-right",children:"Difference +/−"}),a.jsx(In,{className:"text-right",children:h})]})}),a.jsx(Uo,{children:zb.map(f=>{const x=l*(f/100),b=x-d,m=Ub(e,f,t,r);return a.jsxs(Yr,{children:[a.jsxs(Ut,{className:"font-medium",children:[f,"%"]}),a.jsx(Ut,{className:"text-right",children:i(x)}),a.jsxs(Ut,{className:`text-right font-semibold ${b>=0?"text-success":"text-destructive"}`,children:[b>=0?"+":"−",i(Math.abs(b))]}),a.jsx(Ut,{className:`text-right font-semibold ${m!==null&&m>s?"text-destructive":"text-foreground"}`,children:m!==null?c(m):"N/A"})]},f)})})]}):a.jsx("p",{className:"text-sm text-muted-foreground",children:"No property data available."}),a.jsxs("p",{className:"mt-2 text-xs text-muted-foreground",children:["Current combined lien balance: ",i(d)]})]})]})},Wb=80,Wp=90;function Gb(e,t,n=Wp){if(e<=0)return Math.max(0,Math.round(t));const r=Math.round(e*(n/100));return Math.max(Math.round(t),r)}function Ll(e,t,n){const r=t.primaryPropertyValue;
1196return r<=0?null:e==="1st_lien"?Gb(r,t.firstLienComputedBalance):t.maxHelocEstimate!=null&&t.maxHelocEstimate>0?Math.round(t.maxHelocEstimate):Math.max(0,Math.round(r*(n/100)))}function $f(e,t,n){if(e<=0)return!0;const r=Math.round(n.maxHelocEstimate??0);return r>0&&e===r||t>0&&e===t||e<n.firstLienComputedBalance}function Yb(e,t,n){if(t==="1st_lien"){const s=e.firstLienAssumedDti;return{label:"1st Lien DTI",pass:s!=null?s<=n:!1,detail:s!=null?`${s.toFixed(2)}%`:"N/A"}}const r=e.secondLienAssumedDti;return{label:"2nd Lien DTI",pass:r!=null?r<=n:!1,detail:r!=null?`${r.toFixed(2)}%`:"N/A"}}function Kb(e){const{qualMetrics:t,creditLimits:n,helocType:r,maxCltvPct:s,firstLienMaxLtvPct:i=Wb}=e,c=n["2nd_lien"],l=n["1st_lien"],d=t.projectedSecondLienCltvPct,h=t.projectedFirstLienLtvPct,f=c>0&&d!=null?{label:"2nd Lien CLTV",pass:d<=s,detail:`${d.toFixed(1)}%`}:{label:"2nd Lien CLTV",pass:!1,detail:"N/A"},x=l>0&&h!=null?{label:"1st Lien LTV",pass:h<=i,detail:`${h.toFixed(1)}%`}:{label:"1st Lien LTV",pass:!1,detail:"N/A"};return{items:[r==="2nd_lien"?f:x]}}function Qb(e,t){const n=e==="1st_lien"?t["1st_lien"].existingHelocBalance:t["2nd_lien"].existingHelocBalance;return Math.max(0,Number(n)||0)}function Jb(e,t,{firstLienGrossStartingBalance:n,secondLienGrossConsolidated:r,hasConsolidation:s}){const i=Math.max(0,Number(t)||0);return e==="1st_lien"?Math.max(0,i-Math.max(0,n)):s?Math.max(0,i-Math.max(0,r)):i}function Ji(e,t,{firstLienGrossStartingBalance:n,secondLienGrossConsolidated:r,hasConsolidation:s}){const i=Math.max(0,Number(t)||0);return e==="1st_lien"?Math.max(0,n)+i:s?Math.max(0,r)+i:i}function Xb(e){if(!e.hasConsolidation)return 0;const t=Math.max(0,Math.round(Number(e.fromDebtsAndProperties)||0));if(t>0)return t;const n=e.fromMetrics;return n!=null&&Number.isFinite(n)&&n>0?Math.round(n):0}function tu(e){return(e??"").toLowerCase()==="mortgage"}function nu(e){return e.filter(t=>t.ignored&&!tu(t.debt_type)).reduce((t,n)=>t+Math.max(0,Number(n.monthly_payment??0)),0)}function Zb(e){return e.filter(t=>!t.ignored&&!t.is_consolidated&&!tu(t.debt_type)).reduce((t,n)=>t+Math.max(0,Number(n.monthly_payment??0)),0)}function ev(e){return nu(e)+Zb(e)}function tv(e){return e.filter(t=>!tu(t.debt_type)).reduce((t,n)=>t+Math.max(0,Number(n.monthly_payment??0)),0)}function nv(e){const t=new Date(e),n=t.getUTCFullYear(),r=String(t.getUTCMonth()+1).padStart(2,"0");return`${n}-${r}`}function rv(e){return new Date(e).getUTCDate()}function av(e){const t=new Date(e),n=new Date(Date.UTC(t.getUTCFullYear(),t.getUTCMonth()+1,0)).getUTCDate();return t.getUTCDate()===n}function Gp(e){const t=new Map;e.forEach(s=>{const i=nv(s.date),c=t.get(i)??{total:0,hasInterestRow:!1,hasFirstDay:!1,hasLastDay:!1};c.hasFirstDay||(c.hasFirstDay=rv(s.date)===1),c.hasLastDay||(c.hasLastDay=av(s.date)),Number.isFinite(s.locDailyInterest)&&(c.total+=s.locDailyInterest??0,c.hasInterestRow=!0),t.set(i,c)});const n=Array.from(t.values()).find(s=>s.hasInterestRow&&s.hasFirstDay&&s.hasLastDay);if(n)return n.total;const r=Array.from(t.values()).find(s=>s.hasInterestRow);return r?r.total:null}function sv(e,t){if(e<=0)return 0;const n=Math.max(0,t)/100/12;return e*n}function Bd(e){const t=e.chunkAmount;return t!=null&&t>0?t:Math.max(0,e.preHelocCashflowSurplus)}function iv(e){if(e.modeledFirstMonthLocInterest!=null&&e.modeledFirstMonthLocInterest>0)return e.modeledFirstMonthLocInterest;
1196const t=Bd({chunkAmount:e.chunkAmount,preHelocCashflowSurplus:e.preHelocCashflowSurplus});return sv(t,e.helocAnnualRatePct)}function Hf(e,t,n,r){var l,d;if(e==="1st_lien")return t;const s=((d=(l=r["2nd_lien"])==null?void 0:l.accelerated)==null?void 0:d.trackerData)??[],i=Gp(s),c=iv({modeledFirstMonthLocInterest:i,chunkAmount:n.chunkSize,preHelocCashflowSurplus:t,helocAnnualRatePct:n.interestRate});return t-c}function ov(e){var t;return e.length<=1?0:((t=e[e.length-1])==null?void 0:t.month)??0}function lv(e,t){for(const n of e){const r=n.debtBalances.get(t);if(r!==void 0&&r<=.01)return n.month}return null}function cv(e){const{scheduleByDebt:t,monthlyBreakdown:n,consolidatedDebtIds:r,nameById:s}=e,i=[];for(const[c,l]of t.entries()){if(c.endsWith("_baseline"))continue;const d=ov(l);if(d<=0)continue;const h=r.has(c);let f;h?f=0:f=lv(n,c)??d,i.push({id:c,name:s.get(c)??c,baselineMonths:d,acceleratedMonths:f,monthsSaved:Math.max(0,d-f),isConsolidated:h})}return i.sort((c,l)=>l.monthsSaved-c.monthsSaved||c.name.localeCompare(l.name)),i}function Od(e){const t=Math.max(0,e.baseline.totalMonths-e.accelerated.totalMonths),n=e.baseline.totalInterest-e.accelerated.totalInterest,r=Math.max(0,Math.min(Math.round(n),Math.round(e.baseline.totalInterest)));return{monthsSaved:t||Math.max(0,e.savings.monthsSaved),interestSaved:r||Math.max(0,Math.round(e.savings.interestSaved))}}function dv(e){const{monthsSaved:t}=Od(e.comparison),n=e.comparison.baseline.scheduleByDebt,r=e.comparison.accelerated.monthlyBreakdown;if(!(n!=null&&n.size)||!(r!=null&&r.length))return{monthsSaved:t,timeSavedByDebt:void 0};const s=cv({scheduleByDebt:n,monthlyBreakdown:r,consolidatedDebtIds:e.consolidatedDebtIds,nameById:e.nameById});return{monthsSaved:t,timeSavedByDebt:s}}const Uf=()=>({"1st_lien":null,"2nd_lien":null}),od=()=>({"1st_lien":null,"2nd_lien":null});function Yp(){const e=new Date,t=e.getFullYear(),n=String(e.getMonth()+1).padStart(2,"0"),r=String(e.getDate()).padStart(2,"0");return`${t}-${n}-${r}`}function uv(e){const t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e.trim());if(!t)return new Date;const n=Number(t[1]),r=Number(t[2]),s=Number(t[3]);return new Date(Date.UTC(n,r-1,s))}function hv(e){const t=Math.floor(e/12),n=e%12;return t>0?`${t} year${t>1?"s":""}${n>0?` ${n} month${n>1?"s":""}`:""}`.trim():`${n} month${n!==1?"s":""}`}const ld=()=>{const e=Yp();return{"1st_lien":{interestRate:8,startingBalance:0,existingHelocBalance:0,chunkSize:null,strategyStartDate:e},"2nd_lien":{interestRate:8,startingBalance:0,existingHelocBalance:0,chunkSize:null,strategyStartDate:e}}};function fv(e,t){return t?"At strategy start (LOC)":e<=0?"—":Za(e)}function mv({rows:e}){return a.jsx("div",{className:"overflow-hidden rounded-md border border-border/60 bg-background",children:a.jsxs("table",{className:"w-full text-sm",children:[a.jsx("thead",{children:a.jsxs("tr",{className:"text-left text-xs text-muted-foreground",children:[a.jsx("th",{className:"bg-muted/30 px-3 py-2 font-medium",children:"Debt"}),a.jsx("th",{className:"bg-muted/30 px-3 py-2 font-medium",children:"Baseline payoff"}),a.jsx("th",{className:"bg-muted/30 px-3 py-2 font-medium",children:"Strategy payoff"}),a.jsx("th",{className:"bg-muted/30 px-3 py-2 text-right font-medium",children:"Time saved"})]})}),a.jsx("tbody",{children:e.map(t=>a.jsxs("tr",{className:"border-t border-border/40",children:[a.jsx("td",{className:"px-3 py-2 font-medium text-foreground",children:a.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[a.jsx("span",{className:"truncate",children:t.name}),t.isConsolidated?a.jsx(xn,{variant:"outline",className:"shrink-0 text-[10px]",children:"Consolidated"}):null]})}),a.jsx("td",{className:"px-3 py-2 tabular-nums text-muted-foreground",children:Za(t.baselineMonths)}),a.jsx("td",{className:"px-3 py-2 tabular-nums text-muted-foreground",children:fv(t.acceleratedMonths,t.isConsolidated)}),a.jsx("td",{className:"px-3 py-2 text-right font-semibold tabular-nums text-[#28a745]",children:Kp(t.monthsSaved)})]},t.id))})]})})}function pv({baselineInterest:e,acceleratedInterest:t,interestSaved:n}){const r=s=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(s);return a.jsx("div",{className:"overflow-hidden rounded-md border border-border/60 bg-background",children:a.jsxs("table",{className:"w-full text-sm",children:[a.jsx("thead",{children:a.jsxs("tr",{className:"text-left text-xs text-muted-foreground",children:[a.jsx("th",{className:"bg-muted/30 px-3 py-2 font-medium",children:"Scenario"}),a.jsx("th",{className:"bg-muted/30 px-3 py-2 text-right font-medium",children:"Total interest"})]})}),a.jsxs("tbody",{children:[a.jsxs("tr",{className:"border-t border-border/40",children:[a.jsx("td",{className:"px-3 py-2 font-medium text-foreground",children:"Baseline (min. payments)"}),a.jsx("td",{className:"px-3 py-2 text-right tabular-nums text-muted-foreground",children:r(e)})]}),a.jsxs("tr",{className:"border-t border-border/40",children:[a.jsx("td",{className:"px-3 py-2 font-medium text-foreground",children:"Accelerated payoff"}),a.jsx("td",{className:"px-3 py-2 text-right tabular-nums text-muted-foreground",children:r(t)})]}),a.jsxs("tr",{className:"border-t border-border/40",children:[a.jsx("td",{className:"px-3 py-2 font-semibold text-foreground",children:"Interest saved"}),a.jsx("td",{className:"px-3 py-2 text-right font-semibold tabular-nums text-[#28a745]",children:r(n)})]})]})]})})}
1196function gv(e){const t=Math.floor(e/12),n=e%12;if(t===0&&n===0)return"—";const r=[];return t>0&&r.push(`${t} yr${t!==1?"s":""}`),n>0&&r.push(`${n} mo`),r.join(", ")}function Kp(e){const t=Math.floor(e/12),n=e%12,r=[];return t>0&&r.push(`${t} year${t!==1?"s":""}`),n>0&&r.push(`${n} month${n!==1?"s":""}`),r.join(" ").trim()||"0 months"}function Mo(e){return`${Math.round(e)}%`}const ru="text-[#28a745]",Vf="text-[#dc3545]";function cd({icon:e,title:t,value:n,valueClassName:r=ru,iconClassName:s="text-foreground",footnote:i,detailContent:c}){return a.jsxs(_i,{defaultOpen:!1,className:"group overflow-hidden rounded-lg border border-border/80 bg-card shadow-none",children:[a.jsxs(wi,{className:"flex w-full items-center gap-3 px-4 py-3.5 text-left transition-colors hover:bg-muted/40 data-[state=open]:bg-muted/30",children:[a.jsx(Ys,{className:"h-4 w-4 shrink-0 text-muted-foreground transition-transform duration-200 group-data-[state=open]:rotate-180"}),a.jsx("span",{className:Et("flex shrink-0 [&>svg]:h-4 [&>svg]:w-4",s),children:e}),a.jsx("span",{className:"min-w-0 flex-1 text-left text-sm font-bold leading-snug tracking-tight text-foreground",children:t}),a.jsx("span",{className:Et("shrink-0 text-right text-base font-bold tabular-nums sm:text-lg",r),children:n})]}),a.jsxs(Ni,{className:"space-y-3 border-t border-border/60 bg-muted/20 px-4 py-3 text-xs leading-snug text-muted-foreground",children:[c,i?a.jsx("p",{children:i}):null]})]})}function xv({mortgageTipPct:e,helocTipPct:t,tipSavedPct:n}){const r=n>=0,s=r?`${Mo(n)} saved`:`${Mo(Math.abs(n))} higher`;return a.jsxs(_i,{defaultOpen:!1,className:"group overflow-hidden rounded-lg border border-border/80 bg-card shadow-none",children:[a.jsxs(wi,{className:"flex w-full items-center gap-3 px-4 py-3.5 text-left transition-colors hover:bg-muted/40 data-[state=open]:bg-muted/30",children:[a.jsx(Ys,{className:"h-4 w-4 shrink-0 text-muted-foreground transition-transform duration-200 group-data-[state=open]:rotate-180"}),a.jsx("span",{className:"flex shrink-0 text-foreground [&>svg]:h-4 [&>svg]:w-4",children:a.jsx(ac,{})}),a.jsx("span",{className:"min-w-0 flex-1 text-left text-sm font-bold leading-snug tracking-tight text-foreground",children:"Total Interest Percentage Savings (TIP)"}),a.jsx("span",{className:Et("shrink-0 text-right text-base font-bold tabular-nums sm:text-lg",r?ru:Vf),children:s})]}),a.jsxs(Ni,{className:"border-t border-border/60 bg-background px-3 py-3",children:[a.jsxs("div",{className:"overflow-hidden rounded-md border border-border text-sm",children:[a.jsxs("div",{className:"grid grid-cols-2 border-b border-border",children:[a.jsx("div",{className:"bg-muted px-3 py-2 font-medium text-muted-foreground",children:"Mortgage TIP"}),a.jsx("div",{className:Et("px-3 py-2 text-right font-semibold tabular-nums",Vf),children:Mo(e)})]}),a.jsxs("div",{className:"grid grid-cols-2 border-b border-border",children:[a.jsx("div",{className:"bg-muted px-3 py-2 font-medium text-muted-foreground",children:"Cash Flow Strategy HELOC TIP"}),a.jsx("div",{className:"px-3 py-2 text-right font-semibold tabular-nums text-foreground",children:Mo(t)})]}),a.jsxs("div",{className:"grid grid-cols-2",children:[a.jsx("div",{className:"bg-muted px-3 py-2 font-medium text-muted-foreground",children:"TIP % Saved"}),a.jsx("div",{className:Et("px-3 py-2 text-right font-semibold tabular-nums",r?"bg-[#28a745]/10 text-[#28a745]":"bg-[#dc3545]/10 text-[#dc3545]"),children:Mo(n)})]})]}),a.jsx("p",{className:"mt-2 text-xs leading-snug text-muted-foreground",children:"TIP uses the primary mortgage balance as the percentage basis. For 1st-lien HELOCs, LOC interest is allocated to the mortgage share of the opening HELOC balance so consolidated consumer debt does not inflate the mortgage comparison."})]})]})}function yv(){return a.jsxs(_i,{defaultOpen:!1,className:"group overflow-hidden rounded-lg border border-border/80 bg-card shadow-none",children:[a.jsxs(wi,{className:"flex w-full items-center gap-3 px-4 py-3.5 text-left transition-colors hover:bg-muted/40 data-[state=open]:bg-muted/30",children:[a.jsx(Ys,{className:"h-4 w-4 shrink-0 text-muted-foreground transition-transform duration-200 group-data-[state=open]:rotate-180"}),a.jsx("span",{className:"flex shrink-0 text-foreground [&>svg]:h-4 [&>svg]:w-4",children:a.jsx(ac,{})}),a.jsx("span",{className:"min-w-0 flex-1 text-left text-sm font-bold leading-snug tracking-tight text-foreground",children:"Total Interest Percentage Savings (TIP)"}),a.jsx("span",{className:"shrink-0 text-right text-base font-bold tabular-nums text-muted-foreground sm:text-lg",children:"—"})]}),a.jsx(Ni,{className:"border-t border-border/60 bg-muted/20 px-4 py-3 text-xs leading-snug text-muted-foreground",children:"Run and save a fresh calculation on this lien to populate mortgage vs. strategy HELOC TIP comparison. Saved results from before this field was added will show a dash until you recalculate."})]})}function Wf({title:e,children:t}){return a.jsxs(_i,{defaultOpen:!1,className:"group overflow-hidden rounded-lg border border-border/80 bg-card shadow-none",children:[a.jsxs(wi,{className:"flex w-full items-center gap-3 px-4 py-3.5 text-left transition-colors hover:bg-muted/40 data-[state=open]:bg-muted/30",children:[a.jsx(Ys,{className:"h-4 w-4 shrink-0 text-muted-foreground transition-transform duration-200 group-data-[state=open]:rotate-180"}),a.jsx(m0,{className:"h-4 w-4 shrink-0 text-foreground"}),a.jsx("span",{className:"min-w-0 flex-1 text-left text-sm font-bold leading-snug tracking-tight text-foreground",children:e}),a.jsx("span",{className:"shrink-0 text-sm font-bold text-muted-foreground",children:"View detail"})]}),a.jsx(Ni,{children:t})]})}function Gf({summary:e}){return a.jsxs("div",{className:"mt-3 grid gap-1.5 border-t border-border/70 pt-3 text-[11px] leading-tight",children:[a.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[a.jsx("span",{className:"shrink-0 text-muted-foreground",children:"Paid off in"}),a.jsx("span",{className:"min-w-0 text-right font-semibold tabular-nums text-foreground",children:e.paidOffIn})]}),a.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[a.jsx("span",{className:"shrink-0 text-muted-foreground",children:"Interest saved"}),a.jsx("span",{className:"min-w-0 text-right font-semibold tabular-nums text-success",children:e.interestSaved})]})]})}function bv(e){const t={credit_card:"credit_card",personal_loan:"personal_loan",auto:"auto_loan",auto_loan:"auto_loan",student:"student_loan",student_loan:"student_loan",mortgage:"mortgage",heloc:"heloc",ploc:"ploc",line_of_credit:"line_of_credit",other:"other"};return{id:e.id,account_name:e.debt_name,current_balance:e.current_balance,interest_rate:e.interest_rate,monthly_payment:e.monthly_payment,loan_term_months:null,maturity_date:null,created_at:new Date().toISOString(),originial_loan_amount:e.current_balance,monthly_payment_day:null,name:e.debt_name,type:t[e.debt_type]||"other",original_amount:e.current_balance,minimum_payment:e.monthly_payment,term_months:null,due_date:null}}function vv(e){if(!(e!=null&&e.message))return!1;const t=e.message.toLowerCase();return t.includes("no unique or exclusion constraint matching")||t.includes("on conflict specification")||e.code==="42P10"}function _v(e){if(!Array.isArray(e))return null;const t=e.filter(n=>typeof n=="string"&&n.length>0);return t.length>0?t:null}function Yf(e,t){const n=new Set(t);return[...e].filter(r=>!n.has(r.id)).sort((r,s)=>{const i=(r.minimum_payment??0)>0?Number(r.current_balance??0)/(r.minimum_payment??1):1/0,c=(s.minimum_payment??0)>0?Number(s.current_balance??0)/(s.minimum_payment??1):1/0;return i-c}).map(r=>r.id)}function qo(e){const t=new Set,n=[];for(const r of e)t.has(r)||(t.add(r),n.push(r));return n}function Al(e,t){const n=new Set(t),r=qo(e.filter(i=>n.has(i)));if(r.length===0)return qo([...t]);const s=t.filter(i=>!r.includes(i));return qo([...r,...s])}function dd(e){return e==="1st_lien"?"1st_lien":"2nd_lien"}const wv=({leadId:e,scenarioId:t,assessment:n,properties:r,debts:s,expenses:i,metrics:c,qualificationMetrics:l,additionalClients:d=[],onTrackerDataChanged:h,onHelocParamsChanged:f,onStrategyPayoffComparisonChanged:x,onSaveReserves:b,selectedHelocType:m="2nd_lien",firstLienPropertyTypeSupp
1196orted:w=!0})=>{var ya;const{user:v}=vi(),{toast:P}=Ir(),{settings:_}=co(),q=ys(),T=J.useMemo(()=>s.filter(ie=>!ie.ignored),[s]),B=J.useMemo(()=>r.filter(Ml),[r]),Q=J.useMemo(()=>B.filter($l),[B]),me=Math.max(0,Number((n==null?void 0:n.reserves_for_paydown)??0)),[ce,$]=J.useState(me),[D,Y]=J.useState(!1);J.useEffect(()=>{$(me)},[me]);const N=Math.max(0,Number.isFinite(Number(ce))?Number(ce):0),I=b?N:me,k=async()=>{if(!b)return;const ie=N;if(Math.round(ie*100)!==Math.round(me*100)){Y(!0);try{await b(ie),P({title:"Reserves updated"})}catch(xe){const He=xe instanceof Error?xe.message:String(xe);P({title:"Failed to save reserves",description:He,variant:"destructive"})}finally{Y(!1)}}},[L,H]=J.useState(()=>dd(m)),[te,se]=J.useState({"1st_lien":0,"2nd_lien":Math.round(c.maxHelocEstimate??0)}),[K,ae]=J.useState(ld),be=K[L],{interestRate:Ne,startingBalance:A,existingHelocBalance:E,chunkSize:z,strategyStartDate:X}=be,Z=te[L],le=ie=>se(xe=>({...xe,[L]:ie})),fe=J.useCallback((ie,xe)=>{ae(He=>({...He,[ie]:{...He[ie],...xe}}))},[]),[ue,_e]=J.useState(Uf),[Ce,ve]=J.useState(od),we=ue[L],De=Ce[L],R=J.useRef(ue),ze=J.useRef(Ce);R.current=ue,ze.current=Ce;const[ye,Ee]=J.useState(null),[de,Ue]=J.useState({"1st_lien":null,"2nd_lien":null}),[qe,$e]=J.useState(!1),Ge=J.useRef({"1st_lien":!1,"2nd_lien":!1}),[bt,et]=J.useState({"1st_lien":[],"2nd_lien":[]}
1196),[Me,vt]=J.useState({"1st_lien":!1,"2nd_lien":!1}),St=J.useRef(Me);St.current=Me,J.useEffect(()=>{var xe;const ie=ue[L];h==null||h(((xe=ie==null?void 0:ie.accelerated)==null?void 0:xe.trackerData)??[])},[L,ue,h]);const Oe=Vo(r),_t=!!Oe&&Oe.outstanding_mortgage_balance>0,Xe=_t&&w;J.useEffect(()=>{Xe||L!=="1st_lien"||(H("2nd_lien"),nt.from("lead_intake_scenarios").update({selected_heloc_type:"2nd_lien"}).eq("id",t).then(({error:ie})=>{ie&&P({title:"Could not save lien selection",description:ie.message,variant:"destructive"})}))},[Xe,L,t,P]);const Ht=J.useMemo(()=>Ll(L,l,Number(_.max_cltv)||90),[L,l,_.max_cltv]),Lt=J.useCallback(()=>{Ht==null||Ht<=0||se(ie=>({...ie,[L]:Ht}))},[Ht,L]),At=Number(_.max_cltv)||90,kt=J.useRef(l);kt.current=l;const an=J.useRef(At);an.current=At;const it=J.useRef(c.maxHelocEstimate);it.current=c.maxHelocEstimate;const at=J.useCallback(ie=>Ll(ie,l,At),[l,At]),Ve=J.useMemo(()=>{const ie=(Oe==null?void 0:Oe.ignored)===!0?0:(Oe==null?void 0:Oe.outstanding_mortgage_balance)??0,xe=T.filter(rt=>rt.is_consolidated).reduce((rt,mt)=>rt+(mt.current_balance??0),0),He=Q.reduce((rt,mt)=>mt.id===(Oe==null?void 0:Oe.id)?rt:rt+Number(mt.outstanding_mortgage_balance??0),0);return Math.round(ie+xe+He)},[Oe,T,Q]),ft=J.useMemo(()=>{const ie=T.filter(He=>He.is_consolidated).reduce((He,rt)=>He+(rt.current_balance??0),0),xe=Q.reduce((He,rt)=>He+Number(rt.outstanding_mortgage_balance??0),0);return Math.round(ie+xe)},[T,Q]),wt=T.some(ie=>ie.is_consolidated)||Q.length>0,Nt=J.useMemo(()=>Xb({hasConsolidation:wt,fromDebtsAndProperties:ft,fromMetrics:c.consolidatedBalance}),[wt,ft,c.consolidatedBalance]),Qe=J.useRef({firstLienStartingBalance:0,secondLienStartingFromConsolidation:0,hasConsolidation:!1});Qe.current={firstLienStartingBalance:Ve,secondLienStartingFromConsolidation:Nt,hasConsolidation:wt};const Ze=K["1st_lien"].existingHelocBalance,Ae=K["2nd_lien"].existingHelocBalance;J.useEffect(()=>{x&&["1st_lien","2nd_lien"].forEach(ie=>{const xe=ue[ie];if(!xe){x({helocType:ie,comparison:null});return}const He=Math.max(0,Ve+Ze),rt=zf(xe,{helocTypeForScenario:ie,primaryProperty:Oe??void 0,firstLienOpeningLocBalance:He}),mt=xe.savings.paymentsSaved!=null&&Number.isFinite(xe.savings.paymentsSaved)?Math.round(xe.savings.paymentsSaved):void 0;x({helocType:ie,comparison:xe,strategyPdfExtras:{tipSavedPct:rt==null?void 0:rt.tipSavedPct,monthlyPaymentsSaved:mt}})})},[ue,x,Oe,Ve,Ze]),J.useEffect(()=>{ae(ie=>{const xe={firstLienGrossStartingBalance:Ve,secondLienGrossConsolidated:Nt,hasConsolidation:wt},He=Ji("1st_lien",ie["1st_lien"].existingHelocBalance,xe),rt=Ji("2nd_lien",ie["2nd_lien"].existingHelocBalance,xe);return ie["1st_lien"].startingBalance===He&&ie["2nd_lien"].startingBalance===rt?ie:{...ie,"1st_lien":{...ie["1st_lien"],startingBalance:He},"2nd_lien":{...ie["2nd_lien"],startingBalance:rt}}})},[Ve,Nt,wt,Ze,Ae]);const Re=J.useMemo(()=>{const ie=T.map(bv);r.forEach(tt=>{if(tt.outstanding_mortgage_balance>0){const Vn=tt.property_type==="primary_residence";if(Vn){if(tt.ignored)return}else if(!Ml(tt))return;const En=Vn?"Primary Mortgage":`${tt.property_type==="rental"?"Rental":tt.property_type==="vacation_rental"?"Vacation Rental":"Secondary"} Mortgage`,Zt=Number(tt.mortgage_payment)||0,en=xm({totalMonthlyPayment:Zt,outstandingBalance:Number(tt.outstanding_mortgage_balance)||0,originalPrincipal:Number(tt.original_mortgage_balance)||0,annualRatePercent:Number(tt.mortgage_interest_rate)||0,termYears:Number(tt.mortgage_term_years)||30,monthlyTaxes:tt.monthly_taxes,monthlyInsurance:tt.monthly_insurance,monthlyPmi:tt.monthly_pmi});ie.push({id:Vi(tt.id),account_name:En,current_balance:tt.outstanding_mortgage_balance,interest_rate:tt.mortgage_interest_rate,monthly_payment:tt.mortgage_payment,loan_term_months:(tt.mortgage_term_years??30)*12,maturity_date:null,created_at:new Date().toISOString(),originial_loan_amount:tt.outstanding_mortgage_balance,monthly_payment_day:null,name:En,type:"mortgage",original_amount:tt.outstanding_mortgage_balance,minimum_payment:tt.mortgage_payment,term_months:(tt.mortgage_term_years??30)*12,due_date:null,monthly_escrow:e
1196n,monthly_taxes:tt.monthly_taxes,monthly_insurance:tt.monthly_insurance,monthly_pmi:tt.monthly_pmi})}});const xe=new Set;Oe&&(Oe.ignored||xe.add(Vi(Oe.id)),T.filter(tt=>tt.is_consolidated).forEach(tt=>xe.add(tt.id)),Q.forEach(tt=>xe.add(Vi(tt.id))));const He=[];wt&&(T.filter(tt=>tt.is_consolidated).forEach(tt=>He.push(tt.id)),Q.forEach(tt=>He.push(Vi(tt.id))));const rt=[...xe],mt=Yf(ie,rt),Ft=Yf(ie,He);return{mappedDebts:ie,debtsToConsolidate1st:rt,debtsToConsolidate2nd:He,order1st:mt,order2nd:Ft,order1stKey:mt.join("\0"),order2ndKey:Ft.join("\0")}},[T,r,Oe,wt,Q]),Gt=J.useRef(Re);Gt.current=Re,J.useEffect(()=>{const ie=St.current;et(xe=>({"1st_lien":ie["1st_lien"]?Al(xe["1st_lien"],Re.order1st):[...Re.order1st],"2nd_lien":ie["2nd_lien"]?Al(xe["2nd_lien"],Re.order2nd):[...Re.order2nd]}))},[Re.order1stKey,Re.order2ndKey]),J.useEffect(()=>{Ge.current={"1st_lien":!1,"2nd_lien":!1},_e(Uf()),ve(od()),Ue({"1st_lien":null,"2nd_lien":null}),vt({"1st_lien":!1,"2nd_lien":!1}),et({"1st_lien":[],"2nd_lien":[]});const ie=Math.round(it.current??0);se({"1st_lien":0,"2nd_lien":ie}),H(dd(m));const xe=mt=>{const Ft=Qe.current,tt={firstLienGrossStartingBalance:Ft.firstLienStartingBalance,secondLienGrossConsolidated:Ft.secondLienStartingFromConsolidation,hasConsolidation:Ft.hasConsolidation};return{"1st_lien":{...mt["1st_lien"],startingBalance:Ji("1st_lien",mt["1st_lien"].existingHelocBalance,tt)},"2nd_lien":{...mt["2nd_lien"],startingBalance:Ji("2nd_lien",mt["2nd_lien"].existingHelocBalance,tt)}}};ae(xe(ld()));let He=!1;return(async()=>{var Pt;const[mt,Ft]=await Promise.all([nt.from("lead_calculator_results").select("*").eq("scenario_id",t),nt.from("lead_intake_scenarios").select("selected_heloc_type").eq("id",t).maybeSingle()]),tt=mt.data,Vn=dd(((Pt=Ft.data)==null?void 0:Pt.selected_heloc_type)??m);if(He||H(Vn),He)return;if(!(tt!=null&&tt.length)){ae(Te=>xe(Te));return}const En=tt,Zt=od(),en=ld(),Tn={"1st_lien":0,"2nd_lien":Math.round(it.current??0)};let G=null,je=null;for(const Te of En){const un=Te.heloc_type==="1st_lien"?"1st_lien":"2nd_lien",On=Te.credit_limit!=null?Number(Te.credit_limit):null;On!=null&&On>0&&(Tn[un]=On);const Fr=Number(Te.starting_balance??0),ea=Qe.current,ba=Jb(un,Fr,{firstLienGrossStartingBalance:ea.firstLienStartingBalance,secondLienGrossConsolidated:ea.secondLienStartingFromConsolidation,hasConsolidation:ea.hasConsolidation});en[un]={interestRate:Number(Te.interest_rate??8),startingBalance:Ji(un,ba,{firstLienGrossStartingBalance:ea.firstLienStartingBalance,secondLienGrossConsolidated:ea.secondLienStartingFromConsolidation,hasConsolidation:ea.hasConsolidation}),existingHelocBalance:ba,chunkSize:Number(Te.chunk_size)>0?Number(Te.chunk_size):null,strategyStartDate:Te.strategy_start_date&&String(Te.strategy_start_date).length>=10?String(Te.strategy_start_date).slice(0,10):Yp()},Te.baseline_months!=null&&Te.accelerated_months!=null&&(Zt[un]={baselineMonths:Te.baseline_months,baselineInterest:Number(Te.baseline_interest??0),acceleratedMonths:Te.accelerated_months,acceleratedInterest:Number(Te.accelerated_interest??0),monthsSaved:Te.months_saved??0,interestSaved:Number(Te.interest_saved??0),viability:Te.viability??"not_viable"});const Rt=_v(Te.debt_payoff_order);Rt&&(un==="1st_lien"?G=Rt:je=Rt)}if(He)return;const ct=Gt.current;vt({"1st_lien":G!=null,"2nd_lien":je!=null}),et({"1st_lien":G!=null?Al(G,ct.order1st):[...ct.order1st],"2nd_lien":je!=null?Al(je,ct.order2nd):[...ct.order2nd]});const Ye=kt.current,jt=an.current;if($f(Tn["1st_lien"],Tn["2nd_lien"],Ye)){const Te=Ll("1st_lien",Ye,jt);Te!=null&&Te>0&&(Tn["1st_lien"]=Te)}if(Tn["2nd_lien"]<=0){const Te=Ll("2nd_lien",Ye,jt);Te!=null&&Te>0&&(Tn["2nd_lien"]=Te)}se(Tn),ae(xe(en)),ve(Zt)})(),()=>{He=!0}},[e,t]);const yn=J.useCallback(async ie=>{const{error:xe}=await nt.from("lead_intake_scenarios").update({selected_heloc_type:ie}).eq("id",t);if(xe){P({title:"Could not save strategy selection",description:xe.message,variant:"destructive"});return}q.invalidateQueries({queryKey:["lead-intake-scenarios",e]})},[t,e,q,P]),lt=ie=>{H(ie),Ee(null),yn(ie),se(xe=>{const He=at(ie);return He==null||He<=0||ie==="1st_lien"&&!$f(xe["1st_lien"],xe["2nd_lien"],l)||ie==="2nd_lien"&&xe["2nd_lien"]>0?xe:{...xe,[ie]:He}}),ae(xe=>{if((ze.current[ie]!=null||R.current[ie]!=null)&&xe[ie].startingBalance>0)return xe;const rt=xe[ie],Ft=ie==="1st_lien"?Ve+rt.existingHelocBalance:wt?Nt+rt.existingHelocBalance:rt.existingHelocBalance;return{...xe,[ie]:{...rt,startingBalance:Ft}}})},hr=ie=>{L==="1st_lien"?fe(L,{existingHelocBalance:ie,startingBalance:Ve+ie}):wt?fe(L,{existingHelocBalance:ie,startingBalance:Nt+ie}):fe(L,{existingHelocBalance:ie,startingBalance:ie})};J.useMemo(()=>{var ie;return Gp(((ie=we==null?void 0:we.accelerated)==null?void 0:ie.trackerData)??[])},[(ya=we==null?void 0:we.accelerated)==null?void 0:ya.trackerData]);const sn=Lm(r),br=T.reduce((ie,xe)=>ie+(xe.monthly_payment??0),0),bn=i.reduce((ie,xe)=>ie+Number(xe.amount),0),Nn=nu(s),Pn=bn+Nn,Fn=r.filter(ie=>["rental","vacation_rental"].includes(ie.property_type)),Jr=Fn.reduce((ie,xe)=>ie+Number(xe.rental_income??0),0),vr=Fn.reduce((ie,xe)=>ie+Number(xe.rental_expenses??0),0),Un=Jr-vr,_r=d.reduce((ie,xe)=>ie+xe.monthlyNetIncome,0),lr=((n==null?void 0:n.monthly_net_income)??0)+_r,Xn=lr+Un-Pn-br-sn-Fn.reduce((ie,xe)=>ie+Number(xe.mortgage_payment??0),0),Zn=wt?Xn+(c.consolidatedPayments??0):Xn,fr=J.useMemo(()=>Hf(L,Zn,K["2nd_lien"],ue),[L,Zn,K,ue]),nr=J.useCallback((ie,xe)=>{const He=K[ie],rt=te[ie],mt=Hf(ie,Zn,K["2nd_lien"],xe);if(mt<=0)throw new Error("Monthly cashflow must be positive for Accelerated Payoff to work.");if(rt<=0)throw new Error("HELOC credit limit must be greater than zero.");const Ft=Re.mappedDebts,tt=ie==="1st_lien"?[...Re.debtsToConsolidate1st]:ie==="2nd_lien"&&wt?[...Re.debtsToConsolidate2nd]:[],Vn=Oe&&!Oe.ignored?Vi(Oe.id):null,En=qb(Ft,{reserves:I,debtsToConsolidate:tt,helocType:ie,firstLienMortgageDebtId:Vn}),Zt=Qb(ie,K),en={id:"simulated_loc",account_name:ie==="1st_lien"?"1st Lien HELOC":"2nd Lien HELOC / PLOC / HSF",current_balance:Zt,interest_rate:He.interestRate,monthly_payment:0,loan_term_months:null,maturity_date:null,created_at:new Date().toISOString(),originial_loan_amount:null,monthly_payment_day:null,name:ie==="1st_lien"?"1st Lien HELOC":"2nd Lien HELOC / PLOC / HSF",type:"heloc",original_amount:0,minimum_payment:0,term_months:null,due_date:null,credit_limit:rt},Zr=ie==="1st_lien"?bt["1st_lien"]:bt["2nd_lien"],Tn=ie==="1st_lien"?Re.order1st:Re.order2nd,G=Zr.length>0?Zr:Tn,je=Pn,ct=uv(He.strategyStartDate),Ye=ct.getUTCFullYear(),jt=ct.getUTCMonth(),Pt={debts:Ft,debtsBaseline:En,reservesForPaydown:I,locDebt:en,monthlyIncome:lr+Jr,monthlyExpenses:je+vr,chunkAmount:ie==="2nd_lien"?Bd({chunkAmount:He.chunkSize,preHelocCashflowSurplus:mt}):0,debtOrder:G,debtsToConsolidate:tt,startDate:ct,incomeFrequency:"semimonthly",expenseFrequency:"monthly",firstIncomeDate:new Date(Date.UTC(Ye,jt,1)),firstExpenseDate:new Date(Date.UTC(Ye,jt,28))};return a0(Pt)},[Re,wt,K,te,Zn,Jr,vr,Pn,lr,bt,Oe,I]),qr=J.useCallback(()=>nr(L,R.current),[nr,L]);J.useEffect(()=>{const ie=window.setTimeout(()=>{const xe={...R.current},He={"1st_lien":null,"2nd_lien":null};let rt=!1;["2nd_lien","1st_lien"].forEach(mt=>{if(!(mt==="1st_lien"&&!Xe))try{const Ft=nr(mt,xe);xe[mt]!==Ft&&(xe[mt]=Ft,rt=!0)}catch(Ft){He[mt]=Ft instanceof Error?Ft.message:"Calculation failed"}}),rt&&_e(xe),Ue(mt=>mt["1st_lien"]===He["1st_lien"]&&mt["2nd_lien"]===He["2nd_lien"]?mt:He)},400);return()=>window.clearTimeout(ie)},[nr,Xe,te,K,Zn,bt,I]),J.useEffect(()=>{if(!(!Ce[L]||Ge.current[L]||ue[L])){Ge.current[L]=!0;try{const xe=qr();_e(He=>
1196({...He,[L]:xe}))}catch{Ge.current[L]=!1}}},[L,Ce,qr,ue]);const wr=async()=>{var ie;Ee(null),$e(!0);try{await k();const xe=qr();_e(en=>({...en,[L]:xe}));const{savings:He}=xe,{monthsSaved:rt,interestSaved:mt}=Od(xe);let Ft="not_viable";rt>=12&&mt>=1e3?Ft="viable":(rt>0||mt>500)&&(Ft="marginal");const tt=v==null?void 0:v.id;if(!tt){P({title:"Not signed in",description:"Sign in as an admin to save calculator results.",variant:"destructive"});return}const Vn={lead_id:e,scenario_id:t,admin_id:tt,heloc_type:L,credit_limit:Z,interest_rate:Ne,starting_balance:A,chunk_size:Bd({chunkAmount:z,preHelocCashflowSurplus:fr}),monthly_surplus:fr,baseline_months:xe.baseline.totalMonths,baseline_interest:Math.round(xe.baseline.totalInterest),accelerated_months:xe.accelerated.totalMonths,accelerated_interest:Math.round(xe.accelerated.totalInterest),months_saved:rt,interest_saved:mt,viability:Ft,updated_at:new Date().toISOString(),debt_payoff_order:Me[L]?bt[L]:null,strategy_start_date:X};let En=(await nt.from("lead_calculator_results").upsert(Vn,{onConflict:"scenario_id,heloc_type"})).error,Zt=!1;if(En&&vv(En)){const en=await nt.from("lead_calculator_results").upsert(Vn,{onConflict:"lead_id,heloc_type"});En=en.error,Zt=!en.error}if(En){console.error("Failed to save calculator results:",En);const en=((ie=En.message)==null?void 0:ie.slice(0,220))??"Unknown error";P({title:"Calculation complete",description:`Results could not be saved: ${en}`,variant:"destructive"})}else ve(en=>({...en,[L]:{baselineMonths:xe.baseline.totalMonths,baselineInterest:Math.round(xe.baseline.totalInterest),acceleratedMonths:xe.accelerated.totalMonths,acceleratedInterest:Math.round(xe.accelerated.totalInterest),monthsSaved:rt,interestSaved:mt,viability:Ft}})),P(Zt?{title:"Calculation saved",description:"Saved using a legacy unique constraint. Apply the latest lead intake migrations so saves use scenario_id + heloc_type."}:{title:"Calculation saved",description:"Results have been saved successfully."})}catch(xe){Ee(xe instanceof Error?xe.message:"Calculation failed")}finally{$e(!1)}},Sa=J.useMemo(()=>{let ie=0;return T.forEach(xe=>{xe.current_balance&&xe.interest_rate&&(ie+=xe.current_balance*xe.interest_rate/100/12)}),Oe&&Oe.outstanding_mortgage_balance>0&&Oe.mortgage_interest_rate&&(ie+=Oe.outstanding_mortgage_balance*Oe.mortgage_interest_rate/100/12),ie},[T,Oe]),qt=we?s0(we):null,zr=de[L],ma=zr!=null&&(we!=null||De!=null),Ct=J.useMemo(()=>{if(zr)return null;if(we&&qt){const{savings:ie}=we,xe=Math.max(0,Ve+Ze),He=zf(we,{helocTypeForScenario:L,primaryProperty:Oe??void 0,firstLienOpeningLocBalance:xe}),rt=new Map(Re.mappedDebts.map(en=>[en.id,String(en.name||en.account_name||en.id)])),mt=new Set(L==="1st_lien"?Re.debtsToConsolidate1st:Re.debtsToConsolidate2nd),{monthsSaved:Ft,timeSavedByDebt:tt}=dv({comparison:we,consolidatedDebtIds:mt,nameById:rt}),{interestSaved:Vn}=Od(we),En=`$${Vn.toLocaleString()}`,Zt=we.baseline.scheduleByDebt&&we.baseline.scheduleByDebt.size>0?(()=>{var Zr;const en=[];for(const[Tn,G]of we.baseline.scheduleByDebt.entries()){const je=Math.round(G.reduce((jt,Pt)=>jt+Pt.interest,0)),ct=G.length>1?((Zr=G[G.length-1])==null?void 0:Zr.month)??0:0,Ye=Tn.endsWith("_baseline")?"LOC opening balance (baseline)":rt.get(Tn)??Tn;en.push({id:Tn,name:Ye,months:ct,interest:je})}return en.sort((Tn,G)=>G.interest-Tn.interest),en})():void 0;return{baselineMonths:we.baseline.totalMonths,baselineInterest:Math.round(we.baseline.totalInterest),acceleratedMonths:we.accelerated.totalMonths,acceleratedInterest:Math.round(we.accelerated.totalInterest),monthsSaved:Ft,interestSaved:Vn,baselinePayoffDisplay:qt.baselinePayoffDisplay,acceleratedPayoffDisplay:qt.acceleratedPayoffDisplay,timeSavedDisplay:hv(Ft),interestSavedDisplay:En,paymentsSaved:ie.paymentsSaved,tipSavings:He,baselineByDebt:Zt,timeSavedByDebt:tt}}if(De){const ie=He=>{const rt=new Date;return rt.setMonth(rt.getMonth()+He),rt.toLocaleDateString("en-US",{month:"short",year:"numeric"})},xe=He=>{const rt=Math.floor(He/12),mt=He%12;return`${rt>0?`${rt} year${rt!==1?"s":""}`:""}${rt>0&&mt>0?" ":""}${mt>0?`${mt} month${mt!==1?"s":""}`:""}`.trim()||"0 months"};return{baselineMonths:De.baselineMonths,baselineInterest:De.baselineInterest,acceleratedMonths:De.acceleratedMonths,acceleratedInterest:De.acceleratedInterest,monthsSaved:De.monthsSaved,interestSaved:De.interestSaved,baselinePayoffDisplay:ie(De.baselineMonths),acceleratedPayoffDisplay:ie(De.acceleratedMonths),timeSavedDisplay:xe(De.monthsSaved),interestSavedDisplay:`$${De.interestSaved.toLocaleStr
1196ing()}`,paymentsSaved:void 0,tipSavings:void 0,baselineByDebt:void 0,timeSavedByDebt:void 0}}return null},[zr,we,qt,De,Re,Oe,L,Ve,Ze]),ts=!zr&&we!=null&&De!=null&&(De.acceleratedMonths!==we.accelerated.totalMonths||De.baselineMonths!==we.baseline.totalMonths),pa=Ct?Ct.monthsSaved>=12&&Ct.interestSaved>=1e3?{label:"Viable",color:"border-[#28a745]/30 bg-[#28a745]/10 text-[#28a745]",icon:Q0}:Ct.monthsSaved>0||Ct.interestSaved>500?{label:"Needs review",color:"border-sky-400/45 bg-sky-500/[0.12] text-sky-800 dark:border-sky-600/50 dark:bg-sky-950/35 dark:text-sky-100",icon:ms}:{label:"Not Viable",color:"border-[#dc3545]/30 bg-[#dc3545]/10 text-[#dc3545]",icon:Kl}:null,ga=J.useMemo(()=>{const ie=r.filter(He=>(He.outstanding_mortgage_balance??0)>0&&(He.property_type==="primary_residence"&&!He.ignored||Ml(He))).map(He=>{const mt=He.property_type==="primary_residence"?"Primary Mortgage":`${He.property_type==="rental"?"Rental":He.property_type==="vacation_rental"?"Vacation Rental":"Secondary"} Mortgage`;return{id:Vi(He.id),name:mt,type:"Mortgage",balance:He.outstanding_mortgage_balance??0}});return[...T.map(He=>({id:He.id,name:He.debt_name,type:String(He.debt_type??"other").replace(/_/g," "),balance:Math.abs(He.current_balance??0)})),...ie]},[r,T]),cr=J.useMemo(()=>new Map(Re.mappedDebts.map(ie=>[ie.id,ie])),[Re]),Xr=L==="1st_lien"?Re.debtsToConsolidate1st:wt?Re.debtsToConsolidate2nd:[],La=L==="1st_lien"?bt["1st_lien"]:bt["2nd_lien"],xa=J.useMemo(()=>qo(La.filter(ie=>cr.has(ie))),[La,cr]),$r=J.useCallback(ie=>{ie.destination&&(vt(xe=>({...xe,[L]:!0})),et(xe=>{const He=L,rt=qo(xe[He].filter(Vn=>cr.has(Vn))),mt=rt.indexOf(ie.draggableId);if(mt<0)return xe;const Ft=[...rt],[tt]=Ft.splice(mt,1);return tt===void 0?xe:(Ft.splice(ie.destination.index,0,tt),{...xe,[He]:Ft})}))},[L,cr]),Ba=J.useCallback(()=>{vt(ie=>({...ie,[L]:!1})),et(ie=>({...ie,[L]:[...L==="1st_lien"?Re.order1st:Re.order2nd]}))},[L,Re]),bs=J.useMemo(()=>Xr.reduce((ie,xe)=>{const He=cr.get(xe);return ie+(He?Math.abs(Number(He.current_balance)||0):0)},0),[Xr,cr]),Qt=J.useMemo(()=>xa.reduce((ie,xe)=>{const He=cr.get(xe);return ie+(He?Math.abs(Number(He.current_balance)||0):0)},0),[xa,cr]),vs=bs+Qt,rr=J.useMemo(()=>Ji(L,E,{firstLienGrossStartingBalance:Ve,secondLienGrossConsolidated:Nt,hasConsolidation:wt}),[L,E,Ve,Nt,wt]);J.useEffect(()=>{f==null||f({creditLimits:te,helocType:L,interestRate:Ne,startingBalance:A,existingHelocBalance:E,calculatedStartingBalance:rr,chunkSize:z})},[te,L,Ne,A,E,rr,z,f]);const Oa=J.useCallback(()=>{fe(L,{startingBalance:rr})},[L,rr,fe]),Hr=ie=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(ie),Bn=J.useMemo(()=>{const ie=xe=>{if(de[xe])return null;const He=ue[xe],rt=Ce[xe];let mt,Ft;if(He)mt=He.accelerated.totalMonths,Ft=Math.round(He.savings.interestSaved);else if(rt)mt=rt.acceleratedMonths,Ft=rt.interestSaved;else return null;return{paidOffIn:gv(mt),interestSaved:`$${Ft.toLocaleString()}`}};return{"2nd_lien":ie("2nd_lien"),"1st_lien":ie("1st_lien")}},[ue,Ce,de]);return a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("button",{type:"button",onClick:()=>lt("2nd_lien"),className:Et("rounded-xl border-2 p-4 text-left transition-all",L==="2nd_lien"?"border-primary bg-primary/5":"border-border bg-card hover:border-primary/50"),children:[a.jsxs("div",{className:"mb-1 flex items-center gap-2",children:[a.jsx(i0,{className:Et("h-5 w-5 shrink-0",L==="2nd_lien"?"text-primary":"text-muted-foreground")}),a.jsx("span",{className:"text-sm font-semibold",children:"2nd Lien HELOC / PLOC / HSF"})]}),a.jsx("p",{className:"text-xs text-muted-foreground",children:"Periodic chunking with a HELOC/PLOC, or HSF-style payoff with 0% APR"}),Bn["2nd_lien"]&&a.jsx(Gf,{summary:Bn["2nd_lien"]})]}),a.jsxs("button",{type:"button",onClick:()=>Xe?lt("1st_lien"):null,disabled:!Xe,className:Et("rounded-xl border-2 p-4 text-left transition-all",!Xe&&"cursor-not-allowed opacity-50",L==="1st_lien"?"border-primary bg-primary/5":"border-border bg-card hover:border-primary/50"),children:[a.jsxs("div",{className:"mb-1 flex items-center gap-2",children:[a.jsx(cm,{className:Et("h-5 w-5 shrink-0",L==="1st_lien"?"text-primary":"text-muted-foreground")}),a.jsx("span",{className:"text-sm font-semibold",children:"1st Lien HELOC"}),!Xe&&a.jsx(xn,{variant:"outline",className:"py-0 text-[10px]",children:_t?"No Rental Program":"No Mortgage"})]}),a.jsx("p",{className:"text-xs text-muted-foreground",children:_t?w?"Replace the focus-property mortgage with a HELOC":"No active lender program supports this focus property type":"The focus property has no mortgage to replace"}),Xe&&Bn["1st_lien"]&&a.jsx(Gf,{summary:Bn["1st_lien"]})]})]}),(La.length>0||Xr.length>0)&&a.jsxs(rn,{children:[a.jsxs($s,{className:"flex flex-row flex-wrap items-start justify-between gap-2 space-y-0 pb-3",children:[a.jsxs("div",{children:[a.jsx(Hs,{className:"text-lg font-semibold tracking-tight",children:"Debt payoff order (accelerated)"}),a.jsxs("p",{className:"mt-1 text-xs text-muted-foreground",children:["Drag to choose which balance receives HELOC chunks first for this ",L==="1st_lien"?"1st lien":"2nd lien"," ","scenario. Defaults to live cashflow index (frees monthly payment capacity fastest) until you drag a custom order. Consolidation payoffs happen at start and are not reorderable. Use"," ",a.jsx("span",{className:"font-medium text-foreground",children:"Run & Save Calculation"})," to refresh numbers after changing order."]})]}),La.length>0&&a.jsxs("div",{className:"flex shrink-0 flex-wrap items-center gap-2",children:[Me[L]?a.jsx(xn,{variant:"outline",className:"text-[10px]",children:"Custom order"}):a.jsx(xn,{variant:"secondary",className:"text-[10px]",children:"Cashflow index"}),a.jsxs(st,{type:"button",variant:"outline",size:"sm",className:"h-8 gap-1 text-xs",onClick:Ba,disabled:!Me[L],children:[a.jsx(o0,{className:"h-3.5 w-3.5"}),"Cashflow index order"]})]})]}),a.jsxs(on,{className:"space-y-3",children:[Xr.length>0&&a.jsxs("div",{className:"rounded-lg border border-border bg-muted/30 p-3",children:[a.jsx("p",{className:"mb-2 text-xs font-medium text-muted-foreground",children:"Paid via consolidation at start"}),a.jsxs("ul",{className:"space-y-1.5",children:[Xr.map(ie=>{const xe=cr.get(ie);return xe?a.jsxs("li",{className:"flex items-center justify-between text-sm",children:[a.jsx("span",{className:"font-medium",children:xe.name}),a.jsx("span",{className:"tabular-nums text-muted-foreground",children:Hr(Math.abs(Number(xe.current_balance)))})]},ie):null}),a.jsxs("li",{className:"flex items-center justify-between border-t border-border/60 pt-1.5 text-sm font-semibold",children:[a.jsx("span",{children:"Consolidation total"}),a.jsx("span",{className:"tabular-nums",children:Hr(bs)})]})]})]}),xa.length>0&&a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(l0,{onDragEnd:$r,children:a.jsx(c0,{droppableId:`lead-payoff-${e}-${L}`,children:ie=>a.jsxs("ul",{ref:ie.innerRef,...ie.droppableProps,className:"space-y-1.5 rounded-lg border border-border bg-muted/30 p-2",children:[xa.map((xe,He)=>{const rt=cr.get(xe);return a.jsx(d0,{draggableId:xe,index:He,children:(mt,Ft)=>a.jsxs("li",{ref:mt.innerRef,...h0(mt.draggableProps),className:Et("flex items-center justify-between gap-2 rounded-md border border-border/60 bg-card py-2 pl-2 pr-3 text-sm",Ft.isDragging&&"shadow-md ring-2 ring-primary/20"),children:[a.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[a.jsx("button",{type:"button",className:"touch-none text-muted-foreground hover:text-foreground",...mt.dragHandleProps,"aria-label":"Drag to reorder",children:a.jsx(u0,{className:"h-4 w-4 shrink-0"})}),a.jsx("span",{className:"truncate font-medium",children:rt.name}),a.jsx(xn,{variant:"outline",className:"hidden shrink-0 capitalize sm:inline-flex",children:String(rt.type).replace(/_/g," ")})]}),a.jsx("span",{className:"shrink-0 tabular-nums font-medium",children:Hr(Math.abs(Number(rt.current_balance)))})]})},xe)}),ie.placeholder]})})}),a.jsxs("div",{className:"flex items-center justify-between rounded-lg border border-border/60 bg-muted/30 px-3 py-2 text-sm font-semibold",children:[a.jsx("span",{children:"Payoff order total"}),a.jsx("span",{className:"tabular-nums",children:Hr(Qt)})]})]}),(Xr.length>0||xa.length>0)&&a.jsxs("div",{className:"flex items-center justify-between rounded-lg border border-border bg-card px-3 py-2 text-sm font-semibold",children:[a.jsx("span",{children:"Total"}),a.jsx("span",{className:"tabular-nums",children:Hr(vs)})]})]})]}
1196),a.jsx(Vb,{helocType:L,qualificationMetrics:l}),a.jsxs(rn,{children:[a.jsx($s,{className:"pb-3",children:a.jsx(Hs,{className:"text-lg font-semibold tracking-tight",children:L==="2nd_lien"?"Simulated HELOC / PLOC / HSF Terms":"Simulated HELOC Terms"})}),a.jsxs(on,{children:[a.jsxs("div",{className:Et("grid gap-4",L==="2nd_lien"?"grid-cols-2 md:grid-cols-4":"grid-cols-3"),children:[a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(Ke,{className:"text-xs",children:"Credit Limit"}),a.jsxs("div",{className:"relative",children:[a.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-sm text-muted-foreground",children:"$"}),a.jsx(Wt,{type:"number",min:0,inputMode:"numeric",value:Z===0?"":Z,onChange:ie=>{const xe=ie.target.value;le(xe===""?0:Number(xe))},className:"pl-7",placeholder:"0"})]}),Ht!=null&&Ht>0&&a.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[10px] text-muted-foreground",children:[a.jsxs("span",{children:["Est. max: $",Ht.toLocaleString(),L==="1st_lien"?` (${Wp}% LTV)`:" (CLTV room)"]}),Z!==Ht&&a.jsx("button",{type:"button",className:"font-medium text-primary underline-offset-2 hover:underline",onClick:Lt,children:"Use max"})]})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(Ke,{className:"text-xs",children:"Interest Rate (APR)"}),a.jsxs("div",{className:"relative",children:[a.jsx(Wt,{type:"number",step:"0.1",value:Ne,onChange:ie=>fe(L,{interestRate:Number(ie.target.value)}),className:"pr-7"}),a.jsx("span",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-sm text-muted-foreground",children:"%"})]}),L==="2nd_lien"&&a.jsx("p",{className:"text-[10px] text-muted-foreground",children:"For HSF, use 0% APR to model the same payoff flow without line-of-credit interest."})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(Ke,{className:"text-xs",children:"Existing HELOC Balance"}),a.jsxs("div",{className:"relative",children:[a.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-sm text-muted-foreground",children:"$"}),a.jsx(Wt,{type:"number",value:E,onChange:ie=>hr(Number(ie.target.value)),className:"pl-7",placeholder:"0"})]}),a.jsx("p",{className:"text-[10px] text-muted-foreground",children:L==="1st_lien"?"Added on top of mortgage + consolidated debts":"Added on top of consolidated amount"})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(Ke,{className:"text-xs",children:"Starting Balance"}),a.jsxs("div",{className:"relative",children:[a.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-sm text-muted-foreground",children:"$"}),a.jsx(Wt,{type:"number",value:A,onChange:ie=>fe(L,{startingBalance:Number(ie.target.value)}),className:"pl-7"})]}),L==="1st_lien"&&a.jsxs("p",{className:"text-[10px] text-muted-foreground",children:["Auto-set from mortgage + consolidated debts",E>0?" + existing HELOC balance":""]}),L==="2nd_lien"&&wt&&a.jsxs("p",{className:"text-[10px] text-muted-foreground",children:["Auto-set from consolidated debts",E>0?" + existing HELOC balance":""]}),A!==rr&&a.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[10px] text-muted-foreground",children:[a.jsxs("span",{children:["Calculated: $",rr.toLocaleString()]}),a.jsx("button",{type:"button",className:"font-medium text-primary underline-offset-2 hover:underline",onClick:Oa,children:"Use Calculated"})]})]}),L==="2nd_lien"&&a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(Ke,{className:"text-xs",children:"Chunk Size"}),a.jsxs("div",{className:"relative",children:[a.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-sm text-muted-foreground",children:"$"}),a.jsx(Wt,{type:"number",min:0,inputMode:"numeric",value:z!=null&&z>0?z:"",onChange:ie=>{const xe=ie.target.value;fe(L,{chunkSize:xe===""?null:Number(xe)})},className:"pl-7",placeholder:String(Math.max(0,Math.round(fr)))})]}),a.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Defaults to surplus"})]}),b&&a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(Ke,{className:"text-xs",children:"Reserves Used for Paydown"}),a.jsxs("div",{className:"relative",children:[a.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-sm text-muted-foreground",children:"$"}),a.jsx(Wt,{type:"number",step:"0.01",min:0,className:"pl-7",disabled:D,value:Number.isFinite(ce)?ce:0,onChange:ie=>$(Number(ie.target.value)),onBlur:()=>{k()}})]}),a.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Lump-sum cash at the strategy start date (not drawn on the line): offsets opening consolidated LOC balance first, then reduces unpaid debts in payoff order. Baseline min-payment comparison assumes this cash retires consolidated principal before the strategy."})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(Ke,{className:"text-xs",children:"Strategy Start Date"}),a.jsx(Wt,{type:"date",value:X,onChange:ie=>fe(L,{strategyStartDate:ie.target.value}),className:"block w-full"}),a.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Simulation and daily tracker begin on this date"})]})]}),a.jsxs("div",{className:"mt-4 flex flex-wrap items-center justify-between gap-y-1 border-t pt-3",children:[a.jsxs("div",{className:"flex flex-col gap-0.5",children:[a.jsxs("div",{className:"text-xs text-muted-foreground",children:["Monthly Surplus:"," ",a.jsxs("span",{className:Et("font-semibold",fr>0?"text-success":"text-destructive"),children:["$",Math.round(fr).toLocaleStr
1196ing()]})]}),wt&&(c.consolidatedPayments??0)>0&&a.jsxs("div",{className:"text-xs text-muted-foreground",children:["Monthly Cashflow Savings From Consolidation:"," ",a.jsxs("span",{className:"font-semibold text-success",children:["$",Math.round(c.consolidatedPayments).toLocaleString()]})]})]}),a.jsxs(st,{onClick:wr,size:"sm",className:"gap-1.5",disabled:fr<=0||Z<=0||qe||D,children:[qe?a.jsx(Kr,{className:"h-4 w-4 animate-spin"}):a.jsx(f0,{className:"h-4 w-4"}),qe?"Saving...":"Run & Save Calculation"]})]})]})]}),ye&&a.jsxs(qs,{variant:"destructive",children:[a.jsx(ms,{className:"h-4 w-4"}),a.jsx(ps,{children:ye})]}),ma&&a.jsxs(qs,{variant:"destructive",children:[a.jsx(ms,{className:"h-4 w-4"}),a.jsxs(ps,{children:[a.jsx("span",{className:"font-semibold",children:"Payoff results are out of date."})," ",zr," Any previously saved payoff for this scenario reflects different inputs and is hidden until the calculation can run again."]})]}),ts&&a.jsxs(qs,{children:[a.jsx(ms,{className:"h-4 w-4"}),a.jsx(ps,{children:"These numbers have not been saved yet. Run & Save Calculation so the strategy report and AI summary use the same figures shown here."})]}),Ct&&pa&&a.jsxs(rn,{className:"overflow-hidden rounded-2xl border border-border/80 bg-card shadow-sm",children:[a.jsxs($s,{className:"space-y-0 px-6 pb-2 pt-6",children:[a.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[a.jsx(Hs,{className:"text-lg font-bold tracking-tight text-foreground",children:"Accelerated Payoff Analysis"}),a.jsxs(xn,{variant:"outline",className:Et("h-7 shrink-0 gap-1.5 rounded-full border px-3 text-xs font-bold",pa.color),children:[a.jsx(pa.icon,{className:"h-3.5 w-3.5"}),pa.label]})]}),a.jsx("p",{className:"mt-3 max-w-[52rem] text-[10px] italic leading-snug text-muted-foreground",children:Td})]}),a.jsxs(on,{className:"space-y-5 px-6 pb-6 pt-4",children:[a.jsxs("div",{className:"grid grid-cols-1 gap-4 lg:grid-cols-2",children:[a.jsxs("div",{className:"space-y-5 rounded-xl border border-[#dc3545]/40 bg-[#dc3545]/[0.06] p-6",children:[a.jsx("p",{className:"text-sm font-bold text-[#dc3545]",children:"Baseline (Min. Payments)"}),a.jsxs("div",{className:"flex gap-4",children:[a.jsx(Pl,{className:"mt-0.5 h-5 w-5 shrink-0 text-foreground",strokeWidth:2}),a.jsxs("div",{className:"min-w-0 space-y-1.5",children:[a.jsx("p",{className:"text-[11px] leading-snug text-[#dc3545]/80",children:"Total interest (including estimated consumer debt interest)"}),a.jsxs("p",{className:"text-2xl font-bold tabular-nums tracking-tight text-[#dc3545]",children:["$",Ct.baselineInterest.toLocaleString()]})]})]}),a.jsxs("div",{className:"flex gap-4",children:[a.jsx(Vu,{className:"mt-0.5 h-5 w-5 shrink-0 text-foreground",strokeWidth:2}),a.jsxs("div",{className:"min-w-0 space-y-1.5",children:[a.jsx("p",{className:"text-[11px] text-[#dc3545]/80",children:"Time left"}),a.jsx("p",{className:"text-2xl font-bold tabular-nums tracking-tight text-[#dc3545]",children:Za(Ct.baselineMonths)})]})]}),a.jsxs("div",{className:"flex gap-4",children:[a.jsx(Wu,{className:"mt-0.5 h-5 w-5 shrink-0 text-foreground",strokeWidth:2}),a.jsxs("div",{className:"min-w-0 space-y-1.5",children:[a.jsx("p",{className:"text-[11px] text-[#dc3545]/80",children:"Paid off in"}),a.jsx("p",{className:"text-2xl font-bold tabular-nums tracking-tight text-[#dc3545]",children:Ct.baselinePayoffDisplay})]})]})]}),a.jsxs("div",{className:"space-y-5 rounded-xl border border-[#28a745]/40 bg-[#28a745]/[0.07] p-6",children:[a.jsx("p",{className:"text-sm font-bold text-[#28a745]",children:"Accelerated Payoff"}),a.jsxs("div",{className:"flex gap-4",children:[a.jsx(Pl,{className:"mt-0.5 h-5 w-5 shrink-0 text-foreground",strokeWidth:2}),a.jsxs("div",{className:"min-w-0 space-y-1.5",children:[a.jsx("p",{className:"text-[11px] leading-snug text-[#28a745]/80",children:"New total interest (including all consumer debt being paid)"}),a.jsxs("p",{className:"text-2xl font-bold tabular-nums tracking-tight text-[#28a745]",children:["$",Ct.acceleratedInterest.toLocaleString()]})]})]}),a.jsxs("div",{className:"flex gap-4",children:[a.jsx(Vu,{className:"mt-0.5 h-5 w-5 shrink-0 text-foreground",strokeWidth:2}),a.jsxs("div",{className:"min-w-0 space-y-1.5",children:[a.jsx("p",{className:"text-[11px] text-[#28a745]/80",children:"Time left"}),a.jsx("p",{className:"text-2xl font-bold tabular-nums tracking-tight text-[#28a745]",children:Za(Ct.acceleratedMonths)})]})]}),a.jsxs("div",{className:"flex gap-4",children:[a.jsx(Wu,{className:"mt-0.5 h-5 w-5 shrink-0 text-foreground",strokeWidth:2}),a.jsxs("div",{className:"min-w-0 space-y-1.5",children:[a.jsx("p",{className:"text-[11px] text-[#28a745]/80",children:"Paid off in"}),a.jsx("p",{className:"text-2xl font-bold tabular-nums tracking-tight text-[#28a745]",children:Ct.acceleratedPayoffDisplay})]})]})]})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(cd,{icon:a.jsx(ac,{className:"h-4 w-4"}),title:"Time Saved",value:Kp(Ct.monthsSaved),detailContent:Ct.timeSavedByDebt&&Ct.timeSavedByDebt.length>0?a.jsx(mv,{rows:Ct.timeSavedByDebt}):void 0,footnote:"Total calendar time saved: baseline minimum-payment payoff minus accelerated strategy payoff (all debts in this analysis). Per-debt rows show each debt’s own baseline timeline vs. strategy payoff."}),a.jsx(cd,{icon:a.jsx(Pl,{className:"h-4 w-4"}),title:"Interest Saved",value:Ct.interestSavedDisplay,detailContent:a.jsx(pv,{baselineInterest:Ct.baselineInterest,acceleratedInterest:Ct.acceleratedInterest,interestSaved:Ct.interestSaved}),footnote:"Total interest saved: baseline minimum-payment interest minus total interest under the accelerated strategy (including HELOC interest on consolidated debts)."}),a.jsx(cd,{icon:a.jsx(xd,{className:"h-4 w-4"}),title:"Total Monthly Payment Savings",value:Ct.paymentsSaved!=null&&Ct.paymentsSaved>
11960?`$${Math.round(Ct.paymentsSaved).toLocaleString()} / mo`:"—",valueClassName:Ct.paymentsSaved!=null&&Ct.paymentsSaved>0?ru:"text-muted-foreground",footnote:"Sum of debt payments plus mortgage P&I and PMI that go away after payoff. Property taxes and homeowners insurance remain due and are excluded."}),Ct.tipSavings?a.jsx(xv,{mortgageTipPct:Ct.tipSavings.mortgageTipPct,helocTipPct:Ct.tipSavings.helocTipPct,tipSavedPct:Ct.tipSavings.tipSavedPct}):a.jsx(yv,{}),Array.isArray(Ct.baselineByDebt)&&Ct.baselineByDebt.length>0&&a.jsx(Wf,{title:"Baseline by Debt (minimum payments)",children:a.jsx("div",{className:"border-t border-border/60 bg-muted/10 p-3",children:a.jsxs("table",{className:"w-full text-sm",children:[a.jsx("thead",{children:a.jsxs("tr",{className:"text-left text-xs text-muted-foreground",children:[a.jsx("th",{className:"pb-2 pr-2 font-medium",children:"Debt"}),a.jsx("th",{className:"pb-2 pr-2 font-medium",children:"Months to payoff"}),a.jsx("th",{className:"pb-2 text-right font-medium",children:"Interest (baseline)"})]})}),a.jsx("tbody",{children:Ct.baselineByDebt.map(ie=>a.jsxs("tr",{className:"border-t border-border/40",children:[a.jsx("td",{className:"py-1.5 pr-2 font-medium text-foreground",children:ie.name}),a.jsx("td",{className:"py-1.5 pr-2 tabular-nums text-muted-foreground",children:Za(ie.months)}),a.jsxs("td",{className:"py-1.5 text-right font-medium tabular-nums text-foreground",children:["$",ie.interest.toLocaleString()]})]},ie.id))})]})})}),ga.length>0&&a.jsx(Wf,{title:`Debts included in this analysis (${ga.length})`,children:a.jsx("div",{className:"space-y-1.5 border-t border-border/60 bg-muted/20 p-3",children:ga.map(ie=>a.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-border/40 py-1.5 last:border-0",children:[a.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[a.jsx("span",{className:"truncate text-sm font-medium text-foreground",children:ie.name}),a.jsx(xn,{variant:"outline",className:"shrink-0 text-[11px] capitalize",children:ie.type})]}),a.jsxs("span",{className:"shrink-0 text-sm font-medium tabular-nums text-foreground",children:["$",ie.balance.toLocaleString()]})]},ie.id))})})]})]})]}),Sa>0&&a.jsx(rn,{className:"border-destructive/30 bg-destructive/5",children:a.jsx(on,{className:"pb-4 pt-5",children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"rounded-full bg-destructive/15 p-2.5",children:a.jsx(ms,{className:"h-5 w-5 text-destructive"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-xs font-medium uppercase tracking-wide text-destructive",children:"Interest Cost Next Month If You Do Nothing Today"}),a.jsxs("p",{className:"text-2xl font-bold text-destructive",children:["$",Math.round(Sa).toLocaleString()]}),a.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground",children:"Includes consumer debt interest, including debts selected for consolidation"})]})]})})})]})};function Nv(e){const t=e.mortgage_term_years||30,n=Math.max(1,t*12),r=e.mortgage_interest_rate||0;return e.original_mortgage_balance>0?fi(Gu(e.original_mortgage_balance,r,n)):e.outstanding_mortgage_balance>0?fi(Gu(e.outstanding_mortgage_balance,r,n)):null}function jv(e,t,n){if(e<=0)return{rows:[],error:null};if(n<=0)return{rows:[],error:"Could not determine a monthly principal & interest payment from this property."};const r=t/100/12,s=e*r;if(n+1e-6<s)return{rows:[],error:"The computed P&I is less than interest on the current balance. Check original balance, outstanding balance, rate, and term."};const i=p0(e,t,n,new Date);let c=0;return{rows:i.map(d=>(c+=d.interest,{...d,cumulativeInterest:c})),error:null}}function Sv(e){const t=[e.street_address,[e.city,e.state].filter(Boolean).join(", "),e.zip_code].filter(Boolean);return t.length>0?t.join(" · "):"Focus property"}const Lv=({focusProperty:e})=>{const{rows:t,error:n,summary:r}=J.useMemo(()=>{if(!e)return{rows:[],error:null,summary:null};const i=Number(e.outstanding_mortgage_balance)||0;let c=Nv(e);c===null&&i>0&&e.mortgage_payment>0&&(c=fi(e.mortgage_payment));const l=Number(e.mortgage_interest_rate)||0,d=e.mortgage_term_years||30,h=Sv(e),{rows:f,error:x}=jv(i,l,c??0),b={address:h,ratePct:l,termYears:d,monthlyPi:c,startingBalance:i,totalInterest:f.reduce((m,w)=>m+w.interest,0),payoffPayments:f.length};return{rows:f,error:x,summary:b}},[e]);return e?(Number(e.outstanding_mortgage_balance)||0)<=0?a.jsx(rn,{children:a.jsx(on,{className:"py-8 text-center text-muted-foreground text-sm",children:"No outstanding mortgage balance on the focus property — there is nothing to amortize."})}):n?a.jsxs(rn,{children:[a.jsxs($s,{className:"pb-2",children:[a.jsx(Hs,{className:"text-base",children:"Focus property mortgage"}),a.jsx(Cl,{children:(r==null?void 0:r.address)??"Focus property"})]}),a.jsx(on,{className:"text-sm text-destructive",children:n})]}):t.length===0?a.jsx(rn,{children:a.jsx(on,{className:"py-8 text-center text-muted-foreground text-sm",children:"Could not build an amortization schedule from the current fields."})}):a.jsxs("div",{className:"space-y-4",children:[a.jsxs(rn,{children:[a.jsxs($s,{className:"pb-2",children:[a.jsxs(Hs,{className:"text-base",children:[String(e.property_type??"property").replace(/_/g," ")," — P&I amortization"]}),a.jsxs(Cl,{children:[r.address,". Schedule starts from the current outstanding balance using the same P&I as elsewhere in intake (from original loan amount when available). Taxes, insurance, and escrow are not included."]})]}),a.jsxs(on,{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-4 text-sm",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-muted-foreground text-xs",children:"Starting balance"}),a.jsx("p",{className:"font-semibold",children:Fs(r.startingBalance)})]}),a.jsxs("div",{children:[a.jsx("p",{className:"text-muted-foreground text-xs",children:"Rate / Term"}),a.jsxs("p",{className:"font-semibold",children:[r.ratePct,"% · ",r.termYears," yr"]})]}),a.jsxs("div",{children:[a.jsx("p",{className:"text-muted-foreground text-xs",children:"Monthly P&I"}),a.jsx("p",{className:"font-semibold",children:r.monthlyPi!=null?Fs(r.monthlyPi):"—"})]}),a.jsxs("div",{children:[a.jsx("p",{className:"text-muted-foreground text-xs",children:"Total interest (remaining)"}),a.jsx("p",{className:"font-semibold",children:Fs(r.totalInterest)}),a.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[r.payoffPayments," payments to payoff"]})]})]})]}),a.jsxs(rn,{children:[a.jsxs($s,{className:"pb-2",children:[a.jsx(Hs,{className:"text-base",children:"Amortization table"}),a.jsx(Cl,{children:"Ending balance after each payment; interest is cumulative over the schedule."})]}),a.jsx(on,{className:"p-0 sm:p-6 pt-0",children:a.jsx(ym,{className:"h-[min(60vh,520px)] w-full rounded-md border",children:a.jsxs($o,{children:[a.jsx(Ho,{children:a.jsxs(Yr,{children:[a.jsx(In,{className:"w-14",children:"#"}),a.jsx(In,{className:"min-w-[88px]",children:"Month"}),a.jsx(In,{className:"text-right",children:"P&I"}),a.jsx(In,{className:"text-right",children:"Principal"}),a.jsx(In,{className:"text-right",children:"Interest"}),a.jsx(In,{className:"text-right",children:"Balance"}),a.jsx(In,{className:"text-right min-w-[120px]",children:"Interest (cumulative)"})]})}),a.jsx(Uo,{children:t.map(i=>a.jsxs(Yr,{children:[a.jsx(Ut,{className:"text-muted-foreground",children:i.month}),a.jsx(Ut,{className:"whitespace-nowrap",children:ji(i.date,"MMM yyyy")}),a.jsx(Ut,{className:"text-right tabular-nums",children:Fs(i.payment)}),a.jsx(Ut,{className:"text-right tabular-nums",children:Fs(i.principal)}),a.jsx(Ut,{className:"text-right tabular-nums",children:Fs(i.interest)}),a.jsx(Ut,{className:"text-right tabular-nums font-medium",children:Fs(i.balance)}),a.jsx(Ut,{className:"text-right tabular-nums text-muted-foreground",children:Fs(i.cumulativeInterest)})]},i.month))})]})})})]})]}):a.jsx(rn,{children:a.jsx(on,{className:"py-8 text-center text-muted-foreground text-sm",children:"Add a property and select it as the focus property to see its mortgage amortization."})})},Av=({item:e})=>a.jsxs("div",{className:Et("flex items-center gap-2 rounded-xl border px-2.5 py-2",e.pass?"border-success/20 bg-success/10":"border-destructive/20 bg-destructive/10"),children:[e.pass?a.jsx(Wd,{className:"h-4 w-4 shrink-0 text-success"}):a.jsx(Kl,{className:"h-4 w-4 shrink-0 text-destructive"}),a.jsxs("div",{className:"min-w-0",children:[a.jsx("p",{className:"text-[10px] leading-tight text-muted-foreground",children:e.label}),a.jsx("p",{className:Et("text-sm font-semibold leading-tight",e.pass?"text-success":"text-destructive"),children:e.detail})]})]}),kv=({items:e})=>{const[t,n]=J.useState(!0);return a.jsxs("div",{className:"pointer-events-none fixed right-0 top-1/2 z-40 flex -translate-y-1/2 items-stretch",children:[a.jsx("button",{type:"button",onClick:()=>n(!t),className:Et("pointer-events-auto flex w-6 items-center justify-center rounded-l-xl border border-r-0 border-border/80 bg-card/95 shadow-md transition-colors hover:bg-accent","focus:outline-none focus-visible:ring-2 focus-visible:ring-ring"),"aria-label":t?"Collapse qualifications":"Expand qualifications",children:t?a.jsx(g0,{className:"h-4 w-4 text-muted-foreground"}):a.jsx(x0,{className:"h-4 w-4 text-muted-foreground"})}),a.jsx("div",{className:Et("pointer-events-auto overflow-hidden rounded-l-2xl border border-border/80 bg-card/95 shadow-xl backdrop-blur transition-all duration-200",t?"w-44 opacity-100":"w-0 border-0 opacity-0 shadow-none"),children:a.jsxs("div",{className:"w-44 p-3",children:[a.jsx("h3",{className:"mb-3 whitespace-nowrap text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:"Qu
1196ick Qualifications"}),a.jsx("div",{className:"flex flex-col gap-2",children:e.map(r=>a.jsx(Av,{item:r},r.label))})]})})]})};function Cv(e){return Math.max(0,e.baseline.totalMonths-e.accelerated.totalMonths)||Math.max(0,e.savings.monthsSaved)}function Kf(e,t){const n=e.savings.paymentsSaved!=null&&Number.isFinite(e.savings.paymentsSaved)?Math.round(e.savings.paymentsSaved):void 0;return{baseline:{monthsToPayoff:e.baseline.totalMonths,totalInterest:Math.round(e.baseline.totalInterest)},accelerated:{monthsToPayoff:e.accelerated.totalMonths,totalInterest:Math.round(e.accelerated.totalInterest)},timeSavedMonths:Cv(e),interestSavedDollars:Math.round(e.savings.interestSaved),tipSavedPct:t==null?void 0:t.tipSavedPct,monthlyPaymentSavingsDollars:(t==null?void 0:t.monthlyPaymentsSaved)??n}}function Qf(e){return e.baseline_months==null||e.accelerated_months==null?null:{baseline:{monthsToPayoff:e.baseline_months,totalInterest:Math.round(Number(e.baseline_interest??0))},accelerated:{monthsToPayoff:e.accelerated_months,totalInterest:Math.round(Number(e.accelerated_interest??0))},timeSavedMonths:Math.max(0,Number(e.months_saved??0)),interestSavedDollars:Math.round(Number(e.interest_saved??0))}}const Pv=[/does not produce time or interest savings/i,/Stress-test removes modeled savings/i,/prevents amortization/i];function Ev(e){const t=Math.floor(e/12),n=e%12;return t>0?`${t} year${t>1?"s":""}${n>0?` ${n} month${n>1?"s":""}`:""}`:`${n} month${n!==1?"s":""}`}function Mv(e,t,n,r){return Iv(e,t,n)}function Iv(e,t,n){var b,m,w;if(!t)return e;const r=t.interestSavedDollars??0,s=t.timeSavedMonths??0,i=r>=1e3&&s>=12,c=r>0||s>0,l=n==="viable"||i;let d=((b=e.strategyDecision)==null?void 0:b.status)??"conditional";l?d="go":c?d="conditional":n==="not_viable"&&(d="no-go");const f=[c?`Lead Calculator (velocity model): $${r.toLocaleString()} interest saved, ${Ev(s)} faster than minimum payments`:"Lead Calculator: run or save results to confirm projected savings",...(((m=e.strategyDecision)==null?void 0:m.primaryReasons)??[]).filter(v=>!/^Model shows interest savings/i.test(v))],x=(((w=e.strategyDecision)==null?void 0:w.secondaryNotes)??[]).filter(v=>!Pv.some(P=>P.test(v)));return{...e,payoffComparison:t,strategyDecision:{status:d,primaryReasons:f,secondaryNotes:x}}}function Jf(e){return["lead-suggested-lenders",e]}function Fv(e,t=!0){const{user:n}=vi(),{toast:r}=Ir(),s=ys(),i=ha({queryKey:Jf(e),queryFn:async()=>{if(!e)return[];const{data:d,error:h}=await nt.from("lead_intake_scenario_suggested_lenders").select("*").eq("scenario_id",e);if(h)throw h;return d??[]},enabled:!!(n&&e&&t)}),c=new Set((i.data??[]).map(d=>km(d.lender_id,d.program_id))),l=Bs({mutationFn:async({lenderId:d,programId:h,selected:f})=>{if(!e)throw new Error("No intake scenario");if(f){const{error:x}=await nt.from("lead_intake_scenario_suggested_lenders").upsert({scenario_id:e,lender_id:d,program_id:h,selected_by:(n==null?void 0:n.id)??null},{onConflict:"scenario_id,lender_id,program_id"});if(x)throw x}else{const{error:x}=await nt.from("lead_intake_scenario_suggested_lenders").delete().eq("scenario_id",e).eq("lender_id",d).eq("program_id",h);if(x)throw x}},onSuccess:()=>{s.invalidateQueries({queryKey:Jf(e)})},onError:d=>{r({title:"Failed to save lender selection",description:Am(d),variant:"destructive"})}});return{rows:i.data??[],selectedKeys:c,isLoading:i.isLoading,loadError:i.error,isSaving:l.isPending,setSelected:l.mutate}}const Tv={heloc:"HELOC",ploc:"PLOC",home_equity_loan:"Home Equity Loan",other:"Other"};function Dv(e){return e>=1?"Full Match":e>=.7?"Partial Match":"Does Not Qualify"}function Rv(e,t){var r,s,i,c;const n=[];for(let l=0;l<e.length;l++){const d=e[l],h=Cm(d,l);if(!t.has(h))continue;const f=((r=d.program)==null?void 0:r.program_name)??"Default",x=((s=d.program)==null?void 0:s.program_type)??"";n.push({lenderName:d.lender.name,programName:f,programTypeLabel:Tv[x]||x||"Program",contactInfo:((i=d.lender.notes)==null?void 0:i.trim())||null,websiteUrl:((c=d.lender.website_url)==null?void 0:c.trim())||null,matchSummary:`${Dv(d.score)} (${d.metCriteria}/${d.totalCriteria})`})}return n}function Bv({startingBalance:e,existingHelocBalance:t,calculatedStartingBalance:n,initialChunkSize:r}){const s=Math.max(0,Number(e)||0,Number(t)||0,Number(n)||0),i=Math.max(0,Number(r)||0);return s+i}function Xf({mode:e,stressPayment:t,drawnBalance:n,inputAnnualRatePct:r}){if(e==="stress")return Math.max(0,Number(t)||0);const s=Math.max(0,Number(n)||0),i=Math.max(0,Number(r)||0);return s*(i/100/12)}function Ov(e,t,n){return`Strategy IO on ${(n??0)>0?`${Dt(e)} drawn (incl. first chunk)`:`${Dt(e)} drawn`} @ ${t.toFixed(2)}%`}function qv(e){return{monthlyNetIncome:e.monthlyNetIncome,combinedNetIncome:e.displayedCombinedNetIncome,totalMonthlyExpenses:e.totalExpenses,estimatedMonthlyCashFlow:e.inputCashflow,netRentalCf:e.netRentalCf,primaryMortgagePayment:e.displayedPitiPayment,primaryTaxesInsurance:e.primaryTaxesInsurance,hoaMonthly:e.hoaMonthly,selectedHelocType:e.selectedHelocType,selectedHelocPayment:e.inputHelocPayment,helocPaymentSub:Ov(e.dis
1196playedDrawnBalance,e.inputAnnualRatePct,e.initialChunkSize),heloc1st:e.heloc1st,hasConsolidation:e.hasConsolidation,nonConsolidatedDebtPayments:e.nonConsolidatedDebtPayments,totalMinimumDebtPayments:e.totalMinimumDebtPayments,baseCashflow:e.baseCashflow}}function zv(e){const t=[];for(const n of e??[]){if(n.is_active===!1)continue;const r=n.programs??n.lender_programs??[];for(const s of r){if(s.is_active===!1)continue;const i=Number(s.min_fico);Number.isFinite(i)&&i>0&&t.push(i)}}return t}function $v(e,t){if(!(e>0))return!1;const n=zv(t);return n.length===0?!1:n.some(r=>e>=r)}const Qp=e=>e==="baseline"||e==="exit"||e==="restore"||e==="manual",Hv=e=>{if(!e||typeof e!="object")return null;const t=e;return typeof t.id!="string"||typeof t.created_at!="string"?null:{id:t.id,created_at:t.created_at,created_by:typeof t.created_by=="string"?t.created_by:null,trigger:Qp(t.trigger)?t.trigger:String(t.trigger??"exit"),label:typeof t.label=="string"?t.label:null,restored_from_version_id:typeof t.restored_from_version_id=="string"?t.restored_from_version_id:null,actor_display_name:typeof t.actor_display_name=="string"?t.actor_display_name:null,actor_email:typeof t.actor_email=="string"?t.actor_email:null}},au=e=>["lead-intake-scenario-versions",e],Uv=e=>["lead-intake-scenario-version",e],Jp=(e,t=!0)=>{const{user:n}=vi();return ha({queryKey:au(e),queryFn:async()=>{const{data:r,error:s}=await nt.rpc("list_lead_intake_scenario_versions",{p_scenario_id:e});if(s)throw s;return(Array.isArray(r)?r:[]).map(Hv).filter(i=>i!=null)},enabled:!!(n&&e&&t)})},Zf=(e,t=!0)=>{const{user:n}=vi();return ha({queryKey:Uv(e),queryFn:async()=>{const{data:r,error:s}=await nt.from("lead_intake_scenario_versions").select("id, lead_id, scenario_id, created_at, created_by, trigger, label, content_hash, snapshot, restored_from_version_id").eq("id",e).maybeSingle();if(s)throw s;if(!r)return null;const i=h1(r.snapshot,r.scenario_id);return i?{id:r.id,lead_id:r.lead_id,scenario_id:r.scenario_id,created_at:r.created_at,created_by:r.created_by,trigger:(Qp(r.trigger),r.trigger),label:r.label,restored_from_version_id:r.restored_from_version_id,content_hash:r.content_hash,actor_display_name:null,actor_email:null,snapshot:i}:null},enabled:!!(n&&e&&t)})};async function em(e,t,n){const{data:r,error:s}=await nt.rpc("snapshot_lead_intake_scenario",{p_scenario_id:e,p_trigger:t,p_label:void 0});if(s)throw s;return typeof r=="string"?r:null}function Vv(e,t){const n=ys(),{toast:r}=Ir();return Bs({mutationFn:async({versionId:s,restoreLeadContact:i,scope:c})=>{const{data:l,error:d}=await nt.rpc("restore_lead_intake_scenario",{p_version_id:s,p_restore_lead_contact:c==="lead"?!0:i,p_scope:c});if(d)throw d;return l},onSuccess:async(s,i)=>{await Promise.all([n.invalidateQueries({queryKey:["lead-intake-scenarios",e]}),n.invalidateQueries({queryKey:["lead-assessment",e]}),n.invalidateQueries({queryKey:["lead-properties",e]}),n.invalidateQueries({queryKey:["lead-debts",e]}),n.invalidateQueries({queryKey:["lead-expenses",e]}),n.invalidateQueries({queryKey:["lead-additional-clients",e]}),n.invalidateQueries({queryKey:["leads"]}),n.invalidateQueries({queryKey:["lead-calculator-result-strategy-pdf"]}),n.invalidateQueries({queryKey:["lead-calculator-result-ai"]}),n.invalidateQueries({queryKey:["lead-calculator-results-history"]}),n.invalidateQueries({queryKey:["lead-ai-analysis-history"]}),n.invalidateQueries({queryKey:["lead-intake-scenario-versions"]}),n.invalidateQueries({queryKey:["lead-intake-scenario-version"]}),n.invalidateQueries({queryKey:au(t)})]),r({title:i.scope==="lead"?"Entire record restored":"Version restored"})},onError:s=>{r({title:"Restore failed",description:s instanceof Error?s.message:"Could not restore this version.",variant:"destructive"})}})}function Wv(e){const t=ys(),{toast:n}=Ir();return Bs({mutationFn:async({versionId:r,label:s})=>{const{error:i}=await nt.from("lead_intake_scenario_versions").update({label:s}).eq("id",r);if(i)throw i},onSuccess:()=>{t.invalidateQueries({queryKey:au(e)})},onError:r=>{n({title:"Could not name version",description:r instanceof Error?r.message:"Please try again.",variant:"destructive"})}})}function qd(e){var t,n;return((t=e.actor_display_name)==null?void 0:t.trim())||((n=e.actor_email)==null?void 0:n.trim())||"Unknown user"}function tm(e){const t=vm(e);return sc(t)?ji(t,"h:mm a"):"Unknown time"}function Gv(e){const t=vm(e);return sc(t)?ji(t,"EEEE, MMM d, yyyy"):"Unknown date"}function Yv(e){var t;return(t=e.label)!=null&&t.trim()?e.label.trim():e.trigger==="restore"?"Restored from a previous version":e.trigger==="baseline"?"Baseline":e.trigger==="manual"?"Named checkpoint":"Saved on exit"}function Kv({open:e,onOpenChange:t,scenarioId:n,selectedVersionId:r,onSelectVersion:s,compareMode:i,onCompareModeChange:c,compareVersionId:l,onCompareVersionIdChange:d,onRestore:h}){const{data:f=[],isLoading:x,error:b}=Jp(n,e),m=Wv(n),[w,v]=J.useState(null),P=J.useMemo(()=>{const _=new Map;for(const q of f){const T=Gv(q.created_at),B=_.get(T)??[];B.push(q),_.set(T,B)}return[..._.entries()]},[f]);return f.find(_=>_.id===r),a.jsx(y0,{open:e,onOpenChange:t,children:a.jsxs(b0,{side:"right",className:"flex w-full flex-col gap-0 p-0 sm:max-w-md",children:[a.jsxs(v0,{className:"border-b border-border px-6 py-4 text-left",children:[a.jsxs(_0,{className:"flex items-center gap-2 text-base",children:[a.jsx(bm,{className:"h-4 w-4 text-muted-foreground","aria-hidden":!0}),"Version history"]}),a.jsx(w0,{children:"Open a past checkpoint of this scenario. Restore can replace only this tab, or the entire lead record (all scenarios plus contact)."})]}),a.jsxs("div",{className:"space-y-3 border-b border-border px-6 py-3",children:[a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(Ke,{className:"text-xs",children:"Compare to"}),a.jsxs(Ka,{value:i,onValueChange:_=>c(_),children:[a.jsx(Qa,{className:"h-9",children:a.jsx(Ja,{})}),a.jsxs(Xa,{children:[a.jsx(Mr,{value:"previous",children:"Previous version"}),a.jsx(Mr,{value:"current",children:"Current (live)"}),a.jsx(Mr,{value:"picked",children:"Picked version"})]})]})]}),i==="picked"?a.jsxs(Ka,{value:l??"",onValueChange:_=>d(_||null),children:[a.jsx(Qa,{className:"h-9",children:a.jsx(Ja,{placeholder:"Choose a version"})}),a.jsx(Xa,{children:f.filter(_=>_.id!==r).map(_=>a.jsxs(Mr,{value:_.id,children:[tm(_.created_at)," · ",qd(_)]},_.id))})]}):null,a.jsx(st,{type:"button",className:"w-full",disabled:!r,onClick:h,children:"Restore this version"})]}),a.jsxs(ym,{className:"flex-1 px-6 py-4",children:[x?a.jsxs("div",{className:"flex items-center justify-center gap-2 py-12 text-sm text-muted-foreground",children:[a.jsx(Kr,{className:"h-4 w-4 animate-spin","aria-hidden":!0}),"Loading history…"]}):null,b?a.jsx("p",{className:"py-8 text-center text-sm text-destructive",children:b instanceof Error?b.message:"Failed to load history"}):null,!x&&!b&&f.length===0?a.jsx("p",{className:"py-8 text-center text-sm text-muted-foreground",children:"No versions yet."}):null,a.jsx("div",{className:"space-y-5",children:P.map(([_,q])=>a.jsxs("section",{children:[a.jsx("h3",{className:"mb-2 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:_}),a.jsx("ul",{className:"space-y-2",children:q.map(T=>{const B=T.id===r;return a.jsxs("li",{children:[a.jsxs("button",{type:"button",className:Et("w-full rounded-lg border px-3 py-2.5 text-left text-xs transition-colors",B?"border-primary/50 bg-primary/10":"border-border bg-muted/20 hover:bg-muted/40"),onClick:()=>s(B?null:T.id),"data-intake-version-trigger":T.trigger,children:[a.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[a.jsx("time",{className:"font-medium text-foreground",dateTime:T.created_at,children:tm(T.created_at)}),a.jsxs("span",{className:"text-muted-foreground",children:["by ",a.jsx("span",{className:"font-semibold text-foreground",children:qd(T)})]})]}),a.jsx("p",{className:"mt-1 text-muted-foreground",children:Yv(T)})]}),B?a.jsx("div",{className:"mt-1 flex justify-end",children:a.jsx(st,{type:"button",variant:"ghost",size:"sm",className:"h-7 text-xs",onClick:()=>{const Q=typeof window<"u"?window.prompt("Name this version",T.label??""):T.label;Q!==null&&(v(T.id),m.mutateAsync({versionId:T.id,label:Q.trim()||null}).finally(()=>v(null)))},disabled:w===T.id&&m.isPending,children:"Name this version"})}):null]},T.id)})})]},_))})]})]})})}function Qv({open:e,onOpenChange:t,onConfirm:n,isPending:r}){const[s,i]=J.useState("scenario"),[c,l]=J.useState(!1),[d,h]=J.useState(!1),f=J.useRef(!1),x=s==="lead",b=r||d,m=()=>{f.current=!1,h(!1),i("scenario"),l(!1)};return a.jsx(Ql,{open:e,onOpenChange:w=>{w||m(),t(w)},children:a.jsxs(Jl,{children:[a.jsxs(Xl,{children:[a.jsx(Zl,{children:"Restore this version?"}),a.jsx(ec,{children:s==="lead"?"This rolls the entire lead file back to this checkpoint: every scenario tab, plus contact and household members. Scenario tabs created after this version are removed.":"This replaces only the current scenario tab. Other scenario tabs stay as they are. Contact and household members are not changed unless you opt in."})]}),a.jsxs(gm,{value:s,onValueChange:w=>i(w),className:"gap-3","aria-label":"Restore scope",disabled:b,children:[a.jsxs("div",{className:"flex items-start gap-2",children:[a.jsx(To,{value:"scenario",id:"restore-scope-scenario",className:"mt-0.5"}),a.jsxs(Ke,{htmlFor:"restore-scope-scenario",className:"cursor-pointer space-y-0.5 font-normal leading-snug",children:[a.jsx("span",{className:"block text-sm font-medium text-foreground",children:"This scenario only"}),a.jsx("span",{className:"block text-xs text-muted-foreground",children:"Undo this tab. Other tabs are left alone."})]})]}),a.jsxs("div",{className:"flex items-start gap-2",children:[a.jsx(To,{value:"lead",id:"restore-scope-lead",className:"mt-0.5"}),a.jsxs(Ke,{htmlFor:"restore-scope-lead",className:"cursor-pointer space-y-0.5 font-normal leading-snug",children:[a.jsx("span",{className:"block text-sm font-medium text-foreground",children:"Entire record (all scenarios + contact)"}),a.jsx("span",{className:"block text-xs text-muted-foreground",children:"Google Sheets–style undo for the whole lead file."})]})]})]}),a.jsxs("div",{className:Et("flex items-start gap-2",x&&"opacity-70"),children:[a.jsx(lo,{id:"restore-lead-contact",checked:x||c,disabled:x,onCheckedChange:w=>l(w===!0)}),a.jsx(Ke,{htmlFor:"restore-lead-contact",className:Et("text-sm font-normal leading-snug",x&&"cursor-default"),children:x?"Contact and household members are always restored with the entire record":"Also restore contact / household members"})]}),a.jsxs(tc,{children:[a.jsx(st,{type:"button",variant:"outline",disabled:b,onClick:()=>t(!1),children:"Cancel"}),a.jsx(st,{type:"button",disabled:b,onClick:()=>{f.current||r||(f.current=!0,h(!0),n({restoreLeadContact:x||c,scope:s}))},children:b?a.jsxs(a.Fragment,{children:[a.jsx(Kr,{className:"mr-2 h-4 w-4 animate-spin"}),"Restoring…"]}):s==="lead"?"Restore entire record":"Restore this scenario"})]})]})})}function Jv(e,t){fetch("https://rhhrijqyyvtoeqfuxjou.supabase.co/rest/v1/rpc/snapsh
1196ot_lead_intake_scenario",{method:"POST",headers:{Authorization:`Bearer ${t}`,apikey:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InJoaHJpanF5eXZ0b2VxZnV4am91Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjQ4MzY1NzcsImV4cCI6MjA4MDQxMjU3N30.Y4C9KNoRN_2KtVQhw-HyeE_VkjenlZD907Ww48HcH5Y","Content-Type":"application/json",Prefer:"return=minimal"},body:JSON.stringify({p_scenario_id:e,p_trigger:"exit"}),keepalive:!0})}function Xv(e){const t=Kd(),n=J.useRef(e);n.current=e;const r=J.useRef(null);J.useEffect(()=>{nt.auth.getSession().then(({data:l})=>{var d;r.current=((d=l.session)==null?void 0:d.access_token)??null});const{data:c}=nt.auth.onAuthStateChange((l,d)=>{r.current=(d==null?void 0:d.access_token)??null});return()=>c.subscription.unsubscribe()},[]),J.useEffect(()=>{e&&em(e,"baseline").catch(()=>{})},[e]),J.useEffect(()=>{const c=()=>{const d=n.current,h=r.current;!d||!h||Jv(d,h)},l=()=>{document.visibilityState==="hidden"&&c()};return window.addEventListener("pagehide",c),document.addEventListener("visibilitychange",l),()=>{window.removeEventListener("pagehide",c),document.removeEventListener("visibilitychange",l)}},[]);const s=J.useCallback(async(c,l="exit")=>{c&&await em(c,l)},[]),i=J.useCallback(async c=>t&&!await t.confirmLeave()?!1:(await s(c),!0),[t,s]);return{snapshotExit:s,confirmAndSnapshot:i}}function ln(e,t=0){const n=Number(e);return Number.isFinite(n)?n:t}function hi(e){return typeof e=="string"?e:e==null?null:String(e)}function Zv(e,t){return e?{id:String(e.id??""),lead_id:t,scenario_id:typeof e.scenario_id=="string"?e.scenario_id:void 0,is_self_employed:!!e.is_self_employed,is_us_citizen:e.is_us_citizen==null?null:!!e.is_us_citizen,citizenship_status:hi(e.citizenship_status),is_military_veteran:e.is_military_veteran==null?null:!!e.is_military_veteran,yearly_gross_income:ln(e.yearly_gross_income),monthly_net_income:ln(e.monthly_net_income),fico_score:e.fico_score==null?null:ln(e.fico_score),savings_balance:ln(e.savings_balance),retirement_balance:ln(e.retirement_balance),other_assets:ln(e.other_assets),additional_notes:hi(e.additional_notes),reserves_for_paydown:ln(e.reserves_for_paydown),consolidation_ltv_percent:e.consolidation_ltv_percent==null?void 0:ln(e.consolidation_ltv_percent),most_recent_year_gross:ln(e.most_recent_year_gross),prior_year_gross:ln(e.prior_year_gross),added_gross_income:ln(e.added_gross_income),financial_deal_breakers:e.financial_deal_breakers??null}:null}function e_(e,t){return e.map(n=>({id:String(n.id??""),lead_id:t,scenario_id:typeof n.scenario_id=="string"?n.scenario_id:void 0,property_type:String(n.property_type??"primary_residence"),classification:hi(n.classification),estimated_value:ln(n.estimated_value),original_mortgage_balance:ln(n.original_mortgage_balance),outstanding_mortgage_balance:ln(n.outstanding_mortgage_balance),mortgage_payment:ln(n.mortgage_payment),mortgage_interest_rate:ln(n.mortgage_interest_rate),mortgage_term_years:ln(n.mortgage_term_years,30),rental_income:ln(n.rental_income),rental_expenses:ln(n.rental_expenses),monthly_hoa:ln(n.monthly_hoa),monthly_taxes:ln(n.monthly_taxes),monthly_insurance:ln(n.monthly_insurance),monthly_pmi:ln(n.monthly_pmi),street_address:hi(n.street_address),city:hi(n.city),state:hi(n.state),zip_code:hi(n.zip_code),is_consolidated:!!n.is_consolidated,ignored:!!n.ignored,is_focus_property:!!n.is_focus_property}))}function t_(e,t){return e.map(n=>({id:String(n.id??""),lead_id:t,scenario_id:typeof n.scenario_id=="string"?n.scenario_id:void 0,debt_name:String(n.debt_name??""),debt_type:String(n.debt_type??"other"),current_balance:ln(n.current_balance),monthly_payment:ln(n.monthly_payment),interest_rate:ln(n.interest_rate),is_consolidated:!!n.is_consolidated,ignored:!!n.ignored}))}function n_(e,t){return e.map(n=>({id:String(n.id??""),lead_id:t,scenario_id:typeof n.scenario_id=="string"?n.scenario_id:void 0,category:String(n.category??"miscellaneous"),amount:ln(n.amount)}))}function r_(e){return e.map(t=>({id:String(t.id??""),firstName:String(t.first_name??""),lastName:String(t.last_name??""),relationship:String(t.relationship??"spouse"),monthlyNetIncome:ln(t.monthly_net_income),savingsBalance:ln(t.savings_balance),retirementBalance:ln(t.retirement_balance)}))}function a_(e,t){return e.map(n=>({id:String(n.id??""),lead_id:t,relationship:String(n.relationship??"spouse"),first_name:String(n.first_name??""),last_name:String(n.last_name??""),email:typeof n.email=="string"?n.email:null,phone:typeof n.phone=="string"?n.phone:null,fico_score:n.fico_score==null?null:ln(n.fico_score),date_of_birth:typeof n.date_of_birth=="str
1196ing"?n.date_of_birth:null,citizenship_status:typeof n.citizenship_status=="string"?n.citizenship_status:null,is_us_citizen:!!n.is_us_citizen,is_military_veteran:!!n.is_military_veteran}))}function s_(e,t){const n=t.lead_contact;return n?{...e,first_name:n.first_name??e.first_name,last_name:n.last_name??e.last_name,email:n.email??e.email,phone:n.phone,notes:n.notes}:e}function i_(e){return{scenario:e.scenario?{id:e.scenario.id,name:e.scenario.name,selected_heloc_type:e.scenario.selected_heloc_type}:null,assessment:e.assessment?e.assessment:null,properties:e.properties,debts:e.debts,expenses:e.expenses,calculator_results:e.calculatorResults??[],ai_analysis:e.aiAnalysis??null,lead_contact:{first_name:e.lead.first_name,last_name:e.lead.last_name,email:e.lead.email,phone:e.lead.phone,notes:e.lead.notes},additional_clients:e.additionalClients}}const kl=Et("min-h-11 px-2 py-2.5 text-sm font-semibold sm:px-3","text-foreground/85 data-[state=inactive]:text-foreground/75","data-[state=inactive]:hover:bg-muted data-[state=inactive]:hover:text-foreground","data-[state=active]:bg-background data-[state=active]:text-foreground","data-[state=active]:shadow-sm data-[state=active]:ring-2 data-[state=active]:ring-primary/30");function nm(e,t,n="—"){if(e==null||e==="")return n;const r=e instanceof Date?e:new Date(e);return sc(r)?ji(r,t):n}const o_=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;function rm(e){return!!e&&o_.test(e)}function l_(e){if(e==null)return"Unknown error";if(e instanceof Error)return e.message.trim()||e.name||"Unknown error";if(typeof e=="object"){const t=e,n=[];if(typeof t.code=="string"&&t.code&&n.push(`[${t.code}]`),typeof t.message=="string"&&t.message.trim()&&n.push(t.message.trim()),typeof t.details=="string"&&t.details.trim()&&n.push(t.details.trim()),typeof t.hint=="string"&&t.hint.trim()&&n.push(t.hint.trim()),n.length>0)return n.join(" ");try{return JSON.stringify(e)}catch{return String(e)}}return String(e)}const c_=()=>{var en,Zr,Tn;const{leadId:e}=N0(),t=j0(),[n,r]=S0(),s=ys(),{user:i,loading:c}=vi(),{toast:l}=Ir(),{leads:d,isLoading:h}=I0(),f=d.find(G=>G.id===e),x=X0(e),b=x.data??[],m=n.get("scenario")??void 0,w=J.useRef(null),v=J.useMemo(()=>{var G;if(m&&b.some(je=>je.id===m)||rm(m)&&(w.current===m||x.isFetching||x.isLoading))return m;if(b.length)return(G=b[0])==null?void 0:G.id},[b,m,x.isFetching,x.isLoading]);J.useEffect(()=>{w.current&&b.some(G=>G.id===w.current)&&(w.current=null)},[b]);const P=J.useMemo(()=>{const G=b.find(je=>je.id===v);return(G==null?void 0:G.selected_heloc_type)==="1st_lien"?"1st_lien":"2nd_lien"},[b,v]);J.useEffect(()=>{!e||!v||m!==v&&(rm(m)&&!b.some(G=>G.id===m)&&(w.current===m||x.isFetching||x.isLoading)||r(G=>{const je=new URLSearchParams(G);return je.set("scenario",v),je},{replace:!0}))},[e,v,m,b,x.isFetching,x.isLoading,r]);const[_,q]=J.useState(!1),[T,B]=J.useState(null),Q=J.useRef(!1);J.useEffect(()=>{B(null),Q.current=!1},[e]),J.useEffect(()=>{if(!(!e||!i)){if(!x.isSuccess||b.length>0){Q.current=!1;return}T||Q.current||(Q.current=!0,q(!0),nt.rpc("create_blank_lead_intake_scenario",{p_lead_id:e,p_name:"Default"}).then(({error:G})=>{if(q(!1),G){Q.current=!1,B(G.message),l({title:"Could not create default intake scenario",description:G.message,variant:"destructive"});return}s.invalidateQueries({queryKey:["lead-intake-scenarios",e]})}))}},[e,i,x.isSuccess,b.length,T,s,l]);const me=!!(e&&i&&x.isSuccess&&b.length===0&&!T),{assessment:ce,properties:$,debts:D,expenses:Y,metrics:N,isLoading:I,updateAssessment:k,upsertProperties:L,setFocusProperty:H,upsertDebts:te,upsertExpenses:se}=Z0(e,v),K=!!(v&&I),{lenders:ae}=Y0(),{settings:be}=co(),{mutate:Ne}=$0(),{mutate:A}=H0(),[E,z]=J.useState(!1),[X,Z]=J.useState(null),[le,fe]=J.useState(!1),{result:ue,isLoading:_e,generateAnalysis:Ce}=Rb(e,v),[ve,we]=J.useState([]),[De,R]=J.useState(null),[ze,ye]=J.useState(!1),[Ee,de]=J.useState(null),[Ue,qe]=J.useState("previous"),[$e,Ge]=J.useState(null),[bt,et]=J.useState(!1),[Me,vt]=J.useState({creditLimits:{"1st_lien":0,"2nd_lien":0},helocType:"2nd_lien",interestRate:8,startingBalance:0,existingHelocBalance:0,calculatedStartingBalance:0,chunkSize:null}),[St,Oe]=J.useState("stress"),[_t,Xe]=J.useState({"1st_lien":{comparison:null,strategyPdfExtras:null}
1196,"2nd_lien":{comparison:null,strategyPdfExtras:null}});J.useEffect(()=>{Xe({"1st_lien":{comparison:null,strategyPdfExtras:null},"2nd_lien":{comparison:null,strategyPdfExtras:null}})},[v]),J.useEffect(()=>{vt(G=>({...G,helocType:P}))},[P]);const Ht=Kd(),{confirmAndSnapshot:Lt}=Xv(v),At=J.useCallback(async()=>{await Lt(v)&&t("/admin/leads")},[Lt,v,t]),kt=Jp(v,ze||!!Ee),it=(kt.data??[]).find(G=>G.id===Ee)??null,at=Zf(Ee??void 0,!!Ee),Ve=J.useMemo(()=>{var ct;if(!Ee)return null;const G=kt.data??[],je=G.findIndex(Ye=>Ye.id===Ee);return je>=0?((ct=G[je+1])==null?void 0:ct.id)??null:null},[Ee,kt.data]),ft=Ue==="picked"?$e:Ue==="previous"?Ve:null,wt=Zf(ft??void 0,!!ft),Nt=Vv(e,v),Qe=((en=at.data)==null?void 0:en.snapshot)??null,Ze=!!(Qe&&e),Ae=Ze?Zv(Qe.assessment,e)??ce:ce,Re=Ze?e_(Qe.properties,e):$,Gt=Ze?t_(Qe.debts,e):D,yn=Ze?n_(Qe.expenses,e):Y,lt=N,hr=Gt,sn=J.useMemo(()=>{const G=Me.helocType,je=Me.creditLimits[G];return Ze||je>0||G==="1st_lien"?wm(Ae,Re,hr,yn,be,void 0,{cashflowDeploymentFraction:1,helocTermYearsDefault:10,chunkCadenceDays:30,maxSimulationMonths:600,helocCreditLimit:G==="2nd_lien"&&je||void 0,helocCreditLimit1st:G==="1st_lien"&&je||void 0,helocType:G}):lt},[Ae,Re,hr,yn,be,lt,Me,Ze]),br=J.useCallback(G=>{Xe(je=>({...je,[G.helocType]:{comparison:G.comparison,strategyPdfExtras:G.comparison?G.strategyPdfExtras??null:null}}))},[]),bn=ha({queryKey:["lead-additional-clients",e],queryFn:async()=>{const{data:G,error:je}=await nt.from("lead_additional_clients").select("id, fico_score, first_name, last_name, relationship, monthly_net_income, savings_balance, retirement_balance, date_of_birth").eq("lead_id",e);if(je)throw je;return G??[]},enabled:!!e}),Nn=ha({queryKey:["lead-calculator-results-history",v],queryFn:async()=>{const{data:G,error:je}=await nt.from("lead_calculator_results").select("*").eq("scenario_id",v);if(je)throw je;return G??[]},enabled:!!(i&&v&&(ze||Ee))}),Pn=ha({queryKey:["lead-ai-analysis-history",v],queryFn:async()=>{const{data:G,error:je}=await nt.from("lead_ai_analysis").select("*").eq("scenario_id",v).maybeSingle();if(je)throw je;return G??null},enabled:!!(i&&v&&(ze||Ee))}),Fn=f?i_({scenario:b.find(G=>G.id===v)?{id:v,name:b.find(G=>G.id===v).name,selected_heloc_type:P}:null,assessment:ce,properties:$,debts:D,expenses:Y,lead:f,additionalClients:bn.data??[],calculatorResults:Nn.data,aiAnalysis:Pn.data}):null,Jr=Ue==="current"?Fn:((Zr=wt.data)==null?void 0:Zr.snapshot)??null,vr=Ze&&Qe?x1(Jr,Qe):[],Un=y1(vr),_r=eh(vr,"calculator_results").length>0,lr=eh(vr,"ai_analysis").length>0,Xn=f&&Ze&&Qe?s_(f,Qe):f,Zn=Ze&&Qe&&e?a_(Qe.additional_clients,e):null,fr=Ze&&Qe?r_(Qe.additional_clients):(bn.data??[]).map(G=>({id:G.id,firstName:G.first_name,lastName:G.last_name,relationship:G.relationship??"spouse",monthlyNetIncome:Number(G.monthly_net_income??0),savingsBalance:Number(G.savings_balance??0),retirementBalance:Number(G.retirement_balance??0)})),nr=ha({queryKey:["lead-calculator-result-strategy-pdf",v,Me.helocType],queryFn:async()=>{const{data:G,error:je}=await nt.from("lead_calculator_results").select("baseline_months, baseline_interest, accelerated_months, accelerated_interest, months_saved, interest_saved").eq("scenario_id",v).eq("heloc_type",Me.helocType).maybeSingle();if(je)throw je;return G},enabled:!!(i&&e&&v&&le),staleTime:3e4}),qr=ha({queryKey:["lead-calculator-result-ai",v,Me.helocType],queryFn:async()=>{const{data:G,error:je}=await nt.from("lead_calculator_results").select("baseline_months, baseline_interest, accelerated_months, accelerated_interest, months_saved, interest_saved, viability, heloc_type").eq("scenario_id",v).eq("heloc_type",Me.helocType).maybeSingle();if(je)throw je;return G},enabled:!!(i&&v),staleTime:3e4}),wr=J.useMemo(()=>{const G=_t[Me.helocType];if(G!=null&&G.comparison)return{payoff:Kf(G.comparison,G.strategyPdfExtras),viability:null};const je=qr.data;return je?{payoff:Qf(je),viability:je.viability??null}:{payoff:null,viability:null}},[_t,Me.helocType,qr.data]),Sa=J.useMemo(()=>{const G=_t[Me.helocType];if(G!=null&&G.comparison)return{...sn,payoffComparison:Kf(G.comparison,G.strategyPdfExtras)};const je=nr.data?Qf(nr.data):null;return je?{...sn,payoffComparison:je}:sn},[sn,_t,Me.helocType,nr.data]),qt=J.useMemo(()=>{const G=(Ae==null?void 0:Ae.monthly_net_income)??0,je=(Ze&&Qe?Qe.additional_clients.map(Vt=>Number(Vt.monthly_net_income??0)):(bn.data??[]).map(Vt=>Number(Vt.monthly_net_income??0))).reduce((Vt,dr)=>Vt+dr,0),ct=G+je,Ye=yn.reduce((Vt,dr)=>Vt+Number(dr.amount),0),jt=nu(Gt),Pt=Ye+jt,Te=ev(Gt),un=tv(Gt),On=Re.filter($l).reduce((Vt,dr)=>Vt+Number(dr.mortgage_payment??0),0),Fr=Gt.some(Vt=>!Vt.ignored&&Vt.is_consolidated)||On>0,ba=Re.filter(Vt=>["rental","vacation_rental"].includes(Vt.property_type)).reduce((Vt,dr)=>Vt+Number(dr.rental_income??0)-Number(dr.rental_expenses??0)-Number(dr.mortgage_payment??0),0),Rt=Vo(Re),mr=["rental","vacation_rental"].includes(((Rt==null?void 0:Rt.property_type)??"").toLowerCase()),Aa=Lm(Re),Ks=Math.max(0,Aa-(mr?0:Number((Rt==null?void 0:Rt.mortgage_payment)??0))),qa=Rt?xm({totalMonthlyPayment:Number(Rt.mortgage_payment)||0,outstandingBalance:Number(Rt.outstanding_mortgage_balance)||0,originalPrincipal:Number(Rt.original_mortgage_balance)||0,annualRatePercent:Number(Rt.mortgage_interest_rate)||0,termYears:Number(Rt.mortgage_term_years)||30,monthlyTaxes:Rt.monthly_taxes,monthlyInsurance:Rt.monthly_insurance,monthlyPmi:Rt.monthly_pmi}):0,ta=ct+ba,tn=sn.totalMonthlyHoa,pr=Me.helocType,ns=sn.helocInterestOnlyPayment2nd??0,Ai=sn.helocInterestOnlyPayment1st??0,Qs=Gt.filter(Vt=>!Vt.ignored).reduce((Vt,dr)=>Vt+Number(dr.monthly_payment??0),0),ka=ta-Aa-Qs-Pt-tn,va=pr==="1st_lien"?Ai:ns,Ca=Bv({startingBalance:Me.startingBalance,existingHelocBalance:Me.existingHelocBalance,calculatedStartingBalance:Me.calculatedStartingBalance,initialChunkSize:Me.chunkSize}),rs=Xf({mode:"input",stressPayment:va,drawnBalance:Ca,inputAnnualRatePct:Me.interestRate}),za=Xf({mode:St,stressPayment:va,drawnBalance:Ca,inputAnnualRatePct:Me.interestRate}),_s=Fr?Te:un,ws=sn.totalMinimumDebtPayments,ki=Re.filter(Vt=>Vt.id!==(Rt==null?void 0:Rt.id)&&$l(Vt)).reduce((Vt,dr)=>Vt+Number(dr.mortgage_payment??0),0),na=Vt=>ta+(mr?Number((Rt==null?void 0:Rt.mortgage_payment)??0):0)-qa-Vt-Te-Ye-tn-Ks+ki,Ur=Vt=>Fr?ta-Aa-Vt-Te-Ye-tn+On:ka-Vt,Ci=pr==="1st_lien"?na(va):Ur(va),Pi=pr==="1st_lien"?na(za):Ur(za),Ei=pr==="1st_lien"?na(rs):Ur(rs);
1196return{monthlyNetIncome:ct,netRentalCf:ba,combinedNetIncome:ta,isRentalFocus:mr,displayedCombinedNetIncome:ta+(mr?Number((Rt==null?void 0:Rt.mortgage_payment)??0):0),primaryMortgagePayment:Aa,displayedPitiPayment:Aa+(mr?Number((Rt==null?void 0:Rt.mortgage_payment)??0):0),primaryTaxesInsurance:qa,totalExpenses:Ye,categoryExpenses:Ye,ignoredLivingExpensePayments:jt,displayedNonMortgageDebtPayments:_s,hasConsolidation:Fr,hoaMonthly:tn,heloc2nd:ns,heloc1st:Ai,selectedHelocType:pr,selectedHelocPayment:va,inputHelocPayment:rs,inputCashflow:Ei,displayedDrawnBalance:Ca,displayedHelocPayment:za,baseCashflow:ka,adjustedMonthlyCashFlow:Ur(va),nonConsolidatedDebtPayments:_s,totalMinimumDebtPayments:ws,cashflow:Ci,displayedCashflow:Pi}},[Ae,bn.data,Re,Gt,yn,sn,Me,St,Ze,Qe]),zr=J.useMemo(()=>{const G=Mv(sn,wr.payoff,wr.viability);return Pb(G,{hasConsolidation:qt.hasConsolidation,displayedMonthlyCashflow:qt.cashflow,dtiPassThreshold:be.dti_pass_threshold,assumedHelocDti:Me.helocType==="1st_lien"?G.firstLienAssumedDti:G.secondLienAssumedDti})},[sn,wr,qt.hasConsolidation,qt.cashflow,be.dti_pass_threshold,Me.helocType]),ma=J.useMemo(()=>{const G=[];Ae!=null&&Ae.fico_score&&Ae.fico_score>0&&G.push(Ae.fico_score);for(const je of bn.data??[])je.fico_score&&je.fico_score>0&&G.push(je.fico_score);return G.length>0?Math.min(...G):0},[Ae==null?void 0:Ae.fico_score,bn.data]),Ct=J.useMemo(()=>{const G=Me.helocType==="1st_lien"?sn.firstLienAssumedDti:sn.secondLienAssumedDti;return U0({properties:Re,debts:Gt,householdCashflow:qt.baseCashflow,assumedDtiPct:G??null,dtiPassThresholdPct:Number(be.dti_pass_threshold),lowestFico:ma>0?ma:null,householdMonthlyNetIncome:qt.monthlyNetIncome,primaryDateOfBirth:(f==null?void 0:f.date_of_birth)??null,primaryBirthYear:(f==null?void 0:f.birth_year)??null,additionalDatesOfBirth:(bn.data??[]).map(je=>je.date_of_birth)})},[Re,Gt,qt.baseCashflow,qt.monthlyNetIncome,Me.helocType,sn.firstLienAssumedDti,sn.secondLienAssumedDti,be.dti_pass_threshold,ma,f==null?void 0:f.date_of_birth,f==null?void 0:f.birth_year,bn.data]),ts=J.useMemo(()=>JSON.stringify({leadId:e,scenarioId:v,dob:(f==null?void 0:f.date_of_birth)??null,birthYear:(f==null?void 0:f.birth_year)??null,income:(Ae==null?void 0:Ae.monthly_net_income)??null,fico:(Ae==null?void 0:Ae.fico_score)??null,veteran:(Ae==null?void 0:Ae.is_military_veteran)??null,props:Re.map(G=>[G.id,G.property_type,G.estimated_value,G.outstanding_mortgage_balance,G.mortgage_interest_rate,G.mortgage_payment]),debts:Gt.map(G=>[G.id,G.debt_type,G.current_balance,G.monthly_payment,G.ignored]),extra:(bn.data??[]).map(G=>[G.id,G.date_of_birth,G.monthly_net_income,G.fico_score])}),[e,v,f==null?void 0:f.date_of_birth,f==null?void 0:f.birth_year,Ae==null?void 0:Ae.monthly_net_income,Ae==null?void 0:Ae.fico_score,Ae==null?void 0:Ae.is_military_veteran,Re,Gt,bn.data]);J.useEffect(()=>{if(!e||!v||K)return;const G=window.setTimeout(()=>{Ne({leadId:e,scenarioId:v})},800);return()=>window.clearTimeout(G)},[ts,e,v,K,Ne]),J.useEffect(()=>{if(!Ct.eligible||!e||!v||K)return;const G=Re.find(je=>je.property_type==="primary_residence")??Re[0]??null;A({leadId:e,scenarioId:v,propertyId:(G==null?void 0:G.id)??null,propertyType:(G==null?void 0:G.property_type)??null,propertyClassification:G&&"classification"in G?G.classification??null:null,currentRate:G&&Number(G.mortgage_interest_rate)||null,currentBalance:G&&Number(G.outstanding_mortgage_balance)||null,currentPayment:G&&Number(G.mortgage_payment)||null,snapshot:{equityPct:Ct.equityPct,youngestAge:Ct.youngestAge,reasons:Ct.reasons}})},[ts,Ct.eligible,Ct.equityPct,Ct.youngestAge,Ct.reasons,e,v,K,A]);const cn=J.useMemo(()=>Vo(Re),[Re]),pa=J.useCallback(async()=>{if(!(Ae!=null&&Ae.mortgage_statement_path))return;const G=window.open("about:blank","_blank");try{const{data:je,error:ct}=await nt.storage.from("assessment-documents").createSignedUrl(Ae.mortgage_statement_path,60);if(ct)throw ct;G?(G.opener=null,G.location.href=je.signedUrl):window.location.assign(je.signedUrl)}catch(je){G==null||G.close(),l({title:"Could not open mortgage statement",description:je instanceof Error?je.message:"Please try again.",variant:"destructive"})}},[Ae==null?void 0:Ae.mortgage_statement_path,l]),ga=J.useMemo(()=>Re.find(G=>G.property_type==="primary_residence")??null,[Re]),cr=!!(e&&i&&x.isLoading)||!!(e&&i&&!x.isFetched&&!x.isError),Xr=c||h||cr||_||me||K,La=J.useMemo(()=>{var je;return((je=(x.data??[]).find(ct=>ct.id===v))==null?void 0:je.name)??"Intake scenario"},[x.data,v]),xa=J.useMemo(()=>qv({monthlyNetIncome:qt.monthlyNetIncome,displayedCombinedNetIncome:qt.displayedCombinedNetIncome,totalExpenses:qt.totalExpenses,inputCashflow:qt.inputCashflow,netRentalCf:qt.netRentalCf,displayedPitiPayment:qt.displayedPitiPayment,primaryTaxesInsurance:qt.primaryTaxesInsurance,hoaMonthly:qt.hoaMonthly,selectedHelocType:qt.selectedHelocType,inputHelocPayment:qt.inputHelocPayment,heloc1st:qt.heloc1st,hasConsolidation:qt.hasConsolidation,nonConsolidatedDebtPayments:qt.nonConsolidatedDebtPayments,totalMinimumDebtPayments:qt.totalMinimumDebtPayments,baseCashflow:qt.baseCashflow,displayedDrawnBalance:qt.displayedDrawnBalance,inputAnnualRatePct:Me.interestRate,initialChunkSize:Me.chunkSize}),[qt,Me.interestRate,Me.chunkSize]),$r=J.useMemo(()=>(bn.data??[]).map(G=>({first_name:G.first_name,last_name:G.last_name,monthly_net_income:G.monthly_net_income})),[bn.data]),Ba=J.useMemo(()=>{const G=Me.creditLimits[Me.helocType],je=G!=null&&G>0?Dt(G):"—",ct=f==null?void 0:f.created_at,Ye=ct?new Date(ct):null,jt=Ye&&sc(Ye)?ji(Ye,"MM/dd
1196/yyyy"):"—";return[["HELOC Type",Me.helocType==="1st_lien"?"1st Lien":"2nd Lien"],["HELOC Limit",je],["Interest Rate (model)","—"],["Chunk Size (model)","—"],["Strategy Start Date",jt]]},[Me,f==null?void 0:f.created_at]),bs=J.useMemo(()=>{if(!ue)return null;const G=[ue.confidence_rationale.trim(),...ue.strategy_enablers.map(je=>`• ${je}`)].filter(Boolean);return{headline:"AI QUALIFICATION SUMMARY · BASED ON INTAKE DATA & LENDER CRITERIA",summary:ue.summary,narrative:G.join(`
1197
1198`)}},[ue]),Qt=J.useMemo(()=>V0(sn,Ae,Re,ae,{helocType:Me.helocType,helocCreditLimit:Me.creditLimits[Me.helocType]||void 0}),[sn,Ae,Re,ae,Me.helocType,Me.creditLimits]),vs=J.useMemo(()=>{const G=((cn==null?void 0:cn.property_type)??"").toLowerCase();return["rental","vacation_rental"].includes(G)?Qt.some(je=>W0(G,je.program.eligible_property_types).pass):!0},[cn==null?void 0:cn.property_type,Qt]),rr=J.useMemo(()=>Tb({dealBreakersRaw:Ae==null?void 0:Ae.financial_deal_breakers,metrics:zr,lenderMatches:Qt,ficoScore:Ae==null?void 0:Ae.fico_score,calculatorViability:wr.viability}),[Ae==null?void 0:Ae.financial_deal_breakers,Ae==null?void 0:Ae.fico_score,zr,Qt,wr.viability]),Oa=J.useMemo(()=>({assessment:Ae,properties:Re,debts:Gt,expenses:yn,metrics:zr,lenderMatches:Qt,calculatorViability:wr.viability}),[Ae,Re,Gt,yn,zr,Qt,wr.viability]),Hr=El(f==null?void 0:f.status),{selectedKeys:Bn,setSelected:ya,isSaving:ie,loadError:xe}=Fv(v,Hr),He=J.useMemo(()=>Rv(Qt,Bn),[Qt,Bn]),rt=J.useCallback((G,je,ct)=>{var jt;const Ye=(jt=G.program)==null?void 0:jt.id;Ye&&ya({lenderId:G.lender.id,programId:Ye,selected:ct})},[ya]);if(e&&i&&x.isError){const G=l_(x.error),je=/lead_intake_scenarios|relation .* does not exist|42P01|schema cache/i.test(G);return a.jsx(Ui,{children:a.jsxs("div",{className:"max-w-xl space-y-4 p-6",children:[a.jsxs(st,{variant:"outline",size:"sm",className:"gap-2",onClick:()=>t("/admin/leads"),children:[a.jsx(So,{className:"h-4 w-4"}),"Back to leads"]}),a.jsxs(qs,{variant:"destructive",children:[a.jsx(ms,{className:"h-4 w-4"}),a.jsx(Io,{children:"Could not load intake scenarios"}),a.jsxs(ps,{className:"space-y-2",children:[a.jsx("p",{className:"font-mono text-xs break-words",children:G}),je?a.jsxs("p",{className:"text-xs",children:["This usually means the database is behind the app. From ",a.jsx("code",{className:"rounded bg-muted px-1 py-0.5",children:"solvit-prod"}),", run"," ",a.jsx("code",{className:"rounded bg-muted px-1 py-0.5",children:"npx supabase db reset"})," (local) or apply migrations to your linked project, then reload."]}):a.jsxs("p",{className:"text-xs",children:["If you recently pulled code, apply pending Supabase migrations (table"," ",a.jsx("code",{className:"rounded bg-muted px-1 py-0.5",children:"lead_intake_scenarios"}),") and confirm admin RLS allows selecting it."]}),a.jsx(st,{type:"button",variant:"outline",size:"sm",className:"mt-2",onClick:()=>x.refetch(),children:"Retry"})]})]})]})})}if(e&&i&&T&&x.isSuccess&&b.length===0&&!_)return a.jsx(Ui,{children:a.jsxs("div",{className:"max-w-xl space-y-4 p-6",children:[a.jsxs(st,{variant:"outline",size:"sm",className:"gap-2",onClick:()=>t("/admin/leads"),children:[a.jsx(So,{className:"h-4 w-4"}),"Back to leads"]}),a.jsxs(qs,{variant:"destructive",children:[a.jsx(ms,{className:"h-4 w-4"}),a.jsx(Io,{children:"Default intake scenario could not be created"}),a.jsxs(ps,{className:"space-y-2",children:[a.jsx("p",{children:T}),a.jsx(st,{type:"button",variant:"outline",size:"sm",className:"mt-2",onClick:()=>{B(null),Q.current=!1,x.refetch()},children:"Try again"})]})]})]})});if(Xr)return a.jsx(Ui,{children:a.jsx("div",{className:"flex items-center justify-center h-64",children:a.jsx(Kr,{className:"w-8 h-8 animate-spin text-primary"})})});if(!f)return a.jsx(Ui,{children:a.jsxs("div",{className:"max-w-lg space-y-4 p-6",children:[a.jsxs(st,{variant:"outline",size:"sm",className:"gap-2",onClick:()=>t("/admin/leads"),children:[a.jsx(So,{className:"h-4 w-4"}),"Back to leads"]}),a.jsx("p",{className:"text-sm text-muted-foreground",children:"This lead is not in your current list (it may have been removed, or your session cannot see it). Try refreshing the leads page."})]})});if(!v)return a.jsx(Ui,{children:a.jsxs("div",{className:"max-w-lg space-y-4 p-6",children:[a.jsxs(st,{variant:"outline",size:"sm",className:"gap-2",onClick:()=>t("/admin/leads"),children:[a.jsx(So,{className:"h-4 w-4"}),"Back to leads"]}),a.jsx("p",{className:"text-sm text-muted-foreground",children:"No intake scenario is available. Refresh to reload scenarios from the server."}),a.jsx(st,{type:"button",variant:"outline",size:"sm",onClick:()=>void x.refetch(),children:"Refresh scenarios"})]})});const mt=G=>{G!==v&&(async()=>await Lt(v)&&(de(null),r(ct=>{const Ye=new URLSearchParams(ct);return Ye.set("scenario",G),Ye},{replace:!0})))()},Ft=async(G,je)=>{if(!e||!G)return;w.current=G;const ct=new Date().toISOString();s.setQueryData(["lead-intake-scenarios",e],Ye=>{const jt=Ye??[];return jt.some(Pt=>Pt.id===G)?jt:[...jt,{id:G,lead_id:e,name:je.name,sort_order:je.sort_order,selected_heloc_type:je.selected_heloc_type,created_at:ct,updated_at:ct}]}),await s.refetchQueries({queryKey:["lead-intake-scenarios",e]}
1198),r(Ye=>{const jt=new URLSearchParams(Ye);return jt.set("scenario",G),jt},{replace:!0})},tt=async(G=v)=>{if(!e||!G||!await Lt(v))return;const ct=b.find(Fr=>Fr.id===G),Ye=`Copy of ${(ct==null?void 0:ct.name)??"scenario"}`,jt=typeof window<"u"?window.prompt("New scenario name",Ye):Ye;if(jt===null)return;const Pt=jt.trim()||Ye,{data:Te,error:un}=await nt.rpc("duplicate_lead_intake_scenario",{p_source_scenario_id:G,p_new_name:Pt});if(un){l({title:"Duplicate failed",description:un.message,variant:"destructive"});return}const On=typeof Te=="string"?Te:String(Te??"");On&&await Ft(On,{name:Pt,selected_heloc_type:(ct==null?void 0:ct.selected_heloc_type)==="1st_lien"?"1st_lien":"2nd_lien",sort_order:b.length}),l({title:"Scenario duplicated"})},Vn=async G=>{var Te;if(!e)return;const je=b.find(un=>un.id===G);if(b.length<=1){l({title:"Cannot delete only scenario",description:"Create another scenario before deleting this one.",variant:"destructive"});return}if(!(typeof window>"u"||window.confirm(`Delete "${(je==null?void 0:je.name)??"this scenario"}"? This removes its assessment, properties, debts, expenses, calculator results, and AI analysis.`)))return;const Ye=b.filter(un=>un.id!==G),jt=G===v?(Te=Ye[0])==null?void 0:Te.id:v,{error:Pt}=await nt.from("lead_intake_scenarios").delete().eq("id",G).eq("lead_id",e);if(Pt){l({title:"Could not delete scenario",description:Pt.message,variant:"destructive"});return}await s.invalidateQueries({queryKey:["lead-intake-scenarios",e]}),jt&&r(un=>{const On=new URLSearchParams(un);return On.set("scenario",jt),On},{replace:!0}),l({title:"Scenario deleted"})},En=async()=>{if(!e||!await Lt(v))return;const je=typeof window<"u"?window.prompt("Scenario name","New scenario"):"New scenario";if(je===null)return;const ct=je.trim()||"New scenario",{data:Ye,error:jt}=await nt.rpc("create_blank_lead_intake_scenario",{p_lead_id:e,p_name:ct});if(jt){l({title:"Could not create scenario",description:jt.message,variant:"destructive"});return}const Pt=typeof Ye=="string"?Ye:String(Ye??"");Pt&&await Ft(Pt,{name:ct,selected_heloc_type:"2nd_lien",sort_order:b.length}),l({title:"New scenario created"})},Zt=Dt;return a.jsx(Ui,{children:a.jsxs("div",{className:"mx-auto max-w-6xl animate-fade-in space-y-6",children:[a.jsxs("div",{className:"overflow-hidden rounded-2xl border border-border bg-card shadow-sm",children:[a.jsxs("div",{className:"space-y-5 bg-gradient-to-br from-background via-background to-muted/40 p-5 sm:p-6",children:[a.jsxs("div",{className:"flex flex-col gap-4 lg:flex-row lg:items-start lg:justify-between",children:[a.jsxs("div",{className:"flex min-w-0 items-start gap-3",children:[a.jsx(st,{variant:"ghost",size:"icon",className:"mt-1 h-9 w-9 shrink-0 rounded-full border border-border bg-background/80 shadow-sm hover:bg-muted",onClick:()=>void At(),"aria-label":"Back to leads",children:a.jsx(So,{className:"h-4 w-4"})}),a.jsxs("div",{className:"min-w-0 space-y-2",children:[a.jsx(b1,{lead:Xn??f,readOnly:Ze,highlights:Un,statusBadge:a.jsx(xn,{variant:"outline",className:Et("rounded-full px-2.5 py-0.5 text-xs font-medium",El(f.status)?"border-primary/20 bg-primary/10 text-primary":"border-accent/20 bg-accent/10 text-accent"),children:F0(f.status)})}),a.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:[a.jsxs(xn,{variant:"outline",className:"rounded-full bg-background/70 px-2.5 py-0.5 font-normal",children:["Submitted ",nm(f.created_at,"MMM d, yyyy 'at' h:mm a","Unknown")]}),f.source?a.jsxs(xn,{variant:"outline",className:"rounded-full bg-background/70 px-2.5 py-0.5 font-normal",children:["Source: ",f.source]}):null]})]})]}),a.jsxs("div",{className:"flex flex-wrap items-center gap-2 lg:justify-end",children:[e?a.jsx(c1,{leadId:e,disabled:Ze}):null,a.jsxs(st,{type:"button",variant:"outline",className:"h-10 gap-1.5 bg-background/90 px-4 shadow-sm",onClick:()=>ye(!0),"data-testid":"intake-history-button",children:[a.jsx(bm,{className:"h-4 w-4"}),"History"]}),a.jsxs(md,{children:[a.jsx(pd,{asChild:!0,children:a.jsxs(st,{variant:"outline",className:"h-10 gap-1.5 bg-background/90 px-4 shadow-sm",children:["Actions",a.jsx(Ys,{className:"h-4 w-4 opacity-70"})]})}),a.jsxs(gd,{align:"end",className:"w-52",children:[El(f.status)?null:a.jsxs(Hi,{className:"cursor-pointer",onSelect:()=>z(!0),children:[a.jsx(_m,{className:"mr-2 h-4 w-4"}),"Promote to Client"]}),a.jsxs(Hi,{className:"cursor-pointer",disabled:!f||!v||K,onSelect:()=>fe(!0),children:[a.jsx(xd,{className:"mr-2 h-4 w-4"}),"Generate Report"]}),a.jsxs(L0,{children:[a.jsxs(A0,{className:"cursor-pointer",disabled:!f||!v||K||Ze,children:[a.jsx(J0,{className:"mr-2 h-4 w-4"}),"Manual Refer"]}),a.jsxs(k0,{className:"w-48",children:[a.jsx(Hi,{className:"cursor-pointer",disabled:!f||!v||K||Ze,onSelect:()=>Z("refi"),children:"Refer to Refi"}),a.jsx(Hi,{className:"cursor-pointer",disabled:!f||!v||K||Ze,onSelect:()=>Z("hecm"),children:"Refer to HECM"})]})]})]})]})]})]}),Ze&&it?a.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 rounded-xl border border-warning/30 bg-warning/10 px-3 py-2 text-sm","data-testid":"intake-history-preview-banner",children:[a.jsxs("p",{children:["Viewing version from"," ",nm(it.created_at,"MMM d, yyyy 'at' h:mm a")," by"," ",qd(it)]}),a.jsxs("div",{className:"flex flex-wrap gap-2",children:[a.jsx(st,{type:"button",size:"sm",variant:"outline",onClick:()=>de(null),children:"Exit preview"}),a.jsx(st,{type:"button",size:"sm",onClick:()=>et(!0),children:"Restore"})]})]}):null,a.jsxs("div",{className:"grid gap-3 rounded-xl border border-border/70 bg-background/70 p-3 sm:grid-cols-2",children:[a.jsxs("div",{className:"flex flex-col gap-1.5",children:[a.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:"Qualification Specialist"}),a.jsx(Ku,{value:f.qualification_specialist_id,onValueChange:async G=>{await nt.from("leads").update({qualification_specialist_id:G}).eq("id",f.id),s.invalidateQueries({queryKey:["leads"]})}})]}),a.jsxs("div",{className:"flex flex-col gap-1.5",children:[a.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:"Coach"}),a.jsx(Ku,{value:f.strategist_id,onValueChange:async G=>{await nt.from("leads").update({strategist_id:G}).eq("id",f.id),s.invalidateQueries({queryKey:["leads"]})}})]})]})]}),a.jsxs("div",{className:"border-t border-border bg-muted/25 px-4 py-4 sm:px-6",children:[a.jsxs("div",{className:"mb-3 flex flex-wrap items-center justify-between gap-2",children:[a.jsxs("div",{children:[a.jsx("h2",{className:"text-sm font-semibold text-foreground",children:"Intake Scenarios"}),a.jsx("p",{className:"text-xs text-muted-foreground",children:"Compare financial snapshots without changing shared client info."})]}),a.jsx("p",{className:"rounded-full bg-background px-3 py-1 text-[11px] text-muted-foreground shadow-sm",children:"Promote uses the selected scenario"})]}),a.jsxs("div",{className:"flex items-center gap-2 overflow-x-auto pb-1",children:[b.map(G=>{const je=G.id===v;return a.jsxs("div",{className:Et("group flex h-11 shrink-0 items-center rounded-xl border bg-background shadow-sm transition-all",je?"border-primary/55 bg-primary/10 text-primary shadow-primary/10":"border-border/80 text-foreground hover:-translate-y-0.5 hover:border-primary/25 hover:bg-background"),children:[a.jsx("button",{type:"button",className:"h-full max-w-[13rem] truncate pl-4 pr-2 text-sm font-semibold",onClick:()=>mt(G.id),title:G.name,children:G.name}),a.jsxs(md,{children:[a.jsx(pd,{asChild:!0,children:a.jsx(st,{type:"button",variant:"ghost",size:"icon",className:Et("mr-1 h-8 w-8 rounded-lg text-muted-foreground hover:bg-background hover:text-foreground",je&&"text-primary/80 hover:text-primary"),"aria-label":`Actions for ${G.name}`,children:a.jsx(dm,{className:"h-4 w-4"})})}),a.jsxs(gd,{align:"end",className:"w-40",children:[a.jsxs(Hi,{onClick:()=>void tt(G.id),children:[a.jsx(C0,{className:"mr-2 h-4 w-4"}),"Clone"]}),a.jsx(P0,{}),a.jsxs(Hi,{className:"text-destructive focus:text-destructive",disabled:b.length<=1,onClick:()=>void Vn(G.id),children:[a.jsx(nc,{className:"mr-2 h-4 w-4"}),"Delete"]})]})]})]},G.id)}),a.jsxs(st,{type:"button",variant:"outline",size:"sm",className:"h-11 shrink-0 gap-1.5 rounded-xl border-dashed bg-background px-4 shadow-sm hover:border-primary/40 hover:bg-primary/5",onClick:()=>void En(),children:[a.jsx(rc,{className:"h-4 w-4"}),"New Blank"]})]})]})]}),(()=>{const G=ma,je=$v(G,ae),ct=Number(be.dti_pass_threshold),Ye=qt.cashflow,jt=Ye>0,Pt=Qt.filter(Fr=>Fr.score>=.7).length,Te=Pt>0,un=Kb({qualMetrics:sn,creditLimits:Me.creditLimits,helocType:Me.helocType,maxCltvPct:Number(be.max_cltv)}),On=[{label:"FICO",pass:je,detail:G>0?`${G}`:"N/A"},Yb(sn,Me.helocType,ct),...un.items,{label:"Cashflow",pass:jt,detail
1198:Zt(Ye)},{label:"Lender Matches",pass:Te,detail:`${Pt}`},...Ct.eligible?[{label:"HECM",pass:!0,detail:"Candidate"}]:[]];return a.jsx(kv,{items:On})})(),a.jsx(_b,{lead:Xn??f,scenarioId:v,ficoScore:(Ae==null?void 0:Ae.fico_score)??null,citizenshipStatus:(Ae==null?void 0:Ae.citizenship_status)??null,legacyIsUsCitizen:(Ae==null?void 0:Ae.is_us_citizen)??!1,isMilitaryVeteran:(Ae==null?void 0:Ae.is_military_veteran)??!1,hecmOpportunity:Ct,hecmPropertyId:(ga==null?void 0:ga.id)??null,readOnly:Ze,highlights:Un,previewAdditionalClients:Zn}),a.jsx(Lb,{rawBreakers:Ae==null?void 0:Ae.financial_deal_breakers,scenarioSyncKey:v??"",disabled:!(Ae!=null&&Ae.id)||K||Ze,isSaving:k.isPending,highlights:Un,onPatch:async G=>{await k.mutateAsync({financial_deal_breakers:G})}}),Ae!=null&&Ae.mortgage_statement_path?a.jsx(rn,{children:a.jsxs(on,{className:"flex flex-wrap items-center justify-between gap-3 p-4",children:[a.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[a.jsx(xd,{className:"h-5 w-5 shrink-0 text-primary"}),a.jsxs("div",{className:"min-w-0",children:[a.jsx("p",{className:"text-sm font-medium",children:"Mortgage statement"}),a.jsx("p",{className:"truncate text-xs text-muted-foreground",children:Ae.mortgage_statement_file_name??"Uploaded with assessment"})]})]}),a.jsx(st,{type:"button",variant:"outline",size:"sm",onClick:()=>void pa(),children:"View statement"})]})}):null,a.jsx(R1,{properties:Re,leadId:e,scenarioId:v,isMilitaryVeteran:(Ae==null?void 0:Ae.is_military_veteran)??!1,hecmOpportunity:Ct,readOnly:Ze,highlights:Un,onSave:async G=>{await L.mutateAsync(G)},onSetFocusProperty:async G=>{Ze||await H.mutateAsync(G)},onToggleConsolidation:async(G,je)=>{if(!v)throw new Error("An intake scenario is required.");const ct=["lead-properties",e,v];s.setQueryData(ct,jt=>(jt??[]).map(Pt=>Pt.id===G?{...Pt,is_consolidated:je,ignored:je?!1:Pt.ignored}:Pt));const{error:Ye}=await nt.from("lead_properties").update(je?{is_consolidated:!0,ignored:!1}:{is_consolidated:!1}).eq("id",G).eq("lead_id",e).eq("scenario_id",v);if(Ye)throw Ye;s.invalidateQueries({queryKey:["lead-properties",e,v]})},onToggleIgnoreInStrategy:async(G,je)=>{if(!v)throw new Error("An intake scenario is required.");const ct=["lead-properties",e,v];s.setQueryData(ct,jt=>(jt??[]).map(Pt=>Pt.id===G?{...Pt,ignored:je,is_consolidated:je?!1:Pt.is_consolidated}:Pt));const{error:Ye}=await nt.from("lead_properties").update(je?{ignored:!0,is_consolidated:!1}:{ignored:!1}).eq("id",G).eq("lead_id",e).eq("scenario_id",v);if(Ye)throw Ye;s.invalidateQueries({queryKey:["lead-properties",e,v]})}},`properties-${v??"none"}`),a.jsx($1,{debts:Gt,readOnly:Ze,highlights:Un,onSave:async G=>{R(null),await te.mutateAsync(G)},onToggleIgnoreInStrategy:async(G,je)=>{const ct=["lead-debts",e,v];s.setQueryData(ct,Ye=>(Ye??[]).map(jt=>jt.id===G?{...jt,ignored:je,is_consolidated:je?!1:jt.is_consolidated}:jt)),await nt.from("lead_debts").update(je?{ignored:!0,is_consolidated:!1}:{ignored:!1}).eq("id",G),s.invalidateQueries({queryKey:["lead-debts",e,v]})},onToggleConsolidation:async(G,je)=>{const ct=["lead-debts",e,v];s.setQueryData(ct,Ye=>(Ye??[]).map(jt=>jt.id===G?{...jt,is_consolidated:je,ignored:je?!1:jt.ignored}:jt)),await nt.from("lead_debts").update({is_consolidated:je}).eq("id",G),s.invalidateQueries({queryKey:["lead-debts",e,v]})},onConsolidateAll:async()=>{if(!v)return;const G=["lead-debts",e,v];s.setQueryData(G,ct=>(ct??[]).map(Ye=>Ye.ignored?Ye:{...Ye,is_consolidated:!0}));const{error:je}=await nt.from("lead_debts").update({is_consolidated:!0}).eq("scenario_id",v).eq("ignored",!1);if(je)throw je;R(!0),s.invalidateQueries({queryKey:["lead-debts",e,v]})},onEditConsolidationChange:R,formatCurrency:Zt,metrics:lt,displayedMonthlyCashflow:qt.cashflow,baseMonthlyCashflow:qt.baseCashflow,reservesForPaydown:(Ae==null?void 0:Ae.reserves_for_paydown)??0,consolidationLtvPercent:Mm(Ae==null?void 0:Ae.consolidation_ltv_percent),onSaveConsolidationLtv:async G=>{await k.mutateAsync({consolidation_ltv_percent:G})},primaryPropertyValue:(cn==null?void 0:cn.estimated_value)??0,primaryMortgageBalance:(cn==null?void 0:cn.outstanding_mortgage_balance)??0,properties:Re,forceShowConsolidation:De===!0}
1198,`debts-${v??"none"}`),a.jsx(O1,{expenses:yn,onSave:async G=>{await se.mutateAsync(G)},formatCurrency:Zt,readOnly:Ze,highlights:Un},`expenses-${v??"none"}`),a.jsx(w1,{assessment:Ae,onSave:async G=>{await k.mutateAsync(G)},formatCurrency:Zt,primaryClientName:Xn??f?`${(Xn??f).first_name} ${(Xn??f).last_name}`:"Primary",additionalClients:fr,readOnly:Ze,highlights:Un,onSaveClientFields:async(G,je)=>{await nt.from("lead_additional_clients").update(je).eq("id",G),s.invalidateQueries({queryKey:["lead-additional-clients",e]})}}),a.jsxs("section",{children:[a.jsxs("h2",{className:"mb-3 flex items-center gap-2 text-xl font-semibold tracking-tight text-foreground",children:[a.jsx(Pl,{className:"h-5 w-5 text-primary"}),"Cash Flow Summary"]}),a.jsx(rn,{className:"overflow-hidden rounded-2xl border-border/70 shadow-sm",children:a.jsx(on,{className:"p-4",children:(()=>{const G=qt,je=Re.filter(tn=>["rental","vacation_rental"].includes(tn.property_type)),ct=je.reduce((tn,pr)=>tn+Number(pr.rental_income??0),0),Ye=je.reduce((tn,pr)=>tn+Number(pr.rental_expenses??0),0),jt=je.reduce((tn,pr)=>tn+Number(pr.mortgage_payment??0),0),Pt=G.selectedHelocType==="1st_lien",Te=Pt?G.primaryTaxesInsurance:G.displayedPitiPayment,un=G.displayedHelocPayment,On=G.displayedCashflow,Fr=(Me.chunkSize??0)>0?`${Zt(G.displayedDrawnBalance)} drawn (incl. first chunk)`:`${Zt(G.displayedDrawnBalance)} drawn`,ea=St==="stress"?`Qualifying IO on full line @ ${(Number(be.stress_test_rate)+2).toFixed(2)}%`:`Strategy IO on ${Fr} @ ${Me.interestRate.toFixed(2)}%`,ba=je.length>0&&(ct>0||Ye>0||jt>0),Rt=ba?"Net Income (incl. Rental)":"Monthly Net Income",mr=G.isRentalFocus?Number((cn==null?void 0:cn.mortgage_payment)??0):0,Aa=G.netRentalCf+mr,Ks=ba?`$${G.monthlyNetIncome.toLocaleString()} + $${Aa.toLocaleString()} ${G.isRentalFocus?"rental before focus PITI":"net rental"}`:void 0,ta=[{label:Rt,value:Zt(G.displayedCombinedNetIncome),color:"text-success",show:!0,sub:Ks},{label:Pt?"Taxes & Insurance":"PITI Payment",value:Te>0?`-${Zt(Te)}`:"$0",color:"text-destructive",show:!0,sub:Pt?"Principal & interest replaced by 1st lien HELOC":Te>0?"Focus property plus other owned non-rental residences":void 0},{label:"HOA / condo dues",value:G.hoaMonthly>0?`-${Zt(G.hoaMonthly)}`:"$0",color:"text-destructive",show:!0},{label:Pt?"1st Lien HELOC Pmt":"2nd Lien HELOC/PLOC/HSF Pmt",value:un>0?`-${Zt(un)}`:"$0",color:"text-destructive",show:Pt||G.selectedHelocType==="2nd_lien",sub:ea},{label:G.hasConsolidation?"Non-Mortgage Debts":"Non-Mortgage Debt Pmt",value:G.nonConsolidatedDebtPayments>0?`-${Zt(G.nonConsolidatedDebtPayments)}`:"$0",color:"text-destructive",show:!0},{label:"Monthly Expenses",value:`-${Zt(G.totalExpenses)}`,color:"text-destructive",show:!0}].filter(tn=>tn.show);return a.jsxs("div",{className:"space-y-2",children:[a.jsx("div",{className:"flex justify-end",children:a.jsxs("div",{className:"relative z-50 flex items-center gap-1.5 text-[11px] text-muted-foreground",children:[a.jsx("span",{className:Et(St==="stress"&&"text-foreground"),children:"Stress test"}),a.jsx(Ga,{checked:St==="input",onCheckedChange:tn=>Oe(tn?"input":"stress"),"aria-label":"Use input rate for Monthly Cashflow",className:"scale-75"}),a.jsx("span",{className:Et(St==="input"&&"text-foreground"),children:"Input rate"})]})}),a.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-4 xl:grid-cols-7",children:[ta.map((tn,pr)=>a.jsxs("div",{className:"rounded-xl border border-border/70 bg-muted/20 px-3 py-3",children:[a.jsx("p",{className:"mb-1 text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:tn.label}),a.jsx("p",{className:`text-base font-bold tabular-nums ${tn.color}`,children:tn.value}),tn.sub&&a.jsx("p",{className:"mt-1 text-[11px] leading-snug text-muted-foreground",children:tn.sub})]},pr)),a.jsxs("div",{className:"rounded-xl border border-primary/20 bg-primary/5 px-3 py-3 shadow-sm sm:col-span-2 lg:col-span-1",children:[a.jsx("p",{className:"mb-1 text-[11px] font-semibold uppercase tracking-wide text-primary/80",children:G.hasConsolidation?"Adjusted Monthly Cashflow":"Monthly Cashflow"}),a.jsxs("p",{className:`text-xl font-bold tabular-nums ${On>=0?"text-success":"text-destructive"}`,children:[On>=0?"":"-",Zt(Math.abs(On))]}),G.hasConsolidation&&a.jsxs("p",{className:"mt-1 text-[11px] leading-snug text-muted-foreground",children:["Was ",Zt(G.baseCashflow)]})]})]})]})})()})})]}),a.jsxs(um,{defaultValue:"calculator",className:"w-full",children:[a.jsx("div",{className:"sticky top-0 z-30 -mx-1 mb-4 rounded-2xl border border-border/80 bg-background/95 p-2 shadow-md backdrop-blur-md supp
1198orts-[backdrop-filter]:bg-background/85 sm:top-2",children:a.jsxs(hm,{className:"grid h-auto min-h-[3rem] w-full grid-cols-2 gap-2 rounded-xl bg-muted/50 p-1.5 sm:grid-cols-3 md:grid-cols-4",children:[a.jsx(eo,{className:kl,value:"calculator",children:a.jsxs("span",{className:"inline-flex items-center gap-1.5",children:["Calculator",Ze&&_r?a.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-warning","aria-label":"Calculator results changed in this version"}):null]})}),a.jsx(eo,{className:kl,value:"amortization",children:"Amortization"}),a.jsx(eo,{className:kl,value:"daily",children:"Daily"}),a.jsx(eo,{className:kl,value:"lender_match",children:"Product Match"})]})}),a.jsx(ml,{value:"calculator",className:"mt-4",children:a.jsx(wv,{leadId:e,scenarioId:v,selectedHelocType:Me.helocType,assessment:Ae,properties:Re,debts:Gt,expenses:yn,metrics:lt,qualificationMetrics:sn,firstLienPropertyTypeSupported:vs,additionalClients:fr.map(G=>({monthlyNetIncome:G.monthlyNetIncome})),onTrackerDataChanged:we,onHelocParamsChanged:vt,onStrategyPayoffComparisonChanged:br,onSaveReserves:async G=>{Ze||await k.mutateAsync({reserves_for_paydown:G})}},`${e}-${v}`)}),a.jsx(ml,{value:"amortization",className:"mt-4",children:a.jsx(Lv,{focusProperty:cn})}),a.jsx(ml,{value:"daily",className:"mt-4",children:ve.length>0?a.jsx(E0,{trackerData:ve,locInterestRate:Me.interestRate}):a.jsx(rn,{children:a.jsx(on,{className:"py-6 text-center text-muted-foreground",children:"Run a calculation in the Calculator tab first to see the daily tracker."})})}),a.jsxs(ml,{value:"lender_match",className:"mt-4 space-y-3",children:[xe?a.jsxs(qs,{variant:"destructive",children:[a.jsx(ms,{className:"h-4 w-4"}),a.jsx(Io,{children:"Could not load lender selections"}),a.jsx(ps,{children:Am(xe)})]}):null,a.jsx(r1,{matches:Qt,leadStatus:f==null?void 0:f.status,selectionEnabled:Hr,selectedKeys:Bn,onSelectionChange:rt,selectionSaving:ie})]})]}),Ze&&(_r||lr)?a.jsxs(qs,{children:[a.jsx(ms,{className:"h-4 w-4"}),a.jsx(Io,{children:"Calculator / AI in this version"}),a.jsxs(ps,{children:[_r?"Saved calculator results differ from the comparison snapshot. ":null,lr?"AI analysis differs from the comparison snapshot.":null]})]}):null,a.jsx(Ob,{result:ue,isLoading:_e,eligibilityTier:rr.tier,onReanalyze:()=>Ce(Oa)}),a.jsx(a1,{open:E,onOpenChange:z,lead:f,intakeScenarioId:v}),f?a.jsx(l1,{open:X!=null,onOpenChange:G=>{G||Z(null)},product:X,lead:f,scenarioId:v,properties:Re}):null,a.jsx(yb,{open:le,onOpenChange:fe,lead:f,scenarioName:La,assessment:Ae,properties:Re,debts:Gt,expenses:yn,metrics:Sa,cashflow:xa,additionalClients:$r,calculatorPayoffComparison:((Tn=_t[Me.helocType])==null?void 0:Tn.comparison)??null,aiAnalysis:bs,helocTermsRows:Ba,suggestedLenders:He}),a.jsx(Kv,{open:ze,onOpenChange:ye,scenarioId:v,selectedVersionId:Ee,onSelectVersion:de,compareMode:Ue,onCompareModeChange:qe,compareVersionId:$e,onCompareVersionIdChange:Ge,onRestore:()=>{(async()=>(!Ht||await Ht.confirmLeave())&&et(!0))()}}),a.jsx(Qv,{open:bt,onOpenChange:et,isPending:Nt.isPending,onConfirm:({restoreLeadContact:G,scope:je})=>{if(!Ee||Nt.isPending)return;const ct=v;Nt.mutateAsync({versionId:Ee,restoreLeadContact:G,scope:je}).then(()=>{if(et(!1),de(null),ye(!1),je!=="lead"||!e)return;const Ye=s.getQueryData(["lead-intake-scenarios",e]);if((Ye==null?void 0:Ye.some(Te=>Te.id===ct))||!(Ye!=null&&Ye.length))return;const Pt=Ye.find(Te=>Te.name==="Default")??Ye[0];Pt&&r(Te=>{const un=new URLSearchParams(Te);return un.set("scenario",Pt.id),un},{replace:!0})})}})]})})};function d_(){return a.jsx(d1,{children:a.jsx(c_,{})})}const b_=Object.freeze(Object.defineProperty({__proto__:null,default:d_},Symbol.toStringTag,{value:"Module"}));export{b_ as A,pn as _};

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.