@engenty/wizards-runtime 0.7.11 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (257) hide show
  1. package/README.md +5 -1
  2. package/apps/runtime/dist/agents/architect.js +2 -2
  3. package/apps/runtime/dist/agents/studio-assistant.js +1 -1
  4. package/apps/runtime/dist/agents/website.js +1 -1
  5. package/apps/runtime/dist/app.js +1 -1
  6. package/apps/runtime/dist/assistant/browser.js +1 -1
  7. package/apps/runtime/dist/authoring/guide.js +16 -4
  8. package/apps/runtime/dist/authoring/ops.js +1 -1
  9. package/apps/runtime/dist/cli/exec.js +4 -1
  10. package/apps/runtime/dist/cli/features.js +1 -1
  11. package/apps/runtime/dist/cli/validate.js +2 -2
  12. package/apps/runtime/dist/connectors/builtin.js +4 -2
  13. package/apps/runtime/dist/connectors/external.js +1 -1
  14. package/apps/runtime/dist/connectors/index.js +37 -6
  15. package/apps/runtime/dist/connectors/smtp.js +221 -0
  16. package/apps/runtime/dist/connectors/via-account.js +1 -1
  17. package/apps/runtime/dist/credits/estimate.js +1 -1
  18. package/apps/runtime/dist/db/migrations/tenant/0018_share_job.sql +18 -0
  19. package/apps/runtime/dist/db/migrations/tenant/meta/0018_snapshot.json +3460 -0
  20. package/apps/runtime/dist/db/migrations/tenant/meta/_journal.json +7 -0
  21. package/apps/runtime/dist/db/schema.js +19 -0
  22. package/apps/runtime/dist/docs/dev/index.md +25 -13
  23. package/apps/runtime/dist/docs/dev/integration/index.md +1 -1
  24. package/apps/runtime/dist/docs/dev/integration/openui.md +1 -1
  25. package/apps/runtime/dist/docs/dev/integration/own-ui.md +2 -2
  26. package/apps/runtime/dist/docs/dev/meta.json +8 -2
  27. package/apps/runtime/dist/docs/dev/plugins/examples.md +2 -3
  28. package/apps/runtime/dist/docs/dev/plugins/studio.md +5 -6
  29. package/apps/runtime/dist/docs/dev/plugins/styling.md +10 -7
  30. package/apps/runtime/dist/docs/dev/wizard-format/agent-steps.md +112 -0
  31. package/apps/runtime/dist/docs/dev/wizard-format/branches.md +63 -0
  32. package/apps/runtime/dist/docs/dev/wizard-format/film-steps.md +47 -0
  33. package/apps/runtime/dist/docs/dev/wizard-format/generate-steps.md +57 -0
  34. package/apps/runtime/dist/docs/dev/wizard-format/index.md +188 -0
  35. package/apps/runtime/dist/docs/dev/wizard-format/lists-and-connections.md +65 -0
  36. package/apps/runtime/dist/docs/dev/wizard-format/meta.json +19 -0
  37. package/apps/runtime/dist/docs/dev/wizard-format/pages-and-fields.md +102 -0
  38. package/apps/runtime/dist/docs/dev/wizard-format/review-and-result.md +64 -0
  39. package/apps/runtime/dist/docs/dev/wizard-format/templates.md +57 -0
  40. package/apps/runtime/dist/docs/dev/wizard-format/validate.md +63 -0
  41. package/apps/runtime/dist/docs/dev/wizard-format/views-and-widgets.md +103 -0
  42. package/apps/runtime/dist/docs/dev/wizard-format/wizard-file.md +147 -0
  43. package/apps/runtime/dist/docs/user/build-a-wizard.md +2 -2
  44. package/apps/runtime/dist/docs/user/run.md +21 -4
  45. package/apps/runtime/dist/docs/user/space.md +14 -10
  46. package/apps/runtime/dist/docs/user/steps.md +26 -1
  47. package/apps/runtime/dist/docs/user/test-and-share.md +3 -2
  48. package/apps/runtime/dist/documents/parse.js +1 -1
  49. package/apps/runtime/dist/engine/decide.js +1 -1
  50. package/apps/runtime/dist/engine/events.js +1 -1
  51. package/apps/runtime/dist/engine/input.js +3 -3
  52. package/apps/runtime/dist/engine/prepare.js +1 -1
  53. package/apps/runtime/dist/engine/requirements.js +25 -10
  54. package/apps/runtime/dist/engine/runner.js +23 -14
  55. package/apps/runtime/dist/engine/steps.js +6 -6
  56. package/apps/runtime/dist/engine/surface.js +3 -3
  57. package/apps/runtime/dist/engine/template.js +4 -4
  58. package/apps/runtime/dist/env.js +5 -0
  59. package/apps/runtime/dist/features.js +1 -1
  60. package/apps/runtime/dist/film/project.js +2 -2
  61. package/apps/runtime/dist/film/step.js +2 -2
  62. package/apps/runtime/dist/harness/antigravity.js +2 -10
  63. package/apps/runtime/dist/harness/apple.js +1 -1
  64. package/apps/runtime/dist/harness/claude.js +3 -11
  65. package/apps/runtime/dist/harness/codex.js +6 -12
  66. package/apps/runtime/dist/harness/cursor.js +2 -10
  67. package/apps/runtime/dist/harness/env.js +23 -0
  68. package/apps/runtime/dist/harness/index.js +6 -3
  69. package/apps/runtime/dist/harness/model.js +1 -1
  70. package/apps/runtime/dist/harness/terminal.js +1 -1
  71. package/apps/runtime/dist/mcp/flow-app.js +1 -1
  72. package/apps/runtime/dist/media/conversation.js +1 -1
  73. package/apps/runtime/dist/media/transcribe.js +1 -1
  74. package/apps/runtime/dist/model-errors.js +1 -1
  75. package/apps/runtime/dist/models.js +3 -3
  76. package/apps/runtime/dist/plugin.js +1 -1
  77. package/apps/runtime/dist/plugins/discovery.js +1 -1
  78. package/apps/runtime/dist/plugins/loader.js +2 -2
  79. package/apps/runtime/dist/plugins/runs.js +2 -2
  80. package/apps/runtime/dist/render/downloads.js +2 -2
  81. package/apps/runtime/dist/render/shaped.js +1 -1
  82. package/apps/runtime/dist/routes/api.js +2 -2
  83. package/apps/runtime/dist/routes/lang.js +1 -1
  84. package/apps/runtime/dist/routes/marketplace.js +1 -1
  85. package/apps/runtime/dist/routes/runs.js +110 -10
  86. package/apps/runtime/dist/routes/studio.js +20 -8
  87. package/apps/runtime/dist/services/access.js +1 -1
  88. package/apps/runtime/dist/services/api.js +4 -4
  89. package/apps/runtime/dist/services/assistant-chats.js +2 -2
  90. package/apps/runtime/dist/services/brand.js +2 -2
  91. package/apps/runtime/dist/services/cloud.js +1 -1
  92. package/apps/runtime/dist/services/errors.js +1 -1
  93. package/apps/runtime/dist/services/files.js +1 -1
  94. package/apps/runtime/dist/services/knowledge-model.js +3 -3
  95. package/apps/runtime/dist/services/knowledge.js +2 -2
  96. package/apps/runtime/dist/services/marketplace.js +5 -5
  97. package/apps/runtime/dist/services/package-file.js +3 -3
  98. package/apps/runtime/dist/services/package.js +2 -2
  99. package/apps/runtime/dist/services/profile.js +1 -1
  100. package/apps/runtime/dist/services/project-files.js +2 -2
  101. package/apps/runtime/dist/services/project-index.js +1 -1
  102. package/apps/runtime/dist/services/projects.js +2 -2
  103. package/apps/runtime/dist/services/runners.js +3 -3
  104. package/apps/runtime/dist/services/runs.js +2 -2
  105. package/apps/runtime/dist/services/shares.js +1 -1
  106. package/apps/runtime/dist/services/site.js +2 -2
  107. package/apps/runtime/dist/services/space-categories.js +3 -3
  108. package/apps/runtime/dist/services/space-data.js +4 -4
  109. package/apps/runtime/dist/services/spaces.js +6 -6
  110. package/apps/runtime/dist/services/translations.js +5 -5
  111. package/apps/runtime/dist/services/widgets.js +1 -1
  112. package/apps/runtime/dist/services/wizards.js +3 -3
  113. package/apps/runtime/dist/sharing/agent.js +65 -0
  114. package/apps/runtime/dist/sharing/files.js +121 -0
  115. package/apps/runtime/dist/sharing/index.js +298 -0
  116. package/apps/runtime/dist/sharing/jobs.js +186 -0
  117. package/apps/runtime/dist/sharing/state.js +116 -0
  118. package/apps/runtime/dist/sharing/targets/browser.js +131 -0
  119. package/apps/runtime/dist/sharing/targets/connector.js +63 -0
  120. package/apps/runtime/dist/sharing/targets/email.js +98 -0
  121. package/apps/runtime/dist/sharing/targets/slack.js +54 -0
  122. package/apps/runtime/dist/sharing/targets/storage.js +164 -0
  123. package/apps/runtime/dist/sharing/types.js +13 -0
  124. package/apps/runtime/dist/store/index.js +3 -3
  125. package/apps/runtime/dist/store/shared-lists.js +1 -1
  126. package/apps/runtime/dist/texts.js +109 -1
  127. package/apps/runtime/dist/tools/browser.js +48 -0
  128. package/apps/runtime/dist/tools/connector.js +3 -2
  129. package/apps/runtime/dist/tools/index.js +1 -1
  130. package/apps/runtime/dist/tools/plugin.js +2 -2
  131. package/apps/runtime/dist/tools/project.js +1 -1
  132. package/apps/runtime/dist/tools/store.js +20 -3
  133. package/apps/runtime/dist/widgets/bundle.js +1 -1
  134. package/apps/runtime/dist/widgets/step.js +3 -3
  135. package/apps/web/dist/assets/AboutDialog-CB0EwGxP.js +1 -0
  136. package/apps/web/dist/assets/{ChangelogDialog-CZrd-MgC.js → ChangelogDialog-BQRBkiVD.js} +1 -1
  137. package/apps/web/dist/assets/ChatView-BLZkLlHi.js +10 -0
  138. package/apps/web/dist/assets/EditorPage-YawfYRAL.js +4 -0
  139. package/apps/web/dist/assets/{FlowPreview-oX_Emm7u.js → FlowPreview-B0xF8e3r.js} +1 -1
  140. package/apps/web/dist/assets/{Harness-DiB8CBdY.js → Harness-snRbALGd.js} +2 -2
  141. package/apps/web/dist/assets/NewWizardChannels-BGzp9z0m.js +1 -0
  142. package/apps/web/dist/assets/{NewWizardPage-C2Oh2sMM.js → NewWizardPage-cOHfwcnA.js} +2 -2
  143. package/apps/web/dist/assets/OnboardingPage-jB3ChKi3.js +1 -0
  144. package/apps/web/dist/assets/ProjectPage-hRCBquNb.js +1 -0
  145. package/apps/web/dist/assets/PublicRunner-D_ZkOyRV.js +1 -0
  146. package/apps/web/dist/assets/{ReadOnly-CD5YWvrW.js → ReadOnly-Db_odT6Y.js} +1 -1
  147. package/apps/web/dist/assets/RunDrawer-B6AQw90D.js +4 -0
  148. package/apps/web/dist/assets/RunnerView-DHUkvi_G.js +1 -0
  149. package/apps/web/dist/assets/SettingsPage-DleMaLz8.js +2 -0
  150. package/apps/web/dist/assets/SetupPage-DTvVJR1U.js +1 -0
  151. package/apps/web/dist/assets/{SharePage-B6u9kS12.js → SharePage-Bl-rfCji.js} +1 -1
  152. package/apps/web/dist/assets/changelog-BcW79fHm.js +1 -0
  153. package/apps/web/dist/assets/esm-Bji0ThaK.js +7 -0
  154. package/apps/web/dist/assets/index-CQKA-z2z.js +14 -0
  155. package/apps/web/dist/assets/index-Cnziz-H-.css +1 -0
  156. package/apps/web/dist/assets/oss-credits-BjwxLtU4.js +1 -0
  157. package/apps/web/dist/assets/{phone-BjmhIKuT.js → phone-DwAf8S3l.js} +1 -1
  158. package/apps/web/dist/assets/settings-menu-B1ND1GF3.js +1 -0
  159. package/apps/web/dist/assets/ui-Cdv3QUOd.js +137 -0
  160. package/apps/web/dist/assets/{upload-JX9BcMTq.js → upload-DCMZI6pp.js} +1 -1
  161. package/apps/web/dist/assets/{wrench-BSxnPs2_.js → wrench-BRYtnxti.js} +1 -1
  162. package/apps/web/dist/index.html +3 -3
  163. package/apps/web/dist/mcp/flow.html +53 -53
  164. package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/definition.d.ts +22 -0
  165. package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/definition.js +26 -0
  166. package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/run.d.ts +6 -0
  167. package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/run.js +2 -0
  168. package/node_modules/@engenty/wizards-shared/dist/sharing.d.ts +135 -0
  169. package/node_modules/@engenty/wizards-shared/dist/sharing.js +11 -0
  170. package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/store.d.ts +8 -0
  171. package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/package.json +1 -1
  172. package/package.json +4 -3
  173. package/plugin/.claude-plugin/plugin.json +1 -1
  174. package/apps/runtime/dist/docs/dev/wizard-format.md +0 -125
  175. package/apps/web/dist/assets/AboutDialog-CPRAlD2H.js +0 -1
  176. package/apps/web/dist/assets/ChatView-DVeERQdi.js +0 -10
  177. package/apps/web/dist/assets/EditorPage-DhUoKcss.js +0 -4
  178. package/apps/web/dist/assets/NewWizardChannels-Ba3XGpro.js +0 -1
  179. package/apps/web/dist/assets/OnboardingPage-D_4ShWrL.js +0 -1
  180. package/apps/web/dist/assets/ProjectPage-C58rq50b.js +0 -1
  181. package/apps/web/dist/assets/PublicRunner-CE0ohzyd.js +0 -1
  182. package/apps/web/dist/assets/RunDrawer-Cd8-qHV7.js +0 -4
  183. package/apps/web/dist/assets/RunnerView-BW1h4x63.js +0 -1
  184. package/apps/web/dist/assets/SettingsPage-ChYLv-MG.js +0 -1
  185. package/apps/web/dist/assets/SetupPage-hX7deF0g.js +0 -1
  186. package/apps/web/dist/assets/changelog-Dn9LT4MS.js +0 -1
  187. package/apps/web/dist/assets/esm-C-ZWeuhU.js +0 -7
  188. package/apps/web/dist/assets/index-4jH2mkp7.js +0 -14
  189. package/apps/web/dist/assets/index-BwW652E-.css +0 -1
  190. package/apps/web/dist/assets/oss-credits-Bc05Qv5H.js +0 -1
  191. package/apps/web/dist/assets/settings-menu-Dpkp3f56.js +0 -1
  192. package/apps/web/dist/assets/ui-DMmT-cSO.js +0 -137
  193. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/assistant.d.ts +0 -0
  194. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/assistant.js +0 -0
  195. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/changes.d.ts +0 -0
  196. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/changes.js +0 -0
  197. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/claude-plugin.d.ts +0 -0
  198. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/claude-plugin.js +0 -0
  199. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/connectors.d.ts +0 -0
  200. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/connectors.js +0 -0
  201. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/decision.d.ts +0 -0
  202. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/decision.js +0 -0
  203. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/engenty/data-tables/columns-format.d.ts +0 -0
  204. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/engenty/data-tables/columns-format.js +0 -0
  205. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/engenty/data-tables/columns-value.d.ts +0 -0
  206. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/engenty/data-tables/columns-value.js +0 -0
  207. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/engenty/data-tables/columns.d.ts +0 -0
  208. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/engenty/data-tables/columns.js +0 -0
  209. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/engenty/data-tables/index.d.ts +0 -0
  210. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/engenty/data-tables/index.js +0 -0
  211. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/engenty/search-index/catalog-lexical.d.ts +0 -0
  212. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/engenty/search-index/catalog-lexical.js +0 -0
  213. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/engenty/search-index/catalog-rank.d.ts +0 -0
  214. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/engenty/search-index/catalog-rank.js +0 -0
  215. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/feature-flags.d.ts +0 -0
  216. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/feature-flags.js +0 -0
  217. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/features.d.ts +0 -0
  218. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/features.js +0 -0
  219. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/fit.d.ts +0 -0
  220. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/fit.js +0 -0
  221. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/json-schema.d.ts +0 -0
  222. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/json-schema.js +0 -0
  223. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/knowledge.d.ts +0 -0
  224. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/knowledge.js +0 -0
  225. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/marketplace-entry.d.ts +0 -0
  226. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/marketplace-entry.js +0 -0
  227. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/marketplace-search.d.ts +0 -0
  228. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/marketplace-search.js +0 -0
  229. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/marketplace.d.ts +0 -0
  230. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/marketplace.js +0 -0
  231. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/merge.d.ts +0 -0
  232. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/merge.js +0 -0
  233. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/numbers.d.ts +0 -0
  234. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/numbers.js +0 -0
  235. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/projects.d.ts +0 -0
  236. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/projects.js +0 -0
  237. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/providers.d.ts +0 -0
  238. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/providers.js +0 -0
  239. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/runner-texts.d.ts +0 -0
  240. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/runner-texts.js +0 -0
  241. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/runners.d.ts +0 -0
  242. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/runners.js +0 -0
  243. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/shape.d.ts +0 -0
  244. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/shape.js +0 -0
  245. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/space-data.d.ts +0 -0
  246. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/space-data.js +0 -0
  247. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/store.js +0 -0
  248. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/surface.d.ts +0 -0
  249. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/surface.js +0 -0
  250. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/texts.d.ts +0 -0
  251. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/texts.js +0 -0
  252. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/translation.d.ts +0 -0
  253. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/translation.js +0 -0
  254. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/wizard-package.d.ts +0 -0
  255. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/wizard-package.js +0 -0
  256. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/workspace.d.ts +0 -0
  257. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/workspace.js +0 -0
