@aglyn/plugins-ai 1.11.0 → 1.13.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 (74) hide show
  1. package/package.json +17 -17
  2. package/src/lib/components/ai-media-create.component.js +1 -1
  3. package/src/lib/components/ai-media-create.component.js.map +1 -1
  4. package/src/lib/components/ai-upsell-dialog.component.js +1 -1
  5. package/src/lib/components/ai-upsell-dialog.component.js.map +1 -1
  6. package/src/lib/jobs/ai-job-import-step.d.ts +1 -1
  7. package/src/lib/jobs/ai-job-import-step.js +37 -8
  8. package/src/lib/jobs/ai-job-import-step.js.map +1 -1
  9. package/src/lib/jobs/ai-job-privacy-step.js +2 -2
  10. package/src/lib/jobs/ai-job-privacy-step.js.map +1 -1
  11. package/src/lib/jobs/ai-site-import-compile.js +27 -37
  12. package/src/lib/jobs/ai-site-import-compile.js.map +1 -1
  13. package/src/lib/jobs/ai-site-import-look.d.ts +19 -4
  14. package/src/lib/jobs/ai-site-import-look.js +162 -46
  15. package/src/lib/jobs/ai-site-import-look.js.map +1 -1
  16. package/src/lib/jobs/ai-theme-brand-inputs.d.ts +12 -0
  17. package/src/lib/jobs/ai-theme-brand-inputs.js +1 -1
  18. package/src/lib/jobs/ai-theme-brand-inputs.js.map +1 -1
  19. package/src/lib/layout-language/ai-layout-compiler.js +7 -1
  20. package/src/lib/layout-language/ai-layout-compiler.js.map +1 -1
  21. package/src/lib/model/ai-credit-estimate.d.ts +15 -0
  22. package/src/lib/model/ai-credit-estimate.js +13 -0
  23. package/src/lib/model/ai-credit-estimate.js.map +1 -1
  24. package/src/lib/model/ai-site-import-fidelity.d.ts +46 -3
  25. package/src/lib/model/ai-site-import-fidelity.js +254 -62
  26. package/src/lib/model/ai-site-import-fidelity.js.map +1 -1
  27. package/src/lib/model/ai-site-import-report.d.ts +7 -0
  28. package/src/lib/model/ai-site-import-report.js +17 -5
  29. package/src/lib/model/ai-site-import-report.js.map +1 -1
  30. package/src/lib/model/ai-site-import.d.ts +75 -4
  31. package/src/lib/model/ai-site-import.js +34 -11
  32. package/src/lib/model/ai-site-import.js.map +1 -1
  33. package/src/lib/model/ai-site-look.d.ts +16 -0
  34. package/src/lib/model/ai-site-look.js +76 -14
  35. package/src/lib/model/ai-site-look.js.map +1 -1
  36. package/src/lib/model/ai-upsell-copy.js +1 -1
  37. package/src/lib/model/ai-upsell-copy.js.map +1 -1
  38. package/src/lib/site-import/fixtures/aglyn-com-recordings.d.ts +2 -1
  39. package/src/lib/site-import/fixtures/aglyn-com-recordings.js +3 -2
  40. package/src/lib/site-import/fixtures/aglyn-com-recordings.js.map +1 -1
  41. package/src/lib/site-import/fixtures/site-import-crawl-recordings.d.ts +5 -0
  42. package/src/lib/site-import/fixtures/site-import-crawl-recordings.js +116 -3
  43. package/src/lib/site-import/fixtures/site-import-crawl-recordings.js.map +1 -1
  44. package/src/lib/site-import/fixtures/site-import-fidelity-replay.d.ts +7 -0
  45. package/src/lib/site-import/fixtures/site-import-fidelity-replay.js +15 -0
  46. package/src/lib/site-import/fixtures/site-import-fidelity-replay.js.map +1 -1
  47. package/src/lib/site-import/fixtures/site-layout-recordings.d.ts +32 -0
  48. package/src/lib/site-import/fixtures/site-layout-recordings.js +59 -3
  49. package/src/lib/site-import/fixtures/site-layout-recordings.js.map +1 -1
  50. package/src/lib/site-import/fixtures/site-look-slate.d.ts +2 -1
  51. package/src/lib/site-import/fixtures/site-look-slate.js +2 -1
  52. package/src/lib/site-import/fixtures/site-look-slate.js.map +1 -1
  53. package/src/lib/site-import/site-import-crawl.d.ts +9 -1
  54. package/src/lib/site-import/site-import-crawl.js +128 -23
  55. package/src/lib/site-import/site-import-crawl.js.map +1 -1
  56. package/src/lib/site-import/site-import-css.d.ts +89 -1
  57. package/src/lib/site-import/site-import-css.js +468 -28
  58. package/src/lib/site-import/site-import-css.js.map +1 -1
  59. package/src/lib/site-import/site-import-data-forms.d.ts +32 -0
  60. package/src/lib/site-import/site-import-data-forms.js +531 -0
  61. package/src/lib/site-import/site-import-data-forms.js.map +1 -0
  62. package/src/lib/site-import/site-import-html.d.ts +10 -1
  63. package/src/lib/site-import/site-import-html.js +21 -5
  64. package/src/lib/site-import/site-import-html.js.map +1 -1
  65. package/src/lib/site-import/site-import-layout.d.ts +9 -2
  66. package/src/lib/site-import/site-import-layout.js +383 -62
  67. package/src/lib/site-import/site-import-layout.js.map +1 -1
  68. package/src/lib/site-import/site-import-nav.js +17 -3
  69. package/src/lib/site-import/site-import-nav.js.map +1 -1
  70. package/src/lib/site-import/site-import-page.js +5 -0
  71. package/src/lib/site-import/site-import-page.js.map +1 -1
  72. package/src/lib/site-import/site-import-same-page.d.ts +41 -0
  73. package/src/lib/site-import/site-import-same-page.js +108 -0
  74. package/src/lib/site-import/site-import-same-page.js.map +1 -0
