@nice2dev/ui 1.0.21 → 1.0.22

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 (90) hide show
  1. package/CHANGELOG.md +144 -0
  2. package/dist/NiceErrorBoundary-B0262Ffc.js +770 -0
  3. package/dist/NiceErrorBoundary-BXOLv-zG.cjs +1 -0
  4. package/dist/NiceErrorBoundary-DsreAsON.cjs +1 -0
  5. package/dist/NiceErrorBoundary-HMfrXIir.js +770 -0
  6. package/dist/NiceForm-B7D1MASh.js +5383 -0
  7. package/dist/NiceForm-BA9zZdm8.cjs +382 -0
  8. package/dist/NiceForm-Ba9rvBoT.cjs +382 -0
  9. package/dist/NiceForm-DAGMJpgx.js +5383 -0
  10. package/dist/NiceModal-BVT9cZbf.cjs +1 -0
  11. package/dist/NiceModal-CiOYOWJy.cjs +1 -0
  12. package/dist/NiceModal-DZbHCdKq.js +95 -0
  13. package/dist/NiceModal-MeC1cNtW.js +95 -0
  14. package/dist/NiceModuleLifecyclePanel-BiX4KxaK.js +6781 -0
  15. package/dist/NiceModuleLifecyclePanel-CDo0iVfr.js +6781 -0
  16. package/dist/NiceModuleLifecyclePanel-DEJpoz5a.cjs +1 -0
  17. package/dist/NiceModuleLifecyclePanel-DrDTpH6K.cjs +1 -0
  18. package/dist/NiceModuleLifecyclePanel.css +1 -1
  19. package/dist/NicePagination-C8gx6Bcl.js +171 -0
  20. package/dist/NicePagination-CNxEAb4C.cjs +1 -0
  21. package/dist/NicePagination-Cg_WEf-R.cjs +1 -0
  22. package/dist/NicePagination-DQXdzx7W.js +171 -0
  23. package/dist/NicePinCodeInput-3WugpLHi.js +12240 -0
  24. package/dist/NicePinCodeInput-CSfRHs4v.cjs +419 -0
  25. package/dist/NicePinCodeInput-CjwFvOEQ.js +13092 -0
  26. package/dist/NicePinCodeInput-DoBQnMj9.cjs +694 -0
  27. package/dist/NiceSavedQueryPanel-DFDDuKWd.js +6597 -0
  28. package/dist/NiceSavedQueryPanel-DTU4eiIH.cjs +596 -0
  29. package/dist/NiceSavedQueryPanel-qtWETcRP.cjs +596 -0
  30. package/dist/NiceSavedQueryPanel-z29D7N_A.js +6584 -0
  31. package/dist/NiceTabs-B4dM77y_.js +1657 -0
  32. package/dist/NiceTabs-BTVTtRZR.cjs +1 -0
  33. package/dist/NiceTabs-BXGmot7J.cjs +1 -0
  34. package/dist/NiceTabs-DJdhKste.js +1657 -0
  35. package/dist/NiceWindow-Cs6-Dbci.js +1592 -0
  36. package/dist/NiceWindow-DYw4NCeb.js +1592 -0
  37. package/dist/NiceWindow-O_g8StvA.cjs +1 -0
  38. package/dist/NiceWindow-a4wB_m30.cjs +1 -0
  39. package/dist/NiceWindow.css +1 -0
  40. package/dist/charts-BDr6B81L.js +4657 -0
  41. package/dist/charts-Ci_KrAoU.cjs +761 -0
  42. package/dist/charts-ClxW-i5q.js +4657 -0
  43. package/dist/charts-Dr_FIPZT.cjs +761 -0
  44. package/dist/charts.cjs +1 -1
  45. package/dist/charts.mjs +1 -1
  46. package/dist/core-BIz6zQ5u.cjs +122 -0
  47. package/dist/core-BYxnKGOi.js +23141 -0
  48. package/dist/core-Cjw8oBvC.cjs +96 -0
  49. package/dist/core-xcuNJ-DB.js +24948 -0
  50. package/dist/data-branching-Byz79mmA.cjs +1 -0
  51. package/dist/data-branching-DjuerHfS.js +6133 -0
  52. package/dist/data-branching.cjs +1 -1
  53. package/dist/data-branching.d.ts +3 -0
  54. package/dist/data-branching.mjs +1 -1
  55. package/dist/data.cjs +1 -1
  56. package/dist/data.d.ts +10 -7
  57. package/dist/data.mjs +1 -1
  58. package/dist/devops-DYFov8j3.js +7684 -0
  59. package/dist/devops-g4qcLXah.cjs +17 -0
  60. package/dist/devops.cjs +1 -1
  61. package/dist/devops.d.ts +5 -0
  62. package/dist/devops.mjs +1 -1
  63. package/dist/editors.cjs +1 -1
  64. package/dist/editors.d.ts +172 -1
  65. package/dist/editors.mjs +44 -41
  66. package/dist/feedback.cjs +1 -1
  67. package/dist/feedback.d.ts +1 -2
  68. package/dist/feedback.mjs +2 -2
  69. package/dist/index-AEO3cK4T.cjs +5194 -0
  70. package/dist/index-BMQ-F0zE.js +65054 -0
  71. package/dist/index-BNb9q4Ll.cjs +5490 -0
  72. package/dist/index-CjdfogVa.js +66711 -0
  73. package/dist/index.cjs +1 -1
  74. package/dist/index.d.ts +504 -25
  75. package/dist/index.mjs +979 -963
  76. package/dist/lazy.cjs +1 -1
  77. package/dist/lazy.d.ts +11 -0
  78. package/dist/lazy.mjs +24 -24
  79. package/dist/navigation.cjs +1 -1
  80. package/dist/navigation.mjs +34 -34
  81. package/dist/no-code-Dl3ima61.cjs +332 -0
  82. package/dist/no-code-ktRzFaET.js +7133 -0
  83. package/dist/no-code.cjs +1 -1
  84. package/dist/no-code.d.ts +11 -0
  85. package/dist/no-code.mjs +1 -1
  86. package/dist/overlays.cjs +1 -1
  87. package/dist/overlays.d.ts +38 -0
  88. package/dist/overlays.mjs +48 -48
  89. package/dist/style.css +5 -2
  90. package/package.json +1 -1
@@ -0,0 +1,419 @@
1
+ "use strict";const e=require("react/jsx-runtime"),te=require("./core-Cjw8oBvC.cjs"),n=require("react"),xe=require("./NiceTabs-BTVTtRZR.cjs"),bt=require("./NiceForm-Ba9rvBoT.cjs");function In(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"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 jt(t,i={}){const o=i.size??16,r="currentColor",l="currentColor";if(i.rectangle||t==="shade-chain"||t==="monochromatic"){const K=Math.max(3,Math.min(7,i.count??5)),_=o*.1,O=o-_*2,H=Math.max(1.2,o/14),Z=o/2,F=Array.from({length:K},(X,f)=>{const w=_+O*f/(K-1),S=.25+.75*f/(K-1);return e.jsx("circle",{cx:w,cy:Z,r:H,fill:l,opacity:S},f)});return e.jsxs("svg",{width:o,height:o,viewBox:`0 0 ${o} ${o}`,"aria-hidden":!0,children:[e.jsx("rect",{x:1,y:o/2-o/6,width:o-2,height:o/3,rx:o/6,fill:"none",stroke:r,strokeOpacity:.25}),F]})}const C=i.angles??In(t),k=o/2,L=o/2,z=o/2-2,W=Math.max(1.4,o/9);return e.jsxs("svg",{width:o,height:o,viewBox:`0 0 ${o} ${o}`,"aria-hidden":!0,children:[e.jsx("circle",{cx:k,cy:L,r:z,fill:"none",stroke:r,strokeOpacity:.25}),C.map((K,_)=>{const O=(K-90)*Math.PI/180,H=k+z*Math.cos(O),Z=L+z*Math.sin(O);return e.jsx("circle",{cx:H,cy:Z,r:W,fill:l},_)})]})}function vt(t,i,o){return Math.max(i,Math.min(o,t))}function Ft({h:t,s:i,v:o}){t=(t%360+360)%360;const r=o*i,l=r*(1-Math.abs(t/60%2-1)),h=o-r;let C=0,k=0,L=0;return t<60?(C=r,k=l):t<120?(C=l,k=r):t<180?(k=r,L=l):t<240?(k=l,L=r):t<300?(C=l,L=r):(C=r,L=l),{r:Math.round((C+h)*255),g:Math.round((k+h)*255),b:Math.round((L+h)*255)}}function ht({r:t,g:i,b:o}){t/=255,i/=255,o/=255;const r=Math.max(t,i,o),l=Math.min(t,i,o),h=r-l;let C=0;return h!==0&&(r===t?C=(i-o)/h%6:r===i?C=(o-t)/h+2:C=(t-i)/h+4,C=(C*60+360)%360),{h:C,s:r===0?0:h/r,v:r}}function Bt({r:t,g:i,b:o}){t/=255,i/=255,o/=255;const r=Math.max(t,i,o),l=Math.min(t,i,o),h=(r+l)/2;if(r===l)return{h:0,s:0,l:h};const C=r-l,k=h>.5?C/(2-r-l):C/(r+l);let L=0;return r===t?L=((i-o)/C+(i<o?6:0))/6:r===i?L=((o-t)/C+2)/6:L=((t-i)/C+4)/6,{h:L*360,s:k,l:h}}function Ge(t){const i=t.replace("#",""),o=i.length===3?i[0]+i[0]+i[1]+i[1]+i[2]+i[2]:i,r=parseInt(o,16);return{r:r>>16&255,g:r>>8&255,b:r&255}}function Ot({r:t,g:i,b:o}){return"#"+[t,i,o].map(r=>r.toString(16).padStart(2,"0")).join("")}function Se(t){return Ot(Ft(t))}function Ae(t){return ht(Ge(t))}function Kt(t,i){const o=[];for(let r=0;r<i;r++){const l=i<=1?.5:r/(i-1),h=vt(t.s*(.3+l*.7),0,1),C=vt(t.v*(1.2-l*.7),0,1);o.push(Se({h:t.h,s:h,v:C}))}return o}function gt(t,i){if(t==="custom"||t==="shade-chain")return[0];const o=i??30;switch(t){case"monochromatic":return[0];case"complementary":return[0,180];case"split-complementary":return[0,180-o,180+o];case"analogous":return[0,-o,o];case"triadic":return[0,120,240];case"tetradic":return[0,60,180,240];case"square":return[0,90,180,270]}return[0]}function qe(t,i,o){return gt(i,o).map(r=>((t+r)%360+360)%360)}function _t(t,i,o=.12){const r=Math.max(2,i),l=(r-1)/2,h=[];for(let C=0;C<r;C++){const k=(C-l)*o,L=Math.max(.05,Math.min(.98,t.v+k)),z=Math.max(.05,Math.min(1,t.s-Math.abs(k)*.25));h.push(Se({h:t.h,s:z,v:L}))}return h}function kt({r:t,g:i,b:o}){const[r,l,h]=[t,i,o].map(C=>{const k=C/255;return k<=.03928?k/12.92:Math.pow((k+.055)/1.055,2.4)});return .2126*r+.7152*l+.0722*h}function Qe(t,i){const o=kt(Ge(t)),r=kt(Ge(i)),l=Math.max(o,r),h=Math.min(o,r);return(l+.05)/(h+.05)}function et(t){return t>=7?"AAA":t>=4.5?"AA":t>=3?"AA-lg":"Fail"}const Yt={"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 tt(t,i){const o=Yt[i];return t.map(r=>{const l=(o.sRange[0]+o.sRange[1])/2,h=(o.vRange[0]+o.vRange[1])/2;return Se({h:r,s:l,v:h})})}function An(){return Math.floor(Math.random()*360)}function Ut(t,i,o){const r=An(),l=qe(r,t,o),h=[];for(let C=0;C<i;C++){const k=l[C%l.length],L=.55+Math.random()*.4,z=.5+Math.random()*.45;h.push(Se({h:k+(Math.random()-.5)*8,s:L,v:z}))}return h}const Dn=({hues:t,baseHue:i,onBaseHueChange:o,mode:r,distance:l,disabled:h})=>{const K=n.useCallback(F=>{if(h)return;const f=F.currentTarget.getBoundingClientRect(),w=F.clientX-f.left-120,S=F.clientY-f.top-120,M=(Math.atan2(S,w)*180/Math.PI+360)%360;o(Math.round(M))},[120,120,h,o]),_=[];for(let F=0;F<360;F+=2){const X=(F-1)*Math.PI/180,f=(F+1)*Math.PI/180,w=Se({h:F,s:1,v:1});_.push(e.jsx("path",{d:`M${120+55*Math.cos(X)},${120+55*Math.sin(X)} L${120+110*Math.cos(X)},${120+110*Math.sin(X)} 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(X)},${120+55*Math.sin(X)} Z`,fill:w},F))}const O=`wheel-center-${r}`,H=t.map((F,X)=>{const w=F*Math.PI/180;return e.jsx("circle",{cx:120+82.5*Math.cos(w),cy:120+82.5*Math.sin(w),r:X===0?8:6,fill:Se({h:F,s:.85,v:.9}),stroke:X===0?"var(--bg-primary, #fff)":"var(--border-color, #ccc)",strokeWidth:X===0?3:2},X)});let Z=null;if(r==="analogous"||r==="split-complementary"){const f=gt(r,l).slice(1).map((w,S)=>{const M=(i+w)*Math.PI/180;return e.jsx("line",{x1:120,y1:120,x2:120+82.5*Math.cos(M),y2:120+82.5*Math.sin(M),stroke:"var(--nice-overlay-light-30, rgba(255, 255, 255, 0.3))",strokeWidth:1,strokeDasharray:"3,3"},`dline-${S}`)});Z=e.jsx(e.Fragment,{children:f})}return e.jsxs("svg",{className:"nice-palette__wheel",viewBox:"0 0 240 240",width:240,height:240,onClick:K,style:{cursor:h?"default":"crosshair"},children:[e.jsx("defs",{children:e.jsxs("radialGradient",{id:O,children:[e.jsx("stop",{offset:"0%",stopColor:"var(--nice-bg, #fff)"}),e.jsx("stop",{offset:"100%",stopColor:"transparent"})]})}),_,e.jsx("circle",{cx:120,cy:120,r:53,fill:Se({h:i,s:.6,v:.85})}),e.jsx("circle",{cx:120,cy:120,r:53,fill:`url(#${O})`,opacity:.4}),Z,H]})},Ln=({colors:t})=>{if(t.length<2)return null;const i=[];for(let o=0;o<t.length;o++){const r=Qe(t[o],"var(--bg-primary, #ffffff)"),l=Qe(t[o],"var(--text-primary, #000000)");i.push({a:t[o],b:"var(--bg-primary, #ffffff)",ratio:r,level:et(r)}),i.push({a:t[o],b:"var(--text-primary, #000000)",ratio:l,level:et(l)});for(let h=o+1;h<t.length;h++){const C=Qe(t[o],t[h]);i.push({a:t[o],b:t[h],ratio:C,level:et(C)})}}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((o,r)=>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:o.a}}),e.jsx("span",{className:"nice-palette__contrast-vs",children:"vs"}),e.jsx("span",{className:"nice-palette__contrast-dot",style:{background:o.b}})]}),e.jsxs("span",{className:"nice-palette__contrast-ratio",children:[o.ratio.toFixed(1),":1"]}),e.jsx("span",{className:`nice-palette__contrast-level nice-palette__contrast-level--${o.level.toLowerCase().replace("-","")}`,children:o.level})]},r))})]})},zn=({hex:t})=>{const i=Ge(t),o=Bt(i),r=ht(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(o.h),"°, ",Math.round(o.s*100),"%,"," ",Math.round(o.l*100),"%"]}),e.jsxs("div",{children:[e.jsx("strong",{children:"HSV"})," ",Math.round(r.h),"°, ",Math.round(r.s*100),"%,"," ",Math.round(r.v*100),"%"]})]})},Pn={monochromatic:"Monochromatic",complementary:"Complementary","split-complementary":"Split-Complementary",analogous:"Analogous",triadic:"Triadic",tetradic:"Tetradic (Rectangle)",square:"Square","shade-chain":"Shade chain",custom:"Custom"},Hn={"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"},Fn=["monochromatic","shade-chain","complementary","split-complementary","analogous","triadic","tetradic","square","custom"],Bn=["lightest-pastel","bright-pastel","shiny","pastel","full","dark","deep","muted","earth"],Wt="nice-palette-custom-schemes";function On(){if(typeof window>"u")return[];try{const t=window.localStorage.getItem(Wt);if(!t)return[];const i=JSON.parse(t);if(Array.isArray(i))return i}catch{}return[]}function Kn(t){if(!(typeof window>"u"))try{window.localStorage.setItem(Wt,JSON.stringify(t))}catch{}}const Xt=n.forwardRef(({id:t,className:i,style:o,accessMode:r,value:l,onChange:h,minColors:C=1,maxColors:k=8,harmonyMode:L,onHarmonyModeChange:z,distance:W,onDistanceChange:K,preset:_,onPresetChange:O,showWheel:H=!0,showContrast:Z=!0,showInfo:F=!0,showPresets:X=!0,presets:f=[],showVariations:w=!0,showRandom:S=!0,variationCount:M=5,label:G,disabled:y,colorCount:N,shadeStep:j,onShadeStepChange:$,customSchemes:A,onCustomSchemesChange:P,persistCustomSchemes:v=!0},c)=>{const D=te.Zs(r,t),x=D==="hidden";(D==="disabled"||D==="readOnly")&&(y=!0);const m=te.Hs(t),{t:s}=te.Jo(),[d,p]=n.useState("analogous"),[g,u]=n.useState(30),[R,V]=n.useState(""),[I,ee]=n.useState(0),[me,Y]=n.useState(.12),[ne,oe]=n.useState(null),[ue,ye]=n.useState(()=>A??(v?On():[])),[ge,ke]=n.useState(null),ie=L??d,re=W??g,le=_??R,ae=j??me,E=A??ue;n.useEffect(()=>{!A&&v&&Kn(ue)},[ue,A,v]);const b=n.useCallback(Q=>{ye(Q),P?.(Q)},[P]),q=n.useCallback(Q=>{p(Q),z?.(Q)},[z]),ce=n.useCallback(Q=>{u(Q),K?.(Q)},[K]),de=n.useCallback(Q=>{V(Q),Q&&O?.(Q)},[O]),B=n.useMemo(()=>["var(--color-primary, #3b82f6)","var(--color-error, #ef4444)","var(--color-success, #22c55e)"],[]),J=l&&l.length>0?l:B,be=J[0],fe=n.useMemo(()=>Ae(be),[be]),we=n.useMemo(()=>qe(fe.h,ie,re),[fe.h,ie,re]),je=n.useCallback((Q,pe,_e,a)=>{const T=N??ne??void 0,U=T!==void 0?Math.max(C,Math.min(k,T)):void 0;if(pe==="shade-chain"){const Ce=U??Math.max(C,5),Me=_t({h:Q,s:fe.s||.7,v:fe.v||.6},Ce,ae);h?.(Me);return}let se;const he=pe==="custom"&&ge?E.find(Ce=>Ce.id===ge):null;he&&he.angles.length>0?se=he.angles.map(Ce=>((Q+Ce)%360+360)%360):se=qe(Q,pe,_e);let ve;if(a&&Yt[a]?ve=tt(se,a):ve=se.map(Ce=>Se({h:Ce,s:fe.s||.7,v:fe.v||.85})),he?.lightnessOffsets?.length&&(ve=ve.map((Ce,Me)=>{const Te=he.lightnessOffsets?.[Me];if(Te==null)return Ce;const Ie=Ae(Ce);return Se({h:Ie.h,s:Ie.s,v:Math.max(.05,Math.min(.98,Ie.v+Te))})})),U!==void 0){for(;ve.length<U;){const Ce=ve[ve.length-1]||"#888888",Me=Ae(Ce);ve.push(Se({h:(Me.h+18)%360,s:Me.s,v:Me.v}))}ve=ve.slice(0,U)}else{for(;ve.length<C;)ve.push(ve[ve.length-1]||"var(--nice-text-secondary, #888888)");ve.length>k&&(ve=ve.slice(0,k))}h?.(ve)},[fe.s,fe.v,C,k,h,N,ne,ae,ge,E]),De=n.useCallback(Q=>{if(!y){if(ie==="custom"){const pe=Se({h:Q,s:fe.s||.7,v:fe.v||.85}),_e=[...J];_e[I]=pe,h?.(_e);return}je(Q,ie,re,le)}},[y,ie,re,le,je,fe.s,fe.v,J,I,h]),Re=n.useCallback(Q=>{y||(q(Q),Q!=="custom"&&je(fe.h,Q,re,le))},[y,fe.h,re,le,q,je]),$e=n.useCallback(Q=>{y||(ce(Q),je(fe.h,ie,Q,le))},[y,fe.h,ie,le,ce,je]),Le=n.useCallback(Q=>{if(y)return;de(Q);const pe=qe(fe.h,ie,re),_e=tt(pe,Q);h?.(_e.slice(0,k))},[y,fe.h,ie,re,k,de,h]),Fe=n.useCallback((Q,pe)=>{if(y)return;const _e=[...J];_e[Q]=pe,h?.(_e)},[y,J,h]),Ye=n.useCallback(()=>{if(y||J.length>=k)return;const Q=Ae(J[J.length-1]),pe=Se({h:(Q.h+30)%360,s:Q.s,v:Q.v});h?.([...J,pe])},[y,J,k,h]),Ue=n.useCallback(Q=>{if(y||J.length<=C)return;const pe=J.filter((_e,a)=>a!==Q);h?.(pe),I>=pe.length&&ee(Math.max(0,pe.length-1))},[y,J,C,h,I]),Be=n.useCallback(()=>{if(y)return;const Q=Math.max(C,Math.min(k,gt(ie).length)),pe=Ut(ie,Q,re);h?.(pe)},[y,C,k,ie,re,h]),ze=n.useMemo(()=>{if(!w)return[];const Q=J[I]||J[0];return Kt(Ae(Q),M)},[w,J,I,M]),Pe=J[I]||J[0],Ee=n.useMemo(()=>{const Q=Ae(Pe);return Se({h:(Q.h+180)%360,s:Q.s,v:Q.v})},[Pe]);return x?null:e.jsxs("div",{ref:c,id:m,className:`nice-palette ${y?"nice-palette--disabled":""} ${i||""}`,style:o,children:[G&&e.jsx("div",{className:"nice-palette__label",children:G}),e.jsxs("div",{className:"nice-palette__modes",style:{display:"flex",gap:8,alignItems:"center",flexWrap:"wrap"},children:[e.jsx(xe.NiceSelect,{label:s("colorPalette.harmony","Harmony"),labelPlacement:"left",size:"sm",disabled:y,value:ie==="custom"&&ge?`custom:${ge}`:ie,onChange:Q=>{const pe=Array.isArray(Q)?Q[0]:Q;if(typeof pe=="string")if(pe.startsWith("custom:")){const _e=pe.slice(7);ke(_e),Re("custom")}else ke(null),Re(pe)},options:[...Fn.map(Q=>({value:Q,label:Pn[Q]})),...E.map(Q=>({value:`custom:${Q.id}`,label:`★ ${Q.name}`}))],renderOption:(Q,pe)=>{const _e=String(Q.value),a=_e.startsWith("custom:"),T=a?E.find(he=>he.id===_e.slice(7)):null,U=T?T.angles:void 0,se=a?"custom":_e;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:jt(se,{angles:U,size:16,count:N})}),e.jsx("span",{style:{fontWeight:pe?600:400},children:Q.label})]})}}),ie==="shade-chain"&&e.jsx(xe.NiceNumberInput,{label:s("colorPalette.step","Step"),labelPlacement:"left",size:"sm",min:.02,max:.5,step:.02,precision:2,value:ae,onChange:Q=>{const pe=typeof Q=="number"?Q:Number(Q);Number.isNaN(pe)||(Y(pe),$?.(pe),je(fe.h,ie,re,le))},showStepper:!0,disabled:y}),e.jsx(xe.NiceNumberInput,{label:s("colorPalette.colors","Colors"),labelPlacement:"left",size:"sm",min:Math.max(2,C),max:Math.min(12,k),step:1,precision:0,value:N??ne??J.length,onChange:Q=>{const pe=typeof Q=="number"?Q:Number(Q);if(!Number.isFinite(pe))return;const _e=Math.max(Math.max(2,C),Math.min(Math.min(12,k),Math.round(pe)));oe(_e),ie==="shade-chain"?h?.(_t({h:fe.h,s:fe.s||.7,v:fe.v||.6},_e,ae)):setTimeout(()=>je(fe.h,ie,re,le),0)},showStepper:!0,disabled:y})]}),e.jsxs("div",{className:"nice-palette__main",children:[H&&e.jsxs("div",{className:"nice-palette__wheel-container",children:[e.jsx(Dn,{hues:we,baseHue:fe.h,onBaseHueChange:De,mode:ie,distance:re,disabled:y}),(ie==="analogous"||ie==="split-complementary")&&e.jsxs("div",{className:"nice-palette__distance",children:[e.jsxs("label",{children:["Distance: ",re,"°"]}),e.jsx("input",{type:"range",min:10,max:90,value:re,onChange:Q=>$e(Number(Q.target.value)),disabled:y,className:"nice-palette__distance-slider"})]})]}),e.jsxs("div",{className:"nice-palette__strips",children:[e.jsxs("div",{className:"nice-palette__swatches",children:[J.map((Q,pe)=>e.jsxs("div",{className:`nice-palette__swatch-wrapper ${I===pe?"nice-palette__swatch-wrapper--selected":""}`,onClick:()=>ee(pe),children:[e.jsx("div",{className:"nice-palette__swatch",style:{background:Q},children:J.length>C&&e.jsx("button",{type:"button",className:"nice-palette__swatch-remove",onClick:_e=>{_e.stopPropagation(),Ue(pe)},disabled:y,"aria-label":"Remove color",children:"×"})}),e.jsx("input",{type:"text",className:"nice-palette__hex-input",value:Q.toUpperCase(),maxLength:7,disabled:y,onChange:_e=>Fe(pe,_e.target.value)})]},pe)),J.length<k&&e.jsx("button",{type:"button",className:"nice-palette__add-btn",onClick:Ye,disabled:y,title:"Add color",children:"+"})]}),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:Ee},title:Ee.toUpperCase()}),e.jsx("span",{className:"nice-palette__hex-label",children:Ee.toUpperCase()})]}),w&&ze.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:ze.map((Q,pe)=>e.jsx("div",{className:"nice-palette__variation-chip",style:{background:Q},title:Q.toUpperCase(),onClick:()=>{y||Fe(I,Q)},role:"button",tabIndex:0},pe))})]}),S&&e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm nice-palette__random-btn",onClick:Be,disabled:y,title:"Random palette","aria-label":"Random palette",children:"🎲 Random Palette"})]})]}),X&&f.length>0&&e.jsxs("div",{className:"nice-palette__presets",children:[e.jsx("div",{className:"nice-palette__section-title",children:"Style Presets"}),e.jsx("div",{className:"nice-palette__preset-grid",children:f.map(Q=>{const pe=tt(we,Q);return e.jsxs("button",{type:"button",className:`nice-palette__preset-card ${le===Q?"nice-palette__preset-card--active":""}`,onClick:()=>Le(Q),disabled:y,children:[e.jsx("div",{className:"nice-palette__preset-strip",children:pe.map((_e,a)=>e.jsx("span",{className:"nice-palette__preset-dot",style:{background:_e}},a))}),e.jsx("span",{className:"nice-palette__preset-label",children:Hn[Q]})]},Q)})})]}),F&&e.jsxs("div",{className:"nice-palette__info-panel",children:[e.jsx("div",{className:"nice-palette__section-title",children:"Selected Color Info"}),e.jsx(zn,{hex:Pe})]}),e.jsxs("details",{className:"nice-palette__custom-schemes",style:{marginTop:8},children:[e.jsxs("summary",{style:{cursor:"pointer",padding:"6px 10px",background:"var(--bg-secondary)",color:"var(--text-primary)",border:"1px solid var(--border-color)",borderRadius:4,display:"inline-block",fontSize:12,userSelect:"none"},children:["Custom schemes (",E.length,")"]}),e.jsxs("div",{style:{marginTop:8,display:"flex",flexDirection:"column",gap:6},children:[E.length===0&&e.jsx("div",{style:{fontSize:12,color:"var(--text-muted)"},children:s("colorPalette.schemes.empty","Save the current palette as a reusable scheme.")}),E.map(Q=>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:jt("custom",{angles:Q.angles,size:16})}),e.jsx("span",{style:{flex:1},children:Q.name}),e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--xs",onClick:()=>{ke(Q.id),Re("custom")},disabled:y,children:"Use"}),e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--xs",onClick:()=>b(E.filter(pe=>pe.id!==Q.id)),disabled:y,"aria-label":`Delete ${Q.name}`,children:"×"})]},Q.id)),e.jsxs("div",{style:{display:"flex",gap:6},children:[e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm",disabled:y,onClick:()=>{const Q=typeof window<"u"?window.prompt("Scheme name?",`Scheme ${E.length+1}`):null;if(!Q)return;const pe=Ae(J[0]).h,_e=J.map(T=>(Ae(T).h-pe+540)%360-180),a={id:`cs-${Date.now()}`,name:Q,angles:_e};b([...E,a])},children:"+ Save current as scheme"}),e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm",disabled:y||E.length===0,onClick:()=>{typeof navigator>"u"||navigator.clipboard?.writeText(JSON.stringify(E,null,2))},children:s("colorPalette.exportJson","Export JSON")}),e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm",disabled:y,onClick:()=>{if(typeof window>"u")return;const Q=window.prompt("Paste schemes JSON");if(Q)try{const pe=JSON.parse(Q);Array.isArray(pe)&&b(pe)}catch{}},children:s("colorPalette.importJson","Import JSON")})]})]})]}),Z&&e.jsxs("details",{className:"nice-palette__contrast-popup",style:{marginTop:8},children:[e.jsx("summary",{style:{cursor:"pointer",padding:"6px 10px",background:"var(--bg-secondary)",color:"var(--text-primary)",border:"1px solid var(--border-color)",borderRadius:4,display:"inline-block",fontSize:12,userSelect:"none"},children:"Contrast Analysis (WCAG 2.1)"}),e.jsx("div",{style:{marginTop:8},children:e.jsx(Ln,{colors:J})})]})]})});Xt.displayName="NiceColorPalette";function dt(){return{type:"linear",angle:90,stops:[{color:"var(--nice-primary, #3b82f6)",position:0},{color:"var(--nice-accent, #8b5cf6)",position:100}]}}function mt(t){const i=t.stops.slice().sort((r,l)=>r.position-l.position).map(r=>`${r.color} ${r.position}%`).join(", "),o=t.repeating?"repeating-":"";switch(t.type){case"linear":return`${o}linear-gradient(${t.angle}deg, ${i})`;case"radial":{const r=t.shape||"ellipse",l=t.size||"farthest-corner",h=t.positionX??50,C=t.positionY??50;return`${o}radial-gradient(${r} ${l} at ${h}% ${C}%, ${i})`}case"conic":{const r=t.angle??0,l=t.positionX??50,h=t.positionY??50;return`${o}conic-gradient(from ${r}deg at ${l}% ${h}%, ${i})`}}}function Vt(t){const i=t.trim(),o=i.startsWith("repeating-");if(i.includes("linear-gradient")){const r=i.match(/linear-gradient\((.+)\)/)?.[1];if(!r)return null;const l=r.split(",").map(z=>z.trim());let h=90,C=0;const k=l[0].match(/^(\d+)deg$/);k&&(h=parseInt(k[1]),C=1);const L=st(l.slice(C));return{type:"linear",angle:h,repeating:o,stops:L}}if(i.includes("radial-gradient")){const r=i.match(/radial-gradient\((.+)\)/)?.[1];if(!r)return null;const l=r.split(",").map(C=>C.trim()),h=st(l.filter(C=>C.includes("#")||C.includes("rgb")));return{type:"radial",angle:0,repeating:o,stops:h.length>=2?h:dt().stops}}if(i.includes("conic-gradient")){const r=i.match(/conic-gradient\((.+)\)/)?.[1];if(!r)return null;const l=r.split(",").map(C=>C.trim()),h=st(l.filter(C=>C.includes("#")||C.includes("rgb")));return{type:"conic",angle:0,repeating:o,stops:h.length>=2?h:dt().stops}}return null}function st(t){return t.map((i,o,r)=>{const l=i.match(/^(#[0-9a-fA-F]{3,8}|rgba?\([^)]+\))\s*(\d+%?)?$/);if(l){const h=l[2]?parseFloat(l[2]):o/Math.max(1,r.length-1)*100;return{color:l[1],position:h}}return{color:i,position:o/Math.max(1,r.length-1)*100}})}function Yn(){return"#"+Math.floor(Math.random()*16777215).toString(16).padStart(6,"0")}function Un(t=2){const i=["linear","radial","conic"],o=i[Math.floor(Math.random()*i.length)],r=[];for(let l=0;l<t;l++)r.push({color:Yn(),position:Math.round(l/(t-1)*100)});return{type:o,angle:Math.floor(Math.random()*360),stops:r,shape:o==="radial"?Math.random()>.5?"circle":"ellipse":void 0,positionX:o!=="linear"?Math.round(Math.random()*100):void 0,positionY:o!=="linear"?Math.round(Math.random()*100):void 0}}const qt=[{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}}],Gt=n.forwardRef(({id:t,className:i,style:o,accessMode:r,value:l,onChange:h,showCssOutput:C=!0,showPresets:k=!0,showEditor:L=!0,showRandom:z=!0,maxStops:W=10,label:K,disabled:_,width:O},H)=>{const Z=te.Zs(r,t),F=Z==="hidden";(Z==="disabled"||Z==="readOnly")&&(_=!0);const X=te.Hs(t),f=l??dt(),w=n.useMemo(()=>mt(f),[f]),[S,M]=n.useState(0),[G,y]=n.useState(""),N=n.useRef(null),j=n.useCallback(g=>{h?.(g)},[h]),$=n.useCallback(g=>{_||j({...f,type:g})},[_,f,j]),A=n.useCallback(g=>{_||j({...f,angle:g})},[_,f,j]),P=n.useCallback(g=>{_||j({...f,repeating:g})},[_,f,j]),v=n.useCallback(g=>{_||j({...f,shape:g})},[_,f,j]),c=n.useCallback((g,u)=>{if(_)return;const R=f.stops.map((V,I)=>I===g?{...V,...u}:V);j({...f,stops:R})},[_,f,j]),D=n.useCallback(()=>{if(_||f.stops.length>=W)return;const g=f.stops.slice().sort((ee,me)=>ee.position-me.position);let u=0,R=g[0];for(let ee=0;ee<g.length-1;ee++){const me=g[ee+1].position-g[ee].position;me>u&&(u=me,R=g[ee])}const V=Math.round(R.position+u/2),I="#"+Math.floor(Math.random()*16777215).toString(16).padStart(6,"0");j({...f,stops:[...f.stops,{color:I,position:V}]})},[_,f,W,j]),x=n.useCallback(g=>{if(_||f.stops.length<=2)return;const u=f.stops.filter((R,V)=>V!==g);j({...f,stops:u}),S>=u.length&&M(u.length-1)},[_,f,S,j]),m=n.useCallback(()=>{if(_)return;const g=2+Math.floor(Math.random()*3);j(Un(g))},[_,j]),s=n.useCallback(()=>{if(_||!G.trim())return;const g=Vt(G);g&&j(g)},[_,G,j]),d=n.useCallback(g=>{if(_||!N.current||f.stops.length>=W)return;const u=N.current.getBoundingClientRect(),R=Math.round((g.clientX-u.left)/u.width*100),V="#"+Math.floor(Math.random()*16777215).toString(16).padStart(6,"0"),I=[...f.stops,{color:V,position:R}];j({...f,stops:I}),M(I.length-1)},[_,f,W,j]),p=n.useMemo(()=>f.stops.slice().sort((g,u)=>g.position-u.position),[f.stops]);return F?null:e.jsxs("div",{ref:H,id:X,className:`nice-gradient ${_?"nice-gradient--disabled":""} ${i||""}`,style:{width:O!=null?typeof O=="number"?`${O}px`:O:320,boxSizing:"border-box",...o},children:[K&&e.jsx("div",{className:"nice-gradient__label",children:K}),e.jsx("div",{className:"nice-gradient__preview",style:{background:w}}),L&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"nice-gradient__type-row",children:[["linear","radial","conic"].map(g=>e.jsx("button",{type:"button",className:`nice-gradient__type-btn ${f.type===g?"nice-gradient__type-btn--active":""}`,onClick:()=>$(g),disabled:_,children:g.charAt(0).toUpperCase()+g.slice(1)},g)),e.jsxs("label",{className:"nice-gradient__repeat-label",children:[e.jsx("input",{type:"checkbox",checked:f.repeating??!1,onChange:g=>P(g.target.checked),disabled:_}),"Repeating"]})]}),e.jsxs("div",{className:"nice-gradient__controls",children:[f.type==="linear"&&e.jsxs("div",{className:"nice-gradient__control-group",children:[e.jsxs("label",{children:["Angle: ",f.angle,"°"]}),e.jsx("input",{type:"range",min:0,max:360,value:f.angle,onChange:g=>A(Number(g.target.value)),disabled:_,className:"nice-gradient__slider"}),e.jsx("div",{className:"nice-gradient__angle-presets",children:[0,45,90,135,180,225,270,315].map(g=>e.jsx("button",{type:"button",className:`nice-gradient__angle-btn ${f.angle===g?"nice-gradient__angle-btn--active":""}`,onClick:()=>A(g),disabled:_,title:`${g}°`,children:e.jsx("span",{style:{transform:`rotate(${g}deg)`,display:"inline-block"},children:"→"})},g))})]}),f.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(g=>e.jsx("button",{type:"button",className:`nice-gradient__shape-btn ${(f.shape||"ellipse")===g?"nice-gradient__shape-btn--active":""}`,onClick:()=>v(g),disabled:_,children:g},g))})]}),(f.type==="radial"||f.type==="conic")&&e.jsxs("div",{className:"nice-gradient__control-group",children:[e.jsxs("label",{children:["Center: ",f.positionX??50,"%, ",f.positionY??50,"%"]}),e.jsxs("div",{className:"nice-gradient__center-inputs",children:[e.jsx("input",{type:"range",min:0,max:100,value:f.positionX??50,onChange:g=>j({...f,positionX:Number(g.target.value)}),disabled:_,className:"nice-gradient__slider"}),e.jsx("input",{type:"range",min:0,max:100,value:f.positionY??50,onChange:g=>j({...f,positionY:Number(g.target.value)}),disabled:_,className:"nice-gradient__slider"})]})]}),f.type==="conic"&&e.jsxs("div",{className:"nice-gradient__control-group",children:[e.jsxs("label",{children:["Start angle: ",f.angle,"°"]}),e.jsx("input",{type:"range",min:0,max:360,value:f.angle,onChange:g=>A(Number(g.target.value)),disabled:_,className:"nice-gradient__slider"})]})]}),e.jsxs("div",{className:"nice-gradient__bar-container",children:[e.jsx("div",{ref:N,className:"nice-gradient__bar",style:{background:w},onClick:d,children:f.stops.map((g,u)=>e.jsx("div",{className:`nice-gradient__stop-marker ${S===u?"nice-gradient__stop-marker--active":""}`,style:{left:`${g.position}%`},onClick:R=>{R.stopPropagation(),M(u)},title:`${g.color} @ ${g.position}%`,children:e.jsx("div",{className:"nice-gradient__stop-dot",style:{background:g.color}})},u))}),e.jsx("button",{type:"button",className:"nice-gradient__add-stop",onClick:D,disabled:_||f.stops.length>=W,title:"Add stop",children:"+"})]}),e.jsx("div",{className:"nice-gradient__stop-editor",children:e.jsx("div",{className:"nice-gradient__stop-list",children:p.map((g,u)=>{const R=f.stops.indexOf(g);return e.jsxs("div",{className:`nice-gradient__stop-row ${S===R?"nice-gradient__stop-row--active":""}`,onClick:()=>M(R),children:[e.jsx("input",{type:"color",value:g.color,onChange:V=>c(R,{color:V.target.value}),disabled:_,className:"nice-gradient__stop-color"}),e.jsx("input",{type:"text",value:g.color.toUpperCase(),maxLength:7,onChange:V=>c(R,{color:V.target.value}),disabled:_,className:"nice-gradient__stop-hex"}),e.jsx("input",{type:"number",min:0,max:100,value:g.position,onChange:V=>c(R,{position:Number(V.target.value)}),disabled:_,className:"nice-gradient__stop-pos"}),e.jsx("span",{className:"nice-gradient__stop-pct",children:"%"}),f.stops.length>2&&e.jsx("button",{type:"button",className:"nice-gradient__stop-del",onClick:()=>x(R),disabled:_,"aria-label":"Remove stop",children:"×"})]},R)})})})]}),z&&e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm nice-gradient__random-btn",onClick:m,disabled:_,title:"Random gradient","aria-label":"Random gradient",children:"🎲 Random Gradient"}),k&&e.jsxs("div",{className:"nice-gradient__presets",children:[e.jsx("div",{className:"nice-gradient__section-title",children:"Presets"}),e.jsx("div",{className:"nice-gradient__preset-grid",children:qt.map((g,u)=>e.jsxs("button",{type:"button",className:"nice-gradient__preset-card",onClick:()=>{_||j(g.value)},disabled:_,title:g.name,children:[e.jsx("div",{className:"nice-gradient__preset-preview",style:{background:mt(g.value)}}),e.jsx("span",{className:"nice-gradient__preset-name",children:g.name})]},u))})]}),C&&e.jsxs("div",{className:"nice-gradient__css",children:[e.jsx("div",{className:"nice-gradient__section-title",children:"CSS Output"}),e.jsxs("div",{className:"nice-gradient__css-output",children:[e.jsx("code",{children:`background: ${w};`}),e.jsx("button",{type:"button",className:"nice-gradient__copy-btn",onClick:()=>navigator.clipboard?.writeText(`background: ${w};`),title:"Copy CSS",children:"📋"})]}),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:G,onChange:g=>y(g.target.value),disabled:_}),e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm",onClick:s,disabled:_,children:"Import"})]})]})]})});Gt.displayName="NiceGradientPicker";const Wn=({options:t,value:i,onChange:o,searchable:r=!0,clearable:l,loading:h,placeholder:C,label:k,error:L,helperText:z,required:W,disabled:K,size:_="md",id:O,className:H,style:Z,data:F,columns:X,valueField:f="id",displayField:w,dropdownWidth:S,controlWidth:M})=>{const G=te.Hs(O),{t:y}=te.Jo(),[N,j]=n.useState(!1),[$,A]=n.useState(""),P=n.useRef(null);te.$s(P,()=>j(!1));const v=!!(F&&X&&X.length>0),c=w??(X&&X[0]?.key),D=n.useMemo(()=>!v||!F?[]:F.map(p=>({value:String(p[f]??""),label:c?String(p[c]??""):""})),[v,F,f,c]),x=v?D:t??[],m=x.find(p=>String(p.value)===i),s=n.useMemo(()=>{if(!v||!F)return[];if(!$)return F;const p=$.toLowerCase();return F.filter(g=>X.some(u=>String(g[u.key]??"").toLowerCase().includes(p)))},[v,F,X,$]),d=n.useMemo(()=>{if(v||!$)return x;const p=$.toLowerCase();return x.filter(g=>g.label.toLowerCase().includes(p))},[x,$,v]);return e.jsxs("div",{className:`nice-field nice-field--${_} ${L?"nice-field--error":""} ${H||""}`,style:{width:M!=null?typeof M=="number"?`${M}px`:M:"fit-content",...Z},ref:P,children:[k&&e.jsxs("label",{className:"nice-field__label",htmlFor:G,children:[k,W&&e.jsx("span",{className:"nice-field__required",children:"*"})]}),e.jsxs("div",{className:"nice-field__input-wrap",style:{position:"relative"},children:[e.jsxs("button",{type:"button",id:G,className:"nice-select__trigger",onClick:()=>!K&&j(!N),disabled:K,children:[e.jsx("span",{children:m?.label||C||y("controls.select","Select...")}),e.jsx("span",{className:"nice-select__arrow",children:"▾"})]}),l&&i&&!K&&e.jsx("button",{type:"button",className:"nice-field__clear",onClick:()=>o(""),"aria-label":y("controls.clear","Clear"),children:"✕"}),N&&e.jsxs("div",{className:"nice-dropdown nice-lookup__dropdown",style:{position:"absolute",top:"100%",left:0,zIndex:50,marginTop:4,background:"var(--bg-primary)",border:"1px solid var(--border-color)",borderRadius:"var(--nice-radius-md)",boxShadow:"0 4px 16px var(--nice-overlay-15, rgba(0, 0, 0, 0.15))",minWidth:"100%",width:S!=null?typeof S=="number"?`${S}px`:S:v?"max-content":"100%"},children:[r&&e.jsx("div",{className:"nice-dropdown__search",style:{padding:6},children:e.jsx("input",{type:"text",value:$,onChange:p=>A(p.target.value),placeholder:y("controls.search","Search..."),autoFocus:!0,style:{width:"100%",padding:"4px 8px",border:"1px solid var(--border-color)",borderRadius:4,background:"var(--bg-primary)",color:"var(--text-primary)"}})}),v?e.jsxs("table",{className:"nice-lookup__grid",role:"listbox",style:{width:"100%",borderCollapse:"collapse",color:"var(--text-primary)"},children:[e.jsx("thead",{children:e.jsx("tr",{children:X.map(p=>e.jsx("th",{style:{padding:"6px 10px",textAlign:"left",fontSize:12,fontWeight:600,color:"var(--text-secondary)",background:"var(--bg-secondary)",borderBottom:"1px solid var(--border-color)",width:p.width!=null?typeof p.width=="number"?`${p.width}px`:p.width:void 0},children:p.header},p.key))})}),e.jsx("tbody",{children:s.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:X.length,style:{padding:12,textAlign:"center",color:"var(--text-muted)"},children:y("controls.noResults","No results")})}):s.map(p=>{const g=String(p[f]??""),u=g===i;return e.jsx("tr",{role:"option","aria-selected":u,onClick:()=>{o(g),j(!1),A("")},style:{cursor:"pointer",background:u?"var(--hover-bg)":"transparent"},onMouseEnter:R=>{u||(R.currentTarget.style.background="var(--hover-bg)")},onMouseLeave:R=>{u||(R.currentTarget.style.background="transparent")},children:X.map(R=>e.jsx("td",{style:{padding:"6px 10px",fontSize:13,borderBottom:"1px solid var(--border-color)"},children:String(p[R.key]??"")},R.key))},g)})})]}):e.jsx("ul",{className:"nice-dropdown__list",role:"listbox",style:{listStyle:"none",margin:0,padding:4,maxHeight:240,overflowY:"auto"},children:d.length===0?e.jsx("li",{className:"nice-dropdown__empty",style:{padding:8,color:"var(--text-muted)"},children:y("controls.noResults","No results")}):d.map(p=>e.jsx("li",{role:"option",className:`nice-dropdown__option ${String(p.value)===i?"nice-dropdown__option--selected":""}`,onClick:()=>{o(String(p.value)),j(!1),A("")},"aria-selected":String(p.value)===i,children:p.label},String(p.value)))})]})]}),L&&e.jsx("div",{className:"nice-field__error",children:L}),z&&!L&&e.jsx("div",{className:"nice-field__hint",children:z})]})},Xn=["Su","Mo","Tu","We","Th","Fr","Sa"];function Vn(t,i){return new Date(t,i+1,0).getDate()}function qn(t,i){return new Date(t,i,1).getDay()}function wt(t,i,o){return`${t}-${String(i+1).padStart(2,"0")}-${String(o).padStart(2,"0")}`}function Gn(t){const i=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate()));i.setUTCDate(i.getUTCDate()+4-(i.getUTCDay()||7));const o=new Date(Date.UTC(i.getUTCFullYear(),0,1));return Math.ceil(((i.getTime()-o.getTime())/864e5+1)/7)}const Nt=["January","February","March","April","May","June","July","August","September","October","November","December"],Jt=({value:t,onChange:i,min:o,max:r,disabledDates:l=[],firstDayOfWeek:h=1,size:C="md",showWeekNumbers:k,onMonthChange:L,className:z,style:W,accessMode:K,id:_,multiple:O,selectedDates:H=[],onSelectedDatesChange:Z,renderDay:F,showKeyboardHints:X,persistPreferences:f=!1,fullWidth:w=!1,cookies:S=!1,localStorage:M=!0,sessionStorage:G=!1,storageMode:y,storageKey:N})=>{const j=te.Zs(K,_),$=j==="hidden",A=j==="disabled"||j==="readOnly",{t:P}=te.Jo(),v=new Date,c=t?new Date(t):v,D=te.useStorageAdapter(N??"nice-calendar"),x=n.useMemo(()=>f?D.get("prefs")??{}:{},[f,D]),m=x.firstDayOfWeek??h,[s,d]=n.useState(x.lastViewYear??c.getFullYear()),[p,g]=n.useState(x.lastViewMonth??c.getMonth()),[u,R]=n.useState(x.preferredView??"days"),V=n.useCallback(B=>{if(!f)return;const J=D.get("prefs")??{};D.set("prefs",{...J,...B})},[f,D]),I=n.useCallback(B=>{R(B),V({preferredView:B})},[V]),ee=n.useCallback((B,J)=>{V({lastViewYear:B,lastViewMonth:J})},[V]),me=n.useMemo(()=>[te.mc.moveUp,te.mc.moveDown,te.mc.moveLeft,te.mc.moveRight,{key:"Enter",description:P("shortcuts.selectDate","Select date")},te.mc.pageUp,te.mc.pageDown],[P]),Y=n.useMemo(()=>Vn(s,p),[s,p]),ne=n.useMemo(()=>(qn(s,p)-m+7)%7,[s,p,m]),oe=n.useMemo(()=>{const B=[...Xn];for(let J=0;J<m;J++)B.push(B.shift());return B},[m]),ue=n.useCallback(B=>o&&B<o||r&&B>r?!0:l.includes(B),[o,r,l]),ye=n.useCallback(B=>{if(u==="years"){d(fe=>fe+B*10);return}if(u==="months"){d(fe=>fe+B);return}let J=p+B,be=s;J<0&&(J=11,be--),J>11&&(J=0,be++),g(J),d(be),ee(be,J),L?.(be,J)},[p,s,L,u,ee]),ge=wt(v.getFullYear(),v.getMonth(),v.getDate()),ke=n.useCallback(B=>O?H.includes(B):B===t,[O,H,t]),ie=n.useCallback(B=>{if(!A){if(O){const J=H.includes(B)?H.filter(be=>be!==B):[...H,B];Z?.(J)}i?.(B)}},[O,H,i,Z]),re=n.useCallback(()=>{u==="days"?I("months"):u==="months"&&I("years")},[u,I]),le=n.useCallback(B=>{g(B),I("days"),ee(s,B),L?.(s,B)},[s,L,I,ee]),ae=n.useCallback(B=>{d(B),I("months")},[I]),E=u==="years"?`${s-s%10} – ${s-s%10+9}`:u==="months"?`${s}`:`${Nt[p]} ${s}`,b=u==="years"?"decade":u==="months"?"year":"month",q=[];for(let B=0;B<ne;B++)q.push(null);for(let B=1;B<=Y;B++)q.push(B);for(;q.length%7!==0;)q.push(null);const ce=[];for(let B=0;B<q.length;B+=7)ce.push(q.slice(B,B+7));const de=s-s%10;return $?null:e.jsxs("div",{className:`nice-calendar nice-calendar--${C}${w?" nice-calendar--full-width":""} ${z||""}`,style:W,children:[e.jsxs("div",{className:"nice-calendar__header",children:[e.jsx("button",{type:"button",className:"nice-calendar__nav",onClick:()=>ye(-1),"aria-label":`Previous ${b}`,children:"‹"}),e.jsx("button",{type:"button",className:"nice-calendar__title",onClick:re,"aria-label":u==="days"?"Show month picker":u==="months"?"Show year picker":void 0,disabled:u==="years",children:E}),e.jsx("button",{type:"button",className:"nice-calendar__nav",onClick:()=>ye(1),"aria-label":`Next ${b}`,children:"›"}),X&&e.jsx(te.Kr,{shortcuts:me,size:"sm"})]}),u==="days"&&e.jsxs("table",{className:"nice-calendar__grid",role:"grid",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[k&&e.jsx("th",{className:"nice-calendar__wk",children:"W"}),oe.map(B=>e.jsx("th",{children:B},B))]})}),e.jsx("tbody",{children:ce.map((B,J)=>e.jsxs("tr",{children:[k&&e.jsx("td",{className:"nice-calendar__wk",children:B.find(be=>be!=null)?Gn(new Date(s,p,B.find(be=>be!=null))):""}),B.map((be,fe)=>{if(be==null)return e.jsx("td",{className:"nice-calendar__empty-cell"},fe);const we=wt(s,p,be),je=ue(we),De=ke(we),Re=we===ge;return e.jsx("td",{className:`nice-calendar__day${De?" nice-calendar__day--selected":""}${Re?" nice-calendar__day--today":""}${je?" nice-calendar__day--disabled":""}`,onClick:()=>!je&&ie(we),role:"gridcell","aria-selected":De,"aria-disabled":je,children:F?F(we,be):be},fe)})]},J))})]}),u==="months"&&e.jsx("div",{className:"nice-calendar__picker-grid",children:Nt.map((B,J)=>e.jsx("button",{type:"button",className:`nice-calendar__picker-cell${J===p&&s===c.getFullYear()?" nice-calendar__picker-cell--selected":""}`,onClick:()=>le(J),children:B.slice(0,3)},J))}),u==="years"&&e.jsx("div",{className:"nice-calendar__picker-grid",children:Array.from({length:12},(B,J)=>de-1+J).map(B=>e.jsx("button",{type:"button",className:`nice-calendar__picker-cell${B===s?" nice-calendar__picker-cell--selected":""}${B<de||B>de+9?" nice-calendar__picker-cell--other":""}`,onClick:()=>ae(B),children:B},B))})]})};Jt.displayName="NiceCalendar";const Jn=({startDate:t,endDate:i,onStartChange:o,onEndChange:r,min:l,max:h,clearable:C,startPlaceholder:k,endPlaceholder:L,startLabel:z,endLabel:W,layout:K="horizontal",separator:_="–",gap:O=12,fullWidth:H=!1,label:Z,error:F,helperText:X,required:f,disabled:w,size:S="md",id:M,className:G,style:y,accessMode:N,showKeyboardHints:j,labelPlacement:$,errorPlacement:A,labelWidth:P,controlWidth:v,loading:c})=>{const D=te.Zs(N,M),x=te.Hs(M),{t:m}=te.Jo(),s=D==="disabled"||D==="readOnly"||!!w,d=n.useMemo(()=>[{key:"Tab",description:m("shortcuts.switchField","Switch between start/end")},te.mc.cancel],[m]);if(D==="hidden")return null;const p=u=>{o(u),u&&i&&u>i&&r(u)},g=K==="horizontal";return e.jsxs("div",{className:`nice-field nice-field--${S} nice-daterange nice-daterange--${K} ${$==="left"?"nice-field--label-left":""} ${F?"nice-field--error":""} ${c?"nice-field--loading":""} ${G||""}`,style:{...y,...P!=null&&{"--nice-field-label-width":typeof P=="number"?`${P}px`:P},...v!=null&&{"--nice-field-control-width":typeof v=="number"?`${v}px`:v}},"aria-busy":c||void 0,children:[Z&&e.jsxs("label",{className:"nice-field__label",htmlFor:x,children:[Z,f&&e.jsx("span",{className:"nice-field__required",children:"*"}),j&&e.jsx(te.Kr,{shortcuts:d,size:"sm"})]}),e.jsxs("div",{className:"nice-field__control",children:[e.jsxs("div",{className:"nice-daterange__row",style:{display:"flex",flexDirection:g?"row":"column",alignItems:g?"flex-end":"stretch",gap:O,flexWrap:"wrap"},children:[e.jsx("div",{style:{flex:H?"1 1 0":void 0,minWidth:0},children:e.jsx(bt.NiceDatePicker,{id:x,label:z,value:t,onChange:p,min:l,max:i||h,placeholder:k||m("controls.startDate","Start date"),disabled:s,size:S,clearable:C,labelPlacement:$,labelWidth:P})}),g&&_!==""&&_!=null&&e.jsx("span",{className:"nice-daterange__separator",style:{paddingBottom:8,color:"var(--text-secondary, #666)"},"aria-hidden":"true",children:_}),e.jsx("div",{style:{flex:H?"1 1 0":void 0,minWidth:0},children:e.jsx(bt.NiceDatePicker,{label:W,value:i,onChange:r,min:t||l,max:h,placeholder:L||m("controls.endDate","End date"),disabled:s,size:S,clearable:C,labelPlacement:$,labelWidth:P})})]}),c&&e.jsx("span",{className:"nice-field__spinner",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})}),A==="right"&&F&&e.jsx("div",{className:"nice-field__error",role:"alert",children:F}),A==="right"&&!F&&X&&e.jsx("div",{className:"nice-field__helper",children:X})]}),A!=="right"&&F&&e.jsx("div",{className:"nice-field__error",children:F}),A!=="right"&&!F&&X&&e.jsx("div",{className:"nice-field__hint",children:X})]})},Zn=({min:t=0,max:i=100,step:o=1,startValue:r,endValue:l,onChange:h,showLabels:C=!0,formatLabel:k,valuePlacement:L="none",label:z,error:W,helperText:K,required:_,disabled:O,readOnly:H,loading:Z,size:F="md",id:X,className:f,style:w,accessMode:S,showKeyboardHints:M,labelPlacement:G,errorPlacement:y,labelWidth:N,controlWidth:j})=>{const $=te.Zs(S,X),A=$==="hidden";($==="disabled"||$==="readOnly")&&(O=!0);const{t:P}=te.Jo(),v=te.Hs(X),c=n.useRef(null),D=n.useMemo(()=>[te.mc.increment,te.mc.decrement,te.mc.first,te.mc.last,{key:"Tab",description:P("shortcuts.switchThumb","Switch thumb")}],[P]),x=p=>(p-t)/(i-t)*100,m=p=>k?k(p):String(p),s=p=>{const g=Math.round(p/o)*o;return Math.max(t,Math.min(i,g))},d=n.useCallback((p,g)=>{p.preventDefault();const u=c.current;if(!u||O)return;const R=I=>{const ee=u.getBoundingClientRect(),me=Math.max(0,Math.min(1,(I.clientX-ee.left)/ee.width)),Y=s(t+me*(i-t));g==="start"?h(Math.min(Y,l),l):h(r,Math.max(Y,r))},V=()=>{document.removeEventListener("pointermove",R),document.removeEventListener("pointerup",V)};document.addEventListener("pointermove",R),document.addEventListener("pointerup",V)},[t,i,o,r,l,h,O]);return A?null:e.jsxs("div",{className:`nice-field nice-field--${F} nice-field--rangeslider ${G==="left"?"nice-field--label-left":""} ${y==="right"?"nice-field--error-right":""} ${W?"nice-field--error":""} ${Z?"nice-field--loading":""} ${f||""}`,style:{...w,...N!=null&&{"--nice-field-label-width":typeof N=="number"?`${N}px`:N},...j!=null&&{"--nice-field-control-width":typeof j=="number"?`${j}px`:j}},"aria-busy":Z||void 0,children:[z&&e.jsxs("label",{className:"nice-field__label nice-field__label--with-value",htmlFor:v,children:[e.jsxs("span",{className:"nice-field__label-text",children:[z,_&&e.jsx("span",{className:"nice-field__required",children:"*"}),M&&e.jsx(te.Kr,{shortcuts:D,size:"sm"})]}),L==="right"&&e.jsxs("span",{className:"nice-range-slider__value nice-range-slider__value--inline",children:[m(r)," – ",m(l)]})]}),e.jsxs("div",{className:"nice-field__control",children:[L==="right"&&!z&&e.jsxs("span",{className:"nice-range-slider__value",children:[m(r)," – ",m(l)]}),e.jsxs("div",{className:"nice-range-slider__stack",children:[e.jsxs("div",{className:`nice-range-slider ${C?"nice-range-slider--with-labels":""} ${z?"nice-range-slider--has-field-label":""}`,ref:c,children:[e.jsx("div",{className:"nice-range-slider__track",children:e.jsx("div",{className:"nice-range-slider__fill",style:{left:`${x(r)}%`,width:`${x(l)-x(r)}%`}})}),e.jsx("div",{className:"nice-range-slider__thumb",style:{left:`${x(r)}%`},onPointerDown:p=>H?void 0:d(p,"start"),role:"slider","aria-valuemin":t,"aria-valuemax":l,"aria-valuenow":r,tabIndex:O?-1:0,id:v}),e.jsx("div",{className:"nice-range-slider__thumb",style:{left:`${x(l)}%`},onPointerDown:p=>H?void 0:d(p,"end"),role:"slider","aria-valuemin":r,"aria-valuemax":i,"aria-valuenow":l,tabIndex:O?-1:0})]}),C&&e.jsxs("div",{className:"nice-range-slider__values",children:[e.jsx("span",{className:"nice-range-slider__values-start",style:{left:`${x(r)}%`},children:m(r)}),e.jsx("span",{className:"nice-range-slider__values-end",style:{left:`${x(l)}%`},children:m(l)})]}),L==="bottom"&&e.jsxs("div",{className:"nice-range-slider__value nice-range-slider__value--bottom",children:[m(r)," – ",m(l)]})]}),Z&&e.jsx("span",{className:"nice-field__spinner",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})}),y==="right"&&W&&e.jsx("div",{className:"nice-field__error",role:"alert",children:W}),y==="right"&&!W&&K&&e.jsx("div",{className:"nice-field__helper",children:K})]}),y!=="right"&&W&&e.jsx("div",{className:"nice-field__error",role:"alert",children:W}),y!=="right"&&!W&&K&&e.jsx("div",{className:"nice-field__helper",children:K})]})},Qn=({displayValue:t,placeholder:i,clearable:o,children:r,onClear:l,open:h,onOpenChange:C,dropdownWidth:k,label:L,error:z,helperText:W,required:K,disabled:_,size:O="md",id:H,className:Z,style:F,accessMode:X,showKeyboardHints:f,displayStyle:w})=>{te.vs("input",w),te.Ss("input",w);const S=te.Zs(X,H),M=S==="hidden";(S==="disabled"||S==="readOnly")&&(_=!0);const G=te.Hs(H),{t:y}=te.Jo(),[N,j]=n.useState(!1),$=n.useRef(null),A=h??N,P=n.useMemo(()=>[{key:"Enter",description:y("shortcuts.openDropdown","Open dropdown")},te.mc.cancel],[y]),v=c=>{C?C(c):j(c)};return te.$s($,()=>v(!1)),M?null:e.jsxs("div",{className:`nice-field nice-field--${O} ${z?"nice-field--error":""} ${Z||""}`,style:F,ref:$,children:[L&&e.jsxs("label",{className:"nice-field__label",htmlFor:G,children:[L,K&&e.jsx("span",{className:"nice-field__required",children:"*"}),f&&e.jsx(te.Kr,{shortcuts:P,size:"sm"})]}),e.jsxs("div",{className:"nice-field__input-wrap",children:[e.jsxs("button",{type:"button",id:G,className:"nice-select__trigger",onClick:()=>!_&&v(!A),disabled:_,children:[e.jsx("span",{children:t||i||y("controls.select","Select...")}),e.jsx("span",{className:"nice-select__arrow",children:"▾"})]}),o&&t&&!_&&e.jsx("button",{type:"button",className:"nice-field__clear",onClick:()=>l?.(),"aria-label":y("controls.clear","Clear"),children:"✕"})]}),A&&e.jsx("div",{className:"nice-dropdown",style:{width:k},children:r}),z&&e.jsx("div",{className:"nice-field__error",children:z}),W&&!z&&e.jsx("div",{className:"nice-field__hint",children:W})]})};function Ct(t){const i=t.trim().toLowerCase();return i.startsWith("http://")||i.startsWith("https://")||i.startsWith("/")||i.startsWith("./")||i.startsWith("../")?!0:!(i.startsWith("javascript:")||i.startsWith("vbscript:")||i.startsWith("data:text"))}const ei=["bold","italic","underline","strikethrough","h1","h2","h3","ul","ol","blockquote","hr","link","unlink","image","table","code","alignLeft","alignCenter","alignRight","fontSize","fontColor","undo","redo","clear","findReplace","emoji","source","fullscreen","markdown"],Ne=({d:t,viewBox:i="0 0 24 24"})=>e.jsx("svg",{width:"16",height:"16",viewBox:i,fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("path",{d:t})}),ti={bold:e.jsx("strong",{style:{fontFamily:"serif"},children:"B"}),italic:e.jsx("em",{style:{fontFamily:"serif"},children:"I"}),underline:e.jsx("span",{style:{textDecoration:"underline"},children:"U"}),strikethrough:e.jsx("span",{style:{textDecoration:"line-through"},children:"S"}),h1:"H1",h2:"H2",h3:"H3",ul:e.jsx(Ne,{d:"M8 6h13M8 12h13M8 18h13M3 6h.01M3 12h.01M3 18h.01"}),ol:e.jsx(Ne,{d:"M10 6h11M10 12h11M10 18h11M4 6h1v4M4 10h2M6 18H4c0-1 2-2 2-3s-1-1.5-2-1"}),link:e.jsx(Ne,{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"}),unlink:e.jsx(Ne,{d:"M18.84 12.25l1.72-1.71a5 5 0 0 0-7.07-7.07L11 5.78M3 3l18 18M9 15l3-3M14 11l3 3M14 21l-1.72-1.72a5 5 0 0 1-7.07-7.07L7 10.49"}),undo:e.jsx(Ne,{d:"M3 7v6h6M3 13a9 9 0 1 0 3-7.7L3 13"}),redo:e.jsx(Ne,{d:"M21 7v6h-6M21 13a9 9 0 1 1-3-7.7L21 13"}),clear:e.jsx(Ne,{d:"M3 6h18M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"}),table:e.jsx(Ne,{d:"M3 3h18v18H3zM3 9h18M3 15h18M9 3v18M15 3v18"}),image:e.jsx(Ne,{d:"M3 3h18v18H3zM3 16l5-5 4 4 3-3 6 6M9 9a2 2 0 1 1-4 0 2 2 0 0 1 4 0z"}),code:e.jsx(Ne,{d:"M16 18l6-6-6-6M8 6l-6 6 6 6"}),markdown:"MD",blockquote:e.jsx(Ne,{d:"M3 21c3-3 3-9 0-12M21 21c-3-3-3-9 0-12M9 7h6v6H9zM15 7h6v6h-6z"}),hr:e.jsx(Ne,{d:"M5 12h14"}),subscript:"X₂",superscript:"X²",indent:e.jsx(Ne,{d:"M3 8l4 4-4 4M7 6h14M7 12h14M3 18h18"}),outdent:e.jsx(Ne,{d:"M7 8l-4 4 4 4M21 6H3M21 12H7M21 18H3"}),alignLeft:e.jsx(Ne,{d:"M3 6h18M3 12h12M3 18h18"}),alignCenter:e.jsx(Ne,{d:"M3 6h18M6 12h12M3 18h18"}),alignRight:e.jsx(Ne,{d:"M3 6h18M9 12h12M3 18h18"}),alignJustify:e.jsx(Ne,{d:"M3 6h18M3 12h18M3 18h18"}),fullscreen:e.jsx(Ne,{d:"M3 9V3h6M21 9V3h-6M3 15v6h6M21 15v6h-6"}),removeFormat:e.jsx(Ne,{d:"M4 7V4h16v3M5 20h6M13 4 8 20"}),print:e.jsx(Ne,{d:"M6 9V2h12v7M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2M6 14h12v8H6z"}),source:e.jsx(Ne,{d:"M16 18l6-6-6-6M8 6l-6 6 6 6"}),emoji:e.jsx(Ne,{d:"M12 22a10 10 0 1 1 0-20 10 10 0 0 1 0 20zM8 14s1.5 2 4 2 4-2 4-2M9 9h.01M15 9h.01"}),findReplace:e.jsx(Ne,{d:"M11 19a8 8 0 1 1 0-16 8 8 0 0 1 0 16zM21 21l-4.35-4.35"}),fontSize:e.jsx(Ne,{d:"M4 7V4h16v3M9 20h6M12 4v16"}),fontColor:e.jsx(Ne,{d:"M4 21h16M5 17l7-12 7 12M8 13h8"})},ni=[{value:"1",label:"8pt"},{value:"2",label:"10pt"},{value:"3",label:"12pt"},{value:"4",label:"14pt"},{value:"5",label:"18pt"},{value:"6",label:"24pt"},{value:"7",label:"36pt"}],ii=[{label:"Faces",emojis:["??","??","??","??","??","??","??","??","??","??","??","??"]},{label:"Hands",emojis:["??","??","??","??","??","??","??","??","??","??"]},{label:"Symbols",emojis:["??","?","??","?","?","?","??","??","??","??","??","??"]},{label:"Arrows",emojis:["??","??","??","??","??","??","??","??","??","?"]}];function oi(t){let i=t;return i=i.replace(/<h1[^>]*>(.*?)<\/h1>/gi,`# $1
2
+ `),i=i.replace(/<h2[^>]*>(.*?)<\/h2>/gi,`## $1
3
+ `),i=i.replace(/<h3[^>]*>(.*?)<\/h3>/gi,`### $1
4
+ `),i=i.replace(/<strong[^>]*>(.*?)<\/strong>/gi,"**$1**"),i=i.replace(/<b[^>]*>(.*?)<\/b>/gi,"**$1**"),i=i.replace(/<em[^>]*>(.*?)<\/em>/gi,"*$1*"),i=i.replace(/<i[^>]*>(.*?)<\/i>/gi,"*$1*"),i=i.replace(/<code[^>]*>(.*?)<\/code>/gi,"`$1`"),i=i.replace(/<pre[^>]*>(.*?)<\/pre>/gis,"```\n$1\n```\n"),i=i.replace(/<br\s*\/?>/gi,`
5
+ `),i=i.replace(/<li[^>]*>(.*?)<\/li>/gi,`- $1
6
+ `),i=i.replace(/<\/?(?:ul|ol|p|div)[^>]*>/gi,`
7
+ `),i=i.replace(/<[^>]+>/g,""),i=i.replace(/\n{3,}/g,`
8
+
9
+ `),i.trim()}function ai(t){let i=t;return i=i.replace(/^### (.+)$/gm,"<h3>$1</h3>"),i=i.replace(/^## (.+)$/gm,"<h2>$1</h2>"),i=i.replace(/^# (.+)$/gm,"<h1>$1</h1>"),i=i.replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>"),i=i.replace(/\*(.+?)\*/g,"<em>$1</em>"),i=i.replace(/`([^`]+)`/g,"<code>$1</code>"),i=i.replace(/```\n?([\s\S]*?)\n?```/g,"<pre>$1</pre>"),i=i.replace(/^- (.+)$/gm,"<li>$1</li>"),i=i.replace(/(<li>.*<\/li>)/gs,"<ul>$1</ul>"),i=i.replace(/\n/g,"<br>"),i}const ft=({value:t,onChange:i,placeholder:o,height:r=200,toolbar:l=ei,readOnly:h,onImageUpload:C,mentionTrigger:k,mentionSuggestions:L,onMentionSearch:z,onFileDrop:W,pasteCleanup:K=!0,maxLength:_=0,showWordCount:O=!1,templates:H,label:Z,error:F,helperText:X,required:f,disabled:w,size:S="md",id:M,className:G,style:y,accessMode:N})=>{const j=te.Zs(N,M),$=j==="hidden";j==="disabled"&&(w=!0),j==="readOnly"&&(h=!0);const A=te.Hs(M),P=n.useRef(null),v=n.useRef(null),c=n.useRef(null),[D,x]=n.useState(!1),[m,s]=n.useState(""),[d,p]=n.useState(!1),[g,u]=n.useState(""),[R,V]=n.useState(!1),[I,ee]=n.useState(""),[me,Y]=n.useState(0),[ne,oe]=n.useState(!1),[ue,ye]=n.useState("var(--nice-text, #000000)"),[ge,ke]=n.useState("var(--nice-warning, #ffff00)"),[ie,re]=n.useState(0),[le,ae]=n.useState(0),[E,b]=n.useState(!1),[q,ce]=n.useState(""),[de,B]=n.useState(""),[J,be]=n.useState(!1),[fe,we]=n.useState(!1),je=n.useCallback((a,T)=>{if(h||w)return;const U=P.current;if(U){if(a==="markdown"){if(!D)s(oi(t)),x(!0),p(!1);else{const se=ai(m);i(se),x(!1)}return}if(a==="source"){d?(i(g),p(!1)):(u(t),p(!0),x(!1));return}if(a==="fullscreen"){oe(se=>!se);return}if(a==="emoji"){be(se=>!se);return}if(a==="findReplace"){b(se=>!se);return}if(a==="image"){if(C)v.current?.click();else{const se=prompt("Image URL:");se&&Ct(se)&&(U.focus(),document.execCommand("insertImage",!1,se),i(te.As(U.innerHTML)))}return}switch(U.focus(),a){case"bold":document.execCommand("bold");break;case"italic":document.execCommand("italic");break;case"underline":document.execCommand("underline");break;case"strikethrough":document.execCommand("strikeThrough");break;case"h1":document.execCommand("formatBlock",!1,"h1");break;case"h2":document.execCommand("formatBlock",!1,"h2");break;case"h3":document.execCommand("formatBlock",!1,"h3");break;case"ul":document.execCommand("insertUnorderedList");break;case"ol":document.execCommand("insertOrderedList");break;case"blockquote":document.execCommand("formatBlock",!1,"blockquote");break;case"hr":document.execCommand("insertHorizontalRule");break;case"subscript":document.execCommand("subscript");break;case"superscript":document.execCommand("superscript");break;case"indent":document.execCommand("indent");break;case"outdent":document.execCommand("outdent");break;case"alignLeft":document.execCommand("justifyLeft");break;case"alignCenter":document.execCommand("justifyCenter");break;case"alignRight":document.execCommand("justifyRight");break;case"alignJustify":document.execCommand("justifyFull");break;case"removeFormat":document.execCommand("removeFormat");break;case"print":window.print();return;case"link":{const se=prompt("URL:");se&&Ct(se)&&document.execCommand("createLink",!1,se);break}case"unlink":document.execCommand("unlink");break;case"undo":document.execCommand("undo");break;case"redo":document.execCommand("redo");break;case"clear":document.execCommand("removeFormat");break;case"fontSize":{T&&document.execCommand("fontSize",!1,T);break}case"fontColor":{T&&document.execCommand("foreColor",!1,T);break}case"bgColor":{T&&document.execCommand("hiliteColor",!1,T);break}case"table":{document.execCommand("insertHTML",!1,'<table class="nice-htmleditor__table"><thead><tr><th>Header 1</th><th>Header 2</th><th>Header 3</th></tr></thead><tbody><tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr><tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr></tbody></table><p>&nbsp;</p>');break}case"code":{const he=window.getSelection()?.toString()||"";he.includes(`
10
+ `)||he.length>60?document.execCommand("insertHTML",!1,`<pre class="nice-htmleditor__code-block">${he||"// code"}</pre>`):document.execCommand("insertHTML",!1,`<code>${he||"code"}</code>`);break}}i(te.As(U.innerHTML)),re(U.textContent?.length??0)}},[i,h,w,D,m,t,C,d,g]),De=n.useCallback(async a=>{const T=a.target.files?.[0];if(!T||!C)return;const U=await C(T),se=P.current;se&&U&&(se.focus(),document.execCommand("insertImage",!1,U),i(se.innerHTML)),a.target.value=""},[C,i]),Re=n.useCallback(()=>{const a=P.current;if(!a)return;const T=a.textContent?.length??0;if(_>0&&T>_&&(a.textContent=(a.textContent??"").slice(0,_)),re(T),ae((a.textContent??"").trim().split(/\s+/).filter(Boolean).length),i(a.innerHTML),k){const U=window.getSelection();if(U&&U.rangeCount>0){const se=U.getRangeAt(0),he=se.startContainer;if(he.nodeType===Node.TEXT_NODE){const ve=he.textContent||"",Ce=se.startOffset,Me=ve.slice(0,Ce),Te=Me.lastIndexOf(k);if(Te>=0&&(Te===0||/\s/.test(Me[Te-1]))){const Ie=Me.slice(Te+k.length);if(!/\s/.test(Ie)){V(!0),ee(Ie),Y(0),z?.(Ie);return}}}}V(!1)}},[i,k,z]),$e=L?.filter(a=>a.label.toLowerCase().includes(I.toLowerCase())).slice(0,8)??[],Le=n.useCallback(a=>{const T=P.current;if(!T)return;const U=window.getSelection();if(!U||U.rangeCount===0)return;const se=U.getRangeAt(0),he=se.startContainer;if(he.nodeType===Node.TEXT_NODE&&k){const ve=he.textContent||"",Ce=se.startOffset,Te=ve.slice(0,Ce).lastIndexOf(k);if(Te>=0){const Ie=ve.slice(0,Te),En=ve.slice(Ce),Tn=`<span class="nice-htmleditor__mention" data-mention="${a.key}" contenteditable="false">${k}${a.label}</span>&nbsp;`;he.textContent=Ie;const at=document.createRange();at.setStartAfter(he),at.collapse(!0);const Rn=at.createContextualFragment(Tn+En);he.parentNode?.insertBefore(Rn,he.nextSibling),U.collapseToEnd(),i(T.innerHTML)}}V(!1)},[k,i]),Fe=n.useCallback(a=>{if(R&&$e.length>0){a.key==="ArrowDown"?(a.preventDefault(),Y(T=>Math.min(T+1,$e.length-1))):a.key==="ArrowUp"?(a.preventDefault(),Y(T=>Math.max(T-1,0))):a.key==="Enter"?(a.preventDefault(),Le($e[me])):a.key==="Escape"&&V(!1);return}(a.ctrlKey||a.metaKey)&&a.key==="b"?(a.preventDefault(),je("bold")):(a.ctrlKey||a.metaKey)&&a.key==="i"?(a.preventDefault(),je("italic")):(a.ctrlKey||a.metaKey)&&a.key==="u"?(a.preventDefault(),je("underline")):(a.ctrlKey||a.metaKey)&&a.key==="f"?(a.preventDefault(),b(T=>!T)):(a.ctrlKey||a.metaKey)&&a.key==="z"&&!a.shiftKey?(a.preventDefault(),je("undo")):(a.ctrlKey||a.metaKey)&&(a.key==="y"||a.key==="z"&&a.shiftKey)&&(a.preventDefault(),je("redo"))},[R,$e,me,Le,je]),Ye=n.useCallback(a=>{if(!K)return;a.preventDefault();const T=a.clipboardData.getData("text/html"),U=a.clipboardData.getData("text/plain");if(T){const he=T.replace(/<style[\s\S]*?<\/style>/gi,"").replace(/<script[\s\S]*?<\/script>/gi,"").replace(/class="[^"]*"/gi,"").replace(/style="[^"]*"/gi,"").replace(/<o:[^>]*>[\s\S]*?<\/o:[^>]*>/gi,"").replace(/<!--[\s\S]*?-->/g,"").replace(/<\/?(?:xml|meta|link|font|span)[^>]*>/gi,"");document.execCommand("insertHTML",!1,he)}else U&&document.execCommand("insertText",!1,U);const se=P.current;se&&(i(se.innerHTML),re(se.textContent?.length??0))},[K,i]),Ue=n.useCallback(async a=>{if(!W)return;a.preventDefault();const T=Array.from(a.dataTransfer.files);if(T.length===0)return;const U=await W(T),se=P.current;if(se){se.focus();for(const he of U)if(/\.(png|jpe?g|gif|webp|svg|bmp|ico)$/i.test(he)||he.startsWith("data:image/"))document.execCommand("insertImage",!1,he);else{const Ce=`<a href="${he}">${he.split("/").pop()??he}</a>`;document.execCommand("insertHTML",!1,Ce)}i(se.innerHTML)}},[W,i]),Be=n.useCallback(a=>{W&&a.preventDefault()},[W]),ze=n.useCallback(a=>{const T=P.current;if(!T||!q)return;const U=T.textContent??"",se=q.toLowerCase(),he=U.toLowerCase();(a===1?he.indexOf(se):he.lastIndexOf(se))!==-1&&(T.focus(),window.find?.(q))},[q]),Pe=n.useCallback(()=>{const a=P.current;!a||!q||(a.innerHTML=a.innerHTML.split(q).join(de),i(a.innerHTML))},[q,de,i]),Ee=n.useCallback(()=>{if(!q)return;const a=t.split(q).join(de);i(a);const T=P.current;T&&(T.innerHTML=a)},[q,de,t,i]),Q=n.useCallback(a=>{const T=P.current;T&&(T.focus(),document.execCommand("insertText",!1,a),i(T.innerHTML),be(!1))},[i]),pe=n.useCallback(a=>{const T=P.current;T&&(T.focus(),document.execCommand("insertHTML",!1,a),i(T.innerHTML),we(!1))},[i]),_e=n.useCallback(a=>{const T=w||h;if(a==="fontSize")return e.jsx(xe.NiceSelect,{size:"sm",value:"",onChange:se=>je("fontSize",String(se)),disabled:T,placeholder:"Size",options:ni.map(se=>({value:se.value,label:se.label})),style:{minWidth:70,maxWidth:80}},a);if(a==="fontColor")return e.jsx(xe.NiceColorPicker,{value:ue,onChange:se=>{ye(se),je("fontColor",se)},disabled:T,size:"sm",label:"",title:"Text color"},a);if(a==="bgColor")return e.jsx(xe.NiceColorPicker,{value:ge,onChange:se=>{ke(se),je("bgColor",se)},disabled:T,size:"sm",label:"",title:"Highlight color"},a);const U=a==="markdown"&&D||a==="fullscreen"&&ne||a==="source"&&d||a==="findReplace"&&E||a==="emoji"&&J;return e.jsx(xe.NiceButton,{size:"sm",variant:U?"primary":"ghost",onClick:()=>je(a),title:a,disabled:T,children:ti[a]||a},a)},[w,h,je,D,ne,ue,ge,d,E,J]);return $?null:e.jsxs("div",{className:`nice-field nice-field--${S} ${F?"nice-field--error":""} ${G||""}`,style:y,children:[Z&&e.jsxs("label",{className:"nice-field__label",htmlFor:A,children:[Z,f&&e.jsx("span",{className:"nice-field__required",children:"*"})]}),e.jsxs("div",{ref:c,className:`nice-htmleditor${ne?" nice-htmleditor--fullscreen":""}`,children:[e.jsxs("div",{className:"nice-htmleditor__toolbar",style:{display:"flex",flexWrap:"wrap",gap:2,alignItems:"center"},children:[l.map(_e),H&&H.length>0&&e.jsxs("div",{style:{position:"relative"},children:[e.jsx(xe.NiceButton,{size:"sm",variant:fe?"primary":"ghost",onClick:()=>we(a=>!a),title:"Insert template",children:"??"}),fe&&e.jsx("ul",{style:{position:"absolute",top:"100%",right:0,zIndex:200,background:"var(--bg-primary, #fff)",border:"1px solid var(--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:160,maxHeight:200,overflow:"auto"},children:H.map((a,T)=>e.jsx("li",{style:{padding:"6px 10px",cursor:"pointer",borderRadius:4},onMouseDown:U=>{U.preventDefault(),pe(a.html)},children:a.label},T))})]})]}),E&&e.jsxs("div",{className:"nice-htmleditor__find-bar",style:{display:"flex",gap:4,alignItems:"center",padding:"4px 8px",background:"var(--bg-secondary, #f8f9fa)",borderBottom:"1px solid var(--border-color, #ddd)",fontSize:"0.875em"},children:[e.jsx("input",{type:"text",placeholder:"Find...",value:q,onChange:a=>ce(a.target.value),style:{flex:1,maxWidth:180,padding:"2px 6px",border:"1px solid var(--border-color, #ccc)",borderRadius:4,background:"var(--bg-primary, #fff)",color:"var(--text-primary, #1f2937)"}}),e.jsx("input",{type:"text",placeholder:"Replace...",value:de,onChange:a=>B(a.target.value),style:{flex:1,maxWidth:180,padding:"2px 6px",border:"1px solid var(--border-color, #ccc)",borderRadius:4,background:"var(--bg-primary, #fff)",color:"var(--text-primary, #1f2937)"}}),e.jsx(xe.NiceButton,{size:"sm",variant:"ghost",onClick:()=>ze(1),title:"Find next",children:"?"}),e.jsx(xe.NiceButton,{size:"sm",variant:"ghost",onClick:()=>ze(-1),title:"Find previous",children:"?"}),e.jsx(xe.NiceButton,{size:"sm",variant:"ghost",onClick:Pe,disabled:w||h,children:"Replace"}),e.jsx(xe.NiceButton,{size:"sm",variant:"ghost",onClick:Ee,disabled:w||h,children:"All"}),e.jsx(xe.NiceButton,{size:"sm",variant:"ghost",onClick:()=>b(!1),children:"?"})]}),J&&e.jsx("div",{className:"nice-htmleditor__emoji-picker",style:{padding:8,background:"var(--bg-primary, #fff)",borderBottom:"1px solid var(--border-color, #ddd)",maxHeight:180,overflowY:"auto"},children:ii.map(a=>e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:"0.7em",fontWeight:600,color:"var(--text-muted, #999)",padding:"4px 0"},children:a.label}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:2},children:a.emojis.map(T=>e.jsx("span",{style:{cursor:"pointer",fontSize:"1.2em",padding:2,borderRadius:4},onClick:()=>Q(T),title:T,children:T},T))})]},a.label))}),e.jsx("input",{ref:v,type:"file",accept:"image/*",style:{display:"none"},onChange:De}),d?e.jsx("textarea",{className:"nice-htmleditor__source",value:g,onChange:a=>u(a.target.value),style:{minHeight:r,width:"100%",fontFamily:"monospace",resize:"vertical",whiteSpace:"pre",fontSize:"0.85em",background:"var(--bg-primary, #fff)",color:"var(--text-primary, #1f2937)",border:"none",padding:12,boxSizing:"border-box",outline:"none"},disabled:w||h}):D?e.jsx("textarea",{className:"nice-htmleditor__markdown",value:m,onChange:a=>s(a.target.value),style:{minHeight:r,width:"100%",fontFamily:"monospace",resize:"vertical",background:"var(--bg-primary, #fff)",color:"var(--text-primary, #1f2937)",border:"none",padding:12,boxSizing:"border-box",outline:"none"},disabled:w||h}):e.jsxs("div",{style:{position:"relative"},children:[e.jsx("div",{ref:P,id:A,className:"nice-htmleditor__content",contentEditable:!w&&!h,dangerouslySetInnerHTML:{__html:t},onInput:Re,onKeyDown:Fe,onPaste:Ye,onDrop:Ue,onDragOver:Be,style:{minHeight:r},"data-placeholder":o,role:"textbox","aria-multiline":"true",suppressContentEditableWarning:!0}),R&&$e.length>0&&e.jsx("ul",{className:"nice-htmleditor__mention-list",children:$e.map((a,T)=>e.jsx("li",{className:`nice-htmleditor__mention-item ${T===me?"nice-htmleditor__mention-item--active":""}`,onMouseDown:U=>{U.preventDefault(),Le(a)},children:a.label},a.key))})]}),e.jsxs("div",{className:"nice-htmleditor__statusbar",style:{display:"flex",gap:12,padding:"2px 8px",fontSize:"0.75em",color:"var(--text-muted, #666)",borderTop:"1px solid var(--border-color, #eee)"},children:[_>0&&e.jsxs("span",{children:[ie," / ",_]}),O&&e.jsxs("span",{children:[le," words"]}),O&&e.jsxs("span",{children:[ie," chars"]}),d&&e.jsx("span",{style:{fontWeight:600},children:"HTML Source"}),D&&e.jsx("span",{style:{fontWeight:600},children:"Markdown"})]})]}),F&&e.jsx("div",{className:"nice-field__error",children:F}),X&&!F&&e.jsx("div",{className:"nice-field__hint",children:X})]})},si=Object.freeze(Object.defineProperty({__proto__:null,NiceHtmlEditor:ft},Symbol.toStringTag,{value:"Module"})),ri=[{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"}],ci=[{style:"professional",label:"Professional"},{style:"casual",label:"Casual"},{style:"formal",label:"Formal"},{style:"concise",label:"Concise"}],li=n.forwardRef(function(i,o){const{enableAI:r=!0,aiModel:l,enableImprove:h=!0,enableTranslate:C=!0,enableGenerate:k=!0,toolbar:L,languages:z=ri,textStyles:W=ci,onImprove:K,onTranslate:_,onGenerate:O,showAIToolbar:H=!0,value:Z,onChange:F,...X}=i,f=n.useRef(null),[w,S]=n.useState(!1),[M,G]=n.useState(!1),[y,N]=n.useState(!1),[j,$]=n.useState(""),[A,P]=n.useState(""),[v,c]=n.useState("professional"),[D,x]=n.useState(""),[m,s]=n.useState(z[0]?.code||"en"),[d,p]=n.useState(""),[g,u]=n.useState(""),{t:R}=te.Jo(),V=te.ie(),{improveText:I,translate:ee,generateHtml:me,isLoading:Y}=te.Dl(),ne=r&&V.isConfigured,oe=n.useCallback(()=>{const ae=window.getSelection();return ae&&ae.toString().trim()?ae.toString():""},[]),ue=n.useCallback(ae=>{const E=window.getSelection();if(E&&E.rangeCount>0){const b=E.getRangeAt(0);b.deleteContents();const q=document.createElement("div");q.innerHTML=ae;const ce=document.createDocumentFragment();for(;q.firstChild;)ce.appendChild(q.firstChild);if(b.insertNode(ce),f.current){const de=f.current.innerHTML;F(de)}}},[F]),ye=n.useCallback(async(ae="professional")=>{if(!ne||!h)return"";const E=oe();if(!E)return"";$(E),c(ae),S(!0),P("");try{const b=await I(E,ae);return P(b),K?.(E,b,ae),b}catch{return P(R("htmlEditorAI.improveFailed","Failed to improve text")),""}},[ne,h,oe,I,K,R]),ge=n.useCallback(async ae=>{if(!ne||!C)return"";const E=oe();if(!E)return"";$(E),s(ae),G(!0),x("");try{const b=z.find(ce=>ce.code===ae)?.label||ae,q=await ee(E,b);return x(q),_?.(E,q,ae),q}catch{return x(R("htmlEditorAI.translateFailed","Failed to translate text")),""}},[ne,C,oe,ee,z,_,R]),ke=n.useCallback(async ae=>{if(!ne||!k||!ae.trim())return"";p(ae),u("");try{const E=await me(ae);return u(E),O?.(ae,E),E}catch{return u(R("htmlEditorAI.generateFailed","Failed to generate HTML")),""}},[ne,k,me,O,R]),ie=n.useCallback(()=>{A&&ue(A),S(!1),P("")},[A,ue]),re=n.useCallback(()=>{D&&ue(D),G(!1),x("")},[D,ue]),le=n.useCallback(()=>{if(g&&f.current){document.execCommand("insertHTML",!1,g);const ae=f.current.innerHTML;F(ae)}N(!1),u(""),p("")},[g,F]);return n.useImperativeHandle(o,()=>({getEditor:()=>f.current,focus:()=>f.current?.focus(),getValue:()=>f.current?.innerHTML||"",setValue:ae=>{f.current&&(f.current.innerHTML=ae,F(ae))},getSelection:oe,insertHtml:ae=>{document.execCommand("insertHTML",!1,ae),f.current&&F(f.current.innerHTML)},improveSelection:ye,translateSelection:ge,generateHtml:ke})),n.useCallback(ae=>{f.current=ae},[]),e.jsxs("div",{className:"nice-html-editor-ai","data-testid":i["data-testid"],children:[H&&ne&&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"}),Y&&e.jsx("span",{className:"nice-html-editor-ai__loading",children:R("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:()=>ye(),disabled:Y,title:R("htmlEditorAI.improveText","Improve selected text"),children:["✨ ",R("htmlEditorAI.improve","Improve")]}),e.jsx("div",{className:"nice-html-editor-ai__dropdown-menu",children:W.map(({style:ae,label:E})=>e.jsx("button",{type:"button",className:"nice-html-editor-ai__dropdown-item",onClick:()=>ye(ae),children:E},ae))})]}),C&&e.jsxs("div",{className:"nice-html-editor-ai__dropdown",children:[e.jsxs("button",{type:"button",className:"nice-html-editor-ai__btn",disabled:Y,title:R("htmlEditorAI.translateText","Translate selected text"),children:["🌐 ",R("htmlEditorAI.translate","Translate")]}),e.jsx("div",{className:"nice-html-editor-ai__dropdown-menu nice-html-editor-ai__dropdown-menu--languages",children:z.map(({code:ae,label:E})=>e.jsx("button",{type:"button",className:"nice-html-editor-ai__dropdown-item",onClick:()=>ge(ae),children:E},ae))})]}),k&&e.jsxs("button",{type:"button",className:"nice-html-editor-ai__btn",onClick:()=>N(!0),disabled:Y,title:R("htmlEditorAI.generateHtml","Generate HTML from description"),children:["⚡ ",R("htmlEditorAI.generate","Generate")]})]})]}),e.jsx("div",{className:"nice-html-editor-ai__editor-wrapper",children:e.jsx(ft,{value:Z,onChange:F,toolbar:L,...X})}),w&&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:["✨ ",R("htmlEditorAI.improveText","Improve Text")]}),e.jsx("div",{className:"nice-html-editor-ai__style-selector",children:W.map(({style:ae,label:E})=>e.jsx("button",{type:"button",className:`nice-html-editor-ai__style-btn ${v===ae?"nice-html-editor-ai__style-btn--active":""}`,onClick:()=>{c(ae),ye(ae)},children:E},ae))}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__close",onClick:()=>S(!1),children:"✕"})]}),e.jsx("div",{className:"nice-html-editor-ai__panel-body",children:Y?e.jsx("div",{className:"nice-html-editor-ai__loading-panel",children:R("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:R("htmlEditorAI.original","Original")}),e.jsx("div",{className:"nice-html-editor-ai__text-content",children:j})]}),e.jsxs("div",{className:"nice-html-editor-ai__text-block nice-html-editor-ai__text-block--improved",children:[e.jsx("h5",{children:R("htmlEditorAI.improved","Improved")}),e.jsx("div",{className:"nice-html-editor-ai__text-content",children:A})]})]})}),e.jsxs("div",{className:"nice-html-editor-ai__panel-footer",children:[e.jsxs("button",{type:"button",className:"nice-html-editor-ai__apply",onClick:ie,disabled:!A||Y,children:["✓ ",R("htmlEditorAI.apply","Apply")]}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__cancel",onClick:()=>{S(!1),P("")},children:R("htmlEditorAI.cancel","Cancel")})]})]}),M&&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:["🌐 ",R("htmlEditorAI.translateText","Translate Text")]}),e.jsx("div",{className:"nice-html-editor-ai__language-selector",children:e.jsx("select",{value:m,onChange:ae=>{s(ae.target.value),ge(ae.target.value)},className:"nice-html-editor-ai__language-select",children:z.map(({code:ae,label:E})=>e.jsx("option",{value:ae,children:E},ae))})}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__close",onClick:()=>G(!1),children:"✕"})]}),e.jsx("div",{className:"nice-html-editor-ai__panel-body",children:Y?e.jsx("div",{className:"nice-html-editor-ai__loading-panel",children:R("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:R("htmlEditorAI.original","Original")}),e.jsx("div",{className:"nice-html-editor-ai__text-content",children:j})]}),e.jsxs("div",{className:"nice-html-editor-ai__text-block nice-html-editor-ai__text-block--translated",children:[e.jsx("h5",{children:z.find(ae=>ae.code===m)?.label||m}),e.jsx("div",{className:"nice-html-editor-ai__text-content",children:D})]})]})}),e.jsxs("div",{className:"nice-html-editor-ai__panel-footer",children:[e.jsxs("button",{type:"button",className:"nice-html-editor-ai__apply",onClick:re,disabled:!D||Y,children:["✓ ",R("htmlEditorAI.apply","Apply")]}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__cancel",onClick:()=>{G(!1),x("")},children:R("htmlEditorAI.cancel","Cancel")})]})]}),y&&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:["⚡ ",R("htmlEditorAI.generateHtml","Generate HTML")]}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__close",onClick:()=>{N(!1),u(""),p("")},children:"✕"})]}),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:R("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:ae=>p(ae.target.value),className:"nice-html-editor-ai__generate-textarea",rows:3}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__generate-btn",onClick:()=>ke(d),disabled:Y||!d.trim(),children:Y?R("htmlEditorAI.generating","Generating..."):R("htmlEditorAI.generate","Generate")})]}),g&&e.jsxs("div",{className:"nice-html-editor-ai__generate-result",children:[e.jsx("h5",{children:R("htmlEditorAI.preview","Preview")}),e.jsx("div",{className:"nice-html-editor-ai__preview",dangerouslySetInnerHTML:{__html:g}}),e.jsx("h5",{children:R("htmlEditorAI.htmlCode","HTML Code")}),e.jsx("pre",{className:"nice-html-editor-ai__code",children:g})]})]}),e.jsxs("div",{className:"nice-html-editor-ai__panel-footer",children:[e.jsxs("button",{type:"button",className:"nice-html-editor-ai__apply",onClick:le,disabled:!g||Y,children:["✓ ",R("htmlEditorAI.insert","Insert")]}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__cancel",onClick:()=>{N(!1),u(""),p("")},children:R("htmlEditorAI.cancel","Cancel")})]})]})]})}),Zt=n.forwardRef(({length:t=6,value:i="",onChange:o,masked:r=!1,onComplete:l,label:h,helperText:C,error:k,required:L,disabled:z,readOnly:W,size:K="md",name:_,id:O,className:H,style:Z,autoFocus:F,labelPlacement:X,errorPlacement:f,labelWidth:w,controlWidth:S,loading:M,cellWidth:G,...y},N)=>{const j=te.Hs(O),$=n.useRef([]),A=i.padEnd(t,"").slice(0,t).split(""),P=n.useCallback(m=>{const s=Math.max(0,Math.min(t-1,m));$.current[s]?.focus()},[t]),v=n.useCallback(m=>{const s=m.join("");o?.(s),s.length===t&&s.indexOf("")===-1&&/^\d+$/.test(s)&&l?.(s)},[o,l,t]),c=n.useCallback((m,s)=>{const p=s.target.value.replace(/\D/g,"").slice(-1);if(!p)return;const g=[...A];g[m]=p,v(g),P(m+1)},[A,v,P]),D=n.useCallback((m,s)=>{if(s.key==="Backspace"){s.preventDefault();const d=[...A];A[m]?(d[m]="",v(d)):m>0&&(d[m-1]="",v(d),P(m-1))}else s.key==="ArrowLeft"?(s.preventDefault(),P(m-1)):s.key==="ArrowRight"&&(s.preventDefault(),P(m+1))},[A,v,P]),x=n.useCallback(m=>{m.preventDefault();const s=m.clipboardData.getData("text").replace(/\D/g,"").slice(0,t);if(!s)return;const d=s.padEnd(t,"").slice(0,t).split("");for(let p=s.length;p<t;p++)d[p]=A[p]||"";v(d),P(Math.min(s.length,t-1))},[t,A,v,P]);return e.jsxs("div",{className:`nice-field nice-field--${K} nice-field--otp${X?` nice-field--label-${X}`:""}${f==="right"?" nice-field--error-right":""} ${M?"nice-field--loading":""} ${H||""}`,style:{...Z,...w!=null&&{"--nice-field-label-width":typeof w=="number"?`${w}px`:w},...S!=null&&{"--nice-field-control-width":typeof S=="number"?`${S}px`:S},...G!=null&&{"--nice-otp-cell-width":typeof G=="number"?`${G}px`:G}},"aria-busy":M||void 0,...y,children:[h&&e.jsx("label",{htmlFor:`${j}-0`,className:`nice-field__label ${L?"nice-field__label--required":""}`,children:h}),e.jsxs("div",{className:"nice-field__control",children:[e.jsxs("div",{ref:N,className:`nice-otp nice-otp--${K} ${k?"nice-otp--error":""} ${z?"nice-otp--disabled":""}`,onPaste:x,children:[Array.from({length:t},(m,s)=>e.jsx("input",{ref:d=>{$.current[s]=d},id:s===0?`${j}-0`:void 0,className:"nice-otp__digit",type:r?"password":"text",inputMode:"numeric",maxLength:2,value:A[s]||"",disabled:z,readOnly:W,autoFocus:F&&s===0,"aria-invalid":!!k,"aria-label":`${s+1}`,onChange:d=>c(s,d),onKeyDown:d=>D(s,d),onFocus:d=>d.target.select()},s)),_&&e.jsx("input",{type:"hidden",name:_,value:i})]}),f==="right"&&k&&e.jsx("div",{id:`${j}-error`,className:"nice-field__error",role:"alert",children:k}),f==="right"&&!k&&C&&e.jsx("div",{id:`${j}-helper`,className:"nice-field__helper",children:C}),M&&e.jsx("span",{className:"nice-field__spinner",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})})]}),f!=="right"&&k&&e.jsx("div",{id:`${j}-error`,className:"nice-field__error",role:"alert",children:k}),f!=="right"&&!k&&C&&e.jsx("div",{id:`${j}-helper`,className:"nice-field__helper",children:C})]})});Zt.displayName="NiceInputOtp";const di={xxs:36,xs:48,sm:64,md:80,lg:100,xl:128,xxl:160},Je=6,Ve=135,Qt=405,We=Qt-Ve;function ut(t,i,o,r){const l=(r-90)*(Math.PI/180);return{x:t+o*Math.cos(l),y:i+o*Math.sin(l)}}function St(t,i,o,r,l){const h=ut(t,i,o,r),C=ut(t,i,o,l),k=l-r>180?1:0;return`M ${h.x} ${h.y} A ${o} ${o} 0 ${k} 1 ${C.x} ${C.y}`}const en=n.forwardRef(({value:t=0,onChange:i,min:o=0,max:r=100,step:l=1,showValue:h=!0,valueTemplate:C="{value}",label:k,helperText:L,error:z,required:W,disabled:K,readOnly:_,size:O="md",name:H,id:Z,className:F,style:X,labelPlacement:f="top",errorPlacement:w,labelWidth:S,controlWidth:M,loading:G,isLabelCentered:y=!0,...N},j)=>{const $=te.Hs(Z),A=n.useRef(!1),P=n.useRef(null),v=typeof O=="number"?O:di[O],c=v/2,D=v/2,x=(v-Je*2)/2,m=r>o?(t-o)/(r-o):0,s=Ve+m*We,d=n.useCallback(V=>{let I=V-Ve;I<0&&(I+=360),I>We&&(I=I-We<360-I?We:0);const ee=Math.max(0,Math.min(1,I/We)),me=o+ee*(r-o),Y=Math.round(me/l)*l;return Math.max(o,Math.min(r,Y))},[o,r,l]),p=n.useCallback(V=>{if(K||_)return;const I=P.current;if(!I)return;const ee=I.getBoundingClientRect(),me=V.clientX-ee.left-ee.width/2,Y=V.clientY-ee.top-ee.height/2;let ne=Math.atan2(me,-Y)*(180/Math.PI);ne<0&&(ne+=360);const oe=d(ne);i?.(oe)},[d,K,_,i]);n.useEffect(()=>{const V=ee=>{A.current&&p(ee)},I=()=>{A.current=!1};return window.addEventListener("pointermove",V),window.addEventListener("pointerup",I),()=>{window.removeEventListener("pointermove",V),window.removeEventListener("pointerup",I)}},[p]);const g=n.useCallback(V=>{if(K||_)return;let I=t;V.key==="ArrowUp"||V.key==="ArrowRight"?(V.preventDefault(),I=Math.min(r,t+l)):(V.key==="ArrowDown"||V.key==="ArrowLeft")&&(V.preventDefault(),I=Math.max(o,t-l)),I!==t&&i?.(I)},[t,i,o,r,l,K,_]),u=C.replace("{value}",String(t)),R=ut(c,D,x,s);return e.jsxs("div",{className:`nice-field nice-knob-field nice-knob-field--err-${w||"bottom"} nice-field--${typeof O=="string"?O:"md"} ${G?"nice-field--loading":""} ${F||""}`,style:{...X,...S!=null&&{"--nice-field-label-width":typeof S=="number"?`${S}px`:S},...M!=null&&{"--nice-field-control-width":typeof M=="number"?`${M}px`:M}},"aria-busy":G||void 0,...N,children:[e.jsxs("div",{className:`nice-knob-field__inner nice-knob-field--${f} ${y?"nice-knob-field--label-centered":""}`,children:[k&&e.jsx("label",{htmlFor:$,className:`nice-field__label ${W?"nice-field__label--required":""}`,children:k}),e.jsx("div",{className:"nice-field__control",children:e.jsxs("div",{ref:V=>{P.current=V,typeof j=="function"?j(V):j&&(j.current=V)},className:`nice-knob nice-knob--${O} ${K?"nice-knob--disabled":""} ${z?"nice-knob--error":""}`,role:"slider",id:$,tabIndex:K?-1:0,"aria-valuenow":t,"aria-valuemin":o,"aria-valuemax":r,"aria-disabled":K,"aria-invalid":!!z,onPointerDown:V=>{K||_||(A.current=!0,p(V))},onKeyDown:g,children:[e.jsxs("svg",{width:v,height:v,viewBox:`0 0 ${v} ${v}`,children:[e.jsx("path",{d:St(c,D,x,Ve,Qt),fill:"none",stroke:"var(--nice-border-color, #d1d5db)",strokeWidth:Je,strokeLinecap:"round"}),m>0&&e.jsx("path",{d:St(c,D,x,Ve,s),fill:"none",stroke:"var(--nice-primary, #3b82f6)",strokeWidth:Je,strokeLinecap:"round"}),e.jsx("circle",{cx:R.x,cy:R.y,r:Je,fill:"var(--nice-primary, #3b82f6)"})]}),h&&e.jsx("span",{className:"nice-knob__value",children:u}),H&&e.jsx("input",{type:"hidden",name:H,value:t}),G&&e.jsx("span",{className:"nice-knob__spinner","aria-hidden":"true",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})})]})})]}),z&&e.jsx("div",{className:"nice-field__error",role:"alert",children:z}),!z&&L&&e.jsx("div",{className:"nice-field__helper",children:L})]})});en.displayName="NiceKnob";const tn=n.forwardRef(({value:t="",onChange:i,suggestions:o=[],onSearch:r,trigger:l="@",renderSuggestion:h,placeholder:C,rows:k=3,label:L,helperText:z,error:W,required:K,disabled:_,readOnly:O,size:H="md",name:Z,id:F,className:X,style:f,...w},S)=>{const M=te.Hs(F),[G,y]=n.useState(!1),[N,j]=n.useState(""),[$,A]=n.useState(0),[P,v]=n.useState({top:0,left:0}),c=n.useRef(null),D=n.useRef(-1),m=o.map(u=>typeof u=="string"?{key:u,label:u}:u).filter(u=>u.label.toLowerCase().includes(N.toLowerCase())),s=n.useCallback(()=>{y(!1),j(""),A(0),D.current=-1},[]),d=n.useCallback(u=>{const R=c.current;if(!R||D.current<0)return;const V=t.slice(0,D.current),I=t.slice(R.selectionStart),ee=`${l}${u.label} `,me=V+ee+I;i?.(me),s(),requestAnimationFrame(()=>{const Y=V.length+ee.length;R.setSelectionRange(Y,Y),R.focus()})},[t,i,l,s]),p=n.useCallback(u=>{const R=u.target.value;i?.(R);const V=u.target.selectionStart,I=R.slice(0,V),ee=I.lastIndexOf(l);if(ee>=0){const me=ee>0?I[ee-1]:" ",Y=I.slice(ee+l.length);if(/\s/.test(me)&&!/\s/.test(Y)){D.current=ee;const ne=Y;j(ne),y(!0),A(0),r?.(ne);const oe=u.target,ue=oe.getBoundingClientRect(),ye=parseInt(getComputedStyle(oe).lineHeight)||20,ge=I.split(`
11
+ `);v({top:ue.top+ge.length*ye+4-oe.scrollTop,left:ue.left+8});return}}s()},[i,l,r,s]),g=n.useCallback(u=>{!G||m.length===0||(u.key==="ArrowDown"?(u.preventDefault(),A(R=>(R+1)%m.length)):u.key==="ArrowUp"?(u.preventDefault(),A(R=>(R-1+m.length)%m.length)):u.key==="Enter"?(u.preventDefault(),m[$]&&d(m[$])):u.key==="Escape"&&s())},[G,m,$,d,s]);return n.useEffect(()=>{if(!G)return;const u=R=>{const V=c.current;V&&!V.contains(R.target)&&s()};return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[G,s]),e.jsxs("div",{className:`nice-field ${X||""}`,style:f,...w,children:[L&&e.jsx("label",{htmlFor:M,className:`nice-field__label ${K?"nice-field__label--required":""}`,children:L}),e.jsxs("div",{className:`nice-mention nice-mention--${H} ${W?"nice-mention--error":""} ${_?"nice-mention--disabled":""}`,children:[e.jsx("textarea",{ref:u=>{c.current=u,typeof S=="function"?S(u):S&&(S.current=u)},id:M,name:Z,className:"nice-mention__input",value:t,onChange:p,onKeyDown:g,placeholder:C,rows:k,disabled:_,readOnly:O,"aria-invalid":!!W,"aria-describedby":W?`${M}-error`:z?`${M}-helper`:void 0,"aria-autocomplete":"list","aria-expanded":G}),G&&m.length>0&&e.jsx("ul",{className:"nice-mention__suggestions",role:"listbox",style:{position:"fixed",top:P.top,left:P.left},children:m.map((u,R)=>e.jsx("li",{role:"option","aria-selected":R===$,className:`nice-mention__suggestion ${R===$?"nice-mention__suggestion--active":""}`,onMouseDown:V=>{V.preventDefault(),d(u)},onMouseEnter:()=>A(R),children:h?h(u):e.jsxs(e.Fragment,{children:[u.icon&&e.jsx("span",{className:"nice-mention__suggestion-icon",children:u.icon}),e.jsx("span",{children:u.label})]})},u.key))})]}),W&&e.jsx("div",{id:`${M}-error`,className:"nice-field__error",role:"alert",children:W}),!W&&z&&e.jsx("div",{id:`${M}-helper`,className:"nice-field__helper",children:z})]})});tn.displayName="NiceMention";function mi(t){const i=[],o=r=>{for(const l of r)i.push(l),l.children&&o(l.children)};return o(t),i}function nn(t,i){const o=i.toLowerCase();return t.reduce((r,l)=>{const h=l.children?nn(l.children,i):[];return(l.label.toLowerCase().includes(o)||h.length>0)&&r.push({...l,children:h.length>0?h:l.children}),r},[])}const on=({node:t,level:i,selectedKeys:o,expandedKeys:r,onToggleExpand:l,onSelect:h,selectableLeafsOnly:C,maxDepth:k})=>{const L=typeof k=="number"?Math.min(10,Math.max(1,k)):1/0,W=!(i+1>=L)&&t.children&&t.children.length>0,K=r.has(t.key),_=o.has(t.key),O=!W,H=!t.disabled&&(!C||O),Z=Math.min(i+1,10),F={paddingLeft:i*16+8,"--nice-row-bg":`var(--nice-tree-level-${Z}-bg, transparent)`,"--nice-row-text":`var(--nice-tree-level-${Z}-text, inherit)`,"--nice-row-hover-bg":`var(--nice-tree-level-${Z}-hover-bg, var(--bg-secondary, #f3f4f6))`,"--nice-row-active-bg":`var(--nice-tree-level-${Z}-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 ${_?"nice-tree-select__node--selected":""} ${t.disabled?"nice-tree-select__node--disabled":""}`,style:F,"data-nice-depth":Z,onClick:()=>H&&h(t.key),role:"treeitem","aria-selected":_,"aria-expanded":W?K:void 0,"aria-disabled":t.disabled,children:[W?e.jsx("button",{type:"button",className:"nice-tree-select__toggle",onClick:X=>{X.stopPropagation(),l(t.key)},"aria-label":"Toggle",children:e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"currentColor",style:{transform:K?"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})]}),W&&K&&t.children.map(X=>e.jsx(on,{node:X,level:i+1,selectedKeys:o,expandedKeys:r,onToggleExpand:l,onSelect:h,selectableLeafsOnly:C,maxDepth:k},X.key))]})},an=n.forwardRef(({nodes:t,value:i,onChange:o,multiple:r=!1,searchable:l=!1,placeholder:h,selectableLeafsOnly:C=!1,clearable:k=!1,maxDepth:L,label:z,helperText:W,error:K,required:_,disabled:O,readOnly:H,size:Z="md",name:F,id:X,className:f,style:w,controlWidth:S,...M},G)=>{const{t:y}=te.Jo(),N=te.Hs(X),[j,$]=n.useState(!1),[A,P]=n.useState(""),[v,c]=n.useState(new Set),D=n.useRef(null);te.$s(D,()=>$(!1));const x=n.useMemo(()=>i==null?new Set:new Set(Array.isArray(i)?i:[i]),[i]),m=n.useMemo(()=>A?nn(t,A):t,[t,A]),s=n.useMemo(()=>{const u=mi(t);return Array.from(x).map(R=>u.find(V=>V.key===R)?.label).filter(Boolean)},[x,t]),d=n.useCallback(u=>{c(R=>{const V=new Set(R);return V.has(u)?V.delete(u):V.add(u),V})},[]),p=n.useCallback(u=>{if(r){const R=new Set(x);R.has(u)?R.delete(u):R.add(u),o?.(Array.from(R))}else o?.(u),$(!1)},[r,x,o]),g=n.useCallback(u=>{u.stopPropagation(),o?.(r?[]:"")},[o,r]);return e.jsxs("div",{className:`nice-field nice-field--${Z} ${f||""}`,style:{width:"fit-content",maxWidth:"100%",...w},...M,children:[z&&e.jsx("label",{htmlFor:N,className:`nice-field__label ${_?"nice-field__label--required":""}`,children:z}),e.jsxs("div",{ref:D,className:"nice-tree-select",style:{position:"relative",width:S!=null?typeof S=="number"?`${S}px`:S:240},children:[e.jsxs("div",{ref:G,id:N,className:`nice-input nice-input--${Z} ${K?"nice-input--error":""} ${O?"nice-input--disabled":""} ${H?"nice-input--readonly":""}`,role:"combobox","aria-expanded":j,"aria-haspopup":"tree","aria-invalid":!!K,tabIndex:O?-1:0,onClick:()=>!O&&!H&&$(!j),onKeyDown:u=>{(u.key==="Enter"||u.key===" ")&&(u.preventDefault(),!O&&!H&&$(!j))},children:[e.jsx("span",{className:"nice-tree-select__display",children:s.length>0?s.join(", "):e.jsx("span",{className:"nice-tree-select__placeholder",children:h??y("controls.select","Select...")})}),k&&x.size>0&&e.jsx("button",{type:"button",className:"nice-input__clear",onClick:g,"aria-label":y("controls.clear","Clear"),children:"✕"}),e.jsx("svg",{className:"nice-tree-select__arrow",width:"14",height:"14",viewBox:"0 0 20 20",fill:"currentColor",style:{transform:j?"rotate(180deg)":"none",transition:"transform 0.15s"},children:e.jsx("path",{d:"M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z"})})]}),j&&e.jsxs("div",{className:"nice-tree-select__dropdown",role:"tree",children:[l&&e.jsx("div",{className:"nice-tree-select__search",children:e.jsx("input",{className:"nice-input__native",type:"text",placeholder:y("controls.search","Search..."),value:A,onChange:u=>P(u.target.value),autoFocus:!0,onClick:u=>u.stopPropagation()})}),e.jsx("div",{className:"nice-tree-select__list",children:m.length===0?e.jsx("div",{className:"nice-tree-select__empty",children:y("controls.noResults","No results")}):m.map(u=>e.jsx(on,{node:u,level:0,selectedKeys:x,expandedKeys:v,onToggleExpand:d,onSelect:p,selectableLeafsOnly:C,maxDepth:L},u.key))})]})]}),F&&e.jsx("input",{type:"hidden",name:F,value:Array.isArray(i)?i.join(","):i??""}),K&&e.jsx("div",{id:`${N}-error`,className:"nice-field__error",role:"alert",children:K}),!K&&W&&e.jsx("div",{id:`${N}-helper`,className:"nice-field__helper",children:W})]})});an.displayName="NiceTreeSelect";function He(t,i){return String(t[i])}const sn=n.forwardRef(({source:t,target:i,onChange:o,keyField:r="id",labelField:l="label",renderItem:h,filterable:C=!1,searchable:k,groupBy:L,sortable:z=!1,bulkActions:W=!0,maxRight:K,sourceHeader:_,targetHeader:O,disabled:H=!1,size:Z="md",className:F,style:X,id:f,...w},S)=>{const{t:M}=te.Jo(),[G,y]=n.useState(new Set),[N,j]=n.useState(new Set),[$,A]=n.useState(""),[P,v]=n.useState(""),c=n.useCallback((u,R,V)=>{R(I=>{const ee=new Set(I);return ee.has(V)?ee.delete(V):ee.add(V),ee})},[]),D=n.useCallback(()=>{const u=t.filter(ee=>G.has(He(ee,r))),R=t.filter(ee=>!G.has(He(ee,r))),V=typeof K=="number"?u.slice(0,Math.max(0,K-i.length)):u,I=u.slice(V.length);o([...R,...I],[...i,...V]),y(new Set)},[t,i,G,r,o,K]),x=n.useCallback(()=>{const u=i.filter(V=>N.has(He(V,r))),R=i.filter(V=>!N.has(He(V,r)));o([...t,...u],R),j(new Set)},[t,i,N,r,o]),m=n.useCallback(()=>{if(typeof K=="number"){const u=Math.max(0,K-i.length),R=t.slice(0,u),V=t.slice(u);o(V,[...i,...R])}else o([],[...i,...t]);y(new Set)},[t,i,o,K]),s=n.useCallback(()=>{o([...t,...i],[]),j(new Set)},[t,i,o]),d=(u,R)=>{if(!R)return u;const V=R.toLowerCase();return u.filter(I=>String(I[l]).toLowerCase().includes(V))},p=W===!1?{moveAll:!1,removeAll:!1}:W===!0||W===void 0?{moveAll:!0,removeAll:!0}:{moveAll:W.moveAll??!0,removeAll:W.removeAll??!0},g=(u,R,V,I,ee,me,Y)=>{const ne=d(u,I),oe=k===!0||C&&k===void 0?"both":k??!1,ue=oe==="both"||oe==="left"&&Y==="left"||oe==="right"&&Y==="right",ye=(()=>{if(!L)return[{label:"",items:ne}];const ie=new Map;for(const re of ne){const le=String(L(re));let ae=ie.get(le);ae||(ae=[],ie.set(le,ae)),ae.push(re)}return[...ie.entries()].map(([re,le])=>({label:re,items:le}))})(),ge=(ie,re)=>{ie.dataTransfer.setData("text/plain",re),ie.dataTransfer.effectAllowed="move"},ke=(ie,re)=>{ie.preventDefault();const le=ie.dataTransfer.getData("text/plain");if(!le||le===re||Y!=="right"||!z)return;const ae=[...i],E=ae.findIndex(ce=>He(ce,r)===le),b=ae.findIndex(ce=>He(ce,r)===re);if(E===-1||b===-1)return;const[q]=ae.splice(E,1);ae.splice(b,0,q),o(t,ae)};return e.jsxs("div",{className:"nice-picklist__panel",children:[me&&e.jsx("div",{className:"nice-picklist__header",children:me}),ue&&e.jsx("div",{className:"nice-picklist__filter",children:e.jsx("input",{className:"nice-input__native",type:"text",placeholder:M("controls.search","Search..."),value:I,onChange:ie=>ee(ie.target.value)})}),e.jsxs("div",{className:"nice-picklist__list",role:"listbox","aria-multiselectable":"true",children:[ye.map(ie=>e.jsxs(n.Fragment,{children:[ie.label&&e.jsx("div",{className:"nice-picklist__group-header",role:"presentation",children:ie.label}),ie.items.map(re=>{const le=He(re,r),ae=R.has(le);return e.jsx("div",{className:`nice-picklist__item ${ae?"nice-picklist__item--selected":""}`,role:"option","aria-selected":ae,draggable:z&&Y==="right",onDragStart:z&&Y==="right"?E=>ge(E,le):void 0,onDragOver:z&&Y==="right"?E=>E.preventDefault():void 0,onDrop:z&&Y==="right"?E=>ke(E,le):void 0,onClick:()=>!H&&c(R,V,le),children:h?h(re,Y):String(re[l])},le)})]},ie.label||"__none__")),ne.length===0&&e.jsx("div",{className:"nice-picklist__empty",children:M("controls.noItems","No items")})]})]})};return e.jsxs("div",{ref:S,id:f,className:`nice-picklist nice-picklist--${Z} ${H?"nice-picklist--disabled":""} ${F||""}`,style:X,...w,children:[g(t,G,y,$,A,_??M("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--sm",disabled:H||G.size===0,onClick:D,"aria-label":M("picklist.moveRight","Move right"),children:e.jsx("svg",{width:"14",height:"14",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"})})}),p.moveAll&&e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm",disabled:H||t.length===0,onClick:m,"aria-label":M("picklist.moveAllRight","Move all right"),children:e.jsxs("svg",{width:"14",height:"14",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--sm",disabled:H||N.size===0,onClick:x,"aria-label":M("picklist.moveLeft","Move left"),children:e.jsx("svg",{width:"14",height:"14",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"})})}),p.removeAll&&e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm",disabled:H||i.length===0,onClick:s,"aria-label":M("picklist.moveAllLeft","Move all left"),children:e.jsxs("svg",{width:"14",height:"14",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"})]})})]}),g(i,N,j,P,v,O??M("picklist.target","Selected"),"right")]})});sn.displayName="NicePickList";let Oe=null,Xe=null;const ui="0.45.0",it=`https://cdn.jsdelivr.net/npm/monaco-editor@${ui}/min/vs`,Mt=15e3;function $t(){const t=window;if(t.MonacoEnvironment?.getWorkerUrl)return;const i=`self.MonacoEnvironment={baseUrl:'${it}/'};importScripts('${it}/base/worker/workerMain.js');`,o=URL.createObjectURL(new Blob([i],{type:"text/javascript"}));t.MonacoEnvironment={getWorkerUrl:()=>o}}function Ke(t){if(t!=="auto")return t;if(typeof document>"u")return"vs";const i=document.documentElement.dataset.theme;return i==="dark"?"vs-dark":i==="light"?"vs":window.matchMedia?.("(prefers-color-scheme: dark)").matches?"vs-dark":"vs"}function rn(){return Xe?Promise.resolve(Xe):Oe||(Oe=new Promise((t,i)=>{if(window.monaco){$t(),Xe=window.monaco,t(Xe);return}let o=!1;const r=window.setTimeout(()=>{o||(o=!0,Oe=null,i(new Error(`Monaco editor failed to load within ${Mt}ms`)))},Mt),l=document.createElement("script");l.src=`${it}/loader.min.js`,l.async=!0,l.onload=()=>{const h=window.require;h.config({paths:{vs:it}}),$t(),h(["vs/editor/editor.main"],C=>{o||(o=!0,window.clearTimeout(r),Xe=C,t(C))})},l.onerror=()=>{o||(o=!0,window.clearTimeout(r),Oe=null,i(new Error("Failed to load Monaco Editor loader script")))},document.head.appendChild(l)}),Oe)}const yt=n.forwardRef(function(i,o){const{value:r,onChange:l,language:h="plaintext",theme:C="auto",options:k={},height:L=400,width:z="100%",markers:W=[],decorations:K=[],completionProvider:_,onMount:O,onCursorPositionChange:H,onSelectionChange:Z,onSave:F,loading:X,disabled:f=!1,showToolbar:w=!1,showStatusBar:S=!1,editorSize:M="standard",className:G,"data-testid":y,lsp:N}=i,j=n.useRef(null),$=n.useRef(null),A=n.useRef(null),P=n.useRef([]),v=n.useRef(null),[c,D]=n.useState(!0),[x,m]=n.useState(null),[s,d]=n.useState({lineNumber:1,column:1}),[p,g]=n.useState(""),[u,R]=n.useState(k.wordWrap==="on"),V=n.useMemo(()=>({automaticLayout:!0,readOnly:f||k.readOnly,minimap:{enabled:k.minimap??!0},lineNumbers:k.lineNumbers??"on",wordWrap:k.wordWrap??"off",tabSize:k.tabSize??2,insertSpaces:k.insertSpaces??!0,fontSize:k.fontSize??14,fontFamily:k.fontFamily??"'Fira Code', 'Consolas', 'Monaco', monospace",fontLigatures:k.fontLigatures??!0,cursorStyle:k.cursorStyle??"line",cursorBlinking:k.cursorBlinking??"blink",autoClosingBrackets:k.autoClosingBrackets??"languageDefined",autoClosingQuotes:k.autoClosingQuotes??"languageDefined",formatOnPaste:k.formatOnPaste??!1,formatOnType:k.formatOnType??!1,renderWhitespace:k.renderWhitespace??"selection",renderControlCharacters:k.renderControlCharacters??!1,scrollBeyondLastLine:k.scrollBeyondLastLine??!0,smoothScrolling:k.smoothScrolling??!0,folding:k.folding??!0,showFoldingControls:k.showFoldingControls??"mouseover","bracketPairColorization.enabled":k.bracketPairColorization??!0,guides:k.guides??{bracketPairs:!0,indentation:!0,highlightActiveIndentation:!0},stickyScroll:{enabled:k.stickyScroll??!1},quickSuggestions:k.quickSuggestions??!0,suggestOnTriggerCharacters:k.suggestOnTriggerCharacters??!0,acceptSuggestionOnEnter:k.acceptSuggestionOnEnter??"on",inlayHints:{enabled:k.inlayHints?"on":"off"}}),[k,f]);n.useEffect(()=>{if(!j.current)return;let Y=!0;return rn().then(async ne=>{if(!Y||!j.current)return;A.current=ne;const oe=ne.editor.create(j.current,{value:r,language:h,theme:Ke(C),...V});if($.current=oe,D(!1),oe.onDidChangeModelContent(()=>{const ue=oe.getValue();l?.(ue)}),oe.onDidChangeCursorPosition(ue=>{d({lineNumber:ue.position.lineNumber,column:ue.position.column}),H?.({lineNumber:ue.position.lineNumber,column:ue.position.column})}),oe.onDidChangeCursorSelection(ue=>{const ye=ue.selection,ge=oe.getModel()?.getValueInRange(ye)??"";g(ge),Z?.({startLineNumber:ye.startLineNumber,startColumn:ye.startColumn,endLineNumber:ye.endLineNumber,endColumn:ye.endColumn})}),oe.addCommand(ne.KeyMod.CtrlCmd|ne.KeyCode.KeyS,()=>{F?.(oe.getValue())}),N&&typeof window<"u")try{await ot("https://cdn.jsdelivr.net/npm/vscode-ws-jsonrpc@1.0.2/lib/browser/index.min.js"),await ot("https://cdn.jsdelivr.net/npm/monaco-languageclient@0.15.0/lib/monaco-languageclient.min.js");const ue=window,ye=ue.ReconnectingWebSocket,{MonacoLanguageClient:ge,CloseAction:ke,ErrorAction:ie,createConnection:re}=ue.monacoLanguageClient||{};if(ge&&re){const le=N.url,ae=N.language,E=new ye(le),b=new ue.VSCodeWebSocketMessageReader(E),q=new ue.VSCodeWebSocketMessageWriter(E),ce=re(b,q),de=new ge({name:"LSP Client",clientOptions:{documentSelector:[ae],initializationOptions:N.initOptions,errorHandler:{error:()=>ie.Continue,closed:()=>ke.Restart}},connectionProvider:{get:()=>Promise.resolve(ce)}});de.start(),$.current.__lspClient=de}}catch(ue){console.warn("LSP bridge failed to load:",ue)}O?.(oe,ne)}).catch(ne=>{Y&&(m(ne.message??"Failed to load editor"),D(!1))}),()=>{if(Y=!1,$.current?.dispose(),v.current?.dispose(),$.current&&$.current.__lspClient)try{$.current.__lspClient.stop()}catch{}}},[N]),n.useEffect(()=>{const Y=$.current;if(Y&&r!==Y.getValue()){const ne=Y.getPosition();Y.setValue(r),ne&&Y.setPosition(ne)}},[r]),n.useEffect(()=>{const Y=$.current,ne=A.current;if(Y&&ne){const oe=Y.getModel();oe&&ne.editor.setModelLanguage(oe,h)}},[h]),n.useEffect(()=>{const Y=A.current;if(!Y||(Y.editor.setTheme(Ke(C)),C!=="auto"||typeof document>"u"))return;const ne=()=>{A.current?.editor.setTheme(Ke("auto"))},oe=new MutationObserver(ne);oe.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme","class"]});const ue=window.matchMedia?.("(prefers-color-scheme: dark)");return ue?.addEventListener?.("change",ne),()=>{oe.disconnect(),ue?.removeEventListener?.("change",ne)}},[C]),n.useEffect(()=>{const Y=$.current;Y&&Y.updateOptions(V)},[V]),n.useEffect(()=>{const Y=$.current,ne=A.current;if(Y&&ne){const oe=Y.getModel();if(oe){const ue=W.map(ye=>({startLineNumber:ye.startLineNumber,startColumn:ye.startColumn,endLineNumber:ye.endLineNumber,endColumn:ye.endColumn,message:ye.message,severity:ye.severity}));ne.editor.setModelMarkers(oe,"owner",ue)}}},[W]),n.useEffect(()=>{const Y=$.current;if(Y&&K.length>0){const ne=K.map(oe=>({range:{startLineNumber:oe.range.startLineNumber,startColumn:oe.range.startColumn,endLineNumber:oe.range.endLineNumber,endColumn:oe.range.endColumn},options:{className:oe.className,glyphMarginClassName:oe.glyphMarginClassName,hoverMessage:oe.hoverMessage?{value:oe.hoverMessage}:void 0,isWholeLine:oe.isWholeLine}}));P.current=Y.deltaDecorations(P.current,ne)}},[K]),n.useEffect(()=>{const Y=A.current;if(!Y||!_)return;v.current?.dispose();const ne={text:0,method:1,function:2,constructor:3,field:4,variable:5,class:6,interface:7,module:8,property:9,keyword:13,snippet:14,color:15,file:16,reference:17,folder:18};return v.current=Y.languages.registerCompletionItemProvider(h,{provideCompletionItems:async(oe,ue)=>({suggestions:(await _(oe,ue)).map(ge=>({label:ge.label,kind:ne[ge.kind]??0,insertText:ge.insertText,insertTextRules:ge.insertTextRules==="insertAsSnippet"?4:void 0,documentation:ge.documentation,detail:ge.detail,range:{startLineNumber:ue.lineNumber,startColumn:ue.column,endLineNumber:ue.lineNumber,endColumn:ue.column}}))})}),()=>{v.current?.dispose()}},[h,_]),n.useImperativeHandle(o,()=>({getEditor:()=>$.current,getMonaco:()=>A.current,focus:()=>$.current?.focus(),getValue:()=>$.current?.getValue()??"",setValue:Y=>$.current?.setValue(Y),getSelection:()=>{const Y=$.current;if(!Y)return"";const ne=Y.getSelection();return ne?Y.getModel()?.getValueInRange(ne)??"":""},insertText:Y=>{const ne=$.current;if(!ne)return;const oe=ne.getSelection();oe&&ne.executeEdits("",[{range:oe,text:Y}])},formatDocument:()=>{$.current?.getAction("editor.action.formatDocument")?.run()},goToLine:(Y,ne=1)=>{const oe=$.current;oe&&(oe.setPosition({lineNumber:Y,column:ne}),oe.revealLineInCenter(Y),oe.focus())},findReplace:()=>{$.current?.getAction("editor.action.startFindReplaceAction")?.run()},undo:()=>{$.current?.trigger("keyboard","undo",null)},redo:()=>{$.current?.trigger("keyboard","redo",null)},getCursorPosition:()=>{const Y=$.current?.getPosition();return{lineNumber:Y?.lineNumber??1,column:Y?.column??1}},setMarkers:Y=>{const ne=$.current,oe=A.current;if(ne&&oe){const ue=ne.getModel();if(ue){const ye=Y.map(ge=>({startLineNumber:ge.startLineNumber,startColumn:ge.startColumn,endLineNumber:ge.endLineNumber,endColumn:ge.endColumn,message:ge.message,severity:ge.severity}));oe.editor.setModelMarkers(ue,"owner",ye)}}}}),[]);const I=n.useMemo(()=>({format:()=>$.current?.getAction("editor.action.formatDocument")?.run(),undo:()=>$.current?.trigger("keyboard","undo",null),redo:()=>$.current?.trigger("keyboard","redo",null),find:()=>$.current?.getAction("editor.action.startFindReplaceAction")?.run(),toggleWordWrap:()=>{const Y=!u;R(Y),$.current?.updateOptions({wordWrap:Y?"on":"off"})},toggleMinimap:()=>{const Y=$.current?.getOption?.(A.current?.editor?.EditorOption?.minimap);$.current?.updateOptions({minimap:{enabled:!Y?.enabled}})},foldAll:()=>$.current?.getAction("editor.foldAll")?.run(),unfoldAll:()=>$.current?.getAction("editor.unfoldAll")?.run()}),[u]),ee=r.split(`
12
+ `).length,me=r.length;return e.jsxs("div",{className:`nice-code-editor-wrap nice-editor--${M} ${G??""}`,style:{height:L,width:z,display:"flex",flexDirection:"column",position:"relative"},"data-testid":y,children:[x&&e.jsxs("div",{className:"nice-code-editor__error",style:{position:"absolute",inset:0,zIndex:2,background:"var(--nice-bg-primary, #fff)"},children:[e.jsxs("span",{children:["⚠️ ",x]}),e.jsx("textarea",{value:r,onChange:Y=>l?.(Y.target.value),readOnly:f||k.readOnly,style:{width:"100%",height:"100%",fontFamily:"monospace"}})]}),c&&!x&&e.jsx("div",{className:"nice-code-editor__loader-overlay",style:{position:"absolute",inset:0,zIndex:2,display:"flex",alignItems:"center",justifyContent:"center",background:"var(--nice-bg-primary, #fff)"},children:X??e.jsx("div",{className:"nice-code-editor__loader",children:"Loading editor..."})}),w&&e.jsxs("div",{className:"nice-code-editor__toolbar",children:[e.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:I.undo,title:"Undo (Ctrl+Z)",children:"↶"}),e.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:I.redo,title:"Redo (Ctrl+Y)",children:"↷"}),e.jsx("span",{className:"nice-code-editor__toolbar-sep"}),e.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:I.format,title:"Format (Shift+Alt+F)",children:"⎘"}),e.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:I.find,title:"Find & Replace (Ctrl+H)",children:"🔍"}),e.jsx("span",{className:"nice-code-editor__toolbar-sep"}),e.jsx("button",{className:`nice-code-editor__toolbar-btn${u?" nice-code-editor__toolbar-btn--active":""}`,onClick:I.toggleWordWrap,title:"Toggle Word Wrap",children:"↩"}),e.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:I.toggleMinimap,title:"Toggle Minimap",children:"▥"}),e.jsx("span",{className:"nice-code-editor__toolbar-sep"}),e.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:I.foldAll,title:"Fold All",children:"⊟"}),e.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:I.unfoldAll,title:"Unfold All",children:"⊞"})]}),e.jsx("div",{ref:j,className:"nice-code-editor",style:{flex:1,minHeight:0}}),S&&e.jsxs("div",{className:"nice-code-editor__statusbar",children:[e.jsxs("span",{children:["Ln ",s.lineNumber,", Col ",s.column]}),p.length>0&&e.jsxs("span",{children:["(",p.length," selected)"]}),e.jsx("span",{className:"nice-code-editor__statusbar-spacer"}),e.jsxs("span",{children:[ee," lines · ",me," chars"]}),e.jsx("span",{className:"nice-code-editor__statusbar-lang",children:h}),W.length>0&&e.jsxs("span",{className:"nice-code-editor__statusbar-markers",children:["⚠ ",W.length]})]})]})});function cn(t){const{original:i,modified:o,language:r="plaintext",theme:l="auto",height:h=400,width:C="100%",inline:k=!1,renderSideBySide:L=!0,originalEditable:z=!1,modifiedEditable:W=!1,onOriginalChange:K,onModifiedChange:_,loading:O,className:H,"data-testid":Z}=t,F=n.useRef(null),X=n.useRef(null),f=n.useRef(null),[w,S]=n.useState(!0),[M,G]=n.useState(null);return n.useEffect(()=>{if(!F.current)return;let y=!0;return rn().then(N=>{if(!y||!F.current)return;f.current=N;const j=N.editor.createModel(i,r),$=N.editor.createModel(o,r),A=N.editor.createDiffEditor(F.current,{automaticLayout:!0,theme:Ke(l),renderSideBySide:!k&&L,originalEditable:z,readOnly:!W});A.setModel({original:j,modified:$}),X.current=A,S(!1),z&&j.onDidChangeContent(()=>{K?.(j.getValue())}),W&&$.onDidChangeContent(()=>{_?.($.getValue())})}).catch(N=>{y&&(G(N.message??"Failed to load diff editor"),S(!1))}),()=>{y=!1,X.current?.dispose()}},[]),n.useEffect(()=>{const y=X.current;if(!y)return;const N=y.getModel();N&&(N.original.getValue()!==i&&N.original.setValue(i),N.modified.getValue()!==o&&N.modified.setValue(o))},[i,o]),n.useEffect(()=>{const y=f.current;if(!y||(y.editor.setTheme(Ke(l)),l!=="auto"||typeof document>"u"))return;const N=()=>{f.current?.editor.setTheme(Ke("auto"))},j=new MutationObserver(N);j.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme","class"]});const $=window.matchMedia?.("(prefers-color-scheme: dark)");return $?.addEventListener?.("change",N),()=>{j.disconnect(),$?.removeEventListener?.("change",N)}},[l,w]),M?e.jsx("div",{className:`nice-code-diff-editor nice-code-diff-editor--error ${H??""}`,style:{height:h,width:C},"data-testid":Z,children:e.jsx("div",{className:"nice-code-editor__error",children:e.jsxs("span",{children:["⚠️ ",M]})})}):e.jsxs("div",{className:`nice-code-diff-editor ${H??""}`,style:{height:h,width:C,position:"relative"},"data-testid":Z,children:[e.jsx("div",{ref:F,style:{position:"absolute",inset:0}}),w&&e.jsx("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",background:"var(--nice-bg-primary, #fff)",zIndex:2},children:O??e.jsx("div",{className:"nice-code-editor__loader",children:"Loading diff editor..."})})]})}const pi="1.29.0",Et=`https://cdn.jsdelivr.net/npm/prismjs@${pi}`;let rt=null;const pt={javascript:"javascript",typescript:"typescript",json:"json",html:"markup",css:"css",scss:"scss",less:"less",markdown:"markdown",xml:"markup",yaml:"yaml",sql:"sql",python:"python",csharp:"csharp",java:"java",cpp:"cpp",c:"c",go:"go",rust:"rust",php:"php",ruby:"ruby",shell:"bash",powershell:"powershell",plaintext:"plain"};function ot(t){return new Promise((i,o)=>{if(document.querySelector(`script[data-prism-src="${t}"]`)){i();return}const r=document.createElement("script");r.src=t,r.async=!0,r.dataset.prismSrc=t,r.onload=()=>i(),r.onerror=()=>o(new Error(`Failed to load ${t}`)),document.head.appendChild(r)})}function hi(t){if(typeof window>"u")return Promise.resolve(null);const i=window,o=pt[t]??"plain",r=async()=>{if(o!=="plain"&&!i.Prism?.languages?.[o])try{await ot(`${Et}/components/prism-${o}.min.js`)}catch{}};return i.Prism?r().then(()=>i.Prism):(rt||(rt=(async()=>(window.Prism={manual:!0},await ot(`${Et}/prism.min.js`),window.Prism))()),rt.then(async()=>(await r(),window.Prism)))}function ct(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function ln(t){const{value:i,onChange:o,language:r="plaintext",height:l=300,width:h="100%",readOnly:C=!1,tabSize:k=2,lineNumbers:L=!0,placeholder:z,theme:W="auto",className:K,"data-testid":_}=t,O=n.useRef(null),H=n.useRef(null),[Z,F]=n.useState(()=>ct(i)),[X,f]=n.useState("light");n.useEffect(()=>{const N=()=>{if(W!=="auto")return W;if(typeof document>"u")return"light";const P=document.documentElement.dataset.theme;return P==="dark"?"dark":P==="light"?"light":window.matchMedia?.("(prefers-color-scheme: dark)").matches?"dark":"light"};if(f(N()),W!=="auto"||typeof document>"u")return;const j=()=>f(N()),$=new MutationObserver(j);$.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme","class"]});const A=window.matchMedia?.("(prefers-color-scheme: dark)");return A?.addEventListener?.("change",j),()=>{$.disconnect(),A?.removeEventListener?.("change",j)}},[W]),n.useEffect(()=>{let N=!0;return hi(r).then(j=>{if(!N)return;const $=pt[r]??"plain";if(j?.languages?.[$])try{const A=j.highlight(i,j.languages[$],$);F(A);return}catch{}F(ct(i))}).catch(()=>{N&&F(ct(i))}),()=>{N=!1}},[i,r]);const w=n.useCallback(()=>{!H.current||!O.current||(H.current.scrollTop=O.current.scrollTop,H.current.scrollLeft=O.current.scrollLeft)},[]),S=n.useCallback(N=>{if(N.key==="Tab"){N.preventDefault();const j=N.currentTarget,$=j.selectionStart,A=j.selectionEnd,P=" ".repeat(k);if(N.shiftKey){const D=i.substring(0,$).lastIndexOf(`
13
+ `)+1;if((i.substring(D,$).match(/^(\s*)/)?.[1]??"").length>=k){const m=i.substring(0,D)+i.substring(D+k);o?.(m),setTimeout(()=>{j.selectionStart=j.selectionEnd=$-k},0)}}else{const v=i.substring(0,$)+P+i.substring(A);o?.(v),setTimeout(()=>{j.selectionStart=j.selectionEnd=$+k},0)}}},[i,o,k]),G=i.split(`
14
+ `).length,y=pt[r]??"plain";return e.jsxs("div",{className:`nice-simple-code-editor nice-simple-code-editor--${X} ${K??""}`,style:{height:l,width:h},"data-testid":_,"data-language":r,"data-theme":X,children:[L&&e.jsx("div",{className:"nice-simple-code-editor__line-numbers",children:Array.from({length:G},(N,j)=>e.jsx("div",{className:"nice-simple-code-editor__line-number",children:j+1},j))}),e.jsxs("div",{className:"nice-simple-code-editor__editor-area",children:[e.jsx("pre",{ref:H,"aria-hidden":"true",className:`nice-simple-code-editor__highlight language-${y}`,children:e.jsx("code",{className:`language-${y}`,dangerouslySetInnerHTML:{__html:Z+(i.endsWith(`
15
+ `)?`
16
+ `:"")}})}),e.jsx("textarea",{ref:O,className:"nice-simple-code-editor__textarea",value:i,onChange:N=>o?.(N.target.value),onKeyDown:S,onScroll:w,readOnly:C,placeholder:z,spellCheck:!1,autoCapitalize:"off",autoCorrect:"off"})]})]})}const Tt="nice-code-editor-styles";if(typeof document<"u"&&!document.getElementById(Tt)){const t=document.createElement("style");t.id=Tt,t.textContent=`
17
+ .nice-code-editor,
18
+ .nice-code-diff-editor {
19
+ border: 1px solid var(--nice-border, #e0e0e0);
20
+ border-radius: var(--nice-radius-sm, 4px);
21
+ overflow: hidden;
22
+ }
23
+
24
+ .nice-code-editor--loading,
25
+ .nice-code-editor--error,
26
+ .nice-code-diff-editor--loading {
27
+ display: flex;
28
+ align-items: center;
29
+ justify-content: center;
30
+ background: var(--nice-bg-muted, #f5f5f5);
31
+ }
32
+
33
+ .nice-code-editor__loader {
34
+ color: var(--nice-text-secondary, #666);
35
+ font-size: 14px;
36
+ }
37
+
38
+ .nice-code-editor__error {
39
+ display: flex;
40
+ flex-direction: column;
41
+ width: 100%;
42
+ height: 100%;
43
+ padding: var(--nice-space-2, 8px);
44
+ gap: var(--nice-space-2, 8px);
45
+ }
46
+
47
+ .nice-code-editor__error span {
48
+ color: var(--nice-error, #d32f2f);
49
+ }
50
+
51
+ /* Simple code editor */
52
+ .nice-simple-code-editor {
53
+ display: flex;
54
+ border: 1px solid var(--border-color, var(--nice-border, #e0e0e0));
55
+ border-radius: var(--nice-radius-sm, 4px);
56
+ overflow: hidden;
57
+ font-family: 'Fira Code', 'Consolas', 'Monaco', monospace;
58
+ font-size: 14px;
59
+ line-height: 1.5;
60
+ background: var(--bg-primary, var(--nice-bg-surface, #fff));
61
+ color: var(--text-primary, var(--nice-text-primary, #333));
62
+ }
63
+ .nice-simple-code-editor--dark {
64
+ background: var(--nice-bg, #1e1e1e);
65
+ color: var(--nice-text, #d4d4d4);
66
+ }
67
+
68
+ .nice-simple-code-editor__line-numbers {
69
+ padding: var(--nice-space-2, 8px) 0;
70
+ background: var(--bg-secondary, var(--nice-bg-muted, #f5f5f5));
71
+ border-right: 1px solid var(--border-color, var(--nice-border, #e0e0e0));
72
+ user-select: none;
73
+ text-align: right;
74
+ color: var(--text-secondary, var(--nice-text-secondary, #999));
75
+ overflow: hidden;
76
+ }
77
+ .nice-simple-code-editor--dark .nice-simple-code-editor__line-numbers {
78
+ background: var(--nice-bg-secondary, #252526);
79
+ border-right-color: var(--nice-border, #3c3c3c);
80
+ color: var(--nice-text-muted, #858585);
81
+ }
82
+
83
+ .nice-simple-code-editor__line-number {
84
+ padding: 0 var(--nice-space-3, 12px);
85
+ min-width: 40px;
86
+ }
87
+
88
+ .nice-simple-code-editor__editor-area {
89
+ position: relative;
90
+ flex: 1;
91
+ overflow: hidden;
92
+ }
93
+
94
+ .nice-simple-code-editor__highlight,
95
+ .nice-simple-code-editor__textarea {
96
+ position: absolute;
97
+ inset: 0;
98
+ margin: 0;
99
+ padding: var(--nice-space-2, 8px) var(--nice-space-3, 12px);
100
+ border: 0;
101
+ font: inherit;
102
+ line-height: inherit;
103
+ white-space: pre;
104
+ overflow: auto;
105
+ tab-size: 2;
106
+ }
107
+
108
+ .nice-simple-code-editor__highlight {
109
+ pointer-events: none;
110
+ background: transparent;
111
+ color: inherit;
112
+ }
113
+ .nice-simple-code-editor__highlight code {
114
+ font: inherit;
115
+ background: transparent;
116
+ }
117
+
118
+ .nice-simple-code-editor__textarea {
119
+ background: transparent;
120
+ color: transparent;
121
+ caret-color: var(--text-primary, var(--nice-text-primary, #333));
122
+ resize: none;
123
+ outline: none;
124
+ -webkit-text-fill-color: transparent;
125
+ }
126
+ .nice-simple-code-editor--dark .nice-simple-code-editor__textarea {
127
+ caret-color: var(--nice-text, #d4d4d4);
128
+ }
129
+
130
+ .nice-simple-code-editor__textarea::placeholder {
131
+ color: var(--text-secondary, var(--nice-text-secondary, #999));
132
+ -webkit-text-fill-color: var(--text-secondary, var(--nice-text-secondary, #999));
133
+ }
134
+ .nice-simple-code-editor--dark .nice-simple-code-editor__textarea::placeholder {
135
+ color: var(--nice-text-muted, #858585);
136
+ -webkit-text-fill-color: var(--nice-text-muted, #858585);
137
+ }
138
+
139
+ /* Prism token colors — light */
140
+ .nice-simple-code-editor .token.comment,
141
+ .nice-simple-code-editor .token.prolog,
142
+ .nice-simple-code-editor .token.doctype,
143
+ .nice-simple-code-editor .token.cdata { color: #6a737d; font-style: italic; }
144
+ .nice-simple-code-editor .token.punctuation { color: #586069; }
145
+ .nice-simple-code-editor .token.property,
146
+ .nice-simple-code-editor .token.tag,
147
+ .nice-simple-code-editor .token.boolean,
148
+ .nice-simple-code-editor .token.number,
149
+ .nice-simple-code-editor .token.constant,
150
+ .nice-simple-code-editor .token.symbol,
151
+ .nice-simple-code-editor .token.deleted { color: #005cc5; }
152
+ .nice-simple-code-editor .token.selector,
153
+ .nice-simple-code-editor .token.attr-name,
154
+ .nice-simple-code-editor .token.string,
155
+ .nice-simple-code-editor .token.char,
156
+ .nice-simple-code-editor .token.builtin,
157
+ .nice-simple-code-editor .token.inserted { color: #032f62; }
158
+ .nice-simple-code-editor .token.operator,
159
+ .nice-simple-code-editor .token.entity,
160
+ .nice-simple-code-editor .token.url,
161
+ .nice-simple-code-editor .token.variable { color: var(--nice-danger, #d73a49); }
162
+ .nice-simple-code-editor .token.atrule,
163
+ .nice-simple-code-editor .token.attr-value,
164
+ .nice-simple-code-editor .token.keyword { color: var(--nice-danger, #d73a49); font-weight: 600; }
165
+ .nice-simple-code-editor .token.function,
166
+ .nice-simple-code-editor .token.class-name { color: #6f42c1; }
167
+ .nice-simple-code-editor .token.regex,
168
+ .nice-simple-code-editor .token.important { color: #e36209; }
169
+
170
+ /* Prism token colors — dark */
171
+ .nice-simple-code-editor--dark .token.comment,
172
+ .nice-simple-code-editor--dark .token.prolog,
173
+ .nice-simple-code-editor--dark .token.doctype,
174
+ .nice-simple-code-editor--dark .token.cdata { color: var(--nice-success, #6a9955); font-style: italic; }
175
+ .nice-simple-code-editor--dark .token.punctuation { color: var(--nice-text, #d4d4d4); }
176
+ .nice-simple-code-editor--dark .token.property,
177
+ .nice-simple-code-editor--dark .token.tag,
178
+ .nice-simple-code-editor--dark .token.boolean,
179
+ .nice-simple-code-editor--dark .token.number,
180
+ .nice-simple-code-editor--dark .token.constant,
181
+ .nice-simple-code-editor--dark .token.symbol,
182
+ .nice-simple-code-editor--dark .token.deleted { color: var(--nice-success-light, #b5cea8); }
183
+ .nice-simple-code-editor--dark .token.selector,
184
+ .nice-simple-code-editor--dark .token.attr-name,
185
+ .nice-simple-code-editor--dark .token.string,
186
+ .nice-simple-code-editor--dark .token.char,
187
+ .nice-simple-code-editor--dark .token.builtin,
188
+ .nice-simple-code-editor--dark .token.inserted { color: var(--nice-warning, #ce9178); }
189
+ .nice-simple-code-editor--dark .token.operator,
190
+ .nice-simple-code-editor--dark .token.entity,
191
+ .nice-simple-code-editor--dark .token.url,
192
+ .nice-simple-code-editor--dark .token.variable { color: var(--nice-primary, #569cd6); }
193
+ .nice-simple-code-editor--dark .token.atrule,
194
+ .nice-simple-code-editor--dark .token.attr-value,
195
+ .nice-simple-code-editor--dark .token.keyword { color: #c586c0; font-weight: 600; }
196
+ .nice-simple-code-editor--dark .token.function,
197
+ .nice-simple-code-editor--dark .token.class-name { color: #dcdcaa; }
198
+ .nice-simple-code-editor--dark .token.regex,
199
+ .nice-simple-code-editor--dark .token.important { color: #d7ba7d; }
200
+
201
+ /* Toolbar */
202
+ .nice-code-editor-wrap {
203
+ border: 1px solid var(--nice-border, #e0e0e0);
204
+ border-radius: var(--nice-radius-sm, 4px);
205
+ overflow: hidden;
206
+ }
207
+ .nice-code-editor-wrap .nice-code-editor {
208
+ border: none;
209
+ border-radius: 0;
210
+ }
211
+ .nice-code-editor__toolbar {
212
+ display: flex;
213
+ align-items: center;
214
+ gap: var(--nice-space-0-5, 2px);
215
+ padding: var(--nice-space-0-75, 3px) var(--nice-space-1-5, 6px);
216
+ background: var(--nice-bg-muted, #f5f5f5);
217
+ border-bottom: 1px solid var(--nice-border, #e0e0e0);
218
+ }
219
+ .nice-code-editor__toolbar-btn {
220
+ display: inline-flex;
221
+ align-items: center;
222
+ justify-content: center;
223
+ width: 26px;
224
+ height: 26px;
225
+ border: none;
226
+ border-radius: var(--nice-radius-sm, 3px);
227
+ background: transparent;
228
+ color: var(--nice-text-secondary, #666);
229
+ cursor: pointer;
230
+ font-size: 14px;
231
+ transition: background 0.15s, color 0.15s;
232
+ }
233
+ .nice-code-editor__toolbar-btn:hover {
234
+ background: var(--nice-hover, #e0e0e0);
235
+ color: var(--nice-text-primary, #333);
236
+ }
237
+ .nice-code-editor__toolbar-btn--active {
238
+ background: var(--nice-accent, #1976d2);
239
+ color: var(--nice-bg, #FFF);
240
+ }
241
+ .nice-code-editor__toolbar-sep {
242
+ width: 1px;
243
+ height: 18px;
244
+ background: var(--nice-border, #e0e0e0);
245
+ margin: 0 var(--nice-space-1, 4px);
246
+ }
247
+
248
+ /* Status bar */
249
+ .nice-code-editor__statusbar {
250
+ display: flex;
251
+ align-items: center;
252
+ gap: var(--nice-space-3, 12px);
253
+ padding: var(--nice-space-0-5, 2px) var(--nice-space-2-5, 10px);
254
+ background: var(--nice-bg-muted, #f5f5f5);
255
+ border-top: 1px solid var(--nice-border, #e0e0e0);
256
+ font-size: 12px;
257
+ color: var(--nice-text-secondary, #666);
258
+ user-select: none;
259
+ }
260
+ .nice-code-editor__statusbar-spacer { flex: 1; }
261
+ .nice-code-editor__statusbar-lang {
262
+ text-transform: uppercase;
263
+ font-weight: 600;
264
+ font-size: 11px;
265
+ }
266
+ .nice-code-editor__statusbar-markers {
267
+ color: var(--nice-warning, #f39c12);
268
+ font-weight: 600;
269
+ }
270
+ `,document.head.appendChild(t)}const gi=Object.freeze(Object.defineProperty({__proto__:null,NiceCodeDiffEditor:cn,NiceCodeEditor:yt,NiceSimpleCodeEditor:ln},Symbol.toStringTag,{value:"Module"})),fi=n.forwardRef(function(i,o){const{enableAI:r=!0,aiModel:l,enableInlineCompletion:h=!0,completionDelay:C=500,enableExplain:k=!0,enableRefactor:L=!0,enableGenerate:z=!0,systemPrompt:W,onExplain:K,onRefactor:_,showAIToolbar:O=!0,aiShortcutKey:H="Ctrl",language:Z="plaintext",value:F,onChange:X,...f}=i,w=n.useRef(null),[S,M]=n.useState(null),[G,y]=n.useState(!1),[N,j]=n.useState(""),[$,A]=n.useState(!1),[P,v]=n.useState(""),[c,D]=n.useState(""),[x,m]=n.useState(""),s=n.useRef(),{t:d}=te.Jo(),p=te.ie(),{complete:g,explain:u,refactor:R,generateFromComment:V,isLoading:I}=te.Hl({language:Z,model:l}),ee=r&&p.isConfigured,me=n.useCallback(async()=>{if(!ee||!h||!w.current||!w.current.getEditor())return;const re=w.current.getCursorPosition(),ae=w.current.getValue().split(`
271
+ `),E=ae.slice(0,re.lineNumber-1),b=ae[re.lineNumber-1]||"",q=[...E,b.slice(0,re.column-1)].join(`
272
+ `),ce=[b.slice(re.column-1),...ae.slice(re.lineNumber)].join(`
273
+ `);try{const de=await g(q,ce);de&&M({lineNumber:re.lineNumber,column:re.column,text:de})}catch{}},[ee,h,g]),Y=n.useCallback(async()=>{if(!ee||!k||!w.current)return"";const ie=w.current.getSelection();if(!ie)return"";m(ie),y(!0),j("");try{const re=await u(ie);return j(re),K?.(ie,re),re}catch{return j(d("codeEditorAI.explanationFailed","Failed to explain code")),""}},[ee,k,u,K,d]),ne=n.useCallback(async ie=>{if(!ee||!L||!w.current)return"";const re=w.current.getSelection();if(!re)return"";try{const le=await R(re,ie);return D(le),_?.(re,le),le}catch{return""}},[ee,L,R,_]),oe=n.useCallback(async()=>{if(!ee||!z||!w.current)return;const ie=w.current.getCursorPosition(),le=w.current.getValue().split(`
274
+ `);let ae="";for(let E=ie.lineNumber-1;E>=0&&E>=ie.lineNumber-3;E--){const b=le[E]?.trim()||"";if(b.startsWith("//")||b.startsWith("#")||b.startsWith("/*")||b.startsWith("*")){ae=b.replace(/^\/\/\s*|^#\s*|^\/\*\s*|\*\/\s*$|^\*\s*/g,"").trim();break}}if(ae)try{const E=await V(ae);E&&w.current&&w.current.insertText(`
275
+ `+E)}catch{}},[ee,z,V]),ue=n.useCallback(()=>{!S||!w.current||(w.current.insertText(S.text),M(null))},[S]),ye=n.useCallback(()=>{M(null)},[]),ge=n.useCallback(ie=>{i.onCursorPositionChange?.(ie),!(!ee||!h)&&(s.current&&clearTimeout(s.current),M(null),s.current=setTimeout(()=>{me()},C))},[i.onCursorPositionChange,ee,h,C,me]);n.useEffect(()=>{if(!w.current?.getEditor()||!ee)return;const re=le=>{if(H==="Ctrl"&&le.ctrlKey||H==="Alt"&&le.altKey||H==="Meta"&&le.metaKey){if(le.key===" "&&h&&(le.preventDefault(),me()),le.key==="e"&&k&&(le.preventDefault(),Y()),le.key==="r"&&L){le.preventDefault();const E=w.current?.getSelection();E&&(m(E),A(!0))}le.key==="g"&&z&&(le.preventDefault(),oe())}le.key==="Tab"&&S&&(le.preventDefault(),ue()),le.key==="Escape"&&S&&ye()};return window.addEventListener("keydown",re),()=>window.removeEventListener("keydown",re)},[ee,H,h,k,L,z,me,Y,oe,S,ue,ye]),n.useEffect(()=>()=>{s.current&&clearTimeout(s.current)},[]);const ke=n.useCallback(()=>{if(!c||!w.current)return;const ie=w.current.getEditor();if(ie?.executeEdits&&ie?.getSelection){const re=ie.getSelection();ie.executeEdits("ai-refactor",[{range:re,text:c}])}A(!1),D(""),v("")},[c]);return n.useImperativeHandle(o,()=>({...w.current,getEditor:()=>w.current?.getEditor(),getMonaco:()=>w.current?.getMonaco(),focus:()=>w.current?.focus(),getValue:()=>w.current?.getValue()||"",setValue:ie=>w.current?.setValue(ie),getSelection:()=>w.current?.getSelection()||"",insertText:ie=>w.current?.insertText(ie),formatDocument:()=>w.current?.formatDocument(),goToLine:(ie,re)=>w.current?.goToLine(ie,re),findReplace:()=>w.current?.findReplace(),undo:()=>w.current?.undo(),redo:()=>w.current?.redo(),getCursorPosition:()=>w.current?.getCursorPosition()||{lineNumber:1,column:1},setMarkers:ie=>w.current?.setMarkers(ie),triggerCompletion:me,explainSelection:Y,refactorSelection:ne,generateFromComment:oe,acceptCompletion:ue,dismissCompletion:ye})),e.jsxs("div",{className:"nice-code-editor-ai","data-testid":i["data-testid"],children:[O&&ee&&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"}),I&&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:()=>me(),disabled:I,title:`${d("codeEditorAI.complete","Complete")} (${H}+Space)`,children:["💡 ",d("codeEditorAI.complete","Complete")]}),k&&e.jsxs("button",{type:"button",className:"nice-code-editor-ai__toolbar-btn",onClick:()=>Y(),disabled:I,title:`${d("codeEditorAI.explain","Explain")} (${H}+E)`,children:["📖 ",d("codeEditorAI.explain","Explain")]}),L&&e.jsxs("button",{type:"button",className:"nice-code-editor-ai__toolbar-btn",onClick:()=>{const ie=w.current?.getSelection();ie&&(m(ie),A(!0))},disabled:I,title:`${d("codeEditorAI.refactor","Refactor")} (${H}+R)`,children:["🔧 ",d("codeEditorAI.refactor","Refactor")]}),z&&e.jsxs("button",{type:"button",className:"nice-code-editor-ai__toolbar-btn",onClick:()=>oe(),disabled:I,title:`${d("codeEditorAI.generate","Generate")} (${H}+G)`,children:["⚡ ",d("codeEditorAI.generate","Generate")]})]})]}),e.jsxs("div",{className:"nice-code-editor-ai__editor-wrapper",children:[e.jsx(yt,{ref:w,value:F,onChange:X,language:Z,onCursorPositionChange:ge,...f}),S&&e.jsxs("div",{className:"nice-code-editor-ai__ghost-text",style:{top:`calc(${(S.lineNumber-1)*19}px + 4px)`,left:`calc(${(S.column-1)*7.8}px + 60px)`},children:[e.jsx("span",{className:"nice-code-editor-ai__ghost-text-content",children:S.text}),e.jsxs("span",{className:"nice-code-editor-ai__ghost-text-hint",children:["Tab ",d("codeEditorAI.toAccept","to accept")]})]})]}),G&&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:["📖 ",d("codeEditorAI.explanation","Explanation")]}),e.jsx("button",{type:"button",className:"nice-code-editor-ai__panel-close",onClick:()=>y(!1),children:"✕"})]}),e.jsx("div",{className:"nice-code-editor-ai__panel-body",children:I?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:x}),e.jsx("div",{className:"nice-code-editor-ai__explanation-text",children:N||d("codeEditorAI.noExplanation","Select code and click Explain")})]})})]}),$&&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:["🔧 ",d("codeEditorAI.refactorCode","Refactor Code")]}),e.jsx("button",{type:"button",className:"nice-code-editor-ai__panel-close",onClick:()=>{A(!1),D(""),v("")},children:"✕"})]}),e.jsxs("div",{className:"nice-code-editor-ai__panel-body",children:[e.jsx("pre",{className:"nice-code-editor-ai__code-preview",children:x}),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:P,onChange:ie=>v(ie.target.value),onKeyDown:ie=>{ie.key==="Enter"&&P&&ne(P)}}),e.jsx("button",{type:"button",className:"nice-code-editor-ai__refactor-btn",onClick:()=>ne(P),disabled:I||!P,children:I?d("codeEditorAI.refactoring","Refactoring..."):d("codeEditorAI.refactor","Refactor")})]}),c&&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:c}),e.jsxs("div",{className:"nice-code-editor-ai__refactor-actions",children:[e.jsxs("button",{type:"button",className:"nice-code-editor-ai__refactor-apply",onClick:ke,children:["✓ ",d("codeEditorAI.apply","Apply")]}),e.jsxs("button",{type:"button",className:"nice-code-editor-ai__refactor-discard",onClick:()=>{D(""),v("")},children:["✕ ",d("codeEditorAI.discard","Discard")]})]})]})]})]})]})});function Rt(t,i){const o=i.getBoundingClientRect();let r,l,h;if("touches"in t){const C=t.touches[0];r=C.clientX-o.left,l=C.clientY-o.top,h=C.force}else"pressure"in t?(r=t.clientX-o.left,l=t.clientY-o.top,h=t.pressure):(r=t.clientX-o.left,l=t.clientY-o.top);return{x:r,y:l,time:Date.now(),pressure:h!==void 0?h:.5}}function It(t,i,o,r,l){if(!i)return(o+r)/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),C=Math.min(h/5,1),k=r-C*(r-o),L=t.pressure??.5,z=o+L*(r-o);return k*.7+z*.3}function At(t,i,o,r){t.beginPath(),t.moveTo(i.x,i.y),t.lineTo(o.x,o.y),t.lineWidth=r,t.lineCap="round",t.lineJoin="round",t.stroke()}const yi=n.forwardRef(function(i,o){const{value:r,onChange:l,width:h="100%",height:C=200,penColor:k="var(--text-primary, #000000)",penWidth:L=2,minWidth:z=.5,maxWidth:W=4,backgroundColor:K="var(--bg-primary, #ffffff)",placeholder:_="Sign here",showClearButton:O=!0,showUndoButton:H=!0,showColorPicker:Z=!1,showSizeSlider:F=!1,velocityFilterWeight:X=.7,throttle:f=16,disabled:w=!1,readOnly:S=!1,displayMode:M=!1,onBegin:G,onEnd:y,className:N,"data-testid":j}=i,$=S||M,A=M?!1:O,P=M?!1:H,v=M?!1:Z,c=M?!1:F,D=n.useRef(null),[x,m]=n.useState(r?.strokes??[]),[s,d]=n.useState([]),[p,g]=n.useState(!1),[u,R]=n.useState(k),[V,I]=n.useState(L),ee=n.useRef(null),me=n.useRef(0),Y=x.length===0&&s.length===0;n.useEffect(()=>{const E=D.current;if(!E)return;const b=E.getContext("2d");if(!b)return;const q=E.getBoundingClientRect(),ce=window.devicePixelRatio||1;E.width=q.width*ce,E.height=q.height*ce,b.scale(ce,ce),ne()},[h,C]);const ne=n.useCallback(()=>{const E=D.current;if(!E)return;const b=E.getContext("2d");if(!b)return;const q=E.getBoundingClientRect();b.fillStyle=K,b.fillRect(0,0,q.width,q.height),x.forEach(ce=>{if(b.strokeStyle=ce.color,!(ce.points.length<2))for(let de=1;de<ce.points.length;de++){const B=ce.points[de-1],J=ce.points[de],be=It(J,B,z,W);At(b,B,J,be)}})},[x,K,z,W,X]);n.useEffect(()=>{ne()},[ne]),n.useEffect(()=>{r?.strokes&&m(r.strokes)},[r]),n.useEffect(()=>{const E=D.current;if(E)if(x.length===0)l?.(null);else{const b=E.getBoundingClientRect();l?.({strokes:x,width:b.width,height:b.height,timestamp:Date.now()})}},[x,l]);const oe=n.useCallback(E=>{if(w||$)return;const b=D.current;if(!b)return;b.setPointerCapture(E.pointerId);const q=Rt(E.nativeEvent,b);g(!0),d([q]),ee.current=q,me.current=q.time,G?.()},[w,$,G]),ue=n.useCallback(E=>{if(!p||w||$)return;const b=D.current;if(!b)return;const q=b.getContext("2d");if(!q)return;const ce=Date.now();if(ce-me.current<f)return;const de=Rt(E.nativeEvent,b),B=ee.current;if(B){q.strokeStyle=u;const J=It(de,B,z,W);At(q,B,de,J)}d(J=>[...J,de]),ee.current=de,me.current=ce},[p,w,$,u,z,W,X,f]),ye=n.useCallback(E=>{if(!p)return;const b=D.current;if(b&&b.releasePointerCapture(E.pointerId),s.length>0){const q={points:s,color:u,width:V};m(ce=>[...ce,q])}g(!1),d([]),ee.current=null,y?.()},[p,s,u,V,y]),ge=n.useCallback(()=>{m([]),d([]),ne()},[ne]),ke=n.useCallback(()=>{m(E=>E.slice(0,-1))},[]),ie=n.useCallback((E="png",b=.92)=>{const q=D.current;if(!q)return"";const ce=E==="jpeg"?"image/jpeg":"image/png";return q.toDataURL(ce,b)},[]),re=n.useCallback(async(E="png",b=.92)=>{const q=D.current;return q?new Promise(ce=>{const de=E==="jpeg"?"image/jpeg":"image/png";q.toBlob(B=>ce(B),de,b)}):null},[]),le=n.useCallback(()=>{const E=D.current;if(!E)return"";const b=E.getBoundingClientRect(),q=x.map(ce=>ce.points.length<2?"":`<path d="${ce.points.reduce((B,J,be)=>be===0?`M ${J.x} ${J.y}`:`${B} L ${J.x} ${J.y}`,"")}" stroke="${ce.color}" stroke-width="${ce.width}" fill="none" stroke-linecap="round" stroke-linejoin="round"/>`).join(`
276
+ `);return`<svg xmlns="http://www.w3.org/2000/svg" width="${b.width}" height="${b.height}" viewBox="0 0 ${E.width} ${E.height}">
277
+ <rect width="100%" height="100%" fill="${K}"/>
278
+ ${q}
279
+ </svg>`},[x,K]);n.useImperativeHandle(o,()=>({clear:ge,undo:ke,isEmpty:()=>x.length===0,getData:()=>{const E=D.current;if(!E||x.length===0)return null;const b=E.getBoundingClientRect();return{strokes:x,width:b.width,height:b.height,timestamp:Date.now()}},setData:E=>{m(E.strokes)},toDataURL:ie,toBlob:re,toSVG:le,getCanvas:()=>D.current}),[x,ge,ke,ie,re,le]),n.useEffect(()=>{const E=D.current;if(!E)return;const b=q=>{p&&q.preventDefault()};return E.addEventListener("touchmove",b,{passive:!1}),()=>E.removeEventListener("touchmove",b)},[p]);const ae=A||P||v||c;return e.jsxs("div",{className:`nice-signature ${w?"nice-signature--disabled":""} ${$?"nice-signature--readonly":""} ${N??""}`,style:{width:h},"data-testid":j,children:[ae&&e.jsxs("div",{className:"nice-signature__toolbar",children:[v&&e.jsx("div",{className:"nice-signature__color-picker",children:e.jsx("input",{type:"color",value:u,onChange:E=>R(E.target.value),disabled:w||$,title:"Pen color"})}),c&&e.jsx("div",{className:"nice-signature__size-slider",children:e.jsx("input",{type:"range",min:z,max:W,step:.5,value:V,onChange:E=>I(parseFloat(E.target.value)),disabled:w||$,title:"Pen size"})}),e.jsxs("div",{className:"nice-signature__actions",children:[P&&e.jsx("button",{type:"button",onClick:ke,disabled:w||$||x.length===0,className:"nice-signature__btn",title:"Undo",children:"↩️"}),A&&e.jsx("button",{type:"button",onClick:ge,disabled:w||$||Y,className:"nice-signature__btn",title:"Clear",children:"🗑️"})]})]}),e.jsxs("div",{className:"nice-signature__canvas-wrapper",style:{height:C},children:[e.jsx("canvas",{ref:D,className:"nice-signature__canvas",style:{width:"100%",height:"100%",cursor:w||$?"not-allowed":"crosshair",touchAction:"none"},onPointerDown:oe,onPointerMove:ue,onPointerUp:ye,onPointerLeave:ye}),Y&&!p&&_&&e.jsx("div",{className:"nice-signature__placeholder",children:_}),e.jsx("div",{className:"nice-signature__line"})]})]})}),Dt="nice-signature-styles";if(typeof document<"u"&&!document.getElementById(Dt)){const t=document.createElement("style");t.id=Dt,t.textContent=`
280
+ .nice-signature {
281
+ display: flex;
282
+ flex-direction: column;
283
+ border: 1px solid var(--nice-border, #e0e0e0);
284
+ border-radius: var(--nice-radius-sm, 4px);
285
+ overflow: hidden;
286
+ background: var(--nice-bg-surface, #fff);
287
+ }
288
+
289
+ .nice-signature--disabled {
290
+ opacity: 0.6;
291
+ }
292
+
293
+ .nice-signature__toolbar {
294
+ display: flex;
295
+ align-items: center;
296
+ gap: var(--nice-space-2, 8px);
297
+ padding: var(--nice-space-2, 8px);
298
+ background: var(--nice-bg-muted, #f5f5f5);
299
+ border-bottom: 1px solid var(--nice-border, #e0e0e0);
300
+ }
301
+
302
+ .nice-signature__color-picker input {
303
+ width: 32px;
304
+ height: 32px;
305
+ padding: var(--nice-space-0-5, 2px);
306
+ border: 1px solid var(--nice-border, #e0e0e0);
307
+ border-radius: var(--nice-radius-sm, 4px);
308
+ cursor: pointer;
309
+ }
310
+
311
+ .nice-signature__size-slider {
312
+ flex: 1;
313
+ max-width: 120px;
314
+ }
315
+
316
+ .nice-signature__size-slider input {
317
+ width: 100%;
318
+ }
319
+
320
+ .nice-signature__actions {
321
+ display: flex;
322
+ gap: var(--nice-space-1, 4px);
323
+ margin-left: auto;
324
+ }
325
+
326
+ .nice-signature__btn {
327
+ padding: var(--nice-space-1-5, 6px) var(--nice-space-2-5, 10px);
328
+ border: 1px solid var(--nice-border, #e0e0e0);
329
+ border-radius: var(--nice-radius-sm, 4px);
330
+ background: var(--nice-bg-surface, #fff);
331
+ cursor: pointer;
332
+ font-size: 14px;
333
+ }
334
+
335
+ .nice-signature__btn:hover:not(:disabled) {
336
+ background: var(--nice-bg-hover, #f0f0f0);
337
+ }
338
+
339
+ .nice-signature__btn:disabled {
340
+ opacity: 0.4;
341
+ cursor: not-allowed;
342
+ }
343
+
344
+ .nice-signature__canvas-wrapper {
345
+ position: relative;
346
+ background: var(--nice-bg, #FFF);
347
+ }
348
+
349
+ .nice-signature__canvas {
350
+ display: block;
351
+ }
352
+
353
+ .nice-signature__placeholder {
354
+ position: absolute;
355
+ top: 50%;
356
+ left: 50%;
357
+ transform: translate(-50%, -50%);
358
+ color: var(--nice-text-secondary, #999);
359
+ font-size: 14px;
360
+ pointer-events: none;
361
+ user-select: none;
362
+ }
363
+
364
+ .nice-signature__line {
365
+ position: absolute;
366
+ bottom: 30px;
367
+ left: 20px;
368
+ right: 20px;
369
+ height: 1px;
370
+ background: var(--nice-border, #ccc);
371
+ pointer-events: none;
372
+ }
373
+
374
+ /* Display component */
375
+ .nice-signature-display {
376
+ border: 1px solid var(--nice-border, #e0e0e0);
377
+ border-radius: var(--nice-radius-sm, 4px);
378
+ overflow: hidden;
379
+ }
380
+
381
+ .nice-signature-display__canvas-wrapper {
382
+ position: relative;
383
+ background: var(--nice-bg, #FFF);
384
+ }
385
+
386
+ .nice-signature-display__canvas {
387
+ display: block;
388
+ }
389
+
390
+ .nice-signature-display__placeholder {
391
+ position: absolute;
392
+ top: 50%;
393
+ left: 50%;
394
+ transform: translate(-50%, -50%);
395
+ color: var(--nice-text-secondary, #999);
396
+ font-size: 14px;
397
+ }
398
+ `,document.head.appendChild(t)}const xi={recent:"🕒",smileys:"😀",people:"👋",animals:"🐱",food:"🍕",travel:"✈️",activities:"⚽",objects:"💡",symbols:"❤️",flags:"🏳️"},Lt={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"},lt=["","🏻","🏼","🏽","🏾","🏿"],nt=[{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"}],zt="nice-emoji-picker-recent",dn=({onSelect:t,showSearch:i=!0,searchPlaceholder:o,showSkinTones:r=!0,defaultSkinTone:l=0,showRecent:h=!0,maxRecent:C=24,recentEmojis:k,onRecentChange:L,categories:z,customEmojis:W=[],columns:K=8,size:_="md",className:O="",style:H,"data-testid":Z="nice-emoji-picker"})=>{const{t:F}=te.Jo(),[X,f]=n.useState(""),[w,S]=n.useState(h?"recent":"smileys"),[M,G]=n.useState(l),[y,N]=n.useState(!1),j=n.useRef(null),[$,A]=n.useState(()=>{if(typeof window>"u")return[];try{return JSON.parse(localStorage.getItem(zt)||"[]")}catch{return[]}}),P=k??$,v=z??[...h?["recent"]:[],"smileys","people","animals","food","travel","activities","objects","symbols","flags"],c=n.useMemo(()=>{if(!X)return nt;const p=X.toLowerCase();return nt.filter(g=>g.name.toLowerCase().includes(p)||g.emoji.includes(p)||g.keywords?.some(u=>u.toLowerCase().includes(p)))},[X]),D=n.useMemo(()=>{const p={};for(const g of v)g==="recent"?p[g]=P.map(u=>nt.find(R=>R.emoji===u)).filter(u=>u!==void 0).slice(0,C):p[g]=c.filter(u=>u.category===g);return p},[v,c,P,C]),x=n.useCallback((p,g)=>!g||M===0?p:p.replace(/[\u{1F3FB}-\u{1F3FF}]/gu,"")+lt[M],[M]),m=n.useCallback(p=>{const g=x(p.emoji,p.skinTones),u=[p.emoji,...P.filter(R=>R!==p.emoji)].slice(0,C);if(k===void 0){A(u);try{localStorage.setItem(zt,JSON.stringify(u))}catch{}}L?.(u),t?.(g,p)},[x,P,C,k,L,t]),s=n.useCallback(p=>{t?.(`:${p.name}:`,p)},[t]);n.useEffect(()=>{if(!y)return;const p=g=>{j.current&&!j.current.contains(g.target)&&N(!1)};return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[y]);const d=X?c:D[w]||[];return e.jsxs("div",{className:`nice-emoji-picker nice-emoji-picker--${_} ${O}`,style:H,"data-testid":Z,children:[i&&e.jsxs("div",{className:"nice-emoji-picker__search",children:[e.jsx("input",{type:"text",value:X,onChange:p=>f(p.target.value),placeholder:o??F("search","Search emoji..."),className:"nice-emoji-picker__search-input","data-testid":`${Z}-search`}),r&&e.jsxs("div",{className:"nice-emoji-picker__skin-tone-wrapper",children:[e.jsxs("button",{ref:j,type:"button",className:"nice-emoji-picker__skin-tone-btn",onClick:()=>N(!y),title:F("skinTone","Skin tone"),children:["✋",lt[M]]}),y&&e.jsx("div",{className:"nice-emoji-picker__skin-tone-menu",children:lt.map((p,g)=>e.jsxs("button",{type:"button",className:`nice-emoji-picker__skin-tone-option ${g===M?"nice-emoji-picker__skin-tone-option--selected":""}`,onClick:()=>{G(g),N(!1)},children:["✋",p]},g))})]})]}),!X&&e.jsx("div",{className:"nice-emoji-picker__categories",role:"tablist",children:v.map(p=>e.jsx("button",{type:"button",className:`nice-emoji-picker__category-btn ${w===p?"nice-emoji-picker__category-btn--selected":""}`,onClick:()=>S(p),title:Lt[p],role:"tab","aria-selected":w===p,children:xi[p]},p))}),e.jsxs("div",{className:"nice-emoji-picker__grid-container",children:[X?e.jsxs("div",{className:"nice-emoji-picker__section",children:[e.jsx("div",{className:"nice-emoji-picker__section-title",children:F("searchResults","Search Results")}),e.jsx("div",{className:"nice-emoji-picker__grid",style:{gridTemplateColumns:`repeat(${K}, 1fr)`},children:c.length===0?e.jsx("div",{className:"nice-emoji-picker__empty",children:F("noEmojis","No emojis found")}):c.map((p,g)=>e.jsx("button",{type:"button",className:"nice-emoji-picker__emoji",onClick:()=>m(p),title:p.name,children:x(p.emoji,p.skinTones)},`${p.emoji}-${g}`))})]}):e.jsxs("div",{className:"nice-emoji-picker__section",children:[e.jsx("div",{className:"nice-emoji-picker__section-title",children:Lt[w]}),e.jsx("div",{className:"nice-emoji-picker__grid",style:{gridTemplateColumns:`repeat(${K}, 1fr)`},children:d.length===0?e.jsx("div",{className:"nice-emoji-picker__empty",children:w==="recent"?F("noRecent","No recent emojis"):F("noEmojis","No emojis")}):d.map((p,g)=>e.jsx("button",{type:"button",className:"nice-emoji-picker__emoji",onClick:()=>m(p),title:p.name,children:x(p.emoji,p.skinTones)},`${p.emoji}-${g}`))})]}),W.length>0&&e.jsxs("div",{className:"nice-emoji-picker__section",children:[e.jsx("div",{className:"nice-emoji-picker__section-title",children:F("custom","Custom")}),e.jsx("div",{className:"nice-emoji-picker__grid",style:{gridTemplateColumns:`repeat(${K}, 1fr)`},children:W.map(p=>e.jsx("button",{type:"button",className:"nice-emoji-picker__emoji nice-emoji-picker__emoji--custom",onClick:()=>s(p),title:p.name,children:e.jsx("img",{src:p.url,alt:p.name})},p.id))})]})]})]})};dn.displayName="NiceEmojiPicker";const mn=[{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}],un=({src:t,initialCrop:i={x:10,y:10,width:80,height:80},initialRotation:o=0,initialZoom:r=1,aspectRatios:l=mn,defaultAspectRatio:h="free",customAspectRatio:C,showRotation:k=!0,showFlip:L=!0,showZoom:z=!0,minZoom:W=.5,maxZoom:K=3,zoomStep:_=.1,showGrid:O=!0,overlayColor:H="var(--nice-overlay-50, rgba(0, 0, 0, 0.5))",toolbarPosition:Z="bottom",toolbarCollapsible:F=!1,defaultToolbarCollapsed:X=!1,onChange:f,className:w="",style:S,"data-testid":M="nice-crop-editor"})=>{const{t:G}=te.Jo(),y=n.useRef(null),N=n.useRef(null),[j,$]=n.useState(i),[A,P]=n.useState(o),[v,c]=n.useState(r),[D,x]=n.useState(!1),[m,s]=n.useState(!1),[d,p]=n.useState(h),[g,u]=n.useState(X),[R,V]=n.useState(!1),[I,ee]=n.useState({x:0,y:0,crop:j}),me=d==="custom"?C:l.find(b=>b.value===d)?.ratio;n.useEffect(()=>{f?.({crop:j,rotation:A,flipH:D,flipV:m,zoom:v})},[j,A,D,m,v,f]);const Y=n.useCallback((b,q)=>{if(!me)return b;const ce=y.current?.clientWidth??400,de=y.current?.clientHeight??300,B=b.width/100*ce,J=b.height/100*de,be=B/J;if(Math.abs(be-me)<.01)return b;if(q?.includes("e")||q?.includes("w")){const we=B/me/de*100;return{...b,height:Math.min(100-b.y,Math.max(5,we))}}else if(q?.includes("n")||q?.includes("s")){const we=J*me/ce*100;return{...b,width:Math.min(100-b.x,Math.max(5,we))}}else{const we=B/me/de*100;return{...b,height:Math.min(100-b.y,Math.max(5,we))}}},[me]),ne=n.useCallback((b,q)=>{q===!1||(b.preventDefault(),b.stopPropagation(),V(q),!y.current?.getBoundingClientRect())||ee({x:b.clientX,y:b.clientY,crop:{...j}})},[j]),oe=n.useCallback(b=>{if(!R||!y.current)return;const q=y.current.getBoundingClientRect(),ce=(b.clientX-I.x)/q.width*100,de=(b.clientY-I.y)/q.height*100;let B={...I.crop};if(R==="crop")B.x=Math.max(0,Math.min(100-B.width,I.crop.x+ce)),B.y=Math.max(0,Math.min(100-B.height,I.crop.y+de));else{switch(R){case"resize-nw":B.x=Math.max(0,Math.min(I.crop.x+I.crop.width-5,I.crop.x+ce)),B.y=Math.max(0,Math.min(I.crop.y+I.crop.height-5,I.crop.y+de)),B.width=I.crop.width-(B.x-I.crop.x),B.height=I.crop.height-(B.y-I.crop.y);break;case"resize-ne":B.y=Math.max(0,Math.min(I.crop.y+I.crop.height-5,I.crop.y+de)),B.width=Math.max(5,Math.min(100-B.x,I.crop.width+ce)),B.height=I.crop.height-(B.y-I.crop.y);break;case"resize-sw":B.x=Math.max(0,Math.min(I.crop.x+I.crop.width-5,I.crop.x+ce)),B.width=I.crop.width-(B.x-I.crop.x),B.height=Math.max(5,Math.min(100-B.y,I.crop.height+de));break;case"resize-se":B.width=Math.max(5,Math.min(100-B.x,I.crop.width+ce)),B.height=Math.max(5,Math.min(100-B.y,I.crop.height+de));break;case"resize-n":B.y=Math.max(0,Math.min(I.crop.y+I.crop.height-5,I.crop.y+de)),B.height=I.crop.height-(B.y-I.crop.y);break;case"resize-s":B.height=Math.max(5,Math.min(100-B.y,I.crop.height+de));break;case"resize-e":B.width=Math.max(5,Math.min(100-B.x,I.crop.width+ce));break;case"resize-w":B.x=Math.max(0,Math.min(I.crop.x+I.crop.width-5,I.crop.x+ce)),B.width=I.crop.width-(B.x-I.crop.x);break}B=Y(B,R.replace("resize-",""))}$(B)},[R,I,Y]),ue=n.useCallback(()=>{V(!1)},[]);n.useEffect(()=>{if(R)return document.addEventListener("mousemove",oe),document.addEventListener("mouseup",ue),()=>{document.removeEventListener("mousemove",oe),document.removeEventListener("mouseup",ue)}},[R,oe,ue]);const ye=n.useCallback(()=>{P(b=>(b-90+360)%360)},[]),ge=n.useCallback(()=>{P(b=>(b+90)%360)},[]),ke=n.useCallback(()=>{x(b=>!b)},[]),ie=n.useCallback(()=>{s(b=>!b)},[]),re=n.useCallback(()=>{$(i),P(o),c(r),x(!1),s(!1),p(h)},[i,o,r,h]);n.useEffect(()=>{$(b=>Y(b))},[d,Y]);const le=`scale(${v}) rotate(${A}deg) scaleX(${D?-1:1}) scaleY(${m?-1:1})`,ae=Z==="top"?"column-reverse":Z==="left"?"row-reverse":Z==="right"?"row":"column",E=Z==="left"||Z==="right";return e.jsxs("div",{className:`nice-crop-editor nice-crop-editor--toolbar-${Z} ${w}`,style:{display:"flex",flexDirection:ae,gap:12,...S},"data-testid":M,children:[e.jsxs("div",{ref:y,className:"nice-crop-editor__container","data-testid":`${M}-container`,children:[e.jsx("img",{ref:N,src:t,alt:"",className:"nice-crop-editor__image",style:{transform:le},draggable:!1}),e.jsxs("div",{className:"nice-crop-editor__overlay",style:{backgroundColor:H},children:[e.jsx("div",{className:"nice-crop-editor__overlay-piece",style:{top:0,left:0,right:0,height:`${j.y}%`}}),e.jsx("div",{className:"nice-crop-editor__overlay-piece",style:{bottom:0,left:0,right:0,height:`${100-j.y-j.height}%`}}),e.jsx("div",{className:"nice-crop-editor__overlay-piece",style:{top:`${j.y}%`,left:0,width:`${j.x}%`,height:`${j.height}%`}}),e.jsx("div",{className:"nice-crop-editor__overlay-piece",style:{top:`${j.y}%`,right:0,width:`${100-j.x-j.width}%`,height:`${j.height}%`}})]}),e.jsxs("div",{className:"nice-crop-editor__crop-area",style:{left:`${j.x}%`,top:`${j.y}%`,width:`${j.width}%`,height:`${j.height}%`},onMouseDown:b=>ne(b,"crop"),"data-testid":`${M}-crop-area`,children:[O&&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:b=>ne(b,"resize-nw")}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--ne",onMouseDown:b=>ne(b,"resize-ne")}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--sw",onMouseDown:b=>ne(b,"resize-sw")}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--se",onMouseDown:b=>ne(b,"resize-se")}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--n",onMouseDown:b=>ne(b,"resize-n")}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--s",onMouseDown:b=>ne(b,"resize-s")}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--e",onMouseDown:b=>ne(b,"resize-e")}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--w",onMouseDown:b=>ne(b,"resize-w")})]})]}),e.jsxs("div",{className:`nice-crop-editor__controls ${g?"nice-crop-editor__controls--collapsed":""}`,style:{display:"flex",flexDirection:E?"column":"row",flexWrap:E?"nowrap":"wrap",gap:8,alignItems:E?"stretch":"center",flexShrink:0},children:[F&&e.jsx("button",{type:"button",className:"nice-crop-editor__toolbar-toggle","aria-expanded":!g,"aria-label":g?"Show toolbar":"Hide toolbar",onClick:()=>u(b=>!b),style:{alignSelf:"flex-start",background:"var(--bg-secondary)",border:"1px solid var(--border-color)",borderRadius:4,padding:"2px 8px",cursor:"pointer",color:"var(--text-primary)",fontSize:12},children:g?"▸":"▾"}),!g&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"nice-crop-editor__control-group",children:[e.jsx("label",{className:"nice-crop-editor__label",children:G("aspectRatio","Aspect Ratio")}),e.jsx("div",{className:"nice-crop-editor__aspect-buttons",children:l.map(b=>e.jsx("button",{type:"button",className:`nice-crop-editor__aspect-btn ${d===b.value?"nice-crop-editor__aspect-btn--selected":""}`,onClick:()=>p(b.value),title:b.label,children:b.label},b.value))})]}),z&&e.jsxs("div",{className:"nice-crop-editor__control-group",children:[e.jsxs("label",{className:"nice-crop-editor__label",children:[G("zoom","Zoom"),": ",Math.round(v*100),"%"]}),e.jsx("input",{type:"range",className:"nice-crop-editor__slider",min:W,max:K,step:_,value:v,onChange:b=>c(parseFloat(b.target.value)),"data-testid":`${M}-zoom`})]}),e.jsxs("div",{className:"nice-crop-editor__control-group nice-crop-editor__control-group--row",children:[k&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"nice-crop-editor__btn",onClick:ye,title:G("rotateLeft","Rotate Left"),children:"↺"}),e.jsx("button",{type:"button",className:"nice-crop-editor__btn",onClick:ge,title:G("rotateRight","Rotate Right"),children:"↻"})]}),L&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:`nice-crop-editor__btn ${D?"nice-crop-editor__btn--active":""}`,onClick:ke,title:G("flipHorizontal","Flip Horizontal"),children:"⇆"}),e.jsx("button",{type:"button",className:`nice-crop-editor__btn ${m?"nice-crop-editor__btn--active":""}`,onClick:ie,title:G("flipVertical","Flip Vertical"),children:"⇅"})]}),e.jsx("button",{type:"button",className:"nice-crop-editor__btn nice-crop-editor__btn--reset",onClick:re,title:G("reset","Reset"),children:"⟲"})]})]})]})]})};un.displayName="NiceCropEditor";const bi={strokeColor:"#ff3333",fillColor:"transparent",strokeWidth:2,opacity:1,fontSize:16,fontFamily:"sans-serif"};function ji(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(o=>o.id===i.id?{...o,...i.updates}:o),past:[...t.past,t.annotations],future:[]};case"DELETE_ANNOTATION":return{...t,annotations:t.annotations.filter(o=>o.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 o=t.past[t.past.length-1];return{...t,annotations:o,past:t.past.slice(0,-1),future:[t.annotations,...t.future]}}case"REDO":{if(t.future.length===0)return t;const o=t.future[0];return{...t,annotations:o,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 vi=0;function _i(){return`ann-${Date.now()}-${vi++}`}function ki(t){const{style:i}=t,o=`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}" ${o} />`;case"ellipse":{const r=t.x+t.width/2,l=t.y+t.height/2;return`<ellipse cx="${r}" cy="${l}" rx="${t.width/2}" ry="${t.height/2}" ${o} />`}case"arrow":{const r=t,l=Math.atan2(r.endY-r.y,r.endX-r.x),h=12,C=r.endX-h*Math.cos(l-Math.PI/6),k=r.endY-h*Math.sin(l-Math.PI/6),L=r.endX-h*Math.cos(l+Math.PI/6),z=r.endY-h*Math.sin(l+Math.PI/6);return`<line x1="${r.x}" y1="${r.y}" x2="${r.endX}" y2="${r.endY}" ${o} />
399
+ <polygon points="${r.endX},${r.endY} ${C},${k} ${L},${z}" fill="${i.strokeColor}" opacity="${i.opacity}" />`}case"line":{const r=t;return`<line x1="${r.x}" y1="${r.y}" x2="${r.endX}" y2="${r.endY}" ${o} />`}case"text":{const r=t;return`<text x="${r.x}" y="${r.y+(r.style.fontSize??16)}" fill="${i.strokeColor}" font-size="${i.fontSize}" font-family="${i.fontFamily}" opacity="${i.opacity}">${wi(r.text)}</text>`}case"freehand":{const r=t;return r.points.length<2?"":`<path d="${r.points.map((h,C)=>`${C===0?"M":"L"}${h.x},${h.y}`).join(" ")}" ${o} fill="none" />`}case"blur":{const r=t,l=`blur-${r.id}`;return`<defs><filter id="${l}"><feGaussianBlur stdDeviation="${r.intensity??5}" /></filter></defs>
400
+ <rect x="${r.x}" y="${r.y}" width="${r.width}" height="${r.height}" fill="transparent" stroke="none" filter="url(#${l})" />`}default:return""}}function wi(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}const pn=n.forwardRef(({src:t,alt:i="Annotatable image",annotations:o,activeTool:r,defaultStyle:l,onAnnotationsChange:h,className:C,readOnly:k=!1,minZoom:L=.1,maxZoom:z=5},W)=>{const K=n.useRef(null),_=n.useRef(null),O=n.useRef(null),[H,Z]=n.useState(!1),[F,X]=n.useState({width:0,height:0}),[f,w]=n.useReducer(ji,{annotations:o??[],selectedId:null,activeTool:r??"select",style:{...bi,...l},zoom:1,panX:0,panY:0,past:[],future:[]});n.useEffect(()=>{r&&w({type:"SET_TOOL",tool:r})},[r]),n.useEffect(()=>{h?.(f.annotations)},[f.annotations,h]),n.useEffect(()=>{const v=new Image;v.crossOrigin="anonymous",v.onload=()=>{O.current=v,X({width:v.naturalWidth,height:v.naturalHeight}),Z(!0)},v.src=t},[t]);const S=n.useRef({isDrawing:!1,startX:0,startY:0,currentAnnotation:null,freehandPoints:[]}),M=n.useCallback((v,c)=>{const D=K.current;if(!D)return{x:0,y:0};const x=D.getBoundingClientRect();return{x:(v-x.left-f.panX)/f.zoom,y:(c-x.top-f.panY)/f.zoom}},[f.zoom,f.panX,f.panY]),G=n.useCallback(()=>{const v=K.current,c=v?.getContext("2d"),D=O.current;if(!v||!c||!D||!H)return;v.width=_.current?.clientWidth??D.naturalWidth,v.height=_.current?.clientHeight??D.naturalHeight,c.clearRect(0,0,v.width,v.height),c.save(),c.translate(f.panX,f.panY),c.scale(f.zoom,f.zoom),c.drawImage(D,0,0);for(const m of f.annotations){switch(c.save(),c.globalAlpha=m.style.opacity,c.strokeStyle=m.style.strokeColor,c.fillStyle=m.style.fillColor,c.lineWidth=m.style.strokeWidth,m.tool){case"rectangle":c.strokeRect(m.x,m.y,m.width,m.height),m.style.fillColor!=="transparent"&&c.fillRect(m.x,m.y,m.width,m.height);break;case"ellipse":{c.beginPath(),c.ellipse(m.x+m.width/2,m.y+m.height/2,Math.abs(m.width/2),Math.abs(m.height/2),0,0,Math.PI*2),c.stroke(),m.style.fillColor!=="transparent"&&c.fill();break}case"arrow":{const s=m;c.beginPath(),c.moveTo(s.x,s.y),c.lineTo(s.endX,s.endY),c.stroke();const d=Math.atan2(s.endY-s.y,s.endX-s.x),p=12;c.beginPath(),c.moveTo(s.endX,s.endY),c.lineTo(s.endX-p*Math.cos(d-Math.PI/6),s.endY-p*Math.sin(d-Math.PI/6)),c.lineTo(s.endX-p*Math.cos(d+Math.PI/6),s.endY-p*Math.sin(d+Math.PI/6)),c.closePath(),c.fillStyle=m.style.strokeColor,c.fill();break}case"line":{const s=m;c.beginPath(),c.moveTo(s.x,s.y),c.lineTo(s.endX,s.endY),c.stroke();break}case"text":{const s=m;c.font=`${s.style.fontSize??16}px ${s.style.fontFamily??"sans-serif"}`,c.fillStyle=s.style.strokeColor,c.fillText(s.text,s.x,s.y+(s.style.fontSize??16));break}case"freehand":{const s=m;if(s.points.length<2)break;c.beginPath(),c.moveTo(s.points[0].x,s.points[0].y);for(let d=1;d<s.points.length;d++)c.lineTo(s.points[d].x,s.points[d].y);c.stroke();break}case"blur":{const s=m;c.filter=`blur(${s.intensity??5}px)`,c.drawImage(D,s.x,s.y,s.width,s.height,s.x,s.y,s.width,s.height),c.filter="none";break}}m.id===f.selectedId&&(c.strokeStyle="#4488ff",c.lineWidth=1,c.setLineDash([4,4]),c.strokeRect(m.x-2,m.y-2,m.width+4,m.height+4),c.setLineDash([])),c.restore()}const x=S.current;if(x.isDrawing&&x.currentAnnotation){c.save();const m=x.currentAnnotation;if(c.globalAlpha=m.style.opacity,c.strokeStyle=m.style.strokeColor,c.lineWidth=m.style.strokeWidth,c.setLineDash([6,3]),m.tool==="freehand"){const s=m;if(s.points.length>=2){c.beginPath(),c.moveTo(s.points[0].x,s.points[0].y);for(let d=1;d<s.points.length;d++)c.lineTo(s.points[d].x,s.points[d].y);c.stroke()}}else if(m.tool==="rectangle")c.strokeRect(m.x,m.y,m.width,m.height);else if(m.tool==="ellipse")c.beginPath(),c.ellipse(m.x+m.width/2,m.y+m.height/2,Math.abs(m.width/2),Math.abs(m.height/2),0,0,Math.PI*2),c.stroke();else if(m.tool==="arrow"||m.tool==="line"){const s=m;c.beginPath(),c.moveTo(s.x,s.y),c.lineTo(s.endX,s.endY),c.stroke()}c.restore()}c.restore()},[f,H]);n.useEffect(()=>{G()},[G]);const y=n.useCallback(v=>{if(k)return;const c=M(v.clientX,v.clientY),D=f.activeTool;if(D==="select"){const s=[...f.annotations].reverse().find(d=>d.tool==="freehand"?!1:c.x>=d.x&&c.x<=d.x+d.width&&c.y>=d.y&&c.y<=d.y+d.height);w({type:"SELECT",id:s?.id??null});return}const x=S.current;x.isDrawing=!0,x.startX=c.x,x.startY=c.y;const m={id:_i(),style:{...f.style},x:c.x,y:c.y,width:0,height:0};switch(D){case"rectangle":x.currentAnnotation={...m,tool:"rectangle"};break;case"ellipse":x.currentAnnotation={...m,tool:"ellipse"};break;case"arrow":x.currentAnnotation={...m,tool:"arrow",endX:c.x,endY:c.y};break;case"line":x.currentAnnotation={...m,tool:"line",endX:c.x,endY:c.y};break;case"text":x.currentAnnotation={...m,tool:"text",text:"Text",width:100,height:f.style.fontSize??16};break;case"freehand":x.freehandPoints=[c],x.currentAnnotation={...m,tool:"freehand",points:[c]};break;case"blur":x.currentAnnotation={...m,tool:"blur",intensity:5};break}},[k,M,f.activeTool,f.style,f.annotations]),N=n.useCallback(v=>{const c=S.current;if(!c.isDrawing||!c.currentAnnotation)return;const D=M(v.clientX,v.clientY),x=c.currentAnnotation;if(x.tool==="freehand"){c.freehandPoints.push(D),x.points=[...c.freehandPoints];const m=c.freehandPoints.map(d=>d.x),s=c.freehandPoints.map(d=>d.y);x.x=Math.min(...m),x.y=Math.min(...s),x.width=Math.max(...m)-x.x,x.height=Math.max(...s)-x.y}else if(x.tool==="arrow"||x.tool==="line")x.endX=D.x,x.endY=D.y,x.width=Math.abs(D.x-c.startX),x.height=Math.abs(D.y-c.startY);else{const m=Math.min(c.startX,D.x),s=Math.min(c.startY,D.y);x.x=m,x.y=s,x.width=Math.abs(D.x-c.startX),x.height=Math.abs(D.y-c.startY)}G()},[M,G]),j=n.useCallback(()=>{const v=S.current;if(!v.isDrawing||!v.currentAnnotation)return;const c=v.currentAnnotation;(c.tool==="text"||c.tool==="freehand"||Math.abs(c.width)>2||Math.abs(c.height)>2)&&w({type:"ADD_ANNOTATION",annotation:c}),v.isDrawing=!1,v.currentAnnotation=null,v.freehandPoints=[]},[]),$=n.useCallback(v=>{v.preventDefault();const c=v.deltaY>0?.9:1.1,D=Math.max(L,Math.min(z,f.zoom*c));w({type:"SET_ZOOM",zoom:D})},[f.zoom,L,z]);n.useEffect(()=>{if(k)return;const v=c=>{(c.metaKey||c.ctrlKey)&&c.key==="z"&&!c.shiftKey?(c.preventDefault(),w({type:"UNDO"})):(c.metaKey||c.ctrlKey)&&(c.key==="y"||c.key==="z"&&c.shiftKey)?(c.preventDefault(),w({type:"REDO"})):(c.key==="Delete"||c.key==="Backspace")&&f.selectedId&&w({type:"DELETE_ANNOTATION",id:f.selectedId})};return document.addEventListener("keydown",v),()=>document.removeEventListener("keydown",v)},[k,f.selectedId]),n.useImperativeHandle(W,()=>({exportAsDataURL:async(v="png",c=.92)=>{const D=document.createElement("canvas"),x=O.current;if(!x)return"";D.width=x.naturalWidth,D.height=x.naturalHeight;const m=D.getContext("2d");m.drawImage(x,0,0);for(const s of f.annotations){if(m.save(),m.globalAlpha=s.style.opacity,m.strokeStyle=s.style.strokeColor,m.fillStyle=s.style.fillColor,m.lineWidth=s.style.strokeWidth,s.tool==="rectangle")m.strokeRect(s.x,s.y,s.width,s.height);else if(s.tool==="ellipse")m.beginPath(),m.ellipse(s.x+s.width/2,s.y+s.height/2,Math.abs(s.width/2),Math.abs(s.height/2),0,0,Math.PI*2),m.stroke();else if(s.tool==="freehand"){const d=s;if(d.points.length>=2){m.beginPath(),m.moveTo(d.points[0].x,d.points[0].y);for(let p=1;p<d.points.length;p++)m.lineTo(d.points[p].x,d.points[p].y);m.stroke()}}else if(s.tool==="text"){const d=s;m.font=`${d.style.fontSize??16}px ${d.style.fontFamily??"sans-serif"}`,m.fillStyle=d.style.strokeColor,m.fillText(d.text,d.x,d.y+(d.style.fontSize??16))}m.restore()}return D.toDataURL(`image/${v}`,c)},exportAnnotations:()=>[...f.annotations],importAnnotations:v=>{w({type:"SET_ANNOTATIONS",annotations:v})},exportAsSVG:()=>{const{width:v,height:c}=F,D=f.annotations.map(ki);return`<svg xmlns="http://www.w3.org/2000/svg" width="${v}" height="${c}" viewBox="0 0 ${v} ${c}">
401
+ ${D.join(`
402
+ `)}
403
+ </svg>`},undo:()=>w({type:"UNDO"}),redo:()=>w({type:"REDO"}),setZoom:v=>{w({type:"SET_ZOOM",zoom:Math.max(L,Math.min(z,v))})},fitToScreen:()=>{const v=_.current,c=O.current;if(!v||!c)return;const D=v.clientWidth/c.naturalWidth,x=v.clientHeight/c.naturalHeight,m=Math.min(D,x,1);w({type:"SET_ZOOM",zoom:m}),w({type:"SET_PAN",panX:0,panY:0})},clear:()=>w({type:"CLEAR"})}),[f.annotations,F,L,z]);const A=n.useCallback(v=>{if(v.touches.length!==1)return;const c=v.touches[0];y({clientX:c.clientX,clientY:c.clientY,preventDefault:()=>{}})},[y]),P=n.useCallback(v=>{if(v.touches.length!==1)return;const c=v.touches[0];N({clientX:c.clientX,clientY:c.clientY})},[N]);return e.jsx("div",{ref:_,className:`nice-image-annotator ${C??""}`,style:{position:"relative",overflow:"hidden",width:"100%",height:"100%"},children:e.jsx("canvas",{ref:K,className:"nice-image-annotator__canvas",style:{cursor:f.activeTool==="select"?"default":"crosshair"},onMouseDown:y,onMouseMove:N,onMouseUp:j,onMouseLeave:j,onWheel:$,onTouchStart:A,onTouchMove:P,onTouchEnd:j,role:"img","aria-label":i})})});pn.displayName="NiceImageAnnotator";function Ni(t){let i=t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");return i=i.replace(/```(\w*)\n([\s\S]*?)```/g,(o,r,l)=>`<pre><code class="language-${r}">${l.trim()}</code></pre>`),i=i.replace(/^(\|.+\|)\n(\|[-| :]+\|)\n((?:\|.+\|\n?)+)/gm,(o,r,l,h)=>{const C=r.split("|").filter(L=>L.trim()).map(L=>`<th>${L.trim()}</th>`).join(""),k=h.trim().split(`
404
+ `).map(L=>`<tr>${L.split("|").filter(W=>W.trim()).map(W=>`<td>${W.trim()}</td>`).join("")}</tr>`).join("");return`<table><thead><tr>${C}</tr></thead><tbody>${k}</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 Ci=[{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",label:"S̶",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",label:"•",md:"- ",tip:"Unordered list",group:"list"},{key:"ol",label:"1.",md:"1. ",tip:"Ordered list",group:"list"},{key:"task",label:"☑",md:"- [ ] ",tip:"Task list",group:"list"},{key:"quote",label:"❝",md:"> ",tip:"Blockquote",group:"block"},{key:"hr",label:"—",md:`---
405
+ `,tip:"Horizontal rule",group:"block"},{key:"link",label:"🔗",md:"[](url)",tip:"Link",shortcut:"Ctrl+K",group:"insert"},{key:"image",label:"🖼",md:"![](url)",tip:"Image",group:"insert"},{key:"table",label:"⊞",md:`| H1 | H2 | H3 |
406
+ | --- | --- | --- |
407
+ | c1 | c2 | c3 |
408
+ `,tip:"Table",group:"insert"},{key:"codeblock",label:"```",md:"```\n",tip:"Code block",group:"insert"}],Si=["format","heading","list","block","insert"],hn=n.forwardRef(({value:t="",onChange:i,preview:o="side",placeholder:r,disabled:l,readOnly:h,size:C="md",editorSize:k="standard",toolbar:L=!0,minHeight:z=200,showWordCount:W=!1,showLineNumbers:K=!1,onExportHtml:_,onImageUpload:O,className:H,style:Z,id:F},X)=>{const f=te.Hs(F),[w,S]=n.useState("edit"),[M,G]=n.useState(!1),y=n.useRef(null),N=n.useMemo(()=>Ni(t),[t]),j=n.useMemo(()=>{const x=t.trim()?t.trim().split(/\s+/).length:0,m=t.length,s=t.split(`
409
+ `).length;return{words:x,chars:m,lines:s}},[t]),$=n.useCallback(x=>{const m=y.current;if(!m)return;const s=m.selectionStart,d=m.selectionEnd,p=t.slice(s,d);let g,u;x==="[](url)"?(g=t.slice(0,s)+`[${p||"text"}](url)`+t.slice(d),u=s+1+(p||"text").length+2):x==="![](url)"?(g=t.slice(0,s)+`![${p||"alt"}](url)`+t.slice(d),u=s+2+(p||"alt").length+2):x.endsWith(`
410
+ `)||x.endsWith(" ")?(g=t.slice(0,s)+x+p+t.slice(d),u=s+x.length+p.length):(g=t.slice(0,s)+x+p+x+t.slice(d),u=s+x.length+p.length+x.length),i?.(g),requestAnimationFrame(()=>{m.focus(),m.setSelectionRange(u,u)})},[t,i]),A=n.useCallback(x=>{if((x.ctrlKey||x.metaKey)&&(x.key==="b"?(x.preventDefault(),$("**")):x.key==="i"?(x.preventDefault(),$("*")):x.key==="k"&&(x.preventDefault(),$("[](url)"))),x.key==="Tab"){x.preventDefault();const m=x.currentTarget,s=m.selectionStart,d=m.selectionEnd,p=" ";if(x.shiftKey){const R=t.slice(0,s).lastIndexOf(`
411
+ `)+1;if(t.slice(R,R+p.length)===p){const V=t.slice(0,R)+t.slice(R+p.length);i?.(V),requestAnimationFrame(()=>{m.selectionStart=m.selectionEnd=s-p.length})}}else{const g=t.slice(0,s)+p+t.slice(d);i?.(g),requestAnimationFrame(()=>{m.selectionStart=m.selectionEnd=s+p.length})}}},[t,i,$]),P=n.useCallback(async x=>{if(!O)return;const m=Array.from(x.dataTransfer.files).filter(s=>s.type.startsWith("image/"));if(m.length!==0){x.preventDefault();for(const s of m){const d=await O(s),p=y.current;if(!p)continue;const g=p.selectionStart,u=`![${s.name}](${d})
412
+ `,R=t.slice(0,g)+u+t.slice(g);i?.(R)}}},[t,i,O]),v=o!=="tab"||w==="edit",c=o==="side"||o==="tab"&&w==="preview"||o===!0,D=`nice-md-editor nice-md-editor--${C} nice-editor--${k} nice-md-editor--preview-${o}${M?" nice-md-editor--fullscreen":""} ${H||""}`;return e.jsxs("div",{ref:X,id:f,className:D,style:Z,children:[L&&e.jsxs("div",{className:"nice-md-editor__toolbar",children:[Si.map((x,m)=>e.jsxs(n.Fragment,{children:[m>0&&e.jsx("span",{className:"nice-md-editor__sep"}),Ci.filter(s=>s.group===x).map(s=>e.jsx("button",{type:"button",className:"nice-md-editor__btn",title:s.shortcut?`${s.tip} (${s.shortcut})`:s.tip,disabled:l||h,onClick:()=>$(s.md),children:s.label},s.key))]},x)),e.jsx("span",{className:"nice-md-editor__sep"}),e.jsx("button",{type:"button",className:"nice-md-editor__btn",title:"Fullscreen",onClick:()=>G(!M),children:M?"⊙":"⛶"}),_&&e.jsx("button",{type:"button",className:"nice-md-editor__btn",title:"Export HTML",onClick:()=>_(N),children:"↗"}),o==="tab"&&e.jsxs("span",{className:"nice-md-editor__tabs",children:[e.jsx("button",{type:"button",className:`nice-md-editor__tab${w==="edit"?" nice-md-editor__tab--active":""}`,onClick:()=>S("edit"),children:"Edit"}),e.jsx("button",{type:"button",className:`nice-md-editor__tab${w==="preview"?" nice-md-editor__tab--active":""}`,onClick:()=>S("preview"),children:"Preview"})]})]}),e.jsxs("div",{className:"nice-md-editor__body",style:{minHeight:z},children:[v&&e.jsxs("div",{className:"nice-md-editor__editor-wrap",children:[K&&e.jsx("div",{className:"nice-md-editor__line-numbers",children:Array.from({length:j.lines},(x,m)=>e.jsx("div",{className:"nice-md-editor__line-no",children:m+1},m))}),e.jsx("textarea",{ref:y,className:"nice-md-editor__textarea",value:t,onChange:x=>i?.(x.target.value),onKeyDown:A,onDrop:P,placeholder:r,disabled:l,readOnly:h,style:{minHeight:z}})]}),c&&e.jsx("div",{className:"nice-md-editor__preview",dangerouslySetInnerHTML:{__html:te.As(N)},style:{minHeight:z}})]}),W&&e.jsxs("div",{className:"nice-md-editor__statusbar",children:[e.jsxs("span",{children:[j.words," words"]}),e.jsxs("span",{children:[j.chars," chars"]}),e.jsxs("span",{children:[j.lines," lines"]})]})]})});hn.displayName="NiceMarkdownEditor";const Pt={rotation:0,flipH:!1,flipV:!1,brightness:100,contrast:100,saturate:100,blur:0,crop:null,annotations:[]},Mi=["crop","rotate","flip","brightness","contrast","saturate","blur","annotate"],gn=n.forwardRef(({src:t,size:i="md",editorSize:o="standard",tools:r=Mi,showToolbar:l=!0,showZoom:h=!0,maxUndo:C=30,onSave:k,onCancel:L,onChange:z,width:W="100%",height:K=500,className:_,style:O,id:H,...Z},F)=>{const X=te.Hs(H),{t:f}=te.Jo(),w=n.useRef(null),S=n.useRef(null),[M,G]=n.useState({...Pt}),[y,N]=n.useState(null),[j,$]=n.useState(!1),[A,P]=n.useState(1),[v,c]=n.useState("rect"),[D,x]=n.useState("var(--nice-danger, #ff0000)"),[m,s]=n.useState({w:0,h:0}),[d,p]=n.useState([]),[g,u]=n.useState([]),[R,V]=n.useState(null),[I,ee]=n.useState(null),[me,Y]=n.useState(null),ne=n.useCallback(E=>{p(b=>[...b.slice(-(C-1)),E]),u([])},[C]),oe=n.useCallback(E=>{G(b=>{ne(b);const q={...b,...E};return z?.(q),q})},[z,ne]),ue=n.useCallback(()=>{if(d.length===0)return;const E=d[d.length-1];p(b=>b.slice(0,-1)),u(b=>[...b,M]),G(E),z?.(E)},[d,M,z]),ye=n.useCallback(()=>{if(g.length===0)return;const E=g[g.length-1];u(b=>b.slice(0,-1)),p(b=>[...b,M]),G(E),z?.(E)},[g,M,z]);n.useEffect(()=>{const E=new Image;E.crossOrigin="anonymous",E.onload=()=>{S.current=E,s({w:E.width,h:E.height}),$(!0)},E.src=t},[t]),n.useEffect(()=>{if(!j||!w.current||!S.current)return;const E=w.current,b=E.getContext("2d");if(!b)return;const q=S.current,ce=M.rotation%180!==0,de=ce?q.height:q.width,B=ce?q.width:q.height;E.width=de,E.height=B,b.clearRect(0,0,de,B),b.save(),b.filter=`brightness(${M.brightness}%) contrast(${M.contrast}%) saturate(${M.saturate}%) blur(${M.blur}px)`,b.translate(de/2,B/2),b.rotate(M.rotation*Math.PI/180),b.scale(M.flipH?-1:1,M.flipV?-1:1),b.drawImage(q,-q.width/2,-q.height/2),b.restore(),M.annotations.forEach(J=>{switch(b.save(),b.strokeStyle=J.color??"red",b.fillStyle=J.color??"red",b.lineWidth=J.strokeWidth??2,b.font=`${J.fontSize??16}px sans-serif`,J.type){case"text":b.fillText(J.text??"",J.x,J.y);break;case"rect":b.strokeRect(J.x,J.y,J.width??100,J.height??50);break;case"circle":{const be=(J.width??50)/2,fe=(J.height??50)/2;b.beginPath(),b.ellipse(J.x+be,J.y+fe,be,fe,0,0,Math.PI*2),b.stroke();break}case"line":b.beginPath(),b.moveTo(J.x,J.y),b.lineTo(J.x+(J.width??100),J.y+(J.height??0)),b.stroke();break;case"arrow":{const be=J.x+(J.width??100),fe=J.y+(J.height??0);b.beginPath(),b.moveTo(J.x,J.y),b.lineTo(be,fe),b.stroke();const we=Math.atan2(fe-J.y,be-J.x),je=10;b.beginPath(),b.moveTo(be,fe),b.lineTo(be-je*Math.cos(we-.4),fe-je*Math.sin(we-.4)),b.lineTo(be-je*Math.cos(we+.4),fe-je*Math.sin(we+.4)),b.closePath(),b.fill();break}}b.restore()}),I&&(b.save(),b.fillStyle="var(--nice-overlay-50, rgba(0, 0, 0, 0.5))",b.fillRect(0,0,de,B),b.clearRect(I.x,I.y,I.w,I.h),b.strokeStyle="var(--bg-primary, #fff)",b.lineWidth=2,b.setLineDash([5,5]),b.strokeRect(I.x,I.y,I.w,I.h),b.restore())},[j,M,I]);const ge=n.useCallback(E=>{if(!w.current)return;const b=w.current.getBoundingClientRect(),q=w.current.width/b.width,ce=w.current.height/b.height,de=(E.clientX-b.left)*q,B=(E.clientY-b.top)*ce;y==="crop"?V({startX:de,startY:B}):y==="annotate"&&Y({startX:de,startY:B})},[y]),ke=n.useCallback(E=>{if(!w.current)return;const b=w.current.getBoundingClientRect(),q=w.current.width/b.width,ce=w.current.height/b.height,de=(E.clientX-b.left)*q,B=(E.clientY-b.top)*ce;R&&ee({x:Math.min(R.startX,de),y:Math.min(R.startY,B),w:Math.abs(de-R.startX),h:Math.abs(B-R.startY)})},[R]),ie=n.useCallback(E=>{if(R&&I&&I.w>5&&I.h>5&&oe({crop:{x:I.x,y:I.y,width:I.w,height:I.h}}),V(null),me&&w.current){const b=w.current.getBoundingClientRect(),q=w.current.width/b.width,ce=w.current.height/b.height,de=(E.clientX-b.left)*q,B=(E.clientY-b.top)*ce,J=de-me.startX,be=B-me.startY;if(Math.abs(J)>3||Math.abs(be)>3||v==="text"){const fe={type:v,x:me.startX,y:me.startY,width:Math.abs(J)||100,height:Math.abs(be)||50,color:D,strokeWidth:2,text:v==="text"?prompt(f("imageEditor.annotationText","Text:"))??"":void 0};oe({annotations:[...M.annotations,fe]})}Y(null)}},[R,I,me,v,D,M.annotations,oe,f]),re=n.useCallback(()=>{if(!M.crop||!w.current)return;const E=w.current,b=E.getContext("2d");if(!b)return;const{x:q,y:ce,width:de,height:B}=M.crop,J=b.getImageData(q,ce,de,B);E.width=de,E.height=B,b.putImageData(J,0,0),ee(null),N(null)},[M.crop]),le=n.useCallback(()=>{if(!w.current)return;const E=w.current.toDataURL("image/png");k?.(E,M)},[k,M]),ae=n.useCallback(()=>{G({...Pt}),ee(null),N(null)},[]);return n.useMemo(()=>`brightness(${M.brightness}%) contrast(${M.contrast}%) saturate(${M.saturate}%) blur(${M.blur}px)`,[M.brightness,M.contrast,M.saturate,M.blur]),e.jsxs("div",{ref:F,id:X,className:`nice-image-editor nice-image-editor--${i} nice-editor--${o} ${_??""}`,style:{...O,width:W,height:K},role:"application","aria-label":f("imageEditor.label","Image Editor"),...Z,children:[l&&e.jsxs("div",{className:"nice-image-editor__toolbar",role:"toolbar",children:[e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:ue,disabled:d.length===0,title:f("imageEditor.undo","Undo"),children:"↶"}),e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:ye,disabled:g.length===0,title:f("imageEditor.redo","Redo"),children:"↷"}),e.jsx("span",{className:"nice-image-editor__sep"}),r.includes("rotate")&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>oe({rotation:(M.rotation-90+360)%360}),title:f("imageEditor.rotateLeft","Rotate left"),children:"↺"}),e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>oe({rotation:(M.rotation+90)%360}),title:f("imageEditor.rotateRight","Rotate right"),children:"↻"})]}),r.includes("flip")&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>oe({flipH:!M.flipH}),title:f("imageEditor.flipH","Flip horizontal"),children:"⇔"}),e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>oe({flipV:!M.flipV}),title:f("imageEditor.flipV","Flip vertical"),children:"⇕"})]}),r.includes("crop")&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:`nice-image-editor__btn ${y==="crop"?"nice-image-editor__btn--active":""}`,onClick:()=>N(y==="crop"?null:"crop"),title:f("imageEditor.crop","Crop"),children:"⊡"}),y==="crop"&&M.crop&&e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:re,title:f("imageEditor.applyCrop","Apply crop"),children:"✓"})]}),r.includes("brightness")&&e.jsxs("label",{className:"nice-image-editor__slider-label",children:[f("imageEditor.brightness","☀"),e.jsx("input",{type:"range",min:0,max:200,value:M.brightness,onChange:E=>oe({brightness:Number(E.target.value)}),className:"nice-image-editor__slider",title:f("imageEditor.brightness","Brightness")})]}),r.includes("contrast")&&e.jsxs("label",{className:"nice-image-editor__slider-label",children:[f("imageEditor.contrast","◑"),e.jsx("input",{type:"range",min:0,max:200,value:M.contrast,onChange:E=>oe({contrast:Number(E.target.value)}),className:"nice-image-editor__slider",title:f("imageEditor.contrast","Contrast")})]}),r.includes("saturate")&&e.jsxs("label",{className:"nice-image-editor__slider-label",children:[f("imageEditor.saturate","🎨"),e.jsx("input",{type:"range",min:0,max:200,value:M.saturate,onChange:E=>oe({saturate:Number(E.target.value)}),className:"nice-image-editor__slider",title:f("imageEditor.saturate","Saturation")})]}),r.includes("blur")&&e.jsxs("label",{className:"nice-image-editor__slider-label",children:[f("imageEditor.blur","⊘"),e.jsx("input",{type:"range",min:0,max:20,step:.5,value:M.blur,onChange:E=>oe({blur:Number(E.target.value)}),className:"nice-image-editor__slider",title:f("imageEditor.blur","Blur")})]}),r.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 ${y==="annotate"?"nice-image-editor__btn--active":""}`,onClick:()=>N(y==="annotate"?null:"annotate"),title:f("imageEditor.annotate","Annotate"),children:"✎"}),y==="annotate"&&e.jsxs(e.Fragment,{children:[e.jsxs("select",{className:"nice-image-editor__select",value:v,onChange:E=>c(E.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:"T Text"})]}),e.jsx("input",{type:"color",value:D,onChange:E=>x(E.target.value),className:"nice-image-editor__color",title:f("imageEditor.color","Color")}),M.annotations.length>0&&e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>oe({annotations:M.annotations.slice(0,-1)}),title:f("imageEditor.removeLastAnnotation","Remove last"),children:"⌫"})]})]}),e.jsx("span",{className:"nice-image-editor__sep"}),e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:ae,title:f("imageEditor.reset","Reset"),children:"⟲"}),k&&e.jsx("button",{type:"button",className:"nice-image-editor__btn nice-image-editor__btn--save",onClick:le,children:f("imageEditor.save","Save")}),L&&e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:L,children:f("imageEditor.cancel","Cancel")})]}),e.jsx("div",{className:"nice-image-editor__canvas-wrap",children:e.jsx("canvas",{ref:w,className:"nice-image-editor__canvas",onMouseDown:ge,onMouseMove:ke,onMouseUp:ie,style:{cursor:y==="crop"||y==="annotate"?"crosshair":"default",transform:`scale(${A})`,transformOrigin:"center center"}})}),h&&e.jsxs("div",{className:"nice-image-editor__footer",children:[e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>P(E=>Math.max(.1,E-.1)),title:"Zoom out",children:"−"}),e.jsxs("span",{style:{fontSize:"0.85em",minWidth:40,textAlign:"center"},children:[Math.round(A*100),"%"]}),e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>P(E=>Math.min(5,E+.1)),title:"Zoom in",children:"+"}),e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>P(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:[m.w,"×",m.h,"px · ",M.rotation,"°"]})]})]})});gn.displayName="NiceImageEditor";const fn=n.forwardRef(({value:t,onChange:i,penColor:o="var(--text-primary, #000)",penWidth:r=2,backgroundColor:l="var(--bg-primary, #fff)",width:h=400,height:C=200,size:k="md",disabled:L=!1,readOnly:z=!1,showClear:W=!0,showUndo:K=!0,label:_,exportFormat:O="image/png",className:H,style:Z,id:F,...X},f)=>{const w=te.Hs(F),{t:S}=te.Jo(),M=n.useRef(null),[G,y]=n.useState(!1),N=n.useRef([]),j=n.useRef([]),[$,A]=n.useState(!0),P=n.useCallback(()=>{const d=M.current;if(!d)return;const p=d.getContext("2d");if(p){p.fillStyle=l,p.fillRect(0,0,d.width,d.height),p.strokeStyle=o,p.lineWidth=r,p.lineCap="round",p.lineJoin="round";for(const g of N.current)if(!(g.length<2)){p.beginPath(),p.moveTo(g[0].x,g[0].y);for(let u=1;u<g.length;u++)p.lineTo(g[u].x,g[u].y);p.stroke()}}},[l,o,r]);n.useEffect(()=>{if(t&&M.current){const d=new Image;d.onload=()=>{const p=M.current?.getContext("2d");!p||!M.current||(p.fillStyle=l,p.fillRect(0,0,M.current.width,M.current.height),p.drawImage(d,0,0),A(!1))},d.src=t}else t||(N.current=[],A(!0),P())},[t,l,P]),n.useEffect(()=>{const d=M.current;d&&(d.width=h,d.height=C,P())},[h,C,P]);const v=n.useCallback(d=>{const p=M.current,g=p.getBoundingClientRect(),u=p.width/g.width,R=p.height/g.height;if("touches"in d){const V=d.touches[0];return{x:(V.clientX-g.left)*u,y:(V.clientY-g.top)*R}}return{x:(d.clientX-g.left)*u,y:(d.clientY-g.top)*R}},[]),c=n.useCallback(d=>{if(L||z)return;d.preventDefault();const p=v(d);j.current=[p],y(!0)},[L,z,v]),D=n.useCallback(d=>{if(!G)return;d.preventDefault();const p=v(d);j.current.push(p);const g=M.current,u=g?.getContext("2d");if(!u||!g)return;const R=j.current;R.length>=2&&(u.strokeStyle=o,u.lineWidth=r,u.lineCap="round",u.beginPath(),u.moveTo(R[R.length-2].x,R[R.length-2].y),u.lineTo(p.x,p.y),u.stroke())},[G,v,o,r]),x=n.useCallback(()=>{if(G&&(y(!1),j.current.length>0&&(N.current.push([...j.current]),j.current=[],A(!1),M.current))){const d=M.current.toDataURL(O);i?.(d)}},[G,O,i]),m=n.useCallback(()=>{N.current=[],j.current=[],A(!0),P(),i?.(null)},[P,i]),s=n.useCallback(()=>{if(N.current.length!==0&&(N.current.pop(),A(N.current.length===0),P(),M.current)){const d=N.current.length>0?M.current.toDataURL(O):null;i?.(d)}},[P,O,i]);return e.jsxs("div",{ref:f,id:w,className:`nice-signature nice-signature--${k} ${L?"nice-signature--disabled":""} ${z?"nice-signature--readonly":""} ${H??""}`,style:Z,...X,children:[_&&e.jsx("label",{className:"nice-signature__label",children:_}),e.jsx("div",{className:"nice-signature__canvas-wrap",style:{width:h,height:C},children:e.jsx("canvas",{ref:M,className:"nice-signature__canvas",onMouseDown:c,onMouseMove:D,onMouseUp:x,onMouseLeave:x,onTouchStart:c,onTouchMove:D,onTouchEnd:x,style:{touchAction:"none",cursor:L||z?"default":"crosshair"},"aria-label":_??S("signature.label","Signature pad"),role:"img"})}),(W||K)&&!z&&!L&&e.jsxs("div",{className:"nice-signature__actions",children:[K&&e.jsx("button",{type:"button",className:"nice-signature__btn",onClick:s,disabled:$,children:S("signature.undo","Undo")}),W&&e.jsx("button",{type:"button",className:"nice-signature__btn",onClick:m,disabled:$,children:S("signature.clear","Clear")})]})]})});fn.displayName="NiceSignaturePad";let $i=0;function xt(){return`blk-${++$i}-${Date.now().toString(36)}`}function Ht(t=""){return{id:xt(),type:"paragraph",content:t}}function Ei(t,i=""){const o={id:xt(),type:t,content:i};return t==="heading"&&(o.level=2),t==="list"&&(o.listType="unordered"),t==="callout"&&(o.icon="??"),t==="toggle"&&(o.open=!0),o}const Ti=[{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 Ri(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(";"),o=i?` style="${i}"`:"",r=(l,h)=>{let C=h;return t.bold&&(C=`<strong>${C}</strong>`),t.italic&&(C=`<em>${C}</em>`),t.underline&&(C=`<u>${C}</u>`),t.strikethrough&&(C=`<s>${C}</s>`),`<${l}${o}>${C}</${l}>`};switch(t.type){case"heading":return r(`h${t.level??2}`,t.content);case"paragraph":return r("p",t.content||"&nbsp;");case"list":{const l=t.listType==="ordered"?"ol":"ul",h=t.content.split(`
413
+ `).map((C,k)=>t.listType==="checklist"?`<li><input type="checkbox" ${t.checked?.[k]??!1?"checked":""} disabled />${C}</li>`:`<li>${C}</li>`).join("");return`<${l}${o}>${h}</${l}>`}case"image":return`<figure${o}><img src="${t.src??""}" alt="${t.alt??""}" /></figure>`;case"video":return`<figure${o}><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 r("blockquote",t.content);case"callout":return`<div class="nice-doc-callout"${o}><span>${t.icon??"??"}</span><div>${t.content}</div></div>`;case"toggle":return`<details${o}><summary>${t.content.split(`
414
+ `)[0]}</summary>${t.content.split(`
415
+ `).slice(1).join("<br>")}</details>`;case"table":return`<table${o}>${t.content}</table>`;case"embed":return`<iframe src="${t.src??""}" style="width:100%;border:none;min-height:300px"></iframe>`;default:return r("p",t.content)}}function Ii(t){let i=0,o=0;for(const r of t){const l=r.content??"";i+=l.length;const h=l.trim().split(/\s+/).filter(Boolean);o+=h.length}return{words:o,chars:i,readingTime:Math.max(1,Math.ceil(o/200))}}const yn=n.forwardRef(({blocks:t,onChange:i,readOnly:o=!1,showToolbar:r=!0,size:l="md",editorSize:h="standard",placeholder:C,onExport:k,onImageUpload:L,maxUndo:z=50,slashCommands:W=!0,showWordCount:K=!1,showToc:_=!1,showFindReplace:O=!0,className:H,style:Z,id:F,...X},f)=>{const w=te.Hs(F),{t:S}=te.Jo(),[M,G]=n.useState(()=>t??[Ht()]),y=t??M,[N,j]=n.useState(0),$=n.useRef(new Map),A=n.useRef(null),[P,v]=n.useState(!1),[c,D]=n.useState(""),[x,m]=n.useState(""),[s,d]=n.useState([]),[p,g]=n.useState(0),[u,R]=n.useState(!1),V=n.useRef([]),I=n.useRef([]),ee=n.useCallback(a=>{V.current.push(a.map(T=>({...T,checked:T.checked?[...T.checked]:void 0}))),V.current.length>z&&V.current.shift(),I.current=[]},[z]),me=n.useCallback(()=>{if(V.current.length===0)return;const a=V.current.pop();I.current.push(y.map(T=>({...T}))),t||G(a),i?.(a)},[y,t,i]),Y=n.useCallback(()=>{if(I.current.length===0)return;const a=I.current.pop();V.current.push(y.map(T=>({...T}))),t||G(a),i?.(a)},[y,t,i]),[ne,oe]=n.useState(!1),[ue,ye]=n.useState(""),[ge,ke]=n.useState(0),ie=n.useMemo(()=>{if(!ne||!W)return[];const a=ue.toLowerCase();return Ti.filter(T=>T.label.toLowerCase().includes(a)||T.keywords.includes(a))},[ne,ue,W]),[re,le]=n.useState(null),[ae,E]=n.useState(null),b=n.useCallback(a=>{ee(y);const T=a(y);t||G(T),i?.(T)},[y,t,i,ee]),q=n.useCallback((a,T)=>{b(U=>U.map((se,he)=>he===a?{...se,...T}:se))},[b]),ce=n.useCallback((a,T)=>{const U=T??Ht();b(se=>{const he=[...se];return he.splice(a+1,0,U),he}),j(a+1)},[b]),de=n.useCallback(a=>{const T={...y[a],id:xt()};ce(a,T)},[y,ce]),B=n.useCallback(a=>{y.length<=1||(b(T=>T.filter((U,se)=>se!==a)),j(Math.max(0,a-1)))},[y.length,b]),J=n.useCallback((a,T)=>{const U=a+T;U<0||U>=y.length||(b(se=>{const he=[...se];return[he[a],he[U]]=[he[U],he[a]],he}),j(U))},[y.length,b]),be=n.useCallback((a,T)=>{const U={type:T};T==="heading"&&(U.level=2),T==="list"&&(U.listType="unordered"),T==="callout"&&(U.icon="??"),T==="toggle"&&(U.open=!0),q(a,U)},[q]),fe=n.useCallback(a=>{const T=Ei(a.type);a.type==="list"&&a.label.includes("Numbered")&&(T.listType="ordered"),a.type==="list"&&a.label.includes("Checklist")&&(T.listType="checklist",T.checked=[]),y[N]?.content===""||y[N]?.content==="/"?b(U=>U.map((se,he)=>he===N?{...T,id:se.id}:se)):ce(N,T),oe(!1),ye("")},[y,N,b,ce]),we=n.useCallback((a,T)=>{if(o)return;const U=y[T];if(!U?.locked){if((a.ctrlKey||a.metaKey)&&a.key==="z"&&!a.shiftKey){a.preventDefault(),me();return}if((a.ctrlKey||a.metaKey)&&(a.key==="y"||a.key==="z"&&a.shiftKey)){a.preventDefault(),Y();return}if((a.ctrlKey||a.metaKey)&&a.key==="d"){a.preventDefault(),de(T);return}if((a.ctrlKey||a.metaKey)&&a.key==="b"){a.preventDefault(),q(T,{bold:!U?.bold});return}if((a.ctrlKey||a.metaKey)&&a.key==="i"){a.preventDefault(),q(T,{italic:!U?.italic});return}if((a.ctrlKey||a.metaKey)&&a.key==="u"){a.preventDefault(),q(T,{underline:!U?.underline});return}if((a.ctrlKey||a.metaKey)&&a.key==="e"){a.preventDefault(),q(T,{strikethrough:!U?.strikethrough});return}if(a.key==="Tab"&&!a.shiftKey){a.preventDefault(),q(T,{indent:Math.min((U?.indent??0)+1,4)});return}if(a.key==="Tab"&&a.shiftKey){a.preventDefault(),q(T,{indent:Math.max((U?.indent??0)-1,0)});return}if((a.ctrlKey||a.metaKey)&&a.key==="f"&&O){a.preventDefault(),v(se=>!se);return}if(ne&&ie.length>0){if(a.key==="ArrowDown"){a.preventDefault(),ke(se=>Math.min(se+1,ie.length-1));return}if(a.key==="ArrowUp"){a.preventDefault(),ke(se=>Math.max(se-1,0));return}if(a.key==="Enter"){a.preventDefault(),fe(ie[ge]);return}if(a.key==="Escape"){oe(!1);return}}a.key==="Enter"&&!a.shiftKey?(a.preventDefault(),ce(T)):a.key==="Backspace"&&y[T].content===""&&y.length>1?(a.preventDefault(),B(T)):a.key==="ArrowUp"&&a.altKey?(a.preventDefault(),J(T,-1)):a.key==="ArrowDown"&&a.altKey&&(a.preventDefault(),J(T,1))}},[o,y,ce,B,J,me,Y,de,q,ne,ie,ge,fe,O]),je=n.useCallback((a,T)=>{const U=a.target.textContent??"";W&&U.startsWith("/")?(oe(!0),ye(U.slice(1)),ke(0)):ne&&oe(!1),ee(y);const se=y.map((he,ve)=>ve===T?{...he,content:U}:he);t||G(se),i?.(se)},[y,t,i,ee,W,ne]),De=n.useCallback((a,T)=>{le(T),a.dataTransfer.effectAllowed="move"},[]),Re=n.useCallback((a,T)=>{a.preventDefault(),a.dataTransfer.dropEffect="move",E(T)},[]),$e=n.useCallback((a,T)=>{if(a.preventDefault(),re===null||re===T){le(null),E(null);return}b(U=>{const se=[...U],[he]=se.splice(re,1);return se.splice(T>re?T-1:T,0,he),se}),j(T>re?T-1:T),le(null),E(null)},[re,b]);n.useEffect(()=>{if(!P||!c){d([]);return}const a=c.toLowerCase(),T=[];y.forEach((U,se)=>{const he=(U.content??"").toLowerCase();let ve=0;for(;ve<he.length;){const Ce=he.indexOf(a,ve);if(Ce===-1)break;T.push({blockIdx:se,start:Ce,end:Ce+a.length}),ve=Ce+1}}),d(T),g(0)},[c,P,y]);const Le=n.useCallback(()=>{if(s.length===0)return;const a=(p+1)%s.length;g(a),j(s[a].blockIdx)},[s,p]),Fe=n.useCallback(()=>{if(s.length===0)return;const a=(p-1+s.length)%s.length;g(a),j(s[a].blockIdx)},[s,p]),Ye=n.useCallback(()=>{if(s.length===0||!c)return;const a=s[p],T=y[a.blockIdx],U=T.content.slice(0,a.start),se=T.content.slice(a.end);q(a.blockIdx,{content:U+x+se})},[s,p,c,x,y,q]),Ue=n.useCallback(()=>{if(!c)return;const a=c;b(T=>T.map(U=>({...U,content:U.content.split(a).join(x)})))},[c,x,b]),Be=n.useMemo(()=>_?y.map((a,T)=>a.type==="heading"?{idx:T,level:a.level??2,text:a.content}:null).filter(Boolean):[],[y,_]),ze=n.useCallback(async a=>{const T=a.target.files?.[0];if(T){if(L){const U=await L(T);q(N,{src:U})}a.target.value=""}},[L,N,q]);n.useEffect(()=>{const a=y[N];if(a){const T=$.current.get(a.id);T&&T.focus()}},[N,y]);const Pe=n.useCallback(()=>{const a=y.map(Ri).join(`
416
+ `);k?.(a)},[y,k]),Ee=n.useMemo(()=>K?Ii(y):null,[y,K]),[Q,pe]=n.useState(null),_e=n.useCallback((a,T)=>{o||(a.preventDefault(),pe({x:a.clientX,y:a.clientY,idx:T}))},[o]);return n.useEffect(()=>{if(!Q)return;const a=()=>pe(null);return window.addEventListener("click",a),()=>window.removeEventListener("click",a)},[Q]),e.jsxs("div",{ref:f,id:w,className:`nice-doc-editor nice-doc-editor--${l} nice-editor--${h} ${o?"nice-doc-editor--readonly":""} ${H??""}`,style:Z,role:"application","aria-label":S("docEditor.label","Document Editor"),...X,children:[r&&!o&&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(xe.NiceButton,{size:"sm",variant:"ghost",onClick:me,title:S("docEditor.undo","Undo (Ctrl+Z)"),children:"?"}),e.jsx(xe.NiceButton,{size:"sm",variant:"ghost",onClick:Y,title:S("docEditor.redo","Redo (Ctrl+Y)"),children:"?"}),e.jsx("span",{className:"nice-doc-editor__sep"}),e.jsx(xe.NiceSelect,{size:"sm",value:y[N]?.type??"paragraph",onChange:a=>be(N,a),label:"",options:[{value:"paragraph",label:S("docEditor.paragraph","Paragraph")},{value:"heading",label:S("docEditor.heading","Heading")},{value:"list",label:S("docEditor.list","List")},{value:"code",label:S("docEditor.code","Code")},{value:"quote",label:S("docEditor.quote","Quote")},{value:"callout",label:S("docEditor.callout","Callout")},{value:"toggle",label:S("docEditor.toggle","Toggle")},{value:"divider",label:S("docEditor.divider","Divider")},{value:"image",label:S("docEditor.image","Image")},{value:"video",label:S("docEditor.video","Video")},{value:"pageBreak",label:S("docEditor.pageBreak","Page Break")}],style:{minWidth:100}}),y[N]?.type==="heading"&&e.jsx(xe.NiceSelect,{size:"sm",value:String(y[N]?.level??2),onChange:a=>q(N,{level:Number(a)}),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}}),y[N]?.type==="list"&&e.jsx(xe.NiceSelect,{size:"sm",value:y[N]?.listType??"unordered",onChange:a=>q(N,{listType:a}),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(xe.NiceButton,{size:"sm",variant:y[N]?.bold?"primary":"ghost",onClick:()=>q(N,{bold:!y[N]?.bold}),title:S("docEditor.bold","Bold (Ctrl+B)"),children:e.jsx("strong",{children:"B"})}),e.jsx(xe.NiceButton,{size:"sm",variant:y[N]?.italic?"primary":"ghost",onClick:()=>q(N,{italic:!y[N]?.italic}),title:S("docEditor.italic","Italic (Ctrl+I)"),children:e.jsx("em",{children:"I"})}),e.jsx(xe.NiceButton,{size:"sm",variant:y[N]?.underline?"primary":"ghost",onClick:()=>q(N,{underline:!y[N]?.underline}),title:S("docEditor.underline","Underline (Ctrl+U)"),children:e.jsx("u",{children:"U"})}),e.jsx(xe.NiceButton,{size:"sm",variant:y[N]?.strikethrough?"primary":"ghost",onClick:()=>q(N,{strikethrough:!y[N]?.strikethrough}),title:S("docEditor.strikethrough","Strikethrough (Ctrl+E)"),children:e.jsx("s",{children:"S"})}),e.jsx("span",{className:"nice-doc-editor__sep"}),e.jsx(xe.NiceButton,{size:"sm",variant:y[N]?.align==="left"?"primary":"ghost",onClick:()=>q(N,{align:"left"}),title:S("docEditor.alignLeft","Left"),children:"?"}),e.jsx(xe.NiceButton,{size:"sm",variant:y[N]?.align==="center"?"primary":"ghost",onClick:()=>q(N,{align:"center"}),title:S("docEditor.alignCenter","Center"),children:"?"}),e.jsx(xe.NiceButton,{size:"sm",variant:y[N]?.align==="right"?"primary":"ghost",onClick:()=>q(N,{align:"right"}),title:S("docEditor.alignRight","Right"),children:"?"}),e.jsx("span",{className:"nice-doc-editor__sep"}),e.jsx(xe.NiceButton,{size:"sm",variant:"ghost",onClick:()=>q(N,{indent:Math.min((y[N]?.indent??0)+1,4)}),title:S("docEditor.indent","Indent (Tab)"),children:"??"}),e.jsx(xe.NiceButton,{size:"sm",variant:"ghost",onClick:()=>q(N,{indent:Math.max((y[N]?.indent??0)-1,0)}),title:S("docEditor.outdent","Outdent (Shift+Tab)"),children:"??"}),e.jsx("span",{className:"nice-doc-editor__sep"}),e.jsx(xe.NiceColorPicker,{size:"sm",label:"",value:y[N]?.color??"var(--text-primary, #000000)",onChange:a=>q(N,{color:a}),title:"Text color"}),e.jsx(xe.NiceColorPicker,{size:"sm",label:"",value:y[N]?.bgColor??"var(--bg-primary, #ffffff)",onChange:a=>q(N,{bgColor:a}),title:"Block background"}),e.jsx("span",{className:"nice-doc-editor__sep"}),e.jsx(xe.NiceButton,{size:"sm",variant:y[N]?.locked?"primary":"ghost",onClick:()=>q(N,{locked:!y[N]?.locked}),title:S("docEditor.lock","Lock/Unlock block"),children:"??"}),e.jsx(xe.NiceButton,{size:"sm",variant:"ghost",onClick:()=>de(N),title:S("docEditor.duplicate","Duplicate (Ctrl+D)"),children:"?"}),e.jsx(xe.NiceButton,{size:"sm",variant:"ghost",onClick:()=>B(N),title:S("docEditor.delete","Delete block"),children:"??"}),e.jsx(xe.NiceButton,{size:"sm",variant:"ghost",onClick:()=>ce(N),title:S("docEditor.addBlock","Add block"),children:"+"}),O&&e.jsx(xe.NiceButton,{size:"sm",variant:P?"primary":"ghost",onClick:()=>v(a=>!a),title:S("docEditor.find","Find & Replace (Ctrl+F)"),children:"??"}),e.jsx(xe.NiceButton,{size:"sm",variant:"ghost",onClick:()=>R(a=>!a),title:S("docEditor.shortcuts","Keyboard shortcuts"),children:"?"}),k&&e.jsx(xe.NiceButton,{size:"sm",variant:"ghost",onClick:Pe,children:S("docEditor.export","Export HTML")})]}),e.jsx("input",{ref:A,type:"file",accept:"image/*,video/*",style:{display:"none"},onChange:ze}),P&&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(--border-color, #ddd)"},children:[e.jsx(xe.NiceTextInput,{size:"sm",placeholder:S("docEditor.findPlaceholder","Find..."),value:c,onChange:D,style:{flex:1,maxWidth:200}}),e.jsx(xe.NiceTextInput,{size:"sm",placeholder:S("docEditor.replacePlaceholder","Replace..."),value:x,onChange:m,style:{flex:1,maxWidth:200}}),e.jsx(xe.NiceButton,{size:"sm",variant:"ghost",onClick:Fe,title:S("docEditor.findPrev","Previous"),children:"?"}),e.jsx(xe.NiceButton,{size:"sm",variant:"ghost",onClick:Le,title:S("docEditor.findNext","Next"),children:"?"}),e.jsx(xe.NiceButton,{size:"sm",variant:"ghost",onClick:Ye,title:S("docEditor.replaceOne","Replace"),disabled:o,children:S("docEditor.replace","Replace")}),e.jsx(xe.NiceButton,{size:"sm",variant:"ghost",onClick:Ue,title:S("docEditor.replaceAll","Replace all"),disabled:o,children:S("docEditor.replaceAllBtn","All")}),e.jsx("span",{style:{fontSize:"0.75em",color:"var(--text-muted, #666)"},children:s.length>0?`${p+1}/${s.length}`:"0/0"}),e.jsx(xe.NiceButton,{size:"sm",variant:"ghost",onClick:()=>v(!1),children:"?"})]}),u&&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:()=>R(!1),children:e.jsxs("div",{style:{background:"var(--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:a=>a.stopPropagation(),children:[e.jsx("h3",{style:{margin:"0 0 12px"},children:S("docEditor.shortcutsTitle","Keyboard Shortcuts")}),e.jsx("table",{style:{width:"100%",fontSize:"0.875em",borderCollapse:"collapse"},children:e.jsx("tbody",{children:[["Ctrl+B",S("docEditor.bold","Bold")],["Ctrl+I",S("docEditor.italic","Italic")],["Ctrl+U",S("docEditor.underline","Underline")],["Ctrl+E",S("docEditor.strikethrough","Strikethrough")],["Ctrl+D",S("docEditor.duplicate","Duplicate block")],["Ctrl+Z",S("docEditor.undo","Undo")],["Ctrl+Y",S("docEditor.redo","Redo")],["Ctrl+F",S("docEditor.find","Find & Replace")],["Enter",S("docEditor.newBlock","New block")],["Backspace",S("docEditor.deleteEmpty","Delete empty block")],["Alt+?",S("docEditor.moveUp","Move block up")],["Alt+?",S("docEditor.moveDown","Move block down")],["Tab",S("docEditor.indent","Indent")],["Shift+Tab",S("docEditor.outdent","Outdent")],["/",S("docEditor.slashCmd","Slash commands")]].map(([a,T])=>e.jsxs("tr",{style:{borderBottom:"1px solid var(--border-color, #eee)"},children:[e.jsx("td",{style:{padding:"4px 8px",fontFamily:"monospace",fontWeight:600},children:a}),e.jsx("td",{style:{padding:"4px 8px"},children:T})]},a))})}),e.jsx("div",{style:{textAlign:"right",marginTop:12},children:e.jsx(xe.NiceButton,{size:"sm",variant:"ghost",onClick:()=>R(!1),children:S("docEditor.close","Close")})})]})}),e.jsxs("div",{style:{display:"flex",gap:0},children:[_&&Be.length>0&&e.jsxs("nav",{className:"nice-doc-editor__toc",style:{width:200,minWidth:160,borderRight:"1px solid var(--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(--text-muted, #999)"},children:S("docEditor.toc","Contents")}),Be.map(a=>e.jsx("div",{style:{padding:"3px 8px",paddingLeft:8+(a.level-1)*12,cursor:"pointer",borderRadius:4,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",background:a.idx===N?"var(--nice-primary-bg, #e8f0fe)":void 0},onClick:()=>j(a.idx),title:a.text,children:a.text||S("docEditor.untitled","Untitled")},a.idx))]}),e.jsx("div",{className:"nice-doc-editor__body",style:{flex:1},children:y.map((a,T)=>e.jsxs("div",{className:`nice-doc-editor__block nice-doc-editor__block--${a.type} ${T===N?"nice-doc-editor__block--focused":""} ${ae===T?"nice-doc-editor__block--drop-target":""} ${a.locked?"nice-doc-editor__block--locked":""}`,onClick:()=>j(T),onContextMenu:U=>_e(U,T),draggable:!o&&!a.locked,onDragStart:U=>De(U,T),onDragOver:U=>Re(U,T),onDrop:U=>$e(U,T),onDragEnd:()=>{le(null),E(null)},style:{opacity:re===T?.4:1,marginLeft:(a.indent??0)*24},children:[!o&&!a.locked&&e.jsx("div",{className:"nice-doc-editor__block-handle",title:S("docEditor.drag","Drag to reorder"),children:"?"}),a.locked&&e.jsx("span",{className:"nice-doc-editor__lock-icon",style:{position:"absolute",top:2,right:4,fontSize:"0.7em",opacity:.5},children:"??"}),a.type==="divider"?e.jsx("hr",{className:"nice-doc-editor__divider"}):a.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(--text-muted, #999)"},children:["� ",S("docEditor.pageBreak","Page Break")," �"]}):a.type==="image"||a.type==="video"?e.jsx("div",{className:"nice-doc-editor__media-block",children:a.src?a.type==="image"?e.jsx("img",{src:a.src,alt:a.alt??"",className:"nice-doc-editor__image",style:{maxWidth:"100%"}}):e.jsx("video",{src:a.src,controls:!0,className:"nice-doc-editor__video",style:{maxWidth:"100%"}}):!o&&e.jsxs("div",{style:{display:"flex",gap:4,alignItems:"center"},children:[e.jsx(xe.NiceTextInput,{size:"sm",placeholder:S("docEditor.mediaUrl",a.type==="image"?"Image URL":"Video URL"),value:a.src??"",onChange:U=>q(T,{src:U})}),L&&e.jsx(xe.NiceButton,{size:"sm",variant:"ghost",onClick:()=>{j(T),A.current?.click()},children:"??"})]})}):a.type==="callout"?e.jsxs("div",{className:"nice-doc-editor__callout",style:{display:"flex",gap:8,padding:"8px 12px",background:a.bgColor??"#f0f7ff",borderRadius:4,color:a.color},children:[e.jsx("span",{style:{fontSize:"1.2em"},children:a.icon??"??"}),e.jsx("div",{ref:U=>{U&&$.current.set(a.id,U)},className:"nice-doc-editor__content",contentEditable:!o&&!a.locked,suppressContentEditableWarning:!0,onInput:U=>je(U,T),onFocus:()=>j(T),onKeyDown:U=>we(U,T),"data-placeholder":S("docEditor.calloutPlaceholder","Callout text..."),role:"textbox","aria-multiline":"true",style:{flex:1,outline:"none"},children:a.content})]}):a.type==="toggle"?e.jsxs("details",{open:a.open,className:"nice-doc-editor__toggle",onToggle:U=>q(T,{open:U.target.open}),children:[e.jsx("summary",{style:{cursor:"pointer",fontWeight:500},children:a.content.split(`
417
+ `)[0]||S("docEditor.toggleTitle","Toggle")}),e.jsx("div",{ref:U=>{U&&$.current.set(a.id,U)},className:"nice-doc-editor__content",contentEditable:!o&&!a.locked,suppressContentEditableWarning:!0,onInput:U=>je(U,T),onFocus:()=>j(T),onKeyDown:U=>we(U,T),role:"textbox","aria-multiline":"true",style:{padding:"4px 0"},children:a.content.split(`
418
+ `).slice(1).join(`
419
+ `)})]}):a.type==="code"?e.jsxs("div",{className:"nice-doc-editor__code-block",style:{position:"relative"},children:[!o&&e.jsx(xe.NiceTextInput,{size:"sm",value:a.language??"",onChange:U=>q(T,{language:U}),placeholder:"Language",style:{position:"absolute",top:4,right:4,width:80,opacity:.7}}),e.jsx("pre",{ref:U=>{U&&$.current.set(a.id,U)},className:"nice-doc-editor__content",contentEditable:!o&&!a.locked,suppressContentEditableWarning:!0,onInput:U=>je(U,T),onFocus:()=>j(T),onKeyDown:U=>we(U,T),role:"textbox","aria-multiline":"true",style:{fontFamily:"monospace",background:"var(--bg-elevated, #1e1e1e)",color:"var(--text-secondary, #d4d4d4)",padding:12,borderRadius:4,overflow:"auto"},children:a.content})]}):e.jsxs("div",{style:{position:"relative"},children:[e.jsx("div",{ref:U=>{U&&$.current.set(a.id,U)},className:"nice-doc-editor__content",contentEditable:!o&&!a.locked,suppressContentEditableWarning:!0,style:{textAlign:a.align,fontWeight:a.bold?"bold":void 0,fontStyle:a.italic?"italic":void 0,textDecoration:[a.underline?"underline":"",a.strikethrough?"line-through":""].filter(Boolean).join(" ")||void 0,color:a.color,backgroundColor:a.bgColor},onInput:U=>je(U,T),onFocus:()=>j(T),onKeyDown:U=>we(U,T),"data-placeholder":!a.content&&C?C:void 0,role:"textbox","aria-multiline":"true",children:a.content}),ne&&T===N&&ie.length>0&&e.jsx("ul",{className:"nice-doc-editor__slash-menu",style:{position:"absolute",left:0,top:"100%",zIndex:100,background:"var(--bg-primary, #fff)",border:"1px solid var(--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:ie.map((U,se)=>e.jsxs("li",{className:se===ge?"nice-doc-editor__slash-item--active":"",style:{padding:"6px 10px",cursor:"pointer",borderRadius:4,display:"flex",gap:8,alignItems:"center",background:se===ge?"var(--nice-primary-bg, #e8f0fe)":void 0},onMouseDown:he=>{he.preventDefault(),fe(U)},onMouseEnter:()=>ke(se),children:[e.jsx("span",{style:{width:24,textAlign:"center"},children:U.icon}),e.jsx("span",{children:U.label})]},`${U.type}-${U.label}`))})]})]},a.id))})]}),Q&&e.jsxs("div",{className:"nice-doc-editor__ctx-menu",style:{position:"fixed",left:Q.x,top:Q.y,zIndex:1e3,background:"var(--bg-primary, #fff)",border:"1px solid var(--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:()=>{de(Q.idx),pe(null)},children:"? Duplicate"}),e.jsx("div",{style:{padding:"6px 12px",cursor:"pointer"},onClick:()=>{ce(Q.idx),pe(null)},children:"+ Insert below"}),e.jsx("div",{style:{padding:"6px 12px",cursor:"pointer"},onClick:()=>{J(Q.idx,-1),pe(null)},children:"? Move up"}),e.jsx("div",{style:{padding:"6px 12px",cursor:"pointer"},onClick:()=>{J(Q.idx,1),pe(null)},children:"? Move down"}),e.jsx("div",{style:{padding:"6px 12px",cursor:"pointer"},onClick:()=>{q(Q.idx,{locked:!y[Q.idx]?.locked}),pe(null)},children:y[Q.idx]?.locked?"?? Unlock":"?? Lock"}),e.jsx("hr",{style:{margin:"2px 0",border:"none",borderTop:"1px solid var(--border-color, #eee)"}}),e.jsx("div",{style:{padding:"6px 12px",cursor:"pointer",color:"var(--nice-danger-dark, #d32f2f)"},onClick:()=>{B(Q.idx),pe(null)},children:"?? Delete"})]}),K&&Ee&&e.jsxs("div",{className:"nice-doc-editor__footer",style:{padding:"4px 12px",fontSize:"0.75em",color:"var(--text-muted, #666)",borderTop:"1px solid var(--border-color, #eee)",display:"flex",gap:16},children:[e.jsxs("span",{children:[Ee.words," ",S("docEditor.words","words")]}),e.jsxs("span",{children:[Ee.chars," ",S("docEditor.chars","characters")]}),e.jsxs("span",{children:[y.length," ",S("docEditor.blocks","blocks")]}),e.jsxs("span",{children:["~",Ee.readingTime," ",S("docEditor.readingTime","min read")]})]})]})});yn.displayName="NiceDocumentEditor";const Ai=["street","streetNumber","apartment","city","postalCode","state","country"],Ze={street:"Street",streetNumber:"Number",apartment:"Apt/Suite",city:"City",postalCode:"Postal Code",state:"State/Province",country:"Country"},xn=n.forwardRef(({label:t,helperText:i,error:o,required:r,disabled:l,readOnly:h,size:C="md",name:k,id:L,className:z,style:W,accessMode:K,value:_={},onChange:O,fields:H=Ai,placeholders:Z={},countries:F,layout:X="vertical",countryFirst:f=!1,validatePostalCode:w},S)=>{const M=te.Zs(K,L),G=M==="hidden";M==="disabled"&&(l=!0),M==="readOnly"&&(h=!0);const{t:y}=te.Jo(),N=te.Hs(L),j=n.useCallback((v,c)=>{O?.({..._,[v]:c})},[_,O]),$=n.useMemo(()=>{if(w&&_.postalCode)return w(_.postalCode,_.country)},[w,_.postalCode,_.country]),A=n.useMemo(()=>f&&H.includes("country")?["country",...H.filter(v=>v!=="country")]:H,[H,f]),P=`nice-address nice-address--${X} nice-size-${C}`;return G?null:e.jsxs("div",{ref:S,id:N,className:`${P}${z?` ${z}`:""}${o?" nice-error":""}${l?" nice-disabled":""}`,style:W,role:"group","aria-label":t??y("address","Address"),children:[t&&e.jsxs("label",{className:"nice-address__label",children:[t,r&&e.jsx("span",{className:"nice-required",children:"*"})]}),e.jsx("div",{className:"nice-address__fields",children:A.map(v=>v==="country"&&F?e.jsxs("div",{className:`nice-address__field nice-address__field--${v}`,children:[e.jsx("label",{className:"nice-address__field-label",children:y(v,Ze[v])}),e.jsxs("select",{className:"nice-input nice-select",value:_.country??"",onChange:c=>j("country",c.target.value),disabled:l,"aria-label":y(v,Ze[v]),children:[e.jsx("option",{value:"",children:Z.country??y("selectCountry","— Select country —")}),F.map(c=>e.jsx("option",{value:c.code,children:c.name},c.code))]})]},v):e.jsxs("div",{className:`nice-address__field nice-address__field--${v}`,children:[e.jsx("label",{className:"nice-address__field-label",children:y(v,Ze[v])}),e.jsx("input",{className:`nice-input${v==="postalCode"&&$?" nice-input--error":""}`,type:"text",name:k?`${k}.${v}`:v,value:_[v]??"",onChange:c=>j(v,c.target.value),placeholder:Z[v]??"",disabled:l,readOnly:h,"aria-label":y(v,Ze[v])}),v==="postalCode"&&$&&e.jsx("span",{className:"nice-error-text",children:$})]},v))}),i&&e.jsx("span",{className:"nice-helper-text",children:i}),o&&typeof o=="string"&&e.jsx("span",{className:"nice-error-text",children:o})]})});xn.displayName="NiceAddressInput";const Di=[{code:"PLN",symbol:"zł",name:"Polish Zloty"},{code:"EUR",symbol:"€",name:"Euro"},{code:"USD",symbol:"$",name:"US Dollar"},{code:"GBP",symbol:"£",name:"British Pound"},{code:"CZK",symbol:"Kč",name:"Czech Koruna"},{code:"CHF",symbol:"Fr",name:"Swiss Franc"}],bn=n.forwardRef(({label:t,helperText:i,error:o,required:r,disabled:l,readOnly:h,size:C="md",name:k,id:L,className:z,style:W,accessMode:K,value:_,onChange:O,onBlur:H,currency:Z="PLN",onCurrencyChange:F,currencies:X=Di,useMinorUnit:f=!1,min:w,max:S,locale:M,placeholder:G,showCurrencySelector:y},N)=>{const j=te.Zs(K,L),$=j==="hidden";j==="disabled"&&(l=!0),j==="readOnly"&&(h=!0);const{t:A}=te.Jo(),P=te.Hs(L),v=n.useMemo(()=>X.find(d=>d.code===Z)??X[0],[Z,X]),c=v?.decimals??2,D=n.useMemo(()=>_==null?"":(f?_/Math.pow(10,c):_).toFixed(c),[_,f,c]),x=n.useCallback(d=>{const p=d.replace(/[^\d.,\-]/g,"").replace(",",".");if(p===""||p==="-"){O?.(null);return}const g=parseFloat(p);if(isNaN(g))return;const u=f?Math.round(g*Math.pow(10,c)):g;w!=null&&u<w||S!=null&&u>S||O?.(u)},[O,f,c,w,S]),m=y??X.length>1,s=n.useMemo(()=>{if(_==null)return"";const d=f?_/Math.pow(10,c):_;try{return new Intl.NumberFormat(M,{style:"currency",currency:v?.code??"USD",minimumFractionDigits:c}).format(d)}catch{return`${d.toFixed(c)} ${v?.code}`}},[_,f,c,M,v]);return $?null:e.jsxs("div",{ref:N,id:P,className:`nice-currency nice-size-${C}${z?` ${z}`:""}${o?" nice-error":""}${l?" nice-disabled":""}`,style:W,children:[t&&e.jsxs("label",{className:"nice-currency__label",children:[t,r&&e.jsx("span",{className:"nice-required",children:"*"})]}),e.jsxs("div",{className:"nice-currency__row",children:[m&&e.jsx("select",{className:"nice-currency__select nice-select",value:Z,onChange:d=>F?.(d.target.value),disabled:l,"aria-label":A("currency","Currency"),children:X.map(d=>e.jsxs("option",{value:d.code,children:[d.symbol," ",d.code]},d.code))}),!m&&e.jsx("span",{className:"nice-currency__symbol",children:v?.symbol}),e.jsx("input",{className:"nice-input nice-currency__amount",type:"text",inputMode:"decimal",name:k,value:D,onChange:d=>x(d.target.value),onBlur:H,placeholder:G??`0.${"0".repeat(c)}`,disabled:l,readOnly:h,"aria-label":A("amount","Amount")})]}),s&&_!=null&&e.jsx("span",{className:"nice-currency__formatted",children:s}),i&&e.jsx("span",{className:"nice-helper-text",children:i}),o&&typeof o=="string"&&e.jsx("span",{className:"nice-error-text",children:o})]})});bn.displayName="NiceCurrencyInput";let Li=1;function zi(t){return{id:`new-${Li++}`,description:"",quantity:1,unitPrice:0,vatRate:t,discount:0,unit:"szt."}}function jn(t){const o=t.quantity*t.unitPrice*(1-(t.discount??0)/100),r=Math.round(o*100)/100,l=Math.round(r*(t.vatRate??0)/100*100)/100;return{...t,netAmount:r,grossAmount:r+l}}function Pi(t){const i=t.map(jn),o=i.reduce((k,L)=>k+(L.netAmount??0),0),r=i.reduce((k,L)=>k+(L.grossAmount??0),0),l=r-o,h=new Map;for(const k of i){const L=k.vatRate??0,z=h.get(L)??{base:0,amount:0};z.base+=k.netAmount??0,z.amount+=(k.grossAmount??0)-(k.netAmount??0),h.set(L,z)}const C=Array.from(h.entries()).map(([k,L])=>({rate:k,base:Math.round(L.base*100)/100,amount:Math.round(L.amount*100)/100}));return{totalNet:Math.round(o*100)/100,totalVat:Math.round(l*100)/100,totalGross:Math.round(r*100)/100,vatBreakdown:C}}const vn=n.forwardRef(({label:t,helperText:i,error:o,required:r,disabled:l,readOnly:h,size:C="md",name:k,id:L,className:z,style:W,accessMode:K,value:_=[],onChange:O,onTotalsChange:H,currencySymbol:Z="zł",defaultVatRate:F=23,vatRates:X=[0,5,8,23],units:f=["szt.","h","kg","m","usł."],showDiscount:w=!0,showUnit:S=!0,showTotals:M=!0,editable:G=!0,maxLines:y},N)=>{const j=te.Zs(K,L),$=j==="hidden";j==="disabled"&&(l=!0),j==="readOnly"&&(h=!0);const{t:A}=te.Jo(),P=te.Hs(L),v=n.useMemo(()=>_.map(jn),[_]),c=n.useMemo(()=>Pi(_),[_]);n.useEffect(()=>{H?.(c)},[c,H]);const D=n.useCallback((d,p,g)=>{const u=[..._];u[d]={...u[d],[p]:g},O?.(u)},[_,O]),x=n.useCallback(()=>{y&&_.length>=y||O?.([..._,zi(F)])},[_,O,F,y]),m=n.useCallback(d=>{O?.(_.filter((p,g)=>g!==d))},[_,O]),s=d=>`${d.toFixed(2)} ${Z}`;return $?null:e.jsxs("div",{ref:N,id:P,className:`nice-invoice-lines nice-size-${C}${z?` ${z}`:""}${o?" nice-error":""}${l?" nice-disabled":""}`,style:W,children:[t&&e.jsxs("label",{className:"nice-invoice-lines__label",children:[t,r&&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:A("description","Description")}),e.jsx("th",{className:"nice-il__th-qty",children:A("qty","Qty")}),S&&e.jsx("th",{className:"nice-il__th-unit",children:A("unit","Unit")}),e.jsx("th",{className:"nice-il__th-price",children:A("unitPrice","Unit Price")}),w&&e.jsx("th",{className:"nice-il__th-disc",children:A("discount","Disc %")}),e.jsx("th",{className:"nice-il__th-vat",children:A("vat","VAT %")}),e.jsx("th",{className:"nice-il__th-net",children:A("net","Net")}),e.jsx("th",{className:"nice-il__th-gross",children:A("gross","Gross")}),G&&!h&&e.jsx("th",{className:"nice-il__th-actions"})]})}),e.jsx("tbody",{children:v.map((d,p)=>e.jsxs("tr",{children:[e.jsx("td",{className:"nice-il__cell-num",children:p+1}),e.jsx("td",{className:"nice-il__cell-desc",children:e.jsx("input",{className:"nice-input",type:"text",value:d.description,onChange:g=>D(p,"description",g.target.value),disabled:l,readOnly:h,placeholder:A("itemDescription","Item description")})}),e.jsx("td",{className:"nice-il__cell-qty",children:e.jsx("input",{className:"nice-input",type:"number",value:d.quantity,onChange:g=>D(p,"quantity",parseFloat(g.target.value)||0),disabled:l,readOnly:h,min:0,step:"any"})}),S&&e.jsx("td",{className:"nice-il__cell-unit",children:e.jsx("select",{className:"nice-select",value:d.unit??"",onChange:g=>D(p,"unit",g.target.value),disabled:l,children:f.map(g=>e.jsx("option",{value:g,children:g},g))})}),e.jsx("td",{className:"nice-il__cell-price",children:e.jsx("input",{className:"nice-input",type:"number",value:d.unitPrice,onChange:g=>D(p,"unitPrice",parseFloat(g.target.value)||0),disabled:l,readOnly:h,min:0,step:"0.01"})}),w&&e.jsx("td",{className:"nice-il__cell-disc",children:e.jsx("input",{className:"nice-input",type:"number",value:d.discount??0,onChange:g=>D(p,"discount",parseFloat(g.target.value)||0),disabled:l,readOnly:h,min:0,max:100})}),e.jsx("td",{className:"nice-il__cell-vat",children:e.jsx("select",{className:"nice-select",value:d.vatRate??0,onChange:g=>D(p,"vatRate",parseInt(g.target.value,10)),disabled:l,children:X.map(g=>e.jsxs("option",{value:g,children:[g,"%"]},g))})}),e.jsx("td",{className:"nice-il__cell-net",children:s(d.netAmount??0)}),e.jsx("td",{className:"nice-il__cell-gross",children:s(d.grossAmount??0)}),G&&!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:()=>m(p),disabled:l,title:A("remove","Remove"),children:"✕"})})]},d.id))})]}),G&&!h&&e.jsxs("button",{type:"button",className:"nice-btn nice-btn--outlined nice-btn--sm nice-invoice-lines__add",onClick:x,disabled:l||y!=null&&_.length>=y,children:["+ ",A("addLine","Add line")]}),M&&e.jsxs("div",{className:"nice-invoice-lines__totals",children:[e.jsxs("div",{className:"nice-il__total-row",children:[e.jsxs("span",{children:[A("totalNet","Net total"),":"]}),e.jsx("span",{className:"nice-il__total-value",children:s(c.totalNet)})]}),c.vatBreakdown.map(d=>e.jsxs("div",{className:"nice-il__total-row nice-il__total-row--vat",children:[e.jsxs("span",{children:["VAT ",d.rate,"%:"]}),e.jsx("span",{className:"nice-il__total-value",children:s(d.amount)})]},d.rate)),e.jsxs("div",{className:"nice-il__total-row nice-il__total-row--gross",children:[e.jsxs("span",{children:[A("totalGross","Gross total"),":"]}),e.jsx("span",{className:"nice-il__total-value nice-il__total-value--gross",children:s(c.totalGross)})]})]}),i&&e.jsx("span",{className:"nice-helper-text",children:i}),o&&typeof o=="string"&&e.jsx("span",{className:"nice-error-text",children:o})]})});vn.displayName="NiceInvoiceLineEditor";const _n=n.forwardRef(({label:t,helperText:i,error:o,required:r,disabled:l,readOnly:h,size:C="md",name:k,id:L,className:z,style:W,accessMode:K,value:_=[],onChange:O,contacts:H=[],onSearch:Z,searchDelay:F=300,multiple:X=!1,placeholder:f,onContactClick:w,maxSelections:S},M)=>{const G=te.Zs(K,L),y=G==="hidden";G==="disabled"&&(l=!0),G==="readOnly"&&(h=!0);const{t:N}=te.Jo(),j=te.Hs(L),[$,A]=n.useState(""),[P,v]=n.useState([]),[c,D]=n.useState(!1),[x,m]=n.useState(!1),s=n.useMemo(()=>{const u=[...H,...P],R=new Map(u.map(V=>[V.id,V]));return _.map(V=>R.get(V)).filter(Boolean)},[_,H,P]),d=n.useCallback(u=>{if(A(u),u.length<1){v([]),D(!1);return}if(Z){m(!0);const I=setTimeout(async()=>{const ee=await Z(u);v(ee),D(!0),m(!1)},F);return()=>clearTimeout(I)}const R=u.toLowerCase(),V=H.filter(I=>I.name.toLowerCase().includes(R)||I.email?.toLowerCase().includes(R)||I.phone?.includes(u));v(V),D(!0)},[Z,H,F]),p=n.useCallback(u=>{if(X)if(_.includes(u.id))O?.(_.filter(R=>R!==u.id));else{if(S&&_.length>=S)return;O?.([..._,u.id])}else O?.([u.id]),D(!1),A("")},[_,O,X,S]),g=n.useCallback(u=>{O?.(_.filter(R=>R!==u))},[_,O]);return y?null:e.jsxs("div",{ref:M,id:j,className:`nice-contact-picker nice-size-${C}${z?` ${z}`:""}${o?" nice-error":""}${l?" nice-disabled":""}`,style:W,children:[t&&e.jsxs("label",{className:"nice-contact-picker__label",children:[t,r&&e.jsx("span",{className:"nice-required",children:"*"})]}),s.length>0&&e.jsx("div",{className:"nice-contact-picker__chips",children:s.map(u=>e.jsxs("span",{className:"nice-contact-picker__chip",onClick:()=>w?.(u),children:[u.avatarUrl&&e.jsx("img",{src:u.avatarUrl,alt:"",className:"nice-contact-picker__chip-avatar"}),e.jsx("span",{children:u.name}),!h&&e.jsx("button",{type:"button",className:"nice-contact-picker__chip-remove",onClick:R=>{R.stopPropagation(),g(u.id)},disabled:l,children:"×"})]},u.id))}),!h&&e.jsxs("div",{className:"nice-contact-picker__search",children:[e.jsx("input",{className:"nice-input",type:"text",value:$,onChange:u=>d(u.target.value),onFocus:()=>$.length>0&&D(!0),onBlur:()=>setTimeout(()=>D(!1),200),placeholder:f??N("searchContacts","Search contacts…"),disabled:l,"aria-label":N("searchContacts","Search contacts")}),x&&e.jsx("span",{className:"nice-contact-picker__spinner",children:"⏳"})]}),c&&P.length>0&&e.jsx("div",{className:"nice-contact-picker__dropdown",role:"listbox",children:P.map(u=>e.jsxs("div",{className:`nice-contact-picker__option${_.includes(u.id)?" nice-contact-picker__option--selected":""}`,role:"option","aria-selected":_.includes(u.id),onClick:()=>p(u),children:[u.avatarUrl&&e.jsx("img",{src:u.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:u.name}),u.subtitle&&e.jsx("span",{className:"nice-contact-picker__option-subtitle",children:u.subtitle}),u.email&&e.jsx("span",{className:"nice-contact-picker__option-email",children:u.email})]}),u.type&&e.jsx("span",{className:"nice-contact-picker__option-type",children:u.type==="person"?"👤":"🏢"})]},u.id))}),i&&e.jsx("span",{className:"nice-helper-text",children:i}),o&&typeof o=="string"&&e.jsx("span",{className:"nice-error-text",children:o})]})});_n.displayName="NiceContactPicker";const Hi=["highlight","underline","strikethrough","freehand","text","rect","arrow"],Fi={highlight:"🖍️",underline:"⎁",strikethrough:"S̶",freehand:"✏️",text:"T",rect:"▭",arrow:"→",stamp:"🔏"},kn=n.forwardRef(({label:t,helperText:i,error:o,required:r,disabled:l,readOnly:h,size:C="md",id:k,className:L,style:z,accessMode:W,src:K,annotations:_=[],onAnnotationsChange:O,activeTool:H,onToolChange:Z,currentPage:F=1,onPageChange:X,totalPages:f=1,defaultColor:w="var(--nice-warning, #ffff00)",tools:S=Hi,author:M,zoom:G=1,onZoomChange:y,onAnnotationClick:N,onAnnotationDelete:j},$)=>{const A=te.Zs(W,k),P=A==="hidden";A==="disabled"&&(l=!0),A==="readOnly"&&(h=!0);const{t:v}=te.Jo(),c=te.Hs(k),D=_.filter(s=>s.page===F),x=n.useCallback(s=>{Z?.(H===s?null:s)},[H,Z]),m=n.useCallback(s=>{if(h||!H||H==="freehand")return;const d=s.currentTarget.getBoundingClientRect(),p=(s.clientX-d.left)/d.width,g=(s.clientY-d.top)/d.height,u={id:`ann-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,tool:H,page:F,x:p,y:g,color:w,author:M,createdAt:new Date().toISOString(),text:H==="text"?"":void 0};O?.([..._,u])},[h,H,F,w,M,_,O]);return P?null:e.jsxs("div",{ref:$,id:c,className:`nice-pdf-annotation nice-size-${C}${L?` ${L}`:""}${o?" nice-error":""}${l?" nice-disabled":""}`,style:z,children:[t&&e.jsxs("div",{className:"nice-pdf-annotation__label",children:[t,r&&e.jsx("span",{className:"nice-required",children:"*"})]}),!h&&e.jsxs("div",{className:"nice-pdf-annotation__toolbar",children:[S.map(s=>e.jsx("button",{type:"button",className:`nice-pdf-annotation__tool-btn${H===s?" nice-pdf-annotation__tool-btn--active":""}`,onClick:()=>x(s),disabled:l,title:v(`pdfTool_${s}`,s),children:Fi[s]},s)),e.jsx("span",{className:"nice-pdf-annotation__toolbar-sep"}),e.jsx("button",{type:"button",disabled:l,onClick:()=>y?.(Math.max(.25,G-.25)),title:v("zoomOut","Zoom out"),children:"−"}),e.jsxs("span",{className:"nice-pdf-annotation__zoom",children:[Math.round(G*100),"%"]}),e.jsx("button",{type:"button",disabled:l,onClick:()=>y?.(Math.min(4,G+.25)),title:v("zoomIn","Zoom in"),children:"+"})]}),e.jsxs("div",{className:"nice-pdf-annotation__viewport",style:{transform:`scale(${G})`,transformOrigin:"top left"},children:[e.jsx("iframe",{src:K,className:"nice-pdf-annotation__frame",title:v("pdfViewer","PDF Viewer")}),e.jsx("div",{className:"nice-pdf-annotation__layer",onClick:m,children:D.map(s=>e.jsxs("div",{className:`nice-pdf-annotation__mark nice-pdf-annotation__mark--${s.tool}`,style:{left:`${s.x*100}%`,top:`${s.y*100}%`,backgroundColor:s.color},onClick:d=>{d.stopPropagation(),N?.(s)},title:s.text??s.tool,children:[s.text&&e.jsx("span",{children:s.text}),!h&&e.jsx("button",{type:"button",className:"nice-pdf-annotation__mark-delete",onClick:d=>{d.stopPropagation(),j?.(s.id)},children:"×"})]},s.id))})]}),e.jsxs("div",{className:"nice-pdf-annotation__pager",children:[e.jsx("button",{type:"button",disabled:l||F<=1,onClick:()=>X?.(F-1),children:"◀"}),e.jsx("span",{children:v("pageOf","{page} / {total}").replace("{page}",String(F)).replace("{total}",String(f))}),e.jsx("button",{type:"button",disabled:l||F>=f,onClick:()=>X?.(F+1),children:"▶"})]}),i&&e.jsx("span",{className:"nice-helper-text",children:i}),o&&typeof o=="string"&&e.jsx("span",{className:"nice-error-text",children:o})]})});kn.displayName="NicePDFAnnotationEditor";const wn=n.forwardRef(({label:t,helperText:i,error:o,disabled:r,readOnly:l,size:h="md",id:C,className:k,style:L,accessMode:z,pages:W,selectedPageId:K,content:_="",contentFormat:O="html",editing:H=!1,onPageSelect:Z,onContentChange:F,onSave:X,onCreatePage:f,onDeletePage:w,onEditToggle:S,onVersionHistory:M,sidebarWidth:G=260,sidebarCollapsed:y=!1,onSidebarToggle:N,searchable:j=!0,onSearch:$},A)=>{const P=te.Zs(z,C),v=P==="hidden";P==="disabled"&&(r=!0),P==="readOnly"&&(l=!0);const{t:c}=te.Jo(),D=te.Hs(C),[x,m]=n.useState(""),[s,d]=n.useState(""),[p,g]=n.useState(!1),u=n.useMemo(()=>{const ee=me=>{for(const Y of me){if(Y.id===K)return Y;if(Y.children){const ne=ee(Y.children);if(ne)return ne}}};return ee(W)},[W,K]),R=n.useCallback(ee=>{m(ee),$?.(ee)},[$]),V=n.useCallback(()=>{s.trim()&&(f?.(K??null,s.trim()),d(""),g(!1))},[s,K,f]),I=(ee,me=0)=>e.jsx("ul",{className:"nice-wiki__tree",style:{paddingLeft:me>0?16:0},children:ee.map(Y=>e.jsxs("li",{className:"nice-wiki__tree-item",children:[e.jsxs("div",{className:`nice-wiki__tree-node${Y.id===K?" nice-wiki__tree-node--active":""}${Y.isDraft?" nice-wiki__tree-node--draft":""}`,onClick:()=>Z?.(Y),role:"treeitem","aria-selected":Y.id===K,children:[e.jsx("span",{className:"nice-wiki__tree-icon",children:Y.children?.length?"📁":"📄"}),e.jsx("span",{className:"nice-wiki__tree-title",children:Y.title}),Y.isDraft&&e.jsx("span",{className:"nice-wiki__tree-draft",children:c("draft","Draft")})]}),Y.children&&Y.children.length>0&&I(Y.children,me+1)]},Y.id))});return v?null:e.jsxs("div",{ref:A,id:D,className:`nice-wiki nice-size-${h}${k?` ${k}`:""}${r?" nice-disabled":""}`,style:L,children:[!y&&e.jsxs("aside",{className:"nice-wiki__sidebar",style:{width:G},children:[e.jsxs("div",{className:"nice-wiki__sidebar-header",children:[e.jsx("span",{className:"nice-wiki__sidebar-title",children:t??c("wiki","Wiki")}),N&&e.jsx("button",{type:"button",className:"nice-wiki__sidebar-toggle",onClick:()=>N(!0),children:"«"})]}),j&&e.jsx("input",{type:"text",className:"nice-input nice-wiki__search",value:x,onChange:ee=>R(ee.target.value),placeholder:c("searchPages","Search pages…"),disabled:r}),e.jsx("div",{className:"nice-wiki__page-tree",role:"tree",children:I(W)}),f&&!l&&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:s,onChange:ee=>d(ee.target.value),placeholder:c("pageTitle","Page title"),onKeyDown:ee=>ee.key==="Enter"&&V(),disabled:r}),e.jsx("button",{type:"button",disabled:r||!s.trim(),onClick:V,children:"✓"}),e.jsx("button",{type:"button",onClick:()=>g(!1),children:"✕"})]}):e.jsxs("button",{type:"button",className:"nice-wiki__add-page",onClick:()=>g(!0),disabled:r,children:["+ ",c("newPage","New page")]})})]}),y&&N&&e.jsx("button",{type:"button",className:"nice-wiki__sidebar-expand",onClick:()=>N(!1),children:"»"}),e.jsx("main",{className:"nice-wiki__content",children:u?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"nice-wiki__content-header",children:[e.jsx("h1",{className:"nice-wiki__page-title",children:u.title}),e.jsxs("div",{className:"nice-wiki__content-actions",children:[S&&!l&&e.jsx("button",{type:"button",disabled:r,onClick:()=>S(!H),children:H?c("preview","Preview"):c("edit","Edit")}),M&&e.jsx("button",{type:"button",disabled:r,onClick:()=>M(u.id),children:c("history","History")}),w&&!l&&e.jsx("button",{type:"button",className:"nice-btn--danger",disabled:r,onClick:()=>w(u.id),children:c("delete","Delete")})]})]}),u.updatedAt&&e.jsxs("div",{className:"nice-wiki__page-meta",children:[u.updatedBy&&e.jsxs("span",{children:[c("lastEditedBy","Last edited by")," ",u.updatedBy]}),e.jsx("span",{children:new Date(u.updatedAt).toLocaleDateString()})]}),H?e.jsxs("div",{className:"nice-wiki__editor",children:[e.jsx("textarea",{className:"nice-wiki__editor-textarea",value:_,onChange:ee=>F?.(ee.target.value),disabled:r}),X&&e.jsx("button",{type:"button",className:"nice-btn nice-btn--primary",disabled:r,onClick:()=>X(u.id,_),children:c("save","Save")})]}):e.jsx("div",{className:"nice-wiki__viewer",children:O==="html"?e.jsx("div",{className:"nice-wiki__html",dangerouslySetInnerHTML:{__html:te.As(_)}}):e.jsx("pre",{className:"nice-wiki__markdown",children:_})})]}):e.jsx("div",{className:"nice-wiki__empty",children:e.jsx("p",{children:c("selectPage","Select a page from the sidebar or create a new one.")})})}),i&&e.jsx("span",{className:"nice-helper-text",children:i}),o&&typeof o=="string"&&e.jsx("span",{className:"nice-error-text",children:o})]})});wn.displayName="NiceWiki";const Bi=[{code:"PL",label:"Polska",prefix:"PL",pattern:/^\d{10}$/,placeholder:"1234567890"},{code:"DE",label:"Deutschland",prefix:"DE",pattern:/^\d{9}$/,placeholder:"123456789"},{code:"GB",label:"United Kingdom",prefix:"GB",pattern:/^\d{9}(\d{3})?$/,placeholder:"123456789"},{code:"FR",label:"France",prefix:"FR",pattern:/^[A-Z0-9]{2}\d{9}$/,placeholder:"XX123456789"},{code:"CZ",label:"Česko",prefix:"CZ",pattern:/^\d{8,10}$/,placeholder:"12345678"},{code:"SK",label:"Slovensko",prefix:"SK",pattern:/^\d{10}$/,placeholder:"1234567890"},{code:"IT",label:"Italia",prefix:"IT",pattern:/^\d{11}$/,placeholder:"12345678901"},{code:"ES",label:"España",prefix:"ES",pattern:/^[A-Z0-9]\d{7}[A-Z0-9]$/,placeholder:"X1234567X"}],Nn=n.forwardRef(({label:t,helperText:i,error:o,required:r,disabled:l,readOnly:h,size:C="md",name:k,id:L,className:z,style:W,accessMode:K,value:_="",onChange:O,countryCode:H="PL",onCountryChange:Z,countries:F=Bi,showCountrySelector:X=!0,autoPrefixVat:f=!0,validationResult:w,onValidateRequest:S,placeholder:M},G)=>{const y=te.Zs(K,L),N=y==="hidden";y==="disabled"&&(l=!0),y==="readOnly"&&(h=!0);const{t:j}=te.Jo(),$=te.Hs(L),A=n.useMemo(()=>F.find(x=>x.code===H)??F[0],[F,H]),P=n.useCallback(x=>{let m=x.toUpperCase();return A&&m.startsWith(A.prefix)&&(m=m.slice(A.prefix.length)),A?A.pattern.test(m):m.length>0},[A]),v=n.useCallback(x=>{const m=x.target.value.replace(/\s/g,"");O?.(m,P(m))},[O,P]),c=f&&_&&A&&!_.toUpperCase().startsWith(A.prefix)?`${A.prefix}${_}`:_,D=P(_);return N?null:e.jsxs("div",{ref:G,id:$,className:`nice-vat-input nice-size-${C}${z?` ${z}`:""}${o||!D&&_.length>0?" nice-error":""}${l?" nice-disabled":""}`,style:W,children:[t&&e.jsxs("label",{className:"nice-vat-input__label",htmlFor:`${$}-input`,children:[t,r&&e.jsx("span",{className:"nice-required",children:"*"})]}),e.jsxs("div",{className:"nice-vat-input__row",children:[X&&e.jsx("select",{className:"nice-vat-input__country",value:H,onChange:x=>Z?.(x.target.value),disabled:l||h,children:F.map(x=>e.jsx("option",{value:x.code,children:x.prefix},x.code))}),e.jsx("input",{id:`${$}-input`,className:"nice-input nice-vat-input__field",type:"text",name:k,value:_,onChange:v,readOnly:h,disabled:l,placeholder:M??A?.placeholder,required:r,"aria-invalid":!D&&_.length>0}),S&&_.length>0&&e.jsx("button",{type:"button",className:"nice-vat-input__verify",disabled:l||!D,onClick:()=>S(f?c:_,H),title:j("verifyVat","Verify VAT number"),children:"🔍"})]}),w&&e.jsxs("div",{className:`nice-vat-input__result nice-vat-input__result--${w.valid?"valid":"invalid"}`,children:[w.valid?"✅":"❌"," ",w.companyName??w.error??(w.valid?j("vatValid","VAT number valid"):j("vatInvalid","VAT number invalid"))]}),i&&e.jsx("span",{className:"nice-helper-text",children:i}),o&&typeof o=="string"&&e.jsx("span",{className:"nice-error-text",children:o})]})});Nn.displayName="NiceVatInput";const Oi=[{id:"pl-23",label:"23%",rate:.23,countryCode:"PL",category:"standard",isDefault:!0},{id:"pl-8",label:"8%",rate:.08,countryCode:"PL",category:"reduced"},{id:"pl-5",label:"5%",rate:.05,countryCode:"PL",category:"reduced"},{id:"pl-0",label:"0%",rate:0,countryCode:"PL",category:"zero"},{id:"pl-zw",label:"zw.",rate:0,countryCode:"PL",category:"exempt"},{id:"pl-np",label:"n.p.",rate:0,countryCode:"PL",category:"exempt"}],Cn=n.forwardRef(({label:t,helperText:i,error:o,required:r,disabled:l,readOnly:h,size:C="md",name:k,id:L,className:z,style:W,accessMode:K,value:_,onChange:O,rates:H,countryCode:Z,placeholder:F,showPercentage:X=!0},f)=>{const w=te.Zs(K,L),S=w==="hidden";w==="disabled"&&(l=!0),w==="readOnly"&&(h=!0);const{t:M}=te.Jo(),G=te.Hs(L),y=n.useMemo(()=>{const j=H??Oi;return Z?j.filter($=>!$.countryCode||$.countryCode===Z):j},[H,Z]),N=n.useCallback(j=>{const $=j.target.value,A=y.find(P=>P.id===$);A&&O?.($,A)},[O,y]);return S?null:e.jsxs("div",{ref:f,id:G,className:`nice-tax-rate nice-size-${C}${z?` ${z}`:""}${o?" nice-error":""}${l?" nice-disabled":""}`,style:W,children:[t&&e.jsxs("label",{className:"nice-tax-rate__label",htmlFor:`${G}-select`,children:[t,r&&e.jsx("span",{className:"nice-required",children:"*"})]}),e.jsxs("select",{id:`${G}-select`,className:"nice-select nice-tax-rate__select",name:k,value:_??"",onChange:N,disabled:l||h,required:r,children:[e.jsx("option",{value:"",disabled:!0,children:F??M("selectRate","Select rate…")}),y.map(j=>e.jsxs("option",{value:j.id,children:[j.label,X&&j.category!=="exempt"?` (${(j.rate*100).toFixed(0)}%)`:""]},j.id))]}),i&&e.jsx("span",{className:"nice-helper-text",children:i}),o&&typeof o=="string"&&e.jsx("span",{className:"nice-error-text",children:o})]})});Cn.displayName="NiceTaxRatePicker";const Ki={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)"},Sn=n.forwardRef(({label:t,helperText:i,error:o,required:r,disabled:l,readOnly:h,size:C="md",name:k,id:L,className:z,style:W,accessMode:K,value:_,onChange:O,accounts:H,treeView:Z=!1,placeholder:F,searchable:X=!0,showType:f=!0,onSearch:w},S)=>{const M=te.Zs(K,L),G=M==="hidden";M==="disabled"&&(l=!0),M==="readOnly"&&(h=!0);const{t:y}=te.Jo(),N=te.Hs(L),[j,$]=n.useState(""),[A,P]=n.useState(!1),v=n.useMemo(()=>{const s=d=>{for(const p of d){if(p.code===_)return p;if(p.children){const g=s(p.children);if(g)return g}}};return s(H)},[H,_]),c=n.useMemo(()=>{const s=[],d=p=>{for(const g of p)s.push(g),g.children&&d(g.children)};return d(H),s},[H]),D=n.useMemo(()=>{if(!j)return c;const s=j.toLowerCase();return c.filter(d=>d.code.toLowerCase().includes(s)||d.name.toLowerCase().includes(s))},[c,j]),x=n.useCallback(s=>{$(s),w?.(s),P(!0)},[w]),m=n.useCallback(s=>{O?.(s.code,s),P(!1),$("")},[O]);return G?null:e.jsxs("div",{ref:S,id:N,className:`nice-account-picker nice-size-${C}${z?` ${z}`:""}${o?" nice-error":""}${l?" nice-disabled":""}`,style:W,children:[t&&e.jsxs("label",{className:"nice-account-picker__label",htmlFor:`${N}-input`,children:[t,r&&e.jsx("span",{className:"nice-required",children:"*"})]}),e.jsx("div",{className:"nice-account-picker__control",children:X&&!h?e.jsx("input",{id:`${N}-input`,className:"nice-input",type:"text",value:A?j:v?`${v.code} — ${v.name}`:"",onChange:s=>x(s.target.value),onFocus:()=>{$(""),P(!0)},onBlur:()=>setTimeout(()=>P(!1),200),placeholder:F??y("searchAccount","Search account…"),disabled:l,required:r}):e.jsx("div",{className:"nice-account-picker__display",children:v?`${v.code} — ${v.name}`:F??y("selectAccount","Select account…")})}),A&&D.length>0&&e.jsx("div",{className:"nice-account-picker__dropdown",role:"listbox",children:D.map(s=>e.jsxs("div",{className:`nice-account-picker__option${s.code===_?" nice-account-picker__option--selected":""}${s.isActive===!1?" nice-account-picker__option--inactive":""}`,role:"option","aria-selected":s.code===_,onClick:()=>m(s),children:[f&&s.type&&e.jsx("span",{className:"nice-account-picker__type",style:{color:Ki[s.type]},title:s.type,children:"●"}),e.jsx("span",{className:"nice-account-picker__code",children:s.code}),e.jsx("span",{className:"nice-account-picker__name",children:s.name})]},s.code))}),i&&e.jsx("span",{className:"nice-helper-text",children:i}),o&&typeof o=="string"&&e.jsx("span",{className:"nice-error-text",children:o})]})});Sn.displayName="NiceAccountPicker";const Mn=n.forwardRef(({label:t,helperText:i,error:o,required:r,disabled:l,readOnly:h,size:C="md",id:k,className:L,style:z,accessMode:W,mode:K="manual",onScan:_,onModeChange:O,beepOnScan:H=!0,beepFrequency:Z=1800,beepDuration:F=150,placeholder:X,scanHistory:f=[],showHistory:w=!0,maxHistory:S=10,autoFocus:M=!0,onCameraFrame:G},y)=>{const N=te.Zs(W,k),j=N==="hidden";N==="disabled"&&(l=!0),N==="readOnly"&&(h=!0);const{t:$}=te.Jo(),A=te.Hs(k),[P,v]=n.useState(""),c=n.useRef(null),D=n.useRef(null),x=n.useCallback(()=>{if(H)try{D.current||(D.current=new AudioContext);const d=D.current,p=d.createOscillator(),g=d.createGain();p.connect(g),g.connect(d.destination),p.frequency.value=Z,p.type="square",g.gain.value=.3,p.start(),p.stop(d.currentTime+F/1e3)}catch{}},[H,Z,F]),m=n.useCallback(()=>{P.trim()&&(x(),_?.({value:P.trim(),format:"manual",scannedAt:new Date}),v(""),c.current?.focus())},[P,_,x]),s=f.slice(0,S);return j?null:e.jsxs("div",{ref:y,id:A,className:`nice-scanner nice-size-${C}${L?` ${L}`:""}${o?" nice-error":""}${l?" nice-disabled":""}`,style:z,children:[t&&e.jsxs("div",{className:"nice-scanner__label",children:[t,r&&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${K==="camera"?" nice-scanner__mode-btn--active":""}`,onClick:()=>O?.("camera"),disabled:l,children:["📷 ",$("camera","Camera")]}),e.jsxs("button",{type:"button",className:`nice-scanner__mode-btn${K==="manual"?" nice-scanner__mode-btn--active":""}`,onClick:()=>O?.("manual"),disabled:l,children:["⌨️ ",$("manual","Manual")]})]}),K==="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("p",{children:$("cameraPlaceholder","Camera preview — connect scanner adapter")})]})})}),K==="manual"&&!h&&e.jsxs("div",{className:"nice-scanner__manual",children:[e.jsx("input",{ref:c,className:"nice-input nice-scanner__input",type:"text",value:P,onChange:d=>v(d.target.value),onKeyDown:d=>d.key==="Enter"&&m(),placeholder:X??$("enterCode","Enter or scan code…"),disabled:l,autoFocus:M}),e.jsx("button",{type:"button",className:"nice-scanner__submit",onClick:m,disabled:l||!P.trim(),children:"✓"})]}),w&&s.length>0&&e.jsxs("div",{className:"nice-scanner__history",children:[e.jsx("div",{className:"nice-scanner__history-label",children:$("recentScans","Recent scans")}),s.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}),o&&typeof o=="string"&&e.jsx("span",{className:"nice-error-text",children:o})]})});Mn.displayName="NiceScannerControl";const $n=n.forwardRef(({label:t,helperText:i,error:o,required:r,disabled:l,readOnly:h,size:C="md",id:k,className:L,style:z,accessMode:W,value:K="",onChange:_,onComplete:O,length:H=4,masked:Z=!0,showKeypad:F=!1,autoSubmit:X=!0,shake:f=!1,placeholderChar:w="·"},S)=>{const M=te.Zs(W,k),G=M==="hidden";M==="disabled"&&(l=!0),M==="readOnly"&&(h=!0);const{t:y}=te.Jo(),N=te.Hs(k),j=n.useRef([]),[$,A]=n.useState(!1);n.useEffect(()=>{if(f){A(!0);const x=setTimeout(()=>A(!1),500);return()=>clearTimeout(x)}},[f]);const P=K.split("").slice(0,H);for(;P.length<H;)P.push("");const v=n.useCallback((x,m)=>{const s=[...P];s[x]=m;const d=s.join("");_?.(d),m&&x<H-1&&j.current[x+1]?.focus(),X&&d.length===H&&d.indexOf("")===-1&&O?.(d)},[P,H,_,O,X]),c=n.useCallback((x,m)=>{x.key==="Backspace"&&!P[m]&&m>0&&(j.current[m-1]?.focus(),v(m-1,"")),x.key==="ArrowLeft"&&m>0&&j.current[m-1]?.focus(),x.key==="ArrowRight"&&m<H-1&&j.current[m+1]?.focus()},[P,H,v]),D=n.useCallback(x=>{if(x==="clear"){_?.(""),j.current[0]?.focus();return}if(x==="backspace"){const m=K.slice(0,-1);_?.(m);const s=Math.max(0,m.length-1);j.current[s]?.focus();return}if(K.length<H){const m=K+x;_?.(m),m.length<H&&j.current[m.length]?.focus(),X&&m.length===H&&O?.(m)}},[K,H,_,O,X]);return G?null:e.jsxs("div",{ref:S,id:N,className:`nice-pin nice-size-${C}${$?" nice-pin--shake":""}${L?` ${L}`:""}${o?" nice-error":""}${l?" nice-disabled":""}`,style:z,children:[t&&e.jsxs("label",{className:"nice-pin__label",children:[t,r&&e.jsx("span",{className:"nice-required",children:"*"})]}),e.jsx("div",{className:"nice-pin__boxes",children:P.map((x,m)=>e.jsx("input",{ref:s=>{j.current[m]=s},className:"nice-pin__box",type:Z?"password":"text",inputMode:"numeric",maxLength:1,value:x,onChange:s=>{const d=s.target.value.replace(/\D/g,"");d.length<=1&&v(m,d)},onKeyDown:s=>c(s,m),disabled:l,readOnly:h,placeholder:w,"aria-label":`${y("digit","Digit")} ${m+1}`},m))}),F&&!h&&e.jsx("div",{className:"nice-pin__keypad",children:["1","2","3","4","5","6","7","8","9","clear","0","backspace"].map(x=>e.jsx("button",{type:"button",className:`nice-pin__key${x==="clear"||x==="backspace"?" nice-pin__key--action":""}`,onClick:()=>D(x),disabled:l,children:x==="clear"?"C":x==="backspace"?"⌫":x},x))}),i&&e.jsx("span",{className:"nice-helper-text",children:i}),o&&typeof o=="string"&&e.jsx("span",{className:"nice-error-text",children:o})]})});$n.displayName="NicePinCodeInput";exports.DEFAULT_ASPECT_RATIOS=mn;exports.EMOJI_DATA=nt;exports.GRADIENT_PRESETS=qt;exports.NICE_COLOR_PRESET_KEYS=Bn;exports.NiceAccountPicker=Sn;exports.NiceAddressInput=xn;exports.NiceCalendar=Jt;exports.NiceCodeDiffEditor=cn;exports.NiceCodeEditor=yt;exports.NiceCodeEditor$1=gi;exports.NiceCodeEditorAI=fi;exports.NiceColorPalette=Xt;exports.NiceContactPicker=_n;exports.NiceCropEditor=un;exports.NiceCurrencyInput=bn;exports.NiceDateRangeBox=Jn;exports.NiceDocumentEditor=yn;exports.NiceDropDownBox=Qn;exports.NiceEmojiPicker=dn;exports.NiceGradientPicker=Gt;exports.NiceHtmlEditor=ft;exports.NiceHtmlEditor$1=si;exports.NiceHtmlEditorAI=li;exports.NiceImageAnnotator=pn;exports.NiceImageEditor=gn;exports.NiceInputOtp=Zt;exports.NiceInvoiceLineEditor=vn;exports.NiceKnob=en;exports.NiceLookup=Wn;exports.NiceMarkdownEditor=hn;exports.NiceMention=tn;exports.NicePDFAnnotationEditor=kn;exports.NicePickList=sn;exports.NicePinCodeInput=$n;exports.NiceRangeSlider=Zn;exports.NiceScannerControl=Mn;exports.NiceSignature=yi;exports.NiceSignaturePad=fn;exports.NiceSimpleCodeEditor=ln;exports.NiceTaxRatePicker=Cn;exports.NiceTreeSelect=an;exports.NiceVatInput=Nn;exports.NiceWiki=wn;exports.applyPreset=tt;exports.contrastRatio=Qe;exports.cssToGradient=Vt;exports.generateHarmony=qe;exports.generateVariations=Kt;exports.gradientToCss=mt;exports.hexToHsv=Ae;exports.hexToRgb=Ge;exports.hsvToHex=Se;exports.hsvToRgb=Ft;exports.randomPalette=Ut;exports.rgbToHex=Ot;exports.rgbToHsl=Bt;exports.rgbToHsv=ht;exports.wcagLevel=et;