@engenty/wizards-runtime 0.13.0 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/apps/runtime/dist/agents/architect.js +8 -7
- package/apps/runtime/dist/agents/goose-connections.js +82 -0
- package/apps/runtime/dist/agents/space-agent.js +9 -2
- package/apps/runtime/dist/agents/studio-assistant.js +101 -67
- package/apps/runtime/dist/agents/website.js +1 -1
- package/apps/runtime/dist/app.js +17 -1
- package/apps/runtime/dist/assistant/knows.js +6 -5
- package/apps/runtime/dist/authoring/guide.js +25 -5
- package/apps/runtime/dist/broker/account.js +166 -0
- package/apps/runtime/dist/broker/call.js +417 -0
- package/apps/runtime/dist/broker/caller.js +10 -0
- package/apps/runtime/dist/broker/grant.js +152 -0
- package/apps/runtime/dist/broker/host.js +51 -0
- package/apps/runtime/dist/broker/index.js +8 -0
- package/apps/runtime/dist/broker/kept.js +31 -0
- package/apps/runtime/dist/broker/log.js +240 -0
- package/apps/runtime/dist/broker/registry.js +9 -0
- package/apps/runtime/dist/broker/rwx.js +367 -0
- package/apps/runtime/dist/broker/send.js +189 -0
- package/apps/runtime/dist/connectors/builtin.js +1 -1
- package/apps/runtime/dist/connectors/external.js +38 -37
- package/apps/runtime/dist/connectors/index.js +30 -91
- package/apps/runtime/dist/connectors/mail.js +0 -8
- package/apps/runtime/dist/connectors/person-sign-ins.js +73 -0
- package/apps/runtime/dist/connectors/plugin-connections.js +65 -92
- package/apps/runtime/dist/connectors/smtp.js +1 -1
- package/apps/runtime/dist/connectors/space-connections.js +436 -0
- package/apps/runtime/dist/db/adopt.js +3 -3
- package/apps/runtime/dist/db/client.js +9 -0
- package/apps/runtime/dist/db/live-triggers.js +65 -23
- package/apps/runtime/dist/db/migrations/tenant/0027_work_chats.sql +52 -0
- package/apps/runtime/dist/db/migrations/tenant/0028_chat_approvals.sql +17 -0
- package/apps/runtime/dist/db/migrations/tenant/0029_work_chats_live.sql +49 -0
- package/apps/runtime/dist/db/migrations/tenant/0031_space.sql +624 -0
- package/apps/runtime/dist/db/migrations/tenant/0032_rwx_rule.sql +18 -0
- package/apps/runtime/dist/db/migrations/tenant/0033_broker_log.sql +23 -0
- package/apps/runtime/dist/db/migrations/tenant/0034_space_connection.sql +35 -0
- package/apps/runtime/dist/db/migrations/tenant/0035_run_grant.sql +1 -0
- package/apps/runtime/dist/db/migrations/tenant/0036_approval_held_for.sql +1 -0
- package/apps/runtime/dist/db/migrations/tenant/0037_ways_out.sql +5 -0
- package/apps/runtime/dist/db/migrations/tenant/0038_heard.sql +11 -0
- package/apps/runtime/dist/db/migrations/tenant/0039_members_studio.sql +1 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/0027_snapshot.json +383 -155
- package/apps/runtime/dist/db/migrations/tenant/meta/0028_snapshot.json +4468 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/0029_snapshot.json +4475 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/0030_snapshot.json +4629 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/0031_snapshot.json +4629 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/0032_snapshot.json +4757 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/0033_snapshot.json +5039 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/0034_snapshot.json +5022 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/0035_snapshot.json +5029 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/0036_snapshot.json +5037 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/0037_snapshot.json +5076 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/0038_snapshot.json +5145 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/0039_snapshot.json +5153 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/_journal.json +86 -2
- package/apps/runtime/dist/db/schema.js +295 -72
- package/apps/runtime/dist/docs/dev/architecture.md +215 -0
- package/apps/runtime/dist/docs/dev/broker.md +298 -0
- package/apps/runtime/dist/docs/dev/index.md +5 -1
- package/apps/runtime/dist/docs/dev/integration/index.md +2 -0
- package/apps/runtime/dist/docs/dev/meta.json +3 -0
- package/apps/runtime/dist/docs/dev/plugins/connections.md +8 -5
- package/apps/runtime/dist/docs/dev/plugins/events.md +1 -1
- package/apps/runtime/dist/docs/dev/plugins/examples.md +1 -0
- package/apps/runtime/dist/docs/dev/plugins/index.md +2 -2
- package/apps/runtime/dist/docs/dev/plugins/reference.md +3 -2
- package/apps/runtime/dist/docs/dev/plugins/space.md +16 -6
- package/apps/runtime/dist/docs/dev/plugins/studio.md +2 -2
- package/apps/runtime/dist/docs/dev/plugins/tools.md +0 -1
- package/apps/runtime/dist/docs/dev/skills.md +16 -9
- package/apps/runtime/dist/docs/dev/wizard-format/agent-steps.md +40 -5
- package/apps/runtime/dist/docs/dev/wizard-format/lists-and-connections.md +17 -2
- package/apps/runtime/dist/docs/dev/wizard-format/templates.md +2 -0
- package/apps/runtime/dist/docs/dev/wizard-format/views-and-widgets.md +22 -2
- package/apps/runtime/dist/docs/user-guide/capabilities.md +132 -0
- package/apps/runtime/dist/docs/user-guide/cloud-sync.md +2 -0
- package/apps/runtime/dist/docs/user-guide/command-line.md +1 -0
- package/apps/runtime/dist/docs/user-guide/connectors.md +63 -7
- package/apps/runtime/dist/docs/user-guide/index.md +10 -1
- package/apps/runtime/dist/docs/user-guide/meta.json +6 -1
- package/apps/runtime/dist/docs/user-guide/protocol.md +80 -0
- package/apps/runtime/dist/docs/user-guide/skills.md +8 -4
- package/apps/runtime/dist/docs/user-guide/space.md +5 -4
- package/apps/runtime/dist/docs/user-guide/together.md +16 -2
- package/apps/runtime/dist/docs/user-guide/troubleshooting.md +2 -2
- package/apps/runtime/dist/docs/user-guide/work-mode.md +128 -0
- package/apps/runtime/dist/engenty/connections-external/build-connector.js +2 -5
- package/apps/runtime/dist/engenty/connections-external/importer/classify.js +72 -0
- package/apps/runtime/dist/engenty/connections-google/connectors/gmail.js +1 -1
- package/apps/runtime/dist/engenty/connections-microsoft/outlook.js +3 -2
- package/apps/runtime/dist/engenty/connections-sdk/types.js +2 -0
- package/apps/runtime/dist/engenty/connections-slack/connector.js +2 -1
- package/apps/runtime/dist/engine/resources.js +43 -12
- package/apps/runtime/dist/engine/runner.js +75 -23
- package/apps/runtime/dist/engine/steps.js +30 -12
- package/apps/runtime/dist/engine/template.js +18 -1
- package/apps/runtime/dist/env.js +9 -4
- package/apps/runtime/dist/index.js +18 -2
- package/apps/runtime/dist/live/feed.js +2 -2
- package/apps/runtime/dist/live/origin.js +2 -2
- package/apps/runtime/dist/live/views.js +51 -26
- package/apps/runtime/dist/manage.js +7 -0
- package/apps/runtime/dist/mcp/flow-app.js +1 -1
- package/apps/runtime/dist/mcp/tools.js +75 -34
- package/apps/runtime/dist/models.js +1 -1
- package/apps/runtime/dist/motion-graphics/project.js +8 -8
- package/apps/runtime/dist/motion-graphics/tools.js +1 -1
- package/apps/runtime/dist/plugins/events.js +2 -2
- package/apps/runtime/dist/plugins/jobs.js +4 -1
- package/apps/runtime/dist/plugins/loader.js +2 -2
- package/apps/runtime/dist/prompts/architect.md +3 -3
- package/apps/runtime/dist/prompts/authoring.md +46 -12
- package/apps/runtime/dist/prompts/goose.md +7 -7
- package/apps/runtime/dist/prompts/mcp.md +6 -6
- package/apps/runtime/dist/prompts/services.md +4 -4
- package/apps/runtime/dist/prompts/step.md +2 -2
- package/apps/runtime/dist/prompts/tools.md +39 -10
- package/apps/runtime/dist/routes/api.js +31 -20
- package/apps/runtime/dist/routes/broker.js +316 -0
- package/apps/runtime/dist/routes/connections.js +71 -0
- package/apps/runtime/dist/routes/delivery.js +25 -0
- package/apps/runtime/dist/routes/discover.js +17 -0
- package/apps/runtime/dist/routes/live.js +11 -1
- package/apps/runtime/dist/routes/person.js +4 -1
- package/apps/runtime/dist/routes/plugins.js +3 -1
- package/apps/runtime/dist/routes/rules.js +26 -0
- package/apps/runtime/dist/routes/runs.js +54 -33
- package/apps/runtime/dist/routes/skills.js +6 -6
- package/apps/runtime/dist/routes/studio.js +153 -144
- package/apps/runtime/dist/routes/work.js +199 -0
- package/apps/runtime/dist/sandbox/index.js +27 -0
- package/apps/runtime/dist/services/access.js +38 -17
- package/apps/runtime/dist/services/api.js +38 -13
- package/apps/runtime/dist/services/architect.js +3 -3
- package/apps/runtime/dist/services/assistant-chats.js +9 -1
- package/apps/runtime/dist/services/brand.js +12 -12
- package/apps/runtime/dist/services/broker-bell.js +69 -0
- package/apps/runtime/dist/services/broker-notify.js +127 -0
- package/apps/runtime/dist/services/client-steps.js +79 -0
- package/apps/runtime/dist/services/cloud.js +42 -42
- package/apps/runtime/dist/services/command-risk.js +51 -0
- package/apps/runtime/dist/services/discover.js +85 -0
- package/apps/runtime/dist/services/knowledge-model.js +13 -13
- package/apps/runtime/dist/services/knowledge.js +117 -80
- package/apps/runtime/dist/services/manage-reports.js +74 -7
- package/apps/runtime/dist/services/members-studio.js +165 -0
- package/apps/runtime/dist/services/onboarding.js +22 -22
- package/apps/runtime/dist/services/package-file.js +1 -1
- package/apps/runtime/dist/services/package.js +22 -22
- package/apps/runtime/dist/services/pages.js +7 -7
- package/apps/runtime/dist/services/runs.js +4 -3
- package/apps/runtime/dist/services/seen.js +55 -0
- package/apps/runtime/dist/services/shares.js +23 -13
- package/apps/runtime/dist/services/site.js +23 -23
- package/apps/runtime/dist/services/skills-registry.js +15 -15
- package/apps/runtime/dist/services/skills.js +44 -44
- package/apps/runtime/dist/services/space-categories.js +35 -35
- package/apps/runtime/dist/services/space-data.js +130 -111
- package/apps/runtime/dist/services/{project-files.js → space-files.js} +84 -75
- package/apps/runtime/dist/services/{project-index.js → space-index.js} +116 -73
- package/apps/runtime/dist/services/space-origin.js +19 -11
- package/apps/runtime/dist/services/spaces.js +478 -612
- package/apps/runtime/dist/services/synced-spaces.js +668 -0
- package/apps/runtime/dist/services/themes.js +15 -15
- package/apps/runtime/dist/services/widgets.js +6 -6
- package/apps/runtime/dist/services/wizards.js +112 -38
- package/apps/runtime/dist/services/work-ai.js +257 -0
- package/apps/runtime/dist/services/work-approvals.js +104 -0
- package/apps/runtime/dist/services/work-chats.js +908 -0
- package/apps/runtime/dist/services/work-connections.js +90 -0
- package/apps/runtime/dist/services/work-files.js +85 -0
- package/apps/runtime/dist/services/work-mastra.js +73 -0
- package/apps/runtime/dist/services/work-sandbox.js +42 -0
- package/apps/runtime/dist/sharing/files.js +14 -4
- package/apps/runtime/dist/sharing/index.js +40 -39
- package/apps/runtime/dist/sharing/jobs.js +67 -17
- package/apps/runtime/dist/sharing/targets/connector.js +10 -6
- package/apps/runtime/dist/sharing/targets/email.js +10 -8
- package/apps/runtime/dist/sharing/targets/slack.js +10 -8
- package/apps/runtime/dist/sharing/targets/storage.js +6 -4
- package/apps/runtime/dist/store/index.js +14 -3
- package/apps/runtime/dist/store/shared-lists.js +4 -2
- package/apps/runtime/dist/sync/apply.js +2 -2
- package/apps/runtime/dist/sync/client.js +113 -113
- package/apps/runtime/dist/sync/hub.js +41 -41
- package/apps/runtime/dist/sync/log.js +12 -12
- package/apps/runtime/dist/sync/records.js +118 -120
- package/apps/runtime/dist/texts.js +38 -2
- package/apps/runtime/dist/tools/connections.js +112 -0
- package/apps/runtime/dist/tools/connector.js +157 -67
- package/apps/runtime/dist/tools/index.js +28 -13
- package/apps/runtime/dist/tools/mail.js +40 -11
- package/apps/runtime/dist/tools/pages.js +11 -5
- package/apps/runtime/dist/tools/plugin.js +43 -7
- package/apps/runtime/dist/tools/skills.js +1 -1
- package/apps/runtime/dist/tools/{project.js → space.js} +30 -25
- package/apps/runtime/dist/tools/store.js +3 -2
- package/apps/runtime/dist/widgets/step.js +10 -10
- package/apps/web/dist/assets/AboutDialog-DgfeipUc.js +1 -0
- package/apps/web/dist/assets/CapabilitiesPage-BoYJvgIu.js +2 -0
- package/apps/web/dist/assets/{ChangelogDialog-SwyId00t.js → ChangelogDialog-Duab4zTO.js} +1 -1
- package/apps/web/dist/assets/{CodeEditor-BwZsk5Al.js → CodeEditor-nxoOt8ge.js} +1 -1
- package/apps/web/dist/assets/EditorPage-ZrgGpYMC.js +3 -0
- package/apps/web/dist/assets/{FlowPreview-DtSpjVTl.js → FlowPreview-aMfwcPul.js} +1 -1
- package/apps/web/dist/assets/LangSwitch-DpD0inR4.js +1 -0
- package/apps/web/dist/assets/Marketplace-CpzD9pNQ.js +2 -0
- package/apps/web/dist/assets/NewWizardChannels-IB18afWN.js +1 -0
- package/apps/web/dist/assets/NewWizardPage-rYbcmPGG.js +7 -0
- package/apps/web/dist/assets/OnboardingPage-ztHT01ah.js +1 -0
- package/apps/web/dist/assets/PreviewPane-DviWTLfi.js +9 -0
- package/apps/web/dist/assets/PublicRunner-C2geZhhM.js +1 -0
- package/apps/web/dist/assets/ReadOnly-kSb_Kbdm.js +1 -0
- package/apps/web/dist/assets/SettingsPage-DM2h8N0J.js +2 -0
- package/apps/web/dist/assets/SetupPage-Wfyz6xH4.js +1 -0
- package/apps/web/dist/assets/SharePage-CyWQorWB.js +1 -0
- package/apps/web/dist/assets/SkillEditor-CqQMg2MC.js +1 -0
- package/apps/web/dist/assets/Skills-CnhpgoOA.js +9 -0
- package/apps/web/dist/assets/SpacePage-q4Bk3N7k.js +2 -0
- package/apps/web/dist/assets/UpdateCheck-C2CE6CC3.js +2 -0
- package/apps/web/dist/assets/changelog-B6hN1Cp7.js +1 -0
- package/apps/web/dist/assets/circle-alert-C8Ma-bPY.js +1 -0
- package/apps/web/dist/assets/circle-check-Bu9Z3mlJ.js +1 -0
- package/apps/web/dist/assets/code-editor-CfTGqOpp.js +2 -0
- package/apps/web/dist/assets/{code-xml-TwKzzMtA.js → code-xml-B4kLFZSj.js} +1 -1
- package/apps/web/dist/assets/connection-sign-in-CIiv0t2p.js +1 -0
- package/apps/web/dist/assets/esm-Xwn4GtqG.js +7 -0
- package/apps/web/dist/assets/{eye-Brd-xPUJ.js → eye-BpoKpIdt.js} +1 -1
- package/apps/web/dist/assets/host-BrP-ENHg.css +1 -0
- package/apps/web/dist/assets/host-DJ7-p0Sc.js +118 -0
- package/apps/web/dist/assets/i18n-BJ7Ld6O6.js +55 -0
- package/apps/web/dist/assets/index-D18DvnxX.css +1 -0
- package/apps/web/dist/assets/index-D2akynS-.js +10 -0
- package/apps/web/dist/assets/logo-BpnjXTRy.js +1 -0
- package/apps/web/dist/assets/oss-credits-IdX5bc71.js +1 -0
- package/apps/web/dist/assets/{phone-DhkHteoJ.js → phone-Ctvf-Am-.js} +1 -1
- package/apps/web/dist/assets/read-aloud-Da_RSm2S.js +1 -0
- package/apps/web/dist/assets/{runners-G-XYaDgR.js → runners-CyIvJIHr.js} +1 -1
- package/apps/web/dist/assets/scroll-text-ChrjRu9Y.js +1 -0
- package/apps/web/dist/assets/session-SXPtTWRK.js +2 -0
- package/apps/web/dist/assets/theme-CbTcTFWy.js +11 -0
- package/apps/web/dist/assets/ui-Uqnx1UpK.js +82 -0
- package/apps/web/dist/assets/{upload-BYZTwJTD.js → upload-BchUnQGV.js} +1 -1
- package/apps/web/dist/assets/{useMutation-D0QP_k2-.js → useMutation-DEkZhp5c.js} +1 -1
- package/apps/web/dist/assets/{volume-2-CVHoxdGM.js → volume-2-CU_oy81Z.js} +1 -1
- package/apps/web/dist/assets/with-selector-CoMyWBAX.js +1 -0
- package/apps/web/dist/index.html +17 -10
- package/apps/web/dist/mcp/flow.html +119 -64
- package/node_modules/@engenty/wizards/dist/plugin/index.d.ts +20 -10
- package/node_modules/@engenty/wizards-shared/dist/assistant.d.ts +6 -1
- package/node_modules/@engenty/wizards-shared/dist/assistant.js +6 -1
- package/node_modules/@engenty/wizards-shared/dist/connectors.d.ts +236 -2
- package/node_modules/@engenty/wizards-shared/dist/connectors.js +52 -2
- package/node_modules/@engenty/wizards-shared/dist/definition.d.ts +150 -8
- package/node_modules/@engenty/wizards-shared/dist/definition.js +46 -11
- package/node_modules/@engenty/wizards-shared/dist/discover.d.ts +21 -0
- package/node_modules/@engenty/wizards-shared/dist/discover.js +1 -0
- package/node_modules/@engenty/wizards-shared/dist/feature-flags.d.ts +26 -2
- package/node_modules/@engenty/wizards-shared/dist/feature-flags.js +26 -2
- package/node_modules/@engenty/wizards-shared/dist/fit.js +1 -1
- package/node_modules/@engenty/wizards-shared/dist/json-schema.d.ts +1 -1
- package/node_modules/@engenty/wizards-shared/dist/json-schema.js +1 -1
- package/node_modules/@engenty/wizards-shared/dist/live.d.ts +2 -2
- package/node_modules/@engenty/wizards-shared/dist/live.js +1 -1
- package/node_modules/@engenty/wizards-shared/dist/marketplace.js +3 -1
- package/node_modules/@engenty/wizards-shared/dist/run.d.ts +54 -6
- package/node_modules/@engenty/wizards-shared/dist/run.js +85 -0
- package/node_modules/@engenty/wizards-shared/dist/runner-texts.d.ts +15 -1
- package/node_modules/@engenty/wizards-shared/dist/runner-texts.js +14 -0
- package/node_modules/@engenty/wizards-shared/dist/rwx.d.ts +42 -0
- package/node_modules/@engenty/wizards-shared/dist/rwx.js +29 -0
- package/node_modules/@engenty/wizards-shared/dist/skills.d.ts +1 -1
- package/node_modules/@engenty/wizards-shared/dist/space-data.d.ts +2 -2
- package/node_modules/@engenty/wizards-shared/dist/{projects.d.ts → spaces.d.ts} +39 -15
- package/node_modules/@engenty/wizards-shared/dist/{projects.js → spaces.js} +16 -9
- package/node_modules/@engenty/wizards-shared/dist/store.d.ts +7 -2
- package/node_modules/@engenty/wizards-shared/dist/surface.d.ts +35 -4
- package/node_modules/@engenty/wizards-shared/dist/surface.js +121 -3
- package/node_modules/@engenty/wizards-shared/dist/sync.d.ts +1 -1
- package/node_modules/@engenty/wizards-shared/dist/theme-look.js +1 -1
- package/node_modules/@engenty/wizards-shared/dist/wizard-package.d.ts +2 -2
- package/node_modules/@engenty/wizards-shared/dist/wizard-package.js +3 -3
- package/package.json +4 -1
- package/plugin/.claude-plugin/plugin.json +1 -1
- package/plugin/plugin.json +1 -1
- package/plugin/skills/build-wizard/SKILL.md +1 -1
- package/apps/runtime/dist/services/projects.js +0 -473
- package/apps/web/dist/assets/AboutDialog-B-JxkELB.js +0 -1
- package/apps/web/dist/assets/EditorPage-DQ_2FOzI.js +0 -3
- package/apps/web/dist/assets/Marketplace-DoH4YO3D.js +0 -2
- package/apps/web/dist/assets/NewWizardChannels-Tgoexgj4.js +0 -1
- package/apps/web/dist/assets/NewWizardPage-B24AF482.js +0 -7
- package/apps/web/dist/assets/OnboardingPage-BEvq4slJ.js +0 -1
- package/apps/web/dist/assets/PreviewPane-B_v7Y8R7.js +0 -10
- package/apps/web/dist/assets/ProjectPage-ClRuhFJo.js +0 -10
- package/apps/web/dist/assets/PublicRunner-MicrpVsv.js +0 -1
- package/apps/web/dist/assets/ReadOnly-BXjv-MSv.js +0 -1
- package/apps/web/dist/assets/SettingsPage-DY8O1r43.js +0 -2
- package/apps/web/dist/assets/SetupPage-BOVkVpMu.js +0 -1
- package/apps/web/dist/assets/SharePage-DXGzJSnR.js +0 -1
- package/apps/web/dist/assets/SkillEditor-BzzTDeaU.js +0 -1
- package/apps/web/dist/assets/changelog-BLdS-0Bj.js +0 -1
- package/apps/web/dist/assets/esm-BdxDT9Km.js +0 -7
- package/apps/web/dist/assets/i18n-8-Sw11tB.js +0 -55
- package/apps/web/dist/assets/index-OsdQFHmh.js +0 -49
- package/apps/web/dist/assets/index-QPipX5Fi.css +0 -1
- package/apps/web/dist/assets/lock-C0uxcOlq.js +0 -1
- package/apps/web/dist/assets/logo-CGNoptDg.js +0 -1
- package/apps/web/dist/assets/oss-credits-DpRWUPjD.js +0 -1
- package/apps/web/dist/assets/session-BWI-KENJ.js +0 -2
- package/apps/web/dist/assets/theme-D7krsx0_.js +0 -11
- package/apps/web/dist/assets/ui-DSXG3f49.js +0 -83
- /package/apps/runtime/dist/db/migrations/tenant/{0027_space_skill.sql → 0030_space_skill.sql} +0 -0
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/SkillEditor-BzzTDeaU.js","assets/rolldown-runtime-hePW80VL.js","assets/jsx-runtime-BNakU3Ej.js","assets/ui-DSXG3f49.js","assets/preload-helper-DpV6A1kQ.js","assets/i18n-8-Sw11tB.js","assets/useMutation-D0QP_k2-.js","assets/PreviewPane-B_v7Y8R7.js","assets/Marketplace-DoH4YO3D.js","assets/volume-2-CVHoxdGM.js","assets/eye-Brd-xPUJ.js","assets/session-BWI-KENJ.js","assets/engenty-CNjaZCVM.js","assets/logo-CGNoptDg.js","assets/theme-D7krsx0_.js","assets/react-dom-hf6EcyAr.js","assets/phone-DhkHteoJ.js","assets/index-OsdQFHmh.js","assets/media-Cej-H610.js","assets/index-QPipX5Fi.css","assets/theme-CbR9-ayl.css","assets/upload-BYZTwJTD.js","assets/runners-G-XYaDgR.js","assets/code-xml-TwKzzMtA.js","assets/dist-EBVTpvRr.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{$n as r,$t as i,A as a,An as o,B as s,C as c,D as l,E as u,G as d,Gt as f,H as p,I as m,Jt as h,Kt as g,L as _,Ln as v,M as y,Mn as b,N as x,Nn as S,Nr as C,O as w,On as T,P as E,Pn as D,R as O,S as k,T as ee,U as A,Un as te,V as ne,W as j,Wn as M,Wt as N,Xt as P,Yn as re,Yt as F,Zn as I,Zt as L,_ as ie,an as R,ar as ae,b as z,bn as B,cr as V,d as oe,en as H,f as se,g as U,gn as W,h as G,in as ce,ir as le,j as ue,jn as de,k as fe,kn as pe,m as me,nn as he,on as K,or as ge,p as _e,pn as q,qn as ve,qt as J,rn as ye,sr as be,tn as xe,tr as Se,un as Ce,v as we,vn as Te,w as Ee,wn as De,x as Oe,xn as ke,y as Y,yt as Ae,z as je,zn as Me}from"./ui-DSXG3f49.js";import{S as Ne,_ as Pe,b as Fe,v as Ie,x as Le}from"./Marketplace-DoH4YO3D.js";import{t as Re}from"./useMutation-D0QP_k2-.js";import{t as ze}from"./preload-helper-DpV6A1kQ.js";import{I as Be,L as Ve,P as He,R as Ue,S as We,_ as Ge,a as Ke,b as qe,c as Je,d as Ye,f as Xe,g as Ze,h as Qe,i as $e,l as et,m as tt,o as nt,p as rt,r as it,s as at,t as ot,u as st,v as ct,x as lt,y as ut}from"./PreviewPane-B_v7Y8R7.js";import{t as dt}from"./eye-Brd-xPUJ.js";import{b as ft,f as pt}from"./theme-D7krsx0_.js";import{b as mt,d as ht,f as gt,h as _t,u as vt}from"./session-BWI-KENJ.js";import{t as yt}from"./phone-DhkHteoJ.js";import{n as bt,r as xt,t as St}from"./ReadOnly-BXjv-MSv.js";import{t as Ct}from"./upload-BYZTwJTD.js";import{n as wt,pt as Tt,s as X}from"./i18n-8-Sw11tB.js";import{$ as Et,An as Dt,Gt as Ot,H as kt,J as At,K as jt,Q as Mt,Sn as Nt,V as Pt,X as Ft,Xt as It,Y as Lt,Z as Rt,_ as zt,_n as Bt,c as Vt,d as Ht,dn as Ut,f as Wt,gn as Gt,h as Kt,m as qt,on as Jt,p as Yt,q as Xt,rt as Zt,s as Qt,tt as $t,u as en,un as tn,v as nn,vn as rn}from"./index-OsdQFHmh.js";var an={name:`badge-check`,size:24,node:[[`path`,{d:`M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z`,key:`3c2336`}],[`path`,{d:`m16 9-5.5 5.5L8 12`,key:`xofnsj`}]],aliases:[`verified`]};an.node;var on=I(an),sn={name:`blend`,size:24,node:[[`circle`,{cx:`15`,cy:`9`,r:`7`,key:`1i12rt`}],[`circle`,{cx:`9`,cy:`15`,r:`7`,key:`19bs8k`}]]};sn.node;var cn=I(sn),ln={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`}]]};ln.node;var un=I(ln),dn={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`}]]};dn.node;var fn=I(dn),pn={name:`circle-off`,size:24,node:[[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M8.35 2.69A10 10 0 0 1 21.3 15.65`,key:`1pfsoa`}],[`path`,{d:`M19.08 19.08A10 10 0 1 1 4.92 4.92`,key:`1ablyi`}]]};pn.node;var mn=I(pn),hn={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`}]]};hn.node;var gn=I(hn),_n={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`]};_n.node;var vn=I(_n),yn={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`}]]};yn.node;var bn=I(yn),xn={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`}]]};xn.node;var Sn=I(xn),Cn={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`}]]};Cn.node;var wn=I(Cn),Tn={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`}]]};Tn.node;var En=I(Tn),Z=e(t(),1),Q=e(n(),1),Dn={backgroundImage:`repeating-conic-gradient(#c9c9c9 0% 25%, #dedede 0% 50%)`,backgroundSize:`16px 16px`};function On({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:X(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 kn(e,t){confirm(X(`project.removeConfirm`,{name:e.name}))&&t.remove(e.id)}function An({projectId:e,file:t,small:n}){let r=je(e,t.id);if(t.mime.startsWith(`image/`))return(0,Q.jsx)(`img`,{src:r,alt:``,loading:`lazy`,className:K(`size-full`,t.kind===`logo`?`object-contain p-3`:`object-cover`)});if(t.mime.startsWith(`video/`))return(0,Q.jsx)(`video`,{src:`${r}#t=0.1`,preload:`metadata`,controls:!n,className:`size-full object-cover`});if(t.mime.startsWith(`font/`))return(0,Q.jsx)(jn,{src:r,small:n});let i=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)(wn,{className:i}):t.mime===`application/pdf`?(0,Q.jsx)(S,{className:i}):t.mime===`application/json`?(0,Q.jsx)(q,{className:i}):t.mime.startsWith(`model/`)?(0,Q.jsx)(un,{className:i}):(0,Q.jsx)(b,{className:i}),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 jn({src:e,small:t}){let[n,r]=(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),r(t)}).catch(()=>r(null))},[e]),(0,Q.jsx)(`div`,{className:K(`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 Mn=`application/x-wizards-logo`;function Nn({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):kn(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(Mn,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)(g,{tone:`ember`,children:X(`project.logoMain`)})}):null,(0,Q.jsxs)(`div`,{className:`relative h-28 overflow-hidden rounded-md bg-paper-2`,style:t===`logo`?Dn:void 0,children:[s&&n.mime.startsWith(`image/`)?(0,Q.jsx)(`button`,{type:`button`,"aria-label":`${X(`project.preview`)}: ${n.name}`,onClick:()=>s(n),className:`block size-full cursor-zoom-in`,children:(0,Q.jsx)(An,{projectId:e,file:n})}):(0,Q.jsx)(An,{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)(F,{label:X(`project.preview`),onClick:()=>s(n),className:`size-8 bg-card shadow-soft`,children:(0,Q.jsx)(dt,{className:`size-4`})}):null,l&&n.id!==c&&!r.readOnly?(0,Q.jsx)(F,{label:X(`project.logoMakeMain`),onClick:()=>l(n),className:`size-8 bg-card shadow-soft`,children:(0,Q.jsx)(Fe,{className:`size-4`})}):null,u&&!r.readOnly?(0,Q.jsx)(U,{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)(F,{label:X(`project.remove`),onClick:()=>f(n),className:`size-8 bg-card shadow-soft hover:text-rose`,children:(0,Q.jsx)(Ce,{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)(On,{file:n,actions:r})]},n.id)),a&&!r.readOnly?(0,Q.jsxs)(me,{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)(xe,{className:`size-5`}):(0,Q.jsx)(B,{className:`size-5`}),a]}):null]})}function Pn({kind:e,fetchUrl:t,onAdded:n,onClose:r}){let[i,a]=(0,Z.useState)(``),[o,s]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)(null),[u,d]=(0,Z.useState)(null),[f,p]=(0,Z.useState)([]),m=async()=>{s(!0),l(null);try{let a=await t(i.trim());a.file?(n([a.file]),r()):a.candidates?.length?(d(a.candidates),p([a.candidates[0].url])):l(X(e===`logo`?`project.logoNoneFound`:`project.assetNoneFound`))}catch(e){l(e.message)}s(!1)},h=async()=>{s(!0),l(null);let e=[];try{for(let n of f){let r=await t(n);r.file&&e.push(r.file)}}catch(e){l(e.message)}s(!1),e.length&&n(e),e.length===f.length&&r()};return(0,Q.jsx)(J,{open:!0,onClose:r,wide:u?!0:void 0,title:X(u?e===`logo`?`project.logoFound`:`project.assetFound`:e===`logo`?`project.logoFromUrl`:`project.assetFromUrl`),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:X(e===`logo`?`project.logoFoundHint`:`project.assetFoundHint`)}),(0,Q.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(150px,1fr))] gap-3`,children:u.map(t=>{let n=f.includes(t.url);return(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":n,title:t.hint,onClick:()=>p(e=>n?e.filter(e=>e!==t.url):[...e,t.url]),className:K(`relative h-28 overflow-hidden rounded-lg ring-1 transition`,n?`ring-2 ring-ember`:`ring-border-soft hover:ring-ink-4`),style:Dn,children:[(0,Q.jsx)(`img`,{src:t.url,alt:``,className:K(`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)(M,{className:`size-3.5`})}):null]},t.url)})}),c?(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:c}):null,(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Q.jsx)(N,{variant:`ghost`,onClick:()=>d(null),children:X(`run.back`)}),(0,Q.jsx)(N,{busy:o,disabled:!f.length,onClick:()=>void h(),children:f.length>1?X(`project.addMany`,{n:f.length}):X(`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)(L,{children:X(`project.logoUrl`)}),(0,Q.jsx)(P,{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:X(e===`logo`?`project.logoUrlHint`:`project.assetUrlHint`)})]}),c?(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:c}):null,(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Q.jsx)(N,{variant:`ghost`,onClick:r,children:X(`common.cancel`)}),(0,Q.jsx)(N,{type:`submit`,busy:o,disabled:!i.trim(),children:X(`run.next`)})]})]})})}function Fn(e,t,n){return V({queryKey:[`project-file-text`,t.id,t.chars,n],queryFn:()=>d.get(`/api/studio/projects/${e}/files/${t.id}/text?limit=${n}`),enabled:t.status===`ready`,staleTime:6e4})}function In(e){return((e.name.includes(`.`)?e.name.split(`.`).pop():``)||e.mime.split(`/`).pop()||``).toUpperCase().slice(0,5)}var Ln=e=>[In(e),e.pages?X(`project.pages`,{n:e.pages}):null,Tt(e.size)].filter(Boolean).join(` · `),Rn=2e5;function zn({projectId:e,fileId:t,readOnly:n,onGone:r}){let i=C(),a=A(e),o=tt(e),s=ne(e,n),c=a.data?.files.find(e=>e.id===t),l=c?c.mime===`application/pdf`||c.mime.startsWith(`image/`):!1,[u,d]=(0,Z.useState)(null);if(!c)return a.isLoading?(0,Q.jsx)(xe,{className:`mx-auto text-ink-3`}):null;let p=u??(l?`original`:`text`),m=o.data?.items.find(e=>e.key===`f:${c.id}`),h=je(e,c.id),g=(e,t)=>(0,Q.jsx)(`button`,{type:`button`,"aria-pressed":p===e,onClick:()=>d(e),className:K(`rounded-full px-3 py-1 text-[0.8125rem] transition`,p===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:c.name}),(0,Q.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3 max-sm:hidden`,children:Ln(c)}),(0,Q.jsx)(`a`,{href:h,target:`_blank`,rel:`noreferrer`,"aria-label":X(`project.openOriginal`),title:X(`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)(D,{className:`size-4`})}),n?null:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(F,{label:X(`project.reindex`),onClick:async()=>{await s.reindex(c.id),await i.invalidateQueries({queryKey:j.knowledge(e)})},children:(0,Q.jsx)(Te,{className:`size-4`})}),(0,Q.jsx)(F,{label:X(`know.deleteFile`),className:`hover:text-rose`,onClick:async()=>{confirm(X(`data.confirmDelete`,{title:c.name}))&&(await s.remove(c.id),await i.invalidateQueries({queryKey:j.knowledge(e)}),r())},children:(0,Q.jsx)(Ce,{className:`size-4`})})]})]}),(0,Q.jsx)(Xe,{projectId:e,itemKey:`f:${c.id}`,has:m?.categories??[],originLabel:m?.originLabel??null,kept:!1,review:null,file:null,readOnly:n,onReviewed:()=>void 0}),(0,Q.jsx)(`div`,{className:`px-1`,children:(0,Q.jsx)(On,{file:c,actions:s})}),c.status===`failed`?(0,Q.jsx)(`p`,{className:`px-1 text-[0.875rem] text-rose`,children:c.error}):null,(0,Q.jsxs)(f,{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:[l?g(`original`,X(`project.original`)):null,g(`text`,X(`project.readText`))]}),p===`original`?c.mime===`application/pdf`?(0,Q.jsx)(`iframe`,{src:h,title:c.name,className:`h-[70dvh] w-full rounded-b-xl bg-paper-2`}):(0,Q.jsx)(`img`,{src:h,alt:``,className:`mx-auto max-h-[70dvh] object-contain p-4`}):(0,Q.jsx)(Bn,{projectId:e,file:c})]})]})}function Bn({projectId:e,file:t}){let n=Fn(e,t,Rn);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)(xe,{})}):n.data?.text?(0,Q.jsxs)(`div`,{className:`overflow-x-auto p-4 sm:p-5`,children:[(0,Q.jsx)(Ae,{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:X(`project.textCut`,{shown:n.data.text.length.toLocaleString(wt),total:n.data.chars.toLocaleString(wt)})}):null]}):(0,Q.jsx)(`p`,{className:`py-8 text-center text-[0.875rem] text-ink-3`,children:X(`project.noText`)})}var Vn=`image/*,video/*,audio/*,application/pdf,.pdf,.woff2,.woff,.ttf,.otf,.json,.glb,.gltf`,Hn=e=>[(e.name.includes(`.`)?e.name.split(`.`).pop():e.mime.split(`/`).pop())?.toUpperCase().slice(0,5),Tt(e.size)].filter(Boolean).join(` · `);function Un({projectId:e,file:t,actions:n,onClose:r}){let i=je(e,t.id);return(0,Q.jsxs)(J,{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:Hn(t)}),(0,Q.jsx)(`a`,{href:i,target:`_blank`,rel:`noreferrer`,"aria-label":X(`project.openOriginal`),title:X(`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)(D,{className:`size-4`})})]}),t.mime.startsWith(`image/`)?(0,Q.jsx)(`div`,{className:`overflow-hidden rounded-lg`,style:Dn,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)(On,{file:t,actions:n})})]})}function Wn({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":`${X(`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)(An,{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:Hn(t)})]}),(0,Q.jsx)(On,{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)(F,{label:X(`project.preview`),onClick:i,children:(0,Q.jsx)(dt,{className:`size-4`})}),r&&!n.readOnly?(0,Q.jsx)(U,{options:r.options,value:r.current(t),onChange:e=>r.onMove(t,e),className:`size-9`}):null,n.readOnly?null:(0,Q.jsx)(F,{label:X(`project.remove`),onClick:a,className:`hover:text-rose`,children:(0,Q.jsx)(Ce,{className:`size-4`})})]})]})}function Gn({section:e,onSave:t,onRemove:n,onClose:r}){let[i,a]=(0,Z.useState)(e?.title??``);return(0,Q.jsx)(J,{open:!0,onClose:r,title:X(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)(L,{children:X(`project.assetSectionName`)}),(0,Q.jsx)(P,{autoFocus:!0,value:i,maxLength:80,placeholder:X(`project.assetSectionTitle`),onChange:e=>a(e.target.value)})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n?(0,Q.jsx)(N,{variant:`danger`,onClick:n,children:X(`project.sectionRemove`)}):null,(0,Q.jsx)(`span`,{className:`flex-1`}),(0,Q.jsx)(N,{variant:`ghost`,onClick:r,children:X(`common.cancel`)}),(0,Q.jsx)(N,{type:`submit`,disabled:!i.trim(),children:X(e?`settings.save`:`project.add`)})]})]})})}function Kn({projectId:e,data:t,readOnly:n,sections:r,save:i}){let o=ne(e,n),[c,l]=p(`assets`,`cards`),[u,d]=(0,Z.useState)(``),[f,m]=(0,Z.useState)(null),[h,g]=(0,Z.useState)(r),[_,v]=(0,Z.useState)(``),[y,b]=(0,Z.useState)(null),[x,S]=(0,Z.useState)(!1),C=(0,Z.useRef)(null),w=s({assetSections:h},i),T=t.files.filter(e=>e.kind===`asset`),E=new Map(T.map(e=>[e.id,e])),D=new Set(h.flatMap(e=>e.assets)),O=h.find(e=>e.id===_)??null,k=O?O.assets.map(e=>E.get(e)).filter(e=>!!e):T.filter(e=>!D.has(e.id)),ee=T.find(e=>e.id===f),A=u.trim().toLowerCase(),te=A?k.filter(e=>`${e.name} ${e.description}`.toLowerCase().includes(A)):k,j=(e,t)=>g(n=>n.map(n=>{let r=n.assets.filter(t=>t!==e);return{...n,assets:n.id===t?[...r,e]:r}})),M=async e=>{let t=O?.id??null;for(let n of await o.upload(`asset`,e))j(n.id,t)},N=e=>{confirm(X(`project.removeConfirm`,{name:e.name}))&&(o.remove(e.id),j(e.id,null))},P=h.length?{options:[{value:``,label:X(`project.assetsGeneral`)},...h.map(e=>({value:e.id,label:e.title||X(`project.sectionUntitled`)}))],current:e=>h.find(t=>t.assets.includes(e.id))?.id??``,onMove:(e,t)=>j(e.id,t||null)}:void 0,re=[{label:X(`project.assetUpload`),icon:(0,Q.jsx)(Ct,{className:`size-4 shrink-0`}),onPick:()=>C.current?.click()},{label:X(`project.assetFromUrl`),icon:(0,Q.jsx)(bn,{className:`size-4 shrink-0`}),onPick:()=>S(!0)},...h.length<a.logoSections?[{label:X(`project.assetSectionAdd`),icon:(0,Q.jsx)(gn,{className:`size-4 shrink-0`}),onPick:()=>b(`new`)}]:[]],I=h.length||T.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:[h.length?(0,Q.jsx)(ce,{value:_,onChange:e=>{v(e),d(``)},label:X(`project.assets`),options:[{id:``,label:X(`project.assetsGeneral`)},...h.map(e=>({id:e.id,label:e.title||X(`project.sectionUntitled`)}))]}):null,O&&!n?(0,Q.jsx)(F,{label:X(`project.assetSectionRename`),onClick:()=>b(`current`),children:(0,Q.jsx)(ke,{className:`size-4`})}):null]}),k.length?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`w-56 max-w-[45%] shrink`,children:(0,Q.jsx)(we,{value:u,onChange:d,placeholder:X(`project.assetSearch`)})}),(0,Q.jsx)(F,{label:X(c===`list`?`project.viewCards`:`project.viewList`),onClick:l,children:c===`list`?(0,Q.jsx)(Bt,{className:`size-4`}):(0,Q.jsx)(Sn,{className:`size-4`})})]}):null]}):null;return(0,Q.jsxs)(Y,{title:X(`project.assets`),hint:X(`project.assetsHint`),save:w,tabs:I,action:n?null:(0,Q.jsx)(oe,{entries:re}),children:[(0,Q.jsx)(`input`,{ref:C,type:`file`,multiple:!0,accept:Vn,className:`sr-only`,tabIndex:-1,"aria-hidden":!0,onChange:e=>{let t=Array.from(e.target.files??[]);e.target.value=``,t.length&&M(t)}}),te.length?c===`cards`?(0,Q.jsx)(Nn,{projectId:e,kind:`asset`,files:te,actions:o,moveTo:P,onRemove:N,onPreview:e=>m(e.id)}):(0,Q.jsx)(`ul`,{className:`flex flex-col gap-2`,children:te.map(t=>(0,Q.jsx)(Wn,{projectId:e,file:t,actions:o,moveTo:P,onPreview:()=>m(t.id),onRemove:()=>N(t)},t.id))}):k.length?null:n?(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:X(`project.staysLocal`)}):(0,Q.jsxs)(me,{accept:Vn,onFiles:e=>void M(e),className:`h-16 w-full`,children:[o.busy?(0,Q.jsx)(xe,{className:`size-4`}):(0,Q.jsx)(Ct,{className:`size-4`}),X(`project.drop`),` `,(0,Q.jsx)(`span`,{className:`underline`,children:X(`project.assetAdd`)})]}),o.error?(0,Q.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:o.error}):null,ee?(0,Q.jsx)(Un,{projectId:e,file:ee,actions:o,onClose:()=>m(null)}):null,y?(0,Q.jsx)(Gn,{section:y===`current`?O:null,onClose:()=>b(null),onSave:e=>{if(y===`current`&&O)g(t=>t.map(t=>t.id===O.id?{...t,title:e}:t));else{let t=Oe();g(n=>[...n,{id:t,title:e,assets:[]}]),v(t)}},onRemove:y===`current`&&O?()=>{(!O.assets.length||confirm(X(`project.assetSectionRemoveConfirm`,{name:O.title})))&&(g(e=>e.filter(e=>e.id!==O.id)),v(``),b(null))}:void 0}):null,x?(0,Q.jsx)(Pn,{kind:`asset`,onClose:()=>S(!1),fetchUrl:e=>o.fromUrl(`asset`,e),onAdded:e=>{for(let t of e)j(t.id,O?.id??null)}}):null]})}var qn=/^#[0-9a-fA-F]{6}$/;async function Jn(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 Yn={linear:`project.gradientLinear`,radial:`project.gradientRadial`,conic:`project.gradientConic`};function Xn({projectId:e,gradient:t,isNew:n,brand:r,onSave:i,onClose:a}){let[o,s]=(0,Z.useState)(t),[c,u]=(0,Z.useState)(E(t)),[f,p]=(0,Z.useState)(!1),[m,h]=(0,Z.useState)(``),[g,_]=(0,Z.useState)(!1),[v,y]=(0,Z.useState)(null),[b,x]=(0,Z.useState)(!n),S=e=>{s(e),u(E(e)),p(!1)},C=(e,t)=>S({...o,stops:o.stops.map((n,r)=>r===e?{...n,...t}:n)}),w=e=>{let t=[...o.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));S({...o,stops:[...o.stops,{color:e??t[0]?.color??`#888888`,at:n}]})},T=async()=>{_(!0),y(null);try{let{gradient:t}=await d.post(`/api/studio/projects/${e}/gradients/describe`,{text:m.trim(),...b?{gradient:{name:o.name,type:o.type,angle:o.angle,stops:o.stops}}:{}});S({...o,...t,name:o.name.trim()?o.name:t.name}),h(``),x(!0)}catch(e){y(e.message)}_(!1)};return(0,Q.jsx)(J,{open:!0,onClose:a,wide:!0,title:X(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(),m.trim()&&!g&&T()},children:[(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(P,{"data-autofocus":n||void 0,value:m,maxLength:1e3,"aria-label":X(`project.gradientDescribe`),placeholder:X(b?`project.gradientDescribeChange`:`project.gradientDescribeNew`),onChange:e=>h(e.target.value),className:`min-w-0 flex-1`}),(0,Q.jsxs)(N,{type:`submit`,variant:`secondary`,busy:g,disabled:!m.trim(),children:[(0,Q.jsx)(q,{className:`size-4`}),X(b?`project.gradientDescribeApply`:`project.gradientDescribeMake`)]})]}),(0,Q.jsx)(`p`,{className:K(`mt-1.5 text-[0.8125rem]`,v?`text-rose`:`text-ink-3`),children:v??X(`project.gradientDescribeHint`)})]}),(0,Q.jsx)(`div`,{className:`h-40 rounded-lg ring-1 ring-border-soft`,style:{background:E(o)}}),(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)(L,{children:X(`project.gradientName`)}),(0,Q.jsx)(P,{value:o.name,maxLength:80,placeholder:X(`project.gradientNamePlaceholder`),onChange:e=>s({...o,name:e.target.value})})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(L,{children:X(`project.fillUseLabel`)}),(0,Q.jsx)(P,{value:o.description??``,maxLength:400,placeholder:X(`project.gradientUse`),onChange:e=>s({...o,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)(L,{children:X(`project.gradientType`)}),(0,Q.jsx)(`div`,{className:`flex gap-1 rounded-full bg-paper-2 p-0.5 ring-1 ring-border-soft`,children:l.map(e=>(0,Q.jsx)(`button`,{type:`button`,"aria-pressed":o.type===e,onClick:()=>S({...o,type:e}),className:K(`h-9 rounded-full px-4 font-medium text-[0.875rem] transition`,o.type===e?`bg-card text-ink shadow-sm`:`text-ink-3 hover:text-ink-2`),children:X(Yn[e])},e))})]}),o.type===`radial`?null:(0,Q.jsxs)(`div`,{className:`min-w-56`,children:[(0,Q.jsx)(L,{children:X(`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:o.angle,"aria-label":X(`project.gradientAngle`),onChange:e=>S({...o,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(o.angle),`°`]})]})]})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(L,{children:X(`project.gradientStops`)}),(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:o.stops.map((e,t)=>(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsx)(he,{value:qn.test(e.color)?e.color:`#888888`,onChange:e=>C(t,{color:e.target.value})}),(0,Q.jsx)(P,{value:e.color,spellCheck:!1,onChange:e=>{let n=e.target.value.trim();qn.test(n)&&C(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":X(`project.gradientAt`),onChange:e=>C(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)(F,{label:X(`project.remove`),disabled:o.stops.length<=2,onClick:()=>S({...o,stops:o.stops.filter((e,n)=>n!==t)}),className:`hover:text-rose`,children:(0,Q.jsx)(Ce,{className:`size-4`})})]},t))}),(0,Q.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[o.stops.length<12?(0,Q.jsxs)(N,{variant:`secondary`,size:`sm`,onClick:()=>w(),children:[(0,Q.jsx)(B,{className:`size-4`}),` `,X(`project.gradientStopAdd`)]}):null,r.length&&o.stops.length<12?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`ml-2 text-[0.8125rem] text-ink-3`,children:X(`project.gradientFromBrand`)}),r.slice(0,10).map(e=>(0,Q.jsx)(`button`,{type:`button`,title:e.name||e.value,"aria-label":e.name||e.value,onClick:()=>w(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)(L,{children:`CSS`}),(0,Q.jsx)(P,{value:c,spellCheck:!1,onChange:e=>{u(e.target.value);let t=O(e.target.value);p(!t),t&&s({...o,...t})},className:`font-mono text-[0.8125rem]`}),(0,Q.jsx)(`p`,{className:K(`mt-1.5 text-[0.8125rem]`,f?`text-rose`:`text-ink-3`),children:X(f?`project.gradientCssError`:`project.gradientCssHint`)})]}),(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Q.jsx)(N,{variant:`ghost`,onClick:a,children:X(`common.cancel`)}),(0,Q.jsx)(N,{onClick:()=>{i(o),a()},children:X(`settings.save`)})]})]})})}var Zn=`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`,Qn=`size-8 bg-card shadow-soft hover:bg-card`;function $n({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)(G,{value:e,label:X(`project.gradientName`),placeholder:t,maxLength:80,onChange:e=>a({name:e}),className:`font-medium text-[0.875rem]`}),(0,Q.jsx)(G,{value:n??``,label:X(`project.fillUseLabel`),placeholder:r,maxLength:400,onChange:e=>a({description:e}),className:`text-[0.8125rem] text-ink-3`})]})}function er({gradient:e,readOnly:t,onEdit:n,onChange:r,onRemove:i}){let a=E(e),[o,s]=(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":X(`project.gradientEdit`),onClick:n,className:`block h-28 w-full rounded-md ring-1 ring-border-soft transition enabled:hover:brightness-105`,style:{background:a}}),(0,Q.jsxs)(`div`,{className:Zn,children:[(0,Q.jsx)(F,{label:X(o?`project.gradientCopied`:`project.gradientCopy`),onClick:()=>{navigator.clipboard.writeText(`background: ${a};`),s(!0),setTimeout(()=>s(!1),1500)},className:Qn,children:(0,Q.jsx)(Me,{className:`size-4`})}),(0,Q.jsx)(F,{label:X(`project.download`),onClick:()=>void Jn(e,e.name),className:Qn,children:(0,Q.jsx)(v,{className:`size-4`})}),t?null:(0,Q.jsx)(F,{label:X(`project.remove`),onClick:i,className:K(Qn,`hover:text-rose`),children:(0,Q.jsx)(Ce,{className:`size-4`})})]})]}),(0,Q.jsx)($n,{name:e.name,namePlaceholder:X(`project.gradientName`),description:e.description,usePlaceholder:X(`project.gradientUse`),readOnly:t,onChange:r})]})}function tr(e,t){return{backgroundImage:`url("${e}")`,backgroundSize:t?`64px`:`cover`,backgroundRepeat:t?`repeat`:`no-repeat`,backgroundPosition:`center`}}function nr({projectId:e,pattern:t,fileName:n,readOnly:r,onEdit:i,onChange:a,onRemove:o}){let s=je(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:r,"aria-label":X(`project.patternEdit`),onClick:i,className:`block h-28 w-full rounded-md ring-1 ring-border-soft transition enabled:hover:brightness-105`,style:tr(s,t.tile)}),(0,Q.jsxs)(`div`,{className:Zn,children:[(0,Q.jsx)(`a`,{href:s,download:n,"aria-label":X(`project.download`),title:X(`project.download`),className:K(`inline-flex items-center justify-center rounded-full text-ink-3 transition hover:text-ink`,Qn),children:(0,Q.jsx)(v,{className:`size-4`})}),r?null:(0,Q.jsx)(F,{label:X(`project.remove`),onClick:o,className:K(Qn,`hover:text-rose`),children:(0,Q.jsx)(Ce,{className:`size-4`})})]})]}),(0,Q.jsx)($n,{name:t.name,namePlaceholder:n,description:t.description,usePlaceholder:X(`project.patternUse`),readOnly:r,onChange:a})]})}function rr({projectId:e,pattern:t,isNew:n,fileName:r,busy:i,error:a,upload:o,removeFile:s,onSave:c,onClose:l}){let[u,d]=(0,Z.useState)(t),[f,p]=(0,Z.useState)([]),m=async e=>{let t=e[0];if(!t)return;let n=await o(t);n&&(p(e=>[...e,n.id]),d(e=>({...e,file:n.id,name:e.name||n.name.replace(/\.[^.]+$/,``)})))},h=()=>{for(let e of f)s(e);l()};return(0,Q.jsx)(J,{open:!0,onClose:h,wide:!0,title:X(n?`project.patternNew`:`project.patternEdit`),children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[u.file?(0,Q.jsx)(`div`,{className:`relative h-40 rounded-lg ring-1 ring-border-soft`,style:tr(je(e,u.file),u.tile),children:(0,Q.jsxs)(me,{accept:`image/*`,multiple:!1,onFiles:e=>void m(e),className:`absolute right-2 bottom-2 h-9 border-solid bg-card px-3.5 text-ink-2 shadow-soft`,children:[i?(0,Q.jsx)(xe,{className:`size-4`}):(0,Q.jsx)(pe,{className:`size-4`}),X(`project.patternReplace`)]})}):(0,Q.jsxs)(me,{accept:`image/*`,multiple:!1,onFiles:e=>void m(e),className:`h-40 flex-col`,children:[i?(0,Q.jsx)(xe,{className:`size-5`}):(0,Q.jsx)(pe,{className:`size-5`}),X(`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)(L,{children:X(`project.patternName`)}),(0,Q.jsx)(P,{value:u.name,maxLength:80,placeholder:u.file?r(u.file):X(`project.patternNamePlaceholder`),onChange:e=>d({...u,name:e.target.value})})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(L,{children:X(`project.fillUseLabel`)}),(0,Q.jsx)(P,{value:u.description??``,maxLength:400,placeholder:X(`project.patternUse`),onChange:e=>d({...u,description:e.target.value})})]})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(L,{children:X(`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":!!u.tile===e,onClick:()=>d({...u,tile:e||void 0}),className:K(`h-9 rounded-full px-4 font-medium text-[0.875rem] transition`,!!u.tile===e?`bg-card text-ink shadow-sm`:`text-ink-3 hover:text-ink-2`),children:X(e?`project.patternTile`:`project.patternFill`)},String(e)))})]}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[a?(0,Q.jsx)(`p`,{className:`mr-auto text-[0.8125rem] text-rose`,children:a}):null,(0,Q.jsx)(N,{variant:`ghost`,onClick:h,children:X(`common.cancel`)}),(0,Q.jsx)(N,{disabled:!u.file||i,onClick:()=>{for(let e of f.filter(e=>e!==u.file))s(e);t.file&&t.file!==u.file&&s(t.file),c({...u,name:u.name.trim(),description:u.description?.trim()||void 0}),l()},children:X(n?`project.add`:`settings.save`)})]})]})})}var ir=/^#[0-9a-fA-F]{6}$/;function ar({projectId:e,onAdd:t,onClose:n}){let[r,i]=(0,Z.useState)(``),[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(null),[l,u]=(0,Z.useState)(null),[f,p]=(0,Z.useState)([]),m=async()=>{o(!0),c(null);try{let{colors:t}=await d.post(`/api/studio/projects/${e}/colors/scan`,{url:r.trim()});t.length?(u(t),p([])):c(X(`project.colorsNoneFound`))}catch(e){c(e.message)}o(!1)};return(0,Q.jsx)(J,{open:!0,onClose:n,wide:l?!0:void 0,title:X(l?`project.colorsFound`:`project.colorsFromUrl`),children:l?(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:X(`project.colorsFoundHint`)}),(0,Q.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(120px,1fr))] gap-3`,children:l.map(e=>{let t=f.includes(e.value);return(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":t,onClick:()=>p(n=>t?n.filter(t=>t!==e.value):[...n,e.value]),className:K(`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)(M,{className:`size-3.5`})}):null]},e.value)})}),(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Q.jsx)(N,{variant:`ghost`,onClick:()=>u(null),children:X(`run.back`)}),(0,Q.jsx)(N,{disabled:!f.length,onClick:()=>{t(l.filter(e=>f.includes(e.value))),n()},children:f.length>1?X(`project.addMany`,{n:f.length}):X(`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)(L,{children:X(`project.logoUrl`)}),(0,Q.jsx)(P,{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:X(`project.colorsUrlHint`)})]}),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)(N,{variant:`ghost`,onClick:n,children:X(`common.cancel`)}),(0,Q.jsx)(N,{type:`submit`,busy:a,disabled:!r.trim(),children:X(`run.next`)})]})]})})}function or({projectId:e,data:t,colors:n,sections:r,gradients:i,patterns:o,rules:c,sectioned:l,ruled:u,save:d,readOnly:f}){let[p,m]=(0,Z.useState)(()=>n.map(e=>({...e,id:Oe()}))),[h,_]=(0,Z.useState)(r),[v,y]=(0,Z.useState)(i),[b,x]=(0,Z.useState)(o),[S,C]=(0,Z.useState)(null),[w,T]=(0,Z.useState)(null),E=ne(e,f),D=k(c),[O,ee]=(0,Z.useState)(null),[A,te]=(0,Z.useState)(null),[j,M]=(0,Z.useState)(!1),N=s({colors:p.filter(e=>ir.test(e.value)).map(({name:e,value:t,section:n})=>({name:e.trim(),value:t,...n?{section:n}:{}})),colorSections:h,gradients:v,patterns:b,colorRules:D.rules},d),re=l?h:[],I=re.filter(e=>(e.kind??`colors`)===`colors`),L=e=>I.some(t=>t.id===e.section),R=p.filter(e=>!L(e)),ae=(R[0]??p[0])?.id,V=(e,t)=>m(n=>n.map(n=>n.id===e?{...n,...t}:n)),H=e=>m(t=>[...t,...e.map(e=>({...e,id:Oe()}))].slice(0,a.colors)),W=[{value:``,label:X(`project.sectionStandard`)},...I.map(e=>({value:e.id,label:e.title||X(`project.sectionUntitled`)}))],G=(e,t)=>{let n=Oe();ee(n),_(r=>[...r,{id:n,title:t,...e===`colors`?{}:{kind:e}}])},ce=e=>({id:Oe(),name:``,section:e,type:`linear`,angle:90,stops:[{color:p[0]?.value&&ir.test(p[0].value)?p[0].value:`#4b73ff`,at:0},{color:p[1]?.value&&ir.test(p[1].value)?p[1].value:`#ff6d1b`,at:100}]}),le=e=>t.files.find(t=>t.id===e)?.name??`pattern`,ue=[...p.length<a.colors?[{label:X(`project.colorNew`),icon:(0,Q.jsx)(B,{className:`size-4 shrink-0`}),onPick:()=>fe()},{label:X(`project.colorsFromUrl`),icon:(0,Q.jsx)(bn,{className:`size-4 shrink-0`}),onPick:()=>M(!0)}]:[],...l&&h.length<a.logoSections?[{label:X(`project.colorSectionAdd`),icon:(0,Q.jsx)(gn,{className:`size-4 shrink-0`}),onPick:()=>G(`colors`,``)},{label:X(`project.gradientSectionAdd`),icon:(0,Q.jsx)(cn,{className:`size-4 shrink-0`}),onPick:()=>G(`gradients`,X(`project.gradientSectionTitle`))},{label:X(`project.patternSectionAdd`),icon:(0,Q.jsx)(vn,{className:`size-4 shrink-0`}),onPick:()=>G(`patterns`,X(`project.patternSectionTitle`))}]:[],...!u||D.full?[]:[{label:X(`project.ruleNew`),icon:(0,Q.jsx)(Ne,{className:`size-4 shrink-0`}),onPick:()=>D.add()}]],de=e=>(0,Q.jsxs)(`div`,{className:`group/row flex items-center gap-2`,children:[(0,Q.jsx)(he,{value:ir.test(e.value)?e.value:`#888888`,onChange:t=>V(e.id,{value:t.target.value})}),(0,Q.jsx)(P,{value:e.name,autoFocus:e.id===A,placeholder:X(`project.colorName`),maxLength:120,onChange:t=>V(e.id,{name:t.target.value}),className:`min-w-0 flex-1`}),(0,Q.jsx)(P,{value:e.value,placeholder:`#e0531b`,spellCheck:!1,onChange:t=>V(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===ae?(0,Q.jsx)(`span`,{className:`mr-1 max-sm:hidden`,children:(0,Q.jsx)(g,{tone:`ember`,children:X(`project.colorAccent`)})}):f?null:(0,Q.jsx)(F,{label:X(`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)(ve,{className:`size-4`})}),f||!I.length?null:(0,Q.jsx)(U,{options:W,value:L(e)?e.section??``:``,onChange:t=>V(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)(F,{label:X(`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)(Ce,{className:`size-4`})})]})]},e.id),fe=e=>{let t=Oe();te(t),m(n=>[...n,{id:t,name:``,value:`#888888`,...e?{section:e}:{}}])};return(0,Q.jsxs)(Y,{title:X(`project.colors`),hint:X(`project.colorsHint`),save:N,locked:f,action:f?null:(0,Q.jsx)(oe,{entries:ue}),children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[R.length?(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:R.map(de)}),f?null:(0,Q.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:X(`project.colorUse`)})]}):p.length?null:(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:X(`project.colorsEmpty`)}),re.map(t=>{let n=t.kind??`colors`,r=p.filter(e=>e.section===t.id),i=v.filter(e=>e.section===t.id),o=b.filter(e=>e.section===t.id),s=n===`gradients`?i.length:n===`patterns`?o.length:r.length;return(0,Q.jsxs)(`div`,{className:`group/section flex flex-col gap-3`,children:[(0,Q.jsx)(z,{title:t.title,titlePlaceholder:X(n===`gradients`?`project.gradientSectionTitlePlaceholder`:n===`patterns`?`project.patternSectionTitlePlaceholder`:`project.colorSectionTitle`),kind:n===`gradients`?{icon:(0,Q.jsx)(cn,{}),label:X(`project.kindGradients`)}:n===`patterns`?{icon:(0,Q.jsx)(vn,{}),label:X(`project.kindPatterns`)}:{icon:(0,Q.jsx)(tn,{}),label:X(`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(X(n===`colors`?`project.colorSectionRemoveConfirm`:`project.fillSectionRemoveConfirm`,{name:t.title||X(`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:[i.map(e=>(0,Q.jsx)(er,{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>=a.gradients?null:(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>C(ce(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)(B,{className:`size-5`}),X(`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)(nr,{projectId:e,pattern:t,fileName:le(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>=a.files.pattern?null:(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>T({id:Oe(),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)(B,{className:`size-5`}),X(`project.patternAdd`)]})]}):(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[r.map(de),f||p.length>=a.colors?null:(0,Q.jsx)(se,{label:X(`project.colorAdd`),onClick:()=>fe(t.id)})]})]},t.id)}),u?(0,Q.jsx)(ie,{rules:D,placeholder:X(`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)(Xn,{projectId:e,gradient:S,isNew:!v.some(e=>e.id===S.id),brand:p.filter(e=>ir.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)(rr,{projectId:e,pattern:w,isNew:!b.some(e=>e.id===w.id),fileName:le,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)(ar,{projectId:e,onClose:()=>M(!1),onAdd:H}):null]})}var sr=e=>/^(ja|yes|true)$/i.test(e.trim()),cr={text:Ie,longtext:xt,number:Be,date:Ue,url:T,email:Gt,phone:yt,boolean:He};function lr({type:e,detected:t,onChange:n}){let[r,i]=(0,Z.useState)(!1),[a,o]=(0,Z.useState)(!1),s=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{if(!r)return;let e=e=>{s.current?.contains(e.target)||i(!1)},t=e=>e.key===`Escape`&&i(!1);return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[r]);let c=cr[e??t],l=`${X(`project.factType`)}: ${X(`project.type.${e??t}`)}`,u=`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`,d=e=>{n(e),i(!1)};return(0,Q.jsxs)(`div`,{className:`relative`,ref:s,children:[(0,Q.jsx)(`button`,{type:`button`,"aria-label":l,title:l,"aria-haspopup":`menu`,"aria-expanded":r,onClick:e=>{o(window.innerHeight-e.currentTarget.getBoundingClientRect().bottom<400),i(e=>!e)},className:K(`inline-flex size-11 items-center justify-center rounded-lg transition hover:bg-accent hover:text-ink`,r?`bg-accent text-ink`:e?`text-ink-2`:`text-ink-4`),children:(0,Q.jsx)(c,{className:`size-4`})}),r?(0,Q.jsxs)(`div`,{role:`menu`,className:K(`absolute right-0 z-50 w-56 animate-rise rounded-xl bg-card p-1.5 shadow-overlay ring-1 ring-border-soft`,a?`bottom-12`:`top-12`),children:[(0,Q.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":!e,className:u,onClick:()=>d(void 0),children:[(0,Q.jsx)(Pe,{className:`size-4 shrink-0`}),(0,Q.jsx)(`span`,{className:`flex-1`,children:X(`project.factAuto`)}),(0,Q.jsx)(`span`,{className:`text-[0.75rem] text-ink-4`,children:X(`project.type.${t}`)}),(0,Q.jsx)(M,{className:K(`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=cr[t];return(0,Q.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":e===t,className:u,onClick:()=>d(t),children:[(0,Q.jsx)(n,{className:`size-4 shrink-0`}),(0,Q.jsx)(`span`,{className:`flex-1`,children:X(`project.type.${t}`)}),(0,Q.jsx)(M,{className:K(`size-4 shrink-0`,e!==t&&`invisible`)})]},t)})]}):null]})}function ur({facts:e,save:t,readOnly:n}){let r=(0,Z.useRef)(0),i=(0,Z.useRef)(null),[o,l]=(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)=>l(n=>n.map(n=>n.id===e?{...n,...t}:n)),f=(e,t,n=!1)=>{let a=`f${r.current++}`;i.current=`${a}:${t}`;let o={id:a,key:``,label:``,value:``,...e};l(e=>n?[o,...e]:[...e,o])},p=e=>t=>{t&&i.current===e&&(i.current=null,t.focus())},m=c.filter(e=>!o.some(t=>t.key===e));return(0,Q.jsxs)(Y,{title:X(`project.facts`),hint:X(`project.factsHint`),save:u,locked:n,action:o.length<a.facts&&!n?(0,Q.jsxs)(N,{variant:`secondary`,size:`sm`,onClick:()=>f({},`label`,!0),children:[(0,Q.jsx)(B,{className:`size-4`}),` `,X(`project.factAdd`)]}):null,children:[(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:o.map(e=>{let t=ue(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)(P,{ref:p(`${e.id}:label`),value:e.label,placeholder:X(`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:y(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)(ye,{checked:sr(e.value),label:e.label,onChange:t=>d(e.id,{value:X(t?`project.yes`:`project.no`)})}),(0,Q.jsx)(`span`,{className:`text-[0.875rem] text-ink-2`,children:sr(e.value)?X(`project.yes`):X(`project.no`)})]}):(0,Q.jsx)(R,{ref:p(`${e.id}:value`),rows:1,minRows:r===`longtext`?2:1,maxRows:10,value:e.value,placeholder:X(`project.factValue`),onChange:t=>d(e.id,{value:t.target.value}),className:`min-h-11`}),(0,Q.jsx)(lr,{type:e.type,detected:t,onChange:t=>d(e.id,{type:t})}),n?null:(0,Q.jsx)(F,{label:X(`project.remove`),onClick:()=>l(t=>t.filter(t=>t.id!==e.id)),className:`size-11 rounded-lg hover:text-rose`,children:(0,Q.jsx)(Ce,{className:`size-4`})})]},e.id)})}),o.length<a.facts&&!n?(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 ${o.length?`mt-4`:``}`,children:[(0,Q.jsxs)(N,{variant:`secondary`,size:`sm`,onClick:()=>f({},`label`),children:[(0,Q.jsx)(B,{className:`size-4`}),` `,X(`project.factAdd`)]}),m.map(e=>(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>f({key:e,label:X(`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)(B,{className:`size-3.5`}),` `,X(`fact.${e}`)]},e))]}):null]})}function dr({onLogo:e,children:t,className:n}){let[r,i]=(0,Z.useState)(!1);return e?(0,Q.jsx)(`div`,{onDragOver:e=>{e.dataTransfer.types.includes(`application/x-wizards-logo`)&&(e.preventDefault(),i(!0))},onDragLeave:()=>i(!1),onDrop:t=>{let n=t.dataTransfer.getData(Mn);i(!1),n&&(t.preventDefault(),e(n))},className:K(`-m-2 rounded-xl p-2 transition`,r&&`bg-paper-2 ring-1 ring-focus`,n),children:t}):(0,Q.jsx)(`div`,{className:n,children:t})}function fr({projectId:e,data:t,readOnly:n,sections:r,rules:i,sectioned:o,ruled:c,save:l}){let u=ne(e,n),[d,f]=(0,Z.useState)(r),p=k(i),[h,g]=(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=m(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)},A=C.length?{options:[{value:``,label:X(`project.sectionStandard`)},...C.map(e=>({value:e.id,label:e.title||X(`project.sectionUntitled`)}))],current:e=>C.find(t=>t.logos.includes(e.id))?.id??``,onMove:(e,t)=>D(e.id,t||null)}:void 0,te=(t,n,r)=>(0,Q.jsx)(Nn,{projectId:e,kind:`logo`,files:t,actions:u,accept:`image/*`,addLabel:r?X(`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:A,onRemove:e=>{confirm(X(`project.removeConfirm`,{name:e.name}))&&(u.remove(e.id),D(e.id,null))}}),j=n?void 0:e=>t=>D(t,e),M=[{label:X(`project.logoUpload`),icon:(0,Q.jsx)(Ct,{className:`size-4 shrink-0`}),onPick:()=>y.current?.click()},{label:X(`project.logoFromUrl`),icon:(0,Q.jsx)(bn,{className:`size-4 shrink-0`}),onPick:()=>v(!0)},...o&&d.length<a.logoSections?[{label:X(`project.logoSectionAdd`),icon:(0,Q.jsx)(gn,{className:`size-4 shrink-0`}),onPick:()=>{let e=Oe();g(e),f(t=>[...t,{id:e,title:``,description:``,logos:[]}])}}]:[],...!c||p.full?[]:[{label:X(`project.ruleNew`),icon:(0,Q.jsx)(Ne,{className:`size-4 shrink-0`}),onPick:()=>p.add()}]];return(0,Q.jsxs)(Y,{title:X(`project.logos`),hint:X(`project.logosHint`),save:b,action:n?null:(0,Q.jsx)(oe,{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)(dr,{onLogo:j?.(null),children:te(T,null,!0)}),C.map(e=>(0,Q.jsx)(`div`,{className:`group/section`,children:(0,Q.jsxs)(dr,{onLogo:j?.(e.id),className:`flex flex-col gap-3`,children:[(0,Q.jsx)(z,{title:e.title,description:e.description,titlePlaceholder:X(`project.logoSectionTitle`),descriptionPlaceholder:X(`project.logoSectionUse`),autoFocus:h===e.id,readOnly:n,onChange:t=>O(e.id,t),onRemove:()=>{(!e.logos.length||confirm(X(`project.logoSectionRemoveConfirm`,{name:e.title||X(`project.sectionUntitled`)})))&&f(t=>t.filter(t=>t.id!==e.id))}}),te(e.logos.map(e=>S.get(e)).filter(e=>!!e),e.id,!0)]})},e.id)),c?(0,Q.jsx)(ie,{rules:p,placeholder:X(`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)(Pn,{kind:`logo`,onClose:()=>v(!1),fetchUrl:e=>u.fromUrl(`logo`,e),onAdded:e=>{for(let t of e)D(t.id,null)}}):null]})}var pr=e=>URL.canParse(e)?new URL(e).host:e;async function mr(e,t){let n=x({family:t,source:{url:e}});if(!n)return`down`;if(n.stylesheet)return await hr(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 hr(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 gr(e,t){let n=e.source;if(!n)return X(`project.fontSourceNone`);if(`file`in n){let e=t.find(e=>e.id===n.file)?.name??``;return X(`project.fontSourceFile`,{name:e})}return X(`project.fontSourceUrl`,{host:pr(n.url)})}function _r({projectId:e,font:t,onSave:n,onClose:r}){let a=(A(e).data?.files??[]).filter(e=>e.mime.startsWith(`font/`)),o=ne(e),s=(0,Z.useRef)(null),[c,l]=(0,Z.useState)(t.source&&`url`in t.source?`url`:`file`),[u,d]=(0,Z.useState)(t.source&&`file`in t.source?t.source.file:``),[f,p]=(0,Z.useState)(t.source&&`url`in t.source?t.source.url:``),[m,h]=(0,Z.useState)(t.source&&`url`in t.source?{url:t.source.url,result:`ok`}:null),[g,_]=(0,Z.useState)(!1),[v,y]=(0,Z.useState)(t.license??``),[b,x]=(0,Z.useState)(!1),S=f.trim(),C=async()=>{_(!0),h({url:S,result:await mr(S,t.family.trim())}),_(!1)},w=c===`file`?u?{file:u}:null:m?.url===S&&m.result===`ok`?{url:S}:null,T=m?.url===S?m.result:null;return(0,Q.jsx)(J,{open:!0,onClose:r,title:X(`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:X(`project.fontSourceHint`)}),(0,Q.jsx)(i,{value:c,options:[`file`,`url`],label:e=>X(`project.fontSourceKind.${e}`),onChange:e=>l(e)}),c===`file`?(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(L,{children:X(`project.fontSourceFiles`)}),(0,Q.jsx)(`div`,{className:`flex flex-col gap-1`,children:a.map(e=>(0,Q.jsx)(`button`,{type:`button`,"aria-pressed":u===e.id,onClick:()=>d(e.id),className:K(`rounded-lg px-3 py-2 text-left text-[0.875rem] ring-1 transition`,u===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&&d(n.id)}}),(0,Q.jsxs)(N,{variant:`ghost`,className:`mt-2`,busy:o.busy,onClick:()=>s.current?.click(),children:[(0,Q.jsx)(Ct,{className:`size-4`}),X(`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(),C()},children:[(0,Q.jsx)(L,{children:X(`project.fontSourceUrlLabel`)}),(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(P,{value:f,inputMode:`url`,placeholder:X(`project.fontSourceUrlPlaceholder`),onChange:e=>p(e.target.value)}),(0,Q.jsx)(N,{type:`submit`,variant:`ghost`,busy:g,disabled:!S.startsWith(`https://`),children:X(`project.fontSourceCheck`)})]}),T?(0,Q.jsx)(`p`,{className:K(`mt-1.5 text-[0.875rem]`,T===`ok`?`text-ink-3`:`text-rose`),children:X(`project.fontCheck.${T}`,{host:pr(S),family:t.family})}):null,T===`ok`?(0,Q.jsx)(`p`,{className:`mt-1.5 text-[0.875rem] text-ink-3`,children:X(`project.fontPrivacy`,{host:pr(S)})}):null]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(L,{hint:X(`project.fontLicenseHint`),children:X(`project.fontLicense`)}),(0,Q.jsx)(P,{value:v,maxLength:200,placeholder:X(`project.fontLicensePlaceholder`),onChange:e=>y(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:b,onChange:e=>x(e.target.checked)}),X(`project.fontLicenseConfirm`,{family:t.family})]})]}),(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[t.source?(0,Q.jsx)(N,{variant:`ghost`,className:`mr-auto`,onClick:()=>{n({source:void 0,license:t.license}),r()},children:X(`project.fontSourceRemove`)}):null,(0,Q.jsx)(N,{variant:`ghost`,onClick:r,children:X(`common.cancel`)}),(0,Q.jsx)(N,{disabled:!(w&&b),onClick:()=>{w&&(n({source:w,license:v.trim()||void 0}),r())},children:X(`project.fontSourceSave`)})]})]})})}var vr=new Set;function yr(e){(0,Z.useEffect)(()=>{let t=e.trim().toLowerCase().replace(/\s+/g,`-`);if(!t||vr.has(t))return;vr.add(t);let n=document.createElement(`link`);n.rel=`stylesheet`,n.href=`https://fonts.bunny.net/css?family=${encodeURIComponent(t)}:${u.join(`,`)}&display=swap`,document.head.append(n)},[e])}var br=e=>e?`"${e}", system-ui, sans-serif`:`system-ui, sans-serif`;function xr({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 Sr=`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`,Cr={web:`project.fontUseWeb`,documents:`project.fontUseDocuments`,print:`project.fontUsePrint`,images:`project.fontUseImages`,video:`project.fontUseVideo`};function wr({projectId:e,font:t,first:n,readOnly:r,autoFocus:i,onChange:a,onRemove:o}){yr(t.family);let s=A(e).data?.files??[],[c,l]=(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:br(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`})]}),r?(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)(G,{value:t.family,label:X(`project.fontFamily`),placeholder:X(`project.fontFamily`),maxLength:80,autoFocus:i,onChange:e=>a({family:e}),className:`font-medium text-[0.9375rem]`}),(0,Q.jsx)(G,{value:t.role,label:X(`project.fontRole`),placeholder:X(n?`project.fontRoleFirst`:`project.fontRole`),maxLength:200,onChange:e=>a({role:e}),className:`text-[0.875rem] text-ink-3`})]}),(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:u.map(e=>{let n=t.weights.includes(e);return(0,Q.jsx)(`button`,{type:`button`,disabled:r,"aria-pressed":n,onClick:()=>a({weights:n?t.weights.filter(t=>t!==e):[...t.weights,e].sort((e,t)=>e-t)}),style:{fontFamily:br(t.family),fontWeight:e},className:K(`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`,r&&!n&&`hidden`),children:e},e)})}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[r?t.license?(0,Q.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3`,children:t.license}):null:(0,Q.jsx)(G,{value:t.license??``,label:X(`project.fontLicense`),placeholder:X(`project.fontLicensePlaceholder`),maxLength:200,onChange:e=>a({license:e}),className:`text-[0.8125rem] text-ink-3`}),r&&!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:X(`project.fontUses`)}),ee.map(e=>{let n=!!t.uses?.includes(e);return(0,Q.jsxs)(`button`,{type:`button`,disabled:r,"aria-pressed":n,onClick:()=>{let r=n?(t.uses??[]).filter(t=>t!==e):ee.filter(n=>n===e||t.uses?.includes(n));a({uses:r.length?r:void 0})},className:K(`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`,r&&!n&&`hidden`),children:[n?(0,Q.jsx)(M,{className:`size-3.5`}):null,X(Cr[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:gr(t,s)}),r||!t.family.trim()?null:(0,Q.jsx)(`button`,{type:`button`,onClick:()=>l(!0),className:`text-ink underline decoration-border underline-offset-2 hover:decoration-ink`,children:X(t.source?`project.fontSourceChange`:`project.fontSourceSet`)})]}),c?(0,Q.jsx)(_r,{projectId:e,font:t,onSave:a,onClose:()=>l(!1)}):null,r?null:(0,Q.jsx)(F,{label:X(`project.remove`),onClick:o,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)(Ce,{className:`size-4`})})]})}function Tr({style:e,fonts:t,sample:n,readOnly:r,autoFocus:i,onChange:a,onRemove:o}){let s=t.find(t=>t.id===e.font)??t[0],c={fontFamily:br(s?.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:c,children:n}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2`,children:[r?(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)(G,{value:e.name,label:X(`project.styleName`),placeholder:X(`project.styleName`),maxLength:60,autoFocus:i,onChange:e=>a({name:e}),className:`font-medium text-[0.8125rem] text-ink-2 uppercase tracking-wide`})}),(0,Q.jsxs)(`fieldset`,{disabled:r,className:`flex flex-wrap items-center gap-x-3 gap-y-2`,children:[t.length>1?(0,Q.jsx)(`select`,{"aria-label":X(`project.styleFont`),value:s?.id??``,onChange:e=>a({font:e.target.value}),className:K(Sr,`max-w-40`),children:t.map(e=>(0,Q.jsx)(`option`,{value:e.id,children:e.family||X(`project.fontFamily`)},e.id))}):null,(0,Q.jsx)(`select`,{"aria-label":X(`project.styleWeight`),value:e.weight,onChange:e=>a({weight:Number(e.target.value)}),className:Sr,children:[...new Set([...u,e.weight])].sort().map(e=>(0,Q.jsx)(`option`,{value:e,children:e},e))}),(0,Q.jsx)(xr,{unit:`px`,label:X(`project.styleSize`),min:6,max:400,value:e.size,onChange:e=>a({size:Number(e.target.value)||16})}),(0,Q.jsx)(xr,{unit:X(`project.styleLine`),label:X(`project.styleLineLabel`),min:50,max:300,value:e.lineHeight,onChange:e=>a({lineHeight:Number(e.target.value)||100})}),(0,Q.jsx)(xr,{unit:X(`project.styleTracking`),label:X(`project.styleTrackingLabel`),min:-20,max:50,step:.5,value:e.tracking,onChange:e=>a({tracking:Number(e.target.value)||0})}),(0,Q.jsx)(`button`,{type:`button`,"aria-pressed":!!e.uppercase,title:X(`project.styleUpper`),"aria-label":X(`project.styleUpper`),onClick:()=>a({uppercase:!e.uppercase}),className:K(`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)(fn,{className:`size-4`})})]}),r?null:(0,Q.jsx)(F,{label:X(`project.remove`),onClick:o,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)(Ce,{className:`size-4`})})]})]})}function Er({projectId:e,onAdd:t,onClose:n}){let[r,i]=(0,Z.useState)(``),[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(null),[l,u]=(0,Z.useState)(null),[f,p]=(0,Z.useState)([]),m=async()=>{o(!0),c(null);try{let{fonts:t}=await d.post(`/api/studio/projects/${e}/fonts/scan`,{url:r.trim()});t.length?(u(t),p(t.slice(0,2).map(e=>e.family))):c(X(`project.fontsNoneFound`))}catch(e){c(e.message)}o(!1)};return(0,Q.jsx)(J,{open:!0,onClose:n,wide:l?!0:void 0,title:X(l?`project.fontsFound`:`project.fontsFromUrl`),children:l?(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:X(`project.fontsFoundHint`)}),(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:l.map(e=>(0,Q.jsx)(Dr,{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)(N,{variant:`ghost`,onClick:()=>u(null),children:X(`run.back`)}),(0,Q.jsx)(N,{disabled:!f.length,onClick:()=>{t(l.filter(e=>f.includes(e.family))),n()},children:f.length>1?X(`project.addMany`,{n:f.length}):X(`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)(L,{children:X(`project.logoUrl`)}),(0,Q.jsx)(P,{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:X(`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)(N,{variant:`ghost`,onClick:n,children:X(`common.cancel`)}),(0,Q.jsx)(N,{type:`submit`,busy:a,disabled:!r.trim(),children:X(`run.next`)})]})]})})}function Dr({font:e,on:t,onToggle:n}){return yr(e.family),(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":t,onClick:n,className:K(`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:br(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(` · `):X(`project.fontWeightsUnknown`)})]}),t?(0,Q.jsx)(`span`,{className:`grid size-5 place-items-center rounded-full bg-ember text-white`,children:(0,Q.jsx)(M,{className:`size-3.5`})}):null]})}function Or({projectId:e,fonts:t,styles:n,rules:r,ruled:i,sample:o,save:c,readOnly:l}){let[u,d]=(0,Z.useState)(t),[f,p]=(0,Z.useState)(n),m=k(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:Oe(),family:e.family,role:``,weights:e.weights}));t&&n[0]&&g(n[0].id),d(e=>[...e,...n].slice(0,a.fonts))},x=()=>{let e=Oe();g(e),p(t=>[...t,{id:e,name:``,size:16,weight:400,lineHeight:150,tracking:0}])},S=[...u.length<a.fonts?[{label:X(`project.fontNew`),icon:(0,Q.jsx)(B,{className:`size-4 shrink-0`}),onPick:()=>b([{family:``,weights:[400,700]}],!0)},{label:X(`project.fontsFromUrl`),icon:(0,Q.jsx)(bn,{className:`size-4 shrink-0`}),onPick:()=>v(!0)}]:[],...f.length<a.textStyles?[{label:X(`project.styleNew`),icon:(0,Q.jsx)(Jt,{className:`size-4 shrink-0`}),onPick:x}]:[],...!i||m.full?[]:[{label:X(`project.ruleNew`),icon:(0,Q.jsx)(Ne,{className:`size-4 shrink-0`}),onPick:()=>m.add()}]];return(0,Q.jsxs)(Y,{title:X(`project.typography`),hint:X(`project.typographyHint`),save:y,action:l?null:(0,Q.jsx)(oe,{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)(wr,{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:X(`project.fontsEmpty`)}),f.length?(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h3`,{className:`font-medium text-[0.9375rem]`,children:X(`project.styles`)}),l?null:(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-ink-3 leading-snug`,children:X(`project.stylesHint`)}),(0,Q.jsx)(`ul`,{className:`mt-2 flex flex-col`,children:f.map(e=>(0,Q.jsx)(Tr,{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,i?(0,Q.jsx)(ie,{rules:m,placeholder:X(`project.typeRulePlaceholder`),readOnly:l}):null]}),_?(0,Q.jsx)(Er,{projectId:e,onClose:()=>v(!1),onAdd:e=>b(e)}):null]})}function kr({projectId:e,logo:t}){let n=X(t?`project.logoPeek`:`project.logoPeekAdd`);return(0,Q.jsxs)(`div`,{className:`shrink-0`,children:[(0,Q.jsx)(L,{children:X(`project.logo`)}),(0,Q.jsx)(r,{to:{pathname:`/space/brand`,hash:`logos`},title:n,"aria-label":n,className:K(`grid size-[4.5rem] place-items-center overflow-hidden rounded-xl transition`,t?`bg-card ring-1 ring-border-soft hover:ring-border`:`text-ink-4 ring-1 ring-border ring-dashed hover:text-ink-2`),children:t?(0,Q.jsx)(An,{projectId:e,file:t,small:!0}):(0,Q.jsx)(o,{className:`size-5`})})]})}function Ar({project:e,logo:t,save:n}){let[r,i]=(0,Z.useState)(e.brand.name??``),[a,o]=(0,Z.useState)(e.brand.about??``),c=s({name:r.trim(),about:a.trim()},e=>n({brand:e}));return(0,Q.jsx)(Y,{title:X(`project.base`),hint:X(`project.baseHint`),save:c,locked:e.readOnly,children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start gap-4`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(L,{children:X(`project.title`)}),(0,Q.jsx)(P,{value:r,maxLength:120,onChange:e=>i(e.target.value)}),(0,Q.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:X(`project.titleHint`)})]}),(0,Q.jsx)(kr,{projectId:e.id,logo:t})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(L,{children:X(`project.about`)}),(0,Q.jsx)(R,{minRows:4,value:a,onChange:e=>o(e.target.value)}),(0,Q.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:X(`project.aboutHint`)})]})]})})}function jr({project:e,group:t,top:n=!1,children:r}){let i=C(),a=A(e.id),[o,s]=(0,Z.useState)(0),[c,l]=(0,Z.useState)(!1),u=async t=>{await d.patch(`/api/studio/projects/${e.id}`,t),await i.invalidateQueries({queryKey:j.spaces()})},f=Re({mutationFn:()=>d.del(`/api/studio/projects/${e.id}`),onSuccess:()=>i.invalidateQueries({queryKey:j.spaces()})}),p=gt(),h=ht(),g=a.data??{files:[],embeddings:!0},_=`${e.id}:${o}`,v=e.readOnly,y=t===`knowledge`,b=It(`brandSections`),x=It(`brandRules`),S=It(`typography`);return kt(v?{}:{title:X(y?`project.assistantTitleKnowledge`:`project.assistantTitle`),hello:X(y?`project.assistantHelloKnowledge`:`project.assistantHello`),about:X(y?`project.assistantAboutKnowledge`:`project.assistantAbout`),placeholder:X(y?`project.assistantComposerKnowledge`:`project.assistantComposer`),suggestions:y?[{label:X(`assistant.suggest.knowledgeHow`)},{label:X(`assistant.suggest.knowledgeSite`),fill:!0},{label:X(`assistant.suggest.knowledgeCategories`)}]:[{label:X(`assistant.suggest.readSite`),fill:!0},{label:X(`assistant.suggest.missing`)},...t===`info`?[{label:X(`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:()=>s(e=>e+1)}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-9`,children:[v?(0,Q.jsx)(St,{children:bt(e)}):n?(0,Q.jsx)(Pt,{}):null,t===`info`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(_e,{id:`base`,children:(0,Q.jsx)(Ar,{project:e,logo:m(g.files.filter(e=>e.kind===`logo`),e.brand.logoSections),save:u},`base:${_}`)}),(0,Q.jsx)(_e,{id:`facts`,children:(0,Q.jsx)(ur,{facts:e.facts,save:e=>u({facts:e}),readOnly:v},`facts:${_}`)})]}):null,t===`brand`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(_e,{id:`logos`,children:(0,Q.jsx)(fr,{projectId:e.id,data:g,readOnly:v,sections:e.brand.logoSections??[],rules:e.brand.logoRules??[],sectioned:b,ruled:x,save:e=>u({brand:e})},`logos:${_}`)}),(0,Q.jsx)(_e,{id:`colors`,children:(0,Q.jsx)(or,{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=>u({brand:e}),readOnly:v},`colors:${_}`)}),S?(0,Q.jsx)(_e,{id:`typography`,children:(0,Q.jsx)(Or,{projectId:e.id,fonts:e.brand.fonts??[],styles:e.brand.textStyles??[],rules:e.brand.typeRules??[],ruled:x,sample:e.brand.name||X(`project.typeSample`),save:e=>u({brand:e}),readOnly:v},`typography:${_}`)}):null,(0,Q.jsx)(_e,{id:`assets`,children:(0,Q.jsx)(Kn,{projectId:e.id,data:g,readOnly:v,sections:e.brand.assetSections??[],save:e=>u({brand:e})},`assets:${_}`)})]}):null,r,t===`info`&&p&&!v&&h?(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(N,{variant:`danger`,onClick:()=>l(!0),children:X(`settings.delete`)}),(0,Q.jsxs)(J,{open:c,onClose:()=>l(!1),title:X(`settings.deleteTitle`,{name:e.name}),children:[(0,Q.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-ink-2`,children:X(`settings.deleteBody`)}),f.error?(0,Q.jsx)(`p`,{className:`mt-3 text-[0.8125rem] text-rose`,children:f.error.message}):null,(0,Q.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,Q.jsx)(N,{variant:`ghost`,onClick:()=>l(!1),children:X(`common.cancel`)}),(0,Q.jsx)(N,{variant:`danger`,busy:f.isPending,onClick:()=>f.mutate(),children:X(`common.delete`)})]})]})]}):null]})}var Mr=[{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`,Nr=`font-mono text-[0.875rem]`,Pr=e=>e.slice(e.indexOf(`.`)+1);function Fr(){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 Ir(){let e=X(`page.sources`).split(/(\{brand\}|\{facts\})/);return(0,Q.jsxs)(`p`,{className:$,children:[e.map((e,t)=>e===`{brand}`?(0,Q.jsx)(r,{to:`/space/brand`,className:`text-ink underline-offset-2 hover:underline`,children:X(`space.brand`)},t):e===`{facts}`?(0,Q.jsx)(r,{to:`/space/info#facts`,className:`text-ink underline-offset-2 hover:underline`,children:X(`project.facts`)},t):e),` `,X(`page.onlyShared`)]})}function Lr({host:e,value:t,onChange:n,disabled:r}){let i=fe.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:[`…`,Pr(e),`/`]}),(0,Q.jsx)(`input`,{value:t,disabled:r,"aria-label":X(`page.address`),maxLength:w.slug,onChange:e=>n(e.target.value.toLowerCase().replace(/[^a-z0-9-]/g,`-`)),className:K(`min-w-0 flex-1 bg-transparent px-3 outline-none`,Nr)})]}),(0,Q.jsx)(`p`,{className:K(`mt-1.5`,$,!i&&t&&`text-rose`),children:X(`page.addressRules`)})]})}function Rr({host:e,words:t,onChange:n,disabled:r}){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)(L,{children:X(`page.title`)}),(0,Q.jsx)(P,{value:t.title,disabled:r,maxLength:w.title,onChange:e=>n({title:e.target.value})}),(0,Q.jsx)(`p`,{className:K(`mt-1.5`,$),children:X(`page.titleHint`)})]}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(L,{children:X(`page.address`)}),(0,Q.jsx)(Lr,{host:e,value:t.slug,disabled:r,onChange:e=>n({slug:e})}),(0,Q.jsx)(`p`,{className:K(`mt-1`,$),children:X(`page.addressChange`)})]}),(0,Q.jsxs)(`div`,{className:`min-w-0 sm:col-span-2`,children:[(0,Q.jsx)(L,{children:X(`page.headline`)}),(0,Q.jsx)(P,{value:t.headline??``,disabled:r,maxLength:w.headline,onChange:e=>n({headline:e.target.value})})]}),(0,Q.jsxs)(`div`,{className:`min-w-0 sm:col-span-2`,children:[(0,Q.jsx)(L,{children:X(`page.words`)}),(0,Q.jsx)(R,{value:t.intro??``,disabled:r,minRows:3,maxLength:w.intro,onChange:e=>n({intro:e.target.value})})]}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(L,{children:X(`page.lang`)}),(0,Q.jsx)(H,{value:t.voice,onChange:e=>n({voice:e}),options:Mr.map(e=>({value:e.value,label:X(e.label)}))}),(0,Q.jsx)(`p`,{className:K(`mt-1.5`,$),children:X(`page.langHint`)})]})]})}function zr(e,t){if(!e.published)return X(`page.draftNote`);if(!e.shareEnabled)return X(`page.notSharedNote`);let n=e.description.trim();return t?[n,X(`page.first`)].filter(Boolean).join(` · `):n}function Br({wizard:e,first:t,on:n,disabled:r,onToggle:i,drag:a}){return(0,Q.jsxs)(`li`,{draggable:a?!0:void 0,onDragStart:a?.onDragStart,onDragOver:a?.onDragOver,onDrop:a?.onDrop,className:K(`flex items-center gap-3 border-border-soft border-t py-2.5 first:border-t-0`,!e.published&&`opacity-60`),children:[a?(0,Q.jsx)(`button`,{type:`button`,"aria-label":`${X(`page.moveUp`)} / ${X(`page.moveDown`)}`,onKeyDown:a.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)(de,{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:K(`truncate`,$),children:zr(e,t)})]}),(0,Q.jsx)(ye,{checked:n,disabled:r||!e.published,label:X(`page.showOnPage`),onChange:i})]})}function Vr({title:e,text:t,picked:n,disabled:r,later:i,onPick:a}){return(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":n,disabled:r||i,onClick:a,className:K(`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`:i?`border border-border border-dashed opacity-60`:`ring-1 ring-border-soft hover:bg-paper-2`,(r||i)&&`cursor-not-allowed`),children:[(0,Q.jsx)(`span`,{className:`font-medium text-[0.9375rem]`,children:e}),(0,Q.jsx)(`span`,{className:$,children:t})]})}var Hr={desktop:1280,tablet:768,mobile:390},Ur=`wizards.pagePreviewDevice`,Wr=`wizards.pagePreviewHeight`,Gr=360,Kr=e=>e?640:480,qr=()=>Math.max(Gr,window.innerHeight-140);function Jr(){try{let e=Number(localStorage.getItem(Wr));return e>=Gr?e:null}catch{return null}}function Yr(e){try{e===null?localStorage.removeItem(Wr):localStorage.setItem(Wr,String(Math.round(e)))}catch{}}function Xr(){try{let e=localStorage.getItem(Ur);return e&&e in Hr?e:`desktop`}catch{return`desktop`}}function Zr(e){try{localStorage.setItem(Ur,e)}catch{}}function Qr({url:e,version:t,device:n}){let r=(0,Z.useRef)(null),[i,a]=(0,Z.useState)({width:0,tall:!0});(0,Z.useEffect)(()=>{let e=r.current;if(!e)return;let t=()=>a({width:e.clientWidth,tall:e.clientWidth>=640});t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]);let o=Hr[n],[s,c]=(0,Z.useState)(Jr),[l,u]=(0,Z.useState)(!1),d=(0,Z.useRef)(null),f=Math.min(s??Kr(i.tall),i.width?qr():9999),p=e=>{let t=Math.round(Math.min(qr(),Math.max(Gr,e)));return c(t),t},m=n===`mobile`,h=m?12:0,g=i.width?Math.min(1,(i.width-2*h)/o):1,_=(0,Q.jsxs)(`div`,{className:K(`relative overflow-hidden bg-paper-2`,m?`rounded-[1.5rem]`:`rounded-lg ring-1 ring-border-soft`),style:{width:Math.round(o*g),height:f},children:[i.width?(0,Q.jsx)(`iframe`,{title:X(`page.previewTitle`),src:`${e}${e.includes(`?`)?`&`:`?`}v=${t}`,tabIndex:-1,className:K(`absolute top-0 left-0 border-0`,l&&`pointer-events-none`),style:{width:o,height:Math.ceil(f/g),transform:`scale(${g})`,transformOrigin:`top left`}},t):null,(0,Q.jsx)(`button`,{type:`button`,"aria-label":X(`page.resize`),title:X(`page.resize`),onPointerDown:e=>{e.preventDefault();try{e.currentTarget.setPointerCapture(e.pointerId)}catch{}d.current={y:e.clientY,height:f},u(!0)},onPointerMove:e=>{d.current&&p(d.current.height+e.clientY-d.current.y)},onPointerUp:e=>{d.current&&=(Yr(p(d.current.height+e.clientY-d.current.y)),null),u(!1)},onPointerCancel:()=>{d.current=null,u(!1)},onDoubleClick:()=>{c(null),Yr(null)},onKeyDown:e=>{(e.key===`ArrowUp`||e.key===`ArrowDown`)&&(e.preventDefault(),Yr(p(f+(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:r,className:`flex w-full justify-center`,children:m?(0,Q.jsx)(`div`,{className:`rounded-[2.25rem] bg-ink p-3 shadow-soft`,children:_}):_})}function $r({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:We(t)})),l=s(o,async e=>{if(!(fe.test(e.slug)&&e.title.trim()))return;let{lang:t,form:n}=ut(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)(Rr,{host:e,words:o,disabled:n,onChange:e=>c(t=>({...t,...e}))})}function ei({project:e}){let t=C(),n=_t(),r=n.data?.tenant.pagesHost??null,i=n.data?.manageUrl??null,a=e.readOnly,o=e.page,s=!!o?.on,c=V({queryKey:j.projectWizards(e.id),queryFn:()=>d.get(`/api/studio/projects/${e.id}/wizards`)}),[l,u]=(0,Z.useState)(1),[p,m]=(0,Z.useState)(Xr),h=(0,Z.useRef)(o);h.current=o;let g=async n=>{await d.patch(`/api/studio/projects/${e.id}`,{page:n}),await t.invalidateQueries({queryKey:j.spaces()}),u(e=>e+1)},v=Re({mutationFn:e=>{let t=h.current;return t?g({...t,...e}):Promise.resolve()}}),[y,b]=(0,Z.useState)({state:`idle`,error:null}),{copied:x,copy:S}=Fr(),w=c.data??[],T=(o?.wizards??[]).map(e=>w.find(t=>t.id===e)).filter(e=>e!==void 0),E=w.filter(e=>!o?.wizards.includes(e.id)),[D,O]=(0,Z.useState)(null),k=(e,t)=>{let n=[...o?.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})},ee=(e,t)=>v.mutate({wizards:t?[...o?.wizards??[],e]:(o?.wizards??[]).filter(t=>t!==e)}),A=e.brand.name?.trim()||e.name,te=Re({mutationFn:()=>g({on:!0,slug:_(A)||`page`,title:A,...ut(wt===`de`?`de-du`:`en`),wizards:w.filter(e=>e.published&&e.shareEnabled).map(e=>e.id),examples:{}})}),ne=e=>{o?v.mutate({on:e}):e&&te.mutate()},P=v.isPending||te.isPending,re=v.error??te.error;if(!r)return(0,Q.jsx)(_e,{id:`page`,children:(0,Q.jsx)(Y,{title:X(`space.page`),hint:X(`page.intro`),children:(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-ink-2`,children:X(`page.cloudOnly`)})})});let F=o?.slug||_(A)||`…`,I=qe(r,F),L=lt(r,F,i),ie=(0,Q.jsxs)(`span`,{className:K(Nr,`min-w-0 truncate`),children:[(0,Q.jsxs)(`span`,{className:`text-ink-3`,children:[r,`/`]}),(0,Q.jsx)(`b`,{className:`text-ink`,children:F})]}),R=a||!o,ae=(0,Q.jsxs)(f,{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:X(`page.previewTitle`)}),s?(0,Q.jsx)(ot,{named:!0,label:X(`editor.device`),value:p,onChange:e=>{m(e),Zr(e)},options:[{id:`desktop`,label:X(`editor.deviceDesk`),icon:(0,Q.jsx)(Ut,{className:`size-3.5`})},{id:`tablet`,label:X(`page.deviceTablet`),icon:(0,Q.jsx)(En,{className:`size-3.5`})},{id:`mobile`,label:X(`editor.devicePhone`),icon:(0,Q.jsx)(ft,{className:`size-3.5`})}]}):null]}),s?(0,Q.jsx)(Qr,{url:L,version:l,device:p}):(0,Q.jsx)(`p`,{className:$,children:X(`page.previewOff`)}),s?(0,Q.jsx)(`p`,{className:$,children:X(`page.previewHint`)}):null]}),z=(0,Q.jsxs)(f,{className:`flex flex-col gap-3 p-4`,children:[(0,Q.jsx)(`h3`,{className:`font-medium text-[0.875rem]`,children:X(`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:X(`share.onPage`,{space:o?.title||A})}),(0,Q.jsx)(`span`,{className:K(`block truncate font-mono`,$),children:I})]}),(0,Q.jsx)(ye,{checked:!0,disabled:!0,label:X(`page.showOnPage`),onChange:()=>{}})]}),(0,Q.jsx)(`p`,{className:$,children:X(`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)(_e,{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:X(`space.page`)}),(0,Q.jsx)(`p`,{className:`mt-1 text-[0.875rem] text-ink-3 leading-snug`,children:X(`page.intro`)})]}),(0,Q.jsxs)(f,{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:K(`size-2 shrink-0 rounded-full`,s?`bg-moss`:`bg-ink-4`),"aria-hidden":!0}),ie]}),(0,Q.jsxs)(`span`,{className:`flex w-full items-center gap-2 sm:w-auto sm:shrink-0`,children:[(0,Q.jsxs)(N,{variant:`secondary`,size:`sm`,className:`max-sm:flex-1`,disabled:!s,onClick:()=>S(L),children:[x?(0,Q.jsx)(M,{className:`size-3.5`}):(0,Q.jsx)(Me,{className:`size-3.5`}),X(x?`share.copied`:`share.copyMain`)]}),(0,Q.jsxs)(N,{size:`sm`,className:`max-sm:flex-1`,disabled:!s,onClick:()=>window.open(L,`_blank`,`noopener`),children:[X(`page.open`),` `,(0,Q.jsx)(Dt,{className:`size-3.5`})]})]})]}),(0,Q.jsxs)(Y,{title:X(`page.sectionPage`),locked:a,children:[(0,Q.jsxs)(`fieldset`,{"aria-label":X(`page.sectionPage`),className:`grid min-w-0 gap-3 sm:grid-cols-[repeat(3,minmax(0,1fr))]`,children:[(0,Q.jsx)(Vr,{title:X(`page.whoOff`),text:X(`page.whoOffHint`),picked:!s,disabled:a||P,onPick:()=>ne(!1)}),(0,Q.jsx)(Vr,{title:X(`page.whoPublic`),text:X(`page.whoPublicHint`),picked:s,disabled:a||P,onPick:()=>ne(!0)}),(0,Q.jsx)(Vr,{title:X(`page.whoMembers`),text:X(`page.whoMembersHint`),picked:!1,later:!0,onPick:()=>{}})]}),re?(0,Q.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:re.message}):null]})]})}),ae,(0,Q.jsx)(_e,{id:`page-words`,children:(0,Q.jsx)(Y,{title:X(`page.sectionWords`),hint:o?void 0:X(`page.notYet`),save:o?y:void 0,locked:R,children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[o?(0,Q.jsx)($r,{host:r,page:o,disabled:a,save:g,onState:b},`${e.id}:${o.slug}`):(0,Q.jsx)(Rr,{host:r,disabled:!0,words:{slug:F,title:A,headline:``,intro:``,voice:wt===`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:X(`page.sectionWizards`)}),(0,Q.jsx)(`span`,{className:$,children:X(`page.wizardsHint`)})]}),(0,Q.jsxs)(`ul`,{className:`mt-2 flex flex-col`,children:[T.map((e,t)=>(0,Q.jsx)(Br,{wizard:e,first:t===0,on:!0,disabled:R,onToggle:t=>ee(e.id,t),drag:{onDragStart:()=>O(t),onDragOver:e=>e.preventDefault(),onDrop:()=>{D!==null&&k(D,t),O(null)},onKeyDown:e=>{(e.key===`ArrowUp`||e.key===`ArrowDown`)&&(e.preventDefault(),k(t,e.key===`ArrowUp`?t-1:t+1))}}},e.id)),E.map(e=>(0,Q.jsx)(Br,{wizard:e,first:!1,on:!1,disabled:R,onToggle:t=>ee(e.id,t)},e.id))]}),w.length?null:(0,Q.jsx)(`p`,{className:K(`mt-2`,$),children:X(`page.noWizards`)}),(0,Q.jsx)(`p`,{className:K(`mt-4`,$),children:X(`page.wizardsNote`)})]}),(0,Q.jsx)(Ir,{})]})})})]}),z]})}var ti=`results-search`,ni={q:``,mode:``,days:0};function ri(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 V({queryKey:[`results`,e,i],queryFn:()=>d.get(`/api/studio/projects/${e}/results${i&&`?${i}`}`),enabled:!!e,placeholderData:e=>e,refetchInterval:15e3})}function ii({data:e,wizardId:t,onWizard:n,filter:r,onFilter:i}){let[a,o]=(0,Z.useState)(r.q);return Ot({icon:W,label:X(`space.resultsSearch`),run:()=>{let e=document.getElementById(ti);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)(H,{value:t??``,onChange:e=>n(e||null),options:[{value:``,label:X(`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)(W,{className:`-translate-y-1/2 pointer-events-none absolute top-1/2 left-3 size-4 text-ink-3`}),(0,Q.jsx)(P,{type:`search`,value:a,onChange:e=>o(e.target.value),id:ti,placeholder:X(`space.resultsSearch`),"aria-label":X(`space.resultsSearch`),className:`w-full pl-9`})]}),(0,Q.jsx)(H,{value:r.mode,onChange:e=>i({...r,mode:e}),options:[{value:``,label:X(`space.resultsModeAll`)},{value:`live`,label:`Live`},{value:`test`,label:`Test`}],className:`w-32`}),(0,Q.jsx)(H,{value:String(r.days),onChange:e=>i({...r,days:Number(e)}),options:[{value:`0`,label:X(`space.resultsAnyTime`)},{value:`1`,label:X(`space.resultsDay`)},{value:`7`,label:X(`space.resultsDays`,{n:7})},{value:`30`,label:X(`space.resultsDays`,{n:30})}],className:`w-44`})]})}function ai({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(wt,{dateStyle:`medium`,timeStyle:`short`});return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(Y,{title:t?s(t):X(`space.resultsAll`),hint:X(`space.resultsHint`),plain:!0,children:[(0,Q.jsx)(ii,{data:e,wizardId:t,onWizard:n,filter:r,onFilter:i}),e.runs.length?(0,Q.jsx)(f,{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))} · `,X(`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:X(`space.resultFiles`,{n:e.assets}),children:[(0,Q.jsx)(De,{className:`size-3.5`}),e.assets]}):null,e.mode===`test`?(0,Q.jsx)(g,{children:X(`run.testChip`)}):(0,Q.jsxs)(g,{tone:`live`,children:[`Live v`,e.version]})]},e.id))}):(0,Q.jsx)(f,{children:(0,Q.jsx)(h,{children:r.q.trim()||r.mode||r.days?X(`space.resultsNone`):X(`space.resultsEmpty`)})})]}),a?(0,Q.jsx)(it,{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)(g,{children:X(`run.testChip`)}):(0,Q.jsxs)(g,{tone:`live`,children:[`Live v`,a.version]})]}),onClose:()=>o(null),children:(0,Q.jsx)(pt,{runId:a.id,compact:!0,studio:!0},a.id)}):null]})}var oi={name:64,description:1024,skillMd:1e5,file:256e3,total:1e6,files:100,perSpace:100,always:5,alwaysChars:2e4,listed:50,blobFile:5e6,blobTotal:2e7,blobFiles:200};function si(e){return!e||e.length>200||e.startsWith(`/`)||e.includes(`\\`)?!1:e.split(`/`).every(e=>e!==``&&e!==`.`&&e!==`..`&&/^[\w.@+ -]+$/.test(e))}var ci=/\.(py|sh|bash|zsh|js|mjs|cjs|ts|rb|php|go|rs)$/i;function li(e){return ci.test(e)}var ui=class extends Error{problem;constructor(e){super(`SKILL.md: ${e}`),this.problem=e}};function di(e){let t=e.trim();if(t.length>=2&&t.startsWith(`"`)&&t.endsWith(`"`))try{return JSON.parse(t)}catch{return t.slice(1,-1)}return t.length>=2&&t.startsWith(`'`)&&t.endsWith(`'`)?t.slice(1,-1).replace(/''/g,`'`):t}function fi(e,t){let n=Math.min(...t.filter(e=>e.trim()).map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(Number.isFinite(n)?n:0)),i;return i=e.startsWith(`|`)?r.join(`
|
|
3
|
-
`):r.join(`
|
|
4
|
-
`).replace(/([^\n])\n(?!\n)/g,`$1 `).replace(/\n\n/g,`
|
|
5
|
-
`),e.includes(`-`)?i.replace(/\s+$/,``):`${i.replace(/\n*$/,``)}\n`}function pi(e){let t={},n=e.replace(/\r\n?/g,`
|
|
6
|
-
`).split(`
|
|
7
|
-
`),r=0,i=e=>{let t=[],r=e;for(;r<n.length&&(n[r].trim()===``||/^\s/.test(n[r]));)t.push(n[r]),r++;for(;t.length&&t[t.length-1].trim()===``;)t.pop(),r--;return{taken:t,next:r}};for(;r<n.length;){let e=n[r],a=/^([A-Za-z_][\w.-]*)\s*:(.*)$/.exec(e);if(!a||e.trimStart().startsWith(`#`)){r++;continue}let o=a[1],s=a[2].trim(),{taken:c,next:l}=i(r+1);if(r=l,/^[|>][+-]?\d*$/.test(s))t[o]=fi(s,c);else if(s===``&&c.length){let e=c.filter(e=>e.trim());if(e.every(e=>/^\s*-\s/.test(e)))t[o]=e.map(e=>di(e.replace(/^\s*-\s/,``)));else{let n={};for(let t of e){let e=/^\s*([^:#]+?)\s*:\s*(.*)$/.exec(t);e&&(n[e[1]]=di(e[2]))}t[o]=n}}else t[o]=s.startsWith(`[`)&&s.endsWith(`]`)?s.slice(1,-1).split(`,`).map(e=>di(e)).filter(Boolean):/^["']/.test(s)&&!/^(["']).*\1\s*$/.test(s)?di([s,...c.map(e=>e.trim())].join(` `)):di([s,...c.map(e=>e.trim()).filter(Boolean)].join(` `))}return t}var mi=/^?---[ \t]*\r?\n([\s\S]*?)\r?\n---[ \t]*(?:\r?\n|$)/;function hi(e){let t=mi.exec(e);if(!t)throw new ui(`frontmatter`);let n=pi(t[1]),r=typeof n.name==`string`?n.name.trim():``,i=typeof n.description==`string`?n.description.replace(/\s+/g,` `).trim():``;if(!r)throw new ui(`name`);if(!i)throw new ui(`description`);let{name:a,description:o,...s}=n;return{name:r,description:i,body:e.slice(t[0].length).replace(/^\s*\n/,``),meta:s}}function gi(e,t=``){return Array.isArray(e)?`\n${e.map(e=>`${t} - ${_i(String(e))}`).join(`
|
|
8
|
-
`)}`:e&&typeof e==`object`?`\n${Object.entries(e).map(([e,n])=>`${t} ${e}: ${_i(String(n))}`).join(`
|
|
9
|
-
`)}`:` ${_i(String(e??``))}`}function _i(e){return/^[^\s"'#&*!|>%@`{}[\],?:-][^\n#]*$/.test(e)&&!/:\s|\s$/.test(e)&&!/^(true|false|null|yes|no|~|[\d.+-]+)$/i.test(e)?e:JSON.stringify(e)}function vi(e){let t=Object.entries(e.meta??{}).filter(([,e])=>e!=null).map(([e,t])=>`${e}:${gi(t)}`);return[`---`,`name: ${_i(e.name)}`,`description: ${_i(e.description)}`,...t,`---`,``,e.body.replace(/^\n+/,``)].join(`
|
|
10
|
-
`)}function yi(e){return e.toLowerCase().replace(/ä/g,`ae`).replace(/ö/g,`oe`).replace(/ü/g,`ue`).replace(/ß/g,`ss`).normalize(`NFKD`).replace(/[̀-ͯ]/g,``).replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``).slice(0,oi.name).replace(/-+$/,``)}new TextEncoder;function bi(e){return V({queryKey:j.skills(e),queryFn:()=>d.get(`/api/studio/projects/${e}/skills`),enabled:!!e})}var xi={always:Ve,demand:q,off:mn},Si=[`always`,`demand`,`off`];function Ci({value:e,onChange:t,disabled:n}){return(0,Q.jsx)(`fieldset`,{"aria-label":X(`skills.modeLabel`),className:`m-0 min-w-0 border-0 p-0 inline-flex shrink-0 rounded-full bg-paper-2 p-0.5 text-[0.75rem]`,children:Si.map(r=>{let i=r===e;return(0,Q.jsx)(`button`,{type:`button`,"aria-pressed":i,disabled:n,onClick:()=>!i&&t(r),className:K(`h-7 rounded-full px-2.5 transition disabled:pointer-events-none coarse:h-9`,i?`bg-card font-medium text-ink shadow-soft`:`text-ink-3 hover:text-ink`,n&&!i&&`opacity-60`),children:X(`skills.mode.${r}`)},r)})})}function wi({skill:e}){if(e.source===`skills.sh`&&e.origin){let t=e.origin.split(`/`).slice(0,2).join(`/`);return e.official?(0,Q.jsx)(g,{tone:`live`,icon:(0,Q.jsx)(on,{className:`size-3`}),children:t}):(0,Q.jsx)(g,{tone:`warn`,children:t})}return(0,Q.jsx)(g,{children:e.source===`upload`?X(`skills.uploaded`):X(`skills.own`)})}var Ti=e=>e?X(`skills.files`,{n:e}):``;function Ei({skill:e,readOnly:t,onOpen:n,onMode:r}){return(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2 px-3 py-3 sm:flex-nowrap`,children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>n(`k:${e.id}`),className:`min-w-0 flex-1 rounded-lg text-left max-sm:basis-full`,children:[(0,Q.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:K(`font-medium font-mono text-[0.8125rem] hover:underline`,e.mode===`off`&&`text-ink-3`),children:e.name}),(0,Q.jsx)(wi,{skill:e}),e.files?(0,Q.jsx)(`span`,{className:`text-[0.75rem] text-ink-3`,children:Ti(e.files)}):null]}),(0,Q.jsx)(`span`,{className:`mt-0.5 block truncate text-[0.8125rem] text-ink-3`,children:e.description})]}),(0,Q.jsx)(Ci,{value:e.mode,onChange:r,disabled:t})]})}function Di({icon:e,label:t,hint:n,onPick:r}){return(0,Q.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:r,className:`flex w-full items-start gap-2.5 rounded-lg px-2.5 py-2 text-left transition hover:bg-accent`,children:[(0,Q.jsx)(e,{className:`mt-0.5 size-4 shrink-0 text-ink-3`}),(0,Q.jsxs)(`span`,{className:`min-w-0`,children:[(0,Q.jsx)(`span`,{className:`block font-medium text-[0.8125rem]`,children:t}),(0,Q.jsx)(`span`,{className:`block text-[0.75rem] text-ink-3`,children:n})]})]})}function Oi({onRegistry:e,onWrite:t,onUpload:n}){let[r,i]=(0,Z.useState)(!1),a=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{if(!r)return;let e=e=>{a.current?.contains(e.target)||i(!1)},t=e=>e.key===`Escape`&&i(!1);return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[r]);let o=e=>()=>{i(!1),e()};return(0,Q.jsxs)(`div`,{className:`relative`,ref:a,children:[(0,Q.jsxs)(N,{size:`sm`,"aria-haspopup":`menu`,"aria-expanded":r,onClick:()=>i(e=>!e),children:[(0,Q.jsx)(B,{className:`size-4`}),` `,X(`skills.add`),(0,Q.jsx)(te,{className:`-mr-1 size-4`})]}),r?(0,Q.jsxs)(`div`,{role:`menu`,className:`absolute top-10 right-0 z-50 w-72 animate-rise rounded-xl bg-card p-1.5 shadow-overlay ring-1 ring-border-soft`,children:[(0,Q.jsx)(Di,{icon:W,label:X(`skills.fromRegistry`),hint:X(`skills.fromRegistryHint`),onPick:o(e)}),(0,Q.jsx)(Di,{icon:ke,label:X(`skills.write`),hint:X(`skills.writeHint`),onPick:o(t)}),(0,Q.jsx)(Di,{icon:Ct,label:X(`skills.upload`),hint:X(`skills.uploadHint`),onPick:o(n)})]}):null]})}var ki=`.md,.zip,.skill`;function Ai(e,t){let n=C(),[r,i]=(0,Z.useState)(null);return{upload:Re({mutationFn:t=>d.upload(`/api/studio/projects/${e}/skills/upload`,t),onSuccess:async r=>{await n.invalidateQueries({queryKey:j.skills(e)}),i(r.skipped.length?X(`skills.uploadedSkipped`,{name:r.name,paths:r.skipped.map(e=>e.path).join(`, `)}):null),t(`k:${r.id}`)}}),note:r}}function ji({projectId:e,data:t,onOpen:n}){let r=C(),i=t.readOnly,[a,o]=(0,Z.useState)(``),[s,c]=(0,Z.useState)(null),[l,u]=(0,Z.useState)(!1),p=(0,Z.useRef)(null),{upload:m,note:g}=Ai(e,n),_=Re({mutationFn:({id:e,mode:t})=>d.patch(`/api/studio/skills/${e}`,{mode:t}),onSettled:()=>r.invalidateQueries({queryKey:j.skills(e)})}),v=a.trim().toLowerCase(),y=v?t.skills.filter(e=>e.name.includes(v)||e.description.toLowerCase().includes(v)):t.skills,b=y.filter(e=>e.mode===`always`),x=t.skills.filter(e=>e.mode===`always`),S=x.reduce((e,t)=>e+t.chars,0),w=[{mode:`always`,title:X(`skills.mode.always`),hint:X(`skills.alwaysCount`,{n:x.length,max:oi.always,chars:S.toLocaleString(wt),maxChars:oi.alwaysChars.toLocaleString(wt)}),items:b},{mode:`demand`,title:X(`skills.mode.demand`),hint:X(`skills.demandHint`),items:y.filter(e=>e.mode===`demand`)},{mode:`off`,title:X(`skills.mode.off`),items:y.filter(e=>e.mode===`off`)}],T=e=>{for(let t of e.slice(0,1))m.mutate(t)};return(0,Q.jsxs)(Y,{title:X(`space.skills`),hint:X(`skills.hint`),plain:!0,action:i?null:(0,Q.jsx)(Oi,{onRegistry:()=>c(a),onWrite:()=>u(!0),onUpload:()=>p.current?.click()}),children:[(0,Q.jsxs)(`div`,{onDragOver:e=>{i||(e.preventDefault(),e.currentTarget.dataset.over=`1`)},onDragLeave:e=>{delete e.currentTarget.dataset.over},onDrop:e=>{e.preventDefault(),delete e.currentTarget.dataset.over,i||T(Array.from(e.dataTransfer.files))},className:`flex flex-col items-center gap-3 rounded-2xl border border-input border-dashed bg-paper px-4 py-5 transition data-[over]:border-focus data-[over]:bg-paper-2 sm:px-6`,children:[(0,Q.jsxs)(`form`,{className:`flex h-11 w-full max-w-2xl items-center gap-2 rounded-full border border-input bg-card pr-1.5 pl-4 shadow-soft focus-within:border-focus focus-within:ring-4 focus-within:ring-focus-glow`,onSubmit:e=>{e.preventDefault(),c(a)},children:[(0,Q.jsx)(W,{className:`size-4 shrink-0 text-ink-3`}),(0,Q.jsx)(`input`,{type:`search`,value:a,"aria-label":X(`skills.search`),placeholder:X(`skills.search`),onChange:e=>o(e.target.value),className:`min-w-0 flex-1 bg-transparent text-[0.875rem] text-ink outline-none placeholder:text-ink-4`}),(0,Q.jsx)(N,{type:`submit`,size:`sm`,children:X(`skills.searchButton`)})]}),i?null:(0,Q.jsxs)(`span`,{className:`flex flex-wrap items-center justify-center gap-x-2 gap-y-1 text-center text-[0.8125rem] text-ink-3`,children:[m.isPending?(0,Q.jsx)(xe,{className:`size-4`}):(0,Q.jsx)(Ct,{className:`size-4`}),X(`skills.drop`),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>p.current?.click(),className:`underline hover:text-ink`,children:X(`skills.pick`)})]})]}),(0,Q.jsx)(`input`,{ref:p,type:`file`,accept:ki,className:`sr-only`,tabIndex:-1,"aria-hidden":!0,onChange:e=>{T(Array.from(e.target.files??[])),e.target.value=``}}),m.error?(0,Q.jsx)(`p`,{className:`px-1 text-[0.875rem] text-rose`,children:m.error.message}):null,g?(0,Q.jsx)(`p`,{className:`px-1 text-[0.8125rem] text-ink-3`,children:g}):null,_.error?(0,Q.jsx)(`p`,{className:`px-1 text-[0.875rem] text-rose`,children:_.error.message}):null,t.skills.length===0?(0,Q.jsx)(f,{children:(0,Q.jsx)(h,{children:X(`skills.empty`)})}):y.length===0?(0,Q.jsx)(f,{children:(0,Q.jsx)(h,{children:X(`skills.noneHere`)})}):w.filter(e=>e.items.length||e.mode===`always`&&!v).map(e=>(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-3 px-1`,children:[(0,Q.jsx)(`h3`,{className:`font-semibold text-[0.875rem]`,children:e.title}),e.hint?(0,Q.jsx)(`span`,{className:`text-[0.75rem] text-ink-3`,children:e.hint}):null]}),e.items.length?(0,Q.jsx)(f,{className:`flex flex-col divide-y divide-border-soft`,children:e.items.map(e=>(0,Q.jsx)(Ei,{skill:e,readOnly:i,onOpen:n,onMode:t=>_.mutate({id:e.id,mode:t})},e.id))}):null]},e.mode)),(0,Q.jsx)(Fi,{projectId:e,query:s,onClose:()=>c(null),onAdded:e=>{c(null),n(`k:${e}`)}}),(0,Q.jsx)(Mi,{projectId:e,open:l,onClose:()=>u(!1),onMade:e=>{u(!1),n(`k:${e}`)}})]})}function Mi({projectId:e,open:t,onClose:n,onMade:r}){let i=C(),[a,o]=(0,Z.useState)(``),[s,c]=(0,Z.useState)(``),l=Re({mutationFn:()=>d.post(`/api/studio/projects/${e}/skills`,{name:yi(a),description:s.trim(),body:`# ${a.trim()}\n\n`}),onSuccess:async({id:t})=>{await i.invalidateQueries({queryKey:j.skills(e)}),o(``),c(``),r(t)}}),u=yi(a)&&s.trim();return(0,Q.jsx)(J,{open:t,onClose:n,title:X(`skills.newTitle`),children:(0,Q.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),u&&l.mutate()},children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(L,{children:X(`skills.name`)}),(0,Q.jsx)(P,{"data-autofocus":!0,value:a,maxLength:oi.name,placeholder:X(`skills.namePlaceholder`),onChange:e=>o(e.target.value),className:`font-mono`}),(0,Q.jsx)(`p`,{className:`mt-1 text-[0.75rem] text-ink-3`,children:yi(a)&&yi(a)!==a?yi(a):X(`skills.nameHint`)})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(L,{children:X(`skills.description`)}),(0,Q.jsx)(P,{value:s,maxLength:oi.description,placeholder:X(`skills.descPlaceholder`),onChange:e=>c(e.target.value)}),(0,Q.jsx)(`p`,{className:`mt-1 text-[0.75rem] text-ink-3`,children:X(`skills.descHint`)})]}),l.error?(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:l.error.message}):null,(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Q.jsx)(N,{variant:`ghost`,onClick:n,children:X(`common.cancel`)}),(0,Q.jsx)(N,{type:`submit`,busy:l.isPending,disabled:!u,children:X(`skills.create`)})]})]})})}function Ni({files:e,skipped:t}){let n=e.filter(e=>li(e.path));return n.length||t.length?(0,Q.jsxs)(`ul`,{className:`flex flex-col gap-1 text-[0.75rem] text-ink-3`,children:[n.map(e=>(0,Q.jsx)(`li`,{children:X(`skills.scriptNote`,{path:e.path})},e.path)),t.map(e=>(0,Q.jsx)(`li`,{children:X(e.reason===`binary`?`skills.skippedBinary`:e.reason===`size`?`skills.skippedSize`:`skills.skippedOther`,{path:e.path})},e.path))]}):null}var Pi=e=>`${(e/1e3).toLocaleString(wt,{maximumFractionDigits:1})} KB`;function Fi({projectId:e,query:t,onClose:n,onAdded:r}){let i=C(),[a,o]=(0,Z.useState)(``),[s,c]=(0,Z.useState)(``),[l,u]=(0,Z.useState)(!0),[f,p]=(0,Z.useState)(null),[m,_]=(0,Z.useState)(`demand`),[v,y]=(0,Z.useState)(`skill`);(0,Z.useEffect)(()=>{t!==null&&(o(t),c(t.trim()),p(null))},[t]);let b=V({queryKey:[`skills-registry`,e,s],queryFn:()=>d.get(`/api/studio/projects/${e}/skills/registry?q=${encodeURIComponent(s)}`),enabled:t!==null&&s.length>=2,staleTime:6e4}),x=V({queryKey:[`skills-preview`,e,f],queryFn:()=>d.get(`/api/studio/projects/${e}/skills/registry/preview?ref=${encodeURIComponent(f??``)}`),enabled:!!f}),S=Re({mutationFn:()=>d.post(`/api/studio/projects/${e}/skills/registry`,{ref:f,mode:m}),onSuccess:async({id:t})=>{await i.invalidateQueries({queryKey:j.skills(e)}),p(null),r(t)}}),w=(b.data?.hits??[]).filter(e=>!l||e.official),T=x.data;return(0,Q.jsx)(J,{open:t!==null,onClose:n,wide:!0,height:`tall`,title:X(`skills.registryTitle`),children:f?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Q.jsx)(`div`,{children:(0,Q.jsxs)(N,{variant:`ghost`,size:`sm`,className:`-ml-3`,onClick:()=>{p(null),S.reset()},children:[(0,Q.jsx)(re,{className:`size-4`}),` `,X(`skills.results`)]})}),T?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`h2`,{className:`font-medium font-mono text-lg`,children:T.name}),T.official?(0,Q.jsx)(g,{tone:`live`,icon:(0,Q.jsx)(on,{className:`size-3`}),children:X(`skills.official`)}):(0,Q.jsx)(g,{tone:`warn`,children:X(`skills.unchecked`)})]}),(0,Q.jsxs)(`p`,{className:`text-[0.8125rem] text-ink-3`,children:[(0,Q.jsx)(`a`,{href:`https://github.com/${T.ref.split(`/`).slice(0,2).join(`/`)}`,target:`_blank`,rel:`noreferrer`,className:`underline hover:text-ink`,children:T.ref.split(`/`).slice(0,2).join(`/`)}),` `,X(`skills.onGithub`)]}),(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-ink-2`,children:T.description}),T.official?null:(0,Q.jsx)(`p`,{className:`rounded-lg bg-amber-tint px-3 py-2 text-[0.8125rem] text-ink-2`,children:X(`skills.uncheckedWarn`)}),(0,Q.jsx)(`div`,{className:`flex gap-1 border-border-soft border-b`,role:`tablist`,children:[`skill`,`files`].map(e=>(0,Q.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":v===e,onClick:()=>y(e),className:K(`-mb-px h-9 border-b-2 px-2.5 text-[0.8125rem]`,v===e?`border-ink font-medium text-ink`:`border-transparent text-ink-3 hover:text-ink`),children:e===`skill`?`SKILL.md`:X(`skills.tabFiles`,{n:T.fileList.length+T.blobList.length})},e))}),(0,Q.jsx)(`div`,{children:v===`skill`?(0,Q.jsx)(`div`,{className:`rounded-lg bg-paper-2 p-4`,children:(0,Q.jsx)(Ae,{text:T.body})}):(0,Q.jsxs)(`ul`,{className:`flex flex-col divide-y divide-border-soft rounded-lg ring-1 ring-border-soft`,children:[T.fileList.map(e=>(0,Q.jsxs)(`li`,{className:`flex items-center gap-2 px-3 py-2`,children:[(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-[0.8125rem]`,children:e.path}),(0,Q.jsx)(`span`,{className:`text-[0.75rem] text-ink-3`,children:Pi(e.text.length)})]},e.path)),T.blobList.map(e=>(0,Q.jsxs)(`li`,{className:`flex items-center gap-2 px-3 py-2`,children:[(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-[0.8125rem]`,children:e.path}),(0,Q.jsxs)(`span`,{className:`text-[0.75rem] text-ink-3`,children:[X(`skills.forScripts`),` · `,Pi(e.bytes)]})]},e.path))]})}),(0,Q.jsx)(Ni,{files:T.fileList,skipped:T.skipped}),S.error?(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:S.error.message}):null,(0,Q.jsxs)(`div`,{className:`-mx-5 sm:-mx-7 -mb-5 sm:-mb-7 -bottom-5 sm:-bottom-7 sticky flex flex-wrap items-center gap-3 border-border-soft border-t bg-card px-5 pt-3 pb-5 sm:px-7 sm:pb-7`,children:[(0,Q.jsx)(Ci,{value:m===`off`?`demand`:m,onChange:_}),(0,Q.jsx)(`span`,{className:`flex-1 text-[0.75rem] text-ink-3`,children:[Pi(T.bytes),Ti(T.fileList.length+T.blobList.length)].filter(Boolean).join(` · `)}),(0,Q.jsx)(N,{busy:S.isPending,onClick:()=>S.mutate(),children:X(`skills.add`)})]})]}):x.error?(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:x.error.message}):(0,Q.jsx)(`div`,{className:`flex justify-center py-16`,children:(0,Q.jsx)(xe,{className:`size-5`})})]}):(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Q.jsx)(`p`,{className:`-mt-3 text-[0.875rem] text-ink-3`,children:X(`skills.registryHint`)}),(0,Q.jsx)(`form`,{onSubmit:e=>{e.preventDefault(),c(a.trim())},children:(0,Q.jsxs)(`div`,{className:`relative`,children:[(0,Q.jsx)(W,{className:`-translate-y-1/2 pointer-events-none absolute top-1/2 left-3 size-4 text-ink-4`}),(0,Q.jsx)(P,{"data-autofocus":!0,type:`search`,value:a,"aria-label":X(`skills.searchButton`),placeholder:X(`skills.registrySearch`),onChange:e=>o(e.target.value),className:`pl-9`})]})}),(0,Q.jsxs)(`label`,{className:`flex items-center gap-2.5 text-[0.8125rem] text-ink-2`,children:[(0,Q.jsx)(ye,{checked:l,onChange:u}),X(`skills.onlyOfficial`),(0,Q.jsx)(`span`,{className:`flex-1`}),b.data?(0,Q.jsx)(`span`,{className:`text-ink-3`,children:X(`skills.hits`,{n:w.length})}):null]}),(0,Q.jsx)(`div`,{className:`-mx-2`,children:s.length<2?(0,Q.jsx)(h,{children:X(`skills.registryStart`)}):b.isLoading?(0,Q.jsx)(`div`,{className:`flex justify-center py-16`,children:(0,Q.jsx)(xe,{className:`size-5`})}):b.error?(0,Q.jsx)(`p`,{className:`px-2 text-[0.875rem] text-rose`,children:b.error.message}):w.length?(0,Q.jsx)(`ul`,{className:`flex flex-col`,children:w.map(e=>(0,Q.jsxs)(`li`,{className:`flex items-center gap-3 rounded-lg px-2 py-2.5`,children:[(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`font-medium font-mono text-[0.8125rem]`,children:e.name}),e.official?(0,Q.jsx)(g,{tone:`live`,icon:(0,Q.jsx)(on,{className:`size-3`}),children:X(`skills.official`)}):(0,Q.jsx)(g,{tone:`warn`,children:X(`skills.unchecked`)})]}),(0,Q.jsxs)(`span`,{className:`block truncate text-[0.75rem] text-ink-3`,children:[e.source,` · `,X(`skills.installs`,{n:e.installs.toLocaleString(wt)})]})]}),e.added?(0,Q.jsx)(`span`,{className:`text-[0.75rem] text-ink-3`,children:X(`skills.inSpace`)}):null,(0,Q.jsx)(N,{variant:`secondary`,size:`sm`,onClick:()=>{y(`skill`),_(`demand`),p(e.ref)},children:X(`skills.open`)})]},e.ref))}):(0,Q.jsx)(h,{children:X(`skills.registryNone`)})}),(0,Q.jsxs)(`p`,{className:`flex items-start gap-2 border-border-soft border-t pt-3 text-[0.75rem] text-ink-3`,children:[(0,Q.jsx)(on,{className:`mt-0.5 size-3.5 shrink-0`}),X(`skills.officialNote`)]})]})})}function Ii({title:e,children:t}){return(0,Q.jsxs)(`div`,{className:`flex min-h-8 items-center gap-2 px-1`,children:[(0,Q.jsx)(`h3`,{className:`flex-1 font-semibold text-[0.875rem]`,children:e}),t]})}function Li(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=zt(),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 Ri(){let[e,t]=(0,Z.useState)(null);return(0,Z.useEffect)(()=>{let e=zt(),n=()=>t(e.clientHeight);n();let r=new ResizeObserver(n);return r.observe(e),()=>r.disconnect()},[]),e}function zi(e,t){let n=window.matchMedia(`(prefers-reduced-motion: reduce)`).matches;document.getElementById(e)?.scrollIntoView({block:`start`,behavior:t&&!n?`smooth`:`auto`})}function Bi({groups:e,current:t,onPick:n}){return e.map(e=>{let r=e.sections.map(e=>(0,Q.jsx)(Ft,{icon:e.icon??Le,label:e.label,selected:e.id===t,onPick:()=>n(e.id)},e.id));return e.label?(0,Q.jsx)(Lt,{label:e.label,children:r},e.plugin):(0,Q.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:r},`own`)})}var Vi=(0,Z.lazy)(()=>ze(()=>import(`./SkillEditor-BzzTDeaU.js`).then(e=>({default:e.SkillEditor})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24])));function Hi(){let{group:e}=ge(),[t,n]=be(),r=ae(),i=le(),{hash:a}=i,{project:o,loading:s}=vt(),c=en(),l=$t(),[u,d]=(0,Z.useState)(null),[f,p]=(0,Z.useState)(null),[m,g]=(0,Z.useState)(null),_=Wt(e)?e:void 0,v=_?void 0:c.spaceParts.find(t=>t.id===e),y=_??v?.id,b=i.state?.parts===!0,x=It(`pages`),S=It(`skills`),C=qt().filter(e=>(x||e.id!==`page`)&&(S||e.id!==`skills`)),w=Kt(C,c).map(e=>({...e,to:`/space/${e.id}`})),T={id:`results`,label:X(`space.results`),icon:Nt,to:`/space/results`},E=_===`results`?T:w.find(e=>e.id===y),D=t.get(`show`),O=_===`results`?2:y?D?2:1:0,k=_===`results`?1:l?Math.min(O,1):y&&m!==y&&!b?1:0,ee=Zt(k),A=Zt(O),te=(0,Z.useMemo)(()=>({slot:u,narrow:l,setDetail:p}),[u,l]),ne=o?o.brand.name?.trim()||o.name:X(`nav.space`),j=It(`typography`)?[]:[`typography`],M=v?c.spaceMenus[v.id]??[]:[],N=v?[{plugin:null,label:null,sections:M}]:_&&_!==`results`?Yt(_,c,j):[],P=_?Yt(_,c).filter(e=>e.plugin):[],re=Li([...N,..._===`results`?P:[]].flatMap(e=>e.sections.map(e=>e.id))),F=_===`results`&&D&&D!==`all`?D:null,[I,L]=(0,Z.useState)(ni),ie=ri(_===`results`?o?.id:void 0,F,I),R=ie.data?.wizards.find(e=>e.id===F)?.title,z=_===`data`&&D&&D!==`all`||_===`knowledge`&&D&&/^[ptfcvs]:/.test(D)?D:null,B=z?.startsWith(`s:`)?c.spaceSections.find(e=>e.id===z.slice(2)):void 0,V=_===`knowledge`&&z&&/^[ptf]:/.test(z)?z:null,oe=_===`skills`&&D?.startsWith(`k:`)?D:null,H=bi(_===`skills`&&S?o?.id:void 0),se=Je(_===`data`?o?.id:void 0),U=tt(_===`knowledge`?o?.id:void 0),W=ct(z?.startsWith(`v:`)?z.slice(2):``),G=U.data?.categories.find(e=>e.id===(z?.startsWith(`c:`)?z.slice(2):W.data?.category.id)),ce=_===`skills`?H.data?.skills.find(e=>`k:${e.id}`===oe)?.name:_===`knowledge`?B?B.label():z?.startsWith(`v:`)?W.data&&`${W.data.category.name}: ${W.data.value}`:z?.startsWith(`c:`)?G?.name:U.data?.items.find(e=>e.key===z)?.title:se.data?at(se.data).flatMap(e=>e.items).find(e=>e.key===z)?.title:void 0;nn([..._===`results`?[]:[{label:X(`nav.sources`),to:`/space`}],...E?[{label:E.label,to:`/space/${E.id}`}]:[],...E&&(f??R??ce)?[{label:f??R??ce}]:[]]);let ue={p:`page`,t:`table`,f:`file`,c:`category`,v:`category value`,s:`plugin section`};kt({..._===`data`||_===`results`?{compact:!0}:{},..._===`data`?{suggestions:[{label:X(`assistant.suggest.dataWhat`)},{label:X(`assistant.suggest.dataWho`)},{label:X(`assistant.suggest.dataEdit`)}]}:_===`results`?{suggestions:[{label:X(`assistant.suggest.resultsFailed`)},{label:X(`assistant.suggest.resultsCost`)},{label:X(`assistant.suggest.resultsShare`)}]}:{},...z&&ce?{open:{kind:ue[z[0]]??`item`,id:z.slice(2),label:ce}}:F&&R?{open:{kind:`wizard`,id:F,label:R}}:{}});let de=_===`results`||_===`data`||z?a.slice(1):D||a.slice(1),fe=(0,Z.useRef)(``);(0,Z.useEffect)(()=>{let e=`${y}#${de}`;de&&fe.current!==e&&document.getElementById(de)&&(fe.current=e,requestAnimationFrame(()=>zi(de,!1)))},[y,de,o?.id,c.spaceSections,M.length]),(0,Z.useEffect)(()=>{!l&&(y===`knowledge`||y===`data`||y===`skills`)&&zt().scrollTo({top:0})},[l,y,z,oe]);let pe=Ri();if(!y){let t=a.slice(1),n=t?Ht(t,c):null;if(n===`knowledge`&&c.spaceSections.some(e=>e.id===t))return(0,Q.jsx)(Se,{to:`/space/knowledge?show=s:${t}`,replace:!0});if(n)return(0,Q.jsx)(Se,{to:l?`/space/${n}?show=${t}`:{pathname:`/space/${n}`,hash:t},replace:!0});if((t||e)&&c.status!==`ready`)return null;if(e!==void 0||!l)return(0,Q.jsx)(Se,{to:`/space/info`,replace:!0,state:{parts:!0}})}let me=_===`info`?D??a.slice(1):``;if(me&&Ht(me,c)===`brand`)return(0,Q.jsx)(Se,{to:l?`/space/brand?show=${me}`:{pathname:`/space/brand`,hash:me},replace:!0});if(_===`skills`&&!S)return(0,Q.jsx)(Se,{to:`/space/info`,replace:!0});if(_===`knowledge`&&!D&&c.spaceSections.some(e=>e.id===a.slice(1)))return(0,Q.jsx)(Se,{to:`/space/knowledge?show=s:${a.slice(1)}`,replace:!0});let he=e=>{if(l){r({search:`?show=${e}`});return}fe.current=`${y}#${e}`,zi(e,!0),r({search:``,hash:e},{replace:!0})},q=e=>l?n({show:e}):n(e===`all`?{}:{show:e},{replace:!0}),ve=e=>e.flatMap(e=>e.sections).map(e=>c.spaceSections.find(t=>t.id===e.id)).filter(e=>e!==void 0).map(e=>(0,Q.jsx)(_e,{id:e.id,children:(0,Q.jsx)(Y,{title:e.label(),hint:e.hint?.(),plain:!0,children:(0,Q.jsx)(Qt,{of:e,children:(0,Q.jsx)(e.component,{})})})},e.serial)),J=l?void 0:re,ye=(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Xt,{title:ne,open:k===1?E??null:null,onBack:_===`results`?void 0:()=>l?r(`/space`):g(y??null),root:{icon:rn,label:X(`nav.sources`),backLabel:X(`nav.wizards`),onBack:()=>r(`/`)}}),(0,Q.jsx)(`div`,{className:K(Et(ee)),children:k===0?(0,Q.jsx)(At,{entries:w,current:l?void 0:E,onPick:()=>g(null)}):(0,Q.jsx)(`div`,{ref:d})},k)]});return(0,Q.jsx)(Rt.Provider,{value:te,children:(0,Q.jsx)(`div`,{className:`animate-rise`,children:(0,Q.jsxs)(`div`,{className:K(`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:K(`min-w-0 md:sticky md:top-6 md:self-start md:overflow-y-auto md:overscroll-contain`,l&&O===2&&`hidden`,l&&A===`back`&&Et(`back`)),style:!l&&pe?{maxHeight:pe-48,paddingBottom:`var(--assistant-dock, 0px)`}:void 0,children:ye}),y?(0,Q.jsxs)(`div`,{className:K(`min-w-0`,l&&O<2&&`hidden`,l&&A===`deeper`&&Et(`deeper`)),children:[l&&_!==`results`?(0,Q.jsx)(`div`,{className:`mb-3`,children:(0,Q.jsx)(jt,{label:E?.label??ne,onBack:()=>r(`/space/${y}`)})}):null,_===`data`?(0,Q.jsxs)(Mt,{children:[(0,Q.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:(0,Q.jsx)(Ft,{icon:Bt,label:X(`data.all`),selected:!l&&!z,onPick:()=>q(`all`)})}),se.data?at(se.data).map(e=>(0,Q.jsx)(Lt,{label:e.label,children:e.items.map(e=>(0,Q.jsx)(Ft,{icon:Ke[e.kind],label:e.title,selected:!l&&e.key===z,onPick:()=>q(e.key)},e.key))},e.key)):null,(0,Q.jsx)(Bi,{groups:P,current:J,onPick:he})]}):_===`knowledge`?(0,Q.jsxs)(Mt,{children:[(0,Q.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:(0,Q.jsx)(Ft,{icon:Bt,label:X(`know.all`),selected:!(l||z),onPick:()=>q(`all`)})}),U.data?.categories.length?(0,Q.jsx)(Lt,{label:X(`know.categories`),children:U.data.categories.map(e=>(0,Q.jsx)(Ft,{icon:Qe[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:!l&&(z===`c:${e.id}`||W.data?.category.id===e.id),onPick:()=>q(`c:${e.id}`)},e.id))}):null,(0,Q.jsx)(Bi,{groups:P,current:l?void 0:B?.id,onPick:e=>q(`s:${e}`)})]}):_===`skills`?(0,Q.jsxs)(Mt,{children:[(0,Q.jsxs)(`ul`,{className:`flex flex-col gap-0.5`,children:[(0,Q.jsx)(Ft,{icon:Bt,label:X(`skills.all`),selected:!(l||oe),onPick:()=>q(`all`)}),H.data?.skills.map(e=>(0,Q.jsx)(Ft,{icon:xi[e.mode],label:e.name,selected:!l&&oe===`k:${e.id}`,onPick:()=>q(`k:${e.id}`)},e.id))]}),(0,Q.jsx)(Bi,{groups:P,current:J,onPick:he})]}):(0,Q.jsx)(Mt,{children:(0,Q.jsx)(Bi,{groups:N,current:J,onPick:he})}),o&&(_===`info`||_===`brand`||_===`knowledge`)?(0,Q.jsxs)(jr,{project:o,group:_,top:!z||!!B,children:[_===`knowledge`?V?V.startsWith(`p:`)?(0,Q.jsx)(et,{pageId:V.slice(2),onGone:()=>q(`all`),onOpen:q},V):V.startsWith(`t:`)?(0,Q.jsx)($e,{tableId:V.slice(2),onGone:()=>q(`all`)},V):(0,Q.jsx)(zn,{projectId:o.id,fileId:V.slice(2),readOnly:o.readOnly,onGone:()=>q(`all`)},V):U.data?B?(0,Q.jsx)(Y,{title:B.label(),hint:B.hint?.(),plain:!0,children:(0,Q.jsx)(Qt,{of:B,children:(0,Q.jsx)(B.component,{})})},z):z?.startsWith(`c:`)?G?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsx)(Ze,{projectId:o.id,category:G,readOnly:o.readOnly,onOpen:q,onGone:()=>q(`all`)}),G.type===`choice`?null:(0,Q.jsx)(st,{projectId:o.id,category:G,categories:U.data.categories,onOpen:q})]},z):null:z?.startsWith(`v:`)?W.data?(0,Q.jsx)(Ge,{value:W.data,readOnly:o.readOnly,children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[W.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:W.data.items.map(e=>(0,Q.jsx)(Ye,{item:e,categories:U.data.categories.filter(e=>e.id!==W.data?.category.id),onOpen:q},e.key))}):null,W.data.rows.map(e=>(0,Q.jsx)(`button`,{type:`button`,onClick:()=>q(`t:${e.tableId}`),className:`px-1 text-left text-[0.8125rem] text-ink-3 hover:text-ink`,children:X(`know.tocRows`,{n:e.count,table:e.title})},e.tableId))]})},z):null:(0,Q.jsx)(_e,{id:`documents`,children:(0,Q.jsx)(rt,{projectId:o.id,data:U.data,readOnly:o.readOnly,onOpen:q})}):null:null,_===`info`||_===`brand`?ve(P):null]},o.id):null,o&&_===`skills`&&S?(0,Q.jsx)(`div`,{className:`flex flex-col gap-9 pb-20`,children:oe?(0,Q.jsx)(Z.Suspense,{fallback:null,children:(0,Q.jsx)(Vi,{skillId:oe.slice(2),onGone:()=>q(`all`),onOpen:q},oe)}):H.data?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(ji,{projectId:o.id,data:H.data,onOpen:q}),ve(P)]}):H.error?(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:H.error.message}):null}):null,o&&_===`page`&&x?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-9 pb-20`,children:[(0,Q.jsx)(ei,{project:o},o.id),ve(P)]}):null,o&&v?(0,Q.jsx)(Qt,{of:v,children:(0,Q.jsx)(Vt,{part:v.id,children:(0,Q.jsx)(v.component,{})},o.id)}):null,o&&_===`data`?(0,Q.jsx)(`div`,{className:`flex flex-col gap-9 pb-20`,children:z?.startsWith(`t:`)?(0,Q.jsx)($e,{tableId:z.slice(2),onGone:()=>q(`all`)},z):z?.startsWith(`p:`)?(0,Q.jsx)(et,{pageId:z.slice(2),onGone:()=>q(`all`)},z):(0,Q.jsxs)(Q.Fragment,{children:[se.data?(0,Q.jsx)(nt,{projectId:o.id,data:se.data,readOnly:o.readOnly,onOpen:q}):null,ve(P)]})}):null,o&&_===`results`?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-9 pb-20`,children:[ie.data?(0,Q.jsx)(ai,{data:ie.data,wizardId:F,onWizard:e=>q(e??`all`),filter:I,onFilter:L}):null,ie.isError?(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:ie.error.message}):null,ve(P)]}):null,o||s?null:(0,Q.jsx)(h,{children:X(`settings.noProject`)})]}):null]})})})}export{Hi as ProjectPage,oi as a,si as c,wi as i,xi as n,hi as o,Ii as r,vi as s,Ni as t};
|
|
@@ -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{G as r,Jn as i,Q as a,Rt as o,Wt as s,Yt as c,Zn as l,ar as u,cr as d,dt as f,ft as p,ir as m,on as h,or as g,ot as _,sn as v,st as y,tn as b,tr as ee}from"./ui-DSXG3f49.js";import{_ as x,b as S,d as C,f as te,g as w,h as T,m as E,n as ne,p as re,v as D,y as O}from"./theme-D7krsx0_.js";import{D as ie,b as k,x as A,y as ae}from"./session-BWI-KENJ.js";import{W as j,a as M,l as N,s as P}from"./i18n-8-Sw11tB.js";import{$t as F,R as I}from"./index-OsdQFHmh.js";var L={name:`bookmark`,size:24,node:[[`path`,{d:`M17 3a2 2 0 0 1 2 2v15a1 1 0 0 1-1.496.868l-4.512-2.578a2 2 0 0 0-1.984 0l-4.512 2.578A1 1 0 0 1 5 20V5a2 2 0 0 1 2-2z`,key:`oz39mx`}]]};L.node;var oe=l(L),R={name:`square-plus`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M8 12h8`,key:`1wcyev`}],[`path`,{d:`M12 8v8`,key:`napkw2`}]],aliases:[`plus-square`]};R.node;var se=l(R),z=e(t(),1);function ce(){if(window.self===window.top)return null;let e=new URLSearchParams(window.location.search).get(`embed`);return e===`inline`||e===`modal`||e===`popout`?e:null}var B=ce(),le=B?new URLSearchParams(window.location.search).get(`page`):null,V=new URLSearchParams(window.location.search).get(`theme`),H=V?`?theme=${encodeURIComponent(V)}`:``,U=(e,t={})=>window.parent.postMessage({type:`engenty-wizard:${e}`,...t},`*`),ue=()=>U(`close`);function de(e){(0,z.useEffect)(()=>{if(B===`inline`&&!e){let e=document.documentElement;document.getElementById(`root`)?.style.setProperty(`min-height`,`0`),e.style.overflow=`hidden`;let t=new ResizeObserver(()=>U(`height`,{height:Math.ceil(e.getBoundingClientRect().height)}));return t.observe(e),()=>t.disconnect()}if(B===`modal`||B===`popout`){let e=e=>{e.key===`Escape`&&!document.querySelector(`dialog[open]`)&&U(`close`)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)}},[e])}var W=e(n(),1),G=`wizards.runner.translate`,K=new Set;function fe(){try{return localStorage.getItem(G)===`on`}catch{return!1}}function pe(e){try{localStorage.setItem(G,e?`on`:`off`)}catch{}for(let e of K)e()}function me(){return(0,z.useSyncExternalStore)(e=>(K.add(e),()=>K.delete(e)),fe)}function he(e){let t=me(),[n]=(0,z.useState)(()=>N()),i=e?.lang??`en`,a=e?.translatable&&n&&n!==i?n:null,o=a&&t?a:i,s=e?.token,c=d({queryKey:[`public-translation`,s,o],enabled:!!(s&&o!==i),queryFn:()=>r.post(`/api/public/wizards/${s}/translation${H}`,{lang:o}),staleTime:1/0,retry:!1}),l=d({queryKey:[`public-texts`,s,o],enabled:!(!s||j(o)),queryFn:()=>r.get(`/api/public/wizards/${s}/texts/${o}`),staleTime:1/0,retry:!1}),u=!j(o),f=o===i||c.data&&(!u||l.data),p=o!==i&&(c.isError||u&&l.isError),m=f&&!p?o:i,h=(0,z.useMemo)(()=>!j(m)&&l.data?.lang===m?{lang:l.data.lang,runner:l.data.runner,notes:l.data.notes}:null,[m,l.data]);if((0,z.useEffect)(()=>{e&&M(m,h)},[e,m,h]),(0,z.useEffect)(()=>()=>M(null),[]),!e)return null;let g=m!==i&&c.data?c.data:null;return{own:i,other:a,shown:m,wizard:g??e,translating:o!==i&&!f&&!p,failed:!!p,translated:!!g,machine:g?.translation?.machine??!1,pick:e=>pe(e!==i)}}function q({page:e,tone:t=`ground`}){if(!e?.other)return null;let n=e.translating?e.other:e.shown;return(0,W.jsx)(I,{langs:[e.own,e.other],value:n,onPick:e.pick,tone:t})}function J({page:e,small:t}){if(!e)return null;let n=t?`truncate text-[0.75rem]`:`text-[0.8125rem]`;return e.failed?(0,W.jsx)(`p`,{className:h(`text-ink-3`,n),children:P(`translation.failed`)}):e.translated?(0,W.jsxs)(`p`,{className:h(`text-ink-3`,n),children:[e.machine?(0,W.jsxs)(W.Fragment,{children:[P(`translation.machine`),` · `]}):null,(0,W.jsx)(`button`,{type:`button`,className:`underline-offset-4 hover:text-ink hover:underline coarse:min-h-11`,onClick:()=>e.pick(e.own),children:P(`translation.showOriginal`)})]}):null}function ge(e,t){let n=(0,z.useRef)(null),i=t&&!t.translating?t.translated?t.shown:null:void 0;(0,z.useEffect)(()=>{if(!e||i===void 0)return;let t=`${e}:${i}`;n.current!==t&&(n.current=t,r.post(`/api/runs/${e}/lang`,{lang:i}).catch(()=>void 0))},[e,i])}function _e(e,t){(0,z.useEffect)(()=>{if(!e||!t)return;let n=_(`/api/public/wizards/${e}`),r=[{rel:`manifest`,href:`${n}/manifest.webmanifest`},{rel:`apple-touch-icon`,href:`${n}/icons/apple-touch-icon.png`},{rel:`icon`,href:`${n}/icons/favicon.png`,type:`image/png`}].flatMap(({rel:e,href:t,type:n})=>{let r=document.querySelector(`link[rel="${e}"]`);if(!r)return[];let i={href:r.getAttribute(`href`),type:r.getAttribute(`type`)};return r.setAttribute(`href`,t),n&&r.setAttribute(`type`,n),[{link:r,before:i}]}),i=document.createElement(`meta`);return i.name=`apple-mobile-web-app-title`,i.content=t,document.head.appendChild(i),()=>{for(let{link:e,before:t}of r)for(let[n,r]of Object.entries(t))r===null?e.removeAttribute(n):e.setAttribute(n,r);i.remove()}},[e,t])}var Y=/iPhone|iPad|iPod/.test(navigator.userAgent)||navigator.platform===`MacIntel`&&navigator.maxTouchPoints>1,X=Y||/Android/.test(navigator.userAgent);function ve(){let[e,t]=(0,z.useState)(()=>window.wizardInstall??null),[n,r]=(0,z.useState)(!1);if((0,z.useEffect)(()=>{let e=()=>t(window.wizardInstall??null);return window.addEventListener(`wizard-install`,e),()=>window.removeEventListener(`wizard-install`,e)},[]),window.matchMedia(`(display-mode: standalone)`).matches||navigator.standalone===!0||X&&!e&&!Y)return null;let i=/Mac/.test(navigator.platform),a=P(X?`install.ios`:i?`install.bookmark.mac`:`install.bookmark.pc`);return(0,W.jsxs)(`div`,{className:`mt-6 flex flex-col items-center gap-2 text-[0.8125rem] text-ink-3`,children:[(0,W.jsxs)(`button`,{type:`button`,onClick:()=>{X&&e?(e.prompt(),window.wizardInstall=null,t(null)):r(e=>!e)},className:`inline-flex items-center gap-1.5 underline-offset-4 hover:text-ink hover:underline coarse:min-h-11`,children:[X?(0,W.jsx)(se,{className:`size-4`}):(0,W.jsx)(oe,{className:`size-4`}),P(X?`install.add`:`install.bookmark`)]}),n?(0,W.jsx)(`p`,{className:`max-w-xs leading-relaxed`,children:a}):null]})}function Z({brand:e,toggle:t=!0,start:n}){return(0,W.jsx)(`header`,{className:`safe-top`,children:(0,W.jsxs)(`div`,{className:`relative flex h-14 items-center justify-center px-5`,children:[n?(0,W.jsx)(`div`,{className:`absolute left-3`,children:n}):null,e.logoUrl?(0,W.jsx)(`img`,{src:_(e.logoUrl),alt:e.name,className:`h-7 max-w-[160px] object-contain`}):e.name?(0,W.jsx)(`span`,{className:`max-w-[60%] truncate font-display font-semibold text-[0.9375rem] text-ink-2 tracking-tight`,children:e.name}):null,t?(0,W.jsx)(`div`,{className:`absolute right-3`,children:(0,W.jsx)(A,{})}):null]})})}function ye({siteKey:e,onToken:t}){let n=(0,z.useRef)(null);return(0,z.useEffect)(()=>{let r=()=>{n.current&&window.turnstile&&!n.current.childElementCount&&window.turnstile.render(n.current,{sitekey:e,callback:t,appearance:`interaction-only`})};if(window.turnstile){r();return}let i=document.createElement(`script`);i.src=`https://challenges.cloudflare.com/turnstile/v0/api.js`,i.async=!0,i.onload=r,document.head.appendChild(i)},[e,t]),(0,W.jsx)(`div`,{ref:n,className:`mt-4 flex justify-center`})}function be({token:e}){return!/iPhone|iPad|iPod|Android/.test(navigator.userAgent)||y||B?null:(0,W.jsxs)(`a`,{href:f(`${window.location.origin}${a}/w/${e}`),className:`mt-3 inline-flex items-center gap-1.5 text-[0.8125rem] text-ink-3 underline-offset-4 hover:text-ink hover:underline coarse:min-h-11`,children:[(0,W.jsx)(S,{className:`size-4`}),` `,P(`install.app`)]})}var Q=e=>`wz.run.${e}`,xe=()=>m().state?.elsewhere===!0,Se=y&&new URLSearchParams(window.location.search).get(`start`)===`1`,$=B===`inline`?`min-h-80`:`min-h-dvh`;function Ce(e,t,n){let i=u(),[a,o]=(0,z.useState)(!1),[s,c]=(0,z.useState)(null),[l,d]=(0,z.useState)(null),f=(()=>{try{return localStorage.getItem(Q(e.token))}catch{return null}})();return{busy:a,error:s,captcha:l,setCaptcha:d,start:async()=>{o(!0),c(null);try{let{runId:a}=await r.post(`/api/public/wizards/${e.token}/runs`,{turnstileToken:l??void 0,embedded:B!==null,origin:le??void 0,lang:n??void 0});try{localStorage.setItem(Q(e.token),a)}catch{}i(`${t}/${a}`,{replace:Se})}catch(e){c(e.message),o(!1)}},resume:f?()=>i(`${t}/${f}`):null}}function we({wizard:e,page:t}){let{busy:n,error:r,captcha:a,setCaptcha:o,start:c,resume:l}=Ce(e,`/w/${e.token}`,t?.translated?t.shown:null),u=xe(),d=Se&&e.available&&!e.turnstileSiteKey,f=(0,z.useRef)(!1);return(0,z.useEffect)(()=>{d&&!f.current&&(f.current=!0,c())},[d]),d&&!r?(0,W.jsx)(`div`,{className:`flex min-h-[60dvh] items-center justify-center text-ink-4`,children:(0,W.jsx)(b,{})}):(0,W.jsxs)(`div`,{className:`mx-auto flex max-w-lg animate-rise flex-col items-center px-6 pt-6 pb-12 text-center sm:pt-16 sm:pb-16`,children:[u?(0,W.jsx)(`p`,{className:`mb-6 rounded-xl bg-paper-2 px-5 py-3 text-[0.875rem] text-ink-2`,children:P(`run.elsewhere`)}):null,(0,W.jsx)(k,{kind:e.avatar,costume:e.costume,size:190,fluffy:!0}),(0,W.jsx)(`h1`,{className:`wizard-title mt-2 text-balance font-display font-semibold text-[1.875rem] leading-[1.1] tracking-tight sm:text-[2.125rem]`,children:e.title}),e.description?(0,W.jsx)(`p`,{className:`mt-3 text-[1rem] text-ink-2 leading-relaxed`,children:e.description}):null,(0,W.jsx)(`div`,{className:`mt-3`,children:(0,W.jsx)(J,{page:t})}),e.available?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(s,{size:`lg`,className:`mt-10 min-w-48`,busy:n,disabled:!!e.turnstileSiteKey&&!a,onClick:c,children:[P(`run.start`),` `,(0,W.jsx)(i,{className:`size-4`})]}),e.turnstileSiteKey?(0,W.jsx)(ye,{siteKey:e.turnstileSiteKey,onToken:o}):null,l?(0,W.jsx)(`button`,{type:`button`,onClick:l,className:`mt-4 text-[0.875rem] text-ink-3 underline-offset-4 hover:text-ink hover:underline coarse:min-h-11`,children:P(`run.resume`)}):null,(0,W.jsx)(Te,{wizard:e,current:`steps`}),B||y?null:(0,W.jsx)(ve,{}),(0,W.jsx)(be,{token:e.token})]}):(0,W.jsx)(`p`,{className:`mt-10 rounded-xl bg-paper-2 px-5 py-4 text-[0.9375rem] text-ink-2`,children:e.unavailableReason??P(`run.unavailable`)}),r?(0,W.jsx)(`p`,{className:`mt-4 text-[0.875rem] text-rose`,children:r}):null]})}function Te({wizard:e,current:t}){let n=e.runners.filter(e=>e.id!==t&&e.kind===`page`&&e.url);return n.length?(0,W.jsx)(`p`,{className:`mt-4 flex flex-wrap justify-center gap-x-4 text-[0.875rem] text-ink-3`,children:n.map(e=>(0,W.jsx)(`a`,{href:e.url??void 0,className:`underline-offset-4 hover:text-ink hover:underline coarse:min-h-11`,children:P(`run.orAs`,{label:e.label})},e.id))}):null}function Ee({wizard:e,page:t}){let n=O();return(0,W.jsx)(`header`,{className:`safe-top shrink-0 border-border-soft border-b`,children:(0,W.jsxs)(`div`,{className:`mx-auto flex h-16 w-full max-w-[760px] items-center gap-3 pr-2 pl-4 sm:pr-4 sm:pl-6`,children:[(0,W.jsx)(`span`,{className:h(n?.speaking&&`animate-breathe`),children:(0,W.jsx)(k,{kind:e.avatar,costume:e.costume,size:38})}),(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsx)(`div`,{className:`truncate font-display font-semibold text-[1rem] leading-tight tracking-tight`,children:e.title}),e.brand.name?(0,W.jsx)(`div`,{className:`truncate text-[0.75rem] text-ink-3`,children:e.brand.name}):null,(0,W.jsx)(J,{page:t,small:!0})]}),e.brand.logoUrl&&B!==`popout`?(0,W.jsx)(`img`,{src:_(e.brand.logoUrl),alt:e.brand.name,className:`h-6 max-w-[120px] object-contain max-sm:hidden`}):null,(0,W.jsx)(q,{page:t,tone:`surface`}),B?null:(0,W.jsx)(A,{}),B===`popout`?(0,W.jsx)(c,{label:P(`common.close`),onClick:ue,children:(0,W.jsx)(v,{className:`size-5`})}):null]})})}function De({door:e,wizard:t,page:n,header:r,footer:a}){let{busy:o,error:s,captcha:c,setCaptcha:l,start:u,resume:d}=Ce(t,`/w/${t.token}/${e}`,n?.translated?n.shown:null),f=xe(),p=[];return f&&p.push({key:`elsewhere`,who:`bot`,node:P(`run.elsewhere`)}),p.push({key:`hello`,who:`bot`,node:t.description||t.title}),e!==`chat`&&p.push({key:e,who:`bot`,node:P(e===`video`?`video.hint`:`talk.joinHint`)}),t.available||p.push({key:`unavailable`,who:`bot`,node:t.unavailableReason??P(`run.unavailable`)}),s&&p.push({key:`error`,who:`bot`,node:s,tone:`error`}),t.available&&p.push(D(`start`,(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(w,{primary:!0,busy:o,disabled:!!t.turnstileSiteKey&&!c,onClick:()=>void u(),children:[P(`run.start`),` `,(0,W.jsx)(i,{className:`size-4`})]}),d?(0,W.jsx)(w,{onClick:d,children:P(`run.resume`)}):null,t.turnstileSiteKey?(0,W.jsx)(ye,{siteKey:t.turnstileSiteKey,onToken:l}):null]}))),(0,W.jsxs)(E,{header:r,footer:a,children:[(0,W.jsx)(x,{avatar:t.avatar,costume:t.costume,lines:p}),(0,W.jsx)(T,{})]})}function Oe({className:e}){return(0,W.jsx)(`footer`,{className:h(`text-center text-ink-4`,e),children:(0,W.jsx)(`a`,{href:`${a}/`,target:B?`_blank`:void 0,rel:`noreferrer`,className:`inline-block hover:text-ink-2`,children:P(`run.madeWith`).replace(`engenty wizards`,ae.name)})})}function ke({chat:e=!1,steps:t=!1,talk:n=!1,video:i=!1}){let{token:c,runId:l}=g(),f=u(),m=d({queryKey:[`public`,c,H],queryFn:()=>r.get(`/api/public/wizards/${c}${H}`),retry:(e,t)=>o(t)&&e<3}),_=m.data?.runners??[],v=!m.data||_.some(e=>e.id===`talk`),x=!m.data||_.some(e=>e.id===`video`),S=!m.data||_.some(e=>e.id===`chat`)||n&&v||i&&x,w=_[0]?.id,T=e||B===`popout`||!t&&!l&&S&&(w===`chat`||w===`talk`||w===`video`),E=i&&x||!t&&!e&&!n&&w===`video`,D=!E&&(n&&v||!t&&!e&&w===`talk`),O=E?`video`:D?`talk`:`chat`,A=he(m.data);ge(l,A),ne(m.data?.brand.theme),ie(m.data?.avatar),_e(c,m.data?.title),de(T);let j=A?.wizard.title??m.data?.title;(0,z.useEffect)(()=>{j&&(document.title=j)},[j]);let M=(0,z.useCallback)(e=>{try{c&&localStorage.getItem(Q(c))===l&&localStorage.removeItem(Q(c))}catch{}f(e,{replace:!0,state:{elsewhere:!0}})},[f,c,l]);if((0,z.useEffect)(()=>{c&&l&&p(`run`,{token:c,runId:l})},[c,l]),m.isLoading)return(0,W.jsx)(`div`,{className:h(`flex items-center justify-center text-ink-4`,$),children:(0,W.jsx)(b,{})});if(e&&m.data&&!S||n&&m.data&&!v||i&&m.data&&!x)return(0,W.jsx)(ee,{to:`/w/${c}`,replace:!0});if(!m.data){let e=o(m.error);return(0,W.jsxs)(`div`,{className:h(`flex flex-col items-center justify-center gap-4 px-6 text-center`,$),children:[(0,W.jsx)(k,{kind:`pebble`,size:80}),(0,W.jsx)(`p`,{className:`max-w-xs text-ink-3`,children:P(e?`common.offline`:`run.notFound`)}),e?(0,W.jsx)(s,{variant:`secondary`,onClick:()=>void m.refetch(),children:P(`common.retry`)}):null]})}let N=A?.wizard??m.data,I=A?.translating?(0,W.jsxs)(`div`,{className:h(`flex flex-col items-center justify-center gap-3 text-ink-3`,$),children:[(0,W.jsx)(b,{}),(0,W.jsx)(`p`,{className:`text-[0.875rem]`,children:P(`translation.working`)})]}):null;if(T){let e=(0,W.jsx)(Ee,{wizard:N,page:A}),t=y?(0,W.jsx)(`div`,{className:`safe-bottom`}):(0,W.jsx)(Oe,{className:`pb-[max(0.375rem,env(safe-area-inset-bottom))] text-[0.6875rem]`});return(0,W.jsxs)(`div`,{className:`wizard-page flex h-dvh flex-col`,children:[(0,W.jsx)(C,{effects:m.data.brand.theme.effects}),B||y?null:(0,W.jsx)(F,{}),I??(l?(0,W.jsx)(re,{runId:l,talk:D,call:E?`video`:D?`audio`:!1,onRestart:()=>f(`/w/${c}/${O}`),onNotFound:()=>M(`/w/${c}/${O}`),header:E||D?void 0:e,footer:t}):(0,W.jsx)(De,{wizard:N,page:A,header:e,footer:t,door:O}))]})}return(0,W.jsxs)(`div`,{className:h(`wizard-page flex flex-col`,$),children:[(0,W.jsx)(C,{effects:m.data.brand.theme.effects}),B||y?null:(0,W.jsx)(F,{}),B===`inline`||y?null:(0,W.jsx)(Z,{brand:m.data.brand,toggle:!B,start:(0,W.jsx)(q,{page:A})}),B===`inline`||y?(0,W.jsx)(`div`,{className:`flex justify-end px-3 pt-2`,children:(0,W.jsx)(q,{page:A,tone:`surface`})}):null,l&&(A?.translated||A?.failed)?(0,W.jsx)(`div`,{className:`flex justify-center px-5`,children:(0,W.jsx)(J,{page:A})}):null,(0,W.jsx)(`div`,{className:`flex-1`,children:I??(l?(0,W.jsx)(te,{runId:l,onRestart:()=>f(`/w/${c}`),onNotFound:()=>M(`/w/${c}`)}):(0,W.jsx)(we,{wizard:N,page:A}))}),y?(0,W.jsx)(`div`,{className:`safe-bottom`}):(0,W.jsx)(`footer`,{className:`safe-bottom pt-6 text-center text-[0.75rem] text-ink-4`,children:(0,W.jsx)(`a`,{href:`${a}/`,target:B?`_blank`:void 0,rel:`noreferrer`,className:`inline-block py-3.5 hover:text-ink-2`,children:P(`run.madeWith`).replace(`engenty wizards`,ae.name)})})]})}export{Z as BrandHeader,ke as PublicRunner};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{t}from"./jsx-runtime-BNakU3Ej.js";import{Zn as n}from"./ui-DSXG3f49.js";import{s as r}from"./i18n-8-Sw11tB.js";import{yn as i}from"./index-OsdQFHmh.js";var a={name:`text-align-start`,size:24,node:[[`path`,{d:`M21 5H3`,key:`1fi0y6`}],[`path`,{d:`M15 12H3`,key:`6jk70r`}],[`path`,{d:`M17 19H3`,key:`z6ezky`}]],aliases:[`text`,`align-left`]};a.node;var o=n(a),s=e(t(),1);function c(e){return r(e.origin===`local`?`readonly.project`:`readonly.server`)}function l({children:e}){return(0,s.jsxs)(`div`,{className:`flex items-start gap-3 rounded-xl bg-amber-tint px-4 py-3 font-medium text-[0.875rem] text-ink leading-relaxed`,children:[(0,s.jsx)(i,{className:`mt-0.5 size-4 shrink-0 text-amber`}),(0,s.jsx)(`p`,{className:`min-w-0`,children:e})]})}export{c as n,o as r,l as t};
|