@fuma-content/studio 1.0.0 → 1.0.2

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 (616) hide show
  1. package/build/client/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
  2. package/build/client/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
  3. package/build/client/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
  4. package/build/client/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
  5. package/build/client/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
  6. package/build/client/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
  7. package/build/client/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
  8. package/build/client/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
  9. package/build/client/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
  10. package/build/client/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
  11. package/build/client/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
  12. package/build/client/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
  13. package/build/client/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
  14. package/build/client/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
  15. package/build/client/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
  16. package/build/client/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
  17. package/build/client/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
  18. package/build/client/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
  19. package/build/client/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
  20. package/build/client/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
  21. package/build/client/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
  22. package/build/client/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
  23. package/build/client/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
  24. package/build/client/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
  25. package/build/client/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
  26. package/build/client/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
  27. package/build/client/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
  28. package/build/client/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
  29. package/build/client/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
  30. package/build/client/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
  31. package/build/client/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
  32. package/build/client/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
  33. package/build/client/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
  34. package/build/client/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
  35. package/build/client/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
  36. package/build/client/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
  37. package/build/client/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
  38. package/build/client/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
  39. package/build/client/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
  40. package/build/client/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
  41. package/build/client/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
  42. package/build/client/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
  43. package/build/client/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
  44. package/build/client/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
  45. package/build/client/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
  46. package/build/client/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
  47. package/build/client/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
  48. package/build/client/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
  49. package/build/client/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
  50. package/build/client/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
  51. package/build/client/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
  52. package/build/client/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
  53. package/build/client/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
  54. package/build/client/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
  55. package/build/client/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
  56. package/build/client/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
  57. package/build/client/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
  58. package/build/client/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
  59. package/build/client/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
  60. package/build/client/assets/QueryClientProvider-DqiXnN2L.js +1 -0
  61. package/build/client/assets/actions-DkbV2Z0p.js +1 -0
  62. package/build/client/assets/actions-DpkI7OTF.js +1 -0
  63. package/build/client/assets/badge-CZkdLoIP.js +1 -0
  64. package/build/client/assets/button-Bm94vje1.js +41 -0
  65. package/build/client/assets/client-BWBqEatf.js +1 -0
  66. package/build/client/assets/client-Crg-pMcu.js +1 -0
  67. package/build/client/assets/client-DVneG3Rq.css +1 -0
  68. package/build/client/assets/client-OSVRoCKH.js +569 -0
  69. package/build/client/assets/dropdown-menu-EF-sTINr.js +1 -0
  70. package/build/client/assets/entry.rsc-D51PwnQL.js +1 -0
  71. package/build/client/assets/index-BdrDVoE8.js +1 -0
  72. package/build/client/assets/index-BpILsqFO.js +1 -0
  73. package/build/client/assets/index-Bx93mXy1.js +11 -0
  74. package/build/client/assets/index-CQRgqbuL.js +1 -0
  75. package/build/client/assets/index-DOs5iMXj.js +1 -0
  76. package/build/client/assets/index-DTzAH5JX.js +1 -0
  77. package/build/client/assets/layout-CnpYRqF0.js +1 -0
  78. package/build/client/assets/mdx-BNErtsK6.js +1 -0
  79. package/build/client/assets/page-DOzl4Kpa.js +1 -0
  80. package/build/client/assets/page-uNpJU_rv.js +1 -0
  81. package/build/client/assets/query-z9oLNeTD.js +1 -0
  82. package/build/client/assets/react-B8--K7an.js +10 -0
  83. package/build/client/assets/root-B_CXTQpA.js +1 -0
  84. package/build/client/assets/root-D3NoAGI1.js +1 -0
  85. package/build/client/assets/root-z8crlXSh.css +1 -0
  86. package/build/client/assets/route-DVneG3Rq.css +1 -0
  87. package/build/client/assets/router-a9jyj9wf.js +10 -0
  88. package/build/client/assets/separator-tWFpvpUX.js +1 -0
  89. package/build/client/assets/sidebar-BBYit8gY.js +12 -0
  90. package/build/client/assets/site-header-DQkKe-WA.js +1 -0
  91. package/build/client/assets/spinner-BdPhtfsc.js +1 -0
  92. package/build/client/assets/tooltip-Dvh-iHDG.js +16 -0
  93. package/build/client/assets/use-sync-ZgcwUdu_.js +9 -0
  94. package/build/client/assets/yaml-Cloe7OVn.js +32 -0
  95. package/build/server/__ssr_build/__vite_rsc_assets_manifest.js +268 -0
  96. package/build/server/__ssr_build/assets/QueryClientProvider-DlvBH3OQ.js +30 -0
  97. package/build/server/__ssr_build/assets/actions-B50-3n-a.js +63 -0
  98. package/build/server/__ssr_build/assets/actions-BFtCTvOL.js +21 -0
  99. package/{src/components/ui/badge.tsx → build/server/__ssr_build/assets/badge-DYFvBSp8.js} +23 -28
  100. package/build/server/__ssr_build/assets/button-C_-b_vqm.js +4098 -0
  101. package/build/server/__ssr_build/assets/client--HXec13w.js +130 -0
  102. package/build/server/__ssr_build/assets/client-BqW9rGyi.js +116885 -0
  103. package/build/server/__ssr_build/assets/client-CU90j0R8.js +154 -0
  104. package/build/server/__ssr_build/assets/dropdown-menu-D2YyT3lP.js +1312 -0
  105. package/build/server/__ssr_build/assets/entry.rsc-Cg_DxYkh.js +12 -0
  106. package/build/server/__ssr_build/assets/index-B-gno69w.js +58 -0
  107. package/build/server/__ssr_build/assets/index-DBc0nhEL.js +288 -0
  108. package/build/server/__ssr_build/assets/index-Dtw6X3NW.js +1092 -0
  109. package/build/server/__ssr_build/assets/index-DvVNShHF.js +86 -0
  110. package/build/server/__ssr_build/assets/index-PpqpVA51.js +612 -0
  111. package/build/server/__ssr_build/assets/layout-CPnSx9PI.js +454 -0
  112. package/build/server/__ssr_build/assets/mdx-bmeV1kyx.js +44 -0
  113. package/build/server/__ssr_build/assets/page-BwoghW3K.js +38 -0
  114. package/build/server/__ssr_build/assets/page-HxttullC.js +89 -0
  115. package/build/server/__ssr_build/assets/query-C1_xUNXy.js +1975 -0
  116. package/build/server/__ssr_build/assets/root-CS7F-km4.js +16 -0
  117. package/build/server/__ssr_build/assets/root-D-Y-rGw5.js +73 -0
  118. package/build/server/__ssr_build/assets/separator-8UA_ceSq.js +49 -0
  119. package/build/server/__ssr_build/assets/sidebar-BzNOZeBO.js +13194 -0
  120. package/build/server/__ssr_build/assets/site-header-CXHKSzqk.js +13 -0
  121. package/build/server/__ssr_build/assets/spinner-BXcLlTNs.js +1291 -0
  122. package/build/server/__ssr_build/assets/tooltip-DZ4WdJt-.js +9553 -0
  123. package/build/server/__ssr_build/assets/use-sync-TRS0zL-Y.js +3404 -0
  124. package/build/server/__ssr_build/assets/yaml-BEdFfhvc.js +63 -0
  125. package/build/server/__ssr_build/index.js +36076 -0
  126. package/build/server/__vite_rsc_assets_manifest.js +268 -0
  127. package/build/server/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
  128. package/build/server/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
  129. package/build/server/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
  130. package/build/server/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
  131. package/build/server/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
  132. package/build/server/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
  133. package/build/server/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
  134. package/build/server/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
  135. package/build/server/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
  136. package/build/server/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
  137. package/build/server/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
  138. package/build/server/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
  139. package/build/server/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
  140. package/build/server/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
  141. package/build/server/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
  142. package/build/server/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
  143. package/build/server/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
  144. package/build/server/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
  145. package/build/server/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
  146. package/build/server/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
  147. package/build/server/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
  148. package/build/server/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
  149. package/build/server/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
  150. package/build/server/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
  151. package/build/server/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
  152. package/build/server/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
  153. package/build/server/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
  154. package/build/server/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
  155. package/build/server/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
  156. package/build/server/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
  157. package/build/server/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
  158. package/build/server/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
  159. package/build/server/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
  160. package/build/server/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
  161. package/build/server/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
  162. package/build/server/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
  163. package/build/server/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
  164. package/build/server/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
  165. package/build/server/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
  166. package/build/server/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
  167. package/build/server/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
  168. package/build/server/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
  169. package/build/server/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
  170. package/build/server/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
  171. package/build/server/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
  172. package/build/server/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
  173. package/build/server/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
  174. package/build/server/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
  175. package/build/server/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
  176. package/build/server/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
  177. package/build/server/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
  178. package/build/server/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
  179. package/build/server/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
  180. package/build/server/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
  181. package/build/server/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
  182. package/build/server/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
  183. package/build/server/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
  184. package/build/server/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
  185. package/build/server/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
  186. package/build/server/assets/actions-C92yn6jE.js +61 -0
  187. package/build/server/assets/actions-CWWFIcb1.js +46 -0
  188. package/build/server/assets/actions-DZdN0IBq.js +73 -0
  189. package/build/server/assets/client-BdxXy6rH.js +13 -0
  190. package/build/server/assets/client-DLzFPnCR.js +13 -0
  191. package/build/server/assets/config-Cb909uq6.js +257 -0
  192. package/build/server/assets/index-X49ifkk3.js +9 -0
  193. package/build/server/assets/jsx-runtime.react-server-D3We4JeM.js +324 -0
  194. package/build/server/assets/layout-CRw_6FCt.js +2071 -0
  195. package/build/server/assets/page-BcrsPZbM.js +9 -0
  196. package/build/server/assets/page-zlF_Ew1s.js +72 -0
  197. package/build/server/assets/root-CVOXO6T9.js +23 -0
  198. package/build/server/assets/root-dGb6ch_9.js +38 -0
  199. package/build/server/assets/root-z8crlXSh.css +1 -0
  200. package/build/server/assets/route-DVneG3Rq.css +1 -0
  201. package/build/server/assets/route-Ds0B4hTo.js +44 -0
  202. package/build/server/assets/route-DvwlfKZg.js +21 -0
  203. package/build/server/assets/route-o-6k10r9.js +70774 -0
  204. package/build/server/index.js +17032 -0
  205. package/dist/bin/cli.d.mts +1 -0
  206. package/dist/bin/cli.mjs +71 -0
  207. package/dist/bin.mjs +14 -40
  208. package/dist/package.mjs +1 -1
  209. package/package.json +33 -32
  210. package/dist/index.d.mts +0 -52
  211. package/dist/index.mjs +0 -67
  212. package/dist/mdx/actions.mjs +0 -32
  213. package/dist/mdx/client.mjs +0 -167
  214. package/dist/src/components/code-editor/mdx.lazy.mjs +0 -19
  215. package/dist/src/components/code-editor/mdx.mjs +0 -44
  216. package/dist/src/components/code-editor/yaml.lazy.mjs +0 -22
  217. package/dist/src/components/code-editor/yaml.mjs +0 -63
  218. package/dist/src/components/editor/editor-base-kit.mjs +0 -41
  219. package/dist/src/components/editor/editor-kit.mjs +0 -73
  220. package/dist/src/components/editor/md.mjs +0 -42
  221. package/dist/src/components/editor/plugins/ai-kit.mjs +0 -68
  222. package/dist/src/components/editor/plugins/align-base-kit.mjs +0 -28
  223. package/dist/src/components/editor/plugins/align-kit.mjs +0 -30
  224. package/dist/src/components/editor/plugins/autoformat-kit.mjs +0 -214
  225. package/dist/src/components/editor/plugins/basic-blocks-base-kit.mjs +0 -22
  226. package/dist/src/components/editor/plugins/basic-blocks-kit.mjs +0 -51
  227. package/dist/src/components/editor/plugins/basic-marks-base-kit.mjs +0 -20
  228. package/dist/src/components/editor/plugins/basic-marks-kit.mjs +0 -28
  229. package/dist/src/components/editor/plugins/block-menu-kit.mjs +0 -11
  230. package/dist/src/components/editor/plugins/block-placeholder-kit.mjs +0 -14
  231. package/dist/src/components/editor/plugins/block-selection-kit.mjs +0 -48
  232. package/dist/src/components/editor/plugins/callout-base-kit.mjs +0 -8
  233. package/dist/src/components/editor/plugins/callout-kit.mjs +0 -10
  234. package/dist/src/components/editor/plugins/code-block-base-kit.mjs +0 -16
  235. package/dist/src/components/editor/plugins/code-block-kit.mjs +0 -19
  236. package/dist/src/components/editor/plugins/column-base-kit.mjs +0 -8
  237. package/dist/src/components/editor/plugins/column-kit.mjs +0 -10
  238. package/dist/src/components/editor/plugins/comment-base-kit.mjs +0 -8
  239. package/dist/src/components/editor/plugins/comment-kit.mjs +0 -53
  240. package/dist/src/components/editor/plugins/copilot-kit.mjs +0 -49
  241. package/dist/src/components/editor/plugins/cursor-overlay-kit.mjs +0 -11
  242. package/dist/src/components/editor/plugins/date-base-kit.mjs +0 -8
  243. package/dist/src/components/editor/plugins/date-kit.mjs +0 -10
  244. package/dist/src/components/editor/plugins/discussion-kit.mjs +0 -94
  245. package/dist/src/components/editor/plugins/dnd-kit.mjs +0 -31
  246. package/dist/src/components/editor/plugins/emoji-kit.mjs +0 -11
  247. package/dist/src/components/editor/plugins/exit-break-kit.mjs +0 -12
  248. package/dist/src/components/editor/plugins/fixed-toolbar-kit.mjs +0 -15
  249. package/dist/src/components/editor/plugins/floating-toolbar-kit.mjs +0 -15
  250. package/dist/src/components/editor/plugins/font-base-kit.mjs +0 -14
  251. package/dist/src/components/editor/plugins/font-kit.mjs +0 -19
  252. package/dist/src/components/editor/plugins/indent-base-kit.mjs +0 -17
  253. package/dist/src/components/editor/plugins/indent-kit.mjs +0 -20
  254. package/dist/src/components/editor/plugins/line-height-base-kit.mjs +0 -20
  255. package/dist/src/components/editor/plugins/line-height-kit.mjs +0 -22
  256. package/dist/src/components/editor/plugins/link-base-kit.mjs +0 -8
  257. package/dist/src/components/editor/plugins/link-kit.mjs +0 -15
  258. package/dist/src/components/editor/plugins/list-base-kit.mjs +0 -19
  259. package/dist/src/components/editor/plugins/list-kit.mjs +0 -22
  260. package/dist/src/components/editor/plugins/markdown-kit.mjs +0 -17
  261. package/dist/src/components/editor/plugins/math-base-kit.mjs +0 -8
  262. package/dist/src/components/editor/plugins/math-kit.mjs +0 -10
  263. package/dist/src/components/editor/plugins/media-base-kit.mjs +0 -23
  264. package/dist/src/components/editor/plugins/media-kit.mjs +0 -37
  265. package/dist/src/components/editor/plugins/slash-kit.mjs +0 -11
  266. package/dist/src/components/editor/plugins/suggestion-base-kit.mjs +0 -8
  267. package/dist/src/components/editor/plugins/suggestion-kit.mjs +0 -50
  268. package/dist/src/components/editor/plugins/table-base-kit.mjs +0 -13
  269. package/dist/src/components/editor/plugins/table-kit.mjs +0 -15
  270. package/dist/src/components/editor/transforms.mjs +0 -125
  271. package/dist/src/components/editor/ui/ai-chat-editor.mjs +0 -21
  272. package/dist/src/components/editor/ui/ai-menu.mjs +0 -488
  273. package/dist/src/components/editor/ui/ai-node.mjs +0 -24
  274. package/dist/src/components/editor/ui/ai-toolbar-button.mjs +0 -23
  275. package/dist/src/components/editor/ui/align-toolbar-button.mjs +0 -71
  276. package/dist/src/components/editor/ui/block-context-menu.mjs +0 -130
  277. package/dist/src/components/editor/ui/block-discussion.mjs +0 -200
  278. package/dist/src/components/editor/ui/block-draggable.mjs +0 -265
  279. package/dist/src/components/editor/ui/block-list-static.mjs +0 -48
  280. package/dist/src/components/editor/ui/block-list.mjs +0 -47
  281. package/dist/src/components/editor/ui/block-selection.mjs +0 -28
  282. package/dist/src/components/editor/ui/block-suggestion.mjs +0 -319
  283. package/dist/src/components/editor/ui/blockquote-node-static.mjs +0 -14
  284. package/dist/src/components/editor/ui/blockquote-node.mjs +0 -16
  285. package/dist/src/components/editor/ui/callout-node-static.mjs +0 -29
  286. package/dist/src/components/editor/ui/callout-node.mjs +0 -50
  287. package/dist/src/components/editor/ui/caption.mjs +0 -39
  288. package/dist/src/components/editor/ui/code-block-node-static.mjs +0 -30
  289. package/dist/src/components/editor/ui/code-block-node.mjs +0 -121
  290. package/dist/src/components/editor/ui/code-node-static.mjs +0 -15
  291. package/dist/src/components/editor/ui/code-node.mjs +0 -17
  292. package/dist/src/components/editor/ui/column-node-static.mjs +0 -32
  293. package/dist/src/components/editor/ui/column-node.mjs +0 -229
  294. package/dist/src/components/editor/ui/comment-node-static.mjs +0 -14
  295. package/dist/src/components/editor/ui/comment-node.mjs +0 -33
  296. package/dist/src/components/editor/ui/comment-toolbar-button.mjs +0 -23
  297. package/dist/src/components/editor/ui/comment.mjs +0 -422
  298. package/dist/src/components/editor/ui/cursor-overlay.mjs +0 -36
  299. package/dist/src/components/editor/ui/date-node-static.mjs +0 -32
  300. package/dist/src/components/editor/ui/date-node.mjs +0 -60
  301. package/dist/src/components/editor/ui/editor-static.mjs +0 -31
  302. package/dist/src/components/editor/ui/editor.mjs +0 -60
  303. package/dist/src/components/editor/ui/emoji-node.mjs +0 -46
  304. package/dist/src/components/editor/ui/emoji-toolbar-button.mjs +0 -415
  305. package/dist/src/components/editor/ui/equation-node-static.mjs +0 -65
  306. package/dist/src/components/editor/ui/equation-node.mjs +0 -159
  307. package/dist/src/components/editor/ui/equation-toolbar-button.mjs +0 -23
  308. package/dist/src/components/editor/ui/fixed-toolbar-buttons.mjs +0 -109
  309. package/dist/src/components/editor/ui/fixed-toolbar.mjs +0 -16
  310. package/dist/src/components/editor/ui/floating-toolbar-buttons.mjs +0 -54
  311. package/dist/src/components/editor/ui/floating-toolbar.mjs +0 -51
  312. package/dist/src/components/editor/ui/font-color-toolbar-button.mjs +0 -637
  313. package/dist/src/components/editor/ui/font-size-toolbar-button.mjs +0 -83
  314. package/dist/src/components/editor/ui/ghost-text.mjs +0 -22
  315. package/dist/src/components/editor/ui/heading-node-static.mjs +0 -60
  316. package/dist/src/components/editor/ui/heading-node.mjs +0 -62
  317. package/dist/src/components/editor/ui/highlight-node-static.mjs +0 -15
  318. package/dist/src/components/editor/ui/highlight-node.mjs +0 -17
  319. package/dist/src/components/editor/ui/history-toolbar-button.mjs +0 -35
  320. package/dist/src/components/editor/ui/hr-node-static.mjs +0 -18
  321. package/dist/src/components/editor/ui/hr-node.mjs +0 -23
  322. package/dist/src/components/editor/ui/indent-toolbar-button.mjs +0 -29
  323. package/dist/src/components/editor/ui/inline-combobox.mjs +0 -148
  324. package/dist/src/components/editor/ui/insert-toolbar-button.mjs +0 -199
  325. package/dist/src/components/editor/ui/kbd-node-static.mjs +0 -15
  326. package/dist/src/components/editor/ui/kbd-node.mjs +0 -17
  327. package/dist/src/components/editor/ui/line-height-toolbar-button.mjs +0 -56
  328. package/dist/src/components/editor/ui/link-node-static.mjs +0 -20
  329. package/dist/src/components/editor/ui/link-node.mjs +0 -28
  330. package/dist/src/components/editor/ui/link-toolbar-button.mjs +0 -21
  331. package/dist/src/components/editor/ui/link-toolbar.mjs +0 -141
  332. package/dist/src/components/editor/ui/list-toolbar-button.mjs +0 -131
  333. package/dist/src/components/editor/ui/mark-toolbar-button.mjs +0 -20
  334. package/dist/src/components/editor/ui/media-image-node-static.mjs +0 -32
  335. package/dist/src/components/editor/ui/media-image-node.mjs +0 -64
  336. package/dist/src/components/editor/ui/media-placeholder-node.mjs +0 -184
  337. package/dist/src/components/editor/ui/media-preview-dialog.mjs +0 -113
  338. package/dist/src/components/editor/ui/media-toolbar-button.mjs +0 -156
  339. package/dist/src/components/editor/ui/media-toolbar.mjs +0 -80
  340. package/dist/src/components/editor/ui/media-upload-toast.mjs +0 -39
  341. package/dist/src/components/editor/ui/media-video-node-static.mjs +0 -27
  342. package/dist/src/components/editor/ui/mode-toolbar-button.mjs +0 -112
  343. package/dist/src/components/editor/ui/paragraph-node-static.mjs +0 -15
  344. package/dist/src/components/editor/ui/paragraph-node.mjs +0 -17
  345. package/dist/src/components/editor/ui/resize-handle.mjs +0 -43
  346. package/dist/src/components/editor/ui/slash-node.mjs +0 -228
  347. package/dist/src/components/editor/ui/suggestion-node-static.mjs +0 -24
  348. package/dist/src/components/editor/ui/suggestion-node.mjs +0 -111
  349. package/dist/src/components/editor/ui/suggestion-toolbar-button.mjs +0 -24
  350. package/dist/src/components/editor/ui/table-icons.mjs +0 -1310
  351. package/dist/src/components/editor/ui/table-node-static.mjs +0 -68
  352. package/dist/src/components/editor/ui/table-node.mjs +0 -375
  353. package/dist/src/components/editor/ui/table-toolbar-button.mjs +0 -190
  354. package/dist/src/components/editor/ui/turn-into-toolbar-button.mjs +0 -168
  355. package/dist/src/components/editor/use-chat.mjs +0 -80
  356. package/dist/src/components/json-schema-editor/client.mjs +0 -46
  357. package/dist/src/components/json-schema-editor/components/inputs.mjs +0 -438
  358. package/dist/src/components/json-schema-editor/get-default-values.mjs +0 -23
  359. package/dist/src/components/json-schema-editor/schema.mjs +0 -131
  360. package/dist/src/components/json-schema-editor/utils/merge-schema.mjs +0 -134
  361. package/dist/src/components/json-schema-editor/utils/schema-to-string.mjs +0 -53
  362. package/dist/src/components/ui/alert-dialog.mjs +0 -90
  363. package/dist/src/components/ui/avatar.mjs +0 -32
  364. package/dist/src/components/ui/button.mjs +0 -48
  365. package/dist/src/components/ui/calendar.mjs +0 -108
  366. package/dist/src/components/ui/checkbox.mjs +0 -23
  367. package/dist/src/components/ui/combobox.mjs +0 -53
  368. package/dist/src/components/ui/command.mjs +0 -42
  369. package/dist/src/components/ui/context-menu.mjs +0 -67
  370. package/dist/src/components/ui/dialog.mjs +0 -9
  371. package/dist/src/components/ui/dropdown-menu.mjs +0 -122
  372. package/dist/src/components/ui/input-group.mjs +0 -31
  373. package/dist/src/components/ui/input.mjs +0 -15
  374. package/dist/src/components/ui/label.mjs +0 -19
  375. package/dist/src/components/ui/popover.mjs +0 -37
  376. package/dist/src/components/ui/select.mjs +0 -80
  377. package/dist/src/components/ui/separator.mjs +0 -19
  378. package/dist/src/components/ui/spinner.mjs +0 -16
  379. package/dist/src/components/ui/tabs.mjs +0 -39
  380. package/dist/src/components/ui/textarea.mjs +0 -14
  381. package/dist/src/components/ui/toolbar.mjs +0 -183
  382. package/dist/src/components/ui/tooltip.mjs +0 -38
  383. package/dist/src/hooks/editor/use-is-creator.mjs +0 -19
  384. package/dist/src/hooks/use-upload-file.mjs +0 -73
  385. package/dist/src/lib/config.mjs +0 -34
  386. package/dist/src/lib/data/store.d.mts +0 -15
  387. package/dist/src/lib/lowlight.mjs +0 -7
  388. package/dist/src/lib/utils/deep-equal.mjs +0 -18
  389. package/dist/src/lib/utils/remove-undefined.mjs +0 -18
  390. package/dist/src/lib/utils.mjs +0 -10
  391. package/next.config.ts +0 -23
  392. package/postcss.config.mjs +0 -7
  393. package/src/app/(dashboard)/collection/[name]/[...slug]/page.client.tsx +0 -26
  394. package/src/app/(dashboard)/collection/[name]/[...slug]/page.tsx +0 -18
  395. package/src/app/(dashboard)/collection/[name]/page.client.tsx +0 -82
  396. package/src/app/(dashboard)/collection/[name]/page.tsx +0 -11
  397. package/src/app/(dashboard)/layout.tsx +0 -34
  398. package/src/app/(dashboard)/page.tsx +0 -38
  399. package/src/app/api/ai/command/prompts.ts +0 -313
  400. package/src/app/api/ai/command/route.ts +0 -203
  401. package/src/app/api/ai/command/utils.ts +0 -242
  402. package/src/app/api/ai/copilot/route.ts +0 -33
  403. package/src/app/api/uploadthing/route.ts +0 -5
  404. package/src/app/codeblock/LICENSE +0 -21
  405. package/src/app/codeblock/styles.css +0 -289
  406. package/src/app/favicon.ico +0 -0
  407. package/src/app/globals.css +0 -223
  408. package/src/app/layout.client.tsx +0 -15
  409. package/src/app/layout.tsx +0 -30
  410. package/src/components/app-sidebar.tsx +0 -162
  411. package/src/components/code-editor/mdx.lazy.tsx +0 -18
  412. package/src/components/code-editor/mdx.tsx +0 -48
  413. package/src/components/code-editor/yaml.lazy.tsx +0 -20
  414. package/src/components/code-editor/yaml.tsx +0 -71
  415. package/src/components/collection/actions.tsx +0 -41
  416. package/src/components/collection/client.tsx +0 -63
  417. package/src/components/collection/context.tsx +0 -24
  418. package/src/components/collection/document/actions.tsx +0 -83
  419. package/src/components/editor/editor-base-kit.tsx +0 -37
  420. package/src/components/editor/editor-kit.tsx +0 -87
  421. package/src/components/editor/md.tsx +0 -60
  422. package/src/components/editor/plugins/ai-kit.tsx +0 -102
  423. package/src/components/editor/plugins/align-base-kit.tsx +0 -16
  424. package/src/components/editor/plugins/align-kit.tsx +0 -18
  425. package/src/components/editor/plugins/autoformat-kit.tsx +0 -236
  426. package/src/components/editor/plugins/basic-blocks-base-kit.tsx +0 -34
  427. package/src/components/editor/plugins/basic-blocks-kit.tsx +0 -87
  428. package/src/components/editor/plugins/basic-marks-base-kit.tsx +0 -26
  429. package/src/components/editor/plugins/basic-marks-kit.tsx +0 -40
  430. package/src/components/editor/plugins/basic-nodes-kit.tsx +0 -6
  431. package/src/components/editor/plugins/block-menu-kit.tsx +0 -14
  432. package/src/components/editor/plugins/block-placeholder-kit.tsx +0 -17
  433. package/src/components/editor/plugins/block-selection-kit.tsx +0 -54
  434. package/src/components/editor/plugins/callout-base-kit.tsx +0 -5
  435. package/src/components/editor/plugins/callout-kit.tsx +0 -7
  436. package/src/components/editor/plugins/code-block-base-kit.tsx +0 -16
  437. package/src/components/editor/plugins/code-block-kit.tsx +0 -19
  438. package/src/components/editor/plugins/column-base-kit.tsx +0 -11
  439. package/src/components/editor/plugins/column-kit.tsx +0 -10
  440. package/src/components/editor/plugins/comment-base-kit.tsx +0 -5
  441. package/src/components/editor/plugins/comment-kit.tsx +0 -92
  442. package/src/components/editor/plugins/copilot-kit.tsx +0 -70
  443. package/src/components/editor/plugins/cursor-overlay-kit.tsx +0 -13
  444. package/src/components/editor/plugins/date-base-kit.tsx +0 -5
  445. package/src/components/editor/plugins/date-kit.tsx +0 -7
  446. package/src/components/editor/plugins/discussion-kit.tsx +0 -142
  447. package/src/components/editor/plugins/dnd-kit.tsx +0 -25
  448. package/src/components/editor/plugins/emoji-kit.tsx +0 -13
  449. package/src/components/editor/plugins/exit-break-kit.tsx +0 -12
  450. package/src/components/editor/plugins/fixed-toolbar-kit.tsx +0 -19
  451. package/src/components/editor/plugins/floating-toolbar-kit.tsx +0 -19
  452. package/src/components/editor/plugins/font-base-kit.tsx +0 -20
  453. package/src/components/editor/plugins/font-kit.tsx +0 -29
  454. package/src/components/editor/plugins/indent-base-kit.tsx +0 -13
  455. package/src/components/editor/plugins/indent-kit.tsx +0 -22
  456. package/src/components/editor/plugins/line-height-base-kit.tsx +0 -14
  457. package/src/components/editor/plugins/line-height-kit.tsx +0 -16
  458. package/src/components/editor/plugins/link-base-kit.tsx +0 -5
  459. package/src/components/editor/plugins/link-kit.tsx +0 -15
  460. package/src/components/editor/plugins/list-base-kit.tsx +0 -17
  461. package/src/components/editor/plugins/list-kit.tsx +0 -26
  462. package/src/components/editor/plugins/markdown-kit.tsx +0 -13
  463. package/src/components/editor/plugins/math-base-kit.tsx +0 -11
  464. package/src/components/editor/plugins/math-kit.tsx +0 -10
  465. package/src/components/editor/plugins/media-base-kit.tsx +0 -25
  466. package/src/components/editor/plugins/media-kit.tsx +0 -28
  467. package/src/components/editor/plugins/slash-kit.tsx +0 -18
  468. package/src/components/editor/plugins/suggestion-base-kit.tsx +0 -5
  469. package/src/components/editor/plugins/suggestion-kit.tsx +0 -83
  470. package/src/components/editor/plugins/table-base-kit.tsx +0 -20
  471. package/src/components/editor/plugins/table-kit.tsx +0 -22
  472. package/src/components/editor/settings-dialog.tsx +0 -418
  473. package/src/components/editor/transforms.ts +0 -193
  474. package/src/components/editor/types.ts +0 -149
  475. package/src/components/editor/ui/ai-chat-editor.tsx +0 -20
  476. package/src/components/editor/ui/ai-menu.tsx +0 -663
  477. package/src/components/editor/ui/ai-node.tsx +0 -40
  478. package/src/components/editor/ui/ai-toolbar-button.tsx +0 -23
  479. package/src/components/editor/ui/align-toolbar-button.tsx +0 -78
  480. package/src/components/editor/ui/block-context-menu.tsx +0 -154
  481. package/src/components/editor/ui/block-discussion.tsx +0 -318
  482. package/src/components/editor/ui/block-draggable.tsx +0 -464
  483. package/src/components/editor/ui/block-list-static.tsx +0 -75
  484. package/src/components/editor/ui/block-list.tsx +0 -72
  485. package/src/components/editor/ui/block-selection.tsx +0 -37
  486. package/src/components/editor/ui/block-suggestion.tsx +0 -438
  487. package/src/components/editor/ui/blockquote-node-static.tsx +0 -5
  488. package/src/components/editor/ui/blockquote-node.tsx +0 -7
  489. package/src/components/editor/ui/callout-node-static.tsx +0 -30
  490. package/src/components/editor/ui/callout-node.tsx +0 -64
  491. package/src/components/editor/ui/caption.tsx +0 -55
  492. package/src/components/editor/ui/code-block-node-static.tsx +0 -33
  493. package/src/components/editor/ui/code-block-node.tsx +0 -161
  494. package/src/components/editor/ui/code-node-static.tsx +0 -15
  495. package/src/components/editor/ui/code-node.tsx +0 -17
  496. package/src/components/editor/ui/column-node-static.tsx +0 -27
  497. package/src/components/editor/ui/column-node.tsx +0 -285
  498. package/src/components/editor/ui/comment-node-static.tsx +0 -12
  499. package/src/components/editor/ui/comment-node.tsx +0 -43
  500. package/src/components/editor/ui/comment-toolbar-button.tsx +0 -24
  501. package/src/components/editor/ui/comment.tsx +0 -577
  502. package/src/components/editor/ui/cursor-overlay.tsx +0 -66
  503. package/src/components/editor/ui/date-node-static.tsx +0 -45
  504. package/src/components/editor/ui/date-node.tsx +0 -86
  505. package/src/components/editor/ui/editor-static.tsx +0 -47
  506. package/src/components/editor/ui/editor.tsx +0 -120
  507. package/src/components/editor/ui/emoji-node.tsx +0 -65
  508. package/src/components/editor/ui/emoji-toolbar-button.tsx +0 -582
  509. package/src/components/editor/ui/equation-node-static.tsx +0 -94
  510. package/src/components/editor/ui/equation-node.tsx +0 -218
  511. package/src/components/editor/ui/equation-toolbar-button.tsx +0 -24
  512. package/src/components/editor/ui/fixed-toolbar-buttons.tsx +0 -135
  513. package/src/components/editor/ui/fixed-toolbar.tsx +0 -17
  514. package/src/components/editor/ui/floating-toolbar-buttons.tsx +0 -72
  515. package/src/components/editor/ui/floating-toolbar.tsx +0 -76
  516. package/src/components/editor/ui/font-color-toolbar-button.tsx +0 -804
  517. package/src/components/editor/ui/font-size-toolbar-button.tsx +0 -102
  518. package/src/components/editor/ui/ghost-text.tsx +0 -27
  519. package/src/components/editor/ui/heading-node-static.tsx +0 -54
  520. package/src/components/editor/ui/heading-node.tsx +0 -54
  521. package/src/components/editor/ui/highlight-node-static.tsx +0 -11
  522. package/src/components/editor/ui/highlight-node.tsx +0 -13
  523. package/src/components/editor/ui/history-toolbar-button.tsx +0 -41
  524. package/src/components/editor/ui/hr-node-static.tsx +0 -16
  525. package/src/components/editor/ui/hr-node.tsx +0 -28
  526. package/src/components/editor/ui/indent-toolbar-button.tsx +0 -27
  527. package/src/components/editor/ui/inline-combobox.tsx +0 -251
  528. package/src/components/editor/ui/insert-toolbar-button.tsx +0 -242
  529. package/src/components/editor/ui/kbd-node-static.tsx +0 -15
  530. package/src/components/editor/ui/kbd-node.tsx +0 -17
  531. package/src/components/editor/ui/line-height-toolbar-button.tsx +0 -66
  532. package/src/components/editor/ui/link-node-static.tsx +0 -21
  533. package/src/components/editor/ui/link-node.tsx +0 -37
  534. package/src/components/editor/ui/link-toolbar-button.tsx +0 -18
  535. package/src/components/editor/ui/link-toolbar.tsx +0 -196
  536. package/src/components/editor/ui/list-toolbar-button.tsx +0 -195
  537. package/src/components/editor/ui/mark-toolbar-button.tsx +0 -20
  538. package/src/components/editor/ui/media-image-node-static.tsx +0 -33
  539. package/src/components/editor/ui/media-image-node.tsx +0 -75
  540. package/src/components/editor/ui/media-placeholder-node.tsx +0 -235
  541. package/src/components/editor/ui/media-preview-dialog.tsx +0 -145
  542. package/src/components/editor/ui/media-toolbar-button.tsx +0 -202
  543. package/src/components/editor/ui/media-toolbar.tsx +0 -100
  544. package/src/components/editor/ui/media-upload-toast.tsx +0 -59
  545. package/src/components/editor/ui/media-video-node-static.tsx +0 -23
  546. package/src/components/editor/ui/mode-toolbar-button.tsx +0 -121
  547. package/src/components/editor/ui/paragraph-node-static.tsx +0 -13
  548. package/src/components/editor/ui/paragraph-node.tsx +0 -15
  549. package/src/components/editor/ui/resize-handle.tsx +0 -79
  550. package/src/components/editor/ui/slash-node.tsx +0 -274
  551. package/src/components/editor/ui/suggestion-node-static.tsx +0 -30
  552. package/src/components/editor/ui/suggestion-node.tsx +0 -157
  553. package/src/components/editor/ui/suggestion-toolbar-button.tsx +0 -25
  554. package/src/components/editor/ui/table-icons.tsx +0 -685
  555. package/src/components/editor/ui/table-node-static.tsx +0 -86
  556. package/src/components/editor/ui/table-node.tsx +0 -569
  557. package/src/components/editor/ui/table-toolbar-button.tsx +0 -260
  558. package/src/components/editor/ui/turn-into-toolbar-button.tsx +0 -176
  559. package/src/components/editor/use-chat.ts +0 -120
  560. package/src/components/icons/logo.tsx +0 -37
  561. package/src/components/json-schema-editor/client.tsx +0 -55
  562. package/src/components/json-schema-editor/components/inputs.tsx +0 -612
  563. package/src/components/json-schema-editor/get-default-values.ts +0 -29
  564. package/src/components/json-schema-editor/schema.tsx +0 -206
  565. package/src/components/json-schema-editor/utils/merge-schema.ts +0 -167
  566. package/src/components/json-schema-editor/utils/schema-to-string.ts +0 -87
  567. package/src/components/nav-user.tsx +0 -102
  568. package/src/components/site-header.tsx +0 -13
  569. package/src/components/ui/alert-dialog.tsx +0 -182
  570. package/src/components/ui/avatar.tsx +0 -96
  571. package/src/components/ui/button.tsx +0 -65
  572. package/src/components/ui/calendar.tsx +0 -186
  573. package/src/components/ui/checkbox.tsx +0 -29
  574. package/src/components/ui/combobox.tsx +0 -267
  575. package/src/components/ui/command.tsx +0 -180
  576. package/src/components/ui/context-menu.tsx +0 -161
  577. package/src/components/ui/dialog.tsx +0 -142
  578. package/src/components/ui/drawer.tsx +0 -120
  579. package/src/components/ui/dropdown-menu.tsx +0 -239
  580. package/src/components/ui/field.tsx +0 -224
  581. package/src/components/ui/input-group.tsx +0 -144
  582. package/src/components/ui/input.tsx +0 -19
  583. package/src/components/ui/label.tsx +0 -18
  584. package/src/components/ui/popover.tsx +0 -76
  585. package/src/components/ui/select.tsx +0 -182
  586. package/src/components/ui/separator.tsx +0 -28
  587. package/src/components/ui/sheet.tsx +0 -130
  588. package/src/components/ui/sidebar.tsx +0 -608
  589. package/src/components/ui/sonner.tsx +0 -45
  590. package/src/components/ui/spinner.tsx +0 -15
  591. package/src/components/ui/table.tsx +0 -89
  592. package/src/components/ui/tabs.tsx +0 -60
  593. package/src/components/ui/textarea.tsx +0 -18
  594. package/src/components/ui/toggle-group.tsx +0 -86
  595. package/src/components/ui/toggle.tsx +0 -45
  596. package/src/components/ui/toolbar.tsx +0 -365
  597. package/src/components/ui/tooltip.tsx +0 -57
  598. package/src/hooks/editor/use-is-creator.ts +0 -21
  599. package/src/hooks/use-mobile.ts +0 -19
  600. package/src/hooks/use-mounted.ts +0 -11
  601. package/src/hooks/use-upload-file.ts +0 -121
  602. package/src/lib/ai/markdown-joiner-transform.ts +0 -235
  603. package/src/lib/config.ts +0 -42
  604. package/src/lib/data/actions.ts +0 -46
  605. package/src/lib/data/boundary.client.tsx +0 -22
  606. package/src/lib/data/boundary.tsx +0 -22
  607. package/src/lib/data/query.ts +0 -9
  608. package/src/lib/data/store.ts +0 -52
  609. package/src/lib/lowlight.ts +0 -3
  610. package/src/lib/uploadthing.ts +0 -19
  611. package/src/lib/utils/deep-equal.ts +0 -37
  612. package/src/lib/utils/remove-undefined.ts +0 -21
  613. package/src/lib/utils/urls.ts +0 -6
  614. package/src/lib/utils.ts +0 -6
  615. package/tsconfig.build.json +0 -24
  616. package/tsconfig.json +0 -37
