@mistriwork/mistri 1.0.0-rc.12 → 1.0.0-rc.13

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 (221) hide show
  1. package/README.md +4 -3
  2. package/dist/client/assets/LayoutBuilder-MPzkVU2e.js.map +1 -1
  3. package/dist/client/assets/index-D2dHI6hR.js.map +1 -1
  4. package/dist/client/assets/shell-TreN_uLs.js.map +1 -1
  5. package/dist/docs/access-model.md +1 -1
  6. package/dist/docs/build-and-deploy.md +0 -1
  7. package/dist/docs/cli.md +1 -1
  8. package/dist/docs/glossary.md +3 -3
  9. package/dist/docs/query.md +9 -21
  10. package/dist/docs/status.md +3 -3
  11. package/dist/embed/react/chunks/LayoutBuilder-Cbxa_wve.js.map +1 -1
  12. package/dist/embed/react/chunks/app-0UZ1Re1k.js.map +1 -1
  13. package/dist/embed/react/chunks/page-Bx4o1kpQ.js.map +1 -1
  14. package/dist/embed/react/chunks/palette-Bb7Lf6eo.js.map +1 -1
  15. package/dist/embed/react/chunks/shell-DZRACiB9.js.map +1 -1
  16. package/dist/embed/react/chunks/write-BQO4CFc9.js.map +1 -1
  17. package/dist/embed/react/index.js +1 -1
  18. package/dist/server/build/dockerfile.js +1 -1
  19. package/dist/server/cli/usage.js +2 -2
  20. package/dist/ui/index.js +2 -2
  21. package/dist/ui/page.js +2 -2
  22. package/dist/ui/{shared-N4Ej8yRD.js → shared-1PD7TOTJ.js} +5 -5
  23. package/dist/ui/{shared-N4Ej8yRD.js.map → shared-1PD7TOTJ.js.map} +1 -1
  24. package/dist/ui/{shared-D5m86-4o.js → shared-1gMnOu9J.js} +6 -6
  25. package/dist/ui/{shared-D5m86-4o.js.map → shared-1gMnOu9J.js.map} +1 -1
  26. package/dist/ui/{shared-Ctaj8mR2.js → shared-5RQMi4BR.js} +3 -3
  27. package/dist/ui/{shared-Ctaj8mR2.js.map → shared-5RQMi4BR.js.map} +1 -1
  28. package/dist/ui/{shared-DpLeIATZ.js → shared-B-BUF9fx.js} +2 -2
  29. package/dist/ui/{shared-DpLeIATZ.js.map → shared-B-BUF9fx.js.map} +1 -1
  30. package/dist/ui/{shared-DWYnjItP.js → shared-B-MhiPIN.js} +9 -9
  31. package/dist/ui/{shared-DWYnjItP.js.map → shared-B-MhiPIN.js.map} +1 -1
  32. package/dist/ui/{shared-0fNuhSbG.js → shared-B07qIMlE.js} +5 -5
  33. package/dist/ui/{shared-0fNuhSbG.js.map → shared-B07qIMlE.js.map} +1 -1
  34. package/dist/ui/{shared-lYtMadRU.js → shared-B1SAS_J-.js} +3 -3
  35. package/dist/ui/{shared-lYtMadRU.js.map → shared-B1SAS_J-.js.map} +1 -1
  36. package/dist/ui/{shared-CpI0Y8M5.js → shared-B4jgU8h9.js} +6 -6
  37. package/dist/ui/{shared-CpI0Y8M5.js.map → shared-B4jgU8h9.js.map} +1 -1
  38. package/dist/ui/{shared-Cxu1c35l.js → shared-B5aBCUi7.js} +30 -30
  39. package/dist/ui/{shared-Cxu1c35l.js.map → shared-B5aBCUi7.js.map} +1 -1
  40. package/dist/ui/{shared-CAe-US1q.js → shared-B9H7_Pji.js} +5 -5
  41. package/dist/ui/{shared-CAe-US1q.js.map → shared-B9H7_Pji.js.map} +1 -1
  42. package/dist/ui/{shared-Q2bgBaYo.js → shared-BAXr20S-.js} +4 -4
  43. package/dist/ui/{shared-Q2bgBaYo.js.map → shared-BAXr20S-.js.map} +1 -1
  44. package/dist/ui/{shared-CyEefFFb.js → shared-BDDUzH-f.js} +19 -19
  45. package/dist/ui/{shared-CyEefFFb.js.map → shared-BDDUzH-f.js.map} +1 -1
  46. package/dist/ui/{shared-BdhPI6dq.js → shared-BGmkeDeW.js} +3 -3
  47. package/dist/ui/{shared-BdhPI6dq.js.map → shared-BGmkeDeW.js.map} +1 -1
  48. package/dist/ui/{shared-DONIpq2q.js → shared-BHCQ60yN.js} +2 -2
  49. package/dist/ui/{shared-DONIpq2q.js.map → shared-BHCQ60yN.js.map} +1 -1
  50. package/dist/ui/{shared-CNmaAv64.js → shared-BHsjawAG.js} +8 -8
  51. package/dist/ui/{shared-CNmaAv64.js.map → shared-BHsjawAG.js.map} +1 -1
  52. package/dist/ui/{shared-DgjU9kOy.js → shared-BIQuK_nq.js} +4 -4
  53. package/dist/ui/{shared-DgjU9kOy.js.map → shared-BIQuK_nq.js.map} +1 -1
  54. package/dist/ui/{shared-icSQAj21.js → shared-BOe4W2FI.js} +3 -3
  55. package/dist/ui/{shared-icSQAj21.js.map → shared-BOe4W2FI.js.map} +1 -1
  56. package/dist/ui/{shared-BlxoOJSk.js → shared-BPpC08ip.js} +3 -3
  57. package/dist/ui/{shared-BlxoOJSk.js.map → shared-BPpC08ip.js.map} +1 -1
  58. package/dist/ui/{shared-BtiFL37J.js → shared-BdA3LPCB.js} +2 -2
  59. package/dist/ui/{shared-BtiFL37J.js.map → shared-BdA3LPCB.js.map} +1 -1
  60. package/dist/ui/{shared-CvR94vn4.js → shared-Be3nbWsd.js} +11 -11
  61. package/dist/ui/{shared-CvR94vn4.js.map → shared-Be3nbWsd.js.map} +1 -1
  62. package/dist/ui/{shared-Bl_nF_IH.js → shared-Bf30ZLoS.js} +8 -4
  63. package/dist/ui/shared-Bf30ZLoS.js.map +1 -0
  64. package/dist/ui/{shared-DijrJ_V-.js → shared-BguP_BaR.js} +7 -7
  65. package/dist/ui/{shared-DijrJ_V-.js.map → shared-BguP_BaR.js.map} +1 -1
  66. package/dist/ui/{shared-DPAVoWY0.js → shared-BoLbc2WD.js} +17 -2
  67. package/dist/ui/{shared-DPAVoWY0.js.map → shared-BoLbc2WD.js.map} +1 -1
  68. package/dist/ui/{shared-BkdBTYwx.js → shared-BttyOW4W.js} +3 -3
  69. package/dist/ui/{shared-BkdBTYwx.js.map → shared-BttyOW4W.js.map} +1 -1
  70. package/dist/ui/{shared-CQWLz8uT.js → shared-BumxsBlA.js} +10 -10
  71. package/dist/ui/{shared-CQWLz8uT.js.map → shared-BumxsBlA.js.map} +1 -1
  72. package/dist/ui/{shared-Dzu7tFiC.js → shared-Bw73ktBk.js} +3 -3
  73. package/dist/ui/{shared-Dzu7tFiC.js.map → shared-Bw73ktBk.js.map} +1 -1
  74. package/dist/ui/{shared-BhAYErSx.js → shared-C1B0GH0e.js} +4 -4
  75. package/dist/ui/{shared-BhAYErSx.js.map → shared-C1B0GH0e.js.map} +1 -1
  76. package/dist/ui/{shared-BQJQcGgj.js → shared-C2FsyYr7.js} +4 -4
  77. package/dist/ui/{shared-BQJQcGgj.js.map → shared-C2FsyYr7.js.map} +1 -1
  78. package/dist/ui/{shared-B9lw2Ryh.js → shared-C2RU1qjv.js} +4 -4
  79. package/dist/ui/{shared-B9lw2Ryh.js.map → shared-C2RU1qjv.js.map} +1 -1
  80. package/dist/ui/{shared-DQYNI9wO.js → shared-C42f07hJ.js} +5 -5
  81. package/dist/ui/{shared-DQYNI9wO.js.map → shared-C42f07hJ.js.map} +1 -1
  82. package/dist/ui/{shared-CqCZ8wMY.js → shared-C4LkPCU4.js} +3 -3
  83. package/dist/ui/{shared-CqCZ8wMY.js.map → shared-C4LkPCU4.js.map} +1 -1
  84. package/dist/ui/{shared-BhtpgOpa.js → shared-C4wSfz6k.js} +9 -9
  85. package/dist/ui/{shared-BhtpgOpa.js.map → shared-C4wSfz6k.js.map} +1 -1
  86. package/dist/ui/{shared-BHc2Izkj.js → shared-C9DZtSFH.js} +2 -2
  87. package/dist/ui/{shared-BHc2Izkj.js.map → shared-C9DZtSFH.js.map} +1 -1
  88. package/dist/ui/{shared-DW1YuiNS.js → shared-CA52ClGo.js} +2 -2
  89. package/dist/ui/{shared-DW1YuiNS.js.map → shared-CA52ClGo.js.map} +1 -1
  90. package/dist/ui/{shared-BbSbilkh.js → shared-CBciTwm6.js} +9 -9
  91. package/dist/ui/{shared-BbSbilkh.js.map → shared-CBciTwm6.js.map} +1 -1
  92. package/dist/ui/{shared-C-J32eBn.js → shared-CL3RLKDA.js} +16 -16
  93. package/dist/ui/{shared-C-J32eBn.js.map → shared-CL3RLKDA.js.map} +1 -1
  94. package/dist/ui/{shared-Ck8S4OxW.js → shared-CLq3-_hW.js} +3 -3
  95. package/dist/ui/{shared-Ck8S4OxW.js.map → shared-CLq3-_hW.js.map} +1 -1
  96. package/dist/ui/{shared-Q5WefT7G.js → shared-CMjK-Ucd.js} +3 -3
  97. package/dist/ui/{shared-Q5WefT7G.js.map → shared-CMjK-Ucd.js.map} +1 -1
  98. package/dist/ui/{shared-D3MAuEA3.js → shared-CPjpSFGh.js} +2 -2
  99. package/dist/ui/{shared-D3MAuEA3.js.map → shared-CPjpSFGh.js.map} +1 -1
  100. package/dist/ui/{shared-VshXGwXP.js → shared-CSPhENq3.js} +2 -2
  101. package/dist/ui/{shared-VshXGwXP.js.map → shared-CSPhENq3.js.map} +1 -1
  102. package/dist/ui/{shared-DJrJaE73.js → shared-CZJE4Bmp.js} +3 -3
  103. package/dist/ui/{shared-DJrJaE73.js.map → shared-CZJE4Bmp.js.map} +1 -1
  104. package/dist/ui/{shared-D7ONOwI7.js → shared-C_BhUL2I.js} +7 -7
  105. package/dist/ui/{shared-D7ONOwI7.js.map → shared-C_BhUL2I.js.map} +1 -1
  106. package/dist/ui/{shared-j-2peBIB.js → shared-CbeujwdU.js} +4 -4
  107. package/dist/ui/{shared-j-2peBIB.js.map → shared-CbeujwdU.js.map} +1 -1
  108. package/dist/ui/{shared-D5GrOEa2.js → shared-Cbf-o4Dt.js} +4 -4
  109. package/dist/ui/{shared-D5GrOEa2.js.map → shared-Cbf-o4Dt.js.map} +1 -1
  110. package/dist/ui/{shared-HwiPIajr.js → shared-CdNmeNHh.js} +3 -3
  111. package/dist/ui/{shared-HwiPIajr.js.map → shared-CdNmeNHh.js.map} +1 -1
  112. package/dist/ui/{shared-ZCFt-CPb.js → shared-CdQOMD8J.js} +3 -3
  113. package/dist/ui/{shared-ZCFt-CPb.js.map → shared-CdQOMD8J.js.map} +1 -1
  114. package/dist/ui/{shared-ClhXSGGK.js → shared-CdiPYlTh.js} +2 -2
  115. package/dist/ui/{shared-ClhXSGGK.js.map → shared-CdiPYlTh.js.map} +1 -1
  116. package/dist/ui/{shared-DA8_pVRZ.js → shared-CepLAhwm.js} +2 -2
  117. package/dist/ui/{shared-DA8_pVRZ.js.map → shared-CepLAhwm.js.map} +1 -1
  118. package/dist/ui/{shared-BrYKjrnM.js → shared-Ch82h_Fu.js} +6 -6
  119. package/dist/ui/{shared-BrYKjrnM.js.map → shared-Ch82h_Fu.js.map} +1 -1
  120. package/dist/ui/{shared-C4UrE8Fb.js → shared-Chp88all.js} +3 -3
  121. package/dist/ui/{shared-C4UrE8Fb.js.map → shared-Chp88all.js.map} +1 -1
  122. package/dist/ui/{shared-CWa80DTO.js → shared-Ci16s2rN.js} +9 -9
  123. package/dist/ui/{shared-CWa80DTO.js.map → shared-Ci16s2rN.js.map} +1 -1
  124. package/dist/ui/{shared-tksTLD6Q.js → shared-CiqNkoE1.js} +5 -5
  125. package/dist/ui/{shared-tksTLD6Q.js.map → shared-CiqNkoE1.js.map} +1 -1
  126. package/dist/ui/{shared-yt7DjSrq.js → shared-CpMhOq8F.js} +2 -2
  127. package/dist/ui/{shared-yt7DjSrq.js.map → shared-CpMhOq8F.js.map} +1 -1
  128. package/dist/ui/{shared-Dm0z5WUl.js → shared-CrWv5JKH.js} +6 -6
  129. package/dist/ui/{shared-Dm0z5WUl.js.map → shared-CrWv5JKH.js.map} +1 -1
  130. package/dist/ui/{shared-CQL3FGHc.js → shared-Csfi3Pti.js} +2 -2
  131. package/dist/ui/{shared-CQL3FGHc.js.map → shared-Csfi3Pti.js.map} +1 -1
  132. package/dist/ui/{shared-BKNRbm-V.js → shared-CuZt26rm.js} +2 -2
  133. package/dist/ui/{shared-BKNRbm-V.js.map → shared-CuZt26rm.js.map} +1 -1
  134. package/dist/ui/{shared-Guq3upiR.js → shared-Cws_z-TS.js} +2 -2
  135. package/dist/ui/{shared-Guq3upiR.js.map → shared-Cws_z-TS.js.map} +1 -1
  136. package/dist/ui/{shared-Bw_qZeIj.js → shared-D1KWuCg6.js} +2 -2
  137. package/dist/ui/{shared-Bw_qZeIj.js.map → shared-D1KWuCg6.js.map} +1 -1
  138. package/dist/ui/{shared-CuCZKwXW.js → shared-D66ju_Cb.js} +23 -23
  139. package/dist/ui/{shared-CuCZKwXW.js.map → shared-D66ju_Cb.js.map} +1 -1
  140. package/dist/ui/{shared-DYfX7NSM.js → shared-DGaQZXnw.js} +2 -2
  141. package/dist/ui/{shared-DYfX7NSM.js.map → shared-DGaQZXnw.js.map} +1 -1
  142. package/dist/ui/{shared-B3Hp8tOv.js → shared-DHy41sET.js} +6 -6
  143. package/dist/ui/{shared-B3Hp8tOv.js.map → shared-DHy41sET.js.map} +1 -1
  144. package/dist/ui/{shared-CXyd7IKi.js → shared-DKEOMQ6l.js} +2 -2
  145. package/dist/ui/{shared-CXyd7IKi.js.map → shared-DKEOMQ6l.js.map} +1 -1
  146. package/dist/ui/{shared-Ccmc8YO0.js → shared-DSUICuaJ.js} +33 -33
  147. package/dist/ui/{shared-Ccmc8YO0.js.map → shared-DSUICuaJ.js.map} +1 -1
  148. package/dist/ui/{shared-CL2iw_js.js → shared-DUPMRoO0.js} +13 -13
  149. package/dist/ui/{shared-CL2iw_js.js.map → shared-DUPMRoO0.js.map} +1 -1
  150. package/dist/ui/{shared-Dtp4eRul.js → shared-DVfdm6ah.js} +2 -2
  151. package/dist/ui/{shared-Dtp4eRul.js.map → shared-DVfdm6ah.js.map} +1 -1
  152. package/dist/ui/{shared-BJ5Ex32G.js → shared-DXM7d7lJ.js} +3 -3
  153. package/dist/ui/{shared-BJ5Ex32G.js.map → shared-DXM7d7lJ.js.map} +1 -1
  154. package/dist/ui/{shared-BFr6ld0e.js → shared-DXbMlcev.js} +2 -2
  155. package/dist/ui/{shared-BFr6ld0e.js.map → shared-DXbMlcev.js.map} +1 -1
  156. package/dist/ui/{shared-BUp3jv-N.js → shared-D_SkPtJ9.js} +6 -6
  157. package/dist/ui/{shared-BUp3jv-N.js.map → shared-D_SkPtJ9.js.map} +1 -1
  158. package/dist/ui/{shared-CdNomVzH.js → shared-Dd21k2ic.js} +4 -4
  159. package/dist/ui/{shared-CdNomVzH.js.map → shared-Dd21k2ic.js.map} +1 -1
  160. package/dist/ui/{shared-gRMbxmpu.js → shared-Dh0nHtLZ.js} +8 -8
  161. package/dist/ui/{shared-gRMbxmpu.js.map → shared-Dh0nHtLZ.js.map} +1 -1
  162. package/dist/ui/{shared-BKGJgjog.js → shared-DkOdSpSK.js} +3 -3
  163. package/dist/ui/{shared-BKGJgjog.js.map → shared-DkOdSpSK.js.map} +1 -1
  164. package/dist/ui/{shared-BMsh72Uq.js → shared-Dkph5ckT.js} +2 -2
  165. package/dist/ui/{shared-BMsh72Uq.js.map → shared-Dkph5ckT.js.map} +1 -1
  166. package/dist/ui/{shared-Be1HpDOB.js → shared-Dl1_Nx--.js} +3 -3
  167. package/dist/ui/{shared-Be1HpDOB.js.map → shared-Dl1_Nx--.js.map} +1 -1
  168. package/dist/ui/{shared-BQIZWOoJ.js → shared-Dm0IGbAf.js} +2 -2
  169. package/dist/ui/{shared-BQIZWOoJ.js.map → shared-Dm0IGbAf.js.map} +1 -1
  170. package/dist/ui/{shared-DSUtcU5S.js → shared-DnIkTpPr.js} +5 -5
  171. package/dist/ui/{shared-DSUtcU5S.js.map → shared-DnIkTpPr.js.map} +1 -1
  172. package/dist/ui/{shared-DsxGbYlV.js → shared-Docl_0tq.js} +3 -3
  173. package/dist/ui/{shared-DsxGbYlV.js.map → shared-Docl_0tq.js.map} +1 -1
  174. package/dist/ui/{shared-DZskrV26.js → shared-DprrHC72.js} +2 -2
  175. package/dist/ui/{shared-DZskrV26.js.map → shared-DprrHC72.js.map} +1 -1
  176. package/dist/ui/{shared-Bmw43Hwf.js → shared-DyKsJTZs.js} +2 -2
  177. package/dist/ui/{shared-Bmw43Hwf.js.map → shared-DyKsJTZs.js.map} +1 -1
  178. package/dist/ui/{shared-BLG88Pya.js → shared-FO7vfI3F.js} +4 -4
  179. package/dist/ui/{shared-BLG88Pya.js.map → shared-FO7vfI3F.js.map} +1 -1
  180. package/dist/ui/{shared-DLSd80D1.js → shared-HalAVHjv.js} +3 -3
  181. package/dist/ui/{shared-DLSd80D1.js.map → shared-HalAVHjv.js.map} +1 -1
  182. package/dist/ui/{shared-D1mMBLdj.js → shared-JvcI-LWp.js} +15 -15
  183. package/dist/ui/{shared-D1mMBLdj.js.map → shared-JvcI-LWp.js.map} +1 -1
  184. package/dist/ui/{shared-C6Hv_4O0.js → shared-K7Ym27yg.js} +2 -2
  185. package/dist/ui/{shared-C6Hv_4O0.js.map → shared-K7Ym27yg.js.map} +1 -1
  186. package/dist/ui/{shared-B39ln7oi.js → shared-SzlnwfJO.js} +3 -3
  187. package/dist/ui/{shared-B39ln7oi.js.map → shared-SzlnwfJO.js.map} +1 -1
  188. package/dist/ui/{shared-DgPn_Jll.js → shared-TrGbd1FY.js} +3 -3
  189. package/dist/ui/{shared-DgPn_Jll.js.map → shared-TrGbd1FY.js.map} +1 -1
  190. package/dist/ui/{shared-DrFb-XtA.js → shared-WhbuObEW.js} +2 -2
  191. package/dist/ui/{shared-DrFb-XtA.js.map → shared-WhbuObEW.js.map} +1 -1
  192. package/dist/ui/{shared-DiFQljcq.js → shared-XcSKDp6N.js} +11 -11
  193. package/dist/ui/{shared-DiFQljcq.js.map → shared-XcSKDp6N.js.map} +1 -1
  194. package/dist/ui/{shared-CMAg58rY.js → shared-Z4uBJU6I.js} +7 -6
  195. package/dist/ui/shared-Z4uBJU6I.js.map +1 -0
  196. package/dist/ui/{shared-BnUptuUp.js → shared-bAgeiRa5.js} +2 -2
  197. package/dist/ui/{shared-BnUptuUp.js.map → shared-bAgeiRa5.js.map} +1 -1
  198. package/dist/ui/{shared-BxMvSjey.js → shared-cgXG7OgZ.js} +5 -5
  199. package/dist/ui/{shared-BxMvSjey.js.map → shared-cgXG7OgZ.js.map} +1 -1
  200. package/dist/ui/{shared-u4CG2kQJ.js → shared-eZ0SB_zm.js} +2 -2
  201. package/dist/ui/{shared-u4CG2kQJ.js.map → shared-eZ0SB_zm.js.map} +1 -1
  202. package/dist/ui/{shared-L90bWW8e.js → shared-frKFb79C.js} +2 -2
  203. package/dist/ui/{shared-L90bWW8e.js.map → shared-frKFb79C.js.map} +1 -1
  204. package/dist/ui/{shared-Dd34nhkw.js → shared-hAayNSRA.js} +3 -3
  205. package/dist/ui/{shared-Dd34nhkw.js.map → shared-hAayNSRA.js.map} +1 -1
  206. package/dist/ui/{shared-DzC64cpp.js → shared-j_J16p2B.js} +2 -2
  207. package/dist/ui/{shared-DzC64cpp.js.map → shared-j_J16p2B.js.map} +1 -1
  208. package/dist/ui/{shared-DX7HRIV-.js → shared-tqpl5N3g.js} +6 -6
  209. package/dist/ui/{shared-DX7HRIV-.js.map → shared-tqpl5N3g.js.map} +1 -1
  210. package/dist/ui/{shared-BS5dBMpA.js → shared-y-6_ZDts.js} +2 -2
  211. package/dist/ui/{shared-BS5dBMpA.js.map → shared-y-6_ZDts.js.map} +1 -1
  212. package/dist/ui/{shared-Cv5v_MP1.js → shared-zG6e1Rhz.js} +13 -13
  213. package/dist/ui/{shared-Cv5v_MP1.js.map → shared-zG6e1Rhz.js.map} +1 -1
  214. package/dist/ui/testing.js +1 -1
  215. package/package.json +4 -4
  216. package/dist/docs/cli-browser.md +0 -232
  217. package/dist/docs/database-browser.md +0 -115
  218. package/dist/docs/keyboard.md +0 -63
  219. package/dist/docs/mcp.md +0 -86
  220. package/dist/ui/shared-Bl_nF_IH.js.map +0 -1
  221. package/dist/ui/shared-CMAg58rY.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"shared-D1mMBLdj.js","names":["say","readValue","_Fragment"],"sources":["../../src/client/commandSend.ts","../../src/client/commandAvailability.ts","../../src/shared/commandInput.ts","../../src/client/copy/forms/components/CommandFields.ts","../../src/client/components/CommandFields.tsx"],"sourcesContent":["/**\n * A record's command sent without its form, as the form's submit would send it: prepared for the record's revision,\n * started, and sent once. The prepare may already have been asked (`readyCommand`), when the pointer or focus came to\n * the button, so a click sends only the execute. Two callers, one path: a component's `run` (components/sdk/commands.tsx) and an action\n * whose command asks nothing, which runs on one click (components/Actions.tsx). What happens after —\n * a notice, the form opened over an answer that never arrived — is the caller's.\n */\nimport type { AppCommandAction } from '../shared/app.js';\nimport { api } from '@mistriwork/kit/client/core.js';\nimport { ownedBy } from '@mistriwork/kit/client/requestIdentity.js';\nimport { commandOperations, type CommandOperation, type CommandOwner } from './commandState.js';\nimport { message as say } from '@mistriwork/kit/client/messages.js';\n\ntype CommandSent = { operation: CommandOperation } | { refused: string };\n\n/* A revision asked ahead of the click is used for a short while. One the record has moved past is refused by the\n execute as `stale_record`, before any handler runs, and the click then prepares and sends once more, as it would\n have from the start; so a stale one costs a round trip, never a wrong write. */\nconst READY_MS = 10_000;\nconst ready = new Map<string, { at: number; version: Promise<number> }>();\nconst readyKey = (owner: CommandOwner) => JSON.stringify([owner.connection, owner.command, owner.commandVersion, owner.key]);\n\nasync function prepare(owner: CommandOwner): Promise<number> {\n const prepared = await api('/api/commands/prepare', {\n ...ownedBy(owner.connection),\n command: owner.command,\n commandVersion: owner.commandVersion,\n key: owner.key,\n });\n if (!Number.isSafeInteger(prepared?.expectedVersion) || prepared.expectedVersion < 0)\n throw new Error(say('common.theRecordVersionIsUnavailable'));\n return prepared.expectedVersion as number;\n}\n\n/**\n * Ask the record's revision for a command that runs on one click, before the click: the pointer coming to its button,\n * or focus. Asked once while it is fresh; the click's `sendCommand` takes it, or the request still on its way.\n */\nexport function readyCommand(owner: CommandOwner): void {\n const key = readyKey(owner);\n const kept = ready.get(key);\n if (kept && Date.now() - kept.at < READY_MS) return;\n const version = prepare(owner);\n version.catch(() => {\n if (ready.get(key)?.version === version) ready.delete(key);\n });\n ready.set(key, { at: Date.now(), version });\n}\n\nexport async function sendCommand(\n action: AppCommandAction,\n owner: CommandOwner,\n input: Record<string, unknown>,\n options: { headless: boolean; current?: () => boolean; refresh: () => void },\n): Promise<CommandSent> {\n const key = readyKey(owner);\n const kept = ready.get(key);\n ready.delete(key);\n const early = kept && Date.now() - kept.at < READY_MS ? kept.version : undefined;\n let expectedVersion: number;\n try {\n // One asked ahead that failed is asked again here, so its refusal is this click's own.\n expectedVersion = early ? await early.catch(() => prepare(owner)) : await prepare(owner);\n } catch (error) {\n return { refused: (error as Error).message };\n }\n const sent = await execute(action, owner, input, expectedVersion, options);\n if (early && 'operation' in sent && sent.operation.phase === 'error' && sent.operation.code === 'stale_record') {\n commandOperations.forget(owner);\n return sendCommand(action, owner, input, options);\n }\n // A command that ran moved its record, so no revision asked ahead still holds.\n if ('operation' in sent && sent.operation.phase === 'success') ready.clear();\n return sent;\n}\n\nasync function execute(\n action: AppCommandAction,\n owner: CommandOwner,\n input: Record<string, unknown>,\n expectedVersion: number,\n { headless, current = () => true, refresh }: { headless: boolean; current?: () => boolean; refresh: () => void },\n): Promise<CommandSent> {\n let operation: CommandOperation;\n try {\n operation = commandOperations.start(owner, expectedVersion, input, action, headless);\n } catch (error) {\n return { refused: (error as Error).message };\n }\n await commandOperations.send(\n operation,\n 'execute',\n (path, envelope) => {\n if (path !== '/api/commands/execute' && path !== '/api/commands/status') throw new Error(say('common.invalidCommandPath'));\n if (!current()) throw Object.assign(new Error(say('common.thisCommandFormIsNoLonger')), { outcome: 'not_applied' });\n return api(path, { ...envelope, ...ownedBy(owner.connection) });\n },\n refresh,\n );\n return { operation };\n}\n","/** Batched, surface-owned command visibility; never execution authority. */\nimport { useEffect, useId, useMemo, useSyncExternalStore } from 'react';\nimport { useQueries, useQueryClient } from '@tanstack/react-query';\nimport { api, state } from '@mistriwork/kit/client/core.js';\nimport { appRequestScope, ownedBy } from '@mistriwork/kit/client/requestIdentity.js';\nimport { recordKey } from '@mistriwork/kit/client/resourceRequests.js';\nimport { commandKeyText } from '../shared/command.js';\nimport { composeUnderway, composedCheck } from '@mistriwork/kit/client/composedReads.js';\nimport {\n captureTenantLease,\n sessionIdentity,\n subscribeSessionIdentity,\n subscribeTenantLease,\n tenantLeaseActive,\n} from '@mistriwork/kit/client/sessionIdentity.js';\n\ninterface Check {\n command: string;\n commandVersion: number;\n key: Record<string, unknown>;\n}\ntype Identity = ReturnType<typeof sessionIdentity>;\ninterface Pending {\n check: Check;\n identity: Identity;\n connection: string | null;\n scope: ReturnType<typeof appRequestScope>;\n lease: ReturnType<typeof captureTenantLease>;\n resolve: (value: boolean) => void;\n}\nlet pending: Pending[] = [];\nlet nextSurface = 0;\nconst current = (identity: Identity, connection: string | null) =>\n identity === sessionIdentity() &&\n identity.mode === 'authenticated' &&\n identity.appId === connection &&\n (state.activeConnection ?? null) === connection &&\n (!identity.tenantRequired || tenantLeaseActive(identity));\nconst pendingCurrent = (item: Pending) =>\n current(item.identity, item.connection) && item.scope === appRequestScope() && item.lease === captureTenantLease(item.identity);\n\n/** Fresh reads only: pending callers share one microtask batch, never a result cache. */\nexport function commandAvailable(check: Check): Promise<boolean> {\n const identity = sessionIdentity(),\n connection = state.activeConnection ?? null;\n if (!current(identity, connection)) return Promise.resolve(false);\n let captured: Check;\n try {\n captured = { command: check.command, commandVersion: check.commandVersion, key: recordKey(check.key) };\n } catch {\n return Promise.resolve(false);\n }\n /* A record page's compose asked its verbs already (composedReads.ts). One still on its way is waited for: a\n record refreshed after a command asks its verbs in the same moment it composes, and asked beside the compose\n they went out on their own (G173). */\n const underway = composeUnderway(connection);\n if (underway) return underway.then(() => commandAvailable(check));\n const composed = composedCheck(connection, captured.command, captured.commandVersion, captured.key);\n if (composed !== undefined) return Promise.resolve(composed);\n return new Promise((resolve) => {\n if (!pending.length) queueMicrotask(flush);\n pending.push({ check: captured, identity, connection, scope: appRequestScope(), lease: captureTenantLease(identity), resolve });\n });\n}\n\nfunction flush() {\n const work = pending;\n pending = [];\n while (work.length) {\n const first = work.shift()!;\n if (!pendingCurrent(first)) {\n first.resolve(false);\n continue;\n }\n const batch = [first];\n for (let i = 0; i < work.length;) {\n if (\n work[i].identity === first.identity &&\n work[i].connection === first.connection &&\n work[i].scope === first.scope &&\n work[i].lease === first.lease\n )\n batch.push(...work.splice(i, 1));\n else i++;\n }\n while (batch.length) {\n const groups: Array<{ command: string; commandVersion: number; keys: Record<string, unknown>[]; callers: Pending[][] }> = [];\n let keys = 0;\n for (let i = 0; i < batch.length;) {\n const item = batch[i],\n existing = groups.find((group) => group.command === item.check.command);\n if ((existing && existing.commandVersion !== item.check.commandVersion) || (!existing && groups.length >= 16)) {\n i++;\n continue;\n }\n const index = existing?.keys.findIndex((key) => commandKeyText(key) === commandKeyText(item.check.key)) ?? -1;\n if (index < 0 && keys >= 200) {\n i++;\n continue;\n }\n const group = existing ?? { command: item.check.command, commandVersion: item.check.commandVersion, keys: [], callers: [] };\n if (!existing) groups.push(group);\n if (index >= 0) group.callers[index].push(item);\n else {\n group.keys.push(item.check.key);\n group.callers.push([item]);\n keys++;\n }\n batch.splice(i, 1);\n }\n const checks = groups.map(({ command, commandVersion, keys }) => ({ command, commandVersion, keys }));\n /** One request, and its answers only if the reply is exactly about it. */\n const ask = async (asked: typeof checks): Promise<boolean[][] | undefined> => {\n try {\n if (!pendingCurrent(first)) return undefined;\n const reply: unknown = await api('/api/commands/availability', { ...ownedBy(first.connection), checks: asked });\n if (\n !pendingCurrent(first) ||\n !reply ||\n typeof reply !== 'object' ||\n Array.isArray(reply) ||\n Object.keys(reply).length !== 1 ||\n !('checks' in reply) ||\n !Array.isArray(reply.checks) ||\n reply.checks.length !== asked.length\n )\n return undefined;\n const results = reply.checks;\n if (\n Array.from(results).some(\n (result, i) =>\n !result ||\n typeof result !== 'object' ||\n Array.isArray(result) ||\n Object.keys(result).sort().join(',') !== 'available,command,commandVersion' ||\n result.command !== asked[i].command ||\n result.commandVersion !== asked[i].commandVersion ||\n !Array.isArray(result.available) ||\n result.available.length !== asked[i].keys.length ||\n result.available.some((value: unknown) => typeof value !== 'boolean'),\n )\n )\n return undefined;\n return results.map((result) => result.available as boolean[]);\n } catch {\n return undefined; /* Visibility is false on any transport or protocol failure. */\n }\n };\n void (async () => {\n let available: boolean[][] | undefined;\n try {\n available = await ask(checks);\n /* One verb whose visibility cannot be answered must hide itself and\n nothing else. A refusal answers the whole request, so a record\n offering several commands lost its entire action bar to one of\n them — ask the rest again, a command at a time. Only after a\n failure, so an ordinary bar is still one request. */\n if (!available && checks.length > 1) {\n const answers = await Promise.all(checks.map(async (check) => ask([check])));\n available = answers.map((answer, i) => answer?.[0] ?? checks[i].keys.map(() => false));\n }\n } finally {\n groups.forEach((group, i) =>\n group.callers.forEach((callers, k) => callers.forEach((caller) => caller.resolve(available?.[i][k] === true))),\n );\n }\n })();\n }\n }\n}\n\n/** Hide while pending/refetching. Instance-owned queries retire with their\n * record surface; invalidating data after any write also invalidates visibility. */\nexport function useCommandAvailability(checks: Check[], enabled = true, surface?: object): boolean[] {\n return useCommandAnswers(checks, enabled, surface).available;\n}\n\n/** The same, and whether any is still being asked: a bar holds a verb's place until it knows. */\nexport function useCommandAnswers(checks: Check[], enabled = true, surface?: object): { available: boolean[]; asking: boolean } {\n const identity = useSyncExternalStore(subscribeSessionIdentity, sessionIdentity, sessionIdentity);\n const leaseSnapshot = () => {\n const lease = captureTenantLease(identity);\n return `${lease?.revision}:${lease?.expiresAt}:${!identity.tenantRequired || tenantLeaseActive(identity)}`;\n };\n useSyncExternalStore(subscribeTenantLease, leaseSnapshot, leaseSnapshot);\n const lease = captureTenantLease(identity);\n const client = useQueryClient(),\n instance = useId();\n const surfaceKey = useMemo(() => ++nextSurface, [surface]);\n useEffect(() => {\n if (!lease) return;\n const timer = setTimeout(\n () => {\n tenantLeaseActive(identity);\n },\n Math.max(0, lease.expiresAt - Date.now()),\n );\n return () => clearTimeout(timer);\n }, [identity, lease]);\n const checking = checks.length > 0;\n useEffect(() => {\n if (!checking) return;\n let mounted = true,\n queued = false;\n const unsubscribe = client.getQueryCache().subscribe((event) => {\n if (\n event.type !== 'updated' ||\n event.action.type !== 'invalidate' ||\n !['run', 'count', 'when'].includes(String(event.query.queryKey[0])) ||\n queued\n )\n return;\n queued = true;\n queueMicrotask(() => {\n queued = false;\n // A broad invalidation already marks these queries itself. Do not\n // cancel/restart its in-flight refetch in this coalesced follow-up.\n if (mounted) {\n const targets = new Set(\n client\n .getQueryCache()\n .findAll({ queryKey: ['command-availability', instance] })\n .filter((query) => !query.state.isInvalidated)\n .map((query) => query.queryHash),\n );\n void client.invalidateQueries({ predicate: (query) => targets.has(query.queryHash) });\n }\n });\n });\n return () => {\n mounted = false;\n unsubscribe();\n };\n }, [client, instance, checking]);\n const active = enabled && current(identity, state.activeConnection ?? null);\n const results = useQueries({\n queries: checks.map((check) => ({\n queryKey: [\n 'command-availability',\n instance,\n surfaceKey,\n identity.epoch,\n state.activeConnection,\n lease?.revision,\n active,\n check.command,\n check.commandVersion,\n check.key,\n ],\n queryFn: () => commandAvailable(check),\n enabled: active,\n retry: false,\n staleTime: 0,\n gcTime: 0,\n })),\n });\n return {\n available: results.map((result) => active && !result.isFetching && result.data === true),\n asking: active && results.some((result) => result.isFetching),\n };\n}\n","/**\n * A command's input, read against its declaration: the one parser the\n * server runs before a command's own `validate`, and the browser runs to\n * say which field needs attention before anything is sent. It is derived\n * from the field list alone — required, lengths, formats, patterns, case,\n * bounds, whole numbers and steps, dates and moments, a field below or above its\n * sibling, choices, nesting, repeat limits and reference shape — so a\n * command declares its input once, in a browser-safe module both sides import.\n *\n * What comes back is a fresh plain object in the declaration's order: text\n * trimmed and in its declared case, a number on its step, an optional field\n * left empty absent, every group present (an object, or its rows). A key the\n * declaration does not name is refused. A refusal names the field it is\n * about by path — `reason`, `applicant.email`, `vehicles[1].stock` — and\n * never echoes a value.\n */\nimport type { AppCommandField } from './command.js';\nimport { COMMAND_INPUT_LIMITS, fieldPattern, isIsoDate, isIsoMonth, isoInstant, maskPattern } from './command.js';\nimport { RICH_TEXT_MOST, richTextPlain } from '@mistriwork/engine/shared/richText.js';\nimport { DEFINED_KEY, DEFINITIONS_MOST } from '@mistriwork/engine/shared/definedFields.js';\n\nexport type CommandInputReason =\n | 'shape'\n | 'required'\n | 'type'\n | 'text'\n | 'too_short'\n | 'too_long'\n | 'format'\n | 'pattern'\n | 'below_min'\n | 'above_max'\n | 'integer'\n | 'precision'\n | 'not_below'\n | 'not_above'\n | 'choice'\n | 'too_few'\n | 'too_many'\n | 'exclusive';\n\n/** One problem: `path` is empty when it is the input's shape as a whole, such as a key nobody declared. */\ntype CommandInputProblem = { path: string; reason: CommandInputReason };\n\n/** The first problem, as the server's parser meets it. */\nexport class CommandInputRefusal extends Error {\n constructor(\n readonly path: string,\n readonly reason: CommandInputReason,\n ) {\n super('The command input is invalid.');\n this.name = 'CommandInputRefusal';\n }\n}\n\ninterface ReadOptions {\n /** A public form's submission: repeats are held to the public cap whatever the declaration says. */\n publicForm?: boolean;\n /** Starting values (`initial`): nothing is required and no repeat has a minimum; every value is still checked. */\n partial?: boolean;\n /**\n * The server's reading of a rich text value — Markdown or HTML in, sanitized\n * HTML out (server/richText.ts `readRichTextInput`), throwing a refusal with\n * a `reason`. The browser has none: it checks the shape and the size, and\n * the server's reading is the one that is kept.\n */\n richText?: (value: unknown, most: number) => string;\n /**\n * A line's cell read as its column's kind (`lineCell`), where the reader has\n * the catalog: the server where the command runs, the browser from the one it\n * is served. Without one a cell is judged by its shape alone.\n */\n cell?: (table: string, column: string, value: string | number | boolean) => { value: unknown } | CommandInputReason;\n /**\n * Whether a value is one of a table's rows, for a choice read from one (`field.choice({ from })`): the server's\n * reading against the rows the reader may read, the browser's against the options it was served. Without one a\n * value is judged by its shape alone, and the server judges it again.\n */\n sourced?: (field: { name: string; source: { from: string; by: string; labelColumn: string } }, value: string | number) => boolean;\n /**\n * The App's currency (`ui.currency`), which a `minor` money field without a `currency` of its own is typed in: the\n * server's from the App, the browser's from the one it was served. Without one a minor amount is judged by its shape\n * and bounds alone, as a line's cell is without a catalog.\n */\n currency?: string;\n /**\n * Keep a minor-unit amount as the major text a person types (\"19.99\"), validated and tidied, instead of reading it\n * as the minor units a handler receives. What the browser sends, what an API caller sends, and what a form is served\n * as its starting values; the server's own reading before a handler is the other one.\n */\n wire?: boolean;\n}\n\ninterface State extends ReadOptions {\n problems?: CommandInputProblem[];\n}\n\n// eslint-disable-next-line no-control-regex -- One line of text holds no control characters.\nconst CONTROL = /[\\x00-\\x1f\\x7f]/;\n// eslint-disable-next-line no-control-regex -- A textarea keeps tabs and line breaks, and nothing else below space.\nconst CONTROL_MULTILINE = /[\\x00-\\x08\\x0b\\x0c\\x0e-\\x1f\\x7f]/;\n\n/* The formats a text field may declare. Shape checks, not verification:\n nothing here sends mail, opens the address or dials the number. */\nconst EMAIL = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/;\nconst PHONE = /^\\+?[0-9 ().-]{7,32}$/;\nconst FORMATS: Record<'email' | 'url' | 'phone', (value: string) => boolean> = {\n email: (value) => EMAIL.test(value),\n url: (value) => {\n try {\n const url = new URL(value);\n return (url.protocol === 'https:' || url.protocol === 'http:') && !!url.hostname;\n } catch {\n return false;\n }\n },\n phone: (value) => PHONE.test(value) && value.replace(/\\D/g, '').length >= 7,\n};\n\n/** A number on its step: `0.01` keeps cents, and the rounding leaves no binary tail behind. */\nfunction onStep(value: number, step: number): number {\n const text = String(step);\n const places = text.includes('e-') ? Number(text.split('e-')[1]) : (text.split('.')[1]?.length ?? 0);\n return Number((Math.round(value / step) * step).toFixed(Math.min(places, 20)));\n}\n\nconst plain = (value: unknown): value is Record<string, unknown> =>\n !!value && typeof value === 'object' && !Array.isArray(value) && [null, Object.prototype].includes(Object.getPrototypeOf(value));\nconst at = (within: string, name: string): string => (within ? `${within}.${name}` : name);\n\nfunction refuse(state: State, path: string, reason: CommandInputReason): void {\n if (!state.problems) throw new CommandInputRefusal(path, reason);\n state.problems.push({ path, reason });\n}\n\n/** The decimals a currency is written with (Intl's, 2 when it does not know the code); money.ts's, kept out of the first paint. */\nconst currencyPlaces = (currency: string): number => {\n try {\n return new Intl.NumberFormat('en', { style: 'currency', currency }).resolvedOptions().maximumFractionDigits ?? 2;\n } catch {\n return 2;\n }\n};\n\n/* An amount typed in major units and kept in minor ones, text to text: 19.99 USD is 1999, 1500 JPY is 1500, and a fraction\n finer than the currency has is refused, not rounded. Past 2^53 the whole number is a string, as an id is. */\nfunction readMinorMoney(\n field: Extract<AppCommandField, { type: 'money' }>,\n value: unknown,\n state: State,\n problem: (reason: CommandInputReason) => { value?: unknown },\n): { value?: unknown } {\n const m = /^(-?)(\\d*)\\.?(\\d*)$/.exec(\n typeof value === 'string' || typeof value === 'number' ? String(value).trim().replace(/^\\+/, '') : '',\n );\n if (!m || !(m[2] || m[3])) return problem('type');\n // A reading that is to hand a handler minor units always knows the currency: the App's, else dollars.\n const currency = field.currency ?? state.currency ?? (state.wire ? undefined : 'USD');\n const fraction = m[3].replace(/0+$/, '');\n const digits = currency === undefined ? fraction.length : currencyPlaces(currency);\n if (fraction.length > digits) return problem('precision');\n const whole = m[2].replace(/^0+/, '') || '0';\n const tidy = `${m[1] && (+whole || fraction) ? '-' : ''}${whole}${digits ? `.${fraction.padEnd(digits, '0')}` : ''}`;\n if (field.min !== undefined && +tidy < field.min) return problem('below_min');\n if (field.max !== undefined && +tidy > field.max) return problem('above_max');\n if (state.wire || currency === undefined) return { value: tidy };\n const minor = tidy.replace('.', '');\n return { value: Number.isSafeInteger(+minor) ? +minor : minor };\n}\n\nfunction readValue(\n field: Exclude<AppCommandField, { type: 'group' | 'lines' }>,\n value: unknown,\n path: string,\n state: State,\n): { value?: unknown } {\n const blank =\n value === undefined || value === null || value === '' || (typeof value === 'string' && field.type !== 'choice' && !value.trim());\n /* Questions defined in rows always arrive as an object, answered or not: the rows say which answers are required. */\n if (blank && field.type === 'defined') return state.partial ? {} : { value: {} };\n if (blank) {\n /* A field asked only where its `when` holds is required there: the server judges it against the record. */\n if (field.required && !state.partial && field.when === undefined) refuse(state, path, 'required');\n return {};\n }\n const problem = (reason: CommandInputReason) => {\n refuse(state, path, reason);\n return {};\n };\n switch (field.type) {\n case 'text':\n case 'textarea': {\n if (typeof value !== 'string') return problem('type');\n const trimmed = value.trim();\n // A masked value is what its places hold (`123456789`), and the mask is its pattern.\n if (field.type === 'text' && field.mask !== undefined) {\n if (CONTROL.test(trimmed)) return problem('text');\n return fieldPattern(maskPattern(field.mask)).test(trimmed) ? { value: trimmed } : problem('pattern');\n }\n const cased = field.case === 'upper' ? trimmed.toUpperCase() : field.case === 'lower' ? trimmed.toLowerCase() : trimmed;\n if ((field.type === 'text' ? CONTROL : CONTROL_MULTILINE).test(cased)) return problem('text');\n if (field.minLength !== undefined && cased.length < field.minLength) return problem('too_short');\n if (field.maxLength !== undefined && cased.length > field.maxLength) return problem('too_long');\n if (field.format !== undefined && !FORMATS[field.format](cased)) return problem('format');\n if (field.pattern !== undefined && !fieldPattern(field.pattern).test(cased)) return problem('pattern');\n return { value: cased };\n }\n case 'number':\n case 'money': {\n if (field.type === 'money' && field.minor === true) return readMinorMoney(field, value, state, problem);\n if (typeof value !== 'number' || !Number.isFinite(value)) return problem('type');\n if (field.type === 'number' && field.integer && !Number.isSafeInteger(value)) return problem('integer');\n const stepped = field.step === undefined ? value : onStep(value, field.step);\n if (field.min !== undefined && stepped < field.min) return problem('below_min');\n if (field.max !== undefined && stepped > field.max) return problem('above_max');\n return { value: stepped };\n }\n case 'boolean':\n if (typeof value !== 'boolean') return problem('type');\n // A box that must be checked, unchecked, is a required answer not given.\n return field.accept && !value && !state.partial && field.when === undefined ? problem('required') : { value };\n case 'date': {\n if (!isIsoDate(value)) return problem('type');\n if (field.min !== undefined && value < field.min) return problem('below_min');\n if (field.max !== undefined && value > field.max) return problem('above_max');\n return { value };\n }\n case 'month': {\n if (!isIsoMonth(value)) return problem('type');\n if (field.min !== undefined && value < field.min) return problem('below_min');\n if (field.max !== undefined && value > field.max) return problem('above_max');\n return { value };\n }\n case 'datetime': {\n // One spelling, the UTC instant, so bounds and siblings compare as text and the handler reads one form.\n const at = isoInstant(value);\n if (at === undefined) return problem('type');\n if (field.min !== undefined && at < field.min) return problem('below_min');\n if (field.max !== undefined && at > field.max) return problem('above_max');\n return { value: at };\n }\n case 'choice':\n if (field.source)\n return sourced(field as typeof field & { source: NonNullable<typeof field.source> }, value, state) ? { value } : problem('choice');\n return field.options.some((option) => option.value === value) ? { value } : problem('choice');\n case 'choices': {\n if (!Array.isArray(value) || Object.getPrototypeOf(value) !== Array.prototype) return problem('type');\n if (value.length > COMMAND_INPUT_LIMITS.choiceOptions) return problem('too_many');\n const picked: (string | number)[] = [];\n for (const item of value) {\n const known = field.source\n ? sourced(field as typeof field & { source: NonNullable<typeof field.source> }, item, state)\n : field.options.some((option) => option.value === item);\n if (!known) return problem('choice');\n if (!picked.includes(item as string | number)) picked.push(item as string | number);\n }\n // None chosen is no answer: the field's required, or its min, says whether that is enough.\n if (!picked.length) {\n if (field.required && !state.partial && field.when === undefined) refuse(state, path, 'required');\n return {};\n }\n if (field.exclusive?.some((alone) => picked.includes(alone)) && picked.length > 1) return problem('exclusive');\n if (!state.partial && field.min !== undefined && picked.length < field.min) return problem('too_few');\n if (field.max !== undefined && picked.length > field.max) return problem('too_many');\n return { value: picked };\n }\n case 'richText': {\n const said =\n typeof value === 'string'\n ? value\n : plain(value) &&\n Object.keys(value).length === 2 &&\n (value.format === 'markdown' || value.format === 'html') &&\n typeof value.text === 'string'\n ? value.text\n : undefined;\n if (said === undefined) return problem('type');\n const most = field.maxLength ?? RICH_TEXT_MOST;\n let html = said;\n if (state.richText) {\n try {\n html = state.richText(value, most);\n } catch (error) {\n return problem((error as { reason?: unknown }).reason === 'too_long' ? 'too_long' : 'type');\n }\n }\n // A value with no words and no picture — an empty paragraph the editor leaves — is no answer.\n if (!richTextPlain(html) && !/<img\\b/i.test(html)) {\n if (field.required && !state.partial && field.when === undefined) refuse(state, path, 'required');\n return {};\n }\n /* Unread, the text is judged as the reader judges what arrives (four times the kept size): what is kept is only known once it is cleaned. */\n if (html.length > (state.richText ? most : most * 4)) return problem('too_long');\n if (field.minLength !== undefined && richTextPlain(html).trim().length < field.minLength) return problem('too_short');\n return { value: html };\n }\n case 'reference': {\n if (typeof value === 'number') return Number.isSafeInteger(value) ? { value } : problem('type');\n if (typeof value !== 'string' || value.trim().length > 256) return problem('type');\n return { value: value.trim() };\n }\n /* Answers keyed by the questions' keys: only their shape is the declaration's. Which questions there are, and\n what each one takes, are rows, judged where the command runs (businessCommandExecution.ts); an answer left\n empty is left out. */\n case 'defined': {\n if (!plain(value)) return problem('type');\n const answers: Record<string, unknown> = {};\n const entries = Object.entries(value);\n if (entries.length > DEFINITIONS_MOST) return problem('too_many');\n for (const [key, answer] of entries) {\n if (!DEFINED_KEY.test(key)) return problem('shape');\n if (answer === null || answer === undefined || (typeof answer === 'string' && !answer.trim())) continue;\n const fits =\n (typeof answer === 'string' && answer.length <= 10000) ||\n (typeof answer === 'number' && Number.isFinite(answer)) ||\n typeof answer === 'boolean' ||\n (Array.isArray(answer) && answer.length <= 100 && answer.every((item) => typeof item === 'string' && item.length <= 1000));\n if (!fits) return problem('type');\n if (Array.isArray(answer) && !answer.length) continue;\n answers[key] = Array.isArray(answer) ? [...answer] : answer;\n }\n return { value: answers };\n }\n }\n}\n\n/* A table's row, by key: a key's shape here, and its row the reader's `sourced` judgement where there is one. */\nfunction sourced(\n field: { name: string; source: { from: string; by: string; labelColumn: string } },\n value: unknown,\n state: State,\n): boolean {\n const shaped =\n (typeof value === 'string' && value.trim() !== '' && value.length <= 256) || (typeof value === 'number' && Number.isSafeInteger(value));\n return shaped && (state.sourced ? state.sourced(field, value as string | number) : true);\n}\n\nfunction readList(fields: readonly AppCommandField[], raw: unknown, within: string, state: State): Record<string, unknown> {\n const result: Record<string, unknown> = {};\n const given = raw === undefined || raw === null ? {} : raw;\n if (!plain(given)) {\n refuse(state, within, 'shape');\n return result;\n }\n const known = new Set(fields.map((field) => field.name));\n // A key nobody declared is named by no path: what arrived is not echoed back.\n if (Object.keys(given).some((key) => !known.has(key))) refuse(state, '', 'shape');\n for (const field of fields) {\n const path = at(within, field.name);\n const value = Object.hasOwn(given, field.name) ? given[field.name] : undefined;\n if (field.type === 'lines') {\n if (state.partial && value === undefined) continue;\n result[field.name] = readLines(field, value, path, state);\n continue;\n }\n if (field.type !== 'group') {\n const read = readValue(field, value, path, state);\n if ('value' in read) result[field.name] = read.value;\n continue;\n }\n if (state.partial && value === undefined) continue;\n if (!field.repeat) {\n result[field.name] = readList(field.fields, value, path, state);\n continue;\n }\n const rows = value === undefined || value === null ? [] : value;\n if (!Array.isArray(rows)) {\n refuse(state, path, 'shape');\n continue;\n }\n const max = state.publicForm ? Math.min(field.repeat.max, COMMAND_INPUT_LIMITS.publicRepeatRows) : field.repeat.max;\n if (rows.length > max) {\n refuse(state, path, 'too_many');\n continue;\n }\n if (!state.partial && rows.length < (field.repeat.min ?? 0)) refuse(state, path, 'too_few');\n result[field.name] = rows.map((row, index) => readList(field.fields, row, `${path}[${index}]`, state));\n }\n // A field below or above its sibling: judged on the values as read, only when both were given.\n for (const field of fields) {\n if (\n (field.type !== 'number' && field.type !== 'money' && field.type !== 'date' && field.type !== 'month' && field.type !== 'datetime') ||\n !Object.hasOwn(result, field.name)\n )\n continue;\n // A minor-unit amount may be text (major in a wire reading, a string past 2^53): compared as the number it is.\n const compared = (name: string) => (field.type === 'money' ? Number(result[name]) : (result[name] as number | string));\n const mine = compared(field.name);\n if (field.below !== undefined && Object.hasOwn(result, field.below) && !(mine < compared(field.below))) {\n refuse(state, at(within, field.name), 'not_below');\n }\n if (field.above !== undefined && Object.hasOwn(result, field.above) && !(mine > compared(field.above))) {\n refuse(state, at(within, field.name), 'not_above');\n }\n }\n return result;\n}\n\n/* A record's lines (`field.lines`): one to `max` rows, each the columns the field shows and no other, every one given. */\nfunction readLines(field: Extract<AppCommandField, { type: 'lines' }>, raw: unknown, path: string, state: State): unknown[] {\n const rows = raw === undefined || raw === null ? [] : raw;\n if (!Array.isArray(rows)) {\n refuse(state, path, 'shape');\n return [];\n }\n if (rows.length > field.max) {\n refuse(state, path, 'too_many');\n return [];\n }\n if (!state.partial && rows.length < (field.min ?? 0)) refuse(state, path, 'too_few');\n return rows.map((row, index) => {\n const at = `${path}[${index}]`;\n const line: Record<string, unknown> = {};\n if (!plain(row) || Object.keys(row).some((key) => !field.show.includes(key))) {\n refuse(state, at, 'shape');\n return line;\n }\n for (const column of field.show) {\n const value = row[column];\n const cell = `${at}.${column}`;\n if (value === undefined || value === null || (typeof value === 'string' && !value.trim())) {\n if (!state.partial) refuse(state, cell, 'required');\n continue;\n }\n if (\n !(typeof value === 'string' && value.length <= 10_000 && !CONTROL.test(value)) &&\n !(typeof value === 'number' && Number.isFinite(value)) &&\n typeof value !== 'boolean'\n ) {\n refuse(state, cell, 'type');\n continue;\n }\n const read = state.cell ? state.cell(field.from, column, value) : { value: typeof value === 'string' ? value.trim() : value };\n if (typeof read === 'string') refuse(state, cell, read);\n else line[column] = read.value;\n }\n return line;\n });\n}\n\n/** The server's reading: the parsed input, or a CommandInputRefusal naming the first problem. */\nexport function readCommandInput(fields: readonly AppCommandField[], raw: unknown, options: ReadOptions = {}): Record<string, unknown> {\n if (!plain(raw)) throw new CommandInputRefusal('', 'shape');\n return readList(fields, raw, '', { ...options });\n}\n\n/** Every problem at once, for a form that marks each field that needs attention. */\nexport function commandInputProblems(\n fields: readonly AppCommandField[],\n raw: unknown,\n options: Pick<ReadOptions, 'cell' | 'sourced' | 'currency' | 'wire'> = {},\n): Array<{ path: string; reason: CommandInputReason }> {\n const state: State = { ...options, problems: [] };\n if (!plain(raw)) return [{ path: '', reason: 'shape' }];\n readList(fields, raw, '', state);\n return state.problems!;\n}\n\n/** The declared field a path names, with the rows it sits in read through: `vehicles[1].stock` is `vehicles` → `stock`. */\nexport function commandFieldAt(fields: readonly AppCommandField[], path: string): AppCommandField | undefined {\n let list: readonly AppCommandField[] = fields;\n let found: AppCommandField | undefined;\n for (const part of path.split('.')) {\n const name = part.replace(/\\[\\d+\\]$/, '');\n found = list.find((field) => field.name === name);\n if (!found) return undefined;\n list = found.type === 'group' ? found.fields : [];\n }\n return found;\n}\n","/** What CommandFields says, in the forms room (packages/kit/src/client/messages.ts says how the catalog is split). */\nimport { defineMessages } from '@mistriwork/kit/client/messages.js';\n\nexport const say = defineMessages({\n addRow: 'Add row',\n anEmailAddress: 'an email address',\n aWebAddressStarting: 'a web address, starting https://',\n aPhoneNumber: 'a phone number',\n theFormHasAnInput: 'The form has an input it does not ask for.',\n isRequired: '{label} is required.',\n requiredWord: '(required)',\n optionalWord: '(optional)',\n checkThisBoxTo: 'Check this box to continue.',\n mustBeAtLeast: '{label} must be at least {minLength} characters.',\n mustBeCharactersOrFewer: '{label} must be {maxLength} characters or fewer.',\n must: '{label} must be {value}.',\n isNotInTheForm: '{label} is not in the form it takes.',\n mustBeBefore: '{label} must be before {other}.',\n mustBeLessThan: '{label} must be less than {other}.',\n mustBeAfter: '{label} must be after {other}.',\n mustBeMoreThan: '{label} must be more than {other}.',\n hasCharactersAForm: '{label} has characters a form does not take.',\n mustBeASafe: '{label} must be a safe whole number.',\n hasMoreDecimalsThanTheCurrency: '{label} has more decimal places than the currency takes.',\n mustBeOnOrAfter: '{label} must be on or after {min}.',\n labelMustBeAt: '{label} must be at least {min}.',\n mustBeOnOrBefore: '{label} must be on or before {max}.',\n mustBeAtMost: '{label} must be at most {max}.',\n chooseLabel: 'Choose {label}.',\n takesAtMostRows: '{label} takes at most {max} rows.',\n mustBeANumber: '{label} must be a number.',\n mustBeYes: '{label} must be yes or no.',\n mustBeADate: '{label} must be a date.',\n mustBeADateAndTime: '{label} must be a date and time.',\n isNotInAForm: '{label} is not in a form it takes.',\n choosePlaceholder: 'Choose {label}',\n chooseOne: 'Choose one',\n groupRow: '{label}, row {index}',\n rowLabel: 'Row',\n removeRow: 'Remove row {index} of {label}',\n addRowTo: 'Add row to {label}',\n needsAtLeastRows: { one: '{label} needs at least {count} row.', other: '{label} needs at least {count} rows.' },\n rowMatch: 'row {match}',\n inTheFormItTakes: 'in the form it takes',\n chooseAlone: 'Choose {label} on its own, or another.',\n});\n","/**\n * A command's inputs, drawn: the controls the command modal and a command\n * form share. The declaration they draw is the one the server parses by —\n * one field list, in a browser-safe module — so what this checks before\n * anything is sent (`commandInput`, `commandProblems`, through the shared\n * reader) is what the server would refuse, in the person's words.\n *\n * A group is a section, headed by its label; a repeating group is its rows,\n * each added and removed here between the declared minimum and maximum; a\n * choice is radios when it has a few options and the tool's listbox when it\n * has more; a date is the date input the record editor uses, and a date\n * and time the same input with its clock, read in the App's time zone.\n * Questions defined in rows (`field.defined`) are a section of one control\n * per question, as prepare read them. A record's lines (`field.lines`) are the\n * lines grid (CommandLines.tsx), each cell read as its column's kind.\n */\nimport { Fragment, useRef, useState, type ReactElement } from 'react';\nimport type { AppCommandField } from '../../shared/command.js';\nimport type { DraftRule } from '../../shared/commandDraft.js';\nimport {\n CommandInputRefusal,\n commandFieldAt,\n commandInputProblems,\n readCommandInput,\n type CommandInputReason,\n} from '../../shared/commandInput.js';\nimport { toast } from '@mistriwork/kit/client/core.js';\nimport type { LineDraft } from './FormLines.js';\nimport { RichTextField, mentionSearch, pictureKeeper } from '@mistriwork/kit/client/components/RichTextField.js';\nimport type { CommandValue } from '../commandState.js';\nimport { Dropdown, readsAsName } from '@mistriwork/kit/client/components/Dropdown.js';\nimport { DateField } from '@mistriwork/kit/client/components/DateField.js';\nimport { defaultCurrency, formatLocale, formatTimezone } from '@mistriwork/kit/client/locale.js';\nimport { onDemand, useArrived } from '@mistriwork/kit/client/components/onDemand.js';\nimport { Button } from '@mistriwork/ui/Button.js';\nimport { Field } from '@mistriwork/ui/Field.js';\nimport { InputSlot } from '@mistriwork/kit/client/components/inputRenderers.js';\nimport { say } from '../copy/forms/components/CommandFields.js';\nimport type { DefinedField } from '@mistriwork/engine/shared/definedFields.js';\n\n/** A form's values while it is filled in: one per field, an object per group, rows per repeating group, a grid's lines. */\nexport type CommandValues = { [name: string]: CommandValue | CommandValues | CommandValues[] | LineDraft[] | undefined };\n\nexport type ValueField = Exclude<AppCommandField, { type: 'group' | 'lines' }>;\ntype GroupField = Extract<AppCommandField, { type: 'group' }>;\nexport type ReferenceField = Extract<AppCommandField, { type: 'reference' }>;\n\n/** Each `field.defined` input's questions, by input name, as prepare read them. */\nexport type CommandQuestions = Readonly<Record<string, readonly DefinedField[]>>;\n\n/* A date and a time: its zone arithmetic is fetched the first time one is drawn, never by a public form's first page. */\nconst DateTimeInput = onDemand(() => import('./DateTimeInput.js'), 'DateTimeInput', { quiet: true });\n/* The newer vocabulary — money, a month, a mask, a sensitive number, cards, buttons, several choices, a slider, a\n consent's statement — with the form controls' stylesheet: fetched the first time a form asks one. */\nconst IntakeControl = onDemand(() => import('./IntakeControls.js'), 'IntakeControl', { quiet: true });\nexport const CommandLive = onDemand(() => import('./CommandLive.js'), 'CommandLive', { quiet: true });\n/* The draft's logic — a `when` over the answers so far and the command's `rules`, judged by the condition compiler\n and the query language's comparisons (commandDraft.ts, formValues.ts) — fetched the first time a form asks it, so\n a public page whose form asks none (the landing, sign-in, a one-page form) carries none of it. A host that knows\n its form asks it has it here before drawing (FormSurface's formArrives, CommandForm's prepare); CommandFields\n draws nothing until it is, rather than questions that would vanish as it lands. Before it is here, nothing is\n hidden and no rule is said, which the server judges again in any case. */\nlet drafting: typeof import('../../shared/commandDraft.js') | undefined;\nlet draftArriving: Promise<void> | undefined;\nconst loadDraftLogic = (): Promise<void> =>\n (draftArriving ??= import('../../shared/commandDraft.js').then(\n (module) => {\n drafting = module;\n },\n (error: unknown) => {\n draftArriving = undefined;\n throw error;\n },\n ));\nexport const draftLogic = {\n ready: () => loadDraftLogic().catch(() => {}),\n here: () => drafting !== undefined,\n};\n/** Whether a form's fields — or the command's rules — ask the draft's logic: a `when` anywhere, or a rule. */\nexport function asksDraftLogic(fields: readonly AppCommandField[], rules?: readonly unknown[]): boolean {\n if (rules?.length) return true;\n return fields.some((field) => whenOf(field) !== undefined || (field.type === 'group' && asksDraftLogic(field.fields)));\n}\n/** Whether a condition reads the record (`record.<column>`): exact once the logic is here, a plain reading before. */\nexport const readsRecord = (when: string): boolean => (drafting ? drafting.readsRecord(when) : /\\brecord\\./.test(when));\n/* A record's lines: the grid, with the catalog's cells and the words for a cell, fetched the first time a form asks\n lines. A public form cannot ask them, so its first page carries none of it. The cells are judged here by kind once it\n has arrived, which it has by the time a grid is drawn; before then, and in any case, the server reads them again. */\nlet lining: typeof import('./CommandLines.js') | undefined;\n/** The lines module, fetched once: the grid is drawn from it, and a form's checks read a line's cells with it. */\nexport const loadLines = () =>\n import('./CommandLines.js').then((module) => {\n lining = module;\n return module;\n });\nconst CommandLines = onDemand(loadLines, 'CommandLines');\n\nconst asksLines = (fields: readonly AppCommandField[]): boolean =>\n fields.some((field) => field.type === 'lines' || (field.type === 'group' && asksLines(field.fields)));\n/**\n * What judging an input with no form drawn needs first: the draft's logic where a `when` or a rule asks it, and the\n * lines module where a field is a grid. A component's run judges an input before any form is drawn, and before these\n * have landed nothing is hidden: a question its condition hides was asked for, and its default sent (a field report).\n */\nexport function readyToJudge(fields: readonly AppCommandField[], rules?: readonly unknown[]): Promise<unknown> | undefined {\n const logic = asksDraftLogic(fields, rules) && !draftLogic.here();\n const lines = asksLines(fields) && !lining;\n // Nothing to wait for is no wait at all: a run that asks neither sends in the turn it was asked (its prepare first).\n if (!logic && !lines) return undefined;\n return Promise.all([logic ? draftLogic.ready() : undefined, lines ? loadLines().catch(() => {}) : undefined]);\n}\nconst lineAt = (fields: readonly AppCommandField[], path: string) => lining?.lineAt(fields, path);\n/* A typed amount is judged in the App's currency (a field's own `currency` first) and kept as typed, in its major units:\n the server reads it into the minor ones a handler receives. */\nconst cellReading = () => ({ currency: defaultCurrency(), wire: true, ...(lining ? { cell: lining.lineCellOf } : {}) });\n\n/* A grid line's own name, kept across moves (FormLines' blankLine, without loading the grid to make one). */\nlet lastLine = 0;\nconst draftLine = (values: Record<string, string> = {}): LineDraft => ({ id: -++lastLine, values });\nconst isLines = (value: unknown): value is LineDraft[] =>\n Array.isArray(value) && value.every((row) => !!row && typeof row === 'object' && 'values' in row && 'id' in row);\n\n/* A reference's picker (CommandReference.tsx) is drawn where there is somewhere to read its choices: a signed-in\n reader's connection, or a public form's App read signed out. Loaded when drawn, so a public form without one carries\n neither it nor the combobox. */\nconst CommandReferenceField = onDemand(() => import('./CommandReference.js'), 'CommandReferenceField', { quiet: true });\n\n/* Questions defined in rows, drawn and judged (CommandAnswers.tsx): only a signed-in record's command asks them, so a\n first page carries none of it. The answers are judged here once it has arrived, which it has by the time they are\n drawn; the server judges them again in any case. */\nlet answering: typeof import('./CommandAnswers.js') | undefined;\nconst DefinedAnswers = onDemand(\n () =>\n import('./CommandAnswers.js').then((module) => {\n answering = module;\n return module;\n }),\n 'DefinedAnswers',\n { quiet: true },\n);\nconst answerProblems = (fields: readonly AppCommandField[], values: CommandValues, questions?: CommandQuestions): [string, string][] =>\n questions && answering ? answering.answerProblems(fields, values, questions) : [];\n\n/** A choice with this many options or fewer is radios, all of them in view; more is a listbox. */\nconst RADIO_CHOICES = 4;\n/** Whether a choice is radios: as many as RADIO_CHOICES unless the field says `as: 'radios'` or `as: 'select'`. */\nconst asRadios = (field: { options: readonly unknown[]; as?: string }) =>\n field.as === 'radios' || (field.as !== 'select' && field.options.length <= RADIO_CHOICES);\n\n/* Which fields IntakeControls draws: said here too, so knowing it never fetches the chunk (IntakeControls' drawnHere agrees). */\nfunction drawnByIntake(field: AppCommandField): boolean {\n switch (field.type) {\n case 'money':\n case 'month':\n case 'choices':\n return true;\n case 'number':\n return field.as === 'slider';\n case 'text':\n return field.mask !== undefined || field.sensitive !== undefined;\n case 'boolean':\n return field.as === 'buttons' || field.statement !== undefined;\n case 'choice':\n return field.as === 'cards' || field.as === 'buttons' || field.source !== undefined;\n default:\n return false;\n }\n}\n\n/* A yes-or-no drawn as a box: unticked is its no. One asked as two buttons is a question like any other, unanswered\n until pressed, so it is required unless optional and says \"(optional)\" when it is. */\nconst isCheck = (field: AppCommandField): field is Extract<AppCommandField, { type: 'boolean' }> =>\n field.type === 'boolean' && field.as !== 'buttons';\n\nconst isValues = (value: unknown): value is CommandValues => !!value && typeof value === 'object' && !Array.isArray(value);\n\n/** Where a form starts: yes/no unticked, each group its own values, each repeating group its minimum rows. */\nexport function blankCommandValues(fields: readonly AppCommandField[]): CommandValues {\n const values: CommandValues = {};\n for (const field of fields) {\n /* A field's own default, as the form opens: a literal, the day in the App's time zone, the minute. The record's\n value and the reader's arrive with prepare, as `initial()`'s do. */\n const start = field.type === 'group' ? undefined : field.default;\n if (start !== undefined && typeof start !== 'object') values[field.name] = start;\n else if (typeof start === 'object' && 'auto' in start && start.auto !== 'me')\n values[field.name] =\n start.auto === 'today'\n ? new Intl.DateTimeFormat('en-CA', { timeZone: formatTimezone() }).format(new Date())\n : new Date(Math.floor(Date.now() / 60_000) * 60_000).toISOString();\n // A box unticked is an answer, no; a yes or a no asked as two buttons is unanswered until one is pressed, so a\n // question that waits on its no (`when: 'entry_ok = false'`) waits for it, and a required one is asked.\n else if (field.type === 'boolean' && field.as !== 'buttons') values[field.name] = false;\n else if (field.type === 'lines') values[field.name] = Array.from({ length: Math.max(field.min ?? 0, 1) }, () => draftLine());\n else if (field.type === 'group') {\n values[field.name] = field.repeat\n ? Array.from({ length: field.repeat.min ?? 0 }, () => blankCommandValues(field.fields))\n : blankCommandValues(field.fields);\n }\n }\n return values;\n}\n\n/** The blank form with the starting values the server served laid over it, field by field. */\nexport function prefilledCommandValues(fields: readonly AppCommandField[], initial: unknown): CommandValues {\n const values = blankCommandValues(fields);\n if (!isValues(initial)) return values;\n for (const field of fields) {\n if (!Object.hasOwn(initial, field.name)) continue;\n const value = initial[field.name];\n if (field.type === 'defined') {\n if (isValues(value)) values[field.name] = { ...value };\n } else if (field.type === 'lines') {\n if (Array.isArray(value))\n values[field.name] = value.map((row) =>\n draftLine(\n Object.fromEntries(\n field.show.flatMap((column) => {\n const held = isValues(row) ? row[column] : undefined;\n return typeof held === 'string' || typeof held === 'number' || typeof held === 'boolean' ? [[column, String(held)]] : [];\n }),\n ),\n ),\n );\n } else if (field.type !== 'group') {\n if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') values[field.name] = value;\n } else if (field.repeat) {\n if (Array.isArray(value)) values[field.name] = value.map((row) => prefilledCommandValues(field.fields, row));\n } else values[field.name] = prefilledCommandValues(field.fields, value);\n }\n return values;\n}\n\n/** The whole form a list of fields belongs to — a step's fields judge their `when` against every answer so far. */\ninterface CommandDraft {\n fields: readonly AppCommandField[];\n values: CommandValues;\n}\n\n/* A field's condition, where its kind takes one (a grid's lines take none). */\nconst whenOf = (field: AppCommandField): string | undefined => ('when' in field ? (field.when as string | undefined) : undefined);\n\n/* A value as it is read, for a condition: a number typed as text is the number. */\nfunction readValue(field: AppCommandField, value: Entry): unknown {\n if ((field.type === 'number' || field.type === 'money') && typeof value === 'string') return value.trim() ? Number(value) : '';\n return value;\n}\n\n/**\n * The fields of a list a draft's conditions hide (`when: 'entry_ok = false'`): each judged by the shared evaluator\n * (commandDraft.ts) against the answers so far, of the whole form where one is given. A `when` that still reads the\n * record has not been bound by prepare, so it is the server's to judge, and the field stays.\n */\nexport function draftHidden(fields: readonly AppCommandField[], values: CommandValues, whole?: CommandDraft): Set<string> {\n const hidden = new Set<string>();\n if (!fields.some((field) => whenOf(field) !== undefined)) return hidden;\n const all = whole ?? { fields, values };\n const read: Record<string, unknown> = {};\n for (const field of all.fields) read[field.name] = readValue(field, all.values[field.name]);\n for (const field of fields) read[field.name] = readValue(field, values[field.name]);\n const known = [...all.fields, ...fields.filter((field) => !all.fields.includes(field))];\n for (const field of fields) {\n const when = whenOf(field);\n if (when === undefined || readsRecord(when)) continue;\n if (drafting && !drafting.draftHolds(when, read, known)) hidden.add(field.name);\n }\n return hidden;\n}\n\n/** What is sent: a number typed as text read as a number, and nothing the declaration does not ask, nor a question its condition hides. */\nfunction submitted(fields: readonly AppCommandField[], values: CommandValues, whole?: CommandDraft): Record<string, unknown> {\n const result: Record<string, unknown> = {};\n const hidden = draftHidden(fields, values, whole);\n for (const field of fields) {\n if (hidden.has(field.name)) continue;\n const value = values[field.name];\n if (field.type === 'lines') {\n // Only what a line asks is sent: a copied column is the form's to show, and the handler reads that record itself.\n result[field.name] = (isLines(value) ? value : []).map((row) =>\n Object.fromEntries(field.show.flatMap((column) => (row.values[column] ? [[column, row.values[column]]] : []))),\n );\n } else if (field.type === 'group') {\n result[field.name] = field.repeat\n ? (Array.isArray(value) ? value : []).map((row) => submitted(field.fields, isValues(row) ? row : {}))\n : submitted(field.fields, isValues(value) ? value : {});\n } else if ((field.type === 'number' || field.type === 'money') && typeof value === 'string' && !(field.type === 'money' && field.minor))\n result[field.name] = value.trim() ? Number(value) : '';\n else if (value !== undefined) result[field.name] = value;\n }\n return result;\n}\n\nconst FORMAT_SENTENCES = { email: say('anEmailAddress'), url: say('aWebAddressStarting'), phone: say('aPhoneNumber') } as const;\n\n/** A field's sentence for what is wrong with it: its own label, and the rule it did not meet; a sibling rule names the sibling. */\nfunction sentence(fields: readonly AppCommandField[], path: string, reason: CommandInputReason): string {\n const line = lineAt(fields, path);\n if (line) {\n const label = line.label;\n return reason === 'required'\n ? say('isRequired', { label })\n : reason === 'choice'\n ? say('chooseLabel', { label })\n : reason === 'type'\n ? say('isNotInAForm', { label })\n : say('theFormHasAnInput');\n }\n const field = commandFieldAt(fields, path);\n if (!field) return say('theFormHasAnInput');\n const label = field.label;\n const date = field.type === 'date' || field.type === 'datetime';\n // A moment's bound is said in the App's time zone, as the field asks for it.\n const bound = (at: string | undefined) =>\n at && field.type === 'datetime'\n ? new Date(at).toLocaleString(formatLocale(), { timeZone: formatTimezone(), dateStyle: 'medium', timeStyle: 'short' })\n : (at ?? '');\n const text = field.type === 'text' || field.type === 'textarea' ? field : undefined;\n const most = text?.maxLength ?? (field.type === 'richText' ? field.maxLength : undefined);\n const sibling = (name: string | undefined) => {\n const within = path.includes('.') ? path.slice(0, path.lastIndexOf('.') + 1) : '';\n return (name && commandFieldAt(fields, `${within}${name}`)?.label) ?? name ?? '';\n };\n switch (reason) {\n // A box that must be checked is said at the box, which the reader is looking at.\n case 'required':\n return isCheck(field) ? say('checkThisBoxTo') : say('isRequired', { label });\n case 'too_short':\n return say('mustBeAtLeast', { label, minLength: text?.minLength ?? (field.type === 'richText' ? field.minLength : undefined) ?? '' });\n case 'too_long':\n return say('mustBeCharactersOrFewer', { label, maxLength: most ?? '' });\n case 'format':\n return text?.message ?? say('must', { label, value: text?.format ? FORMAT_SENTENCES[text.format] : say('inTheFormItTakes') });\n case 'pattern':\n return text?.message ?? say('isNotInTheForm', { label });\n case 'not_below': {\n const other = sibling((field as { below?: string }).below);\n return date ? say('mustBeBefore', { label, other }) : say('mustBeLessThan', { label, other });\n }\n case 'not_above': {\n const other = sibling((field as { above?: string }).above);\n return date ? say('mustBeAfter', { label, other }) : say('mustBeMoreThan', { label, other });\n }\n case 'text':\n return say('hasCharactersAForm', { label });\n case 'integer':\n return say('mustBeASafe', { label });\n case 'precision':\n return say('hasMoreDecimalsThanTheCurrency', { label });\n case 'below_min':\n return date\n ? say('mustBeOnOrAfter', { label, min: bound((field as { min?: string }).min) })\n : say('labelMustBeAt', { label, min: (field as { min?: number }).min ?? '' });\n case 'above_max':\n return date\n ? say('mustBeOnOrBefore', { label, max: bound((field as { max?: string }).max) })\n : say('mustBeAtMost', { label, max: (field as { max?: number }).max ?? '' });\n case 'choice':\n return say('chooseLabel', { label });\n case 'too_few': {\n const min = field.type === 'group' ? (field.repeat?.min ?? 0) : field.type === 'lines' ? (field.min ?? 0) : 0;\n return say('needsAtLeastRows', { label, count: min });\n }\n case 'too_many':\n return say('takesAtMostRows', {\n label,\n max: (field.type === 'group' ? field.repeat?.max : field.type === 'lines' ? field.max : 0) ?? '',\n });\n case 'type':\n return field.type === 'number'\n ? say('mustBeANumber', { label })\n : field.type === 'boolean'\n ? say('mustBeYes', { label })\n : date\n ? say(field.type === 'datetime' ? 'mustBeADateAndTime' : 'mustBeADate', { label })\n : field.type === 'reference'\n ? say('chooseLabel', { label })\n : say('isNotInAForm', { label });\n case 'shape':\n return say('isNotInAForm', { label });\n case 'exclusive':\n return say('chooseAlone', { label });\n }\n}\n\n/**\n * The words for where a path is: `Phone`, or `Applicant, Email`, or\n * `Trade-ins, row 2, Stock`. Undefined for a path the declaration does not have.\n */\nexport function commandPathLabel(fields: readonly AppCommandField[], path: string): string | undefined {\n const words: string[] = [];\n let list: readonly AppCommandField[] = fields;\n for (const part of path.split('.')) {\n const match = /^([A-Za-z_][A-Za-z0-9_]*)(?:\\[(\\d+)\\])?$/.exec(part);\n const field = match && list.find((item) => item.name === match[1]);\n if (!field) return undefined;\n words.push(field.label);\n if (match[2] !== undefined) words.push(say('rowMatch', { match: Number(match[2]) + 1 }));\n if (field.type === 'lines') {\n // A line's cell is a column of its row: the rest of the path is the column, said by its caption.\n const line = lineAt(fields, path);\n if (line && match[2] !== undefined) words.push(line.label);\n return line || !path.includes('.') ? words.join(', ') : undefined;\n }\n list = field.type === 'group' ? field.fields : [];\n }\n return words.join(', ');\n}\n\n/** How a list of fields is judged beyond itself: the whole form its `when`s read, and the command's rules. */\ninterface CommandJudging {\n whole?: CommandDraft;\n /** The command's rules (`rules`); each is said at its field where that field is in the list judged. */\n rules?: readonly DraftRule[];\n}\n\n/* A question its condition shows is required there, as the server judges it (judgeDraft); then each rule the\n answers break, at its field. Both by path, in the reader's words. */\nfunction draftProblems(fields: readonly AppCommandField[], values: CommandValues, judging: CommandJudging): Array<[string, string]> {\n const found: Array<[string, string]> = [];\n const hidden = draftHidden(fields, values, judging.whole);\n for (const field of fields) {\n const when = whenOf(field);\n if (when === undefined || hidden.has(field.name) || readsRecord(when) || field.type === 'group' || field.type === 'lines') continue;\n const value = values[field.name];\n const empty = value === undefined || value === null || value === '' || (Array.isArray(value) && !value.length);\n if (isCheck(field) ? field.accept === true && value !== true : field.required && empty)\n found.push([field.name, sentence(fields, field.name, 'required')]);\n }\n if (judging.rules?.length && drafting) {\n const all = judging.whole ?? { fields, values };\n const read = { ...submitted(all.fields, all.values), ...submitted(fields, values, judging.whole) };\n const names = new Set(fields.map((field) => field.name));\n for (const broken of drafting.brokenRules(judging.rules, read, [...all.fields, ...fields.filter((f) => !all.fields.includes(f))]))\n if (names.has(broken.field)) found.push([broken.field, broken.message]);\n }\n return found;\n}\n\n/** Every problem, by path, in the person's words: what a form marks beside each field. */\nexport function commandProblems(\n fields: readonly AppCommandField[],\n values: CommandValues,\n questions?: CommandQuestions,\n judging: CommandJudging = {},\n): Record<string, string> {\n const problems: Record<string, string> = {};\n for (const problem of commandInputProblems(fields, submitted(fields, values, judging.whole), cellReading())) {\n if (!Object.hasOwn(problems, problem.path)) problems[problem.path] = sentence(fields, problem.path, problem.reason);\n }\n for (const [path, said] of answerProblems(fields, values, questions)) if (!Object.hasOwn(problems, path)) problems[path] = said;\n for (const [path, said] of draftProblems(fields, values, judging)) if (!Object.hasOwn(problems, path)) problems[path] = said;\n return problems;\n}\n\n/** The input to send, parsed as the server will parse it, or an Error saying the first thing that needs attention. */\nexport function commandInput(\n fields: readonly AppCommandField[],\n values: CommandValues,\n questions?: CommandQuestions,\n judging: CommandJudging = {},\n): Record<string, unknown> {\n let input: Record<string, unknown>;\n try {\n input = readCommandInput(fields, submitted(fields, values, judging.whole), cellReading());\n } catch (error) {\n if (!(error instanceof CommandInputRefusal)) throw error;\n const said = sentence(fields, error.path, error.reason);\n // A field inside a group says which section, and which row.\n const within = error.path.includes('.') ? commandPathLabel(fields, error.path.slice(0, error.path.lastIndexOf('.'))) : undefined;\n throw new Error(within ? `${within}: ${said}` : said);\n }\n const [unanswered] = answerProblems(fields, values, questions);\n if (unanswered) {\n const field = fields.find((candidate) => candidate.name === unanswered[0].slice(0, unanswered[0].indexOf('.')));\n throw new Error(field ? `${field.label}: ${unanswered[1]}` : unanswered[1]);\n }\n const [drafted] = draftProblems(fields, values, judging);\n if (drafted) throw new Error(drafted[1]);\n return input;\n}\n\n/**\n * One value input as a control: text, textarea, number, yes/no, date, date\n * and time, or choice. The command modal and a command form both draw\n * through this; a reference is the picker below instead, and only where\n * there is a connection to read its directory from.\n */\nexport function CommandFieldControl({\n field,\n id,\n describedBy,\n invalid,\n value,\n disabled,\n onChange,\n connection,\n visitor,\n record,\n valid,\n onLeave,\n}: {\n field: Exclude<ValueField, { type: 'reference' | 'defined' }>;\n /** The intake style's valid check on a text or number box: present, the box keeps room for the mark; true draws it. */\n valid?: boolean;\n /** Focus has left the control: where the valid check is kept, it is judged from then on. */\n onLeave?: () => void;\n /** A public form's App, read signed out: where a choice from a table reads its rows. */\n visitor?: CommandFieldsShared['visitor'];\n /** Where a rich text input reads its people and keeps its pictures. */\n connection?: string;\n record?: CommandFieldsShared['record'];\n id: string;\n describedBy?: string;\n /** A problem is said beside the field; the field says it holds one, so a reader landing on it hears which. */\n invalid?: boolean;\n value: CommandValue | undefined;\n disabled?: boolean;\n onChange: (value: CommandValue) => void;\n}) {\n const common = {\n id,\n 'aria-describedby': describedBy,\n 'aria-invalid': invalid || undefined,\n required: field.required,\n className: 'field-control',\n disabled,\n ...(onLeave ? { onBlur: onLeave } : {}),\n };\n /* The mark at a box's inline end, in room the box keeps from the start, so its arriving moves no text. Decorative:\n validity is aria-invalid's to say (TextField's ValidMark, drawn in CSS). */\n const marked = (box: ReactElement, leaves = false) =>\n valid === undefined ? (\n box\n ) : (\n // A control drawn on demand takes no onBlur of its own; the box hears its input leave (focusout bubbles).\n <div className=\"field-box has-mark\" {...(leaves && onLeave ? { onBlur: onLeave } : {})}>\n {box}\n {valid ? <span className=\"field-mark\" aria-hidden=\"true\" /> : null}\n </div>\n );\n if (drawnByIntake(field)) {\n return marked(\n <IntakeControl\n field={field}\n id={id}\n aria-describedby={describedBy}\n aria-invalid={invalid || undefined}\n value={value}\n disabled={disabled}\n onChange={onChange}\n {...(connection !== undefined ? { source: connection } : visitor ? { source: { visitor } } : {})}\n />,\n true,\n );\n }\n if (field.type === 'boolean') {\n return (\n <input\n {...common}\n required={field.accept === true}\n className=\"command-check\"\n type=\"checkbox\"\n checked={value === true}\n onChange={(event) => onChange(event.target.checked)}\n />\n );\n }\n /* Formatted text: the editor, fetched the first time one is drawn; the server sanitizes what it sends. */\n if (field.type === 'richText') {\n return (\n <RichTextField\n id={id}\n label={field.label}\n describedBy={describedBy}\n invalid={invalid}\n disabled={disabled}\n value={typeof value === 'string' ? value : ''}\n onChange={onChange}\n {...(field.mentions && connection !== undefined ? { mentions: mentionSearch(field.mentions, connection) } : {})}\n {...(field.images && connection !== undefined && record\n ? (() => {\n const keep = pictureKeeper(field.images, record, connection);\n return keep ? { pictures: keep, onProblem: (message: string) => toast(message, 'error') } : {};\n })()\n : {})}\n />\n );\n }\n if (field.type === 'textarea') {\n return (\n <textarea\n {...common}\n rows={3}\n maxLength={field.maxLength}\n value={String(value ?? '')}\n onChange={(event) => onChange(event.target.value)}\n />\n );\n }\n if (field.type === 'choice') {\n const chosen = field.options.findIndex((option) => option.value === value);\n if (asRadios(field)) {\n return (\n <div\n className=\"command-choices\"\n role=\"radiogroup\"\n id={id}\n aria-labelledby={`${id}-label`}\n aria-describedby={describedBy}\n aria-required={field.required || undefined}\n aria-invalid={invalid || undefined}\n >\n {field.options.map((option, index) => (\n <label className=\"command-choice\" key={`${typeof option.value}:${option.value}`}>\n <input type=\"radio\" name={id} checked={index === chosen} disabled={disabled} onChange={() => onChange(option.value)} />\n {option.label}\n </label>\n ))}\n </div>\n );\n }\n // The tool's listbox, by position: a value may be a number, and a listbox's values are text.\n return (\n <Dropdown\n /* Named by the field's caption, as a <label> names a textbox: the words a reader\n sees, \"(required)\" with them. An aria-label of the bare name dropped it. */\n id={id}\n ariaLabelledBy={`${id}-label`}\n ariaInvalid={invalid}\n ariaDescribedBy={describedBy}\n disabled={disabled}\n value={chosen < 0 ? '' : String(chosen)}\n valueClassName={chosen < 0 ? 'is-empty' : undefined}\n items={[\n ...(chosen < 0\n ? [\n {\n value: '',\n label: readsAsName(field.label) ? say('choosePlaceholder', { label: field.label.toLowerCase() }) : say('chooseOne'),\n },\n ]\n : []),\n ...field.options.map((option, index) => ({ value: String(index), label: option.label })),\n ]}\n onChange={(next) => {\n if (next !== '') onChange(field.options[Number(next)].value);\n }}\n />\n );\n }\n if (field.type === 'date') {\n return (\n <DateField\n {...common}\n aria-label={`${field.label}${field.required ? ' (required)' : ''}`}\n min={field.min}\n max={field.max}\n locale={formatLocale()}\n timezone={formatTimezone()}\n value={String(value ?? '')}\n onChange={onChange}\n />\n );\n }\n if (field.type === 'datetime') {\n return (\n <DateTimeInput\n {...common}\n aria-label={`${field.label}${field.required ? ' (required)' : ''}`}\n min={field.min}\n max={field.max}\n value={typeof value === 'string' ? value : ''}\n onChange={onChange}\n />\n );\n }\n if (field.type === 'number') {\n const whole = field.integer || (field.step !== undefined && Number.isInteger(field.step));\n return marked(\n <input\n {...common}\n type=\"number\"\n min={field.min}\n max={field.max}\n step={field.step ?? (field.integer ? 1 : 'any')}\n inputMode={whole ? 'numeric' : 'decimal'}\n value={String(value ?? '')}\n onChange={(event) => onChange(event.target.value)}\n />,\n );\n }\n if (field.type !== 'text') return null;\n // The format picks the keyboard; the shared reader still judges the value.\n const type = field.format === 'email' ? 'email' : field.format === 'url' ? 'url' : field.format === 'phone' ? 'tel' : 'text';\n return marked(\n <input\n {...common}\n type={type}\n minLength={field.minLength}\n maxLength={field.maxLength}\n {...(field.case === 'upper' ? { autoCapitalize: 'characters' } : {})}\n value={String(value ?? '')}\n onChange={(event) => onChange(event.target.value)}\n />,\n );\n}\n\n/* A box the valid check stands in: a text or number box, an amount, a text typed through its mask. A sensitive value\n keeps its show button there, and a slider and every chooser say their state their own way. */\nconst markable = (field: AppCommandField): boolean =>\n ((field.type === 'money' || field.type === 'number') && field.as !== 'slider') ||\n (field.type === 'text' && field.sensitive === undefined);\n\n/* Whether an answer given is one its field's own rules take: its kind, its pattern, its bounds — judged alone, so a\n condition on another answer (`when`) does not hide it from the judging. */\nfunction ownRulesTake(field: AppCommandField, value: CommandValue | undefined): boolean {\n if (value === undefined || value === null || value === '') return false;\n const { when: _when, ...own } = field as AppCommandField & { when?: string };\n return (\n commandInputProblems([own as AppCommandField], submitted([own as AppCommandField], { [field.name]: value }), cellReading()).length === 0\n );\n}\n\nexport interface CommandFieldsShared {\n idPrefix: string;\n /** By path; each is drawn beside its field. Absent, the host says problems itself. */\n problems?: Readonly<Record<string, string>>;\n disabled?: boolean;\n /** Signed in: the connection a reference reads its choices from. Without one, or a visitor, a reference is not drawn. */\n connection?: string;\n /** A public form's: its App, read signed out, where a reference's choices are what `auth.public` opens. */\n visitor?: { app: string; via?: string };\n identityEpoch: number;\n isCurrent: () => boolean;\n /** Input name → the App's own input component (an action's or a form's `inputs`); one in a group by its path, `trade.vin`,\n which stands in every row of a repeating group. */\n inputs?: Readonly<Record<string, { id: string }>>;\n /** The record the command acts on, where it names one: a rich text input's pictures are kept as its attachments. */\n record?: { table: string; key: Record<string, unknown> };\n /** The query prepare bound to the record for each picker that reads it (`record.id`), by declared path; null\n when the record holds nothing to narrow by, and such a picker offers nothing. */\n bound?: Readonly<Record<string, string | null>>;\n /** The questions prepare read for each `field.defined` input; until it has, such an input draws nothing. */\n questions?: CommandQuestions;\n /** How the form around the fields is drawn: the intake style turns the valid check on, the stepper leaves it off. */\n presentation?: 'stepper' | 'intake';\n}\n\ntype Entry = CommandValues[string];\n\n/** The fields of one list — a command's, or a group's — each changing its own value in `values`. */\nexport function CommandFields({\n fields,\n values,\n onChange,\n whole,\n ...shared\n}: CommandFieldsShared & {\n fields: readonly AppCommandField[];\n values: CommandValues;\n /** The whole form, where these are one step's fields: their conditions read every answer so far. */\n whole?: CommandDraft;\n /** The whole next values, and the path of the field that changed: a host clears that field's problem. */\n onChange: (values: CommandValues, path: string) => void;\n}) {\n const logic = useArrived(draftLogic, asksDraftLogic(whole?.fields ?? fields));\n const hidden = draftHidden(fields, values, whole);\n if (!logic && asksDraftLogic(whole?.fields ?? fields)) return null;\n return (\n <>\n {fields\n .filter((field) => !hidden.has(field.name))\n .map((field) => {\n const entry = (\n <FieldEntry\n key={field.name}\n field={field}\n path={field.name}\n value={values[field.name]}\n shared={shared}\n onChange={(next, path) => onChange({ ...values, [field.name]: next }, path)}\n />\n );\n // A number's live lines (`live`), under it, read over every answer so far.\n if ((field.type !== 'number' && field.type !== 'money') || !field.live) return entry;\n return (\n <Fragment key={field.name}>\n {entry}\n <CommandLive\n field={field}\n fields={whole?.fields ?? fields}\n values={whole?.values ?? values}\n id={`${shared.idPrefix}-live-${field.name}`}\n />\n </Fragment>\n );\n })}\n </>\n );\n}\n\nfunction FieldEntry({\n field,\n path,\n value,\n onChange,\n shared,\n}: {\n field: AppCommandField;\n path: string;\n value: Entry;\n shared: CommandFieldsShared;\n onChange: (value: Entry, path: string) => void;\n}) {\n // Under its own `-field-` namespace: the page names its heading, its done\n // and review sections as `${idPrefix}-title` and the like, so an input\n // called `title` must never land on one of those ids (it left the region\n // unnamed and the textbox without a label).\n const id = `${shared.idPrefix}-field-${path.replace(/[^A-Za-z0-9_-]/g, '-')}`;\n const problem = shared.problems?.[path];\n /* The intake style's valid check: judged once the box has been left, so it never cheers a half-typed answer. */\n const [left, setLeft] = useState(false);\n if (field.type === 'defined')\n return (\n <DefinedAnswers field={field} id={id} path={path} value={value} shared={shared} onChange={onChange} Control={CommandFieldControl} />\n );\n if (field.type === 'lines')\n return (\n <div className=\"command-lines\">\n <CommandLines\n field={field}\n path={path}\n rows={isLines(value) ? value : []}\n problems={shared.problems}\n disabled={shared.disabled}\n onChange={(rows: LineDraft[], changed: string) => onChange(rows, changed)}\n />\n {shared.problems && (\n <span className=\"insert-missing\" aria-live=\"polite\" hidden={!problem}>\n {problem}\n </span>\n )}\n </div>\n );\n if (field.type === 'group') {\n const helpId = field.help ? `${id}-help` : undefined;\n const errorId = `${id}-error`;\n const describedBy = [helpId, problem ? errorId : undefined].filter(Boolean).join(' ') || undefined;\n return (\n <fieldset className={`command-group${field.repeat ? ' command-repeat' : ''}`} aria-describedby={describedBy}>\n <legend>{field.label}</legend>\n <div className=\"command-group-body\">\n {field.help && (\n <span id={helpId} className=\"command-help\">\n {field.help}\n </span>\n )}\n {field.repeat ? (\n <RepeatRows\n field={field}\n path={path}\n rows={Array.isArray(value) ? (value as CommandValues[]) : []}\n shared={shared}\n onChange={onChange}\n />\n ) : (\n <GroupFields field={field} path={path} values={isValues(value) ? value : {}} shared={shared} onChange={onChange} />\n )}\n {shared.problems && (\n <span id={errorId} className=\"insert-missing\" aria-live=\"polite\" hidden={!problem}>\n {problem}\n </span>\n )}\n </div>\n </fieldset>\n );\n }\n /* Several choices are the one list a value input holds; every other list or object is a group's or the grid's. */\n const scalar =\n field.type === 'choices'\n ? Array.isArray(value)\n ? (value as unknown as readonly (string | number)[])\n : undefined\n : isValues(value) || Array.isArray(value)\n ? undefined\n : (value as CommandValue | undefined);\n /* A yes-or-no is answered either way, so it is only \"required\" when it\n must be checked: a box that says required and takes no was a trap. */\n const needed = isCheck(field) ? field.accept === true : field.required;\n /* Required is said once to a sighted reader: the star (Field's `required`). The word stays in the label's text,\n hidden, so the control's name still carries it for a screen reader and a query by label. */\n const label = needed ? (\n <>\n {field.label}\n <span className=\"visually-hidden\"> {say('requiredWord')}</span>\n </>\n ) : (\n field.label\n );\n const radios = field.type === 'choice' && asRadios(field);\n const listbox = field.type === 'choice' && !radios;\n /* One Field: the label over the control, the help and then the problem\n under it, wired into the control's description. Radios and a listbox's\n button are named by the caption rather than a <label>. */\n /* A checkbox is drawn with its label beside it, and the label checks it:\n the one control whose name reads as a sentence to agree to. An App's own\n input for it keeps the label above, as every other control has. */\n const declared = path.replace(/\\[\\d+\\]/g, '');\n /* The form's own choice of component for this input first, then the field's (`input`, every form that asks it, a\n public one's too: its page loads the ones its payload says are served, sdk/publicInputs.ts). */\n const custom =\n shared.inputs && Object.hasOwn(shared.inputs, declared)\n ? shared.inputs[declared]\n : 'input' in field && typeof field.input === 'string'\n ? { id: field.input }\n : undefined;\n /* A consent beside its statement is drawn whole by its control, the box and the paragraph (IntakeControls): the label\n stays the box's name and the review's, read but not drawn, so it never stands as a narrow column beside them. */\n const stated = field.type === 'boolean' && field.statement !== undefined && !custom;\n const check = isCheck(field) && !custom && !stated;\n /* A yes or a no as two buttons is a question over its answers, named by its caption, as radios are. */\n const pair = field.type === 'boolean' && field.as === 'buttons' && !custom;\n /* A picker narrowed by the record reads the query prepare bound to it (the form opens once prepare answers). */\n const bound = shared.bound && Object.hasOwn(shared.bound, declared) ? shared.bound[declared] : undefined;\n return (\n <Field\n label={label}\n required={needed === true}\n optional={isCheck(field) ? undefined : say('optionalWord')}\n id={id}\n hint={field.help}\n problem={problem}\n group={radios || listbox || pair}\n check={check}\n labelHidden={stated}\n className=\"command-field\"\n >\n {(control) =>\n field.type === 'reference'\n ? (shared.connection !== undefined || shared.visitor) && (\n <CommandReferenceField\n field={bound === undefined ? field : { ...field, query: bound ?? '' }}\n id={id}\n describedBy={control['aria-describedby']}\n invalid={Boolean(problem)}\n connection={shared.connection ?? { visitor: shared.visitor! }}\n identityEpoch={shared.identityEpoch}\n disabled={shared.disabled === true || bound === null}\n value={scalar}\n isCurrent={shared.isCurrent}\n onChange={(next) => onChange(next, path)}\n />\n )\n : (() => {\n const marks = shared.presentation === 'intake' && markable(field);\n const platform = (\n <CommandFieldControl\n field={field}\n id={id}\n describedBy={control['aria-describedby']}\n invalid={Boolean(problem)}\n {...(marks\n ? { valid: left && !problem && ownRulesTake(field, scalar as CommandValue | undefined), onLeave: () => setLeft(true) }\n : {})}\n value={scalar}\n disabled={shared.disabled}\n onChange={(next) => onChange(next, path)}\n {...(shared.connection === undefined ? {} : { connection: shared.connection })}\n {...(shared.visitor ? { visitor: shared.visitor } : {})}\n {...(shared.record ? { record: shared.record } : {})}\n />\n );\n /* The App's own input, where it names one for this input: the form still keeps, checks and sends the value. */\n return custom ? (\n <InputSlot\n component={custom.id}\n fallback={platform}\n value={Array.isArray(scalar) ? null : ((scalar as string | number | boolean | undefined) ?? null)}\n onChange={(next) => onChange(next as CommandValue, path)}\n id={id}\n describedBy={control['aria-describedby']}\n invalid={Boolean(problem)}\n disabled={shared.disabled === true}\n required={field.required === true}\n label={field.label}\n field={{ name: field.name }}\n context=\"command\"\n />\n ) : (\n platform\n );\n })()\n }\n </Field>\n );\n}\n\nfunction GroupFields({\n field,\n path,\n values,\n shared,\n onChange,\n}: {\n field: GroupField;\n path: string;\n values: CommandValues;\n shared: CommandFieldsShared;\n onChange: (value: Entry, path: string) => void;\n}) {\n const hidden = draftHidden(field.fields, values);\n return (\n <div className=\"command-fields\">\n {field.fields\n .filter((member) => !hidden.has(member.name))\n .map((member) => (\n <FieldEntry\n key={member.name}\n field={member}\n path={`${path}.${member.name}`}\n value={values[member.name]}\n shared={shared}\n onChange={(next, changed) => onChange({ ...values, [member.name]: next }, changed)}\n />\n ))}\n </div>\n );\n}\n\n/** A repeating group's rows, from its minimum to its maximum; each row is the group's fields again. */\nfunction RepeatRows({\n field,\n path,\n rows,\n shared,\n onChange,\n}: {\n field: GroupField;\n path: string;\n rows: CommandValues[];\n shared: CommandFieldsShared;\n onChange: (value: Entry, path: string) => void;\n}) {\n // Rows are keyed by when they were added, not where they sit: removing one keeps the others' pickers and focus.\n const keys = useRef<number[]>([]);\n const next = useRef(0);\n while (keys.current.length < rows.length) keys.current.push(next.current++);\n if (keys.current.length > rows.length) keys.current.length = rows.length;\n const min = field.repeat?.min ?? 0,\n max = field.repeat?.max ?? 0;\n return (\n <>\n {rows.map((row, index) => (\n <div\n className=\"command-row\"\n role=\"group\"\n aria-label={say('groupRow', { label: field.label, index: index + 1 })}\n key={keys.current[index]}\n >\n <div className=\"command-row-head\">\n <span className=\"command-row-number\">\n {say('rowLabel')} {index + 1}\n </span>\n <Button\n intent=\"secondary\"\n size=\"compact\"\n disabled={shared.disabled || rows.length <= min}\n aria-label={say('removeRow', { index: index + 1, label: field.label })}\n onClick={() => {\n keys.current.splice(index, 1);\n onChange(\n rows.filter((_, other) => other !== index),\n path,\n );\n }}\n >\n {say('common.remove')}\n </Button>\n </div>\n <GroupFields\n field={field}\n path={`${path}[${index}]`}\n values={row}\n shared={shared}\n onChange={(value, changed) =>\n onChange(\n rows.map((item, other) => (other === index ? (value as CommandValues) : item)),\n changed,\n )\n }\n />\n </div>\n ))}\n <div className=\"command-repeat-actions\">\n <Button\n intent=\"secondary\"\n disabled={shared.disabled || rows.length >= max}\n aria-label={say('addRowTo', { label: field.label })}\n onClick={() => onChange([...rows, blankCommandValues(field.fields)], path)}\n >\n {say('addRow')}\n </Button>\n </div>\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAkBA,IAAM,WAAW;AACjB,IAAM,wBAAQ,IAAI,IAAsD;AACxE,IAAM,YAAY,UAAwB,KAAK,UAAU;CAAC,MAAM;CAAY,MAAM;CAAS,MAAM;CAAgB,MAAM;AAAG,CAAC;AAE3H,eAAe,QAAQ,OAAsC;CAC3D,MAAM,WAAW,MAAM,IAAI,yBAAyB;EAClD,GAAG,QAAQ,MAAM,UAAU;EAC3B,SAAS,MAAM;EACf,gBAAgB,MAAM;EACtB,KAAK,MAAM;CACb,CAAC;CACD,IAAI,CAAC,OAAO,cAAc,UAAU,eAAe,KAAK,SAAS,kBAAkB,GACjF,MAAM,IAAI,MAAMA,QAAI,sCAAsC,CAAC;CAC7D,OAAO,SAAS;AAClB;;;;;AAMA,SAAgB,aAAa,OAA2B;CACtD,MAAM,MAAM,SAAS,KAAK;CAC1B,MAAM,OAAO,MAAM,IAAI,GAAG;CAC1B,IAAI,QAAQ,KAAK,IAAI,IAAI,KAAK,KAAK,UAAU;CAC7C,MAAM,UAAU,QAAQ,KAAK;CAC7B,QAAQ,YAAY;EAClB,IAAI,MAAM,IAAI,GAAG,CAAC,EAAE,YAAY,SAAS,MAAM,OAAO,GAAG;CAC3D,CAAC;CACD,MAAM,IAAI,KAAK;EAAE,IAAI,KAAK,IAAI;EAAG;CAAQ,CAAC;AAC5C;AAEA,eAAsB,YACpB,QACA,OACA,OACA,SACsB;CACtB,MAAM,MAAM,SAAS,KAAK;CAC1B,MAAM,OAAO,MA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AAK,QAAQ,OAAO,OAAO,CAAC;KAC5B,SACE,KAAK,QAAQ,GAAG,UAAU,UAAU,KAAK,GACzC,IACF;IACF;IAEC,UAAA,IAAI,eAAe;GACd,CAAA,CACL;EACL,CAAA,GAAA,oBAAC,aAAD;GACS;GACP,MAAM,GAAG,KAAK,GAAG,MAAM;GACvB,QAAQ;GACA;GACR,WAAW,OAAO,YAChB,SACE,KAAK,KAAK,MAAM,UAAW,UAAU,QAAS,QAA0B,IAAK,GAC7E,OACF;EAEH,CAAA,CACE;CAlCE,GAAA,KAAK,QAAQ,MAkCf,CACN,GACD,oBAAC,OAAD;EAAK,WAAU;EACb,UAAA,oBAAC,QAAD;GACE,QAAO;GACP,UAAU,OAAO,YAAY,KAAK,UAAU;GAC5C,cAAY,IAAI,YAAY,EAAE,OAAO,MAAM,MAAM,CAAC;GAClD,eAAe,SAAS,CAAC,GAAG,MAAM,mBAAmB,MAAM,MAAM,CAAC,GAAG,IAAI;GAExE,UAAA,IAAI,QAAQ;EACP,CAAA;CACL,CAAA,CACL,EAAA,CAAA;AAEN"}
