@nice2dev/ui 1.2.1 → 1.3.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 (118) hide show
  1. package/CHANGELOG.md +476 -0
  2. package/dist/NiceButton-CnAIqCbd.js +101 -0
  3. package/dist/NiceButton-DzCqkG5a.cjs +1 -0
  4. package/dist/NiceCodeEditor-C43xFG8v.cjs +260 -0
  5. package/dist/NiceCodeEditor-CK6B54mu.js +1215 -0
  6. package/dist/NiceCodeEditor-CspuYLh6.js +1174 -0
  7. package/dist/NiceCodeEditor-bJReZPDO.cjs +268 -0
  8. package/dist/NiceColorPicker-BV3olE3M.cjs +1 -0
  9. package/dist/NiceColorPicker-CyY-4q89.js +552 -0
  10. package/dist/NiceDataGrid-BQIqitMM.cjs +10 -0
  11. package/dist/NiceDataGrid-C1eI6Pso.js +2267 -0
  12. package/dist/NiceDataGrid-CrD4HPlO.cjs +10 -0
  13. package/dist/NiceDataGrid-Dfg1DVbU.js +2224 -0
  14. package/dist/NiceForm-CISJyzoW.cjs +1 -0
  15. package/dist/NiceForm-CfAPcXdX.cjs +1 -0
  16. package/dist/NiceForm-DfKYNQti.js +5017 -0
  17. package/dist/NiceForm-DmH6k1b_.js +4775 -0
  18. package/dist/NiceGantt-CHnq-n8f.cjs +1 -0
  19. package/dist/NiceGantt-CX3jVNaF.js +330 -0
  20. package/dist/NiceGantt-TEXbAELi.js +333 -0
  21. package/dist/NiceGantt-s2cgt5zD.cjs +1 -0
  22. package/dist/NiceHtmlEditor-CDZeF_zG.cjs +10 -0
  23. package/dist/NiceHtmlEditor-CdWgddg3.js +901 -0
  24. package/dist/NiceHtmlEditor-DeK0Of98.js +883 -0
  25. package/dist/NiceHtmlEditor-DvVxl4Fu.cjs +10 -0
  26. package/dist/NiceLoginForm-CHXbz0eu.js +747 -0
  27. package/dist/NiceLoginForm-DRPldHXa.js +808 -0
  28. package/dist/NiceLoginForm-IGLUCQUE.cjs +1 -0
  29. package/dist/NiceLoginForm-ix6J1adA.cjs +1 -0
  30. package/dist/NiceMention-CgDp0sl9.cjs +430 -0
  31. package/dist/NiceMention-DBvFvx71.js +11653 -0
  32. package/dist/NiceMention-DKhk3xdM.js +11321 -0
  33. package/dist/NiceMention-wp1AJ5oh.cjs +430 -0
  34. package/dist/NiceMention.css +1 -1
  35. package/dist/NiceModal-BbQwiEOp.cjs +1 -0
  36. package/dist/NiceModal-BlYhFDhP.js +80 -0
  37. package/dist/NiceModal-DQEfTcnZ.js +85 -0
  38. package/dist/NiceModal-DmWz2PDM.cjs +1 -0
  39. package/dist/NiceModuleLifecyclePanel-22CEEVbA.cjs +1 -0
  40. package/dist/NiceModuleLifecyclePanel-BCd9Wv5Y.js +6825 -0
  41. package/dist/NiceModuleLifecyclePanel-D8EoXqBy.cjs +1 -0
  42. package/dist/NiceModuleLifecyclePanel-SN6G7t64.js +7189 -0
  43. package/dist/NiceModuleLifecyclePanel.css +1 -1
  44. package/dist/NicePagination-BFGt1v0a.js +165 -0
  45. package/dist/NicePagination-BJS65foT.js +200 -0
  46. package/dist/NicePagination-D_3GfWp5.cjs +1 -0
  47. package/dist/NicePagination-DltL3-Sz.cjs +1 -0
  48. package/dist/NicePivotGrid-BD87Na7P.js +1163 -0
  49. package/dist/NicePivotGrid-BPmnvbPQ.cjs +152 -0
  50. package/dist/NicePivotGrid-D_kRF1Dt.js +1180 -0
  51. package/dist/NicePivotGrid-DqluEkCI.cjs +152 -0
  52. package/dist/NiceSavedQueryPanel-BSTiZvFg.js +5130 -0
  53. package/dist/NiceSavedQueryPanel-C2Tn1cMW.js +5311 -0
  54. package/dist/NiceSavedQueryPanel-DDKtL1AA.cjs +586 -0
  55. package/dist/NiceSavedQueryPanel-DrR3sw4T.cjs +586 -0
  56. package/dist/NiceScheduler-DvxJ8N0I.js +1698 -0
  57. package/dist/NiceScheduler-GJLvkXJ3.cjs +5 -0
  58. package/dist/NiceScheduler-TIksdF0k.cjs +5 -0
  59. package/dist/NiceScheduler-UT49u2Vq.js +1710 -0
  60. package/dist/NiceSelect-CdUHd8rj.cjs +1 -0
  61. package/dist/NiceSelect-fOelG_QB.js +495 -0
  62. package/dist/NiceWindow-CqSsTjrS.cjs +1 -0
  63. package/dist/NiceWindow-DZLPhXbR.js +2223 -0
  64. package/dist/charts-BYQwl_GS.js +4789 -0
  65. package/dist/charts-BpELGDXh.cjs +768 -0
  66. package/dist/charts-C6iOu0H6.cjs +768 -0
  67. package/dist/charts-M6LuVI7F.js +4776 -0
  68. package/dist/charts.cjs +1 -1
  69. package/dist/charts.d.ts +1 -29
  70. package/dist/charts.mjs +1 -1
  71. package/dist/core-lazy-B_laOXNf.cjs +1 -0
  72. package/dist/core-lazy-Ctin_LwS.cjs +1 -0
  73. package/dist/core-lazy-VQEjdz0L.js +351 -0
  74. package/dist/core-lazy-iDiropM6.js +351 -0
  75. package/dist/data-branching-7rpktFJ-.cjs +1 -0
  76. package/dist/data-branching-BS0aFUMu.js +6428 -0
  77. package/dist/data-branching-BgIAw01q.cjs +1 -0
  78. package/dist/data-branching-bvB9K6KS.js +6386 -0
  79. package/dist/data-branching.cjs +1 -1
  80. package/dist/data-branching.mjs +1 -1
  81. package/dist/data.cjs +1 -1
  82. package/dist/data.mjs +3 -3
  83. package/dist/devops-Bp-_aA-9.js +8682 -0
  84. package/dist/devops-CFytAJQr.cjs +18 -0
  85. package/dist/devops-CW8YY_zA.js +9122 -0
  86. package/dist/devops-CXBSjnyX.cjs +17 -0
  87. package/dist/devops.cjs +1 -1
  88. package/dist/devops.css +1 -0
  89. package/dist/devops.mjs +5 -5
  90. package/dist/editors.cjs +1 -1
  91. package/dist/editors.mjs +8 -8
  92. package/dist/feedback.cjs +1 -1
  93. package/dist/feedback.d.ts +21 -16
  94. package/dist/feedback.mjs +3 -3
  95. package/dist/index.cjs +199 -194
  96. package/dist/index.css +1 -1
  97. package/dist/index.d.ts +378 -48
  98. package/dist/index.mjs +23248 -21783
  99. package/dist/lazy.cjs +1 -1
  100. package/dist/lazy.mjs +24 -24
  101. package/dist/navigation.cjs +1 -1
  102. package/dist/navigation.d.ts +31 -0
  103. package/dist/navigation.mjs +404 -354
  104. package/dist/no-code-BNFk_BDO.js +8275 -0
  105. package/dist/no-code-BaAI_sJR.js +8318 -0
  106. package/dist/no-code-CFdTp543.cjs +331 -0
  107. package/dist/no-code-oQTeAtnW.cjs +331 -0
  108. package/dist/no-code.cjs +1 -1
  109. package/dist/no-code.mjs +1 -1
  110. package/dist/overlays.cjs +1 -1
  111. package/dist/overlays.d.ts +5 -0
  112. package/dist/overlays.mjs +1 -1
  113. package/dist/pickerCommons-BQi6IEAt.js +661 -0
  114. package/dist/pickerCommons-CMxFt9SW.js +548 -0
  115. package/dist/pickerCommons-Dc_hlz-e.cjs +1 -0
  116. package/dist/pickerCommons-DvQptSPX.cjs +1 -0
  117. package/dist/style.css +7 -4
  118. package/package.json +4 -3
@@ -0,0 +1,268 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),g=require("@nice2dev/ui-core"),n=require("react"),ue=require("./injectStyleOnce-DeWaxcdf.cjs"),qe=[{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 G=null,ne=null;const Ue="0.45.0",Ee=`https://cdn.jsdelivr.net/npm/monaco-editor@${Ue}/min`,de=`${Ee}/vs`,we=15e3;function _e(){const s=window;if(s.MonacoEnvironment?.getWorkerUrl)return;const l=`self.MonacoEnvironment={baseUrl:'${Ee}/'};importScripts('${de}/base/worker/workerMain.js');`,p=URL.createObjectURL(new Blob([l],{type:"text/javascript"}));s.MonacoEnvironment={getWorkerUrl:()=>p}}function X(s){if(s!=="auto")return s;if(typeof document>"u")return"vs";const l=document.documentElement.dataset.theme;return l==="dark"?"vs-dark":l==="light"?"vs":window.matchMedia?.("(prefers-color-scheme: dark)").matches?"vs-dark":"vs"}function Be(s){if(!s)return"";try{return JSON.stringify([s.url,s.language,s.initOptions??null])}catch{return JSON.stringify([s.url,s.language])}}function Se(){return ne?Promise.resolve(ne):G||(G=new Promise((s,l)=>{if(window.monaco){_e(),ne=window.monaco,s(ne);return}let p=!1;const o=window.setTimeout(()=>{p||(p=!0,G=null,l(new Error(`Monaco editor failed to load within ${we}ms`)))},we),C=document.createElement("script");C.src=`${de}/loader.min.js`,C.async=!0,C.onload=()=>{const W=window.require;W.config({paths:{vs:de}}),_e(),W(["vs/editor/editor.main"],I=>{p||(p=!0,window.clearTimeout(o),ne=I,s(I))})},C.onerror=()=>{p||(p=!0,window.clearTimeout(o),G=null,l(new Error("Failed to load Monaco Editor loader script")))},document.head.appendChild(C)}),G)}function je(s){n.useEffect(()=>{const l=s.current;if(!l)return;const p=g.createTabEscape(),o=C=>{p(C)&&C.stopPropagation()};return l.addEventListener("keydown",o,!0),()=>l.removeEventListener("keydown",o,!0)},[s])}const He=n.forwardRef(function(l,p){const{t:o}=g.useNiceTranslation();ue.injectStyleOnce(me,pe);const{value:C,defaultValue:W,onChange:I,language:h="plaintext",theme:_="auto",options:a={},height:ee=400,width:V="100%",markers:P=[],decorations:F=[],completionProvider:b,onMount:A,onCursorPositionChange:D,onSelectionChange:M,onSave:U,loading:L,disabled:z=!1,showToolbar:Q=!1,showStatusBar:E=!1,editorSize:B="standard",className:H,"data-testid":$,lsp:R,extraLibs:S,tutorial:K}=l,[N,f,m]=g.useControllableState({value:C,defaultValue:W,fallbackValue:"",onChange:I,componentName:"NiceCodeEditor"}),w=n.useRef(f);w.current=f;const j=n.useRef(N);j.current=N;const v=n.useRef(!1),y=n.useRef(null);je(y);const i=n.useRef(null),x=n.useRef(null),Y=n.useRef([]),O=n.useRef(null),[Z,fe]=n.useState(!0),[ie,Me]=n.useState(null),[ge,Le]=n.useState({lineNumber:1,column:1}),[he,Re]=n.useState(""),[ce,Oe]=n.useState(a.wordWrap==="on"),re=n.useMemo(()=>({automaticLayout:!0,readOnly:z||a.readOnly,minimap:{enabled:a.minimap??!0},lineNumbers:a.lineNumbers??"on",wordWrap:a.wordWrap??"off",tabSize:a.tabSize??2,insertSpaces:a.insertSpaces??!0,fontSize:a.fontSize??14,fontFamily:a.fontFamily??"'Fira Code', 'Consolas', 'Monaco', monospace",fontLigatures:a.fontLigatures??!0,cursorStyle:a.cursorStyle??"line",cursorBlinking:a.cursorBlinking??"blink",autoClosingBrackets:a.autoClosingBrackets??"languageDefined",autoClosingQuotes:a.autoClosingQuotes??"languageDefined",formatOnPaste:a.formatOnPaste??!1,formatOnType:a.formatOnType??!1,renderWhitespace:a.renderWhitespace??"selection",renderControlCharacters:a.renderControlCharacters??!1,scrollBeyondLastLine:a.scrollBeyondLastLine??!0,smoothScrolling:a.smoothScrolling??!0,folding:a.folding??!0,showFoldingControls:a.showFoldingControls??"mouseover","bracketPairColorization.enabled":a.bracketPairColorization??!0,guides:a.guides??{bracketPairs:!0,indentation:!0,highlightActiveIndentation:!0},stickyScroll:{enabled:a.stickyScroll??!1},quickSuggestions:a.quickSuggestions??!0,suggestOnTriggerCharacters:a.suggestOnTriggerCharacters??!0,acceptSuggestionOnEnter:a.acceptSuggestionOnEnter??"on",inlayHints:{enabled:a.inlayHints?"on":"off"}}),[a,z]),te=n.useRef({onCursorPositionChange:D,onSelectionChange:M,onSave:U,onMount:A});te.current={onCursorPositionChange:D,onSelectionChange:M,onSave:U,onMount:A};const be=n.useRef({language:h,theme:_,editorOptions:re});be.current={language:h,theme:_,editorOptions:re};const ve=n.useRef(R);ve.current=R;const Te=Be(R),ke=n.useRef(o);ke.current=o,n.useEffect(()=>{if(!y.current)return;let e=!0;const c=ve.current;return Se().then(async r=>{if(!e||!y.current)return;x.current=r;const u=be.current,k=r.editor.create(y.current,{value:j.current,language:u.language,theme:X(u.theme),...u.editorOptions});if(i.current=k,fe(!1),k.onDidChangeModelContent(()=>{v.current||w.current(k.getValue())}),k.onDidChangeCursorPosition(d=>{Le({lineNumber:d.position.lineNumber,column:d.position.column}),te.current.onCursorPositionChange?.({lineNumber:d.position.lineNumber,column:d.position.column})}),k.onDidChangeCursorSelection(d=>{const T=d.selection,J=k.getModel()?.getValueInRange(T)??"";Re(J),te.current.onSelectionChange?.({startLineNumber:T.startLineNumber,startColumn:T.startColumn,endLineNumber:T.endLineNumber,endColumn:T.endColumn})}),k.addCommand(r.KeyMod.CtrlCmd|r.KeyCode.KeyS,()=>{te.current.onSave?.(k.getValue())}),c&&typeof window<"u")try{await oe("https://cdn.jsdelivr.net/npm/vscode-ws-jsonrpc@1.0.2/lib/browser/index.min.js"),await oe("https://cdn.jsdelivr.net/npm/monaco-languageclient@0.15.0/lib/monaco-languageclient.min.js");const d=window,T=d.ReconnectingWebSocket,{MonacoLanguageClient:J,CloseAction:Ae,ErrorAction:De,createConnection:ye}=d.monacoLanguageClient||{};if(J&&ye){const ze=c.url,We=c.language,xe=new T(ze),Ve=new d.VSCodeWebSocketMessageReader(xe),Fe=new d.VSCodeWebSocketMessageWriter(xe),$e=ye(Ve,Fe),Ce=new J({name:"LSP Client",clientOptions:{documentSelector:[We],initializationOptions:c.initOptions,errorHandler:{error:()=>De.Continue,closed:()=>Ae.Restart}},connectionProvider:{get:()=>Promise.resolve($e)}});Ce.start(),i.current.__lspClient=Ce}}catch(d){console.warn("LSP bridge failed to load:",d)}te.current.onMount?.(k,r)}).catch(r=>{e&&(Me(r.message??ke.current("codeEditor.failedToLoadEditor","Failed to load editor")),fe(!1))}),()=>{if(e=!1,i.current?.dispose(),O.current?.dispose(),i.current&&i.current.__lspClient)try{i.current.__lspClient.stop()}catch{}}},[Te]),n.useEffect(()=>{const e=i.current;if(!m||!e||N===e.getValue())return;const c=e.getPosition();v.current=!0;try{e.setValue(N)}finally{v.current=!1}c&&e.setPosition(c)},[N,m]),n.useEffect(()=>{const e=i.current,c=x.current;if(e&&c){const r=e.getModel();r&&c.editor.setModelLanguage(r,h)}},[h]),n.useEffect(()=>{const e=x.current;if(!e||Z||!S||S.length===0||h!=="javascript"&&h!=="typescript")return;const c=e.languages?.typescript;if(!c)return;const r=[];try{S.forEach((u,k)=>{const d=u.filePath??`inmemory://model/nice-extralib-${k}.d.ts`,T=c.typescriptDefaults?.addExtraLib(u.content,d);T&&r.push(T);const J=c.javascriptDefaults?.addExtraLib(u.content,d);J&&r.push(J)})}catch(u){console.warn("Failed to register extraLibs:",u)}return()=>{r.forEach(u=>{try{u.dispose()}catch{}})}},[S,h,Z]),n.useEffect(()=>{const e=x.current;if(!e||(e.editor.setTheme(X(_)),_!=="auto"||typeof document>"u"))return;const c=()=>{x.current?.editor.setTheme(X("auto"))},r=new MutationObserver(c);r.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme","class"]});const u=window.matchMedia?.("(prefers-color-scheme: dark)");return u?.addEventListener?.("change",c),()=>{r.disconnect(),u?.removeEventListener?.("change",c)}},[_]),n.useEffect(()=>{const e=i.current;e&&e.updateOptions(re)},[re]),n.useEffect(()=>{const e=i.current,c=x.current;if(e&&c){const r=e.getModel();if(r){const u=P.map(k=>({startLineNumber:k.startLineNumber,startColumn:k.startColumn,endLineNumber:k.endLineNumber,endColumn:k.endColumn,message:k.message,severity:k.severity}));c.editor.setModelMarkers(r,"owner",u)}}},[P]),n.useEffect(()=>{const e=i.current;if(e&&F.length>0){const c=F.map(r=>({range:{startLineNumber:r.range.startLineNumber,startColumn:r.range.startColumn,endLineNumber:r.range.endLineNumber,endColumn:r.range.endColumn},options:{className:r.className,glyphMarginClassName:r.glyphMarginClassName,hoverMessage:r.hoverMessage?{value:r.hoverMessage}:void 0,isWholeLine:r.isWholeLine}}));Y.current=e.deltaDecorations(Y.current,c)}},[F]),n.useEffect(()=>{const e=x.current;if(!e||!b)return;O.current?.dispose();const c={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 O.current=e.languages.registerCompletionItemProvider(h,{provideCompletionItems:async(r,u)=>({suggestions:(await b(r,u)).map(d=>({label:d.label,kind:c[d.kind]??0,insertText:d.insertText,insertTextRules:d.insertTextRules==="insertAsSnippet"?4:void 0,documentation:d.documentation,detail:d.detail,range:{startLineNumber:u.lineNumber,startColumn:u.column,endLineNumber:u.lineNumber,endColumn:u.column}}))})}),()=>{O.current?.dispose()}},[h,b]),n.useImperativeHandle(p,()=>({getEditor:()=>i.current,getMonaco:()=>x.current,focus:()=>i.current?.focus(),getValue:()=>i.current?.getValue()??"",setValue:e=>i.current?.setValue(e),getSelection:()=>{const e=i.current;if(!e)return"";const c=e.getSelection();return c?e.getModel()?.getValueInRange(c)??"":""},insertText:e=>{const c=i.current;if(!c)return;const r=c.getSelection();r&&c.executeEdits("",[{range:r,text:e}])},formatDocument:()=>{i.current?.getAction("editor.action.formatDocument")?.run()},goToLine:(e,c=1)=>{const r=i.current;r&&(r.setPosition({lineNumber:e,column:c}),r.revealLineInCenter(e),r.focus())},findReplace:()=>{i.current?.getAction("editor.action.startFindReplaceAction")?.run()},undo:()=>{i.current?.trigger("keyboard","undo",null)},redo:()=>{i.current?.trigger("keyboard","redo",null)},getCursorPosition:()=>{const e=i.current?.getPosition();return{lineNumber:e?.lineNumber??1,column:e?.column??1}},setMarkers:e=>{const c=i.current,r=x.current;if(c&&r){const u=c.getModel();if(u){const k=e.map(d=>({startLineNumber:d.startLineNumber,startColumn:d.startColumn,endLineNumber:d.endLineNumber,endColumn:d.endColumn,message:d.message,severity:d.severity}));r.editor.setModelMarkers(u,"owner",k)}}}}),[]);const q=n.useMemo(()=>({format:()=>i.current?.getAction("editor.action.formatDocument")?.run(),undo:()=>i.current?.trigger("keyboard","undo",null),redo:()=>i.current?.trigger("keyboard","redo",null),find:()=>i.current?.getAction("editor.action.startFindReplaceAction")?.run(),toggleWordWrap:()=>{const e=!ce;Oe(e),i.current?.updateOptions({wordWrap:e?"on":"off"})},toggleMinimap:()=>{const e=i.current?.getOption?.(x.current?.editor?.EditorOption?.minimap);i.current?.updateOptions({minimap:{enabled:!e?.enabled}})},foldAll:()=>i.current?.getAction("editor.foldAll")?.run(),unfoldAll:()=>i.current?.getAction("editor.unfoldAll")?.run()}),[ce]),Ie=N.split(`
2
+ `).length,Pe=N.length;return t.jsxs("div",{className:`nice-code-editor-wrap nice-editor--${B} ${H??""}`,style:{height:ee,width:V,display:"flex",flexDirection:"column",position:"relative"},"data-testid":$,children:[t.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:20},children:t.jsx(g.NiceTutorialButton,{steps:g.resolveTutorial(K,qe)})}),ie&&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(g.NiceIcon,{name:"warning",size:16})," ",ie]}),t.jsx("textarea",{value:N,onChange:e=>f(e.target.value),readOnly:z||a.readOnly,style:{width:"100%",height:"100%",fontFamily:"monospace"}})]}),Z&&!ie&&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:L??t.jsx("div",{className:"nice-code-editor__loader",children:o("codeEditor.loadingEditor","Loading editor...")})}),Q&&t.jsxs("div",{className:"nice-code-editor__toolbar",children:[t.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:q.undo,title:o("codeEditor.undoCtrlZ","Undo (Ctrl+Z)"),"aria-label":o("codeEditor.undo","Undo"),children:t.jsx(g.NiceIcon,{name:"reply",size:16})}),t.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:q.redo,title:o("codeEditor.redoCtrlY","Redo (Ctrl+Y)"),"aria-label":o("codeEditor.redo","Redo"),children:t.jsx(g.NiceIcon,{name:"forward",size:16})}),t.jsx("span",{className:"nice-code-editor__toolbar-sep"}),t.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:q.format,title:o("codeEditor.formatShiftAltF","Format (Shift+Alt+F)"),"aria-label":o("codeEditor.format","Format"),children:t.jsx(g.NiceIcon,{name:"type",size:16})}),t.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:q.find,title:o("codeEditor.findReplaceCtrlH","Find & Replace (Ctrl+H)"),"aria-label":o("codeEditor.findReplace","Find & Replace"),children:t.jsx(g.NiceIcon,{name:"search",size:16})}),t.jsx("span",{className:"nice-code-editor__toolbar-sep"}),t.jsx("button",{className:`nice-code-editor__toolbar-btn${ce?" nice-code-editor__toolbar-btn--active":""}`,onClick:q.toggleWordWrap,title:o("codeEditor.toggleWordWrap","Toggle Word Wrap"),"aria-label":o("codeEditor.toggleWordWrap","Toggle Word Wrap"),children:t.jsx(g.NiceIcon,{name:"align-left",size:16})}),t.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:q.toggleMinimap,title:o("codeEditor.toggleMinimap","Toggle Minimap"),"aria-label":o("codeEditor.toggleMinimap","Toggle Minimap"),children:t.jsx(g.NiceIcon,{name:"columns",size:16})}),t.jsx("span",{className:"nice-code-editor__toolbar-sep"}),t.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:q.foldAll,title:o("codeEditor.foldAll","Fold All"),"aria-label":o("codeEditor.foldAll","Fold All"),children:t.jsx(g.NiceIcon,{name:"collapse",size:16})}),t.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:q.unfoldAll,title:o("codeEditor.unfoldAll","Unfold All"),"aria-label":o("codeEditor.unfoldAll","Unfold All"),children:t.jsx(g.NiceIcon,{name:"expand",size:16})})]}),t.jsx("div",{ref:y,className:"nice-code-editor",style:{flex:1,minHeight:0}}),E&&t.jsxs("div",{className:"nice-code-editor__statusbar",children:[t.jsx("span",{children:o("codeEditor.lnCol","Ln {lineNumber}, Col {column}").replace("{lineNumber}",String(ge.lineNumber)).replace("{column}",String(ge.column))}),he.length>0&&t.jsx("span",{children:o("codeEditor.selected","({selectionText} selected)").replace("{selectionText}",String(he.length))}),t.jsx("span",{className:"nice-code-editor__statusbar-spacer"}),t.jsx("span",{children:o("codeEditor.linesChars","{lineCount} lines · {charCount} chars").replace("{lineCount}",String(Ie)).replace("{charCount}",String(Pe))}),t.jsx("span",{className:"nice-code-editor__statusbar-lang",children:h}),P.length>0&&t.jsxs("span",{className:"nice-code-editor__statusbar-markers",children:[t.jsx(g.NiceIcon,{name:"warning",size:14})," ",P.length]})]})]})});function Ke(s){const{t:l}=g.useNiceTranslation();ue.injectStyleOnce(me,pe);const{original:p,defaultOriginal:o,modified:C,defaultModified:W,language:I="plaintext",theme:h="auto",height:_=400,width:a="100%",inline:ee=!1,renderSideBySide:V=!0,originalEditable:P=!1,modifiedEditable:F=!1,onOriginalChange:b,onModifiedChange:A,loading:D,className:M,"data-testid":U}=s,[L,z,Q]=g.useControllableState({value:p,defaultValue:o,fallbackValue:"",onChange:b,componentName:"NiceCodeDiffEditor.original"}),[E,B,H]=g.useControllableState({value:C,defaultValue:W,fallbackValue:"",onChange:A,componentName:"NiceCodeDiffEditor.modified"}),$=n.useRef({currentOriginal:L,currentModified:E,setOriginal:z,setModified:B});$.current={currentOriginal:L,currentModified:E,setOriginal:z,setModified:B};const R=n.useRef(!1),S=n.useRef(null);je(S);const K=n.useRef(null),N=n.useRef(null),[f,m]=n.useState(!0),[w,j]=n.useState(null);return n.useEffect(()=>{if(!S.current)return;let v=!0;return Se().then(y=>{if(!v||!S.current)return;N.current=y;const{currentOriginal:i,currentModified:x}=$.current,Y=y.editor.createModel(i,I),O=y.editor.createModel(x,I),Z=y.editor.createDiffEditor(S.current,{automaticLayout:!0,theme:X(h),renderSideBySide:!ee&&V,originalEditable:P,readOnly:!F});Z.setModel({original:Y,modified:O}),K.current=Z,m(!1),P&&Y.onDidChangeContent(()=>{R.current||$.current.setOriginal(Y.getValue())}),F&&O.onDidChangeContent(()=>{R.current||$.current.setModified(O.getValue())})}).catch(y=>{v&&(j(y.message??l("codeEditor.failedToLoadDiffEditor","Failed to load diff editor")),m(!1))}),()=>{v=!1,K.current?.dispose()}},[l]),n.useEffect(()=>{const v=K.current?.getModel();if(v){R.current=!0;try{Q&&v.original.getValue()!==L&&v.original.setValue(L),H&&v.modified.getValue()!==E&&v.modified.setValue(E)}finally{R.current=!1}}},[L,E,Q,H]),n.useEffect(()=>{const v=N.current;if(!v||(v.editor.setTheme(X(h)),h!=="auto"||typeof document>"u"))return;const y=()=>{N.current?.editor.setTheme(X("auto"))},i=new MutationObserver(y);i.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme","class"]});const x=window.matchMedia?.("(prefers-color-scheme: dark)");return x?.addEventListener?.("change",y),()=>{i.disconnect(),x?.removeEventListener?.("change",y)}},[h,f]),w?t.jsx("div",{className:`nice-code-diff-editor nice-code-diff-editor--error ${M??""}`,style:{height:_,width:a},"data-testid":U,children:t.jsx("div",{className:"nice-code-editor__error",children:t.jsxs("span",{children:[t.jsx(g.NiceIcon,{name:"warning",size:16})," ",w]})})}):t.jsxs("div",{className:`nice-code-diff-editor ${M??""}`,style:{height:_,width:a,position:"relative"},"data-testid":U,children:[t.jsx("div",{ref:S,style:{position:"absolute",inset:0}}),f&&t.jsx("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",background:"var(--nice-bg-primary, #fff)",zIndex:2},children:D??t.jsx("div",{className:"nice-code-editor__loader",children:l("codeEditor.loadingDiffEditor","Loading diff editor...")})})]})}const Ye="1.29.0",Ne=`https://cdn.jsdelivr.net/npm/prismjs@${Ye}`;let ae=null;const le={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 oe(s){return new Promise((l,p)=>{if(document.querySelector(`script[data-prism-src="${s}"]`)){l();return}const o=document.createElement("script");o.src=s,o.async=!0,o.dataset.prismSrc=s,o.onload=()=>l(),o.onerror=()=>p(new Error(`Failed to load ${s}`)),document.head.appendChild(o)})}function Je(s){if(typeof window>"u")return Promise.resolve(null);const l=window,p=le[s]??"plain",o=async()=>{if(p!=="plain"&&!l.Prism?.languages?.[p])try{await oe(`${Ne}/components/prism-${p}.min.js`)}catch{}};return l.Prism?.languages?o().then(()=>l.Prism):(ae||(ae=(async()=>(window.Prism={manual:!0},await oe(`${Ne}/prism.min.js`),window.Prism))()),ae.then(async()=>(await o(),window.Prism)))}function se(s){return s.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Qe(s){ue.injectStyleOnce(me,pe);const{value:l,defaultValue:p,onChange:o,language:C="plaintext",height:W=300,width:I="100%",readOnly:h=!1,tabSize:_=2,lineNumbers:a=!0,placeholder:ee,theme:V="auto",className:P,"data-testid":F}=s,[b,A]=g.useControllableState({value:l,defaultValue:p,fallbackValue:"",onChange:o,componentName:"NiceSimpleCodeEditor"}),D=n.useRef(null),M=n.useRef(null),{t:U}=g.useNiceTranslation(),L=n.useId(),[z]=n.useState(g.createTabEscape),[Q,E]=n.useState(()=>se(b)),[B,H]=n.useState("light");n.useEffect(()=>{const f=()=>{if(V!=="auto")return V;if(typeof document>"u")return"light";const v=document.documentElement.dataset.theme;return v==="dark"?"dark":v==="light"?"light":window.matchMedia?.("(prefers-color-scheme: dark)").matches?"dark":"light"};if(H(f()),V!=="auto"||typeof document>"u")return;const m=()=>H(f()),w=new MutationObserver(m);w.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme","class"]});const j=window.matchMedia?.("(prefers-color-scheme: dark)");return j?.addEventListener?.("change",m),()=>{w.disconnect(),j?.removeEventListener?.("change",m)}},[V]),n.useEffect(()=>{let f=!0;return Je(C).then(m=>{if(!f)return;const w=le[C]??"plain";if(m?.languages?.[w])try{const j=m.highlight(b,m.languages[w],w);E(j);return}catch{}E(se(b))}).catch(()=>{f&&E(se(b))}),()=>{f=!1}},[b,C]);const $=n.useCallback(()=>{!M.current||!D.current||(M.current.scrollTop=D.current.scrollTop,M.current.scrollLeft=D.current.scrollLeft)},[]),R=n.useCallback(f=>{if(!z(f)&&f.key==="Tab"&&!h){f.preventDefault();const m=f.currentTarget,w=m.selectionStart,j=m.selectionEnd,v=" ".repeat(_);if(f.shiftKey){const x=b.substring(0,w).lastIndexOf(`
3
+ `)+1;if((b.substring(x,w).match(/^(\s*)/)?.[1]??"").length>=_){const O=b.substring(0,x)+b.substring(x+_);A(O),setTimeout(()=>{m.selectionStart=m.selectionEnd=w-_},0)}}else{const y=b.substring(0,w)+v+b.substring(j);A(y),setTimeout(()=>{m.selectionStart=m.selectionEnd=w+_},0)}}},[b,A,_,z,h]),K=b.split(`
4
+ `).length,N=le[C]??"plain";return t.jsxs("div",{className:`nice-simple-code-editor nice-simple-code-editor--${B} ${P??""}`,style:{height:W,width:I},"data-testid":F,"data-language":C,"data-theme":B,children:[a&&t.jsx("div",{className:"nice-simple-code-editor__line-numbers",children:Array.from({length:K},(f,m)=>t.jsx("div",{className:"nice-simple-code-editor__line-number",children:m+1},m))}),t.jsxs("div",{className:"nice-simple-code-editor__editor-area",children:[t.jsx("pre",{ref:M,"aria-hidden":"true",className:`nice-simple-code-editor__highlight language-${N}`,children:t.jsx("code",{className:`language-${N}`,dangerouslySetInnerHTML:{__html:Q+(b.endsWith(`
5
+ `)?`
6
+ `:"")}})}),t.jsx("textarea",{ref:D,className:"nice-simple-code-editor__textarea",value:b,onChange:f=>A(f.target.value),onKeyDown:R,onScroll:$,readOnly:h,placeholder:ee,spellCheck:!1,autoCapitalize:"off",autoCorrect:"off","aria-describedby":h?void 0:L}),!h&&t.jsx("span",{id:L,className:"nice-sr-only",children:U("input.tabEscapeHint","Tab indents. To leave the editor, press Escape, then Tab.")})]})]})}const me="nice-code-editor-styles",pe=`
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
+ /* The editing surface draws no outline: while it has focus, the frame shows the ring
202
+ (TODO_1.3.0 I4). */
203
+ .nice-code-editor-wrap:has(.nice-code-editor:focus-within),
204
+ .nice-code-diff-editor:focus-within,
205
+ .nice-simple-code-editor:focus-within {
206
+ border-color: var(--nice-color-primary, #3b82f6);
207
+ box-shadow: var(--nice-focus-ring, 0 0 0 2px var(--nice-color-primary, #3b82f6));
208
+ }
209
+ .nice-code-editor__toolbar {
210
+ display: flex;
211
+ align-items: center;
212
+ gap: var(--nice-space-0-5, 2px);
213
+ padding: var(--nice-space-0-75, 3px) var(--nice-space-1-5, 6px);
214
+ background: var(--nice-bg-tertiary, #f5f5f5);
215
+ border-bottom: 1px solid var(--nice-border, #e0e0e0);
216
+ }
217
+ .nice-code-editor__toolbar-btn {
218
+ display: inline-flex;
219
+ align-items: center;
220
+ justify-content: center;
221
+ width: 26px;
222
+ height: 26px;
223
+ border: none;
224
+ border-radius: var(--nice-radius-sm, 3px);
225
+ background: transparent;
226
+ color: var(--nice-text-secondary, #666);
227
+ cursor: pointer;
228
+ font-size: 14px;
229
+ transition: background 0.15s, color 0.15s;
230
+ }
231
+ .nice-code-editor__toolbar-btn:hover {
232
+ background: var(--nice-hover-bg, #e0e0e0);
233
+ color: var(--nice-text-primary, #333);
234
+ }
235
+ .nice-code-editor__toolbar-btn--active {
236
+ background: var(--nice-accent, #1976d2);
237
+ color: var(--nice-text-on-primary, #FFF);
238
+ }
239
+ .nice-code-editor__toolbar-sep {
240
+ width: 1px;
241
+ height: 18px;
242
+ background: var(--nice-border, #e0e0e0);
243
+ margin: 0 var(--nice-space-1, 4px);
244
+ }
245
+
246
+ /* Status bar */
247
+ .nice-code-editor__statusbar {
248
+ display: flex;
249
+ align-items: center;
250
+ gap: var(--nice-space-3, 12px);
251
+ padding: var(--nice-space-0-5, 2px) var(--nice-space-2-5, 10px);
252
+ background: var(--nice-bg-tertiary, #f5f5f5);
253
+ border-top: 1px solid var(--nice-border, #e0e0e0);
254
+ font-size: 12px;
255
+ color: var(--nice-text-secondary, #666);
256
+ user-select: none;
257
+ }
258
+ .nice-code-editor__statusbar-spacer { flex: 1; }
259
+ .nice-code-editor__statusbar-lang {
260
+ text-transform: uppercase;
261
+ font-weight: 600;
262
+ font-size: 11px;
263
+ }
264
+ .nice-code-editor__statusbar-markers {
265
+ color: var(--nice-warning, #f39c12);
266
+ font-weight: 600;
267
+ }
268
+ `;exports.NiceCodeDiffEditor=Ke;exports.NiceCodeEditor=He;exports.NiceSimpleCodeEditor=Qe;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),P=require("@nice2dev/ui-core"),k=require("react"),me=require("react-dom"),he=require("./devops-CFytAJQr.cjs"),fe=["#ef4444","#f97316","#f59e0b","#84cc16","#10b981","#06b6d4","#3b82f6","#6366f1","#8b5cf6","#ec4899","#64748b","#1e293b"];function ge(){return"#"+Math.floor(Math.random()*16777215).toString(16).padStart(6,"0")}function ve(a){const u=/^#?([0-9a-f]{6})$/i.exec(a.trim());if(!u)return{r:0,g:0,b:0};const h=parseInt(u[1],16);return{r:h>>16&255,g:h>>8&255,b:h&255}}function be(a,u,h){const p=r=>Math.max(0,Math.min(255,Math.round(r))).toString(16).padStart(2,"0");return`#${p(a)}${p(u)}${p(h)}`}function xe(a,u,h){const p=a/255,r=u/255,i=h/255,n=Math.max(p,r,i),b=Math.min(p,r,i),d=(n+b)/2;let o=0,c=0;if(n!==b){const _=n-b;switch(c=d>.5?_/(2-n-b):_/(n+b),n){case p:o=(r-i)/_+(r<i?6:0);break;case r:o=(i-p)/_+2;break;case i:o=(p-r)/_+4;break}o*=60}return{h:Math.round(o),s:Math.round(c*100),l:Math.round(d*100)}}function _e(a,u,h){const p=u/100,r=h/100,i=(1-Math.abs(2*r-1))*p,n=i*(1-Math.abs(a/60%2-1)),b=r-i/2;let d=0,o=0,c=0;return a<60?[d,o,c]=[i,n,0]:a<120?[d,o,c]=[n,i,0]:a<180?[d,o,c]=[0,i,n]:a<240?[d,o,c]=[0,n,i]:a<300?[d,o,c]=[n,0,i]:[d,o,c]=[i,0,n],{r:Math.round((d+b)*255),g:Math.round((o+b)*255),b:Math.round((c+b)*255)}}function ke(a,u,h){const p=a/255,r=u/255,i=h/255,n=Math.max(p,r,i),b=Math.min(p,r,i),d=n-b;let o=0;d!==0&&(n===p?o=(r-i)/d%6:n===r?o=(i-p)/d+2:o=(p-r)/d+4,o*=60,o<0&&(o+=360));const c=n===0?0:d/n;return{h:Math.round(o),s:Math.round(c*100),v:Math.round(n*100)}}function ye(a,u,h){const p=u/100,r=h/100,i=r*p,n=i*(1-Math.abs(a/60%2-1)),b=r-i;let d=0,o=0,c=0;return a<60?[d,o,c]=[i,n,0]:a<120?[d,o,c]=[n,i,0]:a<180?[d,o,c]=[0,i,n]:a<240?[d,o,c]=[0,n,i]:a<300?[d,o,c]=[n,0,i]:[d,o,c]=[i,0,n],{r:Math.round((d+b)*255),g:Math.round((o+b)*255),b:Math.round((c+b)*255)}}function Ne(a){let u=a.trim();const h=/var\([^,]+,\s*(#[0-9a-fA-F]{3,8})\s*\)/.exec(u);h&&(u=h[1]);const p=/^#?([0-9a-f]{3})$/i.exec(u);p&&(u=`#${p[1].split("").map(n=>n+n).join("")}`);const r=/^#?([0-9a-f]{6})$/i.exec(u),i=/^#?([0-9a-f]{8})$/i.exec(u);if(i){const n=i[1];return{r:parseInt(n.slice(0,2),16),g:parseInt(n.slice(2,4),16),b:parseInt(n.slice(4,6),16),a:parseInt(n.slice(6,8),16)/255}}if(r){const n=parseInt(r[1],16);return{r:n>>16&255,g:n>>8&255,b:n&255,a:1}}return{r:0,g:0,b:0,a:1}}function je(a,u,h,p,r){const i=b=>Math.max(0,Math.min(255,Math.round(b))).toString(16).padStart(2,"0"),n=`#${i(a)}${i(u)}${i(h)}`;return r?`${n}${i(p*255)}`:n}const Me=Object.assign(k.forwardRef(({label:a,helperText:u,error:h,required:p,disabled:r,id:i,className:n,style:b,accessMode:d,displayStyle:o,value:c="#3b82f6",onChange:_,presets:B=fe,showInput:X=!1,showRandom:Y=!1,withAlpha:S=!1,compact:I=!1,showKeyboardHints:J,size:Q="md",labelPlacement:Z,errorPlacement:L,labelWidth:T,controlWidth:D,loading:O},F)=>{const A=P.useNiceAccessMode(d,i),W=A==="hidden";(A==="disabled"||A==="readOnly")&&(r=!0);const{t:v}=P.useNiceTranslation(),$=P.useControlId(i);P.useComponentDisplayClass("input",o);const ee=k.useCallback(()=>{r||_?.(ge())},[r,_]),[M,C]=k.useState(!1),[q,re]=k.useState(null),[K,ne]=k.useState(""),U=k.useRef(null),E=k.useRef(null);k.useLayoutEffect(()=>{if(!M||!E.current)return;ne(he.scopeThemeClass(E.current));const m=()=>{const l=E.current?.getBoundingClientRect();if(!l)return;const N=280,w=360;let x=l.left,j=l.bottom+6;x+N>window.innerWidth-8&&(x=Math.max(8,window.innerWidth-N-8)),j+w>window.innerHeight-8&&(j=Math.max(8,l.top-w-6)),re({left:x,top:j})};return m(),window.addEventListener("scroll",m,!0),window.addEventListener("resize",m),()=>{window.removeEventListener("scroll",m,!0),window.removeEventListener("resize",m)}},[M]),k.useEffect(()=>{if(!M)return;const m=l=>{const N=l.target;U.current?.contains(N)||E.current?.contains(N)||C(!1)};return document.addEventListener("mousedown",m),()=>{document.removeEventListener("mousedown",m)}},[M]),P.useOverlayFocus(U,{open:M,modal:!1,onClose:()=>C(!1)});const V=k.useRef(null);P.useRovingFocus(V,{orientation:"grid",itemSelector:".nice-color-picker__preset",wrap:!0});const te=k.useMemo(()=>[{key:"Enter",description:v("shortcuts.openPicker","Open color picker")},{key:"Arrow keys",description:v("shortcuts.navigatePresets","Navigate presets")}],[v]);return W?null:t.jsxs("div",{className:`nice-field nice-field--${Q} ${Z==="left"?"nice-field--label-left":""} ${I?"nice-color-picker--compact":""} ${O?"nice-field--loading":""} ${n||""}`,style:{...b,...T!=null&&{"--nice-field-label-width":typeof T=="number"?`${T}px`:T},...D!=null&&{"--nice-field-control-width":typeof D=="number"?`${D}px`:D}},"aria-busy":O||void 0,children:[a&&t.jsxs("label",{htmlFor:$,className:`nice-field__label ${p?"nice-field__label--required":""}`,children:[a,J&&t.jsx(P.NiceKeyboardHint,{shortcuts:te,size:"sm"})]}),t.jsx("div",{className:"nice-field__control",children:t.jsxs("div",{className:"nice-color-picker",children:[t.jsxs("div",{className:"nice-color-picker__preview-row",children:[t.jsx("div",{ref:E,className:"nice-color-picker__swatch",id:$,style:{background:c},onClick:m=>{m.stopPropagation(),r||C(l=>!l)},onKeyDown:m=>{!r&&(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),C(l=>!l))},role:"button",tabIndex:r?-1:0,"aria-disabled":r||void 0,"aria-label":v("colorPicker.openPalette","Open color palette"),"aria-haspopup":"dialog","aria-expanded":M,children:t.jsx("input",{ref:m=>{typeof F=="function"?F(m):F&&(F.current=m)},type:"hidden",value:c,disabled:r,readOnly:!0})}),X&&t.jsx("div",{className:"nice-input nice-input--sm",style:I?{flex:1,minWidth:0}:{width:100},children:t.jsx("input",{className:"nice-input__native",type:"text",value:c,disabled:r,onChange:m=>_?.(m.target.value),maxLength:S?9:7,"aria-label":v("colorPicker.hexValue","Hex value")})}),Y&&!I&&t.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm nice-color-picker__random",onClick:ee,disabled:r,title:v("colorPicker.random","Random"),"aria-label":v("colorPicker.random","Random"),style:{fontSize:"0.65rem",textTransform:"uppercase",letterSpacing:"0.05em"},children:v("colorPicker.random","Random")}),O&&t.jsx("span",{className:"nice-field__spinner",children:t.jsx("span",{className:"nice-spinner nice-spinner--sm"})}),L==="right"&&h&&t.jsx("div",{id:`${$}-error`,className:"nice-field__error",role:"alert",children:h}),L==="right"&&!h&&u&&t.jsx("div",{id:`${$}-helper`,className:"nice-field__helper",children:u})]}),M&&q&&typeof document<"u"&&me.createPortal(t.jsx("div",{ref:U,className:`nice-color-picker__popup nice-color-picker__popup--portal ${K}`,"data-theme":K==="nice-dark"?"dark":K==="nice-light"?"light":void 0,role:"dialog","aria-label":v("colorPicker.palette","Color palette"),style:{position:"fixed",left:q.left,top:q.top},onClick:m=>m.stopPropagation(),children:(()=>{const m=Ne(c),l={r:m.r,g:m.g,b:m.b},N=S?m.a:1,w=xe(l.r,l.g,l.b),x=ke(l.r,l.g,l.b),j=(e,f,g,s=N)=>_?.(je(e,f,g,s,S)),ie=(e,f,g)=>j(e,f,g),oe=(e,f,g)=>{const s=_e(e,f,g);j(s.r,s.g,s.b)},z=(e,f,g)=>{const s=ye(e,f,g);j(s.r,s.g,s.b)},G=e=>j(l.r,l.g,l.b,e),se=e=>{if(r)return;const f=e.currentTarget,g=y=>{const R=f.getBoundingClientRect(),le=Math.max(0,Math.min(R.width,y.clientX-R.left)),ue=Math.max(0,Math.min(R.height,y.clientY-R.top)),pe=Math.round(le/R.width*100),de=100-Math.round(ue/R.height*100);z(x.h,pe,de)};g(e);const s=()=>{document.removeEventListener("pointermove",g),document.removeEventListener("pointerup",s)};document.addEventListener("pointermove",g),document.addEventListener("pointerup",s)},ae=`hsl(${x.h}, 100%, 50%)`,ce=e=>{if(r)return;const f=e.shiftKey?10:1;let{s:g,v:s}=x;if(e.key==="ArrowLeft")g-=f;else if(e.key==="ArrowRight")g+=f;else if(e.key==="ArrowDown")s-=f;else if(e.key==="ArrowUp")s+=f;else if(e.key==="PageDown")s-=10;else if(e.key==="PageUp")s+=10;else if(e.key==="Home")g=0;else if(e.key==="End")g=100;else return;e.preventDefault(),z(x.h,Math.max(0,Math.min(100,g)),Math.max(0,Math.min(100,s)))},H={h:v("colorPicker.hue","Hue"),s:v("colorPicker.saturation","Saturation"),l:v("colorPicker.lightness","Lightness"),r:v("colorPicker.red","Red"),g:v("colorPicker.green","Green"),b:v("colorPicker.blue","Blue")};return t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"nice-color-picker__popup-header",children:t.jsx("input",{type:"text",className:"nice-input__native nice-color-picker__popup-hex",value:c,disabled:r,onChange:e=>_?.(e.target.value),maxLength:S?9:7,"aria-label":v("colorPicker.hexValue","Hex value")})}),t.jsx("input",{type:"range",min:0,max:360,value:x.h,disabled:r,onChange:e=>z(Number(e.target.value),x.s,x.v),className:"nice-color-picker__hue-slider","aria-label":v("colorPicker.hue","Hue")}),t.jsx("div",{className:"nice-color-picker__sv",style:{background:`linear-gradient(to top, var(--nice-text, #000), transparent), linear-gradient(to right, var(--nice-bg, #FFF), ${ae})`},onPointerDown:se,onKeyDown:ce,role:"slider",tabIndex:r?-1:0,"aria-label":v("colorPicker.svPalette","Saturation/value palette"),"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":x.s,"aria-valuetext":`${H.s} ${x.s}%, ${v("colorPicker.brightness","Brightness")} ${x.v}%`,children:t.jsx("span",{className:"nice-color-picker__sv-marker",style:{left:`${x.s}%`,top:`${100-x.v}%`}})}),t.jsxs("div",{className:"nice-color-picker__sliders",children:[t.jsx("div",{className:"nice-color-picker__slider-col",children:["h","s","l"].map(e=>{const f=e==="h"?360:100,g=w[e],s=y=>oe(e==="h"?y:w.h,e==="s"?y:w.s,e==="l"?y:w.l);return t.jsxs("div",{className:"nice-color-picker__slider-row",children:[t.jsx("label",{className:"nice-color-picker__slider-label",children:e.toUpperCase()}),t.jsx("input",{type:"range",min:0,max:f,value:g,disabled:r,onChange:y=>s(Number(y.target.value)),"aria-label":H[e]}),t.jsx("input",{type:"number",min:0,max:f,value:g,disabled:r,onChange:y=>s(Number(y.target.value)||0),className:"nice-input__native nice-color-picker__slider-num","aria-label":H[e]})]},e)})}),t.jsx("div",{className:"nice-color-picker__slider-col",children:["r","g","b"].map(e=>{const f=l[e],g=s=>ie(e==="r"?s:l.r,e==="g"?s:l.g,e==="b"?s:l.b);return t.jsxs("div",{className:"nice-color-picker__slider-row",children:[t.jsx("label",{className:"nice-color-picker__slider-label",children:e.toUpperCase()}),t.jsx("input",{type:"range",min:0,max:255,value:f,disabled:r,onChange:s=>g(Number(s.target.value)),"aria-label":H[e]}),t.jsx("input",{type:"number",min:0,max:255,value:f,disabled:r,onChange:s=>g(Number(s.target.value)||0),className:"nice-input__native nice-color-picker__slider-num","aria-label":H[e]})]},e)})})]}),S&&t.jsxs("div",{className:"nice-color-picker__alpha-row",children:[t.jsx("label",{className:"nice-color-picker__slider-label",children:"A"}),t.jsx("input",{type:"range",min:0,max:100,value:Math.round(N*100),disabled:r,onChange:e=>G(Number(e.target.value)/100),className:"nice-color-picker__alpha-slider",style:{background:`linear-gradient(to right, transparent, rgb(${l.r},${l.g},${l.b}))`},"aria-label":v("colorPicker.alpha","Alpha")}),t.jsx("input",{type:"number",min:0,max:100,value:Math.round(N*100),disabled:r,onChange:e=>G((Number(e.target.value)||0)/100),className:"nice-input__native nice-color-picker__slider-num","aria-label":v("colorPicker.alpha","Alpha")})]}),B.length>0&&t.jsx("div",{ref:V,className:"nice-color-picker__popup-presets",role:"group","aria-label":v("colorPicker.presets","Preset colors"),children:B.map(e=>t.jsx("div",{className:`nice-color-picker__preset ${c===e?"nice-color-picker__preset--active":""}`,style:{background:e},onClick:()=>{_?.(e),C(!1)},role:"button","aria-label":e,"aria-pressed":c===e,onKeyDown:f=>{(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),_?.(e),C(!1))}},e))})]})})()}),document.body)]})}),L!=="right"&&h&&t.jsx("div",{id:`${$}-error`,className:"nice-field__error",role:"alert",children:h}),L!=="right"&&!h&&u&&t.jsx("div",{id:`${$}-helper`,className:"nice-field__helper",children:u})]})}),{displayName:"NiceColorPicker"});exports.NiceColorPicker=Me;exports.hexToRgb=ve;exports.rgbToHex=be;