@chaibuilder/sdk 4.0.0-beta.3 → 4.0.0-beta.30

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 (245) hide show
  1. package/README.md +72 -50
  2. package/dist/{2SSKDMRQ-CnSDkQcy.js → 2SSKDMRQ-B5Tzwoh4.js} +2 -2
  3. package/dist/{2SSKDMRQ-BnsZi3K3.cjs → 2SSKDMRQ-Dub3pRV1.cjs} +1 -1
  4. package/dist/{AP7HFJJL-CymCmW14.js → AP7HFJJL-CfmdXP9M.js} +1 -1
  5. package/dist/{AP7HFJJL-B31839PG.cjs → AP7HFJJL-Dt6MglIr.cjs} +1 -1
  6. package/dist/{IconPicker-B1rWC-Ex.js → IconPicker-Cn8Z42-Z.js} +8 -7
  7. package/dist/IconPicker-DLqOB-ri.cjs +1 -0
  8. package/dist/STRINGS-BExFecZW.js +8 -0
  9. package/dist/STRINGS-FNnfjF5H.cjs +1 -0
  10. package/dist/{WDYDFRGG-BUVnbAci.js → WDYDFRGG-BOpmZGHS.js} +2 -2
  11. package/dist/{WDYDFRGG-BxhOCHc3.cjs → WDYDFRGG-Dfj1ikzw.cjs} +1 -1
  12. package/dist/{actions-registery-CZ1w0NKa.js → actions-registery-Bj-j1k5i.js} +2668 -2585
  13. package/dist/actions-registery-Cy1lqUVI.cjs +481 -0
  14. package/dist/actions.cjs +1 -1
  15. package/dist/actions.d.ts +0 -158
  16. package/dist/actions.js +3 -3
  17. package/dist/active-in-another-tab-CEWvA8SG.js +35 -0
  18. package/dist/active-in-another-tab-DV83cJ_v.cjs +1 -0
  19. package/dist/{add-new-language-page-WmlCnytQ.js → add-new-language-page-B3wK94-S.js} +54 -53
  20. package/dist/add-new-language-page-C3Uu92KN.cjs +1 -0
  21. package/dist/{add-new-page-soZ8GAkN.cjs → add-new-page-BOE-xwBc.cjs} +1 -1
  22. package/dist/{add-new-page-VW2wAYZp.js → add-new-page-DsvGVrR8.js} +2 -2
  23. package/dist/{ai-panel-content-D_o7Q_A-.js → ai-panel-content-BBSzHZG6.js} +12 -11
  24. package/dist/ai-panel-content-DBlnfRRi.cjs +1 -0
  25. package/dist/ai-panel-default-lang-BVBuwnyU.js +317 -0
  26. package/dist/ai-panel-default-lang-DJJWAtN0.cjs +3 -0
  27. package/dist/ai-panel-other-lang-fIEZkmRy.js +132 -0
  28. package/dist/ai-panel-other-lang-v8Yd5ggR.cjs +1 -0
  29. package/dist/ai-prompt-input-C7ha_0Cn.cjs +1 -0
  30. package/dist/{ai-prompt-input-Bhc0ds7X.js → ai-prompt-input-CmSfGxTN.js} +70 -73
  31. package/dist/ai-translation-prompt-BzTGAS3W.cjs +1 -0
  32. package/dist/{ai-translation-prompt-CZ55HQmo.js → ai-translation-prompt-CtBmvsRy.js} +2 -2
  33. package/dist/apply-binding-9XSrYzAE.cjs +1 -0
  34. package/dist/{apply-binding-6iwlED02.js → apply-binding-chfbBKi2.js} +238 -225
  35. package/dist/change-password-modal-CdOwtCWN.cjs +1 -0
  36. package/dist/change-password-modal-DxkhBI5d.js +137 -0
  37. package/dist/code-display-BR-gij5j.cjs +1 -0
  38. package/dist/{code-display-DhD_RBcg.js → code-display-DdWcOQ_i.js} +1 -1
  39. package/dist/code-editor-Bpn8z2fo.js +57 -0
  40. package/dist/code-editor-fL3s6Hk7.cjs +1 -0
  41. package/dist/{continue-editing-in-this-client-CS2aQ7yY.js → continue-editing-in-this-client-DDB816CQ.js} +10 -9
  42. package/dist/continue-editing-in-this-client-DjxpjsA8.cjs +1 -0
  43. package/dist/core-BWQrViOY.cjs +1 -0
  44. package/dist/core-QlWEXm1d.js +53 -0
  45. package/dist/core.cjs +1 -1
  46. package/dist/core.d.ts +272 -105
  47. package/dist/core.js +64 -33
  48. package/dist/{css-import-modal-Byg6wV0O.js → css-import-modal-CL8SIC3K.js} +11 -9
  49. package/dist/css-import-modal-CRC7bK1c.cjs +13 -0
  50. package/dist/{delete-design-token-BRZZiWtQ.js → delete-design-token-B0md8qUi.js} +1 -1
  51. package/dist/{delete-design-token-DkVs1oBf.cjs → delete-design-token-C94IgWdi.cjs} +1 -1
  52. package/dist/delete-page-41tvYcEw.js +71 -0
  53. package/dist/delete-page-BHPlx8ec.cjs +1 -0
  54. package/dist/{design-token-usage-xQs6SlaJ.js → design-token-usage-CyOY4Pni.js} +19 -18
  55. package/dist/design-token-usage-DtdjTCn3.cjs +1 -0
  56. package/dist/{digital-asset-manager-DbtwzxRz.js → digital-asset-manager-C_ru4Zes.js} +6 -5
  57. package/dist/digital-asset-manager-DSLQz8qk.cjs +1 -0
  58. package/dist/duplicate-page-BvggF83O.cjs +1 -0
  59. package/dist/{duplicate-page-BR7Dlo9d.js → duplicate-page-DMmDdmfS.js} +20 -19
  60. package/dist/dynamic-page-selector-C5agz2Ze.cjs +1 -0
  61. package/dist/{dynamic-page-selector-Cb5r_W8s.js → dynamic-page-selector-D2z51nLi.js} +12 -11
  62. package/dist/fonts/bungee/Bungee-Regular.woff2 +0 -0
  63. package/dist/fonts/dm_sans/dm-sans-variable.woff2 +0 -0
  64. package/dist/fonts/geist/Geist-VariableFont_wght.ttf +0 -0
  65. package/dist/fonts/geist/Geist-VariableFont_wght.woff2 +0 -0
  66. package/dist/fonts/geist/geist-variable.woff2 +0 -0
  67. package/dist/fonts/geist-mono/GeistMono-VariableFont_wght.woff2 +0 -0
  68. package/dist/fonts/inter/inter-latin.woff2 +0 -0
  69. package/dist/fonts/inter/inter-variable.woff2 +1449 -0
  70. package/dist/fonts/lato/lato-variable.woff2 +0 -0
  71. package/dist/fonts/lavishly_yours/lavishly-yours.woff2 +11 -0
  72. package/dist/fonts/merriweather/merriweather-variable.woff2 +11 -0
  73. package/dist/fonts/montserrat/montserrat-variable.woff2 +0 -0
  74. package/dist/fonts/nunito_sans/nunito-sans-variable.woff2 +11 -0
  75. package/dist/fonts/open_sans/open-sans-variable.woff2 +0 -0
  76. package/dist/fonts/oswald/oswald-variable.woff2 +0 -0
  77. package/dist/fonts/playfair_display/playfair-display-variable.woff2 +11 -0
  78. package/dist/fonts/poppins/poppins-variable.woff2 +0 -0
  79. package/dist/fonts/raleway/raleway-variable.woff2 +0 -0
  80. package/dist/fonts/roboto/roboto-variable.woff2 +11 -0
  81. package/dist/fonts/source_sans_3/source-sans-3-variable.woff2 +11 -0
  82. package/dist/fonts/ubuntu/ubuntu-variable.woff2 +0 -0
  83. package/dist/fonts-B3UYxuJI.js +25 -0
  84. package/dist/fonts-D5fTqvSS.cjs +1 -0
  85. package/dist/get-chai-builder-tailwind-config-DNp8Vhme.cjs +1 -0
  86. package/dist/{get-chai-builder-tailwind-config-DjoVOuAf.js → get-chai-builder-tailwind-config-k8l5sdcw.js} +5 -5
  87. package/dist/{get-chai-builder-theme-Dl72X7cz.cjs → get-chai-builder-theme-B5RkBTsB.cjs} +1 -1
  88. package/dist/{get-chai-builder-theme-BYtp20KD.js → get-chai-builder-theme-BSUcPs5t.js} +1 -1
  89. package/dist/{image-editor-G-K28aTS.cjs → image-editor-DFmlG348.cjs} +1 -1
  90. package/dist/{image-editor-DV8kUKhl.js → image-editor-sKvOFo-S.js} +1 -1
  91. package/dist/{index-Ct7ElCGK.js → index-BFnMzGe6.js} +5381 -5895
  92. package/dist/index-Bzn_gpaK.cjs +5 -0
  93. package/dist/index-CA1OwKJX.js +4887 -0
  94. package/dist/index-D30xvFa5.cjs +160 -0
  95. package/dist/{json-diff-viewer-krslPepD.js → json-diff-viewer-B5wAR5GY.js} +82 -79
  96. package/dist/json-diff-viewer-DRQSNhaS.cjs +8 -0
  97. package/dist/lang-panel-BZsICcBR.cjs +1 -0
  98. package/dist/{lang-panel-BwIewMyw.js → lang-panel-q04hEq5o.js} +15 -14
  99. package/dist/library-blocks/blocks-list.json +16 -0
  100. package/dist/library-blocks/hero-1/hero-1.html +74 -0
  101. package/dist/library-blocks/hero-1/hero-1.webp +0 -0
  102. package/dist/library-blocks/hero-2/hero-2.html +95 -0
  103. package/dist/library-blocks/hero-2/hero-2.webp +0 -0
  104. package/dist/{manage-design-tokens-Caz_20VK.js → manage-design-tokens-Cene3KEu.js} +16 -15
  105. package/dist/manage-design-tokens-Di5C6nTj.cjs +1 -0
  106. package/dist/mark-as-template-CT-hLGIW.cjs +1 -0
  107. package/dist/{mark-as-template-D295ZQtU.js → mark-as-template-raTtKmQ9.js} +17 -16
  108. package/dist/nested-path-selector-content-CSUHTj9G.cjs +1 -0
  109. package/dist/{nested-path-selector-content-CKYYK-C5.js → nested-path-selector-content-CzQ2Lorl.js} +24 -23
  110. package/dist/{no-language-page-content-BvqRBP6y.js → no-language-page-content-Bg6VjMVY.js} +8 -7
  111. package/dist/no-language-page-content-Bkj8JpEY.cjs +1 -0
  112. package/dist/{no-language-page-dialog-PjNqTUpl.js → no-language-page-dialog-CRPMr9YT.js} +2 -2
  113. package/dist/{no-language-page-dialog-BcEoqyQB.cjs → no-language-page-dialog-TffLjvJn.cjs} +1 -1
  114. package/dist/{page-creator-DiOITEMw.js → page-creator-CQhE1tgn.js} +147 -146
  115. package/dist/page-creator-RrUhy8uH.cjs +1 -0
  116. package/dist/{page-lock-BdYmCks0.cjs → page-lock-D9h5pgxn.cjs} +1 -1
  117. package/dist/{page-lock-Bfbs6RgL.js → page-lock-Dye1JZBB.js} +2 -2
  118. package/dist/{page-locked-dialog-B6MKTRfY.js → page-locked-dialog-BMjPVyHF.js} +19 -16
  119. package/dist/page-locked-dialog-b2_f-A7a.cjs +1 -0
  120. package/dist/page-manager-new-2mDjnSqc.cjs +1 -0
  121. package/dist/page-manager-new-DP1b_dXt.js +411 -0
  122. package/dist/page-manager-search-and-filter-D0ZXojiu.cjs +1 -0
  123. package/dist/{page-manager-search-and-filter-CM0UMb6U.js → page-manager-search-and-filter-DCcYyoPO.js} +20 -19
  124. package/dist/page-revisions-content-BX8ZWebc.cjs +1 -0
  125. package/dist/{page-revisions-content-NH9JK4Ey.js → page-revisions-content-mDwvH6J-.js} +134 -120
  126. package/dist/pages.cjs +1 -1
  127. package/dist/pages.d.ts +297 -97
  128. package/dist/pages.js +22 -19
  129. package/dist/plugin-DHpuZZXz.cjs +22 -0
  130. package/dist/plugin-Dkmjb2_e.js +248 -0
  131. package/dist/publish-pages-content-CR4e9inX.cjs +1 -0
  132. package/dist/{publish-pages-content-D9aixMN5.js → publish-pages-content-M_Kb8b-F.js} +71 -70
  133. package/dist/register-chai-top-bar-D6GjnauV.js +237 -0
  134. package/dist/register-chai-top-bar-DyW9GPzV.cjs +1 -0
  135. package/dist/render.cjs +2 -2
  136. package/dist/render.d.ts +21 -20
  137. package/dist/render.js +127 -120
  138. package/dist/rte-widget-modal-BRSm1Lnp.cjs +1 -0
  139. package/dist/{rte-widget-modal-DOJEXLIf.js → rte-widget-modal-CVZDktXI.js} +10 -9
  140. package/dist/runtime-client.cjs +1 -0
  141. package/dist/runtime-client.d.ts +158 -0
  142. package/dist/runtime-client.js +32 -0
  143. package/dist/runtime.cjs +11 -1
  144. package/dist/runtime.d.ts +158 -114
  145. package/dist/runtime.js +107 -42
  146. package/dist/{save-to-lib-eiOc_SSN.js → save-to-lib-B1ccNhR2.js} +152 -145
  147. package/dist/save-to-lib-CYEAWxL9.cjs +1 -0
  148. package/dist/sdk.css +1 -1
  149. package/dist/selected-block-display-MyU0rS4q.cjs +16 -0
  150. package/dist/{selected-block-display-CBFePS19.js → selected-block-display-aGR7p5JC.js} +36 -35
  151. package/dist/seo-panel-B5mDwpaT.cjs +2 -0
  152. package/dist/{seo-panel-C1-iMOR1.js → seo-panel-P9uixkoZ.js} +149 -148
  153. package/dist/{shared-json-ld-B4PxAM_0.js → shared-json-ld-Ba9GcvLr.js} +72 -71
  154. package/dist/shared-json-ld-DhQJh_mT.cjs +1 -0
  155. package/dist/slug-input-BdMnlYKT.cjs +1 -0
  156. package/dist/{slug-input-AwNJs9im.js → slug-input-CAfGHqMW.js} +9 -8
  157. package/dist/supabase-actions.cjs +1 -1
  158. package/dist/supabase-actions.d.ts +40 -1
  159. package/dist/supabase-actions.js +231 -192
  160. package/dist/take-over-request-BeHTL28z.cjs +1 -0
  161. package/dist/{take-over-request-C4FeDtN_.js → take-over-request-CXjaDliJ.js} +18 -17
  162. package/dist/theme-panel-footer-BkwhuXM7.js +26 -0
  163. package/dist/theme-panel-footer-D_gxD0j4.cjs +1 -0
  164. package/dist/{translation-warning-modal-B64YqlbI.js → translation-warning-modal-CTfArsb1.js} +11 -10
  165. package/dist/translation-warning-modal-D_vt37fW.cjs +1 -0
  166. package/dist/types.cjs +1 -0
  167. package/dist/types.d.ts +740 -0
  168. package/dist/types.js +1 -0
  169. package/dist/unmark-as-template-D2bvjGKt.cjs +1 -0
  170. package/dist/{unmark-as-template-CZ9sQp_P.js → unmark-as-template-vFgMIdxN.js} +12 -11
  171. package/dist/unpublish-page-CPjHmtSM.cjs +1 -0
  172. package/dist/unpublish-page-CxkjTzBB.js +28 -0
  173. package/dist/utils.cjs +1 -1
  174. package/dist/utils.d.ts +8 -5
  175. package/dist/utils.js +2 -2
  176. package/dist/web-blocks.cjs +1 -1
  177. package/dist/web-blocks.js +341 -332
  178. package/dist/{web-preview-Djy6WIyj.js → web-preview--by73Vvr.js} +2 -2
  179. package/dist/web-preview-C3AMe_BB.cjs +1 -0
  180. package/package.json +36 -31
  181. package/dist/IconPicker-DREyo007.cjs +0 -1
  182. package/dist/actions-registery-YnFmU21O.cjs +0 -418
  183. package/dist/active-in-another-tab-B47YjQGN.cjs +0 -1
  184. package/dist/active-in-another-tab-CyjngVA6.js +0 -34
  185. package/dist/add-new-language-page-88xzrUy8.cjs +0 -1
  186. package/dist/ai-panel-content-7zCil042.cjs +0 -1
  187. package/dist/ai-panel-default-lang-COYaxNwn.cjs +0 -3
  188. package/dist/ai-panel-default-lang-DnElspF0.js +0 -341
  189. package/dist/ai-panel-other-lang-CkynNlAU.cjs +0 -1
  190. package/dist/ai-panel-other-lang-Dp0E9_Hx.js +0 -162
  191. package/dist/ai-prompt-input-CThbVp0_.cjs +0 -1
  192. package/dist/ai-translation-prompt-C2kJQFDX.cjs +0 -1
  193. package/dist/apply-binding-KKp5PnpZ.cjs +0 -1
  194. package/dist/code-display-BnqzqzoP.cjs +0 -1
  195. package/dist/code-editor-DRIAnNbb.js +0 -50
  196. package/dist/code-editor-o3___nu2.cjs +0 -1
  197. package/dist/continue-editing-in-this-client-CtMYsk-A.cjs +0 -1
  198. package/dist/core-BoRDjj4h.cjs +0 -1
  199. package/dist/core-yvI6kCyw.js +0 -56
  200. package/dist/css-import-modal-CyqkXWCO.cjs +0 -13
  201. package/dist/delete-page-BzyX9TN-.js +0 -70
  202. package/dist/delete-page-DxX7PFIE.cjs +0 -1
  203. package/dist/design-token-usage-CAHzEGgJ.cjs +0 -1
  204. package/dist/digital-asset-manager--uO8Agia.cjs +0 -1
  205. package/dist/duplicate-page-CaNAbXwV.cjs +0 -1
  206. package/dist/dynamic-page-selector-Cxk_gjni.cjs +0 -1
  207. package/dist/fonts/GeistMonoVF.woff +0 -0
  208. package/dist/fonts/GeistVF.woff +0 -0
  209. package/dist/fonts-B-Xt29pe.cjs +0 -1
  210. package/dist/fonts-DRly3Wzd.js +0 -78
  211. package/dist/get-chai-builder-tailwind-config-B9rCyiQo.cjs +0 -1
  212. package/dist/index-B-rSiAp_.cjs +0 -1
  213. package/dist/index-DF5DEvqb.cjs +0 -160
  214. package/dist/index-Dxfyt4d4.js +0 -39
  215. package/dist/index-WQwzsC7A.cjs +0 -5
  216. package/dist/index-ZuacEL1j.js +0 -4732
  217. package/dist/json-diff-viewer-D7z4zNvv.cjs +0 -8
  218. package/dist/lang-panel-DT96k1xg.cjs +0 -1
  219. package/dist/manage-design-tokens-CrmLe7UT.cjs +0 -1
  220. package/dist/mark-as-template-W3LmpiqN.cjs +0 -1
  221. package/dist/nested-path-selector-content-CoS_d3dc.cjs +0 -1
  222. package/dist/no-language-page-content-DkfeMl90.cjs +0 -1
  223. package/dist/page-creator-C4gc5NSC.cjs +0 -1
  224. package/dist/page-locked-dialog-B1FAtK92.cjs +0 -1
  225. package/dist/page-manager-new-CHDueBDk.cjs +0 -1
  226. package/dist/page-manager-new-CzX22g2n.js +0 -394
  227. package/dist/page-manager-search-and-filter-DkkRIH86.cjs +0 -1
  228. package/dist/page-revisions-content-ChY-4f2V.cjs +0 -1
  229. package/dist/plugin-3ZKK6RXm.js +0 -245
  230. package/dist/plugin-C6rgJDNQ.cjs +0 -22
  231. package/dist/publish-pages-content-x-JuSFJ9.cjs +0 -1
  232. package/dist/rte-widget-modal-BaHIuEjF.cjs +0 -1
  233. package/dist/save-to-lib-Cgpxw8-g.cjs +0 -1
  234. package/dist/selected-block-display-BgRY82CT.cjs +0 -16
  235. package/dist/seo-panel-DfAb8U7W.cjs +0 -2
  236. package/dist/shared-json-ld-DzG398hr.cjs +0 -1
  237. package/dist/slug-input-C_ijLQ_X.cjs +0 -1
  238. package/dist/take-over-request-BNxcjY2j.cjs +0 -1
  239. package/dist/theme-panel-footer-Cq9pljro.cjs +0 -1
  240. package/dist/theme-panel-footer-uBQqSJXm.js +0 -25
  241. package/dist/translation-warning-modal-BZAcwM2_.cjs +0 -1
  242. package/dist/unmark-as-template-EVvk0vmp.cjs +0 -1
  243. package/dist/unpublish-page-D4VwOlxc.js +0 -27
  244. package/dist/unpublish-page-bdSmwAVQ.cjs +0 -1
  245. package/dist/web-preview-Cio70gk5.cjs +0 -1
