PageSourceSearch

https://www.floodfirefix.com/_next/static/chunks/14771-b6105aa82e98585a.js

js floodfirefix.com collected 2026-10-08 07:18:57 UTC 32,307 bytes, 3 lines download raw bytes

1
2!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e._posthogReleaseId=e._posthogReleaseId||"01a11221-842e-0000-df20-67b5a60582a7";var n=(new e.Error).stack;n&&(e._posthogChunkIds=e._posthogChunkIds||{},e._posthogChunkIds[n]="0a22d2d3-70aa-529b-b714-13438998cb1d")}catch(e){}}();(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[14771],{300:(e,a,t)=>{"use strict";t.d(a,{FR:()=>h,HI:()=>m,JA:()=>f,ve:()=>g});var n=t(68987),s=t(2315),l=t(10826),i=t(52928),r=t(11535),o=t(93746),c=t(64115);let d=l.Gi,u=0,p=()=>`cf-${++u}`;function m(e,a){let t=new Set((0,l.YY)(e,null)),n=a??{};return(0,l.YY)(e,a).map(e=>({id:t.has(e)?`cf-defined-${e}`:p(),key:e,value:null==n[e]?"":String(n[e]),defined:t.has(e)}))}function h(e,a){let t={};for(let a of e){let e=a.key.trim();e&&!(0,l.HP)(e)&&a.value.trim()&&(t[e]=a.value)}let n=a??{};for(let e of d){let a=n[e];"string"==typeof a&&a.trim()&&(t[e]=a)}return t}function f(e,a){return JSON.stringify(e.map(e=>[e.key,e.value]))===JSON.stringify(a.map(e=>[e.key,e.value]))}function g({value:e,onChange:a,adding:t,onAddingChange:s,disabled:l=!1,idPrefix:i="cf",isPhone:o=!1}){let d=0===e.length;return(0,n.jsxs)(c.wn,{title:"Custom fields",sectionId:"custom",addLabel:d?void 0:"Add field",onAdd:()=>s(!0),addDisabled:l,children:[d?(0,n.jsx)("div",{className:"lc",children:(0,n.jsx)(c.SE,{label:"Add field",onClick:()=>s(!0),disabled:l})}):(0,n.jsx)("div",{className:o?"flex flex-col gap-[14px]":"grid grid-cols-2 gap-x-3 gap-y-[14px]",children:e.map(t=>(0,n.jsxs)("div",{className:"field min-w-0 last:odd:col-span-2",children:[(0,n.jsxs)("div",{className:"cf-h",children:[(0,n.jsx)("label",{htmlFor:`${i}-${t.id}`,children:t.key}),t.defined?null:(0,n.jsx)("button",{type:"button",className:"cf-rm","aria-label":`Remove ${t.key}`,disabled:l,onClick:n=>{var s;let l;return s=t.id,l=n.currentTarget.closest("[data-sec]"),void(a(e.filter(e=>e.id!==s)),requestAnimationFrame(()=>l?.querySelector(".sec-add, .lc-add")?.focus()))},children:(0,n.jsx)(r.sK,{strokeWidth:2})})]}),(0,n.jsx)("div",{className:"input",children:(0,n.jsx)("input",{id:`${i}-${t.id}`,"aria-label":t.key,placeholder:"Value…",value:t.value,disabled:l,onChange:n=>{let s,l;return s=t.id,l=n.target.value,a(e.map(e=>e.id===s?{...e,value:l}:e))}})})]},t.id))}),t?(0,n.jsx)(v,{idPrefix:i,isPhone:o,taken:e.map(e=>e.key),onClose:()=>s(!1),onAdd:(t,n)=>{a([...e,{id:p(),key:t,value:n,defined:!1}]),s(!1)}}):null]})}function v({idPrefix:e,isPhone:a,taken:t,onClose:r,onAdd:d}){let[u,p]=(0,s.useState)(""),[m,h]=(0,s.useState)(""),f=u.trim(),g=(0,l.HP)(f),y=!!f&&t.some(e=>e.trim().toLowerCase()===f.toLowerCase()),x=!!f&&!g&&!y;function j(){x&&d(f,m.trim())}let k=e=>{"Enter"===e.key&&(e.preventDefault(),j())};return(0,n.jsxs)(o.Ds,{title:"Add field",description:"A name and a value for a field only this account carries.",width:400,isPhone:a,onClose:r,footer:(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(i.$,{variant:"outline",type:"button",onClick:r,children:"Cancel"}),(0,n.jsx)(i.$,{type:"button",disabled:!x,onClick:j,children:"Add field"})]}),children:[(0,n.jsx)(c.A_,{id:`${e}-cf-new-key`,label:"Field name",autoComplete:"off",placeholder:"e.g. Gate code",value:u,onValueChange:p,onKeyDown:k,error:g?"That name is already a built-in field.":y?"There's already a field with that name.":null}),(0,n.jsx)(c.A_,{id:`${e}-cf-new-value`,label:"Value",autoComplete:"off",placeholder:"Value…",value:m,onValueChange:h,onKeyDown:k})]})}},4192:(e,a,t)=>{"use strict";t.d(a,{Z:()=>d});var n=t(68987),s=t(2315),l=t(96578),i=t(11535),r=t(15541),o=t(17692);let c=["image/jpeg","image/png","image/webp"];function d({websiteId:e,displayName:a,avatarUrl:t,onUploaded:u}){let{toast:p}=(0,o.dj)(),m=(0,s.useRef)(null),[h,f]=(0,s.useState)(!1),[g,v]=(0,s.useState)(!1),y=a.trim().length>0;async function x(a){if(!c.includes(a.type))return void p({title:"Unsupported file",description:"Use a JPEG, PNG, or WebP image.",variant:"destructive"});if(a.size>0xc00000)return void p({title:"File too large",description:"Maximum size is 12MB.",variant:"destructive"});f(!0);try{let t=new FormData;t.append("file",a),t.append("websiteId",e),t.append("type","customer-avatar");let n=await fetch("/api/upload",{method:"POST",body:t});if(!n.ok)throw Error("upload failed");let{url:s}=await n.json();if(!s)throw Error("no url returned");u(s)}catch{p({title:"Couldn't upload photo",description:"Please try again.",variant:"destructive"})}finally{f(!1)}}return(0,n.jsxs)("button",{type:"button",className:`ava ava-upload${g?" is-drag":""}${h?" is-busy":""}`,"aria-label":t?"Change account photo":"Add an account photo",onClick:()=>!h&&m.current?.click(),onDragOver:e=>{e.preventDefault(),g||v(!0)},onDragLeave:()=>v(!1),onDrop:function(e){e.preventDefault(),v(!1);let a=e.dataTransfer.files?.[0];a&&x(a)},children:[t?(0,n.jsx)("img",{className:"ava-img",src:t,alt:a||"Account photo"}):y?(0,n.jsx)("span",{className:"ava-initials",children:(0,r.yC)(a)}):(0,n.jsx)(l.mD,{name:"person",className:"ava-empty","aria-hidden":!0}),(0,n.jsx)("span",{className:"ava-overlay","aria-hidden":"true",children:h?(0,n.jsx)(l.mD,{name:"spinner"}):(0,n.jsx)(i.i7,{})}),(0,n.jsx)("input",{ref:m,type:"file",accept:c.join(","),hidden:!0,onChange:e=>{let a=e.target.files?.[0];a&&x(a),e.target.value=""}})]})}},5047:(e,a,t)=>{"use strict";t.d(a,{D:()=>b});var n=t(68987),s=t(2315),l=t(73591),i=t(7586),r=t(38489),o=t(89121),c=t(39707),d=t(17692),u=t
2(60660),p=t(64115),m=t(34206),h=t(40999),f=t(300),g=t(52928),v=t(96578),y=t(15541),x=t(4192),j=t(45201);function k(e,a){return{kind:e?.kind??"person",company:(e?.kind==="company"?e.company??e.display_name:e?.company)??"",avatar_url:e?.avatar_url??null,tags:e?.tags?[...e.tags]:[],cfRows:(0,f.HI)(a,e?.custom_fields??null),leadSource:(0,o.rM)(e?.attribution?.source??"")}}function b({open:e,websiteId:a,initial:t,seedName:S,definedCustomFieldNames:_,onClose:D,onSaved:$,onOpenExisting:P,openExistingLabel:L="Open",onCreated:E,nested:A=!1}){let{toast:M}=(0,d.dj)(),R=(0,s.useMemo)(()=>_??[],[_]),[F,O]=(0,s.useState)(()=>k(t,R)),[T,q]=(0,s.useState)(!1),[I,K]=(0,s.useState)(null),[J,W]=(0,s.useState)(()=>t||!S?.trim()?[]:[(0,u.Hz)({isPrimary:!0,name:S.trim()})]),[B,H]=(0,s.useState)(()=>J),[z,U]=(0,s.useState)({}),[V,G]=(0,s.useState)([]),[Q,Y]=(0,s.useState)([]),[Z,X]=(0,s.useState)([]),[ee,ea]=(0,s.useState)([]),[et,en]=(0,s.useState)(null),[es,el]=(0,s.useState)(null),[ei,er]=(0,s.useState)(!1),[eo,ec]=(0,s.useState)(null),ed=(0,l.jE)(),eu=(0,u.zA)(),ep=!!t,em="company"===F.kind,eh=(0,o.rM)(t?.attribution?.source??""),ef=(0,i.I)({queryKey:c.qk.customerContacts(a,t?.id??"new"),queryFn:async()=>{let e=await fetch(`/api/websites/${a}/crm/customers/${t.id}/contacts`);if(!e.ok)throw Error("Failed to load contacts");return(await e.json()).contacts??[]},enabled:e&&!!t}),eg=(0,s.useRef)(!1);(0,s.useEffect)(()=>{if(eg.current||!ef.data)return;eg.current=!0;let e=(0,u.Md)(ef.data),a=e.length>0?e:[(0,u.Hz)({isPrimary:!0})];W(a),H(a)},[ef.data]);let ev=w(a,t?.id??null,"service",e),ey=w(a,t?.id??null,"billing",e);C(ev.data,G,Y),C(ey.data,X,ea);let ex=(e,a)=>O(t=>({...t,[e]:a})),ej=J.find(e=>e.isPrimary)??J[0]??null,ek=ej?.name.trim()??"",eb=em?F.company.trim():ek,ew=J.some(e=>{let a=(0,u._5)(e,{phoneInvalid:e=>!(0,y.TC)(e),emailInvalid:e=>!(0,y.B9)(e)});return a.phone||a.email}),eC=!!eb&&!!(ej?.phone.trim()||ej?.email.trim())&&!ew;async function eN(e,t,n){let s=(0,j.WD)(n);if((0!==s.length||ep)&&!(await fetch(`/api/websites/${a}/crm/customers/${e}/addresses`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({kind:t,addresses:s})})).ok)throw Error(`Saved the account, but couldn't save the ${t} addresses`)}async function eS(e){if(eC){q(!0),K(null),U({});try{let n=ep?`/api/websites/${a}/crm/customers/${t.id}`:`/api/websites/${a}/crm/customers`,s=await fetch(n,{method:ep?"PATCH":"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(function(e){let a=F.company.trim()||null,n={force:e,kind:F.kind,avatar_url:F.avatar_url,company:a,tags:F.tags,custom_fields:(0,f.FR)(F.cfRows,t?.custom_fields)};if(em&&(n.display_name=a??void 0),!ep){let e=(0,r.iy)(ek);n.first_name=em?null:e.first||null,n.last_name=em?null:e.last||null,em||(n.display_name=ek||void 0),n.primary_phone=ej?.phone.trim()||null,n.primary_email=ej?.email.trim()||null,n.sms_consent=ej?.smsOk??!1}if(F.leadSource!==eh){let e=(0,o.Sj)(F.leadSource,new Date().toISOString());e&&(n.attribution=e)}return n}(e))});if(409===s.status){let e=await s.json().catch(()=>null);if(e?.duplicate){K(e.duplicate),q(!1);return}}if(!s.ok){let e=await s.json().catch(()=>null);throw Error(e?.error||"Save failed")}let l=await s.json().catch(()=>null),i=ep?t.id:l?.id;if(!i)throw Error("Save failed");let d=`/api/websites/${a}/crm/customers/${i}/contacts`,p=ef.data??[],m=J;if(!ep){let e=await fetch(d),a=e.ok?await e.json().catch(()=>null):null;p=a?.contacts??[];let t=p.find(e=>e.is_primary)?.id??p[0]?.id??null;m=J.map(e=>e.key===ej?.key?{...e,id:t}:e)}await (0,u.Cu)({base:d,plan:(0,u.GJ)(p,m),onCreated:(e,a)=>W(t=>t.map(t=>t.key===e?{...t,id:a}:t))}),ed.invalidateQueries({queryKey:c.qk.customerContacts(a,i)}),await eN(i,"service",V),await eN(i,"billing",Z),ed.invalidateQueries({queryKey:c.qk.customerAddresses(a,i)}),M({title:ep?"Account updated":`Added ${eb||"account"}`}),!ep&&l&&E?.(l),$()}catch(e){e instanceof u.sr&&(U({[e.key]:e.message}),ep&&ed.invalidateQueries({queryKey:c.qk.customerContacts(a,t.id)})),M({variant:"destructive",title:"Couldn't save",description:e instanceof Error?e.message:"Please try again."}),q(!1)}}}
2let e_=(em?F.company.trim():ek)||(ep?t.display_name:""),eD=(0,s.useMemo)(()=>{let e=k(t,R);return JSON.stringify({...F,cfRows:null})!==JSON.stringify({...e,cfRows:null})||!(0,f.JA)(F.cfRows,e.cfRows)||JSON.stringify(J.map(N))!==JSON.stringify(B.map(N))||JSON.stringify((0,j.WD)(V))!==JSON.stringify((0,j.WD)(Q))||JSON.stringify((0,j.WD)(Z))!==JSON.stringify((0,j.WD)(ee))},[F,t,R,J,B,V,Q,Z,ee]);function e$(){if(!T){if(eD)return void ec("discard");D()}}let eP=!!(et||es||ei||eo),eL=I?(0,n.jsxs)("div",{className:"nc-dup",children:[(0,n.jsx)("span",{className:"wi",children:(0,n.jsx)(v.mD,{name:"warn"})}),(0,n.jsxs)("div",{className:"wmain",children:[(0,n.jsx)("div",{className:"wt",children:"This account is already on file"}),(0,n.jsxs)("div",{className:"wd",children:["It belongs to ",(0,n.jsx)("b",{children:I.display_name}),I.primary_phone?` \xb7 ${(0,y.qH)(I.primary_phone)}`:"",". ",L," that record to avoid a duplicate, or add anyway."]}),P?(0,n.jsxs)("button",{type:"button",className:"wopen",onClick:()=>P(I.id,I),children:[(0,n.jsx)(v.mD,{name:"arrow"}),L," ",I.display_name.split(" ")[0]]}):null]})]}):null,eE=(0,n.jsxs)("section",{className:"ce-ident","data-sec":"identity",children:[(0,n.jsx)(x.Z,{websiteId:a,displayName:e_,avatarUrl:F.avatar_url,onUploaded:e=>ex("avatar_url",e)}),(0,n.jsx)(p.A_,{id:"nc-company",label:em?"Account name":"Company",value:F.company,onValueChange:e=>ex("company",e),placeholder:em?"e.g. Reyes Bakery":"e.g. Russo Auto",autoComplete:"off"})]}),eA=(0,n.jsxs)("div",{className:"flex flex-col gap-[14px]",children:[(0,n.jsx)(m.g,{value:F.leadSource,onChange:e=>ex("leadSource",e),isPhone:eu,clearable:!eh,idPrefix:"nc",disabled:T}),(0,n.jsx)(h.U,{value:F.tags,onChange:e=>ex("tags",e),isPhone:eu,idPrefix:"nc",disabled:T})]}),eM=(0,n.jsx)(f.ve,{value:F.cfRows,onChange:e=>ex("cfRows",e),adding:ei,onAddingChange:er,disabled:T,idPrefix:"nc",isPhone:eu}),eR=(0,n.jsxs)(g.$,{type:"button",size:eu?"md":"default",disabled:!eC||T||ep&&!eD,onClick:()=>eS(!!I),children:[T?(0,n.jsx)("span",{className:"btn-spin"}):null,T?ep?"Saving…":"Adding…":I?"Add anyway":ep?"Save changes":"Add account"]}),eF=(0,n.jsx)(g.$,{type:"button",variant:"outline",size:eu?"md":"default",disabled:T,onClick:e$,children:"Cancel"}),eO=eu?(0,n.jsxs)("div",{className:"sheet-f stack",children:[eR,eF]}):(0,n.jsxs)("div",{className:"form-foot",children:[eF,eR]});return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(u.yR,{open:e,onRequestClose:e$,overlayOpen:eP,nested:A,title:ep?"Edit account":"New account",description:"People, service and billing addresses, tags and custom fields for this account.",banner:eL,primary:(0,n.jsxs)(n.Fragment,{children:[eE,ef.isLoading?(0,n.jsx)(u.XX,{}):(0,n.jsx)(u.UI,{value:J,onEditingChange:el,errors:z,disabled:T,idPrefix:"nc"}),eA]}),secondary:(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(u.JF,{service:V,billing:Z,onEditingChange:en,serviceLoading:ev.isLoading,billingLoading:ey.isLoading,disabled:T}),eM]}),footer:eO,isPhone:eu}),es?(0,n.jsx)(u.q5,{editing:es,value:J,onChange:W,onEditingChange:el,isPhone:eu,idPrefix:"nc",phoneInvalid:e=>!(0,y.TC)(e),emailInvalid:e=>!(0,y.B9)(e),maskPhone:y.$0}):null,et?(0,n.jsx)(u.Wv,{editing:et,value:"billing"===et.kind?Z:V,onChange:"billing"===et.kind?X:G,onEditingChange:en,isPhone:eu,idPrefix:"nc"}):null,(0,n.jsx)(u.g7,{open:"discard"===eo,heading:"Discard your changes?",cancelLabel:"Keep editing",confirmLabel:"Discard",onCancel:()=>ec(null),onConfirm:()=>{ec(null),D()},children:"Nothing you typed here has been saved yet."})]})}function w(e,a,t,n){return(0,i.I)({queryKey:c.qk.customerAddresses(e,a??"new",t),queryFn:async()=>{let n=await fetch(`/api/websites/${e}/crm/customers/${a}/addresses?kind=${t}`);if(!n.ok)throw Error("Failed to load addresses");return(await n.json()).addresses??[]},enabled:n&&!!a})}function C(e,a,t){let n=(0,s.useRef)(!1),l=(0,s.useRef)({apply:a,applyBase:t});l.current={apply:a,applyBase:t},(0,s.useEffect)(()=>{if(n.current||!e)return;n.current=!0;let a=(0,j.Z1)(e);l.current.apply(a),l.current.applyBase(a)},[e])}function N(e){return[e.name.trim(),e.title.trim(),e.phone.trim(),e.email.trim(),e.smsOk,e.isPrimary]}},12132:()=>{},14771:(e,a,t)=>{"use strict";t.d(a,{a:()=>x});var n=t(68987),s=t(2315),l=t(74721),i=t(5047),r=t(15541),o=t(6921);let c={search:2,plus:2.2,check:2.6,company:1.9,camera:2,phone:2,mail:2,pin:2,x:2},d={search:(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("circle",{cx:"11",cy:"11",r:"8"}),(0,n.jsx)("path",{d:"m21 21-4.3-4.3",strokeLinecap:"round"})]}),plus:(0,n.jsx)("path",{d:"M12 5v14M5 12h14",strokeLinecap:"round"}),check:(0,n.jsx)("path",{d:"M20 6 9 17l-5-5",strokeLinecap:"round",strokeLinejoin:"round"}),company:(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("rect",{x:"4",y:"2",width:"16",height:"20",rx:"2"}),(0,n.jsx)("path",{d:"M9 22v-4h6v4M8 6h.01M16 6h.01M8 10h.01M16 10h.01M8 14h.01M16 14h.01",strokeLinecap:"round"})]}),camera:(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("path",{d:"M23 19a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4l2-3h6l2 3h4a2 2 0 0 1 2 2z",strokeLinecap:"round",strokeLinejoin:"round"}),(0,n.jsx)("circle",{cx:"12",cy:"13",r:"4",strokeLinecap:"round",strokeLinejoin:"round"})]}),phone:(0,n.jsx)("path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6A19.79 19.79 0 0 1 2.18 4.18 2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72c.13.96.36 1.9.7 2.81a2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45c.9
21.34 1.85.57 2.81.7A2 2 0 0 1 22 16.92z",strokeLinejoin:"round"}),mail:(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",strokeLinecap:"round",strokeLinejoin:"round"}),(0,n.jsx)("path",{d:"M22 6 12 13 2 6",strokeLinecap:"round",strokeLinejoin:"round"})]}),pin:(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("path",{d:"M20 10c0 6-8 12-8 12s-8-6-8-12a8 8 0 0 1 16 0z",strokeLinecap:"round",strokeLinejoin:"round"}),(0,n.jsx)("circle",{cx:"12",cy:"10",r:"3",strokeLinecap:"round",strokeLinejoin:"round"})]}),x:(0,n.jsx)("path",{d:"M18 6 6 18M6 6l12 12",strokeLinecap:"round"})};function u({name:e,className:a}){return(0,n.jsx)("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:c[e],className:a,"aria-hidden":"true",children:d[e]})}var p=t(41671),m=t(65836),h=t(48486);function f({customer:e}){return(0,n.jsx)(l.H,{className:"cp-av",name:e.display_name,avatarUrl:e.avatar_url})}function g(e){let a=[(0,r.qH)(e.primary_phone),e.primary_email?.trim()].filter(Boolean).join(" \xb7 ");return a||(e.company&&e.company!==e.display_name?e.company:"")}function v({rows:e}){return(0,n.jsx)("div",{className:"cp-skels","data-testid":"account-picker-skeleton","aria-busy":"true",role:"presentation",children:Array.from({length:e},(e,a)=>(0,n.jsxs)("div",{className:"cp-skel",children:[(0,n.jsx)(o.E,{className:"cp-skel-av"}),(0,n.jsxs)("div",{className:"cpm",children:[(0,n.jsx)(o.E,{className:"cp-skel-bar",style:{width:`${56-8*a}%`}}),(0,n.jsx)(o.E,{className:"cp-skel-bar sub",style:{width:`${34-4*a}%`}})]})]},a))})}function y({websiteId:e,listId:a,q:t,known:l,value:i,showCard:r,hi:o,setHi:c,onPick:d,onState:p,searchField:x,searchRef:j,onSearchChange:k,onSearchKey:b,onClear:w,clearLabel:C,onClearPick:N}){let S=(0,m.l$)(e,t,{known:l}),{rows:_,searching:D}=S;(0,s.useEffect)(()=>{p({rows:_,searching:D})},[p,_,D]);let $=t.trim(),P=0===_.length&&(D||S.loading);return(0,n.jsxs)(n.Fragment,{children:[x?(0,n.jsxs)("div",{className:"cp-search",onClick:()=>j.current?.focus(),children:[(0,n.jsx)(u,{name:"search"}),(0,n.jsx)("input",{ref:j,value:t,onChange:e=>k(e.target.value),onKeyDown:b,placeholder:"Search accounts",autoComplete:"off",role:"combobox","aria-expanded":!0,"aria-controls":a,"aria-autocomplete":"list"})]}):null,(0,n.jsxs)("div",{className:"cp-list",id:a,role:"listbox",onScroll:S.onListScroll,children:[w&&!$?(0,n.jsxs)("div",{className:`cp-row cp-clear${null==i?" sel":""}`,role:"option","aria-selected":null==i,onMouseDown:e=>{e.preventDefault(),N()},children:[(0,n.jsx)("span",{className:"cp-av none",children:(0,n.jsx)(u,{name:"x"})}),(0,n.jsx)("div",{className:"cpm",children:(0,n.jsx)("div",{className:"nm",children:C})}),null==i?(0,n.jsx)("span",{className:"cp-chk",children:(0,n.jsx)(u,{name:"check"})}):null]}):null,_.map((e,a)=>{let t=g(e);return(0,n.jsxs)("div",{className:`cp-row${i?.id===e.id?" sel":""}${a===o?" hi":""}`,role:"option","aria-selected":i?.id===e.id,onMouseDown:a=>{a.preventDefault(),d(e)},onMouseEnter:()=>c(a),children:[(0,n.jsx)(f,{customer:e}),(0,n.jsxs)("div",{className:"cpm",children:[(0,n.jsx)("div",{className:"nm",children:e.display_name}),t?(0,n.jsx)("div",{className:"svc",children:t}):null]}),i?.id===e.id?(0,n.jsx)("span",{className:"cp-chk",children:(0,n.jsx)(u,{name:"check"})}):r?(0,n.jsx)("span",{className:`cp-meta${(0,h.o0)(e).dim?" dim":""}`,children:(0,h.o0)(e).label}):null]},e.id)}),_.length>0&&S.hasMore?(0,n.jsx)(v,{rows:1}):null,P?(0,n.jsx)(v,{rows:4}):null,0!==_.length||P?null:(0,n.jsx)("div",{className:"cp-empty",children:S.failed?"Could not load accounts":$?`No accounts match “${$}”`:"No accounts yet"})]})]})}function x({websiteId:e,known:a,value:t,onChange:l,showCard:r=!1,allowCreate:o=!0,onCreated:c,onClear:d,clearLabel:m="No account",contentClassName:v}){let j=(0,s.useId)(),[k,b]=(0,s.useState)(!1),[w,C]=(0,s.useState)(!1),[N,S]=(0,s.useState)(""),[_,D]=(0,s.use
2State)(-1),[$,P]=(0,s.useState)([]),[L,E]=(0,s.useState)(""),[A,M]=(0,s.useState)(0),[R,F]=(0,s.useState)({rows:[],searching:!1}),O=(0,s.useRef)(null),T=(0,s.useRef)(null),q=(0,s.useMemo)(()=>{let e=new Set;return[...$,...t?[t]:[],...a??[]].filter(a=>!e.has(a.id)&&(e.add(a.id),!0))},[$,t,a]),I=null!=t&&$.some(e=>e.id===t.id);function K(e){b(e),D(-1),t&&S(""),e||F({rows:[],searching:!1})}function J(e){l(e),b(!1),C(!1),S(""),D(-1)}function W(){o&&(E(N.trim()),M(e=>e+1),b(!1),C(!0))}function B(e){let a=R.rows;if("ArrowDown"===e.key)e.preventDefault(),D(Math.min(_+1,a.length-1));else if("ArrowUp"===e.key)e.preventDefault(),D(Math.max(_-1,0));else if("Enter"===e.key){e.preventDefault();let t=a[_]??a[0];t?J(t):R.searching||W()}}return(0,s.useEffect)(()=>{if(!k)return;let e=window.setTimeout(()=>O.current?.focus(),30);return()=>window.clearTimeout(e)},[k]),(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)(p.AM,{open:k,onOpenChange:K,modal:!0,children:[(0,n.jsx)("div",{className:"crm-cpick",children:t?(0,n.jsx)(p.Wv,{asChild:!0,children:(0,n.jsxs)("div",{className:"cp-pick",role:"button",tabIndex:0,onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&(e.preventDefault(),K(!k))},children:[(0,n.jsx)(f,{customer:t}),(0,n.jsxs)("div",{className:"cpm",children:[(0,n.jsxs)("div",{className:"nm",children:[t.display_name,I?(0,n.jsx)("span",{className:"cp-newtag",children:"New"}):null]}),(0,n.jsx)("div",{className:"svc",children:g(t)})]}),(0,n.jsx)("span",{className:"cp-chg",children:k?"Close":"Change"})]})}):(0,n.jsx)(p.dT,{asChild:!0,children:(0,n.jsxs)("div",{ref:T,className:"cp-field",onClick:()=>{O.current?.focus(),k||K(!0)},children:[(0,n.jsx)(u,{name:"search"}),(0,n.jsx)("input",{ref:O,"data-testid":"account-picker-field",value:N,onChange:e=>{S(e.target.value),D(-1),k||b(!0)},onKeyDown:function(e){"Escape"===e.key?k&&(e.preventDefault(),e.stopPropagation(),K(!1)):k||"ArrowDown"!==e.key&&"Enter"!==e.key?B(e):(e.preventDefault(),K(!0))},placeholder:"Search accounts","aria-label":"Account",autoComplete:"off",role:"combobox","aria-expanded":k,"aria-controls":k?j:void 0,"aria-autocomplete":"list"})]})})}),(0,n.jsx)(p.hl,{align:"start",sideOffset:8,collisionPadding:12,onOpenAutoFocus:e=>e.preventDefault(),onPointerDownOutside:e=>{T.current?.contains(e.target)&&e.preventDefault()},onEscapeKeyDown:e=>{e.preventDefault(),b(!1)},className:`crm-cpick w-[var(--radix-popover-trigger-width)] border-0 bg-transparent p-0 shadow-none${v?` ${v}`:""}`,children:(0,n.jsxs)("div",{className:"cp-pop",onKeyDown:function(e){"Escape"===e.key&&(e.stopPropagation(),b(!1))},children:[(0,n.jsx)(y,{websiteId:e,listId:j,q:N,known:q,value:t,showCard:r,hi:_,setHi:D,onPick:J,onState:F,searchField:!!t,searchRef:O,onSearchChange:e=>{S(e),D(-1)},onSearchKey:B,onClear:d,clearLabel:m,onClearPick:function(){d?.(),b(!1),S(""),D(-1)}}),o?(0,n.jsx)("div",{className:"cp-foot",children:(0,n.jsxs)("button",{type:"button",className:"cp-newbtn",onClick:W,children:[(0,n.jsx)(u,{name:"plus"}),N.trim()&&0===R.rows.length&&!R.searching?(0,n.jsxs)("span",{children:["Add “",(0,n.jsx)("b",{children:N.trim()}),"” as a new account"]}):"New account"]})}):null]})})]}),w?(0,n.jsx)(i.D,{open:!0,websiteId:e,initial:null,seedName:L,nested:!0,openExistingLabel:"Use",onClose:()=>C(!1),onSaved:()=>C(!1),onCreated:e=>{P(a=>[e,...a.filter(a=>a.id!==e.id)]),c?.(e),J(e)},onOpenExisting:(a,t)=>{let n=q.find(e=>e.id===a)??R.rows.find(e=>e.id===a)??(t?(0,h.BR)(t,e):null);C(!1),n&&J(n)}},A):null]})}t(89600)},20460:(e,a,t)=>{"use strict";t.d(a,{b:()=>o});var n=t(68987),s=t(2315),l=t(25002),i=t(41671),r=t(11535);function o({id:e,label:a,options:t,onPick:c,multiple:d=!1,closedValue:u="",placeholder:p,openPlaceholder:m,chips:h,onRemoveChip:f,isPhone:g,disabled:v}){let[y,x]=(0,s.useState)(!1),[j,k]=(0,s.useState)(""),[b,w]=(0,s.useState)(null),C=(0,s.useRef)(null),N=(0,s.useRef)(null),S=(0,s.useRef)(null),_=(0,s.useRef)(!1),D=(0,s.useRef)(!1),$=(0,s.useCallback)(e=>{if(S.current=e,!e)return;let a=e=>e.stopPropagation();return e.addEventListener("wheel",a,{passive:!0}),e.addEventListener("touchmove",a,{passive:!0}),()=>{e.removeEventListener("wheel",a),e.removeEventListener("touchmove",a),S.current=null}},[]),P=t(j),L=null===b?-1:P.findIndex(e=>e.key===b),E=y&&!v&&P.length>0,A=`${e}-list`,M=a=>`${e}-opt-${a}`;function R(e){let a=t(e);return e.trim()?a[0]?.key??null:d?null:a.find(e=>e.selected)?.key??null}function F(){y||v||(_.current=!0,x(!0),k(""),w(R("")))}function O(){x(!1),k(""),w(null)}function T(e,a=!1){let t=c(e,{typed:a});d?(k(""),w(t||e.key)):O()}(0,s.useEffect)(()=>
2{if(!_.current||L<0)return;let e=S.current,a=e?.querySelector(`[data-index="${L}"]`);if(!e||!a)return;_.current=!1;let t=e.getBoundingClientRect(),n=a.getBoundingClientRect();n.top<t.top+6?e.scrollTop-=t.top+6-n.top:n.bottom>t.bottom-6&&(e.scrollTop+=n.bottom-(t.bottom-6))});let q=(0,n.jsx)("input",{ref:N,id:e,role:"combobox","aria-expanded":E,"aria-controls":E?A:void 0,"aria-autocomplete":"list","aria-activedescendant":E&&L>=0?M(L):void 0,autoComplete:"off",spellCheck:!1,disabled:v,value:y?j:u,placeholder:y?m:h?.length?void 0:p,onChange:e=>{var a;return a=e.target.value,void(_.current=!0,x(!0),k(a),w(R(a)))},onFocus:()=>{D.current||F()},onKeyDown:function(e){if(!e.nativeEvent.isComposing){switch(e.key){case"ArrowDown":case"ArrowUp":e.preventDefault(),E?function(e){if(!P.length)return;let a=L>=0?L:1===e?-1:P.length;_.current=!0,w(P[(a+e+P.length)%P.length].key)}("ArrowDown"===e.key?1:-1):F();return;case"Enter":if(!E)return;e.preventDefault(),L>=0&&T(P[L],!!j.trim());return;case"Escape":case"Tab":y&&O();return;case"Backspace":!j&&h?.length&&f&&f(h[h.length-1]);return}y||1!==e.key.length||e.metaKey||e.ctrlKey||e.altKey||(0,l.flushSync)(F)}}});return(0,n.jsxs)(i.AM,{open:E,onOpenChange:e=>{e||O()},children:[(0,n.jsx)(i.dT,{asChild:!0,children:(0,n.jsxs)("div",{ref:C,className:d?"pk-field pk-multi":"pk-field","data-open":E||void 0,"data-touch":g||void 0,"data-disabled":v||void 0,onMouseDown:e=>{e.target!==N.current&&e.preventDefault()},onClick:()=>{v||(N.current?.focus(),F())},children:[d?(0,n.jsxs)("div",{className:"pk-chips",children:[h?.map(e=>(0,n.jsxs)("span",{className:"pk-chip",children:[(0,n.jsx)("span",{className:"pk-dot",style:{background:e.dot}}),(0,n.jsx)("span",{children:e.label}),(0,n.jsx)("button",{type:"button",className:"pk-x","aria-label":`Remove ${e.label}`,disabled:v,onClick:a=>{a.stopPropagation(),f?.(e),0===a.detail&&(D.current=!0,N.current?.focus(),D.current=!1)},children:(0,n.jsx)(r.bm,{strokeWidth:2.6})})]},e.key)),q]}):q,(0,n.jsx)(r.yQ,{className:"pk-chev"})]})}),(0,n.jsx)(i.hl,{ref:$,id:A,role:"listbox","aria-label":a,"aria-multiselectable":d||void 0,align:"start",sideOffset:4,collisionPadding:8,className:"pk-menu","data-touch":g||void 0,"data-vaul-no-drag":"",onOpenAutoFocus:e=>e.preventDefault(),onCloseAutoFocus:e=>e.preventDefault(),onMouseDown:e=>e.preventDefault(),onInteractOutside:e=>{C.current?.contains(e.target)&&e.preventDefault()},children:P.map((e,a)=>(0,n.jsxs)("div",{id:M(a),"data-index":a,role:"option","aria-selected":!!e.selected,className:"pk-opt","data-active":a===L||void 0,onMouseMove:()=>{b!==e.key&&w(e.key)},onClick:()=>T(e),children:[e.add?(0,n.jsx)(r.FW,{className:"pk-plus",strokeWidth:2.2}):e.dot?(0,n.jsx)("span",{className:"pk-dot",style:{background:e.dot}}):null,(0,n.jsx)("span",{children:e.label}),e.selected?(0,n.jsx)(r.Jl,{className:"pk-ck",strokeWidth:2.4}):null]},e.key))})]})}t(12132)},34206:(e,a,t)=>{"use strict";t.d(a,{g:()=>r});var n=t(68987),s=t(89121),l=t(20460),i=t(64115);function r({value:e,onChange:a,isPhone:t,clearable:o,idPrefix:c="ls",disabled:d}){let u=(0,s.rM)(e),p=`${c}-lead-source`;return(0,n.jsx)(i.D0,{label:"Lead source",htmlFor:p,children:(0,n.jsx)(l.b,{id:p,label:"Lead source",options:function(e){let a=(0,s.rM)(e),t=a.toLowerCase(),n=(0,s.j7)(u),l=n.filter(e=>e.toLowerCase().includes(t)).map(e=>({key:e,label:e,value:e,selected:e===u}));return t&&!n.some(e=>e.toLowerCase()===t)&&l.push({key:"\0add",label:`Add source “${a}”`,value:a,add:!0}),l},onPick:function(e){e.value!==u?a(e.value):o&&a("")},closedValue:u,placeholder:"Choose a source",openPlaceholder:"Search or add a source",isPhone:t,disabled:d})})}},40999:(e,a,t)=>{"use strict";t.d(a,{U:()=>d});var n=t(68987),s=t(96578),l=t(20460),i=t(64115);let r=["Residential","Commercial","VIP","Maintenance","Warranty","Repeat","Referral","Past due"],o=e=>e.toLowerCase(),c=e=>`var(${(0,s.Sf)(e).c})`;function d({value:e,onChange:a,isPhone:t,idPrefix:u="tg",disabled:p}){let m=`${u}-tags`,h=[];for(let a of e){let e=(0,s.Sf)(a).label;h.some(a=>o(a)===o(e))||h.push(e)}let f=e=>h.some(a=>o(a)===o(e));function g(t){a(e.filter(e=>o((0,s.Sf)(e).label)!==o(t)))}let v=h.map(e=>({key:o(e),label:e,dot:c(e)}));return(0,n.jsx)(i.D0,{label:"Tags",htmlFor:m,children:(0,n.jsx)(l.b,{id:m,label:"Tags",multiple:!0,options:function(e){let a=[...r,...h.filter(e=>!r.some(a=>o(a)===o(e)))],t=e.trim().replace(/\s+/g," "),n=o(t),s=a.filter(e=>o(e).includes(n)).map(e=>({key:o(e),label:e,value:e,selected:f(e),dot:c(e)}));return n&&!a.some(e=>o(e)===n)&&s.push({key:"\0add",label:`Add tag “${t}”`,value:t,add:!0}),s},onPick:function(t,{typed:n}){let l=(0,s.Sf)(t.value).label;return f(l)?t.add||n||g(l):a([...e,l]),o(l)},chips:v,onRemoveChip:e=>g(e.label),placeholder:"Choose tags",openPlaceholder:"Search or add a tag",isPhone:t,disabled:p})})}},48486:(e,a,t)=>{"use strict";t.d(a,{BR:()=>i,o0:()=>l,wh:()=>s});var n=t(5058);function s(e,a){let t=a.trim().toLowerCase();if(!t)return e;let s=(0,n.Bx)(a);return e.filter(e=>e.display_name.toLowerCase().includes(t)||(e.company?.toLowerCase().includes(t)??!1)||s.length>0&&(0,n.Bx)(e.primary_phone).includes(s))}function l(e){return e.card_last4?{label:`${e.card_brand??"Card"} \xb7\xb7${e.card_last4}`,dim:!1}:{label:"No card",dim:!0}}function i(e,a){return{id:e.id,website_id:a,kind:"person",first_name:null,last_name:null,display_name:e.display_name,company:null,avatar_url:null,primary_phone:e.primary_phone,primary_email:e.primary_email,secondary_phones:[],secondary_emails:[],address:null,tags:[],lifetime_value_cents:0,card_brand:null,card_last4:null,card_exp_month:null,card_exp_year:null,email_marketing_status:null,sms_consent:!1,sms_consent_at:null,last_activity_type:null,last_activity_at:null,open_opportunity_count:0,created_at:new Date(0).toISOString(),updated_at:new Date(0).toISOString()}}t(15541)},65836:(e,a,t)=>{"use strict";t.d(a,{l$:()=>o,vQ:()=>c});var n=t(2315),s=t(65649),l=t(7586),i=t(39707),r=t(48486);function o(e,a,t){let l=t?.enabled??!0,o=t?.known,c=a.trim(),d=function(e){let[a,t]=(0,n.use
2State)(e);return(0,n.useEffect)(()=>{let a=window.setTimeout(()=>t(e),250);return()=>window.clearTimeout(a)},[e,250]),a}(c),u=(0,s.q)({queryKey:i.qk.customerSearch(e,d),enabled:l&&!!e,initialPageParam:0,staleTime:6e4,refetchOnWindowFocus:!1,queryFn:async({pageParam:a,signal:t})=>{let n=new URLSearchParams({page:String(a)});d&&n.set("q",d);let s=await fetch(`/api/websites/${e}/crm/customers/search?${n.toString()}`,{signal:t,cache:"no-store"});if(!s.ok)throw Error(`Failed to load accounts (${s.status})`);let l=await s.json();return{customers:l.customers??[],total:l.total??0,page:l.page??0,pageSize:l.pageSize??0}},getNextPageParam:e=>(e.page+1)*e.pageSize<e.total?e.page+1:void 0}),p=u.data?.pages,m=(0,n.useMemo)(()=>(p??[]).flatMap(e=>e.customers),[p]),h=(0,n.useMemo)(()=>{if(!o||0===o.length)return m;let e=(0,r.wh)([...o],c);if(0===e.length)return m;let a=new Set(e.map(e=>e.id));return[...e,...m.filter(e=>!a.has(e.id))]},[o,m,c]),f=d!==c,g=(0,n.useCallback)(e=>{let a=e.currentTarget;a.scrollTop+a.clientHeight<a.scrollHeight-48||u.hasNextPage&&!u.isFetchingNextPage&&u.fetchNextPage()},[u]);return{rows:h,searching:l&&(u.isFetching||f),loading:l&&u.isLoading,failed:u.isError&&0===m.length,total:p?.[0]?.total??0,hasMore:u.hasNextPage,onListScroll:g}}function c(e,a,t=[]){let n=a?t.find(e=>e.id===a)??null:null,{data:s,isLoading:r}=(0,l.I)({queryKey:i.qk.accountById(e,a??""),queryFn:async({signal:t})=>{let n=await fetch(`/api/websites/${e}/crm/customers/${a}`,{signal:t});if(404===n.status)return null;if(!n.ok)throw Error(`Failed to load account (${n.status})`);return(await n.json()).customer??null},enabled:!!(e&&a)&&!n,staleTime:3e5});return a?{account:n??s??null,pending:!n&&r}:{account:null,pending:!1}}},74721:(e,a,t)=>{"use strict";t.d(a,{H:()=>l});var n=t(68987),s=t(15541);function l({name:e,avatarUrl:a,className:t,style:i,title:r}){if(a)return(0,n.jsx)("span",{className:t,role:"img","aria-label":e,title:r,style:{...i,backgroundImage:`url("${a.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}")`,backgroundSize:"cover",backgroundPosition:"center",backgroundRepeat:"no-repeat"}});return(0,n.jsx)("span",{className:t,style:i,title:r,children:(0,s.yC)(e)})}},89121:(e,a,t)=>{"use strict";t.d(a,{Sj:()=>o,fT:()=>s,hW:()=>n,j7:()=>r,rM:()=>i});let n="Google Ads",s="Google Local Services",l=["Referral / word of mouth","Google search",n,"Facebook","Nextdoor","Yelp","Website","Social media","Repeat customer"];function i(e){return e.trim().replace(/\s+/g," ").slice(0,200)}function r(e){let a,t=i(e);return(a=i(t))&&!l.some(e=>e===a)?[...l,t]:[...l]}function o(e,a){let t=i(e);return t?{source:t,captured_at:a,via:"manual"}:null}},89600:()=>{}}]);
3//# chunkId=0a22d2d3-70aa-529b-b714-13438998cb1d

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.