@vectoriox/iox-ui 5.162.0 → 5.164.0

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 (47) hide show
  1. package/actions-core/index.d.ts +171 -3
  2. package/assist-core/index.d.ts +3 -2
  3. package/composite-core/index.d.ts +195 -3
  4. package/fesm2022/vectoriox-iox-ui-actions-core.mjs +243 -2
  5. package/fesm2022/vectoriox-iox-ui-actions-core.mjs.map +1 -1
  6. package/fesm2022/vectoriox-iox-ui-assist-core.mjs +6 -5
  7. package/fesm2022/vectoriox-iox-ui-assist-core.mjs.map +1 -1
  8. package/fesm2022/vectoriox-iox-ui-composite-core.mjs +413 -163
  9. package/fesm2022/vectoriox-iox-ui-composite-core.mjs.map +1 -1
  10. package/fesm2022/vectoriox-iox-ui-generation-core.mjs +456 -27
  11. package/fesm2022/vectoriox-iox-ui-generation-core.mjs.map +1 -1
  12. package/fesm2022/vectoriox-iox-ui-harness-core.mjs +140 -1
  13. package/fesm2022/vectoriox-iox-ui-harness-core.mjs.map +1 -1
  14. package/fesm2022/vectoriox-iox-ui-scene-core.mjs +83 -23
  15. package/fesm2022/vectoriox-iox-ui-scene-core.mjs.map +1 -1
  16. package/fesm2022/vectoriox-iox-ui.mjs +387 -11
  17. package/fesm2022/vectoriox-iox-ui.mjs.map +1 -1
  18. package/generation-core/index.d.ts +87 -12
  19. package/harness-core/index.d.ts +132 -2
  20. package/index.d.ts +108 -3
  21. package/package.json +1 -1
  22. package/scene-core/index.d.ts +45 -13
  23. package/src/actions-core/popup-arrival.ts +328 -0
  24. package/src/actions-core/public-api.ts +1 -0
  25. package/src/assist-core/media-generate.ts +6 -5
  26. package/src/composite-core/composite-kinds.ts +9 -0
  27. package/src/composite-core/popup.ts +285 -0
  28. package/src/composite-core/public-api.ts +1 -0
  29. package/src/generation-core/ai-run.ts +65 -2
  30. package/src/generation-core/check-layout.ts +34 -4
  31. package/src/generation-core/compose-layout.ts +211 -10
  32. package/src/generation-core/compose-site.ts +2 -0
  33. package/src/generation-core/layout-drawers.ts +106 -0
  34. package/src/generation-core/layout-fingerprint.ts +3 -0
  35. package/src/generation-core/layout-language.ts +4 -0
  36. package/src/generation-core/layout-space.ts +3 -2
  37. package/src/generation-core/layout-wire.ts +15 -3
  38. package/src/generation-core/patterns.ts +4 -0
  39. package/src/generation-core/pictures.ts +4 -3
  40. package/src/generation-core/site-spec.generated.ts +57 -5
  41. package/src/harness-core/business-types.ts +2 -0
  42. package/src/harness-core/harness-spec.generated.ts +83 -0
  43. package/src/harness-core/popup-stance.ts +111 -0
  44. package/src/harness-core/public-api.ts +1 -0
  45. package/src/scene-core/scene.ts +3 -0
  46. package/src/scene-core/scroll-driver.ts +97 -25
  47. package/styles/iox-design.css +141 -2