@@ -0,0 +1,16 @@
1
+ "use strict";const o=require("react/jsx-runtime"),r=require("./register-chai-top-bar-DyW9GPzV.cjs"),m=require("lucide-react"),i=require("react"),p=require("use-stick-to-bottom"),T=require("streamdown");require("@radix-ui/react-slot");const P=require("class-variance-authority"),_=require("./index-D30xvFa5.cjs");require("clsx");require("tailwind-merge");const z=require("@radix-ui/react-tooltip"),j=require("@radix-ui/react-use-controllable-state"),B=require("@radix-ui/react-collapsible"),D=require("framer-motion"),f=require("./index-Bzn_gpaK.cjs"),I=require("react-i18next");function h(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const s in e)if(s!=="default"){const n=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,n.get?n:{enumerable:!0,get:()=>e[s]})}}return t.default=e,Object.freeze(t)}const L=h(i),S=h(z),b=h(B),G=({className:e,...t})=>o.jsx(p.StickToBottom,{className:r.cn("relative flex-1 overflow-y-hidden",e),initial:"smooth",resize:"smooth",role:"log",...t}),$=({className:e,...t})=>o.jsx(p.StickToBottom.Content,{className:r.cn("flex flex-col gap-8 p-4",e),...t}),F=({className:e,title:t="No messages yet",description:s="Start a conversation to see messages here",icon:n,children:a,...l})=>o.jsx("div",{className:r.cn("flex size-full flex-col items-center justify-center gap-3 p-8 text-center",e),...l,children:a??o.jsxs(o.Fragment,{children:[n&&o.jsx("div",{className:"text-muted-foreground",children:n}),o.jsxs("div",{className:"space-y-1",children:[o.jsx("h3",{className:"text-sm font-medium",children:t}),s&&o.jsx("p",{className:"text-sm text-muted-foreground",children:s})]})]})}),Q=({className:e,...t})=>{const{isAtBottom:s,scrollToBottom:n}=p.useStickToBottomContext(),a=i.useCallback(()=>{n()},[n]);return!s&&o.jsx(r.Button,{className:r.cn("absolute bottom-4 left-[50%] translate-x-[-50%] rounded-full",e),onClick:a,size:"icon",type:"button",variant:"outline",...t,children:o.jsx(m.ArrowDownIcon,{className:"size-4"})})};P.cva("flex w-fit items-stretch has-[>[data-slot=button-group]]:gap-2 [&>*]:focus-visible:relative [&>*]:focus-visible:z-10 has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-r-md [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1",{variants:{orientation:{horizontal:"[&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0 [&>*:not(:last-child)]:rounded-r-none",vertical:"flex-col [&>*:not(:first-child)]:rounded-t-none [&>*:not(:first-child)]:border-t-0 [&>*:not(:last-child)]:rounded-b-none"}},defaultVariants:{orientation:"horizontal"}});const V=L.forwardRef(({className:e,sideOffset:t=4,...s},n)=>o.jsx(S.Content,{ref:n,sideOffset:t,className:r.cn("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-tooltip-content-transform-origin]",e),...s}));V.displayName=S.Content.displayName;const K=({className:e,from:t,...s})=>o.jsx("div",{className:r.cn("group flex w-full max-w-[80%] flex-col gap-2",t==="user"?"is-user ml-auto justify-end":"is-assistant",e),...s}),Y=({children:e,className:t,...s})=>o.jsx("div",{className:r.cn("is-user:dark flex w-fit flex-col gap-2 overflow-hidden text-sm","group-[.is-user]:ml-auto group-[.is-user]:rounded-lg group-[.is-user]:bg-secondary group-[.is-user]:px-4 group-[.is-user]:py-3 group-[.is-user]:text-foreground","group-[.is-assistant]:text-foreground",t),...s,children:e});i.createContext(null);const w=i.memo(({className:e,...t})=>o.jsx(T.Streamdown,{className:r.cn("size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",e),...t}),(e,t)=>e.children===t.children);w.displayName="MessageResponse";const J=b.Root,X=b.CollapsibleTrigger,H=b.CollapsibleContent,W=({children:e,as:t="p",className:s,duration:n=2,spread:a=2})=>{const l=D.motion.create(t),g=i.useMemo(()=>((e==null?void 0:e.length)??0)*a,[e,a]);return o.jsx(l,{animate:{backgroundPosition:"0% center"},className:r.cn("relative inline-block bg-[length:250%_100%,auto] bg-clip-text text-transparent","[--bg:linear-gradient(90deg,#0000_calc(50%-var(--spread)),var(--color-background),#0000_calc(50%+var(--spread)))] [background-repeat:no-repeat,padding-box]",s),initial:{backgroundPosition:"100% center"},style:{"--spread":`${g}px`,backgroundImage:"var(--bg), linear-gradient(var(--color-muted-foreground), var(--color-muted-foreground))"},transition:{repeat:Number.POSITIVE_INFINITY,duration:n,ease:"linear"},children:e})},E=i.memo(W),R=i.createContext(null),Z=()=>{const e=i.useContext(R);if(!e)throw new Error("Reasoning components must be used within Reasoning");return e},ee=1e3,te=1e3,y=i.memo(({className:e,isStreaming:t=!1,open:s,defaultOpen:n=!0,onOpenChange:a,duration:l,children:g,...U})=>{const[c,d]=j.useControllableState({prop:s,defaultProp:n,onChange:a}),[M,v]=j.useControllableState({prop:l,defaultProp:void 0}),[N,q]=i.useState(!1),[u,C]=i.useState(null);i.useEffect(()=>{t?u===null&&C(Date.now()):u!==null&&(v(Math.ceil((Date.now()-u)/te)),C(null))},[t,u,v]),i.useEffect(()=>{if(n&&!t&&c&&!N){const x=setTimeout(()=>{d(!1),q(!0)},ee);return()=>clearTimeout(x)}},[t,c,n,d,N]);const O=x=>{d(x)};return o.jsx(R.Provider,{value:{isStreaming:t,isOpen:c,setIsOpen:d,duration:M},children:o.jsx(J,{className:r.cn("not-prose mb-4",e),onOpenChange:O,open:c,...U,children:g})})}),oe=(e,t)=>e||t===0?o.jsx(E,{duration:1,children:"Thinking..."}):t===void 0?o.jsx("p",{children:"Thought for a few seconds"}):o.jsxs("p",{children:["Thought for ",t," seconds"]}),A=i.memo(({className:e,children:t,...s})=>{const{isStreaming:n,isOpen:a,duration:l}=Z();return o.jsx(X,{className:r.cn("flex w-full items-center gap-2 text-sm text-muted-foreground transition-colors hover:text-foreground",e),...s,children:t??o.jsxs(o.Fragment,{children:[o.jsx(m.BrainIcon,{className:"size-4"}),oe(n,l),o.jsx(m.ChevronDownIcon,{className:r.cn("size-4 transition-transform",a?"rotate-180":"rotate-0")})]})})}),k=i.memo(({className:e,children:t,...s})=>o.jsx(H,{className:r.cn("mt-4 text-sm","text-muted-foreground outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2",e),...s,children:o.jsx(T.Streamdown,{...s,children:t})}));y.displayName="Reasoning";A.displayName="ReasoningTrigger";k.displayName="ReasoningContent";const se=({className:e,content:t,isLoading:s=!1,...n})=>o.jsx("div",{className:r.cn("is-assistant flex w-full max-w-[80%] flex-col gap-2",e),...n,children:o.jsx("div",{className:"flex w-fit flex-col gap-2 overflow-hidden text-sm",children:o.jsx("div",{className:"flex items-center gap-2 rounded-lg border border-muted-foreground/20 bg-muted/50 p-3",children:o.jsxs("div",{className:"flex flex-1 items-center gap-2",children:[s&&o.jsx(E,{duration:1.5,children:t}),!s&&o.jsx("div",{className:"text-xs text-muted-foreground",children:t})]})})})});function ne({userInput:e,language:t="en",currentHtml:s}){const n=f.LANGUAGES[t]||"English";return s&&s.trim().length>0?`
2
+ MODE: EDIT
3
+ CURRENT HTML:
4
+ ${s}
5
+
6
+ USER REQUEST: ${e}
7
+ Use ${n} language.
8
+ `.trim():`
9
+ USER REQUEST: ${e}
10
+ Use ${n} language.
11
+ `.trim()}function re({fallbackLang:e,language:t,blocks:s=[],userInput:n}){const a=f.LANGUAGES[t]||"English";return`
12
+ USER REQUEST: ${n||"Translate the content"}
13
+ LANGUAGE TO TRANSLATE: ${a}
14
+ REQUESTED TRANSLATION LANGUAGE CODE: ${t}
15
+ FALLBACK LANGUAGE: ${f.LANGUAGES[e]}
16
+ BLOCKS: ${JSON.stringify(s)}`.trim()}const ae=({onRemove:e,isLoading:t=!1})=>{const{t:s}=I.useTranslation(),n=_.useSelectedBlock(),a=(n==null?void 0:n._type)||"Unknown",l=(n==null?void 0:n._name)||a;return o.jsx(o.Fragment,{children:o.jsxs("div",{className:"mx-auto flex w-[95%] items-center justify-between rounded-t-md border border-b-0 border-blue-200 bg-blue-50",children:[o.jsxs("div",{className:"flex items-center",children:[o.jsx("div",{className:"flex h-6 w-6 items-center justify-center rounded-l rounded-bl-none bg-blue-500 text-xs font-semibold text-white",children:"@"}),o.jsx("div",{className:"flex w-[95%] flex-col",children:n?o.jsx(o.Fragment,{children:o.jsxs("span",{className:"truncate text-xs font-medium text-blue-900",children:[" ",s("Context: ")," ",l]})}):o.jsxs("span",{className:"text-xs font-medium text-blue-900",children:[" ",s("Context: Entire Page")]})})]}),n&&o.jsx(r.Button,{variant:"ghost",size:"icon",onClick:e,disabled:t,className:"h-6 w-6 text-blue-600 hover:bg-blue-100 hover:text-blue-800",title:"Remove block from context",children:o.jsx(m.X,{size:14})})]})})};exports.Conversation=G;exports.ConversationContent=$;exports.ConversationEmptyState=F;exports.ConversationScrollButton=Q;exports.Message=K;exports.MessageContent=Y;exports.MessageResponse=w;exports.Reasoning=y;exports.ReasoningContent=k;exports.ReasoningTrigger=A;exports.SelectedBlockDisplay=ae;exports.TaskMessage=se;exports.getTranslationUserPrompt=re;exports.getUserPrompt=ne;
@@ -1,21 +1,22 @@
1
1
  import { jsx as o, jsxs as l, Fragment as f } from "react/jsx-runtime";