@@ -0,0 +1,531 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */ /*==========================================
17
+ * A FORM DEFINED IN DATA (AGL-4152).
18
+ *
19
+ * Plenty of site builders and widgets draw a form in the browser: the page
20
+ * they serve has no `<form>`, only an empty box and the form's fields as data,
21
+ * in a script block, a `data-*` attribute or a line of inline JavaScript. The
22
+ * words a visitor would type into are then nowhere in the markup, and the page
23
+ * comes in without its form.
24
+ *
25
+ * So on a page with no `<form>` of its own (a search box does not count), an
26
+ * array of objects that each carry a `type` a form field has, a `title` or
27
+ * `label` and a `required` is a form's fields, and it becomes a `SiteImportForm`
28
+ * placed in the nearest element whose class says it is a form. No such element
29
+ * and no form: an array like it with nowhere to go is some other thing's data.
30
+ * The same array in two places is one form, and one that asks for a password
31
+ * or a card is left out, as a `<form>` that does is.
32
+ *
33
+ * Nothing here runs anything a page wrote: `readLiteral` reads text as data,
34
+ * and stops at the first thing that is not data.
35
+ *=========================================*/ import { _ as _extends } from "@swc/helpers/_/_extends";
36
+ /** The most of one script or attribute read for a form's fields. */ const MAX_SOURCE_CHARS = 1000000;
37
+ /** The most arrays one source is tried at: a bundle holds thousands, and none of them is worth a slow read. */ const MAX_TRIES = 300;
38
+ /** The most values one array read may hold. */ const MAX_VALUES = 20000;
39
+ const MAX_DEPTH = 12;
40
+ /** A `type` as a form's field says it, lowered and its separators dropped, as the field it is. */ const FIELD_TYPES = new Map([
41
+ ...[
42
+ 'text',
43
+ 'input',
44
+ 'string',
45
+ 'name',
46
+ 'fullname',
47
+ 'firstname',
48
+ 'lastname',
49
+ 'company',
50
+ 'subject',
51
+ 'address',
52
+ 'singleline',
53
+ 'shorttext',
54
+ 'shortanswer',
55
+ 'password',
56
+ 'creditcard'
57
+ ].map((type)=>[
58
+ type,
59
+ 'text'
60
+ ]),
61
+ ...[
62
+ 'email',
63
+ 'emailaddress'
64
+ ].map((type)=>[
65
+ type,
66
+ 'email'
67
+ ]),
68
+ ...[
69
+ 'tel',
70
+ 'phone',
71
+ 'telephone',
72
+ 'phonenumber',
73
+ 'mobile'
74
+ ].map((type)=>[
75
+ type,
76
+ 'tel'
77
+ ]),
78
+ ...[
79
+ 'url',
80
+ 'website'
81
+ ].map((type)=>[
82
+ type,
83
+ 'url'
84
+ ]),
85
+ ...[
86
+ 'number',
87
+ 'numeric',
88
+ 'integer'
89
+ ].map((type)=>[
90
+ type,
91
+ 'number'
92
+ ]),
93
+ ...[
94
+ 'date',
95
+ 'datepicker'
96
+ ].map((type)=>[
97
+ type,
98
+ 'date'
99
+ ]),
100
+ ...[
101
+ 'time',
102
+ 'timepicker'
103
+ ].map((type)=>[
104
+ type,
105
+ 'time'
106
+ ]),
107
+ ...[
108
+ 'textarea',
109
+ 'message',
110
+ 'multiline',
111
+ 'longtext',
112
+ 'longanswer',
113
+ 'paragraph',
114
+ 'comment',
115
+ 'comments'
116
+ ].map((type)=>[
117
+ type,
118
+ 'textarea'
119
+ ]),
120
+ ...[
121
+ 'select',
122
+ 'dropdown'
123
+ ].map((type)=>[
124
+ type,
125
+ 'select'
126
+ ]),
127
+ ...[
128
+ 'radio',
129
+ 'radios',
130
+ 'radiogroup',
131
+ 'singlechoice'
132
+ ].map((type)=>[
133
+ type,
134
+ 'radio'
135
+ ]),
136
+ ...[
137
+ 'checkbox',
138
+ 'checkboxes',
139
+ 'checkboxgroup',
140
+ 'multiplechoice',
141
+ 'consent'
142
+ ].map((type)=>[
143
+ type,
144
+ 'checkbox'
145
+ ])
146
+ ]);
147
+ /** Types a form holds that ask nothing a visitor reads as a question. */ const NO_QUESTION = /^(?:hidden|captcha|recaptcha|honeypot|submit|button|reset|section|heading|divider|html|separator|spacer|pagebreak)$/;
148
+ const FILE_TYPES = /^(?:file|fileupload|upload|attachment|image)$/;
149
+ const REFUSED_FIELD = /password|passcode|credit.?card|card.?(?:num|cvc|cvv|exp)|cc.?(?:num|number|exp|csc|cvv|cvc)|cvc|cvv|iban|routing|payment/i;
150
+ /*------------------------------------------
151
+ * Reading text as data
152
+ *-----------------------------------------*/ const FAILED = Symbol('not data');
153
+ /**
154
+ * The array or object a text holds at `start`, and where it ends: JSON, and
155
+ * the looser literal a person writes by hand (bare keys, single quotes, a
156
+ * trailing comma, a comment). `null` at the first thing that is no literal.
157
+ */ function readLiteral(text, start) {
158
+ let at = start;
159
+ let values = 0;
160
+ const space = ()=>{
161
+ for(;;){
162
+ const char = text[at];
163
+ if (char === ' ' || char === '\n' || char === '\t' || char === '\r') at += 1;
164
+ else if (char === '/' && text[at + 1] === '/') at = text.indexOf('\n', at) < 0 ? text.length : text.indexOf('\n', at);
165
+ else if (char === '/' && text[at + 1] === '*') at = text.indexOf('*/', at) < 0 ? text.length : text.indexOf('*/', at) + 2;
166
+ else return;
167
+ }
168
+ };
169
+ const string = (quote)=>{
170
+ let out = '';
171
+ at += 1;
172
+ while(at < text.length){
173
+ const char = text[at];
174
+ if (char === quote) {
175
+ at += 1;
176
+ return out;
177
+ }
178
+ if (char === '\n') return FAILED;
179
+ if (char === '\\') {
180
+ const next = text[at + 1];
181
+ if (next === 'u' && /^[0-9a-f]{4}$/i.test(text.slice(at + 2, at + 6))) {
182
+ out += String.fromCharCode(parseInt(text.slice(at + 2, at + 6), 16));
183
+ at += 6;
184
+ continue;
185
+ }
186
+ out += next === 'n' ? '\n' : next === 't' ? ' ' : next === 'r' ? '' : next != null ? next : '';
187
+ at += 2;
188
+ continue;
189
+ }
190
+ out += char;
191
+ at += 1;
192
+ }
193
+ return FAILED;
194
+ };
195
+ const value = (depth)=>{
196
+ values += 1;
197
+ if (values > MAX_VALUES || depth > MAX_DEPTH) return FAILED;
198
+ space();
199
+ const char = text[at];
200
+ if (char === '"' || char === "'") return string(char);
201
+ if (char === '[') {
202
+ at += 1;
203
+ const list = [];
204
+ for(;;){
205
+ space();
206
+ if (text[at] === ']') {
207
+ at += 1;
208
+ return list;
209
+ }
210
+ const item = value(depth + 1);
211
+ if (item === FAILED) return FAILED;
212
+ list.push(item);
213
+ space();
214
+ if (text[at] === ',') at += 1;
215
+ else if (text[at] !== ']') return FAILED;
216
+ }
217
+ }
218
+ if (char === '{') {
219
+ at += 1;
220
+ const object = {};
221
+ for(;;){
222
+ space();
223
+ if (text[at] === '}') {
224
+ at += 1;
225
+ return object;
226
+ }
227
+ const quote = text[at];
228
+ let key;
229
+ if (quote === '"' || quote === "'") key = string(quote);
230
+ else {
231
+ const bare = /^[A-Za-z_$][\w$]*/.exec(text.slice(at, at + 64));
232
+ key = bare ? bare[0] : FAILED;
233
+ if (bare) at += bare[0].length;
234
+ }
235
+ if (key === FAILED) return FAILED;
236
+ space();
237
+ if (text[at] !== ':') return FAILED;
238
+ at += 1;
239
+ const item = value(depth + 1);
240
+ if (item === FAILED) return FAILED;
241
+ if (key !== '__proto__') object[key] = item;
242
+ space();
243
+ if (text[at] === ',') at += 1;
244
+ else if (text[at] !== '}') return FAILED;
245
+ }
246
+ }
247
+ const word = /^(?:true|false|null|undefined|-?\d+(?:\.\d+)?(?:e[+-]?\d+)?)/i.exec(text.slice(at, at + 40));
248
+ if (!word) return FAILED;
249
+ at += word[0].length;
250
+ if (/^(?:true|false)$/i.test(word[0])) return word[0].toLowerCase() === 'true';
251
+ if (/^(?:null|undefined)$/i.test(word[0])) return null;
252
+ return Number(word[0]);
253
+ };
254
+ const read = value(0);
255
+ return read === FAILED ? null : {
256
+ value: read,
257
+ end: at
258
+ };
259
+ }
260
+ /*------------------------------------------
261
+ * Which arrays are a form's fields
262
+ *-----------------------------------------*/ const isObject = (value)=>!!value && typeof value === 'object' && !Array.isArray(value);
263
+ const typeKey = (value)=>typeof value === 'string' ? value.toLowerCase().replace(/[\s_-]+/g, '') : '';
264
+ const labelOf = (entry)=>typeof entry['title'] === 'string' ? entry['title'] : typeof entry['label'] === 'string' ? entry['label'] : '';
265
+ const isField = (entry)=>typeKey(entry['type']) !== '' && labelOf(entry).trim() !== '' && 'required' in entry;
266
+ const asksQuestion = (entry)=>FIELD_TYPES.has(typeKey(entry['type']));
267
+ /** Whether an array is a form's fields: objects, most of them fields, at least half of what is typed a kind of question a form asks. */ function isFieldArray(value) {
268
+ if (!Array.isArray(value) || !value.length || !value.every(isObject)) return false;
269
+ const fields = value.filter(isField);
270
+ if (fields.length * 2 < value.length) return false;
271
+ return fields.filter(asksQuestion).length * 2 >= fields.length && fields.some(asksQuestion);
272
+ }
273
+ /** The arrays a value read holds that are a form's fields, outermost first. */ function fieldArraysIn(value, depth = 0) {
274
+ if (depth > MAX_DEPTH) return [];
275
+ if (isFieldArray(value)) return [
276
+ value
277
+ ];
278
+ if (Array.isArray(value)) return value.flatMap((item)=>fieldArraysIn(item, depth + 1));
279
+ if (isObject(value)) return Object.values(value).flatMap((item)=>fieldArraysIn(item, depth + 1));
280
+ return [];
281
+ }
282
+ /** The field arrays a text holds, each with where it was found. */ function fieldArraysOfText(text) {
283
+ const source = text.length > MAX_SOURCE_CHARS ? text.slice(0, MAX_SOURCE_CHARS) : text;
284
+ if (!/\brequired\b/.test(source) || !/\btype\b/.test(source) || !/\b(?:title|label)\b/.test(source)) return [];
285
+ const found = [];
286
+ const opening = /\[\s*(?:\/\/[^\n]*\s*)?\{/g;
287
+ let tries = 0;
288
+ for(let match = opening.exec(source); match; match = opening.exec(source)){
289
+ tries += 1;
290
+ if (tries > MAX_TRIES) break;
291
+ const read = readLiteral(source, match.index);
292
+ if (!read) continue;
293
+ for (const fields of fieldArraysIn(read.value))found.push({
294
+ fields,
295
+ at: match.index,
296
+ end: read.end
297
+ });
298
+ opening.lastIndex = read.end;
299
+ }
300
+ return found;
301
+ }
302
+ /** The words on a form's button, where its data says them: an entry of its own, else the nearest key that names them. */ function submitWordsOf(fields, source, at, end, words) {
303
+ const own = fields.find((entry)=>/^(?:submit|button)$/.test(typeKey(entry['type'])));
304
+ const label = own ? labelOf(own) || (typeof own['text'] === 'string' ? own['text'] : '') : '';
305
+ if (label) return words(label).slice(0, 120);
306
+ const around = 4000;
307
+ const from = Math.max(0, at - around);
308
+ const near = source.slice(from, end + around);
309
+ let best = '';
310
+ let distance = Infinity;
311
+ for (const match of near.matchAll(/["']?([A-Za-z_]*(?:submit|button)[A-Za-z_]*)["']?\s*:\s*(?:"([^"\\\n]{1,80})"|'([^'\\\n]{1,80})')/gi)){
312
+ if (!/^(?:submit)$|(?:submit|button)[a-z_]*(?:text|label|title|copy|words|value)$|(?:text|label)[a-z_]*(?:submit|button)$/i.test(match[1])) continue;
313
+ const place = from + match.index;
314
+ const away = place < at ? at - place : place > end ? place - end : 0;
315
+ if (away < distance) {
316
+ var _match_;
317
+ distance = away;
318
+ best = (_match_ = match[2]) != null ? _match_ : match[3];
319
+ }
320
+ }
321
+ return best ? words(best).slice(0, 120) : '';
322
+ }
323
+ /** A field's choices, as written: strings, or objects naming them. */ function optionsOf(entry, words) {
324
+ const list = [
325
+ 'options',
326
+ 'choices',
327
+ 'values',
328
+ 'items'
329
+ ].map((key)=>entry[key]).find(Array.isArray);
330
+ const out = [];
331
+ for (const option of list != null ? list : []){
332
+ const raw = typeof option === 'string' ? option : isObject(option) ? [
333
+ option['label'],
334
+ option['title'],
335
+ option['text'],
336
+ option['name'],
337
+ option['value']
338
+ ].find((value)=>typeof value === 'string') : null;
339
+ const text = typeof raw === 'string' ? words(raw).slice(0, 200) : '';
340
+ if (text) out.push(text);
341
+ }
342
+ return out;
343
+ }
344
+ const slugOf = (label)=>label.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '').slice(0, 60);
345
+ /** A field's name: what its data calls it, where that is a name a form can use, else its words. */ function nameOf(entry, label) {
346
+ const own = [
347
+ 'name',
348
+ 'key',
349
+ 'fieldName',
350
+ 'field_name'
351
+ ].map((key)=>entry[key]).find((value)=>typeof value === 'string' && /^[A-Za-z][\w-]{0,62}$/.test(value));
352
+ return typeof own === 'string' ? own : slugOf(label);
353
+ }
354
+ function isRequired(value) {
355
+ return value === true || value === 1 || typeof value === 'string' && /^(?:true|required|1)$/i.test(value);
356
+ }
357
+ /** A field array as the form it is; `null` where it asks for a password or a card. */ function formOf(fields, submit, words, maxFields) {
358
+ const out = [];
359
+ const leftOut = [];
360
+ const names = new Set();
361
+ for (const entry of fields){
362
+ var _entry_name, _FIELD_TYPES_get;
363
+ if (REFUSED_FIELD.test(`${typeKey(entry['type'])} ${String((_entry_name = entry['name']) != null ? _entry_name : '')} ${labelOf(entry)}`)) return null;
364
+ if (!isField(entry)) continue;
365
+ const type = typeKey(entry['type']);
366
+ if (NO_QUESTION.test(type)) continue;
367
+ const label = words(labelOf(entry)).slice(0, 200);
368
+ if (!label) continue;
369
+ if (FILE_TYPES.test(type)) {
370
+ leftOut.push(label);
371
+ continue;
372
+ }
373
+ if (out.length >= maxFields) continue;
374
+ let name = nameOf(entry, label);
375
+ for(let suffix = 2; names.has(name); suffix += 1)name = `${nameOf(entry, label)}-${suffix}`;
376
+ names.add(name);
377
+ const kind = (_FIELD_TYPES_get = FIELD_TYPES.get(type)) != null ? _FIELD_TYPES_get : 'text';
378
+ const options = optionsOf(entry, words);
379
+ const placeholder = typeof entry['placeholder'] === 'string' ? words(entry['placeholder']).slice(0, 200) : '';
380
+ out.push(_extends({
381
+ type: kind,
382
+ name,
383
+ label
384
+ }, isRequired(entry['required']) ? {
385
+ required: true
386
+ } : {}, placeholder ? {
387
+ placeholder
388
+ } : {}, (kind === 'select' || kind === 'radio' || kind === 'checkbox') && options.length ? {
389
+ options
390
+ } : {}));
391
+ }
392
+ if (!out.length) return null;
393
+ return _extends({
394
+ fields: out
395
+ }, submit ? {
396
+ submit
397
+ } : {}, leftOut.length ? {
398
+ leftOut
399
+ } : {});
400
+ }
401
+ /*------------------------------------------
402
+ * The page
403
+ *-----------------------------------------*/ /** A class's word that says it is a form, at a word's edge: `contact-form`, `form_block`, `contactForm`; never `transform` or `platform`. */ const FORM_HINT = /(?:^|[_-])forms?(?:$|[_-])|[a-z]Forms?(?:$|[_A-Z-])|^Forms?[A-Z]/;
404
+ const NOT_THIS_FORM = /search/i;
405
+ const OPEN_TAG = /<([a-zA-Z][\w:-]*)((?:[^>"']|"[^"]*"|'[^']*')*)>/g;
406
+ const CONTAINER_TAGS = new Set([
407
+ 'div',
408
+ 'section',
409
+ 'article',
410
+ 'aside',
411
+ 'main',
412
+ 'figure',
413
+ 'fieldset'
414
+ ]);
415
+ const CLASS_OF = /\bclass\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+))/i;
416
+ const HIDDEN_BODIES = /<(script|style|noscript|template)\b[\s\S]*?<\/\1\s*>/gi;
417
+ const blanked = (html)=>html.replace(HIDDEN_BODIES, (body)=>' '.repeat(body.length));
418
+ /** Whether an opening tag is an element a form can be attached to. */ function isHint(tag, attributes) {
419
+ var _ref, _ref1, _ref2;
420
+ const name = tag.toLowerCase();
421
+ if (!CONTAINER_TAGS.has(name) && !(name.includes('-') && /(?:^|-)forms?(?:$|-)/.test(name))) return false;
422
+ const match = CLASS_OF.exec(attributes);
423
+ const classes = ((_ref = (_ref1 = (_ref2 = match == null ? void 0 : match[1]) != null ? _ref2 : match == null ? void 0 : match[2]) != null ? _ref1 : match == null ? void 0 : match[3]) != null ? _ref : '').split(/\s+/).filter(Boolean);
424
+ if (/\brole\s*=\s*["']?form\b/i.test(attributes)) return true;
425
+ if (name.includes('-')) return !NOT_THIS_FORM.test(name);
426
+ return classes.some((word)=>FORM_HINT.test(word) && !NOT_THIS_FORM.test(word));
427
+ }
428
+ /**
429
+ * The forms a page holds as data, for a page with no `<form>` of its own but a
430
+ * search box. `words` turns what the data says into what a visitor reads.
431
+ */ export function siteImportDataForms(html, words, limits) {
432
+ const none = {
433
+ html,
434
+ kept: [],
435
+ removed: 0
436
+ };
437
+ if (!/\brequired\b/.test(html)) return none;
438
+ const shown = blanked(html);
439
+ for (const form of shown.matchAll(/<form\b(?:[^>"']|"[^"]*"|'[^']*')*>/gi)){
440
+ if (!/search/i.test(form[0])) return none;
441
+ }
442
+ const hints = [];
443
+ const dataAttributes = [];
444
+ for (const match of shown.matchAll(OPEN_TAG)){
445
+ const attributes = match[2];
446
+ if (isHint(match[1], attributes)) hints.push({
447
+ start: match.index,
448
+ end: match.index + match[0].length
449
+ });
450
+ if (!/\bdata-[\w-]+\s*=/.test(attributes) || !/required/.test(attributes)) continue;
451
+ for (const value of attributes.matchAll(/\bdata-[\w-]+\s*=\s*(?:"([^"]*)"|'([^']*)')/g)){
452
+ var _ref, _value_;
453
+ const raw = (_ref = (_value_ = value[1]) != null ? _value_ : value[2]) != null ? _ref : '';
454
+ if (/required/.test(raw)) dataAttributes.push({
455
+ at: match.index,
456
+ text: decodeQuotes(raw)
457
+ });
458
+ }
459
+ }
460
+ if (!hints.length) return none;
461
+ const sources = [
462
+ ...dataAttributes
463
+ ];
464
+ for (const script of html.matchAll(/<script\b((?:[^>"']|"[^"]*"|'[^']*')*)>([\s\S]*?)<\/script\s*>/gi)){
465
+ var _ref1;
466
+ var _exec_, _exec;
467
+ const attributes = script[1];
468
+ if (/\bsrc\s*=/i.test(attributes)) continue;
469
+ const type = (_ref1 = (_exec = /\btype\s*=\s*["']?([^"'\s>]+)/i.exec(attributes)) == null ? void 0 : (_exec_ = _exec[1]) == null ? void 0 : _exec_.toLowerCase()) != null ? _ref1 : '';
470
+ if (type && !/^(?:module|text\/javascript|application\/javascript|application\/json|text\/json|text\/plain|text\/x-[\w-]*json|application\/(?!ld\+)[\w.-]*\+json)$/.test(type)) continue;
471
+ sources.push({
472
+ at: script.index,
473
+ text: script[2]
474
+ });
475
+ }
476
+ sources.sort((a, b)=>a.at - b.at);
477
+ const kept = [];
478
+ const places = [];
479
+ const seen = new Set();
480
+ let removed = 0;
481
+ for (const source of sources){
482
+ for (const found of fieldArraysOfText(source.text)){
483
+ if (kept.length >= limits.forms) break;
484
+ const submit = submitWordsOf(found.fields, source.text, found.at, found.end, words);
485
+ const signature = JSON.stringify(found.fields.map((entry)=>[
486
+ typeKey(entry['type']),
487
+ labelOf(entry)
488
+ ]));
489
+ if (seen.has(signature)) continue;
490
+ seen.add(signature);
491
+ const form = formOf(found.fields, submit, words, limits.fieldsPerForm);
492
+ if (!form) {
493
+ if (found.fields.some((entry)=>{
494
+ var _entry_name;
495
+ return REFUSED_FIELD.test(`${typeKey(entry['type'])} ${String((_entry_name = entry['name']) != null ? _entry_name : '')} ${labelOf(entry)}`);
496
+ })) removed += 1;
497
+ continue;
498
+ }
499
+ const before = hints.filter((hint)=>hint.start <= source.at).pop();
500
+ const after = hints.find((hint)=>hint.start > source.at);
501
+ const place = before && (!after || source.at - before.end <= after.start - source.at) ? before : after;
502
+ if (!place) continue;
503
+ places.push({
504
+ end: place.end,
505
+ index: kept.length
506
+ });
507
+ kept.push(form);
508
+ }
509
+ }
510
+ if (!kept.length) return {
511
+ html,
512
+ kept: [],
513
+ removed
514
+ };
515
+ let out = html;
516
+ for (const place of [
517
+ ...places
518
+ ].sort((a, b)=>b.end - a.end || b.index - a.index)){
519
+ out = `${out.slice(0, place.end)} <aglyn-form data-form="${place.index}"> ${out.slice(place.end)}`;
520
+ }
521
+ return {
522
+ html: out,
523
+ kept,
524
+ removed
525
+ };
526
+ }
527
+ /** An attribute's value with the quotes a page had to escape to write JSON in it put back; the rest is left to `words`. */ function decodeQuotes(raw) {
528
+ return raw.replace(/&quot;|&#34;|&#x22;/gi, '"').replace(/&#39;|&#x27;|&apos;/gi, "'").replace(/&amp;/gi, '&');
529
+ }
530
+
531
+ //# sourceMappingURL=site-import-data-forms.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/site-import/site-import-data-forms.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/*==========================================\n * A FORM DEFINED IN DATA (AGL-4152).\n *\n * Plenty of site builders and widgets draw a form in the browser: the page\n * they serve has no `<form>`, only an empty box and the form's fields as data,\n * in a script block, a `data-*` attribute or a line of inline JavaScript. The\n * words a visitor would type into are then nowhere in the markup, and the page\n * comes in without its form.\n *\n * So on a page with no `<form>` of its own (a search box does not count), an\n * array of objects that each carry a `type` a form field has, a `title` or\n * `label` and a `required` is a form's fields, and it becomes a `SiteImportForm`\n * placed in the nearest element whose class says it is a form. No such element\n * and no form: an array like it with nowhere to go is some other thing's data.\n * The same array in two places is one form, and one that asks for a password\n * or a card is left out, as a `<form>` that does is.\n *\n * Nothing here runs anything a page wrote: `readLiteral` reads text as data,\n * and stops at the first thing that is not data.\n *=========================================*/\n\nimport type { SiteImportForm, SiteImportFormField } from './site-import-html'\n\n/** The most of one script or attribute read for a form's fields. */\nconst MAX_SOURCE_CHARS = 1_000_000\n/** The most arrays one source is tried at: a bundle holds thousands, and none of them is worth a slow read. */\nconst MAX_TRIES = 300\n/** The most values one array read may hold. */\nconst MAX_VALUES = 20_000\nconst MAX_DEPTH = 12\n\n/** A `type` as a form's field says it, lowered and its separators dropped, as the field it is. */\nconst FIELD_TYPES: ReadonlyMap<string, string> = new Map([\n ...['text', 'input', 'string', 'name', 'fullname', 'firstname', 'lastname', 'company', 'subject', 'address', 'singleline', 'shorttext', 'shortanswer', 'password', 'creditcard'].map((type): [string, string] => [type, 'text']),\n ...['email', 'emailaddress'].map((type): [string, string] => [type, 'email']),\n ...['tel', 'phone', 'telephone', 'phonenumber', 'mobile'].map((type): [string, string] => [type, 'tel']),\n ...['url', 'website'].map((type): [string, string] => [type, 'url']),\n ...['number', 'numeric', 'integer'].map((type): [string, string] => [type, 'number']),\n ...['date', 'datepicker'].map((type): [string, string] => [type, 'date']),\n ...['time', 'timepicker'].map((type): [string, string] => [type, 'time']),\n ...['textarea', 'message', 'multiline', 'longtext', 'longanswer', 'paragraph', 'comment', 'comments'].map((type): [string, string] => [type, 'textarea']),\n ...['select', 'dropdown'].map((type): [string, string] => [type, 'select']),\n ...['radio', 'radios', 'radiogroup', 'singlechoice'].map((type): [string, string] => [type, 'radio']),\n ...['checkbox', 'checkboxes', 'checkboxgroup', 'multiplechoice', 'consent'].map((type): [string, string] => [type, 'checkbox']),\n])\n/** Types a form holds that ask nothing a visitor reads as a question. */\nconst NO_QUESTION = /^(?:hidden|captcha|recaptcha|honeypot|submit|button|reset|section|heading|divider|html|separator|spacer|pagebreak)$/\nconst FILE_TYPES = /^(?:file|fileupload|upload|attachment|image)$/\nconst REFUSED_FIELD = /password|passcode|credit.?card|card.?(?:num|cvc|cvv|exp)|cc.?(?:num|number|exp|csc|cvv|cvc)|cvc|cvv|iban|routing|payment/i\n\ntype Fields = Array<Record<string, unknown>>\n\n/*------------------------------------------\n * Reading text as data\n *-----------------------------------------*/\n\nconst FAILED = Symbol('not data')\n\n/**\n * The array or object a text holds at `start`, and where it ends: JSON, and\n * the looser literal a person writes by hand (bare keys, single quotes, a\n * trailing comma, a comment). `null` at the first thing that is no literal.\n */\nfunction readLiteral(text: string, start: number): { value: unknown; end: number } | null {\n let at = start\n let values = 0\n const space = () => {\n for (;;) {\n const char = text[at]\n if (char === ' ' || char === '\\n' || char === '\\t' || char === '\\r') at += 1\n else if (char === '/' && text[at + 1] === '/') at = text.indexOf('\\n', at) < 0 ? text.length : text.indexOf('\\n', at)\n else if (char === '/' && text[at + 1] === '*') at = text.indexOf('*/', at) < 0 ? text.length : text.indexOf('*/', at) + 2\n else return\n }\n }\n const string = (quote: string): string | typeof FAILED => {\n let out = ''\n at += 1\n while (at < text.length) {\n const char = text[at] as string\n if (char === quote) {\n at += 1\n return out\n }\n if (char === '\\n') return FAILED\n if (char === '\\\\') {\n const next = text[at + 1]\n if (next === 'u' && /^[0-9a-f]{4}$/i.test(text.slice(at + 2, at + 6))) {\n out += String.fromCharCode(parseInt(text.slice(at + 2, at + 6), 16))\n at += 6\n continue\n }\n out += next === 'n' ? '\\n' : next === 't' ? ' ' : next === 'r' ? '' : (next ?? '')\n at += 2\n continue\n }\n out += char\n at += 1\n }\n return FAILED\n }\n const value = (depth: number): unknown => {\n values += 1\n if (values > MAX_VALUES || depth > MAX_DEPTH) return FAILED\n space()\n const char = text[at]\n if (char === '\"' || char === \"'\") return string(char)\n if (char === '[') {\n at += 1\n const list: unknown[] = []\n for (;;) {\n space()\n if (text[at] === ']') {\n at += 1\n return list\n }\n const item = value(depth + 1)\n if (item === FAILED) return FAILED\n list.push(item)\n space()\n if (text[at] === ',') at += 1\n else if (text[at] !== ']') return FAILED\n }\n }\n if (char === '{') {\n at += 1\n const object: Record<string, unknown> = {}\n for (;;) {\n space()\n if (text[at] === '}') {\n at += 1\n return object\n }\n const quote = text[at]\n let key: string | typeof FAILED\n if (quote === '\"' || quote === \"'\") key = string(quote)\n else {\n const bare = /^[A-Za-z_$][\\w$]*/.exec(text.slice(at, at + 64))\n key = bare ? bare[0] : FAILED\n if (bare) at += bare[0].length\n }\n if (key === FAILED) return FAILED\n space()\n if (text[at] !== ':') return FAILED\n at += 1\n const item = value(depth + 1)\n if (item === FAILED) return FAILED\n if (key !== '__proto__') object[key as string] = item\n space()\n if (text[at] === ',') at += 1\n else if (text[at] !== '}') return FAILED\n }\n }\n const word = /^(?:true|false|null|undefined|-?\\d+(?:\\.\\d+)?(?:e[+-]?\\d+)?)/i.exec(text.slice(at, at + 40))\n if (!word) return FAILED\n at += word[0].length\n if (/^(?:true|false)$/i.test(word[0])) return word[0].toLowerCase() === 'true'\n if (/^(?:null|undefined)$/i.test(word[0])) return null\n return Number(word[0])\n }\n const read = value(0)\n return read === FAILED ? null : { value: read, end: at }\n}\n\n/*------------------------------------------\n * Which arrays are a form's fields\n *-----------------------------------------*/\n\nconst isObject = (value: unknown): value is Record<string, unknown> => !!value && typeof value === 'object' && !Array.isArray(value)\nconst typeKey = (value: unknown) => (typeof value === 'string' ? value.toLowerCase().replace(/[\\s_-]+/g, '') : '')\nconst labelOf = (entry: Record<string, unknown>) => (typeof entry['title'] === 'string' ? entry['title'] : typeof entry['label'] === 'string' ? entry['label'] : '')\nconst isField = (entry: Record<string, unknown>) => typeKey(entry['type']) !== '' && labelOf(entry).trim() !== '' && 'required' in entry\nconst asksQuestion = (entry: Record<string, unknown>) => FIELD_TYPES.has(typeKey(entry['type']))\n\n/** Whether an array is a form's fields: objects, most of them fields, at least half of what is typed a kind of question a form asks. */\nfunction isFieldArray(value: unknown): value is Fields {\n if (!Array.isArray(value) || !value.length || !value.every(isObject)) return false\n const fields = (value as Fields).filter(isField)\n if (fields.length * 2 < value.length) return false\n return fields.filter(asksQuestion).length * 2 >= fields.length && fields.some(asksQuestion)\n}\n\n/** The arrays a value read holds that are a form's fields, outermost first. */\nfunction fieldArraysIn(value: unknown, depth = 0): Fields[] {\n if (depth > MAX_DEPTH) return []\n if (isFieldArray(value)) return [value]\n if (Array.isArray(value)) return value.flatMap((item) => fieldArraysIn(item, depth + 1))\n if (isObject(value)) return Object.values(value).flatMap((item) => fieldArraysIn(item, depth + 1))\n return []\n}\n\n/** The field arrays a text holds, each with where it was found. */\nfunction fieldArraysOfText(text: string): Array<{ fields: Fields; at: number; end: number }> {\n const source = text.length > MAX_SOURCE_CHARS ? text.slice(0, MAX_SOURCE_CHARS) : text\n if (!/\\brequired\\b/.test(source) || !/\\btype\\b/.test(source) || !/\\b(?:title|label)\\b/.test(source)) return []\n const found: Array<{ fields: Fields; at: number; end: number }> = []\n const opening = /\\[\\s*(?:\\/\\/[^\\n]*\\s*)?\\{/g\n let tries = 0\n for (let match = opening.exec(source); match; match = opening.exec(source)) {\n tries += 1\n if (tries > MAX_TRIES) break\n const read = readLiteral(source, match.index)\n if (!read) continue\n for (const fields of fieldArraysIn(read.value)) found.push({ fields, at: match.index, end: read.end })\n opening.lastIndex = read.end\n }\n return found\n}\n\n/** The words on a form's button, where its data says them: an entry of its own, else the nearest key that names them. */\nfunction submitWordsOf(fields: Fields, source: string, at: number, end: number, words: (raw: string) => string): string {\n const own = fields.find((entry) => /^(?:submit|button)$/.test(typeKey(entry['type'])))\n const label = own ? labelOf(own) || (typeof own['text'] === 'string' ? own['text'] : '') : ''\n if (label) return words(label).slice(0, 120)\n const around = 4_000\n const from = Math.max(0, at - around)\n const near = source.slice(from, end + around)\n let best = ''\n let distance = Infinity\n for (const match of near.matchAll(/[\"']?([A-Za-z_]*(?:submit|button)[A-Za-z_]*)[\"']?\\s*:\\s*(?:\"([^\"\\\\\\n]{1,80})\"|'([^'\\\\\\n]{1,80})')/gi)) {\n if (!/^(?:submit)$|(?:submit|button)[a-z_]*(?:text|label|title|copy|words|value)$|(?:text|label)[a-z_]*(?:submit|button)$/i.test(match[1] as string)) continue\n const place = from + match.index\n const away = place < at ? at - place : place > end ? place - end : 0\n if (away < distance) {\n distance = away\n best = (match[2] ?? match[3]) as string\n }\n }\n return best ? words(best).slice(0, 120) : ''\n}\n\n/** A field's choices, as written: strings, or objects naming them. */\nfunction optionsOf(entry: Record<string, unknown>, words: (raw: string) => string): string[] {\n const list = ['options', 'choices', 'values', 'items'].map((key) => entry[key]).find(Array.isArray) as unknown[] | undefined\n const out: string[] = []\n for (const option of list ?? []) {\n const raw = typeof option === 'string' ? option : isObject(option) ? [option['label'], option['title'], option['text'], option['name'], option['value']].find((value) => typeof value === 'string') : null\n const text = typeof raw === 'string' ? words(raw).slice(0, 200) : ''\n if (text) out.push(text)\n }\n return out\n}\n\nconst slugOf = (label: string) => label.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '').slice(0, 60)\n\n/** A field's name: what its data calls it, where that is a name a form can use, else its words. */\nfunction nameOf(entry: Record<string, unknown>, label: string): string {\n const own = ['name', 'key', 'fieldName', 'field_name'].map((key) => entry[key]).find((value) => typeof value === 'string' && /^[A-Za-z][\\w-]{0,62}$/.test(value))\n return typeof own === 'string' ? own : slugOf(label)\n}\n\nfunction isRequired(value: unknown): boolean {\n return value === true || value === 1 || (typeof value === 'string' && /^(?:true|required|1)$/i.test(value))\n}\n\n/** A field array as the form it is; `null` where it asks for a password or a card. */\nfunction formOf(fields: Fields, submit: string, words: (raw: string) => string, maxFields: number): SiteImportForm | null {\n const out: SiteImportFormField[] = []\n const leftOut: string[] = []\n const names = new Set<string>()\n for (const entry of fields) {\n if (REFUSED_FIELD.test(`${typeKey(entry['type'])} ${String(entry['name'] ?? '')} ${labelOf(entry)}`)) return null\n if (!isField(entry)) continue\n const type = typeKey(entry['type'])\n if (NO_QUESTION.test(type)) continue\n const label = words(labelOf(entry)).slice(0, 200)\n if (!label) continue\n if (FILE_TYPES.test(type)) {\n leftOut.push(label)\n continue\n }\n if (out.length >= maxFields) continue\n let name = nameOf(entry, label)\n for (let suffix = 2; names.has(name); suffix += 1) name = `${nameOf(entry, label)}-${suffix}`\n names.add(name)\n const kind = FIELD_TYPES.get(type) ?? 'text'\n const options = optionsOf(entry, words)\n const placeholder = typeof entry['placeholder'] === 'string' ? words(entry['placeholder']).slice(0, 200) : ''\n out.push({\n type: kind,\n name,\n label,\n ...(isRequired(entry['required']) ? { required: true as const } : {}),\n ...(placeholder ? { placeholder } : {}),\n ...((kind === 'select' || kind === 'radio' || kind === 'checkbox') && options.length ? { options } : {}),\n })\n }\n if (!out.length) return null\n return { fields: out, ...(submit ? { submit } : {}), ...(leftOut.length ? { leftOut } : {}) }\n}\n\n/*------------------------------------------\n * The page\n *-----------------------------------------*/\n\n/** A class's word that says it is a form, at a word's edge: `contact-form`, `form_block`, `contactForm`; never `transform` or `platform`. */\nconst FORM_HINT = /(?:^|[_-])forms?(?:$|[_-])|[a-z]Forms?(?:$|[_A-Z-])|^Forms?[A-Z]/\nconst NOT_THIS_FORM = /search/i\nconst OPEN_TAG = /<([a-zA-Z][\\w:-]*)((?:[^>\"']|\"[^\"]*\"|'[^']*')*)>/g\nconst CONTAINER_TAGS = new Set(['div', 'section', 'article', 'aside', 'main', 'figure', 'fieldset'])\nconst CLASS_OF = /\\bclass\\s*=\\s*(?:\"([^\"]*)\"|'([^']*)'|([^\\s>]+))/i\nconst HIDDEN_BODIES = /<(script|style|noscript|template)\\b[\\s\\S]*?<\\/\\1\\s*>/gi\n\nconst blanked = (html: string) => html.replace(HIDDEN_BODIES, (body) => ' '.repeat(body.length))\n\n/** Whether an opening tag is an element a form can be attached to. */\nfunction isHint(tag: string, attributes: string): boolean {\n const name = tag.toLowerCase()\n if (!CONTAINER_TAGS.has(name) && !(name.includes('-') && /(?:^|-)forms?(?:$|-)/.test(name))) return false\n const match = CLASS_OF.exec(attributes)\n const classes = (match?.[1] ?? match?.[2] ?? match?.[3] ?? '').split(/\\s+/).filter(Boolean)\n if (/\\brole\\s*=\\s*[\"']?form\\b/i.test(attributes)) return true\n if (name.includes('-')) return !NOT_THIS_FORM.test(name)\n return classes.some((word) => FORM_HINT.test(word) && !NOT_THIS_FORM.test(word))\n}\n\nexport interface SiteImportDataFormsResult {\n /** The page, a marker at each form's place. */\n html: string\n kept: SiteImportForm[]\n /** Forms left out because they ask for a password or a card. */\n removed: number\n}\n\n/**\n * The forms a page holds as data, for a page with no `<form>` of its own but a\n * search box. `words` turns what the data says into what a visitor reads.\n */\nexport function siteImportDataForms(\n html: string,\n words: (raw: string) => string,\n limits: { forms: number; fieldsPerForm: number },\n): SiteImportDataFormsResult {\n const none: SiteImportDataFormsResult = { html, kept: [], removed: 0 }\n if (!/\\brequired\\b/.test(html)) return none\n const shown = blanked(html)\n for (const form of shown.matchAll(/<form\\b(?:[^>\"']|\"[^\"]*\"|'[^']*')*>/gi)) {\n if (!/search/i.test(form[0])) return none\n }\n const hints: Array<{ start: number; end: number }> = []\n const dataAttributes: Array<{ at: number; text: string }> = []\n for (const match of shown.matchAll(OPEN_TAG)) {\n const attributes = match[2] as string\n if (isHint(match[1] as string, attributes)) hints.push({ start: match.index, end: match.index + match[0].length })\n if (!/\\bdata-[\\w-]+\\s*=/.test(attributes) || !/required/.test(attributes)) continue\n for (const value of attributes.matchAll(/\\bdata-[\\w-]+\\s*=\\s*(?:\"([^\"]*)\"|'([^']*)')/g)) {\n const raw = value[1] ?? value[2] ?? ''\n if (/required/.test(raw)) dataAttributes.push({ at: match.index, text: decodeQuotes(raw) })\n }\n }\n if (!hints.length) return none\n const sources: Array<{ at: number; text: string }> = [...dataAttributes]\n for (const script of html.matchAll(/<script\\b((?:[^>\"']|\"[^\"]*\"|'[^']*')*)>([\\s\\S]*?)<\\/script\\s*>/gi)) {\n const attributes = script[1] as string\n if (/\\bsrc\\s*=/i.test(attributes)) continue\n const type = /\\btype\\s*=\\s*[\"']?([^\"'\\s>]+)/i.exec(attributes)?.[1]?.toLowerCase() ?? ''\n if (type && !/^(?:module|text\\/javascript|application\\/javascript|application\\/json|text\\/json|text\\/plain|text\\/x-[\\w-]*json|application\\/(?!ld\\+)[\\w.-]*\\+json)$/.test(type)) continue\n sources.push({ at: script.index, text: script[2] as string })\n }\n sources.sort((a, b) => a.at - b.at)\n const kept: SiteImportForm[] = []\n const places: Array<{ end: number; index: number }> = []\n const seen = new Set<string>()\n let removed = 0\n for (const source of sources) {\n for (const found of fieldArraysOfText(source.text)) {\n if (kept.length >= limits.forms) break\n const submit = submitWordsOf(found.fields, source.text, found.at, found.end, words)\n const signature = JSON.stringify(found.fields.map((entry) => [typeKey(entry['type']), labelOf(entry)]))\n if (seen.has(signature)) continue\n seen.add(signature)\n const form = formOf(found.fields, submit, words, limits.fieldsPerForm)\n if (!form) {\n if (found.fields.some((entry) => REFUSED_FIELD.test(`${typeKey(entry['type'])} ${String(entry['name'] ?? '')} ${labelOf(entry)}`))) removed += 1\n continue\n }\n const before = hints.filter((hint) => hint.start <= source.at).pop()\n const after = hints.find((hint) => hint.start > source.at)\n const place = before && (!after || source.at - before.end <= after.start - source.at) ? before : after\n if (!place) continue\n places.push({ end: place.end, index: kept.length })\n kept.push(form)\n }\n }\n if (!kept.length) return { html, kept: [], removed }\n let out = html\n for (const place of [...places].sort((a, b) => b.end - a.end || b.index - a.index)) {\n out = `${out.slice(0, place.end)} <aglyn-form data-form=\"${place.index}\"> ${out.slice(place.end)}`\n }\n return { html: out, kept, removed }\n}\n\n/** An attribute's value with the quotes a page had to escape to write JSON in it put back; the rest is left to `words`. */\nfunction decodeQuotes(raw: string): string {\n return raw.replace(/&quot;|&#34;|&#x22;/gi, '\"').replace(/&#39;|&#x27;|&apos;/gi, \"'\").replace(/&amp;/gi, '&')\n}\n"],"names":["MAX_SOURCE_CHARS","MAX_TRIES","MAX_VALUES","MAX_DEPTH","FIELD_TYPES","Map","map","type","NO_QUESTION","FILE_TYPES","REFUSED_FIELD","FAILED","Symbol","readLiteral","text","start","at","values","space","char","indexOf","length","string","quote","out","next","test","slice","String","fromCharCode","parseInt","value","depth","list","item","push","object","key","bare","exec","word","toLowerCase","Number","read","end","isObject","Array","isArray","typeKey","replace","labelOf","entry","isField","trim","asksQuestion","has","isFieldArray","every","fields","filter","some","fieldArraysIn","flatMap","Object","fieldArraysOfText","source","found","opening","tries","match","index","lastIndex","submitWordsOf","words","own","find","label","around","from","Math","max","near","best","distance","Infinity","matchAll","place","away","optionsOf","option","raw","slugOf","nameOf","isRequired","formOf","submit","maxFields","leftOut","names","Set","name","suffix","add","kind","get","options","placeholder","required","FORM_HINT","NOT_THIS_FORM","OPEN_TAG","CONTAINER_TAGS","CLASS_OF","HIDDEN_BODIES","blanked","html","body","repeat","isHint","tag","attributes","includes","classes","split","Boolean","siteImportDataForms","limits","none","kept","removed","shown","form","hints","dataAttributes","decodeQuotes","sources","script","sort","a","b","places","seen","forms","signature","JSON","stringify","fieldsPerForm","before","hint","pop","after"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;;;;;;;;;;2CAmB2C;AAI3C,kEAAkE,GAClE,MAAMA,mBAAmB;AACzB,6GAA6G,GAC7G,MAAMC,YAAY;AAClB,6CAA6C,GAC7C,MAAMC,aAAa;AACnB,MAAMC,YAAY;AAElB,gGAAgG,GAChG,MAAMC,cAA2C,IAAIC,IAAI;OACpD;QAAC;QAAQ;QAAS;QAAU;QAAQ;QAAY;QAAa;QAAY;QAAW;QAAW;QAAW;QAAc;QAAa;QAAe;QAAY;KAAa,CAACC,GAAG,CAAC,CAACC,OAA2B;YAACA;YAAM;SAAO;OAC5N;QAAC;QAAS;KAAe,CAACD,GAAG,CAAC,CAACC,OAA2B;YAACA;YAAM;SAAQ;OACzE;QAAC;QAAO;QAAS;QAAa;QAAe;KAAS,CAACD,GAAG,CAAC,CAACC,OAA2B;YAACA;YAAM;SAAM;OACpG;QAAC;QAAO;KAAU,CAACD,GAAG,CAAC,CAACC,OAA2B;YAACA;YAAM;SAAM;OAChE;QAAC;QAAU;QAAW;KAAU,CAACD,GAAG,CAAC,CAACC,OAA2B;Y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,KAAK,IAAIkD,OAAOjD,EAAE,EAAEqI,GAAG;YAClE,MAAMC,QAAQlB,MAAMzD,IAAI,CAAC,CAACyE,OAASA,KAAKrI,KAAK,GAAGkD,OAAOjD,EAAE;YACzD,MAAMsE,QAAQ6D,UAAW,CAAA,CAACG,SAASrF,OAAOjD,EAAE,GAAGmI,OAAOvG,GAAG,IAAI0G,MAAMvI,KAAK,GAAGkD,OAAOjD,EAAE,AAAD,IAAKmI,SAASG;YACjG,IAAI,CAAChE,OAAO;YACZsD,OAAOzG,IAAI,CAAC;gBAAES,KAAK0C,MAAM1C,GAAG;gBAAE0B,OAAO0D,KAAK3G,MAAM;YAAC;YACjD2G,KAAK7F,IAAI,CAACgG;QACZ;IACF;IACA,IAAI,CAACH,KAAK3G,MAAM,EAAE,OAAO;QAAE8F;QAAMa,MAAM,EAAE;QAAEC;IAAQ;IACnD,IAAIzG,MAAM2F;IACV,KAAK,MAAM7B,SAAS;WAAIsD;KAAO,CAACH,IAAI,CAAC,CAACC,GAAGC,IAAMA,EAAE/F,GAAG,GAAG8F,EAAE9F,GAAG,IAAI+F,EAAErE,KAAK,GAAGoE,EAAEpE,KAAK,EAAG;QAClF9C,MAAM,GAAGA,IAAIG,KAAK,CAAC,GAAG2D,MAAM1C,GAAG,EAAE,wBAAwB,EAAE0C,MAAMhB,KAAK,CAAC,GAAG,EAAE9C,IAAIG,KAAK,CAAC2D,MAAM1C,GAAG,GAAG;IACpG;IACA,OAAO;QAAEuE,MAAM3F;QAAKwG;QAAMC;IAAQ;AACpC;AAEA,yHAAyH,GACzH,SAASK,aAAa5C,GAAW;IAC/B,OAAOA,IAAIzC,OAAO,CAAC,yBAAyB,KAAKA,OAAO,CAAC,yBAAyB,KAAKA,OAAO,CAAC,WAAW;AAC5G"}
@@ -146,6 +146,8 @@ export interface SiteImportExtract {
146
146
  description: string;
147
147
  lang: string | null;
148
148
  canonical: string | null;
149
+ /** Its head asks search engines not to list it: `<meta name="robots" content="noindex">` (AGL-4152). */
150
+ noindex: boolean;
149
151
  /** The share card, `og:image` (or `twitter:image`), as an absolute address (AGL-4083). */
150
152
  ogImage: string | null;
151
153
  /** The site's own name, `og:site_name` (or `application-name`); empty when absent. */
@@ -304,7 +306,8 @@ export declare const SITE_IMPORT_PAGE_LIMITS: {
304
306
  readonly svgIcons: 200;
305
307
  readonly anchors: 800;
306
308
  readonly styleChars: 1500000;
307
- readonly stylesheets: 4;
309
+ /** The links listed (AGL-4152); how much of them is read is a byte budget's to say (`SITE_IMPORT_SHEET_LIMITS`). */
310
+ readonly stylesheets: 24;
308
311
  /** A page's videos (AGL-4140). */
309
312
  readonly videos: 10;
310
313
  };
@@ -322,6 +325,12 @@ export declare function resolveSiteUrl(raw: string | undefined, base: string): U
322
325
  * a number in it; `null` for anything else (a script, a jump on the page).
323
326
  */
324
327
  export declare function resolveSiteLink(raw: string | undefined, base: string): string | null;
328
+ /**
329
+ * The stylesheets a page links (AGL-4152), to read: every one, on its own host
330
+ * or a CDN's, print ones and comments left out, Google Fonts' read by its
331
+ * address alone (`siteImportGoogleFamilies`).
332
+ */
333
+ export declare function siteImportStylesheetLinks(html: string, pageUrl: string): string[];
325
334
  /**
326
335
  * The words, structure, pictures and links of one page.
327
336
  *