@@ -0,0 +1,285 @@
1
+ import { CompositeNode, CompositeNodeFactory, writeProp } from './composite-node';
2
+ import { COLUMN, recipeLang, recipePart, recipeText, ROW, WORDS, ZERO } from './recipe-parts';
3
+
4
+ /**
5
+ * THE POPUP (popups-plan.md, PU1; PU-D1…PU-D18) — the owner's own news, arriving once, as ordinary builder nodes. A popup
6
+ * is a Dialog stamped from this ONE recipe (PU-D1): the builder's palette (PU2) and generation-core's composer (PU3) stamp
7
+ * it with their own node factories, so a generated popup and a hand-placed one are the same tree.
8
+ *
9
+ * Popup Dialog popup (kind · form · arrive · again · dates — the popup traits below)
10
+ * › Container popup.media? Image (the owner's picture) — `art: picture`
11
+ * › Container popup.content
12
+ * Text popup.eyebrow? (only from a date the owner gave)
13
+ * Heading popup.title (h2, worn as the look's h3 — its smallest heading style)
14
+ * Text popup.body (≤ 160 characters)
15
+ * <form> popup.form? (newsletter: the caller's forms-core newsletter preset)
16
+ * Link popup.action? (ONE quiet action — a page link; a form's Send is its own)
17
+ * › the Dialog's own ✕ (44 × 44, named in the site's language by the runtime)
18
+ *
19
+ * Its LOOK is the site's element styles (dialog, h4, small, link) — never a colour. Its words are the OWNER's (title, body,
20
+ * eyebrow, the action's label), passed in; the recipe's own words are mechanism microcopy only ("Close", "Send").
21
+ * Framework-free: no actions-core import (actions-core reads this module, never the other way).
22
+ */
23
+
24
+ export enum PopupRole {
25
+ Popup = 'popup',
26
+ Media = 'popup.media',
27
+ Content = 'popup.content',
28
+ Eyebrow = 'popup.eyebrow',
29
+ Title = 'popup.title',
30
+ Body = 'popup.body',
31
+ Form = 'popup.form',
32
+ Action = 'popup.action',
33
+ }
34
+
35
+ export const POPUP_ROLES: ReadonlySet<string> = new Set(Object.values(PopupRole));
36
+
37
+ /** PU-D3: what the popup says (contract POPUP `kind`). Seasonal is not a kind — it is dates on any kind. */
38
+ export enum PopupKind {
39
+ Announcement = 'announcement',
40
+ Offer = 'offer',
41
+ Newsletter = 'newsletter',
42
+ }
43
+
44
+ /** §3b: where it sits (contract POPUP `form`). Only `centred` is modal, and only a newsletter's on a laptop. */
45
+ export enum PopupForm {
46
+ Corner = 'corner',
47
+ Bar = 'bar',
48
+ Centred = 'centred',
49
+ }
50
+
51
+ /** PU-D5: what makes it arrive (contract POPUP `arrive`). `leaving` waits for PU2b (drawn as `time`). */
52
+ export enum PopupArrive {
53
+ Scroll = 'scroll',
54
+ Time = 'time',
55
+ ScrollOrTime = 'scrollOrTime',
56
+ Leaving = 'leaving',
57
+ Button = 'button',
58
+ }
59
+
60
+ /** PU-D6: when it may show again after a close (contract POPUP `again`). "Every page view" is refused. */
61
+ export enum PopupAgain {
62
+ Days = 'days',
63
+ Visit = 'visit',
64
+ Once = 'once',
65
+ }
66
+
67
+ /** The contract's `art`. */
68
+ export enum PopupArt {
69
+ None = 'none',
70
+ Picture = 'picture',
71
+ }
72
+
73
+ /**
74
+ * The Dialog traits a popup carries (Bindings ▸ Popup, PU2). Like the menu traits (HI2a) they have NO default: a Dialog
75
+ * without `popupKind` is not a popup and renders exactly as before (R-H4). `modal` is the one Dialog trait the popup
76
+ * adds for every Dialog: absent = modal, so every existing Dialog keeps `showModal()`.
77
+ */
78
+ export enum PopupTrait {
79
+ Kind = 'popupKind',
80
+ Form = 'popupForm',
81
+ Arrive = 'popupArrive',
82
+ /** `scroll`: the share of the FIRST screen scrolled (default 0.5). */
83
+ Screens = 'popupScreens',
84
+ /** `scroll`: the share of the whole PAGE scrolled instead (a newsletter's 40%). */
85
+ PageShare = 'popupPageShare',
86
+ /** `time`: seconds on the page (visible tab), never under 3. */
87
+ Seconds = 'popupSeconds',
88
+ Again = 'popupAgain',
89
+ /** `again: days`: how many (default 30). */
90
+ Days = 'popupDays',
91
+ /** PU-D18: whole days, `YYYY-MM-DD`, on the visitor's clock. */
92
+ ShowFrom = 'popupFrom',
93
+ ShowUntil = 'popupUntil',
94
+ /** "Show it again to everyone" raises it; a remembered close of an older version is forgotten. */
95
+ Version = 'popupVersion',
96
+ }
97
+
98
+ /** A Dialog's own trait: false = non-modal (`showPopover()`, the page stays usable). Absent = modal (as ever). */
99
+ export const DIALOG_MODAL_TRAIT = 'modal';
100
+
101
+ /** The attributes a popup renders on its `<dialog>` — read by the shared CSS (placement, motion) and the popup runtime. */
102
+ export enum PopupAttribute {
103
+ Kind = 'data-iox-popup',
104
+ Form = 'data-iox-popup-form',
105
+ Arrive = 'data-iox-popup-arrive',
106
+ Screens = 'data-iox-popup-screens',
107
+ PageShare = 'data-iox-popup-page',
108
+ Seconds = 'data-iox-popup-seconds',
109
+ Again = 'data-iox-popup-again',
110
+ Days = 'data-iox-popup-days',
111
+ ShowFrom = 'data-iox-popup-from',
112
+ ShowUntil = 'data-iox-popup-until',
113
+ Version = 'data-iox-popup-version',
114
+ /** A non-modal Dialog (a popup's corner / bar, or `modal: false`): opened with `showPopover()`. */
115
+ NonModal = 'data-iox-dialog-nonmodal',
116
+ /** §8 / R-H8: its words never become the page's search snippet. */
117
+ NoSnippet = 'data-nosnippet',
118
+ }
119
+
120
+ export const POPUP_ATTRIBUTES: ReadonlyArray<string> = Object.values(PopupAttribute);
121
+
122
+ const TRAIT_ATTRIBUTE: ReadonlyArray<readonly [PopupTrait, PopupAttribute]> = [
123
+ [PopupTrait.Arrive, PopupAttribute.Arrive], [PopupTrait.Screens, PopupAttribute.Screens], [PopupTrait.PageShare, PopupAttribute.PageShare],
124
+ [PopupTrait.Seconds, PopupAttribute.Seconds], [PopupTrait.Again, PopupAttribute.Again], [PopupTrait.Days, PopupAttribute.Days],
125
+ [PopupTrait.ShowFrom, PopupAttribute.ShowFrom], [PopupTrait.ShowUntil, PopupAttribute.ShowUntil], [PopupTrait.Version, PopupAttribute.Version],
126
+ ];
127
+
128
+ const inEnum = <E extends Record<string, string>>(e: E, v: unknown): v is E[keyof E] => typeof v === 'string' && (Object.values(e) as string[]).includes(v);
129
+ const isOff = (v: unknown) => v === false || v === 'false';
130
+ const text = (v: unknown): string => (typeof v === 'number' && Number.isFinite(v) ? String(v) : typeof v === 'string' ? v.trim() : '');
131
+
132
+ /** A popup's form, judged: `centred` only for a newsletter (PU-D2) — any other kind asking for it sits in the corner. */
133
+ export function popupFormOf(kind: unknown, form: unknown): PopupForm {
134
+ const f = inEnum(PopupForm, form) ? form : POPUP_KIND_MIX[inEnum(PopupKind, kind) ? kind : PopupKind.Offer].form;
135
+ return f === PopupForm.Centred && kind !== PopupKind.Newsletter ? PopupForm.Corner : f;
136
+ }
137
+
138
+ /** True when a Dialog opens as a modal: a popup only when its form is `centred`; any other Dialog unless `modal: false`. */
139
+ export function dialogIsModal(get: (name: string) => unknown): boolean {
140
+ const kind = get(PopupTrait.Kind);
141
+ if (inEnum(PopupKind, kind)) return popupFormOf(kind, get(PopupTrait.Form)) === PopupForm.Centred;
142
+ return !isOff(get(DIALOG_MODAL_TRAIT));
143
+ }
144
+
145
+ /**
146
+ * The attributes a Dialog renders for the popup and the non-modal opening — ONE function, applied by every renderer
147
+ * through `nodeA11yAttributes` (the engine's string path, its component path, the builder canvas). A plain modal Dialog
148
+ * gets `{}` and renders exactly as before.
149
+ */
150
+ export function popupDialogAttributes(get: (name: string) => unknown): Record<string, string> {
151
+ const out: Record<string, string> = {};
152
+ if (!dialogIsModal(get)) out[PopupAttribute.NonModal] = '';
153
+ const kind = get(PopupTrait.Kind);
154
+ if (!inEnum(PopupKind, kind)) return out;
155
+ out[PopupAttribute.Kind] = kind;
156
+ out[PopupAttribute.Form] = popupFormOf(kind, get(PopupTrait.Form));
157
+ out[PopupAttribute.NoSnippet] = '';
158
+ for (const [trait, attr] of TRAIT_ATTRIBUTE) {
159
+ const v = text(get(trait));
160
+ if (v) out[attr] = v;
161
+ }
162
+ return out;
163
+ }
164
+
165
+ /** §3a + PU-D6: each kind's defaults (contract POPUP `named` — generation-core's spec holds them equal). */
166
+ export const POPUP_KIND_MIX: Readonly<Record<PopupKind, { form: PopupForm; arrive: PopupArrive; again: PopupAgain; art: PopupArt }>> = {
167
+ [PopupKind.Announcement]: { form: PopupForm.Bar, arrive: PopupArrive.Scroll, again: PopupAgain.Visit, art: PopupArt.None },
168
+ [PopupKind.Offer]: { form: PopupForm.Corner, arrive: PopupArrive.ScrollOrTime, again: PopupAgain.Days, art: PopupArt.Picture },
169
+ [PopupKind.Newsletter]: { form: PopupForm.Corner, arrive: PopupArrive.ScrollOrTime, again: PopupAgain.Days, art: PopupArt.None },
170
+ };
171
+
172
+ /** §3a: when each kind arrives by default (contract POPUP `arrival`). */
173
+ export const POPUP_KIND_ARRIVAL: Readonly<Record<PopupKind, { screens?: number; pageShare?: number; seconds?: number }>> = {
174
+ [PopupKind.Announcement]: { screens: 0.5 },
175
+ [PopupKind.Offer]: { screens: 0.5, seconds: 8 },
176
+ [PopupKind.Newsletter]: { pageShare: 0.4, seconds: 25 },
177
+ };
178
+
179
+ /** The recipe's OWN words — mechanism microcopy, in the site's language. The rest is the owner's. */
180
+ const POPUP_WORDS = {
181
+ en: { close: 'Close', send: 'Send', label: { [PopupKind.Announcement]: 'Announcement', [PopupKind.Offer]: 'Offer', [PopupKind.Newsletter]: 'Newsletter' } },
182
+ he: { close: 'סגירה', send: 'שליחה', label: { [PopupKind.Announcement]: 'הודעה', [PopupKind.Offer]: 'הצעה', [PopupKind.Newsletter]: 'ניוזלטר' } },
183
+ } as const;
184
+
185
+ export type PopupWords = (typeof POPUP_WORDS)['en'] | (typeof POPUP_WORDS)['he'];
186
+
187
+ /** The popup's mechanism words in `lang` (English for any language it does not speak yet). */
188
+ export function popupWords(lang: string | null | undefined = 'en'): PopupWords {
189
+ return POPUP_WORDS[recipeLang(lang)];
190
+ }
191
+
192
+ enum Style {
193
+ Dialog = 'dialog',
194
+ /** The look's smallest heading style (there is no h4 element style): the plan's "h4-sized" title. */
195
+ Title = 'h3',
196
+ Body = 'small',
197
+ Eyebrow = 'eyebrow',
198
+ Link = 'link',
199
+ }
200
+
201
+ /** §6: a heading of at most this many words; a body of at most this many characters (the gate judges stored ones). */
202
+ export const POPUP_TITLE_MAX_WORDS = 6;
203
+ export const POPUP_BODY_MAX_CHARS = 160;
204
+
205
+ export interface PopupRecipeOptions {
206
+ kind?: PopupKind;
207
+ /** The site's language — the ✕'s name and the Dialog's label fall back to it. */
208
+ lang?: string | null;
209
+ /** The owner's words. Empty words stay empty (the Publishable gate blocks an empty title — never invented). */
210
+ title?: string;
211
+ body?: string;
212
+ /** Only from a date the owner gave ("Until 30 November"). */
213
+ eyebrow?: string;
214
+ /** The ONE action: a link to a page of the site, with its words. No route = no action (an announcement may have none). */
215
+ actionLabel?: string;
216
+ actionRoute?: string | null;
217
+ /** The owner's picture (`art: picture`); '' = the DS3 empty-image box ("Add image"). */
218
+ imageSrc?: string;
219
+ imageAlt?: string;
220
+ /** Overrides of the kind's mix. */
221
+ form?: PopupForm;
222
+ arrive?: PopupArrive;
223
+ again?: PopupAgain;
224
+ art?: PopupArt;
225
+ /** A newsletter's form — the caller's forms-core newsletter preset (with the AW-D15 legal line), stamped by the caller's
226
+ * own factory; it carries its own Send. */
227
+ newsletterForm?: CompositeNode | null;
228
+ }
229
+
230
+ /** The popup — ONE root. Pure over the factory: the builder and the composer get the same tree. */
231
+ export function buildPopupRecipe(create: CompositeNodeFactory, options: PopupRecipeOptions = {}): CompositeNode {
232
+ const kind = options.kind ?? PopupKind.Offer;
233
+ const mix = POPUP_KIND_MIX[kind];
234
+ const form = popupFormOf(kind, options.form ?? mix.form);
235
+ const art = form === PopupForm.Bar ? PopupArt.None : options.art ?? mix.art;
236
+ const words = popupWords(options.lang);
237
+ const title = options.title?.trim() ?? '';
238
+ const bar = form === PopupForm.Bar;
239
+
240
+ const picture = art === PopupArt.Picture;
241
+ // The dialog style's padding holds, except around a picture: the picture runs to the card's edge, the words keep the pad.
242
+ const { padding: _rowPad, ...row } = ROW;
243
+ const root = recipePart(create, 'popup', 'Dialog', PopupRole.Popup, Style.Dialog, {}, `Popup — ${words.label[kind]}`,
244
+ bar ? { ...row, width: '100%', maxWidth: '100%', gap: '16px' }
245
+ : { ...row, width: picture ? '560px' : '420px', maxWidth: '100%', alignItems: 'stretch', gap: '0px', ...(picture ? { padding: ZERO } : {}) });
246
+ writeProp(root, 'placement', 'center'); // the popup's own form places it (iox-design.css), never the placement
247
+ writeProp(root, 'closeOnBackdrop', true); // centred only: a click on the scrim is a close (remembered)
248
+ writeProp(root, 'showCloseButton', true);
249
+ writeProp(root, 'ariaLabel', title || words.label[kind]);
250
+ writeProp(root, PopupTrait.Kind, kind);
251
+ writeProp(root, PopupTrait.Form, form);
252
+ writeProp(root, PopupTrait.Arrive, options.arrive ?? mix.arrive);
253
+ writeProp(root, PopupTrait.Again, options.again ?? mix.again);
254
+
255
+ const children: CompositeNode[] = [];
256
+ if (picture) {
257
+ const media = recipePart(create, 'popup-media', 'Container', PopupRole.Media, null, {}, 'Picture',
258
+ { ...COLUMN, width: '40%', flexShrink: '0', overflow: 'hidden' });
259
+ media.children = [recipePart(create, 'popup-image', 'Image', null, null, { src: options.imageSrc ?? '', alt: options.imageAlt ?? '' }, 'Picture',
260
+ { width: '100%', height: '100%', minHeight: '160px', objectFit: 'cover', margin: ZERO })];
261
+ children.push(media);
262
+ }
263
+ const content = recipePart(create, 'popup-content', 'Container', PopupRole.Content, null, {}, 'Words',
264
+ bar ? { ...ROW, flexGrow: '1', flexWrap: 'wrap', gap: '4px 16px' }
265
+ : { ...COLUMN, flexGrow: '1', width: 'auto', gap: '8px', ...(picture ? { padding: 'var(--iox-dialog-pad)' } : {}) });
266
+ const parts: CompositeNode[] = [];
267
+ if (options.eyebrow?.trim()) parts.push(recipeText(create, 'popup-eyebrow', PopupRole.Eyebrow, Style.Eyebrow, options.eyebrow.trim(), 'Dates'));
268
+ parts.push(recipePart(create, 'popup-title', 'Heading', PopupRole.Title, Style.Title, { content: title, level: 'h2' }, 'Title', WORDS));
269
+ if (options.body?.trim() || !bar) parts.push(recipeText(create, 'popup-body', PopupRole.Body, Style.Body, options.body?.trim() ?? '', 'Words'));
270
+ if (kind === PopupKind.Newsletter && options.newsletterForm) {
271
+ const f = options.newsletterForm;
272
+ f.role = PopupRole.Form;
273
+ parts.push(f);
274
+ } else if (options.actionRoute) {
275
+ // A popup's action is QUIET — never the page's primary button (§6): the look's link (a Link, the consent banner's
276
+ // privacy link's shape), hugging its words — the column would stretch its box (focus ring, hover) to full width.
277
+ parts.push(recipePart(create, 'popup-action', 'Link', PopupRole.Action, Style.Link,
278
+ { label: options.actionLabel?.trim() ?? '', linkType: 'page', pageRoute: options.actionRoute }, 'Action',
279
+ { ...WORDS, alignSelf: 'flex-start' }));
280
+ }
281
+ content.children = parts;
282
+ children.push(content);
283
+ root.children = children;
284
+ return root;
285
+ }
@@ -33,3 +33,4 @@ export * from './shop-runtime';
33
33
  export * from './account';
