@aglyn/plugins-ai 1.0.0-beta.271 → 1.0.0-beta.272

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 (94) hide show
  1. package/package.json +17 -17
  2. package/src/lib/activity/ai-activity-actions.d.ts +4 -3
  3. package/src/lib/activity/ai-activity-actions.js +3 -0
  4. package/src/lib/activity/ai-activity-actions.js.map +1 -1
  5. package/src/lib/components/ai-site-build-page.component.js +18 -0
  6. package/src/lib/components/ai-site-build-page.component.js.map +1 -1
  7. package/src/lib/components/ai-site-import-job.component.d.ts +41 -0
  8. package/src/lib/components/ai-site-import-job.component.js +707 -0
  9. package/src/lib/components/ai-site-import-job.component.js.map +1 -0
  10. package/src/lib/components/ai-site-import-start.component.d.ts +64 -0
  11. package/src/lib/components/ai-site-import-start.component.js +335 -0
  12. package/src/lib/components/ai-site-import-start.component.js.map +1 -0
  13. package/src/lib/components/ai-site-ownership-proof.component.d.ts +42 -0
  14. package/src/lib/components/ai-site-ownership-proof.component.js +353 -0
  15. package/src/lib/components/ai-site-ownership-proof.component.js.map +1 -0
  16. package/src/lib/components/ai-site-start-card.component.js +165 -91
  17. package/src/lib/components/ai-site-start-card.component.js.map +1 -1
  18. package/src/lib/jobs/ai-job-drafts.d.ts +14 -0
  19. package/src/lib/jobs/ai-job-drafts.js +24 -0
  20. package/src/lib/jobs/ai-job-drafts.js.map +1 -1
  21. package/src/lib/jobs/ai-job-import-step.d.ts +136 -0
  22. package/src/lib/jobs/ai-job-import-step.js +809 -0
  23. package/src/lib/jobs/ai-job-import-step.js.map +1 -0
  24. package/src/lib/jobs/ai-job-page-language.d.ts +39 -1
  25. package/src/lib/jobs/ai-job-page-language.js +62 -4
  26. package/src/lib/jobs/ai-job-page-language.js.map +1 -1
  27. package/src/lib/jobs/ai-job-page-step.d.ts +2 -2
  28. package/src/lib/jobs/ai-job-page-step.js +5 -2
  29. package/src/lib/jobs/ai-job-page-step.js.map +1 -1
  30. package/src/lib/jobs/ai-job-text-step.d.ts +7 -0
  31. package/src/lib/jobs/ai-job-text-step.js.map +1 -1
  32. package/src/lib/jobs/ai-jobs.d.ts +5 -0
  33. package/src/lib/jobs/ai-jobs.js +15 -3
  34. package/src/lib/jobs/ai-jobs.js.map +1 -1
  35. package/src/lib/jobs/ai-layout-owner-photos.d.ts +16 -1
  36. package/src/lib/jobs/ai-layout-owner-photos.js +47 -0
  37. package/src/lib/jobs/ai-layout-owner-photos.js.map +1 -1
  38. package/src/lib/jobs/ai-theme-brand-inputs.d.ts +61 -3
  39. package/src/lib/jobs/ai-theme-brand-inputs.js +117 -27
  40. package/src/lib/jobs/ai-theme-brand-inputs.js.map +1 -1
  41. package/src/lib/model/ai-credit-estimate.d.ts +20 -0
  42. package/src/lib/model/ai-credit-estimate.js +13 -0
  43. package/src/lib/model/ai-credit-estimate.js.map +1 -1
  44. package/src/lib/model/ai-job-activity.d.ts +2 -2
  45. package/src/lib/model/ai-job-activity.js +6 -4
  46. package/src/lib/model/ai-job-activity.js.map +1 -1
  47. package/src/lib/model/ai-job-notice.js +18 -4
  48. package/src/lib/model/ai-job-notice.js.map +1 -1
  49. package/src/lib/model/ai-jobs.types.d.ts +29 -2
  50. package/src/lib/model/ai-jobs.types.js +2 -1
  51. package/src/lib/model/ai-jobs.types.js.map +1 -1
  52. package/src/lib/model/ai-site-import-view.d.ts +130 -0
  53. package/src/lib/model/ai-site-import-view.js +182 -0
  54. package/src/lib/model/ai-site-import-view.js.map +1 -0
  55. package/src/lib/model/ai-site-import.d.ts +302 -0
  56. package/src/lib/model/ai-site-import.js +526 -0
  57. package/src/lib/model/ai-site-import.js.map +1 -0
  58. package/src/lib/model/ai-site-start.d.ts +22 -9
  59. package/src/lib/model/ai-site-start.js +64 -23
  60. package/src/lib/model/ai-site-start.js.map +1 -1
  61. package/src/lib/server/ai-jobs-route.js +11 -0
  62. package/src/lib/server/ai-jobs-route.js.map +1 -1
  63. package/src/lib/server/ai-site-import-route.d.ts +89 -0
  64. package/src/lib/server/ai-site-import-route.js +356 -0
  65. package/src/lib/server/ai-site-import-route.js.map +1 -0
  66. package/src/lib/server.js +14 -0
  67. package/src/lib/server.js.map +1 -1
  68. package/src/lib/site-import/fixtures/site-import-crawl-recordings.d.ts +45 -0
  69. package/src/lib/site-import/fixtures/site-import-crawl-recordings.js +313 -0
  70. package/src/lib/site-import/fixtures/site-import-crawl-recordings.js.map +1 -0
  71. package/src/lib/site-import/fixtures/site-import-wave-recordings.d.ts +50 -0
  72. package/src/lib/site-import/fixtures/site-import-wave-recordings.js +217 -0
  73. package/src/lib/site-import/fixtures/site-import-wave-recordings.js.map +1 -0
  74. package/src/lib/site-import/site-import-crawl.d.ts +163 -0
  75. package/src/lib/site-import/site-import-crawl.js +467 -0
  76. package/src/lib/site-import/site-import-crawl.js.map +1 -0
  77. package/src/lib/site-import/site-import-flag.d.ts +23 -0
  78. package/src/lib/site-import/site-import-flag.js +23 -0
  79. package/src/lib/site-import/site-import-flag.js.map +1 -0
  80. package/src/lib/site-import/site-import-html.d.ts +94 -0
  81. package/src/lib/site-import/site-import-html.js +462 -0
  82. package/src/lib/site-import/site-import-html.js.map +1 -0
  83. package/src/lib/site-import/site-import-images.d.ts +54 -0
  84. package/src/lib/site-import/site-import-images.js +204 -0
  85. package/src/lib/site-import/site-import-images.js.map +1 -0
  86. package/src/lib/site-import/site-import-page.d.ts +48 -0
  87. package/src/lib/site-import/site-import-page.js +150 -0
  88. package/src/lib/site-import/site-import-page.js.map +1 -0
  89. package/src/lib/site-import/site-import-review.d.ts +40 -0
  90. package/src/lib/site-import/site-import-review.js +149 -0
  91. package/src/lib/site-import/site-import-review.js.map +1 -0
  92. package/src/lib/site-import/site-import-robots.d.ts +52 -0
  93. package/src/lib/site-import/site-import-robots.js +126 -0
  94. package/src/lib/site-import/site-import-robots.js.map +1 -0
