@nice2dev/ui 1.2.0 → 1.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (229) hide show
  1. package/CHANGELOG.md +150 -0
  2. package/dist/NiceApiExplorer.doc-CFJndg5h.js +25 -0
  3. package/dist/NiceApiExplorer.doc-TEx67kV5.cjs +1 -0
  4. package/dist/NiceBPMNDesigner.doc-6lK1pXRq.js +32 -0
  5. package/dist/NiceBPMNDesigner.doc-BY8t7qOi.cjs +8 -0
  6. package/dist/NiceBackupDiffViewer.doc-CYvOeX19.js +25 -0
  7. package/dist/NiceBackupDiffViewer.doc-ChQaZCg1.cjs +1 -0
  8. package/dist/NiceBackupList.doc-BdQCw0_D.cjs +1 -0
  9. package/dist/NiceBackupList.doc-BwjIAoqz.js +25 -0
  10. package/dist/NiceBackupRestoreDialog.doc-B2iiqTps.cjs +1 -0
  11. package/dist/NiceBackupRestoreDialog.doc-DuXSGJiD.js +25 -0
  12. package/dist/NiceBackupScheduler.doc-BpY45181.js +31 -0
  13. package/dist/NiceBackupScheduler.doc-ByeL3iH1.cjs +7 -0
  14. package/dist/NiceBackupStatusBadge.doc-BA3dYgiW.cjs +1 -0
  15. package/dist/NiceBackupStatusBadge.doc-CxwkVarP.js +25 -0
  16. package/dist/NiceBackupTagEditor.doc-Bej1KHco.cjs +7 -0
  17. package/dist/NiceBackupTagEditor.doc-CNy4uNws.js +31 -0
  18. package/dist/NiceBottomSheet.doc-keq-Fzlz.cjs +8 -0
  19. package/dist/NiceBottomSheet.doc-v-UPUKQk.js +32 -0
  20. package/dist/NiceBranchManager.doc-BTyRjX7X.cjs +6 -0
  21. package/dist/NiceBranchManager.doc-Cz4SyEqE.js +30 -0
  22. package/dist/NiceButton-3AcJJ15c.cjs +1 -0
  23. package/dist/NiceButton-vkI07DP0.js +88 -0
  24. package/dist/NiceCodeEditor-C43xFG8v.cjs +260 -0
  25. package/dist/NiceCodeEditor-CspuYLh6.js +1174 -0
  26. package/dist/NiceCodeEditor-VGIDWSkS.js +1181 -0
  27. package/dist/NiceCodeEditor-qX39PSnQ.cjs +260 -0
  28. package/dist/NiceColorPicker-CQhhjZ8w.cjs +1 -0
  29. package/dist/NiceColorPicker-Cbop7VMu.js +491 -0
  30. package/dist/NiceConnectorConfigForm.doc-BKrDuhXw.cjs +7 -0
  31. package/dist/NiceConnectorConfigForm.doc-BsHeXz3M.js +31 -0
  32. package/dist/NiceDataBranchGraph.doc-Axidz41W.js +29 -0
  33. package/dist/NiceDataBranchGraph.doc-sjLmrrtE.cjs +5 -0
  34. package/dist/NiceDataBranchManager.doc-B1-Rp2X4.cjs +6 -0
  35. package/dist/NiceDataBranchManager.doc-GUqfTFvW.js +30 -0
  36. package/dist/NiceDataConflictResolver.doc-CjQryrTu.cjs +5 -0
  37. package/dist/NiceDataConflictResolver.doc-L-TcnQMX.js +29 -0
  38. package/dist/NiceDataDiffViewer.doc-BzGrf0U-.cjs +6 -0
  39. package/dist/NiceDataDiffViewer.doc-goxhSldH.js +30 -0
  40. package/dist/NiceDataGrid-BDEIbuBS.js +2218 -0
  41. package/dist/NiceDataGrid-CS5aB-EN.cjs +10 -0
  42. package/dist/NiceDataGrid-CrD4HPlO.cjs +10 -0
  43. package/dist/NiceDataGrid-Dfg1DVbU.js +2224 -0
  44. package/dist/NiceDataMapper.doc-QmnmnvVq.js +30 -0
  45. package/dist/NiceDataMapper.doc-ytGVtYVr.cjs +6 -0
  46. package/dist/NiceDataMergeBuilder.doc-BcmzKxh2.cjs +6 -0
  47. package/dist/NiceDataMergeBuilder.doc-BvYa4aUJ.js +30 -0
  48. package/dist/NiceDataSnapshot.doc-C73K1biG.cjs +6 -0
  49. package/dist/NiceDataSnapshot.doc-hU7wnOzM.js +30 -0
  50. package/dist/NiceDesktopViews.doc-DJjYlyP2.cjs +1 -0
  51. package/dist/NiceDesktopViews.doc-ly-VUAJj.js +25 -0
  52. package/dist/NiceDeviceControlCard.doc-BZIo92-w.cjs +1 -0
  53. package/dist/NiceDeviceControlCard.doc-DIzZcW9L.js +25 -0
  54. package/dist/NiceDocumentViewer-B9VIVKyw.js +726 -0
  55. package/dist/NiceDocumentViewer-CDXAmPp7.cjs +180 -0
  56. package/dist/NiceDocumentationViewer.doc-BSNGa7a_.js +25 -0
  57. package/dist/NiceDocumentationViewer.doc-CrwlvPFg.cjs +1 -0
  58. package/dist/NiceEnergyChart.doc-DW-jllDV.cjs +1 -0
  59. package/dist/NiceEnergyChart.doc-DnEehTff.js +25 -0
  60. package/dist/NiceFeatureGate.doc-DN17uS_B.cjs +3 -0
  61. package/dist/NiceFeatureGate.doc-DNfFSRrh.js +27 -0
  62. package/dist/NiceForm-BcN4p2kG.cjs +1 -0
  63. package/dist/NiceForm-CISJyzoW.cjs +1 -0
  64. package/dist/NiceForm-DmH6k1b_.js +4775 -0
  65. package/dist/NiceForm-tIXS-M6b.js +4770 -0
  66. package/dist/NiceFormItem.doc-BJwEnDz2.js +36 -0
  67. package/dist/NiceFormItem.doc-Ck3PgaPD.cjs +12 -0
  68. package/dist/NiceGantt-CHnq-n8f.cjs +1 -0
  69. package/dist/NiceGantt-CTbqCuwv.cjs +1 -0
  70. package/dist/NiceGantt-CX3jVNaF.js +330 -0
  71. package/dist/NiceGantt-Dao7pN9z.js +328 -0
  72. package/dist/NiceGantt.doc-B6YZcJvG.cjs +11 -0
  73. package/dist/NiceGantt.doc-DsI1QXly.js +48 -0
  74. package/dist/NiceGitBlame.doc-BQ2KvGkD.js +30 -0
  75. package/dist/NiceGitBlame.doc-DuTSjZVN.cjs +6 -0
  76. package/dist/NiceGitDiffViewer.doc-D24AGos_.js +30 -0
  77. package/dist/NiceGitDiffViewer.doc-D9FVquBC.cjs +6 -0
  78. package/dist/NiceGitGraph.doc-C-8VGMIz.js +29 -0
  79. package/dist/NiceGitGraph.doc-eRvTmefl.cjs +5 -0
  80. package/dist/NiceGitHooks.doc-DCTVw7HX.cjs +5 -0
  81. package/dist/NiceGitHooks.doc-OCFj5w6v.js +29 -0
  82. package/dist/NiceHtmlEditor-DUwcqj5N.cjs +10 -0
  83. package/dist/NiceHtmlEditor-DeK0Of98.js +883 -0
  84. package/dist/NiceHtmlEditor-DiAphF1k.js +889 -0
  85. package/dist/NiceHtmlEditor-DvVxl4Fu.cjs +10 -0
  86. package/dist/NiceInstanceMonitor.doc-BSDZp5xa.js +31 -0
  87. package/dist/NiceInstanceMonitor.doc-HVbLufnh.cjs +7 -0
  88. package/dist/NiceLocaleManager.doc-CbVHDEWu.js +25 -0
  89. package/dist/NiceLocaleManager.doc-XH6hMW0Z.cjs +1 -0
  90. package/dist/NiceLockButton.doc-BMhSj3TB.cjs +1 -0
  91. package/dist/NiceLockButton.doc-DvHGhcfm.js +25 -0
  92. package/dist/NiceLoginForm-CHXbz0eu.js +747 -0
  93. package/dist/NiceLoginForm-DQe77Isv.js +747 -0
  94. package/dist/NiceLoginForm-NBCo-DUZ.cjs +1 -0
  95. package/dist/NiceLoginForm-ix6J1adA.cjs +1 -0
  96. package/dist/NiceLoginForm.css +1 -1
  97. package/dist/NiceMAM.doc-CsQ57saR.cjs +8 -0
  98. package/dist/NiceMAM.doc-hjW7buTH.js +32 -0
  99. package/dist/NiceMention--3P3vO-W.cjs +430 -0
  100. package/dist/NiceMention-Co2cqkVM.js +11316 -0
  101. package/dist/NiceMention-DKhk3xdM.js +11321 -0
  102. package/dist/NiceMention-wp1AJ5oh.cjs +430 -0
  103. package/dist/NiceMention.css +1 -1
  104. package/dist/NiceModal-BbQwiEOp.cjs +1 -0
  105. package/dist/NiceModal-DQEfTcnZ.js +85 -0
  106. package/dist/NiceModuleLifecyclePanel-22CEEVbA.cjs +1 -0
  107. package/dist/NiceModuleLifecyclePanel-BCd9Wv5Y.js +6825 -0
  108. package/dist/NiceModuleLifecyclePanel-DV3F_QdI.cjs +1 -0
  109. package/dist/NiceModuleLifecyclePanel-gaZkIEtK.js +6825 -0
  110. package/dist/NiceModuleLifecyclePanel.css +1 -1
  111. package/dist/NiceNetworkDiscoveryPanel.doc-B0RtGaS3.js +25 -0
  112. package/dist/NiceNetworkDiscoveryPanel.doc-BFgFZI5G.cjs +1 -0
  113. package/dist/NicePagination-B3nZDZem.js +165 -0
  114. package/dist/NicePagination-B8rg1Y67.cjs +1 -0
  115. package/dist/NicePagination-BFGt1v0a.js +165 -0
  116. package/dist/NicePagination-DltL3-Sz.cjs +1 -0
  117. package/dist/NicePipelineEditor.doc-CjqDKe2x.js +29 -0
  118. package/dist/NicePipelineEditor.doc-DZ0pTVTp.cjs +5 -0
  119. package/dist/NicePipelineMonitor.doc-C88-TagI.cjs +5 -0
  120. package/dist/NicePipelineMonitor.doc-CFtH4XJx.js +29 -0
  121. package/dist/NicePivotGrid-BD87Na7P.js +1163 -0
  122. package/dist/NicePivotGrid-BPmnvbPQ.cjs +152 -0
  123. package/dist/NicePivotGrid-BaZa2YZW.js +1157 -0
  124. package/dist/NicePivotGrid-DyOPhPO8.cjs +152 -0
  125. package/dist/NiceRoomGrid.doc-DJPVUQVg.cjs +8 -0
  126. package/dist/NiceRoomGrid.doc-DLHJS_Wb.js +32 -0
  127. package/dist/NiceSavedQueryPanel-BC84uRfh.cjs +586 -0
  128. package/dist/NiceSavedQueryPanel-BSTiZvFg.js +5130 -0
  129. package/dist/NiceSavedQueryPanel-CMfcODIO.js +5120 -0
  130. package/dist/NiceSavedQueryPanel-DrR3sw4T.cjs +586 -0
  131. package/dist/NiceSavedQueryPanel.css +1 -1
  132. package/dist/NiceSceneBar.doc-09sc3yuF.cjs +1 -0
  133. package/dist/NiceSceneBar.doc-DLePMuVU.js +25 -0
  134. package/dist/NiceSceneSelector.doc-CPzCAy-d.cjs +7 -0
  135. package/dist/NiceSceneSelector.doc-FCLZvPc0.js +31 -0
  136. package/dist/NiceScheduler-BAJRzFQN.js +1690 -0
  137. package/dist/NiceScheduler-DvxJ8N0I.js +1698 -0
  138. package/dist/NiceScheduler-TIksdF0k.cjs +5 -0
  139. package/dist/NiceScheduler-dJ7gHDv7.cjs +5 -0
  140. package/dist/NiceSchedulerViews.doc-C9opZpgg.cjs +1 -0
  141. package/dist/NiceSchedulerViews.doc-Dy7ZH1iL.js +25 -0
  142. package/dist/NiceSelect-CZR8Zu_k.js +420 -0
  143. package/dist/NiceSelect-DIKGbaJo.cjs +1 -0
  144. package/dist/NiceSensorGaugePanel.doc-BHirbWLn.cjs +8 -0
  145. package/dist/NiceSensorGaugePanel.doc-DjKmooI6.js +32 -0
  146. package/dist/NiceSpotlight.doc-BVZFfDVI.cjs +10 -0
  147. package/dist/NiceSpotlight.doc-JqwkzrEm.js +34 -0
  148. package/dist/NiceStateDesigner.doc-CfnwiwfU.js +29 -0
  149. package/dist/NiceStateDesigner.doc-DV4zEC50.cjs +5 -0
  150. package/dist/NiceStepper.doc-5VjaLM6r.js +31 -0
  151. package/dist/NiceStepper.doc-f8lYpr33.cjs +7 -0
  152. package/dist/NiceTaskInbox.doc-CHrxthqp.js +32 -0
  153. package/dist/NiceTaskInbox.doc-CdCTfgBq.cjs +8 -0
  154. package/dist/NiceTestBuilder.doc-BoBzLfa0.js +30 -0
  155. package/dist/NiceTestBuilder.doc-Cj1fNTvk.cjs +6 -0
  156. package/dist/NiceTranscoder.doc-Dnirl3wg.cjs +7 -0
  157. package/dist/NiceTranscoder.doc-cInCYZh7.js +31 -0
  158. package/dist/NiceVideoAnnotator.doc-C1iEi7OM.cjs +7 -0
  159. package/dist/NiceVideoAnnotator.doc-C8zyfKH_.js +31 -0
  160. package/dist/NiceVideoEditor.doc-C6mhEb-q.cjs +7 -0
  161. package/dist/NiceVideoEditor.doc-lrwmKjqj.js +31 -0
  162. package/dist/NiceWindow-CWN8OCHF.js +2109 -0
  163. package/dist/NiceWindow-Dd8qjkIW.cjs +1 -0
  164. package/dist/NiceWindow.css +1 -1
  165. package/dist/charts-Bo2WAI5T.cjs +768 -0
  166. package/dist/charts-BpELGDXh.cjs +768 -0
  167. package/dist/charts-ByrdMeQP.js +4767 -0
  168. package/dist/charts-M6LuVI7F.js +4776 -0
  169. package/dist/charts.cjs +1 -1
  170. package/dist/charts.css +1 -1
  171. package/dist/charts.d.ts +28 -46
  172. package/dist/charts.mjs +1 -1
  173. package/dist/core-B8eBUE4m.js +438 -0
  174. package/dist/core-lBFqvT0V.cjs +1 -0
  175. package/dist/core-lazy-Bh2yg4Et.js +351 -0
  176. package/dist/core-lazy-CkWKjfc6.cjs +1 -0
  177. package/dist/core-lazy-Ctin_LwS.cjs +1 -0
  178. package/dist/core-lazy-iDiropM6.js +351 -0
  179. package/dist/data-branching-BgIAw01q.cjs +1 -0
  180. package/dist/data-branching-Dak1_ZKR.cjs +1 -0
  181. package/dist/data-branching-DiLAO4Qt.js +6386 -0
  182. package/dist/data-branching-bvB9K6KS.js +6386 -0
  183. package/dist/data-branching.cjs +1 -1
  184. package/dist/data-branching.mjs +1 -1
  185. package/dist/data.cjs +1 -1
  186. package/dist/data.d.ts +22 -18
  187. package/dist/data.mjs +3 -3
  188. package/dist/devops-Bp-_aA-9.js +8682 -0
  189. package/dist/devops-CXBSjnyX.cjs +17 -0
  190. package/dist/devops-DkVluHBp.cjs +17 -0
  191. package/dist/devops-zsMUueTd.js +8648 -0
  192. package/dist/devops.cjs +1 -1
  193. package/dist/devops.d.ts +3 -3
  194. package/dist/devops.mjs +1 -1
  195. package/dist/editors.cjs +1 -1
  196. package/dist/editors.d.ts +100 -38
  197. package/dist/editors.mjs +8 -8
  198. package/dist/feedback.cjs +1 -1
  199. package/dist/feedback.d.ts +71 -2
  200. package/dist/feedback.mjs +10 -9
  201. package/dist/index.cjs +263 -263
  202. package/dist/index.css +1 -1
  203. package/dist/index.d.ts +641 -253
  204. package/dist/index.mjs +26438 -26260
  205. package/dist/injectStyleOnce-BzC_BCs_.js +9 -0
  206. package/dist/injectStyleOnce-DeWaxcdf.cjs +1 -0
  207. package/dist/lazy.cjs +1 -1
  208. package/dist/lazy.d.ts +9 -7
  209. package/dist/lazy.mjs +51 -51
  210. package/dist/navigation.cjs +1 -1
  211. package/dist/navigation.css +1 -0
  212. package/dist/navigation.d.ts +99 -43
  213. package/dist/navigation.mjs +504 -547
  214. package/dist/no-code-BNFk_BDO.js +8275 -0
  215. package/dist/no-code-CFdTp543.cjs +331 -0
  216. package/dist/no-code-DiTEnuRv.js +8288 -0
  217. package/dist/no-code-wG9c0z_T.cjs +331 -0
  218. package/dist/no-code.cjs +1 -1
  219. package/dist/no-code.css +1 -1
  220. package/dist/no-code.mjs +1 -1
  221. package/dist/overlays.cjs +1 -1
  222. package/dist/overlays.d.ts +12 -6
  223. package/dist/overlays.mjs +1 -1
  224. package/dist/pickerCommons-BCRiHDE_.cjs +1 -0
  225. package/dist/pickerCommons-CMxFt9SW.js +548 -0
  226. package/dist/pickerCommons-Dc_hlz-e.cjs +1 -0
  227. package/dist/pickerCommons-DkumQ3KE.js +548 -0
  228. package/dist/style.css +12 -9
  229. package/package.json +3 -3
