@nice2dev/ui 1.0.22 → 1.0.23

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 (61) hide show
  1. package/CHANGELOG.md +54 -0
  2. package/dist/NiceErrorBoundary-BNhkOZtq.cjs +1 -0
  3. package/dist/NiceErrorBoundary-DyPWyuki.js +770 -0
  4. package/dist/NiceForm-D_ifvkIf.js +5386 -0
  5. package/dist/NiceForm-kd4essRP.cjs +382 -0
  6. package/dist/NiceForm.css +1 -1
  7. package/dist/NiceModal-4DLpDmAl.js +95 -0
  8. package/dist/NiceModal-D2xJTZZf.cjs +1 -0
  9. package/dist/NiceModuleLifecyclePanel-BZMUuDad.js +6807 -0
  10. package/dist/NiceModuleLifecyclePanel-C54g5eV_.cjs +1 -0
  11. package/dist/NicePagination-3be3_sVK.js +171 -0
  12. package/dist/NicePagination-BCRsVzkR.cjs +1 -0
  13. package/dist/NicePinCodeInput-BD2bMmVF.cjs +696 -0
  14. package/dist/NicePinCodeInput-DCLRLR8a.js +13097 -0
  15. package/dist/NiceSavedQueryPanel-DT9v7kUB.cjs +596 -0
  16. package/dist/NiceSavedQueryPanel-RLj3BnDR.js +6866 -0
  17. package/dist/NiceTabs-CFA8DGYR.cjs +1 -0
  18. package/dist/NiceTabs-Cx9DN6QD.js +1657 -0
  19. package/dist/NiceWindow-5VCSBJrc.js +1592 -0
  20. package/dist/NiceWindow-BEFAUTLp.cjs +1 -0
  21. package/dist/charts-De7FYS1U.cjs +761 -0
  22. package/dist/charts-DjFvhCdD.js +4657 -0
  23. package/dist/charts.cjs +1 -1
  24. package/dist/charts.mjs +1 -1
  25. package/dist/core-CT5vpy5U.js +25248 -0
  26. package/dist/core-CZE5v34h.cjs +122 -0
  27. package/dist/data-branching-B7dCyaWr.cjs +1 -0
  28. package/dist/data-branching-BPAeL45o.js +6133 -0
  29. package/dist/data-branching.cjs +1 -1
  30. package/dist/data-branching.mjs +1 -1
  31. package/dist/data.cjs +1 -1
  32. package/dist/data.d.ts +36 -1
  33. package/dist/data.mjs +1 -1
  34. package/dist/devops-C3Pmbnxc.js +7684 -0
  35. package/dist/devops-CrXz348W.cjs +17 -0
  36. package/dist/devops.cjs +1 -1
  37. package/dist/devops.mjs +1 -1
  38. package/dist/editors.cjs +1 -1
  39. package/dist/editors.d.ts +5 -2
  40. package/dist/editors.mjs +3 -3
  41. package/dist/feedback.cjs +1 -1
  42. package/dist/feedback.mjs +2 -2
  43. package/dist/index-9Gi1mNY7.js +67912 -0
  44. package/dist/index-Di3Cgr1P.cjs +5518 -0
  45. package/dist/index.cjs +1 -1
  46. package/dist/index.css +1 -1
  47. package/dist/index.d.ts +257 -46
  48. package/dist/index.mjs +743 -740
  49. package/dist/lazy.cjs +1 -1
  50. package/dist/lazy.mjs +24 -24
  51. package/dist/navigation.cjs +1 -1
  52. package/dist/navigation.d.ts +30 -4
  53. package/dist/navigation.mjs +4 -4
  54. package/dist/no-code-CHvv1KjZ.cjs +332 -0
  55. package/dist/no-code-CyvddsYt.js +7133 -0
  56. package/dist/no-code.cjs +1 -1
  57. package/dist/no-code.mjs +1 -1
  58. package/dist/overlays.cjs +1 -1
  59. package/dist/overlays.mjs +31 -31
  60. package/dist/style.css +2 -2
  61. package/package.json +1 -1
@@ -0,0 +1,696 @@
1
+ "use strict";const e=require("react/jsx-runtime"),q=require("./core-CZE5v34h.cjs"),n=require("react"),je=require("./NiceTabs-CFA8DGYR.cjs"),jt=require("./NiceForm-kd4essRP.cjs");function Hn(t,i=30){switch(t){case"monochromatic":return[0];case"complementary":return[0,180];case"split-complementary":return[0,180-i,180+i];case"analogous":return[0,-i,i];case"triadic":return[0,120,240];case"tetradic":return[0,60,180,240];case"square":return[0,90,180,270];case"shade-chain":return[];case"custom":return[0,60,200];default:return[0]}}function _t(t,i={}){const o=i.size??16,a="currentColor",m="currentColor";if(i.rectangle||t==="shade-chain"||t==="monochromatic"){const B=Math.max(3,Math.min(7,i.count??5)),x=o*.1,F=o-x*2,P=Math.max(1.2,o/14),G=o/2,H=Array.from({length:B},(U,v)=>{const k=x+F*v/(B-1),O=.25+.75*v/(B-1);return e.jsx("circle",{cx:k,cy:G,r:P,fill:m,opacity:O},v)});return e.jsxs("svg",{width:o,height:o,viewBox:`0 0 ${o} ${o}`,"aria-hidden":!0,children:[e.jsx("rect",{x:1,y:o/2-o/6,width:o-2,height:o/3,rx:o/6,fill:"none",stroke:a,strokeOpacity:.25}),H]})}const w=i.angles??Hn(t),_=o/2,R=o/2,z=o/2-2,Y=Math.max(1.4,o/9);return e.jsxs("svg",{width:o,height:o,viewBox:`0 0 ${o} ${o}`,"aria-hidden":!0,children:[e.jsx("circle",{cx:_,cy:R,r:z,fill:"none",stroke:a,strokeOpacity:.25}),w.map((B,x)=>{const F=(B-90)*Math.PI/180,P=_+z*Math.cos(F),G=R+z*Math.sin(F);return e.jsx("circle",{cx:P,cy:G,r:Y,fill:m},x)})]})}function vt(t,i,o){return Math.max(i,Math.min(o,t))}function Wt({h:t,s:i,v:o}){t=(t%360+360)%360;const a=o*i,m=a*(1-Math.abs(t/60%2-1)),g=o-a;let w=0,_=0,R=0;return t<60?(w=a,_=m):t<120?(w=m,_=a):t<180?(_=a,R=m):t<240?(_=m,R=a):t<300?(w=m,R=a):(w=a,R=m),{r:Math.round((w+g)*255),g:Math.round((_+g)*255),b:Math.round((R+g)*255)}}function ft({r:t,g:i,b:o}){t/=255,i/=255,o/=255;const a=Math.max(t,i,o),m=Math.min(t,i,o),g=a-m;let w=0;return g!==0&&(a===t?w=(i-o)/g%6:a===i?w=(o-t)/g+2:w=(t-i)/g+4,w=(w*60+360)%360),{h:w,s:a===0?0:g/a,v:a}}function Vt({r:t,g:i,b:o}){t/=255,i/=255,o/=255;const a=Math.max(t,i,o),m=Math.min(t,i,o),g=(a+m)/2;if(a===m)return{h:0,s:0,l:g};const w=a-m,_=g>.5?w/(2-a-m):w/(a+m);let R=0;return a===t?R=((i-o)/w+(i<o?6:0))/6:a===i?R=((o-t)/w+2)/6:R=((t-i)/w+4)/6,{h:R*360,s:_,l:g}}function Ze(t){const i=t.replace("#",""),o=i.length===3?i[0]+i[0]+i[1]+i[1]+i[2]+i[2]:i,a=parseInt(o,16);return{r:a>>16&255,g:a>>8&255,b:a&255}}function Xt({r:t,g:i,b:o}){return"#"+[t,i,o].map(a=>a.toString(16).padStart(2,"0")).join("")}function $e(t){return Xt(Wt(t))}function Ie(t){return ft(Ze(t))}function qt(t,i){const o=[];for(let a=0;a<i;a++){const m=i<=1?.5:a/(i-1),g=vt(t.s*(.3+m*.7),0,1),w=vt(t.v*(1.2-m*.7),0,1);o.push($e({h:t.h,s:g,v:w}))}return o}function yt(t,i){if(t==="custom"||t==="shade-chain")return[0];const o=i??30;switch(t){case"monochromatic":return[0];case"complementary":return[0,180];case"split-complementary":return[0,180-o,180+o];case"analogous":return[0,-o,o];case"triadic":return[0,120,240];case"tetradic":return[0,60,180,240];case"square":return[0,90,180,270]}return[0]}function Ge(t,i,o){return yt(i,o).map(a=>((t+a)%360+360)%360)}function kt(t,i,o=.12){const a=Math.max(2,i),m=(a-1)/2,g=[];for(let w=0;w<a;w++){const _=(w-m)*o,R=Math.max(.05,Math.min(.98,t.v+_)),z=Math.max(.05,Math.min(1,t.s-Math.abs(_)*.25));g.push($e({h:t.h,s:z,v:R}))}return g}function wt({r:t,g:i,b:o}){const[a,m,g]=[t,i,o].map(w=>{const _=w/255;return _<=.03928?_/12.92:Math.pow((_+.055)/1.055,2.4)});return .2126*a+.7152*m+.0722*g}function tt(t,i){const o=wt(Ze(t)),a=wt(Ze(i)),m=Math.max(o,a),g=Math.min(o,a);return(m+.05)/(g+.05)}function nt(t){return t>=7?"AAA":t>=4.5?"AA":t>=3?"AA-lg":"Fail"}const Gt={"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 it(t,i){const o=Gt[i];return t.map(a=>{const m=(o.sRange[0]+o.sRange[1])/2,g=(o.vRange[0]+o.vRange[1])/2;return $e({h:a,s:m,v:g})})}function Fn(){return Math.floor(Math.random()*360)}function Zt(t,i,o){const a=Fn(),m=Ge(a,t,o),g=[];for(let w=0;w<i;w++){const _=m[w%m.length],R=.55+Math.random()*.4,z=.5+Math.random()*.45;g.push($e({h:_+(Math.random()-.5)*8,s:R,v:z}))}return g}const Bn=({hues:t,baseHue:i,onBaseHueChange:o,mode:a,distance:m,disabled:g})=>{const B=n.useCallback(H=>{if(g)return;const v=H.currentTarget.getBoundingClientRect(),k=H.clientX-v.left-120,O=H.clientY-v.top-120,j=(Math.atan2(O,k)*180/Math.PI+360)%360;o(Math.round(j))},[120,120,g,o]),x=[];for(let H=0;H<360;H+=2){const U=(H-1)*Math.PI/180,v=(H+1)*Math.PI/180,k=$e({h:H,s:1,v:1});x.push(e.jsx("path",{d:`M${120+55*Math.cos(U)},${120+55*Math.sin(U)} L${120+110*Math.cos(U)},${120+110*Math.sin(U)} A110,110 0 0,1 ${120+110*Math.cos(v)},${120+110*Math.sin(v)} L${120+55*Math.cos(v)},${120+55*Math.sin(v)} A55,55 0 0,0 ${120+55*Math.cos(U)},${120+55*Math.sin(U)} Z`,fill:k},H))}const F=`wheel-center-${a}`,P=t.map((H,U)=>{const k=H*Math.PI/180;return e.jsx("circle",{cx:120+82.5*Math.cos(k),cy:120+82.5*Math.sin(k),r:U===0?8:6,fill:$e({h:H,s:.85,v:.9}),stroke:U===0?"var(--bg-primary, #fff)":"var(--border-color, #ccc)",strokeWidth:U===0?3:2},U)});let G=null;if(a==="analogous"||a==="split-complementary"){const v=yt(a,m).slice(1).map((k,O)=>{const j=(i+k)*Math.PI/180;return e.jsx("line",{x1:120,y1:120,x2:120+82.5*Math.cos(j),y2:120+82.5*Math.sin(j),stroke:"var(--nice-overlay-light-30, rgba(255, 255, 255, 0.3))",strokeWidth:1,strokeDasharray:"3,3"},`dline-${O}`)});G=e.jsx(e.Fragment,{children:v})}return e.jsxs("svg",{className:"nice-palette__wheel",viewBox:"0 0 240 240",width:240,height:240,onClick:B,style:{cursor:g?"default":"crosshair"},children:[e.jsx("defs",{children:e.jsxs("radialGradient",{id:F,children:[e.jsx("stop",{offset:"0%",stopColor:"var(--nice-bg, #fff)"}),e.jsx("stop",{offset:"100%",stopColor:"transparent"})]})}),x,e.jsx("circle",{cx:120,cy:120,r:53,fill:$e({h:i,s:.6,v:.85})}),e.jsx("circle",{cx:120,cy:120,r:53,fill:`url(#${F})`,opacity:.4}),G,P]})},Kn=({colors:t})=>{if(t.length<2)return null;const i=[];for(let o=0;o<t.length;o++){const a=tt(t[o],"var(--bg-primary, #ffffff)"),m=tt(t[o],"var(--text-primary, #000000)");i.push({a:t[o],b:"var(--bg-primary, #ffffff)",ratio:a,level:nt(a)}),i.push({a:t[o],b:"var(--text-primary, #000000)",ratio:m,level:nt(m)});for(let g=o+1;g<t.length;g++){const w=tt(t[o],t[g]);i.push({a:t[o],b:t[g],ratio:w,level:nt(w)})}}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,a)=>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})]},a))})]})},Un=({hex:t})=>{const i=Ze(t),o=Vt(i),a=ft(i);return e.jsxs("div",{className:"nice-palette__color-info",children:[e.jsxs("div",{children:[e.jsx("strong",{children:"HEX"})," ",t.toUpperCase()]}),e.jsxs("div",{children:[e.jsx("strong",{children:"RGB"})," ",i.r,", ",i.g,", ",i.b]}),e.jsxs("div",{children:[e.jsx("strong",{children:"HSL"})," ",Math.round(o.h),"°, ",Math.round(o.s*100),"%,"," ",Math.round(o.l*100),"%"]}),e.jsxs("div",{children:[e.jsx("strong",{children:"HSV"})," ",Math.round(a.h),"°, ",Math.round(a.s*100),"%,"," ",Math.round(a.v*100),"%"]})]})},Yn={monochromatic:"Monochromatic",complementary:"Complementary","split-complementary":"Split-Complementary",analogous:"Analogous",triadic:"Triadic",tetradic:"Tetradic (Rectangle)",square:"Square","shade-chain":"Shade chain",custom:"Custom"},Wn={"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"},Vn=["monochromatic","shade-chain","complementary","split-complementary","analogous","triadic","tetradic","square","custom"],Xn=["lightest-pastel","bright-pastel","shiny","pastel","full","dark","deep","muted","earth"],Jt="nice-palette-custom-schemes";function qn(){if(typeof window>"u")return[];try{const t=window.localStorage.getItem(Jt);if(!t)return[];const i=JSON.parse(t);if(Array.isArray(i))return i}catch{}return[]}function Gn(t){if(!(typeof window>"u"))try{window.localStorage.setItem(Jt,JSON.stringify(t))}catch{}}const Qt=n.forwardRef(({id:t,className:i,style:o,accessMode:a,value:m,onChange:g,minColors:w=1,maxColors:_=8,harmonyMode:R,onHarmonyModeChange:z,distance:Y,onDistanceChange:B,preset:x,onPresetChange:F,showWheel:P=!0,showContrast:G=!0,showInfo:H=!0,showPresets:U=!0,presets:v=[],showVariations:k=!0,showRandom:O=!0,variationCount:j=5,label:A,disabled:E,colorCount:b,shadeStep:h,onShadeStepChange:M,customSchemes:I,onCustomSchemesChange:S,persistCustomSchemes:y=!0},c)=>{const L=q.sc(a,t),C=L==="hidden";(L==="disabled"||L==="readOnly")&&(E=!0);const u=q._s(t),{t:l}=q.Zt(),[s,p]=n.useState("analogous"),[f,d]=n.useState(30),[$,K]=n.useState(""),[ee,D]=n.useState(0),[ge,re]=n.useState(.12),[ye,ne]=n.useState(null),[se,le]=n.useState(()=>I??(y?qn():[])),[ue,be]=n.useState(null),te=R??s,ce=Y??f,de=x??$,oe=h??ge,J=I??se;n.useEffect(()=>{!I&&y&&Gn(se)},[se,I,y]);const W=n.useCallback(ie=>{le(ie),S?.(ie)},[S]),N=n.useCallback(ie=>{p(ie),z?.(ie)},[z]),Z=n.useCallback(ie=>{d(ie),B?.(ie)},[B]),fe=n.useCallback(ie=>{K(ie),ie&&F?.(ie)},[F]),Q=n.useMemo(()=>["var(--color-primary, #3b82f6)","var(--color-error, #ef4444)","var(--color-success, #22c55e)"],[]),V=m&&m.length>0?m:Q,me=V[0],xe=n.useMemo(()=>Ie(me),[me]),ke=n.useMemo(()=>Ge(xe.h,te,ce),[xe.h,te,ce]),ve=n.useCallback((ie,he,_e,Me)=>{const r=b??ye??void 0,T=r!==void 0?Math.max(w,Math.min(_,r)):void 0;if(he==="shade-chain"){const Ne=T??Math.max(w,5),Se=kt({h:ie,s:xe.s||.7,v:xe.v||.6},Ne,oe);g?.(Se);return}let X;const ae=he==="custom"&&ue?J.find(Ne=>Ne.id===ue):null;ae&&ae.angles.length>0?X=ae.angles.map(Ne=>((ie+Ne)%360+360)%360):X=Ge(ie,he,_e);let pe;if(Me&&Gt[Me]?pe=it(X,Me):pe=X.map(Ne=>$e({h:Ne,s:xe.s||.7,v:xe.v||.85})),ae?.lightnessOffsets?.length&&(pe=pe.map((Ne,Se)=>{const Pe=ae.lightnessOffsets?.[Se];if(Pe==null)return Ne;const Ee=Ie(Ne);return $e({h:Ee.h,s:Ee.s,v:Math.max(.05,Math.min(.98,Ee.v+Pe))})})),T!==void 0){for(;pe.length<T;){const Ne=pe[pe.length-1]||"#888888",Se=Ie(Ne);pe.push($e({h:(Se.h+18)%360,s:Se.s,v:Se.v}))}pe=pe.slice(0,T)}else{for(;pe.length<w;)pe.push(pe[pe.length-1]||"var(--nice-text-secondary, #888888)");pe.length>_&&(pe=pe.slice(0,_))}g?.(pe)},[xe.s,xe.v,w,_,g,b,ye,oe,ue,J]),we=n.useCallback(ie=>{if(!E){if(te==="custom"){const he=$e({h:ie,s:xe.s||.7,v:xe.v||.85}),_e=[...V];_e[ee]=he,g?.(_e);return}ve(ie,te,ce,de)}},[E,te,ce,de,ve,xe.s,xe.v,V,ee,g]),Re=n.useCallback(ie=>{E||(N(ie),ie!=="custom"&&ve(xe.h,ie,ce,de))},[E,xe.h,ce,de,N,ve]),Be=n.useCallback(ie=>{E||(Z(ie),ve(xe.h,te,ie,de))},[E,xe.h,te,de,Z,ve]),Te=n.useCallback(ie=>{if(E)return;fe(ie);const he=Ge(xe.h,te,ce),_e=it(he,ie);g?.(_e.slice(0,_))},[E,xe.h,te,ce,_,fe,g]),Ae=n.useCallback((ie,he)=>{if(E)return;const _e=[...V];_e[ie]=he,g?.(_e)},[E,V,g]),Ke=n.useCallback(()=>{if(E||V.length>=_)return;const ie=Ie(V[V.length-1]),he=$e({h:(ie.h+30)%360,s:ie.s,v:ie.v});g?.([...V,he])},[E,V,_,g]),Ue=n.useCallback(ie=>{if(E||V.length<=w)return;const he=V.filter((_e,Me)=>Me!==ie);g?.(he),ee>=he.length&&D(Math.max(0,he.length-1))},[E,V,w,g,ee]),Ye=n.useCallback(()=>{if(E)return;const ie=Math.max(w,Math.min(_,yt(te).length)),he=Zt(te,ie,ce);g?.(he)},[E,w,_,te,ce,g]),Le=n.useMemo(()=>{if(!k)return[];const ie=V[ee]||V[0];return qt(Ie(ie),j)},[k,V,ee,j]),De=V[ee]||V[0],ze=n.useMemo(()=>{const ie=Ie(De);return $e({h:(ie.h+180)%360,s:ie.s,v:ie.v})},[De]);return C?null:e.jsxs("div",{ref:c,id:u,className:`nice-palette ${E?"nice-palette--disabled":""} ${i||""}`,style:o,children:[A&&e.jsx("div",{className:"nice-palette__label",children:A}),e.jsxs("div",{className:"nice-palette__modes",style:{display:"flex",gap:8,alignItems:"center",flexWrap:"wrap"},children:[e.jsx(je.NiceSelect,{label:l("colorPalette.harmony","Harmony"),labelPlacement:"left",size:"sm",disabled:E,value:te==="custom"&&ue?`custom:${ue}`:te,onChange:ie=>{const he=Array.isArray(ie)?ie[0]:ie;if(typeof he=="string")if(he.startsWith("custom:")){const _e=he.slice(7);be(_e),Re("custom")}else be(null),Re(he)},options:[...Vn.map(ie=>({value:ie,label:Yn[ie]})),...J.map(ie=>({value:`custom:${ie.id}`,label:`★ ${ie.name}`}))],renderOption:(ie,he)=>{const _e=String(ie.value),Me=_e.startsWith("custom:"),r=Me?J.find(ae=>ae.id===_e.slice(7)):null,T=r?r.angles:void 0,X=Me?"custom":_e;return e.jsxs("span",{style:{display:"inline-flex",gap:8,alignItems:"center"},children:[e.jsx("span",{style:{width:16,height:16,display:"inline-flex",color:"currentColor"},children:_t(X,{angles:T,size:16,count:b})}),e.jsx("span",{style:{fontWeight:he?600:400},children:ie.label})]})}}),te==="shade-chain"&&e.jsx(je.NiceNumberInput,{label:l("colorPalette.step","Step"),labelPlacement:"left",size:"sm",min:.02,max:.5,step:.02,precision:2,value:oe,onChange:ie=>{const he=typeof ie=="number"?ie:Number(ie);Number.isNaN(he)||(re(he),M?.(he),ve(xe.h,te,ce,de))},showStepper:!0,disabled:E}),e.jsx(je.NiceNumberInput,{label:l("colorPalette.colors","Colors"),labelPlacement:"left",size:"sm",min:Math.max(2,w),max:Math.min(12,_),step:1,precision:0,value:b??ye??V.length,onChange:ie=>{const he=typeof ie=="number"?ie:Number(ie);if(!Number.isFinite(he))return;const _e=Math.max(Math.max(2,w),Math.min(Math.min(12,_),Math.round(he)));ne(_e),te==="shade-chain"?g?.(kt({h:xe.h,s:xe.s||.7,v:xe.v||.6},_e,oe)):setTimeout(()=>ve(xe.h,te,ce,de),0)},showStepper:!0,disabled:E})]}),e.jsxs("div",{className:"nice-palette__main",children:[P&&e.jsxs("div",{className:"nice-palette__wheel-container",children:[e.jsx(Bn,{hues:ke,baseHue:xe.h,onBaseHueChange:we,mode:te,distance:ce,disabled:E}),(te==="analogous"||te==="split-complementary")&&e.jsxs("div",{className:"nice-palette__distance",children:[e.jsxs("label",{children:["Distance: ",ce,"°"]}),e.jsx("input",{type:"range",min:10,max:90,value:ce,onChange:ie=>Be(Number(ie.target.value)),disabled:E,className:"nice-palette__distance-slider"})]})]}),e.jsxs("div",{className:"nice-palette__strips",children:[e.jsxs("div",{className:"nice-palette__swatches",children:[V.map((ie,he)=>e.jsxs("div",{className:`nice-palette__swatch-wrapper ${ee===he?"nice-palette__swatch-wrapper--selected":""}`,onClick:()=>D(he),children:[e.jsx("div",{className:"nice-palette__swatch",style:{background:ie},children:V.length>w&&e.jsx("button",{type:"button",className:"nice-palette__swatch-remove",onClick:_e=>{_e.stopPropagation(),Ue(he)},disabled:E,"aria-label":"Remove color",children:"×"})}),e.jsx("input",{type:"text",className:"nice-palette__hex-input",value:ie.toUpperCase(),maxLength:7,disabled:E,onChange:_e=>Ae(he,_e.target.value)})]},he)),V.length<_&&e.jsx("button",{type:"button",className:"nice-palette__add-btn",onClick:Ke,disabled:E,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:ze},title:ze.toUpperCase()}),e.jsx("span",{className:"nice-palette__hex-label",children:ze.toUpperCase()})]}),k&&Le.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:Le.map((ie,he)=>e.jsx("div",{className:"nice-palette__variation-chip",style:{background:ie},title:ie.toUpperCase(),onClick:()=>{E||Ae(ee,ie)},role:"button",tabIndex:0},he))})]}),O&&e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm nice-palette__random-btn",onClick:Ye,disabled:E,title:"Random palette","aria-label":"Random palette",children:"🎲 Random Palette"})]})]}),U&&v.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:v.map(ie=>{const he=it(ke,ie);return e.jsxs("button",{type:"button",className:`nice-palette__preset-card ${de===ie?"nice-palette__preset-card--active":""}`,onClick:()=>Te(ie),disabled:E,children:[e.jsx("div",{className:"nice-palette__preset-strip",children:he.map((_e,Me)=>e.jsx("span",{className:"nice-palette__preset-dot",style:{background:_e}},Me))}),e.jsx("span",{className:"nice-palette__preset-label",children:Wn[ie]})]},ie)})})]}),H&&e.jsxs("div",{className:"nice-palette__info-panel",children:[e.jsx("div",{className:"nice-palette__section-title",children:"Selected Color Info"}),e.jsx(Un,{hex:De})]}),e.jsxs("details",{className:"nice-palette__custom-schemes",style:{marginTop:8},children:[e.jsxs("summary",{style:{cursor:"pointer",padding:"6px 10px",background:"var(--bg-secondary)",color:"var(--text-primary)",border:"1px solid var(--border-color)",borderRadius:4,display:"inline-block",fontSize:12,userSelect:"none"},children:["Custom schemes (",J.length,")"]}),e.jsxs("div",{style:{marginTop:8,display:"flex",flexDirection:"column",gap:6},children:[J.length===0&&e.jsx("div",{style:{fontSize:12,color:"var(--text-muted)"},children:l("colorPalette.schemes.empty","Save the current palette as a reusable scheme.")}),J.map(ie=>e.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center",fontSize:12},children:[e.jsx("span",{style:{width:16,height:16,display:"inline-flex"},children:_t("custom",{angles:ie.angles,size:16})}),e.jsx("span",{style:{flex:1},children:ie.name}),e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--xs",onClick:()=>{be(ie.id),Re("custom")},disabled:E,children:"Use"}),e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--xs",onClick:()=>W(J.filter(he=>he.id!==ie.id)),disabled:E,"aria-label":`Delete ${ie.name}`,children:"×"})]},ie.id)),e.jsxs("div",{style:{display:"flex",gap:6},children:[e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm",disabled:E,onClick:()=>{const ie=typeof window<"u"?window.prompt("Scheme name?",`Scheme ${J.length+1}`):null;if(!ie)return;const he=Ie(V[0]).h,_e=V.map(r=>(Ie(r).h-he+540)%360-180),Me={id:`cs-${Date.now()}`,name:ie,angles:_e};W([...J,Me])},children:"+ Save current as scheme"}),e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm",disabled:E||J.length===0,onClick:()=>{typeof navigator>"u"||navigator.clipboard?.writeText(JSON.stringify(J,null,2))},children:l("colorPalette.exportJson","Export JSON")}),e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm",disabled:E,onClick:()=>{if(typeof window>"u")return;const ie=window.prompt("Paste schemes JSON");if(ie)try{const he=JSON.parse(ie);Array.isArray(he)&&W(he)}catch{}},children:l("colorPalette.importJson","Import JSON")})]})]})]}),G&&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(Kn,{colors:V})})]})]})});Qt.displayName="NiceColorPalette";function ut(){return{type:"linear",angle:90,stops:[{color:"var(--nice-primary, #3b82f6)",position:0},{color:"var(--nice-accent, #8b5cf6)",position:100}]}}function pt(t){const i=t.stops.slice().sort((a,m)=>a.position-m.position).map(a=>`${a.color} ${a.position}%`).join(", "),o=t.repeating?"repeating-":"";switch(t.type){case"linear":return`${o}linear-gradient(${t.angle}deg, ${i})`;case"radial":{const a=t.shape||"ellipse",m=t.size||"farthest-corner",g=t.positionX??50,w=t.positionY??50;return`${o}radial-gradient(${a} ${m} at ${g}% ${w}%, ${i})`}case"conic":{const a=t.angle??0,m=t.positionX??50,g=t.positionY??50;return`${o}conic-gradient(from ${a}deg at ${m}% ${g}%, ${i})`}}}function en(t){const i=t.trim(),o=i.startsWith("repeating-");if(i.includes("linear-gradient")){const a=i.match(/linear-gradient\((.+)\)/)?.[1];if(!a)return null;const m=a.split(",").map(z=>z.trim());let g=90,w=0;const _=m[0].match(/^(\d+)deg$/);_&&(g=parseInt(_[1]),w=1);const R=ct(m.slice(w));return{type:"linear",angle:g,repeating:o,stops:R}}if(i.includes("radial-gradient")){const a=i.match(/radial-gradient\((.+)\)/)?.[1];if(!a)return null;const m=a.split(",").map(w=>w.trim()),g=ct(m.filter(w=>w.includes("#")||w.includes("rgb")));return{type:"radial",angle:0,repeating:o,stops:g.length>=2?g:ut().stops}}if(i.includes("conic-gradient")){const a=i.match(/conic-gradient\((.+)\)/)?.[1];if(!a)return null;const m=a.split(",").map(w=>w.trim()),g=ct(m.filter(w=>w.includes("#")||w.includes("rgb")));return{type:"conic",angle:0,repeating:o,stops:g.length>=2?g:ut().stops}}return null}function ct(t){return t.map((i,o,a)=>{const m=i.match(/^(#[0-9a-fA-F]{3,8}|rgba?\([^)]+\))\s*(\d+%?)?$/);if(m){const g=m[2]?parseFloat(m[2]):o/Math.max(1,a.length-1)*100;return{color:m[1],position:g}}return{color:i,position:o/Math.max(1,a.length-1)*100}})}function Zn(){return"#"+Math.floor(Math.random()*16777215).toString(16).padStart(6,"0")}function Jn(t=2){const i=["linear","radial","conic"],o=i[Math.floor(Math.random()*i.length)],a=[];for(let m=0;m<t;m++)a.push({color:Zn(),position:Math.round(m/(t-1)*100)});return{type:o,angle:Math.floor(Math.random()*360),stops:a,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 tn=[{name:"Sunset",value:{type:"linear",angle:135,stops:[{color:"var(--nice-danger, #ff6b6b)",position:0},{color:"#feca57",position:100}]}},{name:"Ocean",value:{type:"linear",angle:180,stops:[{color:"#667eea",position:0},{color:"#764ba2",position:100}]}},{name:"Forest",value:{type:"linear",angle:120,stops:[{color:"#11998e",position:0},{color:"#38ef7d",position:100}]}},{name:"Fire",value:{type:"linear",angle:90,stops:[{color:"#f12711",position:0},{color:"#f5af19",position:100}]}},{name:"Aurora",value:{type:"linear",angle:135,stops:[{color:"#a18cd1",position:0},{color:"#fbc2eb",position:50},{color:"#a6c1ee",position:100}]}},{name:"Midnight",value:{type:"linear",angle:180,stops:[{color:"#0f0c29",position:0},{color:"#302b63",position:50},{color:"#24243e",position:100}]}},{name:"Candy",value:{type:"linear",angle:45,stops:[{color:"#fc5c7d",position:0},{color:"#6a82fb",position:100}]}},{name:"Radial Glow",value:{type:"radial",angle:0,shape:"circle",stops:[{color:"var(--nice-warning-bg, #ffecd2)",position:0},{color:"#fcb69f",position:100}],positionX:50,positionY:50}},{name:"Rainbow",value:{type:"conic",angle:0,stops:[{color:"var(--nice-danger, #ff0000)",position:0},{color:"#ff8800",position:17},{color:"var(--nice-warning, #ffff00)",position:33},{color:"var(--nice-success, #00ff00)",position:50},{color:"#0088ff",position:67},{color:"#8800ff",position:83},{color:"var(--nice-danger, #ff0000)",position:100}],positionX:50,positionY:50}}],nn=n.forwardRef(({id:t,className:i,style:o,accessMode:a,value:m,onChange:g,showCssOutput:w=!0,showPresets:_=!0,showEditor:R=!0,showRandom:z=!0,maxStops:Y=10,label:B,disabled:x,width:F},P)=>{const G=q.sc(a,t),H=G==="hidden";(G==="disabled"||G==="readOnly")&&(x=!0);const U=q._s(t),v=m??ut(),k=n.useMemo(()=>pt(v),[v]),[O,j]=n.useState(0),[A,E]=n.useState(""),b=n.useRef(null),h=n.useCallback(f=>{g?.(f)},[g]),M=n.useCallback(f=>{x||h({...v,type:f})},[x,v,h]),I=n.useCallback(f=>{x||h({...v,angle:f})},[x,v,h]),S=n.useCallback(f=>{x||h({...v,repeating:f})},[x,v,h]),y=n.useCallback(f=>{x||h({...v,shape:f})},[x,v,h]),c=n.useCallback((f,d)=>{if(x)return;const $=v.stops.map((K,ee)=>ee===f?{...K,...d}:K);h({...v,stops:$})},[x,v,h]),L=n.useCallback(()=>{if(x||v.stops.length>=Y)return;const f=v.stops.slice().sort((D,ge)=>D.position-ge.position);let d=0,$=f[0];for(let D=0;D<f.length-1;D++){const ge=f[D+1].position-f[D].position;ge>d&&(d=ge,$=f[D])}const K=Math.round($.position+d/2),ee="#"+Math.floor(Math.random()*16777215).toString(16).padStart(6,"0");h({...v,stops:[...v.stops,{color:ee,position:K}]})},[x,v,Y,h]),C=n.useCallback(f=>{if(x||v.stops.length<=2)return;const d=v.stops.filter(($,K)=>K!==f);h({...v,stops:d}),O>=d.length&&j(d.length-1)},[x,v,O,h]),u=n.useCallback(()=>{if(x)return;const f=2+Math.floor(Math.random()*3);h(Jn(f))},[x,h]),l=n.useCallback(()=>{if(x||!A.trim())return;const f=en(A);f&&h(f)},[x,A,h]),s=n.useCallback(f=>{if(x||!b.current||v.stops.length>=Y)return;const d=b.current.getBoundingClientRect(),$=Math.round((f.clientX-d.left)/d.width*100),K="#"+Math.floor(Math.random()*16777215).toString(16).padStart(6,"0"),ee=[...v.stops,{color:K,position:$}];h({...v,stops:ee}),j(ee.length-1)},[x,v,Y,h]),p=n.useMemo(()=>v.stops.slice().sort((f,d)=>f.position-d.position),[v.stops]);return H?null:e.jsxs("div",{ref:P,id:U,className:`nice-gradient ${x?"nice-gradient--disabled":""} ${i||""}`,style:{width:F!=null?typeof F=="number"?`${F}px`:F:320,boxSizing:"border-box",...o},children:[B&&e.jsx("div",{className:"nice-gradient__label",children:B}),e.jsx("div",{className:"nice-gradient__preview",style:{background:k}}),R&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"nice-gradient__type-row",children:[["linear","radial","conic"].map(f=>e.jsx("button",{type:"button",className:`nice-gradient__type-btn ${v.type===f?"nice-gradient__type-btn--active":""}`,onClick:()=>M(f),disabled:x,children:f.charAt(0).toUpperCase()+f.slice(1)},f)),e.jsxs("label",{className:"nice-gradient__repeat-label",children:[e.jsx("input",{type:"checkbox",checked:v.repeating??!1,onChange:f=>S(f.target.checked),disabled:x}),"Repeating"]})]}),e.jsxs("div",{className:"nice-gradient__controls",children:[v.type==="linear"&&e.jsxs("div",{className:"nice-gradient__control-group",children:[e.jsxs("label",{children:["Angle: ",v.angle,"°"]}),e.jsx("input",{type:"range",min:0,max:360,value:v.angle,onChange:f=>I(Number(f.target.value)),disabled:x,className:"nice-gradient__slider"}),e.jsx("div",{className:"nice-gradient__angle-presets",children:[0,45,90,135,180,225,270,315].map(f=>e.jsx("button",{type:"button",className:`nice-gradient__angle-btn ${v.angle===f?"nice-gradient__angle-btn--active":""}`,onClick:()=>I(f),disabled:x,title:`${f}°`,children:e.jsx("span",{style:{transform:`rotate(${f}deg)`,display:"inline-block"},children:"→"})},f))})]}),v.type==="radial"&&e.jsxs("div",{className:"nice-gradient__control-group",children:[e.jsx("label",{children:"Shape:"}),e.jsx("div",{className:"nice-gradient__shape-btns",children:["circle","ellipse"].map(f=>e.jsx("button",{type:"button",className:`nice-gradient__shape-btn ${(v.shape||"ellipse")===f?"nice-gradient__shape-btn--active":""}`,onClick:()=>y(f),disabled:x,children:f},f))})]}),(v.type==="radial"||v.type==="conic")&&e.jsxs("div",{className:"nice-gradient__control-group",children:[e.jsxs("label",{children:["Center: ",v.positionX??50,"%, ",v.positionY??50,"%"]}),e.jsxs("div",{className:"nice-gradient__center-inputs",children:[e.jsx("input",{type:"range",min:0,max:100,value:v.positionX??50,onChange:f=>h({...v,positionX:Number(f.target.value)}),disabled:x,className:"nice-gradient__slider"}),e.jsx("input",{type:"range",min:0,max:100,value:v.positionY??50,onChange:f=>h({...v,positionY:Number(f.target.value)}),disabled:x,className:"nice-gradient__slider"})]})]}),v.type==="conic"&&e.jsxs("div",{className:"nice-gradient__control-group",children:[e.jsxs("label",{children:["Start angle: ",v.angle,"°"]}),e.jsx("input",{type:"range",min:0,max:360,value:v.angle,onChange:f=>I(Number(f.target.value)),disabled:x,className:"nice-gradient__slider"})]})]}),e.jsxs("div",{className:"nice-gradient__bar-container",children:[e.jsx("div",{ref:b,className:"nice-gradient__bar",style:{background:k},onClick:s,children:v.stops.map((f,d)=>e.jsx("div",{className:`nice-gradient__stop-marker ${O===d?"nice-gradient__stop-marker--active":""}`,style:{left:`${f.position}%`},onClick:$=>{$.stopPropagation(),j(d)},title:`${f.color} @ ${f.position}%`,children:e.jsx("div",{className:"nice-gradient__stop-dot",style:{background:f.color}})},d))}),e.jsx("button",{type:"button",className:"nice-gradient__add-stop",onClick:L,disabled:x||v.stops.length>=Y,title:"Add stop",children:"+"})]}),e.jsx("div",{className:"nice-gradient__stop-editor",children:e.jsx("div",{className:"nice-gradient__stop-list",children:p.map((f,d)=>{const $=v.stops.indexOf(f);return e.jsxs("div",{className:`nice-gradient__stop-row ${O===$?"nice-gradient__stop-row--active":""}`,onClick:()=>j($),children:[e.jsx("input",{type:"color",value:f.color,onChange:K=>c($,{color:K.target.value}),disabled:x,className:"nice-gradient__stop-color"}),e.jsx("input",{type:"text",value:f.color.toUpperCase(),maxLength:7,onChange:K=>c($,{color:K.target.value}),disabled:x,className:"nice-gradient__stop-hex"}),e.jsx("input",{type:"number",min:0,max:100,value:f.position,onChange:K=>c($,{position:Number(K.target.value)}),disabled:x,className:"nice-gradient__stop-pos"}),e.jsx("span",{className:"nice-gradient__stop-pct",children:"%"}),v.stops.length>2&&e.jsx("button",{type:"button",className:"nice-gradient__stop-del",onClick:()=>C($),disabled:x,"aria-label":"Remove stop",children:"×"})]},$)})})})]}),z&&e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm nice-gradient__random-btn",onClick:u,disabled:x,title:"Random gradient","aria-label":"Random gradient",children:"🎲 Random Gradient"}),_&&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:tn.map((f,d)=>e.jsxs("button",{type:"button",className:"nice-gradient__preset-card",onClick:()=>{x||h(f.value)},disabled:x,title:f.name,children:[e.jsx("div",{className:"nice-gradient__preset-preview",style:{background:pt(f.value)}}),e.jsx("span",{className:"nice-gradient__preset-name",children:f.name})]},d))})]}),w&&e.jsxs("div",{className:"nice-gradient__css",children:[e.jsx("div",{className:"nice-gradient__section-title",children:"CSS Output"}),e.jsxs("div",{className:"nice-gradient__css-output",children:[e.jsx("code",{children:`background: ${k};`}),e.jsx("button",{type:"button",className:"nice-gradient__copy-btn",onClick:()=>navigator.clipboard?.writeText(`background: ${k};`),title:"Copy CSS",children:"📋"})]}),e.jsxs("div",{className:"nice-gradient__css-import",children:[e.jsx("input",{type:"text",className:"nice-gradient__css-input",placeholder:"Paste CSS gradient to import...",value:A,onChange:f=>E(f.target.value),disabled:x}),e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm",onClick:l,disabled:x,children:"Import"})]})]})]})});nn.displayName="NiceGradientPicker";const Qn=({options:t,value:i,onChange:o,searchable:a=!0,clearable:m,loading:g,placeholder:w,label:_,error:R,helperText:z,required:Y,disabled:B,size:x="md",id:F,className:P,style:G,data:H,columns:U,valueField:v="id",displayField:k,dropdownWidth:O,controlWidth:j})=>{const A=q._s(F),{t:E}=q.Zt(),[b,h]=n.useState(!1),[M,I]=n.useState(""),S=n.useRef(null);q.Vs(S,()=>h(!1));const y=!!(H&&U&&U.length>0),c=k??(U&&U[0]?.key),L=n.useMemo(()=>!y||!H?[]:H.map(p=>({value:String(p[v]??""),label:c?String(p[c]??""):""})),[y,H,v,c]),C=y?L:t??[],u=C.find(p=>String(p.value)===i),l=n.useMemo(()=>{if(!y||!H)return[];if(!M)return H;const p=M.toLowerCase();return H.filter(f=>U.some(d=>String(f[d.key]??"").toLowerCase().includes(p)))},[y,H,U,M]),s=n.useMemo(()=>{if(y||!M)return C;const p=M.toLowerCase();return C.filter(f=>f.label.toLowerCase().includes(p))},[C,M,y]);return e.jsxs("div",{className:`nice-field nice-field--${x} ${R?"nice-field--error":""} ${P||""}`,style:{width:j!=null?typeof j=="number"?`${j}px`:j:"fit-content",...G},ref:S,children:[_&&e.jsxs("label",{className:"nice-field__label",htmlFor:A,children:[_,Y&&e.jsx("span",{className:"nice-field__required",children:"*"})]}),e.jsxs("div",{className:"nice-field__input-wrap",style:{position:"relative"},children:[e.jsxs("button",{type:"button",id:A,className:"nice-select__trigger",onClick:()=>!B&&h(!b),disabled:B,children:[e.jsx("span",{children:u?.label||w||E("controls.select","Select...")}),e.jsx("span",{className:"nice-select__arrow",children:"▾"})]}),m&&i&&!B&&e.jsx("button",{type:"button",className:"nice-field__clear",onClick:()=>o(""),"aria-label":E("controls.clear","Clear"),children:"✕"}),b&&e.jsxs("div",{className:"nice-dropdown nice-lookup__dropdown",style:{position:"absolute",top:"100%",left:0,zIndex:50,marginTop:4,background:"var(--bg-primary)",border:"1px solid var(--border-color)",borderRadius:"var(--nice-radius-md)",boxShadow:"0 4px 16px var(--nice-overlay-15, rgba(0, 0, 0, 0.15))",minWidth:"100%",width:O!=null?typeof O=="number"?`${O}px`:O:y?"max-content":"100%"},children:[a&&e.jsx("div",{className:"nice-dropdown__search",style:{padding:6},children:e.jsx("input",{type:"text",value:M,onChange:p=>I(p.target.value),placeholder:E("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)"}})}),y?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:U.map(p=>e.jsx("th",{style:{padding:"6px 10px",textAlign:"left",fontSize:12,fontWeight:600,color:"var(--text-secondary)",background:"var(--bg-secondary)",borderBottom:"1px solid var(--border-color)",width:p.width!=null?typeof p.width=="number"?`${p.width}px`:p.width:void 0},children:p.header},p.key))})}),e.jsx("tbody",{children:l.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:U.length,style:{padding:12,textAlign:"center",color:"var(--text-muted)"},children:E("controls.noResults","No results")})}):l.map(p=>{const f=String(p[v]??""),d=f===i;return e.jsx("tr",{role:"option","aria-selected":d,onClick:()=>{o(f),h(!1),I("")},style:{cursor:"pointer",background:d?"var(--hover-bg)":"transparent"},onMouseEnter:$=>{d||($.currentTarget.style.background="var(--hover-bg)")},onMouseLeave:$=>{d||($.currentTarget.style.background="transparent")},children:U.map($=>e.jsx("td",{style:{padding:"6px 10px",fontSize:13,borderBottom:"1px solid var(--border-color)"},children:String(p[$.key]??"")},$.key))},f)})})]}):e.jsx("ul",{className:"nice-dropdown__list",role:"listbox",style:{listStyle:"none",margin:0,padding:4,maxHeight:240,overflowY:"auto"},children:s.length===0?e.jsx("li",{className:"nice-dropdown__empty",style:{padding:8,color:"var(--text-muted)"},children:E("controls.noResults","No results")}):s.map(p=>e.jsx("li",{role:"option",className:`nice-dropdown__option ${String(p.value)===i?"nice-dropdown__option--selected":""}`,onClick:()=>{o(String(p.value)),h(!1),I("")},"aria-selected":String(p.value)===i,children:p.label},String(p.value)))})]})]}),R&&e.jsx("div",{className:"nice-field__error",children:R}),z&&!R&&e.jsx("div",{className:"nice-field__hint",children:z})]})},ei=["Su","Mo","Tu","We","Th","Fr","Sa"];function ti(t,i){return new Date(t,i+1,0).getDate()}function ni(t,i){return new Date(t,i,1).getDay()}function Nt(t,i,o){return`${t}-${String(i+1).padStart(2,"0")}-${String(o).padStart(2,"0")}`}function ii(t){const i=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate()));i.setUTCDate(i.getUTCDate()+4-(i.getUTCDay()||7));const o=new Date(Date.UTC(i.getUTCFullYear(),0,1));return Math.ceil(((i.getTime()-o.getTime())/864e5+1)/7)}const Ct=["January","February","March","April","May","June","July","August","September","October","November","December"],on=({value:t,onChange:i,min:o,max:a,disabledDates:m=[],firstDayOfWeek:g=1,size:w="md",showWeekNumbers:_,onMonthChange:R,className:z,style:Y,accessMode:B,id:x,multiple:F,selectedDates:P=[],onSelectedDatesChange:G,renderDay:H,showKeyboardHints:U,persistPreferences:v=!1,fullWidth:k=!1,cookies:O=!1,localStorage:j=!0,sessionStorage:A=!1,storageMode:E,storageKey:b})=>{const h=q.sc(B,x),M=h==="hidden",I=h==="disabled"||h==="readOnly",{t:S}=q.Zt(),y=new Date,c=t?new Date(t):y,L=q.useStorageAdapter(b??"nice-calendar"),C=n.useMemo(()=>v?L.get("prefs")??{}:{},[v,L]),u=C.firstDayOfWeek??g,[l,s]=n.useState(C.lastViewYear??c.getFullYear()),[p,f]=n.useState(C.lastViewMonth??c.getMonth()),[d,$]=n.useState(C.preferredView??"days"),K=n.useCallback(Q=>{if(!v)return;const V=L.get("prefs")??{};L.set("prefs",{...V,...Q})},[v,L]),ee=n.useCallback(Q=>{$(Q),K({preferredView:Q})},[K]),D=n.useCallback((Q,V)=>{K({lastViewYear:Q,lastViewMonth:V})},[K]),ge=n.useMemo(()=>[q.xc.moveUp,q.xc.moveDown,q.xc.moveLeft,q.xc.moveRight,{key:"Enter",description:S("shortcuts.selectDate","Select date")},q.xc.pageUp,q.xc.pageDown],[S]),re=n.useMemo(()=>ti(l,p),[l,p]),ye=n.useMemo(()=>(ni(l,p)-u+7)%7,[l,p,u]),ne=n.useMemo(()=>{const Q=[...ei];for(let V=0;V<u;V++)Q.push(Q.shift());return Q},[u]),se=n.useCallback(Q=>o&&Q<o||a&&Q>a?!0:m.includes(Q),[o,a,m]),le=n.useCallback(Q=>{if(d==="years"){s(xe=>xe+Q*10);return}if(d==="months"){s(xe=>xe+Q);return}let V=p+Q,me=l;V<0&&(V=11,me--),V>11&&(V=0,me++),f(V),s(me),D(me,V),R?.(me,V)},[p,l,R,d,D]),ue=Nt(y.getFullYear(),y.getMonth(),y.getDate()),be=n.useCallback(Q=>F?P.includes(Q):Q===t,[F,P,t]),te=n.useCallback(Q=>{if(!I){if(F){const V=P.includes(Q)?P.filter(me=>me!==Q):[...P,Q];G?.(V)}i?.(Q)}},[F,P,i,G]),ce=n.useCallback(()=>{d==="days"?ee("months"):d==="months"&&ee("years")},[d,ee]),de=n.useCallback(Q=>{f(Q),ee("days"),D(l,Q),R?.(l,Q)},[l,R,ee,D]),oe=n.useCallback(Q=>{s(Q),ee("months")},[ee]),J=d==="years"?`${l-l%10} – ${l-l%10+9}`:d==="months"?`${l}`:`${Ct[p]} ${l}`,W=d==="years"?"decade":d==="months"?"year":"month",N=[];for(let Q=0;Q<ye;Q++)N.push(null);for(let Q=1;Q<=re;Q++)N.push(Q);for(;N.length%7!==0;)N.push(null);const Z=[];for(let Q=0;Q<N.length;Q+=7)Z.push(N.slice(Q,Q+7));const fe=l-l%10;return M?null:e.jsxs("div",{className:`nice-calendar nice-calendar--${w}${k?" nice-calendar--full-width":""} ${z||""}`,style:Y,children:[e.jsxs("div",{className:"nice-calendar__header",children:[e.jsx("button",{type:"button",className:"nice-calendar__nav",onClick:()=>le(-1),"aria-label":`Previous ${W}`,children:"‹"}),e.jsx("button",{type:"button",className:"nice-calendar__title",onClick:ce,"aria-label":d==="days"?"Show month picker":d==="months"?"Show year picker":void 0,disabled:d==="years",children:J}),e.jsx("button",{type:"button",className:"nice-calendar__nav",onClick:()=>le(1),"aria-label":`Next ${W}`,children:"›"}),U&&e.jsx(q.Qr,{shortcuts:ge,size:"sm"})]}),d==="days"&&e.jsxs("table",{className:"nice-calendar__grid",role:"grid",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[_&&e.jsx("th",{className:"nice-calendar__wk",children:"W"}),ne.map(Q=>e.jsx("th",{children:Q},Q))]})}),e.jsx("tbody",{children:Z.map((Q,V)=>e.jsxs("tr",{children:[_&&e.jsx("td",{className:"nice-calendar__wk",children:Q.find(me=>me!=null)?ii(new Date(l,p,Q.find(me=>me!=null))):""}),Q.map((me,xe)=>{if(me==null)return e.jsx("td",{className:"nice-calendar__empty-cell"},xe);const ke=Nt(l,p,me),ve=se(ke),we=be(ke),Re=ke===ue;return e.jsx("td",{className:`nice-calendar__day${we?" nice-calendar__day--selected":""}${Re?" nice-calendar__day--today":""}${ve?" nice-calendar__day--disabled":""}`,onClick:()=>!ve&&te(ke),role:"gridcell","aria-selected":we,"aria-disabled":ve,children:H?H(ke,me):me},xe)})]},V))})]}),d==="months"&&e.jsx("div",{className:"nice-calendar__picker-grid",children:Ct.map((Q,V)=>e.jsx("button",{type:"button",className:`nice-calendar__picker-cell${V===p&&l===c.getFullYear()?" nice-calendar__picker-cell--selected":""}`,onClick:()=>de(V),children:Q.slice(0,3)},V))}),d==="years"&&e.jsx("div",{className:"nice-calendar__picker-grid",children:Array.from({length:12},(Q,V)=>fe-1+V).map(Q=>e.jsx("button",{type:"button",className:`nice-calendar__picker-cell${Q===l?" nice-calendar__picker-cell--selected":""}${Q<fe||Q>fe+9?" nice-calendar__picker-cell--other":""}`,onClick:()=>oe(Q),children:Q},Q))})]})};on.displayName="NiceCalendar";const oi=({startDate:t,endDate:i,onStartChange:o,onEndChange:a,min:m,max:g,clearable:w,startPlaceholder:_,endPlaceholder:R,startLabel:z,endLabel:Y,layout:B="horizontal",separator:x="–",gap:F=12,fullWidth:P=!1,label:G,error:H,helperText:U,required:v,disabled:k,size:O="md",id:j,className:A,style:E,accessMode:b,showKeyboardHints:h,labelPlacement:M,errorPlacement:I,labelWidth:S,controlWidth:y,loading:c})=>{const L=q.sc(b,j),C=q._s(j),{t:u}=q.Zt(),l=L==="disabled"||L==="readOnly"||!!k,s=n.useMemo(()=>[{key:"Tab",description:u("shortcuts.switchField","Switch between start/end")},q.xc.cancel],[u]);if(L==="hidden")return null;const p=d=>{o(d),d&&i&&d>i&&a(d)},f=B==="horizontal";return e.jsxs("div",{className:`nice-field nice-field--${O} nice-daterange nice-daterange--${B} ${M==="left"?"nice-field--label-left":""} ${H?"nice-field--error":""} ${c?"nice-field--loading":""} ${A||""}`,style:{...E,...S!=null&&{"--nice-field-label-width":typeof S=="number"?`${S}px`:S},...y!=null&&{"--nice-field-control-width":typeof y=="number"?`${y}px`:y}},"aria-busy":c||void 0,children:[G&&e.jsxs("label",{className:"nice-field__label",htmlFor:C,children:[G,v&&e.jsx("span",{className:"nice-field__required",children:"*"}),h&&e.jsx(q.Qr,{shortcuts:s,size:"sm"})]}),e.jsxs("div",{className:"nice-field__control",children:[e.jsxs("div",{className:"nice-daterange__row",style:{display:"flex",flexDirection:f?"row":"column",alignItems:f?"flex-end":"stretch",gap:F,flexWrap:"wrap"},children:[e.jsx("div",{style:{flex:P?"1 1 0":void 0,minWidth:0},children:e.jsx(jt.NiceDatePicker,{id:C,label:z,value:t,onChange:p,min:m,max:i||g,placeholder:_||u("controls.startDate","Start date"),disabled:l,size:O,clearable:w,labelPlacement:M,labelWidth:S})}),f&&x!==""&&x!=null&&e.jsx("span",{className:"nice-daterange__separator",style:{paddingBottom:8,color:"var(--text-secondary, #666)"},"aria-hidden":"true",children:x}),e.jsx("div",{style:{flex:P?"1 1 0":void 0,minWidth:0},children:e.jsx(jt.NiceDatePicker,{label:Y,value:i,onChange:a,min:t||m,max:g,placeholder:R||u("controls.endDate","End date"),disabled:l,size:O,clearable:w,labelPlacement:M,labelWidth:S})})]}),c&&e.jsx("span",{className:"nice-field__spinner",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})}),I==="right"&&H&&e.jsx("div",{className:"nice-field__error",role:"alert",children:H}),I==="right"&&!H&&U&&e.jsx("div",{className:"nice-field__helper",children:U})]}),I!=="right"&&H&&e.jsx("div",{className:"nice-field__error",children:H}),I!=="right"&&!H&&U&&e.jsx("div",{className:"nice-field__hint",children:U})]})},ai=({min:t=0,max:i=100,step:o=1,startValue:a,endValue:m,onChange:g,showLabels:w=!0,formatLabel:_,valuePlacement:R="none",label:z,error:Y,helperText:B,required:x,disabled:F,readOnly:P,loading:G,size:H="md",id:U,className:v,style:k,accessMode:O,showKeyboardHints:j,labelPlacement:A,errorPlacement:E,labelWidth:b,controlWidth:h})=>{const M=q.sc(O,U),I=M==="hidden";(M==="disabled"||M==="readOnly")&&(F=!0);const{t:S}=q.Zt(),y=q._s(U),c=n.useRef(null),L=n.useMemo(()=>[q.xc.increment,q.xc.decrement,q.xc.first,q.xc.last,{key:"Tab",description:S("shortcuts.switchThumb","Switch thumb")}],[S]),C=p=>(p-t)/(i-t)*100,u=p=>_?_(p):String(p),l=p=>{const f=Math.round(p/o)*o;return Math.max(t,Math.min(i,f))},s=n.useCallback((p,f)=>{p.preventDefault();const d=c.current;if(!d||F)return;const $=ee=>{const D=d.getBoundingClientRect(),ge=Math.max(0,Math.min(1,(ee.clientX-D.left)/D.width)),re=l(t+ge*(i-t));f==="start"?g(Math.min(re,m),m):g(a,Math.max(re,a))},K=()=>{document.removeEventListener("pointermove",$),document.removeEventListener("pointerup",K)};document.addEventListener("pointermove",$),document.addEventListener("pointerup",K)},[t,i,o,a,m,g,F]);return I?null:e.jsxs("div",{className:`nice-field nice-field--${H} nice-field--rangeslider ${A==="left"?"nice-field--label-left":""} ${E==="right"?"nice-field--error-right":""} ${Y?"nice-field--error":""} ${G?"nice-field--loading":""} ${v||""}`,style:{...k,...b!=null&&{"--nice-field-label-width":typeof b=="number"?`${b}px`:b},...h!=null&&{"--nice-field-control-width":typeof h=="number"?`${h}px`:h}},"aria-busy":G||void 0,children:[z&&e.jsxs("label",{className:"nice-field__label nice-field__label--with-value",htmlFor:y,children:[e.jsxs("span",{className:"nice-field__label-text",children:[z,x&&e.jsx("span",{className:"nice-field__required",children:"*"}),j&&e.jsx(q.Qr,{shortcuts:L,size:"sm"})]}),R==="right"&&e.jsxs("span",{className:"nice-range-slider__value nice-range-slider__value--inline",children:[u(a)," – ",u(m)]})]}),e.jsxs("div",{className:"nice-field__control",children:[R==="right"&&!z&&e.jsxs("span",{className:"nice-range-slider__value",children:[u(a)," – ",u(m)]}),e.jsxs("div",{className:"nice-range-slider__stack",children:[e.jsxs("div",{className:`nice-range-slider ${w?"nice-range-slider--with-labels":""} ${z?"nice-range-slider--has-field-label":""}`,ref:c,children:[e.jsx("div",{className:"nice-range-slider__track",children:e.jsx("div",{className:"nice-range-slider__fill",style:{left:`${C(a)}%`,width:`${C(m)-C(a)}%`}})}),e.jsx("div",{className:"nice-range-slider__thumb",style:{left:`${C(a)}%`},onPointerDown:p=>P?void 0:s(p,"start"),role:"slider","aria-valuemin":t,"aria-valuemax":m,"aria-valuenow":a,tabIndex:F?-1:0,id:y}),e.jsx("div",{className:"nice-range-slider__thumb",style:{left:`${C(m)}%`},onPointerDown:p=>P?void 0:s(p,"end"),role:"slider","aria-valuemin":a,"aria-valuemax":i,"aria-valuenow":m,tabIndex:F?-1:0})]}),w&&e.jsxs("div",{className:"nice-range-slider__values",children:[e.jsx("span",{className:"nice-range-slider__values-start",style:{left:`${C(a)}%`},children:u(a)}),e.jsx("span",{className:"nice-range-slider__values-end",style:{left:`${C(m)}%`},children:u(m)})]}),R==="bottom"&&e.jsxs("div",{className:"nice-range-slider__value nice-range-slider__value--bottom",children:[u(a)," – ",u(m)]})]}),G&&e.jsx("span",{className:"nice-field__spinner",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})}),E==="right"&&Y&&e.jsx("div",{className:"nice-field__error",role:"alert",children:Y}),E==="right"&&!Y&&B&&e.jsx("div",{className:"nice-field__helper",children:B})]}),E!=="right"&&Y&&e.jsx("div",{className:"nice-field__error",role:"alert",children:Y}),E!=="right"&&!Y&&B&&e.jsx("div",{className:"nice-field__helper",children:B})]})},ri=({displayValue:t,placeholder:i,clearable:o,children:a,onClear:m,open:g,onOpenChange:w,dropdownWidth:_,label:R,error:z,helperText:Y,required:B,disabled:x,size:F="md",id:P,className:G,style:H,accessMode:U,showKeyboardHints:v,displayStyle:k})=>{q.Ns("input",k),q.Es("input",k);const O=q.sc(U,P),j=O==="hidden";(O==="disabled"||O==="readOnly")&&(x=!0);const A=q._s(P),{t:E}=q.Zt(),[b,h]=n.useState(!1),M=n.useRef(null),I=g??b,S=n.useMemo(()=>[{key:"Enter",description:E("shortcuts.openDropdown","Open dropdown")},q.xc.cancel],[E]),y=c=>{w?w(c):h(c)};return q.Vs(M,()=>y(!1)),j?null:e.jsxs("div",{className:`nice-field nice-field--${F} ${z?"nice-field--error":""} ${G||""}`,style:H,ref:M,children:[R&&e.jsxs("label",{className:"nice-field__label",htmlFor:A,children:[R,B&&e.jsx("span",{className:"nice-field__required",children:"*"}),v&&e.jsx(q.Qr,{shortcuts:S,size:"sm"})]}),e.jsxs("div",{className:"nice-field__input-wrap",children:[e.jsxs("button",{type:"button",id:A,className:"nice-select__trigger",onClick:()=>!x&&y(!I),disabled:x,children:[e.jsx("span",{children:t||i||E("controls.select","Select...")}),e.jsx("span",{className:"nice-select__arrow",children:"▾"})]}),o&&t&&!x&&e.jsx("button",{type:"button",className:"nice-field__clear",onClick:()=>m?.(),"aria-label":E("controls.clear","Clear"),children:"✕"})]}),I&&e.jsx("div",{className:"nice-dropdown",style:{width:_},children:a}),z&&e.jsx("div",{className:"nice-field__error",children:z}),Y&&!z&&e.jsx("div",{className:"nice-field__hint",children:Y})]})};function St(t){const i=t.trim().toLowerCase();return i.startsWith("http://")||i.startsWith("https://")||i.startsWith("/")||i.startsWith("./")||i.startsWith("../")?!0:!(i.startsWith("javascript:")||i.startsWith("vbscript:")||i.startsWith("data:text"))}const si=[{target:".nice-htmleditor",titleKey:"tutorial.htmlEditor.intro.title",title:"Rich text editor",contentKey:"tutorial.htmlEditor.intro.content",content:"Format text with the toolbar, insert links, images and tables, and switch to HTML or Markdown source when you need it.",placement:"auto"}],ci=["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"],Ce=({d:t,viewBox:i="0 0 24 24"})=>e.jsx("svg",{width:"16",height:"16",viewBox:i,fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("path",{d:t})}),li={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(Ce,{d:"M8 6h13M8 12h13M8 18h13M3 6h.01M3 12h.01M3 18h.01"}),ol:e.jsx(Ce,{d:"M10 6h11M10 12h11M10 18h11M4 6h1v4M4 10h2M6 18H4c0-1 2-2 2-3s-1-1.5-2-1"}),link:e.jsx(Ce,{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(Ce,{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(Ce,{d:"M3 7v6h6M3 13a9 9 0 1 0 3-7.7L3 13"}),redo:e.jsx(Ce,{d:"M21 7v6h-6M21 13a9 9 0 1 1-3-7.7L21 13"}),clear:e.jsx(Ce,{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(Ce,{d:"M3 3h18v18H3zM3 9h18M3 15h18M9 3v18M15 3v18"}),image:e.jsx(Ce,{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(Ce,{d:"M16 18l6-6-6-6M8 6l-6 6 6 6"}),markdown:"MD",blockquote:e.jsx(Ce,{d:"M3 21c3-3 3-9 0-12M21 21c-3-3-3-9 0-12M9 7h6v6H9zM15 7h6v6h-6z"}),hr:e.jsx(Ce,{d:"M5 12h14"}),subscript:"X₂",superscript:"X²",indent:e.jsx(Ce,{d:"M3 8l4 4-4 4M7 6h14M7 12h14M3 18h18"}),outdent:e.jsx(Ce,{d:"M7 8l-4 4 4 4M21 6H3M21 12H7M21 18H3"}),alignLeft:e.jsx(Ce,{d:"M3 6h18M3 12h12M3 18h18"}),alignCenter:e.jsx(Ce,{d:"M3 6h18M6 12h12M3 18h18"}),alignRight:e.jsx(Ce,{d:"M3 6h18M9 12h12M3 18h18"}),alignJustify:e.jsx(Ce,{d:"M3 6h18M3 12h18M3 18h18"}),fullscreen:e.jsx(Ce,{d:"M3 9V3h6M21 9V3h-6M3 15v6h6M21 15v6h-6"}),removeFormat:e.jsx(Ce,{d:"M4 7V4h16v3M5 20h6M13 4 8 20"}),print:e.jsx(Ce,{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(Ce,{d:"M16 18l6-6-6-6M8 6l-6 6 6 6"}),emoji:e.jsx(Ce,{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(Ce,{d:"M11 19a8 8 0 1 1 0-16 8 8 0 0 1 0 16zM21 21l-4.35-4.35"}),fontSize:e.jsx(Ce,{d:"M4 7V4h16v3M9 20h6M12 4v16"}),fontColor:e.jsx(Ce,{d:"M4 21h16M5 17l7-12 7 12M8 13h8"})},di=[{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"}],mi=[{label:"Faces",emojis:["??","??","??","??","??","??","??","??","??","??","??","??"]},{label:"Hands",emojis:["??","??","??","??","??","??","??","??","??","??"]},{label:"Symbols",emojis:["??","?","??","?","?","?","??","??","??","??","??","??"]},{label:"Arrows",emojis:["??","??","??","??","??","??","??","??","??","?"]}];function ui(t){let i=t;return i=i.replace(/<h1[^>]*>(.*?)<\/h1>/gi,`# $1
2
+ `),i=i.replace(/<h2[^>]*>(.*?)<\/h2>/gi,`## $1
3
+ `),i=i.replace(/<h3[^>]*>(.*?)<\/h3>/gi,`### $1
4
+ `),i=i.replace(/<strong[^>]*>(.*?)<\/strong>/gi,"**$1**"),i=i.replace(/<b[^>]*>(.*?)<\/b>/gi,"**$1**"),i=i.replace(/<em[^>]*>(.*?)<\/em>/gi,"*$1*"),i=i.replace(/<i[^>]*>(.*?)<\/i>/gi,"*$1*"),i=i.replace(/<code[^>]*>(.*?)<\/code>/gi,"`$1`"),i=i.replace(/<pre[^>]*>(.*?)<\/pre>/gis,"```\n$1\n```\n"),i=i.replace(/<br\s*\/?>/gi,`
5
+ `),i=i.replace(/<li[^>]*>(.*?)<\/li>/gi,`- $1
6
+ `),i=i.replace(/<\/?(?:ul|ol|p|div)[^>]*>/gi,`
7
+ `),i=i.replace(/<[^>]+>/g,""),i=i.replace(/\n{3,}/g,`
8
+
9
+ `),i.trim()}function pi(t){let i=t;return i=i.replace(/^### (.+)$/gm,"<h3>$1</h3>"),i=i.replace(/^## (.+)$/gm,"<h2>$1</h2>"),i=i.replace(/^# (.+)$/gm,"<h1>$1</h1>"),i=i.replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>"),i=i.replace(/\*(.+?)\*/g,"<em>$1</em>"),i=i.replace(/`([^`]+)`/g,"<code>$1</code>"),i=i.replace(/```\n?([\s\S]*?)\n?```/g,"<pre>$1</pre>"),i=i.replace(/^- (.+)$/gm,"<li>$1</li>"),i=i.replace(/(<li>.*<\/li>)/gs,"<ul>$1</ul>"),i=i.replace(/\n/g,"<br>"),i}const xt=({value:t,onChange:i,placeholder:o,height:a=200,toolbar:m=ci,readOnly:g,onImageUpload:w,mentionTrigger:_,mentionSuggestions:R,onMentionSearch:z,onFileDrop:Y,pasteCleanup:B=!0,maxLength:x=0,showWordCount:F=!1,templates:P,label:G,error:H,helperText:U,required:v,disabled:k,size:O="md",id:j,className:A,style:E,accessMode:b,tutorial:h})=>{const M=q.sc(b,j),I=M==="hidden";M==="disabled"&&(k=!0),M==="readOnly"&&(g=!0);const S=q._s(j),y=n.useRef(null),c=n.useRef(null),L=n.useRef(null),[C,u]=n.useState(!1),[l,s]=n.useState(""),[p,f]=n.useState(!1),[d,$]=n.useState(""),[K,ee]=n.useState(!1),[D,ge]=n.useState(""),[re,ye]=n.useState(0),[ne,se]=n.useState(!1),[le,ue]=n.useState("var(--nice-text, #000000)"),[be,te]=n.useState("var(--nice-warning, #ffff00)"),[ce,de]=n.useState(0),[oe,J]=n.useState(0),[W,N]=n.useState(!1),[Z,fe]=n.useState(""),[Q,V]=n.useState(""),[me,xe]=n.useState(!1),[ke,ve]=n.useState(!1),we=n.useCallback((r,T)=>{if(g||k)return;const X=y.current;if(X){if(r==="markdown"){if(!C)s(ui(t)),u(!0),f(!1);else{const ae=pi(l);i(ae),u(!1)}return}if(r==="source"){p?(i(d),f(!1)):($(t),f(!0),u(!1));return}if(r==="fullscreen"){se(ae=>!ae);return}if(r==="emoji"){xe(ae=>!ae);return}if(r==="findReplace"){N(ae=>!ae);return}if(r==="image"){if(w)c.current?.click();else{const ae=prompt("Image URL:");ae&&St(ae)&&(X.focus(),document.execCommand("insertImage",!1,ae),i(q.$s(X.innerHTML)))}return}switch(X.focus(),r){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 ae=prompt("URL:");ae&&St(ae)&&document.execCommand("createLink",!1,ae);break}case"unlink":document.execCommand("unlink");break;case"undo":document.execCommand("undo");break;case"redo":document.execCommand("redo");break;case"clear":document.execCommand("removeFormat");break;case"fontSize":{T&&document.execCommand("fontSize",!1,T);break}case"fontColor":{T&&document.execCommand("foreColor",!1,T);break}case"bgColor":{T&&document.execCommand("hiliteColor",!1,T);break}case"table":{document.execCommand("insertHTML",!1,'<table class="nice-htmleditor__table"><thead><tr><th>Header 1</th><th>Header 2</th><th>Header 3</th></tr></thead><tbody><tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr><tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr></tbody></table><p>&nbsp;</p>');break}case"code":{const pe=window.getSelection()?.toString()||"";pe.includes(`
10
+ `)||pe.length>60?document.execCommand("insertHTML",!1,`<pre class="nice-htmleditor__code-block">${pe||"// code"}</pre>`):document.execCommand("insertHTML",!1,`<code>${pe||"code"}</code>`);break}}i(q.$s(X.innerHTML)),de(X.textContent?.length??0)}},[i,g,k,C,l,t,w,p,d]),Re=n.useCallback(async r=>{const T=r.target.files?.[0];if(!T||!w)return;const X=await w(T),ae=y.current;ae&&X&&(ae.focus(),document.execCommand("insertImage",!1,X),i(ae.innerHTML)),r.target.value=""},[w,i]),Be=n.useCallback(()=>{const r=y.current;if(!r)return;const T=r.textContent?.length??0;if(x>0&&T>x&&(r.textContent=(r.textContent??"").slice(0,x)),de(T),J((r.textContent??"").trim().split(/\s+/).filter(Boolean).length),i(r.innerHTML),_){const X=window.getSelection();if(X&&X.rangeCount>0){const ae=X.getRangeAt(0),pe=ae.startContainer;if(pe.nodeType===Node.TEXT_NODE){const Ne=pe.textContent||"",Se=ae.startOffset,Pe=Ne.slice(0,Se),Ee=Pe.lastIndexOf(_);if(Ee>=0&&(Ee===0||/\s/.test(Pe[Ee-1]))){const We=Pe.slice(Ee+_.length);if(!/\s/.test(We)){ee(!0),ge(We),ye(0),z?.(We);return}}}}ee(!1)}},[i,_,z]),Te=R?.filter(r=>r.label.toLowerCase().includes(D.toLowerCase())).slice(0,8)??[],Ae=n.useCallback(r=>{const T=y.current;if(!T)return;const X=window.getSelection();if(!X||X.rangeCount===0)return;const ae=X.getRangeAt(0),pe=ae.startContainer;if(pe.nodeType===Node.TEXT_NODE&&_){const Ne=pe.textContent||"",Se=ae.startOffset,Ee=Ne.slice(0,Se).lastIndexOf(_);if(Ee>=0){const We=Ne.slice(0,Ee),zn=Ne.slice(Se),Pn=`<span class="nice-htmleditor__mention" data-mention="${r.key}" contenteditable="false">${_}${r.label}</span>&nbsp;`;pe.textContent=We;const st=document.createRange();st.setStartAfter(pe),st.collapse(!0);const On=st.createContextualFragment(Pn+zn);pe.parentNode?.insertBefore(On,pe.nextSibling),X.collapseToEnd(),i(T.innerHTML)}}ee(!1)},[_,i]),Ke=n.useCallback(r=>{if(K&&Te.length>0){r.key==="ArrowDown"?(r.preventDefault(),ye(T=>Math.min(T+1,Te.length-1))):r.key==="ArrowUp"?(r.preventDefault(),ye(T=>Math.max(T-1,0))):r.key==="Enter"?(r.preventDefault(),Ae(Te[re])):r.key==="Escape"&&ee(!1);return}(r.ctrlKey||r.metaKey)&&r.key==="b"?(r.preventDefault(),we("bold")):(r.ctrlKey||r.metaKey)&&r.key==="i"?(r.preventDefault(),we("italic")):(r.ctrlKey||r.metaKey)&&r.key==="u"?(r.preventDefault(),we("underline")):(r.ctrlKey||r.metaKey)&&r.key==="f"?(r.preventDefault(),N(T=>!T)):(r.ctrlKey||r.metaKey)&&r.key==="z"&&!r.shiftKey?(r.preventDefault(),we("undo")):(r.ctrlKey||r.metaKey)&&(r.key==="y"||r.key==="z"&&r.shiftKey)&&(r.preventDefault(),we("redo"))},[K,Te,re,Ae,we]),Ue=n.useCallback(r=>{if(!B)return;r.preventDefault();const T=r.clipboardData.getData("text/html"),X=r.clipboardData.getData("text/plain");if(T){const pe=T.replace(/<style[\s\S]*?<\/style>/gi,"").replace(/<script[\s\S]*?<\/script>/gi,"").replace(/class="[^"]*"/gi,"").replace(/style="[^"]*"/gi,"").replace(/<o:[^>]*>[\s\S]*?<\/o:[^>]*>/gi,"").replace(/<!--[\s\S]*?-->/g,"").replace(/<\/?(?:xml|meta|link|font|span)[^>]*>/gi,"");document.execCommand("insertHTML",!1,pe)}else X&&document.execCommand("insertText",!1,X);const ae=y.current;ae&&(i(ae.innerHTML),de(ae.textContent?.length??0))},[B,i]),Ye=n.useCallback(async r=>{if(!Y)return;r.preventDefault();const T=Array.from(r.dataTransfer.files);if(T.length===0)return;const X=await Y(T),ae=y.current;if(ae){ae.focus();for(const pe of X)if(/\.(png|jpe?g|gif|webp|svg|bmp|ico)$/i.test(pe)||pe.startsWith("data:image/"))document.execCommand("insertImage",!1,pe);else{const Se=`<a href="${pe}">${pe.split("/").pop()??pe}</a>`;document.execCommand("insertHTML",!1,Se)}i(ae.innerHTML)}},[Y,i]),Le=n.useCallback(r=>{Y&&r.preventDefault()},[Y]),De=n.useCallback(r=>{const T=y.current;if(!T||!Z)return;const X=T.textContent??"",ae=Z.toLowerCase(),pe=X.toLowerCase();(r===1?pe.indexOf(ae):pe.lastIndexOf(ae))!==-1&&(T.focus(),window.find?.(Z))},[Z]),ze=n.useCallback(()=>{const r=y.current;!r||!Z||(r.innerHTML=r.innerHTML.split(Z).join(Q),i(r.innerHTML))},[Z,Q,i]),ie=n.useCallback(()=>{if(!Z)return;const r=t.split(Z).join(Q);i(r);const T=y.current;T&&(T.innerHTML=r)},[Z,Q,t,i]),he=n.useCallback(r=>{const T=y.current;T&&(T.focus(),document.execCommand("insertText",!1,r),i(T.innerHTML),xe(!1))},[i]),_e=n.useCallback(r=>{const T=y.current;T&&(T.focus(),document.execCommand("insertHTML",!1,r),i(T.innerHTML),ve(!1))},[i]),Me=n.useCallback(r=>{const T=k||g;if(r==="fontSize")return e.jsx(je.NiceSelect,{size:"sm",value:"",onChange:ae=>we("fontSize",String(ae)),disabled:T,placeholder:"Size",options:di.map(ae=>({value:ae.value,label:ae.label})),style:{minWidth:70,maxWidth:80}},r);if(r==="fontColor")return e.jsx(je.NiceColorPicker,{value:le,onChange:ae=>{ue(ae),we("fontColor",ae)},disabled:T,size:"sm",label:"",title:"Text color"},r);if(r==="bgColor")return e.jsx(je.NiceColorPicker,{value:be,onChange:ae=>{te(ae),we("bgColor",ae)},disabled:T,size:"sm",label:"",title:"Highlight color"},r);const X=r==="markdown"&&C||r==="fullscreen"&&ne||r==="source"&&p||r==="findReplace"&&W||r==="emoji"&&me;return e.jsx(je.NiceButton,{size:"sm",variant:X?"primary":"ghost",onClick:()=>we(r),title:r,disabled:T,children:li[r]||r},r)},[k,g,we,C,ne,le,be,p,W,me]);return I?null:e.jsxs("div",{className:`nice-field nice-field--${O} ${H?"nice-field--error":""} ${A||""}`,style:E,children:[G&&e.jsxs("label",{className:"nice-field__label",htmlFor:S,children:[G,v&&e.jsx("span",{className:"nice-field__required",children:"*"})]}),e.jsxs("div",{ref:L,className:`nice-htmleditor${ne?" nice-htmleditor--fullscreen":""}`,style:{position:"relative"},children:[e.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:20},children:e.jsx(q.wl,{steps:q.xl(h,si)})}),e.jsxs("div",{className:"nice-htmleditor__toolbar",style:{display:"flex",flexWrap:"wrap",gap:2,alignItems:"center"},children:[m.map(Me),P&&P.length>0&&e.jsxs("div",{style:{position:"relative"},children:[e.jsx(je.NiceButton,{size:"sm",variant:ke?"primary":"ghost",onClick:()=>ve(r=>!r),title:"Insert template",children:"??"}),ke&&e.jsx("ul",{style:{position:"absolute",top:"100%",right:0,zIndex:200,background:"var(--bg-primary, #fff)",border:"1px solid var(--border-color, #ddd)",borderRadius:6,boxShadow:"0 4px 16px var(--nice-overlay-12, rgba(0, 0, 0, 0.12))",listStyle:"none",margin:0,padding:4,minWidth:160,maxHeight:200,overflow:"auto"},children:P.map((r,T)=>e.jsx("li",{style:{padding:"6px 10px",cursor:"pointer",borderRadius:4},onMouseDown:X=>{X.preventDefault(),_e(r.html)},children:r.label},T))})]})]}),W&&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:Z,onChange:r=>fe(r.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:Q,onChange:r=>V(r.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(je.NiceButton,{size:"sm",variant:"ghost",onClick:()=>De(1),title:"Find next",children:"?"}),e.jsx(je.NiceButton,{size:"sm",variant:"ghost",onClick:()=>De(-1),title:"Find previous",children:"?"}),e.jsx(je.NiceButton,{size:"sm",variant:"ghost",onClick:ze,disabled:k||g,children:"Replace"}),e.jsx(je.NiceButton,{size:"sm",variant:"ghost",onClick:ie,disabled:k||g,children:"All"}),e.jsx(je.NiceButton,{size:"sm",variant:"ghost",onClick:()=>N(!1),children:"?"})]}),me&&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:mi.map(r=>e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:"0.7em",fontWeight:600,color:"var(--text-muted, #999)",padding:"4px 0"},children:r.label}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:2},children:r.emojis.map(T=>e.jsx("span",{style:{cursor:"pointer",fontSize:"1.2em",padding:2,borderRadius:4},onClick:()=>he(T),title:T,children:T},T))})]},r.label))}),e.jsx("input",{ref:c,type:"file",accept:"image/*",style:{display:"none"},onChange:Re}),p?e.jsx("textarea",{className:"nice-htmleditor__source",value:d,onChange:r=>$(r.target.value),style:{minHeight:a,width:"100%",fontFamily:"monospace",resize:"vertical",whiteSpace:"pre",fontSize:"0.85em",background:"var(--bg-primary, #fff)",color:"var(--text-primary, #1f2937)",border:"none",padding:12,boxSizing:"border-box",outline:"none"},disabled:k||g}):C?e.jsx("textarea",{className:"nice-htmleditor__markdown",value:l,onChange:r=>s(r.target.value),style:{minHeight:a,width:"100%",fontFamily:"monospace",resize:"vertical",background:"var(--bg-primary, #fff)",color:"var(--text-primary, #1f2937)",border:"none",padding:12,boxSizing:"border-box",outline:"none"},disabled:k||g}):e.jsxs("div",{style:{position:"relative"},children:[e.jsx("div",{ref:y,id:S,className:"nice-htmleditor__content",contentEditable:!k&&!g,dangerouslySetInnerHTML:{__html:t},onInput:Be,onKeyDown:Ke,onPaste:Ue,onDrop:Ye,onDragOver:Le,style:{minHeight:a},"data-placeholder":o,role:"textbox","aria-multiline":"true",suppressContentEditableWarning:!0}),K&&Te.length>0&&e.jsx("ul",{className:"nice-htmleditor__mention-list",children:Te.map((r,T)=>e.jsx("li",{className:`nice-htmleditor__mention-item ${T===re?"nice-htmleditor__mention-item--active":""}`,onMouseDown:X=>{X.preventDefault(),Ae(r)},children:r.label},r.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:[x>0&&e.jsxs("span",{children:[ce," / ",x]}),F&&e.jsxs("span",{children:[oe," words"]}),F&&e.jsxs("span",{children:[ce," chars"]}),p&&e.jsx("span",{style:{fontWeight:600},children:"HTML Source"}),C&&e.jsx("span",{style:{fontWeight:600},children:"Markdown"})]})]}),H&&e.jsx("div",{className:"nice-field__error",children:H}),U&&!H&&e.jsx("div",{className:"nice-field__hint",children:U})]})},hi=Object.freeze(Object.defineProperty({__proto__:null,NiceHtmlEditor:xt},Symbol.toStringTag,{value:"Module"})),gi=[{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"}],fi=[{style:"professional",label:"Professional"},{style:"casual",label:"Casual"},{style:"formal",label:"Formal"},{style:"concise",label:"Concise"}],yi=n.forwardRef(function(i,o){const{enableAI:a=!0,aiModel:m,enableImprove:g=!0,enableTranslate:w=!0,enableGenerate:_=!0,toolbar:R,languages:z=gi,textStyles:Y=fi,onImprove:B,onTranslate:x,onGenerate:F,showAIToolbar:P=!0,value:G,onChange:H,...U}=i,v=n.useRef(null),[k,O]=n.useState(!1),[j,A]=n.useState(!1),[E,b]=n.useState(!1),[h,M]=n.useState(""),[I,S]=n.useState(""),[y,c]=n.useState("professional"),[L,C]=n.useState(""),[u,l]=n.useState(z[0]?.code||"en"),[s,p]=n.useState(""),[f,d]=n.useState(""),{t:$}=q.Zt(),K=q.se(),{improveText:ee,translate:D,generateHtml:ge,isLoading:re}=q.Jl(),ye=a&&K.isConfigured,ne=n.useCallback(()=>{const oe=window.getSelection();return oe&&oe.toString().trim()?oe.toString():""},[]),se=n.useCallback(oe=>{const J=window.getSelection();if(J&&J.rangeCount>0){const W=J.getRangeAt(0);W.deleteContents();const N=document.createElement("div");N.innerHTML=oe;const Z=document.createDocumentFragment();for(;N.firstChild;)Z.appendChild(N.firstChild);if(W.insertNode(Z),v.current){const fe=v.current.innerHTML;H(fe)}}},[H]),le=n.useCallback(async(oe="professional")=>{if(!ye||!g)return"";const J=ne();if(!J)return"";M(J),c(oe),O(!0),S("");try{const W=await ee(J,oe);return S(W),B?.(J,W,oe),W}catch{return S($("htmlEditorAI.improveFailed","Failed to improve text")),""}},[ye,g,ne,ee,B,$]),ue=n.useCallback(async oe=>{if(!ye||!w)return"";const J=ne();if(!J)return"";M(J),l(oe),A(!0),C("");try{const W=z.find(Z=>Z.code===oe)?.label||oe,N=await D(J,W);return C(N),x?.(J,N,oe),N}catch{return C($("htmlEditorAI.translateFailed","Failed to translate text")),""}},[ye,w,ne,D,z,x,$]),be=n.useCallback(async oe=>{if(!ye||!_||!oe.trim())return"";p(oe),d("");try{const J=await ge(oe);return d(J),F?.(oe,J),J}catch{return d($("htmlEditorAI.generateFailed","Failed to generate HTML")),""}},[ye,_,ge,F,$]),te=n.useCallback(()=>{I&&se(I),O(!1),S("")},[I,se]),ce=n.useCallback(()=>{L&&se(L),A(!1),C("")},[L,se]),de=n.useCallback(()=>{if(f&&v.current){document.execCommand("insertHTML",!1,f);const oe=v.current.innerHTML;H(oe)}b(!1),d(""),p("")},[f,H]);return n.useImperativeHandle(o,()=>({getEditor:()=>v.current,focus:()=>v.current?.focus(),getValue:()=>v.current?.innerHTML||"",setValue:oe=>{v.current&&(v.current.innerHTML=oe,H(oe))},getSelection:ne,insertHtml:oe=>{document.execCommand("insertHTML",!1,oe),v.current&&H(v.current.innerHTML)},improveSelection:le,translateSelection:ue,generateHtml:be})),n.useCallback(oe=>{v.current=oe},[]),e.jsxs("div",{className:"nice-html-editor-ai","data-testid":i["data-testid"],children:[P&&ye&&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"}),re&&e.jsx("span",{className:"nice-html-editor-ai__loading",children:$("htmlEditorAI.processing","Processing...")})]}),e.jsxs("div",{className:"nice-html-editor-ai__toolbar-right",children:[g&&e.jsxs("div",{className:"nice-html-editor-ai__dropdown",children:[e.jsxs("button",{type:"button",className:"nice-html-editor-ai__btn",onClick:()=>le(),disabled:re,title:$("htmlEditorAI.improveText","Improve selected text"),children:["✨ ",$("htmlEditorAI.improve","Improve")]}),e.jsx("div",{className:"nice-html-editor-ai__dropdown-menu",children:Y.map(({style:oe,label:J})=>e.jsx("button",{type:"button",className:"nice-html-editor-ai__dropdown-item",onClick:()=>le(oe),children:J},oe))})]}),w&&e.jsxs("div",{className:"nice-html-editor-ai__dropdown",children:[e.jsxs("button",{type:"button",className:"nice-html-editor-ai__btn",disabled:re,title:$("htmlEditorAI.translateText","Translate selected text"),children:["🌐 ",$("htmlEditorAI.translate","Translate")]}),e.jsx("div",{className:"nice-html-editor-ai__dropdown-menu nice-html-editor-ai__dropdown-menu--languages",children:z.map(({code:oe,label:J})=>e.jsx("button",{type:"button",className:"nice-html-editor-ai__dropdown-item",onClick:()=>ue(oe),children:J},oe))})]}),_&&e.jsxs("button",{type:"button",className:"nice-html-editor-ai__btn",onClick:()=>b(!0),disabled:re,title:$("htmlEditorAI.generateHtml","Generate HTML from description"),children:["⚡ ",$("htmlEditorAI.generate","Generate")]})]})]}),e.jsx("div",{className:"nice-html-editor-ai__editor-wrapper",children:e.jsx(xt,{value:G,onChange:H,toolbar:R,...U})}),k&&e.jsxs("div",{className:"nice-html-editor-ai__panel",children:[e.jsxs("div",{className:"nice-html-editor-ai__panel-header",children:[e.jsxs("h4",{children:["✨ ",$("htmlEditorAI.improveText","Improve Text")]}),e.jsx("div",{className:"nice-html-editor-ai__style-selector",children:Y.map(({style:oe,label:J})=>e.jsx("button",{type:"button",className:`nice-html-editor-ai__style-btn ${y===oe?"nice-html-editor-ai__style-btn--active":""}`,onClick:()=>{c(oe),le(oe)},children:J},oe))}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__close",onClick:()=>O(!1),children:"✕"})]}),e.jsx("div",{className:"nice-html-editor-ai__panel-body",children:re?e.jsx("div",{className:"nice-html-editor-ai__loading-panel",children:$("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:$("htmlEditorAI.original","Original")}),e.jsx("div",{className:"nice-html-editor-ai__text-content",children:h})]}),e.jsxs("div",{className:"nice-html-editor-ai__text-block nice-html-editor-ai__text-block--improved",children:[e.jsx("h5",{children:$("htmlEditorAI.improved","Improved")}),e.jsx("div",{className:"nice-html-editor-ai__text-content",children:I})]})]})}),e.jsxs("div",{className:"nice-html-editor-ai__panel-footer",children:[e.jsxs("button",{type:"button",className:"nice-html-editor-ai__apply",onClick:te,disabled:!I||re,children:["✓ ",$("htmlEditorAI.apply","Apply")]}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__cancel",onClick:()=>{O(!1),S("")},children:$("htmlEditorAI.cancel","Cancel")})]})]}),j&&e.jsxs("div",{className:"nice-html-editor-ai__panel",children:[e.jsxs("div",{className:"nice-html-editor-ai__panel-header",children:[e.jsxs("h4",{children:["🌐 ",$("htmlEditorAI.translateText","Translate Text")]}),e.jsx("div",{className:"nice-html-editor-ai__language-selector",children:e.jsx("select",{value:u,onChange:oe=>{l(oe.target.value),ue(oe.target.value)},className:"nice-html-editor-ai__language-select",children:z.map(({code:oe,label:J})=>e.jsx("option",{value:oe,children:J},oe))})}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__close",onClick:()=>A(!1),children:"✕"})]}),e.jsx("div",{className:"nice-html-editor-ai__panel-body",children:re?e.jsx("div",{className:"nice-html-editor-ai__loading-panel",children:$("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:$("htmlEditorAI.original","Original")}),e.jsx("div",{className:"nice-html-editor-ai__text-content",children:h})]}),e.jsxs("div",{className:"nice-html-editor-ai__text-block nice-html-editor-ai__text-block--translated",children:[e.jsx("h5",{children:z.find(oe=>oe.code===u)?.label||u}),e.jsx("div",{className:"nice-html-editor-ai__text-content",children:L})]})]})}),e.jsxs("div",{className:"nice-html-editor-ai__panel-footer",children:[e.jsxs("button",{type:"button",className:"nice-html-editor-ai__apply",onClick:ce,disabled:!L||re,children:["✓ ",$("htmlEditorAI.apply","Apply")]}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__cancel",onClick:()=>{A(!1),C("")},children:$("htmlEditorAI.cancel","Cancel")})]})]}),E&&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:["⚡ ",$("htmlEditorAI.generateHtml","Generate HTML")]}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__close",onClick:()=>{b(!1),d(""),p("")},children:"✕"})]}),e.jsxs("div",{className:"nice-html-editor-ai__panel-body",children:[e.jsxs("div",{className:"nice-html-editor-ai__generate-input",children:[e.jsx("textarea",{placeholder:$("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:s,onChange:oe=>p(oe.target.value),className:"nice-html-editor-ai__generate-textarea",rows:3}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__generate-btn",onClick:()=>be(s),disabled:re||!s.trim(),children:re?$("htmlEditorAI.generating","Generating..."):$("htmlEditorAI.generate","Generate")})]}),f&&e.jsxs("div",{className:"nice-html-editor-ai__generate-result",children:[e.jsx("h5",{children:$("htmlEditorAI.preview","Preview")}),e.jsx("div",{className:"nice-html-editor-ai__preview",dangerouslySetInnerHTML:{__html:f}}),e.jsx("h5",{children:$("htmlEditorAI.htmlCode","HTML Code")}),e.jsx("pre",{className:"nice-html-editor-ai__code",children:f})]})]}),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:!f||re,children:["✓ ",$("htmlEditorAI.insert","Insert")]}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__cancel",onClick:()=>{b(!1),d(""),p("")},children:$("htmlEditorAI.cancel","Cancel")})]})]})]})}),an=n.forwardRef(({length:t=6,value:i="",onChange:o,masked:a=!1,onComplete:m,label:g,helperText:w,error:_,required:R,disabled:z,readOnly:Y,size:B="md",name:x,id:F,className:P,style:G,autoFocus:H,labelPlacement:U,errorPlacement:v,labelWidth:k,controlWidth:O,loading:j,cellWidth:A,...E},b)=>{const h=q._s(F),M=n.useRef([]),I=i.padEnd(t,"").slice(0,t).split(""),S=n.useCallback(u=>{const l=Math.max(0,Math.min(t-1,u));M.current[l]?.focus()},[t]),y=n.useCallback(u=>{const l=u.join("");o?.(l),l.length===t&&l.indexOf("")===-1&&/^\d+$/.test(l)&&m?.(l)},[o,m,t]),c=n.useCallback((u,l)=>{const p=l.target.value.replace(/\D/g,"").slice(-1);if(!p)return;const f=[...I];f[u]=p,y(f),S(u+1)},[I,y,S]),L=n.useCallback((u,l)=>{if(l.key==="Backspace"){l.preventDefault();const s=[...I];I[u]?(s[u]="",y(s)):u>0&&(s[u-1]="",y(s),S(u-1))}else l.key==="ArrowLeft"?(l.preventDefault(),S(u-1)):l.key==="ArrowRight"&&(l.preventDefault(),S(u+1))},[I,y,S]),C=n.useCallback(u=>{u.preventDefault();const l=u.clipboardData.getData("text").replace(/\D/g,"").slice(0,t);if(!l)return;const s=l.padEnd(t,"").slice(0,t).split("");for(let p=l.length;p<t;p++)s[p]=I[p]||"";y(s),S(Math.min(l.length,t-1))},[t,I,y,S]);return e.jsxs("div",{className:`nice-field nice-field--${B} nice-field--otp${U?` nice-field--label-${U}`:""}${v==="right"?" nice-field--error-right":""} ${j?"nice-field--loading":""} ${P||""}`,style:{...G,...k!=null&&{"--nice-field-label-width":typeof k=="number"?`${k}px`:k},...O!=null&&{"--nice-field-control-width":typeof O=="number"?`${O}px`:O},...A!=null&&{"--nice-otp-cell-width":typeof A=="number"?`${A}px`:A}},"aria-busy":j||void 0,...E,children:[g&&e.jsx("label",{htmlFor:`${h}-0`,className:`nice-field__label ${R?"nice-field__label--required":""}`,children:g}),e.jsxs("div",{className:"nice-field__control",children:[e.jsxs("div",{ref:b,className:`nice-otp nice-otp--${B} ${_?"nice-otp--error":""} ${z?"nice-otp--disabled":""}`,onPaste:C,children:[Array.from({length:t},(u,l)=>e.jsx("input",{ref:s=>{M.current[l]=s},id:l===0?`${h}-0`:void 0,className:"nice-otp__digit",type:a?"password":"text",inputMode:"numeric",maxLength:2,value:I[l]||"",disabled:z,readOnly:Y,autoFocus:H&&l===0,"aria-invalid":!!_,"aria-label":`${l+1}`,onChange:s=>c(l,s),onKeyDown:s=>L(l,s),onFocus:s=>s.target.select()},l)),x&&e.jsx("input",{type:"hidden",name:x,value:i})]}),v==="right"&&_&&e.jsx("div",{id:`${h}-error`,className:"nice-field__error",role:"alert",children:_}),v==="right"&&!_&&w&&e.jsx("div",{id:`${h}-helper`,className:"nice-field__helper",children:w}),j&&e.jsx("span",{className:"nice-field__spinner",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})})]}),v!=="right"&&_&&e.jsx("div",{id:`${h}-error`,className:"nice-field__error",role:"alert",children:_}),v!=="right"&&!_&&w&&e.jsx("div",{id:`${h}-helper`,className:"nice-field__helper",children:w})]})});an.displayName="NiceInputOtp";const xi={xxs:36,xs:48,sm:64,md:80,lg:100,xl:128,xxl:160,small:64,medium:80,large:100},Qe=6,qe=135,rn=405,Ve=rn-qe;function ht(t,i,o,a){const m=(a-90)*(Math.PI/180);return{x:t+o*Math.cos(m),y:i+o*Math.sin(m)}}function Mt(t,i,o,a,m){const g=ht(t,i,o,a),w=ht(t,i,o,m),_=m-a>180?1:0;return`M ${g.x} ${g.y} A ${o} ${o} 0 ${_} 1 ${w.x} ${w.y}`}const sn=n.forwardRef(({value:t=0,onChange:i,min:o=0,max:a=100,step:m=1,showValue:g=!0,valueTemplate:w="{value}",label:_,helperText:R,error:z,required:Y,disabled:B,readOnly:x,size:F="md",name:P,id:G,className:H,style:U,labelPlacement:v="top",errorPlacement:k,labelWidth:O,controlWidth:j,loading:A,isLabelCentered:E=!0,...b},h)=>{const M=q._s(G),I=n.useRef(!1),S=n.useRef(null),y=typeof F=="number"?F:xi[F],c=y/2,L=y/2,C=(y-Qe*2)/2,u=a>o?(t-o)/(a-o):0,l=qe+u*Ve,s=n.useCallback(K=>{let ee=K-qe;ee<0&&(ee+=360),ee>Ve&&(ee=ee-Ve<360-ee?Ve:0);const D=Math.max(0,Math.min(1,ee/Ve)),ge=o+D*(a-o),re=Math.round(ge/m)*m;return Math.max(o,Math.min(a,re))},[o,a,m]),p=n.useCallback(K=>{if(B||x)return;const ee=S.current;if(!ee)return;const D=ee.getBoundingClientRect(),ge=K.clientX-D.left-D.width/2,re=K.clientY-D.top-D.height/2;let ye=Math.atan2(ge,-re)*(180/Math.PI);ye<0&&(ye+=360);const ne=s(ye);i?.(ne)},[s,B,x,i]);n.useEffect(()=>{const K=D=>{I.current&&p(D)},ee=()=>{I.current=!1};return window.addEventListener("pointermove",K),window.addEventListener("pointerup",ee),()=>{window.removeEventListener("pointermove",K),window.removeEventListener("pointerup",ee)}},[p]);const f=n.useCallback(K=>{if(B||x)return;let ee=t;K.key==="ArrowUp"||K.key==="ArrowRight"?(K.preventDefault(),ee=Math.min(a,t+m)):(K.key==="ArrowDown"||K.key==="ArrowLeft")&&(K.preventDefault(),ee=Math.max(o,t-m)),ee!==t&&i?.(ee)},[t,i,o,a,m,B,x]),d=w.replace("{value}",String(t)),$=ht(c,L,C,l);return e.jsxs("div",{className:`nice-field nice-knob-field nice-knob-field--err-${k||"bottom"} nice-field--${typeof F=="string"?F:"md"} ${A?"nice-field--loading":""} ${H||""}`,style:{...U,...O!=null&&{"--nice-field-label-width":typeof O=="number"?`${O}px`:O},...j!=null&&{"--nice-field-control-width":typeof j=="number"?`${j}px`:j}},"aria-busy":A||void 0,...b,children:[e.jsxs("div",{className:`nice-knob-field__inner nice-knob-field--${v} ${E?"nice-knob-field--label-centered":""}`,children:[_&&e.jsx("label",{htmlFor:M,className:`nice-field__label ${Y?"nice-field__label--required":""}`,children:_}),e.jsx("div",{className:"nice-field__control",children:e.jsxs("div",{ref:K=>{S.current=K,typeof h=="function"?h(K):h&&(h.current=K)},className:`nice-knob nice-knob--${F} ${B?"nice-knob--disabled":""} ${z?"nice-knob--error":""}`,role:"slider",id:M,tabIndex:B?-1:0,"aria-valuenow":t,"aria-valuemin":o,"aria-valuemax":a,"aria-disabled":B,"aria-invalid":!!z,onPointerDown:K=>{B||x||(I.current=!0,p(K))},onKeyDown:f,children:[e.jsxs("svg",{width:y,height:y,viewBox:`0 0 ${y} ${y}`,children:[e.jsx("path",{d:Mt(c,L,C,qe,rn),fill:"none",stroke:"var(--nice-border-color, #d1d5db)",strokeWidth:Qe,strokeLinecap:"round"}),u>0&&e.jsx("path",{d:Mt(c,L,C,qe,l),fill:"none",stroke:"var(--nice-primary, #3b82f6)",strokeWidth:Qe,strokeLinecap:"round"}),e.jsx("circle",{cx:$.x,cy:$.y,r:Qe,fill:"var(--nice-primary, #3b82f6)"})]}),g&&e.jsx("span",{className:"nice-knob__value",children:d}),P&&e.jsx("input",{type:"hidden",name:P,value:t}),A&&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&&R&&e.jsx("div",{className:"nice-field__helper",children:R})]})});sn.displayName="NiceKnob";const cn=n.forwardRef(({value:t="",onChange:i,suggestions:o=[],onSearch:a,trigger:m="@",renderSuggestion:g,placeholder:w,rows:_=3,label:R,helperText:z,error:Y,required:B,disabled:x,readOnly:F,size:P="md",name:G,id:H,className:U,style:v,...k},O)=>{const j=q._s(H),[A,E]=n.useState(!1),[b,h]=n.useState(""),[M,I]=n.useState(0),[S,y]=n.useState({top:0,left:0}),c=n.useRef(null),L=n.useRef(-1),u=o.map(d=>typeof d=="string"?{key:d,label:d}:d).filter(d=>d.label.toLowerCase().includes(b.toLowerCase())),l=n.useCallback(()=>{E(!1),h(""),I(0),L.current=-1},[]),s=n.useCallback(d=>{const $=c.current;if(!$||L.current<0)return;const K=t.slice(0,L.current),ee=t.slice($.selectionStart),D=`${m}${d.label} `,ge=K+D+ee;i?.(ge),l(),requestAnimationFrame(()=>{const re=K.length+D.length;$.setSelectionRange(re,re),$.focus()})},[t,i,m,l]),p=n.useCallback(d=>{const $=d.target.value;i?.($);const K=d.target.selectionStart,ee=$.slice(0,K),D=ee.lastIndexOf(m);if(D>=0){const ge=D>0?ee[D-1]:" ",re=ee.slice(D+m.length);if(/\s/.test(ge)&&!/\s/.test(re)){L.current=D;const ye=re;h(ye),E(!0),I(0),a?.(ye);const ne=d.target,se=ne.getBoundingClientRect(),le=parseInt(getComputedStyle(ne).lineHeight)||20,ue=ee.split(`
11
+ `);y({top:se.top+ue.length*le+4-ne.scrollTop,left:se.left+8});return}}l()},[i,m,a,l]),f=n.useCallback(d=>{!A||u.length===0||(d.key==="ArrowDown"?(d.preventDefault(),I($=>($+1)%u.length)):d.key==="ArrowUp"?(d.preventDefault(),I($=>($-1+u.length)%u.length)):d.key==="Enter"?(d.preventDefault(),u[M]&&s(u[M])):d.key==="Escape"&&l())},[A,u,M,s,l]);return n.useEffect(()=>{if(!A)return;const d=$=>{const K=c.current;K&&!K.contains($.target)&&l()};return document.addEventListener("mousedown",d),()=>document.removeEventListener("mousedown",d)},[A,l]),e.jsxs("div",{className:`nice-field ${U||""}`,style:v,...k,children:[R&&e.jsx("label",{htmlFor:j,className:`nice-field__label ${B?"nice-field__label--required":""}`,children:R}),e.jsxs("div",{className:`nice-mention nice-mention--${P} ${Y?"nice-mention--error":""} ${x?"nice-mention--disabled":""}`,children:[e.jsx("textarea",{ref:d=>{c.current=d,typeof O=="function"?O(d):O&&(O.current=d)},id:j,name:G,className:"nice-mention__input",value:t,onChange:p,onKeyDown:f,placeholder:w,rows:_,disabled:x,readOnly:F,"aria-invalid":!!Y,"aria-describedby":Y?`${j}-error`:z?`${j}-helper`:void 0,"aria-autocomplete":"list","aria-expanded":A}),A&&u.length>0&&e.jsx("ul",{className:"nice-mention__suggestions",role:"listbox",style:{position:"fixed",top:S.top,left:S.left},children:u.map((d,$)=>e.jsx("li",{role:"option","aria-selected":$===M,className:`nice-mention__suggestion ${$===M?"nice-mention__suggestion--active":""}`,onMouseDown:K=>{K.preventDefault(),s(d)},onMouseEnter:()=>I($),children:g?g(d):e.jsxs(e.Fragment,{children:[d.icon&&e.jsx("span",{className:"nice-mention__suggestion-icon",children:d.icon}),e.jsx("span",{children:d.label})]})},d.key))})]}),Y&&e.jsx("div",{id:`${j}-error`,className:"nice-field__error",role:"alert",children:Y}),!Y&&z&&e.jsx("div",{id:`${j}-helper`,className:"nice-field__helper",children:z})]})});cn.displayName="NiceMention";function bi(t){const i=[],o=a=>{for(const m of a)i.push(m),m.children&&o(m.children)};return o(t),i}function ln(t,i){const o=i.toLowerCase();return t.reduce((a,m)=>{const g=m.children?ln(m.children,i):[];return(m.label.toLowerCase().includes(o)||g.length>0)&&a.push({...m,children:g.length>0?g:m.children}),a},[])}const dn=({node:t,level:i,selectedKeys:o,expandedKeys:a,onToggleExpand:m,onSelect:g,selectableLeafsOnly:w,maxDepth:_})=>{const R=typeof _=="number"?Math.min(10,Math.max(1,_)):1/0,Y=!(i+1>=R)&&t.children&&t.children.length>0,B=a.has(t.key),x=o.has(t.key),F=!Y,P=!t.disabled&&(!w||F),G=Math.min(i+1,10),H={paddingLeft:i*16+8,"--nice-row-bg":`var(--nice-tree-level-${G}-bg, transparent)`,"--nice-row-text":`var(--nice-tree-level-${G}-text, inherit)`,"--nice-row-hover-bg":`var(--nice-tree-level-${G}-hover-bg, var(--bg-secondary, #f3f4f6))`,"--nice-row-active-bg":`var(--nice-tree-level-${G}-active-bg, var(--nice-primary-tint-10, rgba(59,130,246,0.1)))`};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`nice-tree-select__node ${x?"nice-tree-select__node--selected":""} ${t.disabled?"nice-tree-select__node--disabled":""}`,style:H,"data-nice-depth":G,onClick:()=>P&&g(t.key),role:"treeitem","aria-selected":x,"aria-expanded":Y?B:void 0,"aria-disabled":t.disabled,children:[Y?e.jsx("button",{type:"button",className:"nice-tree-select__toggle",onClick:U=>{U.stopPropagation(),m(t.key)},"aria-label":"Toggle",children:e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"currentColor",style:{transform:B?"rotate(90deg)":"none",transition:"transform 0.15s"},children:e.jsx("path",{d:"M4.5 2l4 4-4 4"})})}):e.jsx("span",{style:{width:12,display:"inline-block"}}),(t.icon==null,null),e.jsx("span",{className:"nice-tree-select__node-label",children:t.label})]}),Y&&B&&t.children.map(U=>e.jsx(dn,{node:U,level:i+1,selectedKeys:o,expandedKeys:a,onToggleExpand:m,onSelect:g,selectableLeafsOnly:w,maxDepth:_},U.key))]})},mn=n.forwardRef(({nodes:t,value:i,onChange:o,multiple:a=!1,searchable:m=!1,placeholder:g,selectableLeafsOnly:w=!1,clearable:_=!1,maxDepth:R,label:z,helperText:Y,error:B,required:x,disabled:F,readOnly:P,size:G="md",name:H,id:U,className:v,style:k,controlWidth:O,...j},A)=>{const{t:E}=q.Zt(),b=q._s(U),[h,M]=n.useState(!1),[I,S]=n.useState(""),[y,c]=n.useState(new Set),L=n.useRef(null);q.Vs(L,()=>M(!1));const C=n.useMemo(()=>i==null?new Set:new Set(Array.isArray(i)?i:[i]),[i]),u=n.useMemo(()=>I?ln(t,I):t,[t,I]),l=n.useMemo(()=>{const d=bi(t);return Array.from(C).map($=>d.find(K=>K.key===$)?.label).filter(Boolean)},[C,t]),s=n.useCallback(d=>{c($=>{const K=new Set($);return K.has(d)?K.delete(d):K.add(d),K})},[]),p=n.useCallback(d=>{if(a){const $=new Set(C);$.has(d)?$.delete(d):$.add(d),o?.(Array.from($))}else o?.(d),M(!1)},[a,C,o]),f=n.useCallback(d=>{d.stopPropagation(),o?.(a?[]:"")},[o,a]);return e.jsxs("div",{className:`nice-field nice-field--${G} ${v||""}`,style:{width:"fit-content",maxWidth:"100%",...k},...j,children:[z&&e.jsx("label",{htmlFor:b,className:`nice-field__label ${x?"nice-field__label--required":""}`,children:z}),e.jsxs("div",{ref:L,className:"nice-tree-select",style:{position:"relative",width:O!=null?typeof O=="number"?`${O}px`:O:240},children:[e.jsxs("div",{ref:A,id:b,className:`nice-input nice-input--${G} ${B?"nice-input--error":""} ${F?"nice-input--disabled":""} ${P?"nice-input--readonly":""}`,role:"combobox","aria-expanded":h,"aria-haspopup":"tree","aria-invalid":!!B,tabIndex:F?-1:0,onClick:()=>!F&&!P&&M(!h),onKeyDown:d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),!F&&!P&&M(!h))},children:[e.jsx("span",{className:"nice-tree-select__display",children:l.length>0?l.join(", "):e.jsx("span",{className:"nice-tree-select__placeholder",children:g??E("controls.select","Select...")})}),_&&C.size>0&&e.jsx("button",{type:"button",className:"nice-input__clear",onClick:f,"aria-label":E("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:h?"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"})})]}),h&&e.jsxs("div",{className:"nice-tree-select__dropdown",role:"tree",children:[m&&e.jsx("div",{className:"nice-tree-select__search",children:e.jsx("input",{className:"nice-input__native",type:"text",placeholder:E("controls.search","Search..."),value:I,onChange:d=>S(d.target.value),autoFocus:!0,onClick:d=>d.stopPropagation()})}),e.jsx("div",{className:"nice-tree-select__list",children:u.length===0?e.jsx("div",{className:"nice-tree-select__empty",children:E("controls.noResults","No results")}):u.map(d=>e.jsx(dn,{node:d,level:0,selectedKeys:C,expandedKeys:y,onToggleExpand:s,onSelect:p,selectableLeafsOnly:w,maxDepth:R},d.key))})]})]}),H&&e.jsx("input",{type:"hidden",name:H,value:Array.isArray(i)?i.join(","):i??""}),B&&e.jsx("div",{id:`${b}-error`,className:"nice-field__error",role:"alert",children:B}),!B&&Y&&e.jsx("div",{id:`${b}-helper`,className:"nice-field__helper",children:Y})]})});mn.displayName="NiceTreeSelect";function Oe(t,i){return String(t[i])}const un=n.forwardRef(({source:t,target:i,onChange:o,keyField:a="id",labelField:m="label",renderItem:g,filterable:w=!1,searchable:_,groupBy:R,sortable:z=!1,bulkActions:Y=!0,maxRight:B,sourceHeader:x,targetHeader:F,disabled:P=!1,size:G="md",className:H,style:U,id:v,...k},O)=>{const{t:j}=q.Zt(),[A,E]=n.useState(new Set),[b,h]=n.useState(new Set),[M,I]=n.useState(""),[S,y]=n.useState(""),c=n.useCallback((d,$,K)=>{$(ee=>{const D=new Set(ee);return D.has(K)?D.delete(K):D.add(K),D})},[]),L=n.useCallback(()=>{const d=t.filter(D=>A.has(Oe(D,a))),$=t.filter(D=>!A.has(Oe(D,a))),K=typeof B=="number"?d.slice(0,Math.max(0,B-i.length)):d,ee=d.slice(K.length);o([...$,...ee],[...i,...K]),E(new Set)},[t,i,A,a,o,B]),C=n.useCallback(()=>{const d=i.filter(K=>b.has(Oe(K,a))),$=i.filter(K=>!b.has(Oe(K,a)));o([...t,...d],$),h(new Set)},[t,i,b,a,o]),u=n.useCallback(()=>{if(typeof B=="number"){const d=Math.max(0,B-i.length),$=t.slice(0,d),K=t.slice(d);o(K,[...i,...$])}else o([],[...i,...t]);E(new Set)},[t,i,o,B]),l=n.useCallback(()=>{o([...t,...i],[]),h(new Set)},[t,i,o]),s=(d,$)=>{if(!$)return d;const K=$.toLowerCase();return d.filter(ee=>String(ee[m]).toLowerCase().includes(K))},p=Y===!1?{moveAll:!1,removeAll:!1}:Y===!0||Y===void 0?{moveAll:!0,removeAll:!0}:{moveAll:Y.moveAll??!0,removeAll:Y.removeAll??!0},f=(d,$,K,ee,D,ge,re)=>{const ye=s(d,ee),ne=_===!0||w&&_===void 0?"both":_??!1,se=ne==="both"||ne==="left"&&re==="left"||ne==="right"&&re==="right",le=(()=>{if(!R)return[{label:"",items:ye}];const te=new Map;for(const ce of ye){const de=String(R(ce));let oe=te.get(de);oe||(oe=[],te.set(de,oe)),oe.push(ce)}return[...te.entries()].map(([ce,de])=>({label:ce,items:de}))})(),ue=(te,ce)=>{te.dataTransfer.setData("text/plain",ce),te.dataTransfer.effectAllowed="move"},be=(te,ce)=>{te.preventDefault();const de=te.dataTransfer.getData("text/plain");if(!de||de===ce||re!=="right"||!z)return;const oe=[...i],J=oe.findIndex(Z=>Oe(Z,a)===de),W=oe.findIndex(Z=>Oe(Z,a)===ce);if(J===-1||W===-1)return;const[N]=oe.splice(J,1);oe.splice(W,0,N),o(t,oe)};return e.jsxs("div",{className:"nice-picklist__panel",children:[ge&&e.jsx("div",{className:"nice-picklist__header",children:ge}),se&&e.jsx("div",{className:"nice-picklist__filter",children:e.jsx("input",{className:"nice-input__native",type:"text",placeholder:j("controls.search","Search..."),value:ee,onChange:te=>D(te.target.value)})}),e.jsxs("div",{className:"nice-picklist__list",role:"listbox","aria-multiselectable":"true",children:[le.map(te=>e.jsxs(n.Fragment,{children:[te.label&&e.jsx("div",{className:"nice-picklist__group-header",role:"presentation",children:te.label}),te.items.map(ce=>{const de=Oe(ce,a),oe=$.has(de);return e.jsx("div",{className:`nice-picklist__item ${oe?"nice-picklist__item--selected":""}`,role:"option","aria-selected":oe,draggable:z&&re==="right",onDragStart:z&&re==="right"?J=>ue(J,de):void 0,onDragOver:z&&re==="right"?J=>J.preventDefault():void 0,onDrop:z&&re==="right"?J=>be(J,de):void 0,onClick:()=>!P&&c($,K,de),children:g?g(ce,re):String(ce[m])},de)})]},te.label||"__none__")),ye.length===0&&e.jsx("div",{className:"nice-picklist__empty",children:j("controls.noItems","No items")})]})]})};return e.jsxs("div",{ref:O,id:v,className:`nice-picklist nice-picklist--${G} ${P?"nice-picklist--disabled":""} ${H||""}`,style:U,...k,children:[f(t,A,E,M,I,x??j("picklist.source","Available"),"left"),e.jsxs("div",{className:"nice-picklist__controls",children:[e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm",disabled:P||A.size===0,onClick:L,"aria-label":j("picklist.moveRight","Move right"),children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{d:"M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z"})})}),p.moveAll&&e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm",disabled:P||t.length===0,onClick:u,"aria-label":j("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:P||b.size===0,onClick:C,"aria-label":j("picklist.moveLeft","Move left"),children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{d:"M12.707 5.293a1 1 0 010 1.414L9.414 10l3.293 3.293a1 1 0 01-1.414 1.414l-4-4a1 1 0 010-1.414l4-4a1 1 0 011.414 0z"})})}),p.removeAll&&e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm",disabled:P||i.length===0,onClick:l,"aria-label":j("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"})]})})]}),f(i,b,h,S,y,F??j("picklist.target","Selected"),"right")]})});un.displayName="NicePickList";const ji=[{target:".nice-code-editor-wrap",titleKey:"tutorial.codeEditor.intro.title",title:"Code editor",contentKey:"tutorial.codeEditor.intro.content",content:"Edit code with syntax highlighting, IntelliSense and the toolbar. Ctrl+S saves; the status bar shows the cursor position and any problems.",placement:"auto"}];let He=null,Xe=null;const _i="0.45.0",at=`https://cdn.jsdelivr.net/npm/monaco-editor@${_i}/min/vs`,$t=15e3;function Et(){const t=window;if(t.MonacoEnvironment?.getWorkerUrl)return;const i=`self.MonacoEnvironment={baseUrl:'${at}/'};importScripts('${at}/base/worker/workerMain.js');`,o=URL.createObjectURL(new Blob([i],{type:"text/javascript"}));t.MonacoEnvironment={getWorkerUrl:()=>o}}function Fe(t){if(t!=="auto")return t;if(typeof document>"u")return"vs";const i=document.documentElement.dataset.theme;return i==="dark"?"vs-dark":i==="light"?"vs":window.matchMedia?.("(prefers-color-scheme: dark)").matches?"vs-dark":"vs"}function pn(){return Xe?Promise.resolve(Xe):He||(He=new Promise((t,i)=>{if(window.monaco){Et(),Xe=window.monaco,t(Xe);return}let o=!1;const a=window.setTimeout(()=>{o||(o=!0,He=null,i(new Error(`Monaco editor failed to load within ${$t}ms`)))},$t),m=document.createElement("script");m.src=`${at}/loader.min.js`,m.async=!0,m.onload=()=>{const g=window.require;g.config({paths:{vs:at}}),Et(),g(["vs/editor/editor.main"],w=>{o||(o=!0,window.clearTimeout(a),Xe=w,t(w))})},m.onerror=()=>{o||(o=!0,window.clearTimeout(a),He=null,i(new Error("Failed to load Monaco Editor loader script")))},document.head.appendChild(m)}),He)}const Je=n.forwardRef(function(i,o){const{value:a,onChange:m,language:g="plaintext",theme:w="auto",options:_={},height:R=400,width:z="100%",markers:Y=[],decorations:B=[],completionProvider:x,onMount:F,onCursorPositionChange:P,onSelectionChange:G,onSave:H,loading:U,disabled:v=!1,showToolbar:k=!1,showStatusBar:O=!1,editorSize:j="standard",className:A,"data-testid":E,lsp:b,extraLibs:h,tutorial:M}=i,I=n.useRef(null),S=n.useRef(null),y=n.useRef(null),c=n.useRef([]),L=n.useRef(null),[C,u]=n.useState(!0),[l,s]=n.useState(null),[p,f]=n.useState({lineNumber:1,column:1}),[d,$]=n.useState(""),[K,ee]=n.useState(_.wordWrap==="on"),D=n.useMemo(()=>({automaticLayout:!0,readOnly:v||_.readOnly,minimap:{enabled:_.minimap??!0},lineNumbers:_.lineNumbers??"on",wordWrap:_.wordWrap??"off",tabSize:_.tabSize??2,insertSpaces:_.insertSpaces??!0,fontSize:_.fontSize??14,fontFamily:_.fontFamily??"'Fira Code', 'Consolas', 'Monaco', monospace",fontLigatures:_.fontLigatures??!0,cursorStyle:_.cursorStyle??"line",cursorBlinking:_.cursorBlinking??"blink",autoClosingBrackets:_.autoClosingBrackets??"languageDefined",autoClosingQuotes:_.autoClosingQuotes??"languageDefined",formatOnPaste:_.formatOnPaste??!1,formatOnType:_.formatOnType??!1,renderWhitespace:_.renderWhitespace??"selection",renderControlCharacters:_.renderControlCharacters??!1,scrollBeyondLastLine:_.scrollBeyondLastLine??!0,smoothScrolling:_.smoothScrolling??!0,folding:_.folding??!0,showFoldingControls:_.showFoldingControls??"mouseover","bracketPairColorization.enabled":_.bracketPairColorization??!0,guides:_.guides??{bracketPairs:!0,indentation:!0,highlightActiveIndentation:!0},stickyScroll:{enabled:_.stickyScroll??!1},quickSuggestions:_.quickSuggestions??!0,suggestOnTriggerCharacters:_.suggestOnTriggerCharacters??!0,acceptSuggestionOnEnter:_.acceptSuggestionOnEnter??"on",inlayHints:{enabled:_.inlayHints?"on":"off"}}),[_,v]);n.useEffect(()=>{if(!I.current)return;let ne=!0;return pn().then(async se=>{if(!ne||!I.current)return;y.current=se;const le=se.editor.create(I.current,{value:a,language:g,theme:Fe(w),...D});if(S.current=le,u(!1),le.onDidChangeModelContent(()=>{const ue=le.getValue();m?.(ue)}),le.onDidChangeCursorPosition(ue=>{f({lineNumber:ue.position.lineNumber,column:ue.position.column}),P?.({lineNumber:ue.position.lineNumber,column:ue.position.column})}),le.onDidChangeCursorSelection(ue=>{const be=ue.selection,te=le.getModel()?.getValueInRange(be)??"";$(te),G?.({startLineNumber:be.startLineNumber,startColumn:be.startColumn,endLineNumber:be.endLineNumber,endColumn:be.endColumn})}),le.addCommand(se.KeyMod.CtrlCmd|se.KeyCode.KeyS,()=>{H?.(le.getValue())}),b&&typeof window<"u")try{await rt("https://cdn.jsdelivr.net/npm/vscode-ws-jsonrpc@1.0.2/lib/browser/index.min.js"),await rt("https://cdn.jsdelivr.net/npm/monaco-languageclient@0.15.0/lib/monaco-languageclient.min.js");const ue=window,be=ue.ReconnectingWebSocket,{MonacoLanguageClient:te,CloseAction:ce,ErrorAction:de,createConnection:oe}=ue.monacoLanguageClient||{};if(te&&oe){const J=b.url,W=b.language,N=new be(J),Z=new ue.VSCodeWebSocketMessageReader(N),fe=new ue.VSCodeWebSocketMessageWriter(N),Q=oe(Z,fe),V=new te({name:"LSP Client",clientOptions:{documentSelector:[W],initializationOptions:b.initOptions,errorHandler:{error:()=>de.Continue,closed:()=>ce.Restart}},connectionProvider:{get:()=>Promise.resolve(Q)}});V.start(),S.current.__lspClient=V}}catch(ue){console.warn("LSP bridge failed to load:",ue)}F?.(le,se)}).catch(se=>{ne&&(s(se.message??"Failed to load editor"),u(!1))}),()=>{if(ne=!1,S.current?.dispose(),L.current?.dispose(),S.current&&S.current.__lspClient)try{S.current.__lspClient.stop()}catch{}}},[b]),n.useEffect(()=>{const ne=S.current;if(ne&&a!==ne.getValue()){const se=ne.getPosition();ne.setValue(a),se&&ne.setPosition(se)}},[a]),n.useEffect(()=>{const ne=S.current,se=y.current;if(ne&&se){const le=ne.getModel();le&&se.editor.setModelLanguage(le,g)}},[g]),n.useEffect(()=>{const ne=y.current;if(!ne||C||!h||h.length===0||g!=="javascript"&&g!=="typescript")return;const se=ne.languages?.typescript;if(!se)return;const le=[];try{h.forEach((ue,be)=>{const te=ue.filePath??`inmemory://model/nice-extralib-${be}.d.ts`,ce=se.typescriptDefaults?.addExtraLib(ue.content,te);ce&&le.push(ce);const de=se.javascriptDefaults?.addExtraLib(ue.content,te);de&&le.push(de)})}catch(ue){console.warn("Failed to register extraLibs:",ue)}return()=>{le.forEach(ue=>{try{ue.dispose()}catch{}})}},[h,g,C]),n.useEffect(()=>{const ne=y.current;if(!ne||(ne.editor.setTheme(Fe(w)),w!=="auto"||typeof document>"u"))return;const se=()=>{y.current?.editor.setTheme(Fe("auto"))},le=new MutationObserver(se);le.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme","class"]});const ue=window.matchMedia?.("(prefers-color-scheme: dark)");return ue?.addEventListener?.("change",se),()=>{le.disconnect(),ue?.removeEventListener?.("change",se)}},[w]),n.useEffect(()=>{const ne=S.current;ne&&ne.updateOptions(D)},[D]),n.useEffect(()=>{const ne=S.current,se=y.current;if(ne&&se){const le=ne.getModel();if(le){const ue=Y.map(be=>({startLineNumber:be.startLineNumber,startColumn:be.startColumn,endLineNumber:be.endLineNumber,endColumn:be.endColumn,message:be.message,severity:be.severity}));se.editor.setModelMarkers(le,"owner",ue)}}},[Y]),n.useEffect(()=>{const ne=S.current;if(ne&&B.length>0){const se=B.map(le=>({range:{startLineNumber:le.range.startLineNumber,startColumn:le.range.startColumn,endLineNumber:le.range.endLineNumber,endColumn:le.range.endColumn},options:{className:le.className,glyphMarginClassName:le.glyphMarginClassName,hoverMessage:le.hoverMessage?{value:le.hoverMessage}:void 0,isWholeLine:le.isWholeLine}}));c.current=ne.deltaDecorations(c.current,se)}},[B]),n.useEffect(()=>{const ne=y.current;if(!ne||!x)return;L.current?.dispose();const se={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 L.current=ne.languages.registerCompletionItemProvider(g,{provideCompletionItems:async(le,ue)=>({suggestions:(await x(le,ue)).map(te=>({label:te.label,kind:se[te.kind]??0,insertText:te.insertText,insertTextRules:te.insertTextRules==="insertAsSnippet"?4:void 0,documentation:te.documentation,detail:te.detail,range:{startLineNumber:ue.lineNumber,startColumn:ue.column,endLineNumber:ue.lineNumber,endColumn:ue.column}}))})}),()=>{L.current?.dispose()}},[g,x]),n.useImperativeHandle(o,()=>({getEditor:()=>S.current,getMonaco:()=>y.current,focus:()=>S.current?.focus(),getValue:()=>S.current?.getValue()??"",setValue:ne=>S.current?.setValue(ne),getSelection:()=>{const ne=S.current;if(!ne)return"";const se=ne.getSelection();return se?ne.getModel()?.getValueInRange(se)??"":""},insertText:ne=>{const se=S.current;if(!se)return;const le=se.getSelection();le&&se.executeEdits("",[{range:le,text:ne}])},formatDocument:()=>{S.current?.getAction("editor.action.formatDocument")?.run()},goToLine:(ne,se=1)=>{const le=S.current;le&&(le.setPosition({lineNumber:ne,column:se}),le.revealLineInCenter(ne),le.focus())},findReplace:()=>{S.current?.getAction("editor.action.startFindReplaceAction")?.run()},undo:()=>{S.current?.trigger("keyboard","undo",null)},redo:()=>{S.current?.trigger("keyboard","redo",null)},getCursorPosition:()=>{const ne=S.current?.getPosition();return{lineNumber:ne?.lineNumber??1,column:ne?.column??1}},setMarkers:ne=>{const se=S.current,le=y.current;if(se&&le){const ue=se.getModel();if(ue){const be=ne.map(te=>({startLineNumber:te.startLineNumber,startColumn:te.startColumn,endLineNumber:te.endLineNumber,endColumn:te.endColumn,message:te.message,severity:te.severity}));le.editor.setModelMarkers(ue,"owner",be)}}}}),[]);const ge=n.useMemo(()=>({format:()=>S.current?.getAction("editor.action.formatDocument")?.run(),undo:()=>S.current?.trigger("keyboard","undo",null),redo:()=>S.current?.trigger("keyboard","redo",null),find:()=>S.current?.getAction("editor.action.startFindReplaceAction")?.run(),toggleWordWrap:()=>{const ne=!K;ee(ne),S.current?.updateOptions({wordWrap:ne?"on":"off"})},toggleMinimap:()=>{const ne=S.current?.getOption?.(y.current?.editor?.EditorOption?.minimap);S.current?.updateOptions({minimap:{enabled:!ne?.enabled}})},foldAll:()=>S.current?.getAction("editor.foldAll")?.run(),unfoldAll:()=>S.current?.getAction("editor.unfoldAll")?.run()}),[K]),re=a.split(`
12
+ `).length,ye=a.length;return e.jsxs("div",{className:`nice-code-editor-wrap nice-editor--${j} ${A??""}`,style:{height:R,width:z,display:"flex",flexDirection:"column",position:"relative"},"data-testid":E,children:[e.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:20},children:e.jsx(q.wl,{steps:q.xl(M,ji)})}),l&&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:["⚠️ ",l]}),e.jsx("textarea",{value:a,onChange:ne=>m?.(ne.target.value),readOnly:v||_.readOnly,style:{width:"100%",height:"100%",fontFamily:"monospace"}})]}),C&&!l&&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:U??e.jsx("div",{className:"nice-code-editor__loader",children:"Loading editor..."})}),k&&e.jsxs("div",{className:"nice-code-editor__toolbar",children:[e.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:ge.undo,title:"Undo (Ctrl+Z)",children:"↶"}),e.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:ge.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:ge.format,title:"Format (Shift+Alt+F)",children:"⎘"}),e.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:ge.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${K?" nice-code-editor__toolbar-btn--active":""}`,onClick:ge.toggleWordWrap,title:"Toggle Word Wrap",children:"↩"}),e.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:ge.toggleMinimap,title:"Toggle Minimap",children:"▥"}),e.jsx("span",{className:"nice-code-editor__toolbar-sep"}),e.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:ge.foldAll,title:"Fold All",children:"⊟"}),e.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:ge.unfoldAll,title:"Unfold All",children:"⊞"})]}),e.jsx("div",{ref:I,className:"nice-code-editor",style:{flex:1,minHeight:0}}),O&&e.jsxs("div",{className:"nice-code-editor__statusbar",children:[e.jsxs("span",{children:["Ln ",p.lineNumber,", Col ",p.column]}),d.length>0&&e.jsxs("span",{children:["(",d.length," selected)"]}),e.jsx("span",{className:"nice-code-editor__statusbar-spacer"}),e.jsxs("span",{children:[re," lines · ",ye," chars"]}),e.jsx("span",{className:"nice-code-editor__statusbar-lang",children:g}),Y.length>0&&e.jsxs("span",{className:"nice-code-editor__statusbar-markers",children:["⚠ ",Y.length]})]})]})});function hn(t){const{original:i,modified:o,language:a="plaintext",theme:m="auto",height:g=400,width:w="100%",inline:_=!1,renderSideBySide:R=!0,originalEditable:z=!1,modifiedEditable:Y=!1,onOriginalChange:B,onModifiedChange:x,loading:F,className:P,"data-testid":G}=t,H=n.useRef(null),U=n.useRef(null),v=n.useRef(null),[k,O]=n.useState(!0),[j,A]=n.useState(null);return n.useEffect(()=>{if(!H.current)return;let E=!0;return pn().then(b=>{if(!E||!H.current)return;v.current=b;const h=b.editor.createModel(i,a),M=b.editor.createModel(o,a),I=b.editor.createDiffEditor(H.current,{automaticLayout:!0,theme:Fe(m),renderSideBySide:!_&&R,originalEditable:z,readOnly:!Y});I.setModel({original:h,modified:M}),U.current=I,O(!1),z&&h.onDidChangeContent(()=>{B?.(h.getValue())}),Y&&M.onDidChangeContent(()=>{x?.(M.getValue())})}).catch(b=>{E&&(A(b.message??"Failed to load diff editor"),O(!1))}),()=>{E=!1,U.current?.dispose()}},[]),n.useEffect(()=>{const E=U.current;if(!E)return;const b=E.getModel();b&&(b.original.getValue()!==i&&b.original.setValue(i),b.modified.getValue()!==o&&b.modified.setValue(o))},[i,o]),n.useEffect(()=>{const E=v.current;if(!E||(E.editor.setTheme(Fe(m)),m!=="auto"||typeof document>"u"))return;const b=()=>{v.current?.editor.setTheme(Fe("auto"))},h=new MutationObserver(b);h.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme","class"]});const M=window.matchMedia?.("(prefers-color-scheme: dark)");return M?.addEventListener?.("change",b),()=>{h.disconnect(),M?.removeEventListener?.("change",b)}},[m,k]),j?e.jsx("div",{className:`nice-code-diff-editor nice-code-diff-editor--error ${P??""}`,style:{height:g,width:w},"data-testid":G,children:e.jsx("div",{className:"nice-code-editor__error",children:e.jsxs("span",{children:["⚠️ ",j]})})}):e.jsxs("div",{className:`nice-code-diff-editor ${P??""}`,style:{height:g,width:w,position:"relative"},"data-testid":G,children:[e.jsx("div",{ref:H,style:{position:"absolute",inset:0}}),k&&e.jsx("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",background:"var(--nice-bg-primary, #fff)",zIndex:2},children:F??e.jsx("div",{className:"nice-code-editor__loader",children:"Loading diff editor..."})})]})}const vi="1.29.0",Tt=`https://cdn.jsdelivr.net/npm/prismjs@${vi}`;let lt=null;const gt={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 rt(t){return new Promise((i,o)=>{if(document.querySelector(`script[data-prism-src="${t}"]`)){i();return}const a=document.createElement("script");a.src=t,a.async=!0,a.dataset.prismSrc=t,a.onload=()=>i(),a.onerror=()=>o(new Error(`Failed to load ${t}`)),document.head.appendChild(a)})}function ki(t){if(typeof window>"u")return Promise.resolve(null);const i=window,o=gt[t]??"plain",a=async()=>{if(o!=="plain"&&!i.Prism?.languages?.[o])try{await rt(`${Tt}/components/prism-${o}.min.js`)}catch{}};return i.Prism?a().then(()=>i.Prism):(lt||(lt=(async()=>(window.Prism={manual:!0},await rt(`${Tt}/prism.min.js`),window.Prism))()),lt.then(async()=>(await a(),window.Prism)))}function dt(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function gn(t){const{value:i,onChange:o,language:a="plaintext",height:m=300,width:g="100%",readOnly:w=!1,tabSize:_=2,lineNumbers:R=!0,placeholder:z,theme:Y="auto",className:B,"data-testid":x}=t,F=n.useRef(null),P=n.useRef(null),[G,H]=n.useState(()=>dt(i)),[U,v]=n.useState("light");n.useEffect(()=>{const b=()=>{if(Y!=="auto")return Y;if(typeof document>"u")return"light";const S=document.documentElement.dataset.theme;return S==="dark"?"dark":S==="light"?"light":window.matchMedia?.("(prefers-color-scheme: dark)").matches?"dark":"light"};if(v(b()),Y!=="auto"||typeof document>"u")return;const h=()=>v(b()),M=new MutationObserver(h);M.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme","class"]});const I=window.matchMedia?.("(prefers-color-scheme: dark)");return I?.addEventListener?.("change",h),()=>{M.disconnect(),I?.removeEventListener?.("change",h)}},[Y]),n.useEffect(()=>{let b=!0;return ki(a).then(h=>{if(!b)return;const M=gt[a]??"plain";if(h?.languages?.[M])try{const I=h.highlight(i,h.languages[M],M);H(I);return}catch{}H(dt(i))}).catch(()=>{b&&H(dt(i))}),()=>{b=!1}},[i,a]);const k=n.useCallback(()=>{!P.current||!F.current||(P.current.scrollTop=F.current.scrollTop,P.current.scrollLeft=F.current.scrollLeft)},[]),O=n.useCallback(b=>{if(b.key==="Tab"){b.preventDefault();const h=b.currentTarget,M=h.selectionStart,I=h.selectionEnd,S=" ".repeat(_);if(b.shiftKey){const L=i.substring(0,M).lastIndexOf(`
13
+ `)+1;if((i.substring(L,M).match(/^(\s*)/)?.[1]??"").length>=_){const u=i.substring(0,L)+i.substring(L+_);o?.(u),setTimeout(()=>{h.selectionStart=h.selectionEnd=M-_},0)}}else{const y=i.substring(0,M)+S+i.substring(I);o?.(y),setTimeout(()=>{h.selectionStart=h.selectionEnd=M+_},0)}}},[i,o,_]),A=i.split(`
14
+ `).length,E=gt[a]??"plain";return e.jsxs("div",{className:`nice-simple-code-editor nice-simple-code-editor--${U} ${B??""}`,style:{height:m,width:g},"data-testid":x,"data-language":a,"data-theme":U,children:[R&&e.jsx("div",{className:"nice-simple-code-editor__line-numbers",children:Array.from({length:A},(b,h)=>e.jsx("div",{className:"nice-simple-code-editor__line-number",children:h+1},h))}),e.jsxs("div",{className:"nice-simple-code-editor__editor-area",children:[e.jsx("pre",{ref:P,"aria-hidden":"true",className:`nice-simple-code-editor__highlight language-${E}`,children:e.jsx("code",{className:`language-${E}`,dangerouslySetInnerHTML:{__html:G+(i.endsWith(`
15
+ `)?`
16
+ `:"")}})}),e.jsx("textarea",{ref:F,className:"nice-simple-code-editor__textarea",value:i,onChange:b=>o?.(b.target.value),onKeyDown:O,onScroll:k,readOnly:w,placeholder:z,spellCheck:!1,autoCapitalize:"off",autoCorrect:"off"})]})]})}const Rt="nice-code-editor-styles";if(typeof document<"u"&&!document.getElementById(Rt)){const t=document.createElement("style");t.id=Rt,t.textContent=`
17
+ .nice-code-editor,
18
+ .nice-code-diff-editor {
19
+ border: 1px solid var(--nice-border, #e0e0e0);
20
+ border-radius: var(--nice-radius-sm, 4px);
21
+ overflow: hidden;
22
+ }
23
+
24
+ .nice-code-editor--loading,
25
+ .nice-code-editor--error,
26
+ .nice-code-diff-editor--loading {
27
+ display: flex;
28
+ align-items: center;
29
+ justify-content: center;
30
+ background: var(--nice-bg-muted, #f5f5f5);
31
+ }
32
+
33
+ .nice-code-editor__loader {
34
+ color: var(--nice-text-secondary, #666);
35
+ font-size: 14px;
36
+ }
37
+
38
+ .nice-code-editor__error {
39
+ display: flex;
40
+ flex-direction: column;
41
+ width: 100%;
42
+ height: 100%;
43
+ padding: var(--nice-space-2, 8px);
44
+ gap: var(--nice-space-2, 8px);
45
+ }
46
+
47
+ .nice-code-editor__error span {
48
+ color: var(--nice-error, #d32f2f);
49
+ }
50
+
51
+ /* Simple code editor */
52
+ .nice-simple-code-editor {
53
+ display: flex;
54
+ border: 1px solid var(--border-color, var(--nice-border, #e0e0e0));
55
+ border-radius: var(--nice-radius-sm, 4px);
56
+ overflow: hidden;
57
+ font-family: 'Fira Code', 'Consolas', 'Monaco', monospace;
58
+ font-size: 14px;
59
+ line-height: 1.5;
60
+ background: var(--bg-primary, var(--nice-bg-surface, #fff));
61
+ color: var(--text-primary, var(--nice-text-primary, #333));
62
+ }
63
+ .nice-simple-code-editor--dark {
64
+ background: var(--nice-bg, #1e1e1e);
65
+ color: var(--nice-text, #d4d4d4);
66
+ }
67
+
68
+ .nice-simple-code-editor__line-numbers {
69
+ padding: var(--nice-space-2, 8px) 0;
70
+ background: var(--bg-secondary, var(--nice-bg-muted, #f5f5f5));
71
+ border-right: 1px solid var(--border-color, var(--nice-border, #e0e0e0));
72
+ user-select: none;
73
+ text-align: right;
74
+ color: var(--text-secondary, var(--nice-text-secondary, #999));
75
+ overflow: hidden;
76
+ }
77
+ .nice-simple-code-editor--dark .nice-simple-code-editor__line-numbers {
78
+ background: var(--nice-bg-secondary, #252526);
79
+ border-right-color: var(--nice-border, #3c3c3c);
80
+ color: var(--nice-text-muted, #858585);
81
+ }
82
+
83
+ .nice-simple-code-editor__line-number {
84
+ padding: 0 var(--nice-space-3, 12px);
85
+ min-width: 40px;
86
+ }
87
+
88
+ .nice-simple-code-editor__editor-area {
89
+ position: relative;
90
+ flex: 1;
91
+ overflow: hidden;
92
+ }
93
+
94
+ .nice-simple-code-editor__highlight,
95
+ .nice-simple-code-editor__textarea {
96
+ position: absolute;
97
+ inset: 0;
98
+ margin: 0;
99
+ padding: var(--nice-space-2, 8px) var(--nice-space-3, 12px);
100
+ border: 0;
101
+ font: inherit;
102
+ line-height: inherit;
103
+ white-space: pre;
104
+ overflow: auto;
105
+ tab-size: 2;
106
+ }
107
+
108
+ .nice-simple-code-editor__highlight {
109
+ pointer-events: none;
110
+ background: transparent;
111
+ color: inherit;
112
+ }
113
+ .nice-simple-code-editor__highlight code {
114
+ font: inherit;
115
+ background: transparent;
116
+ }
117
+
118
+ .nice-simple-code-editor__textarea {
119
+ background: transparent;
120
+ color: transparent;
121
+ caret-color: var(--text-primary, var(--nice-text-primary, #333));
122
+ resize: none;
123
+ outline: none;
124
+ -webkit-text-fill-color: transparent;
125
+ }
126
+ .nice-simple-code-editor--dark .nice-simple-code-editor__textarea {
127
+ caret-color: var(--nice-text, #d4d4d4);
128
+ }
129
+
130
+ .nice-simple-code-editor__textarea::placeholder {
131
+ color: var(--text-secondary, var(--nice-text-secondary, #999));
132
+ -webkit-text-fill-color: var(--text-secondary, var(--nice-text-secondary, #999));
133
+ }
134
+ .nice-simple-code-editor--dark .nice-simple-code-editor__textarea::placeholder {
135
+ color: var(--nice-text-muted, #858585);
136
+ -webkit-text-fill-color: var(--nice-text-muted, #858585);
137
+ }
138
+
139
+ /* Prism token colors — light */
140
+ .nice-simple-code-editor .token.comment,
141
+ .nice-simple-code-editor .token.prolog,
142
+ .nice-simple-code-editor .token.doctype,
143
+ .nice-simple-code-editor .token.cdata { color: #6a737d; font-style: italic; }
144
+ .nice-simple-code-editor .token.punctuation { color: #586069; }
145
+ .nice-simple-code-editor .token.property,
146
+ .nice-simple-code-editor .token.tag,
147
+ .nice-simple-code-editor .token.boolean,
148
+ .nice-simple-code-editor .token.number,
149
+ .nice-simple-code-editor .token.constant,
150
+ .nice-simple-code-editor .token.symbol,
151
+ .nice-simple-code-editor .token.deleted { color: #005cc5; }
152
+ .nice-simple-code-editor .token.selector,
153
+ .nice-simple-code-editor .token.attr-name,
154
+ .nice-simple-code-editor .token.string,
155
+ .nice-simple-code-editor .token.char,
156
+ .nice-simple-code-editor .token.builtin,
157
+ .nice-simple-code-editor .token.inserted { color: #032f62; }
158
+ .nice-simple-code-editor .token.operator,
159
+ .nice-simple-code-editor .token.entity,
160
+ .nice-simple-code-editor .token.url,
161
+ .nice-simple-code-editor .token.variable { color: var(--nice-danger, #d73a49); }
162
+ .nice-simple-code-editor .token.atrule,
163
+ .nice-simple-code-editor .token.attr-value,
164
+ .nice-simple-code-editor .token.keyword { color: var(--nice-danger, #d73a49); font-weight: 600; }
165
+ .nice-simple-code-editor .token.function,
166
+ .nice-simple-code-editor .token.class-name { color: #6f42c1; }
167
+ .nice-simple-code-editor .token.regex,
168
+ .nice-simple-code-editor .token.important { color: #e36209; }
169
+
170
+ /* Prism token colors — dark */
171
+ .nice-simple-code-editor--dark .token.comment,
172
+ .nice-simple-code-editor--dark .token.prolog,
173
+ .nice-simple-code-editor--dark .token.doctype,
174
+ .nice-simple-code-editor--dark .token.cdata { color: var(--nice-success, #6a9955); font-style: italic; }
175
+ .nice-simple-code-editor--dark .token.punctuation { color: var(--nice-text, #d4d4d4); }
176
+ .nice-simple-code-editor--dark .token.property,
177
+ .nice-simple-code-editor--dark .token.tag,
178
+ .nice-simple-code-editor--dark .token.boolean,
179
+ .nice-simple-code-editor--dark .token.number,
180
+ .nice-simple-code-editor--dark .token.constant,
181
+ .nice-simple-code-editor--dark .token.symbol,
182
+ .nice-simple-code-editor--dark .token.deleted { color: var(--nice-success-light, #b5cea8); }
183
+ .nice-simple-code-editor--dark .token.selector,
184
+ .nice-simple-code-editor--dark .token.attr-name,
185
+ .nice-simple-code-editor--dark .token.string,
186
+ .nice-simple-code-editor--dark .token.char,
187
+ .nice-simple-code-editor--dark .token.builtin,
188
+ .nice-simple-code-editor--dark .token.inserted { color: var(--nice-warning, #ce9178); }
189
+ .nice-simple-code-editor--dark .token.operator,
190
+ .nice-simple-code-editor--dark .token.entity,
191
+ .nice-simple-code-editor--dark .token.url,
192
+ .nice-simple-code-editor--dark .token.variable { color: var(--nice-primary, #569cd6); }
193
+ .nice-simple-code-editor--dark .token.atrule,
194
+ .nice-simple-code-editor--dark .token.attr-value,
195
+ .nice-simple-code-editor--dark .token.keyword { color: #c586c0; font-weight: 600; }
196
+ .nice-simple-code-editor--dark .token.function,
197
+ .nice-simple-code-editor--dark .token.class-name { color: #dcdcaa; }
198
+ .nice-simple-code-editor--dark .token.regex,
199
+ .nice-simple-code-editor--dark .token.important { color: #d7ba7d; }
200
+
201
+ /* Toolbar */
202
+ .nice-code-editor-wrap {
203
+ border: 1px solid var(--nice-border, #e0e0e0);
204
+ border-radius: var(--nice-radius-sm, 4px);
205
+ overflow: hidden;
206
+ }
207
+ .nice-code-editor-wrap .nice-code-editor {
208
+ border: none;
209
+ border-radius: 0;
210
+ }
211
+ .nice-code-editor__toolbar {
212
+ display: flex;
213
+ align-items: center;
214
+ gap: var(--nice-space-0-5, 2px);
215
+ padding: var(--nice-space-0-75, 3px) var(--nice-space-1-5, 6px);
216
+ background: var(--nice-bg-muted, #f5f5f5);
217
+ border-bottom: 1px solid var(--nice-border, #e0e0e0);
218
+ }
219
+ .nice-code-editor__toolbar-btn {
220
+ display: inline-flex;
221
+ align-items: center;
222
+ justify-content: center;
223
+ width: 26px;
224
+ height: 26px;
225
+ border: none;
226
+ border-radius: var(--nice-radius-sm, 3px);
227
+ background: transparent;
228
+ color: var(--nice-text-secondary, #666);
229
+ cursor: pointer;
230
+ font-size: 14px;
231
+ transition: background 0.15s, color 0.15s;
232
+ }
233
+ .nice-code-editor__toolbar-btn:hover {
234
+ background: var(--nice-hover, #e0e0e0);
235
+ color: var(--nice-text-primary, #333);
236
+ }
237
+ .nice-code-editor__toolbar-btn--active {
238
+ background: var(--nice-accent, #1976d2);
239
+ color: var(--nice-bg, #FFF);
240
+ }
241
+ .nice-code-editor__toolbar-sep {
242
+ width: 1px;
243
+ height: 18px;
244
+ background: var(--nice-border, #e0e0e0);
245
+ margin: 0 var(--nice-space-1, 4px);
246
+ }
247
+
248
+ /* Status bar */
249
+ .nice-code-editor__statusbar {
250
+ display: flex;
251
+ align-items: center;
252
+ gap: var(--nice-space-3, 12px);
253
+ padding: var(--nice-space-0-5, 2px) var(--nice-space-2-5, 10px);
254
+ background: var(--nice-bg-muted, #f5f5f5);
255
+ border-top: 1px solid var(--nice-border, #e0e0e0);
256
+ font-size: 12px;
257
+ color: var(--nice-text-secondary, #666);
258
+ user-select: none;
259
+ }
260
+ .nice-code-editor__statusbar-spacer { flex: 1; }
261
+ .nice-code-editor__statusbar-lang {
262
+ text-transform: uppercase;
263
+ font-weight: 600;
264
+ font-size: 11px;
265
+ }
266
+ .nice-code-editor__statusbar-markers {
267
+ color: var(--nice-warning, #f39c12);
268
+ font-weight: 600;
269
+ }
270
+ `,document.head.appendChild(t)}const wi=Object.freeze(Object.defineProperty({__proto__:null,NiceCodeDiffEditor:hn,NiceCodeEditor:Je,NiceSimpleCodeEditor:gn},Symbol.toStringTag,{value:"Module"})),Ni=n.forwardRef(function(i,o){const{enableAI:a=!0,aiModel:m,enableInlineCompletion:g=!0,completionDelay:w=500,enableExplain:_=!0,enableRefactor:R=!0,enableGenerate:z=!0,systemPrompt:Y,onExplain:B,onRefactor:x,showAIToolbar:F=!0,aiShortcutKey:P="Ctrl",language:G="plaintext",value:H,onChange:U,...v}=i,k=n.useRef(null),[O,j]=n.useState(null),[A,E]=n.useState(!1),[b,h]=n.useState(""),[M,I]=n.useState(!1),[S,y]=n.useState(""),[c,L]=n.useState(""),[C,u]=n.useState(""),l=n.useRef(),{t:s}=q.Zt(),p=q.se(),{complete:f,explain:d,refactor:$,generateFromComment:K,isLoading:ee}=q.ql({language:G,model:m}),D=a&&p.isConfigured,ge=n.useCallback(async()=>{if(!D||!g||!k.current||!k.current.getEditor())return;const ce=k.current.getCursorPosition(),oe=k.current.getValue().split(`
271
+ `),J=oe.slice(0,ce.lineNumber-1),W=oe[ce.lineNumber-1]||"",N=[...J,W.slice(0,ce.column-1)].join(`
272
+ `),Z=[W.slice(ce.column-1),...oe.slice(ce.lineNumber)].join(`
273
+ `);try{const fe=await f(N,Z);fe&&j({lineNumber:ce.lineNumber,column:ce.column,text:fe})}catch{}},[D,g,f]),re=n.useCallback(async()=>{if(!D||!_||!k.current)return"";const te=k.current.getSelection();if(!te)return"";u(te),E(!0),h("");try{const ce=await d(te);return h(ce),B?.(te,ce),ce}catch{return h(s("codeEditorAI.explanationFailed","Failed to explain code")),""}},[D,_,d,B,s]),ye=n.useCallback(async te=>{if(!D||!R||!k.current)return"";const ce=k.current.getSelection();if(!ce)return"";try{const de=await $(ce,te);return L(de),x?.(ce,de),de}catch{return""}},[D,R,$,x]),ne=n.useCallback(async()=>{if(!D||!z||!k.current)return;const te=k.current.getCursorPosition(),de=k.current.getValue().split(`
274
+ `);let oe="";for(let J=te.lineNumber-1;J>=0&&J>=te.lineNumber-3;J--){const W=de[J]?.trim()||"";if(W.startsWith("//")||W.startsWith("#")||W.startsWith("/*")||W.startsWith("*")){oe=W.replace(/^\/\/\s*|^#\s*|^\/\*\s*|\*\/\s*$|^\*\s*/g,"").trim();break}}if(oe)try{const J=await K(oe);J&&k.current&&k.current.insertText(`
275
+ `+J)}catch{}},[D,z,K]),se=n.useCallback(()=>{!O||!k.current||(k.current.insertText(O.text),j(null))},[O]),le=n.useCallback(()=>{j(null)},[]),ue=n.useCallback(te=>{i.onCursorPositionChange?.(te),!(!D||!g)&&(l.current&&clearTimeout(l.current),j(null),l.current=setTimeout(()=>{ge()},w))},[i.onCursorPositionChange,D,g,w,ge]);n.useEffect(()=>{if(!k.current?.getEditor()||!D)return;const ce=de=>{if(P==="Ctrl"&&de.ctrlKey||P==="Alt"&&de.altKey||P==="Meta"&&de.metaKey){if(de.key===" "&&g&&(de.preventDefault(),ge()),de.key==="e"&&_&&(de.preventDefault(),re()),de.key==="r"&&R){de.preventDefault();const J=k.current?.getSelection();J&&(u(J),I(!0))}de.key==="g"&&z&&(de.preventDefault(),ne())}de.key==="Tab"&&O&&(de.preventDefault(),se()),de.key==="Escape"&&O&&le()};return window.addEventListener("keydown",ce),()=>window.removeEventListener("keydown",ce)},[D,P,g,_,R,z,ge,re,ne,O,se,le]),n.useEffect(()=>()=>{l.current&&clearTimeout(l.current)},[]);const be=n.useCallback(()=>{if(!c||!k.current)return;const te=k.current.getEditor();if(te?.executeEdits&&te?.getSelection){const ce=te.getSelection();te.executeEdits("ai-refactor",[{range:ce,text:c}])}I(!1),L(""),y("")},[c]);return n.useImperativeHandle(o,()=>({...k.current,getEditor:()=>k.current?.getEditor(),getMonaco:()=>k.current?.getMonaco(),focus:()=>k.current?.focus(),getValue:()=>k.current?.getValue()||"",setValue:te=>k.current?.setValue(te),getSelection:()=>k.current?.getSelection()||"",insertText:te=>k.current?.insertText(te),formatDocument:()=>k.current?.formatDocument(),goToLine:(te,ce)=>k.current?.goToLine(te,ce),findReplace:()=>k.current?.findReplace(),undo:()=>k.current?.undo(),redo:()=>k.current?.redo(),getCursorPosition:()=>k.current?.getCursorPosition()||{lineNumber:1,column:1},setMarkers:te=>k.current?.setMarkers(te),triggerCompletion:ge,explainSelection:re,refactorSelection:ye,generateFromComment:ne,acceptCompletion:se,dismissCompletion:le})),e.jsxs("div",{className:"nice-code-editor-ai","data-testid":i["data-testid"],children:[F&&D&&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"}),ee&&e.jsx("span",{className:"nice-code-editor-ai__loading",children:s("codeEditorAI.loading","Thinking...")})]}),e.jsxs("div",{className:"nice-code-editor-ai__toolbar-right",children:[g&&e.jsxs("button",{type:"button",className:"nice-code-editor-ai__toolbar-btn",onClick:()=>ge(),disabled:ee,title:`${s("codeEditorAI.complete","Complete")} (${P}+Space)`,children:["💡 ",s("codeEditorAI.complete","Complete")]}),_&&e.jsxs("button",{type:"button",className:"nice-code-editor-ai__toolbar-btn",onClick:()=>re(),disabled:ee,title:`${s("codeEditorAI.explain","Explain")} (${P}+E)`,children:["📖 ",s("codeEditorAI.explain","Explain")]}),R&&e.jsxs("button",{type:"button",className:"nice-code-editor-ai__toolbar-btn",onClick:()=>{const te=k.current?.getSelection();te&&(u(te),I(!0))},disabled:ee,title:`${s("codeEditorAI.refactor","Refactor")} (${P}+R)`,children:["🔧 ",s("codeEditorAI.refactor","Refactor")]}),z&&e.jsxs("button",{type:"button",className:"nice-code-editor-ai__toolbar-btn",onClick:()=>ne(),disabled:ee,title:`${s("codeEditorAI.generate","Generate")} (${P}+G)`,children:["⚡ ",s("codeEditorAI.generate","Generate")]})]})]}),e.jsxs("div",{className:"nice-code-editor-ai__editor-wrapper",children:[e.jsx(Je,{ref:k,value:H,onChange:U,language:G,onCursorPositionChange:ue,...v}),O&&e.jsxs("div",{className:"nice-code-editor-ai__ghost-text",style:{top:`calc(${(O.lineNumber-1)*19}px + 4px)`,left:`calc(${(O.column-1)*7.8}px + 60px)`},children:[e.jsx("span",{className:"nice-code-editor-ai__ghost-text-content",children:O.text}),e.jsxs("span",{className:"nice-code-editor-ai__ghost-text-hint",children:["Tab ",s("codeEditorAI.toAccept","to accept")]})]})]}),A&&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:["📖 ",s("codeEditorAI.explanation","Explanation")]}),e.jsx("button",{type:"button",className:"nice-code-editor-ai__panel-close",onClick:()=>E(!1),children:"✕"})]}),e.jsx("div",{className:"nice-code-editor-ai__panel-body",children:ee?e.jsx("div",{className:"nice-code-editor-ai__panel-loading",children:s("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:C}),e.jsx("div",{className:"nice-code-editor-ai__explanation-text",children:b||s("codeEditorAI.noExplanation","Select code and click Explain")})]})})]}),M&&e.jsxs("div",{className:"nice-code-editor-ai__panel nice-code-editor-ai__panel--refactor",children:[e.jsxs("div",{className:"nice-code-editor-ai__panel-header",children:[e.jsxs("h4",{children:["🔧 ",s("codeEditorAI.refactorCode","Refactor Code")]}),e.jsx("button",{type:"button",className:"nice-code-editor-ai__panel-close",onClick:()=>{I(!1),L(""),y("")},children:"✕"})]}),e.jsxs("div",{className:"nice-code-editor-ai__panel-body",children:[e.jsx("pre",{className:"nice-code-editor-ai__code-preview",children:C}),e.jsxs("div",{className:"nice-code-editor-ai__refactor-input",children:[e.jsx("input",{type:"text",placeholder:s("codeEditorAI.refactorInstruction",'Describe how to refactor (e.g., "extract function", "add error handling")'),value:S,onChange:te=>y(te.target.value),onKeyDown:te=>{te.key==="Enter"&&S&&ye(S)}}),e.jsx("button",{type:"button",className:"nice-code-editor-ai__refactor-btn",onClick:()=>ye(S),disabled:ee||!S,children:ee?s("codeEditorAI.refactoring","Refactoring..."):s("codeEditorAI.refactor","Refactor")})]}),c&&e.jsxs("div",{className:"nice-code-editor-ai__refactor-result",children:[e.jsx("h5",{children:s("codeEditorAI.refactoredCode","Refactored Code")}),e.jsx("pre",{className:"nice-code-editor-ai__code-preview nice-code-editor-ai__code-preview--result",children:c}),e.jsxs("div",{className:"nice-code-editor-ai__refactor-actions",children:[e.jsxs("button",{type:"button",className:"nice-code-editor-ai__refactor-apply",onClick:be,children:["✓ ",s("codeEditorAI.apply","Apply")]}),e.jsxs("button",{type:"button",className:"nice-code-editor-ai__refactor-discard",onClick:()=>{L(""),y("")},children:["✕ ",s("codeEditorAI.discard","Discard")]})]})]})]})]})]})});function Ci(t){const i=t instanceof Date?t:new Date(t),o=(a,m=2)=>String(a).padStart(m,"0");return`${o(i.getHours())}:${o(i.getMinutes())}:${o(i.getSeconds())}.${o(i.getMilliseconds(),3)}`}function Si(t){if(typeof t=="string")return t;try{return JSON.stringify(t,null,2)}catch{return String(t)}}const fn=n.forwardRef(function(i,o){const{entries:a,maxHeight:m=240,autoScroll:g=!0,showTimestamps:w=!0,levelFilter:_,onClear:R,title:z,emptyText:Y="No output",clearLabel:B="Clear",fontFamily:x,className:F,style:P,id:G,"data-testid":H}=i,U=n.useRef(null),v=n.useMemo(()=>{if(!_||_.length===0)return a;const j=new Set(_);return a.filter(A=>j.has(A.level??"log"))},[a,_]);n.useEffect(()=>{g&&U.current&&(U.current.scrollTop=U.current.scrollHeight)},[v.length,g]);const k=!!z||!!R,O="nice-log-console"+(F?` ${F}`:"");return e.jsxs("div",{ref:o,id:G,className:O,style:{...x?{fontFamily:x}:null,...P},"data-testid":H,children:[k&&e.jsxs("div",{className:"nice-log-console__header",children:[e.jsx("span",{className:"nice-log-console__title",children:z}),R&&e.jsx("button",{type:"button",className:"nice-log-console__clear",onClick:R,"aria-label":B,children:B})]}),e.jsx("div",{ref:U,className:"nice-log-console__body",style:{maxHeight:typeof m=="number"?`${m}px`:m},role:"log","aria-live":"polite","aria-relevant":"additions",children:v.length===0?e.jsx("div",{className:"nice-log-console__empty",children:Y}):v.map((j,A)=>{const E=j.level??"log";return e.jsxs("div",{className:`nice-log-console__entry nice-log-console__entry--${E}`,children:[w&&j.timestamp!=null&&e.jsx("span",{className:"nice-log-console__time",children:Ci(j.timestamp)}),e.jsx("span",{className:"nice-log-console__level",children:E}),j.source&&e.jsx("span",{className:"nice-log-console__source",children:j.source}),e.jsx("span",{className:"nice-log-console__message",children:j.message}),j.data!==void 0&&e.jsx("pre",{className:"nice-log-console__data",children:Si(j.data)})]},A)})})]})}),It="nice-log-console-styles";if(typeof document<"u"&&!document.getElementById(It)){const t=document.createElement("style");t.id=It,t.textContent=`
276
+ .nice-log-console {
277
+ display: flex;
278
+ flex-direction: column;
279
+ border: 1px solid var(--nice-border, #e0e0e0);
280
+ border-radius: var(--nice-radius-sm, 4px);
281
+ background: var(--nice-surface, #fff);
282
+ color: var(--nice-text-primary, #1f2937);
283
+ overflow: hidden;
284
+ font-family: 'Fira Code', 'Consolas', 'Monaco', monospace;
285
+ font-size: 12px;
286
+ line-height: 1.55;
287
+ }
288
+ .nice-log-console__header {
289
+ display: flex;
290
+ align-items: center;
291
+ justify-content: space-between;
292
+ gap: var(--nice-space-2, 8px);
293
+ padding: var(--nice-space-1, 4px) var(--nice-space-2, 8px);
294
+ border-bottom: 1px solid var(--nice-border, #e0e0e0);
295
+ background: var(--nice-bg-secondary, #f5f5f5);
296
+ }
297
+ .nice-log-console__title {
298
+ font-weight: 600;
299
+ font-size: 12px;
300
+ }
301
+ .nice-log-console__clear {
302
+ border: 1px solid var(--nice-border, #e0e0e0);
303
+ background: var(--nice-surface, #fff);
304
+ color: var(--nice-text-secondary, #6b7280);
305
+ border-radius: var(--nice-radius-sm, 4px);
306
+ padding: 2px 8px;
307
+ font: inherit;
308
+ font-size: 11px;
309
+ cursor: pointer;
310
+ }
311
+ .nice-log-console__clear:hover {
312
+ color: var(--nice-text-primary, #1f2937);
313
+ border-color: var(--nice-text-secondary, #9ca3af);
314
+ }
315
+ .nice-log-console__body {
316
+ flex: 1;
317
+ overflow: auto;
318
+ padding: var(--nice-space-2, 8px);
319
+ }
320
+ .nice-log-console__empty {
321
+ color: var(--nice-text-muted, #9ca3af);
322
+ font-style: italic;
323
+ padding: var(--nice-space-2, 8px) 0;
324
+ }
325
+ .nice-log-console__entry {
326
+ display: flex;
327
+ flex-wrap: wrap;
328
+ align-items: baseline;
329
+ gap: var(--nice-space-2, 8px);
330
+ padding: 1px 0;
331
+ white-space: pre-wrap;
332
+ word-break: break-word;
333
+ }
334
+ .nice-log-console__time {
335
+ color: var(--nice-text-muted, #9ca3af);
336
+ flex: 0 0 auto;
337
+ }
338
+ .nice-log-console__level {
339
+ flex: 0 0 auto;
340
+ text-transform: uppercase;
341
+ font-size: 10px;
342
+ font-weight: 700;
343
+ letter-spacing: 0.04em;
344
+ opacity: 0.8;
345
+ min-width: 38px;
346
+ }
347
+ .nice-log-console__source {
348
+ flex: 0 0 auto;
349
+ color: var(--nice-primary, #2563eb);
350
+ }
351
+ .nice-log-console__message {
352
+ flex: 1 1 auto;
353
+ }
354
+ .nice-log-console__data {
355
+ flex: 1 0 100%;
356
+ margin: 2px 0 4px;
357
+ padding: var(--nice-space-1, 4px) var(--nice-space-2, 8px);
358
+ background: var(--nice-bg-secondary, #f5f5f5);
359
+ border-radius: var(--nice-radius-sm, 4px);
360
+ overflow: auto;
361
+ font: inherit;
362
+ }
363
+ .nice-log-console__entry--info .nice-log-console__level { color: var(--nice-primary, #2563eb); }
364
+ .nice-log-console__entry--warn { color: var(--nice-warning-text, #92400e); }
365
+ .nice-log-console__entry--warn .nice-log-console__level { color: var(--nice-warning, #d97706); }
366
+ .nice-log-console__entry--error { color: var(--nice-danger, #dc2626); }
367
+ .nice-log-console__entry--error .nice-log-console__level { color: var(--nice-danger, #dc2626); }
368
+ .nice-log-console__entry--debug { color: var(--nice-text-muted, #9ca3af); }
369
+ .nice-log-console__entry--trace { color: var(--nice-text-disabled, #b8bfc9); }
370
+ .nice-log-console__entry--trace .nice-log-console__level { color: var(--nice-text-disabled, #b8bfc9); }
371
+ `,document.head.appendChild(t)}const Mi=[{target:".nice-script-runner",titleKey:"tutorial.scriptRunner.intro.title",title:"Script runner",contentKey:"tutorial.scriptRunner.intro.content",content:"Write a script and sample input, click Run, then inspect the result and captured logs below.",placement:"auto"}];function At(t){if(t===void 0)return"";if(typeof t=="string")return t;try{return JSON.stringify(t,null,2)}catch{return String(t)}}function Dt(t){const i=t.trim();if(i==="")return{value:void 0,error:null};try{return{value:JSON.parse(i),error:null}}catch(o){return{value:t,error:o instanceof Error?o.message:"Invalid JSON"}}}function $i(t){if(typeof t=="string")return t;try{return JSON.stringify(t,null,2)}catch{return String(t)}}const Ei=n.forwardRef(function(i,o){const{value:a,onChange:m,language:g="javascript",onRun:w,input:_,onInputChange:R,showInputPanel:z,extraLibs:Y,height:B=260,running:x,autoRun:F=!1,autoRunDelay:P=600,layout:G="vertical",runLabel:H="Run",theme:U="auto",tutorial:v,className:k,style:O,id:j,"data-testid":A}=i,E=z??_!==void 0,[b,h]=n.useState(()=>At(_)),[M,I]=n.useState(null),[S,y]=n.useState(!1),[c,L]=n.useState(null),C=x??S,u=U==="light"?"vs":U==="dark"?"vs-dark":U;n.useEffect(()=>{h(At(_))},[_]);const l=n.useCallback(async()=>{const $=Dt(b),K=typeof performance<"u"?performance.now():Date.now();x===void 0&&y(!0);try{const ee=await w(a,$.value),D=ee.durationMs??Math.round((typeof performance<"u"?performance.now():Date.now())-K);L({...ee,durationMs:D})}catch(ee){L({ok:!1,error:ee instanceof Error?ee.message:String(ee),durationMs:Math.round((typeof performance<"u"?performance.now():Date.now())-K)})}finally{x===void 0&&y(!1)}},[b,w,a,x]),s=n.useRef(l);s.current=l,n.useEffect(()=>{if(!F)return;const $=setTimeout(()=>{s.current()},P);return()=>clearTimeout($)},[F,P,a,b]);const p=n.useCallback($=>{h($);const K=Dt($);I(K.error),R?.(K.value)},[R]),f=typeof B=="number"?`${B}px`:B,d=`nice-script-runner nice-script-runner--${G}`+(k?` ${k}`:"");return e.jsxs("div",{ref:o,id:j,className:d,style:O,"data-testid":A,children:[e.jsxs("div",{className:"nice-script-runner__toolbar",children:[e.jsxs("button",{type:"button",className:"nice-script-runner__run",onClick:()=>void l(),disabled:C,children:[C?"…":"▶"," ",H]}),c?.durationMs!=null&&e.jsxs("span",{className:"nice-script-runner__status",children:[e.jsx("span",{className:"nice-script-runner__badge nice-script-runner__badge--"+(c.ok?"ok":"error"),children:c.ok?"OK":"Failed"}),e.jsxs("span",{className:"nice-script-runner__duration",children:[c.durationMs," ms"]})]}),v&&e.jsx("span",{style:{marginLeft:"auto"},children:e.jsx(q.wl,{steps:q.xl(v,Mi)})})]}),e.jsxs("div",{className:"nice-script-runner__panes",children:[e.jsxs("div",{className:"nice-script-runner__editors",children:[e.jsx(Je,{value:a,onChange:m,language:g,theme:u,height:f,extraLibs:Y,options:{minimap:!1}}),E&&e.jsxs("div",{className:"nice-script-runner__input",children:[e.jsxs("div",{className:"nice-script-runner__pane-label",children:["Input (JSON)",M&&e.jsxs("span",{className:"nice-script-runner__input-error",children:[" — ",M]})]}),e.jsx(Je,{value:b,onChange:p,language:"json",theme:u,height:120,options:{minimap:!1,lineNumbers:"off"}})]})]}),e.jsxs("div",{className:"nice-script-runner__output",children:[c?.error&&e.jsx("div",{className:"nice-script-runner__error",children:c.error}),c&&c.result!==void 0&&e.jsxs("div",{className:"nice-script-runner__result",children:[e.jsx("div",{className:"nice-script-runner__pane-label",children:"Result"}),e.jsx("pre",{className:"nice-script-runner__result-body",children:$i(c.result)})]}),e.jsx(fn,{title:"Logs",entries:c?.logs??[],maxHeight:160,emptyText:"Run the script to see logs"})]})]})]})}),Lt="nice-script-runner-styles";if(typeof document<"u"&&!document.getElementById(Lt)){const t=document.createElement("style");t.id=Lt,t.textContent=`
372
+ .nice-script-runner {
373
+ display: flex;
374
+ flex-direction: column;
375
+ gap: var(--nice-space-2, 8px);
376
+ border: 1px solid var(--nice-border, #e0e0e0);
377
+ border-radius: var(--nice-radius-md, 6px);
378
+ padding: var(--nice-space-2, 8px);
379
+ background: var(--nice-surface, #fff);
380
+ }
381
+ .nice-script-runner__toolbar {
382
+ display: flex;
383
+ align-items: center;
384
+ gap: var(--nice-space-2, 8px);
385
+ }
386
+ .nice-script-runner__run {
387
+ border: 0;
388
+ background: var(--nice-primary, #2563eb);
389
+ color: var(--nice-text-inverse, #fff);
390
+ border-radius: var(--nice-radius-sm, 4px);
391
+ padding: 6px 14px;
392
+ font: inherit;
393
+ font-weight: 600;
394
+ cursor: pointer;
395
+ }
396
+ .nice-script-runner__run:disabled {
397
+ opacity: 0.6;
398
+ cursor: default;
399
+ }
400
+ .nice-script-runner__status {
401
+ display: inline-flex;
402
+ align-items: center;
403
+ gap: var(--nice-space-2, 8px);
404
+ font-size: 12px;
405
+ }
406
+ .nice-script-runner__badge {
407
+ padding: 1px 8px;
408
+ border-radius: 999px;
409
+ font-size: 11px;
410
+ font-weight: 700;
411
+ }
412
+ .nice-script-runner__badge--ok {
413
+ background: var(--nice-success-bg, #dcfce7);
414
+ color: var(--nice-success-text, #166534);
415
+ }
416
+ .nice-script-runner__badge--error {
417
+ background: var(--nice-danger-bg, #fee2e2);
418
+ color: var(--nice-danger-text, #991b1b);
419
+ }
420
+ .nice-script-runner__duration {
421
+ color: var(--nice-text-muted, #9ca3af);
422
+ }
423
+ .nice-script-runner__panes {
424
+ display: grid;
425
+ gap: var(--nice-space-2, 8px);
426
+ }
427
+ .nice-script-runner--horizontal .nice-script-runner__panes {
428
+ grid-template-columns: 1fr 1fr;
429
+ }
430
+ .nice-script-runner__editors,
431
+ .nice-script-runner__output {
432
+ display: flex;
433
+ flex-direction: column;
434
+ gap: var(--nice-space-2, 8px);
435
+ min-width: 0;
436
+ }
437
+ .nice-script-runner__pane-label {
438
+ font-size: 11px;
439
+ font-weight: 600;
440
+ text-transform: uppercase;
441
+ letter-spacing: 0.04em;
442
+ color: var(--nice-text-secondary, #6b7280);
443
+ }
444
+ .nice-script-runner__input-error {
445
+ color: var(--nice-danger, #dc2626);
446
+ text-transform: none;
447
+ font-weight: 400;
448
+ }
449
+ .nice-script-runner__error {
450
+ padding: var(--nice-space-2, 8px);
451
+ border-radius: var(--nice-radius-sm, 4px);
452
+ background: var(--nice-danger-bg, #fee2e2);
453
+ color: var(--nice-danger-text, #991b1b);
454
+ font-family: 'Fira Code', 'Consolas', 'Monaco', monospace;
455
+ font-size: 12px;
456
+ white-space: pre-wrap;
457
+ }
458
+ .nice-script-runner__result-body {
459
+ margin: 4px 0 0;
460
+ padding: var(--nice-space-2, 8px);
461
+ border: 1px solid var(--nice-border, #e0e0e0);
462
+ border-radius: var(--nice-radius-sm, 4px);
463
+ background: var(--nice-bg-secondary, #f9fafb);
464
+ max-height: 200px;
465
+ overflow: auto;
466
+ font-family: 'Fira Code', 'Consolas', 'Monaco', monospace;
467
+ font-size: 12px;
468
+ }
469
+ `,document.head.appendChild(t)}const Ti=[{target:".nice-key-value-editor",titleKey:"tutorial.keyValueEditor.intro.title",title:"Key/value editor",contentKey:"tutorial.keyValueEditor.intro.content",content:"Add key/value rows for headers, params, env vars or config; mask secret values, toggle rows on/off, and watch for duplicate keys.",placement:"auto"}],Ri=n.forwardRef(function(i,o){const{value:a,onChange:m,allowSecret:g=!1,allowToggle:w=!1,allowDescription:_=!1,keySuggestions:R,keyPlaceholder:z="Key",valuePlaceholder:Y="Value",addLabel:B="Add",readOnly:x=!1,duplicateKeyWarning:F=!0,tutorial:P,className:G,style:H,id:U,"data-testid":v}=i,k=n.useMemo(()=>`nice-kv-keys-${Math.random().toString(36).slice(2,9)}`,[]),O=n.useMemo(()=>{const h=new Map,M=new Set;if(F){for(const I of a){const S=I.key.trim();S!==""&&h.set(S,(h.get(S)??0)+1)}h.forEach((I,S)=>{I>1&&M.add(S)})}return M},[a,F]),j=(h,M)=>{m(a.map((I,S)=>S===h?{...I,...M}:I))},A=h=>{m(a.filter((M,I)=>I!==h))},E=()=>{m([...a,{key:"",value:"",type:"text",enabled:!0}])},b="nice-key-value-editor"+(G?` ${G}`:"");return e.jsxs("div",{ref:o,id:U,className:b,style:{position:"relative",...H},"data-testid":v,children:[e.jsx("span",{style:{position:"absolute",top:0,right:0,zIndex:20},children:e.jsx(q.wl,{steps:q.xl(P,Ti)})}),R&&R.length>0&&e.jsx("datalist",{id:k,children:R.map(h=>e.jsx("option",{value:h},h))}),e.jsx("div",{className:"nice-key-value-editor__rows",children:a.map((h,M)=>{const I=h.type==="secret",S=h.key.trim()!==""&&O.has(h.key.trim()),y=w&&h.enabled===!1;return e.jsxs("div",{className:"nice-key-value-editor__row"+(y?" nice-key-value-editor__row--disabled":""),children:[w&&e.jsx("input",{type:"checkbox",className:"nice-key-value-editor__toggle",checked:h.enabled!==!1,onChange:c=>j(M,{enabled:c.target.checked}),disabled:x,"aria-label":"Enabled"}),e.jsx("input",{type:"text",className:"nice-key-value-editor__key"+(S?" nice-key-value-editor__key--dup":""),value:h.key,list:R?k:void 0,placeholder:z,onChange:c=>j(M,{key:c.target.value}),readOnly:x,"aria-label":z,title:S?"Duplicate key":void 0}),e.jsx("input",{type:I?"password":"text",className:"nice-key-value-editor__value",value:h.value,placeholder:Y,onChange:c=>j(M,{value:c.target.value}),readOnly:x,autoComplete:I?"new-password":"off","aria-label":Y}),g&&e.jsx("button",{type:"button",className:"nice-key-value-editor__secret"+(I?" nice-key-value-editor__secret--on":""),onClick:()=>j(M,{type:I?"text":"secret"}),disabled:x,title:I?"Secret (click to reveal as text)":"Mark as secret","aria-pressed":I,"aria-label":"Toggle secret",children:I?"🔒":"🔓"}),_&&e.jsx("input",{type:"text",className:"nice-key-value-editor__desc",value:h.description??"",placeholder:"Description",onChange:c=>j(M,{description:c.target.value}),readOnly:x,"aria-label":"Description"}),!x&&e.jsx("button",{type:"button",className:"nice-key-value-editor__remove",onClick:()=>A(M),title:"Remove row","aria-label":"Remove row",children:"✕"})]},h.id??M)})}),!x&&e.jsxs("button",{type:"button",className:"nice-key-value-editor__add",onClick:E,children:["+ ",B]})]})}),zt="nice-key-value-editor-styles";if(typeof document<"u"&&!document.getElementById(zt)){const t=document.createElement("style");t.id=zt,t.textContent=`
470
+ .nice-key-value-editor {
471
+ display: flex;
472
+ flex-direction: column;
473
+ gap: var(--nice-space-2, 8px);
474
+ }
475
+ .nice-key-value-editor__rows {
476
+ display: flex;
477
+ flex-direction: column;
478
+ gap: var(--nice-space-1, 4px);
479
+ }
480
+ .nice-key-value-editor__row {
481
+ display: flex;
482
+ align-items: center;
483
+ gap: var(--nice-space-1, 4px);
484
+ }
485
+ .nice-key-value-editor__row--disabled {
486
+ opacity: 0.55;
487
+ }
488
+ .nice-key-value-editor__key,
489
+ .nice-key-value-editor__value,
490
+ .nice-key-value-editor__desc {
491
+ flex: 1 1 0;
492
+ min-width: 0;
493
+ padding: 6px 8px;
494
+ border: 1px solid var(--nice-border, #d1d5db);
495
+ border-radius: var(--nice-radius-sm, 4px);
496
+ background: var(--nice-bg, #fff);
497
+ color: var(--nice-text-primary, #1f2937);
498
+ font: inherit;
499
+ font-size: 13px;
500
+ }
501
+ .nice-key-value-editor__key {
502
+ flex-basis: 30%;
503
+ font-family: 'Fira Code', 'Consolas', 'Monaco', monospace;
504
+ }
505
+ .nice-key-value-editor__key--dup {
506
+ border-color: var(--nice-danger, #dc2626);
507
+ background: var(--nice-danger-bg, #fee2e2);
508
+ }
509
+ .nice-key-value-editor__key:focus,
510
+ .nice-key-value-editor__value:focus,
511
+ .nice-key-value-editor__desc:focus {
512
+ outline: none;
513
+ border-color: var(--nice-primary, #2563eb);
514
+ }
515
+ .nice-key-value-editor__toggle {
516
+ flex: 0 0 auto;
517
+ }
518
+ .nice-key-value-editor__secret,
519
+ .nice-key-value-editor__remove {
520
+ flex: 0 0 auto;
521
+ border: 1px solid var(--nice-border, #d1d5db);
522
+ background: var(--nice-surface, #fff);
523
+ border-radius: var(--nice-radius-sm, 4px);
524
+ padding: 5px 8px;
525
+ font-size: 13px;
526
+ line-height: 1;
527
+ cursor: pointer;
528
+ }
529
+ .nice-key-value-editor__secret--on {
530
+ border-color: var(--nice-warning, #d97706);
531
+ background: var(--nice-warning-bg, #fef3c7);
532
+ }
533
+ .nice-key-value-editor__remove:hover {
534
+ border-color: var(--nice-danger, #dc2626);
535
+ color: var(--nice-danger, #dc2626);
536
+ }
537
+ .nice-key-value-editor__add {
538
+ align-self: flex-start;
539
+ border: 1px dashed var(--nice-border, #d1d5db);
540
+ background: transparent;
541
+ color: var(--nice-primary, #2563eb);
542
+ border-radius: var(--nice-radius-sm, 4px);
543
+ padding: 5px 12px;
544
+ font: inherit;
545
+ font-size: 13px;
546
+ font-weight: 600;
547
+ cursor: pointer;
548
+ }
549
+ .nice-key-value-editor__add:hover {
550
+ background: var(--nice-bg-secondary, #f5f5f5);
551
+ }
552
+ `,document.head.appendChild(t)}function Pt(t,i){const o=i.getBoundingClientRect();let a,m,g;if("touches"in t){const w=t.touches[0];a=w.clientX-o.left,m=w.clientY-o.top,g=w.force}else"pressure"in t?(a=t.clientX-o.left,m=t.clientY-o.top,g=t.pressure):(a=t.clientX-o.left,m=t.clientY-o.top);return{x:a,y:m,time:Date.now(),pressure:g!==void 0?g:.5}}function Ot(t,i,o,a,m){if(!i)return(o+a)/2;const g=Math.sqrt(Math.pow(t.x-i.x,2)+Math.pow(t.y-i.y,2))/Math.max(1,t.time-i.time),w=Math.min(g/5,1),_=a-w*(a-o),R=t.pressure??.5,z=o+R*(a-o);return _*.7+z*.3}function Ht(t,i,o,a){t.beginPath(),t.moveTo(i.x,i.y),t.lineTo(o.x,o.y),t.lineWidth=a,t.lineCap="round",t.lineJoin="round",t.stroke()}const Ii=n.forwardRef(function(i,o){const{value:a,onChange:m,width:g="100%",height:w=200,penColor:_="var(--text-primary, #000000)",penWidth:R=2,minWidth:z=.5,maxWidth:Y=4,backgroundColor:B="var(--bg-primary, #ffffff)",placeholder:x="Sign here",showClearButton:F=!0,showUndoButton:P=!0,showColorPicker:G=!1,showSizeSlider:H=!1,velocityFilterWeight:U=.7,throttle:v=16,disabled:k=!1,readOnly:O=!1,displayMode:j=!1,onBegin:A,onEnd:E,className:b,"data-testid":h}=i,M=O||j,I=j?!1:F,S=j?!1:P,y=j?!1:G,c=j?!1:H,L=n.useRef(null),[C,u]=n.useState(a?.strokes??[]),[l,s]=n.useState([]),[p,f]=n.useState(!1),[d,$]=n.useState(_),[K,ee]=n.useState(R),D=n.useRef(null),ge=n.useRef(0),re=C.length===0&&l.length===0;n.useEffect(()=>{const J=L.current;if(!J)return;const W=J.getContext("2d");if(!W)return;const N=J.getBoundingClientRect(),Z=window.devicePixelRatio||1;J.width=N.width*Z,J.height=N.height*Z,W.scale(Z,Z),ye()},[g,w]);const ye=n.useCallback(()=>{const J=L.current;if(!J)return;const W=J.getContext("2d");if(!W)return;const N=J.getBoundingClientRect();W.fillStyle=B,W.fillRect(0,0,N.width,N.height),C.forEach(Z=>{if(W.strokeStyle=Z.color,!(Z.points.length<2))for(let fe=1;fe<Z.points.length;fe++){const Q=Z.points[fe-1],V=Z.points[fe],me=Ot(V,Q,z,Y);Ht(W,Q,V,me)}})},[C,B,z,Y,U]);n.useEffect(()=>{ye()},[ye]),n.useEffect(()=>{a?.strokes&&u(a.strokes)},[a]),n.useEffect(()=>{const J=L.current;if(J)if(C.length===0)m?.(null);else{const W=J.getBoundingClientRect();m?.({strokes:C,width:W.width,height:W.height,timestamp:Date.now()})}},[C,m]);const ne=n.useCallback(J=>{if(k||M)return;const W=L.current;if(!W)return;W.setPointerCapture(J.pointerId);const N=Pt(J.nativeEvent,W);f(!0),s([N]),D.current=N,ge.current=N.time,A?.()},[k,M,A]),se=n.useCallback(J=>{if(!p||k||M)return;const W=L.current;if(!W)return;const N=W.getContext("2d");if(!N)return;const Z=Date.now();if(Z-ge.current<v)return;const fe=Pt(J.nativeEvent,W),Q=D.current;if(Q){N.strokeStyle=d;const V=Ot(fe,Q,z,Y);Ht(N,Q,fe,V)}s(V=>[...V,fe]),D.current=fe,ge.current=Z},[p,k,M,d,z,Y,U,v]),le=n.useCallback(J=>{if(!p)return;const W=L.current;if(W&&W.releasePointerCapture(J.pointerId),l.length>0){const N={points:l,color:d,width:K};u(Z=>[...Z,N])}f(!1),s([]),D.current=null,E?.()},[p,l,d,K,E]),ue=n.useCallback(()=>{u([]),s([]),ye()},[ye]),be=n.useCallback(()=>{u(J=>J.slice(0,-1))},[]),te=n.useCallback((J="png",W=.92)=>{const N=L.current;if(!N)return"";const Z=J==="jpeg"?"image/jpeg":"image/png";return N.toDataURL(Z,W)},[]),ce=n.useCallback(async(J="png",W=.92)=>{const N=L.current;return N?new Promise(Z=>{const fe=J==="jpeg"?"image/jpeg":"image/png";N.toBlob(Q=>Z(Q),fe,W)}):null},[]),de=n.useCallback(()=>{const J=L.current;if(!J)return"";const W=J.getBoundingClientRect(),N=C.map(Z=>Z.points.length<2?"":`<path d="${Z.points.reduce((Q,V,me)=>me===0?`M ${V.x} ${V.y}`:`${Q} L ${V.x} ${V.y}`,"")}" stroke="${Z.color}" stroke-width="${Z.width}" fill="none" stroke-linecap="round" stroke-linejoin="round"/>`).join(`
553
+ `);return`<svg xmlns="http://www.w3.org/2000/svg" width="${W.width}" height="${W.height}" viewBox="0 0 ${J.width} ${J.height}">
554
+ <rect width="100%" height="100%" fill="${B}"/>
555
+ ${N}
556
+ </svg>`},[C,B]);n.useImperativeHandle(o,()=>({clear:ue,undo:be,isEmpty:()=>C.length===0,getData:()=>{const J=L.current;if(!J||C.length===0)return null;const W=J.getBoundingClientRect();return{strokes:C,width:W.width,height:W.height,timestamp:Date.now()}},setData:J=>{u(J.strokes)},toDataURL:te,toBlob:ce,toSVG:de,getCanvas:()=>L.current}),[C,ue,be,te,ce,de]),n.useEffect(()=>{const J=L.current;if(!J)return;const W=N=>{p&&N.preventDefault()};return J.addEventListener("touchmove",W,{passive:!1}),()=>J.removeEventListener("touchmove",W)},[p]);const oe=I||S||y||c;return e.jsxs("div",{className:`nice-signature ${k?"nice-signature--disabled":""} ${M?"nice-signature--readonly":""} ${b??""}`,style:{width:g},"data-testid":h,children:[oe&&e.jsxs("div",{className:"nice-signature__toolbar",children:[y&&e.jsx("div",{className:"nice-signature__color-picker",children:e.jsx("input",{type:"color",value:d,onChange:J=>$(J.target.value),disabled:k||M,title:"Pen color"})}),c&&e.jsx("div",{className:"nice-signature__size-slider",children:e.jsx("input",{type:"range",min:z,max:Y,step:.5,value:K,onChange:J=>ee(parseFloat(J.target.value)),disabled:k||M,title:"Pen size"})}),e.jsxs("div",{className:"nice-signature__actions",children:[S&&e.jsx("button",{type:"button",onClick:be,disabled:k||M||C.length===0,className:"nice-signature__btn",title:"Undo",children:"↩️"}),I&&e.jsx("button",{type:"button",onClick:ue,disabled:k||M||re,className:"nice-signature__btn",title:"Clear",children:"🗑️"})]})]}),e.jsxs("div",{className:"nice-signature__canvas-wrapper",style:{height:w},children:[e.jsx("canvas",{ref:L,className:"nice-signature__canvas",style:{width:"100%",height:"100%",cursor:k||M?"not-allowed":"crosshair",touchAction:"none"},onPointerDown:ne,onPointerMove:se,onPointerUp:le,onPointerLeave:le}),re&&!p&&x&&e.jsx("div",{className:"nice-signature__placeholder",children:x}),e.jsx("div",{className:"nice-signature__line"})]})]})}),Ft="nice-signature-styles";if(typeof document<"u"&&!document.getElementById(Ft)){const t=document.createElement("style");t.id=Ft,t.textContent=`
557
+ .nice-signature {
558
+ display: flex;
559
+ flex-direction: column;
560
+ border: 1px solid var(--nice-border, #e0e0e0);
561
+ border-radius: var(--nice-radius-sm, 4px);
562
+ overflow: hidden;
563
+ background: var(--nice-bg-surface, #fff);
564
+ }
565
+
566
+ .nice-signature--disabled {
567
+ opacity: 0.6;
568
+ }
569
+
570
+ .nice-signature__toolbar {
571
+ display: flex;
572
+ align-items: center;
573
+ gap: var(--nice-space-2, 8px);
574
+ padding: var(--nice-space-2, 8px);
575
+ background: var(--nice-bg-muted, #f5f5f5);
576
+ border-bottom: 1px solid var(--nice-border, #e0e0e0);
577
+ }
578
+
579
+ .nice-signature__color-picker input {
580
+ width: 32px;
581
+ height: 32px;
582
+ padding: var(--nice-space-0-5, 2px);
583
+ border: 1px solid var(--nice-border, #e0e0e0);
584
+ border-radius: var(--nice-radius-sm, 4px);
585
+ cursor: pointer;
586
+ }
587
+
588
+ .nice-signature__size-slider {
589
+ flex: 1;
590
+ max-width: 120px;
591
+ }
592
+
593
+ .nice-signature__size-slider input {
594
+ width: 100%;
595
+ }
596
+
597
+ .nice-signature__actions {
598
+ display: flex;
599
+ gap: var(--nice-space-1, 4px);
600
+ margin-left: auto;
601
+ }
602
+
603
+ .nice-signature__btn {
604
+ padding: var(--nice-space-1-5, 6px) var(--nice-space-2-5, 10px);
605
+ border: 1px solid var(--nice-border, #e0e0e0);
606
+ border-radius: var(--nice-radius-sm, 4px);
607
+ background: var(--nice-bg-surface, #fff);
608
+ cursor: pointer;
609
+ font-size: 14px;
610
+ }
611
+
612
+ .nice-signature__btn:hover:not(:disabled) {
613
+ background: var(--nice-bg-hover, #f0f0f0);
614
+ }
615
+
616
+ .nice-signature__btn:disabled {
617
+ opacity: 0.4;
618
+ cursor: not-allowed;
619
+ }
620
+
621
+ .nice-signature__canvas-wrapper {
622
+ position: relative;
623
+ background: var(--nice-bg, #FFF);
624
+ }
625
+
626
+ .nice-signature__canvas {
627
+ display: block;
628
+ }
629
+
630
+ .nice-signature__placeholder {
631
+ position: absolute;
632
+ top: 50%;
633
+ left: 50%;
634
+ transform: translate(-50%, -50%);
635
+ color: var(--nice-text-secondary, #999);
636
+ font-size: 14px;
637
+ pointer-events: none;
638
+ user-select: none;
639
+ }
640
+
641
+ .nice-signature__line {
642
+ position: absolute;
643
+ bottom: 30px;
644
+ left: 20px;
645
+ right: 20px;
646
+ height: 1px;
647
+ background: var(--nice-border, #ccc);
648
+ pointer-events: none;
649
+ }
650
+
651
+ /* Display component */
652
+ .nice-signature-display {
653
+ border: 1px solid var(--nice-border, #e0e0e0);
654
+ border-radius: var(--nice-radius-sm, 4px);
655
+ overflow: hidden;
656
+ }
657
+
658
+ .nice-signature-display__canvas-wrapper {
659
+ position: relative;
660
+ background: var(--nice-bg, #FFF);
661
+ }
662
+
663
+ .nice-signature-display__canvas {
664
+ display: block;
665
+ }
666
+
667
+ .nice-signature-display__placeholder {
668
+ position: absolute;
669
+ top: 50%;
670
+ left: 50%;
671
+ transform: translate(-50%, -50%);
672
+ color: var(--nice-text-secondary, #999);
673
+ font-size: 14px;
674
+ }
675
+ `,document.head.appendChild(t)}const Ai={recent:"🕒",smileys:"😀",people:"👋",animals:"🐱",food:"🍕",travel:"✈️",activities:"⚽",objects:"💡",symbols:"❤️",flags:"🏳️"},Bt={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"},mt=["","🏻","🏼","🏽","🏾","🏿"],ot=[{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"}],Kt="nice-emoji-picker-recent",yn=({onSelect:t,showSearch:i=!0,searchPlaceholder:o,showSkinTones:a=!0,defaultSkinTone:m=0,showRecent:g=!0,maxRecent:w=24,recentEmojis:_,onRecentChange:R,categories:z,customEmojis:Y=[],columns:B=8,size:x="md",className:F="",style:P,"data-testid":G="nice-emoji-picker"})=>{const{t:H}=q.Zt(),[U,v]=n.useState(""),[k,O]=n.useState(g?"recent":"smileys"),[j,A]=n.useState(m),[E,b]=n.useState(!1),h=n.useRef(null),[M,I]=n.useState(()=>{if(typeof window>"u")return[];try{return JSON.parse(localStorage.getItem(Kt)||"[]")}catch{return[]}}),S=_??M,y=z??[...g?["recent"]:[],"smileys","people","animals","food","travel","activities","objects","symbols","flags"],c=n.useMemo(()=>{if(!U)return ot;const p=U.toLowerCase();return ot.filter(f=>f.name.toLowerCase().includes(p)||f.emoji.includes(p)||f.keywords?.some(d=>d.toLowerCase().includes(p)))},[U]),L=n.useMemo(()=>{const p={};for(const f of y)f==="recent"?p[f]=S.map(d=>ot.find($=>$.emoji===d)).filter(d=>d!==void 0).slice(0,w):p[f]=c.filter(d=>d.category===f);return p},[y,c,S,w]),C=n.useCallback((p,f)=>!f||j===0?p:p.replace(/[\u{1F3FB}-\u{1F3FF}]/gu,"")+mt[j],[j]),u=n.useCallback(p=>{const f=C(p.emoji,p.skinTones),d=[p.emoji,...S.filter($=>$!==p.emoji)].slice(0,w);if(_===void 0){I(d);try{localStorage.setItem(Kt,JSON.stringify(d))}catch{}}R?.(d),t?.(f,p)},[C,S,w,_,R,t]),l=n.useCallback(p=>{t?.(`:${p.name}:`,p)},[t]);n.useEffect(()=>{if(!E)return;const p=f=>{h.current&&!h.current.contains(f.target)&&b(!1)};return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[E]);const s=U?c:L[k]||[];return e.jsxs("div",{className:`nice-emoji-picker nice-emoji-picker--${x} ${F}`,style:P,"data-testid":G,children:[i&&e.jsxs("div",{className:"nice-emoji-picker__search",children:[e.jsx("input",{type:"text",value:U,onChange:p=>v(p.target.value),placeholder:o??H("search","Search emoji..."),className:"nice-emoji-picker__search-input","data-testid":`${G}-search`}),a&&e.jsxs("div",{className:"nice-emoji-picker__skin-tone-wrapper",children:[e.jsxs("button",{ref:h,type:"button",className:"nice-emoji-picker__skin-tone-btn",onClick:()=>b(!E),title:H("skinTone","Skin tone"),children:["✋",mt[j]]}),E&&e.jsx("div",{className:"nice-emoji-picker__skin-tone-menu",children:mt.map((p,f)=>e.jsxs("button",{type:"button",className:`nice-emoji-picker__skin-tone-option ${f===j?"nice-emoji-picker__skin-tone-option--selected":""}`,onClick:()=>{A(f),b(!1)},children:["✋",p]},f))})]})]}),!U&&e.jsx("div",{className:"nice-emoji-picker__categories",role:"tablist",children:y.map(p=>e.jsx("button",{type:"button",className:`nice-emoji-picker__category-btn ${k===p?"nice-emoji-picker__category-btn--selected":""}`,onClick:()=>O(p),title:Bt[p],role:"tab","aria-selected":k===p,children:Ai[p]},p))}),e.jsxs("div",{className:"nice-emoji-picker__grid-container",children:[U?e.jsxs("div",{className:"nice-emoji-picker__section",children:[e.jsx("div",{className:"nice-emoji-picker__section-title",children:H("searchResults","Search Results")}),e.jsx("div",{className:"nice-emoji-picker__grid",style:{gridTemplateColumns:`repeat(${B}, 1fr)`},children:c.length===0?e.jsx("div",{className:"nice-emoji-picker__empty",children:H("noEmojis","No emojis found")}):c.map((p,f)=>e.jsx("button",{type:"button",className:"nice-emoji-picker__emoji",onClick:()=>u(p),title:p.name,children:C(p.emoji,p.skinTones)},`${p.emoji}-${f}`))})]}):e.jsxs("div",{className:"nice-emoji-picker__section",children:[e.jsx("div",{className:"nice-emoji-picker__section-title",children:Bt[k]}),e.jsx("div",{className:"nice-emoji-picker__grid",style:{gridTemplateColumns:`repeat(${B}, 1fr)`},children:s.length===0?e.jsx("div",{className:"nice-emoji-picker__empty",children:k==="recent"?H("noRecent","No recent emojis"):H("noEmojis","No emojis")}):s.map((p,f)=>e.jsx("button",{type:"button",className:"nice-emoji-picker__emoji",onClick:()=>u(p),title:p.name,children:C(p.emoji,p.skinTones)},`${p.emoji}-${f}`))})]}),Y.length>0&&e.jsxs("div",{className:"nice-emoji-picker__section",children:[e.jsx("div",{className:"nice-emoji-picker__section-title",children:H("custom","Custom")}),e.jsx("div",{className:"nice-emoji-picker__grid",style:{gridTemplateColumns:`repeat(${B}, 1fr)`},children:Y.map(p=>e.jsx("button",{type:"button",className:"nice-emoji-picker__emoji nice-emoji-picker__emoji--custom",onClick:()=>l(p),title:p.name,children:e.jsx("img",{src:p.url,alt:p.name})},p.id))})]})]})]})};yn.displayName="NiceEmojiPicker";const Di=[{target:".nice-crop-editor",titleKey:"tutorial.cropEditor.intro.title",title:"Crop editor",contentKey:"tutorial.cropEditor.intro.content",content:"Drag the crop box over the image, pick an aspect ratio, rotate, flip or zoom, then use the result.",placement:"auto"}],xn=[{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}],bn=({src:t,initialCrop:i={x:10,y:10,width:80,height:80},initialRotation:o=0,initialZoom:a=1,aspectRatios:m=xn,defaultAspectRatio:g="free",customAspectRatio:w,showRotation:_=!0,showFlip:R=!0,showZoom:z=!0,minZoom:Y=.5,maxZoom:B=3,zoomStep:x=.1,showGrid:F=!0,overlayColor:P="var(--nice-overlay-50, rgba(0, 0, 0, 0.5))",toolbarPosition:G="bottom",toolbarCollapsible:H=!1,defaultToolbarCollapsed:U=!1,onChange:v,tutorial:k,className:O="",style:j,"data-testid":A="nice-crop-editor"})=>{const{t:E}=q.Zt(),b=n.useRef(null),h=n.useRef(null),[M,I]=n.useState(i),[S,y]=n.useState(o),[c,L]=n.useState(a),[C,u]=n.useState(!1),[l,s]=n.useState(!1),[p,f]=n.useState(g),[d,$]=n.useState(U),[K,ee]=n.useState(!1),[D,ge]=n.useState({x:0,y:0,crop:M}),re=p==="custom"?w:m.find(N=>N.value===p)?.ratio;n.useEffect(()=>{v?.({crop:M,rotation:S,flipH:C,flipV:l,zoom:c})},[M,S,C,l,c,v]);const ye=n.useCallback((N,Z)=>{if(!re)return N;const fe=b.current?.clientWidth??400,Q=b.current?.clientHeight??300,V=N.width/100*fe,me=N.height/100*Q,xe=V/me;if(Math.abs(xe-re)<.01)return N;if(Z?.includes("e")||Z?.includes("w")){const ve=V/re/Q*100;return{...N,height:Math.min(100-N.y,Math.max(5,ve))}}else if(Z?.includes("n")||Z?.includes("s")){const ve=me*re/fe*100;return{...N,width:Math.min(100-N.x,Math.max(5,ve))}}else{const ve=V/re/Q*100;return{...N,height:Math.min(100-N.y,Math.max(5,ve))}}},[re]),ne=n.useCallback((N,Z)=>{Z===!1||(N.preventDefault(),N.stopPropagation(),ee(Z),!b.current?.getBoundingClientRect())||ge({x:N.clientX,y:N.clientY,crop:{...M}})},[M]),se=n.useCallback(N=>{if(!K||!b.current)return;const Z=b.current.getBoundingClientRect(),fe=(N.clientX-D.x)/Z.width*100,Q=(N.clientY-D.y)/Z.height*100;let V={...D.crop};if(K==="crop")V.x=Math.max(0,Math.min(100-V.width,D.crop.x+fe)),V.y=Math.max(0,Math.min(100-V.height,D.crop.y+Q));else{switch(K){case"resize-nw":V.x=Math.max(0,Math.min(D.crop.x+D.crop.width-5,D.crop.x+fe)),V.y=Math.max(0,Math.min(D.crop.y+D.crop.height-5,D.crop.y+Q)),V.width=D.crop.width-(V.x-D.crop.x),V.height=D.crop.height-(V.y-D.crop.y);break;case"resize-ne":V.y=Math.max(0,Math.min(D.crop.y+D.crop.height-5,D.crop.y+Q)),V.width=Math.max(5,Math.min(100-V.x,D.crop.width+fe)),V.height=D.crop.height-(V.y-D.crop.y);break;case"resize-sw":V.x=Math.max(0,Math.min(D.crop.x+D.crop.width-5,D.crop.x+fe)),V.width=D.crop.width-(V.x-D.crop.x),V.height=Math.max(5,Math.min(100-V.y,D.crop.height+Q));break;case"resize-se":V.width=Math.max(5,Math.min(100-V.x,D.crop.width+fe)),V.height=Math.max(5,Math.min(100-V.y,D.crop.height+Q));break;case"resize-n":V.y=Math.max(0,Math.min(D.crop.y+D.crop.height-5,D.crop.y+Q)),V.height=D.crop.height-(V.y-D.crop.y);break;case"resize-s":V.height=Math.max(5,Math.min(100-V.y,D.crop.height+Q));break;case"resize-e":V.width=Math.max(5,Math.min(100-V.x,D.crop.width+fe));break;case"resize-w":V.x=Math.max(0,Math.min(D.crop.x+D.crop.width-5,D.crop.x+fe)),V.width=D.crop.width-(V.x-D.crop.x);break}V=ye(V,K.replace("resize-",""))}I(V)},[K,D,ye]),le=n.useCallback(()=>{ee(!1)},[]);n.useEffect(()=>{if(K)return document.addEventListener("mousemove",se),document.addEventListener("mouseup",le),()=>{document.removeEventListener("mousemove",se),document.removeEventListener("mouseup",le)}},[K,se,le]);const ue=n.useCallback(()=>{y(N=>(N-90+360)%360)},[]),be=n.useCallback(()=>{y(N=>(N+90)%360)},[]),te=n.useCallback(()=>{u(N=>!N)},[]),ce=n.useCallback(()=>{s(N=>!N)},[]),de=n.useCallback(()=>{I(i),y(o),L(a),u(!1),s(!1),f(g)},[i,o,a,g]);n.useEffect(()=>{I(N=>ye(N))},[p,ye]);const oe=`scale(${c}) rotate(${S}deg) scaleX(${C?-1:1}) scaleY(${l?-1:1})`,J=G==="top"?"column-reverse":G==="left"?"row-reverse":G==="right"?"row":"column",W=G==="left"||G==="right";return e.jsxs("div",{className:`nice-crop-editor nice-crop-editor--toolbar-${G} ${O}`,style:{position:"relative",display:"flex",flexDirection:J,gap:12,...j},"data-testid":A,children:[e.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:20},children:e.jsx(q.wl,{steps:q.xl(k,Di)})}),e.jsxs("div",{ref:b,className:"nice-crop-editor__container","data-testid":`${A}-container`,children:[e.jsx("img",{ref:h,src:t,alt:"",className:"nice-crop-editor__image",style:{transform:oe},draggable:!1}),e.jsxs("div",{className:"nice-crop-editor__overlay",style:{backgroundColor:P},children:[e.jsx("div",{className:"nice-crop-editor__overlay-piece",style:{top:0,left:0,right:0,height:`${M.y}%`}}),e.jsx("div",{className:"nice-crop-editor__overlay-piece",style:{bottom:0,left:0,right:0,height:`${100-M.y-M.height}%`}}),e.jsx("div",{className:"nice-crop-editor__overlay-piece",style:{top:`${M.y}%`,left:0,width:`${M.x}%`,height:`${M.height}%`}}),e.jsx("div",{className:"nice-crop-editor__overlay-piece",style:{top:`${M.y}%`,right:0,width:`${100-M.x-M.width}%`,height:`${M.height}%`}})]}),e.jsxs("div",{className:"nice-crop-editor__crop-area",style:{left:`${M.x}%`,top:`${M.y}%`,width:`${M.width}%`,height:`${M.height}%`},onMouseDown:N=>ne(N,"crop"),"data-testid":`${A}-crop-area`,children:[F&&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:N=>ne(N,"resize-nw")}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--ne",onMouseDown:N=>ne(N,"resize-ne")}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--sw",onMouseDown:N=>ne(N,"resize-sw")}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--se",onMouseDown:N=>ne(N,"resize-se")}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--n",onMouseDown:N=>ne(N,"resize-n")}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--s",onMouseDown:N=>ne(N,"resize-s")}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--e",onMouseDown:N=>ne(N,"resize-e")}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--w",onMouseDown:N=>ne(N,"resize-w")})]})]}),e.jsxs("div",{className:`nice-crop-editor__controls ${d?"nice-crop-editor__controls--collapsed":""}`,style:{display:"flex",flexDirection:W?"column":"row",flexWrap:W?"nowrap":"wrap",gap:8,alignItems:W?"stretch":"center",flexShrink:0},children:[H&&e.jsx("button",{type:"button",className:"nice-crop-editor__toolbar-toggle","aria-expanded":!d,"aria-label":d?"Show toolbar":"Hide toolbar",onClick:()=>$(N=>!N),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:d?"▸":"▾"}),!d&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"nice-crop-editor__control-group",children:[e.jsx("label",{className:"nice-crop-editor__label",children:E("aspectRatio","Aspect Ratio")}),e.jsx("div",{className:"nice-crop-editor__aspect-buttons",children:m.map(N=>e.jsx("button",{type:"button",className:`nice-crop-editor__aspect-btn ${p===N.value?"nice-crop-editor__aspect-btn--selected":""}`,onClick:()=>f(N.value),title:N.label,children:N.label},N.value))})]}),z&&e.jsxs("div",{className:"nice-crop-editor__control-group",children:[e.jsxs("label",{className:"nice-crop-editor__label",children:[E("zoom","Zoom"),": ",Math.round(c*100),"%"]}),e.jsx("input",{type:"range",className:"nice-crop-editor__slider",min:Y,max:B,step:x,value:c,onChange:N=>L(parseFloat(N.target.value)),"data-testid":`${A}-zoom`})]}),e.jsxs("div",{className:"nice-crop-editor__control-group nice-crop-editor__control-group--row",children:[_&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"nice-crop-editor__btn",onClick:ue,title:E("rotateLeft","Rotate Left"),children:"↺"}),e.jsx("button",{type:"button",className:"nice-crop-editor__btn",onClick:be,title:E("rotateRight","Rotate Right"),children:"↻"})]}),R&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:`nice-crop-editor__btn ${C?"nice-crop-editor__btn--active":""}`,onClick:te,title:E("flipHorizontal","Flip Horizontal"),children:"⇆"}),e.jsx("button",{type:"button",className:`nice-crop-editor__btn ${l?"nice-crop-editor__btn--active":""}`,onClick:ce,title:E("flipVertical","Flip Vertical"),children:"⇅"})]}),e.jsx("button",{type:"button",className:"nice-crop-editor__btn nice-crop-editor__btn--reset",onClick:de,title:E("reset","Reset"),children:"⟲"})]})]})]})]})};bn.displayName="NiceCropEditor";const Li={strokeColor:"#ff3333",fillColor:"transparent",strokeWidth:2,opacity:1,fontSize:16,fontFamily:"sans-serif"};function zi(t,i){switch(i.type){case"SET_TOOL":return{...t,activeTool:i.tool,selectedId:null};case"SET_STYLE":return{...t,style:{...t.style,...i.style}};case"ADD_ANNOTATION":return{...t,annotations:[...t.annotations,i.annotation],past:[...t.past,t.annotations],future:[]};case"UPDATE_ANNOTATION":return{...t,annotations:t.annotations.map(o=>o.id===i.id?{...o,...i.updates}:o),past:[...t.past,t.annotations],future:[]};case"DELETE_ANNOTATION":return{...t,annotations:t.annotations.filter(o=>o.id!==i.id),selectedId:t.selectedId===i.id?null:t.selectedId,past:[...t.past,t.annotations],future:[]};case"SELECT":return{...t,selectedId:i.id};case"SET_ANNOTATIONS":return{...t,annotations:i.annotations,past:[],future:[]};case"SET_ZOOM":return{...t,zoom:i.zoom};case"SET_PAN":return{...t,panX:i.panX,panY:i.panY};case"UNDO":{if(t.past.length===0)return t;const o=t.past[t.past.length-1];return{...t,annotations:o,past:t.past.slice(0,-1),future:[t.annotations,...t.future]}}case"REDO":{if(t.future.length===0)return t;const o=t.future[0];return{...t,annotations:o,past:[...t.past,t.annotations],future:t.future.slice(1)}}case"CLEAR":return{...t,annotations:[],selectedId:null,past:[...t.past,t.annotations],future:[]};default:return t}}let Pi=0;function Oi(){return`ann-${Date.now()}-${Pi++}`}function Hi(t){const{style:i}=t,o=`stroke="${i.strokeColor}" stroke-width="${i.strokeWidth}" fill="${i.fillColor}" opacity="${i.opacity}"`;switch(t.tool){case"rectangle":return`<rect x="${t.x}" y="${t.y}" width="${t.width}" height="${t.height}" ${o} />`;case"ellipse":{const a=t.x+t.width/2,m=t.y+t.height/2;return`<ellipse cx="${a}" cy="${m}" rx="${t.width/2}" ry="${t.height/2}" ${o} />`}case"arrow":{const a=t,m=Math.atan2(a.endY-a.y,a.endX-a.x),g=12,w=a.endX-g*Math.cos(m-Math.PI/6),_=a.endY-g*Math.sin(m-Math.PI/6),R=a.endX-g*Math.cos(m+Math.PI/6),z=a.endY-g*Math.sin(m+Math.PI/6);return`<line x1="${a.x}" y1="${a.y}" x2="${a.endX}" y2="${a.endY}" ${o} />
676
+ <polygon points="${a.endX},${a.endY} ${w},${_} ${R},${z}" fill="${i.strokeColor}" opacity="${i.opacity}" />`}case"line":{const a=t;return`<line x1="${a.x}" y1="${a.y}" x2="${a.endX}" y2="${a.endY}" ${o} />`}case"text":{const a=t;return`<text x="${a.x}" y="${a.y+(a.style.fontSize??16)}" fill="${i.strokeColor}" font-size="${i.fontSize}" font-family="${i.fontFamily}" opacity="${i.opacity}">${Fi(a.text)}</text>`}case"freehand":{const a=t;return a.points.length<2?"":`<path d="${a.points.map((g,w)=>`${w===0?"M":"L"}${g.x},${g.y}`).join(" ")}" ${o} fill="none" />`}case"blur":{const a=t,m=`blur-${a.id}`;return`<defs><filter id="${m}"><feGaussianBlur stdDeviation="${a.intensity??5}" /></filter></defs>
677
+ <rect x="${a.x}" y="${a.y}" width="${a.width}" height="${a.height}" fill="transparent" stroke="none" filter="url(#${m})" />`}default:return""}}function Fi(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}const jn=n.forwardRef(({src:t,alt:i="Annotatable image",annotations:o,activeTool:a,defaultStyle:m,onAnnotationsChange:g,className:w,readOnly:_=!1,minZoom:R=.1,maxZoom:z=5},Y)=>{const B=n.useRef(null),x=n.useRef(null),F=n.useRef(null),[P,G]=n.useState(!1),[H,U]=n.useState({width:0,height:0}),[v,k]=n.useReducer(zi,{annotations:o??[],selectedId:null,activeTool:a??"select",style:{...Li,...m},zoom:1,panX:0,panY:0,past:[],future:[]});n.useEffect(()=>{a&&k({type:"SET_TOOL",tool:a})},[a]),n.useEffect(()=>{g?.(v.annotations)},[v.annotations,g]),n.useEffect(()=>{const y=new Image;y.crossOrigin="anonymous",y.onload=()=>{F.current=y,U({width:y.naturalWidth,height:y.naturalHeight}),G(!0)},y.src=t},[t]);const O=n.useRef({isDrawing:!1,startX:0,startY:0,currentAnnotation:null,freehandPoints:[]}),j=n.useCallback((y,c)=>{const L=B.current;if(!L)return{x:0,y:0};const C=L.getBoundingClientRect();return{x:(y-C.left-v.panX)/v.zoom,y:(c-C.top-v.panY)/v.zoom}},[v.zoom,v.panX,v.panY]),A=n.useCallback(()=>{const y=B.current,c=y?.getContext("2d"),L=F.current;if(!y||!c||!L||!P)return;y.width=x.current?.clientWidth??L.naturalWidth,y.height=x.current?.clientHeight??L.naturalHeight,c.clearRect(0,0,y.width,y.height),c.save(),c.translate(v.panX,v.panY),c.scale(v.zoom,v.zoom),c.drawImage(L,0,0);for(const u of v.annotations){switch(c.save(),c.globalAlpha=u.style.opacity,c.strokeStyle=u.style.strokeColor,c.fillStyle=u.style.fillColor,c.lineWidth=u.style.strokeWidth,u.tool){case"rectangle":c.strokeRect(u.x,u.y,u.width,u.height),u.style.fillColor!=="transparent"&&c.fillRect(u.x,u.y,u.width,u.height);break;case"ellipse":{c.beginPath(),c.ellipse(u.x+u.width/2,u.y+u.height/2,Math.abs(u.width/2),Math.abs(u.height/2),0,0,Math.PI*2),c.stroke(),u.style.fillColor!=="transparent"&&c.fill();break}case"arrow":{const l=u;c.beginPath(),c.moveTo(l.x,l.y),c.lineTo(l.endX,l.endY),c.stroke();const s=Math.atan2(l.endY-l.y,l.endX-l.x),p=12;c.beginPath(),c.moveTo(l.endX,l.endY),c.lineTo(l.endX-p*Math.cos(s-Math.PI/6),l.endY-p*Math.sin(s-Math.PI/6)),c.lineTo(l.endX-p*Math.cos(s+Math.PI/6),l.endY-p*Math.sin(s+Math.PI/6)),c.closePath(),c.fillStyle=u.style.strokeColor,c.fill();break}case"line":{const l=u;c.beginPath(),c.moveTo(l.x,l.y),c.lineTo(l.endX,l.endY),c.stroke();break}case"text":{const l=u;c.font=`${l.style.fontSize??16}px ${l.style.fontFamily??"sans-serif"}`,c.fillStyle=l.style.strokeColor,c.fillText(l.text,l.x,l.y+(l.style.fontSize??16));break}case"freehand":{const l=u;if(l.points.length<2)break;c.beginPath(),c.moveTo(l.points[0].x,l.points[0].y);for(let s=1;s<l.points.length;s++)c.lineTo(l.points[s].x,l.points[s].y);c.stroke();break}case"blur":{const l=u;c.filter=`blur(${l.intensity??5}px)`,c.drawImage(L,l.x,l.y,l.width,l.height,l.x,l.y,l.width,l.height),c.filter="none";break}}u.id===v.selectedId&&(c.strokeStyle="#4488ff",c.lineWidth=1,c.setLineDash([4,4]),c.strokeRect(u.x-2,u.y-2,u.width+4,u.height+4),c.setLineDash([])),c.restore()}const C=O.current;if(C.isDrawing&&C.currentAnnotation){c.save();const u=C.currentAnnotation;if(c.globalAlpha=u.style.opacity,c.strokeStyle=u.style.strokeColor,c.lineWidth=u.style.strokeWidth,c.setLineDash([6,3]),u.tool==="freehand"){const l=u;if(l.points.length>=2){c.beginPath(),c.moveTo(l.points[0].x,l.points[0].y);for(let s=1;s<l.points.length;s++)c.lineTo(l.points[s].x,l.points[s].y);c.stroke()}}else if(u.tool==="rectangle")c.strokeRect(u.x,u.y,u.width,u.height);else if(u.tool==="ellipse")c.beginPath(),c.ellipse(u.x+u.width/2,u.y+u.height/2,Math.abs(u.width/2),Math.abs(u.height/2),0,0,Math.PI*2),c.stroke();else if(u.tool==="arrow"||u.tool==="line"){const l=u;c.beginPath(),c.moveTo(l.x,l.y),c.lineTo(l.endX,l.endY),c.stroke()}c.restore()}c.restore()},[v,P]);n.useEffect(()=>{A()},[A]);const E=n.useCallback(y=>{if(_)return;const c=j(y.clientX,y.clientY),L=v.activeTool;if(L==="select"){const l=[...v.annotations].reverse().find(s=>s.tool==="freehand"?!1:c.x>=s.x&&c.x<=s.x+s.width&&c.y>=s.y&&c.y<=s.y+s.height);k({type:"SELECT",id:l?.id??null});return}const C=O.current;C.isDrawing=!0,C.startX=c.x,C.startY=c.y;const u={id:Oi(),style:{...v.style},x:c.x,y:c.y,width:0,height:0};switch(L){case"rectangle":C.currentAnnotation={...u,tool:"rectangle"};break;case"ellipse":C.currentAnnotation={...u,tool:"ellipse"};break;case"arrow":C.currentAnnotation={...u,tool:"arrow",endX:c.x,endY:c.y};break;case"line":C.currentAnnotation={...u,tool:"line",endX:c.x,endY:c.y};break;case"text":C.currentAnnotation={...u,tool:"text",text:"Text",width:100,height:v.style.fontSize??16};break;case"freehand":C.freehandPoints=[c],C.currentAnnotation={...u,tool:"freehand",points:[c]};break;case"blur":C.currentAnnotation={...u,tool:"blur",intensity:5};break}},[_,j,v.activeTool,v.style,v.annotations]),b=n.useCallback(y=>{const c=O.current;if(!c.isDrawing||!c.currentAnnotation)return;const L=j(y.clientX,y.clientY),C=c.currentAnnotation;if(C.tool==="freehand"){c.freehandPoints.push(L),C.points=[...c.freehandPoints];const u=c.freehandPoints.map(s=>s.x),l=c.freehandPoints.map(s=>s.y);C.x=Math.min(...u),C.y=Math.min(...l),C.width=Math.max(...u)-C.x,C.height=Math.max(...l)-C.y}else if(C.tool==="arrow"||C.tool==="line")C.endX=L.x,C.endY=L.y,C.width=Math.abs(L.x-c.startX),C.height=Math.abs(L.y-c.startY);else{const u=Math.min(c.startX,L.x),l=Math.min(c.startY,L.y);C.x=u,C.y=l,C.width=Math.abs(L.x-c.startX),C.height=Math.abs(L.y-c.startY)}A()},[j,A]),h=n.useCallback(()=>{const y=O.current;if(!y.isDrawing||!y.currentAnnotation)return;const c=y.currentAnnotation;(c.tool==="text"||c.tool==="freehand"||Math.abs(c.width)>2||Math.abs(c.height)>2)&&k({type:"ADD_ANNOTATION",annotation:c}),y.isDrawing=!1,y.currentAnnotation=null,y.freehandPoints=[]},[]),M=n.useCallback(y=>{y.preventDefault();const c=y.deltaY>0?.9:1.1,L=Math.max(R,Math.min(z,v.zoom*c));k({type:"SET_ZOOM",zoom:L})},[v.zoom,R,z]);n.useEffect(()=>{if(_)return;const y=c=>{(c.metaKey||c.ctrlKey)&&c.key==="z"&&!c.shiftKey?(c.preventDefault(),k({type:"UNDO"})):(c.metaKey||c.ctrlKey)&&(c.key==="y"||c.key==="z"&&c.shiftKey)?(c.preventDefault(),k({type:"REDO"})):(c.key==="Delete"||c.key==="Backspace")&&v.selectedId&&k({type:"DELETE_ANNOTATION",id:v.selectedId})};return document.addEventListener("keydown",y),()=>document.removeEventListener("keydown",y)},[_,v.selectedId]),n.useImperativeHandle(Y,()=>({exportAsDataURL:async(y="png",c=.92)=>{const L=document.createElement("canvas"),C=F.current;if(!C)return"";L.width=C.naturalWidth,L.height=C.naturalHeight;const u=L.getContext("2d");u.drawImage(C,0,0);for(const l of v.annotations){if(u.save(),u.globalAlpha=l.style.opacity,u.strokeStyle=l.style.strokeColor,u.fillStyle=l.style.fillColor,u.lineWidth=l.style.strokeWidth,l.tool==="rectangle")u.strokeRect(l.x,l.y,l.width,l.height);else if(l.tool==="ellipse")u.beginPath(),u.ellipse(l.x+l.width/2,l.y+l.height/2,Math.abs(l.width/2),Math.abs(l.height/2),0,0,Math.PI*2),u.stroke();else if(l.tool==="freehand"){const s=l;if(s.points.length>=2){u.beginPath(),u.moveTo(s.points[0].x,s.points[0].y);for(let p=1;p<s.points.length;p++)u.lineTo(s.points[p].x,s.points[p].y);u.stroke()}}else if(l.tool==="text"){const s=l;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))}u.restore()}return L.toDataURL(`image/${y}`,c)},exportAnnotations:()=>[...v.annotations],importAnnotations:y=>{k({type:"SET_ANNOTATIONS",annotations:y})},exportAsSVG:()=>{const{width:y,height:c}=H,L=v.annotations.map(Hi);return`<svg xmlns="http://www.w3.org/2000/svg" width="${y}" height="${c}" viewBox="0 0 ${y} ${c}">
678
+ ${L.join(`
679
+ `)}
680
+ </svg>`},undo:()=>k({type:"UNDO"}),redo:()=>k({type:"REDO"}),setZoom:y=>{k({type:"SET_ZOOM",zoom:Math.max(R,Math.min(z,y))})},fitToScreen:()=>{const y=x.current,c=F.current;if(!y||!c)return;const L=y.clientWidth/c.naturalWidth,C=y.clientHeight/c.naturalHeight,u=Math.min(L,C,1);k({type:"SET_ZOOM",zoom:u}),k({type:"SET_PAN",panX:0,panY:0})},clear:()=>k({type:"CLEAR"})}),[v.annotations,H,R,z]);const I=n.useCallback(y=>{if(y.touches.length!==1)return;const c=y.touches[0];E({clientX:c.clientX,clientY:c.clientY,preventDefault:()=>{}})},[E]),S=n.useCallback(y=>{if(y.touches.length!==1)return;const c=y.touches[0];b({clientX:c.clientX,clientY:c.clientY})},[b]);return e.jsx("div",{ref:x,className:`nice-image-annotator ${w??""}`,style:{position:"relative",overflow:"hidden",width:"100%",height:"100%"},children:e.jsx("canvas",{ref:B,className:"nice-image-annotator__canvas",style:{cursor:v.activeTool==="select"?"default":"crosshair"},onMouseDown:E,onMouseMove:b,onMouseUp:h,onMouseLeave:h,onWheel:M,onTouchStart:I,onTouchMove:S,onTouchEnd:h,role:"img","aria-label":i})})});jn.displayName="NiceImageAnnotator";const Bi=[{target:".nice-md-editor",titleKey:"tutorial.markdownEditor.intro.title",title:"Markdown editor",contentKey:"tutorial.markdownEditor.intro.content",content:"Write Markdown with the formatting toolbar; toggle the live preview to see the rendered result, and export to HTML.",placement:"auto"}];function Ki(t){let i=t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");return i=i.replace(/```(\w*)\n([\s\S]*?)```/g,(o,a,m)=>`<pre><code class="language-${a}">${m.trim()}</code></pre>`),i=i.replace(/^(\|.+\|)\n(\|[-| :]+\|)\n((?:\|.+\|\n?)+)/gm,(o,a,m,g)=>{const w=a.split("|").filter(R=>R.trim()).map(R=>`<th>${R.trim()}</th>`).join(""),_=g.trim().split(`
681
+ `).map(R=>`<tr>${R.split("|").filter(Y=>Y.trim()).map(Y=>`<td>${Y.trim()}</td>`).join("")}</tr>`).join("");return`<table><thead><tr>${w}</tr></thead><tbody>${_}</tbody></table>`}),i=i.replace(/^#### (.+)$/gm,"<h4>$1</h4>"),i=i.replace(/^### (.+)$/gm,"<h3>$1</h3>"),i=i.replace(/^## (.+)$/gm,"<h2>$1</h2>"),i=i.replace(/^# (.+)$/gm,"<h1>$1</h1>"),i=i.replace(/^&gt; (.+)$/gm,"<blockquote>$1</blockquote>"),i=i.replace(/^---$/gm,"<hr/>"),i=i.replace(/^- \[x\] (.+)$/gm,'<li class="task done">☑ $1</li>'),i=i.replace(/^- \[ \] (.+)$/gm,'<li class="task">☐ $1</li>'),i=i.replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>"),i=i.replace(/\*(.+?)\*/g,"<em>$1</em>"),i=i.replace(/~~(.+?)~~/g,"<del>$1</del>"),i=i.replace(/`(.+?)`/g,"<code>$1</code>"),i=i.replace(/!\[([^\]]*)\]\(([^)]+)\)/g,'<img src="$2" alt="$1" style="max-width:100%"/>'),i=i.replace(/\[([^\]]+)\]\(([^)]+)\)/g,'<a href="$2">$1</a>'),i=i.replace(/^\- (.+)$/gm,"<li>$1</li>"),i=i.replace(/^\d+\. (.+)$/gm,"<li>$1</li>"),i=i.replace(/\n/g,"<br/>"),i}const Ui=[{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:`---
682
+ `,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 |
683
+ | --- | --- | --- |
684
+ | c1 | c2 | c3 |
685
+ `,tip:"Table",group:"insert"},{key:"codeblock",label:"```",md:"```\n",tip:"Code block",group:"insert"}],Yi=["format","heading","list","block","insert"],_n=n.forwardRef(({value:t="",onChange:i,preview:o="side",placeholder:a,disabled:m,readOnly:g,size:w="md",editorSize:_="standard",toolbar:R=!0,minHeight:z=200,showWordCount:Y=!1,showLineNumbers:B=!1,onExportHtml:x,onImageUpload:F,tutorial:P,className:G,style:H,id:U},v)=>{const k=q._s(U),[O,j]=n.useState("edit"),[A,E]=n.useState(!1),b=n.useRef(null),h=n.useMemo(()=>Ki(t),[t]),M=n.useMemo(()=>{const u=t.trim()?t.trim().split(/\s+/).length:0,l=t.length,s=t.split(`
686
+ `).length;return{words:u,chars:l,lines:s}},[t]),I=n.useCallback(u=>{const l=b.current;if(!l)return;const s=l.selectionStart,p=l.selectionEnd,f=t.slice(s,p);let d,$;u==="[](url)"?(d=t.slice(0,s)+`[${f||"text"}](url)`+t.slice(p),$=s+1+(f||"text").length+2):u==="![](url)"?(d=t.slice(0,s)+`![${f||"alt"}](url)`+t.slice(p),$=s+2+(f||"alt").length+2):u.endsWith(`
687
+ `)||u.endsWith(" ")?(d=t.slice(0,s)+u+f+t.slice(p),$=s+u.length+f.length):(d=t.slice(0,s)+u+f+u+t.slice(p),$=s+u.length+f.length+u.length),i?.(d),requestAnimationFrame(()=>{l.focus(),l.setSelectionRange($,$)})},[t,i]),S=n.useCallback(u=>{if((u.ctrlKey||u.metaKey)&&(u.key==="b"?(u.preventDefault(),I("**")):u.key==="i"?(u.preventDefault(),I("*")):u.key==="k"&&(u.preventDefault(),I("[](url)"))),u.key==="Tab"){u.preventDefault();const l=u.currentTarget,s=l.selectionStart,p=l.selectionEnd,f=" ";if(u.shiftKey){const K=t.slice(0,s).lastIndexOf(`
688
+ `)+1;if(t.slice(K,K+f.length)===f){const ee=t.slice(0,K)+t.slice(K+f.length);i?.(ee),requestAnimationFrame(()=>{l.selectionStart=l.selectionEnd=s-f.length})}}else{const d=t.slice(0,s)+f+t.slice(p);i?.(d),requestAnimationFrame(()=>{l.selectionStart=l.selectionEnd=s+f.length})}}},[t,i,I]),y=n.useCallback(async u=>{if(!F)return;const l=Array.from(u.dataTransfer.files).filter(s=>s.type.startsWith("image/"));if(l.length!==0){u.preventDefault();for(const s of l){const p=await F(s),f=b.current;if(!f)continue;const d=f.selectionStart,$=`![${s.name}](${p})
689
+ `,K=t.slice(0,d)+$+t.slice(d);i?.(K)}}},[t,i,F]),c=o!=="tab"||O==="edit",L=o==="side"||o==="tab"&&O==="preview"||o===!0,C=`nice-md-editor nice-md-editor--${w} nice-editor--${_} nice-md-editor--preview-${o}${A?" nice-md-editor--fullscreen":""} ${G||""}`;return e.jsxs("div",{ref:v,id:k,className:C,style:{position:"relative",...H},children:[e.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:20},children:e.jsx(q.wl,{steps:q.xl(P,Bi)})}),R&&e.jsxs("div",{className:"nice-md-editor__toolbar",children:[Yi.map((u,l)=>e.jsxs(n.Fragment,{children:[l>0&&e.jsx("span",{className:"nice-md-editor__sep"}),Ui.filter(s=>s.group===u).map(s=>e.jsx("button",{type:"button",className:"nice-md-editor__btn",title:s.shortcut?`${s.tip} (${s.shortcut})`:s.tip,disabled:m||g,onClick:()=>I(s.md),children:s.label},s.key))]},u)),e.jsx("span",{className:"nice-md-editor__sep"}),e.jsx("button",{type:"button",className:"nice-md-editor__btn",title:"Fullscreen",onClick:()=>E(!A),children:A?"⊙":"⛶"}),x&&e.jsx("button",{type:"button",className:"nice-md-editor__btn",title:"Export HTML",onClick:()=>x(h),children:"↗"}),o==="tab"&&e.jsxs("span",{className:"nice-md-editor__tabs",children:[e.jsx("button",{type:"button",className:`nice-md-editor__tab${O==="edit"?" nice-md-editor__tab--active":""}`,onClick:()=>j("edit"),children:"Edit"}),e.jsx("button",{type:"button",className:`nice-md-editor__tab${O==="preview"?" nice-md-editor__tab--active":""}`,onClick:()=>j("preview"),children:"Preview"})]})]}),e.jsxs("div",{className:"nice-md-editor__body",style:{minHeight:z},children:[c&&e.jsxs("div",{className:"nice-md-editor__editor-wrap",children:[B&&e.jsx("div",{className:"nice-md-editor__line-numbers",children:Array.from({length:M.lines},(u,l)=>e.jsx("div",{className:"nice-md-editor__line-no",children:l+1},l))}),e.jsx("textarea",{ref:b,className:"nice-md-editor__textarea",value:t,onChange:u=>i?.(u.target.value),onKeyDown:S,onDrop:y,placeholder:a,disabled:m,readOnly:g,style:{minHeight:z}})]}),L&&e.jsx("div",{className:"nice-md-editor__preview",dangerouslySetInnerHTML:{__html:q.$s(h)},style:{minHeight:z}})]}),Y&&e.jsxs("div",{className:"nice-md-editor__statusbar",children:[e.jsxs("span",{children:[M.words," words"]}),e.jsxs("span",{children:[M.chars," chars"]}),e.jsxs("span",{children:[M.lines," lines"]})]})]})});_n.displayName="NiceMarkdownEditor";const Wi=[{target:".nice-image-editor",titleKey:"tutorial.imageEditor.intro.title",title:"Image editor",contentKey:"tutorial.imageEditor.intro.content",content:"Use the toolbar to crop, rotate, flip, adjust brightness/contrast and annotate; undo/redo your edits, then save the result.",placement:"auto"}],Ut={rotation:0,flipH:!1,flipV:!1,brightness:100,contrast:100,saturate:100,blur:0,crop:null,annotations:[]},Vi=["crop","rotate","flip","brightness","contrast","saturate","blur","annotate"],vn=n.forwardRef(({src:t,size:i="md",editorSize:o="standard",tools:a=Vi,showToolbar:m=!0,showZoom:g=!0,maxUndo:w=30,onSave:_,onCancel:R,onChange:z,width:Y="100%",height:B=500,tutorial:x,className:F,style:P,id:G,...H},U)=>{const v=q._s(G),{t:k}=q.Zt(),O=n.useRef(null),j=n.useRef(null),[A,E]=n.useState({...Ut}),[b,h]=n.useState(null),[M,I]=n.useState(!1),[S,y]=n.useState(1),[c,L]=n.useState("rect"),[C,u]=n.useState("var(--nice-danger, #ff0000)"),[l,s]=n.useState({w:0,h:0}),[p,f]=n.useState([]),[d,$]=n.useState([]),[K,ee]=n.useState(null),[D,ge]=n.useState(null),[re,ye]=n.useState(null),ne=n.useCallback(W=>{f(N=>[...N.slice(-(w-1)),W]),$([])},[w]),se=n.useCallback(W=>{E(N=>{ne(N);const Z={...N,...W};return z?.(Z),Z})},[z,ne]),le=n.useCallback(()=>{if(p.length===0)return;const W=p[p.length-1];f(N=>N.slice(0,-1)),$(N=>[...N,A]),E(W),z?.(W)},[p,A,z]),ue=n.useCallback(()=>{if(d.length===0)return;const W=d[d.length-1];$(N=>N.slice(0,-1)),f(N=>[...N,A]),E(W),z?.(W)},[d,A,z]);n.useEffect(()=>{const W=new Image;W.crossOrigin="anonymous",W.onload=()=>{j.current=W,s({w:W.width,h:W.height}),I(!0)},W.src=t},[t]),n.useEffect(()=>{if(!M||!O.current||!j.current)return;const W=O.current,N=W.getContext("2d");if(!N)return;const Z=j.current,fe=A.rotation%180!==0,Q=fe?Z.height:Z.width,V=fe?Z.width:Z.height;W.width=Q,W.height=V,N.clearRect(0,0,Q,V),N.save(),N.filter=`brightness(${A.brightness}%) contrast(${A.contrast}%) saturate(${A.saturate}%) blur(${A.blur}px)`,N.translate(Q/2,V/2),N.rotate(A.rotation*Math.PI/180),N.scale(A.flipH?-1:1,A.flipV?-1:1),N.drawImage(Z,-Z.width/2,-Z.height/2),N.restore(),A.annotations.forEach(me=>{switch(N.save(),N.strokeStyle=me.color??"red",N.fillStyle=me.color??"red",N.lineWidth=me.strokeWidth??2,N.font=`${me.fontSize??16}px sans-serif`,me.type){case"text":N.fillText(me.text??"",me.x,me.y);break;case"rect":N.strokeRect(me.x,me.y,me.width??100,me.height??50);break;case"circle":{const xe=(me.width??50)/2,ke=(me.height??50)/2;N.beginPath(),N.ellipse(me.x+xe,me.y+ke,xe,ke,0,0,Math.PI*2),N.stroke();break}case"line":N.beginPath(),N.moveTo(me.x,me.y),N.lineTo(me.x+(me.width??100),me.y+(me.height??0)),N.stroke();break;case"arrow":{const xe=me.x+(me.width??100),ke=me.y+(me.height??0);N.beginPath(),N.moveTo(me.x,me.y),N.lineTo(xe,ke),N.stroke();const ve=Math.atan2(ke-me.y,xe-me.x),we=10;N.beginPath(),N.moveTo(xe,ke),N.lineTo(xe-we*Math.cos(ve-.4),ke-we*Math.sin(ve-.4)),N.lineTo(xe-we*Math.cos(ve+.4),ke-we*Math.sin(ve+.4)),N.closePath(),N.fill();break}}N.restore()}),D&&(N.save(),N.fillStyle="var(--nice-overlay-50, rgba(0, 0, 0, 0.5))",N.fillRect(0,0,Q,V),N.clearRect(D.x,D.y,D.w,D.h),N.strokeStyle="var(--bg-primary, #fff)",N.lineWidth=2,N.setLineDash([5,5]),N.strokeRect(D.x,D.y,D.w,D.h),N.restore())},[M,A,D]);const be=n.useCallback(W=>{if(!O.current)return;const N=O.current.getBoundingClientRect(),Z=O.current.width/N.width,fe=O.current.height/N.height,Q=(W.clientX-N.left)*Z,V=(W.clientY-N.top)*fe;b==="crop"?ee({startX:Q,startY:V}):b==="annotate"&&ye({startX:Q,startY:V})},[b]),te=n.useCallback(W=>{if(!O.current)return;const N=O.current.getBoundingClientRect(),Z=O.current.width/N.width,fe=O.current.height/N.height,Q=(W.clientX-N.left)*Z,V=(W.clientY-N.top)*fe;K&&ge({x:Math.min(K.startX,Q),y:Math.min(K.startY,V),w:Math.abs(Q-K.startX),h:Math.abs(V-K.startY)})},[K]),ce=n.useCallback(W=>{if(K&&D&&D.w>5&&D.h>5&&se({crop:{x:D.x,y:D.y,width:D.w,height:D.h}}),ee(null),re&&O.current){const N=O.current.getBoundingClientRect(),Z=O.current.width/N.width,fe=O.current.height/N.height,Q=(W.clientX-N.left)*Z,V=(W.clientY-N.top)*fe,me=Q-re.startX,xe=V-re.startY;if(Math.abs(me)>3||Math.abs(xe)>3||c==="text"){const ke={type:c,x:re.startX,y:re.startY,width:Math.abs(me)||100,height:Math.abs(xe)||50,color:C,strokeWidth:2,text:c==="text"?prompt(k("imageEditor.annotationText","Text:"))??"":void 0};se({annotations:[...A.annotations,ke]})}ye(null)}},[K,D,re,c,C,A.annotations,se,k]),de=n.useCallback(()=>{if(!A.crop||!O.current)return;const W=O.current,N=W.getContext("2d");if(!N)return;const{x:Z,y:fe,width:Q,height:V}=A.crop,me=N.getImageData(Z,fe,Q,V);W.width=Q,W.height=V,N.putImageData(me,0,0),ge(null),h(null)},[A.crop]),oe=n.useCallback(()=>{if(!O.current)return;const W=O.current.toDataURL("image/png");_?.(W,A)},[_,A]),J=n.useCallback(()=>{E({...Ut}),ge(null),h(null)},[]);return n.useMemo(()=>`brightness(${A.brightness}%) contrast(${A.contrast}%) saturate(${A.saturate}%) blur(${A.blur}px)`,[A.brightness,A.contrast,A.saturate,A.blur]),e.jsxs("div",{ref:U,id:v,className:`nice-image-editor nice-image-editor--${i} nice-editor--${o} ${F??""}`,style:{position:"relative",...P,width:Y,height:B},role:"application","aria-label":k("imageEditor.label","Image Editor"),...H,children:[e.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:20},children:e.jsx(q.wl,{steps:q.xl(x,Wi)})}),m&&e.jsxs("div",{className:"nice-image-editor__toolbar",role:"toolbar",children:[e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:le,disabled:p.length===0,title:k("imageEditor.undo","Undo"),children:"↶"}),e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:ue,disabled:d.length===0,title:k("imageEditor.redo","Redo"),children:"↷"}),e.jsx("span",{className:"nice-image-editor__sep"}),a.includes("rotate")&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>se({rotation:(A.rotation-90+360)%360}),title:k("imageEditor.rotateLeft","Rotate left"),children:"↺"}),e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>se({rotation:(A.rotation+90)%360}),title:k("imageEditor.rotateRight","Rotate right"),children:"↻"})]}),a.includes("flip")&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>se({flipH:!A.flipH}),title:k("imageEditor.flipH","Flip horizontal"),children:"⇔"}),e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>se({flipV:!A.flipV}),title:k("imageEditor.flipV","Flip vertical"),children:"⇕"})]}),a.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:()=>h(b==="crop"?null:"crop"),title:k("imageEditor.crop","Crop"),children:"⊡"}),b==="crop"&&A.crop&&e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:de,title:k("imageEditor.applyCrop","Apply crop"),children:"✓"})]}),a.includes("brightness")&&e.jsxs("label",{className:"nice-image-editor__slider-label",children:[k("imageEditor.brightness","☀"),e.jsx("input",{type:"range",min:0,max:200,value:A.brightness,onChange:W=>se({brightness:Number(W.target.value)}),className:"nice-image-editor__slider",title:k("imageEditor.brightness","Brightness")})]}),a.includes("contrast")&&e.jsxs("label",{className:"nice-image-editor__slider-label",children:[k("imageEditor.contrast","◑"),e.jsx("input",{type:"range",min:0,max:200,value:A.contrast,onChange:W=>se({contrast:Number(W.target.value)}),className:"nice-image-editor__slider",title:k("imageEditor.contrast","Contrast")})]}),a.includes("saturate")&&e.jsxs("label",{className:"nice-image-editor__slider-label",children:[k("imageEditor.saturate","🎨"),e.jsx("input",{type:"range",min:0,max:200,value:A.saturate,onChange:W=>se({saturate:Number(W.target.value)}),className:"nice-image-editor__slider",title:k("imageEditor.saturate","Saturation")})]}),a.includes("blur")&&e.jsxs("label",{className:"nice-image-editor__slider-label",children:[k("imageEditor.blur","⊘"),e.jsx("input",{type:"range",min:0,max:20,step:.5,value:A.blur,onChange:W=>se({blur:Number(W.target.value)}),className:"nice-image-editor__slider",title:k("imageEditor.blur","Blur")})]}),a.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:()=>h(b==="annotate"?null:"annotate"),title:k("imageEditor.annotate","Annotate"),children:"✎"}),b==="annotate"&&e.jsxs(e.Fragment,{children:[e.jsxs("select",{className:"nice-image-editor__select",value:c,onChange:W=>L(W.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:C,onChange:W=>u(W.target.value),className:"nice-image-editor__color",title:k("imageEditor.color","Color")}),A.annotations.length>0&&e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>se({annotations:A.annotations.slice(0,-1)}),title:k("imageEditor.removeLastAnnotation","Remove last"),children:"⌫"})]})]}),e.jsx("span",{className:"nice-image-editor__sep"}),e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:J,title:k("imageEditor.reset","Reset"),children:"⟲"}),_&&e.jsx("button",{type:"button",className:"nice-image-editor__btn nice-image-editor__btn--save",onClick:oe,children:k("imageEditor.save","Save")}),R&&e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:R,children:k("imageEditor.cancel","Cancel")})]}),e.jsx("div",{className:"nice-image-editor__canvas-wrap",children:e.jsx("canvas",{ref:O,className:"nice-image-editor__canvas",onMouseDown:be,onMouseMove:te,onMouseUp:ce,style:{cursor:b==="crop"||b==="annotate"?"crosshair":"default",transform:`scale(${S})`,transformOrigin:"center center"}})}),g&&e.jsxs("div",{className:"nice-image-editor__footer",children:[e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>y(W=>Math.max(.1,W-.1)),title:"Zoom out",children:"−"}),e.jsxs("span",{style:{fontSize:"0.85em",minWidth:40,textAlign:"center"},children:[Math.round(S*100),"%"]}),e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>y(W=>Math.min(5,W+.1)),title:"Zoom in",children:"+"}),e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>y(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:[l.w,"×",l.h,"px · ",A.rotation,"°"]})]})]})});vn.displayName="NiceImageEditor";const kn=n.forwardRef(({value:t,onChange:i,penColor:o="var(--text-primary, #000)",penWidth:a=2,backgroundColor:m="var(--bg-primary, #fff)",width:g=400,height:w=200,size:_="md",disabled:R=!1,readOnly:z=!1,showClear:Y=!0,showUndo:B=!0,label:x,exportFormat:F="image/png",className:P,style:G,id:H,...U},v)=>{const k=q._s(H),{t:O}=q.Zt(),j=n.useRef(null),[A,E]=n.useState(!1),b=n.useRef([]),h=n.useRef([]),[M,I]=n.useState(!0),S=n.useCallback(()=>{const s=j.current;if(!s)return;const p=s.getContext("2d");if(p){p.fillStyle=m,p.fillRect(0,0,s.width,s.height),p.strokeStyle=o,p.lineWidth=a,p.lineCap="round",p.lineJoin="round";for(const f of b.current)if(!(f.length<2)){p.beginPath(),p.moveTo(f[0].x,f[0].y);for(let d=1;d<f.length;d++)p.lineTo(f[d].x,f[d].y);p.stroke()}}},[m,o,a]);n.useEffect(()=>{if(t&&j.current){const s=new Image;s.onload=()=>{const p=j.current?.getContext("2d");!p||!j.current||(p.fillStyle=m,p.fillRect(0,0,j.current.width,j.current.height),p.drawImage(s,0,0),I(!1))},s.src=t}else t||(b.current=[],I(!0),S())},[t,m,S]),n.useEffect(()=>{const s=j.current;s&&(s.width=g,s.height=w,S())},[g,w,S]);const y=n.useCallback(s=>{const p=j.current,f=p.getBoundingClientRect(),d=p.width/f.width,$=p.height/f.height;if("touches"in s){const K=s.touches[0];return{x:(K.clientX-f.left)*d,y:(K.clientY-f.top)*$}}return{x:(s.clientX-f.left)*d,y:(s.clientY-f.top)*$}},[]),c=n.useCallback(s=>{if(R||z)return;s.preventDefault();const p=y(s);h.current=[p],E(!0)},[R,z,y]),L=n.useCallback(s=>{if(!A)return;s.preventDefault();const p=y(s);h.current.push(p);const f=j.current,d=f?.getContext("2d");if(!d||!f)return;const $=h.current;$.length>=2&&(d.strokeStyle=o,d.lineWidth=a,d.lineCap="round",d.beginPath(),d.moveTo($[$.length-2].x,$[$.length-2].y),d.lineTo(p.x,p.y),d.stroke())},[A,y,o,a]),C=n.useCallback(()=>{if(A&&(E(!1),h.current.length>0&&(b.current.push([...h.current]),h.current=[],I(!1),j.current))){const s=j.current.toDataURL(F);i?.(s)}},[A,F,i]),u=n.useCallback(()=>{b.current=[],h.current=[],I(!0),S(),i?.(null)},[S,i]),l=n.useCallback(()=>{if(b.current.length!==0&&(b.current.pop(),I(b.current.length===0),S(),j.current)){const s=b.current.length>0?j.current.toDataURL(F):null;i?.(s)}},[S,F,i]);return e.jsxs("div",{ref:v,id:k,className:`nice-signature nice-signature--${_} ${R?"nice-signature--disabled":""} ${z?"nice-signature--readonly":""} ${P??""}`,style:G,...U,children:[x&&e.jsx("label",{className:"nice-signature__label",children:x}),e.jsx("div",{className:"nice-signature__canvas-wrap",style:{width:g,height:w},children:e.jsx("canvas",{ref:j,className:"nice-signature__canvas",onMouseDown:c,onMouseMove:L,onMouseUp:C,onMouseLeave:C,onTouchStart:c,onTouchMove:L,onTouchEnd:C,style:{touchAction:"none",cursor:R||z?"default":"crosshair"},"aria-label":x??O("signature.label","Signature pad"),role:"img"})}),(Y||B)&&!z&&!R&&e.jsxs("div",{className:"nice-signature__actions",children:[B&&e.jsx("button",{type:"button",className:"nice-signature__btn",onClick:l,disabled:M,children:O("signature.undo","Undo")}),Y&&e.jsx("button",{type:"button",className:"nice-signature__btn",onClick:u,disabled:M,children:O("signature.clear","Clear")})]})]})});kn.displayName="NiceSignaturePad";const Xi=[{target:".nice-doc-editor",titleKey:"tutorial.documentEditor.intro.title",title:"Document editor",contentKey:"tutorial.documentEditor.intro.content",content:"Compose a document from blocks: use the toolbar or slash commands to add headings, lists, media and more, then export to HTML.",placement:"auto"}];let qi=0;function bt(){return`blk-${++qi}-${Date.now().toString(36)}`}function Yt(t=""){return{id:bt(),type:"paragraph",content:t}}function Gi(t,i=""){const o={id:bt(),type:t,content:i};return t==="heading"&&(o.level=2),t==="list"&&(o.listType="unordered"),t==="callout"&&(o.icon="??"),t==="toggle"&&(o.open=!0),o}const Zi=[{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 Ji(t){const i=[t.align?`text-align:${t.align}`:"",t.color?`color:${t.color}`:"",t.bgColor?`background-color:${t.bgColor}`:"",t.indent?`margin-left:${t.indent*24}px`:""].filter(Boolean).join(";"),o=i?` style="${i}"`:"",a=(m,g)=>{let w=g;return t.bold&&(w=`<strong>${w}</strong>`),t.italic&&(w=`<em>${w}</em>`),t.underline&&(w=`<u>${w}</u>`),t.strikethrough&&(w=`<s>${w}</s>`),`<${m}${o}>${w}</${m}>`};switch(t.type){case"heading":return a(`h${t.level??2}`,t.content);case"paragraph":return a("p",t.content||"&nbsp;");case"list":{const m=t.listType==="ordered"?"ol":"ul",g=t.content.split(`
690
+ `).map((w,_)=>t.listType==="checklist"?`<li><input type="checkbox" ${t.checked?.[_]??!1?"checked":""} disabled />${w}</li>`:`<li>${w}</li>`).join("");return`<${m}${o}>${g}</${m}>`}case"image":return`<figure${o}><img src="${t.src??""}" alt="${t.alt??""}" /></figure>`;case"video":return`<figure${o}><video src="${t.src??""}" controls></video></figure>`;case"divider":return"<hr />";case"pageBreak":return'<div style="page-break-after:always"></div>';case"code":return`<pre><code class="language-${t.language??""}">${t.content}</code></pre>`;case"quote":return a("blockquote",t.content);case"callout":return`<div class="nice-doc-callout"${o}><span>${t.icon??"??"}</span><div>${t.content}</div></div>`;case"toggle":return`<details${o}><summary>${t.content.split(`
691
+ `)[0]}</summary>${t.content.split(`
692
+ `).slice(1).join("<br>")}</details>`;case"table":return`<table${o}>${t.content}</table>`;case"embed":return`<iframe src="${t.src??""}" style="width:100%;border:none;min-height:300px"></iframe>`;default:return a("p",t.content)}}function Qi(t){let i=0,o=0;for(const a of t){const m=a.content??"";i+=m.length;const g=m.trim().split(/\s+/).filter(Boolean);o+=g.length}return{words:o,chars:i,readingTime:Math.max(1,Math.ceil(o/200))}}const wn=n.forwardRef(({blocks:t,onChange:i,readOnly:o=!1,showToolbar:a=!0,size:m="md",editorSize:g="standard",placeholder:w,onExport:_,onImageUpload:R,maxUndo:z=50,slashCommands:Y=!0,showWordCount:B=!1,showToc:x=!1,showFindReplace:F=!0,tutorial:P,className:G,style:H,id:U,...v},k)=>{const O=q._s(U),{t:j}=q.Zt(),[A,E]=n.useState(()=>t??[Yt()]),b=t??A,[h,M]=n.useState(0),I=n.useRef(new Map),S=n.useRef(null),[y,c]=n.useState(!1),[L,C]=n.useState(""),[u,l]=n.useState(""),[s,p]=n.useState([]),[f,d]=n.useState(0),[$,K]=n.useState(!1),ee=n.useRef([]),D=n.useRef([]),ge=n.useCallback(r=>{ee.current.push(r.map(T=>({...T,checked:T.checked?[...T.checked]:void 0}))),ee.current.length>z&&ee.current.shift(),D.current=[]},[z]),re=n.useCallback(()=>{if(ee.current.length===0)return;const r=ee.current.pop();D.current.push(b.map(T=>({...T}))),t||E(r),i?.(r)},[b,t,i]),ye=n.useCallback(()=>{if(D.current.length===0)return;const r=D.current.pop();ee.current.push(b.map(T=>({...T}))),t||E(r),i?.(r)},[b,t,i]),[ne,se]=n.useState(!1),[le,ue]=n.useState(""),[be,te]=n.useState(0),ce=n.useMemo(()=>{if(!ne||!Y)return[];const r=le.toLowerCase();return Zi.filter(T=>T.label.toLowerCase().includes(r)||T.keywords.includes(r))},[ne,le,Y]),[de,oe]=n.useState(null),[J,W]=n.useState(null),N=n.useCallback(r=>{ge(b);const T=r(b);t||E(T),i?.(T)},[b,t,i,ge]),Z=n.useCallback((r,T)=>{N(X=>X.map((ae,pe)=>pe===r?{...ae,...T}:ae))},[N]),fe=n.useCallback((r,T)=>{const X=T??Yt();N(ae=>{const pe=[...ae];return pe.splice(r+1,0,X),pe}),M(r+1)},[N]),Q=n.useCallback(r=>{const T={...b[r],id:bt()};fe(r,T)},[b,fe]),V=n.useCallback(r=>{b.length<=1||(N(T=>T.filter((X,ae)=>ae!==r)),M(Math.max(0,r-1)))},[b.length,N]),me=n.useCallback((r,T)=>{const X=r+T;X<0||X>=b.length||(N(ae=>{const pe=[...ae];return[pe[r],pe[X]]=[pe[X],pe[r]],pe}),M(X))},[b.length,N]),xe=n.useCallback((r,T)=>{const X={type:T};T==="heading"&&(X.level=2),T==="list"&&(X.listType="unordered"),T==="callout"&&(X.icon="??"),T==="toggle"&&(X.open=!0),Z(r,X)},[Z]),ke=n.useCallback(r=>{const T=Gi(r.type);r.type==="list"&&r.label.includes("Numbered")&&(T.listType="ordered"),r.type==="list"&&r.label.includes("Checklist")&&(T.listType="checklist",T.checked=[]),b[h]?.content===""||b[h]?.content==="/"?N(X=>X.map((ae,pe)=>pe===h?{...T,id:ae.id}:ae)):fe(h,T),se(!1),ue("")},[b,h,N,fe]),ve=n.useCallback((r,T)=>{if(o)return;const X=b[T];if(!X?.locked){if((r.ctrlKey||r.metaKey)&&r.key==="z"&&!r.shiftKey){r.preventDefault(),re();return}if((r.ctrlKey||r.metaKey)&&(r.key==="y"||r.key==="z"&&r.shiftKey)){r.preventDefault(),ye();return}if((r.ctrlKey||r.metaKey)&&r.key==="d"){r.preventDefault(),Q(T);return}if((r.ctrlKey||r.metaKey)&&r.key==="b"){r.preventDefault(),Z(T,{bold:!X?.bold});return}if((r.ctrlKey||r.metaKey)&&r.key==="i"){r.preventDefault(),Z(T,{italic:!X?.italic});return}if((r.ctrlKey||r.metaKey)&&r.key==="u"){r.preventDefault(),Z(T,{underline:!X?.underline});return}if((r.ctrlKey||r.metaKey)&&r.key==="e"){r.preventDefault(),Z(T,{strikethrough:!X?.strikethrough});return}if(r.key==="Tab"&&!r.shiftKey){r.preventDefault(),Z(T,{indent:Math.min((X?.indent??0)+1,4)});return}if(r.key==="Tab"&&r.shiftKey){r.preventDefault(),Z(T,{indent:Math.max((X?.indent??0)-1,0)});return}if((r.ctrlKey||r.metaKey)&&r.key==="f"&&F){r.preventDefault(),c(ae=>!ae);return}if(ne&&ce.length>0){if(r.key==="ArrowDown"){r.preventDefault(),te(ae=>Math.min(ae+1,ce.length-1));return}if(r.key==="ArrowUp"){r.preventDefault(),te(ae=>Math.max(ae-1,0));return}if(r.key==="Enter"){r.preventDefault(),ke(ce[be]);return}if(r.key==="Escape"){se(!1);return}}r.key==="Enter"&&!r.shiftKey?(r.preventDefault(),fe(T)):r.key==="Backspace"&&b[T].content===""&&b.length>1?(r.preventDefault(),V(T)):r.key==="ArrowUp"&&r.altKey?(r.preventDefault(),me(T,-1)):r.key==="ArrowDown"&&r.altKey&&(r.preventDefault(),me(T,1))}},[o,b,fe,V,me,re,ye,Q,Z,ne,ce,be,ke,F]),we=n.useCallback((r,T)=>{const X=r.target.textContent??"";Y&&X.startsWith("/")?(se(!0),ue(X.slice(1)),te(0)):ne&&se(!1),ge(b);const ae=b.map((pe,Ne)=>Ne===T?{...pe,content:X}:pe);t||E(ae),i?.(ae)},[b,t,i,ge,Y,ne]),Re=n.useCallback((r,T)=>{oe(T),r.dataTransfer.effectAllowed="move"},[]),Be=n.useCallback((r,T)=>{r.preventDefault(),r.dataTransfer.dropEffect="move",W(T)},[]),Te=n.useCallback((r,T)=>{if(r.preventDefault(),de===null||de===T){oe(null),W(null);return}N(X=>{const ae=[...X],[pe]=ae.splice(de,1);return ae.splice(T>de?T-1:T,0,pe),ae}),M(T>de?T-1:T),oe(null),W(null)},[de,N]);n.useEffect(()=>{if(!y||!L){p([]);return}const r=L.toLowerCase(),T=[];b.forEach((X,ae)=>{const pe=(X.content??"").toLowerCase();let Ne=0;for(;Ne<pe.length;){const Se=pe.indexOf(r,Ne);if(Se===-1)break;T.push({blockIdx:ae,start:Se,end:Se+r.length}),Ne=Se+1}}),p(T),d(0)},[L,y,b]);const Ae=n.useCallback(()=>{if(s.length===0)return;const r=(f+1)%s.length;d(r),M(s[r].blockIdx)},[s,f]),Ke=n.useCallback(()=>{if(s.length===0)return;const r=(f-1+s.length)%s.length;d(r),M(s[r].blockIdx)},[s,f]),Ue=n.useCallback(()=>{if(s.length===0||!L)return;const r=s[f],T=b[r.blockIdx],X=T.content.slice(0,r.start),ae=T.content.slice(r.end);Z(r.blockIdx,{content:X+u+ae})},[s,f,L,u,b,Z]),Ye=n.useCallback(()=>{if(!L)return;const r=L;N(T=>T.map(X=>({...X,content:X.content.split(r).join(u)})))},[L,u,N]),Le=n.useMemo(()=>x?b.map((r,T)=>r.type==="heading"?{idx:T,level:r.level??2,text:r.content}:null).filter(Boolean):[],[b,x]),De=n.useCallback(async r=>{const T=r.target.files?.[0];if(T){if(R){const X=await R(T);Z(h,{src:X})}r.target.value=""}},[R,h,Z]);n.useEffect(()=>{const r=b[h];if(r){const T=I.current.get(r.id);T&&T.focus()}},[h,b]);const ze=n.useCallback(()=>{const r=b.map(Ji).join(`
693
+ `);_?.(r)},[b,_]),ie=n.useMemo(()=>B?Qi(b):null,[b,B]),[he,_e]=n.useState(null),Me=n.useCallback((r,T)=>{o||(r.preventDefault(),_e({x:r.clientX,y:r.clientY,idx:T}))},[o]);return n.useEffect(()=>{if(!he)return;const r=()=>_e(null);return window.addEventListener("click",r),()=>window.removeEventListener("click",r)},[he]),e.jsxs("div",{ref:k,id:O,className:`nice-doc-editor nice-doc-editor--${m} nice-editor--${g} ${o?"nice-doc-editor--readonly":""} ${G??""}`,style:{position:"relative",...H},role:"application","aria-label":j("docEditor.label","Document Editor"),...v,children:[e.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:20},children:e.jsx(q.wl,{steps:q.xl(P,Xi)})}),a&&!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(je.NiceButton,{size:"sm",variant:"ghost",onClick:re,title:j("docEditor.undo","Undo (Ctrl+Z)"),children:"?"}),e.jsx(je.NiceButton,{size:"sm",variant:"ghost",onClick:ye,title:j("docEditor.redo","Redo (Ctrl+Y)"),children:"?"}),e.jsx("span",{className:"nice-doc-editor__sep"}),e.jsx(je.NiceSelect,{size:"sm",value:b[h]?.type??"paragraph",onChange:r=>xe(h,r),label:"",options:[{value:"paragraph",label:j("docEditor.paragraph","Paragraph")},{value:"heading",label:j("docEditor.heading","Heading")},{value:"list",label:j("docEditor.list","List")},{value:"code",label:j("docEditor.code","Code")},{value:"quote",label:j("docEditor.quote","Quote")},{value:"callout",label:j("docEditor.callout","Callout")},{value:"toggle",label:j("docEditor.toggle","Toggle")},{value:"divider",label:j("docEditor.divider","Divider")},{value:"image",label:j("docEditor.image","Image")},{value:"video",label:j("docEditor.video","Video")},{value:"pageBreak",label:j("docEditor.pageBreak","Page Break")}],style:{minWidth:100}}),b[h]?.type==="heading"&&e.jsx(je.NiceSelect,{size:"sm",value:String(b[h]?.level??2),onChange:r=>Z(h,{level:Number(r)}),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[h]?.type==="list"&&e.jsx(je.NiceSelect,{size:"sm",value:b[h]?.listType??"unordered",onChange:r=>Z(h,{listType:r}),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(je.NiceButton,{size:"sm",variant:b[h]?.bold?"primary":"ghost",onClick:()=>Z(h,{bold:!b[h]?.bold}),title:j("docEditor.bold","Bold (Ctrl+B)"),children:e.jsx("strong",{children:"B"})}),e.jsx(je.NiceButton,{size:"sm",variant:b[h]?.italic?"primary":"ghost",onClick:()=>Z(h,{italic:!b[h]?.italic}),title:j("docEditor.italic","Italic (Ctrl+I)"),children:e.jsx("em",{children:"I"})}),e.jsx(je.NiceButton,{size:"sm",variant:b[h]?.underline?"primary":"ghost",onClick:()=>Z(h,{underline:!b[h]?.underline}),title:j("docEditor.underline","Underline (Ctrl+U)"),children:e.jsx("u",{children:"U"})}),e.jsx(je.NiceButton,{size:"sm",variant:b[h]?.strikethrough?"primary":"ghost",onClick:()=>Z(h,{strikethrough:!b[h]?.strikethrough}),title:j("docEditor.strikethrough","Strikethrough (Ctrl+E)"),children:e.jsx("s",{children:"S"})}),e.jsx("span",{className:"nice-doc-editor__sep"}),e.jsx(je.NiceButton,{size:"sm",variant:b[h]?.align==="left"?"primary":"ghost",onClick:()=>Z(h,{align:"left"}),title:j("docEditor.alignLeft","Left"),children:"?"}),e.jsx(je.NiceButton,{size:"sm",variant:b[h]?.align==="center"?"primary":"ghost",onClick:()=>Z(h,{align:"center"}),title:j("docEditor.alignCenter","Center"),children:"?"}),e.jsx(je.NiceButton,{size:"sm",variant:b[h]?.align==="right"?"primary":"ghost",onClick:()=>Z(h,{align:"right"}),title:j("docEditor.alignRight","Right"),children:"?"}),e.jsx("span",{className:"nice-doc-editor__sep"}),e.jsx(je.NiceButton,{size:"sm",variant:"ghost",onClick:()=>Z(h,{indent:Math.min((b[h]?.indent??0)+1,4)}),title:j("docEditor.indent","Indent (Tab)"),children:"??"}),e.jsx(je.NiceButton,{size:"sm",variant:"ghost",onClick:()=>Z(h,{indent:Math.max((b[h]?.indent??0)-1,0)}),title:j("docEditor.outdent","Outdent (Shift+Tab)"),children:"??"}),e.jsx("span",{className:"nice-doc-editor__sep"}),e.jsx(je.NiceColorPicker,{size:"sm",label:"",value:b[h]?.color??"var(--text-primary, #000000)",onChange:r=>Z(h,{color:r}),title:"Text color"}),e.jsx(je.NiceColorPicker,{size:"sm",label:"",value:b[h]?.bgColor??"var(--bg-primary, #ffffff)",onChange:r=>Z(h,{bgColor:r}),title:"Block background"}),e.jsx("span",{className:"nice-doc-editor__sep"}),e.jsx(je.NiceButton,{size:"sm",variant:b[h]?.locked?"primary":"ghost",onClick:()=>Z(h,{locked:!b[h]?.locked}),title:j("docEditor.lock","Lock/Unlock block"),children:"??"}),e.jsx(je.NiceButton,{size:"sm",variant:"ghost",onClick:()=>Q(h),title:j("docEditor.duplicate","Duplicate (Ctrl+D)"),children:"?"}),e.jsx(je.NiceButton,{size:"sm",variant:"ghost",onClick:()=>V(h),title:j("docEditor.delete","Delete block"),children:"??"}),e.jsx(je.NiceButton,{size:"sm",variant:"ghost",onClick:()=>fe(h),title:j("docEditor.addBlock","Add block"),children:"+"}),F&&e.jsx(je.NiceButton,{size:"sm",variant:y?"primary":"ghost",onClick:()=>c(r=>!r),title:j("docEditor.find","Find & Replace (Ctrl+F)"),children:"??"}),e.jsx(je.NiceButton,{size:"sm",variant:"ghost",onClick:()=>K(r=>!r),title:j("docEditor.shortcuts","Keyboard shortcuts"),children:"?"}),_&&e.jsx(je.NiceButton,{size:"sm",variant:"ghost",onClick:ze,children:j("docEditor.export","Export HTML")})]}),e.jsx("input",{ref:S,type:"file",accept:"image/*,video/*",style:{display:"none"},onChange:De}),y&&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(je.NiceTextInput,{size:"sm",placeholder:j("docEditor.findPlaceholder","Find..."),value:L,onChange:C,style:{flex:1,maxWidth:200}}),e.jsx(je.NiceTextInput,{size:"sm",placeholder:j("docEditor.replacePlaceholder","Replace..."),value:u,onChange:l,style:{flex:1,maxWidth:200}}),e.jsx(je.NiceButton,{size:"sm",variant:"ghost",onClick:Ke,title:j("docEditor.findPrev","Previous"),children:"?"}),e.jsx(je.NiceButton,{size:"sm",variant:"ghost",onClick:Ae,title:j("docEditor.findNext","Next"),children:"?"}),e.jsx(je.NiceButton,{size:"sm",variant:"ghost",onClick:Ue,title:j("docEditor.replaceOne","Replace"),disabled:o,children:j("docEditor.replace","Replace")}),e.jsx(je.NiceButton,{size:"sm",variant:"ghost",onClick:Ye,title:j("docEditor.replaceAll","Replace all"),disabled:o,children:j("docEditor.replaceAllBtn","All")}),e.jsx("span",{style:{fontSize:"0.75em",color:"var(--text-muted, #666)"},children:s.length>0?`${f+1}/${s.length}`:"0/0"}),e.jsx(je.NiceButton,{size:"sm",variant:"ghost",onClick:()=>c(!1),children:"?"})]}),$&&e.jsx("div",{className:"nice-doc-editor__shortcuts-overlay",style:{position:"fixed",inset:0,background:"var(--nice-overlay-40, rgba(0, 0, 0, 0.4))",zIndex:9999,display:"flex",alignItems:"center",justifyContent:"center"},onClick:()=>K(!1),children:e.jsxs("div",{style:{background:"var(--bg-primary, #fff)",borderRadius:8,padding:24,maxWidth:420,width:"90%",boxShadow:"0 8px 32px var(--nice-overlay-20, rgba(0, 0, 0, 0.2))"},onClick:r=>r.stopPropagation(),children:[e.jsx("h3",{style:{margin:"0 0 12px"},children:j("docEditor.shortcutsTitle","Keyboard Shortcuts")}),e.jsx("table",{style:{width:"100%",fontSize:"0.875em",borderCollapse:"collapse"},children:e.jsx("tbody",{children:[["Ctrl+B",j("docEditor.bold","Bold")],["Ctrl+I",j("docEditor.italic","Italic")],["Ctrl+U",j("docEditor.underline","Underline")],["Ctrl+E",j("docEditor.strikethrough","Strikethrough")],["Ctrl+D",j("docEditor.duplicate","Duplicate block")],["Ctrl+Z",j("docEditor.undo","Undo")],["Ctrl+Y",j("docEditor.redo","Redo")],["Ctrl+F",j("docEditor.find","Find & Replace")],["Enter",j("docEditor.newBlock","New block")],["Backspace",j("docEditor.deleteEmpty","Delete empty block")],["Alt+?",j("docEditor.moveUp","Move block up")],["Alt+?",j("docEditor.moveDown","Move block down")],["Tab",j("docEditor.indent","Indent")],["Shift+Tab",j("docEditor.outdent","Outdent")],["/",j("docEditor.slashCmd","Slash commands")]].map(([r,T])=>e.jsxs("tr",{style:{borderBottom:"1px solid var(--border-color, #eee)"},children:[e.jsx("td",{style:{padding:"4px 8px",fontFamily:"monospace",fontWeight:600},children:r}),e.jsx("td",{style:{padding:"4px 8px"},children:T})]},r))})}),e.jsx("div",{style:{textAlign:"right",marginTop:12},children:e.jsx(je.NiceButton,{size:"sm",variant:"ghost",onClick:()=>K(!1),children:j("docEditor.close","Close")})})]})}),e.jsxs("div",{style:{display:"flex",gap:0},children:[x&&Le.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:j("docEditor.toc","Contents")}),Le.map(r=>e.jsx("div",{style:{padding:"3px 8px",paddingLeft:8+(r.level-1)*12,cursor:"pointer",borderRadius:4,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",background:r.idx===h?"var(--nice-primary-bg, #e8f0fe)":void 0},onClick:()=>M(r.idx),title:r.text,children:r.text||j("docEditor.untitled","Untitled")},r.idx))]}),e.jsx("div",{className:"nice-doc-editor__body",style:{flex:1},children:b.map((r,T)=>e.jsxs("div",{className:`nice-doc-editor__block nice-doc-editor__block--${r.type} ${T===h?"nice-doc-editor__block--focused":""} ${J===T?"nice-doc-editor__block--drop-target":""} ${r.locked?"nice-doc-editor__block--locked":""}`,onClick:()=>M(T),onContextMenu:X=>Me(X,T),draggable:!o&&!r.locked,onDragStart:X=>Re(X,T),onDragOver:X=>Be(X,T),onDrop:X=>Te(X,T),onDragEnd:()=>{oe(null),W(null)},style:{opacity:de===T?.4:1,marginLeft:(r.indent??0)*24},children:[!o&&!r.locked&&e.jsx("div",{className:"nice-doc-editor__block-handle",title:j("docEditor.drag","Drag to reorder"),children:"?"}),r.locked&&e.jsx("span",{className:"nice-doc-editor__lock-icon",style:{position:"absolute",top:2,right:4,fontSize:"0.7em",opacity:.5},children:"??"}),r.type==="divider"?e.jsx("hr",{className:"nice-doc-editor__divider"}):r.type==="pageBreak"?e.jsxs("div",{className:"nice-doc-editor__page-break",style:{borderTop:"2px dashed var(--nice-border, #ccc)",textAlign:"center",padding:4,fontSize:"0.75em",color:"var(--text-muted, #999)"},children:["� ",j("docEditor.pageBreak","Page Break")," �"]}):r.type==="image"||r.type==="video"?e.jsx("div",{className:"nice-doc-editor__media-block",children:r.src?r.type==="image"?e.jsx("img",{src:r.src,alt:r.alt??"",className:"nice-doc-editor__image",style:{maxWidth:"100%"}}):e.jsx("video",{src:r.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(je.NiceTextInput,{size:"sm",placeholder:j("docEditor.mediaUrl",r.type==="image"?"Image URL":"Video URL"),value:r.src??"",onChange:X=>Z(T,{src:X})}),R&&e.jsx(je.NiceButton,{size:"sm",variant:"ghost",onClick:()=>{M(T),S.current?.click()},children:"??"})]})}):r.type==="callout"?e.jsxs("div",{className:"nice-doc-editor__callout",style:{display:"flex",gap:8,padding:"8px 12px",background:r.bgColor??"#f0f7ff",borderRadius:4,color:r.color},children:[e.jsx("span",{style:{fontSize:"1.2em"},children:r.icon??"??"}),e.jsx("div",{ref:X=>{X&&I.current.set(r.id,X)},className:"nice-doc-editor__content",contentEditable:!o&&!r.locked,suppressContentEditableWarning:!0,onInput:X=>we(X,T),onFocus:()=>M(T),onKeyDown:X=>ve(X,T),"data-placeholder":j("docEditor.calloutPlaceholder","Callout text..."),role:"textbox","aria-multiline":"true",style:{flex:1,outline:"none"},children:r.content})]}):r.type==="toggle"?e.jsxs("details",{open:r.open,className:"nice-doc-editor__toggle",onToggle:X=>Z(T,{open:X.target.open}),children:[e.jsx("summary",{style:{cursor:"pointer",fontWeight:500},children:r.content.split(`
694
+ `)[0]||j("docEditor.toggleTitle","Toggle")}),e.jsx("div",{ref:X=>{X&&I.current.set(r.id,X)},className:"nice-doc-editor__content",contentEditable:!o&&!r.locked,suppressContentEditableWarning:!0,onInput:X=>we(X,T),onFocus:()=>M(T),onKeyDown:X=>ve(X,T),role:"textbox","aria-multiline":"true",style:{padding:"4px 0"},children:r.content.split(`
695
+ `).slice(1).join(`
696
+ `)})]}):r.type==="code"?e.jsxs("div",{className:"nice-doc-editor__code-block",style:{position:"relative"},children:[!o&&e.jsx(je.NiceTextInput,{size:"sm",value:r.language??"",onChange:X=>Z(T,{language:X}),placeholder:"Language",style:{position:"absolute",top:4,right:4,width:80,opacity:.7}}),e.jsx("pre",{ref:X=>{X&&I.current.set(r.id,X)},className:"nice-doc-editor__content",contentEditable:!o&&!r.locked,suppressContentEditableWarning:!0,onInput:X=>we(X,T),onFocus:()=>M(T),onKeyDown:X=>ve(X,T),role:"textbox","aria-multiline":"true",style:{fontFamily:"monospace",background:"var(--bg-elevated, #1e1e1e)",color:"var(--text-secondary, #d4d4d4)",padding:12,borderRadius:4,overflow:"auto"},children:r.content})]}):e.jsxs("div",{style:{position:"relative"},children:[e.jsx("div",{ref:X=>{X&&I.current.set(r.id,X)},className:"nice-doc-editor__content",contentEditable:!o&&!r.locked,suppressContentEditableWarning:!0,style:{textAlign:r.align,fontWeight:r.bold?"bold":void 0,fontStyle:r.italic?"italic":void 0,textDecoration:[r.underline?"underline":"",r.strikethrough?"line-through":""].filter(Boolean).join(" ")||void 0,color:r.color,backgroundColor:r.bgColor},onInput:X=>we(X,T),onFocus:()=>M(T),onKeyDown:X=>ve(X,T),"data-placeholder":!r.content&&w?w:void 0,role:"textbox","aria-multiline":"true",children:r.content}),ne&&T===h&&ce.length>0&&e.jsx("ul",{className:"nice-doc-editor__slash-menu",style:{position:"absolute",left:0,top:"100%",zIndex:100,background:"var(--bg-primary, #fff)",border:"1px solid var(--border-color, #ddd)",borderRadius:6,boxShadow:"0 4px 16px var(--nice-overlay-12, rgba(0, 0, 0, 0.12))",listStyle:"none",margin:0,padding:4,minWidth:180,maxHeight:240,overflow:"auto"},children:ce.map((X,ae)=>e.jsxs("li",{className:ae===be?"nice-doc-editor__slash-item--active":"",style:{padding:"6px 10px",cursor:"pointer",borderRadius:4,display:"flex",gap:8,alignItems:"center",background:ae===be?"var(--nice-primary-bg, #e8f0fe)":void 0},onMouseDown:pe=>{pe.preventDefault(),ke(X)},onMouseEnter:()=>te(ae),children:[e.jsx("span",{style:{width:24,textAlign:"center"},children:X.icon}),e.jsx("span",{children:X.label})]},`${X.type}-${X.label}`))})]})]},r.id))})]}),he&&e.jsxs("div",{className:"nice-doc-editor__ctx-menu",style:{position:"fixed",left:he.x,top:he.y,zIndex:1e3,background:"var(--bg-primary, #fff)",border:"1px solid var(--border-color, #ddd)",borderRadius:6,boxShadow:"0 4px 16px var(--nice-overlay-12, rgba(0, 0, 0, 0.12))",padding:4,minWidth:160},children:[e.jsx("div",{style:{padding:"6px 12px",cursor:"pointer"},onClick:()=>{Q(he.idx),_e(null)},children:"? Duplicate"}),e.jsx("div",{style:{padding:"6px 12px",cursor:"pointer"},onClick:()=>{fe(he.idx),_e(null)},children:"+ Insert below"}),e.jsx("div",{style:{padding:"6px 12px",cursor:"pointer"},onClick:()=>{me(he.idx,-1),_e(null)},children:"? Move up"}),e.jsx("div",{style:{padding:"6px 12px",cursor:"pointer"},onClick:()=>{me(he.idx,1),_e(null)},children:"? Move down"}),e.jsx("div",{style:{padding:"6px 12px",cursor:"pointer"},onClick:()=>{Z(he.idx,{locked:!b[he.idx]?.locked}),_e(null)},children:b[he.idx]?.locked?"?? Unlock":"?? Lock"}),e.jsx("hr",{style:{margin:"2px 0",border:"none",borderTop:"1px solid var(--border-color, #eee)"}}),e.jsx("div",{style:{padding:"6px 12px",cursor:"pointer",color:"var(--nice-danger-dark, #d32f2f)"},onClick:()=>{V(he.idx),_e(null)},children:"?? Delete"})]}),B&&ie&&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:[ie.words," ",j("docEditor.words","words")]}),e.jsxs("span",{children:[ie.chars," ",j("docEditor.chars","characters")]}),e.jsxs("span",{children:[b.length," ",j("docEditor.blocks","blocks")]}),e.jsxs("span",{children:["~",ie.readingTime," ",j("docEditor.readingTime","min read")]})]})]})});wn.displayName="NiceDocumentEditor";const eo=["street","streetNumber","apartment","city","postalCode","state","country"],et={street:"Street",streetNumber:"Number",apartment:"Apt/Suite",city:"City",postalCode:"Postal Code",state:"State/Province",country:"Country"},Nn=n.forwardRef(({label:t,helperText:i,error:o,required:a,disabled:m,readOnly:g,size:w="md",name:_,id:R,className:z,style:Y,accessMode:B,value:x={},onChange:F,fields:P=eo,placeholders:G={},countries:H,layout:U="vertical",countryFirst:v=!1,validatePostalCode:k},O)=>{const j=q.sc(B,R),A=j==="hidden";j==="disabled"&&(m=!0),j==="readOnly"&&(g=!0);const{t:E}=q.Zt(),b=q._s(R),h=n.useCallback((y,c)=>{F?.({...x,[y]:c})},[x,F]),M=n.useMemo(()=>{if(k&&x.postalCode)return k(x.postalCode,x.country)},[k,x.postalCode,x.country]),I=n.useMemo(()=>v&&P.includes("country")?["country",...P.filter(y=>y!=="country")]:P,[P,v]),S=`nice-address nice-address--${U} nice-size-${w}`;return A?null:e.jsxs("div",{ref:O,id:b,className:`${S}${z?` ${z}`:""}${o?" nice-error":""}${m?" nice-disabled":""}`,style:Y,role:"group","aria-label":t??E("address","Address"),children:[t&&e.jsxs("label",{className:"nice-address__label",children:[t,a&&e.jsx("span",{className:"nice-required",children:"*"})]}),e.jsx("div",{className:"nice-address__fields",children:I.map(y=>y==="country"&&H?e.jsxs("div",{className:`nice-address__field nice-address__field--${y}`,children:[e.jsx("label",{className:"nice-address__field-label",children:E(y,et[y])}),e.jsxs("select",{className:"nice-input nice-select",value:x.country??"",onChange:c=>h("country",c.target.value),disabled:m,"aria-label":E(y,et[y]),children:[e.jsx("option",{value:"",children:G.country??E("selectCountry","— Select country —")}),H.map(c=>e.jsx("option",{value:c.code,children:c.name},c.code))]})]},y):e.jsxs("div",{className:`nice-address__field nice-address__field--${y}`,children:[e.jsx("label",{className:"nice-address__field-label",children:E(y,et[y])}),e.jsx("input",{className:`nice-input${y==="postalCode"&&M?" nice-input--error":""}`,type:"text",name:_?`${_}.${y}`:y,value:x[y]??"",onChange:c=>h(y,c.target.value),placeholder:G[y]??"",disabled:m,readOnly:g,"aria-label":E(y,et[y])}),y==="postalCode"&&M&&e.jsx("span",{className:"nice-error-text",children:M})]},y))}),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="NiceAddressInput";const to=[{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"}],Cn=n.forwardRef(({label:t,helperText:i,error:o,required:a,disabled:m,readOnly:g,size:w="md",name:_,id:R,className:z,style:Y,accessMode:B,value:x,onChange:F,onBlur:P,currency:G="PLN",onCurrencyChange:H,currencies:U=to,useMinorUnit:v=!1,min:k,max:O,locale:j,placeholder:A,showCurrencySelector:E},b)=>{const h=q.sc(B,R),M=h==="hidden";h==="disabled"&&(m=!0),h==="readOnly"&&(g=!0);const{t:I}=q.Zt(),S=q._s(R),y=n.useMemo(()=>U.find(s=>s.code===G)??U[0],[G,U]),c=y?.decimals??2,L=n.useMemo(()=>x==null?"":(v?x/Math.pow(10,c):x).toFixed(c),[x,v,c]),C=n.useCallback(s=>{const p=s.replace(/[^\d.,\-]/g,"").replace(",",".");if(p===""||p==="-"){F?.(null);return}const f=parseFloat(p);if(isNaN(f))return;const d=v?Math.round(f*Math.pow(10,c)):f;k!=null&&d<k||O!=null&&d>O||F?.(d)},[F,v,c,k,O]),u=E??U.length>1,l=n.useMemo(()=>{if(x==null)return"";const s=v?x/Math.pow(10,c):x;try{return new Intl.NumberFormat(j,{style:"currency",currency:y?.code??"USD",minimumFractionDigits:c}).format(s)}catch{return`${s.toFixed(c)} ${y?.code}`}},[x,v,c,j,y]);return M?null:e.jsxs("div",{ref:b,id:S,className:`nice-currency nice-size-${w}${z?` ${z}`:""}${o?" nice-error":""}${m?" nice-disabled":""}`,style:Y,children:[t&&e.jsxs("label",{className:"nice-currency__label",children:[t,a&&e.jsx("span",{className:"nice-required",children:"*"})]}),e.jsxs("div",{className:"nice-currency__row",children:[u&&e.jsx("select",{className:"nice-currency__select nice-select",value:G,onChange:s=>H?.(s.target.value),disabled:m,"aria-label":I("currency","Currency"),children:U.map(s=>e.jsxs("option",{value:s.code,children:[s.symbol," ",s.code]},s.code))}),!u&&e.jsx("span",{className:"nice-currency__symbol",children:y?.symbol}),e.jsx("input",{className:"nice-input nice-currency__amount",type:"text",inputMode:"decimal",name:_,value:L,onChange:s=>C(s.target.value),onBlur:P,placeholder:A??`0.${"0".repeat(c)}`,disabled:m,readOnly:g,"aria-label":I("amount","Amount")})]}),l&&x!=null&&e.jsx("span",{className:"nice-currency__formatted",children:l}),i&&e.jsx("span",{className:"nice-helper-text",children:i}),o&&typeof o=="string"&&e.jsx("span",{className:"nice-error-text",children:o})]})});Cn.displayName="NiceCurrencyInput";const no=[{target:".nice-invoice-lines",titleKey:"tutorial.invoiceLineEditor.intro.title",title:"Invoice lines",contentKey:"tutorial.invoiceLineEditor.intro.content",content:"Add line items with quantity, unit price, VAT and discount — net, gross and the VAT breakdown are calculated automatically.",placement:"auto"}];let io=1;function oo(t){return{id:`new-${io++}`,description:"",quantity:1,unitPrice:0,vatRate:t,discount:0,unit:"szt."}}function Sn(t){const o=t.quantity*t.unitPrice*(1-(t.discount??0)/100),a=Math.round(o*100)/100,m=Math.round(a*(t.vatRate??0)/100*100)/100;return{...t,netAmount:a,grossAmount:a+m}}function ao(t){const i=t.map(Sn),o=i.reduce((_,R)=>_+(R.netAmount??0),0),a=i.reduce((_,R)=>_+(R.grossAmount??0),0),m=a-o,g=new Map;for(const _ of i){const R=_.vatRate??0,z=g.get(R)??{base:0,amount:0};z.base+=_.netAmount??0,z.amount+=(_.grossAmount??0)-(_.netAmount??0),g.set(R,z)}const w=Array.from(g.entries()).map(([_,R])=>({rate:_,base:Math.round(R.base*100)/100,amount:Math.round(R.amount*100)/100}));return{totalNet:Math.round(o*100)/100,totalVat:Math.round(m*100)/100,totalGross:Math.round(a*100)/100,vatBreakdown:w}}const Mn=n.forwardRef(({label:t,helperText:i,error:o,required:a,disabled:m,readOnly:g,size:w="md",name:_,id:R,className:z,style:Y,accessMode:B,value:x=[],onChange:F,onTotalsChange:P,currencySymbol:G="zł",defaultVatRate:H=23,vatRates:U=[0,5,8,23],units:v=["szt.","h","kg","m","usł."],showDiscount:k=!0,showUnit:O=!0,showTotals:j=!0,editable:A=!0,maxLines:E,tutorial:b},h)=>{const M=q.sc(B,R),I=M==="hidden";M==="disabled"&&(m=!0),M==="readOnly"&&(g=!0);const{t:S}=q.Zt(),y=q._s(R),c=n.useMemo(()=>x.map(Sn),[x]),L=n.useMemo(()=>ao(x),[x]);n.useEffect(()=>{P?.(L)},[L,P]);const C=n.useCallback((p,f,d)=>{const $=[...x];$[p]={...$[p],[f]:d},F?.($)},[x,F]),u=n.useCallback(()=>{E&&x.length>=E||F?.([...x,oo(H)])},[x,F,H,E]),l=n.useCallback(p=>{F?.(x.filter((f,d)=>d!==p))},[x,F]),s=p=>`${p.toFixed(2)} ${G}`;return I?null:e.jsxs("div",{ref:h,id:y,className:`nice-invoice-lines nice-size-${w}${z?` ${z}`:""}${o?" nice-error":""}${m?" nice-disabled":""}`,style:{position:"relative",...Y},children:[e.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:20},children:e.jsx(q.wl,{steps:q.xl(b,no)})}),t&&e.jsxs("label",{className:"nice-invoice-lines__label",children:[t,a&&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:S("description","Description")}),e.jsx("th",{className:"nice-il__th-qty",children:S("qty","Qty")}),O&&e.jsx("th",{className:"nice-il__th-unit",children:S("unit","Unit")}),e.jsx("th",{className:"nice-il__th-price",children:S("unitPrice","Unit Price")}),k&&e.jsx("th",{className:"nice-il__th-disc",children:S("discount","Disc %")}),e.jsx("th",{className:"nice-il__th-vat",children:S("vat","VAT %")}),e.jsx("th",{className:"nice-il__th-net",children:S("net","Net")}),e.jsx("th",{className:"nice-il__th-gross",children:S("gross","Gross")}),A&&!g&&e.jsx("th",{className:"nice-il__th-actions"})]})}),e.jsx("tbody",{children:c.map((p,f)=>e.jsxs("tr",{children:[e.jsx("td",{className:"nice-il__cell-num",children:f+1}),e.jsx("td",{className:"nice-il__cell-desc",children:e.jsx("input",{className:"nice-input",type:"text",value:p.description,onChange:d=>C(f,"description",d.target.value),disabled:m,readOnly:g,placeholder:S("itemDescription","Item description")})}),e.jsx("td",{className:"nice-il__cell-qty",children:e.jsx("input",{className:"nice-input",type:"number",value:p.quantity,onChange:d=>C(f,"quantity",parseFloat(d.target.value)||0),disabled:m,readOnly:g,min:0,step:"any"})}),O&&e.jsx("td",{className:"nice-il__cell-unit",children:e.jsx("select",{className:"nice-select",value:p.unit??"",onChange:d=>C(f,"unit",d.target.value),disabled:m,children:v.map(d=>e.jsx("option",{value:d,children:d},d))})}),e.jsx("td",{className:"nice-il__cell-price",children:e.jsx("input",{className:"nice-input",type:"number",value:p.unitPrice,onChange:d=>C(f,"unitPrice",parseFloat(d.target.value)||0),disabled:m,readOnly:g,min:0,step:"0.01"})}),k&&e.jsx("td",{className:"nice-il__cell-disc",children:e.jsx("input",{className:"nice-input",type:"number",value:p.discount??0,onChange:d=>C(f,"discount",parseFloat(d.target.value)||0),disabled:m,readOnly:g,min:0,max:100})}),e.jsx("td",{className:"nice-il__cell-vat",children:e.jsx("select",{className:"nice-select",value:p.vatRate??0,onChange:d=>C(f,"vatRate",parseInt(d.target.value,10)),disabled:m,children:U.map(d=>e.jsxs("option",{value:d,children:[d,"%"]},d))})}),e.jsx("td",{className:"nice-il__cell-net",children:s(p.netAmount??0)}),e.jsx("td",{className:"nice-il__cell-gross",children:s(p.grossAmount??0)}),A&&!g&&e.jsx("td",{className:"nice-il__cell-actions",children:e.jsx("button",{type:"button",className:"nice-btn nice-btn--icon nice-btn--sm",onClick:()=>l(f),disabled:m,title:S("remove","Remove"),children:"✕"})})]},p.id))})]}),A&&!g&&e.jsxs("button",{type:"button",className:"nice-btn nice-btn--outlined nice-btn--sm nice-invoice-lines__add",onClick:u,disabled:m||E!=null&&x.length>=E,children:["+ ",S("addLine","Add line")]}),j&&e.jsxs("div",{className:"nice-invoice-lines__totals",children:[e.jsxs("div",{className:"nice-il__total-row",children:[e.jsxs("span",{children:[S("totalNet","Net total"),":"]}),e.jsx("span",{className:"nice-il__total-value",children:s(L.totalNet)})]}),L.vatBreakdown.map(p=>e.jsxs("div",{className:"nice-il__total-row nice-il__total-row--vat",children:[e.jsxs("span",{children:["VAT ",p.rate,"%:"]}),e.jsx("span",{className:"nice-il__total-value",children:s(p.amount)})]},p.rate)),e.jsxs("div",{className:"nice-il__total-row nice-il__total-row--gross",children:[e.jsxs("span",{children:[S("totalGross","Gross total"),":"]}),e.jsx("span",{className:"nice-il__total-value nice-il__total-value--gross",children:s(L.totalGross)})]})]}),i&&e.jsx("span",{className:"nice-helper-text",children:i}),o&&typeof o=="string"&&e.jsx("span",{className:"nice-error-text",children:o})]})});Mn.displayName="NiceInvoiceLineEditor";const $n=n.forwardRef(({label:t,helperText:i,error:o,required:a,disabled:m,readOnly:g,size:w="md",name:_,id:R,className:z,style:Y,accessMode:B,value:x=[],onChange:F,contacts:P=[],onSearch:G,searchDelay:H=300,multiple:U=!1,placeholder:v,onContactClick:k,maxSelections:O},j)=>{const A=q.sc(B,R),E=A==="hidden";A==="disabled"&&(m=!0),A==="readOnly"&&(g=!0);const{t:b}=q.Zt(),h=q._s(R),[M,I]=n.useState(""),[S,y]=n.useState([]),[c,L]=n.useState(!1),[C,u]=n.useState(!1),l=n.useMemo(()=>{const d=[...P,...S],$=new Map(d.map(K=>[K.id,K]));return x.map(K=>$.get(K)).filter(Boolean)},[x,P,S]),s=n.useCallback(d=>{if(I(d),d.length<1){y([]),L(!1);return}if(G){u(!0);const ee=setTimeout(async()=>{const D=await G(d);y(D),L(!0),u(!1)},H);return()=>clearTimeout(ee)}const $=d.toLowerCase(),K=P.filter(ee=>ee.name.toLowerCase().includes($)||ee.email?.toLowerCase().includes($)||ee.phone?.includes(d));y(K),L(!0)},[G,P,H]),p=n.useCallback(d=>{if(U)if(x.includes(d.id))F?.(x.filter($=>$!==d.id));else{if(O&&x.length>=O)return;F?.([...x,d.id])}else F?.([d.id]),L(!1),I("")},[x,F,U,O]),f=n.useCallback(d=>{F?.(x.filter($=>$!==d))},[x,F]);return E?null:e.jsxs("div",{ref:j,id:h,className:`nice-contact-picker nice-size-${w}${z?` ${z}`:""}${o?" nice-error":""}${m?" nice-disabled":""}`,style:Y,children:[t&&e.jsxs("label",{className:"nice-contact-picker__label",children:[t,a&&e.jsx("span",{className:"nice-required",children:"*"})]}),l.length>0&&e.jsx("div",{className:"nice-contact-picker__chips",children:l.map(d=>e.jsxs("span",{className:"nice-contact-picker__chip",onClick:()=>k?.(d),children:[d.avatarUrl&&e.jsx("img",{src:d.avatarUrl,alt:"",className:"nice-contact-picker__chip-avatar"}),e.jsx("span",{children:d.name}),!g&&e.jsx("button",{type:"button",className:"nice-contact-picker__chip-remove",onClick:$=>{$.stopPropagation(),f(d.id)},disabled:m,children:"×"})]},d.id))}),!g&&e.jsxs("div",{className:"nice-contact-picker__search",children:[e.jsx("input",{className:"nice-input",type:"text",value:M,onChange:d=>s(d.target.value),onFocus:()=>M.length>0&&L(!0),onBlur:()=>setTimeout(()=>L(!1),200),placeholder:v??b("searchContacts","Search contacts…"),disabled:m,"aria-label":b("searchContacts","Search contacts")}),C&&e.jsx("span",{className:"nice-contact-picker__spinner",children:"⏳"})]}),c&&S.length>0&&e.jsx("div",{className:"nice-contact-picker__dropdown",role:"listbox",children:S.map(d=>e.jsxs("div",{className:`nice-contact-picker__option${x.includes(d.id)?" nice-contact-picker__option--selected":""}`,role:"option","aria-selected":x.includes(d.id),onClick:()=>p(d),children:[d.avatarUrl&&e.jsx("img",{src:d.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:d.name}),d.subtitle&&e.jsx("span",{className:"nice-contact-picker__option-subtitle",children:d.subtitle}),d.email&&e.jsx("span",{className:"nice-contact-picker__option-email",children:d.email})]}),d.type&&e.jsx("span",{className:"nice-contact-picker__option-type",children:d.type==="person"?"👤":"🏢"})]},d.id))}),i&&e.jsx("span",{className:"nice-helper-text",children:i}),o&&typeof o=="string"&&e.jsx("span",{className:"nice-error-text",children:o})]})});$n.displayName="NiceContactPicker";const ro=[{target:".nice-pdf-annotation",titleKey:"tutorial.pdfAnnotationEditor.intro.title",title:"PDF annotations",contentKey:"tutorial.pdfAnnotationEditor.intro.content",content:"Pick a tool from the toolbar (highlight, underline, freehand, text…), mark up the page, navigate pages and zoom as needed.",placement:"auto"}],so=["highlight","underline","strikethrough","freehand","text","rect","arrow"],co={highlight:"🖍️",underline:"⎁",strikethrough:"S̶",freehand:"✏️",text:"T",rect:"▭",arrow:"→",stamp:"🔏"},En=n.forwardRef(({label:t,helperText:i,error:o,required:a,disabled:m,readOnly:g,size:w="md",id:_,className:R,style:z,accessMode:Y,src:B,annotations:x=[],onAnnotationsChange:F,activeTool:P,onToolChange:G,currentPage:H=1,onPageChange:U,totalPages:v=1,defaultColor:k="var(--nice-warning, #ffff00)",tools:O=so,author:j,zoom:A=1,onZoomChange:E,onAnnotationClick:b,onAnnotationDelete:h,tutorial:M},I)=>{const S=q.sc(Y,_),y=S==="hidden";S==="disabled"&&(m=!0),S==="readOnly"&&(g=!0);const{t:c}=q.Zt(),L=q._s(_),C=x.filter(s=>s.page===H),u=n.useCallback(s=>{G?.(P===s?null:s)},[P,G]),l=n.useCallback(s=>{if(g||!P||P==="freehand")return;const p=s.currentTarget.getBoundingClientRect(),f=(s.clientX-p.left)/p.width,d=(s.clientY-p.top)/p.height,$={id:`ann-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,tool:P,page:H,x:f,y:d,color:k,author:j,createdAt:new Date().toISOString(),text:P==="text"?"":void 0};F?.([...x,$])},[g,P,H,k,j,x,F]);return y?null:e.jsxs("div",{ref:I,id:L,className:`nice-pdf-annotation nice-size-${w}${R?` ${R}`:""}${o?" nice-error":""}${m?" nice-disabled":""}`,style:{position:"relative",...z},children:[e.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:20},children:e.jsx(q.wl,{steps:q.xl(M,ro)})}),t&&e.jsxs("div",{className:"nice-pdf-annotation__label",children:[t,a&&e.jsx("span",{className:"nice-required",children:"*"})]}),!g&&e.jsxs("div",{className:"nice-pdf-annotation__toolbar",children:[O.map(s=>e.jsx("button",{type:"button",className:`nice-pdf-annotation__tool-btn${P===s?" nice-pdf-annotation__tool-btn--active":""}`,onClick:()=>u(s),disabled:m,title:c(`pdfTool_${s}`,s),children:co[s]},s)),e.jsx("span",{className:"nice-pdf-annotation__toolbar-sep"}),e.jsx("button",{type:"button",disabled:m,onClick:()=>E?.(Math.max(.25,A-.25)),title:c("zoomOut","Zoom out"),children:"−"}),e.jsxs("span",{className:"nice-pdf-annotation__zoom",children:[Math.round(A*100),"%"]}),e.jsx("button",{type:"button",disabled:m,onClick:()=>E?.(Math.min(4,A+.25)),title:c("zoomIn","Zoom in"),children:"+"})]}),e.jsxs("div",{className:"nice-pdf-annotation__viewport",style:{transform:`scale(${A})`,transformOrigin:"top left"},children:[e.jsx("iframe",{src:B,className:"nice-pdf-annotation__frame",title:c("pdfViewer","PDF Viewer")}),e.jsx("div",{className:"nice-pdf-annotation__layer",onClick:l,children:C.map(s=>e.jsxs("div",{className:`nice-pdf-annotation__mark nice-pdf-annotation__mark--${s.tool}`,style:{left:`${s.x*100}%`,top:`${s.y*100}%`,backgroundColor:s.color},onClick:p=>{p.stopPropagation(),b?.(s)},title:s.text??s.tool,children:[s.text&&e.jsx("span",{children:s.text}),!g&&e.jsx("button",{type:"button",className:"nice-pdf-annotation__mark-delete",onClick:p=>{p.stopPropagation(),h?.(s.id)},children:"×"})]},s.id))})]}),e.jsxs("div",{className:"nice-pdf-annotation__pager",children:[e.jsx("button",{type:"button",disabled:m||H<=1,onClick:()=>U?.(H-1),children:"◀"}),e.jsx("span",{children:c("pageOf","{page} / {total}").replace("{page}",String(H)).replace("{total}",String(v))}),e.jsx("button",{type:"button",disabled:m||H>=v,onClick:()=>U?.(H+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})]})});En.displayName="NicePDFAnnotationEditor";const Tn=n.forwardRef(({label:t,helperText:i,error:o,disabled:a,readOnly:m,size:g="md",id:w,className:_,style:R,accessMode:z,pages:Y,selectedPageId:B,content:x="",contentFormat:F="html",editing:P=!1,onPageSelect:G,onContentChange:H,onSave:U,onCreatePage:v,onDeletePage:k,onEditToggle:O,onVersionHistory:j,sidebarWidth:A=260,sidebarCollapsed:E=!1,onSidebarToggle:b,searchable:h=!0,onSearch:M},I)=>{const S=q.sc(z,w),y=S==="hidden";S==="disabled"&&(a=!0),S==="readOnly"&&(m=!0);const{t:c}=q.Zt(),L=q._s(w),[C,u]=n.useState(""),[l,s]=n.useState(""),[p,f]=n.useState(!1),d=n.useMemo(()=>{const D=ge=>{for(const re of ge){if(re.id===B)return re;if(re.children){const ye=D(re.children);if(ye)return ye}}};return D(Y)},[Y,B]),$=n.useCallback(D=>{u(D),M?.(D)},[M]),K=n.useCallback(()=>{l.trim()&&(v?.(B??null,l.trim()),s(""),f(!1))},[l,B,v]),ee=(D,ge=0)=>e.jsx("ul",{className:"nice-wiki__tree",style:{paddingLeft:ge>0?16:0},children:D.map(re=>e.jsxs("li",{className:"nice-wiki__tree-item",children:[e.jsxs("div",{className:`nice-wiki__tree-node${re.id===B?" nice-wiki__tree-node--active":""}${re.isDraft?" nice-wiki__tree-node--draft":""}`,onClick:()=>G?.(re),role:"treeitem","aria-selected":re.id===B,children:[e.jsx("span",{className:"nice-wiki__tree-icon",children:re.children?.length?"📁":"📄"}),e.jsx("span",{className:"nice-wiki__tree-title",children:re.title}),re.isDraft&&e.jsx("span",{className:"nice-wiki__tree-draft",children:c("draft","Draft")})]}),re.children&&re.children.length>0&&ee(re.children,ge+1)]},re.id))});return y?null:e.jsxs("div",{ref:I,id:L,className:`nice-wiki nice-size-${g}${_?` ${_}`:""}${a?" nice-disabled":""}`,style:R,children:[!E&&e.jsxs("aside",{className:"nice-wiki__sidebar",style:{width:A},children:[e.jsxs("div",{className:"nice-wiki__sidebar-header",children:[e.jsx("span",{className:"nice-wiki__sidebar-title",children:t??c("wiki","Wiki")}),b&&e.jsx("button",{type:"button",className:"nice-wiki__sidebar-toggle",onClick:()=>b(!0),children:"«"})]}),h&&e.jsx("input",{type:"text",className:"nice-input nice-wiki__search",value:C,onChange:D=>$(D.target.value),placeholder:c("searchPages","Search pages…"),disabled:a}),e.jsx("div",{className:"nice-wiki__page-tree",role:"tree",children:ee(Y)}),v&&!m&&e.jsx("div",{className:"nice-wiki__sidebar-footer",children:p?e.jsxs("div",{className:"nice-wiki__create-form",children:[e.jsx("input",{type:"text",className:"nice-input",value:l,onChange:D=>s(D.target.value),placeholder:c("pageTitle","Page title"),onKeyDown:D=>D.key==="Enter"&&K(),disabled:a}),e.jsx("button",{type:"button",disabled:a||!l.trim(),onClick:K,children:"✓"}),e.jsx("button",{type:"button",onClick:()=>f(!1),children:"✕"})]}):e.jsxs("button",{type:"button",className:"nice-wiki__add-page",onClick:()=>f(!0),disabled:a,children:["+ ",c("newPage","New page")]})})]}),E&&b&&e.jsx("button",{type:"button",className:"nice-wiki__sidebar-expand",onClick:()=>b(!1),children:"»"}),e.jsx("main",{className:"nice-wiki__content",children:d?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"nice-wiki__content-header",children:[e.jsx("h1",{className:"nice-wiki__page-title",children:d.title}),e.jsxs("div",{className:"nice-wiki__content-actions",children:[O&&!m&&e.jsx("button",{type:"button",disabled:a,onClick:()=>O(!P),children:P?c("preview","Preview"):c("edit","Edit")}),j&&e.jsx("button",{type:"button",disabled:a,onClick:()=>j(d.id),children:c("history","History")}),k&&!m&&e.jsx("button",{type:"button",className:"nice-btn--danger",disabled:a,onClick:()=>k(d.id),children:c("delete","Delete")})]})]}),d.updatedAt&&e.jsxs("div",{className:"nice-wiki__page-meta",children:[d.updatedBy&&e.jsxs("span",{children:[c("lastEditedBy","Last edited by")," ",d.updatedBy]}),e.jsx("span",{children:new Date(d.updatedAt).toLocaleDateString()})]}),P?e.jsxs("div",{className:"nice-wiki__editor",children:[e.jsx("textarea",{className:"nice-wiki__editor-textarea",value:x,onChange:D=>H?.(D.target.value),disabled:a}),U&&e.jsx("button",{type:"button",className:"nice-btn nice-btn--primary",disabled:a,onClick:()=>U(d.id,x),children:c("save","Save")})]}):e.jsx("div",{className:"nice-wiki__viewer",children:F==="html"?e.jsx("div",{className:"nice-wiki__html",dangerouslySetInnerHTML:{__html:q.$s(x)}}):e.jsx("pre",{className:"nice-wiki__markdown",children:x})})]}):e.jsx("div",{className:"nice-wiki__empty",children:e.jsx("p",{children:c("selectPage","Select a page from the sidebar or create a new one.")})})}),i&&e.jsx("span",{className:"nice-helper-text",children:i}),o&&typeof o=="string"&&e.jsx("span",{className:"nice-error-text",children:o})]})});Tn.displayName="NiceWiki";const lo=[{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"}],Rn=n.forwardRef(({label:t,helperText:i,error:o,required:a,disabled:m,readOnly:g,size:w="md",name:_,id:R,className:z,style:Y,accessMode:B,value:x="",onChange:F,countryCode:P="PL",onCountryChange:G,countries:H=lo,showCountrySelector:U=!0,autoPrefixVat:v=!0,validationResult:k,onValidateRequest:O,placeholder:j},A)=>{const E=q.sc(B,R),b=E==="hidden";E==="disabled"&&(m=!0),E==="readOnly"&&(g=!0);const{t:h}=q.Zt(),M=q._s(R),I=n.useMemo(()=>H.find(C=>C.code===P)??H[0],[H,P]),S=n.useCallback(C=>{let u=C.toUpperCase();return I&&u.startsWith(I.prefix)&&(u=u.slice(I.prefix.length)),I?I.pattern.test(u):u.length>0},[I]),y=n.useCallback(C=>{const u=C.target.value.replace(/\s/g,"");F?.(u,S(u))},[F,S]),c=v&&x&&I&&!x.toUpperCase().startsWith(I.prefix)?`${I.prefix}${x}`:x,L=S(x);return b?null:e.jsxs("div",{ref:A,id:M,className:`nice-vat-input nice-size-${w}${z?` ${z}`:""}${o||!L&&x.length>0?" nice-error":""}${m?" nice-disabled":""}`,style:Y,children:[t&&e.jsxs("label",{className:"nice-vat-input__label",htmlFor:`${M}-input`,children:[t,a&&e.jsx("span",{className:"nice-required",children:"*"})]}),e.jsxs("div",{className:"nice-vat-input__row",children:[U&&e.jsx("select",{className:"nice-vat-input__country",value:P,onChange:C=>G?.(C.target.value),disabled:m||g,children:H.map(C=>e.jsx("option",{value:C.code,children:C.prefix},C.code))}),e.jsx("input",{id:`${M}-input`,className:"nice-input nice-vat-input__field",type:"text",name:_,value:x,onChange:y,readOnly:g,disabled:m,placeholder:j??I?.placeholder,required:a,"aria-invalid":!L&&x.length>0}),O&&x.length>0&&e.jsx("button",{type:"button",className:"nice-vat-input__verify",disabled:m||!L,onClick:()=>O(v?c:x,P),title:h("verifyVat","Verify VAT number"),children:"🔍"})]}),k&&e.jsxs("div",{className:`nice-vat-input__result nice-vat-input__result--${k.valid?"valid":"invalid"}`,children:[k.valid?"✅":"❌"," ",k.companyName??k.error??(k.valid?h("vatValid","VAT number valid"):h("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})]})});Rn.displayName="NiceVatInput";const mo=[{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"}],In=n.forwardRef(({label:t,helperText:i,error:o,required:a,disabled:m,readOnly:g,size:w="md",name:_,id:R,className:z,style:Y,accessMode:B,value:x,onChange:F,rates:P,countryCode:G,placeholder:H,showPercentage:U=!0},v)=>{const k=q.sc(B,R),O=k==="hidden";k==="disabled"&&(m=!0),k==="readOnly"&&(g=!0);const{t:j}=q.Zt(),A=q._s(R),E=n.useMemo(()=>{const h=P??mo;return G?h.filter(M=>!M.countryCode||M.countryCode===G):h},[P,G]),b=n.useCallback(h=>{const M=h.target.value,I=E.find(S=>S.id===M);I&&F?.(M,I)},[F,E]);return O?null:e.jsxs("div",{ref:v,id:A,className:`nice-tax-rate nice-size-${w}${z?` ${z}`:""}${o?" nice-error":""}${m?" nice-disabled":""}`,style:Y,children:[t&&e.jsxs("label",{className:"nice-tax-rate__label",htmlFor:`${A}-select`,children:[t,a&&e.jsx("span",{className:"nice-required",children:"*"})]}),e.jsxs("select",{id:`${A}-select`,className:"nice-select nice-tax-rate__select",name:_,value:x??"",onChange:b,disabled:m||g,required:a,children:[e.jsx("option",{value:"",disabled:!0,children:H??j("selectRate","Select rate…")}),E.map(h=>e.jsxs("option",{value:h.id,children:[h.label,U&&h.category!=="exempt"?` (${(h.rate*100).toFixed(0)}%)`:""]},h.id))]}),i&&e.jsx("span",{className:"nice-helper-text",children:i}),o&&typeof o=="string"&&e.jsx("span",{className:"nice-error-text",children:o})]})});In.displayName="NiceTaxRatePicker";const uo={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)"},An=n.forwardRef(({label:t,helperText:i,error:o,required:a,disabled:m,readOnly:g,size:w="md",name:_,id:R,className:z,style:Y,accessMode:B,value:x,onChange:F,accounts:P,treeView:G=!1,placeholder:H,searchable:U=!0,showType:v=!0,onSearch:k},O)=>{const j=q.sc(B,R),A=j==="hidden";j==="disabled"&&(m=!0),j==="readOnly"&&(g=!0);const{t:E}=q.Zt(),b=q._s(R),[h,M]=n.useState(""),[I,S]=n.useState(!1),y=n.useMemo(()=>{const l=s=>{for(const p of s){if(p.code===x)return p;if(p.children){const f=l(p.children);if(f)return f}}};return l(P)},[P,x]),c=n.useMemo(()=>{const l=[],s=p=>{for(const f of p)l.push(f),f.children&&s(f.children)};return s(P),l},[P]),L=n.useMemo(()=>{if(!h)return c;const l=h.toLowerCase();return c.filter(s=>s.code.toLowerCase().includes(l)||s.name.toLowerCase().includes(l))},[c,h]),C=n.useCallback(l=>{M(l),k?.(l),S(!0)},[k]),u=n.useCallback(l=>{F?.(l.code,l),S(!1),M("")},[F]);return A?null:e.jsxs("div",{ref:O,id:b,className:`nice-account-picker nice-size-${w}${z?` ${z}`:""}${o?" nice-error":""}${m?" nice-disabled":""}`,style:Y,children:[t&&e.jsxs("label",{className:"nice-account-picker__label",htmlFor:`${b}-input`,children:[t,a&&e.jsx("span",{className:"nice-required",children:"*"})]}),e.jsx("div",{className:"nice-account-picker__control",children:U&&!g?e.jsx("input",{id:`${b}-input`,className:"nice-input",type:"text",value:I?h:y?`${y.code} — ${y.name}`:"",onChange:l=>C(l.target.value),onFocus:()=>{M(""),S(!0)},onBlur:()=>setTimeout(()=>S(!1),200),placeholder:H??E("searchAccount","Search account…"),disabled:m,required:a}):e.jsx("div",{className:"nice-account-picker__display",children:y?`${y.code} — ${y.name}`:H??E("selectAccount","Select account…")})}),I&&L.length>0&&e.jsx("div",{className:"nice-account-picker__dropdown",role:"listbox",children:L.map(l=>e.jsxs("div",{className:`nice-account-picker__option${l.code===x?" nice-account-picker__option--selected":""}${l.isActive===!1?" nice-account-picker__option--inactive":""}`,role:"option","aria-selected":l.code===x,onClick:()=>u(l),children:[v&&l.type&&e.jsx("span",{className:"nice-account-picker__type",style:{color:uo[l.type]},title:l.type,children:"●"}),e.jsx("span",{className:"nice-account-picker__code",children:l.code}),e.jsx("span",{className:"nice-account-picker__name",children:l.name})]},l.code))}),i&&e.jsx("span",{className:"nice-helper-text",children:i}),o&&typeof o=="string"&&e.jsx("span",{className:"nice-error-text",children:o})]})});An.displayName="NiceAccountPicker";const Dn=n.forwardRef(({label:t,helperText:i,error:o,required:a,disabled:m,readOnly:g,size:w="md",id:_,className:R,style:z,accessMode:Y,mode:B="manual",onScan:x,onModeChange:F,beepOnScan:P=!0,beepFrequency:G=1800,beepDuration:H=150,placeholder:U,scanHistory:v=[],showHistory:k=!0,maxHistory:O=10,autoFocus:j=!0,onCameraFrame:A},E)=>{const b=q.sc(Y,_),h=b==="hidden";b==="disabled"&&(m=!0),b==="readOnly"&&(g=!0);const{t:M}=q.Zt(),I=q._s(_),[S,y]=n.useState(""),c=n.useRef(null),L=n.useRef(null),C=n.useCallback(()=>{if(P)try{L.current||(L.current=new AudioContext);const s=L.current,p=s.createOscillator(),f=s.createGain();p.connect(f),f.connect(s.destination),p.frequency.value=G,p.type="square",f.gain.value=.3,p.start(),p.stop(s.currentTime+H/1e3)}catch{}},[P,G,H]),u=n.useCallback(()=>{S.trim()&&(C(),x?.({value:S.trim(),format:"manual",scannedAt:new Date}),y(""),c.current?.focus())},[S,x,C]),l=v.slice(0,O);return h?null:e.jsxs("div",{ref:E,id:I,className:`nice-scanner nice-size-${w}${R?` ${R}`:""}${o?" nice-error":""}${m?" nice-disabled":""}`,style:z,children:[t&&e.jsxs("div",{className:"nice-scanner__label",children:[t,a&&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${B==="camera"?" nice-scanner__mode-btn--active":""}`,onClick:()=>F?.("camera"),disabled:m,children:["📷 ",M("camera","Camera")]}),e.jsxs("button",{type:"button",className:`nice-scanner__mode-btn${B==="manual"?" nice-scanner__mode-btn--active":""}`,onClick:()=>F?.("manual"),disabled:m,children:["⌨️ ",M("manual","Manual")]})]}),B==="camera"&&e.jsx("div",{className:"nice-scanner__camera",children:e.jsx("div",{className:"nice-scanner__viewfinder",children:e.jsxs("div",{className:"nice-scanner__viewfinder-overlay",children:[e.jsx("span",{children:"📷"}),e.jsx("p",{children:M("cameraPlaceholder","Camera preview — connect scanner adapter")})]})})}),B==="manual"&&!g&&e.jsxs("div",{className:"nice-scanner__manual",children:[e.jsx("input",{ref:c,className:"nice-input nice-scanner__input",type:"text",value:S,onChange:s=>y(s.target.value),onKeyDown:s=>s.key==="Enter"&&u(),placeholder:U??M("enterCode","Enter or scan code…"),disabled:m,autoFocus:j}),e.jsx("button",{type:"button",className:"nice-scanner__submit",onClick:u,disabled:m||!S.trim(),children:"✓"})]}),k&&l.length>0&&e.jsxs("div",{className:"nice-scanner__history",children:[e.jsx("div",{className:"nice-scanner__history-label",children:M("recentScans","Recent scans")}),l.map((s,p)=>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()})]},p))]}),i&&e.jsx("span",{className:"nice-helper-text",children:i}),o&&typeof o=="string"&&e.jsx("span",{className:"nice-error-text",children:o})]})});Dn.displayName="NiceScannerControl";const Ln=n.forwardRef(({label:t,helperText:i,error:o,required:a,disabled:m,readOnly:g,size:w="md",id:_,className:R,style:z,accessMode:Y,value:B="",onChange:x,onComplete:F,length:P=4,masked:G=!0,showKeypad:H=!1,autoSubmit:U=!0,shake:v=!1,placeholderChar:k="·"},O)=>{const j=q.sc(Y,_),A=j==="hidden";j==="disabled"&&(m=!0),j==="readOnly"&&(g=!0);const{t:E}=q.Zt(),b=q._s(_),h=n.useRef([]),[M,I]=n.useState(!1);n.useEffect(()=>{if(v){I(!0);const C=setTimeout(()=>I(!1),500);return()=>clearTimeout(C)}},[v]);const S=B.split("").slice(0,P);for(;S.length<P;)S.push("");const y=n.useCallback((C,u)=>{const l=[...S];l[C]=u;const s=l.join("");x?.(s),u&&C<P-1&&h.current[C+1]?.focus(),U&&s.length===P&&s.indexOf("")===-1&&F?.(s)},[S,P,x,F,U]),c=n.useCallback((C,u)=>{C.key==="Backspace"&&!S[u]&&u>0&&(h.current[u-1]?.focus(),y(u-1,"")),C.key==="ArrowLeft"&&u>0&&h.current[u-1]?.focus(),C.key==="ArrowRight"&&u<P-1&&h.current[u+1]?.focus()},[S,P,y]),L=n.useCallback(C=>{if(C==="clear"){x?.(""),h.current[0]?.focus();return}if(C==="backspace"){const u=B.slice(0,-1);x?.(u);const l=Math.max(0,u.length-1);h.current[l]?.focus();return}if(B.length<P){const u=B+C;x?.(u),u.length<P&&h.current[u.length]?.focus(),U&&u.length===P&&F?.(u)}},[B,P,x,F,U]);return A?null:e.jsxs("div",{ref:O,id:b,className:`nice-pin nice-size-${w}${M?" nice-pin--shake":""}${R?` ${R}`:""}${o?" nice-error":""}${m?" nice-disabled":""}`,style:z,children:[t&&e.jsxs("label",{className:"nice-pin__label",children:[t,a&&e.jsx("span",{className:"nice-required",children:"*"})]}),e.jsx("div",{className:"nice-pin__boxes",children:S.map((C,u)=>e.jsx("input",{ref:l=>{h.current[u]=l},className:"nice-pin__box",type:G?"password":"text",inputMode:"numeric",maxLength:1,value:C,onChange:l=>{const s=l.target.value.replace(/\D/g,"");s.length<=1&&y(u,s)},onKeyDown:l=>c(l,u),disabled:m,readOnly:g,placeholder:k,"aria-label":`${E("digit","Digit")} ${u+1}`},u))}),H&&!g&&e.jsx("div",{className:"nice-pin__keypad",children:["1","2","3","4","5","6","7","8","9","clear","0","backspace"].map(C=>e.jsx("button",{type:"button",className:`nice-pin__key${C==="clear"||C==="backspace"?" nice-pin__key--action":""}`,onClick:()=>L(C),disabled:m,children:C==="clear"?"C":C==="backspace"?"⌫":C},C))}),i&&e.jsx("span",{className:"nice-helper-text",children:i}),o&&typeof o=="string"&&e.jsx("span",{className:"nice-error-text",children:o})]})});Ln.displayName="NicePinCodeInput";exports.DEFAULT_ASPECT_RATIOS=xn;exports.EMOJI_DATA=ot;exports.GRADIENT_PRESETS=tn;exports.NICE_COLOR_PRESET_KEYS=Xn;exports.NiceAccountPicker=An;exports.NiceAddressInput=Nn;exports.NiceCalendar=on;exports.NiceCodeDiffEditor=hn;exports.NiceCodeEditor=Je;exports.NiceCodeEditor$1=wi;exports.NiceCodeEditorAI=Ni;exports.NiceColorPalette=Qt;exports.NiceContactPicker=$n;exports.NiceCropEditor=bn;exports.NiceCurrencyInput=Cn;exports.NiceDateRangeBox=oi;exports.NiceDocumentEditor=wn;exports.NiceDropDownBox=ri;exports.NiceEmojiPicker=yn;exports.NiceGradientPicker=nn;exports.NiceHtmlEditor=xt;exports.NiceHtmlEditor$1=hi;exports.NiceHtmlEditorAI=yi;exports.NiceImageAnnotator=jn;exports.NiceImageEditor=vn;exports.NiceInputOtp=an;exports.NiceInvoiceLineEditor=Mn;exports.NiceKeyValueEditor=Ri;exports.NiceKnob=sn;exports.NiceLogConsole=fn;exports.NiceLookup=Qn;exports.NiceMarkdownEditor=_n;exports.NiceMention=cn;exports.NicePDFAnnotationEditor=En;exports.NicePickList=un;exports.NicePinCodeInput=Ln;exports.NiceRangeSlider=ai;exports.NiceScannerControl=Dn;exports.NiceScriptRunner=Ei;exports.NiceSignature=Ii;exports.NiceSignaturePad=kn;exports.NiceSimpleCodeEditor=gn;exports.NiceTaxRatePicker=In;exports.NiceTreeSelect=mn;exports.NiceVatInput=Rn;exports.NiceWiki=Tn;exports.applyPreset=it;exports.contrastRatio=tt;exports.cssToGradient=en;exports.generateHarmony=Ge;exports.generateVariations=qt;exports.gradientToCss=pt;exports.hexToHsv=Ie;exports.hexToRgb=Ze;exports.hsvToHex=$e;exports.hsvToRgb=Wt;exports.randomPalette=Zt;exports.rgbToHex=Xt;exports.rgbToHsl=Vt;exports.rgbToHsv=ft;exports.wcagLevel=nt;