@nice2dev/ui 1.0.29 → 1.0.31
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/CHANGELOG.md +512 -0
- package/README.md +30 -31
- package/dist/NiceBackupStatusBadge.doc-Bx2bFmBQ.cjs +1 -0
- package/dist/NiceBackupStatusBadge.doc-CdDxIQ-M.js +25 -0
- package/dist/NiceCalendarScheduler.doc-BEtQkZjV.cjs +9 -0
- package/dist/NiceCalendarScheduler.doc-D__LRgOx.js +33 -0
- package/dist/NiceConfirmDialog-B57cl_F7.cjs +1 -0
- package/dist/NiceConfirmDialog-BiTJVR4-.js +81 -0
- package/dist/NiceConfirmDialog-Bjw_rN4o.cjs +1 -0
- package/dist/NiceConfirmDialog-N9fBTLYm.js +81 -0
- package/dist/NiceDrawingCanvas.doc-Dv5vB4gY.js +32 -0
- package/dist/NiceDrawingCanvas.doc-Ww9zz17x.cjs +8 -0
- package/dist/NiceErrorBoundary-1H751jK7.cjs +1 -0
- package/dist/NiceErrorBoundary-B-txoU3Y.js +709 -0
- package/dist/NiceErrorBoundary-BD-uqk_q.js +709 -0
- package/dist/NiceErrorBoundary-CIPXaYik.cjs +1 -0
- package/dist/NiceFileManagerViews.doc-CKlnm6cX.cjs +1 -0
- package/dist/NiceFileManagerViews.doc-Cg21DArG.js +25 -0
- package/dist/NiceForm-BNZB31Pg.js +4499 -0
- package/dist/NiceForm-CPyAXxBO.cjs +1 -0
- package/dist/NiceForm-DGUTmaZT.js +5014 -0
- package/dist/NiceForm-DmU-gmyv.cjs +382 -0
- package/dist/NiceMegaMenu.doc-7UyOCd3l.cjs +7 -0
- package/dist/NiceMegaMenu.doc-zeIyVa65.js +31 -0
- package/dist/NiceModal-BClAtR5T.js +95 -0
- package/dist/NiceModal-Bj53SKLI.js +95 -0
- package/dist/NiceModal-DC0UlQhc.cjs +1 -0
- package/dist/NiceModal-iKwtagFB.cjs +1 -0
- package/dist/NiceModuleLifecyclePanel-BBOg9g0b.cjs +1 -0
- package/dist/NiceModuleLifecyclePanel-BO8Hw_W9.js +7619 -0
- package/dist/NiceModuleLifecyclePanel-Ch7HRRoy.cjs +1 -0
- package/dist/NiceModuleLifecyclePanel-DtuXRiLR.js +6991 -0
- package/dist/NiceModuleLifecyclePanel.css +1 -1
- package/dist/NicePagination-BVo-4KAD.js +172 -0
- package/dist/NicePagination-Bjxy9aEc.js +172 -0
- package/dist/NicePagination-CaohvQsY.cjs +1 -0
- package/dist/NicePagination-CfFfNwrg.cjs +1 -0
- package/dist/NicePinCodeInput-DsyLuc0b.cjs +696 -0
- package/dist/NicePinCodeInput-nuRCN-9R.js +13223 -0
- package/dist/NiceSavedQueryPanel-BBFV4qiF.js +6969 -0
- package/dist/NiceSavedQueryPanel-CH5c3rUG.js +6988 -0
- package/dist/NiceSavedQueryPanel-CsiVNkCT.cjs +596 -0
- package/dist/NiceSavedQueryPanel-aQrEmmcC.cjs +596 -0
- package/dist/NiceScannerControl-Cd5KXJA9.js +12769 -0
- package/dist/NiceScannerControl-DZsERSw_.cjs +698 -0
- package/dist/NiceScannerControl.css +1 -0
- package/dist/NiceWindow-BoDzlGk-.js +1621 -0
- package/dist/NiceWindow-Cm9E6EAi.cjs +1 -0
- package/dist/NiceWindow-DgONWxBm.cjs +1 -0
- package/dist/NiceWindow-FMrVS7zo.js +1603 -0
- package/dist/charts-B90sSFeJ.cjs +761 -0
- package/dist/charts-Bs0aDM0X.js +4671 -0
- package/dist/charts-DaLf19vS.js +4671 -0
- package/dist/charts-DjjKkw0q.cjs +761 -0
- package/dist/charts.cjs +1 -1
- package/dist/charts.mjs +1 -1
- package/dist/core-BUTtIHg0.js +27766 -0
- package/dist/core-BUsZ7_vI.js +27914 -0
- package/dist/core-CESNSRyS.cjs +122 -0
- package/dist/core-CLfcCDKc.cjs +122 -0
- package/dist/data-branching-ByQdcjKO.cjs +1 -0
- package/dist/data-branching-D7l_kILW.cjs +1 -0
- package/dist/data-branching-lJ07lDN-.js +6255 -0
- package/dist/data-branching-psTzlcrT.js +6255 -0
- package/dist/data-branching.cjs +1 -1
- package/dist/data-branching.mjs +1 -1
- package/dist/data.cjs +1 -1
- package/dist/data.d.ts +41 -37
- package/dist/data.mjs +18 -19
- package/dist/devops-Bi8MXtko.js +8165 -0
- package/dist/devops-D7bQ3rE4.cjs +17 -0
- package/dist/devops-On_1wRf9.cjs +17 -0
- package/dist/devops-jCmpD6O-.js +8165 -0
- package/dist/devops.cjs +1 -1
- package/dist/devops.mjs +3 -3
- package/dist/editors.cjs +1 -1
- package/dist/editors.d.ts +219 -431
- package/dist/editors.mjs +48 -56
- package/dist/feedback.cjs +1 -1
- package/dist/feedback.mjs +3 -3
- package/dist/index-BDH1yDSg.js +69235 -0
- package/dist/index-BpixglWg.js +69337 -0
- package/dist/index-C9njkNOD.cjs +5470 -0
- package/dist/index-DLR-aWZR.cjs +5506 -0
- package/dist/index.cjs +1 -1
- package/dist/index.css +1 -1
- package/dist/index.d.ts +798 -1059
- package/dist/index.mjs +741 -756
- package/dist/lazy.cjs +1 -1
- package/dist/lazy.mjs +24 -24
- package/dist/navigation.cjs +1 -1
- package/dist/navigation.d.ts +25 -213
- package/dist/navigation.mjs +143 -151
- package/dist/no-code-8lO7o6xi.js +7425 -0
- package/dist/no-code-BHo5WrXr.js +7425 -0
- package/dist/no-code-DyA_1_Th.cjs +332 -0
- package/dist/no-code-K8tOLNew.cjs +332 -0
- package/dist/no-code.cjs +1 -1
- package/dist/no-code.mjs +1 -1
- package/dist/overlays.cjs +1 -1
- package/dist/overlays.d.ts +12 -0
- package/dist/overlays.mjs +82 -82
- package/dist/pickerCommons-BEc3pZ_s.js +2044 -0
- package/dist/pickerCommons-CORo9j2a.js +2119 -0
- package/dist/pickerCommons-CrITwM88.cjs +1 -0
- package/dist/pickerCommons-D3WShRrR.cjs +1 -0
- package/dist/style.css +5 -5
- package/package.json +3 -3
|
@@ -0,0 +1,698 @@
|
|
|
1
|
+
"use strict";const e=require("react/jsx-runtime"),v=require("./core-CLfcCDKc.cjs"),n=require("react"),pt=require("react-dom"),ve=require("./pickerCommons-D3WShRrR.cjs"),Pt=require("./NiceForm-CPyAXxBO.cjs"),ln=require("./devops-On_1wRf9.cjs");function ei(t,i=30){switch(t){case"monochromatic":return[0];case"complementary":return[0,180];case"split-complementary":return[0,180-i,180+i];case"analogous":return[0,-i,i];case"triadic":return[0,120,240];case"tetradic":return[0,60,180,240];case"square":return[0,90,180,270];case"shade-chain":return[];case"custom":return[0,60,200];default:return[0]}}function Ht(t,i={}){const o=i.size??16,a="currentColor",l="currentColor";if(i.rectangle||t==="shade-chain"||t==="monochromatic"){const F=Math.max(3,Math.min(7,i.count??5)),$=o*.1,T=o-$*2,G=Math.max(1.2,o/14),ie=o/2,V=Array.from({length:F},(ee,M)=>{const f=$+T*M/(F-1),O=.25+.75*M/(F-1);return e.jsx("circle",{cx:f,cy:ie,r:G,fill:l,opacity:O},M)});return e.jsxs("svg",{width:o,height:o,viewBox:`0 0 ${o} ${o}`,"aria-hidden":!0,children:[e.jsx("rect",{x:1,y:o/2-o/6,width:o-2,height:o/3,rx:o/6,fill:"none",stroke:a,strokeOpacity:.25}),V]})}const _=i.angles??ei(t),g=o/2,A=o/2,E=o/2-2,Y=Math.max(1.4,o/9);return e.jsxs("svg",{width:o,height:o,viewBox:`0 0 ${o} ${o}`,"aria-hidden":!0,children:[e.jsx("circle",{cx:g,cy:A,r:E,fill:"none",stroke:a,strokeOpacity:.25}),_.map((F,$)=>{const T=(F-90)*Math.PI/180,G=g+E*Math.cos(T),ie=A+E*Math.sin(T);return e.jsx("circle",{cx:G,cy:ie,r:Y,fill:l},$)})]})}function Ot(t,i,o){return Math.max(i,Math.min(o,t))}function dn({h:t,s:i,v:o}){t=(t%360+360)%360;const a=o*i,l=a*(1-Math.abs(t/60%2-1)),u=o-a;let _=0,g=0,A=0;return t<60?(_=a,g=l):t<120?(_=l,g=a):t<180?(g=a,A=l):t<240?(g=l,A=a):t<300?(_=l,A=a):(_=a,A=l),{r:Math.round((_+u)*255),g:Math.round((g+u)*255),b:Math.round((A+u)*255)}}function It({r:t,g:i,b:o}){t/=255,i/=255,o/=255;const a=Math.max(t,i,o),l=Math.min(t,i,o),u=a-l;let _=0;return u!==0&&(a===t?_=(i-o)/u%6:a===i?_=(o-t)/u+2:_=(t-i)/u+4,_=(_*60+360)%360),{h:_,s:a===0?0:u/a,v:a}}function mn({r:t,g:i,b:o}){t/=255,i/=255,o/=255;const a=Math.max(t,i,o),l=Math.min(t,i,o),u=(a+l)/2;if(a===l)return{h:0,s:0,l:u};const _=a-l,g=u>.5?_/(2-a-l):_/(a+l);let A=0;return a===t?A=((i-o)/_+(i<o?6:0))/6:a===i?A=((o-t)/_+2)/6:A=((t-i)/_+4)/6,{h:A*360,s:g,l:u}}function mt(t){const i=t.replace("#",""),o=i.length===3?i[0]+i[0]+i[1]+i[1]+i[2]+i[2]:i,a=parseInt(o,16);return{r:a>>16&255,g:a>>8&255,b:a&255}}function un({r:t,g:i,b:o}){return"#"+[t,i,o].map(a=>a.toString(16).padStart(2,"0")).join("")}function ze(t){return un(dn(t))}function Ye(t){return It(mt(t))}function pn(t,i){const o=[];for(let a=0;a<i;a++){const l=i<=1?.5:a/(i-1),u=Ot(t.s*(.3+l*.7),0,1),_=Ot(t.v*(1.2-l*.7),0,1);o.push(ze({h:t.h,s:u,v:_}))}return o}function At(t,i){if(t==="custom"||t==="shade-chain")return[0];const o=i??30;switch(t){case"monochromatic":return[0];case"complementary":return[0,180];case"split-complementary":return[0,180-o,180+o];case"analogous":return[0,-o,o];case"triadic":return[0,120,240];case"tetradic":return[0,60,180,240];case"square":return[0,90,180,270]}return[0]}function dt(t,i,o){return At(i,o).map(a=>((t+a)%360+360)%360)}function Bt(t,i,o=.12){const a=Math.max(2,i),l=(a-1)/2,u=[];for(let _=0;_<a;_++){const g=(_-l)*o,A=Math.max(.05,Math.min(.98,t.v+g)),E=Math.max(.05,Math.min(1,t.s-Math.abs(g)*.25));u.push(ze({h:t.h,s:E,v:A}))}return u}function Ft({r:t,g:i,b:o}){const[a,l,u]=[t,i,o].map(_=>{const g=_/255;return g<=.03928?g/12.92:Math.pow((g+.055)/1.055,2.4)});return .2126*a+.7152*l+.0722*u}function yt(t,i){const o=Ft(mt(t)),a=Ft(mt(i)),l=Math.max(o,a),u=Math.min(o,a);return(l+.05)/(u+.05)}function xt(t){return t>=7?"AAA":t>=4.5?"AA":t>=3?"AA-lg":"Fail"}const hn={"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 bt(t,i){const o=hn[i];return t.map(a=>{const l=(o.sRange[0]+o.sRange[1])/2,u=(o.vRange[0]+o.vRange[1])/2;return ze({h:a,s:l,v:u})})}function ti(){return Math.floor(Math.random()*360)}function gn(t,i,o){const a=ti(),l=dt(a,t,o),u=[];for(let _=0;_<i;_++){const g=l[_%l.length],A=.55+Math.random()*.4,E=.5+Math.random()*.45;u.push(ze({h:g+(Math.random()-.5)*8,s:A,v:E}))}return u}const ni=({hues:t,baseHue:i,onBaseHueChange:o,mode:a,distance:l,disabled:u})=>{const F=n.useRef(null),$=n.useCallback((M,f)=>{const O=F.current;if(!O)return;const y=O.getBoundingClientRect(),I=(M-y.left)/y.width*240-120,B=(f-y.top)/y.height*240-120,r=(Math.atan2(B,I)*180/Math.PI+360)%360;o(Math.round(r))},[120,120,240,o]),T=n.useCallback(M=>{if(u)return;M.preventDefault(),$(M.clientX,M.clientY);const f=y=>$(y.clientX,y.clientY),O=()=>{document.removeEventListener("pointermove",f),document.removeEventListener("pointerup",O)};document.addEventListener("pointermove",f),document.addEventListener("pointerup",O)},[u,$]),G=[];for(let M=0;M<360;M+=2){const f=(M-1)*Math.PI/180,O=(M+1)*Math.PI/180,y=ze({h:M,s:1,v:1});G.push(e.jsx("path",{d:`M${120+55*Math.cos(f)},${120+55*Math.sin(f)} L${120+110*Math.cos(f)},${120+110*Math.sin(f)} A110,110 0 0,1 ${120+110*Math.cos(O)},${120+110*Math.sin(O)} L${120+55*Math.cos(O)},${120+55*Math.sin(O)} A55,55 0 0,0 ${120+55*Math.cos(f)},${120+55*Math.sin(f)} Z`,fill:y},M))}const ie=`wheel-center-${a}`,V=t.map((M,f)=>{const y=M*Math.PI/180;return e.jsx("circle",{cx:120+82.5*Math.cos(y),cy:120+82.5*Math.sin(y),r:f===0?8:6,fill:ze({h:M,s:.85,v:.9}),stroke:f===0?"var(--bg-primary, #fff)":"var(--border-color, #ccc)",strokeWidth:f===0?3:2},f)});let ee=null;if(a==="analogous"||a==="split-complementary"){const O=At(a,l).slice(1).map((y,I)=>{const B=(i+y)*Math.PI/180;return e.jsx("line",{x1:120,y1:120,x2:120+82.5*Math.cos(B),y2:120+82.5*Math.sin(B),stroke:"var(--nice-overlay-light-30, rgba(255, 255, 255, 0.3))",strokeWidth:1,strokeDasharray:"3,3"},`dline-${I}`)});ee=e.jsx(e.Fragment,{children:O})}return e.jsxs("svg",{ref:F,className:"nice-palette__wheel",viewBox:"0 0 240 240",width:240,height:240,onPointerDown:T,style:{cursor:u?"default":"crosshair",touchAction:"none"},children:[e.jsx("defs",{children:e.jsxs("radialGradient",{id:ie,children:[e.jsx("stop",{offset:"0%",stopColor:"var(--nice-bg, #fff)"}),e.jsx("stop",{offset:"100%",stopColor:"transparent"})]})}),G,e.jsx("circle",{cx:120,cy:120,r:53,fill:ze({h:i,s:.6,v:.85})}),e.jsx("circle",{cx:120,cy:120,r:53,fill:`url(#${ie})`,opacity:.4}),ee,V]})},ii=({colors:t})=>{if(t.length<2)return null;const i=[];for(let o=0;o<t.length;o++){const a=yt(t[o],"var(--bg-primary, #ffffff)"),l=yt(t[o],"var(--text-primary, #000000)");i.push({a:t[o],b:"var(--bg-primary, #ffffff)",ratio:a,level:xt(a)}),i.push({a:t[o],b:"var(--text-primary, #000000)",ratio:l,level:xt(l)});for(let u=o+1;u<t.length;u++){const _=yt(t[o],t[u]);i.push({a:t[o],b:t[u],ratio:_,level:xt(_)})}}return e.jsxs("div",{className:"nice-palette__contrast",children:[e.jsx("div",{className:"nice-palette__section-title",children:"Contrast Analysis (WCAG 2.1)"}),e.jsx("div",{className:"nice-palette__contrast-grid",children:i.map((o,a)=>e.jsxs("div",{className:"nice-palette__contrast-pair",children:[e.jsxs("div",{className:"nice-palette__contrast-swatches",children:[e.jsx("span",{className:"nice-palette__contrast-dot",style:{background:o.a}}),e.jsx("span",{className:"nice-palette__contrast-vs",children:"vs"}),e.jsx("span",{className:"nice-palette__contrast-dot",style:{background:o.b}})]}),e.jsxs("span",{className:"nice-palette__contrast-ratio",children:[o.ratio.toFixed(1),":1"]}),e.jsx("span",{className:`nice-palette__contrast-level nice-palette__contrast-level--${o.level.toLowerCase().replace("-","")}`,children:o.level})]},a))})]})},oi=({hex:t})=>{const i=mt(t),o=mn(i),a=It(i);return e.jsxs("div",{className:"nice-palette__color-info",children:[e.jsxs("div",{children:[e.jsx("strong",{children:"HEX"})," ",t.toUpperCase()]}),e.jsxs("div",{children:[e.jsx("strong",{children:"RGB"})," ",i.r,", ",i.g,", ",i.b]}),e.jsxs("div",{children:[e.jsx("strong",{children:"HSL"})," ",Math.round(o.h),"°, ",Math.round(o.s*100),"%,"," ",Math.round(o.l*100),"%"]}),e.jsxs("div",{children:[e.jsx("strong",{children:"HSV"})," ",Math.round(a.h),"°, ",Math.round(a.s*100),"%,"," ",Math.round(a.v*100),"%"]})]})},ai={monochromatic:"Monochromatic",complementary:"Complementary","split-complementary":"Split-Complementary",analogous:"Analogous",triadic:"Triadic",tetradic:"Tetradic (Rectangle)",square:"Square","shade-chain":"Shade chain",custom:"Custom"},si={"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"},ri=["monochromatic","shade-chain","complementary","split-complementary","analogous","triadic","tetradic","square","custom"],fn=["lightest-pastel","bright-pastel","shiny","pastel","full","dark","deep","muted","earth"],yn="nice-palette-custom-schemes";function ci(){if(typeof window>"u")return[];try{const t=window.localStorage.getItem(yn);if(!t)return[];const i=JSON.parse(t);if(Array.isArray(i))return i}catch{}return[]}function li(t){if(!(typeof window>"u"))try{window.localStorage.setItem(yn,JSON.stringify(t))}catch{}}const xn=n.forwardRef(({id:t,className:i,style:o,accessMode:a,value:l,onChange:u,minColors:_=1,maxColors:g=8,harmonyMode:A,onHarmonyModeChange:E,distance:Y,onDistanceChange:F,preset:$,onPresetChange:T,showWheel:G=!0,showContrast:ie=!0,showInfo:V=!0,showPresets:ee=!0,presets:M=[],showVariations:f=!0,showRandom:O=!0,variationCount:y=5,label:I,labelPlacement:B="top",disabled:r,readOnly:b,loading:S,error:U,colorCount:k,shadeStep:j,onShadeStepChange:c,customSchemes:z,onCustomSchemesChange:R,persistCustomSchemes:p=!0},d)=>{const m=v.Dc(a,t),x=m==="hidden";m==="disabled"&&(r=!0);const D=b||m==="readOnly",N=v.bc(t),{t:H}=v.Gt(),[L,Q]=n.useState("analogous"),[w,K]=n.useState(30),[Z,pe]=n.useState(""),[q,ne]=n.useState(0),[re,ue]=n.useState(.12),[je,J]=n.useState(null),[ge,ye]=n.useState(()=>z??(p?ci():[])),[se,me]=n.useState(null),[fe,W]=n.useState(!1),[h,P]=n.useState(null),[ce,oe]=n.useState(""),de=n.useContext(v.Er)?.portalTarget??(typeof document<"u"?document.body:null),ae=n.useRef(null),be=n.useRef(null),he=A??L,Ce=Y??w,Me=$??Z,$e=j??re,Te=z??ge;n.useEffect(()=>{!z&&p&&li(ge)},[ge,z,p]);const Ue=n.useCallback(te=>{ye(te),R?.(te)},[R]),Qe=n.useCallback(te=>{Q(te),E?.(te)},[E]),Je=n.useCallback(te=>{K(te),F?.(te)},[F]),We=n.useCallback(te=>{pe(te),te&&T?.(te)},[T]),Ze=n.useMemo(()=>["var(--color-primary, #3b82f6)","var(--color-error, #ef4444)","var(--color-success, #22c55e)"],[]),Se=l&&l.length>0?l:Ze,Fe=Se[0],we=n.useMemo(()=>Ye(Fe),[Fe]),De=n.useMemo(()=>dt(we.h,he,Ce),[we.h,he,Ce]),Pe=n.useCallback((te,xe,Ne,Re)=>{const He=k??je??void 0,Ge=He!==void 0?Math.max(_,Math.min(g,He)):void 0;if(xe==="shade-chain"){const Oe=Ge??Math.max(_,5),Xe=Bt({h:te,s:we.s||.7,v:we.v||.6},Oe,$e);u?.(Xe);return}let tt;const qe=xe==="custom"&&se?Te.find(Oe=>Oe.id===se):null;qe&&qe.angles.length>0?tt=qe.angles.map(Oe=>((te+Oe)%360+360)%360):tt=dt(te,xe,Ne);let Ie;if(Re&&hn[Re]?Ie=bt(tt,Re):Ie=tt.map(Oe=>ze({h:Oe,s:we.s||.7,v:we.v||.85})),qe?.lightnessOffsets?.length&&(Ie=Ie.map((Oe,Xe)=>{const Lt=qe.lightnessOffsets?.[Xe];if(Lt==null)return Oe;const wt=Ye(Oe);return ze({h:wt.h,s:wt.s,v:Math.max(.05,Math.min(.98,wt.v+Lt))})})),Ge!==void 0){for(;Ie.length<Ge;){const Oe=Ie[Ie.length-1]||"#888888",Xe=Ye(Oe);Ie.push(ze({h:(Xe.h+18)%360,s:Xe.s,v:Xe.v}))}Ie=Ie.slice(0,Ge)}else{for(;Ie.length<_;)Ie.push(Ie[Ie.length-1]||"var(--nice-text-secondary, #888888)");Ie.length>g&&(Ie=Ie.slice(0,g))}u?.(Ie)},[we.s,we.v,_,g,u,k,je,$e,se,Te]),s=n.useCallback(te=>{if(!r){if(he==="custom"){const xe=ze({h:te,s:we.s||.7,v:we.v||.85}),Ne=[...Se];Ne[q]=xe,u?.(Ne);return}Pe(te,he,Ce,Me)}},[r,he,Ce,Me,Pe,we.s,we.v,Se,q,u]),C=n.useCallback(te=>{r||(Qe(te),te!=="custom"&&Pe(we.h,te,Ce,Me))},[r,we.h,Ce,Me,Qe,Pe]),X=n.useCallback(te=>{r||(Je(te),Pe(we.h,he,te,Me))},[r,we.h,he,Me,Je,Pe]),le=n.useCallback(te=>{if(r)return;We(te);const xe=dt(we.h,he,Ce),Ne=bt(xe,te);u?.(Ne.slice(0,g))},[r,we.h,he,Ce,g,We,u]),_e=n.useCallback((te,xe)=>{if(r)return;const Ne=[...Se];Ne[te]=xe,u?.(Ne)},[r,Se,u]),Ae=n.useCallback(()=>{if(r||Se.length>=g)return;const te=Ye(Se[Se.length-1]),xe=ze({h:(te.h+30)%360,s:te.s,v:te.v});u?.([...Se,xe])},[r,Se,g,u]),Le=n.useCallback(te=>{if(r||Se.length<=_)return;const xe=Se.filter((Ne,Re)=>Re!==te);u?.(xe),q>=xe.length&&ne(Math.max(0,xe.length-1))},[r,Se,_,u,q]),et=n.useCallback(()=>{if(r)return;const te=Math.max(_,Math.min(g,At(he).length)),xe=gn(he,te,Ce);u?.(xe)},[r,_,g,he,Ce,u]),Be=n.useMemo(()=>{if(!f)return[];const te=Se[q]||Se[0];return pn(Ye(te),y)},[f,Se,q,y]),Ke=Se[q]||Se[0],ot=n.useMemo(()=>{const te=Ye(Ke);return ze({h:(te.h+180)%360,s:te.s,v:te.v})},[Ke]);if(n.useLayoutEffect(()=>{if(!fe||!ae.current)return;oe(ve.scopeThemeClass(ae.current));const te=()=>{const xe=ae.current?.getBoundingClientRect();if(!xe)return;const Ne=600;let Re=xe.left;Re+Ne>window.innerWidth-8&&(Re=Math.max(8,window.innerWidth-Ne-8));let He=xe.bottom+6;He>window.innerHeight*.5&&(He=Math.max(8,window.innerHeight-Math.min(window.innerHeight-16,540)-8)),P({left:Re,top:He})};return te(),window.addEventListener("scroll",te,!0),window.addEventListener("resize",te),()=>{window.removeEventListener("scroll",te,!0),window.removeEventListener("resize",te)}},[fe]),n.useEffect(()=>{if(!fe)return;const te=Ne=>{const Re=Ne.target;ae.current?.contains(Re)||be.current?.contains(Re)||(Re instanceof Element?Re:Re?.parentElement??null)?.closest('.nice-select__dropdown, [role="listbox"], [role="option"]')||W(!1)},xe=Ne=>{Ne.key==="Escape"&&W(!1)};return document.addEventListener("mousedown",te),document.addEventListener("keydown",xe),()=>{document.removeEventListener("mousedown",te),document.removeEventListener("keydown",xe)}},[fe]),x)return null;const ht=M.length>0?M:fn,at=e.jsxs("div",{className:"nice-palette__tab",children:[e.jsxs("div",{className:"nice-palette__modes",style:{display:"flex",gap:8,alignItems:"center",flexWrap:"wrap"},children:[e.jsx(ve.NiceSelect,{label:H("colorPalette.harmony","Harmony"),labelPlacement:"left",size:"sm",disabled:r,value:he==="custom"&&se?`custom:${se}`:he,onChange:te=>{const xe=Array.isArray(te)?te[0]:te;if(typeof xe=="string")if(xe.startsWith("custom:")){const Ne=xe.slice(7);me(Ne),C("custom")}else me(null),C(xe)},options:[...ri.map(te=>({value:te,label:ai[te]})),...Te.map(te=>({value:`custom:${te.id}`,label:te.name}))],renderOption:(te,xe)=>{const Ne=String(te.value),Re=Ne.startsWith("custom:"),He=Re?Te.find(qe=>qe.id===Ne.slice(7)):null,Ge=He?He.angles:void 0,tt=Re?"custom":Ne;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:Ht(tt,{angles:Ge,size:16,count:k})}),e.jsx("span",{style:{fontWeight:xe?600:400},children:te.label})]})}}),he==="shade-chain"&&e.jsx(ve.NiceNumberInput,{label:H("colorPalette.step","Step"),labelPlacement:"left",size:"sm",min:.02,max:.5,step:.02,precision:2,value:$e,onChange:te=>{const xe=typeof te=="number"?te:Number(te);Number.isNaN(xe)||(ue(xe),c?.(xe),Pe(we.h,he,Ce,Me))},showStepper:!0,disabled:r}),e.jsx(ve.NiceNumberInput,{label:H("colorPalette.colors","Colors"),labelPlacement:"left",size:"sm",min:Math.max(2,_),max:Math.min(12,g),step:1,precision:0,value:k??je??Se.length,onChange:te=>{const xe=typeof te=="number"?te:Number(te);if(!Number.isFinite(xe))return;const Ne=Math.max(Math.max(2,_),Math.min(Math.min(12,g),Math.round(xe)));J(Ne),he==="shade-chain"?u?.(Bt({h:we.h,s:we.s||.7,v:we.v||.6},Ne,$e)):setTimeout(()=>Pe(we.h,he,Ce,Me),0)},showStepper:!0,disabled:r})]}),e.jsx("div",{className:"nice-palette__main",children:e.jsxs("div",{className:"nice-palette__strips",children:[e.jsxs("div",{className:"nice-palette__swatches",children:[Se.map((te,xe)=>e.jsxs("div",{className:`nice-palette__swatch-wrapper ${q===xe?"nice-palette__swatch-wrapper--selected":""}`,onClick:()=>ne(xe),children:[e.jsx("span",{className:"nice-palette__swatch",style:{background:te}}),e.jsx("input",{type:"text",className:"nice-palette__hex-input",value:te.toUpperCase(),maxLength:7,disabled:r,onClick:Ne=>Ne.stopPropagation(),onChange:Ne=>_e(xe,Ne.target.value)}),Se.length>_&&e.jsx("button",{type:"button",className:"nice-palette__swatch-remove",onClick:Ne=>{Ne.stopPropagation(),Le(xe)},disabled:r,"aria-label":"Remove color",children:e.jsx(v.oa,{name:"close",size:14})})]},xe)),Se.length<g&&e.jsxs("button",{type:"button",className:"nice-palette__add-btn",onClick:Ae,disabled:r,title:"Add color",children:[e.jsx(v.oa,{name:"plus",size:14}),e.jsx("span",{children:"Add"})]})]}),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:ot},title:ot.toUpperCase()}),e.jsx("span",{className:"nice-palette__hex-label",children:ot.toUpperCase()})]}),O&&e.jsxs("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm nice-palette__random-btn",onClick:et,disabled:r,title:"Random palette","aria-label":"Random palette",children:[e.jsx(v.oa,{name:"shuffle",size:14})," Random Palette"]})]})})]}),kt=e.jsx("div",{className:"nice-palette__tab",children:Be.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:Be.map((te,xe)=>e.jsx("div",{className:"nice-palette__variation-chip",style:{background:te},title:te.toUpperCase(),onClick:()=>{r||_e(q,te)},role:"button",tabIndex:0},xe))})]}):e.jsx("div",{className:"nice-palette__empty",children:"No variations available."})}),Xn=e.jsx("div",{className:"nice-palette__tab",children:e.jsx("div",{className:"nice-palette__preset-grid",children:ht.map(te=>{const xe=bt(De,te);return e.jsxs("button",{type:"button",className:`nice-palette__preset-card ${Me===te?"nice-palette__preset-card--active":""}`,onClick:()=>le(te),disabled:r,children:[e.jsx("div",{className:"nice-palette__preset-strip",children:xe.map((Ne,Re)=>e.jsx("span",{className:"nice-palette__preset-dot",style:{background:Ne}},Re))}),e.jsx("span",{className:"nice-palette__preset-label",children:si[te]})]},te)})})}),Vn=e.jsxs("div",{className:"nice-palette__tab",children:[V&&e.jsxs("div",{className:"nice-palette__info-panel",children:[e.jsx("div",{className:"nice-palette__section-title",children:"Selected Color Info"}),e.jsx(oi,{hex:Ke})]}),ie&&e.jsxs("div",{className:"nice-palette__info-panel",children:[e.jsx("div",{className:"nice-palette__section-title",children:"Contrast Analysis (WCAG 2.1)"}),e.jsx(ii,{colors:Se})]})]}),Qn=e.jsx("div",{className:"nice-palette__tab nice-palette__custom-schemes",children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[Te.length===0&&e.jsx("div",{style:{fontSize:12,color:"var(--text-muted)"},children:H("colorPalette.schemes.empty","Save the current palette as a reusable scheme.")}),Te.map(te=>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:Ht("custom",{angles:te.angles,size:16})}),e.jsx("span",{style:{flex:1},children:te.name}),e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--xs",onClick:()=>{me(te.id),C("custom")},disabled:r,children:"Use"}),e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--xs",onClick:()=>Ue(Te.filter(xe=>xe.id!==te.id)),disabled:r,"aria-label":`Delete ${te.name}`,children:e.jsx(v.oa,{name:"close",size:14})})]},te.id)),e.jsxs("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:[e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm",disabled:r,onClick:()=>{const te=typeof window<"u"?window.prompt("Scheme name?",`Scheme ${Te.length+1}`):null;if(!te)return;const xe=Ye(Se[0]).h,Ne=Se.map(He=>(Ye(He).h-xe+540)%360-180),Re={id:`cs-${Date.now()}`,name:te,angles:Ne};Ue([...Te,Re])},children:"+ Save current as scheme"}),e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm",disabled:r||Te.length===0,onClick:()=>{typeof navigator>"u"||navigator.clipboard?.writeText(JSON.stringify(Te,null,2))},children:H("colorPalette.exportJson","Export JSON")}),e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm",disabled:r,onClick:()=>{if(typeof window>"u")return;const te=window.prompt("Paste schemes JSON");if(te)try{const xe=JSON.parse(te);Array.isArray(xe)&&Ue(xe)}catch{}},children:H("colorPalette.importJson","Import JSON")})]})]})}),st=[{id:"colors",label:"Colors",content:at}];ee&&ht.length>0&&st.push({id:"presets",label:"Presets",content:Xn}),f&&st.push({id:"variations",label:"Variations",content:kt}),(V||ie)&&st.push({id:"info",label:"Info",content:Vn}),st.push({id:"schemes",label:"Schemes",content:Qn});const Jn=e.jsxs("div",{className:"nice-palette__popup-header",children:[G&&e.jsxs("div",{className:"nice-palette__wheel-container",children:[e.jsx(ni,{hues:De,baseHue:we.h,onBaseHueChange:s,mode:he,distance:Ce,disabled:r}),(he==="analogous"||he==="split-complementary")&&e.jsxs("div",{className:"nice-palette__distance",children:[e.jsxs("label",{children:["Distance: ",Ce,"°"]}),e.jsx("input",{type:"range",min:10,max:90,value:Ce,onChange:te=>X(Number(te.target.value)),disabled:r,className:"nice-palette__distance-slider"})]})]}),e.jsx("button",{type:"button",className:"nice-palette__confirm",onClick:()=>W(!1),"aria-label":H("controls.confirm","Confirm"),title:H("controls.confirm","Confirm"),children:e.jsx(v.oa,{name:"check",size:18})})]}),Zn=e.jsxs("div",{className:"nice-palette nice-palette--studio",children:[Jn,e.jsx(ve.NiceTabs,{tabs:st,variant:"enclosed",size:"sm"})]});return e.jsxs("div",{ref:d,id:N,className:`nice-field nice-palette-field ${r?"nice-palette--disabled":""} ${B==="left"?"nice-field--label-left":""} ${S?"nice-field--loading":""} ${U?"nice-field--error":""} ${i||""}`,style:o,children:[I&&e.jsx("label",{htmlFor:N,className:"nice-field__label",children:I}),e.jsxs("div",{className:"nice-field__control",children:[e.jsx("div",{ref:ae,className:"nice-palette__field-swatches",role:"button",tabIndex:r||D?-1:0,"aria-haspopup":"dialog","aria-expanded":fe,"aria-readonly":D||void 0,"aria-label":H("colorPalette.openStudio","Open palette studio"),onClick:()=>{!r&&!D&&W(te=>!te)},onKeyDown:te=>{!r&&!D&&(te.key==="Enter"||te.key===" ")&&(te.preventDefault(),W(xe=>!xe))},children:Se.map((te,xe)=>e.jsx("span",{className:"nice-palette__field-swatch",style:{background:te},title:te.toUpperCase(),onClick:Ne=>{Ne.stopPropagation(),!r&&!D&&(ne(xe),W(!0))}},xe))}),S&&e.jsx("span",{className:"nice-field__spinner",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})}),fe&&h&&de&&pt.createPortal(e.jsx("div",{ref:be,className:`nice-palette__popup${ce?` ${ce}`:""}`,"data-theme":ce==="nice-dark"?"dark":ce==="nice-light"?"light":void 0,role:"dialog","aria-label":H("colorPalette.studio","Palette studio"),style:{position:"fixed",left:h.left,top:h.top,zIndex:1e3},children:Zn}),de)]}),typeof U=="string"&&U&&e.jsx("div",{className:"nice-field__error",role:"alert",children:U})]})});xn.displayName="NiceColorPalette";function Et(){return{type:"linear",angle:90,stops:[{color:"var(--nice-primary, #3b82f6)",position:0},{color:"var(--nice-accent, #8b5cf6)",position:100}]}}function $t(t){const i=t.stops.slice().sort((a,l)=>a.position-l.position).map(a=>`${a.color} ${a.position}%`).join(", "),o=t.repeating?"repeating-":"";switch(t.type){case"linear":return`${o}linear-gradient(${t.angle}deg, ${i})`;case"radial":{const a=t.shape||"ellipse",l=t.size||"farthest-corner",u=t.positionX??50,_=t.positionY??50;return`${o}radial-gradient(${a} ${l} at ${u}% ${_}%, ${i})`}case"conic":{const a=t.angle??0,l=t.positionX??50,u=t.positionY??50;return`${o}conic-gradient(from ${a}deg at ${l}% ${u}%, ${i})`}}}function bn(t){const i=t.trim(),o=i.startsWith("repeating-");if(i.includes("linear-gradient")){const a=i.match(/linear-gradient\((.+)\)/)?.[1];if(!a)return null;const l=a.split(",").map(E=>E.trim());let u=90,_=0;const g=l[0].match(/^(\d+)deg$/);g&&(u=parseInt(g[1]),_=1);const A=Nt(l.slice(_));return{type:"linear",angle:u,repeating:o,stops:A}}if(i.includes("radial-gradient")){const a=i.match(/radial-gradient\((.+)\)/)?.[1];if(!a)return null;const l=a.split(",").map(_=>_.trim()),u=Nt(l.filter(_=>_.includes("#")||_.includes("rgb")));return{type:"radial",angle:0,repeating:o,stops:u.length>=2?u:Et().stops}}if(i.includes("conic-gradient")){const a=i.match(/conic-gradient\((.+)\)/)?.[1];if(!a)return null;const l=a.split(",").map(_=>_.trim()),u=Nt(l.filter(_=>_.includes("#")||_.includes("rgb")));return{type:"conic",angle:0,repeating:o,stops:u.length>=2?u:Et().stops}}return null}function Nt(t){return t.map((i,o,a)=>{const l=i.match(/^(#[0-9a-fA-F]{3,8}|rgba?\([^)]+\))\s*(\d+%?)?$/);if(l){const u=l[2]?parseFloat(l[2]):o/Math.max(1,a.length-1)*100;return{color:l[1],position:u}}return{color:i,position:o/Math.max(1,a.length-1)*100}})}function di(){return"#"+Math.floor(Math.random()*16777215).toString(16).padStart(6,"0")}function mi(t=2){const i=["linear","radial","conic"],o=i[Math.floor(Math.random()*i.length)],a=[];for(let l=0;l<t;l++)a.push({color:di(),position:Math.round(l/(t-1)*100)});return{type:o,angle:Math.floor(Math.random()*360),stops:a,shape:o==="radial"?Math.random()>.5?"circle":"ellipse":void 0,positionX:o!=="linear"?Math.round(Math.random()*100):void 0,positionY:o!=="linear"?Math.round(Math.random()*100):void 0}}const jn=[{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}}],vn=n.forwardRef(({id:t,className:i,style:o,accessMode:a,value:l,onChange:u,showCssOutput:_=!0,showPresets:g=!0,showEditor:A=!0,showRandom:E=!0,maxStops:Y=10,label:F,labelPlacement:$="top",disabled:T,readOnly:G,loading:ie,error:V,width:ee},M)=>{const f=v.Dc(a,t),O=f==="hidden";f==="disabled"&&(T=!0);const y=G||f==="readOnly",I=v.bc(t),{t:B}=v.Gt(),r=l??Et(),b=n.useMemo(()=>$t(r),[r]),[S,U]=n.useState(0),[k,j]=n.useState(""),c=n.useRef(null),[z,R]=n.useState(!1),[p,d]=n.useState(null),[m,x]=n.useState(""),N=n.useContext(v.Er)?.portalTarget??(typeof document<"u"?document.body:null),H=n.useRef(null),L=n.useRef(null),Q=typeof ee=="number"?ee:340;n.useLayoutEffect(()=>{if(!z||!H.current)return;x(ve.scopeThemeClass(H.current));const h=()=>{const P=H.current?.getBoundingClientRect();if(!P)return;let ce=P.left;ce+Q>window.innerWidth-8&&(ce=Math.max(8,window.innerWidth-Q-8));let oe=P.bottom+6;oe>window.innerHeight*.5&&(oe=Math.max(8,window.innerHeight-Math.min(window.innerHeight-16,520)-8)),d({left:ce,top:oe})};return h(),window.addEventListener("scroll",h,!0),window.addEventListener("resize",h),()=>{window.removeEventListener("scroll",h,!0),window.removeEventListener("resize",h)}},[z,Q]),n.useEffect(()=>{if(!z)return;const h=ce=>{const oe=ce.target;H.current?.contains(oe)||L.current?.contains(oe)||(oe instanceof Element?oe:oe?.parentElement??null)?.closest('.nice-select__dropdown, [role="listbox"], [role="option"]')||R(!1)},P=ce=>{ce.key==="Escape"&&R(!1)};return document.addEventListener("mousedown",h),document.addEventListener("keydown",P),()=>{document.removeEventListener("mousedown",h),document.removeEventListener("keydown",P)}},[z]);const w=n.useCallback(h=>{u?.(h)},[u]),K=n.useCallback(h=>{T||w({...r,type:h})},[T,r,w]),Z=n.useCallback(h=>{T||w({...r,angle:h})},[T,r,w]),pe=n.useCallback(h=>{T||w({...r,repeating:h})},[T,r,w]),q=n.useCallback(h=>{T||w({...r,shape:h})},[T,r,w]),ne=n.useCallback((h,P)=>{if(T)return;const ce=r.stops.map((oe,ke)=>ke===h?{...oe,...P}:oe);w({...r,stops:ce})},[T,r,w]),re=n.useCallback(()=>{if(T||r.stops.length>=Y)return;const h=r.stops.slice().sort((de,ae)=>de.position-ae.position);let P=0,ce=h[0];for(let de=0;de<h.length-1;de++){const ae=h[de+1].position-h[de].position;ae>P&&(P=ae,ce=h[de])}const oe=Math.round(ce.position+P/2),ke="#"+Math.floor(Math.random()*16777215).toString(16).padStart(6,"0");w({...r,stops:[...r.stops,{color:ke,position:oe}]})},[T,r,Y,w]),ue=n.useCallback(h=>{if(T||r.stops.length<=2)return;const P=r.stops.filter((ce,oe)=>oe!==h);w({...r,stops:P}),S>=P.length&&U(P.length-1)},[T,r,S,w]),je=n.useCallback(()=>{if(T)return;const h=2+Math.floor(Math.random()*3);w(mi(h))},[T,w]),J=n.useCallback(()=>{if(T||!k.trim())return;const h=bn(k);h&&w(h)},[T,k,w]),ge=n.useCallback(h=>{if(T||!c.current||r.stops.length>=Y)return;const P=c.current.getBoundingClientRect(),ce=Math.round((h.clientX-P.left)/P.width*100),oe="#"+Math.floor(Math.random()*16777215).toString(16).padStart(6,"0"),ke=[...r.stops,{color:oe,position:ce}];w({...r,stops:ke}),U(ke.length-1)},[T,r,Y,w]),ye=n.useMemo(()=>r.stops.slice().sort((h,P)=>h.position-P.position),[r.stops]);if(O)return null;const se=e.jsxs("div",{className:"nice-gradient__tab",children:[A&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"nice-gradient__type-row",children:[["linear","radial","conic"].map(h=>e.jsx("button",{type:"button",className:`nice-gradient__type-btn ${r.type===h?"nice-gradient__type-btn--active":""}`,onClick:()=>K(h),disabled:T,children:h.charAt(0).toUpperCase()+h.slice(1)},h)),e.jsxs("label",{className:"nice-gradient__repeat-label",children:[e.jsx("input",{type:"checkbox",checked:r.repeating??!1,onChange:h=>pe(h.target.checked),disabled:T}),"Repeating"]})]}),e.jsxs("div",{className:"nice-gradient__controls",children:[r.type==="linear"&&e.jsxs("div",{className:"nice-gradient__control-group",children:[e.jsxs("label",{children:["Angle: ",r.angle,"°"]}),e.jsx("input",{type:"range",min:0,max:360,value:r.angle,onChange:h=>Z(Number(h.target.value)),disabled:T,className:"nice-gradient__slider"}),e.jsx("div",{className:"nice-gradient__angle-presets",children:[0,45,90,135,180,225,270,315].map(h=>e.jsx("button",{type:"button",className:`nice-gradient__angle-btn ${r.angle===h?"nice-gradient__angle-btn--active":""}`,onClick:()=>Z(h),disabled:T,title:`${h}°`,children:e.jsx("span",{style:{transform:`rotate(${h}deg)`,display:"inline-flex"},children:e.jsx(v.oa,{name:"arrow-right",size:14})})},h))})]}),r.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(h=>e.jsx("button",{type:"button",className:`nice-gradient__shape-btn ${(r.shape||"ellipse")===h?"nice-gradient__shape-btn--active":""}`,onClick:()=>q(h),disabled:T,children:h},h))})]}),(r.type==="radial"||r.type==="conic")&&e.jsxs("div",{className:"nice-gradient__control-group",children:[e.jsxs("label",{children:["Center: ",r.positionX??50,"%, ",r.positionY??50,"%"]}),e.jsxs("div",{className:"nice-gradient__center-inputs",children:[e.jsx("input",{type:"range",min:0,max:100,value:r.positionX??50,onChange:h=>w({...r,positionX:Number(h.target.value)}),disabled:T,className:"nice-gradient__slider"}),e.jsx("input",{type:"range",min:0,max:100,value:r.positionY??50,onChange:h=>w({...r,positionY:Number(h.target.value)}),disabled:T,className:"nice-gradient__slider"})]})]}),r.type==="conic"&&e.jsxs("div",{className:"nice-gradient__control-group",children:[e.jsxs("label",{children:["Start angle: ",r.angle,"°"]}),e.jsx("input",{type:"range",min:0,max:360,value:r.angle,onChange:h=>Z(Number(h.target.value)),disabled:T,className:"nice-gradient__slider"})]})]}),e.jsxs("div",{className:"nice-gradient__bar-container",children:[e.jsx("div",{ref:c,className:"nice-gradient__bar",style:{background:b},onClick:ge,children:r.stops.map((h,P)=>e.jsx("div",{className:`nice-gradient__stop-marker ${S===P?"nice-gradient__stop-marker--active":""}`,style:{left:`${h.position}%`},onClick:ce=>{ce.stopPropagation(),U(P)},title:`${h.color} @ ${h.position}%`,children:e.jsx("div",{className:"nice-gradient__stop-dot",style:{background:h.color}})},P))}),e.jsx("button",{type:"button",className:"nice-gradient__add-stop",onClick:re,disabled:T||r.stops.length>=Y,title:"Add stop","aria-label":"Add stop",children:e.jsx(v.oa,{name:"plus",size:14})})]}),e.jsx("div",{className:"nice-gradient__stop-editor",children:e.jsx("div",{className:"nice-gradient__stop-list",children:ye.map((h,P)=>{const ce=r.stops.indexOf(h);return e.jsxs("div",{className:`nice-gradient__stop-row ${S===ce?"nice-gradient__stop-row--active":""}`,onClick:()=>U(ce),children:[e.jsx("input",{type:"color",value:h.color,onChange:oe=>ne(ce,{color:oe.target.value}),disabled:T,className:"nice-gradient__stop-color"}),e.jsx("input",{type:"text",value:h.color.toUpperCase(),maxLength:7,onChange:oe=>ne(ce,{color:oe.target.value}),disabled:T,className:"nice-gradient__stop-hex"}),e.jsx("input",{type:"number",min:0,max:100,value:h.position,onChange:oe=>ne(ce,{position:Number(oe.target.value)}),disabled:T,className:"nice-gradient__stop-pos"}),e.jsx("span",{className:"nice-gradient__stop-pct",children:"%"}),r.stops.length>2&&e.jsx("button",{type:"button",className:"nice-gradient__stop-del",onClick:()=>ue(ce),disabled:T,"aria-label":"Remove stop",children:e.jsx(v.oa,{name:"close",size:14})})]},ce)})})})]}),E&&e.jsxs("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm nice-gradient__random-btn",onClick:je,disabled:T,title:"Random gradient","aria-label":"Random gradient",children:[e.jsx(v.oa,{name:"shuffle",size:14})," Random Gradient"]})]}),me=e.jsx("div",{className:"nice-gradient__tab",children:e.jsx("div",{className:"nice-gradient__preset-grid",children:jn.map((h,P)=>e.jsxs("button",{type:"button",className:"nice-gradient__preset-card",onClick:()=>{T||w(h.value)},disabled:T,title:h.name,children:[e.jsx("div",{className:"nice-gradient__preset-preview",style:{background:$t(h.value)}}),e.jsx("span",{className:"nice-gradient__preset-name",children:h.name})]},P))})}),fe=e.jsxs("div",{className:"nice-gradient__tab",children:[e.jsxs("div",{className:"nice-gradient__css-output",children:[e.jsx("code",{children:`background: ${b};`}),e.jsx("button",{type:"button",className:"nice-gradient__copy-btn",onClick:()=>navigator.clipboard?.writeText(`background: ${b};`),title:"Copy CSS","aria-label":"Copy CSS",children:e.jsx(v.oa,{name:"clipboard",size:16})})]}),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:k,onChange:h=>j(h.target.value),disabled:T}),e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm",onClick:J,disabled:T,children:"Import"})]})]}),W=[{id:"editor",label:"Editor",content:se}];return g&&W.push({id:"presets",label:"Presets",content:me}),_&&W.push({id:"css",label:"CSS",content:fe}),e.jsxs("div",{ref:M,id:I,className:`nice-field nice-gradient-field ${T?"nice-gradient--disabled":""} ${$==="left"?"nice-field--label-left":""} ${ie?"nice-field--loading":""} ${V?"nice-field--error":""} ${i||""}`,style:o,children:[F&&e.jsx("label",{htmlFor:I,className:"nice-field__label",children:F}),e.jsxs("div",{className:"nice-field__control",children:[e.jsx("button",{ref:H,type:"button",className:"nice-gradient__swatch",style:{background:b},"aria-haspopup":"dialog","aria-expanded":z,"aria-readonly":y||void 0,"aria-label":"Open gradient editor",disabled:T,onClick:()=>{!T&&!y&&R(h=>!h)}}),ie&&e.jsx("span",{className:"nice-field__spinner",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})}),z&&p&&N&&pt.createPortal(e.jsx("div",{ref:L,className:`nice-gradient__popup${m?` ${m}`:""}`,"data-theme":m==="nice-dark"?"dark":m==="nice-light"?"light":void 0,role:"dialog","aria-label":"Gradient editor",style:{position:"fixed",left:p.left,top:p.top,width:ee!=null?typeof ee=="number"?`${ee}px`:ee:340,zIndex:1e3},children:e.jsxs("div",{className:"nice-gradient nice-gradient--studio",children:[e.jsxs("div",{className:"nice-gradient__popup-header",children:[e.jsx("div",{className:"nice-gradient__preview",style:{background:b}}),e.jsx("button",{type:"button",className:"nice-gradient__confirm",onClick:()=>R(!1),"aria-label":B("controls.confirm","Confirm"),title:B("controls.confirm","Confirm"),children:e.jsx(v.oa,{name:"check",size:18})})]}),e.jsx(ve.NiceTabs,{tabs:W,variant:"enclosed",size:"sm"})]})}),N)]}),typeof V=="string"&&V&&e.jsx("div",{className:"nice-field__error",role:"alert",children:V})]})});vn.displayName="NiceGradientPicker";function ui(t,{open:i,onSelect:o,onClose:a,onOpen:l,loop:u=!1}){const[_,g]=n.useState(0);n.useEffect(()=>{g(E=>t.length===0?0:Math.min(Math.max(E,0),t.length-1))},[t.length]);const A=n.useCallback(E=>{if(!i){(E.key==="ArrowDown"||E.key==="ArrowUp")&&(E.preventDefault(),l?.());return}if(E.key==="ArrowDown")E.preventDefault(),g(Y=>t.length===0?0:u?(Y+1)%t.length:Math.min(Y+1,t.length-1));else if(E.key==="ArrowUp")E.preventDefault(),g(Y=>t.length===0?0:u?(Y-1+t.length)%t.length:Math.max(Y-1,0));else if(E.key==="Enter"){const Y=t[_];Y!==void 0&&(E.preventDefault(),o(Y,_))}else E.key==="Escape"&&a?.()},[i,t,_,u,o,a,l]);return{activeIndex:_,setActiveIndex:g,handleKeyDown:A}}const pi=({options:t,value:i,onChange:o,searchable:a=!0,clearable:l,loading:u,placeholder:_,label:g,error:A,helperText:E,required:Y,disabled:F,readOnly:$,size:T="md",id:G,className:ie,style:V,data:ee,columns:M,valueField:f="id",displayField:O,dropdownWidth:y,menuGap:I,labelPlacement:B,errorPlacement:r,labelWidth:b,controlWidth:S})=>{const U=F||$||u,k=v.bc(G),{t:j}=v.Gt(),[c,z]=n.useState(!1),[R,p]=n.useState(""),d=n.useRef(null),m=n.useRef(null),{popupRef:x,coords:D,themeClass:N,portalTarget:H}=ve.useAnchoredPopup(c,m,()=>z(!1)),L=!!(ee&&M&&M.length>0),Q=O??(M&&M[0]?.key),w=n.useMemo(()=>!L||!ee?[]:ee.map(J=>({value:String(J[f]??""),label:Q?String(J[Q]??""):""})),[L,ee,f,Q]),K=L?w:t??[],Z=K.find(J=>String(J.value)===i),pe=n.useMemo(()=>{if(!L||!ee)return[];if(!R)return ee;const J=R.toLowerCase();return ee.filter(ge=>M.some(ye=>String(ge[ye.key]??"").toLowerCase().includes(J)))},[L,ee,M,R]),q=n.useMemo(()=>{if(L||!R)return K;const J=R.toLowerCase();return K.filter(ge=>ge.label.toLowerCase().includes(J))},[K,R,L]),ne=L?pe:q,{activeIndex:re,setActiveIndex:ue,handleKeyDown:je}=ui(ne,{open:c,onSelect:J=>{const ge=String(L?J[f]??"":J.value);o(ge),z(!1),p("")},onClose:()=>z(!1)});return e.jsxs("div",{className:`nice-field nice-field--lookup nice-field--${T} ${A?"nice-field--error":""} ${B==="left"?"nice-field--label-left":""} ${r==="right"&&(A||E)?"nice-field--error-right":""} ${u?"nice-field--loading":""} ${F?"nice-field--disabled":""} ${ie||""}`,style:{...S!=null&&{"--nice-field-control-width":typeof S=="number"?`${S}px`:S},...b!=null&&{"--nice-field-label-width":typeof b=="number"?`${b}px`:b},...I!=null&&{"--nice-dropdown-gap":`${I}px`},...V},"aria-busy":u||void 0,ref:d,children:[g&&e.jsxs("label",{className:"nice-field__label",htmlFor:k,children:[g,Y&&e.jsx("span",{className:"nice-field__required",children:"*"})]}),e.jsxs("div",{className:"nice-field__control",children:[e.jsxs("div",{className:"nice-field__input-wrap",ref:m,children:[e.jsxs("button",{type:"button",id:k,className:`nice-select__trigger ${F?"nice-select__trigger--disabled":""}`,onClick:()=>!U&&z(!c),disabled:F,"aria-readonly":$||void 0,"aria-expanded":c,children:[e.jsx("span",{children:Z?.label||_||j("controls.select","Select...")}),e.jsxs("span",{style:{display:"flex",alignItems:"center",gap:4},children:[l&&i&&!F&&!$&&e.jsx("span",{className:"nice-input__clear",role:"button",tabIndex:0,"aria-label":j("controls.clear","Clear"),onClick:J=>{J.stopPropagation(),o("")},children:e.jsx(v.oa,{name:"close",size:14})}),e.jsx("span",{className:`nice-select__arrow${$?" nice-select__arrow--hidden":""}`,children:e.jsx(v.oa,{name:"chevron-down",size:16})})]})]}),c&&D&&H&&pt.createPortal(e.jsxs("div",{ref:x,className:`nice-dropdown nice-lookup__dropdown${N?` ${N}`:""}`,"data-theme":N==="nice-dark"?"dark":N==="nice-light"?"light":void 0,style:{position:"fixed",top:D.top,left:D.left,zIndex:1e3,marginTop:"var(--nice-dropdown-gap, 0px)",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:D.width,width:y!=null?typeof y=="number"?`${y}px`:y:L?"max-content":D.width},children:[a&&e.jsx("div",{className:"nice-dropdown__search",style:{padding:6},children:e.jsx("input",{type:"text",value:R,onChange:J=>{p(J.target.value),ue(0)},onKeyDown:je,placeholder:j("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)"}})}),L?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:M.map(J=>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:J.width!=null?typeof J.width=="number"?`${J.width}px`:J.width:void 0},children:J.header},J.key))})}),e.jsx("tbody",{children:pe.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:M.length,style:{padding:12,textAlign:"center",color:"var(--text-muted)"},children:j("controls.noResults","No results")})}):pe.map((J,ge)=>{const ye=String(J[f]??""),se=ye===i,me=ge===re;return e.jsx("tr",{role:"option","aria-selected":se,onClick:()=>{o(ye),z(!1),p("")},style:{cursor:"pointer",background:se||me?"var(--hover-bg)":"transparent"},onMouseEnter:()=>ue(ge),children:M.map(fe=>e.jsx("td",{style:{padding:"6px 10px",fontSize:13,borderBottom:"1px solid var(--border-color)"},children:String(J[fe.key]??"")},fe.key))},ye)})})]}):e.jsx("ul",{className:"nice-dropdown__list",role:"listbox",style:{listStyle:"none",margin:0,padding:4,maxHeight:240,overflowY:"auto"},children:q.length===0?e.jsx("li",{className:"nice-dropdown__empty",style:{padding:8,color:"var(--text-muted)"},children:j("controls.noResults","No results")}):q.map((J,ge)=>e.jsx("li",{role:"option",className:`nice-dropdown__option ${String(J.value)===i?"nice-dropdown__option--selected":""} ${ge===re?"nice-dropdown__option--active":""}`,onClick:()=>{o(String(J.value)),z(!1),p("")},onMouseEnter:()=>ue(ge),"aria-selected":String(J.value)===i,children:J.label},String(J.value)))})]}),H)]}),u&&e.jsx("span",{className:"nice-field__spinner",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})}),r==="right"&&A&&e.jsx("div",{className:"nice-field__error",role:"alert",children:A}),r==="right"&&!A&&E&&e.jsx("div",{className:"nice-field__hint",children:E})]}),r!=="right"&&A&&e.jsx("div",{className:"nice-field__error",children:A}),r!=="right"&&!A&&E&&e.jsx("div",{className:"nice-field__hint",children:E})]})},hi=({startDate:t,endDate:i,onStartChange:o,onEndChange:a,min:l,max:u,clearable:_,startPlaceholder:g,endPlaceholder:A,startLabel:E,endLabel:Y,layout:F="horizontal",separator:$="–",gap:T=12,fullWidth:G=!1,dateFormatPreset:ie,type:V,label:ee,error:M,helperText:f,required:O,disabled:y,size:I="md",id:B,className:r,style:b,accessMode:S,showKeyboardHints:U,labelPlacement:k,errorPlacement:j,labelWidth:c,controlWidth:z,loading:R,readOnly:p})=>{const d=v.Dc(S,B),m=v.bc(B),{t:x}=v.Gt(),D=d==="disabled"||d==="readOnly"||!!y,N=n.useMemo(()=>[{key:"Tab",description:x("shortcuts.switchField","Switch between start/end")},v.Yc.cancel],[x]);if(d==="hidden")return null;const H=Q=>{o(Q),Q&&i&&Q>i&&a(Q)},L=F==="horizontal";return e.jsxs("div",{className:`nice-field nice-field--${I} nice-daterange nice-daterange--${F} ${k==="left"?"nice-field--label-left":""} ${M?"nice-field--error":""} ${R?"nice-field--loading":""} ${r||""}`,style:{...b,...c!=null&&{"--nice-field-label-width":typeof c=="number"?`${c}px`:c},...z!=null&&{"--nice-field-control-width":typeof z=="number"?`${z}px`:z}},"aria-busy":R||void 0,children:[ee&&e.jsxs("label",{className:"nice-field__label",htmlFor:m,children:[ee,O&&e.jsx("span",{className:"nice-field__required",children:"*"}),U&&e.jsx(v.ha,{shortcuts:N,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?k==="left"?"center":"flex-end":"stretch",gap:T,flexWrap:L?"nowrap":"wrap"},children:[e.jsx("div",{style:{flex:G?"1 1 0":void 0,minWidth:0},children:e.jsx(Pt.NiceDateTimePicker,{id:m,dateFormatPreset:ie,type:V,label:E,value:t,onChange:H,min:l,max:i||u,placeholder:g||x("controls.startDate","Start date"),disabled:D,readOnly:p,size:I,clearable:_&&!p,showPickerButton:!p,labelPlacement:k,labelWidth:c})}),L&&$!==""&&$!=null&&e.jsx("span",{className:"nice-daterange__separator",style:{paddingBottom:8,color:"var(--text-secondary, #666)"},"aria-hidden":"true",children:$}),e.jsx("div",{style:{flex:G?"1 1 0":void 0,minWidth:0},children:e.jsx(Pt.NiceDateTimePicker,{dateFormatPreset:ie,type:V,label:Y,value:i,onChange:a,min:t||l,max:u,placeholder:A||x("controls.endDate","End date"),disabled:D,readOnly:p,size:I,clearable:_&&!p,showPickerButton:!p,labelPlacement:k,labelWidth:c})})]}),R&&e.jsx("span",{className:"nice-field__spinner",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})}),j==="right"&&M&&e.jsx("div",{className:"nice-field__error",role:"alert",children:M}),j==="right"&&!M&&f&&e.jsx("div",{className:"nice-field__helper",children:f})]}),j!=="right"&&M&&e.jsx("div",{className:"nice-field__error",children:M}),j!=="right"&&!M&&f&&e.jsx("div",{className:"nice-field__hint",children:f})]})},gi=({min:t=0,max:i=100,step:o=1,startValue:a=t,endValue:l=i,onChange:u,showLabels:_=!0,formatLabel:g,valuePlacement:A="none",label:E,error:Y,helperText:F,required:$,disabled:T,readOnly:G,loading:ie,size:V="md",id:ee,className:M,style:f,accessMode:O,showKeyboardHints:y,labelPlacement:I,errorPlacement:B,labelWidth:r,controlWidth:b})=>{const S=v.Dc(O,ee),U=S==="hidden";(S==="disabled"||S==="readOnly")&&(T=!0);const{t:k}=v.Gt(),j=v.bc(ee),c=n.useRef(null),z=n.useMemo(()=>[v.Yc.increment,v.Yc.decrement,v.Yc.first,v.Yc.last,{key:"Tab",description:k("shortcuts.switchThumb","Switch thumb")}],[k]),R=x=>(x-t)/(i-t)*100,p=x=>g?g(x):String(x),d=x=>{const D=Math.round(x/o)*o;return Math.max(t,Math.min(i,D))},m=n.useCallback((x,D)=>{x.preventDefault();const N=c.current;if(!N||T)return;const H=Q=>{const w=N.getBoundingClientRect(),K=Math.max(0,Math.min(1,(Q.clientX-w.left)/w.width)),Z=d(t+K*(i-t));D==="start"?u?.(Math.min(Z,l),l):u?.(a,Math.max(Z,a))},L=()=>{document.removeEventListener("pointermove",H),document.removeEventListener("pointerup",L)};document.addEventListener("pointermove",H),document.addEventListener("pointerup",L)},[t,i,o,a,l,u,T]);return U?null:e.jsxs("div",{className:`nice-field nice-field--${V} nice-field--rangeslider ${I==="left"?"nice-field--label-left":""} ${B==="right"?"nice-field--error-right":""} ${Y?"nice-field--error":""} ${ie?"nice-field--loading":""} ${M||""}`,style:{...f,...r!=null&&{"--nice-field-label-width":typeof r=="number"?`${r}px`:r},...b!=null&&{"--nice-field-control-width":typeof b=="number"?`${b}px`:b}},"aria-busy":ie||void 0,children:[(E||A==="right"&&I!=="left")&&(I!=="left"?e.jsxs("div",{className:"nice-range-slider__header",children:[E?e.jsx("label",{className:"nice-field__label",htmlFor:j,children:e.jsxs("span",{className:"nice-field__label-text",children:[E,$&&e.jsx("span",{className:"nice-field__required",children:"*"}),y&&e.jsx(v.ha,{shortcuts:z,size:"sm"})]})}):e.jsx("span",{}),A==="right"&&e.jsxs("span",{className:"nice-range-slider__value nice-range-slider__value--header",children:[p(a)," – ",p(l)]})]}):E&&e.jsx("label",{className:"nice-field__label",htmlFor:j,children:e.jsxs("span",{className:"nice-field__label-text",children:[E,$&&e.jsx("span",{className:"nice-field__required",children:"*"}),y&&e.jsx(v.ha,{shortcuts:z,size:"sm"})]})})),e.jsxs("div",{className:"nice-field__control",children:[e.jsxs("div",{className:"nice-range-slider__stack",children:[e.jsxs("div",{className:`nice-range-slider ${_?"nice-range-slider--with-labels":""} ${E?"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(a)}%`,width:`${R(l)-R(a)}%`}})}),e.jsx("div",{className:"nice-range-slider__thumb",style:{left:`${R(a)}%`},onPointerDown:x=>G?void 0:m(x,"start"),role:"slider","aria-valuemin":t,"aria-valuemax":l,"aria-valuenow":a,tabIndex:T?-1:0,id:j}),e.jsx("div",{className:"nice-range-slider__thumb",style:{left:`${R(l)}%`},onPointerDown:x=>G?void 0:m(x,"end"),role:"slider","aria-valuemin":a,"aria-valuemax":i,"aria-valuenow":l,tabIndex:T?-1:0})]}),_&&e.jsxs("div",{className:"nice-range-slider__values",children:[e.jsx("span",{className:"nice-range-slider__values-start",style:{left:`${R(a)}%`},children:p(a)}),e.jsx("span",{className:"nice-range-slider__values-end",style:{left:`${R(l)}%`},children:p(l)})]}),A==="bottom"&&e.jsxs("div",{className:"nice-range-slider__value nice-range-slider__value--bottom",children:[p(a)," – ",p(l)]})]}),A==="right"&&I==="left"&&e.jsxs("span",{className:"nice-range-slider__value nice-range-slider__value--inline",children:[p(a)," – ",p(l)]}),ie&&e.jsx("span",{className:"nice-field__spinner",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})}),B==="right"&&Y&&e.jsx("div",{className:"nice-field__error",role:"alert",children:Y}),B==="right"&&!Y&&F&&e.jsx("div",{className:"nice-field__helper",children:F})]}),B!=="right"&&Y&&e.jsx("div",{className:"nice-field__error",role:"alert",children:Y}),B!=="right"&&!Y&&F&&e.jsx("div",{className:"nice-field__helper",children:F})]})},fi=({displayValue:t,placeholder:i,clearable:o,children:a,onClear:l,open:u,onOpenChange:_,dropdownWidth:g,label:A,error:E,helperText:Y,required:F,disabled:$,size:T="md",id:G,className:ie,style:V,accessMode:ee,showKeyboardHints:M,displayStyle:f})=>{v.rc("input",f),v.ac("input",f);const O=v.Dc(ee,G),y=O==="hidden";(O==="disabled"||O==="readOnly")&&($=!0);const I=v.bc(G),{t:B}=v.Gt(),[r,b]=n.useState(!1),S=n.useRef(null),U=n.useRef(null),k=u??r,j=n.useMemo(()=>[{key:"Enter",description:B("shortcuts.openDropdown","Open dropdown")},v.Yc.cancel],[B]),c=m=>{_?_(m):b(m)},{popupRef:z,coords:R,themeClass:p,portalTarget:d}=ve.useAnchoredPopup(k,U,()=>c(!1));return y?null:e.jsxs("div",{className:`nice-field nice-field--${T} ${E?"nice-field--error":""} ${ie||""}`,style:V,ref:S,children:[A&&e.jsxs("label",{className:"nice-field__label",htmlFor:I,children:[A,F&&e.jsx("span",{className:"nice-field__required",children:"*"}),M&&e.jsx(v.ha,{shortcuts:j,size:"sm"})]}),e.jsxs("div",{className:"nice-field__input-wrap",ref:U,children:[e.jsxs("button",{type:"button",id:I,className:"nice-select__trigger",onClick:()=>!$&&c(!k),disabled:$,children:[e.jsx("span",{children:t||i||B("controls.select","Select...")}),e.jsxs("span",{style:{display:"flex",alignItems:"center",gap:4},children:[o&&t&&!$&&e.jsx("span",{className:"nice-input__clear",role:"button",tabIndex:0,"aria-label":B("controls.clear","Clear"),onClick:m=>{m.stopPropagation(),l?.()},onKeyDown:m=>{(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),m.stopPropagation(),l?.())},children:e.jsx(v.oa,{name:"close",size:14})}),e.jsx("span",{className:"nice-select__arrow",children:e.jsx(v.oa,{name:"chevron-down",size:16})})]})]}),k&&R&&d&&pt.createPortal(e.jsx("div",{ref:z,className:`nice-dropdown${p?` ${p}`:""}`,"data-theme":p==="nice-dark"?"dark":p==="nice-light"?"light":void 0,style:{position:"fixed",left:R.left,top:R.top,width:g??R.width,minWidth:g??R.width,zIndex:1e3},children:a}),d)]}),E&&e.jsx("div",{className:"nice-field__error",children:E}),Y&&!E&&e.jsx("div",{className:"nice-field__hint",children:Y})]})};function Kt(t){const i=t.trim().toLowerCase();return i.startsWith("http://")||i.startsWith("https://")||i.startsWith("/")||i.startsWith("./")||i.startsWith("../")?!0:!(i.startsWith("javascript:")||i.startsWith("vbscript:")||i.startsWith("data:text"))}const yi=[{target:".nice-htmleditor",titleKey:"tutorial.htmlEditor.intro.title",title:"Rich text editor",contentKey:"tutorial.htmlEditor.intro.content",content:"Format text with the toolbar, insert links, images and tables, and switch to HTML or Markdown source when you need it.",placement:"auto"}],xi=["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"],Ee=({d:t,viewBox:i="0 0 24 24"})=>e.jsx("svg",{width:"16",height:"16",viewBox:i,fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("path",{d:t})}),bi={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(Ee,{d:"M8 6h13M8 12h13M8 18h13M3 6h.01M3 12h.01M3 18h.01"}),ol:e.jsx(Ee,{d:"M10 6h11M10 12h11M10 18h11M4 6h1v4M4 10h2M6 18H4c0-1 2-2 2-3s-1-1.5-2-1"}),link:e.jsx(Ee,{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(Ee,{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(Ee,{d:"M3 7v6h6M3 13a9 9 0 1 0 3-7.7L3 13"}),redo:e.jsx(Ee,{d:"M21 7v6h-6M21 13a9 9 0 1 1-3-7.7L21 13"}),clear:e.jsx(Ee,{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(Ee,{d:"M3 3h18v18H3zM3 9h18M3 15h18M9 3v18M15 3v18"}),image:e.jsx(Ee,{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(Ee,{d:"M16 18l6-6-6-6M8 6l-6 6 6 6"}),markdown:"MD",blockquote:e.jsx(Ee,{d:"M3 21c3-3 3-9 0-12M21 21c-3-3-3-9 0-12M9 7h6v6H9zM15 7h6v6h-6z"}),hr:e.jsx(Ee,{d:"M5 12h14"}),subscript:"X₂",superscript:"X²",indent:e.jsx(Ee,{d:"M3 8l4 4-4 4M7 6h14M7 12h14M3 18h18"}),outdent:e.jsx(Ee,{d:"M7 8l-4 4 4 4M21 6H3M21 12H7M21 18H3"}),alignLeft:e.jsx(Ee,{d:"M3 6h18M3 12h12M3 18h18"}),alignCenter:e.jsx(Ee,{d:"M3 6h18M6 12h12M3 18h18"}),alignRight:e.jsx(Ee,{d:"M3 6h18M9 12h12M3 18h18"}),alignJustify:e.jsx(Ee,{d:"M3 6h18M3 12h18M3 18h18"}),fullscreen:e.jsx(Ee,{d:"M3 9V3h6M21 9V3h-6M3 15v6h6M21 15v6h-6"}),removeFormat:e.jsx(Ee,{d:"M4 7V4h16v3M5 20h6M13 4 8 20"}),print:e.jsx(Ee,{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(Ee,{d:"M16 18l6-6-6-6M8 6l-6 6 6 6"}),emoji:e.jsx(Ee,{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(Ee,{d:"M11 19a8 8 0 1 1 0-16 8 8 0 0 1 0 16zM21 21l-4.35-4.35"}),fontSize:e.jsx(Ee,{d:"M4 7V4h16v3M9 20h6M12 4v16"}),fontColor:e.jsx(Ee,{d:"M4 21h16M5 17l7-12 7 12M8 13h8"})},ji=[{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"}],vi=[{label:"Faces",emojis:["??","??","??","??","??","??","??","??","??","??","??","??"]},{label:"Hands",emojis:["??","??","??","??","??","??","??","??","??","??"]},{label:"Symbols",emojis:["??","?","??","?","?","?","??","??","??","??","??","??"]},{label:"Arrows",emojis:["??","??","??","??","??","??","??","??","??","?"]}];function _i(t){let i=t;return i=i.replace(/<h1[^>]*>(.*?)<\/h1>/gi,`# $1
|
|
2
|
+
`),i=i.replace(/<h2[^>]*>(.*?)<\/h2>/gi,`## $1
|
|
3
|
+
`),i=i.replace(/<h3[^>]*>(.*?)<\/h3>/gi,`### $1
|
|
4
|
+
`),i=i.replace(/<strong[^>]*>(.*?)<\/strong>/gi,"**$1**"),i=i.replace(/<b[^>]*>(.*?)<\/b>/gi,"**$1**"),i=i.replace(/<em[^>]*>(.*?)<\/em>/gi,"*$1*"),i=i.replace(/<i[^>]*>(.*?)<\/i>/gi,"*$1*"),i=i.replace(/<code[^>]*>(.*?)<\/code>/gi,"`$1`"),i=i.replace(/<pre[^>]*>(.*?)<\/pre>/gis,"```\n$1\n```\n"),i=i.replace(/<br\s*\/?>/gi,`
|
|
5
|
+
`),i=i.replace(/<li[^>]*>(.*?)<\/li>/gi,`- $1
|
|
6
|
+
`),i=i.replace(/<\/?(?:ul|ol|p|div)[^>]*>/gi,`
|
|
7
|
+
`),i=i.replace(/<[^>]+>/g,""),i=i.replace(/\n{3,}/g,`
|
|
8
|
+
|
|
9
|
+
`),i.trim()}function ki(t){let i=t;return i=i.replace(/^### (.+)$/gm,"<h3>$1</h3>"),i=i.replace(/^## (.+)$/gm,"<h2>$1</h2>"),i=i.replace(/^# (.+)$/gm,"<h1>$1</h1>"),i=i.replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>"),i=i.replace(/\*(.+?)\*/g,"<em>$1</em>"),i=i.replace(/`([^`]+)`/g,"<code>$1</code>"),i=i.replace(/```\n?([\s\S]*?)\n?```/g,"<pre>$1</pre>"),i=i.replace(/^- (.+)$/gm,"<li>$1</li>"),i=i.replace(/(<li>.*<\/li>)/gs,"<ul>$1</ul>"),i=i.replace(/\n/g,"<br>"),i}const zt=({value:t,onChange:i,placeholder:o,height:a=200,toolbar:l=xi,readOnly:u,onImageUpload:_,mentionTrigger:g,mentionSuggestions:A,onMentionSearch:E,onFileDrop:Y,pasteCleanup:F=!0,maxLength:$=0,showWordCount:T=!1,templates:G,label:ie,error:V,helperText:ee,required:M,disabled:f,size:O="md",id:y,className:I,style:B,accessMode:r,tutorial:b})=>{const S=v.Dc(r,y),U=S==="hidden";S==="disabled"&&(f=!0),S==="readOnly"&&(u=!0);const k=v.bc(y),j=n.useRef(null),c=n.useRef(null),z=n.useRef(null),[R,p]=n.useState(!1),[d,m]=n.useState(""),[x,D]=n.useState(!1),[N,H]=n.useState(""),[L,Q]=n.useState(!1),[w,K]=n.useState(""),[Z,pe]=n.useState(0),[q,ne]=n.useState(!1),[re,ue]=n.useState("var(--nice-text, #000000)"),[je,J]=n.useState("var(--nice-warning, #ffff00)"),[ge,ye]=n.useState(0),[se,me]=n.useState(0),[fe,W]=n.useState(!1),[h,P]=n.useState(""),[ce,oe]=n.useState(""),[ke,de]=n.useState(!1),[ae,be]=n.useState(!1),he=n.useCallback((s,C)=>{if(u||f)return;const X=j.current;if(X){if(s==="markdown"){if(!R)m(_i(t)),p(!0),D(!1);else{const le=ki(d);i(le),p(!1)}return}if(s==="source"){x?(i(N),D(!1)):(H(t),D(!0),p(!1));return}if(s==="fullscreen"){ne(le=>!le);return}if(s==="emoji"){de(le=>!le);return}if(s==="findReplace"){W(le=>!le);return}if(s==="image"){if(_)c.current?.click();else{const le=prompt("Image URL:");le&&Kt(le)&&(X.focus(),document.execCommand("insertImage",!1,le),i(v.lc(X.innerHTML)))}return}switch(X.focus(),s){case"bold":document.execCommand("bold");break;case"italic":document.execCommand("italic");break;case"underline":document.execCommand("underline");break;case"strikethrough":document.execCommand("strikeThrough");break;case"h1":document.execCommand("formatBlock",!1,"h1");break;case"h2":document.execCommand("formatBlock",!1,"h2");break;case"h3":document.execCommand("formatBlock",!1,"h3");break;case"ul":document.execCommand("insertUnorderedList");break;case"ol":document.execCommand("insertOrderedList");break;case"blockquote":document.execCommand("formatBlock",!1,"blockquote");break;case"hr":document.execCommand("insertHorizontalRule");break;case"subscript":document.execCommand("subscript");break;case"superscript":document.execCommand("superscript");break;case"indent":document.execCommand("indent");break;case"outdent":document.execCommand("outdent");break;case"alignLeft":document.execCommand("justifyLeft");break;case"alignCenter":document.execCommand("justifyCenter");break;case"alignRight":document.execCommand("justifyRight");break;case"alignJustify":document.execCommand("justifyFull");break;case"removeFormat":document.execCommand("removeFormat");break;case"print":window.print();return;case"link":{const le=prompt("URL:");le&&Kt(le)&&document.execCommand("createLink",!1,le);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":{C&&document.execCommand("fontSize",!1,C);break}case"fontColor":{C&&document.execCommand("foreColor",!1,C);break}case"bgColor":{C&&document.execCommand("hiliteColor",!1,C);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 _e=window.getSelection()?.toString()||"";_e.includes(`
|
|
10
|
+
`)||_e.length>60?document.execCommand("insertHTML",!1,`<pre class="nice-htmleditor__code-block">${_e||"// code"}</pre>`):document.execCommand("insertHTML",!1,`<code>${_e||"code"}</code>`);break}}i(v.lc(X.innerHTML)),ye(X.textContent?.length??0)}},[i,u,f,R,d,t,_,x,N]),Ce=n.useCallback(async s=>{const C=s.target.files?.[0];if(!C||!_)return;const X=await _(C),le=j.current;le&&X&&(le.focus(),document.execCommand("insertImage",!1,X),i(le.innerHTML)),s.target.value=""},[_,i]),Me=n.useCallback(()=>{const s=j.current;if(!s)return;const C=s.textContent?.length??0;if($>0&&C>$&&(s.textContent=(s.textContent??"").slice(0,$)),ye(C),me((s.textContent??"").trim().split(/\s+/).filter(Boolean).length),i(s.innerHTML),g){const X=window.getSelection();if(X&&X.rangeCount>0){const le=X.getRangeAt(0),_e=le.startContainer;if(_e.nodeType===Node.TEXT_NODE){const Ae=_e.textContent||"",Le=le.startOffset,et=Ae.slice(0,Le),Be=et.lastIndexOf(g);if(Be>=0&&(Be===0||/\s/.test(et[Be-1]))){const Ke=et.slice(Be+g.length);if(!/\s/.test(Ke)){Q(!0),K(Ke),pe(0),E?.(Ke);return}}}}Q(!1)}},[i,g,E]),$e=A?.filter(s=>s.label.toLowerCase().includes(w.toLowerCase())).slice(0,8)??[],Te=n.useCallback(s=>{const C=j.current;if(!C)return;const X=window.getSelection();if(!X||X.rangeCount===0)return;const le=X.getRangeAt(0),_e=le.startContainer;if(_e.nodeType===Node.TEXT_NODE&&g){const Ae=_e.textContent||"",Le=le.startOffset,Be=Ae.slice(0,Le).lastIndexOf(g);if(Be>=0){const Ke=Ae.slice(0,Be),ot=Ae.slice(Le),ht=`<span class="nice-htmleditor__mention" data-mention="${s.key}" contenteditable="false">${g}${s.label}</span> `;_e.textContent=Ke;const at=document.createRange();at.setStartAfter(_e),at.collapse(!0);const kt=at.createContextualFragment(ht+ot);_e.parentNode?.insertBefore(kt,_e.nextSibling),X.collapseToEnd(),i(C.innerHTML)}}Q(!1)},[g,i]),Ue=n.useCallback(s=>{if(L&&$e.length>0){s.key==="ArrowDown"?(s.preventDefault(),pe(C=>Math.min(C+1,$e.length-1))):s.key==="ArrowUp"?(s.preventDefault(),pe(C=>Math.max(C-1,0))):s.key==="Enter"?(s.preventDefault(),Te($e[Z])):s.key==="Escape"&&Q(!1);return}(s.ctrlKey||s.metaKey)&&s.key==="b"?(s.preventDefault(),he("bold")):(s.ctrlKey||s.metaKey)&&s.key==="i"?(s.preventDefault(),he("italic")):(s.ctrlKey||s.metaKey)&&s.key==="u"?(s.preventDefault(),he("underline")):(s.ctrlKey||s.metaKey)&&s.key==="f"?(s.preventDefault(),W(C=>!C)):(s.ctrlKey||s.metaKey)&&s.key==="z"&&!s.shiftKey?(s.preventDefault(),he("undo")):(s.ctrlKey||s.metaKey)&&(s.key==="y"||s.key==="z"&&s.shiftKey)&&(s.preventDefault(),he("redo"))},[L,$e,Z,Te,he]),Qe=n.useCallback(s=>{if(!F)return;s.preventDefault();const C=s.clipboardData.getData("text/html"),X=s.clipboardData.getData("text/plain");if(C){const _e=C.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,_e)}else X&&document.execCommand("insertText",!1,X);const le=j.current;le&&(i(le.innerHTML),ye(le.textContent?.length??0))},[F,i]),Je=n.useCallback(async s=>{if(!Y)return;s.preventDefault();const C=Array.from(s.dataTransfer.files);if(C.length===0)return;const X=await Y(C),le=j.current;if(le){le.focus();for(const _e of X)if(/\.(png|jpe?g|gif|webp|svg|bmp|ico)$/i.test(_e)||_e.startsWith("data:image/"))document.execCommand("insertImage",!1,_e);else{const Le=`<a href="${_e}">${_e.split("/").pop()??_e}</a>`;document.execCommand("insertHTML",!1,Le)}i(le.innerHTML)}},[Y,i]),We=n.useCallback(s=>{Y&&s.preventDefault()},[Y]),Ze=n.useCallback(s=>{const C=j.current;if(!C||!h)return;const X=C.textContent??"",le=h.toLowerCase(),_e=X.toLowerCase();(s===1?_e.indexOf(le):_e.lastIndexOf(le))!==-1&&(C.focus(),window.find?.(h))},[h]),Se=n.useCallback(()=>{const s=j.current;!s||!h||(s.innerHTML=s.innerHTML.split(h).join(ce),i(s.innerHTML))},[h,ce,i]),Fe=n.useCallback(()=>{if(!h)return;const s=t.split(h).join(ce);i(s);const C=j.current;C&&(C.innerHTML=s)},[h,ce,t,i]),we=n.useCallback(s=>{const C=j.current;C&&(C.focus(),document.execCommand("insertText",!1,s),i(C.innerHTML),de(!1))},[i]),De=n.useCallback(s=>{const C=j.current;C&&(C.focus(),document.execCommand("insertHTML",!1,s),i(C.innerHTML),be(!1))},[i]),Pe=n.useCallback(s=>{const C=f||u;if(s==="fontSize")return e.jsx(ve.NiceSelect,{size:"sm",value:"",onChange:le=>he("fontSize",String(le)),disabled:C,placeholder:"Size",options:ji.map(le=>({value:le.value,label:le.label})),style:{minWidth:70,maxWidth:80}},s);if(s==="fontColor")return e.jsx(ve.NiceColorPicker,{value:re,onChange:le=>{ue(le),he("fontColor",le)},disabled:C,size:"sm",label:"",title:"Text color"},s);if(s==="bgColor")return e.jsx(ve.NiceColorPicker,{value:je,onChange:le=>{J(le),he("bgColor",le)},disabled:C,size:"sm",label:"",title:"Highlight color"},s);const X=s==="markdown"&&R||s==="fullscreen"&&q||s==="source"&&x||s==="findReplace"&&fe||s==="emoji"&&ke;return e.jsx(ve.NiceButton,{size:"sm",variant:X?"primary":"ghost",onClick:()=>he(s),title:s,disabled:C,children:bi[s]||s},s)},[f,u,he,R,q,re,je,x,fe,ke]);return U?null:e.jsxs("div",{className:`nice-field nice-field--${O} ${V?"nice-field--error":""} ${I||""}`,style:B,children:[ie&&e.jsxs("label",{className:"nice-field__label",htmlFor:k,children:[ie,M&&e.jsx("span",{className:"nice-field__required",children:"*"})]}),e.jsxs("div",{ref:z,className:`nice-htmleditor${q?" nice-htmleditor--fullscreen":""}`,style:{position:"relative"},children:[e.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:20},children:e.jsx(v.Ql,{steps:v.Yl(b,yi)})}),e.jsxs("div",{className:"nice-htmleditor__toolbar",style:{display:"flex",flexWrap:"wrap",gap:2,alignItems:"center"},children:[l.map(Pe),G&&G.length>0&&e.jsxs("div",{style:{position:"relative"},children:[e.jsx(ve.NiceButton,{size:"sm",variant:ae?"primary":"ghost",onClick:()=>be(s=>!s),title:"Insert template",children:"??"}),ae&&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:G.map((s,C)=>e.jsx("li",{style:{padding:"6px 10px",cursor:"pointer",borderRadius:4},onMouseDown:X=>{X.preventDefault(),De(s.html)},children:s.label},C))})]})]}),fe&&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:h,onChange:s=>P(s.target.value),style:{flex:1,maxWidth:180,padding:"2px 6px",border:"1px solid var(--border-color, #ccc)",borderRadius:4,background:"var(--bg-primary, #fff)",color:"var(--text-primary, #1f2937)"}}),e.jsx("input",{type:"text",placeholder:"Replace...",value:ce,onChange:s=>oe(s.target.value),style:{flex:1,maxWidth:180,padding:"2px 6px",border:"1px solid var(--border-color, #ccc)",borderRadius:4,background:"var(--bg-primary, #fff)",color:"var(--text-primary, #1f2937)"}}),e.jsx(ve.NiceButton,{size:"sm",variant:"ghost",onClick:()=>Ze(1),title:"Find next",children:"?"}),e.jsx(ve.NiceButton,{size:"sm",variant:"ghost",onClick:()=>Ze(-1),title:"Find previous",children:"?"}),e.jsx(ve.NiceButton,{size:"sm",variant:"ghost",onClick:Se,disabled:f||u,children:"Replace"}),e.jsx(ve.NiceButton,{size:"sm",variant:"ghost",onClick:Fe,disabled:f||u,children:"All"}),e.jsx(ve.NiceButton,{size:"sm",variant:"ghost",onClick:()=>W(!1),children:"?"})]}),ke&&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:vi.map(s=>e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:"0.7em",fontWeight:600,color:"var(--text-muted, #999)",padding:"4px 0"},children:s.label}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:2},children:s.emojis.map(C=>e.jsx("span",{style:{cursor:"pointer",fontSize:"1.2em",padding:2,borderRadius:4},onClick:()=>we(C),title:C,children:C},C))})]},s.label))}),e.jsx("input",{ref:c,type:"file",accept:"image/*",style:{display:"none"},onChange:Ce}),x?e.jsx("textarea",{className:"nice-htmleditor__source",value:N,onChange:s=>H(s.target.value),style:{minHeight:a,width:"100%",fontFamily:"monospace",resize:"vertical",whiteSpace:"pre",fontSize:"0.85em",background:"var(--bg-primary, #fff)",color:"var(--text-primary, #1f2937)",border:"none",padding:12,boxSizing:"border-box",outline:"none"},disabled:f||u}):R?e.jsx("textarea",{className:"nice-htmleditor__markdown",value:d,onChange:s=>m(s.target.value),style:{minHeight:a,width:"100%",fontFamily:"monospace",resize:"vertical",background:"var(--bg-primary, #fff)",color:"var(--text-primary, #1f2937)",border:"none",padding:12,boxSizing:"border-box",outline:"none"},disabled:f||u}):e.jsxs("div",{style:{position:"relative"},children:[e.jsx("div",{ref:j,id:k,className:"nice-htmleditor__content",contentEditable:!f&&!u,dangerouslySetInnerHTML:{__html:t},onInput:Me,onKeyDown:Ue,onPaste:Qe,onDrop:Je,onDragOver:We,style:{minHeight:a},"data-placeholder":o,role:"textbox","aria-multiline":"true",suppressContentEditableWarning:!0}),L&&$e.length>0&&e.jsx("ul",{className:"nice-htmleditor__mention-list",children:$e.map((s,C)=>e.jsx("li",{className:`nice-htmleditor__mention-item ${C===Z?"nice-htmleditor__mention-item--active":""}`,onMouseDown:X=>{X.preventDefault(),Te(s)},children:s.label},s.key))})]}),e.jsxs("div",{className:"nice-htmleditor__statusbar",style:{display:"flex",gap:12,padding:"2px 8px",fontSize:"0.75em",color:"var(--text-muted, #666)",borderTop:"1px solid var(--border-color, #eee)"},children:[$>0&&e.jsxs("span",{children:[ge," / ",$]}),T&&e.jsxs("span",{children:[se," words"]}),T&&e.jsxs("span",{children:[ge," chars"]}),x&&e.jsx("span",{style:{fontWeight:600},children:"HTML Source"}),R&&e.jsx("span",{style:{fontWeight:600},children:"Markdown"})]})]}),V&&e.jsx("div",{className:"nice-field__error",children:V}),ee&&!V&&e.jsx("div",{className:"nice-field__hint",children:ee})]})},wi=Object.freeze(Object.defineProperty({__proto__:null,NiceHtmlEditor:zt},Symbol.toStringTag,{value:"Module"})),Ni=[{code:"en",label:"English"},{code:"es",label:"Spanish"},{code:"fr",label:"French"},{code:"de",label:"German"},{code:"it",label:"Italian"},{code:"pt",label:"Portuguese"},{code:"pl",label:"Polish"},{code:"ru",label:"Russian"},{code:"zh",label:"Chinese"},{code:"ja",label:"Japanese"},{code:"ko",label:"Korean"},{code:"ar",label:"Arabic"}],Ci=[{style:"professional",label:"Professional"},{style:"casual",label:"Casual"},{style:"formal",label:"Formal"},{style:"concise",label:"Concise"}],Si=n.forwardRef(function(i,o){const{enableAI:a=!0,aiModel:l,enableImprove:u=!0,enableTranslate:_=!0,enableGenerate:g=!0,toolbar:A,languages:E=Ni,textStyles:Y=Ci,onImprove:F,onTranslate:$,onGenerate:T,showAIToolbar:G=!0,value:ie,onChange:V,...ee}=i,M=n.useRef(null),[f,O]=n.useState(!1),[y,I]=n.useState(!1),[B,r]=n.useState(!1),[b,S]=n.useState(""),[U,k]=n.useState(""),[j,c]=n.useState("professional"),[z,R]=n.useState(""),[p,d]=n.useState(E[0]?.code||"en"),[m,x]=n.useState(""),[D,N]=n.useState(""),{t:H}=v.Gt(),L=v.he(),{improveText:Q,translate:w,generateHtml:K,isLoading:Z}=v.Cd(),pe=a&&L.isConfigured,q=n.useCallback(()=>{const se=window.getSelection();return se&&se.toString().trim()?se.toString():""},[]),ne=n.useCallback(se=>{const me=window.getSelection();if(me&&me.rangeCount>0){const fe=me.getRangeAt(0);fe.deleteContents();const W=document.createElement("div");W.innerHTML=se;const h=document.createDocumentFragment();for(;W.firstChild;)h.appendChild(W.firstChild);if(fe.insertNode(h),M.current){const P=M.current.innerHTML;V(P)}}},[V]),re=n.useCallback(async(se="professional")=>{if(!pe||!u)return"";const me=q();if(!me)return"";S(me),c(se),O(!0),k("");try{const fe=await Q(me,se);return k(fe),F?.(me,fe,se),fe}catch{return k(H("htmlEditorAI.improveFailed","Failed to improve text")),""}},[pe,u,q,Q,F,H]),ue=n.useCallback(async se=>{if(!pe||!_)return"";const me=q();if(!me)return"";S(me),d(se),I(!0),R("");try{const fe=E.find(h=>h.code===se)?.label||se,W=await w(me,fe);return R(W),$?.(me,W,se),W}catch{return R(H("htmlEditorAI.translateFailed","Failed to translate text")),""}},[pe,_,q,w,E,$,H]),je=n.useCallback(async se=>{if(!pe||!g||!se.trim())return"";x(se),N("");try{const me=await K(se);return N(me),T?.(se,me),me}catch{return N(H("htmlEditorAI.generateFailed","Failed to generate HTML")),""}},[pe,g,K,T,H]),J=n.useCallback(()=>{U&&ne(U),O(!1),k("")},[U,ne]),ge=n.useCallback(()=>{z&&ne(z),I(!1),R("")},[z,ne]),ye=n.useCallback(()=>{if(D&&M.current){document.execCommand("insertHTML",!1,D);const se=M.current.innerHTML;V(se)}r(!1),N(""),x("")},[D,V]);return n.useImperativeHandle(o,()=>({getEditor:()=>M.current,focus:()=>M.current?.focus(),getValue:()=>M.current?.innerHTML||"",setValue:se=>{M.current&&(M.current.innerHTML=se,V(se))},getSelection:q,insertHtml:se=>{document.execCommand("insertHTML",!1,se),M.current&&V(M.current.innerHTML)},improveSelection:re,translateSelection:ue,generateHtml:je})),n.useCallback(se=>{M.current=se},[]),e.jsxs("div",{className:"nice-html-editor-ai","data-testid":i["data-testid"],children:[G&&pe&&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"}),Z&&e.jsx("span",{className:"nice-html-editor-ai__loading",children:H("htmlEditorAI.processing","Processing...")})]}),e.jsxs("div",{className:"nice-html-editor-ai__toolbar-right",children:[u&&e.jsxs("div",{className:"nice-html-editor-ai__dropdown",children:[e.jsxs("button",{type:"button",className:"nice-html-editor-ai__btn",onClick:()=>re(),disabled:Z,title:H("htmlEditorAI.improveText","Improve selected text"),children:[e.jsx(v.oa,{name:"star",size:14})," ",H("htmlEditorAI.improve","Improve")]}),e.jsx("div",{className:"nice-html-editor-ai__dropdown-menu",children:Y.map(({style:se,label:me})=>e.jsx("button",{type:"button",className:"nice-html-editor-ai__dropdown-item",onClick:()=>re(se),children:me},se))})]}),_&&e.jsxs("div",{className:"nice-html-editor-ai__dropdown",children:[e.jsxs("button",{type:"button",className:"nice-html-editor-ai__btn",disabled:Z,title:H("htmlEditorAI.translateText","Translate selected text"),children:[e.jsx(v.oa,{name:"globe",size:14})," ",H("htmlEditorAI.translate","Translate")]}),e.jsx("div",{className:"nice-html-editor-ai__dropdown-menu nice-html-editor-ai__dropdown-menu--languages",children:E.map(({code:se,label:me})=>e.jsx("button",{type:"button",className:"nice-html-editor-ai__dropdown-item",onClick:()=>ue(se),children:me},se))})]}),g&&e.jsxs("button",{type:"button",className:"nice-html-editor-ai__btn",onClick:()=>r(!0),disabled:Z,title:H("htmlEditorAI.generateHtml","Generate HTML from description"),children:[e.jsx(v.oa,{name:"zap",size:14})," ",H("htmlEditorAI.generate","Generate")]})]})]}),e.jsx("div",{className:"nice-html-editor-ai__editor-wrapper",children:e.jsx(zt,{value:ie,onChange:V,toolbar:A,...ee})}),f&&e.jsxs("div",{className:"nice-html-editor-ai__panel",children:[e.jsxs("div",{className:"nice-html-editor-ai__panel-header",children:[e.jsxs("h4",{children:[e.jsx(v.oa,{name:"star",size:16})," ",H("htmlEditorAI.improveText","Improve Text")]}),e.jsx("div",{className:"nice-html-editor-ai__style-selector",children:Y.map(({style:se,label:me})=>e.jsx("button",{type:"button",className:`nice-html-editor-ai__style-btn ${j===se?"nice-html-editor-ai__style-btn--active":""}`,onClick:()=>{c(se),re(se)},children:me},se))}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__close","aria-label":H("htmlEditorAI.close","Close"),onClick:()=>O(!1),children:e.jsx(v.oa,{name:"close",size:14})})]}),e.jsx("div",{className:"nice-html-editor-ai__panel-body",children:Z?e.jsx("div",{className:"nice-html-editor-ai__loading-panel",children:H("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:H("htmlEditorAI.original","Original")}),e.jsx("div",{className:"nice-html-editor-ai__text-content",children:b})]}),e.jsxs("div",{className:"nice-html-editor-ai__text-block nice-html-editor-ai__text-block--improved",children:[e.jsx("h5",{children:H("htmlEditorAI.improved","Improved")}),e.jsx("div",{className:"nice-html-editor-ai__text-content",children:U})]})]})}),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:!U||Z,children:[e.jsx(v.oa,{name:"check",size:14})," ",H("htmlEditorAI.apply","Apply")]}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__cancel",onClick:()=>{O(!1),k("")},children:H("htmlEditorAI.cancel","Cancel")})]})]}),y&&e.jsxs("div",{className:"nice-html-editor-ai__panel",children:[e.jsxs("div",{className:"nice-html-editor-ai__panel-header",children:[e.jsxs("h4",{children:[e.jsx(v.oa,{name:"globe",size:16})," ",H("htmlEditorAI.translateText","Translate Text")]}),e.jsx("div",{className:"nice-html-editor-ai__language-selector",children:e.jsx("select",{value:p,onChange:se=>{d(se.target.value),ue(se.target.value)},className:"nice-html-editor-ai__language-select",children:E.map(({code:se,label:me})=>e.jsx("option",{value:se,children:me},se))})}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__close","aria-label":H("htmlEditorAI.close","Close"),onClick:()=>I(!1),children:e.jsx(v.oa,{name:"close",size:14})})]}),e.jsx("div",{className:"nice-html-editor-ai__panel-body",children:Z?e.jsx("div",{className:"nice-html-editor-ai__loading-panel",children:H("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:H("htmlEditorAI.original","Original")}),e.jsx("div",{className:"nice-html-editor-ai__text-content",children:b})]}),e.jsxs("div",{className:"nice-html-editor-ai__text-block nice-html-editor-ai__text-block--translated",children:[e.jsx("h5",{children:E.find(se=>se.code===p)?.label||p}),e.jsx("div",{className:"nice-html-editor-ai__text-content",children:z})]})]})}),e.jsxs("div",{className:"nice-html-editor-ai__panel-footer",children:[e.jsxs("button",{type:"button",className:"nice-html-editor-ai__apply",onClick:ge,disabled:!z||Z,children:[e.jsx(v.oa,{name:"check",size:14})," ",H("htmlEditorAI.apply","Apply")]}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__cancel",onClick:()=>{I(!1),R("")},children:H("htmlEditorAI.cancel","Cancel")})]})]}),B&&e.jsxs("div",{className:"nice-html-editor-ai__panel nice-html-editor-ai__panel--generate",children:[e.jsxs("div",{className:"nice-html-editor-ai__panel-header",children:[e.jsxs("h4",{children:[e.jsx(v.oa,{name:"zap",size:16})," ",H("htmlEditorAI.generateHtml","Generate HTML")]}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__close","aria-label":H("htmlEditorAI.close","Close"),onClick:()=>{r(!1),N(""),x("")},children:e.jsx(v.oa,{name:"close",size:14})})]}),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:H("htmlEditorAI.generatePlaceholder",'Describe what you want to create (e.g., "A pricing table with 3 tiers", "A contact form with name, email, and message")'),value:m,onChange:se=>x(se.target.value),className:"nice-html-editor-ai__generate-textarea",rows:3}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__generate-btn",onClick:()=>je(m),disabled:Z||!m.trim(),children:Z?H("htmlEditorAI.generating","Generating..."):H("htmlEditorAI.generate","Generate")})]}),D&&e.jsxs("div",{className:"nice-html-editor-ai__generate-result",children:[e.jsx("h5",{children:H("htmlEditorAI.preview","Preview")}),e.jsx("div",{className:"nice-html-editor-ai__preview",dangerouslySetInnerHTML:{__html:D}}),e.jsx("h5",{children:H("htmlEditorAI.htmlCode","HTML Code")}),e.jsx("pre",{className:"nice-html-editor-ai__code",children:D})]})]}),e.jsxs("div",{className:"nice-html-editor-ai__panel-footer",children:[e.jsxs("button",{type:"button",className:"nice-html-editor-ai__apply",onClick:ye,disabled:!D||Z,children:[e.jsx(v.oa,{name:"check",size:14})," ",H("htmlEditorAI.insert","Insert")]}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__cancel",onClick:()=>{r(!1),N(""),x("")},children:H("htmlEditorAI.cancel","Cancel")})]})]})]})}),_n=n.forwardRef(({length:t=6,value:i="",onChange:o,masked:a=!1,onComplete:l,label:u,helperText:_,error:g,required:A,disabled:E,readOnly:Y,size:F="md",name:$,id:T,className:G,style:ie,autoFocus:V,labelPlacement:ee,errorPlacement:M,labelWidth:f,controlWidth:O,loading:y,cellWidth:I,...B},r)=>{const b=v.bc(T),S=n.useRef([]),U=i.padEnd(t,"").slice(0,t).split(""),k=n.useCallback(p=>{const d=Math.max(0,Math.min(t-1,p));S.current[d]?.focus()},[t]),j=n.useCallback(p=>{const d=p.join("");o?.(d),d.length===t&&d.indexOf("")===-1&&/^\d+$/.test(d)&&l?.(d)},[o,l,t]),c=n.useCallback((p,d)=>{const x=d.target.value.replace(/\D/g,"").slice(-1);if(!x)return;const D=[...U];D[p]=x,j(D),k(p+1)},[U,j,k]),z=n.useCallback((p,d)=>{if(d.key==="Backspace"){d.preventDefault();const m=[...U];U[p]?(m[p]="",j(m)):p>0&&(m[p-1]="",j(m),k(p-1))}else d.key==="ArrowLeft"?(d.preventDefault(),k(p-1)):d.key==="ArrowRight"&&(d.preventDefault(),k(p+1))},[U,j,k]),R=n.useCallback(p=>{p.preventDefault();const d=p.clipboardData.getData("text").replace(/\D/g,"").slice(0,t);if(!d)return;const m=d.padEnd(t,"").slice(0,t).split("");for(let x=d.length;x<t;x++)m[x]=U[x]||"";j(m),k(Math.min(d.length,t-1))},[t,U,j,k]);return e.jsxs("div",{className:`nice-field nice-field--${F} nice-field--otp${ee?` nice-field--label-${ee}`:""}${M==="right"?" nice-field--error-right":""} ${y?"nice-field--loading":""} ${G||""}`,style:{...ie,...f!=null&&{"--nice-field-label-width":typeof f=="number"?`${f}px`:f},...O!=null&&{"--nice-field-control-width":typeof O=="number"?`${O}px`:O},...I!=null&&{"--nice-otp-cell-width":typeof I=="number"?`${I}px`:I}},"aria-busy":y||void 0,...B,children:[u&&e.jsx("label",{htmlFor:`${b}-0`,className:`nice-field__label ${A?"nice-field__label--required":""}`,children:u}),e.jsxs("div",{className:"nice-field__control",children:[e.jsxs("div",{ref:r,className:`nice-otp nice-otp--${F} ${g?"nice-otp--error":""} ${E?"nice-otp--disabled":""}`,onPaste:R,children:[Array.from({length:t},(p,d)=>e.jsx("input",{ref:m=>{S.current[d]=m},id:d===0?`${b}-0`:void 0,className:"nice-otp__digit",type:a?"password":"text",inputMode:"numeric",maxLength:2,value:U[d]||"",disabled:E,readOnly:Y,autoFocus:V&&d===0,"aria-invalid":!!g,"aria-label":`${d+1}`,onChange:m=>c(d,m),onKeyDown:m=>z(d,m),onFocus:m=>m.target.select()},d)),$&&e.jsx("input",{type:"hidden",name:$,value:i})]}),M==="right"&&g&&e.jsx("div",{id:`${b}-error`,className:"nice-field__error",role:"alert",children:g}),M==="right"&&!g&&_&&e.jsx("div",{id:`${b}-helper`,className:"nice-field__helper",children:_}),y&&e.jsx("span",{className:"nice-field__spinner",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})})]}),M!=="right"&&g&&e.jsx("div",{id:`${b}-error`,className:"nice-field__error",role:"alert",children:g}),M!=="right"&&!g&&_&&e.jsx("div",{id:`${b}-helper`,className:"nice-field__helper",children:_})]})});_n.displayName="NiceInputOtp";const Mi={xxs:36,xs:48,sm:64,md:80,lg:100,xl:128,xxl:160,small:64,medium:80,large:100},gt=6,lt=135,kn=405,rt=kn-lt;function Rt(t,i,o,a){const l=(a-90)*(Math.PI/180);return{x:t+o*Math.cos(l),y:i+o*Math.sin(l)}}function Yt(t,i,o,a,l){const u=Rt(t,i,o,a),_=Rt(t,i,o,l),g=l-a>180?1:0;return`M ${u.x} ${u.y} A ${o} ${o} 0 ${g} 1 ${_.x} ${_.y}`}const wn=n.forwardRef(({value:t=0,onChange:i,min:o=0,max:a=100,step:l=1,showValue:u=!0,valueTemplate:_="{value}",label:g,helperText:A,error:E,required:Y,disabled:F,readOnly:$,size:T="md",name:G,id:ie,className:V,style:ee,labelPlacement:M="top",errorPlacement:f,labelWidth:O,controlWidth:y,loading:I,isLabelCentered:B=!0,...r},b)=>{const S=v.bc(ie),U=n.useRef(!1),k=n.useRef(null),j=typeof T=="number"?T:Mi[T],c=j/2,z=j/2,R=(j-gt*2)/2,p=a>o?(t-o)/(a-o):0,d=lt+p*rt,m=n.useCallback(L=>{let Q=L-lt;Q<0&&(Q+=360),Q>rt&&(Q=Q-rt<360-Q?rt:0);const w=Math.max(0,Math.min(1,Q/rt)),K=o+w*(a-o),Z=Math.round(K/l)*l;return Math.max(o,Math.min(a,Z))},[o,a,l]),x=n.useCallback(L=>{if(F||$)return;const Q=k.current;if(!Q)return;const w=Q.getBoundingClientRect(),K=L.clientX-w.left-w.width/2,Z=L.clientY-w.top-w.height/2;let pe=Math.atan2(K,-Z)*(180/Math.PI);pe<0&&(pe+=360);const q=m(pe);i?.(q)},[m,F,$,i]);n.useEffect(()=>{const L=w=>{U.current&&x(w)},Q=()=>{U.current=!1};return window.addEventListener("pointermove",L),window.addEventListener("pointerup",Q),()=>{window.removeEventListener("pointermove",L),window.removeEventListener("pointerup",Q)}},[x]);const D=n.useCallback(L=>{if(F||$)return;let Q=t;L.key==="ArrowUp"||L.key==="ArrowRight"?(L.preventDefault(),Q=Math.min(a,t+l)):(L.key==="ArrowDown"||L.key==="ArrowLeft")&&(L.preventDefault(),Q=Math.max(o,t-l)),Q!==t&&i?.(Q)},[t,i,o,a,l,F,$]),N=(_||"{value}").replace("{value}",String(t)),H=Rt(c,z,R,d);return e.jsxs("div",{className:`nice-field nice-knob-field nice-knob-field--err-${f||"bottom"} nice-field--${typeof T=="string"?T:"md"} ${I?"nice-field--loading":""} ${V||""}`,style:{...ee,...O!=null&&{"--nice-field-label-width":typeof O=="number"?`${O}px`:O},...y!=null&&{"--nice-field-control-width":typeof y=="number"?`${y}px`:y}},"aria-busy":I||void 0,...r,children:[e.jsxs("div",{className:`nice-knob-field__inner nice-knob-field--${M} ${B?"nice-knob-field--label-centered":""}`,children:[g&&e.jsx("label",{htmlFor:S,className:`nice-field__label ${Y?"nice-field__label--required":""}`,children:g}),e.jsx("div",{className:"nice-field__control",children:e.jsxs("div",{ref:L=>{k.current=L,typeof b=="function"?b(L):b&&(b.current=L)},className:`nice-knob nice-knob--${T} ${F?"nice-knob--disabled":""} ${E?"nice-knob--error":""}`,role:"slider",id:S,tabIndex:F?-1:0,"aria-valuenow":t,"aria-valuemin":o,"aria-valuemax":a,"aria-disabled":F,"aria-invalid":!!E,onPointerDown:L=>{F||$||(U.current=!0,x(L))},onKeyDown:D,children:[e.jsxs("svg",{width:j,height:j,viewBox:`0 0 ${j} ${j}`,children:[e.jsx("path",{d:Yt(c,z,R,lt,kn),fill:"none",stroke:"var(--nice-border-color, #d1d5db)",strokeWidth:gt,strokeLinecap:"round"}),p>0&&e.jsx("path",{d:Yt(c,z,R,lt,d),fill:"none",stroke:"var(--nice-primary, #3b82f6)",strokeWidth:gt,strokeLinecap:"round"}),e.jsx("circle",{cx:H.x,cy:H.y,r:gt,fill:"var(--nice-primary, #3b82f6)"})]}),u&&e.jsx("span",{className:"nice-knob__value",children:N}),G&&e.jsx("input",{type:"hidden",name:G,value:t}),I&&e.jsx("span",{className:"nice-knob__spinner","aria-hidden":"true",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})})]})})]}),E&&e.jsx("div",{className:"nice-field__error",role:"alert",children:E}),!E&&A&&e.jsx("div",{className:"nice-field__helper",children:A})]})});wn.displayName="NiceKnob";const Nn=n.forwardRef(({value:t="",onChange:i,suggestions:o=[],onSearch:a,trigger:l="@",renderSuggestion:u,placeholder:_,rows:g=3,label:A,helperText:E,error:Y,required:F,disabled:$,readOnly:T,loading:G,labelPlacement:ie,errorPlacement:V,labelWidth:ee,controlWidth:M,size:f="md",name:O,id:y,className:I,style:B,...r},b)=>{const S=v.bc(y),[U,k]=n.useState(!1),[j,c]=n.useState(""),[z,R]=n.useState(0),[p,d]=n.useState({top:0,left:0}),m=n.useRef(null),x=n.useRef(-1),N=o.map(K=>typeof K=="string"?{key:K,label:K}:K).filter(K=>K.label.toLowerCase().includes(j.toLowerCase())),H=n.useCallback(()=>{k(!1),c(""),R(0),x.current=-1},[]),L=n.useCallback(K=>{const Z=m.current;if(!Z||x.current<0)return;const pe=t.slice(0,x.current),q=t.slice(Z.selectionStart),ne=`${l}${K.label} `,re=pe+ne+q;i?.(re),H(),requestAnimationFrame(()=>{const ue=pe.length+ne.length;Z.setSelectionRange(ue,ue),Z.focus()})},[t,i,l,H]),Q=n.useCallback(K=>{const Z=K.target.value;i?.(Z);const pe=K.target.selectionStart,q=Z.slice(0,pe),ne=q.lastIndexOf(l);if(ne>=0){const re=ne>0?q[ne-1]:" ",ue=q.slice(ne+l.length);if(/\s/.test(re)&&!/\s/.test(ue)){x.current=ne;const je=ue;c(je),k(!0),R(0),a?.(je);const J=K.target,ge=J.getBoundingClientRect(),ye=parseInt(getComputedStyle(J).lineHeight)||20,se=q.split(`
|
|
11
|
+
`);d({top:ge.top+se.length*ye+4-J.scrollTop,left:ge.left+8});return}}H()},[i,l,a,H]),w=n.useCallback(K=>{!U||N.length===0||(K.key==="ArrowDown"?(K.preventDefault(),R(Z=>(Z+1)%N.length)):K.key==="ArrowUp"?(K.preventDefault(),R(Z=>(Z-1+N.length)%N.length)):K.key==="Enter"?(K.preventDefault(),N[z]&&L(N[z])):K.key==="Escape"&&H())},[U,N,z,L,H]);return n.useEffect(()=>{if(!U)return;const K=Z=>{const pe=m.current;pe&&!pe.contains(Z.target)&&H()};return document.addEventListener("mousedown",K),()=>document.removeEventListener("mousedown",K)},[U,H]),e.jsxs("div",{className:`nice-field nice-field--${f} ${ie==="left"?"nice-field--label-left":""} ${V==="right"?"nice-field--error-right":""} ${G?"nice-field--loading":""} ${I||""}`,style:{...B,...ee!=null&&{"--nice-field-label-width":typeof ee=="number"?`${ee}px`:ee},...M!=null&&{"--nice-field-control-width":typeof M=="number"?`${M}px`:M}},"aria-busy":G||void 0,...r,children:[A&&e.jsx("label",{htmlFor:S,className:`nice-field__label ${F?"nice-field__label--required":""}`,children:A}),e.jsxs("div",{className:"nice-field__control",children:[e.jsxs("div",{className:`nice-mention nice-mention--${f} ${Y?"nice-mention--error":""} ${$?"nice-mention--disabled":""}`,children:[e.jsx("textarea",{ref:K=>{m.current=K,typeof b=="function"?b(K):b&&(b.current=K)},id:S,name:O,className:"nice-mention__input",value:t,onChange:Q,onKeyDown:w,placeholder:_,rows:g,disabled:$,readOnly:T,"aria-invalid":!!Y,"aria-describedby":Y?`${S}-error`:E?`${S}-helper`:void 0,"aria-autocomplete":"list","aria-expanded":U}),U&&N.length>0&&e.jsx("ul",{className:"nice-mention__suggestions",role:"listbox",style:{position:"fixed",top:p.top,left:p.left},children:N.map((K,Z)=>e.jsx("li",{role:"option","aria-selected":Z===z,className:`nice-mention__suggestion ${Z===z?"nice-mention__suggestion--active":""}`,onMouseDown:pe=>{pe.preventDefault(),L(K)},onMouseEnter:()=>R(Z),children:u?u(K):e.jsxs(e.Fragment,{children:[K.icon&&e.jsx("span",{className:"nice-mention__suggestion-icon",children:K.icon}),e.jsx("span",{children:K.label})]})},K.key))})]}),G&&e.jsx("span",{className:"nice-field__spinner",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})}),V==="right"&&Y&&e.jsx("div",{id:`${S}-error`,className:"nice-field__error",role:"alert",children:Y}),V==="right"&&!Y&&E&&e.jsx("div",{id:`${S}-helper`,className:"nice-field__helper",children:E})]}),V!=="right"&&Y&&e.jsx("div",{id:`${S}-error`,className:"nice-field__error",role:"alert",children:Y}),V!=="right"&&!Y&&E&&e.jsx("div",{id:`${S}-helper`,className:"nice-field__helper",children:E})]})});Nn.displayName="NiceMention";function Ei(t){const i=[],o=a=>{for(const l of a)i.push(l),l.children&&o(l.children)};return o(t),i}function Cn(t,i){const o=i.toLowerCase();return t.reduce((a,l)=>{const u=l.children?Cn(l.children,i):[];return(l.label.toLowerCase().includes(o)||u.length>0)&&a.push({...l,children:u.length>0?u:l.children}),a},[])}const Sn=({node:t,level:i,selectedKeys:o,expandedKeys:a,onToggleExpand:l,onSelect:u,selectableLeafsOnly:_,maxDepth:g})=>{const A=typeof g=="number"?Math.min(10,Math.max(1,g)):1/0,Y=!(i+1>=A)&&t.children&&t.children.length>0,F=a.has(t.key),$=o.has(t.key),T=!Y,G=!t.disabled&&(!_||T),ie=Math.min(i+1,10),V={paddingLeft:i*16+14,"--nice-row-bg":`var(--nice-tree-level-${ie}-bg, transparent)`,"--nice-row-text":`var(--nice-tree-level-${ie}-text, inherit)`,"--nice-row-hover-bg":`var(--nice-tree-level-${ie}-hover-bg, var(--bg-secondary, #f3f4f6))`,"--nice-row-active-bg":`var(--nice-tree-level-${ie}-active-bg, var(--nice-primary-tint-10, rgba(59,130,246,0.1)))`};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`nice-tree-select__node ${$?"nice-tree-select__node--selected":""} ${t.disabled?"nice-tree-select__node--disabled":""}`,style:V,"data-nice-depth":ie,onClick:()=>{t.disabled||(Y?l(t.key):G&&u(t.key))},role:"treeitem","aria-selected":$,"aria-expanded":Y?F:void 0,"aria-disabled":t.disabled,children:[Y?e.jsx("button",{type:"button",className:"nice-tree-select__toggle-btn",onClick:ee=>{ee.stopPropagation(),l(t.key)},"aria-label":"Toggle",children:e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"currentColor",style:{transform:F?"rotate(90deg)":"none",transition:"transform 0.15s"},children:e.jsx("path",{d:"M4.5 2l4 4-4 4"})})}):e.jsx("span",{style:{width:12,display:"inline-block"}}),(t.icon==null,null),e.jsx("span",{className:"nice-tree-select__node-label",children:t.label})]}),Y&&F&&t.children.map(ee=>e.jsx(Sn,{node:ee,level:i+1,selectedKeys:o,expandedKeys:a,onToggleExpand:l,onSelect:u,selectableLeafsOnly:_,maxDepth:g},ee.key))]})},Mn=n.forwardRef(({nodes:t,value:i,onChange:o,multiple:a=!1,searchable:l=!1,placeholder:u,selectableLeafsOnly:_=!1,clearable:g=!1,maxDepth:A,label:E,helperText:Y,error:F,required:$,disabled:T,readOnly:G,size:ie="md",name:V,id:ee,className:M,style:f,controlWidth:O,menuGap:y,...I},B)=>{const{t:r}=v.Gt(),b=v.bc(ee),[S,U]=n.useState(!1),[k,j]=n.useState(""),[c,z]=n.useState(new Set),R=n.useRef(null),{popupRef:p,coords:d,themeClass:m,portalTarget:x}=ve.useAnchoredPopup(S,R,()=>U(!1)),D=n.useMemo(()=>i==null?new Set:new Set(Array.isArray(i)?i:[i]),[i]),N=n.useMemo(()=>k?Cn(t,k):t,[t,k]),H=n.useMemo(()=>{const K=Ei(t);return Array.from(D).map(Z=>K.find(pe=>pe.key===Z)?.label).filter(Boolean)},[D,t]),L=n.useCallback(K=>{z(Z=>{const pe=new Set(Z);return pe.has(K)?pe.delete(K):pe.add(K),pe})},[]),Q=n.useCallback(K=>{if(a){const Z=new Set(D);Z.has(K)?Z.delete(K):Z.add(K),o?.(Array.from(Z))}else o?.(K),U(!1)},[a,D,o]),w=n.useCallback(K=>{K.stopPropagation(),o?.(a?[]:"")},[o,a]);return e.jsxs("div",{className:`nice-field nice-field--${ie} ${M||""}`,style:{width:"fit-content",maxWidth:"100%",...y!=null&&{"--nice-dropdown-gap":`${y}px`},...f},...I,children:[E&&e.jsx("label",{htmlFor:b,className:`nice-field__label ${$?"nice-field__label--required":""}`,children:E}),e.jsxs("div",{ref:R,className:"nice-tree-select",style:{position:"relative",width:O!=null&&O!==""?typeof O=="number"?`${O}px`:O:"var(--nice-field-control-width, 220px)"},children:[e.jsxs("div",{ref:B,id:b,className:`nice-input nice-input--${ie} ${F?"nice-input--error":""} ${T?"nice-input--disabled":""} ${G?"nice-input--readonly":""}`,role:"combobox","aria-expanded":S,"aria-haspopup":"tree","aria-invalid":!!F,tabIndex:T?-1:0,onClick:()=>!T&&!G&&U(!S),onKeyDown:K=>{(K.key==="Enter"||K.key===" ")&&(K.preventDefault(),!T&&!G&&U(!S))},children:[e.jsx("span",{className:"nice-tree-select__display",children:H.length>0?H.join(", "):e.jsx("span",{className:"nice-tree-select__placeholder",children:u??r("controls.select","Select...")})}),g&&D.size>0&&e.jsx("button",{type:"button",className:"nice-input__clear",onClick:w,"aria-label":r("controls.clear","Clear"),children:e.jsx(v.oa,{name:"close",size:14})}),e.jsx("span",{className:"nice-tree-select__arrow",style:{transform:S?"rotate(180deg)":"none",transition:"transform 0.15s"},children:e.jsx(v.oa,{name:"chevron-down",size:14})})]}),S&&d&&x&&pt.createPortal(e.jsxs("div",{ref:p,className:`nice-tree-select__dropdown${m?` ${m}`:""}`,"data-theme":m==="nice-dark"?"dark":m==="nice-light"?"light":void 0,role:"tree",style:{position:"fixed",left:d.left,top:d.top,width:d.width,minWidth:d.width,zIndex:1e3},children:[l&&e.jsx("div",{className:"nice-select__search",onClick:K=>K.stopPropagation(),role:"presentation",children:e.jsx("input",{type:"text",placeholder:r("controls.search","Search..."),value:k,onChange:K=>j(K.target.value),autoFocus:!0})}),e.jsx("div",{className:"nice-tree-select__list",children:N.length===0?e.jsx("div",{className:"nice-tree-select__empty",children:r("controls.noResults","No results")}):N.map(K=>e.jsx(Sn,{node:K,level:0,selectedKeys:D,expandedKeys:c,onToggleExpand:L,onSelect:Q,selectableLeafsOnly:_,maxDepth:A},K.key))})]}),x)]}),V&&e.jsx("input",{type:"hidden",name:V,value:Array.isArray(i)?i.join(","):i??""}),F&&e.jsx("div",{id:`${b}-error`,className:"nice-field__error",role:"alert",children:F}),!F&&Y&&e.jsx("div",{id:`${b}-helper`,className:"nice-field__helper",children:Y})]})});Mn.displayName="NiceTreeSelect";function Ve(t,i){return String(t[i])}const $i={xxs:10,xs:12,sm:12,md:14,lg:18,xl:22,xxl:26},En=n.forwardRef(({source:t,target:i,onChange:o,keyField:a="id",labelField:l="label",renderItem:u,filterable:_=!1,searchable:g,groupBy:A,sortable:E=!1,bulkActions:Y=!0,maxRight:F,sourceHeader:$,targetHeader:T,disabled:G=!1,size:ie="md",className:V,style:ee,id:M,...f},O)=>{const{t:y}=v.Gt(),I=$i[ie]??14,[B,r]=n.useState(new Set),[b,S]=n.useState(new Set),[U,k]=n.useState(""),[j,c]=n.useState(""),[z,R]=n.useState(null),p=n.useCallback((Q,w,K)=>{w(Z=>{const pe=new Set(Z);return pe.has(K)?pe.delete(K):pe.add(K),pe})},[]),d=n.useCallback(()=>{const Q=t.filter(pe=>B.has(Ve(pe,a))),w=t.filter(pe=>!B.has(Ve(pe,a))),K=typeof F=="number"?Q.slice(0,Math.max(0,F-i.length)):Q,Z=Q.slice(K.length);o([...w,...Z],[...i,...K]),r(new Set)},[t,i,B,a,o,F]),m=n.useCallback(()=>{const Q=i.filter(K=>b.has(Ve(K,a))),w=i.filter(K=>!b.has(Ve(K,a)));o([...t,...Q],w),S(new Set)},[t,i,b,a,o]),x=n.useCallback(()=>{if(typeof F=="number"){const Q=Math.max(0,F-i.length),w=t.slice(0,Q),K=t.slice(Q);o(K,[...i,...w])}else o([],[...i,...t]);r(new Set)},[t,i,o,F]),D=n.useCallback(()=>{o([...t,...i],[]),S(new Set)},[t,i,o]),N=(Q,w)=>{if(!w)return Q;const K=w.toLowerCase();return Q.filter(Z=>String(Z[l]).toLowerCase().includes(K))},H=Y===!1?{moveAll:!1,removeAll:!1}:Y===!0||Y===void 0?{moveAll:!0,removeAll:!0}:{moveAll:Y.moveAll??!0,removeAll:Y.removeAll??!0},L=(Q,w,K,Z,pe,q,ne)=>{let re=N(Q,Z);E||(re=[...re].sort((me,fe)=>String(me[l]).localeCompare(String(fe[l]),void 0,{numeric:!0,sensitivity:"base"})));const ue=g===!0||_&&g===void 0?"both":g??!1,je=ue==="both"||ue==="left"&&ne==="left"||ue==="right"&&ne==="right",J=(()=>{if(!A)return[{label:"",items:re}];const me=new Map;for(const fe of re){const W=String(A(fe));let h=me.get(W);h||(h=[],me.set(W,h)),h.push(fe)}return[...me.entries()].map(([fe,W])=>({label:fe,items:W}))})(),ge=(me,fe)=>{me.dataTransfer.setData("text/plain",fe),me.dataTransfer.effectAllowed="move"},ye=(me,fe)=>{if(me.preventDefault(),!E)return;const W=me.currentTarget.getBoundingClientRect(),h=me.clientY<W.top+W.height/2;R(P=>P&&P.side===ne&&P.key===fe&&P.before===h?P:{side:ne,key:fe,before:h})},se=(me,fe)=>{me.preventDefault();const W=z?.before??!1;R(null);const h=me.dataTransfer.getData("text/plain");if(!h||!E)return;const ce=[...ne==="right"?i:t],oe=ce.findIndex(be=>Ve(be,a)===h),ke=ce.findIndex(be=>Ve(be,a)===fe);if(oe===-1||ke===-1||h===fe)return;let de=W?ke:ke+1;const[ae]=ce.splice(oe,1);oe<de&&(de-=1),ce.splice(de,0,ae),o(ne==="right"?t:ce,ne==="right"?ce:i)};return e.jsxs("div",{className:"nice-picklist__panel",children:[q&&e.jsx("div",{className:"nice-picklist__header",children:q}),je&&e.jsx("div",{className:"nice-picklist__filter",children:e.jsx("input",{className:"nice-input__native",type:"text",size:1,placeholder:y("controls.search","Search..."),value:Z,onChange:me=>pe(me.target.value)})}),e.jsxs("div",{className:"nice-picklist__list",role:"listbox","aria-multiselectable":"true",children:[J.map(me=>e.jsxs(n.Fragment,{children:[me.label&&e.jsx("div",{className:"nice-picklist__group-header",role:"presentation",children:me.label}),me.items.map(fe=>{const W=Ve(fe,a),h=w.has(W),ce=z&&z.side===ne&&z.key===W?z.before?"nice-picklist__item--drop-before":"nice-picklist__item--drop-after":"";return e.jsxs("div",{className:`nice-picklist__item ${h?"nice-picklist__item--selected":""} ${ce}`,role:"option","aria-selected":h,draggable:E,onDragStart:E?oe=>ge(oe,W):void 0,onDragOver:E?oe=>ye(oe,W):void 0,onDrop:E?oe=>se(oe,W):void 0,onDragEnd:E?()=>R(null):void 0,onClick:()=>!G&&p(w,K,W),children:[E&&e.jsx("span",{className:"nice-picklist__drag-handle","aria-hidden":"true",children:e.jsxs("svg",{width:I,height:I,viewBox:"0 0 20 20",fill:"currentColor",children:[e.jsx("circle",{cx:"7",cy:"5",r:"1.5"}),e.jsx("circle",{cx:"13",cy:"5",r:"1.5"}),e.jsx("circle",{cx:"7",cy:"10",r:"1.5"}),e.jsx("circle",{cx:"13",cy:"10",r:"1.5"}),e.jsx("circle",{cx:"7",cy:"15",r:"1.5"}),e.jsx("circle",{cx:"13",cy:"15",r:"1.5"})]})}),u?u(fe,ne):String(fe[l])]},W)})]},me.label||"__none__")),re.length===0&&e.jsx("div",{className:"nice-picklist__empty",children:y("controls.noItems","No items")})]})]})};return e.jsxs("div",{ref:O,id:M,className:`nice-picklist nice-picklist--${ie} ${G?"nice-picklist--disabled":""} ${V||""}`,style:ee,...f,children:[L(t,B,r,U,k,$??y("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--${ie}`,disabled:G||B.size===0,onClick:d,"aria-label":y("picklist.moveRight","Move right"),children:e.jsx("svg",{width:I,height:I,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"})})}),H.moveAll&&e.jsx("button",{type:"button",className:`nice-btn nice-btn--outline nice-btn--${ie}`,disabled:G||t.length===0,onClick:x,"aria-label":y("picklist.moveAllRight","Move all right"),children:e.jsxs("svg",{width:I,height:I,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--${ie}`,disabled:G||b.size===0,onClick:m,"aria-label":y("picklist.moveLeft","Move left"),children:e.jsx("svg",{width:I,height:I,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"})})}),H.removeAll&&e.jsx("button",{type:"button",className:`nice-btn nice-btn--outline nice-btn--${ie}`,disabled:G||i.length===0,onClick:D,"aria-label":y("picklist.moveAllLeft","Move all left"),children:e.jsxs("svg",{width:I,height:I,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(i,b,S,j,c,T??y("picklist.target","Selected"),"right")]})});En.displayName="NicePickList";const Ri=[{target:".nice-code-editor-wrap",titleKey:"tutorial.codeEditor.intro.title",title:"Code editor",contentKey:"tutorial.codeEditor.intro.content",content:"Edit code with syntax highlighting, IntelliSense and the toolbar. Ctrl+S saves; the status bar shows the cursor position and any problems.",placement:"auto"}];let nt=null,ct=null;const Ti="0.45.0",vt=`https://cdn.jsdelivr.net/npm/monaco-editor@${Ti}/min/vs`,Ut=15e3;function Wt(){const t=window;if(t.MonacoEnvironment?.getWorkerUrl)return;const i=`self.MonacoEnvironment={baseUrl:'${vt}/'};importScripts('${vt}/base/worker/workerMain.js');`,o=URL.createObjectURL(new Blob([i],{type:"text/javascript"}));t.MonacoEnvironment={getWorkerUrl:()=>o}}function it(t){if(t!=="auto")return t;if(typeof document>"u")return"vs";const i=document.documentElement.dataset.theme;return i==="dark"?"vs-dark":i==="light"?"vs":window.matchMedia?.("(prefers-color-scheme: dark)").matches?"vs-dark":"vs"}function $n(){return ct?Promise.resolve(ct):nt||(nt=new Promise((t,i)=>{if(window.monaco){Wt(),ct=window.monaco,t(ct);return}let o=!1;const a=window.setTimeout(()=>{o||(o=!0,nt=null,i(new Error(`Monaco editor failed to load within ${Ut}ms`)))},Ut),l=document.createElement("script");l.src=`${vt}/loader.min.js`,l.async=!0,l.onload=()=>{const u=window.require;u.config({paths:{vs:vt}}),Wt(),u(["vs/editor/editor.main"],_=>{o||(o=!0,window.clearTimeout(a),ct=_,t(_))})},l.onerror=()=>{o||(o=!0,window.clearTimeout(a),nt=null,i(new Error("Failed to load Monaco Editor loader script")))},document.head.appendChild(l)}),nt)}const ut=n.forwardRef(function(i,o){const{value:a,onChange:l,language:u="plaintext",theme:_="auto",options:g={},height:A=400,width:E="100%",markers:Y=[],decorations:F=[],completionProvider:$,onMount:T,onCursorPositionChange:G,onSelectionChange:ie,onSave:V,loading:ee,disabled:M=!1,showToolbar:f=!1,showStatusBar:O=!1,editorSize:y="standard",className:I,"data-testid":B,lsp:r,extraLibs:b,tutorial:S}=i,U=n.useRef(null),k=n.useRef(null),j=n.useRef(null),c=n.useRef([]),z=n.useRef(null),[R,p]=n.useState(!0),[d,m]=n.useState(null),[x,D]=n.useState({lineNumber:1,column:1}),[N,H]=n.useState(""),[L,Q]=n.useState(g.wordWrap==="on"),w=n.useMemo(()=>({automaticLayout:!0,readOnly:M||g.readOnly,minimap:{enabled:g.minimap??!0},lineNumbers:g.lineNumbers??"on",wordWrap:g.wordWrap??"off",tabSize:g.tabSize??2,insertSpaces:g.insertSpaces??!0,fontSize:g.fontSize??14,fontFamily:g.fontFamily??"'Fira Code', 'Consolas', 'Monaco', monospace",fontLigatures:g.fontLigatures??!0,cursorStyle:g.cursorStyle??"line",cursorBlinking:g.cursorBlinking??"blink",autoClosingBrackets:g.autoClosingBrackets??"languageDefined",autoClosingQuotes:g.autoClosingQuotes??"languageDefined",formatOnPaste:g.formatOnPaste??!1,formatOnType:g.formatOnType??!1,renderWhitespace:g.renderWhitespace??"selection",renderControlCharacters:g.renderControlCharacters??!1,scrollBeyondLastLine:g.scrollBeyondLastLine??!0,smoothScrolling:g.smoothScrolling??!0,folding:g.folding??!0,showFoldingControls:g.showFoldingControls??"mouseover","bracketPairColorization.enabled":g.bracketPairColorization??!0,guides:g.guides??{bracketPairs:!0,indentation:!0,highlightActiveIndentation:!0},stickyScroll:{enabled:g.stickyScroll??!1},quickSuggestions:g.quickSuggestions??!0,suggestOnTriggerCharacters:g.suggestOnTriggerCharacters??!0,acceptSuggestionOnEnter:g.acceptSuggestionOnEnter??"on",inlayHints:{enabled:g.inlayHints?"on":"off"}}),[g,M]);n.useEffect(()=>{if(!U.current)return;let q=!0;return $n().then(async ne=>{if(!q||!U.current)return;j.current=ne;const re=ne.editor.create(U.current,{value:a,language:u,theme:it(_),...w});if(k.current=re,p(!1),re.onDidChangeModelContent(()=>{const ue=re.getValue();l?.(ue)}),re.onDidChangeCursorPosition(ue=>{D({lineNumber:ue.position.lineNumber,column:ue.position.column}),G?.({lineNumber:ue.position.lineNumber,column:ue.position.column})}),re.onDidChangeCursorSelection(ue=>{const je=ue.selection,J=re.getModel()?.getValueInRange(je)??"";H(J),ie?.({startLineNumber:je.startLineNumber,startColumn:je.startColumn,endLineNumber:je.endLineNumber,endColumn:je.endColumn})}),re.addCommand(ne.KeyMod.CtrlCmd|ne.KeyCode.KeyS,()=>{V?.(re.getValue())}),r&&typeof window<"u")try{await _t("https://cdn.jsdelivr.net/npm/vscode-ws-jsonrpc@1.0.2/lib/browser/index.min.js"),await _t("https://cdn.jsdelivr.net/npm/monaco-languageclient@0.15.0/lib/monaco-languageclient.min.js");const ue=window,je=ue.ReconnectingWebSocket,{MonacoLanguageClient:J,CloseAction:ge,ErrorAction:ye,createConnection:se}=ue.monacoLanguageClient||{};if(J&&se){const me=r.url,fe=r.language,W=new je(me),h=new ue.VSCodeWebSocketMessageReader(W),P=new ue.VSCodeWebSocketMessageWriter(W),ce=se(h,P),oe=new J({name:"LSP Client",clientOptions:{documentSelector:[fe],initializationOptions:r.initOptions,errorHandler:{error:()=>ye.Continue,closed:()=>ge.Restart}},connectionProvider:{get:()=>Promise.resolve(ce)}});oe.start(),k.current.__lspClient=oe}}catch(ue){console.warn("LSP bridge failed to load:",ue)}T?.(re,ne)}).catch(ne=>{q&&(m(ne.message??"Failed to load editor"),p(!1))}),()=>{if(q=!1,k.current?.dispose(),z.current?.dispose(),k.current&&k.current.__lspClient)try{k.current.__lspClient.stop()}catch{}}},[r]),n.useEffect(()=>{const q=k.current;if(q&&a!==q.getValue()){const ne=q.getPosition();q.setValue(a),ne&&q.setPosition(ne)}},[a]),n.useEffect(()=>{const q=k.current,ne=j.current;if(q&&ne){const re=q.getModel();re&&ne.editor.setModelLanguage(re,u)}},[u]),n.useEffect(()=>{const q=j.current;if(!q||R||!b||b.length===0||u!=="javascript"&&u!=="typescript")return;const ne=q.languages?.typescript;if(!ne)return;const re=[];try{b.forEach((ue,je)=>{const J=ue.filePath??`inmemory://model/nice-extralib-${je}.d.ts`,ge=ne.typescriptDefaults?.addExtraLib(ue.content,J);ge&&re.push(ge);const ye=ne.javascriptDefaults?.addExtraLib(ue.content,J);ye&&re.push(ye)})}catch(ue){console.warn("Failed to register extraLibs:",ue)}return()=>{re.forEach(ue=>{try{ue.dispose()}catch{}})}},[b,u,R]),n.useEffect(()=>{const q=j.current;if(!q||(q.editor.setTheme(it(_)),_!=="auto"||typeof document>"u"))return;const ne=()=>{j.current?.editor.setTheme(it("auto"))},re=new MutationObserver(ne);re.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme","class"]});const ue=window.matchMedia?.("(prefers-color-scheme: dark)");return ue?.addEventListener?.("change",ne),()=>{re.disconnect(),ue?.removeEventListener?.("change",ne)}},[_]),n.useEffect(()=>{const q=k.current;q&&q.updateOptions(w)},[w]),n.useEffect(()=>{const q=k.current,ne=j.current;if(q&&ne){const re=q.getModel();if(re){const ue=Y.map(je=>({startLineNumber:je.startLineNumber,startColumn:je.startColumn,endLineNumber:je.endLineNumber,endColumn:je.endColumn,message:je.message,severity:je.severity}));ne.editor.setModelMarkers(re,"owner",ue)}}},[Y]),n.useEffect(()=>{const q=k.current;if(q&&F.length>0){const ne=F.map(re=>({range:{startLineNumber:re.range.startLineNumber,startColumn:re.range.startColumn,endLineNumber:re.range.endLineNumber,endColumn:re.range.endColumn},options:{className:re.className,glyphMarginClassName:re.glyphMarginClassName,hoverMessage:re.hoverMessage?{value:re.hoverMessage}:void 0,isWholeLine:re.isWholeLine}}));c.current=q.deltaDecorations(c.current,ne)}},[F]),n.useEffect(()=>{const q=j.current;if(!q||!$)return;z.current?.dispose();const ne={text:0,method:1,function:2,constructor:3,field:4,variable:5,class:6,interface:7,module:8,property:9,keyword:13,snippet:14,color:15,file:16,reference:17,folder:18};return z.current=q.languages.registerCompletionItemProvider(u,{provideCompletionItems:async(re,ue)=>({suggestions:(await $(re,ue)).map(J=>({label:J.label,kind:ne[J.kind]??0,insertText:J.insertText,insertTextRules:J.insertTextRules==="insertAsSnippet"?4:void 0,documentation:J.documentation,detail:J.detail,range:{startLineNumber:ue.lineNumber,startColumn:ue.column,endLineNumber:ue.lineNumber,endColumn:ue.column}}))})}),()=>{z.current?.dispose()}},[u,$]),n.useImperativeHandle(o,()=>({getEditor:()=>k.current,getMonaco:()=>j.current,focus:()=>k.current?.focus(),getValue:()=>k.current?.getValue()??"",setValue:q=>k.current?.setValue(q),getSelection:()=>{const q=k.current;if(!q)return"";const ne=q.getSelection();return ne?q.getModel()?.getValueInRange(ne)??"":""},insertText:q=>{const ne=k.current;if(!ne)return;const re=ne.getSelection();re&&ne.executeEdits("",[{range:re,text:q}])},formatDocument:()=>{k.current?.getAction("editor.action.formatDocument")?.run()},goToLine:(q,ne=1)=>{const re=k.current;re&&(re.setPosition({lineNumber:q,column:ne}),re.revealLineInCenter(q),re.focus())},findReplace:()=>{k.current?.getAction("editor.action.startFindReplaceAction")?.run()},undo:()=>{k.current?.trigger("keyboard","undo",null)},redo:()=>{k.current?.trigger("keyboard","redo",null)},getCursorPosition:()=>{const q=k.current?.getPosition();return{lineNumber:q?.lineNumber??1,column:q?.column??1}},setMarkers:q=>{const ne=k.current,re=j.current;if(ne&&re){const ue=ne.getModel();if(ue){const je=q.map(J=>({startLineNumber:J.startLineNumber,startColumn:J.startColumn,endLineNumber:J.endLineNumber,endColumn:J.endColumn,message:J.message,severity:J.severity}));re.editor.setModelMarkers(ue,"owner",je)}}}}),[]);const K=n.useMemo(()=>({format:()=>k.current?.getAction("editor.action.formatDocument")?.run(),undo:()=>k.current?.trigger("keyboard","undo",null),redo:()=>k.current?.trigger("keyboard","redo",null),find:()=>k.current?.getAction("editor.action.startFindReplaceAction")?.run(),toggleWordWrap:()=>{const q=!L;Q(q),k.current?.updateOptions({wordWrap:q?"on":"off"})},toggleMinimap:()=>{const q=k.current?.getOption?.(j.current?.editor?.EditorOption?.minimap);k.current?.updateOptions({minimap:{enabled:!q?.enabled}})},foldAll:()=>k.current?.getAction("editor.foldAll")?.run(),unfoldAll:()=>k.current?.getAction("editor.unfoldAll")?.run()}),[L]),Z=a.split(`
|
|
12
|
+
`).length,pe=a.length;return e.jsxs("div",{className:`nice-code-editor-wrap nice-editor--${y} ${I??""}`,style:{height:A,width:E,display:"flex",flexDirection:"column",position:"relative"},"data-testid":B,children:[e.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:20},children:e.jsx(v.Ql,{steps:v.Yl(S,Ri)})}),d&&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:[e.jsx(v.oa,{name:"warning",size:16})," ",d]}),e.jsx("textarea",{value:a,onChange:q=>l?.(q.target.value),readOnly:M||g.readOnly,style:{width:"100%",height:"100%",fontFamily:"monospace"}})]}),R&&!d&&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:ee??e.jsx("div",{className:"nice-code-editor__loader",children:"Loading editor..."})}),f&&e.jsxs("div",{className:"nice-code-editor__toolbar",children:[e.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:K.undo,title:"Undo (Ctrl+Z)","aria-label":"Undo",children:e.jsx(v.oa,{name:"reply",size:16})}),e.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:K.redo,title:"Redo (Ctrl+Y)","aria-label":"Redo",children:e.jsx(v.oa,{name:"forward",size:16})}),e.jsx("span",{className:"nice-code-editor__toolbar-sep"}),e.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:K.format,title:"Format (Shift+Alt+F)","aria-label":"Format",children:e.jsx(v.oa,{name:"type",size:16})}),e.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:K.find,title:"Find & Replace (Ctrl+H)","aria-label":"Find & Replace",children:e.jsx(v.oa,{name:"search",size:16})}),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:K.toggleWordWrap,title:"Toggle Word Wrap","aria-label":"Toggle Word Wrap",children:e.jsx(v.oa,{name:"align-left",size:16})}),e.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:K.toggleMinimap,title:"Toggle Minimap","aria-label":"Toggle Minimap",children:e.jsx(v.oa,{name:"columns",size:16})}),e.jsx("span",{className:"nice-code-editor__toolbar-sep"}),e.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:K.foldAll,title:"Fold All","aria-label":"Fold All",children:e.jsx(v.oa,{name:"collapse",size:16})}),e.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:K.unfoldAll,title:"Unfold All","aria-label":"Unfold All",children:e.jsx(v.oa,{name:"expand",size:16})})]}),e.jsx("div",{ref:U,className:"nice-code-editor",style:{flex:1,minHeight:0}}),O&&e.jsxs("div",{className:"nice-code-editor__statusbar",children:[e.jsxs("span",{children:["Ln ",x.lineNumber,", Col ",x.column]}),N.length>0&&e.jsxs("span",{children:["(",N.length," selected)"]}),e.jsx("span",{className:"nice-code-editor__statusbar-spacer"}),e.jsxs("span",{children:[Z," lines · ",pe," chars"]}),e.jsx("span",{className:"nice-code-editor__statusbar-lang",children:u}),Y.length>0&&e.jsxs("span",{className:"nice-code-editor__statusbar-markers",children:[e.jsx(v.oa,{name:"warning",size:14})," ",Y.length]})]})]})});function Rn(t){const{original:i,modified:o,language:a="plaintext",theme:l="auto",height:u=400,width:_="100%",inline:g=!1,renderSideBySide:A=!0,originalEditable:E=!1,modifiedEditable:Y=!1,onOriginalChange:F,onModifiedChange:$,loading:T,className:G,"data-testid":ie}=t,V=n.useRef(null),ee=n.useRef(null),M=n.useRef(null),[f,O]=n.useState(!0),[y,I]=n.useState(null);return n.useEffect(()=>{if(!V.current)return;let B=!0;return $n().then(r=>{if(!B||!V.current)return;M.current=r;const b=r.editor.createModel(i,a),S=r.editor.createModel(o,a),U=r.editor.createDiffEditor(V.current,{automaticLayout:!0,theme:it(l),renderSideBySide:!g&&A,originalEditable:E,readOnly:!Y});U.setModel({original:b,modified:S}),ee.current=U,O(!1),E&&b.onDidChangeContent(()=>{F?.(b.getValue())}),Y&&S.onDidChangeContent(()=>{$?.(S.getValue())})}).catch(r=>{B&&(I(r.message??"Failed to load diff editor"),O(!1))}),()=>{B=!1,ee.current?.dispose()}},[]),n.useEffect(()=>{const B=ee.current;if(!B)return;const r=B.getModel();r&&(r.original.getValue()!==i&&r.original.setValue(i),r.modified.getValue()!==o&&r.modified.setValue(o))},[i,o]),n.useEffect(()=>{const B=M.current;if(!B||(B.editor.setTheme(it(l)),l!=="auto"||typeof document>"u"))return;const r=()=>{M.current?.editor.setTheme(it("auto"))},b=new MutationObserver(r);b.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme","class"]});const S=window.matchMedia?.("(prefers-color-scheme: dark)");return S?.addEventListener?.("change",r),()=>{b.disconnect(),S?.removeEventListener?.("change",r)}},[l,f]),y?e.jsx("div",{className:`nice-code-diff-editor nice-code-diff-editor--error ${G??""}`,style:{height:u,width:_},"data-testid":ie,children:e.jsx("div",{className:"nice-code-editor__error",children:e.jsxs("span",{children:[e.jsx(v.oa,{name:"warning",size:16})," ",y]})})}):e.jsxs("div",{className:`nice-code-diff-editor ${G??""}`,style:{height:u,width:_,position:"relative"},"data-testid":ie,children:[e.jsx("div",{ref:V,style:{position:"absolute",inset:0}}),f&&e.jsx("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",background:"var(--nice-bg-primary, #fff)",zIndex:2},children:T??e.jsx("div",{className:"nice-code-editor__loader",children:"Loading diff editor..."})})]})}const Ii="1.29.0",Gt=`https://cdn.jsdelivr.net/npm/prismjs@${Ii}`;let Ct=null;const Tt={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 _t(t){return new Promise((i,o)=>{if(document.querySelector(`script[data-prism-src="${t}"]`)){i();return}const a=document.createElement("script");a.src=t,a.async=!0,a.dataset.prismSrc=t,a.onload=()=>i(),a.onerror=()=>o(new Error(`Failed to load ${t}`)),document.head.appendChild(a)})}function Ai(t){if(typeof window>"u")return Promise.resolve(null);const i=window,o=Tt[t]??"plain",a=async()=>{if(o!=="plain"&&!i.Prism?.languages?.[o])try{await _t(`${Gt}/components/prism-${o}.min.js`)}catch{}};return i.Prism?.languages?a().then(()=>i.Prism):(Ct||(Ct=(async()=>(window.Prism={manual:!0},await _t(`${Gt}/prism.min.js`),window.Prism))()),Ct.then(async()=>(await a(),window.Prism)))}function St(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function Tn(t){const{value:i,onChange:o,language:a="plaintext",height:l=300,width:u="100%",readOnly:_=!1,tabSize:g=2,lineNumbers:A=!0,placeholder:E,theme:Y="auto",className:F,"data-testid":$}=t,T=n.useRef(null),G=n.useRef(null),[ie,V]=n.useState(()=>St(i)),[ee,M]=n.useState("light");n.useEffect(()=>{const r=()=>{if(Y!=="auto")return Y;if(typeof document>"u")return"light";const k=document.documentElement.dataset.theme;return k==="dark"?"dark":k==="light"?"light":window.matchMedia?.("(prefers-color-scheme: dark)").matches?"dark":"light"};if(M(r()),Y!=="auto"||typeof document>"u")return;const b=()=>M(r()),S=new MutationObserver(b);S.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme","class"]});const U=window.matchMedia?.("(prefers-color-scheme: dark)");return U?.addEventListener?.("change",b),()=>{S.disconnect(),U?.removeEventListener?.("change",b)}},[Y]),n.useEffect(()=>{let r=!0;return Ai(a).then(b=>{if(!r)return;const S=Tt[a]??"plain";if(b?.languages?.[S])try{const U=b.highlight(i,b.languages[S],S);V(U);return}catch{}V(St(i))}).catch(()=>{r&&V(St(i))}),()=>{r=!1}},[i,a]);const f=n.useCallback(()=>{!G.current||!T.current||(G.current.scrollTop=T.current.scrollTop,G.current.scrollLeft=T.current.scrollLeft)},[]),O=n.useCallback(r=>{if(r.key==="Tab"){r.preventDefault();const b=r.currentTarget,S=b.selectionStart,U=b.selectionEnd,k=" ".repeat(g);if(r.shiftKey){const z=i.substring(0,S).lastIndexOf(`
|
|
13
|
+
`)+1;if((i.substring(z,S).match(/^(\s*)/)?.[1]??"").length>=g){const p=i.substring(0,z)+i.substring(z+g);o?.(p),setTimeout(()=>{b.selectionStart=b.selectionEnd=S-g},0)}}else{const j=i.substring(0,S)+k+i.substring(U);o?.(j),setTimeout(()=>{b.selectionStart=b.selectionEnd=S+g},0)}}},[i,o,g]),I=i.split(`
|
|
14
|
+
`).length,B=Tt[a]??"plain";return e.jsxs("div",{className:`nice-simple-code-editor nice-simple-code-editor--${ee} ${F??""}`,style:{height:l,width:u},"data-testid":$,"data-language":a,"data-theme":ee,children:[A&&e.jsx("div",{className:"nice-simple-code-editor__line-numbers",children:Array.from({length:I},(r,b)=>e.jsx("div",{className:"nice-simple-code-editor__line-number",children:b+1},b))}),e.jsxs("div",{className:"nice-simple-code-editor__editor-area",children:[e.jsx("pre",{ref:G,"aria-hidden":"true",className:`nice-simple-code-editor__highlight language-${B}`,children:e.jsx("code",{className:`language-${B}`,dangerouslySetInnerHTML:{__html:ie+(i.endsWith(`
|
|
15
|
+
`)?`
|
|
16
|
+
`:"")}})}),e.jsx("textarea",{ref:T,className:"nice-simple-code-editor__textarea",value:i,onChange:r=>o?.(r.target.value),onKeyDown:O,onScroll:f,readOnly:_,placeholder:E,spellCheck:!1,autoCapitalize:"off",autoCorrect:"off"})]})]})}const qt="nice-code-editor-styles";if(typeof document<"u"&&!document.getElementById(qt)){const t=document.createElement("style");t.id=qt,t.textContent=`
|
|
17
|
+
.nice-code-editor,
|
|
18
|
+
.nice-code-diff-editor {
|
|
19
|
+
border: 1px solid var(--nice-border, #e0e0e0);
|
|
20
|
+
border-radius: var(--nice-radius-sm, 4px);
|
|
21
|
+
overflow: hidden;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.nice-code-editor--loading,
|
|
25
|
+
.nice-code-editor--error,
|
|
26
|
+
.nice-code-diff-editor--loading {
|
|
27
|
+
display: flex;
|
|
28
|
+
align-items: center;
|
|
29
|
+
justify-content: center;
|
|
30
|
+
background: var(--nice-bg-muted, #f5f5f5);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.nice-code-editor__loader {
|
|
34
|
+
color: var(--nice-text-secondary, #666);
|
|
35
|
+
font-size: 14px;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.nice-code-editor__error {
|
|
39
|
+
display: flex;
|
|
40
|
+
flex-direction: column;
|
|
41
|
+
width: 100%;
|
|
42
|
+
height: 100%;
|
|
43
|
+
padding: var(--nice-space-2, 8px);
|
|
44
|
+
gap: var(--nice-space-2, 8px);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.nice-code-editor__error span {
|
|
48
|
+
color: var(--nice-error, #d32f2f);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/* Simple code editor */
|
|
52
|
+
.nice-simple-code-editor {
|
|
53
|
+
display: flex;
|
|
54
|
+
border: 1px solid var(--border-color, var(--nice-border, #e0e0e0));
|
|
55
|
+
border-radius: var(--nice-radius-sm, 4px);
|
|
56
|
+
overflow: hidden;
|
|
57
|
+
font-family: 'Fira Code', 'Consolas', 'Monaco', monospace;
|
|
58
|
+
font-size: 14px;
|
|
59
|
+
line-height: 1.5;
|
|
60
|
+
background: var(--bg-primary, var(--nice-bg-surface, #fff));
|
|
61
|
+
color: var(--text-primary, var(--nice-text-primary, #333));
|
|
62
|
+
}
|
|
63
|
+
.nice-simple-code-editor--dark {
|
|
64
|
+
background: var(--nice-bg, #1e1e1e);
|
|
65
|
+
color: var(--nice-text, #d4d4d4);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.nice-simple-code-editor__line-numbers {
|
|
69
|
+
padding: var(--nice-space-2, 8px) 0;
|
|
70
|
+
background: var(--bg-secondary, var(--nice-bg-muted, #f5f5f5));
|
|
71
|
+
border-right: 1px solid var(--border-color, var(--nice-border, #e0e0e0));
|
|
72
|
+
user-select: none;
|
|
73
|
+
text-align: right;
|
|
74
|
+
color: var(--text-secondary, var(--nice-text-secondary, #999));
|
|
75
|
+
overflow: hidden;
|
|
76
|
+
}
|
|
77
|
+
.nice-simple-code-editor--dark .nice-simple-code-editor__line-numbers {
|
|
78
|
+
background: var(--nice-bg-secondary, #252526);
|
|
79
|
+
border-right-color: var(--nice-border, #3c3c3c);
|
|
80
|
+
color: var(--nice-text-muted, #858585);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.nice-simple-code-editor__line-number {
|
|
84
|
+
padding: 0 var(--nice-space-3, 12px);
|
|
85
|
+
min-width: 40px;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.nice-simple-code-editor__editor-area {
|
|
89
|
+
position: relative;
|
|
90
|
+
flex: 1;
|
|
91
|
+
overflow: hidden;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.nice-simple-code-editor__highlight,
|
|
95
|
+
.nice-simple-code-editor__textarea {
|
|
96
|
+
position: absolute;
|
|
97
|
+
inset: 0;
|
|
98
|
+
margin: 0;
|
|
99
|
+
padding: var(--nice-space-2, 8px) var(--nice-space-3, 12px);
|
|
100
|
+
border: 0;
|
|
101
|
+
font: inherit;
|
|
102
|
+
line-height: inherit;
|
|
103
|
+
white-space: pre;
|
|
104
|
+
overflow: auto;
|
|
105
|
+
tab-size: 2;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.nice-simple-code-editor__highlight {
|
|
109
|
+
pointer-events: none;
|
|
110
|
+
background: transparent;
|
|
111
|
+
color: inherit;
|
|
112
|
+
}
|
|
113
|
+
.nice-simple-code-editor__highlight code {
|
|
114
|
+
font: inherit;
|
|
115
|
+
background: transparent;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.nice-simple-code-editor__textarea {
|
|
119
|
+
background: transparent;
|
|
120
|
+
color: transparent;
|
|
121
|
+
caret-color: var(--text-primary, var(--nice-text-primary, #333));
|
|
122
|
+
resize: none;
|
|
123
|
+
outline: none;
|
|
124
|
+
-webkit-text-fill-color: transparent;
|
|
125
|
+
}
|
|
126
|
+
.nice-simple-code-editor--dark .nice-simple-code-editor__textarea {
|
|
127
|
+
caret-color: var(--nice-text, #d4d4d4);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
.nice-simple-code-editor__textarea::placeholder {
|
|
131
|
+
color: var(--text-secondary, var(--nice-text-secondary, #999));
|
|
132
|
+
-webkit-text-fill-color: var(--text-secondary, var(--nice-text-secondary, #999));
|
|
133
|
+
}
|
|
134
|
+
.nice-simple-code-editor--dark .nice-simple-code-editor__textarea::placeholder {
|
|
135
|
+
color: var(--nice-text-muted, #858585);
|
|
136
|
+
-webkit-text-fill-color: var(--nice-text-muted, #858585);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/* Prism token colors — light */
|
|
140
|
+
.nice-simple-code-editor .token.comment,
|
|
141
|
+
.nice-simple-code-editor .token.prolog,
|
|
142
|
+
.nice-simple-code-editor .token.doctype,
|
|
143
|
+
.nice-simple-code-editor .token.cdata { color: #6a737d; font-style: italic; }
|
|
144
|
+
.nice-simple-code-editor .token.punctuation { color: #586069; }
|
|
145
|
+
.nice-simple-code-editor .token.property,
|
|
146
|
+
.nice-simple-code-editor .token.tag,
|
|
147
|
+
.nice-simple-code-editor .token.boolean,
|
|
148
|
+
.nice-simple-code-editor .token.number,
|
|
149
|
+
.nice-simple-code-editor .token.constant,
|
|
150
|
+
.nice-simple-code-editor .token.symbol,
|
|
151
|
+
.nice-simple-code-editor .token.deleted { color: #005cc5; }
|
|
152
|
+
.nice-simple-code-editor .token.selector,
|
|
153
|
+
.nice-simple-code-editor .token.attr-name,
|
|
154
|
+
.nice-simple-code-editor .token.string,
|
|
155
|
+
.nice-simple-code-editor .token.char,
|
|
156
|
+
.nice-simple-code-editor .token.builtin,
|
|
157
|
+
.nice-simple-code-editor .token.inserted { color: #032f62; }
|
|
158
|
+
.nice-simple-code-editor .token.operator,
|
|
159
|
+
.nice-simple-code-editor .token.entity,
|
|
160
|
+
.nice-simple-code-editor .token.url,
|
|
161
|
+
.nice-simple-code-editor .token.variable { color: var(--nice-danger, #d73a49); }
|
|
162
|
+
.nice-simple-code-editor .token.atrule,
|
|
163
|
+
.nice-simple-code-editor .token.attr-value,
|
|
164
|
+
.nice-simple-code-editor .token.keyword { color: var(--nice-danger, #d73a49); font-weight: 600; }
|
|
165
|
+
.nice-simple-code-editor .token.function,
|
|
166
|
+
.nice-simple-code-editor .token.class-name { color: #6f42c1; }
|
|
167
|
+
.nice-simple-code-editor .token.regex,
|
|
168
|
+
.nice-simple-code-editor .token.important { color: #e36209; }
|
|
169
|
+
|
|
170
|
+
/* Prism token colors — dark */
|
|
171
|
+
.nice-simple-code-editor--dark .token.comment,
|
|
172
|
+
.nice-simple-code-editor--dark .token.prolog,
|
|
173
|
+
.nice-simple-code-editor--dark .token.doctype,
|
|
174
|
+
.nice-simple-code-editor--dark .token.cdata { color: var(--nice-success, #6a9955); font-style: italic; }
|
|
175
|
+
.nice-simple-code-editor--dark .token.punctuation { color: var(--nice-text, #d4d4d4); }
|
|
176
|
+
.nice-simple-code-editor--dark .token.property,
|
|
177
|
+
.nice-simple-code-editor--dark .token.tag,
|
|
178
|
+
.nice-simple-code-editor--dark .token.boolean,
|
|
179
|
+
.nice-simple-code-editor--dark .token.number,
|
|
180
|
+
.nice-simple-code-editor--dark .token.constant,
|
|
181
|
+
.nice-simple-code-editor--dark .token.symbol,
|
|
182
|
+
.nice-simple-code-editor--dark .token.deleted { color: var(--nice-success-light, #b5cea8); }
|
|
183
|
+
.nice-simple-code-editor--dark .token.selector,
|
|
184
|
+
.nice-simple-code-editor--dark .token.attr-name,
|
|
185
|
+
.nice-simple-code-editor--dark .token.string,
|
|
186
|
+
.nice-simple-code-editor--dark .token.char,
|
|
187
|
+
.nice-simple-code-editor--dark .token.builtin,
|
|
188
|
+
.nice-simple-code-editor--dark .token.inserted { color: var(--nice-warning, #ce9178); }
|
|
189
|
+
.nice-simple-code-editor--dark .token.operator,
|
|
190
|
+
.nice-simple-code-editor--dark .token.entity,
|
|
191
|
+
.nice-simple-code-editor--dark .token.url,
|
|
192
|
+
.nice-simple-code-editor--dark .token.variable { color: var(--nice-primary, #569cd6); }
|
|
193
|
+
.nice-simple-code-editor--dark .token.atrule,
|
|
194
|
+
.nice-simple-code-editor--dark .token.attr-value,
|
|
195
|
+
.nice-simple-code-editor--dark .token.keyword { color: #c586c0; font-weight: 600; }
|
|
196
|
+
.nice-simple-code-editor--dark .token.function,
|
|
197
|
+
.nice-simple-code-editor--dark .token.class-name { color: #dcdcaa; }
|
|
198
|
+
.nice-simple-code-editor--dark .token.regex,
|
|
199
|
+
.nice-simple-code-editor--dark .token.important { color: #d7ba7d; }
|
|
200
|
+
|
|
201
|
+
/* Toolbar */
|
|
202
|
+
.nice-code-editor-wrap {
|
|
203
|
+
border: 1px solid var(--nice-border, #e0e0e0);
|
|
204
|
+
border-radius: var(--nice-radius-sm, 4px);
|
|
205
|
+
overflow: hidden;
|
|
206
|
+
}
|
|
207
|
+
.nice-code-editor-wrap .nice-code-editor {
|
|
208
|
+
border: none;
|
|
209
|
+
border-radius: 0;
|
|
210
|
+
}
|
|
211
|
+
.nice-code-editor__toolbar {
|
|
212
|
+
display: flex;
|
|
213
|
+
align-items: center;
|
|
214
|
+
gap: var(--nice-space-0-5, 2px);
|
|
215
|
+
padding: var(--nice-space-0-75, 3px) var(--nice-space-1-5, 6px);
|
|
216
|
+
background: var(--nice-bg-muted, #f5f5f5);
|
|
217
|
+
border-bottom: 1px solid var(--nice-border, #e0e0e0);
|
|
218
|
+
}
|
|
219
|
+
.nice-code-editor__toolbar-btn {
|
|
220
|
+
display: inline-flex;
|
|
221
|
+
align-items: center;
|
|
222
|
+
justify-content: center;
|
|
223
|
+
width: 26px;
|
|
224
|
+
height: 26px;
|
|
225
|
+
border: none;
|
|
226
|
+
border-radius: var(--nice-radius-sm, 3px);
|
|
227
|
+
background: transparent;
|
|
228
|
+
color: var(--nice-text-secondary, #666);
|
|
229
|
+
cursor: pointer;
|
|
230
|
+
font-size: 14px;
|
|
231
|
+
transition: background 0.15s, color 0.15s;
|
|
232
|
+
}
|
|
233
|
+
.nice-code-editor__toolbar-btn:hover {
|
|
234
|
+
background: var(--nice-hover, #e0e0e0);
|
|
235
|
+
color: var(--nice-text-primary, #333);
|
|
236
|
+
}
|
|
237
|
+
.nice-code-editor__toolbar-btn--active {
|
|
238
|
+
background: var(--nice-accent, #1976d2);
|
|
239
|
+
color: var(--nice-bg, #FFF);
|
|
240
|
+
}
|
|
241
|
+
.nice-code-editor__toolbar-sep {
|
|
242
|
+
width: 1px;
|
|
243
|
+
height: 18px;
|
|
244
|
+
background: var(--nice-border, #e0e0e0);
|
|
245
|
+
margin: 0 var(--nice-space-1, 4px);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/* Status bar */
|
|
249
|
+
.nice-code-editor__statusbar {
|
|
250
|
+
display: flex;
|
|
251
|
+
align-items: center;
|
|
252
|
+
gap: var(--nice-space-3, 12px);
|
|
253
|
+
padding: var(--nice-space-0-5, 2px) var(--nice-space-2-5, 10px);
|
|
254
|
+
background: var(--nice-bg-muted, #f5f5f5);
|
|
255
|
+
border-top: 1px solid var(--nice-border, #e0e0e0);
|
|
256
|
+
font-size: 12px;
|
|
257
|
+
color: var(--nice-text-secondary, #666);
|
|
258
|
+
user-select: none;
|
|
259
|
+
}
|
|
260
|
+
.nice-code-editor__statusbar-spacer { flex: 1; }
|
|
261
|
+
.nice-code-editor__statusbar-lang {
|
|
262
|
+
text-transform: uppercase;
|
|
263
|
+
font-weight: 600;
|
|
264
|
+
font-size: 11px;
|
|
265
|
+
}
|
|
266
|
+
.nice-code-editor__statusbar-markers {
|
|
267
|
+
color: var(--nice-warning, #f39c12);
|
|
268
|
+
font-weight: 600;
|
|
269
|
+
}
|
|
270
|
+
`,document.head.appendChild(t)}const zi=Object.freeze(Object.defineProperty({__proto__:null,NiceCodeDiffEditor:Rn,NiceCodeEditor:ut,NiceSimpleCodeEditor:Tn},Symbol.toStringTag,{value:"Module"})),Di=n.forwardRef(function(i,o){const{enableAI:a=!0,aiModel:l,enableInlineCompletion:u=!0,completionDelay:_=500,enableExplain:g=!0,enableRefactor:A=!0,enableGenerate:E=!0,systemPrompt:Y,onExplain:F,onRefactor:$,showAIToolbar:T=!0,aiShortcutKey:G="Ctrl",language:ie="plaintext",value:V,onChange:ee,...M}=i,f=n.useRef(null),[O,y]=n.useState(null),[I,B]=n.useState(!1),[r,b]=n.useState(""),[S,U]=n.useState(!1),[k,j]=n.useState(""),[c,z]=n.useState(""),[R,p]=n.useState(""),d=n.useRef(),{t:m}=v.Gt(),x=v.he(),{complete:D,explain:N,refactor:H,generateFromComment:L,isLoading:Q}=v.wd({language:ie,model:l}),w=a&&x.isConfigured,K=n.useCallback(async()=>{if(!w||!u||!f.current||!f.current.getEditor())return;const ge=f.current.getCursorPosition(),se=f.current.getValue().split(`
|
|
271
|
+
`),me=se.slice(0,ge.lineNumber-1),fe=se[ge.lineNumber-1]||"",W=[...me,fe.slice(0,ge.column-1)].join(`
|
|
272
|
+
`),h=[fe.slice(ge.column-1),...se.slice(ge.lineNumber)].join(`
|
|
273
|
+
`);try{const P=await D(W,h);P&&y({lineNumber:ge.lineNumber,column:ge.column,text:P})}catch{}},[w,u,D]),Z=n.useCallback(async()=>{if(!w||!g||!f.current)return"";const J=f.current.getSelection();if(!J)return"";p(J),B(!0),b("");try{const ge=await N(J);return b(ge),F?.(J,ge),ge}catch{return b(m("codeEditorAI.explanationFailed","Failed to explain code")),""}},[w,g,N,F,m]),pe=n.useCallback(async J=>{if(!w||!A||!f.current)return"";const ge=f.current.getSelection();if(!ge)return"";try{const ye=await H(ge,J);return z(ye),$?.(ge,ye),ye}catch{return""}},[w,A,H,$]),q=n.useCallback(async()=>{if(!w||!E||!f.current)return;const J=f.current.getCursorPosition(),ye=f.current.getValue().split(`
|
|
274
|
+
`);let se="";for(let me=J.lineNumber-1;me>=0&&me>=J.lineNumber-3;me--){const fe=ye[me]?.trim()||"";if(fe.startsWith("//")||fe.startsWith("#")||fe.startsWith("/*")||fe.startsWith("*")){se=fe.replace(/^\/\/\s*|^#\s*|^\/\*\s*|\*\/\s*$|^\*\s*/g,"").trim();break}}if(se)try{const me=await L(se);me&&f.current&&f.current.insertText(`
|
|
275
|
+
`+me)}catch{}},[w,E,L]),ne=n.useCallback(()=>{!O||!f.current||(f.current.insertText(O.text),y(null))},[O]),re=n.useCallback(()=>{y(null)},[]),ue=n.useCallback(J=>{i.onCursorPositionChange?.(J),!(!w||!u)&&(d.current&&clearTimeout(d.current),y(null),d.current=setTimeout(()=>{K()},_))},[i.onCursorPositionChange,w,u,_,K]);n.useEffect(()=>{if(!f.current?.getEditor()||!w)return;const ge=ye=>{if(G==="Ctrl"&&ye.ctrlKey||G==="Alt"&&ye.altKey||G==="Meta"&&ye.metaKey){if(ye.key===" "&&u&&(ye.preventDefault(),K()),ye.key==="e"&&g&&(ye.preventDefault(),Z()),ye.key==="r"&&A){ye.preventDefault();const me=f.current?.getSelection();me&&(p(me),U(!0))}ye.key==="g"&&E&&(ye.preventDefault(),q())}ye.key==="Tab"&&O&&(ye.preventDefault(),ne()),ye.key==="Escape"&&O&&re()};return window.addEventListener("keydown",ge),()=>window.removeEventListener("keydown",ge)},[w,G,u,g,A,E,K,Z,q,O,ne,re]),n.useEffect(()=>()=>{d.current&&clearTimeout(d.current)},[]);const je=n.useCallback(()=>{if(!c||!f.current)return;const J=f.current.getEditor();if(J?.executeEdits&&J?.getSelection){const ge=J.getSelection();J.executeEdits("ai-refactor",[{range:ge,text:c}])}U(!1),z(""),j("")},[c]);return n.useImperativeHandle(o,()=>({...f.current,getEditor:()=>f.current?.getEditor(),getMonaco:()=>f.current?.getMonaco(),focus:()=>f.current?.focus(),getValue:()=>f.current?.getValue()||"",setValue:J=>f.current?.setValue(J),getSelection:()=>f.current?.getSelection()||"",insertText:J=>f.current?.insertText(J),formatDocument:()=>f.current?.formatDocument(),goToLine:(J,ge)=>f.current?.goToLine(J,ge),findReplace:()=>f.current?.findReplace(),undo:()=>f.current?.undo(),redo:()=>f.current?.redo(),getCursorPosition:()=>f.current?.getCursorPosition()||{lineNumber:1,column:1},setMarkers:J=>f.current?.setMarkers(J),triggerCompletion:K,explainSelection:Z,refactorSelection:pe,generateFromComment:q,acceptCompletion:ne,dismissCompletion:re})),e.jsxs("div",{className:"nice-code-editor-ai","data-testid":i["data-testid"],children:[T&&w&&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"}),Q&&e.jsx("span",{className:"nice-code-editor-ai__loading",children:m("codeEditorAI.loading","Thinking...")})]}),e.jsxs("div",{className:"nice-code-editor-ai__toolbar-right",children:[u&&e.jsxs("button",{type:"button",className:"nice-code-editor-ai__toolbar-btn",onClick:()=>K(),disabled:Q,title:`${m("codeEditorAI.complete","Complete")} (${G}+Space)`,children:[e.jsx(v.oa,{name:"lightbulb",size:14})," ",m("codeEditorAI.complete","Complete")]}),g&&e.jsxs("button",{type:"button",className:"nice-code-editor-ai__toolbar-btn",onClick:()=>Z(),disabled:Q,title:`${m("codeEditorAI.explain","Explain")} (${G}+E)`,children:[e.jsx(v.oa,{name:"book",size:14})," ",m("codeEditorAI.explain","Explain")]}),A&&e.jsxs("button",{type:"button",className:"nice-code-editor-ai__toolbar-btn",onClick:()=>{const J=f.current?.getSelection();J&&(p(J),U(!0))},disabled:Q,title:`${m("codeEditorAI.refactor","Refactor")} (${G}+R)`,children:[e.jsx(v.oa,{name:"settings",size:14})," ",m("codeEditorAI.refactor","Refactor")]}),E&&e.jsxs("button",{type:"button",className:"nice-code-editor-ai__toolbar-btn",onClick:()=>q(),disabled:Q,title:`${m("codeEditorAI.generate","Generate")} (${G}+G)`,children:[e.jsx(v.oa,{name:"zap",size:14})," ",m("codeEditorAI.generate","Generate")]})]})]}),e.jsxs("div",{className:"nice-code-editor-ai__editor-wrapper",children:[e.jsx(ut,{ref:f,value:V,onChange:ee,language:ie,onCursorPositionChange:ue,...M}),O&&e.jsxs("div",{className:"nice-code-editor-ai__ghost-text",style:{top:`calc(${(O.lineNumber-1)*19}px + 4px)`,left:`calc(${(O.column-1)*7.8}px + 60px)`},children:[e.jsx("span",{className:"nice-code-editor-ai__ghost-text-content",children:O.text}),e.jsxs("span",{className:"nice-code-editor-ai__ghost-text-hint",children:["Tab ",m("codeEditorAI.toAccept","to accept")]})]})]}),I&&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:[e.jsx(v.oa,{name:"book",size:16})," ",m("codeEditorAI.explanation","Explanation")]}),e.jsx("button",{type:"button",className:"nice-code-editor-ai__panel-close",onClick:()=>B(!1),"aria-label":m("codeEditorAI.close","Close"),children:e.jsx(v.oa,{name:"close",size:14})})]}),e.jsx("div",{className:"nice-code-editor-ai__panel-body",children:Q?e.jsx("div",{className:"nice-code-editor-ai__panel-loading",children:m("codeEditorAI.analyzing","Analyzing code...")}):e.jsxs("div",{className:"nice-code-editor-ai__explanation",children:[e.jsx("pre",{className:"nice-code-editor-ai__code-preview",children:R}),e.jsx("div",{className:"nice-code-editor-ai__explanation-text",children:r||m("codeEditorAI.noExplanation","Select code and click Explain")})]})})]}),S&&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:[e.jsx(v.oa,{name:"settings",size:16})," ",m("codeEditorAI.refactorCode","Refactor Code")]}),e.jsx("button",{type:"button",className:"nice-code-editor-ai__panel-close",onClick:()=>{U(!1),z(""),j("")},"aria-label":m("codeEditorAI.close","Close"),children:e.jsx(v.oa,{name:"close",size:14})})]}),e.jsxs("div",{className:"nice-code-editor-ai__panel-body",children:[e.jsx("pre",{className:"nice-code-editor-ai__code-preview",children:R}),e.jsxs("div",{className:"nice-code-editor-ai__refactor-input",children:[e.jsx("input",{type:"text",placeholder:m("codeEditorAI.refactorInstruction",'Describe how to refactor (e.g., "extract function", "add error handling")'),value:k,onChange:J=>j(J.target.value),onKeyDown:J=>{J.key==="Enter"&&k&&pe(k)}}),e.jsx("button",{type:"button",className:"nice-code-editor-ai__refactor-btn",onClick:()=>pe(k),disabled:Q||!k,children:Q?m("codeEditorAI.refactoring","Refactoring..."):m("codeEditorAI.refactor","Refactor")})]}),c&&e.jsxs("div",{className:"nice-code-editor-ai__refactor-result",children:[e.jsx("h5",{children:m("codeEditorAI.refactoredCode","Refactored Code")}),e.jsx("pre",{className:"nice-code-editor-ai__code-preview nice-code-editor-ai__code-preview--result",children:c}),e.jsxs("div",{className:"nice-code-editor-ai__refactor-actions",children:[e.jsxs("button",{type:"button",className:"nice-code-editor-ai__refactor-apply",onClick:je,children:[e.jsx(v.oa,{name:"check",size:14})," ",m("codeEditorAI.apply","Apply")]}),e.jsxs("button",{type:"button",className:"nice-code-editor-ai__refactor-discard",onClick:()=>{z(""),j("")},children:[e.jsx(v.oa,{name:"close",size:14})," ",m("codeEditorAI.discard","Discard")]})]})]})]})]})]})});function Li(t){const i=t instanceof Date?t:new Date(t),o=(a,l=2)=>String(a).padStart(l,"0");return`${o(i.getHours())}:${o(i.getMinutes())}:${o(i.getSeconds())}.${o(i.getMilliseconds(),3)}`}function Pi(t){if(typeof t=="string")return t;try{return JSON.stringify(t,null,2)}catch{return String(t)}}const In=n.forwardRef(function(i,o){const{entries:a,maxHeight:l=240,autoScroll:u=!0,showTimestamps:_=!0,levelFilter:g,onClear:A,title:E,emptyText:Y="No output",clearLabel:F="Clear",fontFamily:$,className:T,style:G,id:ie,"data-testid":V}=i,ee=n.useRef(null),M=n.useMemo(()=>{if(!g||g.length===0)return a;const y=new Set(g);return a.filter(I=>y.has(I.level??"log"))},[a,g]);n.useEffect(()=>{u&&ee.current&&(ee.current.scrollTop=ee.current.scrollHeight)},[M.length,u]);const f=!!E||!!A,O="nice-log-console"+(T?` ${T}`:"");return e.jsxs("div",{ref:o,id:ie,className:O,style:{...$?{fontFamily:$}:null,...G},"data-testid":V,children:[f&&e.jsxs("div",{className:"nice-log-console__header",children:[e.jsx("span",{className:"nice-log-console__title",children:E}),A&&e.jsx("button",{type:"button",className:"nice-log-console__clear",onClick:A,"aria-label":F,children:F})]}),e.jsx("div",{ref:ee,className:"nice-log-console__body",style:{maxHeight:typeof l=="number"?`${l}px`:l},role:"log","aria-live":"polite","aria-relevant":"additions",children:M.length===0?e.jsx("div",{className:"nice-log-console__empty",children:Y}):M.map((y,I)=>{const B=y.level??"log";return e.jsxs("div",{className:`nice-log-console__entry nice-log-console__entry--${B}`,children:[_&&y.timestamp!=null&&e.jsx("span",{className:"nice-log-console__time",children:Li(y.timestamp)}),e.jsx("span",{className:"nice-log-console__level",children:B}),y.source&&e.jsx("span",{className:"nice-log-console__source",children:y.source}),e.jsx("span",{className:"nice-log-console__message",children:y.message}),y.data!==void 0&&e.jsx("pre",{className:"nice-log-console__data",children:Pi(y.data)})]},I)})})]})}),Xt="nice-log-console-styles";if(typeof document<"u"&&!document.getElementById(Xt)){const t=document.createElement("style");t.id=Xt,t.textContent=`
|
|
276
|
+
.nice-log-console {
|
|
277
|
+
display: flex;
|
|
278
|
+
flex-direction: column;
|
|
279
|
+
border: 1px solid var(--nice-border, #e0e0e0);
|
|
280
|
+
border-radius: var(--nice-radius-sm, 4px);
|
|
281
|
+
background: var(--nice-surface, #fff);
|
|
282
|
+
color: var(--nice-text-primary, #1f2937);
|
|
283
|
+
overflow: hidden;
|
|
284
|
+
font-family: 'Fira Code', 'Consolas', 'Monaco', monospace;
|
|
285
|
+
font-size: 12px;
|
|
286
|
+
line-height: 1.55;
|
|
287
|
+
}
|
|
288
|
+
.nice-log-console__header {
|
|
289
|
+
display: flex;
|
|
290
|
+
align-items: center;
|
|
291
|
+
justify-content: space-between;
|
|
292
|
+
gap: var(--nice-space-2, 8px);
|
|
293
|
+
padding: var(--nice-space-1, 4px) var(--nice-space-2, 8px);
|
|
294
|
+
border-bottom: 1px solid var(--nice-border, #e0e0e0);
|
|
295
|
+
background: var(--nice-bg-secondary, #f5f5f5);
|
|
296
|
+
}
|
|
297
|
+
.nice-log-console__title {
|
|
298
|
+
font-weight: 600;
|
|
299
|
+
font-size: 12px;
|
|
300
|
+
}
|
|
301
|
+
.nice-log-console__clear {
|
|
302
|
+
border: 1px solid var(--nice-border, #e0e0e0);
|
|
303
|
+
background: var(--nice-surface, #fff);
|
|
304
|
+
color: var(--nice-text-secondary, #6b7280);
|
|
305
|
+
border-radius: var(--nice-radius-sm, 4px);
|
|
306
|
+
padding: 2px 8px;
|
|
307
|
+
font: inherit;
|
|
308
|
+
font-size: 11px;
|
|
309
|
+
cursor: pointer;
|
|
310
|
+
}
|
|
311
|
+
.nice-log-console__clear:hover {
|
|
312
|
+
color: var(--nice-text-primary, #1f2937);
|
|
313
|
+
border-color: var(--nice-text-secondary, #9ca3af);
|
|
314
|
+
}
|
|
315
|
+
.nice-log-console__body {
|
|
316
|
+
flex: 1;
|
|
317
|
+
overflow: auto;
|
|
318
|
+
padding: var(--nice-space-2, 8px);
|
|
319
|
+
}
|
|
320
|
+
.nice-log-console__empty {
|
|
321
|
+
color: var(--nice-text-muted, #9ca3af);
|
|
322
|
+
font-style: italic;
|
|
323
|
+
padding: var(--nice-space-2, 8px) 0;
|
|
324
|
+
}
|
|
325
|
+
.nice-log-console__entry {
|
|
326
|
+
display: flex;
|
|
327
|
+
flex-wrap: wrap;
|
|
328
|
+
align-items: baseline;
|
|
329
|
+
gap: var(--nice-space-2, 8px);
|
|
330
|
+
padding: 1px 0;
|
|
331
|
+
white-space: pre-wrap;
|
|
332
|
+
word-break: break-word;
|
|
333
|
+
}
|
|
334
|
+
.nice-log-console__time {
|
|
335
|
+
color: var(--nice-text-muted, #9ca3af);
|
|
336
|
+
flex: 0 0 auto;
|
|
337
|
+
}
|
|
338
|
+
.nice-log-console__level {
|
|
339
|
+
flex: 0 0 auto;
|
|
340
|
+
text-transform: uppercase;
|
|
341
|
+
font-size: 10px;
|
|
342
|
+
font-weight: 700;
|
|
343
|
+
letter-spacing: 0.04em;
|
|
344
|
+
opacity: 0.8;
|
|
345
|
+
min-width: 38px;
|
|
346
|
+
}
|
|
347
|
+
.nice-log-console__source {
|
|
348
|
+
flex: 0 0 auto;
|
|
349
|
+
color: var(--nice-primary, #2563eb);
|
|
350
|
+
}
|
|
351
|
+
.nice-log-console__message {
|
|
352
|
+
flex: 1 1 auto;
|
|
353
|
+
}
|
|
354
|
+
.nice-log-console__data {
|
|
355
|
+
flex: 1 0 100%;
|
|
356
|
+
margin: 2px 0 4px;
|
|
357
|
+
padding: var(--nice-space-1, 4px) var(--nice-space-2, 8px);
|
|
358
|
+
background: var(--nice-bg-secondary, #f5f5f5);
|
|
359
|
+
border-radius: var(--nice-radius-sm, 4px);
|
|
360
|
+
overflow: auto;
|
|
361
|
+
font: inherit;
|
|
362
|
+
}
|
|
363
|
+
.nice-log-console__entry--info .nice-log-console__level { color: var(--nice-primary, #2563eb); }
|
|
364
|
+
.nice-log-console__entry--warn { color: var(--nice-warning-text, #92400e); }
|
|
365
|
+
.nice-log-console__entry--warn .nice-log-console__level { color: var(--nice-warning, #d97706); }
|
|
366
|
+
.nice-log-console__entry--error { color: var(--nice-danger, #dc2626); }
|
|
367
|
+
.nice-log-console__entry--error .nice-log-console__level { color: var(--nice-danger, #dc2626); }
|
|
368
|
+
.nice-log-console__entry--debug { color: var(--nice-text-muted, #9ca3af); }
|
|
369
|
+
.nice-log-console__entry--trace { color: var(--nice-text-disabled, #b8bfc9); }
|
|
370
|
+
.nice-log-console__entry--trace .nice-log-console__level { color: var(--nice-text-disabled, #b8bfc9); }
|
|
371
|
+
`,document.head.appendChild(t)}const Hi=[{target:".nice-script-runner",titleKey:"tutorial.scriptRunner.intro.title",title:"Script runner",contentKey:"tutorial.scriptRunner.intro.content",content:"Write a script and sample input, click Run, then inspect the result and captured logs below.",placement:"auto"}];function Vt(t){if(t===void 0)return"";if(typeof t=="string")return t;try{return JSON.stringify(t,null,2)}catch{return String(t)}}function Qt(t){const i=t.trim();if(i==="")return{value:void 0,error:null};try{return{value:JSON.parse(i),error:null}}catch(o){return{value:t,error:o instanceof Error?o.message:"Invalid JSON"}}}function Oi(t){if(typeof t=="string")return t;try{return JSON.stringify(t,null,2)}catch{return String(t)}}const Bi=n.forwardRef(function(i,o){const{value:a,onChange:l,language:u="javascript",onRun:_,input:g,onInputChange:A,showInputPanel:E,extraLibs:Y,height:F=260,running:$,autoRun:T=!1,autoRunDelay:G=600,layout:ie="vertical",runLabel:V="Run",theme:ee="auto",tutorial:M,className:f,style:O,id:y,"data-testid":I}=i,B=E??g!==void 0,[r,b]=n.useState(()=>Vt(g)),[S,U]=n.useState(null),[k,j]=n.useState(!1),[c,z]=n.useState(null),R=$??k,p=ee==="light"?"vs":ee==="dark"?"vs-dark":ee;n.useEffect(()=>{b(Vt(g))},[g]);const d=n.useCallback(async()=>{const H=Qt(r),L=typeof performance<"u"?performance.now():Date.now();$===void 0&&j(!0);try{const Q=await _(a,H.value),w=Q.durationMs??Math.round((typeof performance<"u"?performance.now():Date.now())-L);z({...Q,durationMs:w})}catch(Q){z({ok:!1,error:Q instanceof Error?Q.message:String(Q),durationMs:Math.round((typeof performance<"u"?performance.now():Date.now())-L)})}finally{$===void 0&&j(!1)}},[r,_,a,$]),m=n.useRef(d);m.current=d,n.useEffect(()=>{if(!T)return;const H=setTimeout(()=>{m.current()},G);return()=>clearTimeout(H)},[T,G,a,r]);const x=n.useCallback(H=>{b(H);const L=Qt(H);U(L.error),A?.(L.value)},[A]),D=typeof F=="number"?`${F}px`:F,N=`nice-script-runner nice-script-runner--${ie}`+(f?` ${f}`:"");return e.jsxs("div",{ref:o,id:y,className:N,style:O,"data-testid":I,children:[e.jsxs("div",{className:"nice-script-runner__toolbar",children:[e.jsxs("button",{type:"button",className:"nice-script-runner__run",onClick:()=>void d(),disabled:R,children:[R?"…":e.jsx(v.oa,{name:"play",size:14})," ",V]}),c?.durationMs!=null&&e.jsxs("span",{className:"nice-script-runner__status",children:[e.jsx("span",{className:"nice-script-runner__badge nice-script-runner__badge--"+(c.ok?"ok":"error"),children:c.ok?"OK":"Failed"}),e.jsxs("span",{className:"nice-script-runner__duration",children:[c.durationMs," ms"]})]}),M&&e.jsx("span",{style:{marginLeft:"auto"},children:e.jsx(v.Ql,{steps:v.Yl(M,Hi)})})]}),e.jsxs("div",{className:"nice-script-runner__panes",children:[e.jsxs("div",{className:"nice-script-runner__editors",children:[e.jsx(ut,{value:a,onChange:l,language:u,theme:p,height:D,extraLibs:Y,options:{minimap:!1}}),B&&e.jsxs("div",{className:"nice-script-runner__input",children:[e.jsxs("div",{className:"nice-script-runner__pane-label",children:["Input (JSON)",S&&e.jsxs("span",{className:"nice-script-runner__input-error",children:[" — ",S]})]}),e.jsx(ut,{value:r,onChange:x,language:"json",theme:p,height:120,options:{minimap:!1,lineNumbers:"off"}})]})]}),e.jsxs("div",{className:"nice-script-runner__output",children:[c?.error&&e.jsx("div",{className:"nice-script-runner__error",children:c.error}),c&&c.result!==void 0&&e.jsxs("div",{className:"nice-script-runner__result",children:[e.jsx("div",{className:"nice-script-runner__pane-label",children:"Result"}),e.jsx("pre",{className:"nice-script-runner__result-body",children:Oi(c.result)})]}),e.jsx(In,{title:"Logs",entries:c?.logs??[],maxHeight:160,emptyText:"Run the script to see logs"})]})]})]})}),Jt="nice-script-runner-styles";if(typeof document<"u"&&!document.getElementById(Jt)){const t=document.createElement("style");t.id=Jt,t.textContent=`
|
|
372
|
+
.nice-script-runner {
|
|
373
|
+
display: flex;
|
|
374
|
+
flex-direction: column;
|
|
375
|
+
gap: var(--nice-space-2, 8px);
|
|
376
|
+
border: 1px solid var(--nice-border, #e0e0e0);
|
|
377
|
+
border-radius: var(--nice-radius-md, 6px);
|
|
378
|
+
padding: var(--nice-space-2, 8px);
|
|
379
|
+
background: var(--nice-surface, #fff);
|
|
380
|
+
}
|
|
381
|
+
.nice-script-runner__toolbar {
|
|
382
|
+
display: flex;
|
|
383
|
+
align-items: center;
|
|
384
|
+
gap: var(--nice-space-2, 8px);
|
|
385
|
+
}
|
|
386
|
+
.nice-script-runner__run {
|
|
387
|
+
border: 0;
|
|
388
|
+
background: var(--nice-primary, #2563eb);
|
|
389
|
+
color: var(--nice-text-inverse, #fff);
|
|
390
|
+
border-radius: var(--nice-radius-sm, 4px);
|
|
391
|
+
padding: 6px 14px;
|
|
392
|
+
font: inherit;
|
|
393
|
+
font-weight: 600;
|
|
394
|
+
cursor: pointer;
|
|
395
|
+
}
|
|
396
|
+
.nice-script-runner__run:disabled {
|
|
397
|
+
opacity: 0.6;
|
|
398
|
+
cursor: default;
|
|
399
|
+
}
|
|
400
|
+
.nice-script-runner__status {
|
|
401
|
+
display: inline-flex;
|
|
402
|
+
align-items: center;
|
|
403
|
+
gap: var(--nice-space-2, 8px);
|
|
404
|
+
font-size: 12px;
|
|
405
|
+
}
|
|
406
|
+
.nice-script-runner__badge {
|
|
407
|
+
padding: 1px 8px;
|
|
408
|
+
border-radius: 999px;
|
|
409
|
+
font-size: 11px;
|
|
410
|
+
font-weight: 700;
|
|
411
|
+
}
|
|
412
|
+
.nice-script-runner__badge--ok {
|
|
413
|
+
background: var(--nice-success-bg, #dcfce7);
|
|
414
|
+
color: var(--nice-success-text, #166534);
|
|
415
|
+
}
|
|
416
|
+
.nice-script-runner__badge--error {
|
|
417
|
+
background: var(--nice-danger-bg, #fee2e2);
|
|
418
|
+
color: var(--nice-danger-text, #991b1b);
|
|
419
|
+
}
|
|
420
|
+
.nice-script-runner__duration {
|
|
421
|
+
color: var(--nice-text-muted, #9ca3af);
|
|
422
|
+
}
|
|
423
|
+
.nice-script-runner__panes {
|
|
424
|
+
display: grid;
|
|
425
|
+
gap: var(--nice-space-2, 8px);
|
|
426
|
+
}
|
|
427
|
+
.nice-script-runner--horizontal .nice-script-runner__panes {
|
|
428
|
+
grid-template-columns: 1fr 1fr;
|
|
429
|
+
}
|
|
430
|
+
.nice-script-runner__editors,
|
|
431
|
+
.nice-script-runner__output {
|
|
432
|
+
display: flex;
|
|
433
|
+
flex-direction: column;
|
|
434
|
+
gap: var(--nice-space-2, 8px);
|
|
435
|
+
min-width: 0;
|
|
436
|
+
}
|
|
437
|
+
.nice-script-runner__pane-label {
|
|
438
|
+
font-size: 11px;
|
|
439
|
+
font-weight: 600;
|
|
440
|
+
text-transform: uppercase;
|
|
441
|
+
letter-spacing: 0.04em;
|
|
442
|
+
color: var(--nice-text-secondary, #6b7280);
|
|
443
|
+
}
|
|
444
|
+
.nice-script-runner__input-error {
|
|
445
|
+
color: var(--nice-danger, #dc2626);
|
|
446
|
+
text-transform: none;
|
|
447
|
+
font-weight: 400;
|
|
448
|
+
}
|
|
449
|
+
.nice-script-runner__error {
|
|
450
|
+
padding: var(--nice-space-2, 8px);
|
|
451
|
+
border-radius: var(--nice-radius-sm, 4px);
|
|
452
|
+
background: var(--nice-danger-bg, #fee2e2);
|
|
453
|
+
color: var(--nice-danger-text, #991b1b);
|
|
454
|
+
font-family: 'Fira Code', 'Consolas', 'Monaco', monospace;
|
|
455
|
+
font-size: 12px;
|
|
456
|
+
white-space: pre-wrap;
|
|
457
|
+
}
|
|
458
|
+
.nice-script-runner__result-body {
|
|
459
|
+
margin: 4px 0 0;
|
|
460
|
+
padding: var(--nice-space-2, 8px);
|
|
461
|
+
border: 1px solid var(--nice-border, #e0e0e0);
|
|
462
|
+
border-radius: var(--nice-radius-sm, 4px);
|
|
463
|
+
background: var(--nice-bg-secondary, #f9fafb);
|
|
464
|
+
max-height: 200px;
|
|
465
|
+
overflow: auto;
|
|
466
|
+
font-family: 'Fira Code', 'Consolas', 'Monaco', monospace;
|
|
467
|
+
font-size: 12px;
|
|
468
|
+
}
|
|
469
|
+
`,document.head.appendChild(t)}const Fi=[{target:".nice-key-value-editor",titleKey:"tutorial.keyValueEditor.intro.title",title:"Key/value editor",contentKey:"tutorial.keyValueEditor.intro.content",content:"Add key/value rows for headers, params, env vars or config; mask secret values, toggle rows on/off, and watch for duplicate keys.",placement:"auto"}],Ki=n.forwardRef(function(i,o){const{value:a,onChange:l,allowSecret:u=!1,allowToggle:_=!1,allowDescription:g=!1,keySuggestions:A,keyPlaceholder:E="Key",valuePlaceholder:Y="Value",addLabel:F="Add",readOnly:$=!1,duplicateKeyWarning:T=!0,tutorial:G,className:ie,style:V,id:ee,"data-testid":M}=i,f=n.useMemo(()=>`nice-kv-keys-${Math.random().toString(36).slice(2,9)}`,[]),O=n.useMemo(()=>{const b=new Map,S=new Set;if(T){for(const U of a){const k=U.key.trim();k!==""&&b.set(k,(b.get(k)??0)+1)}b.forEach((U,k)=>{U>1&&S.add(k)})}return S},[a,T]),y=(b,S)=>{l(a.map((U,k)=>k===b?{...U,...S}:U))},I=b=>{l(a.filter((S,U)=>U!==b))},B=()=>{l([...a,{key:"",value:"",type:"text",enabled:!0}])},r="nice-key-value-editor"+(ie?` ${ie}`:"");return e.jsxs("div",{ref:o,id:ee,className:r,style:{position:"relative",...V},"data-testid":M,children:[e.jsx("span",{style:{position:"absolute",top:0,right:0,zIndex:20},children:e.jsx(v.Ql,{steps:v.Yl(G,Fi)})}),A&&A.length>0&&e.jsx("datalist",{id:f,children:A.map(b=>e.jsx("option",{value:b},b))}),e.jsx("div",{className:"nice-key-value-editor__rows",children:a.map((b,S)=>{const U=b.type==="secret",k=b.key.trim()!==""&&O.has(b.key.trim()),j=_&&b.enabled===!1;return e.jsxs("div",{className:"nice-key-value-editor__row"+(j?" nice-key-value-editor__row--disabled":""),children:[_&&e.jsx("input",{type:"checkbox",className:"nice-key-value-editor__toggle",checked:b.enabled!==!1,onChange:c=>y(S,{enabled:c.target.checked}),disabled:$,"aria-label":"Enabled"}),e.jsx("input",{type:"text",className:"nice-key-value-editor__key"+(k?" nice-key-value-editor__key--dup":""),value:b.key,list:A?f:void 0,placeholder:E,onChange:c=>y(S,{key:c.target.value}),readOnly:$,"aria-label":E,title:k?"Duplicate key":void 0}),e.jsx("input",{type:U?"password":"text",className:"nice-key-value-editor__value",value:b.value,placeholder:Y,onChange:c=>y(S,{value:c.target.value}),readOnly:$,autoComplete:U?"new-password":"off","aria-label":Y}),u&&e.jsx("button",{type:"button",className:"nice-key-value-editor__secret"+(U?" nice-key-value-editor__secret--on":""),onClick:()=>y(S,{type:U?"text":"secret"}),disabled:$,title:U?"Secret (click to reveal as text)":"Mark as secret","aria-pressed":U,"aria-label":"Toggle secret",children:e.jsx(v.oa,{name:"lock",size:16})}),g&&e.jsx("input",{type:"text",className:"nice-key-value-editor__desc",value:b.description??"",placeholder:"Description",onChange:c=>y(S,{description:c.target.value}),readOnly:$,"aria-label":"Description"}),!$&&e.jsx("button",{type:"button",className:"nice-key-value-editor__remove",onClick:()=>I(S),title:"Remove row","aria-label":"Remove row",children:e.jsx(v.oa,{name:"close",size:14})})]},b.id??S)})}),!$&&e.jsxs("button",{type:"button",className:"nice-key-value-editor__add",onClick:B,children:["+ ",F]})]})}),Zt="nice-key-value-editor-styles";if(typeof document<"u"&&!document.getElementById(Zt)){const t=document.createElement("style");t.id=Zt,t.textContent=`
|
|
470
|
+
.nice-key-value-editor {
|
|
471
|
+
display: flex;
|
|
472
|
+
flex-direction: column;
|
|
473
|
+
gap: var(--nice-space-2, 8px);
|
|
474
|
+
}
|
|
475
|
+
.nice-key-value-editor__rows {
|
|
476
|
+
display: flex;
|
|
477
|
+
flex-direction: column;
|
|
478
|
+
gap: var(--nice-space-1, 4px);
|
|
479
|
+
}
|
|
480
|
+
.nice-key-value-editor__row {
|
|
481
|
+
display: flex;
|
|
482
|
+
align-items: center;
|
|
483
|
+
gap: var(--nice-space-1, 4px);
|
|
484
|
+
}
|
|
485
|
+
.nice-key-value-editor__row--disabled {
|
|
486
|
+
opacity: 0.55;
|
|
487
|
+
}
|
|
488
|
+
.nice-key-value-editor__key,
|
|
489
|
+
.nice-key-value-editor__value,
|
|
490
|
+
.nice-key-value-editor__desc {
|
|
491
|
+
flex: 1 1 0;
|
|
492
|
+
min-width: 0;
|
|
493
|
+
padding: 6px 8px;
|
|
494
|
+
border: 1px solid var(--nice-border, #d1d5db);
|
|
495
|
+
border-radius: var(--nice-radius-sm, 4px);
|
|
496
|
+
background: var(--nice-bg, #fff);
|
|
497
|
+
color: var(--nice-text-primary, #1f2937);
|
|
498
|
+
font: inherit;
|
|
499
|
+
font-size: 13px;
|
|
500
|
+
}
|
|
501
|
+
.nice-key-value-editor__key {
|
|
502
|
+
flex-basis: 30%;
|
|
503
|
+
font-family: 'Fira Code', 'Consolas', 'Monaco', monospace;
|
|
504
|
+
}
|
|
505
|
+
.nice-key-value-editor__key--dup {
|
|
506
|
+
border-color: var(--nice-danger, #dc2626);
|
|
507
|
+
background: var(--nice-danger-bg, #fee2e2);
|
|
508
|
+
}
|
|
509
|
+
.nice-key-value-editor__key:focus,
|
|
510
|
+
.nice-key-value-editor__value:focus,
|
|
511
|
+
.nice-key-value-editor__desc:focus {
|
|
512
|
+
outline: none;
|
|
513
|
+
border-color: var(--nice-primary, #2563eb);
|
|
514
|
+
}
|
|
515
|
+
.nice-key-value-editor__toggle {
|
|
516
|
+
flex: 0 0 auto;
|
|
517
|
+
}
|
|
518
|
+
.nice-key-value-editor__secret,
|
|
519
|
+
.nice-key-value-editor__remove {
|
|
520
|
+
flex: 0 0 auto;
|
|
521
|
+
border: 1px solid var(--nice-border, #d1d5db);
|
|
522
|
+
background: var(--nice-surface, #fff);
|
|
523
|
+
border-radius: var(--nice-radius-sm, 4px);
|
|
524
|
+
padding: 5px 8px;
|
|
525
|
+
font-size: 13px;
|
|
526
|
+
line-height: 1;
|
|
527
|
+
cursor: pointer;
|
|
528
|
+
}
|
|
529
|
+
.nice-key-value-editor__secret--on {
|
|
530
|
+
border-color: var(--nice-warning, #d97706);
|
|
531
|
+
background: var(--nice-warning-bg, #fef3c7);
|
|
532
|
+
}
|
|
533
|
+
.nice-key-value-editor__remove:hover {
|
|
534
|
+
border-color: var(--nice-danger, #dc2626);
|
|
535
|
+
color: var(--nice-danger, #dc2626);
|
|
536
|
+
}
|
|
537
|
+
.nice-key-value-editor__add {
|
|
538
|
+
align-self: flex-start;
|
|
539
|
+
border: 1px dashed var(--nice-border, #d1d5db);
|
|
540
|
+
background: transparent;
|
|
541
|
+
color: var(--nice-primary, #2563eb);
|
|
542
|
+
border-radius: var(--nice-radius-sm, 4px);
|
|
543
|
+
padding: 5px 12px;
|
|
544
|
+
font: inherit;
|
|
545
|
+
font-size: 13px;
|
|
546
|
+
font-weight: 600;
|
|
547
|
+
cursor: pointer;
|
|
548
|
+
}
|
|
549
|
+
.nice-key-value-editor__add:hover {
|
|
550
|
+
background: var(--nice-bg-secondary, #f5f5f5);
|
|
551
|
+
}
|
|
552
|
+
`,document.head.appendChild(t)}function en(t,i){const o=i.getBoundingClientRect();let a,l,u;if("touches"in t){const _=t.touches[0];a=_.clientX-o.left,l=_.clientY-o.top,u=_.force}else"pressure"in t?(a=t.clientX-o.left,l=t.clientY-o.top,u=t.pressure):(a=t.clientX-o.left,l=t.clientY-o.top);return{x:a,y:l,time:Date.now(),pressure:u!==void 0?u:.5}}function tn(t,i,o,a,l){if(!i)return(o+a)/2;const u=Math.sqrt(Math.pow(t.x-i.x,2)+Math.pow(t.y-i.y,2))/Math.max(1,t.time-i.time),_=Math.min(u/5,1),g=a-_*(a-o),A=t.pressure??.5,E=o+A*(a-o);return g*.7+E*.3}function nn(t,i,o,a){t.beginPath(),t.moveTo(i.x,i.y),t.lineTo(o.x,o.y),t.lineWidth=a,t.lineCap="round",t.lineJoin="round",t.stroke()}const Yi=n.forwardRef(function(i,o){const{value:a,onChange:l,onChangeDataUrl:u,label:_,width:g="100%",height:A=200,penColor:E="",penWidth:Y=2,minWidth:F=.5,maxWidth:$=4,backgroundColor:T="",placeholder:G,showClearButton:ie=!0,showUndoButton:V=!0,showColorPicker:ee=!1,showSizeSlider:M=!1,velocityFilterWeight:f=.7,throttle:O=16,disabled:y=!1,readOnly:I=!1,displayMode:B=!1,onBegin:r,onEnd:b,className:S,"data-testid":U}=i,{t:k}=v.Gt(),j=G||k("signature.placeholder","Sign here"),c=I||B,z=B?!1:ie,R=B?!1:V,p=B?!1:ee,d=B?!1:M,m=n.useRef(null),[x,D]=n.useState(a?.strokes??[]),[N,H]=n.useState([]),[L,Q]=n.useState(!1),[w,K]=n.useState(E),[Z,pe]=n.useState(Y),q=n.useRef(null),ne=n.useRef(0),re=v.gu(m),ue=T||(re?"#0f172a":"#ffffff"),je=E||(re?"#f8fafc":"#111827"),J=w||je,ge=x.length===0&&N.length===0;n.useEffect(()=>{const de=m.current;if(!de)return;const ae=de.getContext("2d");if(!ae)return;const be=de.getBoundingClientRect(),he=window.devicePixelRatio||1;de.width=be.width*he,de.height=be.height*he,ae.scale(he,he),ye()},[g,A]);const ye=n.useCallback(()=>{const de=m.current;if(!de)return;const ae=de.getContext("2d");if(!ae)return;const be=de.getBoundingClientRect();ae.fillStyle=ue,ae.fillRect(0,0,be.width,be.height),x.forEach(he=>{if(ae.strokeStyle=he.color||je,!(he.points.length<2))for(let Ce=1;Ce<he.points.length;Ce++){const Me=he.points[Ce-1],$e=he.points[Ce],Te=tn($e,Me,F,$);nn(ae,Me,$e,Te)}})},[x,ue,je,F,$,f]);n.useEffect(()=>{ye()},[ye]),n.useEffect(()=>{a?.strokes&&D(a.strokes)},[a]),n.useEffect(()=>{const de=m.current;if(de)if(x.length===0)l?.(null),u?.(null);else{const ae=de.getBoundingClientRect();l?.({strokes:x,width:ae.width,height:ae.height,timestamp:Date.now()}),u?.(de.toDataURL("image/png"))}},[x,l,u]);const se=n.useCallback(de=>{if(y||c)return;const ae=m.current;if(!ae)return;ae.setPointerCapture(de.pointerId);const be=en(de.nativeEvent,ae);Q(!0),H([be]),q.current=be,ne.current=be.time,r?.()},[y,c,r]),me=n.useCallback(de=>{if(!L||y||c)return;const ae=m.current;if(!ae)return;const be=ae.getContext("2d");if(!be)return;const he=Date.now();if(he-ne.current<O)return;const Ce=en(de.nativeEvent,ae),Me=q.current;if(Me){be.strokeStyle=J;const $e=tn(Ce,Me,F,$);nn(be,Me,Ce,$e)}H($e=>[...$e,Ce]),q.current=Ce,ne.current=he},[L,y,c,J,F,$,f,O]),fe=n.useCallback(de=>{if(!L)return;const ae=m.current;if(ae&&ae.releasePointerCapture(de.pointerId),N.length>0){const be={points:N,color:J,width:Z};D(he=>[...he,be])}Q(!1),H([]),q.current=null,b?.()},[L,N,J,Z,b]),W=n.useCallback(()=>{D([]),H([]),ye()},[ye]),h=n.useCallback(()=>{D(de=>de.slice(0,-1))},[]),P=n.useCallback((de="png",ae=.92)=>{const be=m.current;if(!be)return"";const he=de==="jpeg"?"image/jpeg":"image/png";return be.toDataURL(he,ae)},[]),ce=n.useCallback(async(de="png",ae=.92)=>{const be=m.current;return be?new Promise(he=>{const Ce=de==="jpeg"?"image/jpeg":"image/png";be.toBlob(Me=>he(Me),Ce,ae)}):null},[]),oe=n.useCallback(()=>{const de=m.current;if(!de)return"";const ae=de.getBoundingClientRect(),be=x.map(he=>he.points.length<2?"":`<path d="${he.points.reduce((Me,$e,Te)=>Te===0?`M ${$e.x} ${$e.y}`:`${Me} L ${$e.x} ${$e.y}`,"")}" stroke="${he.color||je}" stroke-width="${he.width}" fill="none" stroke-linecap="round" stroke-linejoin="round"/>`).join(`
|
|
553
|
+
`);return`<svg xmlns="http://www.w3.org/2000/svg" width="${ae.width}" height="${ae.height}" viewBox="0 0 ${de.width} ${de.height}">
|
|
554
|
+
<rect width="100%" height="100%" fill="${ue}"/>
|
|
555
|
+
${be}
|
|
556
|
+
</svg>`},[x,ue,je]);n.useImperativeHandle(o,()=>({clear:W,undo:h,isEmpty:()=>x.length===0,getData:()=>{const de=m.current;if(!de||x.length===0)return null;const ae=de.getBoundingClientRect();return{strokes:x,width:ae.width,height:ae.height,timestamp:Date.now()}},setData:de=>{D(de.strokes)},toDataURL:P,toBlob:ce,toSVG:oe,getCanvas:()=>m.current}),[x,W,h,P,ce,oe]),n.useEffect(()=>{const de=m.current;if(!de)return;const ae=be=>{L&&be.preventDefault()};return de.addEventListener("touchmove",ae,{passive:!1}),()=>de.removeEventListener("touchmove",ae)},[L]);const ke=z||R||p||d;return e.jsxs("div",{className:`nice-signature ${y?"nice-signature--disabled":""} ${c?"nice-signature--readonly":""} ${S??""}`,style:{width:g},"data-testid":U,children:[_&&e.jsx("label",{className:"nice-signature__label",children:_}),ke&&e.jsxs("div",{className:"nice-signature__toolbar",children:[p&&e.jsx("div",{className:"nice-signature__color-picker",children:e.jsx("input",{type:"color",value:w,onChange:de=>K(de.target.value),disabled:y||c,title:"Pen color"})}),d&&e.jsx("div",{className:"nice-signature__size-slider",children:e.jsx("input",{type:"range",min:F,max:$,step:.5,value:Z,onChange:de=>pe(parseFloat(de.target.value)),disabled:y||c,title:"Pen size"})}),e.jsxs("div",{className:"nice-signature__actions",children:[R&&e.jsx("button",{type:"button",onClick:h,disabled:y||c||x.length===0,className:"nice-signature__btn",title:"Undo","aria-label":"Undo",children:e.jsx(v.oa,{name:"reply",size:16})}),z&&e.jsx("button",{type:"button",onClick:W,disabled:y||c||ge,className:"nice-signature__btn",title:"Clear","aria-label":"Clear",children:e.jsx(v.oa,{name:"trash",size:16})})]})]}),e.jsxs("div",{className:"nice-signature__canvas-wrapper",style:{height:A},children:[e.jsx("canvas",{ref:m,className:"nice-signature__canvas",style:{width:"100%",height:"100%",cursor:y||c?"not-allowed":"crosshair",touchAction:"none"},onPointerDown:se,onPointerMove:me,onPointerUp:fe,onPointerLeave:fe}),ge&&!L&&j&&e.jsx("div",{className:"nice-signature__placeholder",children:j}),e.jsx("div",{className:"nice-signature__line"})]})]})}),on="nice-signature-styles";if(typeof document<"u"&&!document.getElementById(on)){const t=document.createElement("style");t.id=on,t.textContent=`
|
|
557
|
+
.nice-signature {
|
|
558
|
+
display: flex;
|
|
559
|
+
flex-direction: column;
|
|
560
|
+
border: 1px solid var(--nice-border, #e0e0e0);
|
|
561
|
+
border-radius: var(--nice-radius-sm, 4px);
|
|
562
|
+
overflow: hidden;
|
|
563
|
+
background: var(--nice-bg-surface, #fff);
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
.nice-signature--disabled {
|
|
567
|
+
opacity: 0.6;
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
.nice-signature__toolbar {
|
|
571
|
+
display: flex;
|
|
572
|
+
align-items: center;
|
|
573
|
+
gap: var(--nice-space-2, 8px);
|
|
574
|
+
padding: var(--nice-space-2, 8px);
|
|
575
|
+
background: var(--nice-bg-muted, #f5f5f5);
|
|
576
|
+
border-bottom: 1px solid var(--nice-border, #e0e0e0);
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
.nice-signature__color-picker input {
|
|
580
|
+
width: 32px;
|
|
581
|
+
height: 32px;
|
|
582
|
+
padding: var(--nice-space-0-5, 2px);
|
|
583
|
+
border: 1px solid var(--nice-border, #e0e0e0);
|
|
584
|
+
border-radius: var(--nice-radius-sm, 4px);
|
|
585
|
+
cursor: pointer;
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
.nice-signature__size-slider {
|
|
589
|
+
flex: 1;
|
|
590
|
+
max-width: 120px;
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
.nice-signature__size-slider input {
|
|
594
|
+
width: 100%;
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
.nice-signature__actions {
|
|
598
|
+
display: flex;
|
|
599
|
+
gap: var(--nice-space-1, 4px);
|
|
600
|
+
margin-left: auto;
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
.nice-signature__btn {
|
|
604
|
+
padding: var(--nice-space-1-5, 6px) var(--nice-space-2-5, 10px);
|
|
605
|
+
border: 1px solid var(--nice-border, #e0e0e0);
|
|
606
|
+
border-radius: var(--nice-radius-sm, 4px);
|
|
607
|
+
background: var(--nice-bg-surface, #fff);
|
|
608
|
+
cursor: pointer;
|
|
609
|
+
font-size: 14px;
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
.nice-signature__btn:hover:not(:disabled) {
|
|
613
|
+
background: var(--nice-bg-hover, #f0f0f0);
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
.nice-signature__btn:disabled {
|
|
617
|
+
opacity: 0.4;
|
|
618
|
+
cursor: not-allowed;
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
.nice-signature__canvas-wrapper {
|
|
622
|
+
position: relative;
|
|
623
|
+
background: var(--nice-bg, #FFF);
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
.nice-signature__canvas {
|
|
627
|
+
display: block;
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
.nice-signature__placeholder {
|
|
631
|
+
position: absolute;
|
|
632
|
+
top: 50%;
|
|
633
|
+
left: 50%;
|
|
634
|
+
transform: translate(-50%, -50%);
|
|
635
|
+
color: var(--nice-text-secondary, #999);
|
|
636
|
+
font-size: 14px;
|
|
637
|
+
pointer-events: none;
|
|
638
|
+
user-select: none;
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
.nice-signature__line {
|
|
642
|
+
position: absolute;
|
|
643
|
+
/* Sit in the lower third (a natural signature baseline) rather than pinned to
|
|
644
|
+
the very bottom. */
|
|
645
|
+
bottom: 64px;
|
|
646
|
+
left: 20px;
|
|
647
|
+
right: 20px;
|
|
648
|
+
height: 1px;
|
|
649
|
+
background: var(--nice-border, #ccc);
|
|
650
|
+
pointer-events: none;
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
/* Display component */
|
|
654
|
+
.nice-signature-display {
|
|
655
|
+
border: 1px solid var(--nice-border, #e0e0e0);
|
|
656
|
+
border-radius: var(--nice-radius-sm, 4px);
|
|
657
|
+
overflow: hidden;
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
.nice-signature-display__canvas-wrapper {
|
|
661
|
+
position: relative;
|
|
662
|
+
background: var(--nice-bg, #FFF);
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
.nice-signature-display__canvas {
|
|
666
|
+
display: block;
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
.nice-signature-display__placeholder {
|
|
670
|
+
position: absolute;
|
|
671
|
+
top: 50%;
|
|
672
|
+
left: 50%;
|
|
673
|
+
transform: translate(-50%, -50%);
|
|
674
|
+
color: var(--nice-text-secondary, #999);
|
|
675
|
+
font-size: 14px;
|
|
676
|
+
}
|
|
677
|
+
`,document.head.appendChild(t)}const Ui={recent:"🕒",smileys:"😀",people:"👋",animals:"🐱",food:"🍕",travel:"✈️",activities:"⚽",objects:"💡",symbols:"❤️",flags:"🏳️"},an={recent:"Recently Used",smileys:"Smileys & Emotion",people:"People & Body",animals:"Animals & Nature",food:"Food & Drink",travel:"Travel & Places",activities:"Activities",objects:"Objects",symbols:"Symbols",flags:"Flags"},Mt=["","🏻","🏼","🏽","🏾","🏿"],jt=[{emoji:"😀",name:"grinning face",category:"smileys",keywords:["happy","smile"]},{emoji:"😃",name:"grinning face with big eyes",category:"smileys"},{emoji:"😄",name:"grinning face with smiling eyes",category:"smileys"},{emoji:"😁",name:"beaming face",category:"smileys"},{emoji:"😅",name:"grinning face with sweat",category:"smileys"},{emoji:"🤣",name:"rolling on the floor laughing",category:"smileys",keywords:["rofl"]},{emoji:"😂",name:"face with tears of joy",category:"smileys",keywords:["lol","laugh"]},{emoji:"🙂",name:"slightly smiling face",category:"smileys"},{emoji:"😉",name:"winking face",category:"smileys",keywords:["wink"]},{emoji:"😊",name:"smiling face with smiling eyes",category:"smileys"},{emoji:"😇",name:"smiling face with halo",category:"smileys",keywords:["angel"]},{emoji:"🥰",name:"smiling face with hearts",category:"smileys",keywords:["love"]},{emoji:"😍",name:"smiling face with heart-eyes",category:"smileys"},{emoji:"🤩",name:"star-struck",category:"smileys",keywords:["wow"]},{emoji:"😘",name:"face blowing a kiss",category:"smileys",keywords:["kiss"]},{emoji:"😗",name:"kissing face",category:"smileys"},{emoji:"😚",name:"kissing face with closed eyes",category:"smileys"},{emoji:"😋",name:"face savoring food",category:"smileys",keywords:["yum"]},{emoji:"😛",name:"face with tongue",category:"smileys"},{emoji:"😜",name:"winking face with tongue",category:"smileys"},{emoji:"🤪",name:"zany face",category:"smileys",keywords:["crazy"]},{emoji:"😝",name:"squinting face with tongue",category:"smileys"},{emoji:"🤑",name:"money-mouth face",category:"smileys"},{emoji:"🤗",name:"hugging face",category:"smileys",keywords:["hug"]},{emoji:"🤭",name:"face with hand over mouth",category:"smileys"},{emoji:"🤫",name:"shushing face",category:"smileys",keywords:["quiet"]},{emoji:"🤔",name:"thinking face",category:"smileys",keywords:["think","hmm"]},{emoji:"🤐",name:"zipper-mouth face",category:"smileys"},{emoji:"🤨",name:"face with raised eyebrow",category:"smileys"},{emoji:"😐",name:"neutral face",category:"smileys"},{emoji:"😑",name:"expressionless face",category:"smileys"},{emoji:"😶",name:"face without mouth",category:"smileys"},{emoji:"😏",name:"smirking face",category:"smileys",keywords:["smirk"]},{emoji:"😒",name:"unamused face",category:"smileys"},{emoji:"🙄",name:"face with rolling eyes",category:"smileys"},{emoji:"😬",name:"grimacing face",category:"smileys"},{emoji:"😮💨",name:"face exhaling",category:"smileys"},{emoji:"🤥",name:"lying face",category:"smileys"},{emoji:"😌",name:"relieved face",category:"smileys"},{emoji:"😔",name:"pensive face",category:"smileys",keywords:["sad"]},{emoji:"😪",name:"sleepy face",category:"smileys"},{emoji:"🤤",name:"drooling face",category:"smileys"},{emoji:"😴",name:"sleeping face",category:"smileys",keywords:["sleep","zzz"]},{emoji:"😷",name:"face with medical mask",category:"smileys",keywords:["sick"]},{emoji:"🤒",name:"face with thermometer",category:"smileys"},{emoji:"🤕",name:"face with head-bandage",category:"smileys"},{emoji:"🤢",name:"nauseated face",category:"smileys"},{emoji:"🤮",name:"face vomiting",category:"smileys"},{emoji:"🤧",name:"sneezing face",category:"smileys"},{emoji:"🥵",name:"hot face",category:"smileys"},{emoji:"🥶",name:"cold face",category:"smileys"},{emoji:"🥴",name:"woozy face",category:"smileys",keywords:["drunk"]},{emoji:"😵",name:"face with crossed-out eyes",category:"smileys"},{emoji:"🤯",name:"exploding head",category:"smileys",keywords:["mind blown"]},{emoji:"🤠",name:"cowboy hat face",category:"smileys"},{emoji:"🥳",name:"partying face",category:"smileys",keywords:["party"]},{emoji:"🥸",name:"disguised face",category:"smileys"},{emoji:"😎",name:"smiling face with sunglasses",category:"smileys",keywords:["cool"]},{emoji:"🤓",name:"nerd face",category:"smileys",keywords:["nerd"]},{emoji:"🧐",name:"face with monocle",category:"smileys"},{emoji:"😕",name:"confused face",category:"smileys"},{emoji:"😟",name:"worried face",category:"smileys"},{emoji:"🙁",name:"slightly frowning face",category:"smileys"},{emoji:"☹️",name:"frowning face",category:"smileys"},{emoji:"😮",name:"face with open mouth",category:"smileys",keywords:["surprised"]},{emoji:"😯",name:"hushed face",category:"smileys"},{emoji:"😲",name:"astonished face",category:"smileys"},{emoji:"😳",name:"flushed face",category:"smileys"},{emoji:"🥺",name:"pleading face",category:"smileys"},{emoji:"😦",name:"frowning face with open mouth",category:"smileys"},{emoji:"😧",name:"anguished face",category:"smileys"},{emoji:"😨",name:"fearful face",category:"smileys"},{emoji:"😰",name:"anxious face with sweat",category:"smileys"},{emoji:"😥",name:"sad but relieved face",category:"smileys"},{emoji:"😢",name:"crying face",category:"smileys",keywords:["cry"]},{emoji:"😭",name:"loudly crying face",category:"smileys",keywords:["sob"]},{emoji:"😱",name:"face screaming in fear",category:"smileys",keywords:["scream"]},{emoji:"😖",name:"confounded face",category:"smileys"},{emoji:"😣",name:"persevering face",category:"smileys"},{emoji:"😞",name:"disappointed face",category:"smileys"},{emoji:"😓",name:"downcast face with sweat",category:"smileys"},{emoji:"😩",name:"weary face",category:"smileys"},{emoji:"😫",name:"tired face",category:"smileys"},{emoji:"🥱",name:"yawning face",category:"smileys"},{emoji:"😤",name:"face with steam from nose",category:"smileys",keywords:["angry"]},{emoji:"😡",name:"pouting face",category:"smileys",keywords:["rage"]},{emoji:"😠",name:"angry face",category:"smileys"},{emoji:"🤬",name:"face with symbols on mouth",category:"smileys",keywords:["swear"]},{emoji:"😈",name:"smiling face with horns",category:"smileys",keywords:["devil"]},{emoji:"👿",name:"angry face with horns",category:"smileys"},{emoji:"💀",name:"skull",category:"smileys",keywords:["dead"]},{emoji:"☠️",name:"skull and crossbones",category:"smileys"},{emoji:"💩",name:"pile of poo",category:"smileys",keywords:["poop"]},{emoji:"🤡",name:"clown face",category:"smileys"},{emoji:"👹",name:"ogre",category:"smileys"},{emoji:"👺",name:"goblin",category:"smileys"},{emoji:"👻",name:"ghost",category:"smileys"},{emoji:"👽",name:"alien",category:"smileys"},{emoji:"👾",name:"alien monster",category:"smileys"},{emoji:"🤖",name:"robot",category:"smileys"},{emoji:"👋",name:"waving hand",category:"people",skinTones:!0,keywords:["wave","hi"]},{emoji:"🤚",name:"raised back of hand",category:"people",skinTones:!0},{emoji:"🖐️",name:"hand with fingers splayed",category:"people",skinTones:!0},{emoji:"✋",name:"raised hand",category:"people",skinTones:!0},{emoji:"🖖",name:"vulcan salute",category:"people",skinTones:!0},{emoji:"👌",name:"ok hand",category:"people",skinTones:!0,keywords:["ok","perfect"]},{emoji:"🤌",name:"pinched fingers",category:"people",skinTones:!0},{emoji:"🤏",name:"pinching hand",category:"people",skinTones:!0},{emoji:"✌️",name:"victory hand",category:"people",skinTones:!0,keywords:["peace"]},{emoji:"🤞",name:"crossed fingers",category:"people",skinTones:!0},{emoji:"🤟",name:"love-you gesture",category:"people",skinTones:!0},{emoji:"🤘",name:"sign of the horns",category:"people",skinTones:!0,keywords:["rock"]},{emoji:"🤙",name:"call me hand",category:"people",skinTones:!0},{emoji:"👈",name:"backhand index pointing left",category:"people",skinTones:!0},{emoji:"👉",name:"backhand index pointing right",category:"people",skinTones:!0},{emoji:"👆",name:"backhand index pointing up",category:"people",skinTones:!0},{emoji:"🖕",name:"middle finger",category:"people",skinTones:!0},{emoji:"👇",name:"backhand index pointing down",category:"people",skinTones:!0},{emoji:"☝️",name:"index pointing up",category:"people",skinTones:!0},{emoji:"👍",name:"thumbs up",category:"people",skinTones:!0,keywords:["like","good"]},{emoji:"👎",name:"thumbs down",category:"people",skinTones:!0,keywords:["dislike","bad"]},{emoji:"✊",name:"raised fist",category:"people",skinTones:!0},{emoji:"👊",name:"oncoming fist",category:"people",skinTones:!0},{emoji:"🤛",name:"left-facing fist",category:"people",skinTones:!0},{emoji:"🤜",name:"right-facing fist",category:"people",skinTones:!0},{emoji:"👏",name:"clapping hands",category:"people",skinTones:!0,keywords:["clap","applause"]},{emoji:"🙌",name:"raising hands",category:"people",skinTones:!0},{emoji:"👐",name:"open hands",category:"people",skinTones:!0},{emoji:"🤲",name:"palms up together",category:"people",skinTones:!0},{emoji:"🤝",name:"handshake",category:"people",skinTones:!0},{emoji:"🙏",name:"folded hands",category:"people",skinTones:!0,keywords:["pray","please"]},{emoji:"✍️",name:"writing hand",category:"people",skinTones:!0},{emoji:"💪",name:"flexed biceps",category:"people",skinTones:!0,keywords:["strong","muscle"]},{emoji:"🐶",name:"dog face",category:"animals",keywords:["dog"]},{emoji:"🐱",name:"cat face",category:"animals",keywords:["cat"]},{emoji:"🐭",name:"mouse face",category:"animals"},{emoji:"🐹",name:"hamster",category:"animals"},{emoji:"🐰",name:"rabbit face",category:"animals"},{emoji:"🦊",name:"fox",category:"animals"},{emoji:"🐻",name:"bear",category:"animals"},{emoji:"🐼",name:"panda",category:"animals"},{emoji:"🐨",name:"koala",category:"animals"},{emoji:"🐯",name:"tiger face",category:"animals"},{emoji:"🦁",name:"lion",category:"animals"},{emoji:"🐮",name:"cow face",category:"animals"},{emoji:"🐷",name:"pig face",category:"animals",keywords:["pig"]},{emoji:"🐸",name:"frog",category:"animals"},{emoji:"🐵",name:"monkey face",category:"animals"},{emoji:"🙈",name:"see-no-evil monkey",category:"animals"},{emoji:"🙉",name:"hear-no-evil monkey",category:"animals"},{emoji:"🙊",name:"speak-no-evil monkey",category:"animals"},{emoji:"🐔",name:"chicken",category:"animals"},{emoji:"🐧",name:"penguin",category:"animals"},{emoji:"🐦",name:"bird",category:"animals"},{emoji:"🐤",name:"baby chick",category:"animals"},{emoji:"🦆",name:"duck",category:"animals"},{emoji:"🦅",name:"eagle",category:"animals"},{emoji:"🦉",name:"owl",category:"animals"},{emoji:"🦇",name:"bat",category:"animals"},{emoji:"🐺",name:"wolf",category:"animals"},{emoji:"🐗",name:"boar",category:"animals"},{emoji:"🐴",name:"horse face",category:"animals"},{emoji:"🦄",name:"unicorn",category:"animals"},{emoji:"🐝",name:"honeybee",category:"animals",keywords:["bee"]},{emoji:"🐛",name:"bug",category:"animals"},{emoji:"🦋",name:"butterfly",category:"animals"},{emoji:"🐌",name:"snail",category:"animals"},{emoji:"🐙",name:"octopus",category:"animals"},{emoji:"🐬",name:"dolphin",category:"animals"},{emoji:"🐳",name:"spouting whale",category:"animals",keywords:["whale"]},{emoji:"🦈",name:"shark",category:"animals"},{emoji:"🐊",name:"crocodile",category:"animals"},{emoji:"🐢",name:"turtle",category:"animals"},{emoji:"🐍",name:"snake",category:"animals"},{emoji:"🦎",name:"lizard",category:"animals"},{emoji:"🐲",name:"dragon face",category:"animals",keywords:["dragon"]},{emoji:"🌸",name:"cherry blossom",category:"animals",keywords:["flower"]},{emoji:"🌹",name:"rose",category:"animals"},{emoji:"🌻",name:"sunflower",category:"animals"},{emoji:"🌺",name:"hibiscus",category:"animals"},{emoji:"🌷",name:"tulip",category:"animals"},{emoji:"🌲",name:"evergreen tree",category:"animals",keywords:["tree"]},{emoji:"🌳",name:"deciduous tree",category:"animals"},{emoji:"🌴",name:"palm tree",category:"animals"},{emoji:"🌵",name:"cactus",category:"animals"},{emoji:"🍀",name:"four leaf clover",category:"animals",keywords:["lucky"]},{emoji:"🍎",name:"red apple",category:"food",keywords:["apple"]},{emoji:"🍊",name:"tangerine",category:"food",keywords:["orange"]},{emoji:"🍋",name:"lemon",category:"food"},{emoji:"🍌",name:"banana",category:"food"},{emoji:"🍉",name:"watermelon",category:"food"},{emoji:"🍇",name:"grapes",category:"food"},{emoji:"🍓",name:"strawberry",category:"food"},{emoji:"🍒",name:"cherries",category:"food"},{emoji:"🍑",name:"peach",category:"food"},{emoji:"🥭",name:"mango",category:"food"},{emoji:"🍍",name:"pineapple",category:"food"},{emoji:"🥝",name:"kiwi fruit",category:"food"},{emoji:"🍅",name:"tomato",category:"food"},{emoji:"🥑",name:"avocado",category:"food"},{emoji:"🥦",name:"broccoli",category:"food"},{emoji:"🥬",name:"leafy green",category:"food"},{emoji:"🥒",name:"cucumber",category:"food"},{emoji:"🌽",name:"ear of corn",category:"food",keywords:["corn"]},{emoji:"🥕",name:"carrot",category:"food"},{emoji:"🧄",name:"garlic",category:"food"},{emoji:"🧅",name:"onion",category:"food"},{emoji:"🥔",name:"potato",category:"food"},{emoji:"🍞",name:"bread",category:"food"},{emoji:"🥐",name:"croissant",category:"food"},{emoji:"🥖",name:"baguette bread",category:"food"},{emoji:"🧀",name:"cheese wedge",category:"food",keywords:["cheese"]},{emoji:"🥚",name:"egg",category:"food"},{emoji:"🍳",name:"cooking",category:"food",keywords:["egg","breakfast"]},{emoji:"🥓",name:"bacon",category:"food"},{emoji:"🥩",name:"cut of meat",category:"food",keywords:["steak"]},{emoji:"🍗",name:"poultry leg",category:"food",keywords:["chicken"]},{emoji:"🍖",name:"meat on bone",category:"food"},{emoji:"🌭",name:"hot dog",category:"food"},{emoji:"🍔",name:"hamburger",category:"food",keywords:["burger"]},{emoji:"🍟",name:"french fries",category:"food",keywords:["fries"]},{emoji:"🍕",name:"pizza",category:"food"},{emoji:"🥪",name:"sandwich",category:"food"},{emoji:"🌮",name:"taco",category:"food"},{emoji:"🌯",name:"burrito",category:"food"},{emoji:"🥗",name:"green salad",category:"food",keywords:["salad"]},{emoji:"🍝",name:"spaghetti",category:"food",keywords:["pasta"]},{emoji:"🍜",name:"steaming bowl",category:"food",keywords:["ramen","noodles"]},{emoji:"🍲",name:"pot of food",category:"food",keywords:["stew"]},{emoji:"🍣",name:"sushi",category:"food"},{emoji:"🍱",name:"bento box",category:"food"},{emoji:"🥟",name:"dumpling",category:"food"},{emoji:"🍩",name:"doughnut",category:"food",keywords:["donut"]},{emoji:"🍪",name:"cookie",category:"food"},{emoji:"🎂",name:"birthday cake",category:"food",keywords:["cake","birthday"]},{emoji:"🍰",name:"shortcake",category:"food",keywords:["cake"]},{emoji:"🧁",name:"cupcake",category:"food"},{emoji:"🍫",name:"chocolate bar",category:"food",keywords:["chocolate"]},{emoji:"🍬",name:"candy",category:"food"},{emoji:"🍭",name:"lollipop",category:"food"},{emoji:"🍦",name:"soft ice cream",category:"food",keywords:["ice cream"]},{emoji:"☕",name:"hot beverage",category:"food",keywords:["coffee","tea"]},{emoji:"🍵",name:"teacup without handle",category:"food",keywords:["tea"]},{emoji:"🥤",name:"cup with straw",category:"food"},{emoji:"🍺",name:"beer mug",category:"food",keywords:["beer"]},{emoji:"🍻",name:"clinking beer mugs",category:"food",keywords:["cheers"]},{emoji:"🥂",name:"clinking glasses",category:"food",keywords:["champagne","toast"]},{emoji:"🍷",name:"wine glass",category:"food",keywords:["wine"]},{emoji:"🍸",name:"cocktail glass",category:"food",keywords:["martini"]},{emoji:"🚗",name:"automobile",category:"travel",keywords:["car"]},{emoji:"🚕",name:"taxi",category:"travel"},{emoji:"🚌",name:"bus",category:"travel"},{emoji:"🚎",name:"trolleybus",category:"travel"},{emoji:"🏎️",name:"racing car",category:"travel"},{emoji:"🚓",name:"police car",category:"travel"},{emoji:"🚑",name:"ambulance",category:"travel"},{emoji:"🚒",name:"fire engine",category:"travel"},{emoji:"🚐",name:"minibus",category:"travel"},{emoji:"🛻",name:"pickup truck",category:"travel"},{emoji:"🚚",name:"delivery truck",category:"travel",keywords:["truck"]},{emoji:"🚲",name:"bicycle",category:"travel",keywords:["bike"]},{emoji:"🛵",name:"motor scooter",category:"travel"},{emoji:"🏍️",name:"motorcycle",category:"travel"},{emoji:"✈️",name:"airplane",category:"travel",keywords:["plane"]},{emoji:"🚀",name:"rocket",category:"travel"},{emoji:"🚁",name:"helicopter",category:"travel"},{emoji:"🛶",name:"canoe",category:"travel"},{emoji:"⛵",name:"sailboat",category:"travel",keywords:["boat"]},{emoji:"🚢",name:"ship",category:"travel"},{emoji:"🚆",name:"train",category:"travel"},{emoji:"🚇",name:"metro",category:"travel",keywords:["subway"]},{emoji:"🏠",name:"house",category:"travel",keywords:["home"]},{emoji:"🏡",name:"house with garden",category:"travel"},{emoji:"🏢",name:"office building",category:"travel",keywords:["office"]},{emoji:"🏣",name:"Japanese post office",category:"travel"},{emoji:"🏥",name:"hospital",category:"travel"},{emoji:"🏦",name:"bank",category:"travel"},{emoji:"🏨",name:"hotel",category:"travel"},{emoji:"🏪",name:"convenience store",category:"travel",keywords:["store"]},{emoji:"🏫",name:"school",category:"travel"},{emoji:"🏭",name:"factory",category:"travel"},{emoji:"🏰",name:"castle",category:"travel"},{emoji:"⛪",name:"church",category:"travel"},{emoji:"🕌",name:"mosque",category:"travel"},{emoji:"🗼",name:"Tokyo tower",category:"travel"},{emoji:"🗽",name:"Statue of Liberty",category:"travel"},{emoji:"🌁",name:"foggy",category:"travel"},{emoji:"🌃",name:"night with stars",category:"travel"},{emoji:"🌄",name:"sunrise over mountains",category:"travel"},{emoji:"🌅",name:"sunrise",category:"travel"},{emoji:"🌆",name:"cityscape at dusk",category:"travel"},{emoji:"🌇",name:"sunset",category:"travel"},{emoji:"🌉",name:"bridge at night",category:"travel"},{emoji:"⛰️",name:"mountain",category:"travel"},{emoji:"🏔️",name:"snow-capped mountain",category:"travel"},{emoji:"🗻",name:"mount fuji",category:"travel"},{emoji:"🏝️",name:"desert island",category:"travel",keywords:["island"]},{emoji:"🏖️",name:"beach with umbrella",category:"travel",keywords:["beach"]},{emoji:"🌋",name:"volcano",category:"travel"},{emoji:"🌍",name:"globe Europe-Africa",category:"travel",keywords:["earth","world"]},{emoji:"🌎",name:"globe Americas",category:"travel"},{emoji:"🌏",name:"globe Asia-Australia",category:"travel"},{emoji:"🌕",name:"full moon",category:"travel",keywords:["moon"]},{emoji:"🌙",name:"crescent moon",category:"travel"},{emoji:"⭐",name:"star",category:"travel"},{emoji:"🌟",name:"glowing star",category:"travel"},{emoji:"☀️",name:"sun",category:"travel"},{emoji:"🌤️",name:"sun behind small cloud",category:"travel"},{emoji:"⛅",name:"sun behind cloud",category:"travel"},{emoji:"🌧️",name:"cloud with rain",category:"travel",keywords:["rain"]},{emoji:"⛈️",name:"cloud with lightning and rain",category:"travel",keywords:["storm"]},{emoji:"🌨️",name:"cloud with snow",category:"travel",keywords:["snow"]},{emoji:"🌈",name:"rainbow",category:"travel"},{emoji:"⚽",name:"soccer ball",category:"activities",keywords:["football","soccer"]},{emoji:"🏀",name:"basketball",category:"activities"},{emoji:"🏈",name:"american football",category:"activities"},{emoji:"⚾",name:"baseball",category:"activities"},{emoji:"🥎",name:"softball",category:"activities"},{emoji:"🎾",name:"tennis",category:"activities"},{emoji:"🏐",name:"volleyball",category:"activities"},{emoji:"🏉",name:"rugby football",category:"activities"},{emoji:"🥏",name:"flying disc",category:"activities",keywords:["frisbee"]},{emoji:"🎱",name:"pool 8 ball",category:"activities",keywords:["billiards"]},{emoji:"🪀",name:"yo-yo",category:"activities"},{emoji:"🏓",name:"ping pong",category:"activities"},{emoji:"🏸",name:"badminton",category:"activities"},{emoji:"🏒",name:"ice hockey",category:"activities"},{emoji:"🥅",name:"goal net",category:"activities"},{emoji:"⛳",name:"flag in hole",category:"activities",keywords:["golf"]},{emoji:"🏹",name:"bow and arrow",category:"activities",keywords:["archery"]},{emoji:"🎣",name:"fishing pole",category:"activities",keywords:["fishing"]},{emoji:"🥊",name:"boxing glove",category:"activities",keywords:["boxing"]},{emoji:"🥋",name:"martial arts uniform",category:"activities"},{emoji:"🎽",name:"running shirt",category:"activities"},{emoji:"🛹",name:"skateboard",category:"activities"},{emoji:"🛷",name:"sled",category:"activities"},{emoji:"⛸️",name:"ice skate",category:"activities"},{emoji:"🥌",name:"curling stone",category:"activities"},{emoji:"🎿",name:"skis",category:"activities",keywords:["skiing"]},{emoji:"🏂",name:"snowboarder",category:"activities",keywords:["snowboard"]},{emoji:"🏋️",name:"person lifting weights",category:"activities",keywords:["gym"]},{emoji:"🤸",name:"person cartwheeling",category:"activities"},{emoji:"🤺",name:"person fencing",category:"activities"},{emoji:"🏊",name:"person swimming",category:"activities",keywords:["swim"]},{emoji:"🚴",name:"person biking",category:"activities",keywords:["cycling"]},{emoji:"🧘",name:"person in lotus position",category:"activities",keywords:["yoga","meditation"]},{emoji:"🏆",name:"trophy",category:"activities",keywords:["winner","champion"]},{emoji:"🥇",name:"gold medal",category:"activities",keywords:["first"]},{emoji:"🥈",name:"silver medal",category:"activities",keywords:["second"]},{emoji:"🥉",name:"bronze medal",category:"activities",keywords:["third"]},{emoji:"🎮",name:"video game",category:"activities",keywords:["game","gaming"]},{emoji:"🕹️",name:"joystick",category:"activities"},{emoji:"🎲",name:"game die",category:"activities",keywords:["dice"]},{emoji:"🧩",name:"puzzle piece",category:"activities",keywords:["puzzle"]},{emoji:"♟️",name:"chess pawn",category:"activities",keywords:["chess"]},{emoji:"🎯",name:"direct hit",category:"activities",keywords:["dart","target"]},{emoji:"🎰",name:"slot machine",category:"activities"},{emoji:"🎭",name:"performing arts",category:"activities",keywords:["theater","drama"]},{emoji:"🎨",name:"artist palette",category:"activities",keywords:["art","paint"]},{emoji:"🎬",name:"clapper board",category:"activities",keywords:["movie","film"]},{emoji:"🎤",name:"microphone",category:"activities",keywords:["karaoke","sing"]},{emoji:"🎧",name:"headphone",category:"activities",keywords:["music"]},{emoji:"🎼",name:"musical score",category:"activities"},{emoji:"🎹",name:"musical keyboard",category:"activities",keywords:["piano"]},{emoji:"🎷",name:"saxophone",category:"activities"},{emoji:"🎸",name:"guitar",category:"activities"},{emoji:"🎻",name:"violin",category:"activities"},{emoji:"🪘",name:"long drum",category:"activities"},{emoji:"🥁",name:"drum",category:"activities"},{emoji:"⌚",name:"watch",category:"objects"},{emoji:"📱",name:"mobile phone",category:"objects",keywords:["phone","smartphone"]},{emoji:"📲",name:"mobile phone with arrow",category:"objects"},{emoji:"💻",name:"laptop",category:"objects",keywords:["computer"]},{emoji:"🖥️",name:"desktop computer",category:"objects"},{emoji:"🖨️",name:"printer",category:"objects"},{emoji:"⌨️",name:"keyboard",category:"objects"},{emoji:"🖱️",name:"computer mouse",category:"objects"},{emoji:"💾",name:"floppy disk",category:"objects"},{emoji:"💿",name:"optical disk",category:"objects",keywords:["cd"]},{emoji:"📀",name:"dvd",category:"objects"},{emoji:"📷",name:"camera",category:"objects"},{emoji:"📹",name:"video camera",category:"objects"},{emoji:"🎥",name:"movie camera",category:"objects"},{emoji:"📺",name:"television",category:"objects",keywords:["tv"]},{emoji:"📻",name:"radio",category:"objects"},{emoji:"🎙️",name:"studio microphone",category:"objects"},{emoji:"⏰",name:"alarm clock",category:"objects",keywords:["clock"]},{emoji:"⏳",name:"hourglass not done",category:"objects"},{emoji:"⌛",name:"hourglass done",category:"objects"},{emoji:"📡",name:"satellite antenna",category:"objects"},{emoji:"🔋",name:"battery",category:"objects"},{emoji:"🔌",name:"electric plug",category:"objects"},{emoji:"💡",name:"light bulb",category:"objects",keywords:["idea"]},{emoji:"🔦",name:"flashlight",category:"objects"},{emoji:"🕯️",name:"candle",category:"objects"},{emoji:"🧯",name:"fire extinguisher",category:"objects"},{emoji:"🛢️",name:"oil drum",category:"objects"},{emoji:"💸",name:"money with wings",category:"objects"},{emoji:"💵",name:"dollar banknote",category:"objects",keywords:["money"]},{emoji:"💳",name:"credit card",category:"objects"},{emoji:"💰",name:"money bag",category:"objects"},{emoji:"🧲",name:"magnet",category:"objects"},{emoji:"🔧",name:"wrench",category:"objects"},{emoji:"🔨",name:"hammer",category:"objects"},{emoji:"🛠️",name:"hammer and wrench",category:"objects",keywords:["tools"]},{emoji:"⚙️",name:"gear",category:"objects",keywords:["settings"]},{emoji:"🔩",name:"nut and bolt",category:"objects"},{emoji:"🔑",name:"key",category:"objects"},{emoji:"🗝️",name:"old key",category:"objects"},{emoji:"🔒",name:"locked",category:"objects",keywords:["lock"]},{emoji:"🔓",name:"unlocked",category:"objects"},{emoji:"📦",name:"package",category:"objects",keywords:["box"]},{emoji:"📫",name:"closed mailbox with raised flag",category:"objects",keywords:["mail"]},{emoji:"📝",name:"memo",category:"objects",keywords:["note"]},{emoji:"📄",name:"page facing up",category:"objects",keywords:["document"]},{emoji:"📁",name:"file folder",category:"objects",keywords:["folder"]},{emoji:"📂",name:"open file folder",category:"objects"},{emoji:"📅",name:"calendar",category:"objects"},{emoji:"📆",name:"tear-off calendar",category:"objects"},{emoji:"📌",name:"pushpin",category:"objects",keywords:["pin"]},{emoji:"📎",name:"paperclip",category:"objects"},{emoji:"✂️",name:"scissors",category:"objects"},{emoji:"📏",name:"straight ruler",category:"objects"},{emoji:"✏️",name:"pencil",category:"objects"},{emoji:"🖊️",name:"pen",category:"objects"},{emoji:"🖍️",name:"crayon",category:"objects"},{emoji:"📚",name:"books",category:"objects",keywords:["book","library"]},{emoji:"📖",name:"open book",category:"objects"},{emoji:"🔗",name:"link",category:"objects"},{emoji:"💊",name:"pill",category:"objects",keywords:["medicine"]},{emoji:"💉",name:"syringe",category:"objects"},{emoji:"🩹",name:"adhesive bandage",category:"objects"},{emoji:"🧪",name:"test tube",category:"objects"},{emoji:"🔬",name:"microscope",category:"objects"},{emoji:"🔭",name:"telescope",category:"objects"},{emoji:"🧬",name:"dna",category:"objects"},{emoji:"🗑️",name:"wastebasket",category:"objects",keywords:["trash","delete"]},{emoji:"🚿",name:"shower",category:"objects"},{emoji:"🛁",name:"bathtub",category:"objects"},{emoji:"🧹",name:"broom",category:"objects"},{emoji:"🧺",name:"basket",category:"objects"},{emoji:"🧻",name:"roll of paper",category:"objects"},{emoji:"🧼",name:"soap",category:"objects"},{emoji:"🪥",name:"toothbrush",category:"objects"},{emoji:"🛒",name:"shopping cart",category:"objects"},{emoji:"🎁",name:"wrapped gift",category:"objects",keywords:["gift","present"]},{emoji:"🎀",name:"ribbon",category:"objects"},{emoji:"🎈",name:"balloon",category:"objects"},{emoji:"🎉",name:"party popper",category:"objects",keywords:["party","celebration"]},{emoji:"🎊",name:"confetti ball",category:"objects"},{emoji:"❤️",name:"red heart",category:"symbols",keywords:["love","heart"]},{emoji:"🧡",name:"orange heart",category:"symbols"},{emoji:"💛",name:"yellow heart",category:"symbols"},{emoji:"💚",name:"green heart",category:"symbols"},{emoji:"💙",name:"blue heart",category:"symbols"},{emoji:"💜",name:"purple heart",category:"symbols"},{emoji:"🖤",name:"black heart",category:"symbols"},{emoji:"🤍",name:"white heart",category:"symbols"},{emoji:"🤎",name:"brown heart",category:"symbols"},{emoji:"💔",name:"broken heart",category:"symbols"},{emoji:"💕",name:"two hearts",category:"symbols"},{emoji:"💖",name:"sparkling heart",category:"symbols"},{emoji:"💗",name:"growing heart",category:"symbols"},{emoji:"💘",name:"heart with arrow",category:"symbols"},{emoji:"💝",name:"heart with ribbon",category:"symbols"},{emoji:"💞",name:"revolving hearts",category:"symbols"},{emoji:"💯",name:"hundred points",category:"symbols",keywords:["100","perfect"]},{emoji:"💢",name:"anger symbol",category:"symbols"},{emoji:"💥",name:"collision",category:"symbols",keywords:["boom","explosion"]},{emoji:"💫",name:"dizzy",category:"symbols"},{emoji:"💦",name:"sweat droplets",category:"symbols"},{emoji:"💨",name:"dashing away",category:"symbols"},{emoji:"🕳️",name:"hole",category:"symbols"},{emoji:"💬",name:"speech balloon",category:"symbols",keywords:["comment","chat"]},{emoji:"👁️🗨️",name:"eye in speech bubble",category:"symbols"},{emoji:"🗨️",name:"left speech bubble",category:"symbols"},{emoji:"🗯️",name:"right anger bubble",category:"symbols"},{emoji:"💭",name:"thought balloon",category:"symbols"},{emoji:"💤",name:"zzz",category:"symbols",keywords:["sleep"]},{emoji:"🔔",name:"bell",category:"symbols",keywords:["notification"]},{emoji:"🔕",name:"bell with slash",category:"symbols",keywords:["mute"]},{emoji:"🎵",name:"musical note",category:"symbols",keywords:["music"]},{emoji:"🎶",name:"musical notes",category:"symbols"},{emoji:"➕",name:"plus",category:"symbols",keywords:["add"]},{emoji:"➖",name:"minus",category:"symbols"},{emoji:"➗",name:"divide",category:"symbols"},{emoji:"✖️",name:"multiply",category:"symbols"},{emoji:"♾️",name:"infinity",category:"symbols"},{emoji:"💲",name:"heavy dollar sign",category:"symbols",keywords:["money"]},{emoji:"🔴",name:"red circle",category:"symbols"},{emoji:"🟠",name:"orange circle",category:"symbols"},{emoji:"🟡",name:"yellow circle",category:"symbols"},{emoji:"🟢",name:"green circle",category:"symbols"},{emoji:"🔵",name:"blue circle",category:"symbols"},{emoji:"🟣",name:"purple circle",category:"symbols"},{emoji:"⚫",name:"black circle",category:"symbols"},{emoji:"⚪",name:"white circle",category:"symbols"},{emoji:"🟤",name:"brown circle",category:"symbols"},{emoji:"🔺",name:"red triangle pointed up",category:"symbols"},{emoji:"🔻",name:"red triangle pointed down",category:"symbols"},{emoji:"🔷",name:"large blue diamond",category:"symbols"},{emoji:"🔶",name:"large orange diamond",category:"symbols"},{emoji:"✅",name:"check mark button",category:"symbols",keywords:["done","yes"]},{emoji:"❌",name:"cross mark",category:"symbols",keywords:["no","wrong"]},{emoji:"❎",name:"cross mark button",category:"symbols"},{emoji:"✔️",name:"check mark",category:"symbols"},{emoji:"⭕",name:"hollow red circle",category:"symbols"},{emoji:"❗",name:"exclamation mark",category:"symbols",keywords:["warning"]},{emoji:"❓",name:"question mark",category:"symbols"},{emoji:"❕",name:"white exclamation mark",category:"symbols"},{emoji:"❔",name:"white question mark",category:"symbols"},{emoji:"⚠️",name:"warning",category:"symbols"},{emoji:"🚫",name:"prohibited",category:"symbols",keywords:["no","forbidden"]},{emoji:"🔞",name:"no one under eighteen",category:"symbols"},{emoji:"⛔",name:"no entry",category:"symbols",keywords:["stop"]},{emoji:"🔙",name:"back arrow",category:"symbols"},{emoji:"🔚",name:"end arrow",category:"symbols"},{emoji:"🔛",name:"on! arrow",category:"symbols"},{emoji:"🔜",name:"soon arrow",category:"symbols"},{emoji:"🔝",name:"top arrow",category:"symbols"},{emoji:"🔃",name:"clockwise vertical arrows",category:"symbols",keywords:["refresh"]},{emoji:"🔄",name:"counterclockwise arrows button",category:"symbols",keywords:["sync"]},{emoji:"🔁",name:"repeat button",category:"symbols"},{emoji:"🔀",name:"shuffle tracks button",category:"symbols"},{emoji:"▶️",name:"play button",category:"symbols"},{emoji:"⏸️",name:"pause button",category:"symbols"},{emoji:"⏹️",name:"stop button",category:"symbols"},{emoji:"⏺️",name:"record button",category:"symbols"},{emoji:"⏭️",name:"next track button",category:"symbols"},{emoji:"⏮️",name:"last track button",category:"symbols"},{emoji:"⏩",name:"fast-forward button",category:"symbols"},{emoji:"⏪",name:"fast reverse button",category:"symbols"},{emoji:"🔼",name:"upwards button",category:"symbols"},{emoji:"🔽",name:"downwards button",category:"symbols"},{emoji:"⬆️",name:"up arrow",category:"symbols"},{emoji:"⬇️",name:"down arrow",category:"symbols"},{emoji:"⬅️",name:"left arrow",category:"symbols"},{emoji:"➡️",name:"right arrow",category:"symbols"},{emoji:"↗️",name:"up-right arrow",category:"symbols"},{emoji:"↘️",name:"down-right arrow",category:"symbols"},{emoji:"↙️",name:"down-left arrow",category:"symbols"},{emoji:"↖️",name:"up-left arrow",category:"symbols"},{emoji:"↕️",name:"up-down arrow",category:"symbols"},{emoji:"↔️",name:"left-right arrow",category:"symbols"},{emoji:"🔀",name:"shuffle",category:"symbols"},{emoji:"ℹ️",name:"information",category:"symbols",keywords:["info"]},{emoji:"🆕",name:"new button",category:"symbols",keywords:["new"]},{emoji:"🆗",name:"ok button",category:"symbols",keywords:["ok"]},{emoji:"🆙",name:"up! button",category:"symbols"},{emoji:"🆒",name:"cool button",category:"symbols",keywords:["cool"]},{emoji:"🆓",name:"free button",category:"symbols",keywords:["free"]},{emoji:"🔟",name:"keycap: 10",category:"symbols"},{emoji:"#️⃣",name:"keycap: #",category:"symbols"},{emoji:"*️⃣",name:"keycap: *",category:"symbols"},{emoji:"0️⃣",name:"keycap: 0",category:"symbols"},{emoji:"1️⃣",name:"keycap: 1",category:"symbols"},{emoji:"2️⃣",name:"keycap: 2",category:"symbols"},{emoji:"3️⃣",name:"keycap: 3",category:"symbols"},{emoji:"4️⃣",name:"keycap: 4",category:"symbols"},{emoji:"5️⃣",name:"keycap: 5",category:"symbols"},{emoji:"6️⃣",name:"keycap: 6",category:"symbols"},{emoji:"7️⃣",name:"keycap: 7",category:"symbols"},{emoji:"8️⃣",name:"keycap: 8",category:"symbols"},{emoji:"9️⃣",name:"keycap: 9",category:"symbols"},{emoji:"©️",name:"copyright",category:"symbols"},{emoji:"®️",name:"registered",category:"symbols"},{emoji:"™️",name:"trade mark",category:"symbols"},{emoji:"🏳️",name:"white flag",category:"flags"},{emoji:"🏴",name:"black flag",category:"flags"},{emoji:"🏁",name:"chequered flag",category:"flags",keywords:["finish","racing"]},{emoji:"🚩",name:"triangular flag",category:"flags"},{emoji:"🏳️🌈",name:"rainbow flag",category:"flags",keywords:["pride"]},{emoji:"🏳️⚧️",name:"transgender flag",category:"flags"},{emoji:"🇺🇸",name:"flag: United States",category:"flags",keywords:["usa","america"]},{emoji:"🇬🇧",name:"flag: United Kingdom",category:"flags",keywords:["uk","britain"]},{emoji:"🇩🇪",name:"flag: Germany",category:"flags"},{emoji:"🇫🇷",name:"flag: France",category:"flags"},{emoji:"🇵🇱",name:"flag: Poland",category:"flags"},{emoji:"🇪🇸",name:"flag: Spain",category:"flags"},{emoji:"🇮🇹",name:"flag: Italy",category:"flags"},{emoji:"🇯🇵",name:"flag: Japan",category:"flags"},{emoji:"🇨🇳",name:"flag: China",category:"flags"},{emoji:"🇰🇷",name:"flag: South Korea",category:"flags"},{emoji:"🇮🇳",name:"flag: India",category:"flags"},{emoji:"🇧🇷",name:"flag: Brazil",category:"flags"},{emoji:"🇷🇺",name:"flag: Russia",category:"flags"},{emoji:"🇦🇺",name:"flag: Australia",category:"flags"},{emoji:"🇨🇦",name:"flag: Canada",category:"flags"},{emoji:"🇲🇽",name:"flag: Mexico",category:"flags"},{emoji:"🇳🇱",name:"flag: Netherlands",category:"flags"},{emoji:"🇧🇪",name:"flag: Belgium",category:"flags"},{emoji:"🇨🇭",name:"flag: Switzerland",category:"flags"},{emoji:"🇦🇹",name:"flag: Austria",category:"flags"},{emoji:"🇸🇪",name:"flag: Sweden",category:"flags"},{emoji:"🇳🇴",name:"flag: Norway",category:"flags"},{emoji:"🇩🇰",name:"flag: Denmark",category:"flags"},{emoji:"🇫🇮",name:"flag: Finland",category:"flags"},{emoji:"🇵🇹",name:"flag: Portugal",category:"flags"},{emoji:"🇬🇷",name:"flag: Greece",category:"flags"},{emoji:"🇹🇷",name:"flag: Turkey",category:"flags"},{emoji:"🇮🇱",name:"flag: Israel",category:"flags"},{emoji:"🇦🇪",name:"flag: United Arab Emirates",category:"flags"},{emoji:"🇸🇦",name:"flag: Saudi Arabia",category:"flags"},{emoji:"🇿🇦",name:"flag: South Africa",category:"flags"},{emoji:"🇪🇬",name:"flag: Egypt",category:"flags"},{emoji:"🇳🇬",name:"flag: Nigeria",category:"flags"},{emoji:"🇹🇭",name:"flag: Thailand",category:"flags"},{emoji:"🇻🇳",name:"flag: Vietnam",category:"flags"},{emoji:"🇸🇬",name:"flag: Singapore",category:"flags"},{emoji:"🇲🇾",name:"flag: Malaysia",category:"flags"},{emoji:"🇮🇩",name:"flag: Indonesia",category:"flags"},{emoji:"🇵🇭",name:"flag: Philippines",category:"flags"},{emoji:"🇦🇷",name:"flag: Argentina",category:"flags"},{emoji:"🇨🇱",name:"flag: Chile",category:"flags"},{emoji:"🇨🇴",name:"flag: Colombia",category:"flags"},{emoji:"🇺🇦",name:"flag: Ukraine",category:"flags"},{emoji:"🇨🇿",name:"flag: Czech Republic",category:"flags"},{emoji:"🇭🇺",name:"flag: Hungary",category:"flags"},{emoji:"🇷🇴",name:"flag: Romania",category:"flags"},{emoji:"🇮🇪",name:"flag: Ireland",category:"flags"},{emoji:"🇳🇿",name:"flag: New Zealand",category:"flags"}],sn="nice-emoji-picker-recent",An=({onSelect:t,showSearch:i=!0,searchPlaceholder:o,showSkinTones:a=!0,defaultSkinTone:l=0,showRecent:u=!0,maxRecent:_=24,recentEmojis:g,onRecentChange:A,categories:E,customEmojis:Y=[],columns:F=8,size:$="md",className:T="",style:G,"data-testid":ie="nice-emoji-picker"})=>{const{t:V}=v.Gt(),[ee,M]=n.useState(""),[f,O]=n.useState(u?"recent":"smileys"),[y,I]=n.useState(l),[B,r]=n.useState(!1),b=n.useRef(null),[S,U]=n.useState(()=>{if(typeof window>"u")return[];try{return JSON.parse(localStorage.getItem(sn)||"[]")}catch{return[]}}),k=g??S,j=E??[...u?["recent"]:[],"smileys","people","animals","food","travel","activities","objects","symbols","flags"],c=n.useMemo(()=>{if(!ee)return jt;const x=ee.toLowerCase();return jt.filter(D=>D.name.toLowerCase().includes(x)||D.emoji.includes(x)||D.keywords?.some(N=>N.toLowerCase().includes(x)))},[ee]),z=n.useMemo(()=>{const x={};for(const D of j)D==="recent"?x[D]=k.map(N=>jt.find(H=>H.emoji===N)).filter(N=>N!==void 0).slice(0,_):x[D]=c.filter(N=>N.category===D);return x},[j,c,k,_]),R=n.useCallback((x,D)=>!D||y===0?x:x.replace(/[\u{1F3FB}-\u{1F3FF}]/gu,"")+Mt[y],[y]),p=n.useCallback(x=>{const D=R(x.emoji,x.skinTones),N=[x.emoji,...k.filter(H=>H!==x.emoji)].slice(0,_);if(g===void 0){U(N);try{localStorage.setItem(sn,JSON.stringify(N))}catch{}}A?.(N),t?.(D,x)},[R,k,_,g,A,t]),d=n.useCallback(x=>{t?.(`:${x.name}:`,x)},[t]);n.useEffect(()=>{if(!B)return;const x=D=>{b.current&&!b.current.contains(D.target)&&r(!1)};return document.addEventListener("mousedown",x),()=>document.removeEventListener("mousedown",x)},[B]);const m=ee?c:z[f]||[];return e.jsxs("div",{className:`nice-emoji-picker nice-emoji-picker--${$} ${T}`,style:G,"data-testid":ie,children:[i&&e.jsxs("div",{className:"nice-emoji-picker__search",children:[e.jsx("input",{type:"text",value:ee,onChange:x=>M(x.target.value),placeholder:o??V("search","Search emoji..."),className:"nice-emoji-picker__search-input","data-testid":`${ie}-search`}),a&&e.jsxs("div",{className:"nice-emoji-picker__skin-tone-wrapper",children:[e.jsxs("button",{ref:b,type:"button",className:"nice-emoji-picker__skin-tone-btn",onClick:()=>r(!B),title:V("skinTone","Skin tone"),children:["✋",Mt[y]]}),B&&e.jsx("div",{className:"nice-emoji-picker__skin-tone-menu",children:Mt.map((x,D)=>e.jsxs("button",{type:"button",className:`nice-emoji-picker__skin-tone-option ${D===y?"nice-emoji-picker__skin-tone-option--selected":""}`,onClick:()=>{I(D),r(!1)},children:["✋",x]},D))})]})]}),!ee&&e.jsx("div",{className:"nice-emoji-picker__categories",role:"tablist",children:j.map(x=>e.jsx("button",{type:"button",className:`nice-emoji-picker__category-btn ${f===x?"nice-emoji-picker__category-btn--selected":""}`,onClick:()=>O(x),title:an[x],role:"tab","aria-selected":f===x,children:Ui[x]},x))}),e.jsxs("div",{className:"nice-emoji-picker__grid-container",children:[ee?e.jsxs("div",{className:"nice-emoji-picker__section",children:[e.jsx("div",{className:"nice-emoji-picker__section-title",children:V("searchResults","Search Results")}),e.jsx("div",{className:"nice-emoji-picker__grid",style:{gridTemplateColumns:`repeat(${F}, 1fr)`},children:c.length===0?e.jsx("div",{className:"nice-emoji-picker__empty",children:V("noEmojis","No emojis found")}):c.map((x,D)=>e.jsx("button",{type:"button",className:"nice-emoji-picker__emoji",onClick:()=>p(x),title:x.name,children:R(x.emoji,x.skinTones)},`${x.emoji}-${D}`))})]}):e.jsxs("div",{className:"nice-emoji-picker__section",children:[e.jsx("div",{className:"nice-emoji-picker__section-title",children:an[f]}),e.jsx("div",{className:"nice-emoji-picker__grid",style:{gridTemplateColumns:`repeat(${F}, 1fr)`},children:m.length===0?e.jsx("div",{className:"nice-emoji-picker__empty",children:f==="recent"?V("noRecent","No recent emojis"):V("noEmojis","No emojis")}):m.map((x,D)=>e.jsx("button",{type:"button",className:"nice-emoji-picker__emoji",onClick:()=>p(x),title:x.name,children:R(x.emoji,x.skinTones)},`${x.emoji}-${D}`))})]}),Y.length>0&&e.jsxs("div",{className:"nice-emoji-picker__section",children:[e.jsx("div",{className:"nice-emoji-picker__section-title",children:V("custom","Custom")}),e.jsx("div",{className:"nice-emoji-picker__grid",style:{gridTemplateColumns:`repeat(${F}, 1fr)`},children:Y.map(x=>e.jsx("button",{type:"button",className:"nice-emoji-picker__emoji nice-emoji-picker__emoji--custom",onClick:()=>d(x),title:x.name,children:e.jsx("img",{src:x.url,alt:x.name})},x.id))})]})]})]})};An.displayName="NiceEmojiPicker";const Wi=[{target:".nice-crop-editor",titleKey:"tutorial.cropEditor.intro.title",title:"Crop editor",contentKey:"tutorial.cropEditor.intro.content",content:"Drag the crop box over the image, pick an aspect ratio, rotate, flip or zoom, then use the result.",placement:"auto"}],zn=[{label:"Free",value:"free"},{label:"1:1",value:"1:1",ratio:1},{label:"4:3",value:"4:3",ratio:4/3},{label:"3:4",value:"3:4",ratio:3/4},{label:"16:9",value:"16:9",ratio:16/9},{label:"9:16",value:"9:16",ratio:9/16},{label:"3:2",value:"3:2",ratio:3/2},{label:"2:3",value:"2:3",ratio:2/3}],Dn=({src:t,initialCrop:i={x:10,y:10,width:80,height:80},initialRotation:o=0,initialZoom:a=1,aspectRatios:l=zn,defaultAspectRatio:u="free",customAspectRatio:_,showRotation:g=!0,showFlip:A=!0,showZoom:E=!0,minZoom:Y=.5,maxZoom:F=3,zoomStep:$=.1,showGrid:T=!0,overlayColor:G="var(--nice-overlay-50, rgba(0, 0, 0, 0.5))",toolbarPosition:ie="bottom",toolbarCollapsible:V=!1,defaultToolbarCollapsed:ee=!1,onChange:M,tutorial:f,className:O="",style:y,"data-testid":I="nice-crop-editor"})=>{const{t:B}=v.Gt(),r=n.useRef(null),b=n.useRef(null),[S,U]=n.useState(i),[k,j]=n.useState(o),[c,z]=n.useState(a),[R,p]=n.useState(!1),[d,m]=n.useState(!1),[x,D]=n.useState(u),[N,H]=n.useState(ee),[L,Q]=n.useState(!1),[w,K]=n.useState({x:0,y:0,crop:S}),Z=x==="custom"?_:l.find(W=>W.value===x)?.ratio;n.useEffect(()=>{M?.({crop:S,rotation:k,flipH:R,flipV:d,zoom:c})},[S,k,R,d,c,M]);const pe=n.useCallback((W,h)=>{if(!Z)return W;const P=r.current?.clientWidth??400,ce=r.current?.clientHeight??300,oe=W.width/100*P,ke=W.height/100*ce,de=oe/ke;if(Math.abs(de-Z)<.01)return W;if(h?.includes("e")||h?.includes("w")){const be=oe/Z/ce*100;return{...W,height:Math.min(100-W.y,Math.max(5,be))}}else if(h?.includes("n")||h?.includes("s")){const be=ke*Z/P*100;return{...W,width:Math.min(100-W.x,Math.max(5,be))}}else{const be=oe/Z/ce*100;return{...W,height:Math.min(100-W.y,Math.max(5,be))}}},[Z]),q=n.useCallback((W,h)=>{h===!1||(W.preventDefault(),W.stopPropagation(),Q(h),!r.current?.getBoundingClientRect())||K({x:W.clientX,y:W.clientY,crop:{...S}})},[S]),ne=n.useCallback(W=>{if(!L||!r.current)return;const h=r.current.getBoundingClientRect(),P=(W.clientX-w.x)/h.width*100,ce=(W.clientY-w.y)/h.height*100;let oe={...w.crop};if(L==="crop")oe.x=Math.max(0,Math.min(100-oe.width,w.crop.x+P)),oe.y=Math.max(0,Math.min(100-oe.height,w.crop.y+ce));else{switch(L){case"resize-nw":oe.x=Math.max(0,Math.min(w.crop.x+w.crop.width-5,w.crop.x+P)),oe.y=Math.max(0,Math.min(w.crop.y+w.crop.height-5,w.crop.y+ce)),oe.width=w.crop.width-(oe.x-w.crop.x),oe.height=w.crop.height-(oe.y-w.crop.y);break;case"resize-ne":oe.y=Math.max(0,Math.min(w.crop.y+w.crop.height-5,w.crop.y+ce)),oe.width=Math.max(5,Math.min(100-oe.x,w.crop.width+P)),oe.height=w.crop.height-(oe.y-w.crop.y);break;case"resize-sw":oe.x=Math.max(0,Math.min(w.crop.x+w.crop.width-5,w.crop.x+P)),oe.width=w.crop.width-(oe.x-w.crop.x),oe.height=Math.max(5,Math.min(100-oe.y,w.crop.height+ce));break;case"resize-se":oe.width=Math.max(5,Math.min(100-oe.x,w.crop.width+P)),oe.height=Math.max(5,Math.min(100-oe.y,w.crop.height+ce));break;case"resize-n":oe.y=Math.max(0,Math.min(w.crop.y+w.crop.height-5,w.crop.y+ce)),oe.height=w.crop.height-(oe.y-w.crop.y);break;case"resize-s":oe.height=Math.max(5,Math.min(100-oe.y,w.crop.height+ce));break;case"resize-e":oe.width=Math.max(5,Math.min(100-oe.x,w.crop.width+P));break;case"resize-w":oe.x=Math.max(0,Math.min(w.crop.x+w.crop.width-5,w.crop.x+P)),oe.width=w.crop.width-(oe.x-w.crop.x);break}oe=pe(oe,L.replace("resize-",""))}U(oe)},[L,w,pe]),re=n.useCallback(()=>{Q(!1)},[]);n.useEffect(()=>{if(L)return document.addEventListener("mousemove",ne),document.addEventListener("mouseup",re),()=>{document.removeEventListener("mousemove",ne),document.removeEventListener("mouseup",re)}},[L,ne,re]);const ue=n.useCallback(()=>{j(W=>(W-90+360)%360)},[]),je=n.useCallback(()=>{j(W=>(W+90)%360)},[]),J=n.useCallback(()=>{p(W=>!W)},[]),ge=n.useCallback(()=>{m(W=>!W)},[]),ye=n.useCallback(()=>{U(i),j(o),z(a),p(!1),m(!1),D(u)},[i,o,a,u]);n.useEffect(()=>{U(W=>pe(W))},[x,pe]);const se=`scale(${c}) rotate(${k}deg) scaleX(${R?-1:1}) scaleY(${d?-1:1})`,me=ie==="top"?"column-reverse":ie==="left"?"row-reverse":ie==="right"?"row":"column",fe=ie==="left"||ie==="right";return e.jsxs("div",{className:`nice-crop-editor nice-crop-editor--toolbar-${ie} ${O}`,style:{position:"relative",display:"flex",flexDirection:me,gap:12,...y},"data-testid":I,children:[e.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:20},children:e.jsx(v.Ql,{steps:v.Yl(f,Wi)})}),e.jsxs("div",{ref:r,className:"nice-crop-editor__container","data-testid":`${I}-container`,children:[e.jsx("img",{ref:b,src:t,alt:"",className:"nice-crop-editor__image",style:{transform:se},draggable:!1}),e.jsxs("div",{className:"nice-crop-editor__overlay",style:{backgroundColor:G},children:[e.jsx("div",{className:"nice-crop-editor__overlay-piece",style:{top:0,left:0,right:0,height:`${S.y}%`}}),e.jsx("div",{className:"nice-crop-editor__overlay-piece",style:{bottom:0,left:0,right:0,height:`${100-S.y-S.height}%`}}),e.jsx("div",{className:"nice-crop-editor__overlay-piece",style:{top:`${S.y}%`,left:0,width:`${S.x}%`,height:`${S.height}%`}}),e.jsx("div",{className:"nice-crop-editor__overlay-piece",style:{top:`${S.y}%`,right:0,width:`${100-S.x-S.width}%`,height:`${S.height}%`}})]}),e.jsxs("div",{className:"nice-crop-editor__crop-area",style:{left:`${S.x}%`,top:`${S.y}%`,width:`${S.width}%`,height:`${S.height}%`},onMouseDown:W=>q(W,"crop"),"data-testid":`${I}-crop-area`,children:[T&&e.jsxs("div",{className:"nice-crop-editor__grid",children:[e.jsx("div",{className:"nice-crop-editor__grid-line nice-crop-editor__grid-line--h1"}),e.jsx("div",{className:"nice-crop-editor__grid-line nice-crop-editor__grid-line--h2"}),e.jsx("div",{className:"nice-crop-editor__grid-line nice-crop-editor__grid-line--v1"}),e.jsx("div",{className:"nice-crop-editor__grid-line nice-crop-editor__grid-line--v2"})]}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--nw",onMouseDown:W=>q(W,"resize-nw")}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--ne",onMouseDown:W=>q(W,"resize-ne")}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--sw",onMouseDown:W=>q(W,"resize-sw")}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--se",onMouseDown:W=>q(W,"resize-se")}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--n",onMouseDown:W=>q(W,"resize-n")}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--s",onMouseDown:W=>q(W,"resize-s")}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--e",onMouseDown:W=>q(W,"resize-e")}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--w",onMouseDown:W=>q(W,"resize-w")})]})]}),e.jsxs("div",{className:`nice-crop-editor__controls ${N?"nice-crop-editor__controls--collapsed":""}`,style:{display:"flex",flexDirection:fe?"column":"row",flexWrap:fe?"nowrap":"wrap",gap:8,alignItems:fe?"stretch":"center",flexShrink:0},children:[V&&e.jsx("button",{type:"button",className:"nice-crop-editor__toolbar-toggle","aria-expanded":!N,"aria-label":N?"Show toolbar":"Hide toolbar",onClick:()=>H(W=>!W),style:{alignSelf:"flex-start",background:"var(--bg-secondary)",border:"1px solid var(--border-color)",borderRadius:4,padding:"2px 8px",cursor:"pointer",color:"var(--text-primary)",fontSize:12},children:e.jsx(v.oa,{name:N?"chevron-right":"chevron-down",size:14})}),!N&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"nice-crop-editor__control-group",children:[e.jsx("label",{className:"nice-crop-editor__label",children:B("aspectRatio","Aspect Ratio")}),e.jsx("div",{className:"nice-crop-editor__aspect-buttons",children:l.map(W=>e.jsx("button",{type:"button",className:`nice-crop-editor__aspect-btn ${x===W.value?"nice-crop-editor__aspect-btn--selected":""}`,onClick:()=>D(W.value),title:W.label,children:W.label},W.value))})]}),E&&e.jsxs("div",{className:"nice-crop-editor__control-group",children:[e.jsxs("label",{className:"nice-crop-editor__label",children:[B("zoom","Zoom"),": ",Math.round(c*100),"%"]}),e.jsx("input",{type:"range",className:"nice-crop-editor__slider",min:Y,max:F,step:$,value:c,onChange:W=>z(parseFloat(W.target.value)),"data-testid":`${I}-zoom`})]}),e.jsxs("div",{className:"nice-crop-editor__control-group nice-crop-editor__control-group--row",children:[g&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"nice-crop-editor__btn",onClick:ue,title:B("rotateLeft","Rotate Left"),"aria-label":B("rotateLeft","Rotate Left"),children:e.jsx(v.oa,{name:"reply",size:16})}),e.jsx("button",{type:"button",className:"nice-crop-editor__btn",onClick:je,title:B("rotateRight","Rotate Right"),"aria-label":B("rotateRight","Rotate Right"),children:e.jsx(v.oa,{name:"forward",size:16})})]}),A&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:`nice-crop-editor__btn ${R?"nice-crop-editor__btn--active":""}`,onClick:J,title:B("flipHorizontal","Flip Horizontal"),"aria-label":B("flipHorizontal","Flip Horizontal"),children:e.jsx(v.oa,{name:"shuffle",size:16})}),e.jsx("button",{type:"button",className:`nice-crop-editor__btn ${d?"nice-crop-editor__btn--active":""}`,onClick:ge,title:B("flipVertical","Flip Vertical"),"aria-label":B("flipVertical","Flip Vertical"),children:e.jsx(v.oa,{name:"shuffle",size:16})})]}),e.jsx("button",{type:"button",className:"nice-crop-editor__btn nice-crop-editor__btn--reset",onClick:ye,title:B("reset","Reset"),"aria-label":B("reset","Reset"),children:e.jsx(v.oa,{name:"refresh",size:16})})]})]})]})]})};Dn.displayName="NiceCropEditor";const Gi={strokeColor:"#ff3333",fillColor:"transparent",strokeWidth:2,opacity:1,fontSize:16,fontFamily:"sans-serif"};function qi(t,i){switch(i.type){case"SET_TOOL":return{...t,activeTool:i.tool,selectedId:null};case"SET_STYLE":return{...t,style:{...t.style,...i.style}};case"ADD_ANNOTATION":return{...t,annotations:[...t.annotations,i.annotation],past:[...t.past,t.annotations],future:[]};case"UPDATE_ANNOTATION":return{...t,annotations:t.annotations.map(o=>o.id===i.id?{...o,...i.updates}:o),past:[...t.past,t.annotations],future:[]};case"DELETE_ANNOTATION":return{...t,annotations:t.annotations.filter(o=>o.id!==i.id),selectedId:t.selectedId===i.id?null:t.selectedId,past:[...t.past,t.annotations],future:[]};case"SELECT":return{...t,selectedId:i.id};case"SET_ANNOTATIONS":return{...t,annotations:i.annotations,past:[],future:[]};case"SET_ZOOM":return{...t,zoom:i.zoom};case"SET_PAN":return{...t,panX:i.panX,panY:i.panY};case"UNDO":{if(t.past.length===0)return t;const o=t.past[t.past.length-1];return{...t,annotations:o,past:t.past.slice(0,-1),future:[t.annotations,...t.future]}}case"REDO":{if(t.future.length===0)return t;const o=t.future[0];return{...t,annotations:o,past:[...t.past,t.annotations],future:t.future.slice(1)}}case"CLEAR":return{...t,annotations:[],selectedId:null,past:[...t.past,t.annotations],future:[]};default:return t}}let Xi=0;function Vi(){return`ann-${Date.now()}-${Xi++}`}function Qi(t){const{style:i}=t,o=`stroke="${i.strokeColor}" stroke-width="${i.strokeWidth}" fill="${i.fillColor}" opacity="${i.opacity}"`;switch(t.tool){case"rectangle":return`<rect x="${t.x}" y="${t.y}" width="${t.width}" height="${t.height}" ${o} />`;case"ellipse":{const a=t.x+t.width/2,l=t.y+t.height/2;return`<ellipse cx="${a}" cy="${l}" rx="${t.width/2}" ry="${t.height/2}" ${o} />`}case"arrow":{const a=t,l=Math.atan2(a.endY-a.y,a.endX-a.x),u=12,_=a.endX-u*Math.cos(l-Math.PI/6),g=a.endY-u*Math.sin(l-Math.PI/6),A=a.endX-u*Math.cos(l+Math.PI/6),E=a.endY-u*Math.sin(l+Math.PI/6);return`<line x1="${a.x}" y1="${a.y}" x2="${a.endX}" y2="${a.endY}" ${o} />
|
|
678
|
+
<polygon points="${a.endX},${a.endY} ${_},${g} ${A},${E}" fill="${i.strokeColor}" opacity="${i.opacity}" />`}case"line":{const a=t;return`<line x1="${a.x}" y1="${a.y}" x2="${a.endX}" y2="${a.endY}" ${o} />`}case"text":{const a=t;return`<text x="${a.x}" y="${a.y+(a.style.fontSize??16)}" fill="${i.strokeColor}" font-size="${i.fontSize}" font-family="${i.fontFamily}" opacity="${i.opacity}">${Ji(a.text)}</text>`}case"freehand":{const a=t;return a.points.length<2?"":`<path d="${a.points.map((u,_)=>`${_===0?"M":"L"}${u.x},${u.y}`).join(" ")}" ${o} fill="none" />`}case"blur":{const a=t,l=`blur-${a.id}`;return`<defs><filter id="${l}"><feGaussianBlur stdDeviation="${a.intensity??5}" /></filter></defs>
|
|
679
|
+
<rect x="${a.x}" y="${a.y}" width="${a.width}" height="${a.height}" fill="transparent" stroke="none" filter="url(#${l})" />`}default:return""}}function Ji(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}const Ln=n.forwardRef(({src:t,alt:i="Annotatable image",annotations:o,activeTool:a,defaultStyle:l,onAnnotationsChange:u,className:_,readOnly:g=!1,minZoom:A=.1,maxZoom:E=5},Y)=>{const F=n.useRef(null),$=n.useRef(null),T=n.useRef(null),[G,ie]=n.useState(!1),[V,ee]=n.useState({width:0,height:0}),[M,f]=n.useReducer(qi,{annotations:o??[],selectedId:null,activeTool:a??"select",style:{...Gi,...l},zoom:1,panX:0,panY:0,past:[],future:[]});n.useEffect(()=>{a&&f({type:"SET_TOOL",tool:a})},[a]),n.useEffect(()=>{u?.(M.annotations)},[M.annotations,u]),n.useEffect(()=>{const j=new Image;j.crossOrigin="anonymous",j.onload=()=>{T.current=j,ee({width:j.naturalWidth,height:j.naturalHeight}),ie(!0)},j.src=t},[t]);const O=n.useRef({isDrawing:!1,startX:0,startY:0,currentAnnotation:null,freehandPoints:[]}),y=n.useCallback((j,c)=>{const z=F.current;if(!z)return{x:0,y:0};const R=z.getBoundingClientRect();return{x:(j-R.left-M.panX)/M.zoom,y:(c-R.top-M.panY)/M.zoom}},[M.zoom,M.panX,M.panY]),I=n.useCallback(()=>{const j=F.current,c=j?.getContext("2d"),z=T.current;if(!j||!c||!z||!G)return;j.width=$.current?.clientWidth??z.naturalWidth,j.height=$.current?.clientHeight??z.naturalHeight,c.clearRect(0,0,j.width,j.height),c.save(),c.translate(M.panX,M.panY),c.scale(M.zoom,M.zoom),c.drawImage(z,0,0);for(const p of M.annotations){switch(c.save(),c.globalAlpha=p.style.opacity,c.strokeStyle=p.style.strokeColor,c.fillStyle=p.style.fillColor,c.lineWidth=p.style.strokeWidth,p.tool){case"rectangle":c.strokeRect(p.x,p.y,p.width,p.height),p.style.fillColor!=="transparent"&&c.fillRect(p.x,p.y,p.width,p.height);break;case"ellipse":{c.beginPath(),c.ellipse(p.x+p.width/2,p.y+p.height/2,Math.abs(p.width/2),Math.abs(p.height/2),0,0,Math.PI*2),c.stroke(),p.style.fillColor!=="transparent"&&c.fill();break}case"arrow":{const d=p;c.beginPath(),c.moveTo(d.x,d.y),c.lineTo(d.endX,d.endY),c.stroke();const m=Math.atan2(d.endY-d.y,d.endX-d.x),x=12;c.beginPath(),c.moveTo(d.endX,d.endY),c.lineTo(d.endX-x*Math.cos(m-Math.PI/6),d.endY-x*Math.sin(m-Math.PI/6)),c.lineTo(d.endX-x*Math.cos(m+Math.PI/6),d.endY-x*Math.sin(m+Math.PI/6)),c.closePath(),c.fillStyle=p.style.strokeColor,c.fill();break}case"line":{const d=p;c.beginPath(),c.moveTo(d.x,d.y),c.lineTo(d.endX,d.endY),c.stroke();break}case"text":{const d=p;c.font=`${d.style.fontSize??16}px ${d.style.fontFamily??"sans-serif"}`,c.fillStyle=d.style.strokeColor,c.fillText(d.text,d.x,d.y+(d.style.fontSize??16));break}case"freehand":{const d=p;if(d.points.length<2)break;c.beginPath(),c.moveTo(d.points[0].x,d.points[0].y);for(let m=1;m<d.points.length;m++)c.lineTo(d.points[m].x,d.points[m].y);c.stroke();break}case"blur":{const d=p;c.filter=`blur(${d.intensity??5}px)`,c.drawImage(z,d.x,d.y,d.width,d.height,d.x,d.y,d.width,d.height),c.filter="none";break}}p.id===M.selectedId&&(c.strokeStyle="#4488ff",c.lineWidth=1,c.setLineDash([4,4]),c.strokeRect(p.x-2,p.y-2,p.width+4,p.height+4),c.setLineDash([])),c.restore()}const R=O.current;if(R.isDrawing&&R.currentAnnotation){c.save();const p=R.currentAnnotation;if(c.globalAlpha=p.style.opacity,c.strokeStyle=p.style.strokeColor,c.lineWidth=p.style.strokeWidth,c.setLineDash([6,3]),p.tool==="freehand"){const d=p;if(d.points.length>=2){c.beginPath(),c.moveTo(d.points[0].x,d.points[0].y);for(let m=1;m<d.points.length;m++)c.lineTo(d.points[m].x,d.points[m].y);c.stroke()}}else if(p.tool==="rectangle")c.strokeRect(p.x,p.y,p.width,p.height);else if(p.tool==="ellipse")c.beginPath(),c.ellipse(p.x+p.width/2,p.y+p.height/2,Math.abs(p.width/2),Math.abs(p.height/2),0,0,Math.PI*2),c.stroke();else if(p.tool==="arrow"||p.tool==="line"){const d=p;c.beginPath(),c.moveTo(d.x,d.y),c.lineTo(d.endX,d.endY),c.stroke()}c.restore()}c.restore()},[M,G]);n.useEffect(()=>{I()},[I]);const B=n.useCallback(j=>{if(g)return;const c=y(j.clientX,j.clientY),z=M.activeTool;if(z==="select"){const d=[...M.annotations].reverse().find(m=>m.tool==="freehand"?!1:c.x>=m.x&&c.x<=m.x+m.width&&c.y>=m.y&&c.y<=m.y+m.height);f({type:"SELECT",id:d?.id??null});return}const R=O.current;R.isDrawing=!0,R.startX=c.x,R.startY=c.y;const p={id:Vi(),style:{...M.style},x:c.x,y:c.y,width:0,height:0};switch(z){case"rectangle":R.currentAnnotation={...p,tool:"rectangle"};break;case"ellipse":R.currentAnnotation={...p,tool:"ellipse"};break;case"arrow":R.currentAnnotation={...p,tool:"arrow",endX:c.x,endY:c.y};break;case"line":R.currentAnnotation={...p,tool:"line",endX:c.x,endY:c.y};break;case"text":R.currentAnnotation={...p,tool:"text",text:"Text",width:100,height:M.style.fontSize??16};break;case"freehand":R.freehandPoints=[c],R.currentAnnotation={...p,tool:"freehand",points:[c]};break;case"blur":R.currentAnnotation={...p,tool:"blur",intensity:5};break}},[g,y,M.activeTool,M.style,M.annotations]),r=n.useCallback(j=>{const c=O.current;if(!c.isDrawing||!c.currentAnnotation)return;const z=y(j.clientX,j.clientY),R=c.currentAnnotation;if(R.tool==="freehand"){c.freehandPoints.push(z),R.points=[...c.freehandPoints];const p=c.freehandPoints.map(m=>m.x),d=c.freehandPoints.map(m=>m.y);R.x=Math.min(...p),R.y=Math.min(...d),R.width=Math.max(...p)-R.x,R.height=Math.max(...d)-R.y}else if(R.tool==="arrow"||R.tool==="line")R.endX=z.x,R.endY=z.y,R.width=Math.abs(z.x-c.startX),R.height=Math.abs(z.y-c.startY);else{const p=Math.min(c.startX,z.x),d=Math.min(c.startY,z.y);R.x=p,R.y=d,R.width=Math.abs(z.x-c.startX),R.height=Math.abs(z.y-c.startY)}I()},[y,I]),b=n.useCallback(()=>{const j=O.current;if(!j.isDrawing||!j.currentAnnotation)return;const c=j.currentAnnotation;(c.tool==="text"||c.tool==="freehand"||Math.abs(c.width)>2||Math.abs(c.height)>2)&&f({type:"ADD_ANNOTATION",annotation:c}),j.isDrawing=!1,j.currentAnnotation=null,j.freehandPoints=[]},[]),S=n.useCallback(j=>{j.preventDefault();const c=j.deltaY>0?.9:1.1,z=Math.max(A,Math.min(E,M.zoom*c));f({type:"SET_ZOOM",zoom:z})},[M.zoom,A,E]);n.useEffect(()=>{if(g)return;const j=c=>{(c.metaKey||c.ctrlKey)&&c.key==="z"&&!c.shiftKey?(c.preventDefault(),f({type:"UNDO"})):(c.metaKey||c.ctrlKey)&&(c.key==="y"||c.key==="z"&&c.shiftKey)?(c.preventDefault(),f({type:"REDO"})):(c.key==="Delete"||c.key==="Backspace")&&M.selectedId&&f({type:"DELETE_ANNOTATION",id:M.selectedId})};return document.addEventListener("keydown",j),()=>document.removeEventListener("keydown",j)},[g,M.selectedId]),n.useImperativeHandle(Y,()=>({exportAsDataURL:async(j="png",c=.92)=>{const z=document.createElement("canvas"),R=T.current;if(!R)return"";z.width=R.naturalWidth,z.height=R.naturalHeight;const p=z.getContext("2d");p.drawImage(R,0,0);for(const d of M.annotations){if(p.save(),p.globalAlpha=d.style.opacity,p.strokeStyle=d.style.strokeColor,p.fillStyle=d.style.fillColor,p.lineWidth=d.style.strokeWidth,d.tool==="rectangle")p.strokeRect(d.x,d.y,d.width,d.height);else if(d.tool==="ellipse")p.beginPath(),p.ellipse(d.x+d.width/2,d.y+d.height/2,Math.abs(d.width/2),Math.abs(d.height/2),0,0,Math.PI*2),p.stroke();else if(d.tool==="freehand"){const m=d;if(m.points.length>=2){p.beginPath(),p.moveTo(m.points[0].x,m.points[0].y);for(let x=1;x<m.points.length;x++)p.lineTo(m.points[x].x,m.points[x].y);p.stroke()}}else if(d.tool==="text"){const m=d;p.font=`${m.style.fontSize??16}px ${m.style.fontFamily??"sans-serif"}`,p.fillStyle=m.style.strokeColor,p.fillText(m.text,m.x,m.y+(m.style.fontSize??16))}p.restore()}return z.toDataURL(`image/${j}`,c)},exportAnnotations:()=>[...M.annotations],importAnnotations:j=>{f({type:"SET_ANNOTATIONS",annotations:j})},exportAsSVG:()=>{const{width:j,height:c}=V,z=M.annotations.map(Qi);return`<svg xmlns="http://www.w3.org/2000/svg" width="${j}" height="${c}" viewBox="0 0 ${j} ${c}">
|
|
680
|
+
${z.join(`
|
|
681
|
+
`)}
|
|
682
|
+
</svg>`},undo:()=>f({type:"UNDO"}),redo:()=>f({type:"REDO"}),setZoom:j=>{f({type:"SET_ZOOM",zoom:Math.max(A,Math.min(E,j))})},fitToScreen:()=>{const j=$.current,c=T.current;if(!j||!c)return;const z=j.clientWidth/c.naturalWidth,R=j.clientHeight/c.naturalHeight,p=Math.min(z,R,1);f({type:"SET_ZOOM",zoom:p}),f({type:"SET_PAN",panX:0,panY:0})},clear:()=>f({type:"CLEAR"})}),[M.annotations,V,A,E]);const U=n.useCallback(j=>{if(j.touches.length!==1)return;const c=j.touches[0];B({clientX:c.clientX,clientY:c.clientY,preventDefault:()=>{}})},[B]),k=n.useCallback(j=>{if(j.touches.length!==1)return;const c=j.touches[0];r({clientX:c.clientX,clientY:c.clientY})},[r]);return e.jsx("div",{ref:$,className:`nice-image-annotator ${_??""}`,style:{position:"relative",overflow:"hidden",width:"100%",height:"100%"},children:e.jsx("canvas",{ref:F,className:"nice-image-annotator__canvas",style:{cursor:M.activeTool==="select"?"default":"crosshair"},onMouseDown:B,onMouseMove:r,onMouseUp:b,onMouseLeave:b,onWheel:S,onTouchStart:U,onTouchMove:k,onTouchEnd:b,role:"img","aria-label":i})})});Ln.displayName="NiceImageAnnotator";const Zi=[{target:".nice-md-editor",titleKey:"tutorial.markdownEditor.intro.title",title:"Markdown editor",contentKey:"tutorial.markdownEditor.intro.content",content:"Write Markdown with the formatting toolbar; toggle the live preview to see the rendered result, and export to HTML.",placement:"auto"}];function eo(t){let i=t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">");return i=i.replace(/```(\w*)\n([\s\S]*?)```/g,(o,a,l)=>`<pre><code class="language-${a}">${l.trim()}</code></pre>`),i=i.replace(/^(\|.+\|)\n(\|[-| :]+\|)\n((?:\|.+\|\n?)+)/gm,(o,a,l,u)=>{const _=a.split("|").filter(A=>A.trim()).map(A=>`<th>${A.trim()}</th>`).join(""),g=u.trim().split(`
|
|
683
|
+
`).map(A=>`<tr>${A.split("|").filter(Y=>Y.trim()).map(Y=>`<td>${Y.trim()}</td>`).join("")}</tr>`).join("");return`<table><thead><tr>${_}</tr></thead><tbody>${g}</tbody></table>`}),i=i.replace(/^#### (.+)$/gm,"<h4>$1</h4>"),i=i.replace(/^### (.+)$/gm,"<h3>$1</h3>"),i=i.replace(/^## (.+)$/gm,"<h2>$1</h2>"),i=i.replace(/^# (.+)$/gm,"<h1>$1</h1>"),i=i.replace(/^> (.+)$/gm,"<blockquote>$1</blockquote>"),i=i.replace(/^---$/gm,"<hr/>"),i=i.replace(/^- \[x\] (.+)$/gm,'<li class="task done">☑ $1</li>'),i=i.replace(/^- \[ \] (.+)$/gm,'<li class="task">☐ $1</li>'),i=i.replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>"),i=i.replace(/\*(.+?)\*/g,"<em>$1</em>"),i=i.replace(/~~(.+?)~~/g,"<del>$1</del>"),i=i.replace(/`(.+?)`/g,"<code>$1</code>"),i=i.replace(/!\[([^\]]*)\]\(([^)]+)\)/g,'<img src="$2" alt="$1" style="max-width:100%"/>'),i=i.replace(/\[([^\]]+)\]\(([^)]+)\)/g,'<a href="$2">$1</a>'),i=i.replace(/^\- (.+)$/gm,"<li>$1</li>"),i=i.replace(/^\d+\. (.+)$/gm,"<li>$1</li>"),i=i.replace(/\n/g,"<br/>"),i}const to=[{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",icon:"type",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",icon:"list",md:"- ",tip:"Unordered list",group:"list"},{key:"ol",label:"1.",md:"1. ",tip:"Ordered list",group:"list"},{key:"task",icon:"check-square",md:"- [ ] ",tip:"Task list",group:"list"},{key:"quote",icon:"message",md:"> ",tip:"Blockquote",group:"block"},{key:"hr",icon:"minus",md:`---
|
|
684
|
+
`,tip:"Horizontal rule",group:"block"},{key:"link",icon:"link",md:"[](url)",tip:"Link",shortcut:"Ctrl+K",group:"insert"},{key:"image",icon:"image",md:"",tip:"Image",group:"insert"},{key:"table",icon:"table",md:`| H1 | H2 | H3 |
|
|
685
|
+
| --- | --- | --- |
|
|
686
|
+
| c1 | c2 | c3 |
|
|
687
|
+
`,tip:"Table",group:"insert"},{key:"codeblock",label:"```",md:"```\n",tip:"Code block",group:"insert"}],no=["format","heading","list","block","insert"],Pn=n.forwardRef(({value:t="",onChange:i,preview:o="side",placeholder:a,disabled:l,readOnly:u,size:_="md",editorSize:g="standard",toolbar:A=!0,minHeight:E=200,showWordCount:Y=!1,showLineNumbers:F=!1,onExportHtml:$,onImageUpload:T,tutorial:G,className:ie,style:V,id:ee},M)=>{const f=v.bc(ee),[O,y]=n.useState("edit"),[I,B]=n.useState(!1),r=n.useRef(null),b=n.useMemo(()=>eo(t),[t]),S=n.useMemo(()=>{const p=t.trim()?t.trim().split(/\s+/).length:0,d=t.length,m=t.split(`
|
|
688
|
+
`).length;return{words:p,chars:d,lines:m}},[t]),U=n.useCallback(p=>{const d=r.current;if(!d)return;const m=d.selectionStart,x=d.selectionEnd,D=t.slice(m,x);let N,H;p==="[](url)"?(N=t.slice(0,m)+`[${D||"text"}](url)`+t.slice(x),H=m+1+(D||"text").length+2):p===""?(N=t.slice(0,m)+``+t.slice(x),H=m+2+(D||"alt").length+2):p.endsWith(`
|
|
689
|
+
`)||p.endsWith(" ")?(N=t.slice(0,m)+p+D+t.slice(x),H=m+p.length+D.length):(N=t.slice(0,m)+p+D+p+t.slice(x),H=m+p.length+D.length+p.length),i?.(N),requestAnimationFrame(()=>{d.focus(),d.setSelectionRange(H,H)})},[t,i]),k=n.useCallback(p=>{if((p.ctrlKey||p.metaKey)&&(p.key==="b"?(p.preventDefault(),U("**")):p.key==="i"?(p.preventDefault(),U("*")):p.key==="k"&&(p.preventDefault(),U("[](url)"))),p.key==="Tab"){p.preventDefault();const d=p.currentTarget,m=d.selectionStart,x=d.selectionEnd,D=" ";if(p.shiftKey){const L=t.slice(0,m).lastIndexOf(`
|
|
690
|
+
`)+1;if(t.slice(L,L+D.length)===D){const Q=t.slice(0,L)+t.slice(L+D.length);i?.(Q),requestAnimationFrame(()=>{d.selectionStart=d.selectionEnd=m-D.length})}}else{const N=t.slice(0,m)+D+t.slice(x);i?.(N),requestAnimationFrame(()=>{d.selectionStart=d.selectionEnd=m+D.length})}}},[t,i,U]),j=n.useCallback(async p=>{if(!T)return;const d=Array.from(p.dataTransfer.files).filter(m=>m.type.startsWith("image/"));if(d.length!==0){p.preventDefault();for(const m of d){const x=await T(m),D=r.current;if(!D)continue;const N=D.selectionStart,H=`
|
|
691
|
+
`,L=t.slice(0,N)+H+t.slice(N);i?.(L)}}},[t,i,T]),c=o!=="tab"||O==="edit",z=o==="side"||o==="tab"&&O==="preview"||o===!0,R=`nice-md-editor nice-md-editor--${_} nice-editor--${g} nice-md-editor--preview-${o}${I?" nice-md-editor--fullscreen":""} ${ie||""}`;return e.jsxs("div",{ref:M,id:f,className:R,style:{position:"relative",...V},children:[e.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:20},children:e.jsx(v.Ql,{steps:v.Yl(G,Zi)})}),A&&e.jsxs("div",{className:"nice-md-editor__toolbar",children:[no.map((p,d)=>e.jsxs(n.Fragment,{children:[d>0&&e.jsx("span",{className:"nice-md-editor__sep"}),to.filter(m=>m.group===p).map(m=>e.jsx("button",{type:"button",className:"nice-md-editor__btn",title:m.shortcut?`${m.tip} (${m.shortcut})`:m.tip,disabled:l||u,onClick:()=>U(m.md),"aria-label":m.tip,children:m.icon?e.jsx(v.oa,{name:m.icon,size:16}):m.label},m.key))]},p)),e.jsx("span",{className:"nice-md-editor__sep"}),e.jsx("button",{type:"button",className:"nice-md-editor__btn",title:"Fullscreen","aria-label":"Fullscreen",onClick:()=>B(!I),children:e.jsx(v.oa,{name:I?"collapse":"expand",size:16})}),$&&e.jsx("button",{type:"button",className:"nice-md-editor__btn",title:"Export HTML","aria-label":"Export HTML",onClick:()=>$(b),children:e.jsx(v.oa,{name:"external-link",size:16})}),o==="tab"&&e.jsxs("span",{className:"nice-md-editor__tabs",children:[e.jsx("button",{type:"button",className:`nice-md-editor__tab${O==="edit"?" nice-md-editor__tab--active":""}`,onClick:()=>y("edit"),children:"Edit"}),e.jsx("button",{type:"button",className:`nice-md-editor__tab${O==="preview"?" nice-md-editor__tab--active":""}`,onClick:()=>y("preview"),children:"Preview"})]})]}),e.jsxs("div",{className:"nice-md-editor__body",style:{minHeight:E},children:[c&&e.jsxs("div",{className:"nice-md-editor__editor-wrap",children:[F&&e.jsx("div",{className:"nice-md-editor__line-numbers",children:Array.from({length:S.lines},(p,d)=>e.jsx("div",{className:"nice-md-editor__line-no",children:d+1},d))}),e.jsx("textarea",{ref:r,className:"nice-md-editor__textarea",value:t,onChange:p=>i?.(p.target.value),onKeyDown:k,onDrop:j,placeholder:a,disabled:l,readOnly:u,style:{minHeight:E}})]}),z&&e.jsx("div",{className:"nice-md-editor__preview",dangerouslySetInnerHTML:{__html:v.lc(b)},style:{minHeight:E}})]}),Y&&e.jsxs("div",{className:"nice-md-editor__statusbar",children:[e.jsxs("span",{children:[S.words," words"]}),e.jsxs("span",{children:[S.chars," chars"]}),e.jsxs("span",{children:[S.lines," lines"]})]})]})});Pn.displayName="NiceMarkdownEditor";const io=[{target:".nice-image-editor",titleKey:"tutorial.imageEditor.intro.title",title:"Image editor",contentKey:"tutorial.imageEditor.intro.content",content:"Use the toolbar to crop, rotate, flip, adjust brightness/contrast and annotate; undo/redo your edits, then save the result.",placement:"auto"}],rn={rotation:0,flipH:!1,flipV:!1,brightness:100,contrast:100,saturate:100,blur:0,crop:null,annotations:[]},oo=["crop","rotate","flip","brightness","contrast","saturate","blur","annotate"],Hn=n.forwardRef(({src:t,size:i="md",editorSize:o="standard",tools:a=oo,showToolbar:l=!0,showZoom:u=!0,maxUndo:_=30,onSave:g,onCancel:A,onChange:E,width:Y="100%",height:F=500,tutorial:$,className:T,style:G,id:ie,...V},ee)=>{const M=v.bc(ie),{t:f}=v.Gt(),O=n.useRef(null),y=n.useRef(null),[I,B]=n.useState({...rn}),[r,b]=n.useState(null),[S,U]=n.useState(!1),[k,j]=n.useState(1),[c,z]=n.useState("rect"),[R,p]=n.useState("var(--nice-danger, #ff0000)"),[d,m]=n.useState({w:0,h:0}),[x,D]=n.useState([]),[N,H]=n.useState([]),[L,Q]=n.useState(null),[w,K]=n.useState(null),[Z,pe]=n.useState(null),q=n.useCallback(h=>{D(P=>[...P.slice(-(_-1)),h]),H([])},[_]),ne=n.useCallback(h=>{B(P=>{q(P);const ce={...P,...h};return E?.(ce),ce})},[E,q]),re=n.useCallback(()=>{if(x.length===0)return;const h=x[x.length-1];D(P=>P.slice(0,-1)),H(P=>[...P,I]),B(h),E?.(h)},[x,I,E]),ue=n.useCallback(()=>{if(N.length===0)return;const h=N[N.length-1];H(P=>P.slice(0,-1)),D(P=>[...P,I]),B(h),E?.(h)},[N,I,E]);n.useEffect(()=>{const h=new Image;h.crossOrigin="anonymous",h.onload=()=>{y.current=h,m({w:h.width,h:h.height}),U(!0)},h.src=t},[t]),n.useEffect(()=>{if(!S||!O.current||!y.current)return;const h=O.current,P=h.getContext("2d");if(!P)return;const ce=y.current,oe=I.rotation%180!==0,ke=oe?ce.height:ce.width,de=oe?ce.width:ce.height;h.width=ke,h.height=de,P.clearRect(0,0,ke,de),P.save(),P.filter=`brightness(${I.brightness}%) contrast(${I.contrast}%) saturate(${I.saturate}%) blur(${I.blur}px)`,P.translate(ke/2,de/2),P.rotate(I.rotation*Math.PI/180),P.scale(I.flipH?-1:1,I.flipV?-1:1),P.drawImage(ce,-ce.width/2,-ce.height/2),P.restore(),I.annotations.forEach(ae=>{switch(P.save(),P.strokeStyle=ae.color??"red",P.fillStyle=ae.color??"red",P.lineWidth=ae.strokeWidth??2,P.font=`${ae.fontSize??16}px sans-serif`,ae.type){case"text":P.fillText(ae.text??"",ae.x,ae.y);break;case"rect":P.strokeRect(ae.x,ae.y,ae.width??100,ae.height??50);break;case"circle":{const be=(ae.width??50)/2,he=(ae.height??50)/2;P.beginPath(),P.ellipse(ae.x+be,ae.y+he,be,he,0,0,Math.PI*2),P.stroke();break}case"line":P.beginPath(),P.moveTo(ae.x,ae.y),P.lineTo(ae.x+(ae.width??100),ae.y+(ae.height??0)),P.stroke();break;case"arrow":{const be=ae.x+(ae.width??100),he=ae.y+(ae.height??0);P.beginPath(),P.moveTo(ae.x,ae.y),P.lineTo(be,he),P.stroke();const Ce=Math.atan2(he-ae.y,be-ae.x),Me=10;P.beginPath(),P.moveTo(be,he),P.lineTo(be-Me*Math.cos(Ce-.4),he-Me*Math.sin(Ce-.4)),P.lineTo(be-Me*Math.cos(Ce+.4),he-Me*Math.sin(Ce+.4)),P.closePath(),P.fill();break}}P.restore()}),w&&(P.save(),P.fillStyle="var(--nice-overlay-50, rgba(0, 0, 0, 0.5))",P.fillRect(0,0,ke,de),P.clearRect(w.x,w.y,w.w,w.h),P.strokeStyle="var(--bg-primary, #fff)",P.lineWidth=2,P.setLineDash([5,5]),P.strokeRect(w.x,w.y,w.w,w.h),P.restore())},[S,I,w]);const je=n.useCallback(h=>{if(!O.current)return;const P=O.current.getBoundingClientRect(),ce=O.current.width/P.width,oe=O.current.height/P.height,ke=(h.clientX-P.left)*ce,de=(h.clientY-P.top)*oe;r==="crop"?Q({startX:ke,startY:de}):r==="annotate"&&pe({startX:ke,startY:de})},[r]),J=n.useCallback(h=>{if(!O.current)return;const P=O.current.getBoundingClientRect(),ce=O.current.width/P.width,oe=O.current.height/P.height,ke=(h.clientX-P.left)*ce,de=(h.clientY-P.top)*oe;L&&K({x:Math.min(L.startX,ke),y:Math.min(L.startY,de),w:Math.abs(ke-L.startX),h:Math.abs(de-L.startY)})},[L]),ge=n.useCallback(h=>{if(L&&w&&w.w>5&&w.h>5&&ne({crop:{x:w.x,y:w.y,width:w.w,height:w.h}}),Q(null),Z&&O.current){const P=O.current.getBoundingClientRect(),ce=O.current.width/P.width,oe=O.current.height/P.height,ke=(h.clientX-P.left)*ce,de=(h.clientY-P.top)*oe,ae=ke-Z.startX,be=de-Z.startY;if(Math.abs(ae)>3||Math.abs(be)>3||c==="text"){const he={type:c,x:Z.startX,y:Z.startY,width:Math.abs(ae)||100,height:Math.abs(be)||50,color:R,strokeWidth:2,text:c==="text"?prompt(f("imageEditor.annotationText","Text:"))??"":void 0};ne({annotations:[...I.annotations,he]})}pe(null)}},[L,w,Z,c,R,I.annotations,ne,f]),ye=n.useCallback(()=>{if(!I.crop||!O.current)return;const h=O.current,P=h.getContext("2d");if(!P)return;const{x:ce,y:oe,width:ke,height:de}=I.crop,ae=P.getImageData(ce,oe,ke,de);h.width=ke,h.height=de,P.putImageData(ae,0,0),K(null),b(null)},[I.crop]),se=n.useCallback(()=>{if(!O.current)return;const h=O.current.toDataURL("image/png");g?.(h,I)},[g,I]),me=n.useCallback(()=>{B({...rn}),K(null),b(null)},[]);n.useMemo(()=>`brightness(${I.brightness}%) contrast(${I.contrast}%) saturate(${I.saturate}%) blur(${I.blur}px)`,[I.brightness,I.contrast,I.saturate,I.blur]);const fe=l?e.jsxs("div",{className:"nice-image-editor__toolbar",role:"toolbar",children:[e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:re,disabled:x.length===0,title:f("imageEditor.undo","Undo"),"aria-label":f("imageEditor.undo","Undo"),children:e.jsx(v.oa,{name:"reply",size:16})}),e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:ue,disabled:N.length===0,title:f("imageEditor.redo","Redo"),"aria-label":f("imageEditor.redo","Redo"),children:e.jsx(v.oa,{name:"forward",size:16})}),e.jsx("span",{className:"nice-image-editor__sep"}),a.includes("rotate")&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>ne({rotation:(I.rotation-90+360)%360}),title:f("imageEditor.rotateLeft","Rotate left"),"aria-label":f("imageEditor.rotateLeft","Rotate left"),children:e.jsx(v.oa,{name:"reply",size:16})}),e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>ne({rotation:(I.rotation+90)%360}),title:f("imageEditor.rotateRight","Rotate right"),"aria-label":f("imageEditor.rotateRight","Rotate right"),children:e.jsx(v.oa,{name:"forward",size:16})})]}),a.includes("flip")&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>ne({flipH:!I.flipH}),title:f("imageEditor.flipH","Flip horizontal"),"aria-label":f("imageEditor.flipH","Flip horizontal"),children:e.jsx(v.oa,{name:"shuffle",size:16})}),e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>ne({flipV:!I.flipV}),title:f("imageEditor.flipV","Flip vertical"),"aria-label":f("imageEditor.flipV","Flip vertical"),children:e.jsx(v.oa,{name:"shuffle",size:16})})]}),a.includes("crop")&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:`nice-image-editor__btn ${r==="crop"?"nice-image-editor__btn--active":""}`,onClick:()=>b(r==="crop"?null:"crop"),title:f("imageEditor.crop","Crop"),"aria-label":f("imageEditor.crop","Crop"),children:e.jsx(v.oa,{name:"box",size:16})}),r==="crop"&&I.crop&&e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:ye,title:f("imageEditor.applyCrop","Apply crop"),"aria-label":f("imageEditor.applyCrop","Apply crop"),children:e.jsx(v.oa,{name:"check",size:16})})]}),a.includes("brightness")&&e.jsxs("label",{className:"nice-image-editor__slider-label",title:f("imageEditor.brightness","Brightness"),children:[e.jsx(v.oa,{name:"lightbulb",size:16}),e.jsx("input",{type:"range",min:0,max:200,value:I.brightness,onChange:h=>ne({brightness:Number(h.target.value)}),className:"nice-image-editor__slider",title:f("imageEditor.brightness","Brightness")})]}),a.includes("contrast")&&e.jsxs("label",{className:"nice-image-editor__slider-label",title:f("imageEditor.contrast","Contrast"),children:[e.jsx(v.oa,{name:"circle",size:16}),e.jsx("input",{type:"range",min:0,max:200,value:I.contrast,onChange:h=>ne({contrast:Number(h.target.value)}),className:"nice-image-editor__slider",title:f("imageEditor.contrast","Contrast")})]}),a.includes("saturate")&&e.jsxs("label",{className:"nice-image-editor__slider-label",title:f("imageEditor.saturate","Saturation"),children:[e.jsx(v.oa,{name:"palette",size:16}),e.jsx("input",{type:"range",min:0,max:200,value:I.saturate,onChange:h=>ne({saturate:Number(h.target.value)}),className:"nice-image-editor__slider",title:f("imageEditor.saturate","Saturation")})]}),a.includes("blur")&&e.jsxs("label",{className:"nice-image-editor__slider-label",title:f("imageEditor.blur","Blur"),children:[e.jsx(v.oa,{name:"eye-off",size:16}),e.jsx("input",{type:"range",min:0,max:20,step:.5,value:I.blur,onChange:h=>ne({blur:Number(h.target.value)}),className:"nice-image-editor__slider",title:f("imageEditor.blur","Blur")})]}),a.includes("annotate")&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"nice-image-editor__sep"}),e.jsx("button",{type:"button",className:`nice-image-editor__btn ${r==="annotate"?"nice-image-editor__btn--active":""}`,onClick:()=>b(r==="annotate"?null:"annotate"),title:f("imageEditor.annotate","Annotate"),"aria-label":f("imageEditor.annotate","Annotate"),children:e.jsx(v.oa,{name:"edit",size:16})}),r==="annotate"&&e.jsxs(e.Fragment,{children:[e.jsxs("select",{className:"nice-image-editor__select",value:c,onChange:h=>z(h.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:"Text"})]}),e.jsx("input",{type:"color",value:R,onChange:h=>p(h.target.value),className:"nice-image-editor__color",title:f("imageEditor.color","Color")}),I.annotations.length>0&&e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>ne({annotations:I.annotations.slice(0,-1)}),title:f("imageEditor.removeLastAnnotation","Remove last"),"aria-label":f("imageEditor.removeLastAnnotation","Remove last"),children:e.jsx(v.oa,{name:"trash",size:16})})]})]}),e.jsx("span",{className:"nice-image-editor__sep"}),e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:me,title:f("imageEditor.reset","Reset"),"aria-label":f("imageEditor.reset","Reset"),children:e.jsx(v.oa,{name:"refresh",size:16})}),g&&e.jsx("button",{type:"button",className:"nice-image-editor__btn nice-image-editor__btn--save",onClick:se,children:f("imageEditor.save","Save")}),A&&e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:A,children:f("imageEditor.cancel","Cancel")})]}):void 0,W=u?e.jsxs("div",{className:"nice-image-editor__footer",children:[e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>j(h=>Math.max(.1,h-.1)),title:"Zoom out","aria-label":"Zoom out",children:e.jsx(v.oa,{name:"minus",size:16})}),e.jsxs("span",{style:{fontSize:"0.85em",minWidth:40,textAlign:"center"},children:[Math.round(k*100),"%"]}),e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>j(h=>Math.min(5,h+.1)),title:"Zoom in","aria-label":"Zoom in",children:e.jsx(v.oa,{name:"plus",size:16})}),e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>j(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:[d.w,"×",d.h,"px · ",I.rotation,"°"]})]}):void 0;return e.jsx(ln.NiceAppShell,{ref:ee,flush:!0,id:M,className:`nice-image-editor nice-image-editor--${i} nice-editor--${o} ${T??""}`,style:{...G,width:Y,height:F},toolbar:fe,statusBar:W,children:e.jsxs("div",{className:"nice-image-editor__canvas-wrap",style:{position:"relative"},role:"application","aria-label":f("imageEditor.label","Image Editor"),...V,children:[e.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:20},children:e.jsx(v.Ql,{steps:v.Yl($,io)})}),e.jsx("canvas",{ref:O,className:"nice-image-editor__canvas",onMouseDown:je,onMouseMove:J,onMouseUp:ge,style:{cursor:r==="crop"||r==="annotate"?"crosshair":"default",transform:`scale(${k})`,transformOrigin:"center center"}})]})})});Hn.displayName="NiceImageEditor";const ao=[{target:".nice-doc-editor",titleKey:"tutorial.documentEditor.intro.title",title:"Document editor",contentKey:"tutorial.documentEditor.intro.content",content:"Compose a document from blocks: use the toolbar or slash commands to add headings, lists, media and more, then export to HTML.",placement:"auto"}];let so=0;function Dt(){return`blk-${++so}-${Date.now().toString(36)}`}function cn(t=""){return{id:Dt(),type:"paragraph",content:t}}function ro(t,i=""){const o={id:Dt(),type:t,content:i};return t==="heading"&&(o.level=2),t==="list"&&(o.listType="unordered"),t==="callout"&&(o.icon="??"),t==="toggle"&&(o.open=!0),o}const co=[{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 lo(t){const i=[t.align?`text-align:${t.align}`:"",t.color?`color:${t.color}`:"",t.bgColor?`background-color:${t.bgColor}`:"",t.indent?`margin-left:${t.indent*24}px`:""].filter(Boolean).join(";"),o=i?` style="${i}"`:"",a=(l,u)=>{let _=u;return t.bold&&(_=`<strong>${_}</strong>`),t.italic&&(_=`<em>${_}</em>`),t.underline&&(_=`<u>${_}</u>`),t.strikethrough&&(_=`<s>${_}</s>`),`<${l}${o}>${_}</${l}>`};switch(t.type){case"heading":return a(`h${t.level??2}`,t.content);case"paragraph":return a("p",t.content||" ");case"list":{const l=t.listType==="ordered"?"ol":"ul",u=t.content.split(`
|
|
692
|
+
`).map((_,g)=>t.listType==="checklist"?`<li><input type="checkbox" ${t.checked?.[g]??!1?"checked":""} disabled />${_}</li>`:`<li>${_}</li>`).join("");return`<${l}${o}>${u}</${l}>`}case"image":return`<figure${o}><img src="${t.src??""}" alt="${t.alt??""}" /></figure>`;case"video":return`<figure${o}><video src="${t.src??""}" controls></video></figure>`;case"divider":return"<hr />";case"pageBreak":return'<div style="page-break-after:always"></div>';case"code":return`<pre><code class="language-${t.language??""}">${t.content}</code></pre>`;case"quote":return a("blockquote",t.content);case"callout":return`<div class="nice-doc-callout"${o}><span>${t.icon??"??"}</span><div>${t.content}</div></div>`;case"toggle":return`<details${o}><summary>${t.content.split(`
|
|
693
|
+
`)[0]}</summary>${t.content.split(`
|
|
694
|
+
`).slice(1).join("<br>")}</details>`;case"table":return`<table${o}>${t.content}</table>`;case"embed":return`<iframe src="${t.src??""}" style="width:100%;border:none;min-height:300px"></iframe>`;default:return a("p",t.content)}}function mo(t){let i=0,o=0;for(const a of t){const l=a.content??"";i+=l.length;const u=l.trim().split(/\s+/).filter(Boolean);o+=u.length}return{words:o,chars:i,readingTime:Math.max(1,Math.ceil(o/200))}}const On=n.forwardRef(({blocks:t,onChange:i,readOnly:o=!1,showToolbar:a=!0,size:l="md",editorSize:u="standard",placeholder:_,onExport:g,onImageUpload:A,maxUndo:E=50,slashCommands:Y=!0,showWordCount:F=!1,showToc:$=!1,showFindReplace:T=!0,tutorial:G,className:ie,style:V,id:ee,...M},f)=>{const O=v.bc(ee),{t:y}=v.Gt(),[I,B]=n.useState(()=>t??[cn()]),r=t??I,[b,S]=n.useState(0),U=n.useRef(new Map),k=n.useRef(null),[j,c]=n.useState(!1),[z,R]=n.useState(""),[p,d]=n.useState(""),[m,x]=n.useState([]),[D,N]=n.useState(0),[H,L]=n.useState(!1),Q=n.useRef([]),w=n.useRef([]),K=n.useCallback(s=>{Q.current.push(s.map(C=>({...C,checked:C.checked?[...C.checked]:void 0}))),Q.current.length>E&&Q.current.shift(),w.current=[]},[E]),Z=n.useCallback(()=>{if(Q.current.length===0)return;const s=Q.current.pop();w.current.push(r.map(C=>({...C}))),t||B(s),i?.(s)},[r,t,i]),pe=n.useCallback(()=>{if(w.current.length===0)return;const s=w.current.pop();Q.current.push(r.map(C=>({...C}))),t||B(s),i?.(s)},[r,t,i]),[q,ne]=n.useState(!1),[re,ue]=n.useState(""),[je,J]=n.useState(0),ge=n.useMemo(()=>{if(!q||!Y)return[];const s=re.toLowerCase();return co.filter(C=>C.label.toLowerCase().includes(s)||C.keywords.includes(s))},[q,re,Y]),[ye,se]=n.useState(null),[me,fe]=n.useState(null),W=n.useCallback(s=>{K(r);const C=s(r);t||B(C),i?.(C)},[r,t,i,K]),h=n.useCallback((s,C)=>{W(X=>X.map((le,_e)=>_e===s?{...le,...C}:le))},[W]),P=n.useCallback((s,C)=>{const X=C??cn();W(le=>{const _e=[...le];return _e.splice(s+1,0,X),_e}),S(s+1)},[W]),ce=n.useCallback(s=>{const C={...r[s],id:Dt()};P(s,C)},[r,P]),oe=n.useCallback(s=>{r.length<=1||(W(C=>C.filter((X,le)=>le!==s)),S(Math.max(0,s-1)))},[r.length,W]),ke=n.useCallback((s,C)=>{const X=s+C;X<0||X>=r.length||(W(le=>{const _e=[...le];return[_e[s],_e[X]]=[_e[X],_e[s]],_e}),S(X))},[r.length,W]),de=n.useCallback((s,C)=>{const X={type:C};C==="heading"&&(X.level=2),C==="list"&&(X.listType="unordered"),C==="callout"&&(X.icon="??"),C==="toggle"&&(X.open=!0),h(s,X)},[h]),ae=n.useCallback(s=>{const C=ro(s.type);s.type==="list"&&s.label.includes("Numbered")&&(C.listType="ordered"),s.type==="list"&&s.label.includes("Checklist")&&(C.listType="checklist",C.checked=[]),r[b]?.content===""||r[b]?.content==="/"?W(X=>X.map((le,_e)=>_e===b?{...C,id:le.id}:le)):P(b,C),ne(!1),ue("")},[r,b,W,P]),be=n.useCallback((s,C)=>{if(o)return;const X=r[C];if(!X?.locked){if((s.ctrlKey||s.metaKey)&&s.key==="z"&&!s.shiftKey){s.preventDefault(),Z();return}if((s.ctrlKey||s.metaKey)&&(s.key==="y"||s.key==="z"&&s.shiftKey)){s.preventDefault(),pe();return}if((s.ctrlKey||s.metaKey)&&s.key==="d"){s.preventDefault(),ce(C);return}if((s.ctrlKey||s.metaKey)&&s.key==="b"){s.preventDefault(),h(C,{bold:!X?.bold});return}if((s.ctrlKey||s.metaKey)&&s.key==="i"){s.preventDefault(),h(C,{italic:!X?.italic});return}if((s.ctrlKey||s.metaKey)&&s.key==="u"){s.preventDefault(),h(C,{underline:!X?.underline});return}if((s.ctrlKey||s.metaKey)&&s.key==="e"){s.preventDefault(),h(C,{strikethrough:!X?.strikethrough});return}if(s.key==="Tab"&&!s.shiftKey){s.preventDefault(),h(C,{indent:Math.min((X?.indent??0)+1,4)});return}if(s.key==="Tab"&&s.shiftKey){s.preventDefault(),h(C,{indent:Math.max((X?.indent??0)-1,0)});return}if((s.ctrlKey||s.metaKey)&&s.key==="f"&&T){s.preventDefault(),c(le=>!le);return}if(q&&ge.length>0){if(s.key==="ArrowDown"){s.preventDefault(),J(le=>Math.min(le+1,ge.length-1));return}if(s.key==="ArrowUp"){s.preventDefault(),J(le=>Math.max(le-1,0));return}if(s.key==="Enter"){s.preventDefault(),ae(ge[je]);return}if(s.key==="Escape"){ne(!1);return}}s.key==="Enter"&&!s.shiftKey?(s.preventDefault(),P(C)):s.key==="Backspace"&&r[C].content===""&&r.length>1?(s.preventDefault(),oe(C)):s.key==="ArrowUp"&&s.altKey?(s.preventDefault(),ke(C,-1)):s.key==="ArrowDown"&&s.altKey&&(s.preventDefault(),ke(C,1))}},[o,r,P,oe,ke,Z,pe,ce,h,q,ge,je,ae,T]),he=n.useCallback((s,C)=>{const X=s.target.textContent??"";Y&&X.startsWith("/")?(ne(!0),ue(X.slice(1)),J(0)):q&&ne(!1),K(r);const le=r.map((_e,Ae)=>Ae===C?{..._e,content:X}:_e);t||B(le),i?.(le)},[r,t,i,K,Y,q]),Ce=n.useCallback((s,C)=>{se(C),s.dataTransfer.effectAllowed="move"},[]),Me=n.useCallback((s,C)=>{s.preventDefault(),s.dataTransfer.dropEffect="move",fe(C)},[]),$e=n.useCallback((s,C)=>{if(s.preventDefault(),ye===null||ye===C){se(null),fe(null);return}W(X=>{const le=[...X],[_e]=le.splice(ye,1);return le.splice(C>ye?C-1:C,0,_e),le}),S(C>ye?C-1:C),se(null),fe(null)},[ye,W]);n.useEffect(()=>{if(!j||!z){x([]);return}const s=z.toLowerCase(),C=[];r.forEach((X,le)=>{const _e=(X.content??"").toLowerCase();let Ae=0;for(;Ae<_e.length;){const Le=_e.indexOf(s,Ae);if(Le===-1)break;C.push({blockIdx:le,start:Le,end:Le+s.length}),Ae=Le+1}}),x(C),N(0)},[z,j,r]);const Te=n.useCallback(()=>{if(m.length===0)return;const s=(D+1)%m.length;N(s),S(m[s].blockIdx)},[m,D]),Ue=n.useCallback(()=>{if(m.length===0)return;const s=(D-1+m.length)%m.length;N(s),S(m[s].blockIdx)},[m,D]),Qe=n.useCallback(()=>{if(m.length===0||!z)return;const s=m[D],C=r[s.blockIdx],X=C.content.slice(0,s.start),le=C.content.slice(s.end);h(s.blockIdx,{content:X+p+le})},[m,D,z,p,r,h]),Je=n.useCallback(()=>{if(!z)return;const s=z;W(C=>C.map(X=>({...X,content:X.content.split(s).join(p)})))},[z,p,W]),We=n.useMemo(()=>$?r.map((s,C)=>s.type==="heading"?{idx:C,level:s.level??2,text:s.content}:null).filter(Boolean):[],[r,$]),Ze=n.useCallback(async s=>{const C=s.target.files?.[0];if(C){if(A){const X=await A(C);h(b,{src:X})}s.target.value=""}},[A,b,h]);n.useEffect(()=>{const s=r[b];if(s){const C=U.current.get(s.id);C&&C.focus()}},[b,r]);const Se=n.useCallback(()=>{const s=r.map(lo).join(`
|
|
695
|
+
`);g?.(s)},[r,g]),Fe=n.useMemo(()=>F?mo(r):null,[r,F]),[we,De]=n.useState(null),Pe=n.useCallback((s,C)=>{o||(s.preventDefault(),De({x:s.clientX,y:s.clientY,idx:C}))},[o]);return n.useEffect(()=>{if(!we)return;const s=()=>De(null);return window.addEventListener("click",s),()=>window.removeEventListener("click",s)},[we]),e.jsxs("div",{ref:f,id:O,className:`nice-doc-editor nice-doc-editor--${l} nice-editor--${u} ${o?"nice-doc-editor--readonly":""} ${ie??""}`,style:{position:"relative",...V},role:"application","aria-label":y("docEditor.label","Document Editor"),...M,children:[e.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:20},children:e.jsx(v.Ql,{steps:v.Yl(G,ao)})}),a&&!o&&e.jsxs("div",{className:"nice-doc-editor__toolbar",role:"toolbar",style:{display:"flex",flexWrap:"wrap",gap:4,alignItems:"center",padding:"4px 8px"},children:[e.jsx(ve.NiceButton,{size:"sm",variant:"ghost",onClick:Z,title:y("docEditor.undo","Undo (Ctrl+Z)"),children:"?"}),e.jsx(ve.NiceButton,{size:"sm",variant:"ghost",onClick:pe,title:y("docEditor.redo","Redo (Ctrl+Y)"),children:"?"}),e.jsx("span",{className:"nice-doc-editor__sep"}),e.jsx(ve.NiceSelect,{size:"sm",value:r[b]?.type??"paragraph",onChange:s=>de(b,s),label:"",options:[{value:"paragraph",label:y("docEditor.paragraph","Paragraph")},{value:"heading",label:y("docEditor.heading","Heading")},{value:"list",label:y("docEditor.list","List")},{value:"code",label:y("docEditor.code","Code")},{value:"quote",label:y("docEditor.quote","Quote")},{value:"callout",label:y("docEditor.callout","Callout")},{value:"toggle",label:y("docEditor.toggle","Toggle")},{value:"divider",label:y("docEditor.divider","Divider")},{value:"image",label:y("docEditor.image","Image")},{value:"video",label:y("docEditor.video","Video")},{value:"pageBreak",label:y("docEditor.pageBreak","Page Break")}],style:{minWidth:100}}),r[b]?.type==="heading"&&e.jsx(ve.NiceSelect,{size:"sm",value:String(r[b]?.level??2),onChange:s=>h(b,{level:Number(s)}),label:"",options:[{value:"1",label:"H1"},{value:"2",label:"H2"},{value:"3",label:"H3"},{value:"4",label:"H4"},{value:"5",label:"H5"},{value:"6",label:"H6"}],style:{minWidth:55}}),r[b]?.type==="list"&&e.jsx(ve.NiceSelect,{size:"sm",value:r[b]?.listType??"unordered",onChange:s=>h(b,{listType:s}),label:"",options:[{value:"unordered",label:"� Bullets"},{value:"ordered",label:"1. Numbers"},{value:"checklist",label:"? Checklist"}],style:{minWidth:90}}),e.jsx("span",{className:"nice-doc-editor__sep"}),e.jsx(ve.NiceButton,{size:"sm",variant:r[b]?.bold?"primary":"ghost",onClick:()=>h(b,{bold:!r[b]?.bold}),title:y("docEditor.bold","Bold (Ctrl+B)"),children:e.jsx("strong",{children:"B"})}),e.jsx(ve.NiceButton,{size:"sm",variant:r[b]?.italic?"primary":"ghost",onClick:()=>h(b,{italic:!r[b]?.italic}),title:y("docEditor.italic","Italic (Ctrl+I)"),children:e.jsx("em",{children:"I"})}),e.jsx(ve.NiceButton,{size:"sm",variant:r[b]?.underline?"primary":"ghost",onClick:()=>h(b,{underline:!r[b]?.underline}),title:y("docEditor.underline","Underline (Ctrl+U)"),children:e.jsx("u",{children:"U"})}),e.jsx(ve.NiceButton,{size:"sm",variant:r[b]?.strikethrough?"primary":"ghost",onClick:()=>h(b,{strikethrough:!r[b]?.strikethrough}),title:y("docEditor.strikethrough","Strikethrough (Ctrl+E)"),children:e.jsx("s",{children:"S"})}),e.jsx("span",{className:"nice-doc-editor__sep"}),e.jsx(ve.NiceButton,{size:"sm",variant:r[b]?.align==="left"?"primary":"ghost",onClick:()=>h(b,{align:"left"}),title:y("docEditor.alignLeft","Left"),children:"?"}),e.jsx(ve.NiceButton,{size:"sm",variant:r[b]?.align==="center"?"primary":"ghost",onClick:()=>h(b,{align:"center"}),title:y("docEditor.alignCenter","Center"),children:"?"}),e.jsx(ve.NiceButton,{size:"sm",variant:r[b]?.align==="right"?"primary":"ghost",onClick:()=>h(b,{align:"right"}),title:y("docEditor.alignRight","Right"),children:"?"}),e.jsx("span",{className:"nice-doc-editor__sep"}),e.jsx(ve.NiceButton,{size:"sm",variant:"ghost",onClick:()=>h(b,{indent:Math.min((r[b]?.indent??0)+1,4)}),title:y("docEditor.indent","Indent (Tab)"),children:"??"}),e.jsx(ve.NiceButton,{size:"sm",variant:"ghost",onClick:()=>h(b,{indent:Math.max((r[b]?.indent??0)-1,0)}),title:y("docEditor.outdent","Outdent (Shift+Tab)"),children:"??"}),e.jsx("span",{className:"nice-doc-editor__sep"}),e.jsx(ve.NiceColorPicker,{size:"sm",label:"",value:r[b]?.color??"var(--text-primary, #000000)",onChange:s=>h(b,{color:s}),title:"Text color"}),e.jsx(ve.NiceColorPicker,{size:"sm",label:"",value:r[b]?.bgColor??"var(--bg-primary, #ffffff)",onChange:s=>h(b,{bgColor:s}),title:"Block background"}),e.jsx("span",{className:"nice-doc-editor__sep"}),e.jsx(ve.NiceButton,{size:"sm",variant:r[b]?.locked?"primary":"ghost",onClick:()=>h(b,{locked:!r[b]?.locked}),title:y("docEditor.lock","Lock/Unlock block"),children:"??"}),e.jsx(ve.NiceButton,{size:"sm",variant:"ghost",onClick:()=>ce(b),title:y("docEditor.duplicate","Duplicate (Ctrl+D)"),children:"?"}),e.jsx(ve.NiceButton,{size:"sm",variant:"ghost",onClick:()=>oe(b),title:y("docEditor.delete","Delete block"),children:"??"}),e.jsx(ve.NiceButton,{size:"sm",variant:"ghost",onClick:()=>P(b),title:y("docEditor.addBlock","Add block"),children:"+"}),T&&e.jsx(ve.NiceButton,{size:"sm",variant:j?"primary":"ghost",onClick:()=>c(s=>!s),title:y("docEditor.find","Find & Replace (Ctrl+F)"),children:"??"}),e.jsx(ve.NiceButton,{size:"sm",variant:"ghost",onClick:()=>L(s=>!s),title:y("docEditor.shortcuts","Keyboard shortcuts"),children:"?"}),g&&e.jsx(ve.NiceButton,{size:"sm",variant:"ghost",onClick:Se,children:y("docEditor.export","Export HTML")})]}),e.jsx("input",{ref:k,type:"file",accept:"image/*,video/*",style:{display:"none"},onChange:Ze}),j&&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(ve.NiceTextInput,{size:"sm",placeholder:y("docEditor.findPlaceholder","Find..."),value:z,onChange:R,style:{flex:1,maxWidth:200}}),e.jsx(ve.NiceTextInput,{size:"sm",placeholder:y("docEditor.replacePlaceholder","Replace..."),value:p,onChange:d,style:{flex:1,maxWidth:200}}),e.jsx(ve.NiceButton,{size:"sm",variant:"ghost",onClick:Ue,title:y("docEditor.findPrev","Previous"),children:"?"}),e.jsx(ve.NiceButton,{size:"sm",variant:"ghost",onClick:Te,title:y("docEditor.findNext","Next"),children:"?"}),e.jsx(ve.NiceButton,{size:"sm",variant:"ghost",onClick:Qe,title:y("docEditor.replaceOne","Replace"),disabled:o,children:y("docEditor.replace","Replace")}),e.jsx(ve.NiceButton,{size:"sm",variant:"ghost",onClick:Je,title:y("docEditor.replaceAll","Replace all"),disabled:o,children:y("docEditor.replaceAllBtn","All")}),e.jsx("span",{style:{fontSize:"0.75em",color:"var(--text-muted, #666)"},children:m.length>0?`${D+1}/${m.length}`:"0/0"}),e.jsx(ve.NiceButton,{size:"sm",variant:"ghost",onClick:()=>c(!1),children:"?"})]}),H&&e.jsx("div",{className:"nice-doc-editor__shortcuts-overlay",style:{position:"fixed",inset:0,background:"var(--nice-overlay-40, rgba(0, 0, 0, 0.4))",zIndex:9999,display:"flex",alignItems:"center",justifyContent:"center"},onClick:()=>L(!1),children:e.jsxs("div",{style:{background:"var(--bg-primary, #fff)",borderRadius:8,padding:24,maxWidth:420,width:"90%",boxShadow:"0 8px 32px var(--nice-overlay-20, rgba(0, 0, 0, 0.2))"},onClick:s=>s.stopPropagation(),children:[e.jsx("h3",{style:{margin:"0 0 12px"},children:y("docEditor.shortcutsTitle","Keyboard Shortcuts")}),e.jsx("table",{style:{width:"100%",fontSize:"0.875em",borderCollapse:"collapse"},children:e.jsx("tbody",{children:[["Ctrl+B",y("docEditor.bold","Bold")],["Ctrl+I",y("docEditor.italic","Italic")],["Ctrl+U",y("docEditor.underline","Underline")],["Ctrl+E",y("docEditor.strikethrough","Strikethrough")],["Ctrl+D",y("docEditor.duplicate","Duplicate block")],["Ctrl+Z",y("docEditor.undo","Undo")],["Ctrl+Y",y("docEditor.redo","Redo")],["Ctrl+F",y("docEditor.find","Find & Replace")],["Enter",y("docEditor.newBlock","New block")],["Backspace",y("docEditor.deleteEmpty","Delete empty block")],["Alt+?",y("docEditor.moveUp","Move block up")],["Alt+?",y("docEditor.moveDown","Move block down")],["Tab",y("docEditor.indent","Indent")],["Shift+Tab",y("docEditor.outdent","Outdent")],["/",y("docEditor.slashCmd","Slash commands")]].map(([s,C])=>e.jsxs("tr",{style:{borderBottom:"1px solid var(--border-color, #eee)"},children:[e.jsx("td",{style:{padding:"4px 8px",fontFamily:"monospace",fontWeight:600},children:s}),e.jsx("td",{style:{padding:"4px 8px"},children:C})]},s))})}),e.jsx("div",{style:{textAlign:"right",marginTop:12},children:e.jsx(ve.NiceButton,{size:"sm",variant:"ghost",onClick:()=>L(!1),children:y("docEditor.close","Close")})})]})}),e.jsxs("div",{style:{display:"flex",gap:0},children:[$&&We.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:y("docEditor.toc","Contents")}),We.map(s=>e.jsx("div",{style:{padding:"3px 8px",paddingLeft:8+(s.level-1)*12,cursor:"pointer",borderRadius:4,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",background:s.idx===b?"var(--nice-primary-bg, #e8f0fe)":void 0},onClick:()=>S(s.idx),title:s.text,children:s.text||y("docEditor.untitled","Untitled")},s.idx))]}),e.jsx("div",{className:"nice-doc-editor__body",style:{flex:1},children:r.map((s,C)=>e.jsxs("div",{className:`nice-doc-editor__block nice-doc-editor__block--${s.type} ${C===b?"nice-doc-editor__block--focused":""} ${me===C?"nice-doc-editor__block--drop-target":""} ${s.locked?"nice-doc-editor__block--locked":""}`,onClick:()=>S(C),onContextMenu:X=>Pe(X,C),draggable:!o&&!s.locked,onDragStart:X=>Ce(X,C),onDragOver:X=>Me(X,C),onDrop:X=>$e(X,C),onDragEnd:()=>{se(null),fe(null)},style:{opacity:ye===C?.4:1,marginLeft:(s.indent??0)*24},children:[!o&&!s.locked&&e.jsx("div",{className:"nice-doc-editor__block-handle",title:y("docEditor.drag","Drag to reorder"),children:"?"}),s.locked&&e.jsx("span",{className:"nice-doc-editor__lock-icon",style:{position:"absolute",top:2,right:4,fontSize:"0.7em",opacity:.5},children:"??"}),s.type==="divider"?e.jsx("hr",{className:"nice-doc-editor__divider"}):s.type==="pageBreak"?e.jsxs("div",{className:"nice-doc-editor__page-break",style:{borderTop:"2px dashed var(--nice-border, #ccc)",textAlign:"center",padding:4,fontSize:"0.75em",color:"var(--text-muted, #999)"},children:["� ",y("docEditor.pageBreak","Page Break")," �"]}):s.type==="image"||s.type==="video"?e.jsx("div",{className:"nice-doc-editor__media-block",children:s.src?s.type==="image"?e.jsx("img",{src:s.src,alt:s.alt??"",className:"nice-doc-editor__image",style:{maxWidth:"100%"}}):e.jsx("video",{src:s.src,controls:!0,className:"nice-doc-editor__video",style:{maxWidth:"100%"}}):!o&&e.jsxs("div",{style:{display:"flex",gap:4,alignItems:"center"},children:[e.jsx(ve.NiceTextInput,{size:"sm",placeholder:y("docEditor.mediaUrl",s.type==="image"?"Image URL":"Video URL"),value:s.src??"",onChange:X=>h(C,{src:X})}),A&&e.jsx(ve.NiceButton,{size:"sm",variant:"ghost",onClick:()=>{S(C),k.current?.click()},children:"??"})]})}):s.type==="callout"?e.jsxs("div",{className:"nice-doc-editor__callout",style:{display:"flex",gap:8,padding:"8px 12px",background:s.bgColor??"#f0f7ff",borderRadius:4,color:s.color},children:[e.jsx("span",{style:{fontSize:"1.2em"},children:s.icon??"??"}),e.jsx("div",{ref:X=>{X&&U.current.set(s.id,X)},className:"nice-doc-editor__content",contentEditable:!o&&!s.locked,suppressContentEditableWarning:!0,onInput:X=>he(X,C),onFocus:()=>S(C),onKeyDown:X=>be(X,C),"data-placeholder":y("docEditor.calloutPlaceholder","Callout text..."),role:"textbox","aria-multiline":"true",style:{flex:1,outline:"none"},children:s.content})]}):s.type==="toggle"?e.jsxs("details",{open:s.open,className:"nice-doc-editor__toggle",onToggle:X=>h(C,{open:X.target.open}),children:[e.jsx("summary",{style:{cursor:"pointer",fontWeight:500},children:s.content.split(`
|
|
696
|
+
`)[0]||y("docEditor.toggleTitle","Toggle")}),e.jsx("div",{ref:X=>{X&&U.current.set(s.id,X)},className:"nice-doc-editor__content",contentEditable:!o&&!s.locked,suppressContentEditableWarning:!0,onInput:X=>he(X,C),onFocus:()=>S(C),onKeyDown:X=>be(X,C),role:"textbox","aria-multiline":"true",style:{padding:"4px 0"},children:s.content.split(`
|
|
697
|
+
`).slice(1).join(`
|
|
698
|
+
`)})]}):s.type==="code"?e.jsxs("div",{className:"nice-doc-editor__code-block",style:{position:"relative"},children:[!o&&e.jsx(ve.NiceTextInput,{size:"sm",value:s.language??"",onChange:X=>h(C,{language:X}),placeholder:"Language",style:{position:"absolute",top:4,right:4,width:80,opacity:.7}}),e.jsx("pre",{ref:X=>{X&&U.current.set(s.id,X)},className:"nice-doc-editor__content",contentEditable:!o&&!s.locked,suppressContentEditableWarning:!0,onInput:X=>he(X,C),onFocus:()=>S(C),onKeyDown:X=>be(X,C),role:"textbox","aria-multiline":"true",style:{fontFamily:"monospace",background:"var(--bg-elevated, #1e1e1e)",color:"var(--text-secondary, #d4d4d4)",padding:12,borderRadius:4,overflow:"auto"},children:s.content})]}):e.jsxs("div",{style:{position:"relative"},children:[e.jsx("div",{ref:X=>{X&&U.current.set(s.id,X)},className:"nice-doc-editor__content",contentEditable:!o&&!s.locked,suppressContentEditableWarning:!0,style:{textAlign:s.align,fontWeight:s.bold?"bold":void 0,fontStyle:s.italic?"italic":void 0,textDecoration:[s.underline?"underline":"",s.strikethrough?"line-through":""].filter(Boolean).join(" ")||void 0,color:s.color,backgroundColor:s.bgColor},onInput:X=>he(X,C),onFocus:()=>S(C),onKeyDown:X=>be(X,C),"data-placeholder":!s.content&&_?_:void 0,role:"textbox","aria-multiline":"true",children:s.content}),q&&C===b&&ge.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:ge.map((X,le)=>e.jsxs("li",{className:le===je?"nice-doc-editor__slash-item--active":"",style:{padding:"6px 10px",cursor:"pointer",borderRadius:4,display:"flex",gap:8,alignItems:"center",background:le===je?"var(--nice-primary-bg, #e8f0fe)":void 0},onMouseDown:_e=>{_e.preventDefault(),ae(X)},onMouseEnter:()=>J(le),children:[e.jsx("span",{style:{width:24,textAlign:"center"},children:X.icon}),e.jsx("span",{children:X.label})]},`${X.type}-${X.label}`))})]})]},s.id))})]}),we&&e.jsxs("div",{className:"nice-doc-editor__ctx-menu",style:{position:"fixed",left:we.x,top:we.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:()=>{ce(we.idx),De(null)},children:"? Duplicate"}),e.jsx("div",{style:{padding:"6px 12px",cursor:"pointer"},onClick:()=>{P(we.idx),De(null)},children:"+ Insert below"}),e.jsx("div",{style:{padding:"6px 12px",cursor:"pointer"},onClick:()=>{ke(we.idx,-1),De(null)},children:"? Move up"}),e.jsx("div",{style:{padding:"6px 12px",cursor:"pointer"},onClick:()=>{ke(we.idx,1),De(null)},children:"? Move down"}),e.jsx("div",{style:{padding:"6px 12px",cursor:"pointer"},onClick:()=>{h(we.idx,{locked:!r[we.idx]?.locked}),De(null)},children:r[we.idx]?.locked?"?? Unlock":"?? Lock"}),e.jsx("hr",{style:{margin:"2px 0",border:"none",borderTop:"1px solid var(--border-color, #eee)"}}),e.jsx("div",{style:{padding:"6px 12px",cursor:"pointer",color:"var(--nice-danger-dark, #d32f2f)"},onClick:()=>{oe(we.idx),De(null)},children:"?? Delete"})]}),F&&Fe&&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:[Fe.words," ",y("docEditor.words","words")]}),e.jsxs("span",{children:[Fe.chars," ",y("docEditor.chars","characters")]}),e.jsxs("span",{children:[r.length," ",y("docEditor.blocks","blocks")]}),e.jsxs("span",{children:["~",Fe.readingTime," ",y("docEditor.readingTime","min read")]})]})]})});On.displayName="NiceDocumentEditor";const uo=["street","streetNumber","apartment","city","postalCode","state","country"],ft={street:"Street",streetNumber:"Number",apartment:"Apt/Suite",city:"City",postalCode:"Postal Code",state:"State/Province",country:"Country"},Bn=n.forwardRef(({label:t,helperText:i,error:o,required:a,disabled:l,readOnly:u,size:_="md",name:g,id:A,className:E,style:Y,accessMode:F,value:$={},onChange:T,fields:G=uo,placeholders:ie={},countries:V,layout:ee="vertical",countryFirst:M=!1,validatePostalCode:f},O)=>{const y=v.Dc(F,A),I=y==="hidden";y==="disabled"&&(l=!0),y==="readOnly"&&(u=!0);const{t:B}=v.Gt(),r=v.bc(A),b=n.useCallback((j,c)=>{T?.({...$,[j]:c})},[$,T]),S=n.useMemo(()=>{if(f&&$.postalCode)return f($.postalCode,$.country)},[f,$.postalCode,$.country]),U=n.useMemo(()=>M&&G.includes("country")?["country",...G.filter(j=>j!=="country")]:G,[G,M]),k=`nice-address nice-address--${ee} nice-size-${_}`;return I?null:e.jsxs("div",{ref:O,id:r,className:`${k}${E?` ${E}`:""}${o?" nice-error":""}${l?" nice-disabled":""}`,style:Y,role:"group","aria-label":t??B("address","Address"),children:[t&&e.jsxs("label",{className:"nice-address__label",children:[t,a&&e.jsx("span",{className:"nice-required",children:"*"})]}),e.jsx("div",{className:"nice-address__fields",children:U.map(j=>j==="country"&&V?e.jsxs("div",{className:`nice-address__field nice-address__field--${j}`,children:[e.jsx("label",{className:"nice-address__field-label",children:B(j,ft[j])}),e.jsxs("select",{className:"nice-input nice-select",value:$.country??"",onChange:c=>b("country",c.target.value),disabled:l,"aria-label":B(j,ft[j]),children:[e.jsx("option",{value:"",children:ie.country??B("selectCountry","— Select country —")}),V.map(c=>e.jsx("option",{value:c.code,children:c.name},c.code))]})]},j):e.jsxs("div",{className:`nice-address__field nice-address__field--${j}`,children:[e.jsx("label",{className:"nice-address__field-label",children:B(j,ft[j])}),e.jsx("input",{className:`nice-input${j==="postalCode"&&S?" nice-input--error":""}`,type:"text",name:g?`${g}.${j}`:j,value:$[j]??"",onChange:c=>b(j,c.target.value),placeholder:ie[j]??"",disabled:l,readOnly:u,"aria-label":B(j,ft[j])}),j==="postalCode"&&S&&e.jsx("span",{className:"nice-error-text",children:S})]},j))}),i&&e.jsx("span",{className:"nice-helper-text",children:i}),o&&typeof o=="string"&&e.jsx("span",{className:"nice-error-text",children:o})]})});Bn.displayName="NiceAddressInput";const po=[{target:".nice-invoice-lines",titleKey:"tutorial.invoiceLineEditor.intro.title",title:"Invoice lines",contentKey:"tutorial.invoiceLineEditor.intro.content",content:"Add line items with quantity, unit price, VAT and discount — net, gross and the VAT breakdown are calculated automatically.",placement:"auto"}];let ho=1;function go(t){return{id:`new-${ho++}`,description:"",quantity:1,unitPrice:0,vatRate:t,discount:0,unit:"szt."}}function Fn(t){const o=t.quantity*t.unitPrice*(1-(t.discount??0)/100),a=Math.round(o*100)/100,l=Math.round(a*(t.vatRate??0)/100*100)/100;return{...t,netAmount:a,grossAmount:a+l}}function fo(t){const i=t.map(Fn),o=i.reduce((g,A)=>g+(A.netAmount??0),0),a=i.reduce((g,A)=>g+(A.grossAmount??0),0),l=a-o,u=new Map;for(const g of i){const A=g.vatRate??0,E=u.get(A)??{base:0,amount:0};E.base+=g.netAmount??0,E.amount+=(g.grossAmount??0)-(g.netAmount??0),u.set(A,E)}const _=Array.from(u.entries()).map(([g,A])=>({rate:g,base:Math.round(A.base*100)/100,amount:Math.round(A.amount*100)/100}));return{totalNet:Math.round(o*100)/100,totalVat:Math.round(l*100)/100,totalGross:Math.round(a*100)/100,vatBreakdown:_}}const Kn=n.forwardRef(({label:t,helperText:i,error:o,required:a,disabled:l,readOnly:u,size:_="md",name:g,id:A,className:E,style:Y,accessMode:F,value:$=[],onChange:T,onTotalsChange:G,currencySymbol:ie="zł",defaultVatRate:V=23,vatRates:ee=[0,5,8,23],units:M=["szt.","h","kg","m","usł."],showDiscount:f=!0,showUnit:O=!0,showTotals:y=!0,editable:I=!0,maxLines:B,tutorial:r},b)=>{const S=v.Dc(F,A),U=S==="hidden";S==="disabled"&&(l=!0),S==="readOnly"&&(u=!0);const{t:k}=v.Gt(),j=v.bc(A),c=n.useMemo(()=>$.map(Fn),[$]),z=n.useMemo(()=>fo($),[$]);n.useEffect(()=>{G?.(z)},[z,G]);const R=n.useCallback((x,D,N)=>{const H=[...$];H[x]={...H[x],[D]:N},T?.(H)},[$,T]),p=n.useCallback(()=>{B&&$.length>=B||T?.([...$,go(V)])},[$,T,V,B]),d=n.useCallback(x=>{T?.($.filter((D,N)=>N!==x))},[$,T]),m=x=>`${x.toFixed(2)} ${ie}`;return U?null:e.jsxs("div",{ref:b,id:j,className:`nice-invoice-lines nice-size-${_}${E?` ${E}`:""}${o?" nice-error":""}${l?" nice-disabled":""}`,style:{position:"relative",...Y},children:[e.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:20},children:e.jsx(v.Ql,{steps:v.Yl(r,po)})}),t&&e.jsxs("label",{className:"nice-invoice-lines__label",children:[t,a&&e.jsx("span",{className:"nice-required",children:"*"})]}),e.jsxs("table",{className:"nice-invoice-lines__table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{className:"nice-il__th-num",children:"#"}),e.jsx("th",{className:"nice-il__th-desc",children:k("description","Description")}),e.jsx("th",{className:"nice-il__th-qty",children:k("qty","Qty")}),O&&e.jsx("th",{className:"nice-il__th-unit",children:k("unit","Unit")}),e.jsx("th",{className:"nice-il__th-price",children:k("unitPrice","Unit Price")}),f&&e.jsx("th",{className:"nice-il__th-disc",children:k("discount","Disc %")}),e.jsx("th",{className:"nice-il__th-vat",children:k("vat","VAT %")}),e.jsx("th",{className:"nice-il__th-net",children:k("net","Net")}),e.jsx("th",{className:"nice-il__th-gross",children:k("gross","Gross")}),I&&!u&&e.jsx("th",{className:"nice-il__th-actions"})]})}),e.jsx("tbody",{children:c.map((x,D)=>e.jsxs("tr",{children:[e.jsx("td",{className:"nice-il__cell-num",children:D+1}),e.jsx("td",{className:"nice-il__cell-desc",children:e.jsx("input",{className:"nice-input",type:"text",value:x.description,onChange:N=>R(D,"description",N.target.value),disabled:l,readOnly:u,placeholder:k("itemDescription","Item description")})}),e.jsx("td",{className:"nice-il__cell-qty",children:e.jsx("input",{className:"nice-input",type:"number",value:x.quantity,onChange:N=>R(D,"quantity",parseFloat(N.target.value)||0),disabled:l,readOnly:u,min:0,step:"any"})}),O&&e.jsx("td",{className:"nice-il__cell-unit",children:e.jsx("select",{className:"nice-select",value:x.unit??"",onChange:N=>R(D,"unit",N.target.value),disabled:l,children:M.map(N=>e.jsx("option",{value:N,children:N},N))})}),e.jsx("td",{className:"nice-il__cell-price",children:e.jsx("input",{className:"nice-input",type:"number",value:x.unitPrice,onChange:N=>R(D,"unitPrice",parseFloat(N.target.value)||0),disabled:l,readOnly:u,min:0,step:"0.01"})}),f&&e.jsx("td",{className:"nice-il__cell-disc",children:e.jsx("input",{className:"nice-input",type:"number",value:x.discount??0,onChange:N=>R(D,"discount",parseFloat(N.target.value)||0),disabled:l,readOnly:u,min:0,max:100})}),e.jsx("td",{className:"nice-il__cell-vat",children:e.jsx("select",{className:"nice-select",value:x.vatRate??0,onChange:N=>R(D,"vatRate",parseInt(N.target.value,10)),disabled:l,children:ee.map(N=>e.jsxs("option",{value:N,children:[N,"%"]},N))})}),e.jsx("td",{className:"nice-il__cell-net",children:m(x.netAmount??0)}),e.jsx("td",{className:"nice-il__cell-gross",children:m(x.grossAmount??0)}),I&&!u&&e.jsx("td",{className:"nice-il__cell-actions",children:e.jsx("button",{type:"button",className:"nice-btn nice-btn--icon nice-btn--sm",onClick:()=>d(D),disabled:l,title:k("remove","Remove"),"aria-label":k("remove","Remove"),children:e.jsx(v.oa,{name:"close",size:14})})})]},x.id))})]}),I&&!u&&e.jsxs("button",{type:"button",className:"nice-btn nice-btn--outlined nice-btn--sm nice-invoice-lines__add",onClick:p,disabled:l||B!=null&&$.length>=B,children:["+ ",k("addLine","Add line")]}),y&&e.jsxs("div",{className:"nice-invoice-lines__totals",children:[e.jsxs("div",{className:"nice-il__total-row",children:[e.jsxs("span",{children:[k("totalNet","Net total"),":"]}),e.jsx("span",{className:"nice-il__total-value",children:m(z.totalNet)})]}),z.vatBreakdown.map(x=>e.jsxs("div",{className:"nice-il__total-row nice-il__total-row--vat",children:[e.jsxs("span",{children:["VAT ",x.rate,"%:"]}),e.jsx("span",{className:"nice-il__total-value",children:m(x.amount)})]},x.rate)),e.jsxs("div",{className:"nice-il__total-row nice-il__total-row--gross",children:[e.jsxs("span",{children:[k("totalGross","Gross total"),":"]}),e.jsx("span",{className:"nice-il__total-value nice-il__total-value--gross",children:m(z.totalGross)})]})]}),i&&e.jsx("span",{className:"nice-helper-text",children:i}),o&&typeof o=="string"&&e.jsx("span",{className:"nice-error-text",children:o})]})});Kn.displayName="NiceInvoiceLineEditor";const Yn=n.forwardRef(({label:t,helperText:i,error:o,required:a,disabled:l,readOnly:u,size:_="md",name:g,id:A,className:E,style:Y,accessMode:F,value:$=[],onChange:T,contacts:G=[],onSearch:ie,searchDelay:V=300,multiple:ee=!1,placeholder:M,onContactClick:f,maxSelections:O},y)=>{const I=v.Dc(F,A),B=I==="hidden";I==="disabled"&&(l=!0),I==="readOnly"&&(u=!0);const{t:r}=v.Gt(),b=v.bc(A),[S,U]=n.useState(""),[k,j]=n.useState([]),[c,z]=n.useState(!1),[R,p]=n.useState(!1),d=n.useMemo(()=>{const N=[...G,...k],H=new Map(N.map(L=>[L.id,L]));return $.map(L=>H.get(L)).filter(Boolean)},[$,G,k]),m=n.useCallback(N=>{if(U(N),N.length<1){j([]),z(!1);return}if(ie){p(!0);const Q=setTimeout(async()=>{const w=await ie(N);j(w),z(!0),p(!1)},V);return()=>clearTimeout(Q)}const H=N.toLowerCase(),L=G.filter(Q=>Q.name.toLowerCase().includes(H)||Q.email?.toLowerCase().includes(H)||Q.phone?.includes(N));j(L),z(!0)},[ie,G,V]),x=n.useCallback(N=>{if(ee)if($.includes(N.id))T?.($.filter(H=>H!==N.id));else{if(O&&$.length>=O)return;T?.([...$,N.id])}else T?.([N.id]),z(!1),U("")},[$,T,ee,O]),D=n.useCallback(N=>{T?.($.filter(H=>H!==N))},[$,T]);return B?null:e.jsxs("div",{ref:y,id:b,className:`nice-contact-picker nice-size-${_}${E?` ${E}`:""}${o?" nice-error":""}${l?" nice-disabled":""}`,style:Y,children:[t&&e.jsxs("label",{className:"nice-contact-picker__label",children:[t,a&&e.jsx("span",{className:"nice-required",children:"*"})]}),d.length>0&&e.jsx("div",{className:"nice-contact-picker__chips",children:d.map(N=>e.jsxs("span",{className:"nice-contact-picker__chip",onClick:()=>f?.(N),children:[N.avatarUrl&&e.jsx("img",{src:N.avatarUrl,alt:"",className:"nice-contact-picker__chip-avatar"}),e.jsx("span",{children:N.name}),!u&&e.jsx("button",{type:"button",className:"nice-contact-picker__chip-remove",onClick:H=>{H.stopPropagation(),D(N.id)},disabled:l,"aria-label":r("controls.remove","Remove"),children:e.jsx(v.oa,{name:"close",size:14})})]},N.id))}),!u&&e.jsxs("div",{className:"nice-contact-picker__search",children:[e.jsx("input",{className:"nice-input",type:"text",value:S,onChange:N=>m(N.target.value),onFocus:()=>S.length>0&&z(!0),onBlur:()=>setTimeout(()=>z(!1),200),placeholder:M??r("searchContacts","Search contacts…"),disabled:l,"aria-label":r("searchContacts","Search contacts")}),R&&e.jsx("span",{className:"nice-contact-picker__spinner",children:e.jsx(v.oa,{name:"refresh",size:16})})]}),c&&k.length>0&&e.jsx("div",{className:"nice-contact-picker__dropdown",role:"listbox",children:k.map(N=>e.jsxs("div",{className:`nice-contact-picker__option${$.includes(N.id)?" nice-contact-picker__option--selected":""}`,role:"option","aria-selected":$.includes(N.id),onClick:()=>x(N),children:[N.avatarUrl&&e.jsx("img",{src:N.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:N.name}),N.subtitle&&e.jsx("span",{className:"nice-contact-picker__option-subtitle",children:N.subtitle}),N.email&&e.jsx("span",{className:"nice-contact-picker__option-email",children:N.email})]}),N.type&&e.jsx("span",{className:"nice-contact-picker__option-type",children:e.jsx(v.oa,{name:N.type==="person"?"user":"building",size:16})})]},N.id))}),i&&e.jsx("span",{className:"nice-helper-text",children:i}),o&&typeof o=="string"&&e.jsx("span",{className:"nice-error-text",children:o})]})});Yn.displayName="NiceContactPicker";const yo=[{target:".nice-pdf-annotation",titleKey:"tutorial.pdfAnnotationEditor.intro.title",title:"PDF annotations",contentKey:"tutorial.pdfAnnotationEditor.intro.content",content:"Pick a tool from the toolbar (highlight, underline, freehand, text…), mark up the page, navigate pages and zoom as needed.",placement:"auto"}],xo=["highlight","underline","strikethrough","freehand","text","rect","arrow"],bo={highlight:"edit",underline:"type",strikethrough:"type",freehand:"edit",text:"type",rect:"box",arrow:"arrow-right",stamp:"tag"},Un=n.forwardRef(({label:t,helperText:i,error:o,required:a,disabled:l,readOnly:u,size:_="md",id:g,className:A,style:E,accessMode:Y,src:F,annotations:$=[],onAnnotationsChange:T,activeTool:G,onToolChange:ie,currentPage:V=1,onPageChange:ee,totalPages:M=1,defaultColor:f="var(--nice-warning, #ffff00)",tools:O=xo,author:y,zoom:I=1,onZoomChange:B,onAnnotationClick:r,onAnnotationDelete:b,tutorial:S},U)=>{const k=v.Dc(Y,g),j=k==="hidden";k==="disabled"&&(l=!0),k==="readOnly"&&(u=!0);const{t:c}=v.Gt(),z=v.bc(g),R=$.filter(L=>L.page===V),p=n.useCallback(L=>{ie?.(G===L?null:L)},[G,ie]),d=n.useCallback(L=>{if(u||!G||G==="freehand")return;const Q=L.currentTarget.getBoundingClientRect(),w=(L.clientX-Q.left)/Q.width,K=(L.clientY-Q.top)/Q.height,Z={id:`ann-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,tool:G,page:V,x:w,y:K,color:f,author:y,createdAt:new Date().toISOString(),text:G==="text"?"":void 0};T?.([...$,Z])},[u,G,V,f,y,$,T]);if(j)return null;const m=t?e.jsxs("div",{className:"nice-pdf-annotation__label",children:[t,a&&e.jsx("span",{className:"nice-required",children:"*"})]}):void 0,x=u?void 0:e.jsxs("div",{className:"nice-pdf-annotation__toolbar",children:[O.map(L=>e.jsx("button",{type:"button",className:`nice-pdf-annotation__tool-btn${G===L?" nice-pdf-annotation__tool-btn--active":""}`,onClick:()=>p(L),disabled:l,title:c(`pdfTool_${L}`,L),children:e.jsx(v.oa,{name:bo[L],size:16})},L)),e.jsx("span",{className:"nice-pdf-annotation__toolbar-sep"}),e.jsx("button",{type:"button",disabled:l,onClick:()=>B?.(Math.max(.25,I-.25)),title:c("zoomOut","Zoom out"),"aria-label":c("zoomOut","Zoom out"),children:e.jsx(v.oa,{name:"minus",size:16})}),e.jsxs("span",{className:"nice-pdf-annotation__zoom",children:[Math.round(I*100),"%"]}),e.jsx("button",{type:"button",disabled:l,onClick:()=>B?.(Math.min(4,I+.25)),title:c("zoomIn","Zoom in"),"aria-label":c("zoomIn","Zoom in"),children:e.jsx(v.oa,{name:"plus",size:16})})]}),D=e.jsxs("div",{className:"nice-pdf-annotation__pager",children:[e.jsx("button",{type:"button",disabled:l||V<=1,onClick:()=>ee?.(V-1),"aria-label":c("prevPage","Previous page"),children:e.jsx(v.oa,{name:"chevron-left",size:16})}),e.jsx("span",{children:c("pageOf","{page} / {total}").replace("{page}",String(V)).replace("{total}",String(M))}),e.jsx("button",{type:"button",disabled:l||V>=M,onClick:()=>ee?.(V+1),"aria-label":c("nextPage","Next page"),children:e.jsx(v.oa,{name:"chevron-right",size:16})})]}),H=!!i||!!o&&typeof o=="string"?e.jsxs(e.Fragment,{children:[i&&e.jsx("span",{className:"nice-helper-text",children:i}),o&&typeof o=="string"&&e.jsx("span",{className:"nice-error-text",children:o})]}):void 0;return e.jsx(ln.NiceAppShell,{ref:U,flush:!0,id:z,className:`nice-pdf-annotation nice-size-${_}${A?` ${A}`:""}${o?" nice-error":""}${l?" nice-disabled":""}`,style:E,menubar:m,toolbar:x,bottomPanel:D,statusBar:H,children:e.jsxs("div",{style:{position:"relative",height:"100%",overflow:"auto"},children:[e.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:20},children:e.jsx(v.Ql,{steps:v.Yl(S,yo)})}),e.jsxs("div",{className:"nice-pdf-annotation__viewport",style:{transform:`scale(${I})`,transformOrigin:"top left"},children:[e.jsx("iframe",{src:F,className:"nice-pdf-annotation__frame",title:c("pdfViewer","PDF Viewer")}),e.jsx("div",{className:"nice-pdf-annotation__layer",onClick:d,children:R.map(L=>e.jsxs("div",{className:`nice-pdf-annotation__mark nice-pdf-annotation__mark--${L.tool}`,style:{left:`${L.x*100}%`,top:`${L.y*100}%`,backgroundColor:L.color},onClick:Q=>{Q.stopPropagation(),r?.(L)},title:L.text??L.tool,children:[L.text&&e.jsx("span",{children:L.text}),!u&&e.jsx("button",{type:"button",className:"nice-pdf-annotation__mark-delete",onClick:Q=>{Q.stopPropagation(),b?.(L.id)},"aria-label":c("delete","Delete"),children:e.jsx(v.oa,{name:"close",size:14})})]},L.id))})]})]})})});Un.displayName="NicePDFAnnotationEditor";const Wn=n.forwardRef(({label:t,helperText:i,error:o,disabled:a,readOnly:l,size:u="md",id:_,className:g,style:A,accessMode:E,pages:Y,selectedPageId:F,content:$="",contentFormat:T="html",editing:G=!1,onPageSelect:ie,onContentChange:V,onSave:ee,onCreatePage:M,onDeletePage:f,onEditToggle:O,onVersionHistory:y,sidebarWidth:I=260,sidebarCollapsed:B=!1,onSidebarToggle:r,searchable:b=!0,onSearch:S},U)=>{const k=v.Dc(E,_),j=k==="hidden";k==="disabled"&&(a=!0),k==="readOnly"&&(l=!0);const{t:c}=v.Gt(),z=v.bc(_),[R,p]=n.useState(""),[d,m]=n.useState(""),[x,D]=n.useState(!1),N=n.useMemo(()=>{const w=K=>{for(const Z of K){if(Z.id===F)return Z;if(Z.children){const pe=w(Z.children);if(pe)return pe}}};return w(Y)},[Y,F]),H=n.useCallback(w=>{p(w),S?.(w)},[S]),L=n.useCallback(()=>{d.trim()&&(M?.(F??null,d.trim()),m(""),D(!1))},[d,F,M]),Q=(w,K=0)=>e.jsx("ul",{className:"nice-wiki__tree",style:{paddingLeft:K>0?16:0},children:w.map(Z=>e.jsxs("li",{className:"nice-wiki__tree-item",children:[e.jsxs("div",{className:`nice-wiki__tree-node${Z.id===F?" nice-wiki__tree-node--active":""}${Z.isDraft?" nice-wiki__tree-node--draft":""}`,onClick:()=>ie?.(Z),role:"treeitem","aria-selected":Z.id===F,children:[e.jsx("span",{className:"nice-wiki__tree-icon",children:e.jsx(v.oa,{name:Z.children?.length?"folder":"file",size:14})}),e.jsx("span",{className:"nice-wiki__tree-title",children:Z.title}),Z.isDraft&&e.jsx("span",{className:"nice-wiki__tree-draft",children:c("draft","Draft")})]}),Z.children&&Z.children.length>0&&Q(Z.children,K+1)]},Z.id))});return j?null:e.jsxs("div",{ref:U,id:z,className:`nice-wiki nice-size-${u}${g?` ${g}`:""}${a?" nice-disabled":""}`,style:A,children:[!B&&e.jsxs("aside",{className:"nice-wiki__sidebar",style:{width:I},children:[e.jsxs("div",{className:"nice-wiki__sidebar-header",children:[e.jsx("span",{className:"nice-wiki__sidebar-title",children:t??c("wiki","Wiki")}),r&&e.jsx("button",{type:"button",className:"nice-wiki__sidebar-toggle",onClick:()=>r(!0),"aria-label":c("collapseSidebar","Collapse sidebar"),children:e.jsx(v.oa,{name:"chevron-left",size:16})})]}),b&&e.jsx("input",{type:"text",className:"nice-input nice-wiki__search",value:R,onChange:w=>H(w.target.value),placeholder:c("searchPages","Search pages…"),disabled:a}),e.jsx("div",{className:"nice-wiki__page-tree",role:"tree",children:Q(Y)}),M&&!l&&e.jsx("div",{className:"nice-wiki__sidebar-footer",children:x?e.jsxs("div",{className:"nice-wiki__create-form",children:[e.jsx("input",{type:"text",className:"nice-input",value:d,onChange:w=>m(w.target.value),placeholder:c("pageTitle","Page title"),onKeyDown:w=>w.key==="Enter"&&L(),disabled:a}),e.jsx("button",{type:"button",disabled:a||!d.trim(),onClick:L,"aria-label":c("create","Create"),children:e.jsx(v.oa,{name:"check",size:14})}),e.jsx("button",{type:"button",onClick:()=>D(!1),"aria-label":c("cancel","Cancel"),children:e.jsx(v.oa,{name:"close",size:14})})]}):e.jsxs("button",{type:"button",className:"nice-wiki__add-page",onClick:()=>D(!0),disabled:a,children:[e.jsx(v.oa,{name:"plus",size:14})," ",c("newPage","New page")]})})]}),B&&r&&e.jsx("button",{type:"button",className:"nice-wiki__sidebar-expand",onClick:()=>r(!1),"aria-label":c("expandSidebar","Expand sidebar"),children:e.jsx(v.oa,{name:"chevron-right",size:16})}),e.jsx("main",{className:"nice-wiki__content",children:N?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"nice-wiki__content-header",children:[e.jsx("h1",{className:"nice-wiki__page-title",children:N.title}),e.jsxs("div",{className:"nice-wiki__content-actions",children:[O&&!l&&e.jsx("button",{type:"button",disabled:a,onClick:()=>O(!G),children:G?c("preview","Preview"):c("edit","Edit")}),y&&e.jsx("button",{type:"button",disabled:a,onClick:()=>y(N.id),children:c("history","History")}),f&&!l&&e.jsx("button",{type:"button",className:"nice-btn--danger",disabled:a,onClick:()=>f(N.id),children:c("delete","Delete")})]})]}),N.updatedAt&&e.jsxs("div",{className:"nice-wiki__page-meta",children:[N.updatedBy&&e.jsxs("span",{children:[c("lastEditedBy","Last edited by")," ",N.updatedBy]}),e.jsx("span",{children:new Date(N.updatedAt).toLocaleDateString()})]}),G?e.jsxs("div",{className:"nice-wiki__editor",children:[e.jsx("textarea",{className:"nice-wiki__editor-textarea",value:$,onChange:w=>V?.(w.target.value),disabled:a}),ee&&e.jsx("button",{type:"button",className:"nice-btn nice-btn--primary",disabled:a,onClick:()=>ee(N.id,$),children:c("save","Save")})]}):e.jsx("div",{className:"nice-wiki__viewer",children:T==="html"?e.jsx("div",{className:"nice-wiki__html",dangerouslySetInnerHTML:{__html:v.lc($)}}):e.jsx("pre",{className:"nice-wiki__markdown",children:$})})]}):e.jsx("div",{className:"nice-wiki__empty",children:e.jsx("p",{children:c("selectPage","Select a page from the sidebar or create a new one.")})})}),i&&e.jsx("span",{className:"nice-helper-text",children:i}),o&&typeof o=="string"&&e.jsx("span",{className:"nice-error-text",children:o})]})});Wn.displayName="NiceWiki";const jo={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)"},Gn=n.forwardRef(({label:t,helperText:i,error:o,required:a,disabled:l,readOnly:u,size:_="md",name:g,id:A,className:E,style:Y,accessMode:F,value:$,onChange:T,accounts:G,treeView:ie=!1,placeholder:V,searchable:ee=!0,showType:M=!0,onSearch:f},O)=>{const y=v.Dc(F,A),I=y==="hidden";y==="disabled"&&(l=!0),y==="readOnly"&&(u=!0);const{t:B}=v.Gt(),r=v.bc(A),[b,S]=n.useState(""),[U,k]=n.useState(!1),j=n.useMemo(()=>{const d=m=>{for(const x of m){if(x.code===$)return x;if(x.children){const D=d(x.children);if(D)return D}}};return d(G)},[G,$]),c=n.useMemo(()=>{const d=[],m=x=>{for(const D of x)d.push(D),D.children&&m(D.children)};return m(G),d},[G]),z=n.useMemo(()=>{if(!b)return c;const d=b.toLowerCase();return c.filter(m=>m.code.toLowerCase().includes(d)||m.name.toLowerCase().includes(d))},[c,b]),R=n.useCallback(d=>{S(d),f?.(d),k(!0)},[f]),p=n.useCallback(d=>{T?.(d.code,d),k(!1),S("")},[T]);return I?null:e.jsxs("div",{ref:O,id:r,className:`nice-account-picker nice-size-${_}${E?` ${E}`:""}${o?" nice-error":""}${l?" nice-disabled":""}`,style:Y,children:[t&&e.jsxs("label",{className:"nice-account-picker__label",htmlFor:`${r}-input`,children:[t,a&&e.jsx("span",{className:"nice-required",children:"*"})]}),e.jsx("div",{className:"nice-account-picker__control",children:ee&&!u?e.jsx("input",{id:`${r}-input`,className:"nice-input",type:"text",value:U?b:j?`${j.code} — ${j.name}`:"",onChange:d=>R(d.target.value),onFocus:()=>{S(""),k(!0)},onBlur:()=>setTimeout(()=>k(!1),200),placeholder:V??B("searchAccount","Search account…"),disabled:l,required:a}):e.jsx("div",{className:"nice-account-picker__display",children:j?`${j.code} — ${j.name}`:V??B("selectAccount","Select account…")})}),U&&z.length>0&&e.jsx("div",{className:"nice-account-picker__dropdown",role:"listbox",children:z.map(d=>e.jsxs("div",{className:`nice-account-picker__option${d.code===$?" nice-account-picker__option--selected":""}${d.isActive===!1?" nice-account-picker__option--inactive":""}`,role:"option","aria-selected":d.code===$,onClick:()=>p(d),children:[M&&d.type&&e.jsx("span",{className:"nice-account-picker__type",style:{color:jo[d.type]},title:d.type,children:e.jsx(v.oa,{name:"circle",size:10})}),e.jsx("span",{className:"nice-account-picker__code",children:d.code}),e.jsx("span",{className:"nice-account-picker__name",children:d.name})]},d.code))}),i&&e.jsx("span",{className:"nice-helper-text",children:i}),o&&typeof o=="string"&&e.jsx("span",{className:"nice-error-text",children:o})]})});Gn.displayName="NiceAccountPicker";const qn=n.forwardRef(({label:t,helperText:i,error:o,required:a,disabled:l,readOnly:u,size:_="md",id:g,className:A,style:E,accessMode:Y,mode:F="manual",onScan:$,onModeChange:T,beepOnScan:G=!0,beepFrequency:ie=1800,beepDuration:V=150,placeholder:ee,scanHistory:M=[],showHistory:f=!0,maxHistory:O=10,autoFocus:y=!0,onCameraFrame:I},B)=>{const r=v.Dc(Y,g),b=r==="hidden";r==="disabled"&&(l=!0),r==="readOnly"&&(u=!0);const{t:S}=v.Gt(),U=v.bc(g),[k,j]=n.useState(""),c=n.useRef(null),z=n.useRef(null),R=n.useCallback(()=>{if(G)try{z.current||(z.current=new AudioContext);const m=z.current,x=m.createOscillator(),D=m.createGain();x.connect(D),D.connect(m.destination),x.frequency.value=ie,x.type="square",D.gain.value=.3,x.start(),x.stop(m.currentTime+V/1e3)}catch{}},[G,ie,V]),p=n.useCallback(()=>{k.trim()&&(R(),$?.({value:k.trim(),format:"manual",scannedAt:new Date}),j(""),c.current?.focus())},[k,$,R]),d=M.slice(0,O);return b?null:e.jsxs("div",{ref:B,id:U,className:`nice-scanner nice-size-${_}${A?` ${A}`:""}${o?" nice-error":""}${l?" nice-disabled":""}`,style:E,children:[t&&e.jsxs("div",{className:"nice-scanner__label",children:[t,a&&e.jsx("span",{className:"nice-required",children:"*"})]}),e.jsxs("div",{className:"nice-scanner__modes",children:[e.jsxs("button",{type:"button",className:`nice-scanner__mode-btn${F==="camera"?" nice-scanner__mode-btn--active":""}`,onClick:()=>T?.("camera"),disabled:l,children:[e.jsx(v.oa,{name:"camera",size:16})," ",S("camera","Camera")]}),e.jsxs("button",{type:"button",className:`nice-scanner__mode-btn${F==="manual"?" nice-scanner__mode-btn--active":""}`,onClick:()=>T?.("manual"),disabled:l,children:[e.jsx(v.oa,{name:"edit",size:16})," ",S("manual","Manual")]})]}),F==="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(v.oa,{name:"camera",size:32})}),e.jsx("p",{children:S("cameraPlaceholder","Camera preview — connect scanner adapter")})]})})}),F==="manual"&&!u&&e.jsxs("div",{className:"nice-scanner__manual",children:[e.jsx("input",{ref:c,className:"nice-input nice-scanner__input",type:"text",value:k,onChange:m=>j(m.target.value),onKeyDown:m=>m.key==="Enter"&&p(),placeholder:ee??S("enterCode","Enter or scan code…"),disabled:l,autoFocus:y}),e.jsx("button",{type:"button",className:"nice-scanner__submit",onClick:p,disabled:l||!k.trim(),"aria-label":S("submit","Submit"),children:e.jsx(v.oa,{name:"check",size:16})})]}),f&&d.length>0&&e.jsxs("div",{className:"nice-scanner__history",children:[e.jsx("div",{className:"nice-scanner__history-label",children:S("recentScans","Recent scans")}),d.map((m,x)=>e.jsxs("div",{className:"nice-scanner__history-item",children:[e.jsx("span",{className:"nice-scanner__history-value",children:m.value}),m.format&&e.jsx("span",{className:"nice-scanner__history-format",children:m.format}),e.jsx("span",{className:"nice-scanner__history-time",children:m.scannedAt.toLocaleTimeString()})]},x))]}),i&&e.jsx("span",{className:"nice-helper-text",children:i}),o&&typeof o=="string"&&e.jsx("span",{className:"nice-error-text",children:o})]})});qn.displayName="NiceScannerControl";exports.DEFAULT_ASPECT_RATIOS=zn;exports.EMOJI_DATA=jt;exports.GRADIENT_PRESETS=jn;exports.NICE_COLOR_PRESET_KEYS=fn;exports.NiceAccountPicker=Gn;exports.NiceAddressInput=Bn;exports.NiceCodeDiffEditor=Rn;exports.NiceCodeEditor=ut;exports.NiceCodeEditor$1=zi;exports.NiceCodeEditorAI=Di;exports.NiceColorPalette=xn;exports.NiceContactPicker=Yn;exports.NiceCropEditor=Dn;exports.NiceDateRangeBox=hi;exports.NiceDocumentEditor=On;exports.NiceDropDownBox=fi;exports.NiceEmojiPicker=An;exports.NiceGradientPicker=vn;exports.NiceHtmlEditor=zt;exports.NiceHtmlEditor$1=wi;exports.NiceHtmlEditorAI=Si;exports.NiceImageAnnotator=Ln;exports.NiceImageEditor=Hn;exports.NiceInputOtp=_n;exports.NiceInvoiceLineEditor=Kn;exports.NiceKeyValueEditor=Ki;exports.NiceKnob=wn;exports.NiceLogConsole=In;exports.NiceLookup=pi;exports.NiceMarkdownEditor=Pn;exports.NiceMention=Nn;exports.NicePDFAnnotationEditor=Un;exports.NicePickList=En;exports.NiceRangeSlider=gi;exports.NiceScannerControl=qn;exports.NiceScriptRunner=Bi;exports.NiceSignature=Yi;exports.NiceSimpleCodeEditor=Tn;exports.NiceTreeSelect=Mn;exports.NiceWiki=Wn;exports.applyPreset=bt;exports.contrastRatio=yt;exports.cssToGradient=bn;exports.generateHarmony=dt;exports.generateVariations=pn;exports.gradientToCss=$t;exports.hexToHsv=Ye;exports.hexToRgb=mt;exports.hsvToHex=ze;exports.hsvToRgb=dn;exports.randomPalette=gn;exports.rgbToHex=un;exports.rgbToHsl=mn;exports.rgbToHsv=It;exports.wcagLevel=xt;
|