2
- import { ag as r, B as E, as as O } from "./index-Ct7ElCGK.js";
3
- import { ArrowDownIcon as D, BrainIcon as P, ChevronDownIcon as $, X as B } from "lucide-react";
4
- import * as _ from "react";
5
- import { useCallback as G, memo as d, createContext as S, useMemo as j, useState as C, useEffect as T, useContext as Q } from "react";
6
- import { StickToBottom as R, useStickToBottomContext as F } from "use-stick-to-bottom";
2
+ import { E as r, B as E } from "./register-chai-top-bar-D6GjnauV.js";
3
+ import { ArrowDownIcon as O, BrainIcon as D, ChevronDownIcon as P, X as $ } from "lucide-react";
4
+ import * as B from "react";
5
+ import { useCallback as _, memo as d, createContext as S, useMemo as G, useState as C, useEffect as T, useContext as j } from "react";
6
+ import { StickToBottom as R, useStickToBottomContext as Q } from "use-stick-to-bottom";
7
7
  import { Streamdown as y } from "streamdown";
8
8
  import "@radix-ui/react-slot";
9
- import { cva as K } from "class-variance-authority";
9
+ import { cva as F } from "class-variance-authority";
10
+ import { a1 as K } from "./index-BFnMzGe6.js";
10
11
  import "clsx";