@@ -0,0 +1,331 @@
1
+ "use strict";const e=require("react/jsx-runtime"),a=require("@nice2dev/ui-core"),x=require("react"),le=require("./devops-DkVluHBp.cjs"),we=Object.assign(x.forwardRef(({label:o,checked:S=!1,indeterminate:b=!1,onChange:j,disabled:$,readOnly:v,loading:k,required:d,size:C="md",name:r,id:i,className:p,style:z,error:w,helperText:I,accessMode:q,displayStyle:G,showKeyboardHints:O,labelPlacement:T,errorPlacement:B,labelWidth:H,controlWidth:M},m)=>{const D=a.useNiceAccessMode(q,i),F=D==="hidden";(D==="disabled"||D==="readOnly")&&($=!0);const{t:Y}=a.useNiceTranslation(),_=a.useControlId(i);a.useComponentDisplayClass("toggle",G);const Z=x.useMemo(()=>[{key:"Space",description:Y("shortcuts.toggle","Toggle")}],[Y]),E=x.useCallback(V=>{V&&(V.indeterminate=b),typeof m=="function"?m(V):m&&(m.current=V)},[b,m]);return F?null:e.jsxs("div",{className:`nice-field nice-field--inline nice-field--${C} ${T==="left"?"nice-field--label-left":""} ${B==="right"?"nice-field--error-right":""} ${k?"nice-field--loading":""} ${p||""}`,style:{...z,...H!=null&&{"--nice-field-label-width":typeof H=="number"?`${H}px`:H},...M!=null&&{"--nice-field-control-width":typeof M=="number"?`${M}px`:M}},"aria-busy":k||void 0,children:[T==="left"&&o&&e.jsx("span",{className:`nice-field__label ${d?"nice-field__label--required":""}`,children:o}),e.jsxs("div",{className:"nice-field__control",children:[e.jsxs("label",{className:`nice-checkbox ${C!=="md"?`nice-checkbox--${C}`:""} ${$||k?"nice-checkbox--disabled":""}`,htmlFor:_,children:[e.jsx("input",{ref:E,id:_,type:"checkbox",className:"nice-checkbox__input",name:r,checked:S,disabled:$||k,readOnly:v,"aria-invalid":!!w,onChange:V=>{v||k||j?.(V.target.checked)}}),e.jsx("span",{className:"nice-checkbox__box",children:e.jsx("svg",{viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:S?e.jsx("polyline",{points:"2 6 5 9 10 3"}):e.jsx("line",{x1:"2",y1:"6",x2:"10",y2:"6"})})}),T!=="left"&&o&&e.jsx("span",{children:o}),O&&e.jsx(a.NiceKeyboardHint,{shortcuts:Z,size:"sm"})]}),k&&e.jsx("span",{className:"nice-field__spinner",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})}),B==="right"&&w&&e.jsx("div",{id:`${_}-error`,className:"nice-field__error",role:"alert",children:w}),B==="right"&&!w&&I&&e.jsx("div",{id:`${_}-helper`,className:"nice-field__helper",children:I})]}),B!=="right"&&w&&e.jsx("div",{id:`${_}-error`,className:"nice-field__error",role:"alert",children:w}),B!=="right"&&!w&&I&&e.jsx("div",{id:`${_}-helper`,className:"nice-field__helper",children:I})]})}),{displayName:"NiceCheckbox"}),it=Object.freeze(Object.defineProperty({__proto__:null,NiceCheckbox:we},Symbol.toStringTag,{value:"Module"})),ke=Object.assign(x.forwardRef(({label:o,helperText:S,error:b,required:j,disabled:$,readOnly:v,size:k="md",name:d,id:C,className:r,style:i,accessMode:p,displayStyle:z,value:w,onChange:I,onBlur:q,onKeyDown:G,placeholder:O,min:T,max:B,step:H=1,precision:M,prefix:m,prefixType:D="label",prefixOptions:F,prefixValue:Y,onPrefixChange:_,suffix:Z,showStepper:E=!0,submitOnEnter:V,onSubmit:h,showKeyboardHints:t,labelPlacement:n,errorPlacement:g,loading:f,labelWidth:s,controlWidth:N,formatPreset:l,format:Q,suffixType:te="label",suffixOptions:c,suffixValue:ee,onSuffixChange:u,suffixSeparator:W=!1,displayMode:J},K)=>{const L=a.useNiceAccessMode(p,C),y=L==="hidden";L==="disabled"&&($=!0),L==="readOnly"&&(v=!0);const{t:P}=a.useNiceTranslation(),A=a.useControlId(C),X=a.useComponentDisplayStyle("input",z),ae=a.useComponentDisplayClass("input",z),[de,$e]=x.useState(!1),[ye,ve]=x.useState(null),me=a.useDisplayModeEdit({enabled:J,readOnly:v,disabled:$}),Ze=x.useMemo(()=>{let R=3;return B!=null&&(R=String(Math.abs(Math.floor(B))).length),T!=null&&T<0&&(R+=1),M&&(R+=M+1),Math.max(3,R)+1},[B,T,M]),Ce=x.useCallback(R=>{if(Q)return Q(R);if(!l)return M!=null?R.toFixed(M):String(R);switch(l){case"integer":return Math.round(R).toLocaleString();case"decimal":return R.toLocaleString(void 0,{minimumFractionDigits:M??2,maximumFractionDigits:M??2});case"money":return R.toLocaleString(void 0,{minimumFractionDigits:M??2,maximumFractionDigits:M??2,useGrouping:!0});case"percent":return(R*100).toLocaleString(void 0,{minimumFractionDigits:M??0,maximumFractionDigits:M??2})+"%";default:return String(R)}},[Q,l,M]),ge=x.useMemo(()=>de&&ye!==null?ye:w==null?"":de?M!=null?w.toFixed(M):String(w):Ce(w),[w,de,ye,Ce,M]),Qe=w!=null&&w<0,Xe=!!(m||D==="select"&&F&&F.length>0),je=Qe&&Xe&&!de,et=je?ge.replace(/^[-−]/,""):ge,xe=x.useCallback(R=>{let U=R;return T!==void 0&&(U=Math.max(T,U)),B!==void 0&&(U=Math.min(B,U)),M!==void 0&&(U=parseFloat(U.toFixed(M))),U},[T,B,M]),tt=x.useCallback(R=>{const U=R.target.value;if(ve(U),U===""||U==="-"||U==="."||U==="-."){U===""&&I?.(null);return}const ne=parseFloat(U);if(!isNaN(ne)){let ie=ne;T!==void 0&&(ie=Math.max(T,ie)),B!==void 0&&(ie=Math.min(B,ie)),I?.(ie)}},[I,T,B]),he=x.useCallback(()=>{const R=ce.current,U=xe((R??0)+H);ce.current=U,I?.(U)},[H,I,xe]),fe=x.useCallback(()=>{const R=ce.current,U=xe((R??0)-H);ce.current=U,I?.(U)},[H,I,xe]),ce=x.useRef(w);ce.current=w;const pe=x.useRef(null),se=x.useCallback(()=>{pe.current&&(clearTimeout(pe.current),pe.current=null)},[]),ze=x.useCallback(R=>{se();let U=300;const ne=()=>{R(),U=Math.max(30,U*.82),pe.current=setTimeout(ne,U)};pe.current=setTimeout(ne,400)},[se]),Te=a.useSubmitOnEnter({enabled:V,onSubmit:h}),nt=x.useCallback(R=>{Te(R),R.key==="ArrowUp"?(R.preventDefault(),he()):R.key==="ArrowDown"&&(R.preventDefault(),fe()),G?.(R)},[Te,G,he,fe]),Ie=x.useMemo(()=>{const R=[];return V&&R.push(a.COMMON_SHORTCUTS.submit),E&&(R.push({key:"ArrowUp",description:P("shortcuts.increment","Increase value")}),R.push({key:"ArrowDown",description:P("shortcuts.decrement","Decrease value")})),R},[V,E,P]);return y?null:e.jsxs("div",{className:`nice-field nice-field--${k} ${n==="left"?"nice-field--label-left":""} ${f?"nice-field--loading":""} ${r||""}`,style:{...i,...s!=null&&{"--nice-field-label-width":typeof s=="number"?`${s}px`:s},...N!=null&&{"--nice-field-control-width":typeof N=="number"?`${N}px`:N}},"aria-busy":f||void 0,children:[o&&e.jsxs("label",{htmlFor:A,className:`nice-field__label ${j?"nice-field__label--required":""}`,children:[o,t&&Ie.length>0&&e.jsx(a.NiceKeyboardHint,{shortcuts:Ie,size:"sm"})]}),e.jsxs("div",{className:"nice-field__control",children:[me.isDisplay?e.jsx(a.DisplayModeView,{value:w==null?"":m?e.jsxs(e.Fragment,{children:[m,ge]}):ge,placeholder:O,disabled:$,readOnly:v,onActivate:me.enterEdit,ariaLabel:o}):e.jsx(e.Fragment,{children:e.jsxs("div",{className:`nice-input nice-input--number nice-input--${k} nice-input--ds-${ae} ${W?"nice-input--suffix-sep":""} ${b?"nice-input--error":""} ${$?"nice-input--disabled":""} ${v?"nice-input--readonly":""}`,style:X,children:[E&&!v&&e.jsx("button",{type:"button",className:"nice-input__clear nice-input__minus",onClick:fe,onMouseDown:()=>ze(fe),onMouseUp:se,onMouseLeave:se,disabled:$,"aria-label":P("controls.decrement","Decrement"),children:e.jsx(a.NiceIcon,{name:"minus",size:16})}),D==="select"&&F&&F.length>0?e.jsxs(e.Fragment,{children:[je&&e.jsx("span",{className:"nice-input__sign",children:"−"}),e.jsx("select",{className:"nice-input__suffix-select nice-input__icon--prefix",value:Y??F[0]?.value,disabled:$,onChange:R=>{const U=R.target.value,ne=F.find(oe=>oe.value===(Y??F[0]?.value)),ie=F.find(oe=>oe.value===U);_?.(U,ne?.weight,ie?.weight)},children:F.map(R=>e.jsx("option",{value:R.value,children:R.label},R.value))})]}):m?e.jsxs("span",{className:"nice-input__icon nice-input__icon--prefix",children:[je&&e.jsx("span",{className:"nice-input__sign",children:"−"}),m]}):null,e.jsx("input",{ref:R=>{typeof K=="function"?K(R):K&&(K.current=R),me.autoFocusRef(R)},id:A,className:"nice-input__native",type:!de&&(Q||l)?"text":"number",name:d,value:et,placeholder:O,min:T,max:B,step:H,disabled:$||f,readOnly:v,"aria-invalid":!!b,onChange:tt,onFocus:R=>{$e(!0),ve(null),R.target.select()},onBlur:R=>{if($e(!1),ve(null),w!=null&&M!==void 0){const U=parseFloat(w.toFixed(M));U!==w&&I?.(U)}J&&me.exitEdit(),q?.(R)},onKeyDown:nt,style:{width:`${Ze}ch`}}),te==="select"&&c&&c.length>0?e.jsx("select",{className:"nice-input__suffix-select nice-input__icon--suffix",value:ee??c[0]?.value,disabled:$,onChange:R=>{const U=R.target.value,ne=c.find(oe=>oe.value===(ee??c[0]?.value)),ie=c.find(oe=>oe.value===U);u?.(U,ne?.weight,ie?.weight)},children:c.map(R=>e.jsx("option",{value:R.value,children:R.label},R.value))}):Z?e.jsx("span",{className:"nice-input__icon nice-input__icon--suffix",children:Z}):null,E&&!v&&e.jsx("button",{type:"button",className:"nice-input__clear nice-input__plus",onClick:he,onMouseDown:()=>ze(he),onMouseUp:se,onMouseLeave:se,disabled:$,"aria-label":P("controls.increment","Increment"),children:e.jsx(a.NiceIcon,{name:"plus",size:16})})]})}),f&&e.jsx("span",{className:"nice-field__spinner",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})}),g==="right"&&b&&e.jsx("div",{className:"nice-field__error",role:"alert",children:b}),g==="right"&&!b&&S&&e.jsx("div",{className:"nice-field__helper",children:S})]}),g!=="right"&&b&&e.jsx("div",{className:"nice-field__error",role:"alert",children:b}),g!=="right"&&!b&&S&&e.jsx("div",{className:"nice-field__helper",children:S})]})}),{displayName:"NiceNumberInput"}),rt=Object.freeze(Object.defineProperty({__proto__:null,NiceNumberInput:ke},Symbol.toStringTag,{value:"Module"})),Ne=Object.assign(x.forwardRef(({label:o,helperText:S,error:b,required:j,disabled:$,readOnly:v,size:k="md",name:d,id:C,className:r,style:i,accessMode:p,displayStyle:z,variant:w,value:I,defaultValue:q,onChange:G,onBlur:O,onKeyDown:T,placeholder:B,type:H="text",maxLength:M,prefix:m,suffix:D,clearable:F,autoFocus:Y,submitOnEnter:_,onSubmit:Z,showKeyboardHints:E,labelPlacement:V,errorPlacement:h,loading:t,labelWidth:n,controlWidth:g,displayMode:f,...s},N)=>{const l=a.useNiceAccessMode(p,C),Q=l==="hidden";l==="disabled"&&($=!0),l==="readOnly"&&(v=!0);const{t:te}=a.useNiceTranslation(),c=a.useControlId(C),ee=a.useComponentDisplayStyle("input",z),u=a.useComponentDisplayClass("input",z),W=w==="filled"?"filled":w==="underlined"?"underlined":"",J=x.useCallback(()=>G?.(""),[G]),K=a.useDisplayModeEdit({enabled:f,readOnly:v,disabled:$}),L=a.useSubmitOnEnter({enabled:_,onSubmit:Z}),y=x.useCallback(A=>{L(A),T?.(A)},[L,T]),P=x.useMemo(()=>{const A=[];return _&&A.push({key:"Enter",description:te("shortcuts.submit","Submit")}),F&&A.push({key:"Escape",description:te("shortcuts.clear","Clear")}),A},[_,F,te]);return Q?null:e.jsxs("div",{className:`nice-field nice-field--${k} ${V==="left"?"nice-field--label-left":""} ${V==="inside"?"nice-field--label-inside":""} ${t?"nice-field--loading":""} ${r||""}`,style:{...i,...n!=null&&{"--nice-field-label-width":typeof n=="number"?`${n}px`:n},...g!=null&&{"--nice-field-control-width":typeof g=="number"?`${g}px`:g}},"aria-busy":t||void 0,"data-floating":V==="inside"&&I?"true":void 0,children:[o&&V!=="inside"&&e.jsxs("label",{htmlFor:c,className:`nice-field__label ${j?"nice-field__label--required":""}`,children:[o,E&&P.length>0&&e.jsx(a.NiceKeyboardHint,{shortcuts:P,size:"sm"})]}),e.jsxs("div",{className:"nice-field__control",children:[K.isDisplay?e.jsx(a.DisplayModeView,{value:I??q??"",placeholder:B,disabled:$,readOnly:v,onActivate:K.enterEdit,ariaLabel:o}):e.jsxs("div",{className:`nice-input nice-input--${k} nice-input--ds-${W||u} ${b?"nice-input--error":""} ${$?"nice-input--disabled":""} ${v?"nice-input--readonly":""}`,style:w?void 0:ee,children:[m&&e.jsx("span",{className:"nice-input__icon",children:m}),e.jsx("input",{ref:A=>{typeof N=="function"?N(A):N&&(N.current=A),K.autoFocusRef(A)},id:c,className:"nice-input__native",type:H,name:d,value:I,defaultValue:q,placeholder:B,disabled:$||t,readOnly:v,maxLength:M,autoFocus:Y,"aria-invalid":!!b,"aria-describedby":b?`${c}-error`:S?`${c}-helper`:void 0,onChange:A=>G?.(A.target.value),onBlur:A=>{f&&K.exitEdit(),O?.(A)},onKeyDown:y,...s}),F&&I&&e.jsx("button",{type:"button",className:"nice-input__clear",onClick:J,"aria-label":te("controls.clear","Clear"),children:e.jsx(a.NiceIcon,{name:"close",size:14})}),D&&e.jsx("span",{className:"nice-input__icon",children:D}),o&&V==="inside"&&e.jsx("label",{htmlFor:c,className:`nice-input__floating-label ${j?"nice-input__floating-label--required":""}`,children:o})]}),t&&e.jsx("span",{className:"nice-field__spinner",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})}),h==="right"&&b&&e.jsx("div",{id:`${c}-error`,className:"nice-field__error",role:"alert",children:b}),h==="right"&&!b&&S&&e.jsx("div",{id:`${c}-helper`,className:"nice-field__helper",children:S})]}),h!=="right"&&b&&e.jsx("div",{id:`${c}-error`,className:"nice-field__error",role:"alert",children:b}),h!=="right"&&!b&&S&&e.jsx("div",{id:`${c}-helper`,className:"nice-field__helper",children:S})]})}),{displayName:"NiceTextInput"}),ot=Object.freeze(Object.defineProperty({__proto__:null,NiceTextInput:Ne},Symbol.toStringTag,{value:"Module"})),Le=({code:o,language:S="typescript",lineNumbers:b=!0,livePreview:j=!1,showDiff:$=!1,previousCode:v,theme:k="light",copyable:d=!0,onCopy:C,className:r})=>{const{t:i}=a.useNiceTranslation(),[p,z]=x.useState(!1),w=async()=>{await navigator.clipboard.writeText(o),z(!0),C?.(),setTimeout(()=>z(!1),2e3)},I=o.split(`
2
+ `),q=()=>e.jsx("div",{className:"nice-code-preview__line-numbers",children:I.map((B,H)=>e.jsx("span",{children:H+1},H))}),G=()=>e.jsx("pre",{className:`nice-code-preview__code language-${S}`,children:e.jsx("code",{children:o})}),O=()=>v?e.jsxs("div",{className:"nice-code-preview__diff",children:[e.jsxs("div",{className:"nice-code-preview__diff-panel nice-code-preview__diff-panel--old",children:[e.jsx("h4",{children:i("codePreview.previous","Previous")}),e.jsx("pre",{children:v})]}),e.jsxs("div",{className:"nice-code-preview__diff-panel nice-code-preview__diff-panel--new",children:[e.jsx("h4",{children:i("codePreview.current","Current")}),e.jsx("pre",{children:o})]})]}):null,T=()=>S!=="html"?e.jsx("div",{className:"nice-code-preview__live-preview",children:e.jsx("p",{children:i("codePreview.livePreviewIsAvailableFor","Live preview is available for HTML only")})}):e.jsx("div",{className:"nice-code-preview__live-preview",children:e.jsx("iframe",{srcDoc:o,title:i("codePreview.livePreview","Live Preview"),sandbox:"allow-scripts"})});return e.jsxs("div",{className:`nice-code-preview nice-code-preview--${k} ${r||""}`,children:[e.jsxs("header",{className:"nice-code-preview__header",children:[e.jsx("span",{className:"nice-code-preview__language",children:S}),d&&e.jsx("button",{onClick:w,className:"nice-code-preview__copy-btn",children:p?e.jsxs(e.Fragment,{children:[e.jsx(a.NiceIcon,{name:"check",size:14})," ",i("codePreview.copied","Copied")]}):"Copy"})]}),$&&v?O():e.jsxs("div",{className:"nice-code-preview__body",children:[b&&q(),G()]}),j&&e.jsxs("div",{className:"nice-code-preview__preview-section",children:[e.jsx("h4",{children:i("codePreview.preview","Preview")}),T()]})]})},at=[{target:".nice-lowcode-studio",titleKey:"tutorial.lowCodeStudio.intro.title",title:"Low-code studio",contentKey:"tutorial.lowCodeStudio.intro.content",content:"Drag components from the sidebar onto the canvas, then switch between Design, Preview and Code tabs to build and export your app.",placement:"auto"}],st={components:[],layout:{type:"flex"},styles:{}},Se="application/x-nice-component";function lt(o){const S=o.replace(/[^A-Za-z0-9]+(.)?/g,(b,j)=>j?j.toUpperCase():"");return/^[A-Za-z]/.test(S)?S.charAt(0).toUpperCase()+S.slice(1):`Component${S}`}function dt(o,S){return["export function Page() {"," return ("," <>",...o.components.map(j=>{const $=Object.entries(j.props).map(([v,k])=>typeof k=="string"?` ${v}=${JSON.stringify(k)}`:` ${v}={${JSON.stringify(k)}}`);return` <${S(j.type)}${$.join("")} />`})," </>"," );","}"].join(`
3
+ `)}const ct=({projectId:o,components:S=[],theme:b="light",onChange:j,onSave:$,renderComponent:v,className:k,tutorial:d})=>{const{t:C}=a.useNiceTranslation(),[r,i]=x.useState("design"),[p,z]=x.useState(st),[w,I]=x.useState(null),[q,G]=x.useState(!1),O=x.useRef(0),T=t=>S.find(n=>n.id===t),B=t=>T(t)?.name??t,H=t=>{const n=T(t)?.icon;return n?e.jsx(a.NiceIcon,{name:n,size:14}):null},M=t=>{const n={...p,components:t};z(n),j?.(n)},m=t=>{O.current+=1;const n={id:`${t.id}-${O.current}`,type:t.id,props:{...t.defaultProps}};M([...p.components,n]),I(n.id)},D=t=>{M(p.components.filter(n=>n.id!==t)),w===t&&I(null)},F=(t,n,g)=>M(p.components.map(f=>f.id===t?{...f,props:{...f.props,[n]:g}}:f)),Y=t=>{Array.from(t.dataTransfer.types).includes(Se)&&(t.preventDefault(),t.dataTransfer.dropEffect="copy",G(!0))},_=t=>{t.currentTarget.contains(t.relatedTarget)||G(!1)},Z=t=>{t.preventDefault(),G(!1);const n=T(t.dataTransfer.getData(Se));n&&m(n)},E=(t,n,g)=>typeof g=="boolean"?e.jsx(we,{label:n,checked:g,onChange:f=>F(t,n,f)}):typeof g=="number"?e.jsx(ke,{label:n,value:g,onChange:f=>F(t,n,f??0)}):typeof g=="string"?e.jsx(Ne,{label:n,value:g,onChange:f=>F(t,n,f)}):e.jsxs(e.Fragment,{children:[e.jsx("span",{children:n}),e.jsx("code",{children:JSON.stringify(g)})]}),V=p.components.find(t=>t.id===w),h=[{id:"design",label:C("noCode.lowCodeStudio.design","Design")},{id:"preview",label:C("noCode.preview","Preview")},{id:"code",label:C("noCode.lowCodeStudio.code","Code")}];return e.jsx(le.NiceAppShell,{flush:!0,className:`nice-lowcode-studio nice-lowcode-studio--${b} ${k||""}`,menubar:e.jsxs("header",{className:"nice-lowcode-studio__header",children:[e.jsx("h1",{children:C("noCode.lowCodeStudio.title","Low-Code Studio")}),e.jsx("nav",{className:"nice-lowcode-studio__tabs",children:h.map(t=>e.jsx("button",{type:"button","aria-pressed":r===t.id,onClick:()=>i(t.id),className:`nice-lowcode-studio__tab ${r===t.id?"nice-lowcode-studio__tab--active":""}`,children:t.label},t.id))}),e.jsx("button",{type:"button",onClick:()=>$?.(p),children:C("save","Save")}),e.jsx(a.NiceTutorialButton,{steps:a.resolveTutorial(d,at)})]}),sidebar:e.jsxs("aside",{className:"nice-lowcode-studio__sidebar",children:[e.jsx("h2",{children:C("noCode.componentDesigner.palette","Component Palette")}),e.jsx("ul",{children:S.map(t=>e.jsx("li",{children:e.jsxs("button",{type:"button",draggable:!0,className:"nice-lowcode-studio__palette-item",title:C("noCode.lowCodeStudio.addHint","Drag onto the canvas, or click to add"),onDragStart:n=>{n.dataTransfer.setData(Se,t.id),n.dataTransfer.effectAllowed="copy"},onClick:()=>m(t),children:[H(t.id),t.name]})},t.id))})]}),rightSidebar:e.jsxs("aside",{className:"nice-lowcode-studio__properties",children:[e.jsx("h2",{children:C("noCode.lowCodeStudio.properties","Properties")}),V?e.jsxs("div",{className:"nice-lowcode-studio__props",children:[e.jsx("h3",{children:B(V.type)}),Object.keys(V.props).length===0?e.jsx("p",{children:C("noCode.lowCodeStudio.noProps","This component has no properties")}):Object.entries(V.props).map(([t,n])=>e.jsx("div",{className:"nice-lowcode-studio__prop",children:E(V.id,t,n)},t))]}):e.jsx("p",{children:C("noCode.lowCodeStudio.selectHint","Select a component to edit its properties")})]}),children:e.jsxs("main",{className:"nice-lowcode-studio__canvas","data-project":o,children:[r==="design"&&e.jsx("div",{className:["nice-lowcode-studio__design-canvas",q&&"nice-lowcode-studio__design-canvas--over",p.components.length>0&&"nice-lowcode-studio__design-canvas--filled"].filter(Boolean).join(" "),onDragOver:Y,onDragLeave:_,onDrop:Z,children:p.components.length===0?e.jsx("p",{children:C("noCode.componentDesigner.dragDrop","Drag components here")}):e.jsx("ul",{className:"nice-lowcode-studio__instances",children:p.components.map(t=>e.jsxs("li",{className:`nice-lowcode-studio__instance${t.id===w?" nice-lowcode-studio__instance--selected":""}`,children:[e.jsxs("button",{type:"button",className:"nice-lowcode-studio__instance-select","aria-pressed":t.id===w,onClick:()=>I(t.id),children:[H(t.type),B(t.type)]}),e.jsx("button",{type:"button","aria-label":`${C("remove","Remove")} ${B(t.type)}`,onClick:()=>D(t.id),children:e.jsx(a.NiceIcon,{name:"close",size:12})})]},t.id))})}),r==="preview"&&e.jsx("div",{className:`nice-lowcode-studio__preview${v?" nice-lowcode-studio__preview--live":""}`,children:v?p.components.map(t=>e.jsx(x.Fragment,{children:v(t)},t.id)):e.jsx("p",{children:C("noCode.lowCodeStudio.previewUnavailable","No preview: the app has not connected its components (renderComponent).")})}),r==="code"&&e.jsx("div",{className:"nice-lowcode-studio__code",children:e.jsx(Le,{code:p.components.length>0?dt(p,t=>lt(B(t))):C("noCode.lowCodeStudio.codeEmpty","// Add components to generate code"),language:"tsx",theme:b})})]})})},pt=[{target:".nice-component-designer",titleKey:"tutorial.componentDesigner.intro.title",title:"Component designer",contentKey:"tutorial.componentDesigner.intro.content",content:"Name your component, declare its props with types and requirements, and preview the generated TypeScript interface live.",placement:"auto"}],ut=({component:o,propTypes:S=[],onChange:b,theme:j="light",className:$,tutorial:v})=>{const{t:k}=a.useNiceTranslation(),[d,C]=x.useState(o||{name:"NewComponent",props:[]}),r=i=>{const p={...d,...i};C(p),b?.(p)};return e.jsxs("div",{className:`nice-component-designer nice-component-designer--${j} ${$||""}`,style:{position:"relative"},children:[e.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:20},children:e.jsx(a.NiceTutorialButton,{steps:a.resolveTutorial(v,pt)})}),e.jsxs("section",{className:"nice-component-designer__header",children:[e.jsx("input",{type:"text",value:d.name,onChange:i=>r({name:i.target.value}),placeholder:k("componentDesigner.componentName","Component Name")}),e.jsx("input",{type:"text",value:d.description||"",onChange:i=>r({description:i.target.value}),placeholder:k("componentDesigner.description","Description")})]}),e.jsxs("section",{className:"nice-component-designer__props",children:[e.jsx("h3",{children:k("componentDesigner.props","Props")}),d.props.map((i,p)=>e.jsxs("div",{className:"nice-component-designer__prop",children:[e.jsx("input",{type:"text",value:i.name,readOnly:!0}),e.jsx("span",{children:i.type}),i.required&&e.jsx("span",{children:"required"})]},p)),e.jsx("button",{onClick:()=>r({props:[...d.props,{name:"newProp",type:"string"}]}),children:k("componentDesigner.addProp","Add Prop")})]}),e.jsxs("section",{className:"nice-component-designer__preview",children:[e.jsx("h3",{children:k("componentDesigner.preview","Preview")}),e.jsx("pre",{children:`interface ${d.name}Props {
4
+ ${d.props.map(i=>` ${i.name}${i.required?"":"?"}: ${i.type};`).join(`
5
+ `)}
6
+ }
7
+
8
+ export const ${d.name}: React.FC<${d.name}Props> = (props) => {
9
+ return <div>Component</div>;
10
+ };`})]})]})},mt=[{target:".nice-page-builder",titleKey:"tutorial.pageBuilder.intro.title",title:"Page builder",contentKey:"tutorial.pageBuilder.intro.content",content:"Drag components from the sidebar onto the responsive grid, switch the desktop/tablet/mobile preview, and save the layout.",placement:"auto"}],gt=({initialLayout:o,components:S=[],grid:b={columns:12,gap:16,padding:24},onChange:j,onSave:$,theme:v="light",previewMode:k="desktop",className:d,tutorial:C})=>{const{t:r}=a.useNiceTranslation(),[i,p]=x.useState(o||{id:"page-1",name:"New Page",rows:[]}),[z,w]=x.useState(null),I=O=>{p(O),j?.(O)},q=()=>{const O={id:`row-${Date.now()}`,columns:[{id:`col-${Date.now()}`,width:12,components:[]}]};I({...i,rows:[...i.rows,O]})},G={desktop:"100%",tablet:"768px",mobile:"375px"}[k];return e.jsx(le.NiceAppShell,{flush:!0,className:`nice-page-builder nice-page-builder--${v} ${d||""}`,toolbar:e.jsxs("header",{className:"nice-page-builder__toolbar",children:[e.jsx("input",{type:"text",value:i.name,onChange:O=>I({...i,name:O.target.value})}),e.jsxs("div",{className:"nice-page-builder__preview-modes",children:[e.jsx("button",{className:`nice-page-builder__preview-mode ${k==="desktop"?"nice-page-builder__preview-mode--active":""}`,children:r("pageBuilder.desktop","Desktop")}),e.jsx("button",{className:`nice-page-builder__preview-mode ${k==="tablet"?"nice-page-builder__preview-mode--active":""}`,children:r("pageBuilder.tablet","Tablet")}),e.jsx("button",{className:`nice-page-builder__preview-mode ${k==="mobile"?"nice-page-builder__preview-mode--active":""}`,children:r("pageBuilder.mobile","Mobile")})]}),e.jsx("button",{onClick:()=>$?.(i),children:r("pageBuilder.save","Save")}),e.jsx(a.NiceTutorialButton,{steps:a.resolveTutorial(C,mt)})]}),sidebar:e.jsxs("aside",{className:"nice-page-builder__sidebar",children:[e.jsx("h3",{children:r("pageBuilder.components","Components")}),e.jsx("ul",{className:"nice-page-builder__components",children:S.map(O=>e.jsxs("li",{draggable:!0,className:"nice-page-builder__component-item",children:[O.icon&&e.jsx(a.NiceIcon,{name:O.icon,size:14}),O.name]},O.id))})]}),rightSidebar:e.jsxs("aside",{className:"nice-page-builder__properties",children:[e.jsx("h3",{children:r("pageBuilder.properties","Properties")}),z?e.jsx("p",{children:r("pageBuilder.editPropertiesForSelectedComponent","Edit properties for selected component")}):e.jsx("p",{children:r("pageBuilder.selectAComponentToEdit","Select a component to edit")})]}),children:e.jsx("main",{className:"nice-page-builder__canvas",children:e.jsxs("div",{className:"nice-page-builder__viewport",style:{maxWidth:G},children:[i.rows.map(O=>e.jsx("div",{className:"nice-page-builder__row",children:O.columns.map(T=>e.jsx("div",{className:"nice-page-builder__column",style:{width:`${T.width/12*100}%`},children:T.components.length===0?e.jsx("div",{className:"nice-page-builder__dropzone",children:r("pageBuilder.dropComponentsHere","Drop components here")}):T.components.map(B=>e.jsx("div",{className:`nice-page-builder__placed-component ${z===B.id?"nice-page-builder__placed-component--selected":""}`,onClick:()=>w(B.id),children:B.type},B.id))},T.id))},O.id)),e.jsx("button",{onClick:q,className:"nice-page-builder__add-row",children:"+ Add Row"})]})})})},xt=[{target:".nice-state-designer",titleKey:"tutorial.stateDesigner.intro.title",title:"State designer",contentKey:"tutorial.stateDesigner.intro.content",content:"Model your store as slices with fields and actions, pick a target (e.g. Zustand) and export ready-to-use state-management code.",placement:"auto"}],ht={id:"store-1",name:"AppStore",description:"Main application state store",slices:[{id:"slice-auth",name:"auth",description:"Authentication state",state:[{id:"f1",name:"user",type:"object",nullable:!0,description:"Current user"},{id:"f2",name:"isAuthenticated",type:"boolean",defaultValue:!1},{id:"f3",name:"token",type:"string",nullable:!0},{id:"f4",name:"loading",type:"boolean",defaultValue:!1},{id:"f5",name:"error",type:"string",nullable:!0}],actions:[{id:"a1",name:"login",description:"Authenticate user",async:!0,params:[{id:"p1",name:"email",type:"string",required:!0},{id:"p2",name:"password",type:"string",required:!0}],reducerSteps:[{id:"s1",type:"set",field:"loading",value:"true"},{id:"s2",type:"set",field:"error",value:"null"},{id:"s3",type:"set",field:"user",value:"response.user"},{id:"s4",type:"set",field:"token",value:"response.token"},{id:"s5",type:"set",field:"isAuthenticated",value:"true"},{id:"s6",type:"set",field:"loading",value:"false"}]},{id:"a2",name:"logout",description:"Clear user session",params:[],reducerSteps:[{id:"s1",type:"reset",field:"user"},{id:"s2",type:"set",field:"isAuthenticated",value:"false"},{id:"s3",type:"reset",field:"token"}]}],selectors:[{id:"sel1",name:"selectUser",expression:"state.auth.user",dependencies:["user"],memoized:!0},{id:"sel2",name:"selectIsLoggedIn",expression:"state.auth.isAuthenticated",dependencies:["isAuthenticated"]}]},{id:"slice-cart",name:"cart",description:"Shopping cart state",state:[{id:"f1",name:"items",type:"array",defaultValue:[],description:"Cart items"},{id:"f2",name:"total",type:"number",defaultValue:0},{id:"f3",name:"currency",type:"string",defaultValue:"USD"}],actions:[{id:"a1",name:"addItem",params:[{id:"p1",name:"item",type:"object",required:!0}],reducerSteps:[{id:"s1",type:"push",field:"items",value:"item"},{id:"s2",type:"update",field:"total",value:"state.total + item.price"}]},{id:"a2",name:"removeItem",params:[{id:"p1",name:"itemId",type:"string",required:!0}],reducerSteps:[{id:"s1",type:"remove",field:"items",value:"item.id !== itemId"}]},{id:"a3",name:"clearCart",params:[],reducerSteps:[{id:"s1",type:"set",field:"items",value:"[]"},{id:"s2",type:"set",field:"total",value:"0"}]}],selectors:[{id:"sel1",name:"selectCartItems",expression:"state.cart.items",dependencies:["items"]},{id:"sel2",name:"selectCartCount",expression:"state.cart.items.length",dependencies:["items"],memoized:!0},{id:"sel3",name:"selectCartTotal",expression:"state.cart.total",dependencies:["total"]}],computed:[{id:"c1",name:"itemCount",expression:"items.length",dependencies:["items"]}]}],middleware:[{type:"immer",enabled:!0},{type:"devtools",enabled:!0},{type:"persist",enabled:!0}],persist:{enabled:!0,key:"app-store",storage:"localStorage",whitelist:["auth.token","cart.items"],version:1},devtools:{enabled:!0,name:"AppStore",trace:!0}},ft=[{id:"tpl-auth",name:"Authentication",description:"User authentication with token",icon:"lock",store:{slices:[{id:"auth",name:"auth",state:[{id:"user",name:"user",type:"object",nullable:!0},{id:"token",name:"token",type:"string",nullable:!0},{id:"isAuthenticated",name:"isAuthenticated",type:"boolean",defaultValue:!1}],actions:[],selectors:[]}]}},{id:"tpl-crud",name:"CRUD Entity",description:"Standard entity with loading states",icon:"box",store:{slices:[{id:"entity",name:"entity",state:[{id:"items",name:"items",type:"array",defaultValue:[]},{id:"selected",name:"selected",type:"object",nullable:!0},{id:"loading",name:"loading",type:"boolean",defaultValue:!1},{id:"error",name:"error",type:"string",nullable:!0}],actions:[],selectors:[]}]}},{id:"tpl-ui",name:"UI State",description:"Theme, sidebar, modal states",icon:"palette",store:{slices:[{id:"ui",name:"ui",state:[{id:"theme",name:"theme",type:"enum",defaultValue:"light"},{id:"sidebarOpen",name:"sidebarOpen",type:"boolean",defaultValue:!0},{id:"activeModal",name:"activeModal",type:"string",nullable:!0}],actions:[],selectors:[]}]}}],_e={string:"edit",number:"hash",boolean:"check",array:"clipboard",object:"box",date:"calendar",enum:"bar-chart",custom:"settings"},Re=o=>{const S=["import { create } from 'zustand'"];o.middleware?.some(r=>r.type==="devtools"&&r.enabled)&&S.push("import { devtools } from 'zustand/middleware'"),o.middleware?.some(r=>r.type==="persist"&&r.enabled)&&S.push("import { persist } from 'zustand/middleware'"),o.middleware?.some(r=>r.type==="immer"&&r.enabled)&&S.push("import { immer } from 'zustand/middleware/immer'");const b=[];o.slices.forEach(r=>{b.push(`interface ${Be(r.name)}State {`),r.state.forEach(i=>{const p=Me(i.type,i.nullable);b.push(` ${i.name}: ${p};`)}),b.push("}"),b.push("")}),b.push("interface Actions {"),o.slices.forEach(r=>{r.actions.forEach(i=>{const p=i.params.map(w=>`${w.name}: ${Me(w.type)}`).join(", "),z=i.async?"Promise<void>":"void";b.push(` ${i.name}: (${p}) => ${z};`)})}),b.push("}");const j=o.slices.map(r=>`${Be(r.name)}State`).join(" & ");b.push(""),b.push(`type StoreState = ${j} & Actions;`);const $=[];o.slices.forEach(r=>{r.state.forEach(i=>{const p=i.defaultValue!==void 0?JSON.stringify(i.defaultValue):i.nullable?"null":Ve(i.type);$.push(` ${i.name}: ${p},`)})});const v=[];o.slices.forEach(r=>{r.actions.forEach(i=>{const p=i.params.map(w=>w.name).join(", "),z=i.async?"async ":"";v.push(` ${i.name}: ${z}(${p}) => {`),i.async?(v.push(" set({ loading: true, error: null });"),v.push(" try {"),v.push(" // TODO: API call"),v.push(` // const response = await api.${i.name}(${p});`),i.reducerSteps.forEach(w=>{w.type==="set"&&v.push(` set({ ${w.field}: ${w.value} });`)}),v.push(" } catch (error) {"),v.push(" set({ error: error.message, loading: false });"),v.push(" }")):(v.push(" set((state) => {"),i.reducerSteps.forEach(w=>{w.type==="set"?v.push(` state.${w.field} = ${w.value};`):w.type==="push"?v.push(` state.${w.field}.push(${w.value});`):w.type==="reset"&&v.push(` state.${w.field} = null;`)}),v.push(" });")),v.push(" },")})});let k="",d="";if(o.middleware?.some(r=>r.type==="immer"&&r.enabled)&&(k+="immer(",d=")"+d),o.middleware?.some(r=>r.type==="devtools"&&r.enabled)&&(k+="devtools(",d=`, { name: '${o.devtools?.name||o.name}' })`+d),o.persist?.enabled){k+="persist(";const r=[`name: '${o.persist.key}'`];o.persist.whitelist&&r.push(`partialize: (state) => ({ ${o.persist.whitelist.map(i=>i.split(".").pop()).join(", ")} })`),d=`, { ${r.join(", ")} })`+d}return`${S.join(`
11
+ `)}
12
+
13
+ // Types
14
+ ${b.join(`
15
+ `)}
16
+
17
+ // Store
18
+ export const use${o.name} = create<StoreState>()(
19
+ ${k}(set, get) => ({
20
+ // Initial State
21
+ ${$.join(`
22
+ `)}
23
+
24
+ // Actions
25
+ ${v.join(`
26
+ `)}
27
+ })${d}
28
+ );
29
+
30
+ // Selectors
31
+ ${o.slices.flatMap(r=>r.selectors.map(i=>`export const ${i.name} = (state: StoreState) => ${i.expression.replace("state.","state.")};`)).join(`
32
+ `)}
33
+ `},Be=o=>o.charAt(0).toUpperCase()+o.slice(1),Me=(o,S)=>{const b={string:"string",number:"number",boolean:"boolean",array:"unknown[]",object:"Record<string, unknown>",date:"Date",enum:"string",custom:"unknown"}[o];return S?`${b} | null`:b},Ve=o=>({string:"''",number:"0",boolean:"false",array:"[]",object:"{}",date:"new Date()",enum:"''",custom:"null"})[o],qe=({store:o=ht,templates:S=ft,onStoreChange:b,onExport:j,onSave:$,tutorial:v,className:k,style:d,"data-testid":C})=>{const{t:r}=a.useNiceTranslation(),[i,p]=x.useState(o),[z,w]=x.useState("slices"),[I,q]=x.useState(i.slices[0]?.id||null),[G,O]=x.useState(null),[T,B]=x.useState("zustand"),[H,M]=x.useState(!1),[m,D]=x.useState(null),[F,Y]=x.useState(""),[_,Z]=x.useState("string"),E=x.useMemo(()=>i.slices.find(c=>c.id===I),[i.slices,I]),V=x.useCallback(c=>{const ee={...i,...c};p(ee),b?.(ee)},[i,b]),h=()=>{const c={id:`slice-${Date.now()}`,name:"newSlice",state:[],actions:[],selectors:[]};V({slices:[...i.slices,c]}),q(c.id)},t=()=>{if(!E||!F)return;const c={id:`field-${Date.now()}`,name:F,type:_,defaultValue:Ve(_).replace(/'/g,"")},ee=i.slices.map(u=>u.id===E.id?{...u,state:[...u.state,c]}:u);V({slices:ee}),Y("")},n=()=>{if(!E)return;const c={id:`action-${Date.now()}`,name:"newAction",params:[],reducerSteps:[]},ee=i.slices.map(u=>u.id===E.id?{...u,actions:[...u.actions,c]}:u);V({slices:ee}),O(c.id)},g=x.useCallback(()=>{let c="";T==="zustand"?c=Re(i):c=`// Export for ${T} coming soon...
34
+ // Store: ${i.name}`,j?.(c,T)},[i,T,j]),f=x.useMemo(()=>T==="zustand"?Re(i):`// ${T} export coming soon...`,[i,T]),s={bg:"var(--nice-bg-elevated, #1e1e1e)",cardBg:"var(--nice-bg-elevated, #252525)",border:"var(--nice-bg-tertiary, #333)",text:"var(--nice-text-primary, #e0e0e0)",textMuted:"var(--nice-text-muted, #888)",accent:"var(--nice-color-primary, #3b82f6)"},N=e.jsxs("div",{style:{padding:"16px 20px",borderBottom:`1px solid ${s.border}`,display:"flex",alignItems:"center",gap:16},children:[e.jsxs("h3",{style:{margin:0,fontSize:18,display:"inline-flex",alignItems:"center",gap:6},children:[e.jsx(a.NiceIcon,{name:"folder",size:16})," ",r("stateDesigner.stateDesigner","State Designer")]}),e.jsx("div",{style:{display:"flex",alignItems:"center",gap:8},children:e.jsx("input",{type:"text",value:i.name,onChange:c=>V({name:c.target.value}),style:{padding:"6px 12px",borderRadius:4,border:`1px solid ${s.border}`,background:s.cardBg,color:s.text,fontSize:14,fontWeight:600}})}),e.jsxs("div",{style:{marginLeft:"auto",display:"flex",gap:8,alignItems:"center"},children:[e.jsx(a.NiceTutorialButton,{steps:a.resolveTutorial(v,xt)}),e.jsxs("button",{onClick:()=>M(!0),style:{padding:"8px 16px",borderRadius:6,border:`1px solid ${s.border}`,background:"transparent",color:s.text,cursor:"pointer",fontSize:13},children:[e.jsx(a.NiceIcon,{name:"clipboard",size:14})," ",r("stateDesigner.templates","Templates")]}),e.jsxs("button",{onClick:()=>$?.(i),style:{padding:"8px 16px",borderRadius:6,border:"none",background:"var(--nice-color-success, #22c55e)",color:"var(--nice-text-on-primary, #fff)",cursor:"pointer",fontSize:13,fontWeight:500},children:[e.jsx(a.NiceIcon,{name:"save",size:14})," ",r("stateDesigner.save","Save")]})]})]}),l=e.jsx("div",{style:{display:"flex",borderBottom:`1px solid ${s.border}`,padding:"0 20px"},children:["slices","actions","selectors","settings","preview"].map(c=>e.jsxs("button",{onClick:()=>w(c),style:{padding:"12px 20px",border:"none",background:"transparent",color:z===c?s.text:s.textMuted,cursor:"pointer",fontSize:13,fontWeight:z===c?600:400,borderBottom:z===c?`2px solid ${s.accent}`:"2px solid transparent",marginBottom:-1},children:[c==="slices"&&e.jsxs(e.Fragment,{children:[e.jsx(a.NiceIcon,{name:"box",size:14})," ",r("stateDesigner.slices","Slices")]}),c==="actions"&&e.jsxs(e.Fragment,{children:[e.jsx(a.NiceIcon,{name:"zap",size:14})," ",r("stateDesigner.actions","Actions")]}),c==="selectors"&&e.jsxs(e.Fragment,{children:[e.jsx(a.NiceIcon,{name:"target",size:14})," ",r("stateDesigner.selectors","Selectors")]}),c==="settings"&&e.jsxs(e.Fragment,{children:[e.jsx(a.NiceIcon,{name:"settings",size:14})," ",r("stateDesigner.settings","Settings")]}),c==="preview"&&e.jsxs(e.Fragment,{children:[e.jsx(a.NiceIcon,{name:"eye",size:14})," ",r("stateDesigner.preview","Preview")]})]},c))}),te=z==="slices"||z==="actions"||z==="selectors"?e.jsxs("div",{style:{width:200,borderRight:`1px solid ${s.border}`,padding:12,display:"flex",flexDirection:"column",gap:8,height:"100%",boxSizing:"border-box"},children:[e.jsx("div",{style:{fontSize:11,color:s.textMuted,marginBottom:4},children:r("stateDesigner.slices2","SLICES")}),i.slices.map(c=>e.jsxs("button",{onClick:()=>q(c.id),style:{padding:"10px 12px",borderRadius:6,border:"none",background:I===c.id?s.accent+"30":s.cardBg,color:s.text,cursor:"pointer",textAlign:"left",fontSize:13},children:[e.jsx(a.NiceIcon,{name:"box",size:14})," ",c.name,e.jsxs("div",{style:{fontSize:10,color:s.textMuted},children:[c.state.length," fields • ",c.actions.length," actions"]})]},c.id)),e.jsx("button",{onClick:h,style:{padding:"10px 12px",borderRadius:6,border:`1px dashed ${s.border}`,background:"transparent",color:s.textMuted,cursor:"pointer",fontSize:13},children:"+ Add Slice"})]}):void 0;return e.jsxs(e.Fragment,{children:[e.jsx(le.NiceAppShell,{flush:!0,className:`nice-state-designer ${k||""}`,style:{background:s.bg,color:s.text,fontFamily:"system-ui, sans-serif",...d},"data-testid":C,menubar:N,toolbar:l,sidebar:te,children:e.jsxs("div",{style:{height:"100%",overflow:"auto",padding:20,boxSizing:"border-box"},children:[z==="slices"&&E&&e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:16,marginBottom:20},children:[e.jsxs("h4",{style:{margin:0,display:"inline-flex",alignItems:"center",gap:6},children:[e.jsx(a.NiceIcon,{name:"box",size:16})," ",E.name]}),e.jsx("input",{type:"text",value:E.name,onChange:c=>{const ee=i.slices.map(u=>u.id===E.id?{...u,name:c.target.value}:u);V({slices:ee})},style:{padding:"6px 12px",borderRadius:4,border:`1px solid ${s.border}`,background:s.cardBg,color:s.text,fontSize:13}})]}),e.jsxs("div",{style:{marginBottom:24},children:[e.jsxs("div",{style:{fontSize:12,color:s.textMuted,marginBottom:12},children:["STATE FIELDS (",E.state.length,")"]}),e.jsxs("div",{style:{border:`1px solid ${s.border}`,borderRadius:8,overflow:"hidden"},children:[E.state.map(c=>e.jsxs("div",{style:{padding:"12px 16px",borderBottom:`1px solid ${s.border}`,display:"flex",alignItems:"center",gap:12},children:[e.jsx(a.NiceIcon,{name:_e[c.type],size:14}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontWeight:500,fontFamily:"monospace"},children:c.name}),e.jsxs("div",{style:{fontSize:11,color:s.textMuted},children:[c.type,c.nullable&&"?",c.defaultValue!==void 0&&` = ${JSON.stringify(c.defaultValue)}`]})]}),e.jsx("button",{onClick:()=>{const ee=i.slices.map(u=>u.id===E.id?{...u,state:u.state.filter(W=>W.id!==c.id)}:u);V({slices:ee})},"aria-label":r("stateDesigner.delete","Delete"),style:{padding:4,border:"none",background:"transparent",color:"var(--nice-color-error, #ef4444)",cursor:"pointer",fontSize:14},children:e.jsx(a.NiceIcon,{name:"trash",size:14})})]},c.id)),e.jsxs("div",{style:{padding:"12px 16px",display:"flex",alignItems:"center",gap:8,background:s.cardBg},children:[e.jsx("input",{type:"text",placeholder:"fieldName",value:F,onChange:c=>Y(c.target.value),style:{flex:1,padding:"8px 12px",borderRadius:4,border:`1px solid ${s.border}`,background:s.bg,color:s.text,fontSize:13,fontFamily:"monospace"}}),e.jsx("select",{value:_,onChange:c=>Z(c.target.value),style:{padding:"8px 12px",borderRadius:4,border:`1px solid ${s.border}`,background:s.bg,color:s.text,fontSize:13},children:Object.keys(_e).map(c=>e.jsx("option",{value:c,children:c},c))}),e.jsx("button",{onClick:t,disabled:!F,style:{padding:"8px 16px",borderRadius:4,border:"none",background:F?s.accent:s.border,color:"var(--nice-color-white, #fff)",cursor:F?"pointer":"not-allowed",fontSize:13},children:"+ Add"})]})]})]})]}),z==="actions"&&E&&e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:16,marginBottom:20},children:[e.jsxs("h4",{style:{margin:0,display:"inline-flex",alignItems:"center",gap:6},children:[e.jsx(a.NiceIcon,{name:"zap",size:16})," ",r("stateDesigner.actionsFor","Actions for {name}").replace("{name}",String(E.name))]}),e.jsx("button",{onClick:n,style:{padding:"6px 12px",borderRadius:4,border:"none",background:s.accent,color:"var(--nice-color-white, #fff)",cursor:"pointer",fontSize:12},children:"+ Add Action"})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12},children:E.actions.map(c=>e.jsxs("div",{style:{padding:16,background:s.cardBg,borderRadius:8,border:`1px solid ${G===c.id?s.accent:s.border}`,cursor:"pointer"},onClick:()=>O(c.id),children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{fontWeight:600,fontFamily:"monospace"},children:c.name}),c.async&&e.jsx("span",{style:{padding:"2px 6px",background:"var(--nice-accent-tint-12, #8b5cf620)",color:"var(--nice-color-accent, #8b5cf6)",borderRadius:4,fontSize:10},children:"async"}),e.jsxs("span",{style:{fontSize:11,color:s.textMuted},children:["(",c.params.map(ee=>`${ee.name}: ${ee.type}`).join(", "),")"]})]}),c.description&&e.jsx("div",{style:{fontSize:12,color:s.textMuted,marginTop:4},children:c.description}),e.jsxs("div",{style:{fontSize:11,color:s.textMuted,marginTop:8},children:[c.reducerSteps.length," reducer steps"]})]},c.id))})]}),z==="selectors"&&E&&e.jsxs("div",{children:[e.jsx("div",{style:{display:"flex",alignItems:"center",gap:16,marginBottom:20},children:e.jsxs("h4",{style:{margin:0,display:"inline-flex",alignItems:"center",gap:6},children:[e.jsx(a.NiceIcon,{name:"target",size:16})," ",r("stateDesigner.selectorsFor","Selectors for {name}").replace("{name}",String(E.name))]})}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12},children:E.selectors.map(c=>e.jsxs("div",{style:{padding:16,background:s.cardBg,borderRadius:8,border:`1px solid ${s.border}`},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{fontWeight:600,fontFamily:"monospace"},children:c.name}),c.memoized&&e.jsx("span",{style:{padding:"2px 6px",background:"var(--nice-success-tint-12, #22c55e20)",color:"var(--nice-color-success, #22c55e)",borderRadius:4,fontSize:10},children:"memoized"})]}),e.jsx("code",{style:{display:"block",marginTop:8,padding:8,background:s.bg,borderRadius:4,fontSize:12,color:"var(--nice-color-warning, #f59e0b)"},children:c.expression})]},c.id))})]}),z==="settings"&&e.jsxs("div",{style:{maxWidth:600},children:[e.jsx("h4",{style:{marginTop:0},children:r("stateDesigner.middleware","Middleware")}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12,marginBottom:24},children:i.middleware?.map(c=>e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:12,padding:12,background:s.cardBg,borderRadius:8,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:c.enabled,onChange:ee=>{const u=i.middleware?.map(W=>W.type===c.type?{...W,enabled:ee.target.checked}:W);V({middleware:u})}}),e.jsxs("div",{children:[e.jsx("div",{style:{fontWeight:500,textTransform:"capitalize"},children:c.type}),e.jsxs("div",{style:{fontSize:11,color:s.textMuted},children:[c.type==="immer"&&"Enable immutable state updates",c.type==="devtools"&&"Redux DevTools integration",c.type==="persist"&&"Persist state to storage"]})]})]},c.type))}),i.persist?.enabled&&e.jsxs(e.Fragment,{children:[e.jsx("h4",{children:r("stateDesigner.persistence","Persistence")}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12,marginBottom:24},children:[e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:12,color:s.textMuted,marginBottom:4},children:r("stateDesigner.storageKey","Storage Key")}),e.jsx("input",{type:"text",value:i.persist.key,onChange:c=>V({persist:{...i.persist,key:c.target.value}}),style:{padding:"8px 12px",borderRadius:4,border:`1px solid ${s.border}`,background:s.cardBg,color:s.text,fontSize:13,width:"100%",boxSizing:"border-box"}})]}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:12,color:s.textMuted,marginBottom:4},children:r("stateDesigner.storageType","Storage Type")}),e.jsxs("select",{value:i.persist.storage,onChange:c=>V({persist:{...i.persist,storage:c.target.value}}),style:{padding:"8px 12px",borderRadius:4,border:`1px solid ${s.border}`,background:s.cardBg,color:s.text,fontSize:13},children:[e.jsx("option",{value:"localStorage",children:"localStorage"}),e.jsx("option",{value:"sessionStorage",children:"sessionStorage"}),e.jsx("option",{value:"indexedDB",children:"indexedDB"})]})]})]})]})]}),z==="preview"&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,marginBottom:16},children:[e.jsxs("select",{value:T,onChange:c=>B(c.target.value),style:{padding:"8px 12px",borderRadius:4,border:`1px solid ${s.border}`,background:s.cardBg,color:s.text,fontSize:13},children:[e.jsx("option",{value:"zustand",children:r("stateDesigner.zustand","Zustand")}),e.jsx("option",{value:"redux-toolkit",children:r("stateDesigner.reduxToolkit","Redux Toolkit")}),e.jsx("option",{value:"jotai",children:r("stateDesigner.jotai","Jotai")}),e.jsx("option",{value:"recoil",children:r("stateDesigner.recoil","Recoil")}),e.jsx("option",{value:"mobx",children:r("stateDesigner.mobx","MobX")})]}),e.jsxs("button",{onClick:g,style:{padding:"8px 16px",borderRadius:4,border:"none",background:s.accent,color:"var(--nice-color-white, #fff)",cursor:"pointer",fontSize:13},children:[e.jsx(a.NiceIcon,{name:"upload",size:14})," ",r("stateDesigner.export","Export")]}),e.jsxs("button",{onClick:()=>navigator.clipboard.writeText(f),style:{padding:"8px 16px",borderRadius:4,border:`1px solid ${s.border}`,background:"transparent",color:s.text,cursor:"pointer",fontSize:13},children:[e.jsx(a.NiceIcon,{name:"clipboard",size:14})," ",r("stateDesigner.copy","Copy")]})]}),e.jsx("pre",{style:{flex:1,padding:16,background:s.cardBg,borderRadius:8,overflow:"auto",fontSize:12,fontFamily:"JetBrains Mono, Consolas, monospace",margin:0,whiteSpace:"pre-wrap"},children:f})]})]})}),H&&e.jsx("div",{style:{position:"fixed",inset:0,background:"var(--nice-overlay-70, rgba(0, 0, 0, 0.7))",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},onClick:()=>M(!1),children:e.jsxs("div",{style:{background:s.cardBg,borderRadius:12,padding:24,width:500,maxHeight:"80vh",overflow:"auto"},onClick:c=>c.stopPropagation(),children:[e.jsxs("h4",{style:{margin:"0 0 16px",display:"inline-flex",alignItems:"center",gap:6},children:[e.jsx(a.NiceIcon,{name:"clipboard",size:16})," ",r("stateDesigner.stateTemplates","State Templates")]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12},children:S.map(c=>e.jsx("button",{onClick:()=>{c.store.slices&&V({slices:[...i.slices,...c.store.slices]}),M(!1)},style:{padding:16,borderRadius:8,border:`1px solid ${s.border}`,background:s.bg,color:s.text,cursor:"pointer",textAlign:"left"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(a.NiceIcon,{name:c.icon,size:24}),e.jsxs("div",{children:[e.jsx("div",{style:{fontWeight:600},children:c.name}),e.jsx("div",{style:{fontSize:12,color:s.textMuted},children:c.description})]})]})},c.id))})]})})]})},bt=Object.freeze(Object.defineProperty({__proto__:null,NiceStateDesigner:qe},Symbol.toStringTag,{value:"Module"})),yt={id:"api-1",name:"UserAPI",description:"User management API client",baseUrl:"https://api.example.com/v1",version:"1.0.0",endpoints:[{id:"ep-1",name:"getUsers",description:"Get list of users",method:"GET",path:"/users",tags:["users"],queryParams:[{id:"p1",name:"page",type:"number",defaultValue:1},{id:"p2",name:"limit",type:"number",defaultValue:10},{id:"p3",name:"search",type:"string"}],responses:[{status:200,description:"Success",schema:{type:"array",items:{type:"object"}}},{status:401,description:"Unauthorized"}],cache:{enabled:!0,ttl:60,strategy:"stale-while-revalidate"}},{id:"ep-2",name:"getUserById",description:"Get single user by ID",method:"GET",path:"/users/{id}",tags:["users"],pathParams:[{id:"p1",name:"id",type:"string",required:!0}],responses:[{status:200,description:"Success"},{status:404,description:"Not found"}],cache:{enabled:!0,ttl:300,strategy:"cache-first"}},{id:"ep-3",name:"createUser",description:"Create new user",method:"POST",path:"/users",tags:["users"],body:{contentType:"application/json",schema:{type:"object",properties:{name:{type:"string"},email:{type:"string"},role:{type:"string"}},required:["name","email"]}},responses:[{status:201,description:"Created"},{status:400,description:"Validation error"}],retry:{enabled:!0,maxAttempts:3,backoff:"exponential",retryOn:[500,502,503]}},{id:"ep-4",name:"updateUser",description:"Update user by ID",method:"PUT",path:"/users/{id}",tags:["users"],pathParams:[{id:"p1",name:"id",type:"string",required:!0}],body:{contentType:"application/json",schema:{type:"object",properties:{name:{type:"string"},email:{type:"string"}}}},responses:[{status:200,description:"Updated"},{status:404,description:"Not found"}]},{id:"ep-5",name:"deleteUser",description:"Delete user by ID",method:"DELETE",path:"/users/{id}",tags:["users"],pathParams:[{id:"p1",name:"id",type:"string",required:!0}],responses:[{status:204,description:"Deleted"},{status:404,description:"Not found"}]}],auth:{type:"bearer",tokenSource:"state.auth.token",headerName:"Authorization",prefix:"Bearer"},globalHeaders:{"Content-Type":"application/json",Accept:"application/json"},errorHandling:{globalErrorHandler:!0,retryOnNetworkError:!0,transformError:!0},cacheConfig:{enabled:!0,storage:"memory",defaultTTL:300}},re={GET:"var(--nice-color-success, #22c55e)",POST:"var(--nice-color-primary, #3b82f6)",PUT:"var(--nice-color-warning, #f59e0b)",PATCH:"var(--nice-color-accent, #8b5cf6)",DELETE:"var(--nice-color-error, #ef4444)",HEAD:"var(--nice-text-muted, #6b7280)",OPTIONS:"var(--nice-text-muted, #6b7280)"},vt=o=>{const S=["import axios, { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios';"],b=[];o.endpoints.forEach(d=>{d.body?.schema&&b.push(`export interface ${ue(d.name)}Request ${He(d.body.schema)}`),b.push(`export interface ${ue(d.name)}Response {
35
+ // TODO: Define response type based on schema
36
+ data: unknown;
37
+ }`)});const j=[];o.endpoints.forEach(d=>{const C=d.pathParams?.map(q=>`${q.name}: ${q.type}`).join(", ")||"",r=d.queryParams?.length?`params?: { ${d.queryParams.map(q=>`${q.name}${q.required?"":"?"}: ${q.type}`).join("; ")} }`:"",i=d.body?`data: ${ue(d.name)}Request`:"",p=[C,r,i].filter(Boolean).join(", ");let z=`'${d.path}'`;d.pathParams?.forEach(q=>{z=z.replace(`{${q.name}}`,`\${${q.name}}`)}),d.pathParams?.length&&(z="`"+z.slice(1,-1)+"`");const w=d.cache?.enabled?`
38
+ // Cache: ${d.cache.strategy}, TTL: ${d.cache.ttl}s`:"",I=d.retry?.enabled?`
39
+ // Retry: ${d.retry.maxAttempts} attempts, ${d.retry.backoff} backoff`:"";j.push(`
40
+ /**
41
+ * ${d.description||d.name}${w}${I}
42
+ */
43
+ async ${d.name}(${p}): Promise<${ue(d.name)}Response> {
44
+ const response = await this.client.${d.method.toLowerCase()}<${ue(d.name)}Response>(
45
+ ${z}${d.queryParams?.length?", { params }":""}${d.body?", data":""}
46
+ );
47
+ return response.data;
48
+ }`)});let $="";o.auth?.type==="bearer"&&($=`
49
+ // Auth interceptor
50
+ this.client.interceptors.request.use((config) => {
51
+ const token = ${o.auth.tokenSource||"getToken()"};
52
+ if (token) {
53
+ config.headers['${o.auth.headerName||"Authorization"}'] = '${o.auth.prefix||"Bearer"} ' + token;
54
+ }
55
+ return config;
56
+ });`);const v=o.errorHandling?.globalErrorHandler?`
57
+ // Error interceptor
58
+ this.client.interceptors.response.use(
59
+ (response) => response,
60
+ (error) => {
61
+ // Transform and handle errors
62
+ const message = error.response?.data?.message || error.message;
63
+ console.error('[API Error]', message);
64
+ return Promise.reject(error);
65
+ }
66
+ );`:"";return`${S.join(`
67
+ `)}
68
+
69
+ // Types
70
+ ${b.join(`
71
+
72
+ `)}
73
+
74
+ // API Client
75
+ export class ${o.name} {
76
+ private client: AxiosInstance;
77
+
78
+ constructor(baseURL: string = '${o.baseUrl}') {
79
+ this.client = axios.create({
80
+ baseURL,
81
+ headers: ${JSON.stringify(o.globalHeaders||{},null,8).replace(/\n/g,`
82
+ `)},
83
+ });
84
+ ${$}${v}
85
+ }
86
+ ${j.join("")}
87
+ }
88
+
89
+ // Default instance
90
+ export const ${o.name.charAt(0).toLowerCase()+o.name.slice(1)} = new ${o.name}();
91
+ `},ue=o=>o.charAt(0).toUpperCase()+o.slice(1),He=o=>o.type==="object"&&o.properties?`{
92
+ ${Object.entries(o.properties).map(([b,j])=>{const $=o.required?.includes(b)?"":"?";return` ${b}${$}: ${Ue(j)};`}).join(`
93
+ `)}
94
+ }`:"{}",Ue=o=>{switch(o.type){case"string":return"string";case"number":return"number";case"boolean":return"boolean";case"array":return o.items?`${Ue(o.items)}[]`:"unknown[]";case"object":return o.properties?He(o):"Record<string, unknown>";default:return"unknown"}},We=({flow:o=yt,dataSources:S=[],onFlowChange:b,onExport:j,onTest:$,onSave:v,className:k,style:d,"data-testid":C})=>{const{t:r}=a.useNiceTranslation(),[i,p]=x.useState(o),[z,w]=x.useState("endpoints"),[I,q]=x.useState(i.endpoints[0]?.id||null),[G,O]=x.useState(!1),[T,B]=x.useState(null),[H,M]=x.useState(!1),m=x.useMemo(()=>i.endpoints.find(t=>t.id===I),[i.endpoints,I]),D=x.useCallback(t=>{const n={...i,...t};p(n),b?.(n)},[i,b]),F=x.useCallback((t,n)=>{const g=i.endpoints.map(f=>f.id===t?{...f,...n}:f);D({endpoints:g})},[i.endpoints,D]),Y=t=>{const n={id:`ep-${Date.now()}`,name:"newEndpoint",method:t,path:"/new-path",responses:[{status:200,description:"Success"}]};D({endpoints:[...i.endpoints,n]}),q(n.id),O(!1)},_=t=>{D({endpoints:i.endpoints.filter(n=>n.id!==t)}),I===t&&q(i.endpoints[0]?.id||null)},Z=async()=>{m&&(M(!0),B(null),await new Promise(t=>setTimeout(t,1e3)),B({status:200,body:{message:"Mock response",timestamp:new Date().toISOString()}}),M(!1),$?.(m.id))},E=x.useMemo(()=>vt(i),[i]),V=()=>{j?.(E)};x.useMemo(()=>{const t=new Set;return i.endpoints.forEach(n=>n.tags?.forEach(g=>t.add(g))),Array.from(t)},[i.endpoints]);const h={bg:"var(--nice-bg-elevated, #1e1e1e)",cardBg:"var(--nice-bg-elevated, #252525)",border:"var(--nice-bg-tertiary, #333)",text:"var(--nice-text-primary, #e0e0e0)",textMuted:"var(--nice-text-muted, #888)",accent:"var(--nice-color-primary, #3b82f6)"};return e.jsxs("div",{className:`nice-api-flow ${k||""}`,style:{display:"flex",flexDirection:"column",height:"100%",background:h.bg,color:h.text,fontFamily:"system-ui, sans-serif",...d},"data-testid":C,children:[e.jsxs("div",{style:{padding:"16px 20px",borderBottom:`1px solid ${h.border}`,display:"flex",alignItems:"center",gap:16},children:[e.jsxs("h3",{style:{margin:0,fontSize:18},children:[e.jsx(a.NiceIcon,{name:"plug",size:16})," ",r("apiFlow.apiFlow","API Flow")]}),e.jsx("input",{type:"text",value:i.name,onChange:t=>D({name:t.target.value}),style:{padding:"6px 12px",borderRadius:4,border:`1px solid ${h.border}`,background:h.cardBg,color:h.text,fontSize:14,fontWeight:600}}),e.jsx("input",{type:"text",value:i.baseUrl,onChange:t=>D({baseUrl:t.target.value}),placeholder:r("apiFlow.baseUrl","Base URL"),style:{padding:"6px 12px",borderRadius:4,border:`1px solid ${h.border}`,background:h.cardBg,color:h.text,fontSize:13,width:300}}),e.jsx("div",{style:{marginLeft:"auto",display:"flex",gap:8},children:e.jsxs("button",{onClick:()=>v?.(i),style:{padding:"8px 16px",borderRadius:6,border:"none",background:"var(--nice-color-success, #22c55e)",color:"var(--nice-text-on-primary, #fff)",cursor:"pointer",fontSize:13,fontWeight:500},children:[e.jsx(a.NiceIcon,{name:"save",size:14})," ",r("apiFlow.save","Save")]})})]}),e.jsx("div",{style:{display:"flex",borderBottom:`1px solid ${h.border}`,padding:"0 20px"},children:["endpoints","auth","settings","test","preview"].map(t=>e.jsxs("button",{onClick:()=>w(t),style:{padding:"12px 20px",border:"none",background:"transparent",color:z===t?h.text:h.textMuted,cursor:"pointer",fontSize:13,fontWeight:z===t?600:400,borderBottom:z===t?`2px solid ${h.accent}`:"2px solid transparent",marginBottom:-1},children:[t==="endpoints"&&e.jsxs(e.Fragment,{children:[e.jsx(a.NiceIcon,{name:"link",size:14})," ",r("apiFlow.endpoints","Endpoints")]}),t==="auth"&&e.jsxs(e.Fragment,{children:[e.jsx(a.NiceIcon,{name:"lock",size:14})," ",r("apiFlow.auth","Auth")]}),t==="settings"&&e.jsxs(e.Fragment,{children:[e.jsx(a.NiceIcon,{name:"settings",size:14})," ",r("apiFlow.settings","Settings")]}),t==="test"&&e.jsxs(e.Fragment,{children:[e.jsx(a.NiceIcon,{name:"flask",size:14})," ",r("apiFlow.test","Test")]}),t==="preview"&&e.jsxs(e.Fragment,{children:[e.jsx(a.NiceIcon,{name:"eye",size:14})," ",r("apiFlow.preview","Preview")]})]},t))}),e.jsxs("div",{style:{flex:1,display:"flex",overflow:"hidden"},children:[z==="endpoints"&&e.jsxs("div",{style:{width:280,borderRight:`1px solid ${h.border}`,padding:12,display:"flex",flexDirection:"column",gap:4,overflow:"auto"},children:[e.jsxs("div",{style:{fontSize:11,color:h.textMuted,marginBottom:8},children:["ENDPOINTS (",i.endpoints.length,")"]}),i.endpoints.map(t=>e.jsxs("button",{onClick:()=>q(t.id),style:{padding:"10px 12px",borderRadius:6,border:"none",background:I===t.id?h.accent+"30":h.cardBg,color:h.text,cursor:"pointer",textAlign:"left",display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{padding:"2px 6px",borderRadius:4,background:re[t.method]+"30",color:re[t.method],fontSize:10,fontWeight:600},children:t.method}),e.jsxs("div",{style:{flex:1,overflow:"hidden"},children:[e.jsx("div",{style:{fontFamily:"monospace",fontSize:12},children:t.name}),e.jsx("div",{style:{fontSize:10,color:h.textMuted,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:t.path})]})]},t.id)),e.jsx("button",{onClick:()=>O(!0),style:{padding:"10px 12px",borderRadius:6,border:`1px dashed ${h.border}`,background:"transparent",color:h.textMuted,cursor:"pointer",fontSize:13,marginTop:8},children:"+ Add Endpoint"})]}),e.jsxs("div",{style:{flex:1,overflow:"auto",padding:20},children:[z==="endpoints"&&m&&e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,marginBottom:24},children:[e.jsx("select",{value:m.method,onChange:t=>F(m.id,{method:t.target.value}),style:{padding:"8px 12px",borderRadius:6,border:"none",background:re[m.method]+"30",color:re[m.method],fontSize:13,fontWeight:600,cursor:"pointer"},children:["GET","POST","PUT","PATCH","DELETE"].map(t=>e.jsx("option",{value:t,children:t},t))}),e.jsx("input",{type:"text",value:m.path,onChange:t=>F(m.id,{path:t.target.value}),style:{flex:1,padding:"8px 12px",borderRadius:6,border:`1px solid ${h.border}`,background:h.cardBg,color:h.text,fontSize:14,fontFamily:"monospace"}}),e.jsxs("button",{onClick:()=>_(m.id),style:{padding:"8px 12px",borderRadius:6,border:`1px solid ${h.border}`,background:"transparent",color:"var(--nice-color-error, #ef4444)",cursor:"pointer",fontSize:13},children:[e.jsx(a.NiceIcon,{name:"trash",size:14})," ",r("apiFlow.delete","Delete")]})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 2fr",gap:16,marginBottom:24},children:[e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:12,color:h.textMuted,marginBottom:4},children:r("apiFlow.name","Name")}),e.jsx("input",{type:"text",value:m.name,onChange:t=>F(m.id,{name:t.target.value}),style:{width:"100%",padding:"8px 12px",borderRadius:6,border:`1px solid ${h.border}`,background:h.cardBg,color:h.text,fontSize:13,fontFamily:"monospace",boxSizing:"border-box"}})]}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:12,color:h.textMuted,marginBottom:4},children:r("apiFlow.description","Description")}),e.jsx("input",{type:"text",value:m.description||"",onChange:t=>F(m.id,{description:t.target.value}),style:{width:"100%",padding:"8px 12px",borderRadius:6,border:`1px solid ${h.border}`,background:h.cardBg,color:h.text,fontSize:13,boxSizing:"border-box"}})]})]}),e.jsxs("div",{style:{marginBottom:24},children:[e.jsxs("h4",{style:{margin:"0 0 12px",display:"flex",alignItems:"center",gap:8},children:[e.jsx(a.NiceIcon,{name:"clipboard",size:14})," ",r("apiFlow.parameters","Parameters")]}),m.pathParams&&m.pathParams.length>0&&e.jsxs("div",{style:{marginBottom:16},children:[e.jsx("div",{style:{fontSize:11,color:h.textMuted,marginBottom:8},children:r("apiFlow.pathParameters","PATH PARAMETERS")}),m.pathParams.map(t=>e.jsxs("div",{style:{padding:12,background:h.cardBg,borderRadius:6,marginBottom:8,display:"flex",gap:12,alignItems:"center"},children:[e.jsx("code",{style:{fontWeight:600},children:t.name}),e.jsx("span",{style:{color:h.textMuted,fontSize:12},children:t.type}),t.required&&e.jsx("span",{style:{color:"var(--nice-color-error, #ef4444)",fontSize:10},children:"required"})]},t.id))]}),m.queryParams&&m.queryParams.length>0&&e.jsxs("div",{style:{marginBottom:16},children:[e.jsx("div",{style:{fontSize:11,color:h.textMuted,marginBottom:8},children:r("apiFlow.queryParameters","QUERY PARAMETERS")}),m.queryParams.map(t=>e.jsxs("div",{style:{padding:12,background:h.cardBg,borderRadius:6,marginBottom:8,display:"flex",gap:12,alignItems:"center"},children:[e.jsx("code",{style:{fontWeight:600},children:t.name}),e.jsx("span",{style:{color:h.textMuted,fontSize:12},children:t.type}),t.defaultValue!==void 0&&e.jsxs("span",{style:{color:"var(--nice-color-warning, #f59e0b)",fontSize:11},children:["= ",JSON.stringify(t.defaultValue)]})]},t.id))]}),m.body&&e.jsxs("div",{style:{marginBottom:16},children:[e.jsx("div",{style:{fontSize:11,color:h.textMuted,marginBottom:8},children:r("apiFlow.requestBody","REQUEST BODY")}),e.jsxs("div",{style:{padding:12,background:h.cardBg,borderRadius:6},children:[e.jsxs("div",{style:{fontSize:12,marginBottom:8},children:["Content-Type: ",e.jsx("code",{children:m.body.contentType})]}),m.body.schema&&e.jsx("pre",{style:{margin:0,padding:12,background:h.bg,borderRadius:4,fontSize:11,overflow:"auto"},children:JSON.stringify(m.body.schema,null,2)})]})]})]}),e.jsxs("div",{style:{marginBottom:24},children:[e.jsxs("h4",{style:{margin:"0 0 12px"},children:[e.jsx(a.NiceIcon,{name:"upload",size:16})," ",r("apiFlow.responses","Responses")]}),e.jsx("div",{style:{display:"flex",gap:12,flexWrap:"wrap"},children:m.responses.map(t=>e.jsxs("div",{style:{padding:12,background:h.cardBg,borderRadius:6,minWidth:120},children:[e.jsx("div",{style:{fontSize:18,fontWeight:600,color:t.status<300?"var(--nice-color-success, #22c55e)":t.status<400?"var(--nice-color-warning, #f59e0b)":"var(--nice-color-error, #ef4444)"},children:t.status}),e.jsx("div",{style:{fontSize:11,color:h.textMuted},children:t.description})]},t.status))})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[e.jsxs("div",{style:{padding:16,background:h.cardBg,borderRadius:8},children:[e.jsxs("h5",{style:{margin:"0 0 12px",display:"flex",alignItems:"center",gap:8},children:[e.jsx("input",{type:"checkbox",checked:m.cache?.enabled||!1,onChange:t=>F(m.id,{cache:{...m.cache,enabled:t.target.checked}})}),e.jsx(a.NiceIcon,{name:"box",size:14})," ",r("apiFlow.cache","Cache")]}),m.cache?.enabled&&e.jsxs("div",{style:{fontSize:12,color:h.textMuted},children:["TTL: ",m.cache.ttl,"s • Strategy: ",m.cache.strategy]})]}),e.jsxs("div",{style:{padding:16,background:h.cardBg,borderRadius:8},children:[e.jsxs("h5",{style:{margin:"0 0 12px",display:"flex",alignItems:"center",gap:8},children:[e.jsx("input",{type:"checkbox",checked:m.retry?.enabled||!1,onChange:t=>F(m.id,{retry:{...m.retry,enabled:t.target.checked,maxAttempts:3,backoff:"exponential"}})}),e.jsx(a.NiceIcon,{name:"refresh",size:14})," ",r("apiFlow.retry","Retry")]}),m.retry?.enabled&&e.jsxs("div",{style:{fontSize:12,color:h.textMuted},children:["Max: ",m.retry.maxAttempts," • ",m.retry.backoff," ","backoff"]})]})]})]}),z==="auth"&&e.jsxs("div",{style:{maxWidth:500},children:[e.jsxs("h4",{style:{marginTop:0},children:[e.jsx(a.NiceIcon,{name:"lock",size:16})," ",r("apiFlow.authentication","Authentication")]}),e.jsxs("div",{style:{marginBottom:24},children:[e.jsx("label",{style:{display:"block",fontSize:12,color:h.textMuted,marginBottom:8},children:r("apiFlow.authType","Auth Type")}),e.jsxs("select",{value:i.auth?.type||"none",onChange:t=>D({auth:{...i.auth,type:t.target.value}}),style:{padding:"10px 12px",borderRadius:6,border:`1px solid ${h.border}`,background:h.cardBg,color:h.text,fontSize:13,width:"100%"},children:[e.jsx("option",{value:"none",children:r("apiFlow.none","None")}),e.jsx("option",{value:"bearer",children:r("apiFlow.bearerToken","Bearer Token")}),e.jsx("option",{value:"basic",children:r("apiFlow.basicAuth","Basic Auth")}),e.jsx("option",{value:"api-key",children:r("apiFlow.apiKey","API Key")}),e.jsx("option",{value:"oauth2",children:r("apiFlow.oauth20","OAuth 2.0")})]})]}),i.auth?.type==="bearer"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{marginBottom:16},children:[e.jsx("label",{style:{display:"block",fontSize:12,color:h.textMuted,marginBottom:8},children:r("apiFlow.tokenSource","Token Source")}),e.jsx("input",{type:"text",value:i.auth.tokenSource||"",onChange:t=>D({auth:{...i.auth,tokenSource:t.target.value}}),placeholder:"state.auth.token",style:{width:"100%",padding:"10px 12px",borderRadius:6,border:`1px solid ${h.border}`,background:h.cardBg,color:h.text,fontSize:13,fontFamily:"monospace",boxSizing:"border-box"}})]}),e.jsxs("div",{style:{marginBottom:16},children:[e.jsx("label",{style:{display:"block",fontSize:12,color:h.textMuted,marginBottom:8},children:r("apiFlow.headerName","Header Name")}),e.jsx("input",{type:"text",value:i.auth.headerName||"Authorization",onChange:t=>D({auth:{...i.auth,headerName:t.target.value}}),style:{width:"100%",padding:"10px 12px",borderRadius:6,border:`1px solid ${h.border}`,background:h.cardBg,color:h.text,fontSize:13,boxSizing:"border-box"}})]})]}),e.jsxs("h4",{children:[e.jsx(a.NiceIcon,{name:"globe",size:16})," ",r("apiFlow.globalHeaders","Global Headers")]}),e.jsx("div",{style:{padding:16,background:h.cardBg,borderRadius:8},children:Object.entries(i.globalHeaders||{}).map(([t,n])=>e.jsxs("div",{style:{display:"flex",gap:8,marginBottom:8,alignItems:"center"},children:[e.jsx("code",{style:{flex:1},children:t}),e.jsx("span",{style:{color:h.textMuted},children:":"}),e.jsx("code",{style:{flex:2,color:"var(--nice-color-success, #22c55e)"},children:n})]},t))})]}),z==="settings"&&e.jsxs("div",{style:{maxWidth:500},children:[e.jsxs("h4",{style:{marginTop:0},children:[e.jsx(a.NiceIcon,{name:"settings",size:16})," ",r("apiFlow.globalSettings","Global Settings")]}),e.jsxs("div",{style:{marginBottom:24},children:[e.jsx("h5",{children:r("apiFlow.errorHandling","Error Handling")}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:12,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:i.errorHandling?.globalErrorHandler||!1,onChange:t=>D({errorHandling:{...i.errorHandling,globalErrorHandler:t.target.checked}})}),r("apiFlow.globalErrorHandler","Global error handler")]}),e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:12,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:i.errorHandling?.retryOnNetworkError||!1,onChange:t=>D({errorHandling:{...i.errorHandling,retryOnNetworkError:t.target.checked}})}),r("apiFlow.retryOnNetworkErrors","Retry on network errors")]}),e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:12,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:i.errorHandling?.transformError||!1,onChange:t=>D({errorHandling:{...i.errorHandling,transformError:t.target.checked}})}),r("apiFlow.transformErrorResponses","Transform error responses")]})]})]}),e.jsxs("div",{style:{marginBottom:24},children:[e.jsx("h5",{children:r("apiFlow.defaultCacheSettings","Default Cache Settings")}),e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:12,marginBottom:12,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:i.cacheConfig?.enabled||!1,onChange:t=>D({cacheConfig:{...i.cacheConfig,enabled:t.target.checked}})}),r("apiFlow.enableCaching","Enable caching")]}),i.cacheConfig?.enabled&&e.jsxs("div",{style:{display:"flex",gap:16},children:[e.jsxs("div",{children:[e.jsx("label",{style:{fontSize:12,color:h.textMuted},children:r("apiFlow.storage","Storage")}),e.jsxs("select",{value:i.cacheConfig.storage,onChange:t=>D({cacheConfig:{...i.cacheConfig,storage:t.target.value}}),style:{display:"block",marginTop:4,padding:"8px 12px",borderRadius:4,border:`1px solid ${h.border}`,background:h.cardBg,color:h.text,fontSize:13},children:[e.jsx("option",{value:"memory",children:r("apiFlow.memory","Memory")}),e.jsx("option",{value:"localStorage",children:"localStorage"}),e.jsx("option",{value:"sessionStorage",children:"sessionStorage"})]})]}),e.jsxs("div",{children:[e.jsx("label",{style:{fontSize:12,color:h.textMuted},children:"Default TTL (seconds)"}),e.jsx("input",{type:"number",value:i.cacheConfig.defaultTTL,onChange:t=>D({cacheConfig:{...i.cacheConfig,defaultTTL:parseInt(t.target.value)}}),style:{display:"block",marginTop:4,padding:"8px 12px",borderRadius:4,border:`1px solid ${h.border}`,background:h.cardBg,color:h.text,fontSize:13,width:100}})]})]})]})]}),z==="test"&&m&&e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,marginBottom:24},children:[e.jsx("span",{style:{padding:"4px 8px",borderRadius:4,background:re[m.method]+"30",color:re[m.method],fontSize:12,fontWeight:600},children:m.method}),e.jsxs("code",{style:{flex:1,fontSize:14},children:[i.baseUrl,m.path]}),e.jsx("button",{onClick:Z,disabled:H,style:{padding:"10px 20px",borderRadius:6,border:"none",background:h.accent,color:"var(--nice-color-white, #fff)",cursor:H?"not-allowed":"pointer",fontSize:13,fontWeight:500,opacity:H?.7:1},children:H?e.jsxs(e.Fragment,{children:[e.jsx(a.NiceIcon,{name:"clock",size:14})," ",r("apiFlow.testing","Testing...")]}):e.jsxs(e.Fragment,{children:[e.jsx(a.NiceIcon,{name:"rocket",size:14})," ",r("apiFlow.sendRequest","Send Request")]})})]}),T&&e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,marginBottom:12},children:[e.jsx("span",{style:{fontSize:18,fontWeight:600,color:T.status<300?"var(--nice-color-success, #22c55e)":"var(--nice-color-error, #ef4444)"},children:T.status}),e.jsx("span",{style:{color:h.textMuted},children:T.status<300?"OK":"Error"})]}),e.jsx("pre",{style:{padding:16,background:h.cardBg,borderRadius:8,overflow:"auto",fontSize:12,fontFamily:"JetBrains Mono, Consolas, monospace",margin:0},children:JSON.stringify(T.body,null,2)})]})]}),z==="preview"&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%"},children:[e.jsxs("div",{style:{display:"flex",gap:12,marginBottom:16},children:[e.jsxs("button",{onClick:V,style:{padding:"8px 16px",borderRadius:4,border:"none",background:h.accent,color:"var(--nice-color-white, #fff)",cursor:"pointer",fontSize:13},children:[e.jsx(a.NiceIcon,{name:"upload",size:14})," ",r("apiFlow.export","Export")]}),e.jsxs("button",{onClick:()=>navigator.clipboard.writeText(E),style:{padding:"8px 16px",borderRadius:4,border:`1px solid ${h.border}`,background:"transparent",color:h.text,cursor:"pointer",fontSize:13},children:[e.jsx(a.NiceIcon,{name:"clipboard",size:14})," ",r("apiFlow.copy","Copy")]})]}),e.jsx("pre",{style:{flex:1,padding:16,background:h.cardBg,borderRadius:8,overflow:"auto",fontSize:12,fontFamily:"JetBrains Mono, Consolas, monospace",margin:0,whiteSpace:"pre-wrap"},children:E})]})]})]}),G&&e.jsx("div",{style:{position:"fixed",inset:0,background:"var(--nice-overlay-70, rgba(0, 0, 0, 0.7))",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},onClick:()=>O(!1),children:e.jsxs("div",{style:{background:h.cardBg,borderRadius:12,padding:24,width:400},onClick:t=>t.stopPropagation(),children:[e.jsxs("h4",{style:{margin:"0 0 16px"},children:[e.jsx(a.NiceIcon,{name:"plus",size:16})," ",r("apiFlow.addEndpoint","Add Endpoint")]}),e.jsx("p",{style:{color:h.textMuted,fontSize:13,marginBottom:16},children:"Select HTTP method for new endpoint:"}),e.jsx("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:["GET","POST","PUT","PATCH","DELETE"].map(t=>e.jsx("button",{onClick:()=>Y(t),style:{padding:"12px 24px",borderRadius:6,border:"none",background:re[t]+"30",color:re[t],cursor:"pointer",fontSize:14,fontWeight:600},children:t},t))})]})})]})},jt=Object.freeze(Object.defineProperty({__proto__:null,NiceAPIFlow:We},Symbol.toStringTag,{value:"Module"})),St={id:"map-1",name:"UserToContact",description:"Transform User API response to Contact entity",sourceSchema:{name:"UserResponse",type:"object",fields:[{id:"s1",name:"id",path:"id",type:"number"},{id:"s2",name:"firstName",path:"firstName",type:"string"},{id:"s3",name:"lastName",path:"lastName",type:"string"},{id:"s4",name:"email",path:"email",type:"string"},{id:"s5",name:"phone",path:"phone",type:"string",nullable:!0},{id:"s6",name:"address",path:"address",type:"object",children:[{id:"s6a",name:"street",path:"address.street",type:"string"},{id:"s6b",name:"city",path:"address.city",type:"string"},{id:"s6c",name:"zipCode",path:"address.zipCode",type:"string"},{id:"s6d",name:"country",path:"address.country",type:"string"}]},{id:"s7",name:"metadata",path:"metadata",type:"object",children:[{id:"s7a",name:"createdAt",path:"metadata.createdAt",type:"date"},{id:"s7b",name:"updatedAt",path:"metadata.updatedAt",type:"date"}]}]},targetSchema:{name:"Contact",type:"object",fields:[{id:"t1",name:"contactId",path:"contactId",type:"string"},{id:"t2",name:"fullName",path:"fullName",type:"string"},{id:"t3",name:"emailAddress",path:"emailAddress",type:"string"},{id:"t4",name:"phoneNumber",path:"phoneNumber",type:"string",nullable:!0},{id:"t5",name:"location",path:"location",type:"string"},{id:"t6",name:"fullAddress",path:"fullAddress",type:"string"},{id:"t7",name:"createdDate",path:"createdDate",type:"string"},{id:"t8",name:"isActive",path:"isActive",type:"boolean"}]},fieldMappings:[{id:"m1",sourceField:"id",targetField:"contactId",transform:"tr-1"},{id:"m2",sourceField:"firstName,lastName",targetField:"fullName",transform:"tr-2"},{id:"m3",sourceField:"email",targetField:"emailAddress"},{id:"m4",sourceField:"phone",targetField:"phoneNumber",defaultValue:""},{id:"m5",sourceField:"address.city,address.country",targetField:"location",transform:"tr-3"},{id:"m6",sourceField:"address",targetField:"fullAddress",transform:"tr-4"},{id:"m7",sourceField:"metadata.createdAt",targetField:"createdDate",transform:"tr-5"},{id:"m8",sourceField:"",targetField:"isActive",defaultValue:!0}],transformations:[{id:"tr-1",name:"ID to String",type:"format",config:{format:"USR-{value}"}},{id:"tr-2",name:"Full Name",type:"concat",config:{separator:" "}},{id:"tr-3",name:"Location",type:"concat",config:{separator:", "}},{id:"tr-4",name:"Full Address",type:"custom",config:{expression:"`${address.street}, ${address.zipCode} ${address.city}, ${address.country}`"}},{id:"tr-5",name:"Format Date",type:"format",config:{format:"YYYY-MM-DD"}}],validationRules:[{id:"v1",field:"emailAddress",type:"required",message:"Email is required"},{id:"v2",field:"emailAddress",type:"pattern",value:"^\\S+@\\S+\\.\\S+$",message:"Invalid email format"},{id:"v3",field:"contactId",type:"required",message:"Contact ID is required"}]},De={string:"var(--nice-color-success, #22c55e)",number:"var(--nice-color-primary, #3b82f6)",boolean:"var(--nice-color-warning, #f59e0b)",date:"var(--nice-color-accent, #8b5cf6)",array:"var(--nice-color-info, #06b6d4)",object:"var(--nice-color-accent-pink, #ec4899)",any:"var(--nice-text-muted, #6b7280)"},Fe={string:"edit",number:"hash",boolean:"check",date:"calendar",array:"clipboard",object:"box",any:"help"},Ee={direct:"arrow-right",format:"edit",convert:"refresh",concat:"link",split:"shuffle",calculate:"hash",lookup:"search",conditional:"help",custom:"settings"},wt=o=>{const S=Ae(o.sourceSchema),b=Ae(o.targetSchema),j=o.fieldMappings.map(v=>{const k=o.transformations.find(r=>r.id===v.transform),d=v.targetField;if(!v.sourceField)return` result.${d} = ${JSON.stringify(v.defaultValue)};`;const C=v.sourceField.split(",").map(r=>r.trim());if(k)switch(k.type){case"concat":return` result.${d} = [${C.map(r=>`source.${r}`).join(", ")}].filter(Boolean).join('${k.config.separator||" "}');`;case"format":if(C.length===1){const r=k.config.format||"{value}";return r.includes("{value}")?` result.${d} = '${r}'.replace('{value}', String(source.${C[0]}));`:` result.${d} = formatDate(source.${C[0]}, '${r}');`}break;case"custom":return` result.${d} = ${k.config.expression?.replace(/(\w+)\.(\w+)/g,"source.$1.$2")};`;case"convert":return` result.${d} = ${k.config.convertTo}(source.${C[0]});`}if(C.length===1){const r=v.defaultValue!==void 0?` ?? ${JSON.stringify(v.defaultValue)}`:"";return` result.${d} = source.${C[0]}${r};`}return` // TODO: Manual mapping for ${d}`}),$=o.validationRules.map(v=>{switch(v.type){case"required":return` if (!data.${v.field}) errors.push('${v.message||v.field+" is required"}');`;case"pattern":return` if (data.${v.field} && !/${v.value}/.test(data.${v.field})) errors.push('${v.message||"Invalid format"}');`;default:return` // ${v.type} validation for ${v.field}`}});return`/**
95
+ * ${o.name}
96
+ * ${o.description||""}
97
+ * Auto-generated by NiceDataMapper
98
+ */
99
+
100
+ // Source Type
101
+ ${S}
102
+
103
+ // Target Type
104
+ ${b}
105
+
106
+ // Validation
107
+ export function validate${o.targetSchema.name}(data: ${o.targetSchema.name}): string[] {
108
+ const errors: string[] = [];
109
+ ${$.join(`
110
+ `)}
111
+ return errors;
112
+ }
113
+
114
+ // Mapper
115
+ export function ${o.name.charAt(0).toLowerCase()+o.name.slice(1)}(source: ${o.sourceSchema.name}): ${o.targetSchema.name} {
116
+ const result = {} as ${o.targetSchema.name};
117
+
118
+ ${j.join(`
119
+ `)}
120
+
121
+ return result;
122
+ }
123
+
124
+ // Helper functions
125
+ function formatDate(date: string | Date, format: string): string {
126
+ const d = typeof date === 'string' ? new Date(date) : date;
127
+ const year = d.getFullYear();
128
+ const month = String(d.getMonth() + 1).padStart(2, '0');
129
+ const day = String(d.getDate()).padStart(2, '0');
130
+ return format
131
+ .replace('YYYY', String(year))
132
+ .replace('MM', month)
133
+ .replace('DD', day);
134
+ }
135
+ `},Ae=(o,S)=>{const b=($,v)=>{const k=" ".repeat(v),d=$.nullable?"?":"";if($.type==="object"&&$.children){const r=$.children.map(i=>b(i,v+1)).join(`
136
+ `);return`${k}${$.name}${d}: {
137
+ ${r}
138
+ ${k}};`}const C={string:"string",number:"number",boolean:"boolean",date:"string | Date",array:"unknown[]",object:"Record<string, unknown>",any:"unknown"}[$.type];return`${k}${$.name}${d}: ${C};`},j=o.fields.map($=>b($,1)).join(`
139
+ `);return`interface ${o.name} {
140
+ ${j}
141
+ }`},Je=({mapping:o=St,sourceSchemas:S=[],targetSchemas:b=[],onMappingChange:j,onExport:$,onTest:v,onSave:k,className:d,style:C,"data-testid":r})=>{const{t:i}=a.useNiceTranslation(),[p,z]=x.useState(o),[w,I]=x.useState("mapping"),[q,G]=x.useState(null),[O,T]=x.useState(""),[B,H]=x.useState(""),[M,m]=x.useState(null),D=x.useCallback(n=>{const g={...p,...n};z(g),j?.(g)},[p,j]),F=(n,g="")=>{const f=[];return n.forEach(s=>{f.push(s),s.children&&f.push(...F(s.children,s.path+"."))}),f},Y=x.useMemo(()=>F(p.sourceSchema.fields),[p.sourceSchema.fields]),_=x.useMemo(()=>F(p.targetSchema.fields),[p.targetSchema.fields]),Z=(n,g)=>{const f={id:`mapping-${Date.now()}`,sourceField:n,targetField:g};D({fieldMappings:[...p.fieldMappings,f]})},E=n=>{D({fieldMappings:p.fieldMappings.filter(g=>g.id!==n)})},V=()=>{try{const n=JSON.parse(O),g={};p.fieldMappings.forEach(f=>{if(!f.sourceField){g[f.targetField]=f.defaultValue;return}const s=f.sourceField.split(",").map(Q=>Q.trim()),N=Q=>Q.split(".").reduce((te,c)=>te?.[c],n),l=p.transformations.find(Q=>Q.id===f.transform);if(l?.type==="concat")g[f.targetField]=s.map(N).filter(Boolean).join(l.config.separator||" ");else if(l?.type==="format"&&s.length===1){const Q=N(s[0]);g[f.targetField]=(l.config.format||"{value}").replace("{value}",String(Q))}else s.length===1&&(g[f.targetField]=N(s[0])??f.defaultValue)}),H(JSON.stringify(g,null,2)),v?.(g)}catch(n){H(`Error: ${n.message}`)}},h=x.useMemo(()=>wt(p),[p]),t={bg:"var(--nice-bg-elevated, #1e1e1e)",cardBg:"var(--nice-bg-elevated, #252525)",border:"var(--nice-bg-tertiary, #333)",text:"var(--nice-text-primary, #e0e0e0)",textMuted:"var(--nice-text-muted, #888)",accent:"var(--nice-color-primary, #3b82f6)"};return e.jsxs("div",{className:`nice-data-mapper ${d||""}`,style:{display:"flex",flexDirection:"column",height:"100%",background:t.bg,color:t.text,fontFamily:"system-ui, sans-serif",...C},"data-testid":r,children:[e.jsxs("div",{style:{padding:"16px 20px",borderBottom:`1px solid ${t.border}`,display:"flex",alignItems:"center",gap:16},children:[e.jsxs("h3",{style:{margin:0,fontSize:18,display:"inline-flex",alignItems:"center",gap:6},children:[e.jsx(a.NiceIcon,{name:"refresh",size:16})," ",i("dataMapper.dataMapper","Data Mapper")]}),e.jsx("input",{type:"text",value:p.name,onChange:n=>D({name:n.target.value}),style:{padding:"6px 12px",borderRadius:4,border:`1px solid ${t.border}`,background:t.cardBg,color:t.text,fontSize:14,fontWeight:600}}),e.jsx("div",{style:{marginLeft:"auto",display:"flex",gap:8},children:e.jsxs("button",{onClick:()=>k?.(p),style:{padding:"8px 16px",borderRadius:6,border:"none",background:"var(--nice-color-success, #22c55e)",color:"var(--nice-text-on-primary, #fff)",cursor:"pointer",fontSize:13,fontWeight:500},children:[e.jsx(a.NiceIcon,{name:"save",size:14})," ",i("dataMapper.save","Save")]})})]}),e.jsx("div",{style:{display:"flex",borderBottom:`1px solid ${t.border}`,padding:"0 20px"},children:["mapping","transforms","validation","test","preview"].map(n=>e.jsxs("button",{onClick:()=>I(n),style:{padding:"12px 20px",border:"none",background:"transparent",color:w===n?t.text:t.textMuted,cursor:"pointer",fontSize:13,fontWeight:w===n?600:400,borderBottom:w===n?`2px solid ${t.accent}`:"2px solid transparent",marginBottom:-1},children:[n==="mapping"&&e.jsxs(e.Fragment,{children:[e.jsx(a.NiceIcon,{name:"link",size:14})," ",i("dataMapper.mapping","Mapping")]}),n==="transforms"&&e.jsxs(e.Fragment,{children:[e.jsx(a.NiceIcon,{name:"zap",size:14})," ",i("dataMapper.transforms","Transforms")]}),n==="validation"&&e.jsxs(e.Fragment,{children:[e.jsx(a.NiceIcon,{name:"check",size:14})," ",i("dataMapper.validation","Validation")]}),n==="test"&&e.jsxs(e.Fragment,{children:[e.jsx(a.NiceIcon,{name:"flask",size:14})," ",i("dataMapper.test","Test")]}),n==="preview"&&e.jsxs(e.Fragment,{children:[e.jsx(a.NiceIcon,{name:"eye",size:14})," ",i("dataMapper.preview","Preview")]})]},n))}),e.jsxs("div",{style:{flex:1,overflow:"auto",padding:20},children:[w==="mapping"&&e.jsxs("div",{style:{display:"flex",gap:24,height:"100%"},children:[e.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column"},children:[e.jsxs("div",{style:{padding:"12px 16px",background:"var(--nice-success-tint-12, #22c55e20)",borderRadius:"8px 8px 0 0",fontSize:13,fontWeight:600},children:[e.jsx(a.NiceIcon,{name:"download",size:14})," Source: ",p.sourceSchema.name]}),e.jsx("div",{style:{flex:1,border:`1px solid ${t.border}`,borderTop:"none",borderRadius:"0 0 8px 8px",overflow:"auto"},children:Y.map(n=>{const g=n.path.split(".").length-1,f=p.fieldMappings.some(s=>s.sourceField.split(",").some(N=>N.trim()===n.path));return e.jsxs("div",{draggable:!0,onDragStart:()=>m(n.path),onDragEnd:()=>m(null),style:{padding:"10px 12px",paddingLeft:12+g*16,borderBottom:`1px solid ${t.border}`,display:"flex",alignItems:"center",gap:8,cursor:"grab",background:f?"var(--nice-success-tint-10, #22c55e10)":"transparent",opacity:n.type==="object"&&n.children?.7:1},children:[e.jsx("span",{style:{color:De[n.type],fontSize:14},children:e.jsx(a.NiceIcon,{name:Fe[n.type],size:14})}),e.jsx("span",{style:{fontFamily:"monospace",fontSize:12},children:n.name}),e.jsx("span",{style:{fontSize:10,color:t.textMuted},children:n.type}),f&&e.jsx("span",{style:{marginLeft:"auto",color:"var(--nice-color-success, #22c55e)",fontSize:10},children:e.jsx(a.NiceIcon,{name:"check",size:14})})]},n.id)})})]}),e.jsxs("div",{style:{width:300,display:"flex",flexDirection:"column"},children:[e.jsxs("div",{style:{padding:"12px 16px",background:t.accent+"20",borderRadius:"8px 8px 0 0",fontSize:13,fontWeight:600},children:[e.jsx(a.NiceIcon,{name:"link",size:16})," Mappings (",p.fieldMappings.length,")"]}),e.jsx("div",{style:{flex:1,border:`1px solid ${t.border}`,borderTop:"none",borderRadius:"0 0 8px 8px",overflow:"auto",padding:8},children:p.fieldMappings.map(n=>{const g=p.transformations.find(f=>f.id===n.transform);return e.jsxs("div",{style:{padding:8,background:t.cardBg,borderRadius:6,marginBottom:8,fontSize:11},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4,marginBottom:4},children:[e.jsx("code",{style:{color:"var(--nice-color-success, #22c55e)"},children:n.sourceField||"(default)"}),e.jsx("span",{style:{color:t.textMuted},children:e.jsx(a.NiceIcon,{name:"arrow-right",size:12})}),e.jsx("code",{style:{color:"var(--nice-color-primary, #3b82f6)"},children:n.targetField}),e.jsx("button",{onClick:()=>E(n.id),"aria-label":i("dataMapper.removeMapping","Remove mapping"),style:{marginLeft:"auto",padding:2,border:"none",background:"transparent",color:"var(--nice-color-error, #ef4444)",cursor:"pointer",fontSize:10},children:e.jsx(a.NiceIcon,{name:"close",size:14})})]}),g&&e.jsxs("div",{style:{color:t.textMuted,display:"flex",alignItems:"center",gap:4},children:[e.jsx(a.NiceIcon,{name:Ee[g.type],size:14})," ",g.name]}),n.defaultValue!==void 0&&e.jsxs("div",{style:{color:"var(--nice-color-warning, #f59e0b)"},children:["Default: ",JSON.stringify(n.defaultValue)]})]},n.id)})})]}),e.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column"},children:[e.jsxs("div",{style:{padding:"12px 16px",background:"var(--nice-primary-tint-12, #3b82f620)",borderRadius:"8px 8px 0 0",fontSize:13,fontWeight:600},children:[e.jsx(a.NiceIcon,{name:"upload",size:14})," Target: ",p.targetSchema.name]}),e.jsx("div",{style:{flex:1,border:`1px solid ${t.border}`,borderTop:"none",borderRadius:"0 0 8px 8px",overflow:"auto"},children:_.map(n=>{const g=n.path.split(".").length-1,f=p.fieldMappings.some(s=>s.targetField===n.path);return e.jsxs("div",{onDragOver:s=>s.preventDefault(),onDrop:()=>{M&&!f&&Z(M,n.path)},style:{padding:"10px 12px",paddingLeft:12+g*16,borderBottom:`1px solid ${t.border}`,display:"flex",alignItems:"center",gap:8,background:M&&!f?t.accent+"10":f?"color-mix(in srgb, var(--nice-color-primary, #3b82f6) 6%, transparent)":"transparent",transition:"background 0.15s"},children:[e.jsx("span",{style:{color:De[n.type],fontSize:14},children:e.jsx(a.NiceIcon,{name:Fe[n.type],size:14})}),e.jsx("span",{style:{fontFamily:"monospace",fontSize:12},children:n.name}),e.jsx("span",{style:{fontSize:10,color:t.textMuted},children:n.type}),n.nullable&&e.jsx("span",{style:{fontSize:10,color:t.textMuted},children:"?"}),f&&e.jsx("span",{style:{marginLeft:"auto",color:"var(--nice-color-primary, #3b82f6)",fontSize:10},children:e.jsx(a.NiceIcon,{name:"check",size:14})})]},n.id)})})]})]}),w==="transforms"&&e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,marginBottom:20},children:[e.jsxs("h4",{style:{margin:0,display:"inline-flex",alignItems:"center",gap:6},children:[e.jsx(a.NiceIcon,{name:"zap",size:16})," ",i("dataMapper.transformations","Transformations")]}),e.jsx("button",{onClick:()=>{const n={id:`tr-${Date.now()}`,name:"New Transform",type:"direct",config:{}};D({transformations:[...p.transformations,n]})},style:{padding:"6px 12px",borderRadius:4,border:"none",background:t.accent,color:"var(--nice-color-white, #fff)",cursor:"pointer",fontSize:12},children:"+ Add Transform"})]}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(300px, 1fr))",gap:16},children:p.transformations.map(n=>e.jsxs("div",{style:{padding:16,background:t.cardBg,borderRadius:8,border:`1px solid ${t.border}`},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:12},children:[e.jsx("span",{style:{fontSize:20},children:e.jsx(a.NiceIcon,{name:Ee[n.type],size:20})}),e.jsx("input",{type:"text",value:n.name,onChange:g=>{const f=p.transformations.map(s=>s.id===n.id?{...s,name:g.target.value}:s);D({transformations:f})},style:{flex:1,padding:"6px 8px",borderRadius:4,border:`1px solid ${t.border}`,background:t.bg,color:t.text,fontSize:13,fontWeight:600}})]}),e.jsxs("div",{style:{marginBottom:12},children:[e.jsx("label",{style:{display:"block",fontSize:11,color:t.textMuted,marginBottom:4},children:i("dataMapper.type","Type")}),e.jsxs("select",{value:n.type,onChange:g=>{const f=p.transformations.map(s=>s.id===n.id?{...s,type:g.target.value}:s);D({transformations:f})},style:{width:"100%",padding:"8px 12px",borderRadius:4,border:`1px solid ${t.border}`,background:t.bg,color:t.text,fontSize:12},children:[e.jsx("option",{value:"direct",children:i("dataMapper.direct","Direct")}),e.jsx("option",{value:"format",children:i("dataMapper.format","Format")}),e.jsx("option",{value:"convert",children:i("dataMapper.convert","Convert")}),e.jsx("option",{value:"concat",children:i("dataMapper.concatenate","Concatenate")}),e.jsx("option",{value:"split",children:i("dataMapper.split","Split")}),e.jsx("option",{value:"calculate",children:i("dataMapper.calculate","Calculate")}),e.jsx("option",{value:"lookup",children:i("dataMapper.lookup","Lookup")}),e.jsx("option",{value:"conditional",children:i("dataMapper.conditional","Conditional")}),e.jsx("option",{value:"custom",children:i("dataMapper.custom","Custom")})]})]}),(n.type==="format"||n.type==="concat")&&e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:11,color:t.textMuted,marginBottom:4},children:n.type==="format"?"Format Pattern":"Separator"}),e.jsx("input",{type:"text",value:n.type==="format"?n.config.format||"":n.config.separator||"",onChange:g=>{const f=p.transformations.map(s=>s.id===n.id?{...s,config:{...s.config,[n.type==="format"?"format":"separator"]:g.target.value}}:s);D({transformations:f})},placeholder:n.type==="format"?"{value} or YYYY-MM-DD":", ",style:{width:"100%",padding:"8px 12px",borderRadius:4,border:`1px solid ${t.border}`,background:t.bg,color:t.text,fontSize:12,fontFamily:"monospace",boxSizing:"border-box"}})]}),n.type==="custom"&&e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:11,color:t.textMuted,marginBottom:4},children:i("dataMapper.expression","Expression")}),e.jsx("textarea",{value:n.config.expression||"",onChange:g=>{const f=p.transformations.map(s=>s.id===n.id?{...s,config:{...s.config,expression:g.target.value}}:s);D({transformations:f})},rows:3,style:{width:"100%",padding:"8px 12px",borderRadius:4,border:`1px solid ${t.border}`,background:t.bg,color:t.text,fontSize:12,fontFamily:"monospace",resize:"vertical",boxSizing:"border-box"}})]})]},n.id))})]}),w==="validation"&&e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,marginBottom:20},children:[e.jsxs("h4",{style:{margin:0,display:"inline-flex",alignItems:"center",gap:6},children:[e.jsx(a.NiceIcon,{name:"check",size:16})," ",i("dataMapper.validationRules","Validation Rules")]}),e.jsx("button",{onClick:()=>{const n={id:`v-${Date.now()}`,field:"",type:"required",message:""};D({validationRules:[...p.validationRules,n]})},style:{padding:"6px 12px",borderRadius:4,border:"none",background:t.accent,color:"var(--nice-color-white, #fff)",cursor:"pointer",fontSize:12},children:"+ Add Rule"})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12},children:p.validationRules.map(n=>e.jsxs("div",{style:{padding:16,background:t.cardBg,borderRadius:8,display:"flex",gap:12,alignItems:"center"},children:[e.jsxs("select",{value:n.field,onChange:g=>{const f=p.validationRules.map(s=>s.id===n.id?{...s,field:g.target.value}:s);D({validationRules:f})},style:{padding:"8px 12px",borderRadius:4,border:`1px solid ${t.border}`,background:t.bg,color:t.text,fontSize:12},children:[e.jsx("option",{value:"",children:i("dataMapper.selectField","Select field...")}),_.map(g=>e.jsx("option",{value:g.path,children:g.path},g.id))]}),e.jsxs("select",{value:n.type,onChange:g=>{const f=p.validationRules.map(s=>s.id===n.id?{...s,type:g.target.value}:s);D({validationRules:f})},style:{padding:"8px 12px",borderRadius:4,border:`1px solid ${t.border}`,background:t.bg,color:t.text,fontSize:12},children:[e.jsx("option",{value:"required",children:i("dataMapper.required","Required")}),e.jsx("option",{value:"type",children:i("dataMapper.type","Type")}),e.jsx("option",{value:"min",children:"Min"}),e.jsx("option",{value:"max",children:"Max"}),e.jsx("option",{value:"pattern",children:i("dataMapper.pattern","Pattern")}),e.jsx("option",{value:"enum",children:i("dataMapper.enum","Enum")}),e.jsx("option",{value:"custom",children:i("dataMapper.custom","Custom")})]}),(n.type==="pattern"||n.type==="min"||n.type==="max")&&e.jsx("input",{type:"text",value:String(n.value||""),onChange:g=>{const f=p.validationRules.map(s=>s.id===n.id?{...s,value:g.target.value}:s);D({validationRules:f})},placeholder:i("dataMapper.value","Value"),style:{padding:"8px 12px",borderRadius:4,border:`1px solid ${t.border}`,background:t.bg,color:t.text,fontSize:12,width:150}}),e.jsx("input",{type:"text",value:n.message||"",onChange:g=>{const f=p.validationRules.map(s=>s.id===n.id?{...s,message:g.target.value}:s);D({validationRules:f})},placeholder:i("dataMapper.errorMessage","Error message"),style:{flex:1,padding:"8px 12px",borderRadius:4,border:`1px solid ${t.border}`,background:t.bg,color:t.text,fontSize:12}}),e.jsx("button",{onClick:()=>{D({validationRules:p.validationRules.filter(g=>g.id!==n.id)})},"aria-label":i("dataMapper.delete","Delete"),style:{padding:6,border:"none",background:"transparent",color:"var(--nice-color-error, #ef4444)",cursor:"pointer",fontSize:14},children:e.jsx(a.NiceIcon,{name:"trash",size:14})})]},n.id))})]}),w==="test"&&e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:20,height:"100%"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,marginBottom:12},children:[e.jsxs("h4",{style:{margin:0,display:"inline-flex",alignItems:"center",gap:6},children:[e.jsx(a.NiceIcon,{name:"download",size:16})," ",i("dataMapper.input","Input")]}),e.jsx("button",{onClick:()=>{const n={},g=(f,s)=>{f.forEach(N=>{N.children&&N.type==="object"?(s[N.name]={},g(N.children,s[N.name])):s[N.name]={string:"sample",number:42,boolean:!0,date:new Date().toISOString(),array:[],object:{},any:null}[N.type]})};g(p.sourceSchema.fields,n),T(JSON.stringify(n,null,2))},style:{padding:"4px 8px",borderRadius:4,border:`1px solid ${t.border}`,background:"transparent",color:t.text,cursor:"pointer",fontSize:11},children:i("dataMapper.generateSample","Generate Sample")})]}),e.jsx("textarea",{value:O,onChange:n=>T(n.target.value),placeholder:i("dataMapper.pasteJsonInputHere","Paste JSON input here..."),style:{flex:1,padding:12,borderRadius:8,border:`1px solid ${t.border}`,background:t.cardBg,color:t.text,fontSize:12,fontFamily:"JetBrains Mono, Consolas, monospace",resize:"none"}})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,marginBottom:12},children:[e.jsxs("h4",{style:{margin:0,display:"inline-flex",alignItems:"center",gap:6},children:[e.jsx(a.NiceIcon,{name:"upload",size:16})," ",i("dataMapper.output","Output")]}),e.jsxs("button",{onClick:V,style:{padding:"6px 16px",borderRadius:4,border:"none",background:t.accent,color:"var(--nice-color-white, #fff)",cursor:"pointer",fontSize:12},children:[e.jsx(a.NiceIcon,{name:"refresh",size:14})," ",i("dataMapper.transform","Transform")]})]}),e.jsx("pre",{style:{flex:1,padding:12,borderRadius:8,background:t.cardBg,margin:0,overflow:"auto",fontSize:12,fontFamily:"JetBrains Mono, Consolas, monospace"},children:B||"Run transform to see output"})]})]}),w==="preview"&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%"},children:[e.jsxs("div",{style:{display:"flex",gap:12,marginBottom:16},children:[e.jsxs("button",{onClick:()=>$?.(h),style:{padding:"8px 16px",borderRadius:4,border:"none",background:t.accent,color:"var(--nice-color-white, #fff)",cursor:"pointer",fontSize:13},children:[e.jsx(a.NiceIcon,{name:"upload",size:14})," ",i("dataMapper.export","Export")]}),e.jsxs("button",{onClick:()=>navigator.clipboard.writeText(h),style:{padding:"8px 16px",borderRadius:4,border:`1px solid ${t.border}`,background:"transparent",color:t.text,cursor:"pointer",fontSize:13},children:[e.jsx(a.NiceIcon,{name:"clipboard",size:14})," ",i("dataMapper.copy","Copy")]})]}),e.jsx("pre",{style:{flex:1,padding:16,background:t.cardBg,borderRadius:8,overflow:"auto",fontSize:12,fontFamily:"JetBrains Mono, Consolas, monospace",margin:0,whiteSpace:"pre-wrap"},children:h})]})]})]})},kt=Object.freeze(Object.defineProperty({__proto__:null,NiceDataMapper:Je},Symbol.toStringTag,{value:"Module"})),Nt=[{type:"ui-event",label:"UI Event",icon:"cursor",color:"var(--nice-color-primary, #3b82f6)",configSchema:[{name:"element",label:"Element Selector",type:"string",required:!0},{name:"event",label:"Event Type",type:"select",required:!0,options:[{value:"click",label:"Click"},{value:"change",label:"Change"},{value:"submit",label:"Submit"},{value:"focus",label:"Focus"},{value:"blur",label:"Blur"},{value:"keydown",label:"Key Down"},{value:"keyup",label:"Key Up"}]}]},{type:"api-response",label:"API Response",icon:"globe",color:"var(--nice-color-success, #22c55e)",configSchema:[{name:"endpoint",label:"Endpoint Pattern",type:"string",required:!0},{name:"method",label:"Method",type:"select",options:[{value:"GET",label:"GET"},{value:"POST",label:"POST"},{value:"PUT",label:"PUT"},{value:"DELETE",label:"DELETE"},{value:"*",label:"Any"}]},{name:"statusCode",label:"Status Code",type:"string"}]},{type:"websocket",label:"WebSocket",icon:"plug",color:"var(--nice-color-accent, #8b5cf6)",configSchema:[{name:"channel",label:"Channel",type:"string",required:!0},{name:"messageType",label:"Message Type",type:"string"}]},{type:"timer",label:"Timer",icon:"clock",color:"var(--nice-color-warning, #f59e0b)",configSchema:[{name:"interval",label:"Interval (ms)",type:"number",required:!0,default:1e3},{name:"repeat",label:"Repeat",type:"boolean",default:!0}]},{type:"state-change",label:"State Change",icon:"bar-chart",color:"var(--nice-color-accent-pink, #ec4899)",configSchema:[{name:"selector",label:"State Selector",type:"string",required:!0},{name:"deep",label:"Deep Compare",type:"boolean",default:!1}]},{type:"broadcast",label:"Broadcast",icon:"wifi",color:"var(--nice-color-info, #06b6d4)",configSchema:[{name:"eventName",label:"Event Name",type:"string",required:!0}]}],$t=[{type:"action",label:"Action",icon:"zap",color:"var(--nice-color-primary, #3b82f6)",configSchema:[{name:"actionType",label:"Action",type:"string",required:!0},{name:"payload",label:"Payload",type:"json"}]},{type:"transform",label:"Transform",icon:"refresh",color:"var(--nice-color-accent, #8b5cf6)",configSchema:[{name:"expression",label:"Transform Expression",type:"code",required:!0}]},{type:"dispatch",label:"Dispatch",icon:"upload",color:"var(--nice-color-success, #22c55e)",configSchema:[{name:"eventName",label:"Event Name",type:"string",required:!0},{name:"payload",label:"Payload",type:"json"}]},{type:"api-call",label:"API Call",icon:"globe",color:"var(--nice-color-warning, #f59e0b)",configSchema:[{name:"endpoint",label:"Endpoint",type:"string",required:!0},{name:"method",label:"Method",type:"select",options:[{value:"GET",label:"GET"},{value:"POST",label:"POST"},{value:"PUT",label:"PUT"},{value:"DELETE",label:"DELETE"}]},{name:"body",label:"Body",type:"json"}]},{type:"state-update",label:"State Update",icon:"bar-chart",color:"var(--nice-color-accent-pink, #ec4899)",configSchema:[{name:"path",label:"State Path",type:"string",required:!0},{name:"value",label:"Value Expression",type:"code"}]},{type:"notification",label:"Notification",icon:"bell",color:"var(--nice-color-info, #06b6d4)",configSchema:[{name:"type",label:"Type",type:"select",options:[{value:"success",label:"Success"},{value:"error",label:"Error"},{value:"warning",label:"Warning"},{value:"info",label:"Info"}]},{name:"message",label:"Message",type:"string",required:!0},{name:"duration",label:"Duration (ms)",type:"number",default:3e3}]},{type:"log",label:"Console Log",icon:"edit",color:"var(--nice-text-muted, #6b7280)",configSchema:[{name:"level",label:"Level",type:"select",options:[{value:"log",label:"Log"},{value:"warn",label:"Warn"},{value:"error",label:"Error"},{value:"debug",label:"Debug"}]},{name:"message",label:"Message",type:"string"}]},{type:"delay",label:"Delay",icon:"clock",color:"var(--nice-accent, #a855f7)",configSchema:[{name:"duration",label:"Duration (ms)",type:"number",required:!0,default:1e3}]},{type:"branch",label:"Conditional Branch",icon:"shuffle",color:"var(--nice-info, #14b8a6)",configSchema:[{name:"condition",label:"Condition",type:"code",required:!0},{name:"trueBranch",label:"If True",type:"string"},{name:"falseBranch",label:"If False",type:"string"}]}],Ct=[{id:"flow-1",name:"Form Submit Handler",description:"Handle form submission with validation",enabled:!0,source:{id:"src-1",type:"ui-event",config:{element:"#contact-form",event:"submit"}},handlers:[{id:"h-1",type:"transform",config:{expression:"(event) => event.formData"}},{id:"h-2",type:"api-call",config:{endpoint:"/api/contact",method:"POST",body:"{{data}}"},modifiers:[{type:"debounce",value:500,unit:"ms"}]},{id:"h-3",type:"notification",config:{type:"success",message:"Form submitted successfully!"}}],errorHandler:{id:"err-1",type:"notification",config:{type:"error",message:"Failed to submit form"}}},{id:"flow-2",name:"Real-time Updates",description:"Handle WebSocket messages",enabled:!0,source:{id:"src-2",type:"websocket",config:{channel:"notifications",messageType:"update"}},handlers:[{id:"h-4",type:"state-update",config:{path:"notifications",value:"(state, data) => [...state.notifications, data]"}},{id:"h-5",type:"notification",config:{type:"info",message:"{{data.title}}",duration:5e3}}]},{id:"flow-3",name:"Auto-save Draft",description:"Periodically save form draft",enabled:!1,source:{id:"src-3",type:"timer",config:{interval:3e4,repeat:!0}},handlers:[{id:"h-6",type:"transform",config:{expression:"() => getFormData()"}},{id:"h-7",type:"api-call",config:{endpoint:"/api/draft",method:"PUT"},condition:{field:"isDirty",operator:"eq",value:!0}},{id:"h-8",type:"log",config:{level:"debug",message:"Draft saved"}}]}],zt=o=>{const S=o.filter(j=>j.enabled);return`/**
142
+ * Generated Event Orchestration
143
+ * @generated by NiceEventOrchestrator
144
+ */
145
+
146
+ import { createEventBus, EventHandler, EventSource } from '@nice2dev/events';
147
+
148
+ // Event Bus Instance
149
+ export const eventBus = createEventBus();
150
+
151
+ // Event Types
152
+ ${S.map(j=>`export type ${j.name.replace(/\s+/g,"")}Event = {
153
+ source: '${j.source.type}';
154
+ payload: unknown;
155
+ };`).join(`
156
+
157
+ `)}
158
+
159
+ // Event Handlers
160
+ ${S.map(j=>{const $=JSON.stringify(j.source.config,null,2),v=j.handlers.flatMap(k=>k.modifiers||[]).map(k=>`.${k.type}(${k.value})`).join("");return`
161
+ /**
162
+ * ${j.name}
163
+ * ${j.description||""}
164
+ */
165
+ export const ${j.name.replace(/\s+/g,"").toLowerCase()}Handler = eventBus
166
+ .on('${j.source.type}', ${$})${v}
167
+ .pipe(
168
+ ${j.handlers.map((k,d)=>` // Step ${d+1}: ${k.type}
169
+ async (event) => {
170
+ ${Pe(k)}
171
+ },`).join(`
172
+ `)}
173
+ )
174
+ ${j.errorHandler?`.catch(async (error) => {
175
+ ${Pe(j.errorHandler)}
176
+ })`:""};`}).join(`
177
+ `)}
178
+
179
+ // Initialize all handlers
180
+ export function initEventOrchestration() {
181
+ ${S.map(j=>` ${j.name.replace(/\s+/g,"").toLowerCase()}Handler.start();`).join(`
182
+ `)}
183
+ console.log('Event orchestration initialized');
184
+ }
185
+
186
+ // Cleanup
187
+ export function destroyEventOrchestration() {
188
+ ${S.map(j=>` ${j.name.replace(/\s+/g,"").toLowerCase()}Handler.stop();`).join(`
189
+ `)}
190
+ }
191
+ `},Pe=o=>{switch(o.type){case"action":return`dispatch({ type: '${o.config.actionType}', payload: ${JSON.stringify(o.config.payload)} });`;case"transform":return`return (${o.config.expression})(event);`;case"dispatch":return`eventBus.emit('${o.config.eventName}', ${JSON.stringify(o.config.payload)});`;case"api-call":return`await fetch('${o.config.endpoint}', { method: '${o.config.method}', body: JSON.stringify(event.payload) });`;case"state-update":return`updateState('${o.config.path}', ${o.config.value});`;case"notification":return`showNotification({ type: '${o.config.type}', message: '${o.config.message}' });`;case"log":return`console.${o.config.level||"log"}('${o.config.message}', event);`;case"delay":return`await new Promise(r => setTimeout(r, ${o.config.duration}));`;case"branch":return`if (${o.config.condition}) { /* true branch */ } else { /* false branch */ }`;default:return"// Unknown handler type"}},Ke=({flows:o=Ct,eventSources:S=Nt,eventHandlers:b=$t,onFlowsChange:j,onExport:$,onTest:v,className:k,style:d,"data-testid":C})=>{const{t:r}=a.useNiceTranslation(),[i,p]=x.useState(o),[z,w]=x.useState(i[0]?.id??null),[I,q]=x.useState("visual"),[G,O]=x.useState(!1),[T,B]=x.useState(""),[H,M]=x.useState(new Set),m=x.useMemo(()=>i.find(n=>n.id===z),[i,z]),D=x.useMemo(()=>zt(i),[i]),F=x.useCallback((n,g)=>{p(f=>{const s=f.map(N=>N.id===n?{...N,...g}:N);return j?.(s),s})},[j]),Y=()=>{if(!T.trim())return;const n={id:`flow-${Date.now()}`,name:T,enabled:!0,source:{id:`src-${Date.now()}`,type:"ui-event",config:{element:"",event:"click"}},handlers:[]};p(g=>{const f=[...g,n];return j?.(f),f}),w(n.id),O(!1),B("")},_=n=>{p(g=>{const f=g.filter(s=>s.id!==n);return j?.(f),f}),z===n&&w(i[0]?.id??null)},Z=n=>{if(!m)return;const g=b.find(N=>N.type===n),f={};g?.configSchema.forEach(N=>{N.default!==void 0&&(f[N.name]=N.default)});const s={id:`handler-${Date.now()}`,type:n,config:f};F(m.id,{handlers:[...m.handlers,s]}),M(N=>new Set([...N,s.id]))},E=(n,g)=>{m&&F(m.id,{handlers:m.handlers.map(f=>f.id===n?{...f,...g}:f)})},V=n=>{m&&F(m.id,{handlers:m.handlers.filter(g=>g.id!==n)})},h=(n,g)=>{if(!m)return;const f=m.handlers.find(l=>l.id===n);if(!f)return;const N=f.modifiers?.find(l=>l.type===g)?f.modifiers?.filter(l=>l.type!==g):[...f.modifiers||[],{type:g,value:500,unit:"ms"}];E(n,{modifiers:N})},t={bg:"var(--nice-bg-elevated, #1e1e1e)",cardBg:"var(--nice-bg-elevated, #252525)",border:"var(--nice-bg-tertiary, #333)",text:"var(--nice-text-primary, #e0e0e0)",textMuted:"var(--nice-text-muted, #888)"};return e.jsxs("div",{className:`nice-event-orchestrator ${k||""}`,style:{display:"flex",flexDirection:"column",height:"100%",background:t.bg,color:t.text,fontFamily:"system-ui, sans-serif",...d},"data-testid":C,children:[e.jsxs("div",{style:{padding:"12px 20px",borderBottom:`1px solid ${t.border}`,display:"flex",alignItems:"center",gap:16},children:[e.jsxs("h3",{style:{margin:0,fontSize:16,display:"inline-flex",alignItems:"center",gap:6},children:[e.jsx(a.NiceIcon,{name:"zap",size:16})," ",r("eventOrchestrator.eventOrchestrator","Event Orchestrator")]}),e.jsx("div",{style:{display:"flex",border:`1px solid ${t.border}`,borderRadius:6,overflow:"hidden",marginLeft:"auto"},children:["visual","code","split"].map(n=>e.jsxs("button",{onClick:()=>q(n),style:{padding:"6px 12px",border:"none",background:I===n?t.cardBg:"transparent",color:t.text,cursor:"pointer",fontSize:12,textTransform:"capitalize",display:"inline-flex",alignItems:"center",gap:6},children:[e.jsx(a.NiceIcon,{name:n==="visual"?"palette":n==="code"?"edit":"grid",size:14})," ",n]},n))}),e.jsxs("button",{onClick:()=>$?.(D),style:{padding:"8px 16px",borderRadius:6,border:"none",background:"var(--nice-color-success, #22c55e)",color:"var(--nice-text-on-primary, #fff)",cursor:"pointer",fontSize:13,fontWeight:500,display:"inline-flex",alignItems:"center",gap:6},children:[e.jsx(a.NiceIcon,{name:"upload",size:14})," ",r("eventOrchestrator.export","Export")]})]}),e.jsxs("div",{style:{flex:1,display:"flex",overflow:"hidden"},children:[(I==="visual"||I==="split")&&e.jsxs("div",{style:{width:240,borderRight:`1px solid ${t.border}`,display:"flex",flexDirection:"column"},children:[e.jsxs("div",{style:{padding:"12px 16px",borderBottom:`1px solid ${t.border}`,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsx("span",{style:{fontSize:12,fontWeight:600},children:r("eventOrchestrator.eventFlows","Event Flows")}),e.jsx("button",{onClick:()=>O(!0),style:{padding:"4px 8px",borderRadius:4,border:`1px solid ${t.border}`,background:"transparent",color:t.text,cursor:"pointer",fontSize:12},children:"+"})]}),e.jsxs("div",{style:{flex:1,overflow:"auto",padding:8},children:[i.map(n=>{const g=S.find(f=>f.type===n.source.type);return e.jsxs("div",{onClick:()=>w(n.id),style:{padding:12,background:z===n.id?t.cardBg:"transparent",borderRadius:6,cursor:"pointer",marginBottom:4,border:`1px solid ${z===n.id?t.border:"transparent"}`,opacity:n.enabled?1:.5},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(a.NiceIcon,{name:g?.icon??"zap",size:16}),e.jsx("span",{style:{flex:1,fontSize:13,fontWeight:500},children:n.name}),e.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:n.enabled?"var(--nice-color-success, #22c55e)":"var(--nice-color-error, #ef4444)"}})]}),e.jsxs("div",{style:{fontSize:10,color:t.textMuted,marginTop:4},children:[n.handlers.length," handler",n.handlers.length!==1?"s":""]})]},n.id)}),G&&e.jsxs("div",{style:{padding:12,background:t.cardBg,borderRadius:6,border:"1px solid var(--nice-primary, #3b82f6)"},children:[e.jsx("input",{type:"text",value:T,onChange:n=>B(n.target.value),placeholder:r("eventOrchestrator.flowName","Flow name..."),autoFocus:!0,style:{width:"100%",padding:8,borderRadius:4,border:`1px solid ${t.border}`,background:t.bg,color:t.text,fontSize:12,marginBottom:8,boxSizing:"border-box"},onKeyDown:n=>n.key==="Enter"&&Y()}),e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx("button",{onClick:()=>O(!1),style:{flex:1,padding:6,borderRadius:4,border:`1px solid ${t.border}`,background:"transparent",color:t.text,cursor:"pointer",fontSize:11},children:r("eventOrchestrator.cancel","Cancel")}),e.jsx("button",{onClick:Y,style:{flex:1,padding:6,borderRadius:4,border:"none",background:"var(--nice-color-primary, #3b82f6)",color:"var(--nice-text-on-primary, #fff)",cursor:"pointer",fontSize:11},children:"Add"})]})]})]})]}),(I==="visual"||I==="split")&&m&&e.jsxs("div",{style:{flex:I==="split"?1:2,overflow:"auto",padding:20},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,marginBottom:20},children:[e.jsx("input",{type:"text",value:m.name,onChange:n=>F(m.id,{name:n.target.value}),style:{flex:1,padding:10,borderRadius:6,border:`1px solid ${t.border}`,background:t.cardBg,color:t.text,fontSize:16,fontWeight:600}}),e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:m.enabled,onChange:n=>F(m.id,{enabled:n.target.checked})}),e.jsx("span",{style:{fontSize:12},children:r("eventOrchestrator.enabled","Enabled")})]}),e.jsxs("button",{onClick:()=>v?.(m.id),style:{padding:"8px 16px",borderRadius:6,border:`1px solid ${t.border}`,background:"transparent",color:t.text,cursor:"pointer",fontSize:12,display:"inline-flex",alignItems:"center",gap:6},children:[e.jsx(a.NiceIcon,{name:"play",size:14})," ",r("eventOrchestrator.test","Test")]}),e.jsx("button",{onClick:()=>_(m.id),"aria-label":r("eventOrchestrator.delete","Delete"),style:{padding:"8px 12px",borderRadius:6,border:"1px solid var(--nice-danger, #ef4444)",background:"transparent",color:"var(--nice-color-error, #ef4444)",cursor:"pointer",fontSize:12},children:e.jsx(a.NiceIcon,{name:"trash",size:14})})]}),e.jsxs("div",{style:{padding:16,background:t.cardBg,borderRadius:8,marginBottom:16,borderLeft:`4px solid ${S.find(n=>n.type===m.source.type)?.color??"var(--nice-text-muted, #888)"}`},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:12},children:[e.jsx(a.NiceIcon,{name:S.find(n=>n.type===m.source.type)?.icon??"zap",size:20}),e.jsx("span",{style:{fontWeight:600},children:r("eventOrchestrator.eventSource","Event Source")})]}),e.jsx("select",{value:m.source.type,onChange:n=>F(m.id,{source:{...m.source,type:n.target.value,config:{}}}),style:{width:"100%",padding:10,borderRadius:6,border:`1px solid ${t.border}`,background:t.bg,color:t.text,fontSize:13,marginBottom:12},children:S.map(n=>e.jsx("option",{value:n.type,children:n.label},n.type))}),S.find(n=>n.type===m.source.type)?.configSchema.map(n=>e.jsxs("div",{style:{marginBottom:8},children:[e.jsxs("label",{style:{display:"block",fontSize:11,color:t.textMuted,marginBottom:4},children:[n.label," ",n.required&&e.jsx("span",{style:{color:"var(--nice-color-error, #ef4444)"},children:"*"})]}),n.type==="select"?e.jsx("select",{value:String(m.source.config[n.name]??""),onChange:g=>F(m.id,{source:{...m.source,config:{...m.source.config,[n.name]:g.target.value}}}),style:{width:"100%",padding:8,borderRadius:4,border:`1px solid ${t.border}`,background:t.bg,color:t.text,fontSize:12},children:n.options?.map(g=>e.jsx("option",{value:g.value,children:g.label},g.value))}):e.jsx("input",{type:n.type==="number"?"number":"text",value:String(m.source.config[n.name]??""),onChange:g=>F(m.id,{source:{...m.source,config:{...m.source.config,[n.name]:n.type==="number"?Number(g.target.value):g.target.value}}}),style:{width:"100%",padding:8,borderRadius:4,border:`1px solid ${t.border}`,background:t.bg,color:t.text,fontSize:12,boxSizing:"border-box"}})]},n.name))]}),e.jsx("div",{style:{textAlign:"center",color:t.textMuted,marginBottom:16},children:e.jsx(a.NiceIcon,{name:"arrow-down",size:16})}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[m.handlers.map((n,g)=>{const f=b.find(N=>N.type===n.type),s=H.has(n.id);return e.jsxs(x.Fragment,{children:[e.jsxs("div",{style:{padding:16,background:t.cardBg,borderRadius:8,borderLeft:`4px solid ${f?.color??"var(--nice-text-muted, #888)"}`},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer"},onClick:()=>M(N=>{const l=new Set(N);return l.has(n.id)?l.delete(n.id):l.add(n.id),l}),children:[e.jsx(a.NiceIcon,{name:f?.icon??"zap",size:16}),e.jsxs("span",{style:{fontWeight:500},children:[g+1,". ",f?.label??n.type]}),n.modifiers?.map(N=>e.jsxs("span",{style:{padding:"2px 6px",background:"var(--nice-accent-tint-12, #8b5cf620)",color:"var(--nice-color-accent, #8b5cf6)",borderRadius:4,fontSize:10},children:[N.type,": ",N.value,"ms"]},N.type)),e.jsx("span",{style:{marginLeft:"auto",color:t.textMuted,display:"inline-flex",alignItems:"center"},children:e.jsx(a.NiceIcon,{name:s?"chevron-down":"chevron-right",size:14})})]}),s&&e.jsxs("div",{style:{marginTop:12,paddingTop:12,borderTop:`1px solid ${t.border}`},children:[e.jsx("select",{value:n.type,onChange:N=>E(n.id,{type:N.target.value}),style:{width:"100%",padding:8,borderRadius:4,border:`1px solid ${t.border}`,background:t.bg,color:t.text,fontSize:12,marginBottom:12},children:b.map(N=>e.jsx("option",{value:N.type,children:N.label},N.type))}),f?.configSchema.map(N=>e.jsxs("div",{style:{marginBottom:8},children:[e.jsx("label",{style:{display:"block",fontSize:11,color:t.textMuted,marginBottom:4},children:N.label}),N.type==="code"?e.jsx("textarea",{value:String(n.config[N.name]??""),onChange:l=>E(n.id,{config:{...n.config,[N.name]:l.target.value}}),rows:3,style:{width:"100%",padding:8,borderRadius:4,border:`1px solid ${t.border}`,background:t.bg,color:t.text,fontFamily:"monospace",fontSize:11,resize:"vertical",boxSizing:"border-box"}}):N.type==="select"?e.jsx("select",{value:String(n.config[N.name]??""),onChange:l=>E(n.id,{config:{...n.config,[N.name]:l.target.value}}),style:{width:"100%",padding:8,borderRadius:4,border:`1px solid ${t.border}`,background:t.bg,color:t.text,fontSize:12},children:N.options?.map(l=>e.jsx("option",{value:l.value,children:l.label},l.value))}):e.jsx("input",{type:N.type==="number"?"number":"text",value:String(n.config[N.name]??""),onChange:l=>E(n.id,{config:{...n.config,[N.name]:N.type==="number"?Number(l.target.value):l.target.value}}),style:{width:"100%",padding:8,borderRadius:4,border:`1px solid ${t.border}`,background:t.bg,color:t.text,fontSize:12,boxSizing:"border-box"}})]},N.name)),e.jsxs("div",{style:{marginTop:12},children:[e.jsx("div",{style:{fontSize:11,color:t.textMuted,marginBottom:8},children:r("eventOrchestrator.modifiers","Modifiers")}),e.jsx("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:["debounce","throttle","delay","retry","once"].map(N=>e.jsx("button",{onClick:()=>h(n.id,N),style:{padding:"4px 8px",borderRadius:4,border:`1px solid ${n.modifiers?.some(l=>l.type===N)?"var(--nice-color-accent, #8b5cf6)":t.border}`,background:n.modifiers?.some(l=>l.type===N)?"var(--nice-accent-tint-12, #8b5cf620)":"transparent",color:t.text,cursor:"pointer",fontSize:11},children:N},N))})]}),e.jsxs("button",{onClick:()=>V(n.id),style:{marginTop:12,padding:"6px 12px",borderRadius:4,border:"1px solid var(--nice-danger, #ef4444)",background:"transparent",color:"var(--nice-color-error, #ef4444)",cursor:"pointer",fontSize:11,display:"inline-flex",alignItems:"center",gap:6},children:[e.jsx(a.NiceIcon,{name:"trash",size:14})," ",r("eventOrchestrator.removeHandler","Remove Handler")]})]})]}),g<m.handlers.length-1&&e.jsx("div",{style:{textAlign:"center",color:t.textMuted},children:e.jsx(a.NiceIcon,{name:"arrow-down",size:16})})]},n.id)}),e.jsxs("div",{style:{padding:16,border:`1px dashed ${t.border}`,borderRadius:8,textAlign:"center"},children:[e.jsx("div",{style:{fontSize:12,color:t.textMuted,marginBottom:12},children:r("eventOrchestrator.addHandler","Add Handler")}),e.jsx("div",{style:{display:"flex",gap:8,flexWrap:"wrap",justifyContent:"center"},children:b.map(n=>e.jsxs("button",{onClick:()=>Z(n.type),style:{padding:"6px 12px",borderRadius:4,border:`1px solid ${n.color}`,background:`${n.color}20`,color:t.text,cursor:"pointer",fontSize:11,display:"inline-flex",alignItems:"center",gap:6},children:[e.jsx(a.NiceIcon,{name:n.icon,size:14})," ",n.label]},n.type))})]})]})]}),(I==="code"||I==="split")&&e.jsx("div",{style:{flex:1,overflow:"auto",padding:16,background:"var(--nice-bg-canvas, #0d1117)",borderLeft:I==="split"?`1px solid ${t.border}`:void 0},children:e.jsx("pre",{style:{margin:0,fontFamily:"Consolas, Monaco, monospace",fontSize:12,lineHeight:1.5,color:"var(--nice-text-primary, #e6edf3)",whiteSpace:"pre-wrap"},children:D})})]})]})},Tt=Object.freeze(Object.defineProperty({__proto__:null,NiceEventOrchestrator:Ke},Symbol.toStringTag,{value:"Module"})),It=[{target:".nice-test-builder",titleKey:"tutorial.testBuilder.intro.title",title:"Test builder",contentKey:"tutorial.testBuilder.intro.content",content:"Build test suites visually: add cases and interaction steps with assertions, run them, and export to a ready-to-run .test.tsx file.",placement:"auto"}],be={render:{label:"Render",icon:"palette",color:"var(--nice-color-primary, #3b82f6)"},click:{label:"Click",icon:"cursor",color:"var(--nice-color-success, #22c55e)",hasTarget:!0},type:{label:"Type",icon:"terminal",color:"var(--nice-color-warning, #f59e0b)",hasTarget:!0,hasValue:!0},select:{label:"Select",icon:"clipboard",color:"var(--nice-color-accent, #8b5cf6)",hasTarget:!0,hasValue:!0},hover:{label:"Hover",icon:"cursor",color:"var(--nice-color-accent-pink, #ec4899)",hasTarget:!0},focus:{label:"Focus",icon:"target",color:"var(--nice-color-info, #06b6d4)",hasTarget:!0},blur:{label:"Blur",icon:"forward",color:"var(--nice-text-muted, #6b7280)",hasTarget:!0},submit:{label:"Submit",icon:"upload",color:"var(--nice-info, #14b8a6)",hasTarget:!0},keypress:{label:"Key Press",icon:"terminal",color:"var(--nice-accent, #a855f7)",hasValue:!0},wait:{label:"Wait",icon:"clock",color:"var(--nice-warning, #f97316)",hasValue:!0},scroll:{label:"Scroll",icon:"file",color:"var(--nice-success, #84cc16)",hasTarget:!0},drag:{label:"Drag & Drop",icon:"cursor",color:"var(--nice-color-warning, #eab308)",hasTarget:!0,hasValue:!0},assert:{label:"Assert",icon:"check",color:"var(--nice-color-success, #22c55e)",hasTarget:!0,hasValue:!0},snapshot:{label:"Snapshot",icon:"camera",color:"var(--nice-color-primary, #3b82f6)"},"a11y-check":{label:"A11y Check",icon:"accessibility",color:"var(--nice-color-accent, #8b5cf6)"}},_t=[{id:"suite-1",name:"Button Component Tests",componentName:"NiceButton",setup:{mocks:[{name:"onClick",type:"function"}]},tests:[{id:"test-1",name:"renders with correct text",type:"unit",steps:[{id:"step-1",action:"render"},{id:"step-2",action:"assert",target:"button",value:{matcher:"toHaveTextContent",expected:"Click me"}}]},{id:"test-2",name:"calls onClick when clicked",type:"unit",steps:[{id:"step-3",action:"render"},{id:"step-4",action:"click",target:"button"},{id:"step-5",action:"assert",value:{mock:"onClick",matcher:"toHaveBeenCalled"}}]},{id:"test-3",name:"is disabled when loading",type:"unit",steps:[{id:"step-6",action:"render"},{id:"step-7",action:"assert",target:"button",value:{matcher:"toHaveAttribute",expected:["disabled","true"]}}]}]},{id:"suite-2",name:"Form Integration Tests",componentName:"ContactForm",setup:{mocks:[{name:"api.submit",type:"api",returnValue:{success:!0}}],providers:[{name:"FormProvider",props:{}}]},tests:[{id:"test-4",name:"submits form with valid data",type:"integration",steps:[{id:"step-8",action:"render"},{id:"step-9",action:"type",target:'input[name="email"]',value:"test@example.com"},{id:"step-10",action:"type",target:'input[name="message"]',value:"Hello!"},{id:"step-11",action:"click",target:'button[type="submit"]'},{id:"step-12",action:"wait",value:{type:"api",timeout:1e3}},{id:"step-13",action:"assert",target:".success-message",value:{matcher:"toBeInTheDocument"}}]},{id:"test-5",name:"shows validation errors",type:"integration",steps:[{id:"step-14",action:"render"},{id:"step-15",action:"click",target:'button[type="submit"]'},{id:"step-16",action:"assert",target:".error",value:{matcher:"toHaveTextContent",expected:"Email is required"}}]}]}],Rt=o=>o.map(S=>{const b=new Set(["import { render, screen, fireEvent, waitFor } from '@testing-library/react';","import userEvent from '@testing-library/user-event';",`import { ${S.componentName} } from './${S.componentName}';`]);S.setup?.mocks.forEach(d=>{d.type==="api"&&(b.add("import { rest } from 'msw';"),b.add("import { setupServer } from 'msw/node';"))});const j=S.setup?.mocks.map(d=>d.type==="function"?`const ${d.name} = jest.fn();`:d.type==="api"?`// API mock: ${d.name}`:"").filter(Boolean).join(`
192
+ `),v=S.setup?.providers&&S.setup.providers.length>0?`const Wrapper = ({ children }) => (
193
+ ${S.setup.providers.map(d=>`<${d.name}>`).join(`
194
+ `)}
195
+ {children}
196
+ ${S.setup.providers.reverse().map(d=>`</${d.name}>`).join(`
197
+ `)}
198
+ );`:"",k=S.tests.map(d=>{const C=d.skip?".skip":d.only?".only":"",r=d.steps.map(i=>Bt(i,S)).join(`
199
+ `);return`
200
+ it${C}('${d.name}', async () => {
201
+ ${r}
202
+ });`}).join(`
203
+ `);return`/**
204
+ * ${S.name}
205
+ * @generated by NiceTestBuilder
206
+ */
207
+
208
+ ${Array.from(b).join(`
209
+ `)}
210
+
211
+ describe('${S.componentName}', () => {
212
+ ${j?` // Mocks
213
+ ${j}
214
+ `:""}
215
+ ${v?` ${v}
216
+ `:""}
217
+ beforeEach(() => {
218
+ jest.clearAllMocks();
219
+ });
220
+ ${k}
221
+ });
222
+ `}).join(`
223
+
224
+ `),Bt=(o,S)=>{switch(be[o.action],o.action){case"render":{const b=S.setup?.providers&&S.setup.providers.length>0,j=S.setup?.props?` {...${JSON.stringify(S.setup.props)}}`:"";return b?`render(<${S.componentName}${j} />, { wrapper: Wrapper });`:`render(<${S.componentName}${j} />);`}case"click":return`await userEvent.click(screen.getByRole('${o.target?.replace(/[[\]'"]/g,"")}'));`;case"type":return`await userEvent.type(screen.getByRole('textbox', { name: /${o.target}/ }), '${o.value}');`;case"select":return`await userEvent.selectOptions(screen.getByRole('combobox'), '${o.value}');`;case"hover":return`await userEvent.hover(screen.getByRole('${o.target}'));`;case"focus":return`screen.getByRole('${o.target}').focus();`;case"blur":return`screen.getByRole('${o.target}').blur();`;case"submit":return"fireEvent.submit(screen.getByRole('form'));";case"wait":if(typeof o.value=="object"&&o.value!==null){const b=o.value;return b.type==="timeout"?`await new Promise(r => setTimeout(r, ${b.value}));`:`await waitFor(() => expect(/* condition */).toBeTruthy(), { timeout: ${b.timeout??1e3} });`}return`await new Promise(r => setTimeout(r, ${o.value}));`;case"assert":if(typeof o.value=="object"&&o.value!==null){const b=o.value;if(b.mock)return`expect(${b.mock}).${b.matcher}(${b.expected?JSON.stringify(b.expected):""});`;const j=o.target?`screen.getByRole('${o.target}')`:"result",$=b.expected!==void 0?JSON.stringify(b.expected):"";return`expect(${j}).${b.matcher}(${$});`}return`expect(screen.getByRole('${o.target}')).toBeInTheDocument();`;case"snapshot":return"expect(container).toMatchSnapshot();";case"a11y-check":return`const results = await axe(container);
225
+ expect(results).toHaveNoViolations();`;default:return`// ${o.action}: ${JSON.stringify(o)}`}},Ge=({componentName:o="MyComponent",testSuites:S=_t,availableMocks:b=[],onSuitesChange:j,onExport:$,onRun:v,onRunAll:k,tutorial:d,className:C,style:r,"data-testid":i})=>{const{t:p}=a.useNiceTranslation(),[z,w]=x.useState(S),[I,q]=x.useState(z[0]?.id??null),[G,O]=x.useState(null),[T,B]=x.useState("visual"),[H,M]=x.useState(!1),[m,D]=x.useState(""),[F,Y]=x.useState(new Set),_=x.useMemo(()=>z.find(u=>u.id===I),[z,I]);x.useMemo(()=>_?.tests.find(u=>u.id===G),[_,G]);const Z=x.useMemo(()=>Rt(z),[z]),E=x.useCallback((u,W)=>{w(J=>{const K=J.map(L=>L.id===u?{...L,...W}:L);return j?.(K),K})},[j]),V=()=>{if(!m.trim())return;const u={id:`suite-${Date.now()}`,name:m,componentName:o,tests:[]};w(W=>{const J=[...W,u];return j?.(J),J}),q(u.id),M(!1),D("")},h=u=>{w(W=>{const J=W.filter(K=>K.id!==u);return j?.(J),J}),I===u&&q(z[0]?.id??null)},t=()=>{if(!_)return;const u={id:`test-${Date.now()}`,name:"New test",type:"unit",steps:[{id:`step-${Date.now()}`,action:"render"}]};E(_.id,{tests:[..._.tests,u]}),O(u.id),Y(W=>new Set([...W,u.id]))},n=(u,W)=>{_&&E(_.id,{tests:_.tests.map(J=>J.id===u?{...J,...W}:J)})},g=u=>{_&&(E(_.id,{tests:_.tests.filter(W=>W.id!==u)}),G===u&&O(null))},f=(u,W)=>{if(!_)return;const J=_.tests.find(L=>L.id===u);if(!J)return;const K={id:`step-${Date.now()}`,action:W};n(u,{steps:[...J.steps,K]})},s=(u,W,J)=>{if(!_)return;const K=_.tests.find(L=>L.id===u);K&&n(u,{steps:K.steps.map(L=>L.id===W?{...L,...J}:L)})},N=(u,W)=>{if(!_)return;const J=_.tests.find(K=>K.id===u);J&&n(u,{steps:J.steps.filter(K=>K.id!==W)})},l={bg:"var(--nice-bg-elevated, #1e1e1e)",cardBg:"var(--nice-bg-elevated, #252525)",border:"var(--nice-bg-tertiary, #333)",text:"var(--nice-text-primary, #e0e0e0)",textMuted:"var(--nice-text-muted, #888)"},Q=x.useMemo(()=>{const u=z.reduce((J,K)=>J+K.tests.length,0),W=z.reduce((J,K)=>J+K.tests.filter(L=>L.skip).length,0);return{total:u,skipped:W}},[z]),te=e.jsxs("div",{style:{padding:"12px 20px",borderBottom:`1px solid ${l.border}`,display:"flex",alignItems:"center",gap:16},children:[e.jsxs("h3",{style:{margin:0,fontSize:16},children:[e.jsx(a.NiceIcon,{name:"flask",size:16})," ",p("testBuilder.testBuilder","Test Builder")]}),e.jsxs("div",{style:{fontSize:12,color:l.textMuted},children:[Q.total," tests • ",Q.skipped," skipped"]}),e.jsx("div",{style:{display:"flex",border:`1px solid ${l.border}`,borderRadius:6,overflow:"hidden",marginLeft:"auto"},children:["visual","code","split"].map(u=>e.jsxs("button",{onClick:()=>B(u),style:{padding:"6px 12px",border:"none",background:T===u?l.cardBg:"transparent",color:l.text,cursor:"pointer",fontSize:12,textTransform:"capitalize"},children:[e.jsx(a.NiceIcon,{name:u==="visual"?"palette":u==="code"?"edit":"grid",size:14})," ",u]},u))}),e.jsxs("button",{onClick:k,style:{padding:"8px 16px",borderRadius:6,border:`1px solid ${l.border}`,background:"transparent",color:l.text,cursor:"pointer",fontSize:13},children:[e.jsx(a.NiceIcon,{name:"play",size:14})," ",p("testBuilder.runAll","Run All")]}),e.jsxs("button",{onClick:()=>$?.(Z),style:{padding:"8px 16px",borderRadius:6,border:"none",background:"var(--nice-color-success, #22c55e)",color:"var(--nice-text-on-primary, #fff)",cursor:"pointer",fontSize:13,fontWeight:500},children:[e.jsx(a.NiceIcon,{name:"upload",size:14})," ",p("testBuilder.export","Export")]}),e.jsx(a.NiceTutorialButton,{steps:a.resolveTutorial(d,It)})]}),ee=T==="visual"||T==="split"?e.jsxs("div",{style:{width:220,borderRight:`1px solid ${l.border}`,display:"flex",flexDirection:"column",height:"100%"},children:[e.jsxs("div",{style:{padding:"12px 16px",borderBottom:`1px solid ${l.border}`,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsx("span",{style:{fontSize:12,fontWeight:600},children:p("testBuilder.testSuites","Test Suites")}),e.jsx("button",{onClick:()=>M(!0),style:{padding:"4px 8px",borderRadius:4,border:`1px solid ${l.border}`,background:"transparent",color:l.text,cursor:"pointer",fontSize:12},children:"+"})]}),e.jsxs("div",{style:{flex:1,overflow:"auto",padding:8},children:[z.map(u=>e.jsxs("div",{onClick:()=>{q(u.id),O(null)},style:{padding:12,background:I===u.id?l.cardBg:"transparent",borderRadius:6,cursor:"pointer",marginBottom:4,border:`1px solid ${I===u.id?l.border:"transparent"}`},children:[e.jsx("div",{style:{fontSize:13,fontWeight:500},children:u.name}),e.jsxs("div",{style:{fontSize:10,color:l.textMuted,marginTop:4},children:[u.componentName," • ",u.tests.length," test",u.tests.length!==1?"s":""]})]},u.id)),H&&e.jsxs("div",{style:{padding:12,background:l.cardBg,borderRadius:6,border:"1px solid var(--nice-primary, #3b82f6)"},children:[e.jsx("input",{type:"text",value:m,onChange:u=>D(u.target.value),placeholder:p("testBuilder.suiteName","Suite name..."),autoFocus:!0,style:{width:"100%",padding:8,borderRadius:4,border:`1px solid ${l.border}`,background:l.bg,color:l.text,fontSize:12,marginBottom:8,boxSizing:"border-box"},onKeyDown:u=>u.key==="Enter"&&V()}),e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx("button",{onClick:()=>M(!1),style:{flex:1,padding:6,borderRadius:4,border:`1px solid ${l.border}`,background:"transparent",color:l.text,cursor:"pointer",fontSize:11},children:p("testBuilder.cancel","Cancel")}),e.jsx("button",{onClick:V,style:{flex:1,padding:6,borderRadius:4,border:"none",background:"var(--nice-color-primary, #3b82f6)",color:"var(--nice-text-on-primary, #fff)",cursor:"pointer",fontSize:11},children:"Add"})]})]})]})]}):void 0;return e.jsx(le.NiceAppShell,{flush:!0,className:`nice-test-builder ${C||""}`,style:{background:l.bg,color:l.text,fontFamily:"system-ui, sans-serif",...r},"data-testid":i,menubar:te,sidebar:ee,children:e.jsxs("div",{style:{display:"flex",height:"100%",overflow:"hidden"},children:[(T==="visual"||T==="split")&&_&&e.jsxs("div",{style:{flex:T==="split"?1:2,overflow:"auto",padding:20},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,marginBottom:20},children:[e.jsx("input",{type:"text",value:_.name,onChange:u=>E(_.id,{name:u.target.value}),style:{flex:1,padding:10,borderRadius:6,border:`1px solid ${l.border}`,background:l.cardBg,color:l.text,fontSize:16,fontWeight:600}}),e.jsxs("button",{onClick:()=>v?.(_.id),style:{padding:"8px 16px",borderRadius:6,border:`1px solid ${l.border}`,background:"transparent",color:l.text,cursor:"pointer",fontSize:12},children:[e.jsx(a.NiceIcon,{name:"play",size:14})," ",p("testBuilder.runSuite","Run Suite")]}),e.jsx("button",{onClick:()=>h(_.id),"aria-label":p("testBuilder.delete","Delete"),style:{padding:"8px 12px",borderRadius:6,border:"1px solid var(--nice-danger, #ef4444)",background:"transparent",color:"var(--nice-color-error, #ef4444)",cursor:"pointer",fontSize:12},children:e.jsx(a.NiceIcon,{name:"trash",size:14})})]}),e.jsxs("div",{style:{marginBottom:20},children:[e.jsx("label",{style:{display:"block",fontSize:11,color:l.textMuted,marginBottom:6},children:p("testBuilder.component","Component")}),e.jsx("input",{type:"text",value:_.componentName,onChange:u=>E(_.id,{componentName:u.target.value}),style:{width:200,padding:8,borderRadius:4,border:`1px solid ${l.border}`,background:l.cardBg,color:l.text,fontSize:13}})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[_.tests.map((u,W)=>{const J=F.has(u.id),K={unit:{color:"var(--nice-color-primary, #3b82f6)",icon:"puzzle"},integration:{color:"var(--nice-color-success, #22c55e)",icon:"link"},e2e:{color:"var(--nice-color-accent, #8b5cf6)",icon:"globe"},snapshot:{color:"var(--nice-color-warning, #f59e0b)",icon:"camera"},accessibility:{color:"var(--nice-color-accent-pink, #ec4899)",icon:"accessibility"}};return e.jsxs("div",{style:{background:l.cardBg,borderRadius:8,border:`1px solid ${G===u.id?"var(--nice-color-primary, #3b82f6)":l.border}`,overflow:"hidden"},children:[e.jsxs("div",{style:{padding:12,display:"flex",alignItems:"center",gap:8,cursor:"pointer",borderLeft:`4px solid ${K[u.type].color}`},onClick:()=>{O(u.id),Y(L=>{const y=new Set(L);return y.has(u.id)?y.delete(u.id):y.add(u.id),y})},children:[e.jsx("span",{children:e.jsx(a.NiceIcon,{name:K[u.type].icon,size:14})}),e.jsxs("span",{style:{fontWeight:500,opacity:u.skip?.5:1},children:[W+1,". ",u.name]}),u.skip&&e.jsx("span",{style:{padding:"2px 6px",background:"var(--nice-warning-tint-20, #f59e0b30)",color:"var(--nice-color-warning, #f59e0b)",borderRadius:4,fontSize:10},children:p("testBuilder.skipped","SKIPPED")}),u.only&&e.jsx("span",{style:{padding:"2px 6px",background:"color-mix(in srgb, var(--nice-color-accent, #8b5cf6) 19%, transparent)",color:"var(--nice-color-accent, #8b5cf6)",borderRadius:4,fontSize:10},children:p("testBuilder.only","ONLY")}),e.jsxs("span",{style:{marginLeft:"auto",fontSize:11,color:l.textMuted},children:[u.steps.length," step",u.steps.length!==1?"s":""]}),e.jsx("span",{style:{color:l.textMuted},children:e.jsx(a.NiceIcon,{name:J?"chevron-down":"chevron-right",size:14})})]}),J&&e.jsxs("div",{style:{padding:16,borderTop:`1px solid ${l.border}`},children:[e.jsxs("div",{style:{display:"flex",gap:12,marginBottom:16},children:[e.jsxs("div",{style:{flex:1},children:[e.jsx("label",{style:{display:"block",fontSize:11,color:l.textMuted,marginBottom:4},children:p("testBuilder.testName","Test Name")}),e.jsx("input",{type:"text",value:u.name,onChange:L=>n(u.id,{name:L.target.value}),style:{width:"100%",padding:8,borderRadius:4,border:`1px solid ${l.border}`,background:l.bg,color:l.text,fontSize:12,boxSizing:"border-box"}})]}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:11,color:l.textMuted,marginBottom:4},children:p("testBuilder.type","Type")}),e.jsxs("select",{value:u.type,onChange:L=>n(u.id,{type:L.target.value}),style:{padding:8,borderRadius:4,border:`1px solid ${l.border}`,background:l.bg,color:l.text,fontSize:12},children:[e.jsx("option",{value:"unit",children:p("testBuilder.unit","Unit")}),e.jsx("option",{value:"integration",children:p("testBuilder.integration","Integration")}),e.jsx("option",{value:"e2e",children:"E2E"}),e.jsx("option",{value:"snapshot",children:p("testBuilder.snapshot","Snapshot")}),e.jsx("option",{value:"accessibility",children:"A11y"})]})]}),e.jsxs("div",{style:{display:"flex",gap:8,alignItems:"flex-end"},children:[e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:4,fontSize:11},children:[e.jsx("input",{type:"checkbox",checked:u.skip??!1,onChange:L=>n(u.id,{skip:L.target.checked,only:!1})}),p("testBuilder.skip","Skip")]}),e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:4,fontSize:11},children:[e.jsx("input",{type:"checkbox",checked:u.only??!1,onChange:L=>n(u.id,{only:L.target.checked,skip:!1})}),p("testBuilder.only2","Only")]})]})]}),e.jsxs("div",{style:{marginBottom:12},children:[e.jsx("div",{style:{fontSize:11,color:l.textMuted,marginBottom:8},children:p("testBuilder.steps","Steps")}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:u.steps.map((L,y)=>{const P=be[L.action];return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:10,background:l.bg,borderRadius:6,borderLeft:`3px solid ${P.color}`},children:[e.jsx("span",{style:{width:20,textAlign:"center",fontSize:11,color:l.textMuted},children:y+1}),e.jsx("span",{children:e.jsx(a.NiceIcon,{name:P.icon,size:14})}),e.jsx("select",{value:L.action,onChange:A=>s(u.id,L.id,{action:A.target.value}),style:{padding:6,borderRadius:4,border:`1px solid ${l.border}`,background:l.cardBg,color:l.text,fontSize:11},children:Object.entries(be).map(([A,X])=>e.jsx("option",{value:A,children:X.label},A))}),P.hasTarget&&e.jsx("input",{type:"text",value:L.target??"",onChange:A=>s(u.id,L.id,{target:A.target.value}),placeholder:p("testBuilder.targetSelector","Target selector"),style:{flex:1,padding:6,borderRadius:4,border:`1px solid ${l.border}`,background:l.cardBg,color:l.text,fontSize:11}}),P.hasValue&&L.action!=="assert"&&e.jsx("input",{type:"text",value:typeof L.value=="string"?L.value:"",onChange:A=>s(u.id,L.id,{value:A.target.value}),placeholder:p("testBuilder.value","Value"),style:{width:120,padding:6,borderRadius:4,border:`1px solid ${l.border}`,background:l.cardBg,color:l.text,fontSize:11}}),e.jsx("button",{onClick:()=>N(u.id,L.id),"aria-label":p("testBuilder.removeStep","Remove step"),style:{padding:4,borderRadius:4,border:"none",background:"transparent",color:"var(--nice-color-error, #ef4444)",cursor:"pointer",fontSize:12},children:e.jsx(a.NiceIcon,{name:"close",size:14})})]},L.id)})})]}),e.jsx("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:Object.entries(be).slice(0,8).map(([L,y])=>e.jsxs("button",{onClick:()=>f(u.id,L),style:{padding:"4px 8px",borderRadius:4,border:`1px solid ${y.color}40`,background:`${y.color}20`,color:l.text,cursor:"pointer",fontSize:10},children:[e.jsx(a.NiceIcon,{name:y.icon,size:14})," ",y.label]},L))}),e.jsx("div",{style:{marginTop:16,display:"flex",gap:8},children:e.jsxs("button",{onClick:()=>g(u.id),style:{padding:"6px 12px",borderRadius:4,border:"1px solid var(--nice-danger, #ef4444)",background:"transparent",color:"var(--nice-color-error, #ef4444)",cursor:"pointer",fontSize:11},children:[e.jsx(a.NiceIcon,{name:"trash",size:14})," ",p("testBuilder.deleteTest","Delete Test")]})})]})]},u.id)}),e.jsx("button",{onClick:t,style:{padding:16,borderRadius:8,border:`1px dashed ${l.border}`,background:"transparent",color:l.textMuted,cursor:"pointer",fontSize:13},children:"+ Add Test"})]})]}),(T==="code"||T==="split")&&e.jsx("div",{style:{flex:1,overflow:"auto",padding:16,background:"var(--nice-bg-canvas, #0d1117)",borderLeft:T==="split"?`1px solid ${l.border}`:void 0},children:e.jsx("pre",{style:{margin:0,fontFamily:"Consolas, Monaco, monospace",fontSize:12,lineHeight:1.5,color:"var(--nice-text-primary, #e6edf3)",whiteSpace:"pre-wrap"},children:Z})})]})})},Mt=Object.freeze(Object.defineProperty({__proto__:null,NiceTestBuilder:Ge},Symbol.toStringTag,{value:"Module"})),Dt=[],Ft=[{id:"react",name:"React",icon:"settings",description:"React component templates",templates:[{id:"react-component",name:"React Component",description:"Basic React functional component",category:"components",icon:"box",engine:"handlebars",variables:[{id:"componentName",name:"componentName",type:"string",required:!0,defaultValue:"MyComponent"},{id:"withProps",name:"withProps",type:"boolean",defaultValue:!0},{id:"withTests",name:"withTests",type:"boolean",defaultValue:!0},{id:"withStory",name:"withStory",type:"boolean",defaultValue:!1}],files:[{id:"component",name:"{{componentName}}.tsx",path:"src/components/{{componentName}}",language:"typescript",content:`import React from 'react';
226
+ {{#if withProps}}
227
+ export interface {{componentName}}Props {
228
+ children?: React.ReactNode;
229
+ className?: string;
230
+ }
231
+ {{/if}}
232
+
233
+ export const {{componentName}}: React.FC{{#if withProps}}<{{componentName}}Props>{{/if}} = ({{#if withProps}}{ children, className }{{/if}}) => {
234
+ return (
235
+ <div className={className}>
236
+ {children}
237
+ </div>
238
+ );
239
+ };
240
+
241
+ export default {{componentName}};
242
+ `},{id:"test",name:"{{componentName}}.test.tsx",path:"src/components/{{componentName}}",language:"typescript",condition:"withTests === true",content:`import { render, screen } from '@testing-library/react';
243
+ import { {{componentName}} } from './{{componentName}}';
244
+
245
+ describe('{{componentName}}', () => {
246
+ it('renders children', () => {
247
+ render(<{{componentName}}>Test Content</{{componentName}}>);
248
+ expect(screen.getByText('Test Content')).toBeInTheDocument();
249
+ });
250
+ });
251
+ `},{id:"story",name:"{{componentName}}.stories.tsx",path:"src/components/{{componentName}}",language:"typescript",condition:"withStory === true",content:`import type { Meta, StoryObj } from '@storybook/react';
252
+ import { {{componentName}} } from './{{componentName}}';
253
+
254
+ const meta: Meta<typeof {{componentName}}> = {
255
+ title: 'Components/{{componentName}}',
256
+ component: {{componentName}},
257
+ };
258
+
259
+ export default meta;
260
+ type Story = StoryObj<typeof {{componentName}}>;
261
+
262
+ export const Default: Story = {
263
+ args: {},
264
+ };
265
+ `},{id:"index",name:"index.ts",path:"src/components/{{componentName}}",language:"typescript",content:`export { {{componentName}} } from './{{componentName}}';
266
+ export type { {{componentName}}Props } from './{{componentName}}';
267
+ `}]}]},{id:"nextjs",name:"Next.js",icon:"play",description:"Next.js page and API templates",templates:[{id:"nextjs-page",name:"Next.js Page",description:"Next.js App Router page",category:"pages",icon:"file",engine:"handlebars",variables:[{id:"pageName",name:"pageName",type:"string",required:!0,defaultValue:"about"},{id:"withMetadata",name:"withMetadata",type:"boolean",defaultValue:!0},{id:"withLoading",name:"withLoading",type:"boolean",defaultValue:!1},{id:"withError",name:"withError",type:"boolean",defaultValue:!1}],files:[{id:"page",name:"page.tsx",path:"app/{{pageName}}",language:"typescript",content:`{{#if withMetadata}}
268
+ import type { Metadata } from 'next';
269
+
270
+ export const metadata: Metadata = {
271
+ title: '{{pageName}}',
272
+ description: '{{pageName}} page',
273
+ };
274
+ {{/if}}
275
+
276
+ export default function {{pascalCase pageName}}Page() {
277
+ return (
278
+ <main>
279
+ <h1>{{pageName}}</h1>
280
+ </main>
281
+ );
282
+ }
283
+ `},{id:"loading",name:"loading.tsx",path:"app/{{pageName}}",language:"typescript",condition:"withLoading === true",content:`export default function Loading() {
284
+ return <div>Loading...</div>;
285
+ }
286
+ `},{id:"error",name:"error.tsx",path:"app/{{pageName}}",language:"typescript",condition:"withError === true",content:`'use client';
287
+
288
+ export default function Error({
289
+ error,
290
+ reset,
291
+ }: {
292
+ error: Error & { digest?: string };
293
+ reset: () => void;
294
+ }) {
295
+ return (
296
+ <div>
297
+ <h2>Something went wrong!</h2>
298
+ <button onClick={reset}>Try again</button>
299
+ </div>
300
+ );
301
+ }
302
+ `}]},{id:"nextjs-api",name:"Next.js API Route",description:"Next.js App Router API handler",category:"api",icon:"plug",engine:"handlebars",variables:[{id:"routeName",name:"routeName",type:"string",required:!0,defaultValue:"users"},{id:"methods",name:"methods",type:"array",defaultValue:["GET","POST"]}],files:[{id:"route",name:"route.ts",path:"app/api/{{routeName}}",language:"typescript",content:`import { NextResponse } from 'next/server';
303
+
304
+ {{#if (includes methods 'GET')}}
305
+ export async function GET() {
306
+ return NextResponse.json({ message: 'GET {{routeName}}' });
307
+ }
308
+ {{/if}}
309
+
310
+ {{#if (includes methods 'POST')}}
311
+ export async function POST(request: Request) {
312
+ const body = await request.json();
313
+ return NextResponse.json({ message: 'POST {{routeName}}', data: body });
314
+ }
315
+ {{/if}}
316
+
317
+ {{#if (includes methods 'PUT')}}
318
+ export async function PUT(request: Request) {
319
+ const body = await request.json();
320
+ return NextResponse.json({ message: 'PUT {{routeName}}', data: body });
321
+ }
322
+ {{/if}}
323
+
324
+ {{#if (includes methods 'DELETE')}}
325
+ export async function DELETE() {
326
+ return NextResponse.json({ message: 'DELETE {{routeName}}' });
327
+ }
328
+ {{/if}}
329
+ `}]}]}],Oe=(o,S,b)=>{let j=o;Object.entries(S).forEach(([k,d])=>{const C=new RegExp(`\\{\\{\\s*${k}\\s*\\}\\}`,"g");j=j.replace(C,String(d));const r=new RegExp(`\\{\\{\\s*pascalCase\\s+${k}\\s*\\}\\}`,"g");if(typeof d=="string"){const i=d.charAt(0).toUpperCase()+d.slice(1);j=j.replace(r,i)}});const $=/\{\{#if\s+([^}]+)\}\}([\s\S]*?)\{\{\/if\}\}/g;j=j.replace($,(k,d,C)=>{const r=d.trim(),i=r.match(/(\w+)\s*===?\s*(\w+|true|false|'[^']*'|"[^"]*")/);if(i){const[,z,w]=i,I=S[z];let q=w;return w==="true"?q=!0:w==="false"?q=!1:(w.startsWith("'")||w.startsWith('"'))&&(q=w.slice(1,-1)),I===q?C:""}return S[r]?C:""});const v=/\{\{#if\s+\(includes\s+(\w+)\s+'([^']+)'\)\}\}([\s\S]*?)\{\{\/if\}\}/g;return j=j.replace(v,(k,d,C,r)=>{const i=S[d];return Array.isArray(i)&&i.includes(C)?r:""}),j},Et=(o,S)=>{try{const b=o.split(/\s*(===|!==|==|!=)\s*/);if(b.length===3){const[j,$,v]=b,k=S[j.trim()],d=v.trim();let C=d;switch(d==="true"?C=!0:d==="false"?C=!1:(d.startsWith("'")||d.startsWith('"'))&&(C=d.slice(1,-1)),$){case"===":case"==":return k===C;case"!==":case"!=":return k!==C}}return!!S[o.trim()]}catch{return!0}},Ye=({templates:o,defaultTemplates:S,onTemplatesChange:b,presets:j=Ft,selectedTemplate:$,defaultSelectedTemplate:v,onSelectedTemplateChange:k,defaultEngine:d="handlebars",showLibrary:C=!0,onTemplateSelect:r,onTemplateCreate:i,onTemplateUpdate:p,onTemplateDelete:z,onGenerate:w,onExport:I,onImport:q,className:G,style:O,"data-testid":T="nice-code-template"})=>{const{t:B}=a.useNiceTranslation(),H=o!==void 0&&b!==void 0,[M,m]=a.useControllableState({value:H?o:void 0,defaultValue:H?S:S??o,fallbackValue:Dt,onChange:b,componentName:"NiceCodeTemplate"});le.useIgnoredPropChangeWarning("NiceCodeTemplate","templates","onTemplatesChange",o,H);const D=$!==void 0&&k!==void 0,[F,Y]=a.useControllableState({value:D?$:void 0,defaultValue:D?v:v??$,fallbackValue:null,onChange:k,componentName:"NiceCodeTemplate"});le.useIgnoredPropChangeWarning("NiceCodeTemplate","selectedTemplate","onSelectedTemplateChange",$,D);const[_,Z]=x.useState({}),[E,V]=x.useState("editor"),[h,t]=x.useState(null),[n,g]=x.useState(!1),[f,s]=x.useState(!1),N=x.useMemo(()=>{const y=j.flatMap(P=>P.templates);return[...M,...y]},[M,j]),l=x.useMemo(()=>N.find(y=>y.id===F),[N,F]),Q=x.useMemo(()=>l?.files.find(y=>y.id===h)||l?.files[0],[l,h]);x.useEffect(()=>{if(l){const y={};l.variables.forEach(P=>{y[P.name]=P.defaultValue??""}),Z(y),t(l.files[0]?.id||null)}},[l]);const te=x.useMemo(()=>l?l.files.filter(y=>y.condition?Et(y.condition,_):!0).map(y=>({path:Oe(`${y.path}/${y.name}`,_,l.engine),content:Oe(y.content,_,l.engine),language:y.language})):[],[l,_]),c=x.useCallback(y=>{Y(y.id),r?.(y)},[r,Y]),ee=x.useCallback(()=>{w?.(te,_)},[te,_,w]),u=x.useCallback(()=>{const y={id:a.createId(),name:"New Template",description:"Custom template",category:"custom",icon:"file",engine:d,variables:[{id:"1",name:"name",type:"string",required:!0,defaultValue:"MyName"}],files:[{id:"1",name:"{{name}}.ts",path:"src",language:"typescript",content:`// {{name}}
330
+ export const {{name}} = {};`}]};m(P=>[...P,y]),Y(y.id),g(!1),i?.(y)},[d,i,m,Y]),W=x.useCallback((y,P)=>{if(!l)return;const A={...l,files:l.files.map(X=>X.id===y?{...X,content:P}:X)};m(X=>X.map(ae=>ae.id===A.id?A:ae)),p?.(A)},[l,p,m]),J=x.useCallback(()=>{if(!l)return;const y={id:a.createId(),name:"new-file.ts",path:"src",language:"typescript",content:`// New file
331
+ `},P={...l,files:[...l.files,y]};m(A=>A.map(X=>X.id===P.id?P:X)),t(y.id),p?.(P)},[l,p,m]),K=x.useCallback(y=>{if(!l)return;const P={...l,files:l.files.filter(A=>A.id!==y)};m(A=>A.map(X=>X.id===P.id?P:X)),t(P.files[0]?.id||null),p?.(P)},[l,p,m]),L=y=>{const P=_[y.name];switch(y.type){case"boolean":return e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:!!P,onChange:A=>Z(X=>({...X,[y.name]:A.target.checked}))}),e.jsx("span",{children:y.name})]});case"select":return e.jsx("select",{value:String(P),onChange:A=>Z(X=>({...X,[y.name]:A.target.value})),style:{width:"100%",padding:"8px 12px",background:"var(--nice-text-secondary, #374151)",border:"1px solid var(--nice-border-color, #4b5563)",borderRadius:6,color:"var(--nice-text-inverse, #fff)"},children:y.options?.map(A=>e.jsx("option",{value:A,children:A},A))});case"array":return e.jsx("input",{type:"text",value:Array.isArray(P)?P.join(", "):"",onChange:A=>Z(X=>({...X,[y.name]:A.target.value.split(",").map(ae=>ae.trim())})),placeholder:B("codeTemplate.value1Value2Value3","value1, value2, value3"),style:{width:"100%",padding:"8px 12px",background:"var(--nice-text-secondary, #374151)",border:"1px solid var(--nice-border-color, #4b5563)",borderRadius:6,color:"var(--nice-text-inverse, #fff)"}});case"number":return e.jsx("input",{type:"number",value:Number(P),onChange:A=>Z(X=>({...X,[y.name]:Number(A.target.value)})),style:{width:"100%",padding:"8px 12px",background:"var(--nice-text-secondary, #374151)",border:"1px solid var(--nice-border-color, #4b5563)",borderRadius:6,color:"var(--nice-text-inverse, #fff)"}});default:return e.jsx("input",{type:"text",value:String(P??""),onChange:A=>Z(X=>({...X,[y.name]:A.target.value})),style:{width:"100%",padding:"8px 12px",background:"var(--nice-text-secondary, #374151)",border:"1px solid var(--nice-border-color, #4b5563)",borderRadius:6,color:"var(--nice-text-inverse, #fff)"}})}};return e.jsxs("div",{className:`nice-code-template ${G||""}`,style:{display:"flex",height:"100%",background:"var(--nice-bg-canvas, #0d1117)",color:"var(--nice-text-primary, #e6edf3)",fontFamily:"system-ui, sans-serif",...O},"data-testid":T,children:[C&&e.jsxs("div",{style:{width:280,borderRight:"1px solid var(--nice-border, #30363d)",display:"flex",flexDirection:"column"},children:[e.jsxs("div",{style:{padding:"12px 16px",borderBottom:"1px solid var(--nice-border, #30363d)",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("span",{style:{fontWeight:500,display:"flex",alignItems:"center",gap:6},children:[e.jsx(a.NiceIcon,{name:"book",size:16})," ",B("codeTemplate.templates","Templates")]}),e.jsx("button",{onClick:u,style:{padding:"4px 8px",background:"var(--nice-color-primary, #3b82f6)",border:"none",borderRadius:4,color:"var(--nice-text-on-primary, #fff)",cursor:"pointer",fontSize:12},children:"+ New"})]}),e.jsxs("div",{style:{flex:1,overflow:"auto"},children:[M.length>0&&e.jsxs("div",{style:{padding:8},children:[e.jsx("div",{style:{fontSize:11,color:"var(--nice-text-muted, #8b949e)",padding:"8px 8px 4px",fontWeight:500},children:B("codeTemplate.custom","CUSTOM")}),M.map(y=>e.jsxs("div",{onClick:()=>c(y),style:{padding:"10px 12px",borderRadius:6,cursor:"pointer",background:F===y.id?"var(--nice-primary-tint-15, rgba(59, 130, 246, 0.15))":"transparent",display:"flex",alignItems:"center",gap:10},children:[e.jsx(a.NiceIcon,{name:y.icon||"file",size:16}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{style:{fontSize:13},children:y.name}),e.jsx("div",{style:{fontSize:11,color:"var(--nice-text-muted, #8b949e)"},children:y.category})]})]},y.id))]}),j.map(y=>e.jsxs("div",{style:{padding:8},children:[e.jsxs("div",{style:{fontSize:11,color:"var(--nice-text-muted, #8b949e)",padding:"8px 8px 4px",fontWeight:500,display:"flex",alignItems:"center",gap:6},children:[e.jsx(a.NiceIcon,{name:y.icon,size:12}),y.name.toUpperCase()]}),y.templates.map(P=>e.jsxs("div",{onClick:()=>c(P),style:{padding:"10px 12px",borderRadius:6,cursor:"pointer",background:F===P.id?"var(--nice-primary-tint-15, rgba(59, 130, 246, 0.15))":"transparent",display:"flex",alignItems:"center",gap:10},children:[e.jsx(a.NiceIcon,{name:P.icon||"file",size:16}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{style:{fontSize:13},children:P.name}),e.jsx("div",{style:{fontSize:11,color:"var(--nice-text-muted, #8b949e)"},children:P.description})]})]},P.id))]},y.id))]})]}),e.jsx("div",{style:{flex:1,display:"flex",flexDirection:"column"},children:l?e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{padding:"12px 16px",borderBottom:"1px solid var(--nice-border, #30363d)",background:"var(--nice-bg-elevated, #161b22)",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(a.NiceIcon,{name:l.icon||"file",size:24}),e.jsxs("div",{children:[e.jsx("div",{style:{fontWeight:500},children:l.name}),e.jsx("div",{style:{fontSize:12,color:"var(--nice-text-muted, #8b949e)"},children:l.description})]})]}),e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsxs("button",{onClick:()=>I?.(l,"json"),style:{padding:"6px 12px",background:"var(--nice-text-secondary, #374151)",border:"none",borderRadius:6,color:"var(--nice-text-inverse, #fff)",cursor:"pointer",fontSize:12,display:"inline-flex",alignItems:"center",gap:6},children:[e.jsx(a.NiceIcon,{name:"upload",size:14})," ",B("codeTemplate.export","Export")]}),e.jsxs("button",{onClick:ee,style:{padding:"6px 16px",background:"var(--nice-color-success, #22c55e)",border:"none",borderRadius:6,color:"var(--nice-text-on-primary, #fff)",cursor:"pointer",fontSize:12,fontWeight:500,display:"inline-flex",alignItems:"center",gap:6},children:[e.jsx(a.NiceIcon,{name:"zap",size:14})," ",B("codeTemplate.generate","Generate")]})]})]}),e.jsx("div",{style:{display:"flex",borderBottom:"1px solid var(--nice-border, #30363d)",background:"var(--nice-bg-elevated, #161b22)"},children:["variables","editor","preview"].map(y=>e.jsxs("button",{onClick:()=>V(y),style:{padding:"10px 20px",background:E===y?"var(--nice-bg-canvas, #0d1117)":"transparent",border:"none",borderBottom:E===y?"2px solid var(--nice-primary, #3b82f6)":"2px solid transparent",color:E===y?"var(--nice-text-primary, #fff)":"var(--nice-text-muted, #8b949e)",cursor:"pointer",textTransform:"capitalize"},children:[y==="variables"&&e.jsxs(e.Fragment,{children:[e.jsx(a.NiceIcon,{name:"settings",size:14})," "]}),y==="editor"&&e.jsxs(e.Fragment,{children:[e.jsx(a.NiceIcon,{name:"edit",size:14})," "]}),y==="preview"&&e.jsxs(e.Fragment,{children:[e.jsx(a.NiceIcon,{name:"eye",size:14})," "]}),y]},y))}),e.jsxs("div",{style:{flex:1,display:"flex",overflow:"hidden"},children:[E==="variables"&&e.jsx("div",{style:{flex:1,padding:20,overflow:"auto"},children:e.jsxs("div",{style:{maxWidth:500},children:[e.jsx("h3",{style:{marginBottom:20},children:B("codeTemplate.templateVariables","Template Variables")}),l.variables.map(y=>e.jsxs("div",{style:{marginBottom:16},children:[e.jsxs("label",{style:{display:"block",fontSize:12,color:"var(--nice-text-muted, #8b949e)",marginBottom:4},children:[y.name,y.required&&e.jsx("span",{style:{color:"var(--nice-color-error, #ef4444)"},children:" *"})]}),L(y),y.description&&e.jsx("div",{style:{fontSize:11,color:"var(--nice-text-muted, #6b7280)",marginTop:4},children:y.description})]},y.id))]})}),E==="editor"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{width:200,borderRight:"1px solid var(--nice-border, #30363d)",display:"flex",flexDirection:"column"},children:[e.jsxs("div",{style:{padding:"8px 12px",borderBottom:"1px solid var(--nice-border, #30363d)",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsx("span",{style:{fontSize:12,color:"var(--nice-text-muted, #8b949e)"},children:B("codeTemplate.files","Files")}),e.jsx("button",{onClick:J,style:{padding:"2px 6px",background:"var(--nice-text-secondary, #374151)",border:"none",borderRadius:4,color:"var(--nice-text-inverse, #fff)",cursor:"pointer",fontSize:12},children:"+"})]}),e.jsx("div",{style:{flex:1,overflow:"auto"},children:l.files.map(y=>e.jsxs("div",{onClick:()=>t(y.id),style:{padding:"8px 12px",cursor:"pointer",background:h===y.id?"var(--nice-primary-tint-15, rgba(59, 130, 246, 0.15))":"transparent",borderLeft:h===y.id?"2px solid var(--nice-primary, #3b82f6)":"2px solid transparent",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsx("div",{style:{fontSize:12,overflow:"hidden",textOverflow:"ellipsis"},children:y.name}),e.jsx("button",{"aria-label":B("codeTemplate.removeFile","Remove file"),onClick:P=>{P.stopPropagation(),K(y.id)},style:{background:"none",border:"none",color:"var(--nice-color-error, #ef4444)",cursor:"pointer",fontSize:12,opacity:.7,display:"inline-flex",alignItems:"center"},children:e.jsx(a.NiceIcon,{name:"close",size:14})})]},y.id))})]}),e.jsx("div",{style:{flex:1,display:"flex",flexDirection:"column"},children:Q&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{padding:"8px 12px",borderBottom:"1px solid var(--nice-border, #30363d)",background:"var(--nice-bg-elevated, #161b22)",fontSize:12},children:[Q.path,"/",Q.name,Q.condition&&e.jsxs("span",{style:{color:"var(--nice-color-warning, #f59e0b)",marginLeft:8},children:["(if: ",Q.condition,")"]})]}),e.jsx("textarea",{value:Q.content,onChange:y=>W(Q.id,y.target.value),style:{flex:1,padding:16,background:"var(--nice-bg-canvas, #0d1117)",color:"var(--nice-text-primary, #e6edf3)",border:"none",fontFamily:"ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace",fontSize:13,lineHeight:1.5,resize:"none"}})]})})]}),E==="preview"&&e.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden"},children:[e.jsx("div",{style:{padding:"12px 16px",borderBottom:"1px solid var(--nice-border, #30363d)",background:"var(--nice-bg-elevated, #161b22)"},children:e.jsxs("span",{style:{fontSize:12,color:"var(--nice-text-muted, #8b949e)"},children:[te.length," file(s) will be generated"]})}),e.jsx("div",{style:{flex:1,overflow:"auto"},children:te.map((y,P)=>e.jsxs("div",{style:{borderBottom:"1px solid var(--nice-border, #30363d)"},children:[e.jsxs("div",{style:{padding:"8px 16px",background:"var(--nice-bg-secondary, #1f2937)",fontFamily:"monospace",fontSize:12,color:"var(--nice-text-muted, #8b949e)",display:"flex",alignItems:"center",gap:6},children:[e.jsx(a.NiceIcon,{name:"file",size:14})," ",y.path]}),e.jsx("pre",{style:{margin:0,padding:16,background:"var(--nice-bg-canvas, #0d1117)",fontFamily:"ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace",fontSize:12,lineHeight:1.5,overflow:"auto"},children:y.content})]},P))})]})]})]}):e.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",color:"var(--nice-text-muted, #8b949e)"},children:[e.jsx("span",{style:{marginBottom:16},children:e.jsx(a.NiceIcon,{name:"book",size:64})}),e.jsx("span",{style:{fontSize:18},children:B("codeTemplate.selectATemplate","Select a template")}),e.jsx("span",{style:{fontSize:12,marginTop:4},children:B("codeTemplate.chooseFromTheLibraryOr","Choose from the library or create a new template")}),e.jsxs("button",{onClick:u,style:{marginTop:20,padding:"10px 20px",background:"var(--nice-color-primary, #3b82f6)",border:"none",borderRadius:6,color:"var(--nice-text-on-primary, #fff)",cursor:"pointer",display:"inline-flex",alignItems:"center",gap:6},children:[e.jsx(a.NiceIcon,{name:"plus",size:14})," ",B("codeTemplate.createTemplate","Create Template")]})]})})]})},At=Object.freeze(Object.defineProperty({__proto__:null,NiceCodeTemplate:Ye},Symbol.toStringTag,{value:"Module"}));exports.NiceAPIFlow=We;exports.NiceAPIFlow$1=jt;exports.NiceCheckbox=we;exports.NiceCheckbox$1=it;exports.NiceCodePreview=Le;exports.NiceCodeTemplate=Ye;exports.NiceCodeTemplate$1=At;exports.NiceComponentDesigner=ut;exports.NiceDataMapper=Je;exports.NiceDataMapper$1=kt;exports.NiceEventOrchestrator=Ke;exports.NiceEventOrchestrator$1=Tt;exports.NiceLowCodeStudio=ct;exports.NiceNumberInput=ke;exports.NiceNumberInput$1=rt;exports.NicePageBuilder=gt;exports.NiceStateDesigner=qe;exports.NiceStateDesigner$1=bt;exports.NiceTestBuilder=Ge;exports.NiceTestBuilder$1=Mt;exports.NiceTextInput=Ne;exports.NiceTextInput$1=ot;