PageSourceSearch

https://payd.io/_app/immutable/nodes/41.BBUL_4Zd.js

js payd.io collected 2026-10-08 10:35:46 UTC 200,907 bytes, 3,809 lines download raw bytes

1import "../chunks/CKOwlSI2.js";
2import { p as push, g as comment, e as first_child, j as noop, a as append, b as pop, q as user_effect, h as get, m as set, u as user_derived, k as state, c as child, s as sibling, n as next, i as text, r as reset, t as template_effect, at as update, f as from_html, l as proxy } from "../chunks/BKjdoxk6.js";
3import { d as delegate, s as set_text, e as event, r as replay_events, b as delegated } from "../chunks/BKlqPofX.js";
4import { s as spread_props, r as rest_props, p as prop, i as if_block } from "../chunks/Dwcrqh2y.js";
5import { a as set_class, e as each, i as index, s as set_attribute, b as attribute_effect, r as remove_input_defaults, c as set_value } from "../chunks/DVzlxsJy.js";
6import { c as component } from "../chunks/BKMwwmgr.js";
7import { C as Card } from "../chunks/DrufZ54p.js";
8import { C as Card_content } from "../chunks/CxqPRnVH.js";
9import { C as Card_description } from "../chunks/C2vsj6nz.js";
10import "../chunks/Bbk80uvW.js";
11import { C as Card_header } from "../chunks/DOQKBaMF.js";
12import { C as Card_title } from "../chunks/CC3JSmHK.js";
13import { E as Empty_media, a as Empty } from "../chunks/4ZKFlzXH.js";
14import { E as Empty_content, a as Empty_title, b as Empty_description } from "../chunks/CoLxRZDD.js";
15import { D as Dialog_content, a as Dialog } from "../chunks/Bs9ZqYRt.js";
16import { D as Dialog_header, a as Dialog_title } from "../chunks/B5oC7qXa.js";
17import { D as Dialog_footer } from "../chunks/BHllcXW-.js";
18import { D as Dialog_description } from "../chunks/CmkAhrRW.js";
19import { a as Select_trigger, b as Select_content, c as Select_item, S as Select } from "../chunks/DTllhafR.js";
20import { F as Field, a as Field_label } from "../chunks/CvO-Ojma.js";
21import { F as Field_group } from "../chunks/CNC92n9d.js";
22import { F as Field_error } from "../chunks/Dvhmo5JG.js";
23import { T as Table, a as Table_header, b as Table_row, c as Table_head, d as Table_body, e as Table_cell } from "../chunks/CMHQITAr.js";
24import { c as cachedResource, P as Pagination_content, a as Pagination_item, b as Pagination_prev_button, d as Pagination_link, e as Pagination_ellipsis, f as Pagination_next_button, g as Pagination } from "../chunks/--EkH-qF.js";
25import { A as Alert_title, a as Alert_description, b as Alert } from "../chunks/DLmf3-B8.js";
26import { B as Button, L as Loader_circle } from "../chunks/DFi0sb4j.js";
27import { B as Badge } from "../chunks/A3jyW80z.js";
28import { p as page } from "../chunks/GZQjZYtn.js";
29import { g as getVideosForLinking, d as getPartnershipsForLinking, A as Arrow_down_left, b as Arrow_up_right, S as Skeleton, l as linkTransactionToVideoCommand, e as linkTransactionToPartnershipCommand, u as unlinkTransactionFromVideo, f as unlinkTransactionFromPartnership, c as createManualTransaction, C as CreateManualTransaction, T as Toggle_group, a as Toggle_group_item } from "../chunks/D1uY2rYd.js";
30import { I as Input } from "../chunks/CgDdDzWH.js";
31import { I as Input_group, a as Input_group_addon } from "../chunks/BhpEP9lX.js";
32import { I as Input_group_text, a as Input_group_input } from "../chunks/DSHAaBFh.js";
33import { I as Icon, g as getPartnershipStatusBadge } from "../chunks/CJ8ugeRc.js";
34import { g as goto } from "../chunks/CJlEUkDW.js";
35import { p as paths } from "../chunks/f0135wJq.js";
36import { A as Arrow_left } from "../chunks/DgWOQXSJ.js";
37import { S as Search } from "../chunks/BFGd3WNb.js";
38import { P as Plus } from "../chunks/Cf58ZC2l.js";
39import { C as Chevron_left } from "../chunks/Bk4AdAvA.js";
40import { C as Chevron_right } from "../chunks/CWcpHtKW.js";
41import { C as Credit_card } from "../chunks/BRoFC1i9.js";
42import { B as Brain_circuit } from "../chunks/BbUz6YVZ.js";
43import { L as Landmark } from "../chunks/BC9XeR1S.js";
44import { X } from "../chunks/Cm6upKwx.js";
45import { V as Video } from "../chunks/JHSgBVIh.js";
46import { t as toast } from "../chunks/Ef4BH15B.js";
47import { C as Circle_check } from "../chunks/DmM9pCsy.js";
48import { s as snippet } from "../chunks/b9KZgspc.js";
49import { U as Upload } from "../chunks/_m71cd5I.js";
50import "../chunks/W0JHbNcr.js";
51import { T as Trending_up } from "../chunks/D_B7K9CM.js";
52import { R as Receipt } from "../chunks/jXRTO0Nt.js";
53function Arrow_up_down($$anchor, $$props) {
54  push($$props, true);
55  let props = rest_props($$props, ["$$slots", "$$events", "$$legacy"]);
56  const iconNode = [
57    ["path", { "d": "m21 16-4 4-4-4" }],
58    ["path", { "d": "M17 20V4" }],
59    ["path", { "d": "m3 8 4-4 4 4" }],
60    ["path", { "d": "M7 4v16" }]
61  ];
62  Icon($$anchor, spread_props({ name: "arrow-up-down" }, () => props, {
63    get iconNode() {
64      return iconNode;
65    },
66    children: ($$anchor2, $$slotProps) => {
67      var fragment_1 = comment();
68      var node = first_child(fragment_1);
69      snippet(node, () => $$props.children ?? noop);
70      append($$anchor2, fragment_1);
71    },
72    $$slots: { default: true }
73  }));
74  pop();
75}
76function Receipt_text($$anchor, $$props) {
77  push($$props, true);
78  let props = rest_props($$props, ["$$slots", "$$events", "$$legacy"]);
79  const iconNode = [
80    ["path", { "d": "M13 16H8" }],
81    ["path", { "d": "M14 8H8" }],
82    ["path", { "d": "M16 12H8" }],
83    [
84      "path",
85      {
86        "d": "M4 3a1 1 0 0 1 1-1 1.3 1.3 0 0 1 .7.2l.933.6a1.3 1.3 0 0 0 1.4 0l.934-.6a1.3 1.3 0 0 1 1.4 0l.933.6a1.3 1.3 0 0 0 1.4 0l.933-.6a1.3 1.3 0 0 1 1.4 0l.934.6a1.3 1.3 0 0 0 1.4 0l.933-.6A1.3 1.3 0 0 1 19 2a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1 1.3 1.3 0 0 1-.7-.2l-.933-.6a1.3 1.3 0 0 0-1.4 0l-.934.6a1.3 1.3 0 0 1-1.4 0l-.933-.6a1.3 1.3 0 0 0-1.4 0l-.933.6a1.3 1.3 0 0 1-1.4 0l-.934-.6a1.3 1.3 0 0 0-1.4 0l-.933.6a1.3 1.3 0 0 1-.7.2 1 1 0 0 1-1-1z"
87      }
88    ]
89  ];
90  Icon($$anchor, spread_props({ name: "receipt-text" }, () => props, {
91    get iconNode() {
92      return iconNode;
93    },
94    children: ($$anchor2, $$slotProps) => {
95      var fragment_1 = comment();
96      var node = first_child(fragment_1);
97      snippet(node, () => $$props.children ?? noop);
98      append($$anchor2, fragment_1);
99    },
100    $$slots: { default: true }
101  }));
102  pop();
103}
104function Message_circle_question_mark($$anchor, $$props) {
105  push($$props, true);
106  let props = rest_props($$props, ["$$slots", "$$events", "$$legacy"]);
107  const iconNode = [
108    [
109      "path",
110      {
111        "d": "M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719"
112      }
113    ],
114    ["path", { "d": "M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3" }],
115    ["path", { "d": "M12 17h.01" }]
116  ];
117  Icon($$anchor, spread_props({ name: "message-circle-question-mark" }, () => props, {
118    get iconNode() {
119      return iconNode;
120    },
121    children: ($$anchor2, $$slotProps) => {
122      var fragment_1 = comment();
123      var node = first_child(fragment_1);
124      snippet(node, () => $$props.children ?? noop);
125      append($$anchor2, fragment_1);
126    },
127    $$slots: { default: true }
128  }));
129  pop();
130}
131function formatConfidenceLabel(value) {
132  if (value >= 0.85) {
133    return "High confidence";
134  }
135  if (value >= 0.7) {
136    return "Medium confidence";
137  }
138  return "Low confidence";
139}
140function formatStatusLabel(status) {
141  if (status === "needs_review") {
142    return "Waiting for clarification";
143  }
144  if (status === "classified") {
145    return "Categorized";
146  }
147  return "Draft categorization";
148}
149function buildSignals(classification, transaction) {
150  const signals = ["Transaction details like merchant, amount, and timing"];
151  if (transaction.plaidAccount?.name) {
152    signals.push(`Account context from ${transaction.plaidAccount.name}`);
153  }
154  if (classification.answer) {
155    signals.push("A prior owner reply about similar bookkeeping");
156  }
157  if (classification.source === "ai") {
158    signals.push("Payd’s bookkeeping model");
159  }
160  return signals;
161}
162function buildSummary(classification, transaction, categoryName) {
163  const subject = transaction.merchantName ?? transaction.description ?? "This transaction";
164  if (classification.status === "needs_review" && classification.question) {
165    return `${subject} has a likely category${categoryName ? ` as ${categoryName}` : ""}, but Payd is waiting for one clarification before finalizing it.`;
166  }
167  if (classification.answer) {
168    return `${subject} was categorized${categoryName ? ` as ${categoryName}` : ""} using the transaction details and a bookkeeping answer you already gave.`;
169  }
170  return `${subject} was categorized${categoryName ? ` as ${categoryName}` : ""} from the transaction details Payd already has.`;
171}
172function buildSanitizedClassificationExplanation(classification, transaction) {
173  if (!classification) {
174    return null;
175  }
176  const confidenceValue = Number.parseFloat(classification.confidence);
177  const categoryName = transaction.category?.name ?? classification.category?.name ?? null;
178  return {
179    statusLabel: formatStatusLabel(classification.status),
180    confidenceLabel: formatConfidenceLabel(confidenceValue),
181    confidenceText: Number.isFinite(confidenceValue) ? `${Math.round(confidenceValue * 100)}%` : "Unknown",
182    categoryName,
183    summary: buildSummary(classification, transaction, categoryName),
184    signals: buildSignals(classification, transaction),
185    followUpQuestion: classification.status === "needs_review" ? classification.question : null,
186    userAnswer: classification.answer
187  };
188}
189let _cachedVideosQuery = null;
190let _cachedPartnershipsQuery = null;
191var root_5 = from_html(`<div class="flex items-center gap-2"><!> <!></div> <!>`, 1);
192var root_10$1 = from_html(`<tr class="border-b last:border-b-0"><td class="px-3 py-2"><!></td><td class="px-3 py-2"><!></td><td class="px-2 py-2"><!></td></tr>`);
193var root_9 = from_html(`<table class="w-full text-sm"><thead class="bg-muted/50"><tr class="border-b text-left text-xs text-muted-foreground"><th class="px-3 py-2 font-medium">Video</th><th class="px-3 py-2 font-medium">Uploaded</th><th class="w-10"></th></tr></thead><tbody></tbody></table>`);
194var root_11 = from_html(`<p class="py-8 text-center text-sm text-muted-foreground"> </p>`);
195var root_13 = from_html(`<tr class="border-b transition-colors last:border-b-0 hover:bg-muted/50"><td class="px-3 py-2"><span class="truncate"> </span></td><td class="px-3 py-2 text-muted-foreground"> </td><td class="px-2 py-2"><!></td></tr>`);
196var root_12 = from_html(`<table class="w-full text-sm"><thead class="bg-muted/50"><tr class="border-b text-left text-xs text-muted-foreground"><th class="px-3 py-2 font-medium">Video</th><th class="px-3 py-2 font-medium">Uploaded</th><th class="w-10"></th></tr></thead><tbody></tbody></table>`);
197var root_15 = from_html(`<div class="mt-3 flex items-center justify-between text-sm"><span class="text-muted-foreground"> </span> <div class="flex gap-1"><!> <!></div></div>`);
198var root_4$1 = from_html(`<!> <div class="mt-6"><div class="relative mb-3"><!> <!></div> <div class="rounded-md border"><!></div> <!></div>`, 1);
199var root_19 = from_html(`<div class="flex items-center gap-2"><!> <!></div> <!>`, 1);
200var root_24 = from_html(`<tr class="border-b last:border-b-0"><td class="px-3 py-2"><!> <!></td><td class="px-3 py-2"><!></td><td class="px-3 py-2 text-right"><!></td><td class="px-2 py-2"><!></td></tr>`);
201var root_23$1 = from_html(`<table class="w-full text-sm"><thead class="bg-muted/50"><tr class="border-b text-left text-xs text-muted-foreground"><th class="px-3 py-2 font-medium">Partnership</th><th class="px-3 py-2 font-medium">Partner</th><th class="px-3 py-2 text-right font-medium">Amount</th><th class="w-10"></th></tr></thead><tbody></tbody></table>`);
202var root_25 = from_html(`<p class="py-8 text-center text-sm text-muted-foreground"> </p>`);
203var root_27 = from_html(`<tr class="border-b transition-colors last:border-b-0 hover:bg-muted/50"><td class="px-3 py-2"><div class="min-w-0"><span class="block truncate"> </span> <!></div></td><td class="px-3 py-2 text-muted-foreground"> </td><td class="px-3 py-2 text-right text-muted-foreground"> </td><td class="px-2 py-2"><!></td></tr>`);
204var root_26 = from_html(`<table class="w-full text-sm"><thead class="bg-muted/50"><tr class="border-b text-left text-xs text-muted-foreground"><th class="px-3 py-2 font-medium">Partnership</th><th class="px-3 py-2 font-medium">Partner</th><th class="px-3 py-2 text-right font-medium">Amount</th><th class="w-10"></th></tr></thead><tbody></tbody></table>`);
205var root_30$1 = from_html(`<div class="mt-3 flex items-center justify-between text-sm"><span class="text-muted-foreground"> </span> <div class="flex gap-1"><!> <!></div></div>`);
206var root_18$1 = from_html(`<!> <div class="mt-6"><div class="relative mb-3"><!> <!></div> <div class="rounded-md border"><!></div> <!></div>`, 1);
207var root_35 = from_html(`<img alt="" class="h-8 w-8 rounded"/>`);
208var root_34 = from_html(`<div class="flex items-start gap-4"><div><!></div> <div class="flex-1"><!> <!></div> <p> </p></div>`);
209var root_39 = from_html(`<div><p class="mb-1 text-sm font-medium text-muted-foreground">Description</p> <p class="text-sm"> </p></div>`);
210var root_41$1 = from_html(`<!> Income`, 1);
211var root_42 = from_html(`<!> Expense`, 1);
212var root_49$1 = from_html(`<!> `, 1);
213var root_50 = from_html(`<li class="flex items-start gap-2"><span class="mt-1 h-1.5 w-1.5 shrink-0 rounded-full bg-muted-foreground"></span> <span> </span></li>`);
214var root_51 = from_html(`<div class="mt-4 rounded-lg border border-dashed bg-background/70 p-3"><div class="mb-1 flex items-center gap-2"><!> <p class="text-sm font-medium">Pending clarification</p></div> <p class="text-sm text-muted-foreground"> </p></div>`);
215var root_52$1 = from_html(`<div class="mt-4 rounded-lg border border-dashed bg-background/70 p-3"><p class="mb-1 text-sm font-medium">Most recent owner answer</p> <p class="text-sm text-muted-foreground"> </p></div>`);
216var root_45 = from_html(`<div class="rounded-xl border bg-muted/30 p-4"><div class="flex items-start justify-between gap-3"><div class="space-y-1"><div class="flex items-center gap-2"><!> <p class="text-sm font-medium">AI categorization</p></div> <p class="text-sm text-muted-foreground"> </p></div> <div class="flex shrink-0 flex-col items-end gap-2"><!> <!></div></div> <div class="mt-3 flex flex-wrap items-center gap-2"><!></div> <div class="mt-4"><p class="mb-2 text-xs font-medium tracking-wide text-muted-foreground uppercase">Signals used</p> <ul class="space-y-1 text-sm text-muted-foreground"></ul></div> <!> <!></div>`);
217var root_54$1 = from_html(`<!> `, 1);
218var root_58$1 = from_html(`<!> Processing`, 1);
219var root_59 = from_html(`<!> Upload`, 1);
220var root_57 = from_html(`<label><!> <input class="sr-only" type="file" accept="image/png,image/jpeg,image/webp"/></label>`);
221var root_61 = from_html(`<a target="_blank" rel="noreferrer" class="block shrink-0 rounded-md focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none" aria-label="Open receipt image"><img alt="" class="h-16 w-16 rounded-md border bg-muted object-cover" loading="lazy"/></a>`);
222var root_62 = from_html(`<div class="flex h-10 w-10 shrink-0 items-center justify-center rounded bg-muted"><!></div>`);
223var root_63$1 = from_html(`<div class="flex h-10 w-10 shrink-0 items-center justify-center rounded bg-muted"><!></div>`);
224var root_60 = from_html(`<div class="flex items-center justify-between gap-3 rounded-lg border p-3"><div class="flex min-w-0 items-center gap-3"><!> <div class="min-w-0"><p class="truncate text-sm font-medium"> </p> <p class="truncate text-xs text-muted-foreground"> </p></div></div> <!></div>`);
225var root_65 = from_html(`<p class="rounded-lg border border-dashed p-3 text-sm text-muted-foreground">No receipt linked yet.</p>`);
226var root_68$1 = from_html(`<img alt="" class="h-8 w-14 rounded object-cover"/>`);
227var root_69 = from_html(`<div class="flex h-8 w-14 items-center justify-center rounded bg-muted"><!></div>`);
228var root_67 = from_html(`<div class="flex items-center justify-between rounded-lg border p-3"><button class="flex flex-1 items-center gap-3 text-left transition-colors hover:opacity-80"><!> <span class="text-sm font-medium"> </span></button> <!></div>`);
229var root_71 = from_html(`<p class="mt-2 text-xs text-muted-foreground"> </p>`);
230var root_72 = from_html(`<!> `, 1);
231var root_66 = from_html(`<div class="space-y-2"></div> <!> <!>`, 1);
232var root_74 = from_html(`<!> Loading videos...`, 1);
233var root_76 = from_html(`<!> `, 1);
234var root_77 = from_html(`<div class="flex items-center justify-between rounded-lg border p-3"><button class="flex flex-1 items-center gap-3 text-left transition-colors hover:opacity-80"><div><p class="text-sm font-medium"> </p> <p class="text-xs text-muted-foreground"> </p></div></button> <!></div>`);
235var root_80 = from_html(`<!> Loading partnerships...`, 1);
236var root_82 = from_html(`<!> `, 1);
237var root_33$1 = from_html(`<!> <div class="mt-6 space-y-4"><!> <div class="flex items-center gap-2"><!> <!></div> <!> <div><p class="mb-2 text-sm font-medium text-muted-foreground">Source</p> <!></div> <div><div class="mb-2 flex items-center justify-between gap-3"><p class="text-sm font-medium text-muted-foreground">Linked Receipt</p> <!></div> <!></div> <div class="space-y-3 pt-2"><div><p class="mb-2 text-sm font-medium text-muted-foreground"> </p> <!></div> <div><p class="mb-2 text-sm font-medium text-muted-foreground">Linked Partnership</p> <!></div></div></div>`, 1);
238function Transaction_details_dialog($$anchor, $$props) {
239  push($$props, true);
240  let open = prop($$props, "open", 15, false);
241  const transaction = user_derived(() => {
242    if (!$$props.transaction) return null;
243    const current = $$props.transactions.current;
244    if (!current) return $$props.transaction;
245    return current.find((t) => t.id === $$props.transaction.id) ?? $$props.transaction;
246  });
247  const classificationExplanation = user_derived(() => get(transaction) ? buildSanitizedClassificationExplanation(get(transaction).classification, get(transaction)) : null);
248  const videosQuery = _cachedVideosQuery ??= getVideosForLinking();
249  const partnershipsQuery = _cachedPartnershipsQuery ??= getPartnershipsForLinking();
250  const videos = user_derived(() => videosQuery.current ?? []);
251  const partnerships = user_derived(() => partnershipsQuery.current ?? []);
252  let currentView = state("details");
253  let videoSearchQuery = state("");
254  let partnershipSearchQuery = state("");
255  let videoPage = state(0);
256  let partnershipPage = state(0);
257  let receiptUploading = state(false);
258  let receiptPreviewUrl = state(null);
259  let receiptPreviewReceiptId = state(null);
260  let receiptPreviewLoading = state(false);
261  const PAGE_SIZE = 5;
262  const linkedVideoIds = user_derived(() => new Set((get(transaction)?.ytVideos ?? []).map((v) => v.id)));
263  const filteredVideos = user_derived(() => {
264    const available = get(videos).filter((video) => !get(linkedVideoIds).has(video.id));
265    if (!get(videoSearchQuery).trim()) return available;
266    const query = get(videoSearchQuery).toLowerCase();
267    return available.filter((video) => video.name.toLowerCase().includes(query));
268  });
269  const paginatedVideos = user_derived(() => {
270    const start = get(videoPage) * PAGE_SIZE;
271    return get(filteredVideos).slice(start, start + PAGE_SIZE);
272  });
273  const videoTotalPages = user_derived(() => Math.ceil(get(filteredVideos).length / PAGE_SIZE));
274  const filteredPartnerships = user_derived(() => {
275    if (!get(partnershipSearchQuery).trim()) return get(partnerships);
276    const query = get(partnershipSearchQuery).toLowerCase();
277    return get(partnerships).filter((p) => p.title.toLowerCase().includes(query) || p.partner.contactName.toLowerCase().includes(query));
278  });
279  const paginatedPartnerships = user_derived(() => {
280    const start = get(partnershipPage) * PAGE_SIZE;
281    return get(filteredPartnerships).slice(start, start + PAGE_SIZE);
282  });
283  const partnershipTotalPages = user_derived(() =>
283 Math.ceil(get(filteredPartnerships).length / PAGE_SIZE));
284  user_effect(() => {
285    get(videoSearchQuery);
286    set(videoPage, 0);
287  });
288  user_effect(() => {
289    get(partnershipSearchQuery);
290    set(partnershipPage, 0);
291  });
292  function formatCurrency(amount, currencyCode) {
293    const num = parseFloat(amount);
294    return new Intl.NumberFormat("en-US", { style: "currency", currency: currencyCode || "USD" }).format(num);
295  }
296  function formatDate(date) {
297    return new Intl.DateTimeFormat("en-US", { month: "long", day: "numeric", year: "numeric" }).format(typeof date === "string" ? new Date(date) : date);
298  }
299  function formatDateShort(date) {
300    return new Intl.DateTimeFormat("en-US", { month: "short", day: "numeric", year: "numeric" }).format(typeof date === "string" ? new Date(date) : date);
301  }
302  function isReceiptUploadPayload(value) {
303    return typeof value === "object" && value !== null;
304  }
305  function isSignedReceiptUrlPayload(value) {
306    return typeof value === "object" && value !== null && typeof value.url === "string" && typeof value.expiresAt === "string";
307  }
308  user_effect(() => {
309    const linkedReceipt = open() ? get(transaction)?.receipt : null;
310    const receiptId = linkedReceipt?.id ?? null;
311    if (!receiptId || !linkedReceipt) {
312      set(receiptPreviewUrl, null);
313      set(receiptPreviewReceiptId, null);
314      set(receiptPreviewLoading, false);
315      return;
316    }
317    if (get(receiptPreviewReceiptId) === receiptId && get(receiptPreviewUrl)) return;
318    let cancelled = false;
319    set(receiptPreviewUrl, null);
320    set(receiptPreviewReceiptId, receiptId, true);
321    set(receiptPreviewLoading, true);
322    fetch(`/receipts/${receiptId}/signed-url`).then(async (response) => {
323      const payload = await response.json().catch(() => null);
324      if (!response.ok) {
325        throw new Error("Receipt preview failed.");
326      }
327      if (!isSignedReceiptUrlPayload(payload)) {
328        throw new Error("Receipt preview response was invalid.");
329      }
330      return payload.url;
331    }).then((url) => {
332      if (!cancelled && get(receiptPreviewReceiptId) === receiptId) {
333        set(receiptPreviewUrl, url, true);
334      }
335    }).catch(() => {
336      if (!cancelled && get(receiptPreviewReceiptId) === receiptId) {
337        set(receiptPreviewUrl, null);
338      }
339    }).finally(() => {
340      if (!cancelled && get(receiptPreviewReceiptId) === receiptId) {
341        set(receiptPreviewLoading, false);
342      }
343    });
344    return () => {
345      cancelled = true;
346    };
347  });
348  async function handleLinkVideo(videoId) {
349    if (!get(transaction)) return;
350    const selectedVideo = get(videos).find((v) => v.id === videoId);
351    if (!selectedVideo) return;
352    const transactionId = get(transaction).id;
353    const current = $$props.transactions.current ?? [];
354    $$props.transactions.mutate(current.map((t) => t.id === transactionId ? {
355      ...t,
356      ytVideos: [
357        ...t.ytVideos,
358        {
359          id: selectedVideo.id,
360          name: selectedVideo.name,
361          thumbnail: selectedVideo.thumbnail
362        }
363      ]
364    } : t));
365    try {
366      await linkTransactionToVideoCommand({ transactionId, ytVideoId: videoId });
367    } catch (e) {
368      $$props.transactions.refetch();
369    }
370  }
371  async function handleUnlinkVideo(ytVideoId) {
372    if (!get(transaction)) return;
373    const transactionId = get(transaction).id;
374    const current = $$props.transactions.current ?? [];
375    $$props.transactions.mutate(current.map((t) => t.id === transactionId ? { ...t, ytVideos: t.ytVideos.filter((v) => v.id !== ytVideoId) } : t));
376    try {
377      await unlinkTransactionFromVideo({ transactionId, ytVideoId });
378    } catch (e) {
379      $$props.transactions.refetch();
380    }
381  }
382  async function handleLinkPartnership(partnershipId) {
383    if (!get(transaction)) return;
384    const selectedPartnership = get(partnerships).find((p) => p.id === partnershipId);
385    if (!selectedPartnership) return;
386    const transactionId = get(transaction).id;
387    set(currentView, "details");
388    set(partnershipSearchQuery, "");
389    set(partnershipPage, 0);
390    const current = $$props.transactions.current ?? [];
391    $$props.transactions.mutate(current.map((t) => t.id === transactionId ? { ...t, partnership: selectedPartnership } : t));
392    try {
393      await linkTransactionToPartnershipCommand({ transactionId, partnershipId });
394    } catch (e) {
395      $$props.transactions.refetch();
396    }
397  }
398  async function handleUnlinkPartnership() {
399    if (!get(transaction)) return;
400    const transactionId = get(transaction).id;
401    const current = $$props.transactions.current ?? [];
402    $$props.transactions.mutate(current.map((t) => t.id === transactionId ? { ...t, partnership: null } : t));
403    try {
404      await unlinkTransactionFromPartnership({ transactionId });
405    } catch (e) {
406      $$props.transactions.refetch();
407    }
408  }
409  async function handleReceiptUpload(event2) {
410    if (!get(transaction)) return;
411    if (get(transaction).receipt) {
412      toast.error("This transaction already has a linked receipt.");
413      return;
414    }
415    const input = event2.currentTarget;
416    const file = input.files?.[0];
417    if (!file) return;
418    set(receiptUploading, true);
419    const formData = new FormData();
420    formData.set("receipt", file);
421    try {
422      const response = await fetch(`/transactions/${get(transaction).id}/receipts`, { method: "POST", body: formData });
423      const rawPayload = await response.json().catch(() => null);
424      const payload = isReceiptUploadPayload(rawPayload) ? rawPayload : null;
425      if (!response.ok) {
426        throw new Error(payload?.message ?? payload?.error ?? "Receipt upload failed.");
427      }
428      if (payload?.status === "non_receipt") {
429        toast.error("Payd could not identify that file as a receipt.");
430        return;
431      }
432      if (payload?.status === "failed") {
433        toast.error(payload.error ?? "Receipt processing failed.");
434        return;
435      }
436      toast.success("Receipt linked to this transaction.");
437      await $$props.transactions.refetch();
438    } catch (error) {
439      toast.error(error instanceof Error ? error.message : String(error));
440    } finally {
441      set(receiptUploading, false);
442      input.value = "";
443    }
444  }
445  function resetState() {
446    set(currentView, "details");
447    set(videoSearchQuery, "");
448    set(partnershipSearchQuery, "");
449    set(videoPage, 0);
450    set(partnershipPage, 0);
451    set(receiptPreviewUrl, null);
452    set(receiptPreviewReceiptId, null);
453    set(receiptPreviewLoading, false);
454  }
455  function goBack() {
456    set(currentView, "details");
457    set(videoSearchQuery, "");
458    set(partnershipSearchQuery, "");
459    set(videoPage, 0);
460    set(partnershipPage, 0);
461  }
462  var fragment = comment();
463  var node = first_child(fragment);
464  component(node, () => Dialog, ($$anchor2, Dialog_Root) => {
465    Dialog_Root($$anchor2, {
466      onOpenChange: (isOpen) => {
467        if (!isOpen) resetState();
468      },
469      get open() {
470        return open();
471      },
472      set open($$value) {
473        open($$value);
474      },
475      children: ($$anchor3, $$slotProps) => {
476        var fragment_1 = comment();
477        var node_1 = first_child(fragment_1);
478        component(node_1, () => Dialog_content, ($$anchor4, Dialog_Content) => {
479          Dialog_Content($$anchor4, {
480            class: "max-w-xl",
481            children: ($$anchor5, $$slotProps2) => {
482              var fragment_2 = comment();
483              var node_2 = first_child(fragment_2);
484              {
485                var consequent_28 = ($$anchor6) => {
486                  const isIncome = user_derived(() => get(transaction).type === "income");
487                  var fragment_3 = comment();
488                  var node_3 = first_child(fragment_3);
489                  {
490                    var consequent_3 = ($$anchor7) => {
491                      var fragment_4 = root_4$1();
492                      var node_4 = first_child(fragment_4);
493                      component(node_4, () => Dialog_header, ($$anchor8, Dialog_Header) => {
494                        Dialog_Header($$anchor8, {
495                          children: ($$anchor9, $$slotProps3) => {
496                            var fragment_5 = root_5();
497                            var div = first_child(fragment_5);
498                            var node_5 = child(div);
499                            Button(node_5, {
500                              variant: "ghost",
501                              size: "icon-sm",
502                              onclick: goBack,
503                              children: ($$anchor10, $$slotProps4) => {
504                                Arrow_left($$anchor10, { class: "h-4 w-4" });
505                              },
506                              $$slots: { default: true }
507                            });
508                            var node_6 = sibling(node_5, 2);
509                            component(node_6, () => Dialog_title, ($$anchor10, Dialog_Title) => {
510                              Dialog_Title($$anchor10, {
511                                children: ($$anchor11, $$slotProps4) => {
512                                  next();
513                                  var text$1 = text("Link Video");
514                                  append($$anchor11, text$1);
515                                },
516                                $$slots: { default: true }
517                              });
518                            });
519                            reset(div);
520                            var node_7 = sibling(div, 2);
521                            component(node_7, () => Dialog_description, ($$anchor10, Dialog_Description) => {
522                              Dialog_Description($$anchor10, {
523                                children: ($$anchor11, $$slotProps4) => {
524                                  next();
525                                  var text_1 = text("Select a video to link to this transaction");
526                                  append($$anchor11, text_1);
527                                },
528                                $$slots: { default: true }
529                              });
530                            });
531                            append($$anchor9, fragment_5);
532                          },
533                          $$slots: { default: true }
534                        });
535                      });
536                      var div_1 = sibling(node_4, 2);
537                      var div_2 = child(div_1);
538                      var node_8 = child(div_2);
539                      Search(node_8, {
540                        class: "absolute top-1/2 left-3 h-4 w-4 -translate-y-1/2 text-muted-foreground"
541                      });
542                      var node_9 = sibling(node_8, 2);
543                      Input(node_9, {
544                        type: "text",
545                        placeholder: "Search videos...",
546                        class: "pl-9",
547                        get value() {
548                          return get(videoSearchQuery);
549                        },
550                        set value($$value) {
551                          set(videoSearchQuery, $$value, true);
552                        }
553                      });
554                      reset(div_2);
555                      var div_3 = sibling(div_2, 2);
556                      var node_10 = child(div_3);
557                      {
558                        var consequent = ($$anchor8) => {
559                          var table = root_9();
560                          var tbody = sibling(child(table));
561                          each(tbody, 20, () => Array(5), index, ($$anchor9, _) => {
562                            var tr = root_10$1();
563                            var td = child(tr);
564                            var node_11 = child(td);
565                            Skeleton(node_11, { class: "h-4 w-32" });
566                            reset(td);
567                            var td_1 = sibling(td);
568                            var node_12 = child(td_1);
569                            Skeleton(node_12, { class: "h-4 w-20" });
570                            reset(td_1);
571                            var td_2 = sibling(td_1);
572                            var node_13 = child(td_2);
573                            Skeleton(node_13, { class: "h-6 w-6 rounded" });
574                            reset(td_2);
575                            reset(tr);
576                            append($$anchor9, tr);
577                          });
578                          reset(tbody);
579                          reset(table);
580                          append($$anchor8, table);
581                        };
582                        var consequent_1 = ($$anchor8) => {
583                          var p_1 = root_11();
584                          var text_2 = child(p_1, true);
585                          reset(p_1);
586                          template_effect(() => set_text(text_2, get(videos).length === 0 ? "No videos available" : "No matching videos"));
587                          append($$anchor8, p_1);
588                        };
589                        var alternate = ($$anchor8) => {
590                          var table_1 = root_12();
591                          var tbody_1 = sibling(child(table_1));
592                          each(tbody_1, 21, () => get(paginatedVideos), (video) => video.id, ($$anchor9, video) => {
593                            var tr_1 = root_13();
594                            var td_3 = child(tr_1);
595                            var span = child(td_3);
596                            var text_3 = child(span, true);
597                            reset(span);
598                            reset(td_3);
599                            var td_4 = sibling(td_3);
600                            var text_4 = child(td_4, true);
601                            reset(td_4);
602                            var td_5 = sibling(td_4);
603                            var node_14 = child(td_5);
604                            Button(node_14, {
605                              variant: "ghost",
606                              size: "icon-sm",
607                              onclick: () => handleLinkVideo(get(video).id),
608                              children: ($$anchor10, $$slotProps3) => {
609                                Plus($$anchor10, { class: "h-4 w-4" });
610                              },
611                              $$slots: { default: true }
612                            });
613                            reset(td_5);
614                            reset(tr_1);
615                            template_effect(
616                              ($0) => {
617                                set_text(text_3, get(video).name);
618                                set_text(text_4, $0);
619                              },
620                              [() => formatDateShort(get(video).uploadedAt)]
621                            );
622                            append($$anchor9, tr_1);
623                          });
624                          reset(tbody_1);
625                          reset(table_1);
626                          append($$anchor8, table_1);
627                        };
628                        if_block(node_10, ($$render) => {
629                          if (videosQuery.loading) $$render(consequent);
630                          else if (get(filteredVideos).length === 0) $$render(consequent_1, 1);
631                          else $$render(alternate, false);
632                        });
633                      }
634                      reset(div_3);
635                      var node_15 = sibling(div_3, 2);
636                      {
637                        var consequent_2 = ($$anchor8) => {
638                          var div_4 = root_15();
639                          var span_1 = child(div_4);
640                          var text_5 = child(span_1);
641                          reset(span_1);
642                          var div_5 = sibling(span_1, 2);
643                          var node_16 = child(div_5);
644                          {
645                            let $0 = user_derived(() => get(videoPage) === 0);
646                            Button(node_16, {
647                              variant: "ghost",
648                              size: "icon-sm",
649                              onclick: () => update(videoPage, -1),
650                              get disabled() {
651                                return get($0);
652                              },
653                              children: ($$anchor9, $$slotProps3) => {
654                                Chevron_left($$anchor9, { class: "h-4 w-4" });
655                              },
656                              $$slots: { default: true }
657                            });
658                          }
659                          var node_17 = sibling(node_16, 2);
660                          {
661                            let $0 = user_derived(() => get(videoPage) >= get(videoTotalPages) - 1);
662                            Button(node_17, {
663                              variant: "ghost",
664                              size: "icon-sm",
665                              onclick: () => update(videoPage),
666                              get disabled() {
667                                return get($0);
668                              },
669                              children: ($$anchor9, $$slotProps3) => {
670                                Chevron_right($$anchor9, { class: "h-4 w-4" });
671                              },
672                              $$slots: { default: true }
673                            });
674                          }
675                          reset(div_5);
676                          reset(div_4);
677                          template_effect(($0) => set_text(text_5, `${get(videoPage) * PAGE_SIZE + 1}-${$0 ?? ""} of ${get(filteredVideos).length ?? ""}`), [
678                            () => Math.min((get(videoPage) + 1) * PAGE_SIZE, get(filteredVideos).length)
679                          ]);
680                          append($$anchor8, div_4);
681                        };
682                        if_block(node_15, ($$render) => {
683                          if (get(videoTotalPages) > 1) $$render(consequent_2);
684                        });
685                      }
686                      reset(div_1);
687                      append($$anchor7, fragment_4);
688                    };
689                    var consequent_7 = ($$anchor7) => {
690                      var fragment_10 = root_18$1();
691                      var node_18 = first_child(fragment_10);
692                      component(node_18, () => Dialog_header, ($$anchor8, Dialog_Header_1) => {
693                        Dialog_Header_1($$anchor8, {
694                          children: ($$anchor9, $$slotProps3) => {
695                            var fragment_11 = root_19();
696                            var div_6 = first_child(fragment_11);
697                            var node_19 = child(div_6);
698                            Button(node_19, {
699                              variant: "ghost",
700                              size: "icon-sm",
701                              onclick: goBack,
702                              children: ($$anchor10, $$slotProps4) => {
703                                Arrow_left($$anchor10, { class: "h-4 w-4" });
704                              },
705                              $$slots: { default: true }
706                            });
707                            var node_20 = sibling(node_19, 2);
708                            component(node_20, () => Dialog_title, ($$anchor10, Dialog_Title_1) => {
709                              Dialog_Title_1($$anchor10, {
710                                children: ($$anchor11, $$slotProps4) => {
711                                  next();
712                                  var text_6 = text("Link Partnership");
713                                  append($$anchor11, text_6);
714                                },
715                                $$slots: { default: true }
716                              });
717                            });
718                            reset(div_6);
719                            var node_21 = sibling(div_6, 2);
720                            component(node_21, () => Dialog_description, ($$anchor10, Dialog_Description_1) => {
721                              Dialog_Description_1($$anchor10, {
722                                children: ($$anchor11, $$slotProps4) => {
723                                  next();
724                                  var text_7 = text("Select a partnership to link to this transaction");
725                                  append($$anchor11, text_7);
726                                },
727                                $$slots: { default: true }
728                              });
729                            });
730                            append($$anchor9, fragment_11);
731                          },
732                          $$slots: { default: true }
733                        });
734                      });
735                      var div_7 = sibling(node_18, 2);
736                      var div_8 = child(div_7);
737                      var node_22 = child(div_8);
738                      Search(node_22, {
739                        class: "absolute top-1/2 left-3 h-4 w-4 -translate-y-1/2 text-muted-foreground"
740                      });
741                      var node_23 = sibling(node_22, 2);
742                      Input(node_23, {
743                        type: "text",
744                        placeholder: "Search partnerships...",
745                        class: "pl-9",
746                        get value() {
747                          return get(partnershipSearchQuery);
748                        },
749                        set value($$value) {
750                          set(partnershipSearchQuery, $$value, true);
751                        }
752                      });
753                      reset(div_8);
754                      var div_9 = sibling(div_8, 2);
755                      var node_24 = child(div_9);
756                      {
757                        var consequent_4 = ($$anchor8) => {
758                          var table_2 = root_23$1();
759                          var tbody_2 = sibling(child(table_2));
760                          each(tbody_2, 20, () => Array(5), index, ($$anchor9, _) => {
761                            var tr_2 = root_24();
762                            var td_6 = child(tr_2);
763                            var node_25 = child(td_6);
764                            Skeleton(node_25, { class: "h-4 w-28" });
765                            var node_26 = sibling(node_25, 2);
766                            Skeleton(node_26, { class: "mt-1 h-5 w-16 rounded-full" });
767                            reset(td_6);
768                            var td_7 = sibling(td_6);
769                            var node_27 = child(td_7);
770                            Skeleton(node_27, { class: "h-4 w-20" });
771                            reset(td_7);
772                            var td_8 = sibling(td_7);
773                            var node_28 = child(td_8);
774                            Skeleton(node_28, { class: "ml-auto h-4 w-16" });
775                            reset(td_8);
776                            var td_9 = sibling(td_8);
777                            var node_29 = child(td_9);
778                            Skeleton(node_29, { class: "h-6 w-6 rounded" });
779                            reset(td_9);
780                            reset(tr_2);
781                            append($$anchor9, tr_2);
782                          });
783                          reset(tbody_2);
784                          reset(table_2);
785                          append($$anchor8, table_2);
786                        };
787                        var consequent_5 = ($$anchor8) => {
788                          var p_2 = root_25();
789                          var text_8 = child(p_2, true);
790                          reset(p_2);
791                          template_effect(() => set_text(text_8, get(partnerships).length === 0 ? "No partnerships available" : "No matching partnerships"));
792                          append($$anchor8, p_2);
793                        };
794                        var alternate_1 = ($$anchor8) => {
795                          var table_3 = root_26();
796                          var tbody_3 = sibling(child(table_3));
797                          each(tbody_3, 21, () => get(paginatedPartnerships), (p) => p.id, ($$anchor9, p) => {
798                            var tr_3 = root_27();
799                            var td_10 = child(tr_3);
800                            var div_10 = child(td_10);
801                            var span_2 = child(div_10);
802                            var text_9 = child(span_2, true);
803                            reset(span_2);
804                            var node_30 = sibling(span_2, 2);
805                            {
806                              let $0 = user_derived(() => getPartnershipStatusBadge(get(p).status).class);
807                              Badge(node_30, {
808                                get class() {
809                                  return `mt-1 ${get($0) ?? ""}`;
810                                },
811                                children: ($$anchor10, $$slotProps3) => {
812                                  next();
813                                  var text_10 = text();
814                                  template_effect(($02) => set_text(text_10, $02), [() => getPartnershipStatusBadge(get(p).status).label]);
815                                  append($$anchor10, text_10);
816                                },
817                                $$slots: { default: true }
818                              });
819                            }
820                            reset(div_10);
821                            reset(td_10);
822                            var td_11 = sibling(td_10);
823                            var text_11 = child(td_11, true);
824                            reset(td_11);
825                            var td_12 = sibling(td_11);
826                            var text_12 = child(td_12, true);
827                            reset(td_12);
828                            var td_13 = sibling(td_12);
829                            var node_31 = child(td_13);
830                            Button(node_31, {
831                              variant: "ghost",
832                              size: "icon-sm",
833                              onclick: () => handleLinkPartnership(get(p).id),
834                              children: ($$anchor10, $$slotProps3) => {
835                                Plus($$anchor10, { class: "h-4 w-4" });
836                              },
837                              $$slots: { default: true }
838                            });
839                            reset(td_13);
840                            reset(tr_3);
841                            template_effect(
842                              ($0) => {
843                                set_text(text_9, get(p).title);
844                                set_text(text_11, get(p).partner.contactName);
845                                set_text(text_12, $0);
846                              },
847                              [
848                                () => get(p).amount ? formatCurrency(get(p).amount, null) : "—"
849                              ]
850                            );
851                            append($$anchor9, tr_3);
852                          });
853                          reset(tbody_3);
854                          reset(table_3);
855                          append($$anchor8, table_3);
856                        };
857                        if_block(node_24, ($$render) => {
858                          if (partnershipsQuery.loading) $$render(consequent_4);
859                          else if (get(filteredPartnerships).length === 0) $$render(consequent_5, 1);
860                          else $$render(alternate_1, false);
861                        });
862                      }
863                      reset(div_9);
864                      var node_32 = sibling(div_9, 2);
865                      {
866                        var consequent_6 = ($$anchor8) => {
867                          var div_11 = root_30$1();
868                          var span_3 = child(div_11);
869                          var text_13 = child(span_3);
870                          reset(span_3);
871                          var div_12 = sibling(span_3, 2);
872                          var node_33 = child(div_12);
873                          {
874                            let $0 = user_derived(() => get(partnershipPage) === 0);
875                            Button(node_33, {
876                              variant: "ghost",
877                              size: "icon-sm",
878                              onclick: () => update(partnershipPage, -1),
879                              get disabled() {
880                                return get($0);
881                              },
882                              children: ($$anchor9, $$slotProps3) => {
883                                Chevron_left($$anchor9, { class: "h-4 w-4" });
884                              },
885                              $$slots: { default: true }
886                            });
887                          }
888                          var node_34 = sibling(node_33, 2);
889                          {
890                            let $0 = user_derived(() => get(partnershipPage) >= get(partnershipTotalPages) - 1);
891                            Button(node_34, {
892                              variant: "ghost",
893                              size: "icon-sm",
894                              onclick: () => update(partnershipPage),
895                              get disabled() {
896                                return get($0);
897                              },
898                              children: ($$anchor9, $$slotProps3) => {
899                                Chevron_right($$anchor9, { class: "h-4 w-4" });
900                              },
901                              $$slots: { default: true }
902                            });
903                          }
904                          reset(div_12);
905                          reset(div_11);
906                          template_effect(($0) => set_text(text_13, `${get(partnershipPage) * PAGE_SIZE + 1}-${$0 ?? ""} of ${get(filteredPartnerships).length ?? ""}`), [
907                            () => Math.min((get(partnershipPage) + 1) * PAGE_SIZE, get(filteredPartnerships).length)
908                          ]);
909                          append($$anchor8, div_11);
910                        };
911                        if_block(node_32, ($$render) => {
912                          if (get(partnershipTotalPages) > 1) $$render(consequent_6);
913                        });
914                      }
915                      reset(div_7);
916                      append($$anchor7, fragment_10);
917                    };
918                    var alternate_11 = ($$anchor7) => {
919                      var fragment_17 = root_33$1();
920                      var node_35 = first_child(fragment_17);
921                      component(node_35, () => Dialog_header, ($$anchor8, Dialog_Header_2) => {
922                        Dialog_Header_2($$anchor8, {
923                          children: ($$anchor9, $$slotProps3) => {
924                            var div_13 = root_34();
925                            var div_14 = child(div_13);
926                            var node_36 = child(div_14);
927                            {
928                              var consequent_8 = ($$anchor10) => {
929                                var img = root_35();
930                                template_effect(() => set_attribute(img, "src", get(transaction).logoUrl));
931                                event("error", img, (e) => e.target.style.display = "none");
932                                replay_events(img);
933                                append($$anchor10, img);
934                              };
935                              var alternate_2 = ($$anchor10) => {
936                                {
937                                  let $0 = user_derived(() => get(isIncome) ? "text-green-600 dark:text-green-400" : "text-foreground");
938                                  Credit_card($$anchor10, {
939                                    get class() {
940                                      return `h-6 w-6 ${get($0) ?? ""}`;
941                                    }
942                                  });
943                                }
944                              };
945                              if_block(node_36, ($$render) => {
946                                if (get(transaction).logoUrl) $$render(consequent_8);
947                                else $$render(alternate_2, false);
948                              });
949                            }
950                            reset(div_14);
951                            var div_15 = sibling(div_14, 2);
952                            var node_37 = child(div_15);
953                            component(node_37, () => Dialog_title, ($$anchor10, Dialog_Title_2) => {
954                              Dialog_Title_2($$anchor10, {
955                                class: "text-xl",
956                                children: ($$anchor11, $$slotProps4) => {
957                                  next();
958                                  var text_14 = text();
959                                  template_effect(() => set_text(text_14, get(transaction).merchantName || get(transaction).description || "Unknown"));
960                                  append($$anchor11, text_14);
961                                },
962                                $$slots: { default: true }
963                              });
964                            });
965                            var node_38 = sibling(node_37, 2);
966                            component(node_38, () => Dialog_description, ($$anchor10, Dialog_Description_2) => {
967                              Dialog_Description_2($$anchor10, {
968                                children: ($$anchor11, $$slotProps4) => {
969                                  next();
970                                  var text_15 = text();
971                                  template_effect(($0) => set_text(text_15, $0), [() => formatDate(get(transaction).date)]);
972                                  append($$anchor11, text_15);
973                                },
974                                $$slots: { default: true }
975                              });
976                            });
977                            reset(div_15);
978                            var p_3 = sibling(div_15, 2);
979                            var text_16 = child(p_3);
980                            reset(p_3);
981                            reset(div_13);
982                            template_effect(
983                              ($0) => {
984                                set_class(div_14, 1, `flex h-12 w-12 shrink-0 items-center justify-center rounded-lg ${get(isIncome) ? "bg-green-100 dark:bg-green-900/30" : "bg-muted"}`);
985                                set_class(p_3, 1, `text-2xl font-bold ${get(isIncome) ? "text-green-600 dark:text-green-400" : ""}`);
986                                set_text(text_16, `${get(isIncome) ? "+" : "-"}${$0 ?? ""}`);
987                              },
988                              [
989                                () => formatCurrency(get(transaction).amount, get(transaction).isoCurrencyCode)
990                              ]
991                            );
992                            append($$anchor9, div_13);
993                          },
994                          $$slots: { default: true }
995                        });
996                      });
997                      var div_16 = sibling(node_35, 2);
998                      var node_39 = child(div_16);
999                      {
1000                        var consequent_9 = ($$anchor8) => {
1001                          var div_17 = root_39();
1002                          var p_4 = sibling(child(div_17), 2);
1003                          var text_17 = child(p_4, true);
1004                          reset(p_4);
1005                          reset(div_17);
1006                          template_effect(() => set_text(text_17, get(transaction).description));
1007                          append($$anchor8, div_17);
1008                        };
1009                        if_block(node_39, ($$render) => {
1010                          if (get(transaction).description && get(transaction).merchantName) $$render(consequent_9);
1011                        });
1012                      }
1013                      var div_18 = sibling(node_39, 2);
1014                      var node_40 = child(div_18);
1015                      {
1016                        let $0 = user_derived(() => get(isIncome) ? "border-green-200 bg-green-50 text-green-700 dark:border-green-800 dark:bg-green-900/20 dark:text-green-400" : "border-border bg-muted text-foreground");
1017                        Badge(node_40, {
1018                          variant: "outline",
1019                          get class() {
1020                            return get($0);
1021                          },
1022                          children: ($$anchor8, $$slotProps3) => {
1023                            var fragment_21 = comment();
1024                            var node_41 = first_child(fragment_21);
1025                            {
1026                              var consequent_10 = ($$anchor9) => {
1027                                var fragment_22 = root_41$1();
1028                                var node_42 = first_child(fragment_22);
1029                                Arrow_down_left(node_42, { class: "h-3 w-3" });
1030                                next();
1031                                append($$anchor9, fragment_22);
1032                              };
1033                              var alternate_3 = ($$anchor9) => {
1034                                var fragment_23 = root_42();
1035                                var node_43 = first_child(fragment_23);
1036                                Arrow_up_right(node_43, { class: "h-3 w-3" });
1037                                next();
1038                                append($$anchor9, fragment_23);
1039                              };
1040                              if_block(node_41, ($$render) => {
1041                                if (get(isIncome)) $$render(consequent_10);
1042                                else $$render(alternate_3, false);
1043                              });
1044                            }
1045                            append($$anchor8, fragment_21);
1046                          },
1047                          $$slots: { default: true }
1048                        });
1049                      }
1050                      var node_44 = sibling(node_40, 2);
1051                      {
1052                        var consequent_11 = ($$anchor8) => {
1053                          Badge($$anchor8, {
1054                            variant: "outline",
1055                            children: ($$anchor9, $$slotProps3) => {
1056                              next();
1057                              var text_18 = text();
1058                              template_effect(() => set_text(text_18, get(transaction).category.name));
1059                              append($$anchor9, text_18);
1060                            },
1061                            $$slots: { default: true }
1062                          });
1063                        };
1064                        if_block(node_44, ($$render) => {
1065                          if (get(transaction).category) $$render(consequent_11);
1066                        });
1067                      }
1068                      reset(div_18);
1069                      var node_45 = sibling(div_18, 2);
1070                      {
1071                        var consequent_15 = ($$anchor8) => {
1072                          var div_19 = root_45();
1073                          var div_20 = child(div_19);
1074                          var div_21 = child(div_20);
1075                          var div_22 = child(div_21);
1076                          var node_46 = child(div_22);
1077                          Brain_circuit(node_46, { class: "h-4 w-4 text-muted-foreground" });
1078                          next(2);
1079                          reset(div_22);
1080                          var p_5 = sibling(div_22, 2);
1081                          var text_19 = child(p_5, true);
1082                          reset(p_5);
1083                          reset(div_21);
1084                          var div_23 = sibling(div_21, 2);
1085                          var node_47 = child(div_23);
1086                          Badge(node_47, {
1087                            variant: "outline",
1088                            children: ($$anchor9, $$slotProps3) => {
1089                              next();
1090                              var text_20 = text();
1091                              template_effect(() => set_text(text_20, get(classificationExplanation).statusLabel));
1092                              append($$anchor9, text_20);
1093                            },
1094                            $$slots: { default: true }
1095                          });
1096                          var node_48 = sibling(node_47, 2);
1097                          Badge(node_48, {
1098                            variant: "secondary",
1099                            children: ($$anchor9, $$slotProps3) => {
1100                              next();
1101                              var text_21 = text();
1102                              template_effect(() => set_text(text_21, `${get(classificationExplanation).confidenceLabel ?? ""} • ${get(classificationExplanation).confidenceText ?? ""}`));
1103                              append($$anchor9, text_21);
1104                            },
1105                            $$slots: { default: true }
1106                          });
1107                          reset(div_23);
1108                          reset(div_20);
1109                          var div_24 = sibling(div_20, 2);
1110                          var node_49 = child(div_24);
1111                          {
1112                            var consequent_12 = ($$anchor9) => {
1113                              Badge($$anchor9, {
1114                                variant: "outline",
1115                                children: ($$anchor10, $$slotProps3) => {
1116                                  var fragment_29 = root_49$1();
1117                                  var node_50 = first_child(fragment_29);
1118                                  Circle_check(node_50, { class: "h-3 w-3" });
1119                                  var text_22 = sibling(node_50);
1120                                  template_effect(() => set_text(text_22, ` ${get(classificationExplanation).categoryName ?? ""}`));
1121                                  append($$anchor10, fragment_29);
1122                                },
1123                                $$slots: { default: true }
1124                              });
1125                            };
1126                            if_block(node_49, ($$render) => {
1127                              if (get(classificationExplanation).categoryName) $$render(consequent_12);
1128                            });
1129                          }
1130                          reset(div_24);
1131                          var div_25 = sibling(div_24, 2);
1132                          var ul = sibling(child(div_25), 2);
1133                          each(ul, 21, () => get(classificationExplanation).signals, index, ($$anchor9, signal) => {
1134                            var li = root_50();
1135                            var span_4 = sibling(child(li), 2);
1136                            var text_23 = child(span_4, true);
1137                            reset(span_4);
1138                            reset(li);
1139                            template_effect(() => set_text(text_23, get(signal)));
1140                            append($$anchor9, li);
1141                          });
1142                          reset(ul);
1143                          reset(div_25);
1144                          var node_51 = sibling(div_25, 2);
1145                          {
1146                            var consequent_13 = ($$anchor9) => {
1147                              var div_26 = root_51();
1148                              var div_27 = child(div_26);
1149                              var node_52 = child(div_27);
1150                              Message_circle_question_mark(node_52, { class: "h-4 w-4 text-muted-foreground" });
1151                              next(2);
1152                              reset(div_27);
1153                              var p_6 = sibling(div_27, 2);
1154                              var text_24 = child(p_6, true);
1155                              reset(p_6);
1156                              reset(div_26);
1157                              template_effect(() => set_text(text_24, get(classificationExplanation).followUpQuestion));
1158                              append($$anchor9, div_26);
1159                            };
1160                            if_block(node_51, ($$render) => {
1161                              if (get(classificationExplanation).followUpQuestion) $$render(consequent_13);
1162                            });
1163                          }
1164                          var node_53 = sibling(node_51, 2);
1165                          {
1166                            var consequent_14 = ($$anchor9) => {
1167                              var div_28 = root_52$1();
1168                              var p_7 = sibling(child(div_28), 2);
1169                              var text_25 = child(p_7, true);
1170                              reset(p_7);
1171                              reset(div_28);
1172                              template_effect(() => set_text(text_25, get(classificationExplanation).userAnswer));
1173                              append($$anchor9, div_28);
1174                            };
1175                            if_block(node_53, ($$render) => {
1176                              if (get(classificationExplanation).userAnswer) $$render(consequent_14);
1177                            });
1178                          }
1179                          reset(div_19);
1180                          template_effect(() => set_text(text_19, get(classificationExplanation).summary));
1181                          append($$anchor8, div_19);
1182                        };
1183                        if_block(node_45, ($$render) => {
1184                          if (get(classificationExplanation)) $$render(consequent_15);
1185                        });
1186                      }
1187                      var div_29 = sibling(node_45, 2);
1188                      var node_54 = sibling(child(div_29), 2);
1189                      {
1190                        var consequent_16 = ($$anchor8) => {
1191                          Badge($$anchor8, {
1192                            variant: "outline",
1193                            children: ($$anchor9, $$slotProps3) => {
1194                              var fragment_31 = root_54$1();
1195                              var node_55 = first_child(fragment_31);
1196                              Landmark(node_55, { class: "h-3 w-3" });
1197                              var text_26 = sibling(node_55);
1198                              template_effect(() => set_text(text_26, ` ${get(transaction).plaidAccount.name ?? ""}${get(transaction).plaidAccount.mask ? ` ••${get(transaction).plaidAccount.mask}` : ""}`));
1199                              append($$anchor9, fragment_31);
1200                            },
1201                            $$slots: { default: true }
1202                          });
1203                        };
1204                        var alternate_4 = ($$anchor8) => {
1205                          Badge($$anchor8, {
1206                            variant: "outline",
1207                            children: ($$anchor9, $$slotProps3) => {
1208                              next();
1209                              var text_27 = text("Manual");
1210                              append($$anchor9, text_27);
1211                            },
1212                            $$slots: { default: true }
1213                          });
1214                        };
1215                        if_block(node_54, ($$render) => {
1216                          if (get(transaction).plaidAccount) $$render(consequent_16);
1217                          else $$render(alternate_4, false);
1218                        });
1219                      }
1220                      reset(div_29);
1221                      var div_30 = sibling(div_29, 2);
1222                      var div_31 = child(div_30);
1223                      var node_56 = sibling(child(div_31), 2);
1224                      {
1225                        var consequent_18 = ($$anchor8) => {
1226                          var label = root_57();
1227                          var node_57 = child(label);
1228                          {
1229                            var consequent_17 = ($$anchor9) => {
1230                              var fragment_33 = root_58$1();
1231                              var node_58 = first_child(fragment_33);
1232                              Loader_circle(node_58, { class: "h-4 w-4 animate-spin" });
1233                              next();
1234                              append($$anchor9, fragment_33);
1235                            };
1236                            var alternate_5 = ($$anchor9) => {
1237                              var fragment_34 = root_59();
1238                              var node_59 = first_child(fragment_34);
1239                              Upload(node_59, { class: "h-4 w-4" });
1240                              next();
1241                              append($$anchor9, fragment_34);
1242                            };
1243                            if_block(node_57, ($$render) => {
1244                              if (get(receiptUploading)) $$render(consequent_17);
1245                              else $$render(alternate_5, false);
1246                            });
1247                          }
1248                          var input_1 = sibling(node_57, 2);
1249                          reset(label);
1250                          template_effect(() => {
1251                            set_class(label, 1, `inline-flex cursor-pointer items-center gap-2 rounded-md border px-3 py-1.5 text-sm transition-colors hover:bg-muted ${get(receiptUploading) ? "pointer-events-none opacity-60" : ""}`);
1252                            input_1.disabled = get(receiptUploading);
1253                          });
1254                          delegated("change", input_1, handleReceiptUpload);
1255                          append($$anchor8, label);
1256                        };
1257                        if_block(node_56, ($$render) => {
1258                          if (!get(transaction).receipt) $$render(consequent_18);
1259                        });
1260                      }
1261                      reset(div_31);
1262                      var node_60 = sibling(div_31, 2);
1263                      {
1264                        var consequent_21 = ($$anchor8) => {
1265                          const linkedReceipt = user_derived(() => get(transaction).receipt);
1266                          var div_32 = root_60();
1267                          var div_33 = child(div_32);
1268                          var node_61 = child(div_33);
1269                          {
1270                            var consequent_19 = ($$anchor9) => {
1271                              var a = root_61();
1272                              var img_1 = child(a);
1273                              reset(a);
1274                              template_effect(() => {
1275                                set_attribute(a, "href", get(receiptPreviewUrl));
1276                                set_attribute(img_1, "src", get(receiptPreviewUrl));
1277                              });
1278                              append($$anchor9, a);
1279                            };
1280                            var consequent_20 = ($$anchor9) => {
1281                              var div_34 = root_62();
1282                              var node_62 = child(div_34);
1283                              Loader_circle(node_62, { class: "h-5 w-5 animate-spin text-muted-foreground" });
1284                              reset(div_34);
1285                              append($$anchor9, div_34);
1286                            };
1287                            var alternate_6 = ($$anchor9) => {
1288                              var div_35 = root_63$1();
1289                              var node_63 = child(div_35);
1290                              Receipt_text(node_63, { class: "h-5 w-5 text-muted-foreground" });
1291                              reset(div_35);
1292                              append($$anchor9, div_35);
1293                            };
1294                            if_block(node_61, ($$render) => {
1295                              if (get(receiptPreviewUrl)) $$render(consequent_19);
1296                              else if (get(receiptPreviewLoading)) $$render(consequent_20, 1);
1297                              else $$render(alternate_6, false);
1298                            });
1299                          }
1300                          var div_36 = sibling(node_61, 2);
1301                          var p_8 = child(div_36);
1302                          var text_28 = child(p_8, true);
1303                          reset(p_8);
1304                          var p_9 = sibling(p_8, 2);
1305                          var text_29 = child(p_9);
1306                          reset(p_9);
1307                          reset(div_36);
1308                          reset(div_33);
1309                          var node_64 = sibling(div_33, 2);
1310                          Badge(node_64, {
1311                            variant: "outline",
1312                            children: ($$anchor9, $$slotProps3) => {
1313                              next();
1314                              var text_30 = text("Receipt");
1315                              append($$anchor9, text_30);
1316                            },
1317                            $$slots: { default: true }
1318                          });
1319                          reset(div_32);
1320                          template_effect(
1321                            ($0, $1) => {
1322                              set_text(text_28, get(linkedReceipt).merchantName || "Receipt");
1323                              set_text(text_29, `${$0 ?? ""} - ${$1 ?? ""}`);
1324                            },
1325                            [
1326                              () => formatDateShort(get(linkedReceipt).receiptDate),
1327                              () => formatCurrency(get(linkedReceipt).totalAmount, get(linkedReceipt).currency)
1328                            ]
1329                          );
1330                          append($$anchor8, div_32);
1331                        };
1332                        var alternate_7 = ($$anchor8) => {
1333                          var p_10 = root_65();
1334                          append($$anchor8, p_10);
1335                        };
1336                        if_block(node_60, ($$render) => {
1337                          if (get(transaction).receipt) $$render(consequent_21);
1338                          else $$render(alternate_7, false);
1339                        });
1340                      }
1341                      reset(div_30);
1342                      var div_37 = sibling(div_30, 2);
1343                      var div_38 = child(div_37);
1344                      var p_11 = child(div_38);
1345                      var text_31 = child(p_11, true);
1346                      reset(p_11);
1347                      var node_65 = sibling(p_11, 2);
1348                      {
1349                        var consequent_24 = ($$anchor8) => {
1350                          var fragment_35 = root_66();
1351                          var div_39 = first_child(fragment_35);
1352                          each(div_39, 21, () => get(transaction).ytVideos, (linkedVideo) => linkedVideo.id, ($$anchor9, linkedVideo) => {
1353                            var div_40 = root_67();
1354                            var button = child(div_40);
1355                            var node_66 = child(button);
1356                            {
1357                              var consequent_22 = ($$anchor10) => {
1358                                var img_2 = root_68$1();
1359                                template_effect(() => set_attribute(img_2, "src", get(linkedVideo).thumbnail));
1360                                append($$anchor10, img_2);
1361                              };
1362                              var alternate_8 = ($$anchor10) => {
1363                                var div_41 = root_69();
1364                                var node_67 = child(div_41);
1365                                Video(node_67, { class: "h-4 w-4 text-muted-foreground" });
1366                                reset(div_41);
1367                                append($$anchor10, div_41);
1368                              };
1369                              if_block(node_66, ($$render) => {
1370                                if (get(linkedVideo).thumbnail) $$render(consequent_22);
1371                                else $$render(alternate_8, false);
1372                              });
1373                            }
1374                            var span_5 = sibling(node_66, 2);
1375                            var text_32 = child(span_5, true);
1376                            reset(span_5);
1377                            reset(button);
1378                            var node_68 = sibling(button, 2);
1379                            Button(node_68, {
1380                              variant: "ghost",
1381                              size: "icon-sm",
1382                              onclick: () => handleUnlinkVideo(get(linkedVideo).id),
1383                              children: ($$anchor10, $$slotProps3) => {
1384                                X($$anchor10, { class: "h-4 w-4" });
1385                              },
1386                              $$slots: { default: true }
1387                            });
1388                            reset(div_40);
1389                            template_effect(() => set_text(text_32, get(linkedVideo).name));
1390                            delegated("click", button, () => {
1391                              open(false);
1392                              goto(paths.content(get(linkedVideo).id));
1393                            });
1394                            append($$anchor9, div_40);
1395                          });
1396                          reset(div_39);
1397                          var node_69 = sibling(div_39, 2);
1398                          {
1399                            var consequent_23 = ($$anchor9) => {
1400                              const perVideo = user_derived(() => parseFloat(get(transaction).amount) / get(transaction).ytVideos.length);
1401                              var p_12 = root_71();
1402                              var text_33 = child(p_12);
1403                              reset(p_12);
1404                              template_effect(($0) => set_text(text_33, `Split across ${get(transaction).ytVideos.length ?? ""} videos · ${$0 ?? ""} per video`), [
1405                                () => formatCurrency(get(perVideo).toFixed(2), get(transaction).isoCurrencyCode)
1406                              ]);
1407                              append($$anchor9, p_12);
1408                            };
1409                            if_block(node_69, ($$render) => {
1410                              if (get(transaction).ytVideos.length > 1) $$render(consequent_23);
1411                            });
1412                          }
1413                          var node_70 = sibling(node_69, 2);
1414                          {
1415                            let $0 = user_derived(() => get(videos).length === 0 || get(linkedVideoIds).size >= get(videos).length);
1416                            Button(node_70, {
1417                              variant: "outline",
1418                              size: "sm",
1419                              class: "mt-2 w-full justify-start",
1420                              onclick: () => set(currentView, "link-video"),
1421                              get disabled() {
1422                                return get($0);
1423                              },
1424                              children: ($$anchor9, $$slotProps3) => {
1425                                var fragment_37 = root_72();
1426                                var node_71 = first_child(fragment_37);
1427                                Plus(node_71, { class: "h-4 w-4" });
1428                                var text_34 = sibling(node_71);
1429                                template_effect(() => set_text(text_34, ` ${get(linkedVideoIds).size >= get(videos).length ? "All videos linked" : "Link another video"}`));
1430                                append($$anchor9, fragment_37);
1431                              },
1432                              $$slots: { default: true }
1433                            });
1434                          }
1435                          append($$anchor8, fragment_35);
1436                        };
1437                        var consequent_25 = ($$anchor8) => {
1438                          Button($$anchor8, {
1439                            variant: "outline",
1440                            size: "sm",
1441                            class: "w-full justify-start",
1442                            disabled: true,
1443                            children: ($$anchor9, $$slotProps3) => {
1444                              var fragment_39 = root_74();
1445                              var node_72 = first_child(fragment_39);
1446                              Loader_circle(node_72, { class: "h-4 w-4 animate-spin" });
1447                              next();
1448                              append($$anchor9, fragment_39);
1449                            },
1450                            $$slots: { default: true }
1451                          });
1452                        };
1453                        var alternate_9 = ($$anchor8) => {
1454                          {
1455                            let $0 = user_derived(() => get(videos).length === 0);
1456                            Button($$anchor8, {
1457                              variant: "outline",
1458                              size: "sm",
1459                              class: "w-full justify-start",
1460                              onclick: () => set(currentView, "link-video"),
1461                              get disabled() {
1462                                return get($0);
1463                              },
1464                              children: ($$anchor9, $$slotProps3) => {
1465                                var fragment_41 = root_76();
1466                                var node_73 = first_child(fragment_41);
1467                                Plus(node_73, { class: "h-4 w-4" });
1468                                var text_35 = sibling(node_73);
1469                                template_effect(() => set_text(text_35, ` ${get(videos).length === 0 ? "No videos available" : "Link to video"}`));
1470                                append($$anchor9, fragment_41);
1471                              },
1472                              $$slots: { default: true }
1473                            });
1474                          }
1475                        };
1476                        if_block(node_65, ($$render) => {
1477                          if (get(transaction).ytVideos.length > 0) $$render(consequent_24);
1478                          else if (videosQuery.loading) $$render(consequent_25, 1);
1479                          else $$render(alternate_9, false);
1480                        });
1481                      }
1482                      reset(div_38);
1483                      var div_42 = sibling(div_38, 2);
1484                      var node_74 = sibling(child(div_42), 2);
1485                      {
1486                        var consequent_26 = ($$anchor8) => {
1487                          var div_43 = root_77();
1488                          var button_1 = child(div_43);
1489                          var div_44 = child(button_1);
1490                          var p_13 = child(div_44);
1491                          var text_36 = child(p_13, true);
1492                          reset(p_13);
1493                          var p_14 = sibling(p_13, 2);
1494                          var text_37 = child(p_14, true);
1495                          reset(p_14);
1496                          reset(div_44);
1497                          reset(button_1);
1498                          var node_75 = sibling(button_1, 2);
1499                          Button(node_75, {
1500                            variant: "ghost",
1501                            size: "icon-sm",
1502                            onclick: handleUnlinkPartnership,
1503                            children: ($$anchor9, $$slotProps3) => {
1504                              X($$anchor9, { class: "h-4 w-4" });
1505                            },
1506                            $$slots: { default: true }
1507                          });
1508                          reset(div_43);
1509                          template_effect(() => {
1510                            set_text(text_36, get(transaction).partnership.title);
1511                            set_text(text_37, get(transaction).partnership.partner.contactName);
1512                          });
1513                          delegated("click", button_1, () => {
1514                            if (get(transaction)?.partnership) {
1515                              open(false);
1516                              goto(paths.partners.partnerships.detail(get(transaction).partnership.partner.id, get(transaction).partnership.id));
1517                            }
1518                          });
1519                          append($$anchor8, div_43);
1520                        };
1521                        var consequent_27 = ($$anchor8) => {
1522                          Button($$anchor8, {
1523                            variant: "outline",
1524                  
1524          size: "sm",
1525                            class: "w-full justify-start",
1526                            disabled: true,
1527                            children: ($$anchor9, $$slotProps3) => {
1528                              var fragment_44 = root_80();
1529                              var node_76 = first_child(fragment_44);
1530                              Loader_circle(node_76, { class: "h-4 w-4 animate-spin" });
1531                              next();
1532                              append($$anchor9, fragment_44);
1533                            },
1534                            $$slots: { default: true }
1535                          });
1536                        };
1537                        var alternate_10 = ($$anchor8) => {
1538                          {
1539                            let $0 = user_derived(() => get(partnerships).length === 0);
1540                            Button($$anchor8, {
1541                              variant: "outline",
1542                              size: "sm",
1543                              class: "w-full justify-start",
1544                              onclick: () => set(currentView, "link-partnership"),
1545                              get disabled() {
1546                                return get($0);
1547                              },
1548                              children: ($$anchor9, $$slotProps3) => {
1549                                var fragment_46 = root_82();
1550                                var node_77 = first_child(fragment_46);
1551                                Plus(node_77, { class: "h-4 w-4" });
1552                                var text_38 = sibling(node_77);
1553                                template_effect(() => set_text(text_38, ` ${get(partnerships).length === 0 ? "No partnerships available" : "Link to partnership"}`));
1554                                append($$anchor9, fragment_46);
1555                              },
1556                              $$slots: { default: true }
1557                            });
1558                          }
1559                        };
1560                        if_block(node_74, ($$render) => {
1561                          if (get(transaction).partnership) $$render(consequent_26);
1562                          else if (partnershipsQuery.loading) $$render(consequent_27, 1);
1563                          else $$render(alternate_10, false);
1564                        });
1565                      }
1566                      reset(div_42);
1567                      reset(div_37);
1568                      reset(div_16);
1569                      template_effect(() => set_text(text_31, get(transaction).ytVideos.length > 1 ? "Linked Videos" : "Linked Video"));
1570                      append($$anchor7, fragment_17);
1571                    };
1572                    if_block(node_3, ($$render) => {
1573                      if (get(currentView) === "link-video") $$render(consequent_3);
1574                      else if (get(currentView) === "link-partnership") $$render(consequent_7, 1);
1575                      else $$render(alternate_11, false);
1576                    });
1577                  }
1578                  append($$anchor6, fragment_3);
1579                };
1580                if_block(node_2, ($$render) => {
1581                  if (get(transaction)) $$render(consequent_28);
1582                });
1583              }
1584              append($$anchor5, fragment_2);
1585            },
1586            $$slots: { default: true }
1587          });
1588        });
1589        append($$anchor3, fragment_1);
1590      },
1591      $$slots: { default: true }
1592    });
1593  });
1594  append($$anchor, fragment);
1595  pop();
1596}
1597delegate(["change", "click"]);
1598var root_3$1 = from_html(`<!> <!> <!> <!> <!> <!> <!> <!>`, 1);
1599var root_17 = from_html(`<div class="flex items-center gap-2"><!> <!></div>`);
1600var root_14$1 = from_html(`<!> <!> <!> <!> <!> <!> <!> <!>`, 1);
1601var root_1 = from_html(`<!> <!>`, 1);
1602function TransactionsSkeleton($$anchor) {
1603  Table($$anchor, {
1604    children: ($$anchor2, $$slotProps) => {
1605      var fragment_1 = root_1();
1606      var node = first_child(fragment_1);
1607      Table_header(node, {
1608        children: ($$anchor3, $$slotProps2) => {
1609          Table_row($$anchor3, {
1610            children: ($$anchor4, $$slotProps3) => {
1611              var fragment_3 = root_3$1();
1612              var node_1 = first_child(fragment_3);
1613              Table_head(node_1, {
1614                class: "w-[160px]",
1615                children: ($$anchor5, $$slotProps4) => {
1616                  next();
1617                  var text$1 = text("DATE");
1618                  append($$anchor5, text$1);
1619                },
1620                $$slots: { default: true }
1621              });
1622              var node_2 = sibling(node_1, 2);
1623              Table_head(node_2, {
1624                class: "w-[100px]",
1625                children: ($$anchor5, $$slotProps4) => {
1626                  next();
1627                  var text_1 = text("TYPE");
1628                  append($$anchor5, text_1);
1629                },
1630                $$slots: { default: true }
1631              });
1632              var node_3 = sibling(node_2, 2);
1633              Table_head(node_3, {
1634                class: "w-[200px]",
1635                children: ($$anchor5, $$slotProps4) => {
1636                  next();
1637                  var text_2 = text("VENDOR");
1638                  append($$anchor5, text_2);
1639                },
1640                $$slots: { default: true }
1641              });
1642              var node_4 = sibling(node_3, 2);
1643              Table_head(node_4, {
1644                class: "w-[120px]",
1645                children: ($$anchor5, $$slotProps4) => {
1646                  next();
1647                  var text_3 = text("AMOUNT");
1648                  append($$anchor5, text_3);
1649                },
1650                $$slots: { default: true }
1651              });
1652              var node_5 = sibling(node_4, 2);
1653              Table_head(node_5, {
1654                class: "w-[120px]",
1655                children: ($$anchor5, $$slotProps4) => {
1656                  next();
1657                  var text_4 = text("CATEGORY");
1658                  append($$anchor5, text_4);
1659                },
1660                $$slots: { default: true }
1661              });
1662              var node_6 = sibling(node_5, 2);
1663              Table_head(node_6, {
1664                class: "w-[200px]",
1665                children: ($$anchor5, $$slotProps4) => {
1666                  next();
1667                  var text_5 = text("DESCRIPTION");
1668                  append($$anchor5, text_5);
1669                },
1670                $$slots: { default: true }
1671              });
1672              var node_7 = sibling(node_6, 2);
1673              Table_head(node_7, {
1674                class: "w-[180px]",
1675                children: ($$anchor5, $$slotProps4) => {
1676                  next();
1677                  var text_6 = text("LINKED VIDEO");
1678                  append($$anchor5, text_6);
1679                },
1680                $$slots: { default: true }
1681              });
1682              var node_8 = sibling(node_7, 2);
1683              Table_head(node_8, {
1684                class: "w-[180px]",
1685                children: ($$anchor5, $$slotProps4) => {
1686                  next();
1687                  var text_7 = text("LINKED PARTNERSHIP");
1688                  append($$anchor5, text_7);
1689                },
1690                $$slots: { default: true }
1691              });
1692              append($$anchor4, fragment_3);
1693            },
1694            $$slots: { default: true }
1695          });
1696        },
1697        $$slots: { default: true }
1698      });
1699      var node_9 = sibling(node, 2);
1700      Table_body(node_9, {
1701        children: ($$anchor3, $$slotProps2) => {
1702          var fragment_4 = comment();
1703          var node_10 = first_child(fragment_4);
1704          each(node_10, 0, () => Array(8), index, ($$anchor4, _) => {
1705            Table_row($$anchor4, {
1706              children: ($$anchor5, $$slotProps3) => {
1707                var fragment_6 = root_14$1();
1708                var node_11 = first_child(fragment_6);
1709                Table_cell(node_11, {
1710                  children: ($$anchor6, $$slotProps4) => {
1711                    Skeleton($$anchor6, { class: "h-4 w-24" });
1712                  },
1713                  $$slots: { default: true }
1714                });
1715                var node_12 = sibling(node_11, 2);
1716                Table_cell(node_12, {
1717                  children: ($$anchor6, $$slotProps4) => {
1718                    Skeleton($$anchor6, { class: "h-4 w-16" });
1719                  },
1720                  $$slots: { default: true }
1721                });
1722                var node_13 = sibling(node_12, 2);
1723                Table_cell(node_13, {
1724                  children: ($$anchor6, $$slotProps4) => {
1725                    var div = root_17();
1726                    var node_14 = child(div);
1727                    Skeleton(node_14, { class: "h-5 w-5 rounded" });
1728                    var node_15 = sibling(node_14, 2);
1729                    Skeleton(node_15, { class: "h-4 w-28" });
1730                    reset(div);
1731                    append($$anchor6, div);
1732                  },
1733                  $$slots: { default: true }
1734                });
1735                var node_16 = sibling(node_13, 2);
1736                Table_cell(node_16, {
1737                  children: ($$anchor6, $$slotProps4) => {
1738                    Skeleton($$anchor6, { class: "h-4 w-20" });
1739                  },
1740                  $$slots: { default: true }
1741                });
1742                var node_17 = sibling(node_16, 2);
1743                Table_cell(node_17, {
1744                  children: ($$anchor6, $$slotProps4) => {
1745                    Skeleton($$anchor6, { class: "h-6 w-16 rounded-full" });
1746                  },
1747                  $$slots: { default: true }
1748                });
1749                var node_18 = sibling(node_17, 2);
1750                Table_cell(node_18, {
1751                  children: ($$anchor6, $$slotProps4) => {
1752                    Skeleton($$anchor6, { class: "h-4 w-32" });
1753                  },
1754                  $$slots: { default: true }
1755                });
1756                var node_19 = sibling(node_18, 2);
1757                Table_cell(node_19, {
1758                  children: ($$anchor6, $$slotProps4) => {
1759                    Skeleton($$anchor6, { class: "h-4 w-24" });
1760                  },
1761                  $$slots: { default: true }
1762                });
1763                var node_20 = sibling(node_19, 2);
1764                Table_cell(node_20, {
1765                  children: ($$anchor6, $$slotProps4) => {
1766                    Skeleton($$anchor6, { class: "h-4 w-24" });
1767                  },
1768                  $$slots: { default: true }
1769                });
1770                append($$anchor5, fragment_6);
1771              },
1772              $$slots: { default: true }
1773            });
1774          });
1775          append($$anchor3, fragment_4);
1776        },
1777        $$slots: { default: true }
1778      });
1779      append($$anchor2, fragment_1);
1780    },
1781    $$slots: { default: true }
1782  });
1783}
1784function buildAssistantBacklogSummary(backlog) {
1785  if (!backlog) {
1786    return null;
1787  }
1788  const queuedCount = backlog.queuedCount ?? backlog.pendingGroupCount ?? 0;
1789  const activeCount = backlog.activeCount ?? 0;
1790  const displayCount = backlog.status === "awaiting_reply" ? activeCount : queuedCount;
1791  if (displayCount === 0) {
1792    return null;
1793  }
1794  if (!backlog.status) {
1795    const label = displayCount === 1 ? "1 transaction group" : `${displayCount} transaction groups`;
1796    return {
1797      title: "Transactions need review",
1798      description: `${label} need your review. Message the assistant to go through them.`,
1799      countLabel: label,
1800      previewTransactions: []
1801    };
1802  }
1803  const previewTransactions = backlog.previewTransactions ?? [];
1804  const countLabel = displayCount === 1 ? "1 transaction" : `${displayCount} transactions`;
1805  const merchantPreview = formatMerchantPreview(backlog.merchantNames ?? []);
1806  const questionPreview = backlog.questionPreview?.trim() || void 0;
1807  if (backlog.status === "awaiting_reply") {
1808    return {
1809      title: "Assistant waiting on your reply",
1810      description: `The assistant is already waiting on you for ${countLabel} in chat.`,
1811      countLabel,
1812      statusLabel: "Awaiting reply",
1813      statusDetail: "Reply in chat to clear this active bookkeeping question.",
1814      merchantPreview,
1815      questionLabel: "Active assistant question",
1816      questionPreview,
1817      previewLabel: `Showing the ${countLabel} in the active chat question.`,
1818      previewTransactions
1819    };
1820  }
1821  return {
1822    title: "Assistant bookkeeping backlog",
1823    description: `The assistant still has ${countLabel} queued to review in chat.`,
1824    countLabel,
1825    statusLabel: "Queued in assistant",
1826    statusDetail: (backlog.deliveryCount ?? 0) > 0 ? "The assistant already started this review in chat and still has more queued." : "The assistant has not surfaced this batch in chat yet.",
1827    merchantPreview,
1828    questionLabel: "Next assistant question",
1829    questionPreview,
1830    previewLabel: buildQueuedPreviewLabel(previewTransactions.length, queuedCount),
1831    previewTransactions
1832  };
1833}
1834function buildQueuedPreviewLabel(previewCount, queuedCount) {
1835  if (previewCount === 0) {
1836    return void 0;
1837  }
1838  if (previewCount >= queuedCount) {
1839    return `Showing all ${queuedCount} queued transactions.`;
1840  }
1841  return `Showing ${previewCount} of ${queuedCount} queued transactions.`;
1842}
1843function formatMerchantPreview(merchantNames) {
1844  if (merchantNames.length === 0) {
1845    return void 0;
1846  }
1847  if (merchantNames.length === 1) {
1848    return merchantNames[0];
1849  }
1850  if (merchantNames.length === 2) {
1851    return `${merchantNames[0]} and ${merchantNames[1]}`;
1852  }
1853  return `${merchantNames[0]}, ${merchantNames[1]}, and ${merchantNames.length - 2} more`;
1854}
1855var root_4 = from_html(`<!> <!>`, 1);
1856var root_8 = from_html(`<!> <!>`, 1);
1857var root_10 = from_html(`<!> <!> <!>`, 1);
1858var root_14 = from_html(`<!> <!> <!>`, 1);
1859var root_21 = from_html(`<!> Income`, 1);
1860var root_22 = from_html(`<!> Expense`, 1);
1861var root_20 = from_html(`<!> <!>`, 1);
1862var root_23 = from_html(`<!> <!>`, 1);
1863var root_18 = from_html(`<!> <div class="flex gap-2"><!> <!></div> <input type="hidden" name="type"/> <!>`, 1);
1864var root_7 = from_html(`<!> <!> <!> <!>`, 1);
1865var root_3 = from_html(`<!> <form><!> <!></form>`, 1);
1866var root_30 = from_html(`<!> Add Manual Entry`, 1);
1867var root_33 = from_html(`<div class="flex items-center gap-2"><div class="flex h-8 w-8 items-center justify-center rounded-full bg-green-100 dark:bg-green-900/30"><!></div> <!></div> <!>`, 1);
1868var root_36 = from_html(`<p class="text-xs text-muted-foreground">Last 30 days</p>`);
1869var root_32 = from_html(`<!> <!>`, 1);
1870var root_38 = from_html(`<div class="flex items-center gap-2"><div class="flex h-8 w-8 items-center justify-center rounded-full bg-muted"><!></div> <!></div> <!>`, 1);
1871var root_41 = from_html(`<p class="text-xs text-muted-foreground">Last 30 days</p>`);
1872var root_37 = from_html(`<!> <!>`, 1);
1873var root_43 = from_html(`<div class="flex items-center gap-2"><div class="flex h-8 w-8 items-center justify-center rounded-full bg-green-100 dark:bg-green-900/30"><!></div> <!></div> <!>`, 1);
1874var root_31 = from_html(`<div class="grid gap-4 md:grid-cols-3"><!> <!> <!></div>`);
1875var root_49 = from_html(`<!> <!>`, 1);
1876var root_47 = from_html(`<!> <!>`, 1);
1877var root_56 = from_html(`<p> </p> <div class="mt-2 flex items-center gap-2 text-xs"><!></div>`, 1);
1878var root_54 = from_html(`<!> <!> <!>`, 1);
1879var root_58 = from_html(`<!> <!>`, 1);
1880var root_64 = from_html(`<span class="truncate"> </span>`);
1881var root_63 = from_html(`<!> <!>`, 1);
1882var root_68 = from_html(`<!> <!>`, 1);
1883var root_75 = from_html(`<!> <!> <!>`, 1);
1884var root_73 = from_html(`<!> <!>`, 1);
1885var root_84 = from_html(`<div class="pointer-events-none absolute inset-0 z-10 bg-background/50"></div>`);
1886var root_88 = from_html(`<button class="flex items-center gap-1 hover:text-foreground">DATE <!></button>`);
1887var root_91 = from_html(`<button class="flex items-center gap-1 hover:text-foreground">AMOUNT <!></button>`);
1888var root_87 = from_html(`<!> <!> <!> <!> <!> <!> <!> <!>`, 1);
1889var root_105 = from_html(`<img alt="" class="h-5 w-5 rounded"/>`);
1890var root_106 = from_html(`<span class="inline-flex h-5 shrink-0 items-center gap-1 rounded-full border border-emerald-500/30 bg-emerald-500/10 px-1.5 text-emerald-600 dark:text-emerald-400" title="Receipt linked" aria-label="Receipt linked"><!></span>`);
1891var root_104 = from_html(`<div class="flex min-w-0 items-center gap-2"><!> <span class="block min-w-0 flex-1 truncate font-medium"> </span> <!></div>`);
1892var root_112 = from_html(`<span> </span>`);
1893var root_118 = from_html(`<span class="text-muted-foreground">—</span>`);
1894var root_119 = from_html(`<span class="block truncate text-muted-foreground"> </span>`);
1895var root_121 = from_html(`<span class="text-muted-foreground">—</span>`);
1896var root_122 = from_html(`<span class="inline-block max-w-[120px] truncate align-bottom text-xs"> </span>`);
1897var root_126 = from_html(`<span class="inline-block max-w-[140px] truncate align-bottom text-xs"> </span>`);
1898var root_127 = from_html(`<span class="text-muted-foreground">—</span>`);
1899var root_102 = from_html(`<!> <!> <!> <!> <!> <!> <!> <!>`, 1);
1900var root_85 = from_html(`<!> <!>`, 1);
1901var root_83 = from_html(`<div class="relative"><!> <!></div>`);
1902var root_132 = from_html(`<!> <!> <!>`, 1);
1903var root_52 = from_html(`<div class="mt-4 space-y-4"><!> <div class="flex flex-wrap items-center gap-4"><!> <!> <!> <!> <div class="relative"><!> <!></div> <!></div> <!> <div class="flex items-center justify-between"><p class="text-xs text-muted-foreground"><!></p> <!></div></div>`);
1904var root = from_html(
1905  `<!> <!> <div class="space-y-6"><div class="flex items-center justify-between"><div><h1 class="text-xl font-medium tracking-tight">Transactions</h1> <p class="text-sm text-muted-foreground">Audit trail, explanations, and manual inspection. The assistant handles review and follow-up
1906				in chat.</p></div> <!></div> <!> <!></div>`,
1907  1
1908);
1909function _page($$anchor, $$props) {
1910  push($$props, true);
1911  function toDialogTransaction(t) {
1912    return {
1913      id: t.id,
1914      type: t.type,
1915      amount: t.amount,
1916      merchantName: t.merchantName,
1917      description: t.description,
1918      date: t.date,
1919      isoCurrencyCode: t.isoCurrencyCode,
1920      logoUrl: t.logoUrl,
1921      source: t.source,
1922      category: t.category,
1923      ytVideos: (t.videoLinks ?? []).map((l) => l.ytVideo),
1924      receipt: t.receipt ?? null,
1925      partnership: t.partnership,
1926      plaidAccount: t.plaidAccount,
1927      classification: t.transactionGroup?.classification ?? null
1928    };
1929  }
1930  let searchInput = state(proxy(page.url.searchParams.get("search") || ""));
1931  let typeFilter = state(proxy(page.url.searchParams.get("type") || "all"));
1932  let accountTypeFilter = state(proxy(page.url.searchParams.get("accountType") || "all"));
1933  let sourceFilter = state(proxy(page.url.searchParams.get("source") || "all"));
1934  let categoryFilter = state(proxy(page.url.searchParams.get("category") || "all"));
1935  let sortField = state(proxy(page.url.searchParams.get("sort") || "date"));
1936  let sortDir = state(proxy(page.url.searchParams.get("dir") || "desc"));
1937  let currentPage = state(proxy(Math.max(1, parseInt(page.url.searchParams.get("page") ?? "1", 10) || 1)));
1938  let debouncedSearch = state(proxy(get(searchInput)));
1939  let searchTimeout = null;
1940  user_effect(() => {
1941    const value = get(searchInput);
1942    if (searchTimeout) clearTimeout(searchTimeout);
1943    searchTimeout = setTimeout(
1944      () => {
1945        set(debouncedSearch, value, true);
1946        set(currentPage, 1);
1947      },
1948      300
1949    );
1950    return () => {
1951      if (searchTimeout) clearTimeout(searchTimeout);
1952    };
1953  });
1954  function buildSearchParams() {
1955    const params = new URLSearchParams();
1956    const allowedSources = /* @__PURE__ */ new Set([
1957      "all",
1958      ...get(accountTypeFilter) === "all" ? ["manual"] : [],
1959      ...($$props.data.plaidAccounts ?? []).filter((acc) => get(accountTypeFilter) === "all" || acc.type === get(accountTypeFilter)).map((acc) => acc.id)
1960    ]);
1961    const validSourceFilter = allowedSources.has(get(sourceFilter)) ? get(sourceFilter) : "all";
1962    if (get(debouncedSearch)) params.set("search", get(debouncedSearch));
1963    if (get(typeFilter) !== "all") params.set("type", get(typeFilter));
1964    if (get(accountTypeFilter) !== "all") params.set("accountType", get(accountTypeFilter));
1965    if (validSourceFilter !== "all") params.set("source", validSourceFilter);
1966    if (get(categoryFilter) !== "all") params.set("category", get(categoryFilter));
1967    if (get(sortField) !== "date") params.set("sort", get(sortField));
1968    if (get(sortDir) !== "desc") params.set("dir", get(sortDir));
1969    if (get(currentPage) >
1969 1) params.set("page", String(get(currentPage)));
1970    return params.toString();
1971  }
1972  const txnResource = cachedResource(() => buildSearchParams(), "/transactions", {
1973    initialValue: {
1974      transactions: $$props.data.transactions,
1975      summary: $$props.data.summary,
1976      uncategorizedTransactions: $$props.data.uncategorizedTransactions,
1977      needsReviewClassifications: $$props.data.needsReviewClassifications,
1978      categories: $$props.data.categories,
1979      plaidAccounts: $$props.data.plaidAccounts ?? [],
1980      assistantBacklog: $$props.data.assistantBacklog ?? null,
1981      totalCount: $$props.data.totalCount,
1982      page: $$props.data.page,
1983      perPage: $$props.data.perPage
1984    }
1985  });
1986  const displayedTransactions = user_derived(() => txnResource.current.transactions);
1987  const summary = user_derived(() => txnResource.current.summary);
1988  const categories = user_derived(() => txnResource.current.categories);
1989  const plaidAccounts = user_derived(() => txnResource.current.plaidAccounts ?? []);
1990  const assistantBacklog = user_derived(() => txnResource.current.assistantBacklog ?? null);
1991  const assistantBacklogSummary = user_derived(() => buildAssistantBacklogSummary(get(assistantBacklog)));
1992  const totalCount = user_derived(() => txnResource.current.totalCount);
1993  const perPage = user_derived(() => txnResource.current.perPage);
1994  const displayedPage = user_derived(() => txnResource.current.page);
1995  user_effect(() => {
1996    const qs = buildSearchParams();
1997    const url = new URL(page.url);
1998    url.search = qs ? `?${qs}` : "";
1999    if (url.toString() !== page.url.toString()) {
2000      history.replaceState(history.state, "", url.toString());
2001    }
2002  });
2003  function updateFilter(key, value) {
2004    if (key === "type") set(typeFilter, value, true);
2005    else if (key === "accountType") {
2006      set(accountTypeFilter, value, true);
2007      set(sourceFilter, "all");
2008    } else if (key === "source") set(sourceFilter, value, true);
2009    else if (key === "category") set(categoryFilter, value, true);
2010    set(currentPage, 1);
2011  }
2012  function toggleSort(field) {
2013    if (get(sortField) === field) {
2014      set(sortDir, get(sortDir) === "desc" ? "asc" : "desc", true);
2015    } else {
2016      set(sortField, field, true);
2017      set(sortDir, "desc");
2018    }
2019    set(currentPage, 1);
2020  }
2021  function goToPage(newPage) {
2022    set(currentPage, newPage, true);
2023  }
2024  let transactionDetailsOpen = state(false);
2025  let selectedTransaction = state(null);
2026  let createManualDialogOpen = state(false);
2027  let transactionType = state("expense");
2028  user_effect(() => {
2029    const amount = createManualTransaction.fields.amount.value();
2030    if (amount && amount !== 0) {
2031      set(transactionType, amount > 0 ? "income" : "expense", true);
2032    }
2033  });
2034  const accountTypeOptions = [
2035    { value: "all", label: "All Accounts" },
2036    { value: "investment", label: "Investment" },
2037    { value: "credit", label: "Credit" },
2038    { value: "depository", label: "Depository" },
2039    { value: "loan", label: "Loan" },
2040    { value: "brokerage", label: "Brokerage" },
2041    { value: "other", label: "Other" }
2042  ];
2043  const filteredPlaidAccounts = user_derived(() => get(accountTypeFilter) !== "all" ? get(plaidAccounts).filter((acc) => acc.type === get(accountTypeFilter)) : get(plaidAccounts));
2044  const sourceOptions = user_derived(() => [
2045    { value: "all", label: "All Sources" },
2046    ...get(accountTypeFilter) === "all" ? [{ value: "manual", label: "Manual" }] : [],
2047    ...get(filteredPlaidAccounts).map((acc) => ({
2048      value: acc.id,
2049      label: `${acc.name}${acc.mask ? ` ••${acc.mask}` : ""}`
2050    }))
2051  ]);
2052  user_effect(() => {
2053    if (!get(sourceOptions).some((option) => option.value === get(sourceFilter))) {
2054      set(sourceFilter, "all");
2055    }
2056  });
2057  const transactionTypeOptions = [
2058    { value: "all", label: "All Types" },
2059    { value: "income", label: "Income" },
2060    { value: "expense", label: "Expense" }
2061  ];
2062  function formatCurrency(amount, currencyCode) {
2063    const num = parseFloat(amount);
2064    return new Intl.NumberFormat("en-US", { style: "currency", currency: currencyCode || "USD" }).format(num);
2065  }
2066  function formatDate(date) {
2067    return new Intl.DateTimeFormat("en-US", { month: "short", day: "
2067numeric", year: "numeric" }).format(new Date(date));
2068  }
2069  function openTransactionDetails(txn) {
2070    set(selectedTransaction, toDialogTransaction(txn), true);
2071    set(transactionDetailsOpen, true);
2072  }
2073  const transactionsWrapper = user_derived(() => ({
2074    get current() {
2075      return get(displayedTransactions).map(toDialogTransaction);
2076    },
2077    loading: txnResource.loading,
2078    mutate(value) {
2079      const prev = txnResource.current;
2080      const byId = new Map(value.map((t) => [t.id, t]));
2081      txnResource.mutate({
2082        ...prev,
2083        transactions: prev.transactions.map((t) => {
2084          const patch = byId.get(t.id);
2085          if (!patch) return t;
2086          return {
2087            ...t,
2088            category: patch.category,
2089            videoLinks: patch.ytVideos.map((v) => ({ id: `dialog-${v.id}`, ytVideo: v })),
2090            partnership: patch.partnership
2091          };
2092        })
2093      });
2094    },
2095    refetch: async () => {
2096      const result = await txnResource.refetch();
2097      return result?.transactions.map(toDialogTransaction);
2098    }
2099  }));
2100  var fragment = root();
2101  var node = first_child(fragment);
2102  {
2103    var consequent = ($$anchor2) => {
2104      Transaction_details_dialog($$anchor2, {
2105        get transaction() {
2106          return get(selectedTransaction);
2107        },
2108        get transactions() {
2109          return get(transactionsWrapper);
2110        },
2111        get open() {
2112          return get(transactionDetailsOpen);
2113        },
2114        set open($$value) {
2115          set(transactionDetailsOpen, $$value, true);
2116        }
2117      });
2118    };
2119    if_block(node, ($$render) => {
2120      if (get(transactionDetailsOpen)) $$render(consequent);
2121    });
2122  }
2123  var node_1 = sibling(node, 2);
2124  component(node_1, () => Dialog, ($$anchor2, Dialog_Root) => {
2125    Dialog_Root($$anchor2, {
2126      get open() {
2127        return get(createManualDialogOpen);
2128      },
2129      set open($$value) {
2130        set(createManualDialogOpen, $$value, true);
2131      },
2132      children: ($$anchor3, $$slotProps) => {
2133        var fragment_2 = comment();
2134        var node_2 = first_child(fragment_2);
2135        component(node_2, () => Dialog_content, ($$anchor4, Dialog_Content) => {
2136          Dialog_Content($$anchor4, {
2137            children: ($$anchor5, $$slotProps2) => {
2138              var fragment_3 = root_3();
2139              var node_3 = first_child(fragment_3);
2140              component(node_3, () => Dialog_header, ($$anchor6, Dialog_Header) => {
2141                Dialog_Header($$anchor6, {
2142                  children: ($$anchor7, $$slotProps3) => {
2143                    var fragment_4 = root_4();
2144                    var node_4 = first_child(fragment_4);
2145                    component(node_4, () => Dialog_title, ($$anchor8, Dialog_Title) => {
2146                      Dialog_Title($$anchor8, {
2147                        children: ($$anchor9, $$slotProps4) => {
2148                          next();
2149                          var text$1 = text("Create Manual Transaction");
2150                          append($$anchor9, text$1);
2151                        },
2152                        $$slots: { default: true }
2153                      });
2154                    });
2155                    var node_5 = sibling(node_4, 2);
2156                    component(node_5, () => Dialog_description, ($$anchor8, Dialog_Description) => {
2157                      Dialog_Description($$anchor8, {
2158                        children: ($$anchor9, $$slotProps4) => {
2159                          next();
2160                          var text_1 = text("Add a manual transaction.");
2161                          append($$anchor9, text_1);
2162                        },
2163                        $$slots: { default: true }
2164                      });
2165                    });
2166                    append($$anchor7, fragment_4);
2167                  },
2168                  $$slots: { default: true }
2169                });
2170              });
2171              var form_1 = sibling(node_3, 2);
2172              attribute_effect(form_1, ($0) => ({ ...$0 }), [
2173                () => createManualTransaction.preflight(CreateManualTransaction).enhance(async ({ form, submit }) => {
2174                  const formData = new FormData(form);
2175                  const optimisticTxn = {
2176                    id: `optimistic-${Date.now()}`,
2177                    type: get(transactionType),
2178                    amount: String(Math.abs(Number(formData.get("amount")) || 0)),
2179                    merchantName: formData.get("merchantName") || null,
2180                    description: formData.get("description") || null,
2181                    date: new Date(formData.get("date") || /* @__PURE__ */ new Date()).toISOString().split("T")[0],
2182                    source: "manual",
2183                    isoCurrencyCode: "USD",
2184                    logoUrl: null,
2185                    category: null,
2186                    videoLinks: [],
2187                    partnership: null,
2188                    createdAt: /* @__PURE__ */ new Date(),
2189                    updatedAt: /* @__PURE__ */ new Date(),
2190                    organizationId: "",
2191                    partnershipId: null,
2192                    categoryId: null,
2193                    plaidAccountId: null,
2194                    plaidTransactionId: null,
2195                    plaidAccount: null
2196                  };
2197                  set(createManualDialogOpen, false);
2198                  const prev = txnResource.current;
2199                  txnResource.mutate({
2200                    ...prev,
2201                    transactions: [optimisticTxn, ...prev.transactions],
2202                    totalCount: prev.totalCount + 1
2203                  });
2204                  try {
2205                    await submit();
2206                    if (createManualTransaction.result?.success) {
2207                      form.reset();
2208                      set(transactionType, "expense");
2209                      toast.success("Transaction created.");
2210                      txnResource.refetch();
2211                    }
2212                  } catch (error) {
2213                    set(createManualDialogOpen, true);
2214                    txnResource.mutate(prev);
2215                    toast.error(error instanceof Error ? error.message : String(error));
2216                  }
2217                })
2218              ]);
2219              var node_6 = child(form_1);
2220              component(node_6, () => Field_group, ($$anchor6, Field_Group) => {
2221                Field_Group($$anchor6, {
2222                  children: ($$anchor7, $$slotProps3) => {
2223                    var fragment_5 = root_7();
2224                    var node_7 = first_child(fragment_5);
2225                    component(node_7, () => Field, ($$anchor8, Field_Field) => {
2226                      Field_Field($$anchor8, {
2227                        children: ($$anchor9, $$slotProps4) => {
2228                          var fragment_6 = root_8();
2229                          var node_8 = first_child(fragment_6);
2230                          component(node_8, () => Field_label, ($$anchor10, Field_Label) => {
2231                            Field_Label($$anchor10, {
2232                              for: "merchantName",
2233                              children: ($$anchor11, $$slotProps5) => {
2234                                next();
2235                                var text_2 = text("Merchant Name (optional)");
2236                                append($$anchor11, text_2);
2237                              },
2238                              $$slots: { default: true }
2239                            });
2240                          });
2241                          var node_9 = sibling(node_8, 2);
2242                          {
2243                            let $0 = user_derived(() => createManualTransaction.fields.merchantName.as("text"));
2244                            Input(node_9, spread_props(
2245                              {
2246                                id: "merchantName",
2247                                placeholder: "e.g. Apple, Amazon, Starbucks..."
2248                              },
2249                              () => get($0)
2250                            ));
2251                          }
2252                          append($$anchor9, fragment_6);
2253                        },
2254                        $$slots: { default: true }
2255                      });
2256                    });
2257                    var node_10 = sibling(node_7, 2);
2258                    component(node_10, () => Field, ($$anchor8, Field_Field_1) => {
2259                      Field_Field_1($$anchor8, {
2260                        children: ($$anchor9, $$slotProps4) => {
2261                          var fragment_7 = root_10();
2262                          var node_11 = first_child(fragment_7);
2263                          component(node_11, () => Field_label, ($$anchor10, Field_Label_1) => {
2264                            Field_Label_1($$anchor10, {
2265                              for: "description",
2266                              children: ($$anchor11, $$slotProps5) => {
2267                                next();
2268                                var text_3 = text("Description");
2269                                append($$anchor11, text_3);
2270                              },
2271                              $$slots: { default: true }
2272                            });
2273                          });
2274                          var node_12 = sibling(node_11, 2);
2275                          {
2276                            let $0 = user_derived(() => createManualTransaction.fields.description.as("text"));
2277                            Input(node_12, spread_props(
2278                              {
2279                                id: "description",
2280                                placeholder: "e.g. Freelance payment, Software subscription..."
2281                              },
2282                              () => get($0)
2283                            ));
2284                          }
2285                          var node_13 = sibling(node_12, 2);
2286                          each(node_13, 17, () => createManualTransaction.fields.description.issues(), index, ($$anchor10, issue) => {
2287                            var fragment_8 = comment();
2288                            var node_14 = first_child(fragment_8);
2289                            component(node_14, () => Field_error, ($$anchor11, Field_Error) => {
2290                              Field_Error($$anchor11, {
2291                                children: ($$anchor12, $$slotProps5) => {
2292                                  next();
2293                                  var text_4 = text();
2294                                  template_effect(() => set_text(text_4, get(issue).message));
2295                                  append($$anchor12, text_4);
2296                                },
2297                                $$slots: { default: true }
2298                              });
2299                            });
2300                            append($$anchor10, fragment_8);
2301                          });
2302                          append($$anchor9, fragment_7);
2303                        },
2304                        $$slots: { default: true }
2305                      });
2306                    });
2307                    var node_15 = sibling(node_10, 2);
2308                    component(node_15, () => Field, ($$anchor8, Field_Field_2) => {
2309                      Field_Field_2($$anchor8, {
2310                        children: ($$anchor9, $$slotProps4) => {
2311                          var fragment_10 = root_14();
2312                          var node_16 = first_child(fragment_10);
2313                          component(node_16, () => Field_label, ($$anchor10, Field_Label_2) => {
2314                            Field_Label_2($$anchor10, {
2315                              for: "date",
2316                              children: ($$anchor11, $$slotProps5) => {
2317                                next();
2318                                var text_5 = text("Date");
2319                                append($$anchor11, text_5);
2320                              },
2321                              $$slots: { default: true }
2322                            });
2323                          });
2324                          var node_17 = sibling(node_16, 2);
2325                          {
2326                            let $0 = user_derived(() => createManualTransaction.fields.date.as("text"));
2327                            Input(node_17, spread_props({ id: "date", type: "date" }, () => get($0)));
2328                          }
2329                          var node_18 = sibling(node_17, 2);
2330                          each(node_18, 17, () => createManualTransaction.fields.date.issues(), index, ($$anchor10, issue) => {
2331                            var fragment_11 = comment();
2332                            var node_19 = first_child(fragment_11);
2333                            component(node_19, () => Field_error, ($$anchor11, Field_Error_1) => {
2334                              Field_Error_1($$anchor11, {
2335                                children: ($$anchor12, $$slotProps5) => {
2336                                  next();
2337                                  var text_6 = text();
2338                                  template_effect(() => set_text(text_6, get(issue).message));
2339                                  append($$anchor12, text_6);
2340                                },
2341                                $$slots: { default: true }
2342                              });
2343                            });
2344                            append($$anchor10, fragment_11);
2345                          });
2346                          append($$anchor9, fragment_10);
2347                        },
2348                        $$slots: { default: true }
2349                      });
2350                    });
2351                    var node_20 = sibling(node_15, 2);
2352                    component(node_20, () => Field, ($$anchor8, Field_Field_3) => {
2353                      Field_Field_3($$anchor8, {
2354                        children: ($$anchor9, $$slotProps4) => {
2355                          var fragment_13 = root_18();
2356                          var node_21 = first_child(fragment_13);
2357                          component(node_21, () => Field_label, ($$anchor10, Field_Label_3) => {
2358                            Field_Label_3($$anchor10, {
2359                              for: "amount",
2360                              children: ($$anchor11, $$slotProps5) => {
2361                                next();
2362                                var text_7 = text("Type & Amount");
2363                                append($$anchor11, text_7);
2364                              },
2365                              $$slots: { default: true }
2366                            });
2367                          });
2368                          var div = sibling(node_21, 2);
2369                          var node_22 = child(div);
2370                          component(node_22, () => Toggle_group, ($$anchor10, ToggleGroup_Root) => {
2371                            ToggleGroup_Root($$anchor10, {
2372                              type: "single",
2373                              variant: "outline",
2374                              get value() {
2375                                return get(transactionType);
2376                              },
2377                              onValueChange: (v) => {
2378                                if (v) set(transactionType, v, true);
2379                              },
2380                              children: ($$anchor11, $$slotProps5) => {
2381                                var fragment_14 = root_20();
2382                                var node_23 = first_child(fragment_14);
2383                                component(node_23, () => Toggle_group_item, ($$anchor12, ToggleGroup_Item) => {
2384                                  ToggleGroup_Item($$anchor12, {
2385                                    value: "income",
2386                                    class: "hover:bg-green-50 hover:text-green-700 data-[state=on]:border-green-500 data-[state=on]:bg-green-50 data-[state=on]:text-green-700 dark:hover:bg-green-900/20 dark:hover:text-green-400 dark:data-[state=on]:bg-green-900/20 dark:data-[state=on]:text-green-400",
2387                                    children: ($$anchor13, $$slotProps6) => {
2388                                      var fragment_15 = root_21();
2389                                      var node_24 = first_child(fragment_15);
2390                                      Arrow_down_left(node_24, { class: "h-4 w-4" });
2391                                      next();
2392                                      append($$anchor13, fragment_15);
2393                                    },
2394                                    $$slots: { default: true }
2395                                  });
2396                                });
2397                                var node_25 = sibling(node_23, 2);
2398                                component(node_25, () => Toggle_group_item, ($$anchor12, ToggleGroup_Item_1) => {
2399                                  ToggleGroup_Item_1($$anchor12, {
2400                                    value: "expense",
2401                                    class: "hover:bg-muted hover:text-foreground data-[state=on]:border-foreground data-[state=on]:bg-muted data-[state=on]:text-foreground",
2402                                    children: ($$anchor13, $$slotProps6) => {
2403                                      var fragment_16 = root_22();
2404                                      var node_26 = first_child(fragment_16);
2405                                      Arrow_up_right(node_26, { class: "h-4 w-4" });
2406                                      next();
2407                                      append($$anchor13, fragment_16);
2408                                    },
2409                                    $$slots: { default: true }
2410                                  });
2411                                });
2412                                append($$anchor11, fragment_14);
2413                              },
2414                              $$slots: { default: true }
2415                            });
2416                          });
2417                          var node_27 = sibling(node_22, 2);
2418                          component(node_27, () => Input_group, ($$anchor10, InputGroup_Root) => {
2419                            InputGroup_Root($$anchor10, {
2420                              class: "flex-1",
2421                              children: ($$anchor11, $$slotProps5) => {
2422                                var fragment_17 = root_23();
2423                                var node_28 = first_child(fragment_17);
2424                                component(node_28, () => Input_group_addon, ($$anchor12, InputGroup_Addon) => {
2425                                  InputGroup_Addon($$anchor12, {
2426                                    children: ($$anchor13, $$slotProps6) => {
2427                                      var fragment_18 = comment();
2428                                      var node_29 = first_child(fragment_18);
2429                                      component(node_29, () => Input_group_text, ($$anchor14, InputGroup_Text) => {
2430                                        InputGroup_Text($$anchor14, {
2431                                          children: ($$anchor15, $$slotProps7) => {
2432                                            next();
2433                                            var text_8 = text("$");
2434                                            append($$anchor15, text_8);
2435                                          },
2436                                          $$slots: { default: true }
2437                                        });
2438                                      });
2439                                      append($$anchor13, fragment_18);
2440                                    },
2441                                    $$slots: { default: true }
2442                                  });
2443                                });
2444                                var node_30 = sibling(node_28, 2);
2445                                {
2446                                  let $0 = user_derived(() => createManualTransaction.fields.amount.as("number"));
2447                                  component(node_30, () => Input_group_input, ($$anchor12, InputGroup_Input) => {
2448                                    InputGroup_Input($$anchor12, spread_props({ id: "amount", step: "0.01", placeholder: "e.g. 100 or -50" }, () => get($0)));
2449                                  });
2450                                }
2451                                append($$anchor11, fragment_17);
2452                              },
2453                              $$slots: { default: true }
2454                            });
2455                          });
2456                          reset(div);
2457                          var input = sibling(div, 2);
2458                          remove_input_defaults(input);
2459                          var node_31 = sibling(input, 2);
2460                          each(node_31, 17, () => createManualTransaction.fields.amount.issues(), index, ($$anchor10, issue) => {
2461                            var fragment_19 = comment();
2462                            var node_32 = first_child(fragment_19);
2463                            component(node_32, () =>
2463 Field_error, ($$anchor11, Field_Error_2) => {
2464                              Field_Error_2($$anchor11, {
2465                                children: ($$anchor12, $$slotProps5) => {
2466                                  next();
2467                                  var text_9 = text();
2468                                  template_effect(() => set_text(text_9, get(issue).message));
2469                                  append($$anchor12, text_9);
2470                                },
2471                                $$slots: { default: true }
2472                              });
2473                            });
2474                            append($$anchor10, fragment_19);
2475                          });
2476                          template_effect(() => set_value(input, get(transactionType)));
2477                          append($$anchor9, fragment_13);
2478                        },
2479                        $$slots: { default: true }
2480                      });
2481                    });
2482                    append($$anchor7, fragment_5);
2483                  },
2484                  $$slots: { default: true }
2485                });
2486              });
2487              var node_33 = sibling(node_6, 2);
2488              component(node_33, () => Dialog_footer, ($$anchor6, Dialog_Footer) => {
2489                Dialog_Footer($$anchor6, {
2490                  class: "pt-6",
2491                  children: ($$anchor7, $$slotProps3) => {
2492                    {
2493                      let $0 = user_derived(() => !!createManualTransaction.pending);
2494                      Button($$anchor7, {
2495                        get loading() {
2496                          return get($0);
2497                        },
2498                        type: "submit",
2499                        children: ($$anchor8, $$slotProps4) => {
2500                          next();
2501                          var text_10 = text("Create Transaction");
2502                          append($$anchor8, text_10);
2503                        },
2504                        $$slots: { default: true }
2505                      });
2506                    }
2507                  },
2508                  $$slots: { default: true }
2509                });
2510              });
2511              reset(form_1);
2512              append($$anchor5, fragment_3);
2513            },
2514            $$slots: { default: true }
2515          });
2516        });
2517        append($$anchor3, fragment_2);
2518      },
2519      $$slots: { default: true }
2520    });
2521  });
2522  var div_1 = sibling(node_1, 2);
2523  var div_2 = child(div_1);
2524  var node_34 = sibling(child(div_2), 2);
2525  Button(node_34, {
2526    onclick: () => set(createManualDialogOpen, true),
2527    children: ($$anchor2, $$slotProps) => {
2528      var fragment_22 = root_30();
2529      var node_35 = first_child(fragment_22);
2530      Plus(node_35, { class: "h-4 w-4" });
2531      next();
2532      append($$anchor2, fragment_22);
2533    },
2534    $$slots: { default: true }
2535  });
2536  reset(div_2);
2537  var node_36 = sibling(div_2, 2);
2538  {
2539    var consequent_1 = ($$anchor2) => {
2540      var div_3 = root_31();
2541      var node_37 = child(div_3);
2542      component(node_37, () => Card, ($$anchor3, Card_Root) => {
2543        Card_Root($$anchor3, {
2544          children: ($$anchor4, $$slotProps) => {
2545            var fragment_23 = root_32();
2546            var node_38 = first_child(fragment_23);
2547            component(node_38, () => Card_header, ($$anchor5, Card_Header) => {
2548              Card_Header($$anchor5, {
2549                class: "pb-2",
2550                children: ($$anchor6, $$slotProps2) => {
2551                  var fragment_24 = root_33();
2552                  var div_4 = first_child(fragment_24);
2553                  var div_5 = child(div_4);
2554                  var node_39 = child(div_5);
2555                  Arrow_down_left(node_39, { class: "h-4 w-4 text-green-600 dark:text-green-400" });
2556                  reset(div_5);
2557                  var node_40 = sibling(div_5, 2);
2558                  component(node_40, () => Card_description, ($$anchor7, Card_Description) => {
2559                    Card_Description($$anchor7, {
2560                      children: ($$anchor8, $$slotProps3) => {
2561                        next();
2562                        var text_11 = text("Total Income");
2563                        append($$anchor8, text_11);
2564                      },
2565                      $$slots: { default: true }
2566                    });
2567                  });
2568                  reset(div_4);
2569                  var node_41 = sibling(div_4, 2);
2570                  component(node_41, () =>
2570 Card_title, ($$anchor7, Card_Title) => {
2571                    Card_Title($$anchor7, {
2572                      class: "text-xl",
2573                      children: ($$anchor8, $$slotProps3) => {
2574                        next();
2575                        var text_12 = text();
2576                        template_effect(($0) => set_text(text_12, $0), [
2577                          () => formatCurrency(get(summary).totalIncome.toString(), "USD")
2578                        ]);
2579                        append($$anchor8, text_12);
2580                      },
2581                      $$slots: { default: true }
2582                    });
2583                  });
2584                  append($$anchor6, fragment_24);
2585                },
2586                $$slots: { default: true }
2587              });
2588            });
2589            var node_42 = sibling(node_38, 2);
2590            component(node_42, () => Card_content, ($$anchor5, Card_Content) => {
2591              Card_Content($$anchor5, {
2592                children: ($$anchor6, $$slotProps2) => {
2593                  var p_1 = root_36();
2594                  append($$anchor6, p_1);
2595                },
2596                $$slots: { default: true }
2597              });
2598            });
2599            append($$anchor4, fragment_23);
2600          },
2601          $$slots: { default: true }
2602        });
2603      });
2604      var node_43 = sibling(node_37, 2);
2605      component(node_43, () => Card, ($$anchor3, Card_Root_1) => {
2606        Card_Root_1($$anchor3, {
2607          children: ($$anchor4, $$slotProps) => {
2608            var fragment_26 = root_37();
2609            var node_44 = first_child(fragment_26);
2610            component(node_44, () => Card_header, ($$anchor5, Card_Header_1) => {
2611              Card_Header_1($$anchor5, {
2612                class: "pb-2",
2613                children: ($$anchor6, $$slotProps2) => {
2614                  var fragment_27 = root_38();
2615                  var div_6 = first_child(fragment_27);
2616                  var div_7 = child(div_6);
2617                  var node_45 = child(div_7);
2618                  Arrow_up_right(node_45, { class: "h-4 w-4 text-foreground" });
2619                  reset(div_7);
2620                  var node_46 = sibling(div_7, 2);
2621                  component(node_46, () => Card_description, ($$anchor7, Card_Description_1) => {
2622                    Card_Description_1($$anchor7, {
2623                      children: ($$anchor8, $$slotProps3) => {
2624                        next();
2625                        var text_13 = text("Total Expenses");
2626                        append($$anchor8, text_13);
2627                      },
2628                      $$slots: { default: true }
2629                    });
2630                  });
2631                  reset(div_6);
2632                  var node_47 = sibling(div_6, 2);
2633                  component(node_47, () => Card_title, ($$anchor7, Card_Title_1) => {
2634                    Card_Title_1($$anchor7, {
2635                      class: "text-xl",
2636                      children: ($$anchor8, $$slotProps3) => {
2637                        next();
2638                        var text_14 = text();
2639                        template_effect(($0) => set_text(text_14, $0), [
2640                          () => formatCurrency(get(summary).totalExpenses.toString(), "USD")
2641                        ]);
2642                        append($$anchor8, text_14);
2643                      },
2644                      $$slots: { default: true }
2645                    });
2646                  });
2647                  append($$anchor6, fragment_27);
2648                },
2649                $$slots: { default: true }
2650              });
2651            });
2652            var node_48 = sibling(node_44, 2);
2653            component(node_48, () => Card_content, ($$anchor5, Card_Content_1) => {
2654              Card_Content_1($$anchor5, {
2655                children: ($$anchor6, $$slotProps2) => {
2656                  var p_2 = root_41();
2657                  append($$anchor6, p_2);
2658                },
2659                $$slots: { default: true }
2660              });
2661            });
2662            append($$anchor4, fragment_26);
2663          },
2664          $$slots: { default: true }
2665        });
2666      });
2667      var node_49 = sibling(node_43, 2);
2668      component(node_49, () => Card, ($$anchor3, Card_Root_2) => {
2669        Card_Root_2($$anchor3, {
2670          children: ($$anchor4, $$slotProps) => {
2671            var fragment_29 = comment();
2672            var node_50 = first_child(fragment_29);
2673            component(node_50, () => Card_header, ($$anchor5, Card_Header_2) => {
2674              Card_Header_2($$anchor5, {
2675                class: "pb-2",
2676                children: ($$anchor6, $$slotProps2) => {
2677                  var fragment_30 = root_43();
2678                  var div_8 = first_child(fragment_30);
2679                  var div_9 = child(div_8);
2680                  var node_51 = child(div_9);
2681                  Trending_up(node_51, { class: "h-4 w-4 text-green-600 dark:text-green-400" });
2682                  reset(div_9);
2683                  var node_52 = sibling(div_9, 2);
2684                  component(node_52, () => Card_description, ($$anchor7, Card_Description_2) => {
2685                    Card_Description_2($$anchor7, {
2686                      children: ($$anchor8, $$slotProps3) => {
2687                        next();
2688                        var text_15 = text("Net");
2689                        append($$anchor8, text_15);
2690                      },
2691                      $$slots: { default: true }
2692                    });
2693                  });
2694                  reset(div_8);
2695                  var node_53 = sibling(div_8, 2);
2696                  component(node_53, () =>
2696 Card_title, ($$anchor7, Card_Title_2) => {
2697                    Card_Title_2($$anchor7, {
2698                      class: "text-xl",
2699                      children: ($$anchor8, $$slotProps3) => {
2700                        next();
2701                        var text_16 = text();
2702                        template_effect(($0) => set_text(text_16, $0), [
2703                          () => formatCurrency(get(summary).netIncome.toString(), "USD")
2704                        ]);
2705                        append($$anchor8, text_16);
2706                      },
2707                      $$slots: { default: true }
2708                    });
2709                  });
2710                  append($$anchor6, fragment_30);
2711                },
2712                $$slots: { default: true }
2713              });
2714            });
2715            append($$anchor4, fragment_29);
2716          },
2717          $$slots: { default: true }
2718        });
2719      });
2720      reset(div_3);
2721      append($$anchor2, div_3);
2722    };
2723    if_block(node_36, ($$render) => {
2724      if (get(summary).hasAnyTransactions) $$render(consequent_1);
2725    });
2726  }
2727  var node_54 = sibling(node_36, 2);
2728  {
2729    var consequent_2 = ($$anchor2) => {
2730      var fragment_32 = comment();
2731      var node_55 = first_child(fragment_32);
2732      component(node_55, () => Empty, ($$anchor3, Empty_Root) => {
2733        Empty_Root($$anchor3, {
2734          children: ($$anchor4, $$slotProps) => {
2735            var fragment_33 = root_47();
2736            var node_56 = first_child(fragment_33);
2737            component(node_56, () => Empty_media, ($$anchor5, Empty_Media) => {
2738              Empty_Media($$anchor5, {
2739                variant: "icon",
2740                children: ($$anchor6, $$slotProps2) => {
2741                  Receipt($$anchor6, {});
2742                },
2743                $$slots: { default: true }
2744              });
2745            });
2746            var node_57 = sibling(node_56, 2);
2747            component(node_57, () => Empty_content, ($$anchor5, Empty_Content) => {
2748              Empty_Content($$anchor5, {
2749                children: ($$anchor6, $$slotProps2) => {
2750                  var fragment_35 = root_49();
2751                  var node_58 = first_child(fragment_35);
2752                  component(node_58, () =>
2752 Empty_title, ($$anchor7, Empty_Title) => {
2753                    Empty_Title($$anchor7, {
2754                      children: ($$anchor8, $$slotProps3) => {
2755                        next();
2756                        var text_17 = text("No transactions yet");
2757                        append($$anchor8, text_17);
2758                      },
2759                      $$slots: { default: true }
2760                    });
2761                  });
2762                  var node_59 = sibling(node_58, 2);
2763                  component(node_59, () => Empty_description, ($$anchor7, Empty_Description) => {
2764                    Empty_Description($$anchor7, {
2765                      children: ($$anchor8, $$slotProps3) => {
2766                        next();
2767                        var text_18 = text("Link a bank account or add a manual entry. Once transactions arrive, the assistant will\n					categorize them and only surface exceptions in chat.");
2768                        append($$anchor8, text_18);
2769                      },
2770                      $$slots: { default: true }
2771                    });
2772                  });
2773                  append($$anchor6, fragment_35);
2774                },
2775                $$slots: { default: true }
2776              });
2777            });
2778            append($$anchor4, fragment_33);
2779          },
2780          $$slots: { default: true }
2781        });
2782      });
2783      append($$anchor2, fragment_32);
2784    };
2785    var alternate_7 = ($$anchor2) => {
2786      var div_10 = root_52();
2787      var node_60 = child(div_10);
2788      {
2789        var consequent_3 = ($$anchor3) => {
2790          var fragment_36 = comment();
2791          var node_61 = first_child(fragment_36);
2792          component(node_61, () => Alert, ($$anchor4, Alert_Root) => {
2793            Alert_Root($$anchor4, {
2794              children: ($$anchor5, $$slotProps) => {
2795                var fragment_37 = root_54();
2796                var node_62 = first_child(fragment_37);
2797                Brain_circuit(node_62, { class: "h-4 w-4" });
2798                var node_63 = sibling(node_62, 2);
2799                component(node_63, () => Alert_title, ($$anchor6, Alert_Title) => {
2800                  Alert_Title($$anchor6, {
2801                    children: ($$anchor7, $$slotProps2) => {
2802                      next();
2803                      var text_19 = text();
2804                      template_effect(() => set_text(text_19, get(assistantBacklogSummary).title));
2805                      append($$anchor7, text_19);
2806                    },
2807                    $$slots: { default: true }
2808                  });
2809                });
2810                var node_64 = sibling(node_63, 2);
2811                component(node_64, () => Alert_description, ($$anchor6, Alert_Description) => {
2812                  Alert_Description($$anchor6, {
2813                    children: ($$anchor7, $$slotProps2) => {
2814                      var fragment_39 = root_56();
2815                      var p_3 = first_child(fragment_39);
2816                      var text_20 = child(p_3, true);
2817                      reset(p_3);
2818                      var div_11 = sibling(p_3, 2);
2819                      var node_65 = child(div_11);
2820                      Badge(node_65, {
2821                        variant: "secondary",
2822                        children: ($$anchor8, $$slotProps3) => {
2823                          next();
2824                          var text_21 = text();
2825                          template_effect(() => set_text(text_21, get(assistantBacklogSummary).countLabel));
2826                          append($$anchor8, text_21);
2827                        },
2828                        $$slots: { default: true }
2829                      });
2830                      reset(div_11);
2831                      template_effect(() => set_text(text_20, get(assistantBacklogSummary).description));
2832                      append($$anchor7, fragment_39);
2833                    },
2834                    $$slots: { default: true }
2835                  });
2836                });
2837                append($$anchor5, fragment_37);
2838              },
2839              $$slots: { default: true }
2840            });
2841          });
2842          append($$anchor3, fragment_36);
2843        };
2844        if_block(node_60, ($$render) => {
2845          if (get(assistantBacklogSummary)) $$render(consequent_3);
2846        });
2847      }
2848      var div_12 = sibling(node_60, 2);
2849      var node_66 = child(div_12);
2850      component(node_66, () => Select, ($$anchor3, Select_Root) => {
2851        Select_Root($$anchor3, {
2852          type: "single",
2853          get value() {
2854            return get(accountTypeFilter);
2855          },
2856          onValueChange: (value) => updateFilter("accountType", value),
2857          children: ($$anchor4, $$slotProps) => {
2858            var fragment_41 = root_58();
2859            var node_67 = first_child(fragment_41);
2860            component(node_67, () => Select_trigger, ($$anchor5, Select_Trigger) => {
2861              Select_Trigger($$anchor5, {
2862                class: "w-40",
2863                children: ($$anchor6, $$slotProps2) => {
2864                  next();
2865                  var text_22 = text();
2866                  template_effect(($0) => set_text(text_22, $0), [
2867                    () => accountTypeOptions.find((o) => o.value === get(accountTypeFilter))?.label || "All Accounts"
2868                  ]);
2869                  append($$anchor6, text_22);
2870                },
2871                $$slots: { default: true }
2872              });
2873            });
2874            var node_68 = sibling(node_67, 2);
2875            component(node_68, () => Select_content, ($$anchor5, Select_Content) => {
2876              Select_Content($$anchor5, {
2877                children: ($$anchor6, $$slotProps2) => {
2878                  var fragment_43 = comment();
2879                  var node_69 = first_child(fragment_43);
2880                  each(node_69, 17, () => accountTypeOptions, (option) => option.value, ($$anchor7, option) => {
2881                    var fragment_44 = comment();
2882                    var node_70 = first_child(fragment_44);
2883                    component(node_70, () => Select_item, ($$anchor8, Select_Item) => {
2884                      Select_Item($$anchor8, {
2885                        get value() {
2886                          return get(option).value;
2887                        },
2888                        children: ($$anchor9, $$slotProps3) => {
2889                          next();
2890                          var text_23 = text();
2891                          template_effect(() => set_text(text_23, get(option).label));
2892                          append($$anchor9, text_23);
2893                        },
2894                        $$slots: { default: true }
2895                      });
2896                    });
2897                    append($$anchor7, fragment_44);
2898                  });
2899                  append($$anchor6, fragment_43);
2900                },
2901                $$slots: { default: true }
2902              });
2903            });
2904            append($$anchor4, fragment_41);
2905          },
2906          $$slots: { default: true }
2907        });
2908      });
2909      var node_71 = sibling(node_66, 2);
2910      component(node_71, () => Select, ($$anchor3, Select_Root_1) => {
2911        Select_Root_1($$anchor3, {
2912          type: "single",
2913          get value() {
2914            return get(sourceFilter);
2915          },
2916          onValueChange: (value) => updateFilter("source", value),
2917          children: ($$anchor4, $$slotProps) => {
2918            var fragment_46 = root_63();
2919            var node_72 = first_child(fragment_46);
2920            component(node_72, () => Select_trigger, ($$anchor5, Select_Trigger_1) => {
2921              Select_Trigger_1($$anchor5, {
2922                class: "w-48",
2923                children: ($$anchor6, $$slotProps2) => {
2924                  var span = root_64();
2925                  var text_24 = child(span, true);
2926                  reset(span);
2927                  template_effect(($0) => set_text(text_24, $0), [
2928                    () => get(sourceOptions).find((o) => o.value === get(sourceFilter))?.label || "All Sources"
2929                  ]);
2930                  append($$anchor6, span);
2931                },
2932                $$slots: { default: true }
2933              });
2934            });
2935            var node_73 = sibling(node_72, 2);
2936            component(node_73, () => Select_content, ($$anchor5, Select_Content_1) => {
2937              Select_Content_1($$anchor5, {
2938                children: ($$anchor6, $$slotProps2) => {
2939                  var fragment_47 = comment();
2940                  var node_74 = first_child(fragment_47);
2941                  each(node_74, 17, () => get(sourceOptions), (option) => option.value, ($$anchor7, option) => {
2942                    var fragment_48 = comment();
2943                    var node_75 = first_child(fragment_48);
2944                    component(node_75, () => Select_item, ($$anchor8, Select_Item_1) => {
2945                      Select_Item_1($$anchor8, {
2946                        get value() {
2947                          return get(option).value;
2948                        },
2949                        children: ($$anchor9, $$slotProps3) => {
2950                          next();
2951                          var text_25 = text();
2952                          template_effect(() => set_text(text_25, get(option).label));
2953                          append($$anchor9, text_25);
2954                        },
2955                        $$slots: { default: true }
2956                      });
2957                    });
2958                    append($$anchor7, fragment_48);
2959                  });
2960                  append($$anchor6, fragment_47);
2961                },
2962                $$slots: { default: true }
2963              });
2964            });
2965            append($$anchor4, fragment_46);
2966          },
2967          $$slots: { default: true }
2968        });
2969      });
2970      var node_76 = sibling(node_71, 2);
2971      component(node_76, () => Select, ($$anchor3, Select_Root_2) => {
2972        Select_Root_2($$anchor3, {
2973          type: "single",
2974          get value() {
2975            return get(typeFilter);
2976          },
2977          onValueChange: (value) => updateFilter("type", value),
2978          children: ($$anchor4, $$slotProps) => {
2979            var fragment_50 = root_68();
2980            var node_77 = first_child(fragment_50);
2981            component(node_77, () => Select_trigger, ($$anchor5, Select_Trigger_2) => {
2982              Select_Trigger_2($$anchor5, {
2983                class: "w-32",
2984                children: ($$anchor6, $$slotProps2) => {
2985                  next();
2986                  var text_26 = text();
2987                  template_effect(($0) => set_text(text_26, $0), [
2988                    () => transactionTypeOptions.find((o) => o.value === get(typeFilter))?.label || "All Types"
2989                  ]);
2990                  append($$anchor6, text_26);
2991                },
2992                $$slots: { default: true }
2993              });
2994            });
2995            var node_78 = sibling(node_77, 2);
2996            component(node_78, () => Select_content, ($$anchor5, Select_Content_2) => {
2997              Select_Content_2($$anchor5, {
2998                children: ($$anchor6, $$slotProps2) => {
2999                  var fragment_52 = comment();
3000                  var node_79 = first_child(fragment_52);
3001                  each(node_79, 17, () => transactionTypeOptions, (option) => option.value, ($$anchor7, option) => {
3002                    var fragment_53 = comment();
3003                    var node_80 = first_child(fragment_53);
3004                    component(node_80, () => Select_item, ($$anchor8, Select_Item_2) => {
3005                      Select_Item_2($$anchor8, {
3006                        get value() {
3007                          return get(option).value;
3008                        },
3009                        children: ($$anchor9, $$slotProps3) => {
3010                          next();
3011                          var text_27 = text();
3012                          template_effect(() => set_text(text_27, get(option).label));
3013                          append($$anchor9, text_27);
3014                        },
3015                        $$slots: { default: true }
3016                      });
3017                    });
3018                    append($$anchor7, fragment_53);
3019                  });
3020                  append($$anchor6, fragment_52);
3021                },
3022                $$slots: { default: true }
3023              });
3024            });
3025            append($$anchor4, fragment_50);
3026          },
3027          $$slots: { default: true }
3028        });
3029      });
3030      var node_81 = sibling(node_76, 2);
3031      component(node_81, () => Select, ($$anchor3, Select_Root_3) => {
3032        Select_Root_3($$anchor3, {
3033          type: "single",
3034          get value() {
3035            return get(categoryFilter);
3036          },
3037          onValueChange: (value) => updateFilter("category", value),
3038          children: ($$anchor4, $$slotProps) => {
3039            var fragment_55 = root_73();
3040            var node_82 = first_child(fragment_55);
3041            component(node_82, () => Select_trigger, ($$anchor5, Select_Trigger_3) => {
3042              Select_Trigger_3($$anchor5, {
3043                class: "w-40",
3044                children: ($$anchor6, $$slotProps2) => {
3045                  next();
3046                  var text_28 = text();
3047                  template_effect(($0) => set_text(text_28, $0), [
3048                    () => get(categoryFilter) === "all" ? "All Categories" : get(categoryFilter) === "uncategorized" ? "Uncategorized" : get(categories).find((c) => c.id === get(categoryFilter))?.name || "All Categories"
3049                  ]);
3050                  append($$anchor6, text_28);
3051                },
3052                $$slots: { default: true }
3053              });
3054            });
3055            var node_83 = sibling(node_82, 2);
3056            component(node_83, () => Select_content, ($$anchor5, Select_Content_3) => {
3057              Select_Content_3($$anchor5, {
3058                children: ($$anchor6, $$slotProps2) => {
3059                  var fragment_57 = root_75();
3060                  var node_84 = first_child(fragment_57);
3061                  component(node_84, () => Select_item, ($$anchor7, Select_Item_3) => {
3062                    Select_Item_3($$anchor7, {
3063                      value: "all",
3064                      children: ($$anchor8, $$slotProps3) => {
3065                        next();
3066                        var text_29 = text("All Categories");
3067                        append($$anchor8, text_29);
3068                      },
3069                      $$slots: { default: true }
3070                    });
3071                  });
3072                  var node_85 = sibling(node_84, 2);
3073                  component(node_85, () => Select_item, ($$anchor7, Select_Item_4) => {
3074                    Select_Item_4($$anchor7, {
3075                      value: "uncategorized",
3076                      children: ($$anchor8, $$slotProps3) => {
3077                        next();
3078                        var text_30 = text("Uncategorized");
3079                        append($$anchor8, text_30);
3080                      },
3081                      $$slots: { default: true }
3082                    });
3083                  });
3084                  var node_86 = sibling(node_85, 2);
3085                  each(node_86, 17, () => get(categories), (category) => category.id, ($$anchor7, category) => {
3086                    var fragment_58 = comment();
3087                    var node_87 = first_child(fragment_58);
3088                    component(node_87, () => Select_item, ($$anchor8, Select_Item_5) => {
3089                      Select_Item_5($$anchor8, {
3090                        get value() {
3091                          return get(category).id;
3092                        },
3093                        children: ($$anchor9, $$slotProps3) => {
3094                          next();
3095                          var text_31 = text();
3096                          template_effect(() => set_text(text_31, get(category).name));
3097                          append($$anchor9, text_31);
3098                        },
3099                        $$slots: { default: true }
3100                      });
3101                    });
3102                    append($$anchor7, fragment_58);
3103                  });
3104                  append($$anchor6, fragment_57);
3105                },
3106                $$slots: { default: true }
3107              });
3108            });
3109            append($$anchor4, fragment_55);
3110          },
3111          $$slots: { default: true }
3112        });
3113      });
3114      var div_13 = sibling(node_81, 2);
3115      var node_88 = child(div_13);
3116      Search(node_88, {
3117        class: "absolute top-1/2 left-3 h-4 w-4 -translate-y-1/2 text-muted-foreground"
3118      });
3119      var node_89 =
3119 sibling(node_88, 2);
3120      Input(node_89, {
3121        type: "text",
3122        placeholder: "Search transactions...",
3123        class: "w-64 pl-9",
3124        get value() {
3125          return get(searchInput);
3126        },
3127        set value($$value) {
3128          set(searchInput, $$value, true);
3129        }
3130      });
3131      reset(div_13);
3132      var node_90 = sibling(div_13, 2);
3133      {
3134        var consequent_4 = ($$anchor3) => {
3135          Loader_circle($$anchor3, { class: "h-4 w-4 animate-spin text-muted-foreground" });
3136        };
3137        if_block(node_90, ($$render) => {
3138          if (txnResource.loading) $$render(consequent_4);
3139        });
3140      }
3141      reset(div_12);
3142      var node_91 = sibling(div_12, 2);
3143      component(node_91, () => Card, ($$anchor3, Card_Root_3) => {
3144        Card_Root_3($$anchor3, {
3145          class: "overflow-hidden rounded-sm py-0",
3146          children: ($$anchor4, $$slotProps) => {
3147            var fragment_61 = comment();
3148            var node_92 = first_child(fragment_61);
3149            {
3150              var consequent_5 = ($$anchor5) => {
3151                TransactionsSkeleton($$anchor5);
3152              };
3153              var alternate_5 = ($$anchor5) => {
3154                var div_14 = root_83();
3155                var node_93 = child(div_14);
3156                {
3157                  var consequent_6 = ($$anchor6) => {
3158                    var div_15 = root_84();
3159                    append($$anchor6, div_15);
3160                  };
3161                  if_block(node_93, ($$render) => {
3162                    if (txnResource.loading && get(displayedTransactions).length > 0) $$render(consequent_6);
3163                  });
3164                }
3165                var node_94 = sibling(node_93, 2);
3166                component(node_94, () => Table, ($$anchor6, Table_Root) => {
3167                  Table_Root($$anchor6, {
3168                    class: "table-fixed",
3169                    children: ($$anchor7, $$slotProps2) => {
3170                      var fragment_63 = root_85();
3171                      var node_95 = first_child(fragment_63);
3172                      component(node_95, () => Table_header, ($$anchor8, Table_Header) => {
3173                        Table_Header($$anchor8, {
3174                          children: ($$anchor9, $$slotProps3) => {
3175                            var fragment_64 = comment();
3176                            var node_96 = first_child(fragment_64);
3177                            component(node_96, () => Table_row, ($$anchor10, Table_Row) => {
3178                              Table_Row($$anchor10, {
3179                                children: ($$anchor11, $$slotProps4) => {
3180                                  var fragment_65 = root_87();
3181                                  var node_97 = first_child(fragment_65);
3182                                  component(node_97, () => Table_head, ($$anchor12, Table_Head) => {
3183                                    Table_Head($$anchor12, {
3184                                      class: "w-[160px]",
3185                                      children: ($$anchor13, $$slotProps5) => {
3186                                        var button = root_88();
3187                                        var node_98 = sibling(child(button));
3188                                        Arrow_up_down(node_98, { class: "h-4 w-4" });
3189                                        reset(button);
3190                                        delegated("click", button, () => toggleSort("date"));
3191                                        append($$anchor13, button);
3192                                      },
3193                                      $$slots: { default: true }
3194                                    });
3195                                  });
3196                                  var node_99 = sibling(node_97, 2);
3197                                  component(node_99, () => Table_head, ($$anchor12, Table_Head_1) => {
3198                                    Table_Head_1($$anchor12, {
3199                                      class: "w-[200px]",
3200                                      children: ($$anchor13, $$slotProps5) => {
3201                                        next();
3202                                        var text_32 = text("VENDOR");
3203                                        append($$anchor13, text_32);
3204                                      },
3205                                      $$slots: { default: true }
3206                                    });
3207                                  });
3208                                  var node_100 = sibling(node_99, 2);
3209                                  component(node_100, () => Table_head, ($$anchor12, Table_Head_2) => {
3210                                    Table_Head_2($$anchor12, {
3211                                      class: "w-[180px]",
3212                                      children: ($$anchor13, $$slotProps5) => {
3213                                        next();
3214                                        var text_33 = text("SOURCE");
3215                                        append($$anchor13, text_33);
3216                                      },
3217                                      $$slots: { default: true }
3218                                    });
3219                                  });
3220                                  var node_101 = sibling(node_100, 2);
3221                                  component(node_101, () => Table_head, ($$anchor12, Table_Head_3) => {
3222                                    Table_Head_3($$anchor12, {
3223                                      class: "w-[120px]",
3224                                      children: ($$anchor13, $$slotProps5) => {
3225                                        var button_1 = root_91();
3226                                        var node_102 = sibling(child(button_1));
3227                                        Arrow_up_down(node_102, { class: "h-4 w-4" });
3228                                        reset(button_1);
3229                                        delegated("click", button_1, () => toggleSort("amount"));
3230                                        append($$anchor13, button_1);
3231                                      },
3232                                      $$slots: { default: true }
3233                                    });
3234                                  });
3235                                  var node_103 = sibling(node_101, 2);
3236                                  component(node_103, () => Table_head, ($$anchor12, Table_Head_4) => {
3237                                    Table_Head_4($$anchor12, {
3238                                      class: "w-[120px]",
3239                                      children: ($$anchor13, $$slotProps5) => {
3240                                        next();
3241                                        var text_34 = text("CATEGORY");
3242                                        append($$anchor13, text_34);
3243                                      },
3244                                      $$slots: { default: true }
3245                                    });
3246                                  });
3247                                  var node_104 = sibling(node_103, 2);
3248                                  component(node_104, () => Table_head, ($$anchor12, Table_Head_5) => {
3249                                    Table_Head_5($$anchor12, {
3250                                      class: "w-[200px]",
3251                                      children: ($$anchor13, $$slotProps5) => {
3252                                        next();
3253                                        var text_35 = text("DESCRIPTION");
3254                                        append($$anchor13, text_35);
3255                                      },
3256                                      $$slots: { default: true }
3257                                    });
3258                                  });
3259                                  var node_105 = sibling(node_104, 2);
3260                                  component(node_105, () => Table_head, ($$anchor12, Table_Head_6) => {
3261                                    Table_Head_6($$anchor12, {
3262                                      class: "w-[180px]",
3263                                      children: ($$anchor13, $$slotProps5) => {
3264                                        next();
3265                                        var text_36 = text("LINKED VIDEO");
3266                                        append($$anchor13, text_36);
3267                                      },
3268                                      $$slots: { default: true }
3269                                    });
3270                                  });
3271                                  var node_106 = sibling(node_105, 2);
3272                                  component(node_106, () => Table_head, ($$anchor12, Table_Head_7) => {
3273                                    Table_Head_7($$anchor12, {
3274                                      class: "w-[180px]",
3275                                      children: ($$anchor13, $$slotProps5) => {
3276                                        next();
3277                                        var text_37 = text("LINKED PARTNERSHIP");
3278                                        append($$anchor13, text_37);
3279                                      },
3280                                      $$slots: { default: true }
3281                                    });
3282                                  });
3283                                  append($$anchor11, fragment_65);
3284                                },
3285                                $$slots: { default: true }
3286                              });
3287                            });
3288                            append($$anchor9, fragment_64);
3289                          },
3290                          $$slots: { default: true }
3291                        });
3292                      });
3293                      var node_107 = sibling(node_95, 2);
3294                      component(node_107, () => Table_body, ($$anchor8, Table_Body) => {
3295                        Table_Body($$anchor8, {
3296                          children: ($$anchor9, $$slotProps3) => {
3297                            var fragment_66 = comment();
3298                            var node_108 = first_child(fragment_66);
3299                            {
3300                              var consequent_7 = ($$anchor10) => {
3301                                var fragment_67 = comment();
3302                                var node_109 = first_child(fragment_67);
3303                                component(node_109, () => Table_row, ($$anchor11, Table_Row_1) => {
3304                                  Table_Row_1($$anchor11, {
3305                                    children: ($$anchor12, $$slotProps4) => {
3306                                      var fragment_68 = comment();
3307                                      var node_110 = first_child(fragment_68);
3308                                      component(node_110, (
3308) => Table_cell, ($$anchor13, Table_Cell) => {
3309                                        Table_Cell($$anchor13, {
3310                                          colspan: 8,
3311                                          class: "py-8 text-center text-muted-foreground",
3312                                          children: ($$anchor14, $$slotProps5) => {
3313                                            next();
3314                                            var text_38 = text("No transactions match your filters");
3315                                            append($$anchor14, text_38);
3316                                          },
3317                                          $$slots: { default: true }
3318                                        });
3319                                      });
3320                                      append($$anchor12, fragment_68);
3321                                    },
3322                                    $$slots: { default: true }
3323                                  });
3324                                });
3325                                append($$anchor10, fragment_67);
3326                              };
3327                              var alternate_4 = ($$anchor10) => {
3328                                var fragment_69 = comment();
3329                                var node_111 = first_child(fragment_69);
3330                                each(node_111, 17, () => get(displayedTransactions), (txn) => txn.id, ($$anchor11, txn) => {
3331                                  const isIncome = user_derived(() => get(txn).type === "income");
3332                                  const hasReceipt = user_derived(() => Boolean(get(txn).receipt));
3333                                  var fragment_70 = comment();
3334                                  var node_112 = first_child(fragment_70);
3335                                  component(node_112, () => Table_row, ($$anchor12, Table_Row_2) => {
3336                                    Table_Row_2($$anchor12, {
3337                                      class: "cursor-pointer",
3338                                      onclick: () => openTransactionDetails(get(txn)),
3339                                      children: ($$anchor13, $$slotProps4) => {
3340                                        var fragment_71 = root_102();
3341                                        var node_
3341113 = first_child(fragment_71);
3342                                        component(node_113, () => Table_cell, ($$anchor14, Table_Cell_1) => {
3343                                          Table_Cell_1($$anchor14, {
3344                                            class: "text-muted-foreground",
3345                                            children: ($$anchor15, $$slotProps5) => {
3346                                              next();
3347                                              var text_39 = text();
3348                                              template_effect(($0) => set_text(text_39, $0), [() => formatDate(get(txn).date)]);
3349                                              append($$anchor15, text_39);
3350                                            },
3351                                            $$slots: { default: true }
3352                                          });
3353                                        });
3354                                        var node_114 = sibling(node_113, 2);
3355                                        component(node_114, () => Table_cell, ($$anchor14, Table_Cell_2) => {
3356                                          Table_Cell_2($$anchor14, {
3357                                            children: ($$anchor15, $$slotProps5) => {
3358                                              var div_16 = root_104();
3359                                              var node_115 = child(div_16);
3360                                              {
3361                                                var consequent_8 = ($$anchor16) => {
3362                                                  var img = root_105();
3363                                                  template_effect(() => set_attribute(img, "src", get(txn).logoUrl));
3364                                                  event("error", img, (e) => e.target.style.display = "none");
3365                                                  replay_events(img);
3366                                                  append($$anchor16, img);
3367                                                };
3368                                                if_block(node_115, ($$render) => {
3369                                                  if (get(txn).source === "plaid" && get(txn).logoUrl) $$render(consequent_8);
3370                                                });
3371                                              }
3372                                              var span_1 = sibling(node_115, 2);
3373                                              var text_40 = child(span_1, true);
3374                                              reset(span_1);
3375                                              var node_116 = sibling(span_1, 2);
3376                                              {
3377                                                var consequent_9 = ($$anchor16) => {
3378                                                  var span_2 = root_106();
3379                                                  var node_117 = child(span_2);
3380                                                  Receipt(node_117, { class: "h-3.5 w-3.5" });
3381                                                  reset(span_2);
3382                                                  append($$anchor16, span_2);
3383                                                };
3384                                                if_block(node_116, ($$render) => {
3385                                                  if (get(hasReceipt)) $$render(consequent_9);
3386                                                });
3387                                              }
3388                                              reset(div_16);
3389                                              template_effect(() => set_text(text_40, get(txn).merchantName || "—"));
3390                                              append($$anchor15, div_16);
3391                                            },
3392                                            $$slots: { default: true }
3393                                          });
3394                                        });
3395                                        var node_118 = sibling(node_114, 2);
3396                                        component(node_118, () => Table_cell, ($$anchor14, Table_Cell_3) => {
3397                                          Table_Cell_3($$anchor14, {
3398                                            class: "max-w-0",
3399                                            children: ($$anchor15, $$slotProps5) => {
3400                                              var fragment_73 = comment();
3401                                              var node_119 = first_child(fragment_73);
3402                                              {
3403                                                var consequent_10 = ($$anchor16) => {
3404                                                  {
3405                                                    let $0 = user_derived(() => `${get(txn).plaidAccount.name}${get(txn).plaidAccount.mask ? ` ••${get(txn).plaidAccount.mask}` : ""}`);
3406                                                    Badge($$anchor16, {
3407                                                      variant: "outline",
3408                                                      class: "inline-block max-w-full truncate align-bottom",
3409                                                      get title() {
3410                                                        return get($0);
3411                                                      },
3412                                                      children: ($$anchor17, $$slotProps6) => {
3413                                                        next();
3414                                                        var text_41 = text();
3415                                                        template_effect(() => set_text(text_41, `${get(txn).plaidAccount.name ?? ""}${get(txn).plaidAccount.mask ? ` ••${get(txn).plaidAccount.mask}` : ""}`));
3416                                                        append($$anchor17, text_41);
3417                                                      },
3418                                                      $$slots: { default: true }
3419                                                    });
3420                                                  }
3421                                                };
3422                                                var alternate = ($$anchor16) => {
3423                                                  Badge($$anchor16, {
3424                                                    variant: "outline",
3425                                                    children: ($$anchor17, $$slotProps6) => {
3426                                                      next();
3427                                                      var text_42 = text("Manual");
3428                                                      append($$anchor17, text_42);
3429                                                    },
3430                                                    $$slots: { default: true }
3431                                                  });
3432                                                };
3433                                                if_block(node_119, ($$render) => {
3434                                                  if (get(txn).plaidAccount) $$render(consequent_10);
3435                                                  else $$render(alternate, false);
3436                                                });
3437                                              }
3438                                              append($$anchor15, fragment_73);
3439                                            },
3440                                            $$slots: { default: true }
3441                                          });
3442                                        });
3443                                        var node_120 = sibling(node_118, 2);
3444                                        component(node_120, () => Table_cell, ($$anchor14, Table_Cell_4) => {
3445                                          Table_Cell_4($$anchor14, {
3446                                            children: ($$anchor15, $$slotProps5) => {
3447                                              var span_3 = root_112();
3448                                              var text_43 = child(span_3);
3449                                              reset(span_3);
3450                                              template_effect(
3451                                                ($0) => {
3452                                                  set_class(span_3, 1, `font-medium ${get(isIncome) ? "text-green-600 dark:text-green-400" : "text-foreground"}`);
3453                                                  set_text(text_43, `${get(isIncome) ? "+" : "-"}${$0 ?? ""}`);
3454                                                },
3455                                                [
3456                                                  () => formatCurrency(get(txn).amount, get(txn).isoCurrencyCode)
3457                                                ]
3458                                              );
3459                                              append($$anchor15, span_3);
3460                                            },
3461                                            $$slots: { default: true }
3462                                          });
3463                                        });
3464                                        var node_121 = sibling(node_120, 2);
3465                                        component(node_121, () => Table_cell, ($$anchor14, Table_Cell_5) => {
3466                                          Table_Cell_5($$anchor14, {
3467                                            class: "max-w-0",
3468                                            children: ($$anchor15, $$slotProps5) => {
3469                                              var fragment_77 = comment();
3470                                              var node_122 = first_child(fragment_77);
3471                                              {
3472                                                var consequent_11 = ($$anchor16) => {
3473                                                  Badge($$anchor16, {
3474                                                    variant: "outline",
3475                                                    class: "inline-block max-w-full truncate align-bottom",
3476                                                    get title() {
3477                                                      return get(txn).transactionGroup.classification.category.name;
3478                                                    },
3479                                                    children: ($$anchor17, $$slotProps6) => {
3480                                                      next();
3481                                                      var text_44 = text();
3482                                                      template_effect(() => set_text(text_44, get(txn).transactionGroup.classification.category.name));
3483                                                      append($$anchor17, text_44);
3484                                                    },
3485                                                    $$slots: { default: true }
3486                                                  });
3487                                                };
3488                                                var consequent_12 = ($$anchor16) => {
3489                                                  Badge($$anchor16, {
3490                                                    variant: "outline",
3491                                                    class: "inline-block max-w-full truncate align-bottom",
3492                                                    get title() {
3493                                                      return get(txn).category.name;
3494                                                    },
3495                                                    children: ($$anchor17, $$slotProps6) => {
3496                                                      next();
3497                                                      var text_45 = text();
3498                                                      template_effect(() => set_text(text_45, get(txn).category.name));
3499                                                      append($$anchor17, text_45);
3500                                                    },
3501                                                    $$slots: { default: true }
3502                                                  });
3503                                                };
3504                                                var alternate_1 = ($$anchor16) => {
3505                                                  var span_4 = root_118();
3506                                                  append($$anchor16, span_4);
3507                                                };
3508                                                if_block(node_122, ($$render) => {
3509                                                  if (get(txn).transactionGroup?.classification?.category) $$render(consequent_11);
3510                                                  else if (get(txn).category) $$render(consequent_12, 1);
3511                                                  else $$render(alternate_1, false);
3512                                                });
3513                                              }
3514                                              append($$anchor15, fragment_77);
3515                                            },
3516                                            $$slots: { default: true }
3517                                          });
3518                                        });
3519                                        var node_123 = sibling(node_121, 2);
3520                                        component(node_123, () => Table_cell, ($$anchor14, Table_Cell_6) => {
3521                                          Table_Cell_6($$anchor14, {
3522                                            class: "max-w-0",
3523                                            children: ($$anchor15, $$slotProps5) => {
3524                                              var span_5 = root_119();
3525                                              var text_46 = child(span_5, true);
3526                                              reset(span_5);
3527                                              template_effect(() => {
3528                                                set_attribute(span_5, "title", get(txn).description || void 0);
3529                                                set_text(text_46, get(txn).description || "—");
3530                                              });
3531                                              append($$anchor15, span_5);
3532                                            },
3533                                            $$slots: { default: true }
3534                                          });
3535                                        });
3536                                        var node_124 = sibling(node_123, 2);
3537                                        component(node_124, () => Table_cell, ($$anchor14, Table_Cell_7) => {
3538                                          Table_Cell_7($$anchor14, {
3539                                            children: ($$anchor15, $$slotProps5) => {
3540                                              var fragment_82 = comment();
3541                                              var node_125 = first_child(fragment_82);
3542                                              {
3543                                                var consequent_13 = ($$anchor16) => {
3544                                                  var span_6 = root_121();
3545                                                  append($$anchor16, span_6);
3546                                                };
3547                                                var consequent_14 = ($$anchor16) => {
3548                                                  var span_7 = root_122();
3549                                                  var text_47 = child(span_7, true);
3550                                                  reset(span_7);
3551                                                  template_effect(() => set_text(text_47, get(txn).videoLinks[0].ytVideo.name));
3552                                                  append($$anchor16, span_7);
3553                                                };
3554                                                var alternate_2 = ($$anchor16) => {
3555                                                  Badge($$anchor16, {
3556                                                    variant: "outline",
3557                                                    children: ($$anchor17, $$slotProps6) => {
3558                                                      next();
3559                                                      var text_48 = text();
3560                                                      template_effect(() => set_text(text_48, `${get(txn).videoLinks.length ?? ""} videos`));
3561                                                      append($$anchor17, text_48);
3562                                                    },
3563                                                    $$slots: { default: true }
3564                                                  });
3565                                                };
3566                                                if_block(node_125, ($$render) => {
3567                                                  if ((get(txn).videoLinks ?? []).length === 0) $$render(consequent_13);
3568                                                  else if ((get(txn).videoLinks ?? []).length === 1) $$render(consequent_14, 1);
3569                                                  else $$render(alternate_2, false);
3570                                                });
3571                                              }
3572                                              append($$anchor15, fragment_82);
3573                                            },
3574                                            $$slots: { default: true }
3575                                          });
3576                                        });
3577                                        var node_126 = sibling(node_124, 2);
3578                                        component(node_126, () => Table_cell, ($$anchor14, Table_Cell_8) => {
3579                                          Table_Cell_8($$anchor14, {
3580                                            children: ($$anchor15, $$slotProps5) => {
3581                                              var fragment_85 = comment();
3582                                              var node_127 = first_child(fragment_85);
3583                                              {
3584                                                var consequent_15 = ($$anchor16) => {
3585                                                  var span_8 = root_126();
3586                                                  var text_49 = child(span_8, true);
3587                                                  reset(span_8);
3588                                                  template_effect(() => set_text(text_49, get(txn).partnership.partner.contactName));
3589                                                  append($$anchor16, span_8);
3590                                                };
3591                                                var alternate_3 = ($$anchor16) => {
3592                                                  var span_9 = root_127();
3593                                                  append($$anchor16, span_9);
3594                                                };
3595                                                if_block(node_127, ($$render) => {
3596                                                  if (get(txn).partnership) $$render(consequent_15);
3597                                                  else $$render(alternate_3, false);
3598                                                });
3599                                              }
3600                                              append($$anchor15, fragment_85);
3601                                            },
3602                                            $$slots: { default: true }
3603                                          });
3604                                        });
3605                                        append($$anchor13, fragment_71);
3606                                      },
3607                                      $$slots: { default: true }
3608                                    });
3609                                  });
3610                                  append($$anchor11, fragment_70);
3611                                });
3612                                append($$anchor10, fragment_69);
3613                              };
3614                              if_block(node_108, ($$render) => {
3615                                if (get(displayedTransactions).length === 0) $$render(consequent_7);
3616                                else $$render(alternate_4, false);
3617                              });
3618                            }
3619                            append($$anchor9, fragment_66);
3620                          },
3621                          $$slots: { default: true }
3622                        });
3623                      });
3624                      append($$anchor7, fragment_63);
3625                    },
3626                    $$slots: { default: true }
3627                  });
3628                });
3629                reset(div_14);
3630                append($$anchor5, div_14);
3631              };
3632              if_block(node_92, ($$render) => {
3633                if (txnResource.loading && !get(displayedTransactions).length) $$render(consequent_5);
3634                else $$render(alternate_5, false);
3635              });
3636            }
3637            append($$anchor4, fragment_61);
3638          },
3639          $$slots: { default: true }
3640        });
3641      });
3642      var div_17 = sibling(node_91, 2);
3643      var p_4 = child(div_17);
3644      var node_128 = child(p_4);
3645      {
3646        var consequent_16 = ($$anchor3) => {
3647          var text_50 = text();
3648          template_effect(($0) => set_text(text_50, `Showing ${(get(displayedPage) - 1) * get(perPage) + 1}–${$0 ?? ""} of ${get(totalCount) ?? ""} transaction${get(totalCount) === 1 ? "" : "s"}`), [
3649            () => Math.min(get(displayedPage) * get(perPage), get(totalCount))
3650          ]);
3651          append($$anchor3, text_50);
3652        };
3653        var alternate_6 = ($$anchor3) => {
3654          var text_51 = text();
3655          template_effect(() => set_text(text_51, `Showing ${get(totalCount) ?? ""} transaction${get(totalCount) === 1 ? "" : "s"}`));
3656          append($$anchor3, text_51);
3657        };
3658        if_block(node_128, ($$render) => {
3659          if (get(totalCount) > get(perPage)) $$render(consequent_16);
3660          else $$render(alternate_6, false);
3661        });
3662      }
3663      reset(p_4);
3664      var node_129 = sibling(p_4, 2);
3665      {
3666        var consequent_19 = ($$anchor3) => {
3667          var fragment_88 = comment();
3668          var node_130 = first_child(fragment_88);
3669          component(node_130, () => Pagination, ($$anchor4, Pagination_Root) => {
3670            Pagination_Root($$anchor4, {
3671              get count() {
3672                return get(totalCount);
3673              },
3674              get perPage() {
3675                return get(perPage);
3676              },
3677              get page() {
3678                return get(displayedPage);
3679              },
3680              onPageChange: (p) => goToPage(p),
3681              children: ($$anchor5, $$slotProps) => {
3682                var fragment_89 = comment();
3683                var node_131 = first_child(fragment_89);
3684                component(node_131, () => Pagination_content, ($$anchor6, Pagination_Content) => {
3685                  Pagination_Content($$anchor6, {
3686                    children: ($$anchor7, $$slotProps2) => {
3687                      var fragment_90 = root_132();
3688                      var node_132 = first_child(fragment_90);
3689                      component(node_132, () => Pagination_item, ($$anchor8, Pagination_Item) => {
3690                        Pagination_Item($$anchor8, {
3691                          children: ($$anchor9, $$slotProps3) => {
3692                            var fragment_91 = comment();
3693                            var node_133 = first_child(fragment_91);
3694                            component(node_133, () => Pagination_prev_button, ($$anchor10, Pagination_PrevButton) => {
3695                              Pagination_PrevButton($$anchor10, {});
3696                            });
3697                            append($$anchor9, fragment_91);
3698                          },
3699                          $$slots: { default: true }
3700                        });
3701                      });
3702                      var node_134 = sibling(node_132, 2);
3703                      each(node_134, 17, () => ({ length: Math.ceil(get(totalCount) / get(perPage)) }), index, ($$anchor8, _, i) => {
3704                        const pageNum = user_derived(() => i + 1);
3705                        const totalPages = user_derived(() => Math.ceil(get(totalCount) / get(perPage)));
3706                        var fragment_92 = comment();
3707                        var node_135 = first_child(fragment_92);
3708                        {
3709                          var consequent_17 = ($$anchor9) => {
3710                            var fragment_93 = comment();
3711                            var node_136 = first_child(fragment_93);
3712                            component(node_136, () => Pagination_item, ($$anchor10, Pagination_Item_1) => {
3713                              Pagination_Item_1($$anchor10, {
3714                                children: ($$anchor11, $$slotProps3) => {
3715                                  var fragment_94 = comment();
3716                                  var node_137 = first_child(fragment_94);
3717                                  {
3718                                    let $0 = user_derived(() => ({ type: "page", value: get(pageNum) }));
3719                                    let $1 = user_derived(() => get(displayedPage) === get(pageNum));
3720                                    component(node_137, () => Pagination_link, ($$anchor12, Pagination_Link) => {
3721                                      Pagination_Link($$anchor12, {
3722                                        get page() {
3723                                          return get($0);
3724                                        },
3725                                        get isActive() {
3726                                          return get($1);
3727                                        }
3728                                      });
3729                                    });
3730                                  }
3731                                  append($$anchor11, fragment_94);
3732                                },
3733                                $$slots: { default: true }
3734                              });
3735                            });
3736                            append($$anchor9, fragment_93);
3737                          };
3738                          var consequent_18 = ($$anchor9) => {
3739                            var fragment_95 = comment();
3740                            var node_138 = first_child(fragment_95);
3741                            component(node_138, () => Pagination_item, ($$anchor10, Pagination_Item_2) => {
3742                              Pagination_Item_2($$anchor10, {
3743                                children: ($$anchor11, $$slotProps3) => {
3744                                  var fragment_96 = comment();
3745                                  var node_139 = first_child(fragment_96);
3746                                  component(node_139, () => Pagination_ellipsis, ($$anchor12, Pagination_Ellipsis) => {
3747                                    Pagination_Ellipsis($$anchor12, {});
3748                                  });
3749                                  append($$anchor11, fragment_96);
3750                                },
3751                                $$slots: { default: true }
3752                              });
3753                            });
3754                            append($$anchor9, fragment_95);
3755                          };
3756                          if_block(node_135, ($$render) => {
3757                            if (get(pageNum) === 1 || get(pageNum) === get(totalPages) || get(pageNum) >= get(displayedPage) - 1 && get(pageNum) <= get(displayedPage) + 1) $$render(consequent_17);
3758                            else if (get(pageNum) === get(displayedPage) - 2 || get(pageNum) === get(displayedPage) + 2) $$render(consequent_18, 1);
3759                          });
3760                        }
3761                        append($$anchor8, fragment_92);
3762                      });
3763                      var node_140 = sibling(node_134, 2);
3764                      component(node_140, () => Pagination_item, ($$anchor8, Pagination_Item_3) => {
3765                        Pagination_Item_3($$anchor8, {
3766                          children: ($$anchor9, $$slotProps3) => {
3767                            var fragment_97 = comment();
3768                            var node_141 = first_child(fragment_97);
3769                            component(node_141, () => Pagination_next_button, ($$anchor10, Pagination_NextButton) => {
3770                              Pagination_NextButton($$anchor10, {});
3771                            });
3772                            append($$anchor9, fragment_97);
3773                          },
3774                          $$slots: { default: true }
3775                        });
3776                      });
3777                      append($$anchor7, fragment_90);
3778                    },
3779                    $$slots: { default: true }
3780                  });
3781                });
3782                append($$anchor5, fragment_89);
3783              },
3784              $$slots: { default: true }
3785            });
3786          });
3787          append($$anchor3, fragment_88);
3788        };
3789        if_block(node_129, ($$render) => {
3790          if (get(totalCount) > get(perPage)) $$render(consequent_19);
3791        });
3792      }
3793      reset(div_17);
3794      reset(div_10);
3795      append($$anchor2, div_10);
3796    };
3797    if_block(node_54, ($$render) => {
3798      if (!get(summary).hasAnyTransactions) $$render(consequent_2);
3799      else $$render(alternate_7, false);
3800    });
3801  }
3802  reset(div_1);
3803  append($$anchor, fragment);
3804  pop();
3805}
3806delegate(["click"]);
3807export {
3808  _page as component
3809};

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.