11
12
  import "tailwind-merge";
12
13
  import * as A from "@radix-ui/react-tooltip";
13
14
  import { useControllableState as w } from "@radix-ui/react-use-controllable-state";
14
15
  import * as x from "@radix-ui/react-collapsible";
15
16
  import { motion as V } from "framer-motion";
16
- import { L as h } from "./index-ZuacEL1j.js";
17
+ import { L as h } from "./index-CA1OwKJX.js";
17
18
  import { useTranslation as Y } from "react-i18next";
18
- const Ce = ({ className: e, ...t }) => /* @__PURE__ */ o(
19
+ const Te = ({ className: e, ...t }) => /* @__PURE__ */ o(
19
20
  R,
20
21
  {
21
22
  className: r("relative flex-1 overflow-y-hidden", e),
@@ -24,7 +25,7 @@ const Ce = ({ className: e, ...t }) => /* @__PURE__ */ o(
24
25
  role: "log",
25
26
  ...t
26
27
  }
27
- ), Te = ({ className: e, ...t }) => /* @__PURE__ */ o(R.Content, { className: r("flex flex-col gap-8 p-4", e), ...t }), we = ({
28
+ ), we = ({ className: e, ...t }) => /* @__PURE__ */ o(R.Content, { className: r("flex flex-col gap-8 p-4", e), ...t }), Ee = ({
28
29
  className: e,
29
30
  title: t = "No messages yet",
30
31
  description: s = "Start a conversation to see messages here",
@@ -44,8 +45,8 @@ const Ce = ({ className: e, ...t }) => /* @__PURE__ */ o(
44
45
  ] })
45
46
  ] })
