@nice2dev/ui 1.0.8 → 1.0.10

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