34
34
  export * from './account-runtime';
35
35
  export * from './consent';
36
+ export * from './popup';
@@ -248,11 +248,74 @@ export function creditsOfUsd(usd: number): number {
248
248
  return Math.round(usd * CREDITS_PER_USD * CREDIT_PRECISION) / CREDIT_PRECISION;
249
249
  }
250
250
 
251
- /** What a typical request of `step` reads and writes — one part's when the step is asked in parts, else the whole step's. */
252
- export function typicalStepTokens(step: AiStep, part?: PlanPart): AiTokenCounts {
251
+ /**
252
+ * What a typical request of `step` reads and writes — one part's when the step is asked in parts, else the whole step's.
253
+ * A picture step on a named `model` is counted as that model's maker bills one picture (`pictureTokensFor`, iox-ui#138);
254
+ * with no model named it is the step's own count (its default model's maker).
255
+ */
256
+ export function typicalStepTokens(step: AiStep, part?: PlanPart, model?: string | null): AiTokenCounts {
257
+ if (model && aiModelStep(step) === AiStep.MakePictures) return pictureTokensFor(model);
253
258
  return (part && AI_STEP_PART_TOKENS[step]?.[part]) || AI_STEP_TYPICAL_TOKENS[step];
254
259
  }
255
260
 
261
+ // ── One picture's bill, by who draws it (iox-ui#138) ────────────────────────────────────────────────────────────────
262
+
263
+ /** Who draws a picture model's pictures — how many tokens one picture is billed depends on it, not on its price. */
264
+ export enum AiPictureMaker {
265
+ /** Google's image models (Nano Banana): a 1 K picture is 1,120 image tokens and a short text beside it. */
266
+ Gemini = 'gemini',
267
+ /** Google's Pro image model, which thinks before it draws: the same picture, more text written. */
268
+ GeminiThinking = 'geminiThinking',
269
+ /** OpenAI's image models behind GPT-5 Image: a reasoning model writes, gpt-image draws — far more image tokens. */
270
+ OpenAiImage = 'openaiImage',
271
+ }
272
+
273
+ export interface AiPictureMakerRow {
274
+ readonly maker: AiPictureMaker;
275
+ /** The model ids it draws for — the first row that matches wins. */
276
+ readonly ids: RegExp;
277
+ /** The MOST one picture is billed: what a shown estimate is made of, so the cost shown is never below the charge. */
278
+ readonly tokens: AiTokenCounts;
279
+ }
280
+
281
+ /**
282
+ * One row per maker, the most specific first. Each count is an upper bound, held by `ai-run.spec` against a recorded
283
+ * charge where one exists:
284
+ * - Gemini — the M7 count (`PICTURE_TOKENS`); Nano Banana 2.1 was charged 3.6492 credits on 2026-11-24 (133 in, 359 out,
285
+ * 1,120 image) against 3.915 counted.
286
+ * - Gemini thinking — the same picture with 2,000 written for its thoughts and text (not yet measured; counted high).
287
+ * - OpenAI image — gpt-image writes at most 6,240 image tokens for one picture (1024×1536 at high quality, OpenAI's own
288
+ * table; the model chooses the quality) and GPT-5's reasoning and text beside it are counted at 4,000. GPT-5 Image Mini
289
+ * was charged 4.30365 credits on 2026-11-25 where 1.191 had been shown (iox-ui#138); counted now: 5.967.
290
+ */
291
+ export const AI_PICTURE_MAKERS: ReadonlyArray<AiPictureMakerRow> = [
292
+ { maker: AiPictureMaker.GeminiThinking, ids: /^google\/gemini-[\w.-]*pro-image/, tokens: { ...PICTURE_TOKENS, output: 2_000 } },
293
+ { maker: AiPictureMaker.Gemini, ids: /^google\//, tokens: PICTURE_TOKENS },
294
+ { maker: AiPictureMaker.OpenAiImage, ids: /^openai\//, tokens: { input: 700, output: 4_000, cacheWrite: 0, cacheRead: 0, imageOutput: 6_240 } },
295
+ ];
296
+
297
+ /** The maker of a picture model, or null when no row names it. */
298
+ export function pictureMakerOf(model: string): AiPictureMakerRow | null {
299
+ return AI_PICTURE_MAKERS.find(row => row.ids.test(model)) ?? null;
300
+ }
301
+
302
+ const largestOf = (rows: ReadonlyArray<AiTokenCounts>): AiTokenCounts => rows.reduce((a, b) => ({
303
+ input: Math.max(a.input, b.input), output: Math.max(a.output, b.output),
304
+ cacheWrite: Math.max(a.cacheWrite, b.cacheWrite), cacheRead: Math.max(a.cacheRead, b.cacheRead),
305
+ imageOutput: Math.max(a.imageOutput ?? 0, b.imageOutput ?? 0),
306
+ }));
307
+
308
+ /** Every class at the most any maker bills it — what a picture of a model no row names is counted as. */
309
+ export const PICTURE_TOKENS_UNKNOWN_MAKER: AiTokenCounts = largestOf(AI_PICTURE_MAKERS.map(row => row.tokens));
310
+
311
+ /**
312
+ * The most one picture on `model` is billed. A model no row names (an own key's choice) is counted at every maker's
313
+ * largest count — never below what it may be charged; the cost shown may be high, it is never short.
314
+ */
315
+ export function pictureTokensFor(model: string): AiTokenCounts {
316
+ return pictureMakerOf(model)?.tokens ?? PICTURE_TOKENS_UNKNOWN_MAKER;
317
+ }
318
+
256
319
  /** The credits a typical use of `step` costs on a model of `price` — never typed, always computed (§3d). */
257
320
  export function estimateStepCredits(step: AiStep, price: AiTokenPrice, tokens: AiTokenCounts = AI_STEP_TYPICAL_TOKENS[step]): number {
258
321
  return creditsOfUsd(costUsd(tokens, price));
@@ -11,6 +11,7 @@ import { layoutColumnsOffered } from './layout-wire';
11
11
  import { layoutColumnWord, layoutJudgeColumnPx } from './layout-column';
12
12
  import { DriftBox, driftOverlap, layoutGlideDepth } from './layout-drift';
13
13
  import { layoutLookOf } from './layout-look';
14
+ import { DRAWER_KINDS, DRAWER_STEPS, drawerStepCount, isDrawers, layoutSignatureOffered } from './layout-drawers';
14
15
  import { patternById, SCENE_LEVEL } from './patterns';
15
16
  import { layoutDesignOf, screenWordMisfit } from './layout-type';
16
17
  import { sectionEntrances } from './entrances';
@@ -296,6 +297,32 @@ interface LayoutTally {
296
297
 
297
298
  const NOTHING_CARRIED: LayoutTally = { signatures: 0, galleries: 0, swappable: 0, layered: 0, bleeds: 0, screenWords: 0, wordsOnPhoto: 0, holds: 0 };
298
299
 
300
+ /**
301
+ * AW9 `drawers` (award plan "Reddottours" S4): the award tier's signature, held and never sideways, its 3–5 steps each
302
+ * opened by a heading and holding words and buttons only (a step paints its own ground from the look's schemes — never on
303
+ * a photo); a step's words ride their step, so they carry no tracks or depth of their own.
304
+ */
305
+ function drawersIssues(
306
+ s: LayoutSection, at: string, track: number, groundPhoto: boolean, tier: string | null | undefined,
307
+ add: (code: LayoutIssueCode, path: string, message: string) => void,
308
+ ): void {
309
+ const layers = Array.isArray(s.layers) ? s.layers : [];
310
+ if (!layoutSignatureOffered(LayoutSectionKind.Drawers, tier)) add(LayoutIssueCode.Value, `${at}.kind`, 'drawers is an award signature — content | inhale | signature');
311
+ if (!s.signature) add(LayoutIssueCode.Structure, at, "drawers is the page's signature");
312
+ if (!s.pin || track > 1) add(LayoutIssueCode.Structure, `${at}.hold`, 'drawers is held (hold 1) and never carried sideways');
313
+ if (groundPhoto) add(LayoutIssueCode.Structure, `${at}.ground`, 'each step paints its own ground — a colour, never a photo');
314
+ const n = drawerStepCount(layers);
315
+ if (n < DRAWER_STEPS[0] || n > DRAWER_STEPS[1]) {
316
+ add(LayoutIssueCode.Structure, `${at}.layers`, `${n} step${n === 1 ? '' : 's'} — drawers hold ${DRAWER_STEPS[0]} to ${DRAWER_STEPS[1]}, each opened by a heading`);
317
+ }
318
+ if (layers.length && layers[0].kind !== LayoutLayerKind.Heading) add(LayoutIssueCode.Structure, `${at}.layers[0]`, 'the first step opens with its heading');
319
+ layers.forEach((l, j) => {
320
+ const lp = `${at}.layers[${j}]`;
321
+ if (!DRAWER_KINDS.has(l.kind)) add(LayoutIssueCode.Structure, `${lp}.kind`, 'a step holds words and buttons — no photo, gallery, form, marquee or shape');
322
+ if (l.motion?.length) add(LayoutIssueCode.Motion, `${lp}.motion`, "a step's words ride their step — no tracks of their own");
323
+ });
324
+ }
325
+
299
326
  /** The model's page in its own order: the sections as they stand, the dropped ones back at their places. */
300
327
  function originalOrder(sections: ReadonlyArray<LayoutSection>, given: ReadonlyArray<LayoutGivenAway>): LayoutSection[] {
301
328
  const kept = new Set(sections.map(s => s.id));
@@ -409,9 +436,10 @@ function examineLayout(page: LayoutPage, ctx: CheckLayoutContext, carried: Layou
409
436
  const at = `sections[${i}]`;
410
437
  const track = trackOf(s);
411
438
  const kind = s.kind ?? LayoutSectionKind.Content;
412
- const content = kind === LayoutSectionKind.Content;
439
+ const drawers = isDrawers(s);
440
+ const content = kind === LayoutSectionKind.Content || drawers;
413
441
  if (!String(s.id ?? '').trim()) add(LayoutIssueCode.Structure, `${at}.id`, 'a short slug');
414
- if (!inList([LayoutSectionKind.Content, LayoutSectionKind.Inhale], kind)) add(LayoutIssueCode.Value, `${at}.kind`, 'content | inhale (a signature is a content section)');
442
+ if (!inList([LayoutSectionKind.Content, LayoutSectionKind.Inhale, LayoutSectionKind.Drawers], kind)) add(LayoutIssueCode.Value, `${at}.kind`, 'content | inhale (a signature is a content section)');
415
443
  if (!(s.screens >= LIM.screens[0] && s.screens <= LIM.screens[1])) add(LayoutIssueCode.Value, `${at}.screens`, `${LIM.screens[0]}..${LIM.screens[1]}`);
416
444
  if (!(Number.isInteger(s.rows) && s.rows >= LIM.rows[0] && s.rows <= LIM.rows[1])) add(LayoutIssueCode.Value, `${at}.rows`, `a whole number ${LIM.rows[0]}..${LIM.rows[1]}`);
417
445
  if (!(Number.isInteger(track) && track >= 1 && track <= LIM.hold[1])) add(LayoutIssueCode.Value, `${at}.track`, `1..${LIM.hold[1]}`);
@@ -441,6 +469,7 @@ function examineLayout(page: LayoutPage, ctx: CheckLayoutContext, carried: Layou
441
469
  if (layers.some(isPictured) || groundPhoto) add(LayoutIssueCode.Structure, at, 'an inhale has no photo and no gallery');
442
470
  if (s.screens > LIM.inhaleScreens) add(LayoutIssueCode.Structure, `${at}.screens`, `an inhale is 1–${LIM.inhaleScreens} screens`);
443
471
  }
472
+ if (drawers) drawersIssues(s, at, track, !!groundPhoto, ctx.tier, add);
444
473
  const leads = layers.filter(l => l.role === LayoutRole.Lead).length;
445
474
  if (content && leads !== 1) add(LayoutIssueCode.Structure, `${at}.layers`, `${leads} leads — exactly one layer is the lead`);
446
475
  if (!content && leads > 1) add(LayoutIssueCode.Structure, `${at}.layers`, 'an inhale has at most one lead');
@@ -463,8 +492,9 @@ function examineLayout(page: LayoutPage, ctx: CheckLayoutContext, carried: Layou
463
492
  const entering = layers.filter(l => l.enter && l.enter !== LayoutEnter.None && l.enter !== LayoutEnter.Fade);
464
493
  if (entering.length) sectionsWithEnters++;
465
494
  const recipes = new Set(entering.filter(l => l.role !== LayoutRole.Lead).map(l => l.enter));
466
- if (recipes.size > 1) add(LayoutIssueCode.Motion, `${at}.layers`, `the supporting layers enter in ${recipes.size} ways — one entrance per section besides the lead's`);
467
- if (entering.length > LIM.enteringPerSection) add(LayoutIssueCode.Motion, `${at}.layers`, `${entering.length} layers enter — at most ${LIM.enteringPerSection}; let the rest simply be there`);
495
+ // A drawers section's words stand on their step (their arrival as it lands is AW10): the composer drops entrances there.
496
+ if (recipes.size > 1 && !drawers) add(LayoutIssueCode.Motion, `${at}.layers`, `the supporting layers enter in ${recipes.size} ways — one entrance per section besides the lead's`);
497
+ if (entering.length > LIM.enteringPerSection && !drawers) add(LayoutIssueCode.Motion, `${at}.layers`, `${entering.length} layers enter — at most ${LIM.enteringPerSection}; let the rest simply be there`);
468
498
 
469
499
  let rotated = 0;
470
500
  layers.forEach((l, j) => {