46
47
  }
47
- ), Ee = ({ className: e, ...t }) => {
48
- const { isAtBottom: s, scrollToBottom: n } = F(), a = G(() => {
48
+ ), Se = ({ className: e, ...t }) => {
49
+ const { isAtBottom: s, scrollToBottom: n } = Q(), a = _(() => {
49
50
  n();
50
51
  }, [n]);
51
52
  return !s && /* @__PURE__ */ o(
@@ -57,11 +58,11 @@ const Ce = ({ className: e, ...t }) => /* @__PURE__ */ o(
57
58
  type: "button",
58
59
  variant: "outline",
59
60
  ...t,
60
- children: /* @__PURE__ */ o(D, { className: "size-4" })
61
+ children: /* @__PURE__ */ o(O, { className: "size-4" })
61
62
  }
62
63
  );
63
64
  };
64
- K(
65
+ F(
65
66
  "flex w-fit items-stretch has-[>[data-slot=button-group]]:gap-2 [&>*]:focus-visible:relative [&>*]:focus-visible:z-10 has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-r-md [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1",
66
67
  {
67
68
  variants: {
@@ -75,7 +76,7 @@ K(
75
76
  }
76
77
  }
77
78
  );
78
- const J = _.forwardRef(({ className: e, sideOffset: t = 4, ...s }, n) => /* @__PURE__ */ o(
79
+ const J = B.forwardRef(({ className: e, sideOffset: t = 4, ...s }, n) => /* @__PURE__ */ o(
79
80
  A.Content,
80
81
  {
81
82
  ref: n,
@@ -88,7 +89,7 @@ const J = _.forwardRef(({ className: e, sideOffset: t = 4, ...s }, n) => /* @__P
88
89
  }
89
90
  ));
90
91
  J.displayName = A.Content.displayName;
91
- const Se = ({ className: e, from: t, ...s }) => /* @__PURE__ */ o(
92
+ const Re = ({ className: e, from: t, ...s }) => /* @__PURE__ */ o(
92
93
  "div",
93
94
  {
94
95
  className: r(
@@ -98,7 +99,7 @@ const Se = ({ className: e, from: t, ...s }) => /* @__PURE__ */ o(
98
99
  ),
99
100
  ...s
100
101
  }
101
- ), Re = ({ children: e, className: t, ...s }) => /* @__PURE__ */ o(
102
+ ), ye = ({ children: e, className: t, ...s }) => /* @__PURE__ */ o(
102
103
  "div",
103
104
  {
104
105
  className: r(
@@ -126,7 +127,7 @@ const q = x.Root, H = x.CollapsibleTrigger, W = x.CollapsibleContent, Z = ({
126
127
  }) => {
127
128
  const i = V.create(
128
129
  t
129
- ), g = j(
130
+ ), g = G(
130
131
  () => ((e == null ? void 0 : e.length) ?? 0) * a,
131
132
  [e, a]
132
133
  );
@@ -153,7 +154,7 @@ const q = x.Root, H = x.CollapsibleTrigger, W = x.CollapsibleContent, Z = ({
153
154
  }
154
155
  );
155
156
  }, k = d(Z), U = S(null), ee = () => {
156
- const e = Q(U);
157
+ const e = j(U);
157
158
  if (!e)
158
159
  throw new Error("Reasoning components must be used within Reasoning");
159
160
  return e;
@@ -215,9 +216,9 @@ const q = x.Root, H = x.CollapsibleTrigger, W = x.CollapsibleContent, Z = ({
215
216
  ),
216
217
  ...s,
217
218
  children: t ?? /* @__PURE__ */ l(f, { children: [
218
- /* @__PURE__ */ o(P, { className: "size-4" }),
219
+ /* @__PURE__ */ o(D, { className: "size-4" }),
219
220
  ne(n, i),
220
- /* @__PURE__ */ o($, { className: r("size-4 transition-transform", a ? "rotate-180" : "rotate-0") })
221
+ /* @__PURE__ */ o(P, { className: r("size-4 transition-transform", a ? "rotate-180" : "rotate-0") })
221
222
  ] })
222
223
  }
223
224
  );
@@ -236,11 +237,11 @@ const q = x.Root, H = x.CollapsibleTrigger, W = x.CollapsibleContent, Z = ({
236
237
  se.displayName = "Reasoning";
237
238
  ae.displayName = "ReasoningTrigger";
238
239
  re.displayName = "ReasoningContent";
239
- const ye = ({ className: e, content: t, isLoading: s = !1, ...n }) => /* @__PURE__ */ o("div", { className: r("is-assistant flex w-full max-w-[80%] flex-col gap-2", e), ...n, children: /* @__PURE__ */ o("div", { className: "flex w-fit flex-col gap-2 overflow-hidden text-sm", children: /* @__PURE__ */ o("div", { className: "flex items-center gap-2 rounded-lg border border-muted-foreground/20 bg-muted/50 p-3", children: /* @__PURE__ */ l("div", { className: "flex flex-1 items-center gap-2", children: [
240
+ const Ae = ({ className: e, content: t, isLoading: s = !1, ...n }) => /* @__PURE__ */ o("div", { className: r("is-assistant flex w-full max-w-[80%] flex-col gap-2", e), ...n, children: /* @__PURE__ */ o("div", { className: "flex w-fit flex-col gap-2 overflow-hidden text-sm", children: /* @__PURE__ */ o("div", { className: "flex items-center gap-2 rounded-lg border border-muted-foreground/20 bg-muted/50 p-3", children: /* @__PURE__ */ l("div", { className: "flex flex-1 items-center gap-2", children: [
240
241
  s && /* @__PURE__ */ o(k, { duration: 1.5, children: t }),
241
242
  !s && /* @__PURE__ */ o("div", { className: "text-xs text-muted-foreground", children: t })
242
243
  ] }) }) }) });
243
- function Ae({
244
+ function ke({
244
245
  userInput: e,
245
246
  language: t = "en",
246
247
  currentHtml: s
@@ -258,7 +259,7 @@ Use ${n} language.
258
259
  Use ${n} language.
259
260
  `.trim();
260
261
  }
261
- function ke({
262
+ function Ue({
262
263
  fallbackLang: e,
263
264
  language: t,
264
265
  blocks: s = [],
@@ -272,8 +273,8 @@ REQUESTED TRANSLATION LANGUAGE CODE: ${t}
272
273
  FALLBACK LANGUAGE: ${h[e]}
273
274
  BLOCKS: ${JSON.stringify(s)}`.trim();
274
275
  }
275
- const Ue = ({ onRemove: e, isLoading: t = !1 }) => {
276
- const { t: s } = Y(), n = O(), a = (n == null ? void 0 : n._type) || "Unknown", i = (n == null ? void 0 : n._name) || a;
276
+ const ze = ({ onRemove: e, isLoading: t = !1 }) => {
277
+ const { t: s } = Y(), n = K(), a = (n == null ? void 0 : n._type) || "Unknown", i = (n == null ? void 0 : n._name) || a;
277
278
  return /* @__PURE__ */ o(f, { children: /* @__PURE__ */ l("div", { className: "mx-auto flex w-[95%] items-center justify-between rounded-t-md border border-b-0 border-blue-200 bg-blue-50", children: [
278
279
  /* @__PURE__ */ l("div", { className: "flex items-center", children: [
279
280
  /* @__PURE__ */ o("div", { className: "flex h-6 w-6 items-center justify-center rounded-l rounded-bl-none bg-blue-500 text-xs font-semibold text-white", children: "@" }),
@@ -296,24 +297,24 @@ const Ue = ({ onRemove: e, isLoading: t = !1 }) => {
296
297
  disabled: t,
297
298
  className: "h-6 w-6 text-blue-600 hover:bg-blue-100 hover:text-blue-800",
298
299
  title: "Remove block from context",
299
- children: /* @__PURE__ */ o(B, { size: 14 })
300
+ children: /* @__PURE__ */ o($, { size: 14 })
300
301
  }
301
302
  )
302
303
  ] }) });
303
304
  };
304
305
  export {
305
- Ce as C,
306
- Se as M,
306
+ Te as C,
307
+ Re as M,
307
308
  se as R,
308
- Ue as S,
309
- ye as T,
310
- Te as a,
311
- we as b,
309
+ ze as S,
310
+ Ae as T,
311
+ we as a,
312
+ Ee as b,
312
313
  ae as c,
313
314
  re as d,
314
- Re as e,
315
+ ye as e,
315
316
  X as f,
316
- Ee as g,
317
- Ae as h,
317
+ Ue as g,
318
+ Se as h,
318
319
  ke as i
319
320
  };
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),i=require("./index-Bzn_gpaK.cjs"),r=require("./index-D30xvFa5.cjs"),u=require("lodash-es"),w=require("react"),f=require("./register-chai-top-bar-DyW9GPzV.cjs"),ie=require("react-i18next"),O=require("sonner"),de=require("@tanstack/react-query"),K=require("lucide-react"),G=require("./get-seo-defaults-Cw7vFt-B.cjs"),ue=()=>{const{selectedLang:t}=r.useLanguages(),{data:p,isFetching:n}=i.useLanguagePages();return{data:w.useMemo(()=>u.find(p,{lang:t||""})||{},[p,t]),isFetching:n}},pe=()=>{var x;const p=(x=document.getElementById("canvas-iframe").contentDocument)==null?void 0:x.body.innerHTML;if(!p)return null;const d=new DOMParser().parseFromString(p,"text/html");d.querySelectorAll("style, script, link, svg, [data-block-type='PartialBlock']").forEach(h=>h.remove()),d.querySelectorAll("*").forEach(h=>{Array.from(h.attributes).forEach(g=>h.removeAttribute(g.name))});const l=d.querySelectorAll("h1, h2, h3, h4, h5, h6, p");return Array.from(l).map(h=>`<${h.tagName.toLowerCase()}>${h.innerHTML}</${h.tagName.toLowerCase()}>`).join(" ").replace(/<p>Partial block. Double click to edit.<\/p>/,"")},R=({keyword:t,onComplete:p,field:n})=>{const d=i.useFetch(),l=i.useApiUrl(),{selectedLang:N,fallbackLang:x}=r.useLanguages(),{mutate:h,isPending:g}=de.useMutation({mutationFn:async()=>{const I=pe();return await d(l,{action:i.ACTIONS.GENERATE_SEO_FIELD,data:{pageContext:"",dynamic:!1,field:n,lang:N||x,pageContent:I,keyword:t}})},onSuccess:I=>{p({fieldValue:I.field})},onError:I=>{p({fieldValue:null,error:I.message})}});return e.jsx(f.Button,{disabled:g,type:"button",className:"h-5 w-5",variant:"ghost",size:"sm",onClick:()=>h(),children:g?e.jsx(K.Loader,{className:"h-3 w-3 animate-spin text-yellow-500"}):e.jsx(K.Wand2Icon,{className:"text-yellow-500"})})},he=(t,p)=>{if(!t)return{success:!1,error:"Empty response from AI"};try{let n=t;if(typeof n=="string"&&(/^".*"$/.test(n)&&(n=n.replace(/^"(.*)"$/,"$1"),n=n.replace(/\\\\/g,"___DOUBLE_BACKSLASH___").replace(/\\n/g,`
2
+ `).replace(/\\"/g,'"').replace(/___DOUBLE_BACKSLASH___/g,"\\")),p==="jsonLD"||p==="metaOther")){n.includes("```")&&(n=n.replace(/^```json\s*/i,"").replace(/^```\s*/,"").replace(/\s*```$/m,"")),n=n.trim();try{JSON.parse(n)}catch{return{success:!1,error:"The AI response is not valid JSON. Please try again or edit manually."}}}return{success:!0,value:n}}catch(n){return{success:!1,error:n instanceof Error?n.message:"Unknown error occurred"}}},ge=({isOpen:t,onClose:p,onSave:n,onDiscard:d,isSaving:l=!1,fromLanguage:N,toLanguage:x})=>{const h=i.LANGUAGES[N]||N,g=i.LANGUAGES[x]||x;return e.jsx(r.Dialog,{open:t,onOpenChange:p,children:e.jsxs(r.DialogContent,{className:"sm:max-w-[425px]",children:[e.jsxs(r.DialogHeader,{children:[e.jsx(r.DialogTitle,{children:"Unsaved SEO Changes"}),e.jsxs(r.DialogDescription,{children:['You have unsaved changes in the SEO for "',h,'" version. Do you want to save these changes before switching to "',g,'" version?']})]}),e.jsxs("div",{className:"flex justify-end gap-3 pt-4",children:[e.jsx(f.Button,{variant:"outline",onClick:d,disabled:l,children:"Discard Changes"}),e.jsx(f.Button,{onClick:n,disabled:l,children:l?"Saving...":"Save & Switch"})]})]})})},me=t=>{if(!t)return!0;try{return JSON.parse(t),!0}catch{return!1}},xe=(t,p)=>{const n=t.selectionStart||0,d=t.selectionEnd||0,l=t.value,N=l.substring(0,n),x=l.substring(d),h=`{{${p}}}`,g=N+""+h+x,I=n+0+h.length;return{value:g,newCursorPos:I}},Q=()=>{const{t}=ie.useTranslation(),[,p]=r.useSidebarActivePanel(),{data:n}=i.useChaiCurrentPage(),{data:d}=i.useBuilderPageData(),{data:l,isFetching:N}=ue(),x=l==null?void 0:l.seo,h=w.useRef(null),[g,I]=w.useState("seo"),F=n==null?void 0:n.id,Y=n==null?void 0:n.pageType,E=i.usePageType(Y),{selectedLang:M,fallbackLang:X}=r.useLanguages(),m=M||X,[H,P]=w.useState(!1),[Z,$]=w.useState(!1),[ee,q]=w.useState(!1),[b,B]=w.useState(null),[o,D]=w.useState({keyword:"",title:"",description:"",cononicalUrl:"",noIndex:!1,noFollow:"",ogTitle:"",ogDescription:"",ogImage:"",ogImageId:"",searchTitle:"",searchDescription:"",jsonLD:"{}",metaOther:"{}",...x}),A=w.useRef({}),{mutate:se,isPending:U}=i.useUpdatePage(),y=U||H||Z,{hasPermission:te}=r.usePermissions(),a=te(i.PAGES_PERMISSIONS.EDIT_SEO),[ne]=i.usePagesProps(),oe=u.get(ne,"flags.resetSeoToDefault",!1),W=!M||o.jsonLD!=="{}";w.useEffect(()=>{if(!N&&x&&F){const s={keyword:"",title:"",description:"",cononicalUrl:"",noIndex:!1,noFollow:"",ogTitle:"",ogDescription:"",ogImage:"",ogImageId:"",searchTitle:"",searchDescription:"",jsonLD:"",metaOther:"",...x};D(s),A.current[m]=s}},[N,x,m,F]),w.useEffect(()=>{const s=c=>{const{fromLang:j,toLang:J,switchHandler:v}=c.detail,_=A.current[m];(_?!u.isEqual(_,o):!1)?(B({fromLang:j,toLang:J,switchHandler:v}),q(!0)):v()};return window.addEventListener("seo-language-switch-check",s),()=>{window.removeEventListener("seo-language-switch-check",s)}},[F,o,m]);const ae=async()=>{if(!(!E||!m))try{P(!0);const s=G.getSeoDefaults(E,m),c={...o,keyword:u.get(s,"seo.keyword",""),title:u.get(s,"seo.title",""),description:u.get(s,"seo.description",""),cononicalUrl:u.get(s,"seo.canonicalUrl",""),noIndex:u.get(s,"seo.noIndex",!1),noFollow:u.get(s,"seo.noFollow",!1),ogTitle:u.get(s,"seo.ogTitle",""),ogDescription:u.get(s,"seo.ogDescription","")};D(c),O.toast.success(t("SEO fields reset to defaults"))}catch(s){O.toast.error(t("Failed to reset SEO fields")),console.error("Reset SEO error:",s)}finally{P(!1)}},re=async()=>{if(!(!E||!m))try{$(!0);const s=G.getSeoDefaults(E,m),c={...o,jsonLD:u.get(s,"seo.jsonLD","")};D(c),O.toast.success(t("JSON-LD reset to default"))}catch(s){O.toast.error(t("Failed to reset JSON-LD")),console.error("Reset JSON-LD error:",s)}finally{$(!1)}},le=async()=>{if(!(!E||!m))try{P(!0);const s=G.getSeoDefaults(E,m),c={...o,ogTitle:u.get(s,"seo.ogTitle",""),ogDescription:u.get(s,"seo.ogDescription",""),ogImage:u.get(s,"seo.ogImage",""),ogImageId:u.get(s,"seo.ogImageId",""),metaOther:u.get(s,"seo.metaOther","{}")};D(c),O.toast.success(t("Meta Tag fields reset to defaults"))}catch(s){O.toast.error(t("Failed to reset Meta Tag fields")),console.error("Reset Meta Tag error:",s)}finally{P(!1)}},z=async()=>{se({id:l==null?void 0:l.id,seo:o,primaryPage:F},{onSuccess:()=>{console.log("SEO & JSON-LD updated successfully",o),A.current[m]=o,O.toast.success("SEO & JSON-LD updated successfully")}})},L=(s,c)=>{const j=document.getElementById(c);if(j){const{value:J,newCursorPos:v}=xe(j,s);h.current={id:c,position:v},j.tagName.toLowerCase()==="input"?(j.value=J,D(k=>({...k,[j.name]:J})),j.focus(),j.setSelectionRange(v,v),[0,10,50,100,200].forEach(k=>{setTimeout(()=>{const V=document.getElementById(c);V&&(V.focus(),V.setSelectionRange(v,v))},k)})):(D(T=>({...T,[j.name]:J})),requestAnimationFrame(()=>{const T=document.getElementById(c);T&&(T.focus(),T.setSelectionRange(v,v),setTimeout(()=>{const k=document.getElementById(c);k&&(k.focus(),k.setSelectionRange(v,v))},50))}))}},S=s=>{const c={...o,[s.target.name]:s.target.name==="noIndex"||s.target.name==="noFollow"?s.target.checked:s.target.value};D(c)},C=s=>c=>{if(!u.isEmpty(c.fieldValue)){const j=he(c.fieldValue,s);j.success?S({target:{name:s,value:j.value}}):O.toast.error(e.jsxs("div",{children:[e.jsx("h2",{children:"Failed to process AI response:"}),e.jsx("p",{children:j.error})]}))}c.error&&O.toast.error(e.jsxs("div",{children:[e.jsx("h2",{children:"Failed to generate:"}),e.jsx("p",{children:c.error})]}))},ce=()=>{const s=u.get(n,"seo.jsonLD","{}");if((s==null?void 0:s.trim())==="{}"){O.toast.error("Default page JSON-LD is empty");return}S({target:{name:"jsonLD",value:s}})};return e.jsxs("div",{className:"relative flex h-full flex-col","data-panel-id":"seo",children:[!a&&e.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center backdrop-blur-sm",children:e.jsx(f.Alert,{variant:"default",className:"w-[80%] max-w-md text-xs",children:e.jsx(f.AlertDescription,{children:t("You don't have permission to edit SEO settings. Contact your administrator for access.")})})}),e.jsxs("div",{className:"no-scrollbar flex-grow overflow-y-auto px-2 pb-20",children:[e.jsxs("div",{className:"mb-4 flex w-full items-center justify-between rounded-md bg-gray-100 px-2 py-1 text-left text-sm",children:[e.jsxs("span",{children:[e.jsx("div",{className:"font-medium",children:l==null?void 0:l.name}),e.jsx("span",{className:"font-mono text-xs leading-tight text-gray-500",children:l==null?void 0:l.slug})]}),e.jsx(i.LanguageSwitcher,{variant:"outline",showAdd:!1})]}),e.jsx("form",{className:"space-y-8",children:e.jsxs(r.Tabs,{value:g,onValueChange:I,className:"w-full",children:[e.jsxs(r.TabsList,{className:"mb-4 grid w-full grid-cols-3",children:[e.jsx(r.TabsTrigger,{value:"seo",children:t("SEO")}),e.jsx(r.TabsTrigger,{value:"opengraph",children:t("Meta Tags")}),e.jsx(r.TabsTrigger,{value:"jsonld",children:t("JSON-LD")})]}),e.jsx("div",{className:g==="seo"?"":"sr-only",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(r.Label,{className:"text-xs",htmlFor:"keyword",children:t("Keyword")}),a&&e.jsx(i.NestedPathSelector,{dataType:"value",data:d??{},onSelect:s=>L(s,"keyword")})]}),e.jsx(f.Input,{type:"text",id:"keyword",name:"keyword",value:o.keyword,onChange:S,disabled:y||!a,placeholder:t("Enter keyword"),readOnly:!a})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(r.Label,{className:"text-xs",htmlFor:"title",children:t("SEO Title")}),e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(R,{keyword:o.keyword,onComplete:C("title"),field:"title"}),a&&e.jsx(i.NestedPathSelector,{dataType:"value",data:d??{},onSelect:s=>L(s,"title")})]})]}),e.jsx(f.Input,{type:"text",id:"title",name:"title",value:o.title,onChange:S,disabled:y||!a,placeholder:t("Enter SEO title"),readOnly:!a})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(r.Label,{className:"text-xs",htmlFor:"description",children:t("SEO Description")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(R,{keyword:o.keyword,onComplete:C("description"),field:"description"}),a&&e.jsx(i.NestedPathSelector,{data:d??{},onSelect:s=>L(s,"description")})]})]}),e.jsx(r.Textarea,{id:"description",name:"description",rows:5,value:o.description,onChange:S,disabled:y||!a,placeholder:t("Enter SEO description"),readOnly:!a})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(r.Label,{className:"text-xs",htmlFor:"title",children:t("Canonical URL")}),a&&e.jsx(i.NestedPathSelector,{dataType:"value",data:d??{},onSelect:s=>L(s,"canonicalUrl")})]}),e.jsx(f.Input,{type:"text",id:"canonicalUrl",name:"canonicalUrl",value:o.canonicalUrl,onChange:S,disabled:y||!a,placeholder:t("Enter Canonical URL"),readOnly:!a})]}),e.jsxs("div",{className:"",children:[e.jsxs("div",{className:"flex items-center gap-x-2",children:[e.jsx(f.Input,{type:"checkbox",id:"noIndex",name:"noIndex",checked:o.noIndex,onChange:S,disabled:y||!a,className:"h-4 w-4"}),e.jsx(r.Label,{className:"pb-1 text-xs",htmlFor:"noIndex",children:t("No Index")})]}),e.jsx("p",{className:"mt-0 text-[10px] font-light leading-4 text-gray-400",children:t("Check this if you don't want search engines to index this page.")})]}),e.jsxs("div",{className:"",children:[e.jsxs("div",{className:"flex items-center gap-x-2",children:[e.jsx(f.Input,{type:"checkbox",id:"noFollow",name:"noFollow",checked:o.noFollow,onChange:S,disabled:y||!a,className:"h-4 w-4"}),e.jsx(r.Label,{className:"pb-1 text-xs",htmlFor:"noIndex",children:t("No Follow")})]}),e.jsx("p",{className:"text-[10px] font-light leading-4 text-gray-400",children:t("Check this if you don't want search engines to follow links on this page.")})]})]})}),e.jsx("div",{className:g==="opengraph"?"":"sr-only",children:e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{children:[e.jsx("h3",{className:"mb-4 font-semibold text-slate-700",children:t("Open Graph")}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(r.Label,{className:"text-xs",htmlFor:"ogTitle",children:t("OG Title")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(R,{keyword:o.keyword,onComplete:C("ogTitle"),field:"ogTitle"}),a&&e.jsx(i.NestedPathSelector,{dataType:"value",data:d??{},onSelect:s=>L(s,"ogTitle")})]})]}),e.jsx(f.Input,{type:"text",id:"ogTitle",name:"ogTitle",value:o.ogTitle,onChange:S,disabled:y||!a,placeholder:t("Enter OG title"),readOnly:!a})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(r.Label,{className:"text-xs",htmlFor:"ogDescription",children:t("OG Description")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(R,{keyword:o.keyword,onComplete:C("ogDescription"),field:"ogDescription"}),a&&e.jsx(i.NestedPathSelector,{dataType:"value",data:d??{},onSelect:s=>L(s,"ogDescription")})]})]}),e.jsx(r.Textarea,{id:"ogDescription",name:"ogDescription",rows:5,value:o.ogDescription,onChange:S,disabled:y||!a,placeholder:t("Enter OG description"),readOnly:!a})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(r.Label,{className:"text-xs",htmlFor:"ogImage",children:t("OG Image")}),a&&e.jsx(i.NestedPathSelector,{dataType:"value",data:d??{},onSelect:s=>{D({...o,ogImage:`{{${s}}}`,ogImageId:""})}})]}),e.jsx(i.ImagePicker,{assetId:o.ogImageId,assetUrl:o.ogImage,onChange:s=>{D({...o,ogImage:s.url,ogImageId:s.id})},disabled:y||!a,placeholder:t("Select OG image"),className:"mb-2"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(r.Label,{className:"text-xs",htmlFor:"metaOther",children:t("Meta Tags")}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(R,{keyword:o.keyword,onComplete:C("metaOther"),field:"metaOther"})})]}),e.jsx(i.SmartJsonInput,{id:"metaOther",value:o.metaOther,onChange:s=>{S({target:{name:"metaOther",value:s}})},placeholder:t("Enter Meta Tags JSON"),disabled:y||!a,readOnly:!a,pageData:d||{},rows:8,handleFieldInsert:L})]})]})]})})}),e.jsx("div",{className:g==="jsonld"?"":"sr-only",children:e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(r.Label,{className:"text-xs",htmlFor:"jsonLD",children:t("JSON-LD")}),W&&e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(R,{keyword:o.keyword,onComplete:C("jsonLD"),field:"jsonLD"})})]}),e.jsx("div",{className:"hidden",children:JSON.stringify(d)}),e.jsx(i.SmartJsonInput,{id:"jsonLD",value:o.jsonLD,onChange:s=>{S({target:{name:"jsonLD",value:s}})},placeholder:t("Enter JSON-LD"),disabled:y||!a,readOnly:!a,pageData:d||{},rows:12,handleFieldInsert:L,hasJsonLdForSelectedLang:W,copyJsonLDFromDefaultPage:ce})]})})})]})})]}),a&&e.jsxs("div",{className:"fixed bottom-0 left-0 right-0 flex w-full flex-shrink-0 items-center justify-between border-t bg-background p-4",children:[oe?e.jsx(f.Button,{type:"button",variant:"ghost",size:"sm",onClick:()=>{g==="jsonld"?re():g==="opengraph"?le():ae()},disabled:y||!a||!E,children:t(H?"Resetting...":`Reset to ${g==="jsonld"?"Default JSON-LD":g==="opengraph"?"Default Open Graph":"Default SEO"}`)}):e.jsx("div",{}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(f.Button,{onClick:z,disabled:!me(o==null?void 0:o.jsonLD)||(A.current[m]?u.isEqual(A.current[m],o):!1)||y||!a,children:t(U?"Saving...":"Save")}),e.jsx(f.Button,{variant:"link",className:"text-gray-500 hover:text-gray-700",onClick:()=>p("outline"),children:t("Cancel")})]})]}),e.jsx(ge,{isOpen:ee,onClose:()=>{q(!1),B(null)},onSave:async()=>{b&&(await z(),b.switchHandler(),q(!1),B(null))},onDiscard:()=>{if(b){const s=A.current[m];s&&D(s),b.switchHandler(),q(!1),B(null)}},isSaving:U,fromLanguage:(b==null?void 0:b.fromLang)||m,toLanguage:(b==null?void 0:b.toLang)||""})]})};Q.displayName="SeoPanel";exports.default=Q;