@@ -1,7 +1,7 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{$ as r,Ar as i,Gr as a,It as o,Lr as s,Qt as c,Rt as l,Ur as u,Vr as d,W as f,Zt as p,an as m,cr as h,d as g,en as _,f as v,gi as y,h as b,ir as x,kt as S,l as ee,m as te,oi as C,p as ne,qn as w,zt as T}from"./ui-DMmT-cSO.js";import{a as re,c as E,i as ie,l as ae}from"./NewWizardChannels-Ba3XGpro.js";import{t as D}from"./upload-JX9BcMTq.js";import{Ct as oe,_ as O,an as k,b as A,ft as j,ht as M,ut as se,v as ce,vt as N,y as P}from"./index-4jH2mkp7.js";var F=[[`id`,8],[`toolId`,10],[`moduleId`,7],[`pluginId`,6],[`title`,6],[`description`,4],[`tags`,3],[`path`,3],[`inputSchema`,2],[`outputSchema`,2],[`request`,1],[`response`,1]];function I(e){return e.normalize(`NFKD`).replace(/[̀-ͯ]/g,``).replace(/([a-z])([A-Z])/g,`$1 $2`).toLowerCase()}function L(e){return I(e).split(/[^a-z0-9]+/).map(e=>e.trim()).filter(e=>e.length>1)}function R(e){return e==null?``:Array.isArray(e)?e.map(R).filter(Boolean).join(` `):typeof e==`object`?Object.values(e).map(R).filter(Boolean).join(` `):String(e)}function z(e,t){let n=t.map(([t,n])=>({text:R(e[t]),weight:n})).filter(e=>e.text.length>0);return{fields:n,tokens:n.flatMap(e=>L(e.text))}}function B(e){let t=[e];if(e.length<5)return t;if(e.endsWith(`ing`)){let n=e.slice(0,-3);n.length>=3&&t.push(n,`${n}e`)}else if(e.endsWith(`ies`)&&e.length>=6)t.push(`${e.slice(0,-3)}y`);else if(e.endsWith(`es`))t.push(e.slice(0,-2),e.slice(0,-1));else if(e.endsWith(`ed`)){let n=e.slice(0,-2);t.push(n,`${n}e`)}else e.endsWith(`s`)&&!e.endsWith(`ss`)&&t.push(e.slice(0,-1));return[...new Set(t)]}function V(e,t){if(e===t)return 1;let n=0;for(let r of B(e))for(let i of B(t)){if(r===i){n=Math.max(n,r===e&&i===t?1:.75);continue}r.length>=2&&i.startsWith(r)&&(n=Math.max(n,.55*(r.length/i.length))),i.length>=4&&r.startsWith(i)&&(n=Math.max(n,.4*(i.length/r.length)))}return n}function H(e,t){return e.reduce((e,n)=>e+V(t,n),0)}function U(e,t,n=F){if(!t?.trim())return 0;let r=L(t);if(r.length===0)return 0;let i=z(e,n);return i.tokens.length===0?0:r.reduce((e,t)=>H(i.tokens,t)===0?e:e+i.fields.reduce((e,n)=>{let r=L(n.text),i=H(r,t);if(i===0)return e;let a=i*2.2/(i+1.2+r.length/16);return e+n.weight*a},0),0)}var W=new Set(L(`aber als also am an auch auf aus bei bin bitte brauche brauchen braucht das dass dem den der
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{Br as r,Er as i,Hn as a,Kt as o,Lr as s,Nr as c,Nt as l,Pt as u,R as d,Yt as f,a as p,c as m,di as h,en as g,er as _,ir as v,jt as y,l as b,o as x,q as S,qt as C,r as ee,s as te,ti as w,wt as T,zr as ne}from"./ui-Cdv3QUOd.js";import{t as E}from"./upload-DCMZI6pp.js";import{At as re,C as ie,S as D,St as O,T as k,Tt as A,_t as ae,w as j,yn as M,yt as N}from"./index-CQKA-z2z.js";import{a as oe,c as P,i as se,l as ce}from"./NewWizardChannels-BGzp9z0m.js";var F=[[`id`,8],[`toolId`,10],[`moduleId`,7],[`pluginId`,6],[`title`,6],[`description`,4],[`tags`,3],[`path`,3],[`inputSchema`,2],[`outputSchema`,2],[`request`,1],[`response`,1]];function I(e){return e.normalize(`NFKD`).replace(/[̀-ͯ]/g,``).replace(/([a-z])([A-Z])/g,`$1 $2`).toLowerCase()}function L(e){return I(e).split(/[^a-z0-9]+/).map(e=>e.trim()).filter(e=>e.length>1)}function R(e){return e==null?``:Array.isArray(e)?e.map(R).filter(Boolean).join(` `):typeof e==`object`?Object.values(e).map(R).filter(Boolean).join(` `):String(e)}function z(e,t){let n=t.map(([t,n])=>({text:R(e[t]),weight:n})).filter(e=>e.text.length>0);return{fields:n,tokens:n.flatMap(e=>L(e.text))}}function B(e){let t=[e];if(e.length<5)return t;if(e.endsWith(`ing`)){let n=e.slice(0,-3);n.length>=3&&t.push(n,`${n}e`)}else if(e.endsWith(`ies`)&&e.length>=6)t.push(`${e.slice(0,-3)}y`);else if(e.endsWith(`es`))t.push(e.slice(0,-2),e.slice(0,-1));else if(e.endsWith(`ed`)){let n=e.slice(0,-2);t.push(n,`${n}e`)}else e.endsWith(`s`)&&!e.endsWith(`ss`)&&t.push(e.slice(0,-1));return[...new Set(t)]}function V(e,t){if(e===t)return 1;let n=0;for(let r of B(e))for(let i of B(t)){if(r===i){n=Math.max(n,r===e&&i===t?1:.75);continue}r.length>=2&&i.startsWith(r)&&(n=Math.max(n,.55*(r.length/i.length))),i.length>=4&&r.startsWith(i)&&(n=Math.max(n,.4*(i.length/r.length)))}return n}function H(e,t){return e.reduce((e,n)=>e+V(t,n),0)}function U(e,t,n=F){if(!t?.trim())return 0;let r=L(t);if(r.length===0)return 0;let i=z(e,n);return i.tokens.length===0?0:r.reduce((e,t)=>H(i.tokens,t)===0?e:e+i.fields.reduce((e,n)=>{let r=L(n.text),i=H(r,t);if(i===0)return e;let a=i*2.2/(i+1.2+r.length/16);return e+n.weight*a},0),0)}var W=new Set(L(`aber als also am an auch auf aus bei bin bitte brauche brauchen braucht das dass dem den der
2
2
  des die dies diese dieser doch du ein eine einem einen einer eines er es etwas fuer für gerne
3
3
  habe haben hat ich ihr im in ist kann können koennen mache machen mag mein meine meinem meinen
4
4
  meiner mich mir mit möchte moechte nach nicht noch nur oder sich sie sind soll suche suchen
5
5
  sucht um und uns unser unsere vom von vor was wie will wir wird wo wollen zu zum zur
6
6
  a about an and are as at be can do for from have how i in is it like looking me my need of on
7
- or our that the this to want we what which who with would you your`)),G=e=>e.replace(/ß/g,`ss`);function K(e){let t=L(G(e)),n=t.filter(e=>!W.has(e));return n.length?n:t}var q=e=>e.trim().split(/\s+/).filter(Boolean).length>=3,J=e(t(),1),Y=e(n(),1);function le({variant:e=`secondary`,label:t=m(`home.import`)}){let n=d(),r=y(),{project:i}=M(),a=N(),s=(0,J.useRef)(null),c=k({mutationFn:e=>f.upload(`/api/studio/projects/${i.id}/wizards/import`,e),onSuccess:async({id:e})=>{await r.invalidateQueries({queryKey:[`projects`]}),await r.invalidateQueries({queryKey:[`wizards`]}),n(`/edit/${e}`)}}),l=c.error instanceof S?c.error.body?.issues??[]:[];return!a||i?.readOnly?null:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(o,{variant:e,busy:c.isPending,disabled:!i,onClick:()=>s.current?.click(),children:[(0,Y.jsx)(D,{className:`size-4`}),` `,t]}),(0,Y.jsx)(`input`,{ref:s,hidden:!0,type:`file`,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t&&c.mutate(t)}}),(0,Y.jsxs)(T,{open:c.isError,onClose:c.reset,title:m(`import.failed`),children:[(0,Y.jsx)(`p`,{className:`text-[0.875rem] text-ink-2`,children:c.error?.message}),l.length?(0,Y.jsx)(`ul`,{className:`mt-3 flex list-disc flex-col gap-1 pl-5 text-[0.8125rem] text-ink-2`,children:l.slice(0,8).map(e=>(0,Y.jsx)(`li`,{children:e.message},e.message))}):null,(0,Y.jsx)(`div`,{className:`mt-5 flex justify-end`,children:(0,Y.jsx)(o,{variant:`secondary`,onClick:c.reset,children:m(`common.close`)})})]})]})}var X=10,Z=3;async function ue(e,t){let n=await fetch(r(`/api/studio/wizards/${e}/files/${encodeURIComponent(t.name)}`),{method:`PUT`,credentials:`include`,headers:{"content-type":t.type||`application/octet-stream`,"accept-language":_},body:t});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error??n.statusText)}}function Q({over:e,onClick:t}){return(0,Y.jsx)(`button`,{type:`button`,"aria-label":m(`editor.detach`),onClick:t,className:c(`inline-flex shrink-0 items-center justify-center rounded-full`,e?`-top-1.5 -right-1.5 absolute size-5 bg-ink text-paper shadow-soft coarse:size-7`:`size-5 text-ink-3 hover:bg-paper-3 hover:text-ink coarse:size-7`),children:(0,Y.jsx)(w,{className:`size-3`})})}function $(e,t){let n=K(t);if(!n.length)return[];let r=e.map(e=>({w:e,score:U({title:e.title,summary:e.description},n.join(` `),[[`title`,10],[`summary`,6]])})).filter(e=>e.score>0).sort((e,t)=>t.score-e.score),i=q(t)?(r[0]?.score??0)*.4:0;return r.filter(e=>e.score>=i).slice(0,Z).map(e=>e.w)}function de({wish:e,projectId:t,busy:n,onTake:r,onMore:i}){let s=d(),[c,u]=(0,J.useState)(null),p=A(e.trim(),300),h=a({queryKey:[`wizards`,t,`similar`],queryFn:()=>f.get(`/api/studio/projects/${t}/wizards`)}),g=a({queryKey:[`marketplace`,_,p,`similar`],queryFn:()=>f.get(`/api/studio/marketplace?${new URLSearchParams({lang:_,limit:String(X),offset:`0`,q:p})}`),enabled:p.length>=3,placeholderData:C});if(p.length<3)return null;let v=$(h.data??[],p),y=(g.data?.entries??[]).slice(0,X-v.length),b=(g.data?.total??0)-y.length;if(!(v.length||y.length))return null;let x=`flex items-center gap-3 rounded-xl bg-card py-2 pr-2 pl-3.5 ring-1 ring-border-soft`;return(0,Y.jsxs)(`section`,{className:`mt-5`,children:[(0,Y.jsx)(`h2`,{className:`mb-2 px-1 text-[0.8125rem] text-ink-3`,children:m(`new.similar`)}),(0,Y.jsxs)(`ul`,{className:`flex flex-col gap-1.5`,children:[v.map(e=>(0,Y.jsxs)(`li`,{className:x,children:[(0,Y.jsx)(l,{children:m(`new.yours`)}),(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>s(`/edit/${e.id}`),className:`min-w-0 flex-1 text-left`,children:[(0,Y.jsx)(`span`,{className:`block truncate font-medium text-[0.9375rem]`,children:e.title}),(0,Y.jsx)(`span`,{className:`block truncate text-[0.8125rem] text-ink-3`,children:e.description})]}),(0,Y.jsx)(o,{variant:`secondary`,size:`sm`,onClick:()=>s(`/edit/${e.id}`),children:m(`new.open`)})]},e.id)),y.map(e=>(0,Y.jsxs)(`li`,{className:x,children:[(0,Y.jsx)(l,{children:m(`new.template`)}),(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>u(e.id),className:`min-w-0 flex-1 text-left`,children:[(0,Y.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`truncate font-medium text-[0.9375rem]`,children:e.title}),e.plan===`pro`?(0,Y.jsx)(P,{}):null]}),(0,Y.jsx)(`span`,{className:`block truncate text-[0.8125rem] text-ink-3`,children:e.pitch})]}),(0,Y.jsx)(o,{variant:`secondary`,size:`sm`,disabled:n,onClick:()=>r(e),children:m(`new.take`)})]},e.id))]}),b>0?(0,Y.jsx)(`button`,{type:`button`,onClick:()=>i(p),className:`mt-2 px-1 text-[0.875rem] text-ink-2 hover:text-ink coarse:min-h-11`,children:m(`new.more`,{n:b})}):null,(0,Y.jsx)(O,{id:c,fallback:y.find(e=>e.id===c)??null,onClose:()=>u(null),onUse:r,busy:n})]})}function fe(){let e=d(),t=y(),{project:n}=M(),r=N(),[l]=u(),[S,C]=(0,J.useState)(()=>l.get(`wish`)??j()??``),w=(0,J.useRef)(j()!==null),[T,D]=(0,J.useState)([`steps`]),[O,A]=(0,J.useState)([]),[P,F]=(0,J.useState)(!1),[I,L]=(0,J.useState)(null),R=(0,J.useRef)(null),z=(0,J.useRef)(null),B=(0,J.useRef)(null),[V]=b(),H=te(S,C,{deviceId:V.deviceId}),U=a({queryKey:[`runners`],queryFn:()=>f.get(`/api/studio/runners`)}),W=e=>{let t=e.map(ne);A(e=>[...e.filter(e=>!t.some(t=>t.name===e.name)),...t])},[G,K]=(0,J.useState)(new Map);(0,J.useEffect)(()=>{let e=new Map(O.filter(e=>e.type.startsWith(`image/`)).map(e=>[e,URL.createObjectURL(e)]));return K(e),()=>{for(let t of e.values())URL.revokeObjectURL(t)}},[O]);let q=k({mutationFn:e=>f.post(`/api/studio/wizards`,{projectId:n.id,starterId:e,lang:_}),onSuccess:async({id:n})=>{await t.invalidateQueries({queryKey:[`projects`]}),await t.invalidateQueries({queryKey:[`wizards`]}),e(`/edit/${n}`)}}),X=k({mutationFn:async()=>{let e=B.current??(await f.post(`/api/studio/wizards`,{projectId:n.id,lang:_})).id;B.current=e,E(T)||await f.patch(`/api/studio/wizards/${e}`,{runners:ae(T)});for(let t of O)await ue(e,t);return e},onSuccess:async n=>{se(),await t.invalidateQueries({queryKey:[`projects`]}),await t.invalidateQueries({queryKey:[`wizards`]});let r=S.trim();E(T)||(r+=`\n\n${re(T)}`),O.length&&(r+=`\n\n${m(`editor.attached`)}: ${O.map(e=>e.name).join(`, `)}`),e(`/edit/${n}?prompt=${encodeURIComponent(r)}`)}}),Z=()=>{S.trim()&&n&&!X.isPending&&(H.listening&&H.stop(),X.mutate())};if((0,J.useEffect)(()=>{w.current&&n&&r&&!n.readOnly&&S.trim()&&(w.current=!1,X.mutate())},[n,r,S,X]),!r||n?.readOnly)return(0,Y.jsx)(s,{to:`/`,replace:!0});let $=X.error??q.error;return(0,Y.jsxs)(`div`,{className:`animate-rise md:pt-4`,children:[(0,Y.jsxs)(`div`,{className:`mx-auto max-w-2xl`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-col items-center text-center`,children:[(0,Y.jsx)(`div`,{className:`size-[84px] md:size-auto`,children:(0,Y.jsx)(`div`,{className:`origin-top-left scale-[0.56] md:scale-100`,children:(0,Y.jsx)(oe,{kind:`sprout`,size:150,fluffy:!0})})}),(0,Y.jsx)(`h1`,{className:`mt-1 font-display font-semibold text-[1.5rem] leading-tight tracking-tight md:mt-2 md:text-[2.375rem]`,children:m(`new.title`)})]}),(0,Y.jsx)(ie,{value:T,onChange:D,runners:U.data,className:`mt-4 px-1 md:mt-8`}),(0,Y.jsxs)(`div`,{className:c(`relative mt-3 rounded-2xl bg-card p-2 shadow-elevated ring-1 ring-border-soft focus-within:ring-focus`,P&&`ring-2 ring-focus`),onDragOver:e=>{e.dataTransfer.types.includes(`Files`)&&(e.preventDefault(),F(!0))},onDragLeave:()=>F(!1),onDrop:e=>{e.preventDefault(),F(!1),W(Array.from(e.dataTransfer.files).map(v))},children:[O.length?(0,Y.jsx)(`div`,{className:`flex flex-wrap items-center gap-2 px-2 pt-2 pb-1`,children:O.map((e,t)=>{let n=G.get(e),r=()=>A(e=>e.filter((e,n)=>n!==t));return n?(0,Y.jsx)(g,{url:n,label:e.name,children:(0,Y.jsx)(Q,{over:!!n,onClick:r})},`${e.name}-${t}`):(0,Y.jsxs)(`span`,{className:`inline-flex max-w-full items-center gap-1.5 rounded-full bg-paper-2 py-1 pr-1 pl-2.5 text-[0.8125rem] text-ink-2`,children:[(0,Y.jsx)(h,{className:`size-3.5 shrink-0 text-ink-4`}),(0,Y.jsx)(`span`,{className:`truncate`,children:e.name}),(0,Y.jsx)(Q,{over:!!n,onClick:r})]},`${e.name}-${t}`)})}):null,(0,Y.jsx)(p,{autoFocus:!0,minRows:4,value:S,onChange:e=>C(e.target.value),onPaste:e=>{let t=Array.from(e.clipboardData.files);t.length&&(e.preventDefault(),W(t.map(v)))},onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&Z()},placeholder:H.listening?m(`editor.listening`):m(`new.placeholder`),className:`border-0 bg-transparent text-[1rem] shadow-none focus:ring-0`}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 px-1 pb-1`,children:[(0,Y.jsx)(`button`,{type:`button`,"aria-label":m(`editor.attach`),title:m(`editor.attach`),onClick:()=>z.current?.click(),className:`inline-flex size-10 shrink-0 items-center justify-center rounded-full border border-border text-ink transition hover:bg-paper-2 coarse:size-11`,children:(0,Y.jsx)(x,{className:`size-4`})}),(0,Y.jsx)(`input`,{ref:z,type:`file`,multiple:!0,hidden:!0,onChange:e=>{let t=Array.from(e.target.files??[]);e.target.value=``,W(t)}}),H.supported?(0,Y.jsx)(ee,{speech:H,labelled:!0}):null,(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[0.75rem] text-ink-4`,children:P?m(`new.dropHint`):null}),(0,Y.jsxs)(o,{size:`md`,onClick:Z,busy:X.isPending,disabled:!S.trim()||q.isPending,children:[m(`new.build`),` `,(0,Y.jsx)(i,{className:`size-4`})]})]})]}),(0,Y.jsx)(`p`,{className:`mt-3 text-center text-[0.875rem] text-ink-3`,children:m(`new.hint`)}),H.error?(0,Y.jsx)(`p`,{className:`mt-2 px-3 text-[0.75rem] text-rose`,children:H.error===`denied`?m(`editor.micDenied`):H.error}):null,$?(0,Y.jsx)(`p`,{className:`mt-3 text-center text-[0.875rem] text-rose`,children:$.message}):null,n?(0,Y.jsx)(de,{wish:S,projectId:n.id,busy:q.isPending||X.isPending,onTake:e=>!q.isPending&&q.mutate(e.id),onMore:e=>{L({text:e}),R.current?.scrollIntoView({behavior:`smooth`,block:`start`})}}):null]}),(0,Y.jsxs)(`section`,{ref:R,className:`mx-auto max-w-5xl scroll-mt-6`,children:[(0,Y.jsx)(`h2`,{className:`mt-16 mb-5 text-center font-medium text-[0.8125rem] text-ink-3 uppercase tracking-[0.08em]`,children:m(`new.orStarter`)}),(0,Y.jsx)(ce,{open:l.get(`starter`),search:I,busy:q.isPending,onUse:e=>n&&!q.isPending&&q.mutate(e.id)})]}),(0,Y.jsx)(`div`,{className:`mt-8 flex justify-center`,children:(0,Y.jsx)(le,{variant:`ghost`,label:m(`new.import`)})})]})}export{fe as NewWizardPage};
7
+ or our that the this to want we what which who with would you your`)),G=e=>e.replace(/ß/g,`ss`);function K(e){let t=L(G(e)),n=t.filter(e=>!W.has(e));return n.length?n:t}var q=e=>e.trim().split(/\s+/).filter(Boolean).length>=3,J=e(t(),1),Y=e(n(),1);function le({variant:e=`secondary`,label:t=g(`home.import`)}){let n=s(),r=h(),{project:i}=O(),a=A(),o=(0,J.useRef)(null),c=M({mutationFn:e=>d.upload(`/api/studio/projects/${i.id}/wizards/import`,e),onSuccess:async({id:e})=>{await r.invalidateQueries({queryKey:[`projects`]}),await r.invalidateQueries({queryKey:[`wizards`]}),n(`/edit/${e}`)}}),l=c.error instanceof T?c.error.body?.issues??[]:[];return!a||i?.readOnly?null:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(y,{variant:e,busy:c.isPending,disabled:!i,onClick:()=>o.current?.click(),children:[(0,Y.jsx)(E,{className:`size-4`}),` `,t]}),(0,Y.jsx)(`input`,{ref:o,hidden:!0,type:`file`,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t&&c.mutate(t)}}),(0,Y.jsxs)(u,{open:c.isError,onClose:c.reset,title:g(`import.failed`),children:[(0,Y.jsx)(`p`,{className:`text-[0.875rem] text-ink-2`,children:c.error?.message}),l.length?(0,Y.jsx)(`ul`,{className:`mt-3 flex list-disc flex-col gap-1 pl-5 text-[0.8125rem] text-ink-2`,children:l.slice(0,8).map(e=>(0,Y.jsx)(`li`,{children:e.message},e.message))}):null,(0,Y.jsx)(`div`,{className:`mt-5 flex justify-end`,children:(0,Y.jsx)(y,{variant:`secondary`,onClick:c.reset,children:g(`common.close`)})})]})]})}var X=10,Z=3;async function ue(e,t){let n=await fetch(S(`/api/studio/wizards/${e}/files/${encodeURIComponent(t.name)}`),{method:`PUT`,credentials:`include`,headers:{"content-type":t.type||`application/octet-stream`,"accept-language":f},body:t});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error??n.statusText)}}function Q({over:e,onClick:t}){return(0,Y.jsx)(`button`,{type:`button`,"aria-label":g(`editor.detach`),onClick:t,className:C(`inline-flex shrink-0 items-center justify-center rounded-full`,e?`-top-1.5 -right-1.5 absolute size-5 bg-ink text-paper shadow-soft coarse:size-7`:`size-5 text-ink-3 hover:bg-paper-3 hover:text-ink coarse:size-7`),children:(0,Y.jsx)(a,{className:`size-3`})})}function $(e,t){let n=K(t);if(!n.length)return[];let r=e.map(e=>({w:e,score:U({title:e.title,summary:e.description},n.join(` `),[[`title`,10],[`summary`,6]])})).filter(e=>e.score>0).sort((e,t)=>t.score-e.score),i=q(t)?(r[0]?.score??0)*.4:0;return r.filter(e=>e.score>=i).slice(0,Z).map(e=>e.w)}function de({wish:e,projectId:t,busy:n,onTake:i,onMore:a}){let o=s(),[c,u]=(0,J.useState)(null),p=k(e.trim(),300),m=r({queryKey:[`wizards`,t,`similar`],queryFn:()=>d.get(`/api/studio/projects/${t}/wizards`)}),h=r({queryKey:[`marketplace`,f,p,`similar`],queryFn:()=>d.get(`/api/studio/marketplace?${new URLSearchParams({lang:f,limit:String(X),offset:`0`,q:p})}`),enabled:p.length>=3,placeholderData:w});if(p.length<3)return null;let _=$(m.data??[],p),v=(h.data?.entries??[]).slice(0,X-_.length),b=(h.data?.total??0)-v.length;if(!(_.length||v.length))return null;let x=`flex items-center gap-3 rounded-xl bg-card py-2 pr-2 pl-3.5 ring-1 ring-border-soft`;return(0,Y.jsxs)(`section`,{className:`mt-5`,children:[(0,Y.jsx)(`h2`,{className:`mb-2 px-1 text-[0.8125rem] text-ink-3`,children:g(`new.similar`)}),(0,Y.jsxs)(`ul`,{className:`flex flex-col gap-1.5`,children:[_.map(e=>(0,Y.jsxs)(`li`,{className:x,children:[(0,Y.jsx)(l,{children:g(`new.yours`)}),(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>o(`/edit/${e.id}`),className:`min-w-0 flex-1 text-left`,children:[(0,Y.jsx)(`span`,{className:`block truncate font-medium text-[0.9375rem]`,children:e.title}),(0,Y.jsx)(`span`,{className:`block truncate text-[0.8125rem] text-ink-3`,children:e.description})]}),(0,Y.jsx)(y,{variant:`secondary`,size:`sm`,onClick:()=>o(`/edit/${e.id}`),children:g(`new.open`)})]},e.id)),v.map(e=>(0,Y.jsxs)(`li`,{className:x,children:[(0,Y.jsx)(l,{children:g(`new.template`)}),(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>u(e.id),className:`min-w-0 flex-1 text-left`,children:[(0,Y.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`truncate font-medium text-[0.9375rem]`,children:e.title}),e.plan===`pro`?(0,Y.jsx)(j,{}):null]}),(0,Y.jsx)(`span`,{className:`block truncate text-[0.8125rem] text-ink-3`,children:e.pitch})]}),(0,Y.jsx)(y,{variant:`secondary`,size:`sm`,disabled:n,onClick:()=>i(e),children:g(`new.take`)})]},e.id))]}),b>0?(0,Y.jsx)(`button`,{type:`button`,onClick:()=>a(p),className:`mt-2 px-1 text-[0.875rem] text-ink-2 hover:text-ink coarse:min-h-11`,children:g(`new.more`,{n:b})}):null,(0,Y.jsx)(D,{id:c,fallback:v.find(e=>e.id===c)??null,onClose:()=>u(null),onUse:i,busy:n})]})}function fe(){let e=s(),t=h(),{project:n}=O(),a=A(),[l]=ne(),[u,S]=(0,J.useState)(()=>l.get(`wish`)??N()??``),w=(0,J.useRef)(N()!==null),[T,E]=(0,J.useState)([`steps`]),[D,k]=(0,J.useState)([]),[j,F]=(0,J.useState)(!1),[I,L]=(0,J.useState)(null),R=(0,J.useRef)(null),z=(0,J.useRef)(null),B=(0,J.useRef)(null),[V]=b(),H=m(u,S,{deviceId:V.deviceId}),U=r({queryKey:[`runners`],queryFn:()=>d.get(`/api/studio/runners`)}),W=e=>{let t=e.map(te);k(e=>[...e.filter(e=>!t.some(t=>t.name===e.name)),...t])},[G,K]=(0,J.useState)(new Map);(0,J.useEffect)(()=>{let e=new Map(D.filter(e=>e.type.startsWith(`image/`)).map(e=>[e,URL.createObjectURL(e)]));return K(e),()=>{for(let t of e.values())URL.revokeObjectURL(t)}},[D]);let q=M({mutationFn:e=>d.post(`/api/studio/wizards`,{projectId:n.id,starterId:e,lang:f}),onSuccess:async({id:n})=>{await t.invalidateQueries({queryKey:[`projects`]}),await t.invalidateQueries({queryKey:[`wizards`]}),e(`/edit/${n}`)}}),X=M({mutationFn:async()=>{let e=B.current??(await d.post(`/api/studio/wizards`,{projectId:n.id,lang:f})).id;B.current=e,P(T)||await d.patch(`/api/studio/wizards/${e}`,{runners:ce(T)});for(let t of D)await ue(e,t);return e},onSuccess:async n=>{ae(),await t.invalidateQueries({queryKey:[`projects`]}),await t.invalidateQueries({queryKey:[`wizards`]});let r=u.trim();P(T)||(r+=`\n\n${oe(T)}`),D.length&&(r+=`\n\n${g(`editor.attached`)}: ${D.map(e=>e.name).join(`, `)}`),e(`/edit/${n}?prompt=${encodeURIComponent(r)}`)}}),Z=()=>{u.trim()&&n&&!X.isPending&&(H.listening&&H.stop(),X.mutate())};if((0,J.useEffect)(()=>{w.current&&n&&a&&!n.readOnly&&u.trim()&&(w.current=!1,X.mutate())},[n,a,u,X]),!a||n?.readOnly)return(0,Y.jsx)(c,{to:`/`,replace:!0});let $=X.error??q.error;return(0,Y.jsxs)(`div`,{className:`animate-rise md:pt-4`,children:[(0,Y.jsxs)(`div`,{className:`mx-auto max-w-2xl`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-col items-center text-center`,children:[(0,Y.jsx)(`div`,{className:`size-[84px] md:size-auto`,children:(0,Y.jsx)(`div`,{className:`origin-top-left scale-[0.56] md:scale-100`,children:(0,Y.jsx)(re,{kind:`sprout`,size:150,fluffy:!0})})}),(0,Y.jsx)(`h1`,{className:`mt-1 font-display font-semibold text-[1.5rem] leading-tight tracking-tight md:mt-2 md:text-[2.375rem]`,children:g(`new.title`)})]}),(0,Y.jsx)(se,{value:T,onChange:E,runners:U.data,className:`mt-4 px-1 md:mt-8`}),(0,Y.jsxs)(`div`,{className:C(`relative mt-3 rounded-2xl bg-card p-2 shadow-elevated ring-1 ring-border-soft focus-within:ring-focus`,j&&`ring-2 ring-focus`),onDragOver:e=>{e.dataTransfer.types.includes(`Files`)&&(e.preventDefault(),F(!0))},onDragLeave:()=>F(!1),onDrop:e=>{e.preventDefault(),F(!1),W(Array.from(e.dataTransfer.files).map(x))},children:[D.length?(0,Y.jsx)(`div`,{className:`flex flex-wrap items-center gap-2 px-2 pt-2 pb-1`,children:D.map((e,t)=>{let n=G.get(e),r=()=>k(e=>e.filter((e,n)=>n!==t));return n?(0,Y.jsx)(p,{url:n,label:e.name,children:(0,Y.jsx)(Q,{over:!!n,onClick:r})},`${e.name}-${t}`):(0,Y.jsxs)(`span`,{className:`inline-flex max-w-full items-center gap-1.5 rounded-full bg-paper-2 py-1 pr-1 pl-2.5 text-[0.8125rem] text-ink-2`,children:[(0,Y.jsx)(v,{className:`size-3.5 shrink-0 text-ink-4`}),(0,Y.jsx)(`span`,{className:`truncate`,children:e.name}),(0,Y.jsx)(Q,{over:!!n,onClick:r})]},`${e.name}-${t}`)})}):null,(0,Y.jsx)(o,{autoFocus:!0,minRows:4,value:u,onChange:e=>S(e.target.value),onPaste:e=>{let t=Array.from(e.clipboardData.files);t.length&&(e.preventDefault(),W(t.map(x)))},onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&Z()},placeholder:H.listening?g(`editor.listening`):g(`new.placeholder`),className:`border-0 bg-transparent text-[1rem] shadow-none focus:ring-0`}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 px-1 pb-1`,children:[(0,Y.jsx)(`button`,{type:`button`,"aria-label":g(`editor.attach`),title:g(`editor.attach`),onClick:()=>z.current?.click(),className:`inline-flex size-10 shrink-0 items-center justify-center rounded-full border border-border text-ink transition hover:bg-paper-2 coarse:size-11`,children:(0,Y.jsx)(_,{className:`size-4`})}),(0,Y.jsx)(`input`,{ref:z,type:`file`,multiple:!0,hidden:!0,onChange:e=>{let t=Array.from(e.target.files??[]);e.target.value=``,W(t)}}),H.supported?(0,Y.jsx)(ee,{speech:H,labelled:!0}):null,(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[0.75rem] text-ink-4`,children:j?g(`new.dropHint`):null}),(0,Y.jsxs)(y,{size:`md`,onClick:Z,busy:X.isPending,disabled:!u.trim()||q.isPending,children:[g(`new.build`),` `,(0,Y.jsx)(i,{className:`size-4`})]})]})]}),(0,Y.jsx)(`p`,{className:`mt-3 text-center text-[0.875rem] text-ink-3`,children:g(`new.hint`)}),H.error?(0,Y.jsx)(`p`,{className:`mt-2 px-3 text-[0.75rem] text-rose`,children:H.error===`denied`?g(`editor.micDenied`):H.error}):null,$?(0,Y.jsx)(`p`,{className:`mt-3 text-center text-[0.875rem] text-rose`,children:$.message}):null,n?(0,Y.jsx)(de,{wish:u,projectId:n.id,busy:q.isPending||X.isPending,onTake:e=>!q.isPending&&q.mutate(e.id),onMore:e=>{L({text:e}),R.current?.scrollIntoView({behavior:`smooth`,block:`start`})}}):null]}),(0,Y.jsxs)(`section`,{ref:R,className:`mx-auto max-w-5xl scroll-mt-6`,children:[(0,Y.jsx)(`h2`,{className:`mt-16 mb-5 text-center font-medium text-[0.8125rem] text-ink-3 uppercase tracking-[0.08em]`,children:g(`new.orStarter`)}),(0,Y.jsx)(ie,{open:l.get(`starter`),search:I,busy:q.isPending,onUse:e=>n&&!q.isPending&&q.mutate(e.id)})]}),(0,Y.jsx)(`div`,{className:`mt-8 flex justify-center`,children:(0,Y.jsx)(le,{variant:`ghost`,label:g(`new.import`)})})]})}export{fe as NewWizardPage};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{Er as r,Lr as i,R as a,Sr as ee,Yt as o,di as te,en as s,fr as ne,qt as c,zr as re}from"./ui-Cdv3QUOd.js";import{t as ie}from"./upload-DCMZI6pp.js";import{At as ae,Et as oe,Ft as l,Mt as se,St as ce,et as le,yn as u,yt as ue}from"./index-CQKA-z2z.js";var d=e(t(),1),f=e(n(),1),p=`oklch(50% 0.2 262)`,m=`oklch(32% 0.15 262)`,de={"--on":`white`,"--dot":`oklch(90% 0.1 80)`,"--ink-2":`oklch(96% 0.02 262)`,"--ink-3":`oklch(90% 0.035 262)`,"--moss":`oklch(90% 0.14 150)`,"--rose":`oklch(89% 0.09 45)`},h={kind:1,details:1,team:1,site:2,know:3,space:4},fe=e=>e!==null&&Object.hasOwn(h,e),g=`w-full rounded-[18px] border border-white/30 bg-white/15 px-6 py-5 text-[1.375rem] text-white outline-none placeholder:text-white/55 focus:border-white/60`;function pe(){return(0,f.jsxs)(`span`,{className:`inline-flex items-center gap-2.5`,children:[(0,f.jsx)(l,{size:28}),(0,f.jsxs)(`span`,{className:`font-display font-semibold text-[1.0625rem] tracking-tight`,children:[`engenty`,(0,f.jsx)(`span`,{className:`mr-[0.09em] ml-[0.06em] text-(color:--dot)`,children:`.`}),(0,f.jsx)(`span`,{className:`font-normal text-white/70`,children:`wizards`})]})]})}function _({children:e,busy:t,onClick:n,type:i=`button`}){return(0,f.jsxs)(`button`,{type:i,disabled:t,onClick:n,className:`inline-flex h-13 cursor-pointer items-center gap-2.5 rounded-full bg-white px-7 font-semibold text-[1rem] transition hover:bg-white/90 disabled:cursor-default disabled:opacity-70`,style:{color:m},children:[e,(0,f.jsx)(r,{className:`size-[18px]`})]})}function v({children:e,onClick:t}){return(0,f.jsx)(`button`,{type:`button`,onClick:t,className:`cursor-pointer font-semibold text-[0.9375rem] text-white/85 transition hover:text-white`,children:e})}function y({step:e}){return(0,f.jsx)(`span`,{className:`ml-auto inline-flex gap-1.5`,role:`img`,"aria-label":s(`onboard.step`,{n:e}),children:[1,2,3,4].map(t=>(0,f.jsx)(`span`,{className:c(`size-2 rounded-full`,t===e?`bg-white`:`bg-white/40`)},t))})}var b=[{kind:`personal`,label:`onboard.kindPersonal`,sub:`onboard.kindPersonalSub`},{kind:`club`,label:`onboard.kindClub`,sub:`onboard.kindClubSub`},{kind:`small`,label:`onboard.kindSmall`,sub:`onboard.kindSmallSub`},{kind:`corp`,label:`onboard.kindCorp`,sub:`onboard.kindCorpSub`}],x=new Set([`gmail.com`,`googlemail.com`,`gmx.at`,`gmx.de`,`gmx.net`,`web.de`,`outlook.com`,`hotmail.com`,`live.com`,`icloud.com`,`me.com`,`yahoo.com`,`yahoo.de`,`aon.at`,`a1.net`,`chello.at`,`t-online.de`,`proton.me`,`protonmail.com`]);function me(e){let t=(e.split(`@`)[1]??``).trim().toLowerCase();return t?x.has(t)?{kind:`personal`,domain:t}:/(verein|club|klub|^sv-|^fc-|^ff-|feuerwehr|musik|chor)/.test(t)?{kind:`club`,domain:t}:{kind:`small`,domain:t}:{kind:null,domain:t}}var S={club:[`0-50`,`50-250`,`250-1000`,`1000+`],small:[`1`,`2-9`,`10-49`],corp:[`50-249`,`250-999`,`1000+`]},C=e=>Number(e).toLocaleString(o),w=e=>{if(e===`1`)return s(`onboard.justMe`);if(e.endsWith(`+`))return`${C(e.slice(0,-1))}+`;let[t,n]=e.split(`-`);return t===`0`?`≤ ${C(n)}`:`${C(t)}–${C(n)}`},he=[`sport`,`culture`,`social`,`education`,`environment`,`rescue`,`other`],ge=[`chair`,`board`,`treasurer`,`secretary`,`member`],_e=[`management`,`it`,`marketing`,`sales`,`operations`,`other`],T=`w-full rounded-[14px] border border-white/30 bg-white/15 px-4 py-3 text-[1.0625rem] text-white outline-none placeholder:text-white/55 focus:border-white/60`;function ve({picked:e,label:t,sub:n,onClick:r}){return(0,f.jsxs)(`button`,{type:`button`,"aria-pressed":e,onClick:r,className:c(`flex cursor-pointer flex-col gap-1 rounded-[18px] border px-5 py-4 text-left transition`,e?`border-white bg-white/25`:`border-white/30 bg-white/10 hover:bg-white/15`),children:[(0,f.jsx)(`span`,{className:`font-display font-semibold text-[1.125rem]`,children:t}),(0,f.jsx)(`span`,{className:`text-[0.875rem] text-white/80`,children:n})]})}function E({label:e,options:t,value:n,text:r,onChange:i}){return(0,f.jsxs)(`fieldset`,{className:`flex flex-col gap-2`,children:[(0,f.jsx)(`legend`,{className:`mb-2 text-[0.9375rem] text-white/85`,children:e}),(0,f.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:t.map(e=>(0,f.jsx)(`button`,{type:`button`,"aria-pressed":n===e,onClick:()=>i(e),className:c(`cursor-pointer rounded-full border px-4 py-2 text-[0.9375rem] transition`,n===e?`border-white bg-white`:`border-white/30 hover:bg-white/15`),style:n===e?{color:m}:void 0,children:r(e)},e))})]})}function D(e,t,n){let r=`${O}${e}:${t}`,[i,a]=(0,d.useState)(()=>{try{let e=sessionStorage.getItem(r);return e===null?n:JSON.parse(e)}catch{return n}});return(0,d.useEffect)(()=>{try{sessionStorage.setItem(r,JSON.stringify(i))}catch{}},[r,i]),[i,a]}var O=`wizards.onboarding:`;function ye(){try{for(let e of Object.keys(sessionStorage))e.startsWith(O)&&sessionStorage.removeItem(e)}catch{}}function k(){se(p);let e=oe(),t=te(),n=i(),{project:r}=ce(),o=e.data?.user.id??``,[l,C]=D(o,`team`,``),[O,k]=D(o,`site`,``),[A,j]=D(o,`line`,null),[M,be]=(0,d.useState)(null),[N,P]=(0,d.useState)([]),F=(0,d.useRef)(null),[I]=(0,d.useState)(ue),[L]=(0,d.useState)(()=>me(e.data?.user.email??``)),[R,xe]=D(o,`profile`,{kind:L.kind,size:null,sector:``,role:null,need:``,legalName:``,phone:``}),[Se,Ce]=re(),z=Se.get(`page`),B=fe(z)&&(z!==`details`||R.kind)?z:`kind`,V=h[B],H=e=>Ce(t=>{let n=new URLSearchParams(t);return n.set(`page`,e),n}),U=e=>xe(t=>({...t,...e})),W=u({mutationFn:e=>a.put(`/api/studio/team/profile`,{kind:R.kind,size:R.size,sector:R.sector.trim()||null,role:R.role,need:R.need.trim()||null,legalName:R.legalName.trim()||null,phone:R.phone.trim()||null,website:e?.trim()||null})}),G=R.kind===`personal`,K=()=>{!O&&L.domain&&R.kind!==`personal`&&!x.has(L.domain)&&k(L.domain),H(`site`)},q=u({mutationFn:e=>a.put(`/api/studio/team`,{name:e}),onSuccess:()=>t.invalidateQueries({queryKey:[`team`]})}),J=u({mutationFn:e=>a.post(`/api/studio/projects/${r?.id}/website`,{url:e}),onSuccess:async e=>{be(e),await t.invalidateQueries({queryKey:[`projects`]})}}),Y=u({mutationFn:e=>a.patch(`/api/studio/projects/${r?.id}`,{brand:{about:e}}),onSuccess:()=>t.invalidateQueries({queryKey:[`projects`]})}),X=u({mutationFn:()=>a.post(`/api/studio/onboarding/done`),onSuccess:async()=>{ye(),await t.invalidateQueries({queryKey:[`me`]}),n(`/new`,{replace:!0})}}),Z=e.data?.user.name??``,Q=Z.includes(`@`)?``:Z.split(` `)[0],$=async e=>{if(e&&r){for(let t of Array.from(e)){P(e=>[...e,{name:t.name,state:`uploading`}]);try{await a.upload(`/api/studio/projects/${r.id}/files?kind=document`,t),P(e=>e.map(e=>e.name===t.name?{...e,state:`done`}:e))}catch{P(e=>e.map(e=>e.name===t.name?{...e,state:`failed`}:e))}}await t.invalidateQueries({queryKey:[`projects`]})}},we=M?[M.about?s(`onboard.readAbout`):``,M.colors?s(`onboard.readColors`,{n:M.colors}):``,M.logo?s(`onboard.readLogo`):``].join(``):``;return(0,f.jsxs)(`div`,{className:`flex min-h-dvh flex-col px-6 text-white sm:px-10`,style:{...de,background:p},children:[(0,f.jsxs)(`header`,{className:`flex items-center justify-between pt-6 sm:pt-8`,children:[(0,f.jsx)(pe,{}),(0,f.jsx)(le,{tone:`ground`,ink:m})]}),(0,f.jsxs)(`main`,{className:`mx-auto grid w-full max-w-6xl flex-1 items-center gap-10 py-10 lg:grid-cols-[5fr_7fr] lg:gap-12`,children:[(0,f.jsxs)(`div`,{className:`flex flex-col items-center gap-8 max-lg:order-first`,children:[(0,f.jsx)(ae,{kind:`drop`,size:240,fluffy:!0,coat:`fur`}),I?(0,f.jsxs)(`figure`,{className:`w-full max-w-sm rounded-[18px] bg-white/15 px-5 py-4`,children:[(0,f.jsx)(`figcaption`,{className:`font-medium text-[0.75rem] text-white/85 uppercase tracking-[0.14em]`,children:s(`onboard.wish`)}),(0,f.jsx)(`blockquote`,{className:`mt-1.5 line-clamp-6 whitespace-pre-line break-words text-[1rem] leading-relaxed`,children:I}),(0,f.jsx)(`p`,{className:`mt-2 text-[0.8125rem] text-white/75`,children:s(`onboard.wishNext`)})]}):null]}),(0,f.jsxs)(`div`,{className:`flex min-w-0 max-w-2xl animate-rise flex-col gap-5`,children:[B===`kind`?(0,f.jsxs)(`form`,{className:`contents`,onSubmit:e=>{e.preventDefault(),R.kind&&H(`details`)},children:[(0,f.jsx)(`p`,{className:`font-medium text-[0.75rem] text-white/85 uppercase tracking-[0.14em]`,children:Q?s(`onboard.kicker1`,{name:Q}):s(`onboard.kicker1Anon`)}),(0,f.jsx)(`h1`,{className:`font-display font-bold text-[2.5rem] leading-[1.05] tracking-[-0.02em] sm:text-[3.25rem]`,children:s(`onboard.kind`)}),(0,f.jsx)(`p`,{className:`text-[1.0625rem] text-white/90 leading-relaxed`,children:s(`onboard.kindSub`)}),L.kind?(0,f.jsx)(`p`,{className:`text-[0.9375rem] text-white/80`,children:s(`onboard.guess`,{domain:L.domain,kind:s(b.find(e=>e.kind===L.kind)?.label??`onboard.kindSmall`)})}):null,(0,f.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:b.map(e=>(0,f.jsx)(ve,{picked:R.kind===e.kind,label:s(e.label),sub:s(e.sub),onClick:()=>U({kind:e.kind,size:e.kind===R.kind?R.size:null})},e.kind))}),(0,f.jsxs)(`div`,{className:`flex flex-wrap items-center gap-5`,children:[(0,f.jsx)(_,{type:`submit`,children:s(`onboard.continue`)}),(0,f.jsx)(y,{step:1})]})]}):null,B===`details`&&R.kind?(0,f.jsxs)(`form`,{className:`contents`,onSubmit:e=>{e.preventDefault(),W.mutate(void 0),R.kind===`corp`&&R.legalName.trim()&&!l&&C(R.legalName.trim()),R.kind===`personal`?K():H(`team`)},children:[(0,f.jsx)(`p`,{className:`font-medium text-[0.75rem] text-white/85 uppercase tracking-[0.14em]`,children:Q?s(`onboard.kicker1`,{name:Q}):s(`onboard.kicker1Anon`)}),(0,f.jsx)(`h1`,{className:`font-display font-bold text-[2.25rem] leading-[1.05] tracking-[-0.02em] sm:text-[2.75rem]`,children:s(R.kind===`personal`?`onboard.personalTitle`:R.kind===`club`?`onboard.clubTitle`:`onboard.businessTitle`)}),R.kind===`personal`?(0,f.jsx)(`textarea`,{value:R.need,onChange:e=>U({need:e.target.value}),placeholder:s(`onboard.personalPlaceholder`),rows:3,maxLength:2e3,"aria-label":s(`onboard.personalTitle`),className:c(g,`resize-none text-[1.125rem] leading-relaxed`)}):null,R.kind===`club`?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(E,{label:s(`onboard.clubKind`),options:he,value:R.sector,text:e=>s(`onboard.club.${e}`),onChange:e=>U({sector:e})}),(0,f.jsx)(E,{label:s(`onboard.members`),options:S.club,value:R.size,text:w,onChange:e=>U({size:e})}),(0,f.jsx)(E,{label:s(`onboard.yourRole`),options:ge,value:R.role,text:e=>s(`onboard.role.${e}`),onChange:e=>U({role:e})})]}):null,R.kind===`small`?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(E,{label:s(`onboard.people`),options:S.small,value:R.size,text:w,onChange:e=>U({size:e})}),(0,f.jsxs)(`label`,{className:`flex flex-col gap-2 text-[0.9375rem] text-white/85`,children:[s(`onboard.sector`),(0,f.jsx)(`input`,{value:R.sector,onChange:e=>U({sector:e.target.value}),placeholder:s(`onboard.sectorPlaceholder`),maxLength:120,className:T})]}),(0,f.jsxs)(`label`,{className:`flex flex-col gap-2 text-[0.9375rem] text-white/85`,children:[(0,f.jsxs)(`span`,{children:[s(`onboard.need`),` `,(0,f.jsx)(`span`,{className:`text-white/60`,children:s(`onboard.optional`)})]}),(0,f.jsx)(`textarea`,{value:R.need,onChange:e=>U({need:e.target.value}),placeholder:s(`onboard.needPlaceholder`),rows:2,maxLength:2e3,className:c(T,`resize-none`)})]})]}):null,R.kind===`corp`?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(E,{label:s(`onboard.people`),options:S.corp,value:R.size,text:w,onChange:e=>U({size:e})}),(0,f.jsx)(E,{label:s(`onboard.yourRole`),options:_e,value:R.role,text:e=>s(`onboard.role.${e}`),onChange:e=>U({role:e})}),(0,f.jsxs)(`label`,{className:`flex flex-col gap-2 text-[0.9375rem] text-white/85`,children:[s(`onboard.legalName`),(0,f.jsx)(`input`,{value:R.legalName,onChange:e=>U({legalName:e.target.value}),placeholder:s(`onboard.legalNamePlaceholder`),maxLength:200,autoComplete:`organization`,className:T})]}),(0,f.jsxs)(`label`,{className:`flex flex-col gap-2 text-[0.9375rem] text-white/85`,children:[(0,f.jsxs)(`span`,{children:[s(`onboard.phone`),` `,(0,f.jsx)(`span`,{className:`text-white/60`,children:s(`onboard.phoneWhy`)})]}),(0,f.jsx)(`input`,{type:`tel`,value:R.phone,onChange:e=>U({phone:e.target.value.replace(/[^+0-9 ()/.-]/g,``)}),placeholder:`+43 …`,maxLength:40,autoComplete:`tel`,className:T})]})]}):null,(0,f.jsxs)(`div`,{className:`flex flex-wrap items-center gap-5`,children:[(0,f.jsx)(_,{type:`submit`,busy:W.isPending,children:s(`onboard.continue`)}),(0,f.jsx)(v,{onClick:()=>window.history.state?.idx>0?n(-1):H(`kind`),children:s(`onboard.back`)}),(0,f.jsx)(y,{step:1})]})]}):null,B===`team`?(0,f.jsxs)(`form`,{className:`contents`,onSubmit:e=>{e.preventDefault();let t=l.trim();t?q.mutate(t,{onSuccess:K}):K()},children:[(0,f.jsx)(`p`,{className:`font-medium text-[0.75rem] text-white/85 uppercase tracking-[0.14em]`,children:Q?s(`onboard.kicker1`,{name:Q}):s(`onboard.kicker1Anon`)}),(0,f.jsx)(`h1`,{className:`font-display font-bold text-[2.5rem] leading-[1.05] tracking-[-0.02em] sm:text-[3.25rem]`,children:s(`onboard.team`)}),(0,f.jsx)(`p`,{className:`text-[1.0625rem] text-white/90 leading-relaxed`,children:s(`onboard.teamSub`)}),(0,f.jsx)(`input`,{value:l,onChange:e=>C(e.target.value),placeholder:s(`onboard.teamPlaceholder`),maxLength:80,"aria-label":s(`onboard.team`),className:g}),(0,f.jsxs)(`div`,{className:`flex flex-wrap items-center gap-5`,children:[(0,f.jsx)(_,{type:`submit`,busy:q.isPending,children:s(`onboard.continue`)}),(0,f.jsx)(y,{step:1})]})]}):null,V===2?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(`p`,{className:`font-medium text-[0.75rem] text-white/85 uppercase tracking-[0.14em]`,children:s(G?`onboard.kicker2Personal`:`onboard.kicker2`)}),(0,f.jsx)(`h1`,{className:`font-display font-bold text-[2.5rem] leading-[1.05] tracking-[-0.02em] sm:text-[3.25rem]`,children:s(`onboard.site`)}),(0,f.jsx)(`p`,{className:`text-[1.0625rem] text-white/90 leading-relaxed`,children:s(G?`onboard.siteSubPersonal`:`onboard.siteSub`)}),A===null?(0,f.jsxs)(`form`,{className:`contents`,onSubmit:e=>{e.preventDefault();let t=O.trim();if(t&&!J.isPending){if(R.kind&&W.mutate(t),!t.includes(`.`)){H(`know`);return}J.mutate(t)}},children:[(0,f.jsx)(`input`,{value:O,onChange:e=>k(e.target.value),placeholder:s(G?`onboard.sitePlaceholderPersonal`:`onboard.sitePlaceholder`),autoCapitalize:`none`,"aria-label":s(`onboard.site`),className:g}),G?null:(0,f.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-white/75`,children:s(`onboard.siteNameHint`)}),M?(0,f.jsxs)(`p`,{className:`flex items-center gap-2 text-[0.9375rem] text-(color:--moss)`,children:[(0,f.jsx)(ee,{className:`size-4`}),s(`onboard.readDone`,{name:M.name,details:we})]}):J.isError?(0,f.jsx)(`p`,{className:`text-[0.9375rem] text-(color:--rose)`,children:s(`onboard.readFailed`)}):null,(0,f.jsxs)(`div`,{className:`flex flex-wrap items-center gap-5`,children:[M?(0,f.jsx)(_,{onClick:()=>H(`know`),children:s(`onboard.continue`)}):(0,f.jsx)(_,{type:`submit`,busy:J.isPending,children:J.isPending?s(`onboard.reading`):s(`onboard.read`)}),(0,f.jsx)(v,{onClick:()=>j(``),children:s(`onboard.line`)}),(0,f.jsx)(v,{onClick:()=>H(`know`),children:s(`onboard.skip`)}),(0,f.jsx)(y,{step:2})]})]}):(0,f.jsxs)(`form`,{className:`contents`,onSubmit:e=>{e.preventDefault();let t=A.trim();t?Y.mutate(t,{onSuccess:()=>H(`know`)}):H(`know`)},children:[(0,f.jsx)(`textarea`,{value:A,onChange:e=>j(e.target.value),placeholder:s(G?`onboard.linePlaceholderPersonal`:`onboard.linePlaceholder`),rows:3,maxLength:8e3,"aria-label":s(`onboard.line`),className:c(g,`resize-none text-[1.125rem] leading-relaxed`)}),(0,f.jsxs)(`div`,{className:`flex flex-wrap items-center gap-5`,children:[(0,f.jsx)(_,{type:`submit`,busy:Y.isPending,children:s(`onboard.continue`)}),(0,f.jsx)(v,{onClick:()=>j(null),children:s(`onboard.site`)}),(0,f.jsx)(v,{onClick:()=>H(`know`),children:s(`onboard.skip`)}),(0,f.jsx)(y,{step:2})]})]})]}):null,V===3?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(`p`,{className:`font-medium text-[0.75rem] text-white/85 uppercase tracking-[0.14em]`,children:s(`onboard.kicker3`)}),(0,f.jsx)(`h1`,{className:`font-display font-bold text-[2.5rem] leading-[1.05] tracking-[-0.02em] sm:text-[3.25rem]`,children:s(`onboard.know`)}),(0,f.jsx)(`p`,{className:`text-[1.0625rem] text-white/90 leading-relaxed`,children:s(`onboard.knowSub`)}),(0,f.jsxs)(`button`,{type:`button`,onClick:()=>F.current?.click(),onDragOver:e=>e.preventDefault(),onDrop:e=>{e.preventDefault(),$(e.dataTransfer.files)},className:`flex cursor-pointer flex-col items-center gap-2 rounded-[18px] border-2 border-white/45 border-dashed bg-white/10 px-6 py-7 text-center transition hover:bg-white/15`,children:[(0,f.jsx)(ie,{className:`size-7`}),(0,f.jsx)(`span`,{className:`font-semibold text-[1.0625rem]`,children:s(`onboard.drop`)}),(0,f.jsx)(`span`,{className:`text-[0.875rem] text-white/80`,children:`PDF · Word · Excel · Markdown`}),(0,f.jsx)(`input`,{ref:F,type:`file`,multiple:!0,className:`sr-only`,onChange:e=>{$(e.target.files),e.target.value=``}})]}),N.length?(0,f.jsx)(`ul`,{className:`flex flex-col gap-2`,children:N.map(e=>(0,f.jsxs)(`li`,{className:`flex items-center gap-2.5 rounded-xl bg-white/15 px-3.5 py-2.5 text-[0.875rem]`,children:[(0,f.jsx)(ne,{className:`size-4 shrink-0`}),(0,f.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),(0,f.jsx)(`span`,{className:c(`text-white/80`,e.state===`failed`?`text-(color:--rose)`:``),children:e.state===`uploading`?s(`onboard.uploading`):e.state===`done`?s(`onboard.uploaded`):s(`onboard.uploadFailed`)})]},e.name))}):null,(0,f.jsxs)(`div`,{className:`flex flex-wrap items-center gap-5`,children:[(0,f.jsx)(_,{busy:N.some(e=>e.state===`uploading`),onClick:()=>H(`space`),children:s(`onboard.continue`)}),N.length?null:(0,f.jsx)(v,{onClick:()=>H(`space`),children:s(`onboard.skip`)}),(0,f.jsx)(y,{step:3})]})]}):null,V===4?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(`p`,{className:`font-medium text-[0.75rem] text-white/85 uppercase tracking-[0.14em]`,children:s(`onboard.kicker4`)}),(0,f.jsx)(`h1`,{className:`font-display font-bold text-[2.5rem] leading-[1.05] tracking-[-0.02em] sm:text-[3.25rem]`,children:s(`onboard.space`)}),(0,f.jsx)(`p`,{className:`text-[1.0625rem] text-white/90 leading-relaxed`,children:s(`onboard.spaceSub`,{space:r?.name??``})}),(0,f.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[[`partInfo`,`partInfoText`,!!(M||A)],[`partKnow`,`partKnowText`,N.some(e=>e.state===`done`)],[`partData`,`partDataText`,!1],[`partResults`,`partResultsText`,!1]].map(([e,t,n])=>(0,f.jsxs)(`div`,{className:`flex flex-col gap-1.5 rounded-2xl border border-white/20 bg-white/10 px-4.5 py-4`,children:[(0,f.jsxs)(`span`,{className:`flex items-center gap-2 font-semibold text-[1rem]`,children:[n?(0,f.jsx)(ee,{className:`size-4 text-(color:--moss)`}):null,s(`onboard.${e}`)]}),(0,f.jsx)(`span`,{className:`text-[0.84375rem] text-white/85 leading-snug`,children:s(`onboard.${t}`)})]},e))}),(0,f.jsxs)(`div`,{className:`flex flex-wrap items-center gap-5`,children:[(0,f.jsx)(_,{busy:X.isPending,onClick:()=>X.mutate(),children:s(`onboard.build`)}),(0,f.jsx)(y,{step:4})]})]}):null]},B)]}),(0,f.jsxs)(`footer`,{className:`mx-auto flex w-full max-w-6xl items-center justify-between pb-6 text-[0.75rem] text-white/55 sm:pb-8`,children:[(0,f.jsx)(`span`,{children:`engenty.wizards`}),(0,f.jsx)(`span`,{"aria-hidden":`true`,className:`size-[3px] bg-(color:--dot)`})]})]})}export{k as OnboardingPage};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{A as r,Bn as i,Br as a,C as o,D as s,E as c,F as l,Ft as u,Gn as d,Gt as f,Ht as p,I as m,Ir as h,It as g,Jn as _,Kt as v,L as y,Lr as b,Lt as x,M as S,Mt as C,N as w,Nr as T,Nt as E,O as D,P as O,Pt as k,Qn as A,R as j,Rr as M,Rt as N,S as ee,Sr as P,T as te,Tr as ne,Ut as re,Vt as F,Wt as ie,Xn as I,Yt as L,_ as ae,_r as R,b as z,cr as B,d as V,di as H,dr as oe,en as U,er as W,f as G,fr as K,g as se,h as ce,hr as le,ir as ue,j as de,jt as q,k as J,kr as Y,lr as fe,m as pe,ot as me,p as he,pr as ge,qt as X,tr as _e,u as ve,v as Z,w as ye,x as be,y as xe,zr as Se}from"./ui-Cdv3QUOd.js";import{S as Ce,_ as we,a as Te,c as Ee,d as De,f as Oe,g as ke,h as Ae,i as je,l as Me,m as Ne,n as Pe,o as Fe,p as Ie,s as Le,u as Re,v as ze,x as Be,y as Ve}from"./RunDrawer-B6AQw90D.js";import{t as He}from"./phone-DwAf8S3l.js";import{n as Ue,r as We,t as Ge}from"./ReadOnly-Db_odT6Y.js";import{t as Ke}from"./upload-DCMZI6pp.js";import{Bt as qe,Ct as Je,Ht as Ye,It as Xe,Kt as Ze,St as Qe,Wt as $e,Yt as et,b as tt,c as nt,d as rt,dn as it,f as at,h as ot,in as st,m as ct,mt as lt,nn as ut,nt as dt,p as ft,s as pt,sn as mt,tn as ht,u as gt,ut as _t,v as vt,wt as yt,y as bt,yn as xt}from"./index-CQKA-z2z.js";import{a as St,c as Ct,f as wt,i as Tt,n as Et,o as Dt,r as Ot,s as kt,t as At,u as jt}from"./settings-menu-B1ND1GF3.js";import{t as Mt}from"./RunnerView-DHUkvi_G.js";var Nt={name:`blend`,size:24,node:[[`circle`,{cx:`15`,cy:`9`,r:`7`,key:`1i12rt`}],[`circle`,{cx:`9`,cy:`15`,r:`7`,key:`19bs8k`}]]};Nt.node;var Pt=Y(Nt),Ft={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`}]]};Ft.node;var It=Y(Ft),Lt={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`}]]};Lt.node;var Rt=Y(Lt),zt={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`}]]};zt.node;var Bt=Y(zt),Vt={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`]};Vt.node;var Ht=Y(Vt),Ut={name:`layout-grid`,size:24,node:[[`rect`,{width:`7`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`1g98yp`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`3`,rx:`1`,key:`6d4xhi`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`14`,rx:`1`,key:`nxv5o0`}],[`rect`,{width:`7`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`1bb6yr`}]]};Ut.node;var Wt=Y(Ut),Gt={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`}]]};Gt.node;var Kt=Y(Gt),qt={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`}]]};qt.node;var Jt=Y(qt),Yt={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`}]]};Yt.node;var Xt=Y(Yt),Q=e(t(),1),$=e(n(),1),Zt={backgroundImage:`repeating-conic-gradient(#c9c9c9 0% 25%, #dedede 0% 50%)`,backgroundSize:`16px 16px`};function Qt({file:e,actions:t}){let[n,r]=(0,Q.useState)(e.description),i=(0,Q.useRef)(e.description),a=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{e.description!==i.current&&(r(t=>t===i.current?e.description:t),i.current=e.description)},[e.description]),(0,Q.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,$.jsx)(`p`,{className:`text-[0.8125rem] text-ink-2 leading-snug`,children:n}):null:(0,$.jsx)(`textarea`,{ref:a,rows:1,value:n,maxLength:600,placeholder:U(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 $t(e,t){confirm(U(`project.removeConfirm`,{name:e.name}))&&t.remove(e.id)}function en({projectId:e,file:t,small:n}){let r=w(e,t.id);if(t.mime.startsWith(`image/`))return(0,$.jsx)(`img`,{src:r,alt:``,loading:`lazy`,className:X(`size-full`,t.kind===`logo`?`object-contain p-3`:`object-cover`)});if(t.mime.startsWith(`video/`))return(0,$.jsx)(`video`,{src:`${r}#t=0.1`,preload:`metadata`,controls:!n,className:`size-full object-cover`});if(t.mime.startsWith(`font/`))return(0,$.jsx)(tn,{src:r,small:n});let i=n?`size-5`:`size-7`;return(0,$.jsxs)(`div`,{className:`flex size-full flex-col items-center justify-center gap-1.5 text-ink-3`,children:[t.mime.startsWith(`audio/`)?(0,$.jsx)(Xt,{className:i}):t.mime===`application/pdf`?(0,$.jsx)(K,{className:i}):t.mime===`application/json`?(0,$.jsx)(_,{className:i}):t.mime.startsWith(`model/`)?(0,$.jsx)(It,{className:i}):(0,$.jsx)(oe,{className:i}),n?null:(0,$.jsx)(`span`,{className:`text-[0.6875rem] uppercase tracking-wide`,children:t.mime===`application/json`?`Lottie / JSON`:t.mime.split(`/`).pop()})]})}function tn({src:e,small:t}){let[n,r]=(0,Q.useState)(null);return(0,Q.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,$.jsx)(`div`,{className:X(`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 nn=`application/x-wizards-logo`;function rn({projectId:e,kind:t,files:n,actions:r,accept:i,addLabel:a,onUpload:o,onPreview:s,mainId:c,onMakeMain:l,moveTo:u,onRemove:f}){let m=e=>f?f(e):$t(e,r);return(0,$.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(184px,1fr))] gap-3`,children:[n.map(n=>(0,$.jsxs)(`div`,{draggable:u&&!r.readOnly?!0:void 0,onDragStart:e=>e.dataTransfer.setData(nn,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,$.jsx)(`span`,{className:`absolute -top-3 left-3 z-10 rounded-full ring-2 ring-card`,children:(0,$.jsx)(E,{tone:`ember`,children:U(`project.logoMain`)})}):null,(0,$.jsxs)(`div`,{className:`relative h-28 overflow-hidden rounded-md bg-paper-2`,style:t===`logo`?Zt:void 0,children:[s&&n.mime.startsWith(`image/`)?(0,$.jsx)(`button`,{type:`button`,"aria-label":`${U(`project.preview`)}: ${n.name}`,onClick:()=>s(n),className:`block size-full cursor-zoom-in`,children:(0,$.jsx)(en,{projectId:e,file:n})}):(0,$.jsx)(en,{projectId:e,file:n}),(0,$.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,$.jsx)(g,{label:U(`project.preview`),onClick:()=>s(n),className:`size-8 bg-card shadow-soft`,children:(0,$.jsx)(it,{className:`size-4`})}):null,l&&n.id!==c&&!r.readOnly?(0,$.jsx)(g,{label:U(`project.logoMakeMain`),onClick:()=>l(n),className:`size-8 bg-card shadow-soft`,children:(0,$.jsx)(Ye,{className:`size-4`})}):null,u&&!r.readOnly?(0,$.jsx)(ce,{options:u.options,value:u.current(n),onChange:e=>u.onMove(n,e),className:`bg-card shadow-soft`}):null,r.readOnly?null:(0,$.jsx)(g,{label:U(`project.remove`),onClick:()=>m(n),className:`size-8 bg-card shadow-soft hover:text-rose`,children:(0,$.jsx)(d,{className:`size-4`})})]})]}),t===`asset`?(0,$.jsx)(`div`,{className:`truncate px-0.5 text-[0.75rem] text-ink-3`,title:n.name,children:n.name}):null,(0,$.jsx)(Qt,{file:n,actions:r})]},n.id)),a&&!r.readOnly?(0,$.jsxs)(he,{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,$.jsx)(p,{className:`size-5`}):(0,$.jsx)(W,{className:`size-5`}),a]}):null]})}function an({kind:e,fetchUrl:t,onAdded:n,onClose:r}){let[i,a]=(0,Q.useState)(``),[o,s]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)(null),[u,d]=(0,Q.useState)(null),[f,p]=(0,Q.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(U(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,$.jsx)(k,{open:!0,onClose:r,wide:u?!0:void 0,title:U(u?e===`logo`?`project.logoFound`:`project.assetFound`:e===`logo`?`project.logoFromUrl`:`project.assetFromUrl`),children:u?(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-ink-3`,children:U(e===`logo`?`project.logoFoundHint`:`project.assetFoundHint`)}),(0,$.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,$.jsxs)(`button`,{type:`button`,"aria-pressed":n,title:t.hint,onClick:()=>p(e=>n?e.filter(e=>e!==t.url):[...e,t.url]),className:X(`relative h-28 overflow-hidden rounded-lg ring-1 transition`,n?`ring-2 ring-ember`:`ring-border-soft hover:ring-ink-4`),style:Zt,children:[(0,$.jsx)(`img`,{src:t.url,alt:``,className:X(`size-full`,e===`logo`?`object-contain p-3`:`object-cover`)}),n?(0,$.jsx)(`span`,{className:`absolute top-1.5 right-1.5 grid size-5 place-items-center rounded-full bg-ember text-white`,children:(0,$.jsx)(P,{className:`size-3.5`})}):null]},t.url)})}),c?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:c}):null,(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(q,{variant:`ghost`,onClick:()=>d(null),children:U(`run.back`)}),(0,$.jsx)(q,{busy:o,disabled:!f.length,onClick:()=>void h(),children:f.length>1?U(`project.addMany`,{n:f.length}):U(`project.add`)})]})]}):(0,$.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),m()},className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(N,{children:U(`project.logoUrl`)}),(0,$.jsx)(x,{autoFocus:!0,value:i,inputMode:`url`,placeholder:`https://example.com`,onChange:e=>a(e.target.value)}),(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:U(e===`logo`?`project.logoUrlHint`:`project.assetUrlHint`)})]}),c?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:c}):null,(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(q,{variant:`ghost`,onClick:r,children:U(`common.cancel`)}),(0,$.jsx)(q,{type:`submit`,busy:o,disabled:!i.trim(),children:U(`run.next`)})]})]})})}function on(e,t,n){return a({queryKey:[`project-file-text`,t.id,t.chars,n],queryFn:()=>j.get(`/api/studio/projects/${e}/files/${t.id}/text?limit=${n}`),enabled:t.status===`ready`,staleTime:6e4})}function sn(e){return((e.name.includes(`.`)?e.name.split(`.`).pop():``)||e.mime.split(`/`).pop()||``).toUpperCase().slice(0,5)}var cn=e=>[sn(e),e.pages?U(`project.pages`,{n:e.pages}):null,i(e.size)].filter(Boolean).join(` · `),ln=2e5;function un({projectId:e,fileId:t,readOnly:n,onGone:r}){let i=H(),a=y(e),o=Ne(e),s=l(e,n),c=a.data?.files.find(e=>e.id===t),u=c?c.mime===`application/pdf`||c.mime.startsWith(`image/`):!1,[f,m]=(0,Q.useState)(null);if(!c)return a.isLoading?(0,$.jsx)(p,{className:`mx-auto text-ink-3`}):null;let h=f??(u?`original`:`text`),_=o.data?.items.find(e=>e.key===`f:${c.id}`),v=w(e,c.id),b=(e,t)=>(0,$.jsx)(`button`,{type:`button`,"aria-pressed":h===e,onClick:()=>m(e),className:X(`rounded-full px-3 py-1 text-[0.8125rem] transition`,h===e?`bg-paper-2 font-medium text-ink`:`text-ink-3 hover:text-ink`),children:t});return(0,$.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-1`,children:[(0,$.jsx)(`h2`,{className:`min-w-0 flex-1 truncate font-display font-semibold text-lg`,children:c.name}),(0,$.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3 max-sm:hidden`,children:cn(c)}),(0,$.jsx)(`a`,{href:v,target:`_blank`,rel:`noreferrer`,"aria-label":U(`project.openOriginal`),title:U(`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,$.jsx)(ge,{className:`size-4`})}),n?null:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(g,{label:U(`project.reindex`),onClick:async()=>{await s.reindex(c.id),await i.invalidateQueries({queryKey:[`knowledge`,e]})},children:(0,$.jsx)(A,{className:`size-4`})}),(0,$.jsx)(g,{label:U(`know.deleteFile`),className:`hover:text-rose`,onClick:async()=>{confirm(U(`data.confirmDelete`,{title:c.name}))&&(await s.remove(c.id),await i.invalidateQueries({queryKey:[`knowledge`,e]}),r())},children:(0,$.jsx)(d,{className:`size-4`})})]})]}),(0,$.jsx)(Oe,{projectId:e,itemKey:`f:${c.id}`,has:_?.categories??[],originLabel:_?.originLabel??null,kept:!1,review:null,file:null,readOnly:n,onReviewed:()=>void 0}),(0,$.jsx)(`div`,{className:`px-1`,children:(0,$.jsx)(Qt,{file:c,actions:s})}),c.status===`failed`?(0,$.jsx)(`p`,{className:`px-1 text-[0.875rem] text-rose`,children:c.error}):null,(0,$.jsxs)(C,{className:`flex flex-col`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1 border-border-soft border-b px-2 py-1.5`,children:[u?b(`original`,U(`project.original`)):null,b(`text`,U(`project.readText`))]}),h===`original`?c.mime===`application/pdf`?(0,$.jsx)(`iframe`,{src:v,title:c.name,className:`h-[70dvh] w-full rounded-b-xl bg-paper-2`}):(0,$.jsx)(`img`,{src:v,alt:``,className:`mx-auto max-h-[70dvh] object-contain p-4`}):(0,$.jsx)(dn,{projectId:e,file:c})]})]})}function dn({projectId:e,file:t}){let n=on(e,t,ln);return n.isLoading||t.status===`pending`?(0,$.jsx)(`div`,{className:`flex h-40 items-center justify-center text-ink-3`,children:(0,$.jsx)(p,{})}):n.data?.text?(0,$.jsxs)(`div`,{className:`overflow-x-auto p-4 sm:p-5`,children:[(0,$.jsx)(me,{text:n.data.text,className:`text-[0.875rem]`}),n.data.chars>n.data.text.length?(0,$.jsx)(`p`,{className:`mt-3 text-[0.8125rem] text-ink-3`,children:U(`project.textCut`,{shown:n.data.text.length.toLocaleString(L),total:n.data.chars.toLocaleString(L)})}):null]}):(0,$.jsx)(`p`,{className:`py-8 text-center text-[0.875rem] text-ink-3`,children:U(`project.noText`)})}var fn=`image/*,video/*,audio/*,application/pdf,.pdf,.woff2,.woff,.ttf,.otf,.json,.glb,.gltf`,pn=e=>[(e.name.includes(`.`)?e.name.split(`.`).pop():e.mime.split(`/`).pop())?.toUpperCase().slice(0,5),i(e.size)].filter(Boolean).join(` · `);function mn({projectId:e,file:t,actions:n,onClose:r}){let i=w(e,t.id);return(0,$.jsxs)(k,{open:!0,onClose:r,wide:`page`,title:t.name,children:[(0,$.jsxs)(`div`,{className:`-mt-2 mb-4 flex items-center justify-between gap-3`,children:[(0,$.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3`,children:pn(t)}),(0,$.jsx)(`a`,{href:i,target:`_blank`,rel:`noreferrer`,"aria-label":U(`project.openOriginal`),title:U(`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,$.jsx)(ge,{className:`size-4`})})]}),t.mime.startsWith(`image/`)?(0,$.jsx)(`div`,{className:`overflow-hidden rounded-lg`,style:Zt,children:(0,$.jsx)(`img`,{src:i,alt:``,className:`mx-auto max-h-[68dvh] object-contain`})}):t.mime.startsWith(`video/`)?(0,$.jsx)(`video`,{src:i,controls:!0,className:`max-h-[68dvh] w-full rounded-lg bg-black`}):(0,$.jsx)(`audio`,{src:i,controls:!0,className:`w-full`}),(0,$.jsx)(`div`,{className:`mt-4`,children:(0,$.jsx)(Qt,{file:t,actions:n})})]})}function hn({projectId:e,file:t,actions:n,moveTo:r,onPreview:i,onRemove:a}){return(0,$.jsxs)(`li`,{className:`group/row flex items-start gap-3 rounded-lg bg-paper p-2 ring-1 ring-border-soft`,children:[(0,$.jsx)(`button`,{type:`button`,"aria-label":`${U(`project.preview`)}: ${t.name}`,onClick:i,className:`size-14 shrink-0 cursor-zoom-in overflow-hidden rounded-md bg-paper-2`,children:(0,$.jsx)(en,{projectId:e,file:t,small:!0})}),(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1 py-0.5`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-3`,children:[(0,$.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,$.jsx)(`span`,{className:`text-[0.75rem] text-ink-3`,children:pn(t)})]}),(0,$.jsx)(Qt,{file:t,actions:n})]}),(0,$.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,$.jsx)(g,{label:U(`project.preview`),onClick:i,children:(0,$.jsx)(it,{className:`size-4`})}),r&&!n.readOnly?(0,$.jsx)(ce,{options:r.options,value:r.current(t),onChange:e=>r.onMove(t,e),className:`size-9`}):null,n.readOnly?null:(0,$.jsx)(g,{label:U(`project.remove`),onClick:a,className:`hover:text-rose`,children:(0,$.jsx)(d,{className:`size-4`})})]})]})}function gn({section:e,onSave:t,onRemove:n,onClose:r}){let[i,a]=(0,Q.useState)(e?.title??``);return(0,$.jsx)(k,{open:!0,onClose:r,title:U(e?`project.assetSectionRename`:`project.assetSectionAdd`),children:(0,$.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),i.trim()&&(t(i.trim()),r())},className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(N,{children:U(`project.assetSectionName`)}),(0,$.jsx)(x,{autoFocus:!0,value:i,maxLength:80,placeholder:U(`project.assetSectionTitle`),onChange:e=>a(e.target.value)})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n?(0,$.jsx)(q,{variant:`danger`,onClick:n,children:U(`project.sectionRemove`)}):null,(0,$.jsx)(`span`,{className:`flex-1`}),(0,$.jsx)(q,{variant:`ghost`,onClick:r,children:U(`common.cancel`)}),(0,$.jsx)(q,{type:`submit`,disabled:!i.trim(),children:U(e?`settings.save`:`project.add`)})]})]})})}function _n({projectId:e,data:t,readOnly:n,sections:r,save:i}){let a=l(e,n),[o,c]=m(`assets`,`cards`),[u,d]=(0,Q.useState)(``),[h,_]=(0,Q.useState)(null),[v,y]=(0,Q.useState)(r),[b,x]=(0,Q.useState)(``),[S,C]=(0,Q.useState)(null),[w,T]=(0,Q.useState)(!1),E=(0,Q.useRef)(null),D=O({assetSections:v},i),k=t.files.filter(e=>e.kind===`asset`),A=new Map(k.map(e=>[e.id,e])),j=new Set(v.flatMap(e=>e.assets)),M=v.find(e=>e.id===b)??null,N=M?M.assets.map(e=>A.get(e)).filter(e=>!!e):k.filter(e=>!j.has(e.id)),ee=k.find(e=>e.id===h),P=u.trim().toLowerCase(),te=P?N.filter(e=>`${e.name} ${e.description}`.toLowerCase().includes(P)):N,ne=(e,t)=>y(n=>n.map(n=>{let r=n.assets.filter(t=>t!==e);return{...n,assets:n.id===t?[...r,e]:r}})),re=async e=>{let t=M?.id??null;for(let n of await a.upload(`asset`,e))ne(n.id,t)},F=e=>{confirm(U(`project.removeConfirm`,{name:e.name}))&&(a.remove(e.id),ne(e.id,null))},ie=v.length?{options:[{value:``,label:U(`project.assetsGeneral`)},...v.map(e=>({value:e.id,label:e.title||U(`project.sectionUntitled`)}))],current:e=>v.find(t=>t.assets.includes(e.id))?.id??``,onMove:(e,t)=>ne(e.id,t||null)}:void 0,I=[{label:U(`project.assetUpload`),icon:(0,$.jsx)(Ke,{className:`size-4 shrink-0`}),onPick:()=>E.current?.click()},{label:U(`project.assetFromUrl`),icon:(0,$.jsx)(Kt,{className:`size-4 shrink-0`}),onPick:()=>T(!0)},...v.length<s.logoSections?[{label:U(`project.assetSectionAdd`),icon:(0,$.jsx)(Bt,{className:`size-4 shrink-0`}),onPick:()=>C(`new`)}]:[]],L=v.length||k.length?(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsxs)(`div`,{className:`-mx-1 flex min-w-0 flex-1 items-center gap-1 overflow-x-auto px-1 pb-0.5`,children:[v.length?(0,$.jsx)(f,{value:b,onChange:e=>{x(e),d(``)},label:U(`project.assets`),options:[{id:``,label:U(`project.assetsGeneral`)},...v.map(e=>({id:e.id,label:e.title||U(`project.sectionUntitled`)}))]}):null,M&&!n?(0,$.jsx)(g,{label:U(`project.assetSectionRename`),onClick:()=>C(`current`),children:(0,$.jsx)(_e,{className:`size-4`})}):null]}),N.length?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`w-56 max-w-[45%] shrink`,children:(0,$.jsx)(ae,{value:u,onChange:d,placeholder:U(`project.assetSearch`)})}),(0,$.jsx)(g,{label:U(o===`list`?`project.viewCards`:`project.viewList`),onClick:c,children:o===`list`?(0,$.jsx)(Wt,{className:`size-4`}):(0,$.jsx)(Jt,{className:`size-4`})})]}):null]}):null;return(0,$.jsxs)(Z,{title:U(`project.assets`),hint:U(`project.assetsHint`),save:D,tabs:L,action:n?null:(0,$.jsx)(ve,{entries:I}),children:[(0,$.jsx)(`input`,{ref:E,type:`file`,multiple:!0,accept:fn,className:`sr-only`,tabIndex:-1,"aria-hidden":!0,onChange:e=>{let t=Array.from(e.target.files??[]);e.target.value=``,t.length&&re(t)}}),te.length?o===`cards`?(0,$.jsx)(rn,{projectId:e,kind:`asset`,files:te,actions:a,moveTo:ie,onRemove:F,onPreview:e=>_(e.id)}):(0,$.jsx)(`ul`,{className:`flex flex-col gap-2`,children:te.map(t=>(0,$.jsx)(hn,{projectId:e,file:t,actions:a,moveTo:ie,onPreview:()=>_(t.id),onRemove:()=>F(t)},t.id))}):N.length?null:n?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:U(`project.staysLocal`)}):(0,$.jsxs)(he,{accept:fn,onFiles:e=>void re(e),className:`h-16 w-full`,children:[a.busy?(0,$.jsx)(p,{className:`size-4`}):(0,$.jsx)(Ke,{className:`size-4`}),U(`project.drop`),` `,(0,$.jsx)(`span`,{className:`underline`,children:U(`project.assetAdd`)})]}),a.error?(0,$.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:a.error}):null,ee?(0,$.jsx)(mn,{projectId:e,file:ee,actions:a,onClose:()=>_(null)}):null,S?(0,$.jsx)(gn,{section:S===`current`?M:null,onClose:()=>C(null),onSave:e=>{if(S===`current`&&M)y(t=>t.map(t=>t.id===M.id?{...t,title:e}:t));else{let t=z();y(n=>[...n,{id:t,title:e,assets:[]}]),x(t)}},onRemove:S===`current`&&M?()=>{(!M.assets.length||confirm(U(`project.assetSectionRemoveConfirm`,{name:M.title})))&&(y(e=>e.filter(e=>e.id!==M.id)),x(``),C(null))}:void 0}):null,w?(0,$.jsx)(an,{kind:`asset`,onClose:()=>T(!1),fetchUrl:e=>a.fromUrl(`asset`,e),onAdded:e=>{for(let t of e)ne(t.id,M?.id??null)}}):null]})}var vn=/^#[0-9a-fA-F]{6}$/;async function yn(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 bn={linear:`project.gradientLinear`,radial:`project.gradientRadial`,conic:`project.gradientConic`};function xn({projectId:e,gradient:t,isNew:n,brand:i,onSave:a,onClose:o}){let[s,l]=(0,Q.useState)(t),[u,f]=(0,Q.useState)(r(t)),[p,m]=(0,Q.useState)(!1),[h,v]=(0,Q.useState)(``),[y,b]=(0,Q.useState)(!1),[C,w]=(0,Q.useState)(null),[T,E]=(0,Q.useState)(!n),D=e=>{l(e),f(r(e)),m(!1)},O=(e,t)=>D({...s,stops:s.stops.map((n,r)=>r===e?{...n,...t}:n)}),A=e=>{let t=[...s.stops].sort((e,t)=>e.at-t.at),n=50,r=-1;for(let e=0;e<t.length-1;e++)t[e+1].at-t[e].at>r&&(r=t[e+1].at-t[e].at,n=Math.round((t[e].at+t[e+1].at)/2));D({...s,stops:[...s.stops,{color:e??t[0]?.color??`#888888`,at:n}]})},M=async()=>{b(!0),w(null);try{let{gradient:t}=await j.post(`/api/studio/projects/${e}/gradients/describe`,{text:h.trim(),...T?{gradient:{name:s.name,type:s.type,angle:s.angle,stops:s.stops}}:{}});D({...s,...t,name:s.name.trim()?s.name:t.name}),v(``),E(!0)}catch(e){w(e.message)}b(!1)};return(0,$.jsx)(k,{open:!0,onClose:o,wide:!0,title:U(n?`project.gradientNew`:`project.gradientEdit`),children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),h.trim()&&!y&&M()},children:[(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(x,{"data-autofocus":n||void 0,value:h,maxLength:1e3,"aria-label":U(`project.gradientDescribe`),placeholder:U(T?`project.gradientDescribeChange`:`project.gradientDescribeNew`),onChange:e=>v(e.target.value),className:`min-w-0 flex-1`}),(0,$.jsxs)(q,{type:`submit`,variant:`secondary`,busy:y,disabled:!h.trim(),children:[(0,$.jsx)(_,{className:`size-4`}),U(T?`project.gradientDescribeApply`:`project.gradientDescribeMake`)]})]}),(0,$.jsx)(`p`,{className:X(`mt-1.5 text-[0.8125rem]`,C?`text-rose`:`text-ink-3`),children:C??U(`project.gradientDescribeHint`)})]}),(0,$.jsx)(`div`,{className:`h-40 rounded-lg ring-1 ring-border-soft`,style:{background:r(s)}}),(0,$.jsxs)(`div`,{className:`grid gap-x-6 gap-y-4 sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(N,{children:U(`project.gradientName`)}),(0,$.jsx)(x,{value:s.name,maxLength:80,placeholder:U(`project.gradientNamePlaceholder`),onChange:e=>l({...s,name:e.target.value})})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(N,{children:U(`project.fillUseLabel`)}),(0,$.jsx)(x,{value:s.description??``,maxLength:400,placeholder:U(`project.gradientUse`),onChange:e=>l({...s,description:e.target.value})})]})]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-end gap-x-6 gap-y-4`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(N,{children:U(`project.gradientType`)}),(0,$.jsx)(`div`,{className:`flex gap-1 rounded-full bg-paper-2 p-0.5 ring-1 ring-border-soft`,children:c.map(e=>(0,$.jsx)(`button`,{type:`button`,"aria-pressed":s.type===e,onClick:()=>D({...s,type:e}),className:X(`h-9 rounded-full px-4 font-medium text-[0.875rem] transition`,s.type===e?`bg-card text-ink shadow-sm`:`text-ink-3 hover:text-ink-2`),children:U(bn[e])},e))})]}),s.type===`radial`?null:(0,$.jsxs)(`div`,{className:`min-w-56`,children:[(0,$.jsx)(N,{children:U(`project.gradientAngle`)}),(0,$.jsxs)(`div`,{className:`flex h-11 items-center gap-3`,children:[(0,$.jsx)(`input`,{type:`range`,min:0,max:360,value:s.angle,"aria-label":U(`project.gradientAngle`),onChange:e=>D({...s,angle:Number(e.target.value)}),className:`flex-1 accent-ink`}),(0,$.jsxs)(`span`,{className:`w-12 text-right text-[0.875rem] text-ink-2 tabular-nums`,children:[Math.round(s.angle),`°`]})]})]})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(N,{children:U(`project.gradientStops`)}),(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:s.stops.map((e,t)=>(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(re,{value:vn.test(e.color)?e.color:`#888888`,onChange:e=>O(t,{color:e.target.value})}),(0,$.jsx)(x,{value:e.color,spellCheck:!1,onChange:e=>{let n=e.target.value.trim();vn.test(n)&&O(t,{color:n.toLowerCase()})},className:`w-28 font-mono text-[0.8125rem]`}),(0,$.jsx)(`input`,{type:`range`,min:0,max:100,value:e.at,"aria-label":U(`project.gradientAt`),onChange:e=>O(t,{at:Number(e.target.value)}),className:`flex-1 accent-ink`}),(0,$.jsxs)(`span`,{className:`w-10 text-right text-[0.875rem] text-ink-2 tabular-nums`,children:[Math.round(e.at),`%`]}),(0,$.jsx)(g,{label:U(`project.remove`),disabled:s.stops.length<=2,onClick:()=>D({...s,stops:s.stops.filter((e,n)=>n!==t)}),className:`hover:text-rose`,children:(0,$.jsx)(d,{className:`size-4`})})]},t))}),(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[s.stops.length<12?(0,$.jsxs)(q,{variant:`secondary`,size:`sm`,onClick:()=>A(),children:[(0,$.jsx)(W,{className:`size-4`}),` `,U(`project.gradientStopAdd`)]}):null,i.length&&s.stops.length<12?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`ml-2 text-[0.8125rem] text-ink-3`,children:U(`project.gradientFromBrand`)}),i.slice(0,10).map(e=>(0,$.jsx)(`button`,{type:`button`,title:e.name||e.value,"aria-label":e.name||e.value,onClick:()=>A(e.value),className:`size-6 rounded-full ring-1 ring-border transition hover:scale-110`,style:{background:e.value}},e.value))]}):null]})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(N,{children:`CSS`}),(0,$.jsx)(x,{value:u,spellCheck:!1,onChange:e=>{f(e.target.value);let t=S(e.target.value);m(!t),t&&l({...s,...t})},className:`font-mono text-[0.8125rem]`}),(0,$.jsx)(`p`,{className:X(`mt-1.5 text-[0.8125rem]`,p?`text-rose`:`text-ink-3`),children:U(p?`project.gradientCssError`:`project.gradientCssHint`)})]}),(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(q,{variant:`ghost`,onClick:o,children:U(`common.cancel`)}),(0,$.jsx)(q,{onClick:()=>{a(s),o()},children:U(`settings.save`)})]})]})})}var Sn=`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`,Cn=`size-8 bg-card shadow-soft hover:bg-card`;function wn({name:e,namePlaceholder:t,description:n,usePlaceholder:r,readOnly:i,onChange:a}){return i?(0,$.jsxs)(`div`,{className:`min-w-0 px-0.5`,children:[(0,$.jsx)(`p`,{className:`truncate text-[0.875rem]`,children:e||t}),n?(0,$.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3 leading-snug`,children:n}):null]}):(0,$.jsxs)(`div`,{className:`min-w-0 px-0.5`,children:[(0,$.jsx)(pe,{value:e,label:U(`project.gradientName`),placeholder:t,maxLength:80,onChange:e=>a({name:e}),className:`font-medium text-[0.875rem]`}),(0,$.jsx)(pe,{value:n??``,label:U(`project.fillUseLabel`),placeholder:r,maxLength:400,onChange:e=>a({description:e}),className:`text-[0.8125rem] text-ink-3`})]})}function Tn({gradient:e,readOnly:t,onEdit:n,onChange:i,onRemove:a}){let o=r(e),[s,c]=(0,Q.useState)(!1);return(0,$.jsxs)(`div`,{className:`group/card flex flex-col gap-2 rounded-lg bg-paper p-2 ring-1 ring-border-soft`,children:[(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(`button`,{type:`button`,disabled:t,"aria-label":U(`project.gradientEdit`),onClick:n,className:`block h-28 w-full rounded-md ring-1 ring-border-soft transition enabled:hover:brightness-105`,style:{background:o}}),(0,$.jsxs)(`div`,{className:Sn,children:[(0,$.jsx)(g,{label:U(s?`project.gradientCopied`:`project.gradientCopy`),onClick:()=>{navigator.clipboard.writeText(`background: ${o};`),c(!0),setTimeout(()=>c(!1),1500)},className:Cn,children:(0,$.jsx)(R,{className:`size-4`})}),(0,$.jsx)(g,{label:U(`project.download`),onClick:()=>void yn(e,e.name),className:Cn,children:(0,$.jsx)(le,{className:`size-4`})}),t?null:(0,$.jsx)(g,{label:U(`project.remove`),onClick:a,className:X(Cn,`hover:text-rose`),children:(0,$.jsx)(d,{className:`size-4`})})]})]}),(0,$.jsx)(wn,{name:e.name,namePlaceholder:U(`project.gradientName`),description:e.description,usePlaceholder:U(`project.gradientUse`),readOnly:t,onChange:i})]})}function En(e,t){return{backgroundImage:`url("${e}")`,backgroundSize:t?`64px`:`cover`,backgroundRepeat:t?`repeat`:`no-repeat`,backgroundPosition:`center`}}function Dn({projectId:e,pattern:t,fileName:n,readOnly:r,onEdit:i,onChange:a,onRemove:o}){let s=w(e,t.file);return(0,$.jsxs)(`div`,{className:`group/card flex flex-col gap-2 rounded-lg bg-paper p-2 ring-1 ring-border-soft`,children:[(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(`button`,{type:`button`,disabled:r,"aria-label":U(`project.patternEdit`),onClick:i,className:`block h-28 w-full rounded-md ring-1 ring-border-soft transition enabled:hover:brightness-105`,style:En(s,t.tile)}),(0,$.jsxs)(`div`,{className:Sn,children:[(0,$.jsx)(`a`,{href:s,download:n,"aria-label":U(`project.download`),title:U(`project.download`),className:X(`inline-flex items-center justify-center rounded-full text-ink-3 transition hover:text-ink`,Cn),children:(0,$.jsx)(le,{className:`size-4`})}),r?null:(0,$.jsx)(g,{label:U(`project.remove`),onClick:o,className:X(Cn,`hover:text-rose`),children:(0,$.jsx)(d,{className:`size-4`})})]})]}),(0,$.jsx)(wn,{name:t.name,namePlaceholder:n,description:t.description,usePlaceholder:U(`project.patternUse`),readOnly:r,onChange:a})]})}function On({projectId:e,pattern:t,isNew:n,fileName:r,busy:i,error:a,upload:o,removeFile:s,onSave:c,onClose:l}){let[u,d]=(0,Q.useState)(t),[f,m]=(0,Q.useState)([]),h=async e=>{let t=e[0];if(!t)return;let n=await o(t);n&&(m(e=>[...e,n.id]),d(e=>({...e,file:n.id,name:e.name||n.name.replace(/\.[^.]+$/,``)})))},g=()=>{for(let e of f)s(e);l()};return(0,$.jsx)(k,{open:!0,onClose:g,wide:!0,title:U(n?`project.patternNew`:`project.patternEdit`),children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[u.file?(0,$.jsx)(`div`,{className:`relative h-40 rounded-lg ring-1 ring-border-soft`,style:En(w(e,u.file),u.tile),children:(0,$.jsxs)(he,{accept:`image/*`,multiple:!1,onFiles:e=>void h(e),className:`absolute right-2 bottom-2 h-9 border-solid bg-card px-3.5 text-ink-2 shadow-soft`,children:[i?(0,$.jsx)(p,{className:`size-4`}):(0,$.jsx)(fe,{className:`size-4`}),U(`project.patternReplace`)]})}):(0,$.jsxs)(he,{accept:`image/*`,multiple:!1,onFiles:e=>void h(e),className:`h-40 flex-col`,children:[i?(0,$.jsx)(p,{className:`size-5`}):(0,$.jsx)(fe,{className:`size-5`}),U(`project.patternPick`)]}),(0,$.jsxs)(`div`,{className:`grid gap-x-6 gap-y-4 sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(N,{children:U(`project.patternName`)}),(0,$.jsx)(x,{value:u.name,maxLength:80,placeholder:u.file?r(u.file):U(`project.patternNamePlaceholder`),onChange:e=>d({...u,name:e.target.value})})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(N,{children:U(`project.fillUseLabel`)}),(0,$.jsx)(x,{value:u.description??``,maxLength:400,placeholder:U(`project.patternUse`),onChange:e=>d({...u,description:e.target.value})})]})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(N,{children:U(`project.patternShow`)}),(0,$.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,$.jsx)(`button`,{type:`button`,"aria-pressed":!!u.tile===e,onClick:()=>d({...u,tile:e||void 0}),className:X(`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:U(e?`project.patternTile`:`project.patternFill`)},String(e)))})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[a?(0,$.jsx)(`p`,{className:`mr-auto text-[0.8125rem] text-rose`,children:a}):null,(0,$.jsx)(q,{variant:`ghost`,onClick:g,children:U(`common.cancel`)}),(0,$.jsx)(q,{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:U(n?`project.add`:`settings.save`)})]})]})})}var kn=/^#[0-9a-fA-F]{6}$/;function An({projectId:e,onAdd:t,onClose:n}){let[r,i]=(0,Q.useState)(``),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(null),[l,u]=(0,Q.useState)(null),[d,f]=(0,Q.useState)([]),p=async()=>{o(!0),c(null);try{let{colors:t}=await j.post(`/api/studio/projects/${e}/colors/scan`,{url:r.trim()});t.length?(u(t),f([])):c(U(`project.colorsNoneFound`))}catch(e){c(e.message)}o(!1)};return(0,$.jsx)(k,{open:!0,onClose:n,wide:l?!0:void 0,title:U(l?`project.colorsFound`:`project.colorsFromUrl`),children:l?(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-ink-3`,children:U(`project.colorsFoundHint`)}),(0,$.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(120px,1fr))] gap-3`,children:l.map(e=>{let t=d.includes(e.value);return(0,$.jsxs)(`button`,{type:`button`,"aria-pressed":t,onClick:()=>f(n=>t?n.filter(t=>t!==e.value):[...n,e.value]),className:X(`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,$.jsx)(`span`,{className:`h-16`,style:{background:e.value}}),(0,$.jsxs)(`span`,{className:`flex flex-col px-2.5 py-2`,children:[(0,$.jsx)(`span`,{className:`truncate text-[0.8125rem] text-ink-2`,children:e.name||`—`}),(0,$.jsx)(`span`,{className:`font-mono text-[0.75rem] text-ink-3`,children:e.value})]}),t?(0,$.jsx)(`span`,{className:`absolute top-1.5 right-1.5 grid size-5 place-items-center rounded-full bg-ember text-white`,children:(0,$.jsx)(P,{className:`size-3.5`})}):null]},e.value)})}),(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(q,{variant:`ghost`,onClick:()=>u(null),children:U(`run.back`)}),(0,$.jsx)(q,{disabled:!d.length,onClick:()=>{t(l.filter(e=>d.includes(e.value))),n()},children:d.length>1?U(`project.addMany`,{n:d.length}):U(`project.add`)})]})]}):(0,$.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),p()},className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(N,{children:U(`project.logoUrl`)}),(0,$.jsx)(x,{autoFocus:!0,value:r,inputMode:`url`,placeholder:`https://example.com`,onChange:e=>i(e.target.value)}),(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:U(`project.colorsUrlHint`)})]}),s?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:s}):null,(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(q,{variant:`ghost`,onClick:n,children:U(`common.cancel`)}),(0,$.jsx)(q,{type:`submit`,busy:a,disabled:!r.trim(),children:U(`run.next`)})]})]})})}function jn({projectId:e,data:t,colors:n,sections:r,gradients:i,patterns:a,rules:o,sectioned:c,ruled:u,save:f,readOnly:p}){let[m,h]=(0,Q.useState)(()=>n.map(e=>({...e,id:z()}))),[_,v]=(0,Q.useState)(r),[y,b]=(0,Q.useState)(i),[S,C]=(0,Q.useState)(a),[w,T]=(0,Q.useState)(null),[D,k]=(0,Q.useState)(null),A=l(e,p),j=be(o),[M,N]=(0,Q.useState)(null),[ee,P]=(0,Q.useState)(null),[te,F]=(0,Q.useState)(!1),ie=O({colors:m.filter(e=>kn.test(e.value)).map(({name:e,value:t,section:n})=>({name:e.trim(),value:t,...n?{section:n}:{}})),colorSections:_,gradients:y,patterns:S,colorRules:j.rules},f),I=c?_:[],L=I.filter(e=>(e.kind??`colors`)===`colors`),ae=e=>L.some(t=>t.id===e.section),R=m.filter(e=>!ae(e)),B=(R[0]??m[0])?.id,H=(e,t)=>h(n=>n.map(n=>n.id===e?{...n,...t}:n)),oe=e=>h(t=>[...t,...e.map(e=>({...e,id:z()}))].slice(0,s.colors)),G=[{value:``,label:U(`project.sectionStandard`)},...L.map(e=>({value:e.id,label:e.title||U(`project.sectionUntitled`)}))],K=(e,t)=>{let n=z();N(n),v(r=>[...r,{id:n,title:t,...e===`colors`?{}:{kind:e}}])},le=e=>({id:z(),name:``,section:e,type:`linear`,angle:90,stops:[{color:m[0]?.value&&kn.test(m[0].value)?m[0].value:`#4b73ff`,at:0},{color:m[1]?.value&&kn.test(m[1].value)?m[1].value:`#ff6d1b`,at:100}]}),ue=e=>t.files.find(t=>t.id===e)?.name??`pattern`,de=[...m.length<s.colors?[{label:U(`project.colorNew`),icon:(0,$.jsx)(W,{className:`size-4 shrink-0`}),onPick:()=>J()},{label:U(`project.colorsFromUrl`),icon:(0,$.jsx)(Kt,{className:`size-4 shrink-0`}),onPick:()=>F(!0)}]:[],...c&&_.length<s.logoSections?[{label:U(`project.colorSectionAdd`),icon:(0,$.jsx)(Bt,{className:`size-4 shrink-0`}),onPick:()=>K(`colors`,``)},{label:U(`project.gradientSectionAdd`),icon:(0,$.jsx)(Pt,{className:`size-4 shrink-0`}),onPick:()=>K(`gradients`,U(`project.gradientSectionTitle`))},{label:U(`project.patternSectionAdd`),icon:(0,$.jsx)(Ht,{className:`size-4 shrink-0`}),onPick:()=>K(`patterns`,U(`project.patternSectionTitle`))}]:[],...!u||j.full?[]:[{label:U(`project.ruleNew`),icon:(0,$.jsx)(ut,{className:`size-4 shrink-0`}),onPick:()=>j.add()}]],q=e=>(0,$.jsxs)(`div`,{className:`group/row flex items-center gap-2`,children:[(0,$.jsx)(re,{value:kn.test(e.value)?e.value:`#888888`,onChange:t=>H(e.id,{value:t.target.value})}),(0,$.jsx)(x,{value:e.name,autoFocus:e.id===ee,placeholder:U(`project.colorName`),maxLength:120,onChange:t=>H(e.id,{name:t.target.value}),className:`min-w-0 flex-1`}),(0,$.jsx)(x,{value:e.value,placeholder:`#e0531b`,spellCheck:!1,onChange:t=>H(e.id,{value:t.target.value.trim()}),className:`w-28 font-mono text-[0.8125rem]`}),(0,$.jsxs)(`div`,{className:`flex w-28 shrink-0 items-center justify-end max-sm:w-auto`,children:[e.id===B?(0,$.jsx)(`span`,{className:`mr-1 max-sm:hidden`,children:(0,$.jsx)(E,{tone:`ember`,children:U(`project.colorAccent`)})}):p?null:(0,$.jsx)(g,{label:U(`project.colorFirst`),onClick:()=>h(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,$.jsx)(ne,{className:`size-4`})}),p||!L.length?null:(0,$.jsx)(ce,{options:G,value:ae(e)?e.section??``:``,onChange:t=>H(e.id,{section:t||void 0}),className:`opacity-0 focus-within:opacity-100 group-hover/row:opacity-100 coarse:opacity-100`}),p?null:(0,$.jsx)(g,{label:U(`project.remove`),onClick:()=>h(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,$.jsx)(d,{className:`size-4`})})]})]},e.id),J=e=>{let t=z();P(t),h(n=>[...n,{id:t,name:``,value:`#888888`,...e?{section:e}:{}}])};return(0,$.jsxs)(Z,{title:U(`project.colors`),hint:U(`project.colorsHint`),save:ie,locked:p,action:p?null:(0,$.jsx)(ve,{entries:de}),children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[R.length?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:R.map(q)}),p?null:(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:U(`project.colorUse`)})]}):m.length?null:(0,$.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:U(`project.colorsEmpty`)}),I.map(t=>{let n=t.kind??`colors`,r=m.filter(e=>e.section===t.id),i=y.filter(e=>e.section===t.id),a=S.filter(e=>e.section===t.id),o=n===`gradients`?i.length:n===`patterns`?a.length:r.length;return(0,$.jsxs)(`div`,{className:`group/section flex flex-col gap-3`,children:[(0,$.jsx)(xe,{title:t.title,titlePlaceholder:U(n===`gradients`?`project.gradientSectionTitlePlaceholder`:n===`patterns`?`project.patternSectionTitlePlaceholder`:`project.colorSectionTitle`),kind:n===`gradients`?{icon:(0,$.jsx)(Pt,{}),label:U(`project.kindGradients`)}:n===`patterns`?{icon:(0,$.jsx)(Ht,{}),label:U(`project.kindPatterns`)}:{icon:(0,$.jsx)(et,{}),label:U(`project.kindColors`)},autoFocus:M===t.id,readOnly:p,onChange:e=>v(n=>n.map(n=>n.id===t.id?{...n,...e}:n)),onRemove:()=>{if(!o||confirm(U(n===`colors`?`project.colorSectionRemoveConfirm`:`project.fillSectionRemoveConfirm`,{name:t.title||U(`project.sectionUntitled`)}))){v(e=>e.filter(e=>e.id!==t.id)),h(e=>e.map(e=>e.section===t.id?{...e,section:void 0}:e)),b(e=>e.filter(e=>e.section!==t.id));for(let e of a)A.remove(e.file);C(e=>e.filter(e=>e.section!==t.id))}}}),n===`gradients`?(0,$.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(200px,1fr))] gap-3`,children:[i.map(e=>(0,$.jsx)(Tn,{gradient:e,readOnly:p,onEdit:()=>T(e),onChange:t=>b(n=>n.map(n=>n.id===e.id?{...n,...t}:n)),onRemove:()=>b(t=>t.filter(t=>t.id!==e.id))},e.id)),p||y.length>=s.gradients?null:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>T(le(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,$.jsx)(W,{className:`size-5`}),U(`project.gradientAdd`)]})]}):n===`patterns`?(0,$.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(200px,1fr))] gap-3`,children:[a.map(t=>(0,$.jsx)(Dn,{projectId:e,pattern:t,fileName:ue(t.file),readOnly:p,onEdit:()=>k(t),onChange:e=>C(n=>n.map(n=>n.id===t.id?{...n,...e}:n)),onRemove:()=>{A.remove(t.file),C(e=>e.filter(e=>e.id!==t.id))}},t.id)),p||S.length>=s.files.pattern?null:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>k({id:z(),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,$.jsx)(W,{className:`size-5`}),U(`project.patternAdd`)]})]}):(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[r.map(q),p||m.length>=s.colors?null:(0,$.jsx)(V,{label:U(`project.colorAdd`),onClick:()=>J(t.id)})]})]},t.id)}),u?(0,$.jsx)(se,{rules:j,placeholder:U(`project.colorRulePlaceholder`),readOnly:p}):null]}),A.error?(0,$.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:A.error}):null,w?(0,$.jsx)(xn,{projectId:e,gradient:w,isNew:!y.some(e=>e.id===w.id),brand:m.filter(e=>kn.test(e.value)),onClose:()=>T(null),onSave:e=>b(t=>t.some(t=>t.id===e.id)?t.map(t=>t.id===e.id?e:t):[...t,e])}):null,D?(0,$.jsx)(On,{projectId:e,pattern:D,isNew:!S.some(e=>e.id===D.id),fileName:ue,busy:A.busy,error:A.error,upload:async e=>(await A.upload(`pattern`,[e]))[0]??null,removeFile:e=>void A.remove(e),onClose:()=>k(null),onSave:e=>C(t=>t.some(t=>t.id===e.id)?t.map(t=>t.id===e.id?e:t):[...t,e])}):null,te?(0,$.jsx)(An,{projectId:e,onClose:()=>F(!1),onAdd:oe}):null]})}var Mn=e=>/^(ja|yes|true)$/i.test(e.trim()),Nn={text:qe,longtext:We,number:Be,date:Ce,url:B,email:ht,phone:He,boolean:Ve};function Pn({type:e,detected:t,onChange:n}){let[r,i]=(0,Q.useState)(!1),[a,s]=(0,Q.useState)(!1),c=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{if(!r)return;let e=e=>{c.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 l=Nn[e??t],u=`${U(`project.factType`)}: ${U(`project.type.${e??t}`)}`,d=`flex w-full items-center gap-3 rounded-lg px-3 py-2 text-left text-[0.875rem] text-ink-2 hover:bg-accent hover:text-ink`,f=e=>{n(e),i(!1)};return(0,$.jsxs)(`div`,{className:`relative`,ref:c,children:[(0,$.jsx)(`button`,{type:`button`,"aria-label":u,title:u,"aria-haspopup":`menu`,"aria-expanded":r,onClick:e=>{s(window.innerHeight-e.currentTarget.getBoundingClientRect().bottom<400),i(e=>!e)},className:X(`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,$.jsx)(l,{className:`size-4`})}),r?(0,$.jsxs)(`div`,{role:`menu`,className:X(`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,$.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":!e,className:d,onClick:()=>f(void 0),children:[(0,$.jsx)(Xe,{className:`size-4 shrink-0`}),(0,$.jsx)(`span`,{className:`flex-1`,children:U(`project.factAuto`)}),(0,$.jsx)(`span`,{className:`text-[0.75rem] text-ink-4`,children:U(`project.type.${t}`)}),(0,$.jsx)(P,{className:X(`size-4 shrink-0`,e&&`invisible`)})]}),(0,$.jsx)(`div`,{className:`mx-2 my-1 h-px bg-border-soft`}),o.map(t=>{let n=Nn[t];return(0,$.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":e===t,className:d,onClick:()=>f(t),children:[(0,$.jsx)(n,{className:`size-4 shrink-0`}),(0,$.jsx)(`span`,{className:`flex-1`,children:U(`project.type.${t}`)}),(0,$.jsx)(P,{className:X(`size-4 shrink-0`,e!==t&&`invisible`)})]},t)})]}):null]})}function Fn({facts:e,save:t,readOnly:n}){let r=(0,Q.useRef)(0),i=(0,Q.useRef)(null),[a,o]=(0,Q.useState)(()=>e.map(e=>({...e,id:`f${r.current++}`}))),c=O(a.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),l=(e,t)=>o(n=>n.map(n=>n.id===e?{...n,...t}:n)),u=(e,t,n=!1)=>{let a=`f${r.current++}`;i.current=`${a}:${t}`;let s={id:a,key:``,label:``,value:``,...e};o(e=>n?[s,...e]:[...e,s])},f=e=>t=>{t&&i.current===e&&(i.current=null,t.focus())},p=ee.filter(e=>!a.some(t=>t.key===e));return(0,$.jsxs)(Z,{title:U(`project.facts`),hint:U(`project.factsHint`),save:c,locked:n,action:a.length<s.facts&&!n?(0,$.jsxs)(q,{variant:`secondary`,size:`sm`,onClick:()=>u({},`label`,!0),children:[(0,$.jsx)(W,{className:`size-4`}),` `,U(`project.factAdd`)]}):null,children:[(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:a.map(e=>{let t=D(e.value),r=e.type??t;return(0,$.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,$.jsx)(x,{ref:f(`${e.id}:label`),value:e.label,placeholder:U(`project.factLabel`),title:e.key?`{{facts.${e.key}}}`:void 0,onChange:t=>l(e.id,{label:t.target.value}),onBlur:()=>{!e.key&&e.label.trim()&&l(e.id,{key:J(e.label,a.map(e=>e.key))})},className:`max-sm:col-span-3 max-sm:font-medium sm:mr-1`}),e.type===`boolean`?(0,$.jsxs)(`div`,{className:`flex h-11 items-center gap-3`,children:[(0,$.jsx)(ie,{checked:Mn(e.value),label:e.label,onChange:t=>l(e.id,{value:U(t?`project.yes`:`project.no`)})}),(0,$.jsx)(`span`,{className:`text-[0.875rem] text-ink-2`,children:Mn(e.value)?U(`project.yes`):U(`project.no`)})]}):(0,$.jsx)(v,{ref:f(`${e.id}:value`),rows:1,minRows:r===`longtext`?2:1,maxRows:10,value:e.value,placeholder:U(`project.factValue`),onChange:t=>l(e.id,{value:t.target.value}),className:`min-h-11`}),(0,$.jsx)(Pn,{type:e.type,detected:t,onChange:t=>l(e.id,{type:t})}),n?null:(0,$.jsx)(g,{label:U(`project.remove`),onClick:()=>o(t=>t.filter(t=>t.id!==e.id)),className:`size-11 rounded-lg hover:text-rose`,children:(0,$.jsx)(d,{className:`size-4`})})]},e.id)})}),a.length<s.facts&&!n?(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 ${a.length?`mt-4`:``}`,children:[(0,$.jsxs)(q,{variant:`secondary`,size:`sm`,onClick:()=>u({},`label`),children:[(0,$.jsx)(W,{className:`size-4`}),` `,U(`project.factAdd`)]}),p.map(e=>(0,$.jsxs)(`button`,{type:`button`,onClick:()=>u({key:e,label:U(`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,$.jsx)(W,{className:`size-3.5`}),` `,U(`fact.${e}`)]},e))]}):null]})}function In({onLogo:e,children:t,className:n}){let[r,i]=(0,Q.useState)(!1);return e?(0,$.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(nn);i(!1),n&&(t.preventDefault(),e(n))},className:X(`-m-2 rounded-xl p-2 transition`,r&&`bg-paper-2 ring-1 ring-focus`,n),children:t}):(0,$.jsx)(`div`,{className:n,children:t})}function Ln({projectId:e,data:t,readOnly:n,sections:r,rules:i,sectioned:a,ruled:o,save:c}){let u=l(e,n),[d,f]=(0,Q.useState)(r),p=be(i),[m,h]=(0,Q.useState)(null),[g,_]=(0,Q.useState)(!1),v=(0,Q.useRef)(null),y=O({logoSections:d,logoRules:p.rules},c),b=t.files.filter(e=>e.kind===`logo`),x=new Map(b.map(e=>[e.id,e])),S=a?d:[],C=new Set(S.flatMap(e=>e.logos)),w=b.filter(e=>!C.has(e.id)),T=de(b,d)?.id,E=(e,t)=>f(n=>n.map(n=>{let r=n.logos.filter(t=>t!==e);return{...n,logos:n.id===t?[...r,e]:r}})),D=(e,t)=>f(n=>n.map(n=>n.id===e?{...n,...t}:n)),k=async(e,t)=>{let n=await u.upload(`logo`,e);for(let e of n)E(e.id,t)},A=S.length?{options:[{value:``,label:U(`project.sectionStandard`)},...S.map(e=>({value:e.id,label:e.title||U(`project.sectionUntitled`)}))],current:e=>S.find(t=>t.logos.includes(e.id))?.id??``,onMove:(e,t)=>E(e.id,t||null)}:void 0,j=(t,n,r)=>(0,$.jsx)(rn,{projectId:e,kind:`logo`,files:t,actions:u,accept:`image/*`,addLabel:r?U(`project.logoAdd`):void 0,onUpload:e=>void k(e,n),mainId:T,onMakeMain:e=>{E(e.id,null),u.order(`logo`,[e.id,...b.filter(t=>t.id!==e.id).map(e=>e.id)])},moveTo:A,onRemove:e=>{confirm(U(`project.removeConfirm`,{name:e.name}))&&(u.remove(e.id),E(e.id,null))}}),M=n?void 0:e=>t=>E(t,e),N=[{label:U(`project.logoUpload`),icon:(0,$.jsx)(Ke,{className:`size-4 shrink-0`}),onPick:()=>v.current?.click()},{label:U(`project.logoFromUrl`),icon:(0,$.jsx)(Kt,{className:`size-4 shrink-0`}),onPick:()=>_(!0)},...a&&d.length<s.logoSections?[{label:U(`project.logoSectionAdd`),icon:(0,$.jsx)(Bt,{className:`size-4 shrink-0`}),onPick:()=>{let e=z();h(e),f(t=>[...t,{id:e,title:``,description:``,logos:[]}])}}]:[],...!o||p.full?[]:[{label:U(`project.ruleNew`),icon:(0,$.jsx)(ut,{className:`size-4 shrink-0`}),onPick:()=>p.add()}]];return(0,$.jsxs)(Z,{title:U(`project.logos`),hint:U(`project.logosHint`),save:y,action:n?null:(0,$.jsx)(ve,{entries:N}),children:[(0,$.jsx)(`input`,{ref:v,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&&k(t,null)}}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[(0,$.jsx)(In,{onLogo:M?.(null),children:j(w,null,!0)}),S.map(e=>(0,$.jsx)(`div`,{className:`group/section`,children:(0,$.jsxs)(In,{onLogo:M?.(e.id),className:`flex flex-col gap-3`,children:[(0,$.jsx)(xe,{title:e.title,description:e.description,titlePlaceholder:U(`project.logoSectionTitle`),descriptionPlaceholder:U(`project.logoSectionUse`),autoFocus:m===e.id,readOnly:n,onChange:t=>D(e.id,t),onRemove:()=>{(!e.logos.length||confirm(U(`project.logoSectionRemoveConfirm`,{name:e.title||U(`project.sectionUntitled`)})))&&f(t=>t.filter(t=>t.id!==e.id))}}),j(e.logos.map(e=>x.get(e)).filter(e=>!!e),e.id,!0)]})},e.id)),o?(0,$.jsx)(se,{rules:p,placeholder:U(`project.logoRulePlaceholder`),readOnly:n}):null]}),u.error?(0,$.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:u.error}):null,g?(0,$.jsx)(an,{kind:`logo`,onClose:()=>_(!1),fetchUrl:e=>u.fromUrl(`logo`,e),onAdded:e=>{for(let t of e)E(t.id,null)}}):null]})}var Rn=new Set;function zn(e){(0,Q.useEffect)(()=>{let t=e.trim().toLowerCase().replace(/\s+/g,`-`);if(!t||Rn.has(t))return;Rn.add(t);let n=document.createElement(`link`);n.rel=`stylesheet`,n.href=`https://fonts.bunny.net/css?family=${encodeURIComponent(t)}:${te.join(`,`)}&display=swap`,document.head.append(n)},[e])}var Bn=e=>e?`"${e}", system-ui, sans-serif`:`system-ui, sans-serif`;function Vn({unit:e,label:t,...n}){return(0,$.jsxs)(`label`,{className:`inline-flex items-center gap-1 text-[0.75rem] text-ink-3`,title:t,children:[(0,$.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 Hn=`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`,Un={web:`project.fontUseWeb`,documents:`project.fontUseDocuments`,print:`project.fontUsePrint`,images:`project.fontUseImages`,video:`project.fontUseVideo`};function Wn({font:e,first:t,readOnly:n,autoFocus:r,onChange:i,onRemove:a}){return zn(e.family),(0,$.jsxs)(`div`,{className:`group/font relative flex flex-col gap-2 rounded-lg bg-paper p-3 ring-1 ring-border-soft`,children:[(0,$.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:Bn(e.family)},children:[(0,$.jsx)(`span`,{className:`text-[3.5rem] text-ink leading-none`,children:`Aa`}),(0,$.jsx)(`span`,{className:`truncate pl-3 text-[0.875rem] text-ink-3`,children:`ABCDEFG abcdefg 0123456789`})]}),n?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`font-medium text-[0.9375rem]`,children:e.family}),e.role?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:e.role}):null]}):(0,$.jsxs)(`div`,{children:[(0,$.jsx)(pe,{value:e.family,label:U(`project.fontFamily`),placeholder:U(`project.fontFamily`),maxLength:80,autoFocus:r,onChange:e=>i({family:e}),className:`font-medium text-[0.9375rem]`}),(0,$.jsx)(pe,{value:e.role,label:U(`project.fontRole`),placeholder:U(t?`project.fontRoleFirst`:`project.fontRole`),maxLength:200,onChange:e=>i({role:e}),className:`text-[0.875rem] text-ink-3`})]}),(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:te.map(t=>{let r=e.weights.includes(t);return(0,$.jsx)(`button`,{type:`button`,disabled:n,"aria-pressed":r,onClick:()=>i({weights:r?e.weights.filter(e=>e!==t):[...e.weights,t].sort((e,t)=>e-t)}),style:{fontFamily:Bn(e.family),fontWeight:t},className:X(`h-7 rounded-full px-2.5 text-[0.8125rem] tabular-nums transition`,r?`bg-ink text-paper`:`bg-paper-2 text-ink-3 hover:text-ink`,n&&!r&&`hidden`),children:t},t)})}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[n?e.license?(0,$.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3`,children:e.license}):null:(0,$.jsx)(pe,{value:e.license??``,label:U(`project.fontLicense`),placeholder:U(`project.fontLicensePlaceholder`),maxLength:200,onChange:e=>i({license:e}),className:`text-[0.8125rem] text-ink-3`}),n&&!e.uses?.length?null:(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[(0,$.jsx)(`span`,{className:`mr-1 text-[0.8125rem] text-ink-3`,children:U(`project.fontUses`)}),ye.map(t=>{let r=!!e.uses?.includes(t);return(0,$.jsxs)(`button`,{type:`button`,disabled:n,"aria-pressed":r,onClick:()=>{let n=r?(e.uses??[]).filter(e=>e!==t):ye.filter(n=>n===t||e.uses?.includes(n));i({uses:n.length?n:void 0})},className:X(`inline-flex h-7 items-center gap-1 rounded-full px-2.5 text-[0.8125rem] transition`,r?`bg-card text-ink ring-1 ring-border`:`bg-paper-2 text-ink-3 hover:text-ink`,n&&!r&&`hidden`),children:[r?(0,$.jsx)(P,{className:`size-3.5`}):null,U(Un[t])]},t)})]})]}),n?null:(0,$.jsx)(g,{label:U(`project.remove`),onClick:a,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,$.jsx)(d,{className:`size-4`})})]})}function Gn({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:Bn(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,$.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,$.jsx)(`div`,{className:`truncate text-ink`,style:c,children:n}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2`,children:[r?(0,$.jsx)(`span`,{className:`font-medium text-[0.8125rem] text-ink-2 uppercase tracking-wide`,children:e.name}):(0,$.jsx)(`div`,{className:`w-40`,children:(0,$.jsx)(pe,{value:e.name,label:U(`project.styleName`),placeholder:U(`project.styleName`),maxLength:60,autoFocus:i,onChange:e=>a({name:e}),className:`font-medium text-[0.8125rem] text-ink-2 uppercase tracking-wide`})}),(0,$.jsxs)(`fieldset`,{disabled:r,className:`flex flex-wrap items-center gap-x-3 gap-y-2`,children:[t.length>1?(0,$.jsx)(`select`,{"aria-label":U(`project.styleFont`),value:s?.id??``,onChange:e=>a({font:e.target.value}),className:X(Hn,`max-w-40`),children:t.map(e=>(0,$.jsx)(`option`,{value:e.id,children:e.family||U(`project.fontFamily`)},e.id))}):null,(0,$.jsx)(`select`,{"aria-label":U(`project.styleWeight`),value:e.weight,onChange:e=>a({weight:Number(e.target.value)}),className:Hn,children:[...new Set([...te,e.weight])].sort().map(e=>(0,$.jsx)(`option`,{value:e,children:e},e))}),(0,$.jsx)(Vn,{unit:`px`,label:U(`project.styleSize`),min:6,max:400,value:e.size,onChange:e=>a({size:Number(e.target.value)||16})}),(0,$.jsx)(Vn,{unit:U(`project.styleLine`),label:U(`project.styleLineLabel`),min:50,max:300,value:e.lineHeight,onChange:e=>a({lineHeight:Number(e.target.value)||100})}),(0,$.jsx)(Vn,{unit:U(`project.styleTracking`),label:U(`project.styleTrackingLabel`),min:-20,max:50,step:.5,value:e.tracking,onChange:e=>a({tracking:Number(e.target.value)||0})}),(0,$.jsx)(`button`,{type:`button`,"aria-pressed":!!e.uppercase,title:U(`project.styleUpper`),"aria-label":U(`project.styleUpper`),onClick:()=>a({uppercase:!e.uppercase}),className:X(`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,$.jsx)(Rt,{className:`size-4`})})]}),r?null:(0,$.jsx)(g,{label:U(`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,$.jsx)(d,{className:`size-4`})})]})]})}function Kn({projectId:e,onAdd:t,onClose:n}){let[r,i]=(0,Q.useState)(``),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(null),[l,u]=(0,Q.useState)(null),[d,f]=(0,Q.useState)([]),p=async()=>{o(!0),c(null);try{let{fonts:t}=await j.post(`/api/studio/projects/${e}/fonts/scan`,{url:r.trim()});t.length?(u(t),f(t.slice(0,2).map(e=>e.family))):c(U(`project.fontsNoneFound`))}catch(e){c(e.message)}o(!1)};return(0,$.jsx)(k,{open:!0,onClose:n,wide:l?!0:void 0,title:U(l?`project.fontsFound`:`project.fontsFromUrl`),children:l?(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-ink-3`,children:U(`project.fontsFoundHint`)}),(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:l.map(e=>(0,$.jsx)(qn,{font:e,on:d.includes(e.family),onToggle:()=>f(t=>t.includes(e.family)?t.filter(t=>t!==e.family):[...t,e.family])},e.family))}),(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(q,{variant:`ghost`,onClick:()=>u(null),children:U(`run.back`)}),(0,$.jsx)(q,{disabled:!d.length,onClick:()=>{t(l.filter(e=>d.includes(e.family))),n()},children:d.length>1?U(`project.addMany`,{n:d.length}):U(`project.add`)})]})]}):(0,$.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),p()},className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(N,{children:U(`project.logoUrl`)}),(0,$.jsx)(x,{autoFocus:!0,value:r,inputMode:`url`,placeholder:`https://example.com`,onChange:e=>i(e.target.value)}),(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:U(`project.fontsUrlHint`)})]}),s?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:s}):null,(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(q,{variant:`ghost`,onClick:n,children:U(`common.cancel`)}),(0,$.jsx)(q,{type:`submit`,busy:a,disabled:!r.trim(),children:U(`run.next`)})]})]})})}function qn({font:e,on:t,onToggle:n}){return zn(e.family),(0,$.jsxs)(`button`,{type:`button`,"aria-pressed":t,onClick:n,className:X(`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,$.jsx)(`span`,{className:`text-[2rem] text-ink leading-none`,style:{fontFamily:Bn(e.family)},children:`Aa`}),(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,$.jsx)(`span`,{className:`font-medium text-[0.9375rem]`,children:e.family}),(0,$.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3 tabular-nums`,children:e.weights.length?e.weights.join(` · `):U(`project.fontWeightsUnknown`)})]}),t?(0,$.jsx)(`span`,{className:`grid size-5 place-items-center rounded-full bg-ember text-white`,children:(0,$.jsx)(P,{className:`size-3.5`})}):null]})}function Jn({projectId:e,fonts:t,styles:n,rules:r,ruled:i,sample:a,save:o,readOnly:c}){let[l,u]=(0,Q.useState)(t),[d,f]=(0,Q.useState)(n),p=be(r),[m,h]=(0,Q.useState)(null),[g,_]=(0,Q.useState)(!1),v=O({fonts:l,textStyles:d,typeRules:p.rules},o),y=(e,t=!1)=>{let n=e.map(e=>({id:z(),family:e.family,role:``,weights:e.weights}));t&&n[0]&&h(n[0].id),u(e=>[...e,...n].slice(0,s.fonts))},b=()=>{let e=z();h(e),f(t=>[...t,{id:e,name:``,size:16,weight:400,lineHeight:150,tracking:0}])},x=[...l.length<s.fonts?[{label:U(`project.fontNew`),icon:(0,$.jsx)(W,{className:`size-4 shrink-0`}),onPick:()=>y([{family:``,weights:[400,700]}],!0)},{label:U(`project.fontsFromUrl`),icon:(0,$.jsx)(Kt,{className:`size-4 shrink-0`}),onPick:()=>_(!0)}]:[],...d.length<s.textStyles?[{label:U(`project.styleNew`),icon:(0,$.jsx)($e,{className:`size-4 shrink-0`}),onPick:b}]:[],...!i||p.full?[]:[{label:U(`project.ruleNew`),icon:(0,$.jsx)(ut,{className:`size-4 shrink-0`}),onPick:()=>p.add()}]];return(0,$.jsxs)(Z,{title:U(`project.typography`),hint:U(`project.typographyHint`),save:v,action:c?null:(0,$.jsx)(ve,{entries:x}),children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[l.length?(0,$.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(260px,1fr))] gap-3`,children:l.map((e,t)=>(0,$.jsx)(Wn,{font:e,first:t===0,readOnly:c,autoFocus:m===e.id,onChange:t=>u(n=>n.map(n=>n.id===e.id?{...n,...t}:n)),onRemove:()=>u(t=>t.filter(t=>t.id!==e.id))},e.id))}):(0,$.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:U(`project.fontsEmpty`)}),d.length?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`font-medium text-[0.9375rem]`,children:U(`project.styles`)}),c?null:(0,$.jsx)(`p`,{className:`text-[0.875rem] text-ink-3 leading-snug`,children:U(`project.stylesHint`)}),(0,$.jsx)(`ul`,{className:`mt-2 flex flex-col`,children:d.map(e=>(0,$.jsx)(Gn,{style:e,fonts:l,sample:a,readOnly:c,autoFocus:m===e.id,onChange:t=>f(n=>n.map(n=>n.id===e.id?{...n,...t}:n)),onRemove:()=>f(t=>t.filter(t=>t.id!==e.id))},e.id))})]}):null,i?(0,$.jsx)(se,{rules:p,placeholder:U(`project.typeRulePlaceholder`),readOnly:c}):null]}),g?(0,$.jsx)(Kn,{projectId:e,onClose:()=>_(!1),onAdd:e=>y(e)}):null]})}function Yn({project:e,save:t}){let[n,r]=(0,Q.useState)(e.brand.name??``),[i,a]=(0,Q.useState)(e.brand.about??``),o=O({name:n.trim(),about:i.trim()},e=>t({brand:e}));return(0,$.jsx)(Z,{title:U(`project.base`),hint:U(`project.baseHint`),save:o,locked:e.readOnly,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(N,{children:U(`project.title`)}),(0,$.jsx)(x,{value:n,maxLength:120,onChange:e=>r(e.target.value)}),(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:U(`project.titleHint`)})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(N,{children:U(`project.about`)}),(0,$.jsx)(v,{minRows:4,value:i,onChange:e=>a(e.target.value)}),(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:U(`project.aboutHint`)})]})]})})}function Xn({project:e,group:t,children:n}){let r=H(),i=y(e.id),[a,o]=(0,Q.useState)(0),[s,c]=(0,Q.useState)(!1),l=async t=>{await j.patch(`/api/studio/projects/${e.id}`,t),await r.invalidateQueries({queryKey:[`projects`]})},u=xt({mutationFn:()=>j.del(`/api/studio/projects/${e.id}`),onSuccess:()=>r.invalidateQueries({queryKey:[`projects`]})}),d=yt(),f=Je(),p=i.data??{files:[],embeddings:!0},m=`${e.id}:${a}`,h=e.readOnly,g=t===`knowledge`,_=lt(`brandSections`),v=lt(`brandRules`),b=lt(`typography`);return dt(h?{}:{title:U(g?`project.assistantTitleKnowledge`:`project.assistantTitle`),hello:U(g?`project.assistantHelloKnowledge`:`project.assistantHello`),placeholder:U(g?`project.assistantComposerKnowledge`:`project.assistantComposer`),suggestions:g?[{label:U(`assistant.suggest.knowledgeHow`)},{label:U(`assistant.suggest.knowledgeSite`),fill:!0},{label:U(`assistant.suggest.knowledgeCategories`)}]:[{label:U(`assistant.suggest.readSite`),fill:!0},{label:U(`assistant.suggest.missing`)},{label:U(`assistant.suggest.facts`)}],summary:g?void 0:[e.brand.name?`title "${e.brand.name}"`:`no title`,`${e.facts.length} facts`,`${e.brand.colors?.length??0} colours`,`${p.files.filter(e=>e.kind===`logo`).length} logos`].join(` · `),onChanged:()=>o(e=>e+1)}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-9`,children:[h?(0,$.jsx)(Ge,{children:Ue(e)}):null,t===`info`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(G,{id:`base`,children:(0,$.jsx)(Yn,{project:e,save:l},`base:${m}`)}),(0,$.jsx)(G,{id:`facts`,children:(0,$.jsx)(Fn,{facts:e.facts,save:e=>l({facts:e}),readOnly:h},`facts:${m}`)}),(0,$.jsx)(G,{id:`logos`,children:(0,$.jsx)(Ln,{projectId:e.id,data:p,readOnly:h,sections:e.brand.logoSections??[],rules:e.brand.logoRules??[],sectioned:_,ruled:v,save:e=>l({brand:e})},`logos:${m}`)}),(0,$.jsx)(G,{id:`colors`,children:(0,$.jsx)(jn,{projectId:e.id,data:p,colors:e.brand.colors??[],sections:e.brand.colorSections??[],gradients:e.brand.gradients??[],patterns:e.brand.patterns??[],rules:e.brand.colorRules??[],sectioned:_,ruled:v,save:e=>l({brand:e}),readOnly:h},`colors:${m}`)}),b?(0,$.jsx)(G,{id:`typography`,children:(0,$.jsx)(Jn,{projectId:e.id,fonts:e.brand.fonts??[],styles:e.brand.textStyles??[],rules:e.brand.typeRules??[],ruled:v,sample:e.brand.name||U(`project.typeSample`),save:e=>l({brand:e}),readOnly:h},`typography:${m}`)}):null,(0,$.jsx)(G,{id:`assets`,children:(0,$.jsx)(_n,{projectId:e.id,data:p,readOnly:h,sections:e.brand.assetSections??[],save:e=>l({brand:e})},`assets:${m}`)})]}):null,n,t===`info`&&d&&!h&&f?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(q,{variant:`danger`,onClick:()=>c(!0),children:U(`settings.delete`)}),(0,$.jsxs)(k,{open:s,onClose:()=>c(!1),title:U(`settings.deleteTitle`,{name:e.name}),children:[(0,$.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-ink-2`,children:U(`settings.deleteBody`)}),u.error?(0,$.jsx)(`p`,{className:`mt-3 text-[0.8125rem] text-rose`,children:u.error.message}):null,(0,$.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,$.jsx)(q,{variant:`ghost`,onClick:()=>c(!1),children:U(`common.cancel`)}),(0,$.jsx)(q,{variant:`danger`,busy:u.isPending,onClick:()=>u.mutate(),children:U(`common.delete`)})]})]})]}):null]})}var Zn=`results-search`,Qn={q:``,mode:``,days:0};function $n(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 a({queryKey:[`results`,e,i],queryFn:()=>j.get(`/api/studio/projects/${e}/results${i&&`?${i}`}`),enabled:!!e,placeholderData:e=>e,refetchInterval:15e3})}function er({data:e,wizardId:t,onWizard:n,filter:r,onFilter:i}){let[a,o]=(0,Q.useState)(r.q);return _t({icon:I,label:U(`space.resultsSearch`),run:()=>{let e=document.getElementById(Zn);e?.scrollIntoView({block:`center`,behavior:`smooth`}),e?.focus()}}),(0,Q.useEffect)(()=>{if(a===r.q)return;let e=setTimeout(()=>i({...r,q:a}),250);return()=>clearTimeout(e)},[a,r,i]),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsx)(F,{value:t??``,onChange:e=>n(e||null),options:[{value:``,label:U(`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,$.jsxs)(`div`,{className:`relative min-w-0 flex-1 basis-56`,children:[(0,$.jsx)(I,{className:`-translate-y-1/2 pointer-events-none absolute top-1/2 left-3 size-4 text-ink-3`}),(0,$.jsx)(x,{type:`search`,value:a,onChange:e=>o(e.target.value),id:Zn,placeholder:U(`space.resultsSearch`),"aria-label":U(`space.resultsSearch`),className:`w-full pl-9`})]}),(0,$.jsx)(F,{value:r.mode,onChange:e=>i({...r,mode:e}),options:[{value:``,label:U(`space.resultsModeAll`)},{value:`live`,label:`Live`},{value:`test`,label:`Test`}],className:`w-32`}),(0,$.jsx)(F,{value:String(r.days),onChange:e=>i({...r,days:Number(e)}),options:[{value:`0`,label:U(`space.resultsAnyTime`)},{value:`1`,label:U(`space.resultsDay`)},{value:`7`,label:U(`space.resultsDays`,{n:7})},{value:`30`,label:U(`space.resultsDays`,{n:30})}],className:`w-44`})]})}function tr({data:e,wizardId:t,onWizard:n,filter:r,onFilter:i}){let[a,o]=(0,Q.useState)(null),s=t=>e.wizards.find(e=>e.id===t)?.title??``,c=new Intl.DateTimeFormat(L,{dateStyle:`medium`,timeStyle:`short`});return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(Z,{title:t?s(t):U(`space.resultsAll`),hint:U(`space.resultsHint`),plain:!0,children:[(0,$.jsx)(er,{data:e,wizardId:t,onWizard:n,filter:r,onFilter:i}),e.runs.length?(0,$.jsx)(C,{className:`flex flex-col p-1.5`,children:e.runs.map(e=>(0,$.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,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`div`,{className:`truncate text-[0.875rem]`,children:t?c.format(new Date(e.doneAt)):s(e.wizardId)}),(0,$.jsxs)(`div`,{className:`truncate text-[0.75rem] text-ink-3`,children:[t?null:`${c.format(new Date(e.doneAt))} · `,U(`space.resultCredits`,{n:e.credits})]})]}),e.assets?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[0.75rem] text-ink-3 tabular-nums`,title:U(`space.resultFiles`,{n:e.assets}),children:[(0,$.jsx)(ue,{className:`size-3.5`}),e.assets]}):null,e.mode===`test`?(0,$.jsx)(E,{children:U(`run.testChip`)}):(0,$.jsxs)(E,{tone:`live`,children:[`Live v`,e.version]})]},e.id))}):(0,$.jsx)(C,{children:(0,$.jsx)(u,{children:r.q.trim()||r.mode||r.days?U(`space.resultsNone`):U(`space.resultsEmpty`)})})]}),a?(0,$.jsx)(Pe,{header:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium text-[0.875rem]`,children:s(a.wizardId)}),a.mode===`test`?(0,$.jsx)(E,{children:U(`run.testChip`)}):(0,$.jsxs)(E,{tone:`live`,children:[`Live v`,a.version]})]}),onClose:()=>o(null),children:(0,$.jsx)(Mt,{runId:a.id,compact:!0,studio:!0},a.id)}):null]})}function nr({project:e,save:t}){let[n,r]=(0,Q.useState)(!1),[i,a]=(0,Q.useState)(e.name),o=xt({mutationFn:()=>t({name:i.trim()}),onSuccess:()=>r(!1)});return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(g,{label:U(`project.rename`),onClick:()=>{a(e.name),r(!0)},children:(0,$.jsx)(_e,{className:`size-4`})}),(0,$.jsx)(k,{open:n,onClose:()=>r(!1),title:U(`project.rename`),children:(0,$.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),i.trim()&&o.mutate()},children:[(0,$.jsx)(x,{"data-autofocus":!0,value:i,maxLength:80,onChange:e=>a(e.target.value)}),o.error?(0,$.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:o.error.message}):null,(0,$.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,$.jsx)(q,{variant:`ghost`,onClick:()=>r(!1),children:U(`common.cancel`)}),(0,$.jsx)(q,{type:`submit`,busy:o.isPending,disabled:!i.trim(),children:U(`settings.save`)})]})]})})]})}function rr({project:e}){let t=H();return(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(tt,{}),e.readOnly?null:(0,$.jsx)(nr,{project:e,save:async n=>{await j.patch(`/api/studio/projects/${e.id}`,n),await t.invalidateQueries({queryKey:[`projects`]})}})]})}function ir(e){let t=e.join(` `),[n,r]=(0,Q.useState)(e[0]);return(0,Q.useEffect)(()=>{let e=t.split(` `),n=0,i=()=>{n=0;let t=vt(),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 ar(e,t){let n=window.matchMedia(`(prefers-reduced-motion: reduce)`).matches;document.getElementById(e)?.scrollIntoView({block:`start`,behavior:t&&!n?`smooth`:`auto`})}function or({groups:e,current:t,onPick:n}){return e.map(e=>{let r=e.sections.map(e=>(0,$.jsx)(St,{icon:e.icon??Ze,label:e.label,selected:e.id===t,onPick:()=>n(e.id)},e.id));return e.label?(0,$.jsx)(Tt,{label:e.label,children:r},e.plugin):(0,$.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:r},`own`)})}function sr(){let{group:e}=M(),[t,n]=Se(),r=b(),i=h(),{hash:a}=i,{project:o,loading:s}=Qe(),c=yt(),l=gt(),d=jt(),[f,p]=(0,Q.useState)(null),[m,g]=(0,Q.useState)(null),[_,v]=(0,Q.useState)(null),y=at(e)?e:void 0,x=y?void 0:l.spaceParts.find(t=>t.id===e),S=y??x?.id,C=i.state?.parts===!0,w=ot(ct(),l).map(e=>({...e,to:`/space/${e.id}`})),E={id:`results`,label:U(`space.results`),icon:mt,to:`/space/results`},D=y===`results`?E:w.find(e=>e.id===S),O=t.get(`show`),k=y===`results`?2:S?O?2:1:0,A=y===`results`?1:d?Math.min(k,1):S&&_!==S&&!C?1:0,j=wt(A),N=wt(k),ee=(0,Q.useMemo)(()=>({slot:f,narrow:d,setDetail:g}),[f,d]),P=o?o.brand.name?.trim()||o.name:U(`nav.project`),te=lt(`typography`)?[]:[`typography`],ne=x?l.spaceMenus[x.id]??[]:[],re=x?[{plugin:null,label:null,sections:ne}]:y&&y!==`results`?ft(y,l,te):[],F=y?ft(y,l).filter(e=>e.plugin):[],ie=ir([...re,...y===`results`?F:[]].flatMap(e=>e.sections.map(e=>e.id))),I=y===`results`&&O&&O!==`all`?O:null,[L,ae]=(0,Q.useState)(Qn),R=$n(y===`results`?o?.id:void 0,I,L),z=R.data?.wizards.find(e=>e.id===I)?.title,B=y===`data`&&O&&O!==`all`||y===`knowledge`&&O&&/^[ptfcvs]:/.test(O)?O:null,V=B?.startsWith(`s:`)?l.spaceSections.find(e=>e.id===B.slice(2)):void 0,H=y===`knowledge`&&B&&/^[ptf]:/.test(B)?B:null,oe=Ee(y===`data`?o?.id:void 0),W=Ne(y===`knowledge`?o?.id:void 0),K=ze(B?.startsWith(`v:`)?B.slice(2):``),se=W.data?.categories.find(e=>e.id===(B?.startsWith(`c:`)?B.slice(2):K.data?.category.id)),ce=y===`knowledge`?V?V.label():B?.startsWith(`v:`)?K.data&&`${K.data.category.name}: ${K.data.value}`:B?.startsWith(`c:`)?se?.name:W.data?.items.find(e=>e.key===B)?.title:oe.data?Le(oe.data).flatMap(e=>e.items).find(e=>e.key===B)?.title:void 0;bt([...y===`results`?[]:[{label:U(`nav.project`),to:`/space`}],...D?[{label:D.label,to:`/space/${D.id}`}]:[],...D&&(m??z??ce)?[{label:m??z??ce}]:[]]);let le={p:`page`,t:`table`,f:`file`,c:`category`,v:`category value`,s:`plugin section`};dt({...y===`data`||y===`results`?{compact:!0}:{},...y===`data`?{suggestions:[{label:U(`assistant.suggest.dataWhat`)},{label:U(`assistant.suggest.dataWho`)},{label:U(`assistant.suggest.dataEdit`)}]}:y===`results`?{suggestions:[{label:U(`assistant.suggest.resultsFailed`)},{label:U(`assistant.suggest.resultsCost`)},{label:U(`assistant.suggest.resultsShare`)}]}:{},...B&&ce?{open:{kind:le[B[0]]??`item`,id:B.slice(2),label:ce}}:I&&z?{open:{kind:`wizard`,id:I,label:z}}:{}});let ue=y===`results`||y===`data`||B?a.slice(1):O||a.slice(1),de=(0,Q.useRef)(``);if((0,Q.useEffect)(()=>{let e=`${S}#${ue}`;ue&&de.current!==e&&document.getElementById(ue)&&(de.current=e,requestAnimationFrame(()=>ar(ue,!1)))},[S,ue,o?.id,l.spaceSections,ne.length]),!S){let t=a.slice(1),n=t?rt(t,l):null;if(n===`knowledge`&&l.spaceSections.some(e=>e.id===t))return(0,$.jsx)(T,{to:`/space/knowledge?show=s:${t}`,replace:!0});if(n)return(0,$.jsx)(T,{to:d?`/space/${n}?show=${t}`:{pathname:`/space/${n}`,hash:t},replace:!0});if((t||e)&&l.status!==`ready`)return null;if(e!==void 0||!d)return(0,$.jsx)(T,{to:`/space/info`,replace:!0,state:{parts:!0}})}if(y===`knowledge`&&!O&&l.spaceSections.some(e=>e.id===a.slice(1)))return(0,$.jsx)(T,{to:`/space/knowledge?show=s:${a.slice(1)}`,replace:!0});let q=e=>{if(d){r({search:`?show=${e}`});return}de.current=`${S}#${e}`,ar(e,!0),r({search:``,hash:e},{replace:!0})},J=e=>d?n({show:e}):n(e===`all`?{}:{show:e},{replace:!0}),Y=e=>e.flatMap(e=>e.sections).map(e=>l.spaceSections.find(t=>t.id===e.id)).filter(e=>e!==void 0).map(e=>(0,$.jsx)(G,{id:e.id,children:(0,$.jsx)(Z,{title:e.label(),hint:e.hint?.(),plain:!0,children:(0,$.jsx)(pt,{of:e,children:(0,$.jsx)(e.component,{})})})},e.serial)),fe=d?void 0:ie,pe=(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Et,{title:P,open:A===1?D??null:null,onBack:y===`results`?void 0:()=>d?r(`/space`):v(S??null),root:{icon:st,label:U(`nav.project`),backLabel:U(`nav.wizards`),onBack:()=>r(`/`)}}),(0,$.jsx)(`div`,{className:X(Ct(j)),children:A===0?(0,$.jsx)(Ot,{entries:w,current:d?void 0:D,onPick:()=>v(null)}):(0,$.jsx)(`div`,{ref:p})},A)]});return(0,$.jsx)(Dt.Provider,{value:ee,children:(0,$.jsx)(`div`,{className:`animate-rise`,children:(0,$.jsxs)(`div`,{className:X(`grid gap-6`,y!==`results`&&`md:grid-cols-[10.5rem_minmax(0,1fr)] md:gap-5 lg:grid-cols-[15rem_minmax(0,1fr)] lg:gap-10`),children:[y===`results`?null:(0,$.jsx)(`aside`,{className:X(`min-w-0 md:sticky md:top-6 md:self-start`,d&&k===2&&`hidden`,d&&N===`back`&&Ct(`back`)),children:pe}),S?(0,$.jsxs)(`div`,{className:X(`min-w-0`,d&&k<2&&`hidden`,d&&N===`deeper`&&Ct(`deeper`)),children:[d&&y!==`results`?(0,$.jsx)(`div`,{className:`mb-3`,children:(0,$.jsx)(At,{label:D?.label??P,onBack:()=>r(`/space/${S}`)})}):null,c&&o?(0,$.jsx)(`div`,{className:`mb-6`,children:(0,$.jsx)(rr,{project:o})}):null,y===`data`?(0,$.jsxs)(kt,{children:[(0,$.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:(0,$.jsx)(St,{icon:Wt,label:U(`data.all`),selected:!d&&!B,onPick:()=>J(`all`)})}),oe.data?Le(oe.data).map(e=>(0,$.jsx)(Tt,{label:e.label,children:e.items.map(e=>(0,$.jsx)(St,{icon:Te[e.kind],label:e.title,selected:!d&&e.key===B,onPick:()=>J(e.key)},e.key))},e.key)):null,(0,$.jsx)(or,{groups:F,current:fe,onPick:q})]}):y===`knowledge`?(0,$.jsxs)(kt,{children:[(0,$.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:(0,$.jsx)(St,{icon:Wt,label:U(`know.all`),selected:!(d||B),onPick:()=>J(`all`)})}),W.data?.categories.length?(0,$.jsx)(Tt,{label:U(`know.categories`),children:W.data.categories.map(e=>(0,$.jsx)(St,{icon:Ae[e.type],label:e.name,badge:(0,$.jsx)(`span`,{className:`text-[0.75rem] text-ink-3 tabular-nums`,children:e.proposed?`·`:e.count}),selected:!d&&(B===`c:${e.id}`||K.data?.category.id===e.id),onPick:()=>J(`c:${e.id}`)},e.id))}):null,(0,$.jsx)(or,{groups:F,current:d?void 0:V?.id,onPick:e=>J(`s:${e}`)})]}):(0,$.jsx)(kt,{children:(0,$.jsx)(or,{groups:re,current:fe,onPick:q})}),o&&(y===`info`||y===`knowledge`)?(0,$.jsxs)(Xn,{project:o,group:y,children:[y===`knowledge`?H?H.startsWith(`p:`)?(0,$.jsx)(Me,{pageId:H.slice(2),onGone:()=>J(`all`),onOpen:J},H):H.startsWith(`t:`)?(0,$.jsx)(je,{tableId:H.slice(2),onGone:()=>J(`all`)},H):(0,$.jsx)(un,{projectId:o.id,fileId:H.slice(2),readOnly:o.readOnly,onGone:()=>J(`all`)},H):W.data?V?(0,$.jsx)(Z,{title:V.label(),hint:V.hint?.(),plain:!0,children:(0,$.jsx)(pt,{of:V,children:(0,$.jsx)(V.component,{})})},B):B?.startsWith(`c:`)?se?(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsx)(ke,{projectId:o.id,category:se,readOnly:o.readOnly,onOpen:J,onGone:()=>J(`all`)}),se.type===`choice`?null:(0,$.jsx)(Re,{projectId:o.id,category:se,categories:W.data.categories,onOpen:J})]},B):null:B?.startsWith(`v:`)?K.data?(0,$.jsx)(we,{value:K.data,readOnly:o.readOnly,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[K.data.items.length?(0,$.jsx)(`div`,{className:`flex flex-col rounded-xl bg-card p-1.5 shadow-soft ring-1 ring-border-soft`,children:K.data.items.map(e=>(0,$.jsx)(De,{item:e,categories:W.data.categories.filter(e=>e.id!==K.data?.category.id),onOpen:J},e.key))}):null,K.data.rows.map(e=>(0,$.jsx)(`button`,{type:`button`,onClick:()=>J(`t:${e.tableId}`),className:`px-1 text-left text-[0.8125rem] text-ink-3 hover:text-ink`,children:U(`know.tocRows`,{n:e.count,table:e.title})},e.tableId))]})},B):null:(0,$.jsx)(G,{id:`documents`,children:(0,$.jsx)(Ie,{projectId:o.id,data:W.data,readOnly:o.readOnly,onOpen:J})}):null:null,y===`info`?Y(F):null]},o.id):null,o&&x?(0,$.jsx)(pt,{of:x,children:(0,$.jsx)(nt,{part:x.id,children:(0,$.jsx)(x.component,{})},o.id)}):null,o&&y===`data`?(0,$.jsx)(`div`,{className:`flex flex-col gap-9 pb-20`,children:B?.startsWith(`t:`)?(0,$.jsx)(je,{tableId:B.slice(2),onGone:()=>J(`all`)},B):B?.startsWith(`p:`)?(0,$.jsx)(Me,{pageId:B.slice(2),onGone:()=>J(`all`)},B):(0,$.jsxs)($.Fragment,{children:[oe.data?(0,$.jsx)(Fe,{projectId:o.id,data:oe.data,readOnly:o.readOnly,onOpen:J}):null,Y(F)]})}):null,o&&y===`results`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-9 pb-20`,children:[R.data?(0,$.jsx)(tr,{data:R.data,wizardId:I,onWizard:e=>J(e??`all`),filter:L,onFilter:ae}):null,R.isError?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:R.error.message}):null,Y(F)]}):null,o||s?null:(0,$.jsx)(u,{children:U(`settings.noProject`)})]}):null]})})})}export{sr as ProjectPage};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{$ as r,Br as i,Dn as a,Er as o,H as s,Hn as c,Ht as l,It as u,J as d,Lr as f,Nr as p,Q as m,Qt as h,R as g,Rr as _,Tt as v,en as y,jt as b,kr as x,nn as S,q as C,qt as w}from"./ui-Cdv3QUOd.js";import{a as T,i as E,n as D,o as O,r as k,s as A,t as ee}from"./ChatView-BLZkLlHi.js";import{$ as j,At as M,Pt as te,jt as N,kt as P}from"./index-CQKA-z2z.js";import{t as ne}from"./RunnerView-DHUkvi_G.js";var F={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`}]]};F.node;var re=x(F),I={name:`smartphone`,size:24,node:[[`rect`,{width:`14`,height:`20`,x:`5`,y:`2`,rx:`2`,ry:`2`,key:`1yt0o3`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}]]};I.node;var ie=x(I),L={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`]};L.node;var ae=x(L),R=e(t(),1);function oe(){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 z=oe(),se=z?new URLSearchParams(window.location.search).get(`page`):null,B=(e,t={})=>window.parent.postMessage({type:`engenty-wizard:${e}`,...t},`*`),ce=()=>B(`close`);function le(e){(0,R.useEffect)(()=>{if(z===`inline`&&!e){let e=document.documentElement;document.getElementById(`root`)?.style.setProperty(`min-height`,`0`),e.style.overflow=`hidden`;let t=new ResizeObserver(()=>B(`height`,{height:Math.ceil(e.getBoundingClientRect().height)}));return t.observe(e),()=>t.disconnect()}if(z===`modal`||z===`popout`){let e=e=>{e.key===`Escape`&&!document.querySelector(`dialog[open]`)&&B(`close`)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)}},[e])}var V=e(n(),1),H=`wizards.runner.translate`,U=new Set;function ue(){try{return localStorage.getItem(H)===`on`}catch{return!1}}function de(e){try{localStorage.setItem(H,e?`on`:`off`)}catch{}for(let e of U)e()}function fe(){return(0,R.useSyncExternalStore)(e=>(U.add(e),()=>U.delete(e)),ue)}function pe(e){let t=fe(),[n]=(0,R.useState)(()=>S()),r=e?.lang??`en`,o=e?.translatable&&n&&n!==r?n:null,s=o&&t?o:r,c=e?.token,l=i({queryKey:[`public-translation`,c,s],enabled:!!(c&&s!==r),queryFn:()=>g.post(`/api/public/wizards/${c}/translation`,{lang:s}),staleTime:1/0,retry:!1}),u=i({queryKey:[`public-texts`,c,s],enabled:!(!c||a(s)),queryFn:()=>g.get(`/api/public/wizards/${c}/texts/${s}`),staleTime:1/0,retry:!1}),d=!a(s),f=s===r||l.data&&(!d||u.data),p=s!==r&&(l.isError||d&&u.isError),m=f&&!p?s:r,_=(0,R.useMemo)(()=>!a(m)&&u.data?.lang===m?{lang:u.data.lang,runner:u.data.runner,notes:u.data.notes}:null,[m,u.data]);if((0,R.useEffect)(()=>{e&&h(m,_)},[e,m,_]),(0,R.useEffect)(()=>()=>h(null),[]),!e)return null;let v=m!==r&&l.data?l.data:null;return{own:r,other:o,shown:m,wizard:v??e,translating:s!==r&&!f&&!p,failed:!!p,translated:!!v,machine:v?.translation?.machine??!1,pick:e=>de(e!==r)}}function W({page:e,tone:t=`ground`}){if(!e?.other)return null;let n=e.translating?e.other:e.shown;return(0,V.jsx)(j,{langs:[e.own,e.other],value:n,onPick:e.pick,tone:t})}function G({page:e,small:t}){if(!e)return null;let n=t?`truncate text-[0.75rem]`:`text-[0.8125rem]`;return e.failed?(0,V.jsx)(`p`,{className:w(`text-ink-3`,n),children:y(`translation.failed`)}):e.translated?(0,V.jsxs)(`p`,{className:w(`text-ink-3`,n),children:[e.machine?(0,V.jsxs)(V.Fragment,{children:[y(`translation.machine`),` · `]}):null,(0,V.jsx)(`button`,{type:`button`,className:`underline-offset-4 hover:text-ink hover:underline coarse:min-h-11`,onClick:()=>e.pick(e.own),children:y(`translation.showOriginal`)})]}):null}var me=`ui-sans-serif, system-ui, sans-serif`,he=`ui-serif, Georgia, serif`;function K(e){return`"${e.replace(/"/g,``)}", ${/serif/i.test(e)&&!/sans/i.test(e)?he:me}`}function q(e){let t=JSON.stringify(e??{});(0,R.useEffect)(()=>{let e=JSON.parse(t),n=document.documentElement,r=[[`--raw-primary`,e.accent],[`--raw-second`,e.second],[`--raw-background`,e.background],[`--brand-stage`,e.background?e.dark?e.background:`oklch(from ${e.background} 0.3 clamp(0.02, calc(c * 3), 0.1) h)`:null],[`--f-display`,e.display?K(e.display):null],[`--f-ui`,e.body?K(e.body):null]].filter(e=>!!e[1]);for(let[e,t]of r)n.style.setProperty(e,t);let i=n.classList.contains(`dark`);return e.dark&&n.classList.add(`dark`),()=>{for(let[e]of r)n.style.removeProperty(e);e.dark&&!i&&n.classList.remove(`dark`)}},[t])}function ge(e,t){let n=(0,R.useRef)(null),r=t&&!t.translating?t.translated?t.shown:null:void 0;(0,R.useEffect)(()=>{if(!e||r===void 0)return;let t=`${e}:${r}`;n.current!==t&&(n.current=t,g.post(`/api/runs/${e}/lang`,{lang:r}).catch(()=>void 0))},[e,r])}function _e(e,t){(0,R.useEffect)(()=>{if(!e||!t)return;let n=C(`/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 J=/iPhone|iPad|iPod/.test(navigator.userAgent)||navigator.platform===`MacIntel`&&navigator.maxTouchPoints>1,Y=J||/Android/.test(navigator.userAgent);function ve(){let[e,t]=(0,R.useState)(()=>window.wizardInstall??null),[n,r]=(0,R.useState)(!1);if((0,R.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||Y&&!e&&!J)return null;let i=/Mac/.test(navigator.platform),a=y(Y?`install.ios`:i?`install.bookmark.mac`:`install.bookmark.pc`);return(0,V.jsxs)(`div`,{className:`mt-6 flex flex-col items-center gap-2 text-[0.8125rem] text-ink-3`,children:[(0,V.jsxs)(`button`,{type:`button`,onClick:()=>{Y&&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:[Y?(0,V.jsx)(ae,{className:`size-4`}):(0,V.jsx)(re,{className:`size-4`}),y(Y?`install.add`:`install.bookmark`)]}),n?(0,V.jsx)(`p`,{className:`max-w-xs leading-relaxed`,children:a}):null]})}function X({brand:e,toggle:t=!0,start:n}){return(0,V.jsx)(`header`,{className:`safe-top`,children:(0,V.jsxs)(`div`,{className:`relative flex h-14 items-center justify-center px-5`,children:[n?(0,V.jsx)(`div`,{className:`absolute left-3`,children:n}):null,e.logoUrl?(0,V.jsx)(`img`,{src:C(e.logoUrl),alt:e.name,className:`h-7 max-w-[160px] object-contain`}):e.name?(0,V.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,V.jsx)(`div`,{className:`absolute right-3`,children:(0,V.jsx)(N,{})}):null]})})}function Z({siteKey:e,onToken:t}){let n=(0,R.useRef)(null);return(0,R.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,V.jsx)(`div`,{ref:n,className:`mt-4 flex justify-center`})}function ye({token:e}){return!/iPhone|iPad|iPod|Android/.test(navigator.userAgent)||d||z?null:(0,V.jsxs)(`a`,{href:m(`${window.location.origin}${s}/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,V.jsx)(ie,{className:`size-4`}),` `,y(`install.app`)]})}var be=e=>`wz.run.${e}`,xe=d&&new URLSearchParams(window.location.search).get(`start`)===`1`,Q=z===`inline`?`min-h-80`:`min-h-dvh`;function $(e,t,n){let r=f(),[i,a]=(0,R.useState)(!1),[o,s]=(0,R.useState)(null),[c,l]=(0,R.useState)(null),u=(()=>{try{return localStorage.getItem(be(e.token))}catch{return null}})();return{busy:i,error:o,captcha:c,setCaptcha:l,start:async()=>{a(!0),s(null);try{let{runId:i}=await g.post(`/api/public/wizards/${e.token}/runs`,{turnstileToken:c??void 0,embedded:z!==null,origin:se??void 0,lang:n??void 0});try{localStorage.setItem(be(e.token),i)}catch{}r(`${t}/${i}`,{replace:xe})}catch(e){s(e.message),a(!1)}},resume:u?()=>r(`${t}/${u}`):null}}function Se({wizard:e,page:t}){let{busy:n,error:r,captcha:i,setCaptcha:a,start:s,resume:c}=$(e,`/w/${e.token}`,t?.translated?t.shown:null),u=xe&&e.available&&!e.turnstileSiteKey,f=(0,R.useRef)(!1);return(0,R.useEffect)(()=>{u&&!f.current&&(f.current=!0,s())},[u]),u&&!r?(0,V.jsx)(`div`,{className:`flex min-h-[60dvh] items-center justify-center text-ink-4`,children:(0,V.jsx)(l,{})}):(0,V.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:[(0,V.jsx)(M,{kind:e.avatar,size:190,fluffy:!0}),(0,V.jsx)(`h1`,{className:`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,V.jsx)(`p`,{className:`mt-3 text-[1rem] text-ink-2 leading-relaxed`,children:e.description}):null,(0,V.jsx)(`div`,{className:`mt-3`,children:(0,V.jsx)(G,{page:t})}),e.available?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(b,{size:`lg`,className:`mt-10 min-w-48`,busy:n,disabled:!!e.turnstileSiteKey&&!i,onClick:s,children:[y(`run.start`),` `,(0,V.jsx)(o,{className:`size-4`})]}),e.turnstileSiteKey?(0,V.jsx)(Z,{siteKey:e.turnstileSiteKey,onToken:a}):null,c?(0,V.jsx)(`button`,{type:`button`,onClick:c,className:`mt-4 text-[0.875rem] text-ink-3 underline-offset-4 hover:text-ink hover:underline coarse:min-h-11`,children:y(`run.resume`)}):null,(0,V.jsx)(Ce,{wizard:e,current:`steps`}),z||d?null:(0,V.jsx)(ve,{}),(0,V.jsx)(ye,{token:e.token})]}):(0,V.jsx)(`p`,{className:`mt-10 rounded-xl bg-paper-2 px-5 py-4 text-[0.9375rem] text-ink-2`,children:e.unavailableReason??y(`run.unavailable`)}),r?(0,V.jsx)(`p`,{className:`mt-4 text-[0.875rem] text-rose`,children:r}):null]})}function Ce({wizard:e,current:t}){let n=e.runners.filter(e=>e.id!==t&&e.kind===`page`&&e.url);return n.length?(0,V.jsx)(`p`,{className:`mt-4 flex flex-wrap justify-center gap-x-4 text-[0.875rem] text-ink-3`,children:n.map(e=>(0,V.jsx)(`a`,{href:e.url??void 0,className:`underline-offset-4 hover:text-ink hover:underline coarse:min-h-11`,children:y(`run.orAs`,{label:e.label})},e.id))}):null}function we({wizard:e,page:t}){let n=A();return(0,V.jsx)(`header`,{className:`safe-top shrink-0 border-border-soft border-b`,children:(0,V.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,V.jsx)(`span`,{className:w(n?.speaking&&`animate-breathe`),children:(0,V.jsx)(M,{kind:e.avatar,size:38})}),(0,V.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,V.jsx)(`div`,{className:`truncate font-display font-semibold text-[1rem] leading-tight tracking-tight`,children:e.title}),e.brand.name?(0,V.jsx)(`div`,{className:`truncate text-[0.75rem] text-ink-3`,children:e.brand.name}):null,(0,V.jsx)(G,{page:t,small:!0})]}),e.brand.logoUrl&&z!==`popout`?(0,V.jsx)(`img`,{src:C(e.brand.logoUrl),alt:e.brand.name,className:`h-6 max-w-[120px] object-contain max-sm:hidden`}):null,(0,V.jsx)(W,{page:t,tone:`surface`}),z?null:(0,V.jsx)(N,{}),z===`popout`?(0,V.jsx)(u,{label:y(`common.close`),onClick:ce,children:(0,V.jsx)(c,{className:`size-5`})}):null]})})}function Te({door:e,wizard:t,page:n,header:r,footer:i}){let{busy:a,error:s,captcha:c,setCaptcha:l,start:u,resume:d}=$(t,`/w/${t.token}/${e}`,n?.translated?n.shown:null),f=[{key:`hello`,who:`bot`,node:t.description||t.title}];return e!==`chat`&&f.push({key:e,who:`bot`,node:y(e===`video`?`video.hint`:`talk.joinHint`)}),t.available||f.push({key:`unavailable`,who:`bot`,node:t.unavailableReason??y(`run.unavailable`)}),s&&f.push({key:`error`,who:`bot`,node:s,tone:`error`}),t.available&&f.push(O(`start`,(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(E,{primary:!0,busy:a,disabled:!!t.turnstileSiteKey&&!c,onClick:()=>void u(),children:[y(`run.start`),` `,(0,V.jsx)(o,{className:`size-4`})]}),d?(0,V.jsx)(E,{onClick:d,children:y(`run.resume`)}):null,t.turnstileSiteKey?(0,V.jsx)(Z,{siteKey:t.turnstileSiteKey,onToken:l}):null]}))),(0,V.jsxs)(D,{header:r,footer:i,children:[(0,V.jsx)(T,{avatar:t.avatar,lines:f}),(0,V.jsx)(k,{})]})}function Ee({className:e}){return(0,V.jsx)(`footer`,{className:w(`text-center text-ink-4`,e),children:(0,V.jsx)(`a`,{href:`${s}/`,target:z?`_blank`:void 0,rel:`noreferrer`,className:`inline-block hover:text-ink-2`,children:y(`run.madeWith`).replace(`engenty wizards`,P.name)})})}function De({chat:e=!1,steps:t=!1,talk:n=!1,video:a=!1}){let{token:o,runId:c}=_(),u=f(),m=i({queryKey:[`public`,o],queryFn:()=>g.get(`/api/public/wizards/${o}`),retry:(e,t)=>v(t)&&e<3}),h=m.data?.runners??[],x=!m.data||h.some(e=>e.id===`talk`),S=!m.data||h.some(e=>e.id===`video`),C=!m.data||h.some(e=>e.id===`chat`)||n&&x||a&&S,T=h[0]?.id,E=e||z===`popout`||!t&&!c&&C&&(T===`chat`||T===`talk`||T===`video`),D=a&&S||!t&&!e&&!n&&T===`video`,O=!D&&(n&&x||!t&&!e&&T===`talk`),k=D?`video`:O?`talk`:`chat`,A=pe(m.data);ge(c,A),q(m.data?.brand.theme),te(m.data?.avatar),_e(o,m.data?.title),le(E);let j=A?.wizard.title??m.data?.title;if((0,R.useEffect)(()=>{j&&(document.title=j)},[j]),(0,R.useEffect)(()=>{o&&c&&r(`run`,{token:o,runId:c})},[o,c]),m.isLoading)return(0,V.jsx)(`div`,{className:w(`flex items-center justify-center text-ink-4`,Q),children:(0,V.jsx)(l,{})});if(e&&m.data&&!C||n&&m.data&&!x||a&&m.data&&!S)return(0,V.jsx)(p,{to:`/w/${o}`,replace:!0});if(!m.data){let e=v(m.error);return(0,V.jsxs)(`div`,{className:w(`flex flex-col items-center justify-center gap-4 px-6 text-center`,Q),children:[(0,V.jsx)(M,{kind:`pebble`,size:80}),(0,V.jsx)(`p`,{className:`max-w-xs text-ink-3`,children:y(e?`common.offline`:`run.notFound`)}),e?(0,V.jsx)(b,{variant:`secondary`,onClick:()=>void m.refetch(),children:y(`common.retry`)}):null]})}let N=A?.wizard??m.data,F=A?.translating?(0,V.jsxs)(`div`,{className:w(`flex flex-col items-center justify-center gap-3 text-ink-3`,Q),children:[(0,V.jsx)(l,{}),(0,V.jsx)(`p`,{className:`text-[0.875rem]`,children:y(`translation.working`)})]}):null;if(E){let e=(0,V.jsx)(we,{wizard:N,page:A}),t=d?(0,V.jsx)(`div`,{className:`safe-bottom`}):(0,V.jsx)(Ee,{className:`pb-[max(0.375rem,env(safe-area-inset-bottom))] text-[0.6875rem]`});return(0,V.jsx)(`div`,{className:`flex h-dvh flex-col`,children:F??(c?(0,V.jsx)(ee,{runId:c,talk:O,call:D?`video`:O?`audio`:!1,onRestart:()=>u(`/w/${o}/${k}`),header:D||O?void 0:e,footer:t}):(0,V.jsx)(Te,{wizard:N,page:A,header:e,footer:t,door:k}))})}return(0,V.jsxs)(`div`,{className:w(`flex flex-col`,Q),children:[z===`inline`||d?null:(0,V.jsx)(X,{brand:m.data.brand,toggle:!z,start:(0,V.jsx)(W,{page:A})}),z===`inline`||d?(0,V.jsx)(`div`,{className:`flex justify-end px-3 pt-2`,children:(0,V.jsx)(W,{page:A,tone:`surface`})}):null,c&&(A?.translated||A?.failed)?(0,V.jsx)(`div`,{className:`flex justify-center px-5`,children:(0,V.jsx)(G,{page:A})}):null,(0,V.jsx)(`div`,{className:`flex-1`,children:F??(c?(0,V.jsx)(ne,{runId:c,onRestart:()=>u(`/w/${o}`)}):(0,V.jsx)(Se,{wizard:N,page:A}))}),d?(0,V.jsx)(`div`,{className:`safe-bottom`}):(0,V.jsx)(`footer`,{className:`safe-bottom pt-6 text-center text-[0.75rem] text-ink-4`,children:(0,V.jsx)(`a`,{href:`${s}/`,target:z?`_blank`:void 0,rel:`noreferrer`,className:`inline-block py-3.5 hover:text-ink-2`,children:y(`run.madeWith`).replace(`engenty wizards`,P.name)})})]})}export{X as BrandHeader,De as PublicRunner,q as t};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{t}from"./jsx-runtime-BNakU3Ej.js";import{Nr as n,an as r}from"./ui-DMmT-cSO.js";import{Jt as i}from"./index-4jH2mkp7.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};
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{t}from"./jsx-runtime-BNakU3Ej.js";import{en as n,kr as r}from"./ui-Cdv3QUOd.js";import{an as i}from"./index-CQKA-z2z.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=r(a),s=e(t(),1);function c(e){return n(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};
@@ -0,0 +1,4 @@
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{Br as r,Bt as i,F as a,Ft as o,Gn as s,Hn as c,Ht as l,It as u,Kt as d,Lt as f,Mt as p,N as m,Nt as h,P as g,Pt as _,Qn as v,R as y,Rt as b,Sr as x,Vt as S,Wt as C,Yt as w,_ as T,di as E,en as D,er as O,fr as k,ir as A,jt as j,kr as M,ot as N,p as ee,qt as P,sr as te,v as F,wt as ne,xr as re,yr as ie,zn as ae}from"./ui-Cdv3QUOd.js";import{t as oe}from"./upload-DCMZI6pp.js";import{Bt as se,Vt as ce,ut as le,yn as I}from"./index-CQKA-z2z.js";var ue={name:`calendar`,size:24,node:[[`path`,{d:`M8 2v3`,key:`1ioesn`}],[`path`,{d:`M16 2v3`,key:`otl347`}],[`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,key:`h1oib`}],[`path`,{d:`M3 9h18`,key:`1pudct`}]]};ue.node;var L=M(ue),de={name:`files`,size:24,node:[[`path`,{d:`M15 2h-4a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V8`,key:`14sh0y`}],[`path`,{d:`M16.706 2.706A2.4 2.4 0 0 0 15 2v5a1 1 0 0 0 1 1h5a2.4 2.4 0 0 0-.706-1.706z`,key:`1970lx`}],[`path`,{d:`M5 7a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 1.732-1`,key:`l4dndm`}]]};de.node;var fe=M(de),R={name:`hash`,size:24,node:[[`line`,{x1:`4`,x2:`20`,y1:`9`,y2:`9`,key:`4lhtct`}],[`line`,{x1:`4`,x2:`20`,y1:`15`,y2:`15`,key:`vyu0kd`}],[`line`,{x1:`10`,x2:`8`,y1:`3`,y2:`21`,key:`1ggp8o`}],[`line`,{x1:`16`,x2:`14`,y1:`3`,y2:`21`,key:`weycgp`}]]};R.node;var z=M(R),B={name:`list-ordered`,size:24,node:[[`path`,{d:`M11 5h10`,key:`1cz7ny`}],[`path`,{d:`M11 12h10`,key:`1438ji`}],[`path`,{d:`M11 19h10`,key:`11t30w`}],[`path`,{d:`M4 4h1v5`,key:`10yrso`}],[`path`,{d:`M4 9h2`,key:`r1h2o0`}],[`path`,{d:`M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02`,key:`xtkcd5`}]]};B.node;var pe=M(B),V={name:`messages-square`,size:24,node:[[`path`,{d:`M16 10a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 14.286V4a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2z`,key:`1n2ejm`}],[`path`,{d:`M20 9a2 2 0 0 1 2 2v10.286a.71.71 0 0 1-1.212.502l-2.202-2.202A2 2 0 0 0 17.172 19H10a2 2 0 0 1-2-2v-1`,key:`1qfcsi`}]]};V.node;var me=M(V),he={name:`minimize-2`,size:24,node:[[`path`,{d:`m14 10 7-7`,key:`oa77jy`}],[`path`,{d:`M20 10h-6V4`,key:`mjg0md`}],[`path`,{d:`m3 21 7-7`,key:`tjx5ai`}],[`path`,{d:`M4 14h6v6`,key:`rmj7iw`}]]};he.node;var ge=M(he),_e={name:`tags`,size:24,node:[[`path`,{d:`M13.172 2a2 2 0 0 1 1.414.586l6.71 6.71a2.4 2.4 0 0 1 0 3.408l-4.592 4.592a2.4 2.4 0 0 1-3.408 0l-6.71-6.71A2 2 0 0 1 6 9.172V3a1 1 0 0 1 1-1z`,key:`16rjxf`}],[`path`,{d:`M2 7v6.172a2 2 0 0 0 .586 1.414l6.71 6.71a2.4 2.4 0 0 0 3.191.193`,key:`178nd4`}],[`circle`,{cx:`10.5`,cy:`6.5`,r:`.5`,fill:`currentColor`,key:`12ikhr`}]]};_e.node;var ve=M(_e),ye={name:`toggle-left`,size:24,node:[[`circle`,{cx:`9`,cy:`12`,r:`3`,key:`u3jwor`}],[`rect`,{width:`20`,height:`14`,x:`2`,y:`5`,rx:`7`,key:`g7kal2`}]]};ye.node;var be=M(ye),H=e(t(),1),U=e(n(),1),W={choice:ve,date:L,number:z,text:se,boolean:be},G=e=>[`knowledge`,e];function xe(e){return e===1?D(`know.item`):D(`know.items`,{n:e})}function K(e,t){if(e.type===`boolean`||typeof t==`boolean`)return D(t?`know.yes`:`know.no`);if(e.type===`date`&&typeof t==`string`){let[e,n]=t.split(` `),r=new Date(`${e}T00:00:00`),i=Number.isNaN(r.getTime())?t:r.toLocaleDateString(w,{day:`2-digit`,month:`2-digit`,year:`numeric`});return n?`${i} ${n}`:i}return e.type===`number`&&typeof t==`number`?`${t.toLocaleString(w)}${e.unit?` ${e.unit}`:``}`:String(t)}function Se(e,t){return e.flatMap(e=>{let n=t.find(t=>t.categoryId===e.id);return n?e.type===`boolean`?n.values[0]===!0?[e.name]:[]:[n.values.map(t=>K(e,t)).join(`, `)]:[]}).join(` · `)}function Ce({trigger:e,open:t,onOpen:n,children:r}){let i=(0,H.useRef)(null);return(0,H.useEffect)(()=>{if(!t)return;let e=e=>{i.current?.contains(e.target)||n(!1)},r=e=>e.key===`Escape`&&n(!1);return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,r),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,r)}},[t,n]),(0,U.jsxs)(`div`,{ref:i,className:`relative inline-flex`,children:[e,t?(0,U.jsx)(`div`,{className:`absolute top-full left-0 z-30 mt-1.5 w-72 max-w-[calc(100vw-32px)] rounded-xl bg-card p-3 shadow-overlay ring-1 ring-border-soft`,children:r}):null]})}function we({category:e,current:t,onSave:n}){let[r,a]=(0,H.useState)(t[0]===void 0?``:String(t[0]));if(e.type===`choice`){let o=t.map(String);return(0,U.jsxs)(`div`,{className:`flex flex-col gap-2.5`,children:[e.values.length?(0,U.jsx)(i,{multi:!0,value:o,options:e.values.map(e=>e.value),onChange:t=>n(e.multiple?t:t.filter(e=>!o.includes(e)).slice(0,1))}):null,(0,U.jsxs)(`form`,{className:`flex gap-2`,onSubmit:t=>{t.preventDefault(),r.trim()&&n(e.multiple?[...o,r.trim()]:[r.trim()])},children:[(0,U.jsx)(f,{"data-autofocus":!0,value:o.includes(r)?``:r,placeholder:D(`know.addValue`),onChange:e=>a(e.target.value),className:`h-9`}),(0,U.jsx)(u,{label:D(`know.addValue`),type:`submit`,children:(0,U.jsx)(O,{className:`size-4`})})]})]})}return e.type===`boolean`?(0,U.jsx)(i,{value:t[0]===!0?D(`know.yes`):t[0]===!1?D(`know.no`):``,options:[D(`know.yes`),D(`know.no`)],onChange:e=>n([e===D(`know.yes`)])}):(0,U.jsxs)(`form`,{className:`flex gap-2`,onSubmit:t=>{t.preventDefault(),n(r.trim()?[e.type===`number`?Number(r.replace(`,`,`.`)):r.trim()]:[])},children:[(0,U.jsx)(f,{"data-autofocus":!0,type:e.type===`date`?`date`:e.type===`number`?`number`:`text`,step:`any`,value:e.type===`date`?r.slice(0,10):r,onChange:e=>a(e.target.value),className:`h-9`}),(0,U.jsx)(j,{type:`submit`,size:`sm`,children:`OK`})]})}function Te({projectId:e,itemKey:t,has:n,categories:r,readOnly:i}){let a=E(),[o,s]=(0,H.useState)(null),[l,d]=(0,H.useState)(n);(0,H.useEffect)(()=>d(n),[n]);let f=I({mutationFn:({categoryId:n,next:r})=>y.put(`/api/studio/projects/${e}/items/${t}/categories/${n}`,{values:r}),onSuccess:()=>a.invalidateQueries({queryKey:G(e)})}),p=r.filter(e=>!(e.proposed||e.tableId)),m=(e,t)=>{d(n=>[...n.filter(t=>t.categoryId!==e.id),...t.length?[{categoryId:e.id,values:t,by:`person`}]:[]]),f.mutate({categoryId:e.id,next:t}),s(null)},h=p.filter(e=>l.some(t=>t.categoryId===e.id)),g=p.filter(e=>!l.some(t=>t.categoryId===e.id));return p.length?(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[h.map(e=>{let t=l.find(t=>t.categoryId===e.id),n=W[e.type],r=(0,U.jsxs)(`button`,{type:`button`,disabled:i,title:`${e.name} · ${D(`know.by.${t.by}`)}`,onClick:()=>s(o===e.id?null:e.id),className:`inline-flex h-7 items-center gap-1.5 rounded-full bg-paper-2 px-2.5 text-[0.75rem] text-ink-2 transition hover:bg-paper-3 hover:text-ink disabled:pointer-events-none`,children:[(0,U.jsx)(n,{className:`size-3.5 text-ink-3`}),(0,U.jsx)(`span`,{className:`text-ink-3`,children:e.name}),(0,U.jsx)(`span`,{className:`font-medium`,children:t.values.map(t=>K(e,t)).join(`, `)})]},e.id);return i?(0,U.jsx)(`span`,{children:r},e.id):(0,U.jsxs)(Ce,{trigger:r,open:o===e.id,onOpen:t=>s(t?e.id:null),children:[(0,U.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,U.jsx)(`span`,{className:`font-medium text-[0.8125rem]`,children:e.name}),(0,U.jsx)(u,{label:D(`know.remove`),onClick:()=>m(e,[]),className:`size-7`,children:(0,U.jsx)(c,{className:`size-3.5`})})]}),(0,U.jsx)(we,{category:e,current:t.values,onSave:t=>m(e,t)})]},e.id)}),i||!g.length?null:(0,U.jsx)(Ce,{open:o===`+`,onOpen:e=>s(e?`+`:null),trigger:(0,U.jsxs)(`button`,{type:`button`,onClick:()=>s(o===`+`?null:`+`),className:`inline-flex h-7 items-center gap-1 rounded-full px-2 text-[0.75rem] text-ink-3 ring-1 ring-border-soft transition hover:text-ink hover:ring-border`,children:[(0,U.jsx)(O,{className:`size-3.5`}),` `,D(`know.category`)]}),children:(0,U.jsx)(Ee,{categories:g,onSave:m})})]}):null}function Ee({categories:e,onSave:t}){let[n,r]=(0,H.useState)(e[0]?.id??``),i=e.find(e=>e.id===n);return(0,U.jsxs)(`div`,{className:`flex flex-col gap-2.5`,children:[(0,U.jsx)(S,{value:n,onChange:r,options:e.map(e=>({value:e.id,label:e.name}))}),i?(0,U.jsx)(we,{category:i,current:[],onSave:e=>t(i,e)},i.id):null]})}function De({projectId:e,open:t,onClose:n,onMade:r}){let i=E(),[a,o]=(0,H.useState)(``),[s,c]=(0,H.useState)(`choice`),[l,u]=(0,H.useState)(``),[p,m]=(0,H.useState)(!1),[h,g]=(0,H.useState)(!1),[v,x]=(0,H.useState)(``),[w,T]=(0,H.useState)(``),O=I({mutationFn:()=>y.post(`/api/studio/projects/${e}/categories`,{name:a.trim(),type:s,unit:s===`number`&&l.trim()||null,multiple:s===`choice`&&p,ordered:s===`choice`&&h,hint:w.trim()||null,values:s===`choice`?v.split(`
2
+ `).map(e=>e.trim()).filter(Boolean):void 0}),onSuccess:async({id:t})=>{await i.invalidateQueries({queryKey:G(e)}),o(``),x(``),T(``),r(t)}});return(0,U.jsx)(_,{open:t,onClose:n,title:D(`know.newCategory`),children:(0,U.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),a.trim()&&O.mutate()},children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(b,{children:D(`know.name`)}),(0,U.jsx)(f,{"data-autofocus":!0,value:a,maxLength:80,onChange:e=>o(e.target.value)})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(b,{children:D(`know.type`)}),(0,U.jsx)(S,{value:s,onChange:e=>c(e),options:[`choice`,`date`,`number`,`text`,`boolean`].map(e=>({value:e,label:D(`know.type.${e}`)}))})]}),s===`number`?(0,U.jsxs)(`div`,{children:[(0,U.jsx)(b,{hint:D(`know.unitHint`),children:D(`know.unit`)}),(0,U.jsx)(f,{value:l,maxLength:20,onChange:e=>u(e.target.value)})]}):null,s===`choice`?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(b,{hint:D(`know.valuesHint`),children:D(`know.values`)}),(0,U.jsx)(d,{minRows:3,value:v,onChange:e=>x(e.target.value)})]}),(0,U.jsxs)(`label`,{className:`flex items-center justify-between gap-3 text-[0.875rem]`,children:[D(`know.multiple`),(0,U.jsx)(C,{checked:p,onChange:m})]}),(0,U.jsxs)(`label`,{className:`flex items-center justify-between gap-3 text-[0.875rem]`,children:[D(`know.ordered`),(0,U.jsx)(C,{checked:h,onChange:g})]})]}):null,(0,U.jsxs)(`div`,{children:[(0,U.jsx)(b,{hint:D(`know.hintFieldHint`),children:D(`know.hintField`)}),(0,U.jsx)(f,{value:w,maxLength:120,onChange:e=>T(e.target.value)})]}),O.error?(0,U.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:O.error.message}):null,(0,U.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,U.jsx)(j,{variant:`ghost`,onClick:n,children:D(`common.cancel`)}),(0,U.jsx)(j,{type:`submit`,busy:O.isPending,disabled:!a.trim(),children:D(`know.create`)})]})]})})}function Oe({projectId:e,category:t,readOnly:n,onOpen:r,onGone:i}){let a=E(),c=()=>a.invalidateQueries({queryKey:G(e)}),[l,d]=(0,H.useState)(``),m=I({mutationFn:e=>e(),onSuccess:c}),g=W[t.type],_=new Map(t.values.map(e=>[e.id,e]));return(0,U.jsxs)(F,{title:t.name,hint:[D(`know.type.${t.type}`),t.unit,t.hint].filter(Boolean).join(` · `),plain:!0,action:n?null:(0,U.jsx)(u,{label:D(`know.deleteCategory`),className:`hover:text-rose`,onClick:()=>confirm(D(`know.confirmCategory`,{name:t.name}))&&m.mutate(async()=>{await y.del(`/api/studio/categories/${t.id}`),i()}),children:(0,U.jsx)(s,{className:`size-4`})}),children:[t.proposed&&!n?(0,U.jsxs)(p,{className:`flex flex-wrap items-center gap-3 p-4`,children:[(0,U.jsx)(h,{tone:`ember`,children:D(`know.proposed`)}),(0,U.jsx)(`span`,{className:`flex-1 text-[0.875rem] text-ink-2`,children:D(`know.proposedHint`)}),(0,U.jsx)(j,{size:`sm`,onClick:()=>m.mutate(()=>y.patch(`/api/studio/categories/${t.id}`,{proposed:!1})),children:D(`know.accept`)})]}):null,t.alike.map(([e,t])=>{let r=_.get(e),i=_.get(t);if(!(r&&i))return null;let[a,o]=r.count<i.count?[r,i]:[i,r];return(0,U.jsxs)(p,{className:`flex flex-wrap items-center gap-3 p-4`,children:[(0,U.jsx)(`span`,{className:`flex-1 text-[0.875rem] text-ink-2`,children:D(`know.alike`,{a:a.value,b:o.value})}),n?null:(0,U.jsx)(j,{size:`sm`,variant:`secondary`,busy:m.isPending,onClick:()=>m.mutate(()=>y.post(`/api/studio/values/${a.id}/merge`,{into:o.id})),children:D(`know.merge`)})]},`${e}:${t}`)}),(0,U.jsxs)(p,{className:`flex flex-col p-1.5`,children:[t.type===`choice`?t.values.length?t.values.map(e=>(0,U.jsxs)(`button`,{type:`button`,onClick:()=>r(`v:${e.id}`),className:`flex items-center gap-3 rounded-lg px-3 py-2.5 text-left transition hover:bg-accent`,children:[(0,U.jsx)(g,{className:`size-4 shrink-0 text-ink-3`}),(0,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[0.875rem]`,children:e.value}),e.summary?(0,U.jsx)(h,{children:D(`know.summary`)}):null,(0,U.jsx)(`span`,{className:`shrink-0 text-[0.75rem] text-ink-3 tabular-nums`,children:xe(e.count)})]},e.id)):(0,U.jsx)(o,{children:D(`know.empty`)}):(0,U.jsxs)(`div`,{className:`flex items-center gap-3 px-3 py-2.5 text-[0.875rem]`,children:[(0,U.jsx)(g,{className:`size-4 shrink-0 text-ink-3`}),(0,U.jsx)(`span`,{className:`flex-1 text-ink-2`,children:t.range?D(`know.range`,{min:K(t,t.range.min),max:K(t,t.range.max)}):D(`know.unset`)}),(0,U.jsx)(`span`,{className:`text-[0.75rem] text-ink-3 tabular-nums`,children:xe(t.count)})]}),t.type===`choice`&&!n?(0,U.jsxs)(`form`,{className:`flex gap-2 border-border-soft border-t p-2`,onSubmit:e=>{e.preventDefault();let n=l.trim();n&&(d(``),m.mutate(()=>y.post(`/api/studio/categories/${t.id}/values`,{value:n})))},children:[(0,U.jsx)(f,{value:l,placeholder:D(`know.addValue`),onChange:e=>d(e.target.value),className:`h-9`}),(0,U.jsx)(u,{label:D(`know.addValue`),type:`submit`,children:(0,U.jsx)(O,{className:`size-4`})})]}):null]}),m.error?(0,U.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:m.error.message}):null]})}function ke(e){return r({queryKey:[`knowledge-value`,e],queryFn:()=>y.get(`/api/studio/values/${e}`),enabled:!!e})}function Ae({value:e,readOnly:t,children:n}){let r=E(),i=I({mutationFn:()=>y.post(`/api/studio/values/${e.id}/summary`),onSuccess:()=>r.invalidateQueries({queryKey:[`knowledge-value`,e.id]})});return(0,U.jsxs)(`div`,{className:`flex flex-col gap-9`,children:[(0,U.jsx)(F,{title:D(`know.summary`),hint:D(`know.summaryHint`),plain:!0,action:t?null:(0,U.jsxs)(j,{variant:`secondary`,size:`sm`,busy:i.isPending,onClick:()=>i.mutate(),children:[e.summary?(0,U.jsx)(v,{className:`size-4`}):null,e.summary?D(`know.summaryAgain`):D(`know.summaryWrite`)]}),children:(0,U.jsxs)(p,{className:`p-4 sm:p-5`,children:[i.isPending?(0,U.jsx)(`div`,{className:`flex h-24 items-center justify-center text-ink-3`,children:(0,U.jsx)(l,{})}):e.summary?(0,U.jsx)(N,{text:e.summary,className:`text-[0.875rem]`}):(0,U.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:D(`know.summaryEmpty`)}),i.error?(0,U.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:i.error.message}):null]})}),(0,U.jsx)(F,{title:D(`know.toc`),plain:!0,children:n})]})}function je(e){return r({queryKey:[`knowledge`,e],queryFn:()=>y.get(`/api/studio/projects/${e}/knowledge`),enabled:!!e,refetchInterval:e=>e.state.data?.items.some(e=>e.status===`pending`)?2e3:!1})}function Me(e){return e.kind===`table`?e.format===`faq`?me:ce:e.kind===`file`?A:e.children?fe:k}function q({item:e,categories:t,onOpen:n}){let r=Me(e),i=[Se(t,e.categories),e.children?e.children===1?D(`know.oneSub`):D(`know.sub`,{n:e.children}):``,e.rows===null?``:e.rows===1?D(`know.row`):D(`know.rows`,{n:e.rows}),e.originLabel??``].filter(Boolean).join(` · `);return(0,U.jsxs)(`button`,{type:`button`,onClick:()=>n(e.key),disabled:e.status===`pending`,className:`flex items-start gap-3 rounded-lg px-3 py-2.5 text-left transition hover:bg-accent disabled:pointer-events-none`,children:[(0,U.jsx)(r,{className:`mt-0.5 size-4 shrink-0 text-ink-3`}),(0,U.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,U.jsx)(`span`,{className:`block truncate text-[0.875rem]`,children:e.title}),i?(0,U.jsx)(`span`,{className:`block truncate text-[0.75rem] text-ink-3`,children:i}):null]}),e.status===`pending`?(0,U.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1.5 text-[0.75rem] text-ink-3`,children:[(0,U.jsx)(l,{className:`size-3`}),` `,D(`know.reading`)]}):e.review?(0,U.jsx)(h,{tone:`warn`,title:e.review,children:D(`know.review`)}):null]})}function J({projectId:e,itemKey:t,has:n,originLabel:r,kept:i,review:a,file:o,readOnly:s,onReviewed:c}){let l=je(e),u=[r?D(i?`know.kept`:`know.from`,{label:r}):``].filter(Boolean);return(0,U.jsxs)(`div`,{className:`flex flex-col gap-2 px-1`,children:[l.data?(0,U.jsx)(Te,{projectId:e,itemKey:t,has:n,categories:l.data.categories,readOnly:s}):null,u.length||o||a?(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 text-[0.8125rem] text-ink-3`,children:[u.map(e=>(0,U.jsx)(`span`,{children:e},e)),o?(0,U.jsxs)(`a`,{href:m(e,o.id),target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 underline-offset-2 hover:text-ink hover:underline`,children:[(0,U.jsx)(A,{className:`size-3.5`}),` `,D(`know.original`),`: `,o.name]}):null,a?(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,U.jsx)(h,{tone:`warn`,children:D(`know.review`)}),(0,U.jsx)(`span`,{children:a}),s?null:(0,U.jsx)(`button`,{type:`button`,onClick:c,className:`underline hover:text-ink`,children:D(`know.reviewed`)})]}):null]}):null]})}function Ne(e){let t=e.filter(Number.isFinite).sort((e,t)=>e-t);if(new Set(t).size<=4)return[];let n=t[0],r=t.at(-1),i=e=>e.slice(0,-1).map((t,n)=>({lo:t,hi:e[n+1]})).filter(e=>t.some(t=>t>=e.lo&&t<e.hi));if(n>0&&r/n>=30){let e=Math.floor(Math.log10(n)),t=Math.floor(Math.log10(r))+1;for(let a of[[1,2,5],[1,3],[1]]){let o=[];for(let n=e;n<=t;n++)for(let e of a)o.push(e*10**n);let s=i(o.filter((e,t)=>e<=n||o[t-1]<=r));if(s.length<=7)return s}}let a=(r-n)/5,o=10**Math.floor(Math.log10(a)),s=([1,2,2.5,5,10].map(e=>e*o).find(e=>e>=a)??a)||1,c=[];for(let e=Math.floor(n/s)*s;e<=r;e+=s)c.push(e);return c.push(c.at(-1)+s),i(c)}function Pe({projectId:e,category:t,categories:n,onOpen:i}){let a=r({queryKey:[`knowledge`,e,`category`,t.id],queryFn:()=>y.get(`/api/studio/categories/${t.id}/items`)});if(!a.data)return a.isLoading?(0,U.jsx)(l,{className:`mx-auto size-4 text-ink-3`}):null;let o=e=>e.categories.find(e=>e.categoryId===t.id)?.values[0],s=[...a.data.items].sort((e,t)=>{let n=o(e),r=o(t);return typeof n==`number`&&typeof r==`number`?n-r:String(r??``).localeCompare(String(n??``),w)}),c=t.type===`number`?Ne(s.map(o).filter(e=>typeof e==`number`)):[],u=new Intl.NumberFormat(w,{notation:`compact`,maximumFractionDigits:1}),d=t.unit?` ${t.unit}`:``,f=new Map;for(let e of s){let n=o(e),r=typeof n==`number`?c.find(e=>n>=e.lo&&n<e.hi):void 0,i=n===void 0?``:t.type===`date`?new Date(`${String(n).slice(0,7)}-01T00:00:00`).toLocaleDateString(w,{month:`long`,year:`numeric`}):r?D(`know.range`,{min:`${u.format(r.lo)}${d}`,max:`${u.format(r.hi)}${d}`}):K(t,n);f.set(i,[...f.get(i)??[],e])}return(0,U.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[[...f].map(([e,t])=>(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[e?(0,U.jsx)(`p`,{className:`px-1 font-medium text-[0.6875rem] text-ink-4 uppercase tracking-[0.12em]`,children:e}):null,(0,U.jsx)(p,{className:`flex flex-col p-1.5`,children:t.map(e=>(0,U.jsx)(q,{item:e,categories:n,onOpen:i},e.key))})]},e)),a.data.rows.map(e=>(0,U.jsx)(`button`,{type:`button`,onClick:()=>i(`t:${e.tableId}`),className:`px-1 text-left text-[0.8125rem] text-ink-3 hover:text-ink`,children:D(`know.tocRows`,{n:e.count,table:e.title})},e.tableId))]})}function Fe(e,t,n){return Array.isArray(n)?t.some(e=>n.map(String).includes(String(e))):typeof n==`object`&&n?t.some(t=>{if(e.type===`number`&&typeof t==`number`)return(n.gte===void 0||t>=n.gte)&&(n.lte===void 0||t<=n.lte);if(e.type===`date`){let e=String(t).slice(0,10);return(!n.after||e>=n.after)&&(!n.before||e<=n.before)}return!n.contains||String(t).toLowerCase().includes(n.contains.toLowerCase())}):t.some(e=>e===n)}function Ie(e,t){if(Array.isArray(t))return t.map(String).join(`, `);if(typeof t==`boolean`)return D(t?`know.yes`:`know.no`);if(typeof t==`object`&&t){let n=t.gte??t.after,r=t.lte??t.before;return t.contains?`${D(`know.contains`)} ${t.contains}`:[n===void 0?``:`${D(`know.minimum`)} ${K(e,n)}`,r===void 0?``:`${D(`know.maximum`)} ${K(e,r)}`].filter(Boolean).join(` `)}return String(t)}function Le({category:e,value:t,onChange:n}){let[r,a]=(0,H.useState)(!1),o=(0,H.useRef)(null);(0,H.useEffect)(()=>{if(!r)return;let e=e=>!o.current?.contains(e.target)&&a(!1);return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[r]);let s=W[e.type],c=typeof t==`object`&&t&&!Array.isArray(t)?t:{},l=(t,r)=>{let i={...c,[t]:r===``?void 0:e.type===`number`?Number(r):r},a=Object.fromEntries(Object.entries(i).filter(([,e])=>e!==void 0));n(Object.keys(a).length?a:void 0)};return(0,U.jsxs)(`div`,{ref:o,className:`relative`,children:[(0,U.jsxs)(`button`,{type:`button`,onClick:()=>a(!r),className:P(`inline-flex h-8 items-center gap-1.5 rounded-full px-3 text-[0.8125rem] transition`,t===void 0?`text-ink-2 ring-1 ring-border-soft hover:ring-border`:`bg-ember-tint text-ink ring-1 ring-ember/30`),children:[(0,U.jsx)(s,{className:`size-3.5 text-ink-3`}),e.name,t===void 0?null:(0,U.jsxs)(`span`,{className:`font-medium`,children:[`: `,Ie(e,t)]}),(0,U.jsx)(re,{className:`size-3.5 text-ink-3`})]}),r?(0,U.jsxs)(`div`,{className:`absolute top-full left-0 z-30 mt-1.5 w-72 max-w-[calc(100vw-32px)] rounded-xl bg-card p-3 shadow-overlay ring-1 ring-border-soft`,children:[e.type===`choice`?(0,U.jsx)(i,{multi:!0,value:Array.isArray(t)?t.map(String):[],options:e.values.map(e=>e.value),onChange:e=>n(e.length?e:void 0)}):e.type===`boolean`?(0,U.jsx)(i,{value:t===!0?D(`know.yes`):t===!1?D(`know.no`):``,options:[D(`know.yes`),D(`know.no`)],onChange:e=>n(e===D(`know.yes`))}):e.type===`text`?(0,U.jsx)(f,{"data-autofocus":!0,value:c.contains??``,placeholder:D(`know.contains`),onChange:e=>n(e.target.value?{contains:e.target.value}:void 0),className:`h-9`}):(0,U.jsx)(`div`,{className:`grid grid-cols-2 gap-2`,children:(e.type===`number`?[`gte`,`lte`]:[`after`,`before`]).map((t,n)=>(0,U.jsxs)(`div`,{children:[(0,U.jsx)(b,{children:D(n===0?`know.minimum`:`know.maximum`)}),(0,U.jsx)(f,{type:e.type===`number`?`number`:`date`,step:`any`,value:String(c[t]??``),placeholder:e.range?String(n===0?e.range.min:e.range.max):``,onChange:e=>l(t,e.target.value),className:`h-9`})]},t))}),t===void 0?null:(0,U.jsx)(`button`,{type:`button`,onClick:()=>{n(void 0),a(!1)},className:`mt-3 text-[0.8125rem] text-ink-3 underline hover:text-ink`,children:D(`know.clear`)})]}):null]})}function Re({found:e,onOpen:t}){return e.hits.length?(0,U.jsxs)(`div`,{className:`flex flex-col`,children:[(0,U.jsx)(`p`,{className:`px-3 pt-1 pb-2 text-[0.75rem] text-ink-3`,children:e.checked?D(`know.searchStats`,{candidates:e.candidates,hits:e.hits.length}):D(`know.searchUnchecked`,{hits:e.hits.length})}),e.hits.map(e=>{let n=e.open;return(0,U.jsxs)(`button`,{type:`button`,disabled:!n,onClick:()=>n&&t(n),className:`flex items-start gap-3 rounded-lg px-3 py-2.5 text-left transition hover:bg-accent disabled:pointer-events-none`,children:[(0,U.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,U.jsxs)(`span`,{className:`block truncate text-[0.875rem]`,children:[e.title,e.heading&&e.heading!==e.title?(0,U.jsxs)(`span`,{className:`text-ink-3`,children:[` › `,e.heading]}):null]}),(0,U.jsx)(`span`,{className:`line-clamp-2 text-[0.8125rem] text-ink-3`,children:e.text})]}),e.relevance===null?null:(0,U.jsx)(`span`,{className:`shrink-0 font-medium text-[0.75rem] text-moss tabular-nums`,children:e.relevance.toLocaleString(w,{minimumFractionDigits:2})})]},`${e.key}:${e.heading}`)})]}):(0,U.jsx)(`p`,{className:`px-3 py-4 text-[0.875rem] text-ink-3`,children:D(`know.searchNone`)})}function ze({kind:e,projectId:t,onClose:n,onMade:r}){let i=E(),[a,o]=(0,H.useState)(``),[s,c]=(0,H.useState)(!1),l=I({mutationFn:()=>y.post(`/api/studio/projects/${t}/${e===`table`?`tables`:`pages`}`,{title:a.trim(),...e===`table`&&s?{format:`faq`}:{}}),onSuccess:async({id:n})=>{await i.invalidateQueries({queryKey:[`knowledge`,t]}),r(`${e===`table`?`t`:`p`}:${n}`),o(``),c(!1)}});return(0,U.jsx)(_,{open:e!==null,onClose:n,title:D(e===`table`?`know.newTable`:`know.newPage`),children:(0,U.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),a.trim()&&l.mutate()},children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(b,{children:D(`data.title`)}),(0,U.jsx)(f,{"data-autofocus":!0,value:a,maxLength:120,onChange:e=>o(e.target.value)})]}),e===`table`?(0,U.jsxs)(`label`,{className:`flex items-center justify-between gap-3 text-[0.875rem]`,children:[D(`know.asFaq`),(0,U.jsx)(C,{checked:s,onChange:c})]}):null,l.error?(0,U.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:l.error.message}):null,(0,U.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,U.jsx)(j,{variant:`ghost`,onClick:n,children:D(`common.cancel`)}),(0,U.jsx)(j,{type:`submit`,busy:l.isPending,disabled:!a.trim(),children:D(`know.create`)})]})]})})}function Be({projectId:e,data:t,readOnly:n,onOpen:r}){let i=E(),s=a(e,n),[c,u]=(0,H.useState)({}),[d,f]=(0,H.useState)(``),[m,g]=(0,H.useState)(null),[_,v]=(0,H.useState)(!1),[b,x]=(0,H.useState)(null),S=t.categories.filter(e=>!e.proposed&&e.count>0),C=t.categories.filter(e=>e.proposed),w=t.items.filter(e=>Object.entries(c).every(([n,r])=>{let i=t.categories.find(e=>e.name===n),a=e.categories.find(e=>e.categoryId===i?.id);return i&&a?Fe(i,a.values,r):!1})),k=async()=>{if(!d.trim()){g(null);return}v(!0);try{g(await y.post(`/api/studio/projects/${e}/search`,{query:d,...Object.keys(c).length?{where:c}:{}}))}catch{g({hits:[],candidates:0,checked:!1,filtered:null})}finally{v(!1)}},A=I({mutationFn:({id:e,keep:t})=>t?y.patch(`/api/studio/categories/${e}`,{proposed:!1}):y.del(`/api/studio/categories/${e}`),onSuccess:()=>i.invalidateQueries({queryKey:[`knowledge`,e]})});return(0,U.jsxs)(F,{title:D(`know.title`),hint:D(`know.hint`),plain:!0,action:n?null:(0,U.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[(0,U.jsxs)(j,{variant:`secondary`,size:`sm`,onClick:()=>x(`page`),children:[(0,U.jsx)(O,{className:`size-4`}),` `,D(`know.page`)]}),(0,U.jsxs)(j,{variant:`secondary`,size:`sm`,onClick:()=>x(`table`),children:[(0,U.jsx)(O,{className:`size-4`}),` `,D(`know.table`)]}),(0,U.jsxs)(j,{variant:`secondary`,size:`sm`,onClick:()=>x(`category`),children:[(0,U.jsx)(O,{className:`size-4`}),` `,D(`know.category`)]})]}),children:[C.length&&!n?(0,U.jsx)(p,{className:`flex flex-col gap-2 p-4`,children:C.map(e=>{let t=W[e.type];return(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2.5`,children:[(0,U.jsx)(h,{tone:`ember`,children:D(`know.proposed`)}),(0,U.jsx)(t,{className:`size-4 text-ink-3`}),(0,U.jsx)(`span`,{className:`font-medium text-[0.875rem]`,children:e.name}),(0,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[0.8125rem] text-ink-3`,children:[D(`know.type.${e.type}`),e.hint].filter(Boolean).join(` · `)}),(0,U.jsx)(j,{size:`sm`,variant:`ghost`,onClick:()=>A.mutate({id:e.id,keep:!1}),children:D(`know.dismiss`)}),(0,U.jsx)(j,{size:`sm`,onClick:()=>A.mutate({id:e.id,keep:!0}),children:D(`know.accept`)})]},e.id)})}):null,t.items.length?(0,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,U.jsx)(T,{value:d,placeholder:D(`know.search`),busy:_,onEnter:()=>void k(),onChange:e=>{f(e),e.trim()||g(null)}}),S.length?(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[S.map(e=>(0,U.jsx)(Le,{category:e,value:c[e.name],onChange:t=>{g(null),u(n=>{let r={...n};return t===void 0?delete r[e.name]:r[e.name]=t,r})}},e.id)),Object.keys(c).length?(0,U.jsx)(`button`,{type:`button`,onClick:()=>u({}),className:`px-2 text-[0.8125rem] text-ink-3 underline hover:text-ink`,children:D(`know.clear`)}):null]}):null]}):null,(0,U.jsx)(p,{className:`flex flex-col p-1.5`,children:m?(0,U.jsx)(Re,{found:m,onOpen:r}):w.length?w.map(e=>(0,U.jsx)(q,{item:e,categories:t.categories,onOpen:r},e.key)):(0,U.jsx)(o,{children:D(`know.empty`)})}),n?null:(0,U.jsxs)(ee,{accept:`.pdf,.docx,.doc,.xlsx,.csv,.tsv,.txt,.md,.json,.html,.eml,image/*`,onFiles:async t=>{await s.upload(`document`,t),await i.invalidateQueries({queryKey:[`knowledge`,e]})},className:`h-14 w-full`,children:[s.busy?(0,U.jsx)(l,{className:`size-4`}):(0,U.jsx)(oe,{className:`size-4`}),D(`know.drop`),` `,(0,U.jsx)(`span`,{className:`underline`,children:D(`know.pick`)})]}),s.error?(0,U.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:s.error}):null,t.items.length&&!(t.checked&&t.embeddings)?(0,U.jsx)(`p`,{className:`px-1 text-[0.8125rem] text-ink-3`,children:[t.embeddings?``:D(`know.keywordsOnly`),t.checked?``:D(`know.unchecked`)].filter(Boolean).join(` `)}):null,(0,U.jsx)(ze,{kind:b===`page`||b===`table`?b:null,projectId:e,onClose:()=>x(null),onMade:e=>{x(null),r(e)}}),(0,U.jsx)(De,{projectId:e,open:b===`category`,onClose:()=>x(null),onMade:e=>{x(null),r(`c:${e}`)}})]})}function Ve({page:e,onGone:t,onOpen:n}){let r=E(),[i,a]=(0,H.useState)(e.title),[o,c]=(0,H.useState)(e.markdown),[d,f]=(0,H.useState)(e.markdown?`read`:`write`),h=e.knowledge,_=async()=>{await r.invalidateQueries({queryKey:[`space-data`,e.projectId]}),await r.invalidateQueries({queryKey:[`knowledge`,e.projectId]})},v=g({title:i.trim()||e.title,markdown:o},async t=>{await y.patch(`/api/studio/pages/${e.id}`,t),r.setQueryData([`space-page`,e.id],e=>e&&{...e,...t}),t.title!==e.title&&await _()}),b=I({mutationFn:()=>y.del(`/api/studio/pages/${e.id}`),onSuccess:async()=>{await _(),t()}}),S=I({mutationFn:()=>y.post(`/api/studio/projects/${e.projectId}/pages`,{title:D(`know.addSub`),parentId:e.id}),onSuccess:async({id:e})=>{await _(),n?.(`p:${e}`)}}),C=I({mutationFn:()=>y.patch(`/api/studio/pages/${e.id}`,{review:null}),onSuccess:()=>r.invalidateQueries({queryKey:[`space-page`,e.id]})}),w=async t=>{let r=t.target.closest(`a`)?.getAttribute(`href`);if(!(r?.startsWith(`pages/`)&&n))return;t.preventDefault();let i=await y.get(`/api/studio/projects/${e.projectId}/resolve?path=${encodeURIComponent(r)}`).catch(()=>null);i?.kind===`page`&&n(`p:${i.id}`)},T=e.readOnly,A=h?.file&&(h.file.mime===`application/pdf`||h.file.mime.startsWith(`image/`))?h.file:null,M=(e,t)=>(0,U.jsx)(`button`,{type:`button`,"aria-pressed":d===e,onClick:()=>f(e),className:P(`rounded-full px-3 py-1 text-[0.8125rem] transition`,d===e?`bg-paper-2 font-medium text-ink`:`text-ink-3 hover:text-ink`),children:t});return(0,U.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[h?.parents.length&&n?(0,U.jsx)(`nav`,{className:`-mb-1.5 flex flex-wrap items-center gap-1 px-1 text-[0.8125rem] text-ink-3`,children:h.parents.map(e=>(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,U.jsx)(`button`,{type:`button`,onClick:()=>n(`p:${e.id}`),className:`hover:text-ink`,children:e.title}),(0,U.jsx)(ie,{className:`size-3.5`})]},e.id))}):null,(0,U.jsxs)(`div`,{className:`flex items-center gap-2 px-1`,children:[(0,U.jsx)(`input`,{value:i,disabled:T,maxLength:200,onChange:e=>a(e.target.value),"aria-label":D(`data.title`),className:`-ml-1 min-w-0 flex-1 rounded-md bg-transparent px-1 font-display font-semibold text-lg outline-none hover:bg-accent focus:bg-paper focus:ring-1 focus:ring-ring disabled:hover:bg-transparent`}),v.state===`saving`?(0,U.jsx)(l,{className:`size-3.5 text-ink-3`}):v.state===`saved`?(0,U.jsx)(x,{className:`size-4 text-moss`,"aria-label":D(`settings.saved`)}):null,T?null:(0,U.jsx)(u,{label:D(`data.deletePage`),onClick:()=>confirm(D(`data.confirmDelete`,{title:e.title}))&&b.mutate(),className:`hover:text-rose`,children:(0,U.jsx)(s,{className:`size-4`})})]}),h?(0,U.jsx)(J,{projectId:e.projectId,itemKey:`p:${e.id}`,has:h.categories,originLabel:h.originLabel,kept:h.kept,review:h.review,file:A?null:h.file,readOnly:T,onReviewed:()=>C.mutate()}):null,(0,U.jsxs)(p,{className:`flex flex-col`,children:[T&&!A?null:(0,U.jsxs)(`div`,{className:`flex items-center gap-1 border-border-soft border-b px-2 py-1.5`,children:[T?null:M(`write`,D(`data.write`)),M(`read`,D(`data.preview`)),A?M(`original`,D(`know.original`)):null,(0,U.jsx)(`span`,{className:`ml-auto truncate px-2 text-[0.75rem] text-ink-4 max-sm:hidden`,children:d===`original`&&A?A.name:D(`data.markdownHint`)})]}),d===`original`&&A?A.mime===`application/pdf`?(0,U.jsx)(`iframe`,{src:m(e.projectId,A.id),title:A.name,className:`h-[70dvh] w-full rounded-b-xl bg-paper-2`}):(0,U.jsx)(`img`,{src:m(e.projectId,A.id),alt:``,className:`mx-auto max-h-[70dvh] object-contain p-4`}):d===`write`&&!T?(0,U.jsx)(`textarea`,{value:o,onChange:e=>c(e.target.value),"aria-label":e.title,placeholder:D(`data.pageEmpty`),className:`field-sizing-content min-h-[50vh] w-full resize-none bg-transparent p-4 font-mono text-[0.8125rem] leading-relaxed outline-none placeholder:text-ink-4 sm:p-5`}):(0,U.jsx)(`div`,{className:`min-h-40 p-4 sm:p-5`,onClick:w,children:o.trim()?(0,U.jsx)(N,{text:o}):(0,U.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:D(`data.pageEmpty`)})})]}),v.state===`error`&&v.error?(0,U.jsx)(`p`,{className:`px-1 text-[0.875rem] text-rose`,children:v.error}):null,h&&n&&(h.children.length||!T)?(0,U.jsxs)(`div`,{className:`mt-3 flex flex-col gap-1.5`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between px-1`,children:[(0,U.jsx)(`p`,{className:`font-medium text-[0.6875rem] text-ink-4 uppercase tracking-[0.12em]`,children:h.children.length?D(`know.subPages`):null}),T?null:(0,U.jsxs)(j,{variant:`ghost`,size:`sm`,busy:S.isPending,onClick:()=>S.mutate(),children:[(0,U.jsx)(O,{className:`size-4`}),` `,D(`know.addSub`)]})]}),h.children.length?(0,U.jsx)(p,{className:`flex flex-col p-1.5`,children:h.children.map(e=>(0,U.jsxs)(`button`,{type:`button`,onClick:()=>n(`p:${e.id}`),className:`flex items-center gap-3 rounded-lg px-3 py-2 text-left transition hover:bg-accent`,children:[(0,U.jsx)(k,{className:`size-4 shrink-0 text-ink-3`}),(0,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[0.875rem]`,children:e.title})]},e.id))}):null]}):null]})}function He({pageId:e,onGone:t,onOpen:n}){let i=r({queryKey:[`space-page`,e],queryFn:()=>y.get(`/api/studio/pages/${e}`),refetchOnWindowFocus:!1});return i.data?(0,U.jsx)(Ve,{page:i.data,onGone:t,onOpen:n},i.data.id):i.isError?(0,U.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:i.error.message}):null}function Ue(e){return r({queryKey:[`space-data`,e],queryFn:()=>y.get(`/api/studio/projects/${e}/data`),enabled:!!e})}function We(e){let t=t=>[...e.tables.filter(e=>e.wizardId===t).map(e=>({key:`t:${e.id}`,kind:`table`,title:e.title,rows:e.rows})),...e.pages.filter(e=>e.wizardId===t).map(e=>({key:`p:${e.id}`,kind:`page`,title:e.title}))];return[{key:`own`,label:D(`data.own`),items:t(null)},...e.wizards.map(e=>({key:e.id,label:e.title,items:t(e.id)}))].filter(e=>e.items.length)}var Ge={table:ce,page:k};function Ke({kind:e,projectId:t,data:n,onClose:r,onMade:i}){let a=E(),[o,s]=(0,H.useState)(``),[c,l]=(0,H.useState)(``),u=I({mutationFn:()=>y.post(`/api/studio/projects/${t}/${e===`table`?`tables`:`pages`}`,{title:o.trim(),wizardId:c||null}),onSuccess:async({id:n})=>{await a.invalidateQueries({queryKey:[`space-data`,t]}),i(`${e===`table`?`t`:`p`}:${n}`),s(``),l(``)}});return(0,U.jsx)(_,{open:e!==null,onClose:r,title:D(e===`table`?`data.newTable`:`data.newPage`),children:(0,U.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),o.trim()&&u.mutate()},children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(b,{children:D(`data.title`)}),(0,U.jsx)(f,{"data-autofocus":!0,value:o,maxLength:120,onChange:e=>s(e.target.value)})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(b,{children:D(`data.owner`)}),(0,U.jsx)(S,{value:c,onChange:l,options:[{value:``,label:D(`data.own`)},...n.wizards.map(e=>({value:e.id,label:e.title}))]})]}),u.error?(0,U.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:u.error.message}):null,(0,U.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,U.jsx)(j,{variant:`ghost`,onClick:r,children:D(`common.cancel`)}),(0,U.jsx)(j,{type:`submit`,busy:u.isPending,disabled:!o.trim(),children:D(`data.create`)})]})]})})}function qe({projectId:e,data:t,readOnly:n,onOpen:r}){let[i,a]=(0,H.useState)(null);le(n?null:{icon:O,label:D(`data.newTable`),run:()=>a(`table`)});let s=We(t),c=new Map([...t.tables.map(e=>[`t:${e.id}`,e.updatedAt]),...t.pages.map(e=>[`p:${e.id}`,e.updatedAt])]),l=new Intl.DateTimeFormat(w,{dateStyle:`medium`});return(0,U.jsxs)(F,{title:D(`space.data`),hint:D(`data.hint`),plain:!0,action:n?null:(0,U.jsxs)(`div`,{className:`flex gap-2`,children:[(0,U.jsxs)(j,{variant:`secondary`,size:`sm`,onClick:()=>a(`table`),children:[(0,U.jsx)(O,{className:`size-4`}),` `,D(`data.table`)]}),(0,U.jsxs)(j,{variant:`secondary`,size:`sm`,onClick:()=>a(`page`),children:[(0,U.jsx)(O,{className:`size-4`}),` `,D(`data.page`)]})]}),children:[s.length?(0,U.jsx)(`div`,{className:`flex flex-col gap-5`,children:s.map(e=>(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(`p`,{className:`px-1 font-medium text-[0.6875rem] text-ink-4 uppercase tracking-[0.12em]`,children:e.label}),(0,U.jsx)(p,{className:`flex flex-col p-1.5`,children:e.items.map(e=>{let t=Ge[e.kind];return(0,U.jsxs)(`button`,{type:`button`,onClick:()=>r(e.key),className:`flex items-center gap-3 rounded-lg px-3 py-2.5 text-left transition hover:bg-accent`,children:[(0,U.jsx)(t,{className:`size-4 shrink-0 text-ink-3`}),(0,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[0.875rem]`,children:e.title}),(0,U.jsxs)(`span`,{className:`shrink-0 text-[0.75rem] text-ink-3 tabular-nums`,children:[e.kind===`table`?`${D(`data.rows`,{n:e.rows??0})} · `:``,l.format(new Date(c.get(e.key)??Date.now()))]})]},e.key)})})]},e.key))}):(0,U.jsx)(p,{children:(0,U.jsx)(o,{children:D(`data.empty`)})}),(0,U.jsx)(Ke,{kind:i,projectId:e,data:t,onClose:()=>a(null),onMade:e=>{a(null),r(e)}})]})}function Je(e,t){let n=e.normalize(`NFKD`).replace(/[̀-ͯ]/g,``).toLowerCase().replace(/[^a-z0-9]+/g,`_`).replace(/^_+|_+$/g,``).replace(/^[^a-z]+/,``).slice(0,48)||`column`,r=n,i=2;for(;t.includes(r);)r=`${n}_${i++}`;return r}var Ye={milliseconds:1,seconds:1e3,minutes:6e4,hours:36e5,days:864e5},Xe=[`text`,`number`,`date`,`duration`,`select`,`boolean`];function Ze(e,t){if(t==null)return``;if(e.type===`duration`&&typeof t==`number`)return String(t/Ye[e.format.inputUnit]);if(e.type===`date`&&e.format.kind===`datetime`&&typeof t==`string`){let e=new Date(t);return new Date(e.getTime()-e.getTimezoneOffset()*6e4).toISOString().slice(0,16)}return String(t)}var Y=`w-full min-w-0 rounded-md bg-transparent px-2 py-1.5 text-[0.875rem] outline-none transition placeholder:text-ink-4 hover:bg-accent focus:bg-paper focus:ring-1 focus:ring-ring disabled:hover:bg-transparent`;function Qe({column:e,value:t,readOnly:n,invalid:r,onSave:i}){let a=Ze(e,t),[o,s]=(0,H.useState)(a);(0,H.useEffect)(()=>s(a),[a]);let l=(t=o)=>{t!==a&&i(ae(e,t))};if(e.type===`boolean`)return(0,U.jsx)(`div`,{className:`px-2 py-1.5`,children:(0,U.jsx)(`input`,{type:`checkbox`,checked:t===!0,disabled:n,onChange:e=>i(e.target.checked),"aria-label":e.name,className:`size-4 accent-[var(--ember)]`})});if(e.type===`select`&&e.format.multiple){let r=Array.isArray(t)?t:[],a=t=>e.format.options.find(e=>e.id===t)?.label??t;return(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 px-2 py-1`,children:[r.map(e=>(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-paper-2 py-0.5 pr-1 pl-2 text-[0.75rem]`,children:[a(e),n?null:(0,U.jsx)(`button`,{type:`button`,"aria-label":D(`data.removeOption`),onClick:()=>i(r.filter(t=>t!==e)),className:`rounded-full text-ink-3 hover:text-ink`,children:(0,U.jsx)(c,{className:`size-3`})})]},e)),n?null:(0,U.jsxs)(`select`,{value:``,onChange:e=>e.target.value&&i([...r,e.target.value]),"aria-label":e.name,className:`h-7 rounded-md bg-transparent px-1 text-[0.75rem] text-ink-3 outline-none hover:bg-accent`,children:[(0,U.jsx)(`option`,{value:``,children:`+`}),e.format.options.filter(e=>!r.includes(e.id)).map(e=>(0,U.jsx)(`option`,{value:e.id,children:e.label},e.id))]})]})}if(e.type===`select`)return(0,U.jsxs)(`select`,{value:typeof t==`string`?t:``,disabled:n,onChange:e=>i(e.target.value||null),"aria-label":e.name,className:Y,children:[(0,U.jsx)(`option`,{value:``}),e.format.options.map(e=>(0,U.jsx)(`option`,{value:e.id,children:e.label},e.id))]});if(e.type===`text`&&e.format?.style&&e.format.style!==`single`)return(0,U.jsx)(`textarea`,{value:o,rows:1,disabled:n,onChange:e=>s(e.target.value),onBlur:()=>l(),"aria-label":e.name,className:P(Y,`field-sizing-content max-h-40 resize-none`)});let u=e.type===`date`?{date:`date`,datetime:`datetime-local`,time:`time`}[e.format.kind]:`text`;return(0,U.jsx)(`input`,{type:u,inputMode:e.type===`number`||e.type===`duration`?`decimal`:void 0,value:o,disabled:n,onChange:t=>{s(t.target.value),e.type===`date`&&l(t.target.value)},onBlur:()=>e.type!==`date`&&l(),onKeyDown:e=>{e.key===`Enter`&&e.target.blur(),e.key===`Escape`&&s(a)},"aria-label":e.name,className:P(Y,(e.type===`number`||e.type===`duration`)&&`text-right tabular-nums`,r&&`ring-1 ring-rose`)})}function $e(e){return e.type===`number`&&e.format.style===`currency`?e.format.currency??null:e.type===`number`&&e.format.style===`percent`?`%`:e.type===`duration`?D(`data.unit.${e.format.inputUnit}`):null}function et(e){return{name:e?.name??``,type:e?.type??`text`,required:e?.required??!1,textStyle:e?.type===`text`&&(e.format?.style??`single`)!==`single`?`multiline`:`single`,numberStyle:e?.type===`number`?e.format.style:`decimal`,currency:e?.type===`number`?e.format.currency??`EUR`:`EUR`,dateKind:e?.type===`date`?e.format.kind:`date`,unit:e?.type===`duration`&&[`minutes`,`hours`,`days`].includes(e.format.inputUnit)?e.format.inputUnit:`minutes`,options:e?.type===`select`?e.format.options.map(e=>e.label).join(`
3
+ `):``,multiple:e?.type===`select`&&!!e.format.multiple}}function tt(e,t,n){let r={id:t,name:e.name.trim(),...e.required?{required:!0}:{}};switch(e.type){case`number`:return{...r,type:`number`,format:e.numberStyle===`currency`?{style:`currency`,currency:e.currency.trim().toUpperCase()}:{style:e.numberStyle}};case`date`:return{...r,type:`date`,format:{kind:e.dateKind}};case`duration`:return{...r,type:`duration`,format:{inputUnit:e.unit,display:`hms`}};case`select`:{let t=n?.type===`select`?n.format.options:[],i=[],a=e.options.split(`
4
+ `).map(e=>e.trim()).filter(Boolean).map(e=>{let n=t.find(t=>t.label===e)?.id??Je(e,i);return i.push(n),{id:n,label:e}});return{...r,type:`select`,format:{allowCustom:!1,options:a,...e.multiple?{multiple:!0}:{}}}}case`boolean`:return{...r,type:`boolean`};default:return{...r,type:`text`,...e.textStyle===`multiline`?{format:{style:`multiline`}}:{}}}}function nt({open:e,column:t,columns:n,onClose:r,onSave:i}){let[a,o]=(0,H.useState)(()=>et(t)),[s,c]=(0,H.useState)(null),[l,u]=(0,H.useState)(!1);(0,H.useEffect)(()=>{e&&(o(et(t)),c(null))},[e,t]);let p=e=>o(t=>({...t,...e})),m=async e=>{u(!0),c(null);try{await i(e),r()}catch(e){c(e.message)}finally{u(!1)}},h=()=>{let e=t?.id??Je(a.name,n.map(e=>e.id)),r=tt(a,e,t);return m(t?n.map(e=>e.id===t.id?r:e):[...n,r])};return(0,U.jsx)(_,{open:e,onClose:r,title:t?t.name:D(`data.newColumn`),children:(0,U.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),a.name.trim()&&h()},children:[(0,U.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(b,{children:D(`data.columnName`)}),(0,U.jsx)(f,{"data-autofocus":!0,value:a.name,maxLength:128,onChange:e=>p({name:e.target.value})})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(b,{children:D(`data.columnType`)}),(0,U.jsx)(S,{value:a.type,onChange:e=>p({type:e}),options:Xe.map(e=>({value:e,label:D(`data.type.${e}`)}))})]})]}),a.type===`text`?(0,U.jsx)(S,{value:a.textStyle,onChange:e=>p({textStyle:e}),options:[{value:`single`,label:D(`data.text.single`)},{value:`multiline`,label:D(`data.text.multiline`)}]}):null,a.type===`number`?(0,U.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,U.jsx)(S,{value:a.numberStyle,onChange:e=>p({numberStyle:e}),options:[`integer`,`decimal`,`percent`,`currency`].map(e=>({value:e,label:D(`data.number.${e}`)}))}),a.numberStyle===`currency`?(0,U.jsx)(f,{value:a.currency,maxLength:3,"aria-label":D(`data.currency`),placeholder:`EUR`,onChange:e=>p({currency:e.target.value})}):null]}):null,a.type===`date`?(0,U.jsx)(S,{value:a.dateKind,onChange:e=>p({dateKind:e}),options:[`date`,`datetime`,`time`].map(e=>({value:e,label:D(`data.date.${e}`)}))}):null,a.type===`duration`?(0,U.jsxs)(`div`,{children:[(0,U.jsx)(b,{children:D(`data.unit`)}),(0,U.jsx)(S,{value:a.unit,onChange:e=>p({unit:e}),options:[`minutes`,`hours`,`days`].map(e=>({value:e,label:D(`data.unit.${e}`)}))})]}):null,a.type===`select`?(0,U.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(b,{children:D(`data.options`)}),(0,U.jsx)(d,{minRows:3,value:a.options,onChange:e=>p({options:e.target.value})})]}),(0,U.jsxs)(`label`,{className:`flex items-center gap-3 text-[0.875rem]`,children:[(0,U.jsx)(C,{checked:a.multiple,onChange:e=>p({multiple:e})}),D(`data.multiple`)]})]}):null,(0,U.jsxs)(`label`,{className:`flex items-center gap-3 text-[0.875rem]`,children:[(0,U.jsx)(C,{checked:a.required,onChange:e=>p({required:e})}),D(`data.required`)]}),s?(0,U.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:s}):null,(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[t&&n.length>1?(0,U.jsx)(j,{variant:`ghost`,className:`text-rose`,disabled:l,onClick:()=>confirm(D(`data.confirmDelete`,{title:t.name}))&&void m(n.filter(e=>e.id!==t.id)),children:D(`data.deleteColumn`)}):null,(0,U.jsx)(`span`,{className:`flex-1`}),(0,U.jsx)(j,{variant:`ghost`,onClick:r,children:D(`common.cancel`)}),(0,U.jsx)(j,{type:`submit`,busy:l,disabled:!a.name.trim(),children:D(`settings.save`)})]})]})})}function rt({tableId:e,onGone:t}){let n=E(),i=[`space-table`,e],a=r({queryKey:i,queryFn:()=>y.get(`/api/studio/tables/${e}`)}),[o,c]=(0,H.useState)(null),[l,d]=(0,H.useState)(null),[f,m]=(0,H.useState)(null),[h,g]=(0,H.useState)(``);(0,H.useEffect)(()=>g(a.data?.title??``),[a.data?.title]);let _=async()=>{await n.invalidateQueries({queryKey:[`space-data`,a.data?.projectId]}),await n.invalidateQueries({queryKey:[`knowledge`,a.data?.projectId]})},v=e=>n.setQueryData(i,t=>t&&{...t,rows:e(t.rows)}),b=e=>{d(e.message),a.refetch()},x=async t=>{await y.patch(`/api/studio/tables/${e}`,t),await a.refetch(),await _()},S=I({mutationFn:({row:t,column:n,value:r})=>y.patch(`/api/studio/tables/${e}/rows/${t}`,{cells:{[n]:r}}),onSuccess:(e,{row:t,column:n})=>{d(null),m(e=>e===`${t}:${n}`?null:e),v(t=>t.map(t=>t.id===e.id?{...t,cells:e.cells}:t))},onError:(e,{row:t,column:n})=>{if(e instanceof ne&&e.body?.column===n){let e=a.data?.columns.find(e=>e.id===n)?.name??n;m(`${t}:${n}`),d(D(`data.badCell`,{column:e}));return}b(e)}}),C=I({mutationFn:()=>y.post(`/api/studio/tables/${e}/rows`,{}),onSuccess:async e=>{v(t=>[...t,{...e,updatedAt:new Date().toISOString()}]),await _()},onError:b}),w=I({mutationFn:t=>y.post(`/api/studio/tables/${e}/rows/delete`,{ids:[t]}),onSuccess:async(e,t)=>{v(e=>e.filter(e=>e.id!==t)),await _()},onError:b}),T=I({mutationFn:()=>y.del(`/api/studio/tables/${e}`),onSuccess:async()=>{await _(),t()}});if(!a.data)return a.isError?(0,U.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:a.error.message}):null;let{columns:k,rows:A,readOnly:M}=a.data,N=!!a.data.list;return(0,U.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2 px-1`,children:[(0,U.jsx)(`input`,{value:h,disabled:M,maxLength:120,onChange:e=>g(e.target.value),onBlur:()=>h.trim()&&h!==a.data?.title&&void x({title:h}).catch(b),onKeyDown:e=>e.key===`Enter`&&e.target.blur(),"aria-label":D(`data.title`),className:`-ml-1 min-w-0 flex-1 rounded-md bg-transparent px-1 font-display font-semibold text-lg outline-none hover:bg-accent focus:bg-paper focus:ring-1 focus:ring-ring disabled:hover:bg-transparent`}),M?null:(0,U.jsx)(u,{label:D(`data.deleteTable`),onClick:()=>confirm(D(`data.confirmDelete`,{title:a.data.title}))&&T.mutate(),className:`hover:text-rose`,children:(0,U.jsx)(s,{className:`size-4`})})]}),N?(0,U.jsx)(`p`,{className:`-mt-1.5 px-1 text-[0.8125rem] text-ink-3`,children:D(`data.fromList`)}):null,a.data.knowledge?(0,U.jsx)(J,{projectId:a.data.projectId,itemKey:`t:${a.data.id}`,has:a.data.knowledge.categories,originLabel:a.data.knowledge.originLabel,kept:a.data.knowledge.kept,review:a.data.knowledge.review,file:a.data.knowledge.file,readOnly:M,onReviewed:()=>void y.patch(`/api/studio/tables/${e}`,{review:null}).then(()=>a.refetch()).catch(b)}):null,(0,U.jsxs)(p,{className:`overflow-hidden`,children:[(0,U.jsx)(`div`,{className:`overflow-x-auto`,children:(0,U.jsxs)(`table`,{className:`w-full border-collapse text-left`,children:[(0,U.jsx)(`thead`,{children:(0,U.jsxs)(`tr`,{className:`border-border-soft border-b`,children:[k.map(e=>(0,U.jsx)(`th`,{className:`min-w-36 border-border-soft border-l p-1 font-medium first:border-l-0`,children:(0,U.jsxs)(`button`,{type:`button`,disabled:M||N,onClick:()=>c(e),className:`flex w-full items-center gap-1 rounded-md px-2 py-1.5 text-left text-[0.8125rem] text-ink-2 transition hover:bg-accent hover:text-ink disabled:hover:bg-transparent`,children:[(0,U.jsx)(`span`,{className:`truncate`,children:e.name}),e.required?(0,U.jsx)(`span`,{className:`text-ember`,children:`*`}):null,$e(e)?(0,U.jsx)(`span`,{className:`font-normal text-ink-4`,children:$e(e)}):null]})},e.id)),(0,U.jsx)(`th`,{className:`w-10 p-1`,children:M||N?null:(0,U.jsx)(u,{label:D(`data.newColumn`),onClick:()=>c(`new`),className:`size-8`,children:(0,U.jsx)(O,{className:`size-4`})})})]})}),(0,U.jsx)(`tbody`,{children:A.map(e=>(0,U.jsxs)(`tr`,{className:`group border-border-soft border-b last:border-b-0`,children:[k.map(t=>(0,U.jsx)(`td`,{className:`border-border-soft border-l p-1 align-top first:border-l-0`,children:(0,U.jsx)(Qe,{column:t,value:e.cells[t.id],readOnly:M,invalid:f===`${e.id}:${t.id}`,onSave:n=>S.mutate({row:e.id,column:t.id,value:n})})},t.id)),(0,U.jsx)(`td`,{className:`w-10 p-1 align-top`,children:M?null:(0,U.jsx)(u,{label:D(`data.deleteRow`),onClick:()=>w.mutate(e.id),className:`size-8 opacity-0 hover:text-rose focus:opacity-100 group-hover:opacity-100 coarse:opacity-100`,children:(0,U.jsx)(s,{className:`size-3.5`})})})]},e.id))})]})}),A.length?null:(0,U.jsx)(`p`,{className:`px-4 py-6 text-center text-[0.875rem] text-ink-3`,children:D(`data.noRows`)}),M?null:(0,U.jsx)(`div`,{className:`border-border-soft border-t p-1.5`,children:(0,U.jsxs)(j,{variant:`ghost`,size:`sm`,busy:C.isPending,onClick:()=>C.mutate(),children:[(0,U.jsx)(O,{className:`size-4`}),` `,D(`data.addRow`)]})})]}),l?(0,U.jsx)(`p`,{className:`px-1 text-[0.875rem] text-rose`,children:l}):null,(0,U.jsx)(nt,{open:o!==null,column:o===`new`?null:o,columns:k,onClose:()=>c(null),onSave:e=>x({columns:e})})]})}var it=`wizards.runDrawer.width`,X=`wizards.runDrawer.wide`,at=`wizards.runDrawer.look`,ot=680,Z=400,st=()=>Math.max(Z,window.innerWidth-120);function Q(e){try{return localStorage.getItem(e)}catch{return null}}function $(e,t){try{localStorage.setItem(e,t)}catch{}}function ct(){let[e,t]=(0,H.useState)(()=>{let e=Number(Q(it));return e?Math.min(Math.max(e,Z),st()):ot}),[n,r]=(0,H.useState)(()=>Q(X)===`1`),i=(0,H.useCallback)(e=>{let n=Math.round(Math.min(Math.max(e,Z),st()));t(n),$(it,String(n))},[]);return{width:e,wide:n,toggleWide:()=>{r(!n),$(X,n?`0`:`1`)},onPointerDown:t=>{t.preventDefault();let n=t.clientX,r=e,a=e=>i(r+n-e.clientX),o=()=>{window.removeEventListener(`pointermove`,a),window.removeEventListener(`pointerup`,o),document.body.style.removeProperty(`cursor`),document.body.style.removeProperty(`user-select`)};document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`,window.addEventListener(`pointermove`,a),window.addEventListener(`pointerup`,o)},onKeyDown:t=>{let n=t.shiftKey?64:16;t.key===`ArrowLeft`?(t.preventDefault(),i(e+n)):t.key===`ArrowRight`&&(t.preventDefault(),i(e-n))},reset:()=>i(ot)}}function lt(){let[e,t]=(0,H.useState)(()=>Q(at)===`chat`?`chat`:`steps`);return[e,e=>{t(e),$(at,e)}]}function ut({look:e,onChange:t}){let n=[{id:`steps`,label:D(`chat.steps`),Icon:pe},{id:`chat`,label:D(`chat.chat`),Icon:me}];return(0,U.jsx)(`fieldset`,{"aria-label":D(`chat.view`),className:`m-0 flex min-w-0 rounded-full border-0 bg-paper-2 p-0.5`,children:n.map(({id:n,label:r,Icon:i})=>(0,U.jsxs)(`button`,{type:`button`,"aria-pressed":e===n,title:r,onClick:()=>t(n),className:P(`inline-flex h-7 items-center gap-1.5 rounded-full px-2.5 font-medium text-[0.75rem] transition coarse:h-9`,e===n?`bg-card text-ink shadow-soft`:`text-ink-3 hover:text-ink`),children:[(0,U.jsx)(i,{className:`size-3.5`}),(0,U.jsx)(`span`,{className:`max-sm:hidden`,children:r})]},n))})}function dt({header:e,actions:t,onClose:n,children:r}){let i=ct();return(0,U.jsx)(`div`,{className:`fixed inset-0 z-50 flex justify-end bg-[oklch(20%_0.01_60/0.22)] backdrop-blur-[1px]`,onClick:n,children:(0,U.jsxs)(`div`,{className:P(`relative flex h-full w-full animate-rise flex-col bg-background shadow-overlay`,!i.wide&&`sm:w-[var(--drawer)]`),style:{"--drawer":`${i.width}px`},onClick:e=>e.stopPropagation(),children:[i.wide?null:(0,U.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":D(`editor.resize`),"aria-valuenow":i.width,tabIndex:0,title:D(`editor.resize`),onPointerDown:i.onPointerDown,onKeyDown:i.onKeyDown,onDoubleClick:i.reset,className:`group -left-2.5 absolute inset-y-0 z-10 hidden w-5 cursor-col-resize outline-none sm:block`,children:(0,U.jsx)(`span`,{className:`-translate-y-1/2 absolute top-1/2 left-[7px] h-12 w-1.5 rounded-full bg-ink-4/40 transition group-hover:bg-ember/70 group-focus-visible:bg-ember group-active:h-16 group-active:bg-ember`})}),(0,U.jsxs)(`div`,{className:`kb-hide flex h-14 shrink-0 items-center gap-3 px-4`,children:[(0,U.jsx)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3`,children:e}),(0,U.jsxs)(`div`,{className:`flex items-center gap-1`,children:[t,(0,U.jsx)(u,{label:D(i.wide?`runDrawer.shrink`:`runDrawer.expand`),onClick:i.toggleWide,className:`max-sm:hidden`,children:i.wide?(0,U.jsx)(ge,{className:`size-4`}):(0,U.jsx)(te,{className:`size-4`})}),(0,U.jsx)(u,{label:D(`editor.close`),onClick:n,children:(0,U.jsx)(c,{className:`size-5`})})]})]}),(0,U.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:r})]})})}export{L as S,Ae as _,Ge as a,ge as b,Ue as c,q as d,J as f,Oe as g,W as h,rt as i,He as l,je as m,dt as n,qe as o,Be as p,lt as r,We as s,ut as t,Pe as u,ke as v,z as x,be as y};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{R as r,X as i,Y as a,et as o,in as s,q as c,wt as l}from"./ui-Cdv3QUOd.js";var u=e(t(),1),d=e(n(),1),f=[`classifier`,`standard`],p=12e3;function m(e){i(`think`)&&r.post(`/api/runs/${e}/device`,{think:{classes:f,maxChars:p}}).catch(()=>void 0)}async function h(e,t){if(t.kind!==`think`)return;let n;try{let e=await a(`think`,{system:t.system,prompt:t.prompt,schema:t.schema});n={text:String(e?.text??``)}}catch(e){n={error:e.message.slice(0,500)}}await r.post(`/api/runs/${e}/device/${t.id}`,n).catch(()=>void 0)}var g=45e3;function _(e){let[t,n]=(0,u.useState)(null),[i,a]=(0,u.useState)(null),[o,d]=(0,u.useState)(!1),[f,p]=(0,u.useState)(!1),[_,v]=(0,u.useState)({});(0,u.useEffect)(()=>{if(n(null),d(!1),!e)return;let t=!1,i=0,a,o=null,s=Date.now(),u=()=>{t=!0,o?.close(),d(!0)},f=async()=>{try{let i=await r.get(`/api/runs/${e}`);t||n(i)}catch(e){e instanceof l&&e.status===404&&u()}},p=()=>{if(clearTimeout(a),o?.close(),t)return;let r=new EventSource(c(`/api/runs/${e}/stream`),{withCredentials:!0});o=r,s=Date.now(),m(e),r.addEventListener(`device`,t=>{s=Date.now(),h(e,JSON.parse(t.data))}),r.addEventListener(`view`,e=>{i=0,s=Date.now(),n(JSON.parse(e.data))}),r.addEventListener(`ping`,()=>{s=Date.now()}),r.onerror=()=>{r.close(),!(t||o!==r)&&(o=null,f(),i=Math.min(i+1,6),a=setTimeout(p,500*2**i))}},_=()=>{t||document.visibilityState!==`visible`||(!o||o.readyState===EventSource.CLOSED||Date.now()-s>g?(i=0,p()):f())},v=setInterval(()=>{!t&&o&&Date.now()-s>g&&(i=0,p())},15e3);return p(),document.addEventListener(`visibilitychange`,_),window.addEventListener(`pageshow`,_),window.addEventListener(`online`,_),()=>{t=!0,clearTimeout(a),clearInterval(v),document.removeEventListener(`visibilitychange`,_),window.removeEventListener(`pageshow`,_),window.removeEventListener(`online`,_),o?.close()}},[e]);let y=(0,u.useCallback)(async(t,n)=>{if(!e)return!1;p(!0),a(null),v({});try{return await r.post(`/api/runs/${e}/${t}`,n),!0}catch(e){return e instanceof l&&e.status===422&&Array.isArray(e.body?.fields)&&v(Object.fromEntries(e.body.fields.map(e=>[e.field,e.message]))),a(e.message),!1}finally{p(!1)}},[e]);return s(t?.translation?.labels),{view:t,notFound:o,error:i,busy:f,fieldErrors:_,submitPage:(e,t)=>y(`pages/${e}`,{values:t}),accept:(e,t)=>y(`reviews/${e}`,{type:`accept`,edits:t}),regenerate:(e,t,n,r)=>y(`reviews/${e}`,{type:`regenerate`,target:t,note:n,items:r?.length?r:void 0}),back:()=>y(`back`),retry:()=>y(`retry`),translateResult:e=>y(`translate-result`,{stepId:e}),setLang:e=>y(`lang`,{lang:e})}}function v({runId:e,...t}){let n=_(e);return(0,d.jsx)(o,{run:n,...t})}export{_ as n,v as t};