1"use strict";(self.webpackChunkfrontend=self.webpackChunkfrontend||[]).push([[6652],{6652(e,t,a){a.r(t),a.d(t,{default:()=>B});var s=a(9379),l=a(9950),d=a(9284),r=a(3581),n=a(9870);const i=(0,n.A)("mountain",[["path",{d:"m8 3 4 8 5-5 5 15H2L8 3z",key:"otkl63"}]]);var c=a(602),o=a(7255),x=a(2989),m=a(446),u=a(2828),p=a(7737),h=a(6987);const b=(0,n.A)("cloud",[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]]),g=(0,n.A)("cloud-off",[["path",{d:"M10.94 5.274A7 7 0 0 1 15.71 10h1.79a4.5 4.5 0 0 1 4.222 6.057",key:"1uxyv8"}],["path",{d:"M18.796 18.81A4.5 4.5 0 0 1 17.5 19H9A7 7 0 0 1 5.79 5.78",key:"99tcn7"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);var f=a(9318);const v=(0,n.A)("keyboard",[["path",{d:"M10 8h.01",key:"1r9ogq"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M7 16h10",key:"wp8him"}],["path",{d:"M8 12h.01",key:"czm47f"}],["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}]]),j=(0,n.A)("flask-conical",[["path",{d:"M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2",key:"18mbvz"}],["path",{d:"M6.453 15h11.094",key:"3shlmq"}],["path",{d:"M8.5 2h7",key:"csnxdl"}]]);var k=a(8890),y=a(6243),N=a(1570),w=a(9469),A=a(1641),C=a(1742),S=a(7224),z=a(4321),_=a(8276),M=a(4814),P=a(7304),L=a(2607),I=a(1064),H=a(9401),D=a(381),F=a(4414);const G=[{value:"openai",label:"OpenAI"},{value:"ghl",label:"GoHighLevel (GHL)"},{value:"stripe",label:"Stripe"},{value:"twilio",label:"Twilio"},{value:"custom",label:"Custom"}];function E(e){let{children:t}=e;return(0,F.jsx)("div",{className:"text-xs text-slate-400 dark:text-slate-500 italic py-6 text-center border border-dashed border-slate-200 dark:border-slate-700 rounded-lg",children:t})}function V(){const e=(0,D.d)(),[t,a]=(0,l.useState)(!0),[s,d]=(0,l.useState)([]),[r,n]=(0,l.useState)([]),[i,c]=(0,l.useState)("openai"),[o,m]=(0,l.useState)(""),[u,p]=(0,l.useState)(""),[b,g]=(0,l.useState)(""),[f,v]=(0,l.useState)(!1),[j,k]=(0,l.useState)("profile"),[N,w]=(0,l.useState)(""),[A,C]=(0,l.useState)(""),[S,V]=(0,l.useState)(""),[K,O]=(0,l.useState)(!1),[T,R]=(0,l.useState)(!1),B=(0,l.useCallback)(async()=>{a(!0);try{const[e,t]=await Promise.all([H.default.getVaultCredentials().catch(()=>({credentials:[]})),H.default.getVaultFormFields().catch(()=>({form_fields:[]}))]);d(e&&e.credentials||[]),n(t&&t.form_fields||[])}catch(t){e.error(t.message||"Could not load your vault \u2014 please try again")}a(!1)},[e]);(0,l.useEffect)(()=>{B()},[B]);const q="w-full px-3 py-2 text-sm border border-slate-200 dark:border-slate-700 dark:bg-slate-900 rounded-lg focus:border-kw-red outline-none";return(0,F.jsxs)("div",{"data-testid":"vault-section",children:[(0,F.jsxs)("div",{className:"bg-white dark:bg-slate-800 rounded-xl shadow-sm border border-slate-100 dark:border-slate-700 p-5 mb-5","data-testid":"vault-credentials-card",children:[(0,F.jsxs)("div",{className:"flex items-start justify-between mb-1",children:[(0,F.jsxs)("h2",{className:"font-heading font-medium text-base text-slate-800 dark:text-slate-100 flex items-center gap-2",children:[(0,F.jsx)(z.A,{size:16,className:"text-kw-red"}),"API Keys & Credentials"]}),(0,F.jsx)("button",{onClick:B,title:"Refresh","data-testid":"vault-refresh-btn",className:"text-slate-400 hover:text-kw-red transition-colors",children:(0,F.jsx)(h.A,{size:14})})]}),(0,F.jsx)("p",{className:"text-xs text-slate-400 mb-1",children:"Connected keys Patti and the browser extension use to act on your behalf."}),(0,F.jsxs)("p",{className:"text-[11px] text-emerald-600 dark:text-emerald-400 bg-emerald-50 dark:bg-emerald-900/20 inline-flex items-center gap-1 px-2 py-0.5 rounded mb-4 font-medium",children:[(0,F.jsx)(y.A,{size:11})," Encrypted & stored securely \u2014 never shown again after you save."]}),t?(0,F.jsxs)("div",{className:"flex items-center gap-2 text-sm text-slate-500 dark:text-slate-400 py-3",children:[(0,F.jsx)(x.A,{size:14,className:"animate-spin"})," Loading your keys\u2026"]}):0===s.length?(0,F.jsx)(E,{children:"No API keys stored yet. Add one below."}):(0,F.jsx)("div",{className:"space-y-2","data-testid":"vault-credentials-list",children:s.map(t=>(0,F.jsxs)("div",{"data-testid":"vault-credential-".concat(t.vault_id),className:"flex items-center justify-between gap-3 p-3 rounded-lg border border-slate-200 dark:border-slate-700 bg-slate-50 dark:bg-slate-900/40",children:[(0,F.jsxs)("div",{className:"min-w-0",children:[(0,F.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,F.jsx)("span",{className:"text-[10px] font-bold uppercase tracking-wide px-1.5 py-0.5 rounded bg-slate-200 dark:bg-slate-700 text-slate-600 dar
1k:text-slate-300",children:t.integration||"custom"}),(0,F.jsx)("span",{className:"text-sm font-medium text-slate-700 dark:text-slate-200 truncate",children:t.name}),t.label&&(0,F.jsxs)("span",{className:"text-xs text-slate-400 truncate",children:["\u2014 ",t.label]})]}),(0,F.jsxs)("div",{className:"flex items-center gap-1 mt-1 text-xs text-slate-400 font-mono",children:[(0,F.jsx)(_.A,{size:10})," ",t.masked_preview||"\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022"]})]}),(0,F.jsx)("button",{onClick:()=>(async t=>{if(window.confirm("Delete the ".concat(t.integration||"",' key "').concat(t.name,'"? Patti and the extension will no longer be able to use it.')))try{await H.default.deleteVaultCredential(t.vault_id),e.success("Key deleted"),await B()}catch(a){e.error(a.message||"Could not delete that key")}})(t),title:"Delete key","data-testid":"vault-credential-delete-".concat(t.vault_id),className:"flex-shrink-0 text-slate-400 hover:text-red-500 transition-colors p-1.5",children:(0,F.jsx)(M.A,{size:15})})]},t.vault_id))}),(0,F.jsxs)("form",{onSubmit:async t=>{if(t&&t.preventDefault&&t.preventDefault(),o.trim()&&u){v(!0);try{await H.default.addVaultCredential({integration:i,name:o.trim(),value:u,label:b.trim()||void 0}),m(""),p(""),g(""),e.success("Key saved securely"),await B()}catch(a){e.error(a.message||"Could not save that key")}v(!1)}else e.error("Give the key a name and paste its value")},className:"mt-4 pt-4 border-t border-slate-100 dark:border-slate-700 space-y-3","data-testid":"vault-credential-form",children:[(0,F.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,F.jsxs)("div",{children:[(0,F.jsx)("label",{className:"block text-xs font-medium text-slate-600 dark:text-slate-300 mb-1",children:"Integration"}),(0,F.jsx)("select",{"data-testid":"vault-credential-integration",className:q,value:i,onChange:e=>c(e.target.value),children:G.map(e=>(0,F.jsx)("option",{value:e.value,children:e.label},e.value))})]}),(0,F.jsxs)("div",{children:[(0,F.jsx)("label",{className:"block text-xs font-medium text-slate-600 dark:text-slate-300 mb-1",children:"Name"}),(0,F.jsx)("input",{"data-testid":"vault-credential-name",type:"text",autoComplete:"off",className:q,value:o,onChange:e=>m(e.target.value),placeholder:"e.g. api_key"})]})]}),(0,F.jsxs)("div",{children:[(0,F.jsx)("label",{className:"block text-xs font-medium text-slate-600 dark:text-slate-300 mb-1",children:"Value"}),(0,F.jsx)("input",{"data-testid":"vault-credential-value",type:"password",autoComplete:"new-password",name:"vault-credential-value",className:q,value:u,onChange:e=>p(e.target.value),placeholder:"Paste the secret \u2014 write-only, hidden after saving"})]}),(0,F.jsxs)("div",{children:[(0,F.jsxs)("label",{className:"block text-xs font-medium text-slate-600 dark:text-slate-300 mb-1",children:["Label ",(0,F.jsx)("span",{className:"text-slate-400 font-normal",children:"(optional)"})]}),(0,F.jsx)("input",{"data-testid":"vault-credential-label",type:"text",autoComplete:"off",className:q,value:b,onChange:e=>g(e.target.value),placeholder:"e.g. Personal OpenAI account"})]}),"openai"===i&&(0,F.jsxs)("p",{className:"text-[11px] text-amber-600 dark:text-amber-400 bg-amber-50 dark:bg-amber-900/20 flex items-center gap-1.5 px-2 py-1.5 rounded","data-testid":"vault-openai-note",children:[(0,F.jsx)(P.A,{size:12,className:"flex-shrink-0"}),"Adding your OpenAI key makes Patti's realtime voice use ",(0,F.jsx)("strong",{children:"your"})," key for billing."]}),(0,F.jsxs)("button",{type:"submit","data-testid":"vault-credential-save",disabled:f,className:"flex items-center gap-2 px-4 py-2 bg-kw-red text-white text-sm font-medium rounded-lg hover:bg-kw-red-hover transition-colors disabled:opacity-60",children:[f?(0,F.jsx)(x.A,{size:14,className:"animate-spin"}):(0,F.jsx)(L.A,{size:14}),f?"Saving\u2026":"Add Key"]})]})]}),(0,F.jsxs)("div",{className:"bg-white dark:bg-slate-800 rounded-xl shadow-sm border border-slate-100 dark:border-slate-700 p-5 mb-5","data-testid":"vault-formfields-card",children:[(0,F.jsxs)("h2",{className:"font-heading font-medium text-base text-slate-800 dark:text-slate-100 mb-1 flex items-center gap-2",children:[(0,F.jsx)(I.A,{size:16,className:"text-kw-red"}),"Autofill / Profile"]}),(0,F.jsx)("p",{className:"text-xs text-slate-400 mb-1",children:"Fields Patti and the extension use to fill forms for you (address, name, logins)."}),(0,F.jsxs)("p",{className:"text-[11px] text-emerald-600 dark:text-emerald-400 bg-emerald-50 dark:bg-emerald-900/20 inline-flex items-center gap-1 px-2 py-0.5 rounded mb-4 font-medium",children:[(0,F.jsx)(y.A,{size:11})," Sensitive fields are encrypted & masked. Non-sensitive fields (like your address) stay readable."]}),t?(0,F.jsxs)("div",{className:"flex items-center gap-2 text-sm text-slate-500 dark:text-slate-400 py-3",children:[(0,F.jsx)(x.A,{size:14,className:"animate-spin"})," Loading your fields\u2026"]}):0===r.length?(0,F.jsx)(E,{children:"No autofill fields yet. Add one below."}):(0,F.jsx)("div",{className:"space-y-2","data-testid":"vault-formfields-list",children:r.map(t=>{const a=t.sensitive?t.masked_preview||"\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022":null!=t.value?t.value:null!=t.display_value?t.display_value:t.masked_preview||"";return(0,F.jsxs)("div",{"data-testid":"vault-formfield-".concat(t.vault_id),className:"flex items-center justify-between gap-3 p-3 rounded-lg border border-slate-200 dark:border-slate-700 bg-slate-50 dark:bg-slate-900/40",children:[(0,F.jsxs)("div",{className:"min-w-0",children:[(0,F.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,F.jsx)("span",{className:"text-[10px] font-bold uppercase tracking-wide px-1.5 py-0.5 rounded bg-slate-200 dark:bg-slate-700 text-slate-600 dar
1k:text-slate-300",children:t.purpose||"profile"}),(0,F.jsx)("span",{className:"text-sm font-medium text-slate-700 dark:text-slate-200 truncate",children:t.name}),t.label&&(0,F.jsxs)("span",{className:"text-xs text-slate-400 truncate",children:["\u2014 ",t.label]})]}),(0,F.jsxs)("div",{className:"flex items-center gap-1 mt-1 text-xs text-slate-400 font-mono",children:[t.sensitive&&(0,F.jsx)(_.A,{size:10})," ",a]})]}),(0,F.jsx)("button",{onClick:()=>(async t=>{if(window.confirm('Delete the autofill field "'.concat(t.name,'"?')))try{await H.default.deleteVaultFormField(t.vault_id),e.success("Field deleted"),await B()}catch(a){e.error(a.message||"Could not delete that field")}})(t),title:"Delete field","data-testid":"vault-formfield-delete-".concat(t.vault_id),className:"flex-shrink-0 text-slate-400 hover:text-red-500 transition-colors p-1.5",children:(0,F.jsx)(M.A,{size:15})})]},t.vault_id)})}),(0,F.jsxs)("form",{onSubmit:async t=>{if(t&&t.preventDefault&&t.preventDefault(),N.trim()&&A){R(!0);try{await H.default.addVaultFormField({purpose:j.trim()||"profile",name:N.trim(),value:A,label:S.trim()||void 0,sensitive:K}),w(""),C(""),V(""),O(!1),e.success("Autofill field saved"),await B()}catch(a){e.error(a.message||"Could not save that field")}R(!1)}else e.error("Give the field a name and a value")},className:"mt-4 pt-4 border-t border-slate-100 dark:border-slate-700 space-y-3","data-testid":"vault-formfield-form",children:[(0,F.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,F.jsxs)("div",{children:[(0,F.jsx)("label",{className:"block text-xs font-medium text-slate-600 dark:text-slate-300 mb-1",children:"Purpose"}),(0,F.jsx)("input",{"data-testid":"vault-formfield-purpose",type:"text",autoComplete:"off",className:q,value:j,onChange:e=>k(e.target.value),placeholder:"e.g. profile"})]}),(0,F.jsxs)("div",{children:[(0,F.jsx)("label",{className:"block text-xs font-medium text-slate-600 dark:text-slate-300 mb-1",children:"Field name"}),(0,F.jsx)("input",{"data-testid":"vault-formfield-name",type:"text",autoComplete:"off",className:q,value:N,onChange:e=>w(e.target.value),placeholder:"e.g. address, first_name, login-password"})]})]}),(0,F.jsxs)("div",{children:[(0,F.jsx)("label",{className:"block text-xs font-medium text-slate-600 dark:text-slate-300 mb-1",children:"Value"}),(0,F.jsx)("input",{"data-testid":"vault-formfield-value",type:K?"password":"text",autoComplete:K?"new-password":"off",name:"vault-formfield-value",className:q,value:A,onChange:e=>C(e.target.value),placeholder:K?"Secret \u2014 hidden after saving":"e.g. 123 Main St"})]}),(0,F.jsxs)("div",{children:[(0,F.jsxs)("label",{className:"block text-xs font-medium text-slate-600 dark:text-slate-300 mb-1",children:["Label ",(0,F.jsx)("span",{className:"text-slate-400 font-normal",children:"(optional)"})]}),(0,F.jsx)("input",{"data-testid":"vault-formfield-label",type:"text",autoComplete:"off",className:q,value:S,onChange:e=>V(e.target.value),placeholder:"e.g. Home address"})]}),(0,F.jsxs)("label",{className:"flex items-center justify-between cursor-pointer","data-testid":"vault-formfield-sensitive-toggle",children:[(0,F.jsxs)("div",{children:[(0,F.jsx)("span",{className:"text-sm font-medium text-slate-700 dark:text-slate-200",children:"Sensitive"}),(0,F.jsx)("p",{className:"text-xs text-slate-400",children:"Encrypt and mask this field (e.g. passwords). Off = readable autofill value."})]}),(0,F.jsx)("div",{className:"w-10 h-6 rounded-full transition-colors ".concat(K?"bg-kw-red":"bg-slate-200 dark:bg-slate-600"),onClick:()=>O(e=>!e),children:(0,F.jsx)("div",{className:"w-4 h-4 bg-white dark:bg-slate-800 rounded-full mt-1 transition-transform ".concat(K?"ml-5":"ml-1")})})]}),(0,F.jsxs)("button",{type:"submit","data-testid":"vault-formfield-save",disabled:T,className:"flex items-center gap-2 px-4 py-2 bg-kw-red text-white text-sm font-medium rounded-lg hover:bg-kw-red-hover transition-colors disabled:opacity-60",children:[T?(0,F.jsx)(x.A,{size:14,className:"animate-spin"}):(0,F.jsx)(L.A,{size:14}),T?"Saving\u2026":"Add Field"]})]})]})]})}var K=a(5582),O=a(1032),T=a(1046);const R={Building2:d.A,UserCheck:r.A,Mountain:i,Settings:c.A};function B(e){let{userRole:t}=e;const a=(0,D.d)(),r="systems_admin"===t,[n,i]=(0,l.useState)(null),[z,_]=(0,l.useState)(!0),[M,P]=(0,l.useState)(!1),[L,I]=(0,l.useState)(!1),[G,E]=(0,l.useState)(!1),[B,q]=(0,l.useState)(null),[W,U]=(0,l.useState)([]),[Q,Y]=(0,l.useState)(null),[Z,J]=(0,l.useState)(null),[X,$]=(0,l.useState)(""),[ee,te]=(0,l.useState)(""),[ae,se]=(0,l.useState)(!1);(0,l.useEffect)(()=>{Promise.all([H.default.getSettings().then(e=>i(e)),H.default.getIngestionLogs().then(e=>U(e.logs||[])).catch(()=>{}),H.default.getKWQueueStats().then(e=>Y(e)).catch(()=>{}),H.default.getGHLConfig().then(e=>{J(e),te(e.location_id||"")}).catch(()=>{})]).finally(()=>_(!1))},[]);const[le,de]=(0,l.useState)({}),[re,ne]=(0,l.useState)(null),[ie,ce]=(0,l.useState)(null),oe=(0,l.useCallback)(async()=>{try{const e=await H.default.getBetaGraduations(),t={};
1(e.graduations||[]).forEach(e=>{t[e.feature_id]=e}),de(t)}catch(e){}},[]);(0,l.useEffect)(()=>{r&&oe()},[r,oe]);return z||!n?(0,F.jsx)("div",{className:"flex-1 flex flex-col min-h-0 min-w-0 w-full","data-testid":"settings-page",children:(0,F.jsx)(S.A,{})}):(0,F.jsxs)("div",{"data-testid":"settings-page",className:"flex-1",children:[(0,F.jsx)("h1",{className:"font-heading font-semibold text-xl text-kw-dark dark:text-slate-100 mb-6",children:"Settings"}),r&&(0,F.jsxs)("div",{className:"bg-white dark:bg-slate-800 rounded-xl shadow-sm border border-slate-100 dark:border-slate-700 p-5 mb-5",children:[(0,F.jsxs)("h2",{className:"font-heading font-medium text-base text-slate-800 dark:text-slate-100 mb-1 flex items-center gap-2",children:[(0,F.jsx)(o.A,{size:16,className:"text-kw-red"}),"Lead Ingestion"]}),(0,F.jsx)("p",{className:"text-xs text-slate-400 mb-1",children:"Pull leads from Serendipity data feeds into your queue"}),(0,F.jsx)("p",{className:"text-[10px] text-emerald-600 bg-emerald-50 inline-block px-2 py-0.5 rounded mb-4 font-medium",children:"Auto-ingestion daily at 3:00 AM PST"}),(0,F.jsx)("div",{className:"grid grid-cols-2 gap-2 mb-3",children:[{cat:"",label:"All Categories",desc:"Buyers + Sellers + Preforeclosure"},{cat:"buyers",label:"Buyers",desc:"CCWA Buyer leads"},{cat:"sellers",label:"Sellers",desc:"CCWA Seller leads"},{cat:"preforeclosure",label:"Preforeclosure",desc:"Last 24hr filings"}].map(e=>(0,F.jsxs)("button",{"data-testid":"ingest-".concat(e.cat||"all"),onClick:()=>async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";E(!0),q(null);try{const t=await H.default.ingestLeads(e);q(t),H.default.getIngestionLogs().then(e=>U(e.logs||[])).catch(()=>{})}catch(t){q({success:!1,error:t.message})}E(!1)}(e.cat),disabled:G,className:"flex flex-col items-start p-3 rounded-lg border border-slate-200 dark:border-slate-700 hover:border-kw-red/30 hover:bg-kw-red/5 transition-all text-left disabled:opacity-60",children:[(0,F.jsx)("span",{className:"text-sm font-medium text-slate-700 dark:text-slate-200",children:e.label}),(0,F.jsx)("span",{className:"text-[10px] text-slate-400",children:e.desc})]},e.cat))}),G&&(0,F.jsxs)("div",{className:"flex items-center gap-2 text-sm text-slate-500 dark:text-slate-400 py-2",children:[(0,F.jsx)(x.A,{size:14,className:"animate-spin"}),"Fetching leads from Serendipity..."]}),B&&(0,F.jsx)("div",{className:"mt-2 p-3 rounded-lg text-sm ".concat(B.success?"bg-green-50 text-green-700":"bg-red-50 text-red-700"),"data-testid":"ingest-result",children:B.success?(0,F.jsxs)("div",{className:"flex items-center gap-2",children:[(0,F.jsx)(m.A,{size:14}),(0,F.jsxs)("span",{children:["Imported ",B.total_ingested," leads"]}),B.by_category&&(0,F.jsxs)("span",{className:"text-xs text-green-600 ml-2",children:["(",Object.entries(B.by_category).map(e=>{let[t,a]=e;return"".concat(t,": ").concat(a)}).join(", "),")"]})]}):(0,F.jsxs)("div",{className:"flex items-center gap-2",children:[(0,F.jsx)(u.A,{size:14}),(0,F.jsx)("span",{children:B.error||"Import failed"})]})}),W.length>0&&(0,F.jsxs)("div",{className:"mt-3 pt-3 border-t border-slate-100 dark:border-slate-700",children:[(0,F.jsx)("p",{className:"text-xs font-medium text-slate-500 dark:text-slate-400 mb-2",children:"Recent Imports"}),(0,F.jsx)("div",{className:"space-y-1.5 max-h-32 overflow-y-auto",children:W.slice(0,5).map((e,t)=>(0,F.jsxs)("div",{className:"flex items-center justify-between text-xs text-slate-500 dark:text-slate-400",children:[(0,F.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,F.jsx)(p.A,{size:10}),new Date(e.timestamp).toLocaleString()]}),(0,F.jsxs)("span",{className:"font-mono",children:[e.total_ingested," leads"]})]},t))})]})]}),(0,F.jsxs)("div",{className:"bg-white dark:bg-slate-800 rounded-xl shadow-sm border border-slate-100 dark:border-slate-700 p-5 mb-5",children:[(0,F.jsxs)("h2",{className:"font-heading font-medium text-base text-slate-800 dark:text-slate-100 mb-1 flex items-center gap-2",children:[(0,F.jsx)(h.A,{size:16,className:"text-kw-red"}),"KW Command Sync"]}),(0,F.jsx)("p",{className:"text-xs text-slate-400 mb-4",children:"Pending operations to sync with KW Command via companion extension"}),Q?(0,F.jsxs)("div",{className:"grid grid-cols-3 gap-3",children:[(0,F.jsxs)("div",{className:"text-center p-3 bg-amber-50 rounded-lg",children:[(0,F.jsx)("p",{className:"text-lg font-semibold font-heading text-amber-700",children:Q.pending}),(0,F.jsx)("p",{className:"text-[10px] text-amber-600",children:"Pending"})]}),(0,F.jsxs)("div",{className:"text-center p-3 bg-green-50 rounded-lg",children:[(0,F.jsx)("p",{className:"text-lg font-semibold font-heading text-green-700",children:Q.synced}),(0,F.jsx)("p",{className:"text-[10px] text-green-600",children:"Synced"})]}),(0,F.jsxs)("div",{className:"text-center p-3 bg-red-50 rounded-lg",children:[(0,F.jsx)("p",{className:"text-lg font-semibold font-heading text-red-700",children:Q.errors}),(0,F.jsx)("p",{className:"text-[10px] text-red-600",children:"Errors"})]})]}):(0,F.jsx)("p",{className:"text-xs text-slate-400",children:"No sync activity yet"}),(0,F.jsx)("p",{className:"text-[10px] text-slate-400 mt-3 leading-relaxed",children:"When you log call outcomes, tasks, or notes, they are queued here. The companion browser extension will sync these to KW Command when connected. Items are cached until sync completes."}),(0,F.jsxs)("a",{"data-testid":"download-extension-btn",href:T.fT,download:!0,className:"mt-3 flex items-center justify-center gap-2 px-4 py-2.5 bg-kw-dark text-white text-sm font-medium rounded-lg hover:bg-slate-800 transition-colors w-full",children:[(0,F.jsx)(o.A,{size:14}),"Download Patti Extension (.zip)"]}),(0,F.jsx)("p",{className:"text-[10px] text-slate-400 mt-2 text-center leading-relaxed",children:"Install in Chrome: Settings \u2192 Extensions \u2192 Developer Mode ON \u2192 Load Unpacked \u2192 Select extracted folder"})]}),(0,F.jsxs)("div",{className:"bg-white dark:bg-slate-800 rounded-xl shadow-sm border border-slate-100 dar
1k:border-slate-700 p-5 mb-5",children:[(0,F.jsxs)("h2",{className:"font-heading font-medium text-base text-slate-800 dark:text-slate-100 mb-1 flex items-center gap-2",children:[null!==Z&&void 0!==Z&&Z.connected?(0,F.jsx)(b,{size:16,className:"text-green-500"}):(0,F.jsx)(g,{size:16,className:"text-slate-400"}),"GoHighLevel"]}),(0,F.jsx)("p",{className:"text-xs text-slate-400 mb-4",children:"Connect GHL for agent KPI tracking and workflow triggers"}),(0,F.jsxs)("div",{className:"flex items-center gap-2 mb-3",children:[(0,F.jsx)("span",{className:"text-xs px-2 py-0.5 rounded-full font-medium ".concat(null!==Z&&void 0!==Z&&Z.connected?"bg-green-100 text-green-700":"bg-slate-100 dark:bg-slate-800 text-slate-500 dark:text-slate-400"),children:null!==Z&&void 0!==Z&&Z.connected?"Connected":"Not Connected"}),(null===Z||void 0===Z?void 0:Z.api_key_set)&&(0,F.jsx)("span",{className:"text-[10px] text-slate-400",children:"API key configured"})]}),(0,F.jsxs)("div",{className:"space-y-3",children:[(0,F.jsxs)("div",{children:[(0,F.jsx)("label",{className:"block text-xs font-medium text-slate-600 dark:text-slate-300 mb-1",children:"API Key"}),(0,F.jsx)("input",{"data-testid":"ghl-api-key-input",type:"password",autoComplete:"new-password",name:"ghl-api-key",className:"w-full px-3 py-2 text-sm border border-slate-200 dark:border-slate-700 rounded-lg focus:border-kw-red outline-none",value:X,onChange:e=>$(e.target.value),placeholder:null!==Z&&void 0!==Z&&Z.api_key_set?"\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022 (already set)":"Enter GHL API key"})]}),(0,F.jsxs)("div",{children:[(0,F.jsx)("label",{className:"block text-xs font-medium text-slate-600 dark:text-slate-300 mb-1",children:"Location ID"}),(0,F.jsx)("input",{"data-testid":"ghl-location-id-input",type:"text",autoComplete:"off",name:"ghl-location-id",className:"w-full px-3 py-2 text-sm border border-slate-200 dark:border-slate-700 rounded-lg focus:border-kw-red outline-none",value:ee,onChange:e=>te(e.target.value),placeholder:"GHL Location ID"})]}),(0,F.jsx)("button",{"data-testid":"ghl-save-btn",onClick:async()=>{se(!0);try{await H.default.updateGHLConfig({api_key:X||void 0,location_id:ee||void 0});const e=await H.default.getGHLConfig();J(e),$(""),a.success("GoHighLevel settings saved")}catch(e){a.error(e.message||"Could not save GoHighLevel settings")}se(!1)},disabled:ae,className:"px-4 py-2 bg-kw-red text-white text-sm rounded-lg hover:bg-kw-red-hover transition-colors disabled:opacity-60",children:ae?"Saving...":"Save GHL Config"})]})]}),(0,F.jsx)(V,{}),(0,F.jsxs)("div",{className:"bg-white dark:bg-slate-800 rounded-xl shadow-sm border border-slate-100 dark:border-slate-700 p-5 mb-5",children:[(0,F.jsxs)("h2",{className:"font-heading font-medium text-base text-slate-800 dark:text-slate-100 mb-4 flex items-center gap-2",children:[(0,F.jsx)(d.A,{size:16,className:"text-kw-red"}),"CRM Export Configuration"]}),(0,F.jsx)("div",{className:"grid grid-cols-2 gap-3 mb-4",children:O.Ur.map(e=>{const t=R[e.icon]||c.A,a=n.crm_preset===e.value;return(0,F.jsxs)("button",{"data-testid":"crm-preset-".concat(e.value),onClick:()=>i((0,s.A)((0,s.A)({},n),{},{crm_preset:e.value})),className:"flex items-center gap-3 p-3 rounded-lg border-2 transition-all text-left ".concat(a?"border-kw-red bg-kw-red/5":"border-slate-200 dark:border-slate-700 hover:border-slate-300"),children:[(0,F.jsx)(t,{size:18,className:a?"text-kw-red":"text-slate-400"}),(0,F.jsx)("span",{className:"text-sm font-medium ".concat(a?"text-kw-red":"text-slate-600 dark:text-slate-300"),children:e.label})]},e.value)})}),"custom"===n.crm_preset&&(0,F.jsxs)("div",{className:"space-y-3 mt-4 pt-4 border-t border-slate-100 dark:border-slate-700",children:[(0,F.jsxs)("div",{children:[(0,F.jsx)("label",{className:"block text-xs font-medium text-slate-600 dark:text-slate-300 mb-1",children:"API Base URL"}),(0,F.jsx)("input",{"data-testid":"crm-base-url",type:"url",className:"w-full px-3 py-2 text-sm border border-slate-200 dark:border-slate-700 rounded-lg focus:border-kw-red outline-none",value:n.crm_base_url||"",onChange:e=>i((0,s.A)((0,s.A)({},n),{},{crm_base_url:e.target.value})),placeholder:"https://api.yourcrm.com"})]}),(0,F.jsxs)("div",{children:[(0,F.jsx)("label",{className:"block text-xs font-medium text-slate-600 dar
1k:text-slate-300 mb-1",children:"API Key"}),(0,F.jsx)("input",{"data-testid":"crm-api-key",type:"password",autoComplete:"new-password",name:"crm-api-key",className:"w-full px-3 py-2 text-sm border border-slate-200 dark:border-slate-700 rounded-lg focus:border-kw-red outline-none",value:n.crm_api_key||"",onChange:e=>i((0,s.A)((0,s.A)({},n),{},{crm_api_key:e.target.value})),placeholder:"Your CRM API key"})]})]})]}),(0,F.jsxs)("div",{className:"bg-white dark:bg-slate-800 rounded-xl shadow-sm border border-slate-100 dark:border-slate-700 p-5 mb-5",children:[(0,F.jsxs)("h2",{className:"font-heading font-medium text-base text-slate-800 dark:text-slate-100 mb-4 flex items-center gap-2",children:[(0,F.jsx)(f.A,{size:16,className:"text-kw-red"}),"Preferences"]}),(0,F.jsxs)("div",{className:"space-y-4",children:[(0,F.jsxs)("label",{className:"flex items-center justify-between cursor-pointer","data-testid":"auto-advance-toggle",children:[(0,F.jsxs)("div",{children:[(0,F.jsx)("span",{className:"text-sm font-medium text-slate-700 dark:text-slate-200",children:"Auto-advance to next lead"}),(0,F.jsx)("p",{className:"text-xs text-slate-400",children:"Automatically show next lead after logging an outcome"})]}),(0,F.jsx)("div",{className:"w-10 h-6 rounded-full transition-colors ".concat(n.auto_advance?"bg-kw-red":"bg-slate-200 dark:bg-slate-600"),onClick:()=>i((0,s.A)((0,s.A)({},n),{},{auto_advance:!n.auto_advance})),children:(0,F.jsx)("div",{className:"w-4 h-4 bg-white dark:bg-slate-800 rounded-full mt-1 transition-transform ".concat(n.auto_advance?"ml-5":"ml-1")})})]}),(0,F.jsxs)("label",{className:"flex items-center justify-between cursor-pointer","data-testid":"sound-toggle",children:[(0,F.jsxs)("div",{children:[(0,F.jsx)("span",{className:"text-sm font-medium text-slate-700 dark:text-slate-200",children:"Sound effects"}),(0,F.jsx)("p",{className:"text-xs text-slate-400",children:"Play sounds on call outcome actions"})]}),(0,F.jsx)("div",{className:"w-10 h-6 rounded-full transition-colors ".concat(n.sound_enabled?"bg-kw-red":"bg-slate-200 dark:bg-slate-600"),onClick:()=>i((0,s.A)((0,s.A)({},n),{},{sound_enabled:!n.sound_enabled})),children:(0,F.jsx)("div",{className:"w-4 h-4 bg-white dark:bg-slate-800 rounded-full mt-1 transition-transform ".concat(n.sound_enabled?"ml-5":"ml-1")})})]})]})]}),(0,F.jsxs)("div",{className:"bg-white dark:bg-slate-800 rounded-xl shadow-sm border border-slate-100 dark:border-slate-700 p-5 mb-5",children:[(0,F.jsxs)("h2",{className:"font-heading font-medium text-base text-slate-800 dark:text-slate-100 mb-4 flex items-center gap-2",children:[(0,F.jsx)(v,{size:16,className:"text-kw-red"}),"Keyboard Shortcuts"]}),(0,F.jsx)("div",{className:"grid grid-cols-2 gap-2 text-sm",children:[["1-9","Quick log outcome (1=Appointment, 2=Callback, ...)"],["N","Next lead"],["P","Previous lead"],["E","Edit current lead"],["S","Toggle notes panel"]].map(e=>{let[t,a]=e;return(0,F.jsxs)("div",{className:"flex items-center gap-3 py-1.5",children:[(0,F.jsx)("kbd",{className:"px-2 py-0.5 bg-slate-100 dark:bg-slate-800 rounded text-xs font-mono text-slate-600 dark:text-slate-300 border border-slate-200 dark:border-slate-700",children:t}),(0,F.jsx)("span",{className:"text-xs text-slate-500 dark:text-slate-400",children:a})]},t)})})]}),r&&(0,F.jsxs)("div",{className:"bg-white dark:bg-slate-800 rounded-xl shadow-sm border-2 border-purple-200 p-5 mb-5","data-testid":"beta-features-panel",children:[(0,F.jsxs)("div",{className:"flex items-start justify-between mb-1",children:[(0,F.jsxs)("h2",{className:"font-heading font-medium text-base text-purple-800 flex items-center gap-2",children:[(0,F.jsx)(j,{size:16,className:"text-purple-600"}),"Beta Features"]}),(0,F.jsx)("button",{onClick:oe,title:"Refresh graduation status",className:"text-purple-400 hover:text-purple-600 transition-colors",children:(0,F.jsx)(h.A,{size:14})})]}),(0,F.jsxs)("p",{className:"text-xs text-purple-500 mb-4",children:["Only visible to Systems account. Mark a feature as graduated when it's ready \u2014 then remove it from ",(0,F.jsx)("code",{className:"bg-purple-50 px-1 rounded text-purple-700",children:"betaFeatures.js"})," and redeploy to release to all users."]}),(0,F.jsxs)("div",{className:"flex items-center gap-4 mb-4 p-3 bg-purple-50 rounded-lg",children:[(0,F.jsxs)("div",{className:"flex items-center gap-1.5 text-xs",children:[(0,F.jsx)(j,{size:13,className:"text-purple-500"}),(0,F.jsxs)("span",{className:"text-purple-700 font-semibold",children:[K.Dy.length," in beta"]})]}),(0,F.jsxs)("div",{className:"flex items-center gap-1.5 text-xs",children:[(0,F.jsx)(k.A,{size:13,className:"text-green-500"}),(0,F.jsxs)("span",{className:"text-green-700 font-semibold",children:[Object.keys(le).length," graduated"]})]}),(0,F.jsxs)("div",{className:"flex items-center gap-1.5 text-xs",children:[(0,F.jsx)(p.A,{size:13,className:"text-amber-500"}),(0,F.jsxs)("span",{className:"text-amber-700 font-semibold",children:[K.Dy.length-Object.keys(le).length," pending"]})]})]}),(0,F.jsx)("div",{className:"space-y-3",children:K.Dy.map(e=>{const t=le[e.id],a=!!t,s=re===e.id,l=ie===e.id;return(0,F.jsxs)("div",{className:"rounded-xl border p-4 transition-all ".concat(a?"bg-green-50 border-green-200":"bg-purple-50 border-purple-100"),"data-testid":"beta-feature-".concat(e.id),children:[(0,F.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,F.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,F.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[a?(0,F.jsx)(y.A,{size:15,className:"text-green-600 flex-shrink-0"}):(0,F.jsx)(j,{size:15,className:"text-purple-500 flex-shrink-0"}),(0,F.jsx)("span",{className:"text-sm font-semibold ".concat(a?"text-green-800":"text-purple-900"),children:e.label}),(0,F.jsx)("span",{className:"text-[10px] font-bold px-1.5 py-0.5 rounded ".concat(a?"bg-green-200 text-green-700":"bg-purple-200 text-purple-700"),
1children:a?"\u2713 Graduated":"ETA ".concat(e.eta)})]}),(0,F.jsx)("p",{className:"text-xs mt-1 leading-relaxed ".concat(a?"text-green-700":"text-purple-600"),children:e.description}),e.sidebarId&&(0,F.jsxs)("p",{className:"text-[10px] text-slate-400 mt-1",children:["Nav: #",e.sidebarId]}),a&&t.graduated_at&&(0,F.jsxs)("p",{className:"text-[10px] text-green-500 mt-1 flex items-center gap-1",children:[(0,F.jsx)(p.A,{size:9}),"Graduated ",new Date(t.graduated_at).toLocaleDateString()]})]}),(0,F.jsx)("div",{className:"flex-shrink-0",children:a?(0,F.jsxs)("button",{onClick:()=>(async e=>{ne(e.id),ce(null);try{await H.default.ungraduateFeature(e.id),await oe()}catch(t){ce(e.id)}ne(null)})(e),disabled:s,title:"Move back to beta",className:"flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium text-slate-500 dark:text-slate-400 bg-white dark:bg-slate-800 border border-slate-200 dark:border-slate-700 rounded-lg hover:border-slate-300 hover:text-slate-700 transition-all disabled:opacity-50",children:[s?(0,F.jsx)(x.A,{size:12,className:"animate-spin"}):(0,F.jsx)(N.A,{size:12}),"Un-graduate"]}):(0,F.jsxs)("button",{onClick:()=>(async e=>{ne(e.id),ce(null);try{await H.default.graduateFeature(e.id,e.label),await oe()}catch(t){ce(e.id)}ne(null)})(e),disabled:s,title:"Mark as ready for production",className:"flex items-center gap-1.5 px-3 py-1.5 text-xs font-semibold text-white bg-green-600 rounded-lg hover:bg-green-700 transition-all disabled:opacity-50 shadow-sm",children:[s?(0,F.jsx)(x.A,{size:12,className:"animate-spin"}):(0,F.jsx)(k.A,{size:12}),"Graduate"]})})]}),l&&(0,F.jsxs)("p",{className:"text-xs text-red-500 mt-2 flex items-center gap-1",children:[(0,F.jsx)(w.A,{size:12})," Failed \u2014 check network and retry."]}),a&&(0,F.jsxs)("div",{className:"mt-3 pt-3 border-t border-green-200",children:[(0,F.jsxs)("p",{className:"text-[11px] text-green-600 font-medium mb-1 flex items-center gap-1",children:[(0,F.jsx)(A.A,{size:10})," Next step to release to all users:"]}),(0,F.jsxs)("ol",{className:"text-[11px] text-green-700 space-y-0.5 list-decimal list-inside",children:[(0,F.jsxs)("li",{children:["Open ",(0,F.jsx)("code",{className:"bg-green-100 px-1 rounded",children:"frontend/src/utils/betaFeatures.js"})]}),(0,F.jsxs)("li",{children:["Remove the ",(0,F.jsx)("code",{className:"bg-green-100 px-1 rounded",children:e.id})," entry from ",(0,F.jsx)("code",{className:"bg-green-100 px-1 rounded",children:"BETA_FEATURES"})]}),(0,F.jsx)("li",{children:"Commit & trigger a redeploy"})]})]})]},e.id)})})]}),(0,F.jsxs)("button",{"data-testid":"save-settings-btn",onClick:async()=>{P(!0);try{const e=await H.default.updateSettings(n);i(e),I(!0),setTimeout(()=>I(!1),2e3)}catch(e){a.error(e.message||"Could not save settings \u2014 please try again")}P(!1)},disabled:M,className:"flex items-center gap-2 px-5 py-2.5 bg-kw-red text-white text-sm font-medium rounded-lg hover:bg-kw-red-hover transition-all disabled:opacity-60",children:[(0,F.jsx)(C.A,{size:15}),L?"Saved!":M?"Saving...":"Save Settings"]}),(0,F.jsx)("p",{className:"text-[10px] text-slate-400 mt-6 text-center",children:"TappIn by Serendipity \u2014 Predictive Convergence Intelligence"})]})}},7255(e,t,a){a.d(t,{A:()=>s});const s=(0,a(9870).A)("download",[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]])},1641(e,t,a){a.d(t,{A:()=>s});const s=(0,a(9870).A)("external-link",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]])},4321(e,t,a){a.d(t,{A:()=>s});const s=(0,a(9870).A)("key-round",[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]])},1742(e,t,a){a.d(t,{A:()=>s});const s=(0,a(9870).A)("save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]])},602(e,t,a){a.d(t,{A:()=>s});const s=(0,a(9870).A)("wrench",[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]])}}]);
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.