@hadoku/jobplatform 3.42.63 → 3.42.64

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1753 @@
1
+ import { jsxs as i, jsx as e, Fragment as K } from "react/jsx-runtime";
2
+ import { useState as _, useMemo as W, useCallback as Q, useEffect as V } from "react";
3
+ import { l as M, a as J, J as S, s as U, f as X, b as Z, u as ee, c as ne, d as te } from "./entry-CFBqMGn5.js";
4
+ function F(r) {
5
+ return r.replace(/\*/g, " ").toLowerCase().replace(/n't\b/g, " not ").replace(/[^a-z0-9]+/g, " ").trim();
6
+ }
7
+ const D = /* @__PURE__ */ new Set([
8
+ "us",
9
+ "u s",
10
+ "usa",
11
+ "u s a",
12
+ "america",
13
+ "united states",
14
+ "united states of america",
15
+ "the united states",
16
+ "the united states of america"
17
+ ]);
18
+ function se(r, t) {
19
+ const o = r.trim();
20
+ if (!o) return null;
21
+ if (t.length === 0) return o;
22
+ const c = F(o), l = t.filter((f) => F(f) === c);
23
+ if (l.length === 1) return l[0] ?? null;
24
+ if (D.has(c)) {
25
+ const f = t.filter((h) => D.has(F(h).replace(/( [0-9]+)+$/, "")));
26
+ if (f.length === 1) return f[0] ?? null;
27
+ }
28
+ const g = c.split(" ")[0];
29
+ if (g === "yes" || g === "no") {
30
+ const f = t.filter((h) => F(h).split(" ")[0] === g);
31
+ return f.length === 1 ? f[0] ?? null : null;
32
+ }
33
+ const b = (f, h) => ` ${f} `.includes(` ${h} `), k = t.filter((f) => {
34
+ const h = F(f);
35
+ return b(h, c) || b(c, h);
36
+ });
37
+ return k.length === 1 ? k[0] ?? null : null;
38
+ }
39
+ function oe({
40
+ similar: r,
41
+ onCopy: t
42
+ }) {
43
+ return r.length === 0 ? null : /* @__PURE__ */ i("details", { className: "jp-questions__dupes", children: [
44
+ /* @__PURE__ */ i("summary", { children: [
45
+ r.length,
46
+ " similar answered"
47
+ ] }),
48
+ /* @__PURE__ */ e("ul", { children: r.map((o) => /* @__PURE__ */ i("li", { className: "jp-questions__dupe", children: [
49
+ /* @__PURE__ */ e("p", { className: "jp-questions__dupe-q", children: o.question }),
50
+ /* @__PURE__ */ e("p", { className: "jp-questions__dupe-a", children: /* @__PURE__ */ e("strong", { children: o.answer || /* @__PURE__ */ e("em", { children: "(blank)" }) }) }),
51
+ o.polarity_differs && /* @__PURE__ */ e("p", { className: "jp-questions__dupe-warn", children: "Opposite phrasing — copying would state the reverse." }),
52
+ o.only_in_pending.length > 0 && /* @__PURE__ */ i("p", { className: "jp-questions__dupe-diff", children: [
53
+ "also asks: ",
54
+ /* @__PURE__ */ e("code", { children: o.only_in_pending.join(", ") })
55
+ ] }),
56
+ o.only_in_answered.length > 0 && /* @__PURE__ */ i("p", { className: "jp-questions__dupe-diff", children: [
57
+ "yours was about: ",
58
+ /* @__PURE__ */ e("code", { children: o.only_in_answered.join(", ") })
59
+ ] }),
60
+ o.runner_would_match && /* @__PURE__ */ e("p", { className: "jp-questions__dupe-diff", children: "covers this one already" }),
61
+ /* @__PURE__ */ e(
62
+ "button",
63
+ {
64
+ type: "button",
65
+ className: "jp-questions__dupe-copy",
66
+ onClick: () => t(o.answer),
67
+ children: "Use this answer"
68
+ }
69
+ )
70
+ ] }, o.question_key)) })
71
+ ] });
72
+ }
73
+ function ie({
74
+ label: r,
75
+ members: t,
76
+ prior: o,
77
+ saving: c,
78
+ onSave: l
79
+ }) {
80
+ const [g, b] = _(
81
+ () => Object.fromEntries(t.map((n) => [n.question_key, n.suggested ?? ""]))
82
+ ), [k, f] = _(
83
+ () => Object.fromEntries(t.map((n) => [n.question_key, n.suggested !== null]))
84
+ ), [h, j] = _(o[0] ?? "");
85
+ function d() {
86
+ const n = { ...g }, a = { ...k };
87
+ for (const m of t) {
88
+ const y = se(h, m.options);
89
+ n[m.question_key] = y ?? "", a[m.question_key] = y !== null;
90
+ }
91
+ b(n), f(a);
92
+ }
93
+ const u = t.filter(
94
+ (n) => k[n.question_key] && (g[n.question_key] ?? "").trim() !== ""
95
+ ), x = t.reduce((n, a) => n + a.blocking, 0);
96
+ return /* @__PURE__ */ i("li", { className: "jp-questions__row jp-family", children: [
97
+ /* @__PURE__ */ e("p", { className: "jp-questions__q", children: r }),
98
+ /* @__PURE__ */ i("p", { className: "jp-questions__meta", children: [
99
+ x > 0 && /* @__PURE__ */ i("strong", { children: [
100
+ "blocking ",
101
+ x,
102
+ " application",
103
+ x === 1 ? "" : "s",
104
+ " ·",
105
+ " "
106
+ ] }),
107
+ "asked ",
108
+ t.length,
109
+ " way",
110
+ t.length === 1 ? "" : "s"
111
+ ] }),
112
+ o.length > 0 && /* @__PURE__ */ i("p", { className: "jp-family__prior", children: [
113
+ "You've answered this as",
114
+ " ",
115
+ o.map((n, a) => /* @__PURE__ */ i("span", { children: [
116
+ a > 0 && " · ",
117
+ /* @__PURE__ */ e("strong", { children: n })
118
+ ] }, n))
119
+ ] }),
120
+ /* @__PURE__ */ i("div", { className: "jp-questions__answer", children: [
121
+ /* @__PURE__ */ e(
122
+ "input",
123
+ {
124
+ type: "text",
125
+ value: h,
126
+ placeholder: "Your answer",
127
+ onChange: (n) => j(n.target.value),
128
+ onKeyDown: (n) => {
129
+ n.key === "Enter" && d();
130
+ }
131
+ }
132
+ ),
133
+ /* @__PURE__ */ e("button", { type: "button", className: "jp-drawer__cta", onClick: d, children: "Apply to all" })
134
+ ] }),
135
+ /* @__PURE__ */ e("ul", { className: "jp-family__members", children: t.map((n) => /* @__PURE__ */ i("li", { className: "jp-family__member", children: [
136
+ /* @__PURE__ */ i("label", { className: "jp-family__pick", children: [
137
+ /* @__PURE__ */ e(
138
+ "input",
139
+ {
140
+ type: "checkbox",
141
+ checked: !!k[n.question_key],
142
+ onChange: (a) => f((m) => ({ ...m, [n.question_key]: a.target.checked }))
143
+ }
144
+ ),
145
+ /* @__PURE__ */ i("span", { children: [
146
+ /* @__PURE__ */ e("span", { className: "jp-family__q", children: n.question }),
147
+ n.companies.length > 0 && /* @__PURE__ */ e("span", { className: "jp-family__who", children: n.companies.join(", ") })
148
+ ] })
149
+ ] }),
150
+ n.saved_answer !== null && /* @__PURE__ */ i("p", { className: "jp-family__rejected", children: [
151
+ "Your saved answer “",
152
+ n.saved_answer,
153
+ "” isn't one of this board's options."
154
+ ] }),
155
+ n.options.length > 0 ? /* @__PURE__ */ i(
156
+ "select",
157
+ {
158
+ value: g[n.question_key] ?? "",
159
+ onChange: (a) => {
160
+ const m = a.target.value;
161
+ b((y) => ({ ...y, [n.question_key]: m })), f((y) => ({ ...y, [n.question_key]: m !== "" }));
162
+ },
163
+ children: [
164
+ /* @__PURE__ */ e("option", { value: "", children: "Pick an answer…" }),
165
+ n.options.map((a) => /* @__PURE__ */ e("option", { value: a, children: a }, a))
166
+ ]
167
+ }
168
+ ) : /* @__PURE__ */ e(
169
+ "input",
170
+ {
171
+ type: "text",
172
+ value: g[n.question_key] ?? "",
173
+ placeholder: "Answer",
174
+ onChange: (a) => b((m) => ({ ...m, [n.question_key]: a.target.value }))
175
+ }
176
+ )
177
+ ] }, n.question_key)) }),
178
+ /* @__PURE__ */ e(
179
+ "button",
180
+ {
181
+ type: "button",
182
+ className: "jp-drawer__cta jp-drawer__cta--primary jp-family__save",
183
+ disabled: c || u.length === 0,
184
+ onClick: () => l(u.map((n) => ({ question: n, answer: g[n.question_key] ?? "" }))),
185
+ children: c ? "Saving…" : `Save ${u.length} answer${u.length === 1 ? "" : "s"}`
186
+ }
187
+ )
188
+ ] });
189
+ }
190
+ const z = " | ";
191
+ function re({
192
+ q: r,
193
+ value: t,
194
+ onChange: o,
195
+ onEnter: c
196
+ }) {
197
+ if (r.multi && r.options.length > 0) {
198
+ const l = new Set(t ? t.split(z) : []), g = (b) => {
199
+ const k = new Set(l);
200
+ k.has(b) ? k.delete(b) : k.add(b), o(r.options.filter((f) => k.has(f)).join(z));
201
+ };
202
+ return /* @__PURE__ */ i("fieldset", { className: "jp-questions__choices", children: [
203
+ /* @__PURE__ */ e("legend", { className: "jp-questions__choices-hint", children: "Pick all that apply" }),
204
+ r.options.map((b) => /* @__PURE__ */ i("label", { children: [
205
+ /* @__PURE__ */ e("input", { type: "checkbox", checked: l.has(b), onChange: () => g(b) }),
206
+ b
207
+ ] }, b))
208
+ ] });
209
+ }
210
+ return r.options.length === 1 ? /* @__PURE__ */ i("label", { className: "jp-questions__consent", children: [
211
+ /* @__PURE__ */ e(
212
+ "input",
213
+ {
214
+ type: "checkbox",
215
+ checked: t === "Yes",
216
+ onChange: (l) => o(l.target.checked ? "Yes" : "")
217
+ }
218
+ ),
219
+ "Tick this box"
220
+ ] }) : r.options.length > 0 ? /* @__PURE__ */ i("select", { value: t, onChange: (l) => o(l.target.value), children: [
221
+ /* @__PURE__ */ e("option", { value: "", children: "Pick an answer…" }),
222
+ r.options.map((l) => /* @__PURE__ */ e("option", { value: l, children: l }, l))
223
+ ] }) : /* @__PURE__ */ e(
224
+ "input",
225
+ {
226
+ type: "text",
227
+ value: t,
228
+ placeholder: "Answer",
229
+ onChange: (l) => o(l.target.value),
230
+ onKeyDown: (l) => {
231
+ l.key === "Enter" && c();
232
+ }
233
+ }
234
+ );
235
+ }
236
+ function B({ auth: r, refreshKey: t = 0 }) {
237
+ const [o, c] = _([]), [l, g] = _([]), [b, k] = _({}), [f, h] = _(null), [j, d] = _(null), [u, x] = _(!0), [n, a] = _(!1), [m, y] = _(""), [C, A] = _(""), [E, $] = _(!1), v = W(() => {
238
+ const s = /* @__PURE__ */ new Map(), w = [];
239
+ for (const p of o)
240
+ if (p.family) {
241
+ const q = s.get(p.family) ?? {
242
+ kind: "family",
243
+ id: p.family,
244
+ label: p.family_label ?? p.family,
245
+ members: [],
246
+ prior: p.family_answers,
247
+ cost: 0,
248
+ seen: 0
249
+ }, N = {
250
+ ...q,
251
+ members: [...q.members, p],
252
+ cost: q.cost + p.blocking,
253
+ seen: q.seen + p.applications
254
+ };
255
+ s.set(p.family, N);
256
+ } else
257
+ w.push({ kind: "single", q: p, cost: p.blocking, seen: p.applications });
258
+ return w.push(...s.values()), w.sort((p, q) => q.cost - p.cost || q.seen - p.seen);
259
+ }, [o]), I = Q(() => {
260
+ x(!0), Promise.all([M(), J()]).then(([s, w]) => {
261
+ c(s), g(w), d(null);
262
+ }).catch((s) => {
263
+ d(s instanceof S ? s.message : "Failed to load questions");
264
+ }).finally(() => x(!1));
265
+ }, [r]);
266
+ V(I, [I, t]);
267
+ async function R(s) {
268
+ h(s.question_key), d(null);
269
+ try {
270
+ const w = await U(
271
+ s.question,
272
+ b[s.question_key] ?? s.suggested ?? "",
273
+ r
274
+ );
275
+ g((p) => [w, ...p.filter((q) => q.question_key !== w.question_key)]), c((p) => p.filter((q) => q.question_key !== s.question_key));
276
+ } catch (w) {
277
+ d(w instanceof S ? w.message : "Failed to save");
278
+ } finally {
279
+ h(null);
280
+ }
281
+ }
282
+ async function Y(s, w) {
283
+ h(`family:${s}`), d(null);
284
+ const p = [];
285
+ try {
286
+ for (const { question: q, answer: N } of w)
287
+ p.push(await U(q.question, N, r));
288
+ } catch (q) {
289
+ d(q instanceof S ? q.message : "Failed to save");
290
+ } finally {
291
+ if (p.length) {
292
+ const q = new Set(p.map((N) => N.question_key));
293
+ g((N) => [...p, ...N.filter((O) => !q.has(O.question_key))]), c((N) => N.filter((O) => !q.has(O.question_key)));
294
+ }
295
+ h(null);
296
+ }
297
+ }
298
+ async function T() {
299
+ if (m.trim()) {
300
+ $(!0), d(null);
301
+ try {
302
+ const s = await U(m, C, r);
303
+ g((w) => [s, ...w.filter((p) => p.question_key !== s.question_key)]), c((w) => w.filter((p) => p.question_key !== s.question_key)), y(""), A(""), a(!0);
304
+ } catch (s) {
305
+ d(s instanceof S ? s.message : "Failed to save");
306
+ } finally {
307
+ $(!1);
308
+ }
309
+ }
310
+ }
311
+ async function G(s) {
312
+ d(null);
313
+ try {
314
+ g(await X(s, r)), c(await M(r));
315
+ } catch (w) {
316
+ d(w instanceof S ? w.message : "Failed to forget");
317
+ }
318
+ }
319
+ return u || !o.length && !l.length ? null : /* @__PURE__ */ i("section", { className: "jp-questions", children: [
320
+ /* @__PURE__ */ i("div", { className: "jp-questions__head", children: [
321
+ /* @__PURE__ */ e("h3", { children: "Unanswered questions" }),
322
+ l.length > 0 && /* @__PURE__ */ i(
323
+ "button",
324
+ {
325
+ type: "button",
326
+ className: "jp-questions__toggle",
327
+ onClick: () => a((s) => !s),
328
+ children: [
329
+ n ? "Hide" : "Show",
330
+ " saved answers (",
331
+ l.length,
332
+ ")"
333
+ ]
334
+ }
335
+ )
336
+ ] }),
337
+ j && /* @__PURE__ */ e("p", { className: "jp-error", children: j }),
338
+ o.length > 0 && /* @__PURE__ */ e("ul", { className: "jp-questions__list", children: v.map(
339
+ (s) => s.kind === "family" ? /* @__PURE__ */ e(
340
+ ie,
341
+ {
342
+ label: s.label,
343
+ members: s.members,
344
+ prior: s.prior,
345
+ saving: f === `family:${s.id}`,
346
+ onSave: (w) => {
347
+ Y(s.id, w);
348
+ }
349
+ },
350
+ `family:${s.id}`
351
+ ) : /* @__PURE__ */ i("li", { className: "jp-questions__row", children: [
352
+ /* @__PURE__ */ e("p", { className: "jp-questions__q", children: s.q.question }),
353
+ s.q.companies.length > 0 && /* @__PURE__ */ i("p", { className: "jp-questions__meta", children: [
354
+ s.q.blocking > 0 && /* @__PURE__ */ i("strong", { children: [
355
+ "blocking ",
356
+ s.q.blocking,
357
+ " application",
358
+ s.q.blocking === 1 ? "" : "s",
359
+ " ·",
360
+ " "
361
+ ] }),
362
+ s.q.companies.join(", ")
363
+ ] }),
364
+ s.q.saved_answer !== null && /* @__PURE__ */ i("p", { className: "jp-family__rejected", children: [
365
+ "Your saved answer “",
366
+ s.q.saved_answer,
367
+ "” isn't one of this board's options."
368
+ ] }),
369
+ /* @__PURE__ */ i("div", { className: "jp-questions__answer", children: [
370
+ /* @__PURE__ */ e(
371
+ re,
372
+ {
373
+ q: s.q,
374
+ value: b[s.q.question_key] ?? s.q.suggested ?? "",
375
+ onChange: (w) => k((p) => ({ ...p, [s.q.question_key]: w })),
376
+ onEnter: () => {
377
+ R(s.q);
378
+ }
379
+ }
380
+ ),
381
+ /* @__PURE__ */ e(
382
+ "button",
383
+ {
384
+ type: "button",
385
+ className: "jp-drawer__cta jp-drawer__cta--primary",
386
+ onClick: () => {
387
+ R(s.q);
388
+ },
389
+ disabled: f === s.q.question_key,
390
+ children: f === s.q.question_key ? "Saving…" : "Save"
391
+ }
392
+ )
393
+ ] }),
394
+ /* @__PURE__ */ e(
395
+ oe,
396
+ {
397
+ similar: s.q.similar ?? [],
398
+ onCopy: (w) => k((p) => ({ ...p, [s.q.question_key]: w }))
399
+ }
400
+ )
401
+ ] }, s.q.question_key)
402
+ ) }),
403
+ /* @__PURE__ */ i("details", { className: "jp-questions__add", children: [
404
+ /* @__PURE__ */ e("summary", { children: "Add another question" }),
405
+ /* @__PURE__ */ e(
406
+ "input",
407
+ {
408
+ type: "text",
409
+ value: m,
410
+ placeholder: "Question, e.g. Are you at least 18 years of age?",
411
+ onChange: (s) => y(s.target.value)
412
+ }
413
+ ),
414
+ /* @__PURE__ */ i("div", { className: "jp-questions__answer", children: [
415
+ /* @__PURE__ */ e(
416
+ "input",
417
+ {
418
+ type: "text",
419
+ value: C,
420
+ placeholder: "Answer",
421
+ onChange: (s) => A(s.target.value),
422
+ onKeyDown: (s) => {
423
+ s.key === "Enter" && T();
424
+ }
425
+ }
426
+ ),
427
+ /* @__PURE__ */ e(
428
+ "button",
429
+ {
430
+ type: "button",
431
+ className: "jp-drawer__cta",
432
+ onClick: () => {
433
+ T();
434
+ },
435
+ disabled: E || !m.trim(),
436
+ children: E ? "Saving…" : "Save"
437
+ }
438
+ )
439
+ ] })
440
+ ] }),
441
+ n && /* @__PURE__ */ e("ul", { className: "jp-questions__saved", children: l.map((s) => /* @__PURE__ */ i("li", { children: [
442
+ /* @__PURE__ */ e("span", { className: "jp-questions__q", children: s.question }),
443
+ /* @__PURE__ */ e("span", { className: "jp-questions__saved-value", children: s.answer === "" ? /* @__PURE__ */ e("em", { children: "(left blank)" }) : s.answer }),
444
+ /* @__PURE__ */ e(
445
+ "button",
446
+ {
447
+ type: "button",
448
+ className: "jp-questions__forget",
449
+ onClick: () => {
450
+ G(s.question_key);
451
+ },
452
+ children: "Forget"
453
+ }
454
+ )
455
+ ] }, s.question_key)) })
456
+ ] });
457
+ }
458
+ const ae = 1e4, le = 15 * 6e4;
459
+ function ce(r, t) {
460
+ const o = Math.round((t - new Date(r).getTime()) / 6e4);
461
+ return o < 1 ? "just now" : o < 60 ? `${o} min ago` : `${Math.round(o / 60)} h ago`;
462
+ }
463
+ function P({ auth: r }) {
464
+ const [t, o] = _([]), [c, l] = _(null), [g, b] = _(!1), [k, f] = _(null), [h, j] = _(() => Date.now());
465
+ V(() => {
466
+ let u = !1;
467
+ async function x() {
468
+ if (document.visibilityState === "visible")
469
+ try {
470
+ const a = await Z(r);
471
+ if (u) return;
472
+ o(a), l(null), j(Date.now());
473
+ } catch (a) {
474
+ if (u) return;
475
+ a instanceof S && a.status === 403 ? b(!0) : l(a instanceof S ? a.message : "Could not read the mail feed");
476
+ }
477
+ }
478
+ x();
479
+ const n = window.setInterval(() => {
480
+ x();
481
+ }, ae);
482
+ return () => {
483
+ u = !0, window.clearInterval(n);
484
+ };
485
+ }, [r]);
486
+ async function d(u) {
487
+ if (u.code)
488
+ try {
489
+ await navigator.clipboard.writeText(u.code), f(u.id);
490
+ } catch {
491
+ l("Copy failed — select the code and copy it by hand");
492
+ }
493
+ }
494
+ return g || !t.length && !c ? null : /* @__PURE__ */ i("section", { className: "jp-codes", "aria-live": "polite", children: [
495
+ /* @__PURE__ */ e("h3", { children: "Verification codes" }),
496
+ c && /* @__PURE__ */ e("p", { className: "jp-error", children: c }),
497
+ /* @__PURE__ */ e("ul", { className: "jp-codes__list", children: t.map((u) => {
498
+ const x = h - new Date(u.received_at).getTime() > le;
499
+ return /* @__PURE__ */ i("li", { className: `jp-codes__row${x ? " jp-codes__row--stale" : ""}`, children: [
500
+ /* @__PURE__ */ e("span", { className: "jp-codes__company", children: u.company ?? u.subject }),
501
+ u.code ? /* @__PURE__ */ e(
502
+ "button",
503
+ {
504
+ type: "button",
505
+ className: "jp-codes__code",
506
+ onClick: () => {
507
+ d(u);
508
+ },
509
+ title: "Copy",
510
+ children: u.code
511
+ }
512
+ ) : /* @__PURE__ */ e("pre", { className: "jp-codes__text", children: u.text }),
513
+ /* @__PURE__ */ i("span", { className: "jp-codes__meta", children: [
514
+ k === u.id ? "copied · " : "",
515
+ ce(u.received_at, h),
516
+ x ? " · probably expired" : ""
517
+ ] })
518
+ ] }, u.id);
519
+ }) })
520
+ ] });
521
+ }
522
+ const ue = `"use strict";
523
+ (() => {
524
+ // extension/src/background.ts
525
+ var DEFAULT_API = "https://hadoku.me/jobplatform/api";
526
+ async function settings() {
527
+ const s = await chrome.storage.local.get(["apiBase", "apiKey"]);
528
+ return {
529
+ api: typeof s.apiBase === "string" && s.apiBase ? s.apiBase : DEFAULT_API,
530
+ key: typeof s.apiKey === "string" && s.apiKey ? s.apiKey : null
531
+ };
532
+ }
533
+ async function api(path, init = {}) {
534
+ const { api: base, key } = await settings();
535
+ const headers = new Headers(init.headers);
536
+ if (key) headers.set("X-User-Key", key);
537
+ if (init.body) headers.set("Content-Type", "application/json");
538
+ const res = await fetch(\`\${base}\${path}\`, { ...init, headers, credentials: "include" });
539
+ const body = await res.json().catch(() => null);
540
+ if (!res.ok || !body?.success) {
541
+ throw new Error(body?.message ?? \`hadoku.me answered \${res.status}\`);
542
+ }
543
+ return body.data;
544
+ }
545
+ async function pdf(url) {
546
+ const res = await fetch(url);
547
+ if (!res.ok) throw new Error(\`r\\xE9sum\\xE9 PDF answered \${res.status}\`);
548
+ const bytes = new Uint8Array(await res.arrayBuffer());
549
+ let binary = "";
550
+ for (let i = 0; i < bytes.length; i += 32768) {
551
+ binary += String.fromCharCode(...bytes.subarray(i, i + 32768));
552
+ }
553
+ return btoa(binary);
554
+ }
555
+ var NO_SESSION = { active: false, current: null, sent: [], skipped: [] };
556
+ async function session() {
557
+ const s = await chrome.storage.session.get("session");
558
+ return s.session ?? NO_SESSION;
559
+ }
560
+ async function saveSession(s) {
561
+ await chrome.storage.session.set({ session: s });
562
+ return s;
563
+ }
564
+ async function ready(s) {
565
+ const { applications } = await api("/applications");
566
+ const rank = (st) => st === "approved" ? 0 : st === "filled" ? 1 : -1;
567
+ return applications.filter((a) => rank(a.status) >= 0 && !s.sent.includes(a.job_id) && !s.skipped.includes(a.job_id)).sort((a, b) => rank(a.status) - rank(b.status) || a.updated_at.localeCompare(b.updated_at));
568
+ }
569
+ async function next(done) {
570
+ const s = await session();
571
+ if (s.current) (done === "sent" ? s.sent : s.skipped).push(s.current);
572
+ const queue = (await ready(s)).filter((a) => a.job_id !== s.current);
573
+ const up = queue[0];
574
+ await saveSession({ ...s, current: up?.job_id ?? null, active: !!up });
575
+ return up ? {
576
+ job_id: up.job_id,
577
+ form_url: up.form_url,
578
+ company: up.company,
579
+ title: up.title,
580
+ remaining: queue.length - 1
581
+ } : null;
582
+ }
583
+ async function handle(req) {
584
+ switch (req.type) {
585
+ case "packet":
586
+ return api(\`/jobs/\${encodeURIComponent(req.jobId)}/fill-packet\`);
587
+ case "pdf":
588
+ return pdf(req.url);
589
+ case "codes":
590
+ return (await api("/verification-codes")).codes;
591
+ case "markSent":
592
+ return api(\`/applications/\${encodeURIComponent(req.applicationId)}/status\`, {
593
+ method: "POST",
594
+ body: JSON.stringify({ status: "submitted" })
595
+ });
596
+ case "sessionStart":
597
+ return saveSession({ active: true, current: req.jobId, sent: [], skipped: [] });
598
+ case "sessionState": {
599
+ const s = await session();
600
+ return {
601
+ ...s,
602
+ remaining: s.active ? (await ready(s)).filter((a) => a.job_id !== s.current).length : 0
603
+ };
604
+ }
605
+ case "sessionStop":
606
+ return saveSession(NO_SESSION);
607
+ case "sessionNext":
608
+ return next(req.done);
609
+ }
610
+ }
611
+ chrome.runtime.onMessage.addListener((req, _sender, sendResponse) => {
612
+ handle(req).then(
613
+ (data) => sendResponse({ ok: true, data }),
614
+ (err) => sendResponse({
615
+ ok: false,
616
+ error: err instanceof Error ? err.message : String(err)
617
+ })
618
+ );
619
+ return true;
620
+ });
621
+ })();
622
+ `, pe = `"use strict";
623
+ (() => {
624
+ // extension/src/ats.ts
625
+ function pageJob(href) {
626
+ const url = new URL(href);
627
+ const host = url.hostname;
628
+ if (host.endsWith("greenhouse.io")) {
629
+ const id = url.searchParams.get("token") ?? /\\/jobs\\/(\\d+)/.exec(url.pathname)?.[1];
630
+ return id ? { ats: "greenhouse", jobId: \`greenhouse_\${id}\` } : null;
631
+ }
632
+ const uuid = /\\/[^/]+\\/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})/i.exec(
633
+ url.pathname
634
+ )?.[1];
635
+ if (!uuid) return null;
636
+ if (host === "jobs.ashbyhq.com") return { ats: "ashby", jobId: \`ashby_\${uuid}\` };
637
+ if (host === "jobs.lever.co") return { ats: "lever", jobId: \`lever_\${uuid}\` };
638
+ return null;
639
+ }
640
+
641
+ // src/components/matchOption.ts
642
+ function normalize(text2) {
643
+ return text2.replace(/\\*/g, " ").toLowerCase().replace(/n't\\b/g, " not ").replace(/[^a-z0-9]+/g, " ").trim();
644
+ }
645
+ var US_NAMES = /* @__PURE__ */ new Set([
646
+ "us",
647
+ "u s",
648
+ "usa",
649
+ "u s a",
650
+ "america",
651
+ "united states",
652
+ "united states of america",
653
+ "the united states",
654
+ "the united states of america"
655
+ ]);
656
+ function matchOption(answer, options) {
657
+ const a = answer.trim();
658
+ if (!a) return null;
659
+ if (options.length === 0) return a;
660
+ const na = normalize(a);
661
+ const exact = options.filter((o) => normalize(o) === na);
662
+ if (exact.length === 1) return exact[0] ?? null;
663
+ if (US_NAMES.has(na)) {
664
+ const us = options.filter((o) => US_NAMES.has(normalize(o).replace(/( [0-9]+)+$/, "")));
665
+ if (us.length === 1) return us[0] ?? null;
666
+ }
667
+ const lead = na.split(" ")[0];
668
+ if (lead === "yes" || lead === "no") {
669
+ const same = options.filter((o) => normalize(o).split(" ")[0] === lead);
670
+ return same.length === 1 ? same[0] ?? null : null;
671
+ }
672
+ const within = (hay, needle) => \` \${hay} \`.includes(\` \${needle} \`);
673
+ const hits = options.filter((o) => {
674
+ const no = normalize(o);
675
+ return within(no, na) || within(na, no);
676
+ });
677
+ return hits.length === 1 ? hits[0] ?? null : null;
678
+ }
679
+
680
+ // extension/src/dom.ts
681
+ var sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
682
+ async function waitFor(probe, timeoutMs = 3e3, stepMs = 100) {
683
+ const end = Date.now() + timeoutMs;
684
+ for (; ; ) {
685
+ const hit = probe();
686
+ if (hit) return hit;
687
+ if (Date.now() > end) return null;
688
+ await sleep(stepMs);
689
+ }
690
+ }
691
+ function cleanLabel(text2) {
692
+ return text2.replace(/\\s+/g, " ").replace(/[\\s*✱]+$/u, "").trim();
693
+ }
694
+ function setValue(el2, value) {
695
+ const proto = el2 instanceof HTMLTextAreaElement ? HTMLTextAreaElement.prototype : HTMLInputElement.prototype;
696
+ Object.getOwnPropertyDescriptor(proto, "value")?.set?.call(el2, value);
697
+ el2.dispatchEvent(new Event("input", { bubbles: true }));
698
+ el2.dispatchEvent(new Event("change", { bubbles: true }));
699
+ }
700
+ function typeWithKeys(el2, value) {
701
+ el2.focus();
702
+ setValue(el2, value);
703
+ const key = value.slice(-1) || " ";
704
+ for (const type of ["keydown", "keypress", "keyup"]) {
705
+ el2.dispatchEvent(new KeyboardEvent(type, { key, bubbles: true }));
706
+ }
707
+ }
708
+ function typeInto(el2, value) {
709
+ el2.focus();
710
+ setValue(el2, value);
711
+ el2.dispatchEvent(new FocusEvent("blur", { bubbles: true }));
712
+ }
713
+ function press(el2) {
714
+ for (const type of ["pointerdown", "mousedown", "pointerup", "mouseup"]) {
715
+ el2.dispatchEvent(new MouseEvent(type, { bubbles: true, cancelable: true }));
716
+ }
717
+ ;
718
+ el2.click();
719
+ }
720
+ function attachFile(input, file) {
721
+ const dt = new DataTransfer();
722
+ dt.items.add(file);
723
+ input.files = dt.files;
724
+ input.dispatchEvent(new Event("input", { bubbles: true }));
725
+ input.dispatchEvent(new Event("change", { bubbles: true }));
726
+ }
727
+ function labelFor(el2) {
728
+ const id = el2.getAttribute("id");
729
+ if (id) {
730
+ const l = document.querySelector(\`label[for="\${CSS.escape(id)}"]\`);
731
+ if (l?.textContent) return cleanLabel(l.textContent);
732
+ }
733
+ const by = el2.getAttribute("aria-labelledby");
734
+ if (by) {
735
+ const l = document.getElementById(by.split(" ")[0] ?? "");
736
+ if (l?.textContent) return cleanLabel(l.textContent);
737
+ }
738
+ const wrap = el2.closest("label");
739
+ return wrap?.textContent ? cleanLabel(wrap.textContent) : "";
740
+ }
741
+ function visible(el2) {
742
+ return el2.getClientRects().length > 0;
743
+ }
744
+
745
+ // extension/src/messages.ts
746
+ function ask(req) {
747
+ return chrome.runtime.sendMessage(req);
748
+ }
749
+
750
+ // extension/src/answers.ts
751
+ var PROFILE_FIELDS = {
752
+ "first name": (p) => p.name.split(" ")[0],
753
+ "legal first name": (p) => p.name.split(" ")[0],
754
+ "last name": (p) => p.name.split(" ").slice(1).join(" ") || p.name,
755
+ "last name surname": (p) => p.name.split(" ").slice(1).join(" ") || p.name,
756
+ "legal last name": (p) => p.name.split(" ").slice(1).join(" ") || p.name,
757
+ surname: (p) => p.name.split(" ").slice(1).join(" ") || p.name,
758
+ name: (p) => p.name,
759
+ "full name": (p) => p.name,
760
+ "legal name": (p) => p.name,
761
+ email: (p) => p.email,
762
+ "email address": (p) => p.email,
763
+ phone: (p) => p.phone,
764
+ "phone number": (p) => p.phone,
765
+ linkedin: (p) => p.linkedin,
766
+ "linkedin profile": (p) => p.linkedin,
767
+ "linkedin url": (p) => p.linkedin,
768
+ "linkedin profile url": (p) => p.linkedin,
769
+ github: (p) => p.github,
770
+ "github url": (p) => p.github,
771
+ "github profile": (p) => p.github
772
+ };
773
+ function answerFor(packet, question) {
774
+ const key = normalize(question);
775
+ if (!key) return null;
776
+ const approved = packet.answers[key];
777
+ if (typeof approved === "string" && approved) return approved;
778
+ for (const [q, a] of Object.entries(packet.standing)) {
779
+ if (normalize(q) === key && a) return a;
780
+ }
781
+ const field2 = packet.profile ? PROFILE_FIELDS[key]?.(packet.profile) : void 0;
782
+ return field2?.trim() ? field2.trim() : null;
783
+ }
784
+ function isMulti(packet, question) {
785
+ return packet.multi.includes(normalize(question));
786
+ }
787
+ function splitAnswer(answer) {
788
+ return answer.includes(" | ") ? answer.split(" | ").map((v) => v.trim()).filter(Boolean) : [answer];
789
+ }
790
+ var AFFIRMATIVE = /* @__PURE__ */ new Set(["yes", "y", "true", "agree", "i agree", "i consent", "consent"]);
791
+
792
+ // extension/src/fill/common.ts
793
+ function newReport() {
794
+ return { filled: [], unanswered: [], optional: [], refused: [] };
795
+ }
796
+ function isRequired(group) {
797
+ if (group.querySelector('[required], [aria-required="true"], .required')) return true;
798
+ const label = group.querySelector("label, legend, .application-label")?.textContent ?? "";
799
+ return /[*✱]\\s*$/u.test(label.trim());
800
+ }
801
+ function fillable(group) {
802
+ return !!group.querySelector(
803
+ 'input:not([type="hidden"]):not([type="file"]), textarea, select, button.ashby-application-form-input-yesno-option'
804
+ );
805
+ }
806
+ function noAnswer(report, group, question) {
807
+ if (isRequired(group)) report.unanswered.push(question);
808
+ else report.optional.push(question);
809
+ }
810
+ function menuOptions(input) {
811
+ const id = input.id;
812
+ const own = id ? document.querySelectorAll(\`[id^="react-select-\${CSS.escape(id)}-option-"]\`) : [];
813
+ if (own.length) return [...own];
814
+ return [
815
+ ...document.querySelectorAll('[role="listbox"] [role="option"], [id*="-option-"]')
816
+ ].filter(visible);
817
+ }
818
+ function optionConsistent(intended, shown) {
819
+ const a = intended.trim().toLowerCase();
820
+ const b = shown.trim().toLowerCase();
821
+ if (!b) return false;
822
+ if (a === b) return true;
823
+ const esc = a.replace(/[.*+?^\${}()|[\\]\\\\]/g, "\\\\$&");
824
+ if (new RegExp(\`\\\\b\${esc}\\\\b\`).test(b)) return true;
825
+ const want = a.match(/[a-z0-9]+/g) ?? [];
826
+ const have = b.match(/[a-z0-9]+/g) ?? [];
827
+ if (!want.length || !have.includes(want[0] ?? "")) return false;
828
+ return want.slice(1).every((t) => have.some((w) => w.startsWith(t)));
829
+ }
830
+ async function commitCombobox(input, value) {
831
+ const attempts = [
832
+ { query: value, firstOk: true },
833
+ { query: "", firstOk: false }
834
+ ];
835
+ for (const { query, firstOk } of attempts) {
836
+ input.focus();
837
+ if (query) {
838
+ press(input);
839
+ setValue(input, query);
840
+ } else {
841
+ setValue(input, "");
842
+ await sleep(300);
843
+ if (!menuOptions(input).length) press(input);
844
+ }
845
+ const opts = await waitFor(() => {
846
+ const o = menuOptions(input);
847
+ return o.length ? o : null;
848
+ }, 4e3);
849
+ if (!opts) continue;
850
+ const texts = opts.map((o) => (o.textContent ?? "").trim());
851
+ let pick = matchOption(value, texts);
852
+ if (pick === null && firstOk && texts[0] !== void 0 && optionConsistent(value, texts[0])) {
853
+ pick = texts[0];
854
+ }
855
+ if (pick === null) continue;
856
+ const el2 = opts[texts.indexOf(pick)];
857
+ if (!el2) continue;
858
+ press(el2);
859
+ await sleep(150);
860
+ return true;
861
+ }
862
+ setValue(input, "");
863
+ input.blur();
864
+ return false;
865
+ }
866
+ async function answerControl(group, answer, multi) {
867
+ const combo2 = group.querySelector('input[role="combobox"]');
868
+ if (combo2) {
869
+ const values = multi ? splitAnswer(answer) : [answer];
870
+ for (const v of values) if (!await commitCombobox(combo2, v)) return false;
871
+ return true;
872
+ }
873
+ const select = group.querySelector("select");
874
+ if (select) {
875
+ const opts = [...select.options].filter((o) => o.value);
876
+ const pick = matchOption(
877
+ answer,
878
+ opts.map((o) => o.text.trim())
879
+ );
880
+ const opt = opts.find((o) => o.text.trim() === pick);
881
+ if (!opt) return false;
882
+ select.value = opt.value;
883
+ select.dispatchEvent(new Event("change", { bubbles: true }));
884
+ return true;
885
+ }
886
+ const boxes = [
887
+ ...group.querySelectorAll('input[type="checkbox"], input[type="radio"]')
888
+ ];
889
+ if (boxes.length === 1 && boxes[0]?.type === "checkbox") {
890
+ if (!AFFIRMATIVE.has(normalize(answer))) return false;
891
+ if (!boxes[0].checked) press(boxes[0]);
892
+ return boxes[0].checked;
893
+ }
894
+ if (boxes.length) {
895
+ const labelled = boxes.map((b) => ({ b, text: optionLabel(b) }));
896
+ const values = splitAnswer(answer);
897
+ const picks = values.map(
898
+ (v) => matchOption(
899
+ v,
900
+ labelled.map((l) => l.text)
901
+ )
902
+ );
903
+ if (picks.some((p) => p === null)) return false;
904
+ for (const { b, text: text2 } of labelled) {
905
+ if (picks.includes(text2) && !b.checked) press(b.closest("label") ?? b);
906
+ }
907
+ return labelled.filter((l) => picks.includes(l.text)).every((l) => l.b.checked);
908
+ }
909
+ const area = group.querySelector("textarea");
910
+ if (area) {
911
+ typeInto(area, answer);
912
+ return true;
913
+ }
914
+ const box = group.querySelector(
915
+ 'input[type="text"], input[type="email"], input[type="tel"], input[type="url"], input[type="number"], input:not([type])'
916
+ );
917
+ if (box) {
918
+ typeInto(box, answer);
919
+ return true;
920
+ }
921
+ return false;
922
+ }
923
+ function optionLabel(input) {
924
+ const byFor = input.id ? document.querySelector(\`label[for="\${CSS.escape(input.id)}"]\`) : null;
925
+ const text2 = (byFor ?? input.closest("label"))?.textContent ?? "";
926
+ return text2.replace(/\\s+/g, " ").trim() || input.value;
927
+ }
928
+ function requiredEmpty(labelOf) {
929
+ const out = /* @__PURE__ */ new Set();
930
+ const seenGroups = /* @__PURE__ */ new Set();
931
+ for (const el2 of document.querySelectorAll("input, textarea, select")) {
932
+ if (el2 instanceof HTMLInputElement && (el2.type === "file" || el2.type === "hidden")) continue;
933
+ if (el2.disabled || !visible(el2.closest("div") ?? el2)) continue;
934
+ const native = el2.willValidate && el2.validity.valueMissing;
935
+ const aria = el2.getAttribute("aria-required") === "true" && el2.getAttribute("role") !== "combobox" && !String(el2.value).trim();
936
+ if (!native && !aria) continue;
937
+ if (el2 instanceof HTMLInputElement && (el2.type === "radio" || el2.type === "checkbox") && el2.name) {
938
+ if (seenGroups.has(el2.name)) continue;
939
+ seenGroups.add(el2.name);
940
+ const group = document.querySelectorAll(
941
+ \`input[name="\${CSS.escape(el2.name)}"]\`
942
+ );
943
+ if ([...group].some((b) => b.checked)) continue;
944
+ }
945
+ const label = labelOf(el2);
946
+ if (label) out.add(label);
947
+ }
948
+ return [...out];
949
+ }
950
+
951
+ // extension/src/fill/greenhouse.ts
952
+ var GROUPS = ".field-wrapper, .eeoc__question__wrapper .select, .application--form fieldset, .demographic--container .select, .application--form > .checkbox";
953
+ var MONTHS = [
954
+ "January",
955
+ "February",
956
+ "March",
957
+ "April",
958
+ "May",
959
+ "June",
960
+ "July",
961
+ "August",
962
+ "September",
963
+ "October",
964
+ "November",
965
+ "December"
966
+ ];
967
+ function month(m) {
968
+ const n = Number(m);
969
+ return Number.isInteger(n) && n >= 1 && n <= 12 ? MONTHS[n - 1] ?? "" : String(m ?? "");
970
+ }
971
+ function byId(id) {
972
+ return document.getElementById(id);
973
+ }
974
+ function text(id, value, report, done) {
975
+ const el2 = byId(id);
976
+ if (!el2 || value === void 0 || value === "") return;
977
+ typeInto(el2, String(value));
978
+ done.add(normalize(labelFor(el2)));
979
+ report.filled.push(labelFor(el2) || id);
980
+ }
981
+ async function combo(id, value, report, done) {
982
+ const el2 = byId(id);
983
+ if (!el2 || !value) return;
984
+ const label = labelFor(el2) || id;
985
+ done.add(normalize(label));
986
+ if (await commitCombobox(el2, value)) report.filled.push(label);
987
+ else report.refused.push(\`\${label}: \\u201C\${value}\\u201D\`);
988
+ }
989
+ async function fillGreenhouse(packet, resume, report) {
990
+ const p = packet.profile;
991
+ const done = /* @__PURE__ */ new Set();
992
+ if (p) {
993
+ const [first, ...rest] = p.name.split(" ");
994
+ text("first_name", first, report, done);
995
+ text("last_name", rest.join(" ") || first, report, done);
996
+ text("email", p.email, report, done);
997
+ text("phone", p.phone, report, done);
998
+ }
999
+ if (resume) {
1000
+ const input = document.querySelector('input[type="file"]#resume') ?? document.querySelector('input[type="file"][id*="resume" i]');
1001
+ if (input) {
1002
+ attachFile(input, resume);
1003
+ report.filled.push("R\\xE9sum\\xE9");
1004
+ done.add(normalize(labelFor(input) || "resume"));
1005
+ }
1006
+ }
1007
+ for (const [i, job] of (p?.work_experience ?? []).entries()) {
1008
+ if (!byId(\`company-name-\${i}\`)) break;
1009
+ text(\`company-name-\${i}\`, job.company, report, done);
1010
+ text(\`title-\${i}\`, job.title, report, done);
1011
+ await combo(\`start-date-month-\${i}\`, month(job.start_month), report, done);
1012
+ text(\`start-date-year-\${i}\`, job.start_year, report, done);
1013
+ const current = byId(\`current-role-\${i}_1\`);
1014
+ if (job.current && current) {
1015
+ if (!current.checked) current.click();
1016
+ done.add(normalize(labelFor(current)));
1017
+ } else if (!job.current) {
1018
+ await combo(\`end-date-month-\${i}\`, month(job.end_month), report, done);
1019
+ text(\`end-date-year-\${i}\`, job.end_year, report, done);
1020
+ }
1021
+ }
1022
+ for (const [i, school] of (p?.education ?? []).entries()) {
1023
+ if (!byId(\`school--\${i}\`)) break;
1024
+ await combo(\`school--\${i}\`, school.school, report, done);
1025
+ await combo(\`degree--\${i}\`, school.degree, report, done);
1026
+ await combo(\`discipline--\${i}\`, school.discipline, report, done);
1027
+ for (const [edge, year, verb] of [
1028
+ ["start", school.start_year, "start at"],
1029
+ ["end", school.end_year, "graduate from"]
1030
+ ]) {
1031
+ const id = byId(\`\${edge}-year--\${i}\`) ? \`\${edge}-year--\${i}\` : \`\${edge}-date-year--\${i}\`;
1032
+ const value = year ?? answerFor(packet, \`What year did you \${verb} \${school.school}?\`) ?? void 0;
1033
+ text(id, value, report, done);
1034
+ }
1035
+ }
1036
+ for (const group of document.querySelectorAll(GROUPS)) {
1037
+ if (!visible(group)) continue;
1038
+ const labelEl = group.querySelector("label, legend");
1039
+ const question = cleanLabel(labelEl?.textContent ?? "");
1040
+ const key = normalize(question);
1041
+ if (!key || done.has(key)) continue;
1042
+ done.add(key);
1043
+ if (group.querySelector('input[type="file"]') || !fillable(group)) continue;
1044
+ const answer = answerFor(packet, question);
1045
+ if (answer === null) {
1046
+ noAnswer(report, group, question);
1047
+ continue;
1048
+ }
1049
+ if (await answerControl(group, answer, isMulti(packet, question))) report.filled.push(question);
1050
+ else report.refused.push(\`\${question}: \\u201C\${answer}\\u201D\`);
1051
+ }
1052
+ for (const label of requiredEmpty((el2) => {
1053
+ const g = el2.closest(GROUPS);
1054
+ return cleanLabel(g?.querySelector("label, legend")?.textContent ?? labelFor(el2));
1055
+ })) {
1056
+ if (!report.unanswered.includes(label) && !report.refused.some((r) => r.startsWith(\`\${label}:\`))) {
1057
+ report.unanswered.push(label);
1058
+ }
1059
+ }
1060
+ }
1061
+
1062
+ // extension/src/fill/ashby.ts
1063
+ var ENTRIES = ".ashby-application-form-field-entry, fieldset";
1064
+ function titleOf(entry) {
1065
+ const t = entry.querySelector(".ashby-application-form-question-title, label, legend");
1066
+ return cleanLabel(t?.textContent ?? "");
1067
+ }
1068
+ async function location2(entry, value) {
1069
+ const input = entry.querySelector('input[role="combobox"], input[type="text"]');
1070
+ if (!input) return false;
1071
+ typeInto(input, value);
1072
+ input.focus();
1073
+ const opts = await waitFor(() => {
1074
+ const o = [...document.querySelectorAll('[role="option"]')].filter(visible);
1075
+ return o.length ? o : null;
1076
+ }, 5e3);
1077
+ if (!opts) return false;
1078
+ const texts = opts.map((o) => (o.textContent ?? "").trim());
1079
+ const city = normalize(value.split(",")[0] ?? value);
1080
+ const pick = matchOption(value, texts) ?? texts.find((t) => normalize(t).startsWith(city)) ?? null;
1081
+ const el2 = pick === null ? null : opts[texts.indexOf(pick)];
1082
+ if (!el2) return false;
1083
+ press(el2);
1084
+ return true;
1085
+ }
1086
+ async function fillAshby(packet, resume, report) {
1087
+ const done = /* @__PURE__ */ new Set();
1088
+ for (const entry of document.querySelectorAll(ENTRIES)) {
1089
+ if (!visible(entry)) continue;
1090
+ const question = titleOf(entry);
1091
+ const key = normalize(question);
1092
+ if (!key || done.has(key)) continue;
1093
+ done.add(key);
1094
+ if (key === "resume" || key === "resume cv") {
1095
+ const input = entry.querySelector('input[type="file"]');
1096
+ if (input && resume) {
1097
+ attachFile(input, resume);
1098
+ report.filled.push(question);
1099
+ }
1100
+ continue;
1101
+ }
1102
+ if (key === "location" && packet.profile?.location) {
1103
+ if (await location2(entry, packet.profile.location)) report.filled.push(question);
1104
+ else report.refused.push(\`\${question}: \\u201C\${packet.profile.location}\\u201D\`);
1105
+ continue;
1106
+ }
1107
+ if (!fillable(entry)) continue;
1108
+ const answer = answerFor(packet, question);
1109
+ if (answer === null) {
1110
+ noAnswer(report, entry, question);
1111
+ continue;
1112
+ }
1113
+ const yesno = entry.querySelectorAll(
1114
+ "button.ashby-application-form-input-yesno-option"
1115
+ );
1116
+ if (yesno.length) {
1117
+ const pick = matchOption(answer, ["Yes", "No"]);
1118
+ const button = pick ? entry.querySelector(\`button[data-option="\${pick.toLowerCase()}"]\`) : null;
1119
+ if (button) {
1120
+ press(button);
1121
+ report.filled.push(question);
1122
+ } else report.refused.push(\`\${question}: \\u201C\${answer}\\u201D\`);
1123
+ continue;
1124
+ }
1125
+ if (await answerControl(entry, answer, isMulti(packet, question))) report.filled.push(question);
1126
+ else report.refused.push(\`\${question}: \\u201C\${answer}\\u201D\`);
1127
+ }
1128
+ for (const label of requiredEmpty((el2) => titleOf(el2.closest(ENTRIES) ?? el2))) {
1129
+ if (!report.unanswered.includes(label) && !report.refused.some((r) => r.startsWith(\`\${label}:\`))) {
1130
+ report.unanswered.push(label);
1131
+ }
1132
+ }
1133
+ }
1134
+
1135
+ // extension/src/fill/lever.ts
1136
+ var QUESTIONS = ".application-question";
1137
+ function questionOf(q) {
1138
+ const t = q.querySelector(".application-label .text, .application-label, label");
1139
+ return cleanLabel((t?.firstChild?.textContent ?? t?.textContent ?? "").replace("\\u2731", ""));
1140
+ }
1141
+ function field(name) {
1142
+ return document.querySelector(\`input[name="\${CSS.escape(name)}"]\`);
1143
+ }
1144
+ async function location3(value) {
1145
+ const input = field("location");
1146
+ if (!input) return false;
1147
+ const city = value.split(",")[0]?.trim() ?? value;
1148
+ typeWithKeys(input, city);
1149
+ const opts = await waitFor(() => {
1150
+ const o = [...document.querySelectorAll(".dropdown-location")].filter(visible);
1151
+ return o.length ? o : null;
1152
+ }, 6e3);
1153
+ if (!opts) return false;
1154
+ const texts = opts.map((o) => (o.textContent ?? "").trim());
1155
+ const sameCity = texts.filter((t) => normalize(t).startsWith(normalize(city)));
1156
+ const pick = sameCity.length === 1 ? sameCity[0] : matchOption(value, texts) ?? sameCity[0] ?? null;
1157
+ const el2 = pick === void 0 || pick === null ? null : opts[texts.indexOf(pick)];
1158
+ if (!el2) return false;
1159
+ press(el2);
1160
+ const chosen = await waitFor(
1161
+ () => document.querySelector("#selected-location")?.value ? true : null,
1162
+ 2e3
1163
+ );
1164
+ return chosen === true;
1165
+ }
1166
+ async function fillLever(packet, resume, report) {
1167
+ const p = packet.profile;
1168
+ const done = /* @__PURE__ */ new Set();
1169
+ const simple = [
1170
+ ["name", p?.name, "Full name"],
1171
+ ["email", p?.email, "Email"],
1172
+ ["phone", p?.phone, "Phone"],
1173
+ [
1174
+ "org",
1175
+ answerFor(packet, "Current company") ?? p?.work_experience?.find((w) => w.current)?.company,
1176
+ "Current company"
1177
+ ],
1178
+ ["urls[LinkedIn]", p?.linkedin, "LinkedIn URL"],
1179
+ ["urls[GitHub]", p?.github, "GitHub URL"]
1180
+ ];
1181
+ for (const [name, value, label] of simple) {
1182
+ const el2 = field(name);
1183
+ if (!el2 || !value) continue;
1184
+ typeInto(el2, value);
1185
+ report.filled.push(label);
1186
+ done.add(normalize(label));
1187
+ }
1188
+ if (resume) {
1189
+ const input = document.querySelector('input[type="file"][name="resume"]');
1190
+ if (input) {
1191
+ attachFile(input, resume);
1192
+ report.filled.push("R\\xE9sum\\xE9");
1193
+ }
1194
+ }
1195
+ if (p?.location && field("location")) {
1196
+ done.add("current location");
1197
+ if (await location3(p.location)) report.filled.push("Current location");
1198
+ else report.refused.push(\`Current location: \\u201C\${p.location}\\u201D (pick it from Lever's list)\`);
1199
+ }
1200
+ for (const q of document.querySelectorAll(QUESTIONS)) {
1201
+ if (!visible(q)) continue;
1202
+ const question = questionOf(q);
1203
+ const key = normalize(question);
1204
+ if (!key || done.has(key)) continue;
1205
+ if (!fillable(q) || q.querySelector('input[type="file"]')) continue;
1206
+ const filledAlready = [
1207
+ ...q.querySelectorAll('input[type="text"], input[type="email"]')
1208
+ ].some((i) => i.value);
1209
+ if (filledAlready) continue;
1210
+ done.add(key);
1211
+ const answer = answerFor(packet, question);
1212
+ if (answer === null) {
1213
+ noAnswer(report, q, question);
1214
+ continue;
1215
+ }
1216
+ if (await answerControl(q, answer, isMulti(packet, question))) report.filled.push(question);
1217
+ else report.refused.push(\`\${question}: \\u201C\${answer}\\u201D\`);
1218
+ }
1219
+ for (const label of requiredEmpty((el2) => questionOf(el2.closest(QUESTIONS) ?? el2))) {
1220
+ if (!report.unanswered.includes(label) && !report.refused.some((r) => r.startsWith(\`\${label}:\`))) {
1221
+ report.unanswered.push(label);
1222
+ }
1223
+ }
1224
+ }
1225
+
1226
+ // extension/src/content.ts
1227
+ var CONFIRMED = /thank you for (applying|your application)|thanks for applying|application (has been |was )?(submitted|received)|we('ve| have) received your application/i;
1228
+ var STYLE = \`
1229
+ :host { all: initial; }
1230
+ .panel { position: fixed; right: 16px; bottom: 16px; z-index: 2147483647; width: 320px;
1231
+ max-height: 70vh; overflow: auto; font: 13px/1.4 system-ui, sans-serif; color: #1d2433;
1232
+ background: #fbfaf7; border: 1px solid #c9c4b8; border-radius: 8px;
1233
+ box-shadow: 0 6px 24px rgba(0,0,0,.18); padding: 12px; }
1234
+ @media (prefers-color-scheme: dark) {
1235
+ .panel { color: #e8e6e1; background: #23262d; border-color: #444955; } }
1236
+ h1 { font-size: 13px; margin: 0 0 4px; }
1237
+ .job { opacity: .8; margin-bottom: 8px; }
1238
+ .row { display: flex; gap: 8px; margin: 8px 0; }
1239
+ button { font: inherit; padding: 6px 10px; border-radius: 6px; border: 1px solid #8a8577;
1240
+ background: transparent; color: inherit; cursor: pointer; }
1241
+ button.primary { background: #2f5d50; border-color: #2f5d50; color: #fff; }
1242
+ button:disabled { opacity: .5; cursor: default; }
1243
+ .code { font: 600 20px/1.2 ui-monospace, monospace; letter-spacing: .08em; }
1244
+ ul { margin: 4px 0 8px; padding-left: 18px; }
1245
+ .warn { color: #9a4b00; } .err { color: #b3261e; } .ok { color: #2f6b3a; }
1246
+ @media (prefers-color-scheme: dark) { .warn { color: #f0b46b; } .err { color: #f2a19a; } .ok { color: #9fd3a8; } }
1247
+ \`;
1248
+ function el(tag, props = {}, ...kids) {
1249
+ const node = Object.assign(document.createElement(tag), props);
1250
+ node.append(...kids);
1251
+ return node;
1252
+ }
1253
+ function list(title, items, cls) {
1254
+ const wrap = el("div", { className: cls });
1255
+ wrap.append(
1256
+ el("strong", {}, \`\${title} (\${items.length})\`),
1257
+ el("ul", {}, ...items.map((i) => el("li", {}, i)))
1258
+ );
1259
+ return wrap;
1260
+ }
1261
+ function decodePdf(base64, name) {
1262
+ const bin = atob(base64);
1263
+ const bytes = new Uint8Array(bin.length);
1264
+ for (let i = 0; i < bin.length; i++) bytes[i] = bin.charCodeAt(i);
1265
+ return new File([bytes], name, { type: "application/pdf" });
1266
+ }
1267
+ async function fill(job, packet) {
1268
+ let resume = null;
1269
+ if (packet.resume_pdf_url) {
1270
+ const pdf = await ask({ type: "pdf", url: packet.resume_pdf_url });
1271
+ if (pdf.ok) resume = decodePdf(pdf.data, \`\${packet.profile?.name ?? "Resume"} - Resume.pdf\`);
1272
+ }
1273
+ const report = newReport();
1274
+ if (job.ats === "greenhouse") await fillGreenhouse(packet, resume, report);
1275
+ else if (job.ats === "ashby") await fillAshby(packet, resume, report);
1276
+ else await fillLever(packet, resume, report);
1277
+ if (packet.resume_pdf_url && !resume) report.refused.push("R\\xE9sum\\xE9: the PDF could not be fetched");
1278
+ if (!packet.resume_pdf_url) {
1279
+ report.unanswered.push("R\\xE9sum\\xE9 \\u2014 no tailored r\\xE9sum\\xE9 was made for this job; attach one yourself");
1280
+ }
1281
+ return report;
1282
+ }
1283
+ async function advance(done, say) {
1284
+ const res = await ask({ type: "sessionNext", done });
1285
+ if (!res.ok) {
1286
+ say(\`Could not find the next one: \${res.error}\`, "err");
1287
+ return;
1288
+ }
1289
+ if (!res.data) {
1290
+ say("Session done \\u2014 nothing left to send.", "ok");
1291
+ return;
1292
+ }
1293
+ say(\`Next: \${res.data.company} \\u2014 \${res.data.title}\\u2026\`);
1294
+ location.href = res.data.form_url;
1295
+ }
1296
+ function mount(job, session) {
1297
+ const host = el("div", { id: "hadoku-fill" });
1298
+ const root = host.attachShadow({ mode: "open" });
1299
+ root.append(el("style", {}, STYLE));
1300
+ const panel = el("div", { className: "panel" });
1301
+ root.append(panel);
1302
+ document.documentElement.append(host);
1303
+ const keep = window.setInterval(() => {
1304
+ if (!host.isConnected) document.documentElement.append(host);
1305
+ }, 500);
1306
+ const status = el("div");
1307
+ const results = el("div");
1308
+ const codes = el("div");
1309
+ const fillBtn = el("button", { className: "primary", textContent: "Fill" });
1310
+ const sentBtn = el("button", { textContent: "Mark sent", disabled: true });
1311
+ const skipBtn = el("button", { textContent: "Skip" });
1312
+ const stopBtn = el("button", { textContent: "Stop session" });
1313
+ const closeBtn = el("button", { textContent: "\\xD7", title: "Hide" });
1314
+ const jobLine = el("div", { className: "job", textContent: "Loading your packet\\u2026" });
1315
+ const sessionLine = el("div", {
1316
+ className: "job",
1317
+ textContent: session ? \`Send session \\xB7 \${session.remaining} more after this one\` : ""
1318
+ });
1319
+ panel.append(
1320
+ el("h1", {}, "hadoku Fill"),
1321
+ ...session ? [sessionLine] : [],
1322
+ jobLine,
1323
+ el(
1324
+ "div",
1325
+ { className: "row" },
1326
+ fillBtn,
1327
+ sentBtn,
1328
+ ...session ? [skipBtn, stopBtn] : [closeBtn]
1329
+ ),
1330
+ status,
1331
+ results,
1332
+ codes
1333
+ );
1334
+ closeBtn.onclick = () => {
1335
+ window.clearInterval(keep);
1336
+ host.remove();
1337
+ };
1338
+ const say = (text2, cls = "") => {
1339
+ status.className = cls;
1340
+ status.textContent = text2;
1341
+ };
1342
+ let packet = null;
1343
+ let filled = false;
1344
+ let sent = false;
1345
+ async function markSent(auto) {
1346
+ if (sent || !packet?.application) return;
1347
+ sent = true;
1348
+ sentBtn.disabled = true;
1349
+ const res = await ask({ type: "markSent", applicationId: packet.application.id });
1350
+ if (!res.ok) {
1351
+ say(\`Could not mark it sent: \${res.error}\`, "err");
1352
+ return;
1353
+ }
1354
+ say(auto ? "The board confirmed it \\u2014 marked sent." : "Marked sent.", "ok");
1355
+ if (session) {
1356
+ await new Promise((r) => setTimeout(r, 1500));
1357
+ await advance("sent", say);
1358
+ }
1359
+ }
1360
+ async function runFill() {
1361
+ if (!packet) return;
1362
+ fillBtn.disabled = true;
1363
+ say("Filling\\u2026");
1364
+ try {
1365
+ const report = await fill(job, packet);
1366
+ filled = true;
1367
+ const gaps = report.unanswered.length || report.refused.length;
1368
+ say(
1369
+ gaps ? "Filled what it could \\u2014 check the items below, then Submit." : "Filled. Review the form, then press Submit.",
1370
+ gaps ? "warn" : "ok"
1371
+ );
1372
+ results.replaceChildren(
1373
+ ...report.refused.length ? [list("Couldn't enter", report.refused, "err")] : [],
1374
+ ...report.unanswered.length ? [list("Needs you", report.unanswered, "warn")] : [],
1375
+ ...report.optional.length ? [list("Left blank (optional)", report.optional, "")] : [],
1376
+ list("Filled", report.filled, "")
1377
+ );
1378
+ } catch (err) {
1379
+ say(\`Fill failed: \${err instanceof Error ? err.message : String(err)}\`, "err");
1380
+ } finally {
1381
+ fillBtn.disabled = false;
1382
+ }
1383
+ }
1384
+ void ask({ type: "packet", jobId: job.jobId }).then((res) => {
1385
+ if (!res.ok) {
1386
+ jobLine.textContent = \`No packet: \${res.error}\`;
1387
+ jobLine.className = "err";
1388
+ fillBtn.disabled = true;
1389
+ return;
1390
+ }
1391
+ packet = res.data;
1392
+ const app = packet.application;
1393
+ jobLine.textContent = \`\${packet.job.company} \\u2014 \${packet.job.title}\${app ? \` \\xB7 \${app.status}\` : " \\xB7 not queued"}\`;
1394
+ if (!packet.profile) {
1395
+ say("No applicant profile on hadoku yet \\u2014 only saved answers will be filled.", "warn");
1396
+ }
1397
+ sentBtn.disabled = !app || app.status === "submitted";
1398
+ if (session) void runFill();
1399
+ });
1400
+ fillBtn.onclick = () => void runFill();
1401
+ sentBtn.onclick = () => void markSent(false);
1402
+ skipBtn.onclick = () => void advance("skipped", say);
1403
+ stopBtn.onclick = async () => {
1404
+ await ask({ type: "sessionStop" });
1405
+ sessionLine.remove();
1406
+ skipBtn.remove();
1407
+ stopBtn.remove();
1408
+ say("Session stopped. This form stays filled.");
1409
+ };
1410
+ new MutationObserver(() => {
1411
+ if (filled && !sent && CONFIRMED.test(document.body.innerText)) void markSent(true);
1412
+ }).observe(document.body, { childList: true, subtree: true, characterData: true });
1413
+ if (job.ats === "greenhouse") {
1414
+ const poll = async () => {
1415
+ const res = await ask({ type: "codes" });
1416
+ if (!res.ok || !packet) return;
1417
+ const company = packet.job.company.toLowerCase();
1418
+ const mine = res.data.filter(
1419
+ (c) => !c.company || company.includes(c.company) || c.company.includes(company)
1420
+ );
1421
+ const latest = mine[0];
1422
+ if (!latest) {
1423
+ codes.replaceChildren();
1424
+ return;
1425
+ }
1426
+ const mins = Math.round((Date.now() - new Date(latest.received_at).getTime()) / 6e4);
1427
+ codes.replaceChildren(
1428
+ el("strong", {}, \`Verification code (\${mins < 1 ? "just now" : \`\${mins} min ago\`})\`),
1429
+ latest.code ? el("div", { className: "code" }, latest.code) : el("pre", {}, latest.text ?? "")
1430
+ );
1431
+ };
1432
+ void poll();
1433
+ setInterval(() => void poll(), 1e4);
1434
+ }
1435
+ }
1436
+ async function confirmedPage(current) {
1437
+ const packet = await ask({ type: "packet", jobId: current });
1438
+ const note = el("div", { id: "hadoku-fill" });
1439
+ note.setAttribute(
1440
+ "style",
1441
+ "position:fixed;right:16px;bottom:16px;z-index:2147483647;padding:10px 12px;border-radius:8px;background:#2f5d50;color:#fff;font:13px system-ui"
1442
+ );
1443
+ document.documentElement.append(note);
1444
+ const say = (text2) => {
1445
+ note.textContent = \`hadoku Fill: \${text2}\`;
1446
+ };
1447
+ if (packet.ok && packet.data.application) {
1448
+ const res = await ask({ type: "markSent", applicationId: packet.data.application.id });
1449
+ say(res.ok ? "confirmed and marked sent." : \`could not mark it sent: \${res.error}\`);
1450
+ }
1451
+ await new Promise((r) => setTimeout(r, 1500));
1452
+ await advance("sent", say);
1453
+ }
1454
+ async function start() {
1455
+ const job = pageJob(location.href);
1456
+ if (job && location.hash.includes("hadoku-session")) {
1457
+ await ask({ type: "sessionStart", jobId: job.jobId });
1458
+ }
1459
+ const state = await ask({ type: "sessionState" });
1460
+ const s = state.ok && state.data.active ? state.data : null;
1461
+ const confirmable = !!s?.current && (!job || job.jobId === s.current) && location.hostname.includes(s.current.split("_")[0] ?? "");
1462
+ const seen = await waitFor(
1463
+ () => document.querySelector('input[type="file"]') ? "form" : confirmable && CONFIRMED.test(document.body.innerText) ? "confirmed" : null,
1464
+ 2e4,
1465
+ 250
1466
+ );
1467
+ if (seen === "confirmed" && s?.current) await confirmedPage(s.current);
1468
+ else if (seen === "form" && job) mount(job, s?.current === job.jobId ? s : null);
1469
+ }
1470
+ void start();
1471
+ })();
1472
+ `, H = `{
1473
+ "manifest_version": 3,
1474
+ "name": "hadoku Fill",
1475
+ "version": "0.1.0",
1476
+ "description": "Fills Greenhouse, Ashby and Lever applications from your hadoku job packet. You review and submit.",
1477
+ "permissions": ["storage"],
1478
+ "host_permissions": [
1479
+ "https://hadoku.me/*",
1480
+ "https://job-boards.greenhouse.io/*",
1481
+ "https://boards.greenhouse.io/*",
1482
+ "https://jobs.ashbyhq.com/*",
1483
+ "https://jobs.lever.co/*"
1484
+ ],
1485
+ "background": { "service_worker": "background.js" },
1486
+ "content_scripts": [
1487
+ {
1488
+ "matches": [
1489
+ "https://job-boards.greenhouse.io/*",
1490
+ "https://boards.greenhouse.io/*",
1491
+ "https://jobs.ashbyhq.com/*",
1492
+ "https://jobs.lever.co/*"
1493
+ ],
1494
+ "js": ["content.js"],
1495
+ "all_frames": true,
1496
+ "run_at": "document_idle"
1497
+ }
1498
+ ]
1499
+ }
1500
+ `, de = (() => {
1501
+ const r = new Uint32Array(256);
1502
+ for (let t = 0; t < 256; t++) {
1503
+ let o = t;
1504
+ for (let c = 0; c < 8; c++) o = o & 1 ? 3988292384 ^ o >>> 1 : o >>> 1;
1505
+ r[t] = o >>> 0;
1506
+ }
1507
+ return r;
1508
+ })();
1509
+ function fe(r) {
1510
+ let t = 4294967295;
1511
+ for (const o of r) t = de[(t ^ o) & 255] ^ t >>> 8;
1512
+ return (t ^ 4294967295) >>> 0;
1513
+ }
1514
+ function he(r) {
1515
+ const t = new TextEncoder(), o = [], c = [];
1516
+ let l = 0;
1517
+ for (const j of r) {
1518
+ const d = t.encode(j.name), u = t.encode(j.text), x = fe(u), n = new Uint8Array(30 + d.length + u.length), a = new DataView(n.buffer);
1519
+ a.setUint32(0, 67324752, !0), a.setUint16(4, 20, !0), a.setUint16(6, 2048, !0), a.setUint16(8, 0, !0), a.setUint16(14, x & 65535, !0), a.setUint16(16, x >>> 16, !0), a.setUint32(18, u.length, !0), a.setUint32(22, u.length, !0), a.setUint16(26, d.length, !0), n.set(d, 30), n.set(u, 30 + d.length);
1520
+ const m = new Uint8Array(46 + d.length), y = new DataView(m.buffer);
1521
+ y.setUint32(0, 33639248, !0), y.setUint16(4, 20, !0), y.setUint16(6, 20, !0), y.setUint16(8, 2048, !0), y.setUint16(10, 0, !0), y.setUint32(16, x, !0), y.setUint32(20, u.length, !0), y.setUint32(24, u.length, !0), y.setUint16(28, d.length, !0), y.setUint32(42, l, !0), m.set(d, 46), o.push(n), c.push(m), l += n.length;
1522
+ }
1523
+ const g = c.reduce((j, d) => j + d.length, 0), b = new Uint8Array(22), k = new DataView(b.buffer);
1524
+ k.setUint32(0, 101010256, !0), k.setUint16(8, r.length, !0), k.setUint16(10, r.length, !0), k.setUint32(12, g, !0), k.setUint32(16, l, !0);
1525
+ const f = new Uint8Array(l + g + b.length);
1526
+ let h = 0;
1527
+ for (const j of [...o, ...c, b])
1528
+ f.set(j, h), h += j.length;
1529
+ return f;
1530
+ }
1531
+ const L = JSON.parse(H).version;
1532
+ function me() {
1533
+ const r = he([
1534
+ { name: "manifest.json", text: H },
1535
+ { name: "background.js", text: ue },
1536
+ { name: "content.js", text: pe }
1537
+ ]), t = URL.createObjectURL(new Blob([r], { type: "application/zip" })), o = document.createElement("a");
1538
+ o.href = t, o.download = `hadoku-fill-${L}.zip`, o.click(), setTimeout(() => URL.revokeObjectURL(t), 1e4);
1539
+ }
1540
+ function ye() {
1541
+ return /* @__PURE__ */ i("details", { className: "jp-fill-install", children: [
1542
+ /* @__PURE__ */ i("summary", { children: [
1543
+ "Install the hadoku Fill extension (v",
1544
+ L,
1545
+ ")"
1546
+ ] }),
1547
+ /* @__PURE__ */ e("p", { children: "Send sessions need it: it fills each form in your own Chrome. It never presses Submit or types a code." }),
1548
+ /* @__PURE__ */ i("ol", { children: [
1549
+ /* @__PURE__ */ i("li", { children: [
1550
+ /* @__PURE__ */ i(
1551
+ "button",
1552
+ {
1553
+ type: "button",
1554
+ className: "jp-fill-install__download",
1555
+ onClick: me,
1556
+ children: [
1557
+ "Download hadoku-fill-",
1558
+ L,
1559
+ ".zip"
1560
+ ]
1561
+ }
1562
+ ),
1563
+ " ",
1564
+ "and unzip it into a folder you'll keep — Chrome loads it from there."
1565
+ ] }),
1566
+ /* @__PURE__ */ i("li", { children: [
1567
+ "Open ",
1568
+ /* @__PURE__ */ e("code", { children: "chrome://extensions" }),
1569
+ " and turn on ",
1570
+ /* @__PURE__ */ e("strong", { children: "Developer mode" }),
1571
+ "."
1572
+ ] }),
1573
+ /* @__PURE__ */ i("li", { children: [
1574
+ "Press ",
1575
+ /* @__PURE__ */ e("strong", { children: "Load unpacked" }),
1576
+ " and choose the folder."
1577
+ ] }),
1578
+ /* @__PURE__ */ e("li", { children: "Stay signed in to hadoku.me in that Chrome profile." })
1579
+ ] }),
1580
+ /* @__PURE__ */ e("p", { className: "jp-fill-install__update", children: "To update: unzip the new download over the same folder, then press ↻ on the extension." })
1581
+ ] });
1582
+ }
1583
+ const be = {
1584
+ queued: "waiting for the runner",
1585
+ filled: "filled — review the screenshot, then approve",
1586
+ approved: "approved — open the form, press Fill, then Submit",
1587
+ submitted: "submitted",
1588
+ needs_manual: "needs you: the runner stopped rather than guess",
1589
+ failed: "failed",
1590
+ job_closed: "the posting was taken down before this could be sent"
1591
+ };
1592
+ function we(r) {
1593
+ const t = new Date(r);
1594
+ return Number.isNaN(t.getTime()) ? r : t.toLocaleString();
1595
+ }
1596
+ function ge(r) {
1597
+ const t = r.evidence?.answers;
1598
+ return typeof t != "object" || t === null || Array.isArray(t) ? [] : Object.entries(t).filter((o) => typeof o[1] == "string").sort(([o], [c]) => o.localeCompare(c));
1599
+ }
1600
+ function ke(r) {
1601
+ const t = r.evidence?.unmatched;
1602
+ return Array.isArray(t) ? t.filter((o) => typeof o == "string") : [];
1603
+ }
1604
+ function _e(r) {
1605
+ const t = r.evidence?.fingerprint;
1606
+ return typeof t == "string" && t ? t : null;
1607
+ }
1608
+ function ve({ apps: r }) {
1609
+ const t = r.filter((c) => c.status === "approved" || c.status === "filled").sort(
1610
+ (c, l) => +(c.status !== "approved") - +(l.status !== "approved") || c.updated_at.localeCompare(l.updated_at)
1611
+ ), o = t[0];
1612
+ return o ? /* @__PURE__ */ i("div", { className: "jp-send", children: [
1613
+ /* @__PURE__ */ i(
1614
+ "a",
1615
+ {
1616
+ className: "jp-send__start",
1617
+ href: `${o.form_url}#hadoku-session`,
1618
+ target: "_blank",
1619
+ rel: "noopener noreferrer",
1620
+ children: [
1621
+ "Start sending (",
1622
+ t.length,
1623
+ ")"
1624
+ ]
1625
+ }
1626
+ ),
1627
+ /* @__PURE__ */ e("span", { className: "jp-send__hint", children: "Opens each ready application in turn, filled by the hadoku Fill extension. You review, press Submit, and type any emailed code; it moves on when the board confirms." })
1628
+ ] }) : null;
1629
+ }
1630
+ function Se({ auth: r }) {
1631
+ const [t, o] = _(null), [c, l] = _(null), [g, b] = _({}), {
1632
+ data: k,
1633
+ loading: f,
1634
+ error: h
1635
+ } = ee("applications", () => ne()), j = h instanceof S && h.status === 403, d = (k ?? []).map((n) => g[n.id] ?? n).filter((n) => n.status !== "job_closed"), u = c ?? (h && !j ? h instanceof S ? h.message : "Failed to load applications" : null);
1636
+ async function x(n) {
1637
+ o(n.id), l(null);
1638
+ try {
1639
+ const a = await te(n.id, r);
1640
+ b((m) => ({ ...m, [a.id]: a }));
1641
+ } catch (a) {
1642
+ l(a instanceof S ? a.message : "Failed to approve");
1643
+ } finally {
1644
+ o(null);
1645
+ }
1646
+ }
1647
+ return j ? /* @__PURE__ */ e("p", { className: "jp-muted", children: "Sign in to see your applications." }) : f ? /* @__PURE__ */ e("p", { className: "jp-muted", children: "Loading applications…" }) : d.length ? /* @__PURE__ */ i("div", { className: "jp-applications", children: [
1648
+ /* @__PURE__ */ e(P, { auth: r }),
1649
+ /* @__PURE__ */ e(B, { auth: r }),
1650
+ u && /* @__PURE__ */ e("p", { className: "jp-error", children: u }),
1651
+ /* @__PURE__ */ e(ve, { apps: d }),
1652
+ /* @__PURE__ */ e(ye, {}),
1653
+ /* @__PURE__ */ e("ul", { className: "jp-applications__list", children: d.map((n) => {
1654
+ const a = _e(n) ?? n.approved_fingerprint, m = ge(n), y = ke(n), C = n.answered_since ?? [], A = n.overridden ?? [], E = n.still_unanswered ?? (n.answered_since ? [] : y), $ = C.length > 0 && E.length === 0;
1655
+ return /* @__PURE__ */ i("li", { className: `jp-applications__row jp-applications__row--${n.status}`, children: [
1656
+ /* @__PURE__ */ i("div", { className: "jp-applications__head", children: [
1657
+ /* @__PURE__ */ e("span", { className: "jp-applications__title", children: n.title }),
1658
+ /* @__PURE__ */ e("span", { className: "jp-applications__company", children: n.company }),
1659
+ /* @__PURE__ */ e("span", { className: `jp-applications__status jp-applications__status--${n.status}`, children: n.status }),
1660
+ n.status !== "submitted" && /* Where the owner submits: the hadoku Fill extension fills it,
1661
+ they press the board's Submit and type any emailed code. */
1662
+ /* @__PURE__ */ e(
1663
+ "a",
1664
+ {
1665
+ className: "jp-applications__open",
1666
+ href: n.form_url,
1667
+ target: "_blank",
1668
+ rel: "noopener noreferrer",
1669
+ children: "Open form ↗"
1670
+ }
1671
+ )
1672
+ ] }),
1673
+ /* @__PURE__ */ i("p", { className: "jp-applications__meta", children: [
1674
+ be[n.status],
1675
+ " · ",
1676
+ n.mode,
1677
+ " mode · updated ",
1678
+ we(n.updated_at)
1679
+ ] }),
1680
+ n.error && !$ && /* @__PURE__ */ e("p", { className: "jp-error", children: n.error }),
1681
+ (m.length > 0 || y.length > 0) && /* @__PURE__ */ i("details", { className: "jp-applications__fill", open: n.status === "filled", children: [
1682
+ /* @__PURE__ */ i("summary", { children: [
1683
+ "Review what was filled (",
1684
+ m.length,
1685
+ " answered",
1686
+ y.length > 0 && `, ${y.length} left blank`,
1687
+ ")"
1688
+ ] }),
1689
+ m.length > 0 && /* @__PURE__ */ e("table", { className: "jp-applications__answers", children: /* @__PURE__ */ e("tbody", { children: m.map(([v, I]) => /* @__PURE__ */ i("tr", { children: [
1690
+ /* @__PURE__ */ e("th", { scope: "row", children: v }),
1691
+ /* @__PURE__ */ e("td", { children: I })
1692
+ ] }, v)) }) }),
1693
+ y.length > 0 && /* @__PURE__ */ i(K, { children: [
1694
+ /* @__PURE__ */ e("p", { className: "jp-applications__blank-head", children: "Left blank:" }),
1695
+ /* @__PURE__ */ e("ul", { className: "jp-applications__blanks", children: y.map((v) => /* @__PURE__ */ e("li", { children: v }, v)) })
1696
+ ] })
1697
+ ] }),
1698
+ A.length > 0 && /* @__PURE__ */ i("div", { className: "jp-applications__override", children: [
1699
+ /* @__PURE__ */ e("p", { className: "jp-applications__override-head", children: "Filled with something other than your saved answer:" }),
1700
+ /* @__PURE__ */ e("ul", { children: A.map((v) => /* @__PURE__ */ i("li", { children: [
1701
+ /* @__PURE__ */ e("span", { className: "jp-applications__override-q", children: v.question }),
1702
+ /* @__PURE__ */ e("br", {}),
1703
+ /* @__PURE__ */ e("strong", { children: v.filled }),
1704
+ " ",
1705
+ /* @__PURE__ */ i("span", { className: "jp-muted", children: [
1706
+ "(saved: ",
1707
+ v.stored,
1708
+ ")"
1709
+ ] })
1710
+ ] }, v.question)) })
1711
+ ] }),
1712
+ C.length > 0 && /* @__PURE__ */ i("div", { className: "jp-applications__resolved", children: [
1713
+ /* @__PURE__ */ e("p", { children: $ ? "No longer blocked — answered since this fill. Re-queue:" : "Answered since this fill — re-queue to apply:" }),
1714
+ /* @__PURE__ */ e("ul", { children: C.map((v) => /* @__PURE__ */ i("li", { children: [
1715
+ v.question,
1716
+ " → ",
1717
+ /* @__PURE__ */ e("strong", { children: v.answer })
1718
+ ] }, v.question)) })
1719
+ ] }),
1720
+ E.length > 0 && /* @__PURE__ */ i("div", { className: "jp-applications__owed", children: [
1721
+ /* @__PURE__ */ e("p", { children: "Still unanswered:" }),
1722
+ /* @__PURE__ */ e("ul", { children: E.map((v) => /* @__PURE__ */ e("li", { children: v }, v)) })
1723
+ ] }),
1724
+ m.length === 0 && a && n.status === "filled" && /* @__PURE__ */ e("p", { className: "jp-applications__evidence jp-applications__evidence--warn", children: "This fill was recorded before the runner sent its answers, so there is nothing to review here — only the screenshot on the runner’s machine. Re-run the fill to get a reviewable record." }),
1725
+ a && /* @__PURE__ */ i("p", { className: "jp-applications__evidence", children: [
1726
+ n.approved_fingerprint ? "Approved fill" : "This fill",
1727
+ ":",
1728
+ " ",
1729
+ /* @__PURE__ */ e("code", { children: a.slice(0, 12) })
1730
+ ] }),
1731
+ n.status === "filled" && (a ? /* @__PURE__ */ e(
1732
+ "button",
1733
+ {
1734
+ type: "button",
1735
+ className: "jp-drawer__cta jp-drawer__cta--primary",
1736
+ onClick: () => {
1737
+ x(n);
1738
+ },
1739
+ disabled: t === n.id,
1740
+ children: t === n.id ? "Approving…" : "Approve for submission"
1741
+ }
1742
+ ) : /* @__PURE__ */ e("p", { className: "jp-muted", children: "Filled by a runner that did not record what it filled, so there is nothing to approve against. Re-run the fill." }))
1743
+ ] }, n.id);
1744
+ }) })
1745
+ ] }) : /* @__PURE__ */ i("div", { className: "jp-applications", children: [
1746
+ /* @__PURE__ */ e(P, { auth: r }),
1747
+ /* @__PURE__ */ e(B, { auth: r }),
1748
+ /* @__PURE__ */ e("p", { className: "jp-muted", children: "No applications queued." })
1749
+ ] });
1750
+ }
1751
+ export {
1752
+ Se as ApplicationsList
1753
+ };