@nice2dev/ui 1.1.9 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (163) hide show
  1. package/CHANGELOG.md +150 -0
  2. package/README.md +27 -34
  3. package/dist/NiceButton-5tWvfXKl.cjs +1 -0
  4. package/dist/NiceButton-DHSgQT1_.js +112 -0
  5. package/dist/NiceCodeEditor-B8At55f5.js +1179 -0
  6. package/dist/NiceCodeEditor-BJSEzhcY.cjs +260 -0
  7. package/dist/NiceCodeEditor-BfkH1bsZ.cjs +260 -0
  8. package/dist/NiceCodeEditor-CduGYggj.js +1179 -0
  9. package/dist/NiceColorPicker-CdUnhM-A.cjs +1 -0
  10. package/dist/NiceColorPicker-DCgmE-3H.cjs +1 -0
  11. package/dist/NiceColorPicker-DK30kJgy.js +486 -0
  12. package/dist/NiceColorPicker-DpXwnDwL.js +598 -0
  13. package/dist/NiceColorPicker-DtPFxDKM.cjs +1 -0
  14. package/dist/NiceColorPicker-bNJBAU_c.js +598 -0
  15. package/dist/NiceConfirmDialog-B7aNRL2K.cjs +1 -0
  16. package/dist/NiceConfirmDialog-BdhWenrO.js +81 -0
  17. package/dist/NiceDataGrid-BOCJr6XF.js +2217 -0
  18. package/dist/NiceDataGrid-BV5Oh-gy.cjs +10 -0
  19. package/dist/NiceDataGrid-CVYEo_nv.cjs +10 -0
  20. package/dist/NiceDataGrid-D-rm4lu8.js +2217 -0
  21. package/dist/NiceDataGrid-Dd7SI-M6.cjs +10 -0
  22. package/dist/NiceDataGrid-DjZchXYG.js +2217 -0
  23. package/dist/NiceDocumentViewer-BgcgLWJ3.cjs +180 -0
  24. package/dist/NiceDocumentViewer-sukmGhRx.js +672 -0
  25. package/dist/NiceForm-BCEXovJR.cjs +1 -0
  26. package/dist/NiceForm-D7oyWHXg.js +4820 -0
  27. package/dist/NiceForm-DUhxXArr.js +4817 -0
  28. package/dist/NiceForm-DVc0Xoly.js +4819 -0
  29. package/dist/NiceForm-qD_RKPYz.cjs +1 -0
  30. package/dist/NiceForm-uCeVmTrD.cjs +1 -0
  31. package/dist/NiceGantt-4UBd4uJ8.cjs +1 -0
  32. package/dist/NiceGantt-B_1lwEsp.js +328 -0
  33. package/dist/NiceHtmlEditor-BYk1roA4.cjs +10 -0
  34. package/dist/NiceHtmlEditor-Bce9Vwe1.cjs +10 -0
  35. package/dist/NiceHtmlEditor-C5kLeF9H.cjs +10 -0
  36. package/dist/NiceHtmlEditor-CFVMIC5L.js +848 -0
  37. package/dist/NiceHtmlEditor-CGRgcu2h.js +848 -0
  38. package/dist/NiceHtmlEditor-mWebBmy1.js +849 -0
  39. package/dist/NiceLoginForm-BHyDY7br.cjs +1 -0
  40. package/dist/NiceLoginForm-BTuQ0eKk.cjs +1 -0
  41. package/dist/NiceLoginForm-BuxFY2Rk.js +750 -0
  42. package/dist/NiceLoginForm-o1A-TBcp.js +736 -0
  43. package/dist/NiceLoginForm.css +1 -0
  44. package/dist/NiceMention-CA7CL5BI.js +11263 -0
  45. package/dist/NiceMention-CHcKRl-L.cjs +430 -0
  46. package/dist/NiceMention-DJD0BLcp.js +11269 -0
  47. package/dist/NiceMention-DcaUEMSg.cjs +430 -0
  48. package/dist/NiceMention-Dds9GQzk.cjs +430 -0
  49. package/dist/NiceMention-DlLXWddO.js +11268 -0
  50. package/dist/NiceMention.css +1 -1
  51. package/dist/NiceModal-C4p8a82e.cjs +1 -0
  52. package/dist/NiceModal-Dr1e3nQZ.cjs +1 -0
  53. package/dist/NiceModal-TNlkaL_i.js +85 -0
  54. package/dist/NiceModal-sihGCfDy.js +95 -0
  55. package/dist/NiceModuleLifecyclePanel-BWbKdVC_.js +7054 -0
  56. package/dist/NiceModuleLifecyclePanel-CZHIzvkE.cjs +1 -0
  57. package/dist/NiceModuleLifecyclePanel-Du7G3-RG.js +7053 -0
  58. package/dist/NiceModuleLifecyclePanel-OC9YK2kG.js +7052 -0
  59. package/dist/NiceModuleLifecyclePanel-_OcfDmtC.cjs +1 -0
  60. package/dist/NiceModuleLifecyclePanel-js1p7LIY.cjs +1 -0
  61. package/dist/NicePagination-8XsBbMNx.js +165 -0
  62. package/dist/NicePagination-CkOoXf0f.js +165 -0
  63. package/dist/NicePagination-D44waj9o.cjs +1 -0
  64. package/dist/NicePagination-D7lek1G7.cjs +1 -0
  65. package/dist/NicePagination-DdxH8KMG.js +179 -0
  66. package/dist/NicePagination-OjTEfZJE.cjs +1 -0
  67. package/dist/NicePivotGrid-B2YHP3Z6.js +1183 -0
  68. package/dist/NicePivotGrid-BJRSciWl.js +1183 -0
  69. package/dist/NicePivotGrid-BtVUWiud.cjs +152 -0
  70. package/dist/NicePivotGrid-CS1dPmNI.cjs +152 -0
  71. package/dist/NicePivotGrid-D2AxqDzJ.js +1183 -0
  72. package/dist/NicePivotGrid-DxQ6Py9D.cjs +152 -0
  73. package/dist/NiceSavedQueryPanel-B5HhqlAI.cjs +586 -0
  74. package/dist/NiceSavedQueryPanel-C0A-eoYN.js +5142 -0
  75. package/dist/NiceSavedQueryPanel-CMStDOKe.js +5125 -0
  76. package/dist/NiceSavedQueryPanel-D2i34e_b.cjs +586 -0
  77. package/dist/NiceSavedQueryPanel-ZrilZRtf.cjs +586 -0
  78. package/dist/NiceSavedQueryPanel-mPO2THs7.js +5142 -0
  79. package/dist/NiceSavedQueryPanel.css +1 -1
  80. package/dist/NiceScheduler-7gP7vcLy.cjs +5 -0
  81. package/dist/NiceScheduler-Cy7F9tgH.js +1693 -0
  82. package/dist/NiceScheduler-DquRUZxD.cjs +5 -0
  83. package/dist/NiceScheduler-KSzaUQxC.js +1693 -0
  84. package/dist/NiceScheduler-O3AwmdGG.cjs +5 -0
  85. package/dist/NiceScheduler-l8N4yCWd.js +1716 -0
  86. package/dist/NiceSelect-BCbWtu1v.js +433 -0
  87. package/dist/NiceSelect-BqtiQbfD.cjs +1 -0
  88. package/dist/NiceSelect-DZB1Rs9x.js +435 -0
  89. package/dist/NiceSelect-tMz9QQUs.cjs +1 -0
  90. package/dist/NiceStreamDashboard.doc-74KUXya1.cjs +8 -0
  91. package/dist/NiceStreamDashboard.doc-k8PQfCM0.js +32 -0
  92. package/dist/NiceWindow-BEov3s9F.js +2094 -0
  93. package/dist/NiceWindow-BU1Ce7gS.js +1623 -0
  94. package/dist/NiceWindow-CDt6PCEg.cjs +1 -0
  95. package/dist/NiceWindow-jjdE6vGy.cjs +1 -0
  96. package/dist/NiceWindow.css +1 -1
  97. package/dist/charts-C047IMVn.cjs +768 -0
  98. package/dist/charts-C44vJber.cjs +768 -0
  99. package/dist/charts-CCXSb3xk.js +4752 -0
  100. package/dist/charts-CqETcUhH.js +4752 -0
  101. package/dist/charts-DouiiHOT.cjs +768 -0
  102. package/dist/charts-XVlDwU0y.js +4732 -0
  103. package/dist/charts.cjs +1 -1
  104. package/dist/charts.mjs +8 -8
  105. package/dist/core-BL-KmGYC.js +795 -0
  106. package/dist/core-BxiH7vkV.cjs +1 -0
  107. package/dist/core-Chg-oYCr.cjs +1 -0
  108. package/dist/core-CxBnKAhs.cjs +1 -0
  109. package/dist/core-DMV6_SEE.js +795 -0
  110. package/dist/core-D_LRh59n.js +795 -0
  111. package/dist/data-branching-Km4lc8P_.cjs +1 -0
  112. package/dist/data-branching-YQtJJEtn.js +6273 -0
  113. package/dist/data-branching-oEH04O3i.js +6273 -0
  114. package/dist/data-branching-wmsbLNfa.cjs +1 -0
  115. package/dist/data-branching.cjs +1 -1
  116. package/dist/data-branching.mjs +1 -1
  117. package/dist/data.cjs +1 -1
  118. package/dist/data.d.ts +2 -53
  119. package/dist/data.mjs +3 -3
  120. package/dist/devops-Bt6EsfPa.cjs +17 -0
  121. package/dist/devops-CnZQ1rU5.js +8312 -0
  122. package/dist/devops-D5yIDM3e.js +8312 -0
  123. package/dist/devops-rVpB0ZAX.cjs +17 -0
  124. package/dist/devops.cjs +1 -1
  125. package/dist/devops.mjs +1 -1
  126. package/dist/editors.cjs +1 -1
  127. package/dist/editors.d.ts +8 -26
  128. package/dist/editors.mjs +55 -54
  129. package/dist/feedback.cjs +1 -1
  130. package/dist/feedback.d.ts +5 -0
  131. package/dist/feedback.mjs +3 -3
  132. package/dist/index.cjs +290 -290
  133. package/dist/index.css +1 -1
  134. package/dist/index.d.ts +239 -234
  135. package/dist/index.mjs +20262 -19440
  136. package/dist/lazy.cjs +1 -1
  137. package/dist/lazy.mjs +29 -29
  138. package/dist/navigation.cjs +1 -1
  139. package/dist/navigation.d.ts +4 -4
  140. package/dist/navigation.mjs +69 -69
  141. package/dist/no-code-4GtIBr6f.js +7503 -0
  142. package/dist/no-code-6WyYb3hL.cjs +331 -0
  143. package/dist/no-code-BH5oVFC6.js +8186 -0
  144. package/dist/no-code-Bdwh1vyS.cjs +332 -0
  145. package/dist/no-code-CnHG5_Vn.js +8186 -0
  146. package/dist/no-code-DMKlg1Zl.cjs +331 -0
  147. package/dist/no-code.cjs +1 -1
  148. package/dist/no-code.css +1 -1
  149. package/dist/no-code.d.ts +25 -18
  150. package/dist/no-code.mjs +3 -3
  151. package/dist/overlays.cjs +1 -1
  152. package/dist/overlays.d.ts +24 -24
  153. package/dist/overlays.mjs +24 -490
  154. package/dist/pickerCommons-0vyK1Knv.js +547 -0
  155. package/dist/pickerCommons-31hyz1gs.js +1122 -0
  156. package/dist/pickerCommons-BFbItm8o.cjs +1 -0
  157. package/dist/pickerCommons-BHirHJyn.js +548 -0
  158. package/dist/pickerCommons-BifIkPdk.cjs +1 -0
  159. package/dist/pickerCommons-Bt8JIaTN.cjs +1 -0
  160. package/dist/pickerCommons.css +1 -1
  161. package/dist/style.css +10 -7
  162. package/package.json +5 -7
  163. package/css/legacy-bg-text-aliases.css +0 -87
