@tomako/tools-runtime 0.1.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 (531) hide show
  1. package/README.md +12 -0
  2. package/package.json +629 -0
  3. package/src/assets/icons/brands/social/bluesky-icon.tsx +9 -0
  4. package/src/assets/icons/brands/social/facebook-icon.tsx +9 -0
  5. package/src/assets/icons/brands/social/index.ts +8 -0
  6. package/src/assets/icons/brands/social/instagram-icon.tsx +9 -0
  7. package/src/assets/icons/brands/social/linkedin-icon.tsx +9 -0
  8. package/src/assets/icons/brands/social/threads-icon.tsx +9 -0
  9. package/src/assets/icons/brands/social/tiktok-icon.tsx +10 -0
  10. package/src/assets/icons/brands/social/x-icon.tsx +9 -0
  11. package/src/assets/icons/brands/social/youtube-icon.tsx +9 -0
  12. package/src/assets/icons/social-profile/facebook-icon.tsx +12 -0
  13. package/src/assets/icons/social-profile/index.ts +29 -0
  14. package/src/assets/icons/social-profile/instagram-icon.tsx +18 -0
  15. package/src/assets/icons/social-profile/linkedin-icon.tsx +12 -0
  16. package/src/assets/icons/social-profile/tiktok-icon.tsx +12 -0
  17. package/src/assets/icons/social-profile/x-icon.tsx +13 -0
  18. package/src/assets/icons/social-profile/youtube-icon.tsx +12 -0
  19. package/src/components/tools/engine/form-builder.tsx +219 -0
  20. package/src/components/tools/engine/package-widget-loader.tsx +38 -0
  21. package/src/components/tools/engine/package-widget-runtime.tsx +409 -0
  22. package/src/components/tools/engine/package-widget.tsx +77 -0
  23. package/src/components/tools/engine/result-view.tsx +596 -0
  24. package/src/components/tools/engine/use-legacy-llm-task.ts +64 -0
  25. package/src/components/tools/engine/use-tool-task.ts +195 -0
  26. package/src/components/tools/market-forecast-report.tsx +1150 -0
  27. package/src/components/tools/registry.ts +13 -0
  28. package/src/components/tools/workspace/index.ts +39 -0
  29. package/src/components/tools/workspace/tool-action-bar.tsx +99 -0
  30. package/src/components/tools/workspace/tool-empty-panel.tsx +32 -0
  31. package/src/components/tools/workspace/tool-error-panel.tsx +40 -0
  32. package/src/components/tools/workspace/tool-field.tsx +124 -0
  33. package/src/components/tools/workspace/tool-file-upload.tsx +112 -0
  34. package/src/components/tools/workspace/tool-form-section.tsx +21 -0
  35. package/src/components/tools/workspace/tool-form-shell.tsx +36 -0
  36. package/src/components/tools/workspace/tool-loading-panel.tsx +269 -0
  37. package/src/components/tools/workspace/tool-option-row.tsx +97 -0
  38. package/src/components/tools/workspace/tool-preview-panel.tsx +31 -0
  39. package/src/components/tools/workspace/tool-result-actions.tsx +67 -0
  40. package/src/components/tools/workspace/tool-result-file-actions.ts +31 -0
  41. package/src/components/tools/workspace/tool-result-header.tsx +39 -0
  42. package/src/components/tools/workspace/tool-status.tsx +13 -0
  43. package/src/components/tools/workspace/tool-workspace-layout.tsx +226 -0
  44. package/src/constants/LKS.ts +29 -0
  45. package/src/constants/related-tools.ts +18 -0
  46. package/src/constants/social-profile-kit.ts +284 -0
  47. package/src/constants/tool-assets.ts +7 -0
  48. package/src/env.d.ts +3 -0
  49. package/src/features/tools/_templates/standard-tool.container.tsx +90 -0
  50. package/src/features/tools/app-icon-resizer/app-icon-resizer.container.tsx +11 -0
  51. package/src/features/tools/app-icon-resizer/app-icon-resizer.spec.ts +15 -0
  52. package/src/features/tools/app-icon-resizer/widget/app-icon-resizer.tsx +444 -0
  53. package/src/features/tools/app-icon-resizer/widget/constants.ts +19 -0
  54. package/src/features/tools/app-icon-resizer/widget/helpers.ts +314 -0
  55. package/src/features/tools/app-icon-resizer/widget/index.ts +7 -0
  56. package/src/features/tools/app-icon-resizer/widget/platform-icons.tsx +59 -0
  57. package/src/features/tools/app-icon-resizer/widget/preview-dialogs.tsx +139 -0
  58. package/src/features/tools/app-icon-resizer/widget/result-shell.tsx +165 -0
  59. package/src/features/tools/app-icon-resizer/widget/types.ts +36 -0
  60. package/src/features/tools/app-store-screenshot-generator/app-store-screenshot-generator.container.tsx +108 -0
  61. package/src/features/tools/app-store-screenshot-generator/app-store-screenshot-generator.spec.ts +14 -0
  62. package/src/features/tools/app-store-screenshot-generator/config.ts +3 -0
  63. package/src/features/tools/app-store-screenshot-generator/widget/app-store-screenshot-generator.tsx +1250 -0
  64. package/src/features/tools/app-store-screenshot-generator/widget/asset-slots.ts +76 -0
  65. package/src/features/tools/app-store-screenshot-generator/widget/constants.ts +43 -0
  66. package/src/features/tools/app-store-screenshot-generator/widget/form-controls.tsx +214 -0
  67. package/src/features/tools/app-store-screenshot-generator/widget/generation.ts +528 -0
  68. package/src/features/tools/app-store-screenshot-generator/widget/index.ts +7 -0
  69. package/src/features/tools/app-store-screenshot-generator/widget/input-media.ts +175 -0
  70. package/src/features/tools/app-store-screenshot-generator/widget/types.ts +60 -0
  71. package/src/features/tools/app-store-screenshot-generator/widget/zip.ts +119 -0
  72. package/src/features/tools/build-in-public-story-generator/build-in-public-story-generator.container.tsx +135 -0
  73. package/src/features/tools/build-in-public-story-generator/build-in-public-story-generator.spec.ts +15 -0
  74. package/src/features/tools/build-in-public-story-generator/widget/build-in-public-story-generator.tsx +314 -0
  75. package/src/features/tools/build-in-public-story-generator/widget/constants.ts +3 -0
  76. package/src/features/tools/build-in-public-story-generator/widget/helpers.ts +25 -0
  77. package/src/features/tools/build-in-public-story-generator/widget/index.ts +7 -0
  78. package/src/features/tools/build-in-public-story-generator/widget/preview-panels.tsx +58 -0
  79. package/src/features/tools/build-in-public-story-generator/widget/result-shell.tsx +164 -0
  80. package/src/features/tools/build-in-public-story-generator/widget/types.ts +6 -0
  81. package/src/features/tools/cold-start-channel-selector/cold-start-channel-selector.container.tsx +30 -0
  82. package/src/features/tools/cold-start-channel-selector/cold-start-channel-selector.spec.ts +15 -0
  83. package/src/features/tools/cold-start-channel-selector/widget/cold-start-channel-selector.tsx +417 -0
  84. package/src/features/tools/cold-start-channel-selector/widget/constants.ts +46 -0
  85. package/src/features/tools/cold-start-channel-selector/widget/form-controls.tsx +41 -0
  86. package/src/features/tools/cold-start-channel-selector/widget/helpers.ts +75 -0
  87. package/src/features/tools/cold-start-channel-selector/widget/index.ts +7 -0
  88. package/src/features/tools/cold-start-channel-selector/widget/preview-panels.tsx +250 -0
  89. package/src/features/tools/cold-start-channel-selector/widget/result-shell.tsx +199 -0
  90. package/src/features/tools/cold-start-channel-selector/widget/types.ts +21 -0
  91. package/src/features/tools/commercial-bp-generator/commercial-bp-generator.container.tsx +102 -0
  92. package/src/features/tools/commercial-bp-generator/commercial-bp-generator.spec.ts +14 -0
  93. package/src/features/tools/commercial-bp-generator/widget/commercial-bp-generator.tsx +676 -0
  94. package/src/features/tools/commercial-bp-generator/widget/constants.ts +32 -0
  95. package/src/features/tools/commercial-bp-generator/widget/helpers.ts +147 -0
  96. package/src/features/tools/commercial-bp-generator/widget/index.ts +7 -0
  97. package/src/features/tools/commercial-bp-generator/widget/result-shell.tsx +271 -0
  98. package/src/features/tools/commercial-bp-generator/widget/style-option.tsx +54 -0
  99. package/src/features/tools/commercial-bp-generator/widget/types.ts +33 -0
  100. package/src/features/tools/community-feedback-inbox/community-feedback-inbox.container.tsx +126 -0
  101. package/src/features/tools/community-feedback-inbox/community-feedback-inbox.spec.ts +15 -0
  102. package/src/features/tools/community-feedback-inbox/widget/community-feedback-inbox.tsx +271 -0
  103. package/src/features/tools/community-feedback-inbox/widget/constants.ts +3 -0
  104. package/src/features/tools/community-feedback-inbox/widget/helpers.ts +28 -0
  105. package/src/features/tools/community-feedback-inbox/widget/index.ts +7 -0
  106. package/src/features/tools/community-feedback-inbox/widget/preview-panels.tsx +92 -0
  107. package/src/features/tools/community-feedback-inbox/widget/result-shell.tsx +266 -0
  108. package/src/features/tools/community-feedback-inbox/widget/types.ts +6 -0
  109. package/src/features/tools/community-pain-point-extractor/community-pain-point-extractor.container.tsx +124 -0
  110. package/src/features/tools/community-pain-point-extractor/community-pain-point-extractor.spec.ts +15 -0
  111. package/src/features/tools/community-pain-point-extractor/widget/community-pain-point-extractor.tsx +404 -0
  112. package/src/features/tools/community-pain-point-extractor/widget/constants.ts +41 -0
  113. package/src/features/tools/community-pain-point-extractor/widget/helpers.ts +76 -0
  114. package/src/features/tools/community-pain-point-extractor/widget/index.ts +8 -0
  115. package/src/features/tools/community-pain-point-extractor/widget/progress-panels.tsx +251 -0
  116. package/src/features/tools/community-pain-point-extractor/widget/result-shell.tsx +478 -0
  117. package/src/features/tools/community-pain-point-extractor/widget/types.ts +33 -0
  118. package/src/features/tools/community-post-risk-checker/community-post-risk-checker.package.ts +792 -0
  119. package/src/features/tools/competitor-analysis/competitor-analysis.container.tsx +136 -0
  120. package/src/features/tools/competitor-analysis/competitor-analysis.spec.ts +15 -0
  121. package/src/features/tools/competitor-analysis/widget/competitor-analysis.tsx +241 -0
  122. package/src/features/tools/competitor-analysis/widget/constants.ts +9 -0
  123. package/src/features/tools/competitor-analysis/widget/index.ts +7 -0
  124. package/src/features/tools/competitor-analysis/widget/preview-panels.tsx +60 -0
  125. package/src/features/tools/competitor-analysis/widget/result-shell.tsx +418 -0
  126. package/src/features/tools/competitor-analysis/widget/types.ts +13 -0
  127. package/src/features/tools/disclaimer-generator/disclaimer-generator.package.ts +339 -0
  128. package/src/features/tools/email-template-generator/email-template-generator.container.tsx +224 -0
  129. package/src/features/tools/email-template-generator/email-template-generator.spec.ts +14 -0
  130. package/src/features/tools/email-template-generator/widget/email-template-generator.tsx +358 -0
  131. package/src/features/tools/email-template-generator/widget/helpers.ts +39 -0
  132. package/src/features/tools/email-template-generator/widget/index.ts +7 -0
  133. package/src/features/tools/email-template-generator/widget/preview-panel.tsx +311 -0
  134. package/src/features/tools/email-template-generator/widget/result-text-block.tsx +7 -0
  135. package/src/features/tools/email-template-generator/widget/types.ts +24 -0
  136. package/src/features/tools/gtm-readiness-checklist/gtm-readiness-checklist.container.tsx +75 -0
  137. package/src/features/tools/gtm-readiness-checklist/gtm-readiness-checklist.spec.ts +15 -0
  138. package/src/features/tools/gtm-readiness-checklist/widget/gtm-readiness-checklist.tsx +122 -0
  139. package/src/features/tools/gtm-readiness-checklist/widget/index.ts +7 -0
  140. package/src/features/tools/investor-matching-planner/investor-matching-planner.package.ts +869 -0
  141. package/src/features/tools/koko-codex-assistant/koko-codex-assistant.container.tsx +151 -0
  142. package/src/features/tools/koko-codex-assistant/koko-codex-assistant.spec.ts +14 -0
  143. package/src/features/tools/koko-codex-assistant/widget/index.ts +7 -0
  144. package/src/features/tools/koko-codex-assistant/widget/koko-codex-assistant-download.tsx +192 -0
  145. package/src/features/tools/logo-generator/logo-generator.container.tsx +112 -0
  146. package/src/features/tools/logo-generator/logo-generator.spec.ts +15 -0
  147. package/src/features/tools/logo-generator/widget/index.ts +7 -0
  148. package/src/features/tools/logo-generator/widget/logo-generator.tsx +1244 -0
  149. package/src/features/tools/market-forecast-report/market-forecast-report.container.tsx +73 -0
  150. package/src/features/tools/market-forecast-report/market-forecast-report.spec.ts +15 -0
  151. package/src/features/tools/million-user-growth-test/million-user-growth-test.container.tsx +123 -0
  152. package/src/features/tools/million-user-growth-test/million-user-growth-test.spec.ts +14 -0
  153. package/src/features/tools/million-user-growth-test/widget/index.ts +7 -0
  154. package/src/features/tools/million-user-growth-test/widget/million-user-growth-test.tsx +433 -0
  155. package/src/features/tools/module-loader.ts +107 -0
  156. package/src/features/tools/og-image-generator/og-image-generator.container.tsx +86 -0
  157. package/src/features/tools/og-image-generator/og-image-generator.spec.ts +14 -0
  158. package/src/features/tools/og-image-generator/widget/constants.ts +38 -0
  159. package/src/features/tools/og-image-generator/widget/form-fields.tsx +240 -0
  160. package/src/features/tools/og-image-generator/widget/index.ts +7 -0
  161. package/src/features/tools/og-image-generator/widget/og-image-generator.tsx +742 -0
  162. package/src/features/tools/og-image-generator/widget/preview-panel.tsx +305 -0
  163. package/src/features/tools/og-image-generator/widget/types.ts +1 -0
  164. package/src/features/tools/package/direct-models.ts +20 -0
  165. package/src/features/tools/package/form.ts +38 -0
  166. package/src/features/tools/package/l10n.ts +22 -0
  167. package/src/features/tools/package/package-container.tsx +285 -0
  168. package/src/features/tools/package/package-loaders.ts +22 -0
  169. package/src/features/tools/package/package-registry.ts +36 -0
  170. package/src/features/tools/package/result-markdown.ts +142 -0
  171. package/src/features/tools/package/schema.ts +379 -0
  172. package/src/features/tools/package/to-tool-module.ts +20 -0
  173. package/src/features/tools/package/to-tool-spec.ts +52 -0
  174. package/src/features/tools/package/types.ts +381 -0
  175. package/src/features/tools/pitch-deck-generator/pitch-deck-generator.container.tsx +175 -0
  176. package/src/features/tools/pitch-deck-generator/pitch-deck-generator.spec.ts +14 -0
  177. package/src/features/tools/pitch-deck-generator/pitch-deck-library-data.ts +476 -0
  178. package/src/features/tools/pitch-deck-generator/pitch-deck-library.tsx +159 -0
  179. package/src/features/tools/pitch-deck-generator/widget/ceremony-line.tsx +27 -0
  180. package/src/features/tools/pitch-deck-generator/widget/constants.ts +27 -0
  181. package/src/features/tools/pitch-deck-generator/widget/index.ts +7 -0
  182. package/src/features/tools/pitch-deck-generator/widget/pitch-deck-generator.tsx +763 -0
  183. package/src/features/tools/pitch-deck-generator/widget/result-helpers.ts +102 -0
  184. package/src/features/tools/pitch-deck-generator/widget/result-shell.tsx +263 -0
  185. package/src/features/tools/pitch-deck-generator/widget/slide-frame.tsx +106 -0
  186. package/src/features/tools/pitch-deck-generator/widget/slide-lightbox.tsx +149 -0
  187. package/src/features/tools/pitch-deck-generator/widget/style-option.tsx +54 -0
  188. package/src/features/tools/pitch-deck-generator/widget/types.ts +44 -0
  189. package/src/features/tools/product-agreement-generator/product-agreement-generator.container.tsx +137 -0
  190. package/src/features/tools/product-agreement-generator/product-agreement-generator.spec.ts +14 -0
  191. package/src/features/tools/product-agreement-generator/widget/constants.ts +27 -0
  192. package/src/features/tools/product-agreement-generator/widget/form-controls.tsx +218 -0
  193. package/src/features/tools/product-agreement-generator/widget/helpers.ts +68 -0
  194. package/src/features/tools/product-agreement-generator/widget/index.ts +7 -0
  195. package/src/features/tools/product-agreement-generator/widget/product-agreement-generator.tsx +671 -0
  196. package/src/features/tools/product-agreement-generator/widget/result-shell.tsx +473 -0
  197. package/src/features/tools/product-agreement-generator/widget/types.ts +89 -0
  198. package/src/features/tools/product-hunt-launch-planner/product-hunt-launch-planner.container.tsx +122 -0
  199. package/src/features/tools/product-hunt-launch-planner/product-hunt-launch-planner.spec.ts +15 -0
  200. package/src/features/tools/product-hunt-launch-planner/widget/constants.ts +5 -0
  201. package/src/features/tools/product-hunt-launch-planner/widget/helpers.ts +44 -0
  202. package/src/features/tools/product-hunt-launch-planner/widget/index.ts +7 -0
  203. package/src/features/tools/product-hunt-launch-planner/widget/preview-panel.tsx +143 -0
  204. package/src/features/tools/product-hunt-launch-planner/widget/product-hunt-launch-planner.tsx +504 -0
  205. package/src/features/tools/product-hunt-launch-planner/widget/result-shell.tsx +176 -0
  206. package/src/features/tools/product-hunt-launch-planner/widget/types.ts +20 -0
  207. package/src/features/tools/product-name-generator/product-name-generator.container.tsx +14 -0
  208. package/src/features/tools/product-name-generator/product-name-generator.spec.ts +15 -0
  209. package/src/features/tools/product-name-generator/widget/candidate-card.tsx +273 -0
  210. package/src/features/tools/product-name-generator/widget/constants.ts +21 -0
  211. package/src/features/tools/product-name-generator/widget/form-controls.tsx +136 -0
  212. package/src/features/tools/product-name-generator/widget/helpers.ts +41 -0
  213. package/src/features/tools/product-name-generator/widget/index.ts +7 -0
  214. package/src/features/tools/product-name-generator/widget/product-name-generator.tsx +776 -0
  215. package/src/features/tools/product-name-generator/widget/types.ts +36 -0
  216. package/src/features/tools/product-positioning-analyzer/product-positioning-analyzer.package.ts +801 -0
  217. package/src/features/tools/product-poster-generator/product-poster-generator.container.tsx +14 -0
  218. package/src/features/tools/product-poster-generator/product-poster-generator.spec.ts +15 -0
  219. package/src/features/tools/product-poster-generator/widget/constants.ts +125 -0
  220. package/src/features/tools/product-poster-generator/widget/form-controls.tsx +204 -0
  221. package/src/features/tools/product-poster-generator/widget/helpers.ts +155 -0
  222. package/src/features/tools/product-poster-generator/widget/index.ts +7 -0
  223. package/src/features/tools/product-poster-generator/widget/product-poster-generator.tsx +663 -0
  224. package/src/features/tools/product-poster-generator/widget/result-shell.tsx +12 -0
  225. package/src/features/tools/product-poster-generator/widget/types.ts +83 -0
  226. package/src/features/tools/product-ui-generator/product-ui-generator.container.tsx +116 -0
  227. package/src/features/tools/product-ui-generator/product-ui-generator.spec.ts +14 -0
  228. package/src/features/tools/product-ui-generator/widget/constants.ts +18 -0
  229. package/src/features/tools/product-ui-generator/widget/helpers.ts +11 -0
  230. package/src/features/tools/product-ui-generator/widget/index.ts +7 -0
  231. package/src/features/tools/product-ui-generator/widget/preview-panels.tsx +73 -0
  232. package/src/features/tools/product-ui-generator/widget/product-ui-generator.tsx +304 -0
  233. package/src/features/tools/product-ui-generator/widget/result-shell.tsx +118 -0
  234. package/src/features/tools/product-ui-generator/widget/types.ts +9 -0
  235. package/src/features/tools/reddit-pain-point-finder/reddit-pain-point-finder.container.tsx +113 -0
  236. package/src/features/tools/reddit-pain-point-finder/reddit-pain-point-finder.spec.ts +15 -0
  237. package/src/features/tools/reddit-pain-point-finder/widget/constants.ts +5 -0
  238. package/src/features/tools/reddit-pain-point-finder/widget/index.ts +7 -0
  239. package/src/features/tools/reddit-pain-point-finder/widget/preview-panels.tsx +73 -0
  240. package/src/features/tools/reddit-pain-point-finder/widget/reddit-pain-point-finder.tsx +281 -0
  241. package/src/features/tools/reddit-pain-point-finder/widget/result-shell.tsx +203 -0
  242. package/src/features/tools/reddit-pain-point-finder/widget/types.ts +15 -0
  243. package/src/features/tools/registry.ts +288 -0
  244. package/src/features/tools/runtime-registry.ts +186 -0
  245. package/src/features/tools/shared/create-guide-stack-container.tsx +176 -0
  246. package/src/features/tools/shared/create-standard-landing-container.tsx +163 -0
  247. package/src/features/tools/shared/tool-content-sections.tsx +659 -0
  248. package/src/features/tools/shared/tool-cta.tsx +66 -0
  249. package/src/features/tools/shared/tool-draft-view.tsx +53 -0
  250. package/src/features/tools/shared/tool-guide-section.tsx +191 -0
  251. package/src/features/tools/shared/tool-handoff.tsx +38 -0
  252. package/src/features/tools/shared/tool-mcp-badge.tsx +23 -0
  253. package/src/features/tools/shared/tool-message-translator.ts +37 -0
  254. package/src/features/tools/shared/tool-page-shell.tsx +348 -0
  255. package/src/features/tools/shared/tool-standard-generation-steps.tsx +52 -0
  256. package/src/features/tools/shared/tool-standard-landing-sections.tsx +447 -0
  257. package/src/features/tools/shared/tool-ui-registry.ts +237 -0
  258. package/src/features/tools/shared/tool-widget-slot.tsx +29 -0
  259. package/src/features/tools/slogan-generator/slogan-generator.package.ts +641 -0
  260. package/src/features/tools/social-listening-research-report/social-listening-research-report.container.tsx +124 -0
  261. package/src/features/tools/social-listening-research-report/social-listening-research-report.spec.ts +15 -0
  262. package/src/features/tools/social-listening-research-report/widget/constants.ts +4 -0
  263. package/src/features/tools/social-listening-research-report/widget/index.ts +7 -0
  264. package/src/features/tools/social-listening-research-report/widget/preview-panels.tsx +73 -0
  265. package/src/features/tools/social-listening-research-report/widget/result-shell.tsx +216 -0
  266. package/src/features/tools/social-listening-research-report/widget/social-listening-research-report.tsx +303 -0
  267. package/src/features/tools/social-listening-research-report/widget/types.ts +15 -0
  268. package/src/features/tools/social-platform-asset-adapter/social-platform-asset-adapter.container.tsx +123 -0
  269. package/src/features/tools/social-platform-asset-adapter/social-platform-asset-adapter.spec.ts +15 -0
  270. package/src/features/tools/social-platform-asset-adapter/widget/constants.ts +43 -0
  271. package/src/features/tools/social-platform-asset-adapter/widget/helpers.ts +249 -0
  272. package/src/features/tools/social-platform-asset-adapter/widget/index.ts +7 -0
  273. package/src/features/tools/social-platform-asset-adapter/widget/result-shell.tsx +350 -0
  274. package/src/features/tools/social-platform-asset-adapter/widget/section-heading.tsx +18 -0
  275. package/src/features/tools/social-platform-asset-adapter/widget/social-platform-asset-adapter.tsx +641 -0
  276. package/src/features/tools/social-platform-asset-adapter/widget/types.ts +40 -0
  277. package/src/features/tools/social-profile-kit/social-profile-kit.container.tsx +177 -0
  278. package/src/features/tools/social-profile-kit/social-profile-kit.spec.ts +15 -0
  279. package/src/features/tools/social-profile-kit/widget/context-editor.tsx +171 -0
  280. package/src/features/tools/social-profile-kit/widget/generation-runtime.ts +281 -0
  281. package/src/features/tools/social-profile-kit/widget/index.ts +7 -0
  282. package/src/features/tools/social-profile-kit/widget/input-panel.tsx +294 -0
  283. package/src/features/tools/social-profile-kit/widget/platform-dock.tsx +115 -0
  284. package/src/features/tools/social-profile-kit/widget/profile-canvas.tsx +318 -0
  285. package/src/features/tools/social-profile-kit/widget/profile-preview/bluesky-preview.tsx +188 -0
  286. package/src/features/tools/social-profile-kit/widget/profile-preview/facebook-preview.tsx +168 -0
  287. package/src/features/tools/social-profile-kit/widget/profile-preview/index.ts +1 -0
  288. package/src/features/tools/social-profile-kit/widget/profile-preview/instagram-preview.tsx +278 -0
  289. package/src/features/tools/social-profile-kit/widget/profile-preview/linkedin-preview.tsx +358 -0
  290. package/src/features/tools/social-profile-kit/widget/profile-preview/profile-preview.tsx +348 -0
  291. package/src/features/tools/social-profile-kit/widget/profile-preview/shared.tsx +391 -0
  292. package/src/features/tools/social-profile-kit/widget/profile-preview/threads-preview.tsx +148 -0
  293. package/src/features/tools/social-profile-kit/widget/profile-preview/tiktok-preview.tsx +319 -0
  294. package/src/features/tools/social-profile-kit/widget/profile-preview/x-preview.tsx +341 -0
  295. package/src/features/tools/social-profile-kit/widget/profile-preview/youtube-preview.tsx +297 -0
  296. package/src/features/tools/social-profile-kit/widget/social-profile-kit-generator.tsx +1059 -0
  297. package/src/features/tools/social-profile-kit/widget/types.ts +104 -0
  298. package/src/features/tools/spec-registry.ts +158 -0
  299. package/src/features/tools/startup-idea-research/startup-idea-research.container.tsx +111 -0
  300. package/src/features/tools/startup-idea-research/startup-idea-research.spec.ts +15 -0
  301. package/src/features/tools/startup-idea-research/widget/constants.ts +11 -0
  302. package/src/features/tools/startup-idea-research/widget/index.ts +7 -0
  303. package/src/features/tools/startup-idea-research/widget/preview-panels.tsx +67 -0
  304. package/src/features/tools/startup-idea-research/widget/result-shell.tsx +323 -0
  305. package/src/features/tools/startup-idea-research/widget/startup-idea-research.tsx +272 -0
  306. package/src/features/tools/startup-idea-research/widget/types.ts +21 -0
  307. package/src/features/tools/tarot-reading/tarot-reading.container.tsx +412 -0
  308. package/src/features/tools/tarot-reading/tarot-reading.spec.ts +15 -0
  309. package/src/features/tools/tarot-reading/widget/cards.tsx +152 -0
  310. package/src/features/tools/tarot-reading/widget/constants.ts +69 -0
  311. package/src/features/tools/tarot-reading/widget/deck-view.tsx +86 -0
  312. package/src/features/tools/tarot-reading/widget/deck.ts +86 -0
  313. package/src/features/tools/tarot-reading/widget/index.ts +7 -0
  314. package/src/features/tools/tarot-reading/widget/landing-view.tsx +209 -0
  315. package/src/features/tools/tarot-reading/widget/reading-copy.tsx +138 -0
  316. package/src/features/tools/tarot-reading/widget/reading-view.tsx +189 -0
  317. package/src/features/tools/tarot-reading/widget/reveal-view.tsx +50 -0
  318. package/src/features/tools/tarot-reading/widget/ritual-view.tsx +276 -0
  319. package/src/features/tools/tarot-reading/widget/tarot-reading.tsx +262 -0
  320. package/src/features/tools/tarot-reading/widget/types.ts +22 -0
  321. package/src/features/tools/twitter-gif-downloader/twitter-gif-downloader.container.tsx +114 -0
  322. package/src/features/tools/twitter-gif-downloader/twitter-gif-downloader.spec.ts +14 -0
  323. package/src/features/tools/twitter-gif-downloader/widget/index.ts +7 -0
  324. package/src/features/tools/twitter-gif-downloader/widget/twitter-gif-downloader.tsx +351 -0
  325. package/src/features/tools/types.ts +68 -0
  326. package/src/features/tools/user-interview-guide-generator/user-interview-guide-generator.package.ts +774 -0
  327. package/src/features/tools/user-interview-insight-report-generator/user-interview-insight-report-generator.container.tsx +23 -0
  328. package/src/features/tools/user-interview-insight-report-generator/user-interview-insight-report-generator.spec.ts +14 -0
  329. package/src/features/tools/user-interview-insight-report-generator/widget/constants.ts +8 -0
  330. package/src/features/tools/user-interview-insight-report-generator/widget/helpers.ts +4 -0
  331. package/src/features/tools/user-interview-insight-report-generator/widget/index.ts +7 -0
  332. package/src/features/tools/user-interview-insight-report-generator/widget/preview-panels.tsx +55 -0
  333. package/src/features/tools/user-interview-insight-report-generator/widget/result-shell.tsx +122 -0
  334. package/src/features/tools/user-interview-insight-report-generator/widget/types.ts +16 -0
  335. package/src/features/tools/user-interview-insight-report-generator/widget/user-interview-insight-report-generator.tsx +293 -0
  336. package/src/features/tools/user-interview-record-generator/user-interview-record-generator.container.tsx +18 -0
  337. package/src/features/tools/user-interview-record-generator/user-interview-record-generator.spec.ts +14 -0
  338. package/src/features/tools/user-interview-record-generator/widget/constants.ts +9 -0
  339. package/src/features/tools/user-interview-record-generator/widget/helpers.ts +4 -0
  340. package/src/features/tools/user-interview-record-generator/widget/index.ts +7 -0
  341. package/src/features/tools/user-interview-record-generator/widget/preview-panels.tsx +48 -0
  342. package/src/features/tools/user-interview-record-generator/widget/result-shell.tsx +128 -0
  343. package/src/features/tools/user-interview-record-generator/widget/types.ts +16 -0
  344. package/src/features/tools/user-interview-record-generator/widget/user-interview-record-generator.tsx +305 -0
  345. package/src/features/tools/utm-builder/utm-builder.package.ts +846 -0
  346. package/src/features/tools/widget-registry.ts +73 -0
  347. package/src/generated/mcp-tools-registry.json +17 -0
  348. package/src/host/client-proxy.test.ts +33 -0
  349. package/src/host/client.ts +678 -0
  350. package/src/host/server.ts +119 -0
  351. package/src/i18n/client.ts +11 -0
  352. package/src/i18n/locale-fallback.ts +38 -0
  353. package/src/i18n/locale.ts +18 -0
  354. package/src/i18n/messages/en/page/tools.ts +124 -0
  355. package/src/i18n/messages/en/tools/app-icon-resizer.ts +244 -0
  356. package/src/i18n/messages/en/tools/app-store-screenshot-generator.ts +145 -0
  357. package/src/i18n/messages/en/tools/build-in-public-story-generator.ts +229 -0
  358. package/src/i18n/messages/en/tools/cold-start-channel-selector.ts +423 -0
  359. package/src/i18n/messages/en/tools/commercial-bp-generator.ts +304 -0
  360. package/src/i18n/messages/en/tools/community-feedback-inbox.ts +218 -0
  361. package/src/i18n/messages/en/tools/community-pain-point-extractor.ts +230 -0
  362. package/src/i18n/messages/en/tools/community-post-risk-checker.ts +209 -0
  363. package/src/i18n/messages/en/tools/competitor-analysis.ts +197 -0
  364. package/src/i18n/messages/en/tools/email-template-generator.ts +302 -0
  365. package/src/i18n/messages/en/tools/engine.ts +69 -0
  366. package/src/i18n/messages/en/tools/gtm-readiness-checklist.ts +166 -0
  367. package/src/i18n/messages/en/tools/index.ts +73 -0
  368. package/src/i18n/messages/en/tools/koko-codex-assistant.ts +171 -0
  369. package/src/i18n/messages/en/tools/logo-generator.ts +173 -0
  370. package/src/i18n/messages/en/tools/market-forecast-report.ts +228 -0
  371. package/src/i18n/messages/en/tools/million-user-growth-test.ts +386 -0
  372. package/src/i18n/messages/en/tools/og-image-generator.ts +172 -0
  373. package/src/i18n/messages/en/tools/pitch-deck-generator.ts +358 -0
  374. package/src/i18n/messages/en/tools/product-agreement-generator.ts +411 -0
  375. package/src/i18n/messages/en/tools/product-hunt-launch-planner.ts +272 -0
  376. package/src/i18n/messages/en/tools/product-name-generator.ts +383 -0
  377. package/src/i18n/messages/en/tools/product-poster-generator.ts +294 -0
  378. package/src/i18n/messages/en/tools/product-ui-generator.ts +234 -0
  379. package/src/i18n/messages/en/tools/reddit-pain-point-finder.ts +163 -0
  380. package/src/i18n/messages/en/tools/shared.ts +24 -0
  381. package/src/i18n/messages/en/tools/social-listening-research-report.ts +185 -0
  382. package/src/i18n/messages/en/tools/social-media-profile-generator.ts +22 -0
  383. package/src/i18n/messages/en/tools/social-platform-asset-adapter.ts +287 -0
  384. package/src/i18n/messages/en/tools/social-profile-kit.ts +150 -0
  385. package/src/i18n/messages/en/tools/startup-idea-research.ts +170 -0
  386. package/src/i18n/messages/en/tools/tarot-reading.ts +230 -0
  387. package/src/i18n/messages/en/tools/twitter-gif-downloader.ts +145 -0
  388. package/src/i18n/messages/en/tools/user-interview-insight-report-generator.ts +242 -0
  389. package/src/i18n/messages/en/tools/user-interview-record-generator.ts +244 -0
  390. package/src/i18n/messages/en/tools-ui.ts +704 -0
  391. package/src/i18n/messages/zh/page/tools.ts +124 -0
  392. package/src/i18n/messages/zh/tools/app-icon-resizer.ts +242 -0
  393. package/src/i18n/messages/zh/tools/app-store-screenshot-generator.ts +145 -0
  394. package/src/i18n/messages/zh/tools/build-in-public-story-generator.ts +230 -0
  395. package/src/i18n/messages/zh/tools/cold-start-channel-selector.ts +422 -0
  396. package/src/i18n/messages/zh/tools/commercial-bp-generator.ts +302 -0
  397. package/src/i18n/messages/zh/tools/community-feedback-inbox.ts +217 -0
  398. package/src/i18n/messages/zh/tools/community-pain-point-extractor.ts +230 -0
  399. package/src/i18n/messages/zh/tools/community-post-risk-checker.ts +200 -0
  400. package/src/i18n/messages/zh/tools/competitor-analysis.ts +192 -0
  401. package/src/i18n/messages/zh/tools/email-template-generator.ts +302 -0
  402. package/src/i18n/messages/zh/tools/engine.ts +68 -0
  403. package/src/i18n/messages/zh/tools/gtm-readiness-checklist.ts +166 -0
  404. package/src/i18n/messages/zh/tools/index.ts +73 -0
  405. package/src/i18n/messages/zh/tools/koko-codex-assistant.ts +170 -0
  406. package/src/i18n/messages/zh/tools/logo-generator.ts +172 -0
  407. package/src/i18n/messages/zh/tools/market-forecast-report.ts +228 -0
  408. package/src/i18n/messages/zh/tools/million-user-growth-test.ts +385 -0
  409. package/src/i18n/messages/zh/tools/og-image-generator.ts +173 -0
  410. package/src/i18n/messages/zh/tools/pitch-deck-generator.ts +358 -0
  411. package/src/i18n/messages/zh/tools/product-agreement-generator.ts +401 -0
  412. package/src/i18n/messages/zh/tools/product-hunt-launch-planner.ts +267 -0
  413. package/src/i18n/messages/zh/tools/product-name-generator.ts +383 -0
  414. package/src/i18n/messages/zh/tools/product-poster-generator.ts +282 -0
  415. package/src/i18n/messages/zh/tools/product-ui-generator.ts +234 -0
  416. package/src/i18n/messages/zh/tools/reddit-pain-point-finder.ts +162 -0
  417. package/src/i18n/messages/zh/tools/shared.ts +24 -0
  418. package/src/i18n/messages/zh/tools/social-listening-research-report.ts +181 -0
  419. package/src/i18n/messages/zh/tools/social-media-profile-generator.ts +22 -0
  420. package/src/i18n/messages/zh/tools/social-platform-asset-adapter.ts +284 -0
  421. package/src/i18n/messages/zh/tools/social-profile-kit.ts +150 -0
  422. package/src/i18n/messages/zh/tools/startup-idea-research.ts +165 -0
  423. package/src/i18n/messages/zh/tools/tarot-reading.ts +228 -0
  424. package/src/i18n/messages/zh/tools/twitter-gif-downloader.ts +138 -0
  425. package/src/i18n/messages/zh/tools/user-interview-insight-report-generator.ts +224 -0
  426. package/src/i18n/messages/zh/tools/user-interview-record-generator.ts +226 -0
  427. package/src/i18n/messages/zh/tools-ui.ts +684 -0
  428. package/src/i18n/messages/zh-tw/page/tools.ts +115 -0
  429. package/src/i18n/messages/zh-tw/tools/app-icon-resizer.ts +242 -0
  430. package/src/i18n/messages/zh-tw/tools/app-store-screenshot-generator.ts +145 -0
  431. package/src/i18n/messages/zh-tw/tools/build-in-public-story-generator.ts +230 -0
  432. package/src/i18n/messages/zh-tw/tools/cold-start-channel-selector.ts +440 -0
  433. package/src/i18n/messages/zh-tw/tools/commercial-bp-generator.ts +302 -0
  434. package/src/i18n/messages/zh-tw/tools/community-feedback-inbox.ts +217 -0
  435. package/src/i18n/messages/zh-tw/tools/community-pain-point-extractor.ts +230 -0
  436. package/src/i18n/messages/zh-tw/tools/community-post-risk-checker.ts +200 -0
  437. package/src/i18n/messages/zh-tw/tools/competitor-analysis.ts +192 -0
  438. package/src/i18n/messages/zh-tw/tools/email-template-generator.ts +302 -0
  439. package/src/i18n/messages/zh-tw/tools/engine.ts +68 -0
  440. package/src/i18n/messages/zh-tw/tools/gtm-readiness-checklist.ts +166 -0
  441. package/src/i18n/messages/zh-tw/tools/index.ts +73 -0
  442. package/src/i18n/messages/zh-tw/tools/koko-codex-assistant.ts +170 -0
  443. package/src/i18n/messages/zh-tw/tools/logo-generator.ts +71 -0
  444. package/src/i18n/messages/zh-tw/tools/market-forecast-report.ts +228 -0
  445. package/src/i18n/messages/zh-tw/tools/million-user-growth-test.ts +385 -0
  446. package/src/i18n/messages/zh-tw/tools/og-image-generator.ts +173 -0
  447. package/src/i18n/messages/zh-tw/tools/pitch-deck-generator.ts +358 -0
  448. package/src/i18n/messages/zh-tw/tools/product-agreement-generator.ts +401 -0
  449. package/src/i18n/messages/zh-tw/tools/product-hunt-launch-planner.ts +267 -0
  450. package/src/i18n/messages/zh-tw/tools/product-name-generator.ts +383 -0
  451. package/src/i18n/messages/zh-tw/tools/product-poster-generator.ts +282 -0
  452. package/src/i18n/messages/zh-tw/tools/product-ui-generator.ts +234 -0
  453. package/src/i18n/messages/zh-tw/tools/reddit-pain-point-finder.ts +162 -0
  454. package/src/i18n/messages/zh-tw/tools/shared.ts +24 -0
  455. package/src/i18n/messages/zh-tw/tools/social-listening-research-report.ts +181 -0
  456. package/src/i18n/messages/zh-tw/tools/social-media-profile-generator.ts +22 -0
  457. package/src/i18n/messages/zh-tw/tools/social-platform-asset-adapter.ts +284 -0
  458. package/src/i18n/messages/zh-tw/tools/social-profile-kit.ts +150 -0
  459. package/src/i18n/messages/zh-tw/tools/startup-idea-research.ts +165 -0
  460. package/src/i18n/messages/zh-tw/tools/tarot-reading.ts +228 -0
  461. package/src/i18n/messages/zh-tw/tools/twitter-gif-downloader.ts +138 -0
  462. package/src/i18n/messages/zh-tw/tools/user-interview-insight-report-generator.ts +224 -0
  463. package/src/i18n/messages/zh-tw/tools/user-interview-record-generator.ts +226 -0
  464. package/src/i18n/messages/zh-tw/tools-ui.ts +525 -0
  465. package/src/index.ts +15 -0
  466. package/src/lib/activity-task-handoff.ts +404 -0
  467. package/src/lib/api/errors.ts +39 -0
  468. package/src/lib/app-origin.ts +30 -0
  469. package/src/lib/fact-claim-contract.ts +68 -0
  470. package/src/lib/fake-delay.ts +3 -0
  471. package/src/lib/file/download.ts +10 -0
  472. package/src/lib/routing/locale-paths.ts +27 -0
  473. package/src/lib/seo-meta.ts +3 -0
  474. package/src/lib/tools/app-icon-resizer-schema.ts +191 -0
  475. package/src/lib/tools/app-store-screenshot-generator-schema.ts +185 -0
  476. package/src/lib/tools/build-in-public-story-generator-schema.ts +67 -0
  477. package/src/lib/tools/build-in-public-story-generator.format.ts +507 -0
  478. package/src/lib/tools/cold-start-channel-selector-schema.ts +147 -0
  479. package/src/lib/tools/commercial-bp-generator-schema.ts +222 -0
  480. package/src/lib/tools/community-feedback-inbox-schema.ts +125 -0
  481. package/src/lib/tools/community-feedback-inbox.format.ts +764 -0
  482. package/src/lib/tools/community-pain-point-extractor-schema.ts +166 -0
  483. package/src/lib/tools/community-post-risk-checker-schema.ts +99 -0
  484. package/src/lib/tools/community-post-risk-checker.format.ts +557 -0
  485. package/src/lib/tools/competitor-analysis-schema.ts +144 -0
  486. package/src/lib/tools/draft-preview-access.ts +3 -0
  487. package/src/lib/tools/draft-store.ts +69 -0
  488. package/src/lib/tools/email-template-generator-schema.ts +124 -0
  489. package/src/lib/tools/gtm-checklist-copy.ts +57 -0
  490. package/src/lib/tools/gtm-checklist-structure.ts +37 -0
  491. package/src/lib/tools/image-download.ts +68 -0
  492. package/src/lib/tools/input-quality.ts +97 -0
  493. package/src/lib/tools/logo-generator-schema.ts +224 -0
  494. package/src/lib/tools/market-forecast-report-schema.ts +299 -0
  495. package/src/lib/tools/mcp-registry.ts +16 -0
  496. package/src/lib/tools/mcp-types.ts +18 -0
  497. package/src/lib/tools/million-user-growth-test-schema.ts +49 -0
  498. package/src/lib/tools/million-user-growth-test.ts +181 -0
  499. package/src/lib/tools/og-image-generator-render.ts +448 -0
  500. package/src/lib/tools/og-image-generator-schema.ts +140 -0
  501. package/src/lib/tools/ops-catalog.ts +102 -0
  502. package/src/lib/tools/pitch-deck-generator-schema.ts +182 -0
  503. package/src/lib/tools/pitch-deck-package.ts +0 -0
  504. package/src/lib/tools/product-agreement-generator-schema.ts +168 -0
  505. package/src/lib/tools/product-hunt-launch-planner-schema.ts +136 -0
  506. package/src/lib/tools/product-hunt-launch-planner.format.ts +72 -0
  507. package/src/lib/tools/product-name-generator-schema.ts +563 -0
  508. package/src/lib/tools/product-poster-generator-schema.ts +215 -0
  509. package/src/lib/tools/product-ui-generator-schema.ts +157 -0
  510. package/src/lib/tools/reddit-pain-point-finder-schema.ts +88 -0
  511. package/src/lib/tools/resolve-tool-locale-copy.ts +75 -0
  512. package/src/lib/tools/slug.ts +60 -0
  513. package/src/lib/tools/social-listening-research-report-schema.ts +105 -0
  514. package/src/lib/tools/social-platform-asset-adapter-schema.ts +152 -0
  515. package/src/lib/tools/social-profile-kit.constants.ts +12 -0
  516. package/src/lib/tools/social-profile-kit.generation.ts +257 -0
  517. package/src/lib/tools/social-profile-kit.input.ts +290 -0
  518. package/src/lib/tools/social-profile-kit.manual.ts +481 -0
  519. package/src/lib/tools/social-profile-kit.package.ts +220 -0
  520. package/src/lib/tools/social-profile-kit.schema.ts +328 -0
  521. package/src/lib/tools/startup-idea-research-schema.ts +107 -0
  522. package/src/lib/tools/tarot-imagery.ts +89 -0
  523. package/src/lib/tools/tarot-reading.ts +1044 -0
  524. package/src/lib/tools/tool-message-keys.ts +18 -0
  525. package/src/lib/tools/types.ts +32 -0
  526. package/src/lib/tools/user-interview.format.ts +147 -0
  527. package/src/lib/tools/user-interview.generation.ts +670 -0
  528. package/src/lib/tools/user-interview.schema.ts +192 -0
  529. package/src/lib/zip.ts +106 -0
  530. package/src/services/tools/handlers/gtm-readiness-checklist.ts +71 -0
  531. package/src/services/tools/handlers/types.ts +7 -0