1
+ {"version":3,"file":"shared-JvcI-LWp.js","names":["say","readValue","_Fragment"],"sources":["../../src/client/commandSend.ts","../../src/client/commandAvailability.ts","../../src/shared/commandInput.ts","../../src/client/copy/forms/components/CommandFields.ts","../../src/client/components/CommandFields.tsx"],"sourcesContent":["/**\n * A record's command sent without its form, as the form's submit would send it: prepared for the record's revision,\n * started, and sent once. The prepare may already have been asked (`readyCommand`), when the pointer or focus came to\n * the button, so a click sends only the execute. Two callers, one path: a component's `run` (components/sdk/commands.tsx) and an action\n * whose command asks nothing, which runs on one click (components/Actions.tsx). What happens after —\n * a notice, the form opened over an answer that never arrived — is the caller's.\n */\nimport type { AppCommandAction } from '../shared/app.js';\nimport { api } from '@mistriwork/kit/client/core.js';\nimport { ownedBy } from '@mistriwork/kit/client/requestIdentity.js';\nimport { commandOperations, type CommandOperation, type CommandOwner } from './commandState.js';\nimport { message as say } from '@mistriwork/kit/client/messages.js';\n\ntype CommandSent = { operation: CommandOperation } | { refused: string };\n\n/* A revision asked ahead of the click is used for a short while. One the record has moved past is refused by the\n execute as `stale_record`, before any handler runs, and the click then prepares and sends once more, as it would\n have from the start; so a stale one costs a round trip, never a wrong write. */\nconst READY_MS = 10_000;\nconst ready = new Map<string, { at: number; version: Promise<number> }>();\nconst readyKey = (owner: CommandOwner) => JSON.stringify([owner.connection, owner.command, owner.commandVersion, owner.key]);\n\nasync function prepare(owner: CommandOwner): Promise<number> {\n const prepared = await api('/api/commands/prepare', {\n ...ownedBy(owner.connection),\n command: owner.command,\n commandVersion: owner.commandVersion,\n key: owner.key,\n });\n if (!Number.isSafeInteger(prepared?.expectedVersion) || prepared.expectedVersion < 0)\n throw new Error(say('common.theRecordVersionIsUnavailable'));\n return prepared.expectedVersion as number;\n}\n\n/**\n * Ask the record's revision for a command that runs on one click, before the click: the pointer coming to its button,\n * or focus. Asked once while it is fresh; the click's `sendCommand` takes it, or the request still on its way.\n */\nexport function readyCommand(owner: CommandOwner): void {\n const key = readyKey(owner);\n const kept = ready.get(key);\n if (kept && Date.now() - kept.at < READY_MS) return;\n const version = prepare(owner);\n version.catch(() => {\n if (ready.get(key)?.version === version) ready.delete(key);\n });\n ready.set(key, { at: Date.now(), version });\n}\n\nexport async function sendCommand(\n action: AppCommandAction,\n owner: CommandOwner,\n input: Record<string, unknown>,\n options: { headless: boolean; current?: () => boolean; refresh: () => void },\n): Promise<CommandSent> {\n const key = readyKey(owner);\n const kept = ready.get(key);\n ready.delete(key);\n const early = kept && Date.now() - kept.at < READY_MS ? kept.version : undefined;\n let expectedVersion: number;\n try {\n // One asked ahead that failed is asked again here, so its refusal is this click's own.\n expectedVersion = early ? await early.catch(() => prepare(owner)) : await prepare(owner);\n } catch (error) {\n return { refused: (error as Error).message };\n }\n const sent = await execute(action, owner, input, expectedVersion, options);\n if (early && 'operation' in sent && sent.operation.phase === 'error' && sent.operation.code === 'stale_record') {\n commandOperations.forget(owner);\n return sendCommand(action, owner, input, options);\n }\n // A command that ran moved its record, so no revision asked ahead still holds.\n if ('operation' in sent && sent.operation.phase === 'success') ready.clear();\n return sent;\n}\n\nasync function execute(\n action: AppCommandAction,\n owner: CommandOwner,\n input: Record<string, unknown>,\n expectedVersion: number,\n { headless, current = () => true, refresh }: { headless: boolean; current?: () => boolean; refresh: () => void },\n): Promise<CommandSent> {\n let operation: CommandOperation;\n try {\n operation = commandOperations.start(owner, expectedVersion, input, action, headless);\n } catch (error) {\n return { refused: (error as Error).message };\n }\n await commandOperations.send(\n operation,\n 'execute',\n (path, envelope) => {\n if (path !== '/api/commands/execute' && path !== '/api/commands/status') throw new Error(say('common.invalidCommandPath'));\n if (!current()) throw Object.assign(new Error(say('common.thisCommandFormIsNoLonger')), { outcome: 'not_applied' });\n return api(path, { ...envelope, ...ownedBy(owner.connection) });\n },\n refresh,\n );\n return { operation };\n}\n","/** Batched, surface-owned command visibility; never execution authority. */\nimport { useEffect, useId, useMemo, useSyncExternalStore } from 'react';\nimport { useQueries, useQueryClient } from '@tanstack/react-query';\nimport { api, state } from '@mistriwork/kit/client/core.js';\nimport { appRequestScope, ownedBy } from '@mistriwork/kit/client/requestIdentity.js';\nimport { recordKey } from '@mistriwork/kit/client/resourceRequests.js';\nimport { commandKeyText } from '../shared/command.js';\nimport { composeUnderway, composedCheck } from '@mistriwork/kit/client/composedReads.js';\nimport {\n captureTenantLease,\n sessionIdentity,\n subscribeSessionIdentity,\n subscribeTenantLease,\n tenantLeaseActive,\n} from '@mistriwork/kit/client/sessionIdentity.js';\n\ninterface Check {\n command: string;\n commandVersion: number;\n key: Record<string, unknown>;\n}\ntype Identity = ReturnType<typeof sessionIdentity>;\ninterface Pending {\n check: Check;\n identity: Identity;\n connection: string | null;\n scope: ReturnType<typeof appRequestScope>;\n lease: ReturnType<typeof captureTenantLease>;\n resolve: (value: boolean) => void;\n}\nlet pending: Pending[] = [];\nlet nextSurface = 0;\nconst current = (identity: Identity, connection: string | null) =>\n identity === sessionIdentity() &&\n identity.mode === 'authenticated' &&\n identity.appId === connection &&\n (state.activeConnection ?? null) === connection &&\n (!identity.tenantRequired || tenantLeaseActive(identity));\nconst pendingCurrent = (item: Pending) =>\n current(item.identity, item.connection) && item.scope === appRequestScope() && item.lease === captureTenantLease(item.identity);\n\n/** Fresh reads only: pending callers share one microtask batch, never a result cache. */\nexport function commandAvailable(check: Check): Promise<boolean> {\n const identity = sessionIdentity(),\n connection = state.activeConnection ?? null;\n if (!current(identity, connection)) return Promise.resolve(false);\n let captured: Check;\n try {\n captured = { command: check.command, commandVersion: check.commandVersion, key: recordKey(check.key) };\n } catch {\n return Promise.resolve(false);\n }\n /* A record page's compose asked its verbs already (composedReads.ts). One still on its way is waited for: a\n record refreshed after a command asks its verbs in the same moment it composes, and asked beside the compose\n they went out on their own (G173). */\n const underway = composeUnderway(connection);\n if (underway) return underway.then(() => commandAvailable(check));\n const composed = composedCheck(connection, captured.command, captured.commandVersion, captured.key);\n if (composed !== undefined) return Promise.resolve(composed);\n return new Promise((resolve) => {\n if (!pending.length) queueMicrotask(flush);\n pending.push({ check: captured, identity, connection, scope: appRequestScope(), lease: captureTenantLease(identity), resolve });\n });\n}\n\nfunction flush() {\n const work = pending;\n pending = [];\n while (work.length) {\n const first = work.shift()!;\n if (!pendingCurrent(first)) {\n first.resolve(false);\n continue;\n }\n const batch = [first];\n for (let i = 0; i < work.length;) {\n if (\n work[i].identity === first.identity &&\n work[i].connection === first.connection &&\n work[i].scope === first.scope &&\n work[i].lease === first.lease\n )\n batch.push(...work.splice(i, 1));\n else i++;\n }\n while (batch.length) {\n const groups: Array<{ command: string; commandVersion: number; keys: Record<string, unknown>[]; callers: Pending[][] }> = [];\n let keys = 0;\n for (let i = 0; i < batch.length;) {\n const item = batch[i],\n existing = groups.find((group) => group.command === item.check.command);\n if ((existing && existing.commandVersion !== item.check.commandVersion) || (!existing && groups.length >= 16)) {\n i++;\n continue;\n }\n const index = existing?.keys.findIndex((key) => commandKeyText(key) === commandKeyText(item.check.key)) ?? -1;\n if (index < 0 && keys >= 200) {\n i++;\n continue;\n }\n const group = existing ?? { command: item.check.command, commandVersion: item.check.commandVersion, keys: [], callers: [] };\n if (!existing) groups.push(group);\n if (index >= 0) group.callers[index].push(item);\n else {\n group.keys.push(item.check.key);\n group.callers.push([item]);\n keys++;\n }\n batch.splice(i, 1);\n }\n const checks = groups.map(({ command, commandVersion, keys }) => ({ command, commandVersion, keys }));\n /** One request, and its answers only if the reply is exactly about it. */\n const ask = async (asked: typeof checks): Promise<boolean[][] | undefined> => {\n try {\n if (!pendingCurrent(first)) return undefined;\n const reply: unknown = await api('/api/commands/availability', { ...ownedBy(first.connection), checks: asked });\n if (\n !pendingCurrent(first) ||\n !reply ||\n typeof reply !== 'object' ||\n Array.isArray(reply) ||\n Object.keys(reply).length !== 1 ||\n !('checks' in reply) ||\n !Array.isArray(reply.checks) ||\n reply.checks.length !== asked.length\n )\n return undefined;\n const results = reply.checks;\n if (\n Array.from(results).some(\n (result, i) =>\n !result ||\n typeof result !== 'object' ||\n Array.isArray(result) ||\n Object.keys(result).sort().join(',') !== 'available,command,commandVersion' ||\n result.command !== asked[i].command ||\n result.commandVersion !== asked[i].commandVersion ||\n !Array.isArray(result.available) ||\n result.available.length !== asked[i].keys.length ||\n result.available.some((value: unknown) => typeof value !== 'boolean'),\n )\n )\n return undefined;\n return results.map((result) => result.available as boolean[]);\n } catch {\n return undefined; /* Visibility is false on any transport or protocol failure. */\n }\n };\n void (async () => {\n let available: boolean[][] | undefined;\n try {\n available = await ask(checks);\n /* One verb whose visibility cannot be answered must hide itself and\n nothing else. A refusal answers the whole request, so a record\n offering several commands lost its entire action bar to one of\n them — ask the rest again, a command at a time. Only after a\n failure, so an ordinary bar is still one request. */\n if (!available && checks.length > 1) {\n const answers = await Promise.all(checks.map(async (check) => ask([check])));\n available = answers.map((answer, i) => answer?.[0] ?? checks[i].keys.map(() => false));\n }\n } finally {\n groups.forEach((group, i) =>\n group.callers.forEach((callers, k) => callers.forEach((caller) => caller.resolve(available?.[i][k] === true))),\n );\n }\n })();\n }\n }\n}\n\n/** Hide while pending/refetching. Instance-owned queries retire with their\n * record surface; invalidating data after any write also invalidates visibility. */\nexport function useCommandAvailability(checks: Check[], enabled = true, surface?: object): boolean[] {\n return useCommandAnswers(checks, enabled, surface).available;\n}\n\n/** The same, and whether any is still being asked: a bar holds a verb's place until it knows. */\nexport function useCommandAnswers(checks: Check[], enabled = true, surface?: object): { available: boolean[]; asking: boolean } {\n const identity = useSyncExternalStore(subscribeSessionIdentity, sessionIdentity, sessionIdentity);\n const leaseSnapshot = () => {\n const lease = captureTenantLease(identity);\n return `${lease?.revision}:${lease?.expiresAt}:${!identity.tenantRequired || tenantLeaseActive(identity)}`;\n };\n useSyncExternalStore(subscribeTenantLease, leaseSnapshot, leaseSnapshot);\n const lease = captureTenantLease(identity);\n const client = useQueryClient(),\n instance = useId();\n const surfaceKey = useMemo(() => ++nextSurface, [surface]);\n useEffect(() => {\n if (!lease) return;\n const timer = setTimeout(\n () => {\n tenantLeaseActive(identity);\n },\n Math.max(0, lease.expiresAt - Date.now()),\n );\n return () => clearTimeout(timer);\n }, [identity, lease]);\n const checking = checks.length > 0;\n useEffect(() => {\n if (!checking) return;\n let mounted = true,\n queued = false;\n const unsubscribe = client.getQueryCache().subscribe((event) => {\n if (\n event.type !== 'updated' ||\n event.action.type !== 'invalidate' ||\n !['run', 'count', 'when'].includes(String(event.query.queryKey[0])) ||\n queued\n )\n return;\n queued = true;\n queueMicrotask(() => {\n queued = false;\n // A broad invalidation already marks these queries itself. Do not\n // cancel/restart its in-flight refetch in this coalesced follow-up.\n if (mounted) {\n const targets = new Set(\n client\n .getQueryCache()\n .findAll({ queryKey: ['command-availability', instance] })\n .filter((query) => !query.state.isInvalidated)\n .map((query) => query.queryHash),\n );\n void client.invalidateQueries({ predicate: (query) => targets.has(query.queryHash) });\n }\n });\n });\n return () => {\n mounted = false;\n unsubscribe();\n };\n }, [client, instance, checking]);\n const active = enabled && current(identity, state.activeConnection ?? null);\n const results = useQueries({\n queries: checks.map((check) => ({\n queryKey: [\n 'command-availability',\n instance,\n surfaceKey,\n identity.epoch,\n state.activeConnection,\n lease?.revision,\n active,\n check.command,\n check.commandVersion,\n check.key,\n ],\n queryFn: () => commandAvailable(check),\n enabled: active,\n retry: false,\n staleTime: 0,\n gcTime: 0,\n })),\n });\n return {\n available: results.map((result) => active && !result.isFetching && result.data === true),\n asking: active && results.some((result) => result.isFetching),\n };\n}\n","/**\n * A command's input, read against its declaration: the one parser the\n * server runs before a command's own `validate`, and the browser runs to\n * say which field needs attention before anything is sent. It is derived\n * from the field list alone — required, lengths, formats, patterns, case,\n * bounds, whole numbers and steps, dates and moments, a field below or above its\n * sibling, choices, nesting, repeat limits and reference shape — so a\n * command declares its input once, in a browser-safe module both sides import.\n *\n * What comes back is a fresh plain object in the declaration's order: text\n * trimmed and in its declared case, a number on its step, an optional field\n * left empty absent, every group present (an object, or its rows). A key the\n * declaration does not name is refused. A refusal names the field it is\n * about by path — `reason`, `applicant.email`, `vehicles[1].stock` — and\n * never echoes a value.\n */\nimport type { AppCommandField } from './command.js';\nimport { COMMAND_INPUT_LIMITS, fieldPattern, isIsoDate, isIsoMonth, isoInstant, maskPattern } from './command.js';\nimport { RICH_TEXT_MOST, richTextPlain } from '@mistriwork/engine/shared/richText.js';\nimport { DEFINED_KEY, DEFINITIONS_MOST } from '@mistriwork/engine/shared/definedFields.js';\n\nexport type CommandInputReason =\n | 'shape'\n | 'required'\n | 'type'\n | 'text'\n | 'too_short'\n | 'too_long'\n | 'format'\n | 'pattern'\n | 'below_min'\n | 'above_max'\n | 'integer'\n | 'precision'\n | 'not_below'\n | 'not_above'\n | 'choice'\n | 'too_few'\n | 'too_many'\n | 'exclusive';\n\n/** One problem: `path` is empty when it is the input's shape as a whole, such as a key nobody declared. */\ntype CommandInputProblem = { path: string; reason: CommandInputReason };\n\n/** The first problem, as the server's parser meets it. */\nexport class CommandInputRefusal extends Error {\n constructor(\n readonly path: string,\n readonly reason: CommandInputReason,\n ) {\n super('The command input is invalid.');\n this.name = 'CommandInputRefusal';\n }\n}\n\ninterface ReadOptions {\n /** A public form's submission: repeats are held to the public cap whatever the declaration says. */\n publicForm?: boolean;\n /** Starting values (`initial`): nothing is required and no repeat has a minimum; every value is still checked. */\n partial?: boolean;\n /**\n * The server's reading of a rich text value — Markdown or HTML in, sanitized\n * HTML out (server/richText.ts `readRichTextInput`), throwing a refusal with\n * a `reason`. The browser has none: it checks the shape and the size, and\n * the server's reading is the one that is kept.\n */\n richText?: (value: unknown, most: number) => string;\n /**\n * A line's cell read as its column's kind (`lineCell`), where the reader has\n * the catalog: the server where the command runs, the browser from the one it\n * is served. Without one a cell is judged by its shape alone.\n */\n cell?: (table: string, column: string, value: string | number | boolean) => { value: unknown } | CommandInputReason;\n /**\n * Whether a value is one of a table's rows, for a choice read from one (`field.choice({ from })`): the server's\n * reading against the rows the reader may read, the browser's against the options it was served. Without one a\n * value is judged by its shape alone, and the server judges it again.\n */\n sourced?: (field: { name: string; source: { from: string; by: string; labelColumn: string } }, value: string | number) => boolean;\n /**\n * The App's currency (`ui.currency`), which a `minor` money field without a `currency` of its own is typed in: the\n * server's from the App, the browser's from the one it was served. Without one a minor amount is judged by its shape\n * and bounds alone, as a line's cell is without a catalog.\n */\n currency?: string;\n /**\n * Keep a minor-unit amount as the major text a person types (\"19.99\"), validated and tidied, instead of reading it\n * as the minor units a handler receives. What the browser sends, what an API caller sends, and what a form is served\n * as its starting values; the server's own reading before a handler is the other one.\n */\n wire?: boolean;\n}\n\ninterface State extends ReadOptions {\n problems?: CommandInputProblem[];\n}\n\n// eslint-disable-next-line no-control-regex -- One line of text holds no control characters.\nconst CONTROL = /[\\x00-\\x1f\\x7f]/;\n// eslint-disable-next-line no-control-regex -- A textarea keeps tabs and line breaks, and nothing else below space.\nconst CONTROL_MULTILINE = /[\\x00-\\x08\\x0b\\x0c\\x0e-\\x1f\\x7f]/;\n\n/* The formats a text field may declare. Shape checks, not verification:\n nothing here sends mail, opens the address or dials the number. */\nconst EMAIL = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/;\nconst PHONE = /^\\+?[0-9 ().-]{7,32}$/;\nconst FORMATS: Record<'email' | 'url' | 'phone', (value: string) => boolean> = {\n email: (value) => EMAIL.test(value),\n url: (value) => {\n try {\n const url = new URL(value);\n return (url.protocol === 'https:' || url.protocol === 'http:') && !!url.hostname;\n } catch {\n return false;\n }\n },\n phone: (value) => PHONE.test(value) && value.replace(/\\D/g, '').length >= 7,\n};\n\n/** A number on its step: `0.01` keeps cents, and the rounding leaves no binary tail behind. */\nfunction onStep(value: number, step: number): number {\n const text = String(step);\n const places = text.includes('e-') ? Number(text.split('e-')[1]) : (text.split('.')[1]?.length ?? 0);\n return Number((Math.round(value / step) * step).toFixed(Math.min(places, 20)));\n}\n\nconst plain = (value: unknown): value is Record<string, unknown> =>\n !!value && typeof value === 'object' && !Array.isArray(value) && [null, Object.prototype].includes(Object.getPrototypeOf(value));\nconst at = (within: string, name: string): string => (within ? `${within}.${name}` : name);\n\nfunction refuse(state: State, path: string, reason: CommandInputReason): void {\n if (!state.problems) throw new CommandInputRefusal(path, reason);\n state.problems.push({ path, reason });\n}\n\n/** The decimals a currency is written with (Intl's, 2 when it does not know the code); money.ts's, kept out of the first paint. */\nconst currencyPlaces = (currency: string): number => {\n try {\n return new Intl.NumberFormat('en', { style: 'currency', currency }).resolvedOptions().maximumFractionDigits ?? 2;\n } catch {\n return 2;\n }\n};\n\n/* An amount typed in major units and kept in minor ones, text to text: 19.99 USD is 1999, 1500 JPY is 1500, and a fraction\n finer than the currency has is refused, not rounded. Past 2^53 the whole number is a string, as an id is. */\nfunction readMinorMoney(\n field: Extract<AppCommandField, { type: 'money' }>,\n value: unknown,\n state: State,\n problem: (reason: CommandInputReason) => { value?: unknown },\n): { value?: unknown } {\n const m = /^(-?)(\\d*)\\.?(\\d*)$/.exec(\n typeof value === 'string' || typeof value === 'number' ? String(value).trim().replace(/^\\+/, '') : '',\n );\n if (!m || !(m[2] || m[3])) return problem('type');\n // A reading that is to hand a handler minor units always knows the currency: the App's, else dollars.\n const currency = field.currency ?? state.currency ?? (state.wire ? undefined : 'USD');\n const fraction = m[3].replace(/0+$/, '');\n const digits = currency === undefined ? fraction.length : currencyPlaces(currency);\n if (fraction.length > digits) return problem('precision');\n const whole = m[2].replace(/^0+/, '') || '0';\n const tidy = `${m[1] && (+whole || fraction) ? '-' : ''}${whole}${digits ? `.${fraction.padEnd(digits, '0')}` : ''}`;\n if (field.min !== undefined && +tidy < field.min) return problem('below_min');\n if (field.max !== undefined && +tidy > field.max) return problem('above_max');\n if (state.wire || currency === undefined) return { value: tidy };\n const minor = tidy.replace('.', '');\n return { value: Number.isSafeInteger(+minor) ? +minor : minor };\n}\n\nfunction readValue(\n field: Exclude<AppCommandField, { type: 'group' | 'lines' }>,\n value: unknown,\n path: string,\n state: State,\n): { value?: unknown } {\n const blank =\n value === undefined || value === null || value === '' || (typeof value === 'string' && field.type !== 'choice' && !value.trim());\n /* Questions defined in rows always arrive as an object, answered or not: the rows say which answers are required. */\n if (blank && field.type === 'defined') return state.partial ? {} : { value: {} };\n if (blank) {\n /* A field asked only where its `when` holds is required there: the server judges it against the record. */\n if (field.required && !state.partial && field.when === undefined) refuse(state, path, 'required');\n return {};\n }\n const problem = (reason: CommandInputReason) => {\n refuse(state, path, reason);\n return {};\n };\n switch (field.type) {\n case 'text':\n case 'textarea': {\n if (typeof value !== 'string') return problem('type');\n const trimmed = value.trim();\n // A masked value is what its places hold (`123456789`), and the mask is its pattern.\n if (field.type === 'text' && field.mask !== undefined) {\n if (CONTROL.test(trimmed)) return problem('text');\n return fieldPattern(maskPattern(field.mask)).test(trimmed) ? { value: trimmed } : problem('pattern');\n }\n const cased = field.case === 'upper' ? trimmed.toUpperCase() : field.case === 'lower' ? trimmed.toLowerCase() : trimmed;\n if ((field.type === 'text' ? CONTROL : CONTROL_MULTILINE).test(cased)) return problem('text');\n if (field.minLength !== undefined && cased.length < field.minLength) return problem('too_short');\n if (field.maxLength !== undefined && cased.length > field.maxLength) return problem('too_long');\n if (field.format !== undefined && !FORMATS[field.format](cased)) return problem('format');\n if (field.pattern !== undefined && !fieldPattern(field.pattern).test(cased)) return problem('pattern');\n return { value: cased };\n }\n case 'number':\n case 'money': {\n if (field.type === 'money' && field.minor === true) return readMinorMoney(field, value, state, problem);\n if (typeof value !== 'number' || !Number.isFinite(value)) return problem('type');\n if (field.type === 'number' && field.integer && !Number.isSafeInteger(value)) return problem('integer');\n const stepped = field.step === undefined ? value : onStep(value, field.step);\n if (field.min !== undefined && stepped < field.min) return problem('below_min');\n if (field.max !== undefined && stepped > field.max) return problem('above_max');\n return { value: stepped };\n }\n case 'boolean':\n if (typeof value !== 'boolean') return problem('type');\n // A box that must be checked, unchecked, is a required answer not given.\n return field.accept && !value && !state.partial && field.when === undefined ? problem('required') : { value };\n case 'date': {\n if (!isIsoDate(value)) return problem('type');\n if (field.min !== undefined && value < field.min) return problem('below_min');\n if (field.max !== undefined && value > field.max) return problem('above_max');\n return { value };\n }\n case 'month': {\n if (!isIsoMonth(value)) return problem('type');\n if (field.min !== undefined && value < field.min) return problem('below_min');\n if (field.max !== undefined && value > field.max) return problem('above_max');\n return { value };\n }\n case 'datetime': {\n // One spelling, the UTC instant, so bounds and siblings compare as text and the handler reads one form.\n const at = isoInstant(value);\n if (at === undefined) return problem('type');\n if (field.min !== undefined && at < field.min) return problem('below_min');\n if (field.max !== undefined && at > field.max) return problem('above_max');\n return { value: at };\n }\n case 'choice':\n if (field.source)\n return sourced(field as typeof field & { source: NonNullable<typeof field.source> }, value, state) ? { value } : problem('choice');\n return field.options.some((option) => option.value === value) ? { value } : problem('choice');\n case 'choices': {\n if (!Array.isArray(value) || Object.getPrototypeOf(value) !== Array.prototype) return problem('type');\n if (value.length > COMMAND_INPUT_LIMITS.choiceOptions) return problem('too_many');\n const picked: (string | number)[] = [];\n for (const item of value) {\n const known = field.source\n ? sourced(field as typeof field & { source: NonNullable<typeof field.source> }, item, state)\n : field.options.some((option) => option.value === item);\n if (!known) return problem('choice');\n if (!picked.includes(item as string | number)) picked.push(item as string | number);\n }\n // None chosen is no answer: the field's required, or its min, says whether that is enough.\n if (!picked.length) {\n if (field.required && !state.partial && field.when === undefined) refuse(state, path, 'required');\n return {};\n }\n if (field.exclusive?.some((alone) => picked.includes(alone)) && picked.length > 1) return problem('exclusive');\n if (!state.partial && field.min !== undefined && picked.length < field.min) return problem('too_few');\n if (field.max !== undefined && picked.length > field.max) return problem('too_many');\n return { value: picked };\n }\n case 'richText': {\n const said =\n typeof value === 'string'\n ? value\n : plain(value) &&\n Object.keys(value).length === 2 &&\n (value.format === 'markdown' || value.format === 'html') &&\n typeof value.text === 'string'\n ? value.text\n : undefined;\n if (said === undefined) return problem('type');\n const most = field.maxLength ?? RICH_TEXT_MOST;\n let html = said;\n if (state.richText) {\n try {\n html = state.richText(value, most);\n } catch (error) {\n return problem((error as { reason?: unknown }).reason === 'too_long' ? 'too_long' : 'type');\n }\n }\n // A value with no words and no picture — an empty paragraph the editor leaves — is no answer.\n if (!richTextPlain(html) && !/<img\\b/i.test(html)) {\n if (field.required && !state.partial && field.when === undefined) refuse(state, path, 'required');\n return {};\n }\n /* Unread, the text is judged as the reader judges what arrives (four times the kept size): what is kept is only known once it is cleaned. */\n if (html.length > (state.richText ? most : most * 4)) return problem('too_long');\n if (field.minLength !== undefined && richTextPlain(html).trim().length < field.minLength) return problem('too_short');\n return { value: html };\n }\n case 'reference': {\n if (typeof value === 'number') return Number.isSafeInteger(value) ? { value } : problem('type');\n if (typeof value !== 'string' || value.trim().length > 256) return problem('type');\n return { value: value.trim() };\n }\n /* Answers keyed by the questions' keys: only their shape is the declaration's. Which questions there are, and\n what each one takes, are rows, judged where the command runs (businessCommandExecution.ts); an answer left\n empty is left out. */\n case 'defined': {\n if (!plain(value)) return problem('type');\n const answers: Record<string, unknown> = {};\n const entries = Object.entries(value);\n if (entries.length > DEFINITIONS_MOST) return problem('too_many');\n for (const [key, answer] of entries) {\n if (!DEFINED_KEY.test(key)) return problem('shape');\n if (answer === null || answer === undefined || (typeof answer === 'string' && !answer.trim())) continue;\n const fits =\n (typeof answer === 'string' && answer.length <= 10000) ||\n (typeof answer === 'number' && Number.isFinite(answer)) ||\n typeof answer === 'boolean' ||\n (Array.isArray(answer) && answer.length <= 100 && answer.every((item) => typeof item === 'string' && item.length <= 1000));\n if (!fits) return problem('type');\n if (Array.isArray(answer) && !answer.length) continue;\n answers[key] = Array.isArray(answer) ? [...answer] : answer;\n }\n return { value: answers };\n }\n }\n}\n\n/* A table's row, by key: a key's shape here, and its row the reader's `sourced` judgement where there is one. */\nfunction sourced(\n field: { name: string; source: { from: string; by: string; labelColumn: string } },\n value: unknown,\n state: State,\n): boolean {\n const shaped =\n (typeof value === 'string' && value.trim() !== '' && value.length <= 256) || (typeof value === 'number' && Number.isSafeInteger(value));\n return shaped && (state.sourced ? state.sourced(field, value as string | number) : true);\n}\n\nfunction readList(fields: readonly AppCommandField[], raw: unknown, within: string, state: State): Record<string, unknown> {\n const result: Record<string, unknown> = {};\n const given = raw === undefined || raw === null ? {} : raw;\n if (!plain(given)) {\n refuse(state, within, 'shape');\n return result;\n }\n const known = new Set(fields.map((field) => field.name));\n // A key nobody declared is named by no path: what arrived is not echoed back.\n if (Object.keys(given).some((key) => !known.has(key))) refuse(state, '', 'shape');\n for (const field of fields) {\n const path = at(within, field.name);\n const value = Object.hasOwn(given, field.name) ? given[field.name] : undefined;\n if (field.type === 'lines') {\n if (state.partial && value === undefined) continue;\n result[field.name] = readLines(field, value, path, state);\n continue;\n }\n if (field.type !== 'group') {\n const read = readValue(field, value, path, state);\n if ('value' in read) result[field.name] = read.value;\n continue;\n }\n if (state.partial && value === undefined) continue;\n if (!field.repeat) {\n result[field.name] = readList(field.fields, value, path, state);\n continue;\n }\n const rows = value === undefined || value === null ? [] : value;\n if (!Array.isArray(rows)) {\n refuse(state, path, 'shape');\n continue;\n }\n const max = state.publicForm ? Math.min(field.repeat.max, COMMAND_INPUT_LIMITS.publicRepeatRows) : field.repeat.max;\n if (rows.length > max) {\n refuse(state, path, 'too_many');\n continue;\n }\n if (!state.partial && rows.length < (field.repeat.min ?? 0)) refuse(state, path, 'too_few');\n result[field.name] = rows.map((row, index) => readList(field.fields, row, `${path}[${index}]`, state));\n }\n // A field below or above its sibling: judged on the values as read, only when both were given.\n for (const field of fields) {\n if (\n (field.type !== 'number' && field.type !== 'money' && field.type !== 'date' && field.type !== 'month' && field.type !== 'datetime') ||\n !Object.hasOwn(result, field.name)\n )\n continue;\n // A minor-unit amount may be text (major in a wire reading, a string past 2^53): compared as the number it is.\n const compared = (name: string) => (field.type === 'money' ? Number(result[name]) : (result[name] as number | string));\n const mine = compared(field.name);\n if (field.below !== undefined && Object.hasOwn(result, field.below) && !(mine < compared(field.below))) {\n refuse(state, at(within, field.name), 'not_below');\n }\n if (field.above !== undefined && Object.hasOwn(result, field.above) && !(mine > compared(field.above))) {\n refuse(state, at(within, field.name), 'not_above');\n }\n }\n return result;\n}\n\n/* A record's lines (`field.lines`): one to `max` rows, each the columns the field shows and no other, every one given. */\nfunction readLines(field: Extract<AppCommandField, { type: 'lines' }>, raw: unknown, path: string, state: State): unknown[] {\n const rows = raw === undefined || raw === null ? [] : raw;\n if (!Array.isArray(rows)) {\n refuse(state, path, 'shape');\n return [];\n }\n if (rows.length > field.max) {\n refuse(state, path, 'too_many');\n return [];\n }\n if (!state.partial && rows.length < (field.min ?? 0)) refuse(state, path, 'too_few');\n return rows.map((row, index) => {\n const at = `${path}[${index}]`;\n const line: Record<string, unknown> = {};\n if (!plain(row) || Object.keys(row).some((key) => !field.show.includes(key))) {\n refuse(state, at, 'shape');\n return line;\n }\n for (const column of field.show) {\n const value = row[column];\n const cell = `${at}.${column}`;\n if (value === undefined || value === null || (typeof value === 'string' && !value.trim())) {\n if (!state.partial) refuse(state, cell, 'required');\n continue;\n }\n if (\n !(typeof value === 'string' && value.length <= 10_000 && !CONTROL.test(value)) &&\n !(typeof value === 'number' && Number.isFinite(value)) &&\n typeof value !== 'boolean'\n ) {\n refuse(state, cell, 'type');\n continue;\n }\n const read = state.cell ? state.cell(field.from, column, value) : { value: typeof value === 'string' ? value.trim() : value };\n if (typeof read === 'string') refuse(state, cell, read);\n else line[column] = read.value;\n }\n return line;\n });\n}\n\n/** The server's reading: the parsed input, or a CommandInputRefusal naming the first problem. */\nexport function readCommandInput(fields: readonly AppCommandField[], raw: unknown, options: ReadOptions = {}): Record<string, unknown> {\n if (!plain(raw)) throw new CommandInputRefusal('', 'shape');\n return readList(fields, raw, '', { ...options });\n}\n\n/** Every problem at once, for a form that marks each field that needs attention. */\nexport function commandInputProblems(\n fields: readonly AppCommandField[],\n raw: unknown,\n options: Pick<ReadOptions, 'cell' | 'sourced' | 'currency' | 'wire'> = {},\n): Array<{ path: string; reason: CommandInputReason }> {\n const state: State = { ...options, problems: [] };\n if (!plain(raw)) return [{ path: '', reason: 'shape' }];\n readList(fields, raw, '', state);\n return state.problems!;\n}\n\n/** The declared field a path names, with the rows it sits in read through: `vehicles[1].stock` is `vehicles` → `stock`. */\nexport function commandFieldAt(fields: readonly AppCommandField[], path: string): AppCommandField | undefined {\n let list: readonly AppCommandField[] = fields;\n let found: AppCommandField | undefined;\n for (const part of path.split('.')) {\n const name = part.replace(/\\[\\d+\\]$/, '');\n found = list.find((field) => field.name === name);\n if (!found) return undefined;\n list = found.type === 'group' ? found.fields : [];\n }\n return found;\n}\n","/** What CommandFields says, in the forms room (packages/kit/src/client/messages.ts says how the catalog is split). */\nimport { defineMessages } from '@mistriwork/kit/client/messages.js';\n\nexport const say = defineMessages({\n addRow: 'Add row',\n anEmailAddress: 'an email address',\n aWebAddressStarting: 'a web address, starting https://',\n aPhoneNumber: 'a phone number',\n theFormHasAnInput: 'The form has an input it does not ask for.',\n isRequired: '{label} is required.',\n requiredWord: '(required)',\n optionalWord: '(optional)',\n checkThisBoxTo: 'Check this box to continue.',\n mustBeAtLeast: '{label} must be at least {minLength} characters.',\n mustBeCharactersOrFewer: '{label} must be {maxLength} characters or fewer.',\n must: '{label} must be {value}.',\n isNotInTheForm: '{label} is not in the form it takes.',\n mustBeBefore: '{label} must be before {other}.',\n mustBeLessThan: '{label} must be less than {other}.',\n mustBeAfter: '{label} must be after {other}.',\n mustBeMoreThan: '{label} must be more than {other}.',\n hasCharactersAForm: '{label} has characters a form does not take.',\n mustBeASafe: '{label} must be a safe whole number.',\n hasMoreDecimalsThanTheCurrency: '{label} has more decimal places than the currency takes.',\n mustBeOnOrAfter: '{label} must be on or after {min}.',\n labelMustBeAt: '{label} must be at least {min}.',\n mustBeOnOrBefore: '{label} must be on or before {max}.',\n mustBeAtMost: '{label} must be at most {max}.',\n chooseLabel: 'Choose {label}.',\n takesAtMostRows: '{label} takes at most {max} rows.',\n mustBeANumber: '{label} must be a number.',\n mustBeYes: '{label} must be yes or no.',\n mustBeADate: '{label} must be a date.',\n mustBeADateAndTime: '{label} must be a date and time.',\n isNotInAForm: '{label} is not in a form it takes.',\n choosePlaceholder: 'Choose {label}',\n chooseOne: 'Choose one',\n groupRow: '{label}, row {index}',\n rowLabel: 'Row',\n removeRow: 'Remove row {index} of {label}',\n addRowTo: 'Add row to {label}',\n needsAtLeastRows: { one: '{label} needs at least {count} row.', other: '{label} needs at least {count} rows.' },\n rowMatch: 'row {match}',\n inTheFormItTakes: 'in the form it takes',\n chooseAlone: 'Choose {label} on its own, or another.',\n});\n","/**\n * A command's inputs, drawn: the controls the command modal and a command\n * form share. The declaration they draw is the one the server parses by —\n * one field list, in a browser-safe module — so what this checks before\n * anything is sent (`commandInput`, `commandProblems`, through the shared\n * reader) is what the server would refuse, in the person's words.\n *\n * A group is a section, headed by its label; a repeating group is its rows,\n * each added and removed here between the declared minimum and maximum; a\n * choice is radios when it has a few options and the tool's listbox when it\n * has more; a date is the date input the record editor uses, and a date\n * and time the same input with its clock, read in the App's time zone.\n * Questions defined in rows (`field.defined`) are a section of one control\n * per question, as prepare read them. A record's lines (`field.lines`) are the\n * lines grid (CommandLines.tsx), each cell read as its column's kind.\n */\nimport { Fragment, useRef, useState, type ReactElement } from 'react';\nimport type { AppCommandField } from '../../shared/command.js';\nimport type { DraftRule } from '../../shared/commandDraft.js';\nimport {\n CommandInputRefusal,\n commandFieldAt,\n commandInputProblems,\n readCommandInput,\n type CommandInputReason,\n} from '../../shared/commandInput.js';\nimport { toast } from '@mistriwork/kit/client/core.js';\nimport type { LineDraft } from './FormLines.js';\nimport { RichTextField, mentionSearch, pictureKeeper } from '@mistriwork/kit/client/components/RichTextField.js';\nimport type { CommandValue } from '../commandState.js';\nimport { Dropdown, readsAsName } from '@mistriwork/kit/client/components/Dropdown.js';\nimport { DateField } from '@mistriwork/kit/client/components/DateField.js';\nimport { defaultCurrency, formatLocale, formatTimezone } from '@mistriwork/kit/client/locale.js';\nimport { onDemand, useArrived } from '@mistriwork/kit/client/components/onDemand.js';\nimport { Button } from '@mistriwork/ui/Button.js';\nimport { Field } from '@mistriwork/ui/Field.js';\nimport { InputSlot } from '@mistriwork/kit/client/components/inputRenderers.js';\nimport { say } from '../copy/forms/components/CommandFields.js';\nimport type { DefinedField } from '@mistriwork/engine/shared/definedFields.js';\n\n/** A form's values while it is filled in: one per field, an object per group, rows per repeating group, a grid's lines. */\nexport type CommandValues = { [name: string]: CommandValue | CommandValues | CommandValues[] | LineDraft[] | undefined };\n\nexport type ValueField = Exclude<AppCommandField, { type: 'group' | 'lines' }>;\ntype GroupField = Extract<AppCommandField, { type: 'group' }>;\nexport type ReferenceField = Extract<AppCommandField, { type: 'reference' }>;\n\n/** Each `field.defined` input's questions, by input name, as prepare read them. */\nexport type CommandQuestions = Readonly<Record<string, readonly DefinedField[]>>;\n\n/* A date and a time: its zone arithmetic is fetched the first time one is drawn, never by a public form's first page. */\nconst DateTimeInput = onDemand(() => import('./DateTimeInput.js'), 'DateTimeInput', { quiet: true });\n/* The newer vocabulary — money, a month, a mask, a sensitive number, cards, buttons, several choices, a slider, a\n consent's statement — with the form controls' stylesheet: fetched the first time a form asks one. */\nconst IntakeControl = onDemand(() => import('./IntakeControls.js'), 'IntakeControl', { quiet: true });\nexport const CommandLive = onDemand(() => import('./CommandLive.js'), 'CommandLive', { quiet: true });\n/* The draft's logic — a `when` over the answers so far and the command's `rules`, judged by the condition compiler\n and the query language's comparisons (commandDraft.ts, formValues.ts) — fetched the first time a form asks it, so\n a public page whose form asks none (the landing, sign-in, a one-page form) carries none of it. A host that knows\n its form asks it has it here before drawing (FormSurface's formArrives, CommandForm's prepare); CommandFields\n draws nothing until it is, rather than questions that would vanish as it lands. Before it is here, nothing is\n hidden and no rule is said, which the server judges again in any case. */\nlet drafting: typeof import('../../shared/commandDraft.js') | undefined;\nlet draftArriving: Promise<void> | undefined;\nconst loadDraftLogic = (): Promise<void> =>\n (draftArriving ??= import('../../shared/commandDraft.js').then(\n (module) => {\n drafting = module;\n },\n (error: unknown) => {\n draftArriving = undefined;\n throw error;\n },\n ));\nexport const draftLogic = {\n ready: () => loadDraftLogic().catch(() => {}),\n here: () => drafting !== undefined,\n};\n/** Whether a form's fields — or the command's rules — ask the draft's logic: a `when` anywhere, or a rule. */\nexport function asksDraftLogic(fields: readonly AppCommandField[], rules?: readonly unknown[]): boolean {\n if (rules?.length) return true;\n return fields.some((field) => whenOf(field) !== undefined || (field.type === 'group' && asksDraftLogic(field.fields)));\n}\n/** Whether a condition reads the record (`record.<column>`): exact once the logic is here, a plain reading before. */\nexport const readsRecord = (when: string): boolean => (drafting ? drafting.readsRecord(when) : /\\brecord\\./.test(when));\n/* A record's lines: the grid, with the catalog's cells and the words for a cell, fetched the first time a form asks\n lines. A public form cannot ask them, so its first page carries none of it. The cells are judged here by kind once it\n has arrived, which it has by the time a grid is drawn; before then, and in any case, the server reads them again. */\nlet lining: typeof import('./CommandLines.js') | undefined;\n/** The lines module, fetched once: the grid is drawn from it, and a form's checks read a line's cells with it. */\nexport const loadLines = () =>\n import('./CommandLines.js').then((module) => {\n lining = module;\n return module;\n });\nconst CommandLines = onDemand(loadLines, 'CommandLines');\n\nconst asksLines = (fields: readonly AppCommandField[]): boolean =>\n fields.some((field) => field.type === 'lines' || (field.type === 'group' && asksLines(field.fields)));\n/**\n * What judging an input with no form drawn needs first: the draft's logic where a `when` or a rule asks it, and the\n * lines module where a field is a grid. A component's run judges an input before any form is drawn, and before these\n * have landed nothing is hidden: a question its condition hides was asked for, and its default sent (a field report).\n */\nexport function readyToJudge(fields: readonly AppCommandField[], rules?: readonly unknown[]): Promise<unknown> | undefined {\n const logic = asksDraftLogic(fields, rules) && !draftLogic.here();\n const lines = asksLines(fields) && !lining;\n // Nothing to wait for is no wait at all: a run that asks neither sends in the turn it was asked (its prepare first).\n if (!logic && !lines) return undefined;\n return Promise.all([logic ? draftLogic.ready() : undefined, lines ? loadLines().catch(() => {}) : undefined]);\n}\nconst lineAt = (fields: readonly AppCommandField[], path: string) => lining?.lineAt(fields, path);\n/* A typed amount is judged in the App's currency (a field's own `currency` first) and kept as typed, in its major units:\n the server reads it into the minor ones a handler receives. */\nconst cellReading = () => ({ currency: defaultCurrency(), wire: true, ...(lining ? { cell: lining.lineCellOf } : {}) });\n\n/* A grid line's own name, kept across moves (FormLines' blankLine, without loading the grid to make one). */\nlet lastLine = 0;\nconst draftLine = (values: Record<string, string> = {}): LineDraft => ({ id: -++lastLine, values });\nconst isLines = (value: unknown): value is LineDraft[] =>\n Array.isArray(value) && value.every((row) => !!row && typeof row === 'object' && 'values' in row && 'id' in row);\n\n/* A reference's picker (CommandReference.tsx) is drawn where there is somewhere to read its choices: a signed-in\n reader's connection, or a public form's App read signed out. Loaded when drawn, so a public form without one carries\n neither it nor the combobox. */\nconst CommandReferenceField = onDemand(() => import('./CommandReference.js'), 'CommandReferenceField', { quiet: true });\n\n/* Questions defined in rows, drawn and judged (CommandAnswers.tsx): only a signed-in record's command asks them, so a\n first page carries none of it. The answers are judged here once it has arrived, which it has by the time they are\n drawn; the server judges them again in any case. */\nlet answering: typeof import('./CommandAnswers.js') | undefined;\nconst DefinedAnswers = onDemand(\n () =>\n import('./CommandAnswers.js').then((module) => {\n answering = module;\n return module;\n }),\n 'DefinedAnswers',\n { quiet: true },\n);\nconst answerProblems = (fields: readonly AppCommandField[], values: CommandValues, questions?: CommandQuestions): [string, string][] =>\n questions && answering ? answering.answerProblems(fields, values, questions) : [];\n\n/** A choice with this many options or fewer is radios, all of them in view; more is a listbox. */\nconst RADIO_CHOICES = 4;\n/** Whether a choice is radios: as many as RADIO_CHOICES unless the field says `as: 'radios'` or `as: 'select'`. */\nconst asRadios = (field: { options: readonly unknown[]; as?: string }) =>\n field.as === 'radios' || (field.as !== 'select' && field.options.length <= RADIO_CHOICES);\n\n/* Which fields IntakeControls draws: said here too, so knowing it never fetches the chunk (IntakeControls' drawnHere agrees). */\nfunction drawnByIntake(field: AppCommandField): boolean {\n switch (field.type) {\n case 'money':\n case 'month':\n case 'choices':\n return true;\n case 'number':\n return field.as === 'slider';\n case 'text':\n return field.mask !== undefined || field.sensitive !== undefined;\n case 'boolean':\n return field.as === 'buttons' || field.statement !== undefined;\n case 'choice':\n return field.as === 'cards' || field.as === 'buttons' || field.source !== undefined;\n default:\n return false;\n }\n}\n\n/* A yes-or-no drawn as a box: unticked is its no. One asked as two buttons is a question like any other, unanswered\n until pressed, so it is required unless optional and says \"(optional)\" when it is. */\nconst isCheck = (field: AppCommandField): field is Extract<AppCommandField, { type: 'boolean' }> =>\n field.type === 'boolean' && field.as !== 'buttons';\n\nconst isValues = (value: unknown): value is CommandValues => !!value && typeof value === 'object' && !Array.isArray(value);\n\n/** Where a form starts: yes/no unticked, each group its own values, each repeating group its minimum rows. */\nexport function blankCommandValues(fields: readonly AppCommandField[]): CommandValues {\n const values: CommandValues = {};\n for (const field of fields) {\n /* A field's own default, as the form opens: a literal, the day in the App's time zone, the minute. The record's\n value and the reader's arrive with prepare, as `initial()`'s do. */\n const start = field.type === 'group' ? undefined : field.default;\n if (start !== undefined && typeof start !== 'object') values[field.name] = start;\n else if (typeof start === 'object' && 'auto' in start && start.auto !== 'me')\n values[field.name] =\n start.auto === 'today'\n ? new Intl.DateTimeFormat('en-CA', { timeZone: formatTimezone() }).format(new Date())\n : new Date(Math.floor(Date.now() / 60_000) * 60_000).toISOString();\n // A box unticked is an answer, no; a yes or a no asked as two buttons is unanswered until one is pressed, so a\n // question that waits on its no (`when: 'entry_ok = false'`) waits for it, and a required one is asked.\n else if (field.type === 'boolean' && field.as !== 'buttons') values[field.name] = false;\n else if (field.type === 'lines') values[field.name] = Array.from({ length: Math.max(field.min ?? 0, 1) }, () => draftLine());\n else if (field.type === 'group') {\n values[field.name] = field.repeat\n ? Array.from({ length: field.repeat.min ?? 0 }, () => blankCommandValues(field.fields))\n : blankCommandValues(field.fields);\n }\n }\n return values;\n}\n\n/** The blank form with the starting values the server served laid over it, field by field. */\nexport function prefilledCommandValues(fields: readonly AppCommandField[], initial: unknown): CommandValues {\n const values = blankCommandValues(fields);\n if (!isValues(initial)) return values;\n for (const field of fields) {\n if (!Object.hasOwn(initial, field.name)) continue;\n const value = initial[field.name];\n if (field.type === 'defined') {\n if (isValues(value)) values[field.name] = { ...value };\n } else if (field.type === 'lines') {\n if (Array.isArray(value))\n values[field.name] = value.map((row) =>\n draftLine(\n Object.fromEntries(\n field.show.flatMap((column) => {\n const held = isValues(row) ? row[column] : undefined;\n return typeof held === 'string' || typeof held === 'number' || typeof held === 'boolean' ? [[column, String(held)]] : [];\n }),\n ),\n ),\n );\n } else if (field.type !== 'group') {\n if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') values[field.name] = value;\n } else if (field.repeat) {\n if (Array.isArray(value)) values[field.name] = value.map((row) => prefilledCommandValues(field.fields, row));\n } else values[field.name] = prefilledCommandValues(field.fields, value);\n }\n return values;\n}\n\n/** The whole form a list of fields belongs to — a step's fields judge their `when` against every answer so far. */\ninterface CommandDraft {\n fields: readonly AppCommandField[];\n values: CommandValues;\n}\n\n/* A field's condition, where its kind takes one (a grid's lines take none). */\nconst whenOf = (field: AppCommandField): string | undefined => ('when' in field ? (field.when as string | undefined) : undefined);\n\n/* A value as it is read, for a condition: a number typed as text is the number. */\nfunction readValue(field: AppCommandField, value: Entry): unknown {\n if ((field.type === 'number' || field.type === 'money') && typeof value === 'string') return value.trim() ? Number(value) : '';\n return value;\n}\n\n/**\n * The fields of a list a draft's conditions hide (`when: 'entry_ok = false'`): each judged by the shared evaluator\n * (commandDraft.ts) against the answers so far, of the whole form where one is given. A `when` that still reads the\n * record has not been bound by prepare, so it is the server's to judge, and the field stays.\n */\nexport function draftHidden(fields: readonly AppCommandField[], values: CommandValues, whole?: CommandDraft): Set<string> {\n const hidden = new Set<string>();\n if (!fields.some((field) => whenOf(field) !== undefined)) return hidden;\n const all = whole ?? { fields, values };\n const read: Record<string, unknown> = {};\n for (const field of all.fields) read[field.name] = readValue(field, all.values[field.name]);\n for (const field of fields) read[field.name] = readValue(field, values[field.name]);\n const known = [...all.fields, ...fields.filter((field) => !all.fields.includes(field))];\n for (const field of fields) {\n const when = whenOf(field);\n if (when === undefined || readsRecord(when)) continue;\n if (drafting && !drafting.draftHolds(when, read, known)) hidden.add(field.name);\n }\n return hidden;\n}\n\n/** What is sent: a number typed as text read as a number, and nothing the declaration does not ask, nor a question its condition hides. */\nfunction submitted(fields: readonly AppCommandField[], values: CommandValues, whole?: CommandDraft): Record<string, unknown> {\n const result: Record<string, unknown> = {};\n const hidden = draftHidden(fields, values, whole);\n for (const field of fields) {\n if (hidden.has(field.name)) continue;\n const value = values[field.name];\n if (field.type === 'lines') {\n // Only what a line asks is sent: a copied column is the form's to show, and the handler reads that record itself.\n result[field.name] = (isLines(value) ? value : []).map((row) =>\n Object.fromEntries(field.show.flatMap((column) => (row.values[column] ? [[column, row.values[column]]] : []))),\n );\n } else if (field.type === 'group') {\n result[field.name] = field.repeat\n ? (Array.isArray(value) ? value : []).map((row) => submitted(field.fields, isValues(row) ? row : {}))\n : submitted(field.fields, isValues(value) ? value : {});\n } else if ((field.type === 'number' || field.type === 'money') && typeof value === 'string' && !(field.type === 'money' && field.minor))\n result[field.name] = value.trim() ? Number(value) : '';\n else if (value !== undefined) result[field.name] = value;\n }\n return result;\n}\n\nconst FORMAT_SENTENCES = { email: say('anEmailAddress'), url: say('aWebAddressStarting'), phone: say('aPhoneNumber') } as const;\n\n/** A field's sentence for what is wrong with it: its own label, and the rule it did not meet; a sibling rule names the sibling. */\nfunction sentence(fields: readonly AppCommandField[], path: string, reason: CommandInputReason): string {\n const line = lineAt(fields, path);\n if (line) {\n const label = line.label;\n return reason === 'required'\n ? say('isRequired', { label })\n : reason === 'choice'\n ? say('chooseLabel', { label })\n : reason === 'type'\n ? say('isNotInAForm', { label })\n : say('theFormHasAnInput');\n }\n const field = commandFieldAt(fields, path);\n if (!field) return say('theFormHasAnInput');\n const label = field.label;\n const date = field.type === 'date' || field.type === 'datetime';\n // A moment's bound is said in the App's time zone, as the field asks for it.\n const bound = (at: string | undefined) =>\n at && field.type === 'datetime'\n ? new Date(at).toLocaleString(formatLocale(), { timeZone: formatTimezone(), dateStyle: 'medium', timeStyle: 'short' })\n : (at ?? '');\n const text = field.type === 'text' || field.type === 'textarea' ? field : undefined;\n const most = text?.maxLength ?? (field.type === 'richText' ? field.maxLength : undefined);\n const sibling = (name: string | undefined) => {\n const within = path.includes('.') ? path.slice(0, path.lastIndexOf('.') + 1) : '';\n return (name && commandFieldAt(fields, `${within}${name}`)?.label) ?? name ?? '';\n };\n switch (reason) {\n // A box that must be checked is said at the box, which the reader is looking at.\n case 'required':\n return isCheck(field) ? say('checkThisBoxTo') : say('isRequired', { label });\n case 'too_short':\n return say('mustBeAtLeast', { label, minLength: text?.minLength ?? (field.type === 'richText' ? field.minLength : undefined) ?? '' });\n case 'too_long':\n return say('mustBeCharactersOrFewer', { label, maxLength: most ?? '' });\n case 'format':\n return text?.message ?? say('must', { label, value: text?.format ? FORMAT_SENTENCES[text.format] : say('inTheFormItTakes') });\n case 'pattern':\n return text?.message ?? say('isNotInTheForm', { label });\n case 'not_below': {\n const other = sibling((field as { below?: string }).below);\n return date ? say('mustBeBefore', { label, other }) : say('mustBeLessThan', { label, other });\n }\n case 'not_above': {\n const other = sibling((field as { above?: string }).above);\n return date ? say('mustBeAfter', { label, other }) : say('mustBeMoreThan', { label, other });\n }\n case 'text':\n return say('hasCharactersAForm', { label });\n case 'integer':\n return say('mustBeASafe', { label });\n case 'precision':\n return say('hasMoreDecimalsThanTheCurrency', { label });\n case 'below_min':\n return date\n ? say('mustBeOnOrAfter', { label, min: bound((field as { min?: string }).min) })\n : say('labelMustBeAt', { label, min: (field as { min?: number }).min ?? '' });\n case 'above_max':\n return date\n ? say('mustBeOnOrBefore', { label, max: bound((field as { max?: string }).max) })\n : say('mustBeAtMost', { label, max: (field as { max?: number }).max ?? '' });\n case 'choice':\n return say('chooseLabel', { label });\n case 'too_few': {\n const min = field.type === 'group' ? (field.repeat?.min ?? 0) : field.type === 'lines' ? (field.min ?? 0) : 0;\n return say('needsAtLeastRows', { label, count: min });\n }\n case 'too_many':\n return say('takesAtMostRows', {\n label,\n max: (field.type === 'group' ? field.repeat?.max : field.type === 'lines' ? field.max : 0) ?? '',\n });\n case 'type':\n return field.type === 'number'\n ? say('mustBeANumber', { label })\n : field.type === 'boolean'\n ? say('mustBeYes', { label })\n : date\n ? say(field.type === 'datetime' ? 'mustBeADateAndTime' : 'mustBeADate', { label })\n : field.type === 'reference'\n ? say('chooseLabel', { label })\n : say('isNotInAForm', { label });\n case 'shape':\n return say('isNotInAForm', { label });\n case 'exclusive':\n return say('chooseAlone', { label });\n }\n}\n\n/**\n * The words for where a path is: `Phone`, or `Applicant, Email`, or\n * `Trade-ins, row 2, Stock`. Undefined for a path the declaration does not have.\n */\nexport function commandPathLabel(fields: readonly AppCommandField[], path: string): string | undefined {\n const words: string[] = [];\n let list: readonly AppCommandField[] = fields;\n for (const part of path.split('.')) {\n const match = /^([A-Za-z_][A-Za-z0-9_]*)(?:\\[(\\d+)\\])?$/.exec(part);\n const field = match && list.find((item) => item.name === match[1]);\n if (!field) return undefined;\n words.push(field.label);\n if (match[2] !== undefined) words.push(say('rowMatch', { match: Number(match[2]) + 1 }));\n if (field.type === 'lines') {\n // A line's cell is a column of its row: the rest of the path is the column, said by its caption.\n const line = lineAt(fields, path);\n if (line && match[2] !== undefined) words.push(line.label);\n return line || !path.includes('.') ? words.join(', ') : undefined;\n }\n list = field.type === 'group' ? field.fields : [];\n }\n return words.join(', ');\n}\n\n/** How a list of fields is judged beyond itself: the whole form its `when`s read, and the command's rules. */\ninterface CommandJudging {\n whole?: CommandDraft;\n /** The command's rules (`rules`); each is said at its field where that field is in the list judged. */\n rules?: readonly DraftRule[];\n}\n\n/* A question its condition shows is required there, as the server judges it (judgeDraft); then each rule the\n answers break, at its field. Both by path, in the reader's words. */\nfunction draftProblems(fields: readonly AppCommandField[], values: CommandValues, judging: CommandJudging): Array<[string, string]> {\n const found: Array<[string, string]> = [];\n const hidden = draftHidden(fields, values, judging.whole);\n for (const field of fields) {\n const when = whenOf(field);\n if (when === undefined || hidden.has(field.name) || readsRecord(when) || field.type === 'group' || field.type === 'lines') continue;\n const value = values[field.name];\n const empty = value === undefined || value === null || value === '' || (Array.isArray(value) && !value.length);\n if (isCheck(field) ? field.accept === true && value !== true : field.required && empty)\n found.push([field.name, sentence(fields, field.name, 'required')]);\n }\n if (judging.rules?.length && drafting) {\n const all = judging.whole ?? { fields, values };\n const read = { ...submitted(all.fields, all.values), ...submitted(fields, values, judging.whole) };\n const names = new Set(fields.map((field) => field.name));\n for (const broken of drafting.brokenRules(judging.rules, read, [...all.fields, ...fields.filter((f) => !all.fields.includes(f))]))\n if (names.has(broken.field)) found.push([broken.field, broken.message]);\n }\n return found;\n}\n\n/** Every problem, by path, in the person's words: what a form marks beside each field. */\nexport function commandProblems(\n fields: readonly AppCommandField[],\n values: CommandValues,\n questions?: CommandQuestions,\n judging: CommandJudging = {},\n): Record<string, string> {\n const problems: Record<string, string> = {};\n for (const problem of commandInputProblems(fields, submitted(fields, values, judging.whole), cellReading())) {\n if (!Object.hasOwn(problems, problem.path)) problems[problem.path] = sentence(fields, problem.path, problem.reason);\n }\n for (const [path, said] of answerProblems(fields, values, questions)) if (!Object.hasOwn(problems, path)) problems[path] = said;\n for (const [path, said] of draftProblems(fields, values, judging)) if (!Object.hasOwn(problems, path)) problems[path] = said;\n return problems;\n}\n\n/** The input to send, parsed as the server will parse it, or an Error saying the first thing that needs attention. */\nexport function commandInput(\n fields: readonly AppCommandField[],\n values: CommandValues,\n questions?: CommandQuestions,\n judging: CommandJudging = {},\n): Record<string, unknown> {\n let input: Record<string, unknown>;\n try {\n input = readCommandInput(fields, submitted(fields, values, judging.whole), cellReading());\n } catch (error) {\n if (!(error instanceof CommandInputRefusal)) throw error;\n const said = sentence(fields, error.path, error.reason);\n // A field inside a group says which section, and which row.\n const within = error.path.includes('.') ? commandPathLabel(fields, error.path.slice(0, error.path.lastIndexOf('.'))) : undefined;\n throw new Error(within ? `${within}: ${said}` : said);\n }\n const [unanswered] = answerProblems(fields, values, questions);\n if (unanswered) {\n const field = fields.find((candidate) => candidate.name === unanswered[0].slice(0, unanswered[0].indexOf('.')));\n throw new Error(field ? `${field.label}: ${unanswered[1]}` : unanswered[1]);\n }\n const [drafted] = draftProblems(fields, values, judging);\n if (drafted) throw new Error(drafted[1]);\n return input;\n}\n\n/**\n * One value input as a control: text, textarea, number, yes/no, date, date\n * and time, or choice. The command modal and a command form both draw\n * through this; a reference is the picker below instead, and only where\n * there is a connection to read its directory from.\n */\nexport function CommandFieldControl({\n field,\n id,\n describedBy,\n invalid,\n value,\n disabled,\n onChange,\n connection,\n visitor,\n record,\n valid,\n onLeave,\n}: {\n field: Exclude<ValueField, { type: 'reference' | 'defined' }>;\n /** The intake style's valid check on a text or number box: present, the box keeps room for the mark; true draws it. */\n valid?: boolean;\n /** Focus has left the control: where the valid check is kept, it is judged from then on. */\n onLeave?: () => void;\n /** A public form's App, read signed out: where a choice from a table reads its rows. */\n visitor?: CommandFieldsShared['visitor'];\n /** Where a rich text input reads its people and keeps its pictures. */\n connection?: string;\n record?: CommandFieldsShared['record'];\n id: string;\n describedBy?: string;\n /** A problem is said beside the field; the field says it holds one, so a reader landing on it hears which. */\n invalid?: boolean;\n value: CommandValue | undefined;\n disabled?: boolean;\n onChange: (value: CommandValue) => void;\n}) {\n const common = {\n id,\n 'aria-describedby': describedBy,\n 'aria-invalid': invalid || undefined,\n required: field.required,\n className: 'field-control',\n disabled,\n ...(onLeave ? { onBlur: onLeave } : {}),\n };\n /* The mark at a box's inline end, in room the box keeps from the start, so its arriving moves no text. Decorative:\n validity is aria-invalid's to say (TextField's ValidMark, drawn in CSS). */\n const marked = (box: ReactElement, leaves = false) =>\n valid === undefined ? (\n box\n ) : (\n // A control drawn on demand takes no onBlur of its own; the box hears its input leave (focusout bubbles).\n <div className=\"field-box has-mark\" {...(leaves && onLeave ? { onBlur: onLeave } : {})}>\n {box}\n {valid ? <span className=\"field-mark\" aria-hidden=\"true\" /> : null}\n </div>\n );\n if (drawnByIntake(field)) {\n return marked(\n <IntakeControl\n field={field}\n id={id}\n aria-describedby={describedBy}\n aria-invalid={invalid || undefined}\n value={value}\n disabled={disabled}\n onChange={onChange}\n {...(connection !== undefined ? { source: connection } : visitor ? { source: { visitor } } : {})}\n />,\n true,\n );\n }\n if (field.type === 'boolean') {\n return (\n <input\n {...common}\n required={field.accept === true}\n className=\"command-check\"\n type=\"checkbox\"\n checked={value === true}\n onChange={(event) => onChange(event.target.checked)}\n />\n );\n }\n /* Formatted text: the editor, fetched the first time one is drawn; the server sanitizes what it sends. */\n if (field.type === 'richText') {\n return (\n <RichTextField\n id={id}\n label={field.label}\n describedBy={describedBy}\n invalid={invalid}\n disabled={disabled}\n value={typeof value === 'string' ? value : ''}\n onChange={onChange}\n {...(field.mentions && connection !== undefined ? { mentions: mentionSearch(field.mentions, connection) } : {})}\n {...(field.images && connection !== undefined && record\n ? (() => {\n const keep = pictureKeeper(field.images, record, connection);\n return keep ? { pictures: keep, onProblem: (message: string) => toast(message, 'error') } : {};\n })()\n : {})}\n />\n );\n }\n if (field.type === 'textarea') {\n return (\n <textarea\n {...common}\n rows={3}\n maxLength={field.maxLength}\n value={String(value ?? '')}\n onChange={(event) => onChange(event.target.value)}\n />\n );\n }\n if (field.type === 'choice') {\n const chosen = field.options.findIndex((option) => option.value === value);\n if (asRadios(field)) {\n return (\n <div\n className=\"command-choices\"\n role=\"radiogroup\"\n id={id}\n aria-labelledby={`${id}-label`}\n aria-describedby={describedBy}\n aria-required={field.required || undefined}\n aria-invalid={invalid || undefined}\n >\n {field.options.map((option, index) => (\n <label className=\"command-choice\" key={`${typeof option.value}:${option.value}`}>\n <input type=\"radio\" name={id} checked={index === chosen} disabled={disabled} onChange={() => onChange(option.value)} />\n {option.label}\n </label>\n ))}\n </div>\n );\n }\n // The tool's listbox, by position: a value may be a number, and a listbox's values are text.\n return (\n <Dropdown\n /* Named by the field's caption, as a <label> names a textbox: the words a reader\n sees, \"(required)\" with them. An aria-label of the bare name dropped it. */\n id={id}\n ariaLabelledBy={`${id}-label`}\n ariaInvalid={invalid}\n ariaDescribedBy={describedBy}\n disabled={disabled}\n value={chosen < 0 ? '' : String(chosen)}\n valueClassName={chosen < 0 ? 'is-empty' : undefined}\n items={[\n ...(chosen < 0\n ? [\n {\n value: '',\n label: readsAsName(field.label) ? say('choosePlaceholder', { label: field.label.toLowerCase() }) : say('chooseOne'),\n },\n ]\n : []),\n ...field.options.map((option, index) => ({ value: String(index), label: option.label })),\n ]}\n onChange={(next) => {\n if (next !== '') onChange(field.options[Number(next)].value);\n }}\n />\n );\n }\n if (field.type === 'date') {\n return (\n <DateField\n {...common}\n aria-label={`${field.label}${field.required ? ' (required)' : ''}`}\n min={field.min}\n max={field.max}\n locale={formatLocale()}\n timezone={formatTimezone()}\n value={String(value ?? '')}\n onChange={onChange}\n />\n );\n }\n if (field.type === 'datetime') {\n return (\n <DateTimeInput\n {...common}\n aria-label={`${field.label}${field.required ? ' (required)' : ''}`}\n min={field.min}\n max={field.max}\n value={typeof value === 'string' ? value : ''}\n onChange={onChange}\n />\n );\n }\n if (field.type === 'number') {\n const whole = field.integer || (field.step !== undefined && Number.isInteger(field.step));\n return marked(\n <input\n {...common}\n type=\"number\"\n min={field.min}\n max={field.max}\n step={field.step ?? (field.integer ? 1 : 'any')}\n inputMode={whole ? 'numeric' : 'decimal'}\n value={String(value ?? '')}\n onChange={(event) => onChange(event.target.value)}\n />,\n );\n }\n if (field.type !== 'text') return null;\n // The format picks the keyboard; the shared reader still judges the value.\n const type = field.format === 'email' ? 'email' : field.format === 'url' ? 'url' : field.format === 'phone' ? 'tel' : 'text';\n return marked(\n <input\n {...common}\n type={type}\n minLength={field.minLength}\n maxLength={field.maxLength}\n {...(field.case === 'upper' ? { autoCapitalize: 'characters' } : {})}\n value={String(value ?? '')}\n onChange={(event) => onChange(event.target.value)}\n />,\n );\n}\n\n/* A box the valid check stands in: a text or number box, an amount, a text typed through its mask. A sensitive value\n keeps its show button there, and a slider and every chooser say their state their own way. */\nconst markable = (field: AppCommandField): boolean =>\n ((field.type === 'money' || field.type === 'number') && field.as !== 'slider') ||\n (field.type === 'text' && field.sensitive === undefined);\n\n/* Whether an answer given is one its field's own rules take: its kind, its pattern, its bounds — judged alone, so a\n condition on another answer (`when`) does not hide it from the judging. */\nfunction ownRulesTake(field: AppCommandField, value: CommandValue | undefined): boolean {\n if (value === undefined || value === null || value === '') return false;\n const { when: _when, ...own } = field as AppCommandField & { when?: string };\n return (\n commandInputProblems([own as AppCommandField], submitted([own as AppCommandField], { [field.name]: value }), cellReading()).length === 0\n );\n}\n\nexport interface CommandFieldsShared {\n idPrefix: string;\n /** By path; each is drawn beside its field. Absent, the host says problems itself. */\n problems?: Readonly<Record<string, string>>;\n disabled?: boolean;\n /** Signed in: the connection a reference reads its choices from. Without one, or a visitor, a reference is not drawn. */\n connection?: string;\n /** A public form's: its App, read signed out, where a reference's choices are what `auth.public` opens. */\n visitor?: { app: string; via?: string };\n identityEpoch: number;\n isCurrent: () => boolean;\n /** Input name → the App's own input component (an action's or a form's `inputs`); one in a group by its path, `trade.vin`,\n which stands in every row of a repeating group. */\n inputs?: Readonly<Record<string, { id: string }>>;\n /** The record the command acts on, where it names one: a rich text input's pictures are kept as its attachments. */\n record?: { table: string; key: Record<string, unknown> };\n /** The query prepare bound to the record for each picker that reads it (`record.id`), by declared path; null\n when the record holds nothing to narrow by, and such a picker offers nothing. */\n bound?: Readonly<Record<string, string | null>>;\n /** The questions prepare read for each `field.defined` input; until it has, such an input draws nothing. */\n questions?: CommandQuestions;\n /** How the form around the fields is drawn: the intake style turns the valid check on, the stepper leaves it off. */\n presentation?: 'stepper' | 'intake';\n}\n\ntype Entry = CommandValues[string];\n\n/** The fields of one list — a command's, or a group's — each changing its own value in `values`. */\nexport function CommandFields({\n fields,\n values,\n onChange,\n whole,\n ...shared\n}: CommandFieldsShared & {\n fields: readonly AppCommandField[];\n values: CommandValues;\n /** The whole form, where these are one step's fields: their conditions read every answer so far. */\n whole?: CommandDraft;\n /** The whole next values, and the path of the field that changed: a host clears that field's problem. */\n onChange: (values: CommandValues, path: string) => void;\n}) {\n const logic = useArrived(draftLogic, asksDraftLogic(whole?.fields ?? fields));\n const hidden = draftHidden(fields, values, whole);\n if (!logic && asksDraftLogic(whole?.fields ?? fields)) return null;\n return (\n <>\n {fields\n .filter((field) => !hidden.has(field.name))\n .map((field) => {\n const entry = (\n <FieldEntry\n key={field.name}\n field={field}\n path={field.name}\n value={values[field.name]}\n shared={shared}\n onChange={(next, path) => onChange({ ...values, [field.name]: next }, path)}\n />\n );\n // A number's live lines (`live`), under it, read over every answer so far.\n if ((field.type !== 'number' && field.type !== 'money') || !field.live) return entry;\n return (\n <Fragment key={field.name}>\n {entry}\n <CommandLive\n field={field}\n fields={whole?.fields ?? fields}\n values={whole?.values ?? values}\n id={`${shared.idPrefix}-live-${field.name}`}\n />\n </Fragment>\n );\n })}\n </>\n );\n}\n\nfunction FieldEntry({\n field,\n path,\n value,\n onChange,\n shared,\n}: {\n field: AppCommandField;\n path: string;\n value: Entry;\n shared: CommandFieldsShared;\n onChange: (value: Entry, path: string) => void;\n}) {\n // Under its own `-field-` namespace: the page names its heading, its done\n // and review sections as `${idPrefix}-title` and the like, so an input\n // called `title` must never land on one of those ids (it left the region\n // unnamed and the textbox without a label).\n const id = `${shared.idPrefix}-field-${path.replace(/[^A-Za-z0-9_-]/g, '-')}`;\n const problem = shared.problems?.[path];\n /* The intake style's valid check: judged once the box has been left, so it never cheers a half-typed answer. */\n const [left, setLeft] = useState(false);\n if (field.type === 'defined')\n return (\n <DefinedAnswers field={field} id={id} path={path} value={value} shared={shared} onChange={onChange} Control={CommandFieldControl} />\n );\n if (field.type === 'lines')\n return (\n <div className=\"command-lines\">\n <CommandLines\n field={field}\n path={path}\n rows={isLines(value) ? value : []}\n problems={shared.problems}\n disabled={shared.disabled}\n onChange={(rows: LineDraft[], changed: string) => onChange(rows, changed)}\n />\n {shared.problems && (\n <span className=\"insert-missing\" aria-live=\"polite\" hidden={!problem}>\n {problem}\n </span>\n )}\n </div>\n );\n if (field.type === 'group') {\n const helpId = field.help ? `${id}-help` : undefined;\n const errorId = `${id}-error`;\n const describedBy = [helpId, problem ? errorId : undefined].filter(Boolean).join(' ') || undefined;\n return (\n <fieldset className={`command-group${field.repeat ? ' command-repeat' : ''}`} aria-describedby={describedBy}>\n <legend>{field.label}</legend>\n <div className=\"command-group-body\">\n {field.help && (\n <span id={helpId} className=\"command-help\">\n {field.help}\n </span>\n )}\n {field.repeat ? (\n <RepeatRows\n field={field}\n path={path}\n rows={Array.isArray(value) ? (value as CommandValues[]) : []}\n shared={shared}\n onChange={onChange}\n />\n ) : (\n <GroupFields field={field} path={path} values={isValues(value) ? value : {}} shared={shared} onChange={onChange} />\n )}\n {shared.problems && (\n <span id={errorId} className=\"insert-missing\" aria-live=\"polite\" hidden={!problem}>\n {problem}\n </span>\n )}\n </div>\n </fieldset>\n );\n }\n /* Several choices are the one list a value input holds; every other list or object is a group's or the grid's. */\n const scalar =\n field.type === 'choices'\n ? Array.isArray(value)\n ? (value as unknown as readonly (string | number)[])\n : undefined\n : isValues(value) || Array.isArray(value)\n ? undefined\n : (value as CommandValue | undefined);\n /* A yes-or-no is answered either way, so it is only \"required\" when it\n must be checked: a box that says required and takes no was a trap. */\n const needed = isCheck(field) ? field.accept === true : field.required;\n /* Required is said once to a sighted reader: the star (Field's `required`). The word stays in the label's text,\n hidden, so the control's name still carries it for a screen reader and a query by label. */\n const label = needed ? (\n <>\n {field.label}\n <span className=\"visually-hidden\"> {say('requiredWord')}</span>\n </>\n ) : (\n field.label\n );\n const radios = field.type === 'choice' && asRadios(field);\n const listbox = field.type === 'choice' && !radios;\n /* One Field: the label over the control, the help and then the problem\n under it, wired into the control's description. Radios and a listbox's\n button are named by the caption rather than a <label>. */\n /* A checkbox is drawn with its label beside it, and the label checks it:\n the one control whose name reads as a sentence to agree to. An App's own\n input for it keeps the label above, as every other control has. */\n const declared = path.replace(/\\[\\d+\\]/g, '');\n /* The form's own choice of component for this input first, then the field's (`input`, every form that asks it, a\n public one's too: its page loads the ones its payload says are served, sdk/publicInputs.ts). */\n const custom =\n shared.inputs && Object.hasOwn(shared.inputs, declared)\n ? shared.inputs[declared]\n : 'input' in field && typeof field.input === 'string'\n ? { id: field.input }\n : undefined;\n /* A consent beside its statement is drawn whole by its control, the box and the paragraph (IntakeControls): the label\n stays the box's name and the review's, read but not drawn, so it never stands as a narrow column beside them. */\n const stated = field.type === 'boolean' && field.statement !== undefined && !custom;\n const check = isCheck(field) && !custom && !stated;\n /* A yes or a no as two buttons is a question over its answers, named by its caption, as radios are. */\n const pair = field.type === 'boolean' && field.as === 'buttons' && !custom;\n /* A picker narrowed by the record reads the query prepare bound to it (the form opens once prepare answers). */\n const bound = shared.bound && Object.hasOwn(shared.bound, declared) ? shared.bound[declared] : undefined;\n return (\n <Field\n label={label}\n required={needed === true}\n optional={isCheck(field) ? undefined : say('optionalWord')}\n id={id}\n hint={field.help}\n problem={problem}\n group={radios || listbox || pair}\n check={check}\n labelHidden={stated}\n className=\"command-field\"\n >\n {(control) =>\n field.type === 'reference'\n ? (shared.connection !== undefined || shared.visitor) && (\n <CommandReferenceField\n field={bound === undefined ? field : { ...field, query: bound ?? '' }}\n id={id}\n describedBy={control['aria-describedby']}\n invalid={Boolean(problem)}\n connection={shared.connection ?? { visitor: shared.visitor! }}\n identityEpoch={shared.identityEpoch}\n disabled={shared.disabled === true || bound === null}\n value={scalar}\n isCurrent={shared.isCurrent}\n onChange={(next) => onChange(next, path)}\n />\n )\n : (() => {\n const marks = shared.presentation === 'intake' && markable(field);\n const platform = (\n <CommandFieldControl\n field={field}\n id={id}\n describedBy={control['aria-describedby']}\n invalid={Boolean(problem)}\n {...(marks\n ? { valid: left && !problem && ownRulesTake(field, scalar as CommandValue | undefined), onLeave: () => setLeft(true) }\n : {})}\n value={scalar}\n disabled={shared.disabled}\n onChange={(next) => onChange(next, path)}\n {...(shared.connection === undefined ? {} : { connection: shared.connection })}\n {...(shared.visitor ? { visitor: shared.visitor } : {})}\n {...(shared.record ? { record: shared.record } : {})}\n />\n );\n /* The App's own input, where it names one for this input: the form still keeps, checks and sends the value. */\n return custom ? (\n <InputSlot\n component={custom.id}\n fallback={platform}\n value={Array.isArray(scalar) ? null : ((scalar as string | number | boolean | undefined) ?? null)}\n onChange={(next) => onChange(next as CommandValue, path)}\n id={id}\n describedBy={control['aria-describedby']}\n invalid={Boolean(problem)}\n disabled={shared.disabled === true}\n required={field.required === true}\n label={field.label}\n field={{ name: field.name }}\n context=\"command\"\n />\n ) : (\n platform\n );\n })()\n }\n </Field>\n );\n}\n\nfunction GroupFields({\n field,\n path,\n values,\n shared,\n onChange,\n}: {\n field: GroupField;\n path: string;\n values: CommandValues;\n shared: CommandFieldsShared;\n onChange: (value: Entry, path: string) => void;\n}) {\n const hidden = draftHidden(field.fields, values);\n return (\n <div className=\"command-fields\">\n {field.fields\n .filter((member) => !hidden.has(member.name))\n .map((member) => (\n <FieldEntry\n key={member.name}\n field={member}\n path={`${path}.${member.name}`}\n value={values[member.name]}\n shared={shared}\n onChange={(next, changed) => onChange({ ...values, [member.name]: next }, changed)}\n />\n ))}\n </div>\n );\n}\n\n/** A repeating group's rows, from its minimum to its maximum; each row is the group's fields again. */\nfunction RepeatRows({\n field,\n path,\n rows,\n shared,\n onChange,\n}: {\n field: GroupField;\n path: string;\n rows: CommandValues[];\n shared: CommandFieldsShared;\n onChange: (value: Entry, path: string) => void;\n}) {\n // Rows are keyed by when they were added, not where they sit: removing one keeps the others' pickers and focus.\n const keys = useRef<number[]>([]);\n const next = useRef(0);\n while (keys.current.length < rows.length) keys.current.push(next.current++);\n if (keys.current.length > rows.length) keys.current.length = rows.length;\n const min = field.repeat?.min ?? 0,\n max = field.repeat?.max ?? 0;\n return (\n <>\n {rows.map((row, index) => (\n <div\n className=\"command-row\"\n role=\"group\"\n aria-label={say('groupRow', { label: field.label, index: index + 1 })}\n key={keys.current[index]}\n >\n <div className=\"command-row-head\">\n <span className=\"command-row-number\">\n {say('rowLabel')} {index + 1}\n </span>\n <Button\n intent=\"secondary\"\n size=\"compact\"\n disabled={shared.disabled || rows.length <= min}\n aria-label={say('removeRow', { index: index + 1, label: field.label })}\n onClick={() => {\n keys.current.splice(index, 1);\n onChange(\n rows.filter((_, other) => other !== index),\n path,\n );\n }}\n >\n {say('common.remove')}\n </Button>\n </div>\n <GroupFields\n field={field}\n path={`${path}[${index}]`}\n values={row}\n shared={shared}\n onChange={(value, changed) =>\n onChange(\n rows.map((item, other) => (other === index ? (value as CommandValues) : item)),\n changed,\n )\n }\n />\n </div>\n ))}\n <div className=\"command-repeat-actions\">\n <Button\n intent=\"secondary\"\n disabled={shared.disabled || rows.length >= max}\n aria-label={say('addRowTo', { label: field.label })}\n onClick={() => onChange([...rows, blankCommandValues(field.fields)], path)}\n >\n {say('addRow')}\n </Button>\n </div>\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAkBA,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