@@ -0,0 +1,332 @@
1
+ "use strict";const e=require("react/jsx-runtime"),s=require("@nice2dev/ui-core"),f=require("react"),ee=require("./devops-Bt6EsfPa.cjs"),ke=[{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"}],we=({projectId:i,components:v=[],theme:j="light",onChange:y,onSave:z,className:b,tutorial:k})=>{const[l,N]=f.useState("design");return e.jsx(ee.NiceAppShell,{flush:!0,className:`nice-lowcode-studio nice-lowcode-studio--${j} ${b||""}`,menubar:e.jsxs("header",{className:"nice-lowcode-studio__header",children:[e.jsx("h1",{children:"Low-Code Studio"}),e.jsxs("nav",{className:"nice-lowcode-studio__tabs",children:[e.jsx("button",{onClick:()=>N("design"),className:l==="design"?"active":"",children:"Design"}),e.jsx("button",{onClick:()=>N("preview"),className:l==="preview"?"active":"",children:"Preview"}),e.jsx("button",{onClick:()=>N("code"),className:l==="code"?"active":"",children:"Code"})]}),e.jsx("button",{onClick:()=>z?.({components:[],layout:{type:"flex"},styles:{}}),children:"Save"}),e.jsx(s.NiceTutorialButton,{steps:s.resolveTutorial(k,ke)})]}),sidebar:e.jsxs("aside",{className:"nice-lowcode-studio__sidebar",children:[e.jsx("h2",{children:"Components"}),e.jsx("ul",{children:v.map(r=>e.jsx("li",{draggable:!0,children:r.name},r.id))})]}),rightSidebar:e.jsxs("aside",{className:"nice-lowcode-studio__properties",children:[e.jsx("h2",{children:"Properties"}),e.jsx("p",{children:"Select a component to edit properties"})]}),children:e.jsxs("main",{className:"nice-lowcode-studio__canvas","data-project":i,children:[l==="design"&&e.jsx("div",{className:"nice-lowcode-studio__design-canvas",children:e.jsx("p",{children:"Drop components here"})}),l==="preview"&&e.jsx("div",{className:"nice-lowcode-studio__preview",children:e.jsx("p",{children:"Preview mode"})}),l==="code"&&e.jsx("div",{className:"nice-lowcode-studio__code",children:e.jsx("pre",{children:"// Generated code will appear here"})})]})})},$e=[{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"}],ze=({component:i,propTypes:v=[],onChange:j,theme:y="light",className:z,tutorial:b})=>{const[k,l]=f.useState(i||{name:"NewComponent",props:[]}),N=r=>{const c={...k,...r};l(c),j?.(c)};return e.jsxs("div",{className:`nice-component-designer nice-component-designer--${y} ${z||""}`,style:{position:"relative"},children:[e.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:20},children:e.jsx(s.NiceTutorialButton,{steps:s.resolveTutorial(b,$e)})}),e.jsxs("section",{className:"nice-component-designer__header",children:[e.jsx("input",{type:"text",value:k.name,onChange:r=>N({name:r.target.value}),placeholder:"Component Name"}),e.jsx("input",{type:"text",value:k.description||"",onChange:r=>N({description:r.target.value}),placeholder:"Description"})]}),e.jsxs("section",{className:"nice-component-designer__props",children:[e.jsx("h3",{children:"Props"}),k.props.map((r,c)=>e.jsxs("div",{className:"nice-component-designer__prop",children:[e.jsx("input",{type:"text",value:r.name,readOnly:!0}),e.jsx("span",{children:r.type}),r.required&&e.jsx("span",{children:"required"})]},c)),e.jsx("button",{onClick:()=>N({props:[...k.props,{name:"newProp",type:"string"}]}),children:"Add Prop"})]}),e.jsxs("section",{className:"nice-component-designer__preview",children:[e.jsx("h3",{children:"Preview"}),e.jsx("pre",{children:`interface ${k.name}Props {
2
+ ${k.props.map(r=>` ${r.name}${r.required?"":"?"}: ${r.type};`).join(`
3
+ `)}
4
+ }
5
+
6
+ export const ${k.name}: React.FC<${k.name}Props> = (props) => {
7
+ return <div>Component</div>;
8
+ };`})]})]})},Ne=[{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"}],Ce=({initialLayout:i,components:v=[],grid:j={columns:12,gap:16,padding:24},onChange:y,onSave:z,theme:b="light",previewMode:k="desktop",className:l,tutorial:N})=>{const[r,c]=f.useState(i||{id:"page-1",name:"New Page",rows:[]}),[w,M]=f.useState(null),$=D=>{c(D),y?.(D)},L=()=>{const D={id:`row-${Date.now()}`,columns:[{id:`col-${Date.now()}`,width:12,components:[]}]};$({...r,rows:[...r.rows,D]})},P={desktop:"100%",tablet:"768px",mobile:"375px"}[k];return e.jsx(ee.NiceAppShell,{flush:!0,className:`nice-page-builder nice-page-builder--${b} ${l||""}`,toolbar:e.jsxs("header",{className:"nice-page-builder__toolbar",children:[e.jsx("input",{type:"text",value:r.name,onChange:D=>$({...r,name:D.target.value})}),e.jsxs("div",{className:"nice-page-builder__preview-modes",children:[e.jsx("button",{className:k==="desktop"?"active":"",children:"Desktop"}),e.jsx("button",{className:k==="tablet"?"active":"",children:"Tablet"}),e.jsx("button",{className:k==="mobile"?"active":"",children:"Mobile"})]}),e.jsx("button",{onClick:()=>z?.(r),children:"Save"}),e.jsx(s.NiceTutorialButton,{steps:s.resolveTutorial(N,Ne)})]}),sidebar:e.jsxs("aside",{className:"nice-page-builder__sidebar",children:[e.jsx("h3",{children:"Components"}),e.jsx("ul",{className:"nice-page-builder__components",children:v.map(D=>e.jsxs("li",{draggable:!0,className:"nice-page-builder__component-item",children:[D.icon&&e.jsx(s.NiceIcon,{name:D.icon,size:14}),D.name]},D.id))})]}),rightSidebar:e.jsxs("aside",{className:"nice-page-builder__properties",children:[e.jsx("h3",{children:"Properties"}),w?e.jsx("p",{children:"Edit properties for selected component"}):e.jsx("p",{children:"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:P},children:[r.rows.map(D=>e.jsx("div",{className:"nice-page-builder__row",children:D.columns.map(R=>e.jsx("div",{className:"nice-page-builder__column",style:{width:`${R.width/12*100}%`},children:R.components.length===0?e.jsx("div",{className:"nice-page-builder__dropzone",children:"Drop components here"}):R.components.map(J=>e.jsx("div",{className:`nice-page-builder__placed-component ${w===J.id?"selected":""}`,onClick:()=>M(J.id),children:J.type},J.id))},R.id))},D.id)),e.jsx("button",{onClick:L,className:"nice-page-builder__add-row",children:"+ Add Row"})]})})})},Te=({code:i,language:v="typescript",lineNumbers:j=!0,livePreview:y=!1,showDiff:z=!1,previousCode:b,theme:k="light",copyable:l=!0,onCopy:N,className:r})=>{const[c,w]=f.useState(!1),M=async()=>{await navigator.clipboard.writeText(i),w(!0),N?.(),setTimeout(()=>w(!1),2e3)},$=i.split(`
9
+ `),L=()=>e.jsx("div",{className:"nice-code-preview__line-numbers",children:$.map((J,H)=>e.jsx("span",{children:H+1},H))}),P=()=>e.jsx("pre",{className:`nice-code-preview__code language-${v}`,children:e.jsx("code",{children:i})}),D=()=>b?(b.split(`
10
+ `),i.split(`
11
+ `),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:"Previous"}),e.jsx("pre",{children:b})]}),e.jsxs("div",{className:"nice-code-preview__diff-panel nice-code-preview__diff-panel--new",children:[e.jsx("h4",{children:"Current"}),e.jsx("pre",{children:i})]})]})):null,R=()=>v!=="html"&&v!=="jsx"&&v!=="tsx"?e.jsx("div",{className:"nice-code-preview__live-preview",children:e.jsx("p",{children:"Live preview only available for HTML, JSX, and TSX"})}):e.jsx("div",{className:"nice-code-preview__live-preview",children:e.jsx("iframe",{srcDoc:v==="html"?i:'<div id="root"></div><script>/* Preview not available for JSX */<\/script>',title:"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:v}),l&&e.jsx("button",{onClick:M,className:"nice-code-preview__copy-btn",children:c?e.jsxs(e.Fragment,{children:[e.jsx(s.NiceIcon,{name:"check",size:14})," Copied"]}):"Copy"})]}),z&&b?D():e.jsxs("div",{className:"nice-code-preview__body",children:[j&&L(),P()]}),y&&e.jsxs("div",{className:"nice-code-preview__preview-section",children:[e.jsx("h4",{children:"Preview"}),R()]})]})},Ie=[{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"}],Re={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}},Be=[{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:[]}]}}],ie={string:"edit",number:"hash",boolean:"check",array:"clipboard",object:"box",date:"calendar",enum:"bar-chart",custom:"settings"},oe=i=>{const v=["import { create } from 'zustand'"];i.middleware?.some(r=>r.type==="devtools"&&r.enabled)&&v.push("import { devtools } from 'zustand/middleware'"),i.middleware?.some(r=>r.type==="persist"&&r.enabled)&&v.push("import { persist } from 'zustand/middleware'"),i.middleware?.some(r=>r.type==="immer"&&r.enabled)&&v.push("import { immer } from 'zustand/middleware/immer'");const j=[];i.slices.forEach(r=>{j.push(`interface ${ae(r.name)}State {`),r.state.forEach(c=>{const w=se(c.type,c.nullable);j.push(` ${c.name}: ${w};`)}),j.push("}"),j.push("")}),j.push("interface Actions {"),i.slices.forEach(r=>{r.actions.forEach(c=>{const w=c.params.map($=>`${$.name}: ${se($.type)}`).join(", "),M=c.async?"Promise<void>":"void";j.push(` ${c.name}: (${w}) => ${M};`)})}),j.push("}");const y=i.slices.map(r=>`${ae(r.name)}State`).join(" & ");j.push(""),j.push(`type StoreState = ${y} & Actions;`);const z=[];i.slices.forEach(r=>{r.state.forEach(c=>{const w=c.defaultValue!==void 0?JSON.stringify(c.defaultValue):c.nullable?"null":xe(c.type);z.push(` ${c.name}: ${w},`)})});const b=[];i.slices.forEach(r=>{r.actions.forEach(c=>{const w=c.params.map($=>$.name).join(", "),M=c.async?"async ":"";b.push(` ${c.name}: ${M}(${w}) => {`),c.async?(b.push(" set({ loading: true, error: null });"),b.push(" try {"),b.push(" // TODO: API call"),b.push(` // const response = await api.${c.name}(${w});`),c.reducerSteps.forEach($=>{$.type==="set"&&b.push(` set({ ${$.field}: ${$.value} });`)}),b.push(" } catch (error) {"),b.push(" set({ error: error.message, loading: false });"),b.push(" }")):(b.push(" set((state) => {"),c.reducerSteps.forEach($=>{$.type==="set"?b.push(` state.${$.field} = ${$.value};`):$.type==="push"?b.push(` state.${$.field}.push(${$.value});`):$.type==="reset"&&b.push(` state.${$.field} = null;`)}),b.push(" });")),b.push(" },")})});let k="",l="";if(i.middleware?.some(r=>r.type==="immer"&&r.enabled)&&(k+="immer(",l=")"+l),i.middleware?.some(r=>r.type==="devtools"&&r.enabled)&&(k+="devtools(",l=`, { name: '${i.devtools?.name||i.name}' })`+l),i.persist?.enabled){k+="persist(";const r=[`name: '${i.persist.key}'`];i.persist.whitelist&&r.push(`partialize: (state) => ({ ${i.persist.whitelist.map(c=>c.split(".").pop()).join(", ")} })`),l=`, { ${r.join(", ")} })`+l}return`${v.join(`
12
+ `)}
13
+
14
+ // Types
15
+ ${j.join(`
16
+ `)}
17
+
18
+ // Store
19
+ export const use${i.name} = create<StoreState>()(
20
+ ${k}(set, get) => ({
21
+ // Initial State
22
+ ${z.join(`
23
+ `)}
24
+
25
+ // Actions
26
+ ${b.join(`
27
+ `)}
28
+ })${l}
29
+ );
30
+
31
+ // Selectors
32
+ ${i.slices.flatMap(r=>r.selectors.map(c=>`export const ${c.name} = (state: StoreState) => ${c.expression.replace("state.","state.")};`)).join(`
33
+ `)}
34
+ `},ae=i=>i.charAt(0).toUpperCase()+i.slice(1),se=(i,v)=>{const j={string:"string",number:"number",boolean:"boolean",array:"unknown[]",object:"Record<string, unknown>",date:"Date",enum:"string",custom:"unknown"}[i];return v?`${j} | null`:j},xe=i=>({string:"''",number:"0",boolean:"false",array:"[]",object:"{}",date:"new Date()",enum:"''",custom:"null"})[i],ge=({store:i=Re,templates:v=Be,onStoreChange:j,onExport:y,onSave:z,tutorial:b,className:k,style:l,"data-testid":N})=>{const[r,c]=f.useState(i),[w,M]=f.useState("slices"),[$,L]=f.useState(r.slices[0]?.id||null),[P,D]=f.useState(null),[R,J]=f.useState("zustand"),[H,q]=f.useState(!1),[u,I]=f.useState(null),[F,Y]=f.useState(""),[C,X]=f.useState("string"),T=f.useMemo(()=>r.slices.find(p=>p.id===$),[r.slices,$]),U=f.useCallback(p=>{const K={...r,...p};c(K),j?.(K)},[r,j]),m=()=>{const p={id:`slice-${Date.now()}`,name:"newSlice",state:[],actions:[],selectors:[]};U({slices:[...r.slices,p]}),L(p.id)},t=()=>{if(!T||!F)return;const p={id:`field-${Date.now()}`,name:F,type:C,defaultValue:xe(C).replace(/'/g,"")},K=r.slices.map(d=>d.id===T.id?{...d,state:[...d.state,p]}:d);U({slices:K}),Y("")},n=()=>{if(!T)return;const p={id:`action-${Date.now()}`,name:"newAction",params:[],reducerSteps:[]},K=r.slices.map(d=>d.id===T.id?{...d,actions:[...d.actions,p]}:d);U({slices:K}),D(p.id)},g=f.useCallback(()=>{let p="";R==="zustand"?p=oe(r):p=`// Export for ${R} coming soon...
35
+ // Store: ${r.name}`,y?.(p,R)},[r,R,y]),h=f.useMemo(()=>R==="zustand"?oe(r):`// ${R} export coming soon...`,[r,R]),o={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)"},S=e.jsxs("div",{style:{padding:"16px 20px",borderBottom:`1px solid ${o.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(s.NiceIcon,{name:"folder",size:16})," State Designer"]}),e.jsx("div",{style:{display:"flex",alignItems:"center",gap:8},children:e.jsx("input",{type:"text",value:r.name,onChange:p=>U({name:p.target.value}),style:{padding:"6px 12px",borderRadius:4,border:`1px solid ${o.border}`,background:o.cardBg,color:o.text,fontSize:14,fontWeight:600}})}),e.jsxs("div",{style:{marginLeft:"auto",display:"flex",gap:8,alignItems:"center"},children:[e.jsx(s.NiceTutorialButton,{steps:s.resolveTutorial(b,Ie)}),e.jsxs("button",{onClick:()=>q(!0),style:{padding:"8px 16px",borderRadius:6,border:`1px solid ${o.border}`,background:"transparent",color:o.text,cursor:"pointer",fontSize:13},children:[e.jsx(s.NiceIcon,{name:"clipboard",size:14})," Templates"]}),e.jsxs("button",{onClick:()=>z?.(r),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(s.NiceIcon,{name:"save",size:14})," Save"]})]})]}),a=e.jsx("div",{style:{display:"flex",borderBottom:`1px solid ${o.border}`,padding:"0 20px"},children:["slices","actions","selectors","settings","preview"].map(p=>e.jsxs("button",{onClick:()=>M(p),style:{padding:"12px 20px",border:"none",background:"transparent",color:w===p?o.text:o.textMuted,cursor:"pointer",fontSize:13,fontWeight:w===p?600:400,borderBottom:w===p?`2px solid ${o.accent}`:"2px solid transparent",marginBottom:-1},children:[p==="slices"&&e.jsxs(e.Fragment,{children:[e.jsx(s.NiceIcon,{name:"box",size:14})," Slices"]}),p==="actions"&&e.jsxs(e.Fragment,{children:[e.jsx(s.NiceIcon,{name:"zap",size:14})," Actions"]}),p==="selectors"&&e.jsxs(e.Fragment,{children:[e.jsx(s.NiceIcon,{name:"target",size:14})," Selectors"]}),p==="settings"&&e.jsxs(e.Fragment,{children:[e.jsx(s.NiceIcon,{name:"settings",size:14})," Settings"]}),p==="preview"&&e.jsxs(e.Fragment,{children:[e.jsx(s.NiceIcon,{name:"eye",size:14})," Preview"]})]},p))}),Z=w==="slices"||w==="actions"||w==="selectors"?e.jsxs("div",{style:{width:200,borderRight:`1px solid ${o.border}`,padding:12,display:"flex",flexDirection:"column",gap:8,height:"100%",boxSizing:"border-box"},children:[e.jsx("div",{style:{fontSize:11,color:o.textMuted,marginBottom:4},children:"SLICES"}),r.slices.map(p=>e.jsxs("button",{onClick:()=>L(p.id),style:{padding:"10px 12px",borderRadius:6,border:"none",background:$===p.id?o.accent+"30":o.cardBg,color:o.text,cursor:"pointer",textAlign:"left",fontSize:13},children:[e.jsx(s.NiceIcon,{name:"box",size:14})," ",p.name,e.jsxs("div",{style:{fontSize:10,color:o.textMuted},children:[p.state.length," fields • ",p.actions.length," actions"]})]},p.id)),e.jsx("button",{onClick:m,style:{padding:"10px 12px",borderRadius:6,border:`1px dashed ${o.border}`,background:"transparent",color:o.textMuted,cursor:"pointer",fontSize:13},children:"+ Add Slice"})]}):void 0;return e.jsxs(e.Fragment,{children:[e.jsx(ee.NiceAppShell,{flush:!0,className:`nice-state-designer ${k||""}`,style:{background:o.bg,color:o.text,fontFamily:"system-ui, sans-serif",...l},"data-testid":N,menubar:S,toolbar:a,sidebar:Z,children:e.jsxs("div",{style:{height:"100%",overflow:"auto",padding:20,boxSizing:"border-box"},children:[w==="slices"&&T&&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(s.NiceIcon,{name:"box",size:16})," ",T.name]}),e.jsx("input",{type:"text",value:T.name,onChange:p=>{const K=r.slices.map(d=>d.id===T.id?{...d,name:p.target.value}:d);U({slices:K})},style:{padding:"6px 12px",borderRadius:4,border:`1px solid ${o.border}`,background:o.cardBg,color:o.text,fontSize:13}})]}),e.jsxs("div",{style:{marginBottom:24},children:[e.jsxs("div",{style:{fontSize:12,color:o.textMuted,marginBottom:12},children:["STATE FIELDS (",T.state.length,")"]}),e.jsxs("div",{style:{border:`1px solid ${o.border}`,borderRadius:8,overflow:"hidden"},children:[T.state.map(p=>e.jsxs("div",{style:{padding:"12px 16px",borderBottom:`1px solid ${o.border}`,display:"flex",alignItems:"center",gap:12},children:[e.jsx(s.NiceIcon,{name:ie[p.type],size:14}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontWeight:500,fontFamily:"monospace"},children:p.name}),e.jsxs("div",{style:{fontSize:11,color:o.textMuted},children:[p.type,p.nullable&&"?",p.defaultValue!==void 0&&` = ${JSON.stringify(p.defaultValue)}`]})]}),e.jsx("button",{onClick:()=>{const K=r.slices.map(d=>d.id===T.id?{...d,state:d.state.filter(_=>_.id!==p.id)}:d);U({slices:K})},"aria-label":"Delete",style:{padding:4,border:"none",background:"transparent",color:"var(--nice-color-error, #ef4444)",cursor:"pointer",fontSize:14},children:e.jsx(s.NiceIcon,{name:"trash",size:14})})]},p.id)),e.jsxs("div",{style:{padding:"12px 16px",display:"flex",alignItems:"center",gap:8,background:o.cardBg},children:[e.jsx("input",{type:"text",placeholder:"fieldName",value:F,onChange:p=>Y(p.target.value),style:{flex:1,padding:"8px 12px",borderRadius:4,border:`1px solid ${o.border}`,background:o.bg,color:o.text,fontSize:13,fontFamily:"monospace"}}),e.jsx("select",{value:C,onChange:p=>X(p.target.value),style:{padding:"8px 12px",borderRadius:4,border:`1px solid ${o.border}`,background:o.bg,color:o.text,fontSize:13},children:Object.keys(ie).map(p=>e.jsx("option",{value:p,children:p},p))}),e.jsx("button",{onClick:t,disabled:!F,style:{padding:"8px 16px",borderRadius:4,border:"none",background:F?o.accent:o.border,color:"var(--nice-text-on-primary, #fff)",cursor:F?"pointer":"not-allowed",fontSize:13},children:"+ Add"})]})]})]})]}),w==="actions"&&T&&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(s.NiceIcon,{name:"zap",size:16})," Actions for ",T.name]}),e.jsx("button",{onClick:n,style:{padding:"6px 12px",borderRadius:4,border:"none",background:o.accent,color:"var(--nice-text-on-primary, #fff)",cursor:"pointer",fontSize:12},children:"+ Add Action"})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12},children:T.actions.map(p=>e.jsxs("div",{style:{padding:16,background:o.cardBg,borderRadius:8,border:`1px solid ${P===p.id?o.accent:o.border}`,cursor:"pointer"},onClick:()=>D(p.id),children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{fontWeight:600,fontFamily:"monospace"},children:p.name}),p.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:o.textMuted},children:["(",p.params.map(K=>`${K.name}: ${K.type}`).join(", "),")"]})]}),p.description&&e.jsx("div",{style:{fontSize:12,color:o.textMuted,marginTop:4},children:p.description}),e.jsxs("div",{style:{fontSize:11,color:o.textMuted,marginTop:8},children:[p.reducerSteps.length," reducer steps"]})]},p.id))})]}),w==="selectors"&&T&&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(s.NiceIcon,{name:"target",size:16})," Selectors for ",T.name]})}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12},children:T.selectors.map(p=>e.jsxs("div",{style:{padding:16,background:o.cardBg,borderRadius:8,border:`1px solid ${o.border}`},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{fontWeight:600,fontFamily:"monospace"},children:p.name}),p.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:o.bg,borderRadius:4,fontSize:12,color:"var(--nice-color-warning, #f59e0b)"},children:p.expression})]},p.id))})]}),w==="settings"&&e.jsxs("div",{style:{maxWidth:600},children:[e.jsx("h4",{style:{marginTop:0},children:"Middleware"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12,marginBottom:24},children:r.middleware?.map(p=>e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:12,padding:12,background:o.cardBg,borderRadius:8,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:p.enabled,onChange:K=>{const d=r.middleware?.map(_=>_.type===p.type?{..._,enabled:K.target.checked}:_);U({middleware:d})}}),e.jsxs("div",{children:[e.jsx("div",{style:{fontWeight:500,textTransform:"capitalize"},children:p.type}),e.jsxs("div",{style:{fontSize:11,color:o.textMuted},children:[p.type==="immer"&&"Enable immutable state updates",p.type==="devtools"&&"Redux DevTools integration",p.type==="persist"&&"Persist state to storage"]})]})]},p.type))}),r.persist?.enabled&&e.jsxs(e.Fragment,{children:[e.jsx("h4",{children:"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:o.textMuted,marginBottom:4},children:"Storage Key"}),e.jsx("input",{type:"text",value:r.persist.key,onChange:p=>U({persist:{...r.persist,key:p.target.value}}),style:{padding:"8px 12px",borderRadius:4,border:`1px solid ${o.border}`,background:o.cardBg,color:o.text,fontSize:13,width:"100%",boxSizing:"border-box"}})]}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:12,color:o.textMuted,marginBottom:4},children:"Storage Type"}),e.jsxs("select",{value:r.persist.storage,onChange:p=>U({persist:{...r.persist,storage:p.target.value}}),style:{padding:"8px 12px",borderRadius:4,border:`1px solid ${o.border}`,background:o.cardBg,color:o.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"})]})]})]})]})]}),w==="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:R,onChange:p=>J(p.target.value),style:{padding:"8px 12px",borderRadius:4,border:`1px solid ${o.border}`,background:o.cardBg,color:o.text,fontSize:13},children:[e.jsx("option",{value:"zustand",children:"Zustand"}),e.jsx("option",{value:"redux-toolkit",children:"Redux Toolkit"}),e.jsx("option",{value:"jotai",children:"Jotai"}),e.jsx("option",{value:"recoil",children:"Recoil"}),e.jsx("option",{value:"mobx",children:"MobX"})]}),e.jsxs("button",{onClick:g,style:{padding:"8px 16px",borderRadius:4,border:"none",background:o.accent,color:"var(--nice-text-on-primary, #fff)",cursor:"pointer",fontSize:13},children:[e.jsx(s.NiceIcon,{name:"upload",size:14})," Export"]}),e.jsxs("button",{onClick:()=>navigator.clipboard.writeText(h),style:{padding:"8px 16px",borderRadius:4,border:`1px solid ${o.border}`,background:"transparent",color:o.text,cursor:"pointer",fontSize:13},children:[e.jsx(s.NiceIcon,{name:"clipboard",size:14})," Copy"]})]}),e.jsx("pre",{style:{flex:1,padding:16,background:o.cardBg,borderRadius:8,overflow:"auto",fontSize:12,fontFamily:"JetBrains Mono, Consolas, monospace",margin:0,whiteSpace:"pre-wrap"},children:h})]})]})}),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:()=>q(!1),children:e.jsxs("div",{style:{background:o.cardBg,borderRadius:12,padding:24,width:500,maxHeight:"80vh",overflow:"auto"},onClick:p=>p.stopPropagation(),children:[e.jsxs("h4",{style:{margin:"0 0 16px",display:"inline-flex",alignItems:"center",gap:6},children:[e.jsx(s.NiceIcon,{name:"clipboard",size:16})," State Templates"]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12},children:v.map(p=>e.jsx("button",{onClick:()=>{p.store.slices&&U({slices:[...r.slices,...p.store.slices]}),q(!1)},style:{padding:16,borderRadius:8,border:`1px solid ${o.border}`,background:o.bg,color:o.text,cursor:"pointer",textAlign:"left"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(s.NiceIcon,{name:p.icon,size:24}),e.jsxs("div",{children:[e.jsx("div",{style:{fontWeight:600},children:p.name}),e.jsx("div",{style:{fontSize:12,color:o.textMuted},children:p.description})]})]})},p.id))})]})})]})},Ee=Object.freeze(Object.defineProperty({__proto__:null,NiceStateDesigner:ge},Symbol.toStringTag,{value:"Module"})),Me={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}},Q={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)"},De=i=>{const v=["import axios, { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios';"],j=[];i.endpoints.forEach(l=>{l.body?.schema&&j.push(`export interface ${te(l.name)}Request ${he(l.body.schema)}`),j.push(`export interface ${te(l.name)}Response {
36
+ // TODO: Define response type based on schema
37
+ data: unknown;
38
+ }`)});const y=[];i.endpoints.forEach(l=>{const N=l.pathParams?.map(P=>`${P.name}: ${P.type}`).join(", ")||"",r=l.queryParams?.length?`params?: { ${l.queryParams.map(P=>`${P.name}${P.required?"":"?"}: ${P.type}`).join("; ")} }`:"",c=l.body?`data: ${te(l.name)}Request`:"",w=[N,r,c].filter(Boolean).join(", ");let M=`'${l.path}'`;l.pathParams?.forEach(P=>{M=M.replace(`{${P.name}}`,`\${${P.name}}`)}),l.pathParams?.length&&(M="`"+M.slice(1,-1)+"`");const $=l.cache?.enabled?`
39
+ // Cache: ${l.cache.strategy}, TTL: ${l.cache.ttl}s`:"",L=l.retry?.enabled?`
40
+ // Retry: ${l.retry.maxAttempts} attempts, ${l.retry.backoff} backoff`:"";y.push(`
41
+ /**
42
+ * ${l.description||l.name}${$}${L}
43
+ */
44
+ async ${l.name}(${w}): Promise<${te(l.name)}Response> {
45
+ const response = await this.client.${l.method.toLowerCase()}<${te(l.name)}Response>(
46
+ ${M}${l.queryParams?.length?", { params }":""}${l.body?", data":""}
47
+ );
48
+ return response.data;
49
+ }`)});let z="";i.auth?.type==="bearer"&&(z=`
50
+ // Auth interceptor
51
+ this.client.interceptors.request.use((config) => {
52
+ const token = ${i.auth.tokenSource||"getToken()"};
53
+ if (token) {
54
+ config.headers['${i.auth.headerName||"Authorization"}'] = '${i.auth.prefix||"Bearer"} ' + token;
55
+ }
56
+ return config;
57
+ });`);const b=i.errorHandling?.globalErrorHandler?`
58
+ // Error interceptor
59
+ this.client.interceptors.response.use(
60
+ (response) => response,
61
+ (error) => {
62
+ // Transform and handle errors
63
+ const message = error.response?.data?.message || error.message;
64
+ console.error('[API Error]', message);
65
+ return Promise.reject(error);
66
+ }
67
+ );`:"";return`${v.join(`
68
+ `)}
69
+
70
+ // Types
71
+ ${j.join(`
72
+
73
+ `)}
74
+
75
+ // API Client
76
+ export class ${i.name} {
77
+ private client: AxiosInstance;
78
+
79
+ constructor(baseURL: string = '${i.baseUrl}') {
80
+ this.client = axios.create({
81
+ baseURL,
82
+ headers: ${JSON.stringify(i.globalHeaders||{},null,8).replace(/\n/g,`
83
+ `)},
84
+ });
85
+ ${z}${b}
86
+ }
87
+ ${y.join("")}
88
+ }
89
+
90
+ // Default instance
91
+ export const ${i.name.charAt(0).toLowerCase()+i.name.slice(1)} = new ${i.name}();
92
+ `},te=i=>i.charAt(0).toUpperCase()+i.slice(1),he=i=>i.type==="object"&&i.properties?`{
93
+ ${Object.entries(i.properties).map(([j,y])=>{const z=i.required?.includes(j)?"":"?";return` ${j}${z}: ${ye(y)};`}).join(`
94
+ `)}
95
+ }`:"{}",ye=i=>{switch(i.type){case"string":return"string";case"number":return"number";case"boolean":return"boolean";case"array":return i.items?`${ye(i.items)}[]`:"unknown[]";case"object":return i.properties?he(i):"Record<string, unknown>";default:return"unknown"}},fe=({flow:i=Me,dataSources:v=[],onFlowChange:j,onExport:y,onTest:z,onSave:b,className:k,style:l,"data-testid":N})=>{const[r,c]=f.useState(i),[w,M]=f.useState("endpoints"),[$,L]=f.useState(r.endpoints[0]?.id||null),[P,D]=f.useState(!1),[R,J]=f.useState(null),[H,q]=f.useState(!1),u=f.useMemo(()=>r.endpoints.find(t=>t.id===$),[r.endpoints,$]),I=f.useCallback(t=>{const n={...r,...t};c(n),j?.(n)},[r,j]),F=f.useCallback((t,n)=>{const g=r.endpoints.map(h=>h.id===t?{...h,...n}:h);I({endpoints:g})},[r.endpoints,I]),Y=t=>{const n={id:`ep-${Date.now()}`,name:"newEndpoint",method:t,path:"/new-path",responses:[{status:200,description:"Success"}]};I({endpoints:[...r.endpoints,n]}),L(n.id),D(!1)},C=t=>{I({endpoints:r.endpoints.filter(n=>n.id!==t)}),$===t&&L(r.endpoints[0]?.id||null)},X=async()=>{u&&(q(!0),J(null),await new Promise(t=>setTimeout(t,1e3)),J({status:200,body:{message:"Mock response",timestamp:new Date().toISOString()}}),q(!1),z?.(u.id))},T=f.useMemo(()=>De(r),[r]),U=()=>{y?.(T)};f.useMemo(()=>{const t=new Set;return r.endpoints.forEach(n=>n.tags?.forEach(g=>t.add(g))),Array.from(t)},[r.endpoints]);const m={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:m.bg,color:m.text,fontFamily:"system-ui, sans-serif",...l},"data-testid":N,children:[e.jsxs("div",{style:{padding:"16px 20px",borderBottom:`1px solid ${m.border}`,display:"flex",alignItems:"center",gap:16},children:[e.jsxs("h3",{style:{margin:0,fontSize:18},children:[e.jsx(s.NiceIcon,{name:"plug",size:16})," API Flow"]}),e.jsx("input",{type:"text",value:r.name,onChange:t=>I({name:t.target.value}),style:{padding:"6px 12px",borderRadius:4,border:`1px solid ${m.border}`,background:m.cardBg,color:m.text,fontSize:14,fontWeight:600}}),e.jsx("input",{type:"text",value:r.baseUrl,onChange:t=>I({baseUrl:t.target.value}),placeholder:"Base URL",style:{padding:"6px 12px",borderRadius:4,border:`1px solid ${m.border}`,background:m.cardBg,color:m.text,fontSize:13,width:300}}),e.jsx("div",{style:{marginLeft:"auto",display:"flex",gap:8},children:e.jsxs("button",{onClick:()=>b?.(r),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(s.NiceIcon,{name:"save",size:14})," Save"]})})]}),e.jsx("div",{style:{display:"flex",borderBottom:`1px solid ${m.border}`,padding:"0 20px"},children:["endpoints","auth","settings","test","preview"].map(t=>e.jsxs("button",{onClick:()=>M(t),style:{padding:"12px 20px",border:"none",background:"transparent",color:w===t?m.text:m.textMuted,cursor:"pointer",fontSize:13,fontWeight:w===t?600:400,borderBottom:w===t?`2px solid ${m.accent}`:"2px solid transparent",marginBottom:-1},children:[t==="endpoints"&&e.jsxs(e.Fragment,{children:[e.jsx(s.NiceIcon,{name:"link",size:14})," Endpoints"]}),t==="auth"&&e.jsxs(e.Fragment,{children:[e.jsx(s.NiceIcon,{name:"lock",size:14})," Auth"]}),t==="settings"&&e.jsxs(e.Fragment,{children:[e.jsx(s.NiceIcon,{name:"settings",size:14})," Settings"]}),t==="test"&&e.jsxs(e.Fragment,{children:[e.jsx(s.NiceIcon,{name:"flask",size:14})," Test"]}),t==="preview"&&e.jsxs(e.Fragment,{children:[e.jsx(s.NiceIcon,{name:"eye",size:14})," Preview"]})]},t))}),e.jsxs("div",{style:{flex:1,display:"flex",overflow:"hidden"},children:[w==="endpoints"&&e.jsxs("div",{style:{width:280,borderRight:`1px solid ${m.border}`,padding:12,display:"flex",flexDirection:"column",gap:4,overflow:"auto"},children:[e.jsxs("div",{style:{fontSize:11,color:m.textMuted,marginBottom:8},children:["ENDPOINTS (",r.endpoints.length,")"]}),r.endpoints.map(t=>e.jsxs("button",{onClick:()=>L(t.id),style:{padding:"10px 12px",borderRadius:6,border:"none",background:$===t.id?m.accent+"30":m.cardBg,color:m.text,cursor:"pointer",textAlign:"left",display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{padding:"2px 6px",borderRadius:4,background:Q[t.method]+"30",color:Q[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:m.textMuted,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:t.path})]})]},t.id)),e.jsx("button",{onClick:()=>D(!0),style:{padding:"10px 12px",borderRadius:6,border:`1px dashed ${m.border}`,background:"transparent",color:m.textMuted,cursor:"pointer",fontSize:13,marginTop:8},children:"+ Add Endpoint"})]}),e.jsxs("div",{style:{flex:1,overflow:"auto",padding:20},children:[w==="endpoints"&&u&&e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,marginBottom:24},children:[e.jsx("select",{value:u.method,onChange:t=>F(u.id,{method:t.target.value}),style:{padding:"8px 12px",borderRadius:6,border:"none",background:Q[u.method]+"30",color:Q[u.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:u.path,onChange:t=>F(u.id,{path:t.target.value}),style:{flex:1,padding:"8px 12px",borderRadius:6,border:`1px solid ${m.border}`,background:m.cardBg,color:m.text,fontSize:14,fontFamily:"monospace"}}),e.jsxs("button",{onClick:()=>C(u.id),style:{padding:"8px 12px",borderRadius:6,border:`1px solid ${m.border}`,background:"transparent",color:"var(--nice-color-error, #ef4444)",cursor:"pointer",fontSize:13},children:[e.jsx(s.NiceIcon,{name:"trash",size:14})," 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:m.textMuted,marginBottom:4},children:"Name"}),e.jsx("input",{type:"text",value:u.name,onChange:t=>F(u.id,{name:t.target.value}),style:{width:"100%",padding:"8px 12px",borderRadius:6,border:`1px solid ${m.border}`,background:m.cardBg,color:m.text,fontSize:13,fontFamily:"monospace",boxSizing:"border-box"}})]}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:12,color:m.textMuted,marginBottom:4},children:"Description"}),e.jsx("input",{type:"text",value:u.description||"",onChange:t=>F(u.id,{description:t.target.value}),style:{width:"100%",padding:"8px 12px",borderRadius:6,border:`1px solid ${m.border}`,background:m.cardBg,color:m.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(s.NiceIcon,{name:"clipboard",size:14})," Parameters"]}),u.pathParams&&u.pathParams.length>0&&e.jsxs("div",{style:{marginBottom:16},children:[e.jsx("div",{style:{fontSize:11,color:m.textMuted,marginBottom:8},children:"PATH PARAMETERS"}),u.pathParams.map(t=>e.jsxs("div",{style:{padding:12,background:m.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:m.textMuted,fontSize:12},children:t.type}),t.required&&e.jsx("span",{style:{color:"var(--nice-color-error, #ef4444)",fontSize:10},children:"required"})]},t.id))]}),u.queryParams&&u.queryParams.length>0&&e.jsxs("div",{style:{marginBottom:16},children:[e.jsx("div",{style:{fontSize:11,color:m.textMuted,marginBottom:8},children:"QUERY PARAMETERS"}),u.queryParams.map(t=>e.jsxs("div",{style:{padding:12,background:m.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:m.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))]}),u.body&&e.jsxs("div",{style:{marginBottom:16},children:[e.jsx("div",{style:{fontSize:11,color:m.textMuted,marginBottom:8},children:"REQUEST BODY"}),e.jsxs("div",{style:{padding:12,background:m.cardBg,borderRadius:6},children:[e.jsxs("div",{style:{fontSize:12,marginBottom:8},children:["Content-Type: ",e.jsx("code",{children:u.body.contentType})]}),u.body.schema&&e.jsx("pre",{style:{margin:0,padding:12,background:m.bg,borderRadius:4,fontSize:11,overflow:"auto"},children:JSON.stringify(u.body.schema,null,2)})]})]})]}),e.jsxs("div",{style:{marginBottom:24},children:[e.jsxs("h4",{style:{margin:"0 0 12px"},children:[e.jsx(s.NiceIcon,{name:"upload",size:16})," Responses"]}),e.jsx("div",{style:{display:"flex",gap:12,flexWrap:"wrap"},children:u.responses.map(t=>e.jsxs("div",{style:{padding:12,background:m.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:m.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:m.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:u.cache?.enabled||!1,onChange:t=>F(u.id,{cache:{...u.cache,enabled:t.target.checked}})}),e.jsx(s.NiceIcon,{name:"box",size:14})," Cache"]}),u.cache?.enabled&&e.jsxs("div",{style:{fontSize:12,color:m.textMuted},children:["TTL: ",u.cache.ttl,"s • Strategy: ",u.cache.strategy]})]}),e.jsxs("div",{style:{padding:16,background:m.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:u.retry?.enabled||!1,onChange:t=>F(u.id,{retry:{...u.retry,enabled:t.target.checked,maxAttempts:3,backoff:"exponential"}})}),e.jsx(s.NiceIcon,{name:"refresh",size:14})," Retry"]}),u.retry?.enabled&&e.jsxs("div",{style:{fontSize:12,color:m.textMuted},children:["Max: ",u.retry.maxAttempts," • ",u.retry.backoff," ","backoff"]})]})]})]}),w==="auth"&&e.jsxs("div",{style:{maxWidth:500},children:[e.jsxs("h4",{style:{marginTop:0},children:[e.jsx(s.NiceIcon,{name:"lock",size:16})," Authentication"]}),e.jsxs("div",{style:{marginBottom:24},children:[e.jsx("label",{style:{display:"block",fontSize:12,color:m.textMuted,marginBottom:8},children:"Auth Type"}),e.jsxs("select",{value:r.auth?.type||"none",onChange:t=>I({auth:{...r.auth,type:t.target.value}}),style:{padding:"10px 12px",borderRadius:6,border:`1px solid ${m.border}`,background:m.cardBg,color:m.text,fontSize:13,width:"100%"},children:[e.jsx("option",{value:"none",children:"None"}),e.jsx("option",{value:"bearer",children:"Bearer Token"}),e.jsx("option",{value:"basic",children:"Basic Auth"}),e.jsx("option",{value:"api-key",children:"API Key"}),e.jsx("option",{value:"oauth2",children:"OAuth 2.0"})]})]}),r.auth?.type==="bearer"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{marginBottom:16},children:[e.jsx("label",{style:{display:"block",fontSize:12,color:m.textMuted,marginBottom:8},children:"Token Source"}),e.jsx("input",{type:"text",value:r.auth.tokenSource||"",onChange:t=>I({auth:{...r.auth,tokenSource:t.target.value}}),placeholder:"state.auth.token",style:{width:"100%",padding:"10px 12px",borderRadius:6,border:`1px solid ${m.border}`,background:m.cardBg,color:m.text,fontSize:13,fontFamily:"monospace",boxSizing:"border-box"}})]}),e.jsxs("div",{style:{marginBottom:16},children:[e.jsx("label",{style:{display:"block",fontSize:12,color:m.textMuted,marginBottom:8},children:"Header Name"}),e.jsx("input",{type:"text",value:r.auth.headerName||"Authorization",onChange:t=>I({auth:{...r.auth,headerName:t.target.value}}),style:{width:"100%",padding:"10px 12px",borderRadius:6,border:`1px solid ${m.border}`,background:m.cardBg,color:m.text,fontSize:13,boxSizing:"border-box"}})]})]}),e.jsxs("h4",{children:[e.jsx(s.NiceIcon,{name:"globe",size:16})," Global Headers"]}),e.jsx("div",{style:{padding:16,background:m.cardBg,borderRadius:8},children:Object.entries(r.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:m.textMuted},children:":"}),e.jsx("code",{style:{flex:2,color:"var(--nice-color-success, #22c55e)"},children:n})]},t))})]}),w==="settings"&&e.jsxs("div",{style:{maxWidth:500},children:[e.jsxs("h4",{style:{marginTop:0},children:[e.jsx(s.NiceIcon,{name:"settings",size:16})," Global Settings"]}),e.jsxs("div",{style:{marginBottom:24},children:[e.jsx("h5",{children:"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:r.errorHandling?.globalErrorHandler||!1,onChange:t=>I({errorHandling:{...r.errorHandling,globalErrorHandler:t.target.checked}})}),"Global error handler"]}),e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:12,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:r.errorHandling?.retryOnNetworkError||!1,onChange:t=>I({errorHandling:{...r.errorHandling,retryOnNetworkError:t.target.checked}})}),"Retry on network errors"]}),e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:12,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:r.errorHandling?.transformError||!1,onChange:t=>I({errorHandling:{...r.errorHandling,transformError:t.target.checked}})}),"Transform error responses"]})]})]}),e.jsxs("div",{style:{marginBottom:24},children:[e.jsx("h5",{children:"Default Cache Settings"}),e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:12,marginBottom:12,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:r.cacheConfig?.enabled||!1,onChange:t=>I({cacheConfig:{...r.cacheConfig,enabled:t.target.checked}})}),"Enable caching"]}),r.cacheConfig?.enabled&&e.jsxs("div",{style:{display:"flex",gap:16},children:[e.jsxs("div",{children:[e.jsx("label",{style:{fontSize:12,color:m.textMuted},children:"Storage"}),e.jsxs("select",{value:r.cacheConfig.storage,onChange:t=>I({cacheConfig:{...r.cacheConfig,storage:t.target.value}}),style:{display:"block",marginTop:4,padding:"8px 12px",borderRadius:4,border:`1px solid ${m.border}`,background:m.cardBg,color:m.text,fontSize:13},children:[e.jsx("option",{value:"memory",children:"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:m.textMuted},children:"Default TTL (seconds)"}),e.jsx("input",{type:"number",value:r.cacheConfig.defaultTTL,onChange:t=>I({cacheConfig:{...r.cacheConfig,defaultTTL:parseInt(t.target.value)}}),style:{display:"block",marginTop:4,padding:"8px 12px",borderRadius:4,border:`1px solid ${m.border}`,background:m.cardBg,color:m.text,fontSize:13,width:100}})]})]})]})]}),w==="test"&&u&&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:Q[u.method]+"30",color:Q[u.method],fontSize:12,fontWeight:600},children:u.method}),e.jsxs("code",{style:{flex:1,fontSize:14},children:[r.baseUrl,u.path]}),e.jsx("button",{onClick:X,disabled:H,style:{padding:"10px 20px",borderRadius:6,border:"none",background:m.accent,color:"var(--nice-text-on-primary, #fff)",cursor:H?"not-allowed":"pointer",fontSize:13,fontWeight:500,opacity:H?.7:1},children:H?e.jsxs(e.Fragment,{children:[e.jsx(s.NiceIcon,{name:"clock",size:14})," Testing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(s.NiceIcon,{name:"rocket",size:14})," Send Request"]})})]}),R&&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:R.status<300?"var(--nice-color-success, #22c55e)":"var(--nice-color-error, #ef4444)"},children:R.status}),e.jsx("span",{style:{color:m.textMuted},children:R.status<300?"OK":"Error"})]}),e.jsx("pre",{style:{padding:16,background:m.cardBg,borderRadius:8,overflow:"auto",fontSize:12,fontFamily:"JetBrains Mono, Consolas, monospace",margin:0},children:JSON.stringify(R.body,null,2)})]})]}),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:U,style:{padding:"8px 16px",borderRadius:4,border:"none",background:m.accent,color:"var(--nice-text-on-primary, #fff)",cursor:"pointer",fontSize:13},children:[e.jsx(s.NiceIcon,{name:"upload",size:14})," Export"]}),e.jsxs("button",{onClick:()=>navigator.clipboard.writeText(T),style:{padding:"8px 16px",borderRadius:4,border:`1px solid ${m.border}`,background:"transparent",color:m.text,cursor:"pointer",fontSize:13},children:[e.jsx(s.NiceIcon,{name:"clipboard",size:14})," Copy"]})]}),e.jsx("pre",{style:{flex:1,padding:16,background:m.cardBg,borderRadius:8,overflow:"auto",fontSize:12,fontFamily:"JetBrains Mono, Consolas, monospace",margin:0,whiteSpace:"pre-wrap"},children:T})]})]})]}),P&&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:()=>D(!1),children:e.jsxs("div",{style:{background:m.cardBg,borderRadius:12,padding:24,width:400},onClick:t=>t.stopPropagation(),children:[e.jsxs("h4",{style:{margin:"0 0 16px"},children:[e.jsx(s.NiceIcon,{name:"plus",size:16})," Add Endpoint"]}),e.jsx("p",{style:{color:m.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:Q[t]+"30",color:Q[t],cursor:"pointer",fontSize:14,fontWeight:600},children:t},t))})]})})]})},Fe=Object.freeze(Object.defineProperty({__proto__:null,NiceAPIFlow:fe},Symbol.toStringTag,{value:"Module"})),Ae={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)"},le={string:"edit",number:"hash",boolean:"check",date:"calendar",array:"clipboard",object:"box",any:"help"},ce={direct:"arrow-right",format:"edit",convert:"refresh",concat:"link",split:"shuffle",calculate:"hash",lookup:"search",conditional:"help",custom:"settings"},Pe=i=>{const v=pe(i.sourceSchema),j=pe(i.targetSchema),y=i.fieldMappings.map(b=>{const k=i.transformations.find(r=>r.id===b.transform),l=b.targetField;if(!b.sourceField)return` result.${l} = ${JSON.stringify(b.defaultValue)};`;const N=b.sourceField.split(",").map(r=>r.trim());if(k)switch(k.type){case"concat":return` result.${l} = [${N.map(r=>`source.${r}`).join(", ")}].filter(Boolean).join('${k.config.separator||" "}');`;case"format":if(N.length===1){const r=k.config.format||"{value}";return r.includes("{value}")?` result.${l} = '${r}'.replace('{value}', String(source.${N[0]}));`:` result.${l} = formatDate(source.${N[0]}, '${r}');`}break;case"custom":return` result.${l} = ${k.config.expression?.replace(/(\w+)\.(\w+)/g,"source.$1.$2")};`;case"convert":return` result.${l} = ${k.config.convertTo}(source.${N[0]});`}if(N.length===1){const r=b.defaultValue!==void 0?` ?? ${JSON.stringify(b.defaultValue)}`:"";return` result.${l} = source.${N[0]}${r};`}return` // TODO: Manual mapping for ${l}`}),z=i.validationRules.map(b=>{switch(b.type){case"required":return` if (!data.${b.field}) errors.push('${b.message||b.field+" is required"}');`;case"pattern":return` if (data.${b.field} && !/${b.value}/.test(data.${b.field})) errors.push('${b.message||"Invalid format"}');`;default:return` // ${b.type} validation for ${b.field}`}});return`/**
96
+ * ${i.name}
97
+ * ${i.description||""}
98
+ * Auto-generated by NiceDataMapper
99
+ */
100
+
101
+ // Source Type
102
+ ${v}
103
+
104
+ // Target Type
105
+ ${j}
106
+
107
+ // Validation
108
+ export function validate${i.targetSchema.name}(data: ${i.targetSchema.name}): string[] {
109
+ const errors: string[] = [];
110
+ ${z.join(`
111
+ `)}
112
+ return errors;
113
+ }
114
+
115
+ // Mapper
116
+ export function ${i.name.charAt(0).toLowerCase()+i.name.slice(1)}(source: ${i.sourceSchema.name}): ${i.targetSchema.name} {
117
+ const result = {} as ${i.targetSchema.name};
118
+
119
+ ${y.join(`
120
+ `)}
121
+
122
+ return result;
123
+ }
124
+
125
+ // Helper functions
126
+ function formatDate(date: string | Date, format: string): string {
127
+ const d = typeof date === 'string' ? new Date(date) : date;
128
+ const year = d.getFullYear();
129
+ const month = String(d.getMonth() + 1).padStart(2, '0');
130
+ const day = String(d.getDate()).padStart(2, '0');
131
+ return format
132
+ .replace('YYYY', String(year))
133
+ .replace('MM', month)
134
+ .replace('DD', day);
135
+ }
136
+ `},pe=(i,v)=>{const j=(z,b)=>{const k=" ".repeat(b),l=z.nullable?"?":"";if(z.type==="object"&&z.children){const r=z.children.map(c=>j(c,b+1)).join(`
137
+ `);return`${k}${z.name}${l}: {
138
+ ${r}
139
+ ${k}};`}const N={string:"string",number:"number",boolean:"boolean",date:"string | Date",array:"unknown[]",object:"Record<string, unknown>",any:"unknown"}[z.type];return`${k}${z.name}${l}: ${N};`},y=i.fields.map(z=>j(z,1)).join(`
140
+ `);return`interface ${i.name} {
141
+ ${y}
142
+ }`},be=({mapping:i=Ae,sourceSchemas:v=[],targetSchemas:j=[],onMappingChange:y,onExport:z,onTest:b,onSave:k,className:l,style:N,"data-testid":r})=>{const[c,w]=f.useState(i),[M,$]=f.useState("mapping"),[L,P]=f.useState(null),[D,R]=f.useState(""),[J,H]=f.useState(""),[q,u]=f.useState(null),I=f.useCallback(n=>{const g={...c,...n};w(g),y?.(g)},[c,y]),F=(n,g="")=>{const h=[];return n.forEach(o=>{h.push(o),o.children&&h.push(...F(o.children,o.path+"."))}),h},Y=f.useMemo(()=>F(c.sourceSchema.fields),[c.sourceSchema.fields]),C=f.useMemo(()=>F(c.targetSchema.fields),[c.targetSchema.fields]),X=(n,g)=>{const h={id:`mapping-${Date.now()}`,sourceField:n,targetField:g};I({fieldMappings:[...c.fieldMappings,h]})},T=n=>{I({fieldMappings:c.fieldMappings.filter(g=>g.id!==n)})},U=()=>{try{const n=JSON.parse(D),g={};c.fieldMappings.forEach(h=>{if(!h.sourceField){g[h.targetField]=h.defaultValue;return}const o=h.sourceField.split(",").map(G=>G.trim()),S=G=>G.split(".").reduce((Z,p)=>Z?.[p],n),a=c.transformations.find(G=>G.id===h.transform);if(a?.type==="concat")g[h.targetField]=o.map(S).filter(Boolean).join(a.config.separator||" ");else if(a?.type==="format"&&o.length===1){const G=S(o[0]);g[h.targetField]=(a.config.format||"{value}").replace("{value}",String(G))}else o.length===1&&(g[h.targetField]=S(o[0])??h.defaultValue)}),H(JSON.stringify(g,null,2)),b?.(g)}catch(n){H(`Error: ${n.message}`)}},m=f.useMemo(()=>Pe(c),[c]),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 ${l||""}`,style:{display:"flex",flexDirection:"column",height:"100%",background:t.bg,color:t.text,fontFamily:"system-ui, sans-serif",...N},"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(s.NiceIcon,{name:"refresh",size:16})," Data Mapper"]}),e.jsx("input",{type:"text",value:c.name,onChange:n=>I({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?.(c),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(s.NiceIcon,{name:"save",size:14})," 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:()=>$(n),style:{padding:"12px 20px",border:"none",background:"transparent",color:M===n?t.text:t.textMuted,cursor:"pointer",fontSize:13,fontWeight:M===n?600:400,borderBottom:M===n?`2px solid ${t.accent}`:"2px solid transparent",marginBottom:-1},children:[n==="mapping"&&e.jsxs(e.Fragment,{children:[e.jsx(s.NiceIcon,{name:"link",size:14})," Mapping"]}),n==="transforms"&&e.jsxs(e.Fragment,{children:[e.jsx(s.NiceIcon,{name:"zap",size:14})," Transforms"]}),n==="validation"&&e.jsxs(e.Fragment,{children:[e.jsx(s.NiceIcon,{name:"check",size:14})," Validation"]}),n==="test"&&e.jsxs(e.Fragment,{children:[e.jsx(s.NiceIcon,{name:"flask",size:14})," Test"]}),n==="preview"&&e.jsxs(e.Fragment,{children:[e.jsx(s.NiceIcon,{name:"eye",size:14})," Preview"]})]},n))}),e.jsxs("div",{style:{flex:1,overflow:"auto",padding:20},children:[M==="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(s.NiceIcon,{name:"download",size:14})," Source: ",c.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,h=c.fieldMappings.some(o=>o.sourceField.split(",").some(S=>S.trim()===n.path));return e.jsxs("div",{draggable:!0,onDragStart:()=>u(n.path),onDragEnd:()=>u(null),style:{padding:"10px 12px",paddingLeft:12+g*16,borderBottom:`1px solid ${t.border}`,display:"flex",alignItems:"center",gap:8,cursor:"grab",background:h?"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(s.NiceIcon,{name:le[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}),h&&e.jsx("span",{style:{marginLeft:"auto",color:"var(--nice-color-success, #22c55e)",fontSize:10},children:e.jsx(s.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(s.NiceIcon,{name:"link",size:16})," Mappings (",c.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:c.fieldMappings.map(n=>{const g=c.transformations.find(h=>h.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("code",{style:{color:"var(--nice-color-primary, #3b82f6)"},children:n.targetField}),e.jsx("button",{onClick:()=>T(n.id),"aria-label":"Remove mapping",style:{marginLeft:"auto",padding:2,border:"none",background:"transparent",color:"var(--nice-color-error, #ef4444)",cursor:"pointer",fontSize:10},children:e.jsx(s.NiceIcon,{name:"close",size:14})})]}),g&&e.jsxs("div",{style:{color:t.textMuted,display:"flex",alignItems:"center",gap:4},children:[e.jsx(s.NiceIcon,{name:ce[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(s.NiceIcon,{name:"upload",size:14})," Target: ",c.targetSchema.name]}),e.jsx("div",{style:{flex:1,border:`1px solid ${t.border}`,borderTop:"none",borderRadius:"0 0 8px 8px",overflow:"auto"},children:C.map(n=>{const g=n.path.split(".").length-1,h=c.fieldMappings.some(o=>o.targetField===n.path);return e.jsxs("div",{onDragOver:o=>o.preventDefault(),onDrop:()=>{q&&!h&&X(q,n.path)},style:{padding:"10px 12px",paddingLeft:12+g*16,borderBottom:`1px solid ${t.border}`,display:"flex",alignItems:"center",gap:8,background:q&&!h?t.accent+"10":h?"#3b82f610":"transparent",transition:"background 0.15s"},children:[e.jsx("span",{style:{color:de[n.type],fontSize:14},children:e.jsx(s.NiceIcon,{name:le[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:"?"}),h&&e.jsx("span",{style:{marginLeft:"auto",color:"var(--nice-color-primary, #3b82f6)",fontSize:10},children:e.jsx(s.NiceIcon,{name:"check",size:14})})]},n.id)})})]})]}),M==="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(s.NiceIcon,{name:"zap",size:16})," Transformations"]}),e.jsx("button",{onClick:()=>{const n={id:`tr-${Date.now()}`,name:"New Transform",type:"direct",config:{}};I({transformations:[...c.transformations,n]})},style:{padding:"6px 12px",borderRadius:4,border:"none",background:t.accent,color:"var(--nice-text-on-primary, #fff)",cursor:"pointer",fontSize:12},children:"+ Add Transform"})]}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(300px, 1fr))",gap:16},children:c.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(s.NiceIcon,{name:ce[n.type],size:20})}),e.jsx("input",{type:"text",value:n.name,onChange:g=>{const h=c.transformations.map(o=>o.id===n.id?{...o,name:g.target.value}:o);I({transformations:h})},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:"Type"}),e.jsxs("select",{value:n.type,onChange:g=>{const h=c.transformations.map(o=>o.id===n.id?{...o,type:g.target.value}:o);I({transformations:h})},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:"Direct"}),e.jsx("option",{value:"format",children:"Format"}),e.jsx("option",{value:"convert",children:"Convert"}),e.jsx("option",{value:"concat",children:"Concatenate"}),e.jsx("option",{value:"split",children:"Split"}),e.jsx("option",{value:"calculate",children:"Calculate"}),e.jsx("option",{value:"lookup",children:"Lookup"}),e.jsx("option",{value:"conditional",children:"Conditional"}),e.jsx("option",{value:"custom",children:"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 h=c.transformations.map(o=>o.id===n.id?{...o,config:{...o.config,[n.type==="format"?"format":"separator"]:g.target.value}}:o);I({transformations:h})},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:"Expression"}),e.jsx("textarea",{value:n.config.expression||"",onChange:g=>{const h=c.transformations.map(o=>o.id===n.id?{...o,config:{...o.config,expression:g.target.value}}:o);I({transformations:h})},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))})]}),M==="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(s.NiceIcon,{name:"check",size:16})," Validation Rules"]}),e.jsx("button",{onClick:()=>{const n={id:`v-${Date.now()}`,field:"",type:"required",message:""};I({validationRules:[...c.validationRules,n]})},style:{padding:"6px 12px",borderRadius:4,border:"none",background:t.accent,color:"var(--nice-text-on-primary, #fff)",cursor:"pointer",fontSize:12},children:"+ Add Rule"})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12},children:c.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 h=c.validationRules.map(o=>o.id===n.id?{...o,field:g.target.value}:o);I({validationRules:h})},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:"Select field..."}),C.map(g=>e.jsx("option",{value:g.path,children:g.path},g.id))]}),e.jsxs("select",{value:n.type,onChange:g=>{const h=c.validationRules.map(o=>o.id===n.id?{...o,type:g.target.value}:o);I({validationRules:h})},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:"Required"}),e.jsx("option",{value:"type",children:"Type"}),e.jsx("option",{value:"min",children:"Min"}),e.jsx("option",{value:"max",children:"Max"}),e.jsx("option",{value:"pattern",children:"Pattern"}),e.jsx("option",{value:"enum",children:"Enum"}),e.jsx("option",{value:"custom",children:"Custom"})]}),(n.type==="pattern"||n.type==="min"||n.type==="max")&&e.jsx("input",{type:"text",value:String(n.value||""),onChange:g=>{const h=c.validationRules.map(o=>o.id===n.id?{...o,value:g.target.value}:o);I({validationRules:h})},placeholder:"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 h=c.validationRules.map(o=>o.id===n.id?{...o,message:g.target.value}:o);I({validationRules:h})},placeholder:"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:()=>{I({validationRules:c.validationRules.filter(g=>g.id!==n.id)})},"aria-label":"Delete",style:{padding:6,border:"none",background:"transparent",color:"var(--nice-color-error, #ef4444)",cursor:"pointer",fontSize:14},children:e.jsx(s.NiceIcon,{name:"trash",size:14})})]},n.id))})]}),M==="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(s.NiceIcon,{name:"download",size:16})," Input"]}),e.jsx("button",{onClick:()=>{const n={},g=(h,o)=>{h.forEach(S=>{S.children&&S.type==="object"?(o[S.name]={},g(S.children,o[S.name])):o[S.name]={string:"sample",number:42,boolean:!0,date:new Date().toISOString(),array:[],object:{},any:null}[S.type]})};g(c.sourceSchema.fields,n),R(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:"Generate Sample"})]}),e.jsx("textarea",{value:D,onChange:n=>R(n.target.value),placeholder:"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(s.NiceIcon,{name:"upload",size:16})," Output"]}),e.jsxs("button",{onClick:U,style:{padding:"6px 16px",borderRadius:4,border:"none",background:t.accent,color:"var(--nice-text-on-primary, #fff)",cursor:"pointer",fontSize:12},children:[e.jsx(s.NiceIcon,{name:"refresh",size:14})," 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:J||"Run transform to see output"})]})]}),M==="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:()=>z?.(m),style:{padding:"8px 16px",borderRadius:4,border:"none",background:t.accent,color:"var(--nice-text-on-primary, #fff)",cursor:"pointer",fontSize:13},children:[e.jsx(s.NiceIcon,{name:"upload",size:14})," Export"]}),e.jsxs("button",{onClick:()=>navigator.clipboard.writeText(m),style:{padding:"8px 16px",borderRadius:4,border:`1px solid ${t.border}`,background:"transparent",color:t.text,cursor:"pointer",fontSize:13},children:[e.jsx(s.NiceIcon,{name:"clipboard",size:14})," 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:m})]})]})]})},_e=Object.freeze(Object.defineProperty({__proto__:null,NiceDataMapper:be},Symbol.toStringTag,{value:"Module"})),Oe=[{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}]}],Le=[{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"}]}],We=[{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"}}]}],qe=i=>{const v=i.filter(y=>y.enabled);return`/**
143
+ * Generated Event Orchestration
144
+ * @generated by NiceEventOrchestrator
145
+ */
146
+
147
+ import { createEventBus, EventHandler, EventSource } from '@nice2dev/events';
148
+
149
+ // Event Bus Instance
150
+ export const eventBus = createEventBus();
151
+
152
+ // Event Types
153
+ ${v.map(y=>`export type ${y.name.replace(/\s+/g,"")}Event = {
154
+ source: '${y.source.type}';
155
+ payload: unknown;
156
+ };`).join(`
157
+
158
+ `)}
159
+
160
+ // Event Handlers
161
+ ${v.map(y=>{const z=JSON.stringify(y.source.config,null,2),b=y.handlers.flatMap(k=>k.modifiers||[]).map(k=>`.${k.type}(${k.value})`).join("");return`
162
+ /**
163
+ * ${y.name}
164
+ * ${y.description||""}
165
+ */
166
+ export const ${y.name.replace(/\s+/g,"").toLowerCase()}Handler = eventBus
167
+ .on('${y.source.type}', ${z})${b}
168
+ .pipe(
169
+ ${y.handlers.map((k,l)=>` // Step ${l+1}: ${k.type}
170
+ async (event) => {
171
+ ${ue(k)}
172
+ },`).join(`
173
+ `)}
174
+ )
175
+ ${y.errorHandler?`.catch(async (error) => {
176
+ ${ue(y.errorHandler)}
177
+ })`:""};`}).join(`
178
+ `)}
179
+
180
+ // Initialize all handlers
181
+ export function initEventOrchestration() {
182
+ ${v.map(y=>` ${y.name.replace(/\s+/g,"").toLowerCase()}Handler.start();`).join(`
183
+ `)}
184
+ console.log('Event orchestration initialized');
185
+ }
186
+
187
+ // Cleanup
188
+ export function destroyEventOrchestration() {
189
+ ${v.map(y=>` ${y.name.replace(/\s+/g,"").toLowerCase()}Handler.stop();`).join(`
190
+ `)}
191
+ }
192
+ `},ue=i=>{switch(i.type){case"action":return`dispatch({ type: '${i.config.actionType}', payload: ${JSON.stringify(i.config.payload)} });`;case"transform":return`return (${i.config.expression})(event);`;case"dispatch":return`eventBus.emit('${i.config.eventName}', ${JSON.stringify(i.config.payload)});`;case"api-call":return`await fetch('${i.config.endpoint}', { method: '${i.config.method}', body: JSON.stringify(event.payload) });`;case"state-update":return`updateState('${i.config.path}', ${i.config.value});`;case"notification":return`showNotification({ type: '${i.config.type}', message: '${i.config.message}' });`;case"log":return`console.${i.config.level||"log"}('${i.config.message}', event);`;case"delay":return`await new Promise(r => setTimeout(r, ${i.config.duration}));`;case"branch":return`if (${i.config.condition}) { /* true branch */ } else { /* false branch */ }`;default:return"// Unknown handler type"}},ve=({flows:i=We,eventSources:v=Oe,eventHandlers:j=Le,onFlowsChange:y,onExport:z,onTest:b,className:k,style:l,"data-testid":N})=>{const[r,c]=f.useState(i),[w,M]=f.useState(r[0]?.id??null),[$,L]=f.useState("visual"),[P,D]=f.useState(!1),[R,J]=f.useState(""),[H,q]=f.useState(new Set),u=f.useMemo(()=>r.find(n=>n.id===w),[r,w]),I=f.useMemo(()=>qe(r),[r]),F=f.useCallback((n,g)=>{c(h=>{const o=h.map(S=>S.id===n?{...S,...g}:S);return y?.(o),o})},[y]),Y=()=>{if(!R.trim())return;const n={id:`flow-${Date.now()}`,name:R,enabled:!0,source:{id:`src-${Date.now()}`,type:"ui-event",config:{element:"",event:"click"}},handlers:[]};c(g=>{const h=[...g,n];return y?.(h),h}),M(n.id),D(!1),J("")},C=n=>{c(g=>{const h=g.filter(o=>o.id!==n);return y?.(h),h}),w===n&&M(r[0]?.id??null)},X=n=>{if(!u)return;const g=j.find(S=>S.type===n),h={};g?.configSchema.forEach(S=>{S.default!==void 0&&(h[S.name]=S.default)});const o={id:`handler-${Date.now()}`,type:n,config:h};F(u.id,{handlers:[...u.handlers,o]}),q(S=>new Set([...S,o.id]))},T=(n,g)=>{u&&F(u.id,{handlers:u.handlers.map(h=>h.id===n?{...h,...g}:h)})},U=n=>{u&&F(u.id,{handlers:u.handlers.filter(g=>g.id!==n)})},m=(n,g)=>{if(!u)return;const h=u.handlers.find(a=>a.id===n);if(!h)return;const S=h.modifiers?.find(a=>a.type===g)?h.modifiers?.filter(a=>a.type!==g):[...h.modifiers||[],{type:g,value:500,unit:"ms"}];T(n,{modifiers:S})},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",...l},"data-testid":N,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(s.NiceIcon,{name:"zap",size:16})," 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:()=>L(n),style:{padding:"6px 12px",border:"none",background:$===n?t.cardBg:"transparent",color:t.text,cursor:"pointer",fontSize:12,textTransform:"capitalize",display:"inline-flex",alignItems:"center",gap:6},children:[e.jsx(s.NiceIcon,{name:n==="visual"?"palette":n==="code"?"edit":"grid",size:14})," ",n]},n))}),e.jsxs("button",{onClick:()=>z?.(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,display:"inline-flex",alignItems:"center",gap:6},children:[e.jsx(s.NiceIcon,{name:"upload",size:14})," Export"]})]}),e.jsxs("div",{style:{flex:1,display:"flex",overflow:"hidden"},children:[($==="visual"||$==="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:"Event Flows"}),e.jsx("button",{onClick:()=>D(!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:[r.map(n=>{const g=v.find(h=>h.type===n.source.type);return e.jsxs("div",{onClick:()=>M(n.id),style:{padding:12,background:w===n.id?t.cardBg:"transparent",borderRadius:6,cursor:"pointer",marginBottom:4,border:`1px solid ${w===n.id?t.border:"transparent"}`,opacity:n.enabled?1:.5},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(s.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)}),P&&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:R,onChange:n=>J(n.target.value),placeholder:"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:()=>D(!1),style:{flex:1,padding:6,borderRadius:4,border:`1px solid ${t.border}`,background:"transparent",color:t.text,cursor:"pointer",fontSize:11},children:"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"})]})]})]})]}),($==="visual"||$==="split")&&u&&e.jsxs("div",{style:{flex:$==="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:u.name,onChange:n=>F(u.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:u.enabled,onChange:n=>F(u.id,{enabled:n.target.checked})}),e.jsx("span",{style:{fontSize:12},children:"Enabled"})]}),e.jsxs("button",{onClick:()=>b?.(u.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(s.NiceIcon,{name:"play",size:14})," Test"]}),e.jsx("button",{onClick:()=>C(u.id),"aria-label":"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(s.NiceIcon,{name:"trash",size:14})})]}),e.jsxs("div",{style:{padding:16,background:t.cardBg,borderRadius:8,marginBottom:16,borderLeft:`4px solid ${v.find(n=>n.type===u.source.type)?.color??"var(--nice-text-muted, #888)"}`},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:12},children:[e.jsx(s.NiceIcon,{name:v.find(n=>n.type===u.source.type)?.icon??"zap",size:20}),e.jsx("span",{style:{fontWeight:600},children:"Event Source"})]}),e.jsx("select",{value:u.source.type,onChange:n=>F(u.id,{source:{...u.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:v.map(n=>e.jsx("option",{value:n.type,children:n.label},n.type))}),v.find(n=>n.type===u.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(u.source.config[n.name]??""),onChange:g=>F(u.id,{source:{...u.source,config:{...u.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(u.source.config[n.name]??""),onChange:g=>F(u.id,{source:{...u.source,config:{...u.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(s.NiceIcon,{name:"arrow-down",size:16})}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[u.handlers.map((n,g)=>{const h=j.find(S=>S.type===n.type),o=H.has(n.id);return e.jsxs(f.Fragment,{children:[e.jsxs("div",{style:{padding:16,background:t.cardBg,borderRadius:8,borderLeft:`4px solid ${h?.color??"var(--nice-text-muted, #888)"}`},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer"},onClick:()=>q(S=>{const a=new Set(S);return a.has(n.id)?a.delete(n.id):a.add(n.id),a}),children:[e.jsx(s.NiceIcon,{name:h?.icon??"zap",size:16}),e.jsxs("span",{style:{fontWeight:500},children:[g+1,". ",h?.label??n.type]}),n.modifiers?.map(S=>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:[S.type,": ",S.value,"ms"]},S.type)),e.jsx("span",{style:{marginLeft:"auto",color:t.textMuted,display:"inline-flex",alignItems:"center"},children:e.jsx(s.NiceIcon,{name:o?"chevron-down":"chevron-right",size:14})})]}),o&&e.jsxs("div",{style:{marginTop:12,paddingTop:12,borderTop:`1px solid ${t.border}`},children:[e.jsx("select",{value:n.type,onChange:S=>T(n.id,{type:S.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:j.map(S=>e.jsx("option",{value:S.type,children:S.label},S.type))}),h?.configSchema.map(S=>e.jsxs("div",{style:{marginBottom:8},children:[e.jsx("label",{style:{display:"block",fontSize:11,color:t.textMuted,marginBottom:4},children:S.label}),S.type==="code"?e.jsx("textarea",{value:String(n.config[S.name]??""),onChange:a=>T(n.id,{config:{...n.config,[S.name]:a.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"}}):S.type==="select"?e.jsx("select",{value:String(n.config[S.name]??""),onChange:a=>T(n.id,{config:{...n.config,[S.name]:a.target.value}}),style:{width:"100%",padding:8,borderRadius:4,border:`1px solid ${t.border}`,background:t.bg,color:t.text,fontSize:12},children:S.options?.map(a=>e.jsx("option",{value:a.value,children:a.label},a.value))}):e.jsx("input",{type:S.type==="number"?"number":"text",value:String(n.config[S.name]??""),onChange:a=>T(n.id,{config:{...n.config,[S.name]:S.type==="number"?Number(a.target.value):a.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"}})]},S.name)),e.jsxs("div",{style:{marginTop:12},children:[e.jsx("div",{style:{fontSize:11,color:t.textMuted,marginBottom:8},children:"Modifiers"}),e.jsx("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:["debounce","throttle","delay","retry","once"].map(S=>e.jsx("button",{onClick:()=>m(n.id,S),style:{padding:"4px 8px",borderRadius:4,border:`1px solid ${n.modifiers?.some(a=>a.type===S)?"var(--nice-color-accent, #8b5cf6)":t.border}`,background:n.modifiers?.some(a=>a.type===S)?"var(--nice-accent-tint-12, #8b5cf620)":"transparent",color:t.text,cursor:"pointer",fontSize:11},children:S},S))})]}),e.jsxs("button",{onClick:()=>U(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(s.NiceIcon,{name:"trash",size:14})," Remove Handler"]})]})]}),g<u.handlers.length-1&&e.jsx("div",{style:{textAlign:"center",color:t.textMuted},children:e.jsx(s.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:"Add Handler"}),e.jsx("div",{style:{display:"flex",gap:8,flexWrap:"wrap",justifyContent:"center"},children:j.map(n=>e.jsxs("button",{onClick:()=>X(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(s.NiceIcon,{name:n.icon,size:14})," ",n.label]},n.type))})]})]})]}),($==="code"||$==="split")&&e.jsx("div",{style:{flex:1,overflow:"auto",padding:16,background:"var(--nice-bg-canvas, #0d1117)",borderLeft:$==="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:I})})]})]})},Ve=Object.freeze(Object.defineProperty({__proto__:null,NiceEventOrchestrator:ve},Symbol.toStringTag,{value:"Module"})),Ue=[{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"}],re={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)"}},He=[{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"}}]}]}],Je=i=>i.map(v=>{const j=new Set(["import { render, screen, fireEvent, waitFor } from '@testing-library/react';","import userEvent from '@testing-library/user-event';",`import { ${v.componentName} } from './${v.componentName}';`]);v.setup?.mocks.forEach(l=>{l.type==="api"&&(j.add("import { rest } from 'msw';"),j.add("import { setupServer } from 'msw/node';"))});const y=v.setup?.mocks.map(l=>l.type==="function"?`const ${l.name} = jest.fn();`:l.type==="api"?`// API mock: ${l.name}`:"").filter(Boolean).join(`
193
+ `),b=v.setup?.providers&&v.setup.providers.length>0?`const Wrapper = ({ children }) => (
194
+ ${v.setup.providers.map(l=>`<${l.name}>`).join(`
195
+ `)}
196
+ {children}
197
+ ${v.setup.providers.reverse().map(l=>`</${l.name}>`).join(`
198
+ `)}
199
+ );`:"",k=v.tests.map(l=>{const N=l.skip?".skip":l.only?".only":"",r=l.steps.map(c=>Ge(c,v)).join(`
200
+ `);return`
201
+ it${N}('${l.name}', async () => {
202
+ ${r}
203
+ });`}).join(`
204
+ `);return`/**
205
+ * ${v.name}
206
+ * @generated by NiceTestBuilder
207
+ */
208
+
209
+ ${Array.from(j).join(`
210
+ `)}
211
+
212
+ describe('${v.componentName}', () => {
213
+ ${y?` // Mocks
214
+ ${y}
215
+ `:""}
216
+ ${b?` ${b}
217
+ `:""}
218
+ beforeEach(() => {
219
+ jest.clearAllMocks();
220
+ });
221
+ ${k}
222
+ });
223
+ `}).join(`
224
+
225
+ `),Ge=(i,v)=>{switch(re[i.action],i.action){case"render":{const j=v.setup?.providers&&v.setup.providers.length>0,y=v.setup?.props?` {...${JSON.stringify(v.setup.props)}}`:"";return j?`render(<${v.componentName}${y} />, { wrapper: Wrapper });`:`render(<${v.componentName}${y} />);`}case"click":return`await userEvent.click(screen.getByRole('${i.target?.replace(/[[\]'"]/g,"")}'));`;case"type":return`await userEvent.type(screen.getByRole('textbox', { name: /${i.target}/ }), '${i.value}');`;case"select":return`await userEvent.selectOptions(screen.getByRole('combobox'), '${i.value}');`;case"hover":return`await userEvent.hover(screen.getByRole('${i.target}'));`;case"focus":return`screen.getByRole('${i.target}').focus();`;case"blur":return`screen.getByRole('${i.target}').blur();`;case"submit":return"fireEvent.submit(screen.getByRole('form'));";case"wait":if(typeof i.value=="object"&&i.value!==null){const j=i.value;return j.type==="timeout"?`await new Promise(r => setTimeout(r, ${j.value}));`:`await waitFor(() => expect(/* condition */).toBeTruthy(), { timeout: ${j.timeout??1e3} });`}return`await new Promise(r => setTimeout(r, ${i.value}));`;case"assert":if(typeof i.value=="object"&&i.value!==null){const j=i.value;if(j.mock)return`expect(${j.mock}).${j.matcher}(${j.expected?JSON.stringify(j.expected):""});`;const y=i.target?`screen.getByRole('${i.target}')`:"result",z=j.expected!==void 0?JSON.stringify(j.expected):"";return`expect(${y}).${j.matcher}(${z});`}return`expect(screen.getByRole('${i.target}')).toBeInTheDocument();`;case"snapshot":return"expect(container).toMatchSnapshot();";case"a11y-check":return`const results = await axe(container);
226
+ expect(results).toHaveNoViolations();`;default:return`// ${i.action}: ${JSON.stringify(i)}`}},je=({componentName:i="MyComponent",testSuites:v=He,availableMocks:j=[],onSuitesChange:y,onExport:z,onRun:b,onRunAll:k,tutorial:l,className:N,style:r,"data-testid":c})=>{const[w,M]=f.useState(v),[$,L]=f.useState(w[0]?.id??null),[P,D]=f.useState(null),[R,J]=f.useState("visual"),[H,q]=f.useState(!1),[u,I]=f.useState(""),[F,Y]=f.useState(new Set),C=f.useMemo(()=>w.find(d=>d.id===$),[w,$]);f.useMemo(()=>C?.tests.find(d=>d.id===P),[C,P]);const X=f.useMemo(()=>Je(w),[w]),T=f.useCallback((d,_)=>{M(O=>{const V=O.map(B=>B.id===d?{...B,..._}:B);return y?.(V),V})},[y]),U=()=>{if(!u.trim())return;const d={id:`suite-${Date.now()}`,name:u,componentName:i,tests:[]};M(_=>{const O=[..._,d];return y?.(O),O}),L(d.id),q(!1),I("")},m=d=>{M(_=>{const O=_.filter(V=>V.id!==d);return y?.(O),O}),$===d&&L(w[0]?.id??null)},t=()=>{if(!C)return;const d={id:`test-${Date.now()}`,name:"New test",type:"unit",steps:[{id:`step-${Date.now()}`,action:"render"}]};T(C.id,{tests:[...C.tests,d]}),D(d.id),Y(_=>new Set([..._,d.id]))},n=(d,_)=>{C&&T(C.id,{tests:C.tests.map(O=>O.id===d?{...O,..._}:O)})},g=d=>{C&&(T(C.id,{tests:C.tests.filter(_=>_.id!==d)}),P===d&&D(null))},h=(d,_)=>{if(!C)return;const O=C.tests.find(B=>B.id===d);if(!O)return;const V={id:`step-${Date.now()}`,action:_};n(d,{steps:[...O.steps,V]})},o=(d,_,O)=>{if(!C)return;const V=C.tests.find(B=>B.id===d);V&&n(d,{steps:V.steps.map(B=>B.id===_?{...B,...O}:B)})},S=(d,_)=>{if(!C)return;const O=C.tests.find(V=>V.id===d);O&&n(d,{steps:O.steps.filter(V=>V.id!==_)})},a={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)"},G=f.useMemo(()=>{const d=w.reduce((O,V)=>O+V.tests.length,0),_=w.reduce((O,V)=>O+V.tests.filter(B=>B.skip).length,0);return{total:d,skipped:_}},[w]),Z=e.jsxs("div",{style:{padding:"12px 20px",borderBottom:`1px solid ${a.border}`,display:"flex",alignItems:"center",gap:16},children:[e.jsxs("h3",{style:{margin:0,fontSize:16},children:[e.jsx(s.NiceIcon,{name:"flask",size:16})," Test Builder"]}),e.jsxs("div",{style:{fontSize:12,color:a.textMuted},children:[G.total," tests • ",G.skipped," skipped"]}),e.jsx("div",{style:{display:"flex",border:`1px solid ${a.border}`,borderRadius:6,overflow:"hidden",marginLeft:"auto"},children:["visual","code","split"].map(d=>e.jsxs("button",{onClick:()=>J(d),style:{padding:"6px 12px",border:"none",background:R===d?a.cardBg:"transparent",color:a.text,cursor:"pointer",fontSize:12,textTransform:"capitalize"},children:[e.jsx(s.NiceIcon,{name:d==="visual"?"palette":d==="code"?"edit":"grid",size:14})," ",d]},d))}),e.jsxs("button",{onClick:k,style:{padding:"8px 16px",borderRadius:6,border:`1px solid ${a.border}`,background:"transparent",color:a.text,cursor:"pointer",fontSize:13},children:[e.jsx(s.NiceIcon,{name:"play",size:14})," Run All"]}),e.jsxs("button",{onClick:()=>z?.(X),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(s.NiceIcon,{name:"upload",size:14})," Export"]}),e.jsx(s.NiceTutorialButton,{steps:s.resolveTutorial(l,Ue)})]}),K=R==="visual"||R==="split"?e.jsxs("div",{style:{width:220,borderRight:`1px solid ${a.border}`,display:"flex",flexDirection:"column",height:"100%"},children:[e.jsxs("div",{style:{padding:"12px 16px",borderBottom:`1px solid ${a.border}`,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsx("span",{style:{fontSize:12,fontWeight:600},children:"Test Suites"}),e.jsx("button",{onClick:()=>q(!0),style:{padding:"4px 8px",borderRadius:4,border:`1px solid ${a.border}`,background:"transparent",color:a.text,cursor:"pointer",fontSize:12},children:"+"})]}),e.jsxs("div",{style:{flex:1,overflow:"auto",padding:8},children:[w.map(d=>e.jsxs("div",{onClick:()=>{L(d.id),D(null)},style:{padding:12,background:$===d.id?a.cardBg:"transparent",borderRadius:6,cursor:"pointer",marginBottom:4,border:`1px solid ${$===d.id?a.border:"transparent"}`},children:[e.jsx("div",{style:{fontSize:13,fontWeight:500},children:d.name}),e.jsxs("div",{style:{fontSize:10,color:a.textMuted,marginTop:4},children:[d.componentName," • ",d.tests.length," test",d.tests.length!==1?"s":""]})]},d.id)),H&&e.jsxs("div",{style:{padding:12,background:a.cardBg,borderRadius:6,border:"1px solid var(--nice-primary, #3b82f6)"},children:[e.jsx("input",{type:"text",value:u,onChange:d=>I(d.target.value),placeholder:"Suite name...",autoFocus:!0,style:{width:"100%",padding:8,borderRadius:4,border:`1px solid ${a.border}`,background:a.bg,color:a.text,fontSize:12,marginBottom:8,boxSizing:"border-box"},onKeyDown:d=>d.key==="Enter"&&U()}),e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx("button",{onClick:()=>q(!1),style:{flex:1,padding:6,borderRadius:4,border:`1px solid ${a.border}`,background:"transparent",color:a.text,cursor:"pointer",fontSize:11},children:"Cancel"}),e.jsx("button",{onClick:U,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(ee.NiceAppShell,{flush:!0,className:`nice-test-builder ${N||""}`,style:{background:a.bg,color:a.text,fontFamily:"system-ui, sans-serif",...r},"data-testid":c,menubar:Z,sidebar:K,children:e.jsxs("div",{style:{display:"flex",height:"100%",overflow:"hidden"},children:[(R==="visual"||R==="split")&&C&&e.jsxs("div",{style:{flex:R==="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:C.name,onChange:d=>T(C.id,{name:d.target.value}),style:{flex:1,padding:10,borderRadius:6,border:`1px solid ${a.border}`,background:a.cardBg,color:a.text,fontSize:16,fontWeight:600}}),e.jsxs("button",{onClick:()=>b?.(C.id),style:{padding:"8px 16px",borderRadius:6,border:`1px solid ${a.border}`,background:"transparent",color:a.text,cursor:"pointer",fontSize:12},children:[e.jsx(s.NiceIcon,{name:"play",size:14})," Run Suite"]}),e.jsx("button",{onClick:()=>m(C.id),"aria-label":"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(s.NiceIcon,{name:"trash",size:14})})]}),e.jsxs("div",{style:{marginBottom:20},children:[e.jsx("label",{style:{display:"block",fontSize:11,color:a.textMuted,marginBottom:6},children:"Component"}),e.jsx("input",{type:"text",value:C.componentName,onChange:d=>T(C.id,{componentName:d.target.value}),style:{width:200,padding:8,borderRadius:4,border:`1px solid ${a.border}`,background:a.cardBg,color:a.text,fontSize:13}})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[C.tests.map((d,_)=>{const O=F.has(d.id),V={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:a.cardBg,borderRadius:8,border:`1px solid ${P===d.id?"var(--nice-color-primary, #3b82f6)":a.border}`,overflow:"hidden"},children:[e.jsxs("div",{style:{padding:12,display:"flex",alignItems:"center",gap:8,cursor:"pointer",borderLeft:`4px solid ${V[d.type].color}`},onClick:()=>{D(d.id),Y(B=>{const x=new Set(B);return x.has(d.id)?x.delete(d.id):x.add(d.id),x})},children:[e.jsx("span",{children:e.jsx(s.NiceIcon,{name:V[d.type].icon,size:14})}),e.jsxs("span",{style:{fontWeight:500,opacity:d.skip?.5:1},children:[_+1,". ",d.name]}),d.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:"SKIPPED"}),d.only&&e.jsx("span",{style:{padding:"2px 6px",background:"#8b5cf630",color:"var(--nice-color-accent, #8b5cf6)",borderRadius:4,fontSize:10},children:"ONLY"}),e.jsxs("span",{style:{marginLeft:"auto",fontSize:11,color:a.textMuted},children:[d.steps.length," step",d.steps.length!==1?"s":""]}),e.jsx("span",{style:{color:a.textMuted},children:e.jsx(s.NiceIcon,{name:O?"chevron-down":"chevron-right",size:14})})]}),O&&e.jsxs("div",{style:{padding:16,borderTop:`1px solid ${a.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:a.textMuted,marginBottom:4},children:"Test Name"}),e.jsx("input",{type:"text",value:d.name,onChange:B=>n(d.id,{name:B.target.value}),style:{width:"100%",padding:8,borderRadius:4,border:`1px solid ${a.border}`,background:a.bg,color:a.text,fontSize:12,boxSizing:"border-box"}})]}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:11,color:a.textMuted,marginBottom:4},children:"Type"}),e.jsxs("select",{value:d.type,onChange:B=>n(d.id,{type:B.target.value}),style:{padding:8,borderRadius:4,border:`1px solid ${a.border}`,background:a.bg,color:a.text,fontSize:12},children:[e.jsx("option",{value:"unit",children:"Unit"}),e.jsx("option",{value:"integration",children:"Integration"}),e.jsx("option",{value:"e2e",children:"E2E"}),e.jsx("option",{value:"snapshot",children:"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:d.skip??!1,onChange:B=>n(d.id,{skip:B.target.checked,only:!1})}),"Skip"]}),e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:4,fontSize:11},children:[e.jsx("input",{type:"checkbox",checked:d.only??!1,onChange:B=>n(d.id,{only:B.target.checked,skip:!1})}),"Only"]})]})]}),e.jsxs("div",{style:{marginBottom:12},children:[e.jsx("div",{style:{fontSize:11,color:a.textMuted,marginBottom:8},children:"Steps"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:d.steps.map((B,x)=>{const E=re[B.action];return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:10,background:a.bg,borderRadius:6,borderLeft:`3px solid ${E.color}`},children:[e.jsx("span",{style:{width:20,textAlign:"center",fontSize:11,color:a.textMuted},children:x+1}),e.jsx("span",{children:e.jsx(s.NiceIcon,{name:E.icon,size:14})}),e.jsx("select",{value:B.action,onChange:A=>o(d.id,B.id,{action:A.target.value}),style:{padding:6,borderRadius:4,border:`1px solid ${a.border}`,background:a.cardBg,color:a.text,fontSize:11},children:Object.entries(re).map(([A,W])=>e.jsx("option",{value:A,children:W.label},A))}),E.hasTarget&&e.jsx("input",{type:"text",value:B.target??"",onChange:A=>o(d.id,B.id,{target:A.target.value}),placeholder:"Target selector",style:{flex:1,padding:6,borderRadius:4,border:`1px solid ${a.border}`,background:a.cardBg,color:a.text,fontSize:11}}),E.hasValue&&B.action!=="assert"&&e.jsx("input",{type:"text",value:typeof B.value=="string"?B.value:"",onChange:A=>o(d.id,B.id,{value:A.target.value}),placeholder:"Value",style:{width:120,padding:6,borderRadius:4,border:`1px solid ${a.border}`,background:a.cardBg,color:a.text,fontSize:11}}),e.jsx("button",{onClick:()=>S(d.id,B.id),"aria-label":"Remove step",style:{padding:4,borderRadius:4,border:"none",background:"transparent",color:"var(--nice-color-error, #ef4444)",cursor:"pointer",fontSize:12},children:e.jsx(s.NiceIcon,{name:"close",size:14})})]},B.id)})})]}),e.jsx("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:Object.entries(re).slice(0,8).map(([B,x])=>e.jsxs("button",{onClick:()=>h(d.id,B),style:{padding:"4px 8px",borderRadius:4,border:`1px solid ${x.color}40`,background:`${x.color}20`,color:a.text,cursor:"pointer",fontSize:10},children:[e.jsx(s.NiceIcon,{name:x.icon,size:14})," ",x.label]},B))}),e.jsx("div",{style:{marginTop:16,display:"flex",gap:8},children:e.jsxs("button",{onClick:()=>g(d.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(s.NiceIcon,{name:"trash",size:14})," Delete Test"]})})]})]},d.id)}),e.jsx("button",{onClick:t,style:{padding:16,borderRadius:8,border:`1px dashed ${a.border}`,background:"transparent",color:a.textMuted,cursor:"pointer",fontSize:13},children:"+ Add Test"})]})]}),(R==="code"||R==="split")&&e.jsx("div",{style:{flex:1,overflow:"auto",padding:16,background:"var(--nice-bg-canvas, #0d1117)",borderLeft:R==="split"?`1px solid ${a.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:X})})]})})},Ke=Object.freeze(Object.defineProperty({__proto__:null,NiceTestBuilder:je},Symbol.toStringTag,{value:"Module"})),Ye=[],Xe=[{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';
227
+ {{#if withProps}}
228
+ export interface {{componentName}}Props {
229
+ children?: React.ReactNode;
230
+ className?: string;
231
+ }
232
+ {{/if}}
233
+
234
+ export const {{componentName}}: React.FC{{#if withProps}}<{{componentName}}Props>{{/if}} = ({{#if withProps}}{ children, className }{{/if}}) => {
235
+ return (
236
+ <div className={className}>
237
+ {children}
238
+ </div>
239
+ );
240
+ };
241
+
242
+ export default {{componentName}};
243
+ `},{id:"test",name:"{{componentName}}.test.tsx",path:"src/components/{{componentName}}",language:"typescript",condition:"withTests === true",content:`import { render, screen } from '@testing-library/react';
244
+ import { {{componentName}} } from './{{componentName}}';
245
+
246
+ describe('{{componentName}}', () => {
247
+ it('renders children', () => {
248
+ render(<{{componentName}}>Test Content</{{componentName}}>);
249
+ expect(screen.getByText('Test Content')).toBeInTheDocument();
250
+ });
251
+ });
252
+ `},{id:"story",name:"{{componentName}}.stories.tsx",path:"src/components/{{componentName}}",language:"typescript",condition:"withStory === true",content:`import type { Meta, StoryObj } from '@storybook/react';
253
+ import { {{componentName}} } from './{{componentName}}';
254
+
255
+ const meta: Meta<typeof {{componentName}}> = {
256
+ title: 'Components/{{componentName}}',
257
+ component: {{componentName}},
258
+ };
259
+
260
+ export default meta;
261
+ type Story = StoryObj<typeof {{componentName}}>;
262
+
263
+ export const Default: Story = {
264
+ args: {},
265
+ };
266
+ `},{id:"index",name:"index.ts",path:"src/components/{{componentName}}",language:"typescript",content:`export { {{componentName}} } from './{{componentName}}';
267
+ export type { {{componentName}}Props } from './{{componentName}}';
268
+ `}]}]},{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}}
269
+ import type { Metadata } from 'next';
270
+
271
+ export const metadata: Metadata = {
272
+ title: '{{pageName}}',
273
+ description: '{{pageName}} page',
274
+ };
275
+ {{/if}}
276
+
277
+ export default function {{pascalCase pageName}}Page() {
278
+ return (
279
+ <main>
280
+ <h1>{{pageName}}</h1>
281
+ </main>
282
+ );
283
+ }
284
+ `},{id:"loading",name:"loading.tsx",path:"app/{{pageName}}",language:"typescript",condition:"withLoading === true",content:`export default function Loading() {
285
+ return <div>Loading...</div>;
286
+ }
287
+ `},{id:"error",name:"error.tsx",path:"app/{{pageName}}",language:"typescript",condition:"withError === true",content:`'use client';
288
+
289
+ export default function Error({
290
+ error,
291
+ reset,
292
+ }: {
293
+ error: Error & { digest?: string };
294
+ reset: () => void;
295
+ }) {
296
+ return (
297
+ <div>
298
+ <h2>Something went wrong!</h2>
299
+ <button onClick={reset}>Try again</button>
300
+ </div>
301
+ );
302
+ }
303
+ `}]},{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';
304
+
305
+ {{#if (includes methods 'GET')}}
306
+ export async function GET() {
307
+ return NextResponse.json({ message: 'GET {{routeName}}' });
308
+ }
309
+ {{/if}}
310
+
311
+ {{#if (includes methods 'POST')}}
312
+ export async function POST(request: Request) {
313
+ const body = await request.json();
314
+ return NextResponse.json({ message: 'POST {{routeName}}', data: body });
315
+ }
316
+ {{/if}}
317
+
318
+ {{#if (includes methods 'PUT')}}
319
+ export async function PUT(request: Request) {
320
+ const body = await request.json();
321
+ return NextResponse.json({ message: 'PUT {{routeName}}', data: body });
322
+ }
323
+ {{/if}}
324
+
325
+ {{#if (includes methods 'DELETE')}}
326
+ export async function DELETE() {
327
+ return NextResponse.json({ message: 'DELETE {{routeName}}' });
328
+ }
329
+ {{/if}}
330
+ `}]}]}],me=(i,v,j)=>{let y=i;Object.entries(v).forEach(([k,l])=>{const N=new RegExp(`\\{\\{\\s*${k}\\s*\\}\\}`,"g");y=y.replace(N,String(l));const r=new RegExp(`\\{\\{\\s*pascalCase\\s+${k}\\s*\\}\\}`,"g");if(typeof l=="string"){const c=l.charAt(0).toUpperCase()+l.slice(1);y=y.replace(r,c)}});const z=/\{\{#if\s+([^}]+)\}\}([\s\S]*?)\{\{\/if\}\}/g;y=y.replace(z,(k,l,N)=>{const r=l.trim(),c=r.match(/(\w+)\s*===?\s*(\w+|true|false|'[^']*'|"[^"]*")/);if(c){const[,M,$]=c,L=v[M];let P=$;return $==="true"?P=!0:$==="false"?P=!1:($.startsWith("'")||$.startsWith('"'))&&(P=$.slice(1,-1)),L===P?N:""}return v[r]?N:""});const b=/\{\{#if\s+\(includes\s+(\w+)\s+'([^']+)'\)\}\}([\s\S]*?)\{\{\/if\}\}/g;return y=y.replace(b,(k,l,N,r)=>{const c=v[l];return Array.isArray(c)&&c.includes(N)?r:""}),y},Ze=(i,v)=>{try{const j=i.split(/\s*(===|!==|==|!=)\s*/);if(j.length===3){const[y,z,b]=j,k=v[y.trim()],l=b.trim();let N=l;switch(l==="true"?N=!0:l==="false"?N=!1:(l.startsWith("'")||l.startsWith('"'))&&(N=l.slice(1,-1)),z){case"===":case"==":return k===N;case"!==":case"!=":return k!==N}}return!!v[i.trim()]}catch{return!0}},Se=({templates:i,defaultTemplates:v,onTemplatesChange:j,presets:y=Xe,selectedTemplate:z,defaultSelectedTemplate:b,onSelectedTemplateChange:k,defaultEngine:l="handlebars",showLibrary:N=!0,onTemplateSelect:r,onTemplateCreate:c,onTemplateUpdate:w,onTemplateDelete:M,onGenerate:$,onExport:L,onImport:P,className:D,style:R,"data-testid":J="nice-code-template"})=>{const H=i!==void 0&&j!==void 0,[q,u]=s.useControllableState({value:H?i:void 0,defaultValue:H?v:v??i,fallbackValue:Ye,onChange:j,componentName:"NiceCodeTemplate"});ee.useIgnoredPropChangeWarning("NiceCodeTemplate","templates","onTemplatesChange",i,H);const I=z!==void 0&&k!==void 0,[F,Y]=s.useControllableState({value:I?z:void 0,defaultValue:I?b:b??z,fallbackValue:null,onChange:k,componentName:"NiceCodeTemplate"});ee.useIgnoredPropChangeWarning("NiceCodeTemplate","selectedTemplate","onSelectedTemplateChange",z,I);const[C,X]=f.useState({}),[T,U]=f.useState("editor"),[m,t]=f.useState(null),[n,g]=f.useState(!1),[h,o]=f.useState(!1),S=f.useMemo(()=>{const x=y.flatMap(E=>E.templates);return[...q,...x]},[q,y]),a=f.useMemo(()=>S.find(x=>x.id===F),[S,F]),G=f.useMemo(()=>a?.files.find(x=>x.id===m)||a?.files[0],[a,m]);f.useEffect(()=>{if(a){const x={};a.variables.forEach(E=>{x[E.name]=E.defaultValue??""}),X(x),t(a.files[0]?.id||null)}},[a]);const Z=f.useMemo(()=>a?a.files.filter(x=>x.condition?Ze(x.condition,C):!0).map(x=>({path:me(`${x.path}/${x.name}`,C,a.engine),content:me(x.content,C,a.engine),language:x.language})):[],[a,C]),p=f.useCallback(x=>{Y(x.id),r?.(x)},[r,Y]),K=f.useCallback(()=>{$?.(Z,C)},[Z,C,$]),d=f.useCallback(()=>{const x={id:crypto.randomUUID(),name:"New Template",description:"Custom template",category:"custom",icon:"file",engine:l,variables:[{id:"1",name:"name",type:"string",required:!0,defaultValue:"MyName"}],files:[{id:"1",name:"{{name}}.ts",path:"src",language:"typescript",content:`// {{name}}
331
+ export const {{name}} = {};`}]};u(E=>[...E,x]),Y(x.id),g(!1),c?.(x)},[l,c,u,Y]),_=f.useCallback((x,E)=>{if(!a)return;const A={...a,files:a.files.map(W=>W.id===x?{...W,content:E}:W)};u(W=>W.map(ne=>ne.id===A.id?A:ne)),w?.(A)},[a,w,u]),O=f.useCallback(()=>{if(!a)return;const x={id:crypto.randomUUID(),name:"new-file.ts",path:"src",language:"typescript",content:`// New file
332
+ `},E={...a,files:[...a.files,x]};u(A=>A.map(W=>W.id===E.id?E:W)),t(x.id),w?.(E)},[a,w,u]),V=f.useCallback(x=>{if(!a)return;const E={...a,files:a.files.filter(A=>A.id!==x)};u(A=>A.map(W=>W.id===E.id?E:W)),t(E.files[0]?.id||null),w?.(E)},[a,w,u]),B=x=>{const E=C[x.name];switch(x.type){case"boolean":return e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:!!E,onChange:A=>X(W=>({...W,[x.name]:A.target.checked}))}),e.jsx("span",{children:x.name})]});case"select":return e.jsx("select",{value:String(E),onChange:A=>X(W=>({...W,[x.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:x.options?.map(A=>e.jsx("option",{value:A,children:A},A))});case"array":return e.jsx("input",{type:"text",value:Array.isArray(E)?E.join(", "):"",onChange:A=>X(W=>({...W,[x.name]:A.target.value.split(",").map(ne=>ne.trim())})),placeholder:"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(E),onChange:A=>X(W=>({...W,[x.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(E??""),onChange:A=>X(W=>({...W,[x.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 ${D||""}`,style:{display:"flex",height:"100%",background:"var(--nice-bg-canvas, #0d1117)",color:"var(--nice-text-primary, #e6edf3)",fontFamily:"system-ui, sans-serif",...R},"data-testid":J,children:[N&&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(s.NiceIcon,{name:"book",size:16})," Templates"]}),e.jsx("button",{onClick:d,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:[q.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:"CUSTOM"}),q.map(x=>e.jsxs("div",{onClick:()=>p(x),style:{padding:"10px 12px",borderRadius:6,cursor:"pointer",background:F===x.id?"var(--nice-primary-tint-15, rgba(59, 130, 246, 0.15))":"transparent",display:"flex",alignItems:"center",gap:10},children:[e.jsx(s.NiceIcon,{name:x.icon||"file",size:16}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{style:{fontSize:13},children:x.name}),e.jsx("div",{style:{fontSize:11,color:"var(--nice-text-muted, #8b949e)"},children:x.category})]})]},x.id))]}),y.map(x=>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(s.NiceIcon,{name:x.icon,size:12}),x.name.toUpperCase()]}),x.templates.map(E=>e.jsxs("div",{onClick:()=>p(E),style:{padding:"10px 12px",borderRadius:6,cursor:"pointer",background:F===E.id?"var(--nice-primary-tint-15, rgba(59, 130, 246, 0.15))":"transparent",display:"flex",alignItems:"center",gap:10},children:[e.jsx(s.NiceIcon,{name:E.icon||"file",size:16}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{style:{fontSize:13},children:E.name}),e.jsx("div",{style:{fontSize:11,color:"var(--nice-text-muted, #8b949e)"},children:E.description})]})]},E.id))]},x.id))]})]}),e.jsx("div",{style:{flex:1,display:"flex",flexDirection:"column"},children:a?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(s.NiceIcon,{name:a.icon||"file",size:24}),e.jsxs("div",{children:[e.jsx("div",{style:{fontWeight:500},children:a.name}),e.jsx("div",{style:{fontSize:12,color:"var(--nice-text-muted, #8b949e)"},children:a.description})]})]}),e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsxs("button",{onClick:()=>L?.(a,"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(s.NiceIcon,{name:"upload",size:14})," Export"]}),e.jsxs("button",{onClick:K,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(s.NiceIcon,{name:"zap",size:14})," 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(x=>e.jsxs("button",{onClick:()=>U(x),style:{padding:"10px 20px",background:T===x?"var(--nice-bg-canvas, #0d1117)":"transparent",border:"none",borderBottom:T===x?"2px solid var(--nice-primary, #3b82f6)":"2px solid transparent",color:T===x?"var(--nice-text-primary, #fff)":"var(--nice-text-muted, #8b949e)",cursor:"pointer",textTransform:"capitalize"},children:[x==="variables"&&e.jsxs(e.Fragment,{children:[e.jsx(s.NiceIcon,{name:"settings",size:14})," "]}),x==="editor"&&e.jsxs(e.Fragment,{children:[e.jsx(s.NiceIcon,{name:"edit",size:14})," "]}),x==="preview"&&e.jsxs(e.Fragment,{children:[e.jsx(s.NiceIcon,{name:"eye",size:14})," "]}),x]},x))}),e.jsxs("div",{style:{flex:1,display:"flex",overflow:"hidden"},children:[T==="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:"Template Variables"}),a.variables.map(x=>e.jsxs("div",{style:{marginBottom:16},children:[e.jsxs("label",{style:{display:"block",fontSize:12,color:"var(--nice-text-muted, #8b949e)",marginBottom:4},children:[x.name,x.required&&e.jsx("span",{style:{color:"var(--nice-color-error, #ef4444)"},children:" *"})]}),B(x),x.description&&e.jsx("div",{style:{fontSize:11,color:"var(--nice-text-muted, #6b7280)",marginTop:4},children:x.description})]},x.id))]})}),T==="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:"Files"}),e.jsx("button",{onClick:O,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:a.files.map(x=>e.jsxs("div",{onClick:()=>t(x.id),style:{padding:"8px 12px",cursor:"pointer",background:m===x.id?"var(--nice-primary-tint-15, rgba(59, 130, 246, 0.15))":"transparent",borderLeft:m===x.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:x.name}),e.jsx("button",{"aria-label":"Remove file",onClick:E=>{E.stopPropagation(),V(x.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(s.NiceIcon,{name:"close",size:14})})]},x.id))})]}),e.jsx("div",{style:{flex:1,display:"flex",flexDirection:"column"},children:G&&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:[G.path,"/",G.name,G.condition&&e.jsxs("span",{style:{color:"var(--nice-color-warning, #f59e0b)",marginLeft:8},children:["(if: ",G.condition,")"]})]}),e.jsx("textarea",{value:G.content,onChange:x=>_(G.id,x.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"}})]})})]}),T==="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:[Z.length," file(s) will be generated"]})}),e.jsx("div",{style:{flex:1,overflow:"auto"},children:Z.map((x,E)=>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(s.NiceIcon,{name:"file",size:14})," ",x.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:x.content})]},E))})]})]})]}):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(s.NiceIcon,{name:"book",size:64})}),e.jsx("span",{style:{fontSize:18},children:"Select a template"}),e.jsx("span",{style:{fontSize:12,marginTop:4},children:"Choose from the library or create a new template"}),e.jsxs("button",{onClick:d,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(s.NiceIcon,{name:"plus",size:14})," Create Template"]})]})})]})},Qe=Object.freeze(Object.defineProperty({__proto__:null,NiceCodeTemplate:Se},Symbol.toStringTag,{value:"Module"}));exports.NiceAPIFlow=fe;exports.NiceAPIFlow$1=Fe;exports.NiceCodePreview=Te;exports.NiceCodeTemplate=Se;exports.NiceCodeTemplate$1=Qe;exports.NiceComponentDesigner=ze;exports.NiceDataMapper=be;exports.NiceDataMapper$1=_e;exports.NiceEventOrchestrator=ve;exports.NiceEventOrchestrator$1=Ve;exports.NiceLowCodeStudio=we;exports.NicePageBuilder=Ce;exports.NiceStateDesigner=ge;exports.NiceStateDesigner$1=Ee;exports.NiceTestBuilder=je;exports.NiceTestBuilder$1=Ke;