@nice2dev/ui 1.1.5 → 1.1.7
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 +102 -0
- package/README.md +50 -29
- package/css/legacy-bg-text-aliases.css +65 -61
- package/dist/NiceCodeEditor-Bc81wiaN.js +1134 -0
- package/dist/NiceCodeEditor-D6f8KdHN.js +1134 -0
- package/dist/NiceCodeEditor-DE3saxyt.cjs +260 -0
- package/dist/NiceCodeEditor-DZM16My5.cjs +260 -0
- package/dist/NiceCodeEditor-HqmcJjmZ.js +1179 -0
- package/dist/NiceColorPicker-6EqXaDj0.cjs +1 -0
- package/dist/NiceColorPicker-BiEWqWnd.js +596 -0
- package/dist/NiceColorPicker-Cuc6YXqz.cjs +1 -0
- package/dist/NiceColorPicker-DMATcNWG.js +596 -0
- package/dist/NiceColorPicker-R3O1nemp.js +596 -0
- package/dist/NiceConfirmDialog-B0e10fRL.cjs +1 -0
- package/dist/NiceConfirmDialog-BBDgEMHv.js +81 -0
- package/dist/NiceConfirmDialog-C7kdr8jJ.js +81 -0
- package/dist/NiceConfirmDialog-DMHqPfFM.js +81 -0
- package/dist/NiceConfirmDialog-ZJpQLQQS.cjs +1 -0
- package/dist/NiceDataGrid-BzUw4dSu.cjs +10 -0
- package/dist/NiceDataGrid-CPKcVOVz.js +1743 -0
- package/dist/NiceDataGrid-DJr33WMy.cjs +10 -0
- package/dist/NiceDataGrid-D_4gZ1Hu.js +1736 -0
- package/dist/NiceDataGrid-DlUAaXhD.js +1736 -0
- package/dist/NiceDocumentViewer-8ghRVtfO.js +672 -0
- package/dist/NiceDocumentViewer-ChWtA_Ry.cjs +180 -0
- package/dist/NiceDocumentViewer-DwLUV7Tc.js +672 -0
- package/dist/NiceDocumentViewer-goMzF1w3.cjs +180 -0
- package/dist/NiceDocumentViewer-gt1mxzP8.js +672 -0
- package/dist/NiceForm-CHEAHxDw.js +4805 -0
- package/dist/NiceForm-CJUp1CL0.cjs +1 -0
- package/dist/NiceForm-Cp_RH3Yj.js +4805 -0
- package/dist/NiceForm-a6tGr6ss.js +4819 -0
- package/dist/NiceForm-jU89oe2S.cjs +1 -0
- package/dist/NiceGantt-BnQwyTfG.cjs +1 -0
- package/dist/NiceGantt-D8coFAvK.js +328 -0
- package/dist/NiceGantt-DOZfT6r5.js +328 -0
- package/dist/NiceGantt-DQzH1V-R.js +328 -0
- package/dist/NiceGantt-jQ8ZpXko.cjs +1 -0
- package/dist/NiceHtmlEditor-B1nlXJNW.cjs +10 -0
- package/dist/NiceHtmlEditor-Bv3VqJPG.js +862 -0
- package/dist/NiceHtmlEditor-CKsGj-Ei.cjs +10 -0
- package/dist/NiceHtmlEditor-CloMgyzg.js +841 -0
- package/dist/NiceHtmlEditor-DUAHmkWI.js +841 -0
- package/dist/NiceLoginForm-Ce_QLnLf.js +736 -0
- package/dist/NiceLoginForm-DLpNTQlR.cjs +1 -0
- package/dist/NiceLoginForm-Dg0286Cc.js +736 -0
- package/dist/NiceLoginForm-X05Vadeg.js +708 -0
- package/dist/NiceLoginForm-f_dBCnUi.cjs +1 -0
- package/dist/NiceMention-BByI4nFG.js +11120 -0
- package/dist/NiceMention-BjeLN4Jx.cjs +430 -0
- package/dist/NiceMention-C2TPiMph.cjs +430 -0
- package/dist/NiceMention-C67vT6m0.js +11145 -0
- package/dist/NiceMention-D1cdy63w.cjs +430 -0
- package/dist/NiceMention-OaCi-GNO.js +11094 -0
- package/dist/NiceMention-QIuggb9Y.js +11122 -0
- package/dist/NiceMention.css +1 -1
- package/dist/NiceModal-CHaan9al.js +95 -0
- package/dist/NiceModal-Czq6OEAT.js +95 -0
- package/dist/NiceModal-D-HFwawr.js +95 -0
- package/dist/NiceModal-DOy2XTzc.cjs +1 -0
- package/dist/NiceModal-DkawKzEE.cjs +1 -0
- package/dist/NiceModuleLifecyclePanel-1CsP8Zst.js +6997 -0
- package/dist/NiceModuleLifecyclePanel-Bkx4Yg-3.cjs +1 -0
- package/dist/NiceModuleLifecyclePanel-C5oYtczk.js +6999 -0
- package/dist/NiceModuleLifecyclePanel-DCcy2yYi.cjs +1 -0
- package/dist/NiceModuleLifecyclePanel-DqdgW-0s.js +7004 -0
- package/dist/NiceModuleLifecyclePanel.css +1 -1
- package/dist/NicePagination-7od5KUa3.cjs +1 -0
- package/dist/NicePagination-DMrkR8hH.cjs +1 -0
- package/dist/NicePagination-DQmZpsSQ.js +179 -0
- package/dist/NicePagination-DipQRjPq.js +172 -0
- package/dist/NicePagination-KhlVXYaT.js +172 -0
- package/dist/NicePivotGrid-B-KthuqL.cjs +152 -0
- package/dist/NicePivotGrid-CLCTHkKO.cjs +152 -0
- package/dist/NicePivotGrid-DV54FCsH.js +1174 -0
- package/dist/NicePivotGrid-DoWLUPUs.js +1167 -0
- package/dist/NicePivotGrid-etwpfccz.js +1167 -0
- package/dist/NiceSavedQueryPanel-BABkTNc5.js +5129 -0
- package/dist/NiceSavedQueryPanel-Cfeig83P.cjs +586 -0
- package/dist/NiceSavedQueryPanel-DTWRLseb.cjs +586 -0
- package/dist/NiceSavedQueryPanel-Dy154sxE.js +5129 -0
- package/dist/NiceSavedQueryPanel-v7AffOOe.js +5129 -0
- package/dist/NiceSavedQueryPanel.css +1 -1
- package/dist/NiceScheduler-BEgB7ZgF.cjs +5 -0
- package/dist/NiceScheduler-C9JprsEI.cjs +5 -0
- package/dist/NiceScheduler-DSP-PPh0.js +1645 -0
- package/dist/NiceScheduler-DuPnaA3t.js +1652 -0
- package/dist/NiceScheduler-Oa89YZx9.js +1645 -0
- package/dist/NiceSelect-A336yeLZ.js +433 -0
- package/dist/NiceSelect-B5hTbqi2.js +433 -0
- package/dist/NiceSelect-BYSgDYzq.cjs +1 -0
- package/dist/NiceSelect-Dudf2T5T.js +433 -0
- package/dist/NiceSelect-DwBAIrX7.cjs +1 -0
- package/dist/NiceWindow-B6zjBTl9.cjs +1 -0
- package/dist/NiceWindow-BKQEx7Vf.js +1623 -0
- package/dist/NiceWindow-BnTH7Gy0.js +1623 -0
- package/dist/NiceWindow-CZN9NVZw.cjs +1 -0
- package/dist/NiceWindow-lxtPR7yZ.js +1623 -0
- package/dist/NiceWindow.css +1 -1
- package/dist/charts-B8_V3_nq.cjs +882 -0
- package/dist/charts-BZgyyybE.js +31933 -0
- package/dist/charts-FuDk5-r6.js +31958 -0
- package/dist/charts-INj3yFo5.js +31946 -0
- package/dist/charts-NolNXKUL.cjs +882 -0
- package/dist/charts.cjs +1 -1
- package/dist/charts.css +1 -1
- package/dist/charts.mjs +1 -1
- package/dist/core-A_A6c7an.js +795 -0
- package/dist/core-B2iH2J_X.js +795 -0
- package/dist/core-BmspZEfD.js +795 -0
- package/dist/core-DAfLOet6.cjs +1 -0
- package/dist/core-ZG3bgnBR.cjs +1 -0
- package/dist/data-branching-B3TOqXAO.cjs +1 -0
- package/dist/data-branching-BUGiICDZ.js +6275 -0
- package/dist/data-branching-DMXmcocj.js +6275 -0
- package/dist/data-branching-YE8P9M5P.js +6275 -0
- package/dist/data-branching-t6uhAwIm.cjs +1 -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 +7 -2
- package/dist/data.mjs +3 -3
- package/dist/devops-BhV3OmF7.js +8285 -0
- package/dist/devops-BqUxnbRi.cjs +17 -0
- package/dist/devops-Bx-Qwj9w.cjs +17 -0
- package/dist/devops-DYZatW45.js +8251 -0
- package/dist/devops-R98k2zpd.js +8251 -0
- package/dist/devops.cjs +1 -1
- package/dist/devops.d.ts +29 -16
- package/dist/devops.mjs +1 -1
- package/dist/editors.cjs +1 -1
- package/dist/editors.d.ts +59 -28
- package/dist/editors.mjs +7 -7
- package/dist/feedback.cjs +1 -1
- package/dist/feedback.mjs +3 -3
- package/dist/index.cjs +445 -445
- package/dist/index.css +1 -1
- package/dist/index.d.ts +214 -119
- package/dist/index.mjs +16635 -16351
- package/dist/lazy.cjs +1 -1
- package/dist/lazy.d.ts +31 -18
- package/dist/lazy.mjs +24 -24
- package/dist/navigation.cjs +1 -1
- package/dist/navigation.d.ts +17 -14
- package/dist/navigation.mjs +130 -130
- package/dist/no-code-BPaAS4wW.cjs +332 -0
- package/dist/no-code-CBwUVL1i.js +7447 -0
- package/dist/no-code-CjktkQ50.js +7447 -0
- package/dist/no-code-DW2NrRba.js +7447 -0
- package/dist/no-code-DmFxrZ5T.cjs +332 -0
- package/dist/no-code.cjs +1 -1
- package/dist/no-code.d.ts +2 -2
- package/dist/no-code.mjs +1 -1
- package/dist/overlays.cjs +1 -1
- package/dist/overlays.d.ts +4 -4
- package/dist/overlays.mjs +2 -2
- package/dist/pickerCommons-C4XWRUvH.cjs +1 -0
- package/dist/pickerCommons-C_BpYs_m.cjs +1 -0
- package/dist/pickerCommons-DAOXH_u5.js +1122 -0
- package/dist/pickerCommons-Dn4wnDco.js +1122 -0
- package/dist/pickerCommons-DskswPS5.js +1122 -0
- package/dist/pickerCommons.css +1 -1
- package/dist/style.css +7 -7
- package/package.json +3 -3
|
@@ -0,0 +1,430 @@
|
|
|
1
|
+
"use strict";const e=require("react/jsx-runtime"),x=require("./charts-B8_V3_nq.cjs"),n=require("react"),Ze=require("react-dom"),Be=require("./NiceSelect-DwBAIrX7.cjs"),rt=require("./NiceForm-CJUp1CL0.cjs"),Fe=require("./pickerCommons-C4XWRUvH.cjs"),Kn=require("./NiceHtmlEditor-CKsGj-Ei.cjs"),Se=require("./NiceColorPicker-6EqXaDj0.cjs"),_t=require("./NiceCodeEditor-DE3saxyt.cjs"),Qt=require("./devops-Bx-Qwj9w.cjs"),Un=({min:t=0,max:i=100,step:a=1,startValue:o=t,endValue:r=i,onChange:h,showLabels:y=!0,formatLabel:_,valuePlacement:E="none",label:C,error:Z,helperText:K,required:R,disabled:w,readOnly:Q,loading:ne,size:ee="md",id:te,className:A,style:j,accessMode:L,showKeyboardHints:f,labelPlacement:k,errorPlacement:q,labelWidth:p,controlWidth:d})=>{const S=x.Dc(L,te),V=S==="hidden";(S==="disabled"||S==="readOnly")&&(w=!0);const{t:B}=x.Gt(),b=x.bc(te),s=n.useRef(null),D=n.useMemo(()=>[x.Yc.increment,x.Yc.decrement,x.Yc.first,x.Yc.last,{key:"Tab",description:B("shortcuts.switchThumb","Switch thumb")}],[B]),M=g=>(g-t)/(i-t)*100,u=g=>_?_(g):String(g),c=g=>{const $=Math.round(g/a)*a;return Math.max(t,Math.min(i,$))},l=n.useCallback((g,$)=>{g.preventDefault();const v=s.current;if(!v||w)return;const T=H=>{const N=v.getBoundingClientRect(),P=Math.max(0,Math.min(1,(H.clientX-N.left)/N.width)),z=c(t+P*(i-t));$==="start"?h?.(Math.min(z,r),r):h?.(o,Math.max(z,o))},I=()=>{document.removeEventListener("pointermove",T),document.removeEventListener("pointerup",I)};document.addEventListener("pointermove",T),document.addEventListener("pointerup",I)},[t,i,a,o,r,h,w]);return V?null:e.jsxs("div",{className:`nice-field nice-field--${ee} nice-field--rangeslider ${k==="left"?"nice-field--label-left":""} ${q==="right"?"nice-field--error-right":""} ${Z?"nice-field--error":""} ${ne?"nice-field--loading":""} ${A||""}`,style:{...j,...p!=null&&{"--nice-field-label-width":typeof p=="number"?`${p}px`:p},...d!=null&&{"--nice-field-control-width":typeof d=="number"?`${d}px`:d}},"aria-busy":ne||void 0,children:[(C||E==="right"&&k!=="left")&&(k!=="left"?e.jsxs("div",{className:"nice-range-slider__header",children:[C?e.jsx("label",{className:"nice-field__label",htmlFor:b,children:e.jsxs("span",{className:"nice-field__label-text",children:[C,R&&e.jsx("span",{className:"nice-field__required",children:"*"}),f&&e.jsx(x.ha,{shortcuts:D,size:"sm"})]})}):e.jsx("span",{}),E==="right"&&e.jsxs("span",{className:"nice-range-slider__value nice-range-slider__value--header",children:[u(o)," – ",u(r)]})]}):C&&e.jsx("label",{className:"nice-field__label",htmlFor:b,children:e.jsxs("span",{className:"nice-field__label-text",children:[C,R&&e.jsx("span",{className:"nice-field__required",children:"*"}),f&&e.jsx(x.ha,{shortcuts:D,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 ${y?"nice-range-slider--with-labels":""} ${C?"nice-range-slider--has-field-label":""}`,ref:s,children:[e.jsx("div",{className:"nice-range-slider__track",children:e.jsx("div",{className:"nice-range-slider__fill",style:{left:`${M(o)}%`,width:`${M(r)-M(o)}%`}})}),e.jsx("div",{className:"nice-range-slider__thumb",style:{left:`${M(o)}%`},onPointerDown:g=>Q?void 0:l(g,"start"),role:"slider","aria-valuemin":t,"aria-valuemax":r,"aria-valuenow":o,tabIndex:w?-1:0,id:b}),e.jsx("div",{className:"nice-range-slider__thumb",style:{left:`${M(r)}%`},onPointerDown:g=>Q?void 0:l(g,"end"),role:"slider","aria-valuemin":o,"aria-valuemax":i,"aria-valuenow":r,tabIndex:w?-1:0})]}),y&&e.jsxs("div",{className:"nice-range-slider__values",children:[e.jsx("span",{className:"nice-range-slider__values-start",style:{left:`${M(o)}%`},children:u(o)}),e.jsx("span",{className:"nice-range-slider__values-end",style:{left:`${M(r)}%`},children:u(r)})]}),E==="bottom"&&e.jsxs("div",{className:"nice-range-slider__value nice-range-slider__value--bottom",children:[u(o)," – ",u(r)]})]}),E==="right"&&k==="left"&&e.jsxs("span",{className:"nice-range-slider__value nice-range-slider__value--inline",children:[u(o)," – ",u(r)]}),ne&&e.jsx("span",{className:"nice-field__spinner",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})}),q==="right"&&Z&&e.jsx("div",{className:"nice-field__error",role:"alert",children:Z}),q==="right"&&!Z&&K&&e.jsx("div",{className:"nice-field__helper",children:K})]}),q!=="right"&&Z&&e.jsx("div",{className:"nice-field__error",role:"alert",children:Z}),q!=="right"&&!Z&&K&&e.jsx("div",{className:"nice-field__helper",children:K})]})},Gn={xxs:36,xs:48,sm:64,md:80,lg:100,xl:128,xxl:160,small:64,medium:80,large:100},ct=6,at=135,Zt=405,it=Zt-at;function kt(t,i,a,o){const r=(o-90)*(Math.PI/180);return{x:t+a*Math.cos(r),y:i+a*Math.sin(r)}}function Tt(t,i,a,o,r){const h=kt(t,i,a,o),y=kt(t,i,a,r),_=r-o>180?1:0;return`M ${h.x} ${h.y} A ${a} ${a} 0 ${_} 1 ${y.x} ${y.y}`}const en=n.forwardRef(({value:t=0,onChange:i,min:a=0,max:o=100,step:r=1,showValue:h=!0,valueTemplate:y="{value}",label:_,helperText:E,error:C,required:Z,disabled:K,readOnly:R,size:w="md",name:Q,id:ne,className:ee,style:te,labelPlacement:A="top",errorPlacement:j,labelWidth:L,controlWidth:f,loading:k,isLabelCentered:q=!0,...p},d)=>{const S=x.bc(ne),V=n.useRef(!1),B=n.useRef(null),b=typeof w=="number"?w:Gn[w],s=b/2,D=b/2,M=(b-ct*2)/2,u=o>a?(t-a)/(o-a):0,c=at+u*it,l=n.useCallback(I=>{let H=I-at;H<0&&(H+=360),H>it&&(H=H-it<360-H?it:0);const N=Math.max(0,Math.min(1,H/it)),P=a+N*(o-a),z=Math.round(P/r)*r;return Math.max(a,Math.min(o,z))},[a,o,r]),g=n.useCallback(I=>{if(K||R)return;const H=B.current;if(!H)return;const N=H.getBoundingClientRect(),P=I.clientX-N.left-N.width/2,z=I.clientY-N.top-N.height/2;let re=Math.atan2(P,-z)*(180/Math.PI);re<0&&(re+=360);const me=l(re);i?.(me)},[l,K,R,i]);n.useEffect(()=>{const I=N=>{V.current&&g(N)},H=()=>{V.current=!1};return window.addEventListener("pointermove",I),window.addEventListener("pointerup",H),()=>{window.removeEventListener("pointermove",I),window.removeEventListener("pointerup",H)}},[g]);const $=n.useCallback(I=>{if(K||R)return;let H=t;I.key==="ArrowUp"||I.key==="ArrowRight"?(I.preventDefault(),H=Math.min(o,t+r)):(I.key==="ArrowDown"||I.key==="ArrowLeft")&&(I.preventDefault(),H=Math.max(a,t-r)),H!==t&&i?.(H)},[t,i,a,o,r,K,R]),v=(y||"{value}").replace("{value}",String(t)),T=kt(s,D,M,c);return e.jsxs("div",{className:`nice-field nice-knob-field nice-knob-field--err-${j||"bottom"} nice-field--${typeof w=="string"?w:"md"} ${k?"nice-field--loading":""} ${ee||""}`,style:{...te,...L!=null&&{"--nice-field-label-width":typeof L=="number"?`${L}px`:L},...f!=null&&{"--nice-field-control-width":typeof f=="number"?`${f}px`:f}},"aria-busy":k||void 0,...p,children:[e.jsxs("div",{className:`nice-knob-field__inner nice-knob-field--${A} ${q?"nice-knob-field--label-centered":""}`,children:[_&&e.jsx("label",{htmlFor:S,className:`nice-field__label ${Z?"nice-field__label--required":""}`,children:_}),e.jsx("div",{className:"nice-field__control",children:e.jsxs("div",{ref:I=>{B.current=I,typeof d=="function"?d(I):d&&(d.current=I)},className:`nice-knob nice-knob--${w} ${K?"nice-knob--disabled":""} ${C?"nice-knob--error":""}`,role:"slider",id:S,tabIndex:K?-1:0,"aria-valuenow":t,"aria-valuemin":a,"aria-valuemax":o,"aria-disabled":K,"aria-invalid":!!C,onPointerDown:I=>{K||R||(V.current=!0,g(I))},onKeyDown:$,children:[e.jsxs("svg",{width:b,height:b,viewBox:`0 0 ${b} ${b}`,children:[e.jsx("path",{d:Tt(s,D,M,at,Zt),fill:"none",stroke:"var(--nice-border-color, #d1d5db)",strokeWidth:ct,strokeLinecap:"round"}),u>0&&e.jsx("path",{d:Tt(s,D,M,at,c),fill:"none",stroke:"var(--nice-primary, #3b82f6)",strokeWidth:ct,strokeLinecap:"round"}),e.jsx("circle",{cx:T.x,cy:T.y,r:ct,fill:"var(--nice-primary, #3b82f6)"})]}),h&&e.jsx("span",{className:"nice-knob__value",children:v}),Q&&e.jsx("input",{type:"hidden",name:Q,value:t}),k&&e.jsx("span",{className:"nice-knob__spinner","aria-hidden":"true",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})})]})})]}),C&&e.jsx("div",{className:"nice-field__error",role:"alert",children:C}),!C&&E&&e.jsx("div",{className:"nice-field__helper",children:E})]})});en.displayName="NiceKnob";function Xn(t,{open:i,onSelect:a,onClose:o,onOpen:r,loop:h=!1}){const[y,_]=n.useState(0);n.useEffect(()=>{_(C=>t.length===0?0:Math.min(Math.max(C,0),t.length-1))},[t.length]);const E=n.useCallback(C=>{if(!i){(C.key==="ArrowDown"||C.key==="ArrowUp")&&(C.preventDefault(),r?.());return}if(C.key==="ArrowDown")C.preventDefault(),_(Z=>t.length===0?0:h?(Z+1)%t.length:Math.min(Z+1,t.length-1));else if(C.key==="ArrowUp")C.preventDefault(),_(Z=>t.length===0?0:h?(Z-1+t.length)%t.length:Math.max(Z-1,0));else if(C.key==="Enter"){const Z=t[y];Z!==void 0&&(C.preventDefault(),a(Z,y))}else C.key==="Escape"&&o?.()},[i,t,y,h,a,o,r]);return{activeIndex:y,setActiveIndex:_,handleKeyDown:E}}const qn=({options:t,value:i,onChange:a,searchable:o=!0,clearable:r,loading:h,placeholder:y,label:_,error:E,helperText:C,required:Z,disabled:K,readOnly:R,size:w="md",id:Q,className:ne,style:ee,data:te,columns:A,valueField:j="id",displayField:L,dropdownWidth:f,menuGap:k,labelPlacement:q,errorPlacement:p,labelWidth:d,controlWidth:S})=>{const V=K||R||h,B=x.bc(Q),{t:b}=x.Gt(),[s,D]=n.useState(!1),[M,u]=n.useState(""),c=n.useRef(null),l=n.useRef(null),{popupRef:g,coords:$,ready:v,themeClass:T,portalTarget:I}=Be.useAnchoredPopup(s,l,()=>D(!1)),H=!!(te&&A&&A.length>0),N=L??(A&&A[0]?.key),P=n.useMemo(()=>!H||!te?[]:te.map(oe=>({value:String(oe[j]??""),label:N?String(oe[N]??""):""})),[H,te,j,N]),z=H?P:t??[],re=z.find(oe=>String(oe.value)===i),me=n.useMemo(()=>{if(!H||!te)return[];if(!M)return te;const oe=M.toLowerCase();return te.filter(he=>A.some(ie=>String(he[ie.key]??"").toLowerCase().includes(oe)))},[H,te,A,M]),de=n.useMemo(()=>{if(H||!M)return z;const oe=M.toLowerCase();return z.filter(he=>he.label.toLowerCase().includes(oe))},[z,M,H]),be=H?me:de,{activeIndex:ve,setActiveIndex:_e,handleKeyDown:fe}=Xn(be,{open:s,onSelect:oe=>{const he=String(H?oe[j]??"":oe.value);a(he),D(!1),u("")},onClose:()=>D(!1)});return e.jsxs("div",{className:`nice-field nice-field--lookup nice-field--${w} ${E?"nice-field--error":""} ${q==="left"?"nice-field--label-left":""} ${p==="right"&&(E||C)?"nice-field--error-right":""} ${h?"nice-field--loading":""} ${K?"nice-field--disabled":""} ${ne||""}`,style:{...S!=null&&{"--nice-field-control-width":typeof S=="number"?`${S}px`:S},...d!=null&&{"--nice-field-label-width":typeof d=="number"?`${d}px`:d},...k!=null&&{"--nice-dropdown-gap":`${k}px`},...ee},"aria-busy":h||void 0,ref:c,children:[_&&e.jsxs("label",{className:"nice-field__label",htmlFor:B,children:[_,Z&&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:l,children:[e.jsxs("button",{type:"button",id:B,className:`nice-select__trigger ${K?"nice-select__trigger--disabled":""}`,onClick:()=>!V&&D(!s),disabled:K,"aria-readonly":R||void 0,"aria-expanded":s,children:[e.jsx("span",{children:re?.label||y||b("controls.select","Select...")}),e.jsxs("span",{style:{display:"flex",alignItems:"center",gap:4},children:[r&&i&&!K&&!R&&e.jsx("span",{className:"nice-input__clear",role:"button",tabIndex:0,"aria-label":b("controls.clear","Clear"),onClick:oe=>{oe.stopPropagation(),a("")},children:e.jsx(x.oa,{name:"close",size:14})}),e.jsx("span",{className:`nice-select__arrow${R?" nice-select__arrow--hidden":""}`,children:e.jsx(x.oa,{name:"chevron-down",size:16})})]})]}),s&&$&&I&&Ze.createPortal(e.jsxs("div",{ref:g,className:`nice-dropdown nice-lookup__dropdown${T?` ${T}`:""}`,"data-theme":T==="nice-dark"?"dark":T==="nice-light"?"light":void 0,style:{position:"fixed",top:$.top,left:$.left,zIndex:1e3,marginTop:"var(--nice-dropdown-gap, 0px)",background:"var(--nice-bg-primary)",border:"1px solid var(--nice-border-color)",borderRadius:"var(--nice-radius-md)",boxShadow:"0 4px 16px var(--nice-overlay-15, rgba(0, 0, 0, 0.15))",minWidth:$.width,width:f!=null?typeof f=="number"?`${f}px`:f:H?"max-content":$.width,opacity:v?1:0,pointerEvents:v?void 0:"none"},children:[o&&e.jsx("div",{className:"nice-dropdown__search",style:{padding:6},children:e.jsx("input",{type:"text",value:M,onChange:oe=>{u(oe.target.value),_e(0)},onKeyDown:fe,placeholder:b("controls.search","Search..."),autoFocus:!0,style:{width:"100%",padding:"4px 8px",border:"1px solid var(--nice-border-color)",borderRadius:4,background:"var(--nice-bg-primary)",color:"var(--nice-text-primary)"}})}),H?e.jsxs("table",{className:"nice-lookup__grid",role:"listbox",style:{width:"100%",borderCollapse:"collapse",color:"var(--nice-text-primary)"},children:[e.jsx("thead",{children:e.jsx("tr",{children:A.map(oe=>e.jsx("th",{style:{padding:"6px 10px",textAlign:"left",fontSize:12,fontWeight:600,color:"var(--nice-text-secondary)",background:"var(--nice-bg-secondary)",borderBottom:"1px solid var(--nice-border-color)",width:oe.width!=null?typeof oe.width=="number"?`${oe.width}px`:oe.width:void 0},children:oe.header},oe.key))})}),e.jsx("tbody",{children:me.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:A.length,style:{padding:12,textAlign:"center",color:"var(--nice-text-muted)"},children:b("controls.noResults","No results")})}):me.map((oe,he)=>{const ie=String(oe[j]??""),ce=ie===i,ge=he===ve;return e.jsx("tr",{role:"option","aria-selected":ce,onClick:()=>{a(ie),D(!1),u("")},style:{cursor:"pointer",background:ce||ge?"var(--nice-hover-bg)":"transparent"},onMouseEnter:()=>_e(he),children:A.map(Y=>e.jsx("td",{style:{padding:"6px 10px",fontSize:13,borderBottom:"1px solid var(--nice-border-color)"},children:String(oe[Y.key]??"")},Y.key))},ie)})})]}):e.jsx("ul",{className:"nice-dropdown__list",role:"listbox",style:{listStyle:"none",margin:0,padding:4,maxHeight:240,overflowY:"auto",position:"static",background:"transparent",border:"none",borderRadius:0,boxShadow:"none"},children:de.length===0?e.jsx("li",{className:"nice-dropdown__empty",style:{padding:8,color:"var(--nice-text-muted)"},children:b("controls.noResults","No results")}):de.map((oe,he)=>e.jsx("li",{role:"option",className:`nice-dropdown__option ${String(oe.value)===i?"nice-dropdown__option--selected":""} ${he===ve?"nice-dropdown__option--active":""}`,onClick:()=>{a(String(oe.value)),D(!1),u("")},onMouseEnter:()=>_e(he),"aria-selected":String(oe.value)===i,children:oe.label},String(oe.value)))})]}),I)]}),h&&e.jsx("span",{className:"nice-field__spinner",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})}),p==="right"&&E&&e.jsx("div",{className:"nice-field__error",role:"alert",children:E}),p==="right"&&!E&&C&&e.jsx("div",{className:"nice-field__hint",children:C})]}),p!=="right"&&E&&e.jsx("div",{className:"nice-field__error",children:E}),p!=="right"&&!E&&C&&e.jsx("div",{className:"nice-field__hint",children:C})]})};function Wn(t){const i=[],a=o=>{for(const r of o)i.push(r),r.children&&a(r.children)};return a(t),i}function tn(t,i){const a=i.toLowerCase();return t.reduce((o,r)=>{const h=r.children?tn(r.children,i):[];return(r.label.toLowerCase().includes(a)||h.length>0)&&o.push({...r,children:h.length>0?h:r.children}),o},[])}const nn=({node:t,level:i,selectedKeys:a,expandedKeys:o,onToggleExpand:r,onSelect:h,selectableLeafsOnly:y,maxDepth:_})=>{const E=typeof _=="number"?Math.min(10,Math.max(1,_)):1/0,Z=!(i+1>=E)&&t.children&&t.children.length>0,K=o.has(t.key),R=a.has(t.key),w=!Z,Q=!t.disabled&&(!y||w),ne=Math.min(i+1,10),ee={paddingLeft:i*16+14,"--nice-row-bg":`var(--nice-tree-level-${ne}-bg, transparent)`,"--nice-row-text":`var(--nice-tree-level-${ne}-text, inherit)`,"--nice-row-hover-bg":`var(--nice-tree-level-${ne}-hover-bg, var(--nice-bg-secondary, #f3f4f6))`,"--nice-row-active-bg":`var(--nice-tree-level-${ne}-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 ${R?"nice-tree-select__node--selected":""} ${t.disabled?"nice-tree-select__node--disabled":""}`,style:ee,"data-nice-depth":ne,onClick:()=>{t.disabled||(Z?r(t.key):Q&&h(t.key))},role:"treeitem","aria-selected":R,"aria-expanded":Z?K:void 0,"aria-disabled":t.disabled,children:[Z?e.jsx("button",{type:"button",className:"nice-tree-select__toggle-btn",onClick:te=>{te.stopPropagation(),r(t.key)},"aria-label":"Toggle",children:e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"currentColor",style:{transform:K?"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})]}),Z&&K&&t.children.map(te=>e.jsx(nn,{node:te,level:i+1,selectedKeys:a,expandedKeys:o,onToggleExpand:r,onSelect:h,selectableLeafsOnly:y,maxDepth:_},te.key))]})},an=n.forwardRef(({nodes:t,value:i,onChange:a,multiple:o=!1,searchable:r=!1,placeholder:h,selectableLeafsOnly:y=!1,clearable:_=!1,maxDepth:E,label:C,helperText:Z,error:K,required:R,disabled:w,readOnly:Q,size:ne="md",name:ee,id:te,className:A,style:j,controlWidth:L,menuGap:f,...k},q)=>{const{t:p}=x.Gt(),d=x.bc(te),[S,V]=n.useState(!1),[B,b]=n.useState(""),[s,D]=n.useState(new Set),M=n.useRef(null),{popupRef:u,coords:c,ready:l,themeClass:g,portalTarget:$}=Be.useAnchoredPopup(S,M,()=>V(!1)),v=n.useMemo(()=>i==null?new Set:new Set(Array.isArray(i)?i:[i]),[i]),T=n.useMemo(()=>B?tn(t,B):t,[t,B]),I=n.useMemo(()=>{const z=Wn(t);return Array.from(v).map(re=>z.find(me=>me.key===re)?.label).filter(Boolean)},[v,t]),H=n.useCallback(z=>{D(re=>{const me=new Set(re);return me.has(z)?me.delete(z):me.add(z),me})},[]),N=n.useCallback(z=>{if(o){const re=new Set(v);re.has(z)?re.delete(z):re.add(z),a?.(Array.from(re))}else a?.(z),V(!1)},[o,v,a]),P=n.useCallback(z=>{z.stopPropagation(),a?.(o?[]:"")},[a,o]);return e.jsxs("div",{className:`nice-field nice-field--${ne} ${A||""}`,style:{width:"fit-content",maxWidth:"100%",...f!=null&&{"--nice-dropdown-gap":`${f}px`},...j},...k,children:[C&&e.jsx("label",{htmlFor:d,className:`nice-field__label ${R?"nice-field__label--required":""}`,children:C}),e.jsxs("div",{ref:M,className:"nice-tree-select",style:{position:"relative",width:L!=null&&L!==""?typeof L=="number"?`${L}px`:L:"var(--nice-field-control-width, 220px)"},children:[e.jsxs("div",{ref:q,id:d,className:`nice-input nice-input--${ne} ${K?"nice-input--error":""} ${w?"nice-input--disabled":""} ${Q?"nice-input--readonly":""}`,role:"combobox","aria-expanded":S,"aria-haspopup":"tree","aria-invalid":!!K,tabIndex:w?-1:0,onClick:()=>!w&&!Q&&V(!S),onKeyDown:z=>{(z.key==="Enter"||z.key===" ")&&(z.preventDefault(),!w&&!Q&&V(!S))},children:[e.jsx("span",{className:"nice-tree-select__display",children:I.length>0?I.join(", "):e.jsx("span",{className:"nice-tree-select__placeholder",children:h??p("controls.select","Select...")})}),_&&v.size>0&&e.jsx("button",{type:"button",className:"nice-input__clear",onClick:P,"aria-label":p("controls.clear","Clear"),children:e.jsx(x.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(x.oa,{name:"chevron-down",size:14})})]}),S&&c&&$&&Ze.createPortal(e.jsxs("div",{ref:u,className:`nice-tree-select__dropdown${g?` ${g}`:""}`,"data-theme":g==="nice-dark"?"dark":g==="nice-light"?"light":void 0,role:"tree",style:{position:"fixed",left:c.left,top:c.top,width:c.width,minWidth:c.width,zIndex:1e3,opacity:l?1:0,pointerEvents:l?void 0:"none"},children:[r&&e.jsx("div",{className:"nice-select__search",onClick:z=>z.stopPropagation(),role:"presentation",children:e.jsx("input",{type:"text",placeholder:p("controls.search","Search..."),value:B,onChange:z=>b(z.target.value),autoFocus:!0})}),e.jsx("div",{className:"nice-tree-select__list",children:T.length===0?e.jsx("div",{className:"nice-tree-select__empty",children:p("controls.noResults","No results")}):T.map(z=>e.jsx(nn,{node:z,level:0,selectedKeys:v,expandedKeys:s,onToggleExpand:H,onSelect:N,selectableLeafsOnly:y,maxDepth:E},z.key))})]}),$)]}),ee&&e.jsx("input",{type:"hidden",name:ee,value:Array.isArray(i)?i.join(","):i??""}),K&&e.jsx("div",{id:`${d}-error`,className:"nice-field__error",role:"alert",children:K}),!K&&Z&&e.jsx("div",{id:`${d}-helper`,className:"nice-field__helper",children:Z})]})});an.displayName="NiceTreeSelect";const Vn=({displayValue:t,placeholder:i,clearable:a,children:o,onClear:r,open:h,onOpenChange:y,dropdownWidth:_,searchable:E=!0,onSearch:C,searchPlaceholder:Z,label:K,error:R,helperText:w,required:Q,disabled:ne,size:ee="md",id:te,className:A,style:j,accessMode:L,showKeyboardHints:f,displayStyle:k})=>{x.rc("input",k),x.ac("input",k);const q=x.Dc(L,te),p=q==="hidden";(q==="disabled"||q==="readOnly")&&(ne=!0);const d=x.bc(te),{t:S}=x.Gt(),[V,B]=n.useState(!1),[b,s]=n.useState(""),D=n.useRef(null),M=n.useRef(null),u=h??V,c=n.useMemo(()=>[{key:"Enter",description:S("shortcuts.openDropdown","Open dropdown")},x.Yc.cancel],[S]),l=H=>{y?y(H):B(H)},{popupRef:g,coords:$,ready:v,themeClass:T,portalTarget:I}=Be.useAnchoredPopup(u,M,()=>l(!1));return p?null:e.jsxs("div",{className:`nice-field nice-field--${ee} ${R?"nice-field--error":""} ${A||""}`,style:j,ref:D,children:[K&&e.jsxs("label",{className:"nice-field__label",htmlFor:d,children:[K,Q&&e.jsx("span",{className:"nice-field__required",children:"*"}),f&&e.jsx(x.ha,{shortcuts:c,size:"sm"})]}),e.jsxs("div",{className:"nice-field__input-wrap",ref:M,children:[e.jsxs("button",{type:"button",id:d,className:"nice-select__trigger",onClick:()=>!ne&&l(!u),disabled:ne,children:[e.jsx("span",{children:t||i||S("controls.select","Select...")}),e.jsxs("span",{style:{display:"flex",alignItems:"center",gap:4},children:[a&&t&&!ne&&e.jsx("span",{className:"nice-input__clear",role:"button",tabIndex:0,"aria-label":S("controls.clear","Clear"),onClick:H=>{H.stopPropagation(),r?.()},onKeyDown:H=>{(H.key==="Enter"||H.key===" ")&&(H.preventDefault(),H.stopPropagation(),r?.())},children:e.jsx(x.oa,{name:"close",size:14})}),e.jsx("span",{className:"nice-select__arrow",children:e.jsx(x.oa,{name:"chevron-down",size:16})})]})]}),u&&$&&I&&Ze.createPortal(e.jsxs("div",{ref:g,className:`nice-dropdown${T?` ${T}`:""}`,"data-theme":T==="nice-dark"?"dark":T==="nice-light"?"light":void 0,style:{position:"fixed",left:$.left,top:$.top,width:_??$.width,minWidth:_??$.width,zIndex:1e3,maxHeight:320,overflowY:"auto",opacity:v?1:0,pointerEvents:v?void 0:"none"},children:[E&&C&&e.jsx("div",{className:"nice-select__search",children:e.jsx("input",{type:"text",value:b,onChange:H=>{s(H.target.value),C(H.target.value)},placeholder:Z??S("controls.search","Search..."),autoFocus:!0})}),o]}),I)]}),R&&e.jsx("div",{className:"nice-field__error",children:R}),w&&!R&&e.jsx("div",{className:"nice-field__hint",children:w})]})};function Xe(t,i){return String(t[i])}const Jn={xxs:10,xs:12,sm:12,md:14,lg:18,xl:22,xxl:26},on=n.forwardRef(({source:t,target:i,onChange:a,keyField:o="id",labelField:r="label",renderItem:h,filterable:y=!1,searchable:_,groupBy:E,sortable:C=!1,bulkActions:Z=!0,maxRight:K,sourceHeader:R,targetHeader:w,disabled:Q=!1,size:ne="md",className:ee,style:te,id:A,...j},L)=>{const{t:f}=x.Gt(),k=Jn[ne]??14,[q,p]=n.useState(new Set),[d,S]=n.useState(new Set),[V,B]=n.useState(""),[b,s]=n.useState(""),[D,M]=n.useState(null),u=n.useCallback((H,N,P)=>{N(z=>{const re=new Set(z);return re.has(P)?re.delete(P):re.add(P),re})},[]),c=n.useCallback(()=>{const H=t.filter(re=>q.has(Xe(re,o))),N=t.filter(re=>!q.has(Xe(re,o))),P=typeof K=="number"?H.slice(0,Math.max(0,K-i.length)):H,z=H.slice(P.length);a([...N,...z],[...i,...P]),p(new Set)},[t,i,q,o,a,K]),l=n.useCallback(()=>{const H=i.filter(P=>d.has(Xe(P,o))),N=i.filter(P=>!d.has(Xe(P,o)));a([...t,...H],N),S(new Set)},[t,i,d,o,a]),g=n.useCallback(()=>{if(typeof K=="number"){const H=Math.max(0,K-i.length),N=t.slice(0,H),P=t.slice(H);a(P,[...i,...N])}else a([],[...i,...t]);p(new Set)},[t,i,a,K]),$=n.useCallback(()=>{a([...t,...i],[]),S(new Set)},[t,i,a]),v=(H,N)=>{if(!N)return H;const P=N.toLowerCase();return H.filter(z=>String(z[r]).toLowerCase().includes(P))},T=Z===!1?{moveAll:!1,removeAll:!1}:Z===!0||Z===void 0?{moveAll:!0,removeAll:!0}:{moveAll:Z.moveAll??!0,removeAll:Z.removeAll??!0},I=(H,N,P,z,re,me,de)=>{let be=v(H,z);C||(be=[...be].sort((ce,ge)=>String(ce[r]).localeCompare(String(ge[r]),void 0,{numeric:!0,sensitivity:"base"})));const ve=_===!0||y&&_===void 0?"both":_??!1,_e=ve==="both"||ve==="left"&&de==="left"||ve==="right"&&de==="right",fe=(()=>{if(!E)return[{label:"",items:be}];const ce=new Map;for(const ge of be){const Y=String(E(ge));let O=ce.get(Y);O||(O=[],ce.set(Y,O)),O.push(ge)}return[...ce.entries()].map(([ge,Y])=>({label:ge,items:Y}))})(),oe=(ce,ge)=>{ce.dataTransfer.setData("text/plain",ge),ce.dataTransfer.effectAllowed="move"},he=(ce,ge)=>{if(ce.preventDefault(),!C)return;const Y=ce.currentTarget.getBoundingClientRect(),O=ce.clientY<Y.top+Y.height/2;M(G=>G&&G.side===de&&G.key===ge&&G.before===O?G:{side:de,key:ge,before:O})},ie=(ce,ge)=>{ce.preventDefault();const Y=D?.before??!1;M(null);const O=ce.dataTransfer.getData("text/plain");if(!O||!C)return;const xe=[...de==="right"?i:t],le=xe.findIndex(se=>Xe(se,o)===O),F=xe.findIndex(se=>Xe(se,o)===ge);if(le===-1||F===-1||O===ge)return;let J=Y?F:F+1;const[U]=xe.splice(le,1);le<J&&(J-=1),xe.splice(J,0,U),a(de==="right"?t:xe,de==="right"?xe:i)};return e.jsxs("div",{className:"nice-picklist__panel",children:[me&&e.jsx("div",{className:"nice-picklist__header",children:me}),_e&&e.jsx("div",{className:"nice-picklist__filter",children:e.jsx("input",{className:"nice-input__native",type:"text",size:1,placeholder:f("controls.search","Search..."),value:z,onChange:ce=>re(ce.target.value)})}),e.jsxs("div",{className:"nice-picklist__list",role:"listbox","aria-multiselectable":"true",children:[fe.map(ce=>e.jsxs(n.Fragment,{children:[ce.label&&e.jsx("div",{className:"nice-picklist__group-header",role:"presentation",children:ce.label}),ce.items.map(ge=>{const Y=Xe(ge,o),O=N.has(Y),xe=D&&D.side===de&&D.key===Y?D.before?"nice-picklist__item--drop-before":"nice-picklist__item--drop-after":"";return e.jsxs("div",{className:`nice-picklist__item ${O?"nice-picklist__item--selected":""} ${xe}`,role:"option","aria-selected":O,draggable:C,onDragStart:C?le=>oe(le,Y):void 0,onDragOver:C?le=>he(le,Y):void 0,onDrop:C?le=>ie(le,Y):void 0,onDragEnd:C?()=>M(null):void 0,onClick:()=>!Q&&u(N,P,Y),children:[C&&e.jsx("span",{className:"nice-picklist__drag-handle","aria-hidden":"true",children:e.jsxs("svg",{width:k,height:k,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"})]})}),h?h(ge,de):String(ge[r])]},Y)})]},ce.label||"__none__")),be.length===0&&e.jsx("div",{className:"nice-picklist__empty",children:f("controls.noItems","No items")})]})]})};return e.jsxs("div",{ref:L,id:A,className:`nice-picklist nice-picklist--${ne} ${Q?"nice-picklist--disabled":""} ${ee||""}`,style:te,...j,children:[I(t,q,p,V,B,R??f("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--${ne}`,disabled:Q||q.size===0,onClick:c,"aria-label":f("picklist.moveRight","Move right"),children:e.jsx("svg",{width:k,height:k,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"})})}),T.moveAll&&e.jsx("button",{type:"button",className:`nice-btn nice-btn--outline nice-btn--${ne}`,disabled:Q||t.length===0,onClick:g,"aria-label":f("picklist.moveAllRight","Move all right"),children:e.jsxs("svg",{width:k,height:k,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--${ne}`,disabled:Q||d.size===0,onClick:l,"aria-label":f("picklist.moveLeft","Move left"),children:e.jsx("svg",{width:k,height:k,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"})})}),T.removeAll&&e.jsx("button",{type:"button",className:`nice-btn nice-btn--outline nice-btn--${ne}`,disabled:Q||i.length===0,onClick:$,"aria-label":f("picklist.moveAllLeft","Move all left"),children:e.jsxs("svg",{width:k,height:k,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"})]})})]}),I(i,d,S,b,s,w??f("picklist.target","Selected"),"right")]})});on.displayName="NicePickList";function Ct(t){return t?.startsWith("datetime")?"datetime":t==="week"?"week":t?.startsWith("month")?"month":"date"}function Qn(t){const i=new Date,a=`${i.getFullYear()}-${String(i.getMonth()+1).padStart(2,"0")}-${String(i.getDate()).padStart(2,"0")}`,o=Ct(t);return o==="datetime"?`${a}T00:00`:o==="month"?a.slice(0,7):a}function It(t,i){if(!t)return t;const a=new Date(t.length<=10?`${t}T00:00`:t);if(Number.isNaN(a.getTime()))return t;a.setDate(a.getDate()+i);const o=`${a.getFullYear()}-${String(a.getMonth()+1).padStart(2,"0")}-${String(a.getDate()).padStart(2,"0")}`;return t.length<=10?o.slice(0,t.length):o+t.slice(10)}function lt(...t){return t.filter(Boolean).sort().pop()}function jt(t,i,a){if(!t)return"";const o=new Date(t.length<=10?`${t}T00:00`:t);if(Number.isNaN(o.getTime()))return t;const r=Ct(a);return r==="month"?o.toLocaleDateString(i,{year:"numeric",month:"2-digit"}):r==="datetime"?o.toLocaleString(i,{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}):o.toLocaleDateString(i,{year:"numeric",month:"2-digit",day:"2-digit"})}function At(t){let i=0;for(const a of t)i+=/[\p{L}\p{N}]/u.test(a)?1:.5;return i}const Zn=({startDate:t,endDate:i,defaultStartDate:a,defaultEndDate:o,onStartChange:r,onEndChange:h,min:y,max:_,clearable:E,startPlaceholder:C,endPlaceholder:Z,startLabel:K,endLabel:R,layout:w="horizontal",separator:Q="–",gap:ne=12,fullWidth:ee=!1,dateFormatPreset:te,locale:A,timeSelectorType:j,type:L,endCondition:f="greater-or-equal",startCondition:k="today-or-greater",singleField:q=!1,label:p,error:d,helperText:S,required:V,disabled:B,size:b="md",id:s,className:D,style:M,accessMode:u,showKeyboardHints:c,labelPlacement:l,errorPlacement:g,labelWidth:$,controlWidth:v,loading:T,readOnly:I})=>{const H=x.Dc(u,s),N=x.bc(s),{t:P}=x.Gt(),z=H==="disabled"||H==="readOnly"||!!B,[re,me]=x.Vu({value:t,defaultValue:a??(t===void 0?"":void 0),onChange:r,componentName:"NiceDateRangeBox"}),[de,be]=x.Vu({value:i,defaultValue:o??(i===void 0?"":void 0),onChange:h,componentName:"NiceDateRangeBox"}),ve=n.useMemo(()=>[{key:"Tab",description:P("shortcuts.switchField","Switch between start/end")},x.Yc.cancel],[P]),_e=n.useRef(null),fe=n.useRef(null),[oe,he]=n.useState(!1),[ie,ce]=n.useState(null),[ge,Y]=n.useState(""),G=n.useContext(x.Er)?.portalTarget??(typeof document<"u"?document.body:null);n.useLayoutEffect(()=>{if(!oe)return;const pe=_e.current?.getBoundingClientRect();pe&&(ce({left:pe.left,top:pe.bottom+6}),Y(Be.scopeThemeClass(_e.current)))},[oe]),n.useEffect(()=>{if(!oe)return;const pe=m=>{const X=m.target;_e.current?.contains(X)||fe.current?.contains(X)||he(!1)},Me=m=>{m.key==="Escape"&&he(!1)},Ae=()=>{const m=_e.current?.getBoundingClientRect();m&&ce({left:m.left,top:m.bottom+6})};return document.addEventListener("mousedown",pe),document.addEventListener("keydown",Me),window.addEventListener("scroll",Ae,!0),window.addEventListener("resize",Ae),()=>{document.removeEventListener("mousedown",pe),document.removeEventListener("keydown",Me),window.removeEventListener("scroll",Ae,!0),window.removeEventListener("resize",Ae)}},[oe]);const xe=Qn(te),le=k==="today-or-greater"?lt(y,xe):k==="greater-than-today"?lt(y,It(xe,1)):y,F=f==="greater-or-equal"?lt(y,re):f==="greater"?lt(y,re?It(re,1):void 0):y,J=n.useMemo(()=>{if(d)return d;if(re&&de){if(f==="greater-or-equal"&&de<re)return P("daterange.endBeforeStart","End date must be on or after the start date");if(f==="greater"&&de<=re)return P("daterange.endAfterStart","End date must be after the start date")}if(re){if(k==="today-or-greater"&&re<xe)return P("daterange.startInPast","Start date cannot be in the past");if(k==="greater-than-today"&&re<=xe)return P("daterange.startAfterToday","Start date must be after today")}},[d,re,de,k,f,xe,P]);if(H==="hidden")return null;const U=pe=>{me(pe),pe&&de&&pe>de&&be(pe)},se=w==="horizontal",ue=Ct(te),je=A||rt.getDefaultLocale(),we=typeof Q=="string"&&Q!==""?Q:"–",Re=jt(re,je,te),Te=jt(de,je,te),Oe=Re||Te?`${Re||"…"} ${we} ${Te||"…"}`:"",qe=(()=>{const pe=jt("2026-12-30T22:58",je,te),Me=`${pe} ${we} ${pe}`;return`${(Math.max(At(Me),At(Oe))+1.5).toFixed(1)}ch`})(),Ye=(pe,Me)=>ue==="datetime"?Me&&Me.length>10?`${pe}${Me.slice(10)}`:`${pe}T00:00`:ue==="month"?pe.slice(0,7):pe,Ke=({start:pe,end:Me})=>{me(pe?Ye(pe,re):""),be(Me?Ye(Me,de):""),pe&&Me&&he(!1)},We=()=>{me(""),be("")},Ne=()=>{!z&&!I&&he(pe=>!pe)},ze=pe=>pe&&pe.length>=10?pe.slice(0,10):pe||void 0;return e.jsxs("div",{className:`nice-field nice-field--${b} nice-daterange nice-daterange--${w} ${l==="left"?"nice-field--label-left":""} ${J?"nice-field--error":""} ${T?"nice-field--loading":""} ${D||""}`,style:{...M,...$!=null&&{"--nice-field-label-width":typeof $=="number"?`${$}px`:$},...v!=null&&{"--nice-field-control-width":typeof v=="number"?`${v}px`:v}},"aria-busy":T||void 0,children:[p&&e.jsxs("label",{className:"nice-field__label",htmlFor:N,children:[p,V&&e.jsx("span",{className:"nice-field__required",children:"*"}),c&&e.jsx(x.ha,{shortcuts:ve,size:"sm"})]}),e.jsxs("div",{className:"nice-field__control",children:[q?e.jsxs("div",{ref:_e,className:`nice-input nice-input--date nice-input--${b} nice-daterange__single ${J?"nice-input--error":""} ${z?"nice-input--disabled":""} ${I?"nice-input--readonly":""}`,style:{position:"relative",width:ee?"100%":"fit-content"},children:[e.jsx("input",{id:N,className:"nice-input__native",type:"text",readOnly:!0,value:Oe,placeholder:C||P("controls.startDate","Start date"),disabled:z||T,autoComplete:"off","aria-invalid":!!J,"aria-label":p?void 0:P("controls.startDate","Start date"),onClick:Ne,style:{width:ee?"100%":qe,cursor:z||I?void 0:"pointer"}}),E&&e.jsx("button",{type:"button",className:"nice-input__clear",onClick:We,disabled:!re&&!de||z||I,"aria-label":P("controls.clear","Clear"),tabIndex:(re||de)&&!z&&!I?0:-1,children:e.jsx(x.oa,{name:"close",size:14})}),e.jsx("button",{type:"button",className:"nice-input__picker-trigger",onClick:Ne,"aria-label":P("controls.openPicker","Open picker"),"aria-expanded":oe,tabIndex:-1,disabled:z||I,children:e.jsx(x.oa,{name:"calendar",size:16})})]}):e.jsxs("div",{className:"nice-daterange__row",style:{display:"flex",flexDirection:se?"row":"column",alignItems:se?l==="left"?"center":"flex-end":"stretch",gap:ne,flexWrap:se?"nowrap":"wrap"},children:[e.jsx("div",{style:{flex:ee?"1 1 0":void 0,minWidth:0},children:e.jsx(rt.NiceDateTimePicker,{id:N,dateFormatPreset:te,displayLocale:A,timeSelectorType:j,type:L,label:K,value:re,onChange:U,min:le,max:de||_,placeholder:C||P("controls.startDate","Start date"),disabled:z,readOnly:I,size:b,clearable:E,labelPlacement:l,labelWidth:$})}),se&&Q!==""&&Q!=null&&e.jsx("span",{className:"nice-daterange__separator",style:{paddingBottom:8,color:"var(--nice-text-secondary, #666)"},"aria-hidden":"true",children:Q}),e.jsx("div",{style:{flex:ee?"1 1 0":void 0,minWidth:0},children:e.jsx(rt.NiceDateTimePicker,{dateFormatPreset:te,displayLocale:A,timeSelectorType:j,type:L,label:R,value:de,onChange:pe=>be(pe),min:F||re||y,max:_,placeholder:Z||P("controls.endDate","End date"),disabled:z,readOnly:I,size:b,clearable:E,labelPlacement:l,labelWidth:$})})]}),q&&oe&&ie&&G&&Ze.createPortal(e.jsxs("div",{ref:fe,className:`nice-datetime-popup${ge?` ${ge}`:""}`,style:{position:"fixed",left:ie.left,top:ie.top,zIndex:1e3},role:"dialog","aria-label":P("controls.openPicker","Open picker"),children:[e.jsx("div",{className:"nice-datetime-popup__body",children:e.jsx("div",{className:"nice-datetime-popup__col nice-datetime-popup__col--date",children:e.jsx(rt.NiceCalendar,{selectionMode:"range",rangeStart:ze(re),rangeEnd:ze(de),onRangeChange:Ke,min:ze(le),max:ze(_),size:b})})}),E&&e.jsx("div",{className:"nice-datetime-popup__footer",children:e.jsx("button",{type:"button",className:"nice-datetime-popup__btn",onClick:We,disabled:!re&&!de,children:P("controls.clear","Clear")})})]}),G),T&&e.jsx("span",{className:"nice-field__spinner",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})}),g==="right"&&J&&e.jsx("div",{className:"nice-field__error",role:"alert",children:J}),g==="right"&&!J&&S&&e.jsx("div",{className:"nice-field__helper",children:S})]}),g!=="right"&&J&&e.jsx("div",{className:"nice-field__error",children:J}),g!=="right"&&!J&&S&&e.jsx("div",{className:"nice-field__hint",children:S})]})};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"analogous-complementary":return[0,-i,i,180];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 Dt(t,i={}){const a=i.size??16,o="currentColor",r="currentColor";if(i.rectangle||t==="shade-chain"||t==="monochromatic"){const K=Math.max(3,Math.min(7,i.count??5)),R=a*.1,w=a-R*2,Q=Math.max(1.2,a/14),ne=a/2,ee=Array.from({length:K},(te,A)=>{const j=R+w*A/(K-1),L=.25+.75*A/(K-1);return e.jsx("circle",{cx:j,cy:ne,r:Q,fill:r,opacity:L},A)});return e.jsxs("svg",{width:a,height:a,viewBox:`0 0 ${a} ${a}`,"aria-hidden":!0,children:[e.jsx("rect",{x:1,y:a/2-a/6,width:a-2,height:a/3,rx:a/6,fill:"none",stroke:o,strokeOpacity:.25}),ee]})}const y=i.angles??ei(t),_=a/2,E=a/2,C=a/2-2,Z=Math.max(1.4,a/9);return e.jsxs("svg",{width:a,height:a,viewBox:`0 0 ${a} ${a}`,"aria-hidden":!0,children:[e.jsx("circle",{cx:_,cy:E,r:C,fill:"none",stroke:o,strokeOpacity:.25}),y.map((K,R)=>{const w=(K-90)*Math.PI/180,Q=_+C*Math.cos(w),ne=E+C*Math.sin(w);return e.jsx("circle",{cx:Q,cy:ne,r:Z,fill:r},R)})]})}function zt(t,i,a){return Math.max(i,Math.min(a,t))}function sn({h:t,s:i,v:a}){t=(t%360+360)%360;const o=a*i,r=o*(1-Math.abs(t/60%2-1)),h=a-o;let y=0,_=0,E=0;return t<60?(y=o,_=r):t<120?(y=r,_=o):t<180?(_=o,E=r):t<240?(_=r,E=o):t<300?(y=r,E=o):(y=o,E=r),{r:Math.round((y+h)*255),g:Math.round((_+h)*255),b:Math.round((E+h)*255)}}function St({r:t,g:i,b:a}){t/=255,i/=255,a/=255;const o=Math.max(t,i,a),r=Math.min(t,i,a),h=o-r;let y=0;return h!==0&&(o===t?y=(i-a)/h%6:o===i?y=(a-t)/h+2:y=(t-i)/h+4,y=(y*60+360)%360),{h:y,s:o===0?0:h/o,v:o}}function rn({r:t,g:i,b:a}){t/=255,i/=255,a/=255;const o=Math.max(t,i,a),r=Math.min(t,i,a),h=(o+r)/2;if(o===r)return{h:0,s:0,l:h};const y=o-r,_=h>.5?y/(2-o-r):y/(o+r);let E=0;return o===t?E=((i-a)/y+(i<a?6:0))/6:o===i?E=((a-t)/y+2)/6:E=((t-i)/y+4)/6,{h:E*360,s:_,l:h}}function st(t){const i=t.replace("#",""),a=i.length===3?i[0]+i[0]+i[1]+i[1]+i[2]+i[2]:i,o=parseInt(a,16);return{r:o>>16&255,g:o>>8&255,b:o&255}}function cn({r:t,g:i,b:a}){return"#"+[t,i,a].map(o=>o.toString(16).padStart(2,"0")).join("")}function De(t){return cn(sn(t))}function He(t){return St(st(t))}function ln(t,i){const a=[];for(let o=0;o<i;o++){const r=i<=1?.5:o/(i-1),h=zt(t.s*(.3+r*.7),0,1),y=zt(t.v*(1.2-r*.7),0,1);a.push(De({h:t.h,s:h,v:y}))}return a}function gt(t,i){if(t==="custom"||t==="shade-chain")return[0];const a=i??30;switch(t){case"monochromatic":return[0];case"complementary":return[0,180];case"split-complementary":return[0,180-a,180+a];case"analogous":return[0,-a,a];case"analogous-complementary":return[0,-a,a,180];case"triadic":return[0,120,240];case"tetradic":return[0,60,180,240];case"square":return[0,90,180,270]}return[0]}function ot(t,i,a){return gt(i,a).map(o=>((t+o)%360+360)%360)}function Lt(t,i,a=.12){const o=Math.max(2,i),r=(o-1)/2,h=[];for(let y=0;y<o;y++){const _=(y-r)*a,E=Math.max(.05,Math.min(.98,t.v+_)),C=Math.max(.05,Math.min(1,t.s-Math.abs(_)*.25));h.push(De({h:t.h,s:C,v:E}))}return h}function Pt({r:t,g:i,b:a}){const[o,r,h]=[t,i,a].map(y=>{const _=y/255;return _<=.03928?_/12.92:Math.pow((_+.055)/1.055,2.4)});return .2126*o+.7152*r+.0722*h}function mt(t,i){const a=Pt(st(t)),o=Pt(st(i)),r=Math.max(a,o),h=Math.min(a,o);return(r+.05)/(h+.05)}function ut(t){return t>=7?"AAA":t>=4.5?"AA":t>=3?"AA-lg":"Fail"}const dn={"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 pt(t,i){const a=dn[i];return t.map(o=>{const r=(a.sRange[0]+a.sRange[1])/2,h=(a.vRange[0]+a.vRange[1])/2;return De({h:o,s:r,v:h})})}function ti(){return Math.floor(Math.random()*360)}function mn(t,i,a){const o=ti(),r=ot(o,t,a),h=[];for(let y=0;y<i;y++){const _=r[y%r.length],E=.55+Math.random()*.4,C=.5+Math.random()*.45;h.push(De({h:_+(Math.random()-.5)*8,s:E,v:C}))}return h}const ni=({hues:t,colors:i,baseHue:a,onBaseHueChange:o,mode:r,distance:h,disabled:y})=>{const R=n.useRef(null),w=n.useCallback((j,L)=>{const f=R.current;if(!f)return;const k=f.getBoundingClientRect(),q=(j-k.left)/k.width*240-120,p=(L-k.top)/k.height*240-120,d=(Math.atan2(p,q)*180/Math.PI+360)%360;o(Math.round(d))},[120,120,240,o]),Q=n.useCallback(j=>{if(y)return;j.preventDefault(),w(j.clientX,j.clientY);const L=k=>w(k.clientX,k.clientY),f=()=>{document.removeEventListener("pointermove",L),document.removeEventListener("pointerup",f)};document.addEventListener("pointermove",L),document.addEventListener("pointerup",f)},[y,w]),ne=[];for(let j=0;j<360;j+=2){const L=(j-1)*Math.PI/180,f=(j+1)*Math.PI/180,k=De({h:j,s:1,v:1});ne.push(e.jsx("path",{d:`M${120+55*Math.cos(L)},${120+55*Math.sin(L)} L${120+110*Math.cos(L)},${120+110*Math.sin(L)} A110,110 0 0,1 ${120+110*Math.cos(f)},${120+110*Math.sin(f)} L${120+55*Math.cos(f)},${120+55*Math.sin(f)} A55,55 0 0,0 ${120+55*Math.cos(L)},${120+55*Math.sin(L)} Z`,fill:k},j))}const ee=`wheel-center-${r}`,te=t.map((j,L)=>{const k=j*Math.PI/180;return e.jsx("circle",{cx:120+82.5*Math.cos(k),cy:120+82.5*Math.sin(k),r:L===0?8:6,fill:i?.[L]??De({h:j,s:.85,v:.9}),stroke:L===0?"var(--nice-bg-primary, #fff)":"var(--nice-border-color, #ccc)",strokeWidth:L===0?3:2},L)});let A=null;if(r==="analogous"||r==="split-complementary"||r==="analogous-complementary"){const f=gt(r,h).slice(1).map((k,q)=>{const p=(a+k)*Math.PI/180;return e.jsx("line",{x1:120,y1:120,x2:120+82.5*Math.cos(p),y2:120+82.5*Math.sin(p),stroke:"var(--nice-overlay-light-30, rgba(255, 255, 255, 0.3))",strokeWidth:1,strokeDasharray:"3,3"},`dline-${q}`)});A=e.jsx(e.Fragment,{children:f})}return e.jsxs("svg",{ref:R,className:"nice-palette__wheel",viewBox:"0 0 240 240",width:240,height:240,onPointerDown:Q,style:{cursor:y?"default":"crosshair",touchAction:"none"},children:[e.jsx("defs",{children:e.jsxs("radialGradient",{id:ee,children:[e.jsx("stop",{offset:"0%",stopColor:"var(--nice-bg, #fff)"}),e.jsx("stop",{offset:"100%",stopColor:"transparent"})]})}),ne,e.jsx("circle",{cx:120,cy:120,r:53,fill:De({h:a,s:.6,v:.85})}),e.jsx("circle",{cx:120,cy:120,r:53,fill:`url(#${ee})`,opacity:.4}),A,te]})},ii=({colors:t})=>{if(t.length<2)return null;const i=[];for(let a=0;a<t.length;a++){const o=mt(t[a],"var(--nice-bg-primary, #ffffff)"),r=mt(t[a],"var(--nice-text-primary, #000000)");i.push({a:t[a],b:"var(--nice-bg-primary, #ffffff)",ratio:o,level:ut(o)}),i.push({a:t[a],b:"var(--nice-text-primary, #000000)",ratio:r,level:ut(r)});for(let h=a+1;h<t.length;h++){const y=mt(t[a],t[h]);i.push({a:t[a],b:t[h],ratio:y,level:ut(y)})}}return e.jsxs("div",{className:"nice-palette__contrast",children:[e.jsx("div",{className:"nice-palette__section-title",children:"Contrast Analysis (WCAG 2.1)"}),e.jsx("div",{className:"nice-palette__contrast-grid",children:i.map((a,o)=>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:a.a}}),e.jsx("span",{className:"nice-palette__contrast-vs",children:"vs"}),e.jsx("span",{className:"nice-palette__contrast-dot",style:{background:a.b}})]}),e.jsxs("span",{className:"nice-palette__contrast-ratio",children:[a.ratio.toFixed(1),":1"]}),e.jsx("span",{className:`nice-palette__contrast-level nice-palette__contrast-level--${a.level.toLowerCase().replace("-","")}`,children:a.level})]},o))})]})},ai=({hex:t})=>{const i=st(t),a=rn(i),o=St(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(a.h),"°, ",Math.round(a.s*100),"%,"," ",Math.round(a.l*100),"%"]}),e.jsxs("div",{children:[e.jsx("strong",{children:"HSV"})," ",Math.round(o.h),"°, ",Math.round(o.s*100),"%,"," ",Math.round(o.v*100),"%"]})]})},oi={monochromatic:"Monochromatic",complementary:"Complementary","split-complementary":"Split-Complementary",analogous:"Analogous","analogous-complementary":"Analogous + Complementary",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","analogous-complementary","triadic","tetradic","square","custom"],un=["lightest-pastel","bright-pastel","shiny","pastel","full","dark","deep","muted","earth"],pn="nice-palette-custom-schemes";function ci(){if(typeof window>"u")return[];try{const t=window.localStorage.getItem(pn);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(pn,JSON.stringify(t))}catch{}}const hn=n.forwardRef(({id:t,className:i,style:a,accessMode:o,value:r,onChange:h,minColors:y=1,maxColors:_=8,harmonyMode:E,onHarmonyModeChange:C,distance:Z,onDistanceChange:K,preset:R,onPresetChange:w,showWheel:Q=!0,showContrast:ne=!0,showInfo:ee=!0,showPresets:te=!0,presets:A=[],showVariations:j=!0,showRandom:L=!0,variationCount:f=5,label:k,labelPlacement:q="top",disabled:p,readOnly:d,loading:S,error:V,colorCount:B,shadeStep:b,onShadeStepChange:s,customSchemes:D,onCustomSchemesChange:M,persistCustomSchemes:u=!0},c)=>{const l=x.Dc(o,t),g=l==="hidden";l==="disabled"&&(p=!0);const $=d||l==="readOnly",v=x.bc(t),{t:T}=x.Gt(),[I,H]=n.useState("analogous-complementary"),[N,P]=n.useState(30),[z,re]=n.useState(""),[me,de]=n.useState(0),[be,ve]=n.useState(.12),[_e,fe]=n.useState(null),[oe,he]=n.useState(()=>D??(u?ci():[])),[ie,ce]=n.useState(null),[ge,Y]=n.useState(!1),[O,G]=n.useState(null),[xe,le]=n.useState(""),J=n.useContext(x.Er)?.portalTarget??(typeof document<"u"?document.body:null),U=n.useRef(null),se=n.useRef(null),ue=E??I,je=Z??N,we=R??z,Re=b??be,Te=D??oe;n.useEffect(()=>{!D&&u&&li(oe)},[oe,D,u]);const Oe=n.useCallback(W=>{he(W),M?.(W)},[M]),qe=n.useCallback(W=>{H(W),C?.(W)},[C]),Ye=n.useCallback(W=>{P(W),K?.(W)},[K]),Ke=n.useCallback(W=>{re(W),W&&w?.(W)},[w]),We=n.useMemo(()=>["var(--nice-color-primary, #3b82f6)","var(--nice-color-error, #ef4444)","var(--nice-color-success, #22c55e)"],[]),Ne=r&&r.length>0?r:We,ze=Ne[0],pe=n.useMemo(()=>He(ze),[ze]),Me=n.useMemo(()=>ot(pe.h,ue,je),[pe.h,ue,je]),Ae=n.useCallback((W,ye,ke,Ee,Pe)=>{const tt=B??Pe??_e??Ne.length,Je=tt!==void 0?Math.max(y,Math.min(_,tt)):void 0;if(ye==="shade-chain"){const Le=Je??Math.max(y,5),Ge=Lt({h:W,s:pe.s||.7,v:pe.v||.6},Le,Re);h?.(Ge);return}let Qe;const nt=ye==="custom"&&ie?Te.find(Le=>Le.id===ie):null;nt&&nt.angles.length>0?Qe=nt.angles.map(Le=>((W+Le)%360+360)%360):Qe=ot(W,ye,ke);let Ie;if(Ee&&dn[Ee]?Ie=pt(Qe,Ee):Ie=Qe.map(Le=>De({h:Le,s:pe.s||.7,v:pe.v||.85})),nt?.lightnessOffsets?.length&&(Ie=Ie.map((Le,Ge)=>{const Rt=nt.lightnessOffsets?.[Ge];if(Rt==null)return Le;const xt=He(Le);return De({h:xt.h,s:xt.s,v:Math.max(.05,Math.min(.98,xt.v+Rt))})})),Je!==void 0){for(;Ie.length<Je;){const Le=Ie[Ie.length-1]||"#888888",Ge=He(Le);Ie.push(De({h:(Ge.h+18)%360,s:Ge.s,v:Ge.v}))}Ie=Ie.slice(0,Je)}else{for(;Ie.length<y;)Ie.push(Ie[Ie.length-1]||"var(--nice-text-secondary, #888888)");Ie.length>_&&(Ie=Ie.slice(0,_))}h?.(Ie)},[pe.s,pe.v,y,_,h,B,_e,Ne.length,Re,ie,Te]),m=n.useCallback(W=>{if(!p){if(ue==="custom"){const ye=De({h:W,s:pe.s||.7,v:pe.v||.85}),ke=[...Ne];ke[me]=ye,h?.(ke);return}Ae(W,ue,je,we)}},[p,ue,je,we,Ae,pe.s,pe.v,Ne,me,h]),X=n.useCallback(W=>{if(p||(qe(W),W==="custom"))return;const ye=gt(W).length,ke=ye<=1;if(B==null&&!ke){const Ee=Math.max(y,Math.min(_,ye));fe(Ee),Ae(pe.h,W,je,we,Ee)}else Ae(pe.h,W,je,we)},[p,pe.h,je,we,qe,Ae,B,y,_]),ae=n.useCallback(W=>{p||(Ye(W),Ae(pe.h,ue,W,we))},[p,pe.h,ue,we,Ye,Ae]),Ce=n.useCallback(W=>{if(p)return;Ke(W);const ye=ot(pe.h,ue,je),ke=pt(ye,W);h?.(ke.slice(0,_))},[p,pe.h,ue,je,_,Ke,h]),$e=n.useCallback((W,ye)=>{if(p)return;const ke=[...Ne];ke[W]=ye,h?.(ke)},[p,Ne,h]),Ue=n.useCallback(()=>{if(p||Ne.length>=_)return;const W=He(Ne[Ne.length-1]),ye=De({h:(W.h+30)%360,s:W.s,v:W.v});h?.([...Ne,ye])},[p,Ne,_,h]),Ve=n.useCallback(W=>{if(p||Ne.length<=y)return;const ye=Ne.filter((ke,Ee)=>Ee!==W);h?.(ye),me>=ye.length&&de(Math.max(0,ye.length-1))},[p,Ne,y,h,me]),zn=n.useCallback(()=>{if(p)return;const W=Math.max(y,Math.min(_,gt(ue).length)),ye=mn(ue,W,je);h?.(ye)},[p,y,_,ue,je,h]),Et=n.useMemo(()=>{if(!j)return[];const W=Ne[me]||Ne[0];return ln(He(W),f)},[j,Ne,me,f]),ft=Ne[me]||Ne[0],yt=n.useMemo(()=>{const W=He(ft);return De({h:(W.h+180)%360,s:W.s,v:W.v})},[ft]);if(n.useLayoutEffect(()=>{if(!ge||!U.current)return;le(Be.scopeThemeClass(U.current));const W=()=>{const ye=U.current?.getBoundingClientRect();if(!ye)return;const ke=600;let Ee=ye.left;Ee+ke>window.innerWidth-8&&(Ee=Math.max(8,window.innerWidth-ke-8));let Pe=ye.bottom+6;Pe>window.innerHeight*.5&&(Pe=Math.max(8,window.innerHeight-Math.min(window.innerHeight-16,540)-8)),G({left:Ee,top:Pe})};return W(),window.addEventListener("scroll",W,!0),window.addEventListener("resize",W),()=>{window.removeEventListener("scroll",W,!0),window.removeEventListener("resize",W)}},[ge]),n.useEffect(()=>{if(!ge)return;const W=ke=>{const Ee=ke.target;U.current?.contains(Ee)||se.current?.contains(Ee)||(Ee instanceof Element?Ee:Ee?.parentElement??null)?.closest('.nice-select__dropdown, [role="listbox"], [role="option"]')||Y(!1)},ye=ke=>{ke.key==="Escape"&&Y(!1)};return document.addEventListener("mousedown",W),document.addEventListener("keydown",ye),()=>{document.removeEventListener("mousedown",W),document.removeEventListener("keydown",ye)}},[ge]),g)return null;const Mt=A.length>0?A:un,Ln=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(Be.NiceSelect,{label:T("colorPalette.harmony","Harmony"),labelPlacement:"left",size:"sm",disabled:p,value:ue==="custom"&&ie?`custom:${ie}`:ue,onChange:W=>{const ye=Array.isArray(W)?W[0]:W;if(typeof ye=="string")if(ye.startsWith("custom:")){const ke=ye.slice(7);ce(ke),X("custom")}else ce(null),X(ye)},options:[...ri.map(W=>({value:W,label:oi[W]})),...Te.map(W=>({value:`custom:${W.id}`,label:W.name}))],renderOption:(W,ye)=>{const ke=String(W.value),Ee=ke.startsWith("custom:"),Pe=Ee?Te.find(Qe=>Qe.id===ke.slice(7)):null,tt=Pe?Pe.angles:void 0,Je=Ee?"custom":ke;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:Dt(Je,{angles:tt,size:16,count:B})}),e.jsx("span",{style:{fontWeight:ye?600:400},children:W.label})]})}}),ue==="shade-chain"&&e.jsx(Fe.NiceNumberInput,{label:T("colorPalette.step","Step"),labelPlacement:"left",size:"sm",min:.02,max:.5,step:.02,precision:2,value:Re,onChange:W=>{const ye=typeof W=="number"?W:Number(W);Number.isNaN(ye)||(ve(ye),s?.(ye),Ae(pe.h,ue,je,we))},showStepper:!0,disabled:p}),e.jsx(Fe.NiceNumberInput,{label:T("colorPalette.colors","Colors"),labelPlacement:"left",size:"sm",min:Math.max(2,y),max:Math.min(12,_),step:1,precision:0,value:B??_e??Ne.length,onChange:W=>{const ye=typeof W=="number"?W:Number(W);if(!Number.isFinite(ye))return;const ke=Math.max(Math.max(2,y),Math.min(Math.min(12,_),Math.round(ye)));fe(ke),ue==="shade-chain"?h?.(Lt({h:pe.h,s:pe.s||.7,v:pe.v||.6},ke,Re)):setTimeout(()=>Ae(pe.h,ue,je,we),0)},showStepper:!0,disabled:p})]}),e.jsx("div",{className:"nice-palette__main",children:e.jsxs("div",{className:"nice-palette__strips",children:[e.jsxs("div",{className:"nice-palette__swatches",children:[Ne.map((W,ye)=>e.jsxs("div",{className:`nice-palette__swatch-wrapper ${me===ye?"nice-palette__swatch-wrapper--selected":""}`,onClick:()=>de(ye),children:[e.jsx("span",{className:"nice-palette__swatch",style:{background:W}}),e.jsx("input",{type:"text",className:"nice-palette__hex-input",value:W.toUpperCase(),maxLength:7,disabled:p,onClick:ke=>ke.stopPropagation(),onChange:ke=>$e(ye,ke.target.value)}),Ne.length>y&&e.jsx("button",{type:"button",className:"nice-palette__swatch-remove",onClick:ke=>{ke.stopPropagation(),Ve(ye)},disabled:p,"aria-label":"Remove color",children:e.jsx(x.oa,{name:"close",size:14})})]},ye)),Ne.length<_&&e.jsxs("button",{type:"button",className:"nice-palette__add-btn",onClick:Ue,disabled:p,title:"Add color",children:[e.jsx(x.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:yt},title:yt.toUpperCase()}),e.jsx("span",{className:"nice-palette__hex-label",children:yt.toUpperCase()})]}),L&&e.jsxs("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm nice-palette__random-btn",onClick:zn,disabled:p,title:"Random palette","aria-label":"Random palette",children:[e.jsx(x.oa,{name:"shuffle",size:14})," Random Palette"]})]})})]}),Pn=e.jsx("div",{className:"nice-palette__tab",children:Et.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:Et.map((W,ye)=>e.jsx("div",{className:"nice-palette__variation-chip",style:{background:W},title:W.toUpperCase(),onClick:()=>{p||$e(me,W)},role:"button",tabIndex:0},ye))})]}):e.jsx("div",{className:"nice-palette__empty",children:"No variations available."})}),Bn=e.jsx("div",{className:"nice-palette__tab",children:e.jsx("div",{className:"nice-palette__preset-grid",children:Mt.map(W=>{const ye=pt(Me,W);return e.jsxs("button",{type:"button",className:`nice-palette__preset-card ${we===W?"nice-palette__preset-card--active":""}`,onClick:()=>Ce(W),disabled:p,children:[e.jsx("div",{className:"nice-palette__preset-strip",children:ye.map((ke,Ee)=>e.jsx("span",{className:"nice-palette__preset-dot",style:{background:ke}},Ee))}),e.jsx("span",{className:"nice-palette__preset-label",children:si[W]})]},W)})})}),Hn=e.jsxs("div",{className:"nice-palette__tab",children:[ee&&e.jsxs("div",{className:"nice-palette__info-panel",children:[e.jsx("div",{className:"nice-palette__section-title",children:"Selected Color Info"}),e.jsx(ai,{hex:ft})]}),ne&&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:Ne})]})]}),On=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(--nice-text-muted)"},children:T("colorPalette.schemes.empty","Save the current palette as a reusable scheme.")}),Te.map(W=>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:Dt("custom",{angles:W.angles,size:16})}),e.jsx("span",{style:{flex:1},children:W.name}),e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--xs",onClick:()=>{ce(W.id),X("custom")},disabled:p,children:"Use"}),e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--xs",onClick:()=>Oe(Te.filter(ye=>ye.id!==W.id)),disabled:p,"aria-label":`Delete ${W.name}`,children:e.jsx(x.oa,{name:"close",size:14})})]},W.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:p,onClick:()=>{const W=typeof window<"u"?window.prompt("Scheme name?",`Scheme ${Te.length+1}`):null;if(!W)return;const ye=He(Ne[0]).h,ke=Ne.map(Pe=>(He(Pe).h-ye+540)%360-180),Ee={id:`cs-${Date.now()}`,name:W,angles:ke};Oe([...Te,Ee])},children:"+ Save current as scheme"}),e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm",disabled:p||Te.length===0,onClick:()=>{typeof navigator>"u"||navigator.clipboard?.writeText(JSON.stringify(Te,null,2))},children:T("colorPalette.exportJson","Export JSON")}),e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm",disabled:p,onClick:()=>{if(typeof window>"u")return;const W=window.prompt("Paste schemes JSON");if(W)try{const ye=JSON.parse(W);Array.isArray(ye)&&Oe(ye)}catch{}},children:T("colorPalette.importJson","Import JSON")})]})]})}),et=[{id:"colors",label:"Colors",content:Ln}];te&&Mt.length>0&&et.push({id:"presets",label:"Presets",content:Bn}),j&&et.push({id:"variations",label:"Variations",content:Pn}),(ee||ne)&&et.push({id:"info",label:"Info",content:Hn}),et.push({id:"schemes",label:"Schemes",content:On});const Fn=e.jsxs("div",{className:"nice-palette__popup-header",children:[Q&&e.jsxs("div",{className:"nice-palette__wheel-container",children:[e.jsx(ni,{hues:Me,colors:Ne,baseHue:pe.h,onBaseHueChange:m,mode:ue,distance:je,disabled:p}),(ue==="analogous"||ue==="split-complementary"||ue==="analogous-complementary")&&e.jsxs("div",{className:"nice-palette__distance",children:[e.jsxs("label",{children:["Distance: ",je,"°"]}),e.jsx("input",{type:"range",min:10,max:90,value:je,onChange:W=>ae(Number(W.target.value)),disabled:p,className:"nice-palette__distance-slider"})]})]}),e.jsx("button",{type:"button",className:"nice-palette__confirm",onClick:()=>Y(!1),"aria-label":T("controls.confirm","Confirm"),title:T("controls.confirm","Confirm"),children:e.jsx(x.oa,{name:"check",size:18})})]}),Yn=e.jsxs("div",{className:"nice-palette nice-palette--studio",children:[Fn,e.jsx(Fe.NiceTabs,{tabs:et,variant:"enclosed",size:"sm"})]});return e.jsxs("div",{ref:c,id:v,className:`nice-field nice-palette-field ${p?"nice-palette--disabled":""} ${q==="left"?"nice-field--label-left":""} ${S?"nice-field--loading":""} ${V?"nice-field--error":""} ${i||""}`,style:a,children:[k&&e.jsx("label",{htmlFor:v,className:"nice-field__label",children:k}),e.jsxs("div",{className:"nice-field__control",children:[e.jsx("div",{ref:U,className:"nice-palette__field-swatches",role:"button",tabIndex:p||$?-1:0,"aria-haspopup":"dialog","aria-expanded":ge,"aria-readonly":$||void 0,"aria-label":T("colorPalette.openStudio","Open palette studio"),onClick:()=>{!p&&!$&&Y(W=>!W)},onKeyDown:W=>{!p&&!$&&(W.key==="Enter"||W.key===" ")&&(W.preventDefault(),Y(ye=>!ye))},children:Ne.map((W,ye)=>e.jsx("span",{className:"nice-palette__field-swatch",style:{background:W},title:W.toUpperCase(),onClick:ke=>{ke.stopPropagation(),!p&&!$&&(de(ye),Y(!0))}},ye))}),S&&e.jsx("span",{className:"nice-field__spinner",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})}),ge&&O&&J&&Ze.createPortal(e.jsx("div",{ref:se,className:`nice-palette__popup${xe?` ${xe}`:""}`,"data-theme":xe==="nice-dark"?"dark":xe==="nice-light"?"light":void 0,role:"dialog","aria-label":T("colorPalette.studio","Palette studio"),style:{position:"fixed",left:O.left,top:O.top,zIndex:1e3},children:Yn}),J)]}),typeof V=="string"&&V&&e.jsx("div",{className:"nice-field__error",role:"alert",children:V})]})});hn.displayName="NiceColorPalette";function wt(){return{type:"linear",angle:90,stops:[{color:"var(--nice-primary, #3b82f6)",position:0},{color:"var(--nice-accent, #8b5cf6)",position:100}]}}function Nt(t){const i=t.stops.slice().sort((o,r)=>o.position-r.position).map(o=>`${o.color} ${o.position}%`).join(", "),a=t.repeating?"repeating-":"";switch(t.type){case"linear":return`${a}linear-gradient(${t.angle}deg, ${i})`;case"radial":{const o=t.shape||"ellipse",r=t.size||"farthest-corner",h=t.positionX??50,y=t.positionY??50;return`${a}radial-gradient(${o} ${r} at ${h}% ${y}%, ${i})`}case"conic":{const o=t.angle??0,r=t.positionX??50,h=t.positionY??50;return`${a}conic-gradient(from ${o}deg at ${r}% ${h}%, ${i})`}}}function gn(t){const i=t.trim(),a=i.startsWith("repeating-");if(i.includes("linear-gradient")){const o=i.match(/linear-gradient\((.+)\)/)?.[1];if(!o)return null;const r=o.split(",").map(C=>C.trim());let h=90,y=0;const _=r[0].match(/^(\d+)deg$/);_&&(h=parseInt(_[1]),y=1);const E=bt(r.slice(y));return{type:"linear",angle:h,repeating:a,stops:E}}if(i.includes("radial-gradient")){const o=i.match(/radial-gradient\((.+)\)/)?.[1];if(!o)return null;const r=o.split(",").map(y=>y.trim()),h=bt(r.filter(y=>y.includes("#")||y.includes("rgb")));return{type:"radial",angle:0,repeating:a,stops:h.length>=2?h:wt().stops}}if(i.includes("conic-gradient")){const o=i.match(/conic-gradient\((.+)\)/)?.[1];if(!o)return null;const r=o.split(",").map(y=>y.trim()),h=bt(r.filter(y=>y.includes("#")||y.includes("rgb")));return{type:"conic",angle:0,repeating:a,stops:h.length>=2?h:wt().stops}}return null}function bt(t){return t.map((i,a,o)=>{const r=i.match(/^(#[0-9a-fA-F]{3,8}|rgba?\([^)]+\))\s*(\d+%?)?$/);if(r){const h=r[2]?parseFloat(r[2]):a/Math.max(1,o.length-1)*100;return{color:r[1],position:h}}return{color:i,position:a/Math.max(1,o.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"],a=i[Math.floor(Math.random()*i.length)],o=[];for(let r=0;r<t;r++)o.push({color:di(),position:Math.round(r/(t-1)*100)});return{type:a,angle:Math.floor(Math.random()*360),stops:o,shape:a==="radial"?Math.random()>.5?"circle":"ellipse":void 0,positionX:a!=="linear"?Math.round(Math.random()*100):void 0,positionY:a!=="linear"?Math.round(Math.random()*100):void 0}}const fn=[{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}}],yn=n.forwardRef(({id:t,className:i,style:a,accessMode:o,value:r,onChange:h,showCssOutput:y=!0,showPresets:_=!0,showEditor:E=!0,showRandom:C=!0,maxStops:Z=10,label:K,labelPlacement:R="top",disabled:w,readOnly:Q,loading:ne,error:ee,errorPlacement:te="bottom",width:A},j)=>{const L=x.Dc(o,t),f=L==="hidden";L==="disabled"&&(w=!0);const k=Q||L==="readOnly",q=x.bc(t),{t:p}=x.Gt(),d=r??wt(),S=n.useMemo(()=>Nt(d),[d]),[V,B]=n.useState(0),[b,s]=n.useState(""),D=n.useRef(null),[M,u]=n.useState(!1),[c,l]=n.useState(null),[g,$]=n.useState(""),T=n.useContext(x.Er)?.portalTarget??(typeof document<"u"?document.body:null),I=n.useRef(null),H=n.useRef(null),N=typeof A=="number"?A:340;n.useLayoutEffect(()=>{if(!M||!I.current)return;$(Be.scopeThemeClass(I.current));const F=()=>{const J=I.current?.getBoundingClientRect();if(!J)return;let U=J.left;U+N>window.innerWidth-8&&(U=Math.max(8,window.innerWidth-N-8));let se=J.bottom+6;se>window.innerHeight*.5&&(se=Math.max(8,window.innerHeight-Math.min(window.innerHeight-16,520)-8)),l({left:U,top:se})};return F(),window.addEventListener("scroll",F,!0),window.addEventListener("resize",F),()=>{window.removeEventListener("scroll",F,!0),window.removeEventListener("resize",F)}},[M,N]),n.useEffect(()=>{if(!M)return;const F=U=>{const se=U.target;I.current?.contains(se)||H.current?.contains(se)||(se instanceof Element?se:se?.parentElement??null)?.closest('.nice-select__dropdown, [role="listbox"], [role="option"]')||u(!1)},J=U=>{U.key==="Escape"&&u(!1)};return document.addEventListener("mousedown",F),document.addEventListener("keydown",J),()=>{document.removeEventListener("mousedown",F),document.removeEventListener("keydown",J)}},[M]);const P=n.useCallback(F=>{h?.(F)},[h]),z=n.useCallback(F=>{w||P({...d,type:F})},[w,d,P]),re=n.useCallback(F=>{w||P({...d,angle:F})},[w,d,P]),me=n.useCallback(F=>{w||P({...d,repeating:F})},[w,d,P]),de=n.useCallback(F=>{w||P({...d,shape:F})},[w,d,P]),be=n.useCallback((F,J)=>{if(w)return;const U=d.stops.map((se,ue)=>ue===F?{...se,...J}:se);P({...d,stops:U})},[w,d,P]),ve=n.useRef(!1),_e=n.useCallback((F,J)=>{if(w||!D.current)return;F.stopPropagation(),F.preventDefault(),B(J),ve.current=!1;const U=ue=>{if(!D.current)return;ve.current=!0;const je=D.current.getBoundingClientRect(),we=Math.round(Math.max(0,Math.min(100,(ue.clientX-je.left)/je.width*100)));be(J,{position:we})},se=()=>{document.removeEventListener("pointermove",U),document.removeEventListener("pointerup",se),document.removeEventListener("pointercancel",se)};document.addEventListener("pointermove",U),document.addEventListener("pointerup",se),document.addEventListener("pointercancel",se)},[w,be]),fe=n.useCallback(()=>{if(w||d.stops.length>=Z)return;const F=d.stops.slice().sort((je,we)=>je.position-we.position);let J=0,U=F[0];for(let je=0;je<F.length-1;je++){const we=F[je+1].position-F[je].position;we>J&&(J=we,U=F[je])}const se=Math.round(U.position+J/2),ue="#"+Math.floor(Math.random()*16777215).toString(16).padStart(6,"0");P({...d,stops:[...d.stops,{color:ue,position:se}]})},[w,d,Z,P]),oe=n.useCallback(F=>{if(w||d.stops.length<=2)return;const J=d.stops.filter((U,se)=>se!==F);P({...d,stops:J}),V>=J.length&&B(J.length-1)},[w,d,V,P]),he=n.useCallback(()=>{if(w)return;const F=2+Math.floor(Math.random()*3);P(mi(F))},[w,P]),ie=n.useCallback(()=>{if(w||!b.trim())return;const F=gn(b);F&&P(F)},[w,b,P]),ce=n.useCallback(F=>{if(w||!D.current||d.stops.length>=Z)return;const J=F.target;if(ve.current||J.closest(".nice-gradient__stop-marker")){ve.current=!1;return}const U=D.current.getBoundingClientRect(),se=Math.round((F.clientX-U.left)/U.width*100),ue="#"+Math.floor(Math.random()*16777215).toString(16).padStart(6,"0"),je=[...d.stops,{color:ue,position:se}];P({...d,stops:je}),B(je.length-1)},[w,d,Z,P]),ge=n.useMemo(()=>d.stops.slice().sort((F,J)=>F.position-J.position),[d.stops]),Y=n.useMemo(()=>`linear-gradient(90deg, ${ge.map(F=>`${F.color} ${F.position}%`).join(", ")})`,[ge]);if(f)return null;const O=e.jsxs("div",{className:"nice-gradient__tab",children:[E&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"nice-gradient__type-row",children:[["linear","radial","conic"].map(F=>e.jsx("button",{type:"button",className:`nice-gradient__type-btn ${d.type===F?"nice-gradient__type-btn--active":""}`,onClick:()=>z(F),disabled:w,children:F.charAt(0).toUpperCase()+F.slice(1)},F)),e.jsxs("label",{className:"nice-gradient__repeat-label",children:[e.jsx("input",{type:"checkbox",checked:d.repeating??!1,onChange:F=>me(F.target.checked),disabled:w}),"Repeating"]})]}),e.jsxs("div",{className:"nice-gradient__controls",children:[d.type==="linear"&&e.jsxs("div",{className:"nice-gradient__control-group",children:[e.jsxs("label",{children:["Angle: ",d.angle,"°"]}),e.jsx("input",{type:"range",min:0,max:360,value:d.angle,onChange:F=>re(Number(F.target.value)),disabled:w,className:"nice-gradient__slider"}),e.jsx("div",{className:"nice-gradient__angle-presets",children:[0,45,90,135,180,225,270,315].map(F=>e.jsx("button",{type:"button",className:`nice-gradient__angle-btn ${d.angle===F?"nice-gradient__angle-btn--active":""}`,onClick:()=>re(F),disabled:w,title:`${F}°`,children:e.jsx("span",{style:{transform:`rotate(${F}deg)`,display:"inline-flex"},children:e.jsx(x.oa,{name:"arrow-right",size:14})})},F))})]}),d.type==="radial"&&e.jsxs("div",{className:"nice-gradient__control-group",children:[e.jsx("label",{children:"Shape:"}),e.jsx("div",{className:"nice-gradient__shape-btns",children:["circle","ellipse"].map(F=>e.jsx("button",{type:"button",className:`nice-gradient__shape-btn ${(d.shape||"ellipse")===F?"nice-gradient__shape-btn--active":""}`,onClick:()=>de(F),disabled:w,children:F},F))})]}),(d.type==="radial"||d.type==="conic")&&e.jsxs("div",{className:"nice-gradient__control-group",children:[e.jsxs("label",{children:["Center: ",d.positionX??50,"%, ",d.positionY??50,"%"]}),e.jsxs("div",{className:"nice-gradient__center-inputs",children:[e.jsx("input",{type:"range",min:0,max:100,value:d.positionX??50,onChange:F=>P({...d,positionX:Number(F.target.value)}),disabled:w,className:"nice-gradient__slider"}),e.jsx("input",{type:"range",min:0,max:100,value:d.positionY??50,onChange:F=>P({...d,positionY:Number(F.target.value)}),disabled:w,className:"nice-gradient__slider"})]})]}),d.type==="conic"&&e.jsxs("div",{className:"nice-gradient__control-group",children:[e.jsxs("label",{children:["Start angle: ",d.angle,"°"]}),e.jsx("input",{type:"range",min:0,max:360,value:d.angle,onChange:F=>re(Number(F.target.value)),disabled:w,className:"nice-gradient__slider"})]})]}),e.jsxs("div",{className:"nice-gradient__bar-container",children:[e.jsx("div",{ref:D,className:"nice-gradient__bar",style:{background:Y},onClick:ce,children:d.stops.map((F,J)=>e.jsx("div",{className:`nice-gradient__stop-marker ${V===J?"nice-gradient__stop-marker--active":""}`,style:{left:`${F.position}%`},onPointerDown:U=>_e(U,J),onClick:U=>{U.stopPropagation(),B(J),ve.current=!1},title:`${F.color} @ ${F.position}%`,children:e.jsx("div",{className:"nice-gradient__stop-dot",style:{background:F.color}})},J))}),e.jsx("button",{type:"button",className:"nice-gradient__add-stop",onClick:fe,disabled:w||d.stops.length>=Z,title:"Add stop","aria-label":"Add stop",children:e.jsx(x.oa,{name:"plus",size:14})})]}),e.jsx("div",{className:"nice-gradient__stop-editor",children:e.jsx("div",{className:"nice-gradient__stop-list",children:ge.map((F,J)=>{const U=d.stops.indexOf(F);return e.jsxs("div",{className:`nice-gradient__stop-row ${V===U?"nice-gradient__stop-row--active":""}`,onClick:()=>B(U),children:[e.jsx("input",{type:"color",value:F.color,onChange:se=>be(U,{color:se.target.value}),disabled:w,className:"nice-gradient__stop-color"}),e.jsx("input",{type:"text",value:F.color.toUpperCase(),maxLength:7,onChange:se=>be(U,{color:se.target.value}),disabled:w,className:"nice-gradient__stop-hex"}),e.jsx("input",{type:"number",min:0,max:100,value:F.position,onChange:se=>be(U,{position:Number(se.target.value)}),disabled:w,className:"nice-gradient__stop-pos"}),e.jsx("span",{className:"nice-gradient__stop-pct",children:"%"}),d.stops.length>2&&e.jsx("button",{type:"button",className:"nice-gradient__stop-del",onClick:()=>oe(U),disabled:w,"aria-label":"Remove stop",children:e.jsx(x.oa,{name:"close",size:14})})]},U)})})})]}),C&&e.jsxs("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm nice-gradient__random-btn",onClick:he,disabled:w,title:"Random gradient","aria-label":"Random gradient",children:[e.jsx(x.oa,{name:"shuffle",size:14})," Random Gradient"]})]}),G=e.jsx("div",{className:"nice-gradient__tab",children:e.jsx("div",{className:"nice-gradient__preset-grid",children:fn.map((F,J)=>e.jsxs("button",{type:"button",className:"nice-gradient__preset-card",onClick:()=>{w||P(F.value)},disabled:w,title:F.name,children:[e.jsx("div",{className:"nice-gradient__preset-preview",style:{background:Nt(F.value)}}),e.jsx("span",{className:"nice-gradient__preset-name",children:F.name})]},J))})}),xe=e.jsxs("div",{className:"nice-gradient__tab",children:[e.jsxs("div",{className:"nice-gradient__css-output",children:[e.jsx("code",{children:`background: ${S};`}),e.jsx("button",{type:"button",className:"nice-gradient__copy-btn",onClick:()=>navigator.clipboard?.writeText(`background: ${S};`),title:"Copy CSS","aria-label":"Copy CSS",children:e.jsx(x.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:b,onChange:F=>s(F.target.value),disabled:w}),e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm",onClick:ie,disabled:w,children:"Import"})]})]}),le=[{id:"editor",label:"Editor",content:O}];return _&&le.push({id:"presets",label:"Presets",content:G}),y&&le.push({id:"css",label:"CSS",content:xe}),e.jsxs("div",{ref:j,id:q,className:`nice-field nice-gradient-field ${w?"nice-gradient--disabled":""} ${R==="left"?"nice-field--label-left":""} ${ne?"nice-field--loading":""} ${ee?"nice-field--error":""} ${te==="right"?"nice-field--error-right":""} ${i||""}`,style:a,children:[K&&e.jsx("label",{htmlFor:q,className:"nice-field__label",children:K}),e.jsxs("div",{className:"nice-field__control",children:[e.jsx("button",{ref:I,type:"button",className:"nice-gradient__swatch",style:{background:S},"aria-haspopup":"dialog","aria-expanded":M,"aria-readonly":k||void 0,"aria-label":"Open gradient editor",disabled:w,onClick:()=>{!w&&!k&&u(F=>!F)}}),ne&&e.jsx("span",{className:"nice-field__spinner",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})}),te==="right"&&typeof ee=="string"&&ee&&e.jsx("div",{className:"nice-field__error",role:"alert",children:ee}),M&&c&&T&&Ze.createPortal(e.jsx("div",{ref:H,className:`nice-gradient__popup${g?` ${g}`:""}`,"data-theme":g==="nice-dark"?"dark":g==="nice-light"?"light":void 0,role:"dialog","aria-label":"Gradient editor",style:{position:"fixed",left:c.left,top:c.top,width:A!=null?typeof A=="number"?`${A}px`:A: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:S}}),e.jsx("button",{type:"button",className:"nice-gradient__confirm",onClick:()=>u(!1),"aria-label":p("controls.confirm","Confirm"),title:p("controls.confirm","Confirm"),children:e.jsx(x.oa,{name:"check",size:18})})]}),e.jsx(Fe.NiceTabs,{tabs:le,variant:"enclosed",size:"sm"})]})}),T)]}),te!=="right"&&typeof ee=="string"&&ee&&e.jsx("div",{className:"nice-field__error",role:"alert",children:ee})]})});yn.displayName="NiceGradientPicker";const ui=[{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"}],pi=[{style:"professional",label:"Professional"},{style:"casual",label:"Casual"},{style:"formal",label:"Formal"},{style:"concise",label:"Concise"}],hi=n.forwardRef(function(i,a){const{enableAI:o=!0,aiModel:r,enableImprove:h=!0,enableTranslate:y=!0,enableGenerate:_=!0,toolbar:E,languages:C=ui,textStyles:Z=pi,onImprove:K,onTranslate:R,onGenerate:w,showAIToolbar:Q=!0,value:ne,onChange:ee,...te}=i,A=n.useRef(null),[j,L]=n.useState(!1),[f,k]=n.useState(!1),[q,p]=n.useState(!1),[d,S]=n.useState(""),[V,B]=n.useState(""),[b,s]=n.useState("professional"),[D,M]=n.useState(""),[u,c]=n.useState(C[0]?.code||"en"),[l,g]=n.useState(""),[$,v]=n.useState(""),{t:T}=x.Gt(),I=x.he(),{improveText:H,translate:N,generateHtml:P,isLoading:z}=x.Cd(),re=o&&I.isConfigured,me=n.useCallback(()=>{const ie=window.getSelection();return ie&&ie.toString().trim()?ie.toString():""},[]),de=n.useCallback(ie=>{const ce=window.getSelection();if(ce&&ce.rangeCount>0){const ge=ce.getRangeAt(0);ge.deleteContents();const Y=document.createElement("div");Y.innerHTML=ie;const O=document.createDocumentFragment();for(;Y.firstChild;)O.appendChild(Y.firstChild);if(ge.insertNode(O),A.current){const G=A.current.innerHTML;ee(G)}}},[ee]),be=n.useCallback(async(ie="professional")=>{if(!re||!h)return"";const ce=me();if(!ce)return"";S(ce),s(ie),L(!0),B("");try{const ge=await H(ce,ie);return B(ge),K?.(ce,ge,ie),ge}catch{return B(T("htmlEditorAI.improveFailed","Failed to improve text")),""}},[re,h,me,H,K,T]),ve=n.useCallback(async ie=>{if(!re||!y)return"";const ce=me();if(!ce)return"";S(ce),c(ie),k(!0),M("");try{const ge=C.find(O=>O.code===ie)?.label||ie,Y=await N(ce,ge);return M(Y),R?.(ce,Y,ie),Y}catch{return M(T("htmlEditorAI.translateFailed","Failed to translate text")),""}},[re,y,me,N,C,R,T]),_e=n.useCallback(async ie=>{if(!re||!_||!ie.trim())return"";g(ie),v("");try{const ce=await P(ie);return v(ce),w?.(ie,ce),ce}catch{return v(T("htmlEditorAI.generateFailed","Failed to generate HTML")),""}},[re,_,P,w,T]),fe=n.useCallback(()=>{V&&de(V),L(!1),B("")},[V,de]),oe=n.useCallback(()=>{D&&de(D),k(!1),M("")},[D,de]),he=n.useCallback(()=>{if($&&A.current){document.execCommand("insertHTML",!1,$);const ie=A.current.innerHTML;ee(ie)}p(!1),v(""),g("")},[$,ee]);return n.useImperativeHandle(a,()=>({getEditor:()=>A.current,focus:()=>A.current?.focus(),getValue:()=>A.current?.innerHTML||"",setValue:ie=>{A.current&&(A.current.innerHTML=ie,ee(ie))},getSelection:me,insertHtml:ie=>{document.execCommand("insertHTML",!1,ie),A.current&&ee(A.current.innerHTML)},improveSelection:be,translateSelection:ve,generateHtml:_e})),n.useCallback(ie=>{A.current=ie},[]),e.jsxs("div",{className:"nice-html-editor-ai","data-testid":i["data-testid"],children:[Q&&re&&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:T("htmlEditorAI.processing","Processing...")})]}),e.jsxs("div",{className:"nice-html-editor-ai__toolbar-right",children:[h&&e.jsxs("div",{className:"nice-html-editor-ai__dropdown",children:[e.jsxs("button",{type:"button",className:"nice-html-editor-ai__btn",onClick:()=>be(),disabled:z,title:T("htmlEditorAI.improveText","Improve selected text"),children:[e.jsx(x.oa,{name:"star",size:14})," ",T("htmlEditorAI.improve","Improve")]}),e.jsx("div",{className:"nice-html-editor-ai__dropdown-menu",children:Z.map(({style:ie,label:ce})=>e.jsx("button",{type:"button",className:"nice-html-editor-ai__dropdown-item",onClick:()=>be(ie),children:ce},ie))})]}),y&&e.jsxs("div",{className:"nice-html-editor-ai__dropdown",children:[e.jsxs("button",{type:"button",className:"nice-html-editor-ai__btn",disabled:z,title:T("htmlEditorAI.translateText","Translate selected text"),children:[e.jsx(x.oa,{name:"globe",size:14})," ",T("htmlEditorAI.translate","Translate")]}),e.jsx("div",{className:"nice-html-editor-ai__dropdown-menu nice-html-editor-ai__dropdown-menu--languages",children:C.map(({code:ie,label:ce})=>e.jsx("button",{type:"button",className:"nice-html-editor-ai__dropdown-item",onClick:()=>ve(ie),children:ce},ie))})]}),_&&e.jsxs("button",{type:"button",className:"nice-html-editor-ai__btn",onClick:()=>p(!0),disabled:z,title:T("htmlEditorAI.generateHtml","Generate HTML from description"),children:[e.jsx(x.oa,{name:"zap",size:14})," ",T("htmlEditorAI.generate","Generate")]})]})]}),e.jsx("div",{className:"nice-html-editor-ai__editor-wrapper",children:e.jsx(Kn.NiceHtmlEditor,{value:ne,onChange:ee,toolbar:E,...te})}),j&&e.jsxs("div",{className:"nice-html-editor-ai__panel",children:[e.jsxs("div",{className:"nice-html-editor-ai__panel-header",children:[e.jsxs("h4",{children:[e.jsx(x.oa,{name:"star",size:16})," ",T("htmlEditorAI.improveText","Improve Text")]}),e.jsx("div",{className:"nice-html-editor-ai__style-selector",children:Z.map(({style:ie,label:ce})=>e.jsx("button",{type:"button",className:`nice-html-editor-ai__style-btn ${b===ie?"nice-html-editor-ai__style-btn--active":""}`,onClick:()=>{s(ie),be(ie)},children:ce},ie))}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__close","aria-label":T("htmlEditorAI.close","Close"),onClick:()=>L(!1),children:e.jsx(x.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:T("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:T("htmlEditorAI.original","Original")}),e.jsx("div",{className:"nice-html-editor-ai__text-content",children:d})]}),e.jsxs("div",{className:"nice-html-editor-ai__text-block nice-html-editor-ai__text-block--improved",children:[e.jsx("h5",{children:T("htmlEditorAI.improved","Improved")}),e.jsx("div",{className:"nice-html-editor-ai__text-content",children:V})]})]})}),e.jsxs("div",{className:"nice-html-editor-ai__panel-footer",children:[e.jsxs("button",{type:"button",className:"nice-html-editor-ai__apply",onClick:fe,disabled:!V||z,children:[e.jsx(x.oa,{name:"check",size:14})," ",T("htmlEditorAI.apply","Apply")]}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__cancel",onClick:()=>{L(!1),B("")},children:T("htmlEditorAI.cancel","Cancel")})]})]}),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(x.oa,{name:"globe",size:16})," ",T("htmlEditorAI.translateText","Translate Text")]}),e.jsx("div",{className:"nice-html-editor-ai__language-selector",children:e.jsx("select",{value:u,onChange:ie=>{c(ie.target.value),ve(ie.target.value)},className:"nice-html-editor-ai__language-select",children:C.map(({code:ie,label:ce})=>e.jsx("option",{value:ie,children:ce},ie))})}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__close","aria-label":T("htmlEditorAI.close","Close"),onClick:()=>k(!1),children:e.jsx(x.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:T("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:T("htmlEditorAI.original","Original")}),e.jsx("div",{className:"nice-html-editor-ai__text-content",children:d})]}),e.jsxs("div",{className:"nice-html-editor-ai__text-block nice-html-editor-ai__text-block--translated",children:[e.jsx("h5",{children:C.find(ie=>ie.code===u)?.label||u}),e.jsx("div",{className:"nice-html-editor-ai__text-content",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:oe,disabled:!D||z,children:[e.jsx(x.oa,{name:"check",size:14})," ",T("htmlEditorAI.apply","Apply")]}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__cancel",onClick:()=>{k(!1),M("")},children:T("htmlEditorAI.cancel","Cancel")})]})]}),q&&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(x.oa,{name:"zap",size:16})," ",T("htmlEditorAI.generateHtml","Generate HTML")]}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__close","aria-label":T("htmlEditorAI.close","Close"),onClick:()=>{p(!1),v(""),g("")},children:e.jsx(x.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:T("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:l,onChange:ie=>g(ie.target.value),className:"nice-html-editor-ai__generate-textarea",rows:3}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__generate-btn",onClick:()=>_e(l),disabled:z||!l.trim(),children:z?T("htmlEditorAI.generating","Generating..."):T("htmlEditorAI.generate","Generate")})]}),$&&e.jsxs("div",{className:"nice-html-editor-ai__generate-result",children:[e.jsx("h5",{children:T("htmlEditorAI.preview","Preview")}),e.jsx("div",{className:"nice-html-editor-ai__preview",dangerouslySetInnerHTML:{__html:$}}),e.jsx("h5",{children:T("htmlEditorAI.htmlCode","HTML Code")}),e.jsx("pre",{className:"nice-html-editor-ai__code",children:$})]})]}),e.jsxs("div",{className:"nice-html-editor-ai__panel-footer",children:[e.jsxs("button",{type:"button",className:"nice-html-editor-ai__apply",onClick:he,disabled:!$||z,children:[e.jsx(x.oa,{name:"check",size:14})," ",T("htmlEditorAI.insert","Insert")]}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__cancel",onClick:()=>{p(!1),v(""),g("")},children:T("htmlEditorAI.cancel","Cancel")})]})]})]})}),gi=[{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 fi(t){let i=t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">");return i=i.replace(/```(\w*)\n([\s\S]*?)```/g,(a,o,r)=>`<pre><code class="language-${o}">${r.trim()}</code></pre>`),i=i.replace(/^(\|.+\|)\n(\|[-| :]+\|)\n((?:\|.+\|\n?)+)/gm,(a,o,r,h)=>{const y=o.split("|").filter(E=>E.trim()).map(E=>`<th>${E.trim()}</th>`).join(""),_=h.trim().split(`
|
|
2
|
+
`).map(E=>`<tr>${E.split("|").filter(Z=>Z.trim()).map(Z=>`<td>${Z.trim()}</td>`).join("")}</tr>`).join("");return`<table><thead><tr>${y}</tr></thead><tbody>${_}</tbody></table>`}),i=i.replace(/^#### (.+)$/gm,"<h4>$1</h4>"),i=i.replace(/^### (.+)$/gm,"<h3>$1</h3>"),i=i.replace(/^## (.+)$/gm,"<h2>$1</h2>"),i=i.replace(/^# (.+)$/gm,"<h1>$1</h1>"),i=i.replace(/^> (.+)$/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 yi=[{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:`---
|
|
3
|
+
`,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 |
|
|
4
|
+
| --- | --- | --- |
|
|
5
|
+
| c1 | c2 | c3 |
|
|
6
|
+
`,tip:"Table",group:"insert"},{key:"codeblock",label:"```",md:"```\n",tip:"Code block",group:"insert"}],xi=["format","heading","list","block","insert"],xn=n.forwardRef(({value:t="",onChange:i,preview:a="side",placeholder:o,disabled:r,readOnly:h,size:y="md",editorSize:_="standard",toolbar:E=!0,minHeight:C=200,showWordCount:Z=!1,showLineNumbers:K=!1,onExportHtml:R,onImageUpload:w,tutorial:Q,className:ne,style:ee,id:te},A)=>{const j=x.bc(te),[L,f]=n.useState("edit"),[k,q]=n.useState(!1),p=n.useRef(null),d=n.useMemo(()=>fi(t),[t]),S=n.useMemo(()=>{const u=t.trim()?t.trim().split(/\s+/).length:0,c=t.length,l=t.split(`
|
|
7
|
+
`).length;return{words:u,chars:c,lines:l}},[t]),V=n.useCallback(u=>{const c=p.current;if(!c)return;const l=c.selectionStart,g=c.selectionEnd,$=t.slice(l,g);let v,T;u==="[](url)"?(v=t.slice(0,l)+`[${$||"text"}](url)`+t.slice(g),T=l+1+($||"text").length+2):u===""?(v=t.slice(0,l)+``+t.slice(g),T=l+2+($||"alt").length+2):u.endsWith(`
|
|
8
|
+
`)||u.endsWith(" ")?(v=t.slice(0,l)+u+$+t.slice(g),T=l+u.length+$.length):(v=t.slice(0,l)+u+$+u+t.slice(g),T=l+u.length+$.length+u.length),i?.(v),requestAnimationFrame(()=>{c.focus(),c.setSelectionRange(T,T)})},[t,i]),B=n.useCallback(u=>{if((u.ctrlKey||u.metaKey)&&(u.key==="b"?(u.preventDefault(),V("**")):u.key==="i"?(u.preventDefault(),V("*")):u.key==="k"&&(u.preventDefault(),V("[](url)"))),u.key==="Tab"){u.preventDefault();const c=u.currentTarget,l=c.selectionStart,g=c.selectionEnd,$=" ";if(u.shiftKey){const I=t.slice(0,l).lastIndexOf(`
|
|
9
|
+
`)+1;if(t.slice(I,I+$.length)===$){const H=t.slice(0,I)+t.slice(I+$.length);i?.(H),requestAnimationFrame(()=>{c.selectionStart=c.selectionEnd=l-$.length})}}else{const v=t.slice(0,l)+$+t.slice(g);i?.(v),requestAnimationFrame(()=>{c.selectionStart=c.selectionEnd=l+$.length})}}},[t,i,V]),b=n.useCallback(async u=>{if(!w)return;const c=Array.from(u.dataTransfer.files).filter(l=>l.type.startsWith("image/"));if(c.length!==0){u.preventDefault();for(const l of c){const g=await w(l),$=p.current;if(!$)continue;const v=$.selectionStart,T=`
|
|
10
|
+
`,I=t.slice(0,v)+T+t.slice(v);i?.(I)}}},[t,i,w]),s=a!=="tab"||L==="edit",D=a==="side"||a==="tab"&&L==="preview"||a===!0,M=`nice-md-editor nice-md-editor--${y} nice-editor--${_} nice-md-editor--preview-${a}${k?" nice-md-editor--fullscreen":""} ${ne||""}`;return e.jsxs("div",{ref:A,id:j,className:M,style:{position:"relative",...ee},children:[e.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:20},children:e.jsx(x.Ql,{steps:x.Yl(Q,gi)})}),E&&e.jsxs("div",{className:"nice-md-editor__toolbar",children:[xi.map((u,c)=>e.jsxs(n.Fragment,{children:[c>0&&e.jsx("span",{className:"nice-md-editor__sep"}),yi.filter(l=>l.group===u).map(l=>e.jsx("button",{type:"button",className:"nice-md-editor__btn",title:l.shortcut?`${l.tip} (${l.shortcut})`:l.tip,disabled:r||h,onClick:()=>V(l.md),"aria-label":l.tip,children:l.icon?e.jsx(x.oa,{name:l.icon,size:16}):l.label},l.key))]},u)),e.jsx("span",{className:"nice-md-editor__sep"}),e.jsx("button",{type:"button",className:"nice-md-editor__btn",title:"Fullscreen","aria-label":"Fullscreen",onClick:()=>q(!k),children:e.jsx(x.oa,{name:k?"collapse":"expand",size:16})}),R&&e.jsx("button",{type:"button",className:"nice-md-editor__btn",title:"Export HTML","aria-label":"Export HTML",onClick:()=>R(d),children:e.jsx(x.oa,{name:"external-link",size:16})}),a==="tab"&&e.jsxs("span",{className:"nice-md-editor__tabs",children:[e.jsx("button",{type:"button",className:`nice-md-editor__tab${L==="edit"?" nice-md-editor__tab--active":""}`,onClick:()=>f("edit"),children:"Edit"}),e.jsx("button",{type:"button",className:`nice-md-editor__tab${L==="preview"?" nice-md-editor__tab--active":""}`,onClick:()=>f("preview"),children:"Preview"})]})]}),e.jsxs("div",{className:"nice-md-editor__body",style:{minHeight:C},children:[s&&e.jsxs("div",{className:"nice-md-editor__editor-wrap",children:[K&&e.jsx("div",{className:"nice-md-editor__line-numbers",children:Array.from({length:S.lines},(u,c)=>e.jsx("div",{className:"nice-md-editor__line-no",children:c+1},c))}),e.jsx("textarea",{ref:p,className:"nice-md-editor__textarea",value:t,onChange:u=>i?.(u.target.value),onKeyDown:B,onDrop:b,placeholder:o,disabled:r,readOnly:h,style:{minHeight:C}})]}),D&&e.jsx("div",{className:"nice-md-editor__preview",dangerouslySetInnerHTML:{__html:x.lc(d)},style:{minHeight:C}})]}),Z&&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"]})]})]})});xn.displayName="NiceMarkdownEditor";const ji=[{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 bi=0;function $t(){return`blk-${++bi}-${Date.now().toString(36)}`}function Bt(t=""){return{id:$t(),type:"paragraph",content:t}}function vi(t,i=""){const a={id:$t(),type:t,content:i};return t==="heading"&&(a.level=2),t==="list"&&(a.listType="unordered"),t==="callout"&&(a.icon="??"),t==="toggle"&&(a.open=!0),a}const _i=[{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 ki(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(";"),a=i?` style="${i}"`:"",o=(r,h)=>{let y=h;return t.bold&&(y=`<strong>${y}</strong>`),t.italic&&(y=`<em>${y}</em>`),t.underline&&(y=`<u>${y}</u>`),t.strikethrough&&(y=`<s>${y}</s>`),`<${r}${a}>${y}</${r}>`};switch(t.type){case"heading":return o(`h${t.level??2}`,t.content);case"paragraph":return o("p",t.content||" ");case"list":{const r=t.listType==="ordered"?"ol":"ul",h=t.content.split(`
|
|
11
|
+
`).map((y,_)=>t.listType==="checklist"?`<li><input type="checkbox" ${t.checked?.[_]??!1?"checked":""} disabled />${y}</li>`:`<li>${y}</li>`).join("");return`<${r}${a}>${h}</${r}>`}case"image":return`<figure${a}><img src="${t.src??""}" alt="${t.alt??""}" /></figure>`;case"video":return`<figure${a}><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 o("blockquote",t.content);case"callout":return`<div class="nice-doc-callout"${a}><span>${t.icon??"??"}</span><div>${t.content}</div></div>`;case"toggle":return`<details${a}><summary>${t.content.split(`
|
|
12
|
+
`)[0]}</summary>${t.content.split(`
|
|
13
|
+
`).slice(1).join("<br>")}</details>`;case"table":return`<table${a}>${t.content}</table>`;case"embed":return`<iframe src="${t.src??""}" style="width:100%;border:none;min-height:300px"></iframe>`;default:return o("p",t.content)}}function wi(t){let i=0,a=0;for(const o of t){const r=o.content??"";i+=r.length;const h=r.trim().split(/\s+/).filter(Boolean);a+=h.length}return{words:a,chars:i,readingTime:Math.max(1,Math.ceil(a/200))}}const jn=n.forwardRef(({blocks:t,onChange:i,readOnly:a=!1,showToolbar:o=!0,size:r="md",editorSize:h="standard",placeholder:y,onExport:_,onImageUpload:E,maxUndo:C=50,slashCommands:Z=!0,showWordCount:K=!1,showToc:R=!1,showFindReplace:w=!0,tutorial:Q,className:ne,style:ee,id:te,...A},j)=>{const L=x.bc(te),{t:f}=x.Gt(),[k,q]=n.useState(()=>t??[Bt()]),p=t??k,[d,S]=n.useState(0),V=n.useRef(new Map),B=n.useRef(null),[b,s]=n.useState(!1),[D,M]=n.useState(""),[u,c]=n.useState(""),[l,g]=n.useState([]),[$,v]=n.useState(0),[T,I]=n.useState(!1),H=n.useRef([]),N=n.useRef([]),P=n.useCallback(m=>{H.current.push(m.map(X=>({...X,checked:X.checked?[...X.checked]:void 0}))),H.current.length>C&&H.current.shift(),N.current=[]},[C]),z=n.useCallback(()=>{if(H.current.length===0)return;const m=H.current.pop();N.current.push(p.map(X=>({...X}))),t||q(m),i?.(m)},[p,t,i]),re=n.useCallback(()=>{if(N.current.length===0)return;const m=N.current.pop();H.current.push(p.map(X=>({...X}))),t||q(m),i?.(m)},[p,t,i]),[me,de]=n.useState(!1),[be,ve]=n.useState(""),[_e,fe]=n.useState(0),oe=n.useMemo(()=>{if(!me||!Z)return[];const m=be.toLowerCase();return _i.filter(X=>X.label.toLowerCase().includes(m)||X.keywords.includes(m))},[me,be,Z]),[he,ie]=n.useState(null),[ce,ge]=n.useState(null),Y=n.useCallback(m=>{P(p);const X=m(p);t||q(X),i?.(X)},[p,t,i,P]),O=n.useCallback((m,X)=>{Y(ae=>ae.map((Ce,$e)=>$e===m?{...Ce,...X}:Ce))},[Y]),G=n.useCallback((m,X)=>{const ae=X??Bt();Y(Ce=>{const $e=[...Ce];return $e.splice(m+1,0,ae),$e}),S(m+1)},[Y]),xe=n.useCallback(m=>{const X={...p[m],id:$t()};G(m,X)},[p,G]),le=n.useCallback(m=>{p.length<=1||(Y(X=>X.filter((ae,Ce)=>Ce!==m)),S(Math.max(0,m-1)))},[p.length,Y]),F=n.useCallback((m,X)=>{const ae=m+X;ae<0||ae>=p.length||(Y(Ce=>{const $e=[...Ce];return[$e[m],$e[ae]]=[$e[ae],$e[m]],$e}),S(ae))},[p.length,Y]),J=n.useCallback((m,X)=>{const ae={type:X};X==="heading"&&(ae.level=2),X==="list"&&(ae.listType="unordered"),X==="callout"&&(ae.icon="??"),X==="toggle"&&(ae.open=!0),O(m,ae)},[O]),U=n.useCallback(m=>{const X=vi(m.type);m.type==="list"&&m.label.includes("Numbered")&&(X.listType="ordered"),m.type==="list"&&m.label.includes("Checklist")&&(X.listType="checklist",X.checked=[]),p[d]?.content===""||p[d]?.content==="/"?Y(ae=>ae.map((Ce,$e)=>$e===d?{...X,id:Ce.id}:Ce)):G(d,X),de(!1),ve("")},[p,d,Y,G]),se=n.useCallback((m,X)=>{if(a)return;const ae=p[X];if(!ae?.locked){if((m.ctrlKey||m.metaKey)&&m.key==="z"&&!m.shiftKey){m.preventDefault(),z();return}if((m.ctrlKey||m.metaKey)&&(m.key==="y"||m.key==="z"&&m.shiftKey)){m.preventDefault(),re();return}if((m.ctrlKey||m.metaKey)&&m.key==="d"){m.preventDefault(),xe(X);return}if((m.ctrlKey||m.metaKey)&&m.key==="b"){m.preventDefault(),O(X,{bold:!ae?.bold});return}if((m.ctrlKey||m.metaKey)&&m.key==="i"){m.preventDefault(),O(X,{italic:!ae?.italic});return}if((m.ctrlKey||m.metaKey)&&m.key==="u"){m.preventDefault(),O(X,{underline:!ae?.underline});return}if((m.ctrlKey||m.metaKey)&&m.key==="e"){m.preventDefault(),O(X,{strikethrough:!ae?.strikethrough});return}if(m.key==="Tab"&&!m.shiftKey){m.preventDefault(),O(X,{indent:Math.min((ae?.indent??0)+1,4)});return}if(m.key==="Tab"&&m.shiftKey){m.preventDefault(),O(X,{indent:Math.max((ae?.indent??0)-1,0)});return}if((m.ctrlKey||m.metaKey)&&m.key==="f"&&w){m.preventDefault(),s(Ce=>!Ce);return}if(me&&oe.length>0){if(m.key==="ArrowDown"){m.preventDefault(),fe(Ce=>Math.min(Ce+1,oe.length-1));return}if(m.key==="ArrowUp"){m.preventDefault(),fe(Ce=>Math.max(Ce-1,0));return}if(m.key==="Enter"){m.preventDefault(),U(oe[_e]);return}if(m.key==="Escape"){de(!1);return}}m.key==="Enter"&&!m.shiftKey?(m.preventDefault(),G(X)):m.key==="Backspace"&&p[X].content===""&&p.length>1?(m.preventDefault(),le(X)):m.key==="ArrowUp"&&m.altKey?(m.preventDefault(),F(X,-1)):m.key==="ArrowDown"&&m.altKey&&(m.preventDefault(),F(X,1))}},[a,p,G,le,F,z,re,xe,O,me,oe,_e,U,w]),ue=n.useCallback((m,X)=>{const ae=m.target.textContent??"";Z&&ae.startsWith("/")?(de(!0),ve(ae.slice(1)),fe(0)):me&&de(!1),P(p);const Ce=p.map(($e,Ue)=>Ue===X?{...$e,content:ae}:$e);t||q(Ce),i?.(Ce)},[p,t,i,P,Z,me]),je=n.useCallback((m,X)=>{ie(X),m.dataTransfer.effectAllowed="move"},[]),we=n.useCallback((m,X)=>{m.preventDefault(),m.dataTransfer.dropEffect="move",ge(X)},[]),Re=n.useCallback((m,X)=>{if(m.preventDefault(),he===null||he===X){ie(null),ge(null);return}Y(ae=>{const Ce=[...ae],[$e]=Ce.splice(he,1);return Ce.splice(X>he?X-1:X,0,$e),Ce}),S(X>he?X-1:X),ie(null),ge(null)},[he,Y]);n.useEffect(()=>{if(!b||!D){g([]);return}const m=D.toLowerCase(),X=[];p.forEach((ae,Ce)=>{const $e=(ae.content??"").toLowerCase();let Ue=0;for(;Ue<$e.length;){const Ve=$e.indexOf(m,Ue);if(Ve===-1)break;X.push({blockIdx:Ce,start:Ve,end:Ve+m.length}),Ue=Ve+1}}),g(X),v(0)},[D,b,p]);const Te=n.useCallback(()=>{if(l.length===0)return;const m=($+1)%l.length;v(m),S(l[m].blockIdx)},[l,$]),Oe=n.useCallback(()=>{if(l.length===0)return;const m=($-1+l.length)%l.length;v(m),S(l[m].blockIdx)},[l,$]),qe=n.useCallback(()=>{if(l.length===0||!D)return;const m=l[$],X=p[m.blockIdx],ae=X.content.slice(0,m.start),Ce=X.content.slice(m.end);O(m.blockIdx,{content:ae+u+Ce})},[l,$,D,u,p,O]),Ye=n.useCallback(()=>{if(!D)return;const m=D;Y(X=>X.map(ae=>({...ae,content:ae.content.split(m).join(u)})))},[D,u,Y]),Ke=n.useMemo(()=>R?p.map((m,X)=>m.type==="heading"?{idx:X,level:m.level??2,text:m.content}:null).filter(Boolean):[],[p,R]),We=n.useCallback(async m=>{const X=m.target.files?.[0];if(X){if(E){const ae=await E(X);O(d,{src:ae})}m.target.value=""}},[E,d,O]);n.useEffect(()=>{const m=p[d];if(m){const X=V.current.get(m.id);X&&X.focus()}},[d,p]);const Ne=n.useCallback(()=>{const m=p.map(ki).join(`
|
|
14
|
+
`);_?.(m)},[p,_]),ze=n.useMemo(()=>K?wi(p):null,[p,K]),[pe,Me]=n.useState(null),Ae=n.useCallback((m,X)=>{a||(m.preventDefault(),Me({x:m.clientX,y:m.clientY,idx:X}))},[a]);return n.useEffect(()=>{if(!pe)return;const m=()=>Me(null);return window.addEventListener("click",m),()=>window.removeEventListener("click",m)},[pe]),e.jsxs("div",{ref:j,id:L,className:`nice-doc-editor nice-doc-editor--${r} nice-editor--${h} ${a?"nice-doc-editor--readonly":""} ${ne??""}`,style:{position:"relative",...ee},role:"application","aria-label":f("docEditor.label","Document Editor"),...A,children:[e.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:20},children:e.jsx(x.Ql,{steps:x.Yl(Q,ji)})}),o&&!a&&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(Se.NiceButton,{size:"sm",variant:"ghost",onClick:z,title:f("docEditor.undo","Undo (Ctrl+Z)"),children:"?"}),e.jsx(Se.NiceButton,{size:"sm",variant:"ghost",onClick:re,title:f("docEditor.redo","Redo (Ctrl+Y)"),children:"?"}),e.jsx("span",{className:"nice-doc-editor__sep"}),e.jsx(Be.NiceSelect,{size:"sm",value:p[d]?.type??"paragraph",onChange:m=>J(d,m),label:"",options:[{value:"paragraph",label:f("docEditor.paragraph","Paragraph")},{value:"heading",label:f("docEditor.heading","Heading")},{value:"list",label:f("docEditor.list","List")},{value:"code",label:f("docEditor.code","Code")},{value:"quote",label:f("docEditor.quote","Quote")},{value:"callout",label:f("docEditor.callout","Callout")},{value:"toggle",label:f("docEditor.toggle","Toggle")},{value:"divider",label:f("docEditor.divider","Divider")},{value:"image",label:f("docEditor.image","Image")},{value:"video",label:f("docEditor.video","Video")},{value:"pageBreak",label:f("docEditor.pageBreak","Page Break")}],style:{minWidth:100}}),p[d]?.type==="heading"&&e.jsx(Be.NiceSelect,{size:"sm",value:String(p[d]?.level??2),onChange:m=>O(d,{level:Number(m)}),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}}),p[d]?.type==="list"&&e.jsx(Be.NiceSelect,{size:"sm",value:p[d]?.listType??"unordered",onChange:m=>O(d,{listType:m}),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(Se.NiceButton,{size:"sm",variant:p[d]?.bold?"primary":"ghost",onClick:()=>O(d,{bold:!p[d]?.bold}),title:f("docEditor.bold","Bold (Ctrl+B)"),children:e.jsx("strong",{children:"B"})}),e.jsx(Se.NiceButton,{size:"sm",variant:p[d]?.italic?"primary":"ghost",onClick:()=>O(d,{italic:!p[d]?.italic}),title:f("docEditor.italic","Italic (Ctrl+I)"),children:e.jsx("em",{children:"I"})}),e.jsx(Se.NiceButton,{size:"sm",variant:p[d]?.underline?"primary":"ghost",onClick:()=>O(d,{underline:!p[d]?.underline}),title:f("docEditor.underline","Underline (Ctrl+U)"),children:e.jsx("u",{children:"U"})}),e.jsx(Se.NiceButton,{size:"sm",variant:p[d]?.strikethrough?"primary":"ghost",onClick:()=>O(d,{strikethrough:!p[d]?.strikethrough}),title:f("docEditor.strikethrough","Strikethrough (Ctrl+E)"),children:e.jsx("s",{children:"S"})}),e.jsx("span",{className:"nice-doc-editor__sep"}),e.jsx(Se.NiceButton,{size:"sm",variant:p[d]?.align==="left"?"primary":"ghost",onClick:()=>O(d,{align:"left"}),title:f("docEditor.alignLeft","Left"),children:"?"}),e.jsx(Se.NiceButton,{size:"sm",variant:p[d]?.align==="center"?"primary":"ghost",onClick:()=>O(d,{align:"center"}),title:f("docEditor.alignCenter","Center"),children:"?"}),e.jsx(Se.NiceButton,{size:"sm",variant:p[d]?.align==="right"?"primary":"ghost",onClick:()=>O(d,{align:"right"}),title:f("docEditor.alignRight","Right"),children:"?"}),e.jsx("span",{className:"nice-doc-editor__sep"}),e.jsx(Se.NiceButton,{size:"sm",variant:"ghost",onClick:()=>O(d,{indent:Math.min((p[d]?.indent??0)+1,4)}),title:f("docEditor.indent","Indent (Tab)"),children:"??"}),e.jsx(Se.NiceButton,{size:"sm",variant:"ghost",onClick:()=>O(d,{indent:Math.max((p[d]?.indent??0)-1,0)}),title:f("docEditor.outdent","Outdent (Shift+Tab)"),children:"??"}),e.jsx("span",{className:"nice-doc-editor__sep"}),e.jsx(Se.NiceColorPicker,{size:"sm",label:"",value:p[d]?.color??"var(--nice-text-primary, #000000)",onChange:m=>O(d,{color:m}),title:"Text color"}),e.jsx(Se.NiceColorPicker,{size:"sm",label:"",value:p[d]?.bgColor??"var(--nice-bg-primary, #ffffff)",onChange:m=>O(d,{bgColor:m}),title:"Block background"}),e.jsx("span",{className:"nice-doc-editor__sep"}),e.jsx(Se.NiceButton,{size:"sm",variant:p[d]?.locked?"primary":"ghost",onClick:()=>O(d,{locked:!p[d]?.locked}),title:f("docEditor.lock","Lock/Unlock block"),children:"??"}),e.jsx(Se.NiceButton,{size:"sm",variant:"ghost",onClick:()=>xe(d),title:f("docEditor.duplicate","Duplicate (Ctrl+D)"),children:"?"}),e.jsx(Se.NiceButton,{size:"sm",variant:"ghost",onClick:()=>le(d),title:f("docEditor.delete","Delete block"),children:"??"}),e.jsx(Se.NiceButton,{size:"sm",variant:"ghost",onClick:()=>G(d),title:f("docEditor.addBlock","Add block"),children:"+"}),w&&e.jsx(Se.NiceButton,{size:"sm",variant:b?"primary":"ghost",onClick:()=>s(m=>!m),title:f("docEditor.find","Find & Replace (Ctrl+F)"),children:"??"}),e.jsx(Se.NiceButton,{size:"sm",variant:"ghost",onClick:()=>I(m=>!m),title:f("docEditor.shortcuts","Keyboard shortcuts"),children:"?"}),_&&e.jsx(Se.NiceButton,{size:"sm",variant:"ghost",onClick:Ne,children:f("docEditor.export","Export HTML")})]}),e.jsx("input",{ref:B,type:"file",accept:"image/*,video/*",style:{display:"none"},onChange:We}),b&&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(--nice-border-color, #ddd)"},children:[e.jsx(Fe.NiceTextInput,{size:"sm",placeholder:f("docEditor.findPlaceholder","Find..."),value:D,onChange:M,style:{flex:1,maxWidth:200}}),e.jsx(Fe.NiceTextInput,{size:"sm",placeholder:f("docEditor.replacePlaceholder","Replace..."),value:u,onChange:c,style:{flex:1,maxWidth:200}}),e.jsx(Se.NiceButton,{size:"sm",variant:"ghost",onClick:Oe,title:f("docEditor.findPrev","Previous"),children:"?"}),e.jsx(Se.NiceButton,{size:"sm",variant:"ghost",onClick:Te,title:f("docEditor.findNext","Next"),children:"?"}),e.jsx(Se.NiceButton,{size:"sm",variant:"ghost",onClick:qe,title:f("docEditor.replaceOne","Replace"),disabled:a,children:f("docEditor.replace","Replace")}),e.jsx(Se.NiceButton,{size:"sm",variant:"ghost",onClick:Ye,title:f("docEditor.replaceAll","Replace all"),disabled:a,children:f("docEditor.replaceAllBtn","All")}),e.jsx("span",{style:{fontSize:"0.75em",color:"var(--nice-text-muted, #666)"},children:l.length>0?`${$+1}/${l.length}`:"0/0"}),e.jsx(Se.NiceButton,{size:"sm",variant:"ghost",onClick:()=>s(!1),children:"?"})]}),T&&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:()=>I(!1),children:e.jsxs("div",{style:{background:"var(--nice-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:m=>m.stopPropagation(),children:[e.jsx("h3",{style:{margin:"0 0 12px"},children:f("docEditor.shortcutsTitle","Keyboard Shortcuts")}),e.jsx("table",{style:{width:"100%",fontSize:"0.875em",borderCollapse:"collapse"},children:e.jsx("tbody",{children:[["Ctrl+B",f("docEditor.bold","Bold")],["Ctrl+I",f("docEditor.italic","Italic")],["Ctrl+U",f("docEditor.underline","Underline")],["Ctrl+E",f("docEditor.strikethrough","Strikethrough")],["Ctrl+D",f("docEditor.duplicate","Duplicate block")],["Ctrl+Z",f("docEditor.undo","Undo")],["Ctrl+Y",f("docEditor.redo","Redo")],["Ctrl+F",f("docEditor.find","Find & Replace")],["Enter",f("docEditor.newBlock","New block")],["Backspace",f("docEditor.deleteEmpty","Delete empty block")],["Alt+?",f("docEditor.moveUp","Move block up")],["Alt+?",f("docEditor.moveDown","Move block down")],["Tab",f("docEditor.indent","Indent")],["Shift+Tab",f("docEditor.outdent","Outdent")],["/",f("docEditor.slashCmd","Slash commands")]].map(([m,X])=>e.jsxs("tr",{style:{borderBottom:"1px solid var(--nice-border-color, #eee)"},children:[e.jsx("td",{style:{padding:"4px 8px",fontFamily:"monospace",fontWeight:600},children:m}),e.jsx("td",{style:{padding:"4px 8px"},children:X})]},m))})}),e.jsx("div",{style:{textAlign:"right",marginTop:12},children:e.jsx(Se.NiceButton,{size:"sm",variant:"ghost",onClick:()=>I(!1),children:f("docEditor.close","Close")})})]})}),e.jsxs("div",{style:{display:"flex",gap:0},children:[R&&Ke.length>0&&e.jsxs("nav",{className:"nice-doc-editor__toc",style:{width:200,minWidth:160,borderRight:"1px solid var(--nice-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(--nice-text-muted, #999)"},children:f("docEditor.toc","Contents")}),Ke.map(m=>e.jsx("div",{style:{padding:"3px 8px",paddingLeft:8+(m.level-1)*12,cursor:"pointer",borderRadius:4,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",background:m.idx===d?"var(--nice-primary-bg, #e8f0fe)":void 0},onClick:()=>S(m.idx),title:m.text,children:m.text||f("docEditor.untitled","Untitled")},m.idx))]}),e.jsx("div",{className:"nice-doc-editor__body",style:{flex:1},children:p.map((m,X)=>e.jsxs("div",{className:`nice-doc-editor__block nice-doc-editor__block--${m.type} ${X===d?"nice-doc-editor__block--focused":""} ${ce===X?"nice-doc-editor__block--drop-target":""} ${m.locked?"nice-doc-editor__block--locked":""}`,onClick:()=>S(X),onContextMenu:ae=>Ae(ae,X),draggable:!a&&!m.locked,onDragStart:ae=>je(ae,X),onDragOver:ae=>we(ae,X),onDrop:ae=>Re(ae,X),onDragEnd:()=>{ie(null),ge(null)},style:{opacity:he===X?.4:1,marginLeft:(m.indent??0)*24},children:[!a&&!m.locked&&e.jsx("div",{className:"nice-doc-editor__block-handle",title:f("docEditor.drag","Drag to reorder"),children:"?"}),m.locked&&e.jsx("span",{className:"nice-doc-editor__lock-icon",style:{position:"absolute",top:2,right:4,fontSize:"0.7em",opacity:.5},children:"??"}),m.type==="divider"?e.jsx("hr",{className:"nice-doc-editor__divider"}):m.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(--nice-text-muted, #999)"},children:["� ",f("docEditor.pageBreak","Page Break")," �"]}):m.type==="image"||m.type==="video"?e.jsx("div",{className:"nice-doc-editor__media-block",children:m.src?m.type==="image"?e.jsx("img",{src:m.src,alt:m.alt??"",className:"nice-doc-editor__image",style:{maxWidth:"100%"}}):e.jsx("video",{src:m.src,controls:!0,className:"nice-doc-editor__video",style:{maxWidth:"100%"}}):!a&&e.jsxs("div",{style:{display:"flex",gap:4,alignItems:"center"},children:[e.jsx(Fe.NiceTextInput,{size:"sm",placeholder:f("docEditor.mediaUrl",m.type==="image"?"Image URL":"Video URL"),value:m.src??"",onChange:ae=>O(X,{src:ae})}),E&&e.jsx(Se.NiceButton,{size:"sm",variant:"ghost",onClick:()=>{S(X),B.current?.click()},children:"??"})]})}):m.type==="callout"?e.jsxs("div",{className:"nice-doc-editor__callout",style:{display:"flex",gap:8,padding:"8px 12px",background:m.bgColor??"#f0f7ff",borderRadius:4,color:m.color},children:[e.jsx("span",{style:{fontSize:"1.2em"},children:m.icon??"??"}),e.jsx("div",{ref:ae=>{ae&&V.current.set(m.id,ae)},className:"nice-doc-editor__content",contentEditable:!a&&!m.locked,suppressContentEditableWarning:!0,onInput:ae=>ue(ae,X),onFocus:()=>S(X),onKeyDown:ae=>se(ae,X),"data-placeholder":f("docEditor.calloutPlaceholder","Callout text..."),role:"textbox","aria-multiline":"true",style:{flex:1,outline:"none"},children:m.content})]}):m.type==="toggle"?e.jsxs("details",{open:m.open,className:"nice-doc-editor__toggle",onToggle:ae=>O(X,{open:ae.target.open}),children:[e.jsx("summary",{style:{cursor:"pointer",fontWeight:500},children:m.content.split(`
|
|
15
|
+
`)[0]||f("docEditor.toggleTitle","Toggle")}),e.jsx("div",{ref:ae=>{ae&&V.current.set(m.id,ae)},className:"nice-doc-editor__content",contentEditable:!a&&!m.locked,suppressContentEditableWarning:!0,onInput:ae=>ue(ae,X),onFocus:()=>S(X),onKeyDown:ae=>se(ae,X),role:"textbox","aria-multiline":"true",style:{padding:"4px 0"},children:m.content.split(`
|
|
16
|
+
`).slice(1).join(`
|
|
17
|
+
`)})]}):m.type==="code"?e.jsxs("div",{className:"nice-doc-editor__code-block",style:{position:"relative"},children:[!a&&e.jsx(Fe.NiceTextInput,{size:"sm",value:m.language??"",onChange:ae=>O(X,{language:ae}),placeholder:"Language",style:{position:"absolute",top:4,right:4,width:80,opacity:.7}}),e.jsx("pre",{ref:ae=>{ae&&V.current.set(m.id,ae)},className:"nice-doc-editor__content",contentEditable:!a&&!m.locked,suppressContentEditableWarning:!0,onInput:ae=>ue(ae,X),onFocus:()=>S(X),onKeyDown:ae=>se(ae,X),role:"textbox","aria-multiline":"true",style:{fontFamily:"monospace",background:"var(--nice-bg-elevated, #1e1e1e)",color:"var(--nice-text-secondary, #d4d4d4)",padding:12,borderRadius:4,overflow:"auto"},children:m.content})]}):e.jsxs("div",{style:{position:"relative"},children:[e.jsx("div",{ref:ae=>{ae&&V.current.set(m.id,ae)},className:"nice-doc-editor__content",contentEditable:!a&&!m.locked,suppressContentEditableWarning:!0,style:{textAlign:m.align,fontWeight:m.bold?"bold":void 0,fontStyle:m.italic?"italic":void 0,textDecoration:[m.underline?"underline":"",m.strikethrough?"line-through":""].filter(Boolean).join(" ")||void 0,color:m.color,backgroundColor:m.bgColor},onInput:ae=>ue(ae,X),onFocus:()=>S(X),onKeyDown:ae=>se(ae,X),"data-placeholder":!m.content&&y?y:void 0,role:"textbox","aria-multiline":"true",children:m.content}),me&&X===d&&oe.length>0&&e.jsx("ul",{className:"nice-doc-editor__slash-menu",style:{position:"absolute",left:0,top:"100%",zIndex:100,background:"var(--nice-bg-primary, #fff)",border:"1px solid var(--nice-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:oe.map((ae,Ce)=>e.jsxs("li",{className:Ce===_e?"nice-doc-editor__slash-item--active":"",style:{padding:"6px 10px",cursor:"pointer",borderRadius:4,display:"flex",gap:8,alignItems:"center",background:Ce===_e?"var(--nice-primary-bg, #e8f0fe)":void 0},onMouseDown:$e=>{$e.preventDefault(),U(ae)},onMouseEnter:()=>fe(Ce),children:[e.jsx("span",{style:{width:24,textAlign:"center"},children:ae.icon}),e.jsx("span",{children:ae.label})]},`${ae.type}-${ae.label}`))})]})]},m.id))})]}),pe&&e.jsxs("div",{className:"nice-doc-editor__ctx-menu",style:{position:"fixed",left:pe.x,top:pe.y,zIndex:1e3,background:"var(--nice-bg-primary, #fff)",border:"1px solid var(--nice-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:()=>{xe(pe.idx),Me(null)},children:"? Duplicate"}),e.jsx("div",{style:{padding:"6px 12px",cursor:"pointer"},onClick:()=>{G(pe.idx),Me(null)},children:"+ Insert below"}),e.jsx("div",{style:{padding:"6px 12px",cursor:"pointer"},onClick:()=>{F(pe.idx,-1),Me(null)},children:"? Move up"}),e.jsx("div",{style:{padding:"6px 12px",cursor:"pointer"},onClick:()=>{F(pe.idx,1),Me(null)},children:"? Move down"}),e.jsx("div",{style:{padding:"6px 12px",cursor:"pointer"},onClick:()=>{O(pe.idx,{locked:!p[pe.idx]?.locked}),Me(null)},children:p[pe.idx]?.locked?"?? Unlock":"?? Lock"}),e.jsx("hr",{style:{margin:"2px 0",border:"none",borderTop:"1px solid var(--nice-border-color, #eee)"}}),e.jsx("div",{style:{padding:"6px 12px",cursor:"pointer",color:"var(--nice-danger-dark, #d32f2f)"},onClick:()=>{le(pe.idx),Me(null)},children:"?? Delete"})]}),K&&ze&&e.jsxs("div",{className:"nice-doc-editor__footer",style:{padding:"4px 12px",fontSize:"0.75em",color:"var(--nice-text-muted, #666)",borderTop:"1px solid var(--nice-border-color, #eee)",display:"flex",gap:16},children:[e.jsxs("span",{children:[ze.words," ",f("docEditor.words","words")]}),e.jsxs("span",{children:[ze.chars," ",f("docEditor.chars","characters")]}),e.jsxs("span",{children:[p.length," ",f("docEditor.blocks","blocks")]}),e.jsxs("span",{children:["~",ze.readingTime," ",f("docEditor.readingTime","min read")]})]})]})});jn.displayName="NiceDocumentEditor";const bn=n.forwardRef(({label:t,helperText:i,error:a,disabled:o,readOnly:r,size:h="md",id:y,className:_,style:E,accessMode:C,pages:Z,selectedPageId:K,content:R="",contentFormat:w="html",editing:Q=!1,onPageSelect:ne,onContentChange:ee,onSave:te,onCreatePage:A,onDeletePage:j,onEditToggle:L,onVersionHistory:f,sidebarWidth:k=260,sidebarCollapsed:q=!1,onSidebarToggle:p,searchable:d=!0,onSearch:S},V)=>{const B=x.Dc(C,y),b=B==="hidden";B==="disabled"&&(o=!0),B==="readOnly"&&(r=!0);const{t:s}=x.Gt(),D=x.bc(y),[M,u]=n.useState(""),[c,l]=n.useState(""),[g,$]=n.useState(!1),v=n.useMemo(()=>{const N=P=>{for(const z of P){if(z.id===K)return z;if(z.children){const re=N(z.children);if(re)return re}}};return N(Z)},[Z,K]),T=n.useCallback(N=>{u(N),S?.(N)},[S]),I=n.useCallback(()=>{c.trim()&&(A?.(K??null,c.trim()),l(""),$(!1))},[c,K,A]),H=(N,P=0)=>e.jsx("ul",{className:"nice-wiki__tree",style:{paddingLeft:P>0?16:0},children:N.map(z=>e.jsxs("li",{className:"nice-wiki__tree-item",children:[e.jsxs("div",{className:`nice-wiki__tree-node${z.id===K?" nice-wiki__tree-node--active":""}${z.isDraft?" nice-wiki__tree-node--draft":""}`,onClick:()=>ne?.(z),role:"treeitem","aria-selected":z.id===K,children:[e.jsx("span",{className:"nice-wiki__tree-icon",children:e.jsx(x.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:s("draft","Draft")})]}),z.children&&z.children.length>0&&H(z.children,P+1)]},z.id))});return b?null:e.jsxs("div",{ref:V,id:D,className:`nice-wiki nice-size-${h}${_?` ${_}`:""}${o?" nice-disabled":""}`,style:E,children:[!q&&e.jsxs("aside",{className:"nice-wiki__sidebar",style:{width:k},children:[e.jsxs("div",{className:"nice-wiki__sidebar-header",children:[e.jsx("span",{className:"nice-wiki__sidebar-title",children:t??s("wiki","Wiki")}),p&&e.jsx("button",{type:"button",className:"nice-wiki__sidebar-toggle",onClick:()=>p(!0),"aria-label":s("collapseSidebar","Collapse sidebar"),children:e.jsx(x.oa,{name:"chevron-left",size:16})})]}),d&&e.jsx("input",{type:"text",className:"nice-input nice-wiki__search",value:M,onChange:N=>T(N.target.value),placeholder:s("searchPages","Search pages…"),disabled:o}),e.jsx("div",{className:"nice-wiki__page-tree",role:"tree",children:H(Z)}),A&&!r&&e.jsx("div",{className:"nice-wiki__sidebar-footer",children:g?e.jsxs("div",{className:"nice-wiki__create-form",children:[e.jsx("input",{type:"text",className:"nice-input",value:c,onChange:N=>l(N.target.value),placeholder:s("pageTitle","Page title"),onKeyDown:N=>N.key==="Enter"&&I(),disabled:o}),e.jsx("button",{type:"button",disabled:o||!c.trim(),onClick:I,"aria-label":s("create","Create"),children:e.jsx(x.oa,{name:"check",size:14})}),e.jsx("button",{type:"button",onClick:()=>$(!1),"aria-label":s("cancel","Cancel"),children:e.jsx(x.oa,{name:"close",size:14})})]}):e.jsxs("button",{type:"button",className:"nice-wiki__add-page",onClick:()=>$(!0),disabled:o,children:[e.jsx(x.oa,{name:"plus",size:14})," ",s("newPage","New page")]})})]}),q&&p&&e.jsx("button",{type:"button",className:"nice-wiki__sidebar-expand",onClick:()=>p(!1),"aria-label":s("expandSidebar","Expand sidebar"),children:e.jsx(x.oa,{name:"chevron-right",size:16})}),e.jsx("main",{className:"nice-wiki__content",children:v?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"nice-wiki__content-header",children:[e.jsx("h1",{className:"nice-wiki__page-title",children:v.title}),e.jsxs("div",{className:"nice-wiki__content-actions",children:[L&&!r&&e.jsx("button",{type:"button",disabled:o,onClick:()=>L(!Q),children:Q?s("preview","Preview"):s("edit","Edit")}),f&&e.jsx("button",{type:"button",disabled:o,onClick:()=>f(v.id),children:s("history","History")}),j&&!r&&e.jsx("button",{type:"button",className:"nice-btn--danger",disabled:o,onClick:()=>j(v.id),children:s("delete","Delete")})]})]}),v.updatedAt&&e.jsxs("div",{className:"nice-wiki__page-meta",children:[v.updatedBy&&e.jsxs("span",{children:[s("lastEditedBy","Last edited by")," ",v.updatedBy]}),e.jsx("span",{children:new Date(v.updatedAt).toLocaleDateString()})]}),Q?e.jsxs("div",{className:"nice-wiki__editor",children:[e.jsx("textarea",{className:"nice-wiki__editor-textarea",value:R,onChange:N=>ee?.(N.target.value),disabled:o}),te&&e.jsx("button",{type:"button",className:"nice-btn nice-btn--primary",disabled:o,onClick:()=>te(v.id,R),children:s("save","Save")})]}):e.jsx("div",{className:"nice-wiki__viewer",children:w==="html"?e.jsx("div",{className:"nice-wiki__html",dangerouslySetInnerHTML:{__html:x.lc(R)}}):e.jsx("pre",{className:"nice-wiki__markdown",children:R})})]}):e.jsx("div",{className:"nice-wiki__empty",children:e.jsx("p",{children:s("selectPage","Select a page from the sidebar or create a new one.")})})}),i&&e.jsx("span",{className:"nice-helper-text",children:i}),a&&typeof a=="string"&&e.jsx("span",{className:"nice-error-text",children:a})]})});bn.displayName="NiceWiki";const Ni=n.forwardRef(function(i,a){const{enableAI:o=!0,aiModel:r,enableInlineCompletion:h=!0,completionDelay:y=500,enableExplain:_=!0,enableRefactor:E=!0,enableGenerate:C=!0,systemPrompt:Z,onExplain:K,onRefactor:R,showAIToolbar:w=!0,aiShortcutKey:Q="Ctrl",language:ne="plaintext",value:ee,onChange:te,...A}=i,j=n.useRef(null),[L,f]=n.useState(null),[k,q]=n.useState(!1),[p,d]=n.useState(""),[S,V]=n.useState(!1),[B,b]=n.useState(""),[s,D]=n.useState(""),[M,u]=n.useState(""),c=n.useRef(void 0),{t:l}=x.Gt(),g=x.he(),{complete:$,explain:v,refactor:T,generateFromComment:I,isLoading:H}=x.wd({language:ne,model:r}),N=o&&g.isConfigured,P=n.useCallback(async()=>{if(!N||!h||!j.current||!j.current.getEditor())return;const oe=j.current.getCursorPosition(),ie=j.current.getValue().split(`
|
|
18
|
+
`),ce=ie.slice(0,oe.lineNumber-1),ge=ie[oe.lineNumber-1]||"",Y=[...ce,ge.slice(0,oe.column-1)].join(`
|
|
19
|
+
`),O=[ge.slice(oe.column-1),...ie.slice(oe.lineNumber)].join(`
|
|
20
|
+
`);try{const G=await $(Y,O);G&&f({lineNumber:oe.lineNumber,column:oe.column,text:G})}catch{}},[N,h,$]),z=n.useCallback(async()=>{if(!N||!_||!j.current)return"";const fe=j.current.getSelection();if(!fe)return"";u(fe),q(!0),d("");try{const oe=await v(fe);return d(oe),K?.(fe,oe),oe}catch{return d(l("codeEditorAI.explanationFailed","Failed to explain code")),""}},[N,_,v,K,l]),re=n.useCallback(async fe=>{if(!N||!E||!j.current)return"";const oe=j.current.getSelection();if(!oe)return"";try{const he=await T(oe,fe);return D(he),R?.(oe,he),he}catch{return""}},[N,E,T,R]),me=n.useCallback(async()=>{if(!N||!C||!j.current)return;const fe=j.current.getCursorPosition(),he=j.current.getValue().split(`
|
|
21
|
+
`);let ie="";for(let ce=fe.lineNumber-1;ce>=0&&ce>=fe.lineNumber-3;ce--){const ge=he[ce]?.trim()||"";if(ge.startsWith("//")||ge.startsWith("#")||ge.startsWith("/*")||ge.startsWith("*")){ie=ge.replace(/^\/\/\s*|^#\s*|^\/\*\s*|\*\/\s*$|^\*\s*/g,"").trim();break}}if(ie)try{const ce=await I(ie);ce&&j.current&&j.current.insertText(`
|
|
22
|
+
`+ce)}catch{}},[N,C,I]),de=n.useCallback(()=>{!L||!j.current||(j.current.insertText(L.text),f(null))},[L]),be=n.useCallback(()=>{f(null)},[]),ve=n.useCallback(fe=>{i.onCursorPositionChange?.(fe),!(!N||!h)&&(c.current&&clearTimeout(c.current),f(null),c.current=setTimeout(()=>{P()},y))},[i.onCursorPositionChange,N,h,y,P]);n.useEffect(()=>{if(!j.current?.getEditor()||!N)return;const oe=he=>{if(Q==="Ctrl"&&he.ctrlKey||Q==="Alt"&&he.altKey||Q==="Meta"&&he.metaKey){if(he.key===" "&&h&&(he.preventDefault(),P()),he.key==="e"&&_&&(he.preventDefault(),z()),he.key==="r"&&E){he.preventDefault();const ce=j.current?.getSelection();ce&&(u(ce),V(!0))}he.key==="g"&&C&&(he.preventDefault(),me())}he.key==="Tab"&&L&&(he.preventDefault(),de()),he.key==="Escape"&&L&&be()};return window.addEventListener("keydown",oe),()=>window.removeEventListener("keydown",oe)},[N,Q,h,_,E,C,P,z,me,L,de,be]),n.useEffect(()=>()=>{c.current&&clearTimeout(c.current)},[]);const _e=n.useCallback(()=>{if(!s||!j.current)return;const fe=j.current.getEditor();if(fe?.executeEdits&&fe?.getSelection){const oe=fe.getSelection();fe.executeEdits("ai-refactor",[{range:oe,text:s}])}V(!1),D(""),b("")},[s]);return n.useImperativeHandle(a,()=>({...j.current,getEditor:()=>j.current?.getEditor(),getMonaco:()=>j.current?.getMonaco(),focus:()=>j.current?.focus(),getValue:()=>j.current?.getValue()||"",setValue:fe=>j.current?.setValue(fe),getSelection:()=>j.current?.getSelection()||"",insertText:fe=>j.current?.insertText(fe),formatDocument:()=>j.current?.formatDocument(),goToLine:(fe,oe)=>j.current?.goToLine(fe,oe),findReplace:()=>j.current?.findReplace(),undo:()=>j.current?.undo(),redo:()=>j.current?.redo(),getCursorPosition:()=>j.current?.getCursorPosition()||{lineNumber:1,column:1},setMarkers:fe=>j.current?.setMarkers(fe),triggerCompletion:P,explainSelection:z,refactorSelection:re,generateFromComment:me,acceptCompletion:de,dismissCompletion:be})),e.jsxs("div",{className:"nice-code-editor-ai","data-testid":i["data-testid"],children:[w&&N&&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"}),H&&e.jsx("span",{className:"nice-code-editor-ai__loading",children:l("codeEditorAI.loading","Thinking...")})]}),e.jsxs("div",{className:"nice-code-editor-ai__toolbar-right",children:[h&&e.jsxs("button",{type:"button",className:"nice-code-editor-ai__toolbar-btn",onClick:()=>P(),disabled:H,title:`${l("codeEditorAI.complete","Complete")} (${Q}+Space)`,children:[e.jsx(x.oa,{name:"lightbulb",size:14})," ",l("codeEditorAI.complete","Complete")]}),_&&e.jsxs("button",{type:"button",className:"nice-code-editor-ai__toolbar-btn",onClick:()=>z(),disabled:H,title:`${l("codeEditorAI.explain","Explain")} (${Q}+E)`,children:[e.jsx(x.oa,{name:"book",size:14})," ",l("codeEditorAI.explain","Explain")]}),E&&e.jsxs("button",{type:"button",className:"nice-code-editor-ai__toolbar-btn",onClick:()=>{const fe=j.current?.getSelection();fe&&(u(fe),V(!0))},disabled:H,title:`${l("codeEditorAI.refactor","Refactor")} (${Q}+R)`,children:[e.jsx(x.oa,{name:"settings",size:14})," ",l("codeEditorAI.refactor","Refactor")]}),C&&e.jsxs("button",{type:"button",className:"nice-code-editor-ai__toolbar-btn",onClick:()=>me(),disabled:H,title:`${l("codeEditorAI.generate","Generate")} (${Q}+G)`,children:[e.jsx(x.oa,{name:"zap",size:14})," ",l("codeEditorAI.generate","Generate")]})]})]}),e.jsxs("div",{className:"nice-code-editor-ai__editor-wrapper",children:[e.jsx(_t.NiceCodeEditor,{ref:j,value:ee,onChange:te,language:ne,onCursorPositionChange:ve,...A}),L&&e.jsxs("div",{className:"nice-code-editor-ai__ghost-text",style:{top:`calc(${(L.lineNumber-1)*19}px + 4px)`,left:`calc(${(L.column-1)*7.8}px + 60px)`},children:[e.jsx("span",{className:"nice-code-editor-ai__ghost-text-content",children:L.text}),e.jsxs("span",{className:"nice-code-editor-ai__ghost-text-hint",children:["Tab ",l("codeEditorAI.toAccept","to accept")]})]})]}),k&&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(x.oa,{name:"book",size:16})," ",l("codeEditorAI.explanation","Explanation")]}),e.jsx("button",{type:"button",className:"nice-code-editor-ai__panel-close",onClick:()=>q(!1),"aria-label":l("codeEditorAI.close","Close"),children:e.jsx(x.oa,{name:"close",size:14})})]}),e.jsx("div",{className:"nice-code-editor-ai__panel-body",children:H?e.jsx("div",{className:"nice-code-editor-ai__panel-loading",children:l("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:M}),e.jsx("div",{className:"nice-code-editor-ai__explanation-text",children:p||l("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(x.oa,{name:"settings",size:16})," ",l("codeEditorAI.refactorCode","Refactor Code")]}),e.jsx("button",{type:"button",className:"nice-code-editor-ai__panel-close",onClick:()=>{V(!1),D(""),b("")},"aria-label":l("codeEditorAI.close","Close"),children:e.jsx(x.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:M}),e.jsxs("div",{className:"nice-code-editor-ai__refactor-input",children:[e.jsx("input",{type:"text",placeholder:l("codeEditorAI.refactorInstruction",'Describe how to refactor (e.g., "extract function", "add error handling")'),value:B,onChange:fe=>b(fe.target.value),onKeyDown:fe=>{fe.key==="Enter"&&B&&re(B)}}),e.jsx("button",{type:"button",className:"nice-code-editor-ai__refactor-btn",onClick:()=>re(B),disabled:H||!B,children:H?l("codeEditorAI.refactoring","Refactoring..."):l("codeEditorAI.refactor","Refactor")})]}),s&&e.jsxs("div",{className:"nice-code-editor-ai__refactor-result",children:[e.jsx("h5",{children:l("codeEditorAI.refactoredCode","Refactored Code")}),e.jsx("pre",{className:"nice-code-editor-ai__code-preview nice-code-editor-ai__code-preview--result",children:s}),e.jsxs("div",{className:"nice-code-editor-ai__refactor-actions",children:[e.jsxs("button",{type:"button",className:"nice-code-editor-ai__refactor-apply",onClick:_e,children:[e.jsx(x.oa,{name:"check",size:14})," ",l("codeEditorAI.apply","Apply")]}),e.jsxs("button",{type:"button",className:"nice-code-editor-ai__refactor-discard",onClick:()=>{D(""),b("")},children:[e.jsx(x.oa,{name:"close",size:14})," ",l("codeEditorAI.discard","Discard")]})]})]})]})]})]})});function Ci(t){const i=t instanceof Date?t:new Date(t),a=(o,r=2)=>String(o).padStart(r,"0");return`${a(i.getHours())}:${a(i.getMinutes())}:${a(i.getSeconds())}.${a(i.getMilliseconds(),3)}`}function Si(t){if(typeof t=="string")return t;try{return JSON.stringify(t,null,2)}catch{return String(t)}}const vn=n.forwardRef(function(i,a){const{entries:o,maxHeight:r=240,autoScroll:h=!0,showTimestamps:y=!0,levelFilter:_,onClear:E,title:C,emptyText:Z="No output",clearLabel:K="Clear",fontFamily:R,className:w,style:Q,id:ne,"data-testid":ee}=i,te=n.useRef(null),A=n.useMemo(()=>{if(!_||_.length===0)return o;const f=new Set(_);return o.filter(k=>f.has(k.level??"log"))},[o,_]);n.useEffect(()=>{h&&te.current&&(te.current.scrollTop=te.current.scrollHeight)},[A.length,h]);const j=!!C||!!E,L="nice-log-console"+(w?` ${w}`:"");return e.jsxs("div",{ref:a,id:ne,className:L,style:{...R?{fontFamily:R}:null,...Q},"data-testid":ee,children:[j&&e.jsxs("div",{className:"nice-log-console__header",children:[e.jsx("span",{className:"nice-log-console__title",children:C}),E&&e.jsx("button",{type:"button",className:"nice-log-console__clear",onClick:E,"aria-label":K,children:K})]}),e.jsx("div",{ref:te,className:"nice-log-console__body",style:{maxHeight:typeof r=="number"?`${r}px`:r},role:"log","aria-live":"polite","aria-relevant":"additions",children:A.length===0?e.jsx("div",{className:"nice-log-console__empty",children:Z}):A.map((f,k)=>{const q=f.level??"log";return e.jsxs("div",{className:`nice-log-console__entry nice-log-console__entry--${q}`,children:[y&&f.timestamp!=null&&e.jsx("span",{className:"nice-log-console__time",children:Ci(f.timestamp)}),e.jsx("span",{className:"nice-log-console__level",children:q}),f.source&&e.jsx("span",{className:"nice-log-console__source",children:f.source}),e.jsx("span",{className:"nice-log-console__message",children:f.message}),f.data!==void 0&&e.jsx("pre",{className:"nice-log-console__data",children:Si(f.data)})]},k)})})]})}),Ht="nice-log-console-styles";if(typeof document<"u"&&!document.getElementById(Ht)){const t=document.createElement("style");t.id=Ht,t.textContent=`
|
|
23
|
+
.nice-log-console {
|
|
24
|
+
display: flex;
|
|
25
|
+
flex-direction: column;
|
|
26
|
+
border: 1px solid var(--nice-border, #e0e0e0);
|
|
27
|
+
border-radius: var(--nice-radius-sm, 4px);
|
|
28
|
+
background: var(--nice-surface, #fff);
|
|
29
|
+
color: var(--nice-text-primary, #1f2937);
|
|
30
|
+
overflow: hidden;
|
|
31
|
+
font-family: 'Fira Code', 'Consolas', 'Monaco', monospace;
|
|
32
|
+
font-size: 12px;
|
|
33
|
+
line-height: 1.55;
|
|
34
|
+
}
|
|
35
|
+
.nice-log-console__header {
|
|
36
|
+
display: flex;
|
|
37
|
+
align-items: center;
|
|
38
|
+
justify-content: space-between;
|
|
39
|
+
gap: var(--nice-space-2, 8px);
|
|
40
|
+
padding: var(--nice-space-1, 4px) var(--nice-space-2, 8px);
|
|
41
|
+
border-bottom: 1px solid var(--nice-border, #e0e0e0);
|
|
42
|
+
background: var(--nice-bg-secondary, #f5f5f5);
|
|
43
|
+
}
|
|
44
|
+
.nice-log-console__title {
|
|
45
|
+
font-weight: 600;
|
|
46
|
+
font-size: 12px;
|
|
47
|
+
}
|
|
48
|
+
.nice-log-console__clear {
|
|
49
|
+
border: 1px solid var(--nice-border, #e0e0e0);
|
|
50
|
+
background: var(--nice-surface, #fff);
|
|
51
|
+
color: var(--nice-text-secondary, #6b7280);
|
|
52
|
+
border-radius: var(--nice-radius-sm, 4px);
|
|
53
|
+
padding: 2px 8px;
|
|
54
|
+
font: inherit;
|
|
55
|
+
font-size: 11px;
|
|
56
|
+
cursor: pointer;
|
|
57
|
+
}
|
|
58
|
+
.nice-log-console__clear:hover {
|
|
59
|
+
color: var(--nice-text-primary, #1f2937);
|
|
60
|
+
border-color: var(--nice-text-secondary, #9ca3af);
|
|
61
|
+
}
|
|
62
|
+
.nice-log-console__body {
|
|
63
|
+
flex: 1;
|
|
64
|
+
overflow: auto;
|
|
65
|
+
padding: var(--nice-space-2, 8px);
|
|
66
|
+
}
|
|
67
|
+
.nice-log-console__empty {
|
|
68
|
+
color: var(--nice-text-muted, #9ca3af);
|
|
69
|
+
font-style: italic;
|
|
70
|
+
padding: var(--nice-space-2, 8px) 0;
|
|
71
|
+
}
|
|
72
|
+
.nice-log-console__entry {
|
|
73
|
+
display: flex;
|
|
74
|
+
flex-wrap: wrap;
|
|
75
|
+
align-items: baseline;
|
|
76
|
+
gap: var(--nice-space-2, 8px);
|
|
77
|
+
padding: 1px 0;
|
|
78
|
+
white-space: pre-wrap;
|
|
79
|
+
word-break: break-word;
|
|
80
|
+
}
|
|
81
|
+
.nice-log-console__time {
|
|
82
|
+
color: var(--nice-text-muted, #9ca3af);
|
|
83
|
+
flex: 0 0 auto;
|
|
84
|
+
}
|
|
85
|
+
.nice-log-console__level {
|
|
86
|
+
flex: 0 0 auto;
|
|
87
|
+
text-transform: uppercase;
|
|
88
|
+
font-size: 10px;
|
|
89
|
+
font-weight: 700;
|
|
90
|
+
letter-spacing: 0.04em;
|
|
91
|
+
opacity: 0.8;
|
|
92
|
+
min-width: 38px;
|
|
93
|
+
}
|
|
94
|
+
.nice-log-console__source {
|
|
95
|
+
flex: 0 0 auto;
|
|
96
|
+
color: var(--nice-primary, #2563eb);
|
|
97
|
+
}
|
|
98
|
+
.nice-log-console__message {
|
|
99
|
+
flex: 1 1 auto;
|
|
100
|
+
}
|
|
101
|
+
.nice-log-console__data {
|
|
102
|
+
flex: 1 0 100%;
|
|
103
|
+
margin: 2px 0 4px;
|
|
104
|
+
padding: var(--nice-space-1, 4px) var(--nice-space-2, 8px);
|
|
105
|
+
background: var(--nice-bg-secondary, #f5f5f5);
|
|
106
|
+
border-radius: var(--nice-radius-sm, 4px);
|
|
107
|
+
overflow: auto;
|
|
108
|
+
font: inherit;
|
|
109
|
+
}
|
|
110
|
+
.nice-log-console__entry--info .nice-log-console__level { color: var(--nice-primary, #2563eb); }
|
|
111
|
+
.nice-log-console__entry--warn { color: var(--nice-warning-text, #92400e); }
|
|
112
|
+
.nice-log-console__entry--warn .nice-log-console__level { color: var(--nice-warning, #d97706); }
|
|
113
|
+
.nice-log-console__entry--error { color: var(--nice-danger, #dc2626); }
|
|
114
|
+
.nice-log-console__entry--error .nice-log-console__level { color: var(--nice-danger, #dc2626); }
|
|
115
|
+
.nice-log-console__entry--debug { color: var(--nice-text-muted, #9ca3af); }
|
|
116
|
+
.nice-log-console__entry--trace { color: var(--nice-text-disabled, #b8bfc9); }
|
|
117
|
+
.nice-log-console__entry--trace .nice-log-console__level { color: var(--nice-text-disabled, #b8bfc9); }
|
|
118
|
+
`,document.head.appendChild(t)}const $i=[{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 Ot(t){if(t===void 0)return"";if(typeof t=="string")return t;try{return JSON.stringify(t,null,2)}catch{return String(t)}}function Ft(t){const i=t.trim();if(i==="")return{value:void 0,error:null};try{return{value:JSON.parse(i),error:null}}catch(a){return{value:t,error:a instanceof Error?a.message:"Invalid JSON"}}}function Ei(t){if(typeof t=="string")return t;try{return JSON.stringify(t,null,2)}catch{return String(t)}}const Mi=n.forwardRef(function(i,a){const{value:o,onChange:r,language:h="javascript",onRun:y,input:_,onInputChange:E,showInputPanel:C,extraLibs:Z,height:K=260,running:R,autoRun:w=!1,autoRunDelay:Q=600,layout:ne="vertical",runLabel:ee="Run",theme:te="auto",tutorial:A,className:j,style:L,id:f,"data-testid":k}=i,q=C??_!==void 0,[p,d]=n.useState(()=>Ot(_)),[S,V]=n.useState(null),[B,b]=n.useState(!1),[s,D]=n.useState(null),M=R??B,u=te==="light"?"vs":te==="dark"?"vs-dark":te;n.useEffect(()=>{d(Ot(_))},[_]);const c=n.useCallback(async()=>{const T=Ft(p),I=typeof performance<"u"?performance.now():Date.now();R===void 0&&b(!0);try{const H=await y(o,T.value),N=H.durationMs??Math.round((typeof performance<"u"?performance.now():Date.now())-I);D({...H,durationMs:N})}catch(H){D({ok:!1,error:H instanceof Error?H.message:String(H),durationMs:Math.round((typeof performance<"u"?performance.now():Date.now())-I)})}finally{R===void 0&&b(!1)}},[p,y,o,R]),l=n.useRef(c);l.current=c,n.useEffect(()=>{if(!w)return;const T=setTimeout(()=>{l.current()},Q);return()=>clearTimeout(T)},[w,Q,o,p]);const g=n.useCallback(T=>{d(T);const I=Ft(T);V(I.error),E?.(I.value)},[E]),$=typeof K=="number"?`${K}px`:K,v=`nice-script-runner nice-script-runner--${ne}`+(j?` ${j}`:"");return e.jsxs("div",{ref:a,id:f,className:v,style:L,"data-testid":k,children:[e.jsxs("div",{className:"nice-script-runner__toolbar",children:[e.jsxs("button",{type:"button",className:"nice-script-runner__run",onClick:()=>void c(),disabled:M,children:[M?"…":e.jsx(x.oa,{name:"play",size:14})," ",ee]}),s?.durationMs!=null&&e.jsxs("span",{className:"nice-script-runner__status",children:[e.jsx("span",{className:"nice-script-runner__badge nice-script-runner__badge--"+(s.ok?"ok":"error"),children:s.ok?"OK":"Failed"}),e.jsxs("span",{className:"nice-script-runner__duration",children:[s.durationMs," ms"]})]}),A&&e.jsx("span",{style:{marginLeft:"auto"},children:e.jsx(x.Ql,{steps:x.Yl(A,$i)})})]}),e.jsxs("div",{className:"nice-script-runner__panes",children:[e.jsxs("div",{className:"nice-script-runner__editors",children:[e.jsx(_t.NiceCodeEditor,{value:o,onChange:r,language:h,theme:u,height:$,extraLibs:Z,options:{minimap:!1}}),q&&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(_t.NiceCodeEditor,{value:p,onChange:g,language:"json",theme:u,height:120,options:{minimap:!1,lineNumbers:"off"}})]})]}),e.jsxs("div",{className:"nice-script-runner__output",children:[s?.error&&e.jsx("div",{className:"nice-script-runner__error",children:s.error}),s&&s.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:Ei(s.result)})]}),e.jsx(vn,{title:"Logs",entries:s?.logs??[],maxHeight:160,emptyText:"Run the script to see logs"})]})]})]})}),Yt="nice-script-runner-styles";if(typeof document<"u"&&!document.getElementById(Yt)){const t=document.createElement("style");t.id=Yt,t.textContent=`
|
|
119
|
+
.nice-script-runner {
|
|
120
|
+
display: flex;
|
|
121
|
+
flex-direction: column;
|
|
122
|
+
gap: var(--nice-space-2, 8px);
|
|
123
|
+
border: 1px solid var(--nice-border, #e0e0e0);
|
|
124
|
+
border-radius: var(--nice-radius-md, 6px);
|
|
125
|
+
padding: var(--nice-space-2, 8px);
|
|
126
|
+
background: var(--nice-surface, #fff);
|
|
127
|
+
}
|
|
128
|
+
.nice-script-runner__toolbar {
|
|
129
|
+
display: flex;
|
|
130
|
+
align-items: center;
|
|
131
|
+
gap: var(--nice-space-2, 8px);
|
|
132
|
+
}
|
|
133
|
+
.nice-script-runner__run {
|
|
134
|
+
border: 0;
|
|
135
|
+
background: var(--nice-primary, #2563eb);
|
|
136
|
+
color: var(--nice-text-inverse, #fff);
|
|
137
|
+
border-radius: var(--nice-radius-sm, 4px);
|
|
138
|
+
padding: 6px 14px;
|
|
139
|
+
font: inherit;
|
|
140
|
+
font-weight: 600;
|
|
141
|
+
cursor: pointer;
|
|
142
|
+
}
|
|
143
|
+
.nice-script-runner__run:disabled {
|
|
144
|
+
opacity: 0.6;
|
|
145
|
+
cursor: default;
|
|
146
|
+
}
|
|
147
|
+
.nice-script-runner__status {
|
|
148
|
+
display: inline-flex;
|
|
149
|
+
align-items: center;
|
|
150
|
+
gap: var(--nice-space-2, 8px);
|
|
151
|
+
font-size: 12px;
|
|
152
|
+
}
|
|
153
|
+
.nice-script-runner__badge {
|
|
154
|
+
padding: 1px 8px;
|
|
155
|
+
border-radius: 999px;
|
|
156
|
+
font-size: 11px;
|
|
157
|
+
font-weight: 700;
|
|
158
|
+
}
|
|
159
|
+
.nice-script-runner__badge--ok {
|
|
160
|
+
background: var(--nice-success-bg, #dcfce7);
|
|
161
|
+
color: var(--nice-success-text, #166534);
|
|
162
|
+
}
|
|
163
|
+
.nice-script-runner__badge--error {
|
|
164
|
+
background: var(--nice-danger-bg, #fee2e2);
|
|
165
|
+
color: var(--nice-danger-text, #991b1b);
|
|
166
|
+
}
|
|
167
|
+
.nice-script-runner__duration {
|
|
168
|
+
color: var(--nice-text-muted, #9ca3af);
|
|
169
|
+
}
|
|
170
|
+
.nice-script-runner__panes {
|
|
171
|
+
display: grid;
|
|
172
|
+
gap: var(--nice-space-2, 8px);
|
|
173
|
+
}
|
|
174
|
+
.nice-script-runner--horizontal .nice-script-runner__panes {
|
|
175
|
+
grid-template-columns: 1fr 1fr;
|
|
176
|
+
}
|
|
177
|
+
.nice-script-runner__editors,
|
|
178
|
+
.nice-script-runner__output {
|
|
179
|
+
display: flex;
|
|
180
|
+
flex-direction: column;
|
|
181
|
+
gap: var(--nice-space-2, 8px);
|
|
182
|
+
min-width: 0;
|
|
183
|
+
}
|
|
184
|
+
.nice-script-runner__pane-label {
|
|
185
|
+
font-size: 11px;
|
|
186
|
+
font-weight: 600;
|
|
187
|
+
text-transform: uppercase;
|
|
188
|
+
letter-spacing: 0.04em;
|
|
189
|
+
color: var(--nice-text-secondary, #6b7280);
|
|
190
|
+
}
|
|
191
|
+
.nice-script-runner__input-error {
|
|
192
|
+
color: var(--nice-danger, #dc2626);
|
|
193
|
+
text-transform: none;
|
|
194
|
+
font-weight: 400;
|
|
195
|
+
}
|
|
196
|
+
.nice-script-runner__error {
|
|
197
|
+
padding: var(--nice-space-2, 8px);
|
|
198
|
+
border-radius: var(--nice-radius-sm, 4px);
|
|
199
|
+
background: var(--nice-danger-bg, #fee2e2);
|
|
200
|
+
color: var(--nice-danger-text, #991b1b);
|
|
201
|
+
font-family: 'Fira Code', 'Consolas', 'Monaco', monospace;
|
|
202
|
+
font-size: 12px;
|
|
203
|
+
white-space: pre-wrap;
|
|
204
|
+
}
|
|
205
|
+
.nice-script-runner__result-body {
|
|
206
|
+
margin: 4px 0 0;
|
|
207
|
+
padding: var(--nice-space-2, 8px);
|
|
208
|
+
border: 1px solid var(--nice-border, #e0e0e0);
|
|
209
|
+
border-radius: var(--nice-radius-sm, 4px);
|
|
210
|
+
background: var(--nice-bg-secondary, #f9fafb);
|
|
211
|
+
max-height: 200px;
|
|
212
|
+
overflow: auto;
|
|
213
|
+
font-family: 'Fira Code', 'Consolas', 'Monaco', monospace;
|
|
214
|
+
font-size: 12px;
|
|
215
|
+
}
|
|
216
|
+
`,document.head.appendChild(t)}const Ri=[{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"}],Ti=n.forwardRef(function(i,a){const{value:o,onChange:r,allowSecret:h=!1,allowToggle:y=!1,allowDescription:_=!1,keySuggestions:E,keyPlaceholder:C="Key",valuePlaceholder:Z="Value",addLabel:K="Add",readOnly:R=!1,duplicateKeyWarning:w=!0,tutorial:Q,className:ne,style:ee,id:te,"data-testid":A}=i,j=n.useMemo(()=>`nice-kv-keys-${Math.random().toString(36).slice(2,9)}`,[]),L=n.useMemo(()=>{const d=new Map,S=new Set;if(w){for(const V of o){const B=V.key.trim();B!==""&&d.set(B,(d.get(B)??0)+1)}d.forEach((V,B)=>{V>1&&S.add(B)})}return S},[o,w]),f=(d,S)=>{r(o.map((V,B)=>B===d?{...V,...S}:V))},k=d=>{r(o.filter((S,V)=>V!==d))},q=()=>{r([...o,{key:"",value:"",type:"text",enabled:!0}])},p="nice-key-value-editor"+(ne?` ${ne}`:"");return e.jsxs("div",{ref:a,id:te,className:p,style:{position:"relative",...ee},"data-testid":A,children:[e.jsx("span",{style:{position:"absolute",top:0,right:0,zIndex:20},children:e.jsx(x.Ql,{steps:x.Yl(Q,Ri)})}),E&&E.length>0&&e.jsx("datalist",{id:j,children:E.map(d=>e.jsx("option",{value:d},d))}),e.jsx("div",{className:"nice-key-value-editor__rows",children:o.map((d,S)=>{const V=d.type==="secret",B=d.key.trim()!==""&&L.has(d.key.trim()),b=y&&d.enabled===!1;return e.jsxs("div",{className:"nice-key-value-editor__row"+(b?" nice-key-value-editor__row--disabled":""),children:[y&&e.jsx("input",{type:"checkbox",className:"nice-key-value-editor__toggle",checked:d.enabled!==!1,onChange:s=>f(S,{enabled:s.target.checked}),disabled:R,"aria-label":"Enabled"}),e.jsx("input",{type:"text",className:"nice-key-value-editor__key"+(B?" nice-key-value-editor__key--dup":""),value:d.key,list:E?j:void 0,placeholder:C,onChange:s=>f(S,{key:s.target.value}),readOnly:R,"aria-label":C,title:B?"Duplicate key":void 0}),e.jsx("input",{type:V?"password":"text",className:"nice-key-value-editor__value",value:d.value,placeholder:Z,onChange:s=>f(S,{value:s.target.value}),readOnly:R,autoComplete:V?"new-password":"off","aria-label":Z}),h&&e.jsx("button",{type:"button",className:"nice-key-value-editor__secret"+(V?" nice-key-value-editor__secret--on":""),onClick:()=>f(S,{type:V?"text":"secret"}),disabled:R,title:V?"Secret (click to reveal as text)":"Mark as secret","aria-pressed":V,"aria-label":"Toggle secret",children:e.jsx(x.oa,{name:"lock",size:16})}),_&&e.jsx("input",{type:"text",className:"nice-key-value-editor__desc",value:d.description??"",placeholder:"Description",onChange:s=>f(S,{description:s.target.value}),readOnly:R,"aria-label":"Description"}),!R&&e.jsx("button",{type:"button",className:"nice-key-value-editor__remove",onClick:()=>k(S),title:"Remove row","aria-label":"Remove row",children:e.jsx(x.oa,{name:"close",size:14})})]},d.id??S)})}),!R&&e.jsxs("button",{type:"button",className:"nice-key-value-editor__add",onClick:q,children:["+ ",K]})]})}),Kt="nice-key-value-editor-styles";if(typeof document<"u"&&!document.getElementById(Kt)){const t=document.createElement("style");t.id=Kt,t.textContent=`
|
|
217
|
+
.nice-key-value-editor {
|
|
218
|
+
display: flex;
|
|
219
|
+
flex-direction: column;
|
|
220
|
+
gap: var(--nice-space-2, 8px);
|
|
221
|
+
}
|
|
222
|
+
.nice-key-value-editor__rows {
|
|
223
|
+
display: flex;
|
|
224
|
+
flex-direction: column;
|
|
225
|
+
gap: var(--nice-space-1, 4px);
|
|
226
|
+
}
|
|
227
|
+
.nice-key-value-editor__row {
|
|
228
|
+
display: flex;
|
|
229
|
+
align-items: center;
|
|
230
|
+
gap: var(--nice-space-1, 4px);
|
|
231
|
+
}
|
|
232
|
+
.nice-key-value-editor__row--disabled {
|
|
233
|
+
opacity: 0.55;
|
|
234
|
+
}
|
|
235
|
+
.nice-key-value-editor__key,
|
|
236
|
+
.nice-key-value-editor__value,
|
|
237
|
+
.nice-key-value-editor__desc {
|
|
238
|
+
flex: 1 1 0;
|
|
239
|
+
min-width: 0;
|
|
240
|
+
padding: 6px 8px;
|
|
241
|
+
border: 1px solid var(--nice-border, #d1d5db);
|
|
242
|
+
border-radius: var(--nice-radius-sm, 4px);
|
|
243
|
+
background: var(--nice-bg, #fff);
|
|
244
|
+
color: var(--nice-text-primary, #1f2937);
|
|
245
|
+
font: inherit;
|
|
246
|
+
font-size: 13px;
|
|
247
|
+
}
|
|
248
|
+
.nice-key-value-editor__key {
|
|
249
|
+
flex-basis: 30%;
|
|
250
|
+
font-family: 'Fira Code', 'Consolas', 'Monaco', monospace;
|
|
251
|
+
}
|
|
252
|
+
.nice-key-value-editor__key--dup {
|
|
253
|
+
border-color: var(--nice-danger, #dc2626);
|
|
254
|
+
background: var(--nice-danger-bg, #fee2e2);
|
|
255
|
+
}
|
|
256
|
+
.nice-key-value-editor__key:focus,
|
|
257
|
+
.nice-key-value-editor__value:focus,
|
|
258
|
+
.nice-key-value-editor__desc:focus {
|
|
259
|
+
outline: none;
|
|
260
|
+
border-color: var(--nice-primary, #2563eb);
|
|
261
|
+
}
|
|
262
|
+
.nice-key-value-editor__toggle {
|
|
263
|
+
flex: 0 0 auto;
|
|
264
|
+
}
|
|
265
|
+
.nice-key-value-editor__secret,
|
|
266
|
+
.nice-key-value-editor__remove {
|
|
267
|
+
flex: 0 0 auto;
|
|
268
|
+
border: 1px solid var(--nice-border, #d1d5db);
|
|
269
|
+
background: var(--nice-surface, #fff);
|
|
270
|
+
border-radius: var(--nice-radius-sm, 4px);
|
|
271
|
+
padding: 5px 8px;
|
|
272
|
+
font-size: 13px;
|
|
273
|
+
line-height: 1;
|
|
274
|
+
cursor: pointer;
|
|
275
|
+
}
|
|
276
|
+
.nice-key-value-editor__secret--on {
|
|
277
|
+
border-color: var(--nice-warning, #d97706);
|
|
278
|
+
background: var(--nice-warning-bg, #fef3c7);
|
|
279
|
+
}
|
|
280
|
+
.nice-key-value-editor__remove:hover {
|
|
281
|
+
border-color: var(--nice-danger, #dc2626);
|
|
282
|
+
color: var(--nice-danger, #dc2626);
|
|
283
|
+
}
|
|
284
|
+
.nice-key-value-editor__add {
|
|
285
|
+
align-self: flex-start;
|
|
286
|
+
border: 1px dashed var(--nice-border, #d1d5db);
|
|
287
|
+
background: transparent;
|
|
288
|
+
color: var(--nice-primary, #2563eb);
|
|
289
|
+
border-radius: var(--nice-radius-sm, 4px);
|
|
290
|
+
padding: 5px 12px;
|
|
291
|
+
font: inherit;
|
|
292
|
+
font-size: 13px;
|
|
293
|
+
font-weight: 600;
|
|
294
|
+
cursor: pointer;
|
|
295
|
+
}
|
|
296
|
+
.nice-key-value-editor__add:hover {
|
|
297
|
+
background: var(--nice-bg-secondary, #f5f5f5);
|
|
298
|
+
}
|
|
299
|
+
`,document.head.appendChild(t)}const Ii=["street","streetNumber","apartment","city","postalCode","state","country"],dt={street:"Street",streetNumber:"Number",apartment:"Apt/Suite",city:"City",postalCode:"Postal Code",state:"State/Province",country:"Country"},_n=n.forwardRef(({label:t,helperText:i,error:a,required:o,disabled:r,readOnly:h,size:y="md",name:_,id:E,className:C,style:Z,accessMode:K,value:R={},onChange:w,fields:Q=Ii,placeholders:ne={},countries:ee,layout:te="vertical",countryFirst:A=!1,validatePostalCode:j},L)=>{const f=x.Dc(K,E),k=f==="hidden";f==="disabled"&&(r=!0),f==="readOnly"&&(h=!0);const{t:q}=x.Gt(),p=x.bc(E),d=n.useCallback((b,s)=>{w?.({...R,[b]:s})},[R,w]),S=n.useMemo(()=>{if(j&&R.postalCode)return j(R.postalCode,R.country)},[j,R.postalCode,R.country]),V=n.useMemo(()=>A&&Q.includes("country")?["country",...Q.filter(b=>b!=="country")]:Q,[Q,A]),B=`nice-address nice-address--${te} nice-size-${y}`;return k?null:e.jsxs("div",{ref:L,id:p,className:`${B}${C?` ${C}`:""}${a?" nice-error":""}${r?" nice-disabled":""}`,style:Z,role:"group","aria-label":t??q("address","Address"),children:[t&&e.jsxs("label",{className:"nice-address__label",children:[t,o&&e.jsx("span",{className:"nice-required",children:"*"})]}),e.jsx("div",{className:"nice-address__fields",children:V.map(b=>b==="country"&&ee?e.jsxs("div",{className:`nice-address__field nice-address__field--${b}`,children:[e.jsx("label",{className:"nice-address__field-label",children:q(b,dt[b])}),e.jsxs("select",{className:"nice-input nice-select",value:R.country??"",onChange:s=>d("country",s.target.value),disabled:r,"aria-label":q(b,dt[b]),children:[e.jsx("option",{value:"",children:ne.country??q("selectCountry","— Select country —")}),ee.map(s=>e.jsx("option",{value:s.code,children:s.name},s.code))]})]},b):e.jsxs("div",{className:`nice-address__field nice-address__field--${b}`,children:[e.jsx("label",{className:"nice-address__field-label",children:q(b,dt[b])}),e.jsx("input",{className:`nice-input${b==="postalCode"&&S?" nice-input--error":""}`,type:"text",name:_?`${_}.${b}`:b,value:R[b]??"",onChange:s=>d(b,s.target.value),placeholder:ne[b]??"",disabled:r,readOnly:h,"aria-label":q(b,dt[b])}),b==="postalCode"&&S&&e.jsx("span",{className:"nice-error-text",children:S})]},b))}),i&&e.jsx("span",{className:"nice-helper-text",children:i}),a&&typeof a=="string"&&e.jsx("span",{className:"nice-error-text",children:a})]})});_n.displayName="NiceAddressInput";const Ai={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)"},kn=n.forwardRef(({label:t,helperText:i,error:a,required:o,disabled:r,readOnly:h,size:y="md",name:_,id:E,className:C,style:Z,accessMode:K,value:R,onChange:w,accounts:Q,treeView:ne=!1,placeholder:ee,searchable:te=!0,showType:A=!0,onSearch:j},L)=>{const f=x.Dc(K,E),k=f==="hidden";f==="disabled"&&(r=!0),f==="readOnly"&&(h=!0);const{t:q}=x.Gt(),p=x.bc(E),[d,S]=n.useState(""),[V,B]=n.useState(!1),b=n.useMemo(()=>{const c=l=>{for(const g of l){if(g.code===R)return g;if(g.children){const $=c(g.children);if($)return $}}};return c(Q)},[Q,R]),s=n.useMemo(()=>{const c=[],l=g=>{for(const $ of g)c.push($),$.children&&l($.children)};return l(Q),c},[Q]),D=n.useMemo(()=>{if(!d)return s;const c=d.toLowerCase();return s.filter(l=>l.code.toLowerCase().includes(c)||l.name.toLowerCase().includes(c))},[s,d]),M=n.useCallback(c=>{S(c),j?.(c),B(!0)},[j]),u=n.useCallback(c=>{w?.(c.code,c),B(!1),S("")},[w]);return k?null:e.jsxs("div",{ref:L,id:p,className:`nice-account-picker nice-size-${y}${C?` ${C}`:""}${a?" nice-error":""}${r?" nice-disabled":""}`,style:Z,children:[t&&e.jsxs("label",{className:"nice-account-picker__label",htmlFor:`${p}-input`,children:[t,o&&e.jsx("span",{className:"nice-required",children:"*"})]}),e.jsx("div",{className:"nice-account-picker__control",children:te&&!h?e.jsx("input",{id:`${p}-input`,className:"nice-input",type:"text",value:V?d:b?`${b.code} — ${b.name}`:"",onChange:c=>M(c.target.value),onFocus:()=>{S(""),B(!0)},onBlur:()=>setTimeout(()=>B(!1),200),placeholder:ee??q("searchAccount","Search account…"),disabled:r,required:o}):e.jsx("div",{className:"nice-account-picker__display",children:b?`${b.code} — ${b.name}`:ee??q("selectAccount","Select account…")})}),V&&D.length>0&&e.jsx("div",{className:"nice-account-picker__dropdown",role:"listbox",children:D.map(c=>e.jsxs("div",{className:`nice-account-picker__option${c.code===R?" nice-account-picker__option--selected":""}${c.isActive===!1?" nice-account-picker__option--inactive":""}`,role:"option","aria-selected":c.code===R,onClick:()=>u(c),children:[A&&c.type&&e.jsx("span",{className:"nice-account-picker__type",style:{color:Ai[c.type]},title:c.type,children:e.jsx(x.oa,{name:"circle",size:10})}),e.jsx("span",{className:"nice-account-picker__code",children:c.code}),e.jsx("span",{className:"nice-account-picker__name",children:c.name})]},c.code))}),i&&e.jsx("span",{className:"nice-helper-text",children:i}),a&&typeof a=="string"&&e.jsx("span",{className:"nice-error-text",children:a})]})});kn.displayName="NiceAccountPicker";const wn=n.forwardRef(({label:t,helperText:i,error:a,required:o,disabled:r,readOnly:h,size:y="md",name:_,id:E,className:C,style:Z,accessMode:K,value:R=[],onChange:w,contacts:Q=[],onSearch:ne,searchDelay:ee=300,multiple:te=!1,placeholder:A,onContactClick:j,maxSelections:L},f)=>{const k=x.Dc(K,E),q=k==="hidden";k==="disabled"&&(r=!0),k==="readOnly"&&(h=!0);const{t:p}=x.Gt(),d=x.bc(E),[S,V]=n.useState(""),[B,b]=n.useState([]),[s,D]=n.useState(!1),[M,u]=n.useState(!1),c=n.useMemo(()=>{const v=[...Q,...B],T=new Map(v.map(I=>[I.id,I]));return R.map(I=>T.get(I)).filter(Boolean)},[R,Q,B]),l=n.useCallback(v=>{if(V(v),v.length<1){b([]),D(!1);return}if(ne){u(!0);const H=setTimeout(async()=>{const N=await ne(v);b(N),D(!0),u(!1)},ee);return()=>clearTimeout(H)}const T=v.toLowerCase(),I=Q.filter(H=>H.name.toLowerCase().includes(T)||H.email?.toLowerCase().includes(T)||H.phone?.includes(v));b(I),D(!0)},[ne,Q,ee]),g=n.useCallback(v=>{if(te)if(R.includes(v.id))w?.(R.filter(T=>T!==v.id));else{if(L&&R.length>=L)return;w?.([...R,v.id])}else w?.([v.id]),D(!1),V("")},[R,w,te,L]),$=n.useCallback(v=>{w?.(R.filter(T=>T!==v))},[R,w]);return q?null:e.jsxs("div",{ref:f,id:d,className:`nice-contact-picker nice-size-${y}${C?` ${C}`:""}${a?" nice-error":""}${r?" nice-disabled":""}`,style:Z,children:[t&&e.jsxs("label",{className:"nice-contact-picker__label",children:[t,o&&e.jsx("span",{className:"nice-required",children:"*"})]}),c.length>0&&e.jsx("div",{className:"nice-contact-picker__chips",children:c.map(v=>e.jsxs("span",{className:"nice-contact-picker__chip",onClick:()=>j?.(v),children:[v.avatarUrl&&e.jsx("img",{src:v.avatarUrl,alt:"",className:"nice-contact-picker__chip-avatar"}),e.jsx("span",{children:v.name}),!h&&e.jsx("button",{type:"button",className:"nice-contact-picker__chip-remove",onClick:T=>{T.stopPropagation(),$(v.id)},disabled:r,"aria-label":p("controls.remove","Remove"),children:e.jsx(x.oa,{name:"close",size:14})})]},v.id))}),!h&&e.jsxs("div",{className:"nice-contact-picker__search",children:[e.jsx("input",{className:"nice-input",type:"text",value:S,onChange:v=>l(v.target.value),onFocus:()=>S.length>0&&D(!0),onBlur:()=>setTimeout(()=>D(!1),200),placeholder:A??p("searchContacts","Search contacts…"),disabled:r,"aria-label":p("searchContacts","Search contacts")}),M&&e.jsx("span",{className:"nice-contact-picker__spinner",children:e.jsx(x.oa,{name:"refresh",size:16})})]}),s&&B.length>0&&e.jsx("div",{className:"nice-contact-picker__dropdown",role:"listbox",children:B.map(v=>e.jsxs("div",{className:`nice-contact-picker__option${R.includes(v.id)?" nice-contact-picker__option--selected":""}`,role:"option","aria-selected":R.includes(v.id),onClick:()=>g(v),children:[v.avatarUrl&&e.jsx("img",{src:v.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:v.name}),v.subtitle&&e.jsx("span",{className:"nice-contact-picker__option-subtitle",children:v.subtitle}),v.email&&e.jsx("span",{className:"nice-contact-picker__option-email",children:v.email})]}),v.type&&e.jsx("span",{className:"nice-contact-picker__option-type",children:e.jsx(x.oa,{name:v.type==="person"?"user":"building",size:16})})]},v.id))}),i&&e.jsx("span",{className:"nice-helper-text",children:i}),a&&typeof a=="string"&&e.jsx("span",{className:"nice-error-text",children:a})]})});wn.displayName="NiceContactPicker";const Di={recent:"🕒",smileys:"😀",people:"👋",animals:"🐱",food:"🍕",travel:"✈️",activities:"⚽",objects:"💡",symbols:"❤️",flags:"🏳️"},Ut={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"},vt=["","🏻","🏼","🏽","🏾","🏿"],ht=[{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"}],Gt="nice-emoji-picker-recent",Nn=({onSelect:t,showSearch:i=!0,searchPlaceholder:a,showSkinTones:o=!0,defaultSkinTone:r=0,showRecent:h=!0,maxRecent:y=24,recentEmojis:_,onRecentChange:E,categories:C,customEmojis:Z=[],columns:K=8,size:R="md",className:w="",style:Q,"data-testid":ne="nice-emoji-picker"})=>{const{t:ee}=x.Gt(),[te,A]=n.useState(""),[j,L]=n.useState(h?"recent":"smileys"),[f,k]=n.useState(r),[q,p]=n.useState(!1),d=n.useRef(null),[S,V]=n.useState(()=>{if(typeof window>"u")return[];try{return JSON.parse(localStorage.getItem(Gt)||"[]")}catch{return[]}}),B=_??S,b=C??[...h?["recent"]:[],"smileys","people","animals","food","travel","activities","objects","symbols","flags"],s=n.useMemo(()=>{if(!te)return ht;const g=te.toLowerCase();return ht.filter($=>$.name.toLowerCase().includes(g)||$.emoji.includes(g)||$.keywords?.some(v=>v.toLowerCase().includes(g)))},[te]),D=n.useMemo(()=>{const g={};for(const $ of b)$==="recent"?g[$]=B.map(v=>ht.find(T=>T.emoji===v)).filter(v=>v!==void 0).slice(0,y):g[$]=s.filter(v=>v.category===$);return g},[b,s,B,y]),M=n.useCallback((g,$)=>!$||f===0?g:g.replace(/[\u{1F3FB}-\u{1F3FF}]/gu,"")+vt[f],[f]),u=n.useCallback(g=>{const $=M(g.emoji,g.skinTones),v=[g.emoji,...B.filter(T=>T!==g.emoji)].slice(0,y);if(_===void 0){V(v);try{localStorage.setItem(Gt,JSON.stringify(v))}catch{}}E?.(v),t?.($,g)},[M,B,y,_,E,t]),c=n.useCallback(g=>{t?.(`:${g.name}:`,g)},[t]);n.useEffect(()=>{if(!q)return;const g=$=>{d.current&&!d.current.contains($.target)&&p(!1)};return document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},[q]);const l=te?s:D[j]||[];return e.jsxs("div",{className:`nice-emoji-picker nice-emoji-picker--${R} ${w}`,style:Q,"data-testid":ne,children:[i&&e.jsxs("div",{className:"nice-emoji-picker__search",children:[e.jsx("input",{type:"text",value:te,onChange:g=>A(g.target.value),placeholder:a??ee("search","Search emoji..."),className:"nice-emoji-picker__search-input","data-testid":`${ne}-search`}),o&&e.jsxs("div",{className:"nice-emoji-picker__skin-tone-wrapper",children:[e.jsxs("button",{ref:d,type:"button",className:"nice-emoji-picker__skin-tone-btn",onClick:()=>p(!q),title:ee("skinTone","Skin tone"),children:["✋",vt[f]]}),q&&e.jsx("div",{className:"nice-emoji-picker__skin-tone-menu",children:vt.map((g,$)=>e.jsxs("button",{type:"button",className:`nice-emoji-picker__skin-tone-option ${$===f?"nice-emoji-picker__skin-tone-option--selected":""}`,onClick:()=>{k($),p(!1)},children:["✋",g]},$))})]})]}),!te&&e.jsx("div",{className:"nice-emoji-picker__categories",role:"tablist",children:b.map(g=>e.jsx("button",{type:"button",className:`nice-emoji-picker__category-btn ${j===g?"nice-emoji-picker__category-btn--selected":""}`,onClick:()=>L(g),title:Ut[g],role:"tab","aria-selected":j===g,children:Di[g]},g))}),e.jsxs("div",{className:"nice-emoji-picker__grid-container",children:[te?e.jsxs("div",{className:"nice-emoji-picker__section",children:[e.jsx("div",{className:"nice-emoji-picker__section-title",children:ee("searchResults","Search Results")}),e.jsx("div",{className:"nice-emoji-picker__grid",style:{gridTemplateColumns:`repeat(${K}, 1fr)`},children:s.length===0?e.jsx("div",{className:"nice-emoji-picker__empty",children:ee("noEmojis","No emojis found")}):s.map((g,$)=>e.jsx("button",{type:"button",className:"nice-emoji-picker__emoji",onClick:()=>u(g),title:g.name,children:M(g.emoji,g.skinTones)},`${g.emoji}-${$}`))})]}):e.jsxs("div",{className:"nice-emoji-picker__section",children:[e.jsx("div",{className:"nice-emoji-picker__section-title",children:Ut[j]}),e.jsx("div",{className:"nice-emoji-picker__grid",style:{gridTemplateColumns:`repeat(${K}, 1fr)`},children:l.length===0?e.jsx("div",{className:"nice-emoji-picker__empty",children:j==="recent"?ee("noRecent","No recent emojis"):ee("noEmojis","No emojis")}):l.map((g,$)=>e.jsx("button",{type:"button",className:"nice-emoji-picker__emoji",onClick:()=>u(g),title:g.name,children:M(g.emoji,g.skinTones)},`${g.emoji}-${$}`))})]}),Z.length>0&&e.jsxs("div",{className:"nice-emoji-picker__section",children:[e.jsx("div",{className:"nice-emoji-picker__section-title",children:ee("custom","Custom")}),e.jsx("div",{className:"nice-emoji-picker__grid",style:{gridTemplateColumns:`repeat(${K}, 1fr)`},children:Z.map(g=>e.jsx("button",{type:"button",className:"nice-emoji-picker__emoji nice-emoji-picker__emoji--custom",onClick:()=>c(g),title:g.name,children:e.jsx("img",{src:g.url,alt:g.name})},g.id))})]})]})]})};Nn.displayName="NiceEmojiPicker";const Cn=n.forwardRef(({length:t=6,value:i="",onChange:a,masked:o=!1,onComplete:r,label:h,helperText:y,error:_,required:E,disabled:C,readOnly:Z,size:K="md",name:R,id:w,className:Q,style:ne,autoFocus:ee,labelPlacement:te,errorPlacement:A,labelWidth:j,controlWidth:L,loading:f,cellWidth:k,...q},p)=>{const d=x.bc(w),S=n.useRef([]),V=i.padEnd(t,"").slice(0,t).split(""),B=n.useCallback(u=>{const c=Math.max(0,Math.min(t-1,u));S.current[c]?.focus()},[t]),b=n.useCallback(u=>{const c=u.join("");a?.(c),c.length===t&&c.indexOf("")===-1&&/^\d+$/.test(c)&&r?.(c)},[a,r,t]),s=n.useCallback((u,c)=>{const g=c.target.value.replace(/\D/g,"").slice(-1);if(!g)return;const $=[...V];$[u]=g,b($),B(u+1)},[V,b,B]),D=n.useCallback((u,c)=>{if(c.key==="Backspace"){c.preventDefault();const l=[...V];V[u]?(l[u]="",b(l)):u>0&&(l[u-1]="",b(l),B(u-1))}else c.key==="ArrowLeft"?(c.preventDefault(),B(u-1)):c.key==="ArrowRight"&&(c.preventDefault(),B(u+1))},[V,b,B]),M=n.useCallback(u=>{u.preventDefault();const c=u.clipboardData.getData("text").replace(/\D/g,"").slice(0,t);if(!c)return;const l=c.padEnd(t,"").slice(0,t).split("");for(let g=c.length;g<t;g++)l[g]=V[g]||"";b(l),B(Math.min(c.length,t-1))},[t,V,b,B]);return e.jsxs("div",{className:`nice-field nice-field--${K} nice-field--otp${te?` nice-field--label-${te}`:""}${A==="right"?" nice-field--error-right":""} ${f?"nice-field--loading":""} ${Q||""}`,style:{...ne,...j!=null&&{"--nice-field-label-width":typeof j=="number"?`${j}px`:j},...L!=null&&{"--nice-field-control-width":typeof L=="number"?`${L}px`:L},...k!=null&&{"--nice-otp-cell-width":typeof k=="number"?`${k}px`:k}},"aria-busy":f||void 0,...q,children:[h&&e.jsx("label",{htmlFor:`${d}-0`,className:`nice-field__label ${E?"nice-field__label--required":""}`,children:h}),e.jsxs("div",{className:"nice-field__control",children:[e.jsxs("div",{ref:p,className:`nice-otp nice-otp--${K} ${_?"nice-otp--error":""} ${C?"nice-otp--disabled":""}`,onPaste:M,children:[Array.from({length:t},(u,c)=>e.jsx("input",{ref:l=>{S.current[c]=l},id:c===0?`${d}-0`:void 0,className:"nice-otp__digit",type:o?"password":"text",inputMode:"numeric",maxLength:2,value:V[c]||"",disabled:C,readOnly:Z,autoFocus:ee&&c===0,"aria-invalid":!!_,"aria-label":`${c+1}`,onChange:l=>s(c,l),onKeyDown:l=>D(c,l),onFocus:l=>l.target.select()},c)),R&&e.jsx("input",{type:"hidden",name:R,value:i})]}),A==="right"&&_&&e.jsx("div",{id:`${d}-error`,className:"nice-field__error",role:"alert",children:_}),A==="right"&&!_&&y&&e.jsx("div",{id:`${d}-helper`,className:"nice-field__helper",children:y}),f&&e.jsx("span",{className:"nice-field__spinner",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})})]}),A!=="right"&&_&&e.jsx("div",{id:`${d}-error`,className:"nice-field__error",role:"alert",children:_}),A!=="right"&&!_&&y&&e.jsx("div",{id:`${d}-helper`,className:"nice-field__helper",children:y})]})});Cn.displayName="NiceInputOtp";const zi=[{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"}],Xt={rotation:0,flipH:!1,flipV:!1,brightness:100,contrast:100,saturate:100,blur:0,crop:null,annotations:[]},Li=["crop","rotate","flip","brightness","contrast","saturate","blur","annotate"],Sn=n.forwardRef(({src:t,size:i="md",editorSize:a="standard",tools:o=Li,showToolbar:r=!0,showZoom:h=!0,maxUndo:y=30,onSave:_,onCancel:E,onChange:C,width:Z="100%",height:K=500,tutorial:R,className:w,style:Q,id:ne,...ee},te)=>{const A=x.bc(ne),{t:j}=x.Gt(),L=n.useRef(null),f=n.useRef(null),[k,q]=n.useState({...Xt}),[p,d]=n.useState(null),[S,V]=n.useState(!1),[B,b]=n.useState(1),[s,D]=n.useState("rect"),[M,u]=n.useState("var(--nice-danger, #ff0000)"),[c,l]=n.useState({w:0,h:0}),[g,$]=n.useState([]),[v,T]=n.useState([]),[I,H]=n.useState(null),[N,P]=n.useState(null),[z,re]=n.useState(null),me=n.useCallback(O=>{$(G=>[...G.slice(-(y-1)),O]),T([])},[y]),de=n.useCallback(O=>{q(G=>{me(G);const xe={...G,...O};return C?.(xe),xe})},[C,me]),be=n.useCallback(()=>{if(g.length===0)return;const O=g[g.length-1];$(G=>G.slice(0,-1)),T(G=>[...G,k]),q(O),C?.(O)},[g,k,C]),ve=n.useCallback(()=>{if(v.length===0)return;const O=v[v.length-1];T(G=>G.slice(0,-1)),$(G=>[...G,k]),q(O),C?.(O)},[v,k,C]);n.useEffect(()=>{const O=new Image;O.crossOrigin="anonymous",O.onload=()=>{f.current=O,l({w:O.width,h:O.height}),V(!0)},O.src=t},[t]),n.useEffect(()=>{if(!S||!L.current||!f.current)return;const O=L.current,G=O.getContext("2d");if(!G)return;const xe=f.current,le=k.rotation%180!==0,F=le?xe.height:xe.width,J=le?xe.width:xe.height;O.width=F,O.height=J,G.clearRect(0,0,F,J),G.save(),G.filter=`brightness(${k.brightness}%) contrast(${k.contrast}%) saturate(${k.saturate}%) blur(${k.blur}px)`,G.translate(F/2,J/2),G.rotate(k.rotation*Math.PI/180),G.scale(k.flipH?-1:1,k.flipV?-1:1),G.drawImage(xe,-xe.width/2,-xe.height/2),G.restore(),k.annotations.forEach(U=>{switch(G.save(),G.strokeStyle=U.color??"red",G.fillStyle=U.color??"red",G.lineWidth=U.strokeWidth??2,G.font=`${U.fontSize??16}px sans-serif`,U.type){case"text":G.fillText(U.text??"",U.x,U.y);break;case"rect":G.strokeRect(U.x,U.y,U.width??100,U.height??50);break;case"circle":{const se=(U.width??50)/2,ue=(U.height??50)/2;G.beginPath(),G.ellipse(U.x+se,U.y+ue,se,ue,0,0,Math.PI*2),G.stroke();break}case"line":G.beginPath(),G.moveTo(U.x,U.y),G.lineTo(U.x+(U.width??100),U.y+(U.height??0)),G.stroke();break;case"arrow":{const se=U.x+(U.width??100),ue=U.y+(U.height??0);G.beginPath(),G.moveTo(U.x,U.y),G.lineTo(se,ue),G.stroke();const je=Math.atan2(ue-U.y,se-U.x),we=10;G.beginPath(),G.moveTo(se,ue),G.lineTo(se-we*Math.cos(je-.4),ue-we*Math.sin(je-.4)),G.lineTo(se-we*Math.cos(je+.4),ue-we*Math.sin(je+.4)),G.closePath(),G.fill();break}}G.restore()}),N&&(G.save(),G.fillStyle="var(--nice-overlay-50, rgba(0, 0, 0, 0.5))",G.fillRect(0,0,F,J),G.clearRect(N.x,N.y,N.w,N.h),G.strokeStyle="var(--nice-bg-primary, #fff)",G.lineWidth=2,G.setLineDash([5,5]),G.strokeRect(N.x,N.y,N.w,N.h),G.restore())},[S,k,N]);const _e=n.useCallback(O=>{if(!L.current)return;const G=L.current.getBoundingClientRect(),xe=L.current.width/G.width,le=L.current.height/G.height,F=(O.clientX-G.left)*xe,J=(O.clientY-G.top)*le;p==="crop"?H({startX:F,startY:J}):p==="annotate"&&re({startX:F,startY:J})},[p]),fe=n.useCallback(O=>{if(!L.current)return;const G=L.current.getBoundingClientRect(),xe=L.current.width/G.width,le=L.current.height/G.height,F=(O.clientX-G.left)*xe,J=(O.clientY-G.top)*le;I&&P({x:Math.min(I.startX,F),y:Math.min(I.startY,J),w:Math.abs(F-I.startX),h:Math.abs(J-I.startY)})},[I]),oe=n.useCallback(O=>{if(I&&N&&N.w>5&&N.h>5&&de({crop:{x:N.x,y:N.y,width:N.w,height:N.h}}),H(null),z&&L.current){const G=L.current.getBoundingClientRect(),xe=L.current.width/G.width,le=L.current.height/G.height,F=(O.clientX-G.left)*xe,J=(O.clientY-G.top)*le,U=F-z.startX,se=J-z.startY;if(Math.abs(U)>3||Math.abs(se)>3||s==="text"){const ue={type:s,x:z.startX,y:z.startY,width:Math.abs(U)||100,height:Math.abs(se)||50,color:M,strokeWidth:2,text:s==="text"?prompt(j("imageEditor.annotationText","Text:"))??"":void 0};de({annotations:[...k.annotations,ue]})}re(null)}},[I,N,z,s,M,k.annotations,de,j]),he=n.useCallback(()=>{if(!k.crop||!L.current)return;const O=L.current,G=O.getContext("2d");if(!G)return;const{x:xe,y:le,width:F,height:J}=k.crop,U=G.getImageData(xe,le,F,J);O.width=F,O.height=J,G.putImageData(U,0,0),P(null),d(null)},[k.crop]),ie=n.useCallback(()=>{if(!L.current)return;const O=L.current.toDataURL("image/png");_?.(O,k)},[_,k]),ce=n.useCallback(()=>{q({...Xt}),P(null),d(null)},[]);n.useMemo(()=>`brightness(${k.brightness}%) contrast(${k.contrast}%) saturate(${k.saturate}%) blur(${k.blur}px)`,[k.brightness,k.contrast,k.saturate,k.blur]);const ge=r?e.jsxs("div",{className:"nice-image-editor__toolbar",role:"toolbar",children:[e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:be,disabled:g.length===0,title:j("imageEditor.undo","Undo"),"aria-label":j("imageEditor.undo","Undo"),children:e.jsx(x.oa,{name:"reply",size:16})}),e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:ve,disabled:v.length===0,title:j("imageEditor.redo","Redo"),"aria-label":j("imageEditor.redo","Redo"),children:e.jsx(x.oa,{name:"forward",size:16})}),e.jsx("span",{className:"nice-image-editor__sep"}),o.includes("rotate")&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>de({rotation:(k.rotation-90+360)%360}),title:j("imageEditor.rotateLeft","Rotate left"),"aria-label":j("imageEditor.rotateLeft","Rotate left"),children:e.jsx(x.oa,{name:"reply",size:16})}),e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>de({rotation:(k.rotation+90)%360}),title:j("imageEditor.rotateRight","Rotate right"),"aria-label":j("imageEditor.rotateRight","Rotate right"),children:e.jsx(x.oa,{name:"forward",size:16})})]}),o.includes("flip")&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>de({flipH:!k.flipH}),title:j("imageEditor.flipH","Flip horizontal"),"aria-label":j("imageEditor.flipH","Flip horizontal"),children:e.jsx(x.oa,{name:"shuffle",size:16})}),e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>de({flipV:!k.flipV}),title:j("imageEditor.flipV","Flip vertical"),"aria-label":j("imageEditor.flipV","Flip vertical"),children:e.jsx(x.oa,{name:"shuffle",size:16})})]}),o.includes("crop")&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:`nice-image-editor__btn ${p==="crop"?"nice-image-editor__btn--active":""}`,onClick:()=>d(p==="crop"?null:"crop"),title:j("imageEditor.crop","Crop"),"aria-label":j("imageEditor.crop","Crop"),children:e.jsx(x.oa,{name:"box",size:16})}),p==="crop"&&k.crop&&e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:he,title:j("imageEditor.applyCrop","Apply crop"),"aria-label":j("imageEditor.applyCrop","Apply crop"),children:e.jsx(x.oa,{name:"check",size:16})})]}),o.includes("brightness")&&e.jsxs("label",{className:"nice-image-editor__slider-label",title:j("imageEditor.brightness","Brightness"),children:[e.jsx(x.oa,{name:"lightbulb",size:16}),e.jsx("input",{type:"range",min:0,max:200,value:k.brightness,onChange:O=>de({brightness:Number(O.target.value)}),className:"nice-image-editor__slider",title:j("imageEditor.brightness","Brightness")})]}),o.includes("contrast")&&e.jsxs("label",{className:"nice-image-editor__slider-label",title:j("imageEditor.contrast","Contrast"),children:[e.jsx(x.oa,{name:"circle",size:16}),e.jsx("input",{type:"range",min:0,max:200,value:k.contrast,onChange:O=>de({contrast:Number(O.target.value)}),className:"nice-image-editor__slider",title:j("imageEditor.contrast","Contrast")})]}),o.includes("saturate")&&e.jsxs("label",{className:"nice-image-editor__slider-label",title:j("imageEditor.saturate","Saturation"),children:[e.jsx(x.oa,{name:"palette",size:16}),e.jsx("input",{type:"range",min:0,max:200,value:k.saturate,onChange:O=>de({saturate:Number(O.target.value)}),className:"nice-image-editor__slider",title:j("imageEditor.saturate","Saturation")})]}),o.includes("blur")&&e.jsxs("label",{className:"nice-image-editor__slider-label",title:j("imageEditor.blur","Blur"),children:[e.jsx(x.oa,{name:"eye-off",size:16}),e.jsx("input",{type:"range",min:0,max:20,step:.5,value:k.blur,onChange:O=>de({blur:Number(O.target.value)}),className:"nice-image-editor__slider",title:j("imageEditor.blur","Blur")})]}),o.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 ${p==="annotate"?"nice-image-editor__btn--active":""}`,onClick:()=>d(p==="annotate"?null:"annotate"),title:j("imageEditor.annotate","Annotate"),"aria-label":j("imageEditor.annotate","Annotate"),children:e.jsx(x.oa,{name:"edit",size:16})}),p==="annotate"&&e.jsxs(e.Fragment,{children:[e.jsxs("select",{className:"nice-image-editor__select",value:s,onChange:O=>D(O.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:M,onChange:O=>u(O.target.value),className:"nice-image-editor__color",title:j("imageEditor.color","Color")}),k.annotations.length>0&&e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>de({annotations:k.annotations.slice(0,-1)}),title:j("imageEditor.removeLastAnnotation","Remove last"),"aria-label":j("imageEditor.removeLastAnnotation","Remove last"),children:e.jsx(x.oa,{name:"trash",size:16})})]})]}),e.jsx("span",{className:"nice-image-editor__sep"}),e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:ce,title:j("imageEditor.reset","Reset"),"aria-label":j("imageEditor.reset","Reset"),children:e.jsx(x.oa,{name:"refresh",size:16})}),_&&e.jsx("button",{type:"button",className:"nice-image-editor__btn nice-image-editor__btn--save",onClick:ie,children:j("imageEditor.save","Save")}),E&&e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:E,children:j("imageEditor.cancel","Cancel")})]}):void 0,Y=h?e.jsxs("div",{className:"nice-image-editor__footer",children:[e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>b(O=>Math.max(.1,O-.1)),title:"Zoom out","aria-label":"Zoom out",children:e.jsx(x.oa,{name:"minus",size:16})}),e.jsxs("span",{style:{fontSize:"0.85em",minWidth:40,textAlign:"center"},children:[Math.round(B*100),"%"]}),e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>b(O=>Math.min(5,O+.1)),title:"Zoom in","aria-label":"Zoom in",children:e.jsx(x.oa,{name:"plus",size:16})}),e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>b(1),title:"Reset zoom",children:"1:1"}),e.jsx("span",{style:{flex:1}}),e.jsxs("span",{style:{fontSize:"0.8em",color:"var(--nice-text-secondary, #666)"},children:[c.w,"×",c.h,"px · ",k.rotation,"°"]})]}):void 0;return e.jsx(Qt.NiceAppShell,{ref:te,flush:!0,id:A,className:`nice-image-editor nice-image-editor--${i} nice-editor--${a} ${w??""}`,style:{...Q,width:Z,height:K},toolbar:ge,statusBar:Y,children:e.jsxs("div",{className:"nice-image-editor__canvas-wrap",style:{position:"relative"},role:"application","aria-label":j("imageEditor.label","Image Editor"),...ee,children:[e.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:20},children:e.jsx(x.Ql,{steps:x.Yl(R,zi)})}),e.jsx("canvas",{ref:L,className:"nice-image-editor__canvas",onMouseDown:_e,onMouseMove:fe,onMouseUp:oe,style:{cursor:p==="crop"||p==="annotate"?"crosshair":"default",transform:`scale(${B})`,transformOrigin:"center center"}})]})})});Sn.displayName="NiceImageEditor";const Pi={strokeColor:"#ff3333",fillColor:"transparent",strokeWidth:2,opacity:1,fontSize:16,fontFamily:"sans-serif"};function Bi(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(a=>a.id===i.id?{...a,...i.updates}:a),past:[...t.past,t.annotations],future:[]};case"DELETE_ANNOTATION":return{...t,annotations:t.annotations.filter(a=>a.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 a=t.past[t.past.length-1];return{...t,annotations:a,past:t.past.slice(0,-1),future:[t.annotations,...t.future]}}case"REDO":{if(t.future.length===0)return t;const a=t.future[0];return{...t,annotations:a,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 Hi=0;function Oi(){return`ann-${Date.now()}-${Hi++}`}function Fi(t){const{style:i}=t,a=`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}" ${a} />`;case"ellipse":{const o=t.x+t.width/2,r=t.y+t.height/2;return`<ellipse cx="${o}" cy="${r}" rx="${t.width/2}" ry="${t.height/2}" ${a} />`}case"arrow":{const o=t,r=Math.atan2(o.endY-o.y,o.endX-o.x),h=12,y=o.endX-h*Math.cos(r-Math.PI/6),_=o.endY-h*Math.sin(r-Math.PI/6),E=o.endX-h*Math.cos(r+Math.PI/6),C=o.endY-h*Math.sin(r+Math.PI/6);return`<line x1="${o.x}" y1="${o.y}" x2="${o.endX}" y2="${o.endY}" ${a} />
|
|
300
|
+
<polygon points="${o.endX},${o.endY} ${y},${_} ${E},${C}" fill="${i.strokeColor}" opacity="${i.opacity}" />`}case"line":{const o=t;return`<line x1="${o.x}" y1="${o.y}" x2="${o.endX}" y2="${o.endY}" ${a} />`}case"text":{const o=t;return`<text x="${o.x}" y="${o.y+(o.style.fontSize??16)}" fill="${i.strokeColor}" font-size="${i.fontSize}" font-family="${i.fontFamily}" opacity="${i.opacity}">${Yi(o.text)}</text>`}case"freehand":{const o=t;return o.points.length<2?"":`<path d="${o.points.map((h,y)=>`${y===0?"M":"L"}${h.x},${h.y}`).join(" ")}" ${a} fill="none" />`}case"blur":{const o=t,r=`blur-${o.id}`;return`<defs><filter id="${r}"><feGaussianBlur stdDeviation="${o.intensity??5}" /></filter></defs>
|
|
301
|
+
<rect x="${o.x}" y="${o.y}" width="${o.width}" height="${o.height}" fill="transparent" stroke="none" filter="url(#${r})" />`}default:return""}}function Yi(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}const $n=n.forwardRef(({src:t,alt:i="Annotatable image",annotations:a,activeTool:o,defaultStyle:r,onAnnotationsChange:h,className:y,readOnly:_=!1,minZoom:E=.1,maxZoom:C=5},Z)=>{const K=n.useRef(null),R=n.useRef(null),w=n.useRef(null),[Q,ne]=n.useState(!1),[ee,te]=n.useState({width:0,height:0}),[A,j]=n.useReducer(Bi,{annotations:a??[],selectedId:null,activeTool:o??"select",style:{...Pi,...r},zoom:1,panX:0,panY:0,past:[],future:[]});n.useEffect(()=>{o&&j({type:"SET_TOOL",tool:o})},[o]),n.useEffect(()=>{h?.(A.annotations)},[A.annotations,h]),n.useEffect(()=>{const b=new Image;b.crossOrigin="anonymous",b.onload=()=>{w.current=b,te({width:b.naturalWidth,height:b.naturalHeight}),ne(!0)},b.src=t},[t]);const L=n.useRef({isDrawing:!1,startX:0,startY:0,currentAnnotation:null,freehandPoints:[]}),f=n.useCallback((b,s)=>{const D=K.current;if(!D)return{x:0,y:0};const M=D.getBoundingClientRect();return{x:(b-M.left-A.panX)/A.zoom,y:(s-M.top-A.panY)/A.zoom}},[A.zoom,A.panX,A.panY]),k=n.useCallback(()=>{const b=K.current,s=b?.getContext("2d"),D=w.current;if(!b||!s||!D||!Q)return;b.width=R.current?.clientWidth??D.naturalWidth,b.height=R.current?.clientHeight??D.naturalHeight,s.clearRect(0,0,b.width,b.height),s.save(),s.translate(A.panX,A.panY),s.scale(A.zoom,A.zoom),s.drawImage(D,0,0);for(const u of A.annotations){switch(s.save(),s.globalAlpha=u.style.opacity,s.strokeStyle=u.style.strokeColor,s.fillStyle=u.style.fillColor,s.lineWidth=u.style.strokeWidth,u.tool){case"rectangle":s.strokeRect(u.x,u.y,u.width,u.height),u.style.fillColor!=="transparent"&&s.fillRect(u.x,u.y,u.width,u.height);break;case"ellipse":{s.beginPath(),s.ellipse(u.x+u.width/2,u.y+u.height/2,Math.abs(u.width/2),Math.abs(u.height/2),0,0,Math.PI*2),s.stroke(),u.style.fillColor!=="transparent"&&s.fill();break}case"arrow":{const c=u;s.beginPath(),s.moveTo(c.x,c.y),s.lineTo(c.endX,c.endY),s.stroke();const l=Math.atan2(c.endY-c.y,c.endX-c.x),g=12;s.beginPath(),s.moveTo(c.endX,c.endY),s.lineTo(c.endX-g*Math.cos(l-Math.PI/6),c.endY-g*Math.sin(l-Math.PI/6)),s.lineTo(c.endX-g*Math.cos(l+Math.PI/6),c.endY-g*Math.sin(l+Math.PI/6)),s.closePath(),s.fillStyle=u.style.strokeColor,s.fill();break}case"line":{const c=u;s.beginPath(),s.moveTo(c.x,c.y),s.lineTo(c.endX,c.endY),s.stroke();break}case"text":{const c=u;s.font=`${c.style.fontSize??16}px ${c.style.fontFamily??"sans-serif"}`,s.fillStyle=c.style.strokeColor,s.fillText(c.text,c.x,c.y+(c.style.fontSize??16));break}case"freehand":{const c=u;if(c.points.length<2)break;s.beginPath(),s.moveTo(c.points[0].x,c.points[0].y);for(let l=1;l<c.points.length;l++)s.lineTo(c.points[l].x,c.points[l].y);s.stroke();break}case"blur":{const c=u;s.filter=`blur(${c.intensity??5}px)`,s.drawImage(D,c.x,c.y,c.width,c.height,c.x,c.y,c.width,c.height),s.filter="none";break}}u.id===A.selectedId&&(s.strokeStyle="#4488ff",s.lineWidth=1,s.setLineDash([4,4]),s.strokeRect(u.x-2,u.y-2,u.width+4,u.height+4),s.setLineDash([])),s.restore()}const M=L.current;if(M.isDrawing&&M.currentAnnotation){s.save();const u=M.currentAnnotation;if(s.globalAlpha=u.style.opacity,s.strokeStyle=u.style.strokeColor,s.lineWidth=u.style.strokeWidth,s.setLineDash([6,3]),u.tool==="freehand"){const c=u;if(c.points.length>=2){s.beginPath(),s.moveTo(c.points[0].x,c.points[0].y);for(let l=1;l<c.points.length;l++)s.lineTo(c.points[l].x,c.points[l].y);s.stroke()}}else if(u.tool==="rectangle")s.strokeRect(u.x,u.y,u.width,u.height);else if(u.tool==="ellipse")s.beginPath(),s.ellipse(u.x+u.width/2,u.y+u.height/2,Math.abs(u.width/2),Math.abs(u.height/2),0,0,Math.PI*2),s.stroke();else if(u.tool==="arrow"||u.tool==="line"){const c=u;s.beginPath(),s.moveTo(c.x,c.y),s.lineTo(c.endX,c.endY),s.stroke()}s.restore()}s.restore()},[A,Q]);n.useEffect(()=>{k()},[k]);const q=n.useCallback(b=>{if(_)return;const s=f(b.clientX,b.clientY),D=A.activeTool;if(D==="select"){const c=[...A.annotations].reverse().find(l=>l.tool==="freehand"?!1:s.x>=l.x&&s.x<=l.x+l.width&&s.y>=l.y&&s.y<=l.y+l.height);j({type:"SELECT",id:c?.id??null});return}const M=L.current;M.isDrawing=!0,M.startX=s.x,M.startY=s.y;const u={id:Oi(),style:{...A.style},x:s.x,y:s.y,width:0,height:0};switch(D){case"rectangle":M.currentAnnotation={...u,tool:"rectangle"};break;case"ellipse":M.currentAnnotation={...u,tool:"ellipse"};break;case"arrow":M.currentAnnotation={...u,tool:"arrow",endX:s.x,endY:s.y};break;case"line":M.currentAnnotation={...u,tool:"line",endX:s.x,endY:s.y};break;case"text":M.currentAnnotation={...u,tool:"text",text:"Text",width:100,height:A.style.fontSize??16};break;case"freehand":M.freehandPoints=[s],M.currentAnnotation={...u,tool:"freehand",points:[s]};break;case"blur":M.currentAnnotation={...u,tool:"blur",intensity:5};break}},[_,f,A.activeTool,A.style,A.annotations]),p=n.useCallback(b=>{const s=L.current;if(!s.isDrawing||!s.currentAnnotation)return;const D=f(b.clientX,b.clientY),M=s.currentAnnotation;if(M.tool==="freehand"){s.freehandPoints.push(D),M.points=[...s.freehandPoints];const u=s.freehandPoints.map(l=>l.x),c=s.freehandPoints.map(l=>l.y);M.x=Math.min(...u),M.y=Math.min(...c),M.width=Math.max(...u)-M.x,M.height=Math.max(...c)-M.y}else if(M.tool==="arrow"||M.tool==="line")M.endX=D.x,M.endY=D.y,M.width=Math.abs(D.x-s.startX),M.height=Math.abs(D.y-s.startY);else{const u=Math.min(s.startX,D.x),c=Math.min(s.startY,D.y);M.x=u,M.y=c,M.width=Math.abs(D.x-s.startX),M.height=Math.abs(D.y-s.startY)}k()},[f,k]),d=n.useCallback(()=>{const b=L.current;if(!b.isDrawing||!b.currentAnnotation)return;const s=b.currentAnnotation;(s.tool==="text"||s.tool==="freehand"||Math.abs(s.width)>2||Math.abs(s.height)>2)&&j({type:"ADD_ANNOTATION",annotation:s}),b.isDrawing=!1,b.currentAnnotation=null,b.freehandPoints=[]},[]),S=n.useCallback(b=>{b.preventDefault();const s=b.deltaY>0?.9:1.1,D=Math.max(E,Math.min(C,A.zoom*s));j({type:"SET_ZOOM",zoom:D})},[A.zoom,E,C]);n.useEffect(()=>{if(_)return;const b=s=>{(s.metaKey||s.ctrlKey)&&s.key==="z"&&!s.shiftKey?(s.preventDefault(),j({type:"UNDO"})):(s.metaKey||s.ctrlKey)&&(s.key==="y"||s.key==="z"&&s.shiftKey)?(s.preventDefault(),j({type:"REDO"})):(s.key==="Delete"||s.key==="Backspace")&&A.selectedId&&j({type:"DELETE_ANNOTATION",id:A.selectedId})};return document.addEventListener("keydown",b),()=>document.removeEventListener("keydown",b)},[_,A.selectedId]),n.useImperativeHandle(Z,()=>({exportAsDataURL:async(b="png",s=.92)=>{const D=document.createElement("canvas"),M=w.current;if(!M)return"";D.width=M.naturalWidth,D.height=M.naturalHeight;const u=D.getContext("2d");u.drawImage(M,0,0);for(const c of A.annotations){if(u.save(),u.globalAlpha=c.style.opacity,u.strokeStyle=c.style.strokeColor,u.fillStyle=c.style.fillColor,u.lineWidth=c.style.strokeWidth,c.tool==="rectangle")u.strokeRect(c.x,c.y,c.width,c.height);else if(c.tool==="ellipse")u.beginPath(),u.ellipse(c.x+c.width/2,c.y+c.height/2,Math.abs(c.width/2),Math.abs(c.height/2),0,0,Math.PI*2),u.stroke();else if(c.tool==="freehand"){const l=c;if(l.points.length>=2){u.beginPath(),u.moveTo(l.points[0].x,l.points[0].y);for(let g=1;g<l.points.length;g++)u.lineTo(l.points[g].x,l.points[g].y);u.stroke()}}else if(c.tool==="text"){const l=c;u.font=`${l.style.fontSize??16}px ${l.style.fontFamily??"sans-serif"}`,u.fillStyle=l.style.strokeColor,u.fillText(l.text,l.x,l.y+(l.style.fontSize??16))}u.restore()}return D.toDataURL(`image/${b}`,s)},exportAnnotations:()=>[...A.annotations],importAnnotations:b=>{j({type:"SET_ANNOTATIONS",annotations:b})},exportAsSVG:()=>{const{width:b,height:s}=ee,D=A.annotations.map(Fi);return`<svg xmlns="http://www.w3.org/2000/svg" width="${b}" height="${s}" viewBox="0 0 ${b} ${s}">
|
|
302
|
+
${D.join(`
|
|
303
|
+
`)}
|
|
304
|
+
</svg>`},undo:()=>j({type:"UNDO"}),redo:()=>j({type:"REDO"}),setZoom:b=>{j({type:"SET_ZOOM",zoom:Math.max(E,Math.min(C,b))})},fitToScreen:()=>{const b=R.current,s=w.current;if(!b||!s)return;const D=b.clientWidth/s.naturalWidth,M=b.clientHeight/s.naturalHeight,u=Math.min(D,M,1);j({type:"SET_ZOOM",zoom:u}),j({type:"SET_PAN",panX:0,panY:0})},clear:()=>j({type:"CLEAR"})}),[A.annotations,ee,E,C]);const V=n.useCallback(b=>{if(b.touches.length!==1)return;const s=b.touches[0];q({clientX:s.clientX,clientY:s.clientY,preventDefault:()=>{}})},[q]),B=n.useCallback(b=>{if(b.touches.length!==1)return;const s=b.touches[0];p({clientX:s.clientX,clientY:s.clientY})},[p]);return e.jsx("div",{ref:R,className:`nice-image-annotator ${y??""}`,style:{position:"relative",overflow:"hidden",width:"100%",height:"100%"},children:e.jsx("canvas",{ref:K,className:"nice-image-annotator__canvas",style:{cursor:A.activeTool==="select"?"default":"crosshair"},onMouseDown:q,onMouseMove:p,onMouseUp:d,onMouseLeave:d,onWheel:S,onTouchStart:V,onTouchMove:B,onTouchEnd:d,role:"img","aria-label":i})})});$n.displayName="NiceImageAnnotator";const Ki=[{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"}],En=[{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}],Mn=({src:t,initialCrop:i={x:10,y:10,width:80,height:80},initialRotation:a=0,initialZoom:o=1,aspectRatios:r=En,defaultAspectRatio:h="free",customAspectRatio:y,showRotation:_=!0,showFlip:E=!0,showZoom:C=!0,minZoom:Z=.5,maxZoom:K=3,zoomStep:R=.1,showGrid:w=!0,overlayColor:Q="var(--nice-overlay-50, rgba(0, 0, 0, 0.5))",toolbarPosition:ne="bottom",toolbarCollapsible:ee=!1,defaultToolbarCollapsed:te=!1,onChange:A,tutorial:j,className:L="",style:f,"data-testid":k="nice-crop-editor"})=>{const{t:q}=x.Gt(),p=n.useRef(null),d=n.useRef(null),[S,V]=n.useState(i),[B,b]=n.useState(a),[s,D]=n.useState(o),[M,u]=n.useState(!1),[c,l]=n.useState(!1),[g,$]=n.useState(h),[v,T]=n.useState(te),[I,H]=n.useState(!1),[N,P]=n.useState({x:0,y:0,crop:S}),z=g==="custom"?y:r.find(Y=>Y.value===g)?.ratio;n.useEffect(()=>{A?.({crop:S,rotation:B,flipH:M,flipV:c,zoom:s})},[S,B,M,c,s,A]);const re=n.useCallback((Y,O)=>{if(!z)return Y;const G=p.current?.clientWidth??400,xe=p.current?.clientHeight??300,le=Y.width/100*G,F=Y.height/100*xe,J=le/F;if(Math.abs(J-z)<.01)return Y;if(O?.includes("e")||O?.includes("w")){const se=le/z/xe*100;return{...Y,height:Math.min(100-Y.y,Math.max(5,se))}}else if(O?.includes("n")||O?.includes("s")){const se=F*z/G*100;return{...Y,width:Math.min(100-Y.x,Math.max(5,se))}}else{const se=le/z/xe*100;return{...Y,height:Math.min(100-Y.y,Math.max(5,se))}}},[z]),me=n.useCallback((Y,O)=>{O===!1||(Y.preventDefault(),Y.stopPropagation(),H(O),!p.current?.getBoundingClientRect())||P({x:Y.clientX,y:Y.clientY,crop:{...S}})},[S]),de=n.useCallback(Y=>{if(!I||!p.current)return;const O=p.current.getBoundingClientRect(),G=(Y.clientX-N.x)/O.width*100,xe=(Y.clientY-N.y)/O.height*100;let le={...N.crop};if(I==="crop")le.x=Math.max(0,Math.min(100-le.width,N.crop.x+G)),le.y=Math.max(0,Math.min(100-le.height,N.crop.y+xe));else{switch(I){case"resize-nw":le.x=Math.max(0,Math.min(N.crop.x+N.crop.width-5,N.crop.x+G)),le.y=Math.max(0,Math.min(N.crop.y+N.crop.height-5,N.crop.y+xe)),le.width=N.crop.width-(le.x-N.crop.x),le.height=N.crop.height-(le.y-N.crop.y);break;case"resize-ne":le.y=Math.max(0,Math.min(N.crop.y+N.crop.height-5,N.crop.y+xe)),le.width=Math.max(5,Math.min(100-le.x,N.crop.width+G)),le.height=N.crop.height-(le.y-N.crop.y);break;case"resize-sw":le.x=Math.max(0,Math.min(N.crop.x+N.crop.width-5,N.crop.x+G)),le.width=N.crop.width-(le.x-N.crop.x),le.height=Math.max(5,Math.min(100-le.y,N.crop.height+xe));break;case"resize-se":le.width=Math.max(5,Math.min(100-le.x,N.crop.width+G)),le.height=Math.max(5,Math.min(100-le.y,N.crop.height+xe));break;case"resize-n":le.y=Math.max(0,Math.min(N.crop.y+N.crop.height-5,N.crop.y+xe)),le.height=N.crop.height-(le.y-N.crop.y);break;case"resize-s":le.height=Math.max(5,Math.min(100-le.y,N.crop.height+xe));break;case"resize-e":le.width=Math.max(5,Math.min(100-le.x,N.crop.width+G));break;case"resize-w":le.x=Math.max(0,Math.min(N.crop.x+N.crop.width-5,N.crop.x+G)),le.width=N.crop.width-(le.x-N.crop.x);break}le=re(le,I.replace("resize-",""))}V(le)},[I,N,re]),be=n.useCallback(()=>{H(!1)},[]);n.useEffect(()=>{if(I)return document.addEventListener("mousemove",de),document.addEventListener("mouseup",be),()=>{document.removeEventListener("mousemove",de),document.removeEventListener("mouseup",be)}},[I,de,be]);const ve=n.useCallback(()=>{b(Y=>(Y-90+360)%360)},[]),_e=n.useCallback(()=>{b(Y=>(Y+90)%360)},[]),fe=n.useCallback(()=>{u(Y=>!Y)},[]),oe=n.useCallback(()=>{l(Y=>!Y)},[]),he=n.useCallback(()=>{V(i),b(a),D(o),u(!1),l(!1),$(h)},[i,a,o,h]);n.useEffect(()=>{V(Y=>re(Y))},[g,re]);const ie=`scale(${s}) rotate(${B}deg) scaleX(${M?-1:1}) scaleY(${c?-1:1})`,ce=ne==="top"?"column-reverse":ne==="left"?"row-reverse":ne==="right"?"row":"column",ge=ne==="left"||ne==="right";return e.jsxs("div",{className:`nice-crop-editor nice-crop-editor--toolbar-${ne} ${L}`,style:{position:"relative",display:"flex",flexDirection:ce,gap:12,...f},"data-testid":k,children:[e.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:20},children:e.jsx(x.Ql,{steps:x.Yl(j,Ki)})}),e.jsxs("div",{ref:p,className:"nice-crop-editor__container","data-testid":`${k}-container`,children:[e.jsx("img",{ref:d,src:t,alt:"",className:"nice-crop-editor__image",style:{transform:ie},draggable:!1}),e.jsxs("div",{className:"nice-crop-editor__overlay",style:{backgroundColor:Q},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:Y=>me(Y,"crop"),"data-testid":`${k}-crop-area`,children:[w&&e.jsxs("div",{className:"nice-crop-editor__grid",children:[e.jsx("div",{className:"nice-crop-editor__grid-line nice-crop-editor__grid-line--h1"}),e.jsx("div",{className:"nice-crop-editor__grid-line nice-crop-editor__grid-line--h2"}),e.jsx("div",{className:"nice-crop-editor__grid-line nice-crop-editor__grid-line--v1"}),e.jsx("div",{className:"nice-crop-editor__grid-line nice-crop-editor__grid-line--v2"})]}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--nw",onMouseDown:Y=>me(Y,"resize-nw")}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--ne",onMouseDown:Y=>me(Y,"resize-ne")}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--sw",onMouseDown:Y=>me(Y,"resize-sw")}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--se",onMouseDown:Y=>me(Y,"resize-se")}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--n",onMouseDown:Y=>me(Y,"resize-n")}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--s",onMouseDown:Y=>me(Y,"resize-s")}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--e",onMouseDown:Y=>me(Y,"resize-e")}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--w",onMouseDown:Y=>me(Y,"resize-w")})]})]}),e.jsxs("div",{className:`nice-crop-editor__controls ${v?"nice-crop-editor__controls--collapsed":""}`,style:{display:"flex",flexDirection:ge?"column":"row",flexWrap:ge?"nowrap":"wrap",gap:8,alignItems:ge?"stretch":"center",flexShrink:0},children:[ee&&e.jsx("button",{type:"button",className:"nice-crop-editor__toolbar-toggle","aria-expanded":!v,"aria-label":v?"Show toolbar":"Hide toolbar",onClick:()=>T(Y=>!Y),style:{alignSelf:"flex-start",background:"var(--nice-bg-secondary)",border:"1px solid var(--nice-border-color)",borderRadius:4,padding:"2px 8px",cursor:"pointer",color:"var(--nice-text-primary)",fontSize:12},children:e.jsx(x.oa,{name:v?"chevron-right":"chevron-down",size:14})}),!v&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"nice-crop-editor__control-group",children:[e.jsx("label",{className:"nice-crop-editor__label",children:q("aspectRatio","Aspect Ratio")}),e.jsx("div",{className:"nice-crop-editor__aspect-buttons",children:r.map(Y=>e.jsx("button",{type:"button",className:`nice-crop-editor__aspect-btn ${g===Y.value?"nice-crop-editor__aspect-btn--selected":""}`,onClick:()=>$(Y.value),title:Y.label,children:Y.label},Y.value))})]}),C&&e.jsxs("div",{className:"nice-crop-editor__control-group",children:[e.jsxs("label",{className:"nice-crop-editor__label",children:[q("zoom","Zoom"),": ",Math.round(s*100),"%"]}),e.jsx("input",{type:"range",className:"nice-crop-editor__slider",min:Z,max:K,step:R,value:s,onChange:Y=>D(parseFloat(Y.target.value)),"data-testid":`${k}-zoom`})]}),e.jsxs("div",{className:"nice-crop-editor__control-group nice-crop-editor__control-group--row",children:[_&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"nice-crop-editor__btn",onClick:ve,title:q("rotateLeft","Rotate Left"),"aria-label":q("rotateLeft","Rotate Left"),children:e.jsx(x.oa,{name:"reply",size:16})}),e.jsx("button",{type:"button",className:"nice-crop-editor__btn",onClick:_e,title:q("rotateRight","Rotate Right"),"aria-label":q("rotateRight","Rotate Right"),children:e.jsx(x.oa,{name:"forward",size:16})})]}),E&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:`nice-crop-editor__btn ${M?"nice-crop-editor__btn--active":""}`,onClick:fe,title:q("flipHorizontal","Flip Horizontal"),"aria-label":q("flipHorizontal","Flip Horizontal"),children:e.jsx(x.oa,{name:"shuffle",size:16})}),e.jsx("button",{type:"button",className:`nice-crop-editor__btn ${c?"nice-crop-editor__btn--active":""}`,onClick:oe,title:q("flipVertical","Flip Vertical"),"aria-label":q("flipVertical","Flip Vertical"),children:e.jsx(x.oa,{name:"shuffle",size:16})})]}),e.jsx("button",{type:"button",className:"nice-crop-editor__btn nice-crop-editor__btn--reset",onClick:he,title:q("reset","Reset"),"aria-label":q("reset","Reset"),children:e.jsx(x.oa,{name:"refresh",size:16})})]})]})]})]})};Mn.displayName="NiceCropEditor";const Ui=[{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"}],Gi=["highlight","underline","strikethrough","freehand","text","rect","arrow"],Xi={highlight:"edit",underline:"type",strikethrough:"type",freehand:"edit",text:"type",rect:"box",arrow:"arrow-right",stamp:"tag"},Rn=n.forwardRef(({label:t,helperText:i,error:a,required:o,disabled:r,readOnly:h,size:y="md",id:_,className:E,style:C,accessMode:Z,src:K,annotations:R=[],onAnnotationsChange:w,activeTool:Q,onToolChange:ne,currentPage:ee=1,onPageChange:te,totalPages:A=1,defaultColor:j="var(--nice-warning, #ffff00)",tools:L=Gi,author:f,zoom:k=1,onZoomChange:q,onAnnotationClick:p,onAnnotationDelete:d,tutorial:S},V)=>{const B=x.Dc(Z,_),b=B==="hidden";B==="disabled"&&(r=!0),B==="readOnly"&&(h=!0);const{t:s}=x.Gt(),D=x.bc(_),M=R.filter(I=>I.page===ee),u=n.useCallback(I=>{ne?.(Q===I?null:I)},[Q,ne]),c=n.useCallback(I=>{if(h||!Q||Q==="freehand")return;const H=I.currentTarget.getBoundingClientRect(),N=(I.clientX-H.left)/H.width,P=(I.clientY-H.top)/H.height,z={id:`ann-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,tool:Q,page:ee,x:N,y:P,color:j,author:f,createdAt:new Date().toISOString(),text:Q==="text"?"":void 0};w?.([...R,z])},[h,Q,ee,j,f,R,w]);if(b)return null;const l=t?e.jsxs("div",{className:"nice-pdf-annotation__label",children:[t,o&&e.jsx("span",{className:"nice-required",children:"*"})]}):void 0,g=h?void 0:e.jsxs("div",{className:"nice-pdf-annotation__toolbar",children:[L.map(I=>e.jsx("button",{type:"button",className:`nice-pdf-annotation__tool-btn${Q===I?" nice-pdf-annotation__tool-btn--active":""}`,onClick:()=>u(I),disabled:r,title:s(`pdfTool_${I}`,I),children:e.jsx(x.oa,{name:Xi[I],size:16})},I)),e.jsx("span",{className:"nice-pdf-annotation__toolbar-sep"}),e.jsx("button",{type:"button",disabled:r,onClick:()=>q?.(Math.max(.25,k-.25)),title:s("zoomOut","Zoom out"),"aria-label":s("zoomOut","Zoom out"),children:e.jsx(x.oa,{name:"minus",size:16})}),e.jsxs("span",{className:"nice-pdf-annotation__zoom",children:[Math.round(k*100),"%"]}),e.jsx("button",{type:"button",disabled:r,onClick:()=>q?.(Math.min(4,k+.25)),title:s("zoomIn","Zoom in"),"aria-label":s("zoomIn","Zoom in"),children:e.jsx(x.oa,{name:"plus",size:16})})]}),$=e.jsxs("div",{className:"nice-pdf-annotation__pager",children:[e.jsx("button",{type:"button",disabled:r||ee<=1,onClick:()=>te?.(ee-1),"aria-label":s("prevPage","Previous page"),children:e.jsx(x.oa,{name:"chevron-left",size:16})}),e.jsx("span",{children:s("pageOf","{page} / {total}").replace("{page}",String(ee)).replace("{total}",String(A))}),e.jsx("button",{type:"button",disabled:r||ee>=A,onClick:()=>te?.(ee+1),"aria-label":s("nextPage","Next page"),children:e.jsx(x.oa,{name:"chevron-right",size:16})})]}),T=!!i||!!a&&typeof a=="string"?e.jsxs(e.Fragment,{children:[i&&e.jsx("span",{className:"nice-helper-text",children:i}),a&&typeof a=="string"&&e.jsx("span",{className:"nice-error-text",children:a})]}):void 0;return e.jsx(Qt.NiceAppShell,{ref:V,flush:!0,id:D,className:`nice-pdf-annotation nice-size-${y}${E?` ${E}`:""}${a?" nice-error":""}${r?" nice-disabled":""}`,style:C,menubar:l,toolbar:g,bottomPanel:$,statusBar:T,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(x.Ql,{steps:x.Yl(S,Ui)})}),e.jsxs("div",{className:"nice-pdf-annotation__viewport",style:{transform:`scale(${k})`,transformOrigin:"top left"},children:[e.jsx("iframe",{src:K,className:"nice-pdf-annotation__frame",title:s("pdfViewer","PDF Viewer")}),e.jsx("div",{className:"nice-pdf-annotation__layer",onClick:c,children:M.map(I=>e.jsxs("div",{className:`nice-pdf-annotation__mark nice-pdf-annotation__mark--${I.tool}`,style:{left:`${I.x*100}%`,top:`${I.y*100}%`,backgroundColor:I.color},onClick:H=>{H.stopPropagation(),p?.(I)},title:I.text??I.tool,children:[I.text&&e.jsx("span",{children:I.text}),!h&&e.jsx("button",{type:"button",className:"nice-pdf-annotation__mark-delete",onClick:H=>{H.stopPropagation(),d?.(I.id)},"aria-label":s("delete","Delete"),children:e.jsx(x.oa,{name:"close",size:14})})]},I.id))})]})]})})});Rn.displayName="NicePDFAnnotationEditor";function qt(t,i){const a=i.getBoundingClientRect();let o,r,h;if("touches"in t){const y=t.touches[0];o=y.clientX-a.left,r=y.clientY-a.top,h=y.force}else"pressure"in t?(o=t.clientX-a.left,r=t.clientY-a.top,h=t.pressure):(o=t.clientX-a.left,r=t.clientY-a.top);return{x:o,y:r,time:Date.now(),pressure:h!==void 0?h:.5}}function Wt(t,i,a,o,r){if(!i)return(a+o)/2;const h=Math.sqrt(Math.pow(t.x-i.x,2)+Math.pow(t.y-i.y,2))/Math.max(1,t.time-i.time),y=Math.min(h/5,1),_=o-y*(o-a),E=t.pressure??.5,C=a+E*(o-a);return _*.7+C*.3}function Vt(t,i,a,o){t.beginPath(),t.moveTo(i.x,i.y),t.lineTo(a.x,a.y),t.lineWidth=o,t.lineCap="round",t.lineJoin="round",t.stroke()}const qi=n.forwardRef(function(i,a){const{value:o,onChange:r,onChangeDataUrl:h,label:y,width:_="100%",height:E=200,penColor:C="",penWidth:Z=2,minWidth:K=.5,maxWidth:R=4,backgroundColor:w="",placeholder:Q,showClearButton:ne=!0,showUndoButton:ee=!0,showColorPicker:te=!1,showSizeSlider:A=!1,velocityFilterWeight:j=.7,throttle:L=16,disabled:f=!1,readOnly:k=!1,displayMode:q=!1,onBegin:p,onEnd:d,className:S,"data-testid":V}=i,{t:B}=x.Gt(),b=Q||B("signature.placeholder","Sign here"),s=k||q,D=q?!1:ne,M=q?!1:ee,u=q?!1:te,c=q?!1:A,l=n.useRef(null),[g,$]=n.useState(o?.strokes??[]),[v,T]=n.useState([]),[I,H]=n.useState(!1),[N,P]=n.useState(C),[z,re]=n.useState(Z),me=n.useRef(null),de=n.useRef(0),be=x.gu(l),ve=w||(be?"#0f172a":"#ffffff"),_e=C||(be?"#f8fafc":"#111827"),fe=N||_e,oe=g.length===0&&v.length===0;n.useEffect(()=>{const J=l.current;if(!J)return;const U=J.getContext("2d");if(!U)return;const se=J.getBoundingClientRect(),ue=window.devicePixelRatio||1;J.width=se.width*ue,J.height=se.height*ue,U.scale(ue,ue),he()},[_,E]);const he=n.useCallback(()=>{const J=l.current;if(!J)return;const U=J.getContext("2d");if(!U)return;const se=J.getBoundingClientRect();U.fillStyle=ve,U.fillRect(0,0,se.width,se.height),g.forEach(ue=>{if(U.strokeStyle=ue.color||_e,!(ue.points.length<2))for(let je=1;je<ue.points.length;je++){const we=ue.points[je-1],Re=ue.points[je],Te=Wt(Re,we,K,R);Vt(U,we,Re,Te)}})},[g,ve,_e,K,R,j]);n.useEffect(()=>{he()},[he]),n.useEffect(()=>{o?.strokes&&$(o.strokes)},[o]),n.useEffect(()=>{const J=l.current;if(J)if(g.length===0)r?.(null),h?.(null);else{const U=J.getBoundingClientRect();r?.({strokes:g,width:U.width,height:U.height,timestamp:Date.now()}),h?.(J.toDataURL("image/png"))}},[g,r,h]);const ie=n.useCallback(J=>{if(f||s)return;const U=l.current;if(!U)return;U.setPointerCapture(J.pointerId);const se=qt(J.nativeEvent,U);H(!0),T([se]),me.current=se,de.current=se.time,p?.()},[f,s,p]),ce=n.useCallback(J=>{if(!I||f||s)return;const U=l.current;if(!U)return;const se=U.getContext("2d");if(!se)return;const ue=Date.now();if(ue-de.current<L)return;const je=qt(J.nativeEvent,U),we=me.current;if(we){se.strokeStyle=fe;const Re=Wt(je,we,K,R);Vt(se,we,je,Re)}T(Re=>[...Re,je]),me.current=je,de.current=ue},[I,f,s,fe,K,R,j,L]),ge=n.useCallback(J=>{if(!I)return;const U=l.current;if(U&&U.releasePointerCapture(J.pointerId),v.length>0){const se={points:v,color:fe,width:z};$(ue=>[...ue,se])}H(!1),T([]),me.current=null,d?.()},[I,v,fe,z,d]),Y=n.useCallback(()=>{$([]),T([]),he()},[he]),O=n.useCallback(()=>{$(J=>J.slice(0,-1))},[]),G=n.useCallback((J="png",U=.92)=>{const se=l.current;if(!se)return"";const ue=J==="jpeg"?"image/jpeg":"image/png";return se.toDataURL(ue,U)},[]),xe=n.useCallback(async(J="png",U=.92)=>{const se=l.current;return se?new Promise(ue=>{const je=J==="jpeg"?"image/jpeg":"image/png";se.toBlob(we=>ue(we),je,U)}):null},[]),le=n.useCallback(()=>{const J=l.current;if(!J)return"";const U=J.getBoundingClientRect(),se=g.map(ue=>ue.points.length<2?"":`<path d="${ue.points.reduce((we,Re,Te)=>Te===0?`M ${Re.x} ${Re.y}`:`${we} L ${Re.x} ${Re.y}`,"")}" stroke="${ue.color||_e}" stroke-width="${ue.width}" fill="none" stroke-linecap="round" stroke-linejoin="round"/>`).join(`
|
|
305
|
+
`);return`<svg xmlns="http://www.w3.org/2000/svg" width="${U.width}" height="${U.height}" viewBox="0 0 ${J.width} ${J.height}">
|
|
306
|
+
<rect width="100%" height="100%" fill="${ve}"/>
|
|
307
|
+
${se}
|
|
308
|
+
</svg>`},[g,ve,_e]);n.useImperativeHandle(a,()=>({clear:Y,undo:O,isEmpty:()=>g.length===0,getData:()=>{const J=l.current;if(!J||g.length===0)return null;const U=J.getBoundingClientRect();return{strokes:g,width:U.width,height:U.height,timestamp:Date.now()}},setData:J=>{$(J.strokes)},toDataURL:G,toBlob:xe,toSVG:le,getCanvas:()=>l.current}),[g,Y,O,G,xe,le]),n.useEffect(()=>{const J=l.current;if(!J)return;const U=se=>{I&&se.preventDefault()};return J.addEventListener("touchmove",U,{passive:!1}),()=>J.removeEventListener("touchmove",U)},[I]);const F=D||M||u||c;return e.jsxs("div",{className:`nice-signature ${f?"nice-signature--disabled":""} ${s?"nice-signature--readonly":""} ${S??""}`,style:{width:_},"data-testid":V,children:[y&&e.jsx("label",{className:"nice-signature__label",children:y}),F&&e.jsxs("div",{className:"nice-signature__toolbar",children:[u&&e.jsx("div",{className:"nice-signature__color-picker",children:e.jsx("input",{type:"color",value:N,onChange:J=>P(J.target.value),disabled:f||s,title:"Pen color"})}),c&&e.jsx("div",{className:"nice-signature__size-slider",children:e.jsx("input",{type:"range",min:K,max:R,step:.5,value:z,onChange:J=>re(parseFloat(J.target.value)),disabled:f||s,title:"Pen size"})}),e.jsxs("div",{className:"nice-signature__actions",children:[M&&e.jsx("button",{type:"button",onClick:O,disabled:f||s||g.length===0,className:"nice-signature__btn",title:"Undo","aria-label":"Undo",children:e.jsx(x.oa,{name:"reply",size:16})}),D&&e.jsx("button",{type:"button",onClick:Y,disabled:f||s||oe,className:"nice-signature__btn",title:"Clear","aria-label":"Clear",children:e.jsx(x.oa,{name:"trash",size:16})})]})]}),e.jsxs("div",{className:"nice-signature__canvas-wrapper",style:{height:E},children:[e.jsx("canvas",{ref:l,className:"nice-signature__canvas",style:{width:"100%",height:"100%",cursor:f||s?"not-allowed":"crosshair",touchAction:"none"},onPointerDown:ie,onPointerMove:ce,onPointerUp:ge,onPointerLeave:ge}),oe&&!I&&b&&e.jsx("div",{className:"nice-signature__placeholder",children:b}),e.jsx("div",{className:"nice-signature__line"})]})]})}),Jt="nice-signature-styles";if(typeof document<"u"&&!document.getElementById(Jt)){const t=document.createElement("style");t.id=Jt,t.textContent=`
|
|
309
|
+
.nice-signature {
|
|
310
|
+
display: flex;
|
|
311
|
+
flex-direction: column;
|
|
312
|
+
border: 1px solid var(--nice-border, #e0e0e0);
|
|
313
|
+
border-radius: var(--nice-radius-sm, 4px);
|
|
314
|
+
overflow: hidden;
|
|
315
|
+
background: var(--nice-bg-surface, #fff);
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
.nice-signature--disabled {
|
|
319
|
+
opacity: 0.6;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
.nice-signature__toolbar {
|
|
323
|
+
display: flex;
|
|
324
|
+
align-items: center;
|
|
325
|
+
gap: var(--nice-space-2, 8px);
|
|
326
|
+
padding: var(--nice-space-2, 8px);
|
|
327
|
+
background: var(--nice-bg-muted, #f5f5f5);
|
|
328
|
+
border-bottom: 1px solid var(--nice-border, #e0e0e0);
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
.nice-signature__color-picker input {
|
|
332
|
+
width: 32px;
|
|
333
|
+
height: 32px;
|
|
334
|
+
padding: var(--nice-space-0-5, 2px);
|
|
335
|
+
border: 1px solid var(--nice-border, #e0e0e0);
|
|
336
|
+
border-radius: var(--nice-radius-sm, 4px);
|
|
337
|
+
cursor: pointer;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
.nice-signature__size-slider {
|
|
341
|
+
flex: 1;
|
|
342
|
+
max-width: 120px;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
.nice-signature__size-slider input {
|
|
346
|
+
width: 100%;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
.nice-signature__actions {
|
|
350
|
+
display: flex;
|
|
351
|
+
gap: var(--nice-space-1, 4px);
|
|
352
|
+
margin-left: auto;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
.nice-signature__btn {
|
|
356
|
+
padding: var(--nice-space-1-5, 6px) var(--nice-space-2-5, 10px);
|
|
357
|
+
border: 1px solid var(--nice-border, #e0e0e0);
|
|
358
|
+
border-radius: var(--nice-radius-sm, 4px);
|
|
359
|
+
background: var(--nice-bg-surface, #fff);
|
|
360
|
+
cursor: pointer;
|
|
361
|
+
font-size: 14px;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
.nice-signature__btn:hover:not(:disabled) {
|
|
365
|
+
background: var(--nice-bg-hover, #f0f0f0);
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
.nice-signature__btn:disabled {
|
|
369
|
+
opacity: 0.4;
|
|
370
|
+
cursor: not-allowed;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
.nice-signature__canvas-wrapper {
|
|
374
|
+
position: relative;
|
|
375
|
+
background: var(--nice-bg, #FFF);
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
.nice-signature__canvas {
|
|
379
|
+
display: block;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
.nice-signature__placeholder {
|
|
383
|
+
position: absolute;
|
|
384
|
+
top: 50%;
|
|
385
|
+
left: 50%;
|
|
386
|
+
transform: translate(-50%, -50%);
|
|
387
|
+
color: var(--nice-text-secondary, #999);
|
|
388
|
+
font-size: 14px;
|
|
389
|
+
pointer-events: none;
|
|
390
|
+
user-select: none;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
.nice-signature__line {
|
|
394
|
+
position: absolute;
|
|
395
|
+
/* Sit in the lower third (a natural signature baseline) rather than pinned to
|
|
396
|
+
the very bottom. */
|
|
397
|
+
bottom: 64px;
|
|
398
|
+
left: 20px;
|
|
399
|
+
right: 20px;
|
|
400
|
+
height: 1px;
|
|
401
|
+
background: var(--nice-border, #ccc);
|
|
402
|
+
pointer-events: none;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
/* Display component */
|
|
406
|
+
.nice-signature-display {
|
|
407
|
+
border: 1px solid var(--nice-border, #e0e0e0);
|
|
408
|
+
border-radius: var(--nice-radius-sm, 4px);
|
|
409
|
+
overflow: hidden;
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
.nice-signature-display__canvas-wrapper {
|
|
413
|
+
position: relative;
|
|
414
|
+
background: var(--nice-bg, #FFF);
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
.nice-signature-display__canvas {
|
|
418
|
+
display: block;
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
.nice-signature-display__placeholder {
|
|
422
|
+
position: absolute;
|
|
423
|
+
top: 50%;
|
|
424
|
+
left: 50%;
|
|
425
|
+
transform: translate(-50%, -50%);
|
|
426
|
+
color: var(--nice-text-secondary, #999);
|
|
427
|
+
font-size: 14px;
|
|
428
|
+
}
|
|
429
|
+
`,document.head.appendChild(t)}const Tn=n.forwardRef(({label:t,helperText:i,error:a,required:o,disabled:r,readOnly:h,size:y="md",id:_,className:E,style:C,accessMode:Z,mode:K="manual",onScan:R,onModeChange:w,beepOnScan:Q=!0,beepFrequency:ne=1800,beepDuration:ee=150,placeholder:te,scanHistory:A=[],showHistory:j=!0,maxHistory:L=10,autoFocus:f=!0,onCameraFrame:k},q)=>{const p=x.Dc(Z,_),d=p==="hidden";p==="disabled"&&(r=!0),p==="readOnly"&&(h=!0);const{t:S}=x.Gt(),V=x.bc(_),[B,b]=n.useState(""),s=n.useRef(null),D=n.useRef(null),M=n.useCallback(()=>{if(Q)try{D.current||(D.current=new AudioContext);const l=D.current,g=l.createOscillator(),$=l.createGain();g.connect($),$.connect(l.destination),g.frequency.value=ne,g.type="square",$.gain.value=.3,g.start(),g.stop(l.currentTime+ee/1e3)}catch{}},[Q,ne,ee]),u=n.useCallback(()=>{B.trim()&&(M(),R?.({value:B.trim(),format:"manual",scannedAt:new Date}),b(""),s.current?.focus())},[B,R,M]),c=A.slice(0,L);return d?null:e.jsxs("div",{ref:q,id:V,className:`nice-scanner nice-size-${y}${E?` ${E}`:""}${a?" nice-error":""}${r?" nice-disabled":""}`,style:C,children:[t&&e.jsxs("div",{className:"nice-scanner__label",children:[t,o&&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${K==="camera"?" nice-scanner__mode-btn--active":""}`,onClick:()=>w?.("camera"),disabled:r,children:[e.jsx(x.oa,{name:"camera",size:16})," ",S("camera","Camera")]}),e.jsxs("button",{type:"button",className:`nice-scanner__mode-btn${K==="manual"?" nice-scanner__mode-btn--active":""}`,onClick:()=>w?.("manual"),disabled:r,children:[e.jsx(x.oa,{name:"edit",size:16})," ",S("manual","Manual")]})]}),K==="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(x.oa,{name:"camera",size:32})}),e.jsx("p",{children:S("cameraPlaceholder","Camera preview — connect scanner adapter")})]})})}),K==="manual"&&!h&&e.jsxs("div",{className:"nice-scanner__manual",children:[e.jsx("input",{ref:s,className:"nice-input nice-scanner__input",type:"text",value:B,onChange:l=>b(l.target.value),onKeyDown:l=>l.key==="Enter"&&u(),placeholder:te??S("enterCode","Enter or scan code…"),disabled:r,autoFocus:f}),e.jsx("button",{type:"button",className:"nice-scanner__submit",onClick:u,disabled:r||!B.trim(),"aria-label":S("submit","Submit"),children:e.jsx(x.oa,{name:"check",size:16})})]}),j&&c.length>0&&e.jsxs("div",{className:"nice-scanner__history",children:[e.jsx("div",{className:"nice-scanner__history-label",children:S("recentScans","Recent scans")}),c.map((l,g)=>e.jsxs("div",{className:"nice-scanner__history-item",children:[e.jsx("span",{className:"nice-scanner__history-value",children:l.value}),l.format&&e.jsx("span",{className:"nice-scanner__history-format",children:l.format}),e.jsx("span",{className:"nice-scanner__history-time",children:l.scannedAt.toLocaleTimeString()})]},g))]}),i&&e.jsx("span",{className:"nice-helper-text",children:i}),a&&typeof a=="string"&&e.jsx("span",{className:"nice-error-text",children:a})]})});Tn.displayName="NiceScannerControl";const Wi=[{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 Vi=1;function Ji(t){return{id:`new-${Vi++}`,description:"",quantity:1,unitPrice:0,vatRate:t,discount:0,unit:"szt."}}function In(t){const a=t.quantity*t.unitPrice*(1-(t.discount??0)/100),o=Math.round(a*100)/100,r=Math.round(o*(t.vatRate??0)/100*100)/100;return{...t,netAmount:o,grossAmount:o+r}}function Qi(t){const i=t.map(In),a=i.reduce((_,E)=>_+(E.netAmount??0),0),o=i.reduce((_,E)=>_+(E.grossAmount??0),0),r=o-a,h=new Map;for(const _ of i){const E=_.vatRate??0,C=h.get(E)??{base:0,amount:0};C.base+=_.netAmount??0,C.amount+=(_.grossAmount??0)-(_.netAmount??0),h.set(E,C)}const y=Array.from(h.entries()).map(([_,E])=>({rate:_,base:Math.round(E.base*100)/100,amount:Math.round(E.amount*100)/100}));return{totalNet:Math.round(a*100)/100,totalVat:Math.round(r*100)/100,totalGross:Math.round(o*100)/100,vatBreakdown:y}}const An=n.forwardRef(({label:t,helperText:i,error:a,required:o,disabled:r,readOnly:h,size:y="md",name:_,id:E,className:C,style:Z,accessMode:K,value:R=[],onChange:w,onTotalsChange:Q,currencySymbol:ne="zł",defaultVatRate:ee=23,vatRates:te=[0,5,8,23],units:A=["szt.","h","kg","m","usł."],showDiscount:j=!0,showUnit:L=!0,showTotals:f=!0,editable:k=!0,maxLines:q,tutorial:p},d)=>{const S=x.Dc(K,E),V=S==="hidden";S==="disabled"&&(r=!0),S==="readOnly"&&(h=!0);const{t:B}=x.Gt(),b=x.bc(E),s=n.useMemo(()=>R.map(In),[R]),D=n.useMemo(()=>Qi(R),[R]);n.useEffect(()=>{Q?.(D)},[D,Q]);const M=n.useCallback((g,$,v)=>{const T=[...R];T[g]={...T[g],[$]:v},w?.(T)},[R,w]),u=n.useCallback(()=>{q&&R.length>=q||w?.([...R,Ji(ee)])},[R,w,ee,q]),c=n.useCallback(g=>{w?.(R.filter(($,v)=>v!==g))},[R,w]),l=g=>`${g.toFixed(2)} ${ne}`;return V?null:e.jsxs("div",{ref:d,id:b,className:`nice-invoice-lines nice-size-${y}${C?` ${C}`:""}${a?" nice-error":""}${r?" nice-disabled":""}`,style:{position:"relative",...Z},children:[e.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:20},children:e.jsx(x.Ql,{steps:x.Yl(p,Wi)})}),t&&e.jsxs("label",{className:"nice-invoice-lines__label",children:[t,o&&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:B("description","Description")}),e.jsx("th",{className:"nice-il__th-qty",children:B("qty","Qty")}),L&&e.jsx("th",{className:"nice-il__th-unit",children:B("unit","Unit")}),e.jsx("th",{className:"nice-il__th-price",children:B("unitPrice","Unit Price")}),j&&e.jsx("th",{className:"nice-il__th-disc",children:B("discount","Disc %")}),e.jsx("th",{className:"nice-il__th-vat",children:B("vat","VAT %")}),e.jsx("th",{className:"nice-il__th-net",children:B("net","Net")}),e.jsx("th",{className:"nice-il__th-gross",children:B("gross","Gross")}),k&&!h&&e.jsx("th",{className:"nice-il__th-actions"})]})}),e.jsx("tbody",{children:s.map((g,$)=>e.jsxs("tr",{children:[e.jsx("td",{className:"nice-il__cell-num",children:$+1}),e.jsx("td",{className:"nice-il__cell-desc",children:e.jsx("input",{className:"nice-input",type:"text",value:g.description,onChange:v=>M($,"description",v.target.value),disabled:r,readOnly:h,placeholder:B("itemDescription","Item description")})}),e.jsx("td",{className:"nice-il__cell-qty",children:e.jsx("input",{className:"nice-input",type:"number",value:g.quantity,onChange:v=>M($,"quantity",parseFloat(v.target.value)||0),disabled:r,readOnly:h,min:0,step:"any"})}),L&&e.jsx("td",{className:"nice-il__cell-unit",children:e.jsx("select",{className:"nice-select",value:g.unit??"",onChange:v=>M($,"unit",v.target.value),disabled:r,children:A.map(v=>e.jsx("option",{value:v,children:v},v))})}),e.jsx("td",{className:"nice-il__cell-price",children:e.jsx("input",{className:"nice-input",type:"number",value:g.unitPrice,onChange:v=>M($,"unitPrice",parseFloat(v.target.value)||0),disabled:r,readOnly:h,min:0,step:"0.01"})}),j&&e.jsx("td",{className:"nice-il__cell-disc",children:e.jsx("input",{className:"nice-input",type:"number",value:g.discount??0,onChange:v=>M($,"discount",parseFloat(v.target.value)||0),disabled:r,readOnly:h,min:0,max:100})}),e.jsx("td",{className:"nice-il__cell-vat",children:e.jsx("select",{className:"nice-select",value:g.vatRate??0,onChange:v=>M($,"vatRate",parseInt(v.target.value,10)),disabled:r,children:te.map(v=>e.jsxs("option",{value:v,children:[v,"%"]},v))})}),e.jsx("td",{className:"nice-il__cell-net",children:l(g.netAmount??0)}),e.jsx("td",{className:"nice-il__cell-gross",children:l(g.grossAmount??0)}),k&&!h&&e.jsx("td",{className:"nice-il__cell-actions",children:e.jsx("button",{type:"button",className:"nice-btn nice-btn--icon nice-btn--sm",onClick:()=>c($),disabled:r,title:B("remove","Remove"),"aria-label":B("remove","Remove"),children:e.jsx(x.oa,{name:"close",size:14})})})]},g.id))})]}),k&&!h&&e.jsxs("button",{type:"button",className:"nice-btn nice-btn--outlined nice-btn--sm nice-invoice-lines__add",onClick:u,disabled:r||q!=null&&R.length>=q,children:["+ ",B("addLine","Add line")]}),f&&e.jsxs("div",{className:"nice-invoice-lines__totals",children:[e.jsxs("div",{className:"nice-il__total-row",children:[e.jsxs("span",{children:[B("totalNet","Net total"),":"]}),e.jsx("span",{className:"nice-il__total-value",children:l(D.totalNet)})]}),D.vatBreakdown.map(g=>e.jsxs("div",{className:"nice-il__total-row nice-il__total-row--vat",children:[e.jsxs("span",{children:["VAT ",g.rate,"%:"]}),e.jsx("span",{className:"nice-il__total-value",children:l(g.amount)})]},g.rate)),e.jsxs("div",{className:"nice-il__total-row nice-il__total-row--gross",children:[e.jsxs("span",{children:[B("totalGross","Gross total"),":"]}),e.jsx("span",{className:"nice-il__total-value nice-il__total-value--gross",children:l(D.totalGross)})]})]}),i&&e.jsx("span",{className:"nice-helper-text",children:i}),a&&typeof a=="string"&&e.jsx("span",{className:"nice-error-text",children:a})]})});An.displayName="NiceInvoiceLineEditor";const Dn=n.forwardRef(({value:t="",onChange:i,suggestions:a=[],onSearch:o,trigger:r="@",renderSuggestion:h,placeholder:y,rows:_=3,label:E,helperText:C,error:Z,required:K,disabled:R,readOnly:w,loading:Q,labelPlacement:ne,errorPlacement:ee,labelWidth:te,controlWidth:A,size:j="md",name:L,id:f,className:k,style:q,...p},d)=>{const S=x.bc(f),[V,B]=n.useState(!1),[b,s]=n.useState(""),[D,M]=n.useState(0),[u,c]=n.useState({top:0,left:0}),l=n.useRef(null),g=n.useRef(-1),v=a.map(P=>typeof P=="string"?{key:P,label:P}:P).filter(P=>P.label.toLowerCase().includes(b.toLowerCase())),T=n.useCallback(()=>{B(!1),s(""),M(0),g.current=-1},[]),I=n.useCallback(P=>{const z=l.current;if(!z||g.current<0)return;const re=t.slice(0,g.current),me=t.slice(z.selectionStart),de=`${r}${P.label} `,be=re+de+me;i?.(be),T(),requestAnimationFrame(()=>{const ve=re.length+de.length;z.setSelectionRange(ve,ve),z.focus()})},[t,i,r,T]),H=n.useCallback(P=>{const z=P.target.value;i?.(z);const re=P.target.selectionStart,me=z.slice(0,re),de=me.lastIndexOf(r);if(de>=0){const be=de>0?me[de-1]:" ",ve=me.slice(de+r.length);if(/\s/.test(be)&&!/\s/.test(ve)){g.current=de;const _e=ve;s(_e),B(!0),M(0),o?.(_e);const fe=P.target,oe=fe.getBoundingClientRect(),he=parseInt(getComputedStyle(fe).lineHeight)||20,ie=me.split(`
|
|
430
|
+
`);c({top:oe.top+ie.length*he+4-fe.scrollTop,left:oe.left+8});return}}T()},[i,r,o,T]),N=n.useCallback(P=>{!V||v.length===0||(P.key==="ArrowDown"?(P.preventDefault(),M(z=>(z+1)%v.length)):P.key==="ArrowUp"?(P.preventDefault(),M(z=>(z-1+v.length)%v.length)):P.key==="Enter"?(P.preventDefault(),v[D]&&I(v[D])):P.key==="Escape"&&T())},[V,v,D,I,T]);return n.useEffect(()=>{if(!V)return;const P=z=>{const re=l.current;re&&!re.contains(z.target)&&T()};return document.addEventListener("mousedown",P),()=>document.removeEventListener("mousedown",P)},[V,T]),e.jsxs("div",{className:`nice-field nice-field--${j} ${ne==="left"?"nice-field--label-left":""} ${ee==="right"?"nice-field--error-right":""} ${Q?"nice-field--loading":""} ${k||""}`,style:{...q,...te!=null&&{"--nice-field-label-width":typeof te=="number"?`${te}px`:te},...A!=null&&{"--nice-field-control-width":typeof A=="number"?`${A}px`:A}},"aria-busy":Q||void 0,...p,children:[E&&e.jsx("label",{htmlFor:S,className:`nice-field__label ${K?"nice-field__label--required":""}`,children:E}),e.jsxs("div",{className:"nice-field__control",children:[e.jsxs("div",{className:`nice-mention nice-mention--${j} ${Z?"nice-mention--error":""} ${R?"nice-mention--disabled":""}`,children:[e.jsx("textarea",{ref:P=>{l.current=P,typeof d=="function"?d(P):d&&(d.current=P)},id:S,name:L,className:"nice-mention__input",value:t,onChange:H,onKeyDown:N,placeholder:y,rows:_,disabled:R,readOnly:w,"aria-invalid":!!Z,"aria-describedby":Z?`${S}-error`:C?`${S}-helper`:void 0,"aria-autocomplete":"list","aria-expanded":V}),V&&v.length>0&&e.jsx("ul",{className:"nice-mention__suggestions",role:"listbox",style:{position:"fixed",top:u.top,left:u.left},children:v.map((P,z)=>e.jsx("li",{role:"option","aria-selected":z===D,className:`nice-mention__suggestion ${z===D?"nice-mention__suggestion--active":""}`,onMouseDown:re=>{re.preventDefault(),I(P)},onMouseEnter:()=>M(z),children:h?h(P):e.jsxs(e.Fragment,{children:[P.icon&&e.jsx("span",{className:"nice-mention__suggestion-icon",children:P.icon}),e.jsx("span",{children:P.label})]})},P.key))})]}),Q&&e.jsx("span",{className:"nice-field__spinner",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})}),ee==="right"&&Z&&e.jsx("div",{id:`${S}-error`,className:"nice-field__error",role:"alert",children:Z}),ee==="right"&&!Z&&C&&e.jsx("div",{id:`${S}-helper`,className:"nice-field__helper",children:C})]}),ee!=="right"&&Z&&e.jsx("div",{id:`${S}-error`,className:"nice-field__error",role:"alert",children:Z}),ee!=="right"&&!Z&&C&&e.jsx("div",{id:`${S}-helper`,className:"nice-field__helper",children:C})]})});Dn.displayName="NiceMention";exports.DEFAULT_ASPECT_RATIOS=En;exports.EMOJI_DATA=ht;exports.GRADIENT_PRESETS=fn;exports.NICE_COLOR_PRESET_KEYS=un;exports.NiceAccountPicker=kn;exports.NiceAddressInput=_n;exports.NiceCodeEditorAI=Ni;exports.NiceColorPalette=hn;exports.NiceContactPicker=wn;exports.NiceCropEditor=Mn;exports.NiceDateRangeBox=Zn;exports.NiceDocumentEditor=jn;exports.NiceDropDownBox=Vn;exports.NiceEmojiPicker=Nn;exports.NiceGradientPicker=yn;exports.NiceHtmlEditorAI=hi;exports.NiceImageAnnotator=$n;exports.NiceImageEditor=Sn;exports.NiceInputOtp=Cn;exports.NiceInvoiceLineEditor=An;exports.NiceKeyValueEditor=Ti;exports.NiceKnob=en;exports.NiceLogConsole=vn;exports.NiceLookup=qn;exports.NiceMarkdownEditor=xn;exports.NiceMention=Dn;exports.NicePDFAnnotationEditor=Rn;exports.NicePickList=on;exports.NiceRangeSlider=Un;exports.NiceScannerControl=Tn;exports.NiceScriptRunner=Mi;exports.NiceSignature=qi;exports.NiceTreeSelect=an;exports.NiceWiki=bn;exports.applyPreset=pt;exports.contrastRatio=mt;exports.cssToGradient=gn;exports.generateHarmony=ot;exports.generateVariations=ln;exports.gradientToCss=Nt;exports.hexToHsv=He;exports.hexToRgb=st;exports.hsvToHex=De;exports.hsvToRgb=sn;exports.randomPalette=mn;exports.rgbToHex=cn;exports.rgbToHsl=rn;exports.rgbToHsv=St;exports.wcagLevel=ut;
|