@@ -0,0 +1,1059 @@
1
+ "use client";
2
+
3
+ import { Button } from "@tomako/ui/button";
4
+ import {
5
+ DropdownMenu,
6
+ DropdownMenuContent,
7
+ DropdownMenuItem,
8
+ DropdownMenuSeparator,
9
+ DropdownMenuTrigger,
10
+ } from "@tomako/ui/dropdown-menu";
11
+ import { useLocale, useTranslations } from "../../../../i18n/client";
12
+ import { downloadBlob } from "../../../../lib/file/download";
13
+ import {
14
+ SOCIAL_PROFILE_PLATFORM_SPECS,
15
+ SOCIAL_PROFILE_PLATFORMS,
16
+ SOCIAL_PROFILE_V1_PLATFORMS,
17
+ } from "../../../../lib/tools/social-profile-kit.constants";
18
+ import {
19
+ createPlatformGenerationState,
20
+ createQueuedGenerationState,
21
+ getPrimaryGenerationPlatforms,
22
+ type PlatformGenerationState
23
+ } from "../../../../lib/tools/social-profile-kit.generation";
24
+ import {
25
+ normalizeSocialProfileInputForSubmission
26
+ } from "../../../../lib/tools/social-profile-kit.input";
27
+ import {
28
+ createDefaultManualSocialProfileKit,
29
+ } from "../../../../lib/tools/social-profile-kit.manual";
30
+ import {
31
+ buildSocialProfileKitZip,
32
+ buildSocialProfileKitZipName,
33
+ } from "../../../../lib/tools/social-profile-kit.package";
34
+ import {
35
+ socialProfileInputSchema,
36
+ type SocialProfileInput,
37
+ type SocialProfileKitOutput,
38
+ type SocialProfilePlatform,
39
+ type SocialProfileTheme,
40
+ } from "../../../../lib/tools/social-profile-kit.schema";
41
+ import { fakeDelay as sleep } from "../../../../lib/fake-delay";
42
+ import { uploadReferenceImage } from "../../../../host/client";
43
+ import {
44
+ submitSocialProfileKitGeneration,
45
+ } from "../../../../host/client";
46
+ import {
47
+ generateSocialProfileBannerImage,
48
+ generateSocialProfileMasterBannerImage,
49
+ SOCIAL_PROFILE_GENERATED_BANNER_PLATFORMS,
50
+ } from "../../../../host/client";
51
+ import { Download } from "lucide-react";
52
+ import { useMemo, useRef, useState } from "react";
53
+
54
+ import {
55
+ BANNER_IMAGE_MAX_ATTEMPTS,
56
+ isAgentKitUsable,
57
+ isGeneratedBannerPlatform,
58
+ isRetriableBannerImageError,
59
+ nextPlatformGenerationStatus,
60
+ readImageAsDataUrl,
61
+ renderSelectedAssetPng,
62
+ SocialProfileKitTaskError,
63
+ waitForAgentKit,
64
+ type BrandAssetState,
65
+ type CanvasZoomMode,
66
+ type KitGenerationResult
67
+ } from "./generation-runtime";
68
+ import { InputPanel } from "./input-panel";
69
+ import { PlatformDock } from "./platform-dock";
70
+ import { ProfileCanvas } from "./profile-canvas";
71
+ import type {
72
+ EditableTextField,
73
+ EditingProfileText,
74
+ ProfilePreviewDevice,
75
+ SelectedProfileElement,
76
+ SocialProfileKitCopy,
77
+ } from "./types";
78
+
79
+ export function SocialProfileKitGenerator() {
80
+ const locale = useLocale();
81
+ const t = useTranslations("toolsUi.socialProfileKit");
82
+ const copy: SocialProfileKitCopy = {
83
+ title: t("title"),
84
+ subtitle: t("subtitle"),
85
+ modes: {
86
+ personalCreator: t("modes.personalCreator"),
87
+ brandCompany: t("modes.brandCompany"),
88
+ },
89
+ inputModes: {
90
+ form: t("inputModes.form"),
91
+ prompt: t("inputModes.prompt"),
92
+ },
93
+ fields: {
94
+ name: t("fields.name"),
95
+ namePlaceholder: t("fields.namePlaceholder"),
96
+ positioning: t("fields.positioning"),
97
+ positioningPlaceholder: t("fields.positioningPlaceholder"),
98
+ audience: t("fields.audience"),
99
+ audiencePlaceholder: t("fields.audiencePlaceholder"),
100
+ targetMarket: t("fields.targetMarket"),
101
+ tone: t("fields.tone"),
102
+ brandAsset: t("fields.brandAsset"),
103
+ brandAssetHint: t("fields.brandAssetHint"),
104
+ brandAssetEmpty: t("fields.brandAssetEmpty"),
105
+ brandAssetRemove: t("fields.brandAssetRemove"),
106
+ prompt: t("fields.prompt"),
107
+ promptPlaceholder: t("fields.promptPlaceholder"),
108
+ },
109
+ tones: {
110
+ modern: t("tones.modern"),
111
+ friendly: t("tones.friendly"),
112
+ professional: t("tones.professional"),
113
+ bold: t("tones.bold"),
114
+ minimal: t("tones.minimal"),
115
+ },
116
+ targetMarkets: {
117
+ china: t("targetMarkets.china"),
118
+ northAmerica: t("targetMarkets.northAmerica"),
119
+ japan: t("targetMarkets.japan"),
120
+ europe: t("targetMarkets.europe"),
121
+ global: t("targetMarkets.global"),
122
+ },
123
+ platforms: {
124
+ x: t("platforms.x"),
125
+ bluesky: t("platforms.bluesky"),
126
+ threads: t("platforms.threads"),
127
+ linkedin: t("platforms.linkedin"),
128
+ "linkedin-company": t("platforms.linkedinCompany"),
129
+ instagram: t("platforms.instagram"),
130
+ tiktok: t("platforms.tiktok"),
131
+ youtube: t("platforms.youtube"),
132
+ facebook: t("platforms.facebook"),
133
+ },
134
+ actions: {
135
+ generate: t("actions.generate"),
136
+ generating: t("actions.generating"),
137
+ regenerate: t("actions.regenerate"),
138
+ copy: t("actions.copy"),
139
+ copied: t("actions.copied"),
140
+ edit: t("actions.edit"),
141
+ done: t("actions.done"),
142
+ upload: t("actions.upload"),
143
+ download: t("actions.download"),
144
+ downloadKit: t("actions.downloadKit"),
145
+ replaceColor: t("actions.replaceColor"),
146
+ downloadAll: t("actions.downloadAll"),
147
+ allPlatforms: t("actions.allPlatforms"),
148
+ fullKit: t("actions.fullKit"),
149
+ currentPlatform: t("actions.currentPlatform"),
150
+ follow: t("actions.follow"),
151
+ message: t("actions.message"),
152
+ },
153
+ canvas: {
154
+ desktop: t("canvas.desktop"),
155
+ mobile: t("canvas.mobile"),
156
+ light: t("canvas.light"),
157
+ dark: t("canvas.dark"),
158
+ zoomIn: t("canvas.zoomIn"),
159
+ zoomOut: t("canvas.zoomOut"),
160
+ fit: t("canvas.fit"),
161
+ selected: t("canvas.selected"),
162
+ unsupportedBanner: t("canvas.unsupportedBanner"),
163
+ },
164
+ elements: {
165
+ avatar: t("elements.avatar"),
166
+ banner: t("elements.banner"),
167
+ displayName: t("elements.displayName"),
168
+ username: t("elements.username"),
169
+ bio: t("elements.bio"),
170
+ headline: t("elements.headline"),
171
+ description: t("elements.description"),
172
+ },
173
+ status: {
174
+ defaultReady: t("status.defaultReady"),
175
+ generated: t("status.generated"),
176
+ validationError: t("status.validationError"),
177
+ idle: t("status.idle"),
178
+ queued: t("status.queued"),
179
+ generating: t("status.generating"),
180
+ ready: t("status.ready"),
181
+ failed: t("status.failed"),
182
+ },
183
+ sections: {
184
+ whatYouGet: t("sections.whatYouGet"),
185
+ sizes: t("sections.sizes"),
186
+ howItWorks: t("sections.howItWorks"),
187
+ relatedTools: t("sections.relatedTools"),
188
+ faq: t("sections.faq"),
189
+ },
190
+ };
191
+ const initial = useMemo(() => createDefaultManualSocialProfileKit(locale), [locale]);
192
+ const generationRunRef = useRef(0);
193
+ const generationTaskIdRef = useRef<string | null>(null);
194
+ const editVersionRef = useRef(0);
195
+ const bannerImageRunRef = useRef<Set<string>>(new Set());
196
+ const pendingKitRef = useRef<SocialProfileKitOutput>(initial);
197
+ const brandAssetRef = useRef<BrandAssetState | null>(null);
198
+ const [form, setForm] = useState<SocialProfileInput>(initial.input);
199
+ const [kit, setKit] = useState<SocialProfileKitOutput>(initial);
200
+ const [brandAsset, setBrandAsset] = useState<BrandAssetState | null>(null);
201
+ const [activePlatform, setActivePlatform] =
202
+ useState<SocialProfilePlatform>("x");
203
+ const [theme, setTheme] = useState<SocialProfileTheme>("light");
204
+ const [zoom, setZoom] = useState(1);
205
+ const [zoomMode, setZoomMode] = useState<CanvasZoomMode>("auto");
206
+ const [generationState, setGenerationState] =
207
+ useState<PlatformGenerationState>(() =>
208
+ createPlatformGenerationState("ready"),
209
+ );
210
+ const [bannerGenerationState, setBannerGenerationState] =
211
+ useState<PlatformGenerationState>(() =>
212
+ createPlatformGenerationState("idle"),
213
+ );
214
+ const [selected, setSelected] = useState<SelectedProfileElement | null>(null);
215
+ const [editing, setEditing] = useState<EditingProfileText>(null);
216
+ const [busy, setBusy] = useState(false);
217
+ const [hasAgentResult, setHasAgentResult] = useState(false);
218
+
219
+ const profile = kit.profiles[activePlatform];
220
+ const hasPendingGeneration = Object.values(generationState).some(
221
+ (status) => status === "queued" || status === "generating",
222
+ );
223
+ const hasPendingBannerGeneration = Object.values(bannerGenerationState).some(
224
+ (status) => status === "queued" || status === "generating",
225
+ );
226
+
227
+ function applyBrandAssetToKit(
228
+ sourceKit: SocialProfileKitOutput,
229
+ asset = brandAssetRef.current,
230
+ ): SocialProfileKitOutput {
231
+ if (!asset) return sourceKit;
232
+
233
+ const profiles = { ...sourceKit.profiles };
234
+ for (const platform of SOCIAL_PROFILE_PLATFORMS) {
235
+ profiles[platform] = {
236
+ ...profiles[platform],
237
+ avatar: {
238
+ ...profiles[platform].avatar,
239
+ kind: "uploaded",
240
+ source: asset.kind === "logo" ? "uploaded" : "uploaded",
241
+ generationMode: "userProvided",
242
+ isPlaceholderOnly: false,
243
+ src: asset.previewSrc,
244
+ prompt:
245
+ asset.kind === "logo"
246
+ ? `User-uploaded brand logo: ${asset.name}`
247
+ : `User-uploaded profile image: ${asset.name}`,
248
+ },
249
+ };
250
+ }
251
+
252
+ return { ...sourceKit, profiles };
253
+ }
254
+
255
+ async function ensureBrandAssetReference(
256
+ asset = brandAssetRef.current,
257
+ ): Promise<BrandAssetState | null> {
258
+ if (!asset) return null;
259
+ if (asset.referenceImageUrl) return asset;
260
+
261
+ const referenceImageUrl = await uploadReferenceImage(asset.dataUrl, asset.name);
262
+ if (!referenceImageUrl) return asset;
263
+
264
+ const next = { ...asset, referenceImageUrl };
265
+ brandAssetRef.current = next;
266
+ setBrandAsset(next);
267
+ return next;
268
+ }
269
+
270
+ function applyGeneratedPlatform(
271
+ platform: SocialProfilePlatform,
272
+ nextKit: SocialProfileKitOutput,
273
+ ) {
274
+ const nextKitWithAsset = applyBrandAssetToKit(nextKit);
275
+ setKit((current) => ({
276
+ ...nextKitWithAsset,
277
+ profiles: {
278
+ ...current.profiles,
279
+ [platform]: nextKitWithAsset.profiles[platform],
280
+ },
281
+ }));
282
+ }
283
+
284
+ function applyLateAgentKit(agentKit: SocialProfileKitOutput) {
285
+ setKit((current) => {
286
+ const profiles = { ...agentKit.profiles };
287
+ let hasPreservedBanner = false;
288
+
289
+ for (const platform of SOCIAL_PROFILE_GENERATED_BANNER_PLATFORMS) {
290
+ const currentBanner = current.profiles[platform].banner;
291
+ const nextBanner = profiles[platform].banner;
292
+ if (!currentBanner?.src || !nextBanner || nextBanner.kind === "notApplicable") {
293
+ continue;
294
+ }
295
+
296
+ profiles[platform] = {
297
+ ...profiles[platform],
298
+ banner: {
299
+ ...nextBanner,
300
+ ...currentBanner,
301
+ },
302
+ };
303
+ hasPreservedBanner = true;
304
+ }
305
+
306
+ const nextKit = hasPreservedBanner ? { ...agentKit, profiles } : agentKit;
307
+ return applyBrandAssetToKit(nextKit);
308
+ });
309
+ }
310
+
311
+ async function generatePlatform(
312
+ platform: SocialProfilePlatform,
313
+ runId = generationRunRef.current,
314
+ ) {
315
+ setGenerationState((current) =>
316
+ nextPlatformGenerationStatus(current, platform, "generating"),
317
+ );
318
+ await sleep(460);
319
+
320
+ if (runId !== generationRunRef.current) return;
321
+
322
+ applyGeneratedPlatform(platform, pendingKitRef.current);
323
+ setGenerationState((current) =>
324
+ nextPlatformGenerationStatus(current, platform, "ready"),
325
+ );
326
+ }
327
+
328
+ async function generateKitWithAgent(
329
+ input: SocialProfileInput,
330
+ runId: number,
331
+ primaryPlatforms: SocialProfilePlatform[],
332
+ editVersion: number,
333
+ submittedBrandAsset: BrandAssetState | null,
334
+ ): Promise<KitGenerationResult> {
335
+ let taskId: string | null = null;
336
+ let agentPending = false;
337
+ let agentError: string | undefined;
338
+
339
+ try {
340
+ const submitted = await submitSocialProfileKitGeneration(
341
+ input,
342
+ locale,
343
+ submittedBrandAsset?.referenceImageUrl
344
+ ? {
345
+ kind: submittedBrandAsset.kind,
346
+ name: submittedBrandAsset.name,
347
+ referenceImageUrl: submittedBrandAsset.referenceImageUrl,
348
+ }
349
+ : undefined,
350
+ );
351
+ taskId = submitted.taskId;
352
+ agentPending = true;
353
+ generationTaskIdRef.current = taskId;
354
+ const agentKit = await waitForAgentKit(
355
+ taskId as string,
356
+ () => runId === generationRunRef.current,
357
+ );
358
+ if (agentKit && isAgentKitUsable(input, agentKit)) {
359
+ return {
360
+ kit: applyBrandAssetToKit(agentKit, submittedBrandAsset),
361
+ status: "agent",
362
+ };
363
+ }
364
+ } catch (error) {
365
+ agentPending = false;
366
+ agentError =
367
+ error instanceof SocialProfileKitTaskError
368
+ ? error.message
369
+ : "The social profile kit agent did not return a usable result.";
370
+ }
371
+
372
+ if (taskId && agentPending) {
373
+ void (async () => {
374
+ try {
375
+ const agentKit = await waitForAgentKit(
376
+ taskId,
377
+ () => runId === generationRunRef.current,
378
+ 72,
379
+ );
380
+
381
+ if (!agentKit || !isAgentKitUsable(input, agentKit)) {
382
+ markBannerGenerationFailed(primaryPlatforms);
383
+ setGenerationState((current) => {
384
+ const next = { ...current };
385
+ for (const platform of primaryPlatforms) next[platform] = "failed";
386
+ return next;
387
+ });
388
+ return;
389
+ }
390
+ if (runId !== generationRunRef.current) return;
391
+ if (editVersion !== editVersionRef.current) return;
392
+
393
+ const agentKitWithAsset = applyBrandAssetToKit(agentKit, submittedBrandAsset);
394
+ pendingKitRef.current = agentKitWithAsset;
395
+ applyLateAgentKit(agentKitWithAsset);
396
+ setHasAgentResult(true);
397
+ setGenerationState((current) => {
398
+ const next = { ...current };
399
+ for (const platform of primaryPlatforms) {
400
+ if (
401
+ isGeneratedBannerPlatform(platform) &&
402
+ (current[platform] === "generating" || current[platform] === "failed")
403
+ ) {
404
+ continue;
405
+ }
406
+ next[platform] = "ready";
407
+ }
408
+ return next;
409
+ });
410
+ startBannerImageGeneration(agentKitWithAsset, taskId, runId, primaryPlatforms);
411
+ } catch {
412
+ markBannerGenerationFailed(primaryPlatforms);
413
+ setGenerationState((current) => {
414
+ const next = { ...current };
415
+ for (const platform of primaryPlatforms) next[platform] = "failed";
416
+ return next;
417
+ });
418
+ }
419
+ })();
420
+ }
421
+
422
+ return {
423
+ status: agentPending ? "pending" : "failed",
424
+ agentError,
425
+ };
426
+ }
427
+
428
+ async function generate() {
429
+ const normalizedForm = normalizeSocialProfileInputForSubmission({
430
+ ...form,
431
+ platforms: [...SOCIAL_PROFILE_V1_PLATFORMS],
432
+ theme,
433
+ });
434
+ const parsed = socialProfileInputSchema.safeParse({
435
+ ...normalizedForm,
436
+ platforms: [...SOCIAL_PROFILE_V1_PLATFORMS],
437
+ theme,
438
+ });
439
+
440
+ if (!parsed.success) {
441
+ return;
442
+ }
443
+
444
+ const primaryPlatforms = getPrimaryGenerationPlatforms(parsed.data.mode);
445
+ const runId = generationRunRef.current + 1;
446
+ const editVersion = editVersionRef.current;
447
+ generationRunRef.current = runId;
448
+ generationTaskIdRef.current = null;
449
+ bannerImageRunRef.current = new Set();
450
+ setBusy(true);
451
+ setEditing(null);
452
+ setSelected(null);
453
+ setActivePlatform(primaryPlatforms[0] ?? "x");
454
+ setZoom(1);
455
+ setZoomMode("auto");
456
+ setGenerationState(
457
+ nextPlatformGenerationStatus(
458
+ createQueuedGenerationState(primaryPlatforms),
459
+ primaryPlatforms[0] ?? "x",
460
+ "generating",
461
+ ),
462
+ );
463
+ setBannerGenerationState(createPlatformGenerationState("idle"));
464
+ let submittedBrandAsset: BrandAssetState | null = null;
465
+ try {
466
+ submittedBrandAsset = await ensureBrandAssetReference();
467
+ } catch {
468
+ submittedBrandAsset = brandAssetRef.current;
469
+ }
470
+
471
+ const result = await generateKitWithAgent(
472
+ parsed.data,
473
+ runId,
474
+ primaryPlatforms,
475
+ editVersion,
476
+ submittedBrandAsset,
477
+ );
478
+ if (runId !== generationRunRef.current) return;
479
+
480
+ const next = result.kit;
481
+ if (!next) {
482
+ setGenerationState((current) => {
483
+ const nextState = { ...current };
484
+ for (const platform of primaryPlatforms) {
485
+ nextState[platform] = result.status === "pending" ? "queued" : "failed";
486
+ }
487
+ return nextState;
488
+ });
489
+ if (result.status === "pending") {
490
+ markBannerGenerationQueued(
491
+ primaryPlatforms,
492
+ Boolean(generationTaskIdRef.current),
493
+ );
494
+ } else {
495
+ markBannerGenerationFailed(primaryPlatforms, true);
496
+ }
497
+ setBusy(false);
498
+ return;
499
+ }
500
+ pendingKitRef.current = next;
501
+ setHasAgentResult(true);
502
+ const startedBannerPlatforms = startBannerImageGeneration(
503
+ next,
504
+ generationTaskIdRef.current,
505
+ runId,
506
+ primaryPlatforms,
507
+ );
508
+
509
+ for (const platform of primaryPlatforms) {
510
+ if (runId !== generationRunRef.current) return;
511
+ await generatePlatform(platform, runId);
512
+ if (startedBannerPlatforms.has(platform)) {
513
+ setGenerationState((current) =>
514
+ nextPlatformGenerationStatus(current, platform, "ready"),
515
+ );
516
+ }
517
+ }
518
+
519
+ if (runId === generationRunRef.current) {
520
+ setBusy(false);
521
+ }
522
+ }
523
+
524
+ function markBannerGenerationQueued(
525
+ platforms: readonly SocialProfilePlatform[],
526
+ enabled: boolean,
527
+ ): Set<SocialProfilePlatform> {
528
+ if (!enabled) return new Set<SocialProfilePlatform>();
529
+ const targets = platforms.filter((platform) =>
530
+ isGeneratedBannerPlatform(platform),
531
+ );
532
+ if (targets.length === 0) return new Set<SocialProfilePlatform>();
533
+
534
+ setBannerGenerationState((current) => {
535
+ const next = { ...current };
536
+ for (const platform of targets) {
537
+ if (current[platform] !== "idle") continue;
538
+ next[platform] = "queued";
539
+ }
540
+ return next;
541
+ });
542
+
543
+ return new Set(targets);
544
+ }
545
+
546
+ function markBannerGenerationFailed(
547
+ platforms: readonly SocialProfilePlatform[],
548
+ enabled = true,
549
+ ): Set<SocialProfilePlatform> {
550
+ if (!enabled) return new Set<SocialProfilePlatform>();
551
+ const targets = platforms.filter((platform) =>
552
+ isGeneratedBannerPlatform(platform),
553
+ );
554
+ if (targets.length === 0) return new Set<SocialProfilePlatform>();
555
+
556
+ setBannerGenerationState((current) => {
557
+ const next = { ...current };
558
+ for (const platform of targets) {
559
+ next[platform] = "failed";
560
+ }
561
+ return next;
562
+ });
563
+
564
+ return new Set(targets);
565
+ }
566
+
567
+ function startBannerImageGeneration(
568
+ sourceKit: SocialProfileKitOutput,
569
+ parentTaskId: string | null,
570
+ runId: number,
571
+ platforms: readonly SocialProfilePlatform[],
572
+ ): Set<SocialProfilePlatform> {
573
+ const started = new Set<SocialProfilePlatform>();
574
+ if (!parentTaskId) return started;
575
+ const targets = platforms.filter((platform) =>
576
+ isGeneratedBannerPlatform(platform),
577
+ ) as Array<(typeof SOCIAL_PROFILE_GENERATED_BANNER_PLATFORMS)[number]>;
578
+ const pendingTargets = targets.filter((platform) => {
579
+ const banner = sourceKit.profiles[platform].banner;
580
+ if (!banner || banner.kind === "notApplicable") return false;
581
+ if (banner.kind === "uploaded") return false;
582
+ if (banner.src) return false;
583
+ return true;
584
+ });
585
+ if (pendingTargets.length === 0) return started;
586
+
587
+ const runKey = `${runId}:${parentTaskId}:master:${pendingTargets.join(",")}`;
588
+ if (bannerImageRunRef.current.has(runKey)) return started;
589
+ bannerImageRunRef.current.add(runKey);
590
+ for (const platform of pendingTargets) {
591
+ started.add(platform);
592
+ }
593
+
594
+ setBannerGenerationState((current) => {
595
+ let next = current;
596
+ for (const platform of pendingTargets) {
597
+ next = nextPlatformGenerationStatus(next, platform, "generating");
598
+ }
599
+ return next;
600
+ });
601
+
602
+ void (async () => {
603
+ let lastError: unknown = null;
604
+ try {
605
+ let result: Awaited<ReturnType<typeof generateSocialProfileMasterBannerImage>> | null =
606
+ null;
607
+
608
+ for (let attempt = 1; attempt <= BANNER_IMAGE_MAX_ATTEMPTS; attempt += 1) {
609
+ try {
610
+ result = await generateSocialProfileMasterBannerImage({
611
+ parentTaskId,
612
+ kit: sourceKit,
613
+ referenceImageUrls: brandAssetRef.current?.referenceImageUrl
614
+ ? [brandAssetRef.current.referenceImageUrl]
615
+ : [],
616
+ });
617
+ break;
618
+ } catch (error) {
619
+ lastError = error;
620
+ if (
621
+ attempt >= BANNER_IMAGE_MAX_ATTEMPTS ||
622
+ !isRetriableBannerImageError(error)
623
+ ) {
624
+ throw error;
625
+ }
626
+ }
627
+ }
628
+
629
+ if (!result) throw lastError ?? new Error("Master banner image generation failed");
630
+ if (runId !== generationRunRef.current) return;
631
+
632
+ setKit((current) => {
633
+ const profiles = { ...current.profiles };
634
+ for (const platform of pendingTargets) {
635
+ const currentProfile = profiles[platform];
636
+ if (!currentProfile.banner || currentProfile.banner.kind === "notApplicable") {
637
+ continue;
638
+ }
639
+ if (currentProfile.banner.kind === "uploaded") continue;
640
+ if (currentProfile.banner.src) continue;
641
+
642
+ profiles[platform] = {
643
+ ...currentProfile,
644
+ banner: {
645
+ ...currentProfile.banner,
646
+ kind: "generated",
647
+ generationMode: platform === pendingTargets[0] ? "generate" : "crop",
648
+ src: result.imageUrl,
649
+ prompt: result.prompt,
650
+ },
651
+ };
652
+ }
653
+ return { ...current, profiles };
654
+ });
655
+ setBannerGenerationState((current) => {
656
+ let next = current;
657
+ for (const platform of pendingTargets) {
658
+ next = nextPlatformGenerationStatus(next, platform, "ready");
659
+ }
660
+ return next;
661
+ });
662
+ } catch {
663
+ if (runId !== generationRunRef.current) return;
664
+ setBannerGenerationState((current) => {
665
+ let next = current;
666
+ for (const platform of pendingTargets) {
667
+ next = nextPlatformGenerationStatus(next, platform, "failed");
668
+ }
669
+ return next;
670
+ });
671
+ }
672
+ })();
673
+
674
+ return started;
675
+ }
676
+
677
+ function startPlatformBannerImageGeneration(
678
+ sourceKit: SocialProfileKitOutput,
679
+ parentTaskId: string | null,
680
+ runId: number,
681
+ platform: (typeof SOCIAL_PROFILE_GENERATED_BANNER_PLATFORMS)[number],
682
+ options: { force?: boolean } = {},
683
+ ): boolean {
684
+ if (!parentTaskId) return false;
685
+
686
+ const banner = sourceKit.profiles[platform].banner;
687
+ const runKey = `${runId}:${parentTaskId}:${platform}`;
688
+ if (!options.force && bannerImageRunRef.current.has(runKey)) return false;
689
+ if (!banner || banner.kind === "notApplicable") return false;
690
+ if (banner.kind === "uploaded") return false;
691
+ if (!options.force && banner.src) return false;
692
+
693
+ bannerImageRunRef.current.add(runKey);
694
+ setBannerGenerationState((current) =>
695
+ nextPlatformGenerationStatus(current, platform, "generating"),
696
+ );
697
+ void (async () => {
698
+ let lastError: unknown = null;
699
+ try {
700
+ let result: Awaited<ReturnType<typeof generateSocialProfileBannerImage>> | null =
701
+ null;
702
+
703
+ for (let attempt = 1; attempt <= BANNER_IMAGE_MAX_ATTEMPTS; attempt += 1) {
704
+ try {
705
+ result = await generateSocialProfileBannerImage({
706
+ parentTaskId,
707
+ kit: sourceKit,
708
+ platform,
709
+ referenceImageUrls: brandAssetRef.current?.referenceImageUrl
710
+ ? [brandAssetRef.current.referenceImageUrl]
711
+ : [],
712
+ });
713
+ break;
714
+ } catch (error) {
715
+ lastError = error;
716
+ if (
717
+ attempt >= BANNER_IMAGE_MAX_ATTEMPTS ||
718
+ !isRetriableBannerImageError(error)
719
+ ) {
720
+ throw error;
721
+ }
722
+ }
723
+ }
724
+
725
+ if (!result) throw lastError ?? new Error("Banner image generation failed");
726
+ if (runId !== generationRunRef.current) return;
727
+
728
+ updateProfile(platform, (current) => {
729
+ if (!current.banner || current.banner.kind === "notApplicable") return current;
730
+ if (current.banner.kind === "uploaded") return current;
731
+ if (!options.force && current.banner.src) return current;
732
+
733
+ return {
734
+ ...current,
735
+ banner: {
736
+ ...current.banner,
737
+ kind: "generated",
738
+ generationMode: "generate",
739
+ src: result.imageUrl,
740
+ prompt: result.prompt,
741
+ },
742
+ };
743
+ });
744
+ setBannerGenerationState((current) =>
745
+ nextPlatformGenerationStatus(current, platform, "ready"),
746
+ );
747
+ } catch {
748
+ if (runId !== generationRunRef.current) return;
749
+ setBannerGenerationState((current) =>
750
+ nextPlatformGenerationStatus(current, platform, "failed"),
751
+ );
752
+ // Real image generation is progressive; the editable preview remains usable.
753
+ }
754
+ })();
755
+ return true;
756
+ }
757
+
758
+ function retryActiveBanner() {
759
+ if (!isGeneratedBannerPlatform(activePlatform)) return;
760
+ if (bannerGenerationState[activePlatform] === "generating") return;
761
+ const parentTaskId = generationTaskIdRef.current;
762
+ const runId = generationRunRef.current;
763
+ const sourceKit = {
764
+ ...kit,
765
+ profiles: {
766
+ ...kit.profiles,
767
+ [activePlatform]: {
768
+ ...kit.profiles[activePlatform],
769
+ banner: kit.profiles[activePlatform].banner
770
+ ? {
771
+ ...kit.profiles[activePlatform].banner,
772
+ src: undefined,
773
+ }
774
+ : kit.profiles[activePlatform].banner,
775
+ },
776
+ },
777
+ };
778
+
779
+ startPlatformBannerImageGeneration(
780
+ sourceKit,
781
+ parentTaskId,
782
+ runId,
783
+ activePlatform as (typeof SOCIAL_PROFILE_GENERATED_BANNER_PLATFORMS)[number],
784
+ { force: true },
785
+ );
786
+ }
787
+
788
+ function updateProfile(
789
+ platform: SocialProfilePlatform,
790
+ updater: (
791
+ profile: SocialProfileKitOutput["profiles"][SocialProfilePlatform],
792
+ ) => SocialProfileKitOutput["profiles"][SocialProfilePlatform],
793
+ ) {
794
+ setKit((current) => ({
795
+ ...current,
796
+ profiles: {
797
+ ...current.profiles,
798
+ [platform]: updater(current.profiles[platform]),
799
+ },
800
+ }));
801
+ }
802
+
803
+ function updateText(field: EditableTextField, value: string) {
804
+ editVersionRef.current += 1;
805
+ updateProfile(activePlatform, (current) => ({
806
+ ...current,
807
+ [field]: value,
808
+ }));
809
+ }
810
+
811
+ async function copyText(_field: EditableTextField, value: string) {
812
+ try {
813
+ await navigator.clipboard.writeText(value);
814
+ } catch {
815
+ return;
816
+ }
817
+ }
818
+
819
+ async function uploadBrandAsset(file: File) {
820
+ if (!file.type.startsWith("image/")) return;
821
+ try {
822
+ const dataUrl = await readImageAsDataUrl(file);
823
+ const next: BrandAssetState = {
824
+ kind: form.mode === "brandCompany" ? "logo" : "avatar",
825
+ name: file.name,
826
+ dataUrl,
827
+ previewSrc: dataUrl,
828
+ };
829
+ brandAssetRef.current = next;
830
+ setBrandAsset(next);
831
+ editVersionRef.current += 1;
832
+ setKit((current) => applyBrandAssetToKit(current, next));
833
+ } catch {
834
+ return;
835
+ }
836
+ }
837
+
838
+ function removeBrandAsset() {
839
+ brandAssetRef.current = null;
840
+ setBrandAsset(null);
841
+ editVersionRef.current += 1;
842
+ setKit((current) => {
843
+ const profiles = { ...current.profiles };
844
+ for (const platform of SOCIAL_PROFILE_PLATFORMS) {
845
+ const currentAvatar = profiles[platform].avatar;
846
+ profiles[platform] = {
847
+ ...profiles[platform],
848
+ avatar: {
849
+ ...currentAvatar,
850
+ kind: "placeholder",
851
+ source: "placeholder",
852
+ generationMode: "placeholder",
853
+ isPlaceholderOnly: true,
854
+ src: undefined,
855
+ prompt: "Neutral initials placeholder; no image has been generated.",
856
+ },
857
+ };
858
+ }
859
+ return { ...current, profiles };
860
+ });
861
+ }
862
+
863
+ function uploadSelected(file: File) {
864
+ editVersionRef.current += 1;
865
+ const src = URL.createObjectURL(file);
866
+ updateProfile(activePlatform, (current) => {
867
+ if (selected?.kind === "avatar") {
868
+ return { ...current, avatar: { ...current.avatar, kind: "uploaded", src } };
869
+ }
870
+ if (selected?.kind === "banner" && current.banner) {
871
+ return {
872
+ ...current,
873
+ banner: { ...current.banner, kind: "uploaded", src },
874
+ };
875
+ }
876
+ return current;
877
+ });
878
+ }
879
+
880
+ function replaceColor() {
881
+ editVersionRef.current += 1;
882
+ updateProfile(activePlatform, (current) => ({
883
+ ...current,
884
+ colors: [...current.colors.slice(1), current.colors[0]],
885
+ }));
886
+ }
887
+
888
+ async function downloadSelected() {
889
+ if (selected?.kind === "avatar") {
890
+ const blob = await renderSelectedAssetPng({
891
+ profile,
892
+ src: profile.avatar.src,
893
+ width: profile.avatar.width,
894
+ height: profile.avatar.height,
895
+ fit: form.mode === "brandCompany" ? "contain" : "cover",
896
+ });
897
+ downloadBlob(blob, `${activePlatform}-avatar-${profile.avatar.width}x${profile.avatar.height}.png`);
898
+ return;
899
+ }
900
+
901
+ if (selected?.kind === "banner" && profile.banner && profile.banner.kind !== "notApplicable") {
902
+ const width = profile.banner.width ?? 1200;
903
+ const height = profile.banner.height ?? 400;
904
+ const blob = await renderSelectedAssetPng({
905
+ profile,
906
+ src: profile.banner.src,
907
+ width,
908
+ height,
909
+ fit: "cover",
910
+ });
911
+ downloadBlob(blob, `${activePlatform}-background-${width}x${height}.png`);
912
+ return;
913
+ }
914
+
915
+ await downloadPlatform(activePlatform);
916
+ }
917
+
918
+ async function downloadPlatform(platform = activePlatform) {
919
+ const zip = await buildSocialProfileKitZip(kit, { platforms: [platform] });
920
+ downloadBlob(zip, buildSocialProfileKitZipName(kit, platform));
921
+ }
922
+
923
+ async function downloadFullKit() {
924
+ const zip = await buildSocialProfileKitZip(kit);
925
+ downloadBlob(zip, buildSocialProfileKitZipName(kit));
926
+ }
927
+
928
+ function selectPlatform(platform: SocialProfilePlatform) {
929
+ setActivePlatform(platform);
930
+ setEditing(null);
931
+ setZoom(1);
932
+ setZoomMode("auto");
933
+ const spec = SOCIAL_PROFILE_PLATFORM_SPECS[platform];
934
+ if (!spec.supportsBanner && selected?.kind === "banner") {
935
+ setSelected(null);
936
+ }
937
+ if (generationState[platform] === "idle") {
938
+ void generatePlatform(platform);
939
+ }
940
+ }
941
+
942
+ function startEdit(field: EditableTextField, device: ProfilePreviewDevice) {
943
+ setEditing({ field, device });
944
+ }
945
+
946
+ return (
947
+ <section className="flex flex-col gap-6">
948
+ <div className="mx-auto max-w-2xl text-center">
949
+ <h2 className="text-3xl font-semibold tracking-tight text-foreground md:text-4xl">
950
+ {copy.title}
951
+ </h2>
952
+ <p className="mt-3 text-sm text-muted-foreground md:text-base">
953
+ {copy.subtitle}
954
+ </p>
955
+ </div>
956
+
957
+ <InputPanel
958
+ copy={copy}
959
+ value={{ ...form, theme }}
960
+ brandAsset={brandAsset}
961
+ busy={busy || hasPendingGeneration || hasPendingBannerGeneration}
962
+ onChange={(next) => {
963
+ editVersionRef.current += 1;
964
+ setForm(next);
965
+ setTheme(next.theme);
966
+ }}
967
+ onBrandAssetUpload={(file) => void uploadBrandAsset(file)}
968
+ onBrandAssetRemove={removeBrandAsset}
969
+ onGenerate={() => void generate()}
970
+ />
971
+
972
+ <div className="relative pb-24">
973
+ <p
974
+ className="mb-3 rounded-xl border border-border bg-card px-4 py-2.5 text-xs leading-5 text-muted-foreground"
975
+ role="status"
976
+ >
977
+ {hasAgentResult ? copy.status.generated : copy.status.defaultReady}
978
+ </p>
979
+ <ProfileCanvas
980
+ copy={copy}
981
+ platform={activePlatform}
982
+ profile={profile}
983
+ mode={form.mode}
984
+ theme={theme}
985
+ zoom={zoom}
986
+ zoomMode={zoomMode}
987
+ platformStatus={
988
+ bannerGenerationState[activePlatform] === "idle"
989
+ ? generationState[activePlatform]
990
+ : bannerGenerationState[activePlatform]
991
+ }
992
+ selected={selected}
993
+ editing={editing}
994
+ onThemeChange={setTheme}
995
+ onZoomChange={(nextZoom) => {
996
+ setZoom(nextZoom);
997
+ setZoomMode("manual");
998
+ }}
999
+ onAutoZoomChange={setZoom}
1000
+ onFitZoom={() => setZoomMode("auto")}
1001
+ onSelect={setSelected}
1002
+ onUpload={uploadSelected}
1003
+ onRetryBanner={retryActiveBanner}
1004
+ onDownloadSelected={downloadSelected}
1005
+ onDownloadPlatform={() => void downloadPlatform()}
1006
+ onReplaceColor={replaceColor}
1007
+ onCopyText={(field, value) => void copyText(field, value)}
1008
+ onStartEdit={startEdit}
1009
+ onStopEdit={() => setEditing(null)}
1010
+ onTextChange={updateText}
1011
+ />
1012
+
1013
+ <div className="sticky bottom-4 z-30 -mt-10 px-2">
1014
+ <div className="mx-auto flex max-w-5xl items-center justify-center gap-3">
1015
+ <PlatformDock
1016
+ copy={copy}
1017
+ activePlatform={activePlatform}
1018
+ generationState={generationState}
1019
+ bannerGenerationState={bannerGenerationState}
1020
+ onPlatformChange={selectPlatform}
1021
+ className="min-h-[104px] min-w-0 flex-1 basis-0 rounded-2xl bg-card/95 p-2 shadow-xl backdrop-blur"
1022
+ />
1023
+ <DropdownMenu>
1024
+ <DropdownMenuTrigger asChild>
1025
+ <Button
1026
+ type="button"
1027
+ variant="outline"
1028
+ className="h-[104px] shrink-0 rounded-2xl border bg-card/95 px-4 text-sm shadow-xl backdrop-blur"
1029
+ aria-label={copy.actions.downloadKit}
1030
+ >
1031
+ <Download className="size-4" />
1032
+ {copy.actions.downloadKit}
1033
+ </Button>
1034
+ </DropdownMenuTrigger>
1035
+ <DropdownMenuContent
1036
+ align="end"
1037
+ sideOffset={8}
1038
+ className="max-h-[min(60vh,420px)] w-56 overflow-y-auto"
1039
+ >
1040
+ {SOCIAL_PROFILE_PLATFORMS.map((platform) => (
1041
+ <DropdownMenuItem
1042
+ key={platform}
1043
+ onSelect={() => void downloadPlatform(platform)}
1044
+ >
1045
+ {copy.platforms[platform]}
1046
+ </DropdownMenuItem>
1047
+ ))}
1048
+ <DropdownMenuSeparator />
1049
+ <DropdownMenuItem onSelect={() => void downloadFullKit()}>
1050
+ {copy.actions.allPlatforms}
1051
+ </DropdownMenuItem>
1052
+ </DropdownMenuContent>
1053
+ </DropdownMenu>
1054
+ </div>
1055
+ </div>
1056
+ </div>
1057
+ </section>
1058
+ );
1059
+ }