@engenty/wizards-runtime 0.9.7 → 0.9.8
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.
- package/apps/runtime/dist/agents/architect.js +4 -2
- package/apps/runtime/dist/agents/company.js +1 -1
- package/apps/runtime/dist/agents/studio-assistant.js +1 -1
- package/apps/runtime/dist/assistant/primer.js +1 -1
- package/apps/runtime/dist/authoring/example.js +2 -2
- package/apps/runtime/dist/authoring/guide.js +11 -11
- package/apps/runtime/dist/credits/estimate.js +5 -5
- package/apps/runtime/dist/db/adopt.js +4 -3
- package/apps/runtime/dist/db/migrations/control/0011_model_classes.sql +11 -0
- package/apps/runtime/dist/db/migrations/control/meta/0011_snapshot.json +600 -0
- package/apps/runtime/dist/db/migrations/control/meta/_journal.json +7 -0
- package/apps/runtime/dist/db/migrations/tenant/0021_model_classes.sql +41 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/0021_snapshot.json +3475 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/_journal.json +7 -0
- package/apps/runtime/dist/docs/dev/plugins/quick-start.md +2 -2
- package/apps/runtime/dist/docs/dev/plugins/server.md +2 -2
- package/apps/runtime/dist/docs/dev/wizard-format/agent-steps.md +9 -5
- package/apps/runtime/dist/docs/dev/wizard-format/film-steps.md +2 -2
- package/apps/runtime/dist/docs/dev/wizard-format/index.md +14 -8
- package/apps/runtime/dist/docs/user-guide/models.md +22 -13
- package/apps/runtime/dist/docs/user-guide/steps.md +6 -6
- package/apps/runtime/dist/documents/parse.js +1 -1
- package/apps/runtime/dist/engine/requirements.js +11 -11
- package/apps/runtime/dist/engine/steps.js +4 -4
- package/apps/runtime/dist/env.js +4 -4
- package/apps/runtime/dist/film/step.js +1 -1
- package/apps/runtime/dist/harness/antigravity.js +3 -3
- package/apps/runtime/dist/harness/apple.js +1 -1
- package/apps/runtime/dist/harness/claude.js +2 -2
- package/apps/runtime/dist/harness/codex.js +3 -3
- package/apps/runtime/dist/harness/cursor.js +1 -1
- package/apps/runtime/dist/mcp/tools.js +6 -3
- package/apps/runtime/dist/models.js +64 -10
- package/apps/runtime/dist/plugins/loader.js +1 -1
- package/apps/runtime/dist/routes/studio.js +16 -5
- package/apps/runtime/dist/services/assistant-chats.js +1 -1
- package/apps/runtime/dist/services/brand.js +1 -1
- package/apps/runtime/dist/services/knowledge-model.js +1 -1
- package/apps/runtime/dist/services/marketplace.js +3 -1
- package/apps/runtime/dist/services/project-files.js +1 -1
- package/apps/runtime/dist/services/translations.js +2 -2
- package/apps/runtime/dist/services/wizards.js +2 -2
- package/apps/runtime/dist/sharing/agent.js +1 -1
- package/apps/runtime/dist/texts.js +12 -0
- package/apps/web/dist/assets/{AboutDialog-B3tljxg5.js → AboutDialog-B_Ixp_Tb.js} +1 -1
- package/apps/web/dist/assets/{ChangelogDialog-DfWTNzyl.js → ChangelogDialog-BpEIbAZ8.js} +1 -1
- package/apps/web/dist/assets/{EditorPage-XDdz2UM4.js → EditorPage-CKHY4hn4.js} +4 -4
- package/apps/web/dist/assets/{FlowPreview-CKNVCFbp.js → FlowPreview-APXdRflR.js} +1 -1
- package/apps/web/dist/assets/{Harness-BCec49Cq.js → Harness-BsGXMlLg.js} +1 -1
- package/apps/web/dist/assets/{Marketplace-BuYeaxK2.js → Marketplace-Dr-Qnb-F.js} +2 -2
- package/apps/web/dist/assets/{NewWizardChannels-DRNji-bk.js → NewWizardChannels-0JrRdUFd.js} +1 -1
- package/apps/web/dist/assets/{NewWizardPage-4TpgYOaI.js → NewWizardPage-9igFL5O8.js} +1 -1
- package/apps/web/dist/assets/{OnboardingPage-Cf52NOIt.js → OnboardingPage-BcK9FUnU.js} +1 -1
- package/apps/web/dist/assets/{PreviewPane-C4yMcZPM.js → PreviewPane-X4LBqA0D.js} +3 -3
- package/apps/web/dist/assets/ProjectPage-CG0i-KhR.js +1 -0
- package/apps/web/dist/assets/{PublicRunner-Bftc1c4m.js → PublicRunner-CZR1ziQ4.js} +1 -1
- package/apps/web/dist/assets/{ReadOnly-DVQm9IYx.js → ReadOnly-BraZbEG_.js} +1 -1
- package/apps/web/dist/assets/SettingsPage-Bw4tdoV7.js +2 -0
- package/apps/web/dist/assets/SetupPage-CvkE2aKx.js +1 -0
- package/apps/web/dist/assets/{SharePage-Cn-bqSyr.js → SharePage-Dk7zC5Zo.js} +1 -1
- package/apps/web/dist/assets/changelog-DDXnAaHm.js +1 -0
- package/apps/web/dist/assets/{coins-DgDTBbeg.js → coins-391m1e4_.js} +1 -1
- package/apps/web/dist/assets/index-BTUtot4r.js +14 -0
- package/apps/web/dist/assets/index-DcUL6teA.css +1 -0
- package/apps/web/dist/assets/{phone-D1Drdiio.js → phone-DvgrtyNO.js} +1 -1
- package/apps/web/dist/assets/{runners-CTd0YAiA.js → runners-4OBelIgF.js} +1 -1
- package/apps/web/dist/assets/{session-DX2BcTfz.js → session-DvnGHbDz.js} +1 -1
- package/apps/web/dist/assets/{settings-menu-ay9jNbQu.js → settings-menu-xK9A-gaP.js} +1 -1
- package/apps/web/dist/assets/theme-D3yDT4QT.js +11 -0
- package/apps/web/dist/assets/ui-BVQk2DtW.js +137 -0
- package/apps/web/dist/assets/{upload-Dj7KPL--.js → upload-BgXbzG6C.js} +1 -1
- package/apps/web/dist/assets/{useMutation-CUSQpD-i.js → useMutation-DkwSQWoD.js} +1 -1
- package/apps/web/dist/assets/{volume-2-CcHZOU2m.js → volume-2-DHGoe3Cg.js} +1 -1
- package/apps/web/dist/assets/{wrench-CfJTFnMJ.js → wrench-Cf_aE3O0.js} +1 -1
- package/apps/web/dist/index.html +8 -8
- package/apps/web/dist/mcp/flow.html +56 -56
- package/node_modules/@engenty/wizards/dist/plugin/index.d.ts +2 -2
- package/node_modules/@engenty/wizards-shared/dist/definition.d.ts +872 -18
- package/node_modules/@engenty/wizards-shared/dist/definition.js +52 -11
- package/node_modules/@engenty/wizards-shared/dist/json-schema.js +3 -3
- package/node_modules/@engenty/wizards-shared/dist/providers.d.ts +37 -0
- package/node_modules/@engenty/wizards-shared/dist/providers.js +64 -12
- package/package.json +1 -1
- package/plugin/.claude-plugin/plugin.json +1 -1
- package/plugin/plugin.json +1 -1
- package/apps/web/dist/assets/ProjectPage-D6Tah3QK.js +0 -1
- package/apps/web/dist/assets/SettingsPage-Cd-osLDu.js +0 -2
- package/apps/web/dist/assets/SetupPage-Dc8U5k5P.js +0 -1
- package/apps/web/dist/assets/changelog-CjSBB-a4.js +0 -1
- package/apps/web/dist/assets/index-DS3zUVw_.css +0 -1
- package/apps/web/dist/assets/index-Da7hPToW.js +0 -14
- package/apps/web/dist/assets/theme-DanjuO1H.js +0 -11
- package/apps/web/dist/assets/ui-CJCF3Mhe.js +0 -137
|
@@ -330,10 +330,11 @@ export function pluginToolOf(id) {
|
|
|
330
330
|
: null;
|
|
331
331
|
}
|
|
332
332
|
/**
|
|
333
|
-
* The
|
|
334
|
-
* outside the wizard (the model-gateway, or the settings of a
|
|
333
|
+
* The model classes a step can ask for (its `model`), cheapest first. A step names a class;
|
|
334
|
+
* which model serves it is bound outside the wizard (the model-gateway, or the settings of a
|
|
335
|
+
* runtime that runs alone).
|
|
335
336
|
*/
|
|
336
|
-
export const TEXT_CLASSES = ["classifier", "
|
|
337
|
+
export const TEXT_CLASSES = ["classifier", "low", "standard", "high"];
|
|
337
338
|
export const MODEL_CLASSES = [...TEXT_CLASSES, "image", "video", "audio", "speech"];
|
|
338
339
|
/** How hard the model should think, where the bound model can be told. */
|
|
339
340
|
export const EFFORTS = ["low", "medium", "high"];
|
|
@@ -567,7 +568,7 @@ export const agentStepSchema = z.object({
|
|
|
567
568
|
surface: z.union([z.boolean(), surfaceComponentsSchema]).optional(),
|
|
568
569
|
})
|
|
569
570
|
.default({ format: "markdown" }),
|
|
570
|
-
/** The
|
|
571
|
+
/** The model class the step needs; default `standard`. The model itself is bound elsewhere. */
|
|
571
572
|
model: z.enum(TEXT_CLASSES).optional(),
|
|
572
573
|
effort: z.enum(EFFORTS).optional(),
|
|
573
574
|
/** Shown to the person while it works. */
|
|
@@ -610,7 +611,7 @@ export const generateStepSchema = z.object({
|
|
|
610
611
|
* `referenceImage` gives each entry its own image when it holds as many.
|
|
611
612
|
*/
|
|
612
613
|
each: z.string().optional(),
|
|
613
|
-
/** For document/dashboard: the
|
|
614
|
+
/** For document/dashboard: the model class that writes it; default `standard`. */
|
|
614
615
|
model: z.enum(TEXT_CLASSES).optional(),
|
|
615
616
|
effort: z.enum(EFFORTS).optional(),
|
|
616
617
|
working: z.string().optional(),
|
|
@@ -685,7 +686,7 @@ export const filmStepSchema = z.object({
|
|
|
685
686
|
from: z.string().optional(),
|
|
686
687
|
/** About how long the film runs, in seconds. */
|
|
687
688
|
seconds: z.number().int().min(3).max(600).optional(),
|
|
688
|
-
/** The
|
|
689
|
+
/** The model class; default `low` — the kit carries the craft. */
|
|
689
690
|
model: z.enum(TEXT_CLASSES).optional(),
|
|
690
691
|
effort: z.enum(EFFORTS).optional(),
|
|
691
692
|
working: z.string().optional(),
|
|
@@ -848,9 +849,46 @@ export const connectionSchema = z.object({
|
|
|
848
849
|
title: z.string().optional(),
|
|
849
850
|
description: z.string().optional(),
|
|
850
851
|
});
|
|
851
|
-
/**
|
|
852
|
-
|
|
853
|
-
|
|
852
|
+
/**
|
|
853
|
+
* The version of the definition this app writes; raised only by a breaking change. It reads the
|
|
854
|
+
* earlier ones too (`upgradeDefinition`). Version 1 named the text classes one step lower: its
|
|
855
|
+
* `standard`, `high` and `highest` are `low`, `standard` and `high` since version 2.
|
|
856
|
+
*/
|
|
857
|
+
export const DEFINITION_VERSION = 2;
|
|
858
|
+
const CLASSES_OF_VERSION_1 = {
|
|
859
|
+
standard: "low",
|
|
860
|
+
high: "standard",
|
|
861
|
+
highest: "high",
|
|
862
|
+
};
|
|
863
|
+
/**
|
|
864
|
+
* A definition of an earlier version, brought to this one; anything else comes back as it is.
|
|
865
|
+
* One without a version is of version 1, unless `unversioned` says which one its writer read:
|
|
866
|
+
* a model that wrote it from today's authoring guide writes today's (`DEFINITION_VERSION`).
|
|
867
|
+
*/
|
|
868
|
+
export function upgradeDefinition(raw, unversioned = 1) {
|
|
869
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) {
|
|
870
|
+
return raw;
|
|
871
|
+
}
|
|
872
|
+
const def = raw;
|
|
873
|
+
const version = def.version ?? unversioned;
|
|
874
|
+
if (version === DEFINITION_VERSION) {
|
|
875
|
+
return def.version === undefined ? { ...def, version } : def;
|
|
876
|
+
}
|
|
877
|
+
if (version !== 1) {
|
|
878
|
+
return raw;
|
|
879
|
+
}
|
|
880
|
+
const steps = Array.isArray(def.steps)
|
|
881
|
+
? def.steps.map((step) => {
|
|
882
|
+
const model = step?.model;
|
|
883
|
+
return typeof model === "string" && CLASSES_OF_VERSION_1[model]
|
|
884
|
+
? { ...step, model: CLASSES_OF_VERSION_1[model] }
|
|
885
|
+
: step;
|
|
886
|
+
})
|
|
887
|
+
: def.steps;
|
|
888
|
+
return { ...def, version: DEFINITION_VERSION, steps };
|
|
889
|
+
}
|
|
890
|
+
/** A definition of this version, as it is written: what the JSON Schema describes. */
|
|
891
|
+
export const currentWizardSchema = z.object({
|
|
854
892
|
version: z.literal(DEFINITION_VERSION).default(DEFINITION_VERSION),
|
|
855
893
|
title: z.string().min(1),
|
|
856
894
|
description: z.string().default(""),
|
|
@@ -882,6 +920,8 @@ export const wizardSchema = z.object({
|
|
|
882
920
|
themes: z.array(z.string().regex(THEME_ID)).max(8).optional(),
|
|
883
921
|
steps: z.array(stepSchema).min(1),
|
|
884
922
|
});
|
|
923
|
+
/** A definition of any version this app reads, brought to this one. */
|
|
924
|
+
export const wizardSchema = z.preprocess((raw) => upgradeDefinition(raw), currentWizardSchema);
|
|
885
925
|
export const INTERACTIVE = new Set(["page", "review", "result"]);
|
|
886
926
|
/** Which formats each producing step can be downloaded in. */
|
|
887
927
|
export function formatsFor(step) {
|
|
@@ -1982,6 +2022,7 @@ function keepsAll(given, read) {
|
|
|
1982
2022
|
}
|
|
1983
2023
|
/** True when this app's schema reads the definition without losing anything of it. */
|
|
1984
2024
|
export function readable(definition) {
|
|
1985
|
-
const
|
|
1986
|
-
|
|
2025
|
+
const upgraded = upgradeDefinition(definition);
|
|
2026
|
+
const parsed = currentWizardSchema.safeParse(upgraded);
|
|
2027
|
+
return parsed.success && keepsAll(upgraded, parsed.data);
|
|
1987
2028
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import {
|
|
2
|
+
import { currentWizardSchema, DEFINITION_VERSION } from "./definition.js";
|
|
3
3
|
import { themeSchema } from "./theme.js";
|
|
4
4
|
import { manifestSchema, PACKAGE_SCHEMA_URL, THEME_SCHEMA_URL, WIZARD_SCHEMA_URL, } from "./wizard-package.js";
|
|
5
5
|
const DIALECT = "https://json-schema.org/draft/2020-12/schema";
|
|
@@ -44,7 +44,7 @@ export function wizardJsonSchema() {
|
|
|
44
44
|
$comment: LICENSE_COMMENT,
|
|
45
45
|
title: "engenty.wizards wizard definition",
|
|
46
46
|
description: `A wizard's definition, version ${DEFINITION_VERSION}. Checked by \`wizards validate\`, which also checks what this schema cannot say: ids, references between steps and templates.`,
|
|
47
|
-
...withSchemaProperty(generate(
|
|
47
|
+
...withSchemaProperty(generate(currentWizardSchema)),
|
|
48
48
|
};
|
|
49
49
|
}
|
|
50
50
|
/** `wizard.json` in a `.wizard` package: the definition with what it needs from its project. */
|
|
@@ -62,7 +62,7 @@ export function packageJsonSchema() {
|
|
|
62
62
|
...properties,
|
|
63
63
|
definition: { $ref: "#/$defs/definition" },
|
|
64
64
|
},
|
|
65
|
-
$defs: { definition: withSchemaProperty(generate(
|
|
65
|
+
$defs: { definition: withSchemaProperty(generate(currentWizardSchema)) },
|
|
66
66
|
};
|
|
67
67
|
}
|
|
68
68
|
/** A theme: how a wizard's pages look, values only (docs/plans/themes.md). Versioned apart from the wizard's. */
|
|
@@ -8,6 +8,43 @@ export declare const MODEL_CAPABILITIES: readonly ["text", "image", "video", "sp
|
|
|
8
8
|
export type ModelCapability = (typeof MODEL_CAPABILITIES)[number];
|
|
9
9
|
export declare const CAPABILITY_CLASSES: Record<ModelCapability, readonly ModelClass[]>;
|
|
10
10
|
export declare function capabilityOf(cls: ModelClass): ModelCapability;
|
|
11
|
+
/**
|
|
12
|
+
* What a model can do, as the AI Gateway's catalog says it (its tags and context window):
|
|
13
|
+
* calls tools, answers in a JSON shape, reads images, reasons before it answers.
|
|
14
|
+
*/
|
|
15
|
+
export interface ModelTraits {
|
|
16
|
+
tools: boolean;
|
|
17
|
+
json: boolean;
|
|
18
|
+
vision: boolean;
|
|
19
|
+
reasoning: boolean;
|
|
20
|
+
/** Tokens it reads at most; null where the catalog does not say. */
|
|
21
|
+
context: number | null;
|
|
22
|
+
}
|
|
23
|
+
/** The text classes by name, the same in every language. */
|
|
24
|
+
export declare const CLASS_NAMES: Record<TextClass, string>;
|
|
25
|
+
/** A minimum a text class asks of its model. */
|
|
26
|
+
export declare const MODEL_NEEDS: readonly ["tools", "json", "vision", "reasoning", "context"];
|
|
27
|
+
export type ModelNeed = (typeof MODEL_NEEDS)[number];
|
|
28
|
+
export interface ClassNeeds {
|
|
29
|
+
needs: Exclude<ModelNeed, "context">[];
|
|
30
|
+
/** Tokens the model must read at least. */
|
|
31
|
+
context: number;
|
|
32
|
+
/** Without these the class cannot work at all: a binding to a model that lacks one is refused. */
|
|
33
|
+
blocks: ModelNeed[];
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* What a model must be able to do to serve a text class. Classifier: decisions and values pulled
|
|
37
|
+
* out of text, in JSON. Low: short copy, API calls, a look at a picture or a PDF. Standard: AI
|
|
38
|
+
* steps with tools and pictures, and Goose. High: the build chat, which writes code and looks at
|
|
39
|
+
* screenshots. Goose and the build chat cannot work without tools.
|
|
40
|
+
*/
|
|
41
|
+
export declare const CLASS_NEEDS: Record<TextClass, ClassNeeds>;
|
|
42
|
+
/** A model's traits from an AI Gateway catalog entry: its tags and context window. */
|
|
43
|
+
export declare function traitsOf(tags: readonly string[], context: number | null | undefined): ModelTraits;
|
|
44
|
+
/** What of a class's minimums a model lacks; empty where it has them all. */
|
|
45
|
+
export declare function missingNeeds(cls: TextClass, traits: ModelTraits): ModelNeed[];
|
|
46
|
+
/** Of what a model lacks, what keeps its class from working at all. */
|
|
47
|
+
export declare function blockingNeeds(cls: TextClass, missing: readonly ModelNeed[]): ModelNeed[];
|
|
11
48
|
/**
|
|
12
49
|
* A binding that sends a class to the credits of the account (or of the organization in the cloud),
|
|
13
50
|
* whatever keys are there; engenty picks the model. `credits:<model>` names the model, as the
|
|
@@ -5,7 +5,7 @@ import { textOf } from "./texts.js";
|
|
|
5
5
|
*/
|
|
6
6
|
export const MODEL_CAPABILITIES = ["text", "image", "video", "speech", "listening"];
|
|
7
7
|
export const CAPABILITY_CLASSES = {
|
|
8
|
-
text: ["classifier", "
|
|
8
|
+
text: ["classifier", "low", "standard", "high"],
|
|
9
9
|
image: ["image"],
|
|
10
10
|
video: ["video"],
|
|
11
11
|
speech: ["speech"],
|
|
@@ -14,6 +14,50 @@ export const CAPABILITY_CLASSES = {
|
|
|
14
14
|
export function capabilityOf(cls) {
|
|
15
15
|
return Object.keys(CAPABILITY_CLASSES).find((c) => CAPABILITY_CLASSES[c].includes(cls));
|
|
16
16
|
}
|
|
17
|
+
/** The text classes by name, the same in every language. */
|
|
18
|
+
export const CLASS_NAMES = {
|
|
19
|
+
classifier: "Classifier",
|
|
20
|
+
low: "Low",
|
|
21
|
+
standard: "Standard",
|
|
22
|
+
high: "High",
|
|
23
|
+
};
|
|
24
|
+
/** A minimum a text class asks of its model. */
|
|
25
|
+
export const MODEL_NEEDS = ["tools", "json", "vision", "reasoning", "context"];
|
|
26
|
+
/**
|
|
27
|
+
* What a model must be able to do to serve a text class. Classifier: decisions and values pulled
|
|
28
|
+
* out of text, in JSON. Low: short copy, API calls, a look at a picture or a PDF. Standard: AI
|
|
29
|
+
* steps with tools and pictures, and Goose. High: the build chat, which writes code and looks at
|
|
30
|
+
* screenshots. Goose and the build chat cannot work without tools.
|
|
31
|
+
*/
|
|
32
|
+
export const CLASS_NEEDS = {
|
|
33
|
+
classifier: { needs: ["json"], context: 32_000, blocks: [] },
|
|
34
|
+
low: { needs: ["tools", "json", "vision"], context: 64_000, blocks: [] },
|
|
35
|
+
standard: { needs: ["tools", "json", "vision"], context: 128_000, blocks: ["tools"] },
|
|
36
|
+
high: { needs: ["tools", "json", "vision", "reasoning"], context: 200_000, blocks: ["tools"] },
|
|
37
|
+
};
|
|
38
|
+
/** A model's traits from an AI Gateway catalog entry: its tags and context window. */
|
|
39
|
+
export function traitsOf(tags, context) {
|
|
40
|
+
return {
|
|
41
|
+
tools: tags.includes("tool-use"),
|
|
42
|
+
json: tags.includes("structured-output"),
|
|
43
|
+
vision: tags.includes("vision"),
|
|
44
|
+
reasoning: tags.includes("reasoning"),
|
|
45
|
+
context: typeof context === "number" && context > 0 ? context : null,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/** What of a class's minimums a model lacks; empty where it has them all. */
|
|
49
|
+
export function missingNeeds(cls, traits) {
|
|
50
|
+
const want = CLASS_NEEDS[cls];
|
|
51
|
+
const missing = want.needs.filter((need) => !traits[need]);
|
|
52
|
+
if (traits.context !== null && traits.context < want.context) {
|
|
53
|
+
missing.push("context");
|
|
54
|
+
}
|
|
55
|
+
return missing;
|
|
56
|
+
}
|
|
57
|
+
/** Of what a model lacks, what keeps its class from working at all. */
|
|
58
|
+
export function blockingNeeds(cls, missing) {
|
|
59
|
+
return missing.filter((need) => CLASS_NEEDS[cls].blocks.includes(need));
|
|
60
|
+
}
|
|
17
61
|
/**
|
|
18
62
|
* A binding that sends a class to the credits of the account (or of the organization in the cloud),
|
|
19
63
|
* whatever keys are there; engenty picks the model. `credits:<model>` names the model, as the
|
|
@@ -107,9 +151,9 @@ export const PROVIDERS = [
|
|
|
107
151
|
keyPlaceholder: "sk-…",
|
|
108
152
|
text: {
|
|
109
153
|
classifier: "openai:gpt-5.4-mini",
|
|
110
|
-
|
|
154
|
+
low: "openai:gpt-5.4-mini",
|
|
155
|
+
standard: "openai:gpt-5.5",
|
|
111
156
|
high: "openai:gpt-5.5",
|
|
112
|
-
highest: "openai:gpt-5.5",
|
|
113
157
|
},
|
|
114
158
|
models: {
|
|
115
159
|
text: [
|
|
@@ -149,9 +193,9 @@ export const PROVIDERS = [
|
|
|
149
193
|
keyPlaceholder: "sk-ant-…",
|
|
150
194
|
text: {
|
|
151
195
|
classifier: "anthropic:claude-haiku-4-5",
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
196
|
+
low: "anthropic:claude-haiku-4-5",
|
|
197
|
+
standard: "anthropic:claude-sonnet-5-5",
|
|
198
|
+
high: "anthropic:claude-opus-5-5",
|
|
155
199
|
},
|
|
156
200
|
models: {
|
|
157
201
|
text: [
|
|
@@ -177,9 +221,9 @@ export const PROVIDERS = [
|
|
|
177
221
|
keyPlaceholder: "AIza…",
|
|
178
222
|
text: {
|
|
179
223
|
classifier: "google:gemini-flash-lite-latest",
|
|
180
|
-
|
|
224
|
+
low: "google:gemini-flash-latest",
|
|
225
|
+
standard: "google:gemini-pro-latest",
|
|
181
226
|
high: "google:gemini-pro-latest",
|
|
182
|
-
highest: "google:gemini-pro-latest",
|
|
183
227
|
},
|
|
184
228
|
models: {
|
|
185
229
|
text: [
|
|
@@ -329,14 +373,22 @@ export const PROVIDERS = [
|
|
|
329
373
|
about: "about.gateway",
|
|
330
374
|
keyUrl: "https://vercel.com/d?to=%2F%5Bteam%5D%2F%7E%2Fai-gateway%2Fapi-keys",
|
|
331
375
|
keyPlaceholder: "vck_…",
|
|
376
|
+
// Economical models that meet each class's minimums (CLASS_NEEDS).
|
|
332
377
|
text: {
|
|
333
|
-
classifier: "
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
378
|
+
classifier: "deepseek/deepseek-v4.1-flash",
|
|
379
|
+
low: "deepseek/deepseek-v4.1-flash",
|
|
380
|
+
standard: "deepseek/deepseek-v4.1-flash",
|
|
381
|
+
high: "moonshotai/kimi-k3",
|
|
337
382
|
},
|
|
338
383
|
models: {
|
|
339
384
|
text: [
|
|
385
|
+
{
|
|
386
|
+
ref: "deepseek/deepseek-v4.1-flash",
|
|
387
|
+
label: "DeepSeek V4.1 Flash",
|
|
388
|
+
note: "fastLowCost",
|
|
389
|
+
},
|
|
390
|
+
{ ref: "moonshotai/kimi-k3", label: "Kimi K3" },
|
|
391
|
+
{ ref: "zai/glm-5.3", label: "GLM 5.3" },
|
|
340
392
|
{
|
|
341
393
|
ref: "anthropic/claude-haiku-4.5",
|
|
342
394
|
label: "Claude Haiku 4.5",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@engenty/wizards-runtime",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.8",
|
|
4
4
|
"description": "Make a wish. Get your wizard. It guides you step by step. Let AI do the work. Runs on your machine, on the AI subscription you already have. The runtime, which `npx wizards` installs.",
|
|
5
5
|
"license": "FSL-1.1-MIT AND CC-BY-4.0",
|
|
6
6
|
"homepage": "https://engenty.ai",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wizards",
|
|
3
3
|
"displayName": "engenty wizards",
|
|
4
|
-
"version": "0.9.
|
|
4
|
+
"version": "0.9.8",
|
|
5
5
|
"description": "Build page-by-page AI wizards that people open on a shared link — designed, tested and published from Claude Code — run your published ones in the chat, and keep them in a pane beside it.",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "engenty"
|
package/plugin/plugin.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json",
|
|
3
3
|
"name": "engenty-wizards",
|
|
4
|
-
"version": "0.9.
|
|
4
|
+
"version": "0.9.8",
|
|
5
5
|
"description": "Build page-by-page AI wizards that people open on a shared link, test and publish them from the chat, and run your published ones here.",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "engenty",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{$t as r,A as i,Ai as a,Ar as o,B as s,Bt as c,C as l,Cr as u,D as d,Dr as f,E as p,H as m,Ht as h,I as g,Ir as _,Jr as v,Jt as y,Kt as b,L as x,Lt as S,M as C,Mr as w,N as T,O as E,Or as D,P as O,Pr as ee,Qr as k,Qt as A,R as j,Rt as M,S as te,T as N,U as P,Ut as F,V as ne,Vr as I,Vt as re,W as L,Wr as ie,Wt as R,Xn as z,Xr as B,Xt as V,Yt as H,Zt as U,_ as W,_r as G,ai as ae,b as oe,br as se,d as ce,f as le,ft as ue,g as de,h as K,hr as fe,ii as pe,j as me,jr as he,k as ge,kr as _e,m as ve,ni as ye,on as q,p as J,pr as be,qt as xe,ri as Se,ti as Ce,tn as we,ur as Y,v as Te,w as Ee,x as De,y as X,yr as Oe,z as ke,zt as Ae}from"./ui-CJCF3Mhe.js";import{S as je,_ as Me,g as Ne,m as Pe,p as Fe,v as Ie}from"./Marketplace-BuYeaxK2.js";import{t as Le}from"./useMutation-CUSQpD-i.js";import{F as Re,I as ze,N as Be,S as Ve,_ as He,a as Ue,b as We,c as Ge,d as Ke,f as qe,g as Je,h as Ye,i as Xe,l as Ze,m as Qe,o as $e,p as et,r as tt,s as nt,t as rt,u as it,v as at,x as ot,y as st}from"./PreviewPane-C4yMcZPM.js";import{b as ct,f as lt}from"./theme-DanjuO1H.js";import{d as ut,f as dt,g as ft,p as pt,x as mt}from"./session-DX2BcTfz.js";import{t as ht}from"./phone-D1Drdiio.js";import{n as gt,r as _t,t as vt}from"./ReadOnly-DVQm9IYx.js";import{t as yt}from"./upload-Dj7KPL--.js";import{Dt as bt,K as xt,at as St,bt as Ct,c as wt,d as Tt,f as Et,h as Dt,m as Ot,mt as kt,p as At,pt as jt,q as Mt,s as Nt,tt as Pt,u as Ft,ut as It,v as Lt,wt as Rt,xt as zt,y as Bt,yt as Vt}from"./index-Da7hPToW.js";import{a as Ht,c as Ut,f as Wt,i as Gt,n as Kt,o as qt,r as Jt,s as Yt,t as Xt,u as Zt}from"./settings-menu-ay9jNbQu.js";var Qt={name:`blend`,size:24,node:[[`circle`,{cx:`15`,cy:`9`,r:`7`,key:`1i12rt`}],[`circle`,{cx:`9`,cy:`15`,r:`7`,key:`19bs8k`}]]};Qt.node;var $t=v(Qt),en={name:`box`,size:24,node:[[`path`,{d:`M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z`,key:`hh9hay`}],[`path`,{d:`m3.3 7 8.7 5 8.7-5`,key:`g66t2b`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}]]};en.node;var tn=v(en),nn={name:`case-upper`,size:24,node:[[`path`,{d:`M15 11h4.5a1 1 0 0 1 0 5h-4a.5.5 0 0 1-.5-.5v-9a.5.5 0 0 1 .5-.5h3a1 1 0 0 1 0 5`,key:`nxs35`}],[`path`,{d:`m2 16 4.039-9.69a.5.5 0 0 1 .923 0L11 16`,key:`d5nyq2`}],[`path`,{d:`M3.304 13h6.392`,key:`1q3zxz`}]]};nn.node;var rn=v(nn),an={name:`folder-plus`,size:24,node:[[`path`,{d:`M12 10v6`,key:`1bos4e`}],[`path`,{d:`M9 13h6`,key:`1uhe8q`}],[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]};an.node;var on=v(an),sn={name:`grid-2x2`,size:24,node:[[`path`,{d:`M12 3v18`,key:`108xh3`}],[`path`,{d:`M3 12h18`,key:`1i2n21`}],[`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,key:`h1oib`}]],aliases:[`grid-2-x-2`]};sn.node;var cn=v(sn),ln={name:`link`,size:24,node:[[`path`,{d:`M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71`,key:`1cjeqo`}],[`path`,{d:`M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71`,key:`19qd67`}]]};ln.node;var un=v(ln),dn={name:`list`,size:24,node:[[`path`,{d:`M3 5h.01`,key:`18ugdj`}],[`path`,{d:`M3 12h.01`,key:`nlz23k`}],[`path`,{d:`M3 19h.01`,key:`noohij`}],[`path`,{d:`M8 5h13`,key:`1pao27`}],[`path`,{d:`M8 12h13`,key:`1za7za`}],[`path`,{d:`M8 19h13`,key:`m83p4d`}]]};dn.node;var fn=v(dn),pn={name:`music`,size:24,node:[[`path`,{d:`M9 18V5l12-2v13`,key:`1jmyc2`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}],[`circle`,{cx:`18`,cy:`16`,r:`3`,key:`1hluhg`}]]};pn.node;var mn=v(pn),hn={name:`tablet`,size:24,node:[[`rect`,{width:`16`,height:`20`,x:`4`,y:`2`,rx:`2`,ry:`2`,key:`76otgf`}],[`line`,{x1:`12`,x2:`12.01`,y1:`18`,y2:`18`,key:`1dp563`}]]};hn.node;var gn=v(hn),Z=e(t(),1),Q=e(n(),1),_n={backgroundImage:`repeating-conic-gradient(#c9c9c9 0% 25%, #dedede 0% 50%)`,backgroundSize:`16px 16px`};function vn({file:e,actions:t}){let[n,r]=(0,Z.useState)(e.description),i=(0,Z.useRef)(e.description),a=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{e.description!==i.current&&(r(t=>t===i.current?e.description:t),i.current=e.description)},[e.description]),(0,Z.useLayoutEffect)(()=>{let e=a.current;e&&(e.style.height=`auto`,e.style.height=`${e.scrollHeight}px`)},[n]);let o=e.status===`pending`&&!n;return t.readOnly?n?(0,Q.jsx)(`p`,{className:`text-[0.8125rem] text-ink-2 leading-snug`,children:n}):null:(0,Q.jsx)(`textarea`,{ref:a,rows:1,value:n,maxLength:600,placeholder:q(o?`project.describing`:`project.description`),onChange:e=>r(e.target.value),onBlur:()=>{n.trim()!==e.description&&(i.current=n.trim(),t.describe(e.id,n.trim()))},className:`-mx-1 block w-[calc(100%+0.5rem)] resize-none overflow-hidden rounded-md bg-transparent px-1 py-0.5 text-[0.8125rem] text-ink-2 leading-snug outline-none transition placeholder:text-ink-4 hover:bg-paper-2 focus:bg-card focus:text-ink focus:ring-1 focus:ring-border`})}function yn(e,t){confirm(q(`project.removeConfirm`,{name:e.name}))&&t.remove(e.id)}function bn({projectId:e,file:t,small:n}){let i=ke(e,t.id);if(t.mime.startsWith(`image/`))return(0,Q.jsx)(`img`,{src:i,alt:``,loading:`lazy`,className:r(`size-full`,t.kind===`logo`?`object-contain p-3`:`object-cover`)});if(t.mime.startsWith(`video/`))return(0,Q.jsx)(`video`,{src:`${i}#t=0.1`,preload:`metadata`,controls:!n,className:`size-full object-cover`});if(t.mime.startsWith(`font/`))return(0,Q.jsx)(xn,{src:i,small:n});let a=n?`size-5`:`size-7`;return(0,Q.jsxs)(`div`,{className:`flex size-full flex-col items-center justify-center gap-1.5 text-ink-3`,children:[t.mime.startsWith(`audio/`)?(0,Q.jsx)(mn,{className:a}):t.mime===`application/pdf`?(0,Q.jsx)(he,{className:a}):t.mime===`application/json`?(0,Q.jsx)(be,{className:a}):t.mime.startsWith(`model/`)?(0,Q.jsx)(tn,{className:a}):(0,Q.jsx)(o,{className:a}),n?null:(0,Q.jsx)(`span`,{className:`text-[0.6875rem] uppercase tracking-wide`,children:t.mime===`application/json`?`Lottie / JSON`:t.mime.split(`/`).pop()})]})}function xn({src:e,small:t}){let[n,i]=(0,Z.useState)(null);return(0,Z.useEffect)(()=>{let t=`asset-${e.split(`/`).slice(-2,-1)[0]}`;new FontFace(t,`url("${e}")`).load().then(e=>{document.fonts.add(e),i(t)}).catch(()=>i(null))},[e]),(0,Q.jsx)(`div`,{className:r(`flex size-full items-center justify-center text-ink`,t?`text-[1.25rem]`:`text-[2.75rem]`),style:n?{fontFamily:`"${n}"`}:void 0,children:`Aa`})}var Sn=`application/x-wizards-logo`;function Cn({projectId:e,kind:t,files:n,actions:r,accept:i,addLabel:a,onUpload:o,onPreview:s,mainId:c,onMakeMain:l,moveTo:u,onRemove:d}){let f=e=>d?d(e):yn(e,r);return(0,Q.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(184px,1fr))] gap-3`,children:[n.map(n=>(0,Q.jsxs)(`div`,{draggable:u&&!r.readOnly?!0:void 0,onDragStart:e=>e.dataTransfer.setData(Sn,n.id),className:`group relative flex flex-col gap-1.5 rounded-lg bg-paper p-2 pb-2.5 ring-1 ring-border-soft`,children:[n.id===c?(0,Q.jsx)(`span`,{className:`absolute -top-3 left-3 z-10 rounded-full ring-2 ring-card`,children:(0,Q.jsx)(Ae,{tone:`ember`,children:q(`project.logoMain`)})}):null,(0,Q.jsxs)(`div`,{className:`relative h-28 overflow-hidden rounded-md bg-paper-2`,style:t===`logo`?_n:void 0,children:[s&&n.mime.startsWith(`image/`)?(0,Q.jsx)(`button`,{type:`button`,"aria-label":`${q(`project.preview`)}: ${n.name}`,onClick:()=>s(n),className:`block size-full cursor-zoom-in`,children:(0,Q.jsx)(bn,{projectId:e,file:n})}):(0,Q.jsx)(bn,{projectId:e,file:n}),(0,Q.jsxs)(`div`,{className:`absolute top-1 right-1 flex gap-1 opacity-0 transition focus-within:opacity-100 group-hover:opacity-100 coarse:opacity-100`,children:[s?(0,Q.jsx)(h,{label:q(`project.preview`),onClick:()=>s(n),className:`size-8 bg-card shadow-soft`,children:(0,Q.jsx)(je,{className:`size-4`})}):null,l&&n.id!==c&&!r.readOnly?(0,Q.jsx)(h,{label:q(`project.logoMakeMain`),onClick:()=>l(n),className:`size-8 bg-card shadow-soft`,children:(0,Q.jsx)(Ne,{className:`size-4`})}):null,u&&!r.readOnly?(0,Q.jsx)(de,{options:u.options,value:u.current(n),onChange:e=>u.onMove(n,e),className:`bg-card shadow-soft`}):null,r.readOnly?null:(0,Q.jsx)(h,{label:q(`project.remove`),onClick:()=>f(n),className:`size-8 bg-card shadow-soft hover:text-rose`,children:(0,Q.jsx)(Y,{className:`size-4`})})]})]}),t===`asset`?(0,Q.jsx)(`div`,{className:`truncate px-0.5 text-[0.75rem] text-ink-3`,title:n.name,children:n.name}):null,(0,Q.jsx)(vn,{file:n,actions:r})]},n.id)),a&&!r.readOnly?(0,Q.jsxs)(ve,{accept:i,multiple:!1,onFiles:e=>o?o(e):r.upload(t,e),className:`min-h-28 flex-col p-3`,children:[r.busy?(0,Q.jsx)(y,{className:`size-5`}):(0,Q.jsx)(Oe,{className:`size-5`}),a]}):null]})}function wn({kind:e,fetchUrl:t,onAdded:n,onClose:i}){let[a,o]=(0,Z.useState)(``),[s,l]=(0,Z.useState)(!1),[u,d]=(0,Z.useState)(null),[f,p]=(0,Z.useState)(null),[m,h]=(0,Z.useState)([]),g=async()=>{l(!0),d(null);try{let r=await t(a.trim());r.file?(n([r.file]),i()):r.candidates?.length?(p(r.candidates),h([r.candidates[0].url])):d(q(e===`logo`?`project.logoNoneFound`:`project.assetNoneFound`))}catch(e){d(e.message)}l(!1)},_=async()=>{l(!0),d(null);let e=[];try{for(let n of m){let r=await t(n);r.file&&e.push(r.file)}}catch(e){d(e.message)}l(!1),e.length&&n(e),e.length===m.length&&i()};return(0,Q.jsx)(c,{open:!0,onClose:i,wide:f?!0:void 0,title:q(f?e===`logo`?`project.logoFound`:`project.assetFound`:e===`logo`?`project.logoFromUrl`:`project.assetFromUrl`),children:f?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-ink-3`,children:q(e===`logo`?`project.logoFoundHint`:`project.assetFoundHint`)}),(0,Q.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(150px,1fr))] gap-3`,children:f.map(t=>{let n=m.includes(t.url);return(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":n,title:t.hint,onClick:()=>h(e=>n?e.filter(e=>e!==t.url):[...e,t.url]),className:r(`relative h-28 overflow-hidden rounded-lg ring-1 transition`,n?`ring-2 ring-ember`:`ring-border-soft hover:ring-ink-4`),style:_n,children:[(0,Q.jsx)(`img`,{src:t.url,alt:``,className:r(`size-full`,e===`logo`?`object-contain p-3`:`object-cover`)}),n?(0,Q.jsx)(`span`,{className:`absolute top-1.5 right-1.5 grid size-5 place-items-center rounded-full bg-ember text-white`,children:(0,Q.jsx)(I,{className:`size-3.5`})}):null]},t.url)})}),u?(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:u}):null,(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Q.jsx)(S,{variant:`ghost`,onClick:()=>p(null),children:q(`run.back`)}),(0,Q.jsx)(S,{busy:s,disabled:!m.length,onClick:()=>void _(),children:m.length>1?q(`project.addMany`,{n:m.length}):q(`project.add`)})]})]}):(0,Q.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),g()},className:`flex flex-col gap-5`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(R,{children:q(`project.logoUrl`)}),(0,Q.jsx)(F,{autoFocus:!0,value:a,inputMode:`url`,placeholder:`https://example.com`,onChange:e=>o(e.target.value)}),(0,Q.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:q(e===`logo`?`project.logoUrlHint`:`project.assetUrlHint`)})]}),u?(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:u}):null,(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Q.jsx)(S,{variant:`ghost`,onClick:i,children:q(`common.cancel`)}),(0,Q.jsx)(S,{type:`submit`,busy:s,disabled:!a.trim(),children:q(`run.next`)})]})]})})}function Tn(e,t,n){return ae({queryKey:[`project-file-text`,t.id,t.chars,n],queryFn:()=>L.get(`/api/studio/projects/${e}/files/${t.id}/text?limit=${n}`),enabled:t.status===`ready`,staleTime:6e4})}function En(e){return((e.name.includes(`.`)?e.name.split(`.`).pop():``)||e.mime.split(`/`).pop()||``).toUpperCase().slice(0,5)}var Dn=e=>[En(e),e.pages?q(`project.pages`,{n:e.pages}):null,z(e.size)].filter(Boolean).join(` · `),On=2e5;function kn({projectId:e,fileId:t,readOnly:n,onGone:i}){let o=a(),s=P(e),c=Qe(e),l=ne(e,n),u=s.data?.files.find(e=>e.id===t),d=u?u.mime===`application/pdf`||u.mime.startsWith(`image/`):!1,[f,p]=(0,Z.useState)(null);if(!u)return s.isLoading?(0,Q.jsx)(y,{className:`mx-auto text-ink-3`}):null;let m=f??(d?`original`:`text`),g=c.data?.items.find(e=>e.key===`f:${u.id}`),_=ke(e,u.id),v=(e,t)=>(0,Q.jsx)(`button`,{type:`button`,"aria-pressed":m===e,onClick:()=>p(e),className:r(`rounded-full px-3 py-1 text-[0.8125rem] transition`,m===e?`bg-paper-2 font-medium text-ink`:`text-ink-3 hover:text-ink`),children:t});return(0,Q.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 px-1`,children:[(0,Q.jsx)(`h2`,{className:`min-w-0 flex-1 truncate font-display font-semibold text-lg`,children:u.name}),(0,Q.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3 max-sm:hidden`,children:Dn(u)}),(0,Q.jsx)(`a`,{href:_,target:`_blank`,rel:`noreferrer`,"aria-label":q(`project.openOriginal`),title:q(`project.openOriginal`),className:`inline-flex size-9 items-center justify-center rounded-full text-ink-3 transition hover:bg-accent hover:text-ink`,children:(0,Q.jsx)(w,{className:`size-4`})}),n?null:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(h,{label:q(`project.reindex`),onClick:async()=>{await l.reindex(u.id),await o.invalidateQueries({queryKey:[`knowledge`,e]})},children:(0,Q.jsx)(G,{className:`size-4`})}),(0,Q.jsx)(h,{label:q(`know.deleteFile`),className:`hover:text-rose`,onClick:async()=>{confirm(q(`data.confirmDelete`,{title:u.name}))&&(await l.remove(u.id),await o.invalidateQueries({queryKey:[`knowledge`,e]}),i())},children:(0,Q.jsx)(Y,{className:`size-4`})})]})]}),(0,Q.jsx)(qe,{projectId:e,itemKey:`f:${u.id}`,has:g?.categories??[],originLabel:g?.originLabel??null,kept:!1,review:null,file:null,readOnly:n,onReviewed:()=>void 0}),(0,Q.jsx)(`div`,{className:`px-1`,children:(0,Q.jsx)(vn,{file:u,actions:l})}),u.status===`failed`?(0,Q.jsx)(`p`,{className:`px-1 text-[0.875rem] text-rose`,children:u.error}):null,(0,Q.jsxs)(M,{className:`flex flex-col`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1 border-border-soft border-b px-2 py-1.5`,children:[d?v(`original`,q(`project.original`)):null,v(`text`,q(`project.readText`))]}),m===`original`?u.mime===`application/pdf`?(0,Q.jsx)(`iframe`,{src:_,title:u.name,className:`h-[70dvh] w-full rounded-b-xl bg-paper-2`}):(0,Q.jsx)(`img`,{src:_,alt:``,className:`mx-auto max-h-[70dvh] object-contain p-4`}):(0,Q.jsx)(An,{projectId:e,file:u})]})]})}function An({projectId:e,file:t}){let n=Tn(e,t,On);return n.isLoading||t.status===`pending`?(0,Q.jsx)(`div`,{className:`flex h-40 items-center justify-center text-ink-3`,children:(0,Q.jsx)(y,{})}):n.data?.text?(0,Q.jsxs)(`div`,{className:`overflow-x-auto p-4 sm:p-5`,children:[(0,Q.jsx)(ue,{text:n.data.text,className:`text-[0.875rem]`}),n.data.chars>n.data.text.length?(0,Q.jsx)(`p`,{className:`mt-3 text-[0.8125rem] text-ink-3`,children:q(`project.textCut`,{shown:n.data.text.length.toLocaleString(we),total:n.data.chars.toLocaleString(we)})}):null]}):(0,Q.jsx)(`p`,{className:`py-8 text-center text-[0.875rem] text-ink-3`,children:q(`project.noText`)})}var jn=`image/*,video/*,audio/*,application/pdf,.pdf,.woff2,.woff,.ttf,.otf,.json,.glb,.gltf`,Mn=e=>[(e.name.includes(`.`)?e.name.split(`.`).pop():e.mime.split(`/`).pop())?.toUpperCase().slice(0,5),z(e.size)].filter(Boolean).join(` · `);function Nn({projectId:e,file:t,actions:n,onClose:r}){let i=ke(e,t.id);return(0,Q.jsxs)(c,{open:!0,onClose:r,wide:`page`,title:t.name,children:[(0,Q.jsxs)(`div`,{className:`-mt-2 mb-4 flex items-center justify-between gap-3`,children:[(0,Q.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3`,children:Mn(t)}),(0,Q.jsx)(`a`,{href:i,target:`_blank`,rel:`noreferrer`,"aria-label":q(`project.openOriginal`),title:q(`project.openOriginal`),className:`inline-flex size-9 items-center justify-center rounded-full text-ink-3 transition hover:bg-accent hover:text-ink`,children:(0,Q.jsx)(w,{className:`size-4`})})]}),t.mime.startsWith(`image/`)?(0,Q.jsx)(`div`,{className:`overflow-hidden rounded-lg`,style:_n,children:(0,Q.jsx)(`img`,{src:i,alt:``,className:`mx-auto max-h-[68dvh] object-contain`})}):t.mime.startsWith(`video/`)?(0,Q.jsx)(`video`,{src:i,controls:!0,className:`max-h-[68dvh] w-full rounded-lg bg-black`}):(0,Q.jsx)(`audio`,{src:i,controls:!0,className:`w-full`}),(0,Q.jsx)(`div`,{className:`mt-4`,children:(0,Q.jsx)(vn,{file:t,actions:n})})]})}function Pn({projectId:e,file:t,actions:n,moveTo:r,onPreview:i,onRemove:a}){return(0,Q.jsxs)(`li`,{className:`group/row flex items-start gap-3 rounded-lg bg-paper p-2 ring-1 ring-border-soft`,children:[(0,Q.jsx)(`button`,{type:`button`,"aria-label":`${q(`project.preview`)}: ${t.name}`,onClick:i,className:`size-14 shrink-0 cursor-zoom-in overflow-hidden rounded-md bg-paper-2`,children:(0,Q.jsx)(bn,{projectId:e,file:t,small:!0})}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1 py-0.5`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-3`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:i,title:t.name,className:`min-w-0 truncate font-medium text-[0.875rem] hover:underline`,children:t.name}),(0,Q.jsx)(`span`,{className:`text-[0.75rem] text-ink-3`,children:Mn(t)})]}),(0,Q.jsx)(vn,{file:t,actions:n})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-start opacity-0 transition focus-within:opacity-100 group-hover/row:opacity-100 coarse:opacity-100`,children:[(0,Q.jsx)(h,{label:q(`project.preview`),onClick:i,children:(0,Q.jsx)(je,{className:`size-4`})}),r&&!n.readOnly?(0,Q.jsx)(de,{options:r.options,value:r.current(t),onChange:e=>r.onMove(t,e),className:`size-9`}):null,n.readOnly?null:(0,Q.jsx)(h,{label:q(`project.remove`),onClick:a,className:`hover:text-rose`,children:(0,Q.jsx)(Y,{className:`size-4`})})]})]})}function Fn({section:e,onSave:t,onRemove:n,onClose:r}){let[i,a]=(0,Z.useState)(e?.title??``);return(0,Q.jsx)(c,{open:!0,onClose:r,title:q(e?`project.assetSectionRename`:`project.assetSectionAdd`),children:(0,Q.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),i.trim()&&(t(i.trim()),r())},className:`flex flex-col gap-5`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(R,{children:q(`project.assetSectionName`)}),(0,Q.jsx)(F,{autoFocus:!0,value:i,maxLength:80,placeholder:q(`project.assetSectionTitle`),onChange:e=>a(e.target.value)})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n?(0,Q.jsx)(S,{variant:`danger`,onClick:n,children:q(`project.sectionRemove`)}):null,(0,Q.jsx)(`span`,{className:`flex-1`}),(0,Q.jsx)(S,{variant:`ghost`,onClick:r,children:q(`common.cancel`)}),(0,Q.jsx)(S,{type:`submit`,disabled:!i.trim(),children:q(e?`settings.save`:`project.add`)})]})]})})}function In({projectId:e,data:t,readOnly:n,sections:r,save:a}){let o=ne(e,n),[c,l]=m(`assets`,`cards`),[u,d]=(0,Z.useState)(``),[f,p]=(0,Z.useState)(null),[g,_]=(0,Z.useState)(r),[v,b]=(0,Z.useState)(``),[x,S]=(0,Z.useState)(null),[C,w]=(0,Z.useState)(!1),T=(0,Z.useRef)(null),E=s({assetSections:g},a),D=t.files.filter(e=>e.kind===`asset`),O=new Map(D.map(e=>[e.id,e])),ee=new Set(g.flatMap(e=>e.assets)),k=g.find(e=>e.id===v)??null,A=k?k.assets.map(e=>O.get(e)).filter(e=>!!e):D.filter(e=>!ee.has(e.id)),j=D.find(e=>e.id===f),M=u.trim().toLowerCase(),te=M?A.filter(e=>`${e.name} ${e.description}`.toLowerCase().includes(M)):A,N=(e,t)=>_(n=>n.map(n=>{let r=n.assets.filter(t=>t!==e);return{...n,assets:n.id===t?[...r,e]:r}})),P=async e=>{let t=k?.id??null;for(let n of await o.upload(`asset`,e))N(n.id,t)},F=e=>{confirm(q(`project.removeConfirm`,{name:e.name}))&&(o.remove(e.id),N(e.id,null))},I=g.length?{options:[{value:``,label:q(`project.assetsGeneral`)},...g.map(e=>({value:e.id,label:e.title||q(`project.sectionUntitled`)}))],current:e=>g.find(t=>t.assets.includes(e.id))?.id??``,onMove:(e,t)=>N(e.id,t||null)}:void 0,re=[{label:q(`project.assetUpload`),icon:(0,Q.jsx)(yt,{className:`size-4 shrink-0`}),onPick:()=>T.current?.click()},{label:q(`project.assetFromUrl`),icon:(0,Q.jsx)(un,{className:`size-4 shrink-0`}),onPick:()=>w(!0)},...g.length<i.logoSections?[{label:q(`project.assetSectionAdd`),icon:(0,Q.jsx)(on,{className:`size-4 shrink-0`}),onPick:()=>S(`new`)}]:[]],L=g.length||D.length?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsxs)(`div`,{className:`-mx-1 flex min-w-0 flex-1 items-center gap-1 overflow-x-auto px-1 pb-0.5`,children:[g.length?(0,Q.jsx)(U,{value:v,onChange:e=>{b(e),d(``)},label:q(`project.assets`),options:[{id:``,label:q(`project.assetsGeneral`)},...g.map(e=>({id:e.id,label:e.title||q(`project.sectionUntitled`)}))]}):null,k&&!n?(0,Q.jsx)(h,{label:q(`project.assetSectionRename`),onClick:()=>S(`current`),children:(0,Q.jsx)(se,{className:`size-4`})}):null]}),A.length?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`w-56 max-w-[45%] shrink`,children:(0,Q.jsx)(Te,{value:u,onChange:d,placeholder:q(`project.assetSearch`)})}),(0,Q.jsx)(h,{label:q(c===`list`?`project.viewCards`:`project.viewList`),onClick:l,children:c===`list`?(0,Q.jsx)(Ct,{className:`size-4`}):(0,Q.jsx)(fn,{className:`size-4`})})]}):null]}):null;return(0,Q.jsxs)(X,{title:q(`project.assets`),hint:q(`project.assetsHint`),save:E,tabs:L,action:n?null:(0,Q.jsx)(ce,{entries:re}),children:[(0,Q.jsx)(`input`,{ref:T,type:`file`,multiple:!0,accept:jn,className:`sr-only`,tabIndex:-1,"aria-hidden":!0,onChange:e=>{let t=Array.from(e.target.files??[]);e.target.value=``,t.length&&P(t)}}),te.length?c===`cards`?(0,Q.jsx)(Cn,{projectId:e,kind:`asset`,files:te,actions:o,moveTo:I,onRemove:F,onPreview:e=>p(e.id)}):(0,Q.jsx)(`ul`,{className:`flex flex-col gap-2`,children:te.map(t=>(0,Q.jsx)(Pn,{projectId:e,file:t,actions:o,moveTo:I,onPreview:()=>p(t.id),onRemove:()=>F(t)},t.id))}):A.length?null:n?(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:q(`project.staysLocal`)}):(0,Q.jsxs)(ve,{accept:jn,onFiles:e=>void P(e),className:`h-16 w-full`,children:[o.busy?(0,Q.jsx)(y,{className:`size-4`}):(0,Q.jsx)(yt,{className:`size-4`}),q(`project.drop`),` `,(0,Q.jsx)(`span`,{className:`underline`,children:q(`project.assetAdd`)})]}),o.error?(0,Q.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:o.error}):null,j?(0,Q.jsx)(Nn,{projectId:e,file:j,actions:o,onClose:()=>p(null)}):null,x?(0,Q.jsx)(Fn,{section:x===`current`?k:null,onClose:()=>S(null),onSave:e=>{if(x===`current`&&k)_(t=>t.map(t=>t.id===k.id?{...t,title:e}:t));else{let t=De();_(n=>[...n,{id:t,title:e,assets:[]}]),b(t)}},onRemove:x===`current`&&k?()=>{(!k.assets.length||confirm(q(`project.assetSectionRemoveConfirm`,{name:k.title})))&&(_(e=>e.filter(e=>e.id!==k.id)),b(``),S(null))}:void 0}):null,C?(0,Q.jsx)(wn,{kind:`asset`,onClose:()=>w(!1),fetchUrl:e=>o.fromUrl(`asset`,e),onAdded:e=>{for(let t of e)N(t.id,k?.id??null)}}):null]})}var Ln=/^#[0-9a-fA-F]{6}$/;async function Rn(e,t){let[n,r]=[1920,1080],i=document.createElement(`canvas`);i.width=n,i.height=r;let a=i.getContext(`2d`);if(!a)return;let o=e.angle*Math.PI/180,s;if(e.type===`radial`)s=a.createRadialGradient(n/2,r/2,0,n/2,r/2,Math.hypot(n,r)/2);else if(e.type===`conic`)s=a.createConicGradient(o-Math.PI/2,n/2,r/2);else{let e=Math.abs(n*Math.sin(o))+Math.abs(r*Math.cos(o)),[t,i]=[Math.sin(o)*e/2,-Math.cos(o)*e/2];s=a.createLinearGradient(n/2-t,r/2-i,n/2+t,r/2+i)}for(let t of[...e.stops].sort((e,t)=>e.at-t.at))s.addColorStop(Math.min(1,Math.max(0,t.at/100)),t.color);a.fillStyle=s,a.fillRect(0,0,n,r);let c=await new Promise(e=>i.toBlob(e,`image/png`));if(c){let e=document.createElement(`a`);e.href=URL.createObjectURL(c),e.download=`${t||`gradient`}.png`,e.click(),setTimeout(()=>URL.revokeObjectURL(e.href),5e3)}}var zn={linear:`project.gradientLinear`,radial:`project.gradientRadial`,conic:`project.gradientConic`};function Bn({projectId:e,gradient:t,isNew:n,brand:i,onSave:a,onClose:o}){let[s,l]=(0,Z.useState)(t),[u,f]=(0,Z.useState)(O(t)),[p,m]=(0,Z.useState)(!1),[g,_]=(0,Z.useState)(``),[v,y]=(0,Z.useState)(!1),[b,x]=(0,Z.useState)(null),[C,w]=(0,Z.useState)(!n),T=e=>{l(e),f(O(e)),m(!1)},E=(e,t)=>T({...s,stops:s.stops.map((n,r)=>r===e?{...n,...t}:n)}),D=e=>{let t=[...s.stops].sort((e,t)=>e.at-t.at),n=50,r=-1;for(let e=0;e<t.length-1;e++)t[e+1].at-t[e].at>r&&(r=t[e+1].at-t[e].at,n=Math.round((t[e].at+t[e+1].at)/2));T({...s,stops:[...s.stops,{color:e??t[0]?.color??`#888888`,at:n}]})},ee=async()=>{y(!0),x(null);try{let{gradient:t}=await L.post(`/api/studio/projects/${e}/gradients/describe`,{text:g.trim(),...C?{gradient:{name:s.name,type:s.type,angle:s.angle,stops:s.stops}}:{}});T({...s,...t,name:s.name.trim()?s.name:t.name}),_(``),w(!0)}catch(e){x(e.message)}y(!1)};return(0,Q.jsx)(c,{open:!0,onClose:o,wide:!0,title:q(n?`project.gradientNew`:`project.gradientEdit`),children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),g.trim()&&!v&&ee()},children:[(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(F,{"data-autofocus":n||void 0,value:g,maxLength:1e3,"aria-label":q(`project.gradientDescribe`),placeholder:q(C?`project.gradientDescribeChange`:`project.gradientDescribeNew`),onChange:e=>_(e.target.value),className:`min-w-0 flex-1`}),(0,Q.jsxs)(S,{type:`submit`,variant:`secondary`,busy:v,disabled:!g.trim(),children:[(0,Q.jsx)(be,{className:`size-4`}),q(C?`project.gradientDescribeApply`:`project.gradientDescribeMake`)]})]}),(0,Q.jsx)(`p`,{className:r(`mt-1.5 text-[0.8125rem]`,b?`text-rose`:`text-ink-3`),children:b??q(`project.gradientDescribeHint`)})]}),(0,Q.jsx)(`div`,{className:`h-40 rounded-lg ring-1 ring-border-soft`,style:{background:O(s)}}),(0,Q.jsxs)(`div`,{className:`grid gap-x-6 gap-y-4 sm:grid-cols-2`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(R,{children:q(`project.gradientName`)}),(0,Q.jsx)(F,{value:s.name,maxLength:80,placeholder:q(`project.gradientNamePlaceholder`),onChange:e=>l({...s,name:e.target.value})})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(R,{children:q(`project.fillUseLabel`)}),(0,Q.jsx)(F,{value:s.description??``,maxLength:400,placeholder:q(`project.gradientUse`),onChange:e=>l({...s,description:e.target.value})})]})]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-end gap-x-6 gap-y-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(R,{children:q(`project.gradientType`)}),(0,Q.jsx)(`div`,{className:`flex gap-1 rounded-full bg-paper-2 p-0.5 ring-1 ring-border-soft`,children:d.map(e=>(0,Q.jsx)(`button`,{type:`button`,"aria-pressed":s.type===e,onClick:()=>T({...s,type:e}),className:r(`h-9 rounded-full px-4 font-medium text-[0.875rem] transition`,s.type===e?`bg-card text-ink shadow-sm`:`text-ink-3 hover:text-ink-2`),children:q(zn[e])},e))})]}),s.type===`radial`?null:(0,Q.jsxs)(`div`,{className:`min-w-56`,children:[(0,Q.jsx)(R,{children:q(`project.gradientAngle`)}),(0,Q.jsxs)(`div`,{className:`flex h-11 items-center gap-3`,children:[(0,Q.jsx)(`input`,{type:`range`,min:0,max:360,value:s.angle,"aria-label":q(`project.gradientAngle`),onChange:e=>T({...s,angle:Number(e.target.value)}),className:`flex-1 accent-ink`}),(0,Q.jsxs)(`span`,{className:`w-12 text-right text-[0.875rem] text-ink-2 tabular-nums`,children:[Math.round(s.angle),`°`]})]})]})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(R,{children:q(`project.gradientStops`)}),(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:s.stops.map((e,t)=>(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsx)(H,{value:Ln.test(e.color)?e.color:`#888888`,onChange:e=>E(t,{color:e.target.value})}),(0,Q.jsx)(F,{value:e.color,spellCheck:!1,onChange:e=>{let n=e.target.value.trim();Ln.test(n)&&E(t,{color:n.toLowerCase()})},className:`w-28 font-mono text-[0.8125rem]`}),(0,Q.jsx)(`input`,{type:`range`,min:0,max:100,value:e.at,"aria-label":q(`project.gradientAt`),onChange:e=>E(t,{at:Number(e.target.value)}),className:`flex-1 accent-ink`}),(0,Q.jsxs)(`span`,{className:`w-10 text-right text-[0.875rem] text-ink-2 tabular-nums`,children:[Math.round(e.at),`%`]}),(0,Q.jsx)(h,{label:q(`project.remove`),disabled:s.stops.length<=2,onClick:()=>T({...s,stops:s.stops.filter((e,n)=>n!==t)}),className:`hover:text-rose`,children:(0,Q.jsx)(Y,{className:`size-4`})})]},t))}),(0,Q.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[s.stops.length<12?(0,Q.jsxs)(S,{variant:`secondary`,size:`sm`,onClick:()=>D(),children:[(0,Q.jsx)(Oe,{className:`size-4`}),` `,q(`project.gradientStopAdd`)]}):null,i.length&&s.stops.length<12?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`ml-2 text-[0.8125rem] text-ink-3`,children:q(`project.gradientFromBrand`)}),i.slice(0,10).map(e=>(0,Q.jsx)(`button`,{type:`button`,title:e.name||e.value,"aria-label":e.name||e.value,onClick:()=>D(e.value),className:`size-6 rounded-full ring-1 ring-border transition hover:scale-110`,style:{background:e.value}},e.value))]}):null]})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(R,{children:`CSS`}),(0,Q.jsx)(F,{value:u,spellCheck:!1,onChange:e=>{f(e.target.value);let t=j(e.target.value);m(!t),t&&l({...s,...t})},className:`font-mono text-[0.8125rem]`}),(0,Q.jsx)(`p`,{className:r(`mt-1.5 text-[0.8125rem]`,p?`text-rose`:`text-ink-3`),children:q(p?`project.gradientCssError`:`project.gradientCssHint`)})]}),(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Q.jsx)(S,{variant:`ghost`,onClick:o,children:q(`common.cancel`)}),(0,Q.jsx)(S,{onClick:()=>{a(s),o()},children:q(`settings.save`)})]})]})})}var Vn=`absolute top-1.5 right-1.5 flex gap-1 opacity-0 transition focus-within:opacity-100 group-hover/card:opacity-100 coarse:opacity-100`,Hn=`size-8 bg-card shadow-soft hover:bg-card`;function Un({name:e,namePlaceholder:t,description:n,usePlaceholder:r,readOnly:i,onChange:a}){return i?(0,Q.jsxs)(`div`,{className:`min-w-0 px-0.5`,children:[(0,Q.jsx)(`p`,{className:`truncate text-[0.875rem]`,children:e||t}),n?(0,Q.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3 leading-snug`,children:n}):null]}):(0,Q.jsxs)(`div`,{className:`min-w-0 px-0.5`,children:[(0,Q.jsx)(K,{value:e,label:q(`project.gradientName`),placeholder:t,maxLength:80,onChange:e=>a({name:e}),className:`font-medium text-[0.875rem]`}),(0,Q.jsx)(K,{value:n??``,label:q(`project.fillUseLabel`),placeholder:r,maxLength:400,onChange:e=>a({description:e}),className:`text-[0.8125rem] text-ink-3`})]})}function Wn({gradient:e,readOnly:t,onEdit:n,onChange:i,onRemove:a}){let o=O(e),[s,c]=(0,Z.useState)(!1);return(0,Q.jsxs)(`div`,{className:`group/card flex flex-col gap-2 rounded-lg bg-paper p-2 ring-1 ring-border-soft`,children:[(0,Q.jsxs)(`div`,{className:`relative`,children:[(0,Q.jsx)(`button`,{type:`button`,disabled:t,"aria-label":q(`project.gradientEdit`),onClick:n,className:`block h-28 w-full rounded-md ring-1 ring-border-soft transition enabled:hover:brightness-105`,style:{background:o}}),(0,Q.jsxs)(`div`,{className:Vn,children:[(0,Q.jsx)(h,{label:q(s?`project.gradientCopied`:`project.gradientCopy`),onClick:()=>{navigator.clipboard.writeText(`background: ${o};`),c(!0),setTimeout(()=>c(!1),1500)},className:Hn,children:(0,Q.jsx)(_,{className:`size-4`})}),(0,Q.jsx)(h,{label:q(`project.download`),onClick:()=>void Rn(e,e.name),className:Hn,children:(0,Q.jsx)(ee,{className:`size-4`})}),t?null:(0,Q.jsx)(h,{label:q(`project.remove`),onClick:a,className:r(Hn,`hover:text-rose`),children:(0,Q.jsx)(Y,{className:`size-4`})})]})]}),(0,Q.jsx)(Un,{name:e.name,namePlaceholder:q(`project.gradientName`),description:e.description,usePlaceholder:q(`project.gradientUse`),readOnly:t,onChange:i})]})}function Gn(e,t){return{backgroundImage:`url("${e}")`,backgroundSize:t?`64px`:`cover`,backgroundRepeat:t?`repeat`:`no-repeat`,backgroundPosition:`center`}}function Kn({projectId:e,pattern:t,fileName:n,readOnly:i,onEdit:a,onChange:o,onRemove:s}){let c=ke(e,t.file);return(0,Q.jsxs)(`div`,{className:`group/card flex flex-col gap-2 rounded-lg bg-paper p-2 ring-1 ring-border-soft`,children:[(0,Q.jsxs)(`div`,{className:`relative`,children:[(0,Q.jsx)(`button`,{type:`button`,disabled:i,"aria-label":q(`project.patternEdit`),onClick:a,className:`block h-28 w-full rounded-md ring-1 ring-border-soft transition enabled:hover:brightness-105`,style:Gn(c,t.tile)}),(0,Q.jsxs)(`div`,{className:Vn,children:[(0,Q.jsx)(`a`,{href:c,download:n,"aria-label":q(`project.download`),title:q(`project.download`),className:r(`inline-flex items-center justify-center rounded-full text-ink-3 transition hover:text-ink`,Hn),children:(0,Q.jsx)(ee,{className:`size-4`})}),i?null:(0,Q.jsx)(h,{label:q(`project.remove`),onClick:s,className:r(Hn,`hover:text-rose`),children:(0,Q.jsx)(Y,{className:`size-4`})})]})]}),(0,Q.jsx)(Un,{name:t.name,namePlaceholder:n,description:t.description,usePlaceholder:q(`project.patternUse`),readOnly:i,onChange:o})]})}function qn({projectId:e,pattern:t,isNew:n,fileName:i,busy:a,error:o,upload:s,removeFile:l,onSave:u,onClose:d}){let[f,p]=(0,Z.useState)(t),[m,h]=(0,Z.useState)([]),g=async e=>{let t=e[0];if(!t)return;let n=await s(t);n&&(h(e=>[...e,n.id]),p(e=>({...e,file:n.id,name:e.name||n.name.replace(/\.[^.]+$/,``)})))},_=()=>{for(let e of m)l(e);d()};return(0,Q.jsx)(c,{open:!0,onClose:_,wide:!0,title:q(n?`project.patternNew`:`project.patternEdit`),children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[f.file?(0,Q.jsx)(`div`,{className:`relative h-40 rounded-lg ring-1 ring-border-soft`,style:Gn(ke(e,f.file),f.tile),children:(0,Q.jsxs)(ve,{accept:`image/*`,multiple:!1,onFiles:e=>void g(e),className:`absolute right-2 bottom-2 h-9 border-solid bg-card px-3.5 text-ink-2 shadow-soft`,children:[a?(0,Q.jsx)(y,{className:`size-4`}):(0,Q.jsx)(D,{className:`size-4`}),q(`project.patternReplace`)]})}):(0,Q.jsxs)(ve,{accept:`image/*`,multiple:!1,onFiles:e=>void g(e),className:`h-40 flex-col`,children:[a?(0,Q.jsx)(y,{className:`size-5`}):(0,Q.jsx)(D,{className:`size-5`}),q(`project.patternPick`)]}),(0,Q.jsxs)(`div`,{className:`grid gap-x-6 gap-y-4 sm:grid-cols-2`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(R,{children:q(`project.patternName`)}),(0,Q.jsx)(F,{value:f.name,maxLength:80,placeholder:f.file?i(f.file):q(`project.patternNamePlaceholder`),onChange:e=>p({...f,name:e.target.value})})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(R,{children:q(`project.fillUseLabel`)}),(0,Q.jsx)(F,{value:f.description??``,maxLength:400,placeholder:q(`project.patternUse`),onChange:e=>p({...f,description:e.target.value})})]})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(R,{children:q(`project.patternShow`)}),(0,Q.jsx)(`div`,{className:`flex w-fit gap-1 rounded-full bg-paper-2 p-0.5 ring-1 ring-border-soft`,children:[!1,!0].map(e=>(0,Q.jsx)(`button`,{type:`button`,"aria-pressed":!!f.tile===e,onClick:()=>p({...f,tile:e||void 0}),className:r(`h-9 rounded-full px-4 font-medium text-[0.875rem] transition`,!!f.tile===e?`bg-card text-ink shadow-sm`:`text-ink-3 hover:text-ink-2`),children:q(e?`project.patternTile`:`project.patternFill`)},String(e)))})]}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[o?(0,Q.jsx)(`p`,{className:`mr-auto text-[0.8125rem] text-rose`,children:o}):null,(0,Q.jsx)(S,{variant:`ghost`,onClick:_,children:q(`common.cancel`)}),(0,Q.jsx)(S,{disabled:!f.file||a,onClick:()=>{for(let e of m.filter(e=>e!==f.file))l(e);t.file&&t.file!==f.file&&l(t.file),u({...f,name:f.name.trim(),description:f.description?.trim()||void 0}),d()},children:q(n?`project.add`:`settings.save`)})]})]})})}var Jn=/^#[0-9a-fA-F]{6}$/;function Yn({projectId:e,onAdd:t,onClose:n}){let[i,a]=(0,Z.useState)(``),[o,s]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(null),[d,f]=(0,Z.useState)(null),[p,m]=(0,Z.useState)([]),h=async()=>{s(!0),u(null);try{let{colors:t}=await L.post(`/api/studio/projects/${e}/colors/scan`,{url:i.trim()});t.length?(f(t),m([])):u(q(`project.colorsNoneFound`))}catch(e){u(e.message)}s(!1)};return(0,Q.jsx)(c,{open:!0,onClose:n,wide:d?!0:void 0,title:q(d?`project.colorsFound`:`project.colorsFromUrl`),children:d?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-ink-3`,children:q(`project.colorsFoundHint`)}),(0,Q.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(120px,1fr))] gap-3`,children:d.map(e=>{let t=p.includes(e.value);return(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":t,onClick:()=>m(n=>t?n.filter(t=>t!==e.value):[...n,e.value]),className:r(`relative flex flex-col overflow-hidden rounded-lg text-left ring-1 transition`,t?`ring-2 ring-ember`:`ring-border-soft hover:ring-ink-4`),children:[(0,Q.jsx)(`span`,{className:`h-16`,style:{background:e.value}}),(0,Q.jsxs)(`span`,{className:`flex flex-col px-2.5 py-2`,children:[(0,Q.jsx)(`span`,{className:`truncate text-[0.8125rem] text-ink-2`,children:e.name||`—`}),(0,Q.jsx)(`span`,{className:`font-mono text-[0.75rem] text-ink-3`,children:e.value})]}),t?(0,Q.jsx)(`span`,{className:`absolute top-1.5 right-1.5 grid size-5 place-items-center rounded-full bg-ember text-white`,children:(0,Q.jsx)(I,{className:`size-3.5`})}):null]},e.value)})}),(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Q.jsx)(S,{variant:`ghost`,onClick:()=>f(null),children:q(`run.back`)}),(0,Q.jsx)(S,{disabled:!p.length,onClick:()=>{t(d.filter(e=>p.includes(e.value))),n()},children:p.length>1?q(`project.addMany`,{n:p.length}):q(`project.add`)})]})]}):(0,Q.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),h()},className:`flex flex-col gap-5`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(R,{children:q(`project.logoUrl`)}),(0,Q.jsx)(F,{autoFocus:!0,value:i,inputMode:`url`,placeholder:`https://example.com`,onChange:e=>a(e.target.value)}),(0,Q.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:q(`project.colorsUrlHint`)})]}),l?(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:l}):null,(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Q.jsx)(S,{variant:`ghost`,onClick:n,children:q(`common.cancel`)}),(0,Q.jsx)(S,{type:`submit`,busy:o,disabled:!i.trim(),children:q(`run.next`)})]})]})})}function Xn({projectId:e,data:t,colors:n,sections:r,gradients:a,patterns:o,rules:c,sectioned:l,ruled:u,save:d,readOnly:f}){let[p,m]=(0,Z.useState)(()=>n.map(e=>({...e,id:De()}))),[g,_]=(0,Z.useState)(r),[v,y]=(0,Z.useState)(a),[b,x]=(0,Z.useState)(o),[S,C]=(0,Z.useState)(null),[w,T]=(0,Z.useState)(null),E=ne(e,f),D=te(c),[O,ee]=(0,Z.useState)(null),[k,A]=(0,Z.useState)(null),[j,M]=(0,Z.useState)(!1),N=s({colors:p.filter(e=>Jn.test(e.value)).map(({name:e,value:t,section:n})=>({name:e.trim(),value:t,...n?{section:n}:{}})),colorSections:g,gradients:v,patterns:b,colorRules:D.rules},d),P=l?g:[],I=P.filter(e=>(e.kind??`colors`)===`colors`),re=e=>I.some(t=>t.id===e.section),L=p.filter(e=>!re(e)),R=(L[0]??p[0])?.id,z=(e,t)=>m(n=>n.map(n=>n.id===e?{...n,...t}:n)),B=e=>m(t=>[...t,...e.map(e=>({...e,id:De()}))].slice(0,i.colors)),V=[{value:``,label:q(`project.sectionStandard`)},...I.map(e=>({value:e.id,label:e.title||q(`project.sectionUntitled`)}))],U=(e,t)=>{let n=De();ee(n),_(r=>[...r,{id:n,title:t,...e===`colors`?{}:{kind:e}}])},G=e=>({id:De(),name:``,section:e,type:`linear`,angle:90,stops:[{color:p[0]?.value&&Jn.test(p[0].value)?p[0].value:`#4b73ff`,at:0},{color:p[1]?.value&&Jn.test(p[1].value)?p[1].value:`#ff6d1b`,at:100}]}),ae=e=>t.files.find(t=>t.id===e)?.name??`pattern`,se=[...p.length<i.colors?[{label:q(`project.colorNew`),icon:(0,Q.jsx)(Oe,{className:`size-4 shrink-0`}),onPick:()=>K()},{label:q(`project.colorsFromUrl`),icon:(0,Q.jsx)(un,{className:`size-4 shrink-0`}),onPick:()=>M(!0)}]:[],...l&&g.length<i.logoSections?[{label:q(`project.colorSectionAdd`),icon:(0,Q.jsx)(on,{className:`size-4 shrink-0`}),onPick:()=>U(`colors`,``)},{label:q(`project.gradientSectionAdd`),icon:(0,Q.jsx)($t,{className:`size-4 shrink-0`}),onPick:()=>U(`gradients`,q(`project.gradientSectionTitle`))},{label:q(`project.patternSectionAdd`),icon:(0,Q.jsx)(cn,{className:`size-4 shrink-0`}),onPick:()=>U(`patterns`,q(`project.patternSectionTitle`))}]:[],...!u||D.full?[]:[{label:q(`project.ruleNew`),icon:(0,Q.jsx)(Ie,{className:`size-4 shrink-0`}),onPick:()=>D.add()}]],ue=e=>(0,Q.jsxs)(`div`,{className:`group/row flex items-center gap-2`,children:[(0,Q.jsx)(H,{value:Jn.test(e.value)?e.value:`#888888`,onChange:t=>z(e.id,{value:t.target.value})}),(0,Q.jsx)(F,{value:e.name,autoFocus:e.id===k,placeholder:q(`project.colorName`),maxLength:120,onChange:t=>z(e.id,{name:t.target.value}),className:`min-w-0 flex-1`}),(0,Q.jsx)(F,{value:e.value,placeholder:`#e0531b`,spellCheck:!1,onChange:t=>z(e.id,{value:t.target.value.trim()}),className:`w-28 font-mono text-[0.8125rem]`}),(0,Q.jsxs)(`div`,{className:`flex w-28 shrink-0 items-center justify-end max-sm:w-auto`,children:[e.id===R?(0,Q.jsx)(`span`,{className:`mr-1 max-sm:hidden`,children:(0,Q.jsx)(Ae,{tone:`ember`,children:q(`project.colorAccent`)})}):f?null:(0,Q.jsx)(h,{label:q(`project.colorFirst`),onClick:()=>m(t=>[{...e,section:void 0},...t.filter(t=>t.id!==e.id)]),className:`opacity-0 transition focus:opacity-100 group-hover/row:opacity-100 coarse:opacity-100`,children:(0,Q.jsx)(ie,{className:`size-4`})}),f||!I.length?null:(0,Q.jsx)(de,{options:V,value:re(e)?e.section??``:``,onChange:t=>z(e.id,{section:t||void 0}),className:`opacity-0 focus-within:opacity-100 group-hover/row:opacity-100 coarse:opacity-100`}),f?null:(0,Q.jsx)(h,{label:q(`project.remove`),onClick:()=>m(t=>t.filter(t=>t.id!==e.id)),className:`opacity-0 transition focus:opacity-100 group-hover/row:opacity-100 coarse:opacity-100 hover:text-rose`,children:(0,Q.jsx)(Y,{className:`size-4`})})]})]},e.id),K=e=>{let t=De();A(t),m(n=>[...n,{id:t,name:``,value:`#888888`,...e?{section:e}:{}}])};return(0,Q.jsxs)(X,{title:q(`project.colors`),hint:q(`project.colorsHint`),save:N,locked:f,action:f?null:(0,Q.jsx)(ce,{entries:se}),children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[L.length?(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:L.map(ue)}),f?null:(0,Q.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:q(`project.colorUse`)})]}):p.length?null:(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:q(`project.colorsEmpty`)}),P.map(t=>{let n=t.kind??`colors`,r=p.filter(e=>e.section===t.id),a=v.filter(e=>e.section===t.id),o=b.filter(e=>e.section===t.id),s=n===`gradients`?a.length:n===`patterns`?o.length:r.length;return(0,Q.jsxs)(`div`,{className:`group/section flex flex-col gap-3`,children:[(0,Q.jsx)(oe,{title:t.title,titlePlaceholder:q(n===`gradients`?`project.gradientSectionTitlePlaceholder`:n===`patterns`?`project.patternSectionTitlePlaceholder`:`project.colorSectionTitle`),kind:n===`gradients`?{icon:(0,Q.jsx)($t,{}),label:q(`project.kindGradients`)}:n===`patterns`?{icon:(0,Q.jsx)(cn,{}),label:q(`project.kindPatterns`)}:{icon:(0,Q.jsx)(jt,{}),label:q(`project.kindColors`)},autoFocus:O===t.id,readOnly:f,onChange:e=>_(n=>n.map(n=>n.id===t.id?{...n,...e}:n)),onRemove:()=>{if(!s||confirm(q(n===`colors`?`project.colorSectionRemoveConfirm`:`project.fillSectionRemoveConfirm`,{name:t.title||q(`project.sectionUntitled`)}))){_(e=>e.filter(e=>e.id!==t.id)),m(e=>e.map(e=>e.section===t.id?{...e,section:void 0}:e)),y(e=>e.filter(e=>e.section!==t.id));for(let e of o)E.remove(e.file);x(e=>e.filter(e=>e.section!==t.id))}}}),n===`gradients`?(0,Q.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(200px,1fr))] gap-3`,children:[a.map(e=>(0,Q.jsx)(Wn,{gradient:e,readOnly:f,onEdit:()=>C(e),onChange:t=>y(n=>n.map(n=>n.id===e.id?{...n,...t}:n)),onRemove:()=>y(t=>t.filter(t=>t.id!==e.id))},e.id)),f||v.length>=i.gradients?null:(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>C(G(t.id)),className:`flex min-h-28 flex-col items-center justify-center gap-2 rounded-lg border border-input border-dashed text-[0.875rem] text-ink-3 transition hover:border-ink-4 hover:text-ink`,children:[(0,Q.jsx)(Oe,{className:`size-5`}),q(`project.gradientAdd`)]})]}):n===`patterns`?(0,Q.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(200px,1fr))] gap-3`,children:[o.map(t=>(0,Q.jsx)(Kn,{projectId:e,pattern:t,fileName:ae(t.file),readOnly:f,onEdit:()=>T(t),onChange:e=>x(n=>n.map(n=>n.id===t.id?{...n,...e}:n)),onRemove:()=>{E.remove(t.file),x(e=>e.filter(e=>e.id!==t.id))}},t.id)),f||b.length>=i.files.pattern?null:(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>T({id:De(),name:``,section:t.id,file:``}),className:`flex min-h-28 flex-col items-center justify-center gap-2 rounded-lg border border-input border-dashed text-[0.875rem] text-ink-3 transition hover:border-ink-4 hover:text-ink`,children:[(0,Q.jsx)(Oe,{className:`size-5`}),q(`project.patternAdd`)]})]}):(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[r.map(ue),f||p.length>=i.colors?null:(0,Q.jsx)(le,{label:q(`project.colorAdd`),onClick:()=>K(t.id)})]})]},t.id)}),u?(0,Q.jsx)(W,{rules:D,placeholder:q(`project.colorRulePlaceholder`),readOnly:f}):null]}),E.error?(0,Q.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:E.error}):null,S?(0,Q.jsx)(Bn,{projectId:e,gradient:S,isNew:!v.some(e=>e.id===S.id),brand:p.filter(e=>Jn.test(e.value)),onClose:()=>C(null),onSave:e=>y(t=>t.some(t=>t.id===e.id)?t.map(t=>t.id===e.id?e:t):[...t,e])}):null,w?(0,Q.jsx)(qn,{projectId:e,pattern:w,isNew:!b.some(e=>e.id===w.id),fileName:ae,busy:E.busy,error:E.error,upload:async e=>(await E.upload(`pattern`,[e]))[0]??null,removeFile:e=>void E.remove(e),onClose:()=>T(null),onSave:e=>x(t=>t.some(t=>t.id===e.id)?t.map(t=>t.id===e.id?e:t):[...t,e])}):null,j?(0,Q.jsx)(Yn,{projectId:e,onClose:()=>M(!1),onAdd:B}):null]})}var Zn=e=>/^(ja|yes|true)$/i.test(e.trim()),Qn={text:Pe,longtext:_t,number:Re,date:ze,url:f,email:Vt,phone:ht,boolean:Be};function $n({type:e,detected:t,onChange:n}){let[i,a]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)(!1),c=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{if(!i)return;let e=e=>{c.current?.contains(e.target)||a(!1)},t=e=>e.key===`Escape`&&a(!1);return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[i]);let l=Qn[e??t],u=`${q(`project.factType`)}: ${q(`project.type.${e??t}`)}`,d=`flex w-full items-center gap-3 rounded-lg px-3 py-2 text-left text-[0.875rem] text-ink-2 hover:bg-accent hover:text-ink`,f=e=>{n(e),a(!1)};return(0,Q.jsxs)(`div`,{className:`relative`,ref:c,children:[(0,Q.jsx)(`button`,{type:`button`,"aria-label":u,title:u,"aria-haspopup":`menu`,"aria-expanded":i,onClick:e=>{s(window.innerHeight-e.currentTarget.getBoundingClientRect().bottom<400),a(e=>!e)},className:r(`inline-flex size-11 items-center justify-center rounded-lg transition hover:bg-accent hover:text-ink`,i?`bg-accent text-ink`:e?`text-ink-2`:`text-ink-4`),children:(0,Q.jsx)(l,{className:`size-4`})}),i?(0,Q.jsxs)(`div`,{role:`menu`,className:r(`absolute right-0 z-50 w-56 animate-rise rounded-xl bg-card p-1.5 shadow-overlay ring-1 ring-border-soft`,o?`bottom-12`:`top-12`),children:[(0,Q.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":!e,className:d,onClick:()=>f(void 0),children:[(0,Q.jsx)(Fe,{className:`size-4 shrink-0`}),(0,Q.jsx)(`span`,{className:`flex-1`,children:q(`project.factAuto`)}),(0,Q.jsx)(`span`,{className:`text-[0.75rem] text-ink-4`,children:q(`project.type.${t}`)}),(0,Q.jsx)(I,{className:r(`size-4 shrink-0`,e&&`invisible`)})]}),(0,Q.jsx)(`div`,{className:`mx-2 my-1 h-px bg-border-soft`}),Ee.map(t=>{let n=Qn[t];return(0,Q.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":e===t,className:d,onClick:()=>f(t),children:[(0,Q.jsx)(n,{className:`size-4 shrink-0`}),(0,Q.jsx)(`span`,{className:`flex-1`,children:q(`project.type.${t}`)}),(0,Q.jsx)(I,{className:r(`size-4 shrink-0`,e!==t&&`invisible`)})]},t)})]}):null]})}function er({facts:e,save:t,readOnly:n}){let r=(0,Z.useRef)(0),a=(0,Z.useRef)(null),[o,c]=(0,Z.useState)(()=>e.map(e=>({...e,id:`f${r.current++}`}))),u=s(o.filter(e=>e.key&&e.label.trim()).map(({key:e,label:t,value:n,type:r})=>({key:e,label:t.trim(),value:n,...r?{type:r}:{}})),t),d=(e,t)=>c(n=>n.map(n=>n.id===e?{...n,...t}:n)),f=(e,t,n=!1)=>{let i=`f${r.current++}`;a.current=`${i}:${t}`;let o={id:i,key:``,label:``,value:``,...e};c(e=>n?[o,...e]:[...e,o])},p=e=>t=>{t&&a.current===e&&(a.current=null,t.focus())},m=l.filter(e=>!o.some(t=>t.key===e));return(0,Q.jsxs)(X,{title:q(`project.facts`),hint:q(`project.factsHint`),save:u,locked:n,action:o.length<i.facts&&!n?(0,Q.jsxs)(S,{variant:`secondary`,size:`sm`,onClick:()=>f({},`label`,!0),children:[(0,Q.jsx)(Oe,{className:`size-4`}),` `,q(`project.factAdd`)]}):null,children:[(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:o.map(e=>{let t=me(e.value),r=e.type??t;return(0,Q.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_auto_auto] items-start gap-x-1 gap-y-2 sm:grid-cols-[minmax(0,2fr)_minmax(0,3fr)_auto_auto]`,children:[(0,Q.jsx)(F,{ref:p(`${e.id}:label`),value:e.label,placeholder:q(`project.factLabel`),title:e.key?`{{facts.${e.key}}}`:void 0,onChange:t=>d(e.id,{label:t.target.value}),onBlur:()=>{!e.key&&e.label.trim()&&d(e.id,{key:C(e.label,o.map(e=>e.key))})},className:`max-sm:col-span-3 max-sm:font-medium sm:mr-1`}),e.type===`boolean`?(0,Q.jsxs)(`div`,{className:`flex h-11 items-center gap-3`,children:[(0,Q.jsx)(V,{checked:Zn(e.value),label:e.label,onChange:t=>d(e.id,{value:q(t?`project.yes`:`project.no`)})}),(0,Q.jsx)(`span`,{className:`text-[0.875rem] text-ink-2`,children:Zn(e.value)?q(`project.yes`):q(`project.no`)})]}):(0,Q.jsx)(A,{ref:p(`${e.id}:value`),rows:1,minRows:r===`longtext`?2:1,maxRows:10,value:e.value,placeholder:q(`project.factValue`),onChange:t=>d(e.id,{value:t.target.value}),className:`min-h-11`}),(0,Q.jsx)($n,{type:e.type,detected:t,onChange:t=>d(e.id,{type:t})}),n?null:(0,Q.jsx)(h,{label:q(`project.remove`),onClick:()=>c(t=>t.filter(t=>t.id!==e.id)),className:`size-11 rounded-lg hover:text-rose`,children:(0,Q.jsx)(Y,{className:`size-4`})})]},e.id)})}),o.length<i.facts&&!n?(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 ${o.length?`mt-4`:``}`,children:[(0,Q.jsxs)(S,{variant:`secondary`,size:`sm`,onClick:()=>f({},`label`),children:[(0,Q.jsx)(Oe,{className:`size-4`}),` `,q(`project.factAdd`)]}),m.map(e=>(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>f({key:e,label:q(`fact.${e}`)},`value`),className:`inline-flex h-8 items-center gap-1 rounded-full bg-paper-2 px-3 text-[0.8125rem] text-ink-2 transition hover:bg-paper-3 hover:text-ink`,children:[(0,Q.jsx)(Oe,{className:`size-3.5`}),` `,q(`fact.${e}`)]},e))]}):null]})}function tr({onLogo:e,children:t,className:n}){let[i,a]=(0,Z.useState)(!1);return e?(0,Q.jsx)(`div`,{onDragOver:e=>{e.dataTransfer.types.includes(`application/x-wizards-logo`)&&(e.preventDefault(),a(!0))},onDragLeave:()=>a(!1),onDrop:t=>{let n=t.dataTransfer.getData(Sn);a(!1),n&&(t.preventDefault(),e(n))},className:r(`-m-2 rounded-xl p-2 transition`,i&&`bg-paper-2 ring-1 ring-focus`,n),children:t}):(0,Q.jsx)(`div`,{className:n,children:t})}function nr({projectId:e,data:t,readOnly:n,sections:r,rules:a,sectioned:o,ruled:c,save:l}){let u=ne(e,n),[d,f]=(0,Z.useState)(r),p=te(a),[m,h]=(0,Z.useState)(null),[_,v]=(0,Z.useState)(!1),y=(0,Z.useRef)(null),b=s({logoSections:d,logoRules:p.rules},l),x=t.files.filter(e=>e.kind===`logo`),S=new Map(x.map(e=>[e.id,e])),C=o?d:[],w=new Set(C.flatMap(e=>e.logos)),T=x.filter(e=>!w.has(e.id)),E=g(x,d)?.id,D=(e,t)=>f(n=>n.map(n=>{let r=n.logos.filter(t=>t!==e);return{...n,logos:n.id===t?[...r,e]:r}})),O=(e,t)=>f(n=>n.map(n=>n.id===e?{...n,...t}:n)),ee=async(e,t)=>{let n=await u.upload(`logo`,e);for(let e of n)D(e.id,t)},k=C.length?{options:[{value:``,label:q(`project.sectionStandard`)},...C.map(e=>({value:e.id,label:e.title||q(`project.sectionUntitled`)}))],current:e=>C.find(t=>t.logos.includes(e.id))?.id??``,onMove:(e,t)=>D(e.id,t||null)}:void 0,A=(t,n,r)=>(0,Q.jsx)(Cn,{projectId:e,kind:`logo`,files:t,actions:u,accept:`image/*`,addLabel:r?q(`project.logoAdd`):void 0,onUpload:e=>void ee(e,n),mainId:E,onMakeMain:e=>{D(e.id,null),u.order(`logo`,[e.id,...x.filter(t=>t.id!==e.id).map(e=>e.id)])},moveTo:k,onRemove:e=>{confirm(q(`project.removeConfirm`,{name:e.name}))&&(u.remove(e.id),D(e.id,null))}}),j=n?void 0:e=>t=>D(t,e),M=[{label:q(`project.logoUpload`),icon:(0,Q.jsx)(yt,{className:`size-4 shrink-0`}),onPick:()=>y.current?.click()},{label:q(`project.logoFromUrl`),icon:(0,Q.jsx)(un,{className:`size-4 shrink-0`}),onPick:()=>v(!0)},...o&&d.length<i.logoSections?[{label:q(`project.logoSectionAdd`),icon:(0,Q.jsx)(on,{className:`size-4 shrink-0`}),onPick:()=>{let e=De();h(e),f(t=>[...t,{id:e,title:``,description:``,logos:[]}])}}]:[],...!c||p.full?[]:[{label:q(`project.ruleNew`),icon:(0,Q.jsx)(Ie,{className:`size-4 shrink-0`}),onPick:()=>p.add()}]];return(0,Q.jsxs)(X,{title:q(`project.logos`),hint:q(`project.logosHint`),save:b,action:n?null:(0,Q.jsx)(ce,{entries:M}),children:[(0,Q.jsx)(`input`,{ref:y,type:`file`,accept:`image/*`,className:`sr-only`,tabIndex:-1,"aria-hidden":!0,onChange:e=>{let t=Array.from(e.target.files??[]);e.target.value=``,t.length&&ee(t,null)}}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[(0,Q.jsx)(tr,{onLogo:j?.(null),children:A(T,null,!0)}),C.map(e=>(0,Q.jsx)(`div`,{className:`group/section`,children:(0,Q.jsxs)(tr,{onLogo:j?.(e.id),className:`flex flex-col gap-3`,children:[(0,Q.jsx)(oe,{title:e.title,description:e.description,titlePlaceholder:q(`project.logoSectionTitle`),descriptionPlaceholder:q(`project.logoSectionUse`),autoFocus:m===e.id,readOnly:n,onChange:t=>O(e.id,t),onRemove:()=>{(!e.logos.length||confirm(q(`project.logoSectionRemoveConfirm`,{name:e.title||q(`project.sectionUntitled`)})))&&f(t=>t.filter(t=>t.id!==e.id))}}),A(e.logos.map(e=>S.get(e)).filter(e=>!!e),e.id,!0)]})},e.id)),c?(0,Q.jsx)(W,{rules:p,placeholder:q(`project.logoRulePlaceholder`),readOnly:n}):null]}),u.error?(0,Q.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:u.error}):null,_?(0,Q.jsx)(wn,{kind:`logo`,onClose:()=>v(!1),fetchUrl:e=>u.fromUrl(`logo`,e),onAdded:e=>{for(let t of e)D(t.id,null)}}):null]})}var rr=e=>URL.canParse(e)?new URL(e).host:e;async function ir(e,t){let n=T({family:t,source:{url:e}});if(!n)return`down`;if(n.stylesheet)return await ar(e,t);let r=await fetch(e,{mode:`cors`}).catch(()=>null);return r?r.ok?await new FontFace(`engenty-check-${Date.now()}`,await r.arrayBuffer()).load().then(()=>`ok`,()=>`noFont`):`down`:await fetch(e,{mode:`no-cors`}).then(()=>!0,()=>!1)?`cors`:`down`}function ar(e,t){let n=new Set(document.fonts),r=document.createElement(`link`);return r.rel=`stylesheet`,r.href=e,new Promise(e=>{r.onerror=()=>e(`down`),r.onload=async()=>{let r=[...document.fonts].filter(e=>!n.has(e)&&e.family.replace(/^["']|["']$/g,``)===t),i=await Promise.allSettled(r.map(e=>e.load()));e(r.length===0?`missing`:i.some(e=>e.status===`fulfilled`)?`ok`:`cors`)},document.head.append(r)}).finally(()=>r.remove())}function or(e,t){let n=e.source;if(!n)return q(`project.fontSourceNone`);if(`file`in n){let e=t.find(e=>e.id===n.file)?.name??``;return q(`project.fontSourceFile`,{name:e})}return q(`project.fontSourceUrl`,{host:rr(n.url)})}function sr({projectId:e,font:t,onSave:n,onClose:i}){let a=(P(e).data?.files??[]).filter(e=>e.mime.startsWith(`font/`)),o=ne(e),s=(0,Z.useRef)(null),[l,u]=(0,Z.useState)(t.source&&`url`in t.source?`url`:`file`),[d,f]=(0,Z.useState)(t.source&&`file`in t.source?t.source.file:``),[p,m]=(0,Z.useState)(t.source&&`url`in t.source?t.source.url:``),[h,g]=(0,Z.useState)(t.source&&`url`in t.source?{url:t.source.url,result:`ok`}:null),[_,v]=(0,Z.useState)(!1),[y,x]=(0,Z.useState)(t.license??``),[C,w]=(0,Z.useState)(!1),T=p.trim(),E=async()=>{v(!0),g({url:T,result:await ir(T,t.family.trim())}),v(!1)},D=l===`file`?d?{file:d}:null:h?.url===T&&h.result===`ok`?{url:T}:null,O=h?.url===T?h.result:null;return(0,Q.jsx)(c,{open:!0,onClose:i,title:q(`project.fontSourceTitle`,{family:t.family}),children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-ink-3`,children:q(`project.fontSourceHint`)}),(0,Q.jsx)(b,{value:l,options:[`file`,`url`],label:e=>q(`project.fontSourceKind.${e}`),onChange:e=>u(e)}),l===`file`?(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(R,{children:q(`project.fontSourceFiles`)}),(0,Q.jsx)(`div`,{className:`flex flex-col gap-1`,children:a.map(e=>(0,Q.jsx)(`button`,{type:`button`,"aria-pressed":d===e.id,onClick:()=>f(e.id),className:r(`rounded-lg px-3 py-2 text-left text-[0.875rem] ring-1 transition`,d===e.id?`ring-2 ring-ember`:`ring-border-soft hover:ring-ink-4`),children:e.name},e.id))}),(0,Q.jsx)(`input`,{ref:s,type:`file`,accept:`.woff2,.woff,.ttf,.otf`,className:`hidden`,onChange:async e=>{let t=[...e.target.files??[]];e.target.value=``;let[n]=await o.upload(`asset`,t);n&&f(n.id)}}),(0,Q.jsxs)(S,{variant:`ghost`,className:`mt-2`,busy:o.busy,onClick:()=>s.current?.click(),children:[(0,Q.jsx)(yt,{className:`size-4`}),q(`project.fontSourceUpload`)]}),o.error?(0,Q.jsx)(`p`,{className:`mt-1.5 text-[0.875rem] text-rose`,children:o.error}):null]}):(0,Q.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),E()},children:[(0,Q.jsx)(R,{children:q(`project.fontSourceUrlLabel`)}),(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(F,{value:p,inputMode:`url`,placeholder:q(`project.fontSourceUrlPlaceholder`),onChange:e=>m(e.target.value)}),(0,Q.jsx)(S,{type:`submit`,variant:`ghost`,busy:_,disabled:!T.startsWith(`https://`),children:q(`project.fontSourceCheck`)})]}),O?(0,Q.jsx)(`p`,{className:r(`mt-1.5 text-[0.875rem]`,O===`ok`?`text-ink-3`:`text-rose`),children:q(`project.fontCheck.${O}`,{host:rr(T),family:t.family})}):null,O===`ok`?(0,Q.jsx)(`p`,{className:`mt-1.5 text-[0.875rem] text-ink-3`,children:q(`project.fontPrivacy`,{host:rr(T)})}):null]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(R,{hint:q(`project.fontLicenseHint`),children:q(`project.fontLicense`)}),(0,Q.jsx)(F,{value:y,maxLength:200,placeholder:q(`project.fontLicensePlaceholder`),onChange:e=>x(e.target.value)}),(0,Q.jsxs)(`label`,{className:`mt-2 flex items-start gap-2 text-[0.875rem]`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,className:`mt-0.5 size-4 accent-ember`,checked:C,onChange:e=>w(e.target.checked)}),q(`project.fontLicenseConfirm`,{family:t.family})]})]}),(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[t.source?(0,Q.jsx)(S,{variant:`ghost`,className:`mr-auto`,onClick:()=>{n({source:void 0,license:t.license}),i()},children:q(`project.fontSourceRemove`)}):null,(0,Q.jsx)(S,{variant:`ghost`,onClick:i,children:q(`common.cancel`)}),(0,Q.jsx)(S,{disabled:!(D&&C),onClick:()=>{D&&(n({source:D,license:y.trim()||void 0}),i())},children:q(`project.fontSourceSave`)})]})]})})}var cr=new Set;function lr(e){(0,Z.useEffect)(()=>{let t=e.trim().toLowerCase().replace(/\s+/g,`-`);if(!t||cr.has(t))return;cr.add(t);let n=document.createElement(`link`);n.rel=`stylesheet`,n.href=`https://fonts.bunny.net/css?family=${encodeURIComponent(t)}:${p.join(`,`)}&display=swap`,document.head.append(n)},[e])}var ur=e=>e?`"${e}", system-ui, sans-serif`:`system-ui, sans-serif`;function dr({unit:e,label:t,...n}){return(0,Q.jsxs)(`label`,{className:`inline-flex items-center gap-1 text-[0.75rem] text-ink-3`,title:t,children:[(0,Q.jsx)(`input`,{type:`number`,"aria-label":t,className:`h-8 w-14 rounded-md border border-input bg-card px-1.5 text-right text-[0.8125rem] text-ink tabular-nums outline-none transition focus:border-focus focus:ring-2 focus:ring-focus-glow`,...n}),e]})}var fr=`h-8 rounded-md border border-input bg-card px-1.5 text-[0.8125rem] text-ink outline-none transition focus:border-focus focus:ring-2 focus:ring-focus-glow`,pr={web:`project.fontUseWeb`,documents:`project.fontUseDocuments`,print:`project.fontUsePrint`,images:`project.fontUseImages`,video:`project.fontUseVideo`};function mr({projectId:e,font:t,first:n,readOnly:i,autoFocus:a,onChange:o,onRemove:s}){lr(t.family);let c=P(e).data?.files??[],[l,u]=(0,Z.useState)(!1);return(0,Q.jsxs)(`div`,{className:`group/font relative flex flex-col gap-2 rounded-lg bg-paper p-3 ring-1 ring-border-soft`,children:[(0,Q.jsxs)(`div`,{className:`flex h-28 items-end justify-between overflow-hidden rounded-md bg-card px-4 pb-3 ring-1 ring-border-soft`,style:{fontFamily:ur(t.family)},children:[(0,Q.jsx)(`span`,{className:`text-[3.5rem] text-ink leading-none`,children:`Aa`}),(0,Q.jsx)(`span`,{className:`truncate pl-3 text-[0.875rem] text-ink-3`,children:`ABCDEFG abcdefg 0123456789`})]}),i?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`font-medium text-[0.9375rem]`,children:t.family}),t.role?(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:t.role}):null]}):(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(K,{value:t.family,label:q(`project.fontFamily`),placeholder:q(`project.fontFamily`),maxLength:80,autoFocus:a,onChange:e=>o({family:e}),className:`font-medium text-[0.9375rem]`}),(0,Q.jsx)(K,{value:t.role,label:q(`project.fontRole`),placeholder:q(n?`project.fontRoleFirst`:`project.fontRole`),maxLength:200,onChange:e=>o({role:e}),className:`text-[0.875rem] text-ink-3`})]}),(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:p.map(e=>{let n=t.weights.includes(e);return(0,Q.jsx)(`button`,{type:`button`,disabled:i,"aria-pressed":n,onClick:()=>o({weights:n?t.weights.filter(t=>t!==e):[...t.weights,e].sort((e,t)=>e-t)}),style:{fontFamily:ur(t.family),fontWeight:e},className:r(`h-7 rounded-full px-2.5 text-[0.8125rem] tabular-nums transition`,n?`bg-ink text-paper`:`bg-paper-2 text-ink-3 hover:text-ink`,i&&!n&&`hidden`),children:e},e)})}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[i?t.license?(0,Q.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3`,children:t.license}):null:(0,Q.jsx)(K,{value:t.license??``,label:q(`project.fontLicense`),placeholder:q(`project.fontLicensePlaceholder`),maxLength:200,onChange:e=>o({license:e}),className:`text-[0.8125rem] text-ink-3`}),i&&!t.uses?.length?null:(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[(0,Q.jsx)(`span`,{className:`mr-1 text-[0.8125rem] text-ink-3`,children:q(`project.fontUses`)}),N.map(e=>{let n=!!t.uses?.includes(e);return(0,Q.jsxs)(`button`,{type:`button`,disabled:i,"aria-pressed":n,onClick:()=>{let r=n?(t.uses??[]).filter(t=>t!==e):N.filter(n=>n===e||t.uses?.includes(n));o({uses:r.length?r:void 0})},className:r(`inline-flex h-7 items-center gap-1 rounded-full px-2.5 text-[0.8125rem] transition`,n?`bg-card text-ink ring-1 ring-border`:`bg-paper-2 text-ink-3 hover:text-ink`,i&&!n&&`hidden`),children:[n?(0,Q.jsx)(I,{className:`size-3.5`}):null,q(pr[e])]},e)})]})]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-[0.8125rem] text-ink-3`,children:[(0,Q.jsx)(`span`,{className:`min-w-0 truncate`,children:or(t,c)}),i||!t.family.trim()?null:(0,Q.jsx)(`button`,{type:`button`,onClick:()=>u(!0),className:`text-ink underline decoration-border underline-offset-2 hover:decoration-ink`,children:q(t.source?`project.fontSourceChange`:`project.fontSourceSet`)})]}),l?(0,Q.jsx)(sr,{projectId:e,font:t,onSave:o,onClose:()=>u(!1)}):null,i?null:(0,Q.jsx)(h,{label:q(`project.remove`),onClick:s,className:`absolute top-4 right-4 size-8 bg-card opacity-0 shadow-soft transition focus:opacity-100 group-hover/font:opacity-100 coarse:opacity-100 hover:text-rose`,children:(0,Q.jsx)(Y,{className:`size-4`})})]})}function hr({style:e,fonts:t,sample:n,readOnly:i,autoFocus:a,onChange:o,onRemove:s}){let c=t.find(t=>t.id===e.font)??t[0],l={fontFamily:ur(c?.family),fontWeight:e.weight,fontSize:`${Math.min(e.size,56)}px`,lineHeight:`${e.lineHeight}%`,letterSpacing:`${e.tracking/100}em`,textTransform:e.uppercase?`uppercase`:void 0};return(0,Q.jsxs)(`li`,{className:`group/row flex flex-col gap-2 border-border-soft border-b py-4 first:pt-1 last:border-b-0`,children:[(0,Q.jsx)(`div`,{className:`truncate text-ink`,style:l,children:n}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2`,children:[i?(0,Q.jsx)(`span`,{className:`font-medium text-[0.8125rem] text-ink-2 uppercase tracking-wide`,children:e.name}):(0,Q.jsx)(`div`,{className:`w-40`,children:(0,Q.jsx)(K,{value:e.name,label:q(`project.styleName`),placeholder:q(`project.styleName`),maxLength:60,autoFocus:a,onChange:e=>o({name:e}),className:`font-medium text-[0.8125rem] text-ink-2 uppercase tracking-wide`})}),(0,Q.jsxs)(`fieldset`,{disabled:i,className:`flex flex-wrap items-center gap-x-3 gap-y-2`,children:[t.length>1?(0,Q.jsx)(`select`,{"aria-label":q(`project.styleFont`),value:c?.id??``,onChange:e=>o({font:e.target.value}),className:r(fr,`max-w-40`),children:t.map(e=>(0,Q.jsx)(`option`,{value:e.id,children:e.family||q(`project.fontFamily`)},e.id))}):null,(0,Q.jsx)(`select`,{"aria-label":q(`project.styleWeight`),value:e.weight,onChange:e=>o({weight:Number(e.target.value)}),className:fr,children:[...new Set([...p,e.weight])].sort().map(e=>(0,Q.jsx)(`option`,{value:e,children:e},e))}),(0,Q.jsx)(dr,{unit:`px`,label:q(`project.styleSize`),min:6,max:400,value:e.size,onChange:e=>o({size:Number(e.target.value)||16})}),(0,Q.jsx)(dr,{unit:q(`project.styleLine`),label:q(`project.styleLineLabel`),min:50,max:300,value:e.lineHeight,onChange:e=>o({lineHeight:Number(e.target.value)||100})}),(0,Q.jsx)(dr,{unit:q(`project.styleTracking`),label:q(`project.styleTrackingLabel`),min:-20,max:50,step:.5,value:e.tracking,onChange:e=>o({tracking:Number(e.target.value)||0})}),(0,Q.jsx)(`button`,{type:`button`,"aria-pressed":!!e.uppercase,title:q(`project.styleUpper`),"aria-label":q(`project.styleUpper`),onClick:()=>o({uppercase:!e.uppercase}),className:r(`grid size-8 place-items-center rounded-md transition`,e.uppercase?`bg-ink text-paper`:`text-ink-3 hover:bg-paper-2 hover:text-ink`),children:(0,Q.jsx)(rn,{className:`size-4`})})]}),i?null:(0,Q.jsx)(h,{label:q(`project.remove`),onClick:s,className:`ml-auto size-8 opacity-0 transition focus:opacity-100 group-hover/row:opacity-100 coarse:opacity-100 hover:text-rose`,children:(0,Q.jsx)(Y,{className:`size-4`})})]})]})}function gr({projectId:e,onAdd:t,onClose:n}){let[r,i]=(0,Z.useState)(``),[a,o]=(0,Z.useState)(!1),[s,l]=(0,Z.useState)(null),[u,d]=(0,Z.useState)(null),[f,p]=(0,Z.useState)([]),m=async()=>{o(!0),l(null);try{let{fonts:t}=await L.post(`/api/studio/projects/${e}/fonts/scan`,{url:r.trim()});t.length?(d(t),p(t.slice(0,2).map(e=>e.family))):l(q(`project.fontsNoneFound`))}catch(e){l(e.message)}o(!1)};return(0,Q.jsx)(c,{open:!0,onClose:n,wide:u?!0:void 0,title:q(u?`project.fontsFound`:`project.fontsFromUrl`),children:u?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-ink-3`,children:q(`project.fontsFoundHint`)}),(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:u.map(e=>(0,Q.jsx)(_r,{font:e,on:f.includes(e.family),onToggle:()=>p(t=>t.includes(e.family)?t.filter(t=>t!==e.family):[...t,e.family])},e.family))}),(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Q.jsx)(S,{variant:`ghost`,onClick:()=>d(null),children:q(`run.back`)}),(0,Q.jsx)(S,{disabled:!f.length,onClick:()=>{t(u.filter(e=>f.includes(e.family))),n()},children:f.length>1?q(`project.addMany`,{n:f.length}):q(`project.add`)})]})]}):(0,Q.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),m()},className:`flex flex-col gap-5`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(R,{children:q(`project.logoUrl`)}),(0,Q.jsx)(F,{autoFocus:!0,value:r,inputMode:`url`,placeholder:`https://example.com`,onChange:e=>i(e.target.value)}),(0,Q.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:q(`project.fontsUrlHint`)})]}),s?(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:s}):null,(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Q.jsx)(S,{variant:`ghost`,onClick:n,children:q(`common.cancel`)}),(0,Q.jsx)(S,{type:`submit`,busy:a,disabled:!r.trim(),children:q(`run.next`)})]})]})})}function _r({font:e,on:t,onToggle:n}){return lr(e.family),(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":t,onClick:n,className:r(`flex items-center gap-4 rounded-lg px-4 py-3 text-left ring-1 transition`,t?`ring-2 ring-ember`:`ring-border-soft hover:ring-ink-4`),children:[(0,Q.jsx)(`span`,{className:`text-[2rem] text-ink leading-none`,style:{fontFamily:ur(e.family)},children:`Aa`}),(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,Q.jsx)(`span`,{className:`font-medium text-[0.9375rem]`,children:e.family}),(0,Q.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3 tabular-nums`,children:e.weights.length?e.weights.join(` · `):q(`project.fontWeightsUnknown`)})]}),t?(0,Q.jsx)(`span`,{className:`grid size-5 place-items-center rounded-full bg-ember text-white`,children:(0,Q.jsx)(I,{className:`size-3.5`})}):null]})}function vr({projectId:e,fonts:t,styles:n,rules:r,ruled:a,sample:o,save:c,readOnly:l}){let[u,d]=(0,Z.useState)(t),[f,p]=(0,Z.useState)(n),m=te(r),[h,g]=(0,Z.useState)(null),[_,v]=(0,Z.useState)(!1),y=s({fonts:u,textStyles:f,typeRules:m.rules},c),b=(e,t=!1)=>{let n=e.map(e=>({id:De(),family:e.family,role:``,weights:e.weights}));t&&n[0]&&g(n[0].id),d(e=>[...e,...n].slice(0,i.fonts))},x=()=>{let e=De();g(e),p(t=>[...t,{id:e,name:``,size:16,weight:400,lineHeight:150,tracking:0}])},S=[...u.length<i.fonts?[{label:q(`project.fontNew`),icon:(0,Q.jsx)(Oe,{className:`size-4 shrink-0`}),onPick:()=>b([{family:``,weights:[400,700]}],!0)},{label:q(`project.fontsFromUrl`),icon:(0,Q.jsx)(un,{className:`size-4 shrink-0`}),onPick:()=>v(!0)}]:[],...f.length<i.textStyles?[{label:q(`project.styleNew`),icon:(0,Q.jsx)(It,{className:`size-4 shrink-0`}),onPick:x}]:[],...!a||m.full?[]:[{label:q(`project.ruleNew`),icon:(0,Q.jsx)(Ie,{className:`size-4 shrink-0`}),onPick:()=>m.add()}]];return(0,Q.jsxs)(X,{title:q(`project.typography`),hint:q(`project.typographyHint`),save:y,action:l?null:(0,Q.jsx)(ce,{entries:S}),children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[u.length?(0,Q.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(260px,1fr))] gap-3`,children:u.map((t,n)=>(0,Q.jsx)(mr,{projectId:e,font:t,first:n===0,readOnly:l,autoFocus:h===t.id,onChange:e=>d(n=>n.map(n=>n.id===t.id?{...n,...e}:n)),onRemove:()=>d(e=>e.filter(e=>e.id!==t.id))},t.id))}):(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:q(`project.fontsEmpty`)}),f.length?(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h3`,{className:`font-medium text-[0.9375rem]`,children:q(`project.styles`)}),l?null:(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-ink-3 leading-snug`,children:q(`project.stylesHint`)}),(0,Q.jsx)(`ul`,{className:`mt-2 flex flex-col`,children:f.map(e=>(0,Q.jsx)(hr,{style:e,fonts:u,sample:o,readOnly:l,autoFocus:h===e.id,onChange:t=>p(n=>n.map(n=>n.id===e.id?{...n,...t}:n)),onRemove:()=>p(t=>t.filter(t=>t.id!==e.id))},e.id))})]}):null,a?(0,Q.jsx)(W,{rules:m,placeholder:q(`project.typeRulePlaceholder`),readOnly:l}):null]}),_?(0,Q.jsx)(gr,{projectId:e,onClose:()=>v(!1),onAdd:e=>b(e)}):null]})}function yr({project:e,save:t}){let[n,r]=(0,Z.useState)(e.brand.name??``),[i,a]=(0,Z.useState)(e.brand.about??``),o=s({name:n.trim(),about:i.trim()},e=>t({brand:e}));return(0,Q.jsx)(X,{title:q(`project.base`),hint:q(`project.baseHint`),save:o,locked:e.readOnly,children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(R,{children:q(`project.title`)}),(0,Q.jsx)(F,{value:n,maxLength:120,onChange:e=>r(e.target.value)}),(0,Q.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:q(`project.titleHint`)})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(R,{children:q(`project.about`)}),(0,Q.jsx)(A,{minRows:4,value:i,onChange:e=>a(e.target.value)}),(0,Q.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:q(`project.aboutHint`)})]})]})})}function br({project:e,group:t,top:n=!1,children:r}){let i=a(),o=P(e.id),[s,l]=(0,Z.useState)(0),[u,d]=(0,Z.useState)(!1),f=async t=>{await L.patch(`/api/studio/projects/${e.id}`,t),await i.invalidateQueries({queryKey:[`projects`]})},p=Le({mutationFn:()=>L.del(`/api/studio/projects/${e.id}`),onSuccess:()=>i.invalidateQueries({queryKey:[`projects`]})}),m=pt(),h=dt(),g=o.data??{files:[],embeddings:!0},_=`${e.id}:${s}`,v=e.readOnly,y=t===`knowledge`,b=St(`brandSections`),x=St(`brandRules`),C=St(`typography`);return Mt(v?{}:{title:q(y?`project.assistantTitleKnowledge`:`project.assistantTitle`),hello:q(y?`project.assistantHelloKnowledge`:`project.assistantHello`),about:q(y?`project.assistantAboutKnowledge`:`project.assistantAbout`),placeholder:q(y?`project.assistantComposerKnowledge`:`project.assistantComposer`),suggestions:y?[{label:q(`assistant.suggest.knowledgeHow`)},{label:q(`assistant.suggest.knowledgeSite`),fill:!0},{label:q(`assistant.suggest.knowledgeCategories`)}]:[{label:q(`assistant.suggest.readSite`),fill:!0},{label:q(`assistant.suggest.missing`)},{label:q(`assistant.suggest.facts`)}],summary:y?void 0:[e.brand.name?`title "${e.brand.name}"`:`no title`,`${e.facts.length} facts`,`${e.brand.colors?.length??0} colours`,`${g.files.filter(e=>e.kind===`logo`).length} logos`].join(` · `),onChanged:()=>l(e=>e+1)}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-9`,children:[v?(0,Q.jsx)(vt,{children:gt(e)}):n?(0,Q.jsx)(xt,{}):null,t===`info`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(J,{id:`base`,children:(0,Q.jsx)(yr,{project:e,save:f},`base:${_}`)}),(0,Q.jsx)(J,{id:`facts`,children:(0,Q.jsx)(er,{facts:e.facts,save:e=>f({facts:e}),readOnly:v},`facts:${_}`)}),(0,Q.jsx)(J,{id:`logos`,children:(0,Q.jsx)(nr,{projectId:e.id,data:g,readOnly:v,sections:e.brand.logoSections??[],rules:e.brand.logoRules??[],sectioned:b,ruled:x,save:e=>f({brand:e})},`logos:${_}`)}),(0,Q.jsx)(J,{id:`colors`,children:(0,Q.jsx)(Xn,{projectId:e.id,data:g,colors:e.brand.colors??[],sections:e.brand.colorSections??[],gradients:e.brand.gradients??[],patterns:e.brand.patterns??[],rules:e.brand.colorRules??[],sectioned:b,ruled:x,save:e=>f({brand:e}),readOnly:v},`colors:${_}`)}),C?(0,Q.jsx)(J,{id:`typography`,children:(0,Q.jsx)(vr,{projectId:e.id,fonts:e.brand.fonts??[],styles:e.brand.textStyles??[],rules:e.brand.typeRules??[],ruled:x,sample:e.brand.name||q(`project.typeSample`),save:e=>f({brand:e}),readOnly:v},`typography:${_}`)}):null,(0,Q.jsx)(J,{id:`assets`,children:(0,Q.jsx)(In,{projectId:e.id,data:g,readOnly:v,sections:e.brand.assetSections??[],save:e=>f({brand:e})},`assets:${_}`)})]}):null,r,t===`info`&&m&&!v&&h?(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(S,{variant:`danger`,onClick:()=>d(!0),children:q(`settings.delete`)}),(0,Q.jsxs)(c,{open:u,onClose:()=>d(!1),title:q(`settings.deleteTitle`,{name:e.name}),children:[(0,Q.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-ink-2`,children:q(`settings.deleteBody`)}),p.error?(0,Q.jsx)(`p`,{className:`mt-3 text-[0.8125rem] text-rose`,children:p.error.message}):null,(0,Q.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,Q.jsx)(S,{variant:`ghost`,onClick:()=>d(!1),children:q(`common.cancel`)}),(0,Q.jsx)(S,{variant:`danger`,busy:p.isPending,onClick:()=>p.mutate(),children:q(`common.delete`)})]})]})]}):null]})}var xr=[{value:`de-du`,label:`page.lang.deDu`},{value:`de-sie`,label:`page.lang.deSie`},{value:`en`,label:`page.lang.en`}],$=`text-[0.8125rem] text-ink-3 leading-snug`,Sr=`font-mono text-[0.875rem]`,Cr=e=>e.slice(e.indexOf(`.`)+1);function wr(){let[e,t]=(0,Z.useState)(!1),n=(0,Z.useRef)(void 0);return(0,Z.useEffect)(()=>()=>clearTimeout(n.current),[]),{copied:e,copy:e=>navigator.clipboard.writeText(e).then(()=>{t(!0),clearTimeout(n.current),n.current=setTimeout(()=>t(!1),1500)}).catch(()=>t(!1))}}function Tr(){let e=q(`page.sources`).split(/(\{brand\}|\{facts\})/);return(0,Q.jsxs)(`p`,{className:$,children:[e.map((e,t)=>e===`{brand}`?(0,Q.jsx)(B,{to:`/space/info`,className:`text-ink underline-offset-2 hover:underline`,children:q(`space.info`)},t):e===`{facts}`?(0,Q.jsx)(B,{to:`/space/info#facts`,className:`text-ink underline-offset-2 hover:underline`,children:q(`project.facts`)},t):e),` `,q(`page.onlyShared`)]})}function Er({host:e,value:t,onChange:n,disabled:i}){let a=ge.test(t);return(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`flex h-11 items-stretch overflow-hidden rounded-lg border border-input bg-card focus-within:border-focus focus-within:ring-4 focus-within:ring-focus-glow`,children:[(0,Q.jsxs)(`span`,{title:`${e}/`,className:`flex max-w-[55%] items-center truncate bg-paper-2 px-3 font-mono text-[0.75rem] text-ink-3`,children:[`…`,Cr(e),`/`]}),(0,Q.jsx)(`input`,{value:t,disabled:i,"aria-label":q(`page.address`),maxLength:E.slug,onChange:e=>n(e.target.value.toLowerCase().replace(/[^a-z0-9-]/g,`-`)),className:r(`min-w-0 flex-1 bg-transparent px-3 outline-none`,Sr)})]}),(0,Q.jsx)(`p`,{className:r(`mt-1.5`,$,!a&&t&&`text-rose`),children:q(`page.addressRules`)})]})}function Dr({host:e,words:t,onChange:n,disabled:i}){return(0,Q.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)] gap-5 sm:grid-cols-[repeat(2,minmax(0,1fr))]`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(R,{children:q(`page.title`)}),(0,Q.jsx)(F,{value:t.title,disabled:i,maxLength:E.title,onChange:e=>n({title:e.target.value})}),(0,Q.jsx)(`p`,{className:r(`mt-1.5`,$),children:q(`page.titleHint`)})]}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(R,{children:q(`page.address`)}),(0,Q.jsx)(Er,{host:e,value:t.slug,disabled:i,onChange:e=>n({slug:e})}),(0,Q.jsx)(`p`,{className:r(`mt-1`,$),children:q(`page.addressChange`)})]}),(0,Q.jsxs)(`div`,{className:`min-w-0 sm:col-span-2`,children:[(0,Q.jsx)(R,{children:q(`page.headline`)}),(0,Q.jsx)(F,{value:t.headline??``,disabled:i,maxLength:E.headline,onChange:e=>n({headline:e.target.value})})]}),(0,Q.jsxs)(`div`,{className:`min-w-0 sm:col-span-2`,children:[(0,Q.jsx)(R,{children:q(`page.words`)}),(0,Q.jsx)(A,{value:t.intro??``,disabled:i,minRows:3,maxLength:E.intro,onChange:e=>n({intro:e.target.value})})]}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(R,{children:q(`page.lang`)}),(0,Q.jsx)(xe,{value:t.voice,onChange:e=>n({voice:e}),options:xr.map(e=>({value:e.value,label:q(e.label)}))}),(0,Q.jsx)(`p`,{className:r(`mt-1.5`,$),children:q(`page.langHint`)})]})]})}function Or(e,t){if(!e.published)return q(`page.draftNote`);if(!e.shareEnabled)return q(`page.notSharedNote`);let n=e.description.trim();return t?[n,q(`page.first`)].filter(Boolean).join(` · `):n}function kr({wizard:e,first:t,on:n,disabled:i,onToggle:a,drag:o}){return(0,Q.jsxs)(`li`,{draggable:o?!0:void 0,onDragStart:o?.onDragStart,onDragOver:o?.onDragOver,onDrop:o?.onDrop,className:r(`flex items-center gap-3 border-border-soft border-t py-2.5 first:border-t-0`,!e.published&&`opacity-60`),children:[o?(0,Q.jsx)(`button`,{type:`button`,"aria-label":`${q(`page.moveUp`)} / ${q(`page.moveDown`)}`,onKeyDown:o.onKeyDown,className:`grid size-7 shrink-0 cursor-grab place-items-center rounded-md text-ink-4 hover:text-ink focus:text-ink`,children:(0,Q.jsx)(_e,{className:`size-4`})}):(0,Q.jsx)(`span`,{className:`size-7 shrink-0`}),(0,Q.jsx)(mt,{kind:e.avatar,costume:e.costume,size:36,interactive:!1}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`div`,{className:`truncate font-medium text-[0.9375rem]`,children:e.title}),(0,Q.jsx)(`p`,{className:r(`truncate`,$),children:Or(e,t)})]}),(0,Q.jsx)(V,{checked:n,disabled:i||!e.published,label:q(`page.showOnPage`),onChange:a})]})}function Ar({title:e,text:t,picked:n,disabled:i,later:a,onPick:o}){return(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":n,disabled:i||a,onClick:o,className:r(`flex min-h-20 flex-col items-start gap-1 rounded-xl px-4 py-3 text-left transition`,n?`bg-accent ring-2 ring-primary`:a?`border border-border border-dashed opacity-60`:`ring-1 ring-border-soft hover:bg-paper-2`,(i||a)&&`cursor-not-allowed`),children:[(0,Q.jsx)(`span`,{className:`font-medium text-[0.9375rem]`,children:e}),(0,Q.jsx)(`span`,{className:$,children:t})]})}var jr={desktop:1280,tablet:768,mobile:390},Mr=`wizards.pagePreviewDevice`,Nr=`wizards.pagePreviewHeight`,Pr=360,Fr=e=>e?640:480,Ir=()=>Math.max(Pr,window.innerHeight-140);function Lr(){try{let e=Number(localStorage.getItem(Nr));return e>=Pr?e:null}catch{return null}}function Rr(e){try{e===null?localStorage.removeItem(Nr):localStorage.setItem(Nr,String(Math.round(e)))}catch{}}function zr(){try{let e=localStorage.getItem(Mr);return e&&e in jr?e:`desktop`}catch{return`desktop`}}function Br(e){try{localStorage.setItem(Mr,e)}catch{}}function Vr({url:e,version:t,device:n}){let i=(0,Z.useRef)(null),[a,o]=(0,Z.useState)({width:0,tall:!0});(0,Z.useEffect)(()=>{let e=i.current;if(!e)return;let t=()=>o({width:e.clientWidth,tall:e.clientWidth>=640});t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]);let s=jr[n],[c,l]=(0,Z.useState)(Lr),[u,d]=(0,Z.useState)(!1),f=(0,Z.useRef)(null),p=Math.min(c??Fr(a.tall),a.width?Ir():9999),m=e=>{let t=Math.round(Math.min(Ir(),Math.max(Pr,e)));return l(t),t},h=n===`mobile`,g=h?12:0,_=a.width?Math.min(1,(a.width-2*g)/s):1,v=(0,Q.jsxs)(`div`,{className:r(`relative overflow-hidden bg-paper-2`,h?`rounded-[1.5rem]`:`rounded-lg ring-1 ring-border-soft`),style:{width:Math.round(s*_),height:p},children:[a.width?(0,Q.jsx)(`iframe`,{title:q(`page.previewTitle`),src:`${e}${e.includes(`?`)?`&`:`?`}v=${t}`,tabIndex:-1,className:r(`absolute top-0 left-0 border-0`,u&&`pointer-events-none`),style:{width:s,height:Math.ceil(p/_),transform:`scale(${_})`,transformOrigin:`top left`}},t):null,(0,Q.jsx)(`button`,{type:`button`,"aria-label":q(`page.resize`),title:q(`page.resize`),onPointerDown:e=>{e.preventDefault();try{e.currentTarget.setPointerCapture(e.pointerId)}catch{}f.current={y:e.clientY,height:p},d(!0)},onPointerMove:e=>{f.current&&m(f.current.height+e.clientY-f.current.y)},onPointerUp:e=>{f.current&&=(Rr(m(f.current.height+e.clientY-f.current.y)),null),d(!1)},onPointerCancel:()=>{f.current=null,d(!1)},onDoubleClick:()=>{l(null),Rr(null)},onKeyDown:e=>{(e.key===`ArrowUp`||e.key===`ArrowDown`)&&(e.preventDefault(),Rr(m(p+(e.key===`ArrowDown`?24:-24))))},className:`absolute right-1 bottom-1 z-10 grid size-7 cursor-ns-resize touch-none place-items-center rounded-md bg-card/90 text-ink-3 shadow-soft ring-1 ring-border-soft hover:text-ink coarse:size-9`,children:(0,Q.jsx)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 12 12`,"aria-hidden":`true`,children:(0,Q.jsx)(`path`,{d:`M11 1 1 11M11 5 5 11M11 9 9 11`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`})})})]});return(0,Q.jsx)(`div`,{ref:i,className:`flex w-full justify-center`,children:h?(0,Q.jsx)(`div`,{className:`rounded-[2.25rem] bg-ink p-3 shadow-soft`,children:v}):v})}function Hr({host:e,page:t,disabled:n,save:r,onState:i}){let a=(0,Z.useRef)(t);a.current=t;let[o,c]=(0,Z.useState)(()=>({slug:t.slug,title:t.title,headline:t.headline??``,intro:t.intro??``,voice:Ve(t)})),l=s(o,async e=>{if(!(ge.test(e.slug)&&e.title.trim()))return;let{lang:t,form:n}=st(e.voice);await r({...a.current,slug:e.slug,title:e.title.trim(),headline:e.headline?.trim()||void 0,intro:e.intro?.trim()||void 0,lang:t,form:n})}),{state:u,error:d}=l;return(0,Z.useEffect)(()=>i(l),[u,d]),(0,Q.jsx)(Dr,{host:e,words:o,disabled:n,onChange:e=>c(t=>({...t,...e}))})}function Ur({project:e}){let t=a(),n=ft(),i=n.data?.tenant.pagesHost??null,o=n.data?.manageUrl??null,s=e.readOnly,c=e.page,l=!!c?.on,u=ae({queryKey:[`project-wizards`,e.id],queryFn:()=>L.get(`/api/studio/projects/${e.id}/wizards`)}),[d,f]=(0,Z.useState)(1),[p,m]=(0,Z.useState)(zr),h=(0,Z.useRef)(c);h.current=c;let g=async n=>{await L.patch(`/api/studio/projects/${e.id}`,{page:n}),await t.invalidateQueries({queryKey:[`projects`]}),f(e=>e+1)},v=Le({mutationFn:e=>{let t=h.current;return t?g({...t,...e}):Promise.resolve()}}),[y,b]=(0,Z.useState)({state:`idle`,error:null}),{copied:C,copy:w}=wr(),T=u.data??[],E=(c?.wizards??[]).map(e=>T.find(t=>t.id===e)).filter(e=>e!==void 0),D=T.filter(e=>!c?.wizards.includes(e.id)),[O,ee]=(0,Z.useState)(null),k=(e,t)=>{let n=[...c?.wizards??[]];if(t<0||t>=n.length||e===t)return;let[r]=n.splice(e,1);n.splice(t,0,r),v.mutate({wizards:n})},A=(e,t)=>v.mutate({wizards:t?[...c?.wizards??[],e]:(c?.wizards??[]).filter(t=>t!==e)}),j=e.brand.name?.trim()||e.name,te=Le({mutationFn:()=>g({on:!0,slug:x(j)||`page`,title:j,...st(we===`de`?`de-du`:`en`),wizards:T.filter(e=>e.published&&e.shareEnabled).map(e=>e.id),examples:{}})}),N=e=>{c?v.mutate({on:e}):e&&te.mutate()},P=v.isPending||te.isPending,F=v.error??te.error;if(!i)return(0,Q.jsx)(J,{id:`page`,children:(0,Q.jsx)(X,{title:q(`space.page`),hint:q(`page.intro`),children:(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-ink-2`,children:q(`page.cloudOnly`)})})});let ne=c?.slug||x(j)||`…`,re=We(i,ne),ie=ot(i,ne,o),R=(0,Q.jsxs)(`span`,{className:r(Sr,`min-w-0 truncate`),children:[(0,Q.jsxs)(`span`,{className:`text-ink-3`,children:[i,`/`]}),(0,Q.jsx)(`b`,{className:`text-ink`,children:ne})]}),z=s||!c,B=(0,Q.jsxs)(M,{className:`flex flex-col gap-2.5 p-4`,children:[(0,Q.jsxs)(`div`,{className:`@container flex items-center justify-between gap-3`,children:[(0,Q.jsx)(`h3`,{className:`font-medium text-[0.875rem]`,children:q(`page.previewTitle`)}),l?(0,Q.jsx)(rt,{named:!0,label:q(`editor.device`),value:p,onChange:e=>{m(e),Br(e)},options:[{id:`desktop`,label:q(`editor.deviceDesk`),icon:(0,Q.jsx)(kt,{className:`size-3.5`})},{id:`tablet`,label:q(`page.deviceTablet`),icon:(0,Q.jsx)(gn,{className:`size-3.5`})},{id:`mobile`,label:q(`editor.devicePhone`),icon:(0,Q.jsx)(ct,{className:`size-3.5`})}]}):null]}),l?(0,Q.jsx)(Vr,{url:ie,version:d,device:p}):(0,Q.jsx)(`p`,{className:$,children:q(`page.previewOff`)}),l?(0,Q.jsx)(`p`,{className:$,children:q(`page.previewHint`)}):null]}),H=(0,Q.jsxs)(M,{className:`flex flex-col gap-3 p-4`,children:[(0,Q.jsx)(`h3`,{className:`font-medium text-[0.875rem]`,children:q(`page.inShare`)}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg bg-paper-2 px-3 py-2.5`,children:[(0,Q.jsxs)(`span`,{className:`min-w-0`,children:[(0,Q.jsx)(`span`,{className:`block truncate font-medium text-[0.875rem]`,children:q(`share.onPage`,{space:c?.title||j})}),(0,Q.jsx)(`span`,{className:r(`block truncate font-mono`,$),children:re})]}),(0,Q.jsx)(V,{checked:!0,disabled:!0,label:q(`page.showOnPage`),onChange:()=>{}})]}),(0,Q.jsx)(`p`,{className:$,children:q(`page.inShareHint`)})]});return(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-9`,children:[(0,Q.jsxs)(`div`,{className:`contents`,children:[(0,Q.jsx)(J,{id:`page`,children:(0,Q.jsxs)(`section`,{className:`flex flex-col gap-4`,children:[(0,Q.jsxs)(`div`,{className:`px-1`,children:[(0,Q.jsx)(`h2`,{className:`font-display font-semibold text-lg leading-tight`,children:q(`space.page`)}),(0,Q.jsx)(`p`,{className:`mt-1 text-[0.875rem] text-ink-3 leading-snug`,children:q(`page.intro`)})]}),(0,Q.jsxs)(M,{className:`flex flex-wrap items-center gap-3 p-3 sm:pl-4`,children:[(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:r(`size-2 shrink-0 rounded-full`,l?`bg-moss`:`bg-ink-4`),"aria-hidden":!0}),R]}),(0,Q.jsxs)(`span`,{className:`flex w-full items-center gap-2 sm:w-auto sm:shrink-0`,children:[(0,Q.jsxs)(S,{variant:`secondary`,size:`sm`,className:`max-sm:flex-1`,disabled:!l,onClick:()=>w(ie),children:[C?(0,Q.jsx)(I,{className:`size-3.5`}):(0,Q.jsx)(_,{className:`size-3.5`}),q(C?`share.copied`:`share.copyMain`)]}),(0,Q.jsxs)(S,{size:`sm`,className:`max-sm:flex-1`,disabled:!l,onClick:()=>window.open(ie,`_blank`,`noopener`),children:[q(`page.open`),` `,(0,Q.jsx)(bt,{className:`size-3.5`})]})]})]}),(0,Q.jsxs)(X,{title:q(`page.sectionPage`),locked:s,children:[(0,Q.jsxs)(`fieldset`,{"aria-label":q(`page.sectionPage`),className:`grid min-w-0 gap-3 sm:grid-cols-[repeat(3,minmax(0,1fr))]`,children:[(0,Q.jsx)(Ar,{title:q(`page.whoOff`),text:q(`page.whoOffHint`),picked:!l,disabled:s||P,onPick:()=>N(!1)}),(0,Q.jsx)(Ar,{title:q(`page.whoPublic`),text:q(`page.whoPublicHint`),picked:l,disabled:s||P,onPick:()=>N(!0)}),(0,Q.jsx)(Ar,{title:q(`page.whoMembers`),text:q(`page.whoMembersHint`),picked:!1,later:!0,onPick:()=>{}})]}),F?(0,Q.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:F.message}):null]})]})}),B,(0,Q.jsx)(J,{id:`page-words`,children:(0,Q.jsx)(X,{title:q(`page.sectionWords`),hint:c?void 0:q(`page.notYet`),save:c?y:void 0,locked:z,children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[c?(0,Q.jsx)(Hr,{host:i,page:c,disabled:s,save:g,onState:b},`${e.id}:${c.slug}`):(0,Q.jsx)(Dr,{host:i,disabled:!0,words:{slug:ne,title:j,headline:``,intro:``,voice:we===`de`?`de-du`:`en`},onChange:()=>{}}),(0,Q.jsxs)(`div`,{id:`page-wizards`,className:`scroll-mt-6 border-border-soft border-t pt-5`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-baseline justify-between gap-x-4 gap-y-1`,children:[(0,Q.jsx)(`h3`,{className:`font-medium text-[0.9375rem]`,children:q(`page.sectionWizards`)}),(0,Q.jsx)(`span`,{className:$,children:q(`page.wizardsHint`)})]}),(0,Q.jsxs)(`ul`,{className:`mt-2 flex flex-col`,children:[E.map((e,t)=>(0,Q.jsx)(kr,{wizard:e,first:t===0,on:!0,disabled:z,onToggle:t=>A(e.id,t),drag:{onDragStart:()=>ee(t),onDragOver:e=>e.preventDefault(),onDrop:()=>{O!==null&&k(O,t),ee(null)},onKeyDown:e=>{(e.key===`ArrowUp`||e.key===`ArrowDown`)&&(e.preventDefault(),k(t,e.key===`ArrowUp`?t-1:t+1))}}},e.id)),D.map(e=>(0,Q.jsx)(kr,{wizard:e,first:!1,on:!1,disabled:z,onToggle:t=>A(e.id,t)},e.id))]}),T.length?null:(0,Q.jsx)(`p`,{className:r(`mt-2`,$),children:q(`page.noWizards`)}),(0,Q.jsx)(`p`,{className:r(`mt-4`,$),children:q(`page.wizardsNote`)})]}),(0,Q.jsx)(Tr,{})]})})})]}),H]})}var Wr=`results-search`,Gr={q:``,mode:``,days:0};function Kr(e,t,n){let r=new URLSearchParams;t&&r.set(`wizard`,t),n.q.trim()&&r.set(`q`,n.q.trim()),n.mode&&r.set(`mode`,n.mode),n.days&&r.set(`days`,String(n.days));let i=r.toString();return ae({queryKey:[`results`,e,i],queryFn:()=>L.get(`/api/studio/projects/${e}/results${i&&`?${i}`}`),enabled:!!e,placeholderData:e=>e,refetchInterval:15e3})}function qr({data:e,wizardId:t,onWizard:n,filter:r,onFilter:i}){let[a,o]=(0,Z.useState)(r.q);return Pt({icon:fe,label:q(`space.resultsSearch`),run:()=>{let e=document.getElementById(Wr);e?.scrollIntoView({block:`center`,behavior:`smooth`}),e?.focus()}}),(0,Z.useEffect)(()=>{if(a===r.q)return;let e=setTimeout(()=>i({...r,q:a}),250);return()=>clearTimeout(e)},[a,r,i]),(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Q.jsx)(xe,{value:t??``,onChange:e=>n(e||null),options:[{value:``,label:q(`space.resultsAllWizards`)},...e.wizards.filter(e=>e.results||e.id===t).map(e=>({value:e.id,label:`${e.title} (${e.results})`}))],className:`w-56 max-sm:w-full`}),(0,Q.jsxs)(`div`,{className:`relative min-w-0 flex-1 basis-56`,children:[(0,Q.jsx)(fe,{className:`-translate-y-1/2 pointer-events-none absolute top-1/2 left-3 size-4 text-ink-3`}),(0,Q.jsx)(F,{type:`search`,value:a,onChange:e=>o(e.target.value),id:Wr,placeholder:q(`space.resultsSearch`),"aria-label":q(`space.resultsSearch`),className:`w-full pl-9`})]}),(0,Q.jsx)(xe,{value:r.mode,onChange:e=>i({...r,mode:e}),options:[{value:``,label:q(`space.resultsModeAll`)},{value:`live`,label:`Live`},{value:`test`,label:`Test`}],className:`w-32`}),(0,Q.jsx)(xe,{value:String(r.days),onChange:e=>i({...r,days:Number(e)}),options:[{value:`0`,label:q(`space.resultsAnyTime`)},{value:`1`,label:q(`space.resultsDay`)},{value:`7`,label:q(`space.resultsDays`,{n:7})},{value:`30`,label:q(`space.resultsDays`,{n:30})}],className:`w-44`})]})}function Jr({data:e,wizardId:t,onWizard:n,filter:r,onFilter:i}){let[a,o]=(0,Z.useState)(null),s=t=>e.wizards.find(e=>e.id===t)?.title??``,c=new Intl.DateTimeFormat(we,{dateStyle:`medium`,timeStyle:`short`});return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(X,{title:t?s(t):q(`space.resultsAll`),hint:q(`space.resultsHint`),plain:!0,children:[(0,Q.jsx)(qr,{data:e,wizardId:t,onWizard:n,filter:r,onFilter:i}),e.runs.length?(0,Q.jsx)(M,{className:`flex flex-col p-1.5`,children:e.runs.map(e=>(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>o(e),className:`flex items-center gap-3 rounded-lg px-3 py-2.5 text-left transition hover:bg-accent`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`div`,{className:`truncate text-[0.875rem]`,children:t?c.format(new Date(e.doneAt)):s(e.wizardId)}),(0,Q.jsxs)(`div`,{className:`truncate text-[0.75rem] text-ink-3`,children:[t?null:`${c.format(new Date(e.doneAt))} · `,q(`space.resultCredits`,{n:e.credits})]})]}),e.assets?(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[0.75rem] text-ink-3 tabular-nums`,title:q(`space.resultFiles`,{n:e.assets}),children:[(0,Q.jsx)(u,{className:`size-3.5`}),e.assets]}):null,e.mode===`test`?(0,Q.jsx)(Ae,{children:q(`run.testChip`)}):(0,Q.jsxs)(Ae,{tone:`live`,children:[`Live v`,e.version]})]},e.id))}):(0,Q.jsx)(M,{children:(0,Q.jsx)(re,{children:r.q.trim()||r.mode||r.days?q(`space.resultsNone`):q(`space.resultsEmpty`)})})]}),a?(0,Q.jsx)(tt,{header:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium text-[0.875rem]`,children:s(a.wizardId)}),a.mode===`test`?(0,Q.jsx)(Ae,{children:q(`run.testChip`)}):(0,Q.jsxs)(Ae,{tone:`live`,children:[`Live v`,a.version]})]}),onClose:()=>o(null),children:(0,Q.jsx)(lt,{runId:a.id,compact:!0,studio:!0},a.id)}):null]})}function Yr(e){let t=e.join(` `),[n,r]=(0,Z.useState)(e[0]);return(0,Z.useEffect)(()=>{let e=t.split(` `),n=0,i=()=>{n=0;let t=Lt(),i=t.scrollTop>0&&t.clientHeight+t.scrollTop>=t.scrollHeight-4,a=(t===document.documentElement?0:t.getBoundingClientRect().top)+Math.max(120,t.clientHeight/3),o=e[0];for(let t of e){let e=document.getElementById(t)?.getBoundingClientRect().top;e!==void 0&&e<=a&&(o=t)}r(i?e.at(-1):o)},a=()=>{n||=requestAnimationFrame(i)};return i(),window.addEventListener(`scroll`,a,{passive:!0,capture:!0}),window.addEventListener(`resize`,a),()=>{cancelAnimationFrame(n),window.removeEventListener(`scroll`,a,{capture:!0}),window.removeEventListener(`resize`,a)}},[t]),n}function Xr(){let[e,t]=(0,Z.useState)(null);return(0,Z.useEffect)(()=>{let e=Lt(),n=()=>t(e.clientHeight);n();let r=new ResizeObserver(n);return r.observe(e),()=>r.disconnect()},[]),e}function Zr(e,t){let n=window.matchMedia(`(prefers-reduced-motion: reduce)`).matches;document.getElementById(e)?.scrollIntoView({block:`start`,behavior:t&&!n?`smooth`:`auto`})}function Qr({groups:e,current:t,onPick:n}){return e.map(e=>{let r=e.sections.map(e=>(0,Q.jsx)(Ht,{icon:e.icon??Me,label:e.label,selected:e.id===t,onPick:()=>n(e.id)},e.id));return e.label?(0,Q.jsx)(Gt,{label:e.label,children:r},e.plugin):(0,Q.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:r},`own`)})}function $r(){let{group:e}=Se(),[t,n]=pe(),i=ye(),a=Ce(),{hash:o}=a,{project:s,loading:c}=ut(),l=Ft(),u=Zt(),[d,f]=(0,Z.useState)(null),[p,m]=(0,Z.useState)(null),[h,g]=(0,Z.useState)(null),_=Et(e)?e:void 0,v=_?void 0:l.spaceParts.find(t=>t.id===e),y=_??v?.id,b=a.state?.parts===!0,x=St(`pages`),S=Ot().filter(e=>x||e.id!==`page`),C=Dt(S,l).map(e=>({...e,to:`/space/${e.id}`})),w={id:`results`,label:q(`space.results`),icon:Rt,to:`/space/results`},T=_===`results`?w:C.find(e=>e.id===y),E=t.get(`show`),D=_===`results`?2:y?E?2:1:0,O=_===`results`?1:u?Math.min(D,1):y&&h!==y&&!b?1:0,ee=Wt(O),A=Wt(D),j=(0,Z.useMemo)(()=>({slot:d,narrow:u,setDetail:m}),[d,u]),M=s?s.brand.name?.trim()||s.name:q(`nav.project`),te=St(`typography`)?[]:[`typography`],N=v?l.spaceMenus[v.id]??[]:[],P=v?[{plugin:null,label:null,sections:N}]:_&&_!==`results`?At(_,l,te):[],F=_?At(_,l).filter(e=>e.plugin):[],ne=Yr([...P,..._===`results`?F:[]].flatMap(e=>e.sections.map(e=>e.id))),I=_===`results`&&E&&E!==`all`?E:null,[L,ie]=(0,Z.useState)(Gr),R=Kr(_===`results`?s?.id:void 0,I,L),z=R.data?.wizards.find(e=>e.id===I)?.title,B=_===`data`&&E&&E!==`all`||_===`knowledge`&&E&&/^[ptfcvs]:/.test(E)?E:null,V=B?.startsWith(`s:`)?l.spaceSections.find(e=>e.id===B.slice(2)):void 0,H=_===`knowledge`&&B&&/^[ptf]:/.test(B)?B:null,U=Ge(_===`data`?s?.id:void 0),W=Qe(_===`knowledge`?s?.id:void 0),G=at(B?.startsWith(`v:`)?B.slice(2):``),ae=W.data?.categories.find(e=>e.id===(B?.startsWith(`c:`)?B.slice(2):G.data?.category.id)),oe=_===`knowledge`?V?V.label():B?.startsWith(`v:`)?G.data&&`${G.data.category.name}: ${G.data.value}`:B?.startsWith(`c:`)?ae?.name:W.data?.items.find(e=>e.key===B)?.title:U.data?nt(U.data).flatMap(e=>e.items).find(e=>e.key===B)?.title:void 0;Bt([..._===`results`?[]:[{label:q(`nav.project`),to:`/space`}],...T?[{label:T.label,to:`/space/${T.id}`}]:[],...T&&(p??z??oe)?[{label:p??z??oe}]:[]]);let se={p:`page`,t:`table`,f:`file`,c:`category`,v:`category value`,s:`plugin section`};Mt({..._===`data`||_===`results`?{compact:!0}:{},..._===`data`?{suggestions:[{label:q(`assistant.suggest.dataWhat`)},{label:q(`assistant.suggest.dataWho`)},{label:q(`assistant.suggest.dataEdit`)}]}:_===`results`?{suggestions:[{label:q(`assistant.suggest.resultsFailed`)},{label:q(`assistant.suggest.resultsCost`)},{label:q(`assistant.suggest.resultsShare`)}]}:{},...B&&oe?{open:{kind:se[B[0]]??`item`,id:B.slice(2),label:oe}}:I&&z?{open:{kind:`wizard`,id:I,label:z}}:{}});let ce=_===`results`||_===`data`||B?o.slice(1):E||o.slice(1),le=(0,Z.useRef)(``);(0,Z.useEffect)(()=>{let e=`${y}#${ce}`;ce&&le.current!==e&&document.getElementById(ce)&&(le.current=e,requestAnimationFrame(()=>Zr(ce,!1)))},[y,ce,s?.id,l.spaceSections,N.length]),(0,Z.useEffect)(()=>{!u&&(y===`knowledge`||y===`data`)&&Lt().scrollTo({top:0})},[u,y,B]);let ue=Xr();if(!y){let t=o.slice(1),n=t?Tt(t,l):null;if(n===`knowledge`&&l.spaceSections.some(e=>e.id===t))return(0,Q.jsx)(k,{to:`/space/knowledge?show=s:${t}`,replace:!0});if(n)return(0,Q.jsx)(k,{to:u?`/space/${n}?show=${t}`:{pathname:`/space/${n}`,hash:t},replace:!0});if((t||e)&&l.status!==`ready`)return null;if(e!==void 0||!u)return(0,Q.jsx)(k,{to:`/space/info`,replace:!0,state:{parts:!0}})}if(_===`knowledge`&&!E&&l.spaceSections.some(e=>e.id===o.slice(1)))return(0,Q.jsx)(k,{to:`/space/knowledge?show=s:${o.slice(1)}`,replace:!0});let de=e=>{if(u){i({search:`?show=${e}`});return}le.current=`${y}#${e}`,Zr(e,!0),i({search:``,hash:e},{replace:!0})},K=e=>u?n({show:e}):n(e===`all`?{}:{show:e},{replace:!0}),fe=e=>e.flatMap(e=>e.sections).map(e=>l.spaceSections.find(t=>t.id===e.id)).filter(e=>e!==void 0).map(e=>(0,Q.jsx)(J,{id:e.id,children:(0,Q.jsx)(X,{title:e.label(),hint:e.hint?.(),plain:!0,children:(0,Q.jsx)(Nt,{of:e,children:(0,Q.jsx)(e.component,{})})})},e.serial)),me=u?void 0:ne,he=(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Kt,{title:M,open:O===1?T??null:null,onBack:_===`results`?void 0:()=>u?i(`/space`):g(y??null),root:{icon:zt,label:q(`nav.project`),backLabel:q(`nav.wizards`),onBack:()=>i(`/`)}}),(0,Q.jsx)(`div`,{className:r(Ut(ee)),children:O===0?(0,Q.jsx)(Jt,{entries:C,current:u?void 0:T,onPick:()=>g(null)}):(0,Q.jsx)(`div`,{ref:f})},O)]});return(0,Q.jsx)(qt.Provider,{value:j,children:(0,Q.jsx)(`div`,{className:`animate-rise`,children:(0,Q.jsxs)(`div`,{className:r(`grid gap-6`,_!==`results`&&`md:grid-cols-[10.5rem_minmax(0,1fr)] md:gap-5 lg:grid-cols-[15rem_minmax(0,1fr)] lg:gap-10`),children:[_===`results`?null:(0,Q.jsx)(`aside`,{className:r(`min-w-0 md:sticky md:top-6 md:self-start md:overflow-y-auto md:overscroll-contain`,u&&D===2&&`hidden`,u&&A===`back`&&Ut(`back`)),style:!u&&ue?{maxHeight:ue-48,paddingBottom:`var(--assistant-dock, 0px)`}:void 0,children:he}),y?(0,Q.jsxs)(`div`,{className:r(`min-w-0`,u&&D<2&&`hidden`,u&&A===`deeper`&&Ut(`deeper`)),children:[u&&_!==`results`?(0,Q.jsx)(`div`,{className:`mb-3`,children:(0,Q.jsx)(Xt,{label:T?.label??M,onBack:()=>i(`/space/${y}`)})}):null,_===`data`?(0,Q.jsxs)(Yt,{children:[(0,Q.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:(0,Q.jsx)(Ht,{icon:Ct,label:q(`data.all`),selected:!u&&!B,onPick:()=>K(`all`)})}),U.data?nt(U.data).map(e=>(0,Q.jsx)(Gt,{label:e.label,children:e.items.map(e=>(0,Q.jsx)(Ht,{icon:Ue[e.kind],label:e.title,selected:!u&&e.key===B,onPick:()=>K(e.key)},e.key))},e.key)):null,(0,Q.jsx)(Qr,{groups:F,current:me,onPick:de})]}):_===`knowledge`?(0,Q.jsxs)(Yt,{children:[(0,Q.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:(0,Q.jsx)(Ht,{icon:Ct,label:q(`know.all`),selected:!(u||B),onPick:()=>K(`all`)})}),W.data?.categories.length?(0,Q.jsx)(Gt,{label:q(`know.categories`),children:W.data.categories.map(e=>(0,Q.jsx)(Ht,{icon:Ye[e.type],label:e.name,badge:(0,Q.jsx)(`span`,{className:`text-[0.75rem] text-ink-3 tabular-nums`,children:e.proposed?`·`:e.count}),selected:!u&&(B===`c:${e.id}`||G.data?.category.id===e.id),onPick:()=>K(`c:${e.id}`)},e.id))}):null,(0,Q.jsx)(Qr,{groups:F,current:u?void 0:V?.id,onPick:e=>K(`s:${e}`)})]}):(0,Q.jsx)(Yt,{children:(0,Q.jsx)(Qr,{groups:P,current:me,onPick:de})}),s&&(_===`info`||_===`knowledge`)?(0,Q.jsxs)(br,{project:s,group:_,top:!B||!!V,children:[_===`knowledge`?H?H.startsWith(`p:`)?(0,Q.jsx)(Ze,{pageId:H.slice(2),onGone:()=>K(`all`),onOpen:K},H):H.startsWith(`t:`)?(0,Q.jsx)(Xe,{tableId:H.slice(2),onGone:()=>K(`all`)},H):(0,Q.jsx)(kn,{projectId:s.id,fileId:H.slice(2),readOnly:s.readOnly,onGone:()=>K(`all`)},H):W.data?V?(0,Q.jsx)(X,{title:V.label(),hint:V.hint?.(),plain:!0,children:(0,Q.jsx)(Nt,{of:V,children:(0,Q.jsx)(V.component,{})})},B):B?.startsWith(`c:`)?ae?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsx)(Je,{projectId:s.id,category:ae,readOnly:s.readOnly,onOpen:K,onGone:()=>K(`all`)}),ae.type===`choice`?null:(0,Q.jsx)(it,{projectId:s.id,category:ae,categories:W.data.categories,onOpen:K})]},B):null:B?.startsWith(`v:`)?G.data?(0,Q.jsx)(He,{value:G.data,readOnly:s.readOnly,children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[G.data.items.length?(0,Q.jsx)(`div`,{className:`flex flex-col rounded-xl bg-card p-1.5 shadow-soft ring-1 ring-border-soft`,children:G.data.items.map(e=>(0,Q.jsx)(Ke,{item:e,categories:W.data.categories.filter(e=>e.id!==G.data?.category.id),onOpen:K},e.key))}):null,G.data.rows.map(e=>(0,Q.jsx)(`button`,{type:`button`,onClick:()=>K(`t:${e.tableId}`),className:`px-1 text-left text-[0.8125rem] text-ink-3 hover:text-ink`,children:q(`know.tocRows`,{n:e.count,table:e.title})},e.tableId))]})},B):null:(0,Q.jsx)(J,{id:`documents`,children:(0,Q.jsx)(et,{projectId:s.id,data:W.data,readOnly:s.readOnly,onOpen:K})}):null:null,_===`info`?fe(F):null]},s.id):null,s&&_===`page`&&x?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-9 pb-20`,children:[(0,Q.jsx)(Ur,{project:s},s.id),fe(F)]}):null,s&&v?(0,Q.jsx)(Nt,{of:v,children:(0,Q.jsx)(wt,{part:v.id,children:(0,Q.jsx)(v.component,{})},s.id)}):null,s&&_===`data`?(0,Q.jsx)(`div`,{className:`flex flex-col gap-9 pb-20`,children:B?.startsWith(`t:`)?(0,Q.jsx)(Xe,{tableId:B.slice(2),onGone:()=>K(`all`)},B):B?.startsWith(`p:`)?(0,Q.jsx)(Ze,{pageId:B.slice(2),onGone:()=>K(`all`)},B):(0,Q.jsxs)(Q.Fragment,{children:[U.data?(0,Q.jsx)($e,{projectId:s.id,data:U.data,readOnly:s.readOnly,onOpen:K}):null,fe(F)]})}):null,s&&_===`results`?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-9 pb-20`,children:[R.data?(0,Q.jsx)(Jr,{data:R.data,wizardId:I,onWizard:e=>K(e??`all`),filter:L,onFilter:ie}):null,R.isError?(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:R.error.message}):null,fe(F)]}):null,s||c?null:(0,Q.jsx)(re,{children:q(`settings.noProject`)})]}):null]})})})}export{$r as ProjectPage};
|