1/*! For license information please see 5516.f12e0b15.chunk.js.LICENSE.txt */ 2"use strict";(self.webpackChunkfrontend=self.webpackChunkfrontend||[]).push([[5516],{27799(e,t,a){a.d(t,{A:()=>k});var s=a(43145),l=a(5763),n=a(5544),d=a(89379),r=a(9950),o=a(42989),i=a(27304),c=a(37358),u=a(52607),m=a(2737),x=a(84814),p=a(32033),h=a(8806),f=a(41111),v=a(94779),y=a(9093),g=a(17255),b=a(44414);function j(e){let t=e.f,a=e.value,s=e.onChange;const l={value:null!==a&&void 0!==a?a:"",onChange:e=>s(t.name,e.target.value),"data-testid":"tool-field-".concat(t.name)};return"textarea"===t.type?(0,b.jsx)(y.T,(0,d.A)({rows:3},l)):"select"===t.type?(0,b.jsxs)("select",(0,d.A)((0,d.A)({},l),{},{className:"h-9 w-full rounded-md border border-border bg-background px-3 text-sm",children:[(0,b.jsx)("option",{value:"",children:"\u2014"}),(t.options||[]).map(e=>(0,b.jsx)("option",{value:e,children:String(e).replace(/_/g," ")},e))]})):(0,b.jsx)(v.p,(0,d.A)({type:"number"===t.type?"number":t.type||"text"},l))}function N(e){let t=e.open,a=e.onClose,s=e.cfg,l=e.initial,i=e.onSaved,c=e.entity;const u=(0,r.useState)({}),m=(0,n.A)(u,2),x=m[0],v=m[1],y=(0,r.useState)(!1),N=(0,n.A)(y,2),k=N[0],A=N[1];if((0,r.useEffect)(()=>{v(l||{})},[l,t]),!s)return null;const w=(e,t)=>v(a=>(0,d.A)((0,d.A)({},a),{},{[e]:t}));return(0,b.jsx)(g.lG,{open:t,onOpenChange:e=>!e&&a(),children:(0,b.jsxs)(g.Cf,{className:"max-h-[85vh] overflow-y-auto sm:max-w-lg","data-testid":"tool-record-dialog",children:[(0,b.jsx)(g.c7,{children:(0,b.jsx)(g.L3,{children:null!==l&&void 0!==l&&l.__rid?"Edit ".concat(s.label):"Add ".concat(s.label)})}),(0,b.jsx)("div",{className:"grid gap-3 sm:grid-cols-2",children:s.fields.map(e=>(0,b.jsxs)("div",{className:"textarea"===e.type?"sm:col-span-2":"",children:[(0,b.jsxs)("label",{className:"mb-1 block text-xs text-muted-foreground",children:[e.label,e.required&&" *"]}),(0,b.jsx)(j,{f:e,value:x[e.name],onChange:w})]},e.name))}),(0,b.jsxs)(g.Es,{children:[(0,b.jsx)(f.$,{variant:"outline",onClick:a,className:"rounded-full",children:"Cancel"}),(0,b.jsxs)(f.$,{onClick:async()=>{for(const a of s.fields){var e;if(a.required&&!String(null!==(e=x[a.name])&&void 0!==e?e:"").trim())return void p.toast.error("".concat(a.label," is required"))}A(!0);try{null!==l&&void 0!==l&&l.__rid?await h.FH.put("/records/".concat(c,"/").concat(l.__rid),x):await h.FH.post("/records/".concat(c),x),p.toast.success(null!==l&&void 0!==l&&l.__rid?"Updated":"".concat(s.label," added")),i(),a()}catch(t){p.toast.error((0,h.KI)(t))}finally{A(!1)}},disabled:k,className:"rounded-full","data-testid":"tool-record-save",children:[k&&(0,b.jsx)(o.A,{className:"mr-2 h-4 w-4 animate-spin"}),"Save"]})]})]})})}function k(e){var t;let a=e.title,y=e.description,j=e.disclaimer,k=e.entities,A=e.prompts,w=void 0===A?[]:A,C=e.stats,S=e.emptyHint,_=e.testid;const z=(0,r.useState)({}),T=(0,n.A)(z,2),E=T[0],I=T[1],D=(0,r.useState)({}),H=(0,n.A)(D,2),O=H[0],M=H[1],$=(0,r.useState)(k[0]),P=(0,n.A)($,2),F=P[0],K=P[1],q=(0,r.useState)(null),L=(0,n.A)(q,2),W=L[0],G=L[1],J=(0,r.useState)(null),R=(0,n.A)(J,2),U=R[0],V=R[1],Y=(0,r.useState)(!0),B=(0,n.A)(Y,2),Q=B[0],X=B[1],Z=(0,r.useState)(""),ee=(0,n.A)(Z,2),te=ee[0],ae=ee[1],se=(0,r.useState)(""),le=(0,n.A)(se,2),ne=le[0],de=le[1],re=(0,r.useState)(!1),oe=(0,n.A)(re,2),ie=oe[0],ce=oe[1],ue=(0,r.useCallback)(async()=>{try{const e=await Promise.all([h.FH.get("/records/entities"),...k.map(e=>h.FH.get("/records/".concat(e)))]),t=(0,l.A)(e),a=t[0],n=(0,s.A)(t).slice(1);I(a.data);const d={};k.forEach((e,t)=>{d[e]=n[t].data.records||n[t].data.rows||[]}),M(d)}catch(e){p.toast.error((0,h.KI)(e))}finally{X(!1)}},[]);(0,r.useEffect)(()=>{ue()},[ue]);const me=async e=>{const t=(e||te).trim();if(t&&!ie){ce(!0),de("");try{const e=await fetch("".concat(h.tE,"/records/ask"),{method:"POST",credentials:"include",headers:(0,d.A)({"Content-Type":"application/json"},(0,h.Y_)()),body:JSON.stringify({question:t,entities:k})});if(!e.ok)throw new Error("HTTP ".concat(e.status));const s=e.body.getReader(),l=new TextDecoder("utf-8");let n="";for(;;){const e=await s.read(),t=e.value;if(e.done)break;n+=l.decode(t,{stream:!0});const d=n.split("\n\n");n=d.pop();for(const s of d){const e=s.trim();if(e.startsWith("data:"))try{const t=JSON.parse(e.slice(5).trim());"delta"===t.type&&de(e=>e+(t.content||""))}catch(a){}}}}catch(s){p.toast.error((0,h.KI)(s))}finally{ce(!1)}}},xe=(0,r.useMemo)(()=>C?C(O):[],[O,C]),pe=E[F],he=O[F]||[];return(0,b.jsxs)("div",{className:"mx-auto max-w-5xl space-y-6 px-4 py-8 sm:px-6","data-testid":_,children:[(0,b.jsxs)("div",{children:[(0,b.jsxs)("h1",{className:"flex items-center gap-2 font-display text-2xl font-bold tracking-tight",children:[(0,b.jsx)(i.A,{className:"h-5 w-5 text-pz-accent"})," ",a]}),(0,b.jsx)("p",{className:"mt-1 text-sm text-muted-foreground",children:y}),j&&(0,b.jsx)("p",{className:"mt-2 rounded-lg border border-border bg-card/40 px-3 py-2 text-xs text-muted-foreground","data-testid":"tool-disclaimer",children:j})]}),xe.length>0&&(0,b.jsx)("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-4","data-testid":"tool-stats",children:xe.map(e=>(0,b.jsxs)("div",{className:"pz-card p-4",children:[(0,b.jsx)("div",{className:"font-display text-2xl font-bold ".concat(e.tone||""),children:e.value}),(0,b.jsx)("div",{className:"mt-1 text-xs text-muted-foreground",children:e.label})]},e.label))}),(0,b.jsxs)("div",{className:"pz-card p-4","data-testid":"tool-ask",children:[(0,b.jsx)("div",{className:"flex flex-wrap gap-2",children:w.map(e=>(0,b.jsx)("button",{onClick:()=>{ae(e),me(e)},className:"rounded-full border border-border px-3 py-1.5 text-xs text-muted-foreground transition-colors hover:border-pz-accent/50 hover:text-foreground","data-testid":"tool-prompt-chip",children:e},e))}),(0,b.jsxs)("div",{className:"mt-3 flex gap-2",children:[(0,b.jsx)(v.p,{value:te,onChange:e=>ae(e.target.value),onKeyDown:e=>"Enter"===e.key&&me(),placeholder:"Ask Panzoe about your data\u2026",className:"rounded-full","data-testid":"tool-ask-input"}),(0,b.jsx)(f.$,{onClick:()=>me(),disabled:ie,className:"rounded-full","data-testid":"tool-ask-btn",children:ie?(0,b.jsx)(o.A,{className:"h-4 w-4 animate-spin"}):(0,b.jsx)(m.A,{className:"h-4 w-4"})})]}),ne&&(0,b.jsx)("p",{className:"mt-3 whitespace-pre-wrap text-sm","data-testid":"tool-ask-answer",children:ne})]}),(0,b.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[k.map(e=>{var t;return(0,b.jsxs)("button",{onClick:()=>K(e),"data-testid":"tool-tab-".concat(e),className:"rounded-full border px-3 py-1.5 text-xs transition-colors ".concat(F===e?"border-pz-accent/60 bg-pz-accent/10 text-pz-accent":"border-border text-muted-foreground hover:text-foreground"),children:[(null===(t=E[e])||void 0===t?void 0:t.label)||e," (",(O[e]||[]).length,")"]},e)}),(0,b.jsxs)(f.$,{size:"sm",className:"ml-auto rounded-full","data-testid":"tool-a
2dd-btn",onClick:()=>G({entity:F,initial:null}),children:[(0,b.jsx)(u.A,{className:"mr-1 h-4 w-4"})," Add ",(null===pe||void 0===pe?void 0:pe.label)||""]})]}),Q?(0,b.jsx)("div",{className:"flex justify-center py-14",children:(0,b.jsx)(o.A,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):0===he.length?(0,b.jsxs)("div",{className:"pz-card p-10 text-center","data-testid":"tool-empty-state",children:[(0,b.jsx)("p",{className:"text-sm text-muted-foreground",children:S||"Nothing here yet. Add your first ".concat((null===pe||void 0===pe||null===(t=pe.label)||void 0===t?void 0:t.toLowerCase())||"record"," to get started \u2014 Panzoe's AI uses this data to help you.")}),(0,b.jsxs)(f.$,{className:"mt-4 rounded-full",onClick:()=>G({entity:F,initial:null}),"data-testid":"tool-empty-add-btn",children:[(0,b.jsx)(u.A,{className:"mr-1 h-4 w-4"})," Add ",null===pe||void 0===pe?void 0:pe.label]})]}):(0,b.jsx)("div",{className:"space-y-2","data-testid":"tool-record-list",children:he.map(e=>{const t=e[pe.id_field],a=pe.fields.filter(t=>t.name!==pe.title_field&&e[t.name]).slice(0,3).map(t=>"".concat(t.label,": ").concat(e[t.name])).join(" \xb7 ");return(0,b.jsxs)("div",{className:"pz-card flex items-center gap-3 p-4","data-testid":"tool-record-".concat(t),children:[(0,b.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,b.jsx)("div",{className:"truncate text-sm font-medium",children:e[pe.title_field]}),a&&(0,b.jsx)("div",{className:"mt-0.5 truncate text-xs text-muted-foreground",children:a})]}),(0,b.jsx)("button",{onClick:()=>G({entity:F,initial:(0,d.A)((0,d.A)({},e),{},{__rid:t})}),className:"text-muted-foreground hover:text-foreground","data-testid":"tool-edit-".concat(t),children:(0,b.jsx)(c.A,{className:"h-4 w-4"})}),(0,b.jsx)("button",{onClick:()=>V({entity:F,row:e}),className:"text-muted-foreground hover:text-red-400","data-testid":"tool-delete-".concat(t),children:(0,b.jsx)(x.A,{className:"h-4 w-4"})})]},t)})}),(0,b.jsx)(N,{open:!!W,onClose:()=>G(null),cfg:W?E[W.entity]:null,initial:null===W||void 0===W?void 0:W.initial,entity:null===W||void 0===W?void 0:W.entity,onSaved:ue}),(0,b.jsx)(g.lG,{open:!!U,onOpenChange:e=>!e&&V(null),children:(0,b.jsxs)(g.Cf,{className:"sm:max-w-sm","data-testid":"tool-delete-confirm",children:[(0,b.jsx)(g.c7,{children:(0,b.jsx)(g.L3,{children:"Delete this record?"})}),(0,b.jsxs)("p",{className:"text-sm text-muted-foreground",children:["This permanently removes it from your ",a," data."]}),(0,b.jsxs)(g.Es,{children:[(0,b.jsx)(f.$,{variant:"outline",className:"rounded-full",onClick:()=>V(null),children:"Cancel"}),(0,b.jsx)(f.$,{variant:"destructive",className:"rounded-full",onClick:async()=>{const e=U.entity,t=U.row,a=E[e];try{await h.FH.delete("/records/".concat(e,"/").concat(t[a.id_field])),p.toast.success("Deleted"),V(null),ue()}catch(s){p.toast.error((0,h.KI)(s))}},"data-testid":"tool-delete-confirm-btn",children:"Delete"})]})]})})]})}},9093(e,t,a){a.d(t,{T:()=>i});var s=a(89379),l=a(53986),n=a(9950),d=a(40090),r=a(44414);const o=["className"],i=n.forwardRef((e,t)=>{let a=e.className,n=(0,l.A)(e,o);return(0,r.jsx)("textarea",(0,s.A)({className:(0,d.cn)("flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-base shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",a),ref:t},n))});i.displayName="Textarea"},55516(e,t,a){a.r(t),a.d(t,{default:()=>n});var s=a(27799),l=a(44414);function n(){return(0,l.jsx)(s.A,{testid:"travel-admin-tool",title:"Travel & Admin",description:"Trips, itineraries, packing lists, important documents and life admin \u2014 with expiry tracking and AI trip prep.",askPath:"/life/ask",entities:["travel-trip","admin-document","admin-task"],prompts:["What do I need to prepare before my next trip?","Which of my documents expire in the next six months?","Create a packing list for my upcoming trip","What admin do I need to complete this week?"],stats:e=>{const t=(new Date).toISOString().slice(0,10),a=new Date(Date.now()+158112e5).toISOString().slice(0,10),s=e["admin-document"]||[],l=e["admin-task"]||[];return[{label:"Upcoming trips",value:(e["travel-trip"]||[]).filter(e=>(e.end_date||e.start_date||"")>=t&&"cancelled"!==e.status&&"completed"!==e.status).length},{label:"Documents tracked",value:s.length},{label:"Expiring in 6 months",value:s.filter(e=>e.expiry_date&&e.expiry_date>=t&&e.expiry_date<=a).length,tone:"text-amber-400"},{label:"Overdue admin tasks",value:l.filter(e=>"done"!==e.status&&e.due_date&&e.due_date<t).length,tone:"text-rose-400"}]}})}},37358(e,t,a){a.d(t,{A:()=>s});const s=(0,a(36230).A)("pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]])},52607(e,t,a){a.d(t,{A:()=>s});const s=(0,a(36230).A)("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]])},84814(e,t,a){a.d(t,{A:()=>s});const s=(0,a(36230).A)("trash-2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}
2],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]])}}]);
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.