@@ -0,0 +1,3404 @@
1
+ import { d as We, r as reactExports, j as jsxRuntimeExports } from "../index.js";
2
+ import { C as ChevronDown, S as Select, a as SelectTrigger, b as SelectValue, c as SelectContent, d as SelectItem, e as Spinner } from "./spinner-BXcLlTNs.js";
3
+ import { c as createLucideIcon, P as Primitive, h as useControllableState, a as createContextScope, k as useId, b as composeEventHandlers, g as Presence, s as cn, v as buttonVariants, X } from "./button-C_-b_vqm.js";
4
+ import { cva } from "class-variance-authority";
5
+ import { Ajv2020 } from "ajv/dist/2020.js";
6
+ import { u as useDirection, c as createRovingFocusGroupScope, R as Root$1, I as Item, C as Check } from "./index-DBc0nhEL.js";
7
+ const __iconNode$3 = [
8
+ ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
9
+ ["line", { x1: "12", x2: "12", y1: "8", y2: "12", key: "1pkeuh" }],
10
+ ["line", { x1: "12", x2: "12.01", y1: "16", y2: "16", key: "4dfq90" }]
11
+ ];
12
+ const CircleAlert = createLucideIcon("circle-alert", __iconNode$3);
13
+ const __iconNode$2 = [["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }]];
14
+ const Circle = createLucideIcon("circle", __iconNode$2);
15
+ const __iconNode$1 = [
16
+ ["path", { d: "M5 12h14", key: "1ays0h" }],
17
+ ["path", { d: "M12 5v14", key: "s699le" }]
18
+ ];
19
+ const Plus = createLucideIcon("plus", __iconNode$1);
20
+ const __iconNode = [
21
+ ["path", { d: "M10 11v6", key: "nco0om" }],
22
+ ["path", { d: "M14 11v6", key: "outv1u" }],
23
+ ["path", { d: "M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6", key: "miytrc" }],
24
+ ["path", { d: "M3 6h18", key: "d0wm0j" }],
25
+ ["path", { d: "M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2", key: "e791ji" }]
26
+ ];
27
+ const Trash2 = createLucideIcon("trash-2", __iconNode);
28
+ var isCheckBoxInput = (element) => element.type === "checkbox";
29
+ var isDateObject = (value) => value instanceof Date;
30
+ var isNullOrUndefined = (value) => value == null;
31
+ const isObjectType = (value) => typeof value === "object";
32
+ var isObject = (value) => !isNullOrUndefined(value) && !Array.isArray(value) && isObjectType(value) && !isDateObject(value);
33
+ var getEventValue = (event) => isObject(event) && event.target ? isCheckBoxInput(event.target) ? event.target.checked : event.target.value : event;
34
+ var getNodeParentName = (name) => name.substring(0, name.search(/\.\d+(\.|$)/)) || name;
35
+ var isNameInFieldArray = (names, name) => names.has(getNodeParentName(name));
36
+ var isPlainObject = (tempObject) => {
37
+ const prototypeCopy = tempObject.constructor && tempObject.constructor.prototype;
38
+ return isObject(prototypeCopy) && prototypeCopy.hasOwnProperty("isPrototypeOf");
39
+ };
40
+ var isWeb = typeof window !== "undefined" && typeof window.HTMLElement !== "undefined" && typeof document !== "undefined";
41
+ function cloneObject(data) {
42
+ if (data instanceof Date) {
43
+ return new Date(data);
44
+ }
45
+ const isFileListInstance = typeof FileList !== "undefined" && data instanceof FileList;
46
+ if (isWeb && (data instanceof Blob || isFileListInstance)) {
47
+ return data;
48
+ }
49
+ const isArray = Array.isArray(data);
50
+ if (!isArray && !(isObject(data) && isPlainObject(data))) {
51
+ return data;
52
+ }
53
+ const copy = isArray ? [] : Object.create(Object.getPrototypeOf(data));
54
+ for (const key in data) {
55
+ if (Object.prototype.hasOwnProperty.call(data, key)) {
56
+ copy[key] = cloneObject(data[key]);
57
+ }
58
+ }
59
+ return copy;
60
+ }
61
+ var isKey = (value) => /^\w*$/.test(value);
62
+ var isUndefined = (val) => val === void 0;
63
+ var compact = (value) => Array.isArray(value) ? value.filter(Boolean) : [];
64
+ var stringToPath = (input) => compact(input.replace(/["|']|\]/g, "").split(/\.|\[/));
65
+ var get = (object, path, defaultValue) => {
66
+ if (!path || !isObject(object)) {
67
+ return defaultValue;
68
+ }
69
+ const result = (isKey(path) ? [path] : stringToPath(path)).reduce((result2, key) => isNullOrUndefined(result2) ? result2 : result2[key], object);
70
+ return isUndefined(result) || result === object ? isUndefined(object[path]) ? defaultValue : object[path] : result;
71
+ };
72
+ var isBoolean = (value) => typeof value === "boolean";
73
+ var isFunction = (value) => typeof value === "function";
74
+ var set = (object, path, value) => {
75
+ let index = -1;
76
+ const tempPath = isKey(path) ? [path] : stringToPath(path);
77
+ const length = tempPath.length;
78
+ const lastIndex = length - 1;
79
+ while (++index < length) {
80
+ const key = tempPath[index];
81
+ let newValue = value;
82
+ if (index !== lastIndex) {
83
+ const objValue = object[key];
84
+ newValue = isObject(objValue) || Array.isArray(objValue) ? objValue : !isNaN(+tempPath[index + 1]) ? [] : {};
85
+ }
86
+ if (key === "__proto__" || key === "constructor" || key === "prototype") {
87
+ return;
88
+ }
89
+ object[key] = newValue;
90
+ object = object[key];
91
+ }
92
+ };
93
+ const EVENTS = {
94
+ BLUR: "blur",
95
+ FOCUS_OUT: "focusout",
96
+ CHANGE: "change"
97
+ };
98
+ const VALIDATION_MODE = {
99
+ onBlur: "onBlur",
100
+ onChange: "onChange",
101
+ onSubmit: "onSubmit",
102
+ onTouched: "onTouched",
103
+ all: "all"
104
+ };
105
+ const INPUT_VALIDATION_RULES = {
106
+ max: "max",
107
+ min: "min",
108
+ maxLength: "maxLength",
109
+ minLength: "minLength",
110
+ pattern: "pattern",
111
+ required: "required",
112
+ validate: "validate"
113
+ };
114
+ const HookFormControlContext = We.createContext(null);
115
+ HookFormControlContext.displayName = "HookFormControlContext";
116
+ const useFormControlContext = () => We.useContext(HookFormControlContext);
117
+ var getProxyFormState = (formState, control, localProxyFormState, isRoot = true) => {
118
+ const result = {
119
+ defaultValues: control._defaultValues
120
+ };
121
+ for (const key in formState) {
122
+ Object.defineProperty(result, key, {
123
+ get: () => {
124
+ const _key = key;
125
+ if (control._proxyFormState[_key] !== VALIDATION_MODE.all) {
126
+ control._proxyFormState[_key] = !isRoot || VALIDATION_MODE.all;
127
+ }
128
+ localProxyFormState && (localProxyFormState[_key] = true);
129
+ return formState[_key];
130
+ }
131
+ });
132
+ }
133
+ return result;
134
+ };
135
+ const useIsomorphicLayoutEffect = typeof window !== "undefined" ? We.useLayoutEffect : We.useEffect;
136
+ function useFormState(props) {
137
+ const formControl = useFormControlContext();
138
+ const { control = formControl, disabled, name, exact } = props || {};
139
+ const [formState, updateFormState] = We.useState(control._formState);
140
+ const _localProxyFormState = We.useRef({
141
+ isDirty: false,
142
+ isLoading: false,
143
+ dirtyFields: false,
144
+ touchedFields: false,
145
+ validatingFields: false,
146
+ isValidating: false,
147
+ isValid: false,
148
+ errors: false
149
+ });
150
+ useIsomorphicLayoutEffect(() => control._subscribe({
151
+ name,
152
+ formState: _localProxyFormState.current,
153
+ exact,
154
+ callback: (formState2) => {
155
+ !disabled && updateFormState({
156
+ ...control._formState,
157
+ ...formState2
158
+ });
159
+ }
160
+ }), [name, disabled, exact]);
161
+ We.useEffect(() => {
162
+ _localProxyFormState.current.isValid && control._setValid(true);
163
+ }, [control]);
164
+ return We.useMemo(() => getProxyFormState(formState, control, _localProxyFormState.current, false), [formState, control]);
165
+ }
166
+ var isString = (value) => typeof value === "string";
167
+ var generateWatchOutput = (names, _names, formValues, isGlobal, defaultValue) => {
168
+ if (isString(names)) {
169
+ isGlobal && _names.watch.add(names);
170
+ return get(formValues, names, defaultValue);
171
+ }
172
+ if (Array.isArray(names)) {
173
+ return names.map((fieldName) => (isGlobal && _names.watch.add(fieldName), get(formValues, fieldName)));
174
+ }
175
+ isGlobal && (_names.watchAll = true);
176
+ return formValues;
177
+ };
178
+ var isPrimitive = (value) => isNullOrUndefined(value) || !isObjectType(value);
179
+ function deepEqual$1(object1, object2, _internal_visited = /* @__PURE__ */ new WeakSet()) {
180
+ if (isPrimitive(object1) || isPrimitive(object2)) {
181
+ return Object.is(object1, object2);
182
+ }
183
+ if (isDateObject(object1) && isDateObject(object2)) {
184
+ return Object.is(object1.getTime(), object2.getTime());
185
+ }
186
+ const keys1 = Object.keys(object1);
187
+ const keys2 = Object.keys(object2);
188
+ if (keys1.length !== keys2.length) {
189
+ return false;
190
+ }
191
+ if (_internal_visited.has(object1) || _internal_visited.has(object2)) {
192
+ return true;
193
+ }
194
+ _internal_visited.add(object1);
195
+ _internal_visited.add(object2);
196
+ for (const key of keys1) {
197
+ const val1 = object1[key];
198
+ if (!keys2.includes(key)) {
199
+ return false;
200
+ }
201
+ if (key !== "ref") {
202
+ const val2 = object2[key];
203
+ if (isDateObject(val1) && isDateObject(val2) || isObject(val1) && isObject(val2) || Array.isArray(val1) && Array.isArray(val2) ? !deepEqual$1(val1, val2, _internal_visited) : !Object.is(val1, val2)) {
204
+ return false;
205
+ }
206
+ }
207
+ }
208
+ return true;
209
+ }
210
+ function useWatch(props) {
211
+ const formControl = useFormControlContext();
212
+ const { control = formControl, name, defaultValue, disabled, exact, compute } = props || {};
213
+ const _defaultValue = We.useRef(defaultValue);
214
+ const _compute = We.useRef(compute);
215
+ const _computeFormValues = We.useRef(void 0);
216
+ const _prevControl = We.useRef(control);
217
+ const _prevName = We.useRef(name);
218
+ _compute.current = compute;
219
+ const [value, updateValue] = We.useState(() => {
220
+ const defaultValue2 = control._getWatch(name, _defaultValue.current);
221
+ return _compute.current ? _compute.current(defaultValue2) : defaultValue2;
222
+ });
223
+ const getCurrentOutput = We.useCallback((values) => {
224
+ const formValues = generateWatchOutput(name, control._names, values || control._formValues, false, _defaultValue.current);
225
+ return _compute.current ? _compute.current(formValues) : formValues;
226
+ }, [control._formValues, control._names, name]);
227
+ const refreshValue = We.useCallback((values) => {
228
+ if (!disabled) {
229
+ const formValues = generateWatchOutput(name, control._names, values || control._formValues, false, _defaultValue.current);
230
+ if (_compute.current) {
231
+ const computedFormValues = _compute.current(formValues);
232
+ if (!deepEqual$1(computedFormValues, _computeFormValues.current)) {
233
+ updateValue(computedFormValues);
234
+ _computeFormValues.current = computedFormValues;
235
+ }
236
+ } else {
237
+ updateValue(formValues);
238
+ }
239
+ }
240
+ }, [control._formValues, control._names, disabled, name]);
241
+ useIsomorphicLayoutEffect(() => {
242
+ if (_prevControl.current !== control || !deepEqual$1(_prevName.current, name)) {
243
+ _prevControl.current = control;
244
+ _prevName.current = name;
245
+ refreshValue();
246
+ }
247
+ return control._subscribe({
248
+ name,
249
+ formState: {
250
+ values: true
251
+ },
252
+ exact,
253
+ callback: (formState) => {
254
+ refreshValue(formState.values);
255
+ }
256
+ });
257
+ }, [control, exact, name, refreshValue]);
258
+ We.useEffect(() => control._removeUnmounted());
259
+ const controlChanged = _prevControl.current !== control;
260
+ const prevName = _prevName.current;
261
+ const computedOutput = We.useMemo(() => {
262
+ if (disabled) {
263
+ return null;
264
+ }
265
+ const nameChanged = !controlChanged && !deepEqual$1(prevName, name);
266
+ const shouldReturnImmediate = controlChanged || nameChanged;
267
+ return shouldReturnImmediate ? getCurrentOutput() : null;
268
+ }, [disabled, controlChanged, name, prevName, getCurrentOutput]);
269
+ return computedOutput !== null ? computedOutput : value;
270
+ }
271
+ function useController(props) {
272
+ const formControl = useFormControlContext();
273
+ const { name, disabled, control = formControl, shouldUnregister, defaultValue, exact = true } = props;
274
+ const isArrayField = isNameInFieldArray(control._names.array, name);
275
+ const defaultValueMemo = We.useMemo(() => get(control._formValues, name, get(control._defaultValues, name, defaultValue)), [control, name, defaultValue]);
276
+ const value = useWatch({
277
+ control,
278
+ name,
279
+ defaultValue: defaultValueMemo,
280
+ exact
281
+ });
282
+ const formState = useFormState({
283
+ control,
284
+ name,
285
+ exact
286
+ });
287
+ const _props = We.useRef(props);
288
+ const _previousNameRef = We.useRef(void 0);
289
+ const _registerProps = We.useRef(control.register(name, {
290
+ ...props.rules,
291
+ value,
292
+ ...isBoolean(props.disabled) ? { disabled: props.disabled } : {}
293
+ }));
294
+ _props.current = props;
295
+ const fieldState = We.useMemo(() => Object.defineProperties({}, {
296
+ invalid: {
297
+ enumerable: true,
298
+ get: () => !!get(formState.errors, name)
299
+ },
300
+ isDirty: {
301
+ enumerable: true,
302
+ get: () => !!get(formState.dirtyFields, name)
303
+ },
304
+ isTouched: {
305
+ enumerable: true,
306
+ get: () => !!get(formState.touchedFields, name)
307
+ },
308
+ isValidating: {
309
+ enumerable: true,
310
+ get: () => !!get(formState.validatingFields, name)
311
+ },
312
+ error: {
313
+ enumerable: true,
314
+ get: () => get(formState.errors, name)
315
+ }
316
+ }), [formState, name]);
317
+ const onChange = We.useCallback((event) => _registerProps.current.onChange({
318
+ target: {
319
+ value: getEventValue(event),
320
+ name
321
+ },
322
+ type: EVENTS.CHANGE
323
+ }), [name]);
324
+ const onBlur = We.useCallback(() => _registerProps.current.onBlur({
325
+ target: {
326
+ value: get(control._formValues, name),
327
+ name
328
+ },
329
+ type: EVENTS.BLUR
330
+ }), [name, control._formValues]);
331
+ const ref = We.useCallback((elm) => {
332
+ const field2 = get(control._fields, name);
333
+ if (field2 && field2._f && elm) {
334
+ field2._f.ref = {
335
+ focus: () => isFunction(elm.focus) && elm.focus(),
336
+ select: () => isFunction(elm.select) && elm.select(),
337
+ setCustomValidity: (message) => isFunction(elm.setCustomValidity) && elm.setCustomValidity(message),
338
+ reportValidity: () => isFunction(elm.reportValidity) && elm.reportValidity()
339
+ };
340
+ }
341
+ }, [control._fields, name]);
342
+ const field = We.useMemo(() => ({
343
+ name,
344
+ value,
345
+ ...isBoolean(disabled) || formState.disabled ? { disabled: formState.disabled || disabled } : {},
346
+ onChange,
347
+ onBlur,
348
+ ref
349
+ }), [name, disabled, formState.disabled, onChange, onBlur, ref, value]);
350
+ We.useEffect(() => {
351
+ const _shouldUnregisterField = control._options.shouldUnregister || shouldUnregister;
352
+ const previousName = _previousNameRef.current;
353
+ if (previousName && previousName !== name && !isArrayField) {
354
+ control.unregister(previousName);
355
+ }
356
+ control.register(name, {
357
+ ..._props.current.rules,
358
+ ...isBoolean(_props.current.disabled) ? { disabled: _props.current.disabled } : {}
359
+ });
360
+ const updateMounted = (name2, value2) => {
361
+ const field2 = get(control._fields, name2);
362
+ if (field2 && field2._f) {
363
+ field2._f.mount = value2;
364
+ }
365
+ };
366
+ updateMounted(name, true);
367
+ if (_shouldUnregisterField) {
368
+ const value2 = cloneObject(get(control._options.defaultValues, name, _props.current.defaultValue));
369
+ set(control._defaultValues, name, value2);
370
+ if (isUndefined(get(control._formValues, name))) {
371
+ set(control._formValues, name, value2);
372
+ }
373
+ }
374
+ !isArrayField && control.register(name);
375
+ _previousNameRef.current = name;
376
+ return () => {
377
+ (isArrayField ? _shouldUnregisterField && !control._state.action : _shouldUnregisterField) ? control.unregister(name) : updateMounted(name, false);
378
+ };
379
+ }, [name, control, isArrayField, shouldUnregister]);
380
+ We.useEffect(() => {
381
+ control._setDisabledField({
382
+ disabled,
383
+ name
384
+ });
385
+ }, [disabled, name, control]);
386
+ return We.useMemo(() => ({
387
+ field,
388
+ formState,
389
+ fieldState
390
+ }), [field, formState, fieldState]);
391
+ }
392
+ const Controller = (props) => props.render(useController(props));
393
+ const HookFormContext = We.createContext(null);
394
+ HookFormContext.displayName = "HookFormContext";
395
+ const useFormContext = () => We.useContext(HookFormContext);
396
+ const FormProvider = (props) => {
397
+ const { children, watch, getValues, getFieldState, setError, clearErrors, setValue, trigger, formState, resetField, reset, handleSubmit, unregister, control, register, setFocus, subscribe } = props;
398
+ return We.createElement(
399
+ HookFormContext.Provider,
400
+ { value: We.useMemo(() => ({
401
+ watch,
402
+ getValues,
403
+ getFieldState,
404
+ setError,
405
+ clearErrors,
406
+ setValue,
407
+ trigger,
408
+ formState,
409
+ resetField,
410
+ reset,
411
+ handleSubmit,
412
+ unregister,
413
+ control,
414
+ register,
415
+ setFocus,
416
+ subscribe
417
+ }), [
418
+ clearErrors,
419
+ control,
420
+ formState,
421
+ getFieldState,
422
+ getValues,
423
+ handleSubmit,
424
+ register,
425
+ reset,
426
+ resetField,
427
+ setError,
428
+ setFocus,
429
+ setValue,
430
+ subscribe,
431
+ trigger,
432
+ unregister,
433
+ watch
434
+ ]) },
435
+ We.createElement(HookFormControlContext.Provider, { value: control }, children)
436
+ );
437
+ };
438
+ var appendErrors = (name, validateAllFieldCriteria, errors, type, message) => validateAllFieldCriteria ? {
439
+ ...errors[name],
440
+ types: {
441
+ ...errors[name] && errors[name].types ? errors[name].types : {},
442
+ [type]: message || true
443
+ }
444
+ } : {};
445
+ var convertToArrayPayload = (value) => Array.isArray(value) ? value : [value];
446
+ var createSubject = () => {
447
+ let _observers = [];
448
+ const next = (value) => {
449
+ for (const observer of _observers) {
450
+ observer.next && observer.next(value);
451
+ }
452
+ };
453
+ const subscribe = (observer) => {
454
+ _observers.push(observer);
455
+ return {
456
+ unsubscribe: () => {
457
+ _observers = _observers.filter((o) => o !== observer);
458
+ }
459
+ };
460
+ };
461
+ const unsubscribe = () => {
462
+ _observers = [];
463
+ };
464
+ return {
465
+ get observers() {
466
+ return _observers;
467
+ },
468
+ next,
469
+ subscribe,
470
+ unsubscribe
471
+ };
472
+ };
473
+ function extractFormValues(fieldsState, formValues) {
474
+ const values = {};
475
+ for (const key in fieldsState) {
476
+ if (fieldsState.hasOwnProperty(key)) {
477
+ const fieldState = fieldsState[key];
478
+ const fieldValue = formValues[key];
479
+ if (fieldState && isObject(fieldState) && fieldValue) {
480
+ const nestedFieldsState = extractFormValues(fieldState, fieldValue);
481
+ if (isObject(nestedFieldsState)) {
482
+ values[key] = nestedFieldsState;
483
+ }
484
+ } else if (fieldsState[key]) {
485
+ values[key] = fieldValue;
486
+ }
487
+ }
488
+ }
489
+ return values;
490
+ }
491
+ var isEmptyObject = (value) => isObject(value) && !Object.keys(value).length;
492
+ var isFileInput = (element) => element.type === "file";
493
+ var isHTMLElement = (value) => {
494
+ if (!isWeb) {
495
+ return false;
496
+ }
497
+ const owner = value ? value.ownerDocument : 0;
498
+ return value instanceof (owner && owner.defaultView ? owner.defaultView.HTMLElement : HTMLElement);
499
+ };
500
+ var isMultipleSelect = (element) => element.type === `select-multiple`;
501
+ var isRadioInput = (element) => element.type === "radio";
502
+ var isRadioOrCheckbox = (ref) => isRadioInput(ref) || isCheckBoxInput(ref);
503
+ var live = (ref) => isHTMLElement(ref) && ref.isConnected;
504
+ function baseGet(object, updatePath) {
505
+ const length = updatePath.slice(0, -1).length;
506
+ let index = 0;
507
+ while (index < length) {
508
+ object = isUndefined(object) ? index++ : object[updatePath[index++]];
509
+ }
510
+ return object;
511
+ }
512
+ function isEmptyArray(obj) {
513
+ for (const key in obj) {
514
+ if (obj.hasOwnProperty(key) && !isUndefined(obj[key])) {
515
+ return false;
516
+ }
517
+ }
518
+ return true;
519
+ }
520
+ function unset(object, path) {
521
+ const paths = Array.isArray(path) ? path : isKey(path) ? [path] : stringToPath(path);
522
+ const childObject = paths.length === 1 ? object : baseGet(object, paths);
523
+ const index = paths.length - 1;
524
+ const key = paths[index];
525
+ if (childObject) {
526
+ delete childObject[key];
527
+ }
528
+ if (index !== 0 && (isObject(childObject) && isEmptyObject(childObject) || Array.isArray(childObject) && isEmptyArray(childObject))) {
529
+ unset(object, paths.slice(0, -1));
530
+ }
531
+ return object;
532
+ }
533
+ var objectHasFunction = (data) => {
534
+ for (const key in data) {
535
+ if (isFunction(data[key])) {
536
+ return true;
537
+ }
538
+ }
539
+ return false;
540
+ };
541
+ function isTraversable(value) {
542
+ return Array.isArray(value) || isObject(value) && !objectHasFunction(value);
543
+ }
544
+ function markFieldsDirty(data, fields = {}) {
545
+ for (const key in data) {
546
+ const value = data[key];
547
+ if (isTraversable(value)) {
548
+ fields[key] = Array.isArray(value) ? [] : {};
549
+ markFieldsDirty(value, fields[key]);
550
+ } else if (!isUndefined(value)) {
551
+ fields[key] = true;
552
+ }
553
+ }
554
+ return fields;
555
+ }
556
+ function getDirtyFields(data, formValues, dirtyFieldsFromValues) {
557
+ if (!dirtyFieldsFromValues) {
558
+ dirtyFieldsFromValues = markFieldsDirty(formValues);
559
+ }
560
+ for (const key in data) {
561
+ const value = data[key];
562
+ if (isTraversable(value)) {
563
+ if (isUndefined(formValues) || isPrimitive(dirtyFieldsFromValues[key])) {
564
+ dirtyFieldsFromValues[key] = markFieldsDirty(value, Array.isArray(value) ? [] : {});
565
+ } else {
566
+ getDirtyFields(value, isNullOrUndefined(formValues) ? {} : formValues[key], dirtyFieldsFromValues[key]);
567
+ }
568
+ } else {
569
+ const formValue = formValues[key];
570
+ dirtyFieldsFromValues[key] = !deepEqual$1(value, formValue);
571
+ }
572
+ }
573
+ return dirtyFieldsFromValues;
574
+ }
575
+ const defaultResult = {
576
+ value: false,
577
+ isValid: false
578
+ };
579
+ const validResult = { value: true, isValid: true };
580
+ var getCheckboxValue = (options) => {
581
+ if (Array.isArray(options)) {
582
+ if (options.length > 1) {
583
+ const values = options.filter((option) => option && option.checked && !option.disabled).map((option) => option.value);
584
+ return { value: values, isValid: !!values.length };
585
+ }
586
+ return options[0].checked && !options[0].disabled ? (
587
+ // @ts-expect-error expected to work in the browser
588
+ options[0].attributes && !isUndefined(options[0].attributes.value) ? isUndefined(options[0].value) || options[0].value === "" ? validResult : { value: options[0].value, isValid: true } : validResult
589
+ ) : defaultResult;
590
+ }
591
+ return defaultResult;
592
+ };
593
+ var getFieldValueAs = (value, { valueAsNumber, valueAsDate, setValueAs }) => isUndefined(value) ? value : valueAsNumber ? value === "" ? NaN : value ? +value : value : valueAsDate && isString(value) ? new Date(value) : setValueAs ? setValueAs(value) : value;
594
+ const defaultReturn = {
595
+ isValid: false,
596
+ value: null
597
+ };
598
+ var getRadioValue = (options) => Array.isArray(options) ? options.reduce((previous, option) => option && option.checked && !option.disabled ? {
599
+ isValid: true,
600
+ value: option.value
601
+ } : previous, defaultReturn) : defaultReturn;
602
+ function getFieldValue(_f) {
603
+ const ref = _f.ref;
604
+ if (isFileInput(ref)) {
605
+ return ref.files;
606
+ }
607
+ if (isRadioInput(ref)) {
608
+ return getRadioValue(_f.refs).value;
609
+ }
610
+ if (isMultipleSelect(ref)) {
611
+ return [...ref.selectedOptions].map(({ value }) => value);
612
+ }
613
+ if (isCheckBoxInput(ref)) {
614
+ return getCheckboxValue(_f.refs).value;
615
+ }
616
+ return getFieldValueAs(isUndefined(ref.value) ? _f.ref.value : ref.value, _f);
617
+ }
618
+ var getResolverOptions = (fieldsNames, _fields, criteriaMode, shouldUseNativeValidation) => {
619
+ const fields = {};
620
+ for (const name of fieldsNames) {
621
+ const field = get(_fields, name);
622
+ field && set(fields, name, field._f);
623
+ }
624
+ return {
625
+ criteriaMode,
626
+ names: [...fieldsNames],
627
+ fields,
628
+ shouldUseNativeValidation
629
+ };
630
+ };
631
+ var isRegex = (value) => value instanceof RegExp;
632
+ var getRuleValue = (rule) => isUndefined(rule) ? rule : isRegex(rule) ? rule.source : isObject(rule) ? isRegex(rule.value) ? rule.value.source : rule.value : rule;
633
+ var getValidationModes = (mode) => ({
634
+ isOnSubmit: !mode || mode === VALIDATION_MODE.onSubmit,
635
+ isOnBlur: mode === VALIDATION_MODE.onBlur,
636
+ isOnChange: mode === VALIDATION_MODE.onChange,
637
+ isOnAll: mode === VALIDATION_MODE.all,
638
+ isOnTouch: mode === VALIDATION_MODE.onTouched
639
+ });
640
+ const ASYNC_FUNCTION = "AsyncFunction";
641
+ var hasPromiseValidation = (fieldReference) => !!fieldReference && !!fieldReference.validate && !!(isFunction(fieldReference.validate) && fieldReference.validate.constructor.name === ASYNC_FUNCTION || isObject(fieldReference.validate) && Object.values(fieldReference.validate).find((validateFunction) => validateFunction.constructor.name === ASYNC_FUNCTION));
642
+ var hasValidation = (options) => options.mount && (options.required || options.min || options.max || options.maxLength || options.minLength || options.pattern || options.validate);
643
+ var isWatched = (name, _names, isBlurEvent) => !isBlurEvent && (_names.watchAll || _names.watch.has(name) || [..._names.watch].some((watchName) => name.startsWith(watchName) && /^\.\w+/.test(name.slice(watchName.length))));
644
+ const iterateFieldsByAction = (fields, action, fieldsNames, abortEarly) => {
645
+ for (const key of fieldsNames || Object.keys(fields)) {
646
+ const field = get(fields, key);
647
+ if (field) {
648
+ const { _f, ...currentField } = field;
649
+ if (_f) {
650
+ if (_f.refs && _f.refs[0] && action(_f.refs[0], key) && !abortEarly) {
651
+ return true;
652
+ } else if (_f.ref && action(_f.ref, _f.name) && !abortEarly) {
653
+ return true;
654
+ } else {
655
+ if (iterateFieldsByAction(currentField, action)) {
656
+ break;
657
+ }
658
+ }
659
+ } else if (isObject(currentField)) {
660
+ if (iterateFieldsByAction(currentField, action)) {
661
+ break;
662
+ }
663
+ }
664
+ }
665
+ }
666
+ return;
667
+ };
668
+ function schemaErrorLookup(errors, _fields, name) {
669
+ const error = get(errors, name);
670
+ if (error || isKey(name)) {
671
+ return {
672
+ error,
673
+ name
674
+ };
675
+ }
676
+ const names = name.split(".");
677
+ while (names.length) {
678
+ const fieldName = names.join(".");
679
+ const field = get(_fields, fieldName);
680
+ const foundError = get(errors, fieldName);
681
+ if (field && !Array.isArray(field) && name !== fieldName) {
682
+ return { name };
683
+ }
684
+ if (foundError && foundError.type) {
685
+ return {
686
+ name: fieldName,
687
+ error: foundError
688
+ };
689
+ }
690
+ if (foundError && foundError.root && foundError.root.type) {
691
+ return {
692
+ name: `${fieldName}.root`,
693
+ error: foundError.root
694
+ };
695
+ }
696
+ names.pop();
697
+ }
698
+ return {
699
+ name
700
+ };
701
+ }
702
+ var shouldRenderFormState = (formStateData, _proxyFormState, updateFormState, isRoot) => {
703
+ updateFormState(formStateData);
704
+ const { name, ...formState } = formStateData;
705
+ return isEmptyObject(formState) || Object.keys(formState).length >= Object.keys(_proxyFormState).length || Object.keys(formState).find((key) => _proxyFormState[key] === (!isRoot || VALIDATION_MODE.all));
706
+ };
707
+ var shouldSubscribeByName = (name, signalName, exact) => !name || !signalName || name === signalName || convertToArrayPayload(name).some((currentName) => currentName && (exact ? currentName === signalName : currentName.startsWith(signalName) || signalName.startsWith(currentName)));
708
+ var skipValidation = (isBlurEvent, isTouched, isSubmitted, reValidateMode, mode) => {
709
+ if (mode.isOnAll) {
710
+ return false;
711
+ } else if (!isSubmitted && mode.isOnTouch) {
712
+ return !(isTouched || isBlurEvent);
713
+ } else if (isSubmitted ? reValidateMode.isOnBlur : mode.isOnBlur) {
714
+ return !isBlurEvent;
715
+ } else if (isSubmitted ? reValidateMode.isOnChange : mode.isOnChange) {
716
+ return isBlurEvent;
717
+ }
718
+ return true;
719
+ };
720
+ var unsetEmptyArray = (ref, name) => !compact(get(ref, name)).length && unset(ref, name);
721
+ var updateFieldArrayRootError = (errors, error, name) => {
722
+ const fieldArrayErrors = convertToArrayPayload(get(errors, name));
723
+ set(fieldArrayErrors, "root", error[name]);
724
+ set(errors, name, fieldArrayErrors);
725
+ return errors;
726
+ };
727
+ function getValidateError(result, ref, type = "validate") {
728
+ if (isString(result) || Array.isArray(result) && result.every(isString) || isBoolean(result) && !result) {
729
+ return {
730
+ type,
731
+ message: isString(result) ? result : "",
732
+ ref
733
+ };
734
+ }
735
+ }
736
+ var getValueAndMessage = (validationData) => isObject(validationData) && !isRegex(validationData) ? validationData : {
737
+ value: validationData,
738
+ message: ""
739
+ };
740
+ var validateField = async (field, disabledFieldNames, formValues, validateAllFieldCriteria, shouldUseNativeValidation, isFieldArray) => {
741
+ const { ref, refs, required, maxLength, minLength, min, max, pattern, validate, name, valueAsNumber, mount } = field._f;
742
+ const inputValue = get(formValues, name);
743
+ if (!mount || disabledFieldNames.has(name)) {
744
+ return {};
745
+ }
746
+ const inputRef = refs ? refs[0] : ref;
747
+ const setCustomValidity = (message) => {
748
+ if (shouldUseNativeValidation && inputRef.reportValidity) {
749
+ inputRef.setCustomValidity(isBoolean(message) ? "" : message || "");
750
+ inputRef.reportValidity();
751
+ }
752
+ };
753
+ const error = {};
754
+ const isRadio = isRadioInput(ref);
755
+ const isCheckBox = isCheckBoxInput(ref);
756
+ const isRadioOrCheckbox2 = isRadio || isCheckBox;
757
+ const isEmpty = (valueAsNumber || isFileInput(ref)) && isUndefined(ref.value) && isUndefined(inputValue) || isHTMLElement(ref) && ref.value === "" || inputValue === "" || Array.isArray(inputValue) && !inputValue.length;
758
+ const appendErrorsCurry = appendErrors.bind(null, name, validateAllFieldCriteria, error);
759
+ const getMinMaxMessage = (exceedMax, maxLengthMessage, minLengthMessage, maxType = INPUT_VALIDATION_RULES.maxLength, minType = INPUT_VALIDATION_RULES.minLength) => {
760
+ const message = exceedMax ? maxLengthMessage : minLengthMessage;
761
+ error[name] = {
762
+ type: exceedMax ? maxType : minType,
763
+ message,
764
+ ref,
765
+ ...appendErrorsCurry(exceedMax ? maxType : minType, message)
766
+ };
767
+ };
768
+ if (isFieldArray ? !Array.isArray(inputValue) || !inputValue.length : required && (!isRadioOrCheckbox2 && (isEmpty || isNullOrUndefined(inputValue)) || isBoolean(inputValue) && !inputValue || isCheckBox && !getCheckboxValue(refs).isValid || isRadio && !getRadioValue(refs).isValid)) {
769
+ const { value, message } = isString(required) ? { value: !!required, message: required } : getValueAndMessage(required);
770
+ if (value) {
771
+ error[name] = {
772
+ type: INPUT_VALIDATION_RULES.required,
773
+ message,
774
+ ref: inputRef,
775
+ ...appendErrorsCurry(INPUT_VALIDATION_RULES.required, message)
776
+ };
777
+ if (!validateAllFieldCriteria) {
778
+ setCustomValidity(message);
779
+ return error;
780
+ }
781
+ }
782
+ }
783
+ if (!isEmpty && (!isNullOrUndefined(min) || !isNullOrUndefined(max))) {
784
+ let exceedMax;
785
+ let exceedMin;
786
+ const maxOutput = getValueAndMessage(max);
787
+ const minOutput = getValueAndMessage(min);
788
+ if (!isNullOrUndefined(inputValue) && !isNaN(inputValue)) {
789
+ const valueNumber = ref.valueAsNumber || (inputValue ? +inputValue : inputValue);
790
+ if (!isNullOrUndefined(maxOutput.value)) {
791
+ exceedMax = valueNumber > maxOutput.value;
792
+ }
793
+ if (!isNullOrUndefined(minOutput.value)) {
794
+ exceedMin = valueNumber < minOutput.value;
795
+ }
796
+ } else {
797
+ const valueDate = ref.valueAsDate || new Date(inputValue);
798
+ const convertTimeToDate = (time) => /* @__PURE__ */ new Date((/* @__PURE__ */ new Date()).toDateString() + " " + time);
799
+ const isTime = ref.type == "time";
800
+ const isWeek = ref.type == "week";
801
+ if (isString(maxOutput.value) && inputValue) {
802
+ exceedMax = isTime ? convertTimeToDate(inputValue) > convertTimeToDate(maxOutput.value) : isWeek ? inputValue > maxOutput.value : valueDate > new Date(maxOutput.value);
803
+ }
804
+ if (isString(minOutput.value) && inputValue) {
805
+ exceedMin = isTime ? convertTimeToDate(inputValue) < convertTimeToDate(minOutput.value) : isWeek ? inputValue < minOutput.value : valueDate < new Date(minOutput.value);
806
+ }
807
+ }
808
+ if (exceedMax || exceedMin) {
809
+ getMinMaxMessage(!!exceedMax, maxOutput.message, minOutput.message, INPUT_VALIDATION_RULES.max, INPUT_VALIDATION_RULES.min);
810
+ if (!validateAllFieldCriteria) {
811
+ setCustomValidity(error[name].message);
812
+ return error;
813
+ }
814
+ }
815
+ }
816
+ if ((maxLength || minLength) && !isEmpty && (isString(inputValue) || isFieldArray && Array.isArray(inputValue))) {
817
+ const maxLengthOutput = getValueAndMessage(maxLength);
818
+ const minLengthOutput = getValueAndMessage(minLength);
819
+ const exceedMax = !isNullOrUndefined(maxLengthOutput.value) && inputValue.length > +maxLengthOutput.value;
820
+ const exceedMin = !isNullOrUndefined(minLengthOutput.value) && inputValue.length < +minLengthOutput.value;
821
+ if (exceedMax || exceedMin) {
822
+ getMinMaxMessage(exceedMax, maxLengthOutput.message, minLengthOutput.message);
823
+ if (!validateAllFieldCriteria) {
824
+ setCustomValidity(error[name].message);
825
+ return error;
826
+ }
827
+ }
828
+ }
829
+ if (pattern && !isEmpty && isString(inputValue)) {
830
+ const { value: patternValue, message } = getValueAndMessage(pattern);
831
+ if (isRegex(patternValue) && !inputValue.match(patternValue)) {
832
+ error[name] = {
833
+ type: INPUT_VALIDATION_RULES.pattern,
834
+ message,
835
+ ref,
836
+ ...appendErrorsCurry(INPUT_VALIDATION_RULES.pattern, message)
837
+ };
838
+ if (!validateAllFieldCriteria) {
839
+ setCustomValidity(message);
840
+ return error;
841
+ }
842
+ }
843
+ }
844
+ if (validate) {
845
+ if (isFunction(validate)) {
846
+ const result = await validate(inputValue, formValues);
847
+ const validateError = getValidateError(result, inputRef);
848
+ if (validateError) {
849
+ error[name] = {
850
+ ...validateError,
851
+ ...appendErrorsCurry(INPUT_VALIDATION_RULES.validate, validateError.message)
852
+ };
853
+ if (!validateAllFieldCriteria) {
854
+ setCustomValidity(validateError.message);
855
+ return error;
856
+ }
857
+ }
858
+ } else if (isObject(validate)) {
859
+ let validationResult = {};
860
+ for (const key in validate) {
861
+ if (!isEmptyObject(validationResult) && !validateAllFieldCriteria) {
862
+ break;
863
+ }
864
+ const validateError = getValidateError(await validate[key](inputValue, formValues), inputRef, key);
865
+ if (validateError) {
866
+ validationResult = {
867
+ ...validateError,
868
+ ...appendErrorsCurry(key, validateError.message)
869
+ };
870
+ setCustomValidity(validateError.message);
871
+ if (validateAllFieldCriteria) {
872
+ error[name] = validationResult;
873
+ }
874
+ }
875
+ }
876
+ if (!isEmptyObject(validationResult)) {
877
+ error[name] = {
878
+ ref: inputRef,
879
+ ...validationResult
880
+ };
881
+ if (!validateAllFieldCriteria) {
882
+ return error;
883
+ }
884
+ }
885
+ }
886
+ }
887
+ setCustomValidity(true);
888
+ return error;
889
+ };
890
+ const defaultOptions = {
891
+ mode: VALIDATION_MODE.onSubmit,
892
+ reValidateMode: VALIDATION_MODE.onChange,
893
+ shouldFocusError: true
894
+ };
895
+ function createFormControl(props = {}) {
896
+ let _options = {
897
+ ...defaultOptions,
898
+ ...props
899
+ };
900
+ let _formState = {
901
+ submitCount: 0,
902
+ isDirty: false,
903
+ isReady: false,
904
+ isLoading: isFunction(_options.defaultValues),
905
+ isValidating: false,
906
+ isSubmitted: false,
907
+ isSubmitting: false,
908
+ isSubmitSuccessful: false,
909
+ isValid: false,
910
+ touchedFields: {},
911
+ dirtyFields: {},
912
+ validatingFields: {},
913
+ errors: _options.errors || {},
914
+ disabled: _options.disabled || false
915
+ };
916
+ let _fields = {};
917
+ let _defaultValues = isObject(_options.defaultValues) || isObject(_options.values) ? cloneObject(_options.defaultValues || _options.values) || {} : {};
918
+ let _formValues = _options.shouldUnregister ? {} : cloneObject(_defaultValues);
919
+ let _state = {
920
+ action: false,
921
+ mount: false,
922
+ watch: false,
923
+ keepIsValid: false
924
+ };
925
+ let _names = {
926
+ mount: /* @__PURE__ */ new Set(),
927
+ disabled: /* @__PURE__ */ new Set(),
928
+ unMount: /* @__PURE__ */ new Set(),
929
+ array: /* @__PURE__ */ new Set(),
930
+ watch: /* @__PURE__ */ new Set()
931
+ };
932
+ let delayErrorCallback;
933
+ let timer = 0;
934
+ const defaultProxyFormState = {
935
+ isDirty: false,
936
+ dirtyFields: false,
937
+ validatingFields: false,
938
+ touchedFields: false,
939
+ isValidating: false,
940
+ isValid: false,
941
+ errors: false
942
+ };
943
+ const _proxyFormState = {
944
+ ...defaultProxyFormState
945
+ };
946
+ let _proxySubscribeFormState = {
947
+ ..._proxyFormState
948
+ };
949
+ const _subjects = {
950
+ array: createSubject(),
951
+ state: createSubject()
952
+ };
953
+ const shouldDisplayAllAssociatedErrors = _options.criteriaMode === VALIDATION_MODE.all;
954
+ const debounce = (callback) => (wait) => {
955
+ clearTimeout(timer);
956
+ timer = setTimeout(callback, wait);
957
+ };
958
+ const _setValid = async (shouldUpdateValid) => {
959
+ if (_state.keepIsValid) {
960
+ return;
961
+ }
962
+ if (!_options.disabled && (_proxyFormState.isValid || _proxySubscribeFormState.isValid || shouldUpdateValid)) {
963
+ let isValid;
964
+ if (_options.resolver) {
965
+ isValid = isEmptyObject((await _runSchema()).errors);
966
+ _updateIsValidating();
967
+ } else {
968
+ isValid = await executeBuiltInValidation(_fields, true);
969
+ }
970
+ if (isValid !== _formState.isValid) {
971
+ _subjects.state.next({
972
+ isValid
973
+ });
974
+ }
975
+ }
976
+ };
977
+ const _updateIsValidating = (names, isValidating) => {
978
+ if (!_options.disabled && (_proxyFormState.isValidating || _proxyFormState.validatingFields || _proxySubscribeFormState.isValidating || _proxySubscribeFormState.validatingFields)) {
979
+ (names || Array.from(_names.mount)).forEach((name) => {
980
+ if (name) {
981
+ isValidating ? set(_formState.validatingFields, name, isValidating) : unset(_formState.validatingFields, name);
982
+ }
983
+ });
984
+ _subjects.state.next({
985
+ validatingFields: _formState.validatingFields,
986
+ isValidating: !isEmptyObject(_formState.validatingFields)
987
+ });
988
+ }
989
+ };
990
+ const _setFieldArray = (name, values = [], method, args, shouldSetValues = true, shouldUpdateFieldsAndState = true) => {
991
+ if (args && method && !_options.disabled) {
992
+ _state.action = true;
993
+ if (shouldUpdateFieldsAndState && Array.isArray(get(_fields, name))) {
994
+ const fieldValues = method(get(_fields, name), args.argA, args.argB);
995
+ shouldSetValues && set(_fields, name, fieldValues);
996
+ }
997
+ if (shouldUpdateFieldsAndState && Array.isArray(get(_formState.errors, name))) {
998
+ const errors = method(get(_formState.errors, name), args.argA, args.argB);
999
+ shouldSetValues && set(_formState.errors, name, errors);
1000
+ unsetEmptyArray(_formState.errors, name);
1001
+ }
1002
+ if ((_proxyFormState.touchedFields || _proxySubscribeFormState.touchedFields) && shouldUpdateFieldsAndState && Array.isArray(get(_formState.touchedFields, name))) {
1003
+ const touchedFields = method(get(_formState.touchedFields, name), args.argA, args.argB);
1004
+ shouldSetValues && set(_formState.touchedFields, name, touchedFields);
1005
+ }
1006
+ if (_proxyFormState.dirtyFields || _proxySubscribeFormState.dirtyFields) {
1007
+ _formState.dirtyFields = getDirtyFields(_defaultValues, _formValues);
1008
+ }
1009
+ _subjects.state.next({
1010
+ name,
1011
+ isDirty: _getDirty(name, values),
1012
+ dirtyFields: _formState.dirtyFields,
1013
+ errors: _formState.errors,
1014
+ isValid: _formState.isValid
1015
+ });
1016
+ } else {
1017
+ set(_formValues, name, values);
1018
+ }
1019
+ };
1020
+ const updateErrors = (name, error) => {
1021
+ set(_formState.errors, name, error);
1022
+ _subjects.state.next({
1023
+ errors: _formState.errors
1024
+ });
1025
+ };
1026
+ const _setErrors = (errors) => {
1027
+ _formState.errors = errors;
1028
+ _subjects.state.next({
1029
+ errors: _formState.errors,
1030
+ isValid: false
1031
+ });
1032
+ };
1033
+ const updateValidAndValue = (name, shouldSkipSetValueAs, value, ref) => {
1034
+ const field = get(_fields, name);
1035
+ if (field) {
1036
+ const defaultValue = get(_formValues, name, isUndefined(value) ? get(_defaultValues, name) : value);
1037
+ isUndefined(defaultValue) || ref && ref.defaultChecked || shouldSkipSetValueAs ? set(_formValues, name, shouldSkipSetValueAs ? defaultValue : getFieldValue(field._f)) : setFieldValue(name, defaultValue);
1038
+ _state.mount && !_state.action && _setValid();
1039
+ }
1040
+ };
1041
+ const updateTouchAndDirty = (name, fieldValue, isBlurEvent, shouldDirty, shouldRender) => {
1042
+ let shouldUpdateField = false;
1043
+ let isPreviousDirty = false;
1044
+ const output = {
1045
+ name
1046
+ };
1047
+ if (!_options.disabled) {
1048
+ if (!isBlurEvent || shouldDirty) {
1049
+ if (_proxyFormState.isDirty || _proxySubscribeFormState.isDirty) {
1050
+ isPreviousDirty = _formState.isDirty;
1051
+ _formState.isDirty = output.isDirty = _getDirty();
1052
+ shouldUpdateField = isPreviousDirty !== output.isDirty;
1053
+ }
1054
+ const isCurrentFieldPristine = deepEqual$1(get(_defaultValues, name), fieldValue);
1055
+ isPreviousDirty = !!get(_formState.dirtyFields, name);
1056
+ isCurrentFieldPristine ? unset(_formState.dirtyFields, name) : set(_formState.dirtyFields, name, true);
1057
+ output.dirtyFields = _formState.dirtyFields;
1058
+ shouldUpdateField = shouldUpdateField || (_proxyFormState.dirtyFields || _proxySubscribeFormState.dirtyFields) && isPreviousDirty !== !isCurrentFieldPristine;
1059
+ }
1060
+ if (isBlurEvent) {
1061
+ const isPreviousFieldTouched = get(_formState.touchedFields, name);
1062
+ if (!isPreviousFieldTouched) {
1063
+ set(_formState.touchedFields, name, isBlurEvent);
1064
+ output.touchedFields = _formState.touchedFields;
1065
+ shouldUpdateField = shouldUpdateField || (_proxyFormState.touchedFields || _proxySubscribeFormState.touchedFields) && isPreviousFieldTouched !== isBlurEvent;
1066
+ }
1067
+ }
1068
+ shouldUpdateField && shouldRender && _subjects.state.next(output);
1069
+ }
1070
+ return shouldUpdateField ? output : {};
1071
+ };
1072
+ const shouldRenderByError = (name, isValid, error, fieldState) => {
1073
+ const previousFieldError = get(_formState.errors, name);
1074
+ const shouldUpdateValid = (_proxyFormState.isValid || _proxySubscribeFormState.isValid) && isBoolean(isValid) && _formState.isValid !== isValid;
1075
+ if (_options.delayError && error) {
1076
+ delayErrorCallback = debounce(() => updateErrors(name, error));
1077
+ delayErrorCallback(_options.delayError);
1078
+ } else {
1079
+ clearTimeout(timer);
1080
+ delayErrorCallback = null;
1081
+ error ? set(_formState.errors, name, error) : unset(_formState.errors, name);
1082
+ }
1083
+ if ((error ? !deepEqual$1(previousFieldError, error) : previousFieldError) || !isEmptyObject(fieldState) || shouldUpdateValid) {
1084
+ const updatedFormState = {
1085
+ ...fieldState,
1086
+ ...shouldUpdateValid && isBoolean(isValid) ? { isValid } : {},
1087
+ errors: _formState.errors,
1088
+ name
1089
+ };
1090
+ _formState = {
1091
+ ..._formState,
1092
+ ...updatedFormState
1093
+ };
1094
+ _subjects.state.next(updatedFormState);
1095
+ }
1096
+ };
1097
+ const _runSchema = async (name) => {
1098
+ _updateIsValidating(name, true);
1099
+ const result = await _options.resolver(_formValues, _options.context, getResolverOptions(name || _names.mount, _fields, _options.criteriaMode, _options.shouldUseNativeValidation));
1100
+ return result;
1101
+ };
1102
+ const executeSchemaAndUpdateState = async (names) => {
1103
+ const { errors } = await _runSchema(names);
1104
+ _updateIsValidating(names);
1105
+ if (names) {
1106
+ for (const name of names) {
1107
+ const error = get(errors, name);
1108
+ error ? set(_formState.errors, name, error) : unset(_formState.errors, name);
1109
+ }
1110
+ } else {
1111
+ _formState.errors = errors;
1112
+ }
1113
+ return errors;
1114
+ };
1115
+ const executeBuiltInValidation = async (fields, shouldOnlyCheckValid, context = {
1116
+ valid: true
1117
+ }) => {
1118
+ for (const name in fields) {
1119
+ const field = fields[name];
1120
+ if (field) {
1121
+ const { _f, ...fieldValue } = field;
1122
+ if (_f) {
1123
+ const isFieldArrayRoot = _names.array.has(_f.name);
1124
+ const isPromiseFunction = field._f && hasPromiseValidation(field._f);
1125
+ if (isPromiseFunction && _proxyFormState.validatingFields) {
1126
+ _updateIsValidating([_f.name], true);
1127
+ }
1128
+ const fieldError = await validateField(field, _names.disabled, _formValues, shouldDisplayAllAssociatedErrors, _options.shouldUseNativeValidation && !shouldOnlyCheckValid, isFieldArrayRoot);
1129
+ if (isPromiseFunction && _proxyFormState.validatingFields) {
1130
+ _updateIsValidating([_f.name]);
1131
+ }
1132
+ if (fieldError[_f.name]) {
1133
+ context.valid = false;
1134
+ if (shouldOnlyCheckValid || props.shouldUseNativeValidation) {
1135
+ break;
1136
+ }
1137
+ }
1138
+ !shouldOnlyCheckValid && (get(fieldError, _f.name) ? isFieldArrayRoot ? updateFieldArrayRootError(_formState.errors, fieldError, _f.name) : set(_formState.errors, _f.name, fieldError[_f.name]) : unset(_formState.errors, _f.name));
1139
+ }
1140
+ !isEmptyObject(fieldValue) && await executeBuiltInValidation(fieldValue, shouldOnlyCheckValid, context);
1141
+ }
1142
+ }
1143
+ return context.valid;
1144
+ };
1145
+ const _removeUnmounted = () => {
1146
+ for (const name of _names.unMount) {
1147
+ const field = get(_fields, name);
1148
+ field && (field._f.refs ? field._f.refs.every((ref) => !live(ref)) : !live(field._f.ref)) && unregister(name);
1149
+ }
1150
+ _names.unMount = /* @__PURE__ */ new Set();
1151
+ };
1152
+ const _getDirty = (name, data) => !_options.disabled && (name && data && set(_formValues, name, data), !deepEqual$1(getValues(), _defaultValues));
1153
+ const _getWatch = (names, defaultValue, isGlobal) => generateWatchOutput(names, _names, {
1154
+ ..._state.mount ? _formValues : isUndefined(defaultValue) ? _defaultValues : isString(names) ? { [names]: defaultValue } : defaultValue
1155
+ }, isGlobal, defaultValue);
1156
+ const _getFieldArray = (name) => compact(get(_state.mount ? _formValues : _defaultValues, name, _options.shouldUnregister ? get(_defaultValues, name, []) : []));
1157
+ const setFieldValue = (name, value, options = {}) => {
1158
+ const field = get(_fields, name);
1159
+ let fieldValue = value;
1160
+ if (field) {
1161
+ const fieldReference = field._f;
1162
+ if (fieldReference) {
1163
+ !fieldReference.disabled && set(_formValues, name, getFieldValueAs(value, fieldReference));
1164
+ fieldValue = isHTMLElement(fieldReference.ref) && isNullOrUndefined(value) ? "" : value;
1165
+ if (isMultipleSelect(fieldReference.ref)) {
1166
+ [...fieldReference.ref.options].forEach((optionRef) => optionRef.selected = fieldValue.includes(optionRef.value));
1167
+ } else if (fieldReference.refs) {
1168
+ if (isCheckBoxInput(fieldReference.ref)) {
1169
+ fieldReference.refs.forEach((checkboxRef) => {
1170
+ if (!checkboxRef.defaultChecked || !checkboxRef.disabled) {
1171
+ if (Array.isArray(fieldValue)) {
1172
+ checkboxRef.checked = !!fieldValue.find((data) => data === checkboxRef.value);
1173
+ } else {
1174
+ checkboxRef.checked = fieldValue === checkboxRef.value || !!fieldValue;
1175
+ }
1176
+ }
1177
+ });
1178
+ } else {
1179
+ fieldReference.refs.forEach((radioRef) => radioRef.checked = radioRef.value === fieldValue);
1180
+ }
1181
+ } else if (isFileInput(fieldReference.ref)) {
1182
+ fieldReference.ref.value = "";
1183
+ } else {
1184
+ fieldReference.ref.value = fieldValue;
1185
+ if (!fieldReference.ref.type) {
1186
+ _subjects.state.next({
1187
+ name,
1188
+ values: cloneObject(_formValues)
1189
+ });
1190
+ }
1191
+ }
1192
+ }
1193
+ }
1194
+ (options.shouldDirty || options.shouldTouch) && updateTouchAndDirty(name, fieldValue, options.shouldTouch, options.shouldDirty, true);
1195
+ options.shouldValidate && trigger(name);
1196
+ };
1197
+ const setValues = (name, value, options) => {
1198
+ for (const fieldKey in value) {
1199
+ if (!value.hasOwnProperty(fieldKey)) {
1200
+ return;
1201
+ }
1202
+ const fieldValue = value[fieldKey];
1203
+ const fieldName = name + "." + fieldKey;
1204
+ const field = get(_fields, fieldName);
1205
+ (_names.array.has(name) || isObject(fieldValue) || field && !field._f) && !isDateObject(fieldValue) ? setValues(fieldName, fieldValue, options) : setFieldValue(fieldName, fieldValue, options);
1206
+ }
1207
+ };
1208
+ const setValue = (name, value, options = {}) => {
1209
+ const field = get(_fields, name);
1210
+ const isFieldArray = _names.array.has(name);
1211
+ const cloneValue = cloneObject(value);
1212
+ set(_formValues, name, cloneValue);
1213
+ if (isFieldArray) {
1214
+ _subjects.array.next({
1215
+ name,
1216
+ values: cloneObject(_formValues)
1217
+ });
1218
+ if ((_proxyFormState.isDirty || _proxyFormState.dirtyFields || _proxySubscribeFormState.isDirty || _proxySubscribeFormState.dirtyFields) && options.shouldDirty) {
1219
+ _subjects.state.next({
1220
+ name,
1221
+ dirtyFields: getDirtyFields(_defaultValues, _formValues),
1222
+ isDirty: _getDirty(name, cloneValue)
1223
+ });
1224
+ }
1225
+ } else {
1226
+ field && !field._f && !isNullOrUndefined(cloneValue) ? setValues(name, cloneValue, options) : setFieldValue(name, cloneValue, options);
1227
+ }
1228
+ if (isWatched(name, _names)) {
1229
+ _subjects.state.next({
1230
+ ..._formState,
1231
+ name,
1232
+ values: cloneObject(_formValues)
1233
+ });
1234
+ } else {
1235
+ _subjects.state.next({
1236
+ name: _state.mount ? name : void 0,
1237
+ values: cloneObject(_formValues)
1238
+ });
1239
+ }
1240
+ };
1241
+ const onChange = async (event) => {
1242
+ _state.mount = true;
1243
+ const target = event.target;
1244
+ let name = target.name;
1245
+ let isFieldValueUpdated = true;
1246
+ const field = get(_fields, name);
1247
+ const _updateIsFieldValueUpdated = (fieldValue) => {
1248
+ isFieldValueUpdated = Number.isNaN(fieldValue) || isDateObject(fieldValue) && isNaN(fieldValue.getTime()) || deepEqual$1(fieldValue, get(_formValues, name, fieldValue));
1249
+ };
1250
+ const validationModeBeforeSubmit = getValidationModes(_options.mode);
1251
+ const validationModeAfterSubmit = getValidationModes(_options.reValidateMode);
1252
+ if (field) {
1253
+ let error;
1254
+ let isValid;
1255
+ const fieldValue = target.type ? getFieldValue(field._f) : getEventValue(event);
1256
+ const isBlurEvent = event.type === EVENTS.BLUR || event.type === EVENTS.FOCUS_OUT;
1257
+ const shouldSkipValidation = !hasValidation(field._f) && !_options.resolver && !get(_formState.errors, name) && !field._f.deps || skipValidation(isBlurEvent, get(_formState.touchedFields, name), _formState.isSubmitted, validationModeAfterSubmit, validationModeBeforeSubmit);
1258
+ const watched = isWatched(name, _names, isBlurEvent);
1259
+ set(_formValues, name, fieldValue);
1260
+ if (isBlurEvent) {
1261
+ if (!target || !target.readOnly) {
1262
+ field._f.onBlur && field._f.onBlur(event);
1263
+ delayErrorCallback && delayErrorCallback(0);
1264
+ }
1265
+ } else if (field._f.onChange) {
1266
+ field._f.onChange(event);
1267
+ }
1268
+ const fieldState = updateTouchAndDirty(name, fieldValue, isBlurEvent);
1269
+ const shouldRender = !isEmptyObject(fieldState) || watched;
1270
+ !isBlurEvent && _subjects.state.next({
1271
+ name,
1272
+ type: event.type,
1273
+ values: cloneObject(_formValues)
1274
+ });
1275
+ if (shouldSkipValidation) {
1276
+ if (_proxyFormState.isValid || _proxySubscribeFormState.isValid) {
1277
+ if (_options.mode === "onBlur") {
1278
+ if (isBlurEvent) {
1279
+ _setValid();
1280
+ }
1281
+ } else if (!isBlurEvent) {
1282
+ _setValid();
1283
+ }
1284
+ }
1285
+ return shouldRender && _subjects.state.next({ name, ...watched ? {} : fieldState });
1286
+ }
1287
+ !isBlurEvent && watched && _subjects.state.next({ ..._formState });
1288
+ if (_options.resolver) {
1289
+ const { errors } = await _runSchema([name]);
1290
+ _updateIsValidating([name]);
1291
+ _updateIsFieldValueUpdated(fieldValue);
1292
+ if (isFieldValueUpdated) {
1293
+ const previousErrorLookupResult = schemaErrorLookup(_formState.errors, _fields, name);
1294
+ const errorLookupResult = schemaErrorLookup(errors, _fields, previousErrorLookupResult.name || name);
1295
+ error = errorLookupResult.error;
1296
+ name = errorLookupResult.name;
1297
+ isValid = isEmptyObject(errors);
1298
+ }
1299
+ } else {
1300
+ _updateIsValidating([name], true);
1301
+ error = (await validateField(field, _names.disabled, _formValues, shouldDisplayAllAssociatedErrors, _options.shouldUseNativeValidation))[name];
1302
+ _updateIsValidating([name]);
1303
+ _updateIsFieldValueUpdated(fieldValue);
1304
+ if (isFieldValueUpdated) {
1305
+ if (error) {
1306
+ isValid = false;
1307
+ } else if (_proxyFormState.isValid || _proxySubscribeFormState.isValid) {
1308
+ isValid = await executeBuiltInValidation(_fields, true);
1309
+ }
1310
+ }
1311
+ }
1312
+ if (isFieldValueUpdated) {
1313
+ field._f.deps && (!Array.isArray(field._f.deps) || field._f.deps.length > 0) && trigger(field._f.deps);
1314
+ shouldRenderByError(name, isValid, error, fieldState);
1315
+ }
1316
+ }
1317
+ };
1318
+ const _focusInput = (ref, key) => {
1319
+ if (get(_formState.errors, key) && ref.focus) {
1320
+ ref.focus();
1321
+ return 1;
1322
+ }
1323
+ return;
1324
+ };
1325
+ const trigger = async (name, options = {}) => {
1326
+ let isValid;
1327
+ let validationResult;
1328
+ const fieldNames = convertToArrayPayload(name);
1329
+ if (_options.resolver) {
1330
+ const errors = await executeSchemaAndUpdateState(isUndefined(name) ? name : fieldNames);
1331
+ isValid = isEmptyObject(errors);
1332
+ validationResult = name ? !fieldNames.some((name2) => get(errors, name2)) : isValid;
1333
+ } else if (name) {
1334
+ validationResult = (await Promise.all(fieldNames.map(async (fieldName) => {
1335
+ const field = get(_fields, fieldName);
1336
+ return await executeBuiltInValidation(field && field._f ? { [fieldName]: field } : field);
1337
+ }))).every(Boolean);
1338
+ !(!validationResult && !_formState.isValid) && _setValid();
1339
+ } else {
1340
+ validationResult = isValid = await executeBuiltInValidation(_fields);
1341
+ }
1342
+ _subjects.state.next({
1343
+ ...!isString(name) || (_proxyFormState.isValid || _proxySubscribeFormState.isValid) && isValid !== _formState.isValid ? {} : { name },
1344
+ ..._options.resolver || !name ? { isValid } : {},
1345
+ errors: _formState.errors
1346
+ });
1347
+ options.shouldFocus && !validationResult && iterateFieldsByAction(_fields, _focusInput, name ? fieldNames : _names.mount);
1348
+ return validationResult;
1349
+ };
1350
+ const getValues = (fieldNames, config) => {
1351
+ let values = {
1352
+ ..._state.mount ? _formValues : _defaultValues
1353
+ };
1354
+ if (config) {
1355
+ values = extractFormValues(config.dirtyFields ? _formState.dirtyFields : _formState.touchedFields, values);
1356
+ }
1357
+ return isUndefined(fieldNames) ? values : isString(fieldNames) ? get(values, fieldNames) : fieldNames.map((name) => get(values, name));
1358
+ };
1359
+ const getFieldState = (name, formState) => ({
1360
+ invalid: !!get((formState || _formState).errors, name),
1361
+ isDirty: !!get((formState || _formState).dirtyFields, name),
1362
+ error: get((formState || _formState).errors, name),
1363
+ isValidating: !!get(_formState.validatingFields, name),
1364
+ isTouched: !!get((formState || _formState).touchedFields, name)
1365
+ });
1366
+ const clearErrors = (name) => {
1367
+ name && convertToArrayPayload(name).forEach((inputName) => unset(_formState.errors, inputName));
1368
+ _subjects.state.next({
1369
+ errors: name ? _formState.errors : {}
1370
+ });
1371
+ };
1372
+ const setError = (name, error, options) => {
1373
+ const ref = (get(_fields, name, { _f: {} })._f || {}).ref;
1374
+ const currentError = get(_formState.errors, name) || {};
1375
+ const { ref: currentRef, message, type, ...restOfErrorTree } = currentError;
1376
+ set(_formState.errors, name, {
1377
+ ...restOfErrorTree,
1378
+ ...error,
1379
+ ref
1380
+ });
1381
+ _subjects.state.next({
1382
+ name,
1383
+ errors: _formState.errors,
1384
+ isValid: false
1385
+ });
1386
+ options && options.shouldFocus && ref && ref.focus && ref.focus();
1387
+ };
1388
+ const watch = (name, defaultValue) => isFunction(name) ? _subjects.state.subscribe({
1389
+ next: (payload) => "values" in payload && name(_getWatch(void 0, defaultValue), payload)
1390
+ }) : _getWatch(name, defaultValue, true);
1391
+ const _subscribe = (props2) => _subjects.state.subscribe({
1392
+ next: (formState) => {
1393
+ if (shouldSubscribeByName(props2.name, formState.name, props2.exact) && shouldRenderFormState(formState, props2.formState || _proxyFormState, _setFormState, props2.reRenderRoot)) {
1394
+ props2.callback({
1395
+ values: { ..._formValues },
1396
+ ..._formState,
1397
+ ...formState,
1398
+ defaultValues: _defaultValues
1399
+ });
1400
+ }
1401
+ }
1402
+ }).unsubscribe;
1403
+ const subscribe = (props2) => {
1404
+ _state.mount = true;
1405
+ _proxySubscribeFormState = {
1406
+ ..._proxySubscribeFormState,
1407
+ ...props2.formState
1408
+ };
1409
+ return _subscribe({
1410
+ ...props2,
1411
+ formState: {
1412
+ ...defaultProxyFormState,
1413
+ ...props2.formState
1414
+ }
1415
+ });
1416
+ };
1417
+ const unregister = (name, options = {}) => {
1418
+ for (const fieldName of name ? convertToArrayPayload(name) : _names.mount) {
1419
+ _names.mount.delete(fieldName);
1420
+ _names.array.delete(fieldName);
1421
+ if (!options.keepValue) {
1422
+ unset(_fields, fieldName);
1423
+ unset(_formValues, fieldName);
1424
+ }
1425
+ !options.keepError && unset(_formState.errors, fieldName);
1426
+ !options.keepDirty && unset(_formState.dirtyFields, fieldName);
1427
+ !options.keepTouched && unset(_formState.touchedFields, fieldName);
1428
+ !options.keepIsValidating && unset(_formState.validatingFields, fieldName);
1429
+ !_options.shouldUnregister && !options.keepDefaultValue && unset(_defaultValues, fieldName);
1430
+ }
1431
+ _subjects.state.next({
1432
+ values: cloneObject(_formValues)
1433
+ });
1434
+ _subjects.state.next({
1435
+ ..._formState,
1436
+ ...!options.keepDirty ? {} : { isDirty: _getDirty() }
1437
+ });
1438
+ !options.keepIsValid && _setValid();
1439
+ };
1440
+ const _setDisabledField = ({ disabled, name }) => {
1441
+ if (isBoolean(disabled) && _state.mount || !!disabled || _names.disabled.has(name)) {
1442
+ const wasDisabled = _names.disabled.has(name);
1443
+ const isDisabled = !!disabled;
1444
+ const disabledStateChanged = wasDisabled !== isDisabled;
1445
+ disabled ? _names.disabled.add(name) : _names.disabled.delete(name);
1446
+ disabledStateChanged && _state.mount && !_state.action && _setValid();
1447
+ }
1448
+ };
1449
+ const register = (name, options = {}) => {
1450
+ let field = get(_fields, name);
1451
+ const disabledIsDefined = isBoolean(options.disabled) || isBoolean(_options.disabled);
1452
+ set(_fields, name, {
1453
+ ...field || {},
1454
+ _f: {
1455
+ ...field && field._f ? field._f : { ref: { name } },
1456
+ name,
1457
+ mount: true,
1458
+ ...options
1459
+ }
1460
+ });
1461
+ _names.mount.add(name);
1462
+ if (field) {
1463
+ _setDisabledField({
1464
+ disabled: isBoolean(options.disabled) ? options.disabled : _options.disabled,
1465
+ name
1466
+ });
1467
+ } else {
1468
+ updateValidAndValue(name, true, options.value);
1469
+ }
1470
+ return {
1471
+ ...disabledIsDefined ? { disabled: options.disabled || _options.disabled } : {},
1472
+ ..._options.progressive ? {
1473
+ required: !!options.required,
1474
+ min: getRuleValue(options.min),
1475
+ max: getRuleValue(options.max),
1476
+ minLength: getRuleValue(options.minLength),
1477
+ maxLength: getRuleValue(options.maxLength),
1478
+ pattern: getRuleValue(options.pattern)
1479
+ } : {},
1480
+ name,
1481
+ onChange,
1482
+ onBlur: onChange,
1483
+ ref: (ref) => {
1484
+ if (ref) {
1485
+ register(name, options);
1486
+ field = get(_fields, name);
1487
+ const fieldRef = isUndefined(ref.value) ? ref.querySelectorAll ? ref.querySelectorAll("input,select,textarea")[0] || ref : ref : ref;
1488
+ const radioOrCheckbox = isRadioOrCheckbox(fieldRef);
1489
+ const refs = field._f.refs || [];
1490
+ if (radioOrCheckbox ? refs.find((option) => option === fieldRef) : fieldRef === field._f.ref) {
1491
+ return;
1492
+ }
1493
+ set(_fields, name, {
1494
+ _f: {
1495
+ ...field._f,
1496
+ ...radioOrCheckbox ? {
1497
+ refs: [
1498
+ ...refs.filter(live),
1499
+ fieldRef,
1500
+ ...Array.isArray(get(_defaultValues, name)) ? [{}] : []
1501
+ ],
1502
+ ref: { type: fieldRef.type, name }
1503
+ } : { ref: fieldRef }
1504
+ }
1505
+ });
1506
+ updateValidAndValue(name, false, void 0, fieldRef);
1507
+ } else {
1508
+ field = get(_fields, name, {});
1509
+ if (field._f) {
1510
+ field._f.mount = false;
1511
+ }
1512
+ (_options.shouldUnregister || options.shouldUnregister) && !(isNameInFieldArray(_names.array, name) && _state.action) && _names.unMount.add(name);
1513
+ }
1514
+ }
1515
+ };
1516
+ };
1517
+ const _focusError = () => _options.shouldFocusError && iterateFieldsByAction(_fields, _focusInput, _names.mount);
1518
+ const _disableForm = (disabled) => {
1519
+ if (isBoolean(disabled)) {
1520
+ _subjects.state.next({ disabled });
1521
+ iterateFieldsByAction(_fields, (ref, name) => {
1522
+ const currentField = get(_fields, name);
1523
+ if (currentField) {
1524
+ ref.disabled = currentField._f.disabled || disabled;
1525
+ if (Array.isArray(currentField._f.refs)) {
1526
+ currentField._f.refs.forEach((inputRef) => {
1527
+ inputRef.disabled = currentField._f.disabled || disabled;
1528
+ });
1529
+ }
1530
+ }
1531
+ }, 0, false);
1532
+ }
1533
+ };
1534
+ const handleSubmit = (onValid, onInvalid) => async (e) => {
1535
+ let onValidError = void 0;
1536
+ if (e) {
1537
+ e.preventDefault && e.preventDefault();
1538
+ e.persist && e.persist();
1539
+ }
1540
+ let fieldValues = cloneObject(_formValues);
1541
+ _subjects.state.next({
1542
+ isSubmitting: true
1543
+ });
1544
+ if (_options.resolver) {
1545
+ const { errors, values } = await _runSchema();
1546
+ _updateIsValidating();
1547
+ _formState.errors = errors;
1548
+ fieldValues = cloneObject(values);
1549
+ } else {
1550
+ await executeBuiltInValidation(_fields);
1551
+ }
1552
+ if (_names.disabled.size) {
1553
+ for (const name of _names.disabled) {
1554
+ unset(fieldValues, name);
1555
+ }
1556
+ }
1557
+ unset(_formState.errors, "root");
1558
+ if (isEmptyObject(_formState.errors)) {
1559
+ _subjects.state.next({
1560
+ errors: {}
1561
+ });
1562
+ try {
1563
+ await onValid(fieldValues, e);
1564
+ } catch (error) {
1565
+ onValidError = error;
1566
+ }
1567
+ } else {
1568
+ if (onInvalid) {
1569
+ await onInvalid({ ..._formState.errors }, e);
1570
+ }
1571
+ _focusError();
1572
+ setTimeout(_focusError);
1573
+ }
1574
+ _subjects.state.next({
1575
+ isSubmitted: true,
1576
+ isSubmitting: false,
1577
+ isSubmitSuccessful: isEmptyObject(_formState.errors) && !onValidError,
1578
+ submitCount: _formState.submitCount + 1,
1579
+ errors: _formState.errors
1580
+ });
1581
+ if (onValidError) {
1582
+ throw onValidError;
1583
+ }
1584
+ };
1585
+ const resetField = (name, options = {}) => {
1586
+ if (get(_fields, name)) {
1587
+ if (isUndefined(options.defaultValue)) {
1588
+ setValue(name, cloneObject(get(_defaultValues, name)));
1589
+ } else {
1590
+ setValue(name, options.defaultValue);
1591
+ set(_defaultValues, name, cloneObject(options.defaultValue));
1592
+ }
1593
+ if (!options.keepTouched) {
1594
+ unset(_formState.touchedFields, name);
1595
+ }
1596
+ if (!options.keepDirty) {
1597
+ unset(_formState.dirtyFields, name);
1598
+ _formState.isDirty = options.defaultValue ? _getDirty(name, cloneObject(get(_defaultValues, name))) : _getDirty();
1599
+ }
1600
+ if (!options.keepError) {
1601
+ unset(_formState.errors, name);
1602
+ _proxyFormState.isValid && _setValid();
1603
+ }
1604
+ _subjects.state.next({ ..._formState });
1605
+ }
1606
+ };
1607
+ const _reset = (formValues, keepStateOptions = {}) => {
1608
+ const updatedValues = formValues ? cloneObject(formValues) : _defaultValues;
1609
+ const cloneUpdatedValues = cloneObject(updatedValues);
1610
+ const isEmptyResetValues = isEmptyObject(formValues);
1611
+ const values = isEmptyResetValues ? _defaultValues : cloneUpdatedValues;
1612
+ if (!keepStateOptions.keepDefaultValues) {
1613
+ _defaultValues = updatedValues;
1614
+ }
1615
+ if (!keepStateOptions.keepValues) {
1616
+ if (keepStateOptions.keepDirtyValues) {
1617
+ const fieldsToCheck = /* @__PURE__ */ new Set([
1618
+ ..._names.mount,
1619
+ ...Object.keys(getDirtyFields(_defaultValues, _formValues))
1620
+ ]);
1621
+ for (const fieldName of Array.from(fieldsToCheck)) {
1622
+ const isDirty = get(_formState.dirtyFields, fieldName);
1623
+ const existingValue = get(_formValues, fieldName);
1624
+ const newValue = get(values, fieldName);
1625
+ if (isDirty && !isUndefined(existingValue)) {
1626
+ set(values, fieldName, existingValue);
1627
+ } else if (!isDirty && !isUndefined(newValue)) {
1628
+ setValue(fieldName, newValue);
1629
+ }
1630
+ }
1631
+ } else {
1632
+ if (isWeb && isUndefined(formValues)) {
1633
+ for (const name of _names.mount) {
1634
+ const field = get(_fields, name);
1635
+ if (field && field._f) {
1636
+ const fieldReference = Array.isArray(field._f.refs) ? field._f.refs[0] : field._f.ref;
1637
+ if (isHTMLElement(fieldReference)) {
1638
+ const form = fieldReference.closest("form");
1639
+ if (form) {
1640
+ form.reset();
1641
+ break;
1642
+ }
1643
+ }
1644
+ }
1645
+ }
1646
+ }
1647
+ if (keepStateOptions.keepFieldsRef) {
1648
+ for (const fieldName of _names.mount) {
1649
+ setValue(fieldName, get(values, fieldName));
1650
+ }
1651
+ } else {
1652
+ _fields = {};
1653
+ }
1654
+ }
1655
+ _formValues = _options.shouldUnregister ? keepStateOptions.keepDefaultValues ? cloneObject(_defaultValues) : {} : cloneObject(values);
1656
+ _subjects.array.next({
1657
+ values: { ...values }
1658
+ });
1659
+ _subjects.state.next({
1660
+ values: { ...values }
1661
+ });
1662
+ }
1663
+ _names = {
1664
+ mount: keepStateOptions.keepDirtyValues ? _names.mount : /* @__PURE__ */ new Set(),
1665
+ unMount: /* @__PURE__ */ new Set(),
1666
+ array: /* @__PURE__ */ new Set(),
1667
+ disabled: /* @__PURE__ */ new Set(),
1668
+ watch: /* @__PURE__ */ new Set(),
1669
+ watchAll: false,
1670
+ focus: ""
1671
+ };
1672
+ _state.mount = !_proxyFormState.isValid || !!keepStateOptions.keepIsValid || !!keepStateOptions.keepDirtyValues || !_options.shouldUnregister && !isEmptyObject(values);
1673
+ _state.watch = !!_options.shouldUnregister;
1674
+ _state.keepIsValid = !!keepStateOptions.keepIsValid;
1675
+ _state.action = false;
1676
+ if (!keepStateOptions.keepErrors) {
1677
+ _formState.errors = {};
1678
+ }
1679
+ _subjects.state.next({
1680
+ submitCount: keepStateOptions.keepSubmitCount ? _formState.submitCount : 0,
1681
+ isDirty: isEmptyResetValues ? false : keepStateOptions.keepDirty ? _formState.isDirty : !!(keepStateOptions.keepDefaultValues && !deepEqual$1(formValues, _defaultValues)),
1682
+ isSubmitted: keepStateOptions.keepIsSubmitted ? _formState.isSubmitted : false,
1683
+ dirtyFields: isEmptyResetValues ? {} : keepStateOptions.keepDirtyValues ? keepStateOptions.keepDefaultValues && _formValues ? getDirtyFields(_defaultValues, _formValues) : _formState.dirtyFields : keepStateOptions.keepDefaultValues && formValues ? getDirtyFields(_defaultValues, formValues) : keepStateOptions.keepDirty ? _formState.dirtyFields : {},
1684
+ touchedFields: keepStateOptions.keepTouched ? _formState.touchedFields : {},
1685
+ errors: keepStateOptions.keepErrors ? _formState.errors : {},
1686
+ isSubmitSuccessful: keepStateOptions.keepIsSubmitSuccessful ? _formState.isSubmitSuccessful : false,
1687
+ isSubmitting: false,
1688
+ defaultValues: _defaultValues
1689
+ });
1690
+ };
1691
+ const reset = (formValues, keepStateOptions) => _reset(isFunction(formValues) ? formValues(_formValues) : formValues, { ..._options.resetOptions, ...keepStateOptions });
1692
+ const setFocus = (name, options = {}) => {
1693
+ const field = get(_fields, name);
1694
+ const fieldReference = field && field._f;
1695
+ if (fieldReference) {
1696
+ const fieldRef = fieldReference.refs ? fieldReference.refs[0] : fieldReference.ref;
1697
+ if (fieldRef.focus) {
1698
+ setTimeout(() => {
1699
+ fieldRef.focus();
1700
+ options.shouldSelect && isFunction(fieldRef.select) && fieldRef.select();
1701
+ });
1702
+ }
1703
+ }
1704
+ };
1705
+ const _setFormState = (updatedFormState) => {
1706
+ _formState = {
1707
+ ..._formState,
1708
+ ...updatedFormState
1709
+ };
1710
+ };
1711
+ const _resetDefaultValues = () => isFunction(_options.defaultValues) && _options.defaultValues().then((values) => {
1712
+ reset(values, _options.resetOptions);
1713
+ _subjects.state.next({
1714
+ isLoading: false
1715
+ });
1716
+ });
1717
+ const methods = {
1718
+ control: {
1719
+ register,
1720
+ unregister,
1721
+ getFieldState,
1722
+ handleSubmit,
1723
+ setError,
1724
+ _subscribe,
1725
+ _runSchema,
1726
+ _updateIsValidating,
1727
+ _focusError,
1728
+ _getWatch,
1729
+ _getDirty,
1730
+ _setValid,
1731
+ _setFieldArray,
1732
+ _setDisabledField,
1733
+ _setErrors,
1734
+ _getFieldArray,
1735
+ _reset,
1736
+ _resetDefaultValues,
1737
+ _removeUnmounted,
1738
+ _disableForm,
1739
+ _subjects,
1740
+ _proxyFormState,
1741
+ get _fields() {
1742
+ return _fields;
1743
+ },
1744
+ get _formValues() {
1745
+ return _formValues;
1746
+ },
1747
+ get _state() {
1748
+ return _state;
1749
+ },
1750
+ set _state(value) {
1751
+ _state = value;
1752
+ },
1753
+ get _defaultValues() {
1754
+ return _defaultValues;
1755
+ },
1756
+ get _names() {
1757
+ return _names;
1758
+ },
1759
+ set _names(value) {
1760
+ _names = value;
1761
+ },
1762
+ get _formState() {
1763
+ return _formState;
1764
+ },
1765
+ get _options() {
1766
+ return _options;
1767
+ },
1768
+ set _options(value) {
1769
+ _options = {
1770
+ ..._options,
1771
+ ...value
1772
+ };
1773
+ }
1774
+ },
1775
+ subscribe,
1776
+ trigger,
1777
+ register,
1778
+ handleSubmit,
1779
+ watch,
1780
+ setValue,
1781
+ getValues,
1782
+ reset,
1783
+ resetField,
1784
+ clearErrors,
1785
+ unregister,
1786
+ setError,
1787
+ setFocus,
1788
+ getFieldState
1789
+ };
1790
+ return {
1791
+ ...methods,
1792
+ formControl: methods
1793
+ };
1794
+ }
1795
+ var generateId = () => {
1796
+ if (typeof crypto !== "undefined" && crypto.randomUUID) {
1797
+ return crypto.randomUUID();
1798
+ }
1799
+ const d = typeof performance === "undefined" ? Date.now() : performance.now() * 1e3;
1800
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
1801
+ const r = (Math.random() * 16 + d) % 16 | 0;
1802
+ return (c == "x" ? r : r & 3 | 8).toString(16);
1803
+ });
1804
+ };
1805
+ var getFocusFieldName = (name, index, options = {}) => options.shouldFocus || isUndefined(options.shouldFocus) ? options.focusName || `${name}.${isUndefined(options.focusIndex) ? index : options.focusIndex}.` : "";
1806
+ var appendAt = (data, value) => [
1807
+ ...data,
1808
+ ...convertToArrayPayload(value)
1809
+ ];
1810
+ var fillEmptyArray = (value) => Array.isArray(value) ? value.map(() => void 0) : void 0;
1811
+ function insert(data, index, value) {
1812
+ return [
1813
+ ...data.slice(0, index),
1814
+ ...convertToArrayPayload(value),
1815
+ ...data.slice(index)
1816
+ ];
1817
+ }
1818
+ var moveArrayAt = (data, from, to) => {
1819
+ if (!Array.isArray(data)) {
1820
+ return [];
1821
+ }
1822
+ if (isUndefined(data[to])) {
1823
+ data[to] = void 0;
1824
+ }
1825
+ data.splice(to, 0, data.splice(from, 1)[0]);
1826
+ return data;
1827
+ };
1828
+ var prependAt = (data, value) => [
1829
+ ...convertToArrayPayload(value),
1830
+ ...convertToArrayPayload(data)
1831
+ ];
1832
+ function removeAtIndexes(data, indexes) {
1833
+ let i = 0;
1834
+ const temp = [...data];
1835
+ for (const index of indexes) {
1836
+ temp.splice(index - i, 1);
1837
+ i++;
1838
+ }
1839
+ return compact(temp).length ? temp : [];
1840
+ }
1841
+ var removeArrayAt = (data, index) => isUndefined(index) ? [] : removeAtIndexes(data, convertToArrayPayload(index).sort((a, b) => a - b));
1842
+ var swapArrayAt = (data, indexA, indexB) => {
1843
+ [data[indexA], data[indexB]] = [data[indexB], data[indexA]];
1844
+ };
1845
+ var updateAt = (fieldValues, index, value) => {
1846
+ fieldValues[index] = value;
1847
+ return fieldValues;
1848
+ };
1849
+ function useFieldArray(props) {
1850
+ const formControl = useFormControlContext();
1851
+ const { control = formControl, name, keyName = "id", shouldUnregister, rules } = props;
1852
+ const [fields, setFields] = We.useState(control._getFieldArray(name));
1853
+ const ids = We.useRef(control._getFieldArray(name).map(generateId));
1854
+ const _actioned = We.useRef(false);
1855
+ control._names.array.add(name);
1856
+ We.useMemo(() => rules && fields.length >= 0 && control.register(name, rules), [control, name, fields.length, rules]);
1857
+ useIsomorphicLayoutEffect(() => control._subjects.array.subscribe({
1858
+ next: ({ values, name: fieldArrayName }) => {
1859
+ if (fieldArrayName === name || !fieldArrayName) {
1860
+ const fieldValues = get(values, name);
1861
+ if (Array.isArray(fieldValues)) {
1862
+ setFields(fieldValues);
1863
+ ids.current = fieldValues.map(generateId);
1864
+ }
1865
+ }
1866
+ }
1867
+ }).unsubscribe, [control, name]);
1868
+ const updateValues = We.useCallback((updatedFieldArrayValues) => {
1869
+ _actioned.current = true;
1870
+ control._setFieldArray(name, updatedFieldArrayValues);
1871
+ }, [control, name]);
1872
+ const append = (value, options) => {
1873
+ const appendValue = convertToArrayPayload(cloneObject(value));
1874
+ const updatedFieldArrayValues = appendAt(control._getFieldArray(name), appendValue);
1875
+ control._names.focus = getFocusFieldName(name, updatedFieldArrayValues.length - 1, options);
1876
+ ids.current = appendAt(ids.current, appendValue.map(generateId));
1877
+ updateValues(updatedFieldArrayValues);
1878
+ setFields(updatedFieldArrayValues);
1879
+ control._setFieldArray(name, updatedFieldArrayValues, appendAt, {
1880
+ argA: fillEmptyArray(value)
1881
+ });
1882
+ };
1883
+ const prepend = (value, options) => {
1884
+ const prependValue = convertToArrayPayload(cloneObject(value));
1885
+ const updatedFieldArrayValues = prependAt(control._getFieldArray(name), prependValue);
1886
+ control._names.focus = getFocusFieldName(name, 0, options);
1887
+ ids.current = prependAt(ids.current, prependValue.map(generateId));
1888
+ updateValues(updatedFieldArrayValues);
1889
+ setFields(updatedFieldArrayValues);
1890
+ control._setFieldArray(name, updatedFieldArrayValues, prependAt, {
1891
+ argA: fillEmptyArray(value)
1892
+ });
1893
+ };
1894
+ const remove = (index) => {
1895
+ const updatedFieldArrayValues = removeArrayAt(control._getFieldArray(name), index);
1896
+ ids.current = removeArrayAt(ids.current, index);
1897
+ updateValues(updatedFieldArrayValues);
1898
+ setFields(updatedFieldArrayValues);
1899
+ !Array.isArray(get(control._fields, name)) && set(control._fields, name, void 0);
1900
+ control._setFieldArray(name, updatedFieldArrayValues, removeArrayAt, {
1901
+ argA: index
1902
+ });
1903
+ };
1904
+ const insert$1 = (index, value, options) => {
1905
+ const insertValue = convertToArrayPayload(cloneObject(value));
1906
+ const updatedFieldArrayValues = insert(control._getFieldArray(name), index, insertValue);
1907
+ control._names.focus = getFocusFieldName(name, index, options);
1908
+ ids.current = insert(ids.current, index, insertValue.map(generateId));
1909
+ updateValues(updatedFieldArrayValues);
1910
+ setFields(updatedFieldArrayValues);
1911
+ control._setFieldArray(name, updatedFieldArrayValues, insert, {
1912
+ argA: index,
1913
+ argB: fillEmptyArray(value)
1914
+ });
1915
+ };
1916
+ const swap = (indexA, indexB) => {
1917
+ const updatedFieldArrayValues = control._getFieldArray(name);
1918
+ swapArrayAt(updatedFieldArrayValues, indexA, indexB);
1919
+ swapArrayAt(ids.current, indexA, indexB);
1920
+ updateValues(updatedFieldArrayValues);
1921
+ setFields(updatedFieldArrayValues);
1922
+ control._setFieldArray(name, updatedFieldArrayValues, swapArrayAt, {
1923
+ argA: indexA,
1924
+ argB: indexB
1925
+ }, false);
1926
+ };
1927
+ const move = (from, to) => {
1928
+ const updatedFieldArrayValues = control._getFieldArray(name);
1929
+ moveArrayAt(updatedFieldArrayValues, from, to);
1930
+ moveArrayAt(ids.current, from, to);
1931
+ updateValues(updatedFieldArrayValues);
1932
+ setFields(updatedFieldArrayValues);
1933
+ control._setFieldArray(name, updatedFieldArrayValues, moveArrayAt, {
1934
+ argA: from,
1935
+ argB: to
1936
+ }, false);
1937
+ };
1938
+ const update = (index, value) => {
1939
+ const updateValue = cloneObject(value);
1940
+ const updatedFieldArrayValues = updateAt(control._getFieldArray(name), index, updateValue);
1941
+ ids.current = [...updatedFieldArrayValues].map((item, i) => !item || i === index ? generateId() : ids.current[i]);
1942
+ updateValues(updatedFieldArrayValues);
1943
+ setFields([...updatedFieldArrayValues]);
1944
+ control._setFieldArray(name, updatedFieldArrayValues, updateAt, {
1945
+ argA: index,
1946
+ argB: updateValue
1947
+ }, true, false);
1948
+ };
1949
+ const replace = (value) => {
1950
+ const updatedFieldArrayValues = convertToArrayPayload(cloneObject(value));
1951
+ ids.current = updatedFieldArrayValues.map(generateId);
1952
+ updateValues([...updatedFieldArrayValues]);
1953
+ setFields([...updatedFieldArrayValues]);
1954
+ control._setFieldArray(name, [...updatedFieldArrayValues], (data) => data, {}, true, false);
1955
+ };
1956
+ We.useEffect(() => {
1957
+ control._state.action = false;
1958
+ isWatched(name, control._names) && control._subjects.state.next({
1959
+ ...control._formState
1960
+ });
1961
+ if (_actioned.current && (!getValidationModes(control._options.mode).isOnSubmit || control._formState.isSubmitted) && !getValidationModes(control._options.reValidateMode).isOnSubmit) {
1962
+ if (control._options.resolver) {
1963
+ control._runSchema([name]).then((result) => {
1964
+ control._updateIsValidating([name]);
1965
+ const error = get(result.errors, name);
1966
+ const existingError = get(control._formState.errors, name);
1967
+ if (existingError ? !error && existingError.type || error && (existingError.type !== error.type || existingError.message !== error.message) : error && error.type) {
1968
+ error ? set(control._formState.errors, name, error) : unset(control._formState.errors, name);
1969
+ control._subjects.state.next({
1970
+ errors: control._formState.errors
1971
+ });
1972
+ }
1973
+ });
1974
+ } else {
1975
+ const field = get(control._fields, name);
1976
+ if (field && field._f && !(getValidationModes(control._options.reValidateMode).isOnSubmit && getValidationModes(control._options.mode).isOnSubmit)) {
1977
+ validateField(field, control._names.disabled, control._formValues, control._options.criteriaMode === VALIDATION_MODE.all, control._options.shouldUseNativeValidation, true).then((error) => !isEmptyObject(error) && control._subjects.state.next({
1978
+ errors: updateFieldArrayRootError(control._formState.errors, error, name)
1979
+ }));
1980
+ }
1981
+ }
1982
+ }
1983
+ control._subjects.state.next({
1984
+ name,
1985
+ values: cloneObject(control._formValues)
1986
+ });
1987
+ control._names.focus && iterateFieldsByAction(control._fields, (ref, key) => {
1988
+ if (control._names.focus && key.startsWith(control._names.focus) && ref.focus) {
1989
+ ref.focus();
1990
+ return 1;
1991
+ }
1992
+ return;
1993
+ });
1994
+ control._names.focus = "";
1995
+ control._setValid();
1996
+ _actioned.current = false;
1997
+ }, [fields, name, control]);
1998
+ We.useEffect(() => {
1999
+ !get(control._formValues, name) && control._setFieldArray(name);
2000
+ return () => {
2001
+ const updateMounted = (name2, value) => {
2002
+ const field = get(control._fields, name2);
2003
+ if (field && field._f) {
2004
+ field._f.mount = value;
2005
+ }
2006
+ };
2007
+ control._options.shouldUnregister || shouldUnregister ? control.unregister(name) : updateMounted(name, false);
2008
+ };
2009
+ }, [name, control, keyName, shouldUnregister]);
2010
+ return {
2011
+ swap: We.useCallback(swap, [updateValues, name, control]),
2012
+ move: We.useCallback(move, [updateValues, name, control]),
2013
+ prepend: We.useCallback(prepend, [updateValues, name, control]),
2014
+ append: We.useCallback(append, [updateValues, name, control]),
2015
+ remove: We.useCallback(remove, [updateValues, name, control]),
2016
+ insert: We.useCallback(insert$1, [updateValues, name, control]),
2017
+ update: We.useCallback(update, [updateValues, name, control]),
2018
+ replace: We.useCallback(replace, [updateValues, name, control]),
2019
+ fields: We.useMemo(() => fields.map((field, index) => ({
2020
+ ...field,
2021
+ [keyName]: ids.current[index] || generateId()
2022
+ })), [fields, keyName])
2023
+ };
2024
+ }
2025
+ function useForm(props = {}) {
2026
+ const _formControl = We.useRef(void 0);
2027
+ const _values = We.useRef(void 0);
2028
+ const [formState, updateFormState] = We.useState({
2029
+ isDirty: false,
2030
+ isValidating: false,
2031
+ isLoading: isFunction(props.defaultValues),
2032
+ isSubmitted: false,
2033
+ isSubmitting: false,
2034
+ isSubmitSuccessful: false,
2035
+ isValid: false,
2036
+ submitCount: 0,
2037
+ dirtyFields: {},
2038
+ touchedFields: {},
2039
+ validatingFields: {},
2040
+ errors: props.errors || {},
2041
+ disabled: props.disabled || false,
2042
+ isReady: false,
2043
+ defaultValues: isFunction(props.defaultValues) ? void 0 : props.defaultValues
2044
+ });
2045
+ if (!_formControl.current) {
2046
+ if (props.formControl) {
2047
+ _formControl.current = {
2048
+ ...props.formControl,
2049
+ formState
2050
+ };
2051
+ if (props.defaultValues && !isFunction(props.defaultValues)) {
2052
+ props.formControl.reset(props.defaultValues, props.resetOptions);
2053
+ }
2054
+ } else {
2055
+ const { formControl, ...rest } = createFormControl(props);
2056
+ _formControl.current = {
2057
+ ...rest,
2058
+ formState
2059
+ };
2060
+ }
2061
+ }
2062
+ const control = _formControl.current.control;
2063
+ control._options = props;
2064
+ useIsomorphicLayoutEffect(() => {
2065
+ const sub = control._subscribe({
2066
+ formState: control._proxyFormState,
2067
+ callback: () => updateFormState({ ...control._formState }),
2068
+ reRenderRoot: true
2069
+ });
2070
+ updateFormState((data) => ({
2071
+ ...data,
2072
+ isReady: true
2073
+ }));
2074
+ control._formState.isReady = true;
2075
+ return sub;
2076
+ }, [control]);
2077
+ We.useEffect(() => control._disableForm(props.disabled), [control, props.disabled]);
2078
+ We.useEffect(() => {
2079
+ if (props.mode) {
2080
+ control._options.mode = props.mode;
2081
+ }
2082
+ if (props.reValidateMode) {
2083
+ control._options.reValidateMode = props.reValidateMode;
2084
+ }
2085
+ }, [control, props.mode, props.reValidateMode]);
2086
+ We.useEffect(() => {
2087
+ if (props.errors) {
2088
+ control._setErrors(props.errors);
2089
+ control._focusError();
2090
+ }
2091
+ }, [control, props.errors]);
2092
+ We.useEffect(() => {
2093
+ props.shouldUnregister && control._subjects.state.next({
2094
+ values: control._getWatch()
2095
+ });
2096
+ }, [control, props.shouldUnregister]);
2097
+ We.useEffect(() => {
2098
+ if (control._proxyFormState.isDirty) {
2099
+ const isDirty = control._getDirty();
2100
+ if (isDirty !== formState.isDirty) {
2101
+ control._subjects.state.next({
2102
+ isDirty
2103
+ });
2104
+ }
2105
+ }
2106
+ }, [control, formState.isDirty]);
2107
+ We.useEffect(() => {
2108
+ var _a;
2109
+ if (props.values && !deepEqual$1(props.values, _values.current)) {
2110
+ control._reset(props.values, {
2111
+ keepFieldsRef: true,
2112
+ ...control._options.resetOptions
2113
+ });
2114
+ if (!((_a = control._options.resetOptions) === null || _a === void 0 ? void 0 : _a.keepIsValid)) {
2115
+ control._setValid();
2116
+ }
2117
+ _values.current = props.values;
2118
+ updateFormState((state) => ({ ...state }));
2119
+ } else {
2120
+ control._resetDefaultValues();
2121
+ }
2122
+ }, [control, props.values]);
2123
+ We.useEffect(() => {
2124
+ if (!control._state.mount) {
2125
+ control._setValid();
2126
+ control._state.mount = true;
2127
+ }
2128
+ if (control._state.watch) {
2129
+ control._state.watch = false;
2130
+ control._subjects.state.next({ ...control._formState });
2131
+ }
2132
+ control._removeUnmounted();
2133
+ });
2134
+ _formControl.current.formState = We.useMemo(() => getProxyFormState(formState, control), [control, formState]);
2135
+ return _formControl.current;
2136
+ }
2137
+ var NAME = "Label";
2138
+ var Label$1 = reactExports.forwardRef((props, forwardedRef) => {
2139
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
2140
+ Primitive.label,
2141
+ {
2142
+ ...props,
2143
+ ref: forwardedRef,
2144
+ onMouseDown: (event) => {
2145
+ const target = event.target;
2146
+ if (target.closest("button, input, select, textarea")) return;
2147
+ props.onMouseDown?.(event);
2148
+ if (!event.defaultPrevented && event.detail > 1) event.preventDefault();
2149
+ }
2150
+ }
2151
+ );
2152
+ });
2153
+ Label$1.displayName = NAME;
2154
+ var Root = Label$1;
2155
+ var TABS_NAME = "Tabs";
2156
+ var [createTabsContext] = createContextScope(TABS_NAME, [
2157
+ createRovingFocusGroupScope
2158
+ ]);
2159
+ var useRovingFocusGroupScope = createRovingFocusGroupScope();
2160
+ var [TabsProvider, useTabsContext] = createTabsContext(TABS_NAME);
2161
+ var Tabs$1 = reactExports.forwardRef(
2162
+ (props, forwardedRef) => {
2163
+ const {
2164
+ __scopeTabs,
2165
+ value: valueProp,
2166
+ onValueChange,
2167
+ defaultValue,
2168
+ orientation = "horizontal",
2169
+ dir,
2170
+ activationMode = "automatic",
2171
+ ...tabsProps
2172
+ } = props;
2173
+ const direction = useDirection(dir);
2174
+ const [value, setValue] = useControllableState({
2175
+ prop: valueProp,
2176
+ onChange: onValueChange,
2177
+ defaultProp: defaultValue ?? "",
2178
+ caller: TABS_NAME
2179
+ });
2180
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
2181
+ TabsProvider,
2182
+ {
2183
+ scope: __scopeTabs,
2184
+ baseId: useId(),
2185
+ value,
2186
+ onValueChange: setValue,
2187
+ orientation,
2188
+ dir: direction,
2189
+ activationMode,
2190
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(
2191
+ Primitive.div,
2192
+ {
2193
+ dir: direction,
2194
+ "data-orientation": orientation,
2195
+ ...tabsProps,
2196
+ ref: forwardedRef
2197
+ }
2198
+ )
2199
+ }
2200
+ );
2201
+ }
2202
+ );
2203
+ Tabs$1.displayName = TABS_NAME;
2204
+ var TAB_LIST_NAME = "TabsList";
2205
+ var TabsList$1 = reactExports.forwardRef(
2206
+ (props, forwardedRef) => {
2207
+ const { __scopeTabs, loop = true, ...listProps } = props;
2208
+ const context = useTabsContext(TAB_LIST_NAME, __scopeTabs);
2209
+ const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeTabs);
2210
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
2211
+ Root$1,
2212
+ {
2213
+ asChild: true,
2214
+ ...rovingFocusGroupScope,
2215
+ orientation: context.orientation,
2216
+ dir: context.dir,
2217
+ loop,
2218
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(
2219
+ Primitive.div,
2220
+ {
2221
+ role: "tablist",
2222
+ "aria-orientation": context.orientation,
2223
+ ...listProps,
2224
+ ref: forwardedRef
2225
+ }
2226
+ )
2227
+ }
2228
+ );
2229
+ }
2230
+ );
2231
+ TabsList$1.displayName = TAB_LIST_NAME;
2232
+ var TRIGGER_NAME = "TabsTrigger";
2233
+ var TabsTrigger$1 = reactExports.forwardRef(
2234
+ (props, forwardedRef) => {
2235
+ const { __scopeTabs, value, disabled = false, ...triggerProps } = props;
2236
+ const context = useTabsContext(TRIGGER_NAME, __scopeTabs);
2237
+ const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeTabs);
2238
+ const triggerId = makeTriggerId(context.baseId, value);
2239
+ const contentId = makeContentId(context.baseId, value);
2240
+ const isSelected = value === context.value;
2241
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
2242
+ Item,
2243
+ {
2244
+ asChild: true,
2245
+ ...rovingFocusGroupScope,
2246
+ focusable: !disabled,
2247
+ active: isSelected,
2248
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(
2249
+ Primitive.button,
2250
+ {
2251
+ type: "button",
2252
+ role: "tab",
2253
+ "aria-selected": isSelected,
2254
+ "aria-controls": contentId,
2255
+ "data-state": isSelected ? "active" : "inactive",
2256
+ "data-disabled": disabled ? "" : void 0,
2257
+ disabled,
2258
+ id: triggerId,
2259
+ ...triggerProps,
2260
+ ref: forwardedRef,
2261
+ onMouseDown: composeEventHandlers(props.onMouseDown, (event) => {
2262
+ if (!disabled && event.button === 0 && event.ctrlKey === false) {
2263
+ context.onValueChange(value);
2264
+ } else {
2265
+ event.preventDefault();
2266
+ }
2267
+ }),
2268
+ onKeyDown: composeEventHandlers(props.onKeyDown, (event) => {
2269
+ if ([" ", "Enter"].includes(event.key)) context.onValueChange(value);
2270
+ }),
2271
+ onFocus: composeEventHandlers(props.onFocus, () => {
2272
+ const isAutomaticActivation = context.activationMode !== "manual";
2273
+ if (!isSelected && !disabled && isAutomaticActivation) {
2274
+ context.onValueChange(value);
2275
+ }
2276
+ })
2277
+ }
2278
+ )
2279
+ }
2280
+ );
2281
+ }
2282
+ );
2283
+ TabsTrigger$1.displayName = TRIGGER_NAME;
2284
+ var CONTENT_NAME = "TabsContent";
2285
+ var TabsContent$1 = reactExports.forwardRef(
2286
+ (props, forwardedRef) => {
2287
+ const { __scopeTabs, value, forceMount, children, ...contentProps } = props;
2288
+ const context = useTabsContext(CONTENT_NAME, __scopeTabs);
2289
+ const triggerId = makeTriggerId(context.baseId, value);
2290
+ const contentId = makeContentId(context.baseId, value);
2291
+ const isSelected = value === context.value;
2292
+ const isMountAnimationPreventedRef = reactExports.useRef(isSelected);
2293
+ reactExports.useEffect(() => {
2294
+ const rAF = requestAnimationFrame(() => isMountAnimationPreventedRef.current = false);
2295
+ return () => cancelAnimationFrame(rAF);
2296
+ }, []);
2297
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(Presence, { present: forceMount || isSelected, children: ({ present }) => /* @__PURE__ */ jsxRuntimeExports.jsx(
2298
+ Primitive.div,
2299
+ {
2300
+ "data-state": isSelected ? "active" : "inactive",
2301
+ "data-orientation": context.orientation,
2302
+ role: "tabpanel",
2303
+ "aria-labelledby": triggerId,
2304
+ hidden: !present,
2305
+ id: contentId,
2306
+ tabIndex: 0,
2307
+ ...contentProps,
2308
+ ref: forwardedRef,
2309
+ style: {
2310
+ ...props.style,
2311
+ animationDuration: isMountAnimationPreventedRef.current ? "0s" : void 0
2312
+ },
2313
+ children: present && children
2314
+ }
2315
+ ) });
2316
+ }
2317
+ );
2318
+ TabsContent$1.displayName = CONTENT_NAME;
2319
+ function makeTriggerId(baseId, value) {
2320
+ return `${baseId}-trigger-${value}`;
2321
+ }
2322
+ function makeContentId(baseId, value) {
2323
+ return `${baseId}-content-${value}`;
2324
+ }
2325
+ var Root2 = Tabs$1;
2326
+ var List = TabsList$1;
2327
+ var Trigger = TabsTrigger$1;
2328
+ var Content = TabsContent$1;
2329
+ function Input({ className, type, ...props }) {
2330
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
2331
+ "input",
2332
+ {
2333
+ type,
2334
+ "data-slot": "input",
2335
+ className: cn(
2336
+ "h-9 w-full min-w-0 rounded-4xl border border-input bg-input/30 px-3 py-1 text-base outline-none transition-colors file:inline-flex file:h-7 file:border-0 file:bg-transparent file:font-medium file:text-foreground file:text-sm placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-[3px] aria-invalid:ring-destructive/20 md:text-sm dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",
2337
+ className
2338
+ ),
2339
+ ...props
2340
+ }
2341
+ );
2342
+ }
2343
+ const labelVariants = cva(
2344
+ "flex select-none items-center gap-2 font-medium text-sm leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-50 group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50"
2345
+ );
2346
+ function Label({ className, ...props }) {
2347
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(Root, { "data-slot": "label", className: cn(labelVariants(), className), ...props });
2348
+ }
2349
+ function getDefaultValue(schema) {
2350
+ if (typeof schema === "boolean") return null;
2351
+ const type = schema.type;
2352
+ if (Array.isArray(type))
2353
+ return getDefaultValue({
2354
+ ...schema,
2355
+ type: type[0]
2356
+ });
2357
+ if (type === "object" && typeof schema === "object")
2358
+ return Object.fromEntries(
2359
+ Object.entries(schema.properties ?? {}).map(([key, prop]) => {
2360
+ return [key, getDefaultValue(prop)];
2361
+ })
2362
+ );
2363
+ if (type === "array") return [];
2364
+ if (type === "null") return null;
2365
+ if (type === "string") {
2366
+ if (typeof schema === "object" && schema.format === "binary") return void 0;
2367
+ return "";
2368
+ }
2369
+ if (type === "number" || type === "integer") return 0;
2370
+ if (type === "boolean") return false;
2371
+ }
2372
+ function deepEqual(a, b) {
2373
+ if (a === b) {
2374
+ return true;
2375
+ }
2376
+ if (a == null || b == null) {
2377
+ return false;
2378
+ }
2379
+ if (typeof a !== "object" || typeof b !== "object") {
2380
+ return false;
2381
+ }
2382
+ if (Array.isArray(a) && Array.isArray(b)) {
2383
+ if (a.length !== b.length) {
2384
+ return false;
2385
+ }
2386
+ return a.every((item, index) => deepEqual(item, b[index]));
2387
+ }
2388
+ if (Array.isArray(a) || Array.isArray(b)) {
2389
+ return false;
2390
+ }
2391
+ const keysA = Object.keys(a);
2392
+ const keysB = Object.keys(b);
2393
+ if (keysA.length !== keysB.length) {
2394
+ return false;
2395
+ }
2396
+ return keysA.every(
2397
+ (key) => Object.prototype.hasOwnProperty.call(b, key) && deepEqual(a[key], b[key])
2398
+ );
2399
+ }
2400
+ function mergeAllOf(schema) {
2401
+ if (typeof schema === "boolean" || !schema.allOf) return schema;
2402
+ const { allOf, ...rest } = schema;
2403
+ let result = rest;
2404
+ for (const item of allOf) {
2405
+ result = intersection(result, item);
2406
+ }
2407
+ return result;
2408
+ }
2409
+ function intersection(a, b) {
2410
+ a = mergeAllOf(a);
2411
+ b = mergeAllOf(b);
2412
+ if (typeof a === "boolean" && typeof b === "boolean") return a && b;
2413
+ if (typeof a === "boolean") return a;
2414
+ if (typeof b === "boolean") return b;
2415
+ const result = { ...a };
2416
+ for (const _k in b) {
2417
+ const key = _k;
2418
+ switch (key) {
2419
+ case "$id":
2420
+ case "$comment":
2421
+ case "description":
2422
+ case "additionalItems":
2423
+ case "examples":
2424
+ case "allOf":
2425
+ case "writeOnly":
2426
+ case "readOnly":
2427
+ break;
2428
+ case "title": {
2429
+ const value = b[key];
2430
+ if (value === void 0) break;
2431
+ if (result[key]) {
2432
+ result[key] = `${result[key]} & ${value}`;
2433
+ } else {
2434
+ result[key] = value;
2435
+ }
2436
+ break;
2437
+ }
2438
+ case "minItems":
2439
+ case "minimum":
2440
+ case "exclusiveMinimum":
2441
+ case "minProperties":
2442
+ case "minContains":
2443
+ case "minLength": {
2444
+ const value = b[key];
2445
+ if (value === void 0) break;
2446
+ result[key] = result[key] === void 0 ? value : Math.max(result[key], value);
2447
+ break;
2448
+ }
2449
+ case "maxContains":
2450
+ case "maxItems":
2451
+ case "maxLength":
2452
+ case "maxProperties":
2453
+ case "maximum":
2454
+ case "exclusiveMaximum": {
2455
+ const value = b[key];
2456
+ if (value === void 0) break;
2457
+ result[key] = result[key] === void 0 ? value : Math.min(result[key], value);
2458
+ break;
2459
+ }
2460
+ // intersection
2461
+ case "enum":
2462
+ case "anyOf":
2463
+ case "oneOf": {
2464
+ const value = b[key];
2465
+ if (value === void 0) break;
2466
+ result[key] = result[key] === void 0 ? value : intersectArray(result[key], value);
2467
+ break;
2468
+ }
2469
+ // require same
2470
+ case "format":
2471
+ case "const":
2472
+ case "type": {
2473
+ const value = b[key];
2474
+ if (value === void 0) break;
2475
+ result[key] ??= value;
2476
+ if (!deepEqual(result[key], value)) return false;
2477
+ break;
2478
+ }
2479
+ // add
2480
+ case "required": {
2481
+ const value = b[key];
2482
+ if (value === void 0) break;
2483
+ result[key] = [...result[key] ?? [], ...value];
2484
+ break;
2485
+ }
2486
+ case "properties":
2487
+ case "patternProperties": {
2488
+ const value = b[key];
2489
+ if (value === void 0) break;
2490
+ if (result[key] === void 0) {
2491
+ result[key] = value;
2492
+ break;
2493
+ }
2494
+ const out = {};
2495
+ const allProps = /* @__PURE__ */ new Set();
2496
+ for (const k in result[key]) allProps.add(k);
2497
+ for (const k in value) allProps.add(k);
2498
+ for (const prop of allProps) {
2499
+ const aProp = result[key][prop];
2500
+ const bProp = value[prop];
2501
+ if (aProp === void 0) {
2502
+ out[prop] = bProp;
2503
+ } else if (bProp === void 0) {
2504
+ out[prop] = aProp;
2505
+ } else {
2506
+ out[prop] = intersection(aProp, bProp);
2507
+ }
2508
+ }
2509
+ result[key] = out;
2510
+ break;
2511
+ }
2512
+ case "additionalProperties":
2513
+ case "contains":
2514
+ case "items": {
2515
+ const value = b[key];
2516
+ if (value === void 0) break;
2517
+ result[key] = result[key] === void 0 ? value : intersection(result[key], value);
2518
+ break;
2519
+ }
2520
+ case "not": {
2521
+ const value = b[key];
2522
+ if (value === void 0) break;
2523
+ if (result[key] && value) {
2524
+ result.not = { anyOf: [result[key], value] };
2525
+ } else if (value) {
2526
+ result.not = value;
2527
+ }
2528
+ break;
2529
+ }
2530
+ default:
2531
+ result[key] = b[key];
2532
+ }
2533
+ }
2534
+ return result;
2535
+ }
2536
+ function intersectArray(a, b) {
2537
+ const out = /* @__PURE__ */ new Set();
2538
+ for (const item of a) {
2539
+ if (b.includes(item)) out.add(item);
2540
+ }
2541
+ for (const item of b) {
2542
+ if (a.includes(item)) out.add(item);
2543
+ }
2544
+ return Array.from(out);
2545
+ }
2546
+ const SchemaContext = reactExports.createContext(void 0);
2547
+ const anyFields = {
2548
+ type: ["string", "number", "boolean", "array", "object"],
2549
+ items: true,
2550
+ additionalProperties: true
2551
+ };
2552
+ function SchemaProvider({
2553
+ schema,
2554
+ readOnly,
2555
+ writeOnly,
2556
+ children
2557
+ }) {
2558
+ const fieldInfoMap = reactExports.useMemo(() => /* @__PURE__ */ new Map(), []);
2559
+ const ajv = reactExports.useMemo(
2560
+ () => new Ajv2020({
2561
+ strict: false,
2562
+ validateSchema: false,
2563
+ validateFormats: false,
2564
+ schemas: [schema]
2565
+ }),
2566
+ [schema]
2567
+ );
2568
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
2569
+ SchemaContext,
2570
+ {
2571
+ value: reactExports.useMemo(
2572
+ () => ({ schema, fieldInfoMap, ajv, readOnly, writeOnly }),
2573
+ [schema, fieldInfoMap, ajv, readOnly, writeOnly]
2574
+ ),
2575
+ children
2576
+ }
2577
+ );
2578
+ }
2579
+ function useSchema() {
2580
+ return reactExports.use(SchemaContext);
2581
+ }
2582
+ function useFieldInfo(fieldName, schema, depth) {
2583
+ const { fieldInfoMap, ajv } = reactExports.use(SchemaContext);
2584
+ const form = useFormContext();
2585
+ const keyName = `${fieldName}:${depth}`;
2586
+ const [info, setInfo] = reactExports.useState(() => {
2587
+ const value = form.getValues(fieldName);
2588
+ const initialInfo = fieldInfoMap.get(keyName);
2589
+ if (initialInfo) return initialInfo;
2590
+ const out = {
2591
+ oneOf: -1
2592
+ };
2593
+ const union = getUnion(schema);
2594
+ if (union) {
2595
+ const [members, field] = union;
2596
+ out.oneOf = members.findIndex((item) => ajv.validate(item, value));
2597
+ if (out.oneOf === -1) out.oneOf = 0;
2598
+ out.unionField = field;
2599
+ }
2600
+ if (Array.isArray(schema.type)) {
2601
+ const types = schema.type;
2602
+ out.selectedType = types.find((type) => {
2603
+ schema.type = type;
2604
+ const match = ajv.validate(schema, value);
2605
+ schema.type = types;
2606
+ return match;
2607
+ }) ?? types.at(0);
2608
+ }
2609
+ if (schema.allOf) {
2610
+ const merged = mergeAllOf(schema);
2611
+ if (typeof merged !== "boolean")
2612
+ out.intersection = {
2613
+ merged
2614
+ };
2615
+ }
2616
+ return out;
2617
+ });
2618
+ fieldInfoMap.set(keyName, info);
2619
+ return {
2620
+ info,
2621
+ updateInfo(value) {
2622
+ const updated = {
2623
+ ...info,
2624
+ ...value
2625
+ };
2626
+ if (updated.oneOf === info.oneOf && updated.selectedType === info.selectedType) return;
2627
+ setInfo(updated);
2628
+ let valueSchema = schema;
2629
+ if (updated.unionField) {
2630
+ valueSchema = schema[updated.unionField][updated.oneOf];
2631
+ } else if (updated.selectedType) {
2632
+ valueSchema = { ...schema, type: updated.selectedType };
2633
+ }
2634
+ form.setValue(fieldName, getDefaultValue(valueSchema));
2635
+ }
2636
+ };
2637
+ }
2638
+ function useResolvedSchema(schema) {
2639
+ const { ajv } = reactExports.use(SchemaContext);
2640
+ return reactExports.useMemo(() => fallbackAny(dereference(schema, { ajv })), [ajv, schema]);
2641
+ }
2642
+ function fallbackAny(schema) {
2643
+ return typeof schema === "boolean" ? anyFields : schema;
2644
+ }
2645
+ function getUnion(schema) {
2646
+ if (schema.anyOf) {
2647
+ return [schema.anyOf, "anyOf"];
2648
+ }
2649
+ if (schema.oneOf) return [schema.oneOf, "oneOf"];
2650
+ }
2651
+ function dereference(schema, { ajv }) {
2652
+ if (typeof schema === "boolean") return schema;
2653
+ if (schema.$ref) return ajv.getSchema(schema.$ref)?.schema ?? false;
2654
+ return schema;
2655
+ }
2656
+ var FormatFlags = /* @__PURE__ */ ((FormatFlags2) => {
2657
+ FormatFlags2[FormatFlags2["None"] = 0] = "None";
2658
+ FormatFlags2[FormatFlags2["UseAlias"] = 1] = "UseAlias";
2659
+ return FormatFlags2;
2660
+ })(FormatFlags || {});
2661
+ function schemaToString(value, ctx, flags = 0) {
2662
+ function union(union2, sep, flags2) {
2663
+ const members = /* @__PURE__ */ new Set();
2664
+ let nullable = false;
2665
+ for (const item of union2) {
2666
+ const result2 = run(
2667
+ item,
2668
+ flags2 | 1
2669
+ /* UseAlias */
2670
+ );
2671
+ if (result2 === "null") {
2672
+ nullable = true;
2673
+ } else if (result2 !== "unknown") {
2674
+ members.add(result2);
2675
+ }
2676
+ }
2677
+ const result = Array.from(members).join(sep);
2678
+ return nullable ? `${result} | null` : result;
2679
+ }
2680
+ function run(schema, flags2) {
2681
+ if (schema === true) return "any";
2682
+ else if (schema === false) return "never";
2683
+ if ((flags2 & 1) === 1) {
2684
+ if (schema.title) return schema.title;
2685
+ const ref = schema.$ref?.split("/");
2686
+ if (ref && ref.length > 0) return ref[ref.length - 1];
2687
+ } else if (schema.$ref) {
2688
+ const out = dereference(schema, ctx);
2689
+ if (typeof out !== "boolean") schema = out;
2690
+ }
2691
+ if (Array.isArray(schema.type)) {
2692
+ return union(
2693
+ schema.type.map((type) => ({
2694
+ ...schema,
2695
+ type
2696
+ })),
2697
+ " | ",
2698
+ flags2
2699
+ );
2700
+ }
2701
+ if (schema.type === "array")
2702
+ return `array<${schema.items ? run(
2703
+ schema.items,
2704
+ flags2 | 1
2705
+ /* UseAlias */
2706
+ ) : "unknown"}>`;
2707
+ const or = schema.oneOf ?? schema.anyOf;
2708
+ if (schema.oneOf && schema.anyOf) {
2709
+ return `(${union(schema.oneOf, " | ", flags2)}) & (${union(schema.anyOf, " | ", flags2)})`;
2710
+ } else if (or) {
2711
+ return union(or, " | ", flags2);
2712
+ }
2713
+ if (schema.allOf) {
2714
+ return union(schema.allOf, " & ", flags2);
2715
+ }
2716
+ if (schema.not) return `not ${run(schema.not, flags2)}`;
2717
+ if (schema.type === "string" && schema.format === "binary") return "file";
2718
+ if (schema.type) {
2719
+ return Array.isArray(schema.type) ? schema.type.filter((v) => v !== "null").join(" | ") : schema.type;
2720
+ }
2721
+ return "unknown";
2722
+ }
2723
+ return run(value, flags);
2724
+ }
2725
+ function Textarea({ className, ...props }) {
2726
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
2727
+ "textarea",
2728
+ {
2729
+ "data-slot": "textarea",
2730
+ className: cn(
2731
+ "field-sizing-content flex min-h-16 w-full resize-none rounded-xl border border-input bg-input/30 px-3 py-3 text-base outline-none transition-colors placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-[3px] aria-invalid:ring-destructive/20 md:text-sm dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",
2732
+ className
2733
+ ),
2734
+ ...props
2735
+ }
2736
+ );
2737
+ }
2738
+ function FieldLabel(props) {
2739
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("label", { ...props, className: cn("w-full inline-flex items-center gap-0.5", props.className), children: props.children });
2740
+ }
2741
+ function FieldLabelName({
2742
+ required = false,
2743
+ className,
2744
+ children,
2745
+ ...props
2746
+ }) {
2747
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { ...props, className: cn(labelVariants(), "me-auto", className), children: [
2748
+ children,
2749
+ required && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-destructive mx-1", children: "*" })
2750
+ ] });
2751
+ }
2752
+ function FieldLabelType(props) {
2753
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("code", { ...props, className: cn("text-xs text-muted-foreground", props.className), children: props.children });
2754
+ }
2755
+ function ObjectInput({
2756
+ field: _field,
2757
+ fieldName,
2758
+ ...props
2759
+ }) {
2760
+ const field = useResolvedSchema(_field);
2761
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { ...props, className: cn("flex flex-col gap-4", props.className), children: [
2762
+ Object.entries(field.properties ?? {}).map(([key, child]) => /* @__PURE__ */ jsxRuntimeExports.jsx(
2763
+ FieldSet,
2764
+ {
2765
+ name: key,
2766
+ field: child,
2767
+ fieldName: `${fieldName}.${key}`,
2768
+ isRequired: field.required?.includes(key)
2769
+ },
2770
+ key
2771
+ )),
2772
+ (field.additionalProperties || field.patternProperties) && /* @__PURE__ */ jsxRuntimeExports.jsx(
2773
+ DynamicProperties,
2774
+ {
2775
+ fieldName,
2776
+ filterKey: (v) => !field.properties || !Object.keys(field.properties).includes(v),
2777
+ getType: (key) => {
2778
+ for (const pattern in field.patternProperties) {
2779
+ if (key.match(RegExp(pattern))) {
2780
+ return field.patternProperties[pattern];
2781
+ }
2782
+ }
2783
+ if (field.additionalProperties) return field.additionalProperties;
2784
+ return anyFields;
2785
+ }
2786
+ }
2787
+ )
2788
+ ] });
2789
+ }
2790
+ function DynamicProperties({
2791
+ fieldName,
2792
+ filterKey = () => true,
2793
+ getType = () => anyFields
2794
+ }) {
2795
+ const { control, setValue, getValues } = useFormContext();
2796
+ const [nextName, setNextName] = reactExports.useState("");
2797
+ const [properties, setProperties] = reactExports.useState(() => {
2798
+ const value = getValues(fieldName);
2799
+ if (value) return Object.keys(value).filter(filterKey);
2800
+ return [];
2801
+ });
2802
+ const onAppend = () => {
2803
+ const name = nextName.trim();
2804
+ if (name.length === 0) return;
2805
+ setProperties((p) => {
2806
+ if (p.includes(name) || !filterKey(name)) return p;
2807
+ const type = getType(name);
2808
+ setValue(`${fieldName}.${name}`, getDefaultValue(type));
2809
+ setNextName("");
2810
+ return [...p, name];
2811
+ });
2812
+ };
2813
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
2814
+ properties.map((item) => {
2815
+ const type = getType(item);
2816
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
2817
+ FieldSet,
2818
+ {
2819
+ name: item,
2820
+ field: type,
2821
+ fieldName: `${fieldName}.${item}`,
2822
+ toolbar: /* @__PURE__ */ jsxRuntimeExports.jsx(
2823
+ "button",
2824
+ {
2825
+ type: "button",
2826
+ "aria-label": "Remove Item",
2827
+ className: cn(
2828
+ buttonVariants({
2829
+ variant: "outline",
2830
+ size: "icon-xs"
2831
+ })
2832
+ ),
2833
+ onClick: () => {
2834
+ setProperties((p) => p.filter((prop) => prop !== item));
2835
+ control.unregister(`${fieldName}.${item}`);
2836
+ },
2837
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(Trash2, {})
2838
+ }
2839
+ )
2840
+ },
2841
+ item
2842
+ );
2843
+ }),
2844
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex gap-2 col-span-full", children: [
2845
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
2846
+ Input,
2847
+ {
2848
+ value: nextName,
2849
+ placeholder: "Enter Property Name",
2850
+ onChange: (e) => setNextName(e.target.value),
2851
+ onKeyDown: (e) => {
2852
+ if (e.key === "Enter") {
2853
+ onAppend();
2854
+ e.preventDefault();
2855
+ }
2856
+ }
2857
+ }
2858
+ ),
2859
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
2860
+ "button",
2861
+ {
2862
+ type: "button",
2863
+ className: cn(buttonVariants({ variant: "secondary", size: "sm" }), "px-4"),
2864
+ onClick: onAppend,
2865
+ children: "New"
2866
+ }
2867
+ )
2868
+ ] })
2869
+ ] });
2870
+ }
2871
+ function FieldInput({
2872
+ field,
2873
+ fieldName,
2874
+ isRequired,
2875
+ ...props
2876
+ }) {
2877
+ const form = useFormContext();
2878
+ const {
2879
+ field: { value, onChange, ...restField },
2880
+ fieldState
2881
+ } = useController({
2882
+ control: form.control,
2883
+ name: fieldName
2884
+ });
2885
+ if (field.type === "null") return;
2886
+ if (field.enum) {
2887
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs(
2888
+ Select,
2889
+ {
2890
+ value: field.enum.indexOf(value).toString(),
2891
+ onValueChange: (value2) => {
2892
+ onChange(value2 === "-1" ? void 0 : value2);
2893
+ },
2894
+ disabled: restField.disabled,
2895
+ children: [
2896
+ /* @__PURE__ */ jsxRuntimeExports.jsx(SelectTrigger, { id: fieldName, className: props.className, ...restField, children: /* @__PURE__ */ jsxRuntimeExports.jsx(SelectValue, {}) }),
2897
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(SelectContent, { children: [
2898
+ field.enum.map((item, i) => /* @__PURE__ */ jsxRuntimeExports.jsx(SelectItem, { value: i.toString(), children: JSON.stringify(item) }, i)),
2899
+ !isRequired && /* @__PURE__ */ jsxRuntimeExports.jsx(SelectItem, { value: "-1", children: "Unset" })
2900
+ ] })
2901
+ ]
2902
+ }
2903
+ );
2904
+ }
2905
+ if (field.type === "boolean") {
2906
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs(
2907
+ Select,
2908
+ {
2909
+ value: String(value),
2910
+ onValueChange: (value2) => onChange(value2 === "undefined" ? void 0 : value2 === "true"),
2911
+ disabled: restField.disabled,
2912
+ children: [
2913
+ /* @__PURE__ */ jsxRuntimeExports.jsx(SelectTrigger, { id: fieldName, className: props.className, ...restField, children: /* @__PURE__ */ jsxRuntimeExports.jsx(SelectValue, {}) }),
2914
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(SelectContent, { children: [
2915
+ /* @__PURE__ */ jsxRuntimeExports.jsx(SelectItem, { value: "true", children: "True" }),
2916
+ /* @__PURE__ */ jsxRuntimeExports.jsx(SelectItem, { value: "false", children: "False" }),
2917
+ !isRequired && /* @__PURE__ */ jsxRuntimeExports.jsx(SelectItem, { value: "undefined", children: "Unset" })
2918
+ ] })
2919
+ ]
2920
+ }
2921
+ );
2922
+ }
2923
+ const resetBn = fieldState.isDirty && /* @__PURE__ */ jsxRuntimeExports.jsx(
2924
+ "button",
2925
+ {
2926
+ type: "button",
2927
+ onClick: () => form.resetField(fieldName),
2928
+ className: "text-muted-foreground",
2929
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(X, { className: "size-4" })
2930
+ }
2931
+ );
2932
+ if (field.type === "string") {
2933
+ if (field.format === "binary") {
2934
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { ...props, children: [
2935
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
2936
+ "label",
2937
+ {
2938
+ htmlFor: fieldName,
2939
+ className: cn(
2940
+ buttonVariants({
2941
+ variant: "secondary",
2942
+ className: "w-full h-9 gap-2 truncate"
2943
+ })
2944
+ ),
2945
+ children: value instanceof File ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
2946
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-muted-foreground text-xs", children: "Selected" }),
2947
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "truncate w-0 flex-1 text-end", children: value.name })
2948
+ ] }) : /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-muted-foreground", children: "Upload" })
2949
+ }
2950
+ ),
2951
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
2952
+ "input",
2953
+ {
2954
+ id: fieldName,
2955
+ type: "file",
2956
+ multiple: false,
2957
+ onChange: (e) => {
2958
+ if (!e.target.files) return;
2959
+ onChange(e.target.files.item(0));
2960
+ },
2961
+ hidden: true,
2962
+ ...restField
2963
+ }
2964
+ )
2965
+ ] });
2966
+ }
2967
+ if (field.format === "datetime" || field.format === "time" || field.format === "date")
2968
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { ...props, className: cn("flex flex-row gap-2", props.className), children: [
2969
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
2970
+ Input,
2971
+ {
2972
+ id: fieldName,
2973
+ type: field.format,
2974
+ placeholder: "Enter value",
2975
+ value: value ?? "",
2976
+ onChange: (e) => onChange(e.target.value),
2977
+ ...restField
2978
+ }
2979
+ ),
2980
+ resetBn
2981
+ ] });
2982
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { ...props, className: cn("flex flex-row gap-2", props.className), children: [
2983
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
2984
+ Textarea,
2985
+ {
2986
+ id: fieldName,
2987
+ placeholder: "Enter value",
2988
+ value: value ?? "",
2989
+ onChange: (e) => onChange(e.target.value),
2990
+ ...restField
2991
+ }
2992
+ ),
2993
+ resetBn
2994
+ ] });
2995
+ }
2996
+ if (field.type === "integer" || field.type === "number") {
2997
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { ...props, className: cn("flex flex-row gap-2", props.className), children: [
2998
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
2999
+ Input,
3000
+ {
3001
+ id: fieldName,
3002
+ placeholder: "Enter value",
3003
+ type: "number",
3004
+ step: field.type === "integer" ? 1 : void 0,
3005
+ value: value ?? "",
3006
+ onChange: (e) => {
3007
+ if (!Number.isNaN(e.target.valueAsNumber)) {
3008
+ onChange(e.target.valueAsNumber);
3009
+ }
3010
+ },
3011
+ ...restField
3012
+ }
3013
+ ),
3014
+ resetBn
3015
+ ] });
3016
+ }
3017
+ }
3018
+ function FieldSet({
3019
+ field: _field,
3020
+ fieldName,
3021
+ toolbar,
3022
+ name,
3023
+ isRequired,
3024
+ depth = 0,
3025
+ slotType,
3026
+ collapsible = true,
3027
+ ...props
3028
+ }) {
3029
+ const schemaContext = useSchema();
3030
+ const field = useResolvedSchema(_field);
3031
+ const [show, setShow] = reactExports.useState(!collapsible);
3032
+ const { info, updateInfo } = useFieldInfo(fieldName, field, depth);
3033
+ if (_field === false) return;
3034
+ if (field.readOnly && !schemaContext.readOnly) return;
3035
+ if (field.writeOnly && !schemaContext.writeOnly) return;
3036
+ if (info.unionField) {
3037
+ const union = field[info.unionField];
3038
+ const showSelect = union.length > 1;
3039
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
3040
+ FieldSet,
3041
+ {
3042
+ ...props,
3043
+ name,
3044
+ fieldName,
3045
+ isRequired,
3046
+ field: union[info.oneOf],
3047
+ depth: depth + 1,
3048
+ slotType: showSelect ? false : slotType,
3049
+ toolbar: /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
3050
+ showSelect && /* @__PURE__ */ jsxRuntimeExports.jsx(
3051
+ "select",
3052
+ {
3053
+ className: "text-xs font-mono",
3054
+ value: info.oneOf,
3055
+ onChange: (e) => {
3056
+ updateInfo({
3057
+ oneOf: Number(e.target.value)
3058
+ });
3059
+ },
3060
+ children: union.map((item, i) => /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: i, className: "bg-popover text-popover-foreground", children: schemaToString(item, schemaContext, FormatFlags.UseAlias) }, i))
3061
+ }
3062
+ ),
3063
+ toolbar
3064
+ ] })
3065
+ }
3066
+ );
3067
+ }
3068
+ if (Array.isArray(field.type)) {
3069
+ const showSelect = field.type.length > 1;
3070
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
3071
+ FieldSet,
3072
+ {
3073
+ ...props,
3074
+ name,
3075
+ fieldName,
3076
+ isRequired,
3077
+ field: {
3078
+ ...field,
3079
+ type: info.selectedType
3080
+ },
3081
+ depth: depth + 1,
3082
+ slotType: showSelect ? false : slotType,
3083
+ toolbar: /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
3084
+ showSelect && /* @__PURE__ */ jsxRuntimeExports.jsx(
3085
+ "select",
3086
+ {
3087
+ className: "text-xs font-mono",
3088
+ value: info.selectedType,
3089
+ onChange: (e) => {
3090
+ updateInfo({
3091
+ selectedType: e.target.value
3092
+ });
3093
+ },
3094
+ children: field.type.map((item) => /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: item, className: "bg-popover text-popover-foreground", children: item }, item))
3095
+ }
3096
+ ),
3097
+ toolbar
3098
+ ] })
3099
+ }
3100
+ );
3101
+ }
3102
+ const showBn = collapsible && /* @__PURE__ */ jsxRuntimeExports.jsx(
3103
+ "button",
3104
+ {
3105
+ type: "button",
3106
+ onClick: () => setShow((prev) => !prev),
3107
+ className: cn(
3108
+ buttonVariants({
3109
+ size: "icon-xs",
3110
+ variant: "ghost",
3111
+ className: "text-muted-foreground -ms-1"
3112
+ })
3113
+ ),
3114
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(ChevronDown, { className: cn(show && "rotate-180") })
3115
+ }
3116
+ );
3117
+ if (field.type === "object" || info.intersection) {
3118
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs(
3119
+ "fieldset",
3120
+ {
3121
+ ...props,
3122
+ className: cn("flex flex-col gap-1.5 col-span-full @container", props.className),
3123
+ children: [
3124
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(FieldLabel, { htmlFor: fieldName, children: [
3125
+ showBn,
3126
+ /* @__PURE__ */ jsxRuntimeExports.jsx(FieldLabelName, { required: isRequired, children: name }),
3127
+ slotType ?? /* @__PURE__ */ jsxRuntimeExports.jsx(FieldLabelType, { children: schemaToString(field, schemaContext) }),
3128
+ toolbar
3129
+ ] }),
3130
+ show && /* @__PURE__ */ jsxRuntimeExports.jsx(
3131
+ ObjectInput,
3132
+ {
3133
+ field: info.intersection?.merged ?? field,
3134
+ fieldName,
3135
+ ...props,
3136
+ className: cn(
3137
+ "rounded-lg border bg-card text-card-foreground p-3 shadow-sm",
3138
+ props.className
3139
+ )
3140
+ }
3141
+ )
3142
+ ]
3143
+ }
3144
+ );
3145
+ }
3146
+ if (field.type === "array") {
3147
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("fieldset", { ...props, className: cn("flex flex-col gap-1.5 col-span-full", props.className), children: [
3148
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(FieldLabel, { htmlFor: fieldName, children: [
3149
+ showBn,
3150
+ /* @__PURE__ */ jsxRuntimeExports.jsx(FieldLabelName, { required: isRequired, children: name }),
3151
+ slotType ?? /* @__PURE__ */ jsxRuntimeExports.jsx(FieldLabelType, { children: schemaToString(field, schemaContext) }),
3152
+ toolbar
3153
+ ] }),
3154
+ show && /* @__PURE__ */ jsxRuntimeExports.jsx(
3155
+ ArrayInput,
3156
+ {
3157
+ fieldName,
3158
+ items: field.items ?? anyFields,
3159
+ ...props,
3160
+ className: cn(
3161
+ "rounded-lg border bg-card text-card-foreground p-3 shadow-sm",
3162
+ props.className
3163
+ )
3164
+ }
3165
+ )
3166
+ ] });
3167
+ }
3168
+ if (!field.type) {
3169
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
3170
+ FieldSet,
3171
+ {
3172
+ ...props,
3173
+ name,
3174
+ fieldName,
3175
+ isRequired,
3176
+ field: anyFields,
3177
+ depth: depth + 1,
3178
+ slotType,
3179
+ toolbar
3180
+ }
3181
+ );
3182
+ }
3183
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("fieldset", { ...props, className: cn("flex flex-col gap-1.5", props.className), children: [
3184
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(FieldLabel, { htmlFor: fieldName, children: [
3185
+ /* @__PURE__ */ jsxRuntimeExports.jsx(FieldLabelName, { required: isRequired, children: name }),
3186
+ slotType ?? /* @__PURE__ */ jsxRuntimeExports.jsx(FieldLabelType, { children: schemaToString(field, schemaContext) }),
3187
+ toolbar
3188
+ ] }),
3189
+ /* @__PURE__ */ jsxRuntimeExports.jsx(FieldInput, { field, fieldName, isRequired })
3190
+ ] });
3191
+ }
3192
+ function ArrayInput({
3193
+ fieldName,
3194
+ items,
3195
+ ...props
3196
+ }) {
3197
+ const name = fieldName.split(".").at(-1) ?? "";
3198
+ const { fields, append, remove } = useFieldArray({
3199
+ name: fieldName
3200
+ });
3201
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { ...props, className: cn("flex flex-col gap-2", props.className), children: [
3202
+ fields.map((item, index) => /* @__PURE__ */ jsxRuntimeExports.jsx(
3203
+ FieldSet,
3204
+ {
3205
+ name: /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "text-muted-foreground", children: [
3206
+ name,
3207
+ "[",
3208
+ index,
3209
+ "]"
3210
+ ] }),
3211
+ field: items,
3212
+ isRequired: true,
3213
+ fieldName: `${fieldName}.${index}`,
3214
+ toolbar: /* @__PURE__ */ jsxRuntimeExports.jsx(
3215
+ "button",
3216
+ {
3217
+ type: "button",
3218
+ "aria-label": "Remove Item",
3219
+ className: cn(
3220
+ buttonVariants({
3221
+ variant: "outline",
3222
+ size: "icon-xs"
3223
+ })
3224
+ ),
3225
+ onClick: () => remove(index),
3226
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(Trash2, {})
3227
+ }
3228
+ )
3229
+ },
3230
+ item.id
3231
+ )),
3232
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(
3233
+ "button",
3234
+ {
3235
+ type: "button",
3236
+ className: cn(
3237
+ buttonVariants({
3238
+ variant: "secondary",
3239
+ className: "gap-1.5 py-2",
3240
+ size: "sm"
3241
+ })
3242
+ ),
3243
+ onClick: () => {
3244
+ append(getDefaultValue(items));
3245
+ },
3246
+ children: [
3247
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Plus, { className: "size-4" }),
3248
+ "New Item"
3249
+ ]
3250
+ }
3251
+ )
3252
+ ] });
3253
+ }
3254
+ function JSONSchemaEditorProvider({
3255
+ children,
3256
+ defaultValue,
3257
+ onValueChange,
3258
+ ...props
3259
+ }) {
3260
+ const form = useForm({
3261
+ defaultValues: { value: defaultValue }
3262
+ });
3263
+ const onValueChangeRef = reactExports.useRef(onValueChange);
3264
+ onValueChangeRef.current = onValueChange;
3265
+ reactExports.useEffect(() => {
3266
+ return form.subscribe({
3267
+ formState: {
3268
+ values: true
3269
+ },
3270
+ callback(data) {
3271
+ onValueChangeRef.current(data.values.value);
3272
+ }
3273
+ });
3274
+ }, []);
3275
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(FormProvider, { ...form, children: /* @__PURE__ */ jsxRuntimeExports.jsx(SchemaProvider, { ...props, children }) });
3276
+ }
3277
+ function JSONSchemaEditorContent() {
3278
+ const { schema } = useSchema();
3279
+ const field = useResolvedSchema(schema);
3280
+ const fieldName = "value";
3281
+ if (field.format === "binary") return /* @__PURE__ */ jsxRuntimeExports.jsx(FieldSet, { field, fieldName });
3282
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(FieldSet, { field, fieldName, collapsible: false });
3283
+ }
3284
+ function Tabs({
3285
+ className,
3286
+ orientation = "horizontal",
3287
+ ...props
3288
+ }) {
3289
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
3290
+ Root2,
3291
+ {
3292
+ "data-slot": "tabs",
3293
+ "data-orientation": orientation,
3294
+ className: cn("group/tabs flex gap-2 data-horizontal:flex-col", className),
3295
+ ...props
3296
+ }
3297
+ );
3298
+ }
3299
+ function TabsList({ className, ...props }) {
3300
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
3301
+ List,
3302
+ {
3303
+ "data-slot": "tabs-list",
3304
+ className: cn(
3305
+ "rounded-4xl bg-muted p-1 group-data-horizontal/tabs:h-9 group-data-vertical/tabs:rounded-2xl group/tabs-list text-muted-foreground inline-flex w-fit items-center justify-center group-data-vertical/tabs:h-fit group-data-vertical/tabs:flex-col",
3306
+ className
3307
+ ),
3308
+ ...props
3309
+ }
3310
+ );
3311
+ }
3312
+ function TabsTrigger({ className, ...props }) {
3313
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
3314
+ Trigger,
3315
+ {
3316
+ "data-slot": "tabs-trigger",
3317
+ className: cn(
3318
+ "relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 whitespace-nowrap rounded-xl border border-transparent px-2 py-1 font-medium text-foreground/60 text-sm transition-colors hover:text-foreground focus-visible:border-ring focus-visible:outline-1 focus-visible:outline-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 group-data-vertical/tabs:w-full group-data-vertical/tabs:justify-start group-data-vertical/tabs:px-2.5 group-data-vertical/tabs:py-1.5 dark:text-muted-foreground dark:hover:text-foreground [&_svg]:size-4 [&_svg]:shrink-0",
3319
+ "data-active:bg-background data-active:text-foreground dark:data-active:border-input dark:data-active:bg-input/30 dark:data-active:text-foreground",
3320
+ className
3321
+ ),
3322
+ ...props
3323
+ }
3324
+ );
3325
+ }
3326
+ function TabsContent({ className, ...props }) {
3327
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
3328
+ Content,
3329
+ {
3330
+ "data-slot": "tabs-content",
3331
+ className: cn("flex-1 text-sm outline-none", className),
3332
+ ...props
3333
+ }
3334
+ );
3335
+ }
3336
+ const Editor = reactExports.lazy(() => import("./yaml-BEdFfhvc.js").then((mod) => ({ default: mod.YamlEditor })));
3337
+ function YamlEditorLazy(props) {
3338
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
3339
+ reactExports.Suspense,
3340
+ {
3341
+ fallback: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex flex-col bg-secondary text-secondary-foreground overflow-hidden border rounded-lg", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "p-2 h-[240px] text-sm font-mono flex items-center justify-center text-muted-foreground", children: "Loading editor..." }) }),
3342
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(Editor, { ...props })
3343
+ }
3344
+ );
3345
+ }
3346
+ function StatusBar({ status }) {
3347
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sticky bottom-2 rounded-full bg-popover text-xs text-popover-foreground inline-flex items-center gap-1 px-3 py-1.5 border shadow-lg z-20 mx-auto", children: status === "updating" ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
3348
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Spinner, { className: "text-primary" }),
3349
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-muted-foreground", children: "Saving" })
3350
+ ] }) : status === "sync" ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
3351
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Check, { className: "size-4 text-green-400" }),
3352
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: "In Sync" })
3353
+ ] }) : status === "updated" ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
3354
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Circle, { className: "size-4 fill-current stroke-transparent text-orange-400" }),
3355
+ /* @__PURE__ */ jsxRuntimeExports.jsx("p", { children: "Updated" })
3356
+ ] }) : /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
3357
+ /* @__PURE__ */ jsxRuntimeExports.jsx(CircleAlert, { className: "size-4 text-destructive" }),
3358
+ /* @__PURE__ */ jsxRuntimeExports.jsx("p", { children: status.message })
3359
+ ] }) });
3360
+ }
3361
+ function useSync(onSyncCallback) {
3362
+ const [isPending, startTransition] = reactExports.useTransition();
3363
+ const [status, setStatus] = reactExports.useState("sync");
3364
+ const timerRef = reactExports.useRef(null);
3365
+ return {
3366
+ status: isPending ? "updating" : status,
3367
+ onSync(syncAction) {
3368
+ if (isPending) return;
3369
+ setStatus("updated");
3370
+ if (timerRef.current) window.clearTimeout(timerRef.current);
3371
+ timerRef.current = window.setTimeout(() => {
3372
+ startTransition(async () => {
3373
+ try {
3374
+ syncAction?.();
3375
+ await onSyncCallback();
3376
+ setStatus("sync");
3377
+ } catch (e) {
3378
+ setStatus({
3379
+ type: "error",
3380
+ message: Error.isError(e) ? e.message : "Failed to save document"
3381
+ });
3382
+ }
3383
+ });
3384
+ }, 500);
3385
+ }
3386
+ };
3387
+ }
3388
+ export {
3389
+ Controller as C,
3390
+ Input as I,
3391
+ JSONSchemaEditorProvider as J,
3392
+ Label as L,
3393
+ Plus as P,
3394
+ StatusBar as S,
3395
+ Tabs as T,
3396
+ YamlEditorLazy as Y,
3397
+ useSync as a,
3398
+ TabsList as b,
3399
+ TabsTrigger as c,
3400
+ TabsContent as d,
3401
+ JSONSchemaEditorContent as e,
3402
+ Trash2 as f,
3403
+ useForm as u
3404
+ };