@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,260 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),C=require("@nice2dev/ui-core"),r=require("react"),Oe=[{target:".nice-code-editor-wrap",titleKey:"tutorial.codeEditor.intro.title",title:"Code editor",contentKey:"tutorial.codeEditor.intro.content",content:"Edit code with syntax highlighting, IntelliSense and the toolbar. Ctrl+S saves; the status bar shows the cursor position and any problems.",placement:"auto"}];let Q=null,J=null;const Ie="0.45.0",ve=`https://cdn.jsdelivr.net/npm/monaco-editor@${Ie}/min`,ae=`${ve}/vs`,ge=15e3;function he(){const d=window;if(d.MonacoEnvironment?.getWorkerUrl)return;const u=`self.MonacoEnvironment={baseUrl:'${ve}/'};importScripts('${ae}/base/worker/workerMain.js');`,m=URL.createObjectURL(new Blob([u],{type:"text/javascript"}));d.MonacoEnvironment={getWorkerUrl:()=>m}}function Y(d){if(d!=="auto")return d;if(typeof document>"u")return"vs";const u=document.documentElement.dataset.theme;return u==="dark"?"vs-dark":u==="light"?"vs":window.matchMedia?.("(prefers-color-scheme: dark)").matches?"vs-dark":"vs"}function xe(){return J?Promise.resolve(J):Q||(Q=new Promise((d,u)=>{if(window.monaco){he(),J=window.monaco,d(J);return}let m=!1;const v=window.setTimeout(()=>{m||(m=!0,Q=null,u(new Error(`Monaco editor failed to load within ${ge}ms`)))},ge),w=document.createElement("script");w.src=`${ae}/loader.min.js`,w.async=!0,w.onload=()=>{const R=window.require;R.config({paths:{vs:ae}}),he(),R(["vs/editor/editor.main"],f=>{m||(m=!0,window.clearTimeout(v),J=f,d(f))})},w.onerror=()=>{m||(m=!0,window.clearTimeout(v),Q=null,u(new Error("Failed to load Monaco Editor loader script")))},document.head.appendChild(w)}),Q)}const Te=r.forwardRef(function(u,m){const{value:v,defaultValue:w,onChange:R,language:f="plaintext",theme:O="auto",options:o={},height:G=400,width:Z="100%",markers:_=[],decorations:z=[],completionProvider:F,onMount:g,onCursorPositionChange:A,onSelectionChange:I,onSave:T,loading:P,disabled:E=!1,showToolbar:W=!1,showStatusBar:M=!1,editorSize:B="standard",className:U,"data-testid":$,lsp:N,extraLibs:S,tutorial:p}=u,[s,h,j]=C.useControllableState({value:v,defaultValue:w,fallbackValue:"",onChange:R,componentName:"NiceCodeEditor"}),L=r.useRef(h);L.current=h;const q=r.useRef(s);q.current=s;const x=r.useRef(!1),b=r.useRef(null),c=r.useRef(null),y=r.useRef(null),H=r.useRef([]),D=r.useRef(null),[K,de]=r.useState(!0),[ne,ye]=r.useState(null),[le,Ce]=r.useState({lineNumber:1,column:1}),[ue,we]=r.useState(""),[re,_e]=r.useState(o.wordWrap==="on"),oe=r.useMemo(()=>({automaticLayout:!0,readOnly:E||o.readOnly,minimap:{enabled:o.minimap??!0},lineNumbers:o.lineNumbers??"on",wordWrap:o.wordWrap??"off",tabSize:o.tabSize??2,insertSpaces:o.insertSpaces??!0,fontSize:o.fontSize??14,fontFamily:o.fontFamily??"'Fira Code', 'Consolas', 'Monaco', monospace",fontLigatures:o.fontLigatures??!0,cursorStyle:o.cursorStyle??"line",cursorBlinking:o.cursorBlinking??"blink",autoClosingBrackets:o.autoClosingBrackets??"languageDefined",autoClosingQuotes:o.autoClosingQuotes??"languageDefined",formatOnPaste:o.formatOnPaste??!1,formatOnType:o.formatOnType??!1,renderWhitespace:o.renderWhitespace??"selection",renderControlCharacters:o.renderControlCharacters??!1,scrollBeyondLastLine:o.scrollBeyondLastLine??!0,smoothScrolling:o.smoothScrolling??!0,folding:o.folding??!0,showFoldingControls:o.showFoldingControls??"mouseover","bracketPairColorization.enabled":o.bracketPairColorization??!0,guides:o.guides??{bracketPairs:!0,indentation:!0,highlightActiveIndentation:!0},stickyScroll:{enabled:o.stickyScroll??!1},quickSuggestions:o.quickSuggestions??!0,suggestOnTriggerCharacters:o.suggestOnTriggerCharacters??!0,acceptSuggestionOnEnter:o.acceptSuggestionOnEnter??"on",inlayHints:{enabled:o.inlayHints?"on":"off"}}),[o,E]);r.useEffect(()=>{if(!b.current)return;let e=!0;return xe().then(async i=>{if(!e||!b.current)return;y.current=i;const n=i.editor.create(b.current,{value:q.current,language:f,theme:Y(O),...oe});if(c.current=n,de(!1),n.onDidChangeModelContent(()=>{x.current||L.current(n.getValue())}),n.onDidChangeCursorPosition(a=>{Ce({lineNumber:a.position.lineNumber,column:a.position.column}),A?.({lineNumber:a.position.lineNumber,column:a.position.column})}),n.onDidChangeCursorSelection(a=>{const k=a.selection,l=n.getModel()?.getValueInRange(k)??"";we(l),I?.({startLineNumber:k.startLineNumber,startColumn:k.startColumn,endLineNumber:k.endLineNumber,endColumn:k.endColumn})}),n.addCommand(i.KeyMod.CtrlCmd|i.KeyCode.KeyS,()=>{T?.(n.getValue())}),N&&typeof window<"u")try{await te("https://cdn.jsdelivr.net/npm/vscode-ws-jsonrpc@1.0.2/lib/browser/index.min.js"),await te("https://cdn.jsdelivr.net/npm/monaco-languageclient@0.15.0/lib/monaco-languageclient.min.js");const a=window,k=a.ReconnectingWebSocket,{MonacoLanguageClient:l,CloseAction:X,ErrorAction:ee,createConnection:me}=a.monacoLanguageClient||{};if(l&&me){const je=N.url,Ee=N.language,pe=new k(je),Me=new a.VSCodeWebSocketMessageReader(pe),Le=new a.VSCodeWebSocketMessageWriter(pe),Re=me(Me,Le),fe=new l({name:"LSP Client",clientOptions:{documentSelector:[Ee],initializationOptions:N.initOptions,errorHandler:{error:()=>ee.Continue,closed:()=>X.Restart}},connectionProvider:{get:()=>Promise.resolve(Re)}});fe.start(),c.current.__lspClient=fe}}catch(a){console.warn("LSP bridge failed to load:",a)}g?.(n,i)}).catch(i=>{e&&(ye(i.message??"Failed to load editor"),de(!1))}),()=>{if(e=!1,c.current?.dispose(),D.current?.dispose(),c.current&&c.current.__lspClient)try{c.current.__lspClient.stop()}catch{}}},[N]),r.useEffect(()=>{const e=c.current;if(!j||!e||s===e.getValue())return;const i=e.getPosition();x.current=!0;try{e.setValue(s)}finally{x.current=!1}i&&e.setPosition(i)},[s,j]),r.useEffect(()=>{const e=c.current,i=y.current;if(e&&i){const n=e.getModel();n&&i.editor.setModelLanguage(n,f)}},[f]),r.useEffect(()=>{const e=y.current;if(!e||K||!S||S.length===0||f!=="javascript"&&f!=="typescript")return;const i=e.languages?.typescript;if(!i)return;const n=[];try{S.forEach((a,k)=>{const l=a.filePath??`inmemory://model/nice-extralib-${k}.d.ts`,X=i.typescriptDefaults?.addExtraLib(a.content,l);X&&n.push(X);const ee=i.javascriptDefaults?.addExtraLib(a.content,l);ee&&n.push(ee)})}catch(a){console.warn("Failed to register extraLibs:",a)}return()=>{n.forEach(a=>{try{a.dispose()}catch{}})}},[S,f,K]),r.useEffect(()=>{const e=y.current;if(!e||(e.editor.setTheme(Y(O)),O!=="auto"||typeof document>"u"))return;const i=()=>{y.current?.editor.setTheme(Y("auto"))},n=new MutationObserver(i);n.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme","class"]});const a=window.matchMedia?.("(prefers-color-scheme: dark)");return a?.addEventListener?.("change",i),()=>{n.disconnect(),a?.removeEventListener?.("change",i)}},[O]),r.useEffect(()=>{const e=c.current;e&&e.updateOptions(oe)},[oe]),r.useEffect(()=>{const e=c.current,i=y.current;if(e&&i){const n=e.getModel();if(n){const a=_.map(k=>({startLineNumber:k.startLineNumber,startColumn:k.startColumn,endLineNumber:k.endLineNumber,endColumn:k.endColumn,message:k.message,severity:k.severity}));i.editor.setModelMarkers(n,"owner",a)}}},[_]),r.useEffect(()=>{const e=c.current;if(e&&z.length>0){const i=z.map(n=>({range:{startLineNumber:n.range.startLineNumber,startColumn:n.range.startColumn,endLineNumber:n.range.endLineNumber,endColumn:n.range.endColumn},options:{className:n.className,glyphMarginClassName:n.glyphMarginClassName,hoverMessage:n.hoverMessage?{value:n.hoverMessage}:void 0,isWholeLine:n.isWholeLine}}));H.current=e.deltaDecorations(H.current,i)}},[z]),r.useEffect(()=>{const e=y.current;if(!e||!F)return;D.current?.dispose();const i={text:0,method:1,function:2,constructor:3,field:4,variable:5,class:6,interface:7,module:8,property:9,keyword:13,snippet:14,color:15,file:16,reference:17,folder:18};return D.current=e.languages.registerCompletionItemProvider(f,{provideCompletionItems:async(n,a)=>({suggestions:(await F(n,a)).map(l=>({label:l.label,kind:i[l.kind]??0,insertText:l.insertText,insertTextRules:l.insertTextRules==="insertAsSnippet"?4:void 0,documentation:l.documentation,detail:l.detail,range:{startLineNumber:a.lineNumber,startColumn:a.column,endLineNumber:a.lineNumber,endColumn:a.column}}))})}),()=>{D.current?.dispose()}},[f,F]),r.useImperativeHandle(m,()=>({getEditor:()=>c.current,getMonaco:()=>y.current,focus:()=>c.current?.focus(),getValue:()=>c.current?.getValue()??"",setValue:e=>c.current?.setValue(e),getSelection:()=>{const e=c.current;if(!e)return"";const i=e.getSelection();return i?e.getModel()?.getValueInRange(i)??"":""},insertText:e=>{const i=c.current;if(!i)return;const n=i.getSelection();n&&i.executeEdits("",[{range:n,text:e}])},formatDocument:()=>{c.current?.getAction("editor.action.formatDocument")?.run()},goToLine:(e,i=1)=>{const n=c.current;n&&(n.setPosition({lineNumber:e,column:i}),n.revealLineInCenter(e),n.focus())},findReplace:()=>{c.current?.getAction("editor.action.startFindReplaceAction")?.run()},undo:()=>{c.current?.trigger("keyboard","undo",null)},redo:()=>{c.current?.trigger("keyboard","redo",null)},getCursorPosition:()=>{const e=c.current?.getPosition();return{lineNumber:e?.lineNumber??1,column:e?.column??1}},setMarkers:e=>{const i=c.current,n=y.current;if(i&&n){const a=i.getModel();if(a){const k=e.map(l=>({startLineNumber:l.startLineNumber,startColumn:l.startColumn,endLineNumber:l.endLineNumber,endColumn:l.endColumn,message:l.message,severity:l.severity}));n.editor.setModelMarkers(a,"owner",k)}}}}),[]);const V=r.useMemo(()=>({format:()=>c.current?.getAction("editor.action.formatDocument")?.run(),undo:()=>c.current?.trigger("keyboard","undo",null),redo:()=>c.current?.trigger("keyboard","redo",null),find:()=>c.current?.getAction("editor.action.startFindReplaceAction")?.run(),toggleWordWrap:()=>{const e=!re;_e(e),c.current?.updateOptions({wordWrap:e?"on":"off"})},toggleMinimap:()=>{const e=c.current?.getOption?.(y.current?.editor?.EditorOption?.minimap);c.current?.updateOptions({minimap:{enabled:!e?.enabled}})},foldAll:()=>c.current?.getAction("editor.foldAll")?.run(),unfoldAll:()=>c.current?.getAction("editor.unfoldAll")?.run()}),[re]),Ne=s.split(`
2
+ `).length,Se=s.length;return t.jsxs("div",{className:`nice-code-editor-wrap nice-editor--${B} ${U??""}`,style:{height:G,width:Z,display:"flex",flexDirection:"column",position:"relative"},"data-testid":$,children:[t.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:20},children:t.jsx(C.NiceTutorialButton,{steps:C.resolveTutorial(p,Oe)})}),ne&&t.jsxs("div",{className:"nice-code-editor__error",style:{position:"absolute",inset:0,zIndex:2,background:"var(--nice-bg-primary, #fff)"},children:[t.jsxs("span",{children:[t.jsx(C.NiceIcon,{name:"warning",size:16})," ",ne]}),t.jsx("textarea",{value:s,onChange:e=>h(e.target.value),readOnly:E||o.readOnly,style:{width:"100%",height:"100%",fontFamily:"monospace"}})]}),K&&!ne&&t.jsx("div",{className:"nice-code-editor__loader-overlay",style:{position:"absolute",inset:0,zIndex:2,display:"flex",alignItems:"center",justifyContent:"center",background:"var(--nice-bg-primary, #fff)"},children:P??t.jsx("div",{className:"nice-code-editor__loader",children:"Loading editor..."})}),W&&t.jsxs("div",{className:"nice-code-editor__toolbar",children:[t.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:V.undo,title:"Undo (Ctrl+Z)","aria-label":"Undo",children:t.jsx(C.NiceIcon,{name:"reply",size:16})}),t.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:V.redo,title:"Redo (Ctrl+Y)","aria-label":"Redo",children:t.jsx(C.NiceIcon,{name:"forward",size:16})}),t.jsx("span",{className:"nice-code-editor__toolbar-sep"}),t.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:V.format,title:"Format (Shift+Alt+F)","aria-label":"Format",children:t.jsx(C.NiceIcon,{name:"type",size:16})}),t.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:V.find,title:"Find & Replace (Ctrl+H)","aria-label":"Find & Replace",children:t.jsx(C.NiceIcon,{name:"search",size:16})}),t.jsx("span",{className:"nice-code-editor__toolbar-sep"}),t.jsx("button",{className:`nice-code-editor__toolbar-btn${re?" nice-code-editor__toolbar-btn--active":""}`,onClick:V.toggleWordWrap,title:"Toggle Word Wrap","aria-label":"Toggle Word Wrap",children:t.jsx(C.NiceIcon,{name:"align-left",size:16})}),t.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:V.toggleMinimap,title:"Toggle Minimap","aria-label":"Toggle Minimap",children:t.jsx(C.NiceIcon,{name:"columns",size:16})}),t.jsx("span",{className:"nice-code-editor__toolbar-sep"}),t.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:V.foldAll,title:"Fold All","aria-label":"Fold All",children:t.jsx(C.NiceIcon,{name:"collapse",size:16})}),t.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:V.unfoldAll,title:"Unfold All","aria-label":"Unfold All",children:t.jsx(C.NiceIcon,{name:"expand",size:16})})]}),t.jsx("div",{ref:b,className:"nice-code-editor",style:{flex:1,minHeight:0}}),M&&t.jsxs("div",{className:"nice-code-editor__statusbar",children:[t.jsxs("span",{children:["Ln ",le.lineNumber,", Col ",le.column]}),ue.length>0&&t.jsxs("span",{children:["(",ue.length," selected)"]}),t.jsx("span",{className:"nice-code-editor__statusbar-spacer"}),t.jsxs("span",{children:[Ne," lines · ",Se," chars"]}),t.jsx("span",{className:"nice-code-editor__statusbar-lang",children:f}),_.length>0&&t.jsxs("span",{className:"nice-code-editor__statusbar-markers",children:[t.jsx(C.NiceIcon,{name:"warning",size:14})," ",_.length]})]})]})});function Pe(d){const{original:u,defaultOriginal:m,modified:v,defaultModified:w,language:R="plaintext",theme:f="auto",height:O=400,width:o="100%",inline:G=!1,renderSideBySide:Z=!0,originalEditable:_=!1,modifiedEditable:z=!1,onOriginalChange:F,onModifiedChange:g,loading:A,className:I,"data-testid":T}=d,[P,E,W]=C.useControllableState({value:u,defaultValue:m,fallbackValue:"",onChange:F,componentName:"NiceCodeDiffEditor.original"}),[M,B,U]=C.useControllableState({value:v,defaultValue:w,fallbackValue:"",onChange:g,componentName:"NiceCodeDiffEditor.modified"}),$=r.useRef({currentOriginal:P,currentModified:M,setOriginal:E,setModified:B});$.current={currentOriginal:P,currentModified:M,setOriginal:E,setModified:B};const N=r.useRef(!1),S=r.useRef(null),p=r.useRef(null),s=r.useRef(null),[h,j]=r.useState(!0),[L,q]=r.useState(null);return r.useEffect(()=>{if(!S.current)return;let x=!0;return xe().then(b=>{if(!x||!S.current)return;s.current=b;const{currentOriginal:c,currentModified:y}=$.current,H=b.editor.createModel(c,R),D=b.editor.createModel(y,R),K=b.editor.createDiffEditor(S.current,{automaticLayout:!0,theme:Y(f),renderSideBySide:!G&&Z,originalEditable:_,readOnly:!z});K.setModel({original:H,modified:D}),p.current=K,j(!1),_&&H.onDidChangeContent(()=>{N.current||$.current.setOriginal(H.getValue())}),z&&D.onDidChangeContent(()=>{N.current||$.current.setModified(D.getValue())})}).catch(b=>{x&&(q(b.message??"Failed to load diff editor"),j(!1))}),()=>{x=!1,p.current?.dispose()}},[]),r.useEffect(()=>{const x=p.current?.getModel();if(x){N.current=!0;try{W&&x.original.getValue()!==P&&x.original.setValue(P),U&&x.modified.getValue()!==M&&x.modified.setValue(M)}finally{N.current=!1}}},[P,M,W,U]),r.useEffect(()=>{const x=s.current;if(!x||(x.editor.setTheme(Y(f)),f!=="auto"||typeof document>"u"))return;const b=()=>{s.current?.editor.setTheme(Y("auto"))},c=new MutationObserver(b);c.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme","class"]});const y=window.matchMedia?.("(prefers-color-scheme: dark)");return y?.addEventListener?.("change",b),()=>{c.disconnect(),y?.removeEventListener?.("change",b)}},[f,h]),L?t.jsx("div",{className:`nice-code-diff-editor nice-code-diff-editor--error ${I??""}`,style:{height:O,width:o},"data-testid":T,children:t.jsx("div",{className:"nice-code-editor__error",children:t.jsxs("span",{children:[t.jsx(C.NiceIcon,{name:"warning",size:16})," ",L]})})}):t.jsxs("div",{className:`nice-code-diff-editor ${I??""}`,style:{height:O,width:o,position:"relative"},"data-testid":T,children:[t.jsx("div",{ref:S,style:{position:"absolute",inset:0}}),h&&t.jsx("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",background:"var(--nice-bg-primary, #fff)",zIndex:2},children:A??t.jsx("div",{className:"nice-code-editor__loader",children:"Loading diff editor..."})})]})}const ze="1.29.0",be=`https://cdn.jsdelivr.net/npm/prismjs@${ze}`;let ie=null;const se={javascript:"javascript",typescript:"typescript",json:"json",html:"markup",css:"css",scss:"scss",less:"less",markdown:"markdown",xml:"markup",yaml:"yaml",sql:"sql",python:"python",csharp:"csharp",java:"java",cpp:"cpp",c:"c",go:"go",rust:"rust",php:"php",ruby:"ruby",shell:"bash",powershell:"powershell",plaintext:"plain"};function te(d){return new Promise((u,m)=>{if(document.querySelector(`script[data-prism-src="${d}"]`)){u();return}const v=document.createElement("script");v.src=d,v.async=!0,v.dataset.prismSrc=d,v.onload=()=>u(),v.onerror=()=>m(new Error(`Failed to load ${d}`)),document.head.appendChild(v)})}function Ae(d){if(typeof window>"u")return Promise.resolve(null);const u=window,m=se[d]??"plain",v=async()=>{if(m!=="plain"&&!u.Prism?.languages?.[m])try{await te(`${be}/components/prism-${m}.min.js`)}catch{}};return u.Prism?.languages?v().then(()=>u.Prism):(ie||(ie=(async()=>(window.Prism={manual:!0},await te(`${be}/prism.min.js`),window.Prism))()),ie.then(async()=>(await v(),window.Prism)))}function ce(d){return d.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function De(d){const{value:u,defaultValue:m,onChange:v,language:w="plaintext",height:R=300,width:f="100%",readOnly:O=!1,tabSize:o=2,lineNumbers:G=!0,placeholder:Z,theme:_="auto",className:z,"data-testid":F}=d,[g,A]=C.useControllableState({value:u,defaultValue:m,fallbackValue:"",onChange:v,componentName:"NiceSimpleCodeEditor"}),I=r.useRef(null),T=r.useRef(null),[P,E]=r.useState(()=>ce(g)),[W,M]=r.useState("light");r.useEffect(()=>{const p=()=>{if(_!=="auto")return _;if(typeof document>"u")return"light";const L=document.documentElement.dataset.theme;return L==="dark"?"dark":L==="light"?"light":window.matchMedia?.("(prefers-color-scheme: dark)").matches?"dark":"light"};if(M(p()),_!=="auto"||typeof document>"u")return;const s=()=>M(p()),h=new MutationObserver(s);h.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme","class"]});const j=window.matchMedia?.("(prefers-color-scheme: dark)");return j?.addEventListener?.("change",s),()=>{h.disconnect(),j?.removeEventListener?.("change",s)}},[_]),r.useEffect(()=>{let p=!0;return Ae(w).then(s=>{if(!p)return;const h=se[w]??"plain";if(s?.languages?.[h])try{const j=s.highlight(g,s.languages[h],h);E(j);return}catch{}E(ce(g))}).catch(()=>{p&&E(ce(g))}),()=>{p=!1}},[g,w]);const B=r.useCallback(()=>{!T.current||!I.current||(T.current.scrollTop=I.current.scrollTop,T.current.scrollLeft=I.current.scrollLeft)},[]),U=r.useCallback(p=>{if(p.key==="Tab"){p.preventDefault();const s=p.currentTarget,h=s.selectionStart,j=s.selectionEnd,L=" ".repeat(o);if(p.shiftKey){const b=g.substring(0,h).lastIndexOf(`
3
+ `)+1;if((g.substring(b,h).match(/^(\s*)/)?.[1]??"").length>=o){const y=g.substring(0,b)+g.substring(b+o);A(y),setTimeout(()=>{s.selectionStart=s.selectionEnd=h-o},0)}}else{const q=g.substring(0,h)+L+g.substring(j);A(q),setTimeout(()=>{s.selectionStart=s.selectionEnd=h+o},0)}}},[g,A,o]),N=g.split(`
4
+ `).length,S=se[w]??"plain";return t.jsxs("div",{className:`nice-simple-code-editor nice-simple-code-editor--${W} ${z??""}`,style:{height:R,width:f},"data-testid":F,"data-language":w,"data-theme":W,children:[G&&t.jsx("div",{className:"nice-simple-code-editor__line-numbers",children:Array.from({length:N},(p,s)=>t.jsx("div",{className:"nice-simple-code-editor__line-number",children:s+1},s))}),t.jsxs("div",{className:"nice-simple-code-editor__editor-area",children:[t.jsx("pre",{ref:T,"aria-hidden":"true",className:`nice-simple-code-editor__highlight language-${S}`,children:t.jsx("code",{className:`language-${S}`,dangerouslySetInnerHTML:{__html:P+(g.endsWith(`
5
+ `)?`
6
+ `:"")}})}),t.jsx("textarea",{ref:I,className:"nice-simple-code-editor__textarea",value:g,onChange:p=>A(p.target.value),onKeyDown:U,onScroll:B,readOnly:O,placeholder:Z,spellCheck:!1,autoCapitalize:"off",autoCorrect:"off"})]})]})}const ke="nice-code-editor-styles";if(typeof document<"u"&&!document.getElementById(ke)){const d=document.createElement("style");d.id=ke,d.textContent=`
7
+ .nice-code-editor,
8
+ .nice-code-diff-editor {
9
+ border: 1px solid var(--nice-border, #e0e0e0);
10
+ border-radius: var(--nice-radius-sm, 4px);
11
+ overflow: hidden;
12
+ }
13
+
14
+ .nice-code-editor--loading,
15
+ .nice-code-editor--error,
16
+ .nice-code-diff-editor--loading {
17
+ display: flex;
18
+ align-items: center;
19
+ justify-content: center;
20
+ background: var(--nice-bg-tertiary, #f5f5f5);
21
+ }
22
+
23
+ .nice-code-editor__loader {
24
+ color: var(--nice-text-secondary, #666);
25
+ font-size: 14px;
26
+ }
27
+
28
+ .nice-code-editor__error {
29
+ display: flex;
30
+ flex-direction: column;
31
+ width: 100%;
32
+ height: 100%;
33
+ padding: var(--nice-space-2, 8px);
34
+ gap: var(--nice-space-2, 8px);
35
+ }
36
+
37
+ .nice-code-editor__error span {
38
+ color: var(--nice-error, #d32f2f);
39
+ }
40
+
41
+ /* Simple code editor */
42
+ .nice-simple-code-editor {
43
+ display: flex;
44
+ border: 1px solid var(--nice-border-color, var(--nice-border, #e0e0e0));
45
+ border-radius: var(--nice-radius-sm, 4px);
46
+ overflow: hidden;
47
+ font-family: 'Fira Code', 'Consolas', 'Monaco', monospace;
48
+ font-size: 14px;
49
+ line-height: 1.5;
50
+ background: var(--nice-bg-primary, var(--nice-bg-surface, #fff));
51
+ color: var(--nice-text-primary, var(--nice-text-primary, #333));
52
+ }
53
+ .nice-simple-code-editor--dark {
54
+ background: var(--nice-bg, #1e1e1e);
55
+ color: var(--nice-text, #d4d4d4);
56
+ }
57
+
58
+ .nice-simple-code-editor__line-numbers {
59
+ padding: var(--nice-space-2, 8px) 0;
60
+ background: var(--nice-bg-secondary, var(--nice-bg-tertiary, #f5f5f5));
61
+ border-right: 1px solid var(--nice-border-color, var(--nice-border, #e0e0e0));
62
+ user-select: none;
63
+ text-align: right;
64
+ color: var(--nice-text-secondary, var(--nice-text-secondary, #999));
65
+ overflow: hidden;
66
+ }
67
+ .nice-simple-code-editor--dark .nice-simple-code-editor__line-numbers {
68
+ background: var(--nice-bg-secondary, #252526);
69
+ border-right-color: var(--nice-border, #3c3c3c);
70
+ color: var(--nice-text-muted, #858585);
71
+ }
72
+
73
+ .nice-simple-code-editor__line-number {
74
+ padding: 0 var(--nice-space-3, 12px);
75
+ min-width: 40px;
76
+ }
77
+
78
+ .nice-simple-code-editor__editor-area {
79
+ position: relative;
80
+ flex: 1;
81
+ overflow: hidden;
82
+ }
83
+
84
+ .nice-simple-code-editor__highlight,
85
+ .nice-simple-code-editor__textarea {
86
+ position: absolute;
87
+ inset: 0;
88
+ margin: 0;
89
+ padding: var(--nice-space-2, 8px) var(--nice-space-3, 12px);
90
+ border: 0;
91
+ font: inherit;
92
+ line-height: inherit;
93
+ white-space: pre;
94
+ overflow: auto;
95
+ tab-size: 2;
96
+ }
97
+
98
+ .nice-simple-code-editor__highlight {
99
+ pointer-events: none;
100
+ background: transparent;
101
+ color: inherit;
102
+ }
103
+ .nice-simple-code-editor__highlight code {
104
+ font: inherit;
105
+ background: transparent;
106
+ }
107
+
108
+ .nice-simple-code-editor__textarea {
109
+ background: transparent;
110
+ color: transparent;
111
+ caret-color: var(--nice-text-primary, var(--nice-text-primary, #333));
112
+ resize: none;
113
+ outline: none;
114
+ -webkit-text-fill-color: transparent;
115
+ }
116
+ .nice-simple-code-editor--dark .nice-simple-code-editor__textarea {
117
+ caret-color: var(--nice-text, #d4d4d4);
118
+ }
119
+
120
+ .nice-simple-code-editor__textarea::placeholder {
121
+ color: var(--nice-text-secondary, var(--nice-text-secondary, #999));
122
+ -webkit-text-fill-color: var(--nice-text-secondary, var(--nice-text-secondary, #999));
123
+ }
124
+ .nice-simple-code-editor--dark .nice-simple-code-editor__textarea::placeholder {
125
+ color: var(--nice-text-muted, #858585);
126
+ -webkit-text-fill-color: var(--nice-text-muted, #858585);
127
+ }
128
+
129
+ /* Prism token colors — light */
130
+ .nice-simple-code-editor .token.comment,
131
+ .nice-simple-code-editor .token.prolog,
132
+ .nice-simple-code-editor .token.doctype,
133
+ .nice-simple-code-editor .token.cdata { color: #6a737d; font-style: italic; }
134
+ .nice-simple-code-editor .token.punctuation { color: #586069; }
135
+ .nice-simple-code-editor .token.property,
136
+ .nice-simple-code-editor .token.tag,
137
+ .nice-simple-code-editor .token.boolean,
138
+ .nice-simple-code-editor .token.number,
139
+ .nice-simple-code-editor .token.constant,
140
+ .nice-simple-code-editor .token.symbol,
141
+ .nice-simple-code-editor .token.deleted { color: #005cc5; }
142
+ .nice-simple-code-editor .token.selector,
143
+ .nice-simple-code-editor .token.attr-name,
144
+ .nice-simple-code-editor .token.string,
145
+ .nice-simple-code-editor .token.char,
146
+ .nice-simple-code-editor .token.builtin,
147
+ .nice-simple-code-editor .token.inserted { color: #032f62; }
148
+ .nice-simple-code-editor .token.operator,
149
+ .nice-simple-code-editor .token.entity,
150
+ .nice-simple-code-editor .token.url,
151
+ .nice-simple-code-editor .token.variable { color: var(--nice-danger, #d73a49); }
152
+ .nice-simple-code-editor .token.atrule,
153
+ .nice-simple-code-editor .token.attr-value,
154
+ .nice-simple-code-editor .token.keyword { color: var(--nice-danger, #d73a49); font-weight: 600; }
155
+ .nice-simple-code-editor .token.function,
156
+ .nice-simple-code-editor .token.class-name { color: #6f42c1; }
157
+ .nice-simple-code-editor .token.regex,
158
+ .nice-simple-code-editor .token.important { color: #e36209; }
159
+
160
+ /* Prism token colors — dark */
161
+ .nice-simple-code-editor--dark .token.comment,
162
+ .nice-simple-code-editor--dark .token.prolog,
163
+ .nice-simple-code-editor--dark .token.doctype,
164
+ .nice-simple-code-editor--dark .token.cdata { color: var(--nice-success, #6a9955); font-style: italic; }
165
+ .nice-simple-code-editor--dark .token.punctuation { color: var(--nice-text, #d4d4d4); }
166
+ .nice-simple-code-editor--dark .token.property,
167
+ .nice-simple-code-editor--dark .token.tag,
168
+ .nice-simple-code-editor--dark .token.boolean,
169
+ .nice-simple-code-editor--dark .token.number,
170
+ .nice-simple-code-editor--dark .token.constant,
171
+ .nice-simple-code-editor--dark .token.symbol,
172
+ .nice-simple-code-editor--dark .token.deleted { color: var(--nice-success-light, #b5cea8); }
173
+ .nice-simple-code-editor--dark .token.selector,
174
+ .nice-simple-code-editor--dark .token.attr-name,
175
+ .nice-simple-code-editor--dark .token.string,
176
+ .nice-simple-code-editor--dark .token.char,
177
+ .nice-simple-code-editor--dark .token.builtin,
178
+ .nice-simple-code-editor--dark .token.inserted { color: var(--nice-warning, #ce9178); }
179
+ .nice-simple-code-editor--dark .token.operator,
180
+ .nice-simple-code-editor--dark .token.entity,
181
+ .nice-simple-code-editor--dark .token.url,
182
+ .nice-simple-code-editor--dark .token.variable { color: var(--nice-primary, #569cd6); }
183
+ .nice-simple-code-editor--dark .token.atrule,
184
+ .nice-simple-code-editor--dark .token.attr-value,
185
+ .nice-simple-code-editor--dark .token.keyword { color: #c586c0; font-weight: 600; }
186
+ .nice-simple-code-editor--dark .token.function,
187
+ .nice-simple-code-editor--dark .token.class-name { color: #dcdcaa; }
188
+ .nice-simple-code-editor--dark .token.regex,
189
+ .nice-simple-code-editor--dark .token.important { color: #d7ba7d; }
190
+
191
+ /* Toolbar */
192
+ .nice-code-editor-wrap {
193
+ border: 1px solid var(--nice-border, #e0e0e0);
194
+ border-radius: var(--nice-radius-sm, 4px);
195
+ overflow: hidden;
196
+ }
197
+ .nice-code-editor-wrap .nice-code-editor {
198
+ border: none;
199
+ border-radius: 0;
200
+ }
201
+ .nice-code-editor__toolbar {
202
+ display: flex;
203
+ align-items: center;
204
+ gap: var(--nice-space-0-5, 2px);
205
+ padding: var(--nice-space-0-75, 3px) var(--nice-space-1-5, 6px);
206
+ background: var(--nice-bg-tertiary, #f5f5f5);
207
+ border-bottom: 1px solid var(--nice-border, #e0e0e0);
208
+ }
209
+ .nice-code-editor__toolbar-btn {
210
+ display: inline-flex;
211
+ align-items: center;
212
+ justify-content: center;
213
+ width: 26px;
214
+ height: 26px;
215
+ border: none;
216
+ border-radius: var(--nice-radius-sm, 3px);
217
+ background: transparent;
218
+ color: var(--nice-text-secondary, #666);
219
+ cursor: pointer;
220
+ font-size: 14px;
221
+ transition: background 0.15s, color 0.15s;
222
+ }
223
+ .nice-code-editor__toolbar-btn:hover {
224
+ background: var(--nice-hover-bg, #e0e0e0);
225
+ color: var(--nice-text-primary, #333);
226
+ }
227
+ .nice-code-editor__toolbar-btn--active {
228
+ background: var(--nice-accent, #1976d2);
229
+ color: var(--nice-text-on-primary, #FFF);
230
+ }
231
+ .nice-code-editor__toolbar-sep {
232
+ width: 1px;
233
+ height: 18px;
234
+ background: var(--nice-border, #e0e0e0);
235
+ margin: 0 var(--nice-space-1, 4px);
236
+ }
237
+
238
+ /* Status bar */
239
+ .nice-code-editor__statusbar {
240
+ display: flex;
241
+ align-items: center;
242
+ gap: var(--nice-space-3, 12px);
243
+ padding: var(--nice-space-0-5, 2px) var(--nice-space-2-5, 10px);
244
+ background: var(--nice-bg-tertiary, #f5f5f5);
245
+ border-top: 1px solid var(--nice-border, #e0e0e0);
246
+ font-size: 12px;
247
+ color: var(--nice-text-secondary, #666);
248
+ user-select: none;
249
+ }
250
+ .nice-code-editor__statusbar-spacer { flex: 1; }
251
+ .nice-code-editor__statusbar-lang {
252
+ text-transform: uppercase;
253
+ font-weight: 600;
254
+ font-size: 11px;
255
+ }
256
+ .nice-code-editor__statusbar-markers {
257
+ color: var(--nice-warning, #f39c12);
258
+ font-weight: 600;
259
+ }
260
+ `,document.head.appendChild(d)}exports.NiceCodeDiffEditor=Pe;exports.NiceCodeEditor=Te;exports.NiceSimpleCodeEditor=De;
@@ -0,0 +1,260 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),C=require("@nice2dev/ui-core"),r=require("react"),Re=[{target:".nice-code-editor-wrap",titleKey:"tutorial.codeEditor.intro.title",title:"Code editor",contentKey:"tutorial.codeEditor.intro.content",content:"Edit code with syntax highlighting, IntelliSense and the toolbar. Ctrl+S saves; the status bar shows the cursor position and any problems.",placement:"auto"}];let Q=null,J=null;const Oe="0.45.0",te=`https://cdn.jsdelivr.net/npm/monaco-editor@${Oe}/min/vs`,ge=15e3;function he(){const d=window;if(d.MonacoEnvironment?.getWorkerUrl)return;const u=`self.MonacoEnvironment={baseUrl:'${te}/'};importScripts('${te}/base/worker/workerMain.js');`,m=URL.createObjectURL(new Blob([u],{type:"text/javascript"}));d.MonacoEnvironment={getWorkerUrl:()=>m}}function Y(d){if(d!=="auto")return d;if(typeof document>"u")return"vs";const u=document.documentElement.dataset.theme;return u==="dark"?"vs-dark":u==="light"?"vs":window.matchMedia?.("(prefers-color-scheme: dark)").matches?"vs-dark":"vs"}function ve(){return J?Promise.resolve(J):Q||(Q=new Promise((d,u)=>{if(window.monaco){he(),J=window.monaco,d(J);return}let m=!1;const v=window.setTimeout(()=>{m||(m=!0,Q=null,u(new Error(`Monaco editor failed to load within ${ge}ms`)))},ge),w=document.createElement("script");w.src=`${te}/loader.min.js`,w.async=!0,w.onload=()=>{const R=window.require;R.config({paths:{vs:te}}),he(),R(["vs/editor/editor.main"],f=>{m||(m=!0,window.clearTimeout(v),J=f,d(f))})},w.onerror=()=>{m||(m=!0,window.clearTimeout(v),Q=null,u(new Error("Failed to load Monaco Editor loader script")))},document.head.appendChild(w)}),Q)}const Ie=r.forwardRef(function(u,m){const{value:v,defaultValue:w,onChange:R,language:f="plaintext",theme:O="auto",options:o={},height:G=400,width:Z="100%",markers:_=[],decorations:z=[],completionProvider:F,onMount:g,onCursorPositionChange:A,onSelectionChange:I,onSave:T,loading:P,disabled:E=!1,showToolbar:W=!1,showStatusBar:M=!1,editorSize:B="standard",className:U,"data-testid":$,lsp:N,extraLibs:S,tutorial:p}=u,[s,h,j]=C.useControllableState({value:v,defaultValue:w,fallbackValue:"",onChange:R,componentName:"NiceCodeEditor"}),L=r.useRef(h);L.current=h;const q=r.useRef(s);q.current=s;const x=r.useRef(!1),b=r.useRef(null),c=r.useRef(null),y=r.useRef(null),H=r.useRef([]),D=r.useRef(null),[K,de]=r.useState(!0),[re,xe]=r.useState(null),[le,ye]=r.useState({lineNumber:1,column:1}),[ue,Ce]=r.useState(""),[oe,we]=r.useState(o.wordWrap==="on"),ie=r.useMemo(()=>({automaticLayout:!0,readOnly:E||o.readOnly,minimap:{enabled:o.minimap??!0},lineNumbers:o.lineNumbers??"on",wordWrap:o.wordWrap??"off",tabSize:o.tabSize??2,insertSpaces:o.insertSpaces??!0,fontSize:o.fontSize??14,fontFamily:o.fontFamily??"'Fira Code', 'Consolas', 'Monaco', monospace",fontLigatures:o.fontLigatures??!0,cursorStyle:o.cursorStyle??"line",cursorBlinking:o.cursorBlinking??"blink",autoClosingBrackets:o.autoClosingBrackets??"languageDefined",autoClosingQuotes:o.autoClosingQuotes??"languageDefined",formatOnPaste:o.formatOnPaste??!1,formatOnType:o.formatOnType??!1,renderWhitespace:o.renderWhitespace??"selection",renderControlCharacters:o.renderControlCharacters??!1,scrollBeyondLastLine:o.scrollBeyondLastLine??!0,smoothScrolling:o.smoothScrolling??!0,folding:o.folding??!0,showFoldingControls:o.showFoldingControls??"mouseover","bracketPairColorization.enabled":o.bracketPairColorization??!0,guides:o.guides??{bracketPairs:!0,indentation:!0,highlightActiveIndentation:!0},stickyScroll:{enabled:o.stickyScroll??!1},quickSuggestions:o.quickSuggestions??!0,suggestOnTriggerCharacters:o.suggestOnTriggerCharacters??!0,acceptSuggestionOnEnter:o.acceptSuggestionOnEnter??"on",inlayHints:{enabled:o.inlayHints?"on":"off"}}),[o,E]);r.useEffect(()=>{if(!b.current)return;let e=!0;return ve().then(async i=>{if(!e||!b.current)return;y.current=i;const n=i.editor.create(b.current,{value:q.current,language:f,theme:Y(O),...ie});if(c.current=n,de(!1),n.onDidChangeModelContent(()=>{x.current||L.current(n.getValue())}),n.onDidChangeCursorPosition(a=>{ye({lineNumber:a.position.lineNumber,column:a.position.column}),A?.({lineNumber:a.position.lineNumber,column:a.position.column})}),n.onDidChangeCursorSelection(a=>{const k=a.selection,l=n.getModel()?.getValueInRange(k)??"";Ce(l),I?.({startLineNumber:k.startLineNumber,startColumn:k.startColumn,endLineNumber:k.endLineNumber,endColumn:k.endColumn})}),n.addCommand(i.KeyMod.CtrlCmd|i.KeyCode.KeyS,()=>{T?.(n.getValue())}),N&&typeof window<"u")try{await ne("https://cdn.jsdelivr.net/npm/vscode-ws-jsonrpc@1.0.2/lib/browser/index.min.js"),await ne("https://cdn.jsdelivr.net/npm/monaco-languageclient@0.15.0/lib/monaco-languageclient.min.js");const a=window,k=a.ReconnectingWebSocket,{MonacoLanguageClient:l,CloseAction:X,ErrorAction:ee,createConnection:me}=a.monacoLanguageClient||{};if(l&&me){const Se=N.url,je=N.language,pe=new k(Se),Ee=new a.VSCodeWebSocketMessageReader(pe),Me=new a.VSCodeWebSocketMessageWriter(pe),Le=me(Ee,Me),fe=new l({name:"LSP Client",clientOptions:{documentSelector:[je],initializationOptions:N.initOptions,errorHandler:{error:()=>ee.Continue,closed:()=>X.Restart}},connectionProvider:{get:()=>Promise.resolve(Le)}});fe.start(),c.current.__lspClient=fe}}catch(a){console.warn("LSP bridge failed to load:",a)}g?.(n,i)}).catch(i=>{e&&(xe(i.message??"Failed to load editor"),de(!1))}),()=>{if(e=!1,c.current?.dispose(),D.current?.dispose(),c.current&&c.current.__lspClient)try{c.current.__lspClient.stop()}catch{}}},[N]),r.useEffect(()=>{const e=c.current;if(!j||!e||s===e.getValue())return;const i=e.getPosition();x.current=!0;try{e.setValue(s)}finally{x.current=!1}i&&e.setPosition(i)},[s,j]),r.useEffect(()=>{const e=c.current,i=y.current;if(e&&i){const n=e.getModel();n&&i.editor.setModelLanguage(n,f)}},[f]),r.useEffect(()=>{const e=y.current;if(!e||K||!S||S.length===0||f!=="javascript"&&f!=="typescript")return;const i=e.languages?.typescript;if(!i)return;const n=[];try{S.forEach((a,k)=>{const l=a.filePath??`inmemory://model/nice-extralib-${k}.d.ts`,X=i.typescriptDefaults?.addExtraLib(a.content,l);X&&n.push(X);const ee=i.javascriptDefaults?.addExtraLib(a.content,l);ee&&n.push(ee)})}catch(a){console.warn("Failed to register extraLibs:",a)}return()=>{n.forEach(a=>{try{a.dispose()}catch{}})}},[S,f,K]),r.useEffect(()=>{const e=y.current;if(!e||(e.editor.setTheme(Y(O)),O!=="auto"||typeof document>"u"))return;const i=()=>{y.current?.editor.setTheme(Y("auto"))},n=new MutationObserver(i);n.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme","class"]});const a=window.matchMedia?.("(prefers-color-scheme: dark)");return a?.addEventListener?.("change",i),()=>{n.disconnect(),a?.removeEventListener?.("change",i)}},[O]),r.useEffect(()=>{const e=c.current;e&&e.updateOptions(ie)},[ie]),r.useEffect(()=>{const e=c.current,i=y.current;if(e&&i){const n=e.getModel();if(n){const a=_.map(k=>({startLineNumber:k.startLineNumber,startColumn:k.startColumn,endLineNumber:k.endLineNumber,endColumn:k.endColumn,message:k.message,severity:k.severity}));i.editor.setModelMarkers(n,"owner",a)}}},[_]),r.useEffect(()=>{const e=c.current;if(e&&z.length>0){const i=z.map(n=>({range:{startLineNumber:n.range.startLineNumber,startColumn:n.range.startColumn,endLineNumber:n.range.endLineNumber,endColumn:n.range.endColumn},options:{className:n.className,glyphMarginClassName:n.glyphMarginClassName,hoverMessage:n.hoverMessage?{value:n.hoverMessage}:void 0,isWholeLine:n.isWholeLine}}));H.current=e.deltaDecorations(H.current,i)}},[z]),r.useEffect(()=>{const e=y.current;if(!e||!F)return;D.current?.dispose();const i={text:0,method:1,function:2,constructor:3,field:4,variable:5,class:6,interface:7,module:8,property:9,keyword:13,snippet:14,color:15,file:16,reference:17,folder:18};return D.current=e.languages.registerCompletionItemProvider(f,{provideCompletionItems:async(n,a)=>({suggestions:(await F(n,a)).map(l=>({label:l.label,kind:i[l.kind]??0,insertText:l.insertText,insertTextRules:l.insertTextRules==="insertAsSnippet"?4:void 0,documentation:l.documentation,detail:l.detail,range:{startLineNumber:a.lineNumber,startColumn:a.column,endLineNumber:a.lineNumber,endColumn:a.column}}))})}),()=>{D.current?.dispose()}},[f,F]),r.useImperativeHandle(m,()=>({getEditor:()=>c.current,getMonaco:()=>y.current,focus:()=>c.current?.focus(),getValue:()=>c.current?.getValue()??"",setValue:e=>c.current?.setValue(e),getSelection:()=>{const e=c.current;if(!e)return"";const i=e.getSelection();return i?e.getModel()?.getValueInRange(i)??"":""},insertText:e=>{const i=c.current;if(!i)return;const n=i.getSelection();n&&i.executeEdits("",[{range:n,text:e}])},formatDocument:()=>{c.current?.getAction("editor.action.formatDocument")?.run()},goToLine:(e,i=1)=>{const n=c.current;n&&(n.setPosition({lineNumber:e,column:i}),n.revealLineInCenter(e),n.focus())},findReplace:()=>{c.current?.getAction("editor.action.startFindReplaceAction")?.run()},undo:()=>{c.current?.trigger("keyboard","undo",null)},redo:()=>{c.current?.trigger("keyboard","redo",null)},getCursorPosition:()=>{const e=c.current?.getPosition();return{lineNumber:e?.lineNumber??1,column:e?.column??1}},setMarkers:e=>{const i=c.current,n=y.current;if(i&&n){const a=i.getModel();if(a){const k=e.map(l=>({startLineNumber:l.startLineNumber,startColumn:l.startColumn,endLineNumber:l.endLineNumber,endColumn:l.endColumn,message:l.message,severity:l.severity}));n.editor.setModelMarkers(a,"owner",k)}}}}),[]);const V=r.useMemo(()=>({format:()=>c.current?.getAction("editor.action.formatDocument")?.run(),undo:()=>c.current?.trigger("keyboard","undo",null),redo:()=>c.current?.trigger("keyboard","redo",null),find:()=>c.current?.getAction("editor.action.startFindReplaceAction")?.run(),toggleWordWrap:()=>{const e=!oe;we(e),c.current?.updateOptions({wordWrap:e?"on":"off"})},toggleMinimap:()=>{const e=c.current?.getOption?.(y.current?.editor?.EditorOption?.minimap);c.current?.updateOptions({minimap:{enabled:!e?.enabled}})},foldAll:()=>c.current?.getAction("editor.foldAll")?.run(),unfoldAll:()=>c.current?.getAction("editor.unfoldAll")?.run()}),[oe]),_e=s.split(`
2
+ `).length,Ne=s.length;return t.jsxs("div",{className:`nice-code-editor-wrap nice-editor--${B} ${U??""}`,style:{height:G,width:Z,display:"flex",flexDirection:"column",position:"relative"},"data-testid":$,children:[t.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:20},children:t.jsx(C.NiceTutorialButton,{steps:C.resolveTutorial(p,Re)})}),re&&t.jsxs("div",{className:"nice-code-editor__error",style:{position:"absolute",inset:0,zIndex:2,background:"var(--nice-bg-primary, #fff)"},children:[t.jsxs("span",{children:[t.jsx(C.NiceIcon,{name:"warning",size:16})," ",re]}),t.jsx("textarea",{value:s,onChange:e=>h(e.target.value),readOnly:E||o.readOnly,style:{width:"100%",height:"100%",fontFamily:"monospace"}})]}),K&&!re&&t.jsx("div",{className:"nice-code-editor__loader-overlay",style:{position:"absolute",inset:0,zIndex:2,display:"flex",alignItems:"center",justifyContent:"center",background:"var(--nice-bg-primary, #fff)"},children:P??t.jsx("div",{className:"nice-code-editor__loader",children:"Loading editor..."})}),W&&t.jsxs("div",{className:"nice-code-editor__toolbar",children:[t.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:V.undo,title:"Undo (Ctrl+Z)","aria-label":"Undo",children:t.jsx(C.NiceIcon,{name:"reply",size:16})}),t.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:V.redo,title:"Redo (Ctrl+Y)","aria-label":"Redo",children:t.jsx(C.NiceIcon,{name:"forward",size:16})}),t.jsx("span",{className:"nice-code-editor__toolbar-sep"}),t.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:V.format,title:"Format (Shift+Alt+F)","aria-label":"Format",children:t.jsx(C.NiceIcon,{name:"type",size:16})}),t.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:V.find,title:"Find & Replace (Ctrl+H)","aria-label":"Find & Replace",children:t.jsx(C.NiceIcon,{name:"search",size:16})}),t.jsx("span",{className:"nice-code-editor__toolbar-sep"}),t.jsx("button",{className:`nice-code-editor__toolbar-btn${oe?" nice-code-editor__toolbar-btn--active":""}`,onClick:V.toggleWordWrap,title:"Toggle Word Wrap","aria-label":"Toggle Word Wrap",children:t.jsx(C.NiceIcon,{name:"align-left",size:16})}),t.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:V.toggleMinimap,title:"Toggle Minimap","aria-label":"Toggle Minimap",children:t.jsx(C.NiceIcon,{name:"columns",size:16})}),t.jsx("span",{className:"nice-code-editor__toolbar-sep"}),t.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:V.foldAll,title:"Fold All","aria-label":"Fold All",children:t.jsx(C.NiceIcon,{name:"collapse",size:16})}),t.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:V.unfoldAll,title:"Unfold All","aria-label":"Unfold All",children:t.jsx(C.NiceIcon,{name:"expand",size:16})})]}),t.jsx("div",{ref:b,className:"nice-code-editor",style:{flex:1,minHeight:0}}),M&&t.jsxs("div",{className:"nice-code-editor__statusbar",children:[t.jsxs("span",{children:["Ln ",le.lineNumber,", Col ",le.column]}),ue.length>0&&t.jsxs("span",{children:["(",ue.length," selected)"]}),t.jsx("span",{className:"nice-code-editor__statusbar-spacer"}),t.jsxs("span",{children:[_e," lines · ",Ne," chars"]}),t.jsx("span",{className:"nice-code-editor__statusbar-lang",children:f}),_.length>0&&t.jsxs("span",{className:"nice-code-editor__statusbar-markers",children:[t.jsx(C.NiceIcon,{name:"warning",size:14})," ",_.length]})]})]})});function Te(d){const{original:u,defaultOriginal:m,modified:v,defaultModified:w,language:R="plaintext",theme:f="auto",height:O=400,width:o="100%",inline:G=!1,renderSideBySide:Z=!0,originalEditable:_=!1,modifiedEditable:z=!1,onOriginalChange:F,onModifiedChange:g,loading:A,className:I,"data-testid":T}=d,[P,E,W]=C.useControllableState({value:u,defaultValue:m,fallbackValue:"",onChange:F,componentName:"NiceCodeDiffEditor.original"}),[M,B,U]=C.useControllableState({value:v,defaultValue:w,fallbackValue:"",onChange:g,componentName:"NiceCodeDiffEditor.modified"}),$=r.useRef({currentOriginal:P,currentModified:M,setOriginal:E,setModified:B});$.current={currentOriginal:P,currentModified:M,setOriginal:E,setModified:B};const N=r.useRef(!1),S=r.useRef(null),p=r.useRef(null),s=r.useRef(null),[h,j]=r.useState(!0),[L,q]=r.useState(null);return r.useEffect(()=>{if(!S.current)return;let x=!0;return ve().then(b=>{if(!x||!S.current)return;s.current=b;const{currentOriginal:c,currentModified:y}=$.current,H=b.editor.createModel(c,R),D=b.editor.createModel(y,R),K=b.editor.createDiffEditor(S.current,{automaticLayout:!0,theme:Y(f),renderSideBySide:!G&&Z,originalEditable:_,readOnly:!z});K.setModel({original:H,modified:D}),p.current=K,j(!1),_&&H.onDidChangeContent(()=>{N.current||$.current.setOriginal(H.getValue())}),z&&D.onDidChangeContent(()=>{N.current||$.current.setModified(D.getValue())})}).catch(b=>{x&&(q(b.message??"Failed to load diff editor"),j(!1))}),()=>{x=!1,p.current?.dispose()}},[]),r.useEffect(()=>{const x=p.current?.getModel();if(x){N.current=!0;try{W&&x.original.getValue()!==P&&x.original.setValue(P),U&&x.modified.getValue()!==M&&x.modified.setValue(M)}finally{N.current=!1}}},[P,M,W,U]),r.useEffect(()=>{const x=s.current;if(!x||(x.editor.setTheme(Y(f)),f!=="auto"||typeof document>"u"))return;const b=()=>{s.current?.editor.setTheme(Y("auto"))},c=new MutationObserver(b);c.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme","class"]});const y=window.matchMedia?.("(prefers-color-scheme: dark)");return y?.addEventListener?.("change",b),()=>{c.disconnect(),y?.removeEventListener?.("change",b)}},[f,h]),L?t.jsx("div",{className:`nice-code-diff-editor nice-code-diff-editor--error ${I??""}`,style:{height:O,width:o},"data-testid":T,children:t.jsx("div",{className:"nice-code-editor__error",children:t.jsxs("span",{children:[t.jsx(C.NiceIcon,{name:"warning",size:16})," ",L]})})}):t.jsxs("div",{className:`nice-code-diff-editor ${I??""}`,style:{height:O,width:o,position:"relative"},"data-testid":T,children:[t.jsx("div",{ref:S,style:{position:"absolute",inset:0}}),h&&t.jsx("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",background:"var(--nice-bg-primary, #fff)",zIndex:2},children:A??t.jsx("div",{className:"nice-code-editor__loader",children:"Loading diff editor..."})})]})}const Pe="1.29.0",be=`https://cdn.jsdelivr.net/npm/prismjs@${Pe}`;let ce=null;const se={javascript:"javascript",typescript:"typescript",json:"json",html:"markup",css:"css",scss:"scss",less:"less",markdown:"markdown",xml:"markup",yaml:"yaml",sql:"sql",python:"python",csharp:"csharp",java:"java",cpp:"cpp",c:"c",go:"go",rust:"rust",php:"php",ruby:"ruby",shell:"bash",powershell:"powershell",plaintext:"plain"};function ne(d){return new Promise((u,m)=>{if(document.querySelector(`script[data-prism-src="${d}"]`)){u();return}const v=document.createElement("script");v.src=d,v.async=!0,v.dataset.prismSrc=d,v.onload=()=>u(),v.onerror=()=>m(new Error(`Failed to load ${d}`)),document.head.appendChild(v)})}function ze(d){if(typeof window>"u")return Promise.resolve(null);const u=window,m=se[d]??"plain",v=async()=>{if(m!=="plain"&&!u.Prism?.languages?.[m])try{await ne(`${be}/components/prism-${m}.min.js`)}catch{}};return u.Prism?.languages?v().then(()=>u.Prism):(ce||(ce=(async()=>(window.Prism={manual:!0},await ne(`${be}/prism.min.js`),window.Prism))()),ce.then(async()=>(await v(),window.Prism)))}function ae(d){return d.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Ae(d){const{value:u,defaultValue:m,onChange:v,language:w="plaintext",height:R=300,width:f="100%",readOnly:O=!1,tabSize:o=2,lineNumbers:G=!0,placeholder:Z,theme:_="auto",className:z,"data-testid":F}=d,[g,A]=C.useControllableState({value:u,defaultValue:m,fallbackValue:"",onChange:v,componentName:"NiceSimpleCodeEditor"}),I=r.useRef(null),T=r.useRef(null),[P,E]=r.useState(()=>ae(g)),[W,M]=r.useState("light");r.useEffect(()=>{const p=()=>{if(_!=="auto")return _;if(typeof document>"u")return"light";const L=document.documentElement.dataset.theme;return L==="dark"?"dark":L==="light"?"light":window.matchMedia?.("(prefers-color-scheme: dark)").matches?"dark":"light"};if(M(p()),_!=="auto"||typeof document>"u")return;const s=()=>M(p()),h=new MutationObserver(s);h.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme","class"]});const j=window.matchMedia?.("(prefers-color-scheme: dark)");return j?.addEventListener?.("change",s),()=>{h.disconnect(),j?.removeEventListener?.("change",s)}},[_]),r.useEffect(()=>{let p=!0;return ze(w).then(s=>{if(!p)return;const h=se[w]??"plain";if(s?.languages?.[h])try{const j=s.highlight(g,s.languages[h],h);E(j);return}catch{}E(ae(g))}).catch(()=>{p&&E(ae(g))}),()=>{p=!1}},[g,w]);const B=r.useCallback(()=>{!T.current||!I.current||(T.current.scrollTop=I.current.scrollTop,T.current.scrollLeft=I.current.scrollLeft)},[]),U=r.useCallback(p=>{if(p.key==="Tab"){p.preventDefault();const s=p.currentTarget,h=s.selectionStart,j=s.selectionEnd,L=" ".repeat(o);if(p.shiftKey){const b=g.substring(0,h).lastIndexOf(`
3
+ `)+1;if((g.substring(b,h).match(/^(\s*)/)?.[1]??"").length>=o){const y=g.substring(0,b)+g.substring(b+o);A(y),setTimeout(()=>{s.selectionStart=s.selectionEnd=h-o},0)}}else{const q=g.substring(0,h)+L+g.substring(j);A(q),setTimeout(()=>{s.selectionStart=s.selectionEnd=h+o},0)}}},[g,A,o]),N=g.split(`
4
+ `).length,S=se[w]??"plain";return t.jsxs("div",{className:`nice-simple-code-editor nice-simple-code-editor--${W} ${z??""}`,style:{height:R,width:f},"data-testid":F,"data-language":w,"data-theme":W,children:[G&&t.jsx("div",{className:"nice-simple-code-editor__line-numbers",children:Array.from({length:N},(p,s)=>t.jsx("div",{className:"nice-simple-code-editor__line-number",children:s+1},s))}),t.jsxs("div",{className:"nice-simple-code-editor__editor-area",children:[t.jsx("pre",{ref:T,"aria-hidden":"true",className:`nice-simple-code-editor__highlight language-${S}`,children:t.jsx("code",{className:`language-${S}`,dangerouslySetInnerHTML:{__html:P+(g.endsWith(`
5
+ `)?`
6
+ `:"")}})}),t.jsx("textarea",{ref:I,className:"nice-simple-code-editor__textarea",value:g,onChange:p=>A(p.target.value),onKeyDown:U,onScroll:B,readOnly:O,placeholder:Z,spellCheck:!1,autoCapitalize:"off",autoCorrect:"off"})]})]})}const ke="nice-code-editor-styles";if(typeof document<"u"&&!document.getElementById(ke)){const d=document.createElement("style");d.id=ke,d.textContent=`
7
+ .nice-code-editor,
8
+ .nice-code-diff-editor {
9
+ border: 1px solid var(--nice-border, #e0e0e0);
10
+ border-radius: var(--nice-radius-sm, 4px);
11
+ overflow: hidden;
12
+ }
13
+
14
+ .nice-code-editor--loading,
15
+ .nice-code-editor--error,
16
+ .nice-code-diff-editor--loading {
17
+ display: flex;
18
+ align-items: center;
19
+ justify-content: center;
20
+ background: var(--nice-bg-tertiary, #f5f5f5);
21
+ }
22
+
23
+ .nice-code-editor__loader {
24
+ color: var(--nice-text-secondary, #666);
25
+ font-size: 14px;
26
+ }
27
+
28
+ .nice-code-editor__error {
29
+ display: flex;
30
+ flex-direction: column;
31
+ width: 100%;
32
+ height: 100%;
33
+ padding: var(--nice-space-2, 8px);
34
+ gap: var(--nice-space-2, 8px);
35
+ }
36
+
37
+ .nice-code-editor__error span {
38
+ color: var(--nice-error, #d32f2f);
39
+ }
40
+
41
+ /* Simple code editor */
42
+ .nice-simple-code-editor {
43
+ display: flex;
44
+ border: 1px solid var(--nice-border-color, var(--nice-border, #e0e0e0));
45
+ border-radius: var(--nice-radius-sm, 4px);
46
+ overflow: hidden;
47
+ font-family: 'Fira Code', 'Consolas', 'Monaco', monospace;
48
+ font-size: 14px;
49
+ line-height: 1.5;
50
+ background: var(--nice-bg-primary, var(--nice-bg-surface, #fff));
51
+ color: var(--nice-text-primary, var(--nice-text-primary, #333));
52
+ }
53
+ .nice-simple-code-editor--dark {
54
+ background: var(--nice-bg, #1e1e1e);
55
+ color: var(--nice-text, #d4d4d4);
56
+ }
57
+
58
+ .nice-simple-code-editor__line-numbers {
59
+ padding: var(--nice-space-2, 8px) 0;
60
+ background: var(--nice-bg-secondary, var(--nice-bg-tertiary, #f5f5f5));
61
+ border-right: 1px solid var(--nice-border-color, var(--nice-border, #e0e0e0));
62
+ user-select: none;
63
+ text-align: right;
64
+ color: var(--nice-text-secondary, var(--nice-text-secondary, #999));
65
+ overflow: hidden;
66
+ }
67
+ .nice-simple-code-editor--dark .nice-simple-code-editor__line-numbers {
68
+ background: var(--nice-bg-secondary, #252526);
69
+ border-right-color: var(--nice-border, #3c3c3c);
70
+ color: var(--nice-text-muted, #858585);
71
+ }
72
+
73
+ .nice-simple-code-editor__line-number {
74
+ padding: 0 var(--nice-space-3, 12px);
75
+ min-width: 40px;
76
+ }
77
+
78
+ .nice-simple-code-editor__editor-area {
79
+ position: relative;
80
+ flex: 1;
81
+ overflow: hidden;
82
+ }
83
+
84
+ .nice-simple-code-editor__highlight,
85
+ .nice-simple-code-editor__textarea {
86
+ position: absolute;
87
+ inset: 0;
88
+ margin: 0;
89
+ padding: var(--nice-space-2, 8px) var(--nice-space-3, 12px);
90
+ border: 0;
91
+ font: inherit;
92
+ line-height: inherit;
93
+ white-space: pre;
94
+ overflow: auto;
95
+ tab-size: 2;
96
+ }
97
+
98
+ .nice-simple-code-editor__highlight {
99
+ pointer-events: none;
100
+ background: transparent;
101
+ color: inherit;
102
+ }
103
+ .nice-simple-code-editor__highlight code {
104
+ font: inherit;
105
+ background: transparent;
106
+ }
107
+
108
+ .nice-simple-code-editor__textarea {
109
+ background: transparent;
110
+ color: transparent;
111
+ caret-color: var(--nice-text-primary, var(--nice-text-primary, #333));
112
+ resize: none;
113
+ outline: none;
114
+ -webkit-text-fill-color: transparent;
115
+ }
116
+ .nice-simple-code-editor--dark .nice-simple-code-editor__textarea {
117
+ caret-color: var(--nice-text, #d4d4d4);
118
+ }
119
+
120
+ .nice-simple-code-editor__textarea::placeholder {
121
+ color: var(--nice-text-secondary, var(--nice-text-secondary, #999));
122
+ -webkit-text-fill-color: var(--nice-text-secondary, var(--nice-text-secondary, #999));
123
+ }
124
+ .nice-simple-code-editor--dark .nice-simple-code-editor__textarea::placeholder {
125
+ color: var(--nice-text-muted, #858585);
126
+ -webkit-text-fill-color: var(--nice-text-muted, #858585);
127
+ }
128
+
129
+ /* Prism token colors — light */
130
+ .nice-simple-code-editor .token.comment,
131
+ .nice-simple-code-editor .token.prolog,
132
+ .nice-simple-code-editor .token.doctype,
133
+ .nice-simple-code-editor .token.cdata { color: #6a737d; font-style: italic; }
134
+ .nice-simple-code-editor .token.punctuation { color: #586069; }
135
+ .nice-simple-code-editor .token.property,
136
+ .nice-simple-code-editor .token.tag,
137
+ .nice-simple-code-editor .token.boolean,
138
+ .nice-simple-code-editor .token.number,
139
+ .nice-simple-code-editor .token.constant,
140
+ .nice-simple-code-editor .token.symbol,
141
+ .nice-simple-code-editor .token.deleted { color: #005cc5; }
142
+ .nice-simple-code-editor .token.selector,
143
+ .nice-simple-code-editor .token.attr-name,
144
+ .nice-simple-code-editor .token.string,
145
+ .nice-simple-code-editor .token.char,
146
+ .nice-simple-code-editor .token.builtin,
147
+ .nice-simple-code-editor .token.inserted { color: #032f62; }
148
+ .nice-simple-code-editor .token.operator,
149
+ .nice-simple-code-editor .token.entity,
150
+ .nice-simple-code-editor .token.url,
151
+ .nice-simple-code-editor .token.variable { color: var(--nice-danger, #d73a49); }
152
+ .nice-simple-code-editor .token.atrule,
153
+ .nice-simple-code-editor .token.attr-value,
154
+ .nice-simple-code-editor .token.keyword { color: var(--nice-danger, #d73a49); font-weight: 600; }
155
+ .nice-simple-code-editor .token.function,
156
+ .nice-simple-code-editor .token.class-name { color: #6f42c1; }
157
+ .nice-simple-code-editor .token.regex,
158
+ .nice-simple-code-editor .token.important { color: #e36209; }
159
+
160
+ /* Prism token colors — dark */
161
+ .nice-simple-code-editor--dark .token.comment,
162
+ .nice-simple-code-editor--dark .token.prolog,
163
+ .nice-simple-code-editor--dark .token.doctype,
164
+ .nice-simple-code-editor--dark .token.cdata { color: var(--nice-success, #6a9955); font-style: italic; }
165
+ .nice-simple-code-editor--dark .token.punctuation { color: var(--nice-text, #d4d4d4); }
166
+ .nice-simple-code-editor--dark .token.property,
167
+ .nice-simple-code-editor--dark .token.tag,
168
+ .nice-simple-code-editor--dark .token.boolean,
169
+ .nice-simple-code-editor--dark .token.number,
170
+ .nice-simple-code-editor--dark .token.constant,
171
+ .nice-simple-code-editor--dark .token.symbol,
172
+ .nice-simple-code-editor--dark .token.deleted { color: var(--nice-success-light, #b5cea8); }
173
+ .nice-simple-code-editor--dark .token.selector,
174
+ .nice-simple-code-editor--dark .token.attr-name,
175
+ .nice-simple-code-editor--dark .token.string,
176
+ .nice-simple-code-editor--dark .token.char,
177
+ .nice-simple-code-editor--dark .token.builtin,
178
+ .nice-simple-code-editor--dark .token.inserted { color: var(--nice-warning, #ce9178); }
179
+ .nice-simple-code-editor--dark .token.operator,
180
+ .nice-simple-code-editor--dark .token.entity,
181
+ .nice-simple-code-editor--dark .token.url,
182
+ .nice-simple-code-editor--dark .token.variable { color: var(--nice-primary, #569cd6); }
183
+ .nice-simple-code-editor--dark .token.atrule,
184
+ .nice-simple-code-editor--dark .token.attr-value,
185
+ .nice-simple-code-editor--dark .token.keyword { color: #c586c0; font-weight: 600; }
186
+ .nice-simple-code-editor--dark .token.function,
187
+ .nice-simple-code-editor--dark .token.class-name { color: #dcdcaa; }
188
+ .nice-simple-code-editor--dark .token.regex,
189
+ .nice-simple-code-editor--dark .token.important { color: #d7ba7d; }
190
+
191
+ /* Toolbar */
192
+ .nice-code-editor-wrap {
193
+ border: 1px solid var(--nice-border, #e0e0e0);
194
+ border-radius: var(--nice-radius-sm, 4px);
195
+ overflow: hidden;
196
+ }
197
+ .nice-code-editor-wrap .nice-code-editor {
198
+ border: none;
199
+ border-radius: 0;
200
+ }
201
+ .nice-code-editor__toolbar {
202
+ display: flex;
203
+ align-items: center;
204
+ gap: var(--nice-space-0-5, 2px);
205
+ padding: var(--nice-space-0-75, 3px) var(--nice-space-1-5, 6px);
206
+ background: var(--nice-bg-tertiary, #f5f5f5);
207
+ border-bottom: 1px solid var(--nice-border, #e0e0e0);
208
+ }
209
+ .nice-code-editor__toolbar-btn {
210
+ display: inline-flex;
211
+ align-items: center;
212
+ justify-content: center;
213
+ width: 26px;
214
+ height: 26px;
215
+ border: none;
216
+ border-radius: var(--nice-radius-sm, 3px);
217
+ background: transparent;
218
+ color: var(--nice-text-secondary, #666);
219
+ cursor: pointer;
220
+ font-size: 14px;
221
+ transition: background 0.15s, color 0.15s;
222
+ }
223
+ .nice-code-editor__toolbar-btn:hover {
224
+ background: var(--nice-hover-bg, #e0e0e0);
225
+ color: var(--nice-text-primary, #333);
226
+ }
227
+ .nice-code-editor__toolbar-btn--active {
228
+ background: var(--nice-accent, #1976d2);
229
+ color: var(--nice-text-on-primary, #FFF);
230
+ }
231
+ .nice-code-editor__toolbar-sep {
232
+ width: 1px;
233
+ height: 18px;
234
+ background: var(--nice-border, #e0e0e0);
235
+ margin: 0 var(--nice-space-1, 4px);
236
+ }
237
+
238
+ /* Status bar */
239
+ .nice-code-editor__statusbar {
240
+ display: flex;
241
+ align-items: center;
242
+ gap: var(--nice-space-3, 12px);
243
+ padding: var(--nice-space-0-5, 2px) var(--nice-space-2-5, 10px);
244
+ background: var(--nice-bg-tertiary, #f5f5f5);
245
+ border-top: 1px solid var(--nice-border, #e0e0e0);
246
+ font-size: 12px;
247
+ color: var(--nice-text-secondary, #666);
248
+ user-select: none;
249
+ }
250
+ .nice-code-editor__statusbar-spacer { flex: 1; }
251
+ .nice-code-editor__statusbar-lang {
252
+ text-transform: uppercase;
253
+ font-weight: 600;
254
+ font-size: 11px;
255
+ }
256
+ .nice-code-editor__statusbar-markers {
257
+ color: var(--nice-warning, #f39c12);
258
+ font-weight: 600;
259
+ }
260
+ `,document.head.appendChild(d)}exports.NiceCodeDiffEditor=Te;exports.NiceCodeEditor=Ie;exports.NiceSimpleCodeEditor=Ae;