@@ -0,0 +1,707 @@
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
+ */ 'use client';
17
+ import { _ as _extends } from "@swc/helpers/_/_extends";
18
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
19
+ import { PageHeaderRecord } from "@aglyn/aglyn/app-utils/page-header-record-context";
20
+ import { buildRoute, Route } from "@aglyn/aglyn/app-utils/console-routes";
21
+ import { mdiAlertCircle, mdiCheckCircle, mdiChevronDown, mdiClockOutline, mdiMinusCircleOutline } from "@aglyn/shared-data-mdi";
22
+ import { AppLink, HelpTip, MdiIcon } from "@aglyn/shared-ui-jsx";
23
+ import { Accordion, AccordionDetails, AccordionSummary, Alert, Box, Button, Card, CircularProgress, Container, LinearProgress, Stack, Typography } from "@mui/material";
24
+ import { useCallback, useState } from "react";
25
+ import { aiSiteImportReviewWave, aiSiteImportRunningWave } from "../model/ai-site-import.js";
26
+ import { aiSiteImportFoundText, aiSiteImportLeftOutLines, aiSiteImportPhaseOf, aiSiteImportPlanText, aiSiteImportStartAction, aiSiteImportWaveRows, aiSiteImportWaveSpent } from "../model/ai-site-import-view.js";
27
+ import { AiJobCancelButton } from "./ai-job-cancel.component.js";
28
+ import { aiCreditsBillingHref, aiJobOutputHref } from "./ai-job-links.js";
29
+ import { AI_SITE_IMPORT_HELP } from "./ai-site-import-start.component.js";
30
+ import { AiSiteOwnershipProof, postAiSiteOwnership } from "./ai-site-ownership-proof.component.js";
31
+ const ROW_ICON = {
32
+ done: {
33
+ path: mdiCheckCircle.path,
34
+ color: 'success.main',
35
+ label: 'In'
36
+ },
37
+ waiting: {
38
+ path: mdiClockOutline.path,
39
+ color: 'text.disabled',
40
+ label: 'Waiting'
41
+ },
42
+ failed: {
43
+ path: mdiAlertCircle.path,
44
+ color: 'error.main',
45
+ label: 'Could not be brought in'
46
+ },
47
+ skipped: {
48
+ path: mdiMinusCircleOutline.path,
49
+ color: 'text.disabled',
50
+ label: 'Left out'
51
+ }
52
+ };
53
+ function RowIcon({ state }) {
54
+ if (state === 'active') return /*#__PURE__*/ _jsx(CircularProgress, {
55
+ size: 20,
56
+ "aria-label": "In progress"
57
+ });
58
+ const icon = ROW_ICON[state];
59
+ return /*#__PURE__*/ _jsx(Box, {
60
+ component: "span",
61
+ role: "img",
62
+ "aria-label": icon.label,
63
+ sx: {
64
+ color: icon.color,
65
+ display: 'inline-flex',
66
+ fontSize: (theme)=>theme.spacing(2.5)
67
+ },
68
+ children: /*#__PURE__*/ _jsx(MdiIcon, {
69
+ path: icon.path,
70
+ "aria-hidden": true
71
+ })
72
+ });
73
+ }
74
+ /** One wave's pages: where each was, where it is now, how it went, and its draft to open. */ function WaveRows({ job, wave, orgSlug }) {
75
+ const rows = aiSiteImportWaveRows(job, wave);
76
+ return /*#__PURE__*/ _jsx(Box, {
77
+ component: "ol",
78
+ "aria-label": wave.label,
79
+ sx: {
80
+ listStyle: 'none',
81
+ m: 0,
82
+ p: {
83
+ xs: 2,
84
+ sm: 3
85
+ }
86
+ },
87
+ children: /*#__PURE__*/ _jsx(Stack, {
88
+ spacing: 2,
89
+ children: rows.map((row)=>{
90
+ const output = row.outputId ? job.outputs.find((entry)=>entry.id === row.outputId) : undefined;
91
+ const href = output ? aiJobOutputHref(output, orgSlug) : null;
92
+ return /*#__PURE__*/ _jsxs(Stack, {
93
+ component: "li",
94
+ direction: "row",
95
+ spacing: 2,
96
+ sx: {
97
+ alignItems: 'flex-start'
98
+ },
99
+ children: [
100
+ /*#__PURE__*/ _jsx(Box, {
101
+ sx: {
102
+ width: (theme)=>theme.spacing(3),
103
+ display: 'flex',
104
+ justifyContent: 'center'
105
+ },
106
+ children: /*#__PURE__*/ _jsx(RowIcon, {
107
+ state: row.state
108
+ })
109
+ }),
110
+ /*#__PURE__*/ _jsxs(Box, {
111
+ sx: {
112
+ flex: 1,
113
+ minWidth: 0
114
+ },
115
+ children: [
116
+ /*#__PURE__*/ _jsxs(Stack, {
117
+ direction: "row",
118
+ spacing: 1,
119
+ sx: {
120
+ alignItems: 'baseline',
121
+ justifyContent: 'space-between'
122
+ },
123
+ children: [
124
+ /*#__PURE__*/ _jsx(Typography, {
125
+ variant: "body1",
126
+ color: row.state === 'waiting' || row.state === 'skipped' ? 'text.secondary' : 'text.primary',
127
+ children: row.title
128
+ }),
129
+ href && row.state === 'done' ? /*#__PURE__*/ _jsx(Button, {
130
+ size: "small",
131
+ component: AppLink,
132
+ href: href,
133
+ children: 'Open draft'
134
+ }) : null
135
+ ]
136
+ }),
137
+ /*#__PURE__*/ _jsx(Typography, {
138
+ variant: "body2",
139
+ color: "text.secondary",
140
+ sx: {
141
+ overflowWrap: 'anywhere'
142
+ },
143
+ children: `${row.from} → ${row.to}`
144
+ }),
145
+ row.photos ? /*#__PURE__*/ _jsx(Typography, {
146
+ variant: "body2",
147
+ color: "text.secondary",
148
+ children: row.photos
149
+ }) : null,
150
+ row.note && row.state !== 'done' ? /*#__PURE__*/ _jsx(Typography, {
151
+ variant: "body2",
152
+ color: "text.secondary",
153
+ children: row.note
154
+ }) : null
155
+ ]
156
+ })
157
+ ]
158
+ }, row.slot);
159
+ })
160
+ })
161
+ });
162
+ }
163
+ function Frame({ siteName, heading, lede, children }) {
164
+ return /*#__PURE__*/ _jsxs(Container, {
165
+ maxWidth: "sm",
166
+ sx: {
167
+ py: {
168
+ xs: 3,
169
+ sm: 5
170
+ },
171
+ px: {
172
+ xs: 2,
173
+ sm: 3
174
+ }
175
+ },
176
+ children: [
177
+ /*#__PURE__*/ _jsx(PageHeaderRecord, {
178
+ title: heading
179
+ }),
180
+ /*#__PURE__*/ _jsxs(Stack, {
181
+ spacing: 4,
182
+ children: [
183
+ /*#__PURE__*/ _jsxs(Stack, {
184
+ spacing: 1,
185
+ children: [
186
+ siteName ? /*#__PURE__*/ _jsx(Typography, {
187
+ variant: "overline",
188
+ color: "text.secondary",
189
+ children: siteName
190
+ }) : null,
191
+ /*#__PURE__*/ _jsx(Typography, {
192
+ variant: "h4",
193
+ component: "h1",
194
+ children: heading
195
+ }),
196
+ lede ? /*#__PURE__*/ _jsx(Typography, {
197
+ variant: "body1",
198
+ color: "text.secondary",
199
+ children: lede
200
+ }) : null
201
+ ]
202
+ }),
203
+ children
204
+ ]
205
+ })
206
+ ]
207
+ });
208
+ }
209
+ /**
210
+ * "Bring my site" (AGL-3976), on the import job's own page: the site read
211
+ * and its waves planned with each one's quote, a wave running page by page,
212
+ * a wave in for its review with its drafts to open, and the next wave's
213
+ * button — the only way the next one starts. A wave held for a new proof, the
214
+ * day's limit or a site that could not be read says so and offers the way on.
215
+ */ export function AiSiteImportJob({ job, orgId, orgSlug, host, siteName, user, busy, notice, onResume, onJob }) {
216
+ var _job_siteImport, _job_error;
217
+ const phase = aiSiteImportPhaseOf(job);
218
+ const state = (_job_siteImport = job.siteImport) != null ? _job_siteImport : null;
219
+ const start = aiSiteImportStartAction(job);
220
+ const pagesHref = host && orgSlug ? buildRoute(Route.HOST_SCREENS, {
221
+ orgSlug,
222
+ host
223
+ }) : null;
224
+ const [claim, setClaim] = useState(null);
225
+ const [claimNotice, setClaimNotice] = useState(null);
226
+ const verifyAgain = useCallback(async ()=>{
227
+ if (!orgId || !state) return;
228
+ setClaimNotice(null);
229
+ const answer = await postAiSiteOwnership(user, {
230
+ orgId,
231
+ action: 'claim',
232
+ domain: state.domain
233
+ });
234
+ if (answer.claim) setClaim(answer.claim);
235
+ else setClaimNotice(answer.message);
236
+ }, [
237
+ orgId,
238
+ state,
239
+ user
240
+ ]);
241
+ const cancel = /*#__PURE__*/ _jsx(Box, {
242
+ children: /*#__PURE__*/ _jsx(AiJobCancelButton, {
243
+ job: job,
244
+ user: user,
245
+ orgId: orgId,
246
+ onJob: onJob,
247
+ variant: "text",
248
+ size: "small"
249
+ })
250
+ });
251
+ const startButton = start ? /*#__PURE__*/ _jsxs(Stack, {
252
+ spacing: 1,
253
+ children: [
254
+ /*#__PURE__*/ _jsx(Box, {
255
+ children: /*#__PURE__*/ _jsx(Button, {
256
+ variant: "contained",
257
+ size: "large",
258
+ disabled: busy,
259
+ onClick: onResume,
260
+ children: busy ? 'Starting…' : start.label
261
+ })
262
+ }),
263
+ /*#__PURE__*/ _jsxs(Stack, {
264
+ direction: "row",
265
+ spacing: 0.5,
266
+ sx: {
267
+ alignItems: 'center'
268
+ },
269
+ children: [
270
+ /*#__PURE__*/ _jsx(Typography, {
271
+ variant: "body2",
272
+ color: "text.secondary",
273
+ children: `${start.quote}, from your AI credits. Every page is a draft until you publish it.`
274
+ }),
275
+ /*#__PURE__*/ _jsx(HelpTip, _extends({}, AI_SITE_IMPORT_HELP.waves, {
276
+ ariaLabel: "How waves work"
277
+ }))
278
+ ]
279
+ })
280
+ ]
281
+ }) : null;
282
+ const waves = state ? /*#__PURE__*/ _jsxs(Accordion, {
283
+ variant: "outlined",
284
+ disableGutters: true,
285
+ sx: {
286
+ borderRadius: 2,
287
+ '&::before': {
288
+ display: 'none'
289
+ }
290
+ },
291
+ children: [
292
+ /*#__PURE__*/ _jsx(AccordionSummary, {
293
+ expandIcon: /*#__PURE__*/ _jsx(MdiIcon, {
294
+ path: mdiChevronDown.path
295
+ }),
296
+ children: /*#__PURE__*/ _jsx(Typography, {
297
+ variant: "subtitle1",
298
+ children: `Every wave (${state.waves.length})`
299
+ })
300
+ }),
301
+ /*#__PURE__*/ _jsx(AccordionDetails, {
302
+ children: /*#__PURE__*/ _jsx(Stack, {
303
+ component: "ol",
304
+ spacing: 1,
305
+ sx: {
306
+ m: 0,
307
+ pl: 2.5
308
+ },
309
+ children: state.waves.map((wave)=>/*#__PURE__*/ _jsx(Typography, {
310
+ component: "li",
311
+ variant: "body2",
312
+ children: `${wave.label}: ${wave.slots.length} ${wave.slots.length === 1 ? 'page' : 'pages'}${wave.frame ? ', with your header and footer' : ''}${wave.status === 'done' || wave.status === 'review' ? ' (in)' : wave.status === 'running' ? ' (running)' : ''}`
313
+ }, wave.index))
314
+ })
315
+ })
316
+ ]
317
+ }) : null;
318
+ const leftOut = state ? aiSiteImportLeftOutLines(state) : [];
319
+ const leftOutCard = leftOut.length ? /*#__PURE__*/ _jsxs(Accordion, {
320
+ variant: "outlined",
321
+ disableGutters: true,
322
+ sx: {
323
+ borderRadius: 2,
324
+ '&::before': {
325
+ display: 'none'
326
+ }
327
+ },
328
+ children: [
329
+ /*#__PURE__*/ _jsx(AccordionSummary, {
330
+ expandIcon: /*#__PURE__*/ _jsx(MdiIcon, {
331
+ path: mdiChevronDown.path
332
+ }),
333
+ children: /*#__PURE__*/ _jsx(Typography, {
334
+ variant: "subtitle1",
335
+ children: `Not brought in (${leftOut.reduce((total, line)=>total + line.count, 0)})`
336
+ })
337
+ }),
338
+ /*#__PURE__*/ _jsx(AccordionDetails, {
339
+ children: /*#__PURE__*/ _jsx(Stack, {
340
+ spacing: 1.5,
341
+ children: leftOut.map((line)=>/*#__PURE__*/ _jsxs(Box, {
342
+ children: [
343
+ /*#__PURE__*/ _jsx(Typography, {
344
+ variant: "body2",
345
+ children: `${line.count} · ${line.text}`
346
+ }),
347
+ line.paths.length ? /*#__PURE__*/ _jsxs(Typography, {
348
+ variant: "body2",
349
+ color: "text.secondary",
350
+ sx: {
351
+ overflowWrap: 'anywhere'
352
+ },
353
+ children: [
354
+ line.paths.slice(0, 8).join(', '),
355
+ line.paths.length > 8 || line.count > line.paths.length ? ', …' : ''
356
+ ]
357
+ }) : null,
358
+ line.reason === 'plan-limit' && orgSlug ? /*#__PURE__*/ _jsx(Button, {
359
+ size: "small",
360
+ component: AppLink,
361
+ href: aiCreditsBillingHref(orgSlug),
362
+ sx: {
363
+ mt: 0.5
364
+ },
365
+ children: 'See plans'
366
+ }) : null
367
+ ]
368
+ }, line.reason))
369
+ })
370
+ })
371
+ ]
372
+ }) : null;
373
+ if (phase === 'reading') {
374
+ return /*#__PURE__*/ _jsxs(Frame, {
375
+ siteName: siteName,
376
+ heading: "Reading your site",
377
+ lede: "AglynBot reads robots.txt first, then your sitemap and your pages. Nothing is built yet, and reading uses no AI credits.",
378
+ children: [
379
+ /*#__PURE__*/ _jsxs(Card, {
380
+ variant: "outlined",
381
+ sx: {
382
+ borderRadius: 2
383
+ },
384
+ children: [
385
+ /*#__PURE__*/ _jsx(LinearProgress, {
386
+ "aria-label": "Reading your site"
387
+ }),
388
+ /*#__PURE__*/ _jsx(Typography, {
389
+ variant: "body2",
390
+ color: "text.secondary",
391
+ sx: {
392
+ p: {
393
+ xs: 2,
394
+ sm: 3
395
+ }
396
+ },
397
+ children: 'This takes a minute or two. You can leave this page; we tell you when your site is read.'
398
+ })
399
+ ]
400
+ }),
401
+ cancel
402
+ ]
403
+ });
404
+ }
405
+ if (phase === 'ready' && state) {
406
+ var _ref;
407
+ var _job_review;
408
+ return /*#__PURE__*/ _jsxs(Frame, {
409
+ siteName: siteName,
410
+ heading: "Your site is read",
411
+ lede: (_ref = (_job_review = job.review) == null ? void 0 : _job_review.message) != null ? _ref : undefined,
412
+ children: [
413
+ notice && /*#__PURE__*/ _jsx(Alert, {
414
+ severity: "warning",
415
+ children: notice
416
+ }),
417
+ /*#__PURE__*/ _jsxs(Stack, {
418
+ spacing: 1,
419
+ children: [
420
+ /*#__PURE__*/ _jsx(Typography, {
421
+ variant: "body1",
422
+ children: aiSiteImportFoundText(state)
423
+ }),
424
+ /*#__PURE__*/ _jsx(Typography, {
425
+ variant: "body2",
426
+ color: "text.secondary",
427
+ children: aiSiteImportPlanText(state)
428
+ })
429
+ ]
430
+ }),
431
+ start ? /*#__PURE__*/ _jsxs(Card, {
432
+ variant: "outlined",
433
+ sx: {
434
+ borderRadius: 2
435
+ },
436
+ children: [
437
+ /*#__PURE__*/ _jsx(Typography, {
438
+ variant: "subtitle1",
439
+ sx: {
440
+ px: {
441
+ xs: 2,
442
+ sm: 3
443
+ },
444
+ pt: {
445
+ xs: 2,
446
+ sm: 3
447
+ }
448
+ },
449
+ children: `First: ${start.wave.label}`
450
+ }),
451
+ /*#__PURE__*/ _jsx(WaveRows, {
452
+ job: job,
453
+ wave: start.wave,
454
+ orgSlug: orgSlug
455
+ })
456
+ ]
457
+ }) : null,
458
+ startButton,
459
+ waves,
460
+ leftOutCard,
461
+ cancel
462
+ ]
463
+ });
464
+ }
465
+ if ((phase === 'running' || phase === 'starting') && state) {
466
+ var _ref1, _aiSiteImportRunningWave;
467
+ const wave = (_ref1 = (_aiSiteImportRunningWave = aiSiteImportRunningWave(state)) != null ? _aiSiteImportRunningWave : start == null ? void 0 : start.wave) != null ? _ref1 : null;
468
+ const rows = wave ? aiSiteImportWaveRows(job, wave) : [];
469
+ const done = rows.filter((row)=>row.state !== 'waiting' && row.state !== 'active').length;
470
+ return /*#__PURE__*/ _jsxs(Frame, {
471
+ siteName: siteName,
472
+ heading: wave ? `Bringing in ${wave.label}` : 'Bringing in your site',
473
+ lede: "Each page is rewritten into your new site’s design with its own words, facts and photos. You review the wave when it is in.",
474
+ children: [
475
+ /*#__PURE__*/ _jsxs(Card, {
476
+ variant: "outlined",
477
+ sx: {
478
+ borderRadius: 2
479
+ },
480
+ children: [
481
+ rows.length ? /*#__PURE__*/ _jsx(LinearProgress, {
482
+ variant: "determinate",
483
+ value: Math.round(done / rows.length * 100),
484
+ "aria-label": `${done} of ${rows.length} in`
485
+ }) : /*#__PURE__*/ _jsx(LinearProgress, {
486
+ "aria-label": "Starting the wave"
487
+ }),
488
+ wave ? /*#__PURE__*/ _jsx(WaveRows, {
489
+ job: job,
490
+ wave: wave,
491
+ orgSlug: orgSlug
492
+ }) : null
493
+ ]
494
+ }),
495
+ waves,
496
+ cancel
497
+ ]
498
+ });
499
+ }
500
+ if (phase === 'review' && state) {
501
+ const wave = aiSiteImportReviewWave(state);
502
+ const spent = aiSiteImportWaveSpent(job, wave);
503
+ return /*#__PURE__*/ _jsxs(Frame, {
504
+ siteName: siteName,
505
+ heading: `${wave.label} is in`,
506
+ lede: "Open each page to review it. They are drafts: nothing is published until you publish it.",
507
+ children: [
508
+ notice && /*#__PURE__*/ _jsx(Alert, {
509
+ severity: "warning",
510
+ children: notice
511
+ }),
512
+ /*#__PURE__*/ _jsx(Card, {
513
+ variant: "outlined",
514
+ sx: {
515
+ borderRadius: 2
516
+ },
517
+ children: /*#__PURE__*/ _jsx(WaveRows, {
518
+ job: job,
519
+ wave: wave,
520
+ orgSlug: orgSlug
521
+ })
522
+ }),
523
+ /*#__PURE__*/ _jsx(Typography, {
524
+ variant: "body2",
525
+ color: "text.secondary",
526
+ children: `This wave used ${spent.toLocaleString('en-US')} AI ${spent === 1 ? 'credit' : 'credits'}.`
527
+ }),
528
+ pagesHref ? /*#__PURE__*/ _jsx(Box, {
529
+ children: /*#__PURE__*/ _jsx(Button, {
530
+ variant: "outlined",
531
+ component: AppLink,
532
+ href: pagesHref,
533
+ children: 'Open your draft pages'
534
+ })
535
+ }) : null,
536
+ start ? /*#__PURE__*/ _jsxs(Card, {
537
+ variant: "outlined",
538
+ sx: {
539
+ borderRadius: 2
540
+ },
541
+ children: [
542
+ /*#__PURE__*/ _jsx(Typography, {
543
+ variant: "subtitle1",
544
+ sx: {
545
+ px: {
546
+ xs: 2,
547
+ sm: 3
548
+ },
549
+ pt: {
550
+ xs: 2,
551
+ sm: 3
552
+ }
553
+ },
554
+ children: `Next: ${start.wave.label}`
555
+ }),
556
+ /*#__PURE__*/ _jsx(WaveRows, {
557
+ job: job,
558
+ wave: start.wave,
559
+ orgSlug: orgSlug
560
+ })
561
+ ]
562
+ }) : null,
563
+ startButton,
564
+ waves,
565
+ leftOutCard,
566
+ cancel
567
+ ]
568
+ });
569
+ }
570
+ if (phase === 'held' || phase === 'paused') {
571
+ var _ref2, _ref3;
572
+ var _job_review1, _job_review2;
573
+ const ownership = ((_job_review1 = job.review) == null ? void 0 : _job_review1.reason) === 'ownership';
574
+ return /*#__PURE__*/ _jsxs(Frame, {
575
+ siteName: siteName,
576
+ heading: ownership ? 'Verify your site again' : phase === 'paused' ? 'Your site import is paused' : 'Your site import is waiting',
577
+ children: [
578
+ notice && /*#__PURE__*/ _jsx(Alert, {
579
+ severity: "warning",
580
+ children: notice
581
+ }),
582
+ /*#__PURE__*/ _jsx(Alert, {
583
+ severity: "info",
584
+ children: (_ref2 = (_ref3 = (_job_review2 = job.review) == null ? void 0 : _job_review2.message) != null ? _ref3 : job.error) != null ? _ref2 : 'It stopped for your decision.'
585
+ }),
586
+ ownership && orgId ? claim ? /*#__PURE__*/ _jsx(AiSiteOwnershipProof, {
587
+ orgId: orgId,
588
+ user: user,
589
+ claim: claim,
590
+ onClaim: setClaim
591
+ }) : /*#__PURE__*/ _jsxs(Box, {
592
+ children: [
593
+ /*#__PURE__*/ _jsx(Button, {
594
+ variant: "outlined",
595
+ onClick: ()=>void verifyAgain(),
596
+ children: 'Verify again'
597
+ }),
598
+ claimNotice ? /*#__PURE__*/ _jsx(Alert, {
599
+ severity: "warning",
600
+ sx: {
601
+ mt: 1
602
+ },
603
+ children: claimNotice
604
+ }) : null
605
+ ]
606
+ }) : null,
607
+ /*#__PURE__*/ _jsxs(Stack, {
608
+ direction: {
609
+ xs: 'column',
610
+ sm: 'row'
611
+ },
612
+ spacing: 2,
613
+ sx: {
614
+ alignItems: {
615
+ sm: 'center'
616
+ }
617
+ },
618
+ children: [
619
+ /*#__PURE__*/ _jsx(Button, {
620
+ variant: "contained",
621
+ disabled: busy || ownership && !(claim == null ? void 0 : claim.current),
622
+ onClick: onResume,
623
+ children: busy ? 'Starting…' : phase === 'paused' ? 'Resume' : start ? `${start.label} again` : 'Read the site again'
624
+ }),
625
+ phase === 'paused' && orgSlug ? /*#__PURE__*/ _jsx(Button, {
626
+ variant: "outlined",
627
+ component: AppLink,
628
+ href: aiCreditsBillingHref(orgSlug),
629
+ children: 'Get more AI credits'
630
+ }) : null
631
+ ]
632
+ }),
633
+ waves,
634
+ cancel
635
+ ]
636
+ });
637
+ }
638
+ if (phase === 'done' && state) {
639
+ var _job_items;
640
+ const brought = ((_job_items = job.items) != null ? _job_items : []).filter((row)=>row.op === 'page' && (row.status === 'succeeded' || row.status === 'degraded')).length;
641
+ return /*#__PURE__*/ _jsxs(Frame, {
642
+ siteName: siteName,
643
+ heading: "Your site is in",
644
+ lede: `${brought} ${brought === 1 ? 'page was' : 'pages were'} brought in from ${state.domain}. They are drafts: review them, then publish them when you are ready.`,
645
+ children: [
646
+ pagesHref ? /*#__PURE__*/ _jsx(Box, {
647
+ children: /*#__PURE__*/ _jsx(Button, {
648
+ variant: "contained",
649
+ size: "large",
650
+ component: AppLink,
651
+ href: pagesHref,
652
+ children: 'Open your draft pages'
653
+ })
654
+ }) : null,
655
+ state.waves.map((wave)=>/*#__PURE__*/ _jsxs(Card, {
656
+ variant: "outlined",
657
+ sx: {
658
+ borderRadius: 2
659
+ },
660
+ children: [
661
+ /*#__PURE__*/ _jsx(Typography, {
662
+ variant: "subtitle1",
663
+ sx: {
664
+ px: {
665
+ xs: 2,
666
+ sm: 3
667
+ },
668
+ pt: {
669
+ xs: 2,
670
+ sm: 3
671
+ }
672
+ },
673
+ children: wave.label
674
+ }),
675
+ /*#__PURE__*/ _jsx(WaveRows, {
676
+ job: job,
677
+ wave: wave,
678
+ orgSlug: orgSlug
679
+ })
680
+ ]
681
+ }, wave.index)),
682
+ leftOutCard
683
+ ]
684
+ });
685
+ }
686
+ return /*#__PURE__*/ _jsxs(Frame, {
687
+ siteName: siteName,
688
+ heading: job.status === 'canceled' ? 'Your site import was stopped' : 'Your site import stopped',
689
+ children: [
690
+ /*#__PURE__*/ _jsx(Alert, {
691
+ severity: "info",
692
+ children: (_job_error = job.error) != null ? _job_error : job.status === 'canceled' ? 'Nothing more is brought in. The pages already in stay as drafts.' : 'It could not go on. The pages already in stay as drafts.'
693
+ }),
694
+ pagesHref ? /*#__PURE__*/ _jsx(Box, {
695
+ children: /*#__PURE__*/ _jsx(Button, {
696
+ variant: "outlined",
697
+ component: AppLink,
698
+ href: pagesHref,
699
+ children: 'Open your draft pages'
700
+ })
701
+ }) : null
702
+ ]
703
+ });
704
+ }
705
+ export default AiSiteImportJob;
706
+
707
+ //# sourceMappingURL=ai-site-import-job.component.js.map