@nice2dev/ui 1.1.6 → 1.1.7

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 (162) hide show
  1. package/CHANGELOG.md +52 -0
  2. package/README.md +50 -29
  3. package/css/legacy-bg-text-aliases.css +65 -61
  4. package/dist/NiceCodeEditor-Bc81wiaN.js +1134 -0
  5. package/dist/NiceCodeEditor-D6f8KdHN.js +1134 -0
  6. package/dist/NiceCodeEditor-DE3saxyt.cjs +260 -0
  7. package/dist/NiceCodeEditor-DZM16My5.cjs +260 -0
  8. package/dist/NiceCodeEditor-HqmcJjmZ.js +1179 -0
  9. package/dist/NiceColorPicker-6EqXaDj0.cjs +1 -0
  10. package/dist/NiceColorPicker-BiEWqWnd.js +596 -0
  11. package/dist/NiceColorPicker-Cuc6YXqz.cjs +1 -0
  12. package/dist/NiceColorPicker-DMATcNWG.js +596 -0
  13. package/dist/NiceColorPicker-R3O1nemp.js +596 -0
  14. package/dist/NiceConfirmDialog-B0e10fRL.cjs +1 -0
  15. package/dist/NiceConfirmDialog-BBDgEMHv.js +81 -0
  16. package/dist/NiceConfirmDialog-C7kdr8jJ.js +81 -0
  17. package/dist/NiceConfirmDialog-DMHqPfFM.js +81 -0
  18. package/dist/NiceConfirmDialog-ZJpQLQQS.cjs +1 -0
  19. package/dist/NiceDataGrid-BzUw4dSu.cjs +10 -0
  20. package/dist/NiceDataGrid-CPKcVOVz.js +1743 -0
  21. package/dist/NiceDataGrid-DJr33WMy.cjs +10 -0
  22. package/dist/NiceDataGrid-D_4gZ1Hu.js +1736 -0
  23. package/dist/NiceDataGrid-DlUAaXhD.js +1736 -0
  24. package/dist/NiceDocumentViewer-8ghRVtfO.js +672 -0
  25. package/dist/NiceDocumentViewer-ChWtA_Ry.cjs +180 -0
  26. package/dist/NiceDocumentViewer-DwLUV7Tc.js +672 -0
  27. package/dist/NiceDocumentViewer-goMzF1w3.cjs +180 -0
  28. package/dist/NiceDocumentViewer-gt1mxzP8.js +672 -0
  29. package/dist/NiceForm-CHEAHxDw.js +4805 -0
  30. package/dist/NiceForm-CJUp1CL0.cjs +1 -0
  31. package/dist/NiceForm-Cp_RH3Yj.js +4805 -0
  32. package/dist/NiceForm-a6tGr6ss.js +4819 -0
  33. package/dist/NiceForm-jU89oe2S.cjs +1 -0
  34. package/dist/NiceGantt-BnQwyTfG.cjs +1 -0
  35. package/dist/NiceGantt-D8coFAvK.js +328 -0
  36. package/dist/NiceGantt-DOZfT6r5.js +328 -0
  37. package/dist/NiceGantt-DQzH1V-R.js +328 -0
  38. package/dist/NiceGantt-jQ8ZpXko.cjs +1 -0
  39. package/dist/NiceHtmlEditor-B1nlXJNW.cjs +10 -0
  40. package/dist/NiceHtmlEditor-Bv3VqJPG.js +862 -0
  41. package/dist/NiceHtmlEditor-CKsGj-Ei.cjs +10 -0
  42. package/dist/NiceHtmlEditor-CloMgyzg.js +841 -0
  43. package/dist/NiceHtmlEditor-DUAHmkWI.js +841 -0
  44. package/dist/NiceLoginForm-Ce_QLnLf.js +736 -0
  45. package/dist/NiceLoginForm-DLpNTQlR.cjs +1 -0
  46. package/dist/NiceLoginForm-Dg0286Cc.js +736 -0
  47. package/dist/NiceLoginForm-X05Vadeg.js +708 -0
  48. package/dist/NiceLoginForm-f_dBCnUi.cjs +1 -0
  49. package/dist/NiceMention-BByI4nFG.js +11120 -0
  50. package/dist/NiceMention-C2TPiMph.cjs +430 -0
  51. package/dist/NiceMention-C67vT6m0.js +11145 -0
  52. package/dist/NiceMention-D1cdy63w.cjs +430 -0
  53. package/dist/NiceMention-QIuggb9Y.js +11122 -0
  54. package/dist/NiceMention.css +1 -1
  55. package/dist/NiceModal-CHaan9al.js +95 -0
  56. package/dist/NiceModal-Czq6OEAT.js +95 -0
  57. package/dist/NiceModal-D-HFwawr.js +95 -0
  58. package/dist/NiceModal-DOy2XTzc.cjs +1 -0
  59. package/dist/NiceModal-DkawKzEE.cjs +1 -0
  60. package/dist/NiceModuleLifecyclePanel-1CsP8Zst.js +6997 -0
  61. package/dist/NiceModuleLifecyclePanel-Bkx4Yg-3.cjs +1 -0
  62. package/dist/NiceModuleLifecyclePanel-C5oYtczk.js +6999 -0
  63. package/dist/NiceModuleLifecyclePanel-DCcy2yYi.cjs +1 -0
  64. package/dist/NiceModuleLifecyclePanel-DqdgW-0s.js +7004 -0
  65. package/dist/NiceModuleLifecyclePanel.css +1 -1
  66. package/dist/NicePagination-7od5KUa3.cjs +1 -0
  67. package/dist/NicePagination-DMrkR8hH.cjs +1 -0
  68. package/dist/NicePagination-DQmZpsSQ.js +179 -0
  69. package/dist/NicePagination-DipQRjPq.js +172 -0
  70. package/dist/NicePagination-KhlVXYaT.js +172 -0
  71. package/dist/NicePivotGrid-B-KthuqL.cjs +152 -0
  72. package/dist/NicePivotGrid-CLCTHkKO.cjs +152 -0
  73. package/dist/NicePivotGrid-DV54FCsH.js +1174 -0
  74. package/dist/NicePivotGrid-DoWLUPUs.js +1167 -0
  75. package/dist/NicePivotGrid-etwpfccz.js +1167 -0
  76. package/dist/NiceSavedQueryPanel-BABkTNc5.js +5129 -0
  77. package/dist/NiceSavedQueryPanel-Cfeig83P.cjs +586 -0
  78. package/dist/NiceSavedQueryPanel-DTWRLseb.cjs +586 -0
  79. package/dist/NiceSavedQueryPanel-Dy154sxE.js +5129 -0
  80. package/dist/NiceSavedQueryPanel-v7AffOOe.js +5129 -0
  81. package/dist/NiceSavedQueryPanel.css +1 -1
  82. package/dist/NiceScheduler-BEgB7ZgF.cjs +5 -0
  83. package/dist/NiceScheduler-C9JprsEI.cjs +5 -0
  84. package/dist/NiceScheduler-DSP-PPh0.js +1645 -0
  85. package/dist/NiceScheduler-DuPnaA3t.js +1652 -0
  86. package/dist/NiceScheduler-Oa89YZx9.js +1645 -0
  87. package/dist/NiceSelect-A336yeLZ.js +433 -0
  88. package/dist/NiceSelect-B5hTbqi2.js +433 -0
  89. package/dist/NiceSelect-BYSgDYzq.cjs +1 -0
  90. package/dist/NiceSelect-Dudf2T5T.js +433 -0
  91. package/dist/NiceSelect-DwBAIrX7.cjs +1 -0
  92. package/dist/NiceWindow-B6zjBTl9.cjs +1 -0
  93. package/dist/NiceWindow-BKQEx7Vf.js +1623 -0
  94. package/dist/NiceWindow-BnTH7Gy0.js +1623 -0
  95. package/dist/NiceWindow-CZN9NVZw.cjs +1 -0
  96. package/dist/NiceWindow-lxtPR7yZ.js +1623 -0
  97. package/dist/NiceWindow.css +1 -1
  98. package/dist/charts-B8_V3_nq.cjs +882 -0
  99. package/dist/charts-BZgyyybE.js +31933 -0
  100. package/dist/charts-FuDk5-r6.js +31958 -0
  101. package/dist/charts-INj3yFo5.js +31946 -0
  102. package/dist/charts-NolNXKUL.cjs +882 -0
  103. package/dist/charts.cjs +1 -1
  104. package/dist/charts.css +1 -1
  105. package/dist/charts.mjs +1 -1
  106. package/dist/core-A_A6c7an.js +795 -0
  107. package/dist/core-B2iH2J_X.js +795 -0
  108. package/dist/core-BmspZEfD.js +795 -0
  109. package/dist/core-DAfLOet6.cjs +1 -0
  110. package/dist/core-ZG3bgnBR.cjs +1 -0
  111. package/dist/data-branching-B3TOqXAO.cjs +1 -0
  112. package/dist/data-branching-BUGiICDZ.js +6275 -0
  113. package/dist/data-branching-DMXmcocj.js +6275 -0
  114. package/dist/data-branching-YE8P9M5P.js +6275 -0
  115. package/dist/data-branching-t6uhAwIm.cjs +1 -0
  116. package/dist/data-branching.cjs +1 -1
  117. package/dist/data-branching.mjs +1 -1
  118. package/dist/data.cjs +1 -1
  119. package/dist/data.d.ts +7 -2
  120. package/dist/data.mjs +3 -3
  121. package/dist/devops-BhV3OmF7.js +8285 -0
  122. package/dist/devops-BqUxnbRi.cjs +17 -0
  123. package/dist/devops-Bx-Qwj9w.cjs +17 -0
  124. package/dist/devops-DYZatW45.js +8251 -0
  125. package/dist/devops-R98k2zpd.js +8251 -0
  126. package/dist/devops.cjs +1 -1
  127. package/dist/devops.d.ts +29 -16
  128. package/dist/devops.mjs +1 -1
  129. package/dist/editors.cjs +1 -1
  130. package/dist/editors.d.ts +35 -20
  131. package/dist/editors.mjs +7 -7
  132. package/dist/feedback.cjs +1 -1
  133. package/dist/feedback.mjs +3 -3
  134. package/dist/index.cjs +445 -445
  135. package/dist/index.css +1 -1
  136. package/dist/index.d.ts +190 -111
  137. package/dist/index.mjs +16635 -16351
  138. package/dist/lazy.cjs +1 -1
  139. package/dist/lazy.d.ts +31 -18
  140. package/dist/lazy.mjs +24 -24
  141. package/dist/navigation.cjs +1 -1
  142. package/dist/navigation.d.ts +17 -14
  143. package/dist/navigation.mjs +130 -130
  144. package/dist/no-code-BPaAS4wW.cjs +332 -0
  145. package/dist/no-code-CBwUVL1i.js +7447 -0
  146. package/dist/no-code-CjktkQ50.js +7447 -0
  147. package/dist/no-code-DW2NrRba.js +7447 -0
  148. package/dist/no-code-DmFxrZ5T.cjs +332 -0
  149. package/dist/no-code.cjs +1 -1
  150. package/dist/no-code.d.ts +2 -2
  151. package/dist/no-code.mjs +1 -1
  152. package/dist/overlays.cjs +1 -1
  153. package/dist/overlays.d.ts +4 -4
  154. package/dist/overlays.mjs +2 -2
  155. package/dist/pickerCommons-C4XWRUvH.cjs +1 -0
  156. package/dist/pickerCommons-C_BpYs_m.cjs +1 -0
  157. package/dist/pickerCommons-DAOXH_u5.js +1122 -0
  158. package/dist/pickerCommons-Dn4wnDco.js +1122 -0
  159. package/dist/pickerCommons-DskswPS5.js +1122 -0
  160. package/dist/pickerCommons.css +1 -1
  161. package/dist/style.css +7 -7
  162. package/package.json +3 -3
@@ -0,0 +1,430 @@
1
+ "use strict";const e=require("react/jsx-runtime"),y=require("./charts-NolNXKUL.cjs"),n=require("react"),Ze=require("react-dom"),Be=require("./NiceSelect-BYSgDYzq.cjs"),rt=require("./NiceForm-jU89oe2S.cjs"),Fe=require("./pickerCommons-C_BpYs_m.cjs"),Kn=require("./NiceHtmlEditor-B1nlXJNW.cjs"),Se=require("./NiceColorPicker-Cuc6YXqz.cjs"),_t=require("./NiceCodeEditor-DZM16My5.cjs"),Qt=require("./devops-BqUxnbRi.cjs"),Un=({min:t=0,max:i=100,step:a=1,startValue:o=t,endValue:r=i,onChange:h,showLabels:x=!0,formatLabel:_,valuePlacement:z="none",label:C,error:X,helperText:q,required:L,disabled:k,readOnly:J,loading:ne,size:ee="md",id:ie,className:I,style:j,accessMode:R,showKeyboardHints:f,labelPlacement:w,errorPlacement:U,labelWidth:u,controlWidth:g})=>{const P=y.Dc(R,ie),te=P==="hidden";(P==="disabled"||P==="readOnly")&&(k=!0);const{t:T}=y.Gt(),b=y.bc(ie),s=n.useRef(null),$=n.useMemo(()=>[y.Yc.increment,y.Yc.decrement,y.Yc.first,y.Yc.last,{key:"Tab",description:T("shortcuts.switchThumb","Switch thumb")}],[T]),M=p=>(p-t)/(i-t)*100,l=p=>_?_(p):String(p),c=p=>{const E=Math.round(p/a)*a;return Math.max(t,Math.min(i,E))},d=n.useCallback((p,E)=>{p.preventDefault();const v=s.current;if(!v||k)return;const B=V=>{const N=v.getBoundingClientRect(),D=Math.max(0,Math.min(1,(V.clientX-N.left)/N.width)),S=c(t+D*(i-t));E==="start"?h?.(Math.min(S,r),r):h?.(o,Math.max(S,o))},A=()=>{document.removeEventListener("pointermove",B),document.removeEventListener("pointerup",A)};document.addEventListener("pointermove",B),document.addEventListener("pointerup",A)},[t,i,a,o,r,h,k]);return te?null:e.jsxs("div",{className:`nice-field nice-field--${ee} nice-field--rangeslider ${w==="left"?"nice-field--label-left":""} ${U==="right"?"nice-field--error-right":""} ${X?"nice-field--error":""} ${ne?"nice-field--loading":""} ${I||""}`,style:{...j,...u!=null&&{"--nice-field-label-width":typeof u=="number"?`${u}px`:u},...g!=null&&{"--nice-field-control-width":typeof g=="number"?`${g}px`:g}},"aria-busy":ne||void 0,children:[(C||z==="right"&&w!=="left")&&(w!=="left"?e.jsxs("div",{className:"nice-range-slider__header",children:[C?e.jsx("label",{className:"nice-field__label",htmlFor:b,children:e.jsxs("span",{className:"nice-field__label-text",children:[C,L&&e.jsx("span",{className:"nice-field__required",children:"*"}),f&&e.jsx(y.ha,{shortcuts:$,size:"sm"})]})}):e.jsx("span",{}),z==="right"&&e.jsxs("span",{className:"nice-range-slider__value nice-range-slider__value--header",children:[l(o)," – ",l(r)]})]}):C&&e.jsx("label",{className:"nice-field__label",htmlFor:b,children:e.jsxs("span",{className:"nice-field__label-text",children:[C,L&&e.jsx("span",{className:"nice-field__required",children:"*"}),f&&e.jsx(y.ha,{shortcuts:$,size:"sm"})]})})),e.jsxs("div",{className:"nice-field__control",children:[e.jsxs("div",{className:"nice-range-slider__stack",children:[e.jsxs("div",{className:`nice-range-slider ${x?"nice-range-slider--with-labels":""} ${C?"nice-range-slider--has-field-label":""}`,ref:s,children:[e.jsx("div",{className:"nice-range-slider__track",children:e.jsx("div",{className:"nice-range-slider__fill",style:{left:`${M(o)}%`,width:`${M(r)-M(o)}%`}})}),e.jsx("div",{className:"nice-range-slider__thumb",style:{left:`${M(o)}%`},onPointerDown:p=>J?void 0:d(p,"start"),role:"slider","aria-valuemin":t,"aria-valuemax":r,"aria-valuenow":o,tabIndex:k?-1:0,id:b}),e.jsx("div",{className:"nice-range-slider__thumb",style:{left:`${M(r)}%`},onPointerDown:p=>J?void 0:d(p,"end"),role:"slider","aria-valuemin":o,"aria-valuemax":i,"aria-valuenow":r,tabIndex:k?-1:0})]}),x&&e.jsxs("div",{className:"nice-range-slider__values",children:[e.jsx("span",{className:"nice-range-slider__values-start",style:{left:`${M(o)}%`},children:l(o)}),e.jsx("span",{className:"nice-range-slider__values-end",style:{left:`${M(r)}%`},children:l(r)})]}),z==="bottom"&&e.jsxs("div",{className:"nice-range-slider__value nice-range-slider__value--bottom",children:[l(o)," – ",l(r)]})]}),z==="right"&&w==="left"&&e.jsxs("span",{className:"nice-range-slider__value nice-range-slider__value--inline",children:[l(o)," – ",l(r)]}),ne&&e.jsx("span",{className:"nice-field__spinner",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})}),U==="right"&&X&&e.jsx("div",{className:"nice-field__error",role:"alert",children:X}),U==="right"&&!X&&q&&e.jsx("div",{className:"nice-field__helper",children:q})]}),U!=="right"&&X&&e.jsx("div",{className:"nice-field__error",role:"alert",children:X}),U!=="right"&&!X&&q&&e.jsx("div",{className:"nice-field__helper",children:q})]})},Gn={xxs:36,xs:48,sm:64,md:80,lg:100,xl:128,xxl:160,small:64,medium:80,large:100},ct=6,at=135,Zt=405,it=Zt-at;function kt(t,i,a,o){const r=(o-90)*(Math.PI/180);return{x:t+a*Math.cos(r),y:i+a*Math.sin(r)}}function Tt(t,i,a,o,r){const h=kt(t,i,a,o),x=kt(t,i,a,r),_=r-o>180?1:0;return`M ${h.x} ${h.y} A ${a} ${a} 0 ${_} 1 ${x.x} ${x.y}`}const en=n.forwardRef(({value:t=0,onChange:i,min:a=0,max:o=100,step:r=1,showValue:h=!0,valueTemplate:x="{value}",label:_,helperText:z,error:C,required:X,disabled:q,readOnly:L,size:k="md",name:J,id:ne,className:ee,style:ie,labelPlacement:I="top",errorPlacement:j,labelWidth:R,controlWidth:f,loading:w,isLabelCentered:U=!0,...u},g)=>{const P=y.bc(ne),te=n.useRef(!1),T=n.useRef(null),b=typeof k=="number"?k:Gn[k],s=b/2,$=b/2,M=(b-ct*2)/2,l=o>a?(t-a)/(o-a):0,c=at+l*it,d=n.useCallback(A=>{let V=A-at;V<0&&(V+=360),V>it&&(V=V-it<360-V?it:0);const N=Math.max(0,Math.min(1,V/it)),D=a+N*(o-a),S=Math.round(D/r)*r;return Math.max(a,Math.min(o,S))},[a,o,r]),p=n.useCallback(A=>{if(q||L)return;const V=T.current;if(!V)return;const N=V.getBoundingClientRect(),D=A.clientX-N.left-N.width/2,S=A.clientY-N.top-N.height/2;let ae=Math.atan2(D,-S)*(180/Math.PI);ae<0&&(ae+=360);const ue=d(ae);i?.(ue)},[d,q,L,i]);n.useEffect(()=>{const A=N=>{te.current&&p(N)},V=()=>{te.current=!1};return window.addEventListener("pointermove",A),window.addEventListener("pointerup",V),()=>{window.removeEventListener("pointermove",A),window.removeEventListener("pointerup",V)}},[p]);const E=n.useCallback(A=>{if(q||L)return;let V=t;A.key==="ArrowUp"||A.key==="ArrowRight"?(A.preventDefault(),V=Math.min(o,t+r)):(A.key==="ArrowDown"||A.key==="ArrowLeft")&&(A.preventDefault(),V=Math.max(a,t-r)),V!==t&&i?.(V)},[t,i,a,o,r,q,L]),v=(x||"{value}").replace("{value}",String(t)),B=kt(s,$,M,c);return e.jsxs("div",{className:`nice-field nice-knob-field nice-knob-field--err-${j||"bottom"} nice-field--${typeof k=="string"?k:"md"} ${w?"nice-field--loading":""} ${ee||""}`,style:{...ie,...R!=null&&{"--nice-field-label-width":typeof R=="number"?`${R}px`:R},...f!=null&&{"--nice-field-control-width":typeof f=="number"?`${f}px`:f}},"aria-busy":w||void 0,...u,children:[e.jsxs("div",{className:`nice-knob-field__inner nice-knob-field--${I} ${U?"nice-knob-field--label-centered":""}`,children:[_&&e.jsx("label",{htmlFor:P,className:`nice-field__label ${X?"nice-field__label--required":""}`,children:_}),e.jsx("div",{className:"nice-field__control",children:e.jsxs("div",{ref:A=>{T.current=A,typeof g=="function"?g(A):g&&(g.current=A)},className:`nice-knob nice-knob--${k} ${q?"nice-knob--disabled":""} ${C?"nice-knob--error":""}`,role:"slider",id:P,tabIndex:q?-1:0,"aria-valuenow":t,"aria-valuemin":a,"aria-valuemax":o,"aria-disabled":q,"aria-invalid":!!C,onPointerDown:A=>{q||L||(te.current=!0,p(A))},onKeyDown:E,children:[e.jsxs("svg",{width:b,height:b,viewBox:`0 0 ${b} ${b}`,children:[e.jsx("path",{d:Tt(s,$,M,at,Zt),fill:"none",stroke:"var(--nice-border-color, #d1d5db)",strokeWidth:ct,strokeLinecap:"round"}),l>0&&e.jsx("path",{d:Tt(s,$,M,at,c),fill:"none",stroke:"var(--nice-primary, #3b82f6)",strokeWidth:ct,strokeLinecap:"round"}),e.jsx("circle",{cx:B.x,cy:B.y,r:ct,fill:"var(--nice-primary, #3b82f6)"})]}),h&&e.jsx("span",{className:"nice-knob__value",children:v}),J&&e.jsx("input",{type:"hidden",name:J,value:t}),w&&e.jsx("span",{className:"nice-knob__spinner","aria-hidden":"true",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})})]})})]}),C&&e.jsx("div",{className:"nice-field__error",role:"alert",children:C}),!C&&z&&e.jsx("div",{className:"nice-field__helper",children:z})]})});en.displayName="NiceKnob";function Xn(t,{open:i,onSelect:a,onClose:o,onOpen:r,loop:h=!1}){const[x,_]=n.useState(0);n.useEffect(()=>{_(C=>t.length===0?0:Math.min(Math.max(C,0),t.length-1))},[t.length]);const z=n.useCallback(C=>{if(!i){(C.key==="ArrowDown"||C.key==="ArrowUp")&&(C.preventDefault(),r?.());return}if(C.key==="ArrowDown")C.preventDefault(),_(X=>t.length===0?0:h?(X+1)%t.length:Math.min(X+1,t.length-1));else if(C.key==="ArrowUp")C.preventDefault(),_(X=>t.length===0?0:h?(X-1+t.length)%t.length:Math.max(X-1,0));else if(C.key==="Enter"){const X=t[x];X!==void 0&&(C.preventDefault(),a(X,x))}else C.key==="Escape"&&o?.()},[i,t,x,h,a,o,r]);return{activeIndex:x,setActiveIndex:_,handleKeyDown:z}}const qn=({options:t,value:i,defaultValue:a,onChange:o,searchable:r=!0,clearable:h,loading:x,placeholder:_,label:z,error:C,helperText:X,required:q,disabled:L,readOnly:k,size:J="md",id:ne,className:ee,style:ie,data:I,columns:j,valueField:R="id",displayField:f,dropdownWidth:w,menuGap:U,labelPlacement:u,errorPlacement:g,labelWidth:P,controlWidth:te})=>{const T=L||k||x,b=y.bc(ne),{t:s}=y.Gt(),[$,M]=y.Vu({value:i,defaultValue:a,fallbackValue:"",onChange:o,componentName:"NiceLookup"}),[l,c]=n.useState(!1),[d,p]=n.useState(""),E=n.useRef(null),v=n.useRef(null),{popupRef:B,coords:A,ready:V,themeClass:N,portalTarget:D}=Be.useAnchoredPopup(l,v,()=>c(!1)),S=!!(I&&j&&j.length>0),ae=f??(j&&j[0]?.key),ue=n.useMemo(()=>!S||!I?[]:I.map(Z=>({value:String(Z[R]??""),label:ae?String(Z[ae]??""):""})),[S,I,R,ae]),ce=S?ue:t??[],be=ce.find(Z=>String(Z.value)===$),ve=n.useMemo(()=>{if(!S||!I)return[];if(!d)return I;const Z=d.toLowerCase();return I.filter(de=>j.some(O=>String(de[O.key]??"").toLowerCase().includes(Z)))},[S,I,j,d]),_e=n.useMemo(()=>{if(S||!d)return ce;const Z=d.toLowerCase();return ce.filter(de=>de.label.toLowerCase().includes(Z))},[ce,d,S]),he=S?ve:_e,{activeIndex:ye,setActiveIndex:xe,handleKeyDown:re}=Xn(he,{open:l,onSelect:Z=>{const de=String(S?Z[R]??"":Z.value);M(de),c(!1),p("")},onClose:()=>c(!1)});return e.jsxs("div",{className:`nice-field nice-field--lookup nice-field--${J} ${C?"nice-field--error":""} ${u==="left"?"nice-field--label-left":""} ${g==="right"&&(C||X)?"nice-field--error-right":""} ${x?"nice-field--loading":""} ${L?"nice-field--disabled":""} ${ee||""}`,style:{...te!=null&&{"--nice-field-control-width":typeof te=="number"?`${te}px`:te},...P!=null&&{"--nice-field-label-width":typeof P=="number"?`${P}px`:P},...U!=null&&{"--nice-dropdown-gap":`${U}px`},...ie},"aria-busy":x||void 0,ref:E,children:[z&&e.jsxs("label",{className:"nice-field__label",htmlFor:b,children:[z,q&&e.jsx("span",{className:"nice-field__required",children:"*"})]}),e.jsxs("div",{className:"nice-field__control",children:[e.jsxs("div",{className:"nice-field__input-wrap",ref:v,children:[e.jsxs("button",{type:"button",id:b,className:`nice-select__trigger ${L?"nice-select__trigger--disabled":""}`,onClick:()=>!T&&c(!l),disabled:L,"aria-readonly":k||void 0,"aria-expanded":l,children:[e.jsx("span",{children:be?.label||_||s("controls.select","Select...")}),e.jsxs("span",{style:{display:"flex",alignItems:"center",gap:4},children:[h&&$&&!L&&!k&&e.jsx("span",{className:"nice-input__clear",role:"button",tabIndex:0,"aria-label":s("controls.clear","Clear"),onClick:Z=>{Z.stopPropagation(),M("")},children:e.jsx(y.oa,{name:"close",size:14})}),e.jsx("span",{className:`nice-select__arrow${k?" nice-select__arrow--hidden":""}`,children:e.jsx(y.oa,{name:"chevron-down",size:16})})]})]}),l&&A&&D&&Ze.createPortal(e.jsxs("div",{ref:B,className:`nice-dropdown nice-lookup__dropdown${N?` ${N}`:""}`,"data-theme":N==="nice-dark"?"dark":N==="nice-light"?"light":void 0,style:{position:"fixed",top:A.top,left:A.left,zIndex:1e3,marginTop:"var(--nice-dropdown-gap, 0px)",background:"var(--nice-bg-primary)",border:"1px solid var(--nice-border-color)",borderRadius:"var(--nice-radius-md)",boxShadow:"0 4px 16px var(--nice-overlay-15, rgba(0, 0, 0, 0.15))",minWidth:A.width,width:w!=null?typeof w=="number"?`${w}px`:w:S?"max-content":A.width,opacity:V?1:0,pointerEvents:V?void 0:"none"},children:[r&&e.jsx("div",{className:"nice-dropdown__search",style:{padding:6},children:e.jsx("input",{type:"text",value:d,onChange:Z=>{p(Z.target.value),xe(0)},onKeyDown:re,placeholder:s("controls.search","Search..."),autoFocus:!0,style:{width:"100%",padding:"4px 8px",border:"1px solid var(--nice-border-color)",borderRadius:4,background:"var(--nice-bg-primary)",color:"var(--nice-text-primary)"}})}),S?e.jsxs("table",{className:"nice-lookup__grid",role:"listbox",style:{width:"100%",borderCollapse:"collapse",color:"var(--nice-text-primary)"},children:[e.jsx("thead",{children:e.jsx("tr",{children:j.map(Z=>e.jsx("th",{style:{padding:"6px 10px",textAlign:"left",fontSize:12,fontWeight:600,color:"var(--nice-text-secondary)",background:"var(--nice-bg-secondary)",borderBottom:"1px solid var(--nice-border-color)",width:Z.width!=null?typeof Z.width=="number"?`${Z.width}px`:Z.width:void 0},children:Z.header},Z.key))})}),e.jsx("tbody",{children:ve.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:j.length,style:{padding:12,textAlign:"center",color:"var(--nice-text-muted)"},children:s("controls.noResults","No results")})}):ve.map((Z,de)=>{const O=String(Z[R]??""),H=O===$,Y=de===ye;return e.jsx("tr",{role:"option","aria-selected":H,onClick:()=>{M(O),c(!1),p("")},style:{cursor:"pointer",background:H||Y?"var(--nice-hover-bg)":"transparent"},onMouseEnter:()=>xe(de),children:j.map(ge=>e.jsx("td",{style:{padding:"6px 10px",fontSize:13,borderBottom:"1px solid var(--nice-border-color)"},children:String(Z[ge.key]??"")},ge.key))},O)})})]}):e.jsx("ul",{className:"nice-dropdown__list",role:"listbox",style:{listStyle:"none",margin:0,padding:4,maxHeight:240,overflowY:"auto",position:"static",background:"transparent",border:"none",borderRadius:0,boxShadow:"none"},children:_e.length===0?e.jsx("li",{className:"nice-dropdown__empty",style:{padding:8,color:"var(--nice-text-muted)"},children:s("controls.noResults","No results")}):_e.map((Z,de)=>e.jsx("li",{role:"option",className:`nice-dropdown__option ${String(Z.value)===$?"nice-dropdown__option--selected":""} ${de===ye?"nice-dropdown__option--active":""}`,onClick:()=>{M(String(Z.value)),c(!1),p("")},onMouseEnter:()=>xe(de),"aria-selected":String(Z.value)===$,children:Z.label},String(Z.value)))})]}),D)]}),x&&e.jsx("span",{className:"nice-field__spinner",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})}),g==="right"&&C&&e.jsx("div",{className:"nice-field__error",role:"alert",children:C}),g==="right"&&!C&&X&&e.jsx("div",{className:"nice-field__hint",children:X})]}),g!=="right"&&C&&e.jsx("div",{className:"nice-field__error",children:C}),g!=="right"&&!C&&X&&e.jsx("div",{className:"nice-field__hint",children:X})]})};function Vn(t){const i=[],a=o=>{for(const r of o)i.push(r),r.children&&a(r.children)};return a(t),i}function tn(t,i){const a=i.toLowerCase();return t.reduce((o,r)=>{const h=r.children?tn(r.children,i):[];return(r.label.toLowerCase().includes(a)||h.length>0)&&o.push({...r,children:h.length>0?h:r.children}),o},[])}const nn=({node:t,level:i,selectedKeys:a,expandedKeys:o,onToggleExpand:r,onSelect:h,selectableLeafsOnly:x,maxDepth:_})=>{const z=typeof _=="number"?Math.min(10,Math.max(1,_)):1/0,X=!(i+1>=z)&&t.children&&t.children.length>0,q=o.has(t.key),L=a.has(t.key),k=!X,J=!t.disabled&&(!x||k),ne=Math.min(i+1,10),ee={paddingLeft:i*16+14,"--nice-row-bg":`var(--nice-tree-level-${ne}-bg, transparent)`,"--nice-row-text":`var(--nice-tree-level-${ne}-text, inherit)`,"--nice-row-hover-bg":`var(--nice-tree-level-${ne}-hover-bg, var(--nice-bg-secondary, #f3f4f6))`,"--nice-row-active-bg":`var(--nice-tree-level-${ne}-active-bg, var(--nice-primary-tint-10, rgba(59,130,246,0.1)))`};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`nice-tree-select__node ${L?"nice-tree-select__node--selected":""} ${t.disabled?"nice-tree-select__node--disabled":""}`,style:ee,"data-nice-depth":ne,onClick:()=>{t.disabled||(X?r(t.key):J&&h(t.key))},role:"treeitem","aria-selected":L,"aria-expanded":X?q:void 0,"aria-disabled":t.disabled,children:[X?e.jsx("button",{type:"button",className:"nice-tree-select__toggle-btn",onClick:ie=>{ie.stopPropagation(),r(t.key)},"aria-label":"Toggle",children:e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"currentColor",style:{transform:q?"rotate(90deg)":"none",transition:"transform 0.15s"},children:e.jsx("path",{d:"M4.5 2l4 4-4 4"})})}):e.jsx("span",{style:{width:12,display:"inline-block"}}),(t.icon==null,null),e.jsx("span",{className:"nice-tree-select__node-label",children:t.label})]}),X&&q&&t.children.map(ie=>e.jsx(nn,{node:ie,level:i+1,selectedKeys:a,expandedKeys:o,onToggleExpand:r,onSelect:h,selectableLeafsOnly:x,maxDepth:_},ie.key))]})},an=n.forwardRef(({nodes:t,value:i,onChange:a,multiple:o=!1,searchable:r=!1,placeholder:h,selectableLeafsOnly:x=!1,clearable:_=!1,maxDepth:z,label:C,helperText:X,error:q,required:L,disabled:k,readOnly:J,size:ne="md",name:ee,id:ie,className:I,style:j,controlWidth:R,menuGap:f,...w},U)=>{const{t:u}=y.Gt(),g=y.bc(ie),[P,te]=n.useState(!1),[T,b]=n.useState(""),[s,$]=n.useState(new Set),M=n.useRef(null),{popupRef:l,coords:c,ready:d,themeClass:p,portalTarget:E}=Be.useAnchoredPopup(P,M,()=>te(!1)),v=n.useMemo(()=>i==null?new Set:new Set(Array.isArray(i)?i:[i]),[i]),B=n.useMemo(()=>T?tn(t,T):t,[t,T]),A=n.useMemo(()=>{const S=Vn(t);return Array.from(v).map(ae=>S.find(ue=>ue.key===ae)?.label).filter(Boolean)},[v,t]),V=n.useCallback(S=>{$(ae=>{const ue=new Set(ae);return ue.has(S)?ue.delete(S):ue.add(S),ue})},[]),N=n.useCallback(S=>{if(o){const ae=new Set(v);ae.has(S)?ae.delete(S):ae.add(S),a?.(Array.from(ae))}else a?.(S),te(!1)},[o,v,a]),D=n.useCallback(S=>{S.stopPropagation(),a?.(o?[]:"")},[a,o]);return e.jsxs("div",{className:`nice-field nice-field--${ne} ${I||""}`,style:{width:"fit-content",maxWidth:"100%",...f!=null&&{"--nice-dropdown-gap":`${f}px`},...j},...w,children:[C&&e.jsx("label",{htmlFor:g,className:`nice-field__label ${L?"nice-field__label--required":""}`,children:C}),e.jsxs("div",{ref:M,className:"nice-tree-select",style:{position:"relative",width:R!=null&&R!==""?typeof R=="number"?`${R}px`:R:"var(--nice-field-control-width, 220px)"},children:[e.jsxs("div",{ref:U,id:g,className:`nice-input nice-input--${ne} ${q?"nice-input--error":""} ${k?"nice-input--disabled":""} ${J?"nice-input--readonly":""}`,role:"combobox","aria-expanded":P,"aria-haspopup":"tree","aria-invalid":!!q,tabIndex:k?-1:0,onClick:()=>!k&&!J&&te(!P),onKeyDown:S=>{(S.key==="Enter"||S.key===" ")&&(S.preventDefault(),!k&&!J&&te(!P))},children:[e.jsx("span",{className:"nice-tree-select__display",children:A.length>0?A.join(", "):e.jsx("span",{className:"nice-tree-select__placeholder",children:h??u("controls.select","Select...")})}),_&&v.size>0&&e.jsx("button",{type:"button",className:"nice-input__clear",onClick:D,"aria-label":u("controls.clear","Clear"),children:e.jsx(y.oa,{name:"close",size:14})}),e.jsx("span",{className:"nice-tree-select__arrow",style:{transform:P?"rotate(180deg)":"none",transition:"transform 0.15s"},children:e.jsx(y.oa,{name:"chevron-down",size:14})})]}),P&&c&&E&&Ze.createPortal(e.jsxs("div",{ref:l,className:`nice-tree-select__dropdown${p?` ${p}`:""}`,"data-theme":p==="nice-dark"?"dark":p==="nice-light"?"light":void 0,role:"tree",style:{position:"fixed",left:c.left,top:c.top,width:c.width,minWidth:c.width,zIndex:1e3,opacity:d?1:0,pointerEvents:d?void 0:"none"},children:[r&&e.jsx("div",{className:"nice-select__search",onClick:S=>S.stopPropagation(),role:"presentation",children:e.jsx("input",{type:"text",placeholder:u("controls.search","Search..."),value:T,onChange:S=>b(S.target.value),autoFocus:!0})}),e.jsx("div",{className:"nice-tree-select__list",children:B.length===0?e.jsx("div",{className:"nice-tree-select__empty",children:u("controls.noResults","No results")}):B.map(S=>e.jsx(nn,{node:S,level:0,selectedKeys:v,expandedKeys:s,onToggleExpand:V,onSelect:N,selectableLeafsOnly:x,maxDepth:z},S.key))})]}),E)]}),ee&&e.jsx("input",{type:"hidden",name:ee,value:Array.isArray(i)?i.join(","):i??""}),q&&e.jsx("div",{id:`${g}-error`,className:"nice-field__error",role:"alert",children:q}),!q&&X&&e.jsx("div",{id:`${g}-helper`,className:"nice-field__helper",children:X})]})});an.displayName="NiceTreeSelect";const Wn=({displayValue:t,placeholder:i,clearable:a,children:o,onClear:r,open:h,onOpenChange:x,dropdownWidth:_,searchable:z=!0,onSearch:C,searchPlaceholder:X,label:q,error:L,helperText:k,required:J,disabled:ne,size:ee="md",id:ie,className:I,style:j,accessMode:R,showKeyboardHints:f,displayStyle:w})=>{y.rc("input",w),y.ac("input",w);const U=y.Dc(R,ie),u=U==="hidden";(U==="disabled"||U==="readOnly")&&(ne=!0);const g=y.bc(ie),{t:P}=y.Gt(),[te,T]=n.useState(!1),[b,s]=n.useState(""),$=n.useRef(null),M=n.useRef(null),l=h??te,c=n.useMemo(()=>[{key:"Enter",description:P("shortcuts.openDropdown","Open dropdown")},y.Yc.cancel],[P]),d=V=>{x?x(V):T(V)},{popupRef:p,coords:E,ready:v,themeClass:B,portalTarget:A}=Be.useAnchoredPopup(l,M,()=>d(!1));return u?null:e.jsxs("div",{className:`nice-field nice-field--${ee} ${L?"nice-field--error":""} ${I||""}`,style:j,ref:$,children:[q&&e.jsxs("label",{className:"nice-field__label",htmlFor:g,children:[q,J&&e.jsx("span",{className:"nice-field__required",children:"*"}),f&&e.jsx(y.ha,{shortcuts:c,size:"sm"})]}),e.jsxs("div",{className:"nice-field__input-wrap",ref:M,children:[e.jsxs("button",{type:"button",id:g,className:"nice-select__trigger",onClick:()=>!ne&&d(!l),disabled:ne,children:[e.jsx("span",{children:t||i||P("controls.select","Select...")}),e.jsxs("span",{style:{display:"flex",alignItems:"center",gap:4},children:[a&&t&&!ne&&e.jsx("span",{className:"nice-input__clear",role:"button",tabIndex:0,"aria-label":P("controls.clear","Clear"),onClick:V=>{V.stopPropagation(),r?.()},onKeyDown:V=>{(V.key==="Enter"||V.key===" ")&&(V.preventDefault(),V.stopPropagation(),r?.())},children:e.jsx(y.oa,{name:"close",size:14})}),e.jsx("span",{className:"nice-select__arrow",children:e.jsx(y.oa,{name:"chevron-down",size:16})})]})]}),l&&E&&A&&Ze.createPortal(e.jsxs("div",{ref:p,className:`nice-dropdown${B?` ${B}`:""}`,"data-theme":B==="nice-dark"?"dark":B==="nice-light"?"light":void 0,style:{position:"fixed",left:E.left,top:E.top,width:_??E.width,minWidth:_??E.width,zIndex:1e3,maxHeight:320,overflowY:"auto",opacity:v?1:0,pointerEvents:v?void 0:"none"},children:[z&&C&&e.jsx("div",{className:"nice-select__search",children:e.jsx("input",{type:"text",value:b,onChange:V=>{s(V.target.value),C(V.target.value)},placeholder:X??P("controls.search","Search..."),autoFocus:!0})}),o]}),A)]}),L&&e.jsx("div",{className:"nice-field__error",children:L}),k&&!L&&e.jsx("div",{className:"nice-field__hint",children:k})]})};function Xe(t,i){return String(t[i])}const Jn={xxs:10,xs:12,sm:12,md:14,lg:18,xl:22,xxl:26},on=n.forwardRef(({source:t,target:i,onChange:a,keyField:o="id",labelField:r="label",renderItem:h,filterable:x=!1,searchable:_,groupBy:z,sortable:C=!1,bulkActions:X=!0,maxRight:q,sourceHeader:L,targetHeader:k,disabled:J=!1,size:ne="md",className:ee,style:ie,id:I,...j},R)=>{const{t:f}=y.Gt(),w=Jn[ne]??14,[U,u]=n.useState(new Set),[g,P]=n.useState(new Set),[te,T]=n.useState(""),[b,s]=n.useState(""),[$,M]=n.useState(null),l=n.useCallback((V,N,D)=>{N(S=>{const ae=new Set(S);return ae.has(D)?ae.delete(D):ae.add(D),ae})},[]),c=n.useCallback(()=>{const V=t.filter(ae=>U.has(Xe(ae,o))),N=t.filter(ae=>!U.has(Xe(ae,o))),D=typeof q=="number"?V.slice(0,Math.max(0,q-i.length)):V,S=V.slice(D.length);a([...N,...S],[...i,...D]),u(new Set)},[t,i,U,o,a,q]),d=n.useCallback(()=>{const V=i.filter(D=>g.has(Xe(D,o))),N=i.filter(D=>!g.has(Xe(D,o)));a([...t,...V],N),P(new Set)},[t,i,g,o,a]),p=n.useCallback(()=>{if(typeof q=="number"){const V=Math.max(0,q-i.length),N=t.slice(0,V),D=t.slice(V);a(D,[...i,...N])}else a([],[...i,...t]);u(new Set)},[t,i,a,q]),E=n.useCallback(()=>{a([...t,...i],[]),P(new Set)},[t,i,a]),v=(V,N)=>{if(!N)return V;const D=N.toLowerCase();return V.filter(S=>String(S[r]).toLowerCase().includes(D))},B=X===!1?{moveAll:!1,removeAll:!1}:X===!0||X===void 0?{moveAll:!0,removeAll:!0}:{moveAll:X.moveAll??!0,removeAll:X.removeAll??!0},A=(V,N,D,S,ae,ue,ce)=>{let be=v(V,S);C||(be=[...be].sort((Z,de)=>String(Z[r]).localeCompare(String(de[r]),void 0,{numeric:!0,sensitivity:"base"})));const ve=_===!0||x&&_===void 0?"both":_??!1,_e=ve==="both"||ve==="left"&&ce==="left"||ve==="right"&&ce==="right",he=(()=>{if(!z)return[{label:"",items:be}];const Z=new Map;for(const de of be){const O=String(z(de));let H=Z.get(O);H||(H=[],Z.set(O,H)),H.push(de)}return[...Z.entries()].map(([de,O])=>({label:de,items:O}))})(),ye=(Z,de)=>{Z.dataTransfer.setData("text/plain",de),Z.dataTransfer.effectAllowed="move"},xe=(Z,de)=>{if(Z.preventDefault(),!C)return;const O=Z.currentTarget.getBoundingClientRect(),H=Z.clientY<O.top+O.height/2;M(Y=>Y&&Y.side===ce&&Y.key===de&&Y.before===H?Y:{side:ce,key:de,before:H})},re=(Z,de)=>{Z.preventDefault();const O=$?.before??!1;M(null);const H=Z.dataTransfer.getData("text/plain");if(!H||!C)return;const ge=[...ce==="right"?i:t],le=ge.findIndex(se=>Xe(se,o)===H),F=ge.findIndex(se=>Xe(se,o)===de);if(le===-1||F===-1||H===de)return;let Q=O?F:F+1;const[K]=ge.splice(le,1);le<Q&&(Q-=1),ge.splice(Q,0,K),a(ce==="right"?t:ge,ce==="right"?ge:i)};return e.jsxs("div",{className:"nice-picklist__panel",children:[ue&&e.jsx("div",{className:"nice-picklist__header",children:ue}),_e&&e.jsx("div",{className:"nice-picklist__filter",children:e.jsx("input",{className:"nice-input__native",type:"text",size:1,placeholder:f("controls.search","Search..."),value:S,onChange:Z=>ae(Z.target.value)})}),e.jsxs("div",{className:"nice-picklist__list",role:"listbox","aria-multiselectable":"true",children:[he.map(Z=>e.jsxs(n.Fragment,{children:[Z.label&&e.jsx("div",{className:"nice-picklist__group-header",role:"presentation",children:Z.label}),Z.items.map(de=>{const O=Xe(de,o),H=N.has(O),ge=$&&$.side===ce&&$.key===O?$.before?"nice-picklist__item--drop-before":"nice-picklist__item--drop-after":"";return e.jsxs("div",{className:`nice-picklist__item ${H?"nice-picklist__item--selected":""} ${ge}`,role:"option","aria-selected":H,draggable:C,onDragStart:C?le=>ye(le,O):void 0,onDragOver:C?le=>xe(le,O):void 0,onDrop:C?le=>re(le,O):void 0,onDragEnd:C?()=>M(null):void 0,onClick:()=>!J&&l(N,D,O),children:[C&&e.jsx("span",{className:"nice-picklist__drag-handle","aria-hidden":"true",children:e.jsxs("svg",{width:w,height:w,viewBox:"0 0 20 20",fill:"currentColor",children:[e.jsx("circle",{cx:"7",cy:"5",r:"1.5"}),e.jsx("circle",{cx:"13",cy:"5",r:"1.5"}),e.jsx("circle",{cx:"7",cy:"10",r:"1.5"}),e.jsx("circle",{cx:"13",cy:"10",r:"1.5"}),e.jsx("circle",{cx:"7",cy:"15",r:"1.5"}),e.jsx("circle",{cx:"13",cy:"15",r:"1.5"})]})}),h?h(de,ce):String(de[r])]},O)})]},Z.label||"__none__")),be.length===0&&e.jsx("div",{className:"nice-picklist__empty",children:f("controls.noItems","No items")})]})]})};return e.jsxs("div",{ref:R,id:I,className:`nice-picklist nice-picklist--${ne} ${J?"nice-picklist--disabled":""} ${ee||""}`,style:ie,...j,children:[A(t,U,u,te,T,L??f("picklist.source","Available"),"left"),e.jsxs("div",{className:"nice-picklist__controls",children:[e.jsx("button",{type:"button",className:`nice-btn nice-btn--outline nice-btn--${ne}`,disabled:J||U.size===0,onClick:c,"aria-label":f("picklist.moveRight","Move right"),children:e.jsx("svg",{width:w,height:w,viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{d:"M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z"})})}),B.moveAll&&e.jsx("button",{type:"button",className:`nice-btn nice-btn--outline nice-btn--${ne}`,disabled:J||t.length===0,onClick:p,"aria-label":f("picklist.moveAllRight","Move all right"),children:e.jsxs("svg",{width:w,height:w,viewBox:"0 0 20 20",fill:"currentColor",children:[e.jsx("path",{d:"M4.293 14.707a1 1 0 010-1.414L7.586 10 4.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z"}),e.jsx("path",{d:"M10.293 14.707a1 1 0 010-1.414L13.586 10 10.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z"})]})}),e.jsx("button",{type:"button",className:`nice-btn nice-btn--outline nice-btn--${ne}`,disabled:J||g.size===0,onClick:d,"aria-label":f("picklist.moveLeft","Move left"),children:e.jsx("svg",{width:w,height:w,viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{d:"M12.707 5.293a1 1 0 010 1.414L9.414 10l3.293 3.293a1 1 0 01-1.414 1.414l-4-4a1 1 0 010-1.414l4-4a1 1 0 011.414 0z"})})}),B.removeAll&&e.jsx("button",{type:"button",className:`nice-btn nice-btn--outline nice-btn--${ne}`,disabled:J||i.length===0,onClick:E,"aria-label":f("picklist.moveAllLeft","Move all left"),children:e.jsxs("svg",{width:w,height:w,viewBox:"0 0 20 20",fill:"currentColor",children:[e.jsx("path",{d:"M15.707 5.293a1 1 0 010 1.414L12.414 10l3.293 3.293a1 1 0 01-1.414 1.414l-4-4a1 1 0 010-1.414l4-4a1 1 0 011.414 0z"}),e.jsx("path",{d:"M9.707 5.293a1 1 0 010 1.414L6.414 10l3.293 3.293a1 1 0 01-1.414 1.414l-4-4a1 1 0 010-1.414l4-4a1 1 0 011.414 0z"})]})})]}),A(i,g,P,b,s,k??f("picklist.target","Selected"),"right")]})});on.displayName="NicePickList";function Ct(t){return t?.startsWith("datetime")?"datetime":t==="week"?"week":t?.startsWith("month")?"month":"date"}function Qn(t){const i=new Date,a=`${i.getFullYear()}-${String(i.getMonth()+1).padStart(2,"0")}-${String(i.getDate()).padStart(2,"0")}`,o=Ct(t);return o==="datetime"?`${a}T00:00`:o==="month"?a.slice(0,7):a}function It(t,i){if(!t)return t;const a=new Date(t.length<=10?`${t}T00:00`:t);if(Number.isNaN(a.getTime()))return t;a.setDate(a.getDate()+i);const o=`${a.getFullYear()}-${String(a.getMonth()+1).padStart(2,"0")}-${String(a.getDate()).padStart(2,"0")}`;return t.length<=10?o.slice(0,t.length):o+t.slice(10)}function lt(...t){return t.filter(Boolean).sort().pop()}function jt(t,i,a){if(!t)return"";const o=new Date(t.length<=10?`${t}T00:00`:t);if(Number.isNaN(o.getTime()))return t;const r=Ct(a);return r==="month"?o.toLocaleDateString(i,{year:"numeric",month:"2-digit"}):r==="datetime"?o.toLocaleString(i,{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}):o.toLocaleDateString(i,{year:"numeric",month:"2-digit",day:"2-digit"})}function At(t){let i=0;for(const a of t)i+=/[\p{L}\p{N}]/u.test(a)?1:.5;return i}const Zn=({startDate:t,endDate:i,defaultStartDate:a,defaultEndDate:o,onStartChange:r,onEndChange:h,min:x,max:_,clearable:z,startPlaceholder:C,endPlaceholder:X,startLabel:q,endLabel:L,layout:k="horizontal",separator:J="–",gap:ne=12,fullWidth:ee=!1,dateFormatPreset:ie,locale:I,timeSelectorType:j,type:R,endCondition:f="greater-or-equal",startCondition:w="today-or-greater",singleField:U=!1,label:u,error:g,helperText:P,required:te,disabled:T,size:b="md",id:s,className:$,style:M,accessMode:l,showKeyboardHints:c,labelPlacement:d,errorPlacement:p,labelWidth:E,controlWidth:v,loading:B,readOnly:A})=>{const V=y.Dc(l,s),N=y.bc(s),{t:D}=y.Gt(),S=V==="disabled"||V==="readOnly"||!!T,[ae,ue]=y.Vu({value:t,defaultValue:a,fallbackValue:"",onChange:r,componentName:"NiceDateRangeBox"}),[ce,be]=y.Vu({value:i,defaultValue:o,fallbackValue:"",onChange:h,componentName:"NiceDateRangeBox"}),ve=n.useMemo(()=>[{key:"Tab",description:D("shortcuts.switchField","Switch between start/end")},y.Yc.cancel],[D]),_e=n.useRef(null),he=n.useRef(null),[ye,xe]=n.useState(!1),[re,Z]=n.useState(null),[de,O]=n.useState(""),Y=n.useContext(y.Er)?.portalTarget??(typeof document<"u"?document.body:null);n.useLayoutEffect(()=>{if(!ye)return;const pe=_e.current?.getBoundingClientRect();pe&&(Z({left:pe.left,top:pe.bottom+6}),O(Be.scopeThemeClass(_e.current)))},[ye]),n.useEffect(()=>{if(!ye)return;const pe=m=>{const G=m.target;_e.current?.contains(G)||he.current?.contains(G)||xe(!1)},Me=m=>{m.key==="Escape"&&xe(!1)},Ae=()=>{const m=_e.current?.getBoundingClientRect();m&&Z({left:m.left,top:m.bottom+6})};return document.addEventListener("mousedown",pe),document.addEventListener("keydown",Me),window.addEventListener("scroll",Ae,!0),window.addEventListener("resize",Ae),()=>{document.removeEventListener("mousedown",pe),document.removeEventListener("keydown",Me),window.removeEventListener("scroll",Ae,!0),window.removeEventListener("resize",Ae)}},[ye]);const ge=Qn(ie),le=w==="today-or-greater"?lt(x,ge):w==="greater-than-today"?lt(x,It(ge,1)):x,F=f==="greater-or-equal"?lt(x,ae):f==="greater"?lt(x,ae?It(ae,1):void 0):x,Q=n.useMemo(()=>{if(g)return g;if(ae&&ce){if(f==="greater-or-equal"&&ce<ae)return D("daterange.endBeforeStart","End date must be on or after the start date");if(f==="greater"&&ce<=ae)return D("daterange.endAfterStart","End date must be after the start date")}if(ae){if(w==="today-or-greater"&&ae<ge)return D("daterange.startInPast","Start date cannot be in the past");if(w==="greater-than-today"&&ae<=ge)return D("daterange.startAfterToday","Start date must be after today")}},[g,ae,ce,w,f,ge,D]);if(V==="hidden")return null;const K=pe=>{ue(pe),pe&&ce&&pe>ce&&be(pe)},se=k==="horizontal",me=Ct(ie),je=I||rt.getDefaultLocale(),we=typeof J=="string"&&J!==""?J:"–",Re=jt(ae,je,ie),Te=jt(ce,je,ie),Oe=Re||Te?`${Re||"…"} ${we} ${Te||"…"}`:"",qe=(()=>{const pe=jt("2026-12-30T22:58",je,ie),Me=`${pe} ${we} ${pe}`;return`${(Math.max(At(Me),At(Oe))+1.5).toFixed(1)}ch`})(),Ye=(pe,Me)=>me==="datetime"?Me&&Me.length>10?`${pe}${Me.slice(10)}`:`${pe}T00:00`:me==="month"?pe.slice(0,7):pe,Ke=({start:pe,end:Me})=>{ue(pe?Ye(pe,ae):""),be(Me?Ye(Me,ce):""),pe&&Me&&xe(!1)},Ve=()=>{ue(""),be("")},Ne=()=>{!S&&!A&&xe(pe=>!pe)},ze=pe=>pe&&pe.length>=10?pe.slice(0,10):pe||void 0;return e.jsxs("div",{className:`nice-field nice-field--${b} nice-daterange nice-daterange--${k} ${d==="left"?"nice-field--label-left":""} ${Q?"nice-field--error":""} ${B?"nice-field--loading":""} ${$||""}`,style:{...M,...E!=null&&{"--nice-field-label-width":typeof E=="number"?`${E}px`:E},...v!=null&&{"--nice-field-control-width":typeof v=="number"?`${v}px`:v}},"aria-busy":B||void 0,children:[u&&e.jsxs("label",{className:"nice-field__label",htmlFor:N,children:[u,te&&e.jsx("span",{className:"nice-field__required",children:"*"}),c&&e.jsx(y.ha,{shortcuts:ve,size:"sm"})]}),e.jsxs("div",{className:"nice-field__control",children:[U?e.jsxs("div",{ref:_e,className:`nice-input nice-input--date nice-input--${b} nice-daterange__single ${Q?"nice-input--error":""} ${S?"nice-input--disabled":""} ${A?"nice-input--readonly":""}`,style:{position:"relative",width:ee?"100%":"fit-content"},children:[e.jsx("input",{id:N,className:"nice-input__native",type:"text",readOnly:!0,value:Oe,placeholder:C||D("controls.startDate","Start date"),disabled:S||B,autoComplete:"off","aria-invalid":!!Q,"aria-label":u?void 0:D("controls.startDate","Start date"),onClick:Ne,style:{width:ee?"100%":qe,cursor:S||A?void 0:"pointer"}}),z&&e.jsx("button",{type:"button",className:"nice-input__clear",onClick:Ve,disabled:!ae&&!ce||S||A,"aria-label":D("controls.clear","Clear"),tabIndex:(ae||ce)&&!S&&!A?0:-1,children:e.jsx(y.oa,{name:"close",size:14})}),e.jsx("button",{type:"button",className:"nice-input__picker-trigger",onClick:Ne,"aria-label":D("controls.openPicker","Open picker"),"aria-expanded":ye,tabIndex:-1,disabled:S||A,children:e.jsx(y.oa,{name:"calendar",size:16})})]}):e.jsxs("div",{className:"nice-daterange__row",style:{display:"flex",flexDirection:se?"row":"column",alignItems:se?d==="left"?"center":"flex-end":"stretch",gap:ne,flexWrap:se?"nowrap":"wrap"},children:[e.jsx("div",{style:{flex:ee?"1 1 0":void 0,minWidth:0},children:e.jsx(rt.NiceDateTimePicker,{id:N,dateFormatPreset:ie,displayLocale:I,timeSelectorType:j,type:R,label:q,value:ae,onChange:K,min:le,max:ce||_,placeholder:C||D("controls.startDate","Start date"),disabled:S,readOnly:A,size:b,clearable:z,labelPlacement:d,labelWidth:E})}),se&&J!==""&&J!=null&&e.jsx("span",{className:"nice-daterange__separator",style:{paddingBottom:8,color:"var(--nice-text-secondary, #666)"},"aria-hidden":"true",children:J}),e.jsx("div",{style:{flex:ee?"1 1 0":void 0,minWidth:0},children:e.jsx(rt.NiceDateTimePicker,{dateFormatPreset:ie,displayLocale:I,timeSelectorType:j,type:R,label:L,value:ce,onChange:pe=>be(pe),min:F||ae||x,max:_,placeholder:X||D("controls.endDate","End date"),disabled:S,readOnly:A,size:b,clearable:z,labelPlacement:d,labelWidth:E})})]}),U&&ye&&re&&Y&&Ze.createPortal(e.jsxs("div",{ref:he,className:`nice-datetime-popup${de?` ${de}`:""}`,style:{position:"fixed",left:re.left,top:re.top,zIndex:1e3},role:"dialog","aria-label":D("controls.openPicker","Open picker"),children:[e.jsx("div",{className:"nice-datetime-popup__body",children:e.jsx("div",{className:"nice-datetime-popup__col nice-datetime-popup__col--date",children:e.jsx(rt.NiceCalendar,{selectionMode:"range",rangeStart:ze(ae),rangeEnd:ze(ce),onRangeChange:Ke,min:ze(le),max:ze(_),size:b})})}),z&&e.jsx("div",{className:"nice-datetime-popup__footer",children:e.jsx("button",{type:"button",className:"nice-datetime-popup__btn",onClick:Ve,disabled:!ae&&!ce,children:D("controls.clear","Clear")})})]}),Y),B&&e.jsx("span",{className:"nice-field__spinner",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})}),p==="right"&&Q&&e.jsx("div",{className:"nice-field__error",role:"alert",children:Q}),p==="right"&&!Q&&P&&e.jsx("div",{className:"nice-field__helper",children:P})]}),p!=="right"&&Q&&e.jsx("div",{className:"nice-field__error",children:Q}),p!=="right"&&!Q&&P&&e.jsx("div",{className:"nice-field__hint",children:P})]})};function ei(t,i=30){switch(t){case"monochromatic":return[0];case"complementary":return[0,180];case"split-complementary":return[0,180-i,180+i];case"analogous":return[0,-i,i];case"analogous-complementary":return[0,-i,i,180];case"triadic":return[0,120,240];case"tetradic":return[0,60,180,240];case"square":return[0,90,180,270];case"shade-chain":return[];case"custom":return[0,60,200];default:return[0]}}function Dt(t,i={}){const a=i.size??16,o="currentColor",r="currentColor";if(i.rectangle||t==="shade-chain"||t==="monochromatic"){const q=Math.max(3,Math.min(7,i.count??5)),L=a*.1,k=a-L*2,J=Math.max(1.2,a/14),ne=a/2,ee=Array.from({length:q},(ie,I)=>{const j=L+k*I/(q-1),R=.25+.75*I/(q-1);return e.jsx("circle",{cx:j,cy:ne,r:J,fill:r,opacity:R},I)});return e.jsxs("svg",{width:a,height:a,viewBox:`0 0 ${a} ${a}`,"aria-hidden":!0,children:[e.jsx("rect",{x:1,y:a/2-a/6,width:a-2,height:a/3,rx:a/6,fill:"none",stroke:o,strokeOpacity:.25}),ee]})}const x=i.angles??ei(t),_=a/2,z=a/2,C=a/2-2,X=Math.max(1.4,a/9);return e.jsxs("svg",{width:a,height:a,viewBox:`0 0 ${a} ${a}`,"aria-hidden":!0,children:[e.jsx("circle",{cx:_,cy:z,r:C,fill:"none",stroke:o,strokeOpacity:.25}),x.map((q,L)=>{const k=(q-90)*Math.PI/180,J=_+C*Math.cos(k),ne=z+C*Math.sin(k);return e.jsx("circle",{cx:J,cy:ne,r:X,fill:r},L)})]})}function zt(t,i,a){return Math.max(i,Math.min(a,t))}function sn({h:t,s:i,v:a}){t=(t%360+360)%360;const o=a*i,r=o*(1-Math.abs(t/60%2-1)),h=a-o;let x=0,_=0,z=0;return t<60?(x=o,_=r):t<120?(x=r,_=o):t<180?(_=o,z=r):t<240?(_=r,z=o):t<300?(x=r,z=o):(x=o,z=r),{r:Math.round((x+h)*255),g:Math.round((_+h)*255),b:Math.round((z+h)*255)}}function St({r:t,g:i,b:a}){t/=255,i/=255,a/=255;const o=Math.max(t,i,a),r=Math.min(t,i,a),h=o-r;let x=0;return h!==0&&(o===t?x=(i-a)/h%6:o===i?x=(a-t)/h+2:x=(t-i)/h+4,x=(x*60+360)%360),{h:x,s:o===0?0:h/o,v:o}}function rn({r:t,g:i,b:a}){t/=255,i/=255,a/=255;const o=Math.max(t,i,a),r=Math.min(t,i,a),h=(o+r)/2;if(o===r)return{h:0,s:0,l:h};const x=o-r,_=h>.5?x/(2-o-r):x/(o+r);let z=0;return o===t?z=((i-a)/x+(i<a?6:0))/6:o===i?z=((a-t)/x+2)/6:z=((t-i)/x+4)/6,{h:z*360,s:_,l:h}}function st(t){const i=t.replace("#",""),a=i.length===3?i[0]+i[0]+i[1]+i[1]+i[2]+i[2]:i,o=parseInt(a,16);return{r:o>>16&255,g:o>>8&255,b:o&255}}function cn({r:t,g:i,b:a}){return"#"+[t,i,a].map(o=>o.toString(16).padStart(2,"0")).join("")}function De(t){return cn(sn(t))}function He(t){return St(st(t))}function ln(t,i){const a=[];for(let o=0;o<i;o++){const r=i<=1?.5:o/(i-1),h=zt(t.s*(.3+r*.7),0,1),x=zt(t.v*(1.2-r*.7),0,1);a.push(De({h:t.h,s:h,v:x}))}return a}function gt(t,i){if(t==="custom"||t==="shade-chain")return[0];const a=i??30;switch(t){case"monochromatic":return[0];case"complementary":return[0,180];case"split-complementary":return[0,180-a,180+a];case"analogous":return[0,-a,a];case"analogous-complementary":return[0,-a,a,180];case"triadic":return[0,120,240];case"tetradic":return[0,60,180,240];case"square":return[0,90,180,270]}return[0]}function ot(t,i,a){return gt(i,a).map(o=>((t+o)%360+360)%360)}function Lt(t,i,a=.12){const o=Math.max(2,i),r=(o-1)/2,h=[];for(let x=0;x<o;x++){const _=(x-r)*a,z=Math.max(.05,Math.min(.98,t.v+_)),C=Math.max(.05,Math.min(1,t.s-Math.abs(_)*.25));h.push(De({h:t.h,s:C,v:z}))}return h}function Pt({r:t,g:i,b:a}){const[o,r,h]=[t,i,a].map(x=>{const _=x/255;return _<=.03928?_/12.92:Math.pow((_+.055)/1.055,2.4)});return .2126*o+.7152*r+.0722*h}function mt(t,i){const a=Pt(st(t)),o=Pt(st(i)),r=Math.max(a,o),h=Math.min(a,o);return(r+.05)/(h+.05)}function ut(t){return t>=7?"AAA":t>=4.5?"AA":t>=3?"AA-lg":"Fail"}const dn={"lightest-pastel":{sRange:[.1,.25],vRange:[.92,1]},"bright-pastel":{sRange:[.25,.45],vRange:[.9,1]},shiny:{sRange:[.7,.95],vRange:[.9,1]},pastel:{sRange:[.3,.55],vRange:[.75,.92]},full:{sRange:[.75,1],vRange:[.75,1]},dark:{sRange:[.6,.9],vRange:[.3,.55]},deep:{sRange:[.85,1],vRange:[.45,.65]},muted:{sRange:[.15,.35],vRange:[.5,.7]},earth:{sRange:[.3,.6],vRange:[.4,.65]}};function pt(t,i){const a=dn[i];return t.map(o=>{const r=(a.sRange[0]+a.sRange[1])/2,h=(a.vRange[0]+a.vRange[1])/2;return De({h:o,s:r,v:h})})}function ti(){return Math.floor(Math.random()*360)}function mn(t,i,a){const o=ti(),r=ot(o,t,a),h=[];for(let x=0;x<i;x++){const _=r[x%r.length],z=.55+Math.random()*.4,C=.5+Math.random()*.45;h.push(De({h:_+(Math.random()-.5)*8,s:z,v:C}))}return h}const ni=({hues:t,colors:i,baseHue:a,onBaseHueChange:o,mode:r,distance:h,disabled:x})=>{const L=n.useRef(null),k=n.useCallback((j,R)=>{const f=L.current;if(!f)return;const w=f.getBoundingClientRect(),U=(j-w.left)/w.width*240-120,u=(R-w.top)/w.height*240-120,g=(Math.atan2(u,U)*180/Math.PI+360)%360;o(Math.round(g))},[120,120,240,o]),J=n.useCallback(j=>{if(x)return;j.preventDefault(),k(j.clientX,j.clientY);const R=w=>k(w.clientX,w.clientY),f=()=>{document.removeEventListener("pointermove",R),document.removeEventListener("pointerup",f)};document.addEventListener("pointermove",R),document.addEventListener("pointerup",f)},[x,k]),ne=[];for(let j=0;j<360;j+=2){const R=(j-1)*Math.PI/180,f=(j+1)*Math.PI/180,w=De({h:j,s:1,v:1});ne.push(e.jsx("path",{d:`M${120+55*Math.cos(R)},${120+55*Math.sin(R)} L${120+110*Math.cos(R)},${120+110*Math.sin(R)} A110,110 0 0,1 ${120+110*Math.cos(f)},${120+110*Math.sin(f)} L${120+55*Math.cos(f)},${120+55*Math.sin(f)} A55,55 0 0,0 ${120+55*Math.cos(R)},${120+55*Math.sin(R)} Z`,fill:w},j))}const ee=`wheel-center-${r}`,ie=t.map((j,R)=>{const w=j*Math.PI/180;return e.jsx("circle",{cx:120+82.5*Math.cos(w),cy:120+82.5*Math.sin(w),r:R===0?8:6,fill:i?.[R]??De({h:j,s:.85,v:.9}),stroke:R===0?"var(--nice-bg-primary, #fff)":"var(--nice-border-color, #ccc)",strokeWidth:R===0?3:2},R)});let I=null;if(r==="analogous"||r==="split-complementary"||r==="analogous-complementary"){const f=gt(r,h).slice(1).map((w,U)=>{const u=(a+w)*Math.PI/180;return e.jsx("line",{x1:120,y1:120,x2:120+82.5*Math.cos(u),y2:120+82.5*Math.sin(u),stroke:"var(--nice-overlay-light-30, rgba(255, 255, 255, 0.3))",strokeWidth:1,strokeDasharray:"3,3"},`dline-${U}`)});I=e.jsx(e.Fragment,{children:f})}return e.jsxs("svg",{ref:L,className:"nice-palette__wheel",viewBox:"0 0 240 240",width:240,height:240,onPointerDown:J,style:{cursor:x?"default":"crosshair",touchAction:"none"},children:[e.jsx("defs",{children:e.jsxs("radialGradient",{id:ee,children:[e.jsx("stop",{offset:"0%",stopColor:"var(--nice-bg, #fff)"}),e.jsx("stop",{offset:"100%",stopColor:"transparent"})]})}),ne,e.jsx("circle",{cx:120,cy:120,r:53,fill:De({h:a,s:.6,v:.85})}),e.jsx("circle",{cx:120,cy:120,r:53,fill:`url(#${ee})`,opacity:.4}),I,ie]})},ii=({colors:t})=>{if(t.length<2)return null;const i=[];for(let a=0;a<t.length;a++){const o=mt(t[a],"var(--nice-bg-primary, #ffffff)"),r=mt(t[a],"var(--nice-text-primary, #000000)");i.push({a:t[a],b:"var(--nice-bg-primary, #ffffff)",ratio:o,level:ut(o)}),i.push({a:t[a],b:"var(--nice-text-primary, #000000)",ratio:r,level:ut(r)});for(let h=a+1;h<t.length;h++){const x=mt(t[a],t[h]);i.push({a:t[a],b:t[h],ratio:x,level:ut(x)})}}return e.jsxs("div",{className:"nice-palette__contrast",children:[e.jsx("div",{className:"nice-palette__section-title",children:"Contrast Analysis (WCAG 2.1)"}),e.jsx("div",{className:"nice-palette__contrast-grid",children:i.map((a,o)=>e.jsxs("div",{className:"nice-palette__contrast-pair",children:[e.jsxs("div",{className:"nice-palette__contrast-swatches",children:[e.jsx("span",{className:"nice-palette__contrast-dot",style:{background:a.a}}),e.jsx("span",{className:"nice-palette__contrast-vs",children:"vs"}),e.jsx("span",{className:"nice-palette__contrast-dot",style:{background:a.b}})]}),e.jsxs("span",{className:"nice-palette__contrast-ratio",children:[a.ratio.toFixed(1),":1"]}),e.jsx("span",{className:`nice-palette__contrast-level nice-palette__contrast-level--${a.level.toLowerCase().replace("-","")}`,children:a.level})]},o))})]})},ai=({hex:t})=>{const i=st(t),a=rn(i),o=St(i);return e.jsxs("div",{className:"nice-palette__color-info",children:[e.jsxs("div",{children:[e.jsx("strong",{children:"HEX"})," ",t.toUpperCase()]}),e.jsxs("div",{children:[e.jsx("strong",{children:"RGB"})," ",i.r,", ",i.g,", ",i.b]}),e.jsxs("div",{children:[e.jsx("strong",{children:"HSL"})," ",Math.round(a.h),"°, ",Math.round(a.s*100),"%,"," ",Math.round(a.l*100),"%"]}),e.jsxs("div",{children:[e.jsx("strong",{children:"HSV"})," ",Math.round(o.h),"°, ",Math.round(o.s*100),"%,"," ",Math.round(o.v*100),"%"]})]})},oi={monochromatic:"Monochromatic",complementary:"Complementary","split-complementary":"Split-Complementary",analogous:"Analogous","analogous-complementary":"Analogous + Complementary",triadic:"Triadic",tetradic:"Tetradic (Rectangle)",square:"Square","shade-chain":"Shade chain",custom:"Custom"},si={"lightest-pastel":"Lightest Pastel","bright-pastel":"Bright Pastel",shiny:"Shiny",pastel:"Pastel",full:"Full Colors",dark:"Dark",deep:"Deep Colors",muted:"Muted",earth:"Earth Tones"},ri=["monochromatic","shade-chain","complementary","split-complementary","analogous","analogous-complementary","triadic","tetradic","square","custom"],un=["lightest-pastel","bright-pastel","shiny","pastel","full","dark","deep","muted","earth"],pn="nice-palette-custom-schemes";function ci(){if(typeof window>"u")return[];try{const t=window.localStorage.getItem(pn);if(!t)return[];const i=JSON.parse(t);if(Array.isArray(i))return i}catch{}return[]}function li(t){if(!(typeof window>"u"))try{window.localStorage.setItem(pn,JSON.stringify(t))}catch{}}const hn=n.forwardRef(({id:t,className:i,style:a,accessMode:o,value:r,onChange:h,minColors:x=1,maxColors:_=8,harmonyMode:z,onHarmonyModeChange:C,distance:X,onDistanceChange:q,preset:L,onPresetChange:k,showWheel:J=!0,showContrast:ne=!0,showInfo:ee=!0,showPresets:ie=!0,presets:I=[],showVariations:j=!0,showRandom:R=!0,variationCount:f=5,label:w,labelPlacement:U="top",disabled:u,readOnly:g,loading:P,error:te,colorCount:T,shadeStep:b,onShadeStepChange:s,customSchemes:$,onCustomSchemesChange:M,persistCustomSchemes:l=!0},c)=>{const d=y.Dc(o,t),p=d==="hidden";d==="disabled"&&(u=!0);const E=g||d==="readOnly",v=y.bc(t),{t:B}=y.Gt(),[A,V]=n.useState("analogous-complementary"),[N,D]=n.useState(30),[S,ae]=n.useState(""),[ue,ce]=n.useState(0),[be,ve]=n.useState(.12),[_e,he]=n.useState(null),[ye,xe]=n.useState(()=>$??(l?ci():[])),[re,Z]=n.useState(null),[de,O]=n.useState(!1),[H,Y]=n.useState(null),[ge,le]=n.useState(""),Q=n.useContext(y.Er)?.portalTarget??(typeof document<"u"?document.body:null),K=n.useRef(null),se=n.useRef(null),me=z??A,je=X??N,we=L??S,Re=b??be,Te=$??ye;n.useEffect(()=>{!$&&l&&li(ye)},[ye,$,l]);const Oe=n.useCallback(W=>{xe(W),M?.(W)},[M]),qe=n.useCallback(W=>{V(W),C?.(W)},[C]),Ye=n.useCallback(W=>{D(W),q?.(W)},[q]),Ke=n.useCallback(W=>{ae(W),W&&k?.(W)},[k]),Ve=n.useMemo(()=>["var(--nice-color-primary, #3b82f6)","var(--nice-color-error, #ef4444)","var(--nice-color-success, #22c55e)"],[]),Ne=r&&r.length>0?r:Ve,ze=Ne[0],pe=n.useMemo(()=>He(ze),[ze]),Me=n.useMemo(()=>ot(pe.h,me,je),[pe.h,me,je]),Ae=n.useCallback((W,fe,ke,Ee,Pe)=>{const tt=T??Pe??_e??Ne.length,Je=tt!==void 0?Math.max(x,Math.min(_,tt)):void 0;if(fe==="shade-chain"){const Le=Je??Math.max(x,5),Ge=Lt({h:W,s:pe.s||.7,v:pe.v||.6},Le,Re);h?.(Ge);return}let Qe;const nt=fe==="custom"&&re?Te.find(Le=>Le.id===re):null;nt&&nt.angles.length>0?Qe=nt.angles.map(Le=>((W+Le)%360+360)%360):Qe=ot(W,fe,ke);let Ie;if(Ee&&dn[Ee]?Ie=pt(Qe,Ee):Ie=Qe.map(Le=>De({h:Le,s:pe.s||.7,v:pe.v||.85})),nt?.lightnessOffsets?.length&&(Ie=Ie.map((Le,Ge)=>{const Rt=nt.lightnessOffsets?.[Ge];if(Rt==null)return Le;const xt=He(Le);return De({h:xt.h,s:xt.s,v:Math.max(.05,Math.min(.98,xt.v+Rt))})})),Je!==void 0){for(;Ie.length<Je;){const Le=Ie[Ie.length-1]||"#888888",Ge=He(Le);Ie.push(De({h:(Ge.h+18)%360,s:Ge.s,v:Ge.v}))}Ie=Ie.slice(0,Je)}else{for(;Ie.length<x;)Ie.push(Ie[Ie.length-1]||"var(--nice-text-secondary, #888888)");Ie.length>_&&(Ie=Ie.slice(0,_))}h?.(Ie)},[pe.s,pe.v,x,_,h,T,_e,Ne.length,Re,re,Te]),m=n.useCallback(W=>{if(!u){if(me==="custom"){const fe=De({h:W,s:pe.s||.7,v:pe.v||.85}),ke=[...Ne];ke[ue]=fe,h?.(ke);return}Ae(W,me,je,we)}},[u,me,je,we,Ae,pe.s,pe.v,Ne,ue,h]),G=n.useCallback(W=>{if(u||(qe(W),W==="custom"))return;const fe=gt(W).length,ke=fe<=1;if(T==null&&!ke){const Ee=Math.max(x,Math.min(_,fe));he(Ee),Ae(pe.h,W,je,we,Ee)}else Ae(pe.h,W,je,we)},[u,pe.h,je,we,qe,Ae,T,x,_]),oe=n.useCallback(W=>{u||(Ye(W),Ae(pe.h,me,W,we))},[u,pe.h,me,we,Ye,Ae]),Ce=n.useCallback(W=>{if(u)return;Ke(W);const fe=ot(pe.h,me,je),ke=pt(fe,W);h?.(ke.slice(0,_))},[u,pe.h,me,je,_,Ke,h]),$e=n.useCallback((W,fe)=>{if(u)return;const ke=[...Ne];ke[W]=fe,h?.(ke)},[u,Ne,h]),Ue=n.useCallback(()=>{if(u||Ne.length>=_)return;const W=He(Ne[Ne.length-1]),fe=De({h:(W.h+30)%360,s:W.s,v:W.v});h?.([...Ne,fe])},[u,Ne,_,h]),We=n.useCallback(W=>{if(u||Ne.length<=x)return;const fe=Ne.filter((ke,Ee)=>Ee!==W);h?.(fe),ue>=fe.length&&ce(Math.max(0,fe.length-1))},[u,Ne,x,h,ue]),zn=n.useCallback(()=>{if(u)return;const W=Math.max(x,Math.min(_,gt(me).length)),fe=mn(me,W,je);h?.(fe)},[u,x,_,me,je,h]),Et=n.useMemo(()=>{if(!j)return[];const W=Ne[ue]||Ne[0];return ln(He(W),f)},[j,Ne,ue,f]),ft=Ne[ue]||Ne[0],yt=n.useMemo(()=>{const W=He(ft);return De({h:(W.h+180)%360,s:W.s,v:W.v})},[ft]);if(n.useLayoutEffect(()=>{if(!de||!K.current)return;le(Be.scopeThemeClass(K.current));const W=()=>{const fe=K.current?.getBoundingClientRect();if(!fe)return;const ke=600;let Ee=fe.left;Ee+ke>window.innerWidth-8&&(Ee=Math.max(8,window.innerWidth-ke-8));let Pe=fe.bottom+6;Pe>window.innerHeight*.5&&(Pe=Math.max(8,window.innerHeight-Math.min(window.innerHeight-16,540)-8)),Y({left:Ee,top:Pe})};return W(),window.addEventListener("scroll",W,!0),window.addEventListener("resize",W),()=>{window.removeEventListener("scroll",W,!0),window.removeEventListener("resize",W)}},[de]),n.useEffect(()=>{if(!de)return;const W=ke=>{const Ee=ke.target;K.current?.contains(Ee)||se.current?.contains(Ee)||(Ee instanceof Element?Ee:Ee?.parentElement??null)?.closest('.nice-select__dropdown, [role="listbox"], [role="option"]')||O(!1)},fe=ke=>{ke.key==="Escape"&&O(!1)};return document.addEventListener("mousedown",W),document.addEventListener("keydown",fe),()=>{document.removeEventListener("mousedown",W),document.removeEventListener("keydown",fe)}},[de]),p)return null;const Mt=I.length>0?I:un,Ln=e.jsxs("div",{className:"nice-palette__tab",children:[e.jsxs("div",{className:"nice-palette__modes",style:{display:"flex",gap:8,alignItems:"center",flexWrap:"wrap"},children:[e.jsx(Be.NiceSelect,{label:B("colorPalette.harmony","Harmony"),labelPlacement:"left",size:"sm",disabled:u,value:me==="custom"&&re?`custom:${re}`:me,onChange:W=>{const fe=Array.isArray(W)?W[0]:W;if(typeof fe=="string")if(fe.startsWith("custom:")){const ke=fe.slice(7);Z(ke),G("custom")}else Z(null),G(fe)},options:[...ri.map(W=>({value:W,label:oi[W]})),...Te.map(W=>({value:`custom:${W.id}`,label:W.name}))],renderOption:(W,fe)=>{const ke=String(W.value),Ee=ke.startsWith("custom:"),Pe=Ee?Te.find(Qe=>Qe.id===ke.slice(7)):null,tt=Pe?Pe.angles:void 0,Je=Ee?"custom":ke;return e.jsxs("span",{style:{display:"inline-flex",gap:8,alignItems:"center"},children:[e.jsx("span",{style:{width:16,height:16,display:"inline-flex",color:"currentColor"},children:Dt(Je,{angles:tt,size:16,count:T})}),e.jsx("span",{style:{fontWeight:fe?600:400},children:W.label})]})}}),me==="shade-chain"&&e.jsx(Fe.NiceNumberInput,{label:B("colorPalette.step","Step"),labelPlacement:"left",size:"sm",min:.02,max:.5,step:.02,precision:2,value:Re,onChange:W=>{const fe=typeof W=="number"?W:Number(W);Number.isNaN(fe)||(ve(fe),s?.(fe),Ae(pe.h,me,je,we))},showStepper:!0,disabled:u}),e.jsx(Fe.NiceNumberInput,{label:B("colorPalette.colors","Colors"),labelPlacement:"left",size:"sm",min:Math.max(2,x),max:Math.min(12,_),step:1,precision:0,value:T??_e??Ne.length,onChange:W=>{const fe=typeof W=="number"?W:Number(W);if(!Number.isFinite(fe))return;const ke=Math.max(Math.max(2,x),Math.min(Math.min(12,_),Math.round(fe)));he(ke),me==="shade-chain"?h?.(Lt({h:pe.h,s:pe.s||.7,v:pe.v||.6},ke,Re)):setTimeout(()=>Ae(pe.h,me,je,we),0)},showStepper:!0,disabled:u})]}),e.jsx("div",{className:"nice-palette__main",children:e.jsxs("div",{className:"nice-palette__strips",children:[e.jsxs("div",{className:"nice-palette__swatches",children:[Ne.map((W,fe)=>e.jsxs("div",{className:`nice-palette__swatch-wrapper ${ue===fe?"nice-palette__swatch-wrapper--selected":""}`,onClick:()=>ce(fe),children:[e.jsx("span",{className:"nice-palette__swatch",style:{background:W}}),e.jsx("input",{type:"text",className:"nice-palette__hex-input",value:W.toUpperCase(),maxLength:7,disabled:u,onClick:ke=>ke.stopPropagation(),onChange:ke=>$e(fe,ke.target.value)}),Ne.length>x&&e.jsx("button",{type:"button",className:"nice-palette__swatch-remove",onClick:ke=>{ke.stopPropagation(),We(fe)},disabled:u,"aria-label":"Remove color",children:e.jsx(y.oa,{name:"close",size:14})})]},fe)),Ne.length<_&&e.jsxs("button",{type:"button",className:"nice-palette__add-btn",onClick:Ue,disabled:u,title:"Add color",children:[e.jsx(y.oa,{name:"plus",size:14}),e.jsx("span",{children:"Add"})]})]}),e.jsxs("div",{className:"nice-palette__complementary",children:[e.jsx("span",{className:"nice-palette__section-tag",children:"Complementary"}),e.jsx("div",{className:"nice-palette__swatch nice-palette__swatch--sm",style:{background:yt},title:yt.toUpperCase()}),e.jsx("span",{className:"nice-palette__hex-label",children:yt.toUpperCase()})]}),R&&e.jsxs("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm nice-palette__random-btn",onClick:zn,disabled:u,title:"Random palette","aria-label":"Random palette",children:[e.jsx(y.oa,{name:"shuffle",size:14})," Random Palette"]})]})})]}),Pn=e.jsx("div",{className:"nice-palette__tab",children:Et.length>0?e.jsxs("div",{className:"nice-palette__variations",children:[e.jsx("span",{className:"nice-palette__section-tag",children:"Tints & Shades"}),e.jsx("div",{className:"nice-palette__variation-strip",children:Et.map((W,fe)=>e.jsx("div",{className:"nice-palette__variation-chip",style:{background:W},title:W.toUpperCase(),onClick:()=>{u||$e(ue,W)},role:"button",tabIndex:0},fe))})]}):e.jsx("div",{className:"nice-palette__empty",children:"No variations available."})}),Bn=e.jsx("div",{className:"nice-palette__tab",children:e.jsx("div",{className:"nice-palette__preset-grid",children:Mt.map(W=>{const fe=pt(Me,W);return e.jsxs("button",{type:"button",className:`nice-palette__preset-card ${we===W?"nice-palette__preset-card--active":""}`,onClick:()=>Ce(W),disabled:u,children:[e.jsx("div",{className:"nice-palette__preset-strip",children:fe.map((ke,Ee)=>e.jsx("span",{className:"nice-palette__preset-dot",style:{background:ke}},Ee))}),e.jsx("span",{className:"nice-palette__preset-label",children:si[W]})]},W)})})}),Hn=e.jsxs("div",{className:"nice-palette__tab",children:[ee&&e.jsxs("div",{className:"nice-palette__info-panel",children:[e.jsx("div",{className:"nice-palette__section-title",children:"Selected Color Info"}),e.jsx(ai,{hex:ft})]}),ne&&e.jsxs("div",{className:"nice-palette__info-panel",children:[e.jsx("div",{className:"nice-palette__section-title",children:"Contrast Analysis (WCAG 2.1)"}),e.jsx(ii,{colors:Ne})]})]}),On=e.jsx("div",{className:"nice-palette__tab nice-palette__custom-schemes",children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[Te.length===0&&e.jsx("div",{style:{fontSize:12,color:"var(--nice-text-muted)"},children:B("colorPalette.schemes.empty","Save the current palette as a reusable scheme.")}),Te.map(W=>e.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center",fontSize:12},children:[e.jsx("span",{style:{width:16,height:16,display:"inline-flex"},children:Dt("custom",{angles:W.angles,size:16})}),e.jsx("span",{style:{flex:1},children:W.name}),e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--xs",onClick:()=>{Z(W.id),G("custom")},disabled:u,children:"Use"}),e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--xs",onClick:()=>Oe(Te.filter(fe=>fe.id!==W.id)),disabled:u,"aria-label":`Delete ${W.name}`,children:e.jsx(y.oa,{name:"close",size:14})})]},W.id)),e.jsxs("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:[e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm",disabled:u,onClick:()=>{const W=typeof window<"u"?window.prompt("Scheme name?",`Scheme ${Te.length+1}`):null;if(!W)return;const fe=He(Ne[0]).h,ke=Ne.map(Pe=>(He(Pe).h-fe+540)%360-180),Ee={id:`cs-${Date.now()}`,name:W,angles:ke};Oe([...Te,Ee])},children:"+ Save current as scheme"}),e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm",disabled:u||Te.length===0,onClick:()=>{typeof navigator>"u"||navigator.clipboard?.writeText(JSON.stringify(Te,null,2))},children:B("colorPalette.exportJson","Export JSON")}),e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm",disabled:u,onClick:()=>{if(typeof window>"u")return;const W=window.prompt("Paste schemes JSON");if(W)try{const fe=JSON.parse(W);Array.isArray(fe)&&Oe(fe)}catch{}},children:B("colorPalette.importJson","Import JSON")})]})]})}),et=[{id:"colors",label:"Colors",content:Ln}];ie&&Mt.length>0&&et.push({id:"presets",label:"Presets",content:Bn}),j&&et.push({id:"variations",label:"Variations",content:Pn}),(ee||ne)&&et.push({id:"info",label:"Info",content:Hn}),et.push({id:"schemes",label:"Schemes",content:On});const Fn=e.jsxs("div",{className:"nice-palette__popup-header",children:[J&&e.jsxs("div",{className:"nice-palette__wheel-container",children:[e.jsx(ni,{hues:Me,colors:Ne,baseHue:pe.h,onBaseHueChange:m,mode:me,distance:je,disabled:u}),(me==="analogous"||me==="split-complementary"||me==="analogous-complementary")&&e.jsxs("div",{className:"nice-palette__distance",children:[e.jsxs("label",{children:["Distance: ",je,"°"]}),e.jsx("input",{type:"range",min:10,max:90,value:je,onChange:W=>oe(Number(W.target.value)),disabled:u,className:"nice-palette__distance-slider"})]})]}),e.jsx("button",{type:"button",className:"nice-palette__confirm",onClick:()=>O(!1),"aria-label":B("controls.confirm","Confirm"),title:B("controls.confirm","Confirm"),children:e.jsx(y.oa,{name:"check",size:18})})]}),Yn=e.jsxs("div",{className:"nice-palette nice-palette--studio",children:[Fn,e.jsx(Fe.NiceTabs,{tabs:et,variant:"enclosed",size:"sm"})]});return e.jsxs("div",{ref:c,id:v,className:`nice-field nice-palette-field ${u?"nice-palette--disabled":""} ${U==="left"?"nice-field--label-left":""} ${P?"nice-field--loading":""} ${te?"nice-field--error":""} ${i||""}`,style:a,children:[w&&e.jsx("label",{htmlFor:v,className:"nice-field__label",children:w}),e.jsxs("div",{className:"nice-field__control",children:[e.jsx("div",{ref:K,className:"nice-palette__field-swatches",role:"button",tabIndex:u||E?-1:0,"aria-haspopup":"dialog","aria-expanded":de,"aria-readonly":E||void 0,"aria-label":B("colorPalette.openStudio","Open palette studio"),onClick:()=>{!u&&!E&&O(W=>!W)},onKeyDown:W=>{!u&&!E&&(W.key==="Enter"||W.key===" ")&&(W.preventDefault(),O(fe=>!fe))},children:Ne.map((W,fe)=>e.jsx("span",{className:"nice-palette__field-swatch",style:{background:W},title:W.toUpperCase(),onClick:ke=>{ke.stopPropagation(),!u&&!E&&(ce(fe),O(!0))}},fe))}),P&&e.jsx("span",{className:"nice-field__spinner",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})}),de&&H&&Q&&Ze.createPortal(e.jsx("div",{ref:se,className:`nice-palette__popup${ge?` ${ge}`:""}`,"data-theme":ge==="nice-dark"?"dark":ge==="nice-light"?"light":void 0,role:"dialog","aria-label":B("colorPalette.studio","Palette studio"),style:{position:"fixed",left:H.left,top:H.top,zIndex:1e3},children:Yn}),Q)]}),typeof te=="string"&&te&&e.jsx("div",{className:"nice-field__error",role:"alert",children:te})]})});hn.displayName="NiceColorPalette";function wt(){return{type:"linear",angle:90,stops:[{color:"var(--nice-primary, #3b82f6)",position:0},{color:"var(--nice-accent, #8b5cf6)",position:100}]}}function Nt(t){const i=t.stops.slice().sort((o,r)=>o.position-r.position).map(o=>`${o.color} ${o.position}%`).join(", "),a=t.repeating?"repeating-":"";switch(t.type){case"linear":return`${a}linear-gradient(${t.angle}deg, ${i})`;case"radial":{const o=t.shape||"ellipse",r=t.size||"farthest-corner",h=t.positionX??50,x=t.positionY??50;return`${a}radial-gradient(${o} ${r} at ${h}% ${x}%, ${i})`}case"conic":{const o=t.angle??0,r=t.positionX??50,h=t.positionY??50;return`${a}conic-gradient(from ${o}deg at ${r}% ${h}%, ${i})`}}}function gn(t){const i=t.trim(),a=i.startsWith("repeating-");if(i.includes("linear-gradient")){const o=i.match(/linear-gradient\((.+)\)/)?.[1];if(!o)return null;const r=o.split(",").map(C=>C.trim());let h=90,x=0;const _=r[0].match(/^(\d+)deg$/);_&&(h=parseInt(_[1]),x=1);const z=bt(r.slice(x));return{type:"linear",angle:h,repeating:a,stops:z}}if(i.includes("radial-gradient")){const o=i.match(/radial-gradient\((.+)\)/)?.[1];if(!o)return null;const r=o.split(",").map(x=>x.trim()),h=bt(r.filter(x=>x.includes("#")||x.includes("rgb")));return{type:"radial",angle:0,repeating:a,stops:h.length>=2?h:wt().stops}}if(i.includes("conic-gradient")){const o=i.match(/conic-gradient\((.+)\)/)?.[1];if(!o)return null;const r=o.split(",").map(x=>x.trim()),h=bt(r.filter(x=>x.includes("#")||x.includes("rgb")));return{type:"conic",angle:0,repeating:a,stops:h.length>=2?h:wt().stops}}return null}function bt(t){return t.map((i,a,o)=>{const r=i.match(/^(#[0-9a-fA-F]{3,8}|rgba?\([^)]+\))\s*(\d+%?)?$/);if(r){const h=r[2]?parseFloat(r[2]):a/Math.max(1,o.length-1)*100;return{color:r[1],position:h}}return{color:i,position:a/Math.max(1,o.length-1)*100}})}function di(){return"#"+Math.floor(Math.random()*16777215).toString(16).padStart(6,"0")}function mi(t=2){const i=["linear","radial","conic"],a=i[Math.floor(Math.random()*i.length)],o=[];for(let r=0;r<t;r++)o.push({color:di(),position:Math.round(r/(t-1)*100)});return{type:a,angle:Math.floor(Math.random()*360),stops:o,shape:a==="radial"?Math.random()>.5?"circle":"ellipse":void 0,positionX:a!=="linear"?Math.round(Math.random()*100):void 0,positionY:a!=="linear"?Math.round(Math.random()*100):void 0}}const fn=[{name:"Sunset",value:{type:"linear",angle:135,stops:[{color:"var(--nice-danger, #ff6b6b)",position:0},{color:"#feca57",position:100}]}},{name:"Ocean",value:{type:"linear",angle:180,stops:[{color:"#667eea",position:0},{color:"#764ba2",position:100}]}},{name:"Forest",value:{type:"linear",angle:120,stops:[{color:"#11998e",position:0},{color:"#38ef7d",position:100}]}},{name:"Fire",value:{type:"linear",angle:90,stops:[{color:"#f12711",position:0},{color:"#f5af19",position:100}]}},{name:"Aurora",value:{type:"linear",angle:135,stops:[{color:"#a18cd1",position:0},{color:"#fbc2eb",position:50},{color:"#a6c1ee",position:100}]}},{name:"Midnight",value:{type:"linear",angle:180,stops:[{color:"#0f0c29",position:0},{color:"#302b63",position:50},{color:"#24243e",position:100}]}},{name:"Candy",value:{type:"linear",angle:45,stops:[{color:"#fc5c7d",position:0},{color:"#6a82fb",position:100}]}},{name:"Radial Glow",value:{type:"radial",angle:0,shape:"circle",stops:[{color:"var(--nice-warning-bg, #ffecd2)",position:0},{color:"#fcb69f",position:100}],positionX:50,positionY:50}},{name:"Rainbow",value:{type:"conic",angle:0,stops:[{color:"var(--nice-danger, #ff0000)",position:0},{color:"#ff8800",position:17},{color:"var(--nice-warning, #ffff00)",position:33},{color:"var(--nice-success, #00ff00)",position:50},{color:"#0088ff",position:67},{color:"#8800ff",position:83},{color:"var(--nice-danger, #ff0000)",position:100}],positionX:50,positionY:50}}],yn=n.forwardRef(({id:t,className:i,style:a,accessMode:o,value:r,onChange:h,showCssOutput:x=!0,showPresets:_=!0,showEditor:z=!0,showRandom:C=!0,maxStops:X=10,label:q,labelPlacement:L="top",disabled:k,readOnly:J,loading:ne,error:ee,errorPlacement:ie="bottom",width:I},j)=>{const R=y.Dc(o,t),f=R==="hidden";R==="disabled"&&(k=!0);const w=J||R==="readOnly",U=y.bc(t),{t:u}=y.Gt(),g=r??wt(),P=n.useMemo(()=>Nt(g),[g]),[te,T]=n.useState(0),[b,s]=n.useState(""),$=n.useRef(null),[M,l]=n.useState(!1),[c,d]=n.useState(null),[p,E]=n.useState(""),B=n.useContext(y.Er)?.portalTarget??(typeof document<"u"?document.body:null),A=n.useRef(null),V=n.useRef(null),N=typeof I=="number"?I:340;n.useLayoutEffect(()=>{if(!M||!A.current)return;E(Be.scopeThemeClass(A.current));const F=()=>{const Q=A.current?.getBoundingClientRect();if(!Q)return;let K=Q.left;K+N>window.innerWidth-8&&(K=Math.max(8,window.innerWidth-N-8));let se=Q.bottom+6;se>window.innerHeight*.5&&(se=Math.max(8,window.innerHeight-Math.min(window.innerHeight-16,520)-8)),d({left:K,top:se})};return F(),window.addEventListener("scroll",F,!0),window.addEventListener("resize",F),()=>{window.removeEventListener("scroll",F,!0),window.removeEventListener("resize",F)}},[M,N]),n.useEffect(()=>{if(!M)return;const F=K=>{const se=K.target;A.current?.contains(se)||V.current?.contains(se)||(se instanceof Element?se:se?.parentElement??null)?.closest('.nice-select__dropdown, [role="listbox"], [role="option"]')||l(!1)},Q=K=>{K.key==="Escape"&&l(!1)};return document.addEventListener("mousedown",F),document.addEventListener("keydown",Q),()=>{document.removeEventListener("mousedown",F),document.removeEventListener("keydown",Q)}},[M]);const D=n.useCallback(F=>{h?.(F)},[h]),S=n.useCallback(F=>{k||D({...g,type:F})},[k,g,D]),ae=n.useCallback(F=>{k||D({...g,angle:F})},[k,g,D]),ue=n.useCallback(F=>{k||D({...g,repeating:F})},[k,g,D]),ce=n.useCallback(F=>{k||D({...g,shape:F})},[k,g,D]),be=n.useCallback((F,Q)=>{if(k)return;const K=g.stops.map((se,me)=>me===F?{...se,...Q}:se);D({...g,stops:K})},[k,g,D]),ve=n.useRef(!1),_e=n.useCallback((F,Q)=>{if(k||!$.current)return;F.stopPropagation(),F.preventDefault(),T(Q),ve.current=!1;const K=me=>{if(!$.current)return;ve.current=!0;const je=$.current.getBoundingClientRect(),we=Math.round(Math.max(0,Math.min(100,(me.clientX-je.left)/je.width*100)));be(Q,{position:we})},se=()=>{document.removeEventListener("pointermove",K),document.removeEventListener("pointerup",se),document.removeEventListener("pointercancel",se)};document.addEventListener("pointermove",K),document.addEventListener("pointerup",se),document.addEventListener("pointercancel",se)},[k,be]),he=n.useCallback(()=>{if(k||g.stops.length>=X)return;const F=g.stops.slice().sort((je,we)=>je.position-we.position);let Q=0,K=F[0];for(let je=0;je<F.length-1;je++){const we=F[je+1].position-F[je].position;we>Q&&(Q=we,K=F[je])}const se=Math.round(K.position+Q/2),me="#"+Math.floor(Math.random()*16777215).toString(16).padStart(6,"0");D({...g,stops:[...g.stops,{color:me,position:se}]})},[k,g,X,D]),ye=n.useCallback(F=>{if(k||g.stops.length<=2)return;const Q=g.stops.filter((K,se)=>se!==F);D({...g,stops:Q}),te>=Q.length&&T(Q.length-1)},[k,g,te,D]),xe=n.useCallback(()=>{if(k)return;const F=2+Math.floor(Math.random()*3);D(mi(F))},[k,D]),re=n.useCallback(()=>{if(k||!b.trim())return;const F=gn(b);F&&D(F)},[k,b,D]),Z=n.useCallback(F=>{if(k||!$.current||g.stops.length>=X)return;const Q=F.target;if(ve.current||Q.closest(".nice-gradient__stop-marker")){ve.current=!1;return}const K=$.current.getBoundingClientRect(),se=Math.round((F.clientX-K.left)/K.width*100),me="#"+Math.floor(Math.random()*16777215).toString(16).padStart(6,"0"),je=[...g.stops,{color:me,position:se}];D({...g,stops:je}),T(je.length-1)},[k,g,X,D]),de=n.useMemo(()=>g.stops.slice().sort((F,Q)=>F.position-Q.position),[g.stops]),O=n.useMemo(()=>`linear-gradient(90deg, ${de.map(F=>`${F.color} ${F.position}%`).join(", ")})`,[de]);if(f)return null;const H=e.jsxs("div",{className:"nice-gradient__tab",children:[z&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"nice-gradient__type-row",children:[["linear","radial","conic"].map(F=>e.jsx("button",{type:"button",className:`nice-gradient__type-btn ${g.type===F?"nice-gradient__type-btn--active":""}`,onClick:()=>S(F),disabled:k,children:F.charAt(0).toUpperCase()+F.slice(1)},F)),e.jsxs("label",{className:"nice-gradient__repeat-label",children:[e.jsx("input",{type:"checkbox",checked:g.repeating??!1,onChange:F=>ue(F.target.checked),disabled:k}),"Repeating"]})]}),e.jsxs("div",{className:"nice-gradient__controls",children:[g.type==="linear"&&e.jsxs("div",{className:"nice-gradient__control-group",children:[e.jsxs("label",{children:["Angle: ",g.angle,"°"]}),e.jsx("input",{type:"range",min:0,max:360,value:g.angle,onChange:F=>ae(Number(F.target.value)),disabled:k,className:"nice-gradient__slider"}),e.jsx("div",{className:"nice-gradient__angle-presets",children:[0,45,90,135,180,225,270,315].map(F=>e.jsx("button",{type:"button",className:`nice-gradient__angle-btn ${g.angle===F?"nice-gradient__angle-btn--active":""}`,onClick:()=>ae(F),disabled:k,title:`${F}°`,children:e.jsx("span",{style:{transform:`rotate(${F}deg)`,display:"inline-flex"},children:e.jsx(y.oa,{name:"arrow-right",size:14})})},F))})]}),g.type==="radial"&&e.jsxs("div",{className:"nice-gradient__control-group",children:[e.jsx("label",{children:"Shape:"}),e.jsx("div",{className:"nice-gradient__shape-btns",children:["circle","ellipse"].map(F=>e.jsx("button",{type:"button",className:`nice-gradient__shape-btn ${(g.shape||"ellipse")===F?"nice-gradient__shape-btn--active":""}`,onClick:()=>ce(F),disabled:k,children:F},F))})]}),(g.type==="radial"||g.type==="conic")&&e.jsxs("div",{className:"nice-gradient__control-group",children:[e.jsxs("label",{children:["Center: ",g.positionX??50,"%, ",g.positionY??50,"%"]}),e.jsxs("div",{className:"nice-gradient__center-inputs",children:[e.jsx("input",{type:"range",min:0,max:100,value:g.positionX??50,onChange:F=>D({...g,positionX:Number(F.target.value)}),disabled:k,className:"nice-gradient__slider"}),e.jsx("input",{type:"range",min:0,max:100,value:g.positionY??50,onChange:F=>D({...g,positionY:Number(F.target.value)}),disabled:k,className:"nice-gradient__slider"})]})]}),g.type==="conic"&&e.jsxs("div",{className:"nice-gradient__control-group",children:[e.jsxs("label",{children:["Start angle: ",g.angle,"°"]}),e.jsx("input",{type:"range",min:0,max:360,value:g.angle,onChange:F=>ae(Number(F.target.value)),disabled:k,className:"nice-gradient__slider"})]})]}),e.jsxs("div",{className:"nice-gradient__bar-container",children:[e.jsx("div",{ref:$,className:"nice-gradient__bar",style:{background:O},onClick:Z,children:g.stops.map((F,Q)=>e.jsx("div",{className:`nice-gradient__stop-marker ${te===Q?"nice-gradient__stop-marker--active":""}`,style:{left:`${F.position}%`},onPointerDown:K=>_e(K,Q),onClick:K=>{K.stopPropagation(),T(Q),ve.current=!1},title:`${F.color} @ ${F.position}%`,children:e.jsx("div",{className:"nice-gradient__stop-dot",style:{background:F.color}})},Q))}),e.jsx("button",{type:"button",className:"nice-gradient__add-stop",onClick:he,disabled:k||g.stops.length>=X,title:"Add stop","aria-label":"Add stop",children:e.jsx(y.oa,{name:"plus",size:14})})]}),e.jsx("div",{className:"nice-gradient__stop-editor",children:e.jsx("div",{className:"nice-gradient__stop-list",children:de.map((F,Q)=>{const K=g.stops.indexOf(F);return e.jsxs("div",{className:`nice-gradient__stop-row ${te===K?"nice-gradient__stop-row--active":""}`,onClick:()=>T(K),children:[e.jsx("input",{type:"color",value:F.color,onChange:se=>be(K,{color:se.target.value}),disabled:k,className:"nice-gradient__stop-color"}),e.jsx("input",{type:"text",value:F.color.toUpperCase(),maxLength:7,onChange:se=>be(K,{color:se.target.value}),disabled:k,className:"nice-gradient__stop-hex"}),e.jsx("input",{type:"number",min:0,max:100,value:F.position,onChange:se=>be(K,{position:Number(se.target.value)}),disabled:k,className:"nice-gradient__stop-pos"}),e.jsx("span",{className:"nice-gradient__stop-pct",children:"%"}),g.stops.length>2&&e.jsx("button",{type:"button",className:"nice-gradient__stop-del",onClick:()=>ye(K),disabled:k,"aria-label":"Remove stop",children:e.jsx(y.oa,{name:"close",size:14})})]},K)})})})]}),C&&e.jsxs("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm nice-gradient__random-btn",onClick:xe,disabled:k,title:"Random gradient","aria-label":"Random gradient",children:[e.jsx(y.oa,{name:"shuffle",size:14})," Random Gradient"]})]}),Y=e.jsx("div",{className:"nice-gradient__tab",children:e.jsx("div",{className:"nice-gradient__preset-grid",children:fn.map((F,Q)=>e.jsxs("button",{type:"button",className:"nice-gradient__preset-card",onClick:()=>{k||D(F.value)},disabled:k,title:F.name,children:[e.jsx("div",{className:"nice-gradient__preset-preview",style:{background:Nt(F.value)}}),e.jsx("span",{className:"nice-gradient__preset-name",children:F.name})]},Q))})}),ge=e.jsxs("div",{className:"nice-gradient__tab",children:[e.jsxs("div",{className:"nice-gradient__css-output",children:[e.jsx("code",{children:`background: ${P};`}),e.jsx("button",{type:"button",className:"nice-gradient__copy-btn",onClick:()=>navigator.clipboard?.writeText(`background: ${P};`),title:"Copy CSS","aria-label":"Copy CSS",children:e.jsx(y.oa,{name:"clipboard",size:16})})]}),e.jsxs("div",{className:"nice-gradient__css-import",children:[e.jsx("input",{type:"text",className:"nice-gradient__css-input",placeholder:"Paste CSS gradient to import...",value:b,onChange:F=>s(F.target.value),disabled:k}),e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm",onClick:re,disabled:k,children:"Import"})]})]}),le=[{id:"editor",label:"Editor",content:H}];return _&&le.push({id:"presets",label:"Presets",content:Y}),x&&le.push({id:"css",label:"CSS",content:ge}),e.jsxs("div",{ref:j,id:U,className:`nice-field nice-gradient-field ${k?"nice-gradient--disabled":""} ${L==="left"?"nice-field--label-left":""} ${ne?"nice-field--loading":""} ${ee?"nice-field--error":""} ${ie==="right"?"nice-field--error-right":""} ${i||""}`,style:a,children:[q&&e.jsx("label",{htmlFor:U,className:"nice-field__label",children:q}),e.jsxs("div",{className:"nice-field__control",children:[e.jsx("button",{ref:A,type:"button",className:"nice-gradient__swatch",style:{background:P},"aria-haspopup":"dialog","aria-expanded":M,"aria-readonly":w||void 0,"aria-label":"Open gradient editor",disabled:k,onClick:()=>{!k&&!w&&l(F=>!F)}}),ne&&e.jsx("span",{className:"nice-field__spinner",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})}),ie==="right"&&typeof ee=="string"&&ee&&e.jsx("div",{className:"nice-field__error",role:"alert",children:ee}),M&&c&&B&&Ze.createPortal(e.jsx("div",{ref:V,className:`nice-gradient__popup${p?` ${p}`:""}`,"data-theme":p==="nice-dark"?"dark":p==="nice-light"?"light":void 0,role:"dialog","aria-label":"Gradient editor",style:{position:"fixed",left:c.left,top:c.top,width:I!=null?typeof I=="number"?`${I}px`:I:340,zIndex:1e3},children:e.jsxs("div",{className:"nice-gradient nice-gradient--studio",children:[e.jsxs("div",{className:"nice-gradient__popup-header",children:[e.jsx("div",{className:"nice-gradient__preview",style:{background:P}}),e.jsx("button",{type:"button",className:"nice-gradient__confirm",onClick:()=>l(!1),"aria-label":u("controls.confirm","Confirm"),title:u("controls.confirm","Confirm"),children:e.jsx(y.oa,{name:"check",size:18})})]}),e.jsx(Fe.NiceTabs,{tabs:le,variant:"enclosed",size:"sm"})]})}),B)]}),ie!=="right"&&typeof ee=="string"&&ee&&e.jsx("div",{className:"nice-field__error",role:"alert",children:ee})]})});yn.displayName="NiceGradientPicker";const ui=[{code:"en",label:"English"},{code:"es",label:"Spanish"},{code:"fr",label:"French"},{code:"de",label:"German"},{code:"it",label:"Italian"},{code:"pt",label:"Portuguese"},{code:"pl",label:"Polish"},{code:"ru",label:"Russian"},{code:"zh",label:"Chinese"},{code:"ja",label:"Japanese"},{code:"ko",label:"Korean"},{code:"ar",label:"Arabic"}],pi=[{style:"professional",label:"Professional"},{style:"casual",label:"Casual"},{style:"formal",label:"Formal"},{style:"concise",label:"Concise"}],hi=n.forwardRef(function(i,a){const{enableAI:o=!0,aiModel:r,enableImprove:h=!0,enableTranslate:x=!0,enableGenerate:_=!0,toolbar:z,languages:C=ui,textStyles:X=pi,onImprove:q,onTranslate:L,onGenerate:k,showAIToolbar:J=!0,value:ne,onChange:ee,...ie}=i,I=n.useRef(null),[j,R]=n.useState(!1),[f,w]=n.useState(!1),[U,u]=n.useState(!1),[g,P]=n.useState(""),[te,T]=n.useState(""),[b,s]=n.useState("professional"),[$,M]=n.useState(""),[l,c]=n.useState(C[0]?.code||"en"),[d,p]=n.useState(""),[E,v]=n.useState(""),{t:B}=y.Gt(),A=y.he(),{improveText:V,translate:N,generateHtml:D,isLoading:S}=y.Cd(),ae=o&&A.isConfigured,ue=n.useCallback(()=>{const re=window.getSelection();return re&&re.toString().trim()?re.toString():""},[]),ce=n.useCallback(re=>{const Z=window.getSelection();if(Z&&Z.rangeCount>0){const de=Z.getRangeAt(0);de.deleteContents();const O=document.createElement("div");O.innerHTML=re;const H=document.createDocumentFragment();for(;O.firstChild;)H.appendChild(O.firstChild);if(de.insertNode(H),I.current){const Y=I.current.innerHTML;ee?.(Y)}}},[ee]),be=n.useCallback(async(re="professional")=>{if(!ae||!h)return"";const Z=ue();if(!Z)return"";P(Z),s(re),R(!0),T("");try{const de=await V(Z,re);return T(de),q?.(Z,de,re),de}catch{return T(B("htmlEditorAI.improveFailed","Failed to improve text")),""}},[ae,h,ue,V,q,B]),ve=n.useCallback(async re=>{if(!ae||!x)return"";const Z=ue();if(!Z)return"";P(Z),c(re),w(!0),M("");try{const de=C.find(H=>H.code===re)?.label||re,O=await N(Z,de);return M(O),L?.(Z,O,re),O}catch{return M(B("htmlEditorAI.translateFailed","Failed to translate text")),""}},[ae,x,ue,N,C,L,B]),_e=n.useCallback(async re=>{if(!ae||!_||!re.trim())return"";p(re),v("");try{const Z=await D(re);return v(Z),k?.(re,Z),Z}catch{return v(B("htmlEditorAI.generateFailed","Failed to generate HTML")),""}},[ae,_,D,k,B]),he=n.useCallback(()=>{te&&ce(te),R(!1),T("")},[te,ce]),ye=n.useCallback(()=>{$&&ce($),w(!1),M("")},[$,ce]),xe=n.useCallback(()=>{if(E&&I.current){document.execCommand("insertHTML",!1,E);const re=I.current.innerHTML;ee?.(re)}u(!1),v(""),p("")},[E,ee]);return n.useImperativeHandle(a,()=>({getEditor:()=>I.current,focus:()=>I.current?.focus(),getValue:()=>I.current?.innerHTML||"",setValue:re=>{I.current&&(I.current.innerHTML=re,ee?.(re))},getSelection:ue,insertHtml:re=>{document.execCommand("insertHTML",!1,re),I.current&&ee?.(I.current.innerHTML)},improveSelection:be,translateSelection:ve,generateHtml:_e})),n.useCallback(re=>{I.current=re},[]),e.jsxs("div",{className:"nice-html-editor-ai","data-testid":i["data-testid"],children:[J&&ae&&e.jsxs("div",{className:"nice-html-editor-ai__toolbar",children:[e.jsxs("div",{className:"nice-html-editor-ai__toolbar-left",children:[e.jsx("span",{className:"nice-html-editor-ai__badge",children:"AI"}),S&&e.jsx("span",{className:"nice-html-editor-ai__loading",children:B("htmlEditorAI.processing","Processing...")})]}),e.jsxs("div",{className:"nice-html-editor-ai__toolbar-right",children:[h&&e.jsxs("div",{className:"nice-html-editor-ai__dropdown",children:[e.jsxs("button",{type:"button",className:"nice-html-editor-ai__btn",onClick:()=>be(),disabled:S,title:B("htmlEditorAI.improveText","Improve selected text"),children:[e.jsx(y.oa,{name:"star",size:14})," ",B("htmlEditorAI.improve","Improve")]}),e.jsx("div",{className:"nice-html-editor-ai__dropdown-menu",children:X.map(({style:re,label:Z})=>e.jsx("button",{type:"button",className:"nice-html-editor-ai__dropdown-item",onClick:()=>be(re),children:Z},re))})]}),x&&e.jsxs("div",{className:"nice-html-editor-ai__dropdown",children:[e.jsxs("button",{type:"button",className:"nice-html-editor-ai__btn",disabled:S,title:B("htmlEditorAI.translateText","Translate selected text"),children:[e.jsx(y.oa,{name:"globe",size:14})," ",B("htmlEditorAI.translate","Translate")]}),e.jsx("div",{className:"nice-html-editor-ai__dropdown-menu nice-html-editor-ai__dropdown-menu--languages",children:C.map(({code:re,label:Z})=>e.jsx("button",{type:"button",className:"nice-html-editor-ai__dropdown-item",onClick:()=>ve(re),children:Z},re))})]}),_&&e.jsxs("button",{type:"button",className:"nice-html-editor-ai__btn",onClick:()=>u(!0),disabled:S,title:B("htmlEditorAI.generateHtml","Generate HTML from description"),children:[e.jsx(y.oa,{name:"zap",size:14})," ",B("htmlEditorAI.generate","Generate")]})]})]}),e.jsx("div",{className:"nice-html-editor-ai__editor-wrapper",children:e.jsx(Kn.NiceHtmlEditor,{value:ne,onChange:ee,toolbar:z,...ie})}),j&&e.jsxs("div",{className:"nice-html-editor-ai__panel",children:[e.jsxs("div",{className:"nice-html-editor-ai__panel-header",children:[e.jsxs("h4",{children:[e.jsx(y.oa,{name:"star",size:16})," ",B("htmlEditorAI.improveText","Improve Text")]}),e.jsx("div",{className:"nice-html-editor-ai__style-selector",children:X.map(({style:re,label:Z})=>e.jsx("button",{type:"button",className:`nice-html-editor-ai__style-btn ${b===re?"nice-html-editor-ai__style-btn--active":""}`,onClick:()=>{s(re),be(re)},children:Z},re))}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__close","aria-label":B("htmlEditorAI.close","Close"),onClick:()=>R(!1),children:e.jsx(y.oa,{name:"close",size:14})})]}),e.jsx("div",{className:"nice-html-editor-ai__panel-body",children:S?e.jsx("div",{className:"nice-html-editor-ai__loading-panel",children:B("htmlEditorAI.improving","Improving text...")}):e.jsxs("div",{className:"nice-html-editor-ai__comparison",children:[e.jsxs("div",{className:"nice-html-editor-ai__text-block",children:[e.jsx("h5",{children:B("htmlEditorAI.original","Original")}),e.jsx("div",{className:"nice-html-editor-ai__text-content",children:g})]}),e.jsxs("div",{className:"nice-html-editor-ai__text-block nice-html-editor-ai__text-block--improved",children:[e.jsx("h5",{children:B("htmlEditorAI.improved","Improved")}),e.jsx("div",{className:"nice-html-editor-ai__text-content",children:te})]})]})}),e.jsxs("div",{className:"nice-html-editor-ai__panel-footer",children:[e.jsxs("button",{type:"button",className:"nice-html-editor-ai__apply",onClick:he,disabled:!te||S,children:[e.jsx(y.oa,{name:"check",size:14})," ",B("htmlEditorAI.apply","Apply")]}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__cancel",onClick:()=>{R(!1),T("")},children:B("htmlEditorAI.cancel","Cancel")})]})]}),f&&e.jsxs("div",{className:"nice-html-editor-ai__panel",children:[e.jsxs("div",{className:"nice-html-editor-ai__panel-header",children:[e.jsxs("h4",{children:[e.jsx(y.oa,{name:"globe",size:16})," ",B("htmlEditorAI.translateText","Translate Text")]}),e.jsx("div",{className:"nice-html-editor-ai__language-selector",children:e.jsx("select",{value:l,onChange:re=>{c(re.target.value),ve(re.target.value)},className:"nice-html-editor-ai__language-select",children:C.map(({code:re,label:Z})=>e.jsx("option",{value:re,children:Z},re))})}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__close","aria-label":B("htmlEditorAI.close","Close"),onClick:()=>w(!1),children:e.jsx(y.oa,{name:"close",size:14})})]}),e.jsx("div",{className:"nice-html-editor-ai__panel-body",children:S?e.jsx("div",{className:"nice-html-editor-ai__loading-panel",children:B("htmlEditorAI.translating","Translating...")}):e.jsxs("div",{className:"nice-html-editor-ai__comparison",children:[e.jsxs("div",{className:"nice-html-editor-ai__text-block",children:[e.jsx("h5",{children:B("htmlEditorAI.original","Original")}),e.jsx("div",{className:"nice-html-editor-ai__text-content",children:g})]}),e.jsxs("div",{className:"nice-html-editor-ai__text-block nice-html-editor-ai__text-block--translated",children:[e.jsx("h5",{children:C.find(re=>re.code===l)?.label||l}),e.jsx("div",{className:"nice-html-editor-ai__text-content",children:$})]})]})}),e.jsxs("div",{className:"nice-html-editor-ai__panel-footer",children:[e.jsxs("button",{type:"button",className:"nice-html-editor-ai__apply",onClick:ye,disabled:!$||S,children:[e.jsx(y.oa,{name:"check",size:14})," ",B("htmlEditorAI.apply","Apply")]}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__cancel",onClick:()=>{w(!1),M("")},children:B("htmlEditorAI.cancel","Cancel")})]})]}),U&&e.jsxs("div",{className:"nice-html-editor-ai__panel nice-html-editor-ai__panel--generate",children:[e.jsxs("div",{className:"nice-html-editor-ai__panel-header",children:[e.jsxs("h4",{children:[e.jsx(y.oa,{name:"zap",size:16})," ",B("htmlEditorAI.generateHtml","Generate HTML")]}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__close","aria-label":B("htmlEditorAI.close","Close"),onClick:()=>{u(!1),v(""),p("")},children:e.jsx(y.oa,{name:"close",size:14})})]}),e.jsxs("div",{className:"nice-html-editor-ai__panel-body",children:[e.jsxs("div",{className:"nice-html-editor-ai__generate-input",children:[e.jsx("textarea",{placeholder:B("htmlEditorAI.generatePlaceholder",'Describe what you want to create (e.g., "A pricing table with 3 tiers", "A contact form with name, email, and message")'),value:d,onChange:re=>p(re.target.value),className:"nice-html-editor-ai__generate-textarea",rows:3}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__generate-btn",onClick:()=>_e(d),disabled:S||!d.trim(),children:S?B("htmlEditorAI.generating","Generating..."):B("htmlEditorAI.generate","Generate")})]}),E&&e.jsxs("div",{className:"nice-html-editor-ai__generate-result",children:[e.jsx("h5",{children:B("htmlEditorAI.preview","Preview")}),e.jsx("div",{className:"nice-html-editor-ai__preview",dangerouslySetInnerHTML:{__html:E}}),e.jsx("h5",{children:B("htmlEditorAI.htmlCode","HTML Code")}),e.jsx("pre",{className:"nice-html-editor-ai__code",children:E})]})]}),e.jsxs("div",{className:"nice-html-editor-ai__panel-footer",children:[e.jsxs("button",{type:"button",className:"nice-html-editor-ai__apply",onClick:xe,disabled:!E||S,children:[e.jsx(y.oa,{name:"check",size:14})," ",B("htmlEditorAI.insert","Insert")]}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__cancel",onClick:()=>{u(!1),v(""),p("")},children:B("htmlEditorAI.cancel","Cancel")})]})]})]})}),gi=[{target:".nice-md-editor",titleKey:"tutorial.markdownEditor.intro.title",title:"Markdown editor",contentKey:"tutorial.markdownEditor.intro.content",content:"Write Markdown with the formatting toolbar; toggle the live preview to see the rendered result, and export to HTML.",placement:"auto"}];function fi(t){let i=t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");return i=i.replace(/```(\w*)\n([\s\S]*?)```/g,(a,o,r)=>`<pre><code class="language-${o}">${r.trim()}</code></pre>`),i=i.replace(/^(\|.+\|)\n(\|[-| :]+\|)\n((?:\|.+\|\n?)+)/gm,(a,o,r,h)=>{const x=o.split("|").filter(z=>z.trim()).map(z=>`<th>${z.trim()}</th>`).join(""),_=h.trim().split(`
2
+ `).map(z=>`<tr>${z.split("|").filter(X=>X.trim()).map(X=>`<td>${X.trim()}</td>`).join("")}</tr>`).join("");return`<table><thead><tr>${x}</tr></thead><tbody>${_}</tbody></table>`}),i=i.replace(/^#### (.+)$/gm,"<h4>$1</h4>"),i=i.replace(/^### (.+)$/gm,"<h3>$1</h3>"),i=i.replace(/^## (.+)$/gm,"<h2>$1</h2>"),i=i.replace(/^# (.+)$/gm,"<h1>$1</h1>"),i=i.replace(/^&gt; (.+)$/gm,"<blockquote>$1</blockquote>"),i=i.replace(/^---$/gm,"<hr/>"),i=i.replace(/^- \[x\] (.+)$/gm,'<li class="task done">☑ $1</li>'),i=i.replace(/^- \[ \] (.+)$/gm,'<li class="task">☐ $1</li>'),i=i.replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>"),i=i.replace(/\*(.+?)\*/g,"<em>$1</em>"),i=i.replace(/~~(.+?)~~/g,"<del>$1</del>"),i=i.replace(/`(.+?)`/g,"<code>$1</code>"),i=i.replace(/!\[([^\]]*)\]\(([^)]+)\)/g,'<img src="$2" alt="$1" style="max-width:100%"/>'),i=i.replace(/\[([^\]]+)\]\(([^)]+)\)/g,'<a href="$2">$1</a>'),i=i.replace(/^\- (.+)$/gm,"<li>$1</li>"),i=i.replace(/^\d+\. (.+)$/gm,"<li>$1</li>"),i=i.replace(/\n/g,"<br/>"),i}const yi=[{key:"bold",label:"B",md:"**",tip:"Bold",shortcut:"Ctrl+B",group:"format"},{key:"italic",label:"I",md:"*",tip:"Italic",shortcut:"Ctrl+I",group:"format"},{key:"strike",icon:"type",md:"~~",tip:"Strikethrough",group:"format"},{key:"code",label:"< >",md:"`",tip:"Inline code",group:"format"},{key:"h1",label:"H1",md:"# ",tip:"Heading 1",group:"heading"},{key:"h2",label:"H2",md:"## ",tip:"Heading 2",group:"heading"},{key:"h3",label:"H3",md:"### ",tip:"Heading 3",group:"heading"},{key:"ul",icon:"list",md:"- ",tip:"Unordered list",group:"list"},{key:"ol",label:"1.",md:"1. ",tip:"Ordered list",group:"list"},{key:"task",icon:"check-square",md:"- [ ] ",tip:"Task list",group:"list"},{key:"quote",icon:"message",md:"> ",tip:"Blockquote",group:"block"},{key:"hr",icon:"minus",md:`---
3
+ `,tip:"Horizontal rule",group:"block"},{key:"link",icon:"link",md:"[](url)",tip:"Link",shortcut:"Ctrl+K",group:"insert"},{key:"image",icon:"image",md:"![](url)",tip:"Image",group:"insert"},{key:"table",icon:"table",md:`| H1 | H2 | H3 |
4
+ | --- | --- | --- |
5
+ | c1 | c2 | c3 |
6
+ `,tip:"Table",group:"insert"},{key:"codeblock",label:"```",md:"```\n",tip:"Code block",group:"insert"}],xi=["format","heading","list","block","insert"],xn=n.forwardRef(({value:t="",onChange:i,preview:a="side",placeholder:o,disabled:r,readOnly:h,size:x="md",editorSize:_="standard",toolbar:z=!0,minHeight:C=200,showWordCount:X=!1,showLineNumbers:q=!1,onExportHtml:L,onImageUpload:k,tutorial:J,className:ne,style:ee,id:ie},I)=>{const j=y.bc(ie),[R,f]=n.useState("edit"),[w,U]=n.useState(!1),u=n.useRef(null),g=n.useMemo(()=>fi(t),[t]),P=n.useMemo(()=>{const l=t.trim()?t.trim().split(/\s+/).length:0,c=t.length,d=t.split(`
7
+ `).length;return{words:l,chars:c,lines:d}},[t]),te=n.useCallback(l=>{const c=u.current;if(!c)return;const d=c.selectionStart,p=c.selectionEnd,E=t.slice(d,p);let v,B;l==="[](url)"?(v=t.slice(0,d)+`[${E||"text"}](url)`+t.slice(p),B=d+1+(E||"text").length+2):l==="![](url)"?(v=t.slice(0,d)+`![${E||"alt"}](url)`+t.slice(p),B=d+2+(E||"alt").length+2):l.endsWith(`
8
+ `)||l.endsWith(" ")?(v=t.slice(0,d)+l+E+t.slice(p),B=d+l.length+E.length):(v=t.slice(0,d)+l+E+l+t.slice(p),B=d+l.length+E.length+l.length),i?.(v),requestAnimationFrame(()=>{c.focus(),c.setSelectionRange(B,B)})},[t,i]),T=n.useCallback(l=>{if((l.ctrlKey||l.metaKey)&&(l.key==="b"?(l.preventDefault(),te("**")):l.key==="i"?(l.preventDefault(),te("*")):l.key==="k"&&(l.preventDefault(),te("[](url)"))),l.key==="Tab"){l.preventDefault();const c=l.currentTarget,d=c.selectionStart,p=c.selectionEnd,E=" ";if(l.shiftKey){const A=t.slice(0,d).lastIndexOf(`
9
+ `)+1;if(t.slice(A,A+E.length)===E){const V=t.slice(0,A)+t.slice(A+E.length);i?.(V),requestAnimationFrame(()=>{c.selectionStart=c.selectionEnd=d-E.length})}}else{const v=t.slice(0,d)+E+t.slice(p);i?.(v),requestAnimationFrame(()=>{c.selectionStart=c.selectionEnd=d+E.length})}}},[t,i,te]),b=n.useCallback(async l=>{if(!k)return;const c=Array.from(l.dataTransfer.files).filter(d=>d.type.startsWith("image/"));if(c.length!==0){l.preventDefault();for(const d of c){const p=await k(d),E=u.current;if(!E)continue;const v=E.selectionStart,B=`![${d.name}](${p})
10
+ `,A=t.slice(0,v)+B+t.slice(v);i?.(A)}}},[t,i,k]),s=a!=="tab"||R==="edit",$=a==="side"||a==="tab"&&R==="preview"||a===!0,M=`nice-md-editor nice-md-editor--${x} nice-editor--${_} nice-md-editor--preview-${a}${w?" nice-md-editor--fullscreen":""} ${ne||""}`;return e.jsxs("div",{ref:I,id:j,className:M,style:{position:"relative",...ee},children:[e.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:20},children:e.jsx(y.Ql,{steps:y.Yl(J,gi)})}),z&&e.jsxs("div",{className:"nice-md-editor__toolbar",children:[xi.map((l,c)=>e.jsxs(n.Fragment,{children:[c>0&&e.jsx("span",{className:"nice-md-editor__sep"}),yi.filter(d=>d.group===l).map(d=>e.jsx("button",{type:"button",className:"nice-md-editor__btn",title:d.shortcut?`${d.tip} (${d.shortcut})`:d.tip,disabled:r||h,onClick:()=>te(d.md),"aria-label":d.tip,children:d.icon?e.jsx(y.oa,{name:d.icon,size:16}):d.label},d.key))]},l)),e.jsx("span",{className:"nice-md-editor__sep"}),e.jsx("button",{type:"button",className:"nice-md-editor__btn",title:"Fullscreen","aria-label":"Fullscreen",onClick:()=>U(!w),children:e.jsx(y.oa,{name:w?"collapse":"expand",size:16})}),L&&e.jsx("button",{type:"button",className:"nice-md-editor__btn",title:"Export HTML","aria-label":"Export HTML",onClick:()=>L(g),children:e.jsx(y.oa,{name:"external-link",size:16})}),a==="tab"&&e.jsxs("span",{className:"nice-md-editor__tabs",children:[e.jsx("button",{type:"button",className:`nice-md-editor__tab${R==="edit"?" nice-md-editor__tab--active":""}`,onClick:()=>f("edit"),children:"Edit"}),e.jsx("button",{type:"button",className:`nice-md-editor__tab${R==="preview"?" nice-md-editor__tab--active":""}`,onClick:()=>f("preview"),children:"Preview"})]})]}),e.jsxs("div",{className:"nice-md-editor__body",style:{minHeight:C},children:[s&&e.jsxs("div",{className:"nice-md-editor__editor-wrap",children:[q&&e.jsx("div",{className:"nice-md-editor__line-numbers",children:Array.from({length:P.lines},(l,c)=>e.jsx("div",{className:"nice-md-editor__line-no",children:c+1},c))}),e.jsx("textarea",{ref:u,className:"nice-md-editor__textarea",value:t,onChange:l=>i?.(l.target.value),onKeyDown:T,onDrop:b,placeholder:o,disabled:r,readOnly:h,style:{minHeight:C}})]}),$&&e.jsx("div",{className:"nice-md-editor__preview",dangerouslySetInnerHTML:{__html:y.lc(g)},style:{minHeight:C}})]}),X&&e.jsxs("div",{className:"nice-md-editor__statusbar",children:[e.jsxs("span",{children:[P.words," words"]}),e.jsxs("span",{children:[P.chars," chars"]}),e.jsxs("span",{children:[P.lines," lines"]})]})]})});xn.displayName="NiceMarkdownEditor";const ji=[{target:".nice-doc-editor",titleKey:"tutorial.documentEditor.intro.title",title:"Document editor",contentKey:"tutorial.documentEditor.intro.content",content:"Compose a document from blocks: use the toolbar or slash commands to add headings, lists, media and more, then export to HTML.",placement:"auto"}];let bi=0;function $t(){return`blk-${++bi}-${Date.now().toString(36)}`}function Bt(t=""){return{id:$t(),type:"paragraph",content:t}}function vi(t,i=""){const a={id:$t(),type:t,content:i};return t==="heading"&&(a.level=2),t==="list"&&(a.listType="unordered"),t==="callout"&&(a.icon="??"),t==="toggle"&&(a.open=!0),a}const _i=[{type:"paragraph",label:"Text",icon:"�",keywords:"paragraph text"},{type:"heading",label:"Heading",icon:"H",keywords:"heading title"},{type:"list",label:"Bulleted list",icon:"�",keywords:"bullet unordered list"},{type:"list",label:"Numbered list",icon:"1.",keywords:"numbered ordered list"},{type:"list",label:"Checklist",icon:"?",keywords:"check todo list"},{type:"quote",label:"Quote",icon:"?",keywords:"quote blockquote"},{type:"callout",label:"Callout",icon:"??",keywords:"callout info alert"},{type:"toggle",label:"Toggle",icon:"?",keywords:"toggle collapse expand"},{type:"code",label:"Code",icon:"</>",keywords:"code snippet"},{type:"image",label:"Image",icon:"??",keywords:"image photo picture"},{type:"video",label:"Video",icon:"??",keywords:"video embed"},{type:"table",label:"Table",icon:"?",keywords:"table grid"},{type:"divider",label:"Divider",icon:"-",keywords:"divider line separator"},{type:"pageBreak",label:"Page Break",icon:"?",keywords:"page break"}];function ki(t){const i=[t.align?`text-align:${t.align}`:"",t.color?`color:${t.color}`:"",t.bgColor?`background-color:${t.bgColor}`:"",t.indent?`margin-left:${t.indent*24}px`:""].filter(Boolean).join(";"),a=i?` style="${i}"`:"",o=(r,h)=>{let x=h;return t.bold&&(x=`<strong>${x}</strong>`),t.italic&&(x=`<em>${x}</em>`),t.underline&&(x=`<u>${x}</u>`),t.strikethrough&&(x=`<s>${x}</s>`),`<${r}${a}>${x}</${r}>`};switch(t.type){case"heading":return o(`h${t.level??2}`,t.content);case"paragraph":return o("p",t.content||"&nbsp;");case"list":{const r=t.listType==="ordered"?"ol":"ul",h=t.content.split(`
11
+ `).map((x,_)=>t.listType==="checklist"?`<li><input type="checkbox" ${t.checked?.[_]??!1?"checked":""} disabled />${x}</li>`:`<li>${x}</li>`).join("");return`<${r}${a}>${h}</${r}>`}case"image":return`<figure${a}><img src="${t.src??""}" alt="${t.alt??""}" /></figure>`;case"video":return`<figure${a}><video src="${t.src??""}" controls></video></figure>`;case"divider":return"<hr />";case"pageBreak":return'<div style="page-break-after:always"></div>';case"code":return`<pre><code class="language-${t.language??""}">${t.content}</code></pre>`;case"quote":return o("blockquote",t.content);case"callout":return`<div class="nice-doc-callout"${a}><span>${t.icon??"??"}</span><div>${t.content}</div></div>`;case"toggle":return`<details${a}><summary>${t.content.split(`
12
+ `)[0]}</summary>${t.content.split(`
13
+ `).slice(1).join("<br>")}</details>`;case"table":return`<table${a}>${t.content}</table>`;case"embed":return`<iframe src="${t.src??""}" style="width:100%;border:none;min-height:300px"></iframe>`;default:return o("p",t.content)}}function wi(t){let i=0,a=0;for(const o of t){const r=o.content??"";i+=r.length;const h=r.trim().split(/\s+/).filter(Boolean);a+=h.length}return{words:a,chars:i,readingTime:Math.max(1,Math.ceil(a/200))}}const jn=n.forwardRef(({blocks:t,onChange:i,readOnly:a=!1,showToolbar:o=!0,size:r="md",editorSize:h="standard",placeholder:x,onExport:_,onImageUpload:z,maxUndo:C=50,slashCommands:X=!0,showWordCount:q=!1,showToc:L=!1,showFindReplace:k=!0,tutorial:J,className:ne,style:ee,id:ie,...I},j)=>{const R=y.bc(ie),{t:f}=y.Gt(),[w,U]=n.useState(()=>t??[Bt()]),u=t??w,[g,P]=n.useState(0),te=n.useRef(new Map),T=n.useRef(null),[b,s]=n.useState(!1),[$,M]=n.useState(""),[l,c]=n.useState(""),[d,p]=n.useState([]),[E,v]=n.useState(0),[B,A]=n.useState(!1),V=n.useRef([]),N=n.useRef([]),D=n.useCallback(m=>{V.current.push(m.map(G=>({...G,checked:G.checked?[...G.checked]:void 0}))),V.current.length>C&&V.current.shift(),N.current=[]},[C]),S=n.useCallback(()=>{if(V.current.length===0)return;const m=V.current.pop();N.current.push(u.map(G=>({...G}))),t||U(m),i?.(m)},[u,t,i]),ae=n.useCallback(()=>{if(N.current.length===0)return;const m=N.current.pop();V.current.push(u.map(G=>({...G}))),t||U(m),i?.(m)},[u,t,i]),[ue,ce]=n.useState(!1),[be,ve]=n.useState(""),[_e,he]=n.useState(0),ye=n.useMemo(()=>{if(!ue||!X)return[];const m=be.toLowerCase();return _i.filter(G=>G.label.toLowerCase().includes(m)||G.keywords.includes(m))},[ue,be,X]),[xe,re]=n.useState(null),[Z,de]=n.useState(null),O=n.useCallback(m=>{D(u);const G=m(u);t||U(G),i?.(G)},[u,t,i,D]),H=n.useCallback((m,G)=>{O(oe=>oe.map((Ce,$e)=>$e===m?{...Ce,...G}:Ce))},[O]),Y=n.useCallback((m,G)=>{const oe=G??Bt();O(Ce=>{const $e=[...Ce];return $e.splice(m+1,0,oe),$e}),P(m+1)},[O]),ge=n.useCallback(m=>{const G={...u[m],id:$t()};Y(m,G)},[u,Y]),le=n.useCallback(m=>{u.length<=1||(O(G=>G.filter((oe,Ce)=>Ce!==m)),P(Math.max(0,m-1)))},[u.length,O]),F=n.useCallback((m,G)=>{const oe=m+G;oe<0||oe>=u.length||(O(Ce=>{const $e=[...Ce];return[$e[m],$e[oe]]=[$e[oe],$e[m]],$e}),P(oe))},[u.length,O]),Q=n.useCallback((m,G)=>{const oe={type:G};G==="heading"&&(oe.level=2),G==="list"&&(oe.listType="unordered"),G==="callout"&&(oe.icon="??"),G==="toggle"&&(oe.open=!0),H(m,oe)},[H]),K=n.useCallback(m=>{const G=vi(m.type);m.type==="list"&&m.label.includes("Numbered")&&(G.listType="ordered"),m.type==="list"&&m.label.includes("Checklist")&&(G.listType="checklist",G.checked=[]),u[g]?.content===""||u[g]?.content==="/"?O(oe=>oe.map((Ce,$e)=>$e===g?{...G,id:Ce.id}:Ce)):Y(g,G),ce(!1),ve("")},[u,g,O,Y]),se=n.useCallback((m,G)=>{if(a)return;const oe=u[G];if(!oe?.locked){if((m.ctrlKey||m.metaKey)&&m.key==="z"&&!m.shiftKey){m.preventDefault(),S();return}if((m.ctrlKey||m.metaKey)&&(m.key==="y"||m.key==="z"&&m.shiftKey)){m.preventDefault(),ae();return}if((m.ctrlKey||m.metaKey)&&m.key==="d"){m.preventDefault(),ge(G);return}if((m.ctrlKey||m.metaKey)&&m.key==="b"){m.preventDefault(),H(G,{bold:!oe?.bold});return}if((m.ctrlKey||m.metaKey)&&m.key==="i"){m.preventDefault(),H(G,{italic:!oe?.italic});return}if((m.ctrlKey||m.metaKey)&&m.key==="u"){m.preventDefault(),H(G,{underline:!oe?.underline});return}if((m.ctrlKey||m.metaKey)&&m.key==="e"){m.preventDefault(),H(G,{strikethrough:!oe?.strikethrough});return}if(m.key==="Tab"&&!m.shiftKey){m.preventDefault(),H(G,{indent:Math.min((oe?.indent??0)+1,4)});return}if(m.key==="Tab"&&m.shiftKey){m.preventDefault(),H(G,{indent:Math.max((oe?.indent??0)-1,0)});return}if((m.ctrlKey||m.metaKey)&&m.key==="f"&&k){m.preventDefault(),s(Ce=>!Ce);return}if(ue&&ye.length>0){if(m.key==="ArrowDown"){m.preventDefault(),he(Ce=>Math.min(Ce+1,ye.length-1));return}if(m.key==="ArrowUp"){m.preventDefault(),he(Ce=>Math.max(Ce-1,0));return}if(m.key==="Enter"){m.preventDefault(),K(ye[_e]);return}if(m.key==="Escape"){ce(!1);return}}m.key==="Enter"&&!m.shiftKey?(m.preventDefault(),Y(G)):m.key==="Backspace"&&u[G].content===""&&u.length>1?(m.preventDefault(),le(G)):m.key==="ArrowUp"&&m.altKey?(m.preventDefault(),F(G,-1)):m.key==="ArrowDown"&&m.altKey&&(m.preventDefault(),F(G,1))}},[a,u,Y,le,F,S,ae,ge,H,ue,ye,_e,K,k]),me=n.useCallback((m,G)=>{const oe=m.target.textContent??"";X&&oe.startsWith("/")?(ce(!0),ve(oe.slice(1)),he(0)):ue&&ce(!1),D(u);const Ce=u.map(($e,Ue)=>Ue===G?{...$e,content:oe}:$e);t||U(Ce),i?.(Ce)},[u,t,i,D,X,ue]),je=n.useCallback((m,G)=>{re(G),m.dataTransfer.effectAllowed="move"},[]),we=n.useCallback((m,G)=>{m.preventDefault(),m.dataTransfer.dropEffect="move",de(G)},[]),Re=n.useCallback((m,G)=>{if(m.preventDefault(),xe===null||xe===G){re(null),de(null);return}O(oe=>{const Ce=[...oe],[$e]=Ce.splice(xe,1);return Ce.splice(G>xe?G-1:G,0,$e),Ce}),P(G>xe?G-1:G),re(null),de(null)},[xe,O]);n.useEffect(()=>{if(!b||!$){p([]);return}const m=$.toLowerCase(),G=[];u.forEach((oe,Ce)=>{const $e=(oe.content??"").toLowerCase();let Ue=0;for(;Ue<$e.length;){const We=$e.indexOf(m,Ue);if(We===-1)break;G.push({blockIdx:Ce,start:We,end:We+m.length}),Ue=We+1}}),p(G),v(0)},[$,b,u]);const Te=n.useCallback(()=>{if(d.length===0)return;const m=(E+1)%d.length;v(m),P(d[m].blockIdx)},[d,E]),Oe=n.useCallback(()=>{if(d.length===0)return;const m=(E-1+d.length)%d.length;v(m),P(d[m].blockIdx)},[d,E]),qe=n.useCallback(()=>{if(d.length===0||!$)return;const m=d[E],G=u[m.blockIdx],oe=G.content.slice(0,m.start),Ce=G.content.slice(m.end);H(m.blockIdx,{content:oe+l+Ce})},[d,E,$,l,u,H]),Ye=n.useCallback(()=>{if(!$)return;const m=$;O(G=>G.map(oe=>({...oe,content:oe.content.split(m).join(l)})))},[$,l,O]),Ke=n.useMemo(()=>L?u.map((m,G)=>m.type==="heading"?{idx:G,level:m.level??2,text:m.content}:null).filter(Boolean):[],[u,L]),Ve=n.useCallback(async m=>{const G=m.target.files?.[0];if(G){if(z){const oe=await z(G);H(g,{src:oe})}m.target.value=""}},[z,g,H]);n.useEffect(()=>{const m=u[g];if(m){const G=te.current.get(m.id);G&&G.focus()}},[g,u]);const Ne=n.useCallback(()=>{const m=u.map(ki).join(`
14
+ `);_?.(m)},[u,_]),ze=n.useMemo(()=>q?wi(u):null,[u,q]),[pe,Me]=n.useState(null),Ae=n.useCallback((m,G)=>{a||(m.preventDefault(),Me({x:m.clientX,y:m.clientY,idx:G}))},[a]);return n.useEffect(()=>{if(!pe)return;const m=()=>Me(null);return window.addEventListener("click",m),()=>window.removeEventListener("click",m)},[pe]),e.jsxs("div",{ref:j,id:R,className:`nice-doc-editor nice-doc-editor--${r} nice-editor--${h} ${a?"nice-doc-editor--readonly":""} ${ne??""}`,style:{position:"relative",...ee},role:"application","aria-label":f("docEditor.label","Document Editor"),...I,children:[e.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:20},children:e.jsx(y.Ql,{steps:y.Yl(J,ji)})}),o&&!a&&e.jsxs("div",{className:"nice-doc-editor__toolbar",role:"toolbar",style:{display:"flex",flexWrap:"wrap",gap:4,alignItems:"center",padding:"4px 8px"},children:[e.jsx(Se.NiceButton,{size:"sm",variant:"ghost",onClick:S,title:f("docEditor.undo","Undo (Ctrl+Z)"),children:"?"}),e.jsx(Se.NiceButton,{size:"sm",variant:"ghost",onClick:ae,title:f("docEditor.redo","Redo (Ctrl+Y)"),children:"?"}),e.jsx("span",{className:"nice-doc-editor__sep"}),e.jsx(Be.NiceSelect,{size:"sm",value:u[g]?.type??"paragraph",onChange:m=>Q(g,m),label:"",options:[{value:"paragraph",label:f("docEditor.paragraph","Paragraph")},{value:"heading",label:f("docEditor.heading","Heading")},{value:"list",label:f("docEditor.list","List")},{value:"code",label:f("docEditor.code","Code")},{value:"quote",label:f("docEditor.quote","Quote")},{value:"callout",label:f("docEditor.callout","Callout")},{value:"toggle",label:f("docEditor.toggle","Toggle")},{value:"divider",label:f("docEditor.divider","Divider")},{value:"image",label:f("docEditor.image","Image")},{value:"video",label:f("docEditor.video","Video")},{value:"pageBreak",label:f("docEditor.pageBreak","Page Break")}],style:{minWidth:100}}),u[g]?.type==="heading"&&e.jsx(Be.NiceSelect,{size:"sm",value:String(u[g]?.level??2),onChange:m=>H(g,{level:Number(m)}),label:"",options:[{value:"1",label:"H1"},{value:"2",label:"H2"},{value:"3",label:"H3"},{value:"4",label:"H4"},{value:"5",label:"H5"},{value:"6",label:"H6"}],style:{minWidth:55}}),u[g]?.type==="list"&&e.jsx(Be.NiceSelect,{size:"sm",value:u[g]?.listType??"unordered",onChange:m=>H(g,{listType:m}),label:"",options:[{value:"unordered",label:"� Bullets"},{value:"ordered",label:"1. Numbers"},{value:"checklist",label:"? Checklist"}],style:{minWidth:90}}),e.jsx("span",{className:"nice-doc-editor__sep"}),e.jsx(Se.NiceButton,{size:"sm",variant:u[g]?.bold?"primary":"ghost",onClick:()=>H(g,{bold:!u[g]?.bold}),title:f("docEditor.bold","Bold (Ctrl+B)"),children:e.jsx("strong",{children:"B"})}),e.jsx(Se.NiceButton,{size:"sm",variant:u[g]?.italic?"primary":"ghost",onClick:()=>H(g,{italic:!u[g]?.italic}),title:f("docEditor.italic","Italic (Ctrl+I)"),children:e.jsx("em",{children:"I"})}),e.jsx(Se.NiceButton,{size:"sm",variant:u[g]?.underline?"primary":"ghost",onClick:()=>H(g,{underline:!u[g]?.underline}),title:f("docEditor.underline","Underline (Ctrl+U)"),children:e.jsx("u",{children:"U"})}),e.jsx(Se.NiceButton,{size:"sm",variant:u[g]?.strikethrough?"primary":"ghost",onClick:()=>H(g,{strikethrough:!u[g]?.strikethrough}),title:f("docEditor.strikethrough","Strikethrough (Ctrl+E)"),children:e.jsx("s",{children:"S"})}),e.jsx("span",{className:"nice-doc-editor__sep"}),e.jsx(Se.NiceButton,{size:"sm",variant:u[g]?.align==="left"?"primary":"ghost",onClick:()=>H(g,{align:"left"}),title:f("docEditor.alignLeft","Left"),children:"?"}),e.jsx(Se.NiceButton,{size:"sm",variant:u[g]?.align==="center"?"primary":"ghost",onClick:()=>H(g,{align:"center"}),title:f("docEditor.alignCenter","Center"),children:"?"}),e.jsx(Se.NiceButton,{size:"sm",variant:u[g]?.align==="right"?"primary":"ghost",onClick:()=>H(g,{align:"right"}),title:f("docEditor.alignRight","Right"),children:"?"}),e.jsx("span",{className:"nice-doc-editor__sep"}),e.jsx(Se.NiceButton,{size:"sm",variant:"ghost",onClick:()=>H(g,{indent:Math.min((u[g]?.indent??0)+1,4)}),title:f("docEditor.indent","Indent (Tab)"),children:"??"}),e.jsx(Se.NiceButton,{size:"sm",variant:"ghost",onClick:()=>H(g,{indent:Math.max((u[g]?.indent??0)-1,0)}),title:f("docEditor.outdent","Outdent (Shift+Tab)"),children:"??"}),e.jsx("span",{className:"nice-doc-editor__sep"}),e.jsx(Se.NiceColorPicker,{size:"sm",label:"",value:u[g]?.color??"var(--nice-text-primary, #000000)",onChange:m=>H(g,{color:m}),title:"Text color"}),e.jsx(Se.NiceColorPicker,{size:"sm",label:"",value:u[g]?.bgColor??"var(--nice-bg-primary, #ffffff)",onChange:m=>H(g,{bgColor:m}),title:"Block background"}),e.jsx("span",{className:"nice-doc-editor__sep"}),e.jsx(Se.NiceButton,{size:"sm",variant:u[g]?.locked?"primary":"ghost",onClick:()=>H(g,{locked:!u[g]?.locked}),title:f("docEditor.lock","Lock/Unlock block"),children:"??"}),e.jsx(Se.NiceButton,{size:"sm",variant:"ghost",onClick:()=>ge(g),title:f("docEditor.duplicate","Duplicate (Ctrl+D)"),children:"?"}),e.jsx(Se.NiceButton,{size:"sm",variant:"ghost",onClick:()=>le(g),title:f("docEditor.delete","Delete block"),children:"??"}),e.jsx(Se.NiceButton,{size:"sm",variant:"ghost",onClick:()=>Y(g),title:f("docEditor.addBlock","Add block"),children:"+"}),k&&e.jsx(Se.NiceButton,{size:"sm",variant:b?"primary":"ghost",onClick:()=>s(m=>!m),title:f("docEditor.find","Find & Replace (Ctrl+F)"),children:"??"}),e.jsx(Se.NiceButton,{size:"sm",variant:"ghost",onClick:()=>A(m=>!m),title:f("docEditor.shortcuts","Keyboard shortcuts"),children:"?"}),_&&e.jsx(Se.NiceButton,{size:"sm",variant:"ghost",onClick:Ne,children:f("docEditor.export","Export HTML")})]}),e.jsx("input",{ref:T,type:"file",accept:"image/*,video/*",style:{display:"none"},onChange:Ve}),b&&e.jsxs("div",{className:"nice-doc-editor__find-bar",style:{display:"flex",gap:4,alignItems:"center",padding:"4px 8px",background:"var(--nice-doc-find-bg, #f8f9fa)",borderBottom:"1px solid var(--nice-border-color, #ddd)"},children:[e.jsx(Fe.NiceTextInput,{size:"sm",placeholder:f("docEditor.findPlaceholder","Find..."),value:$,onChange:M,style:{flex:1,maxWidth:200}}),e.jsx(Fe.NiceTextInput,{size:"sm",placeholder:f("docEditor.replacePlaceholder","Replace..."),value:l,onChange:c,style:{flex:1,maxWidth:200}}),e.jsx(Se.NiceButton,{size:"sm",variant:"ghost",onClick:Oe,title:f("docEditor.findPrev","Previous"),children:"?"}),e.jsx(Se.NiceButton,{size:"sm",variant:"ghost",onClick:Te,title:f("docEditor.findNext","Next"),children:"?"}),e.jsx(Se.NiceButton,{size:"sm",variant:"ghost",onClick:qe,title:f("docEditor.replaceOne","Replace"),disabled:a,children:f("docEditor.replace","Replace")}),e.jsx(Se.NiceButton,{size:"sm",variant:"ghost",onClick:Ye,title:f("docEditor.replaceAll","Replace all"),disabled:a,children:f("docEditor.replaceAllBtn","All")}),e.jsx("span",{style:{fontSize:"0.75em",color:"var(--nice-text-muted, #666)"},children:d.length>0?`${E+1}/${d.length}`:"0/0"}),e.jsx(Se.NiceButton,{size:"sm",variant:"ghost",onClick:()=>s(!1),children:"?"})]}),B&&e.jsx("div",{className:"nice-doc-editor__shortcuts-overlay",style:{position:"fixed",inset:0,background:"var(--nice-overlay-40, rgba(0, 0, 0, 0.4))",zIndex:9999,display:"flex",alignItems:"center",justifyContent:"center"},onClick:()=>A(!1),children:e.jsxs("div",{style:{background:"var(--nice-bg-primary, #fff)",borderRadius:8,padding:24,maxWidth:420,width:"90%",boxShadow:"0 8px 32px var(--nice-overlay-20, rgba(0, 0, 0, 0.2))"},onClick:m=>m.stopPropagation(),children:[e.jsx("h3",{style:{margin:"0 0 12px"},children:f("docEditor.shortcutsTitle","Keyboard Shortcuts")}),e.jsx("table",{style:{width:"100%",fontSize:"0.875em",borderCollapse:"collapse"},children:e.jsx("tbody",{children:[["Ctrl+B",f("docEditor.bold","Bold")],["Ctrl+I",f("docEditor.italic","Italic")],["Ctrl+U",f("docEditor.underline","Underline")],["Ctrl+E",f("docEditor.strikethrough","Strikethrough")],["Ctrl+D",f("docEditor.duplicate","Duplicate block")],["Ctrl+Z",f("docEditor.undo","Undo")],["Ctrl+Y",f("docEditor.redo","Redo")],["Ctrl+F",f("docEditor.find","Find & Replace")],["Enter",f("docEditor.newBlock","New block")],["Backspace",f("docEditor.deleteEmpty","Delete empty block")],["Alt+?",f("docEditor.moveUp","Move block up")],["Alt+?",f("docEditor.moveDown","Move block down")],["Tab",f("docEditor.indent","Indent")],["Shift+Tab",f("docEditor.outdent","Outdent")],["/",f("docEditor.slashCmd","Slash commands")]].map(([m,G])=>e.jsxs("tr",{style:{borderBottom:"1px solid var(--nice-border-color, #eee)"},children:[e.jsx("td",{style:{padding:"4px 8px",fontFamily:"monospace",fontWeight:600},children:m}),e.jsx("td",{style:{padding:"4px 8px"},children:G})]},m))})}),e.jsx("div",{style:{textAlign:"right",marginTop:12},children:e.jsx(Se.NiceButton,{size:"sm",variant:"ghost",onClick:()=>A(!1),children:f("docEditor.close","Close")})})]})}),e.jsxs("div",{style:{display:"flex",gap:0},children:[L&&Ke.length>0&&e.jsxs("nav",{className:"nice-doc-editor__toc",style:{width:200,minWidth:160,borderRight:"1px solid var(--nice-border-color, #eee)",padding:"8px 4px",fontSize:"0.8em",overflowY:"auto",maxHeight:500},children:[e.jsx("div",{style:{fontWeight:600,padding:"4px 8px",fontSize:"0.75em",textTransform:"uppercase",color:"var(--nice-text-muted, #999)"},children:f("docEditor.toc","Contents")}),Ke.map(m=>e.jsx("div",{style:{padding:"3px 8px",paddingLeft:8+(m.level-1)*12,cursor:"pointer",borderRadius:4,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",background:m.idx===g?"var(--nice-primary-bg, #e8f0fe)":void 0},onClick:()=>P(m.idx),title:m.text,children:m.text||f("docEditor.untitled","Untitled")},m.idx))]}),e.jsx("div",{className:"nice-doc-editor__body",style:{flex:1},children:u.map((m,G)=>e.jsxs("div",{className:`nice-doc-editor__block nice-doc-editor__block--${m.type} ${G===g?"nice-doc-editor__block--focused":""} ${Z===G?"nice-doc-editor__block--drop-target":""} ${m.locked?"nice-doc-editor__block--locked":""}`,onClick:()=>P(G),onContextMenu:oe=>Ae(oe,G),draggable:!a&&!m.locked,onDragStart:oe=>je(oe,G),onDragOver:oe=>we(oe,G),onDrop:oe=>Re(oe,G),onDragEnd:()=>{re(null),de(null)},style:{opacity:xe===G?.4:1,marginLeft:(m.indent??0)*24},children:[!a&&!m.locked&&e.jsx("div",{className:"nice-doc-editor__block-handle",title:f("docEditor.drag","Drag to reorder"),children:"?"}),m.locked&&e.jsx("span",{className:"nice-doc-editor__lock-icon",style:{position:"absolute",top:2,right:4,fontSize:"0.7em",opacity:.5},children:"??"}),m.type==="divider"?e.jsx("hr",{className:"nice-doc-editor__divider"}):m.type==="pageBreak"?e.jsxs("div",{className:"nice-doc-editor__page-break",style:{borderTop:"2px dashed var(--nice-border, #ccc)",textAlign:"center",padding:4,fontSize:"0.75em",color:"var(--nice-text-muted, #999)"},children:["� ",f("docEditor.pageBreak","Page Break")," �"]}):m.type==="image"||m.type==="video"?e.jsx("div",{className:"nice-doc-editor__media-block",children:m.src?m.type==="image"?e.jsx("img",{src:m.src,alt:m.alt??"",className:"nice-doc-editor__image",style:{maxWidth:"100%"}}):e.jsx("video",{src:m.src,controls:!0,className:"nice-doc-editor__video",style:{maxWidth:"100%"}}):!a&&e.jsxs("div",{style:{display:"flex",gap:4,alignItems:"center"},children:[e.jsx(Fe.NiceTextInput,{size:"sm",placeholder:f("docEditor.mediaUrl",m.type==="image"?"Image URL":"Video URL"),value:m.src??"",onChange:oe=>H(G,{src:oe})}),z&&e.jsx(Se.NiceButton,{size:"sm",variant:"ghost",onClick:()=>{P(G),T.current?.click()},children:"??"})]})}):m.type==="callout"?e.jsxs("div",{className:"nice-doc-editor__callout",style:{display:"flex",gap:8,padding:"8px 12px",background:m.bgColor??"#f0f7ff",borderRadius:4,color:m.color},children:[e.jsx("span",{style:{fontSize:"1.2em"},children:m.icon??"??"}),e.jsx("div",{ref:oe=>{oe&&te.current.set(m.id,oe)},className:"nice-doc-editor__content",contentEditable:!a&&!m.locked,suppressContentEditableWarning:!0,onInput:oe=>me(oe,G),onFocus:()=>P(G),onKeyDown:oe=>se(oe,G),"data-placeholder":f("docEditor.calloutPlaceholder","Callout text..."),role:"textbox","aria-multiline":"true",style:{flex:1,outline:"none"},children:m.content})]}):m.type==="toggle"?e.jsxs("details",{open:m.open,className:"nice-doc-editor__toggle",onToggle:oe=>H(G,{open:oe.target.open}),children:[e.jsx("summary",{style:{cursor:"pointer",fontWeight:500},children:m.content.split(`
15
+ `)[0]||f("docEditor.toggleTitle","Toggle")}),e.jsx("div",{ref:oe=>{oe&&te.current.set(m.id,oe)},className:"nice-doc-editor__content",contentEditable:!a&&!m.locked,suppressContentEditableWarning:!0,onInput:oe=>me(oe,G),onFocus:()=>P(G),onKeyDown:oe=>se(oe,G),role:"textbox","aria-multiline":"true",style:{padding:"4px 0"},children:m.content.split(`
16
+ `).slice(1).join(`
17
+ `)})]}):m.type==="code"?e.jsxs("div",{className:"nice-doc-editor__code-block",style:{position:"relative"},children:[!a&&e.jsx(Fe.NiceTextInput,{size:"sm",value:m.language??"",onChange:oe=>H(G,{language:oe}),placeholder:"Language",style:{position:"absolute",top:4,right:4,width:80,opacity:.7}}),e.jsx("pre",{ref:oe=>{oe&&te.current.set(m.id,oe)},className:"nice-doc-editor__content",contentEditable:!a&&!m.locked,suppressContentEditableWarning:!0,onInput:oe=>me(oe,G),onFocus:()=>P(G),onKeyDown:oe=>se(oe,G),role:"textbox","aria-multiline":"true",style:{fontFamily:"monospace",background:"var(--nice-bg-elevated, #1e1e1e)",color:"var(--nice-text-secondary, #d4d4d4)",padding:12,borderRadius:4,overflow:"auto"},children:m.content})]}):e.jsxs("div",{style:{position:"relative"},children:[e.jsx("div",{ref:oe=>{oe&&te.current.set(m.id,oe)},className:"nice-doc-editor__content",contentEditable:!a&&!m.locked,suppressContentEditableWarning:!0,style:{textAlign:m.align,fontWeight:m.bold?"bold":void 0,fontStyle:m.italic?"italic":void 0,textDecoration:[m.underline?"underline":"",m.strikethrough?"line-through":""].filter(Boolean).join(" ")||void 0,color:m.color,backgroundColor:m.bgColor},onInput:oe=>me(oe,G),onFocus:()=>P(G),onKeyDown:oe=>se(oe,G),"data-placeholder":!m.content&&x?x:void 0,role:"textbox","aria-multiline":"true",children:m.content}),ue&&G===g&&ye.length>0&&e.jsx("ul",{className:"nice-doc-editor__slash-menu",style:{position:"absolute",left:0,top:"100%",zIndex:100,background:"var(--nice-bg-primary, #fff)",border:"1px solid var(--nice-border-color, #ddd)",borderRadius:6,boxShadow:"0 4px 16px var(--nice-overlay-12, rgba(0, 0, 0, 0.12))",listStyle:"none",margin:0,padding:4,minWidth:180,maxHeight:240,overflow:"auto"},children:ye.map((oe,Ce)=>e.jsxs("li",{className:Ce===_e?"nice-doc-editor__slash-item--active":"",style:{padding:"6px 10px",cursor:"pointer",borderRadius:4,display:"flex",gap:8,alignItems:"center",background:Ce===_e?"var(--nice-primary-bg, #e8f0fe)":void 0},onMouseDown:$e=>{$e.preventDefault(),K(oe)},onMouseEnter:()=>he(Ce),children:[e.jsx("span",{style:{width:24,textAlign:"center"},children:oe.icon}),e.jsx("span",{children:oe.label})]},`${oe.type}-${oe.label}`))})]})]},m.id))})]}),pe&&e.jsxs("div",{className:"nice-doc-editor__ctx-menu",style:{position:"fixed",left:pe.x,top:pe.y,zIndex:1e3,background:"var(--nice-bg-primary, #fff)",border:"1px solid var(--nice-border-color, #ddd)",borderRadius:6,boxShadow:"0 4px 16px var(--nice-overlay-12, rgba(0, 0, 0, 0.12))",padding:4,minWidth:160},children:[e.jsx("div",{style:{padding:"6px 12px",cursor:"pointer"},onClick:()=>{ge(pe.idx),Me(null)},children:"? Duplicate"}),e.jsx("div",{style:{padding:"6px 12px",cursor:"pointer"},onClick:()=>{Y(pe.idx),Me(null)},children:"+ Insert below"}),e.jsx("div",{style:{padding:"6px 12px",cursor:"pointer"},onClick:()=>{F(pe.idx,-1),Me(null)},children:"? Move up"}),e.jsx("div",{style:{padding:"6px 12px",cursor:"pointer"},onClick:()=>{F(pe.idx,1),Me(null)},children:"? Move down"}),e.jsx("div",{style:{padding:"6px 12px",cursor:"pointer"},onClick:()=>{H(pe.idx,{locked:!u[pe.idx]?.locked}),Me(null)},children:u[pe.idx]?.locked?"?? Unlock":"?? Lock"}),e.jsx("hr",{style:{margin:"2px 0",border:"none",borderTop:"1px solid var(--nice-border-color, #eee)"}}),e.jsx("div",{style:{padding:"6px 12px",cursor:"pointer",color:"var(--nice-danger-dark, #d32f2f)"},onClick:()=>{le(pe.idx),Me(null)},children:"?? Delete"})]}),q&&ze&&e.jsxs("div",{className:"nice-doc-editor__footer",style:{padding:"4px 12px",fontSize:"0.75em",color:"var(--nice-text-muted, #666)",borderTop:"1px solid var(--nice-border-color, #eee)",display:"flex",gap:16},children:[e.jsxs("span",{children:[ze.words," ",f("docEditor.words","words")]}),e.jsxs("span",{children:[ze.chars," ",f("docEditor.chars","characters")]}),e.jsxs("span",{children:[u.length," ",f("docEditor.blocks","blocks")]}),e.jsxs("span",{children:["~",ze.readingTime," ",f("docEditor.readingTime","min read")]})]})]})});jn.displayName="NiceDocumentEditor";const Ni=[],bn=n.forwardRef(({label:t,helperText:i,error:a,disabled:o,readOnly:r,size:h="md",id:x,className:_,style:z,accessMode:C,pages:X=Ni,selectedPageId:q,content:L="",contentFormat:k="html",editing:J=!1,onPageSelect:ne,onContentChange:ee,onSave:ie,onCreatePage:I,onDeletePage:j,onEditToggle:R,onVersionHistory:f,sidebarWidth:w=260,sidebarCollapsed:U=!1,onSidebarToggle:u,searchable:g=!0,onSearch:P},te)=>{const T=y.Dc(C,x),b=T==="hidden";T==="disabled"&&(o=!0),T==="readOnly"&&(r=!0);const{t:s}=y.Gt(),$=y.bc(x),[M,l]=n.useState(""),[c,d]=n.useState(""),[p,E]=n.useState(!1),v=n.useMemo(()=>{const N=D=>{for(const S of D){if(S.id===q)return S;if(S.children){const ae=N(S.children);if(ae)return ae}}};return N(X)},[X,q]),B=n.useCallback(N=>{l(N),P?.(N)},[P]),A=n.useCallback(()=>{c.trim()&&(I?.(q??null,c.trim()),d(""),E(!1))},[c,q,I]),V=(N,D=0)=>e.jsx("ul",{className:"nice-wiki__tree",style:{paddingLeft:D>0?16:0},children:N.map(S=>e.jsxs("li",{className:"nice-wiki__tree-item",children:[e.jsxs("div",{className:`nice-wiki__tree-node${S.id===q?" nice-wiki__tree-node--active":""}${S.isDraft?" nice-wiki__tree-node--draft":""}`,onClick:()=>ne?.(S),role:"treeitem","aria-selected":S.id===q,children:[e.jsx("span",{className:"nice-wiki__tree-icon",children:e.jsx(y.oa,{name:S.children?.length?"folder":"file",size:14})}),e.jsx("span",{className:"nice-wiki__tree-title",children:S.title}),S.isDraft&&e.jsx("span",{className:"nice-wiki__tree-draft",children:s("draft","Draft")})]}),S.children&&S.children.length>0&&V(S.children,D+1)]},S.id))});return b?null:e.jsxs("div",{ref:te,id:$,className:`nice-wiki nice-size-${h}${_?` ${_}`:""}${o?" nice-disabled":""}`,style:z,children:[!U&&e.jsxs("aside",{className:"nice-wiki__sidebar",style:{width:w},children:[e.jsxs("div",{className:"nice-wiki__sidebar-header",children:[e.jsx("span",{className:"nice-wiki__sidebar-title",children:t??s("wiki","Wiki")}),u&&e.jsx("button",{type:"button",className:"nice-wiki__sidebar-toggle",onClick:()=>u(!0),"aria-label":s("collapseSidebar","Collapse sidebar"),children:e.jsx(y.oa,{name:"chevron-left",size:16})})]}),g&&e.jsx("input",{type:"text",className:"nice-input nice-wiki__search",value:M,onChange:N=>B(N.target.value),placeholder:s("searchPages","Search pages…"),disabled:o}),e.jsx("div",{className:"nice-wiki__page-tree",role:"tree",children:V(X)}),I&&!r&&e.jsx("div",{className:"nice-wiki__sidebar-footer",children:p?e.jsxs("div",{className:"nice-wiki__create-form",children:[e.jsx("input",{type:"text",className:"nice-input",value:c,onChange:N=>d(N.target.value),placeholder:s("pageTitle","Page title"),onKeyDown:N=>N.key==="Enter"&&A(),disabled:o}),e.jsx("button",{type:"button",disabled:o||!c.trim(),onClick:A,"aria-label":s("create","Create"),children:e.jsx(y.oa,{name:"check",size:14})}),e.jsx("button",{type:"button",onClick:()=>E(!1),"aria-label":s("cancel","Cancel"),children:e.jsx(y.oa,{name:"close",size:14})})]}):e.jsxs("button",{type:"button",className:"nice-wiki__add-page",onClick:()=>E(!0),disabled:o,children:[e.jsx(y.oa,{name:"plus",size:14})," ",s("newPage","New page")]})})]}),U&&u&&e.jsx("button",{type:"button",className:"nice-wiki__sidebar-expand",onClick:()=>u(!1),"aria-label":s("expandSidebar","Expand sidebar"),children:e.jsx(y.oa,{name:"chevron-right",size:16})}),e.jsx("main",{className:"nice-wiki__content",children:v?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"nice-wiki__content-header",children:[e.jsx("h1",{className:"nice-wiki__page-title",children:v.title}),e.jsxs("div",{className:"nice-wiki__content-actions",children:[R&&!r&&e.jsx("button",{type:"button",disabled:o,onClick:()=>R(!J),children:J?s("preview","Preview"):s("edit","Edit")}),f&&e.jsx("button",{type:"button",disabled:o,onClick:()=>f(v.id),children:s("history","History")}),j&&!r&&e.jsx("button",{type:"button",className:"nice-btn--danger",disabled:o,onClick:()=>j(v.id),children:s("delete","Delete")})]})]}),v.updatedAt&&e.jsxs("div",{className:"nice-wiki__page-meta",children:[v.updatedBy&&e.jsxs("span",{children:[s("lastEditedBy","Last edited by")," ",v.updatedBy]}),e.jsx("span",{children:new Date(v.updatedAt).toLocaleDateString()})]}),J?e.jsxs("div",{className:"nice-wiki__editor",children:[e.jsx("textarea",{className:"nice-wiki__editor-textarea",value:L,onChange:N=>ee?.(N.target.value),disabled:o}),ie&&e.jsx("button",{type:"button",className:"nice-btn nice-btn--primary",disabled:o,onClick:()=>ie(v.id,L),children:s("save","Save")})]}):e.jsx("div",{className:"nice-wiki__viewer",children:k==="html"?e.jsx("div",{className:"nice-wiki__html",dangerouslySetInnerHTML:{__html:y.lc(L)}}):e.jsx("pre",{className:"nice-wiki__markdown",children:L})})]}):e.jsx("div",{className:"nice-wiki__empty",children:e.jsx("p",{children:s("selectPage","Select a page from the sidebar or create a new one.")})})}),i&&e.jsx("span",{className:"nice-helper-text",children:i}),a&&typeof a=="string"&&e.jsx("span",{className:"nice-error-text",children:a})]})});bn.displayName="NiceWiki";const Ci=n.forwardRef(function(i,a){const{enableAI:o=!0,aiModel:r,enableInlineCompletion:h=!0,completionDelay:x=500,enableExplain:_=!0,enableRefactor:z=!0,enableGenerate:C=!0,systemPrompt:X,onExplain:q,onRefactor:L,showAIToolbar:k=!0,aiShortcutKey:J="Ctrl",language:ne="plaintext",value:ee,onChange:ie,...I}=i,j=n.useRef(null),[R,f]=n.useState(null),[w,U]=n.useState(!1),[u,g]=n.useState(""),[P,te]=n.useState(!1),[T,b]=n.useState(""),[s,$]=n.useState(""),[M,l]=n.useState(""),c=n.useRef(void 0),{t:d}=y.Gt(),p=y.he(),{complete:E,explain:v,refactor:B,generateFromComment:A,isLoading:V}=y.wd({language:ne,model:r}),N=o&&p.isConfigured,D=n.useCallback(async()=>{if(!N||!h||!j.current||!j.current.getEditor())return;const ye=j.current.getCursorPosition(),re=j.current.getValue().split(`
18
+ `),Z=re.slice(0,ye.lineNumber-1),de=re[ye.lineNumber-1]||"",O=[...Z,de.slice(0,ye.column-1)].join(`
19
+ `),H=[de.slice(ye.column-1),...re.slice(ye.lineNumber)].join(`
20
+ `);try{const Y=await E(O,H);Y&&f({lineNumber:ye.lineNumber,column:ye.column,text:Y})}catch{}},[N,h,E]),S=n.useCallback(async()=>{if(!N||!_||!j.current)return"";const he=j.current.getSelection();if(!he)return"";l(he),U(!0),g("");try{const ye=await v(he);return g(ye),q?.(he,ye),ye}catch{return g(d("codeEditorAI.explanationFailed","Failed to explain code")),""}},[N,_,v,q,d]),ae=n.useCallback(async he=>{if(!N||!z||!j.current)return"";const ye=j.current.getSelection();if(!ye)return"";try{const xe=await B(ye,he);return $(xe),L?.(ye,xe),xe}catch{return""}},[N,z,B,L]),ue=n.useCallback(async()=>{if(!N||!C||!j.current)return;const he=j.current.getCursorPosition(),xe=j.current.getValue().split(`
21
+ `);let re="";for(let Z=he.lineNumber-1;Z>=0&&Z>=he.lineNumber-3;Z--){const de=xe[Z]?.trim()||"";if(de.startsWith("//")||de.startsWith("#")||de.startsWith("/*")||de.startsWith("*")){re=de.replace(/^\/\/\s*|^#\s*|^\/\*\s*|\*\/\s*$|^\*\s*/g,"").trim();break}}if(re)try{const Z=await A(re);Z&&j.current&&j.current.insertText(`
22
+ `+Z)}catch{}},[N,C,A]),ce=n.useCallback(()=>{!R||!j.current||(j.current.insertText(R.text),f(null))},[R]),be=n.useCallback(()=>{f(null)},[]),ve=n.useCallback(he=>{i.onCursorPositionChange?.(he),!(!N||!h)&&(c.current&&clearTimeout(c.current),f(null),c.current=setTimeout(()=>{D()},x))},[i.onCursorPositionChange,N,h,x,D]);n.useEffect(()=>{if(!j.current?.getEditor()||!N)return;const ye=xe=>{if(J==="Ctrl"&&xe.ctrlKey||J==="Alt"&&xe.altKey||J==="Meta"&&xe.metaKey){if(xe.key===" "&&h&&(xe.preventDefault(),D()),xe.key==="e"&&_&&(xe.preventDefault(),S()),xe.key==="r"&&z){xe.preventDefault();const Z=j.current?.getSelection();Z&&(l(Z),te(!0))}xe.key==="g"&&C&&(xe.preventDefault(),ue())}xe.key==="Tab"&&R&&(xe.preventDefault(),ce()),xe.key==="Escape"&&R&&be()};return window.addEventListener("keydown",ye),()=>window.removeEventListener("keydown",ye)},[N,J,h,_,z,C,D,S,ue,R,ce,be]),n.useEffect(()=>()=>{c.current&&clearTimeout(c.current)},[]);const _e=n.useCallback(()=>{if(!s||!j.current)return;const he=j.current.getEditor();if(he?.executeEdits&&he?.getSelection){const ye=he.getSelection();he.executeEdits("ai-refactor",[{range:ye,text:s}])}te(!1),$(""),b("")},[s]);return n.useImperativeHandle(a,()=>({...j.current,getEditor:()=>j.current?.getEditor(),getMonaco:()=>j.current?.getMonaco(),focus:()=>j.current?.focus(),getValue:()=>j.current?.getValue()||"",setValue:he=>j.current?.setValue(he),getSelection:()=>j.current?.getSelection()||"",insertText:he=>j.current?.insertText(he),formatDocument:()=>j.current?.formatDocument(),goToLine:(he,ye)=>j.current?.goToLine(he,ye),findReplace:()=>j.current?.findReplace(),undo:()=>j.current?.undo(),redo:()=>j.current?.redo(),getCursorPosition:()=>j.current?.getCursorPosition()||{lineNumber:1,column:1},setMarkers:he=>j.current?.setMarkers(he),triggerCompletion:D,explainSelection:S,refactorSelection:ae,generateFromComment:ue,acceptCompletion:ce,dismissCompletion:be})),e.jsxs("div",{className:"nice-code-editor-ai","data-testid":i["data-testid"],children:[k&&N&&e.jsxs("div",{className:"nice-code-editor-ai__toolbar",children:[e.jsxs("div",{className:"nice-code-editor-ai__toolbar-left",children:[e.jsx("span",{className:"nice-code-editor-ai__toolbar-badge",children:"AI"}),V&&e.jsx("span",{className:"nice-code-editor-ai__loading",children:d("codeEditorAI.loading","Thinking...")})]}),e.jsxs("div",{className:"nice-code-editor-ai__toolbar-right",children:[h&&e.jsxs("button",{type:"button",className:"nice-code-editor-ai__toolbar-btn",onClick:()=>D(),disabled:V,title:`${d("codeEditorAI.complete","Complete")} (${J}+Space)`,children:[e.jsx(y.oa,{name:"lightbulb",size:14})," ",d("codeEditorAI.complete","Complete")]}),_&&e.jsxs("button",{type:"button",className:"nice-code-editor-ai__toolbar-btn",onClick:()=>S(),disabled:V,title:`${d("codeEditorAI.explain","Explain")} (${J}+E)`,children:[e.jsx(y.oa,{name:"book",size:14})," ",d("codeEditorAI.explain","Explain")]}),z&&e.jsxs("button",{type:"button",className:"nice-code-editor-ai__toolbar-btn",onClick:()=>{const he=j.current?.getSelection();he&&(l(he),te(!0))},disabled:V,title:`${d("codeEditorAI.refactor","Refactor")} (${J}+R)`,children:[e.jsx(y.oa,{name:"settings",size:14})," ",d("codeEditorAI.refactor","Refactor")]}),C&&e.jsxs("button",{type:"button",className:"nice-code-editor-ai__toolbar-btn",onClick:()=>ue(),disabled:V,title:`${d("codeEditorAI.generate","Generate")} (${J}+G)`,children:[e.jsx(y.oa,{name:"zap",size:14})," ",d("codeEditorAI.generate","Generate")]})]})]}),e.jsxs("div",{className:"nice-code-editor-ai__editor-wrapper",children:[e.jsx(_t.NiceCodeEditor,{ref:j,value:ee,onChange:ie,language:ne,onCursorPositionChange:ve,...I}),R&&e.jsxs("div",{className:"nice-code-editor-ai__ghost-text",style:{top:`calc(${(R.lineNumber-1)*19}px + 4px)`,left:`calc(${(R.column-1)*7.8}px + 60px)`},children:[e.jsx("span",{className:"nice-code-editor-ai__ghost-text-content",children:R.text}),e.jsxs("span",{className:"nice-code-editor-ai__ghost-text-hint",children:["Tab ",d("codeEditorAI.toAccept","to accept")]})]})]}),w&&e.jsxs("div",{className:"nice-code-editor-ai__panel nice-code-editor-ai__panel--explain",children:[e.jsxs("div",{className:"nice-code-editor-ai__panel-header",children:[e.jsxs("h4",{children:[e.jsx(y.oa,{name:"book",size:16})," ",d("codeEditorAI.explanation","Explanation")]}),e.jsx("button",{type:"button",className:"nice-code-editor-ai__panel-close",onClick:()=>U(!1),"aria-label":d("codeEditorAI.close","Close"),children:e.jsx(y.oa,{name:"close",size:14})})]}),e.jsx("div",{className:"nice-code-editor-ai__panel-body",children:V?e.jsx("div",{className:"nice-code-editor-ai__panel-loading",children:d("codeEditorAI.analyzing","Analyzing code...")}):e.jsxs("div",{className:"nice-code-editor-ai__explanation",children:[e.jsx("pre",{className:"nice-code-editor-ai__code-preview",children:M}),e.jsx("div",{className:"nice-code-editor-ai__explanation-text",children:u||d("codeEditorAI.noExplanation","Select code and click Explain")})]})})]}),P&&e.jsxs("div",{className:"nice-code-editor-ai__panel nice-code-editor-ai__panel--refactor",children:[e.jsxs("div",{className:"nice-code-editor-ai__panel-header",children:[e.jsxs("h4",{children:[e.jsx(y.oa,{name:"settings",size:16})," ",d("codeEditorAI.refactorCode","Refactor Code")]}),e.jsx("button",{type:"button",className:"nice-code-editor-ai__panel-close",onClick:()=>{te(!1),$(""),b("")},"aria-label":d("codeEditorAI.close","Close"),children:e.jsx(y.oa,{name:"close",size:14})})]}),e.jsxs("div",{className:"nice-code-editor-ai__panel-body",children:[e.jsx("pre",{className:"nice-code-editor-ai__code-preview",children:M}),e.jsxs("div",{className:"nice-code-editor-ai__refactor-input",children:[e.jsx("input",{type:"text",placeholder:d("codeEditorAI.refactorInstruction",'Describe how to refactor (e.g., "extract function", "add error handling")'),value:T,onChange:he=>b(he.target.value),onKeyDown:he=>{he.key==="Enter"&&T&&ae(T)}}),e.jsx("button",{type:"button",className:"nice-code-editor-ai__refactor-btn",onClick:()=>ae(T),disabled:V||!T,children:V?d("codeEditorAI.refactoring","Refactoring..."):d("codeEditorAI.refactor","Refactor")})]}),s&&e.jsxs("div",{className:"nice-code-editor-ai__refactor-result",children:[e.jsx("h5",{children:d("codeEditorAI.refactoredCode","Refactored Code")}),e.jsx("pre",{className:"nice-code-editor-ai__code-preview nice-code-editor-ai__code-preview--result",children:s}),e.jsxs("div",{className:"nice-code-editor-ai__refactor-actions",children:[e.jsxs("button",{type:"button",className:"nice-code-editor-ai__refactor-apply",onClick:_e,children:[e.jsx(y.oa,{name:"check",size:14})," ",d("codeEditorAI.apply","Apply")]}),e.jsxs("button",{type:"button",className:"nice-code-editor-ai__refactor-discard",onClick:()=>{$(""),b("")},children:[e.jsx(y.oa,{name:"close",size:14})," ",d("codeEditorAI.discard","Discard")]})]})]})]})]})]})});function Si(t){const i=t instanceof Date?t:new Date(t),a=(o,r=2)=>String(o).padStart(r,"0");return`${a(i.getHours())}:${a(i.getMinutes())}:${a(i.getSeconds())}.${a(i.getMilliseconds(),3)}`}function $i(t){if(typeof t=="string")return t;try{return JSON.stringify(t,null,2)}catch{return String(t)}}const vn=n.forwardRef(function(i,a){const{entries:o,maxHeight:r=240,autoScroll:h=!0,showTimestamps:x=!0,levelFilter:_,onClear:z,title:C,emptyText:X="No output",clearLabel:q="Clear",fontFamily:L,className:k,style:J,id:ne,"data-testid":ee}=i,ie=n.useRef(null),I=n.useMemo(()=>{if(!_||_.length===0)return o;const f=new Set(_);return o.filter(w=>f.has(w.level??"log"))},[o,_]);n.useEffect(()=>{h&&ie.current&&(ie.current.scrollTop=ie.current.scrollHeight)},[I.length,h]);const j=!!C||!!z,R="nice-log-console"+(k?` ${k}`:"");return e.jsxs("div",{ref:a,id:ne,className:R,style:{...L?{fontFamily:L}:null,...J},"data-testid":ee,children:[j&&e.jsxs("div",{className:"nice-log-console__header",children:[e.jsx("span",{className:"nice-log-console__title",children:C}),z&&e.jsx("button",{type:"button",className:"nice-log-console__clear",onClick:z,"aria-label":q,children:q})]}),e.jsx("div",{ref:ie,className:"nice-log-console__body",style:{maxHeight:typeof r=="number"?`${r}px`:r},role:"log","aria-live":"polite","aria-relevant":"additions",children:I.length===0?e.jsx("div",{className:"nice-log-console__empty",children:X}):I.map((f,w)=>{const U=f.level??"log";return e.jsxs("div",{className:`nice-log-console__entry nice-log-console__entry--${U}`,children:[x&&f.timestamp!=null&&e.jsx("span",{className:"nice-log-console__time",children:Si(f.timestamp)}),e.jsx("span",{className:"nice-log-console__level",children:U}),f.source&&e.jsx("span",{className:"nice-log-console__source",children:f.source}),e.jsx("span",{className:"nice-log-console__message",children:f.message}),f.data!==void 0&&e.jsx("pre",{className:"nice-log-console__data",children:$i(f.data)})]},w)})})]})}),Ht="nice-log-console-styles";if(typeof document<"u"&&!document.getElementById(Ht)){const t=document.createElement("style");t.id=Ht,t.textContent=`
23
+ .nice-log-console {
24
+ display: flex;
25
+ flex-direction: column;
26
+ border: 1px solid var(--nice-border, #e0e0e0);
27
+ border-radius: var(--nice-radius-sm, 4px);
28
+ background: var(--nice-surface, #fff);
29
+ color: var(--nice-text-primary, #1f2937);
30
+ overflow: hidden;
31
+ font-family: 'Fira Code', 'Consolas', 'Monaco', monospace;
32
+ font-size: 12px;
33
+ line-height: 1.55;
34
+ }
35
+ .nice-log-console__header {
36
+ display: flex;
37
+ align-items: center;
38
+ justify-content: space-between;
39
+ gap: var(--nice-space-2, 8px);
40
+ padding: var(--nice-space-1, 4px) var(--nice-space-2, 8px);
41
+ border-bottom: 1px solid var(--nice-border, #e0e0e0);
42
+ background: var(--nice-bg-secondary, #f5f5f5);
43
+ }
44
+ .nice-log-console__title {
45
+ font-weight: 600;
46
+ font-size: 12px;
47
+ }
48
+ .nice-log-console__clear {
49
+ border: 1px solid var(--nice-border, #e0e0e0);
50
+ background: var(--nice-surface, #fff);
51
+ color: var(--nice-text-secondary, #6b7280);
52
+ border-radius: var(--nice-radius-sm, 4px);
53
+ padding: 2px 8px;
54
+ font: inherit;
55
+ font-size: 11px;
56
+ cursor: pointer;
57
+ }
58
+ .nice-log-console__clear:hover {
59
+ color: var(--nice-text-primary, #1f2937);
60
+ border-color: var(--nice-text-secondary, #9ca3af);
61
+ }
62
+ .nice-log-console__body {
63
+ flex: 1;
64
+ overflow: auto;
65
+ padding: var(--nice-space-2, 8px);
66
+ }
67
+ .nice-log-console__empty {
68
+ color: var(--nice-text-muted, #9ca3af);
69
+ font-style: italic;
70
+ padding: var(--nice-space-2, 8px) 0;
71
+ }
72
+ .nice-log-console__entry {
73
+ display: flex;
74
+ flex-wrap: wrap;
75
+ align-items: baseline;
76
+ gap: var(--nice-space-2, 8px);
77
+ padding: 1px 0;
78
+ white-space: pre-wrap;
79
+ word-break: break-word;
80
+ }
81
+ .nice-log-console__time {
82
+ color: var(--nice-text-muted, #9ca3af);
83
+ flex: 0 0 auto;
84
+ }
85
+ .nice-log-console__level {
86
+ flex: 0 0 auto;
87
+ text-transform: uppercase;
88
+ font-size: 10px;
89
+ font-weight: 700;
90
+ letter-spacing: 0.04em;
91
+ opacity: 0.8;
92
+ min-width: 38px;
93
+ }
94
+ .nice-log-console__source {
95
+ flex: 0 0 auto;
96
+ color: var(--nice-primary, #2563eb);
97
+ }
98
+ .nice-log-console__message {
99
+ flex: 1 1 auto;
100
+ }
101
+ .nice-log-console__data {
102
+ flex: 1 0 100%;
103
+ margin: 2px 0 4px;
104
+ padding: var(--nice-space-1, 4px) var(--nice-space-2, 8px);
105
+ background: var(--nice-bg-secondary, #f5f5f5);
106
+ border-radius: var(--nice-radius-sm, 4px);
107
+ overflow: auto;
108
+ font: inherit;
109
+ }
110
+ .nice-log-console__entry--info .nice-log-console__level { color: var(--nice-primary, #2563eb); }
111
+ .nice-log-console__entry--warn { color: var(--nice-warning-text, #92400e); }
112
+ .nice-log-console__entry--warn .nice-log-console__level { color: var(--nice-warning, #d97706); }
113
+ .nice-log-console__entry--error { color: var(--nice-danger, #dc2626); }
114
+ .nice-log-console__entry--error .nice-log-console__level { color: var(--nice-danger, #dc2626); }
115
+ .nice-log-console__entry--debug { color: var(--nice-text-muted, #9ca3af); }
116
+ .nice-log-console__entry--trace { color: var(--nice-text-disabled, #b8bfc9); }
117
+ .nice-log-console__entry--trace .nice-log-console__level { color: var(--nice-text-disabled, #b8bfc9); }
118
+ `,document.head.appendChild(t)}const Ei=[{target:".nice-script-runner",titleKey:"tutorial.scriptRunner.intro.title",title:"Script runner",contentKey:"tutorial.scriptRunner.intro.content",content:"Write a script and sample input, click Run, then inspect the result and captured logs below.",placement:"auto"}];function Ot(t){if(t===void 0)return"";if(typeof t=="string")return t;try{return JSON.stringify(t,null,2)}catch{return String(t)}}function Ft(t){const i=t.trim();if(i==="")return{value:void 0,error:null};try{return{value:JSON.parse(i),error:null}}catch(a){return{value:t,error:a instanceof Error?a.message:"Invalid JSON"}}}function Mi(t){if(typeof t=="string")return t;try{return JSON.stringify(t,null,2)}catch{return String(t)}}const Ri=n.forwardRef(function(i,a){const{value:o,defaultValue:r,onChange:h,language:x="javascript",onRun:_,input:z,onInputChange:C,showInputPanel:X,extraLibs:q,height:L=260,running:k,autoRun:J=!1,autoRunDelay:ne=600,layout:ee="vertical",runLabel:ie="Run",theme:I="auto",tutorial:j,className:R,style:f,id:w,"data-testid":U}=i,[u,g]=y.Vu({value:o,defaultValue:r,fallbackValue:"",onChange:h,componentName:"NiceScriptRunner"}),P=X??z!==void 0,[te,T]=n.useState(()=>Ot(z)),[b,s]=n.useState(null),[$,M]=n.useState(!1),[l,c]=n.useState(null),d=k??$,p=I==="light"?"vs":I==="dark"?"vs-dark":I;n.useEffect(()=>{T(Ot(z))},[z]);const E=n.useCallback(async()=>{const N=Ft(te),D=typeof performance<"u"?performance.now():Date.now();k===void 0&&M(!0);try{const S=await _(u,N.value),ae=S.durationMs??Math.round((typeof performance<"u"?performance.now():Date.now())-D);c({...S,durationMs:ae})}catch(S){c({ok:!1,error:S instanceof Error?S.message:String(S),durationMs:Math.round((typeof performance<"u"?performance.now():Date.now())-D)})}finally{k===void 0&&M(!1)}},[te,_,u,k]),v=n.useRef(E);v.current=E,n.useEffect(()=>{if(!J)return;const N=setTimeout(()=>{v.current()},ne);return()=>clearTimeout(N)},[J,ne,u,te]);const B=n.useCallback(N=>{T(N);const D=Ft(N);s(D.error),C?.(D.value)},[C]),A=typeof L=="number"?`${L}px`:L,V=`nice-script-runner nice-script-runner--${ee}`+(R?` ${R}`:"");return e.jsxs("div",{ref:a,id:w,className:V,style:f,"data-testid":U,children:[e.jsxs("div",{className:"nice-script-runner__toolbar",children:[e.jsxs("button",{type:"button",className:"nice-script-runner__run",onClick:()=>void E(),disabled:d,children:[d?"…":e.jsx(y.oa,{name:"play",size:14})," ",ie]}),l?.durationMs!=null&&e.jsxs("span",{className:"nice-script-runner__status",children:[e.jsx("span",{className:"nice-script-runner__badge nice-script-runner__badge--"+(l.ok?"ok":"error"),children:l.ok?"OK":"Failed"}),e.jsxs("span",{className:"nice-script-runner__duration",children:[l.durationMs," ms"]})]}),j&&e.jsx("span",{style:{marginLeft:"auto"},children:e.jsx(y.Ql,{steps:y.Yl(j,Ei)})})]}),e.jsxs("div",{className:"nice-script-runner__panes",children:[e.jsxs("div",{className:"nice-script-runner__editors",children:[e.jsx(_t.NiceCodeEditor,{value:u,onChange:g,language:x,theme:p,height:A,extraLibs:q,options:{minimap:!1}}),P&&e.jsxs("div",{className:"nice-script-runner__input",children:[e.jsxs("div",{className:"nice-script-runner__pane-label",children:["Input (JSON)",b&&e.jsxs("span",{className:"nice-script-runner__input-error",children:[" — ",b]})]}),e.jsx(_t.NiceCodeEditor,{value:te,onChange:B,language:"json",theme:p,height:120,options:{minimap:!1,lineNumbers:"off"}})]})]}),e.jsxs("div",{className:"nice-script-runner__output",children:[l?.error&&e.jsx("div",{className:"nice-script-runner__error",children:l.error}),l&&l.result!==void 0&&e.jsxs("div",{className:"nice-script-runner__result",children:[e.jsx("div",{className:"nice-script-runner__pane-label",children:"Result"}),e.jsx("pre",{className:"nice-script-runner__result-body",children:Mi(l.result)})]}),e.jsx(vn,{title:"Logs",entries:l?.logs??[],maxHeight:160,emptyText:"Run the script to see logs"})]})]})]})}),Yt="nice-script-runner-styles";if(typeof document<"u"&&!document.getElementById(Yt)){const t=document.createElement("style");t.id=Yt,t.textContent=`
119
+ .nice-script-runner {
120
+ display: flex;
121
+ flex-direction: column;
122
+ gap: var(--nice-space-2, 8px);
123
+ border: 1px solid var(--nice-border, #e0e0e0);
124
+ border-radius: var(--nice-radius-md, 6px);
125
+ padding: var(--nice-space-2, 8px);
126
+ background: var(--nice-surface, #fff);
127
+ }
128
+ .nice-script-runner__toolbar {
129
+ display: flex;
130
+ align-items: center;
131
+ gap: var(--nice-space-2, 8px);
132
+ }
133
+ .nice-script-runner__run {
134
+ border: 0;
135
+ background: var(--nice-primary, #2563eb);
136
+ color: var(--nice-text-inverse, #fff);
137
+ border-radius: var(--nice-radius-sm, 4px);
138
+ padding: 6px 14px;
139
+ font: inherit;
140
+ font-weight: 600;
141
+ cursor: pointer;
142
+ }
143
+ .nice-script-runner__run:disabled {
144
+ opacity: 0.6;
145
+ cursor: default;
146
+ }
147
+ .nice-script-runner__status {
148
+ display: inline-flex;
149
+ align-items: center;
150
+ gap: var(--nice-space-2, 8px);
151
+ font-size: 12px;
152
+ }
153
+ .nice-script-runner__badge {
154
+ padding: 1px 8px;
155
+ border-radius: 999px;
156
+ font-size: 11px;
157
+ font-weight: 700;
158
+ }
159
+ .nice-script-runner__badge--ok {
160
+ background: var(--nice-success-bg, #dcfce7);
161
+ color: var(--nice-success-text, #166534);
162
+ }
163
+ .nice-script-runner__badge--error {
164
+ background: var(--nice-danger-bg, #fee2e2);
165
+ color: var(--nice-danger-text, #991b1b);
166
+ }
167
+ .nice-script-runner__duration {
168
+ color: var(--nice-text-muted, #9ca3af);
169
+ }
170
+ .nice-script-runner__panes {
171
+ display: grid;
172
+ gap: var(--nice-space-2, 8px);
173
+ }
174
+ .nice-script-runner--horizontal .nice-script-runner__panes {
175
+ grid-template-columns: 1fr 1fr;
176
+ }
177
+ .nice-script-runner__editors,
178
+ .nice-script-runner__output {
179
+ display: flex;
180
+ flex-direction: column;
181
+ gap: var(--nice-space-2, 8px);
182
+ min-width: 0;
183
+ }
184
+ .nice-script-runner__pane-label {
185
+ font-size: 11px;
186
+ font-weight: 600;
187
+ text-transform: uppercase;
188
+ letter-spacing: 0.04em;
189
+ color: var(--nice-text-secondary, #6b7280);
190
+ }
191
+ .nice-script-runner__input-error {
192
+ color: var(--nice-danger, #dc2626);
193
+ text-transform: none;
194
+ font-weight: 400;
195
+ }
196
+ .nice-script-runner__error {
197
+ padding: var(--nice-space-2, 8px);
198
+ border-radius: var(--nice-radius-sm, 4px);
199
+ background: var(--nice-danger-bg, #fee2e2);
200
+ color: var(--nice-danger-text, #991b1b);
201
+ font-family: 'Fira Code', 'Consolas', 'Monaco', monospace;
202
+ font-size: 12px;
203
+ white-space: pre-wrap;
204
+ }
205
+ .nice-script-runner__result-body {
206
+ margin: 4px 0 0;
207
+ padding: var(--nice-space-2, 8px);
208
+ border: 1px solid var(--nice-border, #e0e0e0);
209
+ border-radius: var(--nice-radius-sm, 4px);
210
+ background: var(--nice-bg-secondary, #f9fafb);
211
+ max-height: 200px;
212
+ overflow: auto;
213
+ font-family: 'Fira Code', 'Consolas', 'Monaco', monospace;
214
+ font-size: 12px;
215
+ }
216
+ `,document.head.appendChild(t)}const Ti=[{target:".nice-key-value-editor",titleKey:"tutorial.keyValueEditor.intro.title",title:"Key/value editor",contentKey:"tutorial.keyValueEditor.intro.content",content:"Add key/value rows for headers, params, env vars or config; mask secret values, toggle rows on/off, and watch for duplicate keys.",placement:"auto"}],Ii=n.forwardRef(function(i,a){const{value:o,defaultValue:r,onChange:h,allowSecret:x=!1,allowToggle:_=!1,allowDescription:z=!1,keySuggestions:C,keyPlaceholder:X="Key",valuePlaceholder:q="Value",addLabel:L="Add",readOnly:k=!1,duplicateKeyWarning:J=!0,tutorial:ne,className:ee,style:ie,id:I,"data-testid":j}=i,[R,f]=y.Vu({value:o,defaultValue:r,fallbackValue:[],onChange:h,componentName:"NiceKeyValueEditor"}),w=n.useMemo(()=>`nice-kv-keys-${Math.random().toString(36).slice(2,9)}`,[]),U=n.useMemo(()=>{const T=new Map,b=new Set;if(J){for(const s of R){const $=s.key.trim();$!==""&&T.set($,(T.get($)??0)+1)}T.forEach((s,$)=>{s>1&&b.add($)})}return b},[R,J]),u=(T,b)=>{f(R.map((s,$)=>$===T?{...s,...b}:s))},g=T=>{f(R.filter((b,s)=>s!==T))},P=()=>{f([...R,{key:"",value:"",type:"text",enabled:!0}])},te="nice-key-value-editor"+(ee?` ${ee}`:"");return e.jsxs("div",{ref:a,id:I,className:te,style:{position:"relative",...ie},"data-testid":j,children:[e.jsx("span",{style:{position:"absolute",top:0,right:0,zIndex:20},children:e.jsx(y.Ql,{steps:y.Yl(ne,Ti)})}),C&&C.length>0&&e.jsx("datalist",{id:w,children:C.map(T=>e.jsx("option",{value:T},T))}),e.jsx("div",{className:"nice-key-value-editor__rows",children:R.map((T,b)=>{const s=T.type==="secret",$=T.key.trim()!==""&&U.has(T.key.trim()),M=_&&T.enabled===!1;return e.jsxs("div",{className:"nice-key-value-editor__row"+(M?" nice-key-value-editor__row--disabled":""),children:[_&&e.jsx("input",{type:"checkbox",className:"nice-key-value-editor__toggle",checked:T.enabled!==!1,onChange:l=>u(b,{enabled:l.target.checked}),disabled:k,"aria-label":"Enabled"}),e.jsx("input",{type:"text",className:"nice-key-value-editor__key"+($?" nice-key-value-editor__key--dup":""),value:T.key,list:C?w:void 0,placeholder:X,onChange:l=>u(b,{key:l.target.value}),readOnly:k,"aria-label":X,title:$?"Duplicate key":void 0}),e.jsx("input",{type:s?"password":"text",className:"nice-key-value-editor__value",value:T.value,placeholder:q,onChange:l=>u(b,{value:l.target.value}),readOnly:k,autoComplete:s?"new-password":"off","aria-label":q}),x&&e.jsx("button",{type:"button",className:"nice-key-value-editor__secret"+(s?" nice-key-value-editor__secret--on":""),onClick:()=>u(b,{type:s?"text":"secret"}),disabled:k,title:s?"Secret (click to reveal as text)":"Mark as secret","aria-pressed":s,"aria-label":"Toggle secret",children:e.jsx(y.oa,{name:"lock",size:16})}),z&&e.jsx("input",{type:"text",className:"nice-key-value-editor__desc",value:T.description??"",placeholder:"Description",onChange:l=>u(b,{description:l.target.value}),readOnly:k,"aria-label":"Description"}),!k&&e.jsx("button",{type:"button",className:"nice-key-value-editor__remove",onClick:()=>g(b),title:"Remove row","aria-label":"Remove row",children:e.jsx(y.oa,{name:"close",size:14})})]},T.id??b)})}),!k&&e.jsxs("button",{type:"button",className:"nice-key-value-editor__add",onClick:P,children:["+ ",L]})]})}),Kt="nice-key-value-editor-styles";if(typeof document<"u"&&!document.getElementById(Kt)){const t=document.createElement("style");t.id=Kt,t.textContent=`
217
+ .nice-key-value-editor {
218
+ display: flex;
219
+ flex-direction: column;
220
+ gap: var(--nice-space-2, 8px);
221
+ }
222
+ .nice-key-value-editor__rows {
223
+ display: flex;
224
+ flex-direction: column;
225
+ gap: var(--nice-space-1, 4px);
226
+ }
227
+ .nice-key-value-editor__row {
228
+ display: flex;
229
+ align-items: center;
230
+ gap: var(--nice-space-1, 4px);
231
+ }
232
+ .nice-key-value-editor__row--disabled {
233
+ opacity: 0.55;
234
+ }
235
+ .nice-key-value-editor__key,
236
+ .nice-key-value-editor__value,
237
+ .nice-key-value-editor__desc {
238
+ flex: 1 1 0;
239
+ min-width: 0;
240
+ padding: 6px 8px;
241
+ border: 1px solid var(--nice-border, #d1d5db);
242
+ border-radius: var(--nice-radius-sm, 4px);
243
+ background: var(--nice-bg, #fff);
244
+ color: var(--nice-text-primary, #1f2937);
245
+ font: inherit;
246
+ font-size: 13px;
247
+ }
248
+ .nice-key-value-editor__key {
249
+ flex-basis: 30%;
250
+ font-family: 'Fira Code', 'Consolas', 'Monaco', monospace;
251
+ }
252
+ .nice-key-value-editor__key--dup {
253
+ border-color: var(--nice-danger, #dc2626);
254
+ background: var(--nice-danger-bg, #fee2e2);
255
+ }
256
+ .nice-key-value-editor__key:focus,
257
+ .nice-key-value-editor__value:focus,
258
+ .nice-key-value-editor__desc:focus {
259
+ outline: none;
260
+ border-color: var(--nice-primary, #2563eb);
261
+ }
262
+ .nice-key-value-editor__toggle {
263
+ flex: 0 0 auto;
264
+ }
265
+ .nice-key-value-editor__secret,
266
+ .nice-key-value-editor__remove {
267
+ flex: 0 0 auto;
268
+ border: 1px solid var(--nice-border, #d1d5db);
269
+ background: var(--nice-surface, #fff);
270
+ border-radius: var(--nice-radius-sm, 4px);
271
+ padding: 5px 8px;
272
+ font-size: 13px;
273
+ line-height: 1;
274
+ cursor: pointer;
275
+ }
276
+ .nice-key-value-editor__secret--on {
277
+ border-color: var(--nice-warning, #d97706);
278
+ background: var(--nice-warning-bg, #fef3c7);
279
+ }
280
+ .nice-key-value-editor__remove:hover {
281
+ border-color: var(--nice-danger, #dc2626);
282
+ color: var(--nice-danger, #dc2626);
283
+ }
284
+ .nice-key-value-editor__add {
285
+ align-self: flex-start;
286
+ border: 1px dashed var(--nice-border, #d1d5db);
287
+ background: transparent;
288
+ color: var(--nice-primary, #2563eb);
289
+ border-radius: var(--nice-radius-sm, 4px);
290
+ padding: 5px 12px;
291
+ font: inherit;
292
+ font-size: 13px;
293
+ font-weight: 600;
294
+ cursor: pointer;
295
+ }
296
+ .nice-key-value-editor__add:hover {
297
+ background: var(--nice-bg-secondary, #f5f5f5);
298
+ }
299
+ `,document.head.appendChild(t)}const Ai=["street","streetNumber","apartment","city","postalCode","state","country"],dt={street:"Street",streetNumber:"Number",apartment:"Apt/Suite",city:"City",postalCode:"Postal Code",state:"State/Province",country:"Country"},_n=n.forwardRef(({label:t,helperText:i,error:a,required:o,disabled:r,readOnly:h,size:x="md",name:_,id:z,className:C,style:X,accessMode:q,value:L={},onChange:k,fields:J=Ai,placeholders:ne={},countries:ee,layout:ie="vertical",countryFirst:I=!1,validatePostalCode:j},R)=>{const f=y.Dc(q,z),w=f==="hidden";f==="disabled"&&(r=!0),f==="readOnly"&&(h=!0);const{t:U}=y.Gt(),u=y.bc(z),g=n.useCallback((b,s)=>{k?.({...L,[b]:s})},[L,k]),P=n.useMemo(()=>{if(j&&L.postalCode)return j(L.postalCode,L.country)},[j,L.postalCode,L.country]),te=n.useMemo(()=>I&&J.includes("country")?["country",...J.filter(b=>b!=="country")]:J,[J,I]),T=`nice-address nice-address--${ie} nice-size-${x}`;return w?null:e.jsxs("div",{ref:R,id:u,className:`${T}${C?` ${C}`:""}${a?" nice-error":""}${r?" nice-disabled":""}`,style:X,role:"group","aria-label":t??U("address","Address"),children:[t&&e.jsxs("label",{className:"nice-address__label",children:[t,o&&e.jsx("span",{className:"nice-required",children:"*"})]}),e.jsx("div",{className:"nice-address__fields",children:te.map(b=>b==="country"&&ee?e.jsxs("div",{className:`nice-address__field nice-address__field--${b}`,children:[e.jsx("label",{className:"nice-address__field-label",children:U(b,dt[b])}),e.jsxs("select",{className:"nice-input nice-select",value:L.country??"",onChange:s=>g("country",s.target.value),disabled:r,"aria-label":U(b,dt[b]),children:[e.jsx("option",{value:"",children:ne.country??U("selectCountry","— Select country —")}),ee.map(s=>e.jsx("option",{value:s.code,children:s.name},s.code))]})]},b):e.jsxs("div",{className:`nice-address__field nice-address__field--${b}`,children:[e.jsx("label",{className:"nice-address__field-label",children:U(b,dt[b])}),e.jsx("input",{className:`nice-input${b==="postalCode"&&P?" nice-input--error":""}`,type:"text",name:_?`${_}.${b}`:b,value:L[b]??"",onChange:s=>g(b,s.target.value),placeholder:ne[b]??"",disabled:r,readOnly:h,"aria-label":U(b,dt[b])}),b==="postalCode"&&P&&e.jsx("span",{className:"nice-error-text",children:P})]},b))}),i&&e.jsx("span",{className:"nice-helper-text",children:i}),a&&typeof a=="string"&&e.jsx("span",{className:"nice-error-text",children:a})]})});_n.displayName="NiceAddressInput";const Di={asset:"var(--nice-color-info, #5bc0de)",liability:"var(--nice-color-warning, #f0ad4e)",equity:"var(--nice-color-success, #5cb85c)",revenue:"var(--nice-color-primary, #337ab7)",expense:"var(--nice-color-error, #d9534f)"},kn=n.forwardRef(({label:t,helperText:i,error:a,required:o,disabled:r,readOnly:h,size:x="md",name:_,id:z,className:C,style:X,accessMode:q,value:L,onChange:k,accounts:J,treeView:ne=!1,placeholder:ee,searchable:ie=!0,showType:I=!0,onSearch:j},R)=>{const f=y.Dc(q,z),w=f==="hidden";f==="disabled"&&(r=!0),f==="readOnly"&&(h=!0);const{t:U}=y.Gt(),u=y.bc(z),[g,P]=n.useState(""),[te,T]=n.useState(!1),b=n.useMemo(()=>{const c=d=>{for(const p of d){if(p.code===L)return p;if(p.children){const E=c(p.children);if(E)return E}}};return c(J)},[J,L]),s=n.useMemo(()=>{const c=[],d=p=>{for(const E of p)c.push(E),E.children&&d(E.children)};return d(J),c},[J]),$=n.useMemo(()=>{if(!g)return s;const c=g.toLowerCase();return s.filter(d=>d.code.toLowerCase().includes(c)||d.name.toLowerCase().includes(c))},[s,g]),M=n.useCallback(c=>{P(c),j?.(c),T(!0)},[j]),l=n.useCallback(c=>{k?.(c.code,c),T(!1),P("")},[k]);return w?null:e.jsxs("div",{ref:R,id:u,className:`nice-account-picker nice-size-${x}${C?` ${C}`:""}${a?" nice-error":""}${r?" nice-disabled":""}`,style:X,children:[t&&e.jsxs("label",{className:"nice-account-picker__label",htmlFor:`${u}-input`,children:[t,o&&e.jsx("span",{className:"nice-required",children:"*"})]}),e.jsx("div",{className:"nice-account-picker__control",children:ie&&!h?e.jsx("input",{id:`${u}-input`,className:"nice-input",type:"text",value:te?g:b?`${b.code} — ${b.name}`:"",onChange:c=>M(c.target.value),onFocus:()=>{P(""),T(!0)},onBlur:()=>setTimeout(()=>T(!1),200),placeholder:ee??U("searchAccount","Search account…"),disabled:r,required:o}):e.jsx("div",{className:"nice-account-picker__display",children:b?`${b.code} — ${b.name}`:ee??U("selectAccount","Select account…")})}),te&&$.length>0&&e.jsx("div",{className:"nice-account-picker__dropdown",role:"listbox",children:$.map(c=>e.jsxs("div",{className:`nice-account-picker__option${c.code===L?" nice-account-picker__option--selected":""}${c.isActive===!1?" nice-account-picker__option--inactive":""}`,role:"option","aria-selected":c.code===L,onClick:()=>l(c),children:[I&&c.type&&e.jsx("span",{className:"nice-account-picker__type",style:{color:Di[c.type]},title:c.type,children:e.jsx(y.oa,{name:"circle",size:10})}),e.jsx("span",{className:"nice-account-picker__code",children:c.code}),e.jsx("span",{className:"nice-account-picker__name",children:c.name})]},c.code))}),i&&e.jsx("span",{className:"nice-helper-text",children:i}),a&&typeof a=="string"&&e.jsx("span",{className:"nice-error-text",children:a})]})});kn.displayName="NiceAccountPicker";const wn=n.forwardRef(({label:t,helperText:i,error:a,required:o,disabled:r,readOnly:h,size:x="md",name:_,id:z,className:C,style:X,accessMode:q,value:L=[],onChange:k,contacts:J=[],onSearch:ne,searchDelay:ee=300,multiple:ie=!1,placeholder:I,onContactClick:j,maxSelections:R},f)=>{const w=y.Dc(q,z),U=w==="hidden";w==="disabled"&&(r=!0),w==="readOnly"&&(h=!0);const{t:u}=y.Gt(),g=y.bc(z),[P,te]=n.useState(""),[T,b]=n.useState([]),[s,$]=n.useState(!1),[M,l]=n.useState(!1),c=n.useMemo(()=>{const v=[...J,...T],B=new Map(v.map(A=>[A.id,A]));return L.map(A=>B.get(A)).filter(Boolean)},[L,J,T]),d=n.useCallback(v=>{if(te(v),v.length<1){b([]),$(!1);return}if(ne){l(!0);const V=setTimeout(async()=>{const N=await ne(v);b(N),$(!0),l(!1)},ee);return()=>clearTimeout(V)}const B=v.toLowerCase(),A=J.filter(V=>V.name.toLowerCase().includes(B)||V.email?.toLowerCase().includes(B)||V.phone?.includes(v));b(A),$(!0)},[ne,J,ee]),p=n.useCallback(v=>{if(ie)if(L.includes(v.id))k?.(L.filter(B=>B!==v.id));else{if(R&&L.length>=R)return;k?.([...L,v.id])}else k?.([v.id]),$(!1),te("")},[L,k,ie,R]),E=n.useCallback(v=>{k?.(L.filter(B=>B!==v))},[L,k]);return U?null:e.jsxs("div",{ref:f,id:g,className:`nice-contact-picker nice-size-${x}${C?` ${C}`:""}${a?" nice-error":""}${r?" nice-disabled":""}`,style:X,children:[t&&e.jsxs("label",{className:"nice-contact-picker__label",children:[t,o&&e.jsx("span",{className:"nice-required",children:"*"})]}),c.length>0&&e.jsx("div",{className:"nice-contact-picker__chips",children:c.map(v=>e.jsxs("span",{className:"nice-contact-picker__chip",onClick:()=>j?.(v),children:[v.avatarUrl&&e.jsx("img",{src:v.avatarUrl,alt:"",className:"nice-contact-picker__chip-avatar"}),e.jsx("span",{children:v.name}),!h&&e.jsx("button",{type:"button",className:"nice-contact-picker__chip-remove",onClick:B=>{B.stopPropagation(),E(v.id)},disabled:r,"aria-label":u("controls.remove","Remove"),children:e.jsx(y.oa,{name:"close",size:14})})]},v.id))}),!h&&e.jsxs("div",{className:"nice-contact-picker__search",children:[e.jsx("input",{className:"nice-input",type:"text",value:P,onChange:v=>d(v.target.value),onFocus:()=>P.length>0&&$(!0),onBlur:()=>setTimeout(()=>$(!1),200),placeholder:I??u("searchContacts","Search contacts…"),disabled:r,"aria-label":u("searchContacts","Search contacts")}),M&&e.jsx("span",{className:"nice-contact-picker__spinner",children:e.jsx(y.oa,{name:"refresh",size:16})})]}),s&&T.length>0&&e.jsx("div",{className:"nice-contact-picker__dropdown",role:"listbox",children:T.map(v=>e.jsxs("div",{className:`nice-contact-picker__option${L.includes(v.id)?" nice-contact-picker__option--selected":""}`,role:"option","aria-selected":L.includes(v.id),onClick:()=>p(v),children:[v.avatarUrl&&e.jsx("img",{src:v.avatarUrl,alt:"",className:"nice-contact-picker__option-avatar"}),e.jsxs("div",{className:"nice-contact-picker__option-info",children:[e.jsx("span",{className:"nice-contact-picker__option-name",children:v.name}),v.subtitle&&e.jsx("span",{className:"nice-contact-picker__option-subtitle",children:v.subtitle}),v.email&&e.jsx("span",{className:"nice-contact-picker__option-email",children:v.email})]}),v.type&&e.jsx("span",{className:"nice-contact-picker__option-type",children:e.jsx(y.oa,{name:v.type==="person"?"user":"building",size:16})})]},v.id))}),i&&e.jsx("span",{className:"nice-helper-text",children:i}),a&&typeof a=="string"&&e.jsx("span",{className:"nice-error-text",children:a})]})});wn.displayName="NiceContactPicker";const zi={recent:"🕒",smileys:"😀",people:"👋",animals:"🐱",food:"🍕",travel:"✈️",activities:"⚽",objects:"💡",symbols:"❤️",flags:"🏳️"},Ut={recent:"Recently Used",smileys:"Smileys & Emotion",people:"People & Body",animals:"Animals & Nature",food:"Food & Drink",travel:"Travel & Places",activities:"Activities",objects:"Objects",symbols:"Symbols",flags:"Flags"},vt=["","🏻","🏼","🏽","🏾","🏿"],ht=[{emoji:"😀",name:"grinning face",category:"smileys",keywords:["happy","smile"]},{emoji:"😃",name:"grinning face with big eyes",category:"smileys"},{emoji:"😄",name:"grinning face with smiling eyes",category:"smileys"},{emoji:"😁",name:"beaming face",category:"smileys"},{emoji:"😅",name:"grinning face with sweat",category:"smileys"},{emoji:"🤣",name:"rolling on the floor laughing",category:"smileys",keywords:["rofl"]},{emoji:"😂",name:"face with tears of joy",category:"smileys",keywords:["lol","laugh"]},{emoji:"🙂",name:"slightly smiling face",category:"smileys"},{emoji:"😉",name:"winking face",category:"smileys",keywords:["wink"]},{emoji:"😊",name:"smiling face with smiling eyes",category:"smileys"},{emoji:"😇",name:"smiling face with halo",category:"smileys",keywords:["angel"]},{emoji:"🥰",name:"smiling face with hearts",category:"smileys",keywords:["love"]},{emoji:"😍",name:"smiling face with heart-eyes",category:"smileys"},{emoji:"🤩",name:"star-struck",category:"smileys",keywords:["wow"]},{emoji:"😘",name:"face blowing a kiss",category:"smileys",keywords:["kiss"]},{emoji:"😗",name:"kissing face",category:"smileys"},{emoji:"😚",name:"kissing face with closed eyes",category:"smileys"},{emoji:"😋",name:"face savoring food",category:"smileys",keywords:["yum"]},{emoji:"😛",name:"face with tongue",category:"smileys"},{emoji:"😜",name:"winking face with tongue",category:"smileys"},{emoji:"🤪",name:"zany face",category:"smileys",keywords:["crazy"]},{emoji:"😝",name:"squinting face with tongue",category:"smileys"},{emoji:"🤑",name:"money-mouth face",category:"smileys"},{emoji:"🤗",name:"hugging face",category:"smileys",keywords:["hug"]},{emoji:"🤭",name:"face with hand over mouth",category:"smileys"},{emoji:"🤫",name:"shushing face",category:"smileys",keywords:["quiet"]},{emoji:"🤔",name:"thinking face",category:"smileys",keywords:["think","hmm"]},{emoji:"🤐",name:"zipper-mouth face",category:"smileys"},{emoji:"🤨",name:"face with raised eyebrow",category:"smileys"},{emoji:"😐",name:"neutral face",category:"smileys"},{emoji:"😑",name:"expressionless face",category:"smileys"},{emoji:"😶",name:"face without mouth",category:"smileys"},{emoji:"😏",name:"smirking face",category:"smileys",keywords:["smirk"]},{emoji:"😒",name:"unamused face",category:"smileys"},{emoji:"🙄",name:"face with rolling eyes",category:"smileys"},{emoji:"😬",name:"grimacing face",category:"smileys"},{emoji:"😮‍💨",name:"face exhaling",category:"smileys"},{emoji:"🤥",name:"lying face",category:"smileys"},{emoji:"😌",name:"relieved face",category:"smileys"},{emoji:"😔",name:"pensive face",category:"smileys",keywords:["sad"]},{emoji:"😪",name:"sleepy face",category:"smileys"},{emoji:"🤤",name:"drooling face",category:"smileys"},{emoji:"😴",name:"sleeping face",category:"smileys",keywords:["sleep","zzz"]},{emoji:"😷",name:"face with medical mask",category:"smileys",keywords:["sick"]},{emoji:"🤒",name:"face with thermometer",category:"smileys"},{emoji:"🤕",name:"face with head-bandage",category:"smileys"},{emoji:"🤢",name:"nauseated face",category:"smileys"},{emoji:"🤮",name:"face vomiting",category:"smileys"},{emoji:"🤧",name:"sneezing face",category:"smileys"},{emoji:"🥵",name:"hot face",category:"smileys"},{emoji:"🥶",name:"cold face",category:"smileys"},{emoji:"🥴",name:"woozy face",category:"smileys",keywords:["drunk"]},{emoji:"😵",name:"face with crossed-out eyes",category:"smileys"},{emoji:"🤯",name:"exploding head",category:"smileys",keywords:["mind blown"]},{emoji:"🤠",name:"cowboy hat face",category:"smileys"},{emoji:"🥳",name:"partying face",category:"smileys",keywords:["party"]},{emoji:"🥸",name:"disguised face",category:"smileys"},{emoji:"😎",name:"smiling face with sunglasses",category:"smileys",keywords:["cool"]},{emoji:"🤓",name:"nerd face",category:"smileys",keywords:["nerd"]},{emoji:"🧐",name:"face with monocle",category:"smileys"},{emoji:"😕",name:"confused face",category:"smileys"},{emoji:"😟",name:"worried face",category:"smileys"},{emoji:"🙁",name:"slightly frowning face",category:"smileys"},{emoji:"☹️",name:"frowning face",category:"smileys"},{emoji:"😮",name:"face with open mouth",category:"smileys",keywords:["surprised"]},{emoji:"😯",name:"hushed face",category:"smileys"},{emoji:"😲",name:"astonished face",category:"smileys"},{emoji:"😳",name:"flushed face",category:"smileys"},{emoji:"🥺",name:"pleading face",category:"smileys"},{emoji:"😦",name:"frowning face with open mouth",category:"smileys"},{emoji:"😧",name:"anguished face",category:"smileys"},{emoji:"😨",name:"fearful face",category:"smileys"},{emoji:"😰",name:"anxious face with sweat",category:"smileys"},{emoji:"😥",name:"sad but relieved face",category:"smileys"},{emoji:"😢",name:"crying face",category:"smileys",keywords:["cry"]},{emoji:"😭",name:"loudly crying face",category:"smileys",keywords:["sob"]},{emoji:"😱",name:"face screaming in fear",category:"smileys",keywords:["scream"]},{emoji:"😖",name:"confounded face",category:"smileys"},{emoji:"😣",name:"persevering face",category:"smileys"},{emoji:"😞",name:"disappointed face",category:"smileys"},{emoji:"😓",name:"downcast face with sweat",category:"smileys"},{emoji:"😩",name:"weary face",category:"smileys"},{emoji:"😫",name:"tired face",category:"smileys"},{emoji:"🥱",name:"yawning face",category:"smileys"},{emoji:"😤",name:"face with steam from nose",category:"smileys",keywords:["angry"]},{emoji:"😡",name:"pouting face",category:"smileys",keywords:["rage"]},{emoji:"😠",name:"angry face",category:"smileys"},{emoji:"🤬",name:"face with symbols on mouth",category:"smileys",keywords:["swear"]},{emoji:"😈",name:"smiling face with horns",category:"smileys",keywords:["devil"]},{emoji:"👿",name:"angry face with horns",category:"smileys"},{emoji:"💀",name:"skull",category:"smileys",keywords:["dead"]},{emoji:"☠️",name:"skull and crossbones",category:"smileys"},{emoji:"💩",name:"pile of poo",category:"smileys",keywords:["poop"]},{emoji:"🤡",name:"clown face",category:"smileys"},{emoji:"👹",name:"ogre",category:"smileys"},{emoji:"👺",name:"goblin",category:"smileys"},{emoji:"👻",name:"ghost",category:"smileys"},{emoji:"👽",name:"alien",category:"smileys"},{emoji:"👾",name:"alien monster",category:"smileys"},{emoji:"🤖",name:"robot",category:"smileys"},{emoji:"👋",name:"waving hand",category:"people",skinTones:!0,keywords:["wave","hi"]},{emoji:"🤚",name:"raised back of hand",category:"people",skinTones:!0},{emoji:"🖐️",name:"hand with fingers splayed",category:"people",skinTones:!0},{emoji:"✋",name:"raised hand",category:"people",skinTones:!0},{emoji:"🖖",name:"vulcan salute",category:"people",skinTones:!0},{emoji:"👌",name:"ok hand",category:"people",skinTones:!0,keywords:["ok","perfect"]},{emoji:"🤌",name:"pinched fingers",category:"people",skinTones:!0},{emoji:"🤏",name:"pinching hand",category:"people",skinTones:!0},{emoji:"✌️",name:"victory hand",category:"people",skinTones:!0,keywords:["peace"]},{emoji:"🤞",name:"crossed fingers",category:"people",skinTones:!0},{emoji:"🤟",name:"love-you gesture",category:"people",skinTones:!0},{emoji:"🤘",name:"sign of the horns",category:"people",skinTones:!0,keywords:["rock"]},{emoji:"🤙",name:"call me hand",category:"people",skinTones:!0},{emoji:"👈",name:"backhand index pointing left",category:"people",skinTones:!0},{emoji:"👉",name:"backhand index pointing right",category:"people",skinTones:!0},{emoji:"👆",name:"backhand index pointing up",category:"people",skinTones:!0},{emoji:"🖕",name:"middle finger",category:"people",skinTones:!0},{emoji:"👇",name:"backhand index pointing down",category:"people",skinTones:!0},{emoji:"☝️",name:"index pointing up",category:"people",skinTones:!0},{emoji:"👍",name:"thumbs up",category:"people",skinTones:!0,keywords:["like","good"]},{emoji:"👎",name:"thumbs down",category:"people",skinTones:!0,keywords:["dislike","bad"]},{emoji:"✊",name:"raised fist",category:"people",skinTones:!0},{emoji:"👊",name:"oncoming fist",category:"people",skinTones:!0},{emoji:"🤛",name:"left-facing fist",category:"people",skinTones:!0},{emoji:"🤜",name:"right-facing fist",category:"people",skinTones:!0},{emoji:"👏",name:"clapping hands",category:"people",skinTones:!0,keywords:["clap","applause"]},{emoji:"🙌",name:"raising hands",category:"people",skinTones:!0},{emoji:"👐",name:"open hands",category:"people",skinTones:!0},{emoji:"🤲",name:"palms up together",category:"people",skinTones:!0},{emoji:"🤝",name:"handshake",category:"people",skinTones:!0},{emoji:"🙏",name:"folded hands",category:"people",skinTones:!0,keywords:["pray","please"]},{emoji:"✍️",name:"writing hand",category:"people",skinTones:!0},{emoji:"💪",name:"flexed biceps",category:"people",skinTones:!0,keywords:["strong","muscle"]},{emoji:"🐶",name:"dog face",category:"animals",keywords:["dog"]},{emoji:"🐱",name:"cat face",category:"animals",keywords:["cat"]},{emoji:"🐭",name:"mouse face",category:"animals"},{emoji:"🐹",name:"hamster",category:"animals"},{emoji:"🐰",name:"rabbit face",category:"animals"},{emoji:"🦊",name:"fox",category:"animals"},{emoji:"🐻",name:"bear",category:"animals"},{emoji:"🐼",name:"panda",category:"animals"},{emoji:"🐨",name:"koala",category:"animals"},{emoji:"🐯",name:"tiger face",category:"animals"},{emoji:"🦁",name:"lion",category:"animals"},{emoji:"🐮",name:"cow face",category:"animals"},{emoji:"🐷",name:"pig face",category:"animals",keywords:["pig"]},{emoji:"🐸",name:"frog",category:"animals"},{emoji:"🐵",name:"monkey face",category:"animals"},{emoji:"🙈",name:"see-no-evil monkey",category:"animals"},{emoji:"🙉",name:"hear-no-evil monkey",category:"animals"},{emoji:"🙊",name:"speak-no-evil monkey",category:"animals"},{emoji:"🐔",name:"chicken",category:"animals"},{emoji:"🐧",name:"penguin",category:"animals"},{emoji:"🐦",name:"bird",category:"animals"},{emoji:"🐤",name:"baby chick",category:"animals"},{emoji:"🦆",name:"duck",category:"animals"},{emoji:"🦅",name:"eagle",category:"animals"},{emoji:"🦉",name:"owl",category:"animals"},{emoji:"🦇",name:"bat",category:"animals"},{emoji:"🐺",name:"wolf",category:"animals"},{emoji:"🐗",name:"boar",category:"animals"},{emoji:"🐴",name:"horse face",category:"animals"},{emoji:"🦄",name:"unicorn",category:"animals"},{emoji:"🐝",name:"honeybee",category:"animals",keywords:["bee"]},{emoji:"🐛",name:"bug",category:"animals"},{emoji:"🦋",name:"butterfly",category:"animals"},{emoji:"🐌",name:"snail",category:"animals"},{emoji:"🐙",name:"octopus",category:"animals"},{emoji:"🐬",name:"dolphin",category:"animals"},{emoji:"🐳",name:"spouting whale",category:"animals",keywords:["whale"]},{emoji:"🦈",name:"shark",category:"animals"},{emoji:"🐊",name:"crocodile",category:"animals"},{emoji:"🐢",name:"turtle",category:"animals"},{emoji:"🐍",name:"snake",category:"animals"},{emoji:"🦎",name:"lizard",category:"animals"},{emoji:"🐲",name:"dragon face",category:"animals",keywords:["dragon"]},{emoji:"🌸",name:"cherry blossom",category:"animals",keywords:["flower"]},{emoji:"🌹",name:"rose",category:"animals"},{emoji:"🌻",name:"sunflower",category:"animals"},{emoji:"🌺",name:"hibiscus",category:"animals"},{emoji:"🌷",name:"tulip",category:"animals"},{emoji:"🌲",name:"evergreen tree",category:"animals",keywords:["tree"]},{emoji:"🌳",name:"deciduous tree",category:"animals"},{emoji:"🌴",name:"palm tree",category:"animals"},{emoji:"🌵",name:"cactus",category:"animals"},{emoji:"🍀",name:"four leaf clover",category:"animals",keywords:["lucky"]},{emoji:"🍎",name:"red apple",category:"food",keywords:["apple"]},{emoji:"🍊",name:"tangerine",category:"food",keywords:["orange"]},{emoji:"🍋",name:"lemon",category:"food"},{emoji:"🍌",name:"banana",category:"food"},{emoji:"🍉",name:"watermelon",category:"food"},{emoji:"🍇",name:"grapes",category:"food"},{emoji:"🍓",name:"strawberry",category:"food"},{emoji:"🍒",name:"cherries",category:"food"},{emoji:"🍑",name:"peach",category:"food"},{emoji:"🥭",name:"mango",category:"food"},{emoji:"🍍",name:"pineapple",category:"food"},{emoji:"🥝",name:"kiwi fruit",category:"food"},{emoji:"🍅",name:"tomato",category:"food"},{emoji:"🥑",name:"avocado",category:"food"},{emoji:"🥦",name:"broccoli",category:"food"},{emoji:"🥬",name:"leafy green",category:"food"},{emoji:"🥒",name:"cucumber",category:"food"},{emoji:"🌽",name:"ear of corn",category:"food",keywords:["corn"]},{emoji:"🥕",name:"carrot",category:"food"},{emoji:"🧄",name:"garlic",category:"food"},{emoji:"🧅",name:"onion",category:"food"},{emoji:"🥔",name:"potato",category:"food"},{emoji:"🍞",name:"bread",category:"food"},{emoji:"🥐",name:"croissant",category:"food"},{emoji:"🥖",name:"baguette bread",category:"food"},{emoji:"🧀",name:"cheese wedge",category:"food",keywords:["cheese"]},{emoji:"🥚",name:"egg",category:"food"},{emoji:"🍳",name:"cooking",category:"food",keywords:["egg","breakfast"]},{emoji:"🥓",name:"bacon",category:"food"},{emoji:"🥩",name:"cut of meat",category:"food",keywords:["steak"]},{emoji:"🍗",name:"poultry leg",category:"food",keywords:["chicken"]},{emoji:"🍖",name:"meat on bone",category:"food"},{emoji:"🌭",name:"hot dog",category:"food"},{emoji:"🍔",name:"hamburger",category:"food",keywords:["burger"]},{emoji:"🍟",name:"french fries",category:"food",keywords:["fries"]},{emoji:"🍕",name:"pizza",category:"food"},{emoji:"🥪",name:"sandwich",category:"food"},{emoji:"🌮",name:"taco",category:"food"},{emoji:"🌯",name:"burrito",category:"food"},{emoji:"🥗",name:"green salad",category:"food",keywords:["salad"]},{emoji:"🍝",name:"spaghetti",category:"food",keywords:["pasta"]},{emoji:"🍜",name:"steaming bowl",category:"food",keywords:["ramen","noodles"]},{emoji:"🍲",name:"pot of food",category:"food",keywords:["stew"]},{emoji:"🍣",name:"sushi",category:"food"},{emoji:"🍱",name:"bento box",category:"food"},{emoji:"🥟",name:"dumpling",category:"food"},{emoji:"🍩",name:"doughnut",category:"food",keywords:["donut"]},{emoji:"🍪",name:"cookie",category:"food"},{emoji:"🎂",name:"birthday cake",category:"food",keywords:["cake","birthday"]},{emoji:"🍰",name:"shortcake",category:"food",keywords:["cake"]},{emoji:"🧁",name:"cupcake",category:"food"},{emoji:"🍫",name:"chocolate bar",category:"food",keywords:["chocolate"]},{emoji:"🍬",name:"candy",category:"food"},{emoji:"🍭",name:"lollipop",category:"food"},{emoji:"🍦",name:"soft ice cream",category:"food",keywords:["ice cream"]},{emoji:"☕",name:"hot beverage",category:"food",keywords:["coffee","tea"]},{emoji:"🍵",name:"teacup without handle",category:"food",keywords:["tea"]},{emoji:"🥤",name:"cup with straw",category:"food"},{emoji:"🍺",name:"beer mug",category:"food",keywords:["beer"]},{emoji:"🍻",name:"clinking beer mugs",category:"food",keywords:["cheers"]},{emoji:"🥂",name:"clinking glasses",category:"food",keywords:["champagne","toast"]},{emoji:"🍷",name:"wine glass",category:"food",keywords:["wine"]},{emoji:"🍸",name:"cocktail glass",category:"food",keywords:["martini"]},{emoji:"🚗",name:"automobile",category:"travel",keywords:["car"]},{emoji:"🚕",name:"taxi",category:"travel"},{emoji:"🚌",name:"bus",category:"travel"},{emoji:"🚎",name:"trolleybus",category:"travel"},{emoji:"🏎️",name:"racing car",category:"travel"},{emoji:"🚓",name:"police car",category:"travel"},{emoji:"🚑",name:"ambulance",category:"travel"},{emoji:"🚒",name:"fire engine",category:"travel"},{emoji:"🚐",name:"minibus",category:"travel"},{emoji:"🛻",name:"pickup truck",category:"travel"},{emoji:"🚚",name:"delivery truck",category:"travel",keywords:["truck"]},{emoji:"🚲",name:"bicycle",category:"travel",keywords:["bike"]},{emoji:"🛵",name:"motor scooter",category:"travel"},{emoji:"🏍️",name:"motorcycle",category:"travel"},{emoji:"✈️",name:"airplane",category:"travel",keywords:["plane"]},{emoji:"🚀",name:"rocket",category:"travel"},{emoji:"🚁",name:"helicopter",category:"travel"},{emoji:"🛶",name:"canoe",category:"travel"},{emoji:"⛵",name:"sailboat",category:"travel",keywords:["boat"]},{emoji:"🚢",name:"ship",category:"travel"},{emoji:"🚆",name:"train",category:"travel"},{emoji:"🚇",name:"metro",category:"travel",keywords:["subway"]},{emoji:"🏠",name:"house",category:"travel",keywords:["home"]},{emoji:"🏡",name:"house with garden",category:"travel"},{emoji:"🏢",name:"office building",category:"travel",keywords:["office"]},{emoji:"🏣",name:"Japanese post office",category:"travel"},{emoji:"🏥",name:"hospital",category:"travel"},{emoji:"🏦",name:"bank",category:"travel"},{emoji:"🏨",name:"hotel",category:"travel"},{emoji:"🏪",name:"convenience store",category:"travel",keywords:["store"]},{emoji:"🏫",name:"school",category:"travel"},{emoji:"🏭",name:"factory",category:"travel"},{emoji:"🏰",name:"castle",category:"travel"},{emoji:"⛪",name:"church",category:"travel"},{emoji:"🕌",name:"mosque",category:"travel"},{emoji:"🗼",name:"Tokyo tower",category:"travel"},{emoji:"🗽",name:"Statue of Liberty",category:"travel"},{emoji:"🌁",name:"foggy",category:"travel"},{emoji:"🌃",name:"night with stars",category:"travel"},{emoji:"🌄",name:"sunrise over mountains",category:"travel"},{emoji:"🌅",name:"sunrise",category:"travel"},{emoji:"🌆",name:"cityscape at dusk",category:"travel"},{emoji:"🌇",name:"sunset",category:"travel"},{emoji:"🌉",name:"bridge at night",category:"travel"},{emoji:"⛰️",name:"mountain",category:"travel"},{emoji:"🏔️",name:"snow-capped mountain",category:"travel"},{emoji:"🗻",name:"mount fuji",category:"travel"},{emoji:"🏝️",name:"desert island",category:"travel",keywords:["island"]},{emoji:"🏖️",name:"beach with umbrella",category:"travel",keywords:["beach"]},{emoji:"🌋",name:"volcano",category:"travel"},{emoji:"🌍",name:"globe Europe-Africa",category:"travel",keywords:["earth","world"]},{emoji:"🌎",name:"globe Americas",category:"travel"},{emoji:"🌏",name:"globe Asia-Australia",category:"travel"},{emoji:"🌕",name:"full moon",category:"travel",keywords:["moon"]},{emoji:"🌙",name:"crescent moon",category:"travel"},{emoji:"⭐",name:"star",category:"travel"},{emoji:"🌟",name:"glowing star",category:"travel"},{emoji:"☀️",name:"sun",category:"travel"},{emoji:"🌤️",name:"sun behind small cloud",category:"travel"},{emoji:"⛅",name:"sun behind cloud",category:"travel"},{emoji:"🌧️",name:"cloud with rain",category:"travel",keywords:["rain"]},{emoji:"⛈️",name:"cloud with lightning and rain",category:"travel",keywords:["storm"]},{emoji:"🌨️",name:"cloud with snow",category:"travel",keywords:["snow"]},{emoji:"🌈",name:"rainbow",category:"travel"},{emoji:"⚽",name:"soccer ball",category:"activities",keywords:["football","soccer"]},{emoji:"🏀",name:"basketball",category:"activities"},{emoji:"🏈",name:"american football",category:"activities"},{emoji:"⚾",name:"baseball",category:"activities"},{emoji:"🥎",name:"softball",category:"activities"},{emoji:"🎾",name:"tennis",category:"activities"},{emoji:"🏐",name:"volleyball",category:"activities"},{emoji:"🏉",name:"rugby football",category:"activities"},{emoji:"🥏",name:"flying disc",category:"activities",keywords:["frisbee"]},{emoji:"🎱",name:"pool 8 ball",category:"activities",keywords:["billiards"]},{emoji:"🪀",name:"yo-yo",category:"activities"},{emoji:"🏓",name:"ping pong",category:"activities"},{emoji:"🏸",name:"badminton",category:"activities"},{emoji:"🏒",name:"ice hockey",category:"activities"},{emoji:"🥅",name:"goal net",category:"activities"},{emoji:"⛳",name:"flag in hole",category:"activities",keywords:["golf"]},{emoji:"🏹",name:"bow and arrow",category:"activities",keywords:["archery"]},{emoji:"🎣",name:"fishing pole",category:"activities",keywords:["fishing"]},{emoji:"🥊",name:"boxing glove",category:"activities",keywords:["boxing"]},{emoji:"🥋",name:"martial arts uniform",category:"activities"},{emoji:"🎽",name:"running shirt",category:"activities"},{emoji:"🛹",name:"skateboard",category:"activities"},{emoji:"🛷",name:"sled",category:"activities"},{emoji:"⛸️",name:"ice skate",category:"activities"},{emoji:"🥌",name:"curling stone",category:"activities"},{emoji:"🎿",name:"skis",category:"activities",keywords:["skiing"]},{emoji:"🏂",name:"snowboarder",category:"activities",keywords:["snowboard"]},{emoji:"🏋️",name:"person lifting weights",category:"activities",keywords:["gym"]},{emoji:"🤸",name:"person cartwheeling",category:"activities"},{emoji:"🤺",name:"person fencing",category:"activities"},{emoji:"🏊",name:"person swimming",category:"activities",keywords:["swim"]},{emoji:"🚴",name:"person biking",category:"activities",keywords:["cycling"]},{emoji:"🧘",name:"person in lotus position",category:"activities",keywords:["yoga","meditation"]},{emoji:"🏆",name:"trophy",category:"activities",keywords:["winner","champion"]},{emoji:"🥇",name:"gold medal",category:"activities",keywords:["first"]},{emoji:"🥈",name:"silver medal",category:"activities",keywords:["second"]},{emoji:"🥉",name:"bronze medal",category:"activities",keywords:["third"]},{emoji:"🎮",name:"video game",category:"activities",keywords:["game","gaming"]},{emoji:"🕹️",name:"joystick",category:"activities"},{emoji:"🎲",name:"game die",category:"activities",keywords:["dice"]},{emoji:"🧩",name:"puzzle piece",category:"activities",keywords:["puzzle"]},{emoji:"♟️",name:"chess pawn",category:"activities",keywords:["chess"]},{emoji:"🎯",name:"direct hit",category:"activities",keywords:["dart","target"]},{emoji:"🎰",name:"slot machine",category:"activities"},{emoji:"🎭",name:"performing arts",category:"activities",keywords:["theater","drama"]},{emoji:"🎨",name:"artist palette",category:"activities",keywords:["art","paint"]},{emoji:"🎬",name:"clapper board",category:"activities",keywords:["movie","film"]},{emoji:"🎤",name:"microphone",category:"activities",keywords:["karaoke","sing"]},{emoji:"🎧",name:"headphone",category:"activities",keywords:["music"]},{emoji:"🎼",name:"musical score",category:"activities"},{emoji:"🎹",name:"musical keyboard",category:"activities",keywords:["piano"]},{emoji:"🎷",name:"saxophone",category:"activities"},{emoji:"🎸",name:"guitar",category:"activities"},{emoji:"🎻",name:"violin",category:"activities"},{emoji:"🪘",name:"long drum",category:"activities"},{emoji:"🥁",name:"drum",category:"activities"},{emoji:"⌚",name:"watch",category:"objects"},{emoji:"📱",name:"mobile phone",category:"objects",keywords:["phone","smartphone"]},{emoji:"📲",name:"mobile phone with arrow",category:"objects"},{emoji:"💻",name:"laptop",category:"objects",keywords:["computer"]},{emoji:"🖥️",name:"desktop computer",category:"objects"},{emoji:"🖨️",name:"printer",category:"objects"},{emoji:"⌨️",name:"keyboard",category:"objects"},{emoji:"🖱️",name:"computer mouse",category:"objects"},{emoji:"💾",name:"floppy disk",category:"objects"},{emoji:"💿",name:"optical disk",category:"objects",keywords:["cd"]},{emoji:"📀",name:"dvd",category:"objects"},{emoji:"📷",name:"camera",category:"objects"},{emoji:"📹",name:"video camera",category:"objects"},{emoji:"🎥",name:"movie camera",category:"objects"},{emoji:"📺",name:"television",category:"objects",keywords:["tv"]},{emoji:"📻",name:"radio",category:"objects"},{emoji:"🎙️",name:"studio microphone",category:"objects"},{emoji:"⏰",name:"alarm clock",category:"objects",keywords:["clock"]},{emoji:"⏳",name:"hourglass not done",category:"objects"},{emoji:"⌛",name:"hourglass done",category:"objects"},{emoji:"📡",name:"satellite antenna",category:"objects"},{emoji:"🔋",name:"battery",category:"objects"},{emoji:"🔌",name:"electric plug",category:"objects"},{emoji:"💡",name:"light bulb",category:"objects",keywords:["idea"]},{emoji:"🔦",name:"flashlight",category:"objects"},{emoji:"🕯️",name:"candle",category:"objects"},{emoji:"🧯",name:"fire extinguisher",category:"objects"},{emoji:"🛢️",name:"oil drum",category:"objects"},{emoji:"💸",name:"money with wings",category:"objects"},{emoji:"💵",name:"dollar banknote",category:"objects",keywords:["money"]},{emoji:"💳",name:"credit card",category:"objects"},{emoji:"💰",name:"money bag",category:"objects"},{emoji:"🧲",name:"magnet",category:"objects"},{emoji:"🔧",name:"wrench",category:"objects"},{emoji:"🔨",name:"hammer",category:"objects"},{emoji:"🛠️",name:"hammer and wrench",category:"objects",keywords:["tools"]},{emoji:"⚙️",name:"gear",category:"objects",keywords:["settings"]},{emoji:"🔩",name:"nut and bolt",category:"objects"},{emoji:"🔑",name:"key",category:"objects"},{emoji:"🗝️",name:"old key",category:"objects"},{emoji:"🔒",name:"locked",category:"objects",keywords:["lock"]},{emoji:"🔓",name:"unlocked",category:"objects"},{emoji:"📦",name:"package",category:"objects",keywords:["box"]},{emoji:"📫",name:"closed mailbox with raised flag",category:"objects",keywords:["mail"]},{emoji:"📝",name:"memo",category:"objects",keywords:["note"]},{emoji:"📄",name:"page facing up",category:"objects",keywords:["document"]},{emoji:"📁",name:"file folder",category:"objects",keywords:["folder"]},{emoji:"📂",name:"open file folder",category:"objects"},{emoji:"📅",name:"calendar",category:"objects"},{emoji:"📆",name:"tear-off calendar",category:"objects"},{emoji:"📌",name:"pushpin",category:"objects",keywords:["pin"]},{emoji:"📎",name:"paperclip",category:"objects"},{emoji:"✂️",name:"scissors",category:"objects"},{emoji:"📏",name:"straight ruler",category:"objects"},{emoji:"✏️",name:"pencil",category:"objects"},{emoji:"🖊️",name:"pen",category:"objects"},{emoji:"🖍️",name:"crayon",category:"objects"},{emoji:"📚",name:"books",category:"objects",keywords:["book","library"]},{emoji:"📖",name:"open book",category:"objects"},{emoji:"🔗",name:"link",category:"objects"},{emoji:"💊",name:"pill",category:"objects",keywords:["medicine"]},{emoji:"💉",name:"syringe",category:"objects"},{emoji:"🩹",name:"adhesive bandage",category:"objects"},{emoji:"🧪",name:"test tube",category:"objects"},{emoji:"🔬",name:"microscope",category:"objects"},{emoji:"🔭",name:"telescope",category:"objects"},{emoji:"🧬",name:"dna",category:"objects"},{emoji:"🗑️",name:"wastebasket",category:"objects",keywords:["trash","delete"]},{emoji:"🚿",name:"shower",category:"objects"},{emoji:"🛁",name:"bathtub",category:"objects"},{emoji:"🧹",name:"broom",category:"objects"},{emoji:"🧺",name:"basket",category:"objects"},{emoji:"🧻",name:"roll of paper",category:"objects"},{emoji:"🧼",name:"soap",category:"objects"},{emoji:"🪥",name:"toothbrush",category:"objects"},{emoji:"🛒",name:"shopping cart",category:"objects"},{emoji:"🎁",name:"wrapped gift",category:"objects",keywords:["gift","present"]},{emoji:"🎀",name:"ribbon",category:"objects"},{emoji:"🎈",name:"balloon",category:"objects"},{emoji:"🎉",name:"party popper",category:"objects",keywords:["party","celebration"]},{emoji:"🎊",name:"confetti ball",category:"objects"},{emoji:"❤️",name:"red heart",category:"symbols",keywords:["love","heart"]},{emoji:"🧡",name:"orange heart",category:"symbols"},{emoji:"💛",name:"yellow heart",category:"symbols"},{emoji:"💚",name:"green heart",category:"symbols"},{emoji:"💙",name:"blue heart",category:"symbols"},{emoji:"💜",name:"purple heart",category:"symbols"},{emoji:"🖤",name:"black heart",category:"symbols"},{emoji:"🤍",name:"white heart",category:"symbols"},{emoji:"🤎",name:"brown heart",category:"symbols"},{emoji:"💔",name:"broken heart",category:"symbols"},{emoji:"💕",name:"two hearts",category:"symbols"},{emoji:"💖",name:"sparkling heart",category:"symbols"},{emoji:"💗",name:"growing heart",category:"symbols"},{emoji:"💘",name:"heart with arrow",category:"symbols"},{emoji:"💝",name:"heart with ribbon",category:"symbols"},{emoji:"💞",name:"revolving hearts",category:"symbols"},{emoji:"💯",name:"hundred points",category:"symbols",keywords:["100","perfect"]},{emoji:"💢",name:"anger symbol",category:"symbols"},{emoji:"💥",name:"collision",category:"symbols",keywords:["boom","explosion"]},{emoji:"💫",name:"dizzy",category:"symbols"},{emoji:"💦",name:"sweat droplets",category:"symbols"},{emoji:"💨",name:"dashing away",category:"symbols"},{emoji:"🕳️",name:"hole",category:"symbols"},{emoji:"💬",name:"speech balloon",category:"symbols",keywords:["comment","chat"]},{emoji:"👁️‍🗨️",name:"eye in speech bubble",category:"symbols"},{emoji:"🗨️",name:"left speech bubble",category:"symbols"},{emoji:"🗯️",name:"right anger bubble",category:"symbols"},{emoji:"💭",name:"thought balloon",category:"symbols"},{emoji:"💤",name:"zzz",category:"symbols",keywords:["sleep"]},{emoji:"🔔",name:"bell",category:"symbols",keywords:["notification"]},{emoji:"🔕",name:"bell with slash",category:"symbols",keywords:["mute"]},{emoji:"🎵",name:"musical note",category:"symbols",keywords:["music"]},{emoji:"🎶",name:"musical notes",category:"symbols"},{emoji:"➕",name:"plus",category:"symbols",keywords:["add"]},{emoji:"➖",name:"minus",category:"symbols"},{emoji:"➗",name:"divide",category:"symbols"},{emoji:"✖️",name:"multiply",category:"symbols"},{emoji:"♾️",name:"infinity",category:"symbols"},{emoji:"💲",name:"heavy dollar sign",category:"symbols",keywords:["money"]},{emoji:"🔴",name:"red circle",category:"symbols"},{emoji:"🟠",name:"orange circle",category:"symbols"},{emoji:"🟡",name:"yellow circle",category:"symbols"},{emoji:"🟢",name:"green circle",category:"symbols"},{emoji:"🔵",name:"blue circle",category:"symbols"},{emoji:"🟣",name:"purple circle",category:"symbols"},{emoji:"⚫",name:"black circle",category:"symbols"},{emoji:"⚪",name:"white circle",category:"symbols"},{emoji:"🟤",name:"brown circle",category:"symbols"},{emoji:"🔺",name:"red triangle pointed up",category:"symbols"},{emoji:"🔻",name:"red triangle pointed down",category:"symbols"},{emoji:"🔷",name:"large blue diamond",category:"symbols"},{emoji:"🔶",name:"large orange diamond",category:"symbols"},{emoji:"✅",name:"check mark button",category:"symbols",keywords:["done","yes"]},{emoji:"❌",name:"cross mark",category:"symbols",keywords:["no","wrong"]},{emoji:"❎",name:"cross mark button",category:"symbols"},{emoji:"✔️",name:"check mark",category:"symbols"},{emoji:"⭕",name:"hollow red circle",category:"symbols"},{emoji:"❗",name:"exclamation mark",category:"symbols",keywords:["warning"]},{emoji:"❓",name:"question mark",category:"symbols"},{emoji:"❕",name:"white exclamation mark",category:"symbols"},{emoji:"❔",name:"white question mark",category:"symbols"},{emoji:"⚠️",name:"warning",category:"symbols"},{emoji:"🚫",name:"prohibited",category:"symbols",keywords:["no","forbidden"]},{emoji:"🔞",name:"no one under eighteen",category:"symbols"},{emoji:"⛔",name:"no entry",category:"symbols",keywords:["stop"]},{emoji:"🔙",name:"back arrow",category:"symbols"},{emoji:"🔚",name:"end arrow",category:"symbols"},{emoji:"🔛",name:"on! arrow",category:"symbols"},{emoji:"🔜",name:"soon arrow",category:"symbols"},{emoji:"🔝",name:"top arrow",category:"symbols"},{emoji:"🔃",name:"clockwise vertical arrows",category:"symbols",keywords:["refresh"]},{emoji:"🔄",name:"counterclockwise arrows button",category:"symbols",keywords:["sync"]},{emoji:"🔁",name:"repeat button",category:"symbols"},{emoji:"🔀",name:"shuffle tracks button",category:"symbols"},{emoji:"▶️",name:"play button",category:"symbols"},{emoji:"⏸️",name:"pause button",category:"symbols"},{emoji:"⏹️",name:"stop button",category:"symbols"},{emoji:"⏺️",name:"record button",category:"symbols"},{emoji:"⏭️",name:"next track button",category:"symbols"},{emoji:"⏮️",name:"last track button",category:"symbols"},{emoji:"⏩",name:"fast-forward button",category:"symbols"},{emoji:"⏪",name:"fast reverse button",category:"symbols"},{emoji:"🔼",name:"upwards button",category:"symbols"},{emoji:"🔽",name:"downwards button",category:"symbols"},{emoji:"⬆️",name:"up arrow",category:"symbols"},{emoji:"⬇️",name:"down arrow",category:"symbols"},{emoji:"⬅️",name:"left arrow",category:"symbols"},{emoji:"➡️",name:"right arrow",category:"symbols"},{emoji:"↗️",name:"up-right arrow",category:"symbols"},{emoji:"↘️",name:"down-right arrow",category:"symbols"},{emoji:"↙️",name:"down-left arrow",category:"symbols"},{emoji:"↖️",name:"up-left arrow",category:"symbols"},{emoji:"↕️",name:"up-down arrow",category:"symbols"},{emoji:"↔️",name:"left-right arrow",category:"symbols"},{emoji:"🔀",name:"shuffle",category:"symbols"},{emoji:"ℹ️",name:"information",category:"symbols",keywords:["info"]},{emoji:"🆕",name:"new button",category:"symbols",keywords:["new"]},{emoji:"🆗",name:"ok button",category:"symbols",keywords:["ok"]},{emoji:"🆙",name:"up! button",category:"symbols"},{emoji:"🆒",name:"cool button",category:"symbols",keywords:["cool"]},{emoji:"🆓",name:"free button",category:"symbols",keywords:["free"]},{emoji:"🔟",name:"keycap: 10",category:"symbols"},{emoji:"#️⃣",name:"keycap: #",category:"symbols"},{emoji:"*️⃣",name:"keycap: *",category:"symbols"},{emoji:"0️⃣",name:"keycap: 0",category:"symbols"},{emoji:"1️⃣",name:"keycap: 1",category:"symbols"},{emoji:"2️⃣",name:"keycap: 2",category:"symbols"},{emoji:"3️⃣",name:"keycap: 3",category:"symbols"},{emoji:"4️⃣",name:"keycap: 4",category:"symbols"},{emoji:"5️⃣",name:"keycap: 5",category:"symbols"},{emoji:"6️⃣",name:"keycap: 6",category:"symbols"},{emoji:"7️⃣",name:"keycap: 7",category:"symbols"},{emoji:"8️⃣",name:"keycap: 8",category:"symbols"},{emoji:"9️⃣",name:"keycap: 9",category:"symbols"},{emoji:"©️",name:"copyright",category:"symbols"},{emoji:"®️",name:"registered",category:"symbols"},{emoji:"™️",name:"trade mark",category:"symbols"},{emoji:"🏳️",name:"white flag",category:"flags"},{emoji:"🏴",name:"black flag",category:"flags"},{emoji:"🏁",name:"chequered flag",category:"flags",keywords:["finish","racing"]},{emoji:"🚩",name:"triangular flag",category:"flags"},{emoji:"🏳️‍🌈",name:"rainbow flag",category:"flags",keywords:["pride"]},{emoji:"🏳️‍⚧️",name:"transgender flag",category:"flags"},{emoji:"🇺🇸",name:"flag: United States",category:"flags",keywords:["usa","america"]},{emoji:"🇬🇧",name:"flag: United Kingdom",category:"flags",keywords:["uk","britain"]},{emoji:"🇩🇪",name:"flag: Germany",category:"flags"},{emoji:"🇫🇷",name:"flag: France",category:"flags"},{emoji:"🇵🇱",name:"flag: Poland",category:"flags"},{emoji:"🇪🇸",name:"flag: Spain",category:"flags"},{emoji:"🇮🇹",name:"flag: Italy",category:"flags"},{emoji:"🇯🇵",name:"flag: Japan",category:"flags"},{emoji:"🇨🇳",name:"flag: China",category:"flags"},{emoji:"🇰🇷",name:"flag: South Korea",category:"flags"},{emoji:"🇮🇳",name:"flag: India",category:"flags"},{emoji:"🇧🇷",name:"flag: Brazil",category:"flags"},{emoji:"🇷🇺",name:"flag: Russia",category:"flags"},{emoji:"🇦🇺",name:"flag: Australia",category:"flags"},{emoji:"🇨🇦",name:"flag: Canada",category:"flags"},{emoji:"🇲🇽",name:"flag: Mexico",category:"flags"},{emoji:"🇳🇱",name:"flag: Netherlands",category:"flags"},{emoji:"🇧🇪",name:"flag: Belgium",category:"flags"},{emoji:"🇨🇭",name:"flag: Switzerland",category:"flags"},{emoji:"🇦🇹",name:"flag: Austria",category:"flags"},{emoji:"🇸🇪",name:"flag: Sweden",category:"flags"},{emoji:"🇳🇴",name:"flag: Norway",category:"flags"},{emoji:"🇩🇰",name:"flag: Denmark",category:"flags"},{emoji:"🇫🇮",name:"flag: Finland",category:"flags"},{emoji:"🇵🇹",name:"flag: Portugal",category:"flags"},{emoji:"🇬🇷",name:"flag: Greece",category:"flags"},{emoji:"🇹🇷",name:"flag: Turkey",category:"flags"},{emoji:"🇮🇱",name:"flag: Israel",category:"flags"},{emoji:"🇦🇪",name:"flag: United Arab Emirates",category:"flags"},{emoji:"🇸🇦",name:"flag: Saudi Arabia",category:"flags"},{emoji:"🇿🇦",name:"flag: South Africa",category:"flags"},{emoji:"🇪🇬",name:"flag: Egypt",category:"flags"},{emoji:"🇳🇬",name:"flag: Nigeria",category:"flags"},{emoji:"🇹🇭",name:"flag: Thailand",category:"flags"},{emoji:"🇻🇳",name:"flag: Vietnam",category:"flags"},{emoji:"🇸🇬",name:"flag: Singapore",category:"flags"},{emoji:"🇲🇾",name:"flag: Malaysia",category:"flags"},{emoji:"🇮🇩",name:"flag: Indonesia",category:"flags"},{emoji:"🇵🇭",name:"flag: Philippines",category:"flags"},{emoji:"🇦🇷",name:"flag: Argentina",category:"flags"},{emoji:"🇨🇱",name:"flag: Chile",category:"flags"},{emoji:"🇨🇴",name:"flag: Colombia",category:"flags"},{emoji:"🇺🇦",name:"flag: Ukraine",category:"flags"},{emoji:"🇨🇿",name:"flag: Czech Republic",category:"flags"},{emoji:"🇭🇺",name:"flag: Hungary",category:"flags"},{emoji:"🇷🇴",name:"flag: Romania",category:"flags"},{emoji:"🇮🇪",name:"flag: Ireland",category:"flags"},{emoji:"🇳🇿",name:"flag: New Zealand",category:"flags"}],Gt="nice-emoji-picker-recent",Nn=({onSelect:t,showSearch:i=!0,searchPlaceholder:a,showSkinTones:o=!0,defaultSkinTone:r=0,showRecent:h=!0,maxRecent:x=24,recentEmojis:_,onRecentChange:z,categories:C,customEmojis:X=[],columns:q=8,size:L="md",className:k="",style:J,"data-testid":ne="nice-emoji-picker"})=>{const{t:ee}=y.Gt(),[ie,I]=n.useState(""),[j,R]=n.useState(h?"recent":"smileys"),[f,w]=n.useState(r),[U,u]=n.useState(!1),g=n.useRef(null),[P,te]=n.useState(()=>{if(typeof window>"u")return[];try{return JSON.parse(localStorage.getItem(Gt)||"[]")}catch{return[]}}),T=_??P,b=C??[...h?["recent"]:[],"smileys","people","animals","food","travel","activities","objects","symbols","flags"],s=n.useMemo(()=>{if(!ie)return ht;const p=ie.toLowerCase();return ht.filter(E=>E.name.toLowerCase().includes(p)||E.emoji.includes(p)||E.keywords?.some(v=>v.toLowerCase().includes(p)))},[ie]),$=n.useMemo(()=>{const p={};for(const E of b)E==="recent"?p[E]=T.map(v=>ht.find(B=>B.emoji===v)).filter(v=>v!==void 0).slice(0,x):p[E]=s.filter(v=>v.category===E);return p},[b,s,T,x]),M=n.useCallback((p,E)=>!E||f===0?p:p.replace(/[\u{1F3FB}-\u{1F3FF}]/gu,"")+vt[f],[f]),l=n.useCallback(p=>{const E=M(p.emoji,p.skinTones),v=[p.emoji,...T.filter(B=>B!==p.emoji)].slice(0,x);if(_===void 0){te(v);try{localStorage.setItem(Gt,JSON.stringify(v))}catch{}}z?.(v),t?.(E,p)},[M,T,x,_,z,t]),c=n.useCallback(p=>{t?.(`:${p.name}:`,p)},[t]);n.useEffect(()=>{if(!U)return;const p=E=>{g.current&&!g.current.contains(E.target)&&u(!1)};return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[U]);const d=ie?s:$[j]||[];return e.jsxs("div",{className:`nice-emoji-picker nice-emoji-picker--${L} ${k}`,style:J,"data-testid":ne,children:[i&&e.jsxs("div",{className:"nice-emoji-picker__search",children:[e.jsx("input",{type:"text",value:ie,onChange:p=>I(p.target.value),placeholder:a??ee("search","Search emoji..."),className:"nice-emoji-picker__search-input","data-testid":`${ne}-search`}),o&&e.jsxs("div",{className:"nice-emoji-picker__skin-tone-wrapper",children:[e.jsxs("button",{ref:g,type:"button",className:"nice-emoji-picker__skin-tone-btn",onClick:()=>u(!U),title:ee("skinTone","Skin tone"),children:["✋",vt[f]]}),U&&e.jsx("div",{className:"nice-emoji-picker__skin-tone-menu",children:vt.map((p,E)=>e.jsxs("button",{type:"button",className:`nice-emoji-picker__skin-tone-option ${E===f?"nice-emoji-picker__skin-tone-option--selected":""}`,onClick:()=>{w(E),u(!1)},children:["✋",p]},E))})]})]}),!ie&&e.jsx("div",{className:"nice-emoji-picker__categories",role:"tablist",children:b.map(p=>e.jsx("button",{type:"button",className:`nice-emoji-picker__category-btn ${j===p?"nice-emoji-picker__category-btn--selected":""}`,onClick:()=>R(p),title:Ut[p],role:"tab","aria-selected":j===p,children:zi[p]},p))}),e.jsxs("div",{className:"nice-emoji-picker__grid-container",children:[ie?e.jsxs("div",{className:"nice-emoji-picker__section",children:[e.jsx("div",{className:"nice-emoji-picker__section-title",children:ee("searchResults","Search Results")}),e.jsx("div",{className:"nice-emoji-picker__grid",style:{gridTemplateColumns:`repeat(${q}, 1fr)`},children:s.length===0?e.jsx("div",{className:"nice-emoji-picker__empty",children:ee("noEmojis","No emojis found")}):s.map((p,E)=>e.jsx("button",{type:"button",className:"nice-emoji-picker__emoji",onClick:()=>l(p),title:p.name,children:M(p.emoji,p.skinTones)},`${p.emoji}-${E}`))})]}):e.jsxs("div",{className:"nice-emoji-picker__section",children:[e.jsx("div",{className:"nice-emoji-picker__section-title",children:Ut[j]}),e.jsx("div",{className:"nice-emoji-picker__grid",style:{gridTemplateColumns:`repeat(${q}, 1fr)`},children:d.length===0?e.jsx("div",{className:"nice-emoji-picker__empty",children:j==="recent"?ee("noRecent","No recent emojis"):ee("noEmojis","No emojis")}):d.map((p,E)=>e.jsx("button",{type:"button",className:"nice-emoji-picker__emoji",onClick:()=>l(p),title:p.name,children:M(p.emoji,p.skinTones)},`${p.emoji}-${E}`))})]}),X.length>0&&e.jsxs("div",{className:"nice-emoji-picker__section",children:[e.jsx("div",{className:"nice-emoji-picker__section-title",children:ee("custom","Custom")}),e.jsx("div",{className:"nice-emoji-picker__grid",style:{gridTemplateColumns:`repeat(${q}, 1fr)`},children:X.map(p=>e.jsx("button",{type:"button",className:"nice-emoji-picker__emoji nice-emoji-picker__emoji--custom",onClick:()=>c(p),title:p.name,children:e.jsx("img",{src:p.url,alt:p.name})},p.id))})]})]})]})};Nn.displayName="NiceEmojiPicker";const Cn=n.forwardRef(({length:t=6,value:i="",onChange:a,masked:o=!1,onComplete:r,label:h,helperText:x,error:_,required:z,disabled:C,readOnly:X,size:q="md",name:L,id:k,className:J,style:ne,autoFocus:ee,labelPlacement:ie,errorPlacement:I,labelWidth:j,controlWidth:R,loading:f,cellWidth:w,...U},u)=>{const g=y.bc(k),P=n.useRef([]),te=i.padEnd(t,"").slice(0,t).split(""),T=n.useCallback(l=>{const c=Math.max(0,Math.min(t-1,l));P.current[c]?.focus()},[t]),b=n.useCallback(l=>{const c=l.join("");a?.(c),c.length===t&&c.indexOf("")===-1&&/^\d+$/.test(c)&&r?.(c)},[a,r,t]),s=n.useCallback((l,c)=>{const p=c.target.value.replace(/\D/g,"").slice(-1);if(!p)return;const E=[...te];E[l]=p,b(E),T(l+1)},[te,b,T]),$=n.useCallback((l,c)=>{if(c.key==="Backspace"){c.preventDefault();const d=[...te];te[l]?(d[l]="",b(d)):l>0&&(d[l-1]="",b(d),T(l-1))}else c.key==="ArrowLeft"?(c.preventDefault(),T(l-1)):c.key==="ArrowRight"&&(c.preventDefault(),T(l+1))},[te,b,T]),M=n.useCallback(l=>{l.preventDefault();const c=l.clipboardData.getData("text").replace(/\D/g,"").slice(0,t);if(!c)return;const d=c.padEnd(t,"").slice(0,t).split("");for(let p=c.length;p<t;p++)d[p]=te[p]||"";b(d),T(Math.min(c.length,t-1))},[t,te,b,T]);return e.jsxs("div",{className:`nice-field nice-field--${q} nice-field--otp${ie?` nice-field--label-${ie}`:""}${I==="right"?" nice-field--error-right":""} ${f?"nice-field--loading":""} ${J||""}`,style:{...ne,...j!=null&&{"--nice-field-label-width":typeof j=="number"?`${j}px`:j},...R!=null&&{"--nice-field-control-width":typeof R=="number"?`${R}px`:R},...w!=null&&{"--nice-otp-cell-width":typeof w=="number"?`${w}px`:w}},"aria-busy":f||void 0,...U,children:[h&&e.jsx("label",{htmlFor:`${g}-0`,className:`nice-field__label ${z?"nice-field__label--required":""}`,children:h}),e.jsxs("div",{className:"nice-field__control",children:[e.jsxs("div",{ref:u,className:`nice-otp nice-otp--${q} ${_?"nice-otp--error":""} ${C?"nice-otp--disabled":""}`,onPaste:M,children:[Array.from({length:t},(l,c)=>e.jsx("input",{ref:d=>{P.current[c]=d},id:c===0?`${g}-0`:void 0,className:"nice-otp__digit",type:o?"password":"text",inputMode:"numeric",maxLength:2,value:te[c]||"",disabled:C,readOnly:X,autoFocus:ee&&c===0,"aria-invalid":!!_,"aria-label":`${c+1}`,onChange:d=>s(c,d),onKeyDown:d=>$(c,d),onFocus:d=>d.target.select()},c)),L&&e.jsx("input",{type:"hidden",name:L,value:i})]}),I==="right"&&_&&e.jsx("div",{id:`${g}-error`,className:"nice-field__error",role:"alert",children:_}),I==="right"&&!_&&x&&e.jsx("div",{id:`${g}-helper`,className:"nice-field__helper",children:x}),f&&e.jsx("span",{className:"nice-field__spinner",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})})]}),I!=="right"&&_&&e.jsx("div",{id:`${g}-error`,className:"nice-field__error",role:"alert",children:_}),I!=="right"&&!_&&x&&e.jsx("div",{id:`${g}-helper`,className:"nice-field__helper",children:x})]})});Cn.displayName="NiceInputOtp";const Li=[{target:".nice-image-editor",titleKey:"tutorial.imageEditor.intro.title",title:"Image editor",contentKey:"tutorial.imageEditor.intro.content",content:"Use the toolbar to crop, rotate, flip, adjust brightness/contrast and annotate; undo/redo your edits, then save the result.",placement:"auto"}],Xt={rotation:0,flipH:!1,flipV:!1,brightness:100,contrast:100,saturate:100,blur:0,crop:null,annotations:[]},Pi=["crop","rotate","flip","brightness","contrast","saturate","blur","annotate"],Sn=n.forwardRef(({src:t,size:i="md",editorSize:a="standard",tools:o=Pi,showToolbar:r=!0,showZoom:h=!0,maxUndo:x=30,onSave:_,onCancel:z,onChange:C,width:X="100%",height:q=500,tutorial:L,className:k,style:J,id:ne,...ee},ie)=>{const I=y.bc(ne),{t:j}=y.Gt(),R=n.useRef(null),f=n.useRef(null),[w,U]=n.useState({...Xt}),[u,g]=n.useState(null),[P,te]=n.useState(!1),[T,b]=n.useState(1),[s,$]=n.useState("rect"),[M,l]=n.useState("var(--nice-danger, #ff0000)"),[c,d]=n.useState({w:0,h:0}),[p,E]=n.useState([]),[v,B]=n.useState([]),[A,V]=n.useState(null),[N,D]=n.useState(null),[S,ae]=n.useState(null),ue=n.useCallback(H=>{E(Y=>[...Y.slice(-(x-1)),H]),B([])},[x]),ce=n.useCallback(H=>{U(Y=>{ue(Y);const ge={...Y,...H};return C?.(ge),ge})},[C,ue]),be=n.useCallback(()=>{if(p.length===0)return;const H=p[p.length-1];E(Y=>Y.slice(0,-1)),B(Y=>[...Y,w]),U(H),C?.(H)},[p,w,C]),ve=n.useCallback(()=>{if(v.length===0)return;const H=v[v.length-1];B(Y=>Y.slice(0,-1)),E(Y=>[...Y,w]),U(H),C?.(H)},[v,w,C]);n.useEffect(()=>{const H=new Image;H.crossOrigin="anonymous",H.onload=()=>{f.current=H,d({w:H.width,h:H.height}),te(!0)},H.src=t},[t]),n.useEffect(()=>{if(!P||!R.current||!f.current)return;const H=R.current,Y=H.getContext("2d");if(!Y)return;const ge=f.current,le=w.rotation%180!==0,F=le?ge.height:ge.width,Q=le?ge.width:ge.height;H.width=F,H.height=Q,Y.clearRect(0,0,F,Q),Y.save(),Y.filter=`brightness(${w.brightness}%) contrast(${w.contrast}%) saturate(${w.saturate}%) blur(${w.blur}px)`,Y.translate(F/2,Q/2),Y.rotate(w.rotation*Math.PI/180),Y.scale(w.flipH?-1:1,w.flipV?-1:1),Y.drawImage(ge,-ge.width/2,-ge.height/2),Y.restore(),w.annotations.forEach(K=>{switch(Y.save(),Y.strokeStyle=K.color??"red",Y.fillStyle=K.color??"red",Y.lineWidth=K.strokeWidth??2,Y.font=`${K.fontSize??16}px sans-serif`,K.type){case"text":Y.fillText(K.text??"",K.x,K.y);break;case"rect":Y.strokeRect(K.x,K.y,K.width??100,K.height??50);break;case"circle":{const se=(K.width??50)/2,me=(K.height??50)/2;Y.beginPath(),Y.ellipse(K.x+se,K.y+me,se,me,0,0,Math.PI*2),Y.stroke();break}case"line":Y.beginPath(),Y.moveTo(K.x,K.y),Y.lineTo(K.x+(K.width??100),K.y+(K.height??0)),Y.stroke();break;case"arrow":{const se=K.x+(K.width??100),me=K.y+(K.height??0);Y.beginPath(),Y.moveTo(K.x,K.y),Y.lineTo(se,me),Y.stroke();const je=Math.atan2(me-K.y,se-K.x),we=10;Y.beginPath(),Y.moveTo(se,me),Y.lineTo(se-we*Math.cos(je-.4),me-we*Math.sin(je-.4)),Y.lineTo(se-we*Math.cos(je+.4),me-we*Math.sin(je+.4)),Y.closePath(),Y.fill();break}}Y.restore()}),N&&(Y.save(),Y.fillStyle="var(--nice-overlay-50, rgba(0, 0, 0, 0.5))",Y.fillRect(0,0,F,Q),Y.clearRect(N.x,N.y,N.w,N.h),Y.strokeStyle="var(--nice-bg-primary, #fff)",Y.lineWidth=2,Y.setLineDash([5,5]),Y.strokeRect(N.x,N.y,N.w,N.h),Y.restore())},[P,w,N]);const _e=n.useCallback(H=>{if(!R.current)return;const Y=R.current.getBoundingClientRect(),ge=R.current.width/Y.width,le=R.current.height/Y.height,F=(H.clientX-Y.left)*ge,Q=(H.clientY-Y.top)*le;u==="crop"?V({startX:F,startY:Q}):u==="annotate"&&ae({startX:F,startY:Q})},[u]),he=n.useCallback(H=>{if(!R.current)return;const Y=R.current.getBoundingClientRect(),ge=R.current.width/Y.width,le=R.current.height/Y.height,F=(H.clientX-Y.left)*ge,Q=(H.clientY-Y.top)*le;A&&D({x:Math.min(A.startX,F),y:Math.min(A.startY,Q),w:Math.abs(F-A.startX),h:Math.abs(Q-A.startY)})},[A]),ye=n.useCallback(H=>{if(A&&N&&N.w>5&&N.h>5&&ce({crop:{x:N.x,y:N.y,width:N.w,height:N.h}}),V(null),S&&R.current){const Y=R.current.getBoundingClientRect(),ge=R.current.width/Y.width,le=R.current.height/Y.height,F=(H.clientX-Y.left)*ge,Q=(H.clientY-Y.top)*le,K=F-S.startX,se=Q-S.startY;if(Math.abs(K)>3||Math.abs(se)>3||s==="text"){const me={type:s,x:S.startX,y:S.startY,width:Math.abs(K)||100,height:Math.abs(se)||50,color:M,strokeWidth:2,text:s==="text"?prompt(j("imageEditor.annotationText","Text:"))??"":void 0};ce({annotations:[...w.annotations,me]})}ae(null)}},[A,N,S,s,M,w.annotations,ce,j]),xe=n.useCallback(()=>{if(!w.crop||!R.current)return;const H=R.current,Y=H.getContext("2d");if(!Y)return;const{x:ge,y:le,width:F,height:Q}=w.crop,K=Y.getImageData(ge,le,F,Q);H.width=F,H.height=Q,Y.putImageData(K,0,0),D(null),g(null)},[w.crop]),re=n.useCallback(()=>{if(!R.current)return;const H=R.current.toDataURL("image/png");_?.(H,w)},[_,w]),Z=n.useCallback(()=>{U({...Xt}),D(null),g(null)},[]);n.useMemo(()=>`brightness(${w.brightness}%) contrast(${w.contrast}%) saturate(${w.saturate}%) blur(${w.blur}px)`,[w.brightness,w.contrast,w.saturate,w.blur]);const de=r?e.jsxs("div",{className:"nice-image-editor__toolbar",role:"toolbar",children:[e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:be,disabled:p.length===0,title:j("imageEditor.undo","Undo"),"aria-label":j("imageEditor.undo","Undo"),children:e.jsx(y.oa,{name:"reply",size:16})}),e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:ve,disabled:v.length===0,title:j("imageEditor.redo","Redo"),"aria-label":j("imageEditor.redo","Redo"),children:e.jsx(y.oa,{name:"forward",size:16})}),e.jsx("span",{className:"nice-image-editor__sep"}),o.includes("rotate")&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>ce({rotation:(w.rotation-90+360)%360}),title:j("imageEditor.rotateLeft","Rotate left"),"aria-label":j("imageEditor.rotateLeft","Rotate left"),children:e.jsx(y.oa,{name:"reply",size:16})}),e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>ce({rotation:(w.rotation+90)%360}),title:j("imageEditor.rotateRight","Rotate right"),"aria-label":j("imageEditor.rotateRight","Rotate right"),children:e.jsx(y.oa,{name:"forward",size:16})})]}),o.includes("flip")&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>ce({flipH:!w.flipH}),title:j("imageEditor.flipH","Flip horizontal"),"aria-label":j("imageEditor.flipH","Flip horizontal"),children:e.jsx(y.oa,{name:"shuffle",size:16})}),e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>ce({flipV:!w.flipV}),title:j("imageEditor.flipV","Flip vertical"),"aria-label":j("imageEditor.flipV","Flip vertical"),children:e.jsx(y.oa,{name:"shuffle",size:16})})]}),o.includes("crop")&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:`nice-image-editor__btn ${u==="crop"?"nice-image-editor__btn--active":""}`,onClick:()=>g(u==="crop"?null:"crop"),title:j("imageEditor.crop","Crop"),"aria-label":j("imageEditor.crop","Crop"),children:e.jsx(y.oa,{name:"box",size:16})}),u==="crop"&&w.crop&&e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:xe,title:j("imageEditor.applyCrop","Apply crop"),"aria-label":j("imageEditor.applyCrop","Apply crop"),children:e.jsx(y.oa,{name:"check",size:16})})]}),o.includes("brightness")&&e.jsxs("label",{className:"nice-image-editor__slider-label",title:j("imageEditor.brightness","Brightness"),children:[e.jsx(y.oa,{name:"lightbulb",size:16}),e.jsx("input",{type:"range",min:0,max:200,value:w.brightness,onChange:H=>ce({brightness:Number(H.target.value)}),className:"nice-image-editor__slider",title:j("imageEditor.brightness","Brightness")})]}),o.includes("contrast")&&e.jsxs("label",{className:"nice-image-editor__slider-label",title:j("imageEditor.contrast","Contrast"),children:[e.jsx(y.oa,{name:"circle",size:16}),e.jsx("input",{type:"range",min:0,max:200,value:w.contrast,onChange:H=>ce({contrast:Number(H.target.value)}),className:"nice-image-editor__slider",title:j("imageEditor.contrast","Contrast")})]}),o.includes("saturate")&&e.jsxs("label",{className:"nice-image-editor__slider-label",title:j("imageEditor.saturate","Saturation"),children:[e.jsx(y.oa,{name:"palette",size:16}),e.jsx("input",{type:"range",min:0,max:200,value:w.saturate,onChange:H=>ce({saturate:Number(H.target.value)}),className:"nice-image-editor__slider",title:j("imageEditor.saturate","Saturation")})]}),o.includes("blur")&&e.jsxs("label",{className:"nice-image-editor__slider-label",title:j("imageEditor.blur","Blur"),children:[e.jsx(y.oa,{name:"eye-off",size:16}),e.jsx("input",{type:"range",min:0,max:20,step:.5,value:w.blur,onChange:H=>ce({blur:Number(H.target.value)}),className:"nice-image-editor__slider",title:j("imageEditor.blur","Blur")})]}),o.includes("annotate")&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"nice-image-editor__sep"}),e.jsx("button",{type:"button",className:`nice-image-editor__btn ${u==="annotate"?"nice-image-editor__btn--active":""}`,onClick:()=>g(u==="annotate"?null:"annotate"),title:j("imageEditor.annotate","Annotate"),"aria-label":j("imageEditor.annotate","Annotate"),children:e.jsx(y.oa,{name:"edit",size:16})}),u==="annotate"&&e.jsxs(e.Fragment,{children:[e.jsxs("select",{className:"nice-image-editor__select",value:s,onChange:H=>$(H.target.value),children:[e.jsx("option",{value:"rect",children:"Rect"}),e.jsx("option",{value:"circle",children:"Circle"}),e.jsx("option",{value:"line",children:"Line"}),e.jsx("option",{value:"arrow",children:"Arrow"}),e.jsx("option",{value:"text",children:"Text"})]}),e.jsx("input",{type:"color",value:M,onChange:H=>l(H.target.value),className:"nice-image-editor__color",title:j("imageEditor.color","Color")}),w.annotations.length>0&&e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>ce({annotations:w.annotations.slice(0,-1)}),title:j("imageEditor.removeLastAnnotation","Remove last"),"aria-label":j("imageEditor.removeLastAnnotation","Remove last"),children:e.jsx(y.oa,{name:"trash",size:16})})]})]}),e.jsx("span",{className:"nice-image-editor__sep"}),e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:Z,title:j("imageEditor.reset","Reset"),"aria-label":j("imageEditor.reset","Reset"),children:e.jsx(y.oa,{name:"refresh",size:16})}),_&&e.jsx("button",{type:"button",className:"nice-image-editor__btn nice-image-editor__btn--save",onClick:re,children:j("imageEditor.save","Save")}),z&&e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:z,children:j("imageEditor.cancel","Cancel")})]}):void 0,O=h?e.jsxs("div",{className:"nice-image-editor__footer",children:[e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>b(H=>Math.max(.1,H-.1)),title:"Zoom out","aria-label":"Zoom out",children:e.jsx(y.oa,{name:"minus",size:16})}),e.jsxs("span",{style:{fontSize:"0.85em",minWidth:40,textAlign:"center"},children:[Math.round(T*100),"%"]}),e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>b(H=>Math.min(5,H+.1)),title:"Zoom in","aria-label":"Zoom in",children:e.jsx(y.oa,{name:"plus",size:16})}),e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>b(1),title:"Reset zoom",children:"1:1"}),e.jsx("span",{style:{flex:1}}),e.jsxs("span",{style:{fontSize:"0.8em",color:"var(--nice-text-secondary, #666)"},children:[c.w,"×",c.h,"px · ",w.rotation,"°"]})]}):void 0;return e.jsx(Qt.NiceAppShell,{ref:ie,flush:!0,id:I,className:`nice-image-editor nice-image-editor--${i} nice-editor--${a} ${k??""}`,style:{...J,width:X,height:q},toolbar:de,statusBar:O,children:e.jsxs("div",{className:"nice-image-editor__canvas-wrap",style:{position:"relative"},role:"application","aria-label":j("imageEditor.label","Image Editor"),...ee,children:[e.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:20},children:e.jsx(y.Ql,{steps:y.Yl(L,Li)})}),e.jsx("canvas",{ref:R,className:"nice-image-editor__canvas",onMouseDown:_e,onMouseMove:he,onMouseUp:ye,style:{cursor:u==="crop"||u==="annotate"?"crosshair":"default",transform:`scale(${T})`,transformOrigin:"center center"}})]})})});Sn.displayName="NiceImageEditor";const Bi={strokeColor:"#ff3333",fillColor:"transparent",strokeWidth:2,opacity:1,fontSize:16,fontFamily:"sans-serif"};function Hi(t,i){switch(i.type){case"SET_TOOL":return{...t,activeTool:i.tool,selectedId:null};case"SET_STYLE":return{...t,style:{...t.style,...i.style}};case"ADD_ANNOTATION":return{...t,annotations:[...t.annotations,i.annotation],past:[...t.past,t.annotations],future:[]};case"UPDATE_ANNOTATION":return{...t,annotations:t.annotations.map(a=>a.id===i.id?{...a,...i.updates}:a),past:[...t.past,t.annotations],future:[]};case"DELETE_ANNOTATION":return{...t,annotations:t.annotations.filter(a=>a.id!==i.id),selectedId:t.selectedId===i.id?null:t.selectedId,past:[...t.past,t.annotations],future:[]};case"SELECT":return{...t,selectedId:i.id};case"SET_ANNOTATIONS":return{...t,annotations:i.annotations,past:[],future:[]};case"SET_ZOOM":return{...t,zoom:i.zoom};case"SET_PAN":return{...t,panX:i.panX,panY:i.panY};case"UNDO":{if(t.past.length===0)return t;const a=t.past[t.past.length-1];return{...t,annotations:a,past:t.past.slice(0,-1),future:[t.annotations,...t.future]}}case"REDO":{if(t.future.length===0)return t;const a=t.future[0];return{...t,annotations:a,past:[...t.past,t.annotations],future:t.future.slice(1)}}case"CLEAR":return{...t,annotations:[],selectedId:null,past:[...t.past,t.annotations],future:[]};default:return t}}let Oi=0;function Fi(){return`ann-${Date.now()}-${Oi++}`}function Yi(t){const{style:i}=t,a=`stroke="${i.strokeColor}" stroke-width="${i.strokeWidth}" fill="${i.fillColor}" opacity="${i.opacity}"`;switch(t.tool){case"rectangle":return`<rect x="${t.x}" y="${t.y}" width="${t.width}" height="${t.height}" ${a} />`;case"ellipse":{const o=t.x+t.width/2,r=t.y+t.height/2;return`<ellipse cx="${o}" cy="${r}" rx="${t.width/2}" ry="${t.height/2}" ${a} />`}case"arrow":{const o=t,r=Math.atan2(o.endY-o.y,o.endX-o.x),h=12,x=o.endX-h*Math.cos(r-Math.PI/6),_=o.endY-h*Math.sin(r-Math.PI/6),z=o.endX-h*Math.cos(r+Math.PI/6),C=o.endY-h*Math.sin(r+Math.PI/6);return`<line x1="${o.x}" y1="${o.y}" x2="${o.endX}" y2="${o.endY}" ${a} />
300
+ <polygon points="${o.endX},${o.endY} ${x},${_} ${z},${C}" fill="${i.strokeColor}" opacity="${i.opacity}" />`}case"line":{const o=t;return`<line x1="${o.x}" y1="${o.y}" x2="${o.endX}" y2="${o.endY}" ${a} />`}case"text":{const o=t;return`<text x="${o.x}" y="${o.y+(o.style.fontSize??16)}" fill="${i.strokeColor}" font-size="${i.fontSize}" font-family="${i.fontFamily}" opacity="${i.opacity}">${Ki(o.text)}</text>`}case"freehand":{const o=t;return o.points.length<2?"":`<path d="${o.points.map((h,x)=>`${x===0?"M":"L"}${h.x},${h.y}`).join(" ")}" ${a} fill="none" />`}case"blur":{const o=t,r=`blur-${o.id}`;return`<defs><filter id="${r}"><feGaussianBlur stdDeviation="${o.intensity??5}" /></filter></defs>
301
+ <rect x="${o.x}" y="${o.y}" width="${o.width}" height="${o.height}" fill="transparent" stroke="none" filter="url(#${r})" />`}default:return""}}function Ki(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}const $n=n.forwardRef(({src:t,alt:i="Annotatable image",annotations:a,activeTool:o,defaultStyle:r,onAnnotationsChange:h,className:x,readOnly:_=!1,minZoom:z=.1,maxZoom:C=5},X)=>{const q=n.useRef(null),L=n.useRef(null),k=n.useRef(null),[J,ne]=n.useState(!1),[ee,ie]=n.useState({width:0,height:0}),[I,j]=n.useReducer(Hi,{annotations:a??[],selectedId:null,activeTool:o??"select",style:{...Bi,...r},zoom:1,panX:0,panY:0,past:[],future:[]});n.useEffect(()=>{o&&j({type:"SET_TOOL",tool:o})},[o]),n.useEffect(()=>{h?.(I.annotations)},[I.annotations,h]),n.useEffect(()=>{const b=new Image;b.crossOrigin="anonymous",b.onload=()=>{k.current=b,ie({width:b.naturalWidth,height:b.naturalHeight}),ne(!0)},b.src=t},[t]);const R=n.useRef({isDrawing:!1,startX:0,startY:0,currentAnnotation:null,freehandPoints:[]}),f=n.useCallback((b,s)=>{const $=q.current;if(!$)return{x:0,y:0};const M=$.getBoundingClientRect();return{x:(b-M.left-I.panX)/I.zoom,y:(s-M.top-I.panY)/I.zoom}},[I.zoom,I.panX,I.panY]),w=n.useCallback(()=>{const b=q.current,s=b?.getContext("2d"),$=k.current;if(!b||!s||!$||!J)return;b.width=L.current?.clientWidth??$.naturalWidth,b.height=L.current?.clientHeight??$.naturalHeight,s.clearRect(0,0,b.width,b.height),s.save(),s.translate(I.panX,I.panY),s.scale(I.zoom,I.zoom),s.drawImage($,0,0);for(const l of I.annotations){switch(s.save(),s.globalAlpha=l.style.opacity,s.strokeStyle=l.style.strokeColor,s.fillStyle=l.style.fillColor,s.lineWidth=l.style.strokeWidth,l.tool){case"rectangle":s.strokeRect(l.x,l.y,l.width,l.height),l.style.fillColor!=="transparent"&&s.fillRect(l.x,l.y,l.width,l.height);break;case"ellipse":{s.beginPath(),s.ellipse(l.x+l.width/2,l.y+l.height/2,Math.abs(l.width/2),Math.abs(l.height/2),0,0,Math.PI*2),s.stroke(),l.style.fillColor!=="transparent"&&s.fill();break}case"arrow":{const c=l;s.beginPath(),s.moveTo(c.x,c.y),s.lineTo(c.endX,c.endY),s.stroke();const d=Math.atan2(c.endY-c.y,c.endX-c.x),p=12;s.beginPath(),s.moveTo(c.endX,c.endY),s.lineTo(c.endX-p*Math.cos(d-Math.PI/6),c.endY-p*Math.sin(d-Math.PI/6)),s.lineTo(c.endX-p*Math.cos(d+Math.PI/6),c.endY-p*Math.sin(d+Math.PI/6)),s.closePath(),s.fillStyle=l.style.strokeColor,s.fill();break}case"line":{const c=l;s.beginPath(),s.moveTo(c.x,c.y),s.lineTo(c.endX,c.endY),s.stroke();break}case"text":{const c=l;s.font=`${c.style.fontSize??16}px ${c.style.fontFamily??"sans-serif"}`,s.fillStyle=c.style.strokeColor,s.fillText(c.text,c.x,c.y+(c.style.fontSize??16));break}case"freehand":{const c=l;if(c.points.length<2)break;s.beginPath(),s.moveTo(c.points[0].x,c.points[0].y);for(let d=1;d<c.points.length;d++)s.lineTo(c.points[d].x,c.points[d].y);s.stroke();break}case"blur":{const c=l;s.filter=`blur(${c.intensity??5}px)`,s.drawImage($,c.x,c.y,c.width,c.height,c.x,c.y,c.width,c.height),s.filter="none";break}}l.id===I.selectedId&&(s.strokeStyle="#4488ff",s.lineWidth=1,s.setLineDash([4,4]),s.strokeRect(l.x-2,l.y-2,l.width+4,l.height+4),s.setLineDash([])),s.restore()}const M=R.current;if(M.isDrawing&&M.currentAnnotation){s.save();const l=M.currentAnnotation;if(s.globalAlpha=l.style.opacity,s.strokeStyle=l.style.strokeColor,s.lineWidth=l.style.strokeWidth,s.setLineDash([6,3]),l.tool==="freehand"){const c=l;if(c.points.length>=2){s.beginPath(),s.moveTo(c.points[0].x,c.points[0].y);for(let d=1;d<c.points.length;d++)s.lineTo(c.points[d].x,c.points[d].y);s.stroke()}}else if(l.tool==="rectangle")s.strokeRect(l.x,l.y,l.width,l.height);else if(l.tool==="ellipse")s.beginPath(),s.ellipse(l.x+l.width/2,l.y+l.height/2,Math.abs(l.width/2),Math.abs(l.height/2),0,0,Math.PI*2),s.stroke();else if(l.tool==="arrow"||l.tool==="line"){const c=l;s.beginPath(),s.moveTo(c.x,c.y),s.lineTo(c.endX,c.endY),s.stroke()}s.restore()}s.restore()},[I,J]);n.useEffect(()=>{w()},[w]);const U=n.useCallback(b=>{if(_)return;const s=f(b.clientX,b.clientY),$=I.activeTool;if($==="select"){const c=[...I.annotations].reverse().find(d=>d.tool==="freehand"?!1:s.x>=d.x&&s.x<=d.x+d.width&&s.y>=d.y&&s.y<=d.y+d.height);j({type:"SELECT",id:c?.id??null});return}const M=R.current;M.isDrawing=!0,M.startX=s.x,M.startY=s.y;const l={id:Fi(),style:{...I.style},x:s.x,y:s.y,width:0,height:0};switch($){case"rectangle":M.currentAnnotation={...l,tool:"rectangle"};break;case"ellipse":M.currentAnnotation={...l,tool:"ellipse"};break;case"arrow":M.currentAnnotation={...l,tool:"arrow",endX:s.x,endY:s.y};break;case"line":M.currentAnnotation={...l,tool:"line",endX:s.x,endY:s.y};break;case"text":M.currentAnnotation={...l,tool:"text",text:"Text",width:100,height:I.style.fontSize??16};break;case"freehand":M.freehandPoints=[s],M.currentAnnotation={...l,tool:"freehand",points:[s]};break;case"blur":M.currentAnnotation={...l,tool:"blur",intensity:5};break}},[_,f,I.activeTool,I.style,I.annotations]),u=n.useCallback(b=>{const s=R.current;if(!s.isDrawing||!s.currentAnnotation)return;const $=f(b.clientX,b.clientY),M=s.currentAnnotation;if(M.tool==="freehand"){s.freehandPoints.push($),M.points=[...s.freehandPoints];const l=s.freehandPoints.map(d=>d.x),c=s.freehandPoints.map(d=>d.y);M.x=Math.min(...l),M.y=Math.min(...c),M.width=Math.max(...l)-M.x,M.height=Math.max(...c)-M.y}else if(M.tool==="arrow"||M.tool==="line")M.endX=$.x,M.endY=$.y,M.width=Math.abs($.x-s.startX),M.height=Math.abs($.y-s.startY);else{const l=Math.min(s.startX,$.x),c=Math.min(s.startY,$.y);M.x=l,M.y=c,M.width=Math.abs($.x-s.startX),M.height=Math.abs($.y-s.startY)}w()},[f,w]),g=n.useCallback(()=>{const b=R.current;if(!b.isDrawing||!b.currentAnnotation)return;const s=b.currentAnnotation;(s.tool==="text"||s.tool==="freehand"||Math.abs(s.width)>2||Math.abs(s.height)>2)&&j({type:"ADD_ANNOTATION",annotation:s}),b.isDrawing=!1,b.currentAnnotation=null,b.freehandPoints=[]},[]),P=n.useCallback(b=>{b.preventDefault();const s=b.deltaY>0?.9:1.1,$=Math.max(z,Math.min(C,I.zoom*s));j({type:"SET_ZOOM",zoom:$})},[I.zoom,z,C]);n.useEffect(()=>{if(_)return;const b=s=>{(s.metaKey||s.ctrlKey)&&s.key==="z"&&!s.shiftKey?(s.preventDefault(),j({type:"UNDO"})):(s.metaKey||s.ctrlKey)&&(s.key==="y"||s.key==="z"&&s.shiftKey)?(s.preventDefault(),j({type:"REDO"})):(s.key==="Delete"||s.key==="Backspace")&&I.selectedId&&j({type:"DELETE_ANNOTATION",id:I.selectedId})};return document.addEventListener("keydown",b),()=>document.removeEventListener("keydown",b)},[_,I.selectedId]),n.useImperativeHandle(X,()=>({exportAsDataURL:async(b="png",s=.92)=>{const $=document.createElement("canvas"),M=k.current;if(!M)return"";$.width=M.naturalWidth,$.height=M.naturalHeight;const l=$.getContext("2d");l.drawImage(M,0,0);for(const c of I.annotations){if(l.save(),l.globalAlpha=c.style.opacity,l.strokeStyle=c.style.strokeColor,l.fillStyle=c.style.fillColor,l.lineWidth=c.style.strokeWidth,c.tool==="rectangle")l.strokeRect(c.x,c.y,c.width,c.height);else if(c.tool==="ellipse")l.beginPath(),l.ellipse(c.x+c.width/2,c.y+c.height/2,Math.abs(c.width/2),Math.abs(c.height/2),0,0,Math.PI*2),l.stroke();else if(c.tool==="freehand"){const d=c;if(d.points.length>=2){l.beginPath(),l.moveTo(d.points[0].x,d.points[0].y);for(let p=1;p<d.points.length;p++)l.lineTo(d.points[p].x,d.points[p].y);l.stroke()}}else if(c.tool==="text"){const d=c;l.font=`${d.style.fontSize??16}px ${d.style.fontFamily??"sans-serif"}`,l.fillStyle=d.style.strokeColor,l.fillText(d.text,d.x,d.y+(d.style.fontSize??16))}l.restore()}return $.toDataURL(`image/${b}`,s)},exportAnnotations:()=>[...I.annotations],importAnnotations:b=>{j({type:"SET_ANNOTATIONS",annotations:b})},exportAsSVG:()=>{const{width:b,height:s}=ee,$=I.annotations.map(Yi);return`<svg xmlns="http://www.w3.org/2000/svg" width="${b}" height="${s}" viewBox="0 0 ${b} ${s}">
302
+ ${$.join(`
303
+ `)}
304
+ </svg>`},undo:()=>j({type:"UNDO"}),redo:()=>j({type:"REDO"}),setZoom:b=>{j({type:"SET_ZOOM",zoom:Math.max(z,Math.min(C,b))})},fitToScreen:()=>{const b=L.current,s=k.current;if(!b||!s)return;const $=b.clientWidth/s.naturalWidth,M=b.clientHeight/s.naturalHeight,l=Math.min($,M,1);j({type:"SET_ZOOM",zoom:l}),j({type:"SET_PAN",panX:0,panY:0})},clear:()=>j({type:"CLEAR"})}),[I.annotations,ee,z,C]);const te=n.useCallback(b=>{if(b.touches.length!==1)return;const s=b.touches[0];U({clientX:s.clientX,clientY:s.clientY,preventDefault:()=>{}})},[U]),T=n.useCallback(b=>{if(b.touches.length!==1)return;const s=b.touches[0];u({clientX:s.clientX,clientY:s.clientY})},[u]);return e.jsx("div",{ref:L,className:`nice-image-annotator ${x??""}`,style:{position:"relative",overflow:"hidden",width:"100%",height:"100%"},children:e.jsx("canvas",{ref:q,className:"nice-image-annotator__canvas",style:{cursor:I.activeTool==="select"?"default":"crosshair"},onMouseDown:U,onMouseMove:u,onMouseUp:g,onMouseLeave:g,onWheel:P,onTouchStart:te,onTouchMove:T,onTouchEnd:g,role:"img","aria-label":i})})});$n.displayName="NiceImageAnnotator";const Ui=[{target:".nice-crop-editor",titleKey:"tutorial.cropEditor.intro.title",title:"Crop editor",contentKey:"tutorial.cropEditor.intro.content",content:"Drag the crop box over the image, pick an aspect ratio, rotate, flip or zoom, then use the result.",placement:"auto"}],En=[{label:"Free",value:"free"},{label:"1:1",value:"1:1",ratio:1},{label:"4:3",value:"4:3",ratio:4/3},{label:"3:4",value:"3:4",ratio:3/4},{label:"16:9",value:"16:9",ratio:16/9},{label:"9:16",value:"9:16",ratio:9/16},{label:"3:2",value:"3:2",ratio:3/2},{label:"2:3",value:"2:3",ratio:2/3}],Mn=({src:t,initialCrop:i={x:10,y:10,width:80,height:80},initialRotation:a=0,initialZoom:o=1,aspectRatios:r=En,defaultAspectRatio:h="free",customAspectRatio:x,showRotation:_=!0,showFlip:z=!0,showZoom:C=!0,minZoom:X=.5,maxZoom:q=3,zoomStep:L=.1,showGrid:k=!0,overlayColor:J="var(--nice-overlay-50, rgba(0, 0, 0, 0.5))",toolbarPosition:ne="bottom",toolbarCollapsible:ee=!1,defaultToolbarCollapsed:ie=!1,onChange:I,tutorial:j,className:R="",style:f,"data-testid":w="nice-crop-editor"})=>{const{t:U}=y.Gt(),u=n.useRef(null),g=n.useRef(null),[P,te]=n.useState(i),[T,b]=n.useState(a),[s,$]=n.useState(o),[M,l]=n.useState(!1),[c,d]=n.useState(!1),[p,E]=n.useState(h),[v,B]=n.useState(ie),[A,V]=n.useState(!1),[N,D]=n.useState({x:0,y:0,crop:P}),S=p==="custom"?x:r.find(O=>O.value===p)?.ratio;n.useEffect(()=>{I?.({crop:P,rotation:T,flipH:M,flipV:c,zoom:s})},[P,T,M,c,s,I]);const ae=n.useCallback((O,H)=>{if(!S)return O;const Y=u.current?.clientWidth??400,ge=u.current?.clientHeight??300,le=O.width/100*Y,F=O.height/100*ge,Q=le/F;if(Math.abs(Q-S)<.01)return O;if(H?.includes("e")||H?.includes("w")){const se=le/S/ge*100;return{...O,height:Math.min(100-O.y,Math.max(5,se))}}else if(H?.includes("n")||H?.includes("s")){const se=F*S/Y*100;return{...O,width:Math.min(100-O.x,Math.max(5,se))}}else{const se=le/S/ge*100;return{...O,height:Math.min(100-O.y,Math.max(5,se))}}},[S]),ue=n.useCallback((O,H)=>{H===!1||(O.preventDefault(),O.stopPropagation(),V(H),!u.current?.getBoundingClientRect())||D({x:O.clientX,y:O.clientY,crop:{...P}})},[P]),ce=n.useCallback(O=>{if(!A||!u.current)return;const H=u.current.getBoundingClientRect(),Y=(O.clientX-N.x)/H.width*100,ge=(O.clientY-N.y)/H.height*100;let le={...N.crop};if(A==="crop")le.x=Math.max(0,Math.min(100-le.width,N.crop.x+Y)),le.y=Math.max(0,Math.min(100-le.height,N.crop.y+ge));else{switch(A){case"resize-nw":le.x=Math.max(0,Math.min(N.crop.x+N.crop.width-5,N.crop.x+Y)),le.y=Math.max(0,Math.min(N.crop.y+N.crop.height-5,N.crop.y+ge)),le.width=N.crop.width-(le.x-N.crop.x),le.height=N.crop.height-(le.y-N.crop.y);break;case"resize-ne":le.y=Math.max(0,Math.min(N.crop.y+N.crop.height-5,N.crop.y+ge)),le.width=Math.max(5,Math.min(100-le.x,N.crop.width+Y)),le.height=N.crop.height-(le.y-N.crop.y);break;case"resize-sw":le.x=Math.max(0,Math.min(N.crop.x+N.crop.width-5,N.crop.x+Y)),le.width=N.crop.width-(le.x-N.crop.x),le.height=Math.max(5,Math.min(100-le.y,N.crop.height+ge));break;case"resize-se":le.width=Math.max(5,Math.min(100-le.x,N.crop.width+Y)),le.height=Math.max(5,Math.min(100-le.y,N.crop.height+ge));break;case"resize-n":le.y=Math.max(0,Math.min(N.crop.y+N.crop.height-5,N.crop.y+ge)),le.height=N.crop.height-(le.y-N.crop.y);break;case"resize-s":le.height=Math.max(5,Math.min(100-le.y,N.crop.height+ge));break;case"resize-e":le.width=Math.max(5,Math.min(100-le.x,N.crop.width+Y));break;case"resize-w":le.x=Math.max(0,Math.min(N.crop.x+N.crop.width-5,N.crop.x+Y)),le.width=N.crop.width-(le.x-N.crop.x);break}le=ae(le,A.replace("resize-",""))}te(le)},[A,N,ae]),be=n.useCallback(()=>{V(!1)},[]);n.useEffect(()=>{if(A)return document.addEventListener("mousemove",ce),document.addEventListener("mouseup",be),()=>{document.removeEventListener("mousemove",ce),document.removeEventListener("mouseup",be)}},[A,ce,be]);const ve=n.useCallback(()=>{b(O=>(O-90+360)%360)},[]),_e=n.useCallback(()=>{b(O=>(O+90)%360)},[]),he=n.useCallback(()=>{l(O=>!O)},[]),ye=n.useCallback(()=>{d(O=>!O)},[]),xe=n.useCallback(()=>{te(i),b(a),$(o),l(!1),d(!1),E(h)},[i,a,o,h]);n.useEffect(()=>{te(O=>ae(O))},[p,ae]);const re=`scale(${s}) rotate(${T}deg) scaleX(${M?-1:1}) scaleY(${c?-1:1})`,Z=ne==="top"?"column-reverse":ne==="left"?"row-reverse":ne==="right"?"row":"column",de=ne==="left"||ne==="right";return e.jsxs("div",{className:`nice-crop-editor nice-crop-editor--toolbar-${ne} ${R}`,style:{position:"relative",display:"flex",flexDirection:Z,gap:12,...f},"data-testid":w,children:[e.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:20},children:e.jsx(y.Ql,{steps:y.Yl(j,Ui)})}),e.jsxs("div",{ref:u,className:"nice-crop-editor__container","data-testid":`${w}-container`,children:[e.jsx("img",{ref:g,src:t,alt:"",className:"nice-crop-editor__image",style:{transform:re},draggable:!1}),e.jsxs("div",{className:"nice-crop-editor__overlay",style:{backgroundColor:J},children:[e.jsx("div",{className:"nice-crop-editor__overlay-piece",style:{top:0,left:0,right:0,height:`${P.y}%`}}),e.jsx("div",{className:"nice-crop-editor__overlay-piece",style:{bottom:0,left:0,right:0,height:`${100-P.y-P.height}%`}}),e.jsx("div",{className:"nice-crop-editor__overlay-piece",style:{top:`${P.y}%`,left:0,width:`${P.x}%`,height:`${P.height}%`}}),e.jsx("div",{className:"nice-crop-editor__overlay-piece",style:{top:`${P.y}%`,right:0,width:`${100-P.x-P.width}%`,height:`${P.height}%`}})]}),e.jsxs("div",{className:"nice-crop-editor__crop-area",style:{left:`${P.x}%`,top:`${P.y}%`,width:`${P.width}%`,height:`${P.height}%`},onMouseDown:O=>ue(O,"crop"),"data-testid":`${w}-crop-area`,children:[k&&e.jsxs("div",{className:"nice-crop-editor__grid",children:[e.jsx("div",{className:"nice-crop-editor__grid-line nice-crop-editor__grid-line--h1"}),e.jsx("div",{className:"nice-crop-editor__grid-line nice-crop-editor__grid-line--h2"}),e.jsx("div",{className:"nice-crop-editor__grid-line nice-crop-editor__grid-line--v1"}),e.jsx("div",{className:"nice-crop-editor__grid-line nice-crop-editor__grid-line--v2"})]}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--nw",onMouseDown:O=>ue(O,"resize-nw")}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--ne",onMouseDown:O=>ue(O,"resize-ne")}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--sw",onMouseDown:O=>ue(O,"resize-sw")}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--se",onMouseDown:O=>ue(O,"resize-se")}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--n",onMouseDown:O=>ue(O,"resize-n")}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--s",onMouseDown:O=>ue(O,"resize-s")}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--e",onMouseDown:O=>ue(O,"resize-e")}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--w",onMouseDown:O=>ue(O,"resize-w")})]})]}),e.jsxs("div",{className:`nice-crop-editor__controls ${v?"nice-crop-editor__controls--collapsed":""}`,style:{display:"flex",flexDirection:de?"column":"row",flexWrap:de?"nowrap":"wrap",gap:8,alignItems:de?"stretch":"center",flexShrink:0},children:[ee&&e.jsx("button",{type:"button",className:"nice-crop-editor__toolbar-toggle","aria-expanded":!v,"aria-label":v?"Show toolbar":"Hide toolbar",onClick:()=>B(O=>!O),style:{alignSelf:"flex-start",background:"var(--nice-bg-secondary)",border:"1px solid var(--nice-border-color)",borderRadius:4,padding:"2px 8px",cursor:"pointer",color:"var(--nice-text-primary)",fontSize:12},children:e.jsx(y.oa,{name:v?"chevron-right":"chevron-down",size:14})}),!v&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"nice-crop-editor__control-group",children:[e.jsx("label",{className:"nice-crop-editor__label",children:U("aspectRatio","Aspect Ratio")}),e.jsx("div",{className:"nice-crop-editor__aspect-buttons",children:r.map(O=>e.jsx("button",{type:"button",className:`nice-crop-editor__aspect-btn ${p===O.value?"nice-crop-editor__aspect-btn--selected":""}`,onClick:()=>E(O.value),title:O.label,children:O.label},O.value))})]}),C&&e.jsxs("div",{className:"nice-crop-editor__control-group",children:[e.jsxs("label",{className:"nice-crop-editor__label",children:[U("zoom","Zoom"),": ",Math.round(s*100),"%"]}),e.jsx("input",{type:"range",className:"nice-crop-editor__slider",min:X,max:q,step:L,value:s,onChange:O=>$(parseFloat(O.target.value)),"data-testid":`${w}-zoom`})]}),e.jsxs("div",{className:"nice-crop-editor__control-group nice-crop-editor__control-group--row",children:[_&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"nice-crop-editor__btn",onClick:ve,title:U("rotateLeft","Rotate Left"),"aria-label":U("rotateLeft","Rotate Left"),children:e.jsx(y.oa,{name:"reply",size:16})}),e.jsx("button",{type:"button",className:"nice-crop-editor__btn",onClick:_e,title:U("rotateRight","Rotate Right"),"aria-label":U("rotateRight","Rotate Right"),children:e.jsx(y.oa,{name:"forward",size:16})})]}),z&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:`nice-crop-editor__btn ${M?"nice-crop-editor__btn--active":""}`,onClick:he,title:U("flipHorizontal","Flip Horizontal"),"aria-label":U("flipHorizontal","Flip Horizontal"),children:e.jsx(y.oa,{name:"shuffle",size:16})}),e.jsx("button",{type:"button",className:`nice-crop-editor__btn ${c?"nice-crop-editor__btn--active":""}`,onClick:ye,title:U("flipVertical","Flip Vertical"),"aria-label":U("flipVertical","Flip Vertical"),children:e.jsx(y.oa,{name:"shuffle",size:16})})]}),e.jsx("button",{type:"button",className:"nice-crop-editor__btn nice-crop-editor__btn--reset",onClick:xe,title:U("reset","Reset"),"aria-label":U("reset","Reset"),children:e.jsx(y.oa,{name:"refresh",size:16})})]})]})]})]})};Mn.displayName="NiceCropEditor";const Gi=[{target:".nice-pdf-annotation",titleKey:"tutorial.pdfAnnotationEditor.intro.title",title:"PDF annotations",contentKey:"tutorial.pdfAnnotationEditor.intro.content",content:"Pick a tool from the toolbar (highlight, underline, freehand, text…), mark up the page, navigate pages and zoom as needed.",placement:"auto"}],Xi=["highlight","underline","strikethrough","freehand","text","rect","arrow"],qi={highlight:"edit",underline:"type",strikethrough:"type",freehand:"edit",text:"type",rect:"box",arrow:"arrow-right",stamp:"tag"},Rn=n.forwardRef(({label:t,helperText:i,error:a,required:o,disabled:r,readOnly:h,size:x="md",id:_,className:z,style:C,accessMode:X,src:q,annotations:L=[],onAnnotationsChange:k,activeTool:J,onToolChange:ne,currentPage:ee=1,onPageChange:ie,totalPages:I=1,defaultColor:j="var(--nice-warning, #ffff00)",tools:R=Xi,author:f,zoom:w=1,onZoomChange:U,onAnnotationClick:u,onAnnotationDelete:g,tutorial:P},te)=>{const T=y.Dc(X,_),b=T==="hidden";T==="disabled"&&(r=!0),T==="readOnly"&&(h=!0);const{t:s}=y.Gt(),$=y.bc(_),M=L.filter(A=>A.page===ee),l=n.useCallback(A=>{ne?.(J===A?null:A)},[J,ne]),c=n.useCallback(A=>{if(h||!J||J==="freehand")return;const V=A.currentTarget.getBoundingClientRect(),N=(A.clientX-V.left)/V.width,D=(A.clientY-V.top)/V.height,S={id:`ann-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,tool:J,page:ee,x:N,y:D,color:j,author:f,createdAt:new Date().toISOString(),text:J==="text"?"":void 0};k?.([...L,S])},[h,J,ee,j,f,L,k]);if(b)return null;const d=t?e.jsxs("div",{className:"nice-pdf-annotation__label",children:[t,o&&e.jsx("span",{className:"nice-required",children:"*"})]}):void 0,p=h?void 0:e.jsxs("div",{className:"nice-pdf-annotation__toolbar",children:[R.map(A=>e.jsx("button",{type:"button",className:`nice-pdf-annotation__tool-btn${J===A?" nice-pdf-annotation__tool-btn--active":""}`,onClick:()=>l(A),disabled:r,title:s(`pdfTool_${A}`,A),children:e.jsx(y.oa,{name:qi[A],size:16})},A)),e.jsx("span",{className:"nice-pdf-annotation__toolbar-sep"}),e.jsx("button",{type:"button",disabled:r,onClick:()=>U?.(Math.max(.25,w-.25)),title:s("zoomOut","Zoom out"),"aria-label":s("zoomOut","Zoom out"),children:e.jsx(y.oa,{name:"minus",size:16})}),e.jsxs("span",{className:"nice-pdf-annotation__zoom",children:[Math.round(w*100),"%"]}),e.jsx("button",{type:"button",disabled:r,onClick:()=>U?.(Math.min(4,w+.25)),title:s("zoomIn","Zoom in"),"aria-label":s("zoomIn","Zoom in"),children:e.jsx(y.oa,{name:"plus",size:16})})]}),E=e.jsxs("div",{className:"nice-pdf-annotation__pager",children:[e.jsx("button",{type:"button",disabled:r||ee<=1,onClick:()=>ie?.(ee-1),"aria-label":s("prevPage","Previous page"),children:e.jsx(y.oa,{name:"chevron-left",size:16})}),e.jsx("span",{children:s("pageOf","{page} / {total}").replace("{page}",String(ee)).replace("{total}",String(I))}),e.jsx("button",{type:"button",disabled:r||ee>=I,onClick:()=>ie?.(ee+1),"aria-label":s("nextPage","Next page"),children:e.jsx(y.oa,{name:"chevron-right",size:16})})]}),B=!!i||!!a&&typeof a=="string"?e.jsxs(e.Fragment,{children:[i&&e.jsx("span",{className:"nice-helper-text",children:i}),a&&typeof a=="string"&&e.jsx("span",{className:"nice-error-text",children:a})]}):void 0;return e.jsx(Qt.NiceAppShell,{ref:te,flush:!0,id:$,className:`nice-pdf-annotation nice-size-${x}${z?` ${z}`:""}${a?" nice-error":""}${r?" nice-disabled":""}`,style:C,menubar:d,toolbar:p,bottomPanel:E,statusBar:B,children:e.jsxs("div",{style:{position:"relative",height:"100%",overflow:"auto"},children:[e.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:20},children:e.jsx(y.Ql,{steps:y.Yl(P,Gi)})}),e.jsxs("div",{className:"nice-pdf-annotation__viewport",style:{transform:`scale(${w})`,transformOrigin:"top left"},children:[e.jsx("iframe",{src:q,className:"nice-pdf-annotation__frame",title:s("pdfViewer","PDF Viewer")}),e.jsx("div",{className:"nice-pdf-annotation__layer",onClick:c,children:M.map(A=>e.jsxs("div",{className:`nice-pdf-annotation__mark nice-pdf-annotation__mark--${A.tool}`,style:{left:`${A.x*100}%`,top:`${A.y*100}%`,backgroundColor:A.color},onClick:V=>{V.stopPropagation(),u?.(A)},title:A.text??A.tool,children:[A.text&&e.jsx("span",{children:A.text}),!h&&e.jsx("button",{type:"button",className:"nice-pdf-annotation__mark-delete",onClick:V=>{V.stopPropagation(),g?.(A.id)},"aria-label":s("delete","Delete"),children:e.jsx(y.oa,{name:"close",size:14})})]},A.id))})]})]})})});Rn.displayName="NicePDFAnnotationEditor";function qt(t,i){const a=i.getBoundingClientRect();let o,r,h;if("touches"in t){const x=t.touches[0];o=x.clientX-a.left,r=x.clientY-a.top,h=x.force}else"pressure"in t?(o=t.clientX-a.left,r=t.clientY-a.top,h=t.pressure):(o=t.clientX-a.left,r=t.clientY-a.top);return{x:o,y:r,time:Date.now(),pressure:h!==void 0?h:.5}}function Vt(t,i,a,o,r){if(!i)return(a+o)/2;const h=Math.sqrt(Math.pow(t.x-i.x,2)+Math.pow(t.y-i.y,2))/Math.max(1,t.time-i.time),x=Math.min(h/5,1),_=o-x*(o-a),z=t.pressure??.5,C=a+z*(o-a);return _*.7+C*.3}function Wt(t,i,a,o){t.beginPath(),t.moveTo(i.x,i.y),t.lineTo(a.x,a.y),t.lineWidth=o,t.lineCap="round",t.lineJoin="round",t.stroke()}const Vi=n.forwardRef(function(i,a){const{value:o,onChange:r,onChangeDataUrl:h,label:x,width:_="100%",height:z=200,penColor:C="",penWidth:X=2,minWidth:q=.5,maxWidth:L=4,backgroundColor:k="",placeholder:J,showClearButton:ne=!0,showUndoButton:ee=!0,showColorPicker:ie=!1,showSizeSlider:I=!1,velocityFilterWeight:j=.7,throttle:R=16,disabled:f=!1,readOnly:w=!1,displayMode:U=!1,onBegin:u,onEnd:g,className:P,"data-testid":te}=i,{t:T}=y.Gt(),b=J||T("signature.placeholder","Sign here"),s=w||U,$=U?!1:ne,M=U?!1:ee,l=U?!1:ie,c=U?!1:I,d=n.useRef(null),[p,E]=n.useState(o?.strokes??[]),[v,B]=n.useState([]),[A,V]=n.useState(!1),[N,D]=n.useState(C),[S,ae]=n.useState(X),ue=n.useRef(null),ce=n.useRef(0),be=y.gu(d),ve=k||(be?"#0f172a":"#ffffff"),_e=C||(be?"#f8fafc":"#111827"),he=N||_e,ye=p.length===0&&v.length===0;n.useEffect(()=>{const Q=d.current;if(!Q)return;const K=Q.getContext("2d");if(!K)return;const se=Q.getBoundingClientRect(),me=window.devicePixelRatio||1;Q.width=se.width*me,Q.height=se.height*me,K.scale(me,me),xe()},[_,z]);const xe=n.useCallback(()=>{const Q=d.current;if(!Q)return;const K=Q.getContext("2d");if(!K)return;const se=Q.getBoundingClientRect();K.fillStyle=ve,K.fillRect(0,0,se.width,se.height),p.forEach(me=>{if(K.strokeStyle=me.color||_e,!(me.points.length<2))for(let je=1;je<me.points.length;je++){const we=me.points[je-1],Re=me.points[je],Te=Vt(Re,we,q,L);Wt(K,we,Re,Te)}})},[p,ve,_e,q,L,j]);n.useEffect(()=>{xe()},[xe]),n.useEffect(()=>{o?.strokes&&E(o.strokes)},[o]),n.useEffect(()=>{const Q=d.current;if(Q)if(p.length===0)r?.(null),h?.(null);else{const K=Q.getBoundingClientRect();r?.({strokes:p,width:K.width,height:K.height,timestamp:Date.now()}),h?.(Q.toDataURL("image/png"))}},[p,r,h]);const re=n.useCallback(Q=>{if(f||s)return;const K=d.current;if(!K)return;K.setPointerCapture(Q.pointerId);const se=qt(Q.nativeEvent,K);V(!0),B([se]),ue.current=se,ce.current=se.time,u?.()},[f,s,u]),Z=n.useCallback(Q=>{if(!A||f||s)return;const K=d.current;if(!K)return;const se=K.getContext("2d");if(!se)return;const me=Date.now();if(me-ce.current<R)return;const je=qt(Q.nativeEvent,K),we=ue.current;if(we){se.strokeStyle=he;const Re=Vt(je,we,q,L);Wt(se,we,je,Re)}B(Re=>[...Re,je]),ue.current=je,ce.current=me},[A,f,s,he,q,L,j,R]),de=n.useCallback(Q=>{if(!A)return;const K=d.current;if(K&&K.releasePointerCapture(Q.pointerId),v.length>0){const se={points:v,color:he,width:S};E(me=>[...me,se])}V(!1),B([]),ue.current=null,g?.()},[A,v,he,S,g]),O=n.useCallback(()=>{E([]),B([]),xe()},[xe]),H=n.useCallback(()=>{E(Q=>Q.slice(0,-1))},[]),Y=n.useCallback((Q="png",K=.92)=>{const se=d.current;if(!se)return"";const me=Q==="jpeg"?"image/jpeg":"image/png";return se.toDataURL(me,K)},[]),ge=n.useCallback(async(Q="png",K=.92)=>{const se=d.current;return se?new Promise(me=>{const je=Q==="jpeg"?"image/jpeg":"image/png";se.toBlob(we=>me(we),je,K)}):null},[]),le=n.useCallback(()=>{const Q=d.current;if(!Q)return"";const K=Q.getBoundingClientRect(),se=p.map(me=>me.points.length<2?"":`<path d="${me.points.reduce((we,Re,Te)=>Te===0?`M ${Re.x} ${Re.y}`:`${we} L ${Re.x} ${Re.y}`,"")}" stroke="${me.color||_e}" stroke-width="${me.width}" fill="none" stroke-linecap="round" stroke-linejoin="round"/>`).join(`
305
+ `);return`<svg xmlns="http://www.w3.org/2000/svg" width="${K.width}" height="${K.height}" viewBox="0 0 ${Q.width} ${Q.height}">
306
+ <rect width="100%" height="100%" fill="${ve}"/>
307
+ ${se}
308
+ </svg>`},[p,ve,_e]);n.useImperativeHandle(a,()=>({clear:O,undo:H,isEmpty:()=>p.length===0,getData:()=>{const Q=d.current;if(!Q||p.length===0)return null;const K=Q.getBoundingClientRect();return{strokes:p,width:K.width,height:K.height,timestamp:Date.now()}},setData:Q=>{E(Q.strokes)},toDataURL:Y,toBlob:ge,toSVG:le,getCanvas:()=>d.current}),[p,O,H,Y,ge,le]),n.useEffect(()=>{const Q=d.current;if(!Q)return;const K=se=>{A&&se.preventDefault()};return Q.addEventListener("touchmove",K,{passive:!1}),()=>Q.removeEventListener("touchmove",K)},[A]);const F=$||M||l||c;return e.jsxs("div",{className:`nice-signature ${f?"nice-signature--disabled":""} ${s?"nice-signature--readonly":""} ${P??""}`,style:{width:_},"data-testid":te,children:[x&&e.jsx("label",{className:"nice-signature__label",children:x}),F&&e.jsxs("div",{className:"nice-signature__toolbar",children:[l&&e.jsx("div",{className:"nice-signature__color-picker",children:e.jsx("input",{type:"color",value:N,onChange:Q=>D(Q.target.value),disabled:f||s,title:"Pen color"})}),c&&e.jsx("div",{className:"nice-signature__size-slider",children:e.jsx("input",{type:"range",min:q,max:L,step:.5,value:S,onChange:Q=>ae(parseFloat(Q.target.value)),disabled:f||s,title:"Pen size"})}),e.jsxs("div",{className:"nice-signature__actions",children:[M&&e.jsx("button",{type:"button",onClick:H,disabled:f||s||p.length===0,className:"nice-signature__btn",title:"Undo","aria-label":"Undo",children:e.jsx(y.oa,{name:"reply",size:16})}),$&&e.jsx("button",{type:"button",onClick:O,disabled:f||s||ye,className:"nice-signature__btn",title:"Clear","aria-label":"Clear",children:e.jsx(y.oa,{name:"trash",size:16})})]})]}),e.jsxs("div",{className:"nice-signature__canvas-wrapper",style:{height:z},children:[e.jsx("canvas",{ref:d,className:"nice-signature__canvas",style:{width:"100%",height:"100%",cursor:f||s?"not-allowed":"crosshair",touchAction:"none"},onPointerDown:re,onPointerMove:Z,onPointerUp:de,onPointerLeave:de}),ye&&!A&&b&&e.jsx("div",{className:"nice-signature__placeholder",children:b}),e.jsx("div",{className:"nice-signature__line"})]})]})}),Jt="nice-signature-styles";if(typeof document<"u"&&!document.getElementById(Jt)){const t=document.createElement("style");t.id=Jt,t.textContent=`
309
+ .nice-signature {
310
+ display: flex;
311
+ flex-direction: column;
312
+ border: 1px solid var(--nice-border, #e0e0e0);
313
+ border-radius: var(--nice-radius-sm, 4px);
314
+ overflow: hidden;
315
+ background: var(--nice-bg-surface, #fff);
316
+ }
317
+
318
+ .nice-signature--disabled {
319
+ opacity: 0.6;
320
+ }
321
+
322
+ .nice-signature__toolbar {
323
+ display: flex;
324
+ align-items: center;
325
+ gap: var(--nice-space-2, 8px);
326
+ padding: var(--nice-space-2, 8px);
327
+ background: var(--nice-bg-muted, #f5f5f5);
328
+ border-bottom: 1px solid var(--nice-border, #e0e0e0);
329
+ }
330
+
331
+ .nice-signature__color-picker input {
332
+ width: 32px;
333
+ height: 32px;
334
+ padding: var(--nice-space-0-5, 2px);
335
+ border: 1px solid var(--nice-border, #e0e0e0);
336
+ border-radius: var(--nice-radius-sm, 4px);
337
+ cursor: pointer;
338
+ }
339
+
340
+ .nice-signature__size-slider {
341
+ flex: 1;
342
+ max-width: 120px;
343
+ }
344
+
345
+ .nice-signature__size-slider input {
346
+ width: 100%;
347
+ }
348
+
349
+ .nice-signature__actions {
350
+ display: flex;
351
+ gap: var(--nice-space-1, 4px);
352
+ margin-left: auto;
353
+ }
354
+
355
+ .nice-signature__btn {
356
+ padding: var(--nice-space-1-5, 6px) var(--nice-space-2-5, 10px);
357
+ border: 1px solid var(--nice-border, #e0e0e0);
358
+ border-radius: var(--nice-radius-sm, 4px);
359
+ background: var(--nice-bg-surface, #fff);
360
+ cursor: pointer;
361
+ font-size: 14px;
362
+ }
363
+
364
+ .nice-signature__btn:hover:not(:disabled) {
365
+ background: var(--nice-bg-hover, #f0f0f0);
366
+ }
367
+
368
+ .nice-signature__btn:disabled {
369
+ opacity: 0.4;
370
+ cursor: not-allowed;
371
+ }
372
+
373
+ .nice-signature__canvas-wrapper {
374
+ position: relative;
375
+ background: var(--nice-bg, #FFF);
376
+ }
377
+
378
+ .nice-signature__canvas {
379
+ display: block;
380
+ }
381
+
382
+ .nice-signature__placeholder {
383
+ position: absolute;
384
+ top: 50%;
385
+ left: 50%;
386
+ transform: translate(-50%, -50%);
387
+ color: var(--nice-text-secondary, #999);
388
+ font-size: 14px;
389
+ pointer-events: none;
390
+ user-select: none;
391
+ }
392
+
393
+ .nice-signature__line {
394
+ position: absolute;
395
+ /* Sit in the lower third (a natural signature baseline) rather than pinned to
396
+ the very bottom. */
397
+ bottom: 64px;
398
+ left: 20px;
399
+ right: 20px;
400
+ height: 1px;
401
+ background: var(--nice-border, #ccc);
402
+ pointer-events: none;
403
+ }
404
+
405
+ /* Display component */
406
+ .nice-signature-display {
407
+ border: 1px solid var(--nice-border, #e0e0e0);
408
+ border-radius: var(--nice-radius-sm, 4px);
409
+ overflow: hidden;
410
+ }
411
+
412
+ .nice-signature-display__canvas-wrapper {
413
+ position: relative;
414
+ background: var(--nice-bg, #FFF);
415
+ }
416
+
417
+ .nice-signature-display__canvas {
418
+ display: block;
419
+ }
420
+
421
+ .nice-signature-display__placeholder {
422
+ position: absolute;
423
+ top: 50%;
424
+ left: 50%;
425
+ transform: translate(-50%, -50%);
426
+ color: var(--nice-text-secondary, #999);
427
+ font-size: 14px;
428
+ }
429
+ `,document.head.appendChild(t)}const Tn=n.forwardRef(({label:t,helperText:i,error:a,required:o,disabled:r,readOnly:h,size:x="md",id:_,className:z,style:C,accessMode:X,mode:q="manual",onScan:L,onModeChange:k,beepOnScan:J=!0,beepFrequency:ne=1800,beepDuration:ee=150,placeholder:ie,scanHistory:I=[],showHistory:j=!0,maxHistory:R=10,autoFocus:f=!0,onCameraFrame:w},U)=>{const u=y.Dc(X,_),g=u==="hidden";u==="disabled"&&(r=!0),u==="readOnly"&&(h=!0);const{t:P}=y.Gt(),te=y.bc(_),[T,b]=n.useState(""),s=n.useRef(null),$=n.useRef(null),M=n.useCallback(()=>{if(J)try{$.current||($.current=new AudioContext);const d=$.current,p=d.createOscillator(),E=d.createGain();p.connect(E),E.connect(d.destination),p.frequency.value=ne,p.type="square",E.gain.value=.3,p.start(),p.stop(d.currentTime+ee/1e3)}catch{}},[J,ne,ee]),l=n.useCallback(()=>{T.trim()&&(M(),L?.({value:T.trim(),format:"manual",scannedAt:new Date}),b(""),s.current?.focus())},[T,L,M]),c=I.slice(0,R);return g?null:e.jsxs("div",{ref:U,id:te,className:`nice-scanner nice-size-${x}${z?` ${z}`:""}${a?" nice-error":""}${r?" nice-disabled":""}`,style:C,children:[t&&e.jsxs("div",{className:"nice-scanner__label",children:[t,o&&e.jsx("span",{className:"nice-required",children:"*"})]}),e.jsxs("div",{className:"nice-scanner__modes",children:[e.jsxs("button",{type:"button",className:`nice-scanner__mode-btn${q==="camera"?" nice-scanner__mode-btn--active":""}`,onClick:()=>k?.("camera"),disabled:r,children:[e.jsx(y.oa,{name:"camera",size:16})," ",P("camera","Camera")]}),e.jsxs("button",{type:"button",className:`nice-scanner__mode-btn${q==="manual"?" nice-scanner__mode-btn--active":""}`,onClick:()=>k?.("manual"),disabled:r,children:[e.jsx(y.oa,{name:"edit",size:16})," ",P("manual","Manual")]})]}),q==="camera"&&e.jsx("div",{className:"nice-scanner__camera",children:e.jsx("div",{className:"nice-scanner__viewfinder",children:e.jsxs("div",{className:"nice-scanner__viewfinder-overlay",children:[e.jsx("span",{children:e.jsx(y.oa,{name:"camera",size:32})}),e.jsx("p",{children:P("cameraPlaceholder","Camera preview — connect scanner adapter")})]})})}),q==="manual"&&!h&&e.jsxs("div",{className:"nice-scanner__manual",children:[e.jsx("input",{ref:s,className:"nice-input nice-scanner__input",type:"text",value:T,onChange:d=>b(d.target.value),onKeyDown:d=>d.key==="Enter"&&l(),placeholder:ie??P("enterCode","Enter or scan code…"),disabled:r,autoFocus:f}),e.jsx("button",{type:"button",className:"nice-scanner__submit",onClick:l,disabled:r||!T.trim(),"aria-label":P("submit","Submit"),children:e.jsx(y.oa,{name:"check",size:16})})]}),j&&c.length>0&&e.jsxs("div",{className:"nice-scanner__history",children:[e.jsx("div",{className:"nice-scanner__history-label",children:P("recentScans","Recent scans")}),c.map((d,p)=>e.jsxs("div",{className:"nice-scanner__history-item",children:[e.jsx("span",{className:"nice-scanner__history-value",children:d.value}),d.format&&e.jsx("span",{className:"nice-scanner__history-format",children:d.format}),e.jsx("span",{className:"nice-scanner__history-time",children:d.scannedAt.toLocaleTimeString()})]},p))]}),i&&e.jsx("span",{className:"nice-helper-text",children:i}),a&&typeof a=="string"&&e.jsx("span",{className:"nice-error-text",children:a})]})});Tn.displayName="NiceScannerControl";const Wi=[{target:".nice-invoice-lines",titleKey:"tutorial.invoiceLineEditor.intro.title",title:"Invoice lines",contentKey:"tutorial.invoiceLineEditor.intro.content",content:"Add line items with quantity, unit price, VAT and discount — net, gross and the VAT breakdown are calculated automatically.",placement:"auto"}];let Ji=1;function Qi(t){return{id:`new-${Ji++}`,description:"",quantity:1,unitPrice:0,vatRate:t,discount:0,unit:"szt."}}function In(t){const a=t.quantity*t.unitPrice*(1-(t.discount??0)/100),o=Math.round(a*100)/100,r=Math.round(o*(t.vatRate??0)/100*100)/100;return{...t,netAmount:o,grossAmount:o+r}}function Zi(t){const i=t.map(In),a=i.reduce((_,z)=>_+(z.netAmount??0),0),o=i.reduce((_,z)=>_+(z.grossAmount??0),0),r=o-a,h=new Map;for(const _ of i){const z=_.vatRate??0,C=h.get(z)??{base:0,amount:0};C.base+=_.netAmount??0,C.amount+=(_.grossAmount??0)-(_.netAmount??0),h.set(z,C)}const x=Array.from(h.entries()).map(([_,z])=>({rate:_,base:Math.round(z.base*100)/100,amount:Math.round(z.amount*100)/100}));return{totalNet:Math.round(a*100)/100,totalVat:Math.round(r*100)/100,totalGross:Math.round(o*100)/100,vatBreakdown:x}}const An=n.forwardRef(({label:t,helperText:i,error:a,required:o,disabled:r,readOnly:h,size:x="md",name:_,id:z,className:C,style:X,accessMode:q,value:L=[],onChange:k,onTotalsChange:J,currencySymbol:ne="zł",defaultVatRate:ee=23,vatRates:ie=[0,5,8,23],units:I=["szt.","h","kg","m","usł."],showDiscount:j=!0,showUnit:R=!0,showTotals:f=!0,editable:w=!0,maxLines:U,tutorial:u},g)=>{const P=y.Dc(q,z),te=P==="hidden";P==="disabled"&&(r=!0),P==="readOnly"&&(h=!0);const{t:T}=y.Gt(),b=y.bc(z),s=n.useMemo(()=>L.map(In),[L]),$=n.useMemo(()=>Zi(L),[L]);n.useEffect(()=>{J?.($)},[$,J]);const M=n.useCallback((p,E,v)=>{const B=[...L];B[p]={...B[p],[E]:v},k?.(B)},[L,k]),l=n.useCallback(()=>{U&&L.length>=U||k?.([...L,Qi(ee)])},[L,k,ee,U]),c=n.useCallback(p=>{k?.(L.filter((E,v)=>v!==p))},[L,k]),d=p=>`${p.toFixed(2)} ${ne}`;return te?null:e.jsxs("div",{ref:g,id:b,className:`nice-invoice-lines nice-size-${x}${C?` ${C}`:""}${a?" nice-error":""}${r?" nice-disabled":""}`,style:{position:"relative",...X},children:[e.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:20},children:e.jsx(y.Ql,{steps:y.Yl(u,Wi)})}),t&&e.jsxs("label",{className:"nice-invoice-lines__label",children:[t,o&&e.jsx("span",{className:"nice-required",children:"*"})]}),e.jsxs("table",{className:"nice-invoice-lines__table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{className:"nice-il__th-num",children:"#"}),e.jsx("th",{className:"nice-il__th-desc",children:T("description","Description")}),e.jsx("th",{className:"nice-il__th-qty",children:T("qty","Qty")}),R&&e.jsx("th",{className:"nice-il__th-unit",children:T("unit","Unit")}),e.jsx("th",{className:"nice-il__th-price",children:T("unitPrice","Unit Price")}),j&&e.jsx("th",{className:"nice-il__th-disc",children:T("discount","Disc %")}),e.jsx("th",{className:"nice-il__th-vat",children:T("vat","VAT %")}),e.jsx("th",{className:"nice-il__th-net",children:T("net","Net")}),e.jsx("th",{className:"nice-il__th-gross",children:T("gross","Gross")}),w&&!h&&e.jsx("th",{className:"nice-il__th-actions"})]})}),e.jsx("tbody",{children:s.map((p,E)=>e.jsxs("tr",{children:[e.jsx("td",{className:"nice-il__cell-num",children:E+1}),e.jsx("td",{className:"nice-il__cell-desc",children:e.jsx("input",{className:"nice-input",type:"text",value:p.description,onChange:v=>M(E,"description",v.target.value),disabled:r,readOnly:h,placeholder:T("itemDescription","Item description")})}),e.jsx("td",{className:"nice-il__cell-qty",children:e.jsx("input",{className:"nice-input",type:"number",value:p.quantity,onChange:v=>M(E,"quantity",parseFloat(v.target.value)||0),disabled:r,readOnly:h,min:0,step:"any"})}),R&&e.jsx("td",{className:"nice-il__cell-unit",children:e.jsx("select",{className:"nice-select",value:p.unit??"",onChange:v=>M(E,"unit",v.target.value),disabled:r,children:I.map(v=>e.jsx("option",{value:v,children:v},v))})}),e.jsx("td",{className:"nice-il__cell-price",children:e.jsx("input",{className:"nice-input",type:"number",value:p.unitPrice,onChange:v=>M(E,"unitPrice",parseFloat(v.target.value)||0),disabled:r,readOnly:h,min:0,step:"0.01"})}),j&&e.jsx("td",{className:"nice-il__cell-disc",children:e.jsx("input",{className:"nice-input",type:"number",value:p.discount??0,onChange:v=>M(E,"discount",parseFloat(v.target.value)||0),disabled:r,readOnly:h,min:0,max:100})}),e.jsx("td",{className:"nice-il__cell-vat",children:e.jsx("select",{className:"nice-select",value:p.vatRate??0,onChange:v=>M(E,"vatRate",parseInt(v.target.value,10)),disabled:r,children:ie.map(v=>e.jsxs("option",{value:v,children:[v,"%"]},v))})}),e.jsx("td",{className:"nice-il__cell-net",children:d(p.netAmount??0)}),e.jsx("td",{className:"nice-il__cell-gross",children:d(p.grossAmount??0)}),w&&!h&&e.jsx("td",{className:"nice-il__cell-actions",children:e.jsx("button",{type:"button",className:"nice-btn nice-btn--icon nice-btn--sm",onClick:()=>c(E),disabled:r,title:T("remove","Remove"),"aria-label":T("remove","Remove"),children:e.jsx(y.oa,{name:"close",size:14})})})]},p.id))})]}),w&&!h&&e.jsxs("button",{type:"button",className:"nice-btn nice-btn--outlined nice-btn--sm nice-invoice-lines__add",onClick:l,disabled:r||U!=null&&L.length>=U,children:["+ ",T("addLine","Add line")]}),f&&e.jsxs("div",{className:"nice-invoice-lines__totals",children:[e.jsxs("div",{className:"nice-il__total-row",children:[e.jsxs("span",{children:[T("totalNet","Net total"),":"]}),e.jsx("span",{className:"nice-il__total-value",children:d($.totalNet)})]}),$.vatBreakdown.map(p=>e.jsxs("div",{className:"nice-il__total-row nice-il__total-row--vat",children:[e.jsxs("span",{children:["VAT ",p.rate,"%:"]}),e.jsx("span",{className:"nice-il__total-value",children:d(p.amount)})]},p.rate)),e.jsxs("div",{className:"nice-il__total-row nice-il__total-row--gross",children:[e.jsxs("span",{children:[T("totalGross","Gross total"),":"]}),e.jsx("span",{className:"nice-il__total-value nice-il__total-value--gross",children:d($.totalGross)})]})]}),i&&e.jsx("span",{className:"nice-helper-text",children:i}),a&&typeof a=="string"&&e.jsx("span",{className:"nice-error-text",children:a})]})});An.displayName="NiceInvoiceLineEditor";const Dn=n.forwardRef(({value:t="",onChange:i,suggestions:a=[],onSearch:o,trigger:r="@",renderSuggestion:h,placeholder:x,rows:_=3,label:z,helperText:C,error:X,required:q,disabled:L,readOnly:k,loading:J,labelPlacement:ne,errorPlacement:ee,labelWidth:ie,controlWidth:I,size:j="md",name:R,id:f,className:w,style:U,...u},g)=>{const P=y.bc(f),[te,T]=n.useState(!1),[b,s]=n.useState(""),[$,M]=n.useState(0),[l,c]=n.useState({top:0,left:0}),d=n.useRef(null),p=n.useRef(-1),v=a.map(D=>typeof D=="string"?{key:D,label:D}:D).filter(D=>D.label.toLowerCase().includes(b.toLowerCase())),B=n.useCallback(()=>{T(!1),s(""),M(0),p.current=-1},[]),A=n.useCallback(D=>{const S=d.current;if(!S||p.current<0)return;const ae=t.slice(0,p.current),ue=t.slice(S.selectionStart),ce=`${r}${D.label} `,be=ae+ce+ue;i?.(be),B(),requestAnimationFrame(()=>{const ve=ae.length+ce.length;S.setSelectionRange(ve,ve),S.focus()})},[t,i,r,B]),V=n.useCallback(D=>{const S=D.target.value;i?.(S);const ae=D.target.selectionStart,ue=S.slice(0,ae),ce=ue.lastIndexOf(r);if(ce>=0){const be=ce>0?ue[ce-1]:" ",ve=ue.slice(ce+r.length);if(/\s/.test(be)&&!/\s/.test(ve)){p.current=ce;const _e=ve;s(_e),T(!0),M(0),o?.(_e);const he=D.target,ye=he.getBoundingClientRect(),xe=parseInt(getComputedStyle(he).lineHeight)||20,re=ue.split(`
430
+ `);c({top:ye.top+re.length*xe+4-he.scrollTop,left:ye.left+8});return}}B()},[i,r,o,B]),N=n.useCallback(D=>{!te||v.length===0||(D.key==="ArrowDown"?(D.preventDefault(),M(S=>(S+1)%v.length)):D.key==="ArrowUp"?(D.preventDefault(),M(S=>(S-1+v.length)%v.length)):D.key==="Enter"?(D.preventDefault(),v[$]&&A(v[$])):D.key==="Escape"&&B())},[te,v,$,A,B]);return n.useEffect(()=>{if(!te)return;const D=S=>{const ae=d.current;ae&&!ae.contains(S.target)&&B()};return document.addEventListener("mousedown",D),()=>document.removeEventListener("mousedown",D)},[te,B]),e.jsxs("div",{className:`nice-field nice-field--${j} ${ne==="left"?"nice-field--label-left":""} ${ee==="right"?"nice-field--error-right":""} ${J?"nice-field--loading":""} ${w||""}`,style:{...U,...ie!=null&&{"--nice-field-label-width":typeof ie=="number"?`${ie}px`:ie},...I!=null&&{"--nice-field-control-width":typeof I=="number"?`${I}px`:I}},"aria-busy":J||void 0,...u,children:[z&&e.jsx("label",{htmlFor:P,className:`nice-field__label ${q?"nice-field__label--required":""}`,children:z}),e.jsxs("div",{className:"nice-field__control",children:[e.jsxs("div",{className:`nice-mention nice-mention--${j} ${X?"nice-mention--error":""} ${L?"nice-mention--disabled":""}`,children:[e.jsx("textarea",{ref:D=>{d.current=D,typeof g=="function"?g(D):g&&(g.current=D)},id:P,name:R,className:"nice-mention__input",value:t,onChange:V,onKeyDown:N,placeholder:x,rows:_,disabled:L,readOnly:k,"aria-invalid":!!X,"aria-describedby":X?`${P}-error`:C?`${P}-helper`:void 0,"aria-autocomplete":"list","aria-expanded":te}),te&&v.length>0&&e.jsx("ul",{className:"nice-mention__suggestions",role:"listbox",style:{position:"fixed",top:l.top,left:l.left},children:v.map((D,S)=>e.jsx("li",{role:"option","aria-selected":S===$,className:`nice-mention__suggestion ${S===$?"nice-mention__suggestion--active":""}`,onMouseDown:ae=>{ae.preventDefault(),A(D)},onMouseEnter:()=>M(S),children:h?h(D):e.jsxs(e.Fragment,{children:[D.icon&&e.jsx("span",{className:"nice-mention__suggestion-icon",children:D.icon}),e.jsx("span",{children:D.label})]})},D.key))})]}),J&&e.jsx("span",{className:"nice-field__spinner",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})}),ee==="right"&&X&&e.jsx("div",{id:`${P}-error`,className:"nice-field__error",role:"alert",children:X}),ee==="right"&&!X&&C&&e.jsx("div",{id:`${P}-helper`,className:"nice-field__helper",children:C})]}),ee!=="right"&&X&&e.jsx("div",{id:`${P}-error`,className:"nice-field__error",role:"alert",children:X}),ee!=="right"&&!X&&C&&e.jsx("div",{id:`${P}-helper`,className:"nice-field__helper",children:C})]})});Dn.displayName="NiceMention";exports.DEFAULT_ASPECT_RATIOS=En;exports.EMOJI_DATA=ht;exports.GRADIENT_PRESETS=fn;exports.NICE_COLOR_PRESET_KEYS=un;exports.NiceAccountPicker=kn;exports.NiceAddressInput=_n;exports.NiceCodeEditorAI=Ci;exports.NiceColorPalette=hn;exports.NiceContactPicker=wn;exports.NiceCropEditor=Mn;exports.NiceDateRangeBox=Zn;exports.NiceDocumentEditor=jn;exports.NiceDropDownBox=Wn;exports.NiceEmojiPicker=Nn;exports.NiceGradientPicker=yn;exports.NiceHtmlEditorAI=hi;exports.NiceImageAnnotator=$n;exports.NiceImageEditor=Sn;exports.NiceInputOtp=Cn;exports.NiceInvoiceLineEditor=An;exports.NiceKeyValueEditor=Ii;exports.NiceKnob=en;exports.NiceLogConsole=vn;exports.NiceLookup=qn;exports.NiceMarkdownEditor=xn;exports.NiceMention=Dn;exports.NicePDFAnnotationEditor=Rn;exports.NicePickList=on;exports.NiceRangeSlider=Un;exports.NiceScannerControl=Tn;exports.NiceScriptRunner=Ri;exports.NiceSignature=Vi;exports.NiceTreeSelect=an;exports.NiceWiki=bn;exports.applyPreset=pt;exports.contrastRatio=mt;exports.cssToGradient=gn;exports.generateHarmony=ot;exports.generateVariations=ln;exports.gradientToCss=Nt;exports.hexToHsv=He;exports.hexToRgb=st;exports.hsvToHex=De;exports.hsvToRgb=sn;exports.randomPalette=mn;exports.rgbToHex=cn;exports.rgbToHsl=rn;exports.rgbToHsv=St;exports.wcagLevel=ut;