@nice2dev/ui 1.0.14 → 1.0.16

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 (67) hide show
  1. package/README.md +33 -39
  2. package/dist/NiceErrorBoundary-CH8SBcSZ.js +762 -0
  3. package/dist/NiceErrorBoundary-CKBaWmkn.js +762 -0
  4. package/dist/NiceErrorBoundary-CaVVPLh4.cjs +1 -0
  5. package/dist/NiceErrorBoundary-DBiUvzQs.cjs +1 -0
  6. package/dist/NiceForm-B5dMsHbO.js +5357 -0
  7. package/dist/NiceForm-Dbciuo4w.cjs +382 -0
  8. package/dist/NiceForm-DccuzkPX.cjs +382 -0
  9. package/dist/NiceForm-Jf-ufPZz.js +5357 -0
  10. package/dist/NiceModal-Bf1Q1VNL.cjs +1 -0
  11. package/dist/NiceModal-BxXotB3l.js +95 -0
  12. package/dist/NiceModal-DCA0wCuD.cjs +1 -0
  13. package/dist/NiceModal-DrywdSv3.js +95 -0
  14. package/dist/NiceModuleLifecyclePanel-CDX38sEx.js +6343 -0
  15. package/dist/NiceModuleLifecyclePanel-CEzuZnmj.cjs +1 -0
  16. package/dist/NiceModuleLifecyclePanel-D-dojncS.js +6349 -0
  17. package/dist/NiceModuleLifecyclePanel-xLrOv8nL.cjs +1 -0
  18. package/dist/NicePagination-1mgQ1T6J.cjs +1 -0
  19. package/dist/NicePagination-Aj63sKV3.js +171 -0
  20. package/dist/NicePagination-DNjVutBJ.cjs +1 -0
  21. package/dist/NicePagination-kFBRytja.js +171 -0
  22. package/dist/NicePinCodeInput-B_0RCKQN.cjs +419 -0
  23. package/dist/NicePinCodeInput-CPQhsGVC.js +11875 -0
  24. package/dist/NicePinCodeInput-DbeOo9o6.cjs +419 -0
  25. package/dist/NicePinCodeInput-Dffu701_.js +11875 -0
  26. package/dist/NiceSavedQueryPanel-4l-V9dGK.js +6446 -0
  27. package/dist/NiceSavedQueryPanel-B-EQ1oLv.cjs +596 -0
  28. package/dist/NiceSavedQueryPanel-B5TjD_Sb.cjs +596 -0
  29. package/dist/NiceSavedQueryPanel-D9Z3gF87.js +6446 -0
  30. package/dist/NiceTabs-BQgV3eKE.cjs +1 -0
  31. package/dist/NiceTabs-CaCiaBCQ.js +1624 -0
  32. package/dist/NiceTabs-CbKhMxbC.cjs +1 -0
  33. package/dist/NiceTabs-HXphGn1B.js +1624 -0
  34. package/dist/NiceWindow-Ceb0mZ_0.js +1409 -0
  35. package/dist/NiceWindow-Cn3e0Xtd.cjs +1 -0
  36. package/dist/NiceWindow-DXpnFZ0E.cjs +1 -0
  37. package/dist/NiceWindow-EXCwOEXz.js +1409 -0
  38. package/dist/charts-B6dTpbYV.cjs +761 -0
  39. package/dist/charts-BPJefcE8.js +4645 -0
  40. package/dist/charts-D5Qd_0sO.js +4645 -0
  41. package/dist/charts-Dr6QyMiv.cjs +761 -0
  42. package/dist/charts.cjs +1 -1
  43. package/dist/charts.mjs +1 -1
  44. package/dist/core-CtqcSgsw.js +22316 -0
  45. package/dist/core-DJ4NPp2B.js +22316 -0
  46. package/dist/core-DPY4m7vb.cjs +96 -0
  47. package/dist/core-oNMPbzb7.cjs +96 -0
  48. package/dist/data.cjs +1 -1
  49. package/dist/data.mjs +1 -1
  50. package/dist/editors.cjs +1 -1
  51. package/dist/editors.mjs +3 -3
  52. package/dist/feedback.cjs +1 -1
  53. package/dist/feedback.mjs +2 -2
  54. package/dist/index-B-9lbtwJ.cjs +5194 -0
  55. package/dist/index-BNy9Nn0X.js +61422 -0
  56. package/dist/index-DM6SBE8H.cjs +5194 -0
  57. package/dist/index-DqpmYrH_.js +61432 -0
  58. package/dist/index.cjs +1 -1
  59. package/dist/index.d.ts +69 -4
  60. package/dist/index.mjs +892 -890
  61. package/dist/lazy.cjs +1 -1
  62. package/dist/lazy.mjs +3 -3
  63. package/dist/navigation.cjs +1 -1
  64. package/dist/navigation.mjs +13 -13
  65. package/dist/overlays.cjs +1 -1
  66. package/dist/overlays.mjs +36 -36
  67. package/package.json +3 -3
@@ -0,0 +1,419 @@
1
+ "use strict";const e=require("react/jsx-runtime"),ne=require("./core-DPY4m7vb.cjs"),n=require("react"),xt=require("./NiceForm-Dbciuo4w.cjs"),fe=require("./NiceTabs-CbKhMxbC.cjs");function jt(t,i,o){return Math.max(i,Math.min(o,t))}function Ht({h:t,s:i,v:o}){t=(t%360+360)%360;const r=o*i,u=r*(1-Math.abs(t/60%2-1)),g=o-r;let S=0,w=0,L=0;return t<60?(S=r,w=u):t<120?(S=u,w=r):t<180?(w=r,L=u):t<240?(w=u,L=r):t<300?(S=u,L=r):(S=r,L=u),{r:Math.round((S+g)*255),g:Math.round((w+g)*255),b:Math.round((L+g)*255)}}function ht({r:t,g:i,b:o}){t/=255,i/=255,o/=255;const r=Math.max(t,i,o),u=Math.min(t,i,o),g=r-u;let S=0;return g!==0&&(r===t?S=(i-o)/g%6:r===i?S=(o-t)/g+2:S=(t-i)/g+4,S=(S*60+360)%360),{h:S,s:r===0?0:g/r,v:r}}function Ft({r:t,g:i,b:o}){t/=255,i/=255,o/=255;const r=Math.max(t,i,o),u=Math.min(t,i,o),g=(r+u)/2;if(r===u)return{h:0,s:0,l:g};const S=r-u,w=g>.5?S/(2-r-u):S/(r+u);let L=0;return r===t?L=((i-o)/S+(i<o?6:0))/6:r===i?L=((o-t)/S+2)/6:L=((t-i)/S+4)/6,{h:L*360,s:w,l:g}}function Oe(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 Bt({r:t,g:i,b:o}){return"#"+[t,i,o].map(r=>r.toString(16).padStart(2,"0")).join("")}function Ne(t){return Bt(Ht(t))}function He(t){return ht(Oe(t))}function Ot(t,i){const o=[];for(let r=0;r<i;r++){const u=i<=1?.5:r/(i-1),g=jt(t.s*(.3+u*.7),0,1),S=jt(t.v*(1.2-u*.7),0,1);o.push(Ne({h:t.h,s:g,v:S}))}return o}function gt(t,i){if(t==="custom")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]}}function Be(t,i,o){return gt(i,o).map(r=>((t+r)%360+360)%360)}function _t({r:t,g:i,b:o}){const[r,u,g]=[t,i,o].map(S=>{const w=S/255;return w<=.03928?w/12.92:Math.pow((w+.055)/1.055,2.4)});return .2126*r+.7152*u+.0722*g}function Xe(t,i){const o=_t(Oe(t)),r=_t(Oe(i)),u=Math.max(o,r),g=Math.min(o,r);return(u+.05)/(g+.05)}function qe(t){return t>=7?"AAA":t>=4.5?"AA":t>=3?"AA-lg":"Fail"}const Kt={"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 Ge(t,i){const o=Kt[i];return t.map(r=>{const u=(o.sRange[0]+o.sRange[1])/2,g=(o.vRange[0]+o.vRange[1])/2;return Ne({h:r,s:u,v:g})})}function Tn(){return Math.floor(Math.random()*360)}function Yt(t,i,o){const r=Tn(),u=Be(r,t,o),g=[];for(let S=0;S<i;S++){const w=u[S%u.length],L=.55+Math.random()*.4,H=.5+Math.random()*.45;g.push(Ne({h:w+(Math.random()-.5)*8,s:L,v:H}))}return g}const Rn=({hues:t,baseHue:i,onBaseHueChange:o,mode:r,distance:u,disabled:g})=>{const U=n.useCallback(B=>{if(g)return;const f=B.currentTarget.getBoundingClientRect(),k=B.clientX-f.left-120,C=B.clientY-f.top-120,$=(Math.atan2(C,k)*180/Math.PI+360)%360;o(Math.round($))},[120,120,g,o]),v=[];for(let B=0;B<360;B+=2){const q=(B-1)*Math.PI/180,f=(B+1)*Math.PI/180,k=Ne({h:B,s:1,v:1});v.push(e.jsx("path",{d:`M${120+55*Math.cos(q)},${120+55*Math.sin(q)} L${120+110*Math.cos(q)},${120+110*Math.sin(q)} 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(q)},${120+55*Math.sin(q)} Z`,fill:k},B))}const K=`wheel-center-${r}`,F=t.map((B,q)=>{const k=B*Math.PI/180;return e.jsx("circle",{cx:120+82.5*Math.cos(k),cy:120+82.5*Math.sin(k),r:q===0?8:6,fill:Ne({h:B,s:.85,v:.9}),stroke:q===0?"var(--bg-primary, #fff)":"var(--border-color, #ccc)",strokeWidth:q===0?3:2},q)});let te=null;if(r==="analogous"||r==="split-complementary"){const f=gt(r,u).slice(1).map((k,C)=>{const $=(i+k)*Math.PI/180;return e.jsx("line",{x1:120,y1:120,x2:120+82.5*Math.cos($),y2:120+82.5*Math.sin($),stroke:"var(--nice-overlay-light-30, rgba(255, 255, 255, 0.3))",strokeWidth:1,strokeDasharray:"3,3"},`dline-${C}`)});te=e.jsx(e.Fragment,{children:f})}return e.jsxs("svg",{className:"nice-palette__wheel",viewBox:"0 0 240 240",width:240,height:240,onClick:U,style:{cursor:g?"default":"crosshair"},children:[e.jsx("defs",{children:e.jsxs("radialGradient",{id:K,children:[e.jsx("stop",{offset:"0%",stopColor:"var(--nice-bg, #fff)"}),e.jsx("stop",{offset:"100%",stopColor:"transparent"})]})}),v,e.jsx("circle",{cx:120,cy:120,r:53,fill:Ne({h:i,s:.6,v:.85})}),e.jsx("circle",{cx:120,cy:120,r:53,fill:`url(#${K})`,opacity:.4}),te,F]})},In=({colors:t})=>{if(t.length<2)return null;const i=[];for(let o=0;o<t.length;o++){const r=Xe(t[o],"var(--bg-primary, #ffffff)"),u=Xe(t[o],"var(--text-primary, #000000)");i.push({a:t[o],b:"var(--bg-primary, #ffffff)",ratio:r,level:qe(r)}),i.push({a:t[o],b:"var(--text-primary, #000000)",ratio:u,level:qe(u)});for(let g=o+1;g<t.length;g++){const S=Xe(t[o],t[g]);i.push({a:t[o],b:t[g],ratio:S,level:qe(S)})}}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))})]})},An=({hex:t})=>{const i=Oe(t),o=Ft(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),"%"]})]})},vt={monochromatic:"Monochromatic",complementary:"Complementary","split-complementary":"Split-Complementary",analogous:"Analogous",triadic:"Triadic",tetradic:"Tetradic (Rectangle)",square:"Square",custom:"Custom"},Dn={"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"},Ln=["monochromatic","complementary","split-complementary","analogous","triadic","tetradic","square","custom"],zn=["lightest-pastel","bright-pastel","shiny","pastel","full","dark","deep","muted","earth"],Ut=n.forwardRef(({id:t,className:i,style:o,accessMode:r,value:u,onChange:g,minColors:S=1,maxColors:w=8,harmonyMode:L,onHarmonyModeChange:H,distance:Y,onDistanceChange:U,preset:v,onPresetChange:K,showWheel:F=!0,showContrast:te=!0,showInfo:B=!0,showPresets:q=!0,presets:f=[],showVariations:k=!0,showRandom:C=!0,variationCount:$=5,label:W,disabled:y},N)=>{const x=ne._s(r,t),M=x==="hidden";(x==="disabled"||x==="readOnly")&&(y=!0);const z=ne.ks(t),[P,_]=n.useState("analogous"),[d,A]=n.useState(30),[b,p]=n.useState(""),[a,m]=n.useState(0),l=L??P,c=Y??d,h=v??b,E=n.useCallback(V=>{_(V),H?.(V)},[H]),Q=n.useCallback(V=>{A(V),U?.(V)},[U]),D=n.useCallback(V=>{p(V),V&&K?.(V)},[K]),ee=n.useMemo(()=>["var(--color-primary, #3b82f6)","var(--color-error, #ef4444)","var(--color-success, #22c55e)"],[]),ae=u&&u.length>0?u:ee,O=ae[0],Z=n.useMemo(()=>He(O),[O]),ie=n.useMemo(()=>Be(Z.h,l,c),[Z.h,l,c]),de=n.useCallback((V,R,J,ge)=>{const be=Be(V,R,J);let ye;for(ge&&Kt[ge]?ye=Ge(be,ge):ye=be.map(je=>Ne({h:je,s:Z.s||.7,v:Z.v||.85}));ye.length<S;)ye.push(ye[ye.length-1]||"var(--nice-text-secondary, #888888)");ye.length>w&&(ye=ye.slice(0,w)),g?.(ye)},[Z.s,Z.v,S,w,g]),he=n.useCallback(V=>{if(!y){if(l==="custom"){const R=Ne({h:V,s:Z.s||.7,v:Z.v||.85}),J=[...ae];J[a]=R,g?.(J);return}de(V,l,c,h)}},[y,l,c,h,de,Z.s,Z.v,ae,a,g]),pe=n.useCallback(V=>{y||(E(V),V!=="custom"&&de(Z.h,V,c,h))},[y,Z.h,c,h,E,de]),xe=n.useCallback(V=>{y||(Q(V),de(Z.h,l,V,h))},[y,Z.h,l,h,Q,de]),ce=n.useCallback(V=>{if(y)return;D(V);const R=Be(Z.h,l,c),J=Ge(R,V);g?.(J.slice(0,w))},[y,Z.h,l,c,w,D,g]),le=n.useCallback((V,R)=>{if(y)return;const J=[...ae];J[V]=R,g?.(J)},[y,ae,g]),me=n.useCallback(()=>{if(y||ae.length>=w)return;const V=He(ae[ae.length-1]),R=Ne({h:(V.h+30)%360,s:V.s,v:V.v});g?.([...ae,R])},[y,ae,w,g]),oe=n.useCallback(V=>{if(y||ae.length<=S)return;const R=ae.filter((J,ge)=>ge!==V);g?.(R),a>=R.length&&m(Math.max(0,R.length-1))},[y,ae,S,g,a]),I=n.useCallback(()=>{if(y)return;const V=Math.max(S,Math.min(w,gt(l).length)),R=Yt(l,V,c);g?.(R)},[y,S,w,l,c,g]),j=n.useMemo(()=>{if(!k)return[];const V=ae[a]||ae[0];return Ot(He(V),$)},[k,ae,a,$]),X=ae[a]||ae[0],re=n.useMemo(()=>{const V=He(X);return Ne({h:(V.h+180)%360,s:V.s,v:V.v})},[X]);return M?null:e.jsxs("div",{ref:N,id:z,className:`nice-palette ${y?"nice-palette--disabled":""} ${i||""}`,style:o,children:[W&&e.jsx("div",{className:"nice-palette__label",children:W}),e.jsx("div",{className:"nice-palette__modes",children:Ln.map(V=>e.jsx("button",{type:"button",className:`nice-palette__mode-btn ${l===V?"nice-palette__mode-btn--active":""}`,onClick:()=>pe(V),disabled:y,title:vt[V],children:vt[V]},V))}),e.jsxs("div",{className:"nice-palette__main",children:[F&&e.jsxs("div",{className:"nice-palette__wheel-container",children:[e.jsx(Rn,{hues:ie,baseHue:Z.h,onBaseHueChange:he,mode:l,distance:c,disabled:y}),(l==="analogous"||l==="split-complementary")&&e.jsxs("div",{className:"nice-palette__distance",children:[e.jsxs("label",{children:["Distance: ",c,"°"]}),e.jsx("input",{type:"range",min:10,max:90,value:c,onChange:V=>xe(Number(V.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:[ae.map((V,R)=>e.jsxs("div",{className:`nice-palette__swatch-wrapper ${a===R?"nice-palette__swatch-wrapper--selected":""}`,onClick:()=>m(R),children:[e.jsx("div",{className:"nice-palette__swatch",style:{background:V},children:ae.length>S&&e.jsx("button",{type:"button",className:"nice-palette__swatch-remove",onClick:J=>{J.stopPropagation(),oe(R)},disabled:y,"aria-label":"Remove color",children:"×"})}),e.jsx("input",{type:"text",className:"nice-palette__hex-input",value:V.toUpperCase(),maxLength:7,disabled:y,onChange:J=>le(R,J.target.value)})]},R)),ae.length<w&&e.jsx("button",{type:"button",className:"nice-palette__add-btn",onClick:me,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:re},title:re.toUpperCase()}),e.jsx("span",{className:"nice-palette__hex-label",children:re.toUpperCase()})]}),k&&j.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:j.map((V,R)=>e.jsx("div",{className:"nice-palette__variation-chip",style:{background:V},title:V.toUpperCase(),onClick:()=>{y||le(a,V)},role:"button",tabIndex:0},R))})]}),C&&e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm nice-palette__random-btn",onClick:I,disabled:y,title:"Random palette","aria-label":"Random palette",children:"🎲 Random Palette"})]})]}),q&&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(V=>{const R=Ge(ie,V);return e.jsxs("button",{type:"button",className:`nice-palette__preset-card ${h===V?"nice-palette__preset-card--active":""}`,onClick:()=>ce(V),disabled:y,children:[e.jsx("div",{className:"nice-palette__preset-strip",children:R.map((J,ge)=>e.jsx("span",{className:"nice-palette__preset-dot",style:{background:J}},ge))}),e.jsx("span",{className:"nice-palette__preset-label",children:Dn[V]})]},V)})})]}),B&&e.jsxs("div",{className:"nice-palette__info-panel",children:[e.jsx("div",{className:"nice-palette__section-title",children:"Selected Color Info"}),e.jsx(An,{hex:X})]}),te&&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(In,{colors:ae})})]})]})});Ut.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,u)=>r.position-u.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",u=t.size||"farthest-corner",g=t.positionX??50,S=t.positionY??50;return`${o}radial-gradient(${r} ${u} at ${g}% ${S}%, ${i})`}case"conic":{const r=t.angle??0,u=t.positionX??50,g=t.positionY??50;return`${o}conic-gradient(from ${r}deg at ${u}% ${g}%, ${i})`}}}function Wt(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 u=r.split(",").map(H=>H.trim());let g=90,S=0;const w=u[0].match(/^(\d+)deg$/);w&&(g=parseInt(w[1]),S=1);const L=st(u.slice(S));return{type:"linear",angle:g,repeating:o,stops:L}}if(i.includes("radial-gradient")){const r=i.match(/radial-gradient\((.+)\)/)?.[1];if(!r)return null;const u=r.split(",").map(S=>S.trim()),g=st(u.filter(S=>S.includes("#")||S.includes("rgb")));return{type:"radial",angle:0,repeating:o,stops:g.length>=2?g:dt().stops}}if(i.includes("conic-gradient")){const r=i.match(/conic-gradient\((.+)\)/)?.[1];if(!r)return null;const u=r.split(",").map(S=>S.trim()),g=st(u.filter(S=>S.includes("#")||S.includes("rgb")));return{type:"conic",angle:0,repeating:o,stops:g.length>=2?g:dt().stops}}return null}function st(t){return t.map((i,o,r)=>{const u=i.match(/^(#[0-9a-fA-F]{3,8}|rgba?\([^)]+\))\s*(\d+%?)?$/);if(u){const g=u[2]?parseFloat(u[2]):o/Math.max(1,r.length-1)*100;return{color:u[1],position:g}}return{color:i,position:o/Math.max(1,r.length-1)*100}})}function Pn(){return"#"+Math.floor(Math.random()*16777215).toString(16).padStart(6,"0")}function Hn(t=2){const i=["linear","radial","conic"],o=i[Math.floor(Math.random()*i.length)],r=[];for(let u=0;u<t;u++)r.push({color:Pn(),position:Math.round(u/(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 Vt=[{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}}],Xt=n.forwardRef(({id:t,className:i,style:o,accessMode:r,value:u,onChange:g,showCssOutput:S=!0,showPresets:w=!0,showEditor:L=!0,showRandom:H=!0,maxStops:Y=10,label:U,disabled:v,width:K},F)=>{const te=ne._s(r,t),B=te==="hidden";(te==="disabled"||te==="readOnly")&&(v=!0);const q=ne.ks(t),f=u??dt(),k=n.useMemo(()=>mt(f),[f]),[C,$]=n.useState(0),[W,y]=n.useState(""),N=n.useRef(null),x=n.useCallback(c=>{g?.(c)},[g]),M=n.useCallback(c=>{v||x({...f,type:c})},[v,f,x]),z=n.useCallback(c=>{v||x({...f,angle:c})},[v,f,x]),P=n.useCallback(c=>{v||x({...f,repeating:c})},[v,f,x]),_=n.useCallback(c=>{v||x({...f,shape:c})},[v,f,x]),d=n.useCallback((c,h)=>{if(v)return;const E=f.stops.map((Q,D)=>D===c?{...Q,...h}:Q);x({...f,stops:E})},[v,f,x]),A=n.useCallback(()=>{if(v||f.stops.length>=Y)return;const c=f.stops.slice().sort((ee,ae)=>ee.position-ae.position);let h=0,E=c[0];for(let ee=0;ee<c.length-1;ee++){const ae=c[ee+1].position-c[ee].position;ae>h&&(h=ae,E=c[ee])}const Q=Math.round(E.position+h/2),D="#"+Math.floor(Math.random()*16777215).toString(16).padStart(6,"0");x({...f,stops:[...f.stops,{color:D,position:Q}]})},[v,f,Y,x]),b=n.useCallback(c=>{if(v||f.stops.length<=2)return;const h=f.stops.filter((E,Q)=>Q!==c);x({...f,stops:h}),C>=h.length&&$(h.length-1)},[v,f,C,x]),p=n.useCallback(()=>{if(v)return;const c=2+Math.floor(Math.random()*3);x(Hn(c))},[v,x]),a=n.useCallback(()=>{if(v||!W.trim())return;const c=Wt(W);c&&x(c)},[v,W,x]),m=n.useCallback(c=>{if(v||!N.current||f.stops.length>=Y)return;const h=N.current.getBoundingClientRect(),E=Math.round((c.clientX-h.left)/h.width*100),Q="#"+Math.floor(Math.random()*16777215).toString(16).padStart(6,"0"),D=[...f.stops,{color:Q,position:E}];x({...f,stops:D}),$(D.length-1)},[v,f,Y,x]),l=n.useMemo(()=>f.stops.slice().sort((c,h)=>c.position-h.position),[f.stops]);return B?null:e.jsxs("div",{ref:F,id:q,className:`nice-gradient ${v?"nice-gradient--disabled":""} ${i||""}`,style:{width:K!=null?typeof K=="number"?`${K}px`:K:320,boxSizing:"border-box",...o},children:[U&&e.jsx("div",{className:"nice-gradient__label",children:U}),e.jsx("div",{className:"nice-gradient__preview",style:{background:k}}),L&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"nice-gradient__type-row",children:[["linear","radial","conic"].map(c=>e.jsx("button",{type:"button",className:`nice-gradient__type-btn ${f.type===c?"nice-gradient__type-btn--active":""}`,onClick:()=>M(c),disabled:v,children:c.charAt(0).toUpperCase()+c.slice(1)},c)),e.jsxs("label",{className:"nice-gradient__repeat-label",children:[e.jsx("input",{type:"checkbox",checked:f.repeating??!1,onChange:c=>P(c.target.checked),disabled:v}),"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:c=>z(Number(c.target.value)),disabled:v,className:"nice-gradient__slider"}),e.jsx("div",{className:"nice-gradient__angle-presets",children:[0,45,90,135,180,225,270,315].map(c=>e.jsx("button",{type:"button",className:`nice-gradient__angle-btn ${f.angle===c?"nice-gradient__angle-btn--active":""}`,onClick:()=>z(c),disabled:v,title:`${c}°`,children:e.jsx("span",{style:{transform:`rotate(${c}deg)`,display:"inline-block"},children:"→"})},c))})]}),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(c=>e.jsx("button",{type:"button",className:`nice-gradient__shape-btn ${(f.shape||"ellipse")===c?"nice-gradient__shape-btn--active":""}`,onClick:()=>_(c),disabled:v,children:c},c))})]}),(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:c=>x({...f,positionX:Number(c.target.value)}),disabled:v,className:"nice-gradient__slider"}),e.jsx("input",{type:"range",min:0,max:100,value:f.positionY??50,onChange:c=>x({...f,positionY:Number(c.target.value)}),disabled:v,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:c=>z(Number(c.target.value)),disabled:v,className:"nice-gradient__slider"})]})]}),e.jsxs("div",{className:"nice-gradient__bar-container",children:[e.jsx("div",{ref:N,className:"nice-gradient__bar",style:{background:k},onClick:m,children:f.stops.map((c,h)=>e.jsx("div",{className:`nice-gradient__stop-marker ${C===h?"nice-gradient__stop-marker--active":""}`,style:{left:`${c.position}%`},onClick:E=>{E.stopPropagation(),$(h)},title:`${c.color} @ ${c.position}%`,children:e.jsx("div",{className:"nice-gradient__stop-dot",style:{background:c.color}})},h))}),e.jsx("button",{type:"button",className:"nice-gradient__add-stop",onClick:A,disabled:v||f.stops.length>=Y,title:"Add stop",children:"+"})]}),e.jsx("div",{className:"nice-gradient__stop-editor",children:e.jsx("div",{className:"nice-gradient__stop-list",children:l.map((c,h)=>{const E=f.stops.indexOf(c);return e.jsxs("div",{className:`nice-gradient__stop-row ${C===E?"nice-gradient__stop-row--active":""}`,onClick:()=>$(E),children:[e.jsx("input",{type:"color",value:c.color,onChange:Q=>d(E,{color:Q.target.value}),disabled:v,className:"nice-gradient__stop-color"}),e.jsx("input",{type:"text",value:c.color.toUpperCase(),maxLength:7,onChange:Q=>d(E,{color:Q.target.value}),disabled:v,className:"nice-gradient__stop-hex"}),e.jsx("input",{type:"number",min:0,max:100,value:c.position,onChange:Q=>d(E,{position:Number(Q.target.value)}),disabled:v,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:()=>b(E),disabled:v,"aria-label":"Remove stop",children:"×"})]},E)})})})]}),H&&e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm nice-gradient__random-btn",onClick:p,disabled:v,title:"Random gradient","aria-label":"Random gradient",children:"🎲 Random Gradient"}),w&&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:Vt.map((c,h)=>e.jsxs("button",{type:"button",className:"nice-gradient__preset-card",onClick:()=>{v||x(c.value)},disabled:v,title:c.name,children:[e.jsx("div",{className:"nice-gradient__preset-preview",style:{background:mt(c.value)}}),e.jsx("span",{className:"nice-gradient__preset-name",children:c.name})]},h))})]}),S&&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: ${k};`}),e.jsx("button",{type:"button",className:"nice-gradient__copy-btn",onClick:()=>navigator.clipboard?.writeText(`background: ${k};`),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:W,onChange:c=>y(c.target.value),disabled:v}),e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm",onClick:a,disabled:v,children:"Import"})]})]})]})});Xt.displayName="NiceGradientPicker";const Fn=({options:t,value:i,onChange:o,searchable:r=!0,clearable:u,loading:g,placeholder:S,label:w,error:L,helperText:H,required:Y,disabled:U,size:v="md",id:K,className:F,style:te,data:B,columns:q,valueField:f="id",displayField:k,dropdownWidth:C,controlWidth:$})=>{const W=ne.ks(K),{t:y}=ne.$o(),[N,x]=n.useState(!1),[M,z]=n.useState(""),P=n.useRef(null);ne.Cs(P,()=>x(!1));const _=!!(B&&q&&q.length>0),d=k??(q&&q[0]?.key),A=n.useMemo(()=>!_||!B?[]:B.map(l=>({value:String(l[f]??""),label:d?String(l[d]??""):""})),[_,B,f,d]),b=_?A:t??[],p=b.find(l=>String(l.value)===i),a=n.useMemo(()=>{if(!_||!B)return[];if(!M)return B;const l=M.toLowerCase();return B.filter(c=>q.some(h=>String(c[h.key]??"").toLowerCase().includes(l)))},[_,B,q,M]),m=n.useMemo(()=>{if(_||!M)return b;const l=M.toLowerCase();return b.filter(c=>c.label.toLowerCase().includes(l))},[b,M,_]);return e.jsxs("div",{className:`nice-field nice-field--${v} ${L?"nice-field--error":""} ${F||""}`,style:{width:$!=null?typeof $=="number"?`${$}px`:$:"fit-content",...te},ref:P,children:[w&&e.jsxs("label",{className:"nice-field__label",htmlFor:W,children:[w,Y&&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:W,className:"nice-select__trigger",onClick:()=>!U&&x(!N),disabled:U,children:[e.jsx("span",{children:p?.label||S||y("controls.select","Select...")}),e.jsx("span",{className:"nice-select__arrow",children:"▾"})]}),u&&i&&!U&&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:C!=null?typeof C=="number"?`${C}px`:C:_?"max-content":"100%"},children:[r&&e.jsx("div",{className:"nice-dropdown__search",style:{padding:6},children:e.jsx("input",{type:"text",value:M,onChange:l=>z(l.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)"}})}),_?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:q.map(l=>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:l.width!=null?typeof l.width=="number"?`${l.width}px`:l.width:void 0},children:l.header},l.key))})}),e.jsx("tbody",{children:a.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:q.length,style:{padding:12,textAlign:"center",color:"var(--text-muted)"},children:y("controls.noResults","No results")})}):a.map(l=>{const c=String(l[f]??""),h=c===i;return e.jsx("tr",{role:"option","aria-selected":h,onClick:()=>{o(c),x(!1),z("")},style:{cursor:"pointer",background:h?"var(--hover-bg)":"transparent"},onMouseEnter:E=>{h||(E.currentTarget.style.background="var(--hover-bg)")},onMouseLeave:E=>{h||(E.currentTarget.style.background="transparent")},children:q.map(E=>e.jsx("td",{style:{padding:"6px 10px",fontSize:13,borderBottom:"1px solid var(--border-color)"},children:String(l[E.key]??"")},E.key))},c)})})]}):e.jsx("ul",{className:"nice-dropdown__list",role:"listbox",style:{listStyle:"none",margin:0,padding:4,maxHeight:240,overflowY:"auto"},children:m.length===0?e.jsx("li",{className:"nice-dropdown__empty",style:{padding:8,color:"var(--text-muted)"},children:y("controls.noResults","No results")}):m.map(l=>e.jsx("li",{role:"option",className:`nice-dropdown__option ${String(l.value)===i?"nice-dropdown__option--selected":""}`,onClick:()=>{o(String(l.value)),x(!1),z("")},"aria-selected":String(l.value)===i,children:l.label},String(l.value)))})]})]}),L&&e.jsx("div",{className:"nice-field__error",children:L}),H&&!L&&e.jsx("div",{className:"nice-field__hint",children:H})]})},Bn=["Su","Mo","Tu","We","Th","Fr","Sa"];function On(t,i){return new Date(t,i+1,0).getDate()}function Kn(t,i){return new Date(t,i,1).getDay()}function kt(t,i,o){return`${t}-${String(i+1).padStart(2,"0")}-${String(o).padStart(2,"0")}`}function Yn(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 wt=["January","February","March","April","May","June","July","August","September","October","November","December"],qt=({value:t,onChange:i,min:o,max:r,disabledDates:u=[],firstDayOfWeek:g=1,size:S="md",showWeekNumbers:w,onMonthChange:L,className:H,style:Y,accessMode:U,id:v,multiple:K,selectedDates:F=[],onSelectedDatesChange:te,renderDay:B,showKeyboardHints:q,persistPreferences:f=!1,fullWidth:k=!1,cookies:C=!1,localStorage:$=!0,sessionStorage:W=!1,storageMode:y,storageKey:N})=>{const x=ne._s(U,v),M=x==="hidden",z=x==="disabled"||x==="readOnly",{t:P}=ne.$o(),_=new Date,d=t?new Date(t):_,A=ne.useStorageAdapter(N??"nice-calendar"),b=n.useMemo(()=>f?A.get("prefs")??{}:{},[f,A]),p=b.firstDayOfWeek??g,[a,m]=n.useState(b.lastViewYear??d.getFullYear()),[l,c]=n.useState(b.lastViewMonth??d.getMonth()),[h,E]=n.useState(b.preferredView??"days"),Q=n.useCallback(R=>{if(!f)return;const J=A.get("prefs")??{};A.set("prefs",{...J,...R})},[f,A]),D=n.useCallback(R=>{E(R),Q({preferredView:R})},[Q]),ee=n.useCallback((R,J)=>{Q({lastViewYear:R,lastViewMonth:J})},[Q]),ae=n.useMemo(()=>[ne.rc.moveUp,ne.rc.moveDown,ne.rc.moveLeft,ne.rc.moveRight,{key:"Enter",description:P("shortcuts.selectDate","Select date")},ne.rc.pageUp,ne.rc.pageDown],[P]),O=n.useMemo(()=>On(a,l),[a,l]),Z=n.useMemo(()=>(Kn(a,l)-p+7)%7,[a,l,p]),ie=n.useMemo(()=>{const R=[...Bn];for(let J=0;J<p;J++)R.push(R.shift());return R},[p]),de=n.useCallback(R=>o&&R<o||r&&R>r?!0:u.includes(R),[o,r,u]),he=n.useCallback(R=>{if(h==="years"){m(be=>be+R*10);return}if(h==="months"){m(be=>be+R);return}let J=l+R,ge=a;J<0&&(J=11,ge--),J>11&&(J=0,ge++),c(J),m(ge),ee(ge,J),L?.(ge,J)},[l,a,L,h,ee]),pe=kt(_.getFullYear(),_.getMonth(),_.getDate()),xe=n.useCallback(R=>K?F.includes(R):R===t,[K,F,t]),ce=n.useCallback(R=>{if(!z){if(K){const J=F.includes(R)?F.filter(ge=>ge!==R):[...F,R];te?.(J)}i?.(R)}},[K,F,i,te]),le=n.useCallback(()=>{h==="days"?D("months"):h==="months"&&D("years")},[h,D]),me=n.useCallback(R=>{c(R),D("days"),ee(a,R),L?.(a,R)},[a,L,D,ee]),oe=n.useCallback(R=>{m(R),D("months")},[D]),I=h==="years"?`${a-a%10} – ${a-a%10+9}`:h==="months"?`${a}`:`${wt[l]} ${a}`,j=h==="years"?"decade":h==="months"?"year":"month",X=[];for(let R=0;R<Z;R++)X.push(null);for(let R=1;R<=O;R++)X.push(R);for(;X.length%7!==0;)X.push(null);const re=[];for(let R=0;R<X.length;R+=7)re.push(X.slice(R,R+7));const V=a-a%10;return M?null:e.jsxs("div",{className:`nice-calendar nice-calendar--${S}${k?" nice-calendar--full-width":""} ${H||""}`,style:Y,children:[e.jsxs("div",{className:"nice-calendar__header",children:[e.jsx("button",{type:"button",className:"nice-calendar__nav",onClick:()=>he(-1),"aria-label":`Previous ${j}`,children:"‹"}),e.jsx("button",{type:"button",className:"nice-calendar__title",onClick:le,"aria-label":h==="days"?"Show month picker":h==="months"?"Show year picker":void 0,disabled:h==="years",children:I}),e.jsx("button",{type:"button",className:"nice-calendar__nav",onClick:()=>he(1),"aria-label":`Next ${j}`,children:"›"}),q&&e.jsx(ne.Vr,{shortcuts:ae,size:"sm"})]}),h==="days"&&e.jsxs("table",{className:"nice-calendar__grid",role:"grid",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[w&&e.jsx("th",{className:"nice-calendar__wk",children:"W"}),ie.map(R=>e.jsx("th",{children:R},R))]})}),e.jsx("tbody",{children:re.map((R,J)=>e.jsxs("tr",{children:[w&&e.jsx("td",{className:"nice-calendar__wk",children:R.find(ge=>ge!=null)?Yn(new Date(a,l,R.find(ge=>ge!=null))):""}),R.map((ge,be)=>{if(ge==null)return e.jsx("td",{className:"nice-calendar__empty-cell"},be);const ye=kt(a,l,ge),je=de(ye),Ee=xe(ye),Ae=ye===pe;return e.jsx("td",{className:`nice-calendar__day${Ee?" nice-calendar__day--selected":""}${Ae?" nice-calendar__day--today":""}${je?" nice-calendar__day--disabled":""}`,onClick:()=>!je&&ce(ye),role:"gridcell","aria-selected":Ee,"aria-disabled":je,children:B?B(ye,ge):ge},be)})]},J))})]}),h==="months"&&e.jsx("div",{className:"nice-calendar__picker-grid",children:wt.map((R,J)=>e.jsx("button",{type:"button",className:`nice-calendar__picker-cell${J===l&&a===d.getFullYear()?" nice-calendar__picker-cell--selected":""}`,onClick:()=>me(J),children:R.slice(0,3)},J))}),h==="years"&&e.jsx("div",{className:"nice-calendar__picker-grid",children:Array.from({length:12},(R,J)=>V-1+J).map(R=>e.jsx("button",{type:"button",className:`nice-calendar__picker-cell${R===a?" nice-calendar__picker-cell--selected":""}${R<V||R>V+9?" nice-calendar__picker-cell--other":""}`,onClick:()=>oe(R),children:R},R))})]})};qt.displayName="NiceCalendar";const Un=({startDate:t,endDate:i,onStartChange:o,onEndChange:r,min:u,max:g,clearable:S,startPlaceholder:w,endPlaceholder:L,startLabel:H,endLabel:Y,layout:U="horizontal",separator:v="–",gap:K=12,fullWidth:F=!1,label:te,error:B,helperText:q,required:f,disabled:k,size:C="md",id:$,className:W,style:y,accessMode:N,showKeyboardHints:x,labelPlacement:M,errorPlacement:z,labelWidth:P,controlWidth:_,loading:d})=>{const A=ne._s(N,$),b=ne.ks($),{t:p}=ne.$o(),a=A==="disabled"||A==="readOnly"||!!k,m=n.useMemo(()=>[{key:"Tab",description:p("shortcuts.switchField","Switch between start/end")},ne.rc.cancel],[p]);if(A==="hidden")return null;const l=h=>{o(h),h&&i&&h>i&&r(h)},c=U==="horizontal";return e.jsxs("div",{className:`nice-field nice-field--${C} nice-daterange nice-daterange--${U} ${M==="left"?"nice-field--label-left":""} ${B?"nice-field--error":""} ${d?"nice-field--loading":""} ${W||""}`,style:{...y,...P!=null&&{"--nice-field-label-width":typeof P=="number"?`${P}px`:P},..._!=null&&{"--nice-field-control-width":typeof _=="number"?`${_}px`:_}},"aria-busy":d||void 0,children:[te&&e.jsxs("label",{className:"nice-field__label",htmlFor:b,children:[te,f&&e.jsx("span",{className:"nice-field__required",children:"*"}),x&&e.jsx(ne.Vr,{shortcuts:m,size:"sm"})]}),e.jsxs("div",{className:"nice-field__control",children:[e.jsxs("div",{className:"nice-daterange__row",style:{display:"flex",flexDirection:c?"row":"column",alignItems:c?"flex-end":"stretch",gap:K,flexWrap:"wrap"},children:[e.jsx("div",{style:{flex:F?"1 1 0":void 0,minWidth:0},children:e.jsx(xt.NiceDatePicker,{id:b,label:H,value:t,onChange:l,min:u,max:i||g,placeholder:w||p("controls.startDate","Start date"),disabled:a,size:C,clearable:S,labelPlacement:M,labelWidth:P})}),c&&v!==""&&v!=null&&e.jsx("span",{className:"nice-daterange__separator",style:{paddingBottom:8,color:"var(--text-secondary, #666)"},"aria-hidden":"true",children:v}),e.jsx("div",{style:{flex:F?"1 1 0":void 0,minWidth:0},children:e.jsx(xt.NiceDatePicker,{label:Y,value:i,onChange:r,min:t||u,max:g,placeholder:L||p("controls.endDate","End date"),disabled:a,size:C,clearable:S,labelPlacement:M,labelWidth:P})})]}),d&&e.jsx("span",{className:"nice-field__spinner",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})}),z==="right"&&B&&e.jsx("div",{className:"nice-field__error",role:"alert",children:B}),z==="right"&&!B&&q&&e.jsx("div",{className:"nice-field__helper",children:q})]}),z!=="right"&&B&&e.jsx("div",{className:"nice-field__error",children:B}),z!=="right"&&!B&&q&&e.jsx("div",{className:"nice-field__hint",children:q})]})},Wn=({min:t=0,max:i=100,step:o=1,startValue:r,endValue:u,onChange:g,showLabels:S=!0,formatLabel:w,valuePlacement:L="none",label:H,error:Y,helperText:U,required:v,disabled:K,readOnly:F,loading:te,size:B="md",id:q,className:f,style:k,accessMode:C,showKeyboardHints:$,labelPlacement:W,errorPlacement:y,labelWidth:N,controlWidth:x})=>{const M=ne._s(C,q),z=M==="hidden";(M==="disabled"||M==="readOnly")&&(K=!0);const{t:P}=ne.$o(),_=ne.ks(q),d=n.useRef(null),A=n.useMemo(()=>[ne.rc.increment,ne.rc.decrement,ne.rc.first,ne.rc.last,{key:"Tab",description:P("shortcuts.switchThumb","Switch thumb")}],[P]),b=l=>(l-t)/(i-t)*100,p=l=>w?w(l):String(l),a=l=>{const c=Math.round(l/o)*o;return Math.max(t,Math.min(i,c))},m=n.useCallback((l,c)=>{l.preventDefault();const h=d.current;if(!h||K)return;const E=D=>{const ee=h.getBoundingClientRect(),ae=Math.max(0,Math.min(1,(D.clientX-ee.left)/ee.width)),O=a(t+ae*(i-t));c==="start"?g(Math.min(O,u),u):g(r,Math.max(O,r))},Q=()=>{document.removeEventListener("pointermove",E),document.removeEventListener("pointerup",Q)};document.addEventListener("pointermove",E),document.addEventListener("pointerup",Q)},[t,i,o,r,u,g,K]);return z?null:e.jsxs("div",{className:`nice-field nice-field--${B} nice-field--rangeslider ${W==="left"?"nice-field--label-left":""} ${y==="right"?"nice-field--error-right":""} ${Y?"nice-field--error":""} ${te?"nice-field--loading":""} ${f||""}`,style:{...k,...N!=null&&{"--nice-field-label-width":typeof N=="number"?`${N}px`:N},...x!=null&&{"--nice-field-control-width":typeof x=="number"?`${x}px`:x}},"aria-busy":te||void 0,children:[H&&e.jsxs("label",{className:"nice-field__label nice-field__label--with-value",htmlFor:_,children:[e.jsxs("span",{className:"nice-field__label-text",children:[H,v&&e.jsx("span",{className:"nice-field__required",children:"*"}),$&&e.jsx(ne.Vr,{shortcuts:A,size:"sm"})]}),L==="right"&&e.jsxs("span",{className:"nice-range-slider__value nice-range-slider__value--inline",children:[p(r)," – ",p(u)]})]}),e.jsxs("div",{className:"nice-field__control",children:[L==="right"&&!H&&e.jsxs("span",{className:"nice-range-slider__value",children:[p(r)," – ",p(u)]}),e.jsxs("div",{className:"nice-range-slider__stack",children:[e.jsxs("div",{className:`nice-range-slider ${S?"nice-range-slider--with-labels":""} ${H?"nice-range-slider--has-field-label":""}`,ref:d,children:[e.jsx("div",{className:"nice-range-slider__track",children:e.jsx("div",{className:"nice-range-slider__fill",style:{left:`${b(r)}%`,width:`${b(u)-b(r)}%`}})}),e.jsx("div",{className:"nice-range-slider__thumb",style:{left:`${b(r)}%`},onPointerDown:l=>F?void 0:m(l,"start"),role:"slider","aria-valuemin":t,"aria-valuemax":u,"aria-valuenow":r,tabIndex:K?-1:0,id:_}),e.jsx("div",{className:"nice-range-slider__thumb",style:{left:`${b(u)}%`},onPointerDown:l=>F?void 0:m(l,"end"),role:"slider","aria-valuemin":r,"aria-valuemax":i,"aria-valuenow":u,tabIndex:K?-1:0})]}),S&&e.jsxs("div",{className:"nice-range-slider__values",children:[e.jsx("span",{className:"nice-range-slider__values-start",style:{left:`${b(r)}%`},children:p(r)}),e.jsx("span",{className:"nice-range-slider__values-end",style:{left:`${b(u)}%`},children:p(u)})]}),L==="bottom"&&e.jsxs("div",{className:"nice-range-slider__value nice-range-slider__value--bottom",children:[p(r)," – ",p(u)]})]}),te&&e.jsx("span",{className:"nice-field__spinner",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})}),y==="right"&&Y&&e.jsx("div",{className:"nice-field__error",role:"alert",children:Y}),y==="right"&&!Y&&U&&e.jsx("div",{className:"nice-field__helper",children:U})]}),y!=="right"&&Y&&e.jsx("div",{className:"nice-field__error",role:"alert",children:Y}),y!=="right"&&!Y&&U&&e.jsx("div",{className:"nice-field__helper",children:U})]})},Vn=({displayValue:t,placeholder:i,clearable:o,children:r,onClear:u,open:g,onOpenChange:S,dropdownWidth:w,label:L,error:H,helperText:Y,required:U,disabled:v,size:K="md",id:F,className:te,style:B,accessMode:q,showKeyboardHints:f,displayStyle:k})=>{ne.cs("input",k),ne.ls("input",k);const C=ne._s(q,F),$=C==="hidden";(C==="disabled"||C==="readOnly")&&(v=!0);const W=ne.ks(F),{t:y}=ne.$o(),[N,x]=n.useState(!1),M=n.useRef(null),z=g??N,P=n.useMemo(()=>[{key:"Enter",description:y("shortcuts.openDropdown","Open dropdown")},ne.rc.cancel],[y]),_=d=>{S?S(d):x(d)};return ne.Cs(M,()=>_(!1)),$?null:e.jsxs("div",{className:`nice-field nice-field--${K} ${H?"nice-field--error":""} ${te||""}`,style:B,ref:M,children:[L&&e.jsxs("label",{className:"nice-field__label",htmlFor:W,children:[L,U&&e.jsx("span",{className:"nice-field__required",children:"*"}),f&&e.jsx(ne.Vr,{shortcuts:P,size:"sm"})]}),e.jsxs("div",{className:"nice-field__input-wrap",children:[e.jsxs("button",{type:"button",id:W,className:"nice-select__trigger",onClick:()=>!v&&_(!z),disabled:v,children:[e.jsx("span",{children:t||i||y("controls.select","Select...")}),e.jsx("span",{className:"nice-select__arrow",children:"▾"})]}),o&&t&&!v&&e.jsx("button",{type:"button",className:"nice-field__clear",onClick:()=>u?.(),"aria-label":y("controls.clear","Clear"),children:"✕"})]}),z&&e.jsx("div",{className:"nice-dropdown",style:{width:w},children:r}),H&&e.jsx("div",{className:"nice-field__error",children:H}),Y&&!H&&e.jsx("div",{className:"nice-field__hint",children:Y})]})};function Nt(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 Xn=["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"],_e=({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})}),qn={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(_e,{d:"M8 6h13M8 12h13M8 18h13M3 6h.01M3 12h.01M3 18h.01"}),ol:e.jsx(_e,{d:"M10 6h11M10 12h11M10 18h11M4 6h1v4M4 10h2M6 18H4c0-1 2-2 2-3s-1-1.5-2-1"}),link:e.jsx(_e,{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(_e,{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(_e,{d:"M3 7v6h6M3 13a9 9 0 1 0 3-7.7L3 13"}),redo:e.jsx(_e,{d:"M21 7v6h-6M21 13a9 9 0 1 1-3-7.7L21 13"}),clear:e.jsx(_e,{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(_e,{d:"M3 3h18v18H3zM3 9h18M3 15h18M9 3v18M15 3v18"}),image:e.jsx(_e,{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(_e,{d:"M16 18l6-6-6-6M8 6l-6 6 6 6"}),markdown:"MD",blockquote:e.jsx(_e,{d:"M3 21c3-3 3-9 0-12M21 21c-3-3-3-9 0-12M9 7h6v6H9zM15 7h6v6h-6z"}),hr:e.jsx(_e,{d:"M5 12h14"}),subscript:"X₂",superscript:"X²",indent:e.jsx(_e,{d:"M3 8l4 4-4 4M7 6h14M7 12h14M3 18h18"}),outdent:e.jsx(_e,{d:"M7 8l-4 4 4 4M21 6H3M21 12H7M21 18H3"}),alignLeft:e.jsx(_e,{d:"M3 6h18M3 12h12M3 18h18"}),alignCenter:e.jsx(_e,{d:"M3 6h18M6 12h12M3 18h18"}),alignRight:e.jsx(_e,{d:"M3 6h18M9 12h12M3 18h18"}),alignJustify:e.jsx(_e,{d:"M3 6h18M3 12h18M3 18h18"}),fullscreen:e.jsx(_e,{d:"M3 9V3h6M21 9V3h-6M3 15v6h6M21 15v6h-6"}),removeFormat:e.jsx(_e,{d:"M4 7V4h16v3M5 20h6M13 4 8 20"}),print:e.jsx(_e,{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(_e,{d:"M16 18l6-6-6-6M8 6l-6 6 6 6"}),emoji:e.jsx(_e,{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(_e,{d:"M11 19a8 8 0 1 1 0-16 8 8 0 0 1 0 16zM21 21l-4.35-4.35"}),fontSize:e.jsx(_e,{d:"M4 7V4h16v3M9 20h6M12 4v16"}),fontColor:e.jsx(_e,{d:"M4 21h16M5 17l7-12 7 12M8 13h8"})},Gn=[{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"}],Qn=[{label:"Faces",emojis:["??","??","??","??","??","??","??","??","??","??","??","??"]},{label:"Hands",emojis:["??","??","??","??","??","??","??","??","??","??"]},{label:"Symbols",emojis:["??","?","??","?","?","?","??","??","??","??","??","??"]},{label:"Arrows",emojis:["??","??","??","??","??","??","??","??","??","?"]}];function Zn(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 Jn(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:u=Xn,readOnly:g,onImageUpload:S,mentionTrigger:w,mentionSuggestions:L,onMentionSearch:H,onFileDrop:Y,pasteCleanup:U=!0,maxLength:v=0,showWordCount:K=!1,templates:F,label:te,error:B,helperText:q,required:f,disabled:k,size:C="md",id:$,className:W,style:y,accessMode:N})=>{const x=ne._s(N,$),M=x==="hidden";x==="disabled"&&(k=!0),x==="readOnly"&&(g=!0);const z=ne.ks($),P=n.useRef(null),_=n.useRef(null),d=n.useRef(null),[A,b]=n.useState(!1),[p,a]=n.useState(""),[m,l]=n.useState(!1),[c,h]=n.useState(""),[E,Q]=n.useState(!1),[D,ee]=n.useState(""),[ae,O]=n.useState(0),[Z,ie]=n.useState(!1),[de,he]=n.useState("var(--nice-text, #000000)"),[pe,xe]=n.useState("var(--nice-warning, #ffff00)"),[ce,le]=n.useState(0),[me,oe]=n.useState(0),[I,j]=n.useState(!1),[X,re]=n.useState(""),[V,R]=n.useState(""),[J,ge]=n.useState(!1),[be,ye]=n.useState(!1),je=n.useCallback((s,T)=>{if(g||k)return;const G=P.current;if(G){if(s==="markdown"){if(!A)a(Zn(t)),b(!0),l(!1);else{const se=Jn(p);i(se),b(!1)}return}if(s==="source"){m?(i(c),l(!1)):(h(t),l(!0),b(!1));return}if(s==="fullscreen"){ie(se=>!se);return}if(s==="emoji"){ge(se=>!se);return}if(s==="findReplace"){j(se=>!se);return}if(s==="image"){if(S)_.current?.click();else{const se=prompt("Image URL:");se&&Nt(se)&&(G.focus(),document.execCommand("insertImage",!1,se),i(ne.gs(G.innerHTML)))}return}switch(G.focus(),s){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&&Nt(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 ue=window.getSelection()?.toString()||"";ue.includes(`
10
+ `)||ue.length>60?document.execCommand("insertHTML",!1,`<pre class="nice-htmleditor__code-block">${ue||"// code"}</pre>`):document.execCommand("insertHTML",!1,`<code>${ue||"code"}</code>`);break}}i(ne.gs(G.innerHTML)),le(G.textContent?.length??0)}},[i,g,k,A,p,t,S,m,c]),Ee=n.useCallback(async s=>{const T=s.target.files?.[0];if(!T||!S)return;const G=await S(T),se=P.current;se&&G&&(se.focus(),document.execCommand("insertImage",!1,G),i(se.innerHTML)),s.target.value=""},[S,i]),Ae=n.useCallback(()=>{const s=P.current;if(!s)return;const T=s.textContent?.length??0;if(v>0&&T>v&&(s.textContent=(s.textContent??"").slice(0,v)),le(T),oe((s.textContent??"").trim().split(/\s+/).filter(Boolean).length),i(s.innerHTML),w){const G=window.getSelection();if(G&&G.rangeCount>0){const se=G.getRangeAt(0),ue=se.startContainer;if(ue.nodeType===Node.TEXT_NODE){const ke=ue.textContent||"",we=se.startOffset,Ue=ke.slice(0,we),$e=Ue.lastIndexOf(w);if($e>=0&&($e===0||/\s/.test(Ue[$e-1]))){const Le=Ue.slice($e+w.length);if(!/\s/.test(Le)){Q(!0),ee(Le),O(0),H?.(Le);return}}}}Q(!1)}},[i,w,H]),Se=L?.filter(s=>s.label.toLowerCase().includes(D.toLowerCase())).slice(0,8)??[],De=n.useCallback(s=>{const T=P.current;if(!T)return;const G=window.getSelection();if(!G||G.rangeCount===0)return;const se=G.getRangeAt(0),ue=se.startContainer;if(ue.nodeType===Node.TEXT_NODE&&w){const ke=ue.textContent||"",we=se.startOffset,$e=ke.slice(0,we).lastIndexOf(w);if($e>=0){const Le=ke.slice(0,$e),$n=ke.slice(we),Mn=`<span class="nice-htmleditor__mention" data-mention="${s.key}" contenteditable="false">${w}${s.label}</span>&nbsp;`;ue.textContent=Le;const at=document.createRange();at.setStartAfter(ue),at.collapse(!0);const En=at.createContextualFragment(Mn+$n);ue.parentNode?.insertBefore(En,ue.nextSibling),G.collapseToEnd(),i(T.innerHTML)}}Q(!1)},[w,i]),et=n.useCallback(s=>{if(E&&Se.length>0){s.key==="ArrowDown"?(s.preventDefault(),O(T=>Math.min(T+1,Se.length-1))):s.key==="ArrowUp"?(s.preventDefault(),O(T=>Math.max(T-1,0))):s.key==="Enter"?(s.preventDefault(),De(Se[ae])):s.key==="Escape"&&Q(!1);return}(s.ctrlKey||s.metaKey)&&s.key==="b"?(s.preventDefault(),je("bold")):(s.ctrlKey||s.metaKey)&&s.key==="i"?(s.preventDefault(),je("italic")):(s.ctrlKey||s.metaKey)&&s.key==="u"?(s.preventDefault(),je("underline")):(s.ctrlKey||s.metaKey)&&s.key==="f"?(s.preventDefault(),j(T=>!T)):(s.ctrlKey||s.metaKey)&&s.key==="z"&&!s.shiftKey?(s.preventDefault(),je("undo")):(s.ctrlKey||s.metaKey)&&(s.key==="y"||s.key==="z"&&s.shiftKey)&&(s.preventDefault(),je("redo"))},[E,Se,ae,De,je]),tt=n.useCallback(s=>{if(!U)return;s.preventDefault();const T=s.clipboardData.getData("text/html"),G=s.clipboardData.getData("text/plain");if(T){const ue=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,ue)}else G&&document.execCommand("insertText",!1,G);const se=P.current;se&&(i(se.innerHTML),le(se.textContent?.length??0))},[U,i]),nt=n.useCallback(async s=>{if(!Y)return;s.preventDefault();const T=Array.from(s.dataTransfer.files);if(T.length===0)return;const G=await Y(T),se=P.current;if(se){se.focus();for(const ue of G)if(/\.(png|jpe?g|gif|webp|svg|bmp|ico)$/i.test(ue)||ue.startsWith("data:image/"))document.execCommand("insertImage",!1,ue);else{const we=`<a href="${ue}">${ue.split("/").pop()??ue}</a>`;document.execCommand("insertHTML",!1,we)}i(se.innerHTML)}},[Y,i]),Ke=n.useCallback(s=>{Y&&s.preventDefault()},[Y]),Ye=n.useCallback(s=>{const T=P.current;if(!T||!X)return;const G=T.textContent??"",se=X.toLowerCase(),ue=G.toLowerCase();(s===1?ue.indexOf(se):ue.lastIndexOf(se))!==-1&&(T.focus(),window.find?.(X))},[X]),it=n.useCallback(()=>{const s=P.current;!s||!X||(s.innerHTML=s.innerHTML.split(X).join(V),i(s.innerHTML))},[X,V,i]),Te=n.useCallback(()=>{if(!X)return;const s=t.split(X).join(V);i(s);const T=P.current;T&&(T.innerHTML=s)},[X,V,t,i]),ve=n.useCallback(s=>{const T=P.current;T&&(T.focus(),document.execCommand("insertText",!1,s),i(T.innerHTML),ge(!1))},[i]),Ce=n.useCallback(s=>{const T=P.current;T&&(T.focus(),document.execCommand("insertHTML",!1,s),i(T.innerHTML),ye(!1))},[i]),ot=n.useCallback(s=>{const T=k||g;if(s==="fontSize")return e.jsx(fe.NiceSelect,{size:"sm",value:"",onChange:se=>je("fontSize",String(se)),disabled:T,placeholder:"Size",options:Gn.map(se=>({value:se.value,label:se.label})),style:{minWidth:70,maxWidth:80}},s);if(s==="fontColor")return e.jsx(fe.NiceColorPicker,{value:de,onChange:se=>{he(se),je("fontColor",se)},disabled:T,size:"sm",label:"",title:"Text color"},s);if(s==="bgColor")return e.jsx(fe.NiceColorPicker,{value:pe,onChange:se=>{xe(se),je("bgColor",se)},disabled:T,size:"sm",label:"",title:"Highlight color"},s);const G=s==="markdown"&&A||s==="fullscreen"&&Z||s==="source"&&m||s==="findReplace"&&I||s==="emoji"&&J;return e.jsx(fe.NiceButton,{size:"sm",variant:G?"primary":"ghost",onClick:()=>je(s),title:s,disabled:T,children:qn[s]||s},s)},[k,g,je,A,Z,de,pe,m,I,J]);return M?null:e.jsxs("div",{className:`nice-field nice-field--${C} ${B?"nice-field--error":""} ${W||""}`,style:y,children:[te&&e.jsxs("label",{className:"nice-field__label",htmlFor:z,children:[te,f&&e.jsx("span",{className:"nice-field__required",children:"*"})]}),e.jsxs("div",{ref:d,className:`nice-htmleditor${Z?" nice-htmleditor--fullscreen":""}`,children:[e.jsxs("div",{className:"nice-htmleditor__toolbar",style:{display:"flex",flexWrap:"wrap",gap:2,alignItems:"center"},children:[u.map(ot),F&&F.length>0&&e.jsxs("div",{style:{position:"relative"},children:[e.jsx(fe.NiceButton,{size:"sm",variant:be?"primary":"ghost",onClick:()=>ye(s=>!s),title:"Insert template",children:"??"}),be&&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:F.map((s,T)=>e.jsx("li",{style:{padding:"6px 10px",cursor:"pointer",borderRadius:4},onMouseDown:G=>{G.preventDefault(),Ce(s.html)},children:s.label},T))})]})]}),I&&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:X,onChange:s=>re(s.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:V,onChange:s=>R(s.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(fe.NiceButton,{size:"sm",variant:"ghost",onClick:()=>Ye(1),title:"Find next",children:"?"}),e.jsx(fe.NiceButton,{size:"sm",variant:"ghost",onClick:()=>Ye(-1),title:"Find previous",children:"?"}),e.jsx(fe.NiceButton,{size:"sm",variant:"ghost",onClick:it,disabled:k||g,children:"Replace"}),e.jsx(fe.NiceButton,{size:"sm",variant:"ghost",onClick:Te,disabled:k||g,children:"All"}),e.jsx(fe.NiceButton,{size:"sm",variant:"ghost",onClick:()=>j(!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:Qn.map(s=>e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:"0.7em",fontWeight:600,color:"var(--text-muted, #999)",padding:"4px 0"},children:s.label}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:2},children:s.emojis.map(T=>e.jsx("span",{style:{cursor:"pointer",fontSize:"1.2em",padding:2,borderRadius:4},onClick:()=>ve(T),title:T,children:T},T))})]},s.label))}),e.jsx("input",{ref:_,type:"file",accept:"image/*",style:{display:"none"},onChange:Ee}),m?e.jsx("textarea",{className:"nice-htmleditor__source",value:c,onChange:s=>h(s.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:k||g}):A?e.jsx("textarea",{className:"nice-htmleditor__markdown",value:p,onChange:s=>a(s.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:k||g}):e.jsxs("div",{style:{position:"relative"},children:[e.jsx("div",{ref:P,id:z,className:"nice-htmleditor__content",contentEditable:!k&&!g,dangerouslySetInnerHTML:{__html:t},onInput:Ae,onKeyDown:et,onPaste:tt,onDrop:nt,onDragOver:Ke,style:{minHeight:r},"data-placeholder":o,role:"textbox","aria-multiline":"true",suppressContentEditableWarning:!0}),E&&Se.length>0&&e.jsx("ul",{className:"nice-htmleditor__mention-list",children:Se.map((s,T)=>e.jsx("li",{className:`nice-htmleditor__mention-item ${T===ae?"nice-htmleditor__mention-item--active":""}`,onMouseDown:G=>{G.preventDefault(),De(s)},children:s.label},s.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:[v>0&&e.jsxs("span",{children:[ce," / ",v]}),K&&e.jsxs("span",{children:[me," words"]}),K&&e.jsxs("span",{children:[ce," chars"]}),m&&e.jsx("span",{style:{fontWeight:600},children:"HTML Source"}),A&&e.jsx("span",{style:{fontWeight:600},children:"Markdown"})]})]}),B&&e.jsx("div",{className:"nice-field__error",children:B}),q&&!B&&e.jsx("div",{className:"nice-field__hint",children:q})]})},ei=Object.freeze(Object.defineProperty({__proto__:null,NiceHtmlEditor:ft},Symbol.toStringTag,{value:"Module"})),ti=[{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"}],ni=[{style:"professional",label:"Professional"},{style:"casual",label:"Casual"},{style:"formal",label:"Formal"},{style:"concise",label:"Concise"}],ii=n.forwardRef(function(i,o){const{enableAI:r=!0,aiModel:u,enableImprove:g=!0,enableTranslate:S=!0,enableGenerate:w=!0,toolbar:L,languages:H=ti,textStyles:Y=ni,onImprove:U,onTranslate:v,onGenerate:K,showAIToolbar:F=!0,value:te,onChange:B,...q}=i,f=n.useRef(null),[k,C]=n.useState(!1),[$,W]=n.useState(!1),[y,N]=n.useState(!1),[x,M]=n.useState(""),[z,P]=n.useState(""),[_,d]=n.useState("professional"),[A,b]=n.useState(""),[p,a]=n.useState(H[0]?.code||"en"),[m,l]=n.useState(""),[c,h]=n.useState(""),{t:E}=ne.$o(),Q=ne.ie(),{improveText:D,translate:ee,generateHtml:ae,isLoading:O}=ne.Nl(),Z=r&&Q.isConfigured,ie=n.useCallback(()=>{const oe=window.getSelection();return oe&&oe.toString().trim()?oe.toString():""},[]),de=n.useCallback(oe=>{const I=window.getSelection();if(I&&I.rangeCount>0){const j=I.getRangeAt(0);j.deleteContents();const X=document.createElement("div");X.innerHTML=oe;const re=document.createDocumentFragment();for(;X.firstChild;)re.appendChild(X.firstChild);if(j.insertNode(re),f.current){const V=f.current.innerHTML;B(V)}}},[B]),he=n.useCallback(async(oe="professional")=>{if(!Z||!g)return"";const I=ie();if(!I)return"";M(I),d(oe),C(!0),P("");try{const j=await D(I,oe);return P(j),U?.(I,j,oe),j}catch{return P(E("htmlEditorAI.improveFailed","Failed to improve text")),""}},[Z,g,ie,D,U,E]),pe=n.useCallback(async oe=>{if(!Z||!S)return"";const I=ie();if(!I)return"";M(I),a(oe),W(!0),b("");try{const j=H.find(re=>re.code===oe)?.label||oe,X=await ee(I,j);return b(X),v?.(I,X,oe),X}catch{return b(E("htmlEditorAI.translateFailed","Failed to translate text")),""}},[Z,S,ie,ee,H,v,E]),xe=n.useCallback(async oe=>{if(!Z||!w||!oe.trim())return"";l(oe),h("");try{const I=await ae(oe);return h(I),K?.(oe,I),I}catch{return h(E("htmlEditorAI.generateFailed","Failed to generate HTML")),""}},[Z,w,ae,K,E]),ce=n.useCallback(()=>{z&&de(z),C(!1),P("")},[z,de]),le=n.useCallback(()=>{A&&de(A),W(!1),b("")},[A,de]),me=n.useCallback(()=>{if(c&&f.current){document.execCommand("insertHTML",!1,c);const oe=f.current.innerHTML;B(oe)}N(!1),h(""),l("")},[c,B]);return n.useImperativeHandle(o,()=>({getEditor:()=>f.current,focus:()=>f.current?.focus(),getValue:()=>f.current?.innerHTML||"",setValue:oe=>{f.current&&(f.current.innerHTML=oe,B(oe))},getSelection:ie,insertHtml:oe=>{document.execCommand("insertHTML",!1,oe),f.current&&B(f.current.innerHTML)},improveSelection:he,translateSelection:pe,generateHtml:xe})),n.useCallback(oe=>{f.current=oe},[]),e.jsxs("div",{className:"nice-html-editor-ai","data-testid":i["data-testid"],children:[F&&Z&&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"}),O&&e.jsx("span",{className:"nice-html-editor-ai__loading",children:E("htmlEditorAI.processing","Processing...")})]}),e.jsxs("div",{className:"nice-html-editor-ai__toolbar-right",children:[g&&e.jsxs("div",{className:"nice-html-editor-ai__dropdown",children:[e.jsxs("button",{type:"button",className:"nice-html-editor-ai__btn",onClick:()=>he(),disabled:O,title:E("htmlEditorAI.improveText","Improve selected text"),children:["✨ ",E("htmlEditorAI.improve","Improve")]}),e.jsx("div",{className:"nice-html-editor-ai__dropdown-menu",children:Y.map(({style:oe,label:I})=>e.jsx("button",{type:"button",className:"nice-html-editor-ai__dropdown-item",onClick:()=>he(oe),children:I},oe))})]}),S&&e.jsxs("div",{className:"nice-html-editor-ai__dropdown",children:[e.jsxs("button",{type:"button",className:"nice-html-editor-ai__btn",disabled:O,title:E("htmlEditorAI.translateText","Translate selected text"),children:["🌐 ",E("htmlEditorAI.translate","Translate")]}),e.jsx("div",{className:"nice-html-editor-ai__dropdown-menu nice-html-editor-ai__dropdown-menu--languages",children:H.map(({code:oe,label:I})=>e.jsx("button",{type:"button",className:"nice-html-editor-ai__dropdown-item",onClick:()=>pe(oe),children:I},oe))})]}),w&&e.jsxs("button",{type:"button",className:"nice-html-editor-ai__btn",onClick:()=>N(!0),disabled:O,title:E("htmlEditorAI.generateHtml","Generate HTML from description"),children:["⚡ ",E("htmlEditorAI.generate","Generate")]})]})]}),e.jsx("div",{className:"nice-html-editor-ai__editor-wrapper",children:e.jsx(ft,{value:te,onChange:B,toolbar:L,...q})}),k&&e.jsxs("div",{className:"nice-html-editor-ai__panel",children:[e.jsxs("div",{className:"nice-html-editor-ai__panel-header",children:[e.jsxs("h4",{children:["✨ ",E("htmlEditorAI.improveText","Improve Text")]}),e.jsx("div",{className:"nice-html-editor-ai__style-selector",children:Y.map(({style:oe,label:I})=>e.jsx("button",{type:"button",className:`nice-html-editor-ai__style-btn ${_===oe?"nice-html-editor-ai__style-btn--active":""}`,onClick:()=>{d(oe),he(oe)},children:I},oe))}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__close",onClick:()=>C(!1),children:"✕"})]}),e.jsx("div",{className:"nice-html-editor-ai__panel-body",children:O?e.jsx("div",{className:"nice-html-editor-ai__loading-panel",children:E("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:E("htmlEditorAI.original","Original")}),e.jsx("div",{className:"nice-html-editor-ai__text-content",children:x})]}),e.jsxs("div",{className:"nice-html-editor-ai__text-block nice-html-editor-ai__text-block--improved",children:[e.jsx("h5",{children:E("htmlEditorAI.improved","Improved")}),e.jsx("div",{className:"nice-html-editor-ai__text-content",children:z})]})]})}),e.jsxs("div",{className:"nice-html-editor-ai__panel-footer",children:[e.jsxs("button",{type:"button",className:"nice-html-editor-ai__apply",onClick:ce,disabled:!z||O,children:["✓ ",E("htmlEditorAI.apply","Apply")]}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__cancel",onClick:()=>{C(!1),P("")},children:E("htmlEditorAI.cancel","Cancel")})]})]}),$&&e.jsxs("div",{className:"nice-html-editor-ai__panel",children:[e.jsxs("div",{className:"nice-html-editor-ai__panel-header",children:[e.jsxs("h4",{children:["🌐 ",E("htmlEditorAI.translateText","Translate Text")]}),e.jsx("div",{className:"nice-html-editor-ai__language-selector",children:e.jsx("select",{value:p,onChange:oe=>{a(oe.target.value),pe(oe.target.value)},className:"nice-html-editor-ai__language-select",children:H.map(({code:oe,label:I})=>e.jsx("option",{value:oe,children:I},oe))})}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__close",onClick:()=>W(!1),children:"✕"})]}),e.jsx("div",{className:"nice-html-editor-ai__panel-body",children:O?e.jsx("div",{className:"nice-html-editor-ai__loading-panel",children:E("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:E("htmlEditorAI.original","Original")}),e.jsx("div",{className:"nice-html-editor-ai__text-content",children:x})]}),e.jsxs("div",{className:"nice-html-editor-ai__text-block nice-html-editor-ai__text-block--translated",children:[e.jsx("h5",{children:H.find(oe=>oe.code===p)?.label||p}),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:le,disabled:!A||O,children:["✓ ",E("htmlEditorAI.apply","Apply")]}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__cancel",onClick:()=>{W(!1),b("")},children:E("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:["⚡ ",E("htmlEditorAI.generateHtml","Generate HTML")]}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__close",onClick:()=>{N(!1),h(""),l("")},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:E("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:m,onChange:oe=>l(oe.target.value),className:"nice-html-editor-ai__generate-textarea",rows:3}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__generate-btn",onClick:()=>xe(m),disabled:O||!m.trim(),children:O?E("htmlEditorAI.generating","Generating..."):E("htmlEditorAI.generate","Generate")})]}),c&&e.jsxs("div",{className:"nice-html-editor-ai__generate-result",children:[e.jsx("h5",{children:E("htmlEditorAI.preview","Preview")}),e.jsx("div",{className:"nice-html-editor-ai__preview",dangerouslySetInnerHTML:{__html:c}}),e.jsx("h5",{children:E("htmlEditorAI.htmlCode","HTML Code")}),e.jsx("pre",{className:"nice-html-editor-ai__code",children:c})]})]}),e.jsxs("div",{className:"nice-html-editor-ai__panel-footer",children:[e.jsxs("button",{type:"button",className:"nice-html-editor-ai__apply",onClick:me,disabled:!c||O,children:["✓ ",E("htmlEditorAI.insert","Insert")]}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__cancel",onClick:()=>{N(!1),h(""),l("")},children:E("htmlEditorAI.cancel","Cancel")})]})]})]})}),Gt=n.forwardRef(({length:t=6,value:i="",onChange:o,masked:r=!1,onComplete:u,label:g,helperText:S,error:w,required:L,disabled:H,readOnly:Y,size:U="md",name:v,id:K,className:F,style:te,autoFocus:B,labelPlacement:q,errorPlacement:f,labelWidth:k,controlWidth:C,loading:$,cellWidth:W,...y},N)=>{const x=ne.ks(K),M=n.useRef([]),z=i.padEnd(t,"").slice(0,t).split(""),P=n.useCallback(p=>{const a=Math.max(0,Math.min(t-1,p));M.current[a]?.focus()},[t]),_=n.useCallback(p=>{const a=p.join("");o?.(a),a.length===t&&a.indexOf("")===-1&&/^\d+$/.test(a)&&u?.(a)},[o,u,t]),d=n.useCallback((p,a)=>{const l=a.target.value.replace(/\D/g,"").slice(-1);if(!l)return;const c=[...z];c[p]=l,_(c),P(p+1)},[z,_,P]),A=n.useCallback((p,a)=>{if(a.key==="Backspace"){a.preventDefault();const m=[...z];z[p]?(m[p]="",_(m)):p>0&&(m[p-1]="",_(m),P(p-1))}else a.key==="ArrowLeft"?(a.preventDefault(),P(p-1)):a.key==="ArrowRight"&&(a.preventDefault(),P(p+1))},[z,_,P]),b=n.useCallback(p=>{p.preventDefault();const a=p.clipboardData.getData("text").replace(/\D/g,"").slice(0,t);if(!a)return;const m=a.padEnd(t,"").slice(0,t).split("");for(let l=a.length;l<t;l++)m[l]=z[l]||"";_(m),P(Math.min(a.length,t-1))},[t,z,_,P]);return e.jsxs("div",{className:`nice-field nice-field--${U} nice-field--otp${q?` nice-field--label-${q}`:""}${f==="right"?" nice-field--error-right":""} ${$?"nice-field--loading":""} ${F||""}`,style:{...te,...k!=null&&{"--nice-field-label-width":typeof k=="number"?`${k}px`:k},...C!=null&&{"--nice-field-control-width":typeof C=="number"?`${C}px`:C},...W!=null&&{"--nice-otp-cell-width":typeof W=="number"?`${W}px`:W}},"aria-busy":$||void 0,...y,children:[g&&e.jsx("label",{htmlFor:`${x}-0`,className:`nice-field__label ${L?"nice-field__label--required":""}`,children:g}),e.jsxs("div",{className:"nice-field__control",children:[e.jsxs("div",{ref:N,className:`nice-otp nice-otp--${U} ${w?"nice-otp--error":""} ${H?"nice-otp--disabled":""}`,onPaste:b,children:[Array.from({length:t},(p,a)=>e.jsx("input",{ref:m=>{M.current[a]=m},id:a===0?`${x}-0`:void 0,className:"nice-otp__digit",type:r?"password":"text",inputMode:"numeric",maxLength:2,value:z[a]||"",disabled:H,readOnly:Y,autoFocus:B&&a===0,"aria-invalid":!!w,"aria-label":`${a+1}`,onChange:m=>d(a,m),onKeyDown:m=>A(a,m),onFocus:m=>m.target.select()},a)),v&&e.jsx("input",{type:"hidden",name:v,value:i})]}),f==="right"&&w&&e.jsx("div",{id:`${x}-error`,className:"nice-field__error",role:"alert",children:w}),f==="right"&&!w&&S&&e.jsx("div",{id:`${x}-helper`,className:"nice-field__helper",children:S}),$&&e.jsx("span",{className:"nice-field__spinner",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})})]}),f!=="right"&&w&&e.jsx("div",{id:`${x}-error`,className:"nice-field__error",role:"alert",children:w}),f!=="right"&&!w&&S&&e.jsx("div",{id:`${x}-helper`,className:"nice-field__helper",children:S})]})});Gt.displayName="NiceInputOtp";const oi={xxs:36,xs:48,sm:64,md:80,lg:100,xl:128,xxl:160},We=6,Fe=135,Qt=405,ze=Qt-Fe;function ut(t,i,o,r){const u=(r-90)*(Math.PI/180);return{x:t+o*Math.cos(u),y:i+o*Math.sin(u)}}function Ct(t,i,o,r,u){const g=ut(t,i,o,r),S=ut(t,i,o,u),w=u-r>180?1:0;return`M ${g.x} ${g.y} A ${o} ${o} 0 ${w} 1 ${S.x} ${S.y}`}const Zt=n.forwardRef(({value:t=0,onChange:i,min:o=0,max:r=100,step:u=1,showValue:g=!0,valueTemplate:S="{value}",label:w,helperText:L,error:H,required:Y,disabled:U,readOnly:v,size:K="md",name:F,id:te,className:B,style:q,labelPlacement:f="top",errorPlacement:k,labelWidth:C,controlWidth:$,loading:W,isLabelCentered:y=!0,...N},x)=>{const M=ne.ks(te),z=n.useRef(!1),P=n.useRef(null),_=typeof K=="number"?K:oi[K],d=_/2,A=_/2,b=(_-We*2)/2,p=r>o?(t-o)/(r-o):0,a=Fe+p*ze,m=n.useCallback(Q=>{let D=Q-Fe;D<0&&(D+=360),D>ze&&(D=D-ze<360-D?ze:0);const ee=Math.max(0,Math.min(1,D/ze)),ae=o+ee*(r-o),O=Math.round(ae/u)*u;return Math.max(o,Math.min(r,O))},[o,r,u]),l=n.useCallback(Q=>{if(U||v)return;const D=P.current;if(!D)return;const ee=D.getBoundingClientRect(),ae=Q.clientX-ee.left-ee.width/2,O=Q.clientY-ee.top-ee.height/2;let Z=Math.atan2(ae,-O)*(180/Math.PI);Z<0&&(Z+=360);const ie=m(Z);i?.(ie)},[m,U,v,i]);n.useEffect(()=>{const Q=ee=>{z.current&&l(ee)},D=()=>{z.current=!1};return window.addEventListener("pointermove",Q),window.addEventListener("pointerup",D),()=>{window.removeEventListener("pointermove",Q),window.removeEventListener("pointerup",D)}},[l]);const c=n.useCallback(Q=>{if(U||v)return;let D=t;Q.key==="ArrowUp"||Q.key==="ArrowRight"?(Q.preventDefault(),D=Math.min(r,t+u)):(Q.key==="ArrowDown"||Q.key==="ArrowLeft")&&(Q.preventDefault(),D=Math.max(o,t-u)),D!==t&&i?.(D)},[t,i,o,r,u,U,v]),h=S.replace("{value}",String(t)),E=ut(d,A,b,a);return e.jsxs("div",{className:`nice-field nice-knob-field nice-knob-field--err-${k||"bottom"} nice-field--${typeof K=="string"?K:"md"} ${W?"nice-field--loading":""} ${B||""}`,style:{...q,...C!=null&&{"--nice-field-label-width":typeof C=="number"?`${C}px`:C},...$!=null&&{"--nice-field-control-width":typeof $=="number"?`${$}px`:$}},"aria-busy":W||void 0,...N,children:[e.jsxs("div",{className:`nice-knob-field__inner nice-knob-field--${f} ${y?"nice-knob-field--label-centered":""}`,children:[w&&e.jsx("label",{htmlFor:M,className:`nice-field__label ${Y?"nice-field__label--required":""}`,children:w}),e.jsx("div",{className:"nice-field__control",children:e.jsxs("div",{ref:Q=>{P.current=Q,typeof x=="function"?x(Q):x&&(x.current=Q)},className:`nice-knob nice-knob--${K} ${U?"nice-knob--disabled":""} ${H?"nice-knob--error":""}`,role:"slider",id:M,tabIndex:U?-1:0,"aria-valuenow":t,"aria-valuemin":o,"aria-valuemax":r,"aria-disabled":U,"aria-invalid":!!H,onPointerDown:Q=>{U||v||(z.current=!0,l(Q))},onKeyDown:c,children:[e.jsxs("svg",{width:_,height:_,viewBox:`0 0 ${_} ${_}`,children:[e.jsx("path",{d:Ct(d,A,b,Fe,Qt),fill:"none",stroke:"var(--nice-border-color, #d1d5db)",strokeWidth:We,strokeLinecap:"round"}),p>0&&e.jsx("path",{d:Ct(d,A,b,Fe,a),fill:"none",stroke:"var(--nice-primary, #3b82f6)",strokeWidth:We,strokeLinecap:"round"}),e.jsx("circle",{cx:E.x,cy:E.y,r:We,fill:"var(--nice-primary, #3b82f6)"})]}),g&&e.jsx("span",{className:"nice-knob__value",children:h}),F&&e.jsx("input",{type:"hidden",name:F,value:t}),W&&e.jsx("span",{className:"nice-knob__spinner","aria-hidden":"true",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})})]})})]}),H&&e.jsx("div",{className:"nice-field__error",role:"alert",children:H}),!H&&L&&e.jsx("div",{className:"nice-field__helper",children:L})]})});Zt.displayName="NiceKnob";const Jt=n.forwardRef(({value:t="",onChange:i,suggestions:o=[],onSearch:r,trigger:u="@",renderSuggestion:g,placeholder:S,rows:w=3,label:L,helperText:H,error:Y,required:U,disabled:v,readOnly:K,size:F="md",name:te,id:B,className:q,style:f,...k},C)=>{const $=ne.ks(B),[W,y]=n.useState(!1),[N,x]=n.useState(""),[M,z]=n.useState(0),[P,_]=n.useState({top:0,left:0}),d=n.useRef(null),A=n.useRef(-1),p=o.map(h=>typeof h=="string"?{key:h,label:h}:h).filter(h=>h.label.toLowerCase().includes(N.toLowerCase())),a=n.useCallback(()=>{y(!1),x(""),z(0),A.current=-1},[]),m=n.useCallback(h=>{const E=d.current;if(!E||A.current<0)return;const Q=t.slice(0,A.current),D=t.slice(E.selectionStart),ee=`${u}${h.label} `,ae=Q+ee+D;i?.(ae),a(),requestAnimationFrame(()=>{const O=Q.length+ee.length;E.setSelectionRange(O,O),E.focus()})},[t,i,u,a]),l=n.useCallback(h=>{const E=h.target.value;i?.(E);const Q=h.target.selectionStart,D=E.slice(0,Q),ee=D.lastIndexOf(u);if(ee>=0){const ae=ee>0?D[ee-1]:" ",O=D.slice(ee+u.length);if(/\s/.test(ae)&&!/\s/.test(O)){A.current=ee;const Z=O;x(Z),y(!0),z(0),r?.(Z);const ie=h.target,de=ie.getBoundingClientRect(),he=parseInt(getComputedStyle(ie).lineHeight)||20,pe=D.split(`
11
+ `);_({top:de.top+pe.length*he+4-ie.scrollTop,left:de.left+8});return}}a()},[i,u,r,a]),c=n.useCallback(h=>{!W||p.length===0||(h.key==="ArrowDown"?(h.preventDefault(),z(E=>(E+1)%p.length)):h.key==="ArrowUp"?(h.preventDefault(),z(E=>(E-1+p.length)%p.length)):h.key==="Enter"?(h.preventDefault(),p[M]&&m(p[M])):h.key==="Escape"&&a())},[W,p,M,m,a]);return n.useEffect(()=>{if(!W)return;const h=E=>{const Q=d.current;Q&&!Q.contains(E.target)&&a()};return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[W,a]),e.jsxs("div",{className:`nice-field ${q||""}`,style:f,...k,children:[L&&e.jsx("label",{htmlFor:$,className:`nice-field__label ${U?"nice-field__label--required":""}`,children:L}),e.jsxs("div",{className:`nice-mention nice-mention--${F} ${Y?"nice-mention--error":""} ${v?"nice-mention--disabled":""}`,children:[e.jsx("textarea",{ref:h=>{d.current=h,typeof C=="function"?C(h):C&&(C.current=h)},id:$,name:te,className:"nice-mention__input",value:t,onChange:l,onKeyDown:c,placeholder:S,rows:w,disabled:v,readOnly:K,"aria-invalid":!!Y,"aria-describedby":Y?`${$}-error`:H?`${$}-helper`:void 0,"aria-autocomplete":"list","aria-expanded":W}),W&&p.length>0&&e.jsx("ul",{className:"nice-mention__suggestions",role:"listbox",style:{position:"fixed",top:P.top,left:P.left},children:p.map((h,E)=>e.jsx("li",{role:"option","aria-selected":E===M,className:`nice-mention__suggestion ${E===M?"nice-mention__suggestion--active":""}`,onMouseDown:Q=>{Q.preventDefault(),m(h)},onMouseEnter:()=>z(E),children:g?g(h):e.jsxs(e.Fragment,{children:[h.icon&&e.jsx("span",{className:"nice-mention__suggestion-icon",children:h.icon}),e.jsx("span",{children:h.label})]})},h.key))})]}),Y&&e.jsx("div",{id:`${$}-error`,className:"nice-field__error",role:"alert",children:Y}),!Y&&H&&e.jsx("div",{id:`${$}-helper`,className:"nice-field__helper",children:H})]})});Jt.displayName="NiceMention";function ai(t){const i=[],o=r=>{for(const u of r)i.push(u),u.children&&o(u.children)};return o(t),i}function en(t,i){const o=i.toLowerCase();return t.reduce((r,u)=>{const g=u.children?en(u.children,i):[];return(u.label.toLowerCase().includes(o)||g.length>0)&&r.push({...u,children:g.length>0?g:u.children}),r},[])}const tn=({node:t,level:i,selectedKeys:o,expandedKeys:r,onToggleExpand:u,onSelect:g,selectableLeafsOnly:S})=>{const w=t.children&&t.children.length>0,L=r.has(t.key),H=o.has(t.key),Y=!w,U=!t.disabled&&(!S||Y);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`nice-tree-select__node ${H?"nice-tree-select__node--selected":""} ${t.disabled?"nice-tree-select__node--disabled":""}`,style:{paddingLeft:i*16+8},onClick:()=>U&&g(t.key),role:"treeitem","aria-selected":H,"aria-expanded":w?L:void 0,"aria-disabled":t.disabled,children:[w?e.jsx("button",{type:"button",className:"nice-tree-select__toggle",onClick:v=>{v.stopPropagation(),u(t.key)},"aria-label":"Toggle",children:e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"currentColor",style:{transform:L?"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&&L&&t.children.map(v=>e.jsx(tn,{node:v,level:i+1,selectedKeys:o,expandedKeys:r,onToggleExpand:u,onSelect:g,selectableLeafsOnly:S},v.key))]})},nn=n.forwardRef(({nodes:t,value:i,onChange:o,multiple:r=!1,searchable:u=!1,placeholder:g,selectableLeafsOnly:S=!1,clearable:w=!1,label:L,helperText:H,error:Y,required:U,disabled:v,readOnly:K,size:F="md",name:te,id:B,className:q,style:f,controlWidth:k,...C},$)=>{const{t:W}=ne.$o(),y=ne.ks(B),[N,x]=n.useState(!1),[M,z]=n.useState(""),[P,_]=n.useState(new Set),d=n.useRef(null);ne.Cs(d,()=>x(!1));const A=n.useMemo(()=>i==null?new Set:new Set(Array.isArray(i)?i:[i]),[i]),b=n.useMemo(()=>M?en(t,M):t,[t,M]),p=n.useMemo(()=>{const c=ai(t);return Array.from(A).map(h=>c.find(E=>E.key===h)?.label).filter(Boolean)},[A,t]),a=n.useCallback(c=>{_(h=>{const E=new Set(h);return E.has(c)?E.delete(c):E.add(c),E})},[]),m=n.useCallback(c=>{if(r){const h=new Set(A);h.has(c)?h.delete(c):h.add(c),o?.(Array.from(h))}else o?.(c),x(!1)},[r,A,o]),l=n.useCallback(c=>{c.stopPropagation(),o?.(r?[]:"")},[o,r]);return e.jsxs("div",{className:`nice-field nice-field--${F} ${q||""}`,style:{width:"fit-content",maxWidth:"100%",...f},...C,children:[L&&e.jsx("label",{htmlFor:y,className:`nice-field__label ${U?"nice-field__label--required":""}`,children:L}),e.jsxs("div",{ref:d,className:"nice-tree-select",style:{position:"relative",width:k!=null?typeof k=="number"?`${k}px`:k:240},children:[e.jsxs("div",{ref:$,id:y,className:`nice-input nice-input--${F} ${Y?"nice-input--error":""} ${v?"nice-input--disabled":""} ${K?"nice-input--readonly":""}`,role:"combobox","aria-expanded":N,"aria-haspopup":"tree","aria-invalid":!!Y,tabIndex:v?-1:0,onClick:()=>!v&&!K&&x(!N),onKeyDown:c=>{(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),!v&&!K&&x(!N))},children:[e.jsx("span",{className:"nice-tree-select__display",children:p.length>0?p.join(", "):e.jsx("span",{className:"nice-tree-select__placeholder",children:g??W("controls.select","Select...")})}),w&&A.size>0&&e.jsx("button",{type:"button",className:"nice-input__clear",onClick:l,"aria-label":W("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:N?"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"})})]}),N&&e.jsxs("div",{className:"nice-tree-select__dropdown",role:"tree",children:[u&&e.jsx("div",{className:"nice-tree-select__search",children:e.jsx("input",{className:"nice-input__native",type:"text",placeholder:W("controls.search","Search..."),value:M,onChange:c=>z(c.target.value),autoFocus:!0,onClick:c=>c.stopPropagation()})}),e.jsx("div",{className:"nice-tree-select__list",children:b.length===0?e.jsx("div",{className:"nice-tree-select__empty",children:W("controls.noResults","No results")}):b.map(c=>e.jsx(tn,{node:c,level:0,selectedKeys:A,expandedKeys:P,onToggleExpand:a,onSelect:m,selectableLeafsOnly:S},c.key))})]})]}),te&&e.jsx("input",{type:"hidden",name:te,value:Array.isArray(i)?i.join(","):i??""}),Y&&e.jsx("div",{id:`${y}-error`,className:"nice-field__error",role:"alert",children:Y}),!Y&&H&&e.jsx("div",{id:`${y}-helper`,className:"nice-field__helper",children:H})]})});nn.displayName="NiceTreeSelect";function Me(t,i){return String(t[i])}const on=n.forwardRef(({source:t,target:i,onChange:o,keyField:r="id",labelField:u="label",renderItem:g,filterable:S=!1,searchable:w,groupBy:L,sortable:H=!1,bulkActions:Y=!0,maxRight:U,sourceHeader:v,targetHeader:K,disabled:F=!1,size:te="md",className:B,style:q,id:f,...k},C)=>{const{t:$}=ne.$o(),[W,y]=n.useState(new Set),[N,x]=n.useState(new Set),[M,z]=n.useState(""),[P,_]=n.useState(""),d=n.useCallback((h,E,Q)=>{E(D=>{const ee=new Set(D);return ee.has(Q)?ee.delete(Q):ee.add(Q),ee})},[]),A=n.useCallback(()=>{const h=t.filter(ee=>W.has(Me(ee,r))),E=t.filter(ee=>!W.has(Me(ee,r))),Q=typeof U=="number"?h.slice(0,Math.max(0,U-i.length)):h,D=h.slice(Q.length);o([...E,...D],[...i,...Q]),y(new Set)},[t,i,W,r,o,U]),b=n.useCallback(()=>{const h=i.filter(Q=>N.has(Me(Q,r))),E=i.filter(Q=>!N.has(Me(Q,r)));o([...t,...h],E),x(new Set)},[t,i,N,r,o]),p=n.useCallback(()=>{if(typeof U=="number"){const h=Math.max(0,U-i.length),E=t.slice(0,h),Q=t.slice(h);o(Q,[...i,...E])}else o([],[...i,...t]);y(new Set)},[t,i,o,U]),a=n.useCallback(()=>{o([...t,...i],[]),x(new Set)},[t,i,o]),m=(h,E)=>{if(!E)return h;const Q=E.toLowerCase();return h.filter(D=>String(D[u]).toLowerCase().includes(Q))},l=Y===!1?{moveAll:!1,removeAll:!1}:Y===!0||Y===void 0?{moveAll:!0,removeAll:!0}:{moveAll:Y.moveAll??!0,removeAll:Y.removeAll??!0},c=(h,E,Q,D,ee,ae,O)=>{const Z=m(h,D),ie=w===!0||S&&w===void 0?"both":w??!1,de=ie==="both"||ie==="left"&&O==="left"||ie==="right"&&O==="right",he=(()=>{if(!L)return[{label:"",items:Z}];const ce=new Map;for(const le of Z){const me=String(L(le));let oe=ce.get(me);oe||(oe=[],ce.set(me,oe)),oe.push(le)}return[...ce.entries()].map(([le,me])=>({label:le,items:me}))})(),pe=(ce,le)=>{ce.dataTransfer.setData("text/plain",le),ce.dataTransfer.effectAllowed="move"},xe=(ce,le)=>{ce.preventDefault();const me=ce.dataTransfer.getData("text/plain");if(!me||me===le||O!=="right"||!H)return;const oe=[...i],I=oe.findIndex(re=>Me(re,r)===me),j=oe.findIndex(re=>Me(re,r)===le);if(I===-1||j===-1)return;const[X]=oe.splice(I,1);oe.splice(j,0,X),o(t,oe)};return e.jsxs("div",{className:"nice-picklist__panel",children:[ae&&e.jsx("div",{className:"nice-picklist__header",children:ae}),de&&e.jsx("div",{className:"nice-picklist__filter",children:e.jsx("input",{className:"nice-input__native",type:"text",placeholder:$("controls.search","Search..."),value:D,onChange:ce=>ee(ce.target.value)})}),e.jsxs("div",{className:"nice-picklist__list",role:"listbox","aria-multiselectable":"true",children:[he.map(ce=>e.jsxs(n.Fragment,{children:[ce.label&&e.jsx("div",{className:"nice-picklist__group-header",role:"presentation",children:ce.label}),ce.items.map(le=>{const me=Me(le,r),oe=E.has(me);return e.jsx("div",{className:`nice-picklist__item ${oe?"nice-picklist__item--selected":""}`,role:"option","aria-selected":oe,draggable:H&&O==="right",onDragStart:H&&O==="right"?I=>pe(I,me):void 0,onDragOver:H&&O==="right"?I=>I.preventDefault():void 0,onDrop:H&&O==="right"?I=>xe(I,me):void 0,onClick:()=>!F&&d(E,Q,me),children:g?g(le,O):String(le[u])},me)})]},ce.label||"__none__")),Z.length===0&&e.jsx("div",{className:"nice-picklist__empty",children:$("controls.noItems","No items")})]})]})};return e.jsxs("div",{ref:C,id:f,className:`nice-picklist nice-picklist--${te} ${F?"nice-picklist--disabled":""} ${B||""}`,style:q,...k,children:[c(t,W,y,M,z,v??$("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:F||W.size===0,onClick:A,"aria-label":$("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"})})}),l.moveAll&&e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm",disabled:F||t.length===0,onClick:p,"aria-label":$("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:F||N.size===0,onClick:b,"aria-label":$("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"})})}),l.removeAll&&e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm",disabled:F||i.length===0,onClick:a,"aria-label":$("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"})]})})]}),c(i,N,x,P,_,K??$("picklist.target","Selected"),"right")]})});on.displayName="NicePickList";let Re=null,Pe=null;const si="0.45.0",Ze=`https://cdn.jsdelivr.net/npm/monaco-editor@${si}/min/vs`,St=15e3;function $t(){const t=window;if(t.MonacoEnvironment?.getWorkerUrl)return;const i=`self.MonacoEnvironment={baseUrl:'${Ze}/'};importScripts('${Ze}/base/worker/workerMain.js');`,o=URL.createObjectURL(new Blob([i],{type:"text/javascript"}));t.MonacoEnvironment={getWorkerUrl:()=>o}}function Ie(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 an(){return Pe?Promise.resolve(Pe):Re||(Re=new Promise((t,i)=>{if(window.monaco){$t(),Pe=window.monaco,t(Pe);return}let o=!1;const r=window.setTimeout(()=>{o||(o=!0,Re=null,i(new Error(`Monaco editor failed to load within ${St}ms`)))},St),u=document.createElement("script");u.src=`${Ze}/loader.min.js`,u.async=!0,u.onload=()=>{const g=window.require;g.config({paths:{vs:Ze}}),$t(),g(["vs/editor/editor.main"],S=>{o||(o=!0,window.clearTimeout(r),Pe=S,t(S))})},u.onerror=()=>{o||(o=!0,window.clearTimeout(r),Re=null,i(new Error("Failed to load Monaco Editor loader script")))},document.head.appendChild(u)}),Re)}const yt=n.forwardRef(function(i,o){const{value:r,onChange:u,language:g="plaintext",theme:S="auto",options:w={},height:L=400,width:H="100%",markers:Y=[],decorations:U=[],completionProvider:v,onMount:K,onCursorPositionChange:F,onSelectionChange:te,onSave:B,loading:q,disabled:f=!1,showToolbar:k=!1,showStatusBar:C=!1,editorSize:$="standard",className:W,"data-testid":y,lsp:N}=i,x=n.useRef(null),M=n.useRef(null),z=n.useRef(null),P=n.useRef([]),_=n.useRef(null),[d,A]=n.useState(!0),[b,p]=n.useState(null),[a,m]=n.useState({lineNumber:1,column:1}),[l,c]=n.useState(""),[h,E]=n.useState(w.wordWrap==="on"),Q=n.useMemo(()=>({automaticLayout:!0,readOnly:f||w.readOnly,minimap:{enabled:w.minimap??!0},lineNumbers:w.lineNumbers??"on",wordWrap:w.wordWrap??"off",tabSize:w.tabSize??2,insertSpaces:w.insertSpaces??!0,fontSize:w.fontSize??14,fontFamily:w.fontFamily??"'Fira Code', 'Consolas', 'Monaco', monospace",fontLigatures:w.fontLigatures??!0,cursorStyle:w.cursorStyle??"line",cursorBlinking:w.cursorBlinking??"blink",autoClosingBrackets:w.autoClosingBrackets??"languageDefined",autoClosingQuotes:w.autoClosingQuotes??"languageDefined",formatOnPaste:w.formatOnPaste??!1,formatOnType:w.formatOnType??!1,renderWhitespace:w.renderWhitespace??"selection",renderControlCharacters:w.renderControlCharacters??!1,scrollBeyondLastLine:w.scrollBeyondLastLine??!0,smoothScrolling:w.smoothScrolling??!0,folding:w.folding??!0,showFoldingControls:w.showFoldingControls??"mouseover","bracketPairColorization.enabled":w.bracketPairColorization??!0,guides:w.guides??{bracketPairs:!0,indentation:!0,highlightActiveIndentation:!0},stickyScroll:{enabled:w.stickyScroll??!1},quickSuggestions:w.quickSuggestions??!0,suggestOnTriggerCharacters:w.suggestOnTriggerCharacters??!0,acceptSuggestionOnEnter:w.acceptSuggestionOnEnter??"on",inlayHints:{enabled:w.inlayHints?"on":"off"}}),[w,f]);n.useEffect(()=>{if(!x.current)return;let O=!0;return an().then(async Z=>{if(!O||!x.current)return;z.current=Z;const ie=Z.editor.create(x.current,{value:r,language:g,theme:Ie(S),...Q});if(M.current=ie,A(!1),ie.onDidChangeModelContent(()=>{const de=ie.getValue();u?.(de)}),ie.onDidChangeCursorPosition(de=>{m({lineNumber:de.position.lineNumber,column:de.position.column}),F?.({lineNumber:de.position.lineNumber,column:de.position.column})}),ie.onDidChangeCursorSelection(de=>{const he=de.selection,pe=ie.getModel()?.getValueInRange(he)??"";c(pe),te?.({startLineNumber:he.startLineNumber,startColumn:he.startColumn,endLineNumber:he.endLineNumber,endColumn:he.endColumn})}),ie.addCommand(Z.KeyMod.CtrlCmd|Z.KeyCode.KeyS,()=>{B?.(ie.getValue())}),N&&typeof window<"u")try{await Je("https://cdn.jsdelivr.net/npm/vscode-ws-jsonrpc@1.0.2/lib/browser/index.min.js"),await Je("https://cdn.jsdelivr.net/npm/monaco-languageclient@0.15.0/lib/monaco-languageclient.min.js");const de=window,he=de.ReconnectingWebSocket,{MonacoLanguageClient:pe,CloseAction:xe,ErrorAction:ce,createConnection:le}=de.monacoLanguageClient||{};if(pe&&le){const me=N.url,oe=N.language,I=new he(me),j=new de.VSCodeWebSocketMessageReader(I),X=new de.VSCodeWebSocketMessageWriter(I),re=le(j,X),V=new pe({name:"LSP Client",clientOptions:{documentSelector:[oe],initializationOptions:N.initOptions,errorHandler:{error:()=>ce.Continue,closed:()=>xe.Restart}},connectionProvider:{get:()=>Promise.resolve(re)}});V.start(),M.current.__lspClient=V}}catch(de){console.warn("LSP bridge failed to load:",de)}K?.(ie,Z)}).catch(Z=>{O&&(p(Z.message??"Failed to load editor"),A(!1))}),()=>{if(O=!1,M.current?.dispose(),_.current?.dispose(),M.current&&M.current.__lspClient)try{M.current.__lspClient.stop()}catch{}}},[N]),n.useEffect(()=>{const O=M.current;if(O&&r!==O.getValue()){const Z=O.getPosition();O.setValue(r),Z&&O.setPosition(Z)}},[r]),n.useEffect(()=>{const O=M.current,Z=z.current;if(O&&Z){const ie=O.getModel();ie&&Z.editor.setModelLanguage(ie,g)}},[g]),n.useEffect(()=>{const O=z.current;if(!O||(O.editor.setTheme(Ie(S)),S!=="auto"||typeof document>"u"))return;const Z=()=>{z.current?.editor.setTheme(Ie("auto"))},ie=new MutationObserver(Z);ie.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme","class"]});const de=window.matchMedia?.("(prefers-color-scheme: dark)");return de?.addEventListener?.("change",Z),()=>{ie.disconnect(),de?.removeEventListener?.("change",Z)}},[S]),n.useEffect(()=>{const O=M.current;O&&O.updateOptions(Q)},[Q]),n.useEffect(()=>{const O=M.current,Z=z.current;if(O&&Z){const ie=O.getModel();if(ie){const de=Y.map(he=>({startLineNumber:he.startLineNumber,startColumn:he.startColumn,endLineNumber:he.endLineNumber,endColumn:he.endColumn,message:he.message,severity:he.severity}));Z.editor.setModelMarkers(ie,"owner",de)}}},[Y]),n.useEffect(()=>{const O=M.current;if(O&&U.length>0){const Z=U.map(ie=>({range:{startLineNumber:ie.range.startLineNumber,startColumn:ie.range.startColumn,endLineNumber:ie.range.endLineNumber,endColumn:ie.range.endColumn},options:{className:ie.className,glyphMarginClassName:ie.glyphMarginClassName,hoverMessage:ie.hoverMessage?{value:ie.hoverMessage}:void 0,isWholeLine:ie.isWholeLine}}));P.current=O.deltaDecorations(P.current,Z)}},[U]),n.useEffect(()=>{const O=z.current;if(!O||!v)return;_.current?.dispose();const Z={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 _.current=O.languages.registerCompletionItemProvider(g,{provideCompletionItems:async(ie,de)=>({suggestions:(await v(ie,de)).map(pe=>({label:pe.label,kind:Z[pe.kind]??0,insertText:pe.insertText,insertTextRules:pe.insertTextRules==="insertAsSnippet"?4:void 0,documentation:pe.documentation,detail:pe.detail,range:{startLineNumber:de.lineNumber,startColumn:de.column,endLineNumber:de.lineNumber,endColumn:de.column}}))})}),()=>{_.current?.dispose()}},[g,v]),n.useImperativeHandle(o,()=>({getEditor:()=>M.current,getMonaco:()=>z.current,focus:()=>M.current?.focus(),getValue:()=>M.current?.getValue()??"",setValue:O=>M.current?.setValue(O),getSelection:()=>{const O=M.current;if(!O)return"";const Z=O.getSelection();return Z?O.getModel()?.getValueInRange(Z)??"":""},insertText:O=>{const Z=M.current;if(!Z)return;const ie=Z.getSelection();ie&&Z.executeEdits("",[{range:ie,text:O}])},formatDocument:()=>{M.current?.getAction("editor.action.formatDocument")?.run()},goToLine:(O,Z=1)=>{const ie=M.current;ie&&(ie.setPosition({lineNumber:O,column:Z}),ie.revealLineInCenter(O),ie.focus())},findReplace:()=>{M.current?.getAction("editor.action.startFindReplaceAction")?.run()},undo:()=>{M.current?.trigger("keyboard","undo",null)},redo:()=>{M.current?.trigger("keyboard","redo",null)},getCursorPosition:()=>{const O=M.current?.getPosition();return{lineNumber:O?.lineNumber??1,column:O?.column??1}},setMarkers:O=>{const Z=M.current,ie=z.current;if(Z&&ie){const de=Z.getModel();if(de){const he=O.map(pe=>({startLineNumber:pe.startLineNumber,startColumn:pe.startColumn,endLineNumber:pe.endLineNumber,endColumn:pe.endColumn,message:pe.message,severity:pe.severity}));ie.editor.setModelMarkers(de,"owner",he)}}}}),[]);const D=n.useMemo(()=>({format:()=>M.current?.getAction("editor.action.formatDocument")?.run(),undo:()=>M.current?.trigger("keyboard","undo",null),redo:()=>M.current?.trigger("keyboard","redo",null),find:()=>M.current?.getAction("editor.action.startFindReplaceAction")?.run(),toggleWordWrap:()=>{const O=!h;E(O),M.current?.updateOptions({wordWrap:O?"on":"off"})},toggleMinimap:()=>{const O=M.current?.getOption?.(z.current?.editor?.EditorOption?.minimap);M.current?.updateOptions({minimap:{enabled:!O?.enabled}})},foldAll:()=>M.current?.getAction("editor.foldAll")?.run(),unfoldAll:()=>M.current?.getAction("editor.unfoldAll")?.run()}),[h]),ee=r.split(`
12
+ `).length,ae=r.length;return e.jsxs("div",{className:`nice-code-editor-wrap nice-editor--${$} ${W??""}`,style:{height:L,width:H,display:"flex",flexDirection:"column",position:"relative"},"data-testid":y,children:[b&&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:["⚠️ ",b]}),e.jsx("textarea",{value:r,onChange:O=>u?.(O.target.value),readOnly:f||w.readOnly,style:{width:"100%",height:"100%",fontFamily:"monospace"}})]}),d&&!b&&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:q??e.jsx("div",{className:"nice-code-editor__loader",children:"Loading editor..."})}),k&&e.jsxs("div",{className:"nice-code-editor__toolbar",children:[e.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:D.undo,title:"Undo (Ctrl+Z)",children:"↶"}),e.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:D.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:D.format,title:"Format (Shift+Alt+F)",children:"⎘"}),e.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:D.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${h?" nice-code-editor__toolbar-btn--active":""}`,onClick:D.toggleWordWrap,title:"Toggle Word Wrap",children:"↩"}),e.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:D.toggleMinimap,title:"Toggle Minimap",children:"▥"}),e.jsx("span",{className:"nice-code-editor__toolbar-sep"}),e.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:D.foldAll,title:"Fold All",children:"⊟"}),e.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:D.unfoldAll,title:"Unfold All",children:"⊞"})]}),e.jsx("div",{ref:x,className:"nice-code-editor",style:{flex:1,minHeight:0}}),C&&e.jsxs("div",{className:"nice-code-editor__statusbar",children:[e.jsxs("span",{children:["Ln ",a.lineNumber,", Col ",a.column]}),l.length>0&&e.jsxs("span",{children:["(",l.length," selected)"]}),e.jsx("span",{className:"nice-code-editor__statusbar-spacer"}),e.jsxs("span",{children:[ee," lines · ",ae," chars"]}),e.jsx("span",{className:"nice-code-editor__statusbar-lang",children:g}),Y.length>0&&e.jsxs("span",{className:"nice-code-editor__statusbar-markers",children:["⚠ ",Y.length]})]})]})});function sn(t){const{original:i,modified:o,language:r="plaintext",theme:u="auto",height:g=400,width:S="100%",inline:w=!1,renderSideBySide:L=!0,originalEditable:H=!1,modifiedEditable:Y=!1,onOriginalChange:U,onModifiedChange:v,loading:K,className:F,"data-testid":te}=t,B=n.useRef(null),q=n.useRef(null),f=n.useRef(null),[k,C]=n.useState(!0),[$,W]=n.useState(null);return n.useEffect(()=>{if(!B.current)return;let y=!0;return an().then(N=>{if(!y||!B.current)return;f.current=N;const x=N.editor.createModel(i,r),M=N.editor.createModel(o,r),z=N.editor.createDiffEditor(B.current,{automaticLayout:!0,theme:Ie(u),renderSideBySide:!w&&L,originalEditable:H,readOnly:!Y});z.setModel({original:x,modified:M}),q.current=z,C(!1),H&&x.onDidChangeContent(()=>{U?.(x.getValue())}),Y&&M.onDidChangeContent(()=>{v?.(M.getValue())})}).catch(N=>{y&&(W(N.message??"Failed to load diff editor"),C(!1))}),()=>{y=!1,q.current?.dispose()}},[]),n.useEffect(()=>{const y=q.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(Ie(u)),u!=="auto"||typeof document>"u"))return;const N=()=>{f.current?.editor.setTheme(Ie("auto"))},x=new MutationObserver(N);x.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme","class"]});const M=window.matchMedia?.("(prefers-color-scheme: dark)");return M?.addEventListener?.("change",N),()=>{x.disconnect(),M?.removeEventListener?.("change",N)}},[u,k]),$?e.jsx("div",{className:`nice-code-diff-editor nice-code-diff-editor--error ${F??""}`,style:{height:g,width:S},"data-testid":te,children:e.jsx("div",{className:"nice-code-editor__error",children:e.jsxs("span",{children:["⚠️ ",$]})})}):e.jsxs("div",{className:`nice-code-diff-editor ${F??""}`,style:{height:g,width:S,position:"relative"},"data-testid":te,children:[e.jsx("div",{ref:B,style:{position:"absolute",inset:0}}),k&&e.jsx("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",background:"var(--nice-bg-primary, #fff)",zIndex:2},children:K??e.jsx("div",{className:"nice-code-editor__loader",children:"Loading diff editor..."})})]})}const ri="1.29.0",Mt=`https://cdn.jsdelivr.net/npm/prismjs@${ri}`;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 Je(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 ci(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 Je(`${Mt}/components/prism-${o}.min.js`)}catch{}};return i.Prism?r().then(()=>i.Prism):(rt||(rt=(async()=>(window.Prism={manual:!0},await Je(`${Mt}/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 rn(t){const{value:i,onChange:o,language:r="plaintext",height:u=300,width:g="100%",readOnly:S=!1,tabSize:w=2,lineNumbers:L=!0,placeholder:H,theme:Y="auto",className:U,"data-testid":v}=t,K=n.useRef(null),F=n.useRef(null),[te,B]=n.useState(()=>ct(i)),[q,f]=n.useState("light");n.useEffect(()=>{const N=()=>{if(Y!=="auto")return Y;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()),Y!=="auto"||typeof document>"u")return;const x=()=>f(N()),M=new MutationObserver(x);M.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme","class"]});const z=window.matchMedia?.("(prefers-color-scheme: dark)");return z?.addEventListener?.("change",x),()=>{M.disconnect(),z?.removeEventListener?.("change",x)}},[Y]),n.useEffect(()=>{let N=!0;return ci(r).then(x=>{if(!N)return;const M=pt[r]??"plain";if(x?.languages?.[M])try{const z=x.highlight(i,x.languages[M],M);B(z);return}catch{}B(ct(i))}).catch(()=>{N&&B(ct(i))}),()=>{N=!1}},[i,r]);const k=n.useCallback(()=>{!F.current||!K.current||(F.current.scrollTop=K.current.scrollTop,F.current.scrollLeft=K.current.scrollLeft)},[]),C=n.useCallback(N=>{if(N.key==="Tab"){N.preventDefault();const x=N.currentTarget,M=x.selectionStart,z=x.selectionEnd,P=" ".repeat(w);if(N.shiftKey){const A=i.substring(0,M).lastIndexOf(`
13
+ `)+1;if((i.substring(A,M).match(/^(\s*)/)?.[1]??"").length>=w){const p=i.substring(0,A)+i.substring(A+w);o?.(p),setTimeout(()=>{x.selectionStart=x.selectionEnd=M-w},0)}}else{const _=i.substring(0,M)+P+i.substring(z);o?.(_),setTimeout(()=>{x.selectionStart=x.selectionEnd=M+w},0)}}},[i,o,w]),W=i.split(`
14
+ `).length,y=pt[r]??"plain";return e.jsxs("div",{className:`nice-simple-code-editor nice-simple-code-editor--${q} ${U??""}`,style:{height:u,width:g},"data-testid":v,"data-language":r,"data-theme":q,children:[L&&e.jsx("div",{className:"nice-simple-code-editor__line-numbers",children:Array.from({length:W},(N,x)=>e.jsx("div",{className:"nice-simple-code-editor__line-number",children:x+1},x))}),e.jsxs("div",{className:"nice-simple-code-editor__editor-area",children:[e.jsx("pre",{ref:F,"aria-hidden":"true",className:`nice-simple-code-editor__highlight language-${y}`,children:e.jsx("code",{className:`language-${y}`,dangerouslySetInnerHTML:{__html:te+(i.endsWith(`
15
+ `)?`
16
+ `:"")}})}),e.jsx("textarea",{ref:K,className:"nice-simple-code-editor__textarea",value:i,onChange:N=>o?.(N.target.value),onKeyDown:C,onScroll:k,readOnly:S,placeholder:H,spellCheck:!1,autoCapitalize:"off",autoCorrect:"off"})]})]})}const Et="nice-code-editor-styles";if(typeof document<"u"&&!document.getElementById(Et)){const t=document.createElement("style");t.id=Et,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 li=Object.freeze(Object.defineProperty({__proto__:null,NiceCodeDiffEditor:sn,NiceCodeEditor:yt,NiceSimpleCodeEditor:rn},Symbol.toStringTag,{value:"Module"})),di=n.forwardRef(function(i,o){const{enableAI:r=!0,aiModel:u,enableInlineCompletion:g=!0,completionDelay:S=500,enableExplain:w=!0,enableRefactor:L=!0,enableGenerate:H=!0,systemPrompt:Y,onExplain:U,onRefactor:v,showAIToolbar:K=!0,aiShortcutKey:F="Ctrl",language:te="plaintext",value:B,onChange:q,...f}=i,k=n.useRef(null),[C,$]=n.useState(null),[W,y]=n.useState(!1),[N,x]=n.useState(""),[M,z]=n.useState(!1),[P,_]=n.useState(""),[d,A]=n.useState(""),[b,p]=n.useState(""),a=n.useRef(),{t:m}=ne.$o(),l=ne.ie(),{complete:c,explain:h,refactor:E,generateFromComment:Q,isLoading:D}=ne.kl({language:te,model:u}),ee=r&&l.isConfigured,ae=n.useCallback(async()=>{if(!ee||!g||!k.current||!k.current.getEditor())return;const le=k.current.getCursorPosition(),oe=k.current.getValue().split(`
271
+ `),I=oe.slice(0,le.lineNumber-1),j=oe[le.lineNumber-1]||"",X=[...I,j.slice(0,le.column-1)].join(`
272
+ `),re=[j.slice(le.column-1),...oe.slice(le.lineNumber)].join(`
273
+ `);try{const V=await c(X,re);V&&$({lineNumber:le.lineNumber,column:le.column,text:V})}catch{}},[ee,g,c]),O=n.useCallback(async()=>{if(!ee||!w||!k.current)return"";const ce=k.current.getSelection();if(!ce)return"";p(ce),y(!0),x("");try{const le=await h(ce);return x(le),U?.(ce,le),le}catch{return x(m("codeEditorAI.explanationFailed","Failed to explain code")),""}},[ee,w,h,U,m]),Z=n.useCallback(async ce=>{if(!ee||!L||!k.current)return"";const le=k.current.getSelection();if(!le)return"";try{const me=await E(le,ce);return A(me),v?.(le,me),me}catch{return""}},[ee,L,E,v]),ie=n.useCallback(async()=>{if(!ee||!H||!k.current)return;const ce=k.current.getCursorPosition(),me=k.current.getValue().split(`
274
+ `);let oe="";for(let I=ce.lineNumber-1;I>=0&&I>=ce.lineNumber-3;I--){const j=me[I]?.trim()||"";if(j.startsWith("//")||j.startsWith("#")||j.startsWith("/*")||j.startsWith("*")){oe=j.replace(/^\/\/\s*|^#\s*|^\/\*\s*|\*\/\s*$|^\*\s*/g,"").trim();break}}if(oe)try{const I=await Q(oe);I&&k.current&&k.current.insertText(`
275
+ `+I)}catch{}},[ee,H,Q]),de=n.useCallback(()=>{!C||!k.current||(k.current.insertText(C.text),$(null))},[C]),he=n.useCallback(()=>{$(null)},[]),pe=n.useCallback(ce=>{i.onCursorPositionChange?.(ce),!(!ee||!g)&&(a.current&&clearTimeout(a.current),$(null),a.current=setTimeout(()=>{ae()},S))},[i.onCursorPositionChange,ee,g,S,ae]);n.useEffect(()=>{if(!k.current?.getEditor()||!ee)return;const le=me=>{if(F==="Ctrl"&&me.ctrlKey||F==="Alt"&&me.altKey||F==="Meta"&&me.metaKey){if(me.key===" "&&g&&(me.preventDefault(),ae()),me.key==="e"&&w&&(me.preventDefault(),O()),me.key==="r"&&L){me.preventDefault();const I=k.current?.getSelection();I&&(p(I),z(!0))}me.key==="g"&&H&&(me.preventDefault(),ie())}me.key==="Tab"&&C&&(me.preventDefault(),de()),me.key==="Escape"&&C&&he()};return window.addEventListener("keydown",le),()=>window.removeEventListener("keydown",le)},[ee,F,g,w,L,H,ae,O,ie,C,de,he]),n.useEffect(()=>()=>{a.current&&clearTimeout(a.current)},[]);const xe=n.useCallback(()=>{if(!d||!k.current)return;const ce=k.current.getEditor();if(ce?.executeEdits&&ce?.getSelection){const le=ce.getSelection();ce.executeEdits("ai-refactor",[{range:le,text:d}])}z(!1),A(""),_("")},[d]);return n.useImperativeHandle(o,()=>({...k.current,getEditor:()=>k.current?.getEditor(),getMonaco:()=>k.current?.getMonaco(),focus:()=>k.current?.focus(),getValue:()=>k.current?.getValue()||"",setValue:ce=>k.current?.setValue(ce),getSelection:()=>k.current?.getSelection()||"",insertText:ce=>k.current?.insertText(ce),formatDocument:()=>k.current?.formatDocument(),goToLine:(ce,le)=>k.current?.goToLine(ce,le),findReplace:()=>k.current?.findReplace(),undo:()=>k.current?.undo(),redo:()=>k.current?.redo(),getCursorPosition:()=>k.current?.getCursorPosition()||{lineNumber:1,column:1},setMarkers:ce=>k.current?.setMarkers(ce),triggerCompletion:ae,explainSelection:O,refactorSelection:Z,generateFromComment:ie,acceptCompletion:de,dismissCompletion:he})),e.jsxs("div",{className:"nice-code-editor-ai","data-testid":i["data-testid"],children:[K&&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"}),D&&e.jsx("span",{className:"nice-code-editor-ai__loading",children:m("codeEditorAI.loading","Thinking...")})]}),e.jsxs("div",{className:"nice-code-editor-ai__toolbar-right",children:[g&&e.jsxs("button",{type:"button",className:"nice-code-editor-ai__toolbar-btn",onClick:()=>ae(),disabled:D,title:`${m("codeEditorAI.complete","Complete")} (${F}+Space)`,children:["💡 ",m("codeEditorAI.complete","Complete")]}),w&&e.jsxs("button",{type:"button",className:"nice-code-editor-ai__toolbar-btn",onClick:()=>O(),disabled:D,title:`${m("codeEditorAI.explain","Explain")} (${F}+E)`,children:["📖 ",m("codeEditorAI.explain","Explain")]}),L&&e.jsxs("button",{type:"button",className:"nice-code-editor-ai__toolbar-btn",onClick:()=>{const ce=k.current?.getSelection();ce&&(p(ce),z(!0))},disabled:D,title:`${m("codeEditorAI.refactor","Refactor")} (${F}+R)`,children:["🔧 ",m("codeEditorAI.refactor","Refactor")]}),H&&e.jsxs("button",{type:"button",className:"nice-code-editor-ai__toolbar-btn",onClick:()=>ie(),disabled:D,title:`${m("codeEditorAI.generate","Generate")} (${F}+G)`,children:["⚡ ",m("codeEditorAI.generate","Generate")]})]})]}),e.jsxs("div",{className:"nice-code-editor-ai__editor-wrapper",children:[e.jsx(yt,{ref:k,value:B,onChange:q,language:te,onCursorPositionChange:pe,...f}),C&&e.jsxs("div",{className:"nice-code-editor-ai__ghost-text",style:{top:`calc(${(C.lineNumber-1)*19}px + 4px)`,left:`calc(${(C.column-1)*7.8}px + 60px)`},children:[e.jsx("span",{className:"nice-code-editor-ai__ghost-text-content",children:C.text}),e.jsxs("span",{className:"nice-code-editor-ai__ghost-text-hint",children:["Tab ",m("codeEditorAI.toAccept","to accept")]})]})]}),W&&e.jsxs("div",{className:"nice-code-editor-ai__panel nice-code-editor-ai__panel--explain",children:[e.jsxs("div",{className:"nice-code-editor-ai__panel-header",children:[e.jsxs("h4",{children:["📖 ",m("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:D?e.jsx("div",{className:"nice-code-editor-ai__panel-loading",children:m("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:b}),e.jsx("div",{className:"nice-code-editor-ai__explanation-text",children:N||m("codeEditorAI.noExplanation","Select code and click Explain")})]})})]}),M&&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:["🔧 ",m("codeEditorAI.refactorCode","Refactor Code")]}),e.jsx("button",{type:"button",className:"nice-code-editor-ai__panel-close",onClick:()=>{z(!1),A(""),_("")},children:"✕"})]}),e.jsxs("div",{className:"nice-code-editor-ai__panel-body",children:[e.jsx("pre",{className:"nice-code-editor-ai__code-preview",children:b}),e.jsxs("div",{className:"nice-code-editor-ai__refactor-input",children:[e.jsx("input",{type:"text",placeholder:m("codeEditorAI.refactorInstruction",'Describe how to refactor (e.g., "extract function", "add error handling")'),value:P,onChange:ce=>_(ce.target.value),onKeyDown:ce=>{ce.key==="Enter"&&P&&Z(P)}}),e.jsx("button",{type:"button",className:"nice-code-editor-ai__refactor-btn",onClick:()=>Z(P),disabled:D||!P,children:D?m("codeEditorAI.refactoring","Refactoring..."):m("codeEditorAI.refactor","Refactor")})]}),d&&e.jsxs("div",{className:"nice-code-editor-ai__refactor-result",children:[e.jsx("h5",{children:m("codeEditorAI.refactoredCode","Refactored Code")}),e.jsx("pre",{className:"nice-code-editor-ai__code-preview nice-code-editor-ai__code-preview--result",children:d}),e.jsxs("div",{className:"nice-code-editor-ai__refactor-actions",children:[e.jsxs("button",{type:"button",className:"nice-code-editor-ai__refactor-apply",onClick:xe,children:["✓ ",m("codeEditorAI.apply","Apply")]}),e.jsxs("button",{type:"button",className:"nice-code-editor-ai__refactor-discard",onClick:()=>{A(""),_("")},children:["✕ ",m("codeEditorAI.discard","Discard")]})]})]})]})]})]})});function Tt(t,i){const o=i.getBoundingClientRect();let r,u,g;if("touches"in t){const S=t.touches[0];r=S.clientX-o.left,u=S.clientY-o.top,g=S.force}else"pressure"in t?(r=t.clientX-o.left,u=t.clientY-o.top,g=t.pressure):(r=t.clientX-o.left,u=t.clientY-o.top);return{x:r,y:u,time:Date.now(),pressure:g!==void 0?g:.5}}function Rt(t,i,o,r,u){if(!i)return(o+r)/2;const g=Math.sqrt(Math.pow(t.x-i.x,2)+Math.pow(t.y-i.y,2))/Math.max(1,t.time-i.time),S=Math.min(g/5,1),w=r-S*(r-o),L=t.pressure??.5,H=o+L*(r-o);return w*.7+H*.3}function It(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 mi=n.forwardRef(function(i,o){const{value:r,onChange:u,width:g="100%",height:S=200,penColor:w="var(--text-primary, #000000)",penWidth:L=2,minWidth:H=.5,maxWidth:Y=4,backgroundColor:U="var(--bg-primary, #ffffff)",placeholder:v="Sign here",showClearButton:K=!0,showUndoButton:F=!0,showColorPicker:te=!1,showSizeSlider:B=!1,velocityFilterWeight:q=.7,throttle:f=16,disabled:k=!1,readOnly:C=!1,displayMode:$=!1,onBegin:W,onEnd:y,className:N,"data-testid":x}=i,M=C||$,z=$?!1:K,P=$?!1:F,_=$?!1:te,d=$?!1:B,A=n.useRef(null),[b,p]=n.useState(r?.strokes??[]),[a,m]=n.useState([]),[l,c]=n.useState(!1),[h,E]=n.useState(w),[Q,D]=n.useState(L),ee=n.useRef(null),ae=n.useRef(0),O=b.length===0&&a.length===0;n.useEffect(()=>{const I=A.current;if(!I)return;const j=I.getContext("2d");if(!j)return;const X=I.getBoundingClientRect(),re=window.devicePixelRatio||1;I.width=X.width*re,I.height=X.height*re,j.scale(re,re),Z()},[g,S]);const Z=n.useCallback(()=>{const I=A.current;if(!I)return;const j=I.getContext("2d");if(!j)return;const X=I.getBoundingClientRect();j.fillStyle=U,j.fillRect(0,0,X.width,X.height),b.forEach(re=>{if(j.strokeStyle=re.color,!(re.points.length<2))for(let V=1;V<re.points.length;V++){const R=re.points[V-1],J=re.points[V],ge=Rt(J,R,H,Y);It(j,R,J,ge)}})},[b,U,H,Y,q]);n.useEffect(()=>{Z()},[Z]),n.useEffect(()=>{r?.strokes&&p(r.strokes)},[r]),n.useEffect(()=>{const I=A.current;if(I)if(b.length===0)u?.(null);else{const j=I.getBoundingClientRect();u?.({strokes:b,width:j.width,height:j.height,timestamp:Date.now()})}},[b,u]);const ie=n.useCallback(I=>{if(k||M)return;const j=A.current;if(!j)return;j.setPointerCapture(I.pointerId);const X=Tt(I.nativeEvent,j);c(!0),m([X]),ee.current=X,ae.current=X.time,W?.()},[k,M,W]),de=n.useCallback(I=>{if(!l||k||M)return;const j=A.current;if(!j)return;const X=j.getContext("2d");if(!X)return;const re=Date.now();if(re-ae.current<f)return;const V=Tt(I.nativeEvent,j),R=ee.current;if(R){X.strokeStyle=h;const J=Rt(V,R,H,Y);It(X,R,V,J)}m(J=>[...J,V]),ee.current=V,ae.current=re},[l,k,M,h,H,Y,q,f]),he=n.useCallback(I=>{if(!l)return;const j=A.current;if(j&&j.releasePointerCapture(I.pointerId),a.length>0){const X={points:a,color:h,width:Q};p(re=>[...re,X])}c(!1),m([]),ee.current=null,y?.()},[l,a,h,Q,y]),pe=n.useCallback(()=>{p([]),m([]),Z()},[Z]),xe=n.useCallback(()=>{p(I=>I.slice(0,-1))},[]),ce=n.useCallback((I="png",j=.92)=>{const X=A.current;if(!X)return"";const re=I==="jpeg"?"image/jpeg":"image/png";return X.toDataURL(re,j)},[]),le=n.useCallback(async(I="png",j=.92)=>{const X=A.current;return X?new Promise(re=>{const V=I==="jpeg"?"image/jpeg":"image/png";X.toBlob(R=>re(R),V,j)}):null},[]),me=n.useCallback(()=>{const I=A.current;if(!I)return"";const j=I.getBoundingClientRect(),X=b.map(re=>re.points.length<2?"":`<path d="${re.points.reduce((R,J,ge)=>ge===0?`M ${J.x} ${J.y}`:`${R} L ${J.x} ${J.y}`,"")}" stroke="${re.color}" stroke-width="${re.width}" fill="none" stroke-linecap="round" stroke-linejoin="round"/>`).join(`
276
+ `);return`<svg xmlns="http://www.w3.org/2000/svg" width="${j.width}" height="${j.height}" viewBox="0 0 ${I.width} ${I.height}">
277
+ <rect width="100%" height="100%" fill="${U}"/>
278
+ ${X}
279
+ </svg>`},[b,U]);n.useImperativeHandle(o,()=>({clear:pe,undo:xe,isEmpty:()=>b.length===0,getData:()=>{const I=A.current;if(!I||b.length===0)return null;const j=I.getBoundingClientRect();return{strokes:b,width:j.width,height:j.height,timestamp:Date.now()}},setData:I=>{p(I.strokes)},toDataURL:ce,toBlob:le,toSVG:me,getCanvas:()=>A.current}),[b,pe,xe,ce,le,me]),n.useEffect(()=>{const I=A.current;if(!I)return;const j=X=>{l&&X.preventDefault()};return I.addEventListener("touchmove",j,{passive:!1}),()=>I.removeEventListener("touchmove",j)},[l]);const oe=z||P||_||d;return e.jsxs("div",{className:`nice-signature ${k?"nice-signature--disabled":""} ${M?"nice-signature--readonly":""} ${N??""}`,style:{width:g},"data-testid":x,children:[oe&&e.jsxs("div",{className:"nice-signature__toolbar",children:[_&&e.jsx("div",{className:"nice-signature__color-picker",children:e.jsx("input",{type:"color",value:h,onChange:I=>E(I.target.value),disabled:k||M,title:"Pen color"})}),d&&e.jsx("div",{className:"nice-signature__size-slider",children:e.jsx("input",{type:"range",min:H,max:Y,step:.5,value:Q,onChange:I=>D(parseFloat(I.target.value)),disabled:k||M,title:"Pen size"})}),e.jsxs("div",{className:"nice-signature__actions",children:[P&&e.jsx("button",{type:"button",onClick:xe,disabled:k||M||b.length===0,className:"nice-signature__btn",title:"Undo",children:"↩️"}),z&&e.jsx("button",{type:"button",onClick:pe,disabled:k||M||O,className:"nice-signature__btn",title:"Clear",children:"🗑️"})]})]}),e.jsxs("div",{className:"nice-signature__canvas-wrapper",style:{height:S},children:[e.jsx("canvas",{ref:A,className:"nice-signature__canvas",style:{width:"100%",height:"100%",cursor:k||M?"not-allowed":"crosshair",touchAction:"none"},onPointerDown:ie,onPointerMove:de,onPointerUp:he,onPointerLeave:he}),O&&!l&&v&&e.jsx("div",{className:"nice-signature__placeholder",children:v}),e.jsx("div",{className:"nice-signature__line"})]})]})}),At="nice-signature-styles";if(typeof document<"u"&&!document.getElementById(At)){const t=document.createElement("style");t.id=At,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 ui={recent:"🕒",smileys:"😀",people:"👋",animals:"🐱",food:"🍕",travel:"✈️",activities:"⚽",objects:"💡",symbols:"❤️",flags:"🏳️"},Dt={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=["","🏻","🏼","🏽","🏾","🏿"],Qe=[{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"}],Lt="nice-emoji-picker-recent",cn=({onSelect:t,showSearch:i=!0,searchPlaceholder:o,showSkinTones:r=!0,defaultSkinTone:u=0,showRecent:g=!0,maxRecent:S=24,recentEmojis:w,onRecentChange:L,categories:H,customEmojis:Y=[],columns:U=8,size:v="md",className:K="",style:F,"data-testid":te="nice-emoji-picker"})=>{const{t:B}=ne.$o(),[q,f]=n.useState(""),[k,C]=n.useState(g?"recent":"smileys"),[$,W]=n.useState(u),[y,N]=n.useState(!1),x=n.useRef(null),[M,z]=n.useState(()=>{if(typeof window>"u")return[];try{return JSON.parse(localStorage.getItem(Lt)||"[]")}catch{return[]}}),P=w??M,_=H??[...g?["recent"]:[],"smileys","people","animals","food","travel","activities","objects","symbols","flags"],d=n.useMemo(()=>{if(!q)return Qe;const l=q.toLowerCase();return Qe.filter(c=>c.name.toLowerCase().includes(l)||c.emoji.includes(l)||c.keywords?.some(h=>h.toLowerCase().includes(l)))},[q]),A=n.useMemo(()=>{const l={};for(const c of _)c==="recent"?l[c]=P.map(h=>Qe.find(E=>E.emoji===h)).filter(h=>h!==void 0).slice(0,S):l[c]=d.filter(h=>h.category===c);return l},[_,d,P,S]),b=n.useCallback((l,c)=>!c||$===0?l:l.replace(/[\u{1F3FB}-\u{1F3FF}]/gu,"")+lt[$],[$]),p=n.useCallback(l=>{const c=b(l.emoji,l.skinTones),h=[l.emoji,...P.filter(E=>E!==l.emoji)].slice(0,S);if(w===void 0){z(h);try{localStorage.setItem(Lt,JSON.stringify(h))}catch{}}L?.(h),t?.(c,l)},[b,P,S,w,L,t]),a=n.useCallback(l=>{t?.(`:${l.name}:`,l)},[t]);n.useEffect(()=>{if(!y)return;const l=c=>{x.current&&!x.current.contains(c.target)&&N(!1)};return document.addEventListener("mousedown",l),()=>document.removeEventListener("mousedown",l)},[y]);const m=q?d:A[k]||[];return e.jsxs("div",{className:`nice-emoji-picker nice-emoji-picker--${v} ${K}`,style:F,"data-testid":te,children:[i&&e.jsxs("div",{className:"nice-emoji-picker__search",children:[e.jsx("input",{type:"text",value:q,onChange:l=>f(l.target.value),placeholder:o??B("search","Search emoji..."),className:"nice-emoji-picker__search-input","data-testid":`${te}-search`}),r&&e.jsxs("div",{className:"nice-emoji-picker__skin-tone-wrapper",children:[e.jsxs("button",{ref:x,type:"button",className:"nice-emoji-picker__skin-tone-btn",onClick:()=>N(!y),title:B("skinTone","Skin tone"),children:["✋",lt[$]]}),y&&e.jsx("div",{className:"nice-emoji-picker__skin-tone-menu",children:lt.map((l,c)=>e.jsxs("button",{type:"button",className:`nice-emoji-picker__skin-tone-option ${c===$?"nice-emoji-picker__skin-tone-option--selected":""}`,onClick:()=>{W(c),N(!1)},children:["✋",l]},c))})]})]}),!q&&e.jsx("div",{className:"nice-emoji-picker__categories",role:"tablist",children:_.map(l=>e.jsx("button",{type:"button",className:`nice-emoji-picker__category-btn ${k===l?"nice-emoji-picker__category-btn--selected":""}`,onClick:()=>C(l),title:Dt[l],role:"tab","aria-selected":k===l,children:ui[l]},l))}),e.jsxs("div",{className:"nice-emoji-picker__grid-container",children:[q?e.jsxs("div",{className:"nice-emoji-picker__section",children:[e.jsx("div",{className:"nice-emoji-picker__section-title",children:B("searchResults","Search Results")}),e.jsx("div",{className:"nice-emoji-picker__grid",style:{gridTemplateColumns:`repeat(${U}, 1fr)`},children:d.length===0?e.jsx("div",{className:"nice-emoji-picker__empty",children:B("noEmojis","No emojis found")}):d.map((l,c)=>e.jsx("button",{type:"button",className:"nice-emoji-picker__emoji",onClick:()=>p(l),title:l.name,children:b(l.emoji,l.skinTones)},`${l.emoji}-${c}`))})]}):e.jsxs("div",{className:"nice-emoji-picker__section",children:[e.jsx("div",{className:"nice-emoji-picker__section-title",children:Dt[k]}),e.jsx("div",{className:"nice-emoji-picker__grid",style:{gridTemplateColumns:`repeat(${U}, 1fr)`},children:m.length===0?e.jsx("div",{className:"nice-emoji-picker__empty",children:k==="recent"?B("noRecent","No recent emojis"):B("noEmojis","No emojis")}):m.map((l,c)=>e.jsx("button",{type:"button",className:"nice-emoji-picker__emoji",onClick:()=>p(l),title:l.name,children:b(l.emoji,l.skinTones)},`${l.emoji}-${c}`))})]}),Y.length>0&&e.jsxs("div",{className:"nice-emoji-picker__section",children:[e.jsx("div",{className:"nice-emoji-picker__section-title",children:B("custom","Custom")}),e.jsx("div",{className:"nice-emoji-picker__grid",style:{gridTemplateColumns:`repeat(${U}, 1fr)`},children:Y.map(l=>e.jsx("button",{type:"button",className:"nice-emoji-picker__emoji nice-emoji-picker__emoji--custom",onClick:()=>a(l),title:l.name,children:e.jsx("img",{src:l.url,alt:l.name})},l.id))})]})]})]})};cn.displayName="NiceEmojiPicker";const ln=[{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}],dn=({src:t,initialCrop:i={x:10,y:10,width:80,height:80},initialRotation:o=0,initialZoom:r=1,aspectRatios:u=ln,defaultAspectRatio:g="free",customAspectRatio:S,showRotation:w=!0,showFlip:L=!0,showZoom:H=!0,minZoom:Y=.5,maxZoom:U=3,zoomStep:v=.1,showGrid:K=!0,overlayColor:F="var(--nice-overlay-50, rgba(0, 0, 0, 0.5))",toolbarPosition:te="bottom",toolbarCollapsible:B=!1,defaultToolbarCollapsed:q=!1,onChange:f,className:k="",style:C,"data-testid":$="nice-crop-editor"})=>{const{t:W}=ne.$o(),y=n.useRef(null),N=n.useRef(null),[x,M]=n.useState(i),[z,P]=n.useState(o),[_,d]=n.useState(r),[A,b]=n.useState(!1),[p,a]=n.useState(!1),[m,l]=n.useState(g),[c,h]=n.useState(q),[E,Q]=n.useState(!1),[D,ee]=n.useState({x:0,y:0,crop:x}),ae=m==="custom"?S:u.find(j=>j.value===m)?.ratio;n.useEffect(()=>{f?.({crop:x,rotation:z,flipH:A,flipV:p,zoom:_})},[x,z,A,p,_,f]);const O=n.useCallback((j,X)=>{if(!ae)return j;const re=y.current?.clientWidth??400,V=y.current?.clientHeight??300,R=j.width/100*re,J=j.height/100*V,ge=R/J;if(Math.abs(ge-ae)<.01)return j;if(X?.includes("e")||X?.includes("w")){const ye=R/ae/V*100;return{...j,height:Math.min(100-j.y,Math.max(5,ye))}}else if(X?.includes("n")||X?.includes("s")){const ye=J*ae/re*100;return{...j,width:Math.min(100-j.x,Math.max(5,ye))}}else{const ye=R/ae/V*100;return{...j,height:Math.min(100-j.y,Math.max(5,ye))}}},[ae]),Z=n.useCallback((j,X)=>{X===!1||(j.preventDefault(),j.stopPropagation(),Q(X),!y.current?.getBoundingClientRect())||ee({x:j.clientX,y:j.clientY,crop:{...x}})},[x]),ie=n.useCallback(j=>{if(!E||!y.current)return;const X=y.current.getBoundingClientRect(),re=(j.clientX-D.x)/X.width*100,V=(j.clientY-D.y)/X.height*100;let R={...D.crop};if(E==="crop")R.x=Math.max(0,Math.min(100-R.width,D.crop.x+re)),R.y=Math.max(0,Math.min(100-R.height,D.crop.y+V));else{switch(E){case"resize-nw":R.x=Math.max(0,Math.min(D.crop.x+D.crop.width-5,D.crop.x+re)),R.y=Math.max(0,Math.min(D.crop.y+D.crop.height-5,D.crop.y+V)),R.width=D.crop.width-(R.x-D.crop.x),R.height=D.crop.height-(R.y-D.crop.y);break;case"resize-ne":R.y=Math.max(0,Math.min(D.crop.y+D.crop.height-5,D.crop.y+V)),R.width=Math.max(5,Math.min(100-R.x,D.crop.width+re)),R.height=D.crop.height-(R.y-D.crop.y);break;case"resize-sw":R.x=Math.max(0,Math.min(D.crop.x+D.crop.width-5,D.crop.x+re)),R.width=D.crop.width-(R.x-D.crop.x),R.height=Math.max(5,Math.min(100-R.y,D.crop.height+V));break;case"resize-se":R.width=Math.max(5,Math.min(100-R.x,D.crop.width+re)),R.height=Math.max(5,Math.min(100-R.y,D.crop.height+V));break;case"resize-n":R.y=Math.max(0,Math.min(D.crop.y+D.crop.height-5,D.crop.y+V)),R.height=D.crop.height-(R.y-D.crop.y);break;case"resize-s":R.height=Math.max(5,Math.min(100-R.y,D.crop.height+V));break;case"resize-e":R.width=Math.max(5,Math.min(100-R.x,D.crop.width+re));break;case"resize-w":R.x=Math.max(0,Math.min(D.crop.x+D.crop.width-5,D.crop.x+re)),R.width=D.crop.width-(R.x-D.crop.x);break}R=O(R,E.replace("resize-",""))}M(R)},[E,D,O]),de=n.useCallback(()=>{Q(!1)},[]);n.useEffect(()=>{if(E)return document.addEventListener("mousemove",ie),document.addEventListener("mouseup",de),()=>{document.removeEventListener("mousemove",ie),document.removeEventListener("mouseup",de)}},[E,ie,de]);const he=n.useCallback(()=>{P(j=>(j-90+360)%360)},[]),pe=n.useCallback(()=>{P(j=>(j+90)%360)},[]),xe=n.useCallback(()=>{b(j=>!j)},[]),ce=n.useCallback(()=>{a(j=>!j)},[]),le=n.useCallback(()=>{M(i),P(o),d(r),b(!1),a(!1),l(g)},[i,o,r,g]);n.useEffect(()=>{M(j=>O(j))},[m,O]);const me=`scale(${_}) rotate(${z}deg) scaleX(${A?-1:1}) scaleY(${p?-1:1})`,oe=te==="top"?"column-reverse":te==="left"?"row-reverse":te==="right"?"row":"column",I=te==="left"||te==="right";return e.jsxs("div",{className:`nice-crop-editor nice-crop-editor--toolbar-${te} ${k}`,style:{display:"flex",flexDirection:oe,gap:12,...C},"data-testid":$,children:[e.jsxs("div",{ref:y,className:"nice-crop-editor__container","data-testid":`${$}-container`,children:[e.jsx("img",{ref:N,src:t,alt:"",className:"nice-crop-editor__image",style:{transform:me},draggable:!1}),e.jsxs("div",{className:"nice-crop-editor__overlay",style:{backgroundColor:F},children:[e.jsx("div",{className:"nice-crop-editor__overlay-piece",style:{top:0,left:0,right:0,height:`${x.y}%`}}),e.jsx("div",{className:"nice-crop-editor__overlay-piece",style:{bottom:0,left:0,right:0,height:`${100-x.y-x.height}%`}}),e.jsx("div",{className:"nice-crop-editor__overlay-piece",style:{top:`${x.y}%`,left:0,width:`${x.x}%`,height:`${x.height}%`}}),e.jsx("div",{className:"nice-crop-editor__overlay-piece",style:{top:`${x.y}%`,right:0,width:`${100-x.x-x.width}%`,height:`${x.height}%`}})]}),e.jsxs("div",{className:"nice-crop-editor__crop-area",style:{left:`${x.x}%`,top:`${x.y}%`,width:`${x.width}%`,height:`${x.height}%`},onMouseDown:j=>Z(j,"crop"),"data-testid":`${$}-crop-area`,children:[K&&e.jsxs("div",{className:"nice-crop-editor__grid",children:[e.jsx("div",{className:"nice-crop-editor__grid-line nice-crop-editor__grid-line--h1"}),e.jsx("div",{className:"nice-crop-editor__grid-line nice-crop-editor__grid-line--h2"}),e.jsx("div",{className:"nice-crop-editor__grid-line nice-crop-editor__grid-line--v1"}),e.jsx("div",{className:"nice-crop-editor__grid-line nice-crop-editor__grid-line--v2"})]}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--nw",onMouseDown:j=>Z(j,"resize-nw")}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--ne",onMouseDown:j=>Z(j,"resize-ne")}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--sw",onMouseDown:j=>Z(j,"resize-sw")}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--se",onMouseDown:j=>Z(j,"resize-se")}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--n",onMouseDown:j=>Z(j,"resize-n")}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--s",onMouseDown:j=>Z(j,"resize-s")}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--e",onMouseDown:j=>Z(j,"resize-e")}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--w",onMouseDown:j=>Z(j,"resize-w")})]})]}),e.jsxs("div",{className:`nice-crop-editor__controls ${c?"nice-crop-editor__controls--collapsed":""}`,style:{display:"flex",flexDirection:I?"column":"row",flexWrap:I?"nowrap":"wrap",gap:8,alignItems:I?"stretch":"center",flexShrink:0},children:[B&&e.jsx("button",{type:"button",className:"nice-crop-editor__toolbar-toggle","aria-expanded":!c,"aria-label":c?"Show toolbar":"Hide toolbar",onClick:()=>h(j=>!j),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:c?"▸":"▾"}),!c&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"nice-crop-editor__control-group",children:[e.jsx("label",{className:"nice-crop-editor__label",children:W("aspectRatio","Aspect Ratio")}),e.jsx("div",{className:"nice-crop-editor__aspect-buttons",children:u.map(j=>e.jsx("button",{type:"button",className:`nice-crop-editor__aspect-btn ${m===j.value?"nice-crop-editor__aspect-btn--selected":""}`,onClick:()=>l(j.value),title:j.label,children:j.label},j.value))})]}),H&&e.jsxs("div",{className:"nice-crop-editor__control-group",children:[e.jsxs("label",{className:"nice-crop-editor__label",children:[W("zoom","Zoom"),": ",Math.round(_*100),"%"]}),e.jsx("input",{type:"range",className:"nice-crop-editor__slider",min:Y,max:U,step:v,value:_,onChange:j=>d(parseFloat(j.target.value)),"data-testid":`${$}-zoom`})]}),e.jsxs("div",{className:"nice-crop-editor__control-group nice-crop-editor__control-group--row",children:[w&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"nice-crop-editor__btn",onClick:he,title:W("rotateLeft","Rotate Left"),children:"↺"}),e.jsx("button",{type:"button",className:"nice-crop-editor__btn",onClick:pe,title:W("rotateRight","Rotate Right"),children:"↻"})]}),L&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:`nice-crop-editor__btn ${A?"nice-crop-editor__btn--active":""}`,onClick:xe,title:W("flipHorizontal","Flip Horizontal"),children:"⇆"}),e.jsx("button",{type:"button",className:`nice-crop-editor__btn ${p?"nice-crop-editor__btn--active":""}`,onClick:ce,title:W("flipVertical","Flip Vertical"),children:"⇅"})]}),e.jsx("button",{type:"button",className:"nice-crop-editor__btn nice-crop-editor__btn--reset",onClick:le,title:W("reset","Reset"),children:"⟲"})]})]})]})]})};dn.displayName="NiceCropEditor";const pi={strokeColor:"#ff3333",fillColor:"transparent",strokeWidth:2,opacity:1,fontSize:16,fontFamily:"sans-serif"};function hi(t,i){switch(i.type){case"SET_TOOL":return{...t,activeTool:i.tool,selectedId:null};case"SET_STYLE":return{...t,style:{...t.style,...i.style}};case"ADD_ANNOTATION":return{...t,annotations:[...t.annotations,i.annotation],past:[...t.past,t.annotations],future:[]};case"UPDATE_ANNOTATION":return{...t,annotations:t.annotations.map(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 gi=0;function fi(){return`ann-${Date.now()}-${gi++}`}function yi(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,u=t.y+t.height/2;return`<ellipse cx="${r}" cy="${u}" rx="${t.width/2}" ry="${t.height/2}" ${o} />`}case"arrow":{const r=t,u=Math.atan2(r.endY-r.y,r.endX-r.x),g=12,S=r.endX-g*Math.cos(u-Math.PI/6),w=r.endY-g*Math.sin(u-Math.PI/6),L=r.endX-g*Math.cos(u+Math.PI/6),H=r.endY-g*Math.sin(u+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} ${S},${w} ${L},${H}" 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}">${bi(r.text)}</text>`}case"freehand":{const r=t;return r.points.length<2?"":`<path d="${r.points.map((g,S)=>`${S===0?"M":"L"}${g.x},${g.y}`).join(" ")}" ${o} fill="none" />`}case"blur":{const r=t,u=`blur-${r.id}`;return`<defs><filter id="${u}"><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(#${u})" />`}default:return""}}function bi(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}const mn=n.forwardRef(({src:t,alt:i="Annotatable image",annotations:o,activeTool:r,defaultStyle:u,onAnnotationsChange:g,className:S,readOnly:w=!1,minZoom:L=.1,maxZoom:H=5},Y)=>{const U=n.useRef(null),v=n.useRef(null),K=n.useRef(null),[F,te]=n.useState(!1),[B,q]=n.useState({width:0,height:0}),[f,k]=n.useReducer(hi,{annotations:o??[],selectedId:null,activeTool:r??"select",style:{...pi,...u},zoom:1,panX:0,panY:0,past:[],future:[]});n.useEffect(()=>{r&&k({type:"SET_TOOL",tool:r})},[r]),n.useEffect(()=>{g?.(f.annotations)},[f.annotations,g]),n.useEffect(()=>{const _=new Image;_.crossOrigin="anonymous",_.onload=()=>{K.current=_,q({width:_.naturalWidth,height:_.naturalHeight}),te(!0)},_.src=t},[t]);const C=n.useRef({isDrawing:!1,startX:0,startY:0,currentAnnotation:null,freehandPoints:[]}),$=n.useCallback((_,d)=>{const A=U.current;if(!A)return{x:0,y:0};const b=A.getBoundingClientRect();return{x:(_-b.left-f.panX)/f.zoom,y:(d-b.top-f.panY)/f.zoom}},[f.zoom,f.panX,f.panY]),W=n.useCallback(()=>{const _=U.current,d=_?.getContext("2d"),A=K.current;if(!_||!d||!A||!F)return;_.width=v.current?.clientWidth??A.naturalWidth,_.height=v.current?.clientHeight??A.naturalHeight,d.clearRect(0,0,_.width,_.height),d.save(),d.translate(f.panX,f.panY),d.scale(f.zoom,f.zoom),d.drawImage(A,0,0);for(const p of f.annotations){switch(d.save(),d.globalAlpha=p.style.opacity,d.strokeStyle=p.style.strokeColor,d.fillStyle=p.style.fillColor,d.lineWidth=p.style.strokeWidth,p.tool){case"rectangle":d.strokeRect(p.x,p.y,p.width,p.height),p.style.fillColor!=="transparent"&&d.fillRect(p.x,p.y,p.width,p.height);break;case"ellipse":{d.beginPath(),d.ellipse(p.x+p.width/2,p.y+p.height/2,Math.abs(p.width/2),Math.abs(p.height/2),0,0,Math.PI*2),d.stroke(),p.style.fillColor!=="transparent"&&d.fill();break}case"arrow":{const a=p;d.beginPath(),d.moveTo(a.x,a.y),d.lineTo(a.endX,a.endY),d.stroke();const m=Math.atan2(a.endY-a.y,a.endX-a.x),l=12;d.beginPath(),d.moveTo(a.endX,a.endY),d.lineTo(a.endX-l*Math.cos(m-Math.PI/6),a.endY-l*Math.sin(m-Math.PI/6)),d.lineTo(a.endX-l*Math.cos(m+Math.PI/6),a.endY-l*Math.sin(m+Math.PI/6)),d.closePath(),d.fillStyle=p.style.strokeColor,d.fill();break}case"line":{const a=p;d.beginPath(),d.moveTo(a.x,a.y),d.lineTo(a.endX,a.endY),d.stroke();break}case"text":{const a=p;d.font=`${a.style.fontSize??16}px ${a.style.fontFamily??"sans-serif"}`,d.fillStyle=a.style.strokeColor,d.fillText(a.text,a.x,a.y+(a.style.fontSize??16));break}case"freehand":{const a=p;if(a.points.length<2)break;d.beginPath(),d.moveTo(a.points[0].x,a.points[0].y);for(let m=1;m<a.points.length;m++)d.lineTo(a.points[m].x,a.points[m].y);d.stroke();break}case"blur":{const a=p;d.filter=`blur(${a.intensity??5}px)`,d.drawImage(A,a.x,a.y,a.width,a.height,a.x,a.y,a.width,a.height),d.filter="none";break}}p.id===f.selectedId&&(d.strokeStyle="#4488ff",d.lineWidth=1,d.setLineDash([4,4]),d.strokeRect(p.x-2,p.y-2,p.width+4,p.height+4),d.setLineDash([])),d.restore()}const b=C.current;if(b.isDrawing&&b.currentAnnotation){d.save();const p=b.currentAnnotation;if(d.globalAlpha=p.style.opacity,d.strokeStyle=p.style.strokeColor,d.lineWidth=p.style.strokeWidth,d.setLineDash([6,3]),p.tool==="freehand"){const a=p;if(a.points.length>=2){d.beginPath(),d.moveTo(a.points[0].x,a.points[0].y);for(let m=1;m<a.points.length;m++)d.lineTo(a.points[m].x,a.points[m].y);d.stroke()}}else if(p.tool==="rectangle")d.strokeRect(p.x,p.y,p.width,p.height);else if(p.tool==="ellipse")d.beginPath(),d.ellipse(p.x+p.width/2,p.y+p.height/2,Math.abs(p.width/2),Math.abs(p.height/2),0,0,Math.PI*2),d.stroke();else if(p.tool==="arrow"||p.tool==="line"){const a=p;d.beginPath(),d.moveTo(a.x,a.y),d.lineTo(a.endX,a.endY),d.stroke()}d.restore()}d.restore()},[f,F]);n.useEffect(()=>{W()},[W]);const y=n.useCallback(_=>{if(w)return;const d=$(_.clientX,_.clientY),A=f.activeTool;if(A==="select"){const a=[...f.annotations].reverse().find(m=>m.tool==="freehand"?!1:d.x>=m.x&&d.x<=m.x+m.width&&d.y>=m.y&&d.y<=m.y+m.height);k({type:"SELECT",id:a?.id??null});return}const b=C.current;b.isDrawing=!0,b.startX=d.x,b.startY=d.y;const p={id:fi(),style:{...f.style},x:d.x,y:d.y,width:0,height:0};switch(A){case"rectangle":b.currentAnnotation={...p,tool:"rectangle"};break;case"ellipse":b.currentAnnotation={...p,tool:"ellipse"};break;case"arrow":b.currentAnnotation={...p,tool:"arrow",endX:d.x,endY:d.y};break;case"line":b.currentAnnotation={...p,tool:"line",endX:d.x,endY:d.y};break;case"text":b.currentAnnotation={...p,tool:"text",text:"Text",width:100,height:f.style.fontSize??16};break;case"freehand":b.freehandPoints=[d],b.currentAnnotation={...p,tool:"freehand",points:[d]};break;case"blur":b.currentAnnotation={...p,tool:"blur",intensity:5};break}},[w,$,f.activeTool,f.style,f.annotations]),N=n.useCallback(_=>{const d=C.current;if(!d.isDrawing||!d.currentAnnotation)return;const A=$(_.clientX,_.clientY),b=d.currentAnnotation;if(b.tool==="freehand"){d.freehandPoints.push(A),b.points=[...d.freehandPoints];const p=d.freehandPoints.map(m=>m.x),a=d.freehandPoints.map(m=>m.y);b.x=Math.min(...p),b.y=Math.min(...a),b.width=Math.max(...p)-b.x,b.height=Math.max(...a)-b.y}else if(b.tool==="arrow"||b.tool==="line")b.endX=A.x,b.endY=A.y,b.width=Math.abs(A.x-d.startX),b.height=Math.abs(A.y-d.startY);else{const p=Math.min(d.startX,A.x),a=Math.min(d.startY,A.y);b.x=p,b.y=a,b.width=Math.abs(A.x-d.startX),b.height=Math.abs(A.y-d.startY)}W()},[$,W]),x=n.useCallback(()=>{const _=C.current;if(!_.isDrawing||!_.currentAnnotation)return;const d=_.currentAnnotation;(d.tool==="text"||d.tool==="freehand"||Math.abs(d.width)>2||Math.abs(d.height)>2)&&k({type:"ADD_ANNOTATION",annotation:d}),_.isDrawing=!1,_.currentAnnotation=null,_.freehandPoints=[]},[]),M=n.useCallback(_=>{_.preventDefault();const d=_.deltaY>0?.9:1.1,A=Math.max(L,Math.min(H,f.zoom*d));k({type:"SET_ZOOM",zoom:A})},[f.zoom,L,H]);n.useEffect(()=>{if(w)return;const _=d=>{(d.metaKey||d.ctrlKey)&&d.key==="z"&&!d.shiftKey?(d.preventDefault(),k({type:"UNDO"})):(d.metaKey||d.ctrlKey)&&(d.key==="y"||d.key==="z"&&d.shiftKey)?(d.preventDefault(),k({type:"REDO"})):(d.key==="Delete"||d.key==="Backspace")&&f.selectedId&&k({type:"DELETE_ANNOTATION",id:f.selectedId})};return document.addEventListener("keydown",_),()=>document.removeEventListener("keydown",_)},[w,f.selectedId]),n.useImperativeHandle(Y,()=>({exportAsDataURL:async(_="png",d=.92)=>{const A=document.createElement("canvas"),b=K.current;if(!b)return"";A.width=b.naturalWidth,A.height=b.naturalHeight;const p=A.getContext("2d");p.drawImage(b,0,0);for(const a of f.annotations){if(p.save(),p.globalAlpha=a.style.opacity,p.strokeStyle=a.style.strokeColor,p.fillStyle=a.style.fillColor,p.lineWidth=a.style.strokeWidth,a.tool==="rectangle")p.strokeRect(a.x,a.y,a.width,a.height);else if(a.tool==="ellipse")p.beginPath(),p.ellipse(a.x+a.width/2,a.y+a.height/2,Math.abs(a.width/2),Math.abs(a.height/2),0,0,Math.PI*2),p.stroke();else if(a.tool==="freehand"){const m=a;if(m.points.length>=2){p.beginPath(),p.moveTo(m.points[0].x,m.points[0].y);for(let l=1;l<m.points.length;l++)p.lineTo(m.points[l].x,m.points[l].y);p.stroke()}}else if(a.tool==="text"){const m=a;p.font=`${m.style.fontSize??16}px ${m.style.fontFamily??"sans-serif"}`,p.fillStyle=m.style.strokeColor,p.fillText(m.text,m.x,m.y+(m.style.fontSize??16))}p.restore()}return A.toDataURL(`image/${_}`,d)},exportAnnotations:()=>[...f.annotations],importAnnotations:_=>{k({type:"SET_ANNOTATIONS",annotations:_})},exportAsSVG:()=>{const{width:_,height:d}=B,A=f.annotations.map(yi);return`<svg xmlns="http://www.w3.org/2000/svg" width="${_}" height="${d}" viewBox="0 0 ${_} ${d}">
401
+ ${A.join(`
402
+ `)}
403
+ </svg>`},undo:()=>k({type:"UNDO"}),redo:()=>k({type:"REDO"}),setZoom:_=>{k({type:"SET_ZOOM",zoom:Math.max(L,Math.min(H,_))})},fitToScreen:()=>{const _=v.current,d=K.current;if(!_||!d)return;const A=_.clientWidth/d.naturalWidth,b=_.clientHeight/d.naturalHeight,p=Math.min(A,b,1);k({type:"SET_ZOOM",zoom:p}),k({type:"SET_PAN",panX:0,panY:0})},clear:()=>k({type:"CLEAR"})}),[f.annotations,B,L,H]);const z=n.useCallback(_=>{if(_.touches.length!==1)return;const d=_.touches[0];y({clientX:d.clientX,clientY:d.clientY,preventDefault:()=>{}})},[y]),P=n.useCallback(_=>{if(_.touches.length!==1)return;const d=_.touches[0];N({clientX:d.clientX,clientY:d.clientY})},[N]);return e.jsx("div",{ref:v,className:`nice-image-annotator ${S??""}`,style:{position:"relative",overflow:"hidden",width:"100%",height:"100%"},children:e.jsx("canvas",{ref:U,className:"nice-image-annotator__canvas",style:{cursor:f.activeTool==="select"?"default":"crosshair"},onMouseDown:y,onMouseMove:N,onMouseUp:x,onMouseLeave:x,onWheel:M,onTouchStart:z,onTouchMove:P,onTouchEnd:x,role:"img","aria-label":i})})});mn.displayName="NiceImageAnnotator";function xi(t){let i=t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");return i=i.replace(/```(\w*)\n([\s\S]*?)```/g,(o,r,u)=>`<pre><code class="language-${r}">${u.trim()}</code></pre>`),i=i.replace(/^(\|.+\|)\n(\|[-| :]+\|)\n((?:\|.+\|\n?)+)/gm,(o,r,u,g)=>{const S=r.split("|").filter(L=>L.trim()).map(L=>`<th>${L.trim()}</th>`).join(""),w=g.trim().split(`
404
+ `).map(L=>`<tr>${L.split("|").filter(Y=>Y.trim()).map(Y=>`<td>${Y.trim()}</td>`).join("")}</tr>`).join("");return`<table><thead><tr>${S}</tr></thead><tbody>${w}</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 ji=[{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"}],_i=["format","heading","list","block","insert"],un=n.forwardRef(({value:t="",onChange:i,preview:o="side",placeholder:r,disabled:u,readOnly:g,size:S="md",editorSize:w="standard",toolbar:L=!0,minHeight:H=200,showWordCount:Y=!1,showLineNumbers:U=!1,onExportHtml:v,onImageUpload:K,className:F,style:te,id:B},q)=>{const f=ne.ks(B),[k,C]=n.useState("edit"),[$,W]=n.useState(!1),y=n.useRef(null),N=n.useMemo(()=>xi(t),[t]),x=n.useMemo(()=>{const b=t.trim()?t.trim().split(/\s+/).length:0,p=t.length,a=t.split(`
409
+ `).length;return{words:b,chars:p,lines:a}},[t]),M=n.useCallback(b=>{const p=y.current;if(!p)return;const a=p.selectionStart,m=p.selectionEnd,l=t.slice(a,m);let c,h;b==="[](url)"?(c=t.slice(0,a)+`[${l||"text"}](url)`+t.slice(m),h=a+1+(l||"text").length+2):b==="![](url)"?(c=t.slice(0,a)+`![${l||"alt"}](url)`+t.slice(m),h=a+2+(l||"alt").length+2):b.endsWith(`
410
+ `)||b.endsWith(" ")?(c=t.slice(0,a)+b+l+t.slice(m),h=a+b.length+l.length):(c=t.slice(0,a)+b+l+b+t.slice(m),h=a+b.length+l.length+b.length),i?.(c),requestAnimationFrame(()=>{p.focus(),p.setSelectionRange(h,h)})},[t,i]),z=n.useCallback(b=>{if((b.ctrlKey||b.metaKey)&&(b.key==="b"?(b.preventDefault(),M("**")):b.key==="i"?(b.preventDefault(),M("*")):b.key==="k"&&(b.preventDefault(),M("[](url)"))),b.key==="Tab"){b.preventDefault();const p=b.currentTarget,a=p.selectionStart,m=p.selectionEnd,l=" ";if(b.shiftKey){const E=t.slice(0,a).lastIndexOf(`
411
+ `)+1;if(t.slice(E,E+l.length)===l){const Q=t.slice(0,E)+t.slice(E+l.length);i?.(Q),requestAnimationFrame(()=>{p.selectionStart=p.selectionEnd=a-l.length})}}else{const c=t.slice(0,a)+l+t.slice(m);i?.(c),requestAnimationFrame(()=>{p.selectionStart=p.selectionEnd=a+l.length})}}},[t,i,M]),P=n.useCallback(async b=>{if(!K)return;const p=Array.from(b.dataTransfer.files).filter(a=>a.type.startsWith("image/"));if(p.length!==0){b.preventDefault();for(const a of p){const m=await K(a),l=y.current;if(!l)continue;const c=l.selectionStart,h=`![${a.name}](${m})
412
+ `,E=t.slice(0,c)+h+t.slice(c);i?.(E)}}},[t,i,K]),_=o!=="tab"||k==="edit",d=o==="side"||o==="tab"&&k==="preview"||o===!0,A=`nice-md-editor nice-md-editor--${S} nice-editor--${w} nice-md-editor--preview-${o}${$?" nice-md-editor--fullscreen":""} ${F||""}`;return e.jsxs("div",{ref:q,id:f,className:A,style:te,children:[L&&e.jsxs("div",{className:"nice-md-editor__toolbar",children:[_i.map((b,p)=>e.jsxs(n.Fragment,{children:[p>0&&e.jsx("span",{className:"nice-md-editor__sep"}),ji.filter(a=>a.group===b).map(a=>e.jsx("button",{type:"button",className:"nice-md-editor__btn",title:a.shortcut?`${a.tip} (${a.shortcut})`:a.tip,disabled:u||g,onClick:()=>M(a.md),children:a.label},a.key))]},b)),e.jsx("span",{className:"nice-md-editor__sep"}),e.jsx("button",{type:"button",className:"nice-md-editor__btn",title:"Fullscreen",onClick:()=>W(!$),children:$?"⊙":"⛶"}),v&&e.jsx("button",{type:"button",className:"nice-md-editor__btn",title:"Export HTML",onClick:()=>v(N),children:"↗"}),o==="tab"&&e.jsxs("span",{className:"nice-md-editor__tabs",children:[e.jsx("button",{type:"button",className:`nice-md-editor__tab${k==="edit"?" nice-md-editor__tab--active":""}`,onClick:()=>C("edit"),children:"Edit"}),e.jsx("button",{type:"button",className:`nice-md-editor__tab${k==="preview"?" nice-md-editor__tab--active":""}`,onClick:()=>C("preview"),children:"Preview"})]})]}),e.jsxs("div",{className:"nice-md-editor__body",style:{minHeight:H},children:[_&&e.jsxs("div",{className:"nice-md-editor__editor-wrap",children:[U&&e.jsx("div",{className:"nice-md-editor__line-numbers",children:Array.from({length:x.lines},(b,p)=>e.jsx("div",{className:"nice-md-editor__line-no",children:p+1},p))}),e.jsx("textarea",{ref:y,className:"nice-md-editor__textarea",value:t,onChange:b=>i?.(b.target.value),onKeyDown:z,onDrop:P,placeholder:r,disabled:u,readOnly:g,style:{minHeight:H}})]}),d&&e.jsx("div",{className:"nice-md-editor__preview",dangerouslySetInnerHTML:{__html:ne.gs(N)},style:{minHeight:H}})]}),Y&&e.jsxs("div",{className:"nice-md-editor__statusbar",children:[e.jsxs("span",{children:[x.words," words"]}),e.jsxs("span",{children:[x.chars," chars"]}),e.jsxs("span",{children:[x.lines," lines"]})]})]})});un.displayName="NiceMarkdownEditor";const zt={rotation:0,flipH:!1,flipV:!1,brightness:100,contrast:100,saturate:100,blur:0,crop:null,annotations:[]},vi=["crop","rotate","flip","brightness","contrast","saturate","blur","annotate"],pn=n.forwardRef(({src:t,size:i="md",editorSize:o="standard",tools:r=vi,showToolbar:u=!0,showZoom:g=!0,maxUndo:S=30,onSave:w,onCancel:L,onChange:H,width:Y="100%",height:U=500,className:v,style:K,id:F,...te},B)=>{const q=ne.ks(F),{t:f}=ne.$o(),k=n.useRef(null),C=n.useRef(null),[$,W]=n.useState({...zt}),[y,N]=n.useState(null),[x,M]=n.useState(!1),[z,P]=n.useState(1),[_,d]=n.useState("rect"),[A,b]=n.useState("var(--nice-danger, #ff0000)"),[p,a]=n.useState({w:0,h:0}),[m,l]=n.useState([]),[c,h]=n.useState([]),[E,Q]=n.useState(null),[D,ee]=n.useState(null),[ae,O]=n.useState(null),Z=n.useCallback(I=>{l(j=>[...j.slice(-(S-1)),I]),h([])},[S]),ie=n.useCallback(I=>{W(j=>{Z(j);const X={...j,...I};return H?.(X),X})},[H,Z]),de=n.useCallback(()=>{if(m.length===0)return;const I=m[m.length-1];l(j=>j.slice(0,-1)),h(j=>[...j,$]),W(I),H?.(I)},[m,$,H]),he=n.useCallback(()=>{if(c.length===0)return;const I=c[c.length-1];h(j=>j.slice(0,-1)),l(j=>[...j,$]),W(I),H?.(I)},[c,$,H]);n.useEffect(()=>{const I=new Image;I.crossOrigin="anonymous",I.onload=()=>{C.current=I,a({w:I.width,h:I.height}),M(!0)},I.src=t},[t]),n.useEffect(()=>{if(!x||!k.current||!C.current)return;const I=k.current,j=I.getContext("2d");if(!j)return;const X=C.current,re=$.rotation%180!==0,V=re?X.height:X.width,R=re?X.width:X.height;I.width=V,I.height=R,j.clearRect(0,0,V,R),j.save(),j.filter=`brightness(${$.brightness}%) contrast(${$.contrast}%) saturate(${$.saturate}%) blur(${$.blur}px)`,j.translate(V/2,R/2),j.rotate($.rotation*Math.PI/180),j.scale($.flipH?-1:1,$.flipV?-1:1),j.drawImage(X,-X.width/2,-X.height/2),j.restore(),$.annotations.forEach(J=>{switch(j.save(),j.strokeStyle=J.color??"red",j.fillStyle=J.color??"red",j.lineWidth=J.strokeWidth??2,j.font=`${J.fontSize??16}px sans-serif`,J.type){case"text":j.fillText(J.text??"",J.x,J.y);break;case"rect":j.strokeRect(J.x,J.y,J.width??100,J.height??50);break;case"circle":{const ge=(J.width??50)/2,be=(J.height??50)/2;j.beginPath(),j.ellipse(J.x+ge,J.y+be,ge,be,0,0,Math.PI*2),j.stroke();break}case"line":j.beginPath(),j.moveTo(J.x,J.y),j.lineTo(J.x+(J.width??100),J.y+(J.height??0)),j.stroke();break;case"arrow":{const ge=J.x+(J.width??100),be=J.y+(J.height??0);j.beginPath(),j.moveTo(J.x,J.y),j.lineTo(ge,be),j.stroke();const ye=Math.atan2(be-J.y,ge-J.x),je=10;j.beginPath(),j.moveTo(ge,be),j.lineTo(ge-je*Math.cos(ye-.4),be-je*Math.sin(ye-.4)),j.lineTo(ge-je*Math.cos(ye+.4),be-je*Math.sin(ye+.4)),j.closePath(),j.fill();break}}j.restore()}),D&&(j.save(),j.fillStyle="var(--nice-overlay-50, rgba(0, 0, 0, 0.5))",j.fillRect(0,0,V,R),j.clearRect(D.x,D.y,D.w,D.h),j.strokeStyle="var(--bg-primary, #fff)",j.lineWidth=2,j.setLineDash([5,5]),j.strokeRect(D.x,D.y,D.w,D.h),j.restore())},[x,$,D]);const pe=n.useCallback(I=>{if(!k.current)return;const j=k.current.getBoundingClientRect(),X=k.current.width/j.width,re=k.current.height/j.height,V=(I.clientX-j.left)*X,R=(I.clientY-j.top)*re;y==="crop"?Q({startX:V,startY:R}):y==="annotate"&&O({startX:V,startY:R})},[y]),xe=n.useCallback(I=>{if(!k.current)return;const j=k.current.getBoundingClientRect(),X=k.current.width/j.width,re=k.current.height/j.height,V=(I.clientX-j.left)*X,R=(I.clientY-j.top)*re;E&&ee({x:Math.min(E.startX,V),y:Math.min(E.startY,R),w:Math.abs(V-E.startX),h:Math.abs(R-E.startY)})},[E]),ce=n.useCallback(I=>{if(E&&D&&D.w>5&&D.h>5&&ie({crop:{x:D.x,y:D.y,width:D.w,height:D.h}}),Q(null),ae&&k.current){const j=k.current.getBoundingClientRect(),X=k.current.width/j.width,re=k.current.height/j.height,V=(I.clientX-j.left)*X,R=(I.clientY-j.top)*re,J=V-ae.startX,ge=R-ae.startY;if(Math.abs(J)>3||Math.abs(ge)>3||_==="text"){const be={type:_,x:ae.startX,y:ae.startY,width:Math.abs(J)||100,height:Math.abs(ge)||50,color:A,strokeWidth:2,text:_==="text"?prompt(f("imageEditor.annotationText","Text:"))??"":void 0};ie({annotations:[...$.annotations,be]})}O(null)}},[E,D,ae,_,A,$.annotations,ie,f]),le=n.useCallback(()=>{if(!$.crop||!k.current)return;const I=k.current,j=I.getContext("2d");if(!j)return;const{x:X,y:re,width:V,height:R}=$.crop,J=j.getImageData(X,re,V,R);I.width=V,I.height=R,j.putImageData(J,0,0),ee(null),N(null)},[$.crop]),me=n.useCallback(()=>{if(!k.current)return;const I=k.current.toDataURL("image/png");w?.(I,$)},[w,$]),oe=n.useCallback(()=>{W({...zt}),ee(null),N(null)},[]);return n.useMemo(()=>`brightness(${$.brightness}%) contrast(${$.contrast}%) saturate(${$.saturate}%) blur(${$.blur}px)`,[$.brightness,$.contrast,$.saturate,$.blur]),e.jsxs("div",{ref:B,id:q,className:`nice-image-editor nice-image-editor--${i} nice-editor--${o} ${v??""}`,style:{...K,width:Y,height:U},role:"application","aria-label":f("imageEditor.label","Image Editor"),...te,children:[u&&e.jsxs("div",{className:"nice-image-editor__toolbar",role:"toolbar",children:[e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:de,disabled:m.length===0,title:f("imageEditor.undo","Undo"),children:"↶"}),e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:he,disabled:c.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:()=>ie({rotation:($.rotation-90+360)%360}),title:f("imageEditor.rotateLeft","Rotate left"),children:"↺"}),e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>ie({rotation:($.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:()=>ie({flipH:!$.flipH}),title:f("imageEditor.flipH","Flip horizontal"),children:"⇔"}),e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>ie({flipV:!$.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"&&$.crop&&e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:le,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:$.brightness,onChange:I=>ie({brightness:Number(I.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:$.contrast,onChange:I=>ie({contrast:Number(I.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:$.saturate,onChange:I=>ie({saturate:Number(I.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:$.blur,onChange:I=>ie({blur:Number(I.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:_,onChange:I=>d(I.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:A,onChange:I=>b(I.target.value),className:"nice-image-editor__color",title:f("imageEditor.color","Color")}),$.annotations.length>0&&e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>ie({annotations:$.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:oe,title:f("imageEditor.reset","Reset"),children:"⟲"}),w&&e.jsx("button",{type:"button",className:"nice-image-editor__btn nice-image-editor__btn--save",onClick:me,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:k,className:"nice-image-editor__canvas",onMouseDown:pe,onMouseMove:xe,onMouseUp:ce,style:{cursor:y==="crop"||y==="annotate"?"crosshair":"default",transform:`scale(${z})`,transformOrigin:"center center"}})}),g&&e.jsxs("div",{className:"nice-image-editor__footer",children:[e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>P(I=>Math.max(.1,I-.1)),title:"Zoom out",children:"−"}),e.jsxs("span",{style:{fontSize:"0.85em",minWidth:40,textAlign:"center"},children:[Math.round(z*100),"%"]}),e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>P(I=>Math.min(5,I+.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:[p.w,"×",p.h,"px · ",$.rotation,"°"]})]})]})});pn.displayName="NiceImageEditor";const hn=n.forwardRef(({value:t,onChange:i,penColor:o="var(--text-primary, #000)",penWidth:r=2,backgroundColor:u="var(--bg-primary, #fff)",width:g=400,height:S=200,size:w="md",disabled:L=!1,readOnly:H=!1,showClear:Y=!0,showUndo:U=!0,label:v,exportFormat:K="image/png",className:F,style:te,id:B,...q},f)=>{const k=ne.ks(B),{t:C}=ne.$o(),$=n.useRef(null),[W,y]=n.useState(!1),N=n.useRef([]),x=n.useRef([]),[M,z]=n.useState(!0),P=n.useCallback(()=>{const m=$.current;if(!m)return;const l=m.getContext("2d");if(l){l.fillStyle=u,l.fillRect(0,0,m.width,m.height),l.strokeStyle=o,l.lineWidth=r,l.lineCap="round",l.lineJoin="round";for(const c of N.current)if(!(c.length<2)){l.beginPath(),l.moveTo(c[0].x,c[0].y);for(let h=1;h<c.length;h++)l.lineTo(c[h].x,c[h].y);l.stroke()}}},[u,o,r]);n.useEffect(()=>{if(t&&$.current){const m=new Image;m.onload=()=>{const l=$.current?.getContext("2d");!l||!$.current||(l.fillStyle=u,l.fillRect(0,0,$.current.width,$.current.height),l.drawImage(m,0,0),z(!1))},m.src=t}else t||(N.current=[],z(!0),P())},[t,u,P]),n.useEffect(()=>{const m=$.current;m&&(m.width=g,m.height=S,P())},[g,S,P]);const _=n.useCallback(m=>{const l=$.current,c=l.getBoundingClientRect(),h=l.width/c.width,E=l.height/c.height;if("touches"in m){const Q=m.touches[0];return{x:(Q.clientX-c.left)*h,y:(Q.clientY-c.top)*E}}return{x:(m.clientX-c.left)*h,y:(m.clientY-c.top)*E}},[]),d=n.useCallback(m=>{if(L||H)return;m.preventDefault();const l=_(m);x.current=[l],y(!0)},[L,H,_]),A=n.useCallback(m=>{if(!W)return;m.preventDefault();const l=_(m);x.current.push(l);const c=$.current,h=c?.getContext("2d");if(!h||!c)return;const E=x.current;E.length>=2&&(h.strokeStyle=o,h.lineWidth=r,h.lineCap="round",h.beginPath(),h.moveTo(E[E.length-2].x,E[E.length-2].y),h.lineTo(l.x,l.y),h.stroke())},[W,_,o,r]),b=n.useCallback(()=>{if(W&&(y(!1),x.current.length>0&&(N.current.push([...x.current]),x.current=[],z(!1),$.current))){const m=$.current.toDataURL(K);i?.(m)}},[W,K,i]),p=n.useCallback(()=>{N.current=[],x.current=[],z(!0),P(),i?.(null)},[P,i]),a=n.useCallback(()=>{if(N.current.length!==0&&(N.current.pop(),z(N.current.length===0),P(),$.current)){const m=N.current.length>0?$.current.toDataURL(K):null;i?.(m)}},[P,K,i]);return e.jsxs("div",{ref:f,id:k,className:`nice-signature nice-signature--${w} ${L?"nice-signature--disabled":""} ${H?"nice-signature--readonly":""} ${F??""}`,style:te,...q,children:[v&&e.jsx("label",{className:"nice-signature__label",children:v}),e.jsx("div",{className:"nice-signature__canvas-wrap",style:{width:g,height:S},children:e.jsx("canvas",{ref:$,className:"nice-signature__canvas",onMouseDown:d,onMouseMove:A,onMouseUp:b,onMouseLeave:b,onTouchStart:d,onTouchMove:A,onTouchEnd:b,style:{touchAction:"none",cursor:L||H?"default":"crosshair"},"aria-label":v??C("signature.label","Signature pad"),role:"img"})}),(Y||U)&&!H&&!L&&e.jsxs("div",{className:"nice-signature__actions",children:[U&&e.jsx("button",{type:"button",className:"nice-signature__btn",onClick:a,disabled:M,children:C("signature.undo","Undo")}),Y&&e.jsx("button",{type:"button",className:"nice-signature__btn",onClick:p,disabled:M,children:C("signature.clear","Clear")})]})]})});hn.displayName="NiceSignaturePad";let ki=0;function bt(){return`blk-${++ki}-${Date.now().toString(36)}`}function Pt(t=""){return{id:bt(),type:"paragraph",content:t}}function wi(t,i=""){const o={id:bt(),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 Ni=[{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 Ci(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=(u,g)=>{let S=g;return t.bold&&(S=`<strong>${S}</strong>`),t.italic&&(S=`<em>${S}</em>`),t.underline&&(S=`<u>${S}</u>`),t.strikethrough&&(S=`<s>${S}</s>`),`<${u}${o}>${S}</${u}>`};switch(t.type){case"heading":return r(`h${t.level??2}`,t.content);case"paragraph":return r("p",t.content||"&nbsp;");case"list":{const u=t.listType==="ordered"?"ol":"ul",g=t.content.split(`
413
+ `).map((S,w)=>t.listType==="checklist"?`<li><input type="checkbox" ${t.checked?.[w]??!1?"checked":""} disabled />${S}</li>`:`<li>${S}</li>`).join("");return`<${u}${o}>${g}</${u}>`}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 Si(t){let i=0,o=0;for(const r of t){const u=r.content??"";i+=u.length;const g=u.trim().split(/\s+/).filter(Boolean);o+=g.length}return{words:o,chars:i,readingTime:Math.max(1,Math.ceil(o/200))}}const gn=n.forwardRef(({blocks:t,onChange:i,readOnly:o=!1,showToolbar:r=!0,size:u="md",editorSize:g="standard",placeholder:S,onExport:w,onImageUpload:L,maxUndo:H=50,slashCommands:Y=!0,showWordCount:U=!1,showToc:v=!1,showFindReplace:K=!0,className:F,style:te,id:B,...q},f)=>{const k=ne.ks(B),{t:C}=ne.$o(),[$,W]=n.useState(()=>t??[Pt()]),y=t??$,[N,x]=n.useState(0),M=n.useRef(new Map),z=n.useRef(null),[P,_]=n.useState(!1),[d,A]=n.useState(""),[b,p]=n.useState(""),[a,m]=n.useState([]),[l,c]=n.useState(0),[h,E]=n.useState(!1),Q=n.useRef([]),D=n.useRef([]),ee=n.useCallback(s=>{Q.current.push(s.map(T=>({...T,checked:T.checked?[...T.checked]:void 0}))),Q.current.length>H&&Q.current.shift(),D.current=[]},[H]),ae=n.useCallback(()=>{if(Q.current.length===0)return;const s=Q.current.pop();D.current.push(y.map(T=>({...T}))),t||W(s),i?.(s)},[y,t,i]),O=n.useCallback(()=>{if(D.current.length===0)return;const s=D.current.pop();Q.current.push(y.map(T=>({...T}))),t||W(s),i?.(s)},[y,t,i]),[Z,ie]=n.useState(!1),[de,he]=n.useState(""),[pe,xe]=n.useState(0),ce=n.useMemo(()=>{if(!Z||!Y)return[];const s=de.toLowerCase();return Ni.filter(T=>T.label.toLowerCase().includes(s)||T.keywords.includes(s))},[Z,de,Y]),[le,me]=n.useState(null),[oe,I]=n.useState(null),j=n.useCallback(s=>{ee(y);const T=s(y);t||W(T),i?.(T)},[y,t,i,ee]),X=n.useCallback((s,T)=>{j(G=>G.map((se,ue)=>ue===s?{...se,...T}:se))},[j]),re=n.useCallback((s,T)=>{const G=T??Pt();j(se=>{const ue=[...se];return ue.splice(s+1,0,G),ue}),x(s+1)},[j]),V=n.useCallback(s=>{const T={...y[s],id:bt()};re(s,T)},[y,re]),R=n.useCallback(s=>{y.length<=1||(j(T=>T.filter((G,se)=>se!==s)),x(Math.max(0,s-1)))},[y.length,j]),J=n.useCallback((s,T)=>{const G=s+T;G<0||G>=y.length||(j(se=>{const ue=[...se];return[ue[s],ue[G]]=[ue[G],ue[s]],ue}),x(G))},[y.length,j]),ge=n.useCallback((s,T)=>{const G={type:T};T==="heading"&&(G.level=2),T==="list"&&(G.listType="unordered"),T==="callout"&&(G.icon="??"),T==="toggle"&&(G.open=!0),X(s,G)},[X]),be=n.useCallback(s=>{const T=wi(s.type);s.type==="list"&&s.label.includes("Numbered")&&(T.listType="ordered"),s.type==="list"&&s.label.includes("Checklist")&&(T.listType="checklist",T.checked=[]),y[N]?.content===""||y[N]?.content==="/"?j(G=>G.map((se,ue)=>ue===N?{...T,id:se.id}:se)):re(N,T),ie(!1),he("")},[y,N,j,re]),ye=n.useCallback((s,T)=>{if(o)return;const G=y[T];if(!G?.locked){if((s.ctrlKey||s.metaKey)&&s.key==="z"&&!s.shiftKey){s.preventDefault(),ae();return}if((s.ctrlKey||s.metaKey)&&(s.key==="y"||s.key==="z"&&s.shiftKey)){s.preventDefault(),O();return}if((s.ctrlKey||s.metaKey)&&s.key==="d"){s.preventDefault(),V(T);return}if((s.ctrlKey||s.metaKey)&&s.key==="b"){s.preventDefault(),X(T,{bold:!G?.bold});return}if((s.ctrlKey||s.metaKey)&&s.key==="i"){s.preventDefault(),X(T,{italic:!G?.italic});return}if((s.ctrlKey||s.metaKey)&&s.key==="u"){s.preventDefault(),X(T,{underline:!G?.underline});return}if((s.ctrlKey||s.metaKey)&&s.key==="e"){s.preventDefault(),X(T,{strikethrough:!G?.strikethrough});return}if(s.key==="Tab"&&!s.shiftKey){s.preventDefault(),X(T,{indent:Math.min((G?.indent??0)+1,4)});return}if(s.key==="Tab"&&s.shiftKey){s.preventDefault(),X(T,{indent:Math.max((G?.indent??0)-1,0)});return}if((s.ctrlKey||s.metaKey)&&s.key==="f"&&K){s.preventDefault(),_(se=>!se);return}if(Z&&ce.length>0){if(s.key==="ArrowDown"){s.preventDefault(),xe(se=>Math.min(se+1,ce.length-1));return}if(s.key==="ArrowUp"){s.preventDefault(),xe(se=>Math.max(se-1,0));return}if(s.key==="Enter"){s.preventDefault(),be(ce[pe]);return}if(s.key==="Escape"){ie(!1);return}}s.key==="Enter"&&!s.shiftKey?(s.preventDefault(),re(T)):s.key==="Backspace"&&y[T].content===""&&y.length>1?(s.preventDefault(),R(T)):s.key==="ArrowUp"&&s.altKey?(s.preventDefault(),J(T,-1)):s.key==="ArrowDown"&&s.altKey&&(s.preventDefault(),J(T,1))}},[o,y,re,R,J,ae,O,V,X,Z,ce,pe,be,K]),je=n.useCallback((s,T)=>{const G=s.target.textContent??"";Y&&G.startsWith("/")?(ie(!0),he(G.slice(1)),xe(0)):Z&&ie(!1),ee(y);const se=y.map((ue,ke)=>ke===T?{...ue,content:G}:ue);t||W(se),i?.(se)},[y,t,i,ee,Y,Z]),Ee=n.useCallback((s,T)=>{me(T),s.dataTransfer.effectAllowed="move"},[]),Ae=n.useCallback((s,T)=>{s.preventDefault(),s.dataTransfer.dropEffect="move",I(T)},[]),Se=n.useCallback((s,T)=>{if(s.preventDefault(),le===null||le===T){me(null),I(null);return}j(G=>{const se=[...G],[ue]=se.splice(le,1);return se.splice(T>le?T-1:T,0,ue),se}),x(T>le?T-1:T),me(null),I(null)},[le,j]);n.useEffect(()=>{if(!P||!d){m([]);return}const s=d.toLowerCase(),T=[];y.forEach((G,se)=>{const ue=(G.content??"").toLowerCase();let ke=0;for(;ke<ue.length;){const we=ue.indexOf(s,ke);if(we===-1)break;T.push({blockIdx:se,start:we,end:we+s.length}),ke=we+1}}),m(T),c(0)},[d,P,y]);const De=n.useCallback(()=>{if(a.length===0)return;const s=(l+1)%a.length;c(s),x(a[s].blockIdx)},[a,l]),et=n.useCallback(()=>{if(a.length===0)return;const s=(l-1+a.length)%a.length;c(s),x(a[s].blockIdx)},[a,l]),tt=n.useCallback(()=>{if(a.length===0||!d)return;const s=a[l],T=y[s.blockIdx],G=T.content.slice(0,s.start),se=T.content.slice(s.end);X(s.blockIdx,{content:G+b+se})},[a,l,d,b,y,X]),nt=n.useCallback(()=>{if(!d)return;const s=d;j(T=>T.map(G=>({...G,content:G.content.split(s).join(b)})))},[d,b,j]),Ke=n.useMemo(()=>v?y.map((s,T)=>s.type==="heading"?{idx:T,level:s.level??2,text:s.content}:null).filter(Boolean):[],[y,v]),Ye=n.useCallback(async s=>{const T=s.target.files?.[0];if(T){if(L){const G=await L(T);X(N,{src:G})}s.target.value=""}},[L,N,X]);n.useEffect(()=>{const s=y[N];if(s){const T=M.current.get(s.id);T&&T.focus()}},[N,y]);const it=n.useCallback(()=>{const s=y.map(Ci).join(`
416
+ `);w?.(s)},[y,w]),Te=n.useMemo(()=>U?Si(y):null,[y,U]),[ve,Ce]=n.useState(null),ot=n.useCallback((s,T)=>{o||(s.preventDefault(),Ce({x:s.clientX,y:s.clientY,idx:T}))},[o]);return n.useEffect(()=>{if(!ve)return;const s=()=>Ce(null);return window.addEventListener("click",s),()=>window.removeEventListener("click",s)},[ve]),e.jsxs("div",{ref:f,id:k,className:`nice-doc-editor nice-doc-editor--${u} nice-editor--${g} ${o?"nice-doc-editor--readonly":""} ${F??""}`,style:te,role:"application","aria-label":C("docEditor.label","Document Editor"),...q,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(fe.NiceButton,{size:"sm",variant:"ghost",onClick:ae,title:C("docEditor.undo","Undo (Ctrl+Z)"),children:"?"}),e.jsx(fe.NiceButton,{size:"sm",variant:"ghost",onClick:O,title:C("docEditor.redo","Redo (Ctrl+Y)"),children:"?"}),e.jsx("span",{className:"nice-doc-editor__sep"}),e.jsx(fe.NiceSelect,{size:"sm",value:y[N]?.type??"paragraph",onChange:s=>ge(N,s),label:"",options:[{value:"paragraph",label:C("docEditor.paragraph","Paragraph")},{value:"heading",label:C("docEditor.heading","Heading")},{value:"list",label:C("docEditor.list","List")},{value:"code",label:C("docEditor.code","Code")},{value:"quote",label:C("docEditor.quote","Quote")},{value:"callout",label:C("docEditor.callout","Callout")},{value:"toggle",label:C("docEditor.toggle","Toggle")},{value:"divider",label:C("docEditor.divider","Divider")},{value:"image",label:C("docEditor.image","Image")},{value:"video",label:C("docEditor.video","Video")},{value:"pageBreak",label:C("docEditor.pageBreak","Page Break")}],style:{minWidth:100}}),y[N]?.type==="heading"&&e.jsx(fe.NiceSelect,{size:"sm",value:String(y[N]?.level??2),onChange:s=>X(N,{level:Number(s)}),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(fe.NiceSelect,{size:"sm",value:y[N]?.listType??"unordered",onChange:s=>X(N,{listType:s}),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(fe.NiceButton,{size:"sm",variant:y[N]?.bold?"primary":"ghost",onClick:()=>X(N,{bold:!y[N]?.bold}),title:C("docEditor.bold","Bold (Ctrl+B)"),children:e.jsx("strong",{children:"B"})}),e.jsx(fe.NiceButton,{size:"sm",variant:y[N]?.italic?"primary":"ghost",onClick:()=>X(N,{italic:!y[N]?.italic}),title:C("docEditor.italic","Italic (Ctrl+I)"),children:e.jsx("em",{children:"I"})}),e.jsx(fe.NiceButton,{size:"sm",variant:y[N]?.underline?"primary":"ghost",onClick:()=>X(N,{underline:!y[N]?.underline}),title:C("docEditor.underline","Underline (Ctrl+U)"),children:e.jsx("u",{children:"U"})}),e.jsx(fe.NiceButton,{size:"sm",variant:y[N]?.strikethrough?"primary":"ghost",onClick:()=>X(N,{strikethrough:!y[N]?.strikethrough}),title:C("docEditor.strikethrough","Strikethrough (Ctrl+E)"),children:e.jsx("s",{children:"S"})}),e.jsx("span",{className:"nice-doc-editor__sep"}),e.jsx(fe.NiceButton,{size:"sm",variant:y[N]?.align==="left"?"primary":"ghost",onClick:()=>X(N,{align:"left"}),title:C("docEditor.alignLeft","Left"),children:"?"}),e.jsx(fe.NiceButton,{size:"sm",variant:y[N]?.align==="center"?"primary":"ghost",onClick:()=>X(N,{align:"center"}),title:C("docEditor.alignCenter","Center"),children:"?"}),e.jsx(fe.NiceButton,{size:"sm",variant:y[N]?.align==="right"?"primary":"ghost",onClick:()=>X(N,{align:"right"}),title:C("docEditor.alignRight","Right"),children:"?"}),e.jsx("span",{className:"nice-doc-editor__sep"}),e.jsx(fe.NiceButton,{size:"sm",variant:"ghost",onClick:()=>X(N,{indent:Math.min((y[N]?.indent??0)+1,4)}),title:C("docEditor.indent","Indent (Tab)"),children:"??"}),e.jsx(fe.NiceButton,{size:"sm",variant:"ghost",onClick:()=>X(N,{indent:Math.max((y[N]?.indent??0)-1,0)}),title:C("docEditor.outdent","Outdent (Shift+Tab)"),children:"??"}),e.jsx("span",{className:"nice-doc-editor__sep"}),e.jsx(fe.NiceColorPicker,{size:"sm",label:"",value:y[N]?.color??"var(--text-primary, #000000)",onChange:s=>X(N,{color:s}),title:"Text color"}),e.jsx(fe.NiceColorPicker,{size:"sm",label:"",value:y[N]?.bgColor??"var(--bg-primary, #ffffff)",onChange:s=>X(N,{bgColor:s}),title:"Block background"}),e.jsx("span",{className:"nice-doc-editor__sep"}),e.jsx(fe.NiceButton,{size:"sm",variant:y[N]?.locked?"primary":"ghost",onClick:()=>X(N,{locked:!y[N]?.locked}),title:C("docEditor.lock","Lock/Unlock block"),children:"??"}),e.jsx(fe.NiceButton,{size:"sm",variant:"ghost",onClick:()=>V(N),title:C("docEditor.duplicate","Duplicate (Ctrl+D)"),children:"?"}),e.jsx(fe.NiceButton,{size:"sm",variant:"ghost",onClick:()=>R(N),title:C("docEditor.delete","Delete block"),children:"??"}),e.jsx(fe.NiceButton,{size:"sm",variant:"ghost",onClick:()=>re(N),title:C("docEditor.addBlock","Add block"),children:"+"}),K&&e.jsx(fe.NiceButton,{size:"sm",variant:P?"primary":"ghost",onClick:()=>_(s=>!s),title:C("docEditor.find","Find & Replace (Ctrl+F)"),children:"??"}),e.jsx(fe.NiceButton,{size:"sm",variant:"ghost",onClick:()=>E(s=>!s),title:C("docEditor.shortcuts","Keyboard shortcuts"),children:"?"}),w&&e.jsx(fe.NiceButton,{size:"sm",variant:"ghost",onClick:it,children:C("docEditor.export","Export HTML")})]}),e.jsx("input",{ref:z,type:"file",accept:"image/*,video/*",style:{display:"none"},onChange:Ye}),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(fe.NiceTextInput,{size:"sm",placeholder:C("docEditor.findPlaceholder","Find..."),value:d,onChange:A,style:{flex:1,maxWidth:200}}),e.jsx(fe.NiceTextInput,{size:"sm",placeholder:C("docEditor.replacePlaceholder","Replace..."),value:b,onChange:p,style:{flex:1,maxWidth:200}}),e.jsx(fe.NiceButton,{size:"sm",variant:"ghost",onClick:et,title:C("docEditor.findPrev","Previous"),children:"?"}),e.jsx(fe.NiceButton,{size:"sm",variant:"ghost",onClick:De,title:C("docEditor.findNext","Next"),children:"?"}),e.jsx(fe.NiceButton,{size:"sm",variant:"ghost",onClick:tt,title:C("docEditor.replaceOne","Replace"),disabled:o,children:C("docEditor.replace","Replace")}),e.jsx(fe.NiceButton,{size:"sm",variant:"ghost",onClick:nt,title:C("docEditor.replaceAll","Replace all"),disabled:o,children:C("docEditor.replaceAllBtn","All")}),e.jsx("span",{style:{fontSize:"0.75em",color:"var(--text-muted, #666)"},children:a.length>0?`${l+1}/${a.length}`:"0/0"}),e.jsx(fe.NiceButton,{size:"sm",variant:"ghost",onClick:()=>_(!1),children:"?"})]}),h&&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:()=>E(!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:s=>s.stopPropagation(),children:[e.jsx("h3",{style:{margin:"0 0 12px"},children:C("docEditor.shortcutsTitle","Keyboard Shortcuts")}),e.jsx("table",{style:{width:"100%",fontSize:"0.875em",borderCollapse:"collapse"},children:e.jsx("tbody",{children:[["Ctrl+B",C("docEditor.bold","Bold")],["Ctrl+I",C("docEditor.italic","Italic")],["Ctrl+U",C("docEditor.underline","Underline")],["Ctrl+E",C("docEditor.strikethrough","Strikethrough")],["Ctrl+D",C("docEditor.duplicate","Duplicate block")],["Ctrl+Z",C("docEditor.undo","Undo")],["Ctrl+Y",C("docEditor.redo","Redo")],["Ctrl+F",C("docEditor.find","Find & Replace")],["Enter",C("docEditor.newBlock","New block")],["Backspace",C("docEditor.deleteEmpty","Delete empty block")],["Alt+?",C("docEditor.moveUp","Move block up")],["Alt+?",C("docEditor.moveDown","Move block down")],["Tab",C("docEditor.indent","Indent")],["Shift+Tab",C("docEditor.outdent","Outdent")],["/",C("docEditor.slashCmd","Slash commands")]].map(([s,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:s}),e.jsx("td",{style:{padding:"4px 8px"},children:T})]},s))})}),e.jsx("div",{style:{textAlign:"right",marginTop:12},children:e.jsx(fe.NiceButton,{size:"sm",variant:"ghost",onClick:()=>E(!1),children:C("docEditor.close","Close")})})]})}),e.jsxs("div",{style:{display:"flex",gap:0},children:[v&&Ke.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:C("docEditor.toc","Contents")}),Ke.map(s=>e.jsx("div",{style:{padding:"3px 8px",paddingLeft:8+(s.level-1)*12,cursor:"pointer",borderRadius:4,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",background:s.idx===N?"var(--nice-primary-bg, #e8f0fe)":void 0},onClick:()=>x(s.idx),title:s.text,children:s.text||C("docEditor.untitled","Untitled")},s.idx))]}),e.jsx("div",{className:"nice-doc-editor__body",style:{flex:1},children:y.map((s,T)=>e.jsxs("div",{className:`nice-doc-editor__block nice-doc-editor__block--${s.type} ${T===N?"nice-doc-editor__block--focused":""} ${oe===T?"nice-doc-editor__block--drop-target":""} ${s.locked?"nice-doc-editor__block--locked":""}`,onClick:()=>x(T),onContextMenu:G=>ot(G,T),draggable:!o&&!s.locked,onDragStart:G=>Ee(G,T),onDragOver:G=>Ae(G,T),onDrop:G=>Se(G,T),onDragEnd:()=>{me(null),I(null)},style:{opacity:le===T?.4:1,marginLeft:(s.indent??0)*24},children:[!o&&!s.locked&&e.jsx("div",{className:"nice-doc-editor__block-handle",title:C("docEditor.drag","Drag to reorder"),children:"?"}),s.locked&&e.jsx("span",{className:"nice-doc-editor__lock-icon",style:{position:"absolute",top:2,right:4,fontSize:"0.7em",opacity:.5},children:"??"}),s.type==="divider"?e.jsx("hr",{className:"nice-doc-editor__divider"}):s.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:["� ",C("docEditor.pageBreak","Page Break")," �"]}):s.type==="image"||s.type==="video"?e.jsx("div",{className:"nice-doc-editor__media-block",children:s.src?s.type==="image"?e.jsx("img",{src:s.src,alt:s.alt??"",className:"nice-doc-editor__image",style:{maxWidth:"100%"}}):e.jsx("video",{src:s.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(fe.NiceTextInput,{size:"sm",placeholder:C("docEditor.mediaUrl",s.type==="image"?"Image URL":"Video URL"),value:s.src??"",onChange:G=>X(T,{src:G})}),L&&e.jsx(fe.NiceButton,{size:"sm",variant:"ghost",onClick:()=>{x(T),z.current?.click()},children:"??"})]})}):s.type==="callout"?e.jsxs("div",{className:"nice-doc-editor__callout",style:{display:"flex",gap:8,padding:"8px 12px",background:s.bgColor??"#f0f7ff",borderRadius:4,color:s.color},children:[e.jsx("span",{style:{fontSize:"1.2em"},children:s.icon??"??"}),e.jsx("div",{ref:G=>{G&&M.current.set(s.id,G)},className:"nice-doc-editor__content",contentEditable:!o&&!s.locked,suppressContentEditableWarning:!0,onInput:G=>je(G,T),onFocus:()=>x(T),onKeyDown:G=>ye(G,T),"data-placeholder":C("docEditor.calloutPlaceholder","Callout text..."),role:"textbox","aria-multiline":"true",style:{flex:1,outline:"none"},children:s.content})]}):s.type==="toggle"?e.jsxs("details",{open:s.open,className:"nice-doc-editor__toggle",onToggle:G=>X(T,{open:G.target.open}),children:[e.jsx("summary",{style:{cursor:"pointer",fontWeight:500},children:s.content.split(`
417
+ `)[0]||C("docEditor.toggleTitle","Toggle")}),e.jsx("div",{ref:G=>{G&&M.current.set(s.id,G)},className:"nice-doc-editor__content",contentEditable:!o&&!s.locked,suppressContentEditableWarning:!0,onInput:G=>je(G,T),onFocus:()=>x(T),onKeyDown:G=>ye(G,T),role:"textbox","aria-multiline":"true",style:{padding:"4px 0"},children:s.content.split(`
418
+ `).slice(1).join(`
419
+ `)})]}):s.type==="code"?e.jsxs("div",{className:"nice-doc-editor__code-block",style:{position:"relative"},children:[!o&&e.jsx(fe.NiceTextInput,{size:"sm",value:s.language??"",onChange:G=>X(T,{language:G}),placeholder:"Language",style:{position:"absolute",top:4,right:4,width:80,opacity:.7}}),e.jsx("pre",{ref:G=>{G&&M.current.set(s.id,G)},className:"nice-doc-editor__content",contentEditable:!o&&!s.locked,suppressContentEditableWarning:!0,onInput:G=>je(G,T),onFocus:()=>x(T),onKeyDown:G=>ye(G,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:s.content})]}):e.jsxs("div",{style:{position:"relative"},children:[e.jsx("div",{ref:G=>{G&&M.current.set(s.id,G)},className:"nice-doc-editor__content",contentEditable:!o&&!s.locked,suppressContentEditableWarning:!0,style:{textAlign:s.align,fontWeight:s.bold?"bold":void 0,fontStyle:s.italic?"italic":void 0,textDecoration:[s.underline?"underline":"",s.strikethrough?"line-through":""].filter(Boolean).join(" ")||void 0,color:s.color,backgroundColor:s.bgColor},onInput:G=>je(G,T),onFocus:()=>x(T),onKeyDown:G=>ye(G,T),"data-placeholder":!s.content&&S?S:void 0,role:"textbox","aria-multiline":"true",children:s.content}),Z&&T===N&&ce.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:ce.map((G,se)=>e.jsxs("li",{className:se===pe?"nice-doc-editor__slash-item--active":"",style:{padding:"6px 10px",cursor:"pointer",borderRadius:4,display:"flex",gap:8,alignItems:"center",background:se===pe?"var(--nice-primary-bg, #e8f0fe)":void 0},onMouseDown:ue=>{ue.preventDefault(),be(G)},onMouseEnter:()=>xe(se),children:[e.jsx("span",{style:{width:24,textAlign:"center"},children:G.icon}),e.jsx("span",{children:G.label})]},`${G.type}-${G.label}`))})]})]},s.id))})]}),ve&&e.jsxs("div",{className:"nice-doc-editor__ctx-menu",style:{position:"fixed",left:ve.x,top:ve.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:()=>{V(ve.idx),Ce(null)},children:"? Duplicate"}),e.jsx("div",{style:{padding:"6px 12px",cursor:"pointer"},onClick:()=>{re(ve.idx),Ce(null)},children:"+ Insert below"}),e.jsx("div",{style:{padding:"6px 12px",cursor:"pointer"},onClick:()=>{J(ve.idx,-1),Ce(null)},children:"? Move up"}),e.jsx("div",{style:{padding:"6px 12px",cursor:"pointer"},onClick:()=>{J(ve.idx,1),Ce(null)},children:"? Move down"}),e.jsx("div",{style:{padding:"6px 12px",cursor:"pointer"},onClick:()=>{X(ve.idx,{locked:!y[ve.idx]?.locked}),Ce(null)},children:y[ve.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:()=>{R(ve.idx),Ce(null)},children:"?? Delete"})]}),U&&Te&&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:[Te.words," ",C("docEditor.words","words")]}),e.jsxs("span",{children:[Te.chars," ",C("docEditor.chars","characters")]}),e.jsxs("span",{children:[y.length," ",C("docEditor.blocks","blocks")]}),e.jsxs("span",{children:["~",Te.readingTime," ",C("docEditor.readingTime","min read")]})]})]})});gn.displayName="NiceDocumentEditor";const $i=["street","streetNumber","apartment","city","postalCode","state","country"],Ve={street:"Street",streetNumber:"Number",apartment:"Apt/Suite",city:"City",postalCode:"Postal Code",state:"State/Province",country:"Country"},fn=n.forwardRef(({label:t,helperText:i,error:o,required:r,disabled:u,readOnly:g,size:S="md",name:w,id:L,className:H,style:Y,accessMode:U,value:v={},onChange:K,fields:F=$i,placeholders:te={},countries:B,layout:q="vertical",countryFirst:f=!1,validatePostalCode:k},C)=>{const $=ne._s(U,L),W=$==="hidden";$==="disabled"&&(u=!0),$==="readOnly"&&(g=!0);const{t:y}=ne.$o(),N=ne.ks(L),x=n.useCallback((_,d)=>{K?.({...v,[_]:d})},[v,K]),M=n.useMemo(()=>{if(k&&v.postalCode)return k(v.postalCode,v.country)},[k,v.postalCode,v.country]),z=n.useMemo(()=>f&&F.includes("country")?["country",...F.filter(_=>_!=="country")]:F,[F,f]),P=`nice-address nice-address--${q} nice-size-${S}`;return W?null:e.jsxs("div",{ref:C,id:N,className:`${P}${H?` ${H}`:""}${o?" nice-error":""}${u?" nice-disabled":""}`,style:Y,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:z.map(_=>_==="country"&&B?e.jsxs("div",{className:`nice-address__field nice-address__field--${_}`,children:[e.jsx("label",{className:"nice-address__field-label",children:y(_,Ve[_])}),e.jsxs("select",{className:"nice-input nice-select",value:v.country??"",onChange:d=>x("country",d.target.value),disabled:u,"aria-label":y(_,Ve[_]),children:[e.jsx("option",{value:"",children:te.country??y("selectCountry","— Select country —")}),B.map(d=>e.jsx("option",{value:d.code,children:d.name},d.code))]})]},_):e.jsxs("div",{className:`nice-address__field nice-address__field--${_}`,children:[e.jsx("label",{className:"nice-address__field-label",children:y(_,Ve[_])}),e.jsx("input",{className:`nice-input${_==="postalCode"&&M?" nice-input--error":""}`,type:"text",name:w?`${w}.${_}`:_,value:v[_]??"",onChange:d=>x(_,d.target.value),placeholder:te[_]??"",disabled:u,readOnly:g,"aria-label":y(_,Ve[_])}),_==="postalCode"&&M&&e.jsx("span",{className:"nice-error-text",children:M})]},_))}),i&&e.jsx("span",{className:"nice-helper-text",children:i}),o&&typeof o=="string"&&e.jsx("span",{className:"nice-error-text",children:o})]})});fn.displayName="NiceAddressInput";const Mi=[{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"}],yn=n.forwardRef(({label:t,helperText:i,error:o,required:r,disabled:u,readOnly:g,size:S="md",name:w,id:L,className:H,style:Y,accessMode:U,value:v,onChange:K,onBlur:F,currency:te="PLN",onCurrencyChange:B,currencies:q=Mi,useMinorUnit:f=!1,min:k,max:C,locale:$,placeholder:W,showCurrencySelector:y},N)=>{const x=ne._s(U,L),M=x==="hidden";x==="disabled"&&(u=!0),x==="readOnly"&&(g=!0);const{t:z}=ne.$o(),P=ne.ks(L),_=n.useMemo(()=>q.find(m=>m.code===te)??q[0],[te,q]),d=_?.decimals??2,A=n.useMemo(()=>v==null?"":(f?v/Math.pow(10,d):v).toFixed(d),[v,f,d]),b=n.useCallback(m=>{const l=m.replace(/[^\d.,\-]/g,"").replace(",",".");if(l===""||l==="-"){K?.(null);return}const c=parseFloat(l);if(isNaN(c))return;const h=f?Math.round(c*Math.pow(10,d)):c;k!=null&&h<k||C!=null&&h>C||K?.(h)},[K,f,d,k,C]),p=y??q.length>1,a=n.useMemo(()=>{if(v==null)return"";const m=f?v/Math.pow(10,d):v;try{return new Intl.NumberFormat($,{style:"currency",currency:_?.code??"USD",minimumFractionDigits:d}).format(m)}catch{return`${m.toFixed(d)} ${_?.code}`}},[v,f,d,$,_]);return M?null:e.jsxs("div",{ref:N,id:P,className:`nice-currency nice-size-${S}${H?` ${H}`:""}${o?" nice-error":""}${u?" nice-disabled":""}`,style:Y,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:[p&&e.jsx("select",{className:"nice-currency__select nice-select",value:te,onChange:m=>B?.(m.target.value),disabled:u,"aria-label":z("currency","Currency"),children:q.map(m=>e.jsxs("option",{value:m.code,children:[m.symbol," ",m.code]},m.code))}),!p&&e.jsx("span",{className:"nice-currency__symbol",children:_?.symbol}),e.jsx("input",{className:"nice-input nice-currency__amount",type:"text",inputMode:"decimal",name:w,value:A,onChange:m=>b(m.target.value),onBlur:F,placeholder:W??`0.${"0".repeat(d)}`,disabled:u,readOnly:g,"aria-label":z("amount","Amount")})]}),a&&v!=null&&e.jsx("span",{className:"nice-currency__formatted",children:a}),i&&e.jsx("span",{className:"nice-helper-text",children:i}),o&&typeof o=="string"&&e.jsx("span",{className:"nice-error-text",children:o})]})});yn.displayName="NiceCurrencyInput";let Ei=1;function Ti(t){return{id:`new-${Ei++}`,description:"",quantity:1,unitPrice:0,vatRate:t,discount:0,unit:"szt."}}function bn(t){const o=t.quantity*t.unitPrice*(1-(t.discount??0)/100),r=Math.round(o*100)/100,u=Math.round(r*(t.vatRate??0)/100*100)/100;return{...t,netAmount:r,grossAmount:r+u}}function Ri(t){const i=t.map(bn),o=i.reduce((w,L)=>w+(L.netAmount??0),0),r=i.reduce((w,L)=>w+(L.grossAmount??0),0),u=r-o,g=new Map;for(const w of i){const L=w.vatRate??0,H=g.get(L)??{base:0,amount:0};H.base+=w.netAmount??0,H.amount+=(w.grossAmount??0)-(w.netAmount??0),g.set(L,H)}const S=Array.from(g.entries()).map(([w,L])=>({rate:w,base:Math.round(L.base*100)/100,amount:Math.round(L.amount*100)/100}));return{totalNet:Math.round(o*100)/100,totalVat:Math.round(u*100)/100,totalGross:Math.round(r*100)/100,vatBreakdown:S}}const xn=n.forwardRef(({label:t,helperText:i,error:o,required:r,disabled:u,readOnly:g,size:S="md",name:w,id:L,className:H,style:Y,accessMode:U,value:v=[],onChange:K,onTotalsChange:F,currencySymbol:te="zł",defaultVatRate:B=23,vatRates:q=[0,5,8,23],units:f=["szt.","h","kg","m","usł."],showDiscount:k=!0,showUnit:C=!0,showTotals:$=!0,editable:W=!0,maxLines:y},N)=>{const x=ne._s(U,L),M=x==="hidden";x==="disabled"&&(u=!0),x==="readOnly"&&(g=!0);const{t:z}=ne.$o(),P=ne.ks(L),_=n.useMemo(()=>v.map(bn),[v]),d=n.useMemo(()=>Ri(v),[v]);n.useEffect(()=>{F?.(d)},[d,F]);const A=n.useCallback((m,l,c)=>{const h=[...v];h[m]={...h[m],[l]:c},K?.(h)},[v,K]),b=n.useCallback(()=>{y&&v.length>=y||K?.([...v,Ti(B)])},[v,K,B,y]),p=n.useCallback(m=>{K?.(v.filter((l,c)=>c!==m))},[v,K]),a=m=>`${m.toFixed(2)} ${te}`;return M?null:e.jsxs("div",{ref:N,id:P,className:`nice-invoice-lines nice-size-${S}${H?` ${H}`:""}${o?" nice-error":""}${u?" nice-disabled":""}`,style:Y,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:z("description","Description")}),e.jsx("th",{className:"nice-il__th-qty",children:z("qty","Qty")}),C&&e.jsx("th",{className:"nice-il__th-unit",children:z("unit","Unit")}),e.jsx("th",{className:"nice-il__th-price",children:z("unitPrice","Unit Price")}),k&&e.jsx("th",{className:"nice-il__th-disc",children:z("discount","Disc %")}),e.jsx("th",{className:"nice-il__th-vat",children:z("vat","VAT %")}),e.jsx("th",{className:"nice-il__th-net",children:z("net","Net")}),e.jsx("th",{className:"nice-il__th-gross",children:z("gross","Gross")}),W&&!g&&e.jsx("th",{className:"nice-il__th-actions"})]})}),e.jsx("tbody",{children:_.map((m,l)=>e.jsxs("tr",{children:[e.jsx("td",{className:"nice-il__cell-num",children:l+1}),e.jsx("td",{className:"nice-il__cell-desc",children:e.jsx("input",{className:"nice-input",type:"text",value:m.description,onChange:c=>A(l,"description",c.target.value),disabled:u,readOnly:g,placeholder:z("itemDescription","Item description")})}),e.jsx("td",{className:"nice-il__cell-qty",children:e.jsx("input",{className:"nice-input",type:"number",value:m.quantity,onChange:c=>A(l,"quantity",parseFloat(c.target.value)||0),disabled:u,readOnly:g,min:0,step:"any"})}),C&&e.jsx("td",{className:"nice-il__cell-unit",children:e.jsx("select",{className:"nice-select",value:m.unit??"",onChange:c=>A(l,"unit",c.target.value),disabled:u,children:f.map(c=>e.jsx("option",{value:c,children:c},c))})}),e.jsx("td",{className:"nice-il__cell-price",children:e.jsx("input",{className:"nice-input",type:"number",value:m.unitPrice,onChange:c=>A(l,"unitPrice",parseFloat(c.target.value)||0),disabled:u,readOnly:g,min:0,step:"0.01"})}),k&&e.jsx("td",{className:"nice-il__cell-disc",children:e.jsx("input",{className:"nice-input",type:"number",value:m.discount??0,onChange:c=>A(l,"discount",parseFloat(c.target.value)||0),disabled:u,readOnly:g,min:0,max:100})}),e.jsx("td",{className:"nice-il__cell-vat",children:e.jsx("select",{className:"nice-select",value:m.vatRate??0,onChange:c=>A(l,"vatRate",parseInt(c.target.value,10)),disabled:u,children:q.map(c=>e.jsxs("option",{value:c,children:[c,"%"]},c))})}),e.jsx("td",{className:"nice-il__cell-net",children:a(m.netAmount??0)}),e.jsx("td",{className:"nice-il__cell-gross",children:a(m.grossAmount??0)}),W&&!g&&e.jsx("td",{className:"nice-il__cell-actions",children:e.jsx("button",{type:"button",className:"nice-btn nice-btn--icon nice-btn--sm",onClick:()=>p(l),disabled:u,title:z("remove","Remove"),children:"✕"})})]},m.id))})]}),W&&!g&&e.jsxs("button",{type:"button",className:"nice-btn nice-btn--outlined nice-btn--sm nice-invoice-lines__add",onClick:b,disabled:u||y!=null&&v.length>=y,children:["+ ",z("addLine","Add line")]}),$&&e.jsxs("div",{className:"nice-invoice-lines__totals",children:[e.jsxs("div",{className:"nice-il__total-row",children:[e.jsxs("span",{children:[z("totalNet","Net total"),":"]}),e.jsx("span",{className:"nice-il__total-value",children:a(d.totalNet)})]}),d.vatBreakdown.map(m=>e.jsxs("div",{className:"nice-il__total-row nice-il__total-row--vat",children:[e.jsxs("span",{children:["VAT ",m.rate,"%:"]}),e.jsx("span",{className:"nice-il__total-value",children:a(m.amount)})]},m.rate)),e.jsxs("div",{className:"nice-il__total-row nice-il__total-row--gross",children:[e.jsxs("span",{children:[z("totalGross","Gross total"),":"]}),e.jsx("span",{className:"nice-il__total-value nice-il__total-value--gross",children:a(d.totalGross)})]})]}),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="NiceInvoiceLineEditor";const jn=n.forwardRef(({label:t,helperText:i,error:o,required:r,disabled:u,readOnly:g,size:S="md",name:w,id:L,className:H,style:Y,accessMode:U,value:v=[],onChange:K,contacts:F=[],onSearch:te,searchDelay:B=300,multiple:q=!1,placeholder:f,onContactClick:k,maxSelections:C},$)=>{const W=ne._s(U,L),y=W==="hidden";W==="disabled"&&(u=!0),W==="readOnly"&&(g=!0);const{t:N}=ne.$o(),x=ne.ks(L),[M,z]=n.useState(""),[P,_]=n.useState([]),[d,A]=n.useState(!1),[b,p]=n.useState(!1),a=n.useMemo(()=>{const h=[...F,...P],E=new Map(h.map(Q=>[Q.id,Q]));return v.map(Q=>E.get(Q)).filter(Boolean)},[v,F,P]),m=n.useCallback(h=>{if(z(h),h.length<1){_([]),A(!1);return}if(te){p(!0);const D=setTimeout(async()=>{const ee=await te(h);_(ee),A(!0),p(!1)},B);return()=>clearTimeout(D)}const E=h.toLowerCase(),Q=F.filter(D=>D.name.toLowerCase().includes(E)||D.email?.toLowerCase().includes(E)||D.phone?.includes(h));_(Q),A(!0)},[te,F,B]),l=n.useCallback(h=>{if(q)if(v.includes(h.id))K?.(v.filter(E=>E!==h.id));else{if(C&&v.length>=C)return;K?.([...v,h.id])}else K?.([h.id]),A(!1),z("")},[v,K,q,C]),c=n.useCallback(h=>{K?.(v.filter(E=>E!==h))},[v,K]);return y?null:e.jsxs("div",{ref:$,id:x,className:`nice-contact-picker nice-size-${S}${H?` ${H}`:""}${o?" nice-error":""}${u?" nice-disabled":""}`,style:Y,children:[t&&e.jsxs("label",{className:"nice-contact-picker__label",children:[t,r&&e.jsx("span",{className:"nice-required",children:"*"})]}),a.length>0&&e.jsx("div",{className:"nice-contact-picker__chips",children:a.map(h=>e.jsxs("span",{className:"nice-contact-picker__chip",onClick:()=>k?.(h),children:[h.avatarUrl&&e.jsx("img",{src:h.avatarUrl,alt:"",className:"nice-contact-picker__chip-avatar"}),e.jsx("span",{children:h.name}),!g&&e.jsx("button",{type:"button",className:"nice-contact-picker__chip-remove",onClick:E=>{E.stopPropagation(),c(h.id)},disabled:u,children:"×"})]},h.id))}),!g&&e.jsxs("div",{className:"nice-contact-picker__search",children:[e.jsx("input",{className:"nice-input",type:"text",value:M,onChange:h=>m(h.target.value),onFocus:()=>M.length>0&&A(!0),onBlur:()=>setTimeout(()=>A(!1),200),placeholder:f??N("searchContacts","Search contacts…"),disabled:u,"aria-label":N("searchContacts","Search contacts")}),b&&e.jsx("span",{className:"nice-contact-picker__spinner",children:"⏳"})]}),d&&P.length>0&&e.jsx("div",{className:"nice-contact-picker__dropdown",role:"listbox",children:P.map(h=>e.jsxs("div",{className:`nice-contact-picker__option${v.includes(h.id)?" nice-contact-picker__option--selected":""}`,role:"option","aria-selected":v.includes(h.id),onClick:()=>l(h),children:[h.avatarUrl&&e.jsx("img",{src:h.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:h.name}),h.subtitle&&e.jsx("span",{className:"nice-contact-picker__option-subtitle",children:h.subtitle}),h.email&&e.jsx("span",{className:"nice-contact-picker__option-email",children:h.email})]}),h.type&&e.jsx("span",{className:"nice-contact-picker__option-type",children:h.type==="person"?"👤":"🏢"})]},h.id))}),i&&e.jsx("span",{className:"nice-helper-text",children:i}),o&&typeof o=="string"&&e.jsx("span",{className:"nice-error-text",children:o})]})});jn.displayName="NiceContactPicker";const Ii=["highlight","underline","strikethrough","freehand","text","rect","arrow"],Ai={highlight:"🖍️",underline:"⎁",strikethrough:"S̶",freehand:"✏️",text:"T",rect:"▭",arrow:"→",stamp:"🔏"},_n=n.forwardRef(({label:t,helperText:i,error:o,required:r,disabled:u,readOnly:g,size:S="md",id:w,className:L,style:H,accessMode:Y,src:U,annotations:v=[],onAnnotationsChange:K,activeTool:F,onToolChange:te,currentPage:B=1,onPageChange:q,totalPages:f=1,defaultColor:k="var(--nice-warning, #ffff00)",tools:C=Ii,author:$,zoom:W=1,onZoomChange:y,onAnnotationClick:N,onAnnotationDelete:x},M)=>{const z=ne._s(Y,w),P=z==="hidden";z==="disabled"&&(u=!0),z==="readOnly"&&(g=!0);const{t:_}=ne.$o(),d=ne.ks(w),A=v.filter(a=>a.page===B),b=n.useCallback(a=>{te?.(F===a?null:a)},[F,te]),p=n.useCallback(a=>{if(g||!F||F==="freehand")return;const m=a.currentTarget.getBoundingClientRect(),l=(a.clientX-m.left)/m.width,c=(a.clientY-m.top)/m.height,h={id:`ann-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,tool:F,page:B,x:l,y:c,color:k,author:$,createdAt:new Date().toISOString(),text:F==="text"?"":void 0};K?.([...v,h])},[g,F,B,k,$,v,K]);return P?null:e.jsxs("div",{ref:M,id:d,className:`nice-pdf-annotation nice-size-${S}${L?` ${L}`:""}${o?" nice-error":""}${u?" nice-disabled":""}`,style:H,children:[t&&e.jsxs("div",{className:"nice-pdf-annotation__label",children:[t,r&&e.jsx("span",{className:"nice-required",children:"*"})]}),!g&&e.jsxs("div",{className:"nice-pdf-annotation__toolbar",children:[C.map(a=>e.jsx("button",{type:"button",className:`nice-pdf-annotation__tool-btn${F===a?" nice-pdf-annotation__tool-btn--active":""}`,onClick:()=>b(a),disabled:u,title:_(`pdfTool_${a}`,a),children:Ai[a]},a)),e.jsx("span",{className:"nice-pdf-annotation__toolbar-sep"}),e.jsx("button",{type:"button",disabled:u,onClick:()=>y?.(Math.max(.25,W-.25)),title:_("zoomOut","Zoom out"),children:"−"}),e.jsxs("span",{className:"nice-pdf-annotation__zoom",children:[Math.round(W*100),"%"]}),e.jsx("button",{type:"button",disabled:u,onClick:()=>y?.(Math.min(4,W+.25)),title:_("zoomIn","Zoom in"),children:"+"})]}),e.jsxs("div",{className:"nice-pdf-annotation__viewport",style:{transform:`scale(${W})`,transformOrigin:"top left"},children:[e.jsx("iframe",{src:U,className:"nice-pdf-annotation__frame",title:_("pdfViewer","PDF Viewer")}),e.jsx("div",{className:"nice-pdf-annotation__layer",onClick:p,children:A.map(a=>e.jsxs("div",{className:`nice-pdf-annotation__mark nice-pdf-annotation__mark--${a.tool}`,style:{left:`${a.x*100}%`,top:`${a.y*100}%`,backgroundColor:a.color},onClick:m=>{m.stopPropagation(),N?.(a)},title:a.text??a.tool,children:[a.text&&e.jsx("span",{children:a.text}),!g&&e.jsx("button",{type:"button",className:"nice-pdf-annotation__mark-delete",onClick:m=>{m.stopPropagation(),x?.(a.id)},children:"×"})]},a.id))})]}),e.jsxs("div",{className:"nice-pdf-annotation__pager",children:[e.jsx("button",{type:"button",disabled:u||B<=1,onClick:()=>q?.(B-1),children:"◀"}),e.jsx("span",{children:_("pageOf","{page} / {total}").replace("{page}",String(B)).replace("{total}",String(f))}),e.jsx("button",{type:"button",disabled:u||B>=f,onClick:()=>q?.(B+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})]})});_n.displayName="NicePDFAnnotationEditor";const vn=n.forwardRef(({label:t,helperText:i,error:o,disabled:r,readOnly:u,size:g="md",id:S,className:w,style:L,accessMode:H,pages:Y,selectedPageId:U,content:v="",contentFormat:K="html",editing:F=!1,onPageSelect:te,onContentChange:B,onSave:q,onCreatePage:f,onDeletePage:k,onEditToggle:C,onVersionHistory:$,sidebarWidth:W=260,sidebarCollapsed:y=!1,onSidebarToggle:N,searchable:x=!0,onSearch:M},z)=>{const P=ne._s(H,S),_=P==="hidden";P==="disabled"&&(r=!0),P==="readOnly"&&(u=!0);const{t:d}=ne.$o(),A=ne.ks(S),[b,p]=n.useState(""),[a,m]=n.useState(""),[l,c]=n.useState(!1),h=n.useMemo(()=>{const ee=ae=>{for(const O of ae){if(O.id===U)return O;if(O.children){const Z=ee(O.children);if(Z)return Z}}};return ee(Y)},[Y,U]),E=n.useCallback(ee=>{p(ee),M?.(ee)},[M]),Q=n.useCallback(()=>{a.trim()&&(f?.(U??null,a.trim()),m(""),c(!1))},[a,U,f]),D=(ee,ae=0)=>e.jsx("ul",{className:"nice-wiki__tree",style:{paddingLeft:ae>0?16:0},children:ee.map(O=>e.jsxs("li",{className:"nice-wiki__tree-item",children:[e.jsxs("div",{className:`nice-wiki__tree-node${O.id===U?" nice-wiki__tree-node--active":""}${O.isDraft?" nice-wiki__tree-node--draft":""}`,onClick:()=>te?.(O),role:"treeitem","aria-selected":O.id===U,children:[e.jsx("span",{className:"nice-wiki__tree-icon",children:O.children?.length?"📁":"📄"}),e.jsx("span",{className:"nice-wiki__tree-title",children:O.title}),O.isDraft&&e.jsx("span",{className:"nice-wiki__tree-draft",children:d("draft","Draft")})]}),O.children&&O.children.length>0&&D(O.children,ae+1)]},O.id))});return _?null:e.jsxs("div",{ref:z,id:A,className:`nice-wiki nice-size-${g}${w?` ${w}`:""}${r?" nice-disabled":""}`,style:L,children:[!y&&e.jsxs("aside",{className:"nice-wiki__sidebar",style:{width:W},children:[e.jsxs("div",{className:"nice-wiki__sidebar-header",children:[e.jsx("span",{className:"nice-wiki__sidebar-title",children:t??d("wiki","Wiki")}),N&&e.jsx("button",{type:"button",className:"nice-wiki__sidebar-toggle",onClick:()=>N(!0),children:"«"})]}),x&&e.jsx("input",{type:"text",className:"nice-input nice-wiki__search",value:b,onChange:ee=>E(ee.target.value),placeholder:d("searchPages","Search pages…"),disabled:r}),e.jsx("div",{className:"nice-wiki__page-tree",role:"tree",children:D(Y)}),f&&!u&&e.jsx("div",{className:"nice-wiki__sidebar-footer",children:l?e.jsxs("div",{className:"nice-wiki__create-form",children:[e.jsx("input",{type:"text",className:"nice-input",value:a,onChange:ee=>m(ee.target.value),placeholder:d("pageTitle","Page title"),onKeyDown:ee=>ee.key==="Enter"&&Q(),disabled:r}),e.jsx("button",{type:"button",disabled:r||!a.trim(),onClick:Q,children:"✓"}),e.jsx("button",{type:"button",onClick:()=>c(!1),children:"✕"})]}):e.jsxs("button",{type:"button",className:"nice-wiki__add-page",onClick:()=>c(!0),disabled:r,children:["+ ",d("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:h?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"nice-wiki__content-header",children:[e.jsx("h1",{className:"nice-wiki__page-title",children:h.title}),e.jsxs("div",{className:"nice-wiki__content-actions",children:[C&&!u&&e.jsx("button",{type:"button",disabled:r,onClick:()=>C(!F),children:F?d("preview","Preview"):d("edit","Edit")}),$&&e.jsx("button",{type:"button",disabled:r,onClick:()=>$(h.id),children:d("history","History")}),k&&!u&&e.jsx("button",{type:"button",className:"nice-btn--danger",disabled:r,onClick:()=>k(h.id),children:d("delete","Delete")})]})]}),h.updatedAt&&e.jsxs("div",{className:"nice-wiki__page-meta",children:[h.updatedBy&&e.jsxs("span",{children:[d("lastEditedBy","Last edited by")," ",h.updatedBy]}),e.jsx("span",{children:new Date(h.updatedAt).toLocaleDateString()})]}),F?e.jsxs("div",{className:"nice-wiki__editor",children:[e.jsx("textarea",{className:"nice-wiki__editor-textarea",value:v,onChange:ee=>B?.(ee.target.value),disabled:r}),q&&e.jsx("button",{type:"button",className:"nice-btn nice-btn--primary",disabled:r,onClick:()=>q(h.id,v),children:d("save","Save")})]}):e.jsx("div",{className:"nice-wiki__viewer",children:K==="html"?e.jsx("div",{className:"nice-wiki__html",dangerouslySetInnerHTML:{__html:ne.gs(v)}}):e.jsx("pre",{className:"nice-wiki__markdown",children:v})})]}):e.jsx("div",{className:"nice-wiki__empty",children:e.jsx("p",{children:d("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})]})});vn.displayName="NiceWiki";const Di=[{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"}],kn=n.forwardRef(({label:t,helperText:i,error:o,required:r,disabled:u,readOnly:g,size:S="md",name:w,id:L,className:H,style:Y,accessMode:U,value:v="",onChange:K,countryCode:F="PL",onCountryChange:te,countries:B=Di,showCountrySelector:q=!0,autoPrefixVat:f=!0,validationResult:k,onValidateRequest:C,placeholder:$},W)=>{const y=ne._s(U,L),N=y==="hidden";y==="disabled"&&(u=!0),y==="readOnly"&&(g=!0);const{t:x}=ne.$o(),M=ne.ks(L),z=n.useMemo(()=>B.find(b=>b.code===F)??B[0],[B,F]),P=n.useCallback(b=>{let p=b.toUpperCase();return z&&p.startsWith(z.prefix)&&(p=p.slice(z.prefix.length)),z?z.pattern.test(p):p.length>0},[z]),_=n.useCallback(b=>{const p=b.target.value.replace(/\s/g,"");K?.(p,P(p))},[K,P]),d=f&&v&&z&&!v.toUpperCase().startsWith(z.prefix)?`${z.prefix}${v}`:v,A=P(v);return N?null:e.jsxs("div",{ref:W,id:M,className:`nice-vat-input nice-size-${S}${H?` ${H}`:""}${o||!A&&v.length>0?" nice-error":""}${u?" nice-disabled":""}`,style:Y,children:[t&&e.jsxs("label",{className:"nice-vat-input__label",htmlFor:`${M}-input`,children:[t,r&&e.jsx("span",{className:"nice-required",children:"*"})]}),e.jsxs("div",{className:"nice-vat-input__row",children:[q&&e.jsx("select",{className:"nice-vat-input__country",value:F,onChange:b=>te?.(b.target.value),disabled:u||g,children:B.map(b=>e.jsx("option",{value:b.code,children:b.prefix},b.code))}),e.jsx("input",{id:`${M}-input`,className:"nice-input nice-vat-input__field",type:"text",name:w,value:v,onChange:_,readOnly:g,disabled:u,placeholder:$??z?.placeholder,required:r,"aria-invalid":!A&&v.length>0}),C&&v.length>0&&e.jsx("button",{type:"button",className:"nice-vat-input__verify",disabled:u||!A,onClick:()=>C(f?d:v,F),title:x("verifyVat","Verify VAT number"),children:"🔍"})]}),k&&e.jsxs("div",{className:`nice-vat-input__result nice-vat-input__result--${k.valid?"valid":"invalid"}`,children:[k.valid?"✅":"❌"," ",k.companyName??k.error??(k.valid?x("vatValid","VAT number valid"):x("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})]})});kn.displayName="NiceVatInput";const Li=[{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"}],wn=n.forwardRef(({label:t,helperText:i,error:o,required:r,disabled:u,readOnly:g,size:S="md",name:w,id:L,className:H,style:Y,accessMode:U,value:v,onChange:K,rates:F,countryCode:te,placeholder:B,showPercentage:q=!0},f)=>{const k=ne._s(U,L),C=k==="hidden";k==="disabled"&&(u=!0),k==="readOnly"&&(g=!0);const{t:$}=ne.$o(),W=ne.ks(L),y=n.useMemo(()=>{const x=F??Li;return te?x.filter(M=>!M.countryCode||M.countryCode===te):x},[F,te]),N=n.useCallback(x=>{const M=x.target.value,z=y.find(P=>P.id===M);z&&K?.(M,z)},[K,y]);return C?null:e.jsxs("div",{ref:f,id:W,className:`nice-tax-rate nice-size-${S}${H?` ${H}`:""}${o?" nice-error":""}${u?" nice-disabled":""}`,style:Y,children:[t&&e.jsxs("label",{className:"nice-tax-rate__label",htmlFor:`${W}-select`,children:[t,r&&e.jsx("span",{className:"nice-required",children:"*"})]}),e.jsxs("select",{id:`${W}-select`,className:"nice-select nice-tax-rate__select",name:w,value:v??"",onChange:N,disabled:u||g,required:r,children:[e.jsx("option",{value:"",disabled:!0,children:B??$("selectRate","Select rate…")}),y.map(x=>e.jsxs("option",{value:x.id,children:[x.label,q&&x.category!=="exempt"?` (${(x.rate*100).toFixed(0)}%)`:""]},x.id))]}),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="NiceTaxRatePicker";const zi={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)"},Nn=n.forwardRef(({label:t,helperText:i,error:o,required:r,disabled:u,readOnly:g,size:S="md",name:w,id:L,className:H,style:Y,accessMode:U,value:v,onChange:K,accounts:F,treeView:te=!1,placeholder:B,searchable:q=!0,showType:f=!0,onSearch:k},C)=>{const $=ne._s(U,L),W=$==="hidden";$==="disabled"&&(u=!0),$==="readOnly"&&(g=!0);const{t:y}=ne.$o(),N=ne.ks(L),[x,M]=n.useState(""),[z,P]=n.useState(!1),_=n.useMemo(()=>{const a=m=>{for(const l of m){if(l.code===v)return l;if(l.children){const c=a(l.children);if(c)return c}}};return a(F)},[F,v]),d=n.useMemo(()=>{const a=[],m=l=>{for(const c of l)a.push(c),c.children&&m(c.children)};return m(F),a},[F]),A=n.useMemo(()=>{if(!x)return d;const a=x.toLowerCase();return d.filter(m=>m.code.toLowerCase().includes(a)||m.name.toLowerCase().includes(a))},[d,x]),b=n.useCallback(a=>{M(a),k?.(a),P(!0)},[k]),p=n.useCallback(a=>{K?.(a.code,a),P(!1),M("")},[K]);return W?null:e.jsxs("div",{ref:C,id:N,className:`nice-account-picker nice-size-${S}${H?` ${H}`:""}${o?" nice-error":""}${u?" nice-disabled":""}`,style:Y,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:q&&!g?e.jsx("input",{id:`${N}-input`,className:"nice-input",type:"text",value:z?x:_?`${_.code} — ${_.name}`:"",onChange:a=>b(a.target.value),onFocus:()=>{M(""),P(!0)},onBlur:()=>setTimeout(()=>P(!1),200),placeholder:B??y("searchAccount","Search account…"),disabled:u,required:r}):e.jsx("div",{className:"nice-account-picker__display",children:_?`${_.code} — ${_.name}`:B??y("selectAccount","Select account…")})}),z&&A.length>0&&e.jsx("div",{className:"nice-account-picker__dropdown",role:"listbox",children:A.map(a=>e.jsxs("div",{className:`nice-account-picker__option${a.code===v?" nice-account-picker__option--selected":""}${a.isActive===!1?" nice-account-picker__option--inactive":""}`,role:"option","aria-selected":a.code===v,onClick:()=>p(a),children:[f&&a.type&&e.jsx("span",{className:"nice-account-picker__type",style:{color:zi[a.type]},title:a.type,children:"●"}),e.jsx("span",{className:"nice-account-picker__code",children:a.code}),e.jsx("span",{className:"nice-account-picker__name",children:a.name})]},a.code))}),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="NiceAccountPicker";const Cn=n.forwardRef(({label:t,helperText:i,error:o,required:r,disabled:u,readOnly:g,size:S="md",id:w,className:L,style:H,accessMode:Y,mode:U="manual",onScan:v,onModeChange:K,beepOnScan:F=!0,beepFrequency:te=1800,beepDuration:B=150,placeholder:q,scanHistory:f=[],showHistory:k=!0,maxHistory:C=10,autoFocus:$=!0,onCameraFrame:W},y)=>{const N=ne._s(Y,w),x=N==="hidden";N==="disabled"&&(u=!0),N==="readOnly"&&(g=!0);const{t:M}=ne.$o(),z=ne.ks(w),[P,_]=n.useState(""),d=n.useRef(null),A=n.useRef(null),b=n.useCallback(()=>{if(F)try{A.current||(A.current=new AudioContext);const m=A.current,l=m.createOscillator(),c=m.createGain();l.connect(c),c.connect(m.destination),l.frequency.value=te,l.type="square",c.gain.value=.3,l.start(),l.stop(m.currentTime+B/1e3)}catch{}},[F,te,B]),p=n.useCallback(()=>{P.trim()&&(b(),v?.({value:P.trim(),format:"manual",scannedAt:new Date}),_(""),d.current?.focus())},[P,v,b]),a=f.slice(0,C);return x?null:e.jsxs("div",{ref:y,id:z,className:`nice-scanner nice-size-${S}${L?` ${L}`:""}${o?" nice-error":""}${u?" nice-disabled":""}`,style:H,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${U==="camera"?" nice-scanner__mode-btn--active":""}`,onClick:()=>K?.("camera"),disabled:u,children:["📷 ",M("camera","Camera")]}),e.jsxs("button",{type:"button",className:`nice-scanner__mode-btn${U==="manual"?" nice-scanner__mode-btn--active":""}`,onClick:()=>K?.("manual"),disabled:u,children:["⌨️ ",M("manual","Manual")]})]}),U==="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:M("cameraPlaceholder","Camera preview — connect scanner adapter")})]})})}),U==="manual"&&!g&&e.jsxs("div",{className:"nice-scanner__manual",children:[e.jsx("input",{ref:d,className:"nice-input nice-scanner__input",type:"text",value:P,onChange:m=>_(m.target.value),onKeyDown:m=>m.key==="Enter"&&p(),placeholder:q??M("enterCode","Enter or scan code…"),disabled:u,autoFocus:$}),e.jsx("button",{type:"button",className:"nice-scanner__submit",onClick:p,disabled:u||!P.trim(),children:"✓"})]}),k&&a.length>0&&e.jsxs("div",{className:"nice-scanner__history",children:[e.jsx("div",{className:"nice-scanner__history-label",children:M("recentScans","Recent scans")}),a.map((m,l)=>e.jsxs("div",{className:"nice-scanner__history-item",children:[e.jsx("span",{className:"nice-scanner__history-value",children:m.value}),m.format&&e.jsx("span",{className:"nice-scanner__history-format",children:m.format}),e.jsx("span",{className:"nice-scanner__history-time",children:m.scannedAt.toLocaleTimeString()})]},l))]}),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="NiceScannerControl";const Sn=n.forwardRef(({label:t,helperText:i,error:o,required:r,disabled:u,readOnly:g,size:S="md",id:w,className:L,style:H,accessMode:Y,value:U="",onChange:v,onComplete:K,length:F=4,masked:te=!0,showKeypad:B=!1,autoSubmit:q=!0,shake:f=!1,placeholderChar:k="·"},C)=>{const $=ne._s(Y,w),W=$==="hidden";$==="disabled"&&(u=!0),$==="readOnly"&&(g=!0);const{t:y}=ne.$o(),N=ne.ks(w),x=n.useRef([]),[M,z]=n.useState(!1);n.useEffect(()=>{if(f){z(!0);const b=setTimeout(()=>z(!1),500);return()=>clearTimeout(b)}},[f]);const P=U.split("").slice(0,F);for(;P.length<F;)P.push("");const _=n.useCallback((b,p)=>{const a=[...P];a[b]=p;const m=a.join("");v?.(m),p&&b<F-1&&x.current[b+1]?.focus(),q&&m.length===F&&m.indexOf("")===-1&&K?.(m)},[P,F,v,K,q]),d=n.useCallback((b,p)=>{b.key==="Backspace"&&!P[p]&&p>0&&(x.current[p-1]?.focus(),_(p-1,"")),b.key==="ArrowLeft"&&p>0&&x.current[p-1]?.focus(),b.key==="ArrowRight"&&p<F-1&&x.current[p+1]?.focus()},[P,F,_]),A=n.useCallback(b=>{if(b==="clear"){v?.(""),x.current[0]?.focus();return}if(b==="backspace"){const p=U.slice(0,-1);v?.(p);const a=Math.max(0,p.length-1);x.current[a]?.focus();return}if(U.length<F){const p=U+b;v?.(p),p.length<F&&x.current[p.length]?.focus(),q&&p.length===F&&K?.(p)}},[U,F,v,K,q]);return W?null:e.jsxs("div",{ref:C,id:N,className:`nice-pin nice-size-${S}${M?" nice-pin--shake":""}${L?` ${L}`:""}${o?" nice-error":""}${u?" nice-disabled":""}`,style:H,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((b,p)=>e.jsx("input",{ref:a=>{x.current[p]=a},className:"nice-pin__box",type:te?"password":"text",inputMode:"numeric",maxLength:1,value:b,onChange:a=>{const m=a.target.value.replace(/\D/g,"");m.length<=1&&_(p,m)},onKeyDown:a=>d(a,p),disabled:u,readOnly:g,placeholder:k,"aria-label":`${y("digit","Digit")} ${p+1}`},p))}),B&&!g&&e.jsx("div",{className:"nice-pin__keypad",children:["1","2","3","4","5","6","7","8","9","clear","0","backspace"].map(b=>e.jsx("button",{type:"button",className:`nice-pin__key${b==="clear"||b==="backspace"?" nice-pin__key--action":""}`,onClick:()=>A(b),disabled:u,children:b==="clear"?"C":b==="backspace"?"⌫":b},b))}),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="NicePinCodeInput";exports.DEFAULT_ASPECT_RATIOS=ln;exports.EMOJI_DATA=Qe;exports.GRADIENT_PRESETS=Vt;exports.NICE_COLOR_PRESET_KEYS=zn;exports.NiceAccountPicker=Nn;exports.NiceAddressInput=fn;exports.NiceCalendar=qt;exports.NiceCodeDiffEditor=sn;exports.NiceCodeEditor=yt;exports.NiceCodeEditor$1=li;exports.NiceCodeEditorAI=di;exports.NiceColorPalette=Ut;exports.NiceContactPicker=jn;exports.NiceCropEditor=dn;exports.NiceCurrencyInput=yn;exports.NiceDateRangeBox=Un;exports.NiceDocumentEditor=gn;exports.NiceDropDownBox=Vn;exports.NiceEmojiPicker=cn;exports.NiceGradientPicker=Xt;exports.NiceHtmlEditor=ft;exports.NiceHtmlEditor$1=ei;exports.NiceHtmlEditorAI=ii;exports.NiceImageAnnotator=mn;exports.NiceImageEditor=pn;exports.NiceInputOtp=Gt;exports.NiceInvoiceLineEditor=xn;exports.NiceKnob=Zt;exports.NiceLookup=Fn;exports.NiceMarkdownEditor=un;exports.NiceMention=Jt;exports.NicePDFAnnotationEditor=_n;exports.NicePickList=on;exports.NicePinCodeInput=Sn;exports.NiceRangeSlider=Wn;exports.NiceScannerControl=Cn;exports.NiceSignature=mi;exports.NiceSignaturePad=hn;exports.NiceSimpleCodeEditor=rn;exports.NiceTaxRatePicker=wn;exports.NiceTreeSelect=nn;exports.NiceVatInput=kn;exports.NiceWiki=vn;exports.applyPreset=Ge;exports.contrastRatio=Xe;exports.cssToGradient=Wt;exports.generateHarmony=Be;exports.generateVariations=Ot;exports.gradientToCss=mt;exports.hexToHsv=He;exports.hexToRgb=Oe;exports.hsvToHex=Ne;exports.hsvToRgb=Ht;exports.randomPalette=Yt;exports.rgbToHex=Bt;exports.rgbToHsl=Ft;exports.rgbToHsv=ht;exports.wcagLevel=qe;