@nice2dev/ui 1.0.31 → 1.1.5
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 +353 -0
- package/dist/NiceCodeEditor-BVUwp9yX.js +1134 -0
- package/dist/NiceCodeEditor-cIqUSk3j.cjs +260 -0
- package/dist/NiceColorPicker-C8NZZcXE.js +596 -0
- package/dist/NiceColorPicker-CKVbjicN.cjs +1 -0
- package/dist/NiceConfirmDialog-DmBX1Iea.js +81 -0
- package/dist/NiceConfirmDialog-oSxVpsCs.cjs +1 -0
- package/dist/NiceDataGrid-3AIf2D3t.cjs +10 -0
- package/dist/NiceDataGrid-CXCUAkRb.js +1736 -0
- package/dist/NiceDocumentViewer-B-uEPZAf.js +672 -0
- package/dist/NiceDocumentViewer-BE0gKBlw.cjs +180 -0
- package/dist/NiceForm-C6F0HvrX.cjs +1 -0
- package/dist/NiceForm-CCyfWgIs.js +4805 -0
- package/dist/NiceGantt-CSFLZD2y.js +328 -0
- package/dist/NiceGantt-_ysNSVYR.cjs +1 -0
- package/dist/NiceHtmlEditor-B8B8AcSC.js +841 -0
- package/dist/NiceHtmlEditor-D8RQcBNp.cjs +10 -0
- package/dist/NiceLoginForm-Bai7aN8V.js +708 -0
- package/dist/NiceLoginForm-BrvIc-wq.cjs +1 -0
- package/dist/NiceMention-CWoLD0SE.js +11082 -0
- package/dist/NiceMention-J1lUDLhg.cjs +430 -0
- package/dist/NiceMention.css +1 -0
- package/dist/NiceModal-0UxviEYE.cjs +1 -0
- package/dist/NiceModal-D-iOonog.js +95 -0
- package/dist/NiceModuleLifecyclePanel-4hzDw6it.js +6999 -0
- package/dist/NiceModuleLifecyclePanel-Df_1k5qW.cjs +1 -0
- package/dist/NiceModuleLifecyclePanel.css +1 -1
- package/dist/NicePagination-CPn-Q1h_.js +172 -0
- package/dist/NicePagination-EEQ6o1dF.cjs +1 -0
- package/dist/NicePivotGrid-Cmiolup9.cjs +152 -0
- package/dist/NicePivotGrid-DX_iUj2X.js +1167 -0
- package/dist/NiceSavedQueryPanel-BhjFJBvn.cjs +586 -0
- package/dist/NiceSavedQueryPanel-KvyXTnFx.js +5129 -0
- package/dist/NiceScheduler-DuxPzQQZ.js +1645 -0
- package/dist/NiceScheduler-nW7fMzKL.cjs +5 -0
- package/dist/NiceSelect-BVoqtfYN.cjs +1 -0
- package/dist/NiceSelect-DHowflmX.js +433 -0
- package/dist/NiceWindow-DdD9k4nc.cjs +1 -0
- package/dist/NiceWindow-xnTSHdHv.js +1623 -0
- package/dist/charts-B-sl1V9y.cjs +882 -0
- package/dist/charts-DO2z6Ziu.js +31920 -0
- package/dist/charts.cjs +1 -1
- package/dist/charts.mjs +7 -7
- package/dist/core-C2KhqEaU.cjs +1 -0
- package/dist/core-K2DIxXLn.js +795 -0
- package/dist/data-branching-DC6hcBQN.cjs +1 -0
- package/dist/data-branching-DykdTpjJ.js +6255 -0
- package/dist/data-branching.cjs +1 -1
- package/dist/data-branching.mjs +1 -1
- package/dist/data.cjs +1 -1
- package/dist/data.d.ts +29 -7
- package/dist/data.mjs +18 -16
- package/dist/devops-CU0sOVEA.cjs +17 -0
- package/dist/devops-CXyEwQeM.js +8165 -0
- package/dist/devops.cjs +1 -1
- package/dist/devops.mjs +1 -1
- package/dist/editors.cjs +1 -1
- package/dist/editors.d.ts +73 -1
- package/dist/editors.mjs +58 -54
- package/dist/feedback.cjs +1 -1
- package/dist/feedback.d.ts +1 -1
- package/dist/feedback.mjs +3 -3
- package/dist/index.cjs +5137 -1
- package/dist/index.css +1 -1
- package/dist/index.d.ts +115 -13
- package/dist/index.mjs +66371 -992
- package/dist/lazy.cjs +1 -1
- package/dist/lazy.mjs +24 -24
- package/dist/navigation.cjs +1 -1
- package/dist/navigation.d.ts +6 -0
- package/dist/navigation.mjs +4 -4
- package/dist/no-code-C58g8_fb.cjs +332 -0
- package/dist/no-code-Cj4xJ3w9.js +7425 -0
- package/dist/no-code.cjs +1 -1
- package/dist/no-code.mjs +1 -1
- package/dist/overlays.cjs +1 -1
- package/dist/overlays.d.ts +2 -0
- package/dist/overlays.mjs +2 -2
- package/dist/pickerCommons-B-wOzHFh.cjs +1 -0
- package/dist/pickerCommons-COiSUiP2.js +1122 -0
- package/dist/style.css +6 -6
- package/dist/vendor-BPVpdtPp.js +271 -0
- package/dist/vendor-Bo2Q64AF.cjs +1 -0
- package/package.json +17 -17
|
@@ -0,0 +1,430 @@
|
|
|
1
|
+
"use strict";const e=require("react/jsx-runtime"),x=require("./charts-B-sl1V9y.cjs"),n=require("react"),Ze=require("react-dom"),Ye=require("./NiceSelect-BVoqtfYN.cjs"),rt=require("./NiceForm-C6F0HvrX.cjs"),Ue=require("./pickerCommons-B-wOzHFh.cjs"),Kn=require("./NiceHtmlEditor-D8RQcBNp.cjs"),Se=require("./NiceColorPicker-CKVbjicN.cjs"),vt=require("./NiceCodeEditor-cIqUSk3j.cjs"),Qt=require("./devops-CU0sOVEA.cjs"),Un=({min:t=0,max:i=100,step:a=1,startValue:o=t,endValue:r=i,onChange:h,showLabels:j=!0,formatLabel:v,valuePlacement:R="none",label:C,error:J,helperText:Y,required:$,disabled:N,readOnly:Q,loading:te,size:ee="md",id:ne,className:A,style:y,accessMode:D,showKeyboardHints:f,labelPlacement:w,errorPlacement:q,labelWidth:p,controlWidth:m})=>{const S=x.Dc(D,ne),X=S==="hidden";(S==="disabled"||S==="readOnly")&&(N=!0);const{t:P}=x.Gt(),b=x.bc(ne),s=n.useRef(null),z=n.useMemo(()=>[x.Yc.increment,x.Yc.decrement,x.Yc.first,x.Yc.last,{key:"Tab",description:P("shortcuts.switchThumb","Switch thumb")}],[P]),M=g=>(g-t)/(i-t)*100,d=g=>v?v(g):String(g),c=g=>{const E=Math.round(g/a)*a;return Math.max(t,Math.min(i,E))},l=n.useCallback((g,E)=>{g.preventDefault();const _=s.current;if(!_||N)return;const T=I=>{const k=_.getBoundingClientRect(),G=Math.max(0,Math.min(1,(I.clientX-k.left)/k.width)),B=c(t+G*(i-t));E==="start"?h?.(Math.min(B,r),r):h?.(o,Math.max(B,o))},L=()=>{document.removeEventListener("pointermove",T),document.removeEventListener("pointerup",L)};document.addEventListener("pointermove",T),document.addEventListener("pointerup",L)},[t,i,a,o,r,h,N]);return X?null:e.jsxs("div",{className:`nice-field nice-field--${ee} nice-field--rangeslider ${w==="left"?"nice-field--label-left":""} ${q==="right"?"nice-field--error-right":""} ${J?"nice-field--error":""} ${te?"nice-field--loading":""} ${A||""}`,style:{...y,...p!=null&&{"--nice-field-label-width":typeof p=="number"?`${p}px`:p},...m!=null&&{"--nice-field-control-width":typeof m=="number"?`${m}px`:m}},"aria-busy":te||void 0,children:[(C||R==="right"&&w!=="left")&&(w!=="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,$&&e.jsx("span",{className:"nice-field__required",children:"*"}),f&&e.jsx(x.ha,{shortcuts:z,size:"sm"})]})}):e.jsx("span",{}),R==="right"&&e.jsxs("span",{className:"nice-range-slider__value nice-range-slider__value--header",children:[d(o)," – ",d(r)]})]}):C&&e.jsx("label",{className:"nice-field__label",htmlFor:b,children:e.jsxs("span",{className:"nice-field__label-text",children:[C,$&&e.jsx("span",{className:"nice-field__required",children:"*"}),f&&e.jsx(x.ha,{shortcuts:z,size:"sm"})]})})),e.jsxs("div",{className:"nice-field__control",children:[e.jsxs("div",{className:"nice-range-slider__stack",children:[e.jsxs("div",{className:`nice-range-slider ${j?"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:N?-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:N?-1:0})]}),j&&e.jsxs("div",{className:"nice-range-slider__values",children:[e.jsx("span",{className:"nice-range-slider__values-start",style:{left:`${M(o)}%`},children:d(o)}),e.jsx("span",{className:"nice-range-slider__values-end",style:{left:`${M(r)}%`},children:d(r)})]}),R==="bottom"&&e.jsxs("div",{className:"nice-range-slider__value nice-range-slider__value--bottom",children:[d(o)," – ",d(r)]})]}),R==="right"&&w==="left"&&e.jsxs("span",{className:"nice-range-slider__value nice-range-slider__value--inline",children:[d(o)," – ",d(r)]}),te&&e.jsx("span",{className:"nice-field__spinner",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})}),q==="right"&&J&&e.jsx("div",{className:"nice-field__error",role:"alert",children:J}),q==="right"&&!J&&Y&&e.jsx("div",{className:"nice-field__helper",children:Y})]}),q!=="right"&&J&&e.jsx("div",{className:"nice-field__error",role:"alert",children:J}),q!=="right"&&!J&&Y&&e.jsx("div",{className:"nice-field__helper",children:Y})]})},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),j=kt(t,i,a,r),v=r-o>180?1:0;return`M ${h.x} ${h.y} A ${a} ${a} 0 ${v} 1 ${j.x} ${j.y}`}const en=n.forwardRef(({value:t=0,onChange:i,min:a=0,max:o=100,step:r=1,showValue:h=!0,valueTemplate:j="{value}",label:v,helperText:R,error:C,required:J,disabled:Y,readOnly:$,size:N="md",name:Q,id:te,className:ee,style:ne,labelPlacement:A="top",errorPlacement:y,labelWidth:D,controlWidth:f,loading:w,isLabelCentered:q=!0,...p},m)=>{const S=x.bc(te),X=n.useRef(!1),P=n.useRef(null),b=typeof N=="number"?N:Gn[N],s=b/2,z=b/2,M=(b-ct*2)/2,d=o>a?(t-a)/(o-a):0,c=at+d*it,l=n.useCallback(L=>{let I=L-at;I<0&&(I+=360),I>it&&(I=I-it<360-I?it:0);const k=Math.max(0,Math.min(1,I/it)),G=a+k*(o-a),B=Math.round(G/r)*r;return Math.max(a,Math.min(o,B))},[a,o,r]),g=n.useCallback(L=>{if(Y||$)return;const I=P.current;if(!I)return;const k=I.getBoundingClientRect(),G=L.clientX-k.left-k.width/2,B=L.clientY-k.top-k.height/2;let me=Math.atan2(G,-B)*(180/Math.PI);me<0&&(me+=360);const le=l(me);i?.(le)},[l,Y,$,i]);n.useEffect(()=>{const L=k=>{X.current&&g(k)},I=()=>{X.current=!1};return window.addEventListener("pointermove",L),window.addEventListener("pointerup",I),()=>{window.removeEventListener("pointermove",L),window.removeEventListener("pointerup",I)}},[g]);const E=n.useCallback(L=>{if(Y||$)return;let I=t;L.key==="ArrowUp"||L.key==="ArrowRight"?(L.preventDefault(),I=Math.min(o,t+r)):(L.key==="ArrowDown"||L.key==="ArrowLeft")&&(L.preventDefault(),I=Math.max(a,t-r)),I!==t&&i?.(I)},[t,i,a,o,r,Y,$]),_=(j||"{value}").replace("{value}",String(t)),T=kt(s,z,M,c);return e.jsxs("div",{className:`nice-field nice-knob-field nice-knob-field--err-${y||"bottom"} nice-field--${typeof N=="string"?N:"md"} ${w?"nice-field--loading":""} ${ee||""}`,style:{...ne,...D!=null&&{"--nice-field-label-width":typeof D=="number"?`${D}px`:D},...f!=null&&{"--nice-field-control-width":typeof f=="number"?`${f}px`:f}},"aria-busy":w||void 0,...p,children:[e.jsxs("div",{className:`nice-knob-field__inner nice-knob-field--${A} ${q?"nice-knob-field--label-centered":""}`,children:[v&&e.jsx("label",{htmlFor:S,className:`nice-field__label ${J?"nice-field__label--required":""}`,children:v}),e.jsx("div",{className:"nice-field__control",children:e.jsxs("div",{ref:L=>{P.current=L,typeof m=="function"?m(L):m&&(m.current=L)},className:`nice-knob nice-knob--${N} ${Y?"nice-knob--disabled":""} ${C?"nice-knob--error":""}`,role:"slider",id:S,tabIndex:Y?-1:0,"aria-valuenow":t,"aria-valuemin":a,"aria-valuemax":o,"aria-disabled":Y,"aria-invalid":!!C,onPointerDown:L=>{Y||$||(X.current=!0,g(L))},onKeyDown:E,children:[e.jsxs("svg",{width:b,height:b,viewBox:`0 0 ${b} ${b}`,children:[e.jsx("path",{d:Tt(s,z,M,at,Zt),fill:"none",stroke:"var(--nice-border-color, #d1d5db)",strokeWidth:ct,strokeLinecap:"round"}),d>0&&e.jsx("path",{d:Tt(s,z,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:_}),Q&&e.jsx("input",{type:"hidden",name:Q,value:t}),w&&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&&R&&e.jsx("div",{className:"nice-field__helper",children:R})]})});en.displayName="NiceKnob";function Xn(t,{open:i,onSelect:a,onClose:o,onOpen:r,loop:h=!1}){const[j,v]=n.useState(0);n.useEffect(()=>{v(C=>t.length===0?0:Math.min(Math.max(C,0),t.length-1))},[t.length]);const R=n.useCallback(C=>{if(!i){(C.key==="ArrowDown"||C.key==="ArrowUp")&&(C.preventDefault(),r?.());return}if(C.key==="ArrowDown")C.preventDefault(),v(J=>t.length===0?0:h?(J+1)%t.length:Math.min(J+1,t.length-1));else if(C.key==="ArrowUp")C.preventDefault(),v(J=>t.length===0?0:h?(J-1+t.length)%t.length:Math.max(J-1,0));else if(C.key==="Enter"){const J=t[j];J!==void 0&&(C.preventDefault(),a(J,j))}else C.key==="Escape"&&o?.()},[i,t,j,h,a,o,r]);return{activeIndex:j,setActiveIndex:v,handleKeyDown:R}}const qn=({options:t,value:i,onChange:a,searchable:o=!0,clearable:r,loading:h,placeholder:j,label:v,error:R,helperText:C,required:J,disabled:Y,readOnly:$,size:N="md",id:Q,className:te,style:ee,data:ne,columns:A,valueField:y="id",displayField:D,dropdownWidth:f,menuGap:w,labelPlacement:q,errorPlacement:p,labelWidth:m,controlWidth:S})=>{const X=Y||$||h,P=x.bc(Q),{t:b}=x.Gt(),[s,z]=n.useState(!1),[M,d]=n.useState(""),c=n.useRef(null),l=n.useRef(null),{popupRef:g,coords:E,ready:_,themeClass:T,portalTarget:L}=Ye.useAnchoredPopup(s,l,()=>z(!1)),I=!!(ne&&A&&A.length>0),k=D??(A&&A[0]?.key),G=n.useMemo(()=>!I||!ne?[]:ne.map(se=>({value:String(se[y]??""),label:k?String(se[k]??""):""})),[I,ne,y,k]),B=I?G:t??[],me=B.find(se=>String(se.value)===i),le=n.useMemo(()=>{if(!I||!ne)return[];if(!M)return ne;const se=M.toLowerCase();return ne.filter(ge=>A.some(ie=>String(ge[ie.key]??"").toLowerCase().includes(se)))},[I,ne,A,M]),ue=n.useMemo(()=>{if(I||!M)return B;const se=M.toLowerCase();return B.filter(ge=>ge.label.toLowerCase().includes(se))},[B,M,I]),je=I?le:ue,{activeIndex:be,setActiveIndex:ke,handleKeyDown:he}=Xn(je,{open:s,onSelect:se=>{const ge=String(I?se[y]??"":se.value);a(ge),z(!1),d("")},onClose:()=>z(!1)});return e.jsxs("div",{className:`nice-field nice-field--lookup nice-field--${N} ${R?"nice-field--error":""} ${q==="left"?"nice-field--label-left":""} ${p==="right"&&(R||C)?"nice-field--error-right":""} ${h?"nice-field--loading":""} ${Y?"nice-field--disabled":""} ${te||""}`,style:{...S!=null&&{"--nice-field-control-width":typeof S=="number"?`${S}px`:S},...m!=null&&{"--nice-field-label-width":typeof m=="number"?`${m}px`:m},...w!=null&&{"--nice-dropdown-gap":`${w}px`},...ee},"aria-busy":h||void 0,ref:c,children:[v&&e.jsxs("label",{className:"nice-field__label",htmlFor:P,children:[v,J&&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:P,className:`nice-select__trigger ${Y?"nice-select__trigger--disabled":""}`,onClick:()=>!X&&z(!s),disabled:Y,"aria-readonly":$||void 0,"aria-expanded":s,children:[e.jsx("span",{children:me?.label||j||b("controls.select","Select...")}),e.jsxs("span",{style:{display:"flex",alignItems:"center",gap:4},children:[r&&i&&!Y&&!$&&e.jsx("span",{className:"nice-input__clear",role:"button",tabIndex:0,"aria-label":b("controls.clear","Clear"),onClick:se=>{se.stopPropagation(),a("")},children:e.jsx(x.oa,{name:"close",size:14})}),e.jsx("span",{className:`nice-select__arrow${$?" nice-select__arrow--hidden":""}`,children:e.jsx(x.oa,{name:"chevron-down",size:16})})]})]}),s&&E&&L&&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:E.top,left:E.left,zIndex:1e3,marginTop:"var(--nice-dropdown-gap, 0px)",background:"var(--bg-primary)",border:"1px solid var(--border-color)",borderRadius:"var(--nice-radius-md)",boxShadow:"0 4px 16px var(--nice-overlay-15, rgba(0, 0, 0, 0.15))",minWidth:E.width,width:f!=null?typeof f=="number"?`${f}px`:f:I?"max-content":E.width,opacity:_?1:0,pointerEvents:_?void 0:"none"},children:[o&&e.jsx("div",{className:"nice-dropdown__search",style:{padding:6},children:e.jsx("input",{type:"text",value:M,onChange:se=>{d(se.target.value),ke(0)},onKeyDown:he,placeholder:b("controls.search","Search..."),autoFocus:!0,style:{width:"100%",padding:"4px 8px",border:"1px solid var(--border-color)",borderRadius:4,background:"var(--bg-primary)",color:"var(--text-primary)"}})}),I?e.jsxs("table",{className:"nice-lookup__grid",role:"listbox",style:{width:"100%",borderCollapse:"collapse",color:"var(--text-primary)"},children:[e.jsx("thead",{children:e.jsx("tr",{children:A.map(se=>e.jsx("th",{style:{padding:"6px 10px",textAlign:"left",fontSize:12,fontWeight:600,color:"var(--text-secondary)",background:"var(--bg-secondary)",borderBottom:"1px solid var(--border-color)",width:se.width!=null?typeof se.width=="number"?`${se.width}px`:se.width:void 0},children:se.header},se.key))})}),e.jsx("tbody",{children:le.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:A.length,style:{padding:12,textAlign:"center",color:"var(--text-muted)"},children:b("controls.noResults","No results")})}):le.map((se,ge)=>{const ie=String(se[y]??""),re=ie===i,pe=ge===be;return e.jsx("tr",{role:"option","aria-selected":re,onClick:()=>{a(ie),z(!1),d("")},style:{cursor:"pointer",background:re||pe?"var(--hover-bg)":"transparent"},onMouseEnter:()=>ke(ge),children:A.map(H=>e.jsx("td",{style:{padding:"6px 10px",fontSize:13,borderBottom:"1px solid var(--border-color)"},children:String(se[H.key]??"")},H.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:ue.length===0?e.jsx("li",{className:"nice-dropdown__empty",style:{padding:8,color:"var(--text-muted)"},children:b("controls.noResults","No results")}):ue.map((se,ge)=>e.jsx("li",{role:"option",className:`nice-dropdown__option ${String(se.value)===i?"nice-dropdown__option--selected":""} ${ge===be?"nice-dropdown__option--active":""}`,onClick:()=>{a(String(se.value)),z(!1),d("")},onMouseEnter:()=>ke(ge),"aria-selected":String(se.value)===i,children:se.label},String(se.value)))})]}),L)]}),h&&e.jsx("span",{className:"nice-field__spinner",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})}),p==="right"&&R&&e.jsx("div",{className:"nice-field__error",role:"alert",children:R}),p==="right"&&!R&&C&&e.jsx("div",{className:"nice-field__hint",children:C})]}),p!=="right"&&R&&e.jsx("div",{className:"nice-field__error",children:R}),p!=="right"&&!R&&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:j,maxDepth:v})=>{const R=typeof v=="number"?Math.min(10,Math.max(1,v)):1/0,J=!(i+1>=R)&&t.children&&t.children.length>0,Y=o.has(t.key),$=a.has(t.key),N=!J,Q=!t.disabled&&(!j||N),te=Math.min(i+1,10),ee={paddingLeft:i*16+14,"--nice-row-bg":`var(--nice-tree-level-${te}-bg, transparent)`,"--nice-row-text":`var(--nice-tree-level-${te}-text, inherit)`,"--nice-row-hover-bg":`var(--nice-tree-level-${te}-hover-bg, var(--bg-secondary, #f3f4f6))`,"--nice-row-active-bg":`var(--nice-tree-level-${te}-active-bg, var(--nice-primary-tint-10, rgba(59,130,246,0.1)))`};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`nice-tree-select__node ${$?"nice-tree-select__node--selected":""} ${t.disabled?"nice-tree-select__node--disabled":""}`,style:ee,"data-nice-depth":te,onClick:()=>{t.disabled||(J?r(t.key):Q&&h(t.key))},role:"treeitem","aria-selected":$,"aria-expanded":J?Y:void 0,"aria-disabled":t.disabled,children:[J?e.jsx("button",{type:"button",className:"nice-tree-select__toggle-btn",onClick:ne=>{ne.stopPropagation(),r(t.key)},"aria-label":"Toggle",children:e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"currentColor",style:{transform:Y?"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})]}),J&&Y&&t.children.map(ne=>e.jsx(nn,{node:ne,level:i+1,selectedKeys:a,expandedKeys:o,onToggleExpand:r,onSelect:h,selectableLeafsOnly:j,maxDepth:v},ne.key))]})},an=n.forwardRef(({nodes:t,value:i,onChange:a,multiple:o=!1,searchable:r=!1,placeholder:h,selectableLeafsOnly:j=!1,clearable:v=!1,maxDepth:R,label:C,helperText:J,error:Y,required:$,disabled:N,readOnly:Q,size:te="md",name:ee,id:ne,className:A,style:y,controlWidth:D,menuGap:f,...w},q)=>{const{t:p}=x.Gt(),m=x.bc(ne),[S,X]=n.useState(!1),[P,b]=n.useState(""),[s,z]=n.useState(new Set),M=n.useRef(null),{popupRef:d,coords:c,ready:l,themeClass:g,portalTarget:E}=Ye.useAnchoredPopup(S,M,()=>X(!1)),_=n.useMemo(()=>i==null?new Set:new Set(Array.isArray(i)?i:[i]),[i]),T=n.useMemo(()=>P?tn(t,P):t,[t,P]),L=n.useMemo(()=>{const B=Wn(t);return Array.from(_).map(me=>B.find(le=>le.key===me)?.label).filter(Boolean)},[_,t]),I=n.useCallback(B=>{z(me=>{const le=new Set(me);return le.has(B)?le.delete(B):le.add(B),le})},[]),k=n.useCallback(B=>{if(o){const me=new Set(_);me.has(B)?me.delete(B):me.add(B),a?.(Array.from(me))}else a?.(B),X(!1)},[o,_,a]),G=n.useCallback(B=>{B.stopPropagation(),a?.(o?[]:"")},[a,o]);return e.jsxs("div",{className:`nice-field nice-field--${te} ${A||""}`,style:{width:"fit-content",maxWidth:"100%",...f!=null&&{"--nice-dropdown-gap":`${f}px`},...y},...w,children:[C&&e.jsx("label",{htmlFor:m,className:`nice-field__label ${$?"nice-field__label--required":""}`,children:C}),e.jsxs("div",{ref:M,className:"nice-tree-select",style:{position:"relative",width:D!=null&&D!==""?typeof D=="number"?`${D}px`:D:"var(--nice-field-control-width, 220px)"},children:[e.jsxs("div",{ref:q,id:m,className:`nice-input nice-input--${te} ${Y?"nice-input--error":""} ${N?"nice-input--disabled":""} ${Q?"nice-input--readonly":""}`,role:"combobox","aria-expanded":S,"aria-haspopup":"tree","aria-invalid":!!Y,tabIndex:N?-1:0,onClick:()=>!N&&!Q&&X(!S),onKeyDown:B=>{(B.key==="Enter"||B.key===" ")&&(B.preventDefault(),!N&&!Q&&X(!S))},children:[e.jsx("span",{className:"nice-tree-select__display",children:L.length>0?L.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:G,"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&&E&&Ze.createPortal(e.jsxs("div",{ref:d,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:B=>B.stopPropagation(),role:"presentation",children:e.jsx("input",{type:"text",placeholder:p("controls.search","Search..."),value:P,onChange:B=>b(B.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(B=>e.jsx(nn,{node:B,level:0,selectedKeys:_,expandedKeys:s,onToggleExpand:I,onSelect:k,selectableLeafsOnly:j,maxDepth:R},B.key))})]}),E)]}),ee&&e.jsx("input",{type:"hidden",name:ee,value:Array.isArray(i)?i.join(","):i??""}),Y&&e.jsx("div",{id:`${m}-error`,className:"nice-field__error",role:"alert",children:Y}),!Y&&J&&e.jsx("div",{id:`${m}-helper`,className:"nice-field__helper",children:J})]})});an.displayName="NiceTreeSelect";const Vn=({displayValue:t,placeholder:i,clearable:a,children:o,onClear:r,open:h,onOpenChange:j,dropdownWidth:v,searchable:R=!0,onSearch:C,searchPlaceholder:J,label:Y,error:$,helperText:N,required:Q,disabled:te,size:ee="md",id:ne,className:A,style:y,accessMode:D,showKeyboardHints:f,displayStyle:w})=>{x.rc("input",w),x.ac("input",w);const q=x.Dc(D,ne),p=q==="hidden";(q==="disabled"||q==="readOnly")&&(te=!0);const m=x.bc(ne),{t:S}=x.Gt(),[X,P]=n.useState(!1),[b,s]=n.useState(""),z=n.useRef(null),M=n.useRef(null),d=h??X,c=n.useMemo(()=>[{key:"Enter",description:S("shortcuts.openDropdown","Open dropdown")},x.Yc.cancel],[S]),l=I=>{j?j(I):P(I)},{popupRef:g,coords:E,ready:_,themeClass:T,portalTarget:L}=Ye.useAnchoredPopup(d,M,()=>l(!1));return p?null:e.jsxs("div",{className:`nice-field nice-field--${ee} ${$?"nice-field--error":""} ${A||""}`,style:y,ref:z,children:[Y&&e.jsxs("label",{className:"nice-field__label",htmlFor:m,children:[Y,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:m,className:"nice-select__trigger",onClick:()=>!te&&l(!d),disabled:te,children:[e.jsx("span",{children:t||i||S("controls.select","Select...")}),e.jsxs("span",{style:{display:"flex",alignItems:"center",gap:4},children:[a&&t&&!te&&e.jsx("span",{className:"nice-input__clear",role:"button",tabIndex:0,"aria-label":S("controls.clear","Clear"),onClick:I=>{I.stopPropagation(),r?.()},onKeyDown:I=>{(I.key==="Enter"||I.key===" ")&&(I.preventDefault(),I.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})})]})]}),d&&E&&L&&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:E.left,top:E.top,width:v??E.width,minWidth:v??E.width,zIndex:1e3,maxHeight:320,overflowY:"auto",opacity:_?1:0,pointerEvents:_?void 0:"none"},children:[R&&C&&e.jsx("div",{className:"nice-select__search",children:e.jsx("input",{type:"text",value:b,onChange:I=>{s(I.target.value),C(I.target.value)},placeholder:J??S("controls.search","Search..."),autoFocus:!0})}),o]}),L)]}),$&&e.jsx("div",{className:"nice-field__error",children:$}),N&&!$&&e.jsx("div",{className:"nice-field__hint",children:N})]})};function We(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:j=!1,searchable:v,groupBy:R,sortable:C=!1,bulkActions:J=!0,maxRight:Y,sourceHeader:$,targetHeader:N,disabled:Q=!1,size:te="md",className:ee,style:ne,id:A,...y},D)=>{const{t:f}=x.Gt(),w=Jn[te]??14,[q,p]=n.useState(new Set),[m,S]=n.useState(new Set),[X,P]=n.useState(""),[b,s]=n.useState(""),[z,M]=n.useState(null),d=n.useCallback((I,k,G)=>{k(B=>{const me=new Set(B);return me.has(G)?me.delete(G):me.add(G),me})},[]),c=n.useCallback(()=>{const I=t.filter(me=>q.has(We(me,o))),k=t.filter(me=>!q.has(We(me,o))),G=typeof Y=="number"?I.slice(0,Math.max(0,Y-i.length)):I,B=I.slice(G.length);a([...k,...B],[...i,...G]),p(new Set)},[t,i,q,o,a,Y]),l=n.useCallback(()=>{const I=i.filter(G=>m.has(We(G,o))),k=i.filter(G=>!m.has(We(G,o)));a([...t,...I],k),S(new Set)},[t,i,m,o,a]),g=n.useCallback(()=>{if(typeof Y=="number"){const I=Math.max(0,Y-i.length),k=t.slice(0,I),G=t.slice(I);a(G,[...i,...k])}else a([],[...i,...t]);p(new Set)},[t,i,a,Y]),E=n.useCallback(()=>{a([...t,...i],[]),S(new Set)},[t,i,a]),_=(I,k)=>{if(!k)return I;const G=k.toLowerCase();return I.filter(B=>String(B[r]).toLowerCase().includes(G))},T=J===!1?{moveAll:!1,removeAll:!1}:J===!0||J===void 0?{moveAll:!0,removeAll:!0}:{moveAll:J.moveAll??!0,removeAll:J.removeAll??!0},L=(I,k,G,B,me,le,ue)=>{let je=_(I,B);C||(je=[...je].sort((re,pe)=>String(re[r]).localeCompare(String(pe[r]),void 0,{numeric:!0,sensitivity:"base"})));const be=v===!0||j&&v===void 0?"both":v??!1,ke=be==="both"||be==="left"&&ue==="left"||be==="right"&&ue==="right",he=(()=>{if(!R)return[{label:"",items:je}];const re=new Map;for(const pe of je){const H=String(R(pe));let O=re.get(H);O||(O=[],re.set(H,O)),O.push(pe)}return[...re.entries()].map(([pe,H])=>({label:pe,items:H}))})(),se=(re,pe)=>{re.dataTransfer.setData("text/plain",pe),re.dataTransfer.effectAllowed="move"},ge=(re,pe)=>{if(re.preventDefault(),!C)return;const H=re.currentTarget.getBoundingClientRect(),O=re.clientY<H.top+H.height/2;M(K=>K&&K.side===ue&&K.key===pe&&K.before===O?K:{side:ue,key:pe,before:O})},ie=(re,pe)=>{re.preventDefault();const H=z?.before??!1;M(null);const O=re.dataTransfer.getData("text/plain");if(!O||!C)return;const ye=[...ue==="right"?i:t],ce=ye.findIndex(oe=>We(oe,o)===O),F=ye.findIndex(oe=>We(oe,o)===pe);if(ce===-1||F===-1||O===pe)return;let Z=H?F:F+1;const[U]=ye.splice(ce,1);ce<Z&&(Z-=1),ye.splice(Z,0,U),a(ue==="right"?t:ye,ue==="right"?ye:i)};return e.jsxs("div",{className:"nice-picklist__panel",children:[le&&e.jsx("div",{className:"nice-picklist__header",children:le}),ke&&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:B,onChange:re=>me(re.target.value)})}),e.jsxs("div",{className:"nice-picklist__list",role:"listbox","aria-multiselectable":"true",children:[he.map(re=>e.jsxs(n.Fragment,{children:[re.label&&e.jsx("div",{className:"nice-picklist__group-header",role:"presentation",children:re.label}),re.items.map(pe=>{const H=We(pe,o),O=k.has(H),ye=z&&z.side===ue&&z.key===H?z.before?"nice-picklist__item--drop-before":"nice-picklist__item--drop-after":"";return e.jsxs("div",{className:`nice-picklist__item ${O?"nice-picklist__item--selected":""} ${ye}`,role:"option","aria-selected":O,draggable:C,onDragStart:C?ce=>se(ce,H):void 0,onDragOver:C?ce=>ge(ce,H):void 0,onDrop:C?ce=>ie(ce,H):void 0,onDragEnd:C?()=>M(null):void 0,onClick:()=>!Q&&d(k,G,H),children:[C&&e.jsx("span",{className:"nice-picklist__drag-handle","aria-hidden":"true",children:e.jsxs("svg",{width:w,height:w,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(pe,ue):String(pe[r])]},H)})]},re.label||"__none__")),je.length===0&&e.jsx("div",{className:"nice-picklist__empty",children:f("controls.noItems","No items")})]})]})};return e.jsxs("div",{ref:D,id:A,className:`nice-picklist nice-picklist--${te} ${Q?"nice-picklist--disabled":""} ${ee||""}`,style:ne,...y,children:[L(t,q,p,X,P,$??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--${te}`,disabled:Q||q.size===0,onClick:c,"aria-label":f("picklist.moveRight","Move right"),children:e.jsx("svg",{width:w,height:w,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--${te}`,disabled:Q||t.length===0,onClick:g,"aria-label":f("picklist.moveAllRight","Move all right"),children:e.jsxs("svg",{width:w,height:w,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--${te}`,disabled:Q||m.size===0,onClick:l,"aria-label":f("picklist.moveLeft","Move left"),children:e.jsx("svg",{width:w,height:w,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--${te}`,disabled:Q||i.length===0,onClick:E,"aria-label":f("picklist.moveAllLeft","Move all left"),children:e.jsxs("svg",{width:w,height:w,viewBox:"0 0 20 20",fill:"currentColor",children:[e.jsx("path",{d:"M15.707 5.293a1 1 0 010 1.414L12.414 10l3.293 3.293a1 1 0 01-1.414 1.414l-4-4a1 1 0 010-1.414l4-4a1 1 0 011.414 0z"}),e.jsx("path",{d:"M9.707 5.293a1 1 0 010 1.414L6.414 10l3.293 3.293a1 1 0 01-1.414 1.414l-4-4a1 1 0 010-1.414l4-4a1 1 0 011.414 0z"})]})})]}),L(i,m,S,b,s,N??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,onStartChange:a,onEndChange:o,min:r,max:h,clearable:j,startPlaceholder:v,endPlaceholder:R,startLabel:C,endLabel:J,layout:Y="horizontal",separator:$="–",gap:N=12,fullWidth:Q=!1,dateFormatPreset:te,locale:ee,timeSelectorType:ne,type:A,endCondition:y="greater-or-equal",startCondition:D="today-or-greater",singleField:f=!1,label:w,error:q,helperText:p,required:m,disabled:S,size:X="md",id:P,className:b,style:s,accessMode:z,showKeyboardHints:M,labelPlacement:d,errorPlacement:c,labelWidth:l,controlWidth:g,loading:E,readOnly:_})=>{const T=x.Dc(z,P),L=x.bc(P),{t:I}=x.Gt(),k=T==="disabled"||T==="readOnly"||!!S,G=n.useMemo(()=>[{key:"Tab",description:I("shortcuts.switchField","Switch between start/end")},x.Yc.cancel],[I]),B=n.useRef(null),me=n.useRef(null),[le,ue]=n.useState(!1),[je,be]=n.useState(null),[ke,he]=n.useState(""),ge=n.useContext(x.Er)?.portalTarget??(typeof document<"u"?document.body:null);n.useLayoutEffect(()=>{if(!le)return;const Ne=B.current?.getBoundingClientRect();Ne&&(be({left:Ne.left,top:Ne.bottom+6}),he(Ye.scopeThemeClass(B.current)))},[le]),n.useEffect(()=>{if(!le)return;const Ne=Le=>{const Ce=Le.target;B.current?.contains(Ce)||me.current?.contains(Ce)||ue(!1)},Ae=Le=>{Le.key==="Escape"&&ue(!1)},Fe=()=>{const Le=B.current?.getBoundingClientRect();Le&&be({left:Le.left,top:Le.bottom+6})};return document.addEventListener("mousedown",Ne),document.addEventListener("keydown",Ae),window.addEventListener("scroll",Fe,!0),window.addEventListener("resize",Fe),()=>{document.removeEventListener("mousedown",Ne),document.removeEventListener("keydown",Ae),window.removeEventListener("scroll",Fe,!0),window.removeEventListener("resize",Fe)}},[le]);const ie=Qn(te),re=D==="today-or-greater"?lt(r,ie):D==="greater-than-today"?lt(r,It(ie,1)):r,pe=y==="greater-or-equal"?lt(r,t):y==="greater"?lt(r,t?It(t,1):void 0):r,H=n.useMemo(()=>{if(q)return q;if(t&&i){if(y==="greater-or-equal"&&i<t)return I("daterange.endBeforeStart","End date must be on or after the start date");if(y==="greater"&&i<=t)return I("daterange.endAfterStart","End date must be after the start date")}if(t){if(D==="today-or-greater"&&t<ie)return I("daterange.startInPast","Start date cannot be in the past");if(D==="greater-than-today"&&t<=ie)return I("daterange.startAfterToday","Start date must be after today")}},[q,t,i,D,y,ie,I]);if(T==="hidden")return null;const O=Ne=>{a(Ne),Ne&&i&&Ne>i&&o(Ne)},K=Y==="horizontal",ye=Ct(te),ce=ee||rt.getDefaultLocale(),F=typeof $=="string"&&$!==""?$:"–",Z=jt(t,ce,te),U=jt(i,ce,te),oe=Z||U?`${Z||"…"} ${F} ${U||"…"}`:"",de=(()=>{const Ne=jt("2026-12-30T22:58",ce,te),Ae=`${Ne} ${F} ${Ne}`;return`${(Math.max(At(Ae),At(oe))+1.5).toFixed(1)}ch`})(),xe=(Ne,Ae)=>ye==="datetime"?Ae&&Ae.length>10?`${Ne}${Ae.slice(10)}`:`${Ne}T00:00`:ye==="month"?Ne.slice(0,7):Ne,we=({start:Ne,end:Ae})=>{a(Ne?xe(Ne,t):""),o(Ae?xe(Ae,i):""),Ne&&Ae&&ue(!1)},Re=()=>{a(""),o("")},Te=()=>{!k&&!_&&ue(Ne=>!Ne)},Oe=Ne=>Ne&&Ne.length>=10?Ne.slice(0,10):Ne||void 0;return e.jsxs("div",{className:`nice-field nice-field--${X} nice-daterange nice-daterange--${Y} ${d==="left"?"nice-field--label-left":""} ${H?"nice-field--error":""} ${E?"nice-field--loading":""} ${b||""}`,style:{...s,...l!=null&&{"--nice-field-label-width":typeof l=="number"?`${l}px`:l},...g!=null&&{"--nice-field-control-width":typeof g=="number"?`${g}px`:g}},"aria-busy":E||void 0,children:[w&&e.jsxs("label",{className:"nice-field__label",htmlFor:L,children:[w,m&&e.jsx("span",{className:"nice-field__required",children:"*"}),M&&e.jsx(x.ha,{shortcuts:G,size:"sm"})]}),e.jsxs("div",{className:"nice-field__control",children:[f?e.jsxs("div",{ref:B,className:`nice-input nice-input--date nice-input--${X} nice-daterange__single ${H?"nice-input--error":""} ${k?"nice-input--disabled":""} ${_?"nice-input--readonly":""}`,style:{position:"relative",width:Q?"100%":"fit-content"},children:[e.jsx("input",{id:L,className:"nice-input__native",type:"text",readOnly:!0,value:oe,placeholder:v||I("controls.startDate","Start date"),disabled:k||E,autoComplete:"off","aria-invalid":!!H,"aria-label":w?void 0:I("controls.startDate","Start date"),onClick:Te,style:{width:Q?"100%":de,cursor:k||_?void 0:"pointer"}}),j&&e.jsx("button",{type:"button",className:"nice-input__clear",onClick:Re,disabled:!t&&!i||k||_,"aria-label":I("controls.clear","Clear"),tabIndex:(t||i)&&!k&&!_?0:-1,children:e.jsx(x.oa,{name:"close",size:14})}),e.jsx("button",{type:"button",className:"nice-input__picker-trigger",onClick:Te,"aria-label":I("controls.openPicker","Open picker"),"aria-expanded":le,tabIndex:-1,disabled:k||_,children:e.jsx(x.oa,{name:"calendar",size:16})})]}):e.jsxs("div",{className:"nice-daterange__row",style:{display:"flex",flexDirection:K?"row":"column",alignItems:K?d==="left"?"center":"flex-end":"stretch",gap:N,flexWrap:K?"nowrap":"wrap"},children:[e.jsx("div",{style:{flex:Q?"1 1 0":void 0,minWidth:0},children:e.jsx(rt.NiceDateTimePicker,{id:L,dateFormatPreset:te,displayLocale:ee,timeSelectorType:ne,type:A,label:C,value:t,onChange:O,min:re,max:i||h,placeholder:v||I("controls.startDate","Start date"),disabled:k,readOnly:_,size:X,clearable:j,labelPlacement:d,labelWidth:l})}),K&&$!==""&&$!=null&&e.jsx("span",{className:"nice-daterange__separator",style:{paddingBottom:8,color:"var(--text-secondary, #666)"},"aria-hidden":"true",children:$}),e.jsx("div",{style:{flex:Q?"1 1 0":void 0,minWidth:0},children:e.jsx(rt.NiceDateTimePicker,{dateFormatPreset:te,displayLocale:ee,timeSelectorType:ne,type:A,label:J,value:i,onChange:o,min:pe||t||r,max:h,placeholder:R||I("controls.endDate","End date"),disabled:k,readOnly:_,size:X,clearable:j,labelPlacement:d,labelWidth:l})})]}),f&&le&&je&&ge&&Ze.createPortal(e.jsxs("div",{ref:me,className:`nice-datetime-popup${ke?` ${ke}`:""}`,style:{position:"fixed",left:je.left,top:je.top,zIndex:1e3},role:"dialog","aria-label":I("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:Oe(t),rangeEnd:Oe(i),onRangeChange:we,min:Oe(re),max:Oe(h),size:X})})}),j&&e.jsx("div",{className:"nice-datetime-popup__footer",children:e.jsx("button",{type:"button",className:"nice-datetime-popup__btn",onClick:Re,disabled:!t&&!i,children:I("controls.clear","Clear")})})]}),ge),E&&e.jsx("span",{className:"nice-field__spinner",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})}),c==="right"&&H&&e.jsx("div",{className:"nice-field__error",role:"alert",children:H}),c==="right"&&!H&&p&&e.jsx("div",{className:"nice-field__helper",children:p})]}),c!=="right"&&H&&e.jsx("div",{className:"nice-field__error",children:H}),c!=="right"&&!H&&p&&e.jsx("div",{className:"nice-field__hint",children:p})]})};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 zt(t,i={}){const a=i.size??16,o="currentColor",r="currentColor";if(i.rectangle||t==="shade-chain"||t==="monochromatic"){const Y=Math.max(3,Math.min(7,i.count??5)),$=a*.1,N=a-$*2,Q=Math.max(1.2,a/14),te=a/2,ee=Array.from({length:Y},(ne,A)=>{const y=$+N*A/(Y-1),D=.25+.75*A/(Y-1);return e.jsx("circle",{cx:y,cy:te,r:Q,fill:r,opacity:D},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 j=i.angles??ei(t),v=a/2,R=a/2,C=a/2-2,J=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:v,cy:R,r:C,fill:"none",stroke:o,strokeOpacity:.25}),j.map((Y,$)=>{const N=(Y-90)*Math.PI/180,Q=v+C*Math.cos(N),te=R+C*Math.sin(N);return e.jsx("circle",{cx:Q,cy:te,r:J,fill:r},$)})]})}function Dt(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 j=0,v=0,R=0;return t<60?(j=o,v=r):t<120?(j=r,v=o):t<180?(v=o,R=r):t<240?(v=r,R=o):t<300?(j=r,R=o):(j=o,R=r),{r:Math.round((j+h)*255),g:Math.round((v+h)*255),b:Math.round((R+h)*255)}}function $t({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 j=0;return h!==0&&(o===t?j=(i-a)/h%6:o===i?j=(a-t)/h+2:j=(t-i)/h+4,j=(j*60+360)%360),{h:j,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 j=o-r,v=h>.5?j/(2-o-r):j/(o+r);let R=0;return o===t?R=((i-a)/j+(i<a?6:0))/6:o===i?R=((a-t)/j+2)/6:R=((t-i)/j+4)/6,{h:R*360,s:v,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 ze(t){return cn(sn(t))}function Ke(t){return $t(st(t))}function ln(t,i){const a=[];for(let o=0;o<i;o++){const r=i<=1?.5:o/(i-1),h=Dt(t.s*(.3+r*.7),0,1),j=Dt(t.v*(1.2-r*.7),0,1);a.push(ze({h:t.h,s:h,v:j}))}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 j=0;j<o;j++){const v=(j-r)*a,R=Math.max(.05,Math.min(.98,t.v+v)),C=Math.max(.05,Math.min(1,t.s-Math.abs(v)*.25));h.push(ze({h:t.h,s:C,v:R}))}return h}function Pt({r:t,g:i,b:a}){const[o,r,h]=[t,i,a].map(j=>{const v=j/255;return v<=.03928?v/12.92:Math.pow((v+.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 ze({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 j=0;j<i;j++){const v=r[j%r.length],R=.55+Math.random()*.4,C=.5+Math.random()*.45;h.push(ze({h:v+(Math.random()-.5)*8,s:R,v:C}))}return h}const ni=({hues:t,colors:i,baseHue:a,onBaseHueChange:o,mode:r,distance:h,disabled:j})=>{const $=n.useRef(null),N=n.useCallback((y,D)=>{const f=$.current;if(!f)return;const w=f.getBoundingClientRect(),q=(y-w.left)/w.width*240-120,p=(D-w.top)/w.height*240-120,m=(Math.atan2(p,q)*180/Math.PI+360)%360;o(Math.round(m))},[120,120,240,o]),Q=n.useCallback(y=>{if(j)return;y.preventDefault(),N(y.clientX,y.clientY);const D=w=>N(w.clientX,w.clientY),f=()=>{document.removeEventListener("pointermove",D),document.removeEventListener("pointerup",f)};document.addEventListener("pointermove",D),document.addEventListener("pointerup",f)},[j,N]),te=[];for(let y=0;y<360;y+=2){const D=(y-1)*Math.PI/180,f=(y+1)*Math.PI/180,w=ze({h:y,s:1,v:1});te.push(e.jsx("path",{d:`M${120+55*Math.cos(D)},${120+55*Math.sin(D)} L${120+110*Math.cos(D)},${120+110*Math.sin(D)} 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(D)},${120+55*Math.sin(D)} Z`,fill:w},y))}const ee=`wheel-center-${r}`,ne=t.map((y,D)=>{const w=y*Math.PI/180;return e.jsx("circle",{cx:120+82.5*Math.cos(w),cy:120+82.5*Math.sin(w),r:D===0?8:6,fill:i?.[D]??ze({h:y,s:.85,v:.9}),stroke:D===0?"var(--bg-primary, #fff)":"var(--border-color, #ccc)",strokeWidth:D===0?3:2},D)});let A=null;if(r==="analogous"||r==="split-complementary"||r==="analogous-complementary"){const f=gt(r,h).slice(1).map((w,q)=>{const p=(a+w)*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:$,className:"nice-palette__wheel",viewBox:"0 0 240 240",width:240,height:240,onPointerDown:Q,style:{cursor:j?"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"})]})}),te,e.jsx("circle",{cx:120,cy:120,r:53,fill:ze({h:a,s:.6,v:.85})}),e.jsx("circle",{cx:120,cy:120,r:53,fill:`url(#${ee})`,opacity:.4}),A,ne]})},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(--bg-primary, #ffffff)"),r=mt(t[a],"var(--text-primary, #000000)");i.push({a:t[a],b:"var(--bg-primary, #ffffff)",ratio:o,level:ut(o)}),i.push({a:t[a],b:"var(--text-primary, #000000)",ratio:r,level:ut(r)});for(let h=a+1;h<t.length;h++){const j=mt(t[a],t[h]);i.push({a:t[a],b:t[h],ratio:j,level:ut(j)})}}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=$t(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:j=1,maxColors:v=8,harmonyMode:R,onHarmonyModeChange:C,distance:J,onDistanceChange:Y,preset:$,onPresetChange:N,showWheel:Q=!0,showContrast:te=!0,showInfo:ee=!0,showPresets:ne=!0,presets:A=[],showVariations:y=!0,showRandom:D=!0,variationCount:f=5,label:w,labelPlacement:q="top",disabled:p,readOnly:m,loading:S,error:X,colorCount:P,shadeStep:b,onShadeStepChange:s,customSchemes:z,onCustomSchemesChange:M,persistCustomSchemes:d=!0},c)=>{const l=x.Dc(o,t),g=l==="hidden";l==="disabled"&&(p=!0);const E=m||l==="readOnly",_=x.bc(t),{t:T}=x.Gt(),[L,I]=n.useState("analogous-complementary"),[k,G]=n.useState(30),[B,me]=n.useState(""),[le,ue]=n.useState(0),[je,be]=n.useState(.12),[ke,he]=n.useState(null),[se,ge]=n.useState(()=>z??(d?ci():[])),[ie,re]=n.useState(null),[pe,H]=n.useState(!1),[O,K]=n.useState(null),[ye,ce]=n.useState(""),Z=n.useContext(x.Er)?.portalTarget??(typeof document<"u"?document.body:null),U=n.useRef(null),oe=n.useRef(null),de=R??L,xe=J??k,we=$??B,Re=b??je,Te=z??se;n.useEffect(()=>{!z&&d&&li(se)},[se,z,d]);const Oe=n.useCallback(W=>{ge(W),M?.(W)},[M]),Ne=n.useCallback(W=>{I(W),C?.(W)},[C]),Ae=n.useCallback(W=>{G(W),Y?.(W)},[Y]),Fe=n.useCallback(W=>{me(W),W&&N?.(W)},[N]),Le=n.useMemo(()=>["var(--color-primary, #3b82f6)","var(--color-error, #ef4444)","var(--color-success, #22c55e)"],[]),Ce=r&&r.length>0?r:Le,Ge=Ce[0],ve=n.useMemo(()=>Ke(Ge),[Ge]),Pe=n.useMemo(()=>ot(ve.h,de,xe),[ve.h,de,xe]),Be=n.useCallback((W,fe,_e,Me,He)=>{const tt=P??He??ke??Ce.length,Je=tt!==void 0?Math.max(j,Math.min(v,tt)):void 0;if(fe==="shade-chain"){const De=Je??Math.max(j,5),qe=Lt({h:W,s:ve.s||.7,v:ve.v||.6},De,Re);h?.(qe);return}let Qe;const nt=fe==="custom"&&ie?Te.find(De=>De.id===ie):null;nt&&nt.angles.length>0?Qe=nt.angles.map(De=>((W+De)%360+360)%360):Qe=ot(W,fe,_e);let Ie;if(Me&&dn[Me]?Ie=pt(Qe,Me):Ie=Qe.map(De=>ze({h:De,s:ve.s||.7,v:ve.v||.85})),nt?.lightnessOffsets?.length&&(Ie=Ie.map((De,qe)=>{const Rt=nt.lightnessOffsets?.[qe];if(Rt==null)return De;const xt=Ke(De);return ze({h:xt.h,s:xt.s,v:Math.max(.05,Math.min(.98,xt.v+Rt))})})),Je!==void 0){for(;Ie.length<Je;){const De=Ie[Ie.length-1]||"#888888",qe=Ke(De);Ie.push(ze({h:(qe.h+18)%360,s:qe.s,v:qe.v}))}Ie=Ie.slice(0,Je)}else{for(;Ie.length<j;)Ie.push(Ie[Ie.length-1]||"var(--nice-text-secondary, #888888)");Ie.length>v&&(Ie=Ie.slice(0,v))}h?.(Ie)},[ve.s,ve.v,j,v,h,P,ke,Ce.length,Re,ie,Te]),u=n.useCallback(W=>{if(!p){if(de==="custom"){const fe=ze({h:W,s:ve.s||.7,v:ve.v||.85}),_e=[...Ce];_e[le]=fe,h?.(_e);return}Be(W,de,xe,we)}},[p,de,xe,we,Be,ve.s,ve.v,Ce,le,h]),V=n.useCallback(W=>{if(p||(Ne(W),W==="custom"))return;const fe=gt(W).length,_e=fe<=1;if(P==null&&!_e){const Me=Math.max(j,Math.min(v,fe));he(Me),Be(ve.h,W,xe,we,Me)}else Be(ve.h,W,xe,we)},[p,ve.h,xe,we,Ne,Be,P,j,v]),ae=n.useCallback(W=>{p||(Ae(W),Be(ve.h,de,W,we))},[p,ve.h,de,we,Ae,Be]),$e=n.useCallback(W=>{if(p)return;Fe(W);const fe=ot(ve.h,de,xe),_e=pt(fe,W);h?.(_e.slice(0,v))},[p,ve.h,de,xe,v,Fe,h]),Ee=n.useCallback((W,fe)=>{if(p)return;const _e=[...Ce];_e[W]=fe,h?.(_e)},[p,Ce,h]),Xe=n.useCallback(()=>{if(p||Ce.length>=v)return;const W=Ke(Ce[Ce.length-1]),fe=ze({h:(W.h+30)%360,s:W.s,v:W.v});h?.([...Ce,fe])},[p,Ce,v,h]),Ve=n.useCallback(W=>{if(p||Ce.length<=j)return;const fe=Ce.filter((_e,Me)=>Me!==W);h?.(fe),le>=fe.length&&ue(Math.max(0,fe.length-1))},[p,Ce,j,h,le]),Dn=n.useCallback(()=>{if(p)return;const W=Math.max(j,Math.min(v,gt(de).length)),fe=mn(de,W,xe);h?.(fe)},[p,j,v,de,xe,h]),Et=n.useMemo(()=>{if(!y)return[];const W=Ce[le]||Ce[0];return ln(Ke(W),f)},[y,Ce,le,f]),ft=Ce[le]||Ce[0],yt=n.useMemo(()=>{const W=Ke(ft);return ze({h:(W.h+180)%360,s:W.s,v:W.v})},[ft]);if(n.useLayoutEffect(()=>{if(!pe||!U.current)return;ce(Ye.scopeThemeClass(U.current));const W=()=>{const fe=U.current?.getBoundingClientRect();if(!fe)return;const _e=600;let Me=fe.left;Me+_e>window.innerWidth-8&&(Me=Math.max(8,window.innerWidth-_e-8));let He=fe.bottom+6;He>window.innerHeight*.5&&(He=Math.max(8,window.innerHeight-Math.min(window.innerHeight-16,540)-8)),K({left:Me,top:He})};return W(),window.addEventListener("scroll",W,!0),window.addEventListener("resize",W),()=>{window.removeEventListener("scroll",W,!0),window.removeEventListener("resize",W)}},[pe]),n.useEffect(()=>{if(!pe)return;const W=_e=>{const Me=_e.target;U.current?.contains(Me)||oe.current?.contains(Me)||(Me instanceof Element?Me:Me?.parentElement??null)?.closest('.nice-select__dropdown, [role="listbox"], [role="option"]')||H(!1)},fe=_e=>{_e.key==="Escape"&&H(!1)};return document.addEventListener("mousedown",W),document.addEventListener("keydown",fe),()=>{document.removeEventListener("mousedown",W),document.removeEventListener("keydown",fe)}},[pe]),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(Ye.NiceSelect,{label:T("colorPalette.harmony","Harmony"),labelPlacement:"left",size:"sm",disabled:p,value:de==="custom"&&ie?`custom:${ie}`:de,onChange:W=>{const fe=Array.isArray(W)?W[0]:W;if(typeof fe=="string")if(fe.startsWith("custom:")){const _e=fe.slice(7);re(_e),V("custom")}else re(null),V(fe)},options:[...ri.map(W=>({value:W,label:oi[W]})),...Te.map(W=>({value:`custom:${W.id}`,label:W.name}))],renderOption:(W,fe)=>{const _e=String(W.value),Me=_e.startsWith("custom:"),He=Me?Te.find(Qe=>Qe.id===_e.slice(7)):null,tt=He?He.angles:void 0,Je=Me?"custom":_e;return e.jsxs("span",{style:{display:"inline-flex",gap:8,alignItems:"center"},children:[e.jsx("span",{style:{width:16,height:16,display:"inline-flex",color:"currentColor"},children:zt(Je,{angles:tt,size:16,count:P})}),e.jsx("span",{style:{fontWeight:fe?600:400},children:W.label})]})}}),de==="shade-chain"&&e.jsx(Ue.NiceNumberInput,{label:T("colorPalette.step","Step"),labelPlacement:"left",size:"sm",min:.02,max:.5,step:.02,precision:2,value:Re,onChange:W=>{const fe=typeof W=="number"?W:Number(W);Number.isNaN(fe)||(be(fe),s?.(fe),Be(ve.h,de,xe,we))},showStepper:!0,disabled:p}),e.jsx(Ue.NiceNumberInput,{label:T("colorPalette.colors","Colors"),labelPlacement:"left",size:"sm",min:Math.max(2,j),max:Math.min(12,v),step:1,precision:0,value:P??ke??Ce.length,onChange:W=>{const fe=typeof W=="number"?W:Number(W);if(!Number.isFinite(fe))return;const _e=Math.max(Math.max(2,j),Math.min(Math.min(12,v),Math.round(fe)));he(_e),de==="shade-chain"?h?.(Lt({h:ve.h,s:ve.s||.7,v:ve.v||.6},_e,Re)):setTimeout(()=>Be(ve.h,de,xe,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:[Ce.map((W,fe)=>e.jsxs("div",{className:`nice-palette__swatch-wrapper ${le===fe?"nice-palette__swatch-wrapper--selected":""}`,onClick:()=>ue(fe),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:_e=>_e.stopPropagation(),onChange:_e=>Ee(fe,_e.target.value)}),Ce.length>j&&e.jsx("button",{type:"button",className:"nice-palette__swatch-remove",onClick:_e=>{_e.stopPropagation(),Ve(fe)},disabled:p,"aria-label":"Remove color",children:e.jsx(x.oa,{name:"close",size:14})})]},fe)),Ce.length<v&&e.jsxs("button",{type:"button",className:"nice-palette__add-btn",onClick:Xe,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()})]}),D&&e.jsxs("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm nice-palette__random-btn",onClick:Dn,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,fe)=>e.jsx("div",{className:"nice-palette__variation-chip",style:{background:W},title:W.toUpperCase(),onClick:()=>{p||Ee(le,W)},role:"button",tabIndex:0},fe))})]}):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 fe=pt(Pe,W);return e.jsxs("button",{type:"button",className:`nice-palette__preset-card ${we===W?"nice-palette__preset-card--active":""}`,onClick:()=>$e(W),disabled:p,children:[e.jsx("div",{className:"nice-palette__preset-strip",children:fe.map((_e,Me)=>e.jsx("span",{className:"nice-palette__preset-dot",style:{background:_e}},Me))}),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})]}),te&&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:Ce})]})]}),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(--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:zt("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:()=>{re(W.id),V("custom")},disabled:p,children:"Use"}),e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--xs",onClick:()=>Oe(Te.filter(fe=>fe.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 fe=Ke(Ce[0]).h,_e=Ce.map(He=>(Ke(He).h-fe+540)%360-180),Me={id:`cs-${Date.now()}`,name:W,angles:_e};Oe([...Te,Me])},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 fe=JSON.parse(W);Array.isArray(fe)&&Oe(fe)}catch{}},children:T("colorPalette.importJson","Import JSON")})]})]})}),et=[{id:"colors",label:"Colors",content:Ln}];ne&&Mt.length>0&&et.push({id:"presets",label:"Presets",content:Bn}),y&&et.push({id:"variations",label:"Variations",content:Pn}),(ee||te)&&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:Pe,colors:Ce,baseHue:ve.h,onBaseHueChange:u,mode:de,distance:xe,disabled:p}),(de==="analogous"||de==="split-complementary"||de==="analogous-complementary")&&e.jsxs("div",{className:"nice-palette__distance",children:[e.jsxs("label",{children:["Distance: ",xe,"°"]}),e.jsx("input",{type:"range",min:10,max:90,value:xe,onChange:W=>ae(Number(W.target.value)),disabled:p,className:"nice-palette__distance-slider"})]})]}),e.jsx("button",{type:"button",className:"nice-palette__confirm",onClick:()=>H(!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(Ue.NiceTabs,{tabs:et,variant:"enclosed",size:"sm"})]});return e.jsxs("div",{ref:c,id:_,className:`nice-field nice-palette-field ${p?"nice-palette--disabled":""} ${q==="left"?"nice-field--label-left":""} ${S?"nice-field--loading":""} ${X?"nice-field--error":""} ${i||""}`,style:a,children:[w&&e.jsx("label",{htmlFor:_,className:"nice-field__label",children:w}),e.jsxs("div",{className:"nice-field__control",children:[e.jsx("div",{ref:U,className:"nice-palette__field-swatches",role:"button",tabIndex:p||E?-1:0,"aria-haspopup":"dialog","aria-expanded":pe,"aria-readonly":E||void 0,"aria-label":T("colorPalette.openStudio","Open palette studio"),onClick:()=>{!p&&!E&&H(W=>!W)},onKeyDown:W=>{!p&&!E&&(W.key==="Enter"||W.key===" ")&&(W.preventDefault(),H(fe=>!fe))},children:Ce.map((W,fe)=>e.jsx("span",{className:"nice-palette__field-swatch",style:{background:W},title:W.toUpperCase(),onClick:_e=>{_e.stopPropagation(),!p&&!E&&(ue(fe),H(!0))}},fe))}),S&&e.jsx("span",{className:"nice-field__spinner",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})}),pe&&O&&Z&&Ze.createPortal(e.jsx("div",{ref:oe,className:`nice-palette__popup${ye?` ${ye}`:""}`,"data-theme":ye==="nice-dark"?"dark":ye==="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}),Z)]}),typeof X=="string"&&X&&e.jsx("div",{className:"nice-field__error",role:"alert",children:X})]})});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,j=t.positionY??50;return`${a}radial-gradient(${o} ${r} at ${h}% ${j}%, ${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,j=0;const v=r[0].match(/^(\d+)deg$/);v&&(h=parseInt(v[1]),j=1);const R=bt(r.slice(j));return{type:"linear",angle:h,repeating:a,stops:R}}if(i.includes("radial-gradient")){const o=i.match(/radial-gradient\((.+)\)/)?.[1];if(!o)return null;const r=o.split(",").map(j=>j.trim()),h=bt(r.filter(j=>j.includes("#")||j.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(j=>j.trim()),h=bt(r.filter(j=>j.includes("#")||j.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:j=!0,showPresets:v=!0,showEditor:R=!0,showRandom:C=!0,maxStops:J=10,label:Y,labelPlacement:$="top",disabled:N,readOnly:Q,loading:te,error:ee,errorPlacement:ne="bottom",width:A},y)=>{const D=x.Dc(o,t),f=D==="hidden";D==="disabled"&&(N=!0);const w=Q||D==="readOnly",q=x.bc(t),{t:p}=x.Gt(),m=r??wt(),S=n.useMemo(()=>Nt(m),[m]),[X,P]=n.useState(0),[b,s]=n.useState(""),z=n.useRef(null),[M,d]=n.useState(!1),[c,l]=n.useState(null),[g,E]=n.useState(""),T=n.useContext(x.Er)?.portalTarget??(typeof document<"u"?document.body:null),L=n.useRef(null),I=n.useRef(null),k=typeof A=="number"?A:340;n.useLayoutEffect(()=>{if(!M||!L.current)return;E(Ye.scopeThemeClass(L.current));const F=()=>{const Z=L.current?.getBoundingClientRect();if(!Z)return;let U=Z.left;U+k>window.innerWidth-8&&(U=Math.max(8,window.innerWidth-k-8));let oe=Z.bottom+6;oe>window.innerHeight*.5&&(oe=Math.max(8,window.innerHeight-Math.min(window.innerHeight-16,520)-8)),l({left:U,top:oe})};return F(),window.addEventListener("scroll",F,!0),window.addEventListener("resize",F),()=>{window.removeEventListener("scroll",F,!0),window.removeEventListener("resize",F)}},[M,k]),n.useEffect(()=>{if(!M)return;const F=U=>{const oe=U.target;L.current?.contains(oe)||I.current?.contains(oe)||(oe instanceof Element?oe:oe?.parentElement??null)?.closest('.nice-select__dropdown, [role="listbox"], [role="option"]')||d(!1)},Z=U=>{U.key==="Escape"&&d(!1)};return document.addEventListener("mousedown",F),document.addEventListener("keydown",Z),()=>{document.removeEventListener("mousedown",F),document.removeEventListener("keydown",Z)}},[M]);const G=n.useCallback(F=>{h?.(F)},[h]),B=n.useCallback(F=>{N||G({...m,type:F})},[N,m,G]),me=n.useCallback(F=>{N||G({...m,angle:F})},[N,m,G]),le=n.useCallback(F=>{N||G({...m,repeating:F})},[N,m,G]),ue=n.useCallback(F=>{N||G({...m,shape:F})},[N,m,G]),je=n.useCallback((F,Z)=>{if(N)return;const U=m.stops.map((oe,de)=>de===F?{...oe,...Z}:oe);G({...m,stops:U})},[N,m,G]),be=n.useRef(!1),ke=n.useCallback((F,Z)=>{if(N||!z.current)return;F.stopPropagation(),F.preventDefault(),P(Z),be.current=!1;const U=de=>{if(!z.current)return;be.current=!0;const xe=z.current.getBoundingClientRect(),we=Math.round(Math.max(0,Math.min(100,(de.clientX-xe.left)/xe.width*100)));je(Z,{position:we})},oe=()=>{document.removeEventListener("pointermove",U),document.removeEventListener("pointerup",oe),document.removeEventListener("pointercancel",oe)};document.addEventListener("pointermove",U),document.addEventListener("pointerup",oe),document.addEventListener("pointercancel",oe)},[N,je]),he=n.useCallback(()=>{if(N||m.stops.length>=J)return;const F=m.stops.slice().sort((xe,we)=>xe.position-we.position);let Z=0,U=F[0];for(let xe=0;xe<F.length-1;xe++){const we=F[xe+1].position-F[xe].position;we>Z&&(Z=we,U=F[xe])}const oe=Math.round(U.position+Z/2),de="#"+Math.floor(Math.random()*16777215).toString(16).padStart(6,"0");G({...m,stops:[...m.stops,{color:de,position:oe}]})},[N,m,J,G]),se=n.useCallback(F=>{if(N||m.stops.length<=2)return;const Z=m.stops.filter((U,oe)=>oe!==F);G({...m,stops:Z}),X>=Z.length&&P(Z.length-1)},[N,m,X,G]),ge=n.useCallback(()=>{if(N)return;const F=2+Math.floor(Math.random()*3);G(mi(F))},[N,G]),ie=n.useCallback(()=>{if(N||!b.trim())return;const F=gn(b);F&&G(F)},[N,b,G]),re=n.useCallback(F=>{if(N||!z.current||m.stops.length>=J)return;const Z=F.target;if(be.current||Z.closest(".nice-gradient__stop-marker")){be.current=!1;return}const U=z.current.getBoundingClientRect(),oe=Math.round((F.clientX-U.left)/U.width*100),de="#"+Math.floor(Math.random()*16777215).toString(16).padStart(6,"0"),xe=[...m.stops,{color:de,position:oe}];G({...m,stops:xe}),P(xe.length-1)},[N,m,J,G]),pe=n.useMemo(()=>m.stops.slice().sort((F,Z)=>F.position-Z.position),[m.stops]),H=n.useMemo(()=>`linear-gradient(90deg, ${pe.map(F=>`${F.color} ${F.position}%`).join(", ")})`,[pe]);if(f)return null;const O=e.jsxs("div",{className:"nice-gradient__tab",children:[R&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"nice-gradient__type-row",children:[["linear","radial","conic"].map(F=>e.jsx("button",{type:"button",className:`nice-gradient__type-btn ${m.type===F?"nice-gradient__type-btn--active":""}`,onClick:()=>B(F),disabled:N,children:F.charAt(0).toUpperCase()+F.slice(1)},F)),e.jsxs("label",{className:"nice-gradient__repeat-label",children:[e.jsx("input",{type:"checkbox",checked:m.repeating??!1,onChange:F=>le(F.target.checked),disabled:N}),"Repeating"]})]}),e.jsxs("div",{className:"nice-gradient__controls",children:[m.type==="linear"&&e.jsxs("div",{className:"nice-gradient__control-group",children:[e.jsxs("label",{children:["Angle: ",m.angle,"°"]}),e.jsx("input",{type:"range",min:0,max:360,value:m.angle,onChange:F=>me(Number(F.target.value)),disabled:N,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 ${m.angle===F?"nice-gradient__angle-btn--active":""}`,onClick:()=>me(F),disabled:N,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))})]}),m.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 ${(m.shape||"ellipse")===F?"nice-gradient__shape-btn--active":""}`,onClick:()=>ue(F),disabled:N,children:F},F))})]}),(m.type==="radial"||m.type==="conic")&&e.jsxs("div",{className:"nice-gradient__control-group",children:[e.jsxs("label",{children:["Center: ",m.positionX??50,"%, ",m.positionY??50,"%"]}),e.jsxs("div",{className:"nice-gradient__center-inputs",children:[e.jsx("input",{type:"range",min:0,max:100,value:m.positionX??50,onChange:F=>G({...m,positionX:Number(F.target.value)}),disabled:N,className:"nice-gradient__slider"}),e.jsx("input",{type:"range",min:0,max:100,value:m.positionY??50,onChange:F=>G({...m,positionY:Number(F.target.value)}),disabled:N,className:"nice-gradient__slider"})]})]}),m.type==="conic"&&e.jsxs("div",{className:"nice-gradient__control-group",children:[e.jsxs("label",{children:["Start angle: ",m.angle,"°"]}),e.jsx("input",{type:"range",min:0,max:360,value:m.angle,onChange:F=>me(Number(F.target.value)),disabled:N,className:"nice-gradient__slider"})]})]}),e.jsxs("div",{className:"nice-gradient__bar-container",children:[e.jsx("div",{ref:z,className:"nice-gradient__bar",style:{background:H},onClick:re,children:m.stops.map((F,Z)=>e.jsx("div",{className:`nice-gradient__stop-marker ${X===Z?"nice-gradient__stop-marker--active":""}`,style:{left:`${F.position}%`},onPointerDown:U=>ke(U,Z),onClick:U=>{U.stopPropagation(),P(Z),be.current=!1},title:`${F.color} @ ${F.position}%`,children:e.jsx("div",{className:"nice-gradient__stop-dot",style:{background:F.color}})},Z))}),e.jsx("button",{type:"button",className:"nice-gradient__add-stop",onClick:he,disabled:N||m.stops.length>=J,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:pe.map((F,Z)=>{const U=m.stops.indexOf(F);return e.jsxs("div",{className:`nice-gradient__stop-row ${X===U?"nice-gradient__stop-row--active":""}`,onClick:()=>P(U),children:[e.jsx("input",{type:"color",value:F.color,onChange:oe=>je(U,{color:oe.target.value}),disabled:N,className:"nice-gradient__stop-color"}),e.jsx("input",{type:"text",value:F.color.toUpperCase(),maxLength:7,onChange:oe=>je(U,{color:oe.target.value}),disabled:N,className:"nice-gradient__stop-hex"}),e.jsx("input",{type:"number",min:0,max:100,value:F.position,onChange:oe=>je(U,{position:Number(oe.target.value)}),disabled:N,className:"nice-gradient__stop-pos"}),e.jsx("span",{className:"nice-gradient__stop-pct",children:"%"}),m.stops.length>2&&e.jsx("button",{type:"button",className:"nice-gradient__stop-del",onClick:()=>se(U),disabled:N,"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:ge,disabled:N,title:"Random gradient","aria-label":"Random gradient",children:[e.jsx(x.oa,{name:"shuffle",size:14})," Random Gradient"]})]}),K=e.jsx("div",{className:"nice-gradient__tab",children:e.jsx("div",{className:"nice-gradient__preset-grid",children:fn.map((F,Z)=>e.jsxs("button",{type:"button",className:"nice-gradient__preset-card",onClick:()=>{N||G(F.value)},disabled:N,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})]},Z))})}),ye=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:N}),e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm",onClick:ie,disabled:N,children:"Import"})]})]}),ce=[{id:"editor",label:"Editor",content:O}];return v&&ce.push({id:"presets",label:"Presets",content:K}),j&&ce.push({id:"css",label:"CSS",content:ye}),e.jsxs("div",{ref:y,id:q,className:`nice-field nice-gradient-field ${N?"nice-gradient--disabled":""} ${$==="left"?"nice-field--label-left":""} ${te?"nice-field--loading":""} ${ee?"nice-field--error":""} ${ne==="right"?"nice-field--error-right":""} ${i||""}`,style:a,children:[Y&&e.jsx("label",{htmlFor:q,className:"nice-field__label",children:Y}),e.jsxs("div",{className:"nice-field__control",children:[e.jsx("button",{ref:L,type:"button",className:"nice-gradient__swatch",style:{background:S},"aria-haspopup":"dialog","aria-expanded":M,"aria-readonly":w||void 0,"aria-label":"Open gradient editor",disabled:N,onClick:()=>{!N&&!w&&d(F=>!F)}}),te&&e.jsx("span",{className:"nice-field__spinner",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})}),ne==="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:I,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:()=>d(!1),"aria-label":p("controls.confirm","Confirm"),title:p("controls.confirm","Confirm"),children:e.jsx(x.oa,{name:"check",size:18})})]}),e.jsx(Ue.NiceTabs,{tabs:ce,variant:"enclosed",size:"sm"})]})}),T)]}),ne!=="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:j=!0,enableGenerate:v=!0,toolbar:R,languages:C=ui,textStyles:J=pi,onImprove:Y,onTranslate:$,onGenerate:N,showAIToolbar:Q=!0,value:te,onChange:ee,...ne}=i,A=n.useRef(null),[y,D]=n.useState(!1),[f,w]=n.useState(!1),[q,p]=n.useState(!1),[m,S]=n.useState(""),[X,P]=n.useState(""),[b,s]=n.useState("professional"),[z,M]=n.useState(""),[d,c]=n.useState(C[0]?.code||"en"),[l,g]=n.useState(""),[E,_]=n.useState(""),{t:T}=x.Gt(),L=x.he(),{improveText:I,translate:k,generateHtml:G,isLoading:B}=x.Cd(),me=o&&L.isConfigured,le=n.useCallback(()=>{const ie=window.getSelection();return ie&&ie.toString().trim()?ie.toString():""},[]),ue=n.useCallback(ie=>{const re=window.getSelection();if(re&&re.rangeCount>0){const pe=re.getRangeAt(0);pe.deleteContents();const H=document.createElement("div");H.innerHTML=ie;const O=document.createDocumentFragment();for(;H.firstChild;)O.appendChild(H.firstChild);if(pe.insertNode(O),A.current){const K=A.current.innerHTML;ee(K)}}},[ee]),je=n.useCallback(async(ie="professional")=>{if(!me||!h)return"";const re=le();if(!re)return"";S(re),s(ie),D(!0),P("");try{const pe=await I(re,ie);return P(pe),Y?.(re,pe,ie),pe}catch{return P(T("htmlEditorAI.improveFailed","Failed to improve text")),""}},[me,h,le,I,Y,T]),be=n.useCallback(async ie=>{if(!me||!j)return"";const re=le();if(!re)return"";S(re),c(ie),w(!0),M("");try{const pe=C.find(O=>O.code===ie)?.label||ie,H=await k(re,pe);return M(H),$?.(re,H,ie),H}catch{return M(T("htmlEditorAI.translateFailed","Failed to translate text")),""}},[me,j,le,k,C,$,T]),ke=n.useCallback(async ie=>{if(!me||!v||!ie.trim())return"";g(ie),_("");try{const re=await G(ie);return _(re),N?.(ie,re),re}catch{return _(T("htmlEditorAI.generateFailed","Failed to generate HTML")),""}},[me,v,G,N,T]),he=n.useCallback(()=>{X&&ue(X),D(!1),P("")},[X,ue]),se=n.useCallback(()=>{z&&ue(z),w(!1),M("")},[z,ue]),ge=n.useCallback(()=>{if(E&&A.current){document.execCommand("insertHTML",!1,E);const ie=A.current.innerHTML;ee(ie)}p(!1),_(""),g("")},[E,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:le,insertHtml:ie=>{document.execCommand("insertHTML",!1,ie),A.current&&ee(A.current.innerHTML)},improveSelection:je,translateSelection:be,generateHtml:ke})),n.useCallback(ie=>{A.current=ie},[]),e.jsxs("div",{className:"nice-html-editor-ai","data-testid":i["data-testid"],children:[Q&&me&&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"}),B&&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:()=>je(),disabled:B,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:J.map(({style:ie,label:re})=>e.jsx("button",{type:"button",className:"nice-html-editor-ai__dropdown-item",onClick:()=>je(ie),children:re},ie))})]}),j&&e.jsxs("div",{className:"nice-html-editor-ai__dropdown",children:[e.jsxs("button",{type:"button",className:"nice-html-editor-ai__btn",disabled:B,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:re})=>e.jsx("button",{type:"button",className:"nice-html-editor-ai__dropdown-item",onClick:()=>be(ie),children:re},ie))})]}),v&&e.jsxs("button",{type:"button",className:"nice-html-editor-ai__btn",onClick:()=>p(!0),disabled:B,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:te,onChange:ee,toolbar:R,...ne})}),y&&e.jsxs("div",{className:"nice-html-editor-ai__panel",children:[e.jsxs("div",{className:"nice-html-editor-ai__panel-header",children:[e.jsxs("h4",{children:[e.jsx(x.oa,{name:"star",size:16})," ",T("htmlEditorAI.improveText","Improve Text")]}),e.jsx("div",{className:"nice-html-editor-ai__style-selector",children:J.map(({style:ie,label:re})=>e.jsx("button",{type:"button",className:`nice-html-editor-ai__style-btn ${b===ie?"nice-html-editor-ai__style-btn--active":""}`,onClick:()=>{s(ie),je(ie)},children:re},ie))}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__close","aria-label":T("htmlEditorAI.close","Close"),onClick:()=>D(!1),children:e.jsx(x.oa,{name:"close",size:14})})]}),e.jsx("div",{className:"nice-html-editor-ai__panel-body",children:B?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:m})]}),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:X})]})]})}),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:!X||B,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:()=>{D(!1),P("")},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:d,onChange:ie=>{c(ie.target.value),be(ie.target.value)},className:"nice-html-editor-ai__language-select",children:C.map(({code:ie,label:re})=>e.jsx("option",{value:ie,children:re},ie))})}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__close","aria-label":T("htmlEditorAI.close","Close"),onClick:()=>w(!1),children:e.jsx(x.oa,{name:"close",size:14})})]}),e.jsx("div",{className:"nice-html-editor-ai__panel-body",children:B?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:m})]}),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===d)?.label||d}),e.jsx("div",{className:"nice-html-editor-ai__text-content",children:z})]})]})}),e.jsxs("div",{className:"nice-html-editor-ai__panel-footer",children:[e.jsxs("button",{type:"button",className:"nice-html-editor-ai__apply",onClick:se,disabled:!z||B,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:()=>{w(!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),_(""),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:()=>ke(l),disabled:B||!l.trim(),children:B?T("htmlEditorAI.generating","Generating..."):T("htmlEditorAI.generate","Generate")})]}),E&&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}}),e.jsx("h5",{children:T("htmlEditorAI.htmlCode","HTML Code")}),e.jsx("pre",{className:"nice-html-editor-ai__code",children:E})]})]}),e.jsxs("div",{className:"nice-html-editor-ai__panel-footer",children:[e.jsxs("button",{type:"button",className:"nice-html-editor-ai__apply",onClick:ge,disabled:!E||B,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),_(""),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 j=o.split("|").filter(R=>R.trim()).map(R=>`<th>${R.trim()}</th>`).join(""),v=h.trim().split(`
|
|
2
|
+
`).map(R=>`<tr>${R.split("|").filter(J=>J.trim()).map(J=>`<td>${J.trim()}</td>`).join("")}</tr>`).join("");return`<table><thead><tr>${j}</tr></thead><tbody>${v}</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:j="md",editorSize:v="standard",toolbar:R=!0,minHeight:C=200,showWordCount:J=!1,showLineNumbers:Y=!1,onExportHtml:$,onImageUpload:N,tutorial:Q,className:te,style:ee,id:ne},A)=>{const y=x.bc(ne),[D,f]=n.useState("edit"),[w,q]=n.useState(!1),p=n.useRef(null),m=n.useMemo(()=>fi(t),[t]),S=n.useMemo(()=>{const d=t.trim()?t.trim().split(/\s+/).length:0,c=t.length,l=t.split(`
|
|
7
|
+
`).length;return{words:d,chars:c,lines:l}},[t]),X=n.useCallback(d=>{const c=p.current;if(!c)return;const l=c.selectionStart,g=c.selectionEnd,E=t.slice(l,g);let _,T;d==="[](url)"?(_=t.slice(0,l)+`[${E||"text"}](url)`+t.slice(g),T=l+1+(E||"text").length+2):d===""?(_=t.slice(0,l)+``+t.slice(g),T=l+2+(E||"alt").length+2):d.endsWith(`
|
|
8
|
+
`)||d.endsWith(" ")?(_=t.slice(0,l)+d+E+t.slice(g),T=l+d.length+E.length):(_=t.slice(0,l)+d+E+d+t.slice(g),T=l+d.length+E.length+d.length),i?.(_),requestAnimationFrame(()=>{c.focus(),c.setSelectionRange(T,T)})},[t,i]),P=n.useCallback(d=>{if((d.ctrlKey||d.metaKey)&&(d.key==="b"?(d.preventDefault(),X("**")):d.key==="i"?(d.preventDefault(),X("*")):d.key==="k"&&(d.preventDefault(),X("[](url)"))),d.key==="Tab"){d.preventDefault();const c=d.currentTarget,l=c.selectionStart,g=c.selectionEnd,E=" ";if(d.shiftKey){const L=t.slice(0,l).lastIndexOf(`
|
|
9
|
+
`)+1;if(t.slice(L,L+E.length)===E){const I=t.slice(0,L)+t.slice(L+E.length);i?.(I),requestAnimationFrame(()=>{c.selectionStart=c.selectionEnd=l-E.length})}}else{const _=t.slice(0,l)+E+t.slice(g);i?.(_),requestAnimationFrame(()=>{c.selectionStart=c.selectionEnd=l+E.length})}}},[t,i,X]),b=n.useCallback(async d=>{if(!N)return;const c=Array.from(d.dataTransfer.files).filter(l=>l.type.startsWith("image/"));if(c.length!==0){d.preventDefault();for(const l of c){const g=await N(l),E=p.current;if(!E)continue;const _=E.selectionStart,T=`
|
|
10
|
+
`,L=t.slice(0,_)+T+t.slice(_);i?.(L)}}},[t,i,N]),s=a!=="tab"||D==="edit",z=a==="side"||a==="tab"&&D==="preview"||a===!0,M=`nice-md-editor nice-md-editor--${j} nice-editor--${v} nice-md-editor--preview-${a}${w?" nice-md-editor--fullscreen":""} ${te||""}`;return e.jsxs("div",{ref:A,id:y,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)})}),R&&e.jsxs("div",{className:"nice-md-editor__toolbar",children:[xi.map((d,c)=>e.jsxs(n.Fragment,{children:[c>0&&e.jsx("span",{className:"nice-md-editor__sep"}),yi.filter(l=>l.group===d).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:()=>X(l.md),"aria-label":l.tip,children:l.icon?e.jsx(x.oa,{name:l.icon,size:16}):l.label},l.key))]},d)),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(!w),children:e.jsx(x.oa,{name:w?"collapse":"expand",size:16})}),$&&e.jsx("button",{type:"button",className:"nice-md-editor__btn",title:"Export HTML","aria-label":"Export HTML",onClick:()=>$(m),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${D==="edit"?" nice-md-editor__tab--active":""}`,onClick:()=>f("edit"),children:"Edit"}),e.jsx("button",{type:"button",className:`nice-md-editor__tab${D==="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:[Y&&e.jsx("div",{className:"nice-md-editor__line-numbers",children:Array.from({length:S.lines},(d,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:d=>i?.(d.target.value),onKeyDown:P,onDrop:b,placeholder:o,disabled:r,readOnly:h,style:{minHeight:C}})]}),z&&e.jsx("div",{className:"nice-md-editor__preview",dangerouslySetInnerHTML:{__html:x.lc(m)},style:{minHeight:C}})]}),J&&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 St(){return`blk-${++bi}-${Date.now().toString(36)}`}function Bt(t=""){return{id:St(),type:"paragraph",content:t}}function _i(t,i=""){const a={id:St(),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 vi=[{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 j=h;return t.bold&&(j=`<strong>${j}</strong>`),t.italic&&(j=`<em>${j}</em>`),t.underline&&(j=`<u>${j}</u>`),t.strikethrough&&(j=`<s>${j}</s>`),`<${r}${a}>${j}</${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((j,v)=>t.listType==="checklist"?`<li><input type="checkbox" ${t.checked?.[v]??!1?"checked":""} disabled />${j}</li>`:`<li>${j}</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:j,onExport:v,onImageUpload:R,maxUndo:C=50,slashCommands:J=!0,showWordCount:Y=!1,showToc:$=!1,showFindReplace:N=!0,tutorial:Q,className:te,style:ee,id:ne,...A},y)=>{const D=x.bc(ne),{t:f}=x.Gt(),[w,q]=n.useState(()=>t??[Bt()]),p=t??w,[m,S]=n.useState(0),X=n.useRef(new Map),P=n.useRef(null),[b,s]=n.useState(!1),[z,M]=n.useState(""),[d,c]=n.useState(""),[l,g]=n.useState([]),[E,_]=n.useState(0),[T,L]=n.useState(!1),I=n.useRef([]),k=n.useRef([]),G=n.useCallback(u=>{I.current.push(u.map(V=>({...V,checked:V.checked?[...V.checked]:void 0}))),I.current.length>C&&I.current.shift(),k.current=[]},[C]),B=n.useCallback(()=>{if(I.current.length===0)return;const u=I.current.pop();k.current.push(p.map(V=>({...V}))),t||q(u),i?.(u)},[p,t,i]),me=n.useCallback(()=>{if(k.current.length===0)return;const u=k.current.pop();I.current.push(p.map(V=>({...V}))),t||q(u),i?.(u)},[p,t,i]),[le,ue]=n.useState(!1),[je,be]=n.useState(""),[ke,he]=n.useState(0),se=n.useMemo(()=>{if(!le||!J)return[];const u=je.toLowerCase();return vi.filter(V=>V.label.toLowerCase().includes(u)||V.keywords.includes(u))},[le,je,J]),[ge,ie]=n.useState(null),[re,pe]=n.useState(null),H=n.useCallback(u=>{G(p);const V=u(p);t||q(V),i?.(V)},[p,t,i,G]),O=n.useCallback((u,V)=>{H(ae=>ae.map(($e,Ee)=>Ee===u?{...$e,...V}:$e))},[H]),K=n.useCallback((u,V)=>{const ae=V??Bt();H($e=>{const Ee=[...$e];return Ee.splice(u+1,0,ae),Ee}),S(u+1)},[H]),ye=n.useCallback(u=>{const V={...p[u],id:St()};K(u,V)},[p,K]),ce=n.useCallback(u=>{p.length<=1||(H(V=>V.filter((ae,$e)=>$e!==u)),S(Math.max(0,u-1)))},[p.length,H]),F=n.useCallback((u,V)=>{const ae=u+V;ae<0||ae>=p.length||(H($e=>{const Ee=[...$e];return[Ee[u],Ee[ae]]=[Ee[ae],Ee[u]],Ee}),S(ae))},[p.length,H]),Z=n.useCallback((u,V)=>{const ae={type:V};V==="heading"&&(ae.level=2),V==="list"&&(ae.listType="unordered"),V==="callout"&&(ae.icon="??"),V==="toggle"&&(ae.open=!0),O(u,ae)},[O]),U=n.useCallback(u=>{const V=_i(u.type);u.type==="list"&&u.label.includes("Numbered")&&(V.listType="ordered"),u.type==="list"&&u.label.includes("Checklist")&&(V.listType="checklist",V.checked=[]),p[m]?.content===""||p[m]?.content==="/"?H(ae=>ae.map(($e,Ee)=>Ee===m?{...V,id:$e.id}:$e)):K(m,V),ue(!1),be("")},[p,m,H,K]),oe=n.useCallback((u,V)=>{if(a)return;const ae=p[V];if(!ae?.locked){if((u.ctrlKey||u.metaKey)&&u.key==="z"&&!u.shiftKey){u.preventDefault(),B();return}if((u.ctrlKey||u.metaKey)&&(u.key==="y"||u.key==="z"&&u.shiftKey)){u.preventDefault(),me();return}if((u.ctrlKey||u.metaKey)&&u.key==="d"){u.preventDefault(),ye(V);return}if((u.ctrlKey||u.metaKey)&&u.key==="b"){u.preventDefault(),O(V,{bold:!ae?.bold});return}if((u.ctrlKey||u.metaKey)&&u.key==="i"){u.preventDefault(),O(V,{italic:!ae?.italic});return}if((u.ctrlKey||u.metaKey)&&u.key==="u"){u.preventDefault(),O(V,{underline:!ae?.underline});return}if((u.ctrlKey||u.metaKey)&&u.key==="e"){u.preventDefault(),O(V,{strikethrough:!ae?.strikethrough});return}if(u.key==="Tab"&&!u.shiftKey){u.preventDefault(),O(V,{indent:Math.min((ae?.indent??0)+1,4)});return}if(u.key==="Tab"&&u.shiftKey){u.preventDefault(),O(V,{indent:Math.max((ae?.indent??0)-1,0)});return}if((u.ctrlKey||u.metaKey)&&u.key==="f"&&N){u.preventDefault(),s($e=>!$e);return}if(le&&se.length>0){if(u.key==="ArrowDown"){u.preventDefault(),he($e=>Math.min($e+1,se.length-1));return}if(u.key==="ArrowUp"){u.preventDefault(),he($e=>Math.max($e-1,0));return}if(u.key==="Enter"){u.preventDefault(),U(se[ke]);return}if(u.key==="Escape"){ue(!1);return}}u.key==="Enter"&&!u.shiftKey?(u.preventDefault(),K(V)):u.key==="Backspace"&&p[V].content===""&&p.length>1?(u.preventDefault(),ce(V)):u.key==="ArrowUp"&&u.altKey?(u.preventDefault(),F(V,-1)):u.key==="ArrowDown"&&u.altKey&&(u.preventDefault(),F(V,1))}},[a,p,K,ce,F,B,me,ye,O,le,se,ke,U,N]),de=n.useCallback((u,V)=>{const ae=u.target.textContent??"";J&&ae.startsWith("/")?(ue(!0),be(ae.slice(1)),he(0)):le&&ue(!1),G(p);const $e=p.map((Ee,Xe)=>Xe===V?{...Ee,content:ae}:Ee);t||q($e),i?.($e)},[p,t,i,G,J,le]),xe=n.useCallback((u,V)=>{ie(V),u.dataTransfer.effectAllowed="move"},[]),we=n.useCallback((u,V)=>{u.preventDefault(),u.dataTransfer.dropEffect="move",pe(V)},[]),Re=n.useCallback((u,V)=>{if(u.preventDefault(),ge===null||ge===V){ie(null),pe(null);return}H(ae=>{const $e=[...ae],[Ee]=$e.splice(ge,1);return $e.splice(V>ge?V-1:V,0,Ee),$e}),S(V>ge?V-1:V),ie(null),pe(null)},[ge,H]);n.useEffect(()=>{if(!b||!z){g([]);return}const u=z.toLowerCase(),V=[];p.forEach((ae,$e)=>{const Ee=(ae.content??"").toLowerCase();let Xe=0;for(;Xe<Ee.length;){const Ve=Ee.indexOf(u,Xe);if(Ve===-1)break;V.push({blockIdx:$e,start:Ve,end:Ve+u.length}),Xe=Ve+1}}),g(V),_(0)},[z,b,p]);const Te=n.useCallback(()=>{if(l.length===0)return;const u=(E+1)%l.length;_(u),S(l[u].blockIdx)},[l,E]),Oe=n.useCallback(()=>{if(l.length===0)return;const u=(E-1+l.length)%l.length;_(u),S(l[u].blockIdx)},[l,E]),Ne=n.useCallback(()=>{if(l.length===0||!z)return;const u=l[E],V=p[u.blockIdx],ae=V.content.slice(0,u.start),$e=V.content.slice(u.end);O(u.blockIdx,{content:ae+d+$e})},[l,E,z,d,p,O]),Ae=n.useCallback(()=>{if(!z)return;const u=z;H(V=>V.map(ae=>({...ae,content:ae.content.split(u).join(d)})))},[z,d,H]),Fe=n.useMemo(()=>$?p.map((u,V)=>u.type==="heading"?{idx:V,level:u.level??2,text:u.content}:null).filter(Boolean):[],[p,$]),Le=n.useCallback(async u=>{const V=u.target.files?.[0];if(V){if(R){const ae=await R(V);O(m,{src:ae})}u.target.value=""}},[R,m,O]);n.useEffect(()=>{const u=p[m];if(u){const V=X.current.get(u.id);V&&V.focus()}},[m,p]);const Ce=n.useCallback(()=>{const u=p.map(ki).join(`
|
|
14
|
+
`);v?.(u)},[p,v]),Ge=n.useMemo(()=>Y?wi(p):null,[p,Y]),[ve,Pe]=n.useState(null),Be=n.useCallback((u,V)=>{a||(u.preventDefault(),Pe({x:u.clientX,y:u.clientY,idx:V}))},[a]);return n.useEffect(()=>{if(!ve)return;const u=()=>Pe(null);return window.addEventListener("click",u),()=>window.removeEventListener("click",u)},[ve]),e.jsxs("div",{ref:y,id:D,className:`nice-doc-editor nice-doc-editor--${r} nice-editor--${h} ${a?"nice-doc-editor--readonly":""} ${te??""}`,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:B,title:f("docEditor.undo","Undo (Ctrl+Z)"),children:"?"}),e.jsx(Se.NiceButton,{size:"sm",variant:"ghost",onClick:me,title:f("docEditor.redo","Redo (Ctrl+Y)"),children:"?"}),e.jsx("span",{className:"nice-doc-editor__sep"}),e.jsx(Ye.NiceSelect,{size:"sm",value:p[m]?.type??"paragraph",onChange:u=>Z(m,u),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[m]?.type==="heading"&&e.jsx(Ye.NiceSelect,{size:"sm",value:String(p[m]?.level??2),onChange:u=>O(m,{level:Number(u)}),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[m]?.type==="list"&&e.jsx(Ye.NiceSelect,{size:"sm",value:p[m]?.listType??"unordered",onChange:u=>O(m,{listType:u}),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[m]?.bold?"primary":"ghost",onClick:()=>O(m,{bold:!p[m]?.bold}),title:f("docEditor.bold","Bold (Ctrl+B)"),children:e.jsx("strong",{children:"B"})}),e.jsx(Se.NiceButton,{size:"sm",variant:p[m]?.italic?"primary":"ghost",onClick:()=>O(m,{italic:!p[m]?.italic}),title:f("docEditor.italic","Italic (Ctrl+I)"),children:e.jsx("em",{children:"I"})}),e.jsx(Se.NiceButton,{size:"sm",variant:p[m]?.underline?"primary":"ghost",onClick:()=>O(m,{underline:!p[m]?.underline}),title:f("docEditor.underline","Underline (Ctrl+U)"),children:e.jsx("u",{children:"U"})}),e.jsx(Se.NiceButton,{size:"sm",variant:p[m]?.strikethrough?"primary":"ghost",onClick:()=>O(m,{strikethrough:!p[m]?.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[m]?.align==="left"?"primary":"ghost",onClick:()=>O(m,{align:"left"}),title:f("docEditor.alignLeft","Left"),children:"?"}),e.jsx(Se.NiceButton,{size:"sm",variant:p[m]?.align==="center"?"primary":"ghost",onClick:()=>O(m,{align:"center"}),title:f("docEditor.alignCenter","Center"),children:"?"}),e.jsx(Se.NiceButton,{size:"sm",variant:p[m]?.align==="right"?"primary":"ghost",onClick:()=>O(m,{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(m,{indent:Math.min((p[m]?.indent??0)+1,4)}),title:f("docEditor.indent","Indent (Tab)"),children:"??"}),e.jsx(Se.NiceButton,{size:"sm",variant:"ghost",onClick:()=>O(m,{indent:Math.max((p[m]?.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[m]?.color??"var(--text-primary, #000000)",onChange:u=>O(m,{color:u}),title:"Text color"}),e.jsx(Se.NiceColorPicker,{size:"sm",label:"",value:p[m]?.bgColor??"var(--bg-primary, #ffffff)",onChange:u=>O(m,{bgColor:u}),title:"Block background"}),e.jsx("span",{className:"nice-doc-editor__sep"}),e.jsx(Se.NiceButton,{size:"sm",variant:p[m]?.locked?"primary":"ghost",onClick:()=>O(m,{locked:!p[m]?.locked}),title:f("docEditor.lock","Lock/Unlock block"),children:"??"}),e.jsx(Se.NiceButton,{size:"sm",variant:"ghost",onClick:()=>ye(m),title:f("docEditor.duplicate","Duplicate (Ctrl+D)"),children:"?"}),e.jsx(Se.NiceButton,{size:"sm",variant:"ghost",onClick:()=>ce(m),title:f("docEditor.delete","Delete block"),children:"??"}),e.jsx(Se.NiceButton,{size:"sm",variant:"ghost",onClick:()=>K(m),title:f("docEditor.addBlock","Add block"),children:"+"}),N&&e.jsx(Se.NiceButton,{size:"sm",variant:b?"primary":"ghost",onClick:()=>s(u=>!u),title:f("docEditor.find","Find & Replace (Ctrl+F)"),children:"??"}),e.jsx(Se.NiceButton,{size:"sm",variant:"ghost",onClick:()=>L(u=>!u),title:f("docEditor.shortcuts","Keyboard shortcuts"),children:"?"}),v&&e.jsx(Se.NiceButton,{size:"sm",variant:"ghost",onClick:Ce,children:f("docEditor.export","Export HTML")})]}),e.jsx("input",{ref:P,type:"file",accept:"image/*,video/*",style:{display:"none"},onChange:Le}),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(--border-color, #ddd)"},children:[e.jsx(Ue.NiceTextInput,{size:"sm",placeholder:f("docEditor.findPlaceholder","Find..."),value:z,onChange:M,style:{flex:1,maxWidth:200}}),e.jsx(Ue.NiceTextInput,{size:"sm",placeholder:f("docEditor.replacePlaceholder","Replace..."),value:d,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:Ne,title:f("docEditor.replaceOne","Replace"),disabled:a,children:f("docEditor.replace","Replace")}),e.jsx(Se.NiceButton,{size:"sm",variant:"ghost",onClick:Ae,title:f("docEditor.replaceAll","Replace all"),disabled:a,children:f("docEditor.replaceAllBtn","All")}),e.jsx("span",{style:{fontSize:"0.75em",color:"var(--text-muted, #666)"},children:l.length>0?`${E+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:()=>L(!1),children:e.jsxs("div",{style:{background:"var(--bg-primary, #fff)",borderRadius:8,padding:24,maxWidth:420,width:"90%",boxShadow:"0 8px 32px var(--nice-overlay-20, rgba(0, 0, 0, 0.2))"},onClick:u=>u.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(([u,V])=>e.jsxs("tr",{style:{borderBottom:"1px solid var(--border-color, #eee)"},children:[e.jsx("td",{style:{padding:"4px 8px",fontFamily:"monospace",fontWeight:600},children:u}),e.jsx("td",{style:{padding:"4px 8px"},children:V})]},u))})}),e.jsx("div",{style:{textAlign:"right",marginTop:12},children:e.jsx(Se.NiceButton,{size:"sm",variant:"ghost",onClick:()=>L(!1),children:f("docEditor.close","Close")})})]})}),e.jsxs("div",{style:{display:"flex",gap:0},children:[$&&Fe.length>0&&e.jsxs("nav",{className:"nice-doc-editor__toc",style:{width:200,minWidth:160,borderRight:"1px solid var(--border-color, #eee)",padding:"8px 4px",fontSize:"0.8em",overflowY:"auto",maxHeight:500},children:[e.jsx("div",{style:{fontWeight:600,padding:"4px 8px",fontSize:"0.75em",textTransform:"uppercase",color:"var(--text-muted, #999)"},children:f("docEditor.toc","Contents")}),Fe.map(u=>e.jsx("div",{style:{padding:"3px 8px",paddingLeft:8+(u.level-1)*12,cursor:"pointer",borderRadius:4,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",background:u.idx===m?"var(--nice-primary-bg, #e8f0fe)":void 0},onClick:()=>S(u.idx),title:u.text,children:u.text||f("docEditor.untitled","Untitled")},u.idx))]}),e.jsx("div",{className:"nice-doc-editor__body",style:{flex:1},children:p.map((u,V)=>e.jsxs("div",{className:`nice-doc-editor__block nice-doc-editor__block--${u.type} ${V===m?"nice-doc-editor__block--focused":""} ${re===V?"nice-doc-editor__block--drop-target":""} ${u.locked?"nice-doc-editor__block--locked":""}`,onClick:()=>S(V),onContextMenu:ae=>Be(ae,V),draggable:!a&&!u.locked,onDragStart:ae=>xe(ae,V),onDragOver:ae=>we(ae,V),onDrop:ae=>Re(ae,V),onDragEnd:()=>{ie(null),pe(null)},style:{opacity:ge===V?.4:1,marginLeft:(u.indent??0)*24},children:[!a&&!u.locked&&e.jsx("div",{className:"nice-doc-editor__block-handle",title:f("docEditor.drag","Drag to reorder"),children:"?"}),u.locked&&e.jsx("span",{className:"nice-doc-editor__lock-icon",style:{position:"absolute",top:2,right:4,fontSize:"0.7em",opacity:.5},children:"??"}),u.type==="divider"?e.jsx("hr",{className:"nice-doc-editor__divider"}):u.type==="pageBreak"?e.jsxs("div",{className:"nice-doc-editor__page-break",style:{borderTop:"2px dashed var(--nice-border, #ccc)",textAlign:"center",padding:4,fontSize:"0.75em",color:"var(--text-muted, #999)"},children:["� ",f("docEditor.pageBreak","Page Break")," �"]}):u.type==="image"||u.type==="video"?e.jsx("div",{className:"nice-doc-editor__media-block",children:u.src?u.type==="image"?e.jsx("img",{src:u.src,alt:u.alt??"",className:"nice-doc-editor__image",style:{maxWidth:"100%"}}):e.jsx("video",{src:u.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(Ue.NiceTextInput,{size:"sm",placeholder:f("docEditor.mediaUrl",u.type==="image"?"Image URL":"Video URL"),value:u.src??"",onChange:ae=>O(V,{src:ae})}),R&&e.jsx(Se.NiceButton,{size:"sm",variant:"ghost",onClick:()=>{S(V),P.current?.click()},children:"??"})]})}):u.type==="callout"?e.jsxs("div",{className:"nice-doc-editor__callout",style:{display:"flex",gap:8,padding:"8px 12px",background:u.bgColor??"#f0f7ff",borderRadius:4,color:u.color},children:[e.jsx("span",{style:{fontSize:"1.2em"},children:u.icon??"??"}),e.jsx("div",{ref:ae=>{ae&&X.current.set(u.id,ae)},className:"nice-doc-editor__content",contentEditable:!a&&!u.locked,suppressContentEditableWarning:!0,onInput:ae=>de(ae,V),onFocus:()=>S(V),onKeyDown:ae=>oe(ae,V),"data-placeholder":f("docEditor.calloutPlaceholder","Callout text..."),role:"textbox","aria-multiline":"true",style:{flex:1,outline:"none"},children:u.content})]}):u.type==="toggle"?e.jsxs("details",{open:u.open,className:"nice-doc-editor__toggle",onToggle:ae=>O(V,{open:ae.target.open}),children:[e.jsx("summary",{style:{cursor:"pointer",fontWeight:500},children:u.content.split(`
|
|
15
|
+
`)[0]||f("docEditor.toggleTitle","Toggle")}),e.jsx("div",{ref:ae=>{ae&&X.current.set(u.id,ae)},className:"nice-doc-editor__content",contentEditable:!a&&!u.locked,suppressContentEditableWarning:!0,onInput:ae=>de(ae,V),onFocus:()=>S(V),onKeyDown:ae=>oe(ae,V),role:"textbox","aria-multiline":"true",style:{padding:"4px 0"},children:u.content.split(`
|
|
16
|
+
`).slice(1).join(`
|
|
17
|
+
`)})]}):u.type==="code"?e.jsxs("div",{className:"nice-doc-editor__code-block",style:{position:"relative"},children:[!a&&e.jsx(Ue.NiceTextInput,{size:"sm",value:u.language??"",onChange:ae=>O(V,{language:ae}),placeholder:"Language",style:{position:"absolute",top:4,right:4,width:80,opacity:.7}}),e.jsx("pre",{ref:ae=>{ae&&X.current.set(u.id,ae)},className:"nice-doc-editor__content",contentEditable:!a&&!u.locked,suppressContentEditableWarning:!0,onInput:ae=>de(ae,V),onFocus:()=>S(V),onKeyDown:ae=>oe(ae,V),role:"textbox","aria-multiline":"true",style:{fontFamily:"monospace",background:"var(--bg-elevated, #1e1e1e)",color:"var(--text-secondary, #d4d4d4)",padding:12,borderRadius:4,overflow:"auto"},children:u.content})]}):e.jsxs("div",{style:{position:"relative"},children:[e.jsx("div",{ref:ae=>{ae&&X.current.set(u.id,ae)},className:"nice-doc-editor__content",contentEditable:!a&&!u.locked,suppressContentEditableWarning:!0,style:{textAlign:u.align,fontWeight:u.bold?"bold":void 0,fontStyle:u.italic?"italic":void 0,textDecoration:[u.underline?"underline":"",u.strikethrough?"line-through":""].filter(Boolean).join(" ")||void 0,color:u.color,backgroundColor:u.bgColor},onInput:ae=>de(ae,V),onFocus:()=>S(V),onKeyDown:ae=>oe(ae,V),"data-placeholder":!u.content&&j?j:void 0,role:"textbox","aria-multiline":"true",children:u.content}),le&&V===m&&se.length>0&&e.jsx("ul",{className:"nice-doc-editor__slash-menu",style:{position:"absolute",left:0,top:"100%",zIndex:100,background:"var(--bg-primary, #fff)",border:"1px solid var(--border-color, #ddd)",borderRadius:6,boxShadow:"0 4px 16px var(--nice-overlay-12, rgba(0, 0, 0, 0.12))",listStyle:"none",margin:0,padding:4,minWidth:180,maxHeight:240,overflow:"auto"},children:se.map((ae,$e)=>e.jsxs("li",{className:$e===ke?"nice-doc-editor__slash-item--active":"",style:{padding:"6px 10px",cursor:"pointer",borderRadius:4,display:"flex",gap:8,alignItems:"center",background:$e===ke?"var(--nice-primary-bg, #e8f0fe)":void 0},onMouseDown:Ee=>{Ee.preventDefault(),U(ae)},onMouseEnter:()=>he($e),children:[e.jsx("span",{style:{width:24,textAlign:"center"},children:ae.icon}),e.jsx("span",{children:ae.label})]},`${ae.type}-${ae.label}`))})]})]},u.id))})]}),ve&&e.jsxs("div",{className:"nice-doc-editor__ctx-menu",style:{position:"fixed",left:ve.x,top:ve.y,zIndex:1e3,background:"var(--bg-primary, #fff)",border:"1px solid var(--border-color, #ddd)",borderRadius:6,boxShadow:"0 4px 16px 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:()=>{ye(ve.idx),Pe(null)},children:"? Duplicate"}),e.jsx("div",{style:{padding:"6px 12px",cursor:"pointer"},onClick:()=>{K(ve.idx),Pe(null)},children:"+ Insert below"}),e.jsx("div",{style:{padding:"6px 12px",cursor:"pointer"},onClick:()=>{F(ve.idx,-1),Pe(null)},children:"? Move up"}),e.jsx("div",{style:{padding:"6px 12px",cursor:"pointer"},onClick:()=>{F(ve.idx,1),Pe(null)},children:"? Move down"}),e.jsx("div",{style:{padding:"6px 12px",cursor:"pointer"},onClick:()=>{O(ve.idx,{locked:!p[ve.idx]?.locked}),Pe(null)},children:p[ve.idx]?.locked?"?? Unlock":"?? Lock"}),e.jsx("hr",{style:{margin:"2px 0",border:"none",borderTop:"1px solid var(--border-color, #eee)"}}),e.jsx("div",{style:{padding:"6px 12px",cursor:"pointer",color:"var(--nice-danger-dark, #d32f2f)"},onClick:()=>{ce(ve.idx),Pe(null)},children:"?? Delete"})]}),Y&&Ge&&e.jsxs("div",{className:"nice-doc-editor__footer",style:{padding:"4px 12px",fontSize:"0.75em",color:"var(--text-muted, #666)",borderTop:"1px solid var(--border-color, #eee)",display:"flex",gap:16},children:[e.jsxs("span",{children:[Ge.words," ",f("docEditor.words","words")]}),e.jsxs("span",{children:[Ge.chars," ",f("docEditor.chars","characters")]}),e.jsxs("span",{children:[p.length," ",f("docEditor.blocks","blocks")]}),e.jsxs("span",{children:["~",Ge.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:j,className:v,style:R,accessMode:C,pages:J,selectedPageId:Y,content:$="",contentFormat:N="html",editing:Q=!1,onPageSelect:te,onContentChange:ee,onSave:ne,onCreatePage:A,onDeletePage:y,onEditToggle:D,onVersionHistory:f,sidebarWidth:w=260,sidebarCollapsed:q=!1,onSidebarToggle:p,searchable:m=!0,onSearch:S},X)=>{const P=x.Dc(C,j),b=P==="hidden";P==="disabled"&&(o=!0),P==="readOnly"&&(r=!0);const{t:s}=x.Gt(),z=x.bc(j),[M,d]=n.useState(""),[c,l]=n.useState(""),[g,E]=n.useState(!1),_=n.useMemo(()=>{const k=G=>{for(const B of G){if(B.id===Y)return B;if(B.children){const me=k(B.children);if(me)return me}}};return k(J)},[J,Y]),T=n.useCallback(k=>{d(k),S?.(k)},[S]),L=n.useCallback(()=>{c.trim()&&(A?.(Y??null,c.trim()),l(""),E(!1))},[c,Y,A]),I=(k,G=0)=>e.jsx("ul",{className:"nice-wiki__tree",style:{paddingLeft:G>0?16:0},children:k.map(B=>e.jsxs("li",{className:"nice-wiki__tree-item",children:[e.jsxs("div",{className:`nice-wiki__tree-node${B.id===Y?" nice-wiki__tree-node--active":""}${B.isDraft?" nice-wiki__tree-node--draft":""}`,onClick:()=>te?.(B),role:"treeitem","aria-selected":B.id===Y,children:[e.jsx("span",{className:"nice-wiki__tree-icon",children:e.jsx(x.oa,{name:B.children?.length?"folder":"file",size:14})}),e.jsx("span",{className:"nice-wiki__tree-title",children:B.title}),B.isDraft&&e.jsx("span",{className:"nice-wiki__tree-draft",children:s("draft","Draft")})]}),B.children&&B.children.length>0&&I(B.children,G+1)]},B.id))});return b?null:e.jsxs("div",{ref:X,id:z,className:`nice-wiki nice-size-${h}${v?` ${v}`:""}${o?" nice-disabled":""}`,style:R,children:[!q&&e.jsxs("aside",{className:"nice-wiki__sidebar",style:{width:w},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})})]}),m&&e.jsx("input",{type:"text",className:"nice-input nice-wiki__search",value:M,onChange:k=>T(k.target.value),placeholder:s("searchPages","Search pages…"),disabled:o}),e.jsx("div",{className:"nice-wiki__page-tree",role:"tree",children:I(J)}),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:k=>l(k.target.value),placeholder:s("pageTitle","Page title"),onKeyDown:k=>k.key==="Enter"&&L(),disabled:o}),e.jsx("button",{type:"button",disabled:o||!c.trim(),onClick:L,"aria-label":s("create","Create"),children:e.jsx(x.oa,{name:"check",size:14})}),e.jsx("button",{type:"button",onClick:()=>E(!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:()=>E(!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:_?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"nice-wiki__content-header",children:[e.jsx("h1",{className:"nice-wiki__page-title",children:_.title}),e.jsxs("div",{className:"nice-wiki__content-actions",children:[D&&!r&&e.jsx("button",{type:"button",disabled:o,onClick:()=>D(!Q),children:Q?s("preview","Preview"):s("edit","Edit")}),f&&e.jsx("button",{type:"button",disabled:o,onClick:()=>f(_.id),children:s("history","History")}),y&&!r&&e.jsx("button",{type:"button",className:"nice-btn--danger",disabled:o,onClick:()=>y(_.id),children:s("delete","Delete")})]})]}),_.updatedAt&&e.jsxs("div",{className:"nice-wiki__page-meta",children:[_.updatedBy&&e.jsxs("span",{children:[s("lastEditedBy","Last edited by")," ",_.updatedBy]}),e.jsx("span",{children:new Date(_.updatedAt).toLocaleDateString()})]}),Q?e.jsxs("div",{className:"nice-wiki__editor",children:[e.jsx("textarea",{className:"nice-wiki__editor-textarea",value:$,onChange:k=>ee?.(k.target.value),disabled:o}),ne&&e.jsx("button",{type:"button",className:"nice-btn nice-btn--primary",disabled:o,onClick:()=>ne(_.id,$),children:s("save","Save")})]}):e.jsx("div",{className:"nice-wiki__viewer",children:N==="html"?e.jsx("div",{className:"nice-wiki__html",dangerouslySetInnerHTML:{__html:x.lc($)}}):e.jsx("pre",{className:"nice-wiki__markdown",children:$})})]}):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:j=500,enableExplain:v=!0,enableRefactor:R=!0,enableGenerate:C=!0,systemPrompt:J,onExplain:Y,onRefactor:$,showAIToolbar:N=!0,aiShortcutKey:Q="Ctrl",language:te="plaintext",value:ee,onChange:ne,...A}=i,y=n.useRef(null),[D,f]=n.useState(null),[w,q]=n.useState(!1),[p,m]=n.useState(""),[S,X]=n.useState(!1),[P,b]=n.useState(""),[s,z]=n.useState(""),[M,d]=n.useState(""),c=n.useRef(void 0),{t:l}=x.Gt(),g=x.he(),{complete:E,explain:_,refactor:T,generateFromComment:L,isLoading:I}=x.wd({language:te,model:r}),k=o&&g.isConfigured,G=n.useCallback(async()=>{if(!k||!h||!y.current||!y.current.getEditor())return;const se=y.current.getCursorPosition(),ie=y.current.getValue().split(`
|
|
18
|
+
`),re=ie.slice(0,se.lineNumber-1),pe=ie[se.lineNumber-1]||"",H=[...re,pe.slice(0,se.column-1)].join(`
|
|
19
|
+
`),O=[pe.slice(se.column-1),...ie.slice(se.lineNumber)].join(`
|
|
20
|
+
`);try{const K=await E(H,O);K&&f({lineNumber:se.lineNumber,column:se.column,text:K})}catch{}},[k,h,E]),B=n.useCallback(async()=>{if(!k||!v||!y.current)return"";const he=y.current.getSelection();if(!he)return"";d(he),q(!0),m("");try{const se=await _(he);return m(se),Y?.(he,se),se}catch{return m(l("codeEditorAI.explanationFailed","Failed to explain code")),""}},[k,v,_,Y,l]),me=n.useCallback(async he=>{if(!k||!R||!y.current)return"";const se=y.current.getSelection();if(!se)return"";try{const ge=await T(se,he);return z(ge),$?.(se,ge),ge}catch{return""}},[k,R,T,$]),le=n.useCallback(async()=>{if(!k||!C||!y.current)return;const he=y.current.getCursorPosition(),ge=y.current.getValue().split(`
|
|
21
|
+
`);let ie="";for(let re=he.lineNumber-1;re>=0&&re>=he.lineNumber-3;re--){const pe=ge[re]?.trim()||"";if(pe.startsWith("//")||pe.startsWith("#")||pe.startsWith("/*")||pe.startsWith("*")){ie=pe.replace(/^\/\/\s*|^#\s*|^\/\*\s*|\*\/\s*$|^\*\s*/g,"").trim();break}}if(ie)try{const re=await L(ie);re&&y.current&&y.current.insertText(`
|
|
22
|
+
`+re)}catch{}},[k,C,L]),ue=n.useCallback(()=>{!D||!y.current||(y.current.insertText(D.text),f(null))},[D]),je=n.useCallback(()=>{f(null)},[]),be=n.useCallback(he=>{i.onCursorPositionChange?.(he),!(!k||!h)&&(c.current&&clearTimeout(c.current),f(null),c.current=setTimeout(()=>{G()},j))},[i.onCursorPositionChange,k,h,j,G]);n.useEffect(()=>{if(!y.current?.getEditor()||!k)return;const se=ge=>{if(Q==="Ctrl"&&ge.ctrlKey||Q==="Alt"&&ge.altKey||Q==="Meta"&&ge.metaKey){if(ge.key===" "&&h&&(ge.preventDefault(),G()),ge.key==="e"&&v&&(ge.preventDefault(),B()),ge.key==="r"&&R){ge.preventDefault();const re=y.current?.getSelection();re&&(d(re),X(!0))}ge.key==="g"&&C&&(ge.preventDefault(),le())}ge.key==="Tab"&&D&&(ge.preventDefault(),ue()),ge.key==="Escape"&&D&&je()};return window.addEventListener("keydown",se),()=>window.removeEventListener("keydown",se)},[k,Q,h,v,R,C,G,B,le,D,ue,je]),n.useEffect(()=>()=>{c.current&&clearTimeout(c.current)},[]);const ke=n.useCallback(()=>{if(!s||!y.current)return;const he=y.current.getEditor();if(he?.executeEdits&&he?.getSelection){const se=he.getSelection();he.executeEdits("ai-refactor",[{range:se,text:s}])}X(!1),z(""),b("")},[s]);return n.useImperativeHandle(a,()=>({...y.current,getEditor:()=>y.current?.getEditor(),getMonaco:()=>y.current?.getMonaco(),focus:()=>y.current?.focus(),getValue:()=>y.current?.getValue()||"",setValue:he=>y.current?.setValue(he),getSelection:()=>y.current?.getSelection()||"",insertText:he=>y.current?.insertText(he),formatDocument:()=>y.current?.formatDocument(),goToLine:(he,se)=>y.current?.goToLine(he,se),findReplace:()=>y.current?.findReplace(),undo:()=>y.current?.undo(),redo:()=>y.current?.redo(),getCursorPosition:()=>y.current?.getCursorPosition()||{lineNumber:1,column:1},setMarkers:he=>y.current?.setMarkers(he),triggerCompletion:G,explainSelection:B,refactorSelection:me,generateFromComment:le,acceptCompletion:ue,dismissCompletion:je})),e.jsxs("div",{className:"nice-code-editor-ai","data-testid":i["data-testid"],children:[N&&k&&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"}),I&&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:()=>G(),disabled:I,title:`${l("codeEditorAI.complete","Complete")} (${Q}+Space)`,children:[e.jsx(x.oa,{name:"lightbulb",size:14})," ",l("codeEditorAI.complete","Complete")]}),v&&e.jsxs("button",{type:"button",className:"nice-code-editor-ai__toolbar-btn",onClick:()=>B(),disabled:I,title:`${l("codeEditorAI.explain","Explain")} (${Q}+E)`,children:[e.jsx(x.oa,{name:"book",size:14})," ",l("codeEditorAI.explain","Explain")]}),R&&e.jsxs("button",{type:"button",className:"nice-code-editor-ai__toolbar-btn",onClick:()=>{const he=y.current?.getSelection();he&&(d(he),X(!0))},disabled:I,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:()=>le(),disabled:I,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(vt.NiceCodeEditor,{ref:y,value:ee,onChange:ne,language:te,onCursorPositionChange:be,...A}),D&&e.jsxs("div",{className:"nice-code-editor-ai__ghost-text",style:{top:`calc(${(D.lineNumber-1)*19}px + 4px)`,left:`calc(${(D.column-1)*7.8}px + 60px)`},children:[e.jsx("span",{className:"nice-code-editor-ai__ghost-text-content",children:D.text}),e.jsxs("span",{className:"nice-code-editor-ai__ghost-text-hint",children:["Tab ",l("codeEditorAI.toAccept","to accept")]})]})]}),w&&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:I?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:()=>{X(!1),z(""),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:P,onChange:he=>b(he.target.value),onKeyDown:he=>{he.key==="Enter"&&P&&me(P)}}),e.jsx("button",{type:"button",className:"nice-code-editor-ai__refactor-btn",onClick:()=>me(P),disabled:I||!P,children:I?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:ke,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:()=>{z(""),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 $i(t){if(typeof t=="string")return t;try{return JSON.stringify(t,null,2)}catch{return String(t)}}const _n=n.forwardRef(function(i,a){const{entries:o,maxHeight:r=240,autoScroll:h=!0,showTimestamps:j=!0,levelFilter:v,onClear:R,title:C,emptyText:J="No output",clearLabel:Y="Clear",fontFamily:$,className:N,style:Q,id:te,"data-testid":ee}=i,ne=n.useRef(null),A=n.useMemo(()=>{if(!v||v.length===0)return o;const f=new Set(v);return o.filter(w=>f.has(w.level??"log"))},[o,v]);n.useEffect(()=>{h&&ne.current&&(ne.current.scrollTop=ne.current.scrollHeight)},[A.length,h]);const y=!!C||!!R,D="nice-log-console"+(N?` ${N}`:"");return e.jsxs("div",{ref:a,id:te,className:D,style:{...$?{fontFamily:$}:null,...Q},"data-testid":ee,children:[y&&e.jsxs("div",{className:"nice-log-console__header",children:[e.jsx("span",{className:"nice-log-console__title",children:C}),R&&e.jsx("button",{type:"button",className:"nice-log-console__clear",onClick:R,"aria-label":Y,children:Y})]}),e.jsx("div",{ref:ne,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:J}):A.map((f,w)=>{const q=f.level??"log";return e.jsxs("div",{className:`nice-log-console__entry nice-log-console__entry--${q}`,children:[j&&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:$i(f.data)})]},w)})})]})}),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 Si=[{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:j,input:v,onInputChange:R,showInputPanel:C,extraLibs:J,height:Y=260,running:$,autoRun:N=!1,autoRunDelay:Q=600,layout:te="vertical",runLabel:ee="Run",theme:ne="auto",tutorial:A,className:y,style:D,id:f,"data-testid":w}=i,q=C??v!==void 0,[p,m]=n.useState(()=>Ot(v)),[S,X]=n.useState(null),[P,b]=n.useState(!1),[s,z]=n.useState(null),M=$??P,d=ne==="light"?"vs":ne==="dark"?"vs-dark":ne;n.useEffect(()=>{m(Ot(v))},[v]);const c=n.useCallback(async()=>{const T=Ft(p),L=typeof performance<"u"?performance.now():Date.now();$===void 0&&b(!0);try{const I=await j(o,T.value),k=I.durationMs??Math.round((typeof performance<"u"?performance.now():Date.now())-L);z({...I,durationMs:k})}catch(I){z({ok:!1,error:I instanceof Error?I.message:String(I),durationMs:Math.round((typeof performance<"u"?performance.now():Date.now())-L)})}finally{$===void 0&&b(!1)}},[p,j,o,$]),l=n.useRef(c);l.current=c,n.useEffect(()=>{if(!N)return;const T=setTimeout(()=>{l.current()},Q);return()=>clearTimeout(T)},[N,Q,o,p]);const g=n.useCallback(T=>{m(T);const L=Ft(T);X(L.error),R?.(L.value)},[R]),E=typeof Y=="number"?`${Y}px`:Y,_=`nice-script-runner nice-script-runner--${te}`+(y?` ${y}`:"");return e.jsxs("div",{ref:a,id:f,className:_,style:D,"data-testid":w,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,Si)})})]}),e.jsxs("div",{className:"nice-script-runner__panes",children:[e.jsxs("div",{className:"nice-script-runner__editors",children:[e.jsx(vt.NiceCodeEditor,{value:o,onChange:r,language:h,theme:d,height:E,extraLibs:J,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(vt.NiceCodeEditor,{value:p,onChange:g,language:"json",theme:d,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(_n,{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:j=!1,allowDescription:v=!1,keySuggestions:R,keyPlaceholder:C="Key",valuePlaceholder:J="Value",addLabel:Y="Add",readOnly:$=!1,duplicateKeyWarning:N=!0,tutorial:Q,className:te,style:ee,id:ne,"data-testid":A}=i,y=n.useMemo(()=>`nice-kv-keys-${Math.random().toString(36).slice(2,9)}`,[]),D=n.useMemo(()=>{const m=new Map,S=new Set;if(N){for(const X of o){const P=X.key.trim();P!==""&&m.set(P,(m.get(P)??0)+1)}m.forEach((X,P)=>{X>1&&S.add(P)})}return S},[o,N]),f=(m,S)=>{r(o.map((X,P)=>P===m?{...X,...S}:X))},w=m=>{r(o.filter((S,X)=>X!==m))},q=()=>{r([...o,{key:"",value:"",type:"text",enabled:!0}])},p="nice-key-value-editor"+(te?` ${te}`:"");return e.jsxs("div",{ref:a,id:ne,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)})}),R&&R.length>0&&e.jsx("datalist",{id:y,children:R.map(m=>e.jsx("option",{value:m},m))}),e.jsx("div",{className:"nice-key-value-editor__rows",children:o.map((m,S)=>{const X=m.type==="secret",P=m.key.trim()!==""&&D.has(m.key.trim()),b=j&&m.enabled===!1;return e.jsxs("div",{className:"nice-key-value-editor__row"+(b?" nice-key-value-editor__row--disabled":""),children:[j&&e.jsx("input",{type:"checkbox",className:"nice-key-value-editor__toggle",checked:m.enabled!==!1,onChange:s=>f(S,{enabled:s.target.checked}),disabled:$,"aria-label":"Enabled"}),e.jsx("input",{type:"text",className:"nice-key-value-editor__key"+(P?" nice-key-value-editor__key--dup":""),value:m.key,list:R?y:void 0,placeholder:C,onChange:s=>f(S,{key:s.target.value}),readOnly:$,"aria-label":C,title:P?"Duplicate key":void 0}),e.jsx("input",{type:X?"password":"text",className:"nice-key-value-editor__value",value:m.value,placeholder:J,onChange:s=>f(S,{value:s.target.value}),readOnly:$,autoComplete:X?"new-password":"off","aria-label":J}),h&&e.jsx("button",{type:"button",className:"nice-key-value-editor__secret"+(X?" nice-key-value-editor__secret--on":""),onClick:()=>f(S,{type:X?"text":"secret"}),disabled:$,title:X?"Secret (click to reveal as text)":"Mark as secret","aria-pressed":X,"aria-label":"Toggle secret",children:e.jsx(x.oa,{name:"lock",size:16})}),v&&e.jsx("input",{type:"text",className:"nice-key-value-editor__desc",value:m.description??"",placeholder:"Description",onChange:s=>f(S,{description:s.target.value}),readOnly:$,"aria-label":"Description"}),!$&&e.jsx("button",{type:"button",className:"nice-key-value-editor__remove",onClick:()=>w(S),title:"Remove row","aria-label":"Remove row",children:e.jsx(x.oa,{name:"close",size:14})})]},m.id??S)})}),!$&&e.jsxs("button",{type:"button",className:"nice-key-value-editor__add",onClick:q,children:["+ ",Y]})]})}),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"},vn=n.forwardRef(({label:t,helperText:i,error:a,required:o,disabled:r,readOnly:h,size:j="md",name:v,id:R,className:C,style:J,accessMode:Y,value:$={},onChange:N,fields:Q=Ii,placeholders:te={},countries:ee,layout:ne="vertical",countryFirst:A=!1,validatePostalCode:y},D)=>{const f=x.Dc(Y,R),w=f==="hidden";f==="disabled"&&(r=!0),f==="readOnly"&&(h=!0);const{t:q}=x.Gt(),p=x.bc(R),m=n.useCallback((b,s)=>{N?.({...$,[b]:s})},[$,N]),S=n.useMemo(()=>{if(y&&$.postalCode)return y($.postalCode,$.country)},[y,$.postalCode,$.country]),X=n.useMemo(()=>A&&Q.includes("country")?["country",...Q.filter(b=>b!=="country")]:Q,[Q,A]),P=`nice-address nice-address--${ne} nice-size-${j}`;return w?null:e.jsxs("div",{ref:D,id:p,className:`${P}${C?` ${C}`:""}${a?" nice-error":""}${r?" nice-disabled":""}`,style:J,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:X.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:$.country??"",onChange:s=>m("country",s.target.value),disabled:r,"aria-label":q(b,dt[b]),children:[e.jsx("option",{value:"",children:te.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:v?`${v}.${b}`:b,value:$[b]??"",onChange:s=>m(b,s.target.value),placeholder:te[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})]})});vn.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:j="md",name:v,id:R,className:C,style:J,accessMode:Y,value:$,onChange:N,accounts:Q,treeView:te=!1,placeholder:ee,searchable:ne=!0,showType:A=!0,onSearch:y},D)=>{const f=x.Dc(Y,R),w=f==="hidden";f==="disabled"&&(r=!0),f==="readOnly"&&(h=!0);const{t:q}=x.Gt(),p=x.bc(R),[m,S]=n.useState(""),[X,P]=n.useState(!1),b=n.useMemo(()=>{const c=l=>{for(const g of l){if(g.code===$)return g;if(g.children){const E=c(g.children);if(E)return E}}};return c(Q)},[Q,$]),s=n.useMemo(()=>{const c=[],l=g=>{for(const E of g)c.push(E),E.children&&l(E.children)};return l(Q),c},[Q]),z=n.useMemo(()=>{if(!m)return s;const c=m.toLowerCase();return s.filter(l=>l.code.toLowerCase().includes(c)||l.name.toLowerCase().includes(c))},[s,m]),M=n.useCallback(c=>{S(c),y?.(c),P(!0)},[y]),d=n.useCallback(c=>{N?.(c.code,c),P(!1),S("")},[N]);return w?null:e.jsxs("div",{ref:D,id:p,className:`nice-account-picker nice-size-${j}${C?` ${C}`:""}${a?" nice-error":""}${r?" nice-disabled":""}`,style:J,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:ne&&!h?e.jsx("input",{id:`${p}-input`,className:"nice-input",type:"text",value:X?m:b?`${b.code} — ${b.name}`:"",onChange:c=>M(c.target.value),onFocus:()=>{S(""),P(!0)},onBlur:()=>setTimeout(()=>P(!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…")})}),X&&z.length>0&&e.jsx("div",{className:"nice-account-picker__dropdown",role:"listbox",children:z.map(c=>e.jsxs("div",{className:`nice-account-picker__option${c.code===$?" nice-account-picker__option--selected":""}${c.isActive===!1?" nice-account-picker__option--inactive":""}`,role:"option","aria-selected":c.code===$,onClick:()=>d(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:j="md",name:v,id:R,className:C,style:J,accessMode:Y,value:$=[],onChange:N,contacts:Q=[],onSearch:te,searchDelay:ee=300,multiple:ne=!1,placeholder:A,onContactClick:y,maxSelections:D},f)=>{const w=x.Dc(Y,R),q=w==="hidden";w==="disabled"&&(r=!0),w==="readOnly"&&(h=!0);const{t:p}=x.Gt(),m=x.bc(R),[S,X]=n.useState(""),[P,b]=n.useState([]),[s,z]=n.useState(!1),[M,d]=n.useState(!1),c=n.useMemo(()=>{const _=[...Q,...P],T=new Map(_.map(L=>[L.id,L]));return $.map(L=>T.get(L)).filter(Boolean)},[$,Q,P]),l=n.useCallback(_=>{if(X(_),_.length<1){b([]),z(!1);return}if(te){d(!0);const I=setTimeout(async()=>{const k=await te(_);b(k),z(!0),d(!1)},ee);return()=>clearTimeout(I)}const T=_.toLowerCase(),L=Q.filter(I=>I.name.toLowerCase().includes(T)||I.email?.toLowerCase().includes(T)||I.phone?.includes(_));b(L),z(!0)},[te,Q,ee]),g=n.useCallback(_=>{if(ne)if($.includes(_.id))N?.($.filter(T=>T!==_.id));else{if(D&&$.length>=D)return;N?.([...$,_.id])}else N?.([_.id]),z(!1),X("")},[$,N,ne,D]),E=n.useCallback(_=>{N?.($.filter(T=>T!==_))},[$,N]);return q?null:e.jsxs("div",{ref:f,id:m,className:`nice-contact-picker nice-size-${j}${C?` ${C}`:""}${a?" nice-error":""}${r?" nice-disabled":""}`,style:J,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(_=>e.jsxs("span",{className:"nice-contact-picker__chip",onClick:()=>y?.(_),children:[_.avatarUrl&&e.jsx("img",{src:_.avatarUrl,alt:"",className:"nice-contact-picker__chip-avatar"}),e.jsx("span",{children:_.name}),!h&&e.jsx("button",{type:"button",className:"nice-contact-picker__chip-remove",onClick:T=>{T.stopPropagation(),E(_.id)},disabled:r,"aria-label":p("controls.remove","Remove"),children:e.jsx(x.oa,{name:"close",size:14})})]},_.id))}),!h&&e.jsxs("div",{className:"nice-contact-picker__search",children:[e.jsx("input",{className:"nice-input",type:"text",value:S,onChange:_=>l(_.target.value),onFocus:()=>S.length>0&&z(!0),onBlur:()=>setTimeout(()=>z(!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&&P.length>0&&e.jsx("div",{className:"nice-contact-picker__dropdown",role:"listbox",children:P.map(_=>e.jsxs("div",{className:`nice-contact-picker__option${$.includes(_.id)?" nice-contact-picker__option--selected":""}`,role:"option","aria-selected":$.includes(_.id),onClick:()=>g(_),children:[_.avatarUrl&&e.jsx("img",{src:_.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:_.name}),_.subtitle&&e.jsx("span",{className:"nice-contact-picker__option-subtitle",children:_.subtitle}),_.email&&e.jsx("span",{className:"nice-contact-picker__option-email",children:_.email})]}),_.type&&e.jsx("span",{className:"nice-contact-picker__option-type",children:e.jsx(x.oa,{name:_.type==="person"?"user":"building",size:16})})]},_.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 zi={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"},_t=["","🏻","🏼","🏽","🏾","🏿"],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:j=24,recentEmojis:v,onRecentChange:R,categories:C,customEmojis:J=[],columns:Y=8,size:$="md",className:N="",style:Q,"data-testid":te="nice-emoji-picker"})=>{const{t:ee}=x.Gt(),[ne,A]=n.useState(""),[y,D]=n.useState(h?"recent":"smileys"),[f,w]=n.useState(r),[q,p]=n.useState(!1),m=n.useRef(null),[S,X]=n.useState(()=>{if(typeof window>"u")return[];try{return JSON.parse(localStorage.getItem(Gt)||"[]")}catch{return[]}}),P=v??S,b=C??[...h?["recent"]:[],"smileys","people","animals","food","travel","activities","objects","symbols","flags"],s=n.useMemo(()=>{if(!ne)return ht;const g=ne.toLowerCase();return ht.filter(E=>E.name.toLowerCase().includes(g)||E.emoji.includes(g)||E.keywords?.some(_=>_.toLowerCase().includes(g)))},[ne]),z=n.useMemo(()=>{const g={};for(const E of b)E==="recent"?g[E]=P.map(_=>ht.find(T=>T.emoji===_)).filter(_=>_!==void 0).slice(0,j):g[E]=s.filter(_=>_.category===E);return g},[b,s,P,j]),M=n.useCallback((g,E)=>!E||f===0?g:g.replace(/[\u{1F3FB}-\u{1F3FF}]/gu,"")+_t[f],[f]),d=n.useCallback(g=>{const E=M(g.emoji,g.skinTones),_=[g.emoji,...P.filter(T=>T!==g.emoji)].slice(0,j);if(v===void 0){X(_);try{localStorage.setItem(Gt,JSON.stringify(_))}catch{}}R?.(_),t?.(E,g)},[M,P,j,v,R,t]),c=n.useCallback(g=>{t?.(`:${g.name}:`,g)},[t]);n.useEffect(()=>{if(!q)return;const g=E=>{m.current&&!m.current.contains(E.target)&&p(!1)};return document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},[q]);const l=ne?s:z[y]||[];return e.jsxs("div",{className:`nice-emoji-picker nice-emoji-picker--${$} ${N}`,style:Q,"data-testid":te,children:[i&&e.jsxs("div",{className:"nice-emoji-picker__search",children:[e.jsx("input",{type:"text",value:ne,onChange:g=>A(g.target.value),placeholder:a??ee("search","Search emoji..."),className:"nice-emoji-picker__search-input","data-testid":`${te}-search`}),o&&e.jsxs("div",{className:"nice-emoji-picker__skin-tone-wrapper",children:[e.jsxs("button",{ref:m,type:"button",className:"nice-emoji-picker__skin-tone-btn",onClick:()=>p(!q),title:ee("skinTone","Skin tone"),children:["✋",_t[f]]}),q&&e.jsx("div",{className:"nice-emoji-picker__skin-tone-menu",children:_t.map((g,E)=>e.jsxs("button",{type:"button",className:`nice-emoji-picker__skin-tone-option ${E===f?"nice-emoji-picker__skin-tone-option--selected":""}`,onClick:()=>{w(E),p(!1)},children:["✋",g]},E))})]})]}),!ne&&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 ${y===g?"nice-emoji-picker__category-btn--selected":""}`,onClick:()=>D(g),title:Ut[g],role:"tab","aria-selected":y===g,children:zi[g]},g))}),e.jsxs("div",{className:"nice-emoji-picker__grid-container",children:[ne?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(${Y}, 1fr)`},children:s.length===0?e.jsx("div",{className:"nice-emoji-picker__empty",children:ee("noEmojis","No emojis found")}):s.map((g,E)=>e.jsx("button",{type:"button",className:"nice-emoji-picker__emoji",onClick:()=>d(g),title:g.name,children:M(g.emoji,g.skinTones)},`${g.emoji}-${E}`))})]}):e.jsxs("div",{className:"nice-emoji-picker__section",children:[e.jsx("div",{className:"nice-emoji-picker__section-title",children:Ut[y]}),e.jsx("div",{className:"nice-emoji-picker__grid",style:{gridTemplateColumns:`repeat(${Y}, 1fr)`},children:l.length===0?e.jsx("div",{className:"nice-emoji-picker__empty",children:y==="recent"?ee("noRecent","No recent emojis"):ee("noEmojis","No emojis")}):l.map((g,E)=>e.jsx("button",{type:"button",className:"nice-emoji-picker__emoji",onClick:()=>d(g),title:g.name,children:M(g.emoji,g.skinTones)},`${g.emoji}-${E}`))})]}),J.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(${Y}, 1fr)`},children:J.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:j,error:v,required:R,disabled:C,readOnly:J,size:Y="md",name:$,id:N,className:Q,style:te,autoFocus:ee,labelPlacement:ne,errorPlacement:A,labelWidth:y,controlWidth:D,loading:f,cellWidth:w,...q},p)=>{const m=x.bc(N),S=n.useRef([]),X=i.padEnd(t,"").slice(0,t).split(""),P=n.useCallback(d=>{const c=Math.max(0,Math.min(t-1,d));S.current[c]?.focus()},[t]),b=n.useCallback(d=>{const c=d.join("");a?.(c),c.length===t&&c.indexOf("")===-1&&/^\d+$/.test(c)&&r?.(c)},[a,r,t]),s=n.useCallback((d,c)=>{const g=c.target.value.replace(/\D/g,"").slice(-1);if(!g)return;const E=[...X];E[d]=g,b(E),P(d+1)},[X,b,P]),z=n.useCallback((d,c)=>{if(c.key==="Backspace"){c.preventDefault();const l=[...X];X[d]?(l[d]="",b(l)):d>0&&(l[d-1]="",b(l),P(d-1))}else c.key==="ArrowLeft"?(c.preventDefault(),P(d-1)):c.key==="ArrowRight"&&(c.preventDefault(),P(d+1))},[X,b,P]),M=n.useCallback(d=>{d.preventDefault();const c=d.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]=X[g]||"";b(l),P(Math.min(c.length,t-1))},[t,X,b,P]);return e.jsxs("div",{className:`nice-field nice-field--${Y} nice-field--otp${ne?` nice-field--label-${ne}`:""}${A==="right"?" nice-field--error-right":""} ${f?"nice-field--loading":""} ${Q||""}`,style:{...te,...y!=null&&{"--nice-field-label-width":typeof y=="number"?`${y}px`:y},...D!=null&&{"--nice-field-control-width":typeof D=="number"?`${D}px`:D},...w!=null&&{"--nice-otp-cell-width":typeof w=="number"?`${w}px`:w}},"aria-busy":f||void 0,...q,children:[h&&e.jsx("label",{htmlFor:`${m}-0`,className:`nice-field__label ${R?"nice-field__label--required":""}`,children:h}),e.jsxs("div",{className:"nice-field__control",children:[e.jsxs("div",{ref:p,className:`nice-otp nice-otp--${Y} ${v?"nice-otp--error":""} ${C?"nice-otp--disabled":""}`,onPaste:M,children:[Array.from({length:t},(d,c)=>e.jsx("input",{ref:l=>{S.current[c]=l},id:c===0?`${m}-0`:void 0,className:"nice-otp__digit",type:o?"password":"text",inputMode:"numeric",maxLength:2,value:X[c]||"",disabled:C,readOnly:J,autoFocus:ee&&c===0,"aria-invalid":!!v,"aria-label":`${c+1}`,onChange:l=>s(c,l),onKeyDown:l=>z(c,l),onFocus:l=>l.target.select()},c)),$&&e.jsx("input",{type:"hidden",name:$,value:i})]}),A==="right"&&v&&e.jsx("div",{id:`${m}-error`,className:"nice-field__error",role:"alert",children:v}),A==="right"&&!v&&j&&e.jsx("div",{id:`${m}-helper`,className:"nice-field__helper",children:j}),f&&e.jsx("span",{className:"nice-field__spinner",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})})]}),A!=="right"&&v&&e.jsx("div",{id:`${m}-error`,className:"nice-field__error",role:"alert",children:v}),A!=="right"&&!v&&j&&e.jsx("div",{id:`${m}-helper`,className:"nice-field__helper",children:j})]})});Cn.displayName="NiceInputOtp";const Di=[{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"],$n=n.forwardRef(({src:t,size:i="md",editorSize:a="standard",tools:o=Li,showToolbar:r=!0,showZoom:h=!0,maxUndo:j=30,onSave:v,onCancel:R,onChange:C,width:J="100%",height:Y=500,tutorial:$,className:N,style:Q,id:te,...ee},ne)=>{const A=x.bc(te),{t:y}=x.Gt(),D=n.useRef(null),f=n.useRef(null),[w,q]=n.useState({...Xt}),[p,m]=n.useState(null),[S,X]=n.useState(!1),[P,b]=n.useState(1),[s,z]=n.useState("rect"),[M,d]=n.useState("var(--nice-danger, #ff0000)"),[c,l]=n.useState({w:0,h:0}),[g,E]=n.useState([]),[_,T]=n.useState([]),[L,I]=n.useState(null),[k,G]=n.useState(null),[B,me]=n.useState(null),le=n.useCallback(O=>{E(K=>[...K.slice(-(j-1)),O]),T([])},[j]),ue=n.useCallback(O=>{q(K=>{le(K);const ye={...K,...O};return C?.(ye),ye})},[C,le]),je=n.useCallback(()=>{if(g.length===0)return;const O=g[g.length-1];E(K=>K.slice(0,-1)),T(K=>[...K,w]),q(O),C?.(O)},[g,w,C]),be=n.useCallback(()=>{if(_.length===0)return;const O=_[_.length-1];T(K=>K.slice(0,-1)),E(K=>[...K,w]),q(O),C?.(O)},[_,w,C]);n.useEffect(()=>{const O=new Image;O.crossOrigin="anonymous",O.onload=()=>{f.current=O,l({w:O.width,h:O.height}),X(!0)},O.src=t},[t]),n.useEffect(()=>{if(!S||!D.current||!f.current)return;const O=D.current,K=O.getContext("2d");if(!K)return;const ye=f.current,ce=w.rotation%180!==0,F=ce?ye.height:ye.width,Z=ce?ye.width:ye.height;O.width=F,O.height=Z,K.clearRect(0,0,F,Z),K.save(),K.filter=`brightness(${w.brightness}%) contrast(${w.contrast}%) saturate(${w.saturate}%) blur(${w.blur}px)`,K.translate(F/2,Z/2),K.rotate(w.rotation*Math.PI/180),K.scale(w.flipH?-1:1,w.flipV?-1:1),K.drawImage(ye,-ye.width/2,-ye.height/2),K.restore(),w.annotations.forEach(U=>{switch(K.save(),K.strokeStyle=U.color??"red",K.fillStyle=U.color??"red",K.lineWidth=U.strokeWidth??2,K.font=`${U.fontSize??16}px sans-serif`,U.type){case"text":K.fillText(U.text??"",U.x,U.y);break;case"rect":K.strokeRect(U.x,U.y,U.width??100,U.height??50);break;case"circle":{const oe=(U.width??50)/2,de=(U.height??50)/2;K.beginPath(),K.ellipse(U.x+oe,U.y+de,oe,de,0,0,Math.PI*2),K.stroke();break}case"line":K.beginPath(),K.moveTo(U.x,U.y),K.lineTo(U.x+(U.width??100),U.y+(U.height??0)),K.stroke();break;case"arrow":{const oe=U.x+(U.width??100),de=U.y+(U.height??0);K.beginPath(),K.moveTo(U.x,U.y),K.lineTo(oe,de),K.stroke();const xe=Math.atan2(de-U.y,oe-U.x),we=10;K.beginPath(),K.moveTo(oe,de),K.lineTo(oe-we*Math.cos(xe-.4),de-we*Math.sin(xe-.4)),K.lineTo(oe-we*Math.cos(xe+.4),de-we*Math.sin(xe+.4)),K.closePath(),K.fill();break}}K.restore()}),k&&(K.save(),K.fillStyle="var(--nice-overlay-50, rgba(0, 0, 0, 0.5))",K.fillRect(0,0,F,Z),K.clearRect(k.x,k.y,k.w,k.h),K.strokeStyle="var(--bg-primary, #fff)",K.lineWidth=2,K.setLineDash([5,5]),K.strokeRect(k.x,k.y,k.w,k.h),K.restore())},[S,w,k]);const ke=n.useCallback(O=>{if(!D.current)return;const K=D.current.getBoundingClientRect(),ye=D.current.width/K.width,ce=D.current.height/K.height,F=(O.clientX-K.left)*ye,Z=(O.clientY-K.top)*ce;p==="crop"?I({startX:F,startY:Z}):p==="annotate"&&me({startX:F,startY:Z})},[p]),he=n.useCallback(O=>{if(!D.current)return;const K=D.current.getBoundingClientRect(),ye=D.current.width/K.width,ce=D.current.height/K.height,F=(O.clientX-K.left)*ye,Z=(O.clientY-K.top)*ce;L&&G({x:Math.min(L.startX,F),y:Math.min(L.startY,Z),w:Math.abs(F-L.startX),h:Math.abs(Z-L.startY)})},[L]),se=n.useCallback(O=>{if(L&&k&&k.w>5&&k.h>5&&ue({crop:{x:k.x,y:k.y,width:k.w,height:k.h}}),I(null),B&&D.current){const K=D.current.getBoundingClientRect(),ye=D.current.width/K.width,ce=D.current.height/K.height,F=(O.clientX-K.left)*ye,Z=(O.clientY-K.top)*ce,U=F-B.startX,oe=Z-B.startY;if(Math.abs(U)>3||Math.abs(oe)>3||s==="text"){const de={type:s,x:B.startX,y:B.startY,width:Math.abs(U)||100,height:Math.abs(oe)||50,color:M,strokeWidth:2,text:s==="text"?prompt(y("imageEditor.annotationText","Text:"))??"":void 0};ue({annotations:[...w.annotations,de]})}me(null)}},[L,k,B,s,M,w.annotations,ue,y]),ge=n.useCallback(()=>{if(!w.crop||!D.current)return;const O=D.current,K=O.getContext("2d");if(!K)return;const{x:ye,y:ce,width:F,height:Z}=w.crop,U=K.getImageData(ye,ce,F,Z);O.width=F,O.height=Z,K.putImageData(U,0,0),G(null),m(null)},[w.crop]),ie=n.useCallback(()=>{if(!D.current)return;const O=D.current.toDataURL("image/png");v?.(O,w)},[v,w]),re=n.useCallback(()=>{q({...Xt}),G(null),m(null)},[]);n.useMemo(()=>`brightness(${w.brightness}%) contrast(${w.contrast}%) saturate(${w.saturate}%) blur(${w.blur}px)`,[w.brightness,w.contrast,w.saturate,w.blur]);const pe=r?e.jsxs("div",{className:"nice-image-editor__toolbar",role:"toolbar",children:[e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:je,disabled:g.length===0,title:y("imageEditor.undo","Undo"),"aria-label":y("imageEditor.undo","Undo"),children:e.jsx(x.oa,{name:"reply",size:16})}),e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:be,disabled:_.length===0,title:y("imageEditor.redo","Redo"),"aria-label":y("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:()=>ue({rotation:(w.rotation-90+360)%360}),title:y("imageEditor.rotateLeft","Rotate left"),"aria-label":y("imageEditor.rotateLeft","Rotate left"),children:e.jsx(x.oa,{name:"reply",size:16})}),e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>ue({rotation:(w.rotation+90)%360}),title:y("imageEditor.rotateRight","Rotate right"),"aria-label":y("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:()=>ue({flipH:!w.flipH}),title:y("imageEditor.flipH","Flip horizontal"),"aria-label":y("imageEditor.flipH","Flip horizontal"),children:e.jsx(x.oa,{name:"shuffle",size:16})}),e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>ue({flipV:!w.flipV}),title:y("imageEditor.flipV","Flip vertical"),"aria-label":y("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:()=>m(p==="crop"?null:"crop"),title:y("imageEditor.crop","Crop"),"aria-label":y("imageEditor.crop","Crop"),children:e.jsx(x.oa,{name:"box",size:16})}),p==="crop"&&w.crop&&e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:ge,title:y("imageEditor.applyCrop","Apply crop"),"aria-label":y("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:y("imageEditor.brightness","Brightness"),children:[e.jsx(x.oa,{name:"lightbulb",size:16}),e.jsx("input",{type:"range",min:0,max:200,value:w.brightness,onChange:O=>ue({brightness:Number(O.target.value)}),className:"nice-image-editor__slider",title:y("imageEditor.brightness","Brightness")})]}),o.includes("contrast")&&e.jsxs("label",{className:"nice-image-editor__slider-label",title:y("imageEditor.contrast","Contrast"),children:[e.jsx(x.oa,{name:"circle",size:16}),e.jsx("input",{type:"range",min:0,max:200,value:w.contrast,onChange:O=>ue({contrast:Number(O.target.value)}),className:"nice-image-editor__slider",title:y("imageEditor.contrast","Contrast")})]}),o.includes("saturate")&&e.jsxs("label",{className:"nice-image-editor__slider-label",title:y("imageEditor.saturate","Saturation"),children:[e.jsx(x.oa,{name:"palette",size:16}),e.jsx("input",{type:"range",min:0,max:200,value:w.saturate,onChange:O=>ue({saturate:Number(O.target.value)}),className:"nice-image-editor__slider",title:y("imageEditor.saturate","Saturation")})]}),o.includes("blur")&&e.jsxs("label",{className:"nice-image-editor__slider-label",title:y("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:w.blur,onChange:O=>ue({blur:Number(O.target.value)}),className:"nice-image-editor__slider",title:y("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:()=>m(p==="annotate"?null:"annotate"),title:y("imageEditor.annotate","Annotate"),"aria-label":y("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=>z(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=>d(O.target.value),className:"nice-image-editor__color",title:y("imageEditor.color","Color")}),w.annotations.length>0&&e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>ue({annotations:w.annotations.slice(0,-1)}),title:y("imageEditor.removeLastAnnotation","Remove last"),"aria-label":y("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:re,title:y("imageEditor.reset","Reset"),"aria-label":y("imageEditor.reset","Reset"),children:e.jsx(x.oa,{name:"refresh",size:16})}),v&&e.jsx("button",{type:"button",className:"nice-image-editor__btn nice-image-editor__btn--save",onClick:ie,children:y("imageEditor.save","Save")}),R&&e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:R,children:y("imageEditor.cancel","Cancel")})]}):void 0,H=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(P*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 · ",w.rotation,"°"]})]}):void 0;return e.jsx(Qt.NiceAppShell,{ref:ne,flush:!0,id:A,className:`nice-image-editor nice-image-editor--${i} nice-editor--${a} ${N??""}`,style:{...Q,width:J,height:Y},toolbar:pe,statusBar:H,children:e.jsxs("div",{className:"nice-image-editor__canvas-wrap",style:{position:"relative"},role:"application","aria-label":y("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($,Di)})}),e.jsx("canvas",{ref:D,className:"nice-image-editor__canvas",onMouseDown:ke,onMouseMove:he,onMouseUp:se,style:{cursor:p==="crop"||p==="annotate"?"crosshair":"default",transform:`scale(${P})`,transformOrigin:"center center"}})]})})});$n.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,j=o.endX-h*Math.cos(r-Math.PI/6),v=o.endY-h*Math.sin(r-Math.PI/6),R=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} ${j},${v} ${R},${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,j)=>`${j===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 Sn=n.forwardRef(({src:t,alt:i="Annotatable image",annotations:a,activeTool:o,defaultStyle:r,onAnnotationsChange:h,className:j,readOnly:v=!1,minZoom:R=.1,maxZoom:C=5},J)=>{const Y=n.useRef(null),$=n.useRef(null),N=n.useRef(null),[Q,te]=n.useState(!1),[ee,ne]=n.useState({width:0,height:0}),[A,y]=n.useReducer(Bi,{annotations:a??[],selectedId:null,activeTool:o??"select",style:{...Pi,...r},zoom:1,panX:0,panY:0,past:[],future:[]});n.useEffect(()=>{o&&y({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=()=>{N.current=b,ne({width:b.naturalWidth,height:b.naturalHeight}),te(!0)},b.src=t},[t]);const D=n.useRef({isDrawing:!1,startX:0,startY:0,currentAnnotation:null,freehandPoints:[]}),f=n.useCallback((b,s)=>{const z=Y.current;if(!z)return{x:0,y:0};const M=z.getBoundingClientRect();return{x:(b-M.left-A.panX)/A.zoom,y:(s-M.top-A.panY)/A.zoom}},[A.zoom,A.panX,A.panY]),w=n.useCallback(()=>{const b=Y.current,s=b?.getContext("2d"),z=N.current;if(!b||!s||!z||!Q)return;b.width=$.current?.clientWidth??z.naturalWidth,b.height=$.current?.clientHeight??z.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(z,0,0);for(const d of A.annotations){switch(s.save(),s.globalAlpha=d.style.opacity,s.strokeStyle=d.style.strokeColor,s.fillStyle=d.style.fillColor,s.lineWidth=d.style.strokeWidth,d.tool){case"rectangle":s.strokeRect(d.x,d.y,d.width,d.height),d.style.fillColor!=="transparent"&&s.fillRect(d.x,d.y,d.width,d.height);break;case"ellipse":{s.beginPath(),s.ellipse(d.x+d.width/2,d.y+d.height/2,Math.abs(d.width/2),Math.abs(d.height/2),0,0,Math.PI*2),s.stroke(),d.style.fillColor!=="transparent"&&s.fill();break}case"arrow":{const c=d;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=d.style.strokeColor,s.fill();break}case"line":{const c=d;s.beginPath(),s.moveTo(c.x,c.y),s.lineTo(c.endX,c.endY),s.stroke();break}case"text":{const c=d;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=d;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=d;s.filter=`blur(${c.intensity??5}px)`,s.drawImage(z,c.x,c.y,c.width,c.height,c.x,c.y,c.width,c.height),s.filter="none";break}}d.id===A.selectedId&&(s.strokeStyle="#4488ff",s.lineWidth=1,s.setLineDash([4,4]),s.strokeRect(d.x-2,d.y-2,d.width+4,d.height+4),s.setLineDash([])),s.restore()}const M=D.current;if(M.isDrawing&&M.currentAnnotation){s.save();const d=M.currentAnnotation;if(s.globalAlpha=d.style.opacity,s.strokeStyle=d.style.strokeColor,s.lineWidth=d.style.strokeWidth,s.setLineDash([6,3]),d.tool==="freehand"){const c=d;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(d.tool==="rectangle")s.strokeRect(d.x,d.y,d.width,d.height);else if(d.tool==="ellipse")s.beginPath(),s.ellipse(d.x+d.width/2,d.y+d.height/2,Math.abs(d.width/2),Math.abs(d.height/2),0,0,Math.PI*2),s.stroke();else if(d.tool==="arrow"||d.tool==="line"){const c=d;s.beginPath(),s.moveTo(c.x,c.y),s.lineTo(c.endX,c.endY),s.stroke()}s.restore()}s.restore()},[A,Q]);n.useEffect(()=>{w()},[w]);const q=n.useCallback(b=>{if(v)return;const s=f(b.clientX,b.clientY),z=A.activeTool;if(z==="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);y({type:"SELECT",id:c?.id??null});return}const M=D.current;M.isDrawing=!0,M.startX=s.x,M.startY=s.y;const d={id:Oi(),style:{...A.style},x:s.x,y:s.y,width:0,height:0};switch(z){case"rectangle":M.currentAnnotation={...d,tool:"rectangle"};break;case"ellipse":M.currentAnnotation={...d,tool:"ellipse"};break;case"arrow":M.currentAnnotation={...d,tool:"arrow",endX:s.x,endY:s.y};break;case"line":M.currentAnnotation={...d,tool:"line",endX:s.x,endY:s.y};break;case"text":M.currentAnnotation={...d,tool:"text",text:"Text",width:100,height:A.style.fontSize??16};break;case"freehand":M.freehandPoints=[s],M.currentAnnotation={...d,tool:"freehand",points:[s]};break;case"blur":M.currentAnnotation={...d,tool:"blur",intensity:5};break}},[v,f,A.activeTool,A.style,A.annotations]),p=n.useCallback(b=>{const s=D.current;if(!s.isDrawing||!s.currentAnnotation)return;const z=f(b.clientX,b.clientY),M=s.currentAnnotation;if(M.tool==="freehand"){s.freehandPoints.push(z),M.points=[...s.freehandPoints];const d=s.freehandPoints.map(l=>l.x),c=s.freehandPoints.map(l=>l.y);M.x=Math.min(...d),M.y=Math.min(...c),M.width=Math.max(...d)-M.x,M.height=Math.max(...c)-M.y}else if(M.tool==="arrow"||M.tool==="line")M.endX=z.x,M.endY=z.y,M.width=Math.abs(z.x-s.startX),M.height=Math.abs(z.y-s.startY);else{const d=Math.min(s.startX,z.x),c=Math.min(s.startY,z.y);M.x=d,M.y=c,M.width=Math.abs(z.x-s.startX),M.height=Math.abs(z.y-s.startY)}w()},[f,w]),m=n.useCallback(()=>{const b=D.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)&&y({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,z=Math.max(R,Math.min(C,A.zoom*s));y({type:"SET_ZOOM",zoom:z})},[A.zoom,R,C]);n.useEffect(()=>{if(v)return;const b=s=>{(s.metaKey||s.ctrlKey)&&s.key==="z"&&!s.shiftKey?(s.preventDefault(),y({type:"UNDO"})):(s.metaKey||s.ctrlKey)&&(s.key==="y"||s.key==="z"&&s.shiftKey)?(s.preventDefault(),y({type:"REDO"})):(s.key==="Delete"||s.key==="Backspace")&&A.selectedId&&y({type:"DELETE_ANNOTATION",id:A.selectedId})};return document.addEventListener("keydown",b),()=>document.removeEventListener("keydown",b)},[v,A.selectedId]),n.useImperativeHandle(J,()=>({exportAsDataURL:async(b="png",s=.92)=>{const z=document.createElement("canvas"),M=N.current;if(!M)return"";z.width=M.naturalWidth,z.height=M.naturalHeight;const d=z.getContext("2d");d.drawImage(M,0,0);for(const c of A.annotations){if(d.save(),d.globalAlpha=c.style.opacity,d.strokeStyle=c.style.strokeColor,d.fillStyle=c.style.fillColor,d.lineWidth=c.style.strokeWidth,c.tool==="rectangle")d.strokeRect(c.x,c.y,c.width,c.height);else if(c.tool==="ellipse")d.beginPath(),d.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),d.stroke();else if(c.tool==="freehand"){const l=c;if(l.points.length>=2){d.beginPath(),d.moveTo(l.points[0].x,l.points[0].y);for(let g=1;g<l.points.length;g++)d.lineTo(l.points[g].x,l.points[g].y);d.stroke()}}else if(c.tool==="text"){const l=c;d.font=`${l.style.fontSize??16}px ${l.style.fontFamily??"sans-serif"}`,d.fillStyle=l.style.strokeColor,d.fillText(l.text,l.x,l.y+(l.style.fontSize??16))}d.restore()}return z.toDataURL(`image/${b}`,s)},exportAnnotations:()=>[...A.annotations],importAnnotations:b=>{y({type:"SET_ANNOTATIONS",annotations:b})},exportAsSVG:()=>{const{width:b,height:s}=ee,z=A.annotations.map(Fi);return`<svg xmlns="http://www.w3.org/2000/svg" width="${b}" height="${s}" viewBox="0 0 ${b} ${s}">
|
|
302
|
+
${z.join(`
|
|
303
|
+
`)}
|
|
304
|
+
</svg>`},undo:()=>y({type:"UNDO"}),redo:()=>y({type:"REDO"}),setZoom:b=>{y({type:"SET_ZOOM",zoom:Math.max(R,Math.min(C,b))})},fitToScreen:()=>{const b=$.current,s=N.current;if(!b||!s)return;const z=b.clientWidth/s.naturalWidth,M=b.clientHeight/s.naturalHeight,d=Math.min(z,M,1);y({type:"SET_ZOOM",zoom:d}),y({type:"SET_PAN",panX:0,panY:0})},clear:()=>y({type:"CLEAR"})}),[A.annotations,ee,R,C]);const X=n.useCallback(b=>{if(b.touches.length!==1)return;const s=b.touches[0];q({clientX:s.clientX,clientY:s.clientY,preventDefault:()=>{}})},[q]),P=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:$,className:`nice-image-annotator ${j??""}`,style:{position:"relative",overflow:"hidden",width:"100%",height:"100%"},children:e.jsx("canvas",{ref:Y,className:"nice-image-annotator__canvas",style:{cursor:A.activeTool==="select"?"default":"crosshair"},onMouseDown:q,onMouseMove:p,onMouseUp:m,onMouseLeave:m,onWheel:S,onTouchStart:X,onTouchMove:P,onTouchEnd:m,role:"img","aria-label":i})})});Sn.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:j,showRotation:v=!0,showFlip:R=!0,showZoom:C=!0,minZoom:J=.5,maxZoom:Y=3,zoomStep:$=.1,showGrid:N=!0,overlayColor:Q="var(--nice-overlay-50, rgba(0, 0, 0, 0.5))",toolbarPosition:te="bottom",toolbarCollapsible:ee=!1,defaultToolbarCollapsed:ne=!1,onChange:A,tutorial:y,className:D="",style:f,"data-testid":w="nice-crop-editor"})=>{const{t:q}=x.Gt(),p=n.useRef(null),m=n.useRef(null),[S,X]=n.useState(i),[P,b]=n.useState(a),[s,z]=n.useState(o),[M,d]=n.useState(!1),[c,l]=n.useState(!1),[g,E]=n.useState(h),[_,T]=n.useState(ne),[L,I]=n.useState(!1),[k,G]=n.useState({x:0,y:0,crop:S}),B=g==="custom"?j:r.find(H=>H.value===g)?.ratio;n.useEffect(()=>{A?.({crop:S,rotation:P,flipH:M,flipV:c,zoom:s})},[S,P,M,c,s,A]);const me=n.useCallback((H,O)=>{if(!B)return H;const K=p.current?.clientWidth??400,ye=p.current?.clientHeight??300,ce=H.width/100*K,F=H.height/100*ye,Z=ce/F;if(Math.abs(Z-B)<.01)return H;if(O?.includes("e")||O?.includes("w")){const oe=ce/B/ye*100;return{...H,height:Math.min(100-H.y,Math.max(5,oe))}}else if(O?.includes("n")||O?.includes("s")){const oe=F*B/K*100;return{...H,width:Math.min(100-H.x,Math.max(5,oe))}}else{const oe=ce/B/ye*100;return{...H,height:Math.min(100-H.y,Math.max(5,oe))}}},[B]),le=n.useCallback((H,O)=>{O===!1||(H.preventDefault(),H.stopPropagation(),I(O),!p.current?.getBoundingClientRect())||G({x:H.clientX,y:H.clientY,crop:{...S}})},[S]),ue=n.useCallback(H=>{if(!L||!p.current)return;const O=p.current.getBoundingClientRect(),K=(H.clientX-k.x)/O.width*100,ye=(H.clientY-k.y)/O.height*100;let ce={...k.crop};if(L==="crop")ce.x=Math.max(0,Math.min(100-ce.width,k.crop.x+K)),ce.y=Math.max(0,Math.min(100-ce.height,k.crop.y+ye));else{switch(L){case"resize-nw":ce.x=Math.max(0,Math.min(k.crop.x+k.crop.width-5,k.crop.x+K)),ce.y=Math.max(0,Math.min(k.crop.y+k.crop.height-5,k.crop.y+ye)),ce.width=k.crop.width-(ce.x-k.crop.x),ce.height=k.crop.height-(ce.y-k.crop.y);break;case"resize-ne":ce.y=Math.max(0,Math.min(k.crop.y+k.crop.height-5,k.crop.y+ye)),ce.width=Math.max(5,Math.min(100-ce.x,k.crop.width+K)),ce.height=k.crop.height-(ce.y-k.crop.y);break;case"resize-sw":ce.x=Math.max(0,Math.min(k.crop.x+k.crop.width-5,k.crop.x+K)),ce.width=k.crop.width-(ce.x-k.crop.x),ce.height=Math.max(5,Math.min(100-ce.y,k.crop.height+ye));break;case"resize-se":ce.width=Math.max(5,Math.min(100-ce.x,k.crop.width+K)),ce.height=Math.max(5,Math.min(100-ce.y,k.crop.height+ye));break;case"resize-n":ce.y=Math.max(0,Math.min(k.crop.y+k.crop.height-5,k.crop.y+ye)),ce.height=k.crop.height-(ce.y-k.crop.y);break;case"resize-s":ce.height=Math.max(5,Math.min(100-ce.y,k.crop.height+ye));break;case"resize-e":ce.width=Math.max(5,Math.min(100-ce.x,k.crop.width+K));break;case"resize-w":ce.x=Math.max(0,Math.min(k.crop.x+k.crop.width-5,k.crop.x+K)),ce.width=k.crop.width-(ce.x-k.crop.x);break}ce=me(ce,L.replace("resize-",""))}X(ce)},[L,k,me]),je=n.useCallback(()=>{I(!1)},[]);n.useEffect(()=>{if(L)return document.addEventListener("mousemove",ue),document.addEventListener("mouseup",je),()=>{document.removeEventListener("mousemove",ue),document.removeEventListener("mouseup",je)}},[L,ue,je]);const be=n.useCallback(()=>{b(H=>(H-90+360)%360)},[]),ke=n.useCallback(()=>{b(H=>(H+90)%360)},[]),he=n.useCallback(()=>{d(H=>!H)},[]),se=n.useCallback(()=>{l(H=>!H)},[]),ge=n.useCallback(()=>{X(i),b(a),z(o),d(!1),l(!1),E(h)},[i,a,o,h]);n.useEffect(()=>{X(H=>me(H))},[g,me]);const ie=`scale(${s}) rotate(${P}deg) scaleX(${M?-1:1}) scaleY(${c?-1:1})`,re=te==="top"?"column-reverse":te==="left"?"row-reverse":te==="right"?"row":"column",pe=te==="left"||te==="right";return e.jsxs("div",{className:`nice-crop-editor nice-crop-editor--toolbar-${te} ${D}`,style:{position:"relative",display:"flex",flexDirection:re,gap:12,...f},"data-testid":w,children:[e.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:20},children:e.jsx(x.Ql,{steps:x.Yl(y,Ki)})}),e.jsxs("div",{ref:p,className:"nice-crop-editor__container","data-testid":`${w}-container`,children:[e.jsx("img",{ref:m,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:H=>le(H,"crop"),"data-testid":`${w}-crop-area`,children:[N&&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:H=>le(H,"resize-nw")}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--ne",onMouseDown:H=>le(H,"resize-ne")}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--sw",onMouseDown:H=>le(H,"resize-sw")}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--se",onMouseDown:H=>le(H,"resize-se")}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--n",onMouseDown:H=>le(H,"resize-n")}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--s",onMouseDown:H=>le(H,"resize-s")}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--e",onMouseDown:H=>le(H,"resize-e")}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--w",onMouseDown:H=>le(H,"resize-w")})]})]}),e.jsxs("div",{className:`nice-crop-editor__controls ${_?"nice-crop-editor__controls--collapsed":""}`,style:{display:"flex",flexDirection:pe?"column":"row",flexWrap:pe?"nowrap":"wrap",gap:8,alignItems:pe?"stretch":"center",flexShrink:0},children:[ee&&e.jsx("button",{type:"button",className:"nice-crop-editor__toolbar-toggle","aria-expanded":!_,"aria-label":_?"Show toolbar":"Hide toolbar",onClick:()=>T(H=>!H),style:{alignSelf:"flex-start",background:"var(--bg-secondary)",border:"1px solid var(--border-color)",borderRadius:4,padding:"2px 8px",cursor:"pointer",color:"var(--text-primary)",fontSize:12},children:e.jsx(x.oa,{name:_?"chevron-right":"chevron-down",size:14})}),!_&&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(H=>e.jsx("button",{type:"button",className:`nice-crop-editor__aspect-btn ${g===H.value?"nice-crop-editor__aspect-btn--selected":""}`,onClick:()=>E(H.value),title:H.label,children:H.label},H.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:J,max:Y,step:$,value:s,onChange:H=>z(parseFloat(H.target.value)),"data-testid":`${w}-zoom`})]}),e.jsxs("div",{className:"nice-crop-editor__control-group nice-crop-editor__control-group--row",children:[v&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"nice-crop-editor__btn",onClick:be,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:ke,title:q("rotateRight","Rotate Right"),"aria-label":q("rotateRight","Rotate Right"),children:e.jsx(x.oa,{name:"forward",size:16})})]}),R&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:`nice-crop-editor__btn ${M?"nice-crop-editor__btn--active":""}`,onClick:he,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:se,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:ge,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:j="md",id:v,className:R,style:C,accessMode:J,src:Y,annotations:$=[],onAnnotationsChange:N,activeTool:Q,onToolChange:te,currentPage:ee=1,onPageChange:ne,totalPages:A=1,defaultColor:y="var(--nice-warning, #ffff00)",tools:D=Gi,author:f,zoom:w=1,onZoomChange:q,onAnnotationClick:p,onAnnotationDelete:m,tutorial:S},X)=>{const P=x.Dc(J,v),b=P==="hidden";P==="disabled"&&(r=!0),P==="readOnly"&&(h=!0);const{t:s}=x.Gt(),z=x.bc(v),M=$.filter(L=>L.page===ee),d=n.useCallback(L=>{te?.(Q===L?null:L)},[Q,te]),c=n.useCallback(L=>{if(h||!Q||Q==="freehand")return;const I=L.currentTarget.getBoundingClientRect(),k=(L.clientX-I.left)/I.width,G=(L.clientY-I.top)/I.height,B={id:`ann-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,tool:Q,page:ee,x:k,y:G,color:y,author:f,createdAt:new Date().toISOString(),text:Q==="text"?"":void 0};N?.([...$,B])},[h,Q,ee,y,f,$,N]);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:[D.map(L=>e.jsx("button",{type:"button",className:`nice-pdf-annotation__tool-btn${Q===L?" nice-pdf-annotation__tool-btn--active":""}`,onClick:()=>d(L),disabled:r,title:s(`pdfTool_${L}`,L),children:e.jsx(x.oa,{name:Xi[L],size:16})},L)),e.jsx("span",{className:"nice-pdf-annotation__toolbar-sep"}),e.jsx("button",{type:"button",disabled:r,onClick:()=>q?.(Math.max(.25,w-.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(w*100),"%"]}),e.jsx("button",{type:"button",disabled:r,onClick:()=>q?.(Math.min(4,w+.25)),title:s("zoomIn","Zoom in"),"aria-label":s("zoomIn","Zoom in"),children:e.jsx(x.oa,{name:"plus",size:16})})]}),E=e.jsxs("div",{className:"nice-pdf-annotation__pager",children:[e.jsx("button",{type:"button",disabled:r||ee<=1,onClick:()=>ne?.(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:()=>ne?.(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:X,flush:!0,id:z,className:`nice-pdf-annotation nice-size-${j}${R?` ${R}`:""}${a?" nice-error":""}${r?" nice-disabled":""}`,style:C,menubar:l,toolbar:g,bottomPanel:E,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(${w})`,transformOrigin:"top left"},children:[e.jsx("iframe",{src:Y,className:"nice-pdf-annotation__frame",title:s("pdfViewer","PDF Viewer")}),e.jsx("div",{className:"nice-pdf-annotation__layer",onClick:c,children:M.map(L=>e.jsxs("div",{className:`nice-pdf-annotation__mark nice-pdf-annotation__mark--${L.tool}`,style:{left:`${L.x*100}%`,top:`${L.y*100}%`,backgroundColor:L.color},onClick:I=>{I.stopPropagation(),p?.(L)},title:L.text??L.tool,children:[L.text&&e.jsx("span",{children:L.text}),!h&&e.jsx("button",{type:"button",className:"nice-pdf-annotation__mark-delete",onClick:I=>{I.stopPropagation(),m?.(L.id)},"aria-label":s("delete","Delete"),children:e.jsx(x.oa,{name:"close",size:14})})]},L.id))})]})]})})});Rn.displayName="NicePDFAnnotationEditor";function qt(t,i){const a=i.getBoundingClientRect();let o,r,h;if("touches"in t){const j=t.touches[0];o=j.clientX-a.left,r=j.clientY-a.top,h=j.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),j=Math.min(h/5,1),v=o-j*(o-a),R=t.pressure??.5,C=a+R*(o-a);return v*.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:j,width:v="100%",height:R=200,penColor:C="",penWidth:J=2,minWidth:Y=.5,maxWidth:$=4,backgroundColor:N="",placeholder:Q,showClearButton:te=!0,showUndoButton:ee=!0,showColorPicker:ne=!1,showSizeSlider:A=!1,velocityFilterWeight:y=.7,throttle:D=16,disabled:f=!1,readOnly:w=!1,displayMode:q=!1,onBegin:p,onEnd:m,className:S,"data-testid":X}=i,{t:P}=x.Gt(),b=Q||P("signature.placeholder","Sign here"),s=w||q,z=q?!1:te,M=q?!1:ee,d=q?!1:ne,c=q?!1:A,l=n.useRef(null),[g,E]=n.useState(o?.strokes??[]),[_,T]=n.useState([]),[L,I]=n.useState(!1),[k,G]=n.useState(C),[B,me]=n.useState(J),le=n.useRef(null),ue=n.useRef(0),je=x.gu(l),be=N||(je?"#0f172a":"#ffffff"),ke=C||(je?"#f8fafc":"#111827"),he=k||ke,se=g.length===0&&_.length===0;n.useEffect(()=>{const Z=l.current;if(!Z)return;const U=Z.getContext("2d");if(!U)return;const oe=Z.getBoundingClientRect(),de=window.devicePixelRatio||1;Z.width=oe.width*de,Z.height=oe.height*de,U.scale(de,de),ge()},[v,R]);const ge=n.useCallback(()=>{const Z=l.current;if(!Z)return;const U=Z.getContext("2d");if(!U)return;const oe=Z.getBoundingClientRect();U.fillStyle=be,U.fillRect(0,0,oe.width,oe.height),g.forEach(de=>{if(U.strokeStyle=de.color||ke,!(de.points.length<2))for(let xe=1;xe<de.points.length;xe++){const we=de.points[xe-1],Re=de.points[xe],Te=Wt(Re,we,Y,$);Vt(U,we,Re,Te)}})},[g,be,ke,Y,$,y]);n.useEffect(()=>{ge()},[ge]),n.useEffect(()=>{o?.strokes&&E(o.strokes)},[o]),n.useEffect(()=>{const Z=l.current;if(Z)if(g.length===0)r?.(null),h?.(null);else{const U=Z.getBoundingClientRect();r?.({strokes:g,width:U.width,height:U.height,timestamp:Date.now()}),h?.(Z.toDataURL("image/png"))}},[g,r,h]);const ie=n.useCallback(Z=>{if(f||s)return;const U=l.current;if(!U)return;U.setPointerCapture(Z.pointerId);const oe=qt(Z.nativeEvent,U);I(!0),T([oe]),le.current=oe,ue.current=oe.time,p?.()},[f,s,p]),re=n.useCallback(Z=>{if(!L||f||s)return;const U=l.current;if(!U)return;const oe=U.getContext("2d");if(!oe)return;const de=Date.now();if(de-ue.current<D)return;const xe=qt(Z.nativeEvent,U),we=le.current;if(we){oe.strokeStyle=he;const Re=Wt(xe,we,Y,$);Vt(oe,we,xe,Re)}T(Re=>[...Re,xe]),le.current=xe,ue.current=de},[L,f,s,he,Y,$,y,D]),pe=n.useCallback(Z=>{if(!L)return;const U=l.current;if(U&&U.releasePointerCapture(Z.pointerId),_.length>0){const oe={points:_,color:he,width:B};E(de=>[...de,oe])}I(!1),T([]),le.current=null,m?.()},[L,_,he,B,m]),H=n.useCallback(()=>{E([]),T([]),ge()},[ge]),O=n.useCallback(()=>{E(Z=>Z.slice(0,-1))},[]),K=n.useCallback((Z="png",U=.92)=>{const oe=l.current;if(!oe)return"";const de=Z==="jpeg"?"image/jpeg":"image/png";return oe.toDataURL(de,U)},[]),ye=n.useCallback(async(Z="png",U=.92)=>{const oe=l.current;return oe?new Promise(de=>{const xe=Z==="jpeg"?"image/jpeg":"image/png";oe.toBlob(we=>de(we),xe,U)}):null},[]),ce=n.useCallback(()=>{const Z=l.current;if(!Z)return"";const U=Z.getBoundingClientRect(),oe=g.map(de=>de.points.length<2?"":`<path d="${de.points.reduce((we,Re,Te)=>Te===0?`M ${Re.x} ${Re.y}`:`${we} L ${Re.x} ${Re.y}`,"")}" stroke="${de.color||ke}" stroke-width="${de.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 ${Z.width} ${Z.height}">
|
|
306
|
+
<rect width="100%" height="100%" fill="${be}"/>
|
|
307
|
+
${oe}
|
|
308
|
+
</svg>`},[g,be,ke]);n.useImperativeHandle(a,()=>({clear:H,undo:O,isEmpty:()=>g.length===0,getData:()=>{const Z=l.current;if(!Z||g.length===0)return null;const U=Z.getBoundingClientRect();return{strokes:g,width:U.width,height:U.height,timestamp:Date.now()}},setData:Z=>{E(Z.strokes)},toDataURL:K,toBlob:ye,toSVG:ce,getCanvas:()=>l.current}),[g,H,O,K,ye,ce]),n.useEffect(()=>{const Z=l.current;if(!Z)return;const U=oe=>{L&&oe.preventDefault()};return Z.addEventListener("touchmove",U,{passive:!1}),()=>Z.removeEventListener("touchmove",U)},[L]);const F=z||M||d||c;return e.jsxs("div",{className:`nice-signature ${f?"nice-signature--disabled":""} ${s?"nice-signature--readonly":""} ${S??""}`,style:{width:v},"data-testid":X,children:[j&&e.jsx("label",{className:"nice-signature__label",children:j}),F&&e.jsxs("div",{className:"nice-signature__toolbar",children:[d&&e.jsx("div",{className:"nice-signature__color-picker",children:e.jsx("input",{type:"color",value:k,onChange:Z=>G(Z.target.value),disabled:f||s,title:"Pen color"})}),c&&e.jsx("div",{className:"nice-signature__size-slider",children:e.jsx("input",{type:"range",min:Y,max:$,step:.5,value:B,onChange:Z=>me(parseFloat(Z.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})}),z&&e.jsx("button",{type:"button",onClick:H,disabled:f||s||se,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:R},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:re,onPointerUp:pe,onPointerLeave:pe}),se&&!L&&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:j="md",id:v,className:R,style:C,accessMode:J,mode:Y="manual",onScan:$,onModeChange:N,beepOnScan:Q=!0,beepFrequency:te=1800,beepDuration:ee=150,placeholder:ne,scanHistory:A=[],showHistory:y=!0,maxHistory:D=10,autoFocus:f=!0,onCameraFrame:w},q)=>{const p=x.Dc(J,v),m=p==="hidden";p==="disabled"&&(r=!0),p==="readOnly"&&(h=!0);const{t:S}=x.Gt(),X=x.bc(v),[P,b]=n.useState(""),s=n.useRef(null),z=n.useRef(null),M=n.useCallback(()=>{if(Q)try{z.current||(z.current=new AudioContext);const l=z.current,g=l.createOscillator(),E=l.createGain();g.connect(E),E.connect(l.destination),g.frequency.value=te,g.type="square",E.gain.value=.3,g.start(),g.stop(l.currentTime+ee/1e3)}catch{}},[Q,te,ee]),d=n.useCallback(()=>{P.trim()&&(M(),$?.({value:P.trim(),format:"manual",scannedAt:new Date}),b(""),s.current?.focus())},[P,$,M]),c=A.slice(0,D);return m?null:e.jsxs("div",{ref:q,id:X,className:`nice-scanner nice-size-${j}${R?` ${R}`:""}${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${Y==="camera"?" nice-scanner__mode-btn--active":""}`,onClick:()=>N?.("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${Y==="manual"?" nice-scanner__mode-btn--active":""}`,onClick:()=>N?.("manual"),disabled:r,children:[e.jsx(x.oa,{name:"edit",size:16})," ",S("manual","Manual")]})]}),Y==="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")})]})})}),Y==="manual"&&!h&&e.jsxs("div",{className:"nice-scanner__manual",children:[e.jsx("input",{ref:s,className:"nice-input nice-scanner__input",type:"text",value:P,onChange:l=>b(l.target.value),onKeyDown:l=>l.key==="Enter"&&d(),placeholder:ne??S("enterCode","Enter or scan code…"),disabled:r,autoFocus:f}),e.jsx("button",{type:"button",className:"nice-scanner__submit",onClick:d,disabled:r||!P.trim(),"aria-label":S("submit","Submit"),children:e.jsx(x.oa,{name:"check",size:16})})]}),y&&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((v,R)=>v+(R.netAmount??0),0),o=i.reduce((v,R)=>v+(R.grossAmount??0),0),r=o-a,h=new Map;for(const v of i){const R=v.vatRate??0,C=h.get(R)??{base:0,amount:0};C.base+=v.netAmount??0,C.amount+=(v.grossAmount??0)-(v.netAmount??0),h.set(R,C)}const j=Array.from(h.entries()).map(([v,R])=>({rate:v,base:Math.round(R.base*100)/100,amount:Math.round(R.amount*100)/100}));return{totalNet:Math.round(a*100)/100,totalVat:Math.round(r*100)/100,totalGross:Math.round(o*100)/100,vatBreakdown:j}}const An=n.forwardRef(({label:t,helperText:i,error:a,required:o,disabled:r,readOnly:h,size:j="md",name:v,id:R,className:C,style:J,accessMode:Y,value:$=[],onChange:N,onTotalsChange:Q,currencySymbol:te="zł",defaultVatRate:ee=23,vatRates:ne=[0,5,8,23],units:A=["szt.","h","kg","m","usł."],showDiscount:y=!0,showUnit:D=!0,showTotals:f=!0,editable:w=!0,maxLines:q,tutorial:p},m)=>{const S=x.Dc(Y,R),X=S==="hidden";S==="disabled"&&(r=!0),S==="readOnly"&&(h=!0);const{t:P}=x.Gt(),b=x.bc(R),s=n.useMemo(()=>$.map(In),[$]),z=n.useMemo(()=>Qi($),[$]);n.useEffect(()=>{Q?.(z)},[z,Q]);const M=n.useCallback((g,E,_)=>{const T=[...$];T[g]={...T[g],[E]:_},N?.(T)},[$,N]),d=n.useCallback(()=>{q&&$.length>=q||N?.([...$,Ji(ee)])},[$,N,ee,q]),c=n.useCallback(g=>{N?.($.filter((E,_)=>_!==g))},[$,N]),l=g=>`${g.toFixed(2)} ${te}`;return X?null:e.jsxs("div",{ref:m,id:b,className:`nice-invoice-lines nice-size-${j}${C?` ${C}`:""}${a?" nice-error":""}${r?" nice-disabled":""}`,style:{position:"relative",...J},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:P("description","Description")}),e.jsx("th",{className:"nice-il__th-qty",children:P("qty","Qty")}),D&&e.jsx("th",{className:"nice-il__th-unit",children:P("unit","Unit")}),e.jsx("th",{className:"nice-il__th-price",children:P("unitPrice","Unit Price")}),y&&e.jsx("th",{className:"nice-il__th-disc",children:P("discount","Disc %")}),e.jsx("th",{className:"nice-il__th-vat",children:P("vat","VAT %")}),e.jsx("th",{className:"nice-il__th-net",children:P("net","Net")}),e.jsx("th",{className:"nice-il__th-gross",children:P("gross","Gross")}),w&&!h&&e.jsx("th",{className:"nice-il__th-actions"})]})}),e.jsx("tbody",{children:s.map((g,E)=>e.jsxs("tr",{children:[e.jsx("td",{className:"nice-il__cell-num",children:E+1}),e.jsx("td",{className:"nice-il__cell-desc",children:e.jsx("input",{className:"nice-input",type:"text",value:g.description,onChange:_=>M(E,"description",_.target.value),disabled:r,readOnly:h,placeholder:P("itemDescription","Item description")})}),e.jsx("td",{className:"nice-il__cell-qty",children:e.jsx("input",{className:"nice-input",type:"number",value:g.quantity,onChange:_=>M(E,"quantity",parseFloat(_.target.value)||0),disabled:r,readOnly:h,min:0,step:"any"})}),D&&e.jsx("td",{className:"nice-il__cell-unit",children:e.jsx("select",{className:"nice-select",value:g.unit??"",onChange:_=>M(E,"unit",_.target.value),disabled:r,children:A.map(_=>e.jsx("option",{value:_,children:_},_))})}),e.jsx("td",{className:"nice-il__cell-price",children:e.jsx("input",{className:"nice-input",type:"number",value:g.unitPrice,onChange:_=>M(E,"unitPrice",parseFloat(_.target.value)||0),disabled:r,readOnly:h,min:0,step:"0.01"})}),y&&e.jsx("td",{className:"nice-il__cell-disc",children:e.jsx("input",{className:"nice-input",type:"number",value:g.discount??0,onChange:_=>M(E,"discount",parseFloat(_.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:_=>M(E,"vatRate",parseInt(_.target.value,10)),disabled:r,children:ne.map(_=>e.jsxs("option",{value:_,children:[_,"%"]},_))})}),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)}),w&&!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(E),disabled:r,title:P("remove","Remove"),"aria-label":P("remove","Remove"),children:e.jsx(x.oa,{name:"close",size:14})})})]},g.id))})]}),w&&!h&&e.jsxs("button",{type:"button",className:"nice-btn nice-btn--outlined nice-btn--sm nice-invoice-lines__add",onClick:d,disabled:r||q!=null&&$.length>=q,children:["+ ",P("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:[P("totalNet","Net total"),":"]}),e.jsx("span",{className:"nice-il__total-value",children:l(z.totalNet)})]}),z.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:[P("totalGross","Gross total"),":"]}),e.jsx("span",{className:"nice-il__total-value nice-il__total-value--gross",children:l(z.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 zn=n.forwardRef(({value:t="",onChange:i,suggestions:a=[],onSearch:o,trigger:r="@",renderSuggestion:h,placeholder:j,rows:v=3,label:R,helperText:C,error:J,required:Y,disabled:$,readOnly:N,loading:Q,labelPlacement:te,errorPlacement:ee,labelWidth:ne,controlWidth:A,size:y="md",name:D,id:f,className:w,style:q,...p},m)=>{const S=x.bc(f),[X,P]=n.useState(!1),[b,s]=n.useState(""),[z,M]=n.useState(0),[d,c]=n.useState({top:0,left:0}),l=n.useRef(null),g=n.useRef(-1),_=a.map(G=>typeof G=="string"?{key:G,label:G}:G).filter(G=>G.label.toLowerCase().includes(b.toLowerCase())),T=n.useCallback(()=>{P(!1),s(""),M(0),g.current=-1},[]),L=n.useCallback(G=>{const B=l.current;if(!B||g.current<0)return;const me=t.slice(0,g.current),le=t.slice(B.selectionStart),ue=`${r}${G.label} `,je=me+ue+le;i?.(je),T(),requestAnimationFrame(()=>{const be=me.length+ue.length;B.setSelectionRange(be,be),B.focus()})},[t,i,r,T]),I=n.useCallback(G=>{const B=G.target.value;i?.(B);const me=G.target.selectionStart,le=B.slice(0,me),ue=le.lastIndexOf(r);if(ue>=0){const je=ue>0?le[ue-1]:" ",be=le.slice(ue+r.length);if(/\s/.test(je)&&!/\s/.test(be)){g.current=ue;const ke=be;s(ke),P(!0),M(0),o?.(ke);const he=G.target,se=he.getBoundingClientRect(),ge=parseInt(getComputedStyle(he).lineHeight)||20,ie=le.split(`
|
|
430
|
+
`);c({top:se.top+ie.length*ge+4-he.scrollTop,left:se.left+8});return}}T()},[i,r,o,T]),k=n.useCallback(G=>{!X||_.length===0||(G.key==="ArrowDown"?(G.preventDefault(),M(B=>(B+1)%_.length)):G.key==="ArrowUp"?(G.preventDefault(),M(B=>(B-1+_.length)%_.length)):G.key==="Enter"?(G.preventDefault(),_[z]&&L(_[z])):G.key==="Escape"&&T())},[X,_,z,L,T]);return n.useEffect(()=>{if(!X)return;const G=B=>{const me=l.current;me&&!me.contains(B.target)&&T()};return document.addEventListener("mousedown",G),()=>document.removeEventListener("mousedown",G)},[X,T]),e.jsxs("div",{className:`nice-field nice-field--${y} ${te==="left"?"nice-field--label-left":""} ${ee==="right"?"nice-field--error-right":""} ${Q?"nice-field--loading":""} ${w||""}`,style:{...q,...ne!=null&&{"--nice-field-label-width":typeof ne=="number"?`${ne}px`:ne},...A!=null&&{"--nice-field-control-width":typeof A=="number"?`${A}px`:A}},"aria-busy":Q||void 0,...p,children:[R&&e.jsx("label",{htmlFor:S,className:`nice-field__label ${Y?"nice-field__label--required":""}`,children:R}),e.jsxs("div",{className:"nice-field__control",children:[e.jsxs("div",{className:`nice-mention nice-mention--${y} ${J?"nice-mention--error":""} ${$?"nice-mention--disabled":""}`,children:[e.jsx("textarea",{ref:G=>{l.current=G,typeof m=="function"?m(G):m&&(m.current=G)},id:S,name:D,className:"nice-mention__input",value:t,onChange:I,onKeyDown:k,placeholder:j,rows:v,disabled:$,readOnly:N,"aria-invalid":!!J,"aria-describedby":J?`${S}-error`:C?`${S}-helper`:void 0,"aria-autocomplete":"list","aria-expanded":X}),X&&_.length>0&&e.jsx("ul",{className:"nice-mention__suggestions",role:"listbox",style:{position:"fixed",top:d.top,left:d.left},children:_.map((G,B)=>e.jsx("li",{role:"option","aria-selected":B===z,className:`nice-mention__suggestion ${B===z?"nice-mention__suggestion--active":""}`,onMouseDown:me=>{me.preventDefault(),L(G)},onMouseEnter:()=>M(B),children:h?h(G):e.jsxs(e.Fragment,{children:[G.icon&&e.jsx("span",{className:"nice-mention__suggestion-icon",children:G.icon}),e.jsx("span",{children:G.label})]})},G.key))})]}),Q&&e.jsx("span",{className:"nice-field__spinner",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})}),ee==="right"&&J&&e.jsx("div",{id:`${S}-error`,className:"nice-field__error",role:"alert",children:J}),ee==="right"&&!J&&C&&e.jsx("div",{id:`${S}-helper`,className:"nice-field__helper",children:C})]}),ee!=="right"&&J&&e.jsx("div",{id:`${S}-error`,className:"nice-field__error",role:"alert",children:J}),ee!=="right"&&!J&&C&&e.jsx("div",{id:`${S}-helper`,className:"nice-field__helper",children:C})]})});zn.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=vn;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=Sn;exports.NiceImageEditor=$n;exports.NiceInputOtp=Cn;exports.NiceInvoiceLineEditor=An;exports.NiceKeyValueEditor=Ti;exports.NiceKnob=en;exports.NiceLogConsole=_n;exports.NiceLookup=qn;exports.NiceMarkdownEditor=xn;exports.NiceMention=zn;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=Ke;exports.hexToRgb=st;exports.hsvToHex=ze;exports.hsvToRgb=sn;exports.randomPalette=mn;exports.rgbToHex=cn;exports.rgbToHsl=rn;exports.rgbToHsv=$t;exports.wcagLevel=ut;
|