@nice2dev/ui-forms 1.0.18 → 1.0.20
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.
- package/dist/NicePinCodeInput-Bo8Ahkae-CXs3LKfk.js +11037 -0
- package/dist/NicePinCodeInput-Bo8Ahkae-f-uvUCHx.cjs +419 -0
- package/dist/NicePinCodeInput-CpPtHZsK-BytgasfR.js +11037 -0
- package/dist/NicePinCodeInput-CpPtHZsK-C4RoIoFf.cjs +419 -0
- package/dist/NicePinCodeInput-ltwzQf4r-B0xfLk8p.cjs +419 -0
- package/dist/NicePinCodeInput-ltwzQf4r-Bc3ZXuae.js +11037 -0
- package/dist/NiceSavedQueryPanel-BIXW0y1X-CgbXXtAR.cjs +596 -0
- package/dist/NiceSavedQueryPanel-BIXW0y1X-z-Az1-J8.js +6616 -0
- package/dist/NiceSavedQueryPanel-BOBULytX-Cmtj1h-j.cjs +596 -0
- package/dist/NiceSavedQueryPanel-BOBULytX-DmG26ZzM.js +6616 -0
- package/dist/NiceSavedQueryPanel-DuonbEem-CJH3syEu.cjs +596 -0
- package/dist/NiceSavedQueryPanel-DuonbEem-jjHiCWLy.js +6745 -0
- package/dist/charts-C60va95_-BwLGpxnA.cjs +546 -0
- package/dist/charts-C60va95_-zu0Sv2JV.js +3880 -0
- package/dist/charts-CYpqDxHd-DUD-8Sxr.js +3880 -0
- package/dist/charts-CYpqDxHd-Ws-ovMry.cjs +546 -0
- package/dist/charts-P6qura0j-B3N_VL8t.js +3880 -0
- package/dist/charts-P6qura0j-CLgGqRTJ.cjs +546 -0
- package/dist/index-BFmhgiku.cjs +404 -0
- package/dist/index-BM5m0r6_.js +22197 -0
- package/dist/index-C89TyjTI.js +21831 -0
- package/dist/index-CtikFbFa-BR5iuIPM.cjs +4504 -0
- package/dist/index-CtikFbFa-DaU7rUi2.js +40183 -0
- package/dist/index-DCDfWfAt-B8_e9qqx.cjs +4504 -0
- package/dist/index-DCDfWfAt-Crrk5MG7.js +40182 -0
- package/dist/index-DuZApx8d.cjs +404 -0
- package/dist/index-PE-O9RBQ.cjs +404 -0
- package/dist/index-XaDIMnTX.js +21831 -0
- package/dist/index-xVJiF843-B0LiUw3t.js +41393 -0
- package/dist/index-xVJiF843-QCTzf0Xj.cjs +4504 -0
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,419 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),F=require("./index-BFmhgiku.cjs"),a=require("react");function Ln(n,t=30){switch(n){case"monochromatic":return[0];case"complementary":return[0,180];case"split-complementary":return[0,180-t,180+t];case"analogous":return[0,-t,t];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 Mt(n,t={}){const i=t.size??16,r="currentColor",d="currentColor";if(t.rectangle||n==="shade-chain"||n==="monochromatic"){const H=Math.max(3,Math.min(7,t.count??5)),I=i*.1,b=i-I*2,C=Math.max(1.2,i/14),P=i/2,ee=Array.from({length:H},(V,Y)=>{const p=I+b*Y/(H-1),T=.25+.75*Y/(H-1);return e.jsx("circle",{cx:p,cy:P,r:C,fill:d,opacity:T},Y)});return e.jsxs("svg",{width:i,height:i,viewBox:`0 0 ${i} ${i}`,"aria-hidden":!0,children:[e.jsx("rect",{x:1,y:i/2-i/6,width:i-2,height:i/3,rx:i/6,fill:"none",stroke:r,strokeOpacity:.25}),ee]})}const h=t.angles??Ln(n),y=i/2,N=i/2,$=i/2-2,S=Math.max(1.4,i/9);return e.jsxs("svg",{width:i,height:i,viewBox:`0 0 ${i} ${i}`,"aria-hidden":!0,children:[e.jsx("circle",{cx:y,cy:N,r:$,fill:"none",stroke:r,strokeOpacity:.25}),h.map((H,I)=>{const b=(H-90)*Math.PI/180,C=y+$*Math.cos(b),P=N+$*Math.sin(b);return e.jsx("circle",{cx:C,cy:P,r:S,fill:d},I)})]})}function St(n,t,i){return Math.max(t,Math.min(i,n))}function qt({h:n,s:t,v:i}){n=(n%360+360)%360;const r=i*t,d=r*(1-Math.abs(n/60%2-1)),h=i-r;let y=0,N=0,$=0;return n<60?(y=r,N=d):n<120?(y=d,N=r):n<180?(N=r,$=d):n<240?(N=d,$=r):n<300?(y=d,$=r):(y=r,$=d),{r:Math.round((y+h)*255),g:Math.round((N+h)*255),b:Math.round(($+h)*255)}}function _t({r:n,g:t,b:i}){n/=255,t/=255,i/=255;const r=Math.max(n,t,i),d=Math.min(n,t,i),h=r-d;let y=0;return h!==0&&(r===n?y=(t-i)/h%6:r===t?y=(i-n)/h+2:y=(n-t)/h+4,y=(y*60+360)%360),{h:y,s:r===0?0:h/r,v:r}}function Vt({r:n,g:t,b:i}){n/=255,t/=255,i/=255;const r=Math.max(n,t,i),d=Math.min(n,t,i),h=(r+d)/2;if(r===d)return{h:0,s:0,l:h};const y=r-d,N=h>.5?y/(2-r-d):y/(r+d);let $=0;return r===n?$=((t-i)/y+(t<i?6:0))/6:r===t?$=((i-n)/y+2)/6:$=((n-t)/y+4)/6,{h:$*360,s:N,l:h}}function it(n){const t=n.replace("#",""),i=t.length===3?t[0]+t[0]+t[1]+t[1]+t[2]+t[2]:t,r=parseInt(i,16);return{r:r>>16&255,g:r>>8&255,b:r&255}}function Yt({r:n,g:t,b:i}){return"#"+[n,t,i].map(r=>r.toString(16).padStart(2,"0")).join("")}function Le(n){return Yt(qt(n))}function Fe(n){return _t(it(n))}function Jt(n,t){const i=[];for(let r=0;r<t;r++){const d=t<=1?.5:r/(t-1),h=St(n.s*(.3+d*.7),0,1),y=St(n.v*(1.2-d*.7),0,1);i.push(Le({h:n.h,s:h,v:y}))}return i}function kt(n,t){if(n==="custom"||n==="shade-chain")return[0];const i=t??30;switch(n){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]}return[0]}function at(n,t,i){return kt(t,i).map(r=>((n+r)%360+360)%360)}function Et(n,t,i=.12){const r=Math.max(2,t),d=(r-1)/2,h=[];for(let y=0;y<r;y++){const N=(y-d)*i,$=Math.max(.05,Math.min(.98,n.v+N)),S=Math.max(.05,Math.min(1,n.s-Math.abs(N)*.25));h.push(Le({h:n.h,s:S,v:$}))}return h}function At({r:n,g:t,b:i}){const[r,d,h]=[n,t,i].map(y=>{const N=y/255;return N<=.03928?N/12.92:Math.pow((N+.055)/1.055,2.4)});return .2126*r+.7152*d+.0722*h}function ct(n,t){const i=At(it(n)),r=At(it(t)),d=Math.max(i,r),h=Math.min(i,r);return(d+.05)/(h+.05)}function dt(n){return n>=7?"AAA":n>=4.5?"AA":n>=3?"AA-lg":"Fail"}const Zt={"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 ut(n,t){const i=Zt[t];return n.map(r=>{const d=(i.sRange[0]+i.sRange[1])/2,h=(i.vRange[0]+i.vRange[1])/2;return Le({h:r,s:d,v:h})})}function Tn(){return Math.floor(Math.random()*360)}function Gt(n,t,i){const r=Tn(),d=at(r,n,i),h=[];for(let y=0;y<t;y++){const N=d[y%d.length],$=.55+Math.random()*.4,S=.5+Math.random()*.45;h.push(Le({h:N+(Math.random()-.5)*8,s:$,v:S}))}return h}const Dn=({hues:n,baseHue:t,onBaseHueChange:i,mode:r,distance:d,disabled:h})=>{const y=a.useCallback(I=>{if(h)return;const b=I.currentTarget.getBoundingClientRect(),C=I.clientX-b.left-120,P=I.clientY-b.top-120,ee=(Math.atan2(P,C)*180/Math.PI+360)%360;i(Math.round(ee))},[120,120,h,i]),N=[];for(let I=0;I<360;I+=2){const b=(I-1)*Math.PI/180,C=(I+1)*Math.PI/180,P=Le({h:I,s:1,v:1});N.push(e.jsx("path",{d:`M${120+55*Math.cos(b)},${120+55*Math.sin(b)} L${120+110*Math.cos(b)},${120+110*Math.sin(b)} A110,110 0 0,1 ${120+110*Math.cos(C)},${120+110*Math.sin(C)} L${120+55*Math.cos(C)},${120+55*Math.sin(C)} A55,55 0 0,0 ${120+55*Math.cos(b)},${120+55*Math.sin(b)} Z`,fill:P},I))}const $=`wheel-center-${r}`,S=n.map((I,b)=>{const C=I*Math.PI/180;return e.jsx("circle",{cx:120+82.5*Math.cos(C),cy:120+82.5*Math.sin(C),r:b===0?8:6,fill:Le({h:I,s:.85,v:.9}),stroke:b===0?"var(--bg-primary, #fff)":"var(--border-color, #ccc)",strokeWidth:b===0?3:2},b)});let H=null;if(r==="analogous"||r==="split-complementary"){const I=kt(r,d).slice(1).map((b,C)=>{const P=(t+b)*Math.PI/180;return e.jsx("line",{x1:120,y1:120,x2:120+82.5*Math.cos(P),y2:120+82.5*Math.sin(P),stroke:"var(--nice-overlay-light-30, rgba(255, 255, 255, 0.3))",strokeWidth:1,strokeDasharray:"3,3"},`dline-${C}`)});H=e.jsx(e.Fragment,{children:I})}return e.jsxs("svg",{className:"nice-palette__wheel",viewBox:"0 0 240 240",width:240,height:240,onClick:y,style:{cursor:h?"default":"crosshair"},children:[e.jsx("defs",{children:e.jsxs("radialGradient",{id:$,children:[e.jsx("stop",{offset:"0%",stopColor:"var(--nice-bg, #fff)"}),e.jsx("stop",{offset:"100%",stopColor:"transparent"})]})}),N,e.jsx("circle",{cx:120,cy:120,r:53,fill:Le({h:t,s:.6,v:.85})}),e.jsx("circle",{cx:120,cy:120,r:53,fill:`url(#${$})`,opacity:.4}),H,S]})},In=({colors:n})=>{if(n.length<2)return null;const t=[];for(let i=0;i<n.length;i++){const r=ct(n[i],"var(--bg-primary, #ffffff)"),d=ct(n[i],"var(--text-primary, #000000)");t.push({a:n[i],b:"var(--bg-primary, #ffffff)",ratio:r,level:dt(r)}),t.push({a:n[i],b:"var(--text-primary, #000000)",ratio:d,level:dt(d)});for(let h=i+1;h<n.length;h++){const y=ct(n[i],n[h]);t.push({a:n[i],b:n[h],ratio:y,level:dt(y)})}}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:t.map((i,r)=>e.jsxs("div",{className:"nice-palette__contrast-pair",children:[e.jsxs("div",{className:"nice-palette__contrast-swatches",children:[e.jsx("span",{className:"nice-palette__contrast-dot",style:{background:i.a}}),e.jsx("span",{className:"nice-palette__contrast-vs",children:"vs"}),e.jsx("span",{className:"nice-palette__contrast-dot",style:{background:i.b}})]}),e.jsxs("span",{className:"nice-palette__contrast-ratio",children:[i.ratio.toFixed(1),":1"]}),e.jsx("span",{className:`nice-palette__contrast-level nice-palette__contrast-level--${i.level.toLowerCase().replace("-","")}`,children:i.level})]},r))})]})},Pn=({hex:n})=>{const t=it(n),i=Vt(t),r=_t(t);return e.jsxs("div",{className:"nice-palette__color-info",children:[e.jsxs("div",{children:[e.jsx("strong",{children:"HEX"})," ",n.toUpperCase()]}),e.jsxs("div",{children:[e.jsx("strong",{children:"RGB"})," ",t.r,", ",t.g,", ",t.b]}),e.jsxs("div",{children:[e.jsx("strong",{children:"HSL"})," ",Math.round(i.h),"°, ",Math.round(i.s*100),"%,"," ",Math.round(i.l*100),"%"]}),e.jsxs("div",{children:[e.jsx("strong",{children:"HSV"})," ",Math.round(r.h),"°, ",Math.round(r.s*100),"%,"," ",Math.round(r.v*100),"%"]})]})},zn={monochromatic:"Monochromatic",complementary:"Complementary","split-complementary":"Split-Complementary",analogous:"Analogous",triadic:"Triadic",tetradic:"Tetradic (Rectangle)",square:"Square","shade-chain":"Shade chain",custom:"Custom"},Fn={"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"},Wn=["monochromatic","shade-chain","complementary","split-complementary","analogous","triadic","tetradic","square","custom"],Qt="nice-palette-custom-schemes";function On(){if(typeof window>"u")return[];try{const n=window.localStorage.getItem(Qt);if(!n)return[];const t=JSON.parse(n);if(Array.isArray(t))return t}catch{}return[]}function Un(n){if(!(typeof window>"u"))try{window.localStorage.setItem(Qt,JSON.stringify(n))}catch{}}const Kt=a.forwardRef(({id:n,className:t,style:i,accessMode:r,value:d,onChange:h,minColors:y=1,maxColors:N=8,harmonyMode:$,onHarmonyModeChange:S,distance:H,onDistanceChange:I,preset:b,onPresetChange:C,showWheel:P=!0,showContrast:ee=!0,showInfo:V=!0,showPresets:Y=!0,presets:p=[],showVariations:T=!0,showRandom:w=!0,variationCount:E=5,label:G,disabled:g,colorCount:k,shadeStep:v,onShadeStepChange:A,customSchemes:D,onCustomSchemesChange:W,persistCustomSchemes:x=!0},c)=>{const z=F.Cl(r,n),_=z==="hidden";(z==="disabled"||z==="readOnly")&&(g=!0);const j=F.nl(n),[o,s]=a.useState("analogous"),[m,l]=a.useState(30),[u,q]=a.useState(""),[O,Z]=a.useState(0),[le,L]=a.useState(.12),[U,ae]=a.useState(null),[se,he]=a.useState(()=>D??(x?On():[])),[me,_e]=a.useState(null),J=$??o,re=H??m,ce=b??u,ve=v??le,ie=D??se;a.useEffect(()=>{!D&&x&&Un(se)},[se,D,x]);const M=a.useCallback(ne=>{he(ne),W==null||W(ne)},[W]),R=a.useCallback(ne=>{s(ne),S==null||S(ne)},[S]),Q=a.useCallback(ne=>{l(ne),I==null||I(ne)},[I]),ge=a.useCallback(ne=>{q(ne),ne&&(C==null||C(ne))},[C]),fe=a.useMemo(()=>["var(--color-primary, #3b82f6)","var(--color-error, #ef4444)","var(--color-success, #22c55e)"],[]),X=d&&d.length>0?d:fe,oe=X[0],pe=a.useMemo(()=>Fe(oe),[oe]),Ne=a.useMemo(()=>at(pe.h,J,re),[pe.h,J,re]),we=a.useCallback((ne,ue,ke,Ae)=>{var Ee;const B=k??U??void 0,de=B!==void 0?Math.max(y,Math.min(N,B)):void 0;if(ue==="shade-chain"){const ye=de??Math.max(y,5),Re=Et({h:ne,s:pe.s||.7,v:pe.v||.6},ye,ve);h==null||h(Re);return}let xe;const je=ue==="custom"&&me?ie.find(ye=>ye.id===me):null;je&&je.angles.length>0?xe=je.angles.map(ye=>((ne+ye)%360+360)%360):xe=at(ne,ue,ke);let be;if(Ae&&Zt[Ae]?be=ut(xe,Ae):be=xe.map(ye=>Le({h:ye,s:pe.s||.7,v:pe.v||.85})),(Ee=je==null?void 0:je.lightnessOffsets)!=null&&Ee.length&&(be=be.map((ye,Re)=>{var Ie;const De=(Ie=je.lightnessOffsets)==null?void 0:Ie[Re];if(De==null)return ye;const Te=Fe(ye);return Le({h:Te.h,s:Te.s,v:Math.max(.05,Math.min(.98,Te.v+De))})})),de!==void 0){for(;be.length<de;){const ye=be[be.length-1]||"#888888",Re=Fe(ye);be.push(Le({h:(Re.h+18)%360,s:Re.s,v:Re.v}))}be=be.slice(0,de)}else{for(;be.length<y;)be.push(be[be.length-1]||"var(--nice-text-secondary, #888888)");be.length>N&&(be=be.slice(0,N))}h==null||h(be)},[pe.s,pe.v,y,N,h,k,U,ve,me,ie]),$e=a.useCallback(ne=>{if(!g){if(J==="custom"){const ue=Le({h:ne,s:pe.s||.7,v:pe.v||.85}),ke=[...X];ke[O]=ue,h==null||h(ke);return}we(ne,J,re,ce)}},[g,J,re,ce,we,pe.s,pe.v,X,O,h]),Pe=a.useCallback(ne=>{g||(R(ne),ne!=="custom"&&we(pe.h,ne,re,ce))},[g,pe.h,re,ce,R,we]),Je=a.useCallback(ne=>{g||(Q(ne),we(pe.h,J,ne,ce))},[g,pe.h,J,ce,Q,we]),ze=a.useCallback(ne=>{if(g)return;ge(ne);const ue=at(pe.h,J,re),ke=ut(ue,ne);h==null||h(ke.slice(0,N))},[g,pe.h,J,re,N,ge,h]),We=a.useCallback((ne,ue)=>{if(g)return;const ke=[...X];ke[ne]=ue,h==null||h(ke)},[g,X,h]),Ze=a.useCallback(()=>{if(g||X.length>=N)return;const ne=Fe(X[X.length-1]),ue=Le({h:(ne.h+30)%360,s:ne.s,v:ne.v});h==null||h([...X,ue])},[g,X,N,h]),Ge=a.useCallback(ne=>{if(g||X.length<=y)return;const ue=X.filter((ke,Ae)=>Ae!==ne);h==null||h(ue),O>=ue.length&&Z(Math.max(0,ue.length-1))},[g,X,y,h,O]),Qe=a.useCallback(()=>{if(g)return;const ne=Math.max(y,Math.min(N,kt(J).length)),ue=Gt(J,ne,re);h==null||h(ue)},[g,y,N,J,re,h]),He=a.useMemo(()=>{if(!T)return[];const ne=X[O]||X[0];return Jt(Fe(ne),E)},[T,X,O,E]),Oe=X[O]||X[0],Be=a.useMemo(()=>{const ne=Fe(Oe);return Le({h:(ne.h+180)%360,s:ne.s,v:ne.v})},[Oe]);return _?null:e.jsxs("div",{ref:c,id:j,className:`nice-palette ${g?"nice-palette--disabled":""} ${t||""}`,style:i,children:[G&&e.jsx("div",{className:"nice-palette__label",children:G}),e.jsxs("div",{className:"nice-palette__modes",style:{display:"flex",gap:8,alignItems:"center",flexWrap:"wrap"},children:[e.jsx(F.Ge,{label:"Harmony",labelPlacement:"left",size:"sm",disabled:g,value:J==="custom"&&me?`custom:${me}`:J,onChange:ne=>{const ue=Array.isArray(ne)?ne[0]:ne;if(typeof ue=="string")if(ue.startsWith("custom:")){const ke=ue.slice(7);_e(ke),Pe("custom")}else _e(null),Pe(ue)},options:[...Wn.map(ne=>({value:ne,label:zn[ne]})),...ie.map(ne=>({value:`custom:${ne.id}`,label:`★ ${ne.name}`}))],renderOption:(ne,ue)=>{const ke=String(ne.value),Ae=ke.startsWith("custom:"),B=Ae?ie.find(xe=>xe.id===ke.slice(7)):null,de=B?B.angles:void 0;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:Mt(Ae?"custom":ke,{angles:de,size:16,count:k})}),e.jsx("span",{style:{fontWeight:ue?600:400},children:ne.label})]})}}),J==="shade-chain"&&e.jsx(F.Ze,{label:"Step",labelPlacement:"left",size:"sm",min:.02,max:.5,step:.02,precision:2,value:ve,onChange:ne=>{const ue=typeof ne=="number"?ne:Number(ne);Number.isNaN(ue)||(L(ue),A==null||A(ue),we(pe.h,J,re,ce))},showStepper:!0,disabled:g}),e.jsx(F.Ze,{label:"Colors",labelPlacement:"left",size:"sm",min:Math.max(2,y),max:Math.min(12,N),step:1,precision:0,value:k??U??X.length,onChange:ne=>{const ue=typeof ne=="number"?ne:Number(ne);if(!Number.isFinite(ue))return;const ke=Math.max(Math.max(2,y),Math.min(Math.min(12,N),Math.round(ue)));ae(ke),J==="shade-chain"?h==null||h(Et({h:pe.h,s:pe.s||.7,v:pe.v||.6},ke,ve)):setTimeout(()=>we(pe.h,J,re,ce),0)},showStepper:!0,disabled:g})]}),e.jsxs("div",{className:"nice-palette__main",children:[P&&e.jsxs("div",{className:"nice-palette__wheel-container",children:[e.jsx(Dn,{hues:Ne,baseHue:pe.h,onBaseHueChange:$e,mode:J,distance:re,disabled:g}),(J==="analogous"||J==="split-complementary")&&e.jsxs("div",{className:"nice-palette__distance",children:[e.jsxs("label",{children:["Distance: ",re,"°"]}),e.jsx("input",{type:"range",min:10,max:90,value:re,onChange:ne=>Je(Number(ne.target.value)),disabled:g,className:"nice-palette__distance-slider"})]})]}),e.jsxs("div",{className:"nice-palette__strips",children:[e.jsxs("div",{className:"nice-palette__swatches",children:[X.map((ne,ue)=>e.jsxs("div",{className:`nice-palette__swatch-wrapper ${O===ue?"nice-palette__swatch-wrapper--selected":""}`,onClick:()=>Z(ue),children:[e.jsx("div",{className:"nice-palette__swatch",style:{background:ne},children:X.length>y&&e.jsx("button",{type:"button",className:"nice-palette__swatch-remove",onClick:ke=>{ke.stopPropagation(),Ge(ue)},disabled:g,"aria-label":"Remove color",children:"×"})}),e.jsx("input",{type:"text",className:"nice-palette__hex-input",value:ne.toUpperCase(),maxLength:7,disabled:g,onChange:ke=>We(ue,ke.target.value)})]},ue)),X.length<N&&e.jsx("button",{type:"button",className:"nice-palette__add-btn",onClick:Ze,disabled:g,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:Be},title:Be.toUpperCase()}),e.jsx("span",{className:"nice-palette__hex-label",children:Be.toUpperCase()})]}),T&&He.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:He.map((ne,ue)=>e.jsx("div",{className:"nice-palette__variation-chip",style:{background:ne},title:ne.toUpperCase(),onClick:()=>{g||We(O,ne)},role:"button",tabIndex:0},ue))})]}),w&&e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm nice-palette__random-btn",onClick:Qe,disabled:g,title:"Random palette","aria-label":"Random palette",children:"🎲 Random Palette"})]})]}),Y&&p.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:p.map(ne=>{const ue=ut(Ne,ne);return e.jsxs("button",{type:"button",className:`nice-palette__preset-card ${ce===ne?"nice-palette__preset-card--active":""}`,onClick:()=>ze(ne),disabled:g,children:[e.jsx("div",{className:"nice-palette__preset-strip",children:ue.map((ke,Ae)=>e.jsx("span",{className:"nice-palette__preset-dot",style:{background:ke}},Ae))}),e.jsx("span",{className:"nice-palette__preset-label",children:Fn[ne]})]},ne)})})]}),V&&e.jsxs("div",{className:"nice-palette__info-panel",children:[e.jsx("div",{className:"nice-palette__section-title",children:"Selected Color Info"}),e.jsx(Pn,{hex:Oe})]}),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 (",ie.length,")"]}),e.jsxs("div",{style:{marginTop:8,display:"flex",flexDirection:"column",gap:6},children:[ie.length===0&&e.jsx("div",{style:{fontSize:12,color:"var(--text-muted)"},children:"Save the current palette as a reusable scheme."}),ie.map(ne=>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:Mt("custom",{angles:ne.angles,size:16})}),e.jsx("span",{style:{flex:1},children:ne.name}),e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--xs",onClick:()=>{_e(ne.id),Pe("custom")},disabled:g,children:"Use"}),e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--xs",onClick:()=>M(ie.filter(ue=>ue.id!==ne.id)),disabled:g,"aria-label":`Delete ${ne.name}`,children:"×"})]},ne.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:g,onClick:()=>{const ne=typeof window<"u"?window.prompt("Scheme name?",`Scheme ${ie.length+1}`):null;if(!ne)return;const ue=Fe(X[0]).h,ke=X.map(B=>(Fe(B).h-ue+540)%360-180),Ae={id:`cs-${Date.now()}`,name:ne,angles:ke};M([...ie,Ae])},children:"+ Save current as scheme"}),e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm",disabled:g||ie.length===0,onClick:()=>{var ne;typeof navigator>"u"||((ne=navigator.clipboard)==null||ne.writeText(JSON.stringify(ie,null,2)))},children:"Export JSON"}),e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm",disabled:g,onClick:()=>{if(typeof window>"u")return;const ne=window.prompt("Paste schemes JSON");if(ne)try{const ue=JSON.parse(ne);Array.isArray(ue)&&M(ue)}catch{}},children:"Import JSON"})]})]})]}),ee&&e.jsxs("details",{className:"nice-palette__contrast-popup",style:{marginTop:8},children:[e.jsx("summary",{style:{cursor:"pointer",padding:"6px 10px",background:"var(--bg-secondary)",color:"var(--text-primary)",border:"1px solid var(--border-color)",borderRadius:4,display:"inline-block",fontSize:12,userSelect:"none"},children:"Contrast Analysis (WCAG 2.1)"}),e.jsx("div",{style:{marginTop:8},children:e.jsx(In,{colors:X})})]})]})});Kt.displayName="NiceColorPalette";function bt(){return{type:"linear",angle:90,stops:[{color:"var(--nice-primary, #3b82f6)",position:0},{color:"var(--nice-accent, #8b5cf6)",position:100}]}}function xt(n){const t=n.stops.slice().sort((r,d)=>r.position-d.position).map(r=>`${r.color} ${r.position}%`).join(", "),i=n.repeating?"repeating-":"";switch(n.type){case"linear":return`${i}linear-gradient(${n.angle}deg, ${t})`;case"radial":{const r=n.shape||"ellipse",d=n.size||"farthest-corner",h=n.positionX??50,y=n.positionY??50;return`${i}radial-gradient(${r} ${d} at ${h}% ${y}%, ${t})`}case"conic":{const r=n.angle??0,d=n.positionX??50,h=n.positionY??50;return`${i}conic-gradient(from ${r}deg at ${d}% ${h}%, ${t})`}}}function en(n){var r,d,h;const t=n.trim(),i=t.startsWith("repeating-");if(t.includes("linear-gradient")){const y=(r=t.match(/linear-gradient\((.+)\)/))==null?void 0:r[1];if(!y)return null;const N=y.split(",").map(b=>b.trim());let $=90,S=0;const H=N[0].match(/^(\d+)deg$/);H&&($=parseInt(H[1]),S=1);const I=mt(N.slice(S));return{type:"linear",angle:$,repeating:i,stops:I}}if(t.includes("radial-gradient")){const y=(d=t.match(/radial-gradient\((.+)\)/))==null?void 0:d[1];if(!y)return null;const N=y.split(",").map(S=>S.trim()),$=mt(N.filter(S=>S.includes("#")||S.includes("rgb")));return{type:"radial",angle:0,repeating:i,stops:$.length>=2?$:bt().stops}}if(t.includes("conic-gradient")){const y=(h=t.match(/conic-gradient\((.+)\)/))==null?void 0:h[1];if(!y)return null;const N=y.split(",").map(S=>S.trim()),$=mt(N.filter(S=>S.includes("#")||S.includes("rgb")));return{type:"conic",angle:0,repeating:i,stops:$.length>=2?$:bt().stops}}return null}function mt(n){return n.map((t,i,r)=>{const d=t.match(/^(#[0-9a-fA-F]{3,8}|rgba?\([^)]+\))\s*(\d+%?)?$/);if(d){const h=d[2]?parseFloat(d[2]):i/Math.max(1,r.length-1)*100;return{color:d[1],position:h}}return{color:t,position:i/Math.max(1,r.length-1)*100}})}function Hn(){return"#"+Math.floor(Math.random()*16777215).toString(16).padStart(6,"0")}function Bn(n=2){const t=["linear","radial","conic"],i=t[Math.floor(Math.random()*t.length)],r=[];for(let d=0;d<n;d++)r.push({color:Hn(),position:Math.round(d/(n-1)*100)});return{type:i,angle:Math.floor(Math.random()*360),stops:r,shape:i==="radial"?Math.random()>.5?"circle":"ellipse":void 0,positionX:i!=="linear"?Math.round(Math.random()*100):void 0,positionY:i!=="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=a.forwardRef(({id:n,className:t,style:i,accessMode:r,value:d,onChange:h,showCssOutput:y=!0,showPresets:N=!0,showEditor:$=!0,showRandom:S=!0,maxStops:H=10,label:I,disabled:b,width:C},P)=>{const ee=F.Cl(r,n),V=ee==="hidden";(ee==="disabled"||ee==="readOnly")&&(b=!0);const Y=F.nl(n),p=d??bt(),T=a.useMemo(()=>xt(p),[p]),[w,E]=a.useState(0),[G,g]=a.useState(""),k=a.useRef(null),v=a.useCallback(l=>{h==null||h(l)},[h]),A=a.useCallback(l=>{b||v({...p,type:l})},[b,p,v]),D=a.useCallback(l=>{b||v({...p,angle:l})},[b,p,v]),W=a.useCallback(l=>{b||v({...p,repeating:l})},[b,p,v]),x=a.useCallback(l=>{b||v({...p,shape:l})},[b,p,v]),c=a.useCallback((l,u)=>{if(b)return;const q=p.stops.map((O,Z)=>Z===l?{...O,...u}:O);v({...p,stops:q})},[b,p,v]),z=a.useCallback(()=>{if(b||p.stops.length>=H)return;const l=p.stops.slice().sort((le,L)=>le.position-L.position);let u=0,q=l[0];for(let le=0;le<l.length-1;le++){const L=l[le+1].position-l[le].position;L>u&&(u=L,q=l[le])}const O=Math.round(q.position+u/2),Z="#"+Math.floor(Math.random()*16777215).toString(16).padStart(6,"0");v({...p,stops:[...p.stops,{color:Z,position:O}]})},[b,p,H,v]),_=a.useCallback(l=>{if(b||p.stops.length<=2)return;const u=p.stops.filter((q,O)=>O!==l);v({...p,stops:u}),w>=u.length&&E(u.length-1)},[b,p,w,v]),j=a.useCallback(()=>{if(b)return;const l=2+Math.floor(Math.random()*3);v(Bn(l))},[b,v]),o=a.useCallback(()=>{if(b||!G.trim())return;const l=en(G);l&&v(l)},[b,G,v]),s=a.useCallback(l=>{if(b||!k.current||p.stops.length>=H)return;const u=k.current.getBoundingClientRect(),q=Math.round((l.clientX-u.left)/u.width*100),O="#"+Math.floor(Math.random()*16777215).toString(16).padStart(6,"0"),Z=[...p.stops,{color:O,position:q}];v({...p,stops:Z}),E(Z.length-1)},[b,p,H,v]),m=a.useMemo(()=>p.stops.slice().sort((l,u)=>l.position-u.position),[p.stops]);return V?null:e.jsxs("div",{ref:P,id:Y,className:`nice-gradient ${b?"nice-gradient--disabled":""} ${t||""}`,style:{width:C!=null?typeof C=="number"?`${C}px`:C:320,boxSizing:"border-box",...i},children:[I&&e.jsx("div",{className:"nice-gradient__label",children:I}),e.jsx("div",{className:"nice-gradient__preview",style:{background:T}}),$&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"nice-gradient__type-row",children:[["linear","radial","conic"].map(l=>e.jsx("button",{type:"button",className:`nice-gradient__type-btn ${p.type===l?"nice-gradient__type-btn--active":""}`,onClick:()=>A(l),disabled:b,children:l.charAt(0).toUpperCase()+l.slice(1)},l)),e.jsxs("label",{className:"nice-gradient__repeat-label",children:[e.jsx("input",{type:"checkbox",checked:p.repeating??!1,onChange:l=>W(l.target.checked),disabled:b}),"Repeating"]})]}),e.jsxs("div",{className:"nice-gradient__controls",children:[p.type==="linear"&&e.jsxs("div",{className:"nice-gradient__control-group",children:[e.jsxs("label",{children:["Angle: ",p.angle,"°"]}),e.jsx("input",{type:"range",min:0,max:360,value:p.angle,onChange:l=>D(Number(l.target.value)),disabled:b,className:"nice-gradient__slider"}),e.jsx("div",{className:"nice-gradient__angle-presets",children:[0,45,90,135,180,225,270,315].map(l=>e.jsx("button",{type:"button",className:`nice-gradient__angle-btn ${p.angle===l?"nice-gradient__angle-btn--active":""}`,onClick:()=>D(l),disabled:b,title:`${l}°`,children:e.jsx("span",{style:{transform:`rotate(${l}deg)`,display:"inline-block"},children:"→"})},l))})]}),p.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(l=>e.jsx("button",{type:"button",className:`nice-gradient__shape-btn ${(p.shape||"ellipse")===l?"nice-gradient__shape-btn--active":""}`,onClick:()=>x(l),disabled:b,children:l},l))})]}),(p.type==="radial"||p.type==="conic")&&e.jsxs("div",{className:"nice-gradient__control-group",children:[e.jsxs("label",{children:["Center: ",p.positionX??50,"%, ",p.positionY??50,"%"]}),e.jsxs("div",{className:"nice-gradient__center-inputs",children:[e.jsx("input",{type:"range",min:0,max:100,value:p.positionX??50,onChange:l=>v({...p,positionX:Number(l.target.value)}),disabled:b,className:"nice-gradient__slider"}),e.jsx("input",{type:"range",min:0,max:100,value:p.positionY??50,onChange:l=>v({...p,positionY:Number(l.target.value)}),disabled:b,className:"nice-gradient__slider"})]})]}),p.type==="conic"&&e.jsxs("div",{className:"nice-gradient__control-group",children:[e.jsxs("label",{children:["Start angle: ",p.angle,"°"]}),e.jsx("input",{type:"range",min:0,max:360,value:p.angle,onChange:l=>D(Number(l.target.value)),disabled:b,className:"nice-gradient__slider"})]})]}),e.jsxs("div",{className:"nice-gradient__bar-container",children:[e.jsx("div",{ref:k,className:"nice-gradient__bar",style:{background:T},onClick:s,children:p.stops.map((l,u)=>e.jsx("div",{className:`nice-gradient__stop-marker ${w===u?"nice-gradient__stop-marker--active":""}`,style:{left:`${l.position}%`},onClick:q=>{q.stopPropagation(),E(u)},title:`${l.color} @ ${l.position}%`,children:e.jsx("div",{className:"nice-gradient__stop-dot",style:{background:l.color}})},u))}),e.jsx("button",{type:"button",className:"nice-gradient__add-stop",onClick:z,disabled:b||p.stops.length>=H,title:"Add stop",children:"+"})]}),e.jsx("div",{className:"nice-gradient__stop-editor",children:e.jsx("div",{className:"nice-gradient__stop-list",children:m.map((l,u)=>{const q=p.stops.indexOf(l);return e.jsxs("div",{className:`nice-gradient__stop-row ${w===q?"nice-gradient__stop-row--active":""}`,onClick:()=>E(q),children:[e.jsx("input",{type:"color",value:l.color,onChange:O=>c(q,{color:O.target.value}),disabled:b,className:"nice-gradient__stop-color"}),e.jsx("input",{type:"text",value:l.color.toUpperCase(),maxLength:7,onChange:O=>c(q,{color:O.target.value}),disabled:b,className:"nice-gradient__stop-hex"}),e.jsx("input",{type:"number",min:0,max:100,value:l.position,onChange:O=>c(q,{position:Number(O.target.value)}),disabled:b,className:"nice-gradient__stop-pos"}),e.jsx("span",{className:"nice-gradient__stop-pct",children:"%"}),p.stops.length>2&&e.jsx("button",{type:"button",className:"nice-gradient__stop-del",onClick:()=>_(q),disabled:b,"aria-label":"Remove stop",children:"×"})]},q)})})})]}),S&&e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm nice-gradient__random-btn",onClick:j,disabled:b,title:"Random gradient","aria-label":"Random gradient",children:"🎲 Random Gradient"}),N&&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((l,u)=>e.jsxs("button",{type:"button",className:"nice-gradient__preset-card",onClick:()=>{b||v(l.value)},disabled:b,title:l.name,children:[e.jsx("div",{className:"nice-gradient__preset-preview",style:{background:xt(l.value)}}),e.jsx("span",{className:"nice-gradient__preset-name",children:l.name})]},u))})]}),y&&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: ${T};`}),e.jsx("button",{type:"button",className:"nice-gradient__copy-btn",onClick:()=>{var l;return(l=navigator.clipboard)==null?void 0:l.writeText(`background: ${T};`)},title:"Copy CSS",children:"📋"})]}),e.jsxs("div",{className:"nice-gradient__css-import",children:[e.jsx("input",{type:"text",className:"nice-gradient__css-input",placeholder:"Paste CSS gradient to import...",value:G,onChange:l=>g(l.target.value),disabled:b}),e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm",onClick:o,disabled:b,children:"Import"})]})]})]})});nn.displayName="NiceGradientPicker";const Xn=({options:n,value:t,onChange:i,searchable:r=!0,clearable:d,loading:h,placeholder:y,label:N,error:$,helperText:S,required:H,disabled:I,size:b="md",id:C,className:P,style:ee,data:V,columns:Y,valueField:p="id",displayField:T,dropdownWidth:w,controlWidth:E})=>{var m;const G=F.nl(C),{t:g}=F.ue(),[k,v]=a.useState(!1),[A,D]=a.useState(""),W=a.useRef(null);F.sl(W,()=>v(!1));const x=!!(V&&Y&&Y.length>0),c=T??(Y&&((m=Y[0])==null?void 0:m.key)),z=a.useMemo(()=>!x||!V?[]:V.map(l=>({value:String(l[p]??""),label:c?String(l[c]??""):""})),[x,V,p,c]),_=x?z:n??[],j=_.find(l=>String(l.value)===t),o=a.useMemo(()=>{if(!x||!V)return[];if(!A)return V;const l=A.toLowerCase();return V.filter(u=>Y.some(q=>String(u[q.key]??"").toLowerCase().includes(l)))},[x,V,Y,A]),s=a.useMemo(()=>{if(x||!A)return _;const l=A.toLowerCase();return _.filter(u=>u.label.toLowerCase().includes(l))},[_,A,x]);return e.jsxs("div",{className:`nice-field nice-field--${b} ${$?"nice-field--error":""} ${P||""}`,style:{width:E!=null?typeof E=="number"?`${E}px`:E:"fit-content",...ee},ref:W,children:[N&&e.jsxs("label",{className:"nice-field__label",htmlFor:G,children:[N,H&&e.jsx("span",{className:"nice-field__required",children:"*"})]}),e.jsxs("div",{className:"nice-field__input-wrap",style:{position:"relative"},children:[e.jsxs("button",{type:"button",id:G,className:"nice-select__trigger",onClick:()=>!I&&v(!k),disabled:I,children:[e.jsx("span",{children:(j==null?void 0:j.label)||y||g("controls.select","Select...")}),e.jsx("span",{className:"nice-select__arrow",children:"▾"})]}),d&&t&&!I&&e.jsx("button",{type:"button",className:"nice-field__clear",onClick:()=>i(""),"aria-label":g("controls.clear","Clear"),children:"✕"}),k&&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:w!=null?typeof w=="number"?`${w}px`:w:x?"max-content":"100%"},children:[r&&e.jsx("div",{className:"nice-dropdown__search",style:{padding:6},children:e.jsx("input",{type:"text",value:A,onChange:l=>D(l.target.value),placeholder:g("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)"}})}),x?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:Y.map(l=>e.jsx("th",{style:{padding:"6px 10px",textAlign:"left",fontSize:12,fontWeight:600,color:"var(--text-secondary)",background:"var(--bg-secondary)",borderBottom:"1px solid var(--border-color)",width:l.width!=null?typeof l.width=="number"?`${l.width}px`:l.width:void 0},children:l.header},l.key))})}),e.jsx("tbody",{children:o.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:Y.length,style:{padding:12,textAlign:"center",color:"var(--text-muted)"},children:g("controls.noResults","No results")})}):o.map(l=>{const u=String(l[p]??""),q=u===t;return e.jsx("tr",{role:"option","aria-selected":q,onClick:()=>{i(u),v(!1),D("")},style:{cursor:"pointer",background:q?"var(--hover-bg)":"transparent"},onMouseEnter:O=>{q||(O.currentTarget.style.background="var(--hover-bg)")},onMouseLeave:O=>{q||(O.currentTarget.style.background="transparent")},children:Y.map(O=>e.jsx("td",{style:{padding:"6px 10px",fontSize:13,borderBottom:"1px solid var(--border-color)"},children:String(l[O.key]??"")},O.key))},u)})})]}):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:g("controls.noResults","No results")}):s.map(l=>e.jsx("li",{role:"option",className:`nice-dropdown__option ${String(l.value)===t?"nice-dropdown__option--selected":""}`,onClick:()=>{i(String(l.value)),v(!1),D("")},"aria-selected":String(l.value)===t,children:l.label},String(l.value)))})]})]}),$&&e.jsx("div",{className:"nice-field__error",children:$}),S&&!$&&e.jsx("div",{className:"nice-field__hint",children:S})]})},qn=["Su","Mo","Tu","We","Th","Fr","Sa"];function Vn(n,t){return new Date(n,t+1,0).getDate()}function Yn(n,t){return new Date(n,t,1).getDay()}function Rt(n,t,i){return`${n}-${String(t+1).padStart(2,"0")}-${String(i).padStart(2,"0")}`}function Jn(n){const t=new Date(Date.UTC(n.getFullYear(),n.getMonth(),n.getDate()));t.setUTCDate(t.getUTCDate()+4-(t.getUTCDay()||7));const i=new Date(Date.UTC(t.getUTCFullYear(),0,1));return Math.ceil(((t.getTime()-i.getTime())/864e5+1)/7)}const Lt=["January","February","March","April","May","June","July","August","September","October","November","December"],an=({value:n,onChange:t,min:i,max:r,disabledDates:d=[],firstDayOfWeek:h=1,size:y="md",showWeekNumbers:N,onMonthChange:$,className:S,style:H,accessMode:I,id:b,multiple:C,selectedDates:P=[],onSelectedDatesChange:ee,renderDay:V,showKeyboardHints:Y,persistPreferences:p=!1,fullWidth:T=!1,cookies:w=!1,localStorage:E=!0,sessionStorage:G=!1,storageMode:g,storageKey:k})=>{const v=F.Cl(I,b),A=v==="hidden",D=v==="disabled"||v==="readOnly",{t:W}=F.ue(),x=new Date,c=n?new Date(n):x,z=F.fa(k??"nice-calendar"),_=a.useMemo(()=>p?z.get("prefs")??{}:{},[p,z]),j=_.firstDayOfWeek??h,[o,s]=a.useState(_.lastViewYear??c.getFullYear()),[m,l]=a.useState(_.lastViewMonth??c.getMonth()),[u,q]=a.useState(_.preferredView??"days"),O=a.useCallback(X=>{if(!p)return;const oe=z.get("prefs")??{};z.set("prefs",{...oe,...X})},[p,z]),Z=a.useCallback(X=>{q(X),O({preferredView:X})},[O]),le=a.useCallback((X,oe)=>{O({lastViewYear:X,lastViewMonth:oe})},[O]),L=a.useMemo(()=>[F.Ol.moveUp,F.Ol.moveDown,F.Ol.moveLeft,F.Ol.moveRight,{key:"Enter",description:W("shortcuts.selectDate","Select date")},F.Ol.pageUp,F.Ol.pageDown],[W]),U=a.useMemo(()=>Vn(o,m),[o,m]),ae=a.useMemo(()=>(Yn(o,m)-j+7)%7,[o,m,j]),se=a.useMemo(()=>{const X=[...qn];for(let oe=0;oe<j;oe++)X.push(X.shift());return X},[j]),he=a.useCallback(X=>i&&X<i||r&&X>r?!0:d.includes(X),[i,r,d]),me=a.useCallback(X=>{if(u==="years"){s(Ne=>Ne+X*10);return}if(u==="months"){s(Ne=>Ne+X);return}let oe=m+X,pe=o;oe<0&&(oe=11,pe--),oe>11&&(oe=0,pe++),l(oe),s(pe),le(pe,oe),$==null||$(pe,oe)},[m,o,$,u,le]),_e=Rt(x.getFullYear(),x.getMonth(),x.getDate()),J=a.useCallback(X=>C?P.includes(X):X===n,[C,P,n]),re=a.useCallback(X=>{if(!D){if(C){const oe=P.includes(X)?P.filter(pe=>pe!==X):[...P,X];ee==null||ee(oe)}t==null||t(X)}},[C,P,t,ee]),ce=a.useCallback(()=>{u==="days"?Z("months"):u==="months"&&Z("years")},[u,Z]),ve=a.useCallback(X=>{l(X),Z("days"),le(o,X),$==null||$(o,X)},[o,$,Z,le]),ie=a.useCallback(X=>{s(X),Z("months")},[Z]),M=u==="years"?`${o-o%10} – ${o-o%10+9}`:u==="months"?`${o}`:`${Lt[m]} ${o}`,R=u==="years"?"decade":u==="months"?"year":"month",Q=[];for(let X=0;X<ae;X++)Q.push(null);for(let X=1;X<=U;X++)Q.push(X);for(;Q.length%7!==0;)Q.push(null);const ge=[];for(let X=0;X<Q.length;X+=7)ge.push(Q.slice(X,X+7));const fe=o-o%10;return A?null:e.jsxs("div",{className:`nice-calendar nice-calendar--${y}${T?" nice-calendar--full-width":""} ${S||""}`,style:H,children:[e.jsxs("div",{className:"nice-calendar__header",children:[e.jsx("button",{type:"button",className:"nice-calendar__nav",onClick:()=>me(-1),"aria-label":`Previous ${R}`,children:"‹"}),e.jsx("button",{type:"button",className:"nice-calendar__title",onClick:ce,"aria-label":u==="days"?"Show month picker":u==="months"?"Show year picker":void 0,disabled:u==="years",children:M}),e.jsx("button",{type:"button",className:"nice-calendar__nav",onClick:()=>me(1),"aria-label":`Next ${R}`,children:"›"}),Y&&e.jsx(F.Or,{shortcuts:L,size:"sm"})]}),u==="days"&&e.jsxs("table",{className:"nice-calendar__grid",role:"grid",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[N&&e.jsx("th",{className:"nice-calendar__wk",children:"W"}),se.map(X=>e.jsx("th",{children:X},X))]})}),e.jsx("tbody",{children:ge.map((X,oe)=>e.jsxs("tr",{children:[N&&e.jsx("td",{className:"nice-calendar__wk",children:X.find(pe=>pe!=null)?Jn(new Date(o,m,X.find(pe=>pe!=null))):""}),X.map((pe,Ne)=>{if(pe==null)return e.jsx("td",{className:"nice-calendar__empty-cell"},Ne);const we=Rt(o,m,pe),$e=he(we),Pe=J(we);return e.jsx("td",{className:`nice-calendar__day${Pe?" nice-calendar__day--selected":""}${we===_e?" nice-calendar__day--today":""}${$e?" nice-calendar__day--disabled":""}`,onClick:()=>!$e&&re(we),role:"gridcell","aria-selected":Pe,"aria-disabled":$e,children:V?V(we,pe):pe},Ne)})]},oe))})]}),u==="months"&&e.jsx("div",{className:"nice-calendar__picker-grid",children:Lt.map((X,oe)=>e.jsx("button",{type:"button",className:`nice-calendar__picker-cell${oe===m&&o===c.getFullYear()?" nice-calendar__picker-cell--selected":""}`,onClick:()=>ve(oe),children:X.slice(0,3)},oe))}),u==="years"&&e.jsx("div",{className:"nice-calendar__picker-grid",children:Array.from({length:12},(X,oe)=>fe-1+oe).map(X=>e.jsx("button",{type:"button",className:`nice-calendar__picker-cell${X===o?" nice-calendar__picker-cell--selected":""}${X<fe||X>fe+9?" nice-calendar__picker-cell--other":""}`,onClick:()=>ie(X),children:X},X))})]})};an.displayName="NiceCalendar";const Zn=({startDate:n,endDate:t,onStartChange:i,onEndChange:r,min:d,max:h,clearable:y,startPlaceholder:N,endPlaceholder:$,startLabel:S,endLabel:H,layout:I="horizontal",separator:b="–",gap:C=12,fullWidth:P=!1,label:ee,error:V,helperText:Y,required:p,disabled:T,size:w="md",id:E,className:G,style:g,accessMode:k,showKeyboardHints:v,labelPlacement:A,errorPlacement:D,labelWidth:W,controlWidth:x,loading:c})=>{const z=F.Cl(k,E),_=F.nl(E),{t:j}=F.ue(),o=z==="disabled"||z==="readOnly"||!!T,s=a.useMemo(()=>[{key:"Tab",description:j("shortcuts.switchField","Switch between start/end")},F.Ol.cancel],[j]);if(z==="hidden")return null;const m=u=>{i(u),u&&t&&u>t&&r(u)},l=I==="horizontal";return e.jsxs("div",{className:`nice-field nice-field--${w} nice-daterange nice-daterange--${I} ${A==="left"?"nice-field--label-left":""} ${V?"nice-field--error":""} ${c?"nice-field--loading":""} ${G||""}`,style:{...g,...W!=null&&{"--nice-field-label-width":typeof W=="number"?`${W}px`:W},...x!=null&&{"--nice-field-control-width":typeof x=="number"?`${x}px`:x}},"aria-busy":c||void 0,children:[ee&&e.jsxs("label",{className:"nice-field__label",htmlFor:_,children:[ee,p&&e.jsx("span",{className:"nice-field__required",children:"*"}),v&&e.jsx(F.Or,{shortcuts:s,size:"sm"})]}),e.jsxs("div",{className:"nice-field__control",children:[e.jsxs("div",{className:"nice-daterange__row",style:{display:"flex",flexDirection:l?"row":"column",alignItems:l?"flex-end":"stretch",gap:C,flexWrap:"wrap"},children:[e.jsx("div",{style:{flex:P?"1 1 0":void 0,minWidth:0},children:e.jsx(F.sn,{id:_,label:S,value:n,onChange:m,min:d,max:t||h,placeholder:N||j("controls.startDate","Start date"),disabled:o,size:w,clearable:y,labelPlacement:A,labelWidth:W})}),l&&b!==""&&b!=null&&e.jsx("span",{className:"nice-daterange__separator",style:{paddingBottom:8,color:"var(--text-secondary, #666)"},"aria-hidden":"true",children:b}),e.jsx("div",{style:{flex:P?"1 1 0":void 0,minWidth:0},children:e.jsx(F.sn,{label:H,value:t,onChange:r,min:n||d,max:h,placeholder:$||j("controls.endDate","End date"),disabled:o,size:w,clearable:y,labelPlacement:A,labelWidth:W})})]}),c&&e.jsx("span",{className:"nice-field__spinner",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})}),D==="right"&&V&&e.jsx("div",{className:"nice-field__error",role:"alert",children:V}),D==="right"&&!V&&Y&&e.jsx("div",{className:"nice-field__helper",children:Y})]}),D!=="right"&&V&&e.jsx("div",{className:"nice-field__error",children:V}),D!=="right"&&!V&&Y&&e.jsx("div",{className:"nice-field__hint",children:Y})]})},Gn=({min:n=0,max:t=100,step:i=1,startValue:r,endValue:d,onChange:h,showLabels:y=!0,formatLabel:N,valuePlacement:$="none",label:S,error:H,helperText:I,required:b,disabled:C,readOnly:P,loading:ee,size:V="md",id:Y,className:p,style:T,accessMode:w,showKeyboardHints:E,labelPlacement:G,errorPlacement:g,labelWidth:k,controlWidth:v})=>{const A=F.Cl(w,Y),D=A==="hidden";(A==="disabled"||A==="readOnly")&&(C=!0);const{t:W}=F.ue(),x=F.nl(Y),c=a.useRef(null),z=a.useMemo(()=>[F.Ol.increment,F.Ol.decrement,F.Ol.first,F.Ol.last,{key:"Tab",description:W("shortcuts.switchThumb","Switch thumb")}],[W]),_=m=>(m-n)/(t-n)*100,j=m=>N?N(m):String(m),o=m=>{const l=Math.round(m/i)*i;return Math.max(n,Math.min(t,l))},s=a.useCallback((m,l)=>{m.preventDefault();const u=c.current;if(!u||C)return;const q=Z=>{const le=u.getBoundingClientRect(),L=Math.max(0,Math.min(1,(Z.clientX-le.left)/le.width)),U=o(n+L*(t-n));l==="start"?h(Math.min(U,d),d):h(r,Math.max(U,r))},O=()=>{document.removeEventListener("pointermove",q),document.removeEventListener("pointerup",O)};document.addEventListener("pointermove",q),document.addEventListener("pointerup",O)},[n,t,i,r,d,h,C]);return D?null:e.jsxs("div",{className:`nice-field nice-field--${V} nice-field--rangeslider ${G==="left"?"nice-field--label-left":""} ${g==="right"?"nice-field--error-right":""} ${H?"nice-field--error":""} ${ee?"nice-field--loading":""} ${p||""}`,style:{...T,...k!=null&&{"--nice-field-label-width":typeof k=="number"?`${k}px`:k},...v!=null&&{"--nice-field-control-width":typeof v=="number"?`${v}px`:v}},"aria-busy":ee||void 0,children:[S&&e.jsxs("label",{className:"nice-field__label nice-field__label--with-value",htmlFor:x,children:[e.jsxs("span",{className:"nice-field__label-text",children:[S,b&&e.jsx("span",{className:"nice-field__required",children:"*"}),E&&e.jsx(F.Or,{shortcuts:z,size:"sm"})]}),$==="right"&&e.jsxs("span",{className:"nice-range-slider__value nice-range-slider__value--inline",children:[j(r)," – ",j(d)]})]}),e.jsxs("div",{className:"nice-field__control",children:[$==="right"&&!S&&e.jsxs("span",{className:"nice-range-slider__value",children:[j(r)," – ",j(d)]}),e.jsxs("div",{className:"nice-range-slider__stack",children:[e.jsxs("div",{className:`nice-range-slider ${y?"nice-range-slider--with-labels":""} ${S?"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:`${_(r)}%`,width:`${_(d)-_(r)}%`}})}),e.jsx("div",{className:"nice-range-slider__thumb",style:{left:`${_(r)}%`},onPointerDown:m=>P?void 0:s(m,"start"),role:"slider","aria-valuemin":n,"aria-valuemax":d,"aria-valuenow":r,tabIndex:C?-1:0,id:x}),e.jsx("div",{className:"nice-range-slider__thumb",style:{left:`${_(d)}%`},onPointerDown:m=>P?void 0:s(m,"end"),role:"slider","aria-valuemin":r,"aria-valuemax":t,"aria-valuenow":d,tabIndex:C?-1:0})]}),y&&e.jsxs("div",{className:"nice-range-slider__values",children:[e.jsx("span",{className:"nice-range-slider__values-start",style:{left:`${_(r)}%`},children:j(r)}),e.jsx("span",{className:"nice-range-slider__values-end",style:{left:`${_(d)}%`},children:j(d)})]}),$==="bottom"&&e.jsxs("div",{className:"nice-range-slider__value nice-range-slider__value--bottom",children:[j(r)," – ",j(d)]})]}),ee&&e.jsx("span",{className:"nice-field__spinner",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})}),g==="right"&&H&&e.jsx("div",{className:"nice-field__error",role:"alert",children:H}),g==="right"&&!H&&I&&e.jsx("div",{className:"nice-field__helper",children:I})]}),g!=="right"&&H&&e.jsx("div",{className:"nice-field__error",role:"alert",children:H}),g!=="right"&&!H&&I&&e.jsx("div",{className:"nice-field__helper",children:I})]})},Qn=({displayValue:n,placeholder:t,clearable:i,children:r,onClear:d,open:h,onOpenChange:y,dropdownWidth:N,label:$,error:S,helperText:H,required:I,disabled:b,size:C="md",id:P,className:ee,style:V,accessMode:Y,showKeyboardHints:p,displayStyle:T})=>{F.Us("input",T),F.Ks("input",T);const w=F.Cl(Y,P),E=w==="hidden";(w==="disabled"||w==="readOnly")&&(b=!0);const G=F.nl(P),{t:g}=F.ue(),[k,v]=a.useState(!1),A=a.useRef(null),D=h??k,W=a.useMemo(()=>[{key:"Enter",description:g("shortcuts.openDropdown","Open dropdown")},F.Ol.cancel],[g]),x=c=>{y?y(c):v(c)};return F.sl(A,()=>x(!1)),E?null:e.jsxs("div",{className:`nice-field nice-field--${C} ${S?"nice-field--error":""} ${ee||""}`,style:V,ref:A,children:[$&&e.jsxs("label",{className:"nice-field__label",htmlFor:G,children:[$,I&&e.jsx("span",{className:"nice-field__required",children:"*"}),p&&e.jsx(F.Or,{shortcuts:W,size:"sm"})]}),e.jsxs("div",{className:"nice-field__input-wrap",children:[e.jsxs("button",{type:"button",id:G,className:"nice-select__trigger",onClick:()=>!b&&x(!D),disabled:b,children:[e.jsx("span",{children:n||t||g("controls.select","Select...")}),e.jsx("span",{className:"nice-select__arrow",children:"▾"})]}),i&&n&&!b&&e.jsx("button",{type:"button",className:"nice-field__clear",onClick:()=>d==null?void 0:d(),"aria-label":g("controls.clear","Clear"),children:"✕"})]}),D&&e.jsx("div",{className:"nice-dropdown",style:{width:N},children:r}),S&&e.jsx("div",{className:"nice-field__error",children:S}),H&&!S&&e.jsx("div",{className:"nice-field__hint",children:H})]})};function Tt(n){const t=n.trim().toLowerCase();return t.startsWith("http://")||t.startsWith("https://")||t.startsWith("/")||t.startsWith("./")||t.startsWith("../")?!0:!(t.startsWith("javascript:")||t.startsWith("vbscript:")||t.startsWith("data:text"))}const Kn=["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"],Me=({d:n,viewBox:t="0 0 24 24"})=>e.jsx("svg",{width:"16",height:"16",viewBox:t,fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("path",{d:n})}),ea={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(Me,{d:"M8 6h13M8 12h13M8 18h13M3 6h.01M3 12h.01M3 18h.01"}),ol:e.jsx(Me,{d:"M10 6h11M10 12h11M10 18h11M4 6h1v4M4 10h2M6 18H4c0-1 2-2 2-3s-1-1.5-2-1"}),link:e.jsx(Me,{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(Me,{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(Me,{d:"M3 7v6h6M3 13a9 9 0 1 0 3-7.7L3 13"}),redo:e.jsx(Me,{d:"M21 7v6h-6M21 13a9 9 0 1 1-3-7.7L21 13"}),clear:e.jsx(Me,{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(Me,{d:"M3 3h18v18H3zM3 9h18M3 15h18M9 3v18M15 3v18"}),image:e.jsx(Me,{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(Me,{d:"M16 18l6-6-6-6M8 6l-6 6 6 6"}),markdown:"MD",blockquote:e.jsx(Me,{d:"M3 21c3-3 3-9 0-12M21 21c-3-3-3-9 0-12M9 7h6v6H9zM15 7h6v6h-6z"}),hr:e.jsx(Me,{d:"M5 12h14"}),subscript:"X₂",superscript:"X²",indent:e.jsx(Me,{d:"M3 8l4 4-4 4M7 6h14M7 12h14M3 18h18"}),outdent:e.jsx(Me,{d:"M7 8l-4 4 4 4M21 6H3M21 12H7M21 18H3"}),alignLeft:e.jsx(Me,{d:"M3 6h18M3 12h12M3 18h18"}),alignCenter:e.jsx(Me,{d:"M3 6h18M6 12h12M3 18h18"}),alignRight:e.jsx(Me,{d:"M3 6h18M9 12h12M3 18h18"}),alignJustify:e.jsx(Me,{d:"M3 6h18M3 12h18M3 18h18"}),fullscreen:e.jsx(Me,{d:"M3 9V3h6M21 9V3h-6M3 15v6h6M21 15v6h-6"}),removeFormat:e.jsx(Me,{d:"M4 7V4h16v3M5 20h6M13 4 8 20"}),print:e.jsx(Me,{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(Me,{d:"M16 18l6-6-6-6M8 6l-6 6 6 6"}),emoji:e.jsx(Me,{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(Me,{d:"M11 19a8 8 0 1 1 0-16 8 8 0 0 1 0 16zM21 21l-4.35-4.35"}),fontSize:e.jsx(Me,{d:"M4 7V4h16v3M9 20h6M12 4v16"}),fontColor:e.jsx(Me,{d:"M4 21h16M5 17l7-12 7 12M8 13h8"})},ta=[{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"}],na=[{label:"Faces",emojis:["??","??","??","??","??","??","??","??","??","??","??","??"]},{label:"Hands",emojis:["??","??","??","??","??","??","??","??","??","??"]},{label:"Symbols",emojis:["??","?","??","?","?","?","??","??","??","??","??","??"]},{label:"Arrows",emojis:["??","??","??","??","??","??","??","??","??","?"]}];function aa(n){let t=n;return t=t.replace(/<h1[^>]*>(.*?)<\/h1>/gi,`# $1
|
|
2
|
+
`),t=t.replace(/<h2[^>]*>(.*?)<\/h2>/gi,`## $1
|
|
3
|
+
`),t=t.replace(/<h3[^>]*>(.*?)<\/h3>/gi,`### $1
|
|
4
|
+
`),t=t.replace(/<strong[^>]*>(.*?)<\/strong>/gi,"**$1**"),t=t.replace(/<b[^>]*>(.*?)<\/b>/gi,"**$1**"),t=t.replace(/<em[^>]*>(.*?)<\/em>/gi,"*$1*"),t=t.replace(/<i[^>]*>(.*?)<\/i>/gi,"*$1*"),t=t.replace(/<code[^>]*>(.*?)<\/code>/gi,"`$1`"),t=t.replace(/<pre[^>]*>(.*?)<\/pre>/gis,"```\n$1\n```\n"),t=t.replace(/<br\s*\/?>/gi,`
|
|
5
|
+
`),t=t.replace(/<li[^>]*>(.*?)<\/li>/gi,`- $1
|
|
6
|
+
`),t=t.replace(/<\/?(?:ul|ol|p|div)[^>]*>/gi,`
|
|
7
|
+
`),t=t.replace(/<[^>]+>/g,""),t=t.replace(/\n{3,}/g,`
|
|
8
|
+
|
|
9
|
+
`),t.trim()}function ia(n){let t=n;return t=t.replace(/^### (.+)$/gm,"<h3>$1</h3>"),t=t.replace(/^## (.+)$/gm,"<h2>$1</h2>"),t=t.replace(/^# (.+)$/gm,"<h1>$1</h1>"),t=t.replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>"),t=t.replace(/\*(.+?)\*/g,"<em>$1</em>"),t=t.replace(/`([^`]+)`/g,"<code>$1</code>"),t=t.replace(/```\n?([\s\S]*?)\n?```/g,"<pre>$1</pre>"),t=t.replace(/^- (.+)$/gm,"<li>$1</li>"),t=t.replace(/(<li>.*<\/li>)/gs,"<ul>$1</ul>"),t=t.replace(/\n/g,"<br>"),t}const jt=({value:n,onChange:t,placeholder:i,height:r=200,toolbar:d=Kn,readOnly:h,onImageUpload:y,mentionTrigger:N,mentionSuggestions:$,onMentionSearch:S,onFileDrop:H,pasteCleanup:I=!0,maxLength:b=0,showWordCount:C=!1,templates:P,label:ee,error:V,helperText:Y,required:p,disabled:T,size:w="md",id:E,className:G,style:g,accessMode:k})=>{const v=F.Cl(k,E),A=v==="hidden";v==="disabled"&&(T=!0),v==="readOnly"&&(h=!0);const D=F.nl(E),W=a.useRef(null),x=a.useRef(null),c=a.useRef(null),[z,_]=a.useState(!1),[j,o]=a.useState(""),[s,m]=a.useState(!1),[l,u]=a.useState(""),[q,O]=a.useState(!1),[Z,le]=a.useState(""),[L,U]=a.useState(0),[ae,se]=a.useState(!1),[he,me]=a.useState("var(--nice-text, #000000)"),[_e,J]=a.useState("var(--nice-warning, #ffff00)"),[re,ce]=a.useState(0),[ve,ie]=a.useState(0),[M,R]=a.useState(!1),[Q,ge]=a.useState(""),[fe,X]=a.useState(""),[oe,pe]=a.useState(!1),[Ne,we]=a.useState(!1),$e=a.useCallback((B,de)=>{var je,be,Ee;if(h||T)return;const xe=W.current;if(xe){if(B==="markdown"){if(!z)o(aa(n)),_(!0),m(!1);else{const ye=ia(j);t(ye),_(!1)}return}if(B==="source"){s?(t(l),m(!1)):(u(n),m(!0),_(!1));return}if(B==="fullscreen"){se(ye=>!ye);return}if(B==="emoji"){pe(ye=>!ye);return}if(B==="findReplace"){R(ye=>!ye);return}if(B==="image"){if(y)(je=x.current)==null||je.click();else{const ye=prompt("Image URL:");ye&&Tt(ye)&&(xe.focus(),document.execCommand("insertImage",!1,ye),t(F.Ys(xe.innerHTML)))}return}switch(xe.focus(),B){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 ye=prompt("URL:");ye&&Tt(ye)&&document.execCommand("createLink",!1,ye);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":{de&&document.execCommand("fontSize",!1,de);break}case"fontColor":{de&&document.execCommand("foreColor",!1,de);break}case"bgColor":{de&&document.execCommand("hiliteColor",!1,de);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> </td><td> </td><td> </td></tr><tr><td> </td><td> </td><td> </td></tr></tbody></table><p> </p>');break}case"code":{const ye=((be=window.getSelection())==null?void 0:be.toString())||"";ye.includes(`
|
|
10
|
+
`)||ye.length>60?document.execCommand("insertHTML",!1,`<pre class="nice-htmleditor__code-block">${ye||"// code"}</pre>`):document.execCommand("insertHTML",!1,`<code>${ye||"code"}</code>`);break}}t(F.Ys(xe.innerHTML)),ce(((Ee=xe.textContent)==null?void 0:Ee.length)??0)}},[t,h,T,z,j,n,y,s,l]),Pe=a.useCallback(async B=>{var be;const de=(be=B.target.files)==null?void 0:be[0];if(!de||!y)return;const xe=await y(de),je=W.current;je&&xe&&(je.focus(),document.execCommand("insertImage",!1,xe),t(je.innerHTML)),B.target.value=""},[y,t]),Je=a.useCallback(()=>{var xe;const B=W.current;if(!B)return;const de=((xe=B.textContent)==null?void 0:xe.length)??0;if(b>0&&de>b&&(B.textContent=(B.textContent??"").slice(0,b)),ce(de),ie((B.textContent??"").trim().split(/\s+/).filter(Boolean).length),t(B.innerHTML),N){const je=window.getSelection();if(je&&je.rangeCount>0){const be=je.getRangeAt(0),Ee=be.startContainer;if(Ee.nodeType===Node.TEXT_NODE){const ye=Ee.textContent||"",Re=be.startOffset,De=ye.slice(0,Re),Te=De.lastIndexOf(N);if(Te>=0&&(Te===0||/\s/.test(De[Te-1]))){const Ie=De.slice(Te+N.length);if(!/\s/.test(Ie)){O(!0),le(Ie),U(0),S==null||S(Ie);return}}}}O(!1)}},[t,N,S]),ze=($==null?void 0:$.filter(B=>B.label.toLowerCase().includes(Z.toLowerCase())).slice(0,8))??[],We=a.useCallback(B=>{var Ee;const de=W.current;if(!de)return;const xe=window.getSelection();if(!xe||xe.rangeCount===0)return;const je=xe.getRangeAt(0),be=je.startContainer;if(be.nodeType===Node.TEXT_NODE&&N){const ye=be.textContent||"",Re=je.startOffset,De=ye.slice(0,Re).lastIndexOf(N);if(De>=0){const Te=ye.slice(0,De),Ie=ye.slice(Re),rt=`<span class="nice-htmleditor__mention" data-mention="${B.key}" contenteditable="false">${N}${B.label}</span> `;be.textContent=Te;const qe=document.createRange();qe.setStartAfter(be),qe.collapse(!0);const lt=qe.createContextualFragment(rt+Ie);(Ee=be.parentNode)==null||Ee.insertBefore(lt,be.nextSibling),xe.collapseToEnd(),t(de.innerHTML)}}O(!1)},[N,t]),Ze=a.useCallback(B=>{if(q&&ze.length>0){B.key==="ArrowDown"?(B.preventDefault(),U(de=>Math.min(de+1,ze.length-1))):B.key==="ArrowUp"?(B.preventDefault(),U(de=>Math.max(de-1,0))):B.key==="Enter"?(B.preventDefault(),We(ze[L])):B.key==="Escape"&&O(!1);return}(B.ctrlKey||B.metaKey)&&B.key==="b"?(B.preventDefault(),$e("bold")):(B.ctrlKey||B.metaKey)&&B.key==="i"?(B.preventDefault(),$e("italic")):(B.ctrlKey||B.metaKey)&&B.key==="u"?(B.preventDefault(),$e("underline")):(B.ctrlKey||B.metaKey)&&B.key==="f"?(B.preventDefault(),R(de=>!de)):(B.ctrlKey||B.metaKey)&&B.key==="z"&&!B.shiftKey?(B.preventDefault(),$e("undo")):(B.ctrlKey||B.metaKey)&&(B.key==="y"||B.key==="z"&&B.shiftKey)&&(B.preventDefault(),$e("redo"))},[q,ze,L,We,$e]),Ge=a.useCallback(B=>{var be;if(!I)return;B.preventDefault();const de=B.clipboardData.getData("text/html"),xe=B.clipboardData.getData("text/plain");if(de){const Ee=de.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,Ee)}else xe&&document.execCommand("insertText",!1,xe);const je=W.current;je&&(t(je.innerHTML),ce(((be=je.textContent)==null?void 0:be.length)??0))},[I,t]),Qe=a.useCallback(async B=>{if(!H)return;B.preventDefault();const de=Array.from(B.dataTransfer.files);if(de.length===0)return;const xe=await H(de),je=W.current;if(je){je.focus();for(const be of xe)if(/\.(png|jpe?g|gif|webp|svg|bmp|ico)$/i.test(be)||be.startsWith("data:image/"))document.execCommand("insertImage",!1,be);else{const Ee=`<a href="${be}">${be.split("/").pop()??be}</a>`;document.execCommand("insertHTML",!1,Ee)}t(je.innerHTML)}},[H,t]),He=a.useCallback(B=>{H&&B.preventDefault()},[H]),Oe=a.useCallback(B=>{var Ee;const de=W.current;if(!de||!Q)return;const xe=de.textContent??"",je=Q.toLowerCase(),be=xe.toLowerCase();(B===1?be.indexOf(je):be.lastIndexOf(je))!==-1&&(de.focus(),(Ee=window.find)==null||Ee.call(window,Q))},[Q]),Be=a.useCallback(()=>{const B=W.current;!B||!Q||(B.innerHTML=B.innerHTML.split(Q).join(fe),t(B.innerHTML))},[Q,fe,t]),ne=a.useCallback(()=>{if(!Q)return;const B=n.split(Q).join(fe);t(B);const de=W.current;de&&(de.innerHTML=B)},[Q,fe,n,t]),ue=a.useCallback(B=>{const de=W.current;de&&(de.focus(),document.execCommand("insertText",!1,B),t(de.innerHTML),pe(!1))},[t]),ke=a.useCallback(B=>{const de=W.current;de&&(de.focus(),document.execCommand("insertHTML",!1,B),t(de.innerHTML),we(!1))},[t]),Ae=a.useCallback(B=>{const de=T||h;return B==="fontSize"?e.jsx(F.Ge,{size:"sm",value:"",onChange:xe=>$e("fontSize",String(xe)),disabled:de,placeholder:"Size",options:ta.map(xe=>({value:xe.value,label:xe.label})),style:{minWidth:70,maxWidth:80}},B):B==="fontColor"?e.jsx(F.Ye,{value:he,onChange:xe=>{me(xe),$e("fontColor",xe)},disabled:de,size:"sm",label:"",title:"Text color"},B):B==="bgColor"?e.jsx(F.Ye,{value:_e,onChange:xe=>{J(xe),$e("bgColor",xe)},disabled:de,size:"sm",label:"",title:"Highlight color"},B):e.jsx(F.pn,{size:"sm",variant:B==="markdown"&&z||B==="fullscreen"&&ae||B==="source"&&s||B==="findReplace"&&M||B==="emoji"&&oe?"primary":"ghost",onClick:()=>$e(B),title:B,disabled:de,children:ea[B]||B},B)},[T,h,$e,z,ae,he,_e,s,M,oe]);return A?null:e.jsxs("div",{className:`nice-field nice-field--${w} ${V?"nice-field--error":""} ${G||""}`,style:g,children:[ee&&e.jsxs("label",{className:"nice-field__label",htmlFor:D,children:[ee,p&&e.jsx("span",{className:"nice-field__required",children:"*"})]}),e.jsxs("div",{ref:c,className:`nice-htmleditor${ae?" nice-htmleditor--fullscreen":""}`,children:[e.jsxs("div",{className:"nice-htmleditor__toolbar",style:{display:"flex",flexWrap:"wrap",gap:2,alignItems:"center"},children:[d.map(Ae),P&&P.length>0&&e.jsxs("div",{style:{position:"relative"},children:[e.jsx(F.pn,{size:"sm",variant:Ne?"primary":"ghost",onClick:()=>we(B=>!B),title:"Insert template",children:"??"}),Ne&&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((B,de)=>e.jsx("li",{style:{padding:"6px 10px",cursor:"pointer",borderRadius:4},onMouseDown:xe=>{xe.preventDefault(),ke(B.html)},children:B.label},de))})]})]}),M&&e.jsxs("div",{className:"nice-htmleditor__find-bar",style:{display:"flex",gap:4,alignItems:"center",padding:"4px 8px",background:"var(--bg-secondary, #f8f9fa)",borderBottom:"1px solid var(--border-color, #ddd)",fontSize:"0.875em"},children:[e.jsx("input",{type:"text",placeholder:"Find...",value:Q,onChange:B=>ge(B.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:fe,onChange:B=>X(B.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(F.pn,{size:"sm",variant:"ghost",onClick:()=>Oe(1),title:"Find next",children:"?"}),e.jsx(F.pn,{size:"sm",variant:"ghost",onClick:()=>Oe(-1),title:"Find previous",children:"?"}),e.jsx(F.pn,{size:"sm",variant:"ghost",onClick:Be,disabled:T||h,children:"Replace"}),e.jsx(F.pn,{size:"sm",variant:"ghost",onClick:ne,disabled:T||h,children:"All"}),e.jsx(F.pn,{size:"sm",variant:"ghost",onClick:()=>R(!1),children:"?"})]}),oe&&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:na.map(B=>e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:"0.7em",fontWeight:600,color:"var(--text-muted, #999)",padding:"4px 0"},children:B.label}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:2},children:B.emojis.map(de=>e.jsx("span",{style:{cursor:"pointer",fontSize:"1.2em",padding:2,borderRadius:4},onClick:()=>ue(de),title:de,children:de},de))})]},B.label))}),e.jsx("input",{ref:x,type:"file",accept:"image/*",style:{display:"none"},onChange:Pe}),s?e.jsx("textarea",{className:"nice-htmleditor__source",value:l,onChange:B=>u(B.target.value),style:{minHeight:r,width:"100%",fontFamily:"monospace",resize:"vertical",whiteSpace:"pre",fontSize:"0.85em",background:"var(--bg-primary, #fff)",color:"var(--text-primary, #1f2937)",border:"none",padding:12,boxSizing:"border-box",outline:"none"},disabled:T||h}):z?e.jsx("textarea",{className:"nice-htmleditor__markdown",value:j,onChange:B=>o(B.target.value),style:{minHeight:r,width:"100%",fontFamily:"monospace",resize:"vertical",background:"var(--bg-primary, #fff)",color:"var(--text-primary, #1f2937)",border:"none",padding:12,boxSizing:"border-box",outline:"none"},disabled:T||h}):e.jsxs("div",{style:{position:"relative"},children:[e.jsx("div",{ref:W,id:D,className:"nice-htmleditor__content",contentEditable:!T&&!h,dangerouslySetInnerHTML:{__html:n},onInput:Je,onKeyDown:Ze,onPaste:Ge,onDrop:Qe,onDragOver:He,style:{minHeight:r},"data-placeholder":i,role:"textbox","aria-multiline":"true",suppressContentEditableWarning:!0}),q&&ze.length>0&&e.jsx("ul",{className:"nice-htmleditor__mention-list",children:ze.map((B,de)=>e.jsx("li",{className:`nice-htmleditor__mention-item ${de===L?"nice-htmleditor__mention-item--active":""}`,onMouseDown:xe=>{xe.preventDefault(),We(B)},children:B.label},B.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:[b>0&&e.jsxs("span",{children:[re," / ",b]}),C&&e.jsxs("span",{children:[ve," words"]}),C&&e.jsxs("span",{children:[re," chars"]}),s&&e.jsx("span",{style:{fontWeight:600},children:"HTML Source"}),z&&e.jsx("span",{style:{fontWeight:600},children:"Markdown"})]})]}),V&&e.jsx("div",{className:"nice-field__error",children:V}),Y&&!V&&e.jsx("div",{className:"nice-field__hint",children:Y})]})},ra=Object.freeze(Object.defineProperty({__proto__:null,NiceHtmlEditor:jt},Symbol.toStringTag,{value:"Module"})),la=[{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"}],sa=[{style:"professional",label:"Professional"},{style:"casual",label:"Casual"},{style:"formal",label:"Formal"},{style:"concise",label:"Concise"}];a.forwardRef(function(n,t){var ve,ie;const{enableAI:i=!0,aiModel:r,enableImprove:d=!0,enableTranslate:h=!0,enableGenerate:y=!0,toolbar:N,languages:$=la,textStyles:S=sa,onImprove:H,onTranslate:I,onGenerate:b,showAIToolbar:C=!0,value:P,onChange:ee,...V}=n,Y=a.useRef(null),[p,T]=a.useState(!1),[w,E]=a.useState(!1),[G,g]=a.useState(!1),[k,v]=a.useState(""),[A,D]=a.useState(""),[W,x]=a.useState("professional"),[c,z]=a.useState(""),[_,j]=a.useState(((ve=$[0])==null?void 0:ve.code)||"en"),[o,s]=a.useState(""),[m,l]=a.useState(""),{t:u}=F.ue(),q=F.me(),{improveText:O,translate:Z,generateHtml:le,isLoading:L}=F.Vd(),U=i&&q.isConfigured,ae=a.useCallback(()=>{const M=window.getSelection();return M&&M.toString().trim()?M.toString():""},[]),se=a.useCallback(M=>{const R=window.getSelection();if(R&&R.rangeCount>0){const Q=R.getRangeAt(0);Q.deleteContents();const ge=document.createElement("div");ge.innerHTML=M;const fe=document.createDocumentFragment();for(;ge.firstChild;)fe.appendChild(ge.firstChild);if(Q.insertNode(fe),Y.current){const X=Y.current.innerHTML;ee(X)}}},[ee]),he=a.useCallback(async(M="professional")=>{if(!U||!d)return"";const R=ae();if(!R)return"";v(R),x(M),T(!0),D("");try{const Q=await O(R,M);return D(Q),H==null||H(R,Q,M),Q}catch{return D(u("htmlEditorAI.improveFailed","Failed to improve text")),""}},[U,d,ae,O,H,u]),me=a.useCallback(async M=>{var Q;if(!U||!h)return"";const R=ae();if(!R)return"";v(R),j(M),E(!0),z("");try{const ge=((Q=$.find(X=>X.code===M))==null?void 0:Q.label)||M,fe=await Z(R,ge);return z(fe),I==null||I(R,fe,M),fe}catch{return z(u("htmlEditorAI.translateFailed","Failed to translate text")),""}},[U,h,ae,Z,$,I,u]),_e=a.useCallback(async M=>{if(!U||!y||!M.trim())return"";s(M),l("");try{const R=await le(M);return l(R),b==null||b(M,R),R}catch{return l(u("htmlEditorAI.generateFailed","Failed to generate HTML")),""}},[U,y,le,b,u]),J=a.useCallback(()=>{A&&se(A),T(!1),D("")},[A,se]),re=a.useCallback(()=>{c&&se(c),E(!1),z("")},[c,se]),ce=a.useCallback(()=>{if(m&&Y.current){document.execCommand("insertHTML",!1,m);const M=Y.current.innerHTML;ee(M)}g(!1),l(""),s("")},[m,ee]);return a.useImperativeHandle(t,()=>({getEditor:()=>Y.current,focus:()=>{var M;return(M=Y.current)==null?void 0:M.focus()},getValue:()=>{var M;return((M=Y.current)==null?void 0:M.innerHTML)||""},setValue:M=>{Y.current&&(Y.current.innerHTML=M,ee(M))},getSelection:ae,insertHtml:M=>{document.execCommand("insertHTML",!1,M),Y.current&&ee(Y.current.innerHTML)},improveSelection:he,translateSelection:me,generateHtml:_e})),a.useCallback(M=>{Y.current=M},[]),e.jsxs("div",{className:"nice-html-editor-ai","data-testid":n["data-testid"],children:[C&&U&&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"}),L&&e.jsx("span",{className:"nice-html-editor-ai__loading",children:u("htmlEditorAI.processing","Processing...")})]}),e.jsxs("div",{className:"nice-html-editor-ai__toolbar-right",children:[d&&e.jsxs("div",{className:"nice-html-editor-ai__dropdown",children:[e.jsxs("button",{type:"button",className:"nice-html-editor-ai__btn",onClick:()=>he(),disabled:L,title:u("htmlEditorAI.improveText","Improve selected text"),children:["✨ ",u("htmlEditorAI.improve","Improve")]}),e.jsx("div",{className:"nice-html-editor-ai__dropdown-menu",children:S.map(({style:M,label:R})=>e.jsx("button",{type:"button",className:"nice-html-editor-ai__dropdown-item",onClick:()=>he(M),children:R},M))})]}),h&&e.jsxs("div",{className:"nice-html-editor-ai__dropdown",children:[e.jsxs("button",{type:"button",className:"nice-html-editor-ai__btn",disabled:L,title:u("htmlEditorAI.translateText","Translate selected text"),children:["🌐 ",u("htmlEditorAI.translate","Translate")]}),e.jsx("div",{className:"nice-html-editor-ai__dropdown-menu nice-html-editor-ai__dropdown-menu--languages",children:$.map(({code:M,label:R})=>e.jsx("button",{type:"button",className:"nice-html-editor-ai__dropdown-item",onClick:()=>me(M),children:R},M))})]}),y&&e.jsxs("button",{type:"button",className:"nice-html-editor-ai__btn",onClick:()=>g(!0),disabled:L,title:u("htmlEditorAI.generateHtml","Generate HTML from description"),children:["⚡ ",u("htmlEditorAI.generate","Generate")]})]})]}),e.jsx("div",{className:"nice-html-editor-ai__editor-wrapper",children:e.jsx(jt,{value:P,onChange:ee,toolbar:N,...V})}),p&&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:["✨ ",u("htmlEditorAI.improveText","Improve Text")]}),e.jsx("div",{className:"nice-html-editor-ai__style-selector",children:S.map(({style:M,label:R})=>e.jsx("button",{type:"button",className:`nice-html-editor-ai__style-btn ${W===M?"nice-html-editor-ai__style-btn--active":""}`,onClick:()=>{x(M),he(M)},children:R},M))}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__close",onClick:()=>T(!1),children:"✕"})]}),e.jsx("div",{className:"nice-html-editor-ai__panel-body",children:L?e.jsx("div",{className:"nice-html-editor-ai__loading-panel",children:u("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:u("htmlEditorAI.original","Original")}),e.jsx("div",{className:"nice-html-editor-ai__text-content",children:k})]}),e.jsxs("div",{className:"nice-html-editor-ai__text-block nice-html-editor-ai__text-block--improved",children:[e.jsx("h5",{children:u("htmlEditorAI.improved","Improved")}),e.jsx("div",{className:"nice-html-editor-ai__text-content",children:A})]})]})}),e.jsxs("div",{className:"nice-html-editor-ai__panel-footer",children:[e.jsxs("button",{type:"button",className:"nice-html-editor-ai__apply",onClick:J,disabled:!A||L,children:["✓ ",u("htmlEditorAI.apply","Apply")]}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__cancel",onClick:()=>{T(!1),D("")},children:u("htmlEditorAI.cancel","Cancel")})]})]}),w&&e.jsxs("div",{className:"nice-html-editor-ai__panel",children:[e.jsxs("div",{className:"nice-html-editor-ai__panel-header",children:[e.jsxs("h4",{children:["🌐 ",u("htmlEditorAI.translateText","Translate Text")]}),e.jsx("div",{className:"nice-html-editor-ai__language-selector",children:e.jsx("select",{value:_,onChange:M=>{j(M.target.value),me(M.target.value)},className:"nice-html-editor-ai__language-select",children:$.map(({code:M,label:R})=>e.jsx("option",{value:M,children:R},M))})}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__close",onClick:()=>E(!1),children:"✕"})]}),e.jsx("div",{className:"nice-html-editor-ai__panel-body",children:L?e.jsx("div",{className:"nice-html-editor-ai__loading-panel",children:u("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:u("htmlEditorAI.original","Original")}),e.jsx("div",{className:"nice-html-editor-ai__text-content",children:k})]}),e.jsxs("div",{className:"nice-html-editor-ai__text-block nice-html-editor-ai__text-block--translated",children:[e.jsx("h5",{children:((ie=$.find(M=>M.code===_))==null?void 0:ie.label)||_}),e.jsx("div",{className:"nice-html-editor-ai__text-content",children:c})]})]})}),e.jsxs("div",{className:"nice-html-editor-ai__panel-footer",children:[e.jsxs("button",{type:"button",className:"nice-html-editor-ai__apply",onClick:re,disabled:!c||L,children:["✓ ",u("htmlEditorAI.apply","Apply")]}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__cancel",onClick:()=>{E(!1),z("")},children:u("htmlEditorAI.cancel","Cancel")})]})]}),G&&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:["⚡ ",u("htmlEditorAI.generateHtml","Generate HTML")]}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__close",onClick:()=>{g(!1),l(""),s("")},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:u("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:o,onChange:M=>s(M.target.value),className:"nice-html-editor-ai__generate-textarea",rows:3}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__generate-btn",onClick:()=>_e(o),disabled:L||!o.trim(),children:L?u("htmlEditorAI.generating","Generating..."):u("htmlEditorAI.generate","Generate")})]}),m&&e.jsxs("div",{className:"nice-html-editor-ai__generate-result",children:[e.jsx("h5",{children:u("htmlEditorAI.preview","Preview")}),e.jsx("div",{className:"nice-html-editor-ai__preview",dangerouslySetInnerHTML:{__html:m}}),e.jsx("h5",{children:u("htmlEditorAI.htmlCode","HTML Code")}),e.jsx("pre",{className:"nice-html-editor-ai__code",children:m})]})]}),e.jsxs("div",{className:"nice-html-editor-ai__panel-footer",children:[e.jsxs("button",{type:"button",className:"nice-html-editor-ai__apply",onClick:ce,disabled:!m||L,children:["✓ ",u("htmlEditorAI.insert","Insert")]}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__cancel",onClick:()=>{g(!1),l(""),s("")},children:u("htmlEditorAI.cancel","Cancel")})]})]})]})});const rn=a.forwardRef(({length:n=6,value:t="",onChange:i,masked:r=!1,onComplete:d,label:h,helperText:y,error:N,required:$,disabled:S,readOnly:H,size:I="md",name:b,id:C,className:P,style:ee,autoFocus:V,labelPlacement:Y,errorPlacement:p,labelWidth:T,controlWidth:w,loading:E,cellWidth:G,...g},k)=>{const v=F.nl(C),A=a.useRef([]),D=t.padEnd(n,"").slice(0,n).split(""),W=a.useCallback(j=>{var s;const o=Math.max(0,Math.min(n-1,j));(s=A.current[o])==null||s.focus()},[n]),x=a.useCallback(j=>{const o=j.join("");i==null||i(o),o.length===n&&o.indexOf("")===-1&&/^\d+$/.test(o)&&(d==null||d(o))},[i,d,n]),c=a.useCallback((j,o)=>{const s=o.target.value.replace(/\D/g,"").slice(-1);if(!s)return;const m=[...D];m[j]=s,x(m),W(j+1)},[D,x,W]),z=a.useCallback((j,o)=>{if(o.key==="Backspace"){o.preventDefault();const s=[...D];D[j]?(s[j]="",x(s)):j>0&&(s[j-1]="",x(s),W(j-1))}else o.key==="ArrowLeft"?(o.preventDefault(),W(j-1)):o.key==="ArrowRight"&&(o.preventDefault(),W(j+1))},[D,x,W]),_=a.useCallback(j=>{j.preventDefault();const o=j.clipboardData.getData("text").replace(/\D/g,"").slice(0,n);if(!o)return;const s=o.padEnd(n,"").slice(0,n).split("");for(let m=o.length;m<n;m++)s[m]=D[m]||"";x(s),W(Math.min(o.length,n-1))},[n,D,x,W]);return e.jsxs("div",{className:`nice-field nice-field--${I} nice-field--otp${Y?` nice-field--label-${Y}`:""}${p==="right"?" nice-field--error-right":""} ${E?"nice-field--loading":""} ${P||""}`,style:{...ee,...T!=null&&{"--nice-field-label-width":typeof T=="number"?`${T}px`:T},...w!=null&&{"--nice-field-control-width":typeof w=="number"?`${w}px`:w},...G!=null&&{"--nice-otp-cell-width":typeof G=="number"?`${G}px`:G}},"aria-busy":E||void 0,...g,children:[h&&e.jsx("label",{htmlFor:`${v}-0`,className:`nice-field__label ${$?"nice-field__label--required":""}`,children:h}),e.jsxs("div",{className:"nice-field__control",children:[e.jsxs("div",{ref:k,className:`nice-otp nice-otp--${I} ${N?"nice-otp--error":""} ${S?"nice-otp--disabled":""}`,onPaste:_,children:[Array.from({length:n},(j,o)=>e.jsx("input",{ref:s=>{A.current[o]=s},id:o===0?`${v}-0`:void 0,className:"nice-otp__digit",type:r?"password":"text",inputMode:"numeric",maxLength:2,value:D[o]||"",disabled:S,readOnly:H,autoFocus:V&&o===0,"aria-invalid":!!N,"aria-label":`${o+1}`,onChange:s=>c(o,s),onKeyDown:s=>z(o,s),onFocus:s=>s.target.select()},o)),b&&e.jsx("input",{type:"hidden",name:b,value:t})]}),p==="right"&&N&&e.jsx("div",{id:`${v}-error`,className:"nice-field__error",role:"alert",children:N}),p==="right"&&!N&&y&&e.jsx("div",{id:`${v}-helper`,className:"nice-field__helper",children:y}),E&&e.jsx("span",{className:"nice-field__spinner",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})})]}),p!=="right"&&N&&e.jsx("div",{id:`${v}-error`,className:"nice-field__error",role:"alert",children:N}),p!=="right"&&!N&&y&&e.jsx("div",{id:`${v}-helper`,className:"nice-field__helper",children:y})]})});rn.displayName="NiceInputOtp";const oa={xxs:36,xs:48,sm:64,md:80,lg:100,xl:128,xxl:160},st=6,nt=135,ln=405,Ke=ln-nt;function vt(n,t,i,r){const d=(r-90)*(Math.PI/180);return{x:n+i*Math.cos(d),y:t+i*Math.sin(d)}}function Dt(n,t,i,r,d){const h=vt(n,t,i,r),y=vt(n,t,i,d),N=d-r>180?1:0;return`M ${h.x} ${h.y} A ${i} ${i} 0 ${N} 1 ${y.x} ${y.y}`}const sn=a.forwardRef(({value:n=0,onChange:t,min:i=0,max:r=100,step:d=1,showValue:h=!0,valueTemplate:y="{value}",label:N,helperText:$,error:S,required:H,disabled:I,readOnly:b,size:C="md",name:P,id:ee,className:V,style:Y,labelPlacement:p="top",errorPlacement:T,labelWidth:w,controlWidth:E,loading:G,isLabelCentered:g=!0,...k},v)=>{const A=F.nl(ee),D=a.useRef(!1),W=a.useRef(null),x=typeof C=="number"?C:oa[C],c=x/2,z=x/2,_=(x-st*2)/2,j=r>i?(n-i)/(r-i):0,o=nt+j*Ke,s=a.useCallback(O=>{let Z=O-nt;Z<0&&(Z+=360),Z>Ke&&(Z=Z-Ke<360-Z?Ke:0);const le=Math.max(0,Math.min(1,Z/Ke)),L=i+le*(r-i),U=Math.round(L/d)*d;return Math.max(i,Math.min(r,U))},[i,r,d]),m=a.useCallback(O=>{if(I||b)return;const Z=W.current;if(!Z)return;const le=Z.getBoundingClientRect(),L=O.clientX-le.left-le.width/2,U=O.clientY-le.top-le.height/2;let ae=Math.atan2(L,-U)*(180/Math.PI);ae<0&&(ae+=360);const se=s(ae);t==null||t(se)},[s,I,b,t]);a.useEffect(()=>{const O=le=>{D.current&&m(le)},Z=()=>{D.current=!1};return window.addEventListener("pointermove",O),window.addEventListener("pointerup",Z),()=>{window.removeEventListener("pointermove",O),window.removeEventListener("pointerup",Z)}},[m]);const l=a.useCallback(O=>{if(I||b)return;let Z=n;O.key==="ArrowUp"||O.key==="ArrowRight"?(O.preventDefault(),Z=Math.min(r,n+d)):(O.key==="ArrowDown"||O.key==="ArrowLeft")&&(O.preventDefault(),Z=Math.max(i,n-d)),Z!==n&&(t==null||t(Z))},[n,t,i,r,d,I,b]),u=y.replace("{value}",String(n)),q=vt(c,z,_,o);return e.jsxs("div",{className:`nice-field nice-knob-field nice-knob-field--err-${T||"bottom"} nice-field--${typeof C=="string"?C:"md"} ${G?"nice-field--loading":""} ${V||""}`,style:{...Y,...w!=null&&{"--nice-field-label-width":typeof w=="number"?`${w}px`:w},...E!=null&&{"--nice-field-control-width":typeof E=="number"?`${E}px`:E}},"aria-busy":G||void 0,...k,children:[e.jsxs("div",{className:`nice-knob-field__inner nice-knob-field--${p} ${g?"nice-knob-field--label-centered":""}`,children:[N&&e.jsx("label",{htmlFor:A,className:`nice-field__label ${H?"nice-field__label--required":""}`,children:N}),e.jsx("div",{className:"nice-field__control",children:e.jsxs("div",{ref:O=>{W.current=O,typeof v=="function"?v(O):v&&(v.current=O)},className:`nice-knob nice-knob--${C} ${I?"nice-knob--disabled":""} ${S?"nice-knob--error":""}`,role:"slider",id:A,tabIndex:I?-1:0,"aria-valuenow":n,"aria-valuemin":i,"aria-valuemax":r,"aria-disabled":I,"aria-invalid":!!S,onPointerDown:O=>{I||b||(D.current=!0,m(O))},onKeyDown:l,children:[e.jsxs("svg",{width:x,height:x,viewBox:`0 0 ${x} ${x}`,children:[e.jsx("path",{d:Dt(c,z,_,nt,ln),fill:"none",stroke:"var(--nice-border-color, #d1d5db)",strokeWidth:st,strokeLinecap:"round"}),j>0&&e.jsx("path",{d:Dt(c,z,_,nt,o),fill:"none",stroke:"var(--nice-primary, #3b82f6)",strokeWidth:st,strokeLinecap:"round"}),e.jsx("circle",{cx:q.x,cy:q.y,r:st,fill:"var(--nice-primary, #3b82f6)"})]}),h&&e.jsx("span",{className:"nice-knob__value",children:u}),P&&e.jsx("input",{type:"hidden",name:P,value:n}),G&&e.jsx("span",{className:"nice-knob__spinner","aria-hidden":"true",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})})]})})]}),S&&e.jsx("div",{className:"nice-field__error",role:"alert",children:S}),!S&&$&&e.jsx("div",{className:"nice-field__helper",children:$})]})});sn.displayName="NiceKnob";const on=a.forwardRef(({value:n="",onChange:t,suggestions:i=[],onSearch:r,trigger:d="@",renderSuggestion:h,placeholder:y,rows:N=3,label:$,helperText:S,error:H,required:I,disabled:b,readOnly:C,size:P="md",name:ee,id:V,className:Y,style:p,...T},w)=>{const E=F.nl(V),[G,g]=a.useState(!1),[k,v]=a.useState(""),[A,D]=a.useState(0),[W,x]=a.useState({top:0,left:0}),c=a.useRef(null),z=a.useRef(-1),_=i.map(l=>typeof l=="string"?{key:l,label:l}:l).filter(l=>l.label.toLowerCase().includes(k.toLowerCase())),j=a.useCallback(()=>{g(!1),v(""),D(0),z.current=-1},[]),o=a.useCallback(l=>{const u=c.current;if(!u||z.current<0)return;const q=n.slice(0,z.current),O=n.slice(u.selectionStart),Z=`${d}${l.label} `,le=q+Z+O;t==null||t(le),j(),requestAnimationFrame(()=>{const L=q.length+Z.length;u.setSelectionRange(L,L),u.focus()})},[n,t,d,j]),s=a.useCallback(l=>{const u=l.target.value;t==null||t(u);const q=l.target.selectionStart,O=u.slice(0,q),Z=O.lastIndexOf(d);if(Z>=0){const le=Z>0?O[Z-1]:" ",L=O.slice(Z+d.length);if(/\s/.test(le)&&!/\s/.test(L)){z.current=Z;const U=L;v(U),g(!0),D(0),r==null||r(U);const ae=l.target,se=ae.getBoundingClientRect(),he=parseInt(getComputedStyle(ae).lineHeight)||20,me=O.split(`
|
|
11
|
+
`);x({top:se.top+me.length*he+4-ae.scrollTop,left:se.left+8});return}}j()},[t,d,r,j]),m=a.useCallback(l=>{!G||_.length===0||(l.key==="ArrowDown"?(l.preventDefault(),D(u=>(u+1)%_.length)):l.key==="ArrowUp"?(l.preventDefault(),D(u=>(u-1+_.length)%_.length)):l.key==="Enter"?(l.preventDefault(),_[A]&&o(_[A])):l.key==="Escape"&&j())},[G,_,A,o,j]);return a.useEffect(()=>{if(!G)return;const l=u=>{const q=c.current;q&&!q.contains(u.target)&&j()};return document.addEventListener("mousedown",l),()=>document.removeEventListener("mousedown",l)},[G,j]),e.jsxs("div",{className:`nice-field ${Y||""}`,style:p,...T,children:[$&&e.jsx("label",{htmlFor:E,className:`nice-field__label ${I?"nice-field__label--required":""}`,children:$}),e.jsxs("div",{className:`nice-mention nice-mention--${P} ${H?"nice-mention--error":""} ${b?"nice-mention--disabled":""}`,children:[e.jsx("textarea",{ref:l=>{c.current=l,typeof w=="function"?w(l):w&&(w.current=l)},id:E,name:ee,className:"nice-mention__input",value:n,onChange:s,onKeyDown:m,placeholder:y,rows:N,disabled:b,readOnly:C,"aria-invalid":!!H,"aria-describedby":H?`${E}-error`:S?`${E}-helper`:void 0,"aria-autocomplete":"list","aria-expanded":G}),G&&_.length>0&&e.jsx("ul",{className:"nice-mention__suggestions",role:"listbox",style:{position:"fixed",top:W.top,left:W.left},children:_.map((l,u)=>e.jsx("li",{role:"option","aria-selected":u===A,className:`nice-mention__suggestion ${u===A?"nice-mention__suggestion--active":""}`,onMouseDown:q=>{q.preventDefault(),o(l)},onMouseEnter:()=>D(u),children:h?h(l):e.jsxs(e.Fragment,{children:[l.icon&&e.jsx("span",{className:"nice-mention__suggestion-icon",children:l.icon}),e.jsx("span",{children:l.label})]})},l.key))})]}),H&&e.jsx("div",{id:`${E}-error`,className:"nice-field__error",role:"alert",children:H}),!H&&S&&e.jsx("div",{id:`${E}-helper`,className:"nice-field__helper",children:S})]})});on.displayName="NiceMention";function ca(n){const t=[],i=r=>{for(const d of r)t.push(d),d.children&&i(d.children)};return i(n),t}function cn(n,t){const i=t.toLowerCase();return n.reduce((r,d)=>{const h=d.children?cn(d.children,t):[];return(d.label.toLowerCase().includes(i)||h.length>0)&&r.push({...d,children:h.length>0?h:d.children}),r},[])}const dn=({node:n,level:t,selectedKeys:i,expandedKeys:r,onToggleExpand:d,onSelect:h,selectableLeafsOnly:y,maxDepth:N})=>{const $=typeof N=="number"?Math.min(10,Math.max(1,N)):1/0,S=!(t+1>=$)&&n.children&&n.children.length>0,H=r.has(n.key),I=i.has(n.key),b=!S,C=!n.disabled&&(!y||b),P=Math.min(t+1,10),ee={paddingLeft:t*16+8,"--nice-row-bg":`var(--nice-tree-level-${P}-bg, transparent)`,"--nice-row-text":`var(--nice-tree-level-${P}-text, inherit)`,"--nice-row-hover-bg":`var(--nice-tree-level-${P}-hover-bg, var(--bg-secondary, #f3f4f6))`,"--nice-row-active-bg":`var(--nice-tree-level-${P}-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 ${I?"nice-tree-select__node--selected":""} ${n.disabled?"nice-tree-select__node--disabled":""}`,style:ee,"data-nice-depth":P,onClick:()=>C&&h(n.key),role:"treeitem","aria-selected":I,"aria-expanded":S?H:void 0,"aria-disabled":n.disabled,children:[S?e.jsx("button",{type:"button",className:"nice-tree-select__toggle",onClick:V=>{V.stopPropagation(),d(n.key)},"aria-label":"Toggle",children:e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"currentColor",style:{transform:H?"rotate(90deg)":"none",transition:"transform 0.15s"},children:e.jsx("path",{d:"M4.5 2l4 4-4 4"})})}):e.jsx("span",{style:{width:12,display:"inline-block"}}),(n.icon==null,null),e.jsx("span",{className:"nice-tree-select__node-label",children:n.label})]}),S&&H&&n.children.map(V=>e.jsx(dn,{node:V,level:t+1,selectedKeys:i,expandedKeys:r,onToggleExpand:d,onSelect:h,selectableLeafsOnly:y,maxDepth:N},V.key))]})},un=a.forwardRef(({nodes:n,value:t,onChange:i,multiple:r=!1,searchable:d=!1,placeholder:h,selectableLeafsOnly:y=!1,clearable:N=!1,maxDepth:$,label:S,helperText:H,error:I,required:b,disabled:C,readOnly:P,size:ee="md",name:V,id:Y,className:p,style:T,controlWidth:w,...E},G)=>{const{t:g}=F.ue(),k=F.nl(Y),[v,A]=a.useState(!1),[D,W]=a.useState(""),[x,c]=a.useState(new Set),z=a.useRef(null);F.sl(z,()=>A(!1));const _=a.useMemo(()=>t==null?new Set:new Set(Array.isArray(t)?t:[t]),[t]),j=a.useMemo(()=>D?cn(n,D):n,[n,D]),o=a.useMemo(()=>{const u=ca(n);return Array.from(_).map(q=>{var O;return(O=u.find(Z=>Z.key===q))==null?void 0:O.label}).filter(Boolean)},[_,n]),s=a.useCallback(u=>{c(q=>{const O=new Set(q);return O.has(u)?O.delete(u):O.add(u),O})},[]),m=a.useCallback(u=>{if(r){const q=new Set(_);q.has(u)?q.delete(u):q.add(u),i==null||i(Array.from(q))}else i==null||i(u),A(!1)},[r,_,i]),l=a.useCallback(u=>{u.stopPropagation(),i==null||i(r?[]:"")},[i,r]);return e.jsxs("div",{className:`nice-field nice-field--${ee} ${p||""}`,style:{width:"fit-content",maxWidth:"100%",...T},...E,children:[S&&e.jsx("label",{htmlFor:k,className:`nice-field__label ${b?"nice-field__label--required":""}`,children:S}),e.jsxs("div",{ref:z,className:"nice-tree-select",style:{position:"relative",width:w!=null?typeof w=="number"?`${w}px`:w:240},children:[e.jsxs("div",{ref:G,id:k,className:`nice-input nice-input--${ee} ${I?"nice-input--error":""} ${C?"nice-input--disabled":""} ${P?"nice-input--readonly":""}`,role:"combobox","aria-expanded":v,"aria-haspopup":"tree","aria-invalid":!!I,tabIndex:C?-1:0,onClick:()=>!C&&!P&&A(!v),onKeyDown:u=>{(u.key==="Enter"||u.key===" ")&&(u.preventDefault(),!C&&!P&&A(!v))},children:[e.jsx("span",{className:"nice-tree-select__display",children:o.length>0?o.join(", "):e.jsx("span",{className:"nice-tree-select__placeholder",children:h??g("controls.select","Select...")})}),N&&_.size>0&&e.jsx("button",{type:"button",className:"nice-input__clear",onClick:l,"aria-label":g("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:v?"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"})})]}),v&&e.jsxs("div",{className:"nice-tree-select__dropdown",role:"tree",children:[d&&e.jsx("div",{className:"nice-tree-select__search",children:e.jsx("input",{className:"nice-input__native",type:"text",placeholder:g("controls.search","Search..."),value:D,onChange:u=>W(u.target.value),autoFocus:!0,onClick:u=>u.stopPropagation()})}),e.jsx("div",{className:"nice-tree-select__list",children:j.length===0?e.jsx("div",{className:"nice-tree-select__empty",children:g("controls.noResults","No results")}):j.map(u=>e.jsx(dn,{node:u,level:0,selectedKeys:_,expandedKeys:x,onToggleExpand:s,onSelect:m,selectableLeafsOnly:y,maxDepth:$},u.key))})]})]}),V&&e.jsx("input",{type:"hidden",name:V,value:Array.isArray(t)?t.join(","):t??""}),I&&e.jsx("div",{id:`${k}-error`,className:"nice-field__error",role:"alert",children:I}),!I&&H&&e.jsx("div",{id:`${k}-helper`,className:"nice-field__helper",children:H})]})});un.displayName="NiceTreeSelect";function Xe(n,t){return String(n[t])}const pn=a.forwardRef(({source:n,target:t,onChange:i,keyField:r="id",labelField:d="label",renderItem:h,filterable:y=!1,searchable:N,groupBy:$,sortable:S=!1,bulkActions:H=!0,maxRight:I,sourceHeader:b,targetHeader:C,disabled:P=!1,size:ee="md",className:V,style:Y,id:p,...T},w)=>{const{t:E}=F.ue(),[G,g]=a.useState(new Set),[k,v]=a.useState(new Set),[A,D]=a.useState(""),[W,x]=a.useState(""),c=a.useCallback((u,q,O)=>{q(Z=>{const le=new Set(Z);return le.has(O)?le.delete(O):le.add(O),le})},[]),z=a.useCallback(()=>{const u=n.filter(le=>G.has(Xe(le,r))),q=n.filter(le=>!G.has(Xe(le,r))),O=typeof I=="number"?u.slice(0,Math.max(0,I-t.length)):u,Z=u.slice(O.length);i([...q,...Z],[...t,...O]),g(new Set)},[n,t,G,r,i,I]),_=a.useCallback(()=>{const u=t.filter(O=>k.has(Xe(O,r))),q=t.filter(O=>!k.has(Xe(O,r)));i([...n,...u],q),v(new Set)},[n,t,k,r,i]),j=a.useCallback(()=>{if(typeof I=="number"){const u=Math.max(0,I-t.length),q=n.slice(0,u),O=n.slice(u);i(O,[...t,...q])}else i([],[...t,...n]);g(new Set)},[n,t,i,I]),o=a.useCallback(()=>{i([...n,...t],[]),v(new Set)},[n,t,i]),s=(u,q)=>{if(!q)return u;const O=q.toLowerCase();return u.filter(Z=>String(Z[d]).toLowerCase().includes(O))},m=H===!1?{moveAll:!1,removeAll:!1}:H===!0||H===void 0?{moveAll:!0,removeAll:!0}:{moveAll:H.moveAll??!0,removeAll:H.removeAll??!0},l=(u,q,O,Z,le,L,U)=>{const ae=s(u,Z),se=N===!0||y&&N===void 0?"both":N??!1,he=se==="both"||se==="left"&&U==="left"||se==="right"&&U==="right",me=(()=>{if(!$)return[{label:"",items:ae}];const re=new Map;for(const ce of ae){const ve=String($(ce));let ie=re.get(ve);ie||(ie=[],re.set(ve,ie)),ie.push(ce)}return[...re.entries()].map(([ce,ve])=>({label:ce,items:ve}))})(),_e=(re,ce)=>{re.dataTransfer.setData("text/plain",ce),re.dataTransfer.effectAllowed="move"},J=(re,ce)=>{re.preventDefault();const ve=re.dataTransfer.getData("text/plain");if(!ve||ve===ce||U!=="right"||!S)return;const ie=[...t],M=ie.findIndex(ge=>Xe(ge,r)===ve),R=ie.findIndex(ge=>Xe(ge,r)===ce);if(M===-1||R===-1)return;const[Q]=ie.splice(M,1);ie.splice(R,0,Q),i(n,ie)};return e.jsxs("div",{className:"nice-picklist__panel",children:[L&&e.jsx("div",{className:"nice-picklist__header",children:L}),he&&e.jsx("div",{className:"nice-picklist__filter",children:e.jsx("input",{className:"nice-input__native",type:"text",placeholder:E("controls.search","Search..."),value:Z,onChange:re=>le(re.target.value)})}),e.jsxs("div",{className:"nice-picklist__list",role:"listbox","aria-multiselectable":"true",children:[me.map(re=>e.jsxs(a.Fragment,{children:[re.label&&e.jsx("div",{className:"nice-picklist__group-header",role:"presentation",children:re.label}),re.items.map(ce=>{const ve=Xe(ce,r),ie=q.has(ve);return e.jsx("div",{className:`nice-picklist__item ${ie?"nice-picklist__item--selected":""}`,role:"option","aria-selected":ie,draggable:S&&U==="right",onDragStart:S&&U==="right"?M=>_e(M,ve):void 0,onDragOver:S&&U==="right"?M=>M.preventDefault():void 0,onDrop:S&&U==="right"?M=>J(M,ve):void 0,onClick:()=>!P&&c(q,O,ve),children:h?h(ce,U):String(ce[d])},ve)})]},re.label||"__none__")),ae.length===0&&e.jsx("div",{className:"nice-picklist__empty",children:E("controls.noItems","No items")})]})]})};return e.jsxs("div",{ref:w,id:p,className:`nice-picklist nice-picklist--${ee} ${P?"nice-picklist--disabled":""} ${V||""}`,style:Y,...T,children:[l(n,G,g,A,D,b??E("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||G.size===0,onClick:z,"aria-label":E("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"})})}),m.moveAll&&e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm",disabled:P||n.length===0,onClick:j,"aria-label":E("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||k.size===0,onClick:_,"aria-label":E("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"})})}),m.removeAll&&e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm",disabled:P||t.length===0,onClick:o,"aria-label":E("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"})]})})]}),l(t,k,v,W,x,C??E("picklist.target","Selected"),"right")]})});pn.displayName="NicePickList";let et=null,tt=null;const da="0.45.0",pt=`https://cdn.jsdelivr.net/npm/monaco-editor@${da}/min/vs`,It=15e3;function Pt(){var r;const n=window;if((r=n.MonacoEnvironment)!=null&&r.getWorkerUrl)return;const t=`self.MonacoEnvironment={baseUrl:'${pt}/'};importScripts('${pt}/base/worker/workerMain.js');`,i=URL.createObjectURL(new Blob([t],{type:"text/javascript"}));n.MonacoEnvironment={getWorkerUrl:()=>i}}function Ye(n){var i;if(n!=="auto")return n;if(typeof document>"u")return"vs";const t=document.documentElement.dataset.theme;return t==="dark"?"vs-dark":t==="light"?"vs":(i=window.matchMedia)!=null&&i.call(window,"(prefers-color-scheme: dark)").matches?"vs-dark":"vs"}function hn(){return tt?Promise.resolve(tt):et||(et=new Promise((n,t)=>{if(window.monaco){Pt(),tt=window.monaco,n(tt);return}let i=!1;const r=window.setTimeout(()=>{i||(i=!0,et=null,t(new Error(`Monaco editor failed to load within ${It}ms`)))},It),d=document.createElement("script");d.src=`${pt}/loader.min.js`,d.async=!0,d.onload=()=>{const h=window.require;h.config({paths:{vs:pt}}),Pt(),h(["vs/editor/editor.main"],y=>{i||(i=!0,window.clearTimeout(r),tt=y,n(y))})},d.onerror=()=>{i||(i=!0,window.clearTimeout(r),et=null,t(new Error("Failed to load Monaco Editor loader script")))},document.head.appendChild(d)}),et)}const Ct=a.forwardRef(function(n,t){const{value:i,onChange:r,language:d="plaintext",theme:h="auto",options:y={},height:N=400,width:$="100%",markers:S=[],decorations:H=[],completionProvider:I,onMount:b,onCursorPositionChange:C,onSelectionChange:P,onSave:ee,loading:V,disabled:Y=!1,showToolbar:p=!1,showStatusBar:T=!1,editorSize:w="standard",className:E,"data-testid":G,lsp:g}=n,k=a.useRef(null),v=a.useRef(null),A=a.useRef(null),D=a.useRef([]),W=a.useRef(null),[x,c]=a.useState(!0),[z,_]=a.useState(null),[j,o]=a.useState({lineNumber:1,column:1}),[s,m]=a.useState(""),[l,u]=a.useState(y.wordWrap==="on"),q=a.useMemo(()=>({automaticLayout:!0,readOnly:Y||y.readOnly,minimap:{enabled:y.minimap??!0},lineNumbers:y.lineNumbers??"on",wordWrap:y.wordWrap??"off",tabSize:y.tabSize??2,insertSpaces:y.insertSpaces??!0,fontSize:y.fontSize??14,fontFamily:y.fontFamily??"'Fira Code', 'Consolas', 'Monaco', monospace",fontLigatures:y.fontLigatures??!0,cursorStyle:y.cursorStyle??"line",cursorBlinking:y.cursorBlinking??"blink",autoClosingBrackets:y.autoClosingBrackets??"languageDefined",autoClosingQuotes:y.autoClosingQuotes??"languageDefined",formatOnPaste:y.formatOnPaste??!1,formatOnType:y.formatOnType??!1,renderWhitespace:y.renderWhitespace??"selection",renderControlCharacters:y.renderControlCharacters??!1,scrollBeyondLastLine:y.scrollBeyondLastLine??!0,smoothScrolling:y.smoothScrolling??!0,folding:y.folding??!0,showFoldingControls:y.showFoldingControls??"mouseover","bracketPairColorization.enabled":y.bracketPairColorization??!0,guides:y.guides??{bracketPairs:!0,indentation:!0,highlightActiveIndentation:!0},stickyScroll:{enabled:y.stickyScroll??!1},quickSuggestions:y.quickSuggestions??!0,suggestOnTriggerCharacters:y.suggestOnTriggerCharacters??!0,acceptSuggestionOnEnter:y.acceptSuggestionOnEnter??"on",inlayHints:{enabled:y.inlayHints?"on":"off"}}),[y,Y]);a.useEffect(()=>{if(!k.current)return;let L=!0;return hn().then(async U=>{if(!L||!k.current)return;A.current=U;const ae=U.editor.create(k.current,{value:i,language:d,theme:Ye(h),...q});if(v.current=ae,c(!1),ae.onDidChangeModelContent(()=>{const se=ae.getValue();r==null||r(se)}),ae.onDidChangeCursorPosition(se=>{o({lineNumber:se.position.lineNumber,column:se.position.column}),C==null||C({lineNumber:se.position.lineNumber,column:se.position.column})}),ae.onDidChangeCursorSelection(se=>{var _e;const he=se.selection,me=((_e=ae.getModel())==null?void 0:_e.getValueInRange(he))??"";m(me),P==null||P({startLineNumber:he.startLineNumber,startColumn:he.startColumn,endLineNumber:he.endLineNumber,endColumn:he.endColumn})}),ae.addCommand(U.KeyMod.CtrlCmd|U.KeyCode.KeyS,()=>{ee==null||ee(ae.getValue())}),g&&typeof window<"u")try{await ht("https://cdn.jsdelivr.net/npm/vscode-ws-jsonrpc@1.0.2/lib/browser/index.min.js"),await ht("https://cdn.jsdelivr.net/npm/monaco-languageclient@0.15.0/lib/monaco-languageclient.min.js");const se=window,he=se.ReconnectingWebSocket,{MonacoLanguageClient:me,CloseAction:_e,ErrorAction:J,createConnection:re}=se.monacoLanguageClient||{};if(me&&re){const ce=g.url,ve=g.language,ie=new he(ce),M=new se.VSCodeWebSocketMessageReader(ie),R=new se.VSCodeWebSocketMessageWriter(ie),Q=re(M,R),ge=new me({name:"LSP Client",clientOptions:{documentSelector:[ve],initializationOptions:g.initOptions,errorHandler:{error:()=>J.Continue,closed:()=>_e.Restart}},connectionProvider:{get:()=>Promise.resolve(Q)}});ge.start(),v.current.__lspClient=ge}}catch(se){console.warn("LSP bridge failed to load:",se)}b==null||b(ae,U)}).catch(U=>{L&&(_(U.message??"Failed to load editor"),c(!1))}),()=>{var U,ae;if(L=!1,(U=v.current)==null||U.dispose(),(ae=W.current)==null||ae.dispose(),v.current&&v.current.__lspClient)try{v.current.__lspClient.stop()}catch{}}},[g]),a.useEffect(()=>{const L=v.current;if(L&&i!==L.getValue()){const U=L.getPosition();L.setValue(i),U&&L.setPosition(U)}},[i]),a.useEffect(()=>{const L=v.current,U=A.current;if(L&&U){const ae=L.getModel();ae&&U.editor.setModelLanguage(ae,d)}},[d]),a.useEffect(()=>{var he,me;const L=A.current;if(!L||(L.editor.setTheme(Ye(h)),h!=="auto"||typeof document>"u"))return;const U=()=>{var _e;(_e=A.current)==null||_e.editor.setTheme(Ye("auto"))},ae=new MutationObserver(U);ae.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme","class"]});const se=(he=window.matchMedia)==null?void 0:he.call(window,"(prefers-color-scheme: dark)");return(me=se==null?void 0:se.addEventListener)==null||me.call(se,"change",U),()=>{var _e;ae.disconnect(),(_e=se==null?void 0:se.removeEventListener)==null||_e.call(se,"change",U)}},[h]),a.useEffect(()=>{const L=v.current;L&&L.updateOptions(q)},[q]),a.useEffect(()=>{const L=v.current,U=A.current;if(L&&U){const ae=L.getModel();if(ae){const se=S.map(he=>({startLineNumber:he.startLineNumber,startColumn:he.startColumn,endLineNumber:he.endLineNumber,endColumn:he.endColumn,message:he.message,severity:he.severity}));U.editor.setModelMarkers(ae,"owner",se)}}},[S]),a.useEffect(()=>{const L=v.current;if(L&&H.length>0){const U=H.map(ae=>({range:{startLineNumber:ae.range.startLineNumber,startColumn:ae.range.startColumn,endLineNumber:ae.range.endLineNumber,endColumn:ae.range.endColumn},options:{className:ae.className,glyphMarginClassName:ae.glyphMarginClassName,hoverMessage:ae.hoverMessage?{value:ae.hoverMessage}:void 0,isWholeLine:ae.isWholeLine}}));D.current=L.deltaDecorations(D.current,U)}},[H]),a.useEffect(()=>{var ae;const L=A.current;if(!L||!I)return;(ae=W.current)==null||ae.dispose();const U={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 W.current=L.languages.registerCompletionItemProvider(d,{provideCompletionItems:async(se,he)=>({suggestions:(await I(se,he)).map(me=>({label:me.label,kind:U[me.kind]??0,insertText:me.insertText,insertTextRules:me.insertTextRules==="insertAsSnippet"?4:void 0,documentation:me.documentation,detail:me.detail,range:{startLineNumber:he.lineNumber,startColumn:he.column,endLineNumber:he.lineNumber,endColumn:he.column}}))})}),()=>{var se;(se=W.current)==null||se.dispose()}},[d,I]),a.useImperativeHandle(t,()=>({getEditor:()=>v.current,getMonaco:()=>A.current,focus:()=>{var L;return(L=v.current)==null?void 0:L.focus()},getValue:()=>{var L;return((L=v.current)==null?void 0:L.getValue())??""},setValue:L=>{var U;return(U=v.current)==null?void 0:U.setValue(L)},getSelection:()=>{var ae;const L=v.current;if(!L)return"";const U=L.getSelection();return U?((ae=L.getModel())==null?void 0:ae.getValueInRange(U))??"":""},insertText:L=>{const U=v.current;if(!U)return;const ae=U.getSelection();ae&&U.executeEdits("",[{range:ae,text:L}])},formatDocument:()=>{var L,U;(U=(L=v.current)==null?void 0:L.getAction("editor.action.formatDocument"))==null||U.run()},goToLine:(L,U=1)=>{const ae=v.current;ae&&(ae.setPosition({lineNumber:L,column:U}),ae.revealLineInCenter(L),ae.focus())},findReplace:()=>{var L,U;(U=(L=v.current)==null?void 0:L.getAction("editor.action.startFindReplaceAction"))==null||U.run()},undo:()=>{var L;(L=v.current)==null||L.trigger("keyboard","undo",null)},redo:()=>{var L;(L=v.current)==null||L.trigger("keyboard","redo",null)},getCursorPosition:()=>{var U;const L=(U=v.current)==null?void 0:U.getPosition();return{lineNumber:(L==null?void 0:L.lineNumber)??1,column:(L==null?void 0:L.column)??1}},setMarkers:L=>{const U=v.current,ae=A.current;if(U&&ae){const se=U.getModel();if(se){const he=L.map(me=>({startLineNumber:me.startLineNumber,startColumn:me.startColumn,endLineNumber:me.endLineNumber,endColumn:me.endColumn,message:me.message,severity:me.severity}));ae.editor.setModelMarkers(se,"owner",he)}}}}),[]);const O=a.useMemo(()=>({format:()=>{var L,U;return(U=(L=v.current)==null?void 0:L.getAction("editor.action.formatDocument"))==null?void 0:U.run()},undo:()=>{var L;return(L=v.current)==null?void 0:L.trigger("keyboard","undo",null)},redo:()=>{var L;return(L=v.current)==null?void 0:L.trigger("keyboard","redo",null)},find:()=>{var L,U;return(U=(L=v.current)==null?void 0:L.getAction("editor.action.startFindReplaceAction"))==null?void 0:U.run()},toggleWordWrap:()=>{var U;const L=!l;u(L),(U=v.current)==null||U.updateOptions({wordWrap:L?"on":"off"})},toggleMinimap:()=>{var U,ae,se,he,me,_e;const L=(me=(U=v.current)==null?void 0:U.getOption)==null?void 0:me.call(U,(he=(se=(ae=A.current)==null?void 0:ae.editor)==null?void 0:se.EditorOption)==null?void 0:he.minimap);(_e=v.current)==null||_e.updateOptions({minimap:{enabled:!(L!=null&&L.enabled)}})},foldAll:()=>{var L,U;return(U=(L=v.current)==null?void 0:L.getAction("editor.foldAll"))==null?void 0:U.run()},unfoldAll:()=>{var L,U;return(U=(L=v.current)==null?void 0:L.getAction("editor.unfoldAll"))==null?void 0:U.run()}}),[l]),Z=i.split(`
|
|
12
|
+
`).length,le=i.length;return e.jsxs("div",{className:`nice-code-editor-wrap nice-editor--${w} ${E??""}`,style:{height:N,width:$,display:"flex",flexDirection:"column",position:"relative"},"data-testid":G,children:[z&&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:["⚠️ ",z]}),e.jsx("textarea",{value:i,onChange:L=>r==null?void 0:r(L.target.value),readOnly:Y||y.readOnly,style:{width:"100%",height:"100%",fontFamily:"monospace"}})]}),x&&!z&&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:V??e.jsx("div",{className:"nice-code-editor__loader",children:"Loading editor..."})}),p&&e.jsxs("div",{className:"nice-code-editor__toolbar",children:[e.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:O.undo,title:"Undo (Ctrl+Z)",children:"↶"}),e.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:O.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:O.format,title:"Format (Shift+Alt+F)",children:"⎘"}),e.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:O.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${l?" nice-code-editor__toolbar-btn--active":""}`,onClick:O.toggleWordWrap,title:"Toggle Word Wrap",children:"↩"}),e.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:O.toggleMinimap,title:"Toggle Minimap",children:"▥"}),e.jsx("span",{className:"nice-code-editor__toolbar-sep"}),e.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:O.foldAll,title:"Fold All",children:"⊟"}),e.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:O.unfoldAll,title:"Unfold All",children:"⊞"})]}),e.jsx("div",{ref:k,className:"nice-code-editor",style:{flex:1,minHeight:0}}),T&&e.jsxs("div",{className:"nice-code-editor__statusbar",children:[e.jsxs("span",{children:["Ln ",j.lineNumber,", Col ",j.column]}),s.length>0&&e.jsxs("span",{children:["(",s.length," selected)"]}),e.jsx("span",{className:"nice-code-editor__statusbar-spacer"}),e.jsxs("span",{children:[Z," lines · ",le," chars"]}),e.jsx("span",{className:"nice-code-editor__statusbar-lang",children:d}),S.length>0&&e.jsxs("span",{className:"nice-code-editor__statusbar-markers",children:["⚠ ",S.length]})]})]})});function mn(n){const{original:t,modified:i,language:r="plaintext",theme:d="auto",height:h=400,width:y="100%",inline:N=!1,renderSideBySide:$=!0,originalEditable:S=!1,modifiedEditable:H=!1,onOriginalChange:I,onModifiedChange:b,loading:C,className:P,"data-testid":ee}=n,V=a.useRef(null),Y=a.useRef(null),p=a.useRef(null),[T,w]=a.useState(!0),[E,G]=a.useState(null);return a.useEffect(()=>{if(!V.current)return;let g=!0;return hn().then(k=>{if(!g||!V.current)return;p.current=k;const v=k.editor.createModel(t,r),A=k.editor.createModel(i,r),D=k.editor.createDiffEditor(V.current,{automaticLayout:!0,theme:Ye(d),renderSideBySide:!N&&$,originalEditable:S,readOnly:!H});D.setModel({original:v,modified:A}),Y.current=D,w(!1),S&&v.onDidChangeContent(()=>{I==null||I(v.getValue())}),H&&A.onDidChangeContent(()=>{b==null||b(A.getValue())})}).catch(k=>{g&&(G(k.message??"Failed to load diff editor"),w(!1))}),()=>{var k;g=!1,(k=Y.current)==null||k.dispose()}},[]),a.useEffect(()=>{const g=Y.current;if(!g)return;const k=g.getModel();k&&(k.original.getValue()!==t&&k.original.setValue(t),k.modified.getValue()!==i&&k.modified.setValue(i))},[t,i]),a.useEffect(()=>{var D,W;const g=p.current;if(!g||(g.editor.setTheme(Ye(d)),d!=="auto"||typeof document>"u"))return;const k=()=>{var x;(x=p.current)==null||x.editor.setTheme(Ye("auto"))},v=new MutationObserver(k);v.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme","class"]});const A=(D=window.matchMedia)==null?void 0:D.call(window,"(prefers-color-scheme: dark)");return(W=A==null?void 0:A.addEventListener)==null||W.call(A,"change",k),()=>{var x;v.disconnect(),(x=A==null?void 0:A.removeEventListener)==null||x.call(A,"change",k)}},[d,T]),E?e.jsx("div",{className:`nice-code-diff-editor nice-code-diff-editor--error ${P??""}`,style:{height:h,width:y},"data-testid":ee,children:e.jsx("div",{className:"nice-code-editor__error",children:e.jsxs("span",{children:["⚠️ ",E]})})}):e.jsxs("div",{className:`nice-code-diff-editor ${P??""}`,style:{height:h,width:y,position:"relative"},"data-testid":ee,children:[e.jsx("div",{ref:V,style:{position:"absolute",inset:0}}),T&&e.jsx("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",background:"var(--nice-bg-primary, #fff)",zIndex:2},children:C??e.jsx("div",{className:"nice-code-editor__loader",children:"Loading diff editor..."})})]})}const ua="1.29.0",zt=`https://cdn.jsdelivr.net/npm/prismjs@${ua}`;let gt=null;const yt={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 ht(n){return new Promise((t,i)=>{if(document.querySelector(`script[data-prism-src="${n}"]`)){t();return}const r=document.createElement("script");r.src=n,r.async=!0,r.dataset.prismSrc=n,r.onload=()=>t(),r.onerror=()=>i(new Error(`Failed to load ${n}`)),document.head.appendChild(r)})}function pa(n){if(typeof window>"u")return Promise.resolve(null);const t=window,i=yt[n]??"plain",r=async()=>{var d,h;if(i!=="plain"&&!((h=(d=t.Prism)==null?void 0:d.languages)!=null&&h[i]))try{await ht(`${zt}/components/prism-${i}.min.js`)}catch{}};return t.Prism?r().then(()=>t.Prism):(gt||(gt=(async()=>(window.Prism={manual:!0},await ht(`${zt}/prism.min.js`),window.Prism))()),gt.then(async()=>(await r(),window.Prism)))}function ft(n){return n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function gn(n){const{value:t,onChange:i,language:r="plaintext",height:d=300,width:h="100%",readOnly:y=!1,tabSize:N=2,lineNumbers:$=!0,placeholder:S,theme:H="auto",className:I,"data-testid":b}=n,C=a.useRef(null),P=a.useRef(null),[ee,V]=a.useState(()=>ft(t)),[Y,p]=a.useState("light");a.useEffect(()=>{var D,W;const g=()=>{var c;if(H!=="auto")return H;if(typeof document>"u")return"light";const x=document.documentElement.dataset.theme;return x==="dark"?"dark":x==="light"?"light":(c=window.matchMedia)!=null&&c.call(window,"(prefers-color-scheme: dark)").matches?"dark":"light"};if(p(g()),H!=="auto"||typeof document>"u")return;const k=()=>p(g()),v=new MutationObserver(k);v.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme","class"]});const A=(D=window.matchMedia)==null?void 0:D.call(window,"(prefers-color-scheme: dark)");return(W=A==null?void 0:A.addEventListener)==null||W.call(A,"change",k),()=>{var x;v.disconnect(),(x=A==null?void 0:A.removeEventListener)==null||x.call(A,"change",k)}},[H]),a.useEffect(()=>{let g=!0;return pa(r).then(k=>{var A;if(!g)return;const v=yt[r]??"plain";if((A=k==null?void 0:k.languages)!=null&&A[v])try{const D=k.highlight(t,k.languages[v],v);V(D);return}catch{}V(ft(t))}).catch(()=>{g&&V(ft(t))}),()=>{g=!1}},[t,r]);const T=a.useCallback(()=>{!P.current||!C.current||(P.current.scrollTop=C.current.scrollTop,P.current.scrollLeft=C.current.scrollLeft)},[]),w=a.useCallback(g=>{var k;if(g.key==="Tab"){g.preventDefault();const v=g.currentTarget,A=v.selectionStart,D=v.selectionEnd,W=" ".repeat(N);if(g.shiftKey){const x=t.substring(0,A).lastIndexOf(`
|
|
13
|
+
`)+1;if((((k=t.substring(x,A).match(/^(\s*)/))==null?void 0:k[1])??"").length>=N){const c=t.substring(0,x)+t.substring(x+N);i==null||i(c),setTimeout(()=>{v.selectionStart=v.selectionEnd=A-N},0)}}else{const x=t.substring(0,A)+W+t.substring(D);i==null||i(x),setTimeout(()=>{v.selectionStart=v.selectionEnd=A+N},0)}}},[t,i,N]),E=t.split(`
|
|
14
|
+
`).length,G=yt[r]??"plain";return e.jsxs("div",{className:`nice-simple-code-editor nice-simple-code-editor--${Y} ${I??""}`,style:{height:d,width:h},"data-testid":b,"data-language":r,"data-theme":Y,children:[$&&e.jsx("div",{className:"nice-simple-code-editor__line-numbers",children:Array.from({length:E},(g,k)=>e.jsx("div",{className:"nice-simple-code-editor__line-number",children:k+1},k))}),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-${G}`,children:e.jsx("code",{className:`language-${G}`,dangerouslySetInnerHTML:{__html:ee+(t.endsWith(`
|
|
15
|
+
`)?`
|
|
16
|
+
`:"")}})}),e.jsx("textarea",{ref:C,className:"nice-simple-code-editor__textarea",value:t,onChange:g=>i==null?void 0:i(g.target.value),onKeyDown:w,onScroll:T,readOnly:y,placeholder:S,spellCheck:!1,autoCapitalize:"off",autoCorrect:"off"})]})]})}const Ft="nice-code-editor-styles";if(typeof document<"u"&&!document.getElementById(Ft)){const n=document.createElement("style");n.id=Ft,n.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(n)}const ha=Object.freeze(Object.defineProperty({__proto__:null,NiceCodeDiffEditor:mn,NiceCodeEditor:Ct,NiceSimpleCodeEditor:gn},Symbol.toStringTag,{value:"Module"}));a.forwardRef(function(n,t){const{enableAI:i=!0,aiModel:r,enableInlineCompletion:d=!0,completionDelay:h=500,enableExplain:y=!0,enableRefactor:N=!0,enableGenerate:$=!0,systemPrompt:S,onExplain:H,onRefactor:I,showAIToolbar:b=!0,aiShortcutKey:C="Ctrl",language:P="plaintext",value:ee,onChange:V,...Y}=n,p=a.useRef(null),[T,w]=a.useState(null),[E,G]=a.useState(!1),[g,k]=a.useState(""),[v,A]=a.useState(!1),[D,W]=a.useState(""),[x,c]=a.useState(""),[z,_]=a.useState(""),j=a.useRef(),{t:o}=F.ue(),s=F.me(),{complete:m,explain:l,refactor:u,generateFromComment:q,isLoading:O}=F.Id({language:P,model:r}),Z=i&&s.isConfigured,le=a.useCallback(async()=>{if(!Z||!d||!p.current||!p.current.getEditor())return;const J=p.current.getCursorPosition(),re=p.current.getValue().split(`
|
|
271
|
+
`),ce=re.slice(0,J.lineNumber-1),ve=re[J.lineNumber-1]||"",ie=[...ce,ve.slice(0,J.column-1)].join(`
|
|
272
|
+
`),M=[ve.slice(J.column-1),...re.slice(J.lineNumber)].join(`
|
|
273
|
+
`);try{const R=await m(ie,M);R&&w({lineNumber:J.lineNumber,column:J.column,text:R})}catch{}},[Z,d,m]),L=a.useCallback(async()=>{if(!Z||!y||!p.current)return"";const J=p.current.getSelection();if(!J)return"";_(J),G(!0),k("");try{const re=await l(J);return k(re),H==null||H(J,re),re}catch{return k(o("codeEditorAI.explanationFailed","Failed to explain code")),""}},[Z,y,l,H,o]),U=a.useCallback(async J=>{if(!Z||!N||!p.current)return"";const re=p.current.getSelection();if(!re)return"";try{const ce=await u(re,J);return c(ce),I==null||I(re,ce),ce}catch{return""}},[Z,N,u,I]),ae=a.useCallback(async()=>{var ve;if(!Z||!$||!p.current)return;const J=p.current.getCursorPosition(),re=p.current.getValue().split(`
|
|
274
|
+
`);let ce="";for(let ie=J.lineNumber-1;ie>=0&&ie>=J.lineNumber-3;ie--){const M=((ve=re[ie])==null?void 0:ve.trim())||"";if(M.startsWith("//")||M.startsWith("#")||M.startsWith("/*")||M.startsWith("*")){ce=M.replace(/^\/\/\s*|^#\s*|^\/\*\s*|\*\/\s*$|^\*\s*/g,"").trim();break}}if(ce)try{const ie=await q(ce);ie&&p.current&&p.current.insertText(`
|
|
275
|
+
`+ie)}catch{}},[Z,$,q]),se=a.useCallback(()=>{!T||!p.current||(p.current.insertText(T.text),w(null))},[T]),he=a.useCallback(()=>{w(null)},[]),me=a.useCallback(J=>{var re;(re=n.onCursorPositionChange)==null||re.call(n,J),!(!Z||!d)&&(j.current&&clearTimeout(j.current),w(null),j.current=setTimeout(()=>{le()},h))},[n.onCursorPositionChange,Z,d,h,le]);a.useEffect(()=>{var re;if(!((re=p.current)!=null&&re.getEditor())||!Z)return;const J=ce=>{var ve;if(C==="Ctrl"&&ce.ctrlKey||C==="Alt"&&ce.altKey||C==="Meta"&&ce.metaKey){if(ce.key===" "&&d&&(ce.preventDefault(),le()),ce.key==="e"&&y&&(ce.preventDefault(),L()),ce.key==="r"&&N){ce.preventDefault();const ie=(ve=p.current)==null?void 0:ve.getSelection();ie&&(_(ie),A(!0))}ce.key==="g"&&$&&(ce.preventDefault(),ae())}ce.key==="Tab"&&T&&(ce.preventDefault(),se()),ce.key==="Escape"&&T&&he()};return window.addEventListener("keydown",J),()=>window.removeEventListener("keydown",J)},[Z,C,d,y,N,$,le,L,ae,T,se,he]),a.useEffect(()=>()=>{j.current&&clearTimeout(j.current)},[]);const _e=a.useCallback(()=>{if(!x||!p.current)return;const J=p.current.getEditor();if(J!=null&&J.executeEdits&&(J!=null&&J.getSelection)){const re=J.getSelection();J.executeEdits("ai-refactor",[{range:re,text:x}])}A(!1),c(""),W("")},[x]);return a.useImperativeHandle(t,()=>({...p.current,getEditor:()=>{var J;return(J=p.current)==null?void 0:J.getEditor()},getMonaco:()=>{var J;return(J=p.current)==null?void 0:J.getMonaco()},focus:()=>{var J;return(J=p.current)==null?void 0:J.focus()},getValue:()=>{var J;return((J=p.current)==null?void 0:J.getValue())||""},setValue:J=>{var re;return(re=p.current)==null?void 0:re.setValue(J)},getSelection:()=>{var J;return((J=p.current)==null?void 0:J.getSelection())||""},insertText:J=>{var re;return(re=p.current)==null?void 0:re.insertText(J)},formatDocument:()=>{var J;return(J=p.current)==null?void 0:J.formatDocument()},goToLine:(J,re)=>{var ce;return(ce=p.current)==null?void 0:ce.goToLine(J,re)},findReplace:()=>{var J;return(J=p.current)==null?void 0:J.findReplace()},undo:()=>{var J;return(J=p.current)==null?void 0:J.undo()},redo:()=>{var J;return(J=p.current)==null?void 0:J.redo()},getCursorPosition:()=>{var J;return((J=p.current)==null?void 0:J.getCursorPosition())||{lineNumber:1,column:1}},setMarkers:J=>{var re;return(re=p.current)==null?void 0:re.setMarkers(J)},triggerCompletion:le,explainSelection:L,refactorSelection:U,generateFromComment:ae,acceptCompletion:se,dismissCompletion:he})),e.jsxs("div",{className:"nice-code-editor-ai","data-testid":n["data-testid"],children:[b&&Z&&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"}),O&&e.jsx("span",{className:"nice-code-editor-ai__loading",children:o("codeEditorAI.loading","Thinking...")})]}),e.jsxs("div",{className:"nice-code-editor-ai__toolbar-right",children:[d&&e.jsxs("button",{type:"button",className:"nice-code-editor-ai__toolbar-btn",onClick:()=>le(),disabled:O,title:`${o("codeEditorAI.complete","Complete")} (${C}+Space)`,children:["💡 ",o("codeEditorAI.complete","Complete")]}),y&&e.jsxs("button",{type:"button",className:"nice-code-editor-ai__toolbar-btn",onClick:()=>L(),disabled:O,title:`${o("codeEditorAI.explain","Explain")} (${C}+E)`,children:["📖 ",o("codeEditorAI.explain","Explain")]}),N&&e.jsxs("button",{type:"button",className:"nice-code-editor-ai__toolbar-btn",onClick:()=>{var re;const J=(re=p.current)==null?void 0:re.getSelection();J&&(_(J),A(!0))},disabled:O,title:`${o("codeEditorAI.refactor","Refactor")} (${C}+R)`,children:["🔧 ",o("codeEditorAI.refactor","Refactor")]}),$&&e.jsxs("button",{type:"button",className:"nice-code-editor-ai__toolbar-btn",onClick:()=>ae(),disabled:O,title:`${o("codeEditorAI.generate","Generate")} (${C}+G)`,children:["⚡ ",o("codeEditorAI.generate","Generate")]})]})]}),e.jsxs("div",{className:"nice-code-editor-ai__editor-wrapper",children:[e.jsx(Ct,{ref:p,value:ee,onChange:V,language:P,onCursorPositionChange:me,...Y}),T&&e.jsxs("div",{className:"nice-code-editor-ai__ghost-text",style:{top:`calc(${(T.lineNumber-1)*19}px + 4px)`,left:`calc(${(T.column-1)*7.8}px + 60px)`},children:[e.jsx("span",{className:"nice-code-editor-ai__ghost-text-content",children:T.text}),e.jsxs("span",{className:"nice-code-editor-ai__ghost-text-hint",children:["Tab ",o("codeEditorAI.toAccept","to accept")]})]})]}),E&&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:["📖 ",o("codeEditorAI.explanation","Explanation")]}),e.jsx("button",{type:"button",className:"nice-code-editor-ai__panel-close",onClick:()=>G(!1),children:"✕"})]}),e.jsx("div",{className:"nice-code-editor-ai__panel-body",children:O?e.jsx("div",{className:"nice-code-editor-ai__panel-loading",children:o("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:z}),e.jsx("div",{className:"nice-code-editor-ai__explanation-text",children:g||o("codeEditorAI.noExplanation","Select code and click Explain")})]})})]}),v&&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:["🔧 ",o("codeEditorAI.refactorCode","Refactor Code")]}),e.jsx("button",{type:"button",className:"nice-code-editor-ai__panel-close",onClick:()=>{A(!1),c(""),W("")},children:"✕"})]}),e.jsxs("div",{className:"nice-code-editor-ai__panel-body",children:[e.jsx("pre",{className:"nice-code-editor-ai__code-preview",children:z}),e.jsxs("div",{className:"nice-code-editor-ai__refactor-input",children:[e.jsx("input",{type:"text",placeholder:o("codeEditorAI.refactorInstruction",'Describe how to refactor (e.g., "extract function", "add error handling")'),value:D,onChange:J=>W(J.target.value),onKeyDown:J=>{J.key==="Enter"&&D&&U(D)}}),e.jsx("button",{type:"button",className:"nice-code-editor-ai__refactor-btn",onClick:()=>U(D),disabled:O||!D,children:O?o("codeEditorAI.refactoring","Refactoring..."):o("codeEditorAI.refactor","Refactor")})]}),x&&e.jsxs("div",{className:"nice-code-editor-ai__refactor-result",children:[e.jsx("h5",{children:o("codeEditorAI.refactoredCode","Refactored Code")}),e.jsx("pre",{className:"nice-code-editor-ai__code-preview nice-code-editor-ai__code-preview--result",children:x}),e.jsxs("div",{className:"nice-code-editor-ai__refactor-actions",children:[e.jsxs("button",{type:"button",className:"nice-code-editor-ai__refactor-apply",onClick:_e,children:["✓ ",o("codeEditorAI.apply","Apply")]}),e.jsxs("button",{type:"button",className:"nice-code-editor-ai__refactor-discard",onClick:()=>{c(""),W("")},children:["✕ ",o("codeEditorAI.discard","Discard")]})]})]})]})]})]})});function Wt(n,t){const i=t.getBoundingClientRect();let r,d,h;if("touches"in n){const y=n.touches[0];r=y.clientX-i.left,d=y.clientY-i.top,h=y.force}else"pressure"in n?(r=n.clientX-i.left,d=n.clientY-i.top,h=n.pressure):(r=n.clientX-i.left,d=n.clientY-i.top);return{x:r,y:d,time:Date.now(),pressure:h!==void 0?h:.5}}function Ot(n,t,i,r,d){if(!t)return(i+r)/2;const h=Math.sqrt(Math.pow(n.x-t.x,2)+Math.pow(n.y-t.y,2))/Math.max(1,n.time-t.time),y=Math.min(h/5,1),N=r-y*(r-i),$=n.pressure??.5,S=i+$*(r-i);return N*.7+S*.3}function Ut(n,t,i,r){n.beginPath(),n.moveTo(t.x,t.y),n.lineTo(i.x,i.y),n.lineWidth=r,n.lineCap="round",n.lineJoin="round",n.stroke()}a.forwardRef(function(n,t){const{value:i,onChange:r,width:d="100%",height:h=200,penColor:y="var(--text-primary, #000000)",penWidth:N=2,minWidth:$=.5,maxWidth:S=4,backgroundColor:H="var(--bg-primary, #ffffff)",placeholder:I="Sign here",showClearButton:b=!0,showUndoButton:C=!0,showColorPicker:P=!1,showSizeSlider:ee=!1,velocityFilterWeight:V=.7,throttle:Y=16,disabled:p=!1,readOnly:T=!1,displayMode:w=!1,onBegin:E,onEnd:G,className:g,"data-testid":k}=n,v=T||w,A=w?!1:b,D=w?!1:C,W=w?!1:P,x=w?!1:ee,c=a.useRef(null),[z,_]=a.useState((i==null?void 0:i.strokes)??[]),[j,o]=a.useState([]),[s,m]=a.useState(!1),[l,u]=a.useState(y),[q,O]=a.useState(N),Z=a.useRef(null),le=a.useRef(0),L=z.length===0&&j.length===0;a.useEffect(()=>{const ie=c.current;if(!ie)return;const M=ie.getContext("2d");if(!M)return;const R=ie.getBoundingClientRect(),Q=window.devicePixelRatio||1;ie.width=R.width*Q,ie.height=R.height*Q,M.scale(Q,Q),U()},[d,h]);const U=a.useCallback(()=>{const ie=c.current;if(!ie)return;const M=ie.getContext("2d");if(!M)return;const R=ie.getBoundingClientRect();M.fillStyle=H,M.fillRect(0,0,R.width,R.height),z.forEach(Q=>{if(M.strokeStyle=Q.color,!(Q.points.length<2))for(let ge=1;ge<Q.points.length;ge++){const fe=Q.points[ge-1],X=Q.points[ge],oe=Ot(X,fe,$,S);Ut(M,fe,X,oe)}})},[z,H,$,S,V]);a.useEffect(()=>{U()},[U]),a.useEffect(()=>{i!=null&&i.strokes&&_(i.strokes)},[i]),a.useEffect(()=>{const ie=c.current;if(ie)if(z.length===0)r==null||r(null);else{const M=ie.getBoundingClientRect();r==null||r({strokes:z,width:M.width,height:M.height,timestamp:Date.now()})}},[z,r]);const ae=a.useCallback(ie=>{if(p||v)return;const M=c.current;if(!M)return;M.setPointerCapture(ie.pointerId);const R=Wt(ie.nativeEvent,M);m(!0),o([R]),Z.current=R,le.current=R.time,E==null||E()},[p,v,E]),se=a.useCallback(ie=>{if(!s||p||v)return;const M=c.current;if(!M)return;const R=M.getContext("2d");if(!R)return;const Q=Date.now();if(Q-le.current<Y)return;const ge=Wt(ie.nativeEvent,M),fe=Z.current;if(fe){R.strokeStyle=l;const X=Ot(ge,fe,$,S);Ut(R,fe,ge,X)}o(X=>[...X,ge]),Z.current=ge,le.current=Q},[s,p,v,l,$,S,V,Y]),he=a.useCallback(ie=>{if(!s)return;const M=c.current;if(M&&M.releasePointerCapture(ie.pointerId),j.length>0){const R={points:j,color:l,width:q};_(Q=>[...Q,R])}m(!1),o([]),Z.current=null,G==null||G()},[s,j,l,q,G]),me=a.useCallback(()=>{_([]),o([]),U()},[U]),_e=a.useCallback(()=>{_(ie=>ie.slice(0,-1))},[]),J=a.useCallback((ie="png",M=.92)=>{const R=c.current;if(!R)return"";const Q=ie==="jpeg"?"image/jpeg":"image/png";return R.toDataURL(Q,M)},[]),re=a.useCallback(async(ie="png",M=.92)=>{const R=c.current;return R?new Promise(Q=>{const ge=ie==="jpeg"?"image/jpeg":"image/png";R.toBlob(fe=>Q(fe),ge,M)}):null},[]),ce=a.useCallback(()=>{const ie=c.current;if(!ie)return"";const M=ie.getBoundingClientRect(),R=z.map(Q=>Q.points.length<2?"":`<path d="${Q.points.reduce((ge,fe,X)=>X===0?`M ${fe.x} ${fe.y}`:`${ge} L ${fe.x} ${fe.y}`,"")}" stroke="${Q.color}" stroke-width="${Q.width}" fill="none" stroke-linecap="round" stroke-linejoin="round"/>`).join(`
|
|
276
|
+
`);return`<svg xmlns="http://www.w3.org/2000/svg" width="${M.width}" height="${M.height}" viewBox="0 0 ${ie.width} ${ie.height}">
|
|
277
|
+
<rect width="100%" height="100%" fill="${H}"/>
|
|
278
|
+
${R}
|
|
279
|
+
</svg>`},[z,H]);a.useImperativeHandle(t,()=>({clear:me,undo:_e,isEmpty:()=>z.length===0,getData:()=>{const ie=c.current;if(!ie||z.length===0)return null;const M=ie.getBoundingClientRect();return{strokes:z,width:M.width,height:M.height,timestamp:Date.now()}},setData:ie=>{_(ie.strokes)},toDataURL:J,toBlob:re,toSVG:ce,getCanvas:()=>c.current}),[z,me,_e,J,re,ce]),a.useEffect(()=>{const ie=c.current;if(!ie)return;const M=R=>{s&&R.preventDefault()};return ie.addEventListener("touchmove",M,{passive:!1}),()=>ie.removeEventListener("touchmove",M)},[s]);const ve=A||D||W||x;return e.jsxs("div",{className:`nice-signature ${p?"nice-signature--disabled":""} ${v?"nice-signature--readonly":""} ${g??""}`,style:{width:d},"data-testid":k,children:[ve&&e.jsxs("div",{className:"nice-signature__toolbar",children:[W&&e.jsx("div",{className:"nice-signature__color-picker",children:e.jsx("input",{type:"color",value:l,onChange:ie=>u(ie.target.value),disabled:p||v,title:"Pen color"})}),x&&e.jsx("div",{className:"nice-signature__size-slider",children:e.jsx("input",{type:"range",min:$,max:S,step:.5,value:q,onChange:ie=>O(parseFloat(ie.target.value)),disabled:p||v,title:"Pen size"})}),e.jsxs("div",{className:"nice-signature__actions",children:[D&&e.jsx("button",{type:"button",onClick:_e,disabled:p||v||z.length===0,className:"nice-signature__btn",title:"Undo",children:"↩️"}),A&&e.jsx("button",{type:"button",onClick:me,disabled:p||v||L,className:"nice-signature__btn",title:"Clear",children:"🗑️"})]})]}),e.jsxs("div",{className:"nice-signature__canvas-wrapper",style:{height:h},children:[e.jsx("canvas",{ref:c,className:"nice-signature__canvas",style:{width:"100%",height:"100%",cursor:p||v?"not-allowed":"crosshair",touchAction:"none"},onPointerDown:ae,onPointerMove:se,onPointerUp:he,onPointerLeave:he}),L&&!s&&I&&e.jsx("div",{className:"nice-signature__placeholder",children:I}),e.jsx("div",{className:"nice-signature__line"})]})]})});const Ht="nice-signature-styles";if(typeof document<"u"&&!document.getElementById(Ht)){const n=document.createElement("style");n.id=Ht,n.textContent=`
|
|
280
|
+
.nice-signature {
|
|
281
|
+
display: flex;
|
|
282
|
+
flex-direction: column;
|
|
283
|
+
border: 1px solid var(--nice-border, #e0e0e0);
|
|
284
|
+
border-radius: var(--nice-radius-sm, 4px);
|
|
285
|
+
overflow: hidden;
|
|
286
|
+
background: var(--nice-bg-surface, #fff);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
.nice-signature--disabled {
|
|
290
|
+
opacity: 0.6;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
.nice-signature__toolbar {
|
|
294
|
+
display: flex;
|
|
295
|
+
align-items: center;
|
|
296
|
+
gap: var(--nice-space-2, 8px);
|
|
297
|
+
padding: var(--nice-space-2, 8px);
|
|
298
|
+
background: var(--nice-bg-muted, #f5f5f5);
|
|
299
|
+
border-bottom: 1px solid var(--nice-border, #e0e0e0);
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
.nice-signature__color-picker input {
|
|
303
|
+
width: 32px;
|
|
304
|
+
height: 32px;
|
|
305
|
+
padding: var(--nice-space-0-5, 2px);
|
|
306
|
+
border: 1px solid var(--nice-border, #e0e0e0);
|
|
307
|
+
border-radius: var(--nice-radius-sm, 4px);
|
|
308
|
+
cursor: pointer;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
.nice-signature__size-slider {
|
|
312
|
+
flex: 1;
|
|
313
|
+
max-width: 120px;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
.nice-signature__size-slider input {
|
|
317
|
+
width: 100%;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
.nice-signature__actions {
|
|
321
|
+
display: flex;
|
|
322
|
+
gap: var(--nice-space-1, 4px);
|
|
323
|
+
margin-left: auto;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
.nice-signature__btn {
|
|
327
|
+
padding: var(--nice-space-1-5, 6px) var(--nice-space-2-5, 10px);
|
|
328
|
+
border: 1px solid var(--nice-border, #e0e0e0);
|
|
329
|
+
border-radius: var(--nice-radius-sm, 4px);
|
|
330
|
+
background: var(--nice-bg-surface, #fff);
|
|
331
|
+
cursor: pointer;
|
|
332
|
+
font-size: 14px;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
.nice-signature__btn:hover:not(:disabled) {
|
|
336
|
+
background: var(--nice-bg-hover, #f0f0f0);
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
.nice-signature__btn:disabled {
|
|
340
|
+
opacity: 0.4;
|
|
341
|
+
cursor: not-allowed;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
.nice-signature__canvas-wrapper {
|
|
345
|
+
position: relative;
|
|
346
|
+
background: var(--nice-bg, #FFF);
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
.nice-signature__canvas {
|
|
350
|
+
display: block;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
.nice-signature__placeholder {
|
|
354
|
+
position: absolute;
|
|
355
|
+
top: 50%;
|
|
356
|
+
left: 50%;
|
|
357
|
+
transform: translate(-50%, -50%);
|
|
358
|
+
color: var(--nice-text-secondary, #999);
|
|
359
|
+
font-size: 14px;
|
|
360
|
+
pointer-events: none;
|
|
361
|
+
user-select: none;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
.nice-signature__line {
|
|
365
|
+
position: absolute;
|
|
366
|
+
bottom: 30px;
|
|
367
|
+
left: 20px;
|
|
368
|
+
right: 20px;
|
|
369
|
+
height: 1px;
|
|
370
|
+
background: var(--nice-border, #ccc);
|
|
371
|
+
pointer-events: none;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
/* Display component */
|
|
375
|
+
.nice-signature-display {
|
|
376
|
+
border: 1px solid var(--nice-border, #e0e0e0);
|
|
377
|
+
border-radius: var(--nice-radius-sm, 4px);
|
|
378
|
+
overflow: hidden;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
.nice-signature-display__canvas-wrapper {
|
|
382
|
+
position: relative;
|
|
383
|
+
background: var(--nice-bg, #FFF);
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
.nice-signature-display__canvas {
|
|
387
|
+
display: block;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
.nice-signature-display__placeholder {
|
|
391
|
+
position: absolute;
|
|
392
|
+
top: 50%;
|
|
393
|
+
left: 50%;
|
|
394
|
+
transform: translate(-50%, -50%);
|
|
395
|
+
color: var(--nice-text-secondary, #999);
|
|
396
|
+
font-size: 14px;
|
|
397
|
+
}
|
|
398
|
+
`,document.head.appendChild(n)}const ma={strokeColor:"#ff3333",fillColor:"transparent",strokeWidth:2,opacity:1,fontSize:16,fontFamily:"sans-serif"};function ga(n,t){switch(t.type){case"SET_TOOL":return{...n,activeTool:t.tool,selectedId:null};case"SET_STYLE":return{...n,style:{...n.style,...t.style}};case"ADD_ANNOTATION":return{...n,annotations:[...n.annotations,t.annotation],past:[...n.past,n.annotations],future:[]};case"UPDATE_ANNOTATION":return{...n,annotations:n.annotations.map(i=>i.id===t.id?{...i,...t.updates}:i),past:[...n.past,n.annotations],future:[]};case"DELETE_ANNOTATION":return{...n,annotations:n.annotations.filter(i=>i.id!==t.id),selectedId:n.selectedId===t.id?null:n.selectedId,past:[...n.past,n.annotations],future:[]};case"SELECT":return{...n,selectedId:t.id};case"SET_ANNOTATIONS":return{...n,annotations:t.annotations,past:[],future:[]};case"SET_ZOOM":return{...n,zoom:t.zoom};case"SET_PAN":return{...n,panX:t.panX,panY:t.panY};case"UNDO":{if(n.past.length===0)return n;const i=n.past[n.past.length-1];return{...n,annotations:i,past:n.past.slice(0,-1),future:[n.annotations,...n.future]}}case"REDO":{if(n.future.length===0)return n;const i=n.future[0];return{...n,annotations:i,past:[...n.past,n.annotations],future:n.future.slice(1)}}case"CLEAR":return{...n,annotations:[],selectedId:null,past:[...n.past,n.annotations],future:[]};default:return n}}let fa=0;function ba(){return`ann-${Date.now()}-${fa++}`}function xa(n){const{style:t}=n,i=`stroke="${t.strokeColor}" stroke-width="${t.strokeWidth}" fill="${t.fillColor}" opacity="${t.opacity}"`;switch(n.tool){case"rectangle":return`<rect x="${n.x}" y="${n.y}" width="${n.width}" height="${n.height}" ${i} />`;case"ellipse":{const r=n.x+n.width/2,d=n.y+n.height/2;return`<ellipse cx="${r}" cy="${d}" rx="${n.width/2}" ry="${n.height/2}" ${i} />`}case"arrow":{const r=n,d=Math.atan2(r.endY-r.y,r.endX-r.x),h=12,y=r.endX-h*Math.cos(d-Math.PI/6),N=r.endY-h*Math.sin(d-Math.PI/6),$=r.endX-h*Math.cos(d+Math.PI/6),S=r.endY-h*Math.sin(d+Math.PI/6);return`<line x1="${r.x}" y1="${r.y}" x2="${r.endX}" y2="${r.endY}" ${i} />
|
|
399
|
+
<polygon points="${r.endX},${r.endY} ${y},${N} ${$},${S}" fill="${t.strokeColor}" opacity="${t.opacity}" />`}case"line":{const r=n;return`<line x1="${r.x}" y1="${r.y}" x2="${r.endX}" y2="${r.endY}" ${i} />`}case"text":{const r=n;return`<text x="${r.x}" y="${r.y+(r.style.fontSize??16)}" fill="${t.strokeColor}" font-size="${t.fontSize}" font-family="${t.fontFamily}" opacity="${t.opacity}">${va(r.text)}</text>`}case"freehand":{const r=n;return r.points.length<2?"":`<path d="${r.points.map((d,h)=>`${h===0?"M":"L"}${d.x},${d.y}`).join(" ")}" ${i} fill="none" />`}case"blur":{const r=n,d=`blur-${r.id}`;return`<defs><filter id="${d}"><feGaussianBlur stdDeviation="${r.intensity??5}" /></filter></defs>
|
|
400
|
+
<rect x="${r.x}" y="${r.y}" width="${r.width}" height="${r.height}" fill="transparent" stroke="none" filter="url(#${d})" />`}default:return""}}function va(n){return n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}const fn=a.forwardRef(({src:n,alt:t="Annotatable image",annotations:i,activeTool:r,defaultStyle:d,onAnnotationsChange:h,className:y,readOnly:N=!1,minZoom:$=.1,maxZoom:S=5},H)=>{const I=a.useRef(null),b=a.useRef(null),C=a.useRef(null),[P,ee]=a.useState(!1),[V,Y]=a.useState({width:0,height:0}),[p,T]=a.useReducer(ga,{annotations:i??[],selectedId:null,activeTool:r??"select",style:{...ma,...d},zoom:1,panX:0,panY:0,past:[],future:[]});a.useEffect(()=>{r&&T({type:"SET_TOOL",tool:r})},[r]),a.useEffect(()=>{h==null||h(p.annotations)},[p.annotations,h]),a.useEffect(()=>{const x=new Image;x.crossOrigin="anonymous",x.onload=()=>{C.current=x,Y({width:x.naturalWidth,height:x.naturalHeight}),ee(!0)},x.src=n},[n]);const w=a.useRef({isDrawing:!1,startX:0,startY:0,currentAnnotation:null,freehandPoints:[]}),E=a.useCallback((x,c)=>{const z=I.current;if(!z)return{x:0,y:0};const _=z.getBoundingClientRect();return{x:(x-_.left-p.panX)/p.zoom,y:(c-_.top-p.panY)/p.zoom}},[p.zoom,p.panX,p.panY]),G=a.useCallback(()=>{var j,o;const x=I.current,c=x==null?void 0:x.getContext("2d"),z=C.current;if(!x||!c||!z||!P)return;x.width=((j=b.current)==null?void 0:j.clientWidth)??z.naturalWidth,x.height=((o=b.current)==null?void 0:o.clientHeight)??z.naturalHeight,c.clearRect(0,0,x.width,x.height),c.save(),c.translate(p.panX,p.panY),c.scale(p.zoom,p.zoom),c.drawImage(z,0,0);for(const s of p.annotations){switch(c.save(),c.globalAlpha=s.style.opacity,c.strokeStyle=s.style.strokeColor,c.fillStyle=s.style.fillColor,c.lineWidth=s.style.strokeWidth,s.tool){case"rectangle":c.strokeRect(s.x,s.y,s.width,s.height),s.style.fillColor!=="transparent"&&c.fillRect(s.x,s.y,s.width,s.height);break;case"ellipse":{c.beginPath(),c.ellipse(s.x+s.width/2,s.y+s.height/2,Math.abs(s.width/2),Math.abs(s.height/2),0,0,Math.PI*2),c.stroke(),s.style.fillColor!=="transparent"&&c.fill();break}case"arrow":{const m=s;c.beginPath(),c.moveTo(m.x,m.y),c.lineTo(m.endX,m.endY),c.stroke();const l=Math.atan2(m.endY-m.y,m.endX-m.x),u=12;c.beginPath(),c.moveTo(m.endX,m.endY),c.lineTo(m.endX-u*Math.cos(l-Math.PI/6),m.endY-u*Math.sin(l-Math.PI/6)),c.lineTo(m.endX-u*Math.cos(l+Math.PI/6),m.endY-u*Math.sin(l+Math.PI/6)),c.closePath(),c.fillStyle=s.style.strokeColor,c.fill();break}case"line":{const m=s;c.beginPath(),c.moveTo(m.x,m.y),c.lineTo(m.endX,m.endY),c.stroke();break}case"text":{const m=s;c.font=`${m.style.fontSize??16}px ${m.style.fontFamily??"sans-serif"}`,c.fillStyle=m.style.strokeColor,c.fillText(m.text,m.x,m.y+(m.style.fontSize??16));break}case"freehand":{const m=s;if(m.points.length<2)break;c.beginPath(),c.moveTo(m.points[0].x,m.points[0].y);for(let l=1;l<m.points.length;l++)c.lineTo(m.points[l].x,m.points[l].y);c.stroke();break}case"blur":{const m=s;c.filter=`blur(${m.intensity??5}px)`,c.drawImage(z,m.x,m.y,m.width,m.height,m.x,m.y,m.width,m.height),c.filter="none";break}}s.id===p.selectedId&&(c.strokeStyle="#4488ff",c.lineWidth=1,c.setLineDash([4,4]),c.strokeRect(s.x-2,s.y-2,s.width+4,s.height+4),c.setLineDash([])),c.restore()}const _=w.current;if(_.isDrawing&&_.currentAnnotation){c.save();const s=_.currentAnnotation;if(c.globalAlpha=s.style.opacity,c.strokeStyle=s.style.strokeColor,c.lineWidth=s.style.strokeWidth,c.setLineDash([6,3]),s.tool==="freehand"){const m=s;if(m.points.length>=2){c.beginPath(),c.moveTo(m.points[0].x,m.points[0].y);for(let l=1;l<m.points.length;l++)c.lineTo(m.points[l].x,m.points[l].y);c.stroke()}}else if(s.tool==="rectangle")c.strokeRect(s.x,s.y,s.width,s.height);else if(s.tool==="ellipse")c.beginPath(),c.ellipse(s.x+s.width/2,s.y+s.height/2,Math.abs(s.width/2),Math.abs(s.height/2),0,0,Math.PI*2),c.stroke();else if(s.tool==="arrow"||s.tool==="line"){const m=s;c.beginPath(),c.moveTo(m.x,m.y),c.lineTo(m.endX,m.endY),c.stroke()}c.restore()}c.restore()},[p,P]);a.useEffect(()=>{G()},[G]);const g=a.useCallback(x=>{if(N)return;const c=E(x.clientX,x.clientY),z=p.activeTool;if(z==="select"){const o=[...p.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);T({type:"SELECT",id:(o==null?void 0:o.id)??null});return}const _=w.current;_.isDrawing=!0,_.startX=c.x,_.startY=c.y;const j={id:ba(),style:{...p.style},x:c.x,y:c.y,width:0,height:0};switch(z){case"rectangle":_.currentAnnotation={...j,tool:"rectangle"};break;case"ellipse":_.currentAnnotation={...j,tool:"ellipse"};break;case"arrow":_.currentAnnotation={...j,tool:"arrow",endX:c.x,endY:c.y};break;case"line":_.currentAnnotation={...j,tool:"line",endX:c.x,endY:c.y};break;case"text":_.currentAnnotation={...j,tool:"text",text:"Text",width:100,height:p.style.fontSize??16};break;case"freehand":_.freehandPoints=[c],_.currentAnnotation={...j,tool:"freehand",points:[c]};break;case"blur":_.currentAnnotation={...j,tool:"blur",intensity:5};break}},[N,E,p.activeTool,p.style,p.annotations]),k=a.useCallback(x=>{const c=w.current;if(!c.isDrawing||!c.currentAnnotation)return;const z=E(x.clientX,x.clientY),_=c.currentAnnotation;if(_.tool==="freehand"){c.freehandPoints.push(z),_.points=[...c.freehandPoints];const j=c.freehandPoints.map(s=>s.x),o=c.freehandPoints.map(s=>s.y);_.x=Math.min(...j),_.y=Math.min(...o),_.width=Math.max(...j)-_.x,_.height=Math.max(...o)-_.y}else if(_.tool==="arrow"||_.tool==="line")_.endX=z.x,_.endY=z.y,_.width=Math.abs(z.x-c.startX),_.height=Math.abs(z.y-c.startY);else{const j=Math.min(c.startX,z.x),o=Math.min(c.startY,z.y);_.x=j,_.y=o,_.width=Math.abs(z.x-c.startX),_.height=Math.abs(z.y-c.startY)}G()},[E,G]),v=a.useCallback(()=>{const x=w.current;if(!x.isDrawing||!x.currentAnnotation)return;const c=x.currentAnnotation;(c.tool==="text"||c.tool==="freehand"||Math.abs(c.width)>2||Math.abs(c.height)>2)&&T({type:"ADD_ANNOTATION",annotation:c}),x.isDrawing=!1,x.currentAnnotation=null,x.freehandPoints=[]},[]),A=a.useCallback(x=>{x.preventDefault();const c=x.deltaY>0?.9:1.1,z=Math.max($,Math.min(S,p.zoom*c));T({type:"SET_ZOOM",zoom:z})},[p.zoom,$,S]);a.useEffect(()=>{if(N)return;const x=c=>{(c.metaKey||c.ctrlKey)&&c.key==="z"&&!c.shiftKey?(c.preventDefault(),T({type:"UNDO"})):(c.metaKey||c.ctrlKey)&&(c.key==="y"||c.key==="z"&&c.shiftKey)?(c.preventDefault(),T({type:"REDO"})):(c.key==="Delete"||c.key==="Backspace")&&p.selectedId&&T({type:"DELETE_ANNOTATION",id:p.selectedId})};return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[N,p.selectedId]),a.useImperativeHandle(H,()=>({exportAsDataURL:async(x="png",c=.92)=>{const z=document.createElement("canvas"),_=C.current;if(!_)return"";z.width=_.naturalWidth,z.height=_.naturalHeight;const j=z.getContext("2d");j.drawImage(_,0,0);for(const o of p.annotations){if(j.save(),j.globalAlpha=o.style.opacity,j.strokeStyle=o.style.strokeColor,j.fillStyle=o.style.fillColor,j.lineWidth=o.style.strokeWidth,o.tool==="rectangle")j.strokeRect(o.x,o.y,o.width,o.height);else if(o.tool==="ellipse")j.beginPath(),j.ellipse(o.x+o.width/2,o.y+o.height/2,Math.abs(o.width/2),Math.abs(o.height/2),0,0,Math.PI*2),j.stroke();else if(o.tool==="freehand"){const s=o;if(s.points.length>=2){j.beginPath(),j.moveTo(s.points[0].x,s.points[0].y);for(let m=1;m<s.points.length;m++)j.lineTo(s.points[m].x,s.points[m].y);j.stroke()}}else if(o.tool==="text"){const s=o;j.font=`${s.style.fontSize??16}px ${s.style.fontFamily??"sans-serif"}`,j.fillStyle=s.style.strokeColor,j.fillText(s.text,s.x,s.y+(s.style.fontSize??16))}j.restore()}return z.toDataURL(`image/${x}`,c)},exportAnnotations:()=>[...p.annotations],importAnnotations:x=>{T({type:"SET_ANNOTATIONS",annotations:x})},exportAsSVG:()=>{const{width:x,height:c}=V,z=p.annotations.map(xa);return`<svg xmlns="http://www.w3.org/2000/svg" width="${x}" height="${c}" viewBox="0 0 ${x} ${c}">
|
|
401
|
+
${z.join(`
|
|
402
|
+
`)}
|
|
403
|
+
</svg>`},undo:()=>T({type:"UNDO"}),redo:()=>T({type:"REDO"}),setZoom:x=>{T({type:"SET_ZOOM",zoom:Math.max($,Math.min(S,x))})},fitToScreen:()=>{const x=b.current,c=C.current;if(!x||!c)return;const z=x.clientWidth/c.naturalWidth,_=x.clientHeight/c.naturalHeight,j=Math.min(z,_,1);T({type:"SET_ZOOM",zoom:j}),T({type:"SET_PAN",panX:0,panY:0})},clear:()=>T({type:"CLEAR"})}),[p.annotations,V,$,S]);const D=a.useCallback(x=>{if(x.touches.length!==1)return;const c=x.touches[0];g({clientX:c.clientX,clientY:c.clientY,preventDefault:()=>{}})},[g]),W=a.useCallback(x=>{if(x.touches.length!==1)return;const c=x.touches[0];k({clientX:c.clientX,clientY:c.clientY})},[k]);return e.jsx("div",{ref:b,className:`nice-image-annotator ${y??""}`,style:{position:"relative",overflow:"hidden",width:"100%",height:"100%"},children:e.jsx("canvas",{ref:I,className:"nice-image-annotator__canvas",style:{cursor:p.activeTool==="select"?"default":"crosshair"},onMouseDown:g,onMouseMove:k,onMouseUp:v,onMouseLeave:v,onWheel:A,onTouchStart:D,onTouchMove:W,onTouchEnd:v,role:"img","aria-label":t})})});fn.displayName="NiceImageAnnotator";function ya(n){let t=n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">");return t=t.replace(/```(\w*)\n([\s\S]*?)```/g,(i,r,d)=>`<pre><code class="language-${r}">${d.trim()}</code></pre>`),t=t.replace(/^(\|.+\|)\n(\|[-| :]+\|)\n((?:\|.+\|\n?)+)/gm,(i,r,d,h)=>{const y=r.split("|").filter($=>$.trim()).map($=>`<th>${$.trim()}</th>`).join(""),N=h.trim().split(`
|
|
404
|
+
`).map($=>`<tr>${$.split("|").filter(S=>S.trim()).map(S=>`<td>${S.trim()}</td>`).join("")}</tr>`).join("");return`<table><thead><tr>${y}</tr></thead><tbody>${N}</tbody></table>`}),t=t.replace(/^#### (.+)$/gm,"<h4>$1</h4>"),t=t.replace(/^### (.+)$/gm,"<h3>$1</h3>"),t=t.replace(/^## (.+)$/gm,"<h2>$1</h2>"),t=t.replace(/^# (.+)$/gm,"<h1>$1</h1>"),t=t.replace(/^> (.+)$/gm,"<blockquote>$1</blockquote>"),t=t.replace(/^---$/gm,"<hr/>"),t=t.replace(/^- \[x\] (.+)$/gm,'<li class="task done">☑ $1</li>'),t=t.replace(/^- \[ \] (.+)$/gm,'<li class="task">☐ $1</li>'),t=t.replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>"),t=t.replace(/\*(.+?)\*/g,"<em>$1</em>"),t=t.replace(/~~(.+?)~~/g,"<del>$1</del>"),t=t.replace(/`(.+?)`/g,"<code>$1</code>"),t=t.replace(/!\[([^\]]*)\]\(([^)]+)\)/g,'<img src="$2" alt="$1" style="max-width:100%"/>'),t=t.replace(/\[([^\]]+)\]\(([^)]+)\)/g,'<a href="$2">$1</a>'),t=t.replace(/^\- (.+)$/gm,"<li>$1</li>"),t=t.replace(/^\d+\. (.+)$/gm,"<li>$1</li>"),t=t.replace(/\n/g,"<br/>"),t}const _a=[{key:"bold",label:"B",md:"**",tip:"Bold",shortcut:"Ctrl+B",group:"format"},{key:"italic",label:"I",md:"*",tip:"Italic",shortcut:"Ctrl+I",group:"format"},{key:"strike",label:"S̶",md:"~~",tip:"Strikethrough",group:"format"},{key:"code",label:"< >",md:"`",tip:"Inline code",group:"format"},{key:"h1",label:"H1",md:"# ",tip:"Heading 1",group:"heading"},{key:"h2",label:"H2",md:"## ",tip:"Heading 2",group:"heading"},{key:"h3",label:"H3",md:"### ",tip:"Heading 3",group:"heading"},{key:"ul",label:"•",md:"- ",tip:"Unordered list",group:"list"},{key:"ol",label:"1.",md:"1. ",tip:"Ordered list",group:"list"},{key:"task",label:"☑",md:"- [ ] ",tip:"Task list",group:"list"},{key:"quote",label:"❝",md:"> ",tip:"Blockquote",group:"block"},{key:"hr",label:"—",md:`---
|
|
405
|
+
`,tip:"Horizontal rule",group:"block"},{key:"link",label:"🔗",md:"[](url)",tip:"Link",shortcut:"Ctrl+K",group:"insert"},{key:"image",label:"🖼",md:"",tip:"Image",group:"insert"},{key:"table",label:"⊞",md:`| H1 | H2 | H3 |
|
|
406
|
+
| --- | --- | --- |
|
|
407
|
+
| c1 | c2 | c3 |
|
|
408
|
+
`,tip:"Table",group:"insert"},{key:"codeblock",label:"```",md:"```\n",tip:"Code block",group:"insert"}],ka=["format","heading","list","block","insert"],bn=a.forwardRef(({value:n="",onChange:t,preview:i="side",placeholder:r,disabled:d,readOnly:h,size:y="md",editorSize:N="standard",toolbar:$=!0,minHeight:S=200,showWordCount:H=!1,showLineNumbers:I=!1,onExportHtml:b,onImageUpload:C,className:P,style:ee,id:V},Y)=>{const p=F.nl(V),[T,w]=a.useState("edit"),[E,G]=a.useState(!1),g=a.useRef(null),k=a.useMemo(()=>ya(n),[n]),v=a.useMemo(()=>{const _=n.trim()?n.trim().split(/\s+/).length:0,j=n.length,o=n.split(`
|
|
409
|
+
`).length;return{words:_,chars:j,lines:o}},[n]),A=a.useCallback(_=>{const j=g.current;if(!j)return;const o=j.selectionStart,s=j.selectionEnd,m=n.slice(o,s);let l,u;_==="[](url)"?(l=n.slice(0,o)+`[${m||"text"}](url)`+n.slice(s),u=o+1+(m||"text").length+2):_===""?(l=n.slice(0,o)+``+n.slice(s),u=o+2+(m||"alt").length+2):_.endsWith(`
|
|
410
|
+
`)||_.endsWith(" ")?(l=n.slice(0,o)+_+m+n.slice(s),u=o+_.length+m.length):(l=n.slice(0,o)+_+m+_+n.slice(s),u=o+_.length+m.length+_.length),t==null||t(l),requestAnimationFrame(()=>{j.focus(),j.setSelectionRange(u,u)})},[n,t]),D=a.useCallback(_=>{if((_.ctrlKey||_.metaKey)&&(_.key==="b"?(_.preventDefault(),A("**")):_.key==="i"?(_.preventDefault(),A("*")):_.key==="k"&&(_.preventDefault(),A("[](url)"))),_.key==="Tab"){_.preventDefault();const j=_.currentTarget,o=j.selectionStart,s=j.selectionEnd,m=" ";if(_.shiftKey){const l=n.slice(0,o).lastIndexOf(`
|
|
411
|
+
`)+1;if(n.slice(l,l+m.length)===m){const u=n.slice(0,l)+n.slice(l+m.length);t==null||t(u),requestAnimationFrame(()=>{j.selectionStart=j.selectionEnd=o-m.length})}}else{const l=n.slice(0,o)+m+n.slice(s);t==null||t(l),requestAnimationFrame(()=>{j.selectionStart=j.selectionEnd=o+m.length})}}},[n,t,A]),W=a.useCallback(async _=>{if(!C)return;const j=Array.from(_.dataTransfer.files).filter(o=>o.type.startsWith("image/"));if(j.length!==0){_.preventDefault();for(const o of j){const s=await C(o),m=g.current;if(!m)continue;const l=m.selectionStart,u=`
|
|
412
|
+
`,q=n.slice(0,l)+u+n.slice(l);t==null||t(q)}}},[n,t,C]),x=i!=="tab"||T==="edit",c=i==="side"||i==="tab"&&T==="preview"||i===!0,z=`nice-md-editor nice-md-editor--${y} nice-editor--${N} nice-md-editor--preview-${i}${E?" nice-md-editor--fullscreen":""} ${P||""}`;return e.jsxs("div",{ref:Y,id:p,className:z,style:ee,children:[$&&e.jsxs("div",{className:"nice-md-editor__toolbar",children:[ka.map((_,j)=>e.jsxs(a.Fragment,{children:[j>0&&e.jsx("span",{className:"nice-md-editor__sep"}),_a.filter(o=>o.group===_).map(o=>e.jsx("button",{type:"button",className:"nice-md-editor__btn",title:o.shortcut?`${o.tip} (${o.shortcut})`:o.tip,disabled:d||h,onClick:()=>A(o.md),children:o.label},o.key))]},_)),e.jsx("span",{className:"nice-md-editor__sep"}),e.jsx("button",{type:"button",className:"nice-md-editor__btn",title:"Fullscreen",onClick:()=>G(!E),children:E?"⊙":"⛶"}),b&&e.jsx("button",{type:"button",className:"nice-md-editor__btn",title:"Export HTML",onClick:()=>b(k),children:"↗"}),i==="tab"&&e.jsxs("span",{className:"nice-md-editor__tabs",children:[e.jsx("button",{type:"button",className:`nice-md-editor__tab${T==="edit"?" nice-md-editor__tab--active":""}`,onClick:()=>w("edit"),children:"Edit"}),e.jsx("button",{type:"button",className:`nice-md-editor__tab${T==="preview"?" nice-md-editor__tab--active":""}`,onClick:()=>w("preview"),children:"Preview"})]})]}),e.jsxs("div",{className:"nice-md-editor__body",style:{minHeight:S},children:[x&&e.jsxs("div",{className:"nice-md-editor__editor-wrap",children:[I&&e.jsx("div",{className:"nice-md-editor__line-numbers",children:Array.from({length:v.lines},(_,j)=>e.jsx("div",{className:"nice-md-editor__line-no",children:j+1},j))}),e.jsx("textarea",{ref:g,className:"nice-md-editor__textarea",value:n,onChange:_=>t==null?void 0:t(_.target.value),onKeyDown:D,onDrop:W,placeholder:r,disabled:d,readOnly:h,style:{minHeight:S}})]}),c&&e.jsx("div",{className:"nice-md-editor__preview",dangerouslySetInnerHTML:{__html:F.Ys(k)},style:{minHeight:S}})]}),H&&e.jsxs("div",{className:"nice-md-editor__statusbar",children:[e.jsxs("span",{children:[v.words," words"]}),e.jsxs("span",{children:[v.chars," chars"]}),e.jsxs("span",{children:[v.lines," lines"]})]})]})});bn.displayName="NiceMarkdownEditor";const Bt={rotation:0,flipH:!1,flipV:!1,brightness:100,contrast:100,saturate:100,blur:0,crop:null,annotations:[]},ja=["crop","rotate","flip","brightness","contrast","saturate","blur","annotate"],xn=a.forwardRef(({src:n,size:t="md",editorSize:i="standard",tools:r=ja,showToolbar:d=!0,showZoom:h=!0,maxUndo:y=30,onSave:N,onCancel:$,onChange:S,width:H="100%",height:I=500,className:b,style:C,id:P,...ee},V)=>{const Y=F.nl(P),{t:p}=F.ue(),T=a.useRef(null),w=a.useRef(null),[E,G]=a.useState({...Bt}),[g,k]=a.useState(null),[v,A]=a.useState(!1),[D,W]=a.useState(1),[x,c]=a.useState("rect"),[z,_]=a.useState("var(--nice-danger, #ff0000)"),[j,o]=a.useState({w:0,h:0}),[s,m]=a.useState([]),[l,u]=a.useState([]),[q,O]=a.useState(null),[Z,le]=a.useState(null),[L,U]=a.useState(null),ae=a.useCallback(M=>{m(R=>[...R.slice(-(y-1)),M]),u([])},[y]),se=a.useCallback(M=>{G(R=>{ae(R);const Q={...R,...M};return S==null||S(Q),Q})},[S,ae]),he=a.useCallback(()=>{if(s.length===0)return;const M=s[s.length-1];m(R=>R.slice(0,-1)),u(R=>[...R,E]),G(M),S==null||S(M)},[s,E,S]),me=a.useCallback(()=>{if(l.length===0)return;const M=l[l.length-1];u(R=>R.slice(0,-1)),m(R=>[...R,E]),G(M),S==null||S(M)},[l,E,S]);a.useEffect(()=>{const M=new Image;M.crossOrigin="anonymous",M.onload=()=>{w.current=M,o({w:M.width,h:M.height}),A(!0)},M.src=n},[n]),a.useEffect(()=>{if(!v||!T.current||!w.current)return;const M=T.current,R=M.getContext("2d");if(!R)return;const Q=w.current,ge=E.rotation%180!==0,fe=ge?Q.height:Q.width,X=ge?Q.width:Q.height;M.width=fe,M.height=X,R.clearRect(0,0,fe,X),R.save(),R.filter=`brightness(${E.brightness}%) contrast(${E.contrast}%) saturate(${E.saturate}%) blur(${E.blur}px)`,R.translate(fe/2,X/2),R.rotate(E.rotation*Math.PI/180),R.scale(E.flipH?-1:1,E.flipV?-1:1),R.drawImage(Q,-Q.width/2,-Q.height/2),R.restore(),E.annotations.forEach(oe=>{switch(R.save(),R.strokeStyle=oe.color??"red",R.fillStyle=oe.color??"red",R.lineWidth=oe.strokeWidth??2,R.font=`${oe.fontSize??16}px sans-serif`,oe.type){case"text":R.fillText(oe.text??"",oe.x,oe.y);break;case"rect":R.strokeRect(oe.x,oe.y,oe.width??100,oe.height??50);break;case"circle":{const pe=(oe.width??50)/2,Ne=(oe.height??50)/2;R.beginPath(),R.ellipse(oe.x+pe,oe.y+Ne,pe,Ne,0,0,Math.PI*2),R.stroke();break}case"line":R.beginPath(),R.moveTo(oe.x,oe.y),R.lineTo(oe.x+(oe.width??100),oe.y+(oe.height??0)),R.stroke();break;case"arrow":{const pe=oe.x+(oe.width??100),Ne=oe.y+(oe.height??0);R.beginPath(),R.moveTo(oe.x,oe.y),R.lineTo(pe,Ne),R.stroke();const we=Math.atan2(Ne-oe.y,pe-oe.x),$e=10;R.beginPath(),R.moveTo(pe,Ne),R.lineTo(pe-$e*Math.cos(we-.4),Ne-$e*Math.sin(we-.4)),R.lineTo(pe-$e*Math.cos(we+.4),Ne-$e*Math.sin(we+.4)),R.closePath(),R.fill();break}}R.restore()}),Z&&(R.save(),R.fillStyle="var(--nice-overlay-50, rgba(0, 0, 0, 0.5))",R.fillRect(0,0,fe,X),R.clearRect(Z.x,Z.y,Z.w,Z.h),R.strokeStyle="var(--bg-primary, #fff)",R.lineWidth=2,R.setLineDash([5,5]),R.strokeRect(Z.x,Z.y,Z.w,Z.h),R.restore())},[v,E,Z]);const _e=a.useCallback(M=>{if(!T.current)return;const R=T.current.getBoundingClientRect(),Q=T.current.width/R.width,ge=T.current.height/R.height,fe=(M.clientX-R.left)*Q,X=(M.clientY-R.top)*ge;g==="crop"?O({startX:fe,startY:X}):g==="annotate"&&U({startX:fe,startY:X})},[g]),J=a.useCallback(M=>{if(!T.current)return;const R=T.current.getBoundingClientRect(),Q=T.current.width/R.width,ge=T.current.height/R.height,fe=(M.clientX-R.left)*Q,X=(M.clientY-R.top)*ge;q&&le({x:Math.min(q.startX,fe),y:Math.min(q.startY,X),w:Math.abs(fe-q.startX),h:Math.abs(X-q.startY)})},[q]),re=a.useCallback(M=>{if(q&&Z&&Z.w>5&&Z.h>5&&se({crop:{x:Z.x,y:Z.y,width:Z.w,height:Z.h}}),O(null),L&&T.current){const R=T.current.getBoundingClientRect(),Q=T.current.width/R.width,ge=T.current.height/R.height,fe=(M.clientX-R.left)*Q,X=(M.clientY-R.top)*ge,oe=fe-L.startX,pe=X-L.startY;if(Math.abs(oe)>3||Math.abs(pe)>3||x==="text"){const Ne={type:x,x:L.startX,y:L.startY,width:Math.abs(oe)||100,height:Math.abs(pe)||50,color:z,strokeWidth:2,text:x==="text"?prompt(p("imageEditor.annotationText","Text:"))??"":void 0};se({annotations:[...E.annotations,Ne]})}U(null)}},[q,Z,L,x,z,E.annotations,se,p]),ce=a.useCallback(()=>{if(!E.crop||!T.current)return;const M=T.current,R=M.getContext("2d");if(!R)return;const{x:Q,y:ge,width:fe,height:X}=E.crop,oe=R.getImageData(Q,ge,fe,X);M.width=fe,M.height=X,R.putImageData(oe,0,0),le(null),k(null)},[E.crop]),ve=a.useCallback(()=>{if(!T.current)return;const M=T.current.toDataURL("image/png");N==null||N(M,E)},[N,E]),ie=a.useCallback(()=>{G({...Bt}),le(null),k(null)},[]);return a.useMemo(()=>`brightness(${E.brightness}%) contrast(${E.contrast}%) saturate(${E.saturate}%) blur(${E.blur}px)`,[E.brightness,E.contrast,E.saturate,E.blur]),e.jsxs("div",{ref:V,id:Y,className:`nice-image-editor nice-image-editor--${t} nice-editor--${i} ${b??""}`,style:{...C,width:H,height:I},role:"application","aria-label":p("imageEditor.label","Image Editor"),...ee,children:[d&&e.jsxs("div",{className:"nice-image-editor__toolbar",role:"toolbar",children:[e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:he,disabled:s.length===0,title:p("imageEditor.undo","Undo"),children:"↶"}),e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:me,disabled:l.length===0,title:p("imageEditor.redo","Redo"),children:"↷"}),e.jsx("span",{className:"nice-image-editor__sep"}),r.includes("rotate")&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>se({rotation:(E.rotation-90+360)%360}),title:p("imageEditor.rotateLeft","Rotate left"),children:"↺"}),e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>se({rotation:(E.rotation+90)%360}),title:p("imageEditor.rotateRight","Rotate right"),children:"↻"})]}),r.includes("flip")&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>se({flipH:!E.flipH}),title:p("imageEditor.flipH","Flip horizontal"),children:"⇔"}),e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>se({flipV:!E.flipV}),title:p("imageEditor.flipV","Flip vertical"),children:"⇕"})]}),r.includes("crop")&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:`nice-image-editor__btn ${g==="crop"?"nice-image-editor__btn--active":""}`,onClick:()=>k(g==="crop"?null:"crop"),title:p("imageEditor.crop","Crop"),children:"⊡"}),g==="crop"&&E.crop&&e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:ce,title:p("imageEditor.applyCrop","Apply crop"),children:"✓"})]}),r.includes("brightness")&&e.jsxs("label",{className:"nice-image-editor__slider-label",children:[p("imageEditor.brightness","☀"),e.jsx("input",{type:"range",min:0,max:200,value:E.brightness,onChange:M=>se({brightness:Number(M.target.value)}),className:"nice-image-editor__slider",title:p("imageEditor.brightness","Brightness")})]}),r.includes("contrast")&&e.jsxs("label",{className:"nice-image-editor__slider-label",children:[p("imageEditor.contrast","◑"),e.jsx("input",{type:"range",min:0,max:200,value:E.contrast,onChange:M=>se({contrast:Number(M.target.value)}),className:"nice-image-editor__slider",title:p("imageEditor.contrast","Contrast")})]}),r.includes("saturate")&&e.jsxs("label",{className:"nice-image-editor__slider-label",children:[p("imageEditor.saturate","🎨"),e.jsx("input",{type:"range",min:0,max:200,value:E.saturate,onChange:M=>se({saturate:Number(M.target.value)}),className:"nice-image-editor__slider",title:p("imageEditor.saturate","Saturation")})]}),r.includes("blur")&&e.jsxs("label",{className:"nice-image-editor__slider-label",children:[p("imageEditor.blur","⊘"),e.jsx("input",{type:"range",min:0,max:20,step:.5,value:E.blur,onChange:M=>se({blur:Number(M.target.value)}),className:"nice-image-editor__slider",title:p("imageEditor.blur","Blur")})]}),r.includes("annotate")&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"nice-image-editor__sep"}),e.jsx("button",{type:"button",className:`nice-image-editor__btn ${g==="annotate"?"nice-image-editor__btn--active":""}`,onClick:()=>k(g==="annotate"?null:"annotate"),title:p("imageEditor.annotate","Annotate"),children:"✎"}),g==="annotate"&&e.jsxs(e.Fragment,{children:[e.jsxs("select",{className:"nice-image-editor__select",value:x,onChange:M=>c(M.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:z,onChange:M=>_(M.target.value),className:"nice-image-editor__color",title:p("imageEditor.color","Color")}),E.annotations.length>0&&e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>se({annotations:E.annotations.slice(0,-1)}),title:p("imageEditor.removeLastAnnotation","Remove last"),children:"⌫"})]})]}),e.jsx("span",{className:"nice-image-editor__sep"}),e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:ie,title:p("imageEditor.reset","Reset"),children:"⟲"}),N&&e.jsx("button",{type:"button",className:"nice-image-editor__btn nice-image-editor__btn--save",onClick:ve,children:p("imageEditor.save","Save")}),$&&e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:$,children:p("imageEditor.cancel","Cancel")})]}),e.jsx("div",{className:"nice-image-editor__canvas-wrap",children:e.jsx("canvas",{ref:T,className:"nice-image-editor__canvas",onMouseDown:_e,onMouseMove:J,onMouseUp:re,style:{cursor:g==="crop"||g==="annotate"?"crosshair":"default",transform:`scale(${D})`,transformOrigin:"center center"}})}),h&&e.jsxs("div",{className:"nice-image-editor__footer",children:[e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>W(M=>Math.max(.1,M-.1)),title:"Zoom out",children:"−"}),e.jsxs("span",{style:{fontSize:"0.85em",minWidth:40,textAlign:"center"},children:[Math.round(D*100),"%"]}),e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>W(M=>Math.min(5,M+.1)),title:"Zoom in",children:"+"}),e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>W(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:[j.w,"×",j.h,"px · ",E.rotation,"°"]})]})]})});xn.displayName="NiceImageEditor";const vn=a.forwardRef(({value:n,onChange:t,penColor:i="var(--text-primary, #000)",penWidth:r=2,backgroundColor:d="var(--bg-primary, #fff)",width:h=400,height:y=200,size:N="md",disabled:$=!1,readOnly:S=!1,showClear:H=!0,showUndo:I=!0,label:b,exportFormat:C="image/png",className:P,style:ee,id:V,...Y},p)=>{const T=F.nl(V),{t:w}=F.ue(),E=a.useRef(null),[G,g]=a.useState(!1),k=a.useRef([]),v=a.useRef([]),[A,D]=a.useState(!0),W=a.useCallback(()=>{const s=E.current;if(!s)return;const m=s.getContext("2d");if(m){m.fillStyle=d,m.fillRect(0,0,s.width,s.height),m.strokeStyle=i,m.lineWidth=r,m.lineCap="round",m.lineJoin="round";for(const l of k.current)if(!(l.length<2)){m.beginPath(),m.moveTo(l[0].x,l[0].y);for(let u=1;u<l.length;u++)m.lineTo(l[u].x,l[u].y);m.stroke()}}},[d,i,r]);a.useEffect(()=>{if(n&&E.current){const s=new Image;s.onload=()=>{var l;const m=(l=E.current)==null?void 0:l.getContext("2d");!m||!E.current||(m.fillStyle=d,m.fillRect(0,0,E.current.width,E.current.height),m.drawImage(s,0,0),D(!1))},s.src=n}else n||(k.current=[],D(!0),W())},[n,d,W]),a.useEffect(()=>{const s=E.current;s&&(s.width=h,s.height=y,W())},[h,y,W]);const x=a.useCallback(s=>{const m=E.current,l=m.getBoundingClientRect(),u=m.width/l.width,q=m.height/l.height;if("touches"in s){const O=s.touches[0];return{x:(O.clientX-l.left)*u,y:(O.clientY-l.top)*q}}return{x:(s.clientX-l.left)*u,y:(s.clientY-l.top)*q}},[]),c=a.useCallback(s=>{if($||S)return;s.preventDefault();const m=x(s);v.current=[m],g(!0)},[$,S,x]),z=a.useCallback(s=>{if(!G)return;s.preventDefault();const m=x(s);v.current.push(m);const l=E.current,u=l==null?void 0:l.getContext("2d");if(!u||!l)return;const q=v.current;q.length>=2&&(u.strokeStyle=i,u.lineWidth=r,u.lineCap="round",u.beginPath(),u.moveTo(q[q.length-2].x,q[q.length-2].y),u.lineTo(m.x,m.y),u.stroke())},[G,x,i,r]),_=a.useCallback(()=>{if(G&&(g(!1),v.current.length>0&&(k.current.push([...v.current]),v.current=[],D(!1),E.current))){const s=E.current.toDataURL(C);t==null||t(s)}},[G,C,t]),j=a.useCallback(()=>{k.current=[],v.current=[],D(!0),W(),t==null||t(null)},[W,t]),o=a.useCallback(()=>{if(k.current.length!==0&&(k.current.pop(),D(k.current.length===0),W(),E.current)){const s=k.current.length>0?E.current.toDataURL(C):null;t==null||t(s)}},[W,C,t]);return e.jsxs("div",{ref:p,id:T,className:`nice-signature nice-signature--${N} ${$?"nice-signature--disabled":""} ${S?"nice-signature--readonly":""} ${P??""}`,style:ee,...Y,children:[b&&e.jsx("label",{className:"nice-signature__label",children:b}),e.jsx("div",{className:"nice-signature__canvas-wrap",style:{width:h,height:y},children:e.jsx("canvas",{ref:E,className:"nice-signature__canvas",onMouseDown:c,onMouseMove:z,onMouseUp:_,onMouseLeave:_,onTouchStart:c,onTouchMove:z,onTouchEnd:_,style:{touchAction:"none",cursor:$||S?"default":"crosshair"},"aria-label":b??w("signature.label","Signature pad"),role:"img"})}),(H||I)&&!S&&!$&&e.jsxs("div",{className:"nice-signature__actions",children:[I&&e.jsx("button",{type:"button",className:"nice-signature__btn",onClick:o,disabled:A,children:w("signature.undo","Undo")}),H&&e.jsx("button",{type:"button",className:"nice-signature__btn",onClick:j,disabled:A,children:w("signature.clear","Clear")})]})]})});vn.displayName="NiceSignaturePad";let Ca=0;function Nt(){return`blk-${++Ca}-${Date.now().toString(36)}`}function Xt(n=""){return{id:Nt(),type:"paragraph",content:n}}function Na(n,t=""){const i={id:Nt(),type:n,content:t};return n==="heading"&&(i.level=2),n==="list"&&(i.listType="unordered"),n==="callout"&&(i.icon="??"),n==="toggle"&&(i.open=!0),i}const wa=[{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 $a(n){const t=[n.align?`text-align:${n.align}`:"",n.color?`color:${n.color}`:"",n.bgColor?`background-color:${n.bgColor}`:"",n.indent?`margin-left:${n.indent*24}px`:""].filter(Boolean).join(";"),i=t?` style="${t}"`:"",r=(d,h)=>{let y=h;return n.bold&&(y=`<strong>${y}</strong>`),n.italic&&(y=`<em>${y}</em>`),n.underline&&(y=`<u>${y}</u>`),n.strikethrough&&(y=`<s>${y}</s>`),`<${d}${i}>${y}</${d}>`};switch(n.type){case"heading":return r(`h${n.level??2}`,n.content);case"paragraph":return r("p",n.content||" ");case"list":{const d=n.listType==="ordered"?"ol":"ul",h=n.content.split(`
|
|
413
|
+
`).map((y,N)=>{var $;return n.listType==="checklist"?`<li><input type="checkbox" ${(($=n.checked)==null?void 0:$[N])??!1?"checked":""} disabled />${y}</li>`:`<li>${y}</li>`}).join("");return`<${d}${i}>${h}</${d}>`}case"image":return`<figure${i}><img src="${n.src??""}" alt="${n.alt??""}" /></figure>`;case"video":return`<figure${i}><video src="${n.src??""}" controls></video></figure>`;case"divider":return"<hr />";case"pageBreak":return'<div style="page-break-after:always"></div>';case"code":return`<pre><code class="language-${n.language??""}">${n.content}</code></pre>`;case"quote":return r("blockquote",n.content);case"callout":return`<div class="nice-doc-callout"${i}><span>${n.icon??"??"}</span><div>${n.content}</div></div>`;case"toggle":return`<details${i}><summary>${n.content.split(`
|
|
414
|
+
`)[0]}</summary>${n.content.split(`
|
|
415
|
+
`).slice(1).join("<br>")}</details>`;case"table":return`<table${i}>${n.content}</table>`;case"embed":return`<iframe src="${n.src??""}" style="width:100%;border:none;min-height:300px"></iframe>`;default:return r("p",n.content)}}function Ma(n){let t=0,i=0;for(const r of n){const d=r.content??"";t+=d.length;const h=d.trim().split(/\s+/).filter(Boolean);i+=h.length}return{words:i,chars:t,readingTime:Math.max(1,Math.ceil(i/200))}}const yn=a.forwardRef(({blocks:n,onChange:t,readOnly:i=!1,showToolbar:r=!0,size:d="md",editorSize:h="standard",placeholder:y,onExport:N,onImageUpload:$,maxUndo:S=50,slashCommands:H=!0,showWordCount:I=!1,showToc:b=!1,showFindReplace:C=!0,className:P,style:ee,id:V,...Y},p)=>{var B,de,xe,je,be,Ee,ye,Re,De,Te,Ie,rt,qe,lt,wt,$t;const T=F.nl(V),{t:w}=F.ue(),[E,G]=a.useState(()=>n??[Xt()]),g=n??E,[k,v]=a.useState(0),A=a.useRef(new Map),D=a.useRef(null),[W,x]=a.useState(!1),[c,z]=a.useState(""),[_,j]=a.useState(""),[o,s]=a.useState([]),[m,l]=a.useState(0),[u,q]=a.useState(!1),O=a.useRef([]),Z=a.useRef([]),le=a.useCallback(f=>{O.current.push(f.map(K=>({...K,checked:K.checked?[...K.checked]:void 0}))),O.current.length>S&&O.current.shift(),Z.current=[]},[S]),L=a.useCallback(()=>{if(O.current.length===0)return;const f=O.current.pop();Z.current.push(g.map(K=>({...K}))),n||G(f),t==null||t(f)},[g,n,t]),U=a.useCallback(()=>{if(Z.current.length===0)return;const f=Z.current.pop();O.current.push(g.map(K=>({...K}))),n||G(f),t==null||t(f)},[g,n,t]),[ae,se]=a.useState(!1),[he,me]=a.useState(""),[_e,J]=a.useState(0),re=a.useMemo(()=>{if(!ae||!H)return[];const f=he.toLowerCase();return wa.filter(K=>K.label.toLowerCase().includes(f)||K.keywords.includes(f))},[ae,he,H]),[ce,ve]=a.useState(null),[ie,M]=a.useState(null),R=a.useCallback(f=>{le(g);const K=f(g);n||G(K),t==null||t(K)},[g,n,t,le]),Q=a.useCallback((f,K)=>{R(te=>te.map((Ce,Se)=>Se===f?{...Ce,...K}:Ce))},[R]),ge=a.useCallback((f,K)=>{const te=K??Xt();R(Ce=>{const Se=[...Ce];return Se.splice(f+1,0,te),Se}),v(f+1)},[R]),fe=a.useCallback(f=>{const K={...g[f],id:Nt()};ge(f,K)},[g,ge]),X=a.useCallback(f=>{g.length<=1||(R(K=>K.filter((te,Ce)=>Ce!==f)),v(Math.max(0,f-1)))},[g.length,R]),oe=a.useCallback((f,K)=>{const te=f+K;te<0||te>=g.length||(R(Ce=>{const Se=[...Ce];return[Se[f],Se[te]]=[Se[te],Se[f]],Se}),v(te))},[g.length,R]),pe=a.useCallback((f,K)=>{const te={type:K};K==="heading"&&(te.level=2),K==="list"&&(te.listType="unordered"),K==="callout"&&(te.icon="??"),K==="toggle"&&(te.open=!0),Q(f,te)},[Q]),Ne=a.useCallback(f=>{var te,Ce;const K=Na(f.type);f.type==="list"&&f.label.includes("Numbered")&&(K.listType="ordered"),f.type==="list"&&f.label.includes("Checklist")&&(K.listType="checklist",K.checked=[]),((te=g[k])==null?void 0:te.content)===""||((Ce=g[k])==null?void 0:Ce.content)==="/"?R(Se=>Se.map((Ue,Ve)=>Ve===k?{...K,id:Ue.id}:Ue)):ge(k,K),se(!1),me("")},[g,k,R,ge]),we=a.useCallback((f,K)=>{if(i)return;const te=g[K];if(!(te!=null&&te.locked)){if((f.ctrlKey||f.metaKey)&&f.key==="z"&&!f.shiftKey){f.preventDefault(),L();return}if((f.ctrlKey||f.metaKey)&&(f.key==="y"||f.key==="z"&&f.shiftKey)){f.preventDefault(),U();return}if((f.ctrlKey||f.metaKey)&&f.key==="d"){f.preventDefault(),fe(K);return}if((f.ctrlKey||f.metaKey)&&f.key==="b"){f.preventDefault(),Q(K,{bold:!(te!=null&&te.bold)});return}if((f.ctrlKey||f.metaKey)&&f.key==="i"){f.preventDefault(),Q(K,{italic:!(te!=null&&te.italic)});return}if((f.ctrlKey||f.metaKey)&&f.key==="u"){f.preventDefault(),Q(K,{underline:!(te!=null&&te.underline)});return}if((f.ctrlKey||f.metaKey)&&f.key==="e"){f.preventDefault(),Q(K,{strikethrough:!(te!=null&&te.strikethrough)});return}if(f.key==="Tab"&&!f.shiftKey){f.preventDefault(),Q(K,{indent:Math.min(((te==null?void 0:te.indent)??0)+1,4)});return}if(f.key==="Tab"&&f.shiftKey){f.preventDefault(),Q(K,{indent:Math.max(((te==null?void 0:te.indent)??0)-1,0)});return}if((f.ctrlKey||f.metaKey)&&f.key==="f"&&C){f.preventDefault(),x(Ce=>!Ce);return}if(ae&&re.length>0){if(f.key==="ArrowDown"){f.preventDefault(),J(Ce=>Math.min(Ce+1,re.length-1));return}if(f.key==="ArrowUp"){f.preventDefault(),J(Ce=>Math.max(Ce-1,0));return}if(f.key==="Enter"){f.preventDefault(),Ne(re[_e]);return}if(f.key==="Escape"){se(!1);return}}f.key==="Enter"&&!f.shiftKey?(f.preventDefault(),ge(K)):f.key==="Backspace"&&g[K].content===""&&g.length>1?(f.preventDefault(),X(K)):f.key==="ArrowUp"&&f.altKey?(f.preventDefault(),oe(K,-1)):f.key==="ArrowDown"&&f.altKey&&(f.preventDefault(),oe(K,1))}},[i,g,ge,X,oe,L,U,fe,Q,ae,re,_e,Ne,C]),$e=a.useCallback((f,K)=>{const te=f.target.textContent??"";H&&te.startsWith("/")?(se(!0),me(te.slice(1)),J(0)):ae&&se(!1),le(g);const Ce=g.map((Se,Ue)=>Ue===K?{...Se,content:te}:Se);n||G(Ce),t==null||t(Ce)},[g,n,t,le,H,ae]),Pe=a.useCallback((f,K)=>{ve(K),f.dataTransfer.effectAllowed="move"},[]),Je=a.useCallback((f,K)=>{f.preventDefault(),f.dataTransfer.dropEffect="move",M(K)},[]),ze=a.useCallback((f,K)=>{if(f.preventDefault(),ce===null||ce===K){ve(null),M(null);return}R(te=>{const Ce=[...te],[Se]=Ce.splice(ce,1);return Ce.splice(K>ce?K-1:K,0,Se),Ce}),v(K>ce?K-1:K),ve(null),M(null)},[ce,R]);a.useEffect(()=>{if(!W||!c){s([]);return}const f=c.toLowerCase(),K=[];g.forEach((te,Ce)=>{const Se=(te.content??"").toLowerCase();let Ue=0;for(;Ue<Se.length;){const Ve=Se.indexOf(f,Ue);if(Ve===-1)break;K.push({blockIdx:Ce,start:Ve,end:Ve+f.length}),Ue=Ve+1}}),s(K),l(0)},[c,W,g]);const We=a.useCallback(()=>{if(o.length===0)return;const f=(m+1)%o.length;l(f),v(o[f].blockIdx)},[o,m]),Ze=a.useCallback(()=>{if(o.length===0)return;const f=(m-1+o.length)%o.length;l(f),v(o[f].blockIdx)},[o,m]),Ge=a.useCallback(()=>{if(o.length===0||!c)return;const f=o[m],K=g[f.blockIdx],te=K.content.slice(0,f.start),Ce=K.content.slice(f.end);Q(f.blockIdx,{content:te+_+Ce})},[o,m,c,_,g,Q]),Qe=a.useCallback(()=>{if(!c)return;const f=c;R(K=>K.map(te=>({...te,content:te.content.split(f).join(_)})))},[c,_,R]),He=a.useMemo(()=>b?g.map((f,K)=>f.type==="heading"?{idx:K,level:f.level??2,text:f.content}:null).filter(Boolean):[],[g,b]),Oe=a.useCallback(async f=>{var te;const K=(te=f.target.files)==null?void 0:te[0];if(K){if($){const Ce=await $(K);Q(k,{src:Ce})}f.target.value=""}},[$,k,Q]);a.useEffect(()=>{const f=g[k];if(f){const K=A.current.get(f.id);K&&K.focus()}},[k,g]);const Be=a.useCallback(()=>{const f=g.map($a).join(`
|
|
416
|
+
`);N==null||N(f)},[g,N]),ne=a.useMemo(()=>I?Ma(g):null,[g,I]),[ue,ke]=a.useState(null),Ae=a.useCallback((f,K)=>{i||(f.preventDefault(),ke({x:f.clientX,y:f.clientY,idx:K}))},[i]);return a.useEffect(()=>{if(!ue)return;const f=()=>ke(null);return window.addEventListener("click",f),()=>window.removeEventListener("click",f)},[ue]),e.jsxs("div",{ref:p,id:T,className:`nice-doc-editor nice-doc-editor--${d} nice-editor--${h} ${i?"nice-doc-editor--readonly":""} ${P??""}`,style:ee,role:"application","aria-label":w("docEditor.label","Document Editor"),...Y,children:[r&&!i&&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(F.pn,{size:"sm",variant:"ghost",onClick:L,title:w("docEditor.undo","Undo (Ctrl+Z)"),children:"?"}),e.jsx(F.pn,{size:"sm",variant:"ghost",onClick:U,title:w("docEditor.redo","Redo (Ctrl+Y)"),children:"?"}),e.jsx("span",{className:"nice-doc-editor__sep"}),e.jsx(F.Ge,{size:"sm",value:((B=g[k])==null?void 0:B.type)??"paragraph",onChange:f=>pe(k,f),label:"",options:[{value:"paragraph",label:w("docEditor.paragraph","Paragraph")},{value:"heading",label:w("docEditor.heading","Heading")},{value:"list",label:w("docEditor.list","List")},{value:"code",label:w("docEditor.code","Code")},{value:"quote",label:w("docEditor.quote","Quote")},{value:"callout",label:w("docEditor.callout","Callout")},{value:"toggle",label:w("docEditor.toggle","Toggle")},{value:"divider",label:w("docEditor.divider","Divider")},{value:"image",label:w("docEditor.image","Image")},{value:"video",label:w("docEditor.video","Video")},{value:"pageBreak",label:w("docEditor.pageBreak","Page Break")}],style:{minWidth:100}}),((de=g[k])==null?void 0:de.type)==="heading"&&e.jsx(F.Ge,{size:"sm",value:String(((xe=g[k])==null?void 0:xe.level)??2),onChange:f=>Q(k,{level:Number(f)}),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}}),((je=g[k])==null?void 0:je.type)==="list"&&e.jsx(F.Ge,{size:"sm",value:((be=g[k])==null?void 0:be.listType)??"unordered",onChange:f=>Q(k,{listType:f}),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(F.pn,{size:"sm",variant:(Ee=g[k])!=null&&Ee.bold?"primary":"ghost",onClick:()=>{var f;return Q(k,{bold:!((f=g[k])!=null&&f.bold)})},title:w("docEditor.bold","Bold (Ctrl+B)"),children:e.jsx("strong",{children:"B"})}),e.jsx(F.pn,{size:"sm",variant:(ye=g[k])!=null&&ye.italic?"primary":"ghost",onClick:()=>{var f;return Q(k,{italic:!((f=g[k])!=null&&f.italic)})},title:w("docEditor.italic","Italic (Ctrl+I)"),children:e.jsx("em",{children:"I"})}),e.jsx(F.pn,{size:"sm",variant:(Re=g[k])!=null&&Re.underline?"primary":"ghost",onClick:()=>{var f;return Q(k,{underline:!((f=g[k])!=null&&f.underline)})},title:w("docEditor.underline","Underline (Ctrl+U)"),children:e.jsx("u",{children:"U"})}),e.jsx(F.pn,{size:"sm",variant:(De=g[k])!=null&&De.strikethrough?"primary":"ghost",onClick:()=>{var f;return Q(k,{strikethrough:!((f=g[k])!=null&&f.strikethrough)})},title:w("docEditor.strikethrough","Strikethrough (Ctrl+E)"),children:e.jsx("s",{children:"S"})}),e.jsx("span",{className:"nice-doc-editor__sep"}),e.jsx(F.pn,{size:"sm",variant:((Te=g[k])==null?void 0:Te.align)==="left"?"primary":"ghost",onClick:()=>Q(k,{align:"left"}),title:w("docEditor.alignLeft","Left"),children:"?"}),e.jsx(F.pn,{size:"sm",variant:((Ie=g[k])==null?void 0:Ie.align)==="center"?"primary":"ghost",onClick:()=>Q(k,{align:"center"}),title:w("docEditor.alignCenter","Center"),children:"?"}),e.jsx(F.pn,{size:"sm",variant:((rt=g[k])==null?void 0:rt.align)==="right"?"primary":"ghost",onClick:()=>Q(k,{align:"right"}),title:w("docEditor.alignRight","Right"),children:"?"}),e.jsx("span",{className:"nice-doc-editor__sep"}),e.jsx(F.pn,{size:"sm",variant:"ghost",onClick:()=>{var f;return Q(k,{indent:Math.min((((f=g[k])==null?void 0:f.indent)??0)+1,4)})},title:w("docEditor.indent","Indent (Tab)"),children:"??"}),e.jsx(F.pn,{size:"sm",variant:"ghost",onClick:()=>{var f;return Q(k,{indent:Math.max((((f=g[k])==null?void 0:f.indent)??0)-1,0)})},title:w("docEditor.outdent","Outdent (Shift+Tab)"),children:"??"}),e.jsx("span",{className:"nice-doc-editor__sep"}),e.jsx(F.Ye,{size:"sm",label:"",value:((qe=g[k])==null?void 0:qe.color)??"var(--text-primary, #000000)",onChange:f=>Q(k,{color:f}),title:"Text color"}),e.jsx(F.Ye,{size:"sm",label:"",value:((lt=g[k])==null?void 0:lt.bgColor)??"var(--bg-primary, #ffffff)",onChange:f=>Q(k,{bgColor:f}),title:"Block background"}),e.jsx("span",{className:"nice-doc-editor__sep"}),e.jsx(F.pn,{size:"sm",variant:(wt=g[k])!=null&&wt.locked?"primary":"ghost",onClick:()=>{var f;return Q(k,{locked:!((f=g[k])!=null&&f.locked)})},title:w("docEditor.lock","Lock/Unlock block"),children:"??"}),e.jsx(F.pn,{size:"sm",variant:"ghost",onClick:()=>fe(k),title:w("docEditor.duplicate","Duplicate (Ctrl+D)"),children:"?"}),e.jsx(F.pn,{size:"sm",variant:"ghost",onClick:()=>X(k),title:w("docEditor.delete","Delete block"),children:"??"}),e.jsx(F.pn,{size:"sm",variant:"ghost",onClick:()=>ge(k),title:w("docEditor.addBlock","Add block"),children:"+"}),C&&e.jsx(F.pn,{size:"sm",variant:W?"primary":"ghost",onClick:()=>x(f=>!f),title:w("docEditor.find","Find & Replace (Ctrl+F)"),children:"??"}),e.jsx(F.pn,{size:"sm",variant:"ghost",onClick:()=>q(f=>!f),title:w("docEditor.shortcuts","Keyboard shortcuts"),children:"?"}),N&&e.jsx(F.pn,{size:"sm",variant:"ghost",onClick:Be,children:w("docEditor.export","Export HTML")})]}),e.jsx("input",{ref:D,type:"file",accept:"image/*,video/*",style:{display:"none"},onChange:Oe}),W&&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(F.Pe,{size:"sm",placeholder:w("docEditor.findPlaceholder","Find..."),value:c,onChange:z,style:{flex:1,maxWidth:200}}),e.jsx(F.Pe,{size:"sm",placeholder:w("docEditor.replacePlaceholder","Replace..."),value:_,onChange:j,style:{flex:1,maxWidth:200}}),e.jsx(F.pn,{size:"sm",variant:"ghost",onClick:Ze,title:w("docEditor.findPrev","Previous"),children:"?"}),e.jsx(F.pn,{size:"sm",variant:"ghost",onClick:We,title:w("docEditor.findNext","Next"),children:"?"}),e.jsx(F.pn,{size:"sm",variant:"ghost",onClick:Ge,title:w("docEditor.replaceOne","Replace"),disabled:i,children:w("docEditor.replace","Replace")}),e.jsx(F.pn,{size:"sm",variant:"ghost",onClick:Qe,title:w("docEditor.replaceAll","Replace all"),disabled:i,children:w("docEditor.replaceAllBtn","All")}),e.jsx("span",{style:{fontSize:"0.75em",color:"var(--text-muted, #666)"},children:o.length>0?`${m+1}/${o.length}`:"0/0"}),e.jsx(F.pn,{size:"sm",variant:"ghost",onClick:()=>x(!1),children:"?"})]}),u&&e.jsx("div",{className:"nice-doc-editor__shortcuts-overlay",style:{position:"fixed",inset:0,background:"var(--nice-overlay-40, rgba(0, 0, 0, 0.4))",zIndex:9999,display:"flex",alignItems:"center",justifyContent:"center"},onClick:()=>q(!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:f=>f.stopPropagation(),children:[e.jsx("h3",{style:{margin:"0 0 12px"},children:w("docEditor.shortcutsTitle","Keyboard Shortcuts")}),e.jsx("table",{style:{width:"100%",fontSize:"0.875em",borderCollapse:"collapse"},children:e.jsx("tbody",{children:[["Ctrl+B",w("docEditor.bold","Bold")],["Ctrl+I",w("docEditor.italic","Italic")],["Ctrl+U",w("docEditor.underline","Underline")],["Ctrl+E",w("docEditor.strikethrough","Strikethrough")],["Ctrl+D",w("docEditor.duplicate","Duplicate block")],["Ctrl+Z",w("docEditor.undo","Undo")],["Ctrl+Y",w("docEditor.redo","Redo")],["Ctrl+F",w("docEditor.find","Find & Replace")],["Enter",w("docEditor.newBlock","New block")],["Backspace",w("docEditor.deleteEmpty","Delete empty block")],["Alt+?",w("docEditor.moveUp","Move block up")],["Alt+?",w("docEditor.moveDown","Move block down")],["Tab",w("docEditor.indent","Indent")],["Shift+Tab",w("docEditor.outdent","Outdent")],["/",w("docEditor.slashCmd","Slash commands")]].map(([f,K])=>e.jsxs("tr",{style:{borderBottom:"1px solid var(--border-color, #eee)"},children:[e.jsx("td",{style:{padding:"4px 8px",fontFamily:"monospace",fontWeight:600},children:f}),e.jsx("td",{style:{padding:"4px 8px"},children:K})]},f))})}),e.jsx("div",{style:{textAlign:"right",marginTop:12},children:e.jsx(F.pn,{size:"sm",variant:"ghost",onClick:()=>q(!1),children:w("docEditor.close","Close")})})]})}),e.jsxs("div",{style:{display:"flex",gap:0},children:[b&&He.length>0&&e.jsxs("nav",{className:"nice-doc-editor__toc",style:{width:200,minWidth:160,borderRight:"1px solid var(--border-color, #eee)",padding:"8px 4px",fontSize:"0.8em",overflowY:"auto",maxHeight:500},children:[e.jsx("div",{style:{fontWeight:600,padding:"4px 8px",fontSize:"0.75em",textTransform:"uppercase",color:"var(--text-muted, #999)"},children:w("docEditor.toc","Contents")}),He.map(f=>e.jsx("div",{style:{padding:"3px 8px",paddingLeft:8+(f.level-1)*12,cursor:"pointer",borderRadius:4,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",background:f.idx===k?"var(--nice-primary-bg, #e8f0fe)":void 0},onClick:()=>v(f.idx),title:f.text,children:f.text||w("docEditor.untitled","Untitled")},f.idx))]}),e.jsx("div",{className:"nice-doc-editor__body",style:{flex:1},children:g.map((f,K)=>e.jsxs("div",{className:`nice-doc-editor__block nice-doc-editor__block--${f.type} ${K===k?"nice-doc-editor__block--focused":""} ${ie===K?"nice-doc-editor__block--drop-target":""} ${f.locked?"nice-doc-editor__block--locked":""}`,onClick:()=>v(K),onContextMenu:te=>Ae(te,K),draggable:!i&&!f.locked,onDragStart:te=>Pe(te,K),onDragOver:te=>Je(te,K),onDrop:te=>ze(te,K),onDragEnd:()=>{ve(null),M(null)},style:{opacity:ce===K?.4:1,marginLeft:(f.indent??0)*24},children:[!i&&!f.locked&&e.jsx("div",{className:"nice-doc-editor__block-handle",title:w("docEditor.drag","Drag to reorder"),children:"?"}),f.locked&&e.jsx("span",{className:"nice-doc-editor__lock-icon",style:{position:"absolute",top:2,right:4,fontSize:"0.7em",opacity:.5},children:"??"}),f.type==="divider"?e.jsx("hr",{className:"nice-doc-editor__divider"}):f.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:["� ",w("docEditor.pageBreak","Page Break")," �"]}):f.type==="image"||f.type==="video"?e.jsx("div",{className:"nice-doc-editor__media-block",children:f.src?f.type==="image"?e.jsx("img",{src:f.src,alt:f.alt??"",className:"nice-doc-editor__image",style:{maxWidth:"100%"}}):e.jsx("video",{src:f.src,controls:!0,className:"nice-doc-editor__video",style:{maxWidth:"100%"}}):!i&&e.jsxs("div",{style:{display:"flex",gap:4,alignItems:"center"},children:[e.jsx(F.Pe,{size:"sm",placeholder:w("docEditor.mediaUrl",f.type==="image"?"Image URL":"Video URL"),value:f.src??"",onChange:te=>Q(K,{src:te})}),$&&e.jsx(F.pn,{size:"sm",variant:"ghost",onClick:()=>{var te;v(K),(te=D.current)==null||te.click()},children:"??"})]})}):f.type==="callout"?e.jsxs("div",{className:"nice-doc-editor__callout",style:{display:"flex",gap:8,padding:"8px 12px",background:f.bgColor??"#f0f7ff",borderRadius:4,color:f.color},children:[e.jsx("span",{style:{fontSize:"1.2em"},children:f.icon??"??"}),e.jsx("div",{ref:te=>{te&&A.current.set(f.id,te)},className:"nice-doc-editor__content",contentEditable:!i&&!f.locked,suppressContentEditableWarning:!0,onInput:te=>$e(te,K),onFocus:()=>v(K),onKeyDown:te=>we(te,K),"data-placeholder":w("docEditor.calloutPlaceholder","Callout text..."),role:"textbox","aria-multiline":"true",style:{flex:1,outline:"none"},children:f.content})]}):f.type==="toggle"?e.jsxs("details",{open:f.open,className:"nice-doc-editor__toggle",onToggle:te=>Q(K,{open:te.target.open}),children:[e.jsx("summary",{style:{cursor:"pointer",fontWeight:500},children:f.content.split(`
|
|
417
|
+
`)[0]||w("docEditor.toggleTitle","Toggle")}),e.jsx("div",{ref:te=>{te&&A.current.set(f.id,te)},className:"nice-doc-editor__content",contentEditable:!i&&!f.locked,suppressContentEditableWarning:!0,onInput:te=>$e(te,K),onFocus:()=>v(K),onKeyDown:te=>we(te,K),role:"textbox","aria-multiline":"true",style:{padding:"4px 0"},children:f.content.split(`
|
|
418
|
+
`).slice(1).join(`
|
|
419
|
+
`)})]}):f.type==="code"?e.jsxs("div",{className:"nice-doc-editor__code-block",style:{position:"relative"},children:[!i&&e.jsx(F.Pe,{size:"sm",value:f.language??"",onChange:te=>Q(K,{language:te}),placeholder:"Language",style:{position:"absolute",top:4,right:4,width:80,opacity:.7}}),e.jsx("pre",{ref:te=>{te&&A.current.set(f.id,te)},className:"nice-doc-editor__content",contentEditable:!i&&!f.locked,suppressContentEditableWarning:!0,onInput:te=>$e(te,K),onFocus:()=>v(K),onKeyDown:te=>we(te,K),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:f.content})]}):e.jsxs("div",{style:{position:"relative"},children:[e.jsx("div",{ref:te=>{te&&A.current.set(f.id,te)},className:"nice-doc-editor__content",contentEditable:!i&&!f.locked,suppressContentEditableWarning:!0,style:{textAlign:f.align,fontWeight:f.bold?"bold":void 0,fontStyle:f.italic?"italic":void 0,textDecoration:[f.underline?"underline":"",f.strikethrough?"line-through":""].filter(Boolean).join(" ")||void 0,color:f.color,backgroundColor:f.bgColor},onInput:te=>$e(te,K),onFocus:()=>v(K),onKeyDown:te=>we(te,K),"data-placeholder":!f.content&&y?y:void 0,role:"textbox","aria-multiline":"true",children:f.content}),ae&&K===k&&re.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:re.map((te,Ce)=>e.jsxs("li",{className:Ce===_e?"nice-doc-editor__slash-item--active":"",style:{padding:"6px 10px",cursor:"pointer",borderRadius:4,display:"flex",gap:8,alignItems:"center",background:Ce===_e?"var(--nice-primary-bg, #e8f0fe)":void 0},onMouseDown:Se=>{Se.preventDefault(),Ne(te)},onMouseEnter:()=>J(Ce),children:[e.jsx("span",{style:{width:24,textAlign:"center"},children:te.icon}),e.jsx("span",{children:te.label})]},`${te.type}-${te.label}`))})]})]},f.id))})]}),ue&&e.jsxs("div",{className:"nice-doc-editor__ctx-menu",style:{position:"fixed",left:ue.x,top:ue.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:()=>{fe(ue.idx),ke(null)},children:"? Duplicate"}),e.jsx("div",{style:{padding:"6px 12px",cursor:"pointer"},onClick:()=>{ge(ue.idx),ke(null)},children:"+ Insert below"}),e.jsx("div",{style:{padding:"6px 12px",cursor:"pointer"},onClick:()=>{oe(ue.idx,-1),ke(null)},children:"? Move up"}),e.jsx("div",{style:{padding:"6px 12px",cursor:"pointer"},onClick:()=>{oe(ue.idx,1),ke(null)},children:"? Move down"}),e.jsx("div",{style:{padding:"6px 12px",cursor:"pointer"},onClick:()=>{var f;Q(ue.idx,{locked:!((f=g[ue.idx])!=null&&f.locked)}),ke(null)},children:($t=g[ue.idx])!=null&&$t.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:()=>{X(ue.idx),ke(null)},children:"?? Delete"})]}),I&&ne&&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:[ne.words," ",w("docEditor.words","words")]}),e.jsxs("span",{children:[ne.chars," ",w("docEditor.chars","characters")]}),e.jsxs("span",{children:[g.length," ",w("docEditor.blocks","blocks")]}),e.jsxs("span",{children:["~",ne.readingTime," ",w("docEditor.readingTime","min read")]})]})]})});yn.displayName="NiceDocumentEditor";const Sa=["street","streetNumber","apartment","city","postalCode","state","country"],ot={street:"Street",streetNumber:"Number",apartment:"Apt/Suite",city:"City",postalCode:"Postal Code",state:"State/Province",country:"Country"},_n=a.forwardRef(({label:n,helperText:t,error:i,required:r,disabled:d,readOnly:h,size:y="md",name:N,id:$,className:S,style:H,accessMode:I,value:b={},onChange:C,fields:P=Sa,placeholders:ee={},countries:V,layout:Y="vertical",countryFirst:p=!1,validatePostalCode:T},w)=>{const E=F.Cl(I,$),G=E==="hidden";E==="disabled"&&(d=!0),E==="readOnly"&&(h=!0);const{t:g}=F.ue(),k=F.nl($),v=a.useCallback((x,c)=>{C==null||C({...b,[x]:c})},[b,C]),A=a.useMemo(()=>{if(T&&b.postalCode)return T(b.postalCode,b.country)},[T,b.postalCode,b.country]),D=a.useMemo(()=>p&&P.includes("country")?["country",...P.filter(x=>x!=="country")]:P,[P,p]),W=`nice-address nice-address--${Y} nice-size-${y}`;return G?null:e.jsxs("div",{ref:w,id:k,className:`${W}${S?` ${S}`:""}${i?" nice-error":""}${d?" nice-disabled":""}`,style:H,role:"group","aria-label":n??g("address","Address"),children:[n&&e.jsxs("label",{className:"nice-address__label",children:[n,r&&e.jsx("span",{className:"nice-required",children:"*"})]}),e.jsx("div",{className:"nice-address__fields",children:D.map(x=>x==="country"&&V?e.jsxs("div",{className:`nice-address__field nice-address__field--${x}`,children:[e.jsx("label",{className:"nice-address__field-label",children:g(x,ot[x])}),e.jsxs("select",{className:"nice-input nice-select",value:b.country??"",onChange:c=>v("country",c.target.value),disabled:d,"aria-label":g(x,ot[x]),children:[e.jsx("option",{value:"",children:ee.country??g("selectCountry","— Select country —")}),V.map(c=>e.jsx("option",{value:c.code,children:c.name},c.code))]})]},x):e.jsxs("div",{className:`nice-address__field nice-address__field--${x}`,children:[e.jsx("label",{className:"nice-address__field-label",children:g(x,ot[x])}),e.jsx("input",{className:`nice-input${x==="postalCode"&&A?" nice-input--error":""}`,type:"text",name:N?`${N}.${x}`:x,value:b[x]??"",onChange:c=>v(x,c.target.value),placeholder:ee[x]??"",disabled:d,readOnly:h,"aria-label":g(x,ot[x])}),x==="postalCode"&&A&&e.jsx("span",{className:"nice-error-text",children:A})]},x))}),t&&e.jsx("span",{className:"nice-helper-text",children:t}),i&&typeof i=="string"&&e.jsx("span",{className:"nice-error-text",children:i})]})});_n.displayName="NiceAddressInput";const Ea=[{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"}],kn=a.forwardRef(({label:n,helperText:t,error:i,required:r,disabled:d,readOnly:h,size:y="md",name:N,id:$,className:S,style:H,accessMode:I,value:b,onChange:C,onBlur:P,currency:ee="PLN",onCurrencyChange:V,currencies:Y=Ea,useMinorUnit:p=!1,min:T,max:w,locale:E,placeholder:G,showCurrencySelector:g},k)=>{const v=F.Cl(I,$),A=v==="hidden";v==="disabled"&&(d=!0),v==="readOnly"&&(h=!0);const{t:D}=F.ue(),W=F.nl($),x=a.useMemo(()=>Y.find(s=>s.code===ee)??Y[0],[ee,Y]),c=(x==null?void 0:x.decimals)??2,z=a.useMemo(()=>b==null?"":(p?b/Math.pow(10,c):b).toFixed(c),[b,p,c]),_=a.useCallback(s=>{const m=s.replace(/[^\d.,\-]/g,"").replace(",",".");if(m===""||m==="-"){C==null||C(null);return}const l=parseFloat(m);if(isNaN(l))return;const u=p?Math.round(l*Math.pow(10,c)):l;T!=null&&u<T||w!=null&&u>w||(C==null||C(u))},[C,p,c,T,w]),j=g??Y.length>1,o=a.useMemo(()=>{if(b==null)return"";const s=p?b/Math.pow(10,c):b;try{return new Intl.NumberFormat(E,{style:"currency",currency:(x==null?void 0:x.code)??"USD",minimumFractionDigits:c}).format(s)}catch{return`${s.toFixed(c)} ${x==null?void 0:x.code}`}},[b,p,c,E,x]);return A?null:e.jsxs("div",{ref:k,id:W,className:`nice-currency nice-size-${y}${S?` ${S}`:""}${i?" nice-error":""}${d?" nice-disabled":""}`,style:H,children:[n&&e.jsxs("label",{className:"nice-currency__label",children:[n,r&&e.jsx("span",{className:"nice-required",children:"*"})]}),e.jsxs("div",{className:"nice-currency__row",children:[j&&e.jsx("select",{className:"nice-currency__select nice-select",value:ee,onChange:s=>V==null?void 0:V(s.target.value),disabled:d,"aria-label":D("currency","Currency"),children:Y.map(s=>e.jsxs("option",{value:s.code,children:[s.symbol," ",s.code]},s.code))}),!j&&e.jsx("span",{className:"nice-currency__symbol",children:x==null?void 0:x.symbol}),e.jsx("input",{className:"nice-input nice-currency__amount",type:"text",inputMode:"decimal",name:N,value:z,onChange:s=>_(s.target.value),onBlur:P,placeholder:G??`0.${"0".repeat(c)}`,disabled:d,readOnly:h,"aria-label":D("amount","Amount")})]}),o&&b!=null&&e.jsx("span",{className:"nice-currency__formatted",children:o}),t&&e.jsx("span",{className:"nice-helper-text",children:t}),i&&typeof i=="string"&&e.jsx("span",{className:"nice-error-text",children:i})]})});kn.displayName="NiceCurrencyInput";let Aa=1;function Ra(n){return{id:`new-${Aa++}`,description:"",quantity:1,unitPrice:0,vatRate:n,discount:0,unit:"szt."}}function jn(n){const t=n.quantity*n.unitPrice*(1-(n.discount??0)/100),i=Math.round(t*100)/100,r=Math.round(i*(n.vatRate??0)/100*100)/100;return{...n,netAmount:i,grossAmount:i+r}}function La(n){const t=n.map(jn),i=t.reduce((N,$)=>N+($.netAmount??0),0),r=t.reduce((N,$)=>N+($.grossAmount??0),0),d=r-i,h=new Map;for(const N of t){const $=N.vatRate??0,S=h.get($)??{base:0,amount:0};S.base+=N.netAmount??0,S.amount+=(N.grossAmount??0)-(N.netAmount??0),h.set($,S)}const y=Array.from(h.entries()).map(([N,$])=>({rate:N,base:Math.round($.base*100)/100,amount:Math.round($.amount*100)/100}));return{totalNet:Math.round(i*100)/100,totalVat:Math.round(d*100)/100,totalGross:Math.round(r*100)/100,vatBreakdown:y}}const Cn=a.forwardRef(({label:n,helperText:t,error:i,required:r,disabled:d,readOnly:h,size:y="md",name:N,id:$,className:S,style:H,accessMode:I,value:b=[],onChange:C,onTotalsChange:P,currencySymbol:ee="zł",defaultVatRate:V=23,vatRates:Y=[0,5,8,23],units:p=["szt.","h","kg","m","usł."],showDiscount:T=!0,showUnit:w=!0,showTotals:E=!0,editable:G=!0,maxLines:g},k)=>{const v=F.Cl(I,$),A=v==="hidden";v==="disabled"&&(d=!0),v==="readOnly"&&(h=!0);const{t:D}=F.ue(),W=F.nl($),x=a.useMemo(()=>b.map(jn),[b]),c=a.useMemo(()=>La(b),[b]);a.useEffect(()=>{P==null||P(c)},[c,P]);const z=a.useCallback((s,m,l)=>{const u=[...b];u[s]={...u[s],[m]:l},C==null||C(u)},[b,C]),_=a.useCallback(()=>{g&&b.length>=g||(C==null||C([...b,Ra(V)]))},[b,C,V,g]),j=a.useCallback(s=>{C==null||C(b.filter((m,l)=>l!==s))},[b,C]),o=s=>`${s.toFixed(2)} ${ee}`;return A?null:e.jsxs("div",{ref:k,id:W,className:`nice-invoice-lines nice-size-${y}${S?` ${S}`:""}${i?" nice-error":""}${d?" nice-disabled":""}`,style:H,children:[n&&e.jsxs("label",{className:"nice-invoice-lines__label",children:[n,r&&e.jsx("span",{className:"nice-required",children:"*"})]}),e.jsxs("table",{className:"nice-invoice-lines__table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{className:"nice-il__th-num",children:"#"}),e.jsx("th",{className:"nice-il__th-desc",children:D("description","Description")}),e.jsx("th",{className:"nice-il__th-qty",children:D("qty","Qty")}),w&&e.jsx("th",{className:"nice-il__th-unit",children:D("unit","Unit")}),e.jsx("th",{className:"nice-il__th-price",children:D("unitPrice","Unit Price")}),T&&e.jsx("th",{className:"nice-il__th-disc",children:D("discount","Disc %")}),e.jsx("th",{className:"nice-il__th-vat",children:D("vat","VAT %")}),e.jsx("th",{className:"nice-il__th-net",children:D("net","Net")}),e.jsx("th",{className:"nice-il__th-gross",children:D("gross","Gross")}),G&&!h&&e.jsx("th",{className:"nice-il__th-actions"})]})}),e.jsx("tbody",{children:x.map((s,m)=>e.jsxs("tr",{children:[e.jsx("td",{className:"nice-il__cell-num",children:m+1}),e.jsx("td",{className:"nice-il__cell-desc",children:e.jsx("input",{className:"nice-input",type:"text",value:s.description,onChange:l=>z(m,"description",l.target.value),disabled:d,readOnly:h,placeholder:D("itemDescription","Item description")})}),e.jsx("td",{className:"nice-il__cell-qty",children:e.jsx("input",{className:"nice-input",type:"number",value:s.quantity,onChange:l=>z(m,"quantity",parseFloat(l.target.value)||0),disabled:d,readOnly:h,min:0,step:"any"})}),w&&e.jsx("td",{className:"nice-il__cell-unit",children:e.jsx("select",{className:"nice-select",value:s.unit??"",onChange:l=>z(m,"unit",l.target.value),disabled:d,children:p.map(l=>e.jsx("option",{value:l,children:l},l))})}),e.jsx("td",{className:"nice-il__cell-price",children:e.jsx("input",{className:"nice-input",type:"number",value:s.unitPrice,onChange:l=>z(m,"unitPrice",parseFloat(l.target.value)||0),disabled:d,readOnly:h,min:0,step:"0.01"})}),T&&e.jsx("td",{className:"nice-il__cell-disc",children:e.jsx("input",{className:"nice-input",type:"number",value:s.discount??0,onChange:l=>z(m,"discount",parseFloat(l.target.value)||0),disabled:d,readOnly:h,min:0,max:100})}),e.jsx("td",{className:"nice-il__cell-vat",children:e.jsx("select",{className:"nice-select",value:s.vatRate??0,onChange:l=>z(m,"vatRate",parseInt(l.target.value,10)),disabled:d,children:Y.map(l=>e.jsxs("option",{value:l,children:[l,"%"]},l))})}),e.jsx("td",{className:"nice-il__cell-net",children:o(s.netAmount??0)}),e.jsx("td",{className:"nice-il__cell-gross",children:o(s.grossAmount??0)}),G&&!h&&e.jsx("td",{className:"nice-il__cell-actions",children:e.jsx("button",{type:"button",className:"nice-btn nice-btn--icon nice-btn--sm",onClick:()=>j(m),disabled:d,title:D("remove","Remove"),children:"✕"})})]},s.id))})]}),G&&!h&&e.jsxs("button",{type:"button",className:"nice-btn nice-btn--outlined nice-btn--sm nice-invoice-lines__add",onClick:_,disabled:d||g!=null&&b.length>=g,children:["+ ",D("addLine","Add line")]}),E&&e.jsxs("div",{className:"nice-invoice-lines__totals",children:[e.jsxs("div",{className:"nice-il__total-row",children:[e.jsxs("span",{children:[D("totalNet","Net total"),":"]}),e.jsx("span",{className:"nice-il__total-value",children:o(c.totalNet)})]}),c.vatBreakdown.map(s=>e.jsxs("div",{className:"nice-il__total-row nice-il__total-row--vat",children:[e.jsxs("span",{children:["VAT ",s.rate,"%:"]}),e.jsx("span",{className:"nice-il__total-value",children:o(s.amount)})]},s.rate)),e.jsxs("div",{className:"nice-il__total-row nice-il__total-row--gross",children:[e.jsxs("span",{children:[D("totalGross","Gross total"),":"]}),e.jsx("span",{className:"nice-il__total-value nice-il__total-value--gross",children:o(c.totalGross)})]})]}),t&&e.jsx("span",{className:"nice-helper-text",children:t}),i&&typeof i=="string"&&e.jsx("span",{className:"nice-error-text",children:i})]})});Cn.displayName="NiceInvoiceLineEditor";const Nn=a.forwardRef(({label:n,helperText:t,error:i,required:r,disabled:d,readOnly:h,size:y="md",name:N,id:$,className:S,style:H,accessMode:I,value:b=[],onChange:C,contacts:P=[],onSearch:ee,searchDelay:V=300,multiple:Y=!1,placeholder:p,onContactClick:T,maxSelections:w},E)=>{const G=F.Cl(I,$),g=G==="hidden";G==="disabled"&&(d=!0),G==="readOnly"&&(h=!0);const{t:k}=F.ue(),v=F.nl($),[A,D]=a.useState(""),[W,x]=a.useState([]),[c,z]=a.useState(!1),[_,j]=a.useState(!1),o=a.useMemo(()=>{const u=[...P,...W],q=new Map(u.map(O=>[O.id,O]));return b.map(O=>q.get(O)).filter(Boolean)},[b,P,W]),s=a.useCallback(u=>{if(D(u),u.length<1){x([]),z(!1);return}if(ee){j(!0);const Z=setTimeout(async()=>{const le=await ee(u);x(le),z(!0),j(!1)},V);return()=>clearTimeout(Z)}const q=u.toLowerCase(),O=P.filter(Z=>{var le,L;return Z.name.toLowerCase().includes(q)||((le=Z.email)==null?void 0:le.toLowerCase().includes(q))||((L=Z.phone)==null?void 0:L.includes(u))});x(O),z(!0)},[ee,P,V]),m=a.useCallback(u=>{if(Y)if(b.includes(u.id))C==null||C(b.filter(q=>q!==u.id));else{if(w&&b.length>=w)return;C==null||C([...b,u.id])}else C==null||C([u.id]),z(!1),D("")},[b,C,Y,w]),l=a.useCallback(u=>{C==null||C(b.filter(q=>q!==u))},[b,C]);return g?null:e.jsxs("div",{ref:E,id:v,className:`nice-contact-picker nice-size-${y}${S?` ${S}`:""}${i?" nice-error":""}${d?" nice-disabled":""}`,style:H,children:[n&&e.jsxs("label",{className:"nice-contact-picker__label",children:[n,r&&e.jsx("span",{className:"nice-required",children:"*"})]}),o.length>0&&e.jsx("div",{className:"nice-contact-picker__chips",children:o.map(u=>e.jsxs("span",{className:"nice-contact-picker__chip",onClick:()=>T==null?void 0:T(u),children:[u.avatarUrl&&e.jsx("img",{src:u.avatarUrl,alt:"",className:"nice-contact-picker__chip-avatar"}),e.jsx("span",{children:u.name}),!h&&e.jsx("button",{type:"button",className:"nice-contact-picker__chip-remove",onClick:q=>{q.stopPropagation(),l(u.id)},disabled:d,children:"×"})]},u.id))}),!h&&e.jsxs("div",{className:"nice-contact-picker__search",children:[e.jsx("input",{className:"nice-input",type:"text",value:A,onChange:u=>s(u.target.value),onFocus:()=>A.length>0&&z(!0),onBlur:()=>setTimeout(()=>z(!1),200),placeholder:p??k("searchContacts","Search contacts…"),disabled:d,"aria-label":k("searchContacts","Search contacts")}),_&&e.jsx("span",{className:"nice-contact-picker__spinner",children:"⏳"})]}),c&&W.length>0&&e.jsx("div",{className:"nice-contact-picker__dropdown",role:"listbox",children:W.map(u=>e.jsxs("div",{className:`nice-contact-picker__option${b.includes(u.id)?" nice-contact-picker__option--selected":""}`,role:"option","aria-selected":b.includes(u.id),onClick:()=>m(u),children:[u.avatarUrl&&e.jsx("img",{src:u.avatarUrl,alt:"",className:"nice-contact-picker__option-avatar"}),e.jsxs("div",{className:"nice-contact-picker__option-info",children:[e.jsx("span",{className:"nice-contact-picker__option-name",children:u.name}),u.subtitle&&e.jsx("span",{className:"nice-contact-picker__option-subtitle",children:u.subtitle}),u.email&&e.jsx("span",{className:"nice-contact-picker__option-email",children:u.email})]}),u.type&&e.jsx("span",{className:"nice-contact-picker__option-type",children:u.type==="person"?"👤":"🏢"})]},u.id))}),t&&e.jsx("span",{className:"nice-helper-text",children:t}),i&&typeof i=="string"&&e.jsx("span",{className:"nice-error-text",children:i})]})});Nn.displayName="NiceContactPicker";const Ta=["highlight","underline","strikethrough","freehand","text","rect","arrow"],Da={highlight:"🖍️",underline:"⎁",strikethrough:"S̶",freehand:"✏️",text:"T",rect:"▭",arrow:"→",stamp:"🔏"},wn=a.forwardRef(({label:n,helperText:t,error:i,required:r,disabled:d,readOnly:h,size:y="md",id:N,className:$,style:S,accessMode:H,src:I,annotations:b=[],onAnnotationsChange:C,activeTool:P,onToolChange:ee,currentPage:V=1,onPageChange:Y,totalPages:p=1,defaultColor:T="var(--nice-warning, #ffff00)",tools:w=Ta,author:E,zoom:G=1,onZoomChange:g,onAnnotationClick:k,onAnnotationDelete:v},A)=>{const D=F.Cl(H,N),W=D==="hidden";D==="disabled"&&(d=!0),D==="readOnly"&&(h=!0);const{t:x}=F.ue(),c=F.nl(N),z=b.filter(o=>o.page===V),_=a.useCallback(o=>{ee==null||ee(P===o?null:o)},[P,ee]),j=a.useCallback(o=>{if(h||!P||P==="freehand")return;const s=o.currentTarget.getBoundingClientRect(),m=(o.clientX-s.left)/s.width,l=(o.clientY-s.top)/s.height,u={id:`ann-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,tool:P,page:V,x:m,y:l,color:T,author:E,createdAt:new Date().toISOString(),text:P==="text"?"":void 0};C==null||C([...b,u])},[h,P,V,T,E,b,C]);return W?null:e.jsxs("div",{ref:A,id:c,className:`nice-pdf-annotation nice-size-${y}${$?` ${$}`:""}${i?" nice-error":""}${d?" nice-disabled":""}`,style:S,children:[n&&e.jsxs("div",{className:"nice-pdf-annotation__label",children:[n,r&&e.jsx("span",{className:"nice-required",children:"*"})]}),!h&&e.jsxs("div",{className:"nice-pdf-annotation__toolbar",children:[w.map(o=>e.jsx("button",{type:"button",className:`nice-pdf-annotation__tool-btn${P===o?" nice-pdf-annotation__tool-btn--active":""}`,onClick:()=>_(o),disabled:d,title:x(`pdfTool_${o}`,o),children:Da[o]},o)),e.jsx("span",{className:"nice-pdf-annotation__toolbar-sep"}),e.jsx("button",{type:"button",disabled:d,onClick:()=>g==null?void 0:g(Math.max(.25,G-.25)),title:x("zoomOut","Zoom out"),children:"−"}),e.jsxs("span",{className:"nice-pdf-annotation__zoom",children:[Math.round(G*100),"%"]}),e.jsx("button",{type:"button",disabled:d,onClick:()=>g==null?void 0:g(Math.min(4,G+.25)),title:x("zoomIn","Zoom in"),children:"+"})]}),e.jsxs("div",{className:"nice-pdf-annotation__viewport",style:{transform:`scale(${G})`,transformOrigin:"top left"},children:[e.jsx("iframe",{src:I,className:"nice-pdf-annotation__frame",title:x("pdfViewer","PDF Viewer")}),e.jsx("div",{className:"nice-pdf-annotation__layer",onClick:j,children:z.map(o=>e.jsxs("div",{className:`nice-pdf-annotation__mark nice-pdf-annotation__mark--${o.tool}`,style:{left:`${o.x*100}%`,top:`${o.y*100}%`,backgroundColor:o.color},onClick:s=>{s.stopPropagation(),k==null||k(o)},title:o.text??o.tool,children:[o.text&&e.jsx("span",{children:o.text}),!h&&e.jsx("button",{type:"button",className:"nice-pdf-annotation__mark-delete",onClick:s=>{s.stopPropagation(),v==null||v(o.id)},children:"×"})]},o.id))})]}),e.jsxs("div",{className:"nice-pdf-annotation__pager",children:[e.jsx("button",{type:"button",disabled:d||V<=1,onClick:()=>Y==null?void 0:Y(V-1),children:"◀"}),e.jsx("span",{children:x("pageOf","{page} / {total}").replace("{page}",String(V)).replace("{total}",String(p))}),e.jsx("button",{type:"button",disabled:d||V>=p,onClick:()=>Y==null?void 0:Y(V+1),children:"▶"})]}),t&&e.jsx("span",{className:"nice-helper-text",children:t}),i&&typeof i=="string"&&e.jsx("span",{className:"nice-error-text",children:i})]})});wn.displayName="NicePDFAnnotationEditor";const $n=a.forwardRef(({label:n,helperText:t,error:i,disabled:r,readOnly:d,size:h="md",id:y,className:N,style:$,accessMode:S,pages:H,selectedPageId:I,content:b="",contentFormat:C="html",editing:P=!1,onPageSelect:ee,onContentChange:V,onSave:Y,onCreatePage:p,onDeletePage:T,onEditToggle:w,onVersionHistory:E,sidebarWidth:G=260,sidebarCollapsed:g=!1,onSidebarToggle:k,searchable:v=!0,onSearch:A},D)=>{const W=F.Cl(S,y),x=W==="hidden";W==="disabled"&&(r=!0),W==="readOnly"&&(d=!0);const{t:c}=F.ue(),z=F.nl(y),[_,j]=a.useState(""),[o,s]=a.useState(""),[m,l]=a.useState(!1),u=a.useMemo(()=>{const le=L=>{for(const U of L){if(U.id===I)return U;if(U.children){const ae=le(U.children);if(ae)return ae}}};return le(H)},[H,I]),q=a.useCallback(le=>{j(le),A==null||A(le)},[A]),O=a.useCallback(()=>{o.trim()&&(p==null||p(I??null,o.trim()),s(""),l(!1))},[o,I,p]),Z=(le,L=0)=>e.jsx("ul",{className:"nice-wiki__tree",style:{paddingLeft:L>0?16:0},children:le.map(U=>{var ae;return e.jsxs("li",{className:"nice-wiki__tree-item",children:[e.jsxs("div",{className:`nice-wiki__tree-node${U.id===I?" nice-wiki__tree-node--active":""}${U.isDraft?" nice-wiki__tree-node--draft":""}`,onClick:()=>ee==null?void 0:ee(U),role:"treeitem","aria-selected":U.id===I,children:[e.jsx("span",{className:"nice-wiki__tree-icon",children:(ae=U.children)!=null&&ae.length?"📁":"📄"}),e.jsx("span",{className:"nice-wiki__tree-title",children:U.title}),U.isDraft&&e.jsx("span",{className:"nice-wiki__tree-draft",children:c("draft","Draft")})]}),U.children&&U.children.length>0&&Z(U.children,L+1)]},U.id)})});return x?null:e.jsxs("div",{ref:D,id:z,className:`nice-wiki nice-size-${h}${N?` ${N}`:""}${r?" nice-disabled":""}`,style:$,children:[!g&&e.jsxs("aside",{className:"nice-wiki__sidebar",style:{width:G},children:[e.jsxs("div",{className:"nice-wiki__sidebar-header",children:[e.jsx("span",{className:"nice-wiki__sidebar-title",children:n??c("wiki","Wiki")}),k&&e.jsx("button",{type:"button",className:"nice-wiki__sidebar-toggle",onClick:()=>k(!0),children:"«"})]}),v&&e.jsx("input",{type:"text",className:"nice-input nice-wiki__search",value:_,onChange:le=>q(le.target.value),placeholder:c("searchPages","Search pages…"),disabled:r}),e.jsx("div",{className:"nice-wiki__page-tree",role:"tree",children:Z(H)}),p&&!d&&e.jsx("div",{className:"nice-wiki__sidebar-footer",children:m?e.jsxs("div",{className:"nice-wiki__create-form",children:[e.jsx("input",{type:"text",className:"nice-input",value:o,onChange:le=>s(le.target.value),placeholder:c("pageTitle","Page title"),onKeyDown:le=>le.key==="Enter"&&O(),disabled:r}),e.jsx("button",{type:"button",disabled:r||!o.trim(),onClick:O,children:"✓"}),e.jsx("button",{type:"button",onClick:()=>l(!1),children:"✕"})]}):e.jsxs("button",{type:"button",className:"nice-wiki__add-page",onClick:()=>l(!0),disabled:r,children:["+ ",c("newPage","New page")]})})]}),g&&k&&e.jsx("button",{type:"button",className:"nice-wiki__sidebar-expand",onClick:()=>k(!1),children:"»"}),e.jsx("main",{className:"nice-wiki__content",children:u?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"nice-wiki__content-header",children:[e.jsx("h1",{className:"nice-wiki__page-title",children:u.title}),e.jsxs("div",{className:"nice-wiki__content-actions",children:[w&&!d&&e.jsx("button",{type:"button",disabled:r,onClick:()=>w(!P),children:P?c("preview","Preview"):c("edit","Edit")}),E&&e.jsx("button",{type:"button",disabled:r,onClick:()=>E(u.id),children:c("history","History")}),T&&!d&&e.jsx("button",{type:"button",className:"nice-btn--danger",disabled:r,onClick:()=>T(u.id),children:c("delete","Delete")})]})]}),u.updatedAt&&e.jsxs("div",{className:"nice-wiki__page-meta",children:[u.updatedBy&&e.jsxs("span",{children:[c("lastEditedBy","Last edited by")," ",u.updatedBy]}),e.jsx("span",{children:new Date(u.updatedAt).toLocaleDateString()})]}),P?e.jsxs("div",{className:"nice-wiki__editor",children:[e.jsx("textarea",{className:"nice-wiki__editor-textarea",value:b,onChange:le=>V==null?void 0:V(le.target.value),disabled:r}),Y&&e.jsx("button",{type:"button",className:"nice-btn nice-btn--primary",disabled:r,onClick:()=>Y(u.id,b),children:c("save","Save")})]}):e.jsx("div",{className:"nice-wiki__viewer",children:C==="html"?e.jsx("div",{className:"nice-wiki__html",dangerouslySetInnerHTML:{__html:F.Ys(b)}}):e.jsx("pre",{className:"nice-wiki__markdown",children:b})})]}):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.")})})}),t&&e.jsx("span",{className:"nice-helper-text",children:t}),i&&typeof i=="string"&&e.jsx("span",{className:"nice-error-text",children:i})]})});$n.displayName="NiceWiki";const Ia=[{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"}],Mn=a.forwardRef(({label:n,helperText:t,error:i,required:r,disabled:d,readOnly:h,size:y="md",name:N,id:$,className:S,style:H,accessMode:I,value:b="",onChange:C,countryCode:P="PL",onCountryChange:ee,countries:V=Ia,showCountrySelector:Y=!0,autoPrefixVat:p=!0,validationResult:T,onValidateRequest:w,placeholder:E},G)=>{const g=F.Cl(I,$),k=g==="hidden";g==="disabled"&&(d=!0),g==="readOnly"&&(h=!0);const{t:v}=F.ue(),A=F.nl($),D=a.useMemo(()=>V.find(_=>_.code===P)??V[0],[V,P]),W=a.useCallback(_=>{let j=_.toUpperCase();return D&&j.startsWith(D.prefix)&&(j=j.slice(D.prefix.length)),D?D.pattern.test(j):j.length>0},[D]),x=a.useCallback(_=>{const j=_.target.value.replace(/\s/g,"");C==null||C(j,W(j))},[C,W]),c=p&&b&&D&&!b.toUpperCase().startsWith(D.prefix)?`${D.prefix}${b}`:b,z=W(b);return k?null:e.jsxs("div",{ref:G,id:A,className:`nice-vat-input nice-size-${y}${S?` ${S}`:""}${i||!z&&b.length>0?" nice-error":""}${d?" nice-disabled":""}`,style:H,children:[n&&e.jsxs("label",{className:"nice-vat-input__label",htmlFor:`${A}-input`,children:[n,r&&e.jsx("span",{className:"nice-required",children:"*"})]}),e.jsxs("div",{className:"nice-vat-input__row",children:[Y&&e.jsx("select",{className:"nice-vat-input__country",value:P,onChange:_=>ee==null?void 0:ee(_.target.value),disabled:d||h,children:V.map(_=>e.jsx("option",{value:_.code,children:_.prefix},_.code))}),e.jsx("input",{id:`${A}-input`,className:"nice-input nice-vat-input__field",type:"text",name:N,value:b,onChange:x,readOnly:h,disabled:d,placeholder:E??(D==null?void 0:D.placeholder),required:r,"aria-invalid":!z&&b.length>0}),w&&b.length>0&&e.jsx("button",{type:"button",className:"nice-vat-input__verify",disabled:d||!z,onClick:()=>w(p?c:b,P),title:v("verifyVat","Verify VAT number"),children:"🔍"})]}),T&&e.jsxs("div",{className:`nice-vat-input__result nice-vat-input__result--${T.valid?"valid":"invalid"}`,children:[T.valid?"✅":"❌"," ",T.companyName??T.error??(T.valid?v("vatValid","VAT number valid"):v("vatInvalid","VAT number invalid"))]}),t&&e.jsx("span",{className:"nice-helper-text",children:t}),i&&typeof i=="string"&&e.jsx("span",{className:"nice-error-text",children:i})]})});Mn.displayName="NiceVatInput";const Pa=[{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"}],Sn=a.forwardRef(({label:n,helperText:t,error:i,required:r,disabled:d,readOnly:h,size:y="md",name:N,id:$,className:S,style:H,accessMode:I,value:b,onChange:C,rates:P,countryCode:ee,placeholder:V,showPercentage:Y=!0},p)=>{const T=F.Cl(I,$),w=T==="hidden";T==="disabled"&&(d=!0),T==="readOnly"&&(h=!0);const{t:E}=F.ue(),G=F.nl($),g=a.useMemo(()=>{const v=P??Pa;return ee?v.filter(A=>!A.countryCode||A.countryCode===ee):v},[P,ee]),k=a.useCallback(v=>{const A=v.target.value,D=g.find(W=>W.id===A);D&&(C==null||C(A,D))},[C,g]);return w?null:e.jsxs("div",{ref:p,id:G,className:`nice-tax-rate nice-size-${y}${S?` ${S}`:""}${i?" nice-error":""}${d?" nice-disabled":""}`,style:H,children:[n&&e.jsxs("label",{className:"nice-tax-rate__label",htmlFor:`${G}-select`,children:[n,r&&e.jsx("span",{className:"nice-required",children:"*"})]}),e.jsxs("select",{id:`${G}-select`,className:"nice-select nice-tax-rate__select",name:N,value:b??"",onChange:k,disabled:d||h,required:r,children:[e.jsx("option",{value:"",disabled:!0,children:V??E("selectRate","Select rate…")}),g.map(v=>e.jsxs("option",{value:v.id,children:[v.label,Y&&v.category!=="exempt"?` (${(v.rate*100).toFixed(0)}%)`:""]},v.id))]}),t&&e.jsx("span",{className:"nice-helper-text",children:t}),i&&typeof i=="string"&&e.jsx("span",{className:"nice-error-text",children:i})]})});Sn.displayName="NiceTaxRatePicker";const za={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)"},En=a.forwardRef(({label:n,helperText:t,error:i,required:r,disabled:d,readOnly:h,size:y="md",name:N,id:$,className:S,style:H,accessMode:I,value:b,onChange:C,accounts:P,treeView:ee=!1,placeholder:V,searchable:Y=!0,showType:p=!0,onSearch:T},w)=>{const E=F.Cl(I,$),G=E==="hidden";E==="disabled"&&(d=!0),E==="readOnly"&&(h=!0);const{t:g}=F.ue(),k=F.nl($),[v,A]=a.useState(""),[D,W]=a.useState(!1),x=a.useMemo(()=>{const o=s=>{for(const m of s){if(m.code===b)return m;if(m.children){const l=o(m.children);if(l)return l}}};return o(P)},[P,b]),c=a.useMemo(()=>{const o=[],s=m=>{for(const l of m)o.push(l),l.children&&s(l.children)};return s(P),o},[P]),z=a.useMemo(()=>{if(!v)return c;const o=v.toLowerCase();return c.filter(s=>s.code.toLowerCase().includes(o)||s.name.toLowerCase().includes(o))},[c,v]),_=a.useCallback(o=>{A(o),T==null||T(o),W(!0)},[T]),j=a.useCallback(o=>{C==null||C(o.code,o),W(!1),A("")},[C]);return G?null:e.jsxs("div",{ref:w,id:k,className:`nice-account-picker nice-size-${y}${S?` ${S}`:""}${i?" nice-error":""}${d?" nice-disabled":""}`,style:H,children:[n&&e.jsxs("label",{className:"nice-account-picker__label",htmlFor:`${k}-input`,children:[n,r&&e.jsx("span",{className:"nice-required",children:"*"})]}),e.jsx("div",{className:"nice-account-picker__control",children:Y&&!h?e.jsx("input",{id:`${k}-input`,className:"nice-input",type:"text",value:D?v:x?`${x.code} — ${x.name}`:"",onChange:o=>_(o.target.value),onFocus:()=>{A(""),W(!0)},onBlur:()=>setTimeout(()=>W(!1),200),placeholder:V??g("searchAccount","Search account…"),disabled:d,required:r}):e.jsx("div",{className:"nice-account-picker__display",children:x?`${x.code} — ${x.name}`:V??g("selectAccount","Select account…")})}),D&&z.length>0&&e.jsx("div",{className:"nice-account-picker__dropdown",role:"listbox",children:z.map(o=>e.jsxs("div",{className:`nice-account-picker__option${o.code===b?" nice-account-picker__option--selected":""}${o.isActive===!1?" nice-account-picker__option--inactive":""}`,role:"option","aria-selected":o.code===b,onClick:()=>j(o),children:[p&&o.type&&e.jsx("span",{className:"nice-account-picker__type",style:{color:za[o.type]},title:o.type,children:"●"}),e.jsx("span",{className:"nice-account-picker__code",children:o.code}),e.jsx("span",{className:"nice-account-picker__name",children:o.name})]},o.code))}),t&&e.jsx("span",{className:"nice-helper-text",children:t}),i&&typeof i=="string"&&e.jsx("span",{className:"nice-error-text",children:i})]})});En.displayName="NiceAccountPicker";const An=a.forwardRef(({label:n,helperText:t,error:i,required:r,disabled:d,readOnly:h,size:y="md",id:N,className:$,style:S,accessMode:H,mode:I="manual",onScan:b,onModeChange:C,beepOnScan:P=!0,beepFrequency:ee=1800,beepDuration:V=150,placeholder:Y,scanHistory:p=[],showHistory:T=!0,maxHistory:w=10,autoFocus:E=!0,onCameraFrame:G},g)=>{const k=F.Cl(H,N),v=k==="hidden";k==="disabled"&&(d=!0),k==="readOnly"&&(h=!0);const{t:A}=F.ue(),D=F.nl(N),[W,x]=a.useState(""),c=a.useRef(null),z=a.useRef(null),_=a.useCallback(()=>{if(P)try{z.current||(z.current=new AudioContext);const s=z.current,m=s.createOscillator(),l=s.createGain();m.connect(l),l.connect(s.destination),m.frequency.value=ee,m.type="square",l.gain.value=.3,m.start(),m.stop(s.currentTime+V/1e3)}catch{}},[P,ee,V]),j=a.useCallback(()=>{var s;W.trim()&&(_(),b==null||b({value:W.trim(),format:"manual",scannedAt:new Date}),x(""),(s=c.current)==null||s.focus())},[W,b,_]),o=p.slice(0,w);return v?null:e.jsxs("div",{ref:g,id:D,className:`nice-scanner nice-size-${y}${$?` ${$}`:""}${i?" nice-error":""}${d?" nice-disabled":""}`,style:S,children:[n&&e.jsxs("div",{className:"nice-scanner__label",children:[n,r&&e.jsx("span",{className:"nice-required",children:"*"})]}),e.jsxs("div",{className:"nice-scanner__modes",children:[e.jsxs("button",{type:"button",className:`nice-scanner__mode-btn${I==="camera"?" nice-scanner__mode-btn--active":""}`,onClick:()=>C==null?void 0:C("camera"),disabled:d,children:["📷 ",A("camera","Camera")]}),e.jsxs("button",{type:"button",className:`nice-scanner__mode-btn${I==="manual"?" nice-scanner__mode-btn--active":""}`,onClick:()=>C==null?void 0:C("manual"),disabled:d,children:["⌨️ ",A("manual","Manual")]})]}),I==="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:A("cameraPlaceholder","Camera preview — connect scanner adapter")})]})})}),I==="manual"&&!h&&e.jsxs("div",{className:"nice-scanner__manual",children:[e.jsx("input",{ref:c,className:"nice-input nice-scanner__input",type:"text",value:W,onChange:s=>x(s.target.value),onKeyDown:s=>s.key==="Enter"&&j(),placeholder:Y??A("enterCode","Enter or scan code…"),disabled:d,autoFocus:E}),e.jsx("button",{type:"button",className:"nice-scanner__submit",onClick:j,disabled:d||!W.trim(),children:"✓"})]}),T&&o.length>0&&e.jsxs("div",{className:"nice-scanner__history",children:[e.jsx("div",{className:"nice-scanner__history-label",children:A("recentScans","Recent scans")}),o.map((s,m)=>e.jsxs("div",{className:"nice-scanner__history-item",children:[e.jsx("span",{className:"nice-scanner__history-value",children:s.value}),s.format&&e.jsx("span",{className:"nice-scanner__history-format",children:s.format}),e.jsx("span",{className:"nice-scanner__history-time",children:s.scannedAt.toLocaleTimeString()})]},m))]}),t&&e.jsx("span",{className:"nice-helper-text",children:t}),i&&typeof i=="string"&&e.jsx("span",{className:"nice-error-text",children:i})]})});An.displayName="NiceScannerControl";const Rn=a.forwardRef(({label:n,helperText:t,error:i,required:r,disabled:d,readOnly:h,size:y="md",id:N,className:$,style:S,accessMode:H,value:I="",onChange:b,onComplete:C,length:P=4,masked:ee=!0,showKeypad:V=!1,autoSubmit:Y=!0,shake:p=!1,placeholderChar:T="·"},w)=>{const E=F.Cl(H,N),G=E==="hidden";E==="disabled"&&(d=!0),E==="readOnly"&&(h=!0);const{t:g}=F.ue(),k=F.nl(N),v=a.useRef([]),[A,D]=a.useState(!1);a.useEffect(()=>{if(p){D(!0);const _=setTimeout(()=>D(!1),500);return()=>clearTimeout(_)}},[p]);const W=I.split("").slice(0,P);for(;W.length<P;)W.push("");const x=a.useCallback((_,j)=>{var m;const o=[...W];o[_]=j;const s=o.join("");b==null||b(s),j&&_<P-1&&((m=v.current[_+1])==null||m.focus()),Y&&s.length===P&&s.indexOf("")===-1&&(C==null||C(s))},[W,P,b,C,Y]),c=a.useCallback((_,j)=>{var o,s,m;_.key==="Backspace"&&!W[j]&&j>0&&((o=v.current[j-1])==null||o.focus(),x(j-1,"")),_.key==="ArrowLeft"&&j>0&&((s=v.current[j-1])==null||s.focus()),_.key==="ArrowRight"&&j<P-1&&((m=v.current[j+1])==null||m.focus())},[W,P,x]),z=a.useCallback(_=>{var j,o,s;if(_==="clear"){b==null||b(""),(j=v.current[0])==null||j.focus();return}if(_==="backspace"){const m=I.slice(0,-1);b==null||b(m);const l=Math.max(0,m.length-1);(o=v.current[l])==null||o.focus();return}if(I.length<P){const m=I+_;b==null||b(m),m.length<P&&((s=v.current[m.length])==null||s.focus()),Y&&m.length===P&&(C==null||C(m))}},[I,P,b,C,Y]);return G?null:e.jsxs("div",{ref:w,id:k,className:`nice-pin nice-size-${y}${A?" nice-pin--shake":""}${$?` ${$}`:""}${i?" nice-error":""}${d?" nice-disabled":""}`,style:S,children:[n&&e.jsxs("label",{className:"nice-pin__label",children:[n,r&&e.jsx("span",{className:"nice-required",children:"*"})]}),e.jsx("div",{className:"nice-pin__boxes",children:W.map((_,j)=>e.jsx("input",{ref:o=>{v.current[j]=o},className:"nice-pin__box",type:ee?"password":"text",inputMode:"numeric",maxLength:1,value:_,onChange:o=>{const s=o.target.value.replace(/\D/g,"");s.length<=1&&x(j,s)},onKeyDown:o=>c(o,j),disabled:d,readOnly:h,placeholder:T,"aria-label":`${g("digit","Digit")} ${j+1}`},j))}),V&&!h&&e.jsx("div",{className:"nice-pin__keypad",children:["1","2","3","4","5","6","7","8","9","clear","0","backspace"].map(_=>e.jsx("button",{type:"button",className:`nice-pin__key${_==="clear"||_==="backspace"?" nice-pin__key--action":""}`,onClick:()=>z(_),disabled:d,children:_==="clear"?"C":_==="backspace"?"⌫":_},_))}),t&&e.jsx("span",{className:"nice-helper-text",children:t}),i&&typeof i=="string"&&e.jsx("span",{className:"nice-error-text",children:i})]})});Rn.displayName="NicePinCodeInput";exports.$=Vt;exports.A=Rn;exports.B=Gn;exports.C=An;exports.E=vn;exports.F=Sn;exports.G=un;exports.H=Mn;exports.I=$n;exports.L=tn;exports.M=mn;exports.O=gn;exports.P=ut;exports.Q=ct;exports.R=en;exports.S=at;exports.T=Jt;exports.U=xt;exports.V=Fe;exports.W=it;exports.X=Le;exports.Y=qt;exports.Z=Gt;exports._=Yt;exports.a=En;exports.a0=_t;exports.a1=dt;exports.a2=ra;exports.a3=ha;exports.b=_n;exports.c=an;exports.d=Ct;exports.f=Kt;exports.g=Nn;exports.i=kn;exports.j=Zn;exports.k=yn;exports.l=Qn;exports.n=nn;exports.o=jt;exports.q=fn;exports.r=xn;exports.s=rn;exports.t=Cn;exports.u=sn;exports.v=Xn;exports.w=bn;exports.x=on;exports.y=wn;exports.z=pn;
|