@graview/tools 0.1.65 → 0.1.67

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.
Files changed (78) hide show
  1. package/dist/ai.d.ts +63 -1
  2. package/dist/ai.d.ts.map +1 -1
  3. package/dist/ai.js.map +1 -1
  4. package/dist/cli.d.ts.map +1 -1
  5. package/dist/cli.js +2 -1
  6. package/dist/cli.js.map +1 -1
  7. package/dist/design-agent.d.ts +190 -0
  8. package/dist/design-agent.d.ts.map +1 -0
  9. package/dist/design-agent.js +434 -0
  10. package/dist/design-agent.js.map +1 -0
  11. package/dist/dev-ai.js +61 -0
  12. package/dist/dev-ai.js.map +1 -1
  13. package/dist/draft-check.d.ts +166 -0
  14. package/dist/draft-check.d.ts.map +1 -0
  15. package/dist/draft-check.js +443 -0
  16. package/dist/draft-check.js.map +1 -0
  17. package/dist/frame.d.ts +1 -1
  18. package/dist/frame.d.ts.map +1 -1
  19. package/dist/index.d.ts +2 -1
  20. package/dist/index.d.ts.map +1 -1
  21. package/dist/index.js.map +1 -1
  22. package/dist/inline-ai.d.ts.map +1 -1
  23. package/dist/inline-ai.js +28 -1
  24. package/dist/inline-ai.js.map +1 -1
  25. package/dist/page-better.d.ts +240 -0
  26. package/dist/page-better.d.ts.map +1 -0
  27. package/dist/page-better.js +383 -0
  28. package/dist/page-better.js.map +1 -0
  29. package/dist/providers/structure.d.ts.map +1 -1
  30. package/dist/providers/structure.js +2 -2
  31. package/dist/providers/structure.js.map +1 -1
  32. package/dist/reshape.d.ts +15 -0
  33. package/dist/reshape.d.ts.map +1 -1
  34. package/dist/reshape.js.map +1 -1
  35. package/dist/section.d.ts +30 -4
  36. package/dist/section.d.ts.map +1 -1
  37. package/dist/section.js +58 -30
  38. package/dist/section.js.map +1 -1
  39. package/dist/tidy/blocking.d.ts +1 -1
  40. package/dist/tidy/blocking.d.ts.map +1 -1
  41. package/dist/tidy/blocking.js +21 -14
  42. package/dist/tidy/blocking.js.map +1 -1
  43. package/dist/tidy/dream.d.ts.map +1 -1
  44. package/dist/tidy/dream.js +5 -1
  45. package/dist/tidy/dream.js.map +1 -1
  46. package/dist/tidy/judges.d.ts +19 -0
  47. package/dist/tidy/judges.d.ts.map +1 -1
  48. package/dist/tidy/judges.js +46 -8
  49. package/dist/tidy/judges.js.map +1 -1
  50. package/dist/tidy/judging.d.ts.map +1 -1
  51. package/dist/tidy/judging.js +15 -24
  52. package/dist/tidy/judging.js.map +1 -1
  53. package/dist/workflows/far.d.ts +17 -0
  54. package/dist/workflows/far.d.ts.map +1 -0
  55. package/dist/workflows/far.js +63 -0
  56. package/dist/workflows/far.js.map +1 -0
  57. package/dist/workflows/run-act.d.ts.map +1 -1
  58. package/dist/workflows/run-act.js +35 -1
  59. package/dist/workflows/run-act.js.map +1 -1
  60. package/dist/workflows/run-agent.d.ts.map +1 -1
  61. package/dist/workflows/run-agent.js +80 -14
  62. package/dist/workflows/run-agent.js.map +1 -1
  63. package/dist/workflows/run-classify.js +4 -4
  64. package/dist/workflows/run-classify.js.map +1 -1
  65. package/dist/workflows/run.d.ts.map +1 -1
  66. package/dist/workflows/run.js +85 -2
  67. package/dist/workflows/run.js.map +1 -1
  68. package/dist/workflows/seat.d.ts +3 -1
  69. package/dist/workflows/seat.d.ts.map +1 -1
  70. package/dist/workflows/seat.js +1 -0
  71. package/dist/workflows/seat.js.map +1 -1
  72. package/dist/workflows/types.d.ts +126 -2
  73. package/dist/workflows/types.d.ts.map +1 -1
  74. package/dist/workflows.d.ts +2 -1
  75. package/dist/workflows.d.ts.map +1 -1
  76. package/dist/workflows.js +1 -0
  77. package/dist/workflows.js.map +1 -1
  78. package/package.json +3 -3
@@ -0,0 +1,166 @@
1
+ /**
2
+ * A drawing read for judging: its headings in order, the records it shows
3
+ * in order with where and how big, and all its words. Each record carries
4
+ * what its row or card says beside its name (`facts`: "Todo", "Sep 3,
5
+ * 2026", "3 tasks"), the words of that row or card whole (`row`), and the
6
+ * heading it sits under (`under`).
7
+ */
8
+ export interface DrawnRead {
9
+ readonly headings: readonly string[];
10
+ readonly records: readonly {
11
+ readonly label: string;
12
+ readonly top: number;
13
+ readonly left: number;
14
+ readonly size: number;
15
+ readonly facts?: readonly string[];
16
+ readonly row?: string;
17
+ readonly under?: string;
18
+ /** Whether its row offered a control to press (a circle that finishes it, a toggle), and whether its name opened it. */
19
+ readonly presses?: boolean;
20
+ readonly opens?: boolean;
21
+ }[];
22
+ readonly text: string;
23
+ }
24
+ /**
25
+ * WHAT THE HOST WOULD STRIP FROM A SCRIPT'S STYLESHEETS, before it is
26
+ * drawn: each `graview.style` string read by the framework's own
27
+ * sanitizer, and what it refuses said by its rule — which rule, what of it
28
+ * was kept, why the rest is not — and what to do instead. With `already`
29
+ * (the script on the page), a refusal that script had too is left out: the
30
+ * page draws without it now, and a draft that keeps it changes nothing.
31
+ */
32
+ export declare function cssFindings(source: string, options?: {
33
+ readonly already?: string;
34
+ }): string[];
35
+ /**
36
+ * WHETHER A ROW STILL SAYS A FACT IT SAID, in other words if it likes: the
37
+ * same words, or the same day of the same month ("Sep 3, 2026" as "3
38
+ * September" or "Sep 3"), or the same number where the fact was one.
39
+ */
40
+ export declare function rowSays(row: string, fact: string): boolean;
41
+ /** Whether the person's words ask for a heading's words to change. */
42
+ export declare function asksToReword(asked: string | undefined): boolean;
43
+ /**
44
+ * WHAT A DRAFT CHANGED THE WORDS OF, IN PLACE: each name of `before` that
45
+ * stands where a new name now stands — the same number of names, the one
46
+ * at that place no longer among them and the new one never among them
47
+ * before — by its old name. A part is found by where it stands, not by
48
+ * its words: a heading reworded is the same heading.
49
+ */
50
+ export declare function renamedInPlace(before: readonly string[], after: readonly string[]): ReadonlyMap<string, string>;
51
+ /**
52
+ * THE NAMES A DRAFT NO LONGER DRAWS that it may not have changed: of
53
+ * `lost`, each but those reworded in place (`renamedInPlace`) where the
54
+ * person asked for a heading's words to change — and, where the part being
55
+ * changed is named (`mayReword`, its own headings), only that part's.
56
+ */
57
+ export declare function lostUnlessReworded(lost: readonly string[], before: readonly string[], after: readonly string[], options: {
58
+ readonly mayReword?: readonly string[];
59
+ readonly asked?: string;
60
+ }): string[];
61
+ /**
62
+ * WHAT A CHECK FOUND, BY WHAT IT IS: a record left out or shown twice, a
63
+ * fact a record no longer says, a record in another group, a heading or a
64
+ * part no longer drawn, the title drawn twice, words shown as the computer
65
+ * keeps them, a style the page will not keep, a class left unstyled, a
66
+ * control that does not work, a draft that did not draw, an edit whose
67
+ * text is not in the script once (`edit-missed`) — and `other`, said in
68
+ * its own words.
69
+ */
70
+ export type FindingKind = "record-lost" | "record-twice" | "fact-lost" | "record-moved" | "heading-lost" | "section-lost" | "title-twice" | "computer-words" | "style-refused" | "unstyled" | "control" | "did-not-draw" | "edit-missed" | "other";
71
+ /** A finding with what it is: what a host logs, and what the panel says it by. */
72
+ export interface DraftFinding {
73
+ readonly kind: FindingKind;
74
+ readonly words: string;
75
+ }
76
+ /** What one finding is, read from its words. */
77
+ export declare function findingKind(finding: string): FindingKind;
78
+ /**
79
+ * ONE DRAFT AS BETTER UI'S CHECKS JUDGED IT, told to the host
80
+ * (`HostAi.onDraftChecked`): the part it was for, which draft of the turn
81
+ * it was, whether it passed, and each finding whole with its kind.
82
+ */
83
+ export interface DraftChecked {
84
+ readonly part: string;
85
+ readonly draft: number;
86
+ readonly passed: boolean;
87
+ readonly findings: readonly DraftFinding[];
88
+ }
89
+ /** Each finding with its kind. */
90
+ export declare const findingsOf: (findings: readonly string[]) => DraftFinding[];
91
+ /**
92
+ * WHAT A DRAFT BROKE, against what the page showed: a record or a heading
93
+ * it no longer shows, a fact a record's row said that its card no longer
94
+ * says (its status, its date, a count), a record moved under another
95
+ * heading, a heading drawn twice, and words no person was shown before — a
96
+ * field's own name, a date as the computer keeps it, `true`, `undefined`.
97
+ * A fact or a group the person asked to change (`asked`: "hide the dates",
98
+ * "group by status") is theirs to change, and so is a heading's wording
99
+ * they asked for — in its place, and only the part's being changed
100
+ * (`mayReword`) where one is. Empty when the draft may be shown.
101
+ */
102
+ export declare function drawnFindings(before: DrawnRead, after: DrawnRead, options?: {
103
+ readonly fields?: readonly string[];
104
+ readonly asked?: string;
105
+ readonly mayReword?: readonly string[];
106
+ }): string[];
107
+ /**
108
+ * WHAT A NEW DESIGN COULD NOT KEEP, said plainly from what broke: "I
109
+ * couldn't keep the dates and statuses in a new design." — the facts by
110
+ * what they are (a day is a date, a number a count, other words a
111
+ * status), a record or a heading lost, a record moved out of its group,
112
+ * words shown as the computer keeps them. Plain `COULD_NOT` where what
113
+ * broke is none of those (the view did not draw, the answer was not one).
114
+ */
115
+ export declare function couldNotKeep(findings: readonly string[]): string;
116
+ /**
117
+ * WHAT CHANGED, SAID BY CODE from the two readings: how the records stand
118
+ * (side by side, how many to a line), how big they are, their order, and
119
+ * headings it adds. Undefined where nothing measurable moved, for the card
120
+ * to say so plainly rather than echo the model.
121
+ */
122
+ export declare function describeChange(name: string, before: DrawnRead, after: DrawnRead): string | undefined;
123
+ /** One control a press check pressed, and what came of it. */
124
+ export interface PressSaid {
125
+ readonly control: string;
126
+ readonly element: string;
127
+ readonly does: string;
128
+ readonly ok: boolean;
129
+ readonly says: string;
130
+ }
131
+ /**
132
+ * WHAT A PERSON CAN DO ON EACH RECORD, KEPT (Roadmap f-make-any-page-better):
133
+ * every control the draft drew, pressed headless with nothing applied —
134
+ * one that does nothing, throws, or is refused is a finding in its own
135
+ * words — and each record whose row the page let a person press (a circle
136
+ * that finishes it) or open by its name must still be: a press bound to
137
+ * one of the toggles (`data-act`, `data-record` its id) that the check
138
+ * found the app accepts, and a link to it.
139
+ */
140
+ export declare function pressFindings(presses: {
141
+ readonly controls: readonly PressSaid[];
142
+ readonly problems: readonly PressSaid[];
143
+ }, wanted: readonly {
144
+ readonly label: string;
145
+ readonly id: string;
146
+ readonly presses?: boolean;
147
+ readonly opens?: boolean;
148
+ }[], toggles: readonly string[], noun?: string): string[];
149
+ /**
150
+ * WHAT THE CONTROLS DO, SAID BY THE PRESS CHECK: "Pressing it checked:
151
+ * “Done” marks each of the 3 tasks done, and each opens its page." Only
152
+ * what was pressed and accepted is said; undefined where it found nothing
153
+ * to say. The agent's own account of its controls is never said for it.
154
+ */
155
+ export declare function pressSaid(presses: {
156
+ readonly controls: readonly PressSaid[];
157
+ }, acts: readonly {
158
+ readonly act: string;
159
+ readonly title: string;
160
+ readonly toggle?: string;
161
+ }[], noun?: string): string | undefined;
162
+ /** Words that say what a control does: a sentence of the model's with one is not said for it — the press check says what was checked. */
163
+ export declare const CONTROL_WORDS: RegExp;
164
+ /** Words of a person who says a control does not work. */
165
+ export declare const IT_DOES_NOT_WORK: RegExp;
166
+ //# sourceMappingURL=draft-check.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"draft-check.d.ts","sourceRoot":"","sources":["../src/draft-check.ts"],"names":[],"mappings":"AAcA;;;;;;GAMG;AACH,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC,QAAQ,CAAC,OAAO,EAAE,SAAS;QACzB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;QACvB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;QACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QACtB,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;QACnC,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;QACtB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QACxB,wHAAwH;QACxH,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;QAC3B,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;KAC1B,EAAE,CAAC;IACJ,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAyGD;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE;IAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAO,GAAG,MAAM,EAAE,CAKjG;AAUD;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAmB1D;AAqBD,sEAAsE;AACtE,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAE/D;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,EAAE,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAU/G;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,EAAE,MAAM,EAAE,SAAS,MAAM,EAAE,EAAE,KAAK,EAAE,SAAS,MAAM,EAAE,EAAE,OAAO,EAAE;IAAE,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,EAAE,CAKvM;AAED;;;;;;;;GAQG;AACH,MAAM,MAAM,WAAW,GAAG,aAAa,GAAG,cAAc,GAAG,WAAW,GAAG,cAAc,GAAG,cAAc,GAAG,cAAc,GAAG,aAAa,GAAG,gBAAgB,GAAG,eAAe,GAAG,UAAU,GAAG,SAAS,GAAG,cAAc,GAAG,aAAa,GAAG,OAAO,CAAC;AAEnP,kFAAkF;AAClF,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAC3B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED,gDAAgD;AAChD,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,WAAW,CAexD;AAED;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE,SAAS,YAAY,EAAE,CAAC;CAC5C;AAED,kCAAkC;AAClC,eAAO,MAAM,UAAU,GAAI,UAAU,SAAS,MAAM,EAAE,KAAG,YAAY,EAAoE,CAAC;AAE1I;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,GAAE;IAAE,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;CAAO,GAAG,MAAM,EAAE,CAoDnM;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAyBhE;AAYD;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,GAAG,MAAM,GAAG,SAAS,CAmBpG;AAED,8DAA8D;AAC9D,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAID;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE;IAAE,QAAQ,CAAC,QAAQ,EAAE,SAAS,SAAS,EAAE,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,SAAS,SAAS,EAAE,CAAA;CAAE,EAAE,MAAM,EAAE,SAAS;IAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,EAAE,EAAE,OAAO,EAAE,SAAS,MAAM,EAAE,EAAE,IAAI,SAAW,GAAG,MAAM,EAAE,CAY5S;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE;IAAE,QAAQ,CAAC,QAAQ,EAAE,SAAS,SAAS,EAAE,CAAA;CAAE,EAAE,IAAI,EAAE,SAAS;IAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,EAAE,EAAE,IAAI,SAAY,GAAG,MAAM,GAAG,SAAS,CAUjN;AAED,yIAAyI;AACzI,eAAO,MAAM,aAAa,QAA8K,CAAC;AAEzM,0DAA0D;AAC1D,eAAO,MAAM,gBAAgB,QAA2M,CAAC"}
@@ -0,0 +1,443 @@
1
+ import { sanitizeStylesheet } from "@graview/core/css";
2
+ import { styleStringsOf } from "./section.js";
3
+ const norm = (words) => words.replace(/\s+/g, " ").trim().toLowerCase();
4
+ const counted = ["no", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten"];
5
+ /** A list said in words: "a", "a and b", "a, b and c". */
6
+ const listed = (list) => (list.length < 2 ? (list[0] ?? "") : `${list.slice(0, -1).join(", ")} and ${list.at(-1)}`);
7
+ /**
8
+ * What a refused stylesheet rule needs, in words a model can act on — and,
9
+ * where it was in a rule, which rule and what of it was kept: "In “.home
10
+ * .lg”, the property “image-rendering” is not allowed and is removed
11
+ * (border-radius is kept): …".
12
+ */
13
+ function refusalWords({ refusal, rule, kept }) {
14
+ const name = refusal.name ? `“${refusal.name}”` : "";
15
+ const where = rule ? `In “${rule}”, ` : "";
16
+ const keeps = kept && kept.length > 0 ? ` (${listed(kept)} ${kept.length === 1 ? "is" : "are"} kept)` : "";
17
+ const begun = (words) => (where ? `${where}${words}` : words.charAt(0).toUpperCase() + words.slice(1));
18
+ switch (refusal.reason) {
19
+ case "selector":
20
+ return `The selector “${/^(host|host-context)$/.test(refusal.name ?? "") ? ":" : /^(slotted|part)$/.test(refusal.name ?? "") ? "::" : ""}${refusal.name ?? ""}” reaches outside the view and is removed with its rule: give the view's outer element a class and style that instead.`;
21
+ case "at-rule":
22
+ return `${name || "An at-rule"} is not allowed and is removed with what it holds: use plain rules and @media only.`;
23
+ case "property":
24
+ return `${begun(`the property ${name}`)} is not allowed and is removed${keeps}: use ordinary layout, color and type properties.`;
25
+ case "function":
26
+ return `${begun(`the function ${name}()`)} is not allowed and is removed${keeps}: use var(--graview-…), calc(), min(), max(), clamp() or repeat().`;
27
+ case "url":
28
+ return `${begun("url()")} is not allowed and is removed${keeps}: draw nothing from an address.`;
29
+ case "value":
30
+ return `${begun(`a value of ${name || "a property"}`)} is not allowed and is removed${keeps} (position may be static, relative, absolute or sticky).`;
31
+ case "size":
32
+ return "The stylesheet is too long and is removed whole: keep it short.";
33
+ default:
34
+ return `${begun(`a rule ${name ? `near ${name} ` : ""}`)}could not be read and is removed: write plain CSS, one rule at a time, no nesting.`;
35
+ }
36
+ }
37
+ /** The rules of a stylesheet at its top level, each with its head (a selector, or an at-rule's prelude) and its whole text. */
38
+ function topRules(css) {
39
+ const rules = [];
40
+ const bare = css.replace(/\/\*[\s\S]*?\*\//g, (comment) => " ".repeat(comment.length));
41
+ let at = 0;
42
+ while (at < bare.length) {
43
+ const open = bare.indexOf("{", at);
44
+ if (open < 0)
45
+ break;
46
+ let depth = 0;
47
+ let close = open;
48
+ for (; close < bare.length; close++) {
49
+ if (bare[close] === "{")
50
+ depth += 1;
51
+ else if (bare[close] === "}" && --depth === 0)
52
+ break;
53
+ }
54
+ rules.push({ head: bare.slice(at, open).replace(/\s+/g, " ").trim(), text: bare.slice(at, close + 1) });
55
+ at = close + 1;
56
+ }
57
+ return rules;
58
+ }
59
+ /** The properties a sanitized rule kept, in order: each declaration's name in `selector { name: value; … }` — none for an at-rule's. */
60
+ function keptOf(css) {
61
+ const open = css.indexOf("{");
62
+ if (open < 0 || css.trimStart().startsWith("@"))
63
+ return [];
64
+ return [...new Set([...css.slice(open + 1).matchAll(/(?:^|;)\s*(-{0,2}[a-zA-Z][\w-]*)\s*:/g)].map((one) => one[1]))];
65
+ }
66
+ /** What the host's sanitizer refuses of a script's stylesheets, each with the rule it was in and what of that rule was kept. */
67
+ function styleRefusalsOf(source) {
68
+ const found = [];
69
+ for (const sheet of styleStringsOf(source)) {
70
+ const css = source.slice(sheet.start, sheet.end).replace(/\$\{(?:[^{}]|\{[^{}]*\})*\}/g, "0");
71
+ const whole = sanitizeStylesheet(css).refused;
72
+ if (whole.length === 0)
73
+ continue;
74
+ if (whole.some((one) => one.reason === "size")) {
75
+ found.push({ refusal: { reason: "size" } });
76
+ continue;
77
+ }
78
+ // Each rule judged alone, as the sanitizer judges it among the rest, so what it refuses is said with its own selector.
79
+ const left = [...whole];
80
+ for (const rule of topRules(css)) {
81
+ const judged = sanitizeStylesheet(rule.text);
82
+ const kept = keptOf(judged.css);
83
+ for (const refusal of judged.refused) {
84
+ const at = left.findIndex((one) => one.reason === refusal.reason && one.name === refusal.name);
85
+ if (at < 0)
86
+ continue;
87
+ left.splice(at, 1);
88
+ found.push({ refusal, ...(rule.head ? { rule: rule.head } : {}), ...(kept.length > 0 ? { kept } : {}) });
89
+ }
90
+ }
91
+ // What no one rule accounts for is said as the sheet's.
92
+ found.push(...left.map((refusal) => ({ refusal })));
93
+ }
94
+ return found;
95
+ }
96
+ /** What makes two refusals the same: what was refused, why, and in which rule — never what else of the rule was kept. */
97
+ const refusalKey = (one) => `${one.refusal.reason}|${one.refusal.name ?? ""}|${(one.rule ?? "").replace(/\s+/g, "")}`;
98
+ /**
99
+ * WHAT THE HOST WOULD STRIP FROM A SCRIPT'S STYLESHEETS, before it is
100
+ * drawn: each `graview.style` string read by the framework's own
101
+ * sanitizer, and what it refuses said by its rule — which rule, what of it
102
+ * was kept, why the rest is not — and what to do instead. With `already`
103
+ * (the script on the page), a refusal that script had too is left out: the
104
+ * page draws without it now, and a draft that keeps it changes nothing.
105
+ */
106
+ export function cssFindings(source, options = {}) {
107
+ const before = options.already === undefined ? new Set() : new Set(styleRefusalsOf(options.already).map(refusalKey));
108
+ const findings = new Set();
109
+ for (const one of styleRefusalsOf(source))
110
+ if (!before.has(refusalKey(one)))
111
+ findings.add(refusalWords(one));
112
+ return [...findings];
113
+ }
114
+ const ISO_DAY = /\b\d{4}-\d{2}-\d{2}(?:T[\d:.]+Z?)?\b/;
115
+ const MARKUP = /<\/?[a-z][a-z0-9-]*(?:\s[^<>]*)?>/i;
116
+ const RAW = /\b(undefined|null|NaN|\[object Object\]|true|false)\b/;
117
+ const MONTHS = ["jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"];
118
+ const DAY_SAID = /\b(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)[a-z]*\.?\s+(\d{1,2})\b|\b(\d{1,2})\s+(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)[a-z]*\b/;
119
+ const WEEKDAY = /\b(mon|tue|wed|thu|fri|sat|sun)[a-z]*\b|\b(today|tomorrow|yesterday)\b/;
120
+ /**
121
+ * WHETHER A ROW STILL SAYS A FACT IT SAID, in other words if it likes: the
122
+ * same words, or the same day of the same month ("Sep 3, 2026" as "3
123
+ * September" or "Sep 3"), or the same number where the fact was one.
124
+ */
125
+ export function rowSays(row, fact) {
126
+ const said = norm(row);
127
+ const wanted = norm(fact);
128
+ if (!wanted)
129
+ return true;
130
+ if (said.includes(wanted))
131
+ return true;
132
+ // "To do" for "Todo", "in-progress" for "In progress": the same letters, spaced or joined.
133
+ const squashed = (text) => text.replace(/[^\p{L}\p{N}]+/gu, "");
134
+ if (squashed(wanted).length >= 3 && squashed(said).includes(squashed(wanted)))
135
+ return true;
136
+ const day = DAY_SAID.exec(wanted);
137
+ if (day) {
138
+ const month = (day[1] ?? day[4]);
139
+ const date = Number(day[2] ?? day[3]);
140
+ for (const one of said.matchAll(new RegExp(DAY_SAID.source, "g")))
141
+ if ((one[1] ?? one[4]) === month && Number(one[2] ?? one[3]) === date)
142
+ return true;
143
+ // A day said by its weekday or as "today" stands for it where the draft says no month at all.
144
+ return MONTHS.every((name) => !said.includes(name)) && WEEKDAY.test(said);
145
+ }
146
+ const number = /^\D*(\d+(?:[.,]\d+)?)\D*$/.exec(wanted);
147
+ if (number)
148
+ return new RegExp(`(^|\\D)${number[1].replace(/[.,]/g, "[.,]")}(\\D|$)`).test(said);
149
+ return false;
150
+ }
151
+ /** Words that ask for something a page showed to go: "hide the dates", "just the names", "without the status". */
152
+ const TAKE_AWAY = /\b(hide|hides|hiding|remove|drop|without|no more|less|fewer|only|just|minimal|simpler|declutter|strip)\b/i;
153
+ /** Words that ask for records to be grouped or moved differently. */
154
+ const REGROUP = /\b(group|groups|grouped|regroup|section|sections|categor\w*|split|move|moved|bucket\w*|by (status|date|day|list|owner|person))\b/i;
155
+ /** Whether the words asked a fact like this one to go: a dates' fact by "dates", a status by "status", anything by "just the names". */
156
+ function askedAway(asked, fact) {
157
+ if (!asked || !TAKE_AWAY.test(asked))
158
+ return false;
159
+ const words = asked.toLowerCase();
160
+ if (/\b(only|just)\b[^.]*\b(name|names|title|titles|label|labels)\b/.test(words))
161
+ return true;
162
+ if (DAY_SAID.test(norm(fact)) || WEEKDAY.test(norm(fact)))
163
+ return /\b(date|dates|due|day|days|when|deadline|deadlines)\b/.test(words);
164
+ if (/^\D*\d/.test(fact))
165
+ return /\b(count|counts|number|numbers|how many|total|totals)\b/.test(words);
166
+ return /\b(status|statuses|state|tag|tags|chip|chips|badge|badges|label|labels|pill|pills|meta|details)\b/.test(words) || words.includes(norm(fact));
167
+ }
168
+ /** Words that ask for a heading's words to change: "reword the top heading", "a shorter title", "rename this section". */
169
+ const REWORD_VERB = /\b(re-?word\w*|re-?name\w*|re-?title\w*|re-?phrase\w*|rewrite|shorten|shorter|longer|wording|words|call it|say|says)\b/i;
170
+ const A_HEADING = /\b(heading|headings|title|titles|header|headers|headline|headlines)\b/i;
171
+ /** Whether the person's words ask for a heading's words to change. */
172
+ export function asksToReword(asked) {
173
+ return Boolean(asked && REWORD_VERB.test(asked) && A_HEADING.test(asked));
174
+ }
175
+ /**
176
+ * WHAT A DRAFT CHANGED THE WORDS OF, IN PLACE: each name of `before` that
177
+ * stands where a new name now stands — the same number of names, the one
178
+ * at that place no longer among them and the new one never among them
179
+ * before — by its old name. A part is found by where it stands, not by
180
+ * its words: a heading reworded is the same heading.
181
+ */
182
+ export function renamedInPlace(before, after) {
183
+ const renamed = new Map();
184
+ if (before.length !== after.length)
185
+ return renamed;
186
+ const was = new Set(before.map(norm));
187
+ const now = new Set(after.map(norm));
188
+ before.forEach((name, at) => {
189
+ const next = after[at];
190
+ if (norm(name) !== norm(next) && !now.has(norm(name)) && !was.has(norm(next)))
191
+ renamed.set(name, next);
192
+ });
193
+ return renamed;
194
+ }
195
+ /**
196
+ * THE NAMES A DRAFT NO LONGER DRAWS that it may not have changed: of
197
+ * `lost`, each but those reworded in place (`renamedInPlace`) where the
198
+ * person asked for a heading's words to change — and, where the part being
199
+ * changed is named (`mayReword`, its own headings), only that part's.
200
+ */
201
+ export function lostUnlessReworded(lost, before, after, options) {
202
+ if (!asksToReword(options.asked))
203
+ return [...lost];
204
+ const renamed = renamedInPlace(before, after);
205
+ const theirs = (name) => !options.mayReword || options.mayReword.some((one) => norm(one) === norm(name));
206
+ return lost.filter((name) => !(renamed.has(name) && theirs(name)));
207
+ }
208
+ /** What one finding is, read from its words. */
209
+ export function findingKind(finding) {
210
+ if (/^Edit \d+: “|^There is no script to edit|^Your edits change nothing/.test(finding))
211
+ return "edit-missed";
212
+ if (/no longer says what it said/.test(finding))
213
+ return "fact-lost";
214
+ if (/^It no longer shows “/.test(finding))
215
+ return "record-lost";
216
+ if (/more often than the page did/.test(finding))
217
+ return "record-twice";
218
+ if (/moved to another group/.test(finding))
219
+ return "record-moved";
220
+ if (/no longer shows the heading/.test(finding))
221
+ return "heading-lost";
222
+ if (/” is not drawn any more\.?$/.test(finding))
223
+ return "section-lost";
224
+ if (/drawn twice/.test(finding))
225
+ return "title-twice";
226
+ if (/markup as words|a date as “|as the computer keeps it|a field's name/.test(finding))
227
+ return "computer-words";
228
+ if (/is still drawn and no rule styles it/.test(finding))
229
+ return "unstyled";
230
+ if (/can no longer be marked|no longer opens? (its|their) page/.test(finding))
231
+ return "control";
232
+ if (/did not draw|did not start|threw while drawing|could not start/.test(finding))
233
+ return "did-not-draw";
234
+ if (/not allowed|is removed|reaches outside/.test(finding))
235
+ return "style-refused";
236
+ return "other";
237
+ }
238
+ /** Each finding with its kind. */
239
+ export const findingsOf = (findings) => findings.map((words) => ({ kind: findingKind(words), words }));
240
+ /**
241
+ * WHAT A DRAFT BROKE, against what the page showed: a record or a heading
242
+ * it no longer shows, a fact a record's row said that its card no longer
243
+ * says (its status, its date, a count), a record moved under another
244
+ * heading, a heading drawn twice, and words no person was shown before — a
245
+ * field's own name, a date as the computer keeps it, `true`, `undefined`.
246
+ * A fact or a group the person asked to change (`asked`: "hide the dates",
247
+ * "group by status") is theirs to change, and so is a heading's wording
248
+ * they asked for — in its place, and only the part's being changed
249
+ * (`mayReword`) where one is. Empty when the draft may be shown.
250
+ */
251
+ export function drawnFindings(before, after, options = {}) {
252
+ const findings = [];
253
+ const text = norm(after.text);
254
+ const lost = before.records.map((one) => one.label).filter((label) => label && !text.includes(norm(label)));
255
+ if (lost.length > 0)
256
+ findings.push(`It no longer shows ${lost.slice(0, 4).map((one) => `“${one}”`).join(", ")}${lost.length > 4 ? ` and ${lost.length - 4} more` : ""}: show every record the page showed.`);
257
+ // A record shown more times than the page showed it: put under a group it is not in, as well as its own.
258
+ const times = (words, label) => words.split(norm(label)).length - 1;
259
+ const shownBefore = norm(before.text);
260
+ const twiceOver = before.records.map((one) => one.label).filter((label) => label && times(text, label) > times(shownBefore, label));
261
+ if (twiceOver.length > 0 && !(options.asked && REGROUP.test(options.asked)))
262
+ findings.push(`It shows ${twiceOver.slice(0, 4).map((one) => `“${one}”`).join(", ")}${twiceOver.length > 4 ? ` and ${twiceOver.length - 4} more` : ""} more often than the page did: show each record where the page showed it, and nowhere else.`);
263
+ // What each record's row said, said still: each fact by the record it was about, in words or as the same day.
264
+ const factsLost = [];
265
+ const moved = [];
266
+ for (const was of before.records) {
267
+ const now = after.records.find((one) => norm(one.label) === norm(was.label));
268
+ if (!now)
269
+ continue;
270
+ // A fact said by the heading it now sits under ("Doing" over a column of what is doing) is said still.
271
+ const row = `${now.row ?? ""} ${now.under ?? ""}`;
272
+ for (const fact of was.facts ?? [])
273
+ if (!rowSays(row, fact) && !askedAway(options.asked, fact))
274
+ factsLost.push(`“${fact}” on “${was.label}”`);
275
+ if (was.under && now.under && norm(was.under) !== norm(now.under) && after.headings.some((one) => norm(one) === norm(was.under)) && !(options.asked && REGROUP.test(options.asked)))
276
+ moved.push(`“${was.label}” is under “${now.under}”, and was under “${was.under}”`);
277
+ }
278
+ if (factsLost.length > 0)
279
+ findings.push(`A record no longer says what it said: ${factsLost.slice(0, 4).join(", ")}${factsLost.length > 4 ? ` and ${factsLost.length - 4} more` : ""}. Show on each record what the page showed on it (its status, its dates, its counts), in words.`);
280
+ if (moved.length > 0)
281
+ findings.push(`A record moved to another group: ${moved.slice(0, 3).join("; ")}${moved.length > 3 ? ` and ${moved.length - 3} more` : ""}. Keep each record under the heading it was under.`);
282
+ const headingsLost = lostUnlessReworded(before.headings.filter((heading) => heading && !text.includes(norm(heading))), before.headings, after.headings, options);
283
+ if (headingsLost.length > 0)
284
+ findings.push(`It no longer shows the heading${headingsLost.length > 1 ? "s" : ""} ${headingsLost.map((one) => `“${one}”`).join(", ")}: keep each heading the page had.`);
285
+ const seen = new Map();
286
+ for (const heading of after.headings)
287
+ if (heading.trim())
288
+ seen.set(norm(heading), (seen.get(norm(heading)) ?? 0) + 1);
289
+ const twice = [...seen].filter(([, n]) => n > 1).map(([heading]) => after.headings.find((one) => norm(one) === heading));
290
+ // Said with what to keep: a model told only to leave the title out drops every heading with it.
291
+ const others = before.headings.filter((one) => !twice.some((title) => norm(title) === norm(one)));
292
+ if (twice.length > 0)
293
+ findings.push(`The heading${twice.length > 1 ? "s" : ""} ${twice.map((one) => `“${one}”`).join(", ")} ${twice.length > 1 ? "are" : "is"} drawn twice: the page already draws its title above the view, so leave it out${others.length > 0 ? ` — and keep every other heading as it was: ${others.map((one) => `“${one}”`).join(", ")}` : ""}.`);
294
+ const markup = MARKUP.exec(after.text);
295
+ if (markup && !MARKUP.test(before.text))
296
+ findings.push(`It shows its own markup as words (“${markup[0].slice(0, 40)}”): build it with graview.html\`…\`, nesting graview.html for each list, never a string of HTML.`);
297
+ const iso = ISO_DAY.exec(after.text);
298
+ if (iso && !ISO_DAY.test(before.text))
299
+ findings.push(`It shows a date as “${iso[0]}”: say dates in words, as the page did (“Sep 3”).`);
300
+ const raw = RAW.exec(after.text);
301
+ if (raw && !new RegExp(`\\b${raw[1].replace(/[[\]]/g, "\\$&")}\\b`).test(before.text))
302
+ findings.push(`It shows “${raw[1]}”, which is a value as the computer keeps it, not words for a person: say it in words or leave it out.`);
303
+ for (const field of options.fields ?? []) {
304
+ if (field.length < 3 || ["label", "name", "title"].includes(field))
305
+ continue;
306
+ // As the computer keeps it: a camelCase key anywhere, or a lowercase one with a value after it ("order 2", "done: true") — never a label a person wrote ("Due Sep 3").
307
+ const named = /[A-Z]/.test(field) ? new RegExp(`\\b${field}\\b`) : new RegExp(`(?:^|[^\\w])${field}(?:\\s*[:=]|\\s+(?:\\d|true|false|null))`);
308
+ if (named.test(after.text) && !named.test(before.text)) {
309
+ findings.push(`It shows “${field}”, a field's name, not words for a person: say what it means, or leave it out.`);
310
+ break;
311
+ }
312
+ }
313
+ return findings;
314
+ }
315
+ /**
316
+ * WHAT A NEW DESIGN COULD NOT KEEP, said plainly from what broke: "I
317
+ * couldn't keep the dates and statuses in a new design." — the facts by
318
+ * what they are (a day is a date, a number a count, other words a
319
+ * status), a record or a heading lost, a record moved out of its group,
320
+ * words shown as the computer keeps them. Plain `COULD_NOT` where what
321
+ * broke is none of those (the view did not draw, the answer was not one).
322
+ */
323
+ export function couldNotKeep(findings) {
324
+ const things = [];
325
+ const add = (thing) => void (things.includes(thing) || things.push(thing));
326
+ for (const finding of findings) {
327
+ const facts = /no longer says what it said: (.*?)(?: and \d+ more)?\. Show/.exec(finding);
328
+ if (facts) {
329
+ for (const one of facts[1].matchAll(/“([^”]+)” on “/g)) {
330
+ const fact = norm(one[1]);
331
+ add(DAY_SAID.test(fact) || WEEKDAY.test(fact) ? "dates" : /^\D*\d/.test(fact) ? "counts" : "statuses");
332
+ }
333
+ continue;
334
+ }
335
+ if (/^It no longer shows “/.test(finding))
336
+ add("every record");
337
+ else if (/no longer shows the heading/.test(finding))
338
+ add("headings");
339
+ else if (/moved to another group/.test(finding))
340
+ add("each record in its group");
341
+ else if (/drawn twice/.test(finding))
342
+ add("the title once");
343
+ else if (/markup as words|a date as “|as the computer keeps it|a field's name/.test(finding))
344
+ add("the words as the page said them");
345
+ }
346
+ if (things.length === 0)
347
+ return "I couldn't make a version that looks right.";
348
+ const order = ["dates", "statuses", "counts", "headings"];
349
+ const facts = order.filter((one) => things.includes(one));
350
+ const rest = things.filter((one) => !order.includes(one));
351
+ const and = (list) => (list.length < 2 ? (list[0] ?? "") : `${list.slice(0, -1).join(", ")} and ${list.at(-1)}`);
352
+ const said = [...(facts.length > 0 ? [`the ${and(facts)}`] : []), ...rest];
353
+ return `I couldn't keep ${and(said)} in a new design.`;
354
+ }
355
+ /** How the records stand: the most side by side on one line. */
356
+ function perLine(records) {
357
+ const lines = new Map();
358
+ for (const one of records) {
359
+ const line = [...lines.keys()].find((top) => Math.abs(top - one.top) <= 6) ?? one.top;
360
+ lines.set(line, (lines.get(line) ?? 0) + 1);
361
+ }
362
+ return Math.max(0, ...lines.values());
363
+ }
364
+ /**
365
+ * WHAT CHANGED, SAID BY CODE from the two readings: how the records stand
366
+ * (side by side, how many to a line), how big they are, their order, and
367
+ * headings it adds. Undefined where nothing measurable moved, for the card
368
+ * to say so plainly rather than echo the model.
369
+ */
370
+ export function describeChange(name, before, after) {
371
+ const said = [];
372
+ const was = perLine(before.records);
373
+ const now = perLine(after.records);
374
+ if (now > 1 && now !== was)
375
+ said.push(`side by side, ${counted[now] ?? now} to a line`);
376
+ else if (now === 1 && was > 1)
377
+ said.push("one under another");
378
+ const size = (records) => (records.length ? records.reduce((sum, one) => sum + one.size, 0) / records.length : 0);
379
+ const ratio = size(before.records) > 0 ? size(after.records) / size(before.records) : 1;
380
+ if (ratio >= 1.12)
381
+ said.push("in bigger type");
382
+ else if (ratio <= 0.89)
383
+ said.push("in smaller type");
384
+ const order = (records, keep) => records.map((one) => norm(one.label)).filter((one) => keep.has(one));
385
+ const common = new Set(before.records.map((one) => norm(one.label)).filter((label) => after.records.some((one) => norm(one.label) === label)));
386
+ if (order(before.records, common).join("|") !== order(after.records, common).join("|"))
387
+ said.push("in a new order");
388
+ const labels = new Set(before.records.map((one) => norm(one.label)));
389
+ const added = after.headings.filter((heading) => heading.trim() && !before.headings.some((one) => norm(one) === norm(heading)) && norm(heading) !== norm(name) && !labels.has(norm(heading)));
390
+ if (added.length > 0)
391
+ said.push(`under ${added.length === 1 ? "a new heading" : "new headings"}: ${added.slice(0, 3).map((one) => `“${one}”`).join(", ")}`);
392
+ if (said.length === 0)
393
+ return undefined;
394
+ const plural = /s$/i.test(name.trim());
395
+ return `${name} now ${plural ? "show" : "shows"} ${said.length === 1 ? said[0] : `${said.slice(0, -1).join(", ")} and ${said.at(-1)}`}.`;
396
+ }
397
+ const attribute = (element, name) => new RegExp(`\\s${name}="([^"]*)"`).exec(element)?.[1];
398
+ /**
399
+ * WHAT A PERSON CAN DO ON EACH RECORD, KEPT (Roadmap f-make-any-page-better):
400
+ * every control the draft drew, pressed headless with nothing applied —
401
+ * one that does nothing, throws, or is refused is a finding in its own
402
+ * words — and each record whose row the page let a person press (a circle
403
+ * that finishes it) or open by its name must still be: a press bound to
404
+ * one of the toggles (`data-act`, `data-record` its id) that the check
405
+ * found the app accepts, and a link to it.
406
+ */
407
+ export function pressFindings(presses, wanted, toggles, noun = "record") {
408
+ const findings = presses.problems.slice(0, 5).map((one) => `${one.control}: ${one.says}`);
409
+ const bound = (id) => presses.controls.some((one) => one.ok && one.does === "act" && attribute(one.element, "data-record") === id && toggles.includes(attribute(one.element, "data-act") ?? ""));
410
+ const linked = (id) => presses.controls.some((one) => one.ok && one.does === "link" && attribute(one.element, "data-record") === id);
411
+ const unpressable = toggles.length > 0 ? wanted.filter((one) => one.presses && !bound(one.id)) : [];
412
+ if (unpressable.length > 0)
413
+ findings.push(`${unpressable.slice(0, 3).map((one) => `“${one.label}”`).join(", ")}${unpressable.length > 3 ? ` and ${unpressable.length - 3} more` : ""} can no longer be marked as the page let a person mark ${unpressable.length === 1 ? "it" : "them"}: give each ${noun} a press bound to ${toggles.map((one) => `“${one}”`).join(" or ")}, e.g. <button data-act="${toggles[0]}" data-record="${unpressable[0].id}">…</button>.`);
414
+ const closed = wanted.filter((one) => one.opens && !linked(one.id));
415
+ if (closed.length > 0)
416
+ findings.push(`${closed.slice(0, 3).map((one) => `“${one.label}”`).join(", ")}${closed.length > 3 ? ` and ${closed.length - 3} more` : ""} no longer ${closed.length === 1 ? "opens its" : "open their"} page: link each with data-record="its id".`);
417
+ return findings;
418
+ }
419
+ /**
420
+ * WHAT THE CONTROLS DO, SAID BY THE PRESS CHECK: "Pressing it checked:
421
+ * “Done” marks each of the 3 tasks done, and each opens its page." Only
422
+ * what was pressed and accepted is said; undefined where it found nothing
423
+ * to say. The agent's own account of its controls is never said for it.
424
+ */
425
+ export function pressSaid(presses, acts, noun = "records") {
426
+ const said = [];
427
+ for (const act of acts) {
428
+ const on = new Set(presses.controls.filter((one) => one.ok && one.does === "act" && attribute(one.element, "data-act") === act.act).map((one) => attribute(one.element, "data-record") ?? one.control));
429
+ if (on.size > 0)
430
+ said.push(`${act.title.replace(/[.…]+$/, "")} works on ${on.size === 1 ? "one of the" : `${on.size}`} ${noun}`);
431
+ }
432
+ const opens = new Set(presses.controls.filter((one) => one.ok && one.does === "link" && attribute(one.element, "data-record")).map((one) => attribute(one.element, "data-record")));
433
+ if (opens.size > 0)
434
+ said.push(`${opens.size} open${opens.size === 1 ? "s its" : " their"} page${opens.size === 1 ? "" : "s"}`);
435
+ if (said.length === 0)
436
+ return undefined;
437
+ return `Pressing each control checked it: ${said.length < 2 ? said[0] : `${said.slice(0, -1).join(", ")} and ${said.at(-1)}`}.`;
438
+ }
439
+ /** Words that say what a control does: a sentence of the model's with one is not said for it — the press check says what was checked. */
440
+ export const CONTROL_WORDS = /\b(check ?box(es)?|button|click|tap|press|toggle|mark(ed|s|ing)?|complet(e|ed|ing)|finish(ed|es|ing)?|persist|sav(e|es|ed|ing)|updat(e|es|ed|ing)|works?|working|data)\b/i;
441
+ /** Words of a person who says a control does not work. */
442
+ export const IT_DOES_NOT_WORK = /\b(does(n'?t| not)|did(n'?t| not)|can'?t|cannot|won'?t|not)\s+(work|working|persist|save|stick|change|update|do anything|mark|finish|complete|click|press)|\bfake\b|\bbroken\b|\bstill (broken|not)\b/i;
443
+ //# sourceMappingURL=draft-check.js.map