@nice2dev/ui 1.4.0 → 1.4.2
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 +51 -0
- package/dist/NiceCodeEditor-DhdjnDLV.cjs +289 -0
- package/dist/{NiceDataGrid-BT6iCUgP.cjs → NiceDataGrid-CrKDzMM1.cjs} +1 -1
- package/dist/{NiceForm-Bysp66Ef.cjs → NiceForm-CT9hEXpc.cjs} +1 -1
- package/dist/NiceLoginForm-C2-WgRn0.cjs +1 -0
- package/dist/NiceMention-BZEHqPrf.cjs +432 -0
- package/dist/NiceModuleLifecyclePanel-DKlqKPy2.cjs +1 -0
- package/dist/{NiceSavedQueryPanel-BbznsXFd.cjs → NiceSavedQueryPanel-C5Ab_NWx.cjs} +1 -1
- package/dist/NiceScheduler-BZQAKEVF.cjs +5 -0
- package/dist/{NiceWindow-pgR4c-kQ.cjs → NiceWindow-BklnkBpu.cjs} +1 -1
- package/dist/charts/NiceLinearGauge.mjs +96 -83
- package/dist/charts/NicePolarChart.mjs +47 -47
- package/dist/charts-BzlvCCg9.cjs +768 -0
- package/dist/charts.cjs +1 -1
- package/dist/{core-lazy-CL4ZIxF-.cjs → core-lazy-VTd5zfoZ.cjs} +1 -1
- package/dist/data.cjs +1 -1
- package/dist/display/NiceAvatar.mjs +40 -24
- package/dist/editors/pickers/NiceDateRangeBox.mjs +92 -92
- package/dist/editors/pickers/NiceDateTimePicker.mjs +173 -173
- package/dist/editors/rich/NiceCodeEditor.mjs +645 -584
- package/dist/editors/rich/NiceDocumentEditor.mjs +277 -254
- package/dist/editors.cjs +1 -1
- package/dist/feedback/NiceDrawer.mjs +15 -15
- package/dist/feedback.cjs +1 -1
- package/dist/index.cjs +202 -202
- package/dist/index.d.ts +18 -0
- package/dist/lazy.cjs +1 -1
- package/dist/navigation/NiceNavShell.mjs +646 -593
- package/dist/navigation/NiceSidebarNav.mjs +844 -823
- package/dist/navigation.cjs +1 -1
- package/dist/overlays/NiceWindow.mjs +91 -91
- package/dist/overlays.cjs +1 -1
- package/dist/planning/NiceScheduler.mjs +170 -169
- package/dist/planning/NiceSchedulerViews.mjs +242 -233
- package/dist/style.css +2 -2
- package/dist/utility/intlNames.mjs +26 -16
- package/package.json +4 -4
- package/dist/NiceCodeEditor-D0QZW88r.cjs +0 -268
- package/dist/NiceLoginForm-FGf32sro.cjs +0 -1
- package/dist/NiceMention-sc8W-DwH.cjs +0 -430
- package/dist/NiceModuleLifecyclePanel-DBQPCa_V.cjs +0 -1
- package/dist/NiceScheduler-3Ez0zSQJ.cjs +0 -5
- package/dist/charts-B0tHOpJ7.cjs +0 -768
|
@@ -1,430 +0,0 @@
|
|
|
1
|
-
"use strict";const e=require("react/jsx-runtime"),r=require("@nice2dev/ui-core"),n=require("react"),nt=require("react-dom"),We=require("./NiceSelect-BNPXs6FQ.cjs"),lt=require("./pickerCommons-CwcCc8Qi.cjs"),Je=require("./devops-cgRBnZVX.cjs"),mt=require("./NiceForm-Bysp66Ef.cjs"),tt=require("./no-code-B3BHeyG-.cjs"),on=require("@nice2dev/i18n"),In=require("./NiceHtmlEditor-C1OVtLQ6.cjs"),Ie=require("./NiceButton-DzCqkG5a.cjs"),Ot=require("./NiceColorPicker-BLwYNSXJ.cjs"),Et=require("./NiceCodeEditor-D0QZW88r.cjs"),jt=require("./injectStyleOnce-DeWaxcdf.cjs"),Mn=({min:t=0,max:i=100,step:a=1,startValue:o=t,endValue:c=i,onChange:g,showLabels:y=!0,formatLabel:T,valuePlacement:P="none",label:M,error:W,helperText:X,required:B,disabled:$,readOnly:U,loading:ie,size:ee="md",id:re,className:G,style:H,accessMode:w,showKeyboardHints:s,labelPlacement:R,errorPlacement:F,labelWidth:A,controlWidth:k})=>{const x=r.useNiceAccessMode(w,re),C=x==="hidden";(x==="disabled"||x==="readOnly")&&($=!0);const{t:f}=r.useNiceTranslation(),E=r.useControlId(re),L=n.useRef(null),N=n.useMemo(()=>[r.COMMON_SHORTCUTS.increment,r.COMMON_SHORTCUTS.decrement,r.COMMON_SHORTCUTS.first,r.COMMON_SHORTCUTS.last,{key:"Tab",description:f("shortcuts.switchThumb","Switch thumb")}],[f]),d=u=>(u-t)/(i-t)*100,z=u=>T?T(u):String(u),b=n.useCallback(u=>{const _=Math.round(u/a)*a;return Math.max(t,Math.min(i,_))},[t,i,a]),h=n.useCallback((u,_)=>{u.preventDefault();const S=L.current;if(!S||$)return;const m=O=>{const V=S.getBoundingClientRect(),v=Math.max(0,Math.min(1,(O.clientX-V.left)/V.width)),q=b(t+v*(i-t));_==="start"?g?.(Math.min(q,c),c):g?.(o,Math.max(q,o))},D=()=>{document.removeEventListener("pointermove",m),document.removeEventListener("pointerup",D)};document.addEventListener("pointermove",m),document.addEventListener("pointerup",D)},[t,i,b,o,c,g,$]),l=(u,_)=>{if($||U)return;const S=_==="start"?o:c,m=_==="start"?t:o,D=_==="start"?c:i,O=Math.max(a,(i-t)/10),V=u.key==="ArrowRight"||u.key==="ArrowUp"?S+a:u.key==="ArrowLeft"||u.key==="ArrowDown"?S-a:u.key==="PageUp"?S+O:u.key==="PageDown"?S-O:u.key==="Home"?m:u.key==="End"?D:null;if(V===null)return;u.preventDefault();const v=Math.max(m,Math.min(D,b(V)));_==="start"?g?.(v,c):g?.(o,v)};return C?null:e.jsxs("div",{className:`nice-field nice-field--${ee} nice-field--rangeslider ${R==="left"?"nice-field--label-left":""} ${F==="right"?"nice-field--error-right":""} ${W?"nice-field--error":""} ${ie?"nice-field--loading":""} ${G||""}`,style:{...H,...A!=null&&{"--nice-field-label-width":typeof A=="number"?`${A}px`:A},...k!=null&&{"--nice-field-control-width":typeof k=="number"?`${k}px`:k}},"aria-busy":ie||void 0,children:[(M||P==="right"&&R!=="left")&&(R!=="left"?e.jsxs("div",{className:"nice-range-slider__header",children:[M?e.jsx("label",{className:"nice-field__label",htmlFor:E,children:e.jsxs("span",{className:"nice-field__label-text",children:[M,B&&e.jsx("span",{className:"nice-field__required",children:"*"}),s&&e.jsx(r.NiceKeyboardHint,{shortcuts:N,size:"sm"})]})}):e.jsx("span",{}),P==="right"&&e.jsxs("span",{className:"nice-range-slider__value nice-range-slider__value--header",children:[z(o)," – ",z(c)]})]}):M&&e.jsx("label",{className:"nice-field__label",htmlFor:E,children:e.jsxs("span",{className:"nice-field__label-text",children:[M,B&&e.jsx("span",{className:"nice-field__required",children:"*"}),s&&e.jsx(r.NiceKeyboardHint,{shortcuts:N,size:"sm"})]})})),e.jsxs("div",{className:"nice-field__control",children:[e.jsxs("div",{className:"nice-range-slider__stack",children:[e.jsxs("div",{className:`nice-range-slider ${y?"nice-range-slider--with-labels":""} ${M?"nice-range-slider--has-field-label":""}`,ref:L,children:[e.jsx("div",{className:"nice-range-slider__track",children:e.jsx("div",{className:"nice-range-slider__fill",style:{left:`${d(o)}%`,width:`${d(c)-d(o)}%`}})}),e.jsx("div",{className:"nice-range-slider__thumb",style:{left:`${d(o)}%`},onPointerDown:u=>U?void 0:h(u,"start"),onKeyDown:u=>l(u,"start"),role:"slider","aria-label":f("rangeSlider.min","Minimum"),"aria-valuemin":t,"aria-valuemax":c,"aria-valuenow":o,"aria-valuetext":z(o),"aria-disabled":$||void 0,"aria-readonly":U||void 0,tabIndex:$?-1:0,id:E}),e.jsx("div",{className:"nice-range-slider__thumb",style:{left:`${d(c)}%`},onPointerDown:u=>U?void 0:h(u,"end"),onKeyDown:u=>l(u,"end"),role:"slider","aria-label":f("rangeSlider.max","Maximum"),"aria-valuemin":o,"aria-valuemax":i,"aria-valuenow":c,"aria-valuetext":z(c),"aria-disabled":$||void 0,"aria-readonly":U||void 0,tabIndex:$?-1:0})]}),y&&e.jsxs("div",{className:"nice-range-slider__values",children:[e.jsx("span",{className:"nice-range-slider__values-start",style:{left:`${d(o)}%`},children:z(o)}),e.jsx("span",{className:"nice-range-slider__values-end",style:{left:`${d(c)}%`},children:z(c)})]}),P==="bottom"&&e.jsxs("div",{className:"nice-range-slider__value nice-range-slider__value--bottom",children:[z(o)," – ",z(c)]})]}),P==="right"&&R==="left"&&e.jsxs("span",{className:"nice-range-slider__value nice-range-slider__value--inline",children:[z(o)," – ",z(c)]}),ie&&e.jsx("span",{className:"nice-field__spinner",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})}),F==="right"&&W&&e.jsx("div",{className:"nice-field__error",role:"alert",children:W}),F==="right"&&!W&&X&&e.jsx("div",{className:"nice-field__helper",children:X})]}),F!=="right"&&W&&e.jsx("div",{className:"nice-field__error",role:"alert",children:W}),F!=="right"&&!W&&X&&e.jsx("div",{className:"nice-field__helper",children:X})]})},Tn={xxs:36,xs:48,sm:64,md:80,lg:100,xl:128,xxl:160,small:64,medium:80,large:100},ut=6,st=135,an=405,at=an-st;function $t(t,i,a,o){const c=(o-90)*(Math.PI/180);return{x:t+a*Math.cos(c),y:i+a*Math.sin(c)}}function Bt(t,i,a,o,c){const g=$t(t,i,a,o),y=$t(t,i,a,c),T=c-o>180?1:0;return`M ${g.x} ${g.y} A ${a} ${a} 0 ${T} 1 ${y.x} ${y.y}`}const Rn=Object.assign(n.forwardRef(({value:t=0,onChange:i,min:a=0,max:o=100,step:c=1,showValue:g=!0,valueTemplate:y="{value}",label:T,helperText:P,error:M,required:W,disabled:X,readOnly:B,size:$="md",name:U,id:ie,className:ee,style:re,labelPlacement:G="top",errorPlacement:H,labelWidth:w,controlWidth:s,loading:R,isLabelCentered:F=!0,...A},k)=>{const x=r.useControlId(ie),C=n.useRef(!1),f=n.useRef(null),E=typeof $=="number"?$:Tn[$],L=E/2,N=E/2,d=(E-ut*2)/2,z=o>a?(t-a)/(o-a):0,b=st+z*at,h=n.useCallback(m=>{let D=m-st;D<0&&(D+=360),D>at&&(D=D-at<360-D?at:0);const O=Math.max(0,Math.min(1,D/at)),V=a+O*(o-a),v=Math.round(V/c)*c;return Math.max(a,Math.min(o,v))},[a,o,c]),l=n.useCallback(m=>{if(X||B)return;const D=f.current;if(!D)return;const O=D.getBoundingClientRect(),V=m.clientX-O.left-O.width/2,v=m.clientY-O.top-O.height/2;let q=Math.atan2(V,-v)*(180/Math.PI);q<0&&(q+=360);const K=h(q);i?.(K)},[h,X,B,i]);n.useEffect(()=>{const m=O=>{C.current&&l(O)},D=()=>{C.current=!1};return window.addEventListener("pointermove",m),window.addEventListener("pointerup",D),()=>{window.removeEventListener("pointermove",m),window.removeEventListener("pointerup",D)}},[l]);const u=n.useCallback(m=>{if(X||B)return;let D=t;const O=Math.max(c,(o-a)/10);m.key==="ArrowUp"||m.key==="ArrowRight"?(m.preventDefault(),D=Math.min(o,t+c)):m.key==="ArrowDown"||m.key==="ArrowLeft"?(m.preventDefault(),D=Math.max(a,t-c)):m.key==="PageUp"||m.key==="PageDown"?(m.preventDefault(),D=Math.max(a,Math.min(o,t+(m.key==="PageUp"?O:-O)))):(m.key==="Home"||m.key==="End")&&(m.preventDefault(),D=m.key==="Home"?a:o),D!==t&&i?.(D)},[t,i,a,o,c,X,B]),_=(y||"{value}").replace("{value}",String(t)),S=$t(L,N,d,b);return e.jsxs("div",{className:`nice-field nice-knob-field nice-knob-field--err-${H||"bottom"} nice-field--${typeof $=="string"?$:"md"} ${R?"nice-field--loading":""} ${ee||""}`,style:{...re,...w!=null&&{"--nice-field-label-width":typeof w=="number"?`${w}px`:w},...s!=null&&{"--nice-field-control-width":typeof s=="number"?`${s}px`:s}},"aria-busy":R||void 0,...A,children:[e.jsxs("div",{className:`nice-knob-field__inner nice-knob-field--${G} ${F?"nice-knob-field--label-centered":""}`,children:[T&&e.jsx("label",{htmlFor:x,className:`nice-field__label ${W?"nice-field__label--required":""}`,children:T}),e.jsx("div",{className:"nice-field__control",children:e.jsxs("div",{ref:m=>{f.current=m,typeof k=="function"?k(m):k&&(k.current=m)},className:`nice-knob nice-knob--${$} ${X?"nice-knob--disabled":""} ${M?"nice-knob--error":""}`,role:"slider",id:x,tabIndex:X?-1:0,"aria-valuenow":t,"aria-valuemin":a,"aria-valuemax":o,"aria-disabled":X,"aria-invalid":!!M,onPointerDown:m=>{X||B||(C.current=!0,l(m))},onKeyDown:u,children:[e.jsxs("svg",{width:E,height:E,viewBox:`0 0 ${E} ${E}`,children:[e.jsx("path",{d:Bt(L,N,d,st,an),fill:"none",stroke:"var(--nice-border-color, #d1d5db)",strokeWidth:ut,strokeLinecap:"round"}),z>0&&e.jsx("path",{d:Bt(L,N,d,st,b),fill:"none",stroke:"var(--nice-primary, #3b82f6)",strokeWidth:ut,strokeLinecap:"round"}),e.jsx("circle",{cx:S.x,cy:S.y,r:ut,fill:"var(--nice-primary, #3b82f6)"})]}),g&&e.jsx("span",{className:"nice-knob__value",children:_}),U&&e.jsx("input",{type:"hidden",name:U,value:t}),R&&e.jsx("span",{className:"nice-knob__spinner","aria-hidden":"true",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})})]})})]}),M&&e.jsx("div",{className:"nice-field__error",role:"alert",children:M}),!M&&P&&e.jsx("div",{className:"nice-field__helper",children:P})]})}),{displayName:"NiceKnob"}),An=({options:t,value:i,defaultValue:a,onChange:o,searchable:c=!0,clearable:g,loading:y,placeholder:T,label:P,error:M,helperText:W,required:X,disabled:B,readOnly:$,size:U="md",id:ie,className:ee,style:re,data:G,columns:H,valueField:w="id",displayField:s,dropdownWidth:R,menuGap:F,labelPlacement:A,errorPlacement:k,labelWidth:x,controlWidth:C})=>{const f=B||$||y,E=r.useControlId(ie),{t:L}=r.useNiceTranslation(),[N,d]=r.useControllableState({value:i,defaultValue:a,fallbackValue:"",onChange:o,componentName:"NiceLookup"}),[z,b]=n.useState(!1),[h,l]=n.useState(""),u=n.useRef(null),_=n.useRef(null),{popupRef:S,coords:m,ready:D,themeClass:O,portalTarget:V}=We.useAnchoredPopup(z,_,()=>b(!1)),v=!!(G&&H&&H.length>0),q=s??(H&&H[0]?.key),K=n.useMemo(()=>!v||!G?[]:G.map(ae=>({value:String(ae[w]??""),label:q?String(ae[q]??""):""})),[v,G,w,q]),de=n.useMemo(()=>v?K:t??[],[v,K,t]),he=de.find(ae=>String(ae.value)===N),be=n.useMemo(()=>{if(!v||!G)return[];if(!h)return G;const ae=h.toLowerCase();return G.filter(ue=>H.some(I=>String(ue[I.key]??"").toLowerCase().includes(ae)))},[v,G,H,h]),ge=n.useMemo(()=>{if(v||!h)return de;const ae=h.toLowerCase();return de.filter(ue=>ue.label.toLowerCase().includes(ae))},[de,h,v]),fe=v?be:ge,{activeIndex:me,setActiveIndex:pe,handleKeyDown:te}=lt.useListKeyboardNav(fe,{open:z,onSelect:ae=>{const ue=String(v?ae[w]??"":ae.value);d(ue),b(!1),l("")},onClose:()=>b(!1),onOpen:()=>!f&&b(!0),intentRef:S}),_e=`${n.useId()}-listbox`,ne=ae=>`${_e}-opt-${ae}`,we=z&&fe.length>0?ne(me):void 0;return n.useLayoutEffect(()=>{we&&document.getElementById(we)?.scrollIntoView?.({block:"nearest"})},[we]),e.jsxs("div",{className:`nice-field nice-field--lookup nice-field--${U} ${M?"nice-field--error":""} ${A==="left"?"nice-field--label-left":""} ${k==="right"&&(M||W)?"nice-field--error-right":""} ${y?"nice-field--loading":""} ${B?"nice-field--disabled":""} ${ee||""}`,style:{...C!=null&&{"--nice-field-control-width":typeof C=="number"?`${C}px`:C},...x!=null&&{"--nice-field-label-width":typeof x=="number"?`${x}px`:x},...F!=null&&{"--nice-dropdown-gap":`${F}px`},...re},"aria-busy":y||void 0,ref:u,children:[P&&e.jsxs("label",{className:"nice-field__label",htmlFor:E,children:[P,X&&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:_,children:[e.jsxs("button",{type:"button",id:E,className:`nice-select__trigger ${B?"nice-select__trigger--disabled":""}`,onClick:()=>!f&&b(!z),onKeyDown:te,disabled:B,"aria-readonly":$||void 0,role:"combobox","aria-haspopup":"listbox","aria-expanded":z,"aria-controls":z?_e:void 0,"aria-activedescendant":c?void 0:we,children:[e.jsx("span",{children:he?.label||T||L("controls.select","Select...")}),e.jsxs("span",{style:{display:"flex",alignItems:"center",gap:4},children:[g&&N&&!B&&!$&&e.jsx("span",{onKeyDown:r.clickOnActivationKey,className:"nice-input__clear",role:"button",tabIndex:0,"aria-label":L("controls.clear","Clear"),onClick:ae=>{ae.stopPropagation(),d("")},children:e.jsx(r.NiceIcon,{name:"close",size:14})}),e.jsx("span",{className:`nice-select__arrow${$?" nice-select__arrow--hidden":""}`,children:e.jsx(r.NiceIcon,{name:"chevron-down",size:16})})]})]}),z&&m&&V&&nt.createPortal(e.jsxs("div",{ref:S,className:`nice-dropdown nice-lookup__dropdown${O?` ${O}`:""}`,"data-theme":O==="nice-dark"?"dark":O==="nice-light"?"light":void 0,style:{position:"fixed",top:m.top,left:m.left,zIndex:1e3,marginTop:"var(--nice-dropdown-gap, 0px)",background:"var(--nice-bg-primary)",border:"1px solid var(--nice-border-color)",borderRadius:"var(--nice-radius-md)",boxShadow:"0 4px 16px var(--nice-overlay-15, rgba(0, 0, 0, 0.15))",minWidth:m.width,width:R!=null?typeof R=="number"?`${R}px`:R:v?"max-content":m.width,opacity:D?1:0,pointerEvents:D?void 0:"none"},children:[c&&e.jsx("div",{className:"nice-dropdown__search",style:{padding:6},children:e.jsx("input",{type:"text",value:h,onChange:ae=>{l(ae.target.value),pe(0)},onKeyDown:te,placeholder:L("controls.search","Search..."),"aria-label":L("controls.search","Search..."),"aria-controls":_e,"aria-activedescendant":we,"aria-autocomplete":"list",autoFocus:!0,style:{width:"100%",padding:"4px 8px",border:"1px solid var(--nice-border-color)",borderRadius:4,background:"var(--nice-bg-primary)",color:"var(--nice-text-primary)"}})}),v?e.jsxs("table",{className:"nice-lookup__grid",role:"listbox",id:_e,style:{width:"100%",borderCollapse:"collapse",color:"var(--nice-text-primary)"},children:[e.jsx("thead",{children:e.jsx("tr",{children:H.map(ae=>e.jsx("th",{style:{padding:"6px 10px",textAlign:"left",fontSize:12,fontWeight:600,color:"var(--nice-text-secondary)",background:"var(--nice-bg-secondary)",borderBottom:"1px solid var(--nice-border-color)",width:ae.width!=null?typeof ae.width=="number"?`${ae.width}px`:ae.width:void 0},children:ae.header},ae.key))})}),e.jsx("tbody",{children:be.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:H.length,style:{padding:12,textAlign:"center",color:"var(--nice-text-muted)"},children:L("controls.noResults","No results")})}):be.map((ae,ue)=>{const I=String(ae[w]??""),Y=I===N,le=ue===me;return e.jsx("tr",{id:ne(ue),role:"option","aria-selected":Y,onClick:()=>{d(I),b(!1),l("")},style:{cursor:"pointer",background:Y||le?"var(--nice-hover-bg)":"transparent"},onMouseEnter:()=>pe(ue),children:H.map(j=>e.jsx("td",{style:{padding:"6px 10px",fontSize:13,borderBottom:"1px solid var(--nice-border-color)"},children:String(ae[j.key]??"")},j.key))},I)})})]}):e.jsx("ul",{className:"nice-dropdown__list",role:"listbox",id:_e,style:{listStyle:"none",margin:0,padding:4,maxHeight:240,overflowY:"auto",position:"static",background:"transparent",border:"none",borderRadius:0,boxShadow:"none"},children:ge.length===0?e.jsx("li",{className:"nice-dropdown__empty",style:{padding:8,color:"var(--nice-text-muted)"},children:L("controls.noResults","No results")}):ge.map((ae,ue)=>e.jsx("li",{id:ne(ue),role:"option",className:`nice-dropdown__option ${String(ae.value)===N?"nice-dropdown__option--selected":""} ${ue===me?"nice-dropdown__option--active":""}`,onClick:()=>{d(String(ae.value)),b(!1),l("")},onMouseEnter:()=>pe(ue),"aria-selected":String(ae.value)===N,children:ae.label},String(ae.value)))})]}),V)]}),y&&e.jsx("span",{className:"nice-field__spinner",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})}),k==="right"&&M&&e.jsx("div",{className:"nice-field__error",role:"alert",children:M}),k==="right"&&!M&&W&&e.jsx("div",{className:"nice-field__hint",children:W})]}),k!=="right"&&M&&e.jsx("div",{className:"nice-field__error",children:M}),k!=="right"&&!M&&W&&e.jsx("div",{className:"nice-field__hint",children:W})]})},Dn=[];function Ht(t){const i=[],a=o=>{for(const c of o)i.push(c),c.children&&a(c.children)};return a(t),i}function sn(t,i){const a=i.toLowerCase();return t.reduce((o,c)=>{const g=c.children?sn(c.children,i):[];return(c.label.toLowerCase().includes(a)||g.length>0)&&o.push({...c,children:g.length>0?g:c.children}),o},[])}const rn=({node:t,level:i,selectedKeys:a,expandedKeys:o,onToggleExpand:c,onSelect:g,selectableLeafsOnly:y,maxDepth:T})=>{const{t:P}=r.useNiceTranslation(),M=typeof T=="number"?Math.min(10,Math.max(1,T)):1/0,X=!(i+1>=M)&&t.children&&t.children.length>0,B=o.has(t.key),$=a.has(t.key),U=!X,ie=!t.disabled&&(!y||U),ee=Math.min(i+1,10),re={paddingLeft:i*16+14,"--nice-row-bg":`var(--nice-tree-level-${ee}-bg, transparent)`,"--nice-row-text":`var(--nice-tree-level-${ee}-text, inherit)`,"--nice-row-hover-bg":`var(--nice-tree-level-${ee}-hover-bg, var(--nice-bg-secondary, #f3f4f6))`,"--nice-row-active-bg":`var(--nice-tree-level-${ee}-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:re,"data-nice-depth":ee,onClick:()=>{t.disabled||(X?c(t.key):ie&&g(t.key))},role:"treeitem","aria-level":i+1,"aria-selected":$,"aria-expanded":X?B:void 0,"aria-disabled":t.disabled,"data-key":String(t.key),children:[X?e.jsx("button",{type:"button",className:"nice-tree-select__toggle-btn",tabIndex:-1,onClick:G=>{G.stopPropagation(),c(t.key)},"aria-label":P("controls.toggle","Toggle"),children:e.jsx(r.NiceIcon,{name:"chevron-right",size:12,style:{transform:B?"rotate(90deg)":"none",transition:"transform 0.15s"}})}):e.jsx("span",{style:{width:12,display:"inline-block"}}),e.jsx("span",{className:"nice-tree-select__node-label",children:t.label})]}),X&&B&&t.children.map(G=>e.jsx(rn,{node:G,level:i+1,selectedKeys:a,expandedKeys:o,onToggleExpand:c,onSelect:g,selectableLeafsOnly:y,maxDepth:T},G.key))]})},zn=Object.assign(n.forwardRef(({nodes:t=Dn,value:i,onChange:a,multiple:o=!1,searchable:c=!1,placeholder:g,selectableLeafsOnly:y=!1,clearable:T=!1,maxDepth:P,label:M,helperText:W,error:X,required:B,disabled:$,readOnly:U,size:ie="md",name:ee,id:re,className:G,style:H,controlWidth:w,menuGap:s,labelPlacement:R,errorPlacement:F,labelWidth:A,...k},x)=>{const{t:C}=r.useNiceTranslation(),f=r.useControlId(re),[E,L]=n.useState(!1),[N,d]=n.useState(""),[z,b]=n.useState(new Set),h=n.useRef(null),{popupRef:l,coords:u,ready:_,themeClass:S,portalTarget:m}=We.useAnchoredPopup(E,h,()=>L(!1)),D=n.useMemo(()=>i==null?new Set:new Set(Array.isArray(i)?i:[i]),[i]),O=n.useMemo(()=>N?sn(t,N):t,[t,N]),V=n.useMemo(()=>{const fe=Ht(t);return Array.from(D).map(me=>fe.find(pe=>pe.key===me)?.label).filter(Boolean)},[D,t]),v=n.useCallback(fe=>{b(me=>{const pe=new Set(me);return pe.has(fe)?pe.delete(fe):pe.add(fe),pe})},[]),q=n.useCallback(fe=>{if(o){const me=new Set(D);me.has(fe)?me.delete(fe):me.add(fe),a?.(Array.from(me))}else a?.(fe),L(!1)},[o,D,a]),K=n.useCallback(fe=>{fe.stopPropagation(),a?.(o?[]:"")},[a,o]),de=n.useRef(null),he=`${f}-tree`;r.useTreeFocus(de,{onToggle:(fe,me)=>{const pe=Ht(O).find(te=>String(te.key)===fe.dataset.key);pe&&z.has(pe.key)!==me&&v(pe.key)}});const be=n.useCallback(()=>(de.current?.querySelector('[role="treeitem"][tabindex="0"]')??de.current?.querySelector('[role="treeitem"]'))?.focus(),[]),ge=!!u;return n.useEffect(()=>{E&&ge&&!c&&be()},[E,ge,c,be]),e.jsxs("div",{className:`nice-field nice-field--${ie}${R?` nice-field--label-${R}`:""}${F==="right"?" nice-field--error-right":""} ${G||""}`,style:{width:"fit-content",maxWidth:"100%",...s!=null&&{"--nice-dropdown-gap":`${s}px`},...A!=null&&{"--nice-field-label-width":typeof A=="number"?`${A}px`:A},...H},...k,children:[M&&e.jsx("label",{htmlFor:f,className:`nice-field__label ${B?"nice-field__label--required":""}`,children:M}),e.jsxs("div",{ref:h,className:"nice-tree-select",style:{position:"relative",width:w!=null&&w!==""?typeof w=="number"?`${w}px`:w:"var(--nice-field-control-width, 220px)"},children:[e.jsxs("div",{ref:x,id:f,className:`nice-input nice-input--${ie} ${X?"nice-input--error":""} ${$?"nice-input--disabled":""} ${U?"nice-input--readonly":""}`,role:"combobox","aria-expanded":E,"aria-haspopup":"tree","aria-controls":E?he:void 0,"aria-invalid":!!X,tabIndex:$?-1:0,onClick:()=>!$&&!U&&L(!E),onKeyDown:fe=>{(fe.key==="Enter"||fe.key===" "||fe.key==="ArrowDown"||fe.key==="ArrowUp")&&!$&&!U&&(fe.preventDefault(),E?be():L(!0))},children:[e.jsx("span",{className:"nice-tree-select__display",children:V.length>0?V.join(", "):e.jsx("span",{className:"nice-tree-select__placeholder",children:g??C("controls.select","Select...")})}),T&&D.size>0&&e.jsx("button",{type:"button",className:"nice-input__clear",onClick:K,"aria-label":C("controls.clear","Clear"),children:e.jsx(r.NiceIcon,{name:"close",size:14})}),e.jsx("span",{className:"nice-tree-select__arrow",style:{transform:E?"rotate(180deg)":"none",transition:"transform 0.15s"},children:e.jsx(r.NiceIcon,{name:"chevron-down",size:14})})]}),E&&u&&m&&nt.createPortal(e.jsxs("div",{ref:l,className:`nice-tree-select__dropdown${S?` ${S}`:""}`,"data-theme":S==="nice-dark"?"dark":S==="nice-light"?"light":void 0,style:{position:"fixed",left:u.left,top:u.top,width:u.width,minWidth:u.width,zIndex:1e3,opacity:_?1:0,pointerEvents:_?void 0:"none"},children:[c&&e.jsx("div",{className:"nice-select__search",onClick:fe=>fe.stopPropagation(),role:"presentation",children:e.jsx("input",{type:"text",placeholder:C("controls.search","Search..."),"aria-label":C("controls.search","Search..."),"aria-controls":he,value:N,onChange:fe=>d(fe.target.value),onKeyDown:fe=>{fe.key==="ArrowDown"&&(fe.preventDefault(),be())},autoFocus:!0})}),e.jsx("div",{ref:de,id:he,className:"nice-tree-select__list",role:"tree","aria-label":M||g||C("controls.select","Select..."),"aria-multiselectable":o||void 0,children:O.length===0?e.jsx("div",{className:"nice-tree-select__empty",children:C("controls.noResults","No results")}):O.map(fe=>e.jsx(rn,{node:fe,level:0,selectedKeys:D,expandedKeys:z,onToggleExpand:v,onSelect:q,selectableLeafsOnly:y,maxDepth:P},fe.key))})]}),m)]}),ee&&e.jsx("input",{type:"hidden",name:ee,value:Array.isArray(i)?i.join(","):i??""}),X&&e.jsx("div",{id:`${f}-error`,className:"nice-field__error",role:"alert",children:X}),!X&&W&&e.jsx("div",{id:`${f}-helper`,className:"nice-field__helper",children:W})]})}),{displayName:"NiceTreeSelect"}),Ln=({displayValue:t,placeholder:i,clearable:a,children:o,onClear:c,open:g,onOpenChange:y,dropdownWidth:T,searchable:P=!0,onSearch:M,searchPlaceholder:W,label:X,error:B,helperText:$,required:U,disabled:ie,size:ee="md",id:re,className:G,style:H,accessMode:w,showKeyboardHints:s,displayStyle:R})=>{r.useComponentDisplayStyle("input",R),r.useComponentDisplayClass("input",R);const F=r.useNiceAccessMode(w,re),A=F==="hidden";(F==="disabled"||F==="readOnly")&&(ie=!0);const k=r.useControlId(re),{t:x}=r.useNiceTranslation(),[C,f]=n.useState(!1),[E,L]=n.useState(""),N=n.useRef(null),d=n.useRef(null),z=g??C,b=n.useMemo(()=>[{key:"Enter",description:x("shortcuts.openDropdown","Open dropdown")},r.COMMON_SHORTCUTS.cancel],[x]),h=D=>{y?y(D):f(D)},{popupRef:l,coords:u,ready:_,themeClass:S,portalTarget:m}=We.useAnchoredPopup(z,d,()=>h(!1));return A?null:e.jsxs("div",{className:`nice-field nice-field--${ee} ${B?"nice-field--error":""} ${G||""}`,style:H,ref:N,children:[X&&e.jsxs("label",{className:"nice-field__label",htmlFor:k,children:[X,U&&e.jsx("span",{className:"nice-field__required",children:"*"}),s&&e.jsx(r.NiceKeyboardHint,{shortcuts:b,size:"sm"})]}),e.jsxs("div",{className:"nice-field__input-wrap",ref:d,children:[e.jsxs("button",{type:"button",id:k,className:"nice-select__trigger",onClick:()=>!ie&&h(!z),disabled:ie,children:[e.jsx("span",{children:t||i||x("controls.select","Select...")}),e.jsxs("span",{style:{display:"flex",alignItems:"center",gap:4},children:[a&&t&&!ie&&e.jsx("span",{className:"nice-input__clear",role:"button",tabIndex:0,"aria-label":x("controls.clear","Clear"),onClick:D=>{D.stopPropagation(),c?.()},onKeyDown:D=>{(D.key==="Enter"||D.key===" ")&&(D.preventDefault(),D.stopPropagation(),c?.())},children:e.jsx(r.NiceIcon,{name:"close",size:14})}),e.jsx("span",{className:"nice-select__arrow",children:e.jsx(r.NiceIcon,{name:"chevron-down",size:16})})]})]}),z&&u&&m&&nt.createPortal(e.jsxs("div",{ref:l,className:`nice-dropdown${S?` ${S}`:""}`,"data-theme":S==="nice-dark"?"dark":S==="nice-light"?"light":void 0,style:{position:"fixed",left:u.left,top:u.top,width:T??u.width,minWidth:T??u.width,zIndex:1e3,maxHeight:320,overflowY:"auto",opacity:_?1:0,pointerEvents:_?void 0:"none"},children:[P&&M&&e.jsx("div",{className:"nice-select__search",children:e.jsx("input",{type:"text",value:E,onChange:D=>{L(D.target.value),M(D.target.value)},placeholder:W??x("controls.search","Search..."),autoFocus:!0})}),o]}),m)]}),B&&e.jsx("div",{className:"nice-field__error",children:B}),$&&!B&&e.jsx("div",{className:"nice-field__hint",children:$})]})},Pn=[],On=[];function Ve(t,i){return String(t[i])}const Bn={xxs:10,xs:12,sm:12,md:14,lg:18,xl:22,xxl:26},Hn=Object.assign(n.forwardRef(({source:t=Pn,target:i=On,onChange:a,keyField:o="id",labelField:c="label",renderItem:g,filterable:y=!1,searchable:T,groupBy:P,sortable:M=!1,bulkActions:W=!0,maxRight:X,sourceHeader:B,targetHeader:$,disabled:U=!1,size:ie="md",className:ee,style:re,id:G,...H},w)=>{const{t:s}=r.useNiceTranslation(),R=Bn[ie]??14,[F,A]=n.useState(new Set),[k,x]=n.useState(new Set),[C,f]=n.useState(""),[E,L]=n.useState(""),[N,d]=n.useState(null),z=n.useRef(null),b=n.useRef(null),h={orientation:"vertical",typeahead:!0,pageSize:10};r.useRovingFocus(z,h),r.useRovingFocus(b,h);const l=n.useCallback((v,q,K)=>{q(de=>{const he=new Set(de);return he.has(K)?he.delete(K):he.add(K),he})},[]),u=n.useCallback(()=>{const v=t.filter(he=>F.has(Ve(he,o))),q=t.filter(he=>!F.has(Ve(he,o))),K=typeof X=="number"?v.slice(0,Math.max(0,X-i.length)):v,de=v.slice(K.length);a([...q,...de],[...i,...K]),A(new Set)},[t,i,F,o,a,X]),_=n.useCallback(()=>{const v=i.filter(K=>k.has(Ve(K,o))),q=i.filter(K=>!k.has(Ve(K,o)));a([...t,...v],q),x(new Set)},[t,i,k,o,a]),S=n.useCallback(()=>{if(typeof X=="number"){const v=Math.max(0,X-i.length),q=t.slice(0,v),K=t.slice(v);a(K,[...i,...q])}else a([],[...i,...t]);A(new Set)},[t,i,a,X]),m=n.useCallback(()=>{a([...t,...i],[]),x(new Set)},[t,i,a]),D=(v,q)=>{if(!q)return v;const K=q.toLowerCase();return v.filter(de=>String(de[c]).toLowerCase().includes(K))},O=W===!1?{moveAll:!1,removeAll:!1}:W===!0||W===void 0?{moveAll:!0,removeAll:!0}:{moveAll:W.moveAll??!0,removeAll:W.removeAll??!0},V=(v,q,K,de,he,be,ge,fe)=>{let me=D(v,de);M||(me=[...me].sort((ae,ue)=>String(ae[c]).localeCompare(String(ue[c]),void 0,{numeric:!0,sensitivity:"base"})));const pe=T===!0||y&&T===void 0?"both":T??!1,te=pe==="both"||pe==="left"&&ge==="left"||pe==="right"&&ge==="right",ve=(()=>{if(!P)return[{label:"",items:me}];const ae=new Map;for(const ue of me){const I=String(P(ue));let Y=ae.get(I);Y||(Y=[],ae.set(I,Y)),Y.push(ue)}return[...ae.entries()].map(([ue,I])=>({label:ue,items:I}))})(),_e=(ae,ue)=>{ae.dataTransfer.setData("text/plain",ue),ae.dataTransfer.effectAllowed="move"},ne=(ae,ue)=>{if(ae.preventDefault(),!M)return;const I=ae.currentTarget.getBoundingClientRect(),Y=ae.clientY<I.top+I.height/2;d(le=>le&&le.side===ge&&le.key===ue&&le.before===Y?le:{side:ge,key:ue,before:Y})},we=(ae,ue)=>{ae.preventDefault();const I=N?.before??!1;d(null);const Y=ae.dataTransfer.getData("text/plain");if(!Y||!M)return;const j=[...ge==="right"?i:t],Z=j.findIndex(xe=>Ve(xe,o)===Y),oe=j.findIndex(xe=>Ve(xe,o)===ue);if(Z===-1||oe===-1||Y===ue)return;let se=I?oe:oe+1;const[ye]=j.splice(Z,1);Z<se&&(se-=1),j.splice(se,0,ye),a(ge==="right"?t:j,ge==="right"?j:i)};return e.jsxs("div",{className:"nice-picklist__panel",children:[be&&e.jsx("div",{className:"nice-picklist__header",children:be}),te&&e.jsx("div",{className:"nice-picklist__filter",children:e.jsx("input",{className:"nice-input__native",type:"text",size:1,placeholder:s("controls.search","Search..."),value:de,onChange:ae=>he(ae.target.value)})}),e.jsxs("div",{className:"nice-picklist__list",role:"listbox","aria-multiselectable":"true","aria-label":typeof be=="string"?be:void 0,ref:fe,children:[ve.map(ae=>e.jsxs(n.Fragment,{children:[ae.label&&e.jsx("div",{className:"nice-picklist__group-header",role:"presentation",children:ae.label}),ae.items.map(ue=>{const I=Ve(ue,o),Y=q.has(I),j=N&&N.side===ge&&N.key===I?N.before?"nice-picklist__item--drop-before":"nice-picklist__item--drop-after":"";return e.jsxs("div",{className:`nice-picklist__item ${Y?"nice-picklist__item--selected":""} ${j}`,role:"option","aria-selected":Y,draggable:M,onDragStart:M?Z=>_e(Z,I):void 0,onDragOver:M?Z=>ne(Z,I):void 0,onDrop:M?Z=>we(Z,I):void 0,onDragEnd:M?()=>d(null):void 0,onClick:()=>!U&&l(q,K,I),onKeyDown:Z=>{(Z.key===" "||Z.key==="Enter")&&(Z.preventDefault(),U||l(q,K,I))},children:[M&&e.jsx("span",{className:"nice-picklist__drag-handle","aria-hidden":"true",children:e.jsx(r.NiceIcon,{name:"grip",size:R})}),g?g(ue,ge):String(ue[c])]},I)})]},ae.label||"__none__")),me.length===0&&e.jsx("div",{className:"nice-picklist__empty",children:s("controls.noItems","No items")})]})]})};return e.jsxs("div",{ref:w,id:G,className:`nice-picklist nice-picklist--${ie} ${U?"nice-picklist--disabled":""} ${ee||""}`,style:re,...H,children:[V(t,F,A,C,f,B??s("picklist.source","Available"),"left",z),e.jsxs("div",{className:"nice-picklist__controls",children:[e.jsx("button",{type:"button",className:`nice-btn nice-btn--outline nice-btn--${ie}`,disabled:U||F.size===0,onClick:u,"aria-label":s("picklist.moveRight","Move right"),children:e.jsx(r.NiceIcon,{name:"chevron-right",size:R})}),O.moveAll&&e.jsx("button",{type:"button",className:`nice-btn nice-btn--outline nice-btn--${ie}`,disabled:U||t.length===0,onClick:S,"aria-label":s("picklist.moveAllRight","Move all right"),children:e.jsx(r.NiceIcon,{name:"chevrons-right",size:R})}),e.jsx("button",{type:"button",className:`nice-btn nice-btn--outline nice-btn--${ie}`,disabled:U||k.size===0,onClick:_,"aria-label":s("picklist.moveLeft","Move left"),children:e.jsx(r.NiceIcon,{name:"chevron-left",size:R})}),O.removeAll&&e.jsx("button",{type:"button",className:`nice-btn nice-btn--outline nice-btn--${ie}`,disabled:U||i.length===0,onClick:m,"aria-label":s("picklist.moveAllLeft","Move all left"),children:e.jsx(r.NiceIcon,{name:"chevrons-left",size:R})})]}),V(i,k,x,E,L,$??s("picklist.target","Selected"),"right",b)]})}),{displayName:"NicePickList"});function Tt(t){return t?.startsWith("datetime")?"datetime":t==="week"?"week":t?.startsWith("month")?"month":"date"}function Fn(t){const i=new Date,a=`${i.getFullYear()}-${String(i.getMonth()+1).padStart(2,"0")}-${String(i.getDate()).padStart(2,"0")}`,o=Tt(t);return o==="datetime"?`${a}T00:00`:o==="month"?a.slice(0,7):a}function Ft(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 pt(...t){return t.filter(Boolean).sort().pop()}function Nt(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 c=Tt(a);return c==="month"?o.toLocaleDateString(i,{year:"numeric",month:"2-digit"}):c==="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 Kt(t){let i=0;for(const a of t)i+=/[\p{L}\p{N}]/u.test(a)?1:.5;return i}const Kn=({startDate:t,endDate:i,defaultStartDate:a,defaultEndDate:o,onStartChange:c,onEndChange:g,min:y,max:T,clearable:P,startPlaceholder:M,endPlaceholder:W,startLabel:X,endLabel:B,layout:$="horizontal",separator:U="–",gap:ie=12,fullWidth:ee=!1,dateFormatPreset:re,locale:G,timeSelectorType:H,endCondition:w="greater-or-equal",startCondition:s="today-or-greater",singleField:R=!1,label:F,error:A,helperText:k,required:x,disabled:C,size:f="md",id:E,className:L,style:N,accessMode:d,showKeyboardHints:z,labelPlacement:b,errorPlacement:h,labelWidth:l,controlWidth:u,loading:_,readOnly:S})=>{const m=r.useNiceAccessMode(d,E),D=r.useControlId(E),{t:O}=r.useNiceTranslation(),V=m==="disabled"||m==="readOnly"||!!C,[v,q]=r.useControllableState({value:t,defaultValue:a,fallbackValue:"",onChange:c,componentName:"NiceDateRangeBox"}),[K,de]=r.useControllableState({value:i,defaultValue:o,fallbackValue:"",onChange:g,componentName:"NiceDateRangeBox"}),he=n.useMemo(()=>[{key:"Tab",description:O("shortcuts.switchField","Switch between start/end")},r.COMMON_SHORTCUTS.cancel],[O]),be=n.useRef(null),ge=n.useRef(null),[fe,me]=n.useState(!1),[pe,te]=n.useState(null),[ve,_e]=n.useState(""),we=n.useContext(r.NiceThemeContext)?.portalTarget??(typeof document<"u"?document.body:null);n.useLayoutEffect(()=>{if(!fe)return;const Ce=be.current?.getBoundingClientRect();Ce&&(te({left:Ce.left,top:Ce.bottom+6}),_e(Je.scopeThemeClass(be.current)))},[fe]),n.useEffect(()=>{if(!fe)return;const Ce=Be=>{const $e=Be.target;be.current?.contains($e)||ge.current?.contains($e)||me(!1)},Ne=()=>{const Be=be.current?.getBoundingClientRect();Be&&te({left:Be.left,top:Be.bottom+6})};return document.addEventListener("mousedown",Ce),window.addEventListener("scroll",Ne,!0),window.addEventListener("resize",Ne),()=>{document.removeEventListener("mousedown",Ce),window.removeEventListener("scroll",Ne,!0),window.removeEventListener("resize",Ne)}},[fe]),r.useOverlayFocus(ge,{open:fe,modal:!1,initialFocus:'.nice-calendar__grid [tabindex="0"]',onClose:()=>me(!1)});const ae=Fn(re),ue=s==="today-or-greater"?pt(y,ae):s==="greater-than-today"?pt(y,Ft(ae,1)):y,I=w==="greater-or-equal"?pt(y,v):w==="greater"?pt(y,v?Ft(v,1):void 0):y,Y=n.useMemo(()=>{if(A)return A;if(v&&K){if(w==="greater-or-equal"&&K<v)return O("daterange.endBeforeStart","End date must be on or after the start date");if(w==="greater"&&K<=v)return O("daterange.endAfterStart","End date must be after the start date")}if(v){if(s==="today-or-greater"&&v<ae)return O("daterange.startInPast","Start date cannot be in the past");if(s==="greater-than-today"&&v<=ae)return O("daterange.startAfterToday","Start date must be after today")}},[A,v,K,s,w,ae,O]);if(m==="hidden")return null;const le=Ce=>{q(Ce),Ce&&K&&Ce>K&&de(Ce)},j=$==="horizontal",Z=Tt(re),oe=G||mt.getDefaultLocale(),se=typeof U=="string"&&U!==""?U:"–",ye=Nt(v,oe,re),xe=Nt(K,oe,re),Ee=ye||xe?`${ye||"…"} ${se} ${xe||"…"}`:"",ze=(()=>{const Ce=Nt("2026-12-30T22:58",oe,re),Ne=`${Ce} ${se} ${Ce}`;return`${(Math.max(Kt(Ne),Kt(Ee))+1.5).toFixed(1)}ch`})(),Le=(Ce,Ne)=>Z==="datetime"?Ne&&Ne.length>10?`${Ce}${Ne.slice(10)}`:`${Ce}T00:00`:Z==="month"?Ce.slice(0,7):Ce,Ye=({start:Ce,end:Ne})=>{q(Ce?Le(Ce,v):""),de(Ne?Le(Ne,K):""),Ce&&Ne&&me(!1)},Xe=()=>{q(""),de("")},Ke=()=>{!V&&!S&&me(Ce=>!Ce)},He=Ce=>Ce&&Ce.length>=10?Ce.slice(0,10):Ce||void 0;return e.jsxs("div",{className:`nice-field nice-field--${f} nice-daterange nice-daterange--${$} ${b==="left"?"nice-field--label-left":""} ${Y?"nice-field--error":""} ${_?"nice-field--loading":""} ${L||""}`,style:{...N,...l!=null&&{"--nice-field-label-width":typeof l=="number"?`${l}px`:l},...u!=null&&{"--nice-field-control-width":typeof u=="number"?`${u}px`:u}},"aria-busy":_||void 0,children:[F&&e.jsxs("label",{className:"nice-field__label",htmlFor:D,children:[F,x&&e.jsx("span",{className:"nice-field__required",children:"*"}),z&&e.jsx(r.NiceKeyboardHint,{shortcuts:he,size:"sm"})]}),e.jsxs("div",{className:"nice-field__control",children:[R?e.jsxs("div",{ref:be,className:`nice-input nice-input--date nice-input--${f} nice-daterange__single ${Y?"nice-input--error":""} ${V?"nice-input--disabled":""} ${S?"nice-input--readonly":""}`,style:{position:"relative",width:ee?"100%":"fit-content"},children:[e.jsx("input",{id:D,className:"nice-input__native",type:"text",readOnly:!0,value:Ee,placeholder:M||O("controls.startDate","Start date"),disabled:V||_,autoComplete:"off","aria-invalid":!!Y,"aria-label":F?void 0:O("controls.startDate","Start date"),"aria-haspopup":"dialog","aria-expanded":fe,onClick:Ke,onKeyDown:Ce=>{const Ne=!!Ce.nativeEvent.niceSource;(Ce.key==="Enter"||Ce.key===" "||Ce.key==="ArrowDown"&&!Ne)&&(Ce.preventDefault(),fe||Ke())},style:{width:ee?"100%":ze,cursor:V||S?void 0:"pointer"}}),P&&e.jsx("button",{type:"button",className:"nice-input__clear",onClick:Xe,disabled:!v&&!K||V||S,"aria-label":O("controls.clear","Clear"),tabIndex:(v||K)&&!V&&!S?0:-1,children:e.jsx(r.NiceIcon,{name:"close",size:14})}),e.jsx("button",{type:"button",className:"nice-input__picker-trigger",onClick:Ke,"aria-label":O("controls.openPicker","Open picker"),"aria-expanded":fe,tabIndex:-1,disabled:V||S,children:e.jsx(r.NiceIcon,{name:"calendar",size:16})})]}):e.jsxs("div",{className:"nice-daterange__row",style:{display:"flex",flexDirection:j?"row":"column",alignItems:j?b==="left"?"center":"flex-end":"stretch",gap:ie,flexWrap:j?"nowrap":"wrap"},children:[e.jsx("div",{style:{flex:ee?"1 1 0":void 0,minWidth:0},children:e.jsx(mt.NiceDateTimePicker,{id:D,dateFormatPreset:re,displayLocale:G,timeSelectorType:H,label:X,value:v,onChange:le,min:ue,max:K||T,placeholder:M||O("controls.startDate","Start date"),disabled:V,readOnly:S,size:f,clearable:P,labelPlacement:b,labelWidth:l})}),j&&U!==""&&U!=null&&e.jsx("span",{className:"nice-daterange__separator",style:{paddingBottom:8,color:"var(--nice-text-secondary, #666)"},"aria-hidden":"true",children:U}),e.jsx("div",{style:{flex:ee?"1 1 0":void 0,minWidth:0},children:e.jsx(mt.NiceDateTimePicker,{dateFormatPreset:re,displayLocale:G,timeSelectorType:H,label:B,value:K,onChange:Ce=>de(Ce),min:I||v||y,max:T,placeholder:W||O("controls.endDate","End date"),disabled:V,readOnly:S,size:f,clearable:P,labelPlacement:b,labelWidth:l})})]}),R&&fe&&pe&&we&&nt.createPortal(e.jsxs("div",{ref:ge,className:`nice-datetime-popup${ve?` ${ve}`:""}`,style:{position:"fixed",left:pe.left,top:pe.top,zIndex:1e3},role:"dialog","aria-label":O("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(mt.NiceCalendar,{selectionMode:"range",rangeStart:He(v),rangeEnd:He(K),onRangeChange:Ye,min:He(ue),max:He(T),size:f})})}),P&&e.jsx("div",{className:"nice-datetime-popup__footer",children:e.jsx("button",{type:"button",className:"nice-datetime-popup__btn",onClick:Xe,disabled:!v&&!K,children:O("controls.clear","Clear")})})]}),we),_&&e.jsx("span",{className:"nice-field__spinner",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})}),h==="right"&&Y&&e.jsx("div",{className:"nice-field__error",role:"alert",children:Y}),h==="right"&&!Y&&k&&e.jsx("div",{className:"nice-field__helper",children:k})]}),h!=="right"&&Y&&e.jsx("div",{className:"nice-field__error",children:Y}),h!=="right"&&!Y&&k&&e.jsx("div",{className:"nice-field__hint",children:k})]})};function Un(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 Ut(t,i={}){const a=i.size??16,o="currentColor",c="currentColor";if(i.rectangle||t==="shade-chain"||t==="monochromatic"){const X=Math.max(3,Math.min(7,i.count??5)),B=a*.1,$=a-B*2,U=Math.max(1.2,a/14),ie=a/2,ee=Array.from({length:X},(re,G)=>{const H=B+$*G/(X-1),w=.25+.75*G/(X-1);return e.jsx("circle",{cx:H,cy:ie,r:U,fill:c,opacity:w},G)});return e.jsxs("svg",{width:a,height:a,viewBox:`0 0 ${a} ${a}`,"aria-hidden":!0,children:[e.jsx("rect",{x:1,y:a/2-a/6,width:a-2,height:a/3,rx:a/6,fill:"none",stroke:o,strokeOpacity:.25}),ee]})}const y=i.angles??Un(t),T=a/2,P=a/2,M=a/2-2,W=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:T,cy:P,r:M,fill:"none",stroke:o,strokeOpacity:.25}),y.map((X,B)=>{const $=(X-90)*Math.PI/180,U=T+M*Math.cos($),ie=P+M*Math.sin($);return e.jsx("circle",{cx:U,cy:ie,r:W,fill:c},B)})]})}function Yt(t,i,a){return Math.max(i,Math.min(a,t))}function cn({h:t,s:i,v:a}){t=(t%360+360)%360;const o=a*i,c=o*(1-Math.abs(t/60%2-1)),g=a-o;let y=0,T=0,P=0;return t<60?(y=o,T=c):t<120?(y=c,T=o):t<180?(T=o,P=c):t<240?(T=c,P=o):t<300?(y=c,P=o):(y=o,P=c),{r:Math.round((y+g)*255),g:Math.round((T+g)*255),b:Math.round((P+g)*255)}}function Rt({r:t,g:i,b:a}){t/=255,i/=255,a/=255;const o=Math.max(t,i,a),c=Math.min(t,i,a),g=o-c;let y=0;return g!==0&&(o===t?y=(i-a)/g%6:o===i?y=(a-t)/g+2:y=(t-i)/g+4,y=(y*60+360)%360),{h:y,s:o===0?0:g/o,v:o}}function ln({r:t,g:i,b:a}){t/=255,i/=255,a/=255;const o=Math.max(t,i,a),c=Math.min(t,i,a),g=(o+c)/2;if(o===c)return{h:0,s:0,l:g};const y=o-c,T=g>.5?y/(2-o-c):y/(o+c);let P=0;return o===t?P=((i-a)/y+(i<a?6:0))/6:o===i?P=((a-t)/y+2)/6:P=((t-i)/y+4)/6,{h:P*360,s:T,l:g}}function ct(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 dn({r:t,g:i,b:a}){return"#"+[t,i,a].map(o=>o.toString(16).padStart(2,"0")).join("")}function Pe(t){return dn(cn(t))}function Fe(t){return Rt(ct(t))}function mn(t,i){const a=[];for(let o=0;o<i;o++){const c=i<=1?.5:o/(i-1),g=Yt(t.s*(.3+c*.7),0,1),y=Yt(t.v*(1.2-c*.7),0,1);a.push(Pe({h:t.h,s:g,v:y}))}return a}function bt(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 rt(t,i,a){return bt(i,a).map(o=>((t+o)%360+360)%360)}function Xt(t,i,a=.12){const o=Math.max(2,i),c=(o-1)/2,g=[];for(let y=0;y<o;y++){const T=(y-c)*a,P=Math.max(.05,Math.min(.98,t.v+T)),M=Math.max(.05,Math.min(1,t.s-Math.abs(T)*.25));g.push(Pe({h:t.h,s:M,v:P}))}return g}function qt({r:t,g:i,b:a}){const[o,c,g]=[t,i,a].map(y=>{const T=y/255;return T<=.03928?T/12.92:Math.pow((T+.055)/1.055,2.4)});return .2126*o+.7152*c+.0722*g}function gt(t,i){const a=qt(ct(t)),o=qt(ct(i)),c=Math.max(a,o),g=Math.min(a,o);return(c+.05)/(g+.05)}function ft(t){return t>=7?"AAA":t>=4.5?"AA":t>=3?"AA-lg":"Fail"}const un={"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 yt(t,i){const a=un[i];return t.map(o=>{const c=(a.sRange[0]+a.sRange[1])/2,g=(a.vRange[0]+a.vRange[1])/2;return Pe({h:o,s:c,v:g})})}function Yn(){return Math.floor(Math.random()*360)}function pn(t,i,a){const o=Yn(),c=rt(o,t,a),g=[];for(let y=0;y<i;y++){const T=c[y%c.length],P=.55+Math.random()*.4,M=.5+Math.random()*.45;g.push(Pe({h:T+(Math.random()-.5)*8,s:P,v:M}))}return g}const Xn=({hues:t,colors:i,baseHue:a,onBaseHueChange:o,mode:c,distance:g,disabled:y})=>{const{t:T}=r.useNiceTranslation(),P=240,M=P/2,W=P/2,X=110,B=55,$=s=>{if(y)return;const R=s.shiftKey?15:1,F=s.key==="ArrowLeft"||s.key==="ArrowDown"?-R:s.key==="ArrowRight"||s.key==="ArrowUp"?R:s.key==="PageDown"?-15:s.key==="PageUp"?15:null;F!==null?(s.preventDefault(),o(((a+F)%360+360)%360)):(s.key==="Home"||s.key==="End")&&(s.preventDefault(),o(s.key==="Home"?0:359))},U=n.useRef(null),ie=n.useCallback((s,R)=>{const F=U.current;if(!F)return;const A=F.getBoundingClientRect(),k=(s-A.left)/A.width*P-M,x=(R-A.top)/A.height*P-W,C=(Math.atan2(x,k)*180/Math.PI+360)%360;o(Math.round(C))},[M,W,P,o]),ee=n.useCallback(s=>{if(y)return;s.preventDefault(),ie(s.clientX,s.clientY);const R=A=>ie(A.clientX,A.clientY),F=()=>{document.removeEventListener("pointermove",R),document.removeEventListener("pointerup",F)};document.addEventListener("pointermove",R),document.addEventListener("pointerup",F)},[y,ie]),re=[];for(let s=0;s<360;s+=2){const R=(s-1)*Math.PI/180,F=(s+1)*Math.PI/180,A=Pe({h:s,s:1,v:1});re.push(e.jsx("path",{d:`M${M+B*Math.cos(R)},${W+B*Math.sin(R)} L${M+X*Math.cos(R)},${W+X*Math.sin(R)} A${X},${X} 0 0,1 ${M+X*Math.cos(F)},${W+X*Math.sin(F)} L${M+B*Math.cos(F)},${W+B*Math.sin(F)} A${B},${B} 0 0,0 ${M+B*Math.cos(R)},${W+B*Math.sin(R)} Z`,fill:A},s))}const G=`wheel-center-${c}`,H=t.map((s,R)=>{const F=(X+B)/2,A=s*Math.PI/180;return e.jsx("circle",{cx:M+F*Math.cos(A),cy:W+F*Math.sin(A),r:R===0?8:6,fill:i?.[R]??Pe({h:s,s:.85,v:.9}),stroke:R===0?"var(--nice-bg-primary, #fff)":"var(--nice-border-color, #ccc)",strokeWidth:R===0?3:2},R)});let w=null;if(c==="analogous"||c==="split-complementary"||c==="analogous-complementary"){const s=(X+B)/2,F=bt(c,g).slice(1).map((A,k)=>{const x=(a+A)*Math.PI/180;return e.jsx("line",{x1:M,y1:W,x2:M+s*Math.cos(x),y2:W+s*Math.sin(x),stroke:"var(--nice-overlay-light-30, rgba(255, 255, 255, 0.3))",strokeWidth:1,strokeDasharray:"3,3"},`dline-${k}`)});w=e.jsx(e.Fragment,{children:F})}return e.jsxs("svg",{ref:U,className:"nice-palette__wheel",viewBox:`0 0 ${P} ${P}`,width:P,height:P,onPointerDown:ee,onKeyDown:$,role:"slider",tabIndex:y?-1:0,"aria-label":T("colorPalette.baseHue","Base hue"),"aria-valuemin":0,"aria-valuemax":359,"aria-valuenow":Math.round(a),"aria-valuetext":`${Math.round(a)}°`,style:{cursor:y?"default":"crosshair",touchAction:"none"},children:[e.jsx("defs",{children:e.jsxs("radialGradient",{id:G,children:[e.jsx("stop",{offset:"0%",stopColor:"var(--nice-bg, #fff)"}),e.jsx("stop",{offset:"100%",stopColor:"transparent"})]})}),re,e.jsx("circle",{cx:M,cy:W,r:B-2,fill:Pe({h:a,s:.6,v:.85})}),e.jsx("circle",{cx:M,cy:W,r:B-2,fill:`url(#${G})`,opacity:.4}),w,H]})},qn=({colors:t})=>{const{t:i}=r.useNiceTranslation();if(t.length<2)return null;const a=[];for(let o=0;o<t.length;o++){const c=gt(t[o],"var(--nice-bg-primary, #ffffff)"),g=gt(t[o],"var(--nice-text-primary, #000000)");a.push({a:t[o],b:"var(--nice-bg-primary, #ffffff)",ratio:c,level:ft(c)}),a.push({a:t[o],b:"var(--nice-text-primary, #000000)",ratio:g,level:ft(g)});for(let y=o+1;y<t.length;y++){const T=gt(t[o],t[y]);a.push({a:t[o],b:t[y],ratio:T,level:ft(T)})}}return e.jsxs("div",{className:"nice-palette__contrast",children:[e.jsx("div",{className:"nice-palette__section-title",children:i("colorPalette.contrastAnalysisWcag21","Contrast Analysis (WCAG 2.1)")}),e.jsx("div",{className:"nice-palette__contrast-grid",children:a.map((o,c)=>e.jsxs("div",{className:"nice-palette__contrast-pair",children:[e.jsxs("div",{className:"nice-palette__contrast-swatches",children:[e.jsx("span",{className:"nice-palette__contrast-dot",style:{background:o.a}}),e.jsx("span",{className:"nice-palette__contrast-vs",children:i("colorPalette.vs","vs")}),e.jsx("span",{className:"nice-palette__contrast-dot",style:{background:o.b}})]}),e.jsxs("span",{className:"nice-palette__contrast-ratio",children:[o.ratio.toFixed(1),":1"]}),e.jsx("span",{className:`nice-palette__contrast-level nice-palette__contrast-level--${o.level.toLowerCase().replace("-","")}`,children:o.level})]},c))})]})},Gn=({hex:t})=>{const i=ct(t),a=ln(i),o=Rt(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),"%"]})]})},Vn={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"},Wn={"lightest-pastel":"Lightest Pastel","bright-pastel":"Bright Pastel",shiny:"Shiny",pastel:"Pastel",full:"Full Colors",dark:"Dark",deep:"Deep Colors",muted:"Muted",earth:"Earth Tones"},Jn=["monochromatic","shade-chain","complementary","split-complementary","analogous","analogous-complementary","triadic","tetradic","square","custom"],hn=["lightest-pastel","bright-pastel","shiny","pastel","full","dark","deep","muted","earth"],gn="nice-palette-custom-schemes";function Zn(){if(typeof window>"u")return[];try{const t=window.localStorage.getItem(gn);if(!t)return[];const i=JSON.parse(t);if(Array.isArray(i))return i}catch{}return[]}function Qn(t){if(!(typeof window>"u"))try{window.localStorage.setItem(gn,JSON.stringify(t))}catch{}}const ei=Object.assign(n.forwardRef(({id:t,className:i,style:a,accessMode:o,value:c,onChange:g,minColors:y=1,maxColors:T=8,harmonyMode:P,onHarmonyModeChange:M,distance:W,onDistanceChange:X,preset:B,onPresetChange:$,showWheel:U=!0,showContrast:ie=!0,showInfo:ee=!0,showPresets:re=!0,presets:G=[],showVariations:H=!0,showRandom:w=!0,variationCount:s=5,label:R,labelPlacement:F="top",disabled:A,readOnly:k,loading:x,error:C,colorCount:f,shadeStep:E,onShadeStepChange:L,customSchemes:N,onCustomSchemesChange:d,persistCustomSchemes:z=!0,"data-testid":b},h)=>{const l=r.useNiceAccessMode(o,t),u=l==="hidden";l==="disabled"&&(A=!0);const _=k||l==="readOnly",S=r.useControlId(t),{t:m}=r.useNiceTranslation(),D=Je.useNiceDialogs(),[O,V]=n.useState("analogous-complementary"),[v,q]=n.useState(30),[K,de]=n.useState(""),[he,be]=n.useState(0),[ge,fe]=n.useState(.12),[me,pe]=n.useState(null),[te,ve]=n.useState(()=>N??(z?Zn():[])),[_e,ne]=n.useState(null),[we,ae]=n.useState(!1),[ue,I]=n.useState(null),[Y,le]=n.useState(""),Z=n.useContext(r.NiceThemeContext)?.portalTarget??(typeof document<"u"?document.body:null),oe=n.useRef(null),se=n.useRef(null),ye=P??O,xe=W??v,Ee=B??K,ze=E??ge,Le=N??te;n.useEffect(()=>{!N&&z&&Qn(te)},[te,N,z]);const Ye=n.useCallback(J=>{ve(J),d?.(J)},[d]),Xe=n.useCallback(J=>{V(J),M?.(J)},[M]),Ke=n.useCallback(J=>{q(J),X?.(J)},[X]),He=n.useCallback(J=>{de(J),J&&$?.(J)},[$]),Ce=n.useMemo(()=>["var(--nice-color-primary, #3b82f6)","var(--nice-color-error, #ef4444)","var(--nice-color-success, #22c55e)"],[]),Ne=c&&c.length>0?c:Ce,Be=Ne[0],$e=n.useMemo(()=>Fe(Be),[Be]),De=n.useMemo(()=>rt($e.h,ye,xe),[$e.h,ye,xe]),Re=n.useCallback((J,je,ke,Te,Ue)=>{const dt=f??Ue??me??Ne.length,Qe=dt!==void 0?Math.max(y,Math.min(T,dt)):void 0;if(je==="shade-chain"){const Oe=Qe??Math.max(y,5),Ge=Xt({h:J,s:$e.s||.7,v:$e.v||.6},Oe,ze);g?.(Ge);return}let et;const ot=je==="custom"&&_e?Le.find(Oe=>Oe.id===_e):null;ot&&ot.angles.length>0?et=ot.angles.map(Oe=>((J+Oe)%360+360)%360):et=rt(J,je,ke);let Ae;if(Te&&un[Te]?Ae=yt(et,Te):Ae=et.map(Oe=>Pe({h:Oe,s:$e.s||.7,v:$e.v||.85})),ot?.lightnessOffsets?.length&&(Ae=Ae.map((Oe,Ge)=>{const Pt=ot.lightnessOffsets?.[Ge];if(Pt==null)return Oe;const wt=Fe(Oe);return Pe({h:wt.h,s:wt.s,v:Math.max(.05,Math.min(.98,wt.v+Pt))})})),Qe!==void 0){for(;Ae.length<Qe;){const Oe=Ae[Ae.length-1]||"#888888",Ge=Fe(Oe);Ae.push(Pe({h:(Ge.h+18)%360,s:Ge.s,v:Ge.v}))}Ae=Ae.slice(0,Qe)}else{for(;Ae.length<y;)Ae.push(Ae[Ae.length-1]||"var(--nice-text-secondary, #888888)");Ae.length>T&&(Ae=Ae.slice(0,T))}g?.(Ae)},[$e.s,$e.v,y,T,g,f,me,Ne.length,ze,_e,Le]),vt=n.useCallback(J=>{if(!A){if(ye==="custom"){const je=Pe({h:J,s:$e.s||.7,v:$e.v||.85}),ke=[...Ne];ke[he]=je,g?.(ke);return}Re(J,ye,xe,Ee)}},[A,ye,xe,Ee,Re,$e.s,$e.v,Ne,he,g]),p=n.useCallback(J=>{if(A||(Xe(J),J==="custom"))return;const je=bt(J).length,ke=je<=1;if(f==null&&!ke){const Te=Math.max(y,Math.min(T,je));pe(Te),Re($e.h,J,xe,Ee,Te)}else Re($e.h,J,xe,Ee)},[A,$e.h,xe,Ee,Xe,Re,f,y,T]),Q=n.useCallback(J=>{A||(Ke(J),Re($e.h,ye,J,Ee))},[A,$e.h,ye,Ee,Ke,Re]),ce=n.useCallback(J=>{if(A)return;He(J);const je=rt($e.h,ye,xe),ke=yt(je,J);g?.(ke.slice(0,T))},[A,$e.h,ye,xe,T,He,g]),Se=n.useCallback((J,je)=>{if(A)return;const ke=[...Ne];ke[J]=je,g?.(ke)},[A,Ne,g]),Me=n.useCallback(()=>{if(A||Ne.length>=T)return;const J=Fe(Ne[Ne.length-1]),je=Pe({h:(J.h+30)%360,s:J.s,v:J.v});g?.([...Ne,je])},[A,Ne,T,g]),qe=n.useCallback(J=>{if(A||Ne.length<=y)return;const je=Ne.filter((ke,Te)=>Te!==J);g?.(je),he>=je.length&&be(Math.max(0,je.length-1))},[A,Ne,y,g,he]),Ze=n.useCallback(()=>{if(A)return;const J=Math.max(y,Math.min(T,bt(ye).length)),je=pn(ye,J,xe);g?.(je)},[A,y,T,ye,xe,g]),Dt=n.useMemo(()=>{if(!H)return[];const J=Ne[he]||Ne[0];return mn(Fe(J),s)},[H,Ne,he,s]),_t=Ne[he]||Ne[0],kt=n.useMemo(()=>{const J=Fe(_t);return Pe({h:(J.h+180)%360,s:J.s,v:J.v})},[_t]);n.useLayoutEffect(()=>{if(!we||!oe.current)return;le(Je.scopeThemeClass(oe.current));const J=()=>{const je=oe.current?.getBoundingClientRect();if(!je)return;const ke=600;let Te=je.left;Te+ke>window.innerWidth-8&&(Te=Math.max(8,window.innerWidth-ke-8));let Ue=je.bottom+6;Ue>window.innerHeight*.5&&(Ue=Math.max(8,window.innerHeight-Math.min(window.innerHeight-16,540)-8)),I({left:Te,top:Ue})};return J(),window.addEventListener("scroll",J,!0),window.addEventListener("resize",J),()=>{window.removeEventListener("scroll",J,!0),window.removeEventListener("resize",J)}},[we]),n.useEffect(()=>{if(!we)return;const J=je=>{const ke=je.target;oe.current?.contains(ke)||se.current?.contains(ke)||(ke instanceof Element?ke:ke?.parentElement??null)?.closest('.nice-select__dropdown, [role="listbox"], [role="option"], [aria-modal="true"]')||ae(!1)};return document.addEventListener("mousedown",J),()=>{document.removeEventListener("mousedown",J)}},[we]),r.useOverlayFocus(se,{open:we,modal:!1,onClose:()=>ae(!1)});const zt=n.useRef(null);if(r.useRovingFocus(zt,{orientation:"horizontal",itemSelector:".nice-palette__variation-chip"}),u)return null;const Lt=G.length>0?G:hn,kn=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(We.NiceSelect,{label:m("colorPalette.harmony","Harmony"),labelPlacement:"left",size:"sm",disabled:A,value:ye==="custom"&&_e?`custom:${_e}`:ye,onChange:J=>{const je=Array.isArray(J)?J[0]:J;if(typeof je=="string")if(je.startsWith("custom:")){const ke=je.slice(7);ne(ke),p("custom")}else ne(null),p(je)},options:[...Jn.map(J=>({value:J,label:Vn[J]})),...Le.map(J=>({value:`custom:${J.id}`,label:J.name}))],renderOption:(J,je)=>{const ke=String(J.value),Te=ke.startsWith("custom:"),Ue=Te?Le.find(et=>et.id===ke.slice(7)):null,dt=Ue?Ue.angles:void 0,Qe=Te?"custom":ke;return e.jsxs("span",{style:{display:"inline-flex",gap:8,alignItems:"center"},children:[e.jsx("span",{style:{width:16,height:16,display:"inline-flex",color:"currentColor"},children:Ut(Qe,{angles:dt,size:16,count:f})}),e.jsx("span",{style:{fontWeight:je?600:400},children:J.label})]})}}),ye==="shade-chain"&&e.jsx(tt.NiceNumberInput,{label:m("colorPalette.step","Step"),labelPlacement:"left",size:"sm",min:.02,max:.5,step:.02,precision:2,value:ze,onChange:J=>{const je=typeof J=="number"?J:Number(J);Number.isNaN(je)||(fe(je),L?.(je),Re($e.h,ye,xe,Ee))},showStepper:!0,disabled:A}),e.jsx(tt.NiceNumberInput,{label:m("colorPalette.colors","Colors"),labelPlacement:"left",size:"sm",min:Math.max(2,y),max:Math.min(12,T),step:1,precision:0,value:f??me??Ne.length,onChange:J=>{const je=typeof J=="number"?J:Number(J);if(!Number.isFinite(je))return;const ke=Math.max(Math.max(2,y),Math.min(Math.min(12,T),Math.round(je)));pe(ke),ye==="shade-chain"?g?.(Xt({h:$e.h,s:$e.s||.7,v:$e.v||.6},ke,ze)):setTimeout(()=>Re($e.h,ye,xe,Ee),0)},showStepper:!0,disabled:A})]}),e.jsx("div",{className:"nice-palette__main",children:e.jsxs("div",{className:"nice-palette__strips",children:[e.jsxs("div",{className:"nice-palette__swatches",children:[Ne.map((J,je)=>e.jsxs("div",{role:"presentation",className:`nice-palette__swatch-wrapper ${he===je?"nice-palette__swatch-wrapper--selected":""}`,onClick:()=>be(je),onFocus:()=>be(je),children:[e.jsx("span",{className:"nice-palette__swatch",style:{background:J}}),e.jsx("input",{type:"text",className:"nice-palette__hex-input",value:J.toUpperCase(),maxLength:7,disabled:A,onClick:ke=>ke.stopPropagation(),onChange:ke=>Se(je,ke.target.value),"aria-label":m("colorPalette.colorN","Color {n}").replace("{n}",String(je+1))}),Ne.length>y&&e.jsx("button",{type:"button",className:"nice-palette__swatch-remove",onClick:ke=>{ke.stopPropagation(),qe(je)},disabled:A,"aria-label":m("colorPalette.removeColor","Remove color"),children:e.jsx(r.NiceIcon,{name:"close",size:14})})]},je)),Ne.length<T&&e.jsxs("button",{type:"button",className:"nice-palette__add-btn",onClick:Me,disabled:A,title:m("colorPalette.addColor","Add color"),children:[e.jsx(r.NiceIcon,{name:"plus",size:14}),e.jsx("span",{children:m("colorPalette.add","Add")})]})]}),e.jsxs("div",{className:"nice-palette__complementary",children:[e.jsx("span",{className:"nice-palette__section-tag",children:m("colorPalette.complementary","Complementary")}),e.jsx("div",{className:"nice-palette__swatch nice-palette__swatch--sm",style:{background:kt},title:kt.toUpperCase()}),e.jsx("span",{className:"nice-palette__hex-label",children:kt.toUpperCase()})]}),w&&e.jsxs("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm nice-palette__random-btn",onClick:Ze,disabled:A,title:m("colorPalette.randomPalette","Random palette"),"aria-label":m("colorPalette.randomPalette","Random palette"),children:[e.jsx(r.NiceIcon,{name:"shuffle",size:14})," ",m("colorPalette.randomPalette2","Random Palette")]})]})})]}),wn=e.jsx("div",{className:"nice-palette__tab",children:Dt.length>0?e.jsxs("div",{className:"nice-palette__variations",children:[e.jsx("span",{className:"nice-palette__section-tag",children:m("colorPalette.tintsShades","Tints & Shades")}),e.jsx("div",{ref:zt,className:"nice-palette__variation-strip",role:"group","aria-label":m("colorPalette.tintsShades","Tints & Shades"),children:Dt.map((J,je)=>e.jsx("div",{className:"nice-palette__variation-chip",style:{background:J},title:J.toUpperCase(),onClick:()=>{A||Se(he,J)},onKeyDown:ke=>{!A&&(ke.key==="Enter"||ke.key===" ")&&(ke.preventDefault(),Se(he,J))},role:"button","aria-label":J.toUpperCase()},je))})]}):e.jsx("div",{className:"nice-palette__empty",children:m("colorPalette.noVariationsAvailable","No variations available.")})}),Nn=e.jsx("div",{className:"nice-palette__tab",children:e.jsx("div",{className:"nice-palette__preset-grid",children:Lt.map(J=>{const je=yt(De,J);return e.jsxs("button",{type:"button",className:`nice-palette__preset-card ${Ee===J?"nice-palette__preset-card--active":""}`,onClick:()=>ce(J),disabled:A,children:[e.jsx("div",{className:"nice-palette__preset-strip",children:je.map((ke,Te)=>e.jsx("span",{className:"nice-palette__preset-dot",style:{background:ke}},Te))}),e.jsx("span",{className:"nice-palette__preset-label",children:Wn[J]})]},J)})})}),Cn=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:m("colorPalette.selectedColorInfo","Selected Color Info")}),e.jsx(Gn,{hex:_t})]}),ie&&e.jsxs("div",{className:"nice-palette__info-panel",children:[e.jsx("div",{className:"nice-palette__section-title",children:m("colorPalette.contrastAnalysisWcag21","Contrast Analysis (WCAG 2.1)")}),e.jsx(qn,{colors:Ne})]})]}),Sn=e.jsx("div",{className:"nice-palette__tab nice-palette__custom-schemes",children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[Le.length===0&&e.jsx("div",{style:{fontSize:12,color:"var(--nice-text-muted)"},children:m("colorPalette.schemes.empty","Save the current palette as a reusable scheme.")}),Le.map(J=>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:Ut("custom",{angles:J.angles,size:16})}),e.jsx("span",{style:{flex:1},children:J.name}),e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--xs",onClick:()=>{ne(J.id),p("custom")},disabled:A,children:m("colorPalette.use","Use")}),e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--xs",onClick:()=>Ye(Le.filter(je=>je.id!==J.id)),disabled:A,"aria-label":m("colorPalette.delete","Delete {name}").replace("{name}",String(J.name)),children:e.jsx(r.NiceIcon,{name:"close",size:14})})]},J.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:A,onClick:()=>{const J=Fe(Ne[0]).h,je=Ne.map(ke=>(Fe(ke).h-J+540)%360-180);D.prompt({title:m("colorPalette.schemeNamePrompt","Scheme name"),defaultValue:`Scheme ${Le.length+1}`}).then(ke=>{if(!ke)return;const Te={id:`cs-${Date.now()}`,name:ke,angles:je};Ye([...Le,Te])})},children:m("colorPalette.saveCurrentAsScheme","+ Save current as scheme")}),e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm",disabled:A||Le.length===0,onClick:()=>{typeof navigator>"u"||navigator.clipboard?.writeText(JSON.stringify(Le,null,2))},children:m("colorPalette.exportJson","Export JSON")}),e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm",disabled:A,onClick:()=>{D.prompt({title:m("colorPalette.pasteSchemesPrompt","Paste the schemes JSON")}).then(J=>{if(J)try{const je=JSON.parse(J);Array.isArray(je)&&Ye(je)}catch{}})},children:m("colorPalette.importJson","Import JSON")})]})]})}),it=[{id:"colors",label:m("colorPalette.colors","Colors"),content:kn}];re&&Lt.length>0&&it.push({id:"presets",label:m("colorPalette.presets","Presets"),content:Nn}),H&&it.push({id:"variations",label:m("colorPalette.variations","Variations"),content:wn}),(ee||ie)&&it.push({id:"info",label:m("colorPalette.info","Info"),content:Cn}),it.push({id:"schemes",label:m("colorPalette.schemes","Schemes"),content:Sn});const En=e.jsxs("div",{className:"nice-palette__popup-header",children:[U&&e.jsxs("div",{className:"nice-palette__wheel-container",children:[e.jsx(Xn,{hues:De,colors:Ne,baseHue:$e.h,onBaseHueChange:vt,mode:ye,distance:xe,disabled:A}),(ye==="analogous"||ye==="split-complementary"||ye==="analogous-complementary")&&e.jsxs("div",{className:"nice-palette__distance",children:[e.jsx("label",{children:m("colorPalette.distance","Distance: {dist}°").replace("{dist}",String(xe))}),e.jsx("input",{type:"range",min:10,max:90,value:xe,onChange:J=>Q(Number(J.target.value)),disabled:A,className:"nice-palette__distance-slider","aria-label":m("colorPalette.distanceLabel","Distance")})]})]}),e.jsx("button",{type:"button",className:"nice-palette__confirm",onClick:()=>ae(!1),"aria-label":m("controls.confirm","Confirm"),title:m("controls.confirm","Confirm"),children:e.jsx(r.NiceIcon,{name:"check",size:18})})]}),$n=e.jsxs("div",{className:"nice-palette nice-palette--studio",children:[En,e.jsx(lt.NiceTabs,{tabs:it,variant:"enclosed",size:"sm"})]});return e.jsxs("div",{ref:h,id:S,className:`nice-field nice-palette-field ${A?"nice-palette--disabled":""} ${F==="left"?"nice-field--label-left":""} ${x?"nice-field--loading":""} ${C?"nice-field--error":""} ${i||""}`,style:a,"data-testid":b,children:[D.element,R&&e.jsx("label",{htmlFor:S,className:"nice-field__label",children:R}),e.jsxs("div",{className:"nice-field__control",children:[e.jsx("div",{ref:oe,className:"nice-palette__field-swatches",role:"button",tabIndex:A||_?-1:0,"aria-haspopup":"dialog","aria-expanded":we,"aria-readonly":_||void 0,"aria-label":m("colorPalette.openStudio","Open palette studio"),onClick:()=>{!A&&!_&&ae(J=>!J)},onKeyDown:J=>{!A&&!_&&(J.key==="Enter"||J.key===" ")&&(J.preventDefault(),ae(je=>!je))},children:Ne.map((J,je)=>e.jsx("span",{role:"presentation",className:"nice-palette__field-swatch",style:{background:J},title:J.toUpperCase(),onClick:ke=>{ke.stopPropagation(),!A&&!_&&(be(je),ae(!0))}},je))}),x&&e.jsx("span",{className:"nice-field__spinner",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})}),we&&ue&&Z&&nt.createPortal(e.jsx("div",{ref:se,className:`nice-palette__popup${Y?` ${Y}`:""}`,"data-theme":Y==="nice-dark"?"dark":Y==="nice-light"?"light":void 0,role:"dialog","aria-label":m("colorPalette.studio","Palette studio"),style:{position:"fixed",left:ue.left,top:ue.top,zIndex:1e3},children:$n}),Z)]}),typeof C=="string"&&C&&e.jsx("div",{className:"nice-field__error",role:"alert",children:C})]})}),{displayName:"NiceColorPalette"});function It(){return{type:"linear",angle:90,stops:[{color:"var(--nice-primary, #3b82f6)",position:0},{color:"var(--nice-accent, #8b5cf6)",position:100}]}}function Mt(t){const i=t.stops.slice().sort((o,c)=>o.position-c.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",c=t.size||"farthest-corner",g=t.positionX??50,y=t.positionY??50;return`${a}radial-gradient(${o} ${c} at ${g}% ${y}%, ${i})`}case"conic":{const o=t.angle??0,c=t.positionX??50,g=t.positionY??50;return`${a}conic-gradient(from ${o}deg at ${c}% ${g}%, ${i})`}}}function fn(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 c=o.split(",").map(M=>M.trim());let g=90,y=0;const T=c[0].match(/^(\d+)deg$/);T&&(g=parseInt(T[1]),y=1);const P=Ct(c.slice(y));return{type:"linear",angle:g,repeating:a,stops:P}}if(i.includes("radial-gradient")){const o=i.match(/radial-gradient\((.+)\)/)?.[1];if(!o)return null;const c=o.split(",").map(y=>y.trim()),g=Ct(c.filter(y=>y.includes("#")||y.includes("rgb")));return{type:"radial",angle:0,repeating:a,stops:g.length>=2?g:It().stops}}if(i.includes("conic-gradient")){const o=i.match(/conic-gradient\((.+)\)/)?.[1];if(!o)return null;const c=o.split(",").map(y=>y.trim()),g=Ct(c.filter(y=>y.includes("#")||y.includes("rgb")));return{type:"conic",angle:0,repeating:a,stops:g.length>=2?g:It().stops}}return null}function Ct(t){return t.map((i,a,o)=>{const c=i.match(/^(#[0-9a-fA-F]{3,8}|rgba?\([^)]+\))\s*(\d+%?)?$/);if(c){const g=c[2]?parseFloat(c[2]):a/Math.max(1,o.length-1)*100;return{color:c[1],position:g}}return{color:i,position:a/Math.max(1,o.length-1)*100}})}function ti(){return"#"+Math.floor(Math.random()*16777215).toString(16).padStart(6,"0")}function ni(t=2){const i=["linear","radial","conic"],a=i[Math.floor(Math.random()*i.length)],o=[];for(let c=0;c<t;c++)o.push({color:ti(),position:Math.round(c/(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 yn=[{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}}],ii=Object.assign(n.forwardRef(({id:t,className:i,style:a,accessMode:o,value:c,onChange:g,showCssOutput:y=!0,showPresets:T=!0,showEditor:P=!0,showRandom:M=!0,maxStops:W=10,label:X,labelPlacement:B="top",disabled:$,readOnly:U,loading:ie,error:ee,errorPlacement:re="bottom",width:G,"data-testid":H},w)=>{const s=r.useNiceAccessMode(o,t),R=s==="hidden";s==="disabled"&&($=!0);const F=U||s==="readOnly",A=r.useControlId(t),{t:k}=r.useNiceTranslation(),x=c??It(),C=n.useMemo(()=>Mt(x),[x]),[f,E]=n.useState(0),[L,N]=n.useState(""),d=n.useRef(null),[z,b]=n.useState(!1),[h,l]=n.useState(null),[u,_]=n.useState(""),m=n.useContext(r.NiceThemeContext)?.portalTarget??(typeof document<"u"?document.body:null),D=n.useRef(null),O=n.useRef(null),V=typeof G=="number"?G:340;n.useLayoutEffect(()=>{if(!z||!D.current)return;_(Je.scopeThemeClass(D.current));const j=()=>{const Z=D.current?.getBoundingClientRect();if(!Z)return;let oe=Z.left;oe+V>window.innerWidth-8&&(oe=Math.max(8,window.innerWidth-V-8));let se=Z.bottom+6;se>window.innerHeight*.5&&(se=Math.max(8,window.innerHeight-Math.min(window.innerHeight-16,520)-8)),l({left:oe,top:se})};return j(),window.addEventListener("scroll",j,!0),window.addEventListener("resize",j),()=>{window.removeEventListener("scroll",j,!0),window.removeEventListener("resize",j)}},[z,V]),n.useEffect(()=>{if(!z)return;const j=Z=>{const oe=Z.target;D.current?.contains(oe)||O.current?.contains(oe)||(oe instanceof Element?oe:oe?.parentElement??null)?.closest('.nice-select__dropdown, [role="listbox"], [role="option"]')||b(!1)};return document.addEventListener("mousedown",j),()=>{document.removeEventListener("mousedown",j)}},[z]),r.useOverlayFocus(O,{open:z,modal:!1,onClose:()=>b(!1)});const v=n.useCallback(j=>{g?.(j)},[g]),q=n.useCallback(j=>{$||v({...x,type:j})},[$,x,v]),K=n.useCallback(j=>{$||v({...x,angle:j})},[$,x,v]),de=n.useCallback(j=>{$||v({...x,repeating:j})},[$,x,v]),he=n.useCallback(j=>{$||v({...x,shape:j})},[$,x,v]),be=n.useCallback((j,Z)=>{if($)return;const oe=x.stops.map((se,ye)=>ye===j?{...se,...Z}:se);v({...x,stops:oe})},[$,x,v]),ge=n.useRef(!1),fe=n.useCallback((j,Z)=>{if($||!d.current)return;j.stopPropagation(),j.preventDefault(),E(Z),ge.current=!1;const oe=ye=>{if(!d.current)return;ge.current=!0;const xe=d.current.getBoundingClientRect(),Ee=Math.round(Math.max(0,Math.min(100,(ye.clientX-xe.left)/xe.width*100)));be(Z,{position:Ee})},se=()=>{document.removeEventListener("pointermove",oe),document.removeEventListener("pointerup",se),document.removeEventListener("pointercancel",se)};document.addEventListener("pointermove",oe),document.addEventListener("pointerup",se),document.addEventListener("pointercancel",se)},[$,be]),me=n.useCallback(()=>{if($||x.stops.length>=W)return;const j=x.stops.slice().sort((xe,Ee)=>xe.position-Ee.position);let Z=0,oe=j[0];for(let xe=0;xe<j.length-1;xe++){const Ee=j[xe+1].position-j[xe].position;Ee>Z&&(Z=Ee,oe=j[xe])}const se=Math.round(oe.position+Z/2),ye="#"+Math.floor(Math.random()*16777215).toString(16).padStart(6,"0");v({...x,stops:[...x.stops,{color:ye,position:se}]})},[$,x,W,v]),pe=n.useCallback(j=>{if($||x.stops.length<=2)return;const Z=x.stops.filter((oe,se)=>se!==j);v({...x,stops:Z}),f>=Z.length&&E(Z.length-1)},[$,x,f,v]),te=(j,Z)=>{const oe=x.stops[Z];if($||!oe)return;const se=j.shiftKey?10:1,ye=j.key==="ArrowLeft"||j.key==="ArrowDown"?oe.position-se:j.key==="ArrowRight"||j.key==="ArrowUp"?oe.position+se:j.key==="PageDown"?oe.position-10:j.key==="PageUp"?oe.position+10:j.key==="Home"?0:j.key==="End"?100:null;ye!==null?(j.preventDefault(),be(Z,{position:Math.max(0,Math.min(100,ye))})):(j.key==="Delete"||j.key==="Backspace")&&x.stops.length>2&&(j.preventDefault(),pe(Z))},ve=n.useCallback(()=>{if($)return;const j=2+Math.floor(Math.random()*3);v(ni(j))},[$,v]),_e=n.useCallback(()=>{if($||!L.trim())return;const j=fn(L);j&&v(j)},[$,L,v]),ne=n.useCallback(j=>{if($||!d.current||x.stops.length>=W)return;const Z=j.target;if(ge.current||Z.closest(".nice-gradient__stop-marker")){ge.current=!1;return}const oe=d.current.getBoundingClientRect(),se=Math.round((j.clientX-oe.left)/oe.width*100),ye="#"+Math.floor(Math.random()*16777215).toString(16).padStart(6,"0"),xe=[...x.stops,{color:ye,position:se}];v({...x,stops:xe}),E(xe.length-1)},[$,x,W,v]),we=n.useMemo(()=>x.stops.slice().sort((j,Z)=>j.position-Z.position),[x.stops]),ae=n.useMemo(()=>`linear-gradient(90deg, ${we.map(j=>`${j.color} ${j.position}%`).join(", ")})`,[we]);if(R)return null;const ue=e.jsxs("div",{className:"nice-gradient__tab",children:[P&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"nice-gradient__type-row",children:[["linear","radial","conic"].map(j=>e.jsx("button",{type:"button",className:`nice-gradient__type-btn ${x.type===j?"nice-gradient__type-btn--active":""}`,onClick:()=>q(j),disabled:$,"aria-pressed":x.type===j,children:j.charAt(0).toUpperCase()+j.slice(1)},j)),e.jsxs("label",{className:"nice-gradient__repeat-label",children:[e.jsx("input",{type:"checkbox",checked:x.repeating??!1,onChange:j=>de(j.target.checked),disabled:$}),k("controls.repeating","Repeating")]})]}),e.jsxs("div",{className:"nice-gradient__controls",children:[x.type==="linear"&&e.jsxs("div",{className:"nice-gradient__control-group",children:[e.jsx("label",{children:k("controls.angle","Angle: {angle}°").replace("{angle}",String(x.angle))}),e.jsx("input",{type:"range",min:0,max:360,value:x.angle,onChange:j=>K(Number(j.target.value)),disabled:$,className:"nice-gradient__slider","aria-label":k("gradient.angle","Angle")}),e.jsx("div",{className:"nice-gradient__angle-presets",children:[0,45,90,135,180,225,270,315].map(j=>e.jsx("button",{type:"button",className:`nice-gradient__angle-btn ${x.angle===j?"nice-gradient__angle-btn--active":""}`,onClick:()=>K(j),disabled:$,title:`${j}°`,"aria-label":`${j}°`,"aria-pressed":x.angle===j,children:e.jsx("span",{style:{transform:`rotate(${j}deg)`,display:"inline-flex"},children:e.jsx(r.NiceIcon,{name:"arrow-right",size:14})})},j))})]}),x.type==="radial"&&e.jsxs("div",{className:"nice-gradient__control-group",children:[e.jsx("label",{children:k("controls.shape","Shape:")}),e.jsx("div",{className:"nice-gradient__shape-btns",children:["circle","ellipse"].map(j=>e.jsx("button",{type:"button",className:`nice-gradient__shape-btn ${(x.shape||"ellipse")===j?"nice-gradient__shape-btn--active":""}`,onClick:()=>he(j),disabled:$,"aria-pressed":(x.shape||"ellipse")===j,children:j},j))})]}),(x.type==="radial"||x.type==="conic")&&e.jsxs("div",{className:"nice-gradient__control-group",children:[e.jsx("label",{children:k("controls.center","Center: {positionX}%, {positionY}%").replace("{positionX}",String(x.positionX??50)).replace("{positionY}",String(x.positionY??50))}),e.jsxs("div",{className:"nice-gradient__center-inputs",children:[e.jsx("input",{type:"range",min:0,max:100,value:x.positionX??50,onChange:j=>v({...x,positionX:Number(j.target.value)}),disabled:$,className:"nice-gradient__slider","aria-label":k("gradient.centerX","Horizontal center")}),e.jsx("input",{type:"range",min:0,max:100,value:x.positionY??50,onChange:j=>v({...x,positionY:Number(j.target.value)}),disabled:$,className:"nice-gradient__slider","aria-label":k("gradient.centerY","Vertical center")})]})]}),x.type==="conic"&&e.jsxs("div",{className:"nice-gradient__control-group",children:[e.jsx("label",{children:k("controls.startAngle","Start angle: {angle}°").replace("{angle}",String(x.angle))}),e.jsx("input",{type:"range",min:0,max:360,value:x.angle,onChange:j=>K(Number(j.target.value)),disabled:$,className:"nice-gradient__slider","aria-label":k("gradient.startAngle","Start angle")})]})]}),e.jsxs("div",{className:"nice-gradient__bar-container",children:[e.jsx("div",{role:"presentation",ref:d,className:"nice-gradient__bar",style:{background:ae},onClick:ne,children:x.stops.map((j,Z)=>e.jsx("div",{className:`nice-gradient__stop-marker ${f===Z?"nice-gradient__stop-marker--active":""}`,style:{left:`${j.position}%`},onPointerDown:oe=>fe(oe,Z),onClick:oe=>{oe.stopPropagation(),E(Z),ge.current=!1},onFocus:()=>E(Z),onKeyDown:oe=>te(oe,Z),role:"slider",tabIndex:$?-1:0,"aria-label":k("gradient.stop","Stop {n}").replace("{n}",String(Z+1)),"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":j.position,"aria-valuetext":`${j.color} ${j.position}%`,title:`${j.color} @ ${j.position}%`,children:e.jsx("div",{className:"nice-gradient__stop-dot",style:{background:j.color}})},Z))}),e.jsx("button",{type:"button",className:"nice-gradient__add-stop",onClick:me,disabled:$||x.stops.length>=W,title:k("controls.addStop","Add stop"),"aria-label":k("controls.addStop","Add stop"),children:e.jsx(r.NiceIcon,{name:"plus",size:14})})]}),e.jsx("div",{className:"nice-gradient__stop-editor",children:e.jsx("div",{className:"nice-gradient__stop-list",children:we.map((j,Z)=>{const oe=x.stops.indexOf(j);return e.jsxs("div",{role:"presentation",className:`nice-gradient__stop-row ${f===oe?"nice-gradient__stop-row--active":""}`,onClick:()=>E(oe),onFocus:()=>E(oe),children:[e.jsx("input",{type:"color",value:j.color,onChange:se=>be(oe,{color:se.target.value}),disabled:$,className:"nice-gradient__stop-color","aria-label":k("gradient.stopColor","Stop color")}),e.jsx("input",{type:"text",value:j.color.toUpperCase(),maxLength:7,onChange:se=>be(oe,{color:se.target.value}),disabled:$,className:"nice-gradient__stop-hex","aria-label":k("gradient.stopHex","Stop color (hex)")}),e.jsx("input",{type:"number",min:0,max:100,value:j.position,onChange:se=>be(oe,{position:Number(se.target.value)}),disabled:$,className:"nice-gradient__stop-pos","aria-label":k("gradient.stopPosition","Stop position")}),e.jsx("span",{className:"nice-gradient__stop-pct",children:"%"}),x.stops.length>2&&e.jsx("button",{type:"button",className:"nice-gradient__stop-del",onClick:()=>pe(oe),disabled:$,"aria-label":k("controls.removeStop","Remove stop"),children:e.jsx(r.NiceIcon,{name:"close",size:14})})]},oe)})})})]}),M&&e.jsxs("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm nice-gradient__random-btn",onClick:ve,disabled:$,title:k("controls.randomGradient","Random gradient"),"aria-label":k("controls.randomGradient","Random gradient"),children:[e.jsx(r.NiceIcon,{name:"shuffle",size:14})," ",k("controls.randomGradient2","Random Gradient")]})]}),I=e.jsx("div",{className:"nice-gradient__tab",children:e.jsx("div",{className:"nice-gradient__preset-grid",children:yn.map((j,Z)=>e.jsxs("button",{type:"button",className:"nice-gradient__preset-card",onClick:()=>{$||v(j.value)},disabled:$,title:j.name,children:[e.jsx("div",{className:"nice-gradient__preset-preview",style:{background:Mt(j.value)}}),e.jsx("span",{className:"nice-gradient__preset-name",children:j.name})]},Z))})}),Y=e.jsxs("div",{className:"nice-gradient__tab",children:[e.jsxs("div",{className:"nice-gradient__css-output",children:[e.jsx("code",{children:`background: ${C};`}),e.jsx("button",{type:"button",className:"nice-gradient__copy-btn",onClick:()=>navigator.clipboard?.writeText(`background: ${C};`),title:k("controls.copyCss","Copy CSS"),"aria-label":k("controls.copyCss","Copy CSS"),children:e.jsx(r.NiceIcon,{name:"clipboard",size:16})})]}),e.jsxs("div",{className:"nice-gradient__css-import",children:[e.jsx("input",{type:"text",className:"nice-gradient__css-input",placeholder:k("controls.pasteCssGradientToImport","Paste CSS gradient to import..."),value:L,onChange:j=>N(j.target.value),disabled:$,"aria-label":k("gradient.importCss","CSS gradient to import")}),e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm",onClick:_e,disabled:$,children:k("controls.import","Import")})]})]}),le=[{id:"editor",label:k("controls.editor","Editor"),content:ue}];return T&&le.push({id:"presets",label:k("controls.presets","Presets"),content:I}),y&&le.push({id:"css",label:"CSS",content:Y}),e.jsxs("div",{ref:w,id:A,className:`nice-field nice-gradient-field ${$?"nice-gradient--disabled":""} ${B==="left"?"nice-field--label-left":""} ${ie?"nice-field--loading":""} ${ee?"nice-field--error":""} ${re==="right"?"nice-field--error-right":""} ${i||""}`,style:a,"data-testid":H,children:[X&&e.jsx("label",{htmlFor:A,className:"nice-field__label",children:X}),e.jsxs("div",{className:"nice-field__control",children:[e.jsx("button",{ref:D,type:"button",className:"nice-gradient__swatch",style:{background:C},"aria-haspopup":"dialog","aria-expanded":z,"aria-readonly":F||void 0,"aria-label":k("controls.openGradientEditor","Open gradient editor"),disabled:$,onClick:()=>{!$&&!F&&b(j=>!j)}}),ie&&e.jsx("span",{className:"nice-field__spinner",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})}),re==="right"&&typeof ee=="string"&&ee&&e.jsx("div",{className:"nice-field__error",role:"alert",children:ee}),z&&h&&m&&nt.createPortal(e.jsx("div",{ref:O,className:`nice-gradient__popup${u?` ${u}`:""}`,"data-theme":u==="nice-dark"?"dark":u==="nice-light"?"light":void 0,role:"dialog","aria-label":k("controls.gradientEditor","Gradient editor"),style:{position:"fixed",left:h.left,top:h.top,width:G!=null?typeof G=="number"?`${G}px`:G: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:C}}),e.jsx("button",{type:"button",className:"nice-gradient__confirm",onClick:()=>b(!1),"aria-label":k("controls.confirm","Confirm"),title:k("controls.confirm","Confirm"),children:e.jsx(r.NiceIcon,{name:"check",size:18})})]}),e.jsx(lt.NiceTabs,{tabs:le,variant:"enclosed",size:"sm"})]})}),m)]}),re!=="right"&&typeof ee=="string"&&ee&&e.jsx("div",{className:"nice-field__error",role:"alert",children:ee})]})}),{displayName:"NiceGradientPicker"}),oi=[{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"}],ai=[{style:"professional",label:"Professional"},{style:"casual",label:"Casual"},{style:"formal",label:"Formal"},{style:"concise",label:"Concise"}],si=n.forwardRef(function(i,a){const{enableAI:o=!0,aiModel:c,enableImprove:g=!0,enableTranslate:y=!0,enableGenerate:T=!0,toolbar:P,languages:M=oi,textStyles:W=ai,onImprove:X,onTranslate:B,onGenerate:$,showAIToolbar:U=!0,value:ie,onChange:ee,...re}=i,G=n.useRef(null),[H,w]=n.useState(!1),[s,R]=n.useState(!1),[F,A]=n.useState(!1),[k,x]=n.useState(""),[C,f]=n.useState(""),[E,L]=n.useState("professional"),[N,d]=n.useState(""),[z,b]=n.useState(M[0]?.code||"en"),[h,l]=n.useState(""),[u,_]=n.useState(""),{t:S}=on.useNiceTranslation(),m=r.useNiceAI(),{improveText:D,translate:O,generateHtml:V,isLoading:v}=r.useTextImprovement(),q=o&&m.isConfigured,K=n.useCallback(()=>{const te=window.getSelection();return te&&te.toString().trim()?te.toString():""},[]),de=n.useCallback(te=>{const ve=window.getSelection();if(ve&&ve.rangeCount>0){const _e=ve.getRangeAt(0);_e.deleteContents();const ne=document.createElement("div");ne.innerHTML=te;const we=document.createDocumentFragment();for(;ne.firstChild;)we.appendChild(ne.firstChild);if(_e.insertNode(we),G.current){const ae=G.current.innerHTML;ee?.(ae)}}},[ee]),he=n.useCallback(async(te="professional")=>{if(!q||!g)return"";const ve=K();if(!ve)return"";x(ve),L(te),w(!0),f("");try{const _e=await D(ve,te);return f(_e),X?.(ve,_e,te),_e}catch{return f(S("htmlEditorAI.improveFailed","Failed to improve text")),""}},[q,g,K,D,X,S]),be=n.useCallback(async te=>{if(!q||!y)return"";const ve=K();if(!ve)return"";x(ve),b(te),R(!0),d("");try{const _e=M.find(we=>we.code===te)?.label||te,ne=await O(ve,_e);return d(ne),B?.(ve,ne,te),ne}catch{return d(S("htmlEditorAI.translateFailed","Failed to translate text")),""}},[q,y,K,O,M,B,S]),ge=n.useCallback(async te=>{if(!q||!T||!te.trim())return"";l(te),_("");try{const ve=await V(te);return _(ve),$?.(te,ve),ve}catch{return _(S("htmlEditorAI.generateFailed","Failed to generate HTML")),""}},[q,T,V,$,S]),fe=n.useCallback(()=>{C&&de(C),w(!1),f("")},[C,de]),me=n.useCallback(()=>{N&&de(N),R(!1),d("")},[N,de]),pe=n.useCallback(()=>{if(u&&G.current){document.execCommand("insertHTML",!1,u);const te=G.current.innerHTML;ee?.(te)}A(!1),_(""),l("")},[u,ee]);return n.useImperativeHandle(a,()=>({getEditor:()=>G.current,focus:()=>G.current?.focus(),getValue:()=>G.current?.innerHTML||"",setValue:te=>{G.current&&(G.current.innerHTML=te,ee?.(te))},getSelection:K,insertHtml:te=>{document.execCommand("insertHTML",!1,te),G.current&&ee?.(G.current.innerHTML)},improveSelection:he,translateSelection:be,generateHtml:ge})),n.useCallback(te=>{G.current=te},[]),e.jsxs("div",{className:"nice-html-editor-ai","data-testid":i["data-testid"],children:[U&&q&&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:S("htmlEditorAI.ai","AI")}),v&&e.jsx("span",{className:"nice-html-editor-ai__loading",children:S("htmlEditorAI.processing","Processing...")})]}),e.jsxs("div",{className:"nice-html-editor-ai__toolbar-right",children:[g&&e.jsxs("div",{className:"nice-html-editor-ai__dropdown",children:[e.jsxs("button",{type:"button",className:"nice-html-editor-ai__btn",onClick:()=>he(),disabled:v,title:S("htmlEditorAI.improveText","Improve selected text"),children:[e.jsx(r.NiceIcon,{name:"star",size:14})," ",S("htmlEditorAI.improve","Improve")]}),e.jsx("div",{className:"nice-html-editor-ai__dropdown-menu",children:W.map(({style:te,label:ve})=>e.jsx("button",{type:"button",className:"nice-html-editor-ai__dropdown-item",onClick:()=>he(te),children:ve},te))})]}),y&&e.jsxs("div",{className:"nice-html-editor-ai__dropdown",children:[e.jsxs("button",{type:"button",className:"nice-html-editor-ai__btn",disabled:v,title:S("htmlEditorAI.translateText","Translate selected text"),children:[e.jsx(r.NiceIcon,{name:"globe",size:14})," ",S("htmlEditorAI.translate","Translate")]}),e.jsx("div",{className:"nice-html-editor-ai__dropdown-menu nice-html-editor-ai__dropdown-menu--languages",children:M.map(({code:te,label:ve})=>e.jsx("button",{type:"button",className:"nice-html-editor-ai__dropdown-item",onClick:()=>be(te),children:ve},te))})]}),T&&e.jsxs("button",{type:"button",className:"nice-html-editor-ai__btn",onClick:()=>A(!0),disabled:v,title:S("htmlEditorAI.generateHtml","Generate HTML from description"),children:[e.jsx(r.NiceIcon,{name:"zap",size:14})," ",S("htmlEditorAI.generate","Generate")]})]})]}),e.jsx("div",{className:"nice-html-editor-ai__editor-wrapper",children:e.jsx(In.NiceHtmlEditor,{value:ie,onChange:ee,toolbar:P,...re})}),H&&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(r.NiceIcon,{name:"star",size:16})," ",S("htmlEditorAI.improveText","Improve Text")]}),e.jsx("div",{className:"nice-html-editor-ai__style-selector",children:W.map(({style:te,label:ve})=>e.jsx("button",{type:"button",className:`nice-html-editor-ai__style-btn ${E===te?"nice-html-editor-ai__style-btn--active":""}`,onClick:()=>{L(te),he(te)},children:ve},te))}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__close","aria-label":S("htmlEditorAI.close","Close"),onClick:()=>w(!1),children:e.jsx(r.NiceIcon,{name:"close",size:14})})]}),e.jsx("div",{className:"nice-html-editor-ai__panel-body",children:v?e.jsx("div",{className:"nice-html-editor-ai__loading-panel",children:S("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:S("htmlEditorAI.original","Original")}),e.jsx("div",{className:"nice-html-editor-ai__text-content",children:k})]}),e.jsxs("div",{className:"nice-html-editor-ai__text-block nice-html-editor-ai__text-block--improved",children:[e.jsx("h5",{children:S("htmlEditorAI.improved","Improved")}),e.jsx("div",{className:"nice-html-editor-ai__text-content",children:C})]})]})}),e.jsxs("div",{className:"nice-html-editor-ai__panel-footer",children:[e.jsxs("button",{type:"button",className:"nice-html-editor-ai__apply",onClick:fe,disabled:!C||v,children:[e.jsx(r.NiceIcon,{name:"check",size:14})," ",S("htmlEditorAI.apply","Apply")]}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__cancel",onClick:()=>{w(!1),f("")},children:S("htmlEditorAI.cancel","Cancel")})]})]}),s&&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(r.NiceIcon,{name:"globe",size:16})," ",S("htmlEditorAI.translateText","Translate Text")]}),e.jsx("div",{className:"nice-html-editor-ai__language-selector",children:e.jsx("select",{value:z,onChange:te=>{b(te.target.value),be(te.target.value)},className:"nice-html-editor-ai__language-select",children:M.map(({code:te,label:ve})=>e.jsx("option",{value:te,children:ve},te))})}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__close","aria-label":S("htmlEditorAI.close","Close"),onClick:()=>R(!1),children:e.jsx(r.NiceIcon,{name:"close",size:14})})]}),e.jsx("div",{className:"nice-html-editor-ai__panel-body",children:v?e.jsx("div",{className:"nice-html-editor-ai__loading-panel",children:S("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:S("htmlEditorAI.original","Original")}),e.jsx("div",{className:"nice-html-editor-ai__text-content",children:k})]}),e.jsxs("div",{className:"nice-html-editor-ai__text-block nice-html-editor-ai__text-block--translated",children:[e.jsx("h5",{children:M.find(te=>te.code===z)?.label||z}),e.jsx("div",{className:"nice-html-editor-ai__text-content",children:N})]})]})}),e.jsxs("div",{className:"nice-html-editor-ai__panel-footer",children:[e.jsxs("button",{type:"button",className:"nice-html-editor-ai__apply",onClick:me,disabled:!N||v,children:[e.jsx(r.NiceIcon,{name:"check",size:14})," ",S("htmlEditorAI.apply","Apply")]}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__cancel",onClick:()=>{R(!1),d("")},children:S("htmlEditorAI.cancel","Cancel")})]})]}),F&&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(r.NiceIcon,{name:"zap",size:16})," ",S("htmlEditorAI.generateHtml","Generate HTML")]}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__close","aria-label":S("htmlEditorAI.close","Close"),onClick:()=>{A(!1),_(""),l("")},children:e.jsx(r.NiceIcon,{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:S("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:h,onChange:te=>l(te.target.value),className:"nice-html-editor-ai__generate-textarea",rows:3}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__generate-btn",onClick:()=>ge(h),disabled:v||!h.trim(),children:v?S("htmlEditorAI.generating","Generating..."):S("htmlEditorAI.generate","Generate")})]}),u&&e.jsxs("div",{className:"nice-html-editor-ai__generate-result",children:[e.jsx("h5",{children:S("htmlEditorAI.preview","Preview")}),e.jsx("div",{className:"nice-html-editor-ai__preview",dangerouslySetInnerHTML:{__html:u}}),e.jsx("h5",{children:S("htmlEditorAI.htmlCode","HTML Code")}),e.jsx("pre",{className:"nice-html-editor-ai__code",children:u})]})]}),e.jsxs("div",{className:"nice-html-editor-ai__panel-footer",children:[e.jsxs("button",{type:"button",className:"nice-html-editor-ai__apply",onClick:pe,disabled:!u||v,children:[e.jsx(r.NiceIcon,{name:"check",size:14})," ",S("htmlEditorAI.insert","Insert")]}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__cancel",onClick:()=>{A(!1),_(""),l("")},children:S("htmlEditorAI.cancel","Cancel")})]})]})]})}),ri=[{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 ci(t){let i=t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">");return i=i.replace(/```(\w*)\n([\s\S]*?)```/g,(a,o,c)=>`<pre><code class="language-${o}">${c.trim()}</code></pre>`),i=i.replace(/^(\|.+\|)\n(\|[-| :]+\|)\n((?:\|.+\|\n?)+)/gm,(a,o,c,g)=>{const y=o.split("|").filter(P=>P.trim()).map(P=>`<th>${P.trim()}</th>`).join(""),T=g.trim().split(`
|
|
2
|
-
`).map(P=>`<tr>${P.split("|").filter(W=>W.trim()).map(W=>`<td>${W.trim()}</td>`).join("")}</tr>`).join("");return`<table><thead><tr>${y}</tr></thead><tbody>${T}</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"><input type="checkbox" checked disabled> $1</li>'),i=i.replace(/^- \[ \] (.+)$/gm,'<li class="task"><input type="checkbox" disabled> $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 li=[{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"}],di=["format","heading","list","block","insert"],mi=Object.assign(n.forwardRef(({value:t="",onChange:i,preview:a="side",placeholder:o,disabled:c,readOnly:g,size:y="md",editorSize:T="standard",toolbar:P=!0,minHeight:M=200,showWordCount:W=!1,showLineNumbers:X=!1,onExportHtml:B,onImageUpload:$,tutorial:U,className:ie,style:ee,id:re,"data-testid":G},H)=>{const{t:w}=r.useNiceTranslation(),s=r.useControlId(re),[R,F]=n.useState("edit"),[A,k]=n.useState(!1),x=n.useRef(null),[C]=n.useState(r.createTabEscape),f=n.useMemo(()=>ci(t),[t]),E=n.useMemo(()=>{const l=t.trim()?t.trim().split(/\s+/).length:0,u=t.length,_=t.split(`
|
|
7
|
-
`).length;return{words:l,chars:u,lines:_}},[t]),L=n.useCallback(l=>{const u=x.current;if(!u)return;const _=u.selectionStart,S=u.selectionEnd,m=t.slice(_,S);let D,O;l==="[](url)"?(D=t.slice(0,_)+`[${m||"text"}](url)`+t.slice(S),O=_+1+(m||"text").length+2):l===""?(D=t.slice(0,_)+``+t.slice(S),O=_+2+(m||"alt").length+2):l.endsWith(`
|
|
8
|
-
`)||l.endsWith(" ")?(D=t.slice(0,_)+l+m+t.slice(S),O=_+l.length+m.length):(D=t.slice(0,_)+l+m+l+t.slice(S),O=_+l.length+m.length+l.length),i?.(D),requestAnimationFrame(()=>{u.focus(),u.setSelectionRange(O,O)})},[t,i]),N=n.useCallback(l=>{if(!C(l)&&((l.ctrlKey||l.metaKey)&&(l.key==="b"?(l.preventDefault(),L("**")):l.key==="i"?(l.preventDefault(),L("*")):l.key==="k"&&(l.preventDefault(),L("[](url)"))),l.key==="Tab"&&!g)){l.preventDefault();const u=l.currentTarget,_=u.selectionStart,S=u.selectionEnd,m=" ";if(l.shiftKey){const V=t.slice(0,_).lastIndexOf(`
|
|
9
|
-
`)+1;if(t.slice(V,V+m.length)===m){const v=t.slice(0,V)+t.slice(V+m.length);i?.(v),requestAnimationFrame(()=>{u.selectionStart=u.selectionEnd=_-m.length})}}else{const D=t.slice(0,_)+m+t.slice(S);i?.(D),requestAnimationFrame(()=>{u.selectionStart=u.selectionEnd=_+m.length})}}},[t,i,L,C,g]),d=n.useCallback(async l=>{if(!$)return;const u=Array.from(l.dataTransfer.files).filter(_=>_.type.startsWith("image/"));if(u.length!==0){l.preventDefault();for(const _ of u){const S=await $(_),m=x.current;if(!m)continue;const D=m.selectionStart,O=`
|
|
10
|
-
`,V=t.slice(0,D)+O+t.slice(D);i?.(V)}}},[t,i,$]),z=a!=="tab"||R==="edit",b=a==="side"||a==="tab"&&R==="preview"||a===!0,h=`nice-md-editor nice-md-editor--${y} nice-editor--${T} nice-md-editor--preview-${a}${A?" nice-md-editor--fullscreen":""} ${ie||""}`;return e.jsxs("div",{ref:H,id:s,className:h,style:{position:"relative",...ee},"data-testid":G,children:[e.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:20},children:e.jsx(r.NiceTutorialButton,{steps:r.resolveTutorial(U,ri)})}),P&&e.jsxs("div",{className:"nice-md-editor__toolbar",children:[di.map((l,u)=>e.jsxs(n.Fragment,{children:[u>0&&e.jsx("span",{className:"nice-md-editor__sep"}),li.filter(_=>_.group===l).map(_=>e.jsx("button",{type:"button",className:"nice-md-editor__btn",title:_.shortcut?`${_.tip} (${_.shortcut})`:_.tip,disabled:c||g,onClick:()=>L(_.md),"aria-label":_.tip,children:_.icon?e.jsx(r.NiceIcon,{name:_.icon,size:16}):_.label},_.key))]},l)),e.jsx("span",{className:"nice-md-editor__sep"}),e.jsx("button",{type:"button",className:"nice-md-editor__btn",title:w("markdownEditor.fullscreen","Fullscreen"),"aria-label":w("markdownEditor.fullscreen","Fullscreen"),onClick:()=>k(!A),children:e.jsx(r.NiceIcon,{name:A?"collapse":"expand",size:16})}),B&&e.jsx("button",{type:"button",className:"nice-md-editor__btn",title:w("markdownEditor.exportHtml","Export HTML"),"aria-label":w("markdownEditor.exportHtml","Export HTML"),onClick:()=>B(f),children:e.jsx(r.NiceIcon,{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${R==="edit"?" nice-md-editor__tab--active":""}`,onClick:()=>F("edit"),children:w("markdownEditor.edit","Edit")}),e.jsx("button",{type:"button",className:`nice-md-editor__tab${R==="preview"?" nice-md-editor__tab--active":""}`,onClick:()=>F("preview"),children:w("markdownEditor.preview","Preview")})]})]}),e.jsxs("div",{className:"nice-md-editor__body",style:{minHeight:M},children:[z&&e.jsxs("div",{className:"nice-md-editor__editor-wrap",children:[X&&e.jsx("div",{className:"nice-md-editor__line-numbers",children:Array.from({length:E.lines},(l,u)=>e.jsx("div",{className:"nice-md-editor__line-no",children:u+1},u))}),e.jsx("textarea",{ref:x,className:"nice-md-editor__textarea",value:t,onChange:l=>i?.(l.target.value),onKeyDown:N,onDrop:d,placeholder:o,disabled:c,readOnly:g,style:{minHeight:M},"aria-describedby":g?void 0:`${s}-tab-hint`}),!g&&e.jsx("span",{id:`${s}-tab-hint`,className:"nice-sr-only",children:w("input.tabEscapeHint","Tab indents. To leave the editor, press Escape, then Tab.")})]}),b&&e.jsx("div",{className:"nice-md-editor__preview",dangerouslySetInnerHTML:{__html:r.sanitizeHtml(f)},style:{minHeight:M}})]}),W&&e.jsxs("div",{className:"nice-md-editor__statusbar",children:[e.jsx("span",{children:w("markdownEditor.words","{words} words").replace("{words}",String(E.words))}),e.jsx("span",{children:w("markdownEditor.chars","{chars} chars").replace("{chars}",String(E.chars))}),e.jsx("span",{children:w("markdownEditor.lines","{lines} lines").replace("{lines}",String(E.lines))})]})]})}),{displayName:"NiceMarkdownEditor"}),ui=[{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 pi=0;function At(){return`blk-${++pi}-${Date.now().toString(36)}`}function Gt(t=""){return{id:At(),type:"paragraph",content:t}}function hi(t,i=""){const a={id:At(),type:t,content:i};return t==="heading"&&(a.level=2),t==="list"&&(a.listType="unordered"),t==="toggle"&&(a.open=!0),a}const gi=[{type:"paragraph",label:"Text",icon:"align-left",keywords:"paragraph text"},{type:"heading",label:"Heading",icon:"type",keywords:"heading title"},{type:"list",label:"Bulleted list",icon:"list",keywords:"bullet unordered list"},{type:"list",label:"Numbered list",icon:"list-ordered",keywords:"numbered ordered list"},{type:"list",label:"Checklist",icon:"check-square",keywords:"check todo list"},{type:"quote",label:"Quote",icon:"quote",keywords:"quote blockquote"},{type:"callout",label:"Callout",icon:"info",keywords:"callout info alert"},{type:"toggle",label:"Toggle",icon:"chevron-right",keywords:"toggle collapse expand"},{type:"code",label:"Code",icon:"code",keywords:"code snippet"},{type:"image",label:"Image",icon:"image",keywords:"image photo picture"},{type:"video",label:"Video",icon:"video",keywords:"video embed"},{type:"table",label:"Table",icon:"table",keywords:"table grid"},{type:"divider",label:"Divider",icon:"minus",keywords:"divider line separator"},{type:"pageBreak",label:"Page Break",icon:"page-break",keywords:"page break"}];function fi(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=(c,g)=>{let y=g;return t.bold&&(y=`<strong>${y}</strong>`),t.italic&&(y=`<em>${y}</em>`),t.underline&&(y=`<u>${y}</u>`),t.strikethrough&&(y=`<s>${y}</s>`),`<${c}${a}>${y}</${c}>`};switch(t.type){case"heading":return o(`h${t.level??2}`,t.content);case"paragraph":return o("p",t.content||" ");case"list":{const c=t.listType==="ordered"?"ol":"ul",g=t.content.split(`
|
|
11
|
-
`).map((y,T)=>t.listType==="checklist"?`<li><input type="checkbox" ${t.checked?.[T]??!1?"checked":""} disabled />${y}</li>`:`<li>${y}</li>`).join("");return`<${c}${a}>${g}</${c}>`}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}>${t.icon?`<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 yi(t){let i=0,a=0;for(const o of t){const c=o.content??"";i+=c.length;const g=c.trim().split(/\s+/).filter(Boolean);a+=g.length}return{words:a,chars:i,readingTime:Math.max(1,Math.ceil(a/200))}}const xi=Object.assign(n.forwardRef(({blocks:t,onChange:i,readOnly:a=!1,showToolbar:o=!0,size:c="md",editorSize:g="standard",placeholder:y,onExport:T,onImageUpload:P,maxUndo:M=50,slashCommands:W=!0,showWordCount:X=!1,showToc:B=!1,showFindReplace:$=!0,tutorial:U,className:ie,style:ee,id:re,...G},H)=>{const w=r.useControlId(re),{t:s}=r.useNiceTranslation(),[R]=n.useState(r.createTabEscape),F=`${w}-tab-hint`,A=n.useRef(null);r.useRovingFocus(A,{orientation:"horizontal",itemSelector:"button"});const[k,x]=n.useState(()=>t??[Gt()]),C=t??k,[f,E]=n.useState(0),L=n.useRef(new Map),N=n.useRef(null),[d,z]=n.useState(!1),[b,h]=n.useState(""),[l,u]=n.useState(""),[_,S]=n.useState([]),[m,D]=n.useState(0),[O,V]=n.useState(!1),v=n.useRef([]),q=n.useRef([]),K=n.useCallback(p=>{v.current.push(p.map(Q=>({...Q,checked:Q.checked?[...Q.checked]:void 0}))),v.current.length>M&&v.current.shift(),q.current=[]},[M]),de=n.useCallback(()=>{if(v.current.length===0)return;const p=v.current.pop();q.current.push(C.map(Q=>({...Q}))),t||x(p),i?.(p)},[C,t,i]),he=n.useCallback(()=>{if(q.current.length===0)return;const p=q.current.pop();v.current.push(C.map(Q=>({...Q}))),t||x(p),i?.(p)},[C,t,i]),[be,ge]=n.useState(!1),[fe,me]=n.useState(""),[pe,te]=n.useState(0),ve=n.useMemo(()=>{if(!be||!W)return[];const p=fe.toLowerCase();return gi.filter(Q=>Q.label.toLowerCase().includes(p)||Q.keywords.includes(p))},[be,fe,W]),[_e,ne]=n.useState(null),[we,ae]=n.useState(null),ue=n.useCallback(p=>{K(C);const Q=p(C);t||x(Q),i?.(Q)},[C,t,i,K]),I=n.useCallback((p,Q)=>{ue(ce=>ce.map((Se,Me)=>Me===p?{...Se,...Q}:Se))},[ue]),Y=n.useCallback((p,Q)=>{const ce=Q??Gt();ue(Se=>{const Me=[...Se];return Me.splice(p+1,0,ce),Me}),E(p+1)},[ue]),le=n.useCallback(p=>{const Q={...C[p],id:At()};Y(p,Q)},[C,Y]),j=n.useCallback(p=>{C.length<=1||(ue(Q=>Q.filter((ce,Se)=>Se!==p)),E(Math.max(0,p-1)))},[C.length,ue]),Z=n.useCallback((p,Q)=>{const ce=p+Q;ce<0||ce>=C.length||(ue(Se=>{const Me=[...Se];return[Me[p],Me[ce]]=[Me[ce],Me[p]],Me}),E(ce))},[C.length,ue]),oe=n.useCallback((p,Q)=>{const ce={type:Q};Q==="heading"&&(ce.level=2),Q==="list"&&(ce.listType="unordered"),Q==="toggle"&&(ce.open=!0),I(p,ce)},[I]),se=n.useCallback(p=>{const Q=hi(p.type);p.type==="list"&&p.label.includes("Numbered")&&(Q.listType="ordered"),p.type==="list"&&p.label.includes("Checklist")&&(Q.listType="checklist",Q.checked=[]),C[f]?.content===""||C[f]?.content==="/"?ue(ce=>ce.map((Se,Me)=>Me===f?{...Q,id:Se.id}:Se)):Y(f,Q),ge(!1),me("")},[C,f,ue,Y]),ye=n.useCallback((p,Q)=>{if(R(p)||a)return;const ce=C[Q];if(!ce?.locked){if((p.ctrlKey||p.metaKey)&&p.key==="z"&&!p.shiftKey){p.preventDefault(),de();return}if((p.ctrlKey||p.metaKey)&&(p.key==="y"||p.key==="z"&&p.shiftKey)){p.preventDefault(),he();return}if((p.ctrlKey||p.metaKey)&&p.key==="d"){p.preventDefault(),le(Q);return}if((p.ctrlKey||p.metaKey)&&p.key==="b"){p.preventDefault(),I(Q,{bold:!ce?.bold});return}if((p.ctrlKey||p.metaKey)&&p.key==="i"){p.preventDefault(),I(Q,{italic:!ce?.italic});return}if((p.ctrlKey||p.metaKey)&&p.key==="u"){p.preventDefault(),I(Q,{underline:!ce?.underline});return}if((p.ctrlKey||p.metaKey)&&p.key==="e"){p.preventDefault(),I(Q,{strikethrough:!ce?.strikethrough});return}if(p.key==="Tab"&&!p.shiftKey){p.preventDefault(),I(Q,{indent:Math.min((ce?.indent??0)+1,4)});return}if(p.key==="Tab"&&p.shiftKey){p.preventDefault(),I(Q,{indent:Math.max((ce?.indent??0)-1,0)});return}if((p.ctrlKey||p.metaKey)&&p.key==="f"&&$){p.preventDefault(),z(Se=>!Se);return}if(be&&ve.length>0){if(p.key==="ArrowDown"){p.preventDefault(),te(Se=>Math.min(Se+1,ve.length-1));return}if(p.key==="ArrowUp"){p.preventDefault(),te(Se=>Math.max(Se-1,0));return}if(p.key==="Enter"){p.preventDefault(),se(ve[pe]);return}if(p.key==="Escape"){ge(!1);return}}p.key==="Enter"&&!p.shiftKey?(p.preventDefault(),Y(Q)):p.key==="Backspace"&&C[Q].content===""&&C.length>1?(p.preventDefault(),j(Q)):p.key==="ArrowUp"&&p.altKey?(p.preventDefault(),Z(Q,-1)):p.key==="ArrowDown"&&p.altKey&&(p.preventDefault(),Z(Q,1))}},[R,a,C,Y,j,Z,de,he,le,I,be,ve,pe,se,$]),xe=n.useCallback((p,Q)=>{const ce=p.target.textContent??"";W&&ce.startsWith("/")?(ge(!0),me(ce.slice(1)),te(0)):be&&ge(!1),K(C);const Se=C.map((Me,qe)=>qe===Q?{...Me,content:ce}:Me);t||x(Se),i?.(Se)},[C,t,i,K,W,be]),Ee=n.useCallback((p,Q)=>{ne(Q),p.dataTransfer.effectAllowed="move"},[]),ze=n.useCallback((p,Q)=>{p.preventDefault(),p.dataTransfer.dropEffect="move",ae(Q)},[]),Le=n.useCallback((p,Q)=>{if(p.preventDefault(),_e===null||_e===Q){ne(null),ae(null);return}ue(ce=>{const Se=[...ce],[Me]=Se.splice(_e,1);return Se.splice(Q>_e?Q-1:Q,0,Me),Se}),E(Q>_e?Q-1:Q),ne(null),ae(null)},[_e,ue]);n.useEffect(()=>{if(!d||!b){S([]);return}const p=b.toLowerCase(),Q=[];C.forEach((ce,Se)=>{const Me=(ce.content??"").toLowerCase();let qe=0;for(;qe<Me.length;){const Ze=Me.indexOf(p,qe);if(Ze===-1)break;Q.push({blockIdx:Se,start:Ze,end:Ze+p.length}),qe=Ze+1}}),S(Q),D(0)},[b,d,C]);const Ye=n.useCallback(()=>{if(_.length===0)return;const p=(m+1)%_.length;D(p),E(_[p].blockIdx)},[_,m]),Xe=n.useCallback(()=>{if(_.length===0)return;const p=(m-1+_.length)%_.length;D(p),E(_[p].blockIdx)},[_,m]),Ke=n.useCallback(()=>{if(_.length===0||!b)return;const p=_[m],Q=C[p.blockIdx],ce=Q.content.slice(0,p.start),Se=Q.content.slice(p.end);I(p.blockIdx,{content:ce+l+Se})},[_,m,b,l,C,I]),He=n.useCallback(()=>{if(!b)return;const p=b;ue(Q=>Q.map(ce=>({...ce,content:ce.content.split(p).join(l)})))},[b,l,ue]),Ce=n.useMemo(()=>B?C.map((p,Q)=>p.type==="heading"?{idx:Q,level:p.level??2,text:p.content}:null).filter(Boolean):[],[C,B]),Ne=n.useCallback(async p=>{const Q=p.target.files?.[0];if(Q){if(P){const ce=await P(Q);I(f,{src:ce})}p.target.value=""}},[P,f,I]);n.useEffect(()=>{const p=C[f];if(p){const Q=L.current.get(p.id);Q&&Q.focus()}},[f,C]);const Be=n.useCallback(()=>{const p=C.map(fi).join(`
|
|
14
|
-
`);T?.(p)},[C,T]),$e=n.useMemo(()=>X?yi(C):null,[C,X]),[De,Re]=n.useState(null),vt=n.useCallback((p,Q)=>{a||(p.preventDefault(),Re({x:p.clientX,y:p.clientY,idx:Q}))},[a]);return n.useEffect(()=>{if(!De)return;const p=()=>Re(null);return window.addEventListener("click",p),()=>window.removeEventListener("click",p)},[De]),e.jsxs("div",{ref:H,id:w,className:`nice-doc-editor nice-doc-editor--${c} nice-editor--${g} ${a?"nice-doc-editor--readonly":""} ${ie??""}`,style:{position:"relative",...ee},role:"application","aria-label":s("docEditor.label","Document Editor"),...G,children:[e.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:20},children:e.jsx(r.NiceTutorialButton,{steps:r.resolveTutorial(U,ui)})}),o&&!a&&e.jsxs("div",{ref:A,className:"nice-doc-editor__toolbar",role:"toolbar","aria-label":s("docEditor.toolbar","Formatting"),style:{display:"flex",flexWrap:"wrap",gap:4,alignItems:"center",padding:"4px 8px"},children:[e.jsx(Ie.NiceButton,{size:"sm",variant:"ghost",onClick:de,title:s("docEditor.undo","Undo (Ctrl+Z)"),ariaLabel:s("docEditor.undo","Undo (Ctrl+Z)"),children:e.jsx(r.NiceIcon,{name:"undo",size:"sm"})}),e.jsx(Ie.NiceButton,{size:"sm",variant:"ghost",onClick:he,title:s("docEditor.redo","Redo (Ctrl+Y)"),ariaLabel:s("docEditor.redo","Redo (Ctrl+Y)"),children:e.jsx(r.NiceIcon,{name:"redo",size:"sm"})}),e.jsx("span",{className:"nice-doc-editor__sep"}),e.jsx(We.NiceSelect,{size:"sm",value:C[f]?.type??"paragraph",onChange:p=>oe(f,p),label:"",options:[{value:"paragraph",label:s("docEditor.paragraph","Paragraph")},{value:"heading",label:s("docEditor.heading","Heading")},{value:"list",label:s("docEditor.list","List")},{value:"code",label:s("docEditor.code","Code")},{value:"quote",label:s("docEditor.quote","Quote")},{value:"callout",label:s("docEditor.callout","Callout")},{value:"toggle",label:s("docEditor.toggle","Toggle")},{value:"divider",label:s("docEditor.divider","Divider")},{value:"image",label:s("docEditor.image","Image")},{value:"video",label:s("docEditor.video","Video")},{value:"pageBreak",label:s("docEditor.pageBreak","Page Break")}],style:{minWidth:100}}),C[f]?.type==="heading"&&e.jsx(We.NiceSelect,{size:"sm",value:String(C[f]?.level??2),onChange:p=>I(f,{level:Number(p)}),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}}),C[f]?.type==="list"&&e.jsx(We.NiceSelect,{size:"sm",value:C[f]?.listType??"unordered",onChange:p=>I(f,{listType:p}),label:"",options:[{value:"unordered",label:s("docEditor.bullets","Bullets")},{value:"ordered",label:s("docEditor.numbers","Numbers")},{value:"checklist",label:s("docEditor.checklist","Checklist")}],style:{minWidth:90}}),e.jsx("span",{className:"nice-doc-editor__sep"}),e.jsx(Ie.NiceButton,{size:"sm",variant:C[f]?.bold?"primary":"ghost",onClick:()=>I(f,{bold:!C[f]?.bold}),title:s("docEditor.bold","Bold (Ctrl+B)"),children:e.jsx("strong",{children:"B"})}),e.jsx(Ie.NiceButton,{size:"sm",variant:C[f]?.italic?"primary":"ghost",onClick:()=>I(f,{italic:!C[f]?.italic}),title:s("docEditor.italic","Italic (Ctrl+I)"),children:e.jsx("em",{children:"I"})}),e.jsx(Ie.NiceButton,{size:"sm",variant:C[f]?.underline?"primary":"ghost",onClick:()=>I(f,{underline:!C[f]?.underline}),title:s("docEditor.underline","Underline (Ctrl+U)"),children:e.jsx("u",{children:"U"})}),e.jsx(Ie.NiceButton,{size:"sm",variant:C[f]?.strikethrough?"primary":"ghost",onClick:()=>I(f,{strikethrough:!C[f]?.strikethrough}),title:s("docEditor.strikethrough","Strikethrough (Ctrl+E)"),children:e.jsx("s",{children:"S"})}),e.jsx("span",{className:"nice-doc-editor__sep"}),e.jsx(Ie.NiceButton,{size:"sm",variant:C[f]?.align==="left"?"primary":"ghost",onClick:()=>I(f,{align:"left"}),title:s("docEditor.alignLeft","Left"),ariaLabel:s("docEditor.alignLeft","Left"),children:e.jsx(r.NiceIcon,{name:"align-left",size:"sm"})}),e.jsx(Ie.NiceButton,{size:"sm",variant:C[f]?.align==="center"?"primary":"ghost",onClick:()=>I(f,{align:"center"}),title:s("docEditor.alignCenter","Center"),ariaLabel:s("docEditor.alignCenter","Center"),children:e.jsx(r.NiceIcon,{name:"align-center",size:"sm"})}),e.jsx(Ie.NiceButton,{size:"sm",variant:C[f]?.align==="right"?"primary":"ghost",onClick:()=>I(f,{align:"right"}),title:s("docEditor.alignRight","Right"),ariaLabel:s("docEditor.alignRight","Right"),children:e.jsx(r.NiceIcon,{name:"align-right",size:"sm"})}),e.jsx("span",{className:"nice-doc-editor__sep"}),e.jsx(Ie.NiceButton,{size:"sm",variant:"ghost",onClick:()=>I(f,{indent:Math.min((C[f]?.indent??0)+1,4)}),title:s("docEditor.indent","Indent (Tab)"),ariaLabel:s("docEditor.indent","Indent (Tab)"),children:e.jsx(r.NiceIcon,{name:"indent",size:"sm"})}),e.jsx(Ie.NiceButton,{size:"sm",variant:"ghost",onClick:()=>I(f,{indent:Math.max((C[f]?.indent??0)-1,0)}),title:s("docEditor.outdent","Outdent (Shift+Tab)"),ariaLabel:s("docEditor.outdent","Outdent (Shift+Tab)"),children:e.jsx(r.NiceIcon,{name:"outdent",size:"sm"})}),e.jsx("span",{className:"nice-doc-editor__sep"}),e.jsx(Ot.NiceColorPicker,{size:"sm",label:"",value:C[f]?.color??"var(--nice-text-primary, #000000)",onChange:p=>I(f,{color:p}),title:s("docEditor.textColor","Text color")}),e.jsx(Ot.NiceColorPicker,{size:"sm",label:"",value:C[f]?.bgColor??"var(--nice-bg-primary, #ffffff)",onChange:p=>I(f,{bgColor:p}),title:s("docEditor.blockBackground","Block background")}),e.jsx("span",{className:"nice-doc-editor__sep"}),e.jsx(Ie.NiceButton,{size:"sm",variant:C[f]?.locked?"primary":"ghost",onClick:()=>I(f,{locked:!C[f]?.locked}),title:s("docEditor.lock","Lock/Unlock block"),ariaLabel:s("docEditor.lock","Lock/Unlock block"),children:e.jsx(r.NiceIcon,{name:C[f]?.locked?"lock":"unlock",size:"sm"})}),e.jsx(Ie.NiceButton,{size:"sm",variant:"ghost",onClick:()=>le(f),title:s("docEditor.duplicate","Duplicate (Ctrl+D)"),ariaLabel:s("docEditor.duplicate","Duplicate (Ctrl+D)"),children:e.jsx(r.NiceIcon,{name:"copy",size:"sm"})}),e.jsx(Ie.NiceButton,{size:"sm",variant:"ghost",onClick:()=>j(f),title:s("docEditor.delete","Delete block"),ariaLabel:s("docEditor.delete","Delete block"),children:e.jsx(r.NiceIcon,{name:"trash",size:"sm"})}),e.jsx(Ie.NiceButton,{size:"sm",variant:"ghost",onClick:()=>Y(f),title:s("docEditor.addBlock","Add block"),ariaLabel:s("docEditor.addBlock","Add block"),children:e.jsx(r.NiceIcon,{name:"plus",size:"sm"})}),$&&e.jsx(Ie.NiceButton,{size:"sm",variant:d?"primary":"ghost",onClick:()=>z(p=>!p),title:s("docEditor.find","Find & Replace (Ctrl+F)"),ariaLabel:s("docEditor.find","Find & Replace (Ctrl+F)"),children:e.jsx(r.NiceIcon,{name:"search",size:"sm"})}),e.jsx(Ie.NiceButton,{size:"sm",variant:"ghost",onClick:()=>V(p=>!p),title:s("docEditor.shortcuts","Keyboard shortcuts"),ariaLabel:s("docEditor.shortcuts","Keyboard shortcuts"),children:e.jsx(r.NiceIcon,{name:"keyboard",size:"sm"})}),T&&e.jsx(Ie.NiceButton,{size:"sm",variant:"ghost",onClick:Be,children:s("docEditor.export","Export HTML")})]}),e.jsx("input",{ref:N,type:"file",accept:"image/*,video/*",style:{display:"none"},onChange:Ne}),d&&e.jsxs("div",{className:"nice-doc-editor__find-bar",style:{display:"flex",gap:4,alignItems:"center",padding:"4px 8px",background:"var(--nice-bg-secondary, #f8f9fa)",borderBottom:"1px solid var(--nice-border-color, #ddd)"},children:[e.jsx(tt.NiceTextInput,{size:"sm",placeholder:s("docEditor.findPlaceholder","Find..."),value:b,onChange:h,style:{flex:1,maxWidth:200}}),e.jsx(tt.NiceTextInput,{size:"sm",placeholder:s("docEditor.replacePlaceholder","Replace..."),value:l,onChange:u,style:{flex:1,maxWidth:200}}),e.jsx(Ie.NiceButton,{size:"sm",variant:"ghost",onClick:Xe,title:s("docEditor.findPrev","Previous"),ariaLabel:s("docEditor.findPrev","Previous"),children:e.jsx(r.NiceIcon,{name:"chevron-up",size:"sm"})}),e.jsx(Ie.NiceButton,{size:"sm",variant:"ghost",onClick:Ye,title:s("docEditor.findNext","Next"),ariaLabel:s("docEditor.findNext","Next"),children:e.jsx(r.NiceIcon,{name:"chevron-down",size:"sm"})}),e.jsx(Ie.NiceButton,{size:"sm",variant:"ghost",onClick:Ke,title:s("docEditor.replaceOne","Replace"),disabled:a,children:s("docEditor.replace","Replace")}),e.jsx(Ie.NiceButton,{size:"sm",variant:"ghost",onClick:He,title:s("docEditor.replaceAll","Replace all"),disabled:a,children:s("docEditor.replaceAllBtn","All")}),e.jsx("span",{style:{fontSize:"0.75em",color:"var(--nice-text-muted, #666)"},children:_.length>0?`${m+1}/${_.length}`:"0/0"}),e.jsx(Ie.NiceButton,{size:"sm",variant:"ghost",onClick:()=>z(!1),title:s("docEditor.closeFind","Close"),ariaLabel:s("docEditor.closeFind","Close"),children:e.jsx(r.NiceIcon,{name:"close",size:"sm"})})]}),O&&e.jsx("div",{role:"presentation",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:()=>V(!1),children:e.jsxs("div",{role:"presentation",style:{background:"var(--nice-bg-primary, #fff)",borderRadius:8,padding:24,maxWidth:420,width:"90%",boxShadow:"0 8px 32px var(--nice-overlay-20, rgba(0, 0, 0, 0.2))"},onClick:p=>p.stopPropagation(),children:[e.jsx("h3",{style:{margin:"0 0 12px"},children:s("docEditor.shortcutsTitle","Keyboard Shortcuts")}),e.jsx("table",{style:{width:"100%",fontSize:"0.875em",borderCollapse:"collapse"},children:e.jsx("tbody",{children:[["Ctrl+B",s("docEditor.bold","Bold")],["Ctrl+I",s("docEditor.italic","Italic")],["Ctrl+U",s("docEditor.underline","Underline")],["Ctrl+E",s("docEditor.strikethrough","Strikethrough")],["Ctrl+D",s("docEditor.duplicate","Duplicate block")],["Ctrl+Z",s("docEditor.undo","Undo")],["Ctrl+Y",s("docEditor.redo","Redo")],["Ctrl+F",s("docEditor.find","Find & Replace")],["Enter",s("docEditor.newBlock","New block")],["Backspace",s("docEditor.deleteEmpty","Delete empty block")],["Alt+↑",s("docEditor.moveUp","Move block up")],["Alt+↓",s("docEditor.moveDown","Move block down")],["Tab",s("docEditor.indent","Indent")],["Shift+Tab",s("docEditor.outdent","Outdent")],["Esc, Tab",s("docEditor.leaveEditor","Leave the editor")],["/",s("docEditor.slashCmd","Slash commands")]].map(([p,Q])=>e.jsxs("tr",{style:{borderBottom:"1px solid var(--nice-border-color, #eee)"},children:[e.jsx("td",{style:{padding:"4px 8px",fontFamily:"monospace",fontWeight:600},children:p}),e.jsx("td",{style:{padding:"4px 8px"},children:Q})]},p))})}),e.jsx("div",{style:{textAlign:"right",marginTop:12},children:e.jsx(Ie.NiceButton,{size:"sm",variant:"ghost",onClick:()=>V(!1),children:s("docEditor.close","Close")})})]})}),e.jsxs("div",{style:{display:"flex",gap:0},children:[B&&Ce.length>0&&e.jsxs("nav",{className:"nice-doc-editor__toc",style:{width:200,minWidth:160,borderRight:"1px solid var(--nice-border-color, #eee)",padding:"8px 4px",fontSize:"0.8em",overflowY:"auto",maxHeight:500},children:[e.jsx("div",{style:{fontWeight:600,padding:"4px 8px",fontSize:"0.75em",textTransform:"uppercase",color:"var(--nice-text-muted, #999)"},children:s("docEditor.toc","Contents")}),Ce.map(p=>e.jsx("div",{role:"button",tabIndex:0,onKeyDown:r.clickOnActivationKey,style:{padding:"3px 8px",paddingLeft:8+(p.level-1)*12,cursor:"pointer",borderRadius:4,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",background:p.idx===f?"var(--nice-primary-bg, #e8f0fe)":void 0},onClick:()=>E(p.idx),title:p.text,children:p.text||s("docEditor.untitled","Untitled")},p.idx))]}),e.jsxs("div",{className:"nice-doc-editor__body",style:{flex:1},children:[!a&&e.jsx("span",{id:F,className:"nice-sr-only",children:s("input.tabEscapeHint","Tab indents. To leave the editor, press Escape, then Tab.")}),C.map((p,Q)=>e.jsxs("div",{role:"presentation",className:`nice-doc-editor__block nice-doc-editor__block--${p.type} ${Q===f?"nice-doc-editor__block--focused":""} ${we===Q?"nice-doc-editor__block--drop-target":""} ${p.locked?"nice-doc-editor__block--locked":""}`,onClick:()=>E(Q),onContextMenu:ce=>vt(ce,Q),draggable:!a&&!p.locked,onDragStart:ce=>Ee(ce,Q),onDragOver:ce=>ze(ce,Q),onDrop:ce=>Le(ce,Q),onDragEnd:()=>{ne(null),ae(null)},style:{opacity:_e===Q?.4:1,marginLeft:(p.indent??0)*24},children:[!a&&!p.locked&&e.jsx("div",{className:"nice-doc-editor__block-handle",title:s("docEditor.drag","Drag to reorder"),children:e.jsx(r.NiceIcon,{name:"grip",size:"sm"})}),p.locked&&e.jsx("span",{className:"nice-doc-editor__lock-icon",style:{position:"absolute",top:2,right:4,fontSize:"0.7em",opacity:.5},children:e.jsx(r.NiceIcon,{name:"lock",size:"sm"})}),p.type==="divider"?e.jsx("hr",{className:"nice-doc-editor__divider"}):p.type==="pageBreak"?e.jsxs("div",{className:"nice-doc-editor__page-break",style:{borderTop:"2px dashed var(--nice-border, #ccc)",textAlign:"center",padding:4,fontSize:"0.75em",color:"var(--nice-text-muted, #999)"},children:["— ",s("docEditor.pageBreak","Page Break")," —"]}):p.type==="image"||p.type==="video"?e.jsx("div",{className:"nice-doc-editor__media-block",children:p.src?p.type==="image"?e.jsx("img",{src:p.src,alt:p.alt??"",className:"nice-doc-editor__image",style:{maxWidth:"100%"}}):e.jsx("video",{src:p.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(tt.NiceTextInput,{size:"sm",placeholder:p.type==="image"?s("docEditor.imageUrl","Image URL"):s("docEditor.videoUrl","Video URL"),value:p.src??"",onChange:ce=>I(Q,{src:ce})}),P&&e.jsx(Ie.NiceButton,{size:"sm",variant:"ghost",onClick:()=>{E(Q),N.current?.click()},title:s("docEditor.upload","Upload file"),ariaLabel:s("docEditor.upload","Upload file"),children:e.jsx(r.NiceIcon,{name:"upload",size:"sm"})})]})}):p.type==="callout"?e.jsxs("div",{className:"nice-doc-editor__callout",style:{display:"flex",gap:8,padding:"8px 12px",background:p.bgColor??"var(--nice-info-bg, #f0f7ff)",borderRadius:4,color:p.color},children:[e.jsx("span",{style:{fontSize:"1.2em",display:"inline-flex"},children:p.icon??e.jsx(r.NiceIcon,{name:"info",size:"sm"})}),e.jsx("div",{ref:ce=>{ce&&L.current.set(p.id,ce)},className:"nice-doc-editor__content",contentEditable:!a&&!p.locked,suppressContentEditableWarning:!0,onInput:ce=>xe(ce,Q),onFocus:()=>E(Q),onKeyDown:ce=>ye(ce,Q),"data-placeholder":s("docEditor.calloutPlaceholder","Callout text..."),role:"textbox","aria-multiline":"true","aria-describedby":a?void 0:F,style:{flex:1,outline:"none"},children:p.content})]}):p.type==="toggle"?e.jsxs("details",{open:p.open,className:"nice-doc-editor__toggle",onToggle:ce=>I(Q,{open:ce.target.open}),children:[e.jsx("summary",{style:{cursor:"pointer",fontWeight:500},children:p.content.split(`
|
|
15
|
-
`)[0]||s("docEditor.toggleTitle","Toggle")}),e.jsx("div",{ref:ce=>{ce&&L.current.set(p.id,ce)},className:"nice-doc-editor__content",contentEditable:!a&&!p.locked,suppressContentEditableWarning:!0,onInput:ce=>xe(ce,Q),onFocus:()=>E(Q),onKeyDown:ce=>ye(ce,Q),role:"textbox","aria-multiline":"true","aria-describedby":a?void 0:F,style:{padding:"4px 0"},children:p.content.split(`
|
|
16
|
-
`).slice(1).join(`
|
|
17
|
-
`)})]}):p.type==="code"?e.jsxs("div",{className:"nice-doc-editor__code-block",style:{position:"relative"},children:[!a&&e.jsx(tt.NiceTextInput,{size:"sm",value:p.language??"",onChange:ce=>I(Q,{language:ce}),placeholder:s("docEditor.language","Language"),style:{position:"absolute",top:4,right:4,width:80,opacity:.7}}),e.jsx("pre",{ref:ce=>{ce&&L.current.set(p.id,ce)},className:"nice-doc-editor__content",contentEditable:!a&&!p.locked,suppressContentEditableWarning:!0,onInput:ce=>xe(ce,Q),onFocus:()=>E(Q),onKeyDown:ce=>ye(ce,Q),role:"textbox","aria-multiline":"true","aria-describedby":a?void 0:F,style:{fontFamily:"monospace",background:"var(--nice-bg-elevated, #1e1e1e)",color:"var(--nice-text-secondary, #d4d4d4)",padding:12,borderRadius:4,overflow:"auto"},children:p.content})]}):e.jsxs("div",{style:{position:"relative"},children:[e.jsx("div",{ref:ce=>{ce&&L.current.set(p.id,ce)},className:"nice-doc-editor__content",contentEditable:!a&&!p.locked,suppressContentEditableWarning:!0,style:{textAlign:p.align,fontWeight:p.bold?"bold":void 0,fontStyle:p.italic?"italic":void 0,textDecoration:[p.underline?"underline":"",p.strikethrough?"line-through":""].filter(Boolean).join(" ")||void 0,color:p.color,backgroundColor:p.bgColor},onInput:ce=>xe(ce,Q),onFocus:()=>E(Q),onKeyDown:ce=>ye(ce,Q),"data-placeholder":!p.content&&y?y:void 0,role:"textbox","aria-multiline":"true","aria-describedby":a?void 0:F,children:p.content}),be&&Q===f&&ve.length>0&&e.jsx("ul",{className:"nice-doc-editor__slash-menu",style:{position:"absolute",left:0,top:"100%",zIndex:100,background:"var(--nice-bg-primary, #fff)",border:"1px solid var(--nice-border-color, #ddd)",borderRadius:6,boxShadow:"0 4px 16px var(--nice-overlay-12, rgba(0, 0, 0, 0.12))",listStyle:"none",margin:0,padding:4,minWidth:180,maxHeight:240,overflow:"auto"},children:ve.map((ce,Se)=>e.jsxs("li",{role:"presentation",className:Se===pe?"nice-doc-editor__slash-item--active":"",style:{padding:"6px 10px",cursor:"pointer",borderRadius:4,display:"flex",gap:8,alignItems:"center",background:Se===pe?"var(--nice-primary-bg, #e8f0fe)":void 0},onMouseDown:Me=>{Me.preventDefault(),se(ce)},onMouseEnter:()=>te(Se),children:[e.jsx("span",{style:{width:24,display:"inline-flex",justifyContent:"center"},children:e.jsx(r.NiceIcon,{name:ce.icon,size:"sm"})}),e.jsx("span",{children:ce.label})]},`${ce.type}-${ce.label}`))})]})]},p.id))]})]}),De&&e.jsxs("div",{className:"nice-doc-editor__ctx-menu",style:{position:"fixed",left:De.x,top:De.y,zIndex:1e3,background:"var(--nice-bg-primary, #fff)",border:"1px solid var(--nice-border-color, #ddd)",borderRadius:6,boxShadow:"0 4px 16px var(--nice-overlay-12, rgba(0, 0, 0, 0.12))",padding:4,minWidth:160},children:[e.jsxs("div",{role:"button",tabIndex:0,onKeyDown:r.clickOnActivationKey,style:{padding:"6px 12px",cursor:"pointer"},onClick:()=>{le(De.idx),Re(null)},children:[e.jsx(r.NiceIcon,{name:"copy",size:"sm"})," ",s("docEditor.duplicate2","Duplicate")]}),e.jsxs("div",{role:"button",tabIndex:0,onKeyDown:r.clickOnActivationKey,style:{padding:"6px 12px",cursor:"pointer"},onClick:()=>{Y(De.idx),Re(null)},children:[e.jsx(r.NiceIcon,{name:"plus",size:"sm"})," ",s("docEditor.insertBelow","Insert below")]}),e.jsxs("div",{role:"button",tabIndex:0,onKeyDown:r.clickOnActivationKey,style:{padding:"6px 12px",cursor:"pointer"},onClick:()=>{Z(De.idx,-1),Re(null)},children:[e.jsx(r.NiceIcon,{name:"arrow-up",size:"sm"})," ",s("docEditor.moveUp2","Move up")]}),e.jsxs("div",{role:"button",tabIndex:0,onKeyDown:r.clickOnActivationKey,style:{padding:"6px 12px",cursor:"pointer"},onClick:()=>{Z(De.idx,1),Re(null)},children:[e.jsx(r.NiceIcon,{name:"arrow-down",size:"sm"})," ",s("docEditor.moveDown2","Move down")]}),e.jsxs("div",{role:"button",tabIndex:0,onKeyDown:r.clickOnActivationKey,style:{padding:"6px 12px",cursor:"pointer"},onClick:()=>{I(De.idx,{locked:!C[De.idx]?.locked}),Re(null)},children:[e.jsx(r.NiceIcon,{name:C[De.idx]?.locked?"unlock":"lock",size:"sm"})," ",C[De.idx]?.locked?s("docEditor.unlock","Unlock"):s("docEditor.lock2","Lock")]}),e.jsx("hr",{style:{margin:"2px 0",border:"none",borderTop:"1px solid var(--nice-border-color, #eee)"}}),e.jsxs("div",{role:"button",tabIndex:0,onKeyDown:r.clickOnActivationKey,style:{padding:"6px 12px",cursor:"pointer",color:"var(--nice-danger-dark, #d32f2f)"},onClick:()=>{j(De.idx),Re(null)},children:[e.jsx(r.NiceIcon,{name:"trash",size:"sm"})," ",s("docEditor.delete2","Delete")]})]}),X&&$e&&e.jsxs("div",{className:"nice-doc-editor__footer",style:{padding:"4px 12px",fontSize:"0.75em",color:"var(--nice-text-muted, #666)",borderTop:"1px solid var(--nice-border-color, #eee)",display:"flex",gap:16},children:[e.jsxs("span",{children:[$e.words," ",s("docEditor.words","words")]}),e.jsxs("span",{children:[$e.chars," ",s("docEditor.chars","characters")]}),e.jsxs("span",{children:[C.length," ",s("docEditor.blocks","blocks")]}),e.jsxs("span",{children:["~",$e.readingTime," ",s("docEditor.readingTime","min read")]})]})]})}),{displayName:"NiceDocumentEditor"}),bi=[],ji=Object.assign(n.forwardRef(({label:t,helperText:i,error:a,disabled:o,readOnly:c,size:g="md",id:y,className:T,style:P,accessMode:M,pages:W=bi,selectedPageId:X,content:B="",contentFormat:$="html",editing:U=!1,onPageSelect:ie,onContentChange:ee,onSave:re,onCreatePage:G,onDeletePage:H,onEditToggle:w,onVersionHistory:s,sidebarWidth:R=260,sidebarCollapsed:F=!1,onSidebarToggle:A,searchable:k=!0,onSearch:x},C)=>{const f=r.useNiceAccessMode(M,y),E=f==="hidden";f==="disabled"&&(o=!0),f==="readOnly"&&(c=!0);const{t:L}=r.useNiceTranslation(),N=r.useControlId(y),[d,z]=n.useState(""),[b,h]=n.useState(""),[l,u]=n.useState(!1),_=n.useMemo(()=>{const V=v=>{for(const q of v){if(q.id===X)return q;if(q.children){const K=V(q.children);if(K)return K}}};return V(W)},[W,X]),S=n.useCallback(V=>{z(V),x?.(V)},[x]),m=n.useCallback(()=>{b.trim()&&(G?.(X??null,b.trim()),h(""),u(!1))},[b,X,G]),D=n.useRef(null);r.useTreeFocus(D,{rowSelector:".nice-wiki__tree-node",onToggle:()=>{}});const O=(V,v=0)=>e.jsx("ul",{className:"nice-wiki__tree",role:v>0?"group":"none",style:{paddingLeft:v>0?16:0},children:V.map(q=>e.jsxs("li",{className:"nice-wiki__tree-item",role:"treeitem","aria-label":q.title,"aria-selected":q.id===X,children:[e.jsxs("div",{role:"button",tabIndex:0,onKeyDown:r.clickOnActivationKey,className:`nice-wiki__tree-node${q.id===X?" nice-wiki__tree-node--active":""}${q.isDraft?" nice-wiki__tree-node--draft":""}`,onClick:()=>ie?.(q),children:[e.jsx("span",{className:"nice-wiki__tree-icon",children:e.jsx(r.NiceIcon,{name:q.children?.length?"folder":"file",size:14})}),e.jsx("span",{className:"nice-wiki__tree-title",children:q.title}),q.isDraft&&e.jsx("span",{className:"nice-wiki__tree-draft",children:L("draft","Draft")})]}),q.children&&q.children.length>0&&O(q.children,v+1)]},q.id))});return E?null:e.jsxs("div",{ref:C,id:N,className:`nice-wiki nice-size-${g}${T?` ${T}`:""}${o?" nice-disabled":""}`,style:P,children:[!F&&e.jsxs("aside",{className:"nice-wiki__sidebar",style:{width:R},children:[e.jsxs("div",{className:"nice-wiki__sidebar-header",children:[e.jsx("span",{className:"nice-wiki__sidebar-title",children:t??L("wiki","Wiki")}),A&&e.jsx("button",{type:"button",className:"nice-wiki__sidebar-toggle",onClick:()=>A(!0),"aria-label":L("collapseSidebar","Collapse sidebar"),children:e.jsx(r.NiceIcon,{name:"chevron-left",size:16})})]}),k&&e.jsx("input",{type:"text",className:"nice-input nice-wiki__search",value:d,onChange:V=>S(V.target.value),placeholder:L("searchPages","Search pages…"),disabled:o}),e.jsx("div",{ref:D,className:"nice-wiki__page-tree",role:"tree","aria-label":t??L("wiki","Wiki"),children:O(W)}),G&&!c&&e.jsx("div",{className:"nice-wiki__sidebar-footer",children:l?e.jsxs("div",{className:"nice-wiki__create-form",children:[e.jsx("input",{type:"text",className:"nice-input",value:b,onChange:V=>h(V.target.value),placeholder:L("pageTitle","Page title"),onKeyDown:V=>V.key==="Enter"&&m(),disabled:o}),e.jsx("button",{type:"button",disabled:o||!b.trim(),onClick:m,"aria-label":L("create","Create"),children:e.jsx(r.NiceIcon,{name:"check",size:14})}),e.jsx("button",{type:"button",onClick:()=>u(!1),"aria-label":L("cancel","Cancel"),children:e.jsx(r.NiceIcon,{name:"close",size:14})})]}):e.jsxs("button",{type:"button",className:"nice-wiki__add-page",onClick:()=>u(!0),disabled:o,children:[e.jsx(r.NiceIcon,{name:"plus",size:14})," ",L("newPage","New page")]})})]}),F&&A&&e.jsx("button",{type:"button",className:"nice-wiki__sidebar-expand",onClick:()=>A(!1),"aria-label":L("expandSidebar","Expand sidebar"),children:e.jsx(r.NiceIcon,{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:[w&&!c&&e.jsx("button",{type:"button",disabled:o,onClick:()=>w(!U),children:U?L("preview","Preview"):L("edit","Edit")}),s&&e.jsx("button",{type:"button",disabled:o,onClick:()=>s(_.id),children:L("history","History")}),H&&!c&&e.jsx("button",{type:"button",className:"nice-btn--danger",disabled:o,onClick:()=>H(_.id),children:L("delete","Delete")})]})]}),_.updatedAt&&e.jsxs("div",{className:"nice-wiki__page-meta",children:[_.updatedBy&&e.jsxs("span",{children:[L("lastEditedBy","Last edited by")," ",_.updatedBy]}),e.jsx("span",{children:new Date(_.updatedAt).toLocaleDateString()})]}),U?e.jsxs("div",{className:"nice-wiki__editor",children:[e.jsx("textarea",{className:"nice-wiki__editor-textarea",value:B,onChange:V=>ee?.(V.target.value),disabled:o}),re&&e.jsx("button",{type:"button",className:"nice-btn nice-btn--primary",disabled:o,onClick:()=>re(_.id,B),children:L("save","Save")})]}):e.jsx("div",{className:"nice-wiki__viewer",children:$==="html"?e.jsx("div",{className:"nice-wiki__html",dangerouslySetInnerHTML:{__html:r.sanitizeHtml(B)}}):e.jsx("pre",{className:"nice-wiki__markdown",children:B})})]}):e.jsx("div",{className:"nice-wiki__empty",children:e.jsx("p",{children:L("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})]})}),{displayName:"NiceWiki"}),vi=n.forwardRef(function(i,a){const{enableAI:o=!0,aiModel:c,enableInlineCompletion:g=!0,completionDelay:y=500,enableExplain:T=!0,enableRefactor:P=!0,enableGenerate:M=!0,systemPrompt:W,onExplain:X,onRefactor:B,showAIToolbar:$=!0,aiShortcutKey:U="Ctrl",language:ie="plaintext",value:ee,onChange:re,onCursorPositionChange:G,...H}=i,w=n.useRef(null),[s,R]=n.useState(null),[F,A]=n.useState(!1),[k,x]=n.useState(""),[C,f]=n.useState(!1),[E,L]=n.useState(""),[N,d]=n.useState(""),[z,b]=n.useState(""),h=n.useRef(void 0),{t:l}=on.useNiceTranslation(),u=r.useNiceAI(),{complete:_,explain:S,refactor:m,generateFromComment:D,isLoading:O}=r.useCodeCompletion({language:ie,model:c}),V=o&&u.isConfigured,v=n.useCallback(async()=>{if(!V||!g||!w.current||!w.current.getEditor())return;const pe=w.current.getCursorPosition(),ve=w.current.getValue().split(`
|
|
18
|
-
`),_e=ve.slice(0,pe.lineNumber-1),ne=ve[pe.lineNumber-1]||"",we=[..._e,ne.slice(0,pe.column-1)].join(`
|
|
19
|
-
`),ae=[ne.slice(pe.column-1),...ve.slice(pe.lineNumber)].join(`
|
|
20
|
-
`);try{const ue=await _(we,ae);ue&&R({lineNumber:pe.lineNumber,column:pe.column,text:ue})}catch{}},[V,g,_]),q=n.useCallback(async()=>{if(!V||!T||!w.current)return"";const me=w.current.getSelection();if(!me)return"";b(me),A(!0),x("");try{const pe=await S(me);return x(pe),X?.(me,pe),pe}catch{return x(l("codeEditorAI.explanationFailed","Failed to explain code")),""}},[V,T,S,X,l]),K=n.useCallback(async me=>{if(!V||!P||!w.current)return"";const pe=w.current.getSelection();if(!pe)return"";try{const te=await m(pe,me);return d(te),B?.(pe,te),te}catch{return""}},[V,P,m,B]),de=n.useCallback(async()=>{if(!V||!M||!w.current)return;const me=w.current.getCursorPosition(),te=w.current.getValue().split(`
|
|
21
|
-
`);let ve="";for(let _e=me.lineNumber-1;_e>=0&&_e>=me.lineNumber-3;_e--){const ne=te[_e]?.trim()||"";if(ne.startsWith("//")||ne.startsWith("#")||ne.startsWith("/*")||ne.startsWith("*")){ve=ne.replace(/^\/\/\s*|^#\s*|^\/\*\s*|\*\/\s*$|^\*\s*/g,"").trim();break}}if(ve)try{const _e=await D(ve);_e&&w.current&&w.current.insertText(`
|
|
22
|
-
`+_e)}catch{}},[V,M,D]),he=n.useCallback(()=>{!s||!w.current||(w.current.insertText(s.text),R(null))},[s]),be=n.useCallback(()=>{R(null)},[]),ge=n.useCallback(me=>{G?.(me),!(!V||!g)&&(h.current&&clearTimeout(h.current),R(null),h.current=setTimeout(()=>{v()},y))},[G,V,g,y,v]);n.useEffect(()=>{if(!w.current?.getEditor()||!V)return;const pe=te=>{if(U==="Ctrl"&&te.ctrlKey||U==="Alt"&&te.altKey||U==="Meta"&&te.metaKey){if(te.key===" "&&g&&(te.preventDefault(),v()),te.key==="e"&&T&&(te.preventDefault(),q()),te.key==="r"&&P){te.preventDefault();const _e=w.current?.getSelection();_e&&(b(_e),f(!0))}te.key==="g"&&M&&(te.preventDefault(),de())}te.key==="Tab"&&s&&(te.preventDefault(),he()),te.key==="Escape"&&s&&be()};return window.addEventListener("keydown",pe),()=>window.removeEventListener("keydown",pe)},[V,U,g,T,P,M,v,q,de,s,he,be]),n.useEffect(()=>()=>{h.current&&clearTimeout(h.current)},[]);const fe=n.useCallback(()=>{if(!N||!w.current)return;const me=w.current.getEditor();if(me?.executeEdits&&me?.getSelection){const pe=me.getSelection();me.executeEdits("ai-refactor",[{range:pe,text:N}])}f(!1),d(""),L("")},[N]);return n.useImperativeHandle(a,()=>({...w.current,getEditor:()=>w.current?.getEditor(),getMonaco:()=>w.current?.getMonaco(),focus:()=>w.current?.focus(),getValue:()=>w.current?.getValue()||"",setValue:me=>w.current?.setValue(me),getSelection:()=>w.current?.getSelection()||"",insertText:me=>w.current?.insertText(me),formatDocument:()=>w.current?.formatDocument(),goToLine:(me,pe)=>w.current?.goToLine(me,pe),findReplace:()=>w.current?.findReplace(),undo:()=>w.current?.undo(),redo:()=>w.current?.redo(),getCursorPosition:()=>w.current?.getCursorPosition()||{lineNumber:1,column:1},setMarkers:me=>w.current?.setMarkers(me),triggerCompletion:v,explainSelection:q,refactorSelection:K,generateFromComment:de,acceptCompletion:he,dismissCompletion:be})),e.jsxs("div",{className:"nice-code-editor-ai","data-testid":i["data-testid"],children:[$&&V&&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:l("codeEditorAI.ai","AI")}),O&&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:[g&&e.jsxs("button",{type:"button",className:"nice-code-editor-ai__toolbar-btn",onClick:()=>v(),disabled:O,title:`${l("codeEditorAI.complete","Complete")} (${U}+Space)`,children:[e.jsx(r.NiceIcon,{name:"lightbulb",size:14})," ",l("codeEditorAI.complete","Complete")]}),T&&e.jsxs("button",{type:"button",className:"nice-code-editor-ai__toolbar-btn",onClick:()=>q(),disabled:O,title:`${l("codeEditorAI.explain","Explain")} (${U}+E)`,children:[e.jsx(r.NiceIcon,{name:"book",size:14})," ",l("codeEditorAI.explain","Explain")]}),P&&e.jsxs("button",{type:"button",className:"nice-code-editor-ai__toolbar-btn",onClick:()=>{const me=w.current?.getSelection();me&&(b(me),f(!0))},disabled:O,title:`${l("codeEditorAI.refactor","Refactor")} (${U}+R)`,children:[e.jsx(r.NiceIcon,{name:"settings",size:14})," ",l("codeEditorAI.refactor","Refactor")]}),M&&e.jsxs("button",{type:"button",className:"nice-code-editor-ai__toolbar-btn",onClick:()=>de(),disabled:O,title:`${l("codeEditorAI.generate","Generate")} (${U}+G)`,children:[e.jsx(r.NiceIcon,{name:"zap",size:14})," ",l("codeEditorAI.generate","Generate")]})]})]}),e.jsxs("div",{className:"nice-code-editor-ai__editor-wrapper",children:[e.jsx(Et.NiceCodeEditor,{ref:w,value:ee,onChange:re,language:ie,onCursorPositionChange:ge,...H}),s&&e.jsxs("div",{className:"nice-code-editor-ai__ghost-text",style:{top:`calc(${(s.lineNumber-1)*19}px + 4px)`,left:`calc(${(s.column-1)*7.8}px + 60px)`},children:[e.jsx("span",{className:"nice-code-editor-ai__ghost-text-content",children:s.text}),e.jsx("span",{className:"nice-code-editor-ai__ghost-text-hint",children:l("codeEditorAI.tab","Tab {accept}").replace("{accept}",String(l("codeEditorAI.toAccept","to accept")))})]})]}),F&&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(r.NiceIcon,{name:"book",size:16})," ",l("codeEditorAI.explanation","Explanation")]}),e.jsx("button",{type:"button",className:"nice-code-editor-ai__panel-close",onClick:()=>A(!1),"aria-label":l("codeEditorAI.close","Close"),children:e.jsx(r.NiceIcon,{name:"close",size:14})})]}),e.jsx("div",{className:"nice-code-editor-ai__panel-body",children:O?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:z}),e.jsx("div",{className:"nice-code-editor-ai__explanation-text",children:k||l("codeEditorAI.noExplanation","Select code and click Explain")})]})})]}),C&&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(r.NiceIcon,{name:"settings",size:16})," ",l("codeEditorAI.refactorCode","Refactor Code")]}),e.jsx("button",{type:"button",className:"nice-code-editor-ai__panel-close",onClick:()=>{f(!1),d(""),L("")},"aria-label":l("codeEditorAI.close","Close"),children:e.jsx(r.NiceIcon,{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:z}),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:E,onChange:me=>L(me.target.value),onKeyDown:me=>{me.key==="Enter"&&E&&K(E)}}),e.jsx("button",{type:"button",className:"nice-code-editor-ai__refactor-btn",onClick:()=>K(E),disabled:O||!E,children:O?l("codeEditorAI.refactoring","Refactoring..."):l("codeEditorAI.refactor","Refactor")})]}),N&&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:N}),e.jsxs("div",{className:"nice-code-editor-ai__refactor-actions",children:[e.jsxs("button",{type:"button",className:"nice-code-editor-ai__refactor-apply",onClick:fe,children:[e.jsx(r.NiceIcon,{name:"check",size:14})," ",l("codeEditorAI.apply","Apply")]}),e.jsxs("button",{type:"button",className:"nice-code-editor-ai__refactor-discard",onClick:()=>{d(""),L("")},children:[e.jsx(r.NiceIcon,{name:"close",size:14})," ",l("codeEditorAI.discard","Discard")]})]})]})]})]})]})}),_i=[];function ki(t){const i=t instanceof Date?t:new Date(t),a=(o,c=2)=>String(o).padStart(c,"0");return`${a(i.getHours())}:${a(i.getMinutes())}:${a(i.getSeconds())}.${a(i.getMilliseconds(),3)}`}function wi(t){if(typeof t=="string")return t;try{return JSON.stringify(t,null,2)}catch{return String(t)}}const xn=n.forwardRef(function(i,a){const{t:o}=r.useNiceTranslation();jt.injectStyleOnce(Ni,Ci);const{entries:c=_i,maxHeight:g=240,autoScroll:y=!0,showTimestamps:T=!0,levelFilter:P,onClear:M,title:W,emptyText:X=o("logConsole.noOutput","No output"),clearLabel:B=o("logConsole.clear","Clear"),fontFamily:$,className:U,style:ie,id:ee,"data-testid":re}=i,G=n.useRef(null),H=n.useMemo(()=>{if(!P||P.length===0)return c;const R=new Set(P);return c.filter(F=>R.has(F.level??"log"))},[c,P]);n.useEffect(()=>{y&&G.current&&(G.current.scrollTop=G.current.scrollHeight)},[H.length,y]);const w=!!W||!!M,s="nice-log-console"+(U?` ${U}`:"");return e.jsxs("div",{ref:a,id:ee,className:s,style:{...$?{fontFamily:$}:null,...ie},"data-testid":re,children:[w&&e.jsxs("div",{className:"nice-log-console__header",children:[e.jsx("span",{className:"nice-log-console__title",children:W}),M&&e.jsx("button",{type:"button",className:"nice-log-console__clear",onClick:M,"aria-label":B,children:B})]}),e.jsx("div",{ref:G,className:"nice-log-console__body",style:{maxHeight:typeof g=="number"?`${g}px`:g},role:"log","aria-live":"polite","aria-relevant":"additions",children:H.length===0?e.jsx("div",{className:"nice-log-console__empty",children:X}):H.map((R,F)=>{const A=R.level??"log";return e.jsxs("div",{className:`nice-log-console__entry nice-log-console__entry--${A}`,children:[T&&R.timestamp!=null&&e.jsx("span",{className:"nice-log-console__time",children:ki(R.timestamp)}),e.jsx("span",{className:"nice-log-console__level",children:A}),R.source&&e.jsx("span",{className:"nice-log-console__source",children:R.source}),e.jsx("span",{className:"nice-log-console__message",children:R.message}),R.data!==void 0&&e.jsx("pre",{className:"nice-log-console__data",children:wi(R.data)})]},F)})})]})}),Ni="nice-log-console-styles",Ci=`
|
|
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-border-color, #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
|
-
`,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 Vt(t){if(t===void 0)return"";if(typeof t=="string")return t;try{return JSON.stringify(t,null,2)}catch{return String(t)}}function Wt(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 $i=n.forwardRef(function(i,a){const{t:o}=r.useNiceTranslation();jt.injectStyleOnce(Ii,Mi);const{value:c,defaultValue:g,onChange:y,language:T="javascript",onRun:P,input:M,onInputChange:W,showInputPanel:X,extraLibs:B,height:$=260,running:U,autoRun:ie=!1,autoRunDelay:ee=600,layout:re="vertical",runLabel:G=o("scriptRunner.run","Run"),theme:H="auto",tutorial:w,className:s,style:R,id:F,"data-testid":A}=i,[k,x]=r.useControllableState({value:c,defaultValue:g,fallbackValue:"",onChange:y,componentName:"NiceScriptRunner"}),C=X??M!==void 0,[f,E]=n.useState(()=>Vt(M)),[L,N]=n.useState(null),[d,z]=n.useState(!1),[b,h]=n.useState(null),l=U??d,u=H==="light"?"vs":H==="dark"?"vs-dark":H;n.useEffect(()=>{E(Vt(M))},[M]);const _=n.useCallback(async()=>{const V=Wt(f),v=typeof performance<"u"?performance.now():Date.now();U===void 0&&z(!0);try{const q=await P(k,V.value),K=q.durationMs??Math.round((typeof performance<"u"?performance.now():Date.now())-v);h({...q,durationMs:K})}catch(q){h({ok:!1,error:q instanceof Error?q.message:String(q),durationMs:Math.round((typeof performance<"u"?performance.now():Date.now())-v)})}finally{U===void 0&&z(!1)}},[f,P,k,U]),S=n.useRef(_);S.current=_,n.useEffect(()=>{if(!ie)return;const V=setTimeout(()=>{S.current()},ee);return()=>clearTimeout(V)},[ie,ee,k,f]);const m=n.useCallback(V=>{E(V);const v=Wt(V);N(v.error),W?.(v.value)},[W]),D=typeof $=="number"?`${$}px`:$,O=`nice-script-runner nice-script-runner--${re}`+(s?` ${s}`:"");return e.jsxs("div",{ref:a,id:F,className:O,style:R,"data-testid":A,children:[e.jsxs("div",{className:"nice-script-runner__toolbar",children:[e.jsxs("button",{type:"button",className:"nice-script-runner__run",onClick:()=>void _(),disabled:l,children:[l?"…":e.jsx(r.NiceIcon,{name:"play",size:14})," ",G]}),b?.durationMs!=null&&e.jsxs("span",{className:"nice-script-runner__status",children:[e.jsx("span",{className:"nice-script-runner__badge nice-script-runner__badge--"+(b.ok?"ok":"error"),children:b.ok?o("scriptRunner.ok","OK"):o("scriptRunner.failed","Failed")}),e.jsxs("span",{className:"nice-script-runner__duration",children:[b.durationMs," ms"]})]}),w&&e.jsx("span",{style:{marginLeft:"auto"},children:e.jsx(r.NiceTutorialButton,{steps:r.resolveTutorial(w,Si)})})]}),e.jsxs("div",{className:"nice-script-runner__panes",children:[e.jsxs("div",{className:"nice-script-runner__editors",children:[e.jsx(Et.NiceCodeEditor,{value:k,onChange:x,language:T,theme:u,height:D,extraLibs:B,options:{minimap:!1}}),C&&e.jsxs("div",{className:"nice-script-runner__input",children:[e.jsxs("div",{className:"nice-script-runner__pane-label",children:[o("scriptRunner.inputJson","Input (JSON)"),L&&e.jsxs("span",{className:"nice-script-runner__input-error",children:[" — ",L]})]}),e.jsx(Et.NiceCodeEditor,{value:f,onChange:m,language:"json",theme:u,height:120,options:{minimap:!1,lineNumbers:"off"}})]})]}),e.jsxs("div",{className:"nice-script-runner__output",children:[b?.error&&e.jsx("div",{className:"nice-script-runner__error",children:b.error}),b&&b.result!==void 0&&e.jsxs("div",{className:"nice-script-runner__result",children:[e.jsx("div",{className:"nice-script-runner__pane-label",children:o("scriptRunner.result","Result")}),e.jsx("pre",{className:"nice-script-runner__result-body",children:Ei(b.result)})]}),e.jsx(xn,{title:o("scriptRunner.logs","Logs"),entries:b?.logs??[],maxHeight:160,emptyText:"Run the script to see logs"})]})]})]})}),Ii="nice-script-runner-styles",Mi=`
|
|
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
|
-
`,Ti=[{target:".nice-key-value-editor",titleKey:"tutorial.keyValueEditor.intro.title",title:"Key/value editor",contentKey:"tutorial.keyValueEditor.intro.content",content:"Add key/value rows for headers, params, env vars or config; mask secret values, toggle rows on/off, and watch for duplicate keys.",placement:"auto"}],Ri=n.forwardRef(function(i,a){const{t:o}=r.useNiceTranslation();jt.injectStyleOnce(Ai,Di);const{value:c,defaultValue:g,onChange:y,allowSecret:T=!1,allowToggle:P=!1,allowDescription:M=!1,keySuggestions:W,keyPlaceholder:X=o("keyValueEditor.key","Key"),valuePlaceholder:B=o("keyValueEditor.value","Value"),addLabel:$=o("keyValueEditor.add","Add"),readOnly:U=!1,duplicateKeyWarning:ie=!0,tutorial:ee,className:re,style:G,id:H,"data-testid":w}=i,[s,R]=r.useControllableState({value:c,defaultValue:g,fallbackValue:[],onChange:y,componentName:"NiceKeyValueEditor"}),F=n.useMemo(()=>`nice-kv-keys-${Math.random().toString(36).slice(2,9)}`,[]),A=n.useMemo(()=>{const E=new Map,L=new Set;if(ie){for(const N of s){const d=N.key.trim();d!==""&&E.set(d,(E.get(d)??0)+1)}E.forEach((N,d)=>{N>1&&L.add(d)})}return L},[s,ie]),k=(E,L)=>{R(s.map((N,d)=>d===E?{...N,...L}:N))},x=E=>{R(s.filter((L,N)=>N!==E))},C=()=>{R([...s,{key:"",value:"",type:"text",enabled:!0}])},f="nice-key-value-editor"+(re?` ${re}`:"");return e.jsxs("div",{ref:a,id:H,className:f,style:{position:"relative",...G},"data-testid":w,children:[e.jsx("span",{style:{position:"absolute",top:0,right:0,zIndex:20},children:e.jsx(r.NiceTutorialButton,{steps:r.resolveTutorial(ee,Ti)})}),W&&W.length>0&&e.jsx("datalist",{id:F,children:W.map(E=>e.jsx("option",{value:E},E))}),e.jsx("div",{className:"nice-key-value-editor__rows",children:s.map((E,L)=>{const N=E.type==="secret",d=E.key.trim()!==""&&A.has(E.key.trim()),z=P&&E.enabled===!1;return e.jsxs("div",{className:"nice-key-value-editor__row"+(z?" nice-key-value-editor__row--disabled":""),children:[P&&e.jsx("input",{type:"checkbox",className:"nice-key-value-editor__toggle",checked:E.enabled!==!1,onChange:b=>k(L,{enabled:b.target.checked}),disabled:U,"aria-label":o("keyValueEditor.enabled","Enabled")}),e.jsx("input",{type:"text",className:"nice-key-value-editor__key"+(d?" nice-key-value-editor__key--dup":""),value:E.key,list:W?F:void 0,placeholder:X,onChange:b=>k(L,{key:b.target.value}),readOnly:U,"aria-label":X,title:d?o("keyValueEditor.duplicateKey","Duplicate key"):void 0}),e.jsx("input",{type:N?"password":"text",className:"nice-key-value-editor__value",value:E.value,placeholder:B,onChange:b=>k(L,{value:b.target.value}),readOnly:U,autoComplete:N?"new-password":"off","aria-label":B}),T&&e.jsx("button",{type:"button",className:"nice-key-value-editor__secret"+(N?" nice-key-value-editor__secret--on":""),onClick:()=>k(L,{type:N?"text":"secret"}),disabled:U,title:N?o("keyValueEditor.secretClickToRevealAs","Secret (click to reveal as text)"):o("keyValueEditor.markAsSecret","Mark as secret"),"aria-pressed":N,"aria-label":o("keyValueEditor.toggleSecret","Toggle secret"),children:e.jsx(r.NiceIcon,{name:"lock",size:16})}),M&&e.jsx("input",{type:"text",className:"nice-key-value-editor__desc",value:E.description??"",placeholder:o("keyValueEditor.description","Description"),onChange:b=>k(L,{description:b.target.value}),readOnly:U,"aria-label":o("keyValueEditor.description","Description")}),!U&&e.jsx("button",{type:"button",className:"nice-key-value-editor__remove",onClick:()=>x(L),title:o("keyValueEditor.removeRow","Remove row"),"aria-label":o("keyValueEditor.removeRow","Remove row"),children:e.jsx(r.NiceIcon,{name:"close",size:14})})]},E.id??L)})}),!U&&e.jsxs("button",{type:"button",className:"nice-key-value-editor__add",onClick:C,children:["+ ",$]})]})}),Ai="nice-key-value-editor-styles",Di=`
|
|
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
|
-
`,zi=["street","streetNumber","apartment","city","postalCode","state","country"],ht={street:"Street",streetNumber:"Number",apartment:"Apt/Suite",city:"City",postalCode:"Postal Code",state:"State/Province",country:"Country"},Li=Object.assign(n.forwardRef(({label:t,helperText:i,error:a,required:o,disabled:c,readOnly:g,size:y="md",name:T,id:P,className:M,style:W,accessMode:X,value:B={},onChange:$,fields:U=zi,placeholders:ie={},countries:ee,layout:re="vertical",countryFirst:G=!1,validatePostalCode:H},w)=>{const s=r.useNiceAccessMode(X,P),R=s==="hidden";s==="disabled"&&(c=!0),s==="readOnly"&&(g=!0);const{t:F}=r.useNiceTranslation(),A=r.useControlId(P),k=n.useCallback((E,L)=>{$?.({...B,[E]:L})},[B,$]),x=n.useMemo(()=>{if(H&&B.postalCode)return H(B.postalCode,B.country)},[H,B.postalCode,B.country]),C=n.useMemo(()=>G&&U.includes("country")?["country",...U.filter(E=>E!=="country")]:U,[U,G]),f=`nice-address nice-address--${re} nice-size-${y}`;return R?null:e.jsxs("div",{ref:w,id:A,className:`${f}${M?` ${M}`:""}${a?" nice-error":""}${c?" nice-disabled":""}`,style:W,role:"group","aria-label":t??F("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:C.map(E=>E==="country"&&ee?e.jsxs("div",{className:`nice-address__field nice-address__field--${E}`,children:[e.jsx("label",{className:"nice-address__field-label",children:F(E,ht[E])}),e.jsxs("select",{className:"nice-input nice-select",value:B.country??"",onChange:L=>k("country",L.target.value),disabled:c,"aria-label":F(E,ht[E]),children:[e.jsx("option",{value:"",children:ie.country??F("selectCountry","— Select country —")}),ee.map(L=>e.jsx("option",{value:L.code,children:L.name},L.code))]})]},E):e.jsxs("div",{className:`nice-address__field nice-address__field--${E}`,children:[e.jsx("label",{className:"nice-address__field-label",children:F(E,ht[E])}),e.jsx("input",{className:`nice-input${E==="postalCode"&&x?" nice-input--error":""}`,type:"text",name:T?`${T}.${E}`:E,value:B[E]??"",onChange:L=>k(E,L.target.value),placeholder:ie[E]??"",disabled:c,readOnly:g,"aria-label":F(E,ht[E])}),E==="postalCode"&&x&&e.jsx("span",{className:"nice-error-text",children:x})]},E))}),i&&e.jsx("span",{className:"nice-helper-text",children:i}),a&&typeof a=="string"&&e.jsx("span",{className:"nice-error-text",children:a})]})}),{displayName:"NiceAddressInput"}),Pi=[],Oi={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)"},Bi=Object.assign(n.forwardRef(({label:t,helperText:i,error:a,required:o,disabled:c,readOnly:g,size:y="md",name:T,id:P,className:M,style:W,accessMode:X,value:B,onChange:$,accounts:U=Pi,treeView:ie=!1,placeholder:ee,searchable:re=!0,showType:G=!0,onSearch:H},w)=>{const s=r.useNiceAccessMode(X,P),R=s==="hidden";s==="disabled"&&(c=!0),s==="readOnly"&&(g=!0);const{t:F}=r.useNiceTranslation(),A=r.useControlId(P),[k,x]=n.useState(""),[C,f]=n.useState(!1),E=n.useMemo(()=>{const m=D=>{for(const O of D){if(O.code===B)return O;if(O.children){const V=m(O.children);if(V)return V}}};return m(U)},[U,B]),L=n.useMemo(()=>{const m=[],D=O=>{for(const V of O)m.push(V),V.children&&D(V.children)};return D(U),m},[U]),N=n.useMemo(()=>{if(!k)return L;const m=k.toLowerCase();return L.filter(D=>D.code.toLowerCase().includes(m)||D.name.toLowerCase().includes(m))},[L,k]),d=n.useCallback(m=>{x(m),H?.(m),f(!0)},[H]),z=n.useCallback(m=>{$?.(m.code,m),f(!1),x("")},[$]),b=n.useRef(null),h=C&&N.length>0,{activeIndex:l,setActiveIndex:u,handleKeyDown:_}=lt.useListKeyboardNav(N,{open:h,onSelect:m=>z(m),onClose:()=>f(!1),onOpen:()=>{u(0),f(!0)},intentRef:b}),S=`${A}-accounts`;return R?null:e.jsxs("div",{ref:w,id:A,className:`nice-account-picker nice-size-${y}${M?` ${M}`:""}${a?" nice-error":""}${c?" nice-disabled":""}`,style:W,children:[t&&e.jsxs("label",{className:"nice-account-picker__label",htmlFor:`${A}-input`,children:[t,o&&e.jsx("span",{className:"nice-required",children:"*"})]}),e.jsx("div",{className:"nice-account-picker__control",children:re&&!g?e.jsx("input",{ref:b,id:`${A}-input`,className:"nice-input",type:"text",value:C?k:E?`${E.code} — ${E.name}`:"",onChange:m=>{d(m.target.value),u(0)},onFocus:()=>{x(""),u(-1),f(!0)},onBlur:()=>setTimeout(()=>f(!1),200),onKeyDown:_,placeholder:ee??F("searchAccount","Search account…"),disabled:c,required:o,autoComplete:"off",role:"combobox","aria-autocomplete":"list","aria-expanded":h,"aria-controls":h?S:void 0,"aria-activedescendant":h&&N[l]?`${S}-${l}`:void 0}):e.jsx("div",{className:"nice-account-picker__display",children:E?`${E.code} — ${E.name}`:ee??F("selectAccount","Select account…")})}),h&&e.jsx("div",{className:"nice-account-picker__dropdown",role:"listbox",id:S,children:N.map((m,D)=>e.jsxs("div",{id:`${S}-${D}`,className:`nice-account-picker__option${m.code===B?" nice-account-picker__option--selected":""}${D===l?" nice-account-picker__option--active":""}${m.isActive===!1?" nice-account-picker__option--inactive":""}`,role:"option","aria-selected":m.code===B,onMouseEnter:()=>u(D),onClick:()=>z(m),children:[G&&m.type&&e.jsx("span",{className:"nice-account-picker__type",style:{color:Oi[m.type]},title:m.type,children:e.jsx(r.NiceIcon,{name:"circle",size:10})}),e.jsx("span",{className:"nice-account-picker__code",children:m.code}),e.jsx("span",{className:"nice-account-picker__name",children:m.name})]},m.code))}),i&&e.jsx("span",{className:"nice-helper-text",children:i}),a&&typeof a=="string"&&e.jsx("span",{className:"nice-error-text",children:a})]})}),{displayName:"NiceAccountPicker"}),Hi=Object.assign(n.forwardRef(({label:t,helperText:i,error:a,required:o,disabled:c,readOnly:g,size:y="md",name:T,id:P,className:M,style:W,accessMode:X,value:B=[],onChange:$,contacts:U=[],onSearch:ie,searchDelay:ee=300,multiple:re=!1,placeholder:G,onContactClick:H,maxSelections:w},s)=>{const R=r.useNiceAccessMode(X,P),F=R==="hidden";R==="disabled"&&(c=!0),R==="readOnly"&&(g=!0);const{t:A}=r.useNiceTranslation(),k=r.useControlId(P),[x,C]=n.useState(""),[f,E]=n.useState([]),[L,N]=n.useState(!1),[d,z]=n.useState(!1),b=n.useMemo(()=>{const v=[...U,...f],q=new Map(v.map(K=>[K.id,K]));return B.map(K=>q.get(K)).filter(Boolean)},[B,U,f]),h=n.useCallback(v=>{if(C(v),v.length<1){E([]),N(!1);return}if(ie){z(!0);const de=setTimeout(async()=>{const he=await ie(v);E(he),N(!0),z(!1)},ee);return()=>clearTimeout(de)}const q=v.toLowerCase(),K=U.filter(de=>de.name.toLowerCase().includes(q)||de.email?.toLowerCase().includes(q)||de.phone?.includes(v));E(K),N(!0)},[ie,U,ee]),l=n.useCallback(v=>{if(re)if(B.includes(v.id))$?.(B.filter(q=>q!==v.id));else{if(w&&B.length>=w)return;$?.([...B,v.id])}else $?.([v.id]),N(!1),C("")},[B,$,re,w]),u=n.useCallback(v=>{$?.(B.filter(q=>q!==v))},[B,$]),_=n.useRef(null),S=L&&f.length>0,{activeIndex:m,setActiveIndex:D,handleKeyDown:O}=lt.useListKeyboardNav(f,{open:S,onSelect:v=>l(v),onClose:()=>N(!1),onOpen:()=>{f.length>0&&(D(0),N(!0))},intentRef:_}),V=`${k}-results`;return F?null:e.jsxs("div",{ref:s,id:k,className:`nice-contact-picker nice-size-${y}${M?` ${M}`:""}${a?" nice-error":""}${c?" nice-disabled":""}`,style:W,children:[t&&e.jsxs("label",{className:"nice-contact-picker__label",children:[t,o&&e.jsx("span",{className:"nice-required",children:"*"})]}),b.length>0&&e.jsx("div",{className:"nice-contact-picker__chips",children:b.map(v=>e.jsxs("span",{role:H?"button":void 0,tabIndex:H?0:void 0,onKeyDown:H?r.clickOnActivationKey:void 0,className:"nice-contact-picker__chip",onClick:()=>H?.(v),children:[v.avatarUrl&&e.jsx("img",{src:v.avatarUrl,alt:"",className:"nice-contact-picker__chip-avatar"}),e.jsx("span",{children:v.name}),!g&&e.jsx("button",{type:"button",className:"nice-contact-picker__chip-remove",onClick:q=>{q.stopPropagation(),u(v.id)},disabled:c,"aria-label":A("controls.remove","Remove"),children:e.jsx(r.NiceIcon,{name:"close",size:14})})]},v.id))}),!g&&e.jsxs("div",{className:"nice-contact-picker__search",children:[e.jsx("input",{ref:_,className:"nice-input",type:"text",value:x,onChange:v=>{h(v.target.value),D(0)},onFocus:()=>x.length>0&&N(!0),onBlur:()=>setTimeout(()=>N(!1),200),onKeyDown:O,placeholder:G??A("searchContacts","Search contacts…"),disabled:c,"aria-label":A("contactPicker.search","Search contacts"),autoComplete:"off",role:"combobox","aria-autocomplete":"list","aria-expanded":S,"aria-controls":S?V:void 0,"aria-activedescendant":S&&f[m]?`${V}-${m}`:void 0}),d&&e.jsx("span",{className:"nice-contact-picker__spinner",children:e.jsx(r.NiceIcon,{name:"refresh",size:16})})]}),S&&e.jsx("div",{className:"nice-contact-picker__dropdown",role:"listbox",id:V,"aria-multiselectable":re||void 0,children:f.map((v,q)=>e.jsxs("div",{id:`${V}-${q}`,className:`nice-contact-picker__option${B.includes(v.id)?" nice-contact-picker__option--selected":""}${q===m?" nice-contact-picker__option--active":""}`,role:"option","aria-selected":B.includes(v.id),onMouseEnter:()=>D(q),onClick:()=>l(v),children:[v.avatarUrl&&e.jsx("img",{src:v.avatarUrl,alt:"",className:"nice-contact-picker__option-avatar"}),e.jsxs("div",{className:"nice-contact-picker__option-info",children:[e.jsx("span",{className:"nice-contact-picker__option-name",children:v.name}),v.subtitle&&e.jsx("span",{className:"nice-contact-picker__option-subtitle",children:v.subtitle}),v.email&&e.jsx("span",{className:"nice-contact-picker__option-email",children:v.email})]}),v.type&&e.jsx("span",{className:"nice-contact-picker__option-type",children:e.jsx(r.NiceIcon,{name:v.type==="person"?"user":"building",size:16})})]},v.id))}),i&&e.jsx("span",{className:"nice-helper-text",children:i}),a&&typeof a=="string"&&e.jsx("span",{className:"nice-error-text",children:a})]})}),{displayName:"NiceContactPicker"}),Fi={recent:"🕒",smileys:"😀",people:"👋",animals:"🐱",food:"🍕",travel:"✈️",activities:"⚽",objects:"💡",symbols:"❤️",flags:"🏳️"},Jt={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"},St=["","🏻","🏼","🏽","🏾","🏿"],xt=[{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"}],Zt="nice-emoji-picker-recent",bn=({onSelect:t,showSearch:i=!0,searchPlaceholder:a,showSkinTones:o=!0,defaultSkinTone:c=0,showRecent:g=!0,maxRecent:y=24,recentEmojis:T,onRecentChange:P,categories:M,customEmojis:W=[],columns:X=8,size:B="md",className:$="",style:U,"data-testid":ie="nice-emoji-picker"})=>{const ee=n.useRef(null);r.useRovingFocus(ee,{orientation:"horizontal",wrap:!0,activateOnMove:!0});const{t:re}=r.useNiceTranslation(),[G,H]=n.useState(""),[w,s]=n.useState(g?"recent":"smileys"),[R,F]=n.useState(c),[A,k]=n.useState(!1),x=n.useRef(null),[C,f]=n.useState(()=>{if(typeof window>"u")return[];try{return JSON.parse(localStorage.getItem(Zt)||"[]")}catch{return[]}}),E=T??C,L=n.useMemo(()=>M??[...g?["recent"]:[],"smileys","people","animals","food","travel","activities","objects","symbols","flags"],[M,g]),N=n.useMemo(()=>{if(!G)return xt;const u=G.toLowerCase();return xt.filter(_=>_.name.toLowerCase().includes(u)||_.emoji.includes(u)||_.keywords?.some(S=>S.toLowerCase().includes(u)))},[G]),d=n.useMemo(()=>{const u={};for(const _ of L)_==="recent"?u[_]=E.map(S=>xt.find(m=>m.emoji===S)).filter(S=>S!==void 0).slice(0,y):u[_]=N.filter(S=>S.category===_);return u},[L,N,E,y]),z=n.useCallback((u,_)=>!_||R===0?u:u.replace(/[\u{1F3FB}-\u{1F3FF}]/gu,"")+St[R],[R]),b=n.useCallback(u=>{const _=z(u.emoji,u.skinTones),S=[u.emoji,...E.filter(m=>m!==u.emoji)].slice(0,y);if(T===void 0){f(S);try{localStorage.setItem(Zt,JSON.stringify(S))}catch{}}P?.(S),t?.(_,u)},[z,E,y,T,P,t]),h=n.useCallback(u=>{t?.(`:${u.name}:`,u)},[t]);n.useEffect(()=>{if(!A)return;const u=_=>{x.current&&!x.current.contains(_.target)&&k(!1)};return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[A]);const l=G?N:d[w]||[];return e.jsxs("div",{className:`nice-emoji-picker nice-emoji-picker--${B} ${$}`,style:U,"data-testid":ie,children:[i&&e.jsxs("div",{className:"nice-emoji-picker__search",children:[e.jsx("input",{type:"text",value:G,onChange:u=>H(u.target.value),placeholder:a??re("search","Search emoji..."),className:"nice-emoji-picker__search-input","data-testid":`${ie}-search`}),o&&e.jsxs("div",{className:"nice-emoji-picker__skin-tone-wrapper",children:[e.jsxs("button",{ref:x,type:"button",className:"nice-emoji-picker__skin-tone-btn",onClick:()=>k(!A),title:re("skinTone","Skin tone"),children:["✋",St[R]]}),A&&e.jsx("div",{className:"nice-emoji-picker__skin-tone-menu",children:St.map((u,_)=>e.jsxs("button",{type:"button",className:`nice-emoji-picker__skin-tone-option ${_===R?"nice-emoji-picker__skin-tone-option--selected":""}`,onClick:()=>{F(_),k(!1)},children:["✋",u]},_))})]})]}),!G&&e.jsx("div",{className:"nice-emoji-picker__categories",ref:ee,role:"tablist",children:L.map(u=>e.jsx("button",{type:"button",className:`nice-emoji-picker__category-btn ${w===u?"nice-emoji-picker__category-btn--selected":""}`,onClick:()=>s(u),title:Jt[u],role:"tab","aria-selected":w===u,children:Fi[u]},u))}),e.jsxs("div",{className:"nice-emoji-picker__grid-container",children:[G?e.jsxs("div",{className:"nice-emoji-picker__section",children:[e.jsx("div",{className:"nice-emoji-picker__section-title",children:re("searchResults","Search Results")}),e.jsx("div",{className:"nice-emoji-picker__grid",style:{gridTemplateColumns:`repeat(${X}, 1fr)`},children:N.length===0?e.jsx("div",{className:"nice-emoji-picker__empty",children:re("noEmojis","No emojis found")}):N.map((u,_)=>e.jsx("button",{type:"button",className:"nice-emoji-picker__emoji",onClick:()=>b(u),title:u.name,children:z(u.emoji,u.skinTones)},`${u.emoji}-${_}`))})]}):e.jsxs("div",{className:"nice-emoji-picker__section",children:[e.jsx("div",{className:"nice-emoji-picker__section-title",children:Jt[w]}),e.jsx("div",{className:"nice-emoji-picker__grid",style:{gridTemplateColumns:`repeat(${X}, 1fr)`},children:l.length===0?e.jsx("div",{className:"nice-emoji-picker__empty",children:w==="recent"?re("noRecent","No recent emojis"):re("noEmojis","No emojis found")}):l.map((u,_)=>e.jsx("button",{type:"button",className:"nice-emoji-picker__emoji",onClick:()=>b(u),title:u.name,children:z(u.emoji,u.skinTones)},`${u.emoji}-${_}`))})]}),W.length>0&&e.jsxs("div",{className:"nice-emoji-picker__section",children:[e.jsx("div",{className:"nice-emoji-picker__section-title",children:re("custom","Custom")}),e.jsx("div",{className:"nice-emoji-picker__grid",style:{gridTemplateColumns:`repeat(${X}, 1fr)`},children:W.map(u=>e.jsx("button",{type:"button",className:"nice-emoji-picker__emoji nice-emoji-picker__emoji--custom",onClick:()=>h(u),title:u.name,children:e.jsx("img",{src:u.url,alt:u.name})},u.id))})]})]})]})};process.env.NODE_ENV!=="production"&&(bn.displayName="NiceEmojiPicker");const Ki=Object.assign(n.forwardRef(({length:t=6,value:i="",onChange:a,masked:o=!1,onComplete:c,label:g,helperText:y,error:T,required:P,disabled:M,readOnly:W,size:X="md",name:B,id:$,className:U,style:ie,autoFocus:ee,labelPlacement:re,errorPlacement:G,labelWidth:H,controlWidth:w,loading:s,cellWidth:R,...F},A)=>{const k=r.useControlId($),x=n.useRef([]),C=i.padEnd(t,"").slice(0,t).split(""),f=n.useCallback(z=>{const b=Math.max(0,Math.min(t-1,z));x.current[b]?.focus()},[t]),E=n.useCallback(z=>{const b=z.join("");a?.(b),b.length===t&&b.indexOf("")===-1&&/^\d+$/.test(b)&&c?.(b)},[a,c,t]),L=n.useCallback((z,b)=>{const l=b.target.value.replace(/\D/g,"").slice(-1);if(!l)return;const u=[...C];u[z]=l,E(u),f(z+1)},[C,E,f]),N=n.useCallback((z,b)=>{if(b.key==="Backspace"){b.preventDefault();const h=[...C];C[z]?(h[z]="",E(h)):z>0&&(h[z-1]="",E(h),f(z-1))}else b.key==="ArrowLeft"?(b.preventDefault(),f(z-1)):b.key==="ArrowRight"&&(b.preventDefault(),f(z+1))},[C,E,f]),d=n.useCallback(z=>{z.preventDefault();const b=z.clipboardData.getData("text").replace(/\D/g,"").slice(0,t);if(!b)return;const h=b.padEnd(t,"").slice(0,t).split("");for(let l=b.length;l<t;l++)h[l]=C[l]||"";E(h),f(Math.min(b.length,t-1))},[t,C,E,f]);return e.jsxs("div",{className:`nice-field nice-field--${X} nice-field--otp${re?` nice-field--label-${re}`:""}${G==="right"?" nice-field--error-right":""} ${s?"nice-field--loading":""} ${U||""}`,style:{...ie,...H!=null&&{"--nice-field-label-width":typeof H=="number"?`${H}px`:H},...w!=null&&{"--nice-field-control-width":typeof w=="number"?`${w}px`:w},...R!=null&&{"--nice-otp-cell-width":typeof R=="number"?`${R}px`:R}},"aria-busy":s||void 0,...F,children:[g&&e.jsx("label",{htmlFor:`${k}-0`,className:`nice-field__label ${P?"nice-field__label--required":""}`,children:g}),e.jsxs("div",{className:"nice-field__control",children:[e.jsxs("div",{ref:A,className:`nice-otp nice-otp--${X} ${T?"nice-otp--error":""} ${M?"nice-otp--disabled":""}`,onPaste:d,children:[Array.from({length:t},(z,b)=>e.jsx("input",{ref:h=>{x.current[b]=h},id:b===0?`${k}-0`:void 0,className:"nice-otp__digit",type:o?"password":"text",inputMode:"numeric",maxLength:2,value:C[b]||"",disabled:M,readOnly:W,autoFocus:ee&&b===0,"aria-invalid":!!T,"aria-label":`${b+1}`,onChange:h=>L(b,h),onKeyDown:h=>N(b,h),onFocus:h=>h.target.select()},b)),B&&e.jsx("input",{type:"hidden",name:B,value:i})]}),G==="right"&&T&&e.jsx("div",{id:`${k}-error`,className:"nice-field__error",role:"alert",children:T}),G==="right"&&!T&&y&&e.jsx("div",{id:`${k}-helper`,className:"nice-field__helper",children:y}),s&&e.jsx("span",{className:"nice-field__spinner",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})})]}),G!=="right"&&T&&e.jsx("div",{id:`${k}-error`,className:"nice-field__error",role:"alert",children:T}),G!=="right"&&!T&&y&&e.jsx("div",{id:`${k}-helper`,className:"nice-field__helper",children:y})]})}),{displayName:"NiceInputOtp"}),Ui=[{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"}],Qt={rotation:0,flipH:!1,flipV:!1,brightness:100,contrast:100,saturate:100,blur:0,crop:null,annotations:[]},Yi=["crop","rotate","flip","brightness","contrast","saturate","blur","annotate"],Xi=Object.assign(n.forwardRef(({src:t,size:i="md",editorSize:a="standard",tools:o=Yi,showToolbar:c=!0,showZoom:g=!0,maxUndo:y=30,onSave:T,onCancel:P,onChange:M,width:W="100%",height:X=500,tutorial:B,className:$,style:U,id:ie,...ee},re)=>{const G=r.useControlId(ie),{t:H}=r.useNiceTranslation(),{prompt:w,element:s}=Je.useNiceDialogs(),R=n.useRef(null),F=n.useRef(null);r.useRovingFocus(F,{orientation:"horizontal",itemSelector:"button"});const A=n.useRef(null),[k,x]=n.useState({...Qt}),[C,f]=n.useState(null),[E,L]=n.useState(!1),[N,d]=n.useState(1),[z,b]=n.useState("rect"),[h,l]=n.useState("var(--nice-danger, #ff0000)"),[u,_]=n.useState({w:0,h:0}),[S,m]=n.useState([]),[D,O]=n.useState([]),[V,v]=n.useState(null),[q,K]=n.useState(null),[de,he]=n.useState(null),be=n.useCallback(I=>{m(Y=>[...Y.slice(-(y-1)),I]),O([])},[y]),ge=n.useCallback(I=>{x(Y=>{be(Y);const le={...Y,...I};return M?.(le),le})},[M,be]),fe=n.useCallback(()=>{if(S.length===0)return;const I=S[S.length-1];m(Y=>Y.slice(0,-1)),O(Y=>[...Y,k]),x(I),M?.(I)},[S,k,M]),me=n.useCallback(()=>{if(D.length===0)return;const I=D[D.length-1];O(Y=>Y.slice(0,-1)),m(Y=>[...Y,k]),x(I),M?.(I)},[D,k,M]);n.useEffect(()=>{const I=new Image;I.crossOrigin="anonymous",I.onload=()=>{A.current=I,_({w:I.width,h:I.height}),L(!0)},I.src=t},[t]),n.useEffect(()=>{if(!E||!R.current||!A.current)return;const I=R.current,Y=I.getContext("2d");if(!Y)return;const le=A.current,j=k.rotation%180!==0,Z=j?le.height:le.width,oe=j?le.width:le.height;I.width=Z,I.height=oe,Y.clearRect(0,0,Z,oe),Y.save(),Y.filter=`brightness(${k.brightness}%) contrast(${k.contrast}%) saturate(${k.saturate}%) blur(${k.blur}px)`,Y.translate(Z/2,oe/2),Y.rotate(k.rotation*Math.PI/180),Y.scale(k.flipH?-1:1,k.flipV?-1:1),Y.drawImage(le,-le.width/2,-le.height/2),Y.restore(),k.annotations.forEach(se=>{switch(Y.save(),Y.strokeStyle=se.color??"red",Y.fillStyle=se.color??"red",Y.lineWidth=se.strokeWidth??2,Y.font=`${se.fontSize??16}px sans-serif`,se.type){case"text":Y.fillText(se.text??"",se.x,se.y);break;case"rect":Y.strokeRect(se.x,se.y,se.width??100,se.height??50);break;case"circle":{const ye=(se.width??50)/2,xe=(se.height??50)/2;Y.beginPath(),Y.ellipse(se.x+ye,se.y+xe,ye,xe,0,0,Math.PI*2),Y.stroke();break}case"line":Y.beginPath(),Y.moveTo(se.x,se.y),Y.lineTo(se.x+(se.width??100),se.y+(se.height??0)),Y.stroke();break;case"arrow":{const ye=se.x+(se.width??100),xe=se.y+(se.height??0);Y.beginPath(),Y.moveTo(se.x,se.y),Y.lineTo(ye,xe),Y.stroke();const Ee=Math.atan2(xe-se.y,ye-se.x),ze=10;Y.beginPath(),Y.moveTo(ye,xe),Y.lineTo(ye-ze*Math.cos(Ee-.4),xe-ze*Math.sin(Ee-.4)),Y.lineTo(ye-ze*Math.cos(Ee+.4),xe-ze*Math.sin(Ee+.4)),Y.closePath(),Y.fill();break}}Y.restore()}),q&&(Y.save(),Y.fillStyle=r.resolveCssColor("var(--nice-overlay-50, rgba(0, 0, 0, 0.5))",Y.canvas),Y.fillRect(0,0,Z,oe),Y.clearRect(q.x,q.y,q.w,q.h),Y.strokeStyle=r.resolveCssColor("var(--nice-bg-primary, #fff)",Y.canvas),Y.lineWidth=2,Y.setLineDash([5,5]),Y.strokeRect(q.x,q.y,q.w,q.h),Y.restore())},[E,k,q]);const pe=n.useCallback(I=>{if(!R.current)return;const Y=R.current.getBoundingClientRect(),le=R.current.width/Y.width,j=R.current.height/Y.height,Z=(I.clientX-Y.left)*le,oe=(I.clientY-Y.top)*j;C==="crop"?v({startX:Z,startY:oe}):C==="annotate"&&he({startX:Z,startY:oe})},[C]),te=n.useCallback(I=>{if(!R.current)return;const Y=R.current.getBoundingClientRect(),le=R.current.width/Y.width,j=R.current.height/Y.height,Z=(I.clientX-Y.left)*le,oe=(I.clientY-Y.top)*j;V&&K({x:Math.min(V.startX,Z),y:Math.min(V.startY,oe),w:Math.abs(Z-V.startX),h:Math.abs(oe-V.startY)})},[V]),ve=n.useCallback(I=>{if(V&&q&&q.w>5&&q.h>5&&ge({crop:{x:q.x,y:q.y,width:q.w,height:q.h}}),v(null),de&&R.current){const Y=R.current.getBoundingClientRect(),le=R.current.width/Y.width,j=R.current.height/Y.height,Z=(I.clientX-Y.left)*le,oe=(I.clientY-Y.top)*j,se=Z-de.startX,ye=oe-de.startY;if(Math.abs(se)>3||Math.abs(ye)>3||z==="text"){const xe={type:z,x:de.startX,y:de.startY,width:Math.abs(se)||100,height:Math.abs(ye)||50,color:h,strokeWidth:2};if(z==="text"){const Ee=k.annotations;w({title:H("imageEditor.annotationText","Text:")}).then(ze=>{ze&&ge({annotations:[...Ee,{...xe,text:ze}]})})}else ge({annotations:[...k.annotations,xe]})}he(null)}},[V,q,de,z,h,k.annotations,ge,H,w]),_e=n.useCallback(()=>{if(!k.crop||!R.current)return;const I=R.current,Y=I.getContext("2d");if(!Y)return;const{x:le,y:j,width:Z,height:oe}=k.crop,se=Y.getImageData(le,j,Z,oe);I.width=Z,I.height=oe,Y.putImageData(se,0,0),K(null),f(null)},[k.crop]),ne=n.useCallback(()=>{if(!R.current)return;const I=R.current.toDataURL("image/png");T?.(I,k)},[T,k]),we=n.useCallback(()=>{x({...Qt}),K(null),f(null)},[]);n.useMemo(()=>`brightness(${k.brightness}%) contrast(${k.contrast}%) saturate(${k.saturate}%) blur(${k.blur}px)`,[k.brightness,k.contrast,k.saturate,k.blur]);const ae=c?e.jsxs("div",{ref:F,className:"nice-image-editor__toolbar",role:"toolbar","aria-label":H("imageEditor.toolbar","Image tools"),children:[e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:fe,disabled:S.length===0,title:H("imageEditor.undo","Undo"),"aria-label":H("imageEditor.undo","Undo"),children:e.jsx(r.NiceIcon,{name:"reply",size:16})}),e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:me,disabled:D.length===0,title:H("imageEditor.redo","Redo"),"aria-label":H("imageEditor.redo","Redo"),children:e.jsx(r.NiceIcon,{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:()=>ge({rotation:(k.rotation-90+360)%360}),title:H("imageEditor.rotateLeft","Rotate left"),"aria-label":H("imageEditor.rotateLeft","Rotate left"),children:e.jsx(r.NiceIcon,{name:"reply",size:16})}),e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>ge({rotation:(k.rotation+90)%360}),title:H("imageEditor.rotateRight","Rotate right"),"aria-label":H("imageEditor.rotateRight","Rotate right"),children:e.jsx(r.NiceIcon,{name:"forward",size:16})})]}),o.includes("flip")&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>ge({flipH:!k.flipH}),title:H("imageEditor.flipH","Flip horizontal"),"aria-label":H("imageEditor.flipH","Flip horizontal"),children:e.jsx(r.NiceIcon,{name:"shuffle",size:16})}),e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>ge({flipV:!k.flipV}),title:H("imageEditor.flipV","Flip vertical"),"aria-label":H("imageEditor.flipV","Flip vertical"),children:e.jsx(r.NiceIcon,{name:"shuffle",size:16})})]}),o.includes("crop")&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:`nice-image-editor__btn ${C==="crop"?"nice-image-editor__btn--active":""}`,onClick:()=>f(C==="crop"?null:"crop"),title:H("imageEditor.crop","Crop"),"aria-label":H("imageEditor.crop","Crop"),children:e.jsx(r.NiceIcon,{name:"box",size:16})}),C==="crop"&&k.crop&&e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:_e,title:H("imageEditor.applyCrop","Apply crop"),"aria-label":H("imageEditor.applyCrop","Apply crop"),children:e.jsx(r.NiceIcon,{name:"check",size:16})})]}),o.includes("brightness")&&e.jsxs("label",{className:"nice-image-editor__slider-label",title:H("imageEditor.brightness","Brightness"),children:[e.jsx(r.NiceIcon,{name:"lightbulb",size:16}),e.jsx("input",{type:"range",min:0,max:200,value:k.brightness,onChange:I=>ge({brightness:Number(I.target.value)}),className:"nice-image-editor__slider",title:H("imageEditor.brightness","Brightness")})]}),o.includes("contrast")&&e.jsxs("label",{className:"nice-image-editor__slider-label",title:H("imageEditor.contrast","Contrast"),children:[e.jsx(r.NiceIcon,{name:"circle",size:16}),e.jsx("input",{type:"range",min:0,max:200,value:k.contrast,onChange:I=>ge({contrast:Number(I.target.value)}),className:"nice-image-editor__slider",title:H("imageEditor.contrast","Contrast")})]}),o.includes("saturate")&&e.jsxs("label",{className:"nice-image-editor__slider-label",title:H("imageEditor.saturate","Saturation"),children:[e.jsx(r.NiceIcon,{name:"palette",size:16}),e.jsx("input",{type:"range",min:0,max:200,value:k.saturate,onChange:I=>ge({saturate:Number(I.target.value)}),className:"nice-image-editor__slider",title:H("imageEditor.saturate","Saturation")})]}),o.includes("blur")&&e.jsxs("label",{className:"nice-image-editor__slider-label",title:H("imageEditor.blur","Blur"),children:[e.jsx(r.NiceIcon,{name:"eye-off",size:16}),e.jsx("input",{type:"range",min:0,max:20,step:.5,value:k.blur,onChange:I=>ge({blur:Number(I.target.value)}),className:"nice-image-editor__slider",title:H("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 ${C==="annotate"?"nice-image-editor__btn--active":""}`,onClick:()=>f(C==="annotate"?null:"annotate"),title:H("imageEditor.annotate","Annotate"),"aria-label":H("imageEditor.annotate","Annotate"),children:e.jsx(r.NiceIcon,{name:"edit",size:16})}),C==="annotate"&&e.jsxs(e.Fragment,{children:[e.jsxs("select",{className:"nice-image-editor__select",value:z,onChange:I=>b(I.target.value),children:[e.jsx("option",{value:"rect",children:H("imageEditor.rect","Rect")}),e.jsx("option",{value:"circle",children:H("imageEditor.circle","Circle")}),e.jsx("option",{value:"line",children:H("imageEditor.line","Line")}),e.jsx("option",{value:"arrow",children:H("imageEditor.arrow","Arrow")}),e.jsx("option",{value:"text",children:H("imageEditor.text","Text")})]}),e.jsx("input",{type:"color",value:h,onChange:I=>l(I.target.value),className:"nice-image-editor__color",title:H("imageEditor.color","Color")}),k.annotations.length>0&&e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>ge({annotations:k.annotations.slice(0,-1)}),title:H("imageEditor.removeLastAnnotation","Remove last"),"aria-label":H("imageEditor.removeLastAnnotation","Remove last"),children:e.jsx(r.NiceIcon,{name:"trash",size:16})})]})]}),e.jsx("span",{className:"nice-image-editor__sep"}),e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:we,title:H("imageEditor.reset","Reset"),"aria-label":H("imageEditor.reset","Reset"),children:e.jsx(r.NiceIcon,{name:"refresh",size:16})}),T&&e.jsx("button",{type:"button",className:"nice-image-editor__btn nice-image-editor__btn--save",onClick:ne,children:H("imageEditor.save","Save")}),P&&e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:P,children:H("imageEditor.cancel","Cancel")})]}):void 0,ue=g?e.jsxs("div",{className:"nice-image-editor__footer",children:[e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>d(I=>Math.max(.1,I-.1)),title:H("imageEditor.zoomOut","Zoom out"),"aria-label":H("imageEditor.zoomOut","Zoom out"),children:e.jsx(r.NiceIcon,{name:"minus",size:16})}),e.jsxs("span",{style:{fontSize:"0.85em",minWidth:40,textAlign:"center"},children:[Math.round(N*100),"%"]}),e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>d(I=>Math.min(5,I+.1)),title:H("imageEditor.zoomIn","Zoom in"),"aria-label":H("imageEditor.zoomIn","Zoom in"),children:e.jsx(r.NiceIcon,{name:"plus",size:16})}),e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>d(1),title:H("imageEditor.resetZoom","Reset zoom"),children:"1:1"}),e.jsx("span",{style:{flex:1}}),e.jsx("span",{style:{fontSize:"0.8em",color:"var(--nice-text-secondary, #666)"},children:H("imageEditor.px","{w}×{h}px · {rotation}°").replace("{w}",String(u.w)).replace("{h}",String(u.h)).replace("{rotation}",String(k.rotation))})]}):void 0;return e.jsxs(Je.NiceAppShell,{ref:re,flush:!0,id:G,className:`nice-image-editor nice-image-editor--${i} nice-editor--${a} ${$??""}`,style:{...U,width:W,height:X},toolbar:ae,statusBar:ue,children:[s,e.jsxs("div",{className:"nice-image-editor__canvas-wrap",style:{position:"relative"},role:"application","aria-label":H("imageEditor.label","Image Editor"),...ee,children:[e.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:20},children:e.jsx(r.NiceTutorialButton,{steps:r.resolveTutorial(B,Ui)})}),e.jsx("canvas",{ref:R,className:"nice-image-editor__canvas",onMouseDown:pe,onMouseMove:te,onMouseUp:ve,style:{cursor:C==="crop"||C==="annotate"?"crosshair":"default",transform:`scale(${N})`,transformOrigin:"center center"}})]})]})}),{displayName:"NiceImageEditor"}),qi={strokeColor:"#ff3333",fillColor:"transparent",strokeWidth:2,opacity:1,fontSize:16,fontFamily:"sans-serif"};function Gi(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 Vi=0;function Wi(){return`ann-${Date.now()}-${Vi++}`}function Ji(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,c=t.y+t.height/2;return`<ellipse cx="${o}" cy="${c}" rx="${t.width/2}" ry="${t.height/2}" ${a} />`}case"arrow":{const o=t,c=Math.atan2(o.endY-o.y,o.endX-o.x),g=12,y=o.endX-g*Math.cos(c-Math.PI/6),T=o.endY-g*Math.sin(c-Math.PI/6),P=o.endX-g*Math.cos(c+Math.PI/6),M=o.endY-g*Math.sin(c+Math.PI/6);return`<line x1="${o.x}" y1="${o.y}" x2="${o.endX}" y2="${o.endY}" ${a} />
|
|
300
|
-
<polygon points="${o.endX},${o.endY} ${y},${T} ${P},${M}" 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}">${Zi(o.text)}</text>`}case"freehand":{const o=t;return o.points.length<2?"":`<path d="${o.points.map((g,y)=>`${y===0?"M":"L"}${g.x},${g.y}`).join(" ")}" ${a} fill="none" />`}case"blur":{const o=t,c=`blur-${o.id}`;return`<defs><filter id="${c}"><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(#${c})" />`}default:return""}}function Zi(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}const Qi=Object.assign(n.forwardRef(({src:t,alt:i,annotations:a,activeTool:o,defaultStyle:c,onAnnotationsChange:g,className:y,readOnly:T=!1,minZoom:P=.1,maxZoom:M=5},W)=>{const{t:X}=r.useNiceTranslation(),B=i??X("imageAnnotator.annotatableImage","Annotatable image"),$=n.useRef(null),U=n.useRef(null),ie=n.useRef(null),[ee,re]=n.useState(!1),[G,H]=n.useState({width:0,height:0}),[w,s]=n.useReducer(Gi,{annotations:a??[],selectedId:null,activeTool:o??"select",style:{...qi,...c},zoom:1,panX:0,panY:0,past:[],future:[]});n.useEffect(()=>{o&&s({type:"SET_TOOL",tool:o})},[o]),n.useEffect(()=>{g?.(w.annotations)},[w.annotations,g]),n.useEffect(()=>{const N=new Image;N.crossOrigin="anonymous",N.onload=()=>{ie.current=N,H({width:N.naturalWidth,height:N.naturalHeight}),re(!0)},N.src=t},[t]);const R=n.useRef({isDrawing:!1,startX:0,startY:0,currentAnnotation:null,freehandPoints:[]}),F=n.useCallback((N,d)=>{const z=$.current;if(!z)return{x:0,y:0};const b=z.getBoundingClientRect();return{x:(N-b.left-w.panX)/w.zoom,y:(d-b.top-w.panY)/w.zoom}},[w.zoom,w.panX,w.panY]),A=n.useCallback(()=>{const N=$.current,d=N?.getContext("2d"),z=ie.current;if(!N||!d||!z||!ee)return;N.width=U.current?.clientWidth??z.naturalWidth,N.height=U.current?.clientHeight??z.naturalHeight,d.clearRect(0,0,N.width,N.height),d.save(),d.translate(w.panX,w.panY),d.scale(w.zoom,w.zoom),d.drawImage(z,0,0);for(const h of w.annotations){switch(d.save(),d.globalAlpha=h.style.opacity,d.strokeStyle=h.style.strokeColor,d.fillStyle=h.style.fillColor,d.lineWidth=h.style.strokeWidth,h.tool){case"rectangle":d.strokeRect(h.x,h.y,h.width,h.height),h.style.fillColor!=="transparent"&&d.fillRect(h.x,h.y,h.width,h.height);break;case"ellipse":{d.beginPath(),d.ellipse(h.x+h.width/2,h.y+h.height/2,Math.abs(h.width/2),Math.abs(h.height/2),0,0,Math.PI*2),d.stroke(),h.style.fillColor!=="transparent"&&d.fill();break}case"arrow":{const l=h;d.beginPath(),d.moveTo(l.x,l.y),d.lineTo(l.endX,l.endY),d.stroke();const u=Math.atan2(l.endY-l.y,l.endX-l.x),_=12;d.beginPath(),d.moveTo(l.endX,l.endY),d.lineTo(l.endX-_*Math.cos(u-Math.PI/6),l.endY-_*Math.sin(u-Math.PI/6)),d.lineTo(l.endX-_*Math.cos(u+Math.PI/6),l.endY-_*Math.sin(u+Math.PI/6)),d.closePath(),d.fillStyle=h.style.strokeColor,d.fill();break}case"line":{const l=h;d.beginPath(),d.moveTo(l.x,l.y),d.lineTo(l.endX,l.endY),d.stroke();break}case"text":{const l=h;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));break}case"freehand":{const l=h;if(l.points.length<2)break;d.beginPath(),d.moveTo(l.points[0].x,l.points[0].y);for(let u=1;u<l.points.length;u++)d.lineTo(l.points[u].x,l.points[u].y);d.stroke();break}case"blur":{const l=h;d.filter=`blur(${l.intensity??5}px)`,d.drawImage(z,l.x,l.y,l.width,l.height,l.x,l.y,l.width,l.height),d.filter="none";break}}h.id===w.selectedId&&(d.strokeStyle=r.resolveCssColor("var(--nice-color-primary, #4488ff)",d.canvas),d.lineWidth=1,d.setLineDash([4,4]),d.strokeRect(h.x-2,h.y-2,h.width+4,h.height+4),d.setLineDash([])),d.restore()}const b=R.current;if(b.isDrawing&&b.currentAnnotation){d.save();const h=b.currentAnnotation;if(d.globalAlpha=h.style.opacity,d.strokeStyle=h.style.strokeColor,d.lineWidth=h.style.strokeWidth,d.setLineDash([6,3]),h.tool==="freehand"){const l=h;if(l.points.length>=2){d.beginPath(),d.moveTo(l.points[0].x,l.points[0].y);for(let u=1;u<l.points.length;u++)d.lineTo(l.points[u].x,l.points[u].y);d.stroke()}}else if(h.tool==="rectangle")d.strokeRect(h.x,h.y,h.width,h.height);else if(h.tool==="ellipse")d.beginPath(),d.ellipse(h.x+h.width/2,h.y+h.height/2,Math.abs(h.width/2),Math.abs(h.height/2),0,0,Math.PI*2),d.stroke();else if(h.tool==="arrow"||h.tool==="line"){const l=h;d.beginPath(),d.moveTo(l.x,l.y),d.lineTo(l.endX,l.endY),d.stroke()}d.restore()}d.restore()},[w,ee]);n.useEffect(()=>{A()},[A]);const k=n.useCallback(N=>{if(T)return;const d=F(N.clientX,N.clientY),z=w.activeTool;if(z==="select"){const l=[...w.annotations].reverse().find(u=>u.tool==="freehand"?!1:d.x>=u.x&&d.x<=u.x+u.width&&d.y>=u.y&&d.y<=u.y+u.height);s({type:"SELECT",id:l?.id??null});return}const b=R.current;b.isDrawing=!0,b.startX=d.x,b.startY=d.y;const h={id:Wi(),style:{...w.style},x:d.x,y:d.y,width:0,height:0};switch(z){case"rectangle":b.currentAnnotation={...h,tool:"rectangle"};break;case"ellipse":b.currentAnnotation={...h,tool:"ellipse"};break;case"arrow":b.currentAnnotation={...h,tool:"arrow",endX:d.x,endY:d.y};break;case"line":b.currentAnnotation={...h,tool:"line",endX:d.x,endY:d.y};break;case"text":b.currentAnnotation={...h,tool:"text",text:X("imageAnnotator.text","Text"),width:100,height:w.style.fontSize??16};break;case"freehand":b.freehandPoints=[d],b.currentAnnotation={...h,tool:"freehand",points:[d]};break;case"blur":b.currentAnnotation={...h,tool:"blur",intensity:5};break}},[T,F,w.activeTool,w.style,w.annotations,X]),x=n.useCallback(N=>{const d=R.current;if(!d.isDrawing||!d.currentAnnotation)return;const z=F(N.clientX,N.clientY),b=d.currentAnnotation;if(b.tool==="freehand"){d.freehandPoints.push(z),b.points=[...d.freehandPoints];const h=d.freehandPoints.map(u=>u.x),l=d.freehandPoints.map(u=>u.y);b.x=Math.min(...h),b.y=Math.min(...l),b.width=Math.max(...h)-b.x,b.height=Math.max(...l)-b.y}else if(b.tool==="arrow"||b.tool==="line")b.endX=z.x,b.endY=z.y,b.width=Math.abs(z.x-d.startX),b.height=Math.abs(z.y-d.startY);else{const h=Math.min(d.startX,z.x),l=Math.min(d.startY,z.y);b.x=h,b.y=l,b.width=Math.abs(z.x-d.startX),b.height=Math.abs(z.y-d.startY)}A()},[F,A]),C=n.useCallback(()=>{const N=R.current;if(!N.isDrawing||!N.currentAnnotation)return;const d=N.currentAnnotation;(d.tool==="text"||d.tool==="freehand"||Math.abs(d.width)>2||Math.abs(d.height)>2)&&s({type:"ADD_ANNOTATION",annotation:d}),N.isDrawing=!1,N.currentAnnotation=null,N.freehandPoints=[]},[]),f=n.useCallback(N=>{N.preventDefault();const d=N.deltaY>0?.9:1.1,z=Math.max(P,Math.min(M,w.zoom*d));s({type:"SET_ZOOM",zoom:z})},[w.zoom,P,M]);n.useEffect(()=>{if(T)return;const N=d=>{(d.metaKey||d.ctrlKey)&&d.key==="z"&&!d.shiftKey?(d.preventDefault(),s({type:"UNDO"})):(d.metaKey||d.ctrlKey)&&(d.key==="y"||d.key==="z"&&d.shiftKey)?(d.preventDefault(),s({type:"REDO"})):(d.key==="Delete"||d.key==="Backspace")&&w.selectedId&&s({type:"DELETE_ANNOTATION",id:w.selectedId})};return document.addEventListener("keydown",N),()=>document.removeEventListener("keydown",N)},[T,w.selectedId]),n.useImperativeHandle(W,()=>({exportAsDataURL:async(N="png",d=.92)=>{const z=document.createElement("canvas"),b=ie.current;if(!b)return"";z.width=b.naturalWidth,z.height=b.naturalHeight;const h=z.getContext("2d");h.drawImage(b,0,0);for(const l of w.annotations){if(h.save(),h.globalAlpha=l.style.opacity,h.strokeStyle=l.style.strokeColor,h.fillStyle=l.style.fillColor,h.lineWidth=l.style.strokeWidth,l.tool==="rectangle")h.strokeRect(l.x,l.y,l.width,l.height);else if(l.tool==="ellipse")h.beginPath(),h.ellipse(l.x+l.width/2,l.y+l.height/2,Math.abs(l.width/2),Math.abs(l.height/2),0,0,Math.PI*2),h.stroke();else if(l.tool==="freehand"){const u=l;if(u.points.length>=2){h.beginPath(),h.moveTo(u.points[0].x,u.points[0].y);for(let _=1;_<u.points.length;_++)h.lineTo(u.points[_].x,u.points[_].y);h.stroke()}}else if(l.tool==="text"){const u=l;h.font=`${u.style.fontSize??16}px ${u.style.fontFamily??"sans-serif"}`,h.fillStyle=u.style.strokeColor,h.fillText(u.text,u.x,u.y+(u.style.fontSize??16))}h.restore()}return z.toDataURL(`image/${N}`,d)},exportAnnotations:()=>[...w.annotations],importAnnotations:N=>{s({type:"SET_ANNOTATIONS",annotations:N})},exportAsSVG:()=>{const{width:N,height:d}=G,z=w.annotations.map(Ji);return`<svg xmlns="http://www.w3.org/2000/svg" width="${N}" height="${d}" viewBox="0 0 ${N} ${d}">
|
|
302
|
-
${z.join(`
|
|
303
|
-
`)}
|
|
304
|
-
</svg>`},undo:()=>s({type:"UNDO"}),redo:()=>s({type:"REDO"}),setZoom:N=>{s({type:"SET_ZOOM",zoom:Math.max(P,Math.min(M,N))})},fitToScreen:()=>{const N=U.current,d=ie.current;if(!N||!d)return;const z=N.clientWidth/d.naturalWidth,b=N.clientHeight/d.naturalHeight,h=Math.min(z,b,1);s({type:"SET_ZOOM",zoom:h}),s({type:"SET_PAN",panX:0,panY:0})},clear:()=>s({type:"CLEAR"})}),[w.annotations,G,P,M]);const E=n.useCallback(N=>{if(N.touches.length!==1)return;const d=N.touches[0];k({clientX:d.clientX,clientY:d.clientY,preventDefault:()=>{}})},[k]),L=n.useCallback(N=>{if(N.touches.length!==1)return;const d=N.touches[0];x({clientX:d.clientX,clientY:d.clientY})},[x]);return e.jsx("div",{ref:U,className:`nice-image-annotator ${y??""}`,children:e.jsx("canvas",{ref:$,className:"nice-image-annotator__canvas",style:{cursor:w.activeTool==="select"?"default":"crosshair"},onMouseDown:k,onMouseMove:x,onMouseUp:C,onMouseLeave:C,onWheel:f,onTouchStart:E,onTouchMove:L,onTouchEnd:C,role:"img","aria-label":B})})}),{displayName:"NiceImageAnnotator"}),eo=[{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"}],jn=[{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}],vn=({src:t,initialCrop:i={x:10,y:10,width:80,height:80},initialRotation:a=0,initialZoom:o=1,aspectRatios:c=jn,defaultAspectRatio:g="free",customAspectRatio:y,showRotation:T=!0,showFlip:P=!0,showZoom:M=!0,minZoom:W=.5,maxZoom:X=3,zoomStep:B=.1,showGrid:$=!0,overlayColor:U="var(--nice-overlay-50, rgba(0, 0, 0, 0.5))",toolbarPosition:ie="bottom",toolbarCollapsible:ee=!1,defaultToolbarCollapsed:re=!1,onChange:G,tutorial:H,className:w="",style:s,"data-testid":R="nice-crop-editor"})=>{const{t:F}=r.useNiceTranslation(),A=n.useRef(null),k=n.useRef(null),[x,C]=n.useState(i),[f,E]=n.useState(a),[L,N]=n.useState(o),[d,z]=n.useState(!1),[b,h]=n.useState(!1),[l,u]=n.useState(g),[_,S]=n.useState(re),[m,D]=n.useState(!1),[O,V]=n.useState({x:0,y:0,crop:x}),v=l==="custom"?y:c.find(ne=>ne.value===l)?.ratio;n.useEffect(()=>{G?.({crop:x,rotation:f,flipH:d,flipV:b,zoom:L})},[x,f,d,b,L,G]);const q=n.useCallback((ne,we)=>{if(!v)return ne;const ae=A.current?.clientWidth??400,ue=A.current?.clientHeight??300,I=ne.width/100*ae,Y=ne.height/100*ue,le=I/Y;if(Math.abs(le-v)<.01)return ne;if(we?.includes("e")||we?.includes("w")){const Z=I/v/ue*100;return{...ne,height:Math.min(100-ne.y,Math.max(5,Z))}}else if(we?.includes("n")||we?.includes("s")){const Z=Y*v/ae*100;return{...ne,width:Math.min(100-ne.x,Math.max(5,Z))}}else{const Z=I/v/ue*100;return{...ne,height:Math.min(100-ne.y,Math.max(5,Z))}}},[v]),K=n.useCallback((ne,we)=>{we===!1||(ne.preventDefault(),ne.stopPropagation(),D(we),!A.current?.getBoundingClientRect())||V({x:ne.clientX,y:ne.clientY,crop:{...x}})},[x]),de=n.useCallback(ne=>{if(!m||!A.current)return;const we=A.current.getBoundingClientRect(),ae=(ne.clientX-O.x)/we.width*100,ue=(ne.clientY-O.y)/we.height*100;let I={...O.crop};if(m==="crop")I.x=Math.max(0,Math.min(100-I.width,O.crop.x+ae)),I.y=Math.max(0,Math.min(100-I.height,O.crop.y+ue));else{switch(m){case"resize-nw":I.x=Math.max(0,Math.min(O.crop.x+O.crop.width-5,O.crop.x+ae)),I.y=Math.max(0,Math.min(O.crop.y+O.crop.height-5,O.crop.y+ue)),I.width=O.crop.width-(I.x-O.crop.x),I.height=O.crop.height-(I.y-O.crop.y);break;case"resize-ne":I.y=Math.max(0,Math.min(O.crop.y+O.crop.height-5,O.crop.y+ue)),I.width=Math.max(5,Math.min(100-I.x,O.crop.width+ae)),I.height=O.crop.height-(I.y-O.crop.y);break;case"resize-sw":I.x=Math.max(0,Math.min(O.crop.x+O.crop.width-5,O.crop.x+ae)),I.width=O.crop.width-(I.x-O.crop.x),I.height=Math.max(5,Math.min(100-I.y,O.crop.height+ue));break;case"resize-se":I.width=Math.max(5,Math.min(100-I.x,O.crop.width+ae)),I.height=Math.max(5,Math.min(100-I.y,O.crop.height+ue));break;case"resize-n":I.y=Math.max(0,Math.min(O.crop.y+O.crop.height-5,O.crop.y+ue)),I.height=O.crop.height-(I.y-O.crop.y);break;case"resize-s":I.height=Math.max(5,Math.min(100-I.y,O.crop.height+ue));break;case"resize-e":I.width=Math.max(5,Math.min(100-I.x,O.crop.width+ae));break;case"resize-w":I.x=Math.max(0,Math.min(O.crop.x+O.crop.width-5,O.crop.x+ae)),I.width=O.crop.width-(I.x-O.crop.x);break}I=q(I,m.replace("resize-",""))}C(I)},[m,O,q]),he=n.useCallback(()=>{D(!1)},[]);n.useEffect(()=>{if(m)return document.addEventListener("mousemove",de),document.addEventListener("mouseup",he),()=>{document.removeEventListener("mousemove",de),document.removeEventListener("mouseup",he)}},[m,de,he]);const be=n.useCallback(()=>{E(ne=>(ne-90+360)%360)},[]),ge=n.useCallback(()=>{E(ne=>(ne+90)%360)},[]),fe=n.useCallback(()=>{z(ne=>!ne)},[]),me=n.useCallback(()=>{h(ne=>!ne)},[]),pe=n.useCallback(()=>{C(i),E(a),N(o),z(!1),h(!1),u(g)},[i,a,o,g]);n.useEffect(()=>{C(ne=>q(ne))},[l,q]);const te=`translate(-50%, -50%) scale(${L}) rotate(${f}deg) scaleX(${d?-1:1}) scaleY(${b?-1:1})`,ve=ie==="top"?"column-reverse":ie==="left"?"row-reverse":ie==="right"?"row":"column",_e=ie==="left"||ie==="right";return e.jsxs("div",{className:`nice-crop-editor nice-crop-editor--toolbar-${ie} ${w}`,style:{position:"relative",display:"flex",flexDirection:ve,gap:12,...s},"data-testid":R,children:[e.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:20},children:e.jsx(r.NiceTutorialButton,{steps:r.resolveTutorial(H,eo)})}),e.jsxs("div",{ref:A,className:"nice-crop-editor__container","data-testid":`${R}-container`,children:[e.jsx("img",{ref:k,src:t||void 0,alt:"",className:"nice-crop-editor__image",style:{transform:te},draggable:!1}),e.jsxs("div",{className:"nice-crop-editor__overlay",style:{backgroundColor:U},children:[e.jsx("div",{className:"nice-crop-editor__overlay-piece",style:{top:0,left:0,right:0,height:`${x.y}%`}}),e.jsx("div",{className:"nice-crop-editor__overlay-piece",style:{bottom:0,left:0,right:0,height:`${100-x.y-x.height}%`}}),e.jsx("div",{className:"nice-crop-editor__overlay-piece",style:{top:`${x.y}%`,left:0,width:`${x.x}%`,height:`${x.height}%`}}),e.jsx("div",{className:"nice-crop-editor__overlay-piece",style:{top:`${x.y}%`,right:0,width:`${100-x.x-x.width}%`,height:`${x.height}%`}})]}),e.jsxs("div",{className:"nice-crop-editor__crop-area",style:{left:`${x.x}%`,top:`${x.y}%`,width:`${x.width}%`,height:`${x.height}%`},onMouseDown:ne=>K(ne,"crop"),"data-testid":`${R}-crop-area`,children:[$&&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:ne=>K(ne,"resize-nw")}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--ne",onMouseDown:ne=>K(ne,"resize-ne")}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--sw",onMouseDown:ne=>K(ne,"resize-sw")}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--se",onMouseDown:ne=>K(ne,"resize-se")}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--n",onMouseDown:ne=>K(ne,"resize-n")}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--s",onMouseDown:ne=>K(ne,"resize-s")}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--e",onMouseDown:ne=>K(ne,"resize-e")}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--w",onMouseDown:ne=>K(ne,"resize-w")})]})]}),e.jsxs("div",{className:`nice-crop-editor__controls ${_?"nice-crop-editor__controls--collapsed":""}`,style:{display:"flex",flexDirection:_e?"column":"row",flexWrap:_e?"nowrap":"wrap",gap:8,alignItems:_e?"stretch":"center",flexShrink:0},children:[ee&&e.jsx("button",{type:"button",className:"nice-crop-editor__toolbar-toggle","aria-expanded":!_,"aria-label":_?F("cropEditor.showToolbar","Show toolbar"):F("cropEditor.hideToolbar","Hide toolbar"),onClick:()=>S(ne=>!ne),style:{alignSelf:"flex-start",background:"var(--nice-bg-secondary)",border:"1px solid var(--nice-border-color)",borderRadius:4,padding:"2px 8px",cursor:"pointer",color:"var(--nice-text-primary)",fontSize:12},children:e.jsx(r.NiceIcon,{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:F("aspectRatio","Aspect Ratio")}),e.jsx("div",{className:"nice-crop-editor__aspect-buttons",children:c.map(ne=>e.jsx("button",{type:"button",className:`nice-crop-editor__aspect-btn ${l===ne.value?"nice-crop-editor__aspect-btn--selected":""}`,onClick:()=>u(ne.value),title:ne.label,children:ne.label},ne.value))})]}),M&&e.jsxs("div",{className:"nice-crop-editor__control-group",children:[e.jsxs("label",{className:"nice-crop-editor__label",children:[F("zoom","Zoom"),": ",Math.round(L*100),"%"]}),e.jsx("input",{type:"range",className:"nice-crop-editor__slider",min:W,max:X,step:B,value:L,onChange:ne=>N(parseFloat(ne.target.value)),"data-testid":`${R}-zoom`})]}),e.jsxs("div",{className:"nice-crop-editor__control-group nice-crop-editor__control-group--row",children:[T&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"nice-crop-editor__btn",onClick:be,title:F("rotateLeft","Rotate Left"),"aria-label":F("rotateLeft","Rotate Left"),children:e.jsx(r.NiceIcon,{name:"reply",size:16})}),e.jsx("button",{type:"button",className:"nice-crop-editor__btn",onClick:ge,title:F("rotateRight","Rotate Right"),"aria-label":F("rotateRight","Rotate Right"),children:e.jsx(r.NiceIcon,{name:"forward",size:16})})]}),P&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:`nice-crop-editor__btn ${d?"nice-crop-editor__btn--active":""}`,onClick:fe,title:F("flipHorizontal","Flip Horizontal"),"aria-label":F("flipHorizontal","Flip Horizontal"),children:e.jsx(r.NiceIcon,{name:"shuffle",size:16})}),e.jsx("button",{type:"button",className:`nice-crop-editor__btn ${b?"nice-crop-editor__btn--active":""}`,onClick:me,title:F("flipVertical","Flip Vertical"),"aria-label":F("flipVertical","Flip Vertical"),children:e.jsx(r.NiceIcon,{name:"shuffle",size:16})})]}),e.jsx("button",{type:"button",className:"nice-crop-editor__btn nice-crop-editor__btn--reset",onClick:pe,title:F("reset","Reset"),"aria-label":F("reset","Reset"),children:e.jsx(r.NiceIcon,{name:"refresh",size:16})})]})]})]})]})};process.env.NODE_ENV!=="production"&&(vn.displayName="NiceCropEditor");const to=[{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"}],no=["highlight","underline","strikethrough","freehand","text","rect","arrow"],io={highlight:"edit",underline:"type",strikethrough:"type",freehand:"edit",text:"type",rect:"box",arrow:"arrow-right",stamp:"tag"},oo=Object.assign(n.forwardRef(({label:t,helperText:i,error:a,required:o,disabled:c,readOnly:g,size:y="md",id:T,className:P,style:M,accessMode:W,src:X,annotations:B=[],onAnnotationsChange:$,activeTool:U,onToolChange:ie,currentPage:ee=1,onPageChange:re,totalPages:G=1,defaultColor:H="var(--nice-warning, #ffff00)",tools:w=no,author:s,zoom:R=1,onZoomChange:F,onAnnotationClick:A,onAnnotationDelete:k,tutorial:x},C)=>{const f=r.useNiceAccessMode(W,T),E=f==="hidden";f==="disabled"&&(c=!0),f==="readOnly"&&(g=!0);const{t:L}=r.useNiceTranslation(),N=r.useControlId(T),d=B.filter(m=>m.page===ee),z=n.useCallback(m=>{ie?.(U===m?null:m)},[U,ie]),b=n.useCallback(m=>{if(g||!U||U==="freehand")return;const D=m.currentTarget.getBoundingClientRect(),O=(m.clientX-D.left)/D.width,V=(m.clientY-D.top)/D.height,v={id:`ann-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,tool:U,page:ee,x:O,y:V,color:H,author:s,createdAt:new Date().toISOString(),text:U==="text"?"":void 0};$?.([...B,v])},[g,U,ee,H,s,B,$]);if(E)return null;const h=t?e.jsxs("div",{className:"nice-pdf-annotation__label",children:[t,o&&e.jsx("span",{className:"nice-required",children:"*"})]}):void 0,l=g?void 0:e.jsxs("div",{className:"nice-pdf-annotation__toolbar",children:[w.map(m=>e.jsx("button",{type:"button",className:`nice-pdf-annotation__tool-btn${U===m?" nice-pdf-annotation__tool-btn--active":""}`,onClick:()=>z(m),disabled:c,title:L(`pdfTool_${m}`,m),children:e.jsx(r.NiceIcon,{name:io[m],size:16})},m)),e.jsx("span",{className:"nice-pdf-annotation__toolbar-sep"}),e.jsx("button",{type:"button",disabled:c,onClick:()=>F?.(Math.max(.25,R-.25)),title:L("zoomOut","Zoom out"),"aria-label":L("zoomOut","Zoom out"),children:e.jsx(r.NiceIcon,{name:"minus",size:16})}),e.jsxs("span",{className:"nice-pdf-annotation__zoom",children:[Math.round(R*100),"%"]}),e.jsx("button",{type:"button",disabled:c,onClick:()=>F?.(Math.min(4,R+.25)),title:L("zoomIn","Zoom in"),"aria-label":L("zoomIn","Zoom in"),children:e.jsx(r.NiceIcon,{name:"plus",size:16})})]}),u=e.jsxs("div",{className:"nice-pdf-annotation__pager",children:[e.jsx("button",{type:"button",disabled:c||ee<=1,onClick:()=>re?.(ee-1),"aria-label":L("prevPage","Previous page"),children:e.jsx(r.NiceIcon,{name:"chevron-left",size:16})}),e.jsx("span",{children:L("pageOf","{page} / {total}").replace("{page}",String(ee)).replace("{total}",String(G))}),e.jsx("button",{type:"button",disabled:c||ee>=G,onClick:()=>re?.(ee+1),"aria-label":L("nextPage","Next page"),children:e.jsx(r.NiceIcon,{name:"chevron-right",size:16})})]}),S=!!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(Je.NiceAppShell,{ref:C,flush:!0,id:N,className:`nice-pdf-annotation nice-size-${y}${P?` ${P}`:""}${a?" nice-error":""}${c?" nice-disabled":""}`,style:M,menubar:h,toolbar:l,bottomPanel:u,statusBar:S,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(r.NiceTutorialButton,{steps:r.resolveTutorial(x,to)})}),e.jsxs("div",{className:"nice-pdf-annotation__viewport",style:{transform:`scale(${R})`,transformOrigin:"top left"},children:[e.jsx("iframe",{src:X||void 0,className:"nice-pdf-annotation__frame",title:L("pdfViewer","PDF Viewer")}),e.jsx("div",{role:"presentation",className:"nice-pdf-annotation__layer",onClick:b,children:d.map(m=>e.jsxs("div",{role:"button",tabIndex:0,onKeyDown:r.clickOnActivationKey,className:`nice-pdf-annotation__mark nice-pdf-annotation__mark--${m.tool}`,style:{left:`${m.x*100}%`,top:`${m.y*100}%`,backgroundColor:m.color},onClick:D=>{D.stopPropagation(),A?.(m)},title:m.text??m.tool,children:[m.text&&e.jsx("span",{children:m.text}),!g&&e.jsx("button",{type:"button",className:"nice-pdf-annotation__mark-delete",onClick:D=>{D.stopPropagation(),k?.(m.id)},"aria-label":L("delete","Delete"),children:e.jsx(r.NiceIcon,{name:"close",size:14})})]},m.id))})]})]})})}),{displayName:"NicePDFAnnotationEditor"});function en(t,i){const a=i.getBoundingClientRect();let o,c,g;if("touches"in t){const y=t.touches[0];o=y.clientX-a.left,c=y.clientY-a.top,g=y.force}else"pressure"in t?(o=t.clientX-a.left,c=t.clientY-a.top,g=t.pressure):(o=t.clientX-a.left,c=t.clientY-a.top);return{x:o,y:c,time:Date.now(),pressure:g!==void 0?g:.5}}function tn(t,i,a,o,c){if(!i)return(a+o)/2;const g=Math.sqrt(Math.pow(t.x-i.x,2)+Math.pow(t.y-i.y,2))/Math.max(1,t.time-i.time),y=Math.min(g/5,1),T=o-y*(o-a),P=t.pressure??.5,M=a+P*(o-a);return T*.7+M*.3}function nn(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 ao=n.forwardRef(function(i,a){jt.injectStyleOnce(so,ro);const{value:o,onChange:c,onChangeDataUrl:g,label:y,width:T="100%",height:P=200,penColor:M="",penWidth:W=2,minWidth:X=.5,maxWidth:B=4,backgroundColor:$="",placeholder:U,showClearButton:ie=!0,showUndoButton:ee=!0,showColorPicker:re=!1,showSizeSlider:G=!1,velocityFilterWeight:H=.7,throttle:w=16,disabled:s=!1,readOnly:R=!1,displayMode:F=!1,onBegin:A,onEnd:k,className:x,"data-testid":C}=i,{t:f}=r.useNiceTranslation(),E=U||f("signature.placeholder","Sign here"),L=R||F,N=F?!1:ie,d=F?!1:ee,z=F?!1:re,b=F?!1:G,h=n.useRef(null),[l,u]=n.useState(o?.strokes??[]),[_,S]=n.useState([]),[m,D]=n.useState(!1),[O,V]=n.useState(M),[v,q]=n.useState(W),K=n.useRef(null),de=n.useRef(0),he=r.useThemeIsDark(h),be=$||(he?"#0f172a":"#ffffff"),ge=M||(he?"#f8fafc":"#111827"),fe=O||ge,me=l.length===0&&_.length===0;n.useEffect(()=>{const le=h.current;if(!le)return;const j=le.getContext("2d");if(!j)return;const Z=le.getBoundingClientRect(),oe=window.devicePixelRatio||1;le.width=Z.width*oe,le.height=Z.height*oe,j.scale(oe,oe),pe()},[T,P]);const pe=n.useCallback(()=>{const le=h.current;if(!le)return;const j=le.getContext("2d");if(!j)return;const Z=le.getBoundingClientRect();j.fillStyle=be,j.fillRect(0,0,Z.width,Z.height),l.forEach(oe=>{if(j.strokeStyle=oe.color||ge,!(oe.points.length<2))for(let se=1;se<oe.points.length;se++){const ye=oe.points[se-1],xe=oe.points[se],Ee=tn(xe,ye,X,B);nn(j,ye,xe,Ee)}})},[l,be,ge,X,B,H]);n.useEffect(()=>{pe()},[pe]),n.useEffect(()=>{o?.strokes&&u(o.strokes)},[o]),n.useEffect(()=>{const le=h.current;if(le)if(l.length===0)c?.(null),g?.(null);else{const j=le.getBoundingClientRect();c?.({strokes:l,width:j.width,height:j.height,timestamp:Date.now()}),g?.(le.toDataURL("image/png"))}},[l,c,g]);const te=n.useCallback(le=>{if(s||L)return;const j=h.current;if(!j)return;j.setPointerCapture(le.pointerId);const Z=en(le.nativeEvent,j);D(!0),S([Z]),K.current=Z,de.current=Z.time,A?.()},[s,L,A]),ve=n.useCallback(le=>{if(!m||s||L)return;const j=h.current;if(!j)return;const Z=j.getContext("2d");if(!Z)return;const oe=Date.now();if(oe-de.current<w)return;const se=en(le.nativeEvent,j),ye=K.current;if(ye){Z.strokeStyle=fe;const xe=tn(se,ye,X,B);nn(Z,ye,se,xe)}S(xe=>[...xe,se]),K.current=se,de.current=oe},[m,s,L,fe,X,B,H,w]),_e=n.useCallback(le=>{if(!m)return;const j=h.current;if(j&&j.releasePointerCapture(le.pointerId),_.length>0){const Z={points:_,color:fe,width:v};u(oe=>[...oe,Z])}D(!1),S([]),K.current=null,k?.()},[m,_,fe,v,k]),ne=n.useCallback(()=>{u([]),S([]),pe()},[pe]),we=n.useCallback(()=>{u(le=>le.slice(0,-1))},[]),ae=n.useCallback((le="png",j=.92)=>{const Z=h.current;if(!Z)return"";const oe=le==="jpeg"?"image/jpeg":"image/png";return Z.toDataURL(oe,j)},[]),ue=n.useCallback(async(le="png",j=.92)=>{const Z=h.current;return Z?new Promise(oe=>{const se=le==="jpeg"?"image/jpeg":"image/png";Z.toBlob(ye=>oe(ye),se,j)}):null},[]),I=n.useCallback(()=>{const le=h.current;if(!le)return"";const j=le.getBoundingClientRect(),Z=l.map(oe=>oe.points.length<2?"":`<path d="${oe.points.reduce((ye,xe,Ee)=>Ee===0?`M ${xe.x} ${xe.y}`:`${ye} L ${xe.x} ${xe.y}`,"")}" stroke="${oe.color||ge}" stroke-width="${oe.width}" fill="none" stroke-linecap="round" stroke-linejoin="round"/>`).join(`
|
|
305
|
-
`);return`<svg xmlns="http://www.w3.org/2000/svg" width="${j.width}" height="${j.height}" viewBox="0 0 ${le.width} ${le.height}">
|
|
306
|
-
<rect width="100%" height="100%" fill="${be}"/>
|
|
307
|
-
${Z}
|
|
308
|
-
</svg>`},[l,be,ge]);n.useImperativeHandle(a,()=>({clear:ne,undo:we,isEmpty:()=>l.length===0,getData:()=>{const le=h.current;if(!le||l.length===0)return null;const j=le.getBoundingClientRect();return{strokes:l,width:j.width,height:j.height,timestamp:Date.now()}},setData:le=>{u(le.strokes)},toDataURL:ae,toBlob:ue,toSVG:I,getCanvas:()=>h.current}),[l,ne,we,ae,ue,I]),n.useEffect(()=>{const le=h.current;if(!le)return;const j=Z=>{m&&Z.preventDefault()};return le.addEventListener("touchmove",j,{passive:!1}),()=>le.removeEventListener("touchmove",j)},[m]);const Y=N||d||z||b;return e.jsxs("div",{className:`nice-signature ${s?"nice-signature--disabled":""} ${L?"nice-signature--readonly":""} ${x??""}`,style:{width:T},"data-testid":C,children:[y&&e.jsx("label",{className:"nice-signature__label",children:y}),Y&&e.jsxs("div",{className:"nice-signature__toolbar",children:[z&&e.jsx("div",{className:"nice-signature__color-picker",children:e.jsx("input",{type:"color",value:O,onChange:le=>V(le.target.value),disabled:s||L,title:f("signature.penColor","Pen color")})}),b&&e.jsx("div",{className:"nice-signature__size-slider",children:e.jsx("input",{type:"range",min:X,max:B,step:.5,value:v,onChange:le=>q(parseFloat(le.target.value)),disabled:s||L,title:f("signature.penSize","Pen size")})}),e.jsxs("div",{className:"nice-signature__actions",children:[d&&e.jsx("button",{type:"button",onClick:we,disabled:s||L||l.length===0,className:"nice-signature__btn",title:f("signature.undo","Undo"),"aria-label":f("signature.undo","Undo"),children:e.jsx(r.NiceIcon,{name:"reply",size:16})}),N&&e.jsx("button",{type:"button",onClick:ne,disabled:s||L||me,className:"nice-signature__btn",title:f("signature.clear","Clear"),"aria-label":f("signature.clear","Clear"),children:e.jsx(r.NiceIcon,{name:"trash",size:16})})]})]}),e.jsxs("div",{className:"nice-signature__canvas-wrapper",style:{height:P},children:[e.jsx("canvas",{ref:h,className:"nice-signature__canvas",style:{width:"100%",height:"100%",cursor:s||L?"not-allowed":"crosshair",touchAction:"none"},onPointerDown:te,onPointerMove:ve,onPointerUp:_e,onPointerLeave:_e}),me&&!m&&E&&e.jsx("div",{className:"nice-signature__placeholder",children:E}),e.jsx("div",{className:"nice-signature__line"})]})]})}),so="nice-signature-styles",ro=`
|
|
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-tertiary, #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
|
-
`,co=Object.assign(n.forwardRef(({label:t,helperText:i,error:a,required:o,disabled:c,readOnly:g,size:y="md",id:T,className:P,style:M,accessMode:W,mode:X="manual",onScan:B,onModeChange:$,beepOnScan:U=!0,beepFrequency:ie=1800,beepDuration:ee=150,placeholder:re,scanHistory:G=[],showHistory:H=!0,maxHistory:w=10,autoFocus:s=!0,onCameraFrame:R},F)=>{const A=r.useNiceAccessMode(W,T),k=A==="hidden";A==="disabled"&&(c=!0),A==="readOnly"&&(g=!0);const{t:x}=r.useNiceTranslation(),C=r.useControlId(T),[f,E]=n.useState(""),L=n.useRef(null),N=n.useRef(null),d=n.useCallback(()=>{if(U)try{N.current||(N.current=new AudioContext);const h=N.current,l=h.createOscillator(),u=h.createGain();l.connect(u),u.connect(h.destination),l.frequency.value=ie,l.type="square",u.gain.value=.3,l.start(),l.stop(h.currentTime+ee/1e3)}catch{}},[U,ie,ee]),z=n.useCallback(()=>{f.trim()&&(d(),B?.({value:f.trim(),format:"manual",scannedAt:new Date}),E(""),L.current?.focus())},[f,B,d]),b=G.slice(0,w);return k?null:e.jsxs("div",{ref:F,id:C,className:`nice-scanner nice-size-${y}${P?` ${P}`:""}${a?" nice-error":""}${c?" nice-disabled":""}`,style:M,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${X==="camera"?" nice-scanner__mode-btn--active":""}`,onClick:()=>$?.("camera"),disabled:c,children:[e.jsx(r.NiceIcon,{name:"camera",size:16})," ",x("camera","Camera")]}),e.jsxs("button",{type:"button",className:`nice-scanner__mode-btn${X==="manual"?" nice-scanner__mode-btn--active":""}`,onClick:()=>$?.("manual"),disabled:c,children:[e.jsx(r.NiceIcon,{name:"edit",size:16})," ",x("manual","Manual")]})]}),X==="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(r.NiceIcon,{name:"camera",size:32})}),e.jsx("p",{children:x("cameraPlaceholder","Camera preview — connect scanner adapter")})]})})}),X==="manual"&&!g&&e.jsxs("div",{className:"nice-scanner__manual",children:[e.jsx("input",{ref:L,className:"nice-input nice-scanner__input",type:"text",value:f,onChange:h=>E(h.target.value),onKeyDown:h=>h.key==="Enter"&&z(),placeholder:re??x("enterCode","Enter or scan code…"),disabled:c,autoFocus:s}),e.jsx("button",{type:"button",className:"nice-scanner__submit",onClick:z,disabled:c||!f.trim(),"aria-label":x("submit","Submit"),children:e.jsx(r.NiceIcon,{name:"check",size:16})})]}),H&&b.length>0&&e.jsxs("div",{className:"nice-scanner__history",children:[e.jsx("div",{className:"nice-scanner__history-label",children:x("recentScans","Recent scans")}),b.map((h,l)=>e.jsxs("div",{className:"nice-scanner__history-item",children:[e.jsx("span",{className:"nice-scanner__history-value",children:h.value}),h.format&&e.jsx("span",{className:"nice-scanner__history-format",children:h.format}),e.jsx("span",{className:"nice-scanner__history-time",children:h.scannedAt.toLocaleTimeString()})]},l))]}),i&&e.jsx("span",{className:"nice-helper-text",children:i}),a&&typeof a=="string"&&e.jsx("span",{className:"nice-error-text",children:a})]})}),{displayName:"NiceScannerControl"}),lo=[{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 mo=1;function uo(t){return{id:`new-${mo++}`,description:"",quantity:1,unitPrice:0,vatRate:t,discount:0,unit:"pcs"}}function _n(t){const a=t.quantity*t.unitPrice*(1-(t.discount??0)/100),o=Math.round(a*100)/100,c=Math.round(o*(t.vatRate??0)/100*100)/100;return{...t,netAmount:o,grossAmount:o+c}}function po(t){const i=t.map(_n),a=i.reduce((T,P)=>T+(P.netAmount??0),0),o=i.reduce((T,P)=>T+(P.grossAmount??0),0),c=o-a,g=new Map;for(const T of i){const P=T.vatRate??0,M=g.get(P)??{base:0,amount:0};M.base+=T.netAmount??0,M.amount+=(T.grossAmount??0)-(T.netAmount??0),g.set(P,M)}const y=Array.from(g.entries()).map(([T,P])=>({rate:T,base:Math.round(P.base*100)/100,amount:Math.round(P.amount*100)/100}));return{totalNet:Math.round(a*100)/100,totalVat:Math.round(c*100)/100,totalGross:Math.round(o*100)/100,vatBreakdown:y}}const ho={pl:"PLN",cs:"CZK",sk:"EUR",hu:"HUF",ro:"RON",bg:"BGN",uk:"UAH",de:"EUR",fr:"EUR",es:"EUR",it:"EUR",nl:"EUR",pt:"EUR",fi:"EUR",sv:"SEK",no:"NOK",da:"DKK",ja:"JPY",zh:"CNY",ko:"KRW",hi:"INR",th:"THB",vi:"VND",id:"IDR",ms:"MYR",fil:"PHP",bn:"BDT",ar:"AED",sw:"KES"};function go(t){const i=ho[t];if(!i)return"$";try{return new Intl.NumberFormat(t,{style:"currency",currency:i,minimumFractionDigits:0,maximumFractionDigits:0}).formatToParts(0).find(o=>o.type==="currency")?.value??"$"}catch{return"$"}}const fo=["pcs","h","kg","m","svc"],yo=Object.assign(n.forwardRef(({label:t,helperText:i,error:a,required:o,disabled:c,readOnly:g,size:y="md",name:T,id:P,className:M,style:W,accessMode:X,value:B=[],onChange:$,onTotalsChange:U,currencySymbol:ie,defaultVatRate:ee=23,vatRates:re=[0,5,8,23],units:G,showDiscount:H=!0,showUnit:w=!0,showTotals:s=!0,editable:R=!0,maxLines:F,tutorial:A},k)=>{const x=r.useNiceAccessMode(X,P),C=x==="hidden";x==="disabled"&&(c=!0),x==="readOnly"&&(g=!0);const{t:f,lang:E}=r.useNiceTranslation(),L=r.useControlId(P),N=n.useMemo(()=>ie??go(E),[ie,E]),d=n.useMemo(()=>G??fo.map(S=>f(`invoice.unit.${S}`,S)),[G,f]),z=n.useMemo(()=>B.map(_n),[B]),b=n.useMemo(()=>po(B),[B]);n.useEffect(()=>{U?.(b)},[b,U]);const h=n.useCallback((S,m,D)=>{const O=[...B];O[S]={...O[S],[m]:D},$?.(O)},[B,$]),l=n.useCallback(()=>{F&&B.length>=F||$?.([...B,uo(ee)])},[B,$,ee,F]),u=n.useCallback(S=>{$?.(B.filter((m,D)=>D!==S))},[B,$]),_=S=>`${S.toFixed(2)} ${N}`;return C?null:e.jsxs("div",{ref:k,id:L,className:`nice-invoice-lines nice-size-${y}${M?` ${M}`:""}${a?" nice-error":""}${c?" nice-disabled":""}`,style:{position:"relative",...W},children:[e.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:20},children:e.jsx(r.NiceTutorialButton,{steps:r.resolveTutorial(A,lo)})}),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:f("description","Description")}),e.jsx("th",{className:"nice-il__th-qty",children:f("qty","Qty")}),w&&e.jsx("th",{className:"nice-il__th-unit",children:f("unit","Unit")}),e.jsx("th",{className:"nice-il__th-price",children:f("unitPrice","Unit Price")}),H&&e.jsx("th",{className:"nice-il__th-disc",children:f("invoice.discountPct","Disc %")}),e.jsx("th",{className:"nice-il__th-vat",children:f("invoice.vatPct","VAT %")}),e.jsx("th",{className:"nice-il__th-net",children:f("net","Net")}),e.jsx("th",{className:"nice-il__th-gross",children:f("gross","Gross")}),R&&!g&&e.jsx("th",{className:"nice-il__th-actions"})]})}),e.jsx("tbody",{children:z.map((S,m)=>e.jsxs("tr",{children:[e.jsx("td",{className:"nice-il__cell-num",children:m+1}),e.jsx("td",{className:"nice-il__cell-desc",children:e.jsx("input",{className:"nice-input",type:"text",value:S.description,onChange:D=>h(m,"description",D.target.value),disabled:c,readOnly:g,placeholder:f("itemDescription","Item description")})}),e.jsx("td",{className:"nice-il__cell-qty",children:e.jsx("input",{className:"nice-input",type:"number",value:S.quantity,onChange:D=>h(m,"quantity",parseFloat(D.target.value)||0),disabled:c,readOnly:g,min:0,step:"any"})}),w&&e.jsx("td",{className:"nice-il__cell-unit",children:e.jsx("select",{className:"nice-select",value:S.unit??"",onChange:D=>h(m,"unit",D.target.value),disabled:c,children:d.map(D=>e.jsx("option",{value:D,children:D},D))})}),e.jsx("td",{className:"nice-il__cell-price",children:e.jsx("input",{className:"nice-input",type:"number",value:S.unitPrice,onChange:D=>h(m,"unitPrice",parseFloat(D.target.value)||0),disabled:c,readOnly:g,min:0,step:"0.01"})}),H&&e.jsx("td",{className:"nice-il__cell-disc",children:e.jsx("input",{className:"nice-input",type:"number",value:S.discount??0,onChange:D=>h(m,"discount",parseFloat(D.target.value)||0),disabled:c,readOnly:g,min:0,max:100})}),e.jsx("td",{className:"nice-il__cell-vat",children:e.jsx("select",{className:"nice-select",value:S.vatRate??0,onChange:D=>h(m,"vatRate",parseInt(D.target.value,10)),disabled:c,children:re.map(D=>e.jsxs("option",{value:D,children:[D,"%"]},D))})}),e.jsx("td",{className:"nice-il__cell-net",children:_(S.netAmount??0)}),e.jsx("td",{className:"nice-il__cell-gross",children:_(S.grossAmount??0)}),R&&!g&&e.jsx("td",{className:"nice-il__cell-actions",children:e.jsx("button",{type:"button",className:"nice-btn nice-btn--icon nice-btn--sm",onClick:()=>u(m),disabled:c,title:f("remove","Remove"),"aria-label":f("remove","Remove"),children:e.jsx(r.NiceIcon,{name:"close",size:14})})})]},S.id))})]}),R&&!g&&e.jsxs("button",{type:"button",className:"nice-btn nice-btn--outlined nice-btn--sm nice-invoice-lines__add",onClick:l,disabled:c||F!=null&&B.length>=F,children:["+ ",f("addLine","Add line")]}),s&&e.jsxs("div",{className:"nice-invoice-lines__totals",children:[e.jsxs("div",{className:"nice-il__total-row",children:[e.jsxs("span",{children:[f("totalNet","Net total"),":"]}),e.jsx("span",{className:"nice-il__total-value",children:_(b.totalNet)})]}),b.vatBreakdown.map(S=>e.jsxs("div",{className:"nice-il__total-row nice-il__total-row--vat",children:[e.jsx("span",{children:f("invoice.vat","VAT {rate}%:").replace("{rate}",String(S.rate))}),e.jsx("span",{className:"nice-il__total-value",children:_(S.amount)})]},S.rate)),e.jsxs("div",{className:"nice-il__total-row nice-il__total-row--gross",children:[e.jsxs("span",{children:[f("totalGross","Gross total"),":"]}),e.jsx("span",{className:"nice-il__total-value nice-il__total-value--gross",children:_(b.totalGross)})]})]}),i&&e.jsx("span",{className:"nice-helper-text",children:i}),a&&typeof a=="string"&&e.jsx("span",{className:"nice-error-text",children:a})]})}),{displayName:"NiceInvoiceLineEditor"}),xo=Object.assign(n.forwardRef(({value:t="",onChange:i,suggestions:a=[],onSearch:o,trigger:c="@",renderSuggestion:g,placeholder:y,rows:T=3,label:P,helperText:M,error:W,required:X,disabled:B,readOnly:$,loading:U,labelPlacement:ie,errorPlacement:ee,labelWidth:re,controlWidth:G,size:H="md",name:w,id:s,className:R,style:F,...A},k)=>{const x=r.useControlId(s),[C,f]=n.useState(!1),[E,L]=n.useState(""),[N,d]=n.useState(0),[z,b]=n.useState({top:0,left:0}),h=n.useRef(null),l=n.useRef(-1),_=a.map(K=>typeof K=="string"?{key:K,label:K}:K).filter(K=>K.label.toLowerCase().includes(E.toLowerCase())),S=n.useCallback(()=>{f(!1),L(""),d(0),l.current=-1},[]),m=n.useCallback(K=>{const de=h.current;if(!de||l.current<0)return;const he=t.slice(0,l.current),be=t.slice(de.selectionStart),ge=`${c}${K.label} `,fe=he+ge+be;i?.(fe),S(),requestAnimationFrame(()=>{const me=he.length+ge.length;de.setSelectionRange(me,me),de.focus()})},[t,i,c,S]),D=n.useCallback(K=>{const de=K.target.value;i?.(de);const he=K.target.selectionStart,be=de.slice(0,he),ge=be.lastIndexOf(c);if(ge>=0){const fe=ge>0?be[ge-1]:" ",me=be.slice(ge+c.length);if(/\s/.test(fe)&&!/\s/.test(me)){l.current=ge;const pe=me;L(pe),f(!0),d(0),o?.(pe);const te=K.target,ve=te.getBoundingClientRect(),_e=parseInt(getComputedStyle(te).lineHeight)||20,ne=be.split(`
|
|
430
|
-
`);b({top:ve.top+ne.length*_e+4-te.scrollTop,left:ve.left+8});return}}S()},[i,c,o,S]),O=n.useCallback(K=>{!C||_.length===0||(K.key==="ArrowDown"?(K.preventDefault(),d(de=>(de+1)%_.length)):K.key==="ArrowUp"?(K.preventDefault(),d(de=>(de-1+_.length)%_.length)):K.key==="Enter"?(K.preventDefault(),_[N]&&m(_[N])):K.key==="Escape"&&S())},[C,_,N,m,S]),V=C&&_.length>0,v=n.useRef(null),q=`${x}-suggestions`;return r.useIntent(["navigate","activate"],K=>{if(K.source==="keyboard")return!1;if(K.intent==="activate"){const he=_[N];if(!he)return!1;m(he);return}if(K.direction!=="up"&&K.direction!=="down")return!1;const de=K.direction==="down"?1:-1;d(he=>(he+de+_.length)%_.length)},{ref:v,enabled:V}),n.useEffect(()=>{if(!C)return;const K=de=>{const he=h.current;he&&!he.contains(de.target)&&S()};return document.addEventListener("mousedown",K),()=>document.removeEventListener("mousedown",K)},[C,S]),e.jsxs("div",{className:`nice-field nice-field--${H} ${ie==="left"?"nice-field--label-left":""} ${ee==="right"?"nice-field--error-right":""} ${U?"nice-field--loading":""} ${R||""}`,style:{...F,...re!=null&&{"--nice-field-label-width":typeof re=="number"?`${re}px`:re},...G!=null&&{"--nice-field-control-width":typeof G=="number"?`${G}px`:G}},"aria-busy":U||void 0,...A,children:[P&&e.jsx("label",{htmlFor:x,className:`nice-field__label ${X?"nice-field__label--required":""}`,children:P}),e.jsxs("div",{className:"nice-field__control",children:[e.jsxs("div",{ref:v,className:`nice-mention nice-mention--${H} ${W?"nice-mention--error":""} ${B?"nice-mention--disabled":""}`,children:[e.jsx("textarea",{ref:K=>{h.current=K,typeof k=="function"?k(K):k&&(k.current=K)},id:x,name:w,className:"nice-mention__input",value:t,onChange:D,onKeyDown:O,placeholder:y,rows:T,disabled:B,readOnly:$,"aria-invalid":!!W,"aria-describedby":W?`${x}-error`:M?`${x}-helper`:void 0,"aria-autocomplete":"list","aria-expanded":V,"aria-controls":V?q:void 0,"aria-activedescendant":V?`${q}-${N}`:void 0}),V&&e.jsx("ul",{id:q,className:"nice-mention__suggestions",role:"listbox",style:{position:"fixed",top:z.top,left:z.left},children:_.map((K,de)=>e.jsx("li",{id:`${q}-${de}`,role:"option","aria-selected":de===N,className:`nice-mention__suggestion ${de===N?"nice-mention__suggestion--active":""}`,onMouseDown:he=>{he.preventDefault(),m(K)},onMouseEnter:()=>d(de),children:g?g(K):e.jsxs(e.Fragment,{children:[K.icon&&e.jsx("span",{className:"nice-mention__suggestion-icon",children:K.icon}),e.jsx("span",{children:K.label})]})},K.key))})]}),U&&e.jsx("span",{className:"nice-field__spinner",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})}),ee==="right"&&W&&e.jsx("div",{id:`${x}-error`,className:"nice-field__error",role:"alert",children:W}),ee==="right"&&!W&&M&&e.jsx("div",{id:`${x}-helper`,className:"nice-field__helper",children:M})]}),ee!=="right"&&W&&e.jsx("div",{id:`${x}-error`,className:"nice-field__error",role:"alert",children:W}),ee!=="right"&&!W&&M&&e.jsx("div",{id:`${x}-helper`,className:"nice-field__helper",children:M})]})}),{displayName:"NiceMention"});exports.DEFAULT_ASPECT_RATIOS=jn;exports.EMOJI_DATA=xt;exports.GRADIENT_PRESETS=yn;exports.NICE_COLOR_PRESET_KEYS=hn;exports.NiceAccountPicker=Bi;exports.NiceAddressInput=Li;exports.NiceCodeEditorAI=vi;exports.NiceColorPalette=ei;exports.NiceContactPicker=Hi;exports.NiceCropEditor=vn;exports.NiceDateRangeBox=Kn;exports.NiceDocumentEditor=xi;exports.NiceDropDownBox=Ln;exports.NiceEmojiPicker=bn;exports.NiceGradientPicker=ii;exports.NiceHtmlEditorAI=si;exports.NiceImageAnnotator=Qi;exports.NiceImageEditor=Xi;exports.NiceInputOtp=Ki;exports.NiceInvoiceLineEditor=yo;exports.NiceKeyValueEditor=Ri;exports.NiceKnob=Rn;exports.NiceLogConsole=xn;exports.NiceLookup=An;exports.NiceMarkdownEditor=mi;exports.NiceMention=xo;exports.NicePDFAnnotationEditor=oo;exports.NicePickList=Hn;exports.NiceRangeSlider=Mn;exports.NiceScannerControl=co;exports.NiceScriptRunner=$i;exports.NiceSignature=ao;exports.NiceTreeSelect=zn;exports.NiceWiki=ji;exports.applyPreset=yt;exports.contrastRatio=gt;exports.cssToGradient=fn;exports.generateHarmony=rt;exports.generateVariations=mn;exports.gradientToCss=Mt;exports.hexToHsv=Fe;exports.hexToRgb=ct;exports.hsvToHex=Pe;exports.hsvToRgb=cn;exports.randomPalette=pn;exports.rgbToHex=dn;exports.rgbToHsl=ln;exports.rgbToHsv=Rt;exports.wcagLevel=ft;
|