@nice2dev/ui 1.4.1 → 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.
Files changed (43) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/dist/NiceCodeEditor-DhdjnDLV.cjs +289 -0
  3. package/dist/{NiceDataGrid-BT6iCUgP.cjs → NiceDataGrid-CrKDzMM1.cjs} +1 -1
  4. package/dist/{NiceForm-Bysp66Ef.cjs → NiceForm-CT9hEXpc.cjs} +1 -1
  5. package/dist/NiceLoginForm-C2-WgRn0.cjs +1 -0
  6. package/dist/NiceMention-BZEHqPrf.cjs +432 -0
  7. package/dist/NiceModuleLifecyclePanel-DKlqKPy2.cjs +1 -0
  8. package/dist/{NiceSavedQueryPanel-BbznsXFd.cjs → NiceSavedQueryPanel-C5Ab_NWx.cjs} +1 -1
  9. package/dist/NiceScheduler-BZQAKEVF.cjs +5 -0
  10. package/dist/{NiceWindow-pgR4c-kQ.cjs → NiceWindow-BklnkBpu.cjs} +1 -1
  11. package/dist/charts/NiceLinearGauge.mjs +96 -83
  12. package/dist/charts/NicePolarChart.mjs +47 -47
  13. package/dist/charts-BzlvCCg9.cjs +768 -0
  14. package/dist/charts.cjs +1 -1
  15. package/dist/{core-lazy-CL4ZIxF-.cjs → core-lazy-VTd5zfoZ.cjs} +1 -1
  16. package/dist/data.cjs +1 -1
  17. package/dist/display/NiceAvatar.mjs +40 -24
  18. package/dist/editors/pickers/NiceDateRangeBox.mjs +92 -92
  19. package/dist/editors/pickers/NiceDateTimePicker.mjs +173 -173
  20. package/dist/editors/rich/NiceCodeEditor.mjs +645 -584
  21. package/dist/editors/rich/NiceDocumentEditor.mjs +277 -254
  22. package/dist/editors.cjs +1 -1
  23. package/dist/feedback/NiceDrawer.mjs +15 -15
  24. package/dist/feedback.cjs +1 -1
  25. package/dist/index.cjs +202 -202
  26. package/dist/index.d.ts +18 -0
  27. package/dist/lazy.cjs +1 -1
  28. package/dist/navigation/NiceNavShell.mjs +646 -593
  29. package/dist/navigation/NiceSidebarNav.mjs +844 -823
  30. package/dist/navigation.cjs +1 -1
  31. package/dist/overlays/NiceWindow.mjs +91 -91
  32. package/dist/overlays.cjs +1 -1
  33. package/dist/planning/NiceScheduler.mjs +170 -169
  34. package/dist/planning/NiceSchedulerViews.mjs +242 -233
  35. package/dist/style.css +2 -2
  36. package/dist/utility/intlNames.mjs +26 -16
  37. package/package.json +4 -4
  38. package/dist/NiceCodeEditor-D0QZW88r.cjs +0 -268
  39. package/dist/NiceLoginForm-FGf32sro.cjs +0 -1
  40. package/dist/NiceMention-sc8W-DwH.cjs +0 -430
  41. package/dist/NiceModuleLifecyclePanel-DBQPCa_V.cjs +0 -1
  42. package/dist/NiceScheduler-3Ez0zSQJ.cjs +0 -5
  43. package/dist/charts-B0tHOpJ7.cjs +0 -768
@@ -1,4 +1,4 @@
1
- "use strict";const e=require("react/jsx-runtime"),hi=require("@nice2dev/i18n"),N=require("@nice2dev/ui-core"),n=require("react"),mi=require("./NiceDataGrid-BT6iCUgP.cjs"),He=require("./NiceButton-DzCqkG5a.cjs"),fi=require("./NiceForm-Bysp66Ef.cjs"),pi=require("./NiceModal-BRVzjuUN.cjs"),gi=require("./core-lBFqvT0V.cjs"),_i=require("./NiceSelect-BNPXs6FQ.cjs"),Ln=require("./no-code-B3BHeyG-.cjs"),Pn=require("./NiceColorPicker-BLwYNSXJ.cjs"),bi=[];function xi(t,a){return t.filter(s=>a.every(r=>{const l=s[r.field],o=r.value;switch(r.operator){case"eq":return l===o;case"ne":return l!==o;case"gt":return typeof l=="number"&&typeof o=="number"&&l>o;case"gte":return typeof l=="number"&&typeof o=="number"&&l>=o;case"lt":return typeof l=="number"&&typeof o=="number"&&l<o;case"lte":return typeof l=="number"&&typeof o=="number"&&l<=o;case"contains":return String(l).toLowerCase().includes(String(o).toLowerCase());case"startsWith":return String(l).toLowerCase().startsWith(String(o).toLowerCase());case"endsWith":return String(l).toLowerCase().endsWith(String(o).toLowerCase());default:return!0}}))}function yi(t){return t.map(a=>({field:a.field,type:a.dataType||"string",label:typeof a.header=="string"?a.header:a.field}))}function vi(t,a){const{enableAI:s=!0,aiModel:r,enableNLSearch:l=!0,enableInsights:o=!0,nlPlaceholder:d,onAIFilter:c,onInsights:f,showAISearchBar:m=!0,exampleQueries:w=["Show items from last week","Filter by status = active","Orders over $1000",'Names starting with "A"'],columns:E=bi,data:P,...R}=t,[T,K]=n.useState(""),[p,b]=n.useState([]),[I,_]=n.useState([]),[z,C]=n.useState(!1),[G,H]=n.useState(null),he=n.useRef(null),{t:se}=hi.useNiceTranslation(),fe=N.useNiceAI(),{parseFilter:Ie,isLoading:ee}=N.useNaturalLanguageFilter(),we=s&&fe.isConfigured,B=p.length>0?xi(P||[],p):P,$e=n.useCallback(async A=>{if(!we||!l||!A.trim())return;H(A);const g=yi(E);try{const pe=await Ie(A,g);b(pe),c?.(A,pe)}catch{b([])}},[we,l,E,Ie,c]),ke=n.useCallback(()=>{b([]),H(null),K("")},[]),Pe=n.useCallback(()=>p,[p]),Z=n.useCallback(async()=>{if(!we||!o||!P?.length)return[];try{const A=await fe.complete([{role:"user",content:`Analyze this data and provide 3-5 key insights. Data sample (${P.length} total rows): ${JSON.stringify(P.slice(0,20))}
1
+ "use strict";const e=require("react/jsx-runtime"),hi=require("@nice2dev/i18n"),N=require("@nice2dev/ui-core"),n=require("react"),mi=require("./NiceDataGrid-CrKDzMM1.cjs"),He=require("./NiceButton-DzCqkG5a.cjs"),fi=require("./NiceForm-CT9hEXpc.cjs"),pi=require("./NiceModal-BRVzjuUN.cjs"),gi=require("./core-lBFqvT0V.cjs"),_i=require("./NiceSelect-BNPXs6FQ.cjs"),Ln=require("./no-code-B3BHeyG-.cjs"),Pn=require("./NiceColorPicker-BLwYNSXJ.cjs"),bi=[];function xi(t,a){return t.filter(s=>a.every(r=>{const l=s[r.field],o=r.value;switch(r.operator){case"eq":return l===o;case"ne":return l!==o;case"gt":return typeof l=="number"&&typeof o=="number"&&l>o;case"gte":return typeof l=="number"&&typeof o=="number"&&l>=o;case"lt":return typeof l=="number"&&typeof o=="number"&&l<o;case"lte":return typeof l=="number"&&typeof o=="number"&&l<=o;case"contains":return String(l).toLowerCase().includes(String(o).toLowerCase());case"startsWith":return String(l).toLowerCase().startsWith(String(o).toLowerCase());case"endsWith":return String(l).toLowerCase().endsWith(String(o).toLowerCase());default:return!0}}))}function yi(t){return t.map(a=>({field:a.field,type:a.dataType||"string",label:typeof a.header=="string"?a.header:a.field}))}function vi(t,a){const{enableAI:s=!0,aiModel:r,enableNLSearch:l=!0,enableInsights:o=!0,nlPlaceholder:d,onAIFilter:c,onInsights:f,showAISearchBar:m=!0,exampleQueries:w=["Show items from last week","Filter by status = active","Orders over $1000",'Names starting with "A"'],columns:E=bi,data:P,...R}=t,[T,K]=n.useState(""),[p,b]=n.useState([]),[I,_]=n.useState([]),[z,C]=n.useState(!1),[G,H]=n.useState(null),he=n.useRef(null),{t:se}=hi.useNiceTranslation(),fe=N.useNiceAI(),{parseFilter:Ie,isLoading:ee}=N.useNaturalLanguageFilter(),we=s&&fe.isConfigured,B=p.length>0?xi(P||[],p):P,$e=n.useCallback(async A=>{if(!we||!l||!A.trim())return;H(A);const g=yi(E);try{const pe=await Ie(A,g);b(pe),c?.(A,pe)}catch{b([])}},[we,l,E,Ie,c]),ke=n.useCallback(()=>{b([]),H(null),K("")},[]),Pe=n.useCallback(()=>p,[p]),Z=n.useCallback(async()=>{if(!we||!o||!P?.length)return[];try{const A=await fe.complete([{role:"user",content:`Analyze this data and provide 3-5 key insights. Data sample (${P.length} total rows): ${JSON.stringify(P.slice(0,20))}
2
2
 
3
3
  Columns: ${E.map(g=>g.field).join(", ")}
4
4
 
@@ -0,0 +1,5 @@
1
+ "use strict";const t=require("react/jsx-runtime"),H=require("@nice2dev/ui-core"),D=require("react"),re=require("./NiceButton-DzCqkG5a.cjs"),Q=require("./NiceForm-CT9hEXpc.cjs"),Te=require("./devops-cgRBnZVX.cjs"),_t=require("./NiceColorPicker-BLwYNSXJ.cjs"),xt=require("./NiceModal-BRVzjuUN.cjs"),$e=({children:e,className:n,style:c,"data-testid":d,direction:a="horizontal",size:o,disabled:x,readOnly:_,loading:b,error:E,errorPlacement:w="bottom"})=>{const f=t.jsxs("div",{className:`nice-btn-group ${a==="vertical"?"nice-btn-group--vertical":""} ${b?"nice-btn-group--loading":""} ${_?"nice-btn-group--readonly":""} ${n||""}`,style:c,role:"group","data-testid":d,"aria-busy":b||void 0,children:[D.Children.map(e,s=>{if(!D.isValidElement(s))return s;const N={};return x&&(N.disabled=!0),_&&(N.disabled=!0),b&&(N.disabled=!0),o&&(N.size=o),D.cloneElement(s,N)}),b&&t.jsx("span",{className:"nice-btn-group__spinner",children:t.jsx("span",{className:"nice-spinner nice-spinner--sm"})})]});if(!E)return f;const C=t.jsx("div",{className:"nice-field__error",role:"alert",children:E});return w==="right"?t.jsxs("span",{className:`nice-btn-field nice-btn-field--right ${o?`nice-field--${o}`:""}`,children:[f,C]}):t.jsxs("span",{className:`nice-btn-field nice-btn-field--bottom ${o?`nice-field--${o}`:""}`,children:[f,C]})},Ke=new Map;function Qe(e){if(!e)return"en";try{return Intl.DateTimeFormat.supportedLocalesOf(e).length>0?e:"en"}catch{return"en"}}function we(e,n){const c=Qe(e),d=`${c}|${JSON.stringify(n)}`;let a=Ke.get(d);return a||(a=new Intl.DateTimeFormat(c,n),Ke.set(d,a)),a}const Ze=(e,n)=>e.charAt(0).toLocaleUpperCase(Qe(n))+e.slice(1);function Z(e,n="short"){const c=we(e,{weekday:n});return Array.from({length:7},(d,a)=>Ze(c.format(new Date(2023,0,1+a)),e))}function Ee(e,n="long"){const c=we(e,{month:n});return Array.from({length:12},(d,a)=>Ze(c.format(new Date(2023,a,1)),e))}function se(e,n){return we(e,{year:"numeric",month:"2-digit",day:"2-digit"}).format(n)}function De(e,n){return we(e,{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}).format(n)}const L=(e,n)=>{const c=new Date(e);return c.setDate(c.getDate()+n),c},B=(e,n)=>e.getFullYear()===n.getFullYear()&&e.getMonth()===n.getMonth()&&e.getDate()===n.getDate();function Oe(e,n,c,d=1/0){const a=[],o=Math.max(1,Math.floor(e.interval??1)),x=e.until?new Date(e.until):void 0,_=x&&x<c?x:c,b=Math.min(e.count&&e.count>0?e.count:1/0,d),E=e.freq==="weekly"&&e.byDay?.length?[...new Set(e.byDay.filter(f=>Number.isInteger(f)&&f>=0&&f<=6))].sort((f,C)=>f-C):[];if(E.length>0){const f=new Date(n);f.setDate(n.getDate()-n.getDay());for(let C=0;a.length<b;C+=o){const s=new Date(f);if(s.setDate(f.getDate()+C*7),s>_)break;for(const N of E){const j=new Date(s);if(j.setDate(s.getDate()+N),!(j<n)){if(j>_||a.length>=b)break;a.push(j)}}}return a}let w=new Date(n);for(;w<=_&&a.length<b;){a.push(new Date(w));const f=new Date(w);e.freq==="daily"?f.setDate(f.getDate()+o):e.freq==="weekly"?f.setDate(f.getDate()+7*o):e.freq==="monthly"?f.setMonth(f.getMonth()+o):f.setFullYear(f.getFullYear()+o),w=f}return a}function Nt(e,n,c){const d=[];for(const a of e){if(!a.recurrence){d.push(a);continue}const o=new Date(a.end).getTime()-new Date(a.start).getTime();Oe(a.recurrence,new Date(a.start),c).forEach((x,_)=>{const b=new Date(x.getTime()+o);b>=n&&d.push({...a,id:`${a.id}_${_}`,start:x,end:b})})}return d}function et(e,n){return e.filter(c=>{const d=new Date(c.start),a=new Date(c.end);return n>=new Date(d.getFullYear(),d.getMonth(),d.getDate())&&n<=new Date(a.getFullYear(),a.getMonth(),a.getDate())})}function tt(e="r"){return`${e}_${Math.random().toString(36).slice(2,9)}`}function nt(e={}){return{id:e.id??tt(),title:e.title??"",description:e.description??"",servings:e.servings??2,prepMinutes:e.prepMinutes,cookMinutes:e.cookMinutes,difficulty:e.difficulty,cuisine:e.cuisine,tags:e.tags??[],ingredients:e.ingredients??[],steps:e.steps??[],photos:e.photos??[],nutrition:e.nutrition,sourceUrl:e.sourceUrl,createdAt:e.createdAt??new Date,updatedAt:e.updatedAt??new Date}}function st(e){const n=(e.prepMinutes??0)+(e.cookMinutes??0);return n>0?n:void 0}const pe=({ev:e,renderEvent:n,onClick:c,draggable:d,dragRef:a,onHover:o,categoryColor:x})=>{const _=x||e.color||"var(--nice-color-primary, #3b82f6)",E={solid:{backgroundColor:_,color:"var(--nice-color-white, #fff)"},striped:{background:`repeating-linear-gradient(45deg, ${_}, ${_} 4px, transparent 4px, transparent 8px)`,border:`1px solid ${_}`,color:"var(--nice-text-primary, #333)"},outlined:{backgroundColor:"transparent",border:`2px solid ${_}`,color:_},dashed:{backgroundColor:"transparent",border:`2px dashed ${_}`,color:_}}[e.eventStyle||"solid"];return t.jsx("div",{className:`nice-scheduler__event nice-scheduler__event--${e.eventStyle||"solid"}`,style:E,role:"button",tabIndex:0,"aria-label":e.title,draggable:d,onDragStart:()=>{a.current={event:e}},onDragEnd:()=>{a.current=null},onClick:w=>{w.stopPropagation(),c?.(e)},onKeyDown:w=>{(w.key==="Enter"||w.key===" ")&&(w.preventDefault(),w.stopPropagation(),c?.(e))},onMouseEnter:w=>o(e,w.currentTarget.getBoundingClientRect()),onMouseLeave:()=>o(null),onFocus:w=>o(e,w.currentTarget.getBoundingClientRect()),onBlur:()=>o(null),children:n?n(e):e.title})};function ie(e,n){if(!(!e.category||!n))return n.find(c=>c.key===e.category)?.color}const Dt=({events:e,curDate:n,firstDayOfWeek:c,onSlotClick:d,onEventClick:a,draggable:o,dragRef:x,categories:_,renderEvent:b,onHoverEvent:E,readOnly:w})=>{const{lang:f}=H.useNiceTranslation(),C=Z(f,"short"),s=n.getFullYear(),N=n.getMonth(),j=new Date(s,N,1),l=new Date(s,N+1,0),k=(j.getDay()-c+7)%7,h=l.getDate(),m=[];for(let u=k-1;u>=0;u--)m.push({date:L(j,-u-1),isCurrentMonth:!1});for(let u=0;u<h;u++)m.push({date:new Date(s,N,u+1),isCurrentMonth:!0});let P=1;for(;m.length<42;)m.push({date:new Date(s,N+1,P++),isCurrentMonth:!1});return t.jsxs("div",{className:"nice-scheduler__month",children:[t.jsx("div",{className:"nice-scheduler__month-header",children:Array.from({length:7},(u,g)=>t.jsx("div",{className:"nice-scheduler__month-dayname",children:C[(c+g)%7]},g))}),t.jsx("div",{className:"nice-scheduler__month-grid",children:m.map((u,g)=>{const R=et(e,u.date),p=B(u.date,new Date),S=u.date.getDay(),F=S===0||S===6;return t.jsxs("div",{className:`nice-scheduler__month-cell ${u.isCurrentMonth?"":"nice-scheduler__month-cell--other"} ${p?"nice-scheduler__month-cell--today":""} ${F?"nice-scheduler__month-cell--weekend":""}`,onClick:()=>!w&&d?.(u.date,L(u.date,1)),children:[t.jsx("div",{className:"nice-scheduler__month-date",children:u.date.getDate()}),R.slice(0,3).map(q=>t.jsx(pe,{ev:q,renderEvent:b,onClick:a,draggable:o&&!w,dragRef:x,onHover:E,categoryColor:ie(q,_)},q.id)),R.length>3&&t.jsxs("div",{className:"nice-scheduler__month-more",children:["+",R.length-3]})]},g)})})]})},wt=({events:e,days:n,startHour:c,endHour:d,draggable:a,dragRef:o,onEventClick:x,onSlotClick:_,onEventDrop:b,categories:E,workHours:w,showCurrentTime:f,renderEvent:C,onHoverEvent:s,readOnly:N})=>{const{lang:j}=H.useNiceTranslation(),l=[];for(let p=c;p<d;p++)l.push(p);Z(j,"short");const k=Z(j,"long"),h=D.useRef(null),m=new Date,P=m.getHours()*60+m.getMinutes(),u=(d-c)*60,g=(P-c*60)/u*100,R=f&&P>=c*60&&P<d*60;return D.useEffect(()=>{const p=h.current;if(!p)return;const S=new Date,F=e.filter($=>n.some(Y=>B(Y,new Date($.start)))),q=F.filter($=>B(new Date($.start),S));let W;q.length>0?W=Math.min(...q.map($=>new Date($.start).getHours())):F.length>0?W=Math.min(...F.map($=>new Date($.start).getHours())):W=8,W=Math.max(c,Math.min(W,d-1));const i=W-c,y=p.children[i];if(y){const $=p.closest(".nice-scheduler__content")??p.closest(".nice-scheduler__timegrid");$&&($.scrollTop=y.offsetTop-4)}},[]),t.jsxs("div",{className:"nice-scheduler__timegrid",children:[t.jsxs("div",{className:"nice-scheduler__timegrid-header",children:[t.jsx("div",{className:"nice-scheduler__time-gutter"}),n.map((p,S)=>{const F=p.getDay()===0||p.getDay()===6;return t.jsxs("div",{className:`nice-scheduler__timegrid-day-header ${B(p,m)?"nice-scheduler__timegrid-day-header--today":""} ${F?"nice-scheduler__timegrid-day-header--weekend":""}`,children:[t.jsx("div",{className:"nice-scheduler__timegrid-day-name",children:k[p.getDay()]}),t.jsx("div",{className:"nice-scheduler__timegrid-day-num",children:p.getDate()})]},S)})]}),t.jsxs("div",{className:"nice-scheduler__timegrid-body",ref:h,style:{position:"relative"},children:[l.map(p=>{const S=w?p>=w[0]&&p<w[1]:!1;return t.jsxs("div",{className:`nice-scheduler__timegrid-row ${S?"nice-scheduler__timegrid-row--work":""}`,children:[t.jsx("div",{className:"nice-scheduler__time-gutter",children:`${p.toString().padStart(2,"0")}:00`}),n.map((F,q)=>{const W=e.filter(i=>{const y=new Date(i.start);return B(y,F)&&y.getHours()===p});return t.jsx("div",{className:"nice-scheduler__timegrid-cell",onDragOver:a&&!N?i=>i.preventDefault():void 0,onDrop:a&&!N?()=>{if(!o.current||!b)return;const i=o.current.event,y=new Date(i.end).getTime()-new Date(i.start).getTime(),$=new Date(F);$.setHours(p,0,0,0);const Y=new Date($.getTime()+y);b(i,$,Y),o.current=null}:void 0,onClick:()=>!N&&(()=>{const i=new Date(F);i.setHours(p);const y=new Date(i);y.setHours(p+1),_?.(i,y)})(),children:W.map(i=>t.jsx(pe,{ev:i,renderEvent:C,onClick:x,draggable:a&&!N,dragRef:o,onHover:s,categoryColor:ie(i,E)},i.id))},q)})]},p)}),R&&n.some(p=>B(p,m))&&t.jsx("div",{className:"nice-scheduler__now-line",style:{top:`${g}%`},children:t.jsx("div",{className:"nice-scheduler__now-dot"})})]})]})},bt=({events:e,curDate:n,onEventClick:c,categories:d,t:a})=>{const o=[...e].filter(x=>new Date(x.start)>=new Date(n.getFullYear(),n.getMonth(),n.getDate())).sort((x,_)=>new Date(x.start).getTime()-new Date(_.start).getTime()).slice(0,50);return t.jsxs("div",{className:"nice-scheduler__agenda",children:[o.map(x=>t.jsx(jt,{ev:x,categories:d,onEventClick:c},x.id)),o.length===0&&t.jsx("div",{className:"nice-scheduler__agenda-empty",children:a("noEvents","No upcoming events")})]})},Je=({parts:e})=>t.jsx("div",{className:"nice-scheduler__agenda-meta",children:e.map(([n,c],d)=>t.jsxs(D.Fragment,{children:[d>0&&" · ",t.jsx(H.NiceIcon,{name:n,size:12,style:{verticalAlign:"-2px"}})," ",c]},n))}),rt=({ev:e})=>{if(e.eventType==="recipe"&&e.recipe){const n=st(e.recipe),c=[];return n!==void 0&&c.push(["clock",`${n} min`]),e.recipe.ingredients?.length&&c.push(["list",`${e.recipe.ingredients.length} ingredients`]),e.recipe.servings&&c.push(["utensils",`${e.recipe.servings} servings`]),c.length===0?null:t.jsx(Je,{parts:c})}if(e.eventType==="service"&&e.service){const n=e.service,c=[];return n.serviceName&&c.push(["bell",n.serviceName]),n.providerName&&c.push(["user",n.providerName]),n.customerName&&c.push(["arrow-right",n.customerName]),typeof n.price=="number"&&c.push(["dollar",`${n.price}${n.currency?" "+n.currency:""}`]),c.length===0?null:t.jsx(Je,{parts:c})}return null},jt=({ev:e,categories:n,onEventClick:c})=>{const{t:d}=H.useNiceTranslation(),a=H.useAccessibleClick({onClick:()=>c?.(e)});return t.jsxs("div",{className:"nice-scheduler__agenda-item","aria-label":d("service.event","Event {title}").replace("{title}",String(e.title)),...a,children:[t.jsx("div",{className:"nice-scheduler__agenda-dot",style:{backgroundColor:ie(e,n)||e.color||"var(--nice-color-primary, #3b82f6)"}}),t.jsxs("div",{className:"nice-scheduler__agenda-info",children:[t.jsx("div",{className:"nice-scheduler__agenda-title",children:e.title}),t.jsxs("div",{className:"nice-scheduler__agenda-time",children:[De(Q.getDefaultLocale(),new Date(e.start))," –"," ",De(Q.getDefaultLocale(),new Date(e.end))]}),e.description&&t.jsx("div",{className:"nice-scheduler__agenda-desc",children:e.description}),t.jsx(rt,{ev:e})]}),e.category&&n&&t.jsx("span",{className:"nice-scheduler__agenda-badge",style:{backgroundColor:ie(e,n)||e.color},children:n.find(o=>o.key===e.category)?.label})]})},kt=({events:e,curDate:n,timelineDays:c,resources:d,draggable:a,dragRef:o,onEventClick:x,onSlotClick:_,onEventDrop:b,categories:E,renderEvent:w,onHoverEvent:f,readOnly:C})=>{const{lang:s}=H.useNiceTranslation(),N=Array.from({length:c},(k,h)=>L(n,h)),j=d??[{id:"__default",name:""}],l=Z(s,"short");return t.jsxs("div",{className:"nice-scheduler__timeline",children:[t.jsxs("div",{className:"nice-scheduler__timeline-header",children:[t.jsx("div",{className:"nice-scheduler__timeline-res-label"}),N.map((k,h)=>t.jsxs("div",{className:`nice-scheduler__timeline-day ${B(k,new Date)?"nice-scheduler__timeline-day--today":""}`,children:[l[k.getDay()]," ",k.getDate()]},h))]}),t.jsx("div",{className:"nice-scheduler__timeline-body",children:j.map(k=>{const h=e.filter(m=>!d||m.resourceId===k.id);return t.jsxs("div",{className:"nice-scheduler__timeline-row",children:[t.jsx("div",{className:"nice-scheduler__timeline-res-label",children:k.name}),N.map((m,P)=>{const u=h.filter(g=>B(new Date(g.start),m));return t.jsx("div",{className:"nice-scheduler__timeline-cell",onDragOver:a&&!C?g=>g.preventDefault():void 0,onDrop:a&&!C?()=>{if(!o.current||!b)return;const g=o.current.event,R=new Date(g.end).getTime()-new Date(g.start).getTime(),p=new Date(m);p.setHours(new Date(g.start).getHours(),new Date(g.start).getMinutes()),b(g,p,new Date(p.getTime()+R),k.id),o.current=null}:void 0,onClick:()=>!C&&_?.(m,L(m,1),k.id),children:u.map(g=>t.jsx(pe,{ev:g,renderEvent:w,onClick:x,draggable:a&&!C,dragRef:o,onHover:f,categoryColor:ie(g,E)},g.id))},P)})]},k.id)})})]})},Xe=({categories:e,events:n,filteredCategories:c,onToggleCategory:d,t:a})=>t.jsxs("div",{className:"nice-scheduler__legend",children:[t.jsx("div",{className:"nice-scheduler__legend-title",children:a("legend","Legend")}),e.map(o=>{const x=n.filter(b=>b.category===o.key).length,_=!c.has(o.key);return t.jsxs("button",{className:`nice-scheduler__legend-item ${_?"":"nice-scheduler__legend-item--hidden"}`,onClick:()=>d(o.key),children:[t.jsx("span",{className:"nice-scheduler__legend-dot",style:{backgroundColor:_?o.color:"var(--nice-border-color, #ccc)"}}),t.jsx("span",{className:"nice-scheduler__legend-label",children:o.label}),t.jsx("span",{className:"nice-scheduler__legend-count",children:x})]},o.key)})]}),Ct=({curDate:e,onDateSelect:n,firstDayOfWeek:c,t:d})=>{const{lang:a}=H.useNiceTranslation(),[o,x]=D.useState(e.getMonth()),[_,b]=D.useState(e.getFullYear()),E=new Date(_,o,1),w=new Date(_,o+1,0),f=(E.getDay()-c+7)%7,C=[];for(let h=f-1;h>=0;h--)C.push(L(E,-h-1));for(let h=0;h<w.getDate();h++)C.push(new Date(_,o,h+1));const s=7-C.length%7;if(s<7)for(let h=1;h<=s;h++)C.push(new Date(_,o+1,h));const N=()=>{o===0?(x(11),b(h=>h-1)):x(h=>h-1)},j=()=>{o===11?(x(0),b(h=>h+1)):x(h=>h+1)},l=Ee(a,"short"),k=Z(a,"short");return t.jsxs("div",{className:"nice-scheduler__mini-cal",children:[t.jsxs("div",{className:"nice-scheduler__mini-cal-header",children:[t.jsx("button",{type:"button",className:"nice-btn nice-btn--xs",onClick:N,"aria-label":d("scheduler.prevMonth","Previous month"),children:t.jsx(H.NiceIcon,{name:"chevron-left",size:"sm"})}),t.jsxs("span",{children:[l[o]," ",_]}),t.jsx("button",{type:"button",className:"nice-btn nice-btn--xs",onClick:j,"aria-label":d("scheduler.nextMonth","Next month"),children:t.jsx(H.NiceIcon,{name:"chevron-right",size:"sm"})})]}),t.jsxs("div",{className:"nice-scheduler__mini-cal-grid",children:[k.map((h,m)=>t.jsx("div",{className:"nice-scheduler__mini-cal-dayname",children:k[(c+m)%7].charAt(0)},m)),C.map((h,m)=>{const P=B(h,new Date),u=B(h,e),g=h.getMonth()!==o;return t.jsx("button",{className:`nice-scheduler__mini-cal-day ${P?"nice-scheduler__mini-cal-day--today":""} ${u?"nice-scheduler__mini-cal-day--selected":""} ${g?"nice-scheduler__mini-cal-day--other":""}`,onClick:()=>n(h),children:h.getDate()},m)})]})]})},St=({events:e,rangeStart:n,rangeEnd:c,startHour:d,endHour:a,draggable:o,dragRef:x,onEventClick:_,onSlotClick:b,onEventDrop:E,categories:w,workHours:f,showCurrentTime:C,renderEvent:s,onHoverEvent:N,readOnly:j})=>{const{lang:l}=H.useNiceTranslation(),k=[];let h=new Date(n);for(;h<=c;)k.push(new Date(h)),h=L(h,1);const m=[];for(let y=d;y<a;y++)m.push(y);const P=Z(l,"long"),u=D.useRef(null),g=D.useRef(null),R=D.useRef(null),p=new Date,S=p.getHours()*60+p.getMinutes(),F=(a-d)*60,q=(S-d*60)/F*100,W=C&&S>=d*60&&S<a*60;D.useEffect(()=>{const y=u.current;if(!y)return;const $=new Date,Y=e.filter(I=>k.some(M=>B(M,$)&&B(new Date(I.start),$)));let V=Y.length>0?Math.min(...Y.map(I=>new Date(I.start).getHours())):$.getHours();V=Math.max(d,Math.min(V,a-1));const K=y.children[V-d];if(K){const I=R.current??y.closest(".nice-scheduler__content")??y.closest(".nice-scheduler__timegrid");I&&(I.scrollTop=K.offsetTop-4)}},[]);const i=y=>{g.current&&(g.current.scrollLeft=y.currentTarget.scrollLeft)};return t.jsxs("div",{className:"nice-scheduler__timegrid nice-scheduler__timegrid--range",children:[t.jsx("div",{className:"nice-scheduler__timegrid-header-scroll",ref:g,"aria-hidden":"true",children:t.jsxs("div",{className:"nice-scheduler__timegrid-header",children:[t.jsx("div",{className:"nice-scheduler__time-gutter"}),k.map((y,$)=>{const Y=y.getDay()===0||y.getDay()===6;return t.jsxs("div",{className:`nice-scheduler__timegrid-day-header ${B(y,p)?"nice-scheduler__timegrid-day-header--today":""} ${Y?"nice-scheduler__timegrid-day-header--weekend":""}`,children:[t.jsx("div",{className:"nice-scheduler__timegrid-day-name",children:P[y.getDay()]}),t.jsx("div",{className:"nice-scheduler__timegrid-day-num",children:y.getDate()})]},$)})]})}),t.jsx("div",{className:"nice-scheduler__timegrid-body-scroll",ref:R,onScroll:i,children:t.jsxs("div",{className:"nice-scheduler__timegrid-body",ref:u,style:{position:"relative"},children:[m.map(y=>{const $=f?y>=f[0]&&y<f[1]:!1;return t.jsxs("div",{className:`nice-scheduler__timegrid-row ${$?"nice-scheduler__timegrid-row--work":""}`,children:[t.jsx("div",{className:"nice-scheduler__time-gutter",children:`${y.toString().padStart(2,"0")}:00`}),k.map((Y,V)=>{const K=e.filter(I=>{const M=new Date(I.start);return B(M,Y)&&M.getHours()===y});return t.jsx("div",{className:"nice-scheduler__timegrid-cell",onDragOver:o&&!j?I=>I.preventDefault():void 0,onDrop:o&&!j?()=>{if(!x.current||!E)return;const I=x.current.event,M=new Date(I.end).getTime()-new Date(I.start).getTime(),O=new Date(Y);O.setHours(y,0,0,0),E(I,O,new Date(O.getTime()+M)),x.current=null}:void 0,onClick:()=>!j&&(()=>{const I=new Date(Y);I.setHours(y);const M=new Date(I);M.setHours(y+1),b?.(I,M)})(),children:K.map(I=>t.jsx(pe,{ev:I,renderEvent:s,onClick:_,draggable:o&&!j,dragRef:x,onHover:N,categoryColor:ie(I,w)},I.id))},V)})]},y)}),W&&k.some(y=>B(y,p))&&t.jsx("div",{className:"nice-scheduler__now-line",style:{top:`${q}%`},children:t.jsx("div",{className:"nice-scheduler__now-dot"})})]})})]})},Mt=({events:e,rangeStart:n,rangeEnd:c,firstDayOfWeek:d,onSlotClick:a,onEventClick:o,draggable:x,dragRef:_,categories:b,renderEvent:E,onHoverEvent:w,readOnly:f})=>{const{lang:C}=H.useNiceTranslation(),s=Z(C,"short");Z(C,"long");const N=[];let j=new Date(n);for(;j<=c;)N.push(new Date(j)),j=L(j,1);const l=(N[0].getDay()-d+7)%7,k=[];for(let m=l-1;m>=0;m--)k.push({date:L(N[0],-m-1),inRange:!1});N.forEach(m=>k.push({date:m,inRange:!0}));const h=7-k.length%7;if(h<7){const m=N[N.length-1];for(let P=1;P<=h;P++)k.push({date:L(m,P),inRange:!1})}return t.jsxs("div",{className:"nice-scheduler__month nice-scheduler__month--range",children:[t.jsx("div",{className:"nice-scheduler__month-header",children:Array.from({length:7},(m,P)=>t.jsx("div",{className:"nice-scheduler__month-dayname",children:s[(d+P)%7]},P))}),t.jsx("div",{className:"nice-scheduler__month-grid",children:k.map((m,P)=>{const u=et(e,m.date),g=B(m.date,new Date),R=m.date.getDay()===0||m.date.getDay()===6;return t.jsxs("div",{className:`nice-scheduler__month-cell ${m.inRange?"":"nice-scheduler__month-cell--other"} ${g?"nice-scheduler__month-cell--today":""} ${R?"nice-scheduler__month-cell--weekend":""}`,onClick:()=>!f&&a?.(m.date,L(m.date,1)),children:[t.jsx("div",{className:"nice-scheduler__month-date",children:m.date.getDate()===1||P===0?t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"nice-scheduler__month-monthname",children:Ee(C,"short")[m.date.getMonth()]})," ",m.date.getDate()]}):m.date.getDate()}),u.slice(0,3).map(p=>t.jsx(pe,{ev:p,renderEvent:E,onClick:o,draggable:x&&!f,dragRef:_,onHover:w,categoryColor:ie(p,b)},p.id)),u.length>3&&t.jsxs("div",{className:"nice-scheduler__month-more",children:["+",u.length-3]})]},P)})})]})},Tt=({event:e,rect:n,categories:c,renderTooltip:d})=>{if(d)return t.jsx("div",{className:"nice-scheduler__tooltip",style:{position:"fixed",left:n.right+8,top:n.top,zIndex:1e4},children:d(e)});const a=c?.find(o=>o.key===e.category);return t.jsxs("div",{className:"nice-scheduler__tooltip",style:{position:"fixed",left:n.right+8,top:n.top,zIndex:1e4},children:[t.jsx("div",{className:"nice-scheduler__tooltip-title",children:e.title}),t.jsxs("div",{className:"nice-scheduler__tooltip-time",children:[De(Q.getDefaultLocale(),new Date(e.start))," –"," ",De(Q.getDefaultLocale(),new Date(e.end))]}),a&&t.jsxs("div",{className:"nice-scheduler__tooltip-cat",children:[t.jsx("span",{className:"nice-scheduler__tooltip-dot",style:{backgroundColor:a.color}}),a.label]}),e.description&&t.jsx("div",{className:"nice-scheduler__tooltip-desc",children:e.description}),t.jsx(rt,{ev:e})]})},$t=({event:e,slotStart:n,slotEnd:c,categories:d,resources:a,formFields:o,formFieldsByType:x,eventTypes:_,renderEditor:b,saving:E,onSave:w,onDelete:f,onClose:C,t:s})=>{const N=!!e,j=D.useMemo(()=>({title:e?.title??"",description:e?.description??"",color:e?.color??"var(--nice-primary, #3b82f6)",category:e?.category??"",eventStyle:e?.eventStyle??"solid",start:e?.start??n??new Date,end:e?.end??c??new Date,allDay:e?.allDay??!1,resourceId:e?.resourceId??"",eventType:e?.eventType??"task",recurring:!!e?.recurrence,recurrenceFreq:e?.recurrence?.freq??"weekly",recurrenceInterval:e?.recurrence?.interval??1,recurrenceCount:e?.recurrence?.count,recipeTitle:e?.recipe?.title??"",recipeServings:e?.recipe?.servings??2,recipePrep:e?.recipe?.prepMinutes,recipeCook:e?.recipe?.cookMinutes,recipeIngredients:(e?.recipe?.ingredients??[]).map(u=>[u.quantity,u.unit,u.name].filter(g=>g!==void 0&&g!=="").join(" ")).join(`
2
+ `),recipeSteps:(e?.recipe?.steps??[]).map(u=>u.instruction).join(`
3
+ `),serviceName:e?.service?.serviceName??"",serviceProvider:e?.service?.providerName??"",serviceCustomer:e?.service?.customerName??"",serviceContact:e?.service?.customerContact??"",serviceLocation:e?.service?.location??"",servicePrice:e?.service?.price,serviceCurrency:e?.service?.currency??"PLN",serviceNotes:e?.service?.notes??""}),[e,n,c]),[l,k]=D.useState(j);D.useEffect(()=>{k(j)},[j]);const h=D.useCallback((u,g)=>{k(R=>({...R,[u]:g}))},[]),m=D.useMemo(()=>{if(o&&o.length>0)return o;const u=i=>i.toString().padStart(2,"0"),g=i=>`${i.getFullYear()}-${u(i.getMonth()+1)}-${u(i.getDate())}`,R=i=>`${u(i.getHours())}:${u(i.getMinutes())}`,p=(i,y)=>{const $=i instanceof Date?i:new Date(i),Y=isNaN($.getTime())?new Date:$,V=g(Y),K=R(Y),I=(M,O)=>{const[fe,X,U]=M.split("-").map(de=>parseInt(de,10)),[ye,ve]=O.split(":").map(de=>parseInt(de,10)),le=new Date(Y);!isNaN(fe)&&!isNaN(X)&&!isNaN(U)&&le.setFullYear(fe,X-1,U),!isNaN(ye)&&!isNaN(ve)&&le.setHours(ye,ve,0,0),y(le)};return t.jsxs("div",{style:{display:"flex",gap:12,flexWrap:"wrap",alignItems:"flex-end"},children:[t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:2},children:[t.jsx("span",{style:{fontSize:"0.7rem",color:"var(--nice-text-muted, #888)"},children:s("date","Date")}),t.jsx(Q.NiceDateTimePicker,{dateFormatPreset:"date-local",value:V,onChange:M=>I(M,K),size:"sm"})]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:2},children:[t.jsx("span",{style:{fontSize:"0.7rem",color:"var(--nice-text-muted, #888)"},children:s("time","Time")}),t.jsx(Q.NiceDateTimePicker,{dateFormatPreset:"time",value:K,onChange:M=>I(V,M),size:"sm"})]})]})},S=[];_&&_.length>1&&S.push({field:"eventType",label:s("eventType","Type"),type:"select",group:s("common","Common"),options:_.map(i=>({label:i.icon?`${i.icon} ${i.label}`:i.label,value:i.type}))}),S.push({field:"title",label:s("title","Title"),type:"text",required:!0,group:s("common","Common")},{field:"start",label:s("start","Start"),render:p,group:s("common","Common")},{field:"end",label:s("end","End"),render:p,group:s("common","Common")},{field:"description",label:s("description","Description"),type:"textarea",group:s("common","Common")},{field:"color",label:s("color","Color"),group:s("common","Common"),render:(i,y)=>t.jsx(_t.NiceColorPicker,{value:typeof i=="string"?i:"var(--nice-primary, #3b82f6)",onChange:y,showInput:!1,showRandom:!1})}),d&&d.length>0&&S.push({field:"category",label:s("category","Category"),type:"select",group:s("common","Common"),options:[{label:s("none","(none)"),value:""},...d.map(i=>({label:i.label,value:i.key}))]}),a&&a.length>0&&S.push({field:"resourceId",label:s("resource","Resource"),type:"select",group:s("common","Common"),options:[{label:s("none","(none)"),value:""},...a.map(i=>({label:i.name,value:String(i.id)}))]});const F=s("recurring","Recurring");S.push({field:"recurring",label:s("repeat","Repeat"),type:"checkbox",group:F}),S.push({field:"recurrenceFreq",label:s("frequency","Frequency"),type:"select",group:F,visibleWhen:i=>!!i.recurring,options:[{label:s("daily","Daily"),value:"daily"},{label:s("weekly","Weekly"),value:"weekly"},{label:s("monthly","Monthly"),value:"monthly"},{label:s("yearly","Yearly"),value:"yearly"}]}),S.push({field:"recurrenceInterval",label:s("interval","Interval"),type:"number",group:F,visibleWhen:i=>!!i.recurring}),S.push({field:"recurrenceCount",label:s("occurrences","Occurrences (optional)"),type:"number",group:F,visibleWhen:i=>!!i.recurring});const q=l.eventType??"task",W=x?.[q];if(W&&W.length>0)S.push(...W);else if(q==="recipe"){const i=s("recipe.section","Recipe");S.push({field:"recipeTitle",label:s("recipe.title","Recipe title"),type:"text",group:i},{field:"recipeServings",label:s("recipe.servings","Servings"),type:"number",group:i},{field:"recipePrep",label:s("recipe.prepMinutes","Prep (min)"),type:"number",group:i},{field:"recipeCook",label:s("recipe.cookMinutes","Cook (min)"),type:"number",group:i},{field:"recipeIngredients",label:s("recipe.ingredients","Ingredients (one per line)"),type:"textarea",group:i,hint:s("recipe.ingredients.hint",'Format: "200 g flour"')},{field:"recipeSteps",label:s("recipe.steps","Steps (one per line)"),type:"textarea",group:i})}else if(q==="service"){const i=s("service.section","Service");S.push({field:"serviceName",label:s("service.name","Service name"),type:"text",group:i,required:!0},{field:"serviceProvider",label:s("service.provider","Provider"),type:"text",group:i},{field:"serviceCustomer",label:s("service.customer","Customer"),type:"text",group:i},{field:"serviceContact",label:s("service.contact","Contact"),type:"text",group:i},{field:"serviceLocation",label:s("service.location","Location"),type:"text",group:i},{field:"servicePrice",label:s("service.price","Price"),type:"number",group:i},{field:"serviceCurrency",label:s("service.currency","Currency"),type:"text",group:i},{field:"serviceNotes",label:s("service.notes","Notes"),type:"textarea",group:i})}return S},[o,x,_,d,a,l.eventType,s]),P=()=>{const u=l.eventType??"task",g={title:l.title,description:l.description||void 0,color:l.color,category:l.category||void 0,eventStyle:l.eventStyle,allDay:l.allDay,start:l.start instanceof Date?l.start:new Date(l.start),end:l.end instanceof Date?l.end:new Date(l.end),resourceId:l.resourceId||void 0,eventType:u};if(l.recurring){const R={freq:l.recurrenceFreq||"weekly",interval:typeof l.recurrenceInterval=="number"&&l.recurrenceInterval>0?l.recurrenceInterval:1};typeof l.recurrenceCount=="number"&&l.recurrenceCount>0&&(R.count=l.recurrenceCount),g.recurrence=R}else g.recurrence=void 0;if(u==="recipe"){const R=String(l.recipeIngredients||"").split(`
4
+ `).map(q=>q.trim()).filter(Boolean).map((q,W)=>{const i=q.match(/^([\d.,/]+)\s*(\S+)?\s+(.+)$/);if(i){const y=parseFloat(i[1].replace(",","."));return{id:`ing-${W}`,name:i[3],quantity:isNaN(y)?void 0:y,unit:i[2]}}return{id:`ing-${W}`,name:q}}),p=String(l.recipeSteps||"").split(`
5
+ `).map(q=>q.trim()).filter(Boolean).map((q,W)=>({id:`step-${W}`,order:W+1,instruction:q})),S=e?.recipe??nt(),F={...S,title:l.recipeTitle||l.title||S.title,servings:typeof l.recipeServings=="number"?l.recipeServings:S.servings,prepMinutes:typeof l.recipePrep=="number"?l.recipePrep:S.prepMinutes,cookMinutes:typeof l.recipeCook=="number"?l.recipeCook:S.cookMinutes,ingredients:R,steps:p};g.recipe=F,g.service=void 0}else if(u==="service"){const R={serviceName:String(l.serviceName||""),providerName:l.serviceProvider||void 0,customerName:l.serviceCustomer||void 0,customerContact:l.serviceContact||void 0,location:l.serviceLocation||void 0,price:typeof l.servicePrice=="number"?l.servicePrice:void 0,currency:l.serviceCurrency||void 0,notes:l.serviceNotes||void 0};g.service=R,g.recipe=void 0}else g.recipe=void 0,g.service=void 0;return N&&(g.id=e.id),g};return t.jsx(xt.NiceModal,{open:!0,onClose:C,title:N?s("editEvent","Edit Event"):s("newEvent","New Event"),size:"md",footer:b?null:t.jsxs(t.Fragment,{children:[N&&f&&t.jsx(re.NiceButton,{type:"button",variant:"error",size:"sm",onClick:()=>{f(e),C()},disabled:E,children:s("delete","Delete")}),t.jsx("div",{style:{flex:1}}),t.jsx(re.NiceButton,{type:"button",variant:"secondary",size:"sm",onClick:C,disabled:E,children:s("cancel","Cancel")}),t.jsx(re.NiceButton,{type:"button",variant:"primary",size:"sm",onClick:()=>{l.title&&w(P())},disabled:E||!l.title,children:E?s("saving","Saving…"):s("save","Save")})]}),children:t.jsx("div",{className:"nice-scheduler__form-body",onKeyDown:u=>{u.key==="Enter"&&u.target.tagName!=="TEXTAREA"&&(u.preventDefault(),l.title&&w(P()))},children:b?b({event:e,slotStart:n,slotEnd:c,save:w,cancel:C,remove:f}):t.jsx(Q.NiceForm,{items:m,data:l,onFieldChange:h,columns:1,gap:12,size:"sm"})})})},Et=["day","workWeek","week","dayRange","month","monthRange","timeline","agenda"],Re=({events:e,defaultEvents:n,resources:c,currentDate:d,view:a,onDateChange:o,onViewChange:x,onEventClick:_,onSlotClick:b,onEventDrop:E,draggable:w=!1,timelineDays:f=7,startHour:C=0,endHour:s=24,firstDayOfWeek:N=1,categories:j,showLegend:l,showTooltip:k,renderEvent:h,renderTooltip:m,workHours:P,showCurrentTime:u=!0,showMiniCalendar:g,onEventCreate:R,onEventEdit:p,onEventDelete:S,editable:F=!0,formFields:q,formFieldsByType:W,eventTypes:i,renderEventEditor:y,loadEvents:$,onEventsChange:Y,accessMode:V="full",className:K,style:I})=>{const{t:M,lang:O}=H.useNiceTranslation(),fe=V==="hidden",X=V==="readOnly"||V==="disabled",U=V==="disabled",[ye,ve]=D.useState(d??new Date),[le,de]=D.useState(a??"week"),Ie=d!==void 0&&o!==void 0,Pe=a!==void 0&&x!==void 0,A=Ie?d:ye,T=Pe?a:le;Te.useIgnoredPropChangeWarning("NiceScheduler","currentDate","onDateChange",d,Ie),Te.useIgnoredPropChangeWarning("NiceScheduler","view","onViewChange",a,Pe);const it=D.useRef(null),[G,be]=D.useState(()=>{const r=new Date;return r.setHours(0,0,0,0),r}),[J,je]=D.useState(()=>L(new Date,13)),[ke,Fe]=D.useState(null),ct=D.useCallback((r,v)=>{k&&Fe(r&&v?{event:r,rect:v}:null)},[k]),[ce,ue]=D.useState(null),[at,_e]=D.useState(!1),Ce=e!==void 0&&Y!==void 0,[ot,Le]=H.useControllableState({value:Ce?e:void 0,defaultValue:n,fallbackValue:[],onChange:Y,componentName:"NiceScheduler"}),[qe,lt]=D.useState(!1),[Ae,dt]=D.useState(null),[It,We]=D.useState(!1),ee=Ae??(Ce||qe||e===void 0?ot:e);Te.useIgnoredPropChangeWarning("NiceScheduler","events","onEventsChange",e,Ce||!(qe||Ae!==null),"the built-in editor has taken over the list");const[me,ut]=D.useState(new Set),Ye=D.useCallback(r=>{ut(v=>{const z=new Set(v);return z.has(r)?z.delete(r):z.add(r),z})},[]),he=D.useMemo(()=>{if(T==="month")return{start:new Date(A.getFullYear(),A.getMonth(),1),end:new Date(A.getFullYear(),A.getMonth()+2,0)};if(T==="timeline")return{start:new Date(A),end:L(A,f)};if(T==="dayRange"||T==="monthRange")return{start:new Date(G),end:L(J,1)};const r=(()=>{const v=new Date(A),z=(v.getDay()-N+7)%7;return L(v,-z)})();return{start:L(r,-1),end:L(r,8)}},[A,T,N,f,G,J]),Se=D.useMemo(()=>{let r=Nt(ee,he.start,he.end);return me.size>0&&(r=r.filter(v=>!v.category||!me.has(v.category))),r},[ee,he,me]),ae=r=>{ve(r),o?.(r)},mt=r=>{de(r),x?.(r)},ze=r=>{if(T==="day")ae(L(A,r));else if(T==="week"||T==="workWeek")ae(L(A,r*7));else if(T==="timeline")ae(L(A,r*f));else if(T==="dayRange"||T==="monthRange"){const v=Math.round((J.getTime()-G.getTime())/864e5)+1;be(L(G,r*v)),je(L(J,r*v))}else{const v=new Date(A);v.setMonth(v.getMonth()+r),ae(v)}},Me=D.useMemo(()=>{const r=new Date(A),v=(r.getDay()-N+7)%7;return L(r,-v)},[A,N]),xe=D.useMemo(()=>{if(T==="day")return[A];if(T==="workWeek"){const r=[];for(let v=0;v<7;v++){const z=L(Me,v),ne=z.getDay();ne!==0&&ne!==6&&r.push(z)}return r}return Array.from({length:7},(r,v)=>L(Me,v))},[T,A,Me]),te=Q.getDefaultLocale(),ht=T==="day"?se(te,A):T==="week"||T==="workWeek"?`${se(te,xe[0])} – ${se(te,xe[xe.length-1])}`:T==="timeline"?`${se(te,A)} – ${se(te,L(A,f-1))}`:T==="dayRange"||T==="monthRange"?`${se(te,G)} – ${se(te,J)}`:`${Ee(O,"long")[A.getMonth()]} ${A.getFullYear()}`,gt=D.useCallback((r,v,z)=>{X||(F&&ue({mode:"create",slotStart:r,slotEnd:v}),b?.(r,v,z))},[F,b,X]),pt=D.useCallback(r=>{F&&!X&&ue({mode:"edit",event:r}),_?.(r)},[F,_,X]),ge=D.useCallback(r=>{lt(!0),Le(r)},[Le]),ft=D.useCallback(async r=>{const v=ce?.mode==="create";try{if(_e(!0),v){const ne=(R?await R(r):void 0)??{...r,id:typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():`evt_${Date.now()}_${Math.random().toString(36).slice(2,7)}`},Ne=ee.slice();Ne.push(ne),ge(Ne)}else{const ne=(p?await p(r):void 0)??r,Ne=ee.map(Ge=>Ge.id===ne.id?ne:Ge);ge(Ne)}ue(null)}finally{_e(!1)}},[ce,R,p,ee,ge]),yt=D.useCallback(async r=>{try{_e(!0),S&&await S(r);const v=ee.filter(z=>z.id!==r.id);ge(v),ue(null)}finally{_e(!1)}},[S,ee,ge]),Be=he.start.getTime(),Ve=he.end.getTime();D.useEffect(()=>{if(!$)return;let r=!1;return We(!0),$({start:new Date(Be),end:new Date(Ve)}).then(v=>{r||dt(v)}).finally(()=>{r||We(!1)}),()=>{r=!0}},[$,Be,Ve]);const vt=r=>({day:M("day","Day"),week:M("week","Week"),workWeek:M("workWeek","Work Week"),month:M("month","Month"),timeline:M("timeline","Timeline"),agenda:M("agenda","Agenda"),dayRange:M("dayRange","Day Range"),monthRange:M("monthRange","Month Range")})[r],oe={events:Se,curDate:A,firstDayOfWeek:N,startHour:C,endHour:s,draggable:w,dragRef:it,onEventClick:pt,onSlotClick:gt,onEventDrop:E,resources:c,timelineDays:f,categories:j,workHours:P,showCurrentTime:u,renderEvent:h,showTooltip:k,renderTooltip:m,onHoverEvent:ct,readOnly:X,t:M},He=T==="dayRange"||T==="monthRange",Ue=r=>{const v=z=>z.toString().padStart(2,"0");return`${r.getFullYear()}-${v(r.getMonth()+1)}-${v(r.getDate())}`};return fe?null:t.jsxs("div",{className:`nice-scheduler ${U?"nice-scheduler--disabled":""} ${K||""}`,style:I,children:[t.jsxs("div",{className:"nice-scheduler__toolbar",children:[t.jsxs("div",{className:"nice-scheduler__nav",children:[t.jsxs($e,{size:"sm",children:[t.jsx(re.NiceButton,{onClick:()=>ze(-1),disabled:U,"aria-label":M("previous","Previous"),children:"‹"}),t.jsx(re.NiceButton,{onClick:()=>{if(He){const r=new Date;r.setHours(0,0,0,0);const v=Math.round((J.getTime()-G.getTime())/864e5);be(r),je(L(r,v))}else ae(new Date)},disabled:U,children:M("today","Today")}),t.jsx(re.NiceButton,{onClick:()=>ze(1),disabled:U,"aria-label":M("next","Next"),children:"›"})]}),He?t.jsxs("span",{className:"nice-scheduler__range-picker",children:[t.jsx("input",{type:"date",className:"nice-textinput nice-textinput--sm",value:Ue(G),disabled:U,onChange:r=>{const v=new Date(r.target.value+"T00:00:00");isNaN(v.getTime())||be(v)}}),t.jsx("span",{style:{margin:"0 4px"},children:"–"}),t.jsx("input",{type:"date",className:"nice-textinput nice-textinput--sm",value:Ue(J),disabled:U,onChange:r=>{const v=new Date(r.target.value+"T00:00:00");!isNaN(v.getTime())&&v>=G&&je(v)}})]}):t.jsx("span",{className:"nice-scheduler__title",children:ht})]}),t.jsx("div",{className:"nice-scheduler__views",children:t.jsx($e,{size:"sm",children:Et.map(r=>t.jsx(re.NiceButton,{variant:r===T?"primary":"secondary",onClick:()=>mt(r),disabled:U,children:vt(r)},r))})})]}),t.jsxs("div",{className:"nice-scheduler__body",children:[g&&t.jsxs("div",{className:"nice-scheduler__sidebar",children:[t.jsx(Ct,{curDate:A,onDateSelect:r=>ae(r),firstDayOfWeek:N,t:M}),l&&j&&t.jsx(Xe,{categories:j,events:Se,filteredCategories:me,onToggleCategory:Ye,t:M})]}),t.jsxs("div",{className:"nice-scheduler__content",children:[T==="month"&&t.jsx(Dt,{...oe}),(T==="week"||T==="day"||T==="workWeek")&&t.jsx(wt,{...oe,days:xe}),T==="dayRange"&&t.jsx(St,{...oe,rangeStart:G,rangeEnd:J}),T==="monthRange"&&t.jsx(Mt,{...oe,rangeStart:G,rangeEnd:J}),T==="timeline"&&t.jsx(kt,{...oe}),T==="agenda"&&t.jsx(bt,{...oe})]}),!g&&l&&j&&t.jsx("div",{className:"nice-scheduler__sidebar nice-scheduler__sidebar--right",children:t.jsx(Xe,{categories:j,events:Se,filteredCategories:me,onToggleCategory:Ye,t:M})})]}),ke&&t.jsx(Tt,{event:ke.event,rect:ke.rect,categories:j,renderTooltip:m}),ce&&F&&t.jsx($t,{event:ce.event,slotStart:ce.slotStart,slotEnd:ce.slotEnd,categories:j,resources:c,formFields:q,formFieldsByType:W,eventTypes:i,renderEditor:y,saving:at,onSave:ft,onDelete:yt,onClose:()=>ue(null),t:M})]})};process.env.NODE_ENV!=="production"&&(Re.displayName="NiceScheduler");const Rt=Object.freeze(Object.defineProperty({__proto__:null,NiceScheduler:Re},Symbol.toStringTag,{value:"Module"}));exports.NiceButtonGroup=$e;exports.NiceScheduler=Re;exports.NiceScheduler$1=Rt;exports.createEmptyRecipe=nt;exports.newRecipeId=tt;exports.recipeTotalMinutes=st;exports.recurrenceDates=Oe;
@@ -1 +1 @@
1
- "use strict";const e=require("react/jsx-runtime"),g=require("@nice2dev/ui-core"),t=require("react"),je=require("react-dom"),ut=[],mt=({visible:n,onClose:i,title:c,items:o=ut,showCancelButton:d=!0,cancelText:m,size:u="md",disabled:x,readOnly:f,loading:N,error:z,className:T,"data-testid":M,style:I})=>{const{t:k}=g.useNiceTranslation();if(!n)return null;const h=x||N||f;return e.jsxs(e.Fragment,{children:[e.jsx("div",{role:"presentation",className:"nice-actionsheet__overlay",onClick:i}),e.jsxs("div",{className:`nice-actionsheet nice-actionsheet--${u} ${x?"nice-actionsheet--disabled":""} ${f?"nice-actionsheet--readonly":""} ${N?"nice-actionsheet--loading":""} ${z?"nice-actionsheet--error":""} ${T||""}`,style:I,"data-testid":M,"aria-disabled":x||void 0,"aria-readonly":f||void 0,"aria-busy":N||void 0,children:[z&&e.jsx("div",{className:"nice-actionsheet__error",role:"alert",children:z}),N&&e.jsx("span",{className:"nice-actionsheet__spinner","aria-hidden":"true",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})}),c&&e.jsx("div",{className:"nice-actionsheet__title",children:c}),e.jsx("div",{className:"nice-actionsheet__items",children:o.map((r,w)=>e.jsxs("button",{className:`nice-actionsheet__item ${r.type==="danger"?"nice-actionsheet__item--danger":""}`,disabled:r.disabled||h,onClick:()=>{h||(r.onClick?.(),i())},children:[r.icon&&e.jsx("span",{className:"nice-actionsheet__icon",children:r.icon}),r.text]},w))}),d&&e.jsx("button",{className:"nice-actionsheet__cancel",onClick:i,children:m||k("cancel","Cancel")})]})]})},ft=({visible:n,onClose:i,targetRef:c,position:o="bottom",title:d,showArrow:m=!0,width:u,children:x,className:f,"data-testid":N,style:z,displayStyle:T})=>{g.useComponentDisplayClass("tooltip",T);const M=t.useRef(null),[I,k]=t.useState({top:0,left:0}),h=t.useCallback(()=>{const r=c.current,w=M.current;if(!r||!w)return;const l=r.getBoundingClientRect(),S=w.getBoundingClientRect();let a=0,L=0;const _=8;switch(o){case"top":a=l.top-S.height-_,L=l.left+(l.width-S.width)/2;break;case"bottom":a=l.bottom+_,L=l.left+(l.width-S.width)/2;break;case"left":a=l.top+(l.height-S.height)/2,L=l.left-S.width-_;break;case"right":a=l.top+(l.height-S.height)/2,L=l.right+_;break}k({top:a+window.scrollY,left:L+window.scrollX})},[c,o]);return t.useEffect(()=>{if(n){requestAnimationFrame(h);const r=w=>{const l=w.target;(l instanceof Element?l:l?.parentElement??null)?.closest('.nice-select__dropdown, [role="listbox"], [role="option"]')||M.current&&!M.current.contains(l)&&c.current&&!c.current.contains(l)&&i()};return document.addEventListener("mousedown",r),()=>document.removeEventListener("mousedown",r)}},[n,h,i,c]),g.useOverlayFocus(M,{open:n,modal:!1,onClose:()=>i()}),n?e.jsxs("div",{ref:M,className:`nice-popover nice-popover--${o} ${f||""}`,style:{...z,position:"absolute",top:I.top,left:I.left,width:u},"data-testid":N,role:"dialog","aria-label":d,children:[m&&e.jsx("div",{className:`nice-popover__arrow nice-popover__arrow--${o}`}),d&&e.jsx("div",{className:"nice-popover__title",children:d}),e.jsx("div",{className:"nice-popover__content",children:x})]}):null},ht=({visible:n,message:i,container:c,showIndicator:o=!0,shading:d=!0,className:m,"data-testid":u,style:x})=>{const{t:f}=g.useNiceTranslation();if(!n)return null;const N=!!c?.current,z=e.jsxs("div",{className:`nice-loadpanel ${m||""}`,style:x,"data-testid":u,children:[d&&e.jsx("div",{className:"nice-loadpanel__shade"}),e.jsxs("div",{className:"nice-loadpanel__box",children:[o&&e.jsx("div",{className:"nice-spinner nice-spinner--md"}),e.jsx("span",{className:"nice-loadpanel__text",children:i||f("loading","Loading...")})]})]});if(N&&c.current){const T=c.current;return T.style.position=T.style.position||"relative",z}return z},pt=({direction:n="row",align:i,justify:c,wrap:o,gap:d,flex:m,children:u,className:x,"data-testid":f,style:N})=>e.jsx("div",{"data-testid":f,className:`nice-box ${x||""}`,style:{display:"flex",flexDirection:n,alignItems:i,justifyContent:c,flexWrap:o?"wrap":void 0,gap:d,flex:m,...N},children:u}),xt=[],wt=({direction:n="row",items:i=xt,gap:c,className:o,"data-testid":d,style:m})=>e.jsx("div",{"data-testid":d,className:`nice-responsivebox ${o||""}`,style:{display:"flex",flexDirection:n,gap:c,...m},children:i.map((u,x)=>e.jsx("div",{style:{flex:u.ratio??1,flexBasis:u.baseSize,flexShrink:u.shrink??1},children:u.children},x))}),gt=({width:n=200,height:i=200,minWidth:c=50,minHeight:o=50,maxWidth:d=1/0,maxHeight:m=1/0,handles:u=["right","bottom","bottomRight"],onResize:x,children:f,className:N,"data-testid":z,style:T})=>{const[M,I]=t.useState({width:n,height:i}),k=t.useRef(null),h=(l,S)=>{S.preventDefault();const a=S.clientX,L=S.clientY,_=M.width,B=M.height,j={n:"top",s:"bottom",e:"right",w:"left",ne:"topRight",se:"bottomRight",sw:"bottomLeft",nw:"topLeft"}[l]??l,F=j==="right"||j==="topRight"||j==="bottomRight",C=j==="left"||j==="topLeft"||j==="bottomLeft",s=j==="bottom"||j==="bottomRight"||j==="bottomLeft",y=j==="top"||j==="topRight"||j==="topLeft",E=O=>{const H=O.clientX-a,v=O.clientY-L;let q=_,p=B;F&&(q=_+H),C&&(q=_-H),s&&(p=B+v),y&&(p=B-v),q=Math.max(c,Math.min(d,q)),p=Math.max(o,Math.min(m,p)),I({width:q,height:p}),x?.({width:q,height:p})},R=()=>{document.removeEventListener("pointermove",E),document.removeEventListener("pointerup",R)};document.addEventListener("pointermove",E),document.addEventListener("pointerup",R)},r=l=>{switch(l){case"top":case"bottom":return"ns-resize";case"left":case"right":return"ew-resize";case"topLeft":case"bottomRight":return"nwse-resize";case"topRight":case"bottomLeft":return"nesw-resize";default:return"default"}},w=l=>{const S={position:"absolute",zIndex:1},a=8;return l==="right"?{...S,top:0,right:-a/2,width:a,height:"100%",cursor:r(l)}:l==="bottom"?{...S,left:0,bottom:-a/2,width:"100%",height:a,cursor:r(l)}:l==="left"?{...S,top:0,left:-a/2,width:a,height:"100%",cursor:r(l)}:l==="top"?{...S,top:-a/2,left:0,width:"100%",height:a,cursor:r(l)}:l==="bottomRight"?{...S,bottom:-a/2,right:-a/2,width:a*2,height:a*2,cursor:r(l)}:l==="bottomLeft"?{...S,bottom:-a/2,left:-a/2,width:a*2,height:a*2,cursor:r(l)}:l==="topRight"?{...S,top:-a/2,right:-a/2,width:a*2,height:a*2,cursor:r(l)}:l==="topLeft"?{...S,top:-a/2,left:-a/2,width:a*2,height:a*2,cursor:r(l)}:S};return e.jsxs("div",{ref:k,"data-testid":z,className:`nice-resizable ${N||""}`,style:{...T,width:M.width,height:M.height,position:"relative",overflow:"hidden"},children:[f,u.map(l=>e.jsx("div",{style:w(l),onPointerDown:S=>h(l,S)},l))]})},bt=({direction:n="vertical",showScrollbar:i="onInteraction",width:c,height:o,onScroll:d,children:m,className:u,"data-testid":x,style:f})=>{const N=n==="horizontal"||n==="both"?"auto":"hidden",z=n==="vertical"||n==="both"?"auto":"hidden",T=i==="never"?"nice-scrollview--hide-sb":i==="always"?"nice-scrollview--show-sb":"";return e.jsx("div",{"data-testid":x,className:`nice-scrollview ${T} ${u||""}`,style:{...f,width:c,height:o,overflowX:N,overflowY:z},onScroll:d,children:m})},_t=[];function Ce(){const n=t.useContext(g.NiceThemeContext);return n?.portalTarget?n.portalTarget:typeof document<"u"?document.body:null}const vt=({open:n,onClose:i,children:c,title:o,size:d="md",closeOnBackdropClick:m=!0,closeOnEscape:u=!0,disableFocusTrap:x=!1,disableBodyScroll:f=!0,zIndex:N=1e3,className:z,style:T})=>{const M=t.useRef(null);g.useOverlayFocus(M,{open:n,modal:!x,onClose:i,closeOnEscape:u});const I=Ce();t.useEffect(()=>{if(!f&&n){const r=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=r}}},[n,f]);const k=t.useCallback(r=>{m&&r.target===r.currentTarget&&i()},[m,i]);if(!n)return null;const h={sm:"nice-modal--sm",md:"nice-modal--md",lg:"nice-modal--lg",xl:"nice-modal--xl",full:"nice-modal--full"}[d];return je.createPortal(e.jsx("div",{className:"nice-modal__overlay",style:{zIndex:N},onClick:k,role:"presentation",children:e.jsx("div",{ref:M,className:`nice-modal ${h} ${z||""}`,role:"dialog","aria-modal":"true","aria-label":o,style:T,tabIndex:-1,children:c})}),I)},yt=({children:n,showClose:i=!0,onClose:c,className:o})=>{const{t:d}=g.useNiceTranslation();return e.jsxs("div",{className:`nice-modal__header ${o||""}`,children:[e.jsx("div",{className:"nice-modal__title",children:n}),i&&c&&e.jsx("button",{type:"button",className:"nice-modal__close",onClick:c,"aria-label":d("overlays.close","Close"),children:e.jsx(g.NiceIcon,{name:"close",size:20})})]})},Nt=({children:n,className:i})=>e.jsx("div",{className:`nice-modal__body ${i||""}`,children:n}),kt=({children:n,className:i})=>e.jsx("div",{className:`nice-modal__footer ${i||""}`,children:n}),jt=({open:n,onClose:i,children:c,position:o="right",size:d=320,title:m,closeOnBackdropClick:u=!0,closeOnEscape:x=!0,swipeToClose:f=!0,zIndex:N=1e3,className:z,style:T})=>{const M=t.useRef(null),[I,k]=t.useState(!1),[h,r]=t.useState(0);g.useOverlayFocus(M,{open:n,onClose:i,closeOnEscape:x});const w=Ce(),l=t.useCallback(j=>{let F=0;switch(o){case"left":F=Math.min(0,j.deltaX);break;case"right":F=Math.max(0,j.deltaX);break;case"top":F=Math.min(0,j.deltaY);break;case"bottom":F=Math.max(0,j.deltaY);break}r(F)},[o]),S=t.useCallback(j=>{let C=!1;switch(o){case"left":C=j.deltaX<-100;break;case"right":C=j.deltaX>100;break;case"top":C=j.deltaY<-100;break;case"bottom":C=j.deltaY>100;break}C&&(g.triggerHaptic("light"),i()),r(0),k(!1)},[o,i]),{ref:a}=g.usePan({enabled:f&&n,onPanStart:()=>k(!0),onPan:l,onPanEnd:S}),L=t.useCallback(j=>{u&&j.target===j.currentTarget&&i()},[u,i]);if(!n)return null;const _=o==="left"||o==="right",B=_?{width:typeof d=="number"?`${d}px`:d}:{height:typeof d=="number"?`${d}px`:d},V=()=>{if(I)return _?`translateX(${h}px)`:`translateY(${h}px)`};return je.createPortal(e.jsxs(e.Fragment,{children:[e.jsx("div",{role:"presentation",className:`nice-drawer__overlay ${n?"nice-drawer__overlay--visible":""}`,style:{zIndex:N},onClick:L}),e.jsx("div",{ref:j=>{M.current=j,a.current=j},className:`nice-drawer nice-drawer--${o} ${n?"nice-drawer--open":""} ${z||""}`,style:{...B,zIndex:N+1,transform:V(),transition:I?"none":void 0,...T},role:"dialog","aria-modal":"true","aria-label":m,tabIndex:-1,children:c})]}),w)},Ct=({open:n,onClose:i,children:c,title:o,showHandle:d=!0,snapPoints:m=[.5,.9],initialSnap:u=0,expandable:x=!0,closeOnBackdropClick:f=!0,closeOnEscape:N=!0,hapticFeedback:z=!0,zIndex:T=1e3,className:M,style:I})=>{const k=t.useRef(null),h=t.useRef(null),[r,w]=t.useState(u),[l,S]=t.useState(!1),[a,L]=t.useState(0),_=t.useRef(0);t.useEffect(()=>{n&&(w(u),L(0))},[n,u]),g.useOverlayFocus(k,{open:n,onClose:i,closeOnEscape:N});const B=Ce();t.useEffect(()=>{if(n){const E=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=E}}},[n]);const V=t.useCallback(E=>{const R=E.target.closest(".nice-bottom-sheet__handle"),O=h.current,H=!O||O.scrollTop<=0;!R&&!H||(S(!0),_.current=E.touches[0].clientY)},[]),j=t.useCallback(E=>{if(!l)return;const R=E.touches[0].clientY-_.current;(R>0||r<m.length-1)&&L(R)},[l,r,m.length]),F=t.useCallback(()=>{if(!l)return;const E=window.innerHeight;m[r]*E;const R=-a,O=E*.15;R>O&&x&&r<m.length-1?(w(r+1),z&&g.triggerHaptic("selection")):R<-O&&(r>0?(w(r-1),z&&g.triggerHaptic("selection")):(z&&g.triggerHaptic("light"),i())),S(!1),L(0)},[l,a,r,m,x,z,i]),C=t.useCallback(()=>{f&&i()},[f,i]);if(!n)return null;const s=m[r]*100,y=l?a:0;return je.createPortal(e.jsxs(e.Fragment,{children:[e.jsx("div",{role:"presentation",className:`nice-bottom-sheet__overlay ${n?"nice-bottom-sheet__overlay--visible":""}`,style:{zIndex:T},onClick:C}),e.jsxs("div",{ref:k,className:`nice-bottom-sheet ${n?"nice-bottom-sheet--open":""} ${M||""}`,style:{zIndex:T+1,height:`${s}vh`,transform:`translateY(${Math.max(0,y)}px)`,transition:l?"none":"transform 0.3s ease-out, height 0.3s ease-out",...I},role:"dialog","aria-modal":"true","aria-label":o,tabIndex:-1,onTouchStart:V,onTouchMove:j,onTouchEnd:F,children:[d&&e.jsx("div",{className:"nice-bottom-sheet__handle","aria-hidden":"true"}),o&&e.jsx("div",{className:"nice-bottom-sheet__title",children:o}),e.jsx("div",{ref:h,className:"nice-bottom-sheet__content",children:c})]})]}),B)},Et=({trigger:n,children:i,placement:c="bottom",triggerMode:o="click",open:d,onOpenChange:m,hoverDelay:u=200,offset:x=8,className:f,showArrow:N=!0})=>{const[z,T]=t.useState(!1),M=t.useRef(null),I=t.useRef(null),k=t.useRef(null),h=Ce(),r=d!==void 0,w=r?d:z,l=t.useCallback(C=>{r||T(C),m?.(C)},[r,m]);g.useClickOutside(I,()=>{o!=="manual"&&w&&l(!1)});const S=o!=="hover";g.useOverlayFocus(I,{open:w&&S,modal:!1,onClose:()=>l(!1)});const a=t.useCallback(()=>{o==="click"&&l(!w)},[o,w,l]),L=t.useCallback(()=>{o==="hover"&&(k.current&&window.clearTimeout(k.current),k.current=window.setTimeout(()=>l(!0),u))},[o,u,l]),_=t.useCallback(()=>{o==="hover"&&(k.current&&window.clearTimeout(k.current),k.current=window.setTimeout(()=>l(!1),u))},[o,u,l]),B=t.useCallback(C=>{const s=C.relatedTarget;!M.current?.contains(s)&&!I.current?.contains(s)&&_()},[_]),V=t.useCallback(C=>{o==="hover"&&w&&C.key==="Escape"&&(C.preventDefault(),C.stopPropagation(),k.current&&window.clearTimeout(k.current),l(!1))},[o,w,l]),[j,F]=t.useState({top:0,left:0});return t.useEffect(()=>{if(!w||!M.current||!I.current)return;const C=M.current.getBoundingClientRect(),s=I.current.getBoundingClientRect(),y=window.innerWidth,E=window.innerHeight;let R=0,O=0;const[H,v="center"]=c.split("-");switch(H){case"top":R=C.top-s.height-x,O=C.left+(C.width-s.width)/2;break;case"bottom":R=C.bottom+x,O=C.left+(C.width-s.width)/2;break;case"left":R=C.top+(C.height-s.height)/2,O=C.left-s.width-x;break;case"right":R=C.top+(C.height-s.height)/2,O=C.right+x;break}H==="top"||H==="bottom"?(v==="start"&&(O=C.left),v==="end"&&(O=C.right-s.width)):(v==="start"&&(R=C.top),v==="end"&&(R=C.bottom-s.height)),O=Math.max(8,Math.min(y-s.width-8,O)),R=Math.max(8,Math.min(E-s.height-8,R)),F({top:R,left:O})},[w,c,x]),e.jsxs(e.Fragment,{children:[e.jsx("div",{ref:M,className:"nice-popover__trigger",onClick:a,onMouseEnter:L,onMouseLeave:_,onFocus:L,onBlur:B,onKeyDown:V,style:{display:"inline-block"},children:n}),w&&je.createPortal(e.jsxs("div",{ref:I,className:`nice-popover nice-popover--${c} ${f||""}`,style:{position:"fixed",top:j.top,left:j.left,zIndex:1100},onMouseEnter:L,onMouseLeave:_,role:S?"dialog":"tooltip",children:[N&&e.jsx("div",{className:"nice-popover__arrow"}),e.jsx("div",{className:"nice-popover__content",children:i})]}),h)]})},It=({items:n=_t,children:i,onOpen:c,onClose:o,className:d})=>{const[m,u]=t.useState(!1),[x,f]=t.useState({x:0,y:0}),N=t.useRef(null),z=t.useRef(null),T=Ce();g.useClickOutside(N,()=>{m&&(u(!1),o?.())});const M=t.useCallback(r=>{if(r.preventDefault(),r.clientX===0&&r.clientY===0&&r.target instanceof Element){const w=r.target.getBoundingClientRect();f({x:w.left,y:w.bottom})}else f({x:r.clientX,y:r.clientY});u(!0),c?.()},[c]),I=t.useCallback(()=>{u(!1),o?.()},[o]),k=t.useCallback(r=>{!r.disabled&&r.onClick&&(r.onClick(),I())},[I]);g.useOverlayFocus(N,{open:m,modal:!1,onClose:I}),g.useRovingFocus(N,{orientation:"vertical",wrap:!0,typeahead:!0});const h=r=>e.jsx("ul",{className:"nice-context-menu__list",role:"menu",children:r.map(w=>w.divider?e.jsx("li",{className:"nice-context-menu__divider",role:"separator"},w.key):e.jsx("li",{role:"presentation",children:e.jsxs("button",{type:"button",className:`nice-context-menu__item ${w.disabled?"nice-context-menu__item--disabled":""} ${w.danger?"nice-context-menu__item--danger":""}`,role:"menuitem",disabled:w.disabled,onClick:()=>k(w),children:[w.icon&&e.jsx("span",{className:"nice-context-menu__icon",children:w.icon}),e.jsx("span",{className:"nice-context-menu__label",children:w.label})]})},w.key))});return e.jsxs(e.Fragment,{children:[e.jsx("div",{ref:z,onContextMenu:M,style:{display:"contents"},children:i}),m&&je.createPortal(e.jsx("div",{ref:N,className:`nice-context-menu ${d||""}`,style:{position:"fixed",left:x.x,top:x.y,zIndex:1200},children:h(n)}),T)]})};function Oe(n,i){if(!n)return{score:1,indices:[]};const c=n.toLowerCase(),o=i.toLowerCase();let d=0;const m=[];let u=0,x=-1;for(let f=0;f<o.length&&d<c.length;f++)o[f]===c[d]&&(m.push(f),x===f-1&&(u+=3),(f===0||/[\s\-_/.]/.test(i[f-1]))&&(u+=5),i[f]===n[d]&&(u+=1),u+=1,x=f,d++);return d<c.length?null:(u-=m[0]*.1,{score:u,indices:m})}function Ke(n,i){if(i.length===0)return[n];const c=[];let o=0;const d=new Set(i);for(let m=0;m<n.length;m++)d.has(m)&&(o<m&&c.push(n.slice(o,m)),c.push(t.createElement("mark",{key:`m-${m}`,className:"nice-command-palette__match"},n[m])),o=m+1);return o<n.length&&c.push(n.slice(o)),c}function Rt(n,i){switch(i.type){case"REGISTER":{const c=new Map(n.commands);return c.set(i.command.id,i.command),{...n,commands:c}}case"REGISTER_BATCH":{const c=new Map(n.commands);for(const o of i.commands)c.set(o.id,o);return{...n,commands:c}}case"UNREGISTER":{const c=new Map(n.commands);return c.delete(i.id),{...n,commands:c}}case"OPEN":return{...n,isOpen:!0,query:"",selectedIndex:0};case"CLOSE":return{...n,isOpen:!1,query:"",selectedIndex:0};case"SET_QUERY":return{...n,query:i.query,selectedIndex:0};case"SET_SELECTED":return{...n,selectedIndex:i.index};case"ADD_RECENT":{const c=n.recentIds.filter(o=>o!==i.id);return{...n,recentIds:[i.id,...c].slice(0,i.maxRecent)}}default:return n}}const Ge=t.createContext(null);function Qe(){const n=t.useContext(Ge);if(!n)throw new Error("useCommandPalette must be used within NiceCommandPaletteProvider");return n}const Ze=({children:n,commands:i,placeholder:c,maxVisible:o=10,maxRecent:d=5,className:m,emptyText:u,closeOnAction:x=!0,onOpen:f,onClose:N,includeActions:z=!0})=>{const{t:T}=g.useNiceTranslation(),M=g.useNiceActions(),I=T("commandPalette.general","General"),k=Ce(),[h,r]=t.useReducer(Rt,{commands:new Map(i?.map(p=>[p.id,p])??[]),isOpen:!1,query:"",selectedIndex:0,recentIds:[]}),w=t.useRef(null),l=t.useRef(null),[S,a]=t.useState(!1),L=t.useCallback(p=>{r({type:"REGISTER",command:p})},[]),_=t.useCallback(p=>{r({type:"UNREGISTER",id:p})},[]),B=t.useCallback(p=>{r({type:"REGISTER_BATCH",commands:p})},[]),V=t.useCallback(()=>{r({type:"OPEN"}),f?.()},[f]),j=t.useCallback(()=>{r({type:"CLOSE"}),N?.()},[N]),F=t.useCallback(()=>{h.isOpen?j():V()},[h.isOpen,j,V]),C=t.useMemo(()=>{const p=new Map(h.commands);if(z)for(const $ of M){const b=`action:${$.id}`;$.palette===!1||p.has(b)||p.set(b,{id:b,label:$.label,description:$.description,category:$.group,shortcut:typeof $.keyboard=="string"?$.keyboard:$.keyboard?.[0],disabled:$.when?!$.when():!1,action:()=>{g.triggerNiceAction($.id,"keyboard")}})}return p},[h.commands,M,z,h.isOpen]),y=t.useMemo(()=>{const p=Array.from(C.values()).filter(b=>!b.hidden);if(!h.query.trim()){const b=h.recentIds.map(D=>C.get(D)).filter(D=>!!D&&!D.hidden),W=p.filter(D=>!h.recentIds.includes(D.id));return W.sort((D,se)=>D.label.localeCompare(se.label)),[...b,...W].map(D=>({command:D,match:null,isRecent:h.recentIds.includes(D.id)}))}return p.map(b=>{const W=Oe(h.query,b.label),D=b.description?Oe(h.query,b.description):null,se=b.keywords?.map(ne=>Oe(h.query,ne)).filter(Boolean)[0]??null,ae=[W,D,se].filter(Boolean).sort((ne,pe)=>(pe?.score??0)-(ne?.score??0))[0]??null;return{command:b,match:ae,isRecent:!1}}).filter(b=>b.match!==null).sort((b,W)=>(W.match?.score??0)-(b.match?.score??0))},[C,h.query,h.recentIds]).slice(0,o),E=t.useCallback(async p=>{const $=C.get(p);if(!(!$||$.disabled)){a(!0);try{await $.action(),r({type:"ADD_RECENT",id:p,maxRecent:d})}finally{a(!1),x&&j()}}},[C,d,x,j]);g.useIntent("menu",()=>F());const R=t.useRef(null);g.useOverlayFocus(R,{open:h.isOpen,onClose:j,initialFocus:w}),g.useIntent(["navigate","activate"],p=>{const $=y.length;if(p.intent==="activate"){const W=y[h.selectedIndex];return W&&E(W.command.id),!0}if(!$||p.direction!=="up"&&p.direction!=="down")return!1;const b=p.direction==="down"?1:-1;return r({type:"SET_SELECTED",index:(h.selectedIndex+b+$)%$}),!0},{ref:R,enabled:h.isOpen}),g.useInputHints(R,h.isOpen?[{intent:"navigate",label:T("commandPalette.choose","Choose")},{intent:"activate",label:T("commandPalette.run","Run")},{intent:"back",label:T("input.hint.close","Close")}]:[]);const O=t.useCallback(p=>{const $=y.length;if($){if(p.key==="ArrowDown")p.preventDefault(),r({type:"SET_SELECTED",index:(h.selectedIndex+1)%$});else if(p.key==="ArrowUp")p.preventDefault(),r({type:"SET_SELECTED",index:(h.selectedIndex-1+$)%$});else if(p.key==="Enter"){p.preventDefault();const b=y[h.selectedIndex];b&&E(b.command.id)}}},[y,h.selectedIndex,E]);t.useEffect(()=>{if(!l.current)return;l.current.children[h.selectedIndex]?.scrollIntoView?.({block:"nearest"})},[h.selectedIndex]);const H=t.useMemo(()=>({registerCommand:L,unregisterCommand:_,registerCommands:B,open:V,close:j,toggle:F,isOpen:h.isOpen,executeCommand:E}),[L,_,B,V,j,F,h.isOpen,E]),v=t.useMemo(()=>{const p=new Map;for(const $ of y){const b=$.command.category??I;p.has(b)||p.set(b,[]),p.get(b).push($)}return p},[y,I]);let q=0;return e.jsxs(Ge.Provider,{value:H,children:[n,h.isOpen&&je.createPortal(e.jsx("div",{className:`nice-command-palette__overlay ${m??""}`,role:"presentation",onClick:p=>{p.stopPropagation(),p.target===p.currentTarget&&j()},children:e.jsxs("div",{ref:R,className:"nice-command-palette",role:"dialog","aria-label":T("commandPalette.title","Command palette"),"aria-modal":"true",children:[e.jsx("div",{className:"nice-command-palette__input-wrapper",children:e.jsx("input",{ref:w,className:"nice-command-palette__input",type:"text",placeholder:c??T("commandPalette.placeholder","Type a command..."),value:h.query,onChange:p=>r({type:"SET_QUERY",query:p.target.value}),onKeyDown:O,"aria-label":T("commandPalette.search","Search commands"),"aria-autocomplete":"list","aria-controls":"nice-command-palette-list","aria-activedescendant":y[h.selectedIndex]?`nice-cmd-${y[h.selectedIndex].command.id}`:void 0})}),e.jsxs("div",{ref:l,id:"nice-command-palette-list",className:"nice-command-palette__list",role:"listbox",children:[y.length===0&&e.jsx("div",{className:"nice-command-palette__empty",children:u??T("commandPalette.empty","No commands found")}),Array.from(v.entries()).map(([p,$])=>e.jsxs("div",{className:"nice-command-palette__group",children:[e.jsx("div",{className:"nice-command-palette__category",children:p}),$.map(b=>{const W=q++,D=W===h.selectedIndex;return e.jsxs("div",{id:`nice-cmd-${b.command.id}`,className:`nice-command-palette__item ${D?"nice-command-palette__item--selected":""} ${b.command.disabled?"nice-command-palette__item--disabled":""}`,role:"option","aria-selected":D,"aria-disabled":b.command.disabled,onClick:()=>!b.command.disabled&&E(b.command.id),onMouseEnter:()=>r({type:"SET_SELECTED",index:W}),children:[b.command.icon&&e.jsx("span",{className:"nice-command-palette__icon",children:b.command.icon}),e.jsxs("div",{className:"nice-command-palette__label-group",children:[e.jsx("span",{className:"nice-command-palette__label",children:b.match&&h.query?Ke(b.command.label,b.match.indices):b.command.label}),b.command.description&&e.jsx("span",{className:"nice-command-palette__description",children:b.command.description})]}),b.command.shortcut&&e.jsx("kbd",{className:"nice-command-palette__shortcut",children:b.command.shortcut}),b.isRecent&&e.jsx("span",{className:"nice-command-palette__recent-badge",children:T("commandPalette.recent","Recent")})]},b.command.id)})]},p))]}),S&&e.jsx("div",{className:"nice-command-palette__executing",children:T("commandPalette.executing","Executing...")})]})}),k)]})};process.env.NODE_ENV!=="production"&&(Ze.displayName="NiceCommandPaletteProvider");function Tt(n){const{registerCommands:i,unregisterCommand:c}=Qe();t.useEffect(()=>(i(n),()=>{for(const o of n)c(o.id)}),[])}const Mt=Object.assign(t.forwardRef(({blocked:n,message:i,spinner:c,blur:o,children:d,className:m,"data-testid":u,style:x,id:f},N)=>{const z=g.useControlId(f);return e.jsxs("div",{ref:N,id:z,className:`nice-block-ui ${m||""}`,style:{position:"relative",...x},"data-testid":u,children:[d,n&&e.jsx("div",{className:`nice-block-ui__overlay${o?" nice-block-ui__overlay--blur":""}`,"aria-busy":"true",role:"alert",children:(c||i)&&e.jsxs("div",{className:"nice-block-ui__content",children:[c&&e.jsx("div",{className:"nice-block-ui__spinner","aria-hidden":"true"}),i&&e.jsx("div",{className:"nice-block-ui__message",children:i})]})})]})}),{displayName:"NiceBlockUI"}),St=Object.assign(t.forwardRef(({windows:n,children:i,onChange:c,onClose:o,onFocus:d,showTaskbar:m=!0,size:u="md",className:x,style:f,id:N,...z},T)=>{const M=g.useControlId(N),{t:I}=g.useNiceTranslation(),[k,h]=t.useState(null),r=t.useRef(null),w=t.useRef(null);g.useRovingFocus(w,{orientation:"horizontal",itemSelector:".nice-wm__taskbar-btn"});const l=t.useRef(null),S=t.useCallback(s=>{const y=[...r.current?.querySelectorAll("[data-wm-key]")??[]].find(E=>E.getAttribute("data-wm-key")===s);return y?((g.focusCandidates(y)[0]??y).focus(),!0):!1},[]);t.useEffect(()=>{const s=l.current;s&&S(s)&&(l.current=null)});const a=t.useMemo(()=>n??[],[n]),L=Math.max(1,...a.map(s=>s.zIndex??1)),_=t.useCallback((s,y)=>{const E=a.map(R=>R.key===s?{...R,...y}:R);c?.(E)},[a,c]),B=t.useCallback(s=>{_(s,{zIndex:L+1}),d?.(s)},[_,L,d]),V=t.useCallback(s=>{o?.(s),c?.(a.filter(y=>y.key!==s))},[a,c,o]),j=t.useCallback(s=>{const y=a.find(E=>E.key===s);y&&_(s,{minimized:!y.minimized,maximized:!1})},[a,_]),F=t.useCallback(s=>{const y=a.find(E=>E.key===s);y&&_(s,{maximized:!y.maximized,minimized:!1})},[a,_]);t.useEffect(()=>{if(!k)return;const s=E=>{const R=a.find(O=>O.key===k.key);if(R)if(k.mode==="move")_(k.key,{x:E.clientX-k.offsetX,y:E.clientY-k.offsetY});else{const H=r.current?.getBoundingClientRect(),v=H?.left??0,q=H?.top??0;_(k.key,{width:Math.max(200,E.clientX-v-R.x),height:Math.max(100,E.clientY-q-R.y)})}},y=()=>h(null);return document.addEventListener("mousemove",s),document.addEventListener("mouseup",y),()=>{document.removeEventListener("mousemove",s),document.removeEventListener("mouseup",y)}},[k,a,_]);const C=t.useCallback((s,y,E)=>{y.preventDefault();const R=a.find(O=>O.key===s);R&&(B(s),h({key:s,offsetX:E==="move"?y.clientX-R.x:0,offsetY:E==="move"?y.clientY-R.y:0,mode:E}))},[a,B]);return e.jsxs("div",{ref:s=>{r.current=s,typeof T=="function"?T(s):T&&(T.current=s)},id:M,className:`nice-wm nice-wm--${u} ${x??""}`,style:{...f,position:"relative",overflow:"hidden"},...z,children:[a.map(s=>{if(s.minimized)return null;const y=s.maximized,E=y?{position:"absolute",top:0,left:0,width:"100%",height:"100%",zIndex:s.zIndex??1}:{position:"absolute",top:s.y,left:s.x,width:s.width,height:s.height,zIndex:s.zIndex??1};return e.jsxs("div",{className:`nice-wm__window ${y?"nice-wm__window--maximized":""}`,style:E,onMouseDown:()=>B(s.key),onFocus:()=>{(s.zIndex??1)<L&&B(s.key)},role:"dialog","aria-label":s.title,tabIndex:-1,"data-wm-key":s.key,"data-nice-focus-scope":"spatial","data-nice-region":s.title,children:[e.jsxs("div",{className:"nice-wm__titlebar",onMouseDown:R=>!y&&C(s.key,R,"move"),children:[s.icon&&e.jsx("span",{className:"nice-wm__icon",children:s.icon}),e.jsx("span",{className:"nice-wm__title",children:s.title}),e.jsxs("div",{className:"nice-wm__controls",children:[(s.minimizable??!0)&&e.jsx("button",{type:"button",className:"nice-wm__ctrl-btn nice-wm__ctrl-btn--min",onClick:()=>j(s.key),title:I("wm.minimize","Minimize"),children:e.jsx(g.NiceIcon,{name:"minus",size:14})}),(s.maximizable??!0)&&e.jsx("button",{type:"button",className:"nice-wm__ctrl-btn nice-wm__ctrl-btn--max",onClick:()=>F(s.key),title:I("wm.maximize","Maximize"),children:e.jsx(g.NiceIcon,{name:y?"copy":"window",size:14})}),(s.closable??!0)&&e.jsx("button",{type:"button",className:"nice-wm__ctrl-btn nice-wm__ctrl-btn--close",onClick:()=>V(s.key),title:I("wm.close","Close"),children:e.jsx(g.NiceIcon,{name:"close",size:14})})]})]}),e.jsx("div",{className:"nice-wm__body",children:s.content}),(s.resizable??!0)&&!y&&e.jsx("div",{className:"nice-wm__resize-handle",onMouseDown:R=>C(s.key,R,"resize")})]},s.key)}),n===void 0&&i,m&&e.jsx("div",{ref:w,className:"nice-wm__taskbar",role:"toolbar","aria-label":I("wm.taskbar","Taskbar"),"data-nice-region":I("wm.taskbar","Taskbar"),children:a.map(s=>e.jsxs("button",{type:"button",className:`nice-wm__taskbar-btn ${s.minimized?"nice-wm__taskbar-btn--minimized":""}`,onClick:()=>{s.minimized&&j(s.key),B(s.key),(s.minimized||!S(s.key))&&(l.current=s.key)},children:[s.icon&&e.jsx("span",{className:"nice-wm__taskbar-icon",children:s.icon}),e.jsx("span",{className:"nice-wm__taskbar-label",children:s.title})]},s.key))})]})}),{displayName:"NiceWindowManager"});function zt(n,i){const c=document.querySelector(n);if(!c)return null;const o=c.getBoundingClientRect();return{top:o.top-i+window.scrollY,left:o.left-i+window.scrollX,width:o.width+i*2,height:o.height+i*2}}function $t(n,i,c,o){const m={w:window.innerWidth,h:window.innerHeight+window.scrollY},u={top:{top:n.top-c-12,left:n.left+n.width/2-i/2},bottom:{top:n.top+n.height+12,left:n.left+n.width/2-i/2},left:{top:n.top+n.height/2-c/2,left:n.left-i-12},right:{top:n.top+n.height/2-c/2,left:n.left+n.width+12}};if(o&&o!=="auto")return{...u[o],actualPlacement:o};for(const x of["bottom","top","right","left"]){const f=u[x];if(f.top>=0&&f.left>=0&&f.top+c<=m.h&&f.left+i<=m.w)return{...f,actualPlacement:x}}return{...u.bottom,actualPlacement:"bottom"}}function Pt(){return e.jsx(g.NiceIcon,{name:"close",size:16})}function Lt(){return e.jsx(g.NiceIcon,{name:"chevron-left",size:16})}function Ot(){return e.jsx(g.NiceIcon,{name:"chevron-right",size:16})}function Yt(){return e.jsx(g.NiceIcon,{name:"skip-forward",size:16})}function Dt(){return e.jsx(g.NiceIcon,{name:"play",size:16})}function Ft(){return e.jsx(g.NiceIcon,{name:"pause",size:16})}function Le(n,i,c){return c==="text"?e.jsx("span",{className:"nice-tutorial__btn-label",children:i}):c==="icon-text"?e.jsxs(e.Fragment,{children:[n,e.jsx("span",{className:"nice-tutorial__btn-label",children:i})]}):n}const Bt=[],We=({steps:n=Bt,active:i,onFinish:c,onSkip:o,onStepChange:d,closeOnEscape:m=!0,closeOnOverlayClick:u=!1,showProgress:x=!0,showSkipButton:f=!0,labels:N,animationDuration:z=300,overlayOpacity:T=.6,zIndex:M=1e4,buttonsPlacement:I="floating-bottom",buttonsDisplay:k="icon",showAutoplay:h=!0,autoplayInterval:r=5e3,autoplaySpeedRange:w={min:2e3,max:15e3},onAutoplayChange:l})=>{const{t:S}=g.useNiceTranslation(),[a,L]=t.useState(0),[_,B]=t.useState(null),[V,j]=t.useState({w:340,h:200}),[F,C]=t.useState(!0),[s,y]=t.useState(!1),[E,R]=t.useState(r),O=t.useRef(null),H=t.useRef(-1),v=n[a],q=a===n.length-1,p=a===0,$=N?.next??"Next",b=N?.back??"Back",W=N?.finish??"Finish",D=N?.skip??"Skip",se=N?.stepOf??"of",ae=N?.play??"Play",ne=N?.pause??"Pause",pe=N?.speed??"Speed",Se=N?.close??"Close";t.useEffect(()=>{i&&(L(0),y(!1),R(r))},[i,r]),t.useEffect(()=>{if(O.current){const P=O.current.getBoundingClientRect();j({w:P.width,h:P.height})}},[a,i]),t.useEffect(()=>{if(!i||!v)return;const P=v.highlightPadding??0,X=()=>{const K=zt(v.target,P);B(K)};if(X(),v.scrollIntoView!==!1){document.querySelector(v.target)?.scrollIntoView({behavior:"smooth",block:"center"});const Ie=setTimeout(X,350);return()=>clearTimeout(Ie)}},[i,v,a]),t.useEffect(()=>{!i||!v||H.current!==a&&(H.current>=0&&H.current<n.length&&n[H.current]?.onLeave?.(),v.onEnter?.(),H.current=a)},[i,v,a,n]);const oe=t.useCallback(()=>{if(q)v?.onLeave?.(),c?.();else{const P=a+1;L(P),d?.(P)}},[a,q,c,d,v]),xe=t.useCallback(()=>{if(!p){const P=a-1;L(P),d?.(P)}},[a,p,d]),ze=t.useCallback(P=>{P!==a&&P>=0&&P<n.length&&(L(P),d?.(P))},[a,n.length,d]);t.useEffect(()=>{if(!i||!v?.advanceOn)return;const P=document.querySelector(v.target);if(!P)return;const X=()=>oe();return P.addEventListener(v.advanceOn.event,X),()=>P.removeEventListener(v.advanceOn.event,X)},[i,v,a,oe]);const we=t.useRef(null),G=!!(i&&v);g.useOverlayFocus(we,{open:G,modal:!(v?.waitForAction||v?.advanceOn),onClose:()=>o?.(),closeOnEscape:m,closeHint:D}),t.useEffect(()=>{const P=we.current;if(!G||!P)return;const X=K=>{if(!(K.defaultPrevented||K.target instanceof HTMLInputElement)){if(K.key==="ArrowRight")oe();else if(K.key==="ArrowLeft")xe();else if(K.key==="Home"||K.key==="End")ze(K.key==="Home"?0:n.length-1);else return;K.preventDefault()}};return P.addEventListener("keydown",X),()=>P.removeEventListener("keydown",X)},[G,oe,xe,ze,n.length]);const ye=g.useInputEngine(),A=G?v?.title:void 0;t.useEffect(()=>{A&&a>0&&ye?.announce(A)},[ye,A,a]);const Ee=t.useId(),$e=`${Ee}-content`;g.useIntent(["sectionPrev","sectionNext"],P=>{if(P.intent==="sectionNext"){if(v?.waitForAction)return!1;oe()}else xe()},{ref:we,enabled:G}),g.useInputHints(we,G?[...p?[]:[{intent:"sectionPrev",label:b}],...v?.waitForAction?[]:[{intent:"sectionNext",label:q?W:$}]]:[]),t.useEffect(()=>{C(!0);const P=setTimeout(()=>C(!1),z);return()=>clearTimeout(P)},[a,z]),t.useEffect(()=>{if(!i||!s)return;const P=setInterval(()=>{L(X=>{if(X>=n.length-1)return y(!1),l?.(!1),n[X]?.onLeave?.(),c?.(),X;const K=X+1;return d?.(K),K})},Math.max(500,E));return()=>clearInterval(P)},[i,s,E,n,l,c,d]);const ge=t.useCallback(()=>{y(P=>{const X=!P;return l?.(X),X})},[l]),ee=t.useMemo(()=>_?$t(_,V.w,V.h,v?.placement):{top:typeof window<"u"?window.innerHeight/2:0,left:typeof window<"u"?window.innerWidth/2:0,actualPlacement:"bottom"},[_,V,v?.placement]),re=n.length===0?0:(a+1)/n.length*100,be=t.useCallback(P=>{const X=h&&n.length>1,K=f&&!q&&e.jsx("button",{type:"button",className:`nice-tutorial__btn nice-tutorial__btn--skip nice-tutorial__btn--${k}`,onClick:o,"aria-label":D,title:D,children:Le(e.jsx(Yt,{}),D,k)}),Ie=!p&&e.jsx("button",{type:"button",className:`nice-tutorial__btn nice-tutorial__btn--back nice-tutorial__btn--${k}`,onClick:xe,"aria-label":b,title:b,children:Le(e.jsx(Lt,{}),b,k)}),Fe=!v?.waitForAction&&e.jsx("button",{type:"button",className:`nice-tutorial__btn nice-tutorial__btn--next nice-tutorial__btn--${k}`,onClick:oe,"aria-label":q?W:$,title:q?W:$,children:Le(e.jsx(Ot,{}),q?W:$,k)}),Be=X&&e.jsx("button",{type:"button",className:["nice-tutorial__btn","nice-tutorial__btn--play",`nice-tutorial__btn--${k}`,s?"nice-tutorial__btn--active":""].filter(Boolean).join(" "),onClick:ge,"aria-label":s?ne:ae,title:s?ne:ae,"aria-pressed":s,children:Le(s?e.jsx(Ft,{}):e.jsx(Dt,{}),s?ne:ae,k)});return e.jsxs("div",{className:["nice-tutorial__controls",P?"nice-tutorial__controls--inline":"nice-tutorial__controls--floating-bottom"].join(" "),style:P?void 0:{zIndex:M+2},role:"group","aria-label":S("tutorial.tutorialControls","Tutorial controls"),children:[K,Ie,x&&e.jsxs("span",{className:"nice-tutorial__step-label","aria-live":"polite",children:[a+1," ",se," ",n.length]}),Fe,X&&e.jsx("div",{className:"nice-tutorial__progress-bar",role:"progressbar","aria-valuenow":Math.round(re),"aria-valuemin":0,"aria-valuemax":100,"aria-label":`${a+1} ${se} ${n.length}`,children:e.jsx("div",{className:"nice-tutorial__progress-bar-fill",style:{width:`${re}%`}})}),Be,X&&e.jsxs("label",{className:"nice-tutorial__speed",children:[e.jsx("input",{type:"range",className:"nice-tutorial__speed-slider",min:w.min,max:w.max,step:500,value:w.min+w.max-E,onChange:te=>R(w.min+w.max-Number(te.target.value)),"aria-label":pe}),e.jsxs("span",{className:"nice-tutorial__speed-value",children:[(E/1e3).toFixed(1),"s"]})]})]})},[h,f,x,k,p,q,o,D,b,$,W,ae,ne,pe,se,xe,oe,v,s,ge,a,n.length,re,E,w,M,S]);if(!i||!v)return null;const Ye=typeof document<"u"?Math.max(document.documentElement.scrollWidth,window.innerWidth):0,De=typeof document<"u"?Math.max(document.documentElement.scrollHeight,window.innerHeight):0;return e.jsxs("div",{ref:we,className:"nice-tutorial",style:{zIndex:M},"aria-modal":v.waitForAction||v.advanceOn?void 0:!0,role:"dialog","aria-label":v.title?void 0:S("tutorial.tutorial","Tutorial"),"aria-labelledby":v.title?Ee:void 0,"aria-describedby":v.content?$e:void 0,children:[e.jsxs("svg",{className:"nice-tutorial__overlay",style:{position:"absolute",top:0,left:0,width:Ye,height:De,pointerEvents:"auto"},onClick:u?o:void 0,children:[e.jsx("defs",{children:e.jsxs("mask",{id:"nice-tutorial-mask",children:[e.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:"white"}),_&&e.jsx("rect",{x:_.left,y:_.top,width:_.width,height:_.height,rx:"4",fill:"black",className:F?"nice-tutorial__spotlight--entering":""})]})}),e.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`rgba(0,0,0,${T})`,mask:"url(#nice-tutorial-mask)"})]}),_&&e.jsx("div",{className:`nice-tutorial__highlight ${F?"nice-tutorial__highlight--entering":""}`,style:{position:"absolute",top:_.top,left:_.left,width:_.width,height:_.height,transition:`all ${z}ms ease`}}),v.disableInteraction&&_&&e.jsx("div",{className:"nice-tutorial__blocker",style:{position:"absolute",top:_.top,left:_.left,width:_.width,height:_.height}}),e.jsxs("div",{ref:O,className:`nice-tutorial__tooltip nice-tutorial__tooltip--${ee.actualPlacement} ${F?"nice-tutorial__tooltip--entering":""}`,style:{position:"absolute",top:ee.top,left:ee.left,transition:`all ${z}ms ease`,maxWidth:380,zIndex:M+1},children:[v.showArrow!==!1&&e.jsx("div",{className:`nice-tutorial__arrow nice-tutorial__arrow--${ee.actualPlacement}`}),e.jsxs("div",{className:"nice-tutorial__header",children:[e.jsx("h4",{id:Ee,className:"nice-tutorial__title",children:v.title}),f&&e.jsx("button",{type:"button",className:"nice-tutorial__close",onClick:o,"aria-label":Se,title:Se,children:e.jsx(Pt,{})})]}),e.jsx("div",{id:$e,className:"nice-tutorial__content",dangerouslySetInnerHTML:{__html:g.sanitizeHtml(v.content)}}),I==="inline"&&be(!0)]}),I==="floating-bottom"&&be(!1)]})};process.env.NODE_ENV!=="production"&&(We.displayName="NiceTutorial");const Je=t.createContext({startTutorial:()=>{},stopTutorial:()=>{},isActive:!1,currentStep:0,nextStep:()=>{},prevStep:()=>{},goToStep:()=>{}});function Ht(){return t.useContext(Je)}const et=({children:n})=>{const[i,c]=t.useState([]),[o,d]=t.useState(!1),[m,u]=t.useState(0),x=t.useCallback(I=>{c(I),u(0),d(!0)},[]),f=t.useCallback(()=>{d(!1),u(0),c([])},[]),N=t.useCallback(()=>{u(I=>Math.min(I+1,i.length-1))},[i.length]),z=t.useCallback(()=>{u(I=>Math.max(I-1,0))},[]),T=t.useCallback(I=>{u(Math.max(0,Math.min(I,i.length-1)))},[i.length]),M={startTutorial:x,stopTutorial:f,isActive:o,currentStep:m,nextStep:N,prevStep:z,goToStep:T};return e.jsxs(Je.Provider,{value:M,children:[n,o&&i.length>0&&e.jsx(We,{steps:i,active:o,onFinish:f,onSkip:f,onStepChange:u})]})};process.env.NODE_ENV!=="production"&&(et.displayName="NiceTutorialProvider");function Xt(n,i,c,o,d){const m=n<=d,u=n+d>=c,x=i<=d,f=i+d>=o;return x&&m?"top-left":x&&u?"top-right":f&&m?"bottom-left":f&&u?"bottom-right":m?"left":u?"right":x?"top":f?"bottom":"none"}function qt(n){switch(n){case"left":return{left:0,top:0,width:"50%",height:"100%"};case"right":return{left:"50%",top:0,width:"50%",height:"100%"};case"top":return{left:0,top:0,width:"100%",height:"50%"};case"bottom":return{left:0,top:"50%",width:"100%",height:"50%"};case"top-left":return{left:0,top:0,width:"50%",height:"50%"};case"top-right":return{left:"50%",top:0,width:"50%",height:"50%"};case"bottom-left":return{left:0,top:"50%",width:"50%",height:"50%"};case"bottom-right":return{left:"50%",top:"50%",width:"50%",height:"50%"};default:return null}}const At=Object.assign(t.forwardRef(({windowKey:n,title:i,icon:c,children:o,footer:d,x:m,y:u,defaultPosition:x,width:f=480,height:N=360,minWidth:z=200,minHeight:T=120,maxWidth:M,maxHeight:I,zIndex:k=1,closable:h=!0,minimizable:r=!0,maximizable:w=!0,fullscreenable:l=!1,pinnable:S=!1,resizable:a=!0,draggable:L=!0,snappable:_=!0,snapThreshold:B=20,minimized:V,maximized:j,fullscreen:F,pinned:C,focused:s,onClose:y,onMinimize:E,onMaximize:R,onFullscreen:O,onPin:H,onFocus:v,onMove:q,onResize:p,onSnap:$,onTitleBarDoubleClick:b,size:W="md",statusBar:D,titleBarActions:se,className:ae,style:ne,id:pe,accessMode:Se,...oe},xe)=>{const ze=g.useControlId(pe),we=g.useNiceAccessMode(Se,pe),{t:G}=g.useNiceTranslation(),ye=t.useRef(null);ye.current==null&&(ye.current=`nice-window-${Math.random().toString(36).slice(2,10)}`);const A=n??ye.current,Ee=m??x?.x??100,$e=u??x?.y??100,[ge,ee]=t.useState({x:Ee,y:$e}),[re,be]=t.useState({width:f,height:N}),[Ye,De]=t.useState(!1),[P,X]=t.useState(!1),[K,Ie]=t.useState(!1),[Fe,Be]=t.useState(!1),[te,He]=t.useState("none"),tt=V??Ye,ie=j??P,Z=F??K,Re=C??Fe,Pe=s??!0,_e=ge.x,ve=ge.y,le=re.width,de=re.height,ue=t.useRef(null),J=t.useRef(null),U=t.useRef(null),nt=t.useCallback(()=>{y?.(A)},[A,y]),it=t.useCallback(()=>{De(!0),E?.(A)},[A,E]),Xe=t.useCallback(()=>{const Y=!ie;X(Y),!Y&&U.current?(ee({x:U.current.x,y:U.current.y}),be({width:U.current.w,height:U.current.h}),U.current=null):Y&&(U.current={x:_e,y:ve,w:le,h:de}),He("none"),R?.(A,Y)},[A,ie,_e,ve,le,de,R]),qe=t.useCallback(()=>{const Y=!Z;Ie(Y),Y?U.current={x:_e,y:ve,w:le,h:de}:U.current&&(ee({x:U.current.x,y:U.current.y}),be({width:U.current.w,height:U.current.h}),U.current=null),O?.(A,Y)},[A,Z,_e,ve,le,de,O]),st=t.useCallback(()=>{const Y=!Re;Be(Y),H?.(A,Y)},[A,Re,H]),Ne=t.useCallback(()=>{v?.(A)},[A,v]),ot=t.useCallback(()=>{b?b(A):w&&Xe()},[A,w,Xe,b]);t.useEffect(()=>{const Y=me=>{if(!ue.current)return;const ce=me.clientX-ue.current.startX+ue.current.origX,Te=me.clientY-ue.current.startY+ue.current.origY;ee({x:ce,y:Te}),q?.(A,{x:ce,y:Te})},Q=me=>{if(ue.current){if(_){const ce=Xt(me.clientX,me.clientY,window.innerWidth,window.innerHeight,B);ce!=="none"&&(U.current={x:ge.x,y:ge.y,w:le,h:de},He(ce),$?.(A,ce))}ue.current=null}};return document.addEventListener("mousemove",Y),document.addEventListener("mouseup",Q),()=>{document.removeEventListener("mousemove",Y),document.removeEventListener("mouseup",Q)}});const ct=t.useCallback(Y=>{!L||ie||Z||(Y.preventDefault(),te!=="none"&&(U.current&&(ee({x:U.current.x,y:U.current.y}),be({width:U.current.w,height:U.current.h})),He("none")),Ne(),ue.current={startX:Y.clientX,startY:Y.clientY,origX:_e,origY:ve})},[L,ie,Z,te,_e,ve,Ne]);t.useEffect(()=>{const Y=me=>{if(!J.current)return;const ce=me.clientX-J.current.startX,Te=me.clientY-J.current.startY,ke=J.current.handle;let fe=J.current.origW,he=J.current.origH;if(ke.includes("e")&&(fe=J.current.origW+ce),ke.includes("w")&&(fe=J.current.origW-ce),ke.includes("s")&&(he=J.current.origH+Te),ke.includes("n")&&(he=J.current.origH-Te),fe=Math.max(z,M?Math.min(M,fe):fe),he=Math.max(T,I?Math.min(I,he):he),ke.includes("w")){const Ae=re.width-fe;ee(Me=>({...Me,x:Me.x+Ae}))}if(ke.includes("n")){const Ae=re.height-he;ee(Me=>({...Me,y:Me.y+Ae}))}be({width:fe,height:he}),p?.(A,{width:fe,height:he})},Q=()=>{J.current=null};return document.addEventListener("mousemove",Y),document.addEventListener("mouseup",Q),()=>{document.removeEventListener("mousemove",Y),document.removeEventListener("mouseup",Q)}});const at=t.useCallback((Y,Q)=>{!a||ie||Z||te!=="none"||(Q.preventDefault(),Q.stopPropagation(),Ne(),J.current={startX:Q.clientX,startY:Q.clientY,origW:le,origH:de,handle:Y})},[a,ie,Z,te,le,de,Ne]);if(t.useEffect(()=>{if(!Pe)return;const Y=Q=>{Q.key==="Escape"&&Z&&qe()};return document.addEventListener("keydown",Y),()=>document.removeEventListener("keydown",Y)},[Pe,Z,qe]),we==="hidden"||tt)return null;const Ue=te!=="none"?qt(te):null,Ve=ie||Z,rt=Z?{position:"fixed",top:0,left:0,width:"100vw",height:"100vh",zIndex:999999}:ie?{position:"absolute",top:0,left:0,width:"100%",height:"100%",zIndex:k}:Ue?{position:"absolute",...Ue,zIndex:k}:{position:"absolute",top:ve,left:_e,width:le,height:de,zIndex:k},lt=["n","e","s","w","ne","se","sw","nw"],dt={n:"ns-resize",s:"ns-resize",e:"ew-resize",w:"ew-resize",ne:"nesw-resize",sw:"nesw-resize",nw:"nwse-resize",se:"nwse-resize"};return e.jsxs("div",{ref:xe,id:ze,className:`nice-window nice-window--${W} ${Pe?"nice-window--focused":""} ${Re?"nice-window--pinned":""} ${Ve?"nice-window--maximized":""} ${te!=="none"?`nice-window--snapped-${te}`:""} ${ae??""}`,style:{...rt,...ne},onMouseDown:Ne,onFocus:Pe?void 0:Ne,role:"dialog","aria-label":i,tabIndex:-1,"data-nice-focus-scope":"spatial","data-nice-region":i,...oe,children:[e.jsxs("div",{className:"nice-window__titlebar",onMouseDown:ct,onDoubleClick:ot,children:[c&&e.jsx("span",{className:"nice-window__icon",children:c}),e.jsx("span",{className:"nice-window__title",children:i}),e.jsxs("div",{className:"nice-window__actions",children:[se,S&&e.jsx("button",{type:"button",className:`nice-window__action nice-window__action--pin ${Re?"nice-window__action--active":""}`,onClick:st,title:Re?G("window.unpin","Unpin"):G("window.pin","Pin"),children:e.jsx(g.NiceIcon,{name:"paperclip",size:14})}),r&&e.jsx("button",{type:"button",className:"nice-window__action nice-window__action--minimize",onClick:it,title:G("window.minimize","Minimize"),children:e.jsx(g.NiceIcon,{name:"minus",size:14})}),w&&e.jsx("button",{type:"button",className:"nice-window__action nice-window__action--maximize",onClick:Xe,title:ie?G("window.restore","Restore"):G("window.maximize","Maximize"),children:e.jsx(g.NiceIcon,{name:ie?"copy":"window",size:14})}),l&&e.jsx("button",{type:"button",className:"nice-window__action nice-window__action--fullscreen",onClick:qe,title:Z?G("window.exitFullscreen","Exit Full Screen"):G("window.fullscreen","Full Screen"),children:e.jsx(g.NiceIcon,{name:Z?"collapse":"expand",size:14})}),h&&e.jsx("button",{type:"button",className:"nice-window__action nice-window__action--close",onClick:nt,title:G("window.close","Close"),children:e.jsx(g.NiceIcon,{name:"close",size:14})})]})]}),e.jsx("div",{className:"nice-window__body",children:o}),d&&e.jsx("div",{className:"nice-window__footer",children:d}),D&&e.jsx("div",{className:"nice-window__statusbar",children:D}),a&&!Ve&&te==="none"&&e.jsx(e.Fragment,{children:lt.map(Y=>e.jsx("div",{className:`nice-window__resize nice-window__resize--${Y}`,style:{cursor:dt[Y]},onMouseDown:Q=>at(Y,Q)},Y))})]})}),{displayName:"NiceWindow"});exports.NiceActionSheet=mt;exports.NiceBlockUI=Mt;exports.NiceBottomSheet=Ct;exports.NiceBox=pt;exports.NiceCommandPaletteProvider=Ze;exports.NiceContextMenu=It;exports.NiceDrawer=jt;exports.NiceLoadPanel=ht;exports.NiceModal=vt;exports.NiceModalBody=Nt;exports.NiceModalFooter=kt;exports.NiceModalHeader=yt;exports.NicePopover=Et;exports.NicePopover$1=ft;exports.NiceResizable=gt;exports.NiceResponsiveBox=wt;exports.NiceScrollView=bt;exports.NiceTutorial=We;exports.NiceTutorialProvider=et;exports.NiceWindow=At;exports.NiceWindowManager=St;exports.fuzzyMatch=Oe;exports.highlightMatches=Ke;exports.useCommandPalette=Qe;exports.useNiceTutorial=Ht;exports.useRegisterCommands=Tt;
1
+ "use strict";const e=require("react/jsx-runtime"),g=require("@nice2dev/ui-core"),t=require("react"),je=require("react-dom"),ft=[],ht=({visible:n,onClose:i,title:c,items:o=ft,showCancelButton:d=!0,cancelText:m,size:u="md",disabled:x,readOnly:f,loading:N,error:z,className:T,"data-testid":M,style:I})=>{const{t:k}=g.useNiceTranslation();if(!n)return null;const h=x||N||f;return e.jsxs(e.Fragment,{children:[e.jsx("div",{role:"presentation",className:"nice-actionsheet__overlay",onClick:i}),e.jsxs("div",{className:`nice-actionsheet nice-actionsheet--${u} ${x?"nice-actionsheet--disabled":""} ${f?"nice-actionsheet--readonly":""} ${N?"nice-actionsheet--loading":""} ${z?"nice-actionsheet--error":""} ${T||""}`,style:I,"data-testid":M,"aria-disabled":x||void 0,"aria-readonly":f||void 0,"aria-busy":N||void 0,children:[z&&e.jsx("div",{className:"nice-actionsheet__error",role:"alert",children:z}),N&&e.jsx("span",{className:"nice-actionsheet__spinner","aria-hidden":"true",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})}),c&&e.jsx("div",{className:"nice-actionsheet__title",children:c}),e.jsx("div",{className:"nice-actionsheet__items",children:o.map((r,w)=>e.jsxs("button",{className:`nice-actionsheet__item ${r.type==="danger"?"nice-actionsheet__item--danger":""}`,disabled:r.disabled||h,onClick:()=>{h||(r.onClick?.(),i())},children:[r.icon&&e.jsx("span",{className:"nice-actionsheet__icon",children:r.icon}),r.text]},w))}),d&&e.jsx("button",{className:"nice-actionsheet__cancel",onClick:i,children:m||k("cancel","Cancel")})]})]})},pt=({visible:n,onClose:i,targetRef:c,position:o="bottom",title:d,showArrow:m=!0,width:u,children:x,className:f,"data-testid":N,style:z,displayStyle:T})=>{g.useComponentDisplayClass("tooltip",T);const M=t.useRef(null),[I,k]=t.useState({top:0,left:0}),h=t.useCallback(()=>{const r=c.current,w=M.current;if(!r||!w)return;const l=r.getBoundingClientRect(),S=w.getBoundingClientRect();let a=0,L=0;const _=8;switch(o){case"top":a=l.top-S.height-_,L=l.left+(l.width-S.width)/2;break;case"bottom":a=l.bottom+_,L=l.left+(l.width-S.width)/2;break;case"left":a=l.top+(l.height-S.height)/2,L=l.left-S.width-_;break;case"right":a=l.top+(l.height-S.height)/2,L=l.right+_;break}k({top:a+window.scrollY,left:L+window.scrollX})},[c,o]);return t.useEffect(()=>{if(n){requestAnimationFrame(h);const r=w=>{const l=w.target;(l instanceof Element?l:l?.parentElement??null)?.closest('.nice-select__dropdown, [role="listbox"], [role="option"]')||M.current&&!M.current.contains(l)&&c.current&&!c.current.contains(l)&&i()};return document.addEventListener("mousedown",r),()=>document.removeEventListener("mousedown",r)}},[n,h,i,c]),g.useOverlayFocus(M,{open:n,modal:!1,onClose:()=>i()}),n?e.jsxs("div",{ref:M,className:`nice-popover nice-popover--${o} ${f||""}`,style:{...z,position:"absolute",top:I.top,left:I.left,width:u},"data-testid":N,role:"dialog","aria-label":d,children:[m&&e.jsx("div",{className:`nice-popover__arrow nice-popover__arrow--${o}`}),d&&e.jsx("div",{className:"nice-popover__title",children:d}),e.jsx("div",{className:"nice-popover__content",children:x})]}):null},xt=({visible:n,message:i,container:c,showIndicator:o=!0,shading:d=!0,className:m,"data-testid":u,style:x})=>{const{t:f}=g.useNiceTranslation();if(!n)return null;const N=!!c?.current,z=e.jsxs("div",{className:`nice-loadpanel ${m||""}`,style:x,"data-testid":u,children:[d&&e.jsx("div",{className:"nice-loadpanel__shade"}),e.jsxs("div",{className:"nice-loadpanel__box",children:[o&&e.jsx("div",{className:"nice-spinner nice-spinner--md"}),e.jsx("span",{className:"nice-loadpanel__text",children:i||f("loading","Loading...")})]})]});if(N&&c.current){const T=c.current;return T.style.position=T.style.position||"relative",z}return z},wt=({direction:n="row",align:i,justify:c,wrap:o,gap:d,flex:m,children:u,className:x,"data-testid":f,style:N})=>e.jsx("div",{"data-testid":f,className:`nice-box ${x||""}`,style:{display:"flex",flexDirection:n,alignItems:i,justifyContent:c,flexWrap:o?"wrap":void 0,gap:d,flex:m,...N},children:u}),gt=[],bt=({direction:n="row",items:i=gt,gap:c,className:o,"data-testid":d,style:m})=>e.jsx("div",{"data-testid":d,className:`nice-responsivebox ${o||""}`,style:{display:"flex",flexDirection:n,gap:c,...m},children:i.map((u,x)=>e.jsx("div",{style:{flex:u.ratio??1,flexBasis:u.baseSize,flexShrink:u.shrink??1},children:u.children},x))}),_t=({width:n=200,height:i=200,minWidth:c=50,minHeight:o=50,maxWidth:d=1/0,maxHeight:m=1/0,handles:u=["right","bottom","bottomRight"],onResize:x,children:f,className:N,"data-testid":z,style:T})=>{const[M,I]=t.useState({width:n,height:i}),k=t.useRef(null),h=(l,S)=>{S.preventDefault();const a=S.clientX,L=S.clientY,_=M.width,B=M.height,j={n:"top",s:"bottom",e:"right",w:"left",ne:"topRight",se:"bottomRight",sw:"bottomLeft",nw:"topLeft"}[l]??l,F=j==="right"||j==="topRight"||j==="bottomRight",C=j==="left"||j==="topLeft"||j==="bottomLeft",s=j==="bottom"||j==="bottomRight"||j==="bottomLeft",y=j==="top"||j==="topRight"||j==="topLeft",E=O=>{const H=O.clientX-a,v=O.clientY-L;let q=_,p=B;F&&(q=_+H),C&&(q=_-H),s&&(p=B+v),y&&(p=B-v),q=Math.max(c,Math.min(d,q)),p=Math.max(o,Math.min(m,p)),I({width:q,height:p}),x?.({width:q,height:p})},R=()=>{document.removeEventListener("pointermove",E),document.removeEventListener("pointerup",R)};document.addEventListener("pointermove",E),document.addEventListener("pointerup",R)},r=l=>{switch(l){case"top":case"bottom":return"ns-resize";case"left":case"right":return"ew-resize";case"topLeft":case"bottomRight":return"nwse-resize";case"topRight":case"bottomLeft":return"nesw-resize";default:return"default"}},w=l=>{const S={position:"absolute",zIndex:1},a=8;return l==="right"?{...S,top:0,right:-a/2,width:a,height:"100%",cursor:r(l)}:l==="bottom"?{...S,left:0,bottom:-a/2,width:"100%",height:a,cursor:r(l)}:l==="left"?{...S,top:0,left:-a/2,width:a,height:"100%",cursor:r(l)}:l==="top"?{...S,top:-a/2,left:0,width:"100%",height:a,cursor:r(l)}:l==="bottomRight"?{...S,bottom:-a/2,right:-a/2,width:a*2,height:a*2,cursor:r(l)}:l==="bottomLeft"?{...S,bottom:-a/2,left:-a/2,width:a*2,height:a*2,cursor:r(l)}:l==="topRight"?{...S,top:-a/2,right:-a/2,width:a*2,height:a*2,cursor:r(l)}:l==="topLeft"?{...S,top:-a/2,left:-a/2,width:a*2,height:a*2,cursor:r(l)}:S};return e.jsxs("div",{ref:k,"data-testid":z,className:`nice-resizable ${N||""}`,style:{...T,width:M.width,height:M.height,position:"relative",overflow:"hidden"},children:[f,u.map(l=>e.jsx("div",{style:w(l),onPointerDown:S=>h(l,S)},l))]})},vt=({direction:n="vertical",showScrollbar:i="onInteraction",width:c,height:o,onScroll:d,children:m,className:u,"data-testid":x,style:f})=>{const N=n==="horizontal"||n==="both"?"auto":"hidden",z=n==="vertical"||n==="both"?"auto":"hidden",T=i==="never"?"nice-scrollview--hide-sb":i==="always"?"nice-scrollview--show-sb":"";return e.jsx("div",{"data-testid":x,className:`nice-scrollview ${T} ${u||""}`,style:{...f,width:c,height:o,overflowX:N,overflowY:z},onScroll:d,children:m})},yt=[];function Ce(){const n=t.useContext(g.NiceThemeContext);return n?.portalTarget?n.portalTarget:typeof document<"u"?document.body:null}const Nt=({open:n,onClose:i,children:c,title:o,size:d="md",closeOnBackdropClick:m=!0,closeOnEscape:u=!0,disableFocusTrap:x=!1,disableBodyScroll:f=!0,zIndex:N=1e3,className:z,style:T})=>{const M=t.useRef(null);g.useOverlayFocus(M,{open:n,modal:!x,onClose:i,closeOnEscape:u});const I=Ce();t.useEffect(()=>{if(!f&&n){const r=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=r}}},[n,f]);const k=t.useCallback(r=>{m&&r.target===r.currentTarget&&i()},[m,i]);if(!n)return null;const h={sm:"nice-modal--sm",md:"nice-modal--md",lg:"nice-modal--lg",xl:"nice-modal--xl",full:"nice-modal--full"}[d];return je.createPortal(e.jsx("div",{className:"nice-modal__overlay",style:{zIndex:N},onClick:k,role:"presentation",children:e.jsx("div",{ref:M,className:`nice-modal ${h} ${z||""}`,role:"dialog","aria-modal":"true","aria-label":o,style:T,tabIndex:-1,children:c})}),I)},kt=({children:n,showClose:i=!0,onClose:c,className:o})=>{const{t:d}=g.useNiceTranslation();return e.jsxs("div",{className:`nice-modal__header ${o||""}`,children:[e.jsx("div",{className:"nice-modal__title",children:n}),i&&c&&e.jsx("button",{type:"button",className:"nice-modal__close",onClick:c,"aria-label":d("overlays.close","Close"),children:e.jsx(g.NiceIcon,{name:"close",size:20})})]})},jt=({children:n,className:i})=>e.jsx("div",{className:`nice-modal__body ${i||""}`,children:n}),Ct=({children:n,className:i})=>e.jsx("div",{className:`nice-modal__footer ${i||""}`,children:n}),Et=({open:n,onClose:i,children:c,position:o="right",size:d=320,title:m,closeOnBackdropClick:u=!0,closeOnEscape:x=!0,swipeToClose:f=!0,zIndex:N=1e3,className:z,style:T})=>{const M=t.useRef(null),[I,k]=t.useState(!1),[h,r]=t.useState(0);g.useOverlayFocus(M,{open:n,onClose:i,closeOnEscape:x});const w=Ce(),l=t.useCallback(j=>{let F=0;switch(o){case"left":F=Math.min(0,j.deltaX);break;case"right":F=Math.max(0,j.deltaX);break;case"top":F=Math.min(0,j.deltaY);break;case"bottom":F=Math.max(0,j.deltaY);break}r(F)},[o]),S=t.useCallback(j=>{let C=!1;switch(o){case"left":C=j.deltaX<-100;break;case"right":C=j.deltaX>100;break;case"top":C=j.deltaY<-100;break;case"bottom":C=j.deltaY>100;break}C&&(g.triggerHaptic("light"),i()),r(0),k(!1)},[o,i]),{ref:a}=g.usePan({enabled:f&&n,onPanStart:()=>k(!0),onPan:l,onPanEnd:S}),L=t.useCallback(j=>{u&&j.target===j.currentTarget&&i()},[u,i]);if(!n)return null;const _=o==="left"||o==="right",B=_?{width:typeof d=="number"?`${d}px`:d}:{height:typeof d=="number"?`${d}px`:d},V=()=>{if(I)return _?`translateX(${h}px)`:`translateY(${h}px)`};return je.createPortal(e.jsxs(e.Fragment,{children:[e.jsx("div",{role:"presentation",className:`nice-drawer__overlay ${n?"nice-drawer__overlay--visible":""}`,style:{zIndex:N},onClick:L}),e.jsx("div",{ref:j=>{M.current=j,a.current=j},className:`nice-drawer nice-drawer--${o} ${n?"nice-drawer--open":""} ${z||""}`,style:{...B,zIndex:N+1,transform:V(),transition:I?"none":void 0,...T},role:"dialog","aria-modal":"true","aria-label":m,tabIndex:-1,children:c})]}),w)},It=({open:n,onClose:i,children:c,title:o,showHandle:d=!0,snapPoints:m=[.5,.9],initialSnap:u=0,expandable:x=!0,closeOnBackdropClick:f=!0,closeOnEscape:N=!0,hapticFeedback:z=!0,zIndex:T=1e3,className:M,style:I})=>{const k=t.useRef(null),h=t.useRef(null),[r,w]=t.useState(u),[l,S]=t.useState(!1),[a,L]=t.useState(0),_=t.useRef(0);t.useEffect(()=>{n&&(w(u),L(0))},[n,u]),g.useOverlayFocus(k,{open:n,onClose:i,closeOnEscape:N});const B=Ce();t.useEffect(()=>{if(n){const E=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=E}}},[n]);const V=t.useCallback(E=>{const R=E.target.closest(".nice-bottom-sheet__handle"),O=h.current,H=!O||O.scrollTop<=0;!R&&!H||(S(!0),_.current=E.touches[0].clientY)},[]),j=t.useCallback(E=>{if(!l)return;const R=E.touches[0].clientY-_.current;(R>0||r<m.length-1)&&L(R)},[l,r,m.length]),F=t.useCallback(()=>{if(!l)return;const E=window.innerHeight;m[r]*E;const R=-a,O=E*.15;R>O&&x&&r<m.length-1?(w(r+1),z&&g.triggerHaptic("selection")):R<-O&&(r>0?(w(r-1),z&&g.triggerHaptic("selection")):(z&&g.triggerHaptic("light"),i())),S(!1),L(0)},[l,a,r,m,x,z,i]),C=t.useCallback(()=>{f&&i()},[f,i]);if(!n)return null;const s=m[r]*100,y=l?a:0;return je.createPortal(e.jsxs(e.Fragment,{children:[e.jsx("div",{role:"presentation",className:`nice-bottom-sheet__overlay ${n?"nice-bottom-sheet__overlay--visible":""}`,style:{zIndex:T},onClick:C}),e.jsxs("div",{ref:k,className:`nice-bottom-sheet ${n?"nice-bottom-sheet--open":""} ${M||""}`,style:{zIndex:T+1,height:`${s}vh`,transform:`translateY(${Math.max(0,y)}px)`,transition:l?"none":"transform 0.3s ease-out, height 0.3s ease-out",...I},role:"dialog","aria-modal":"true","aria-label":o,tabIndex:-1,onTouchStart:V,onTouchMove:j,onTouchEnd:F,children:[d&&e.jsx("div",{className:"nice-bottom-sheet__handle","aria-hidden":"true"}),o&&e.jsx("div",{className:"nice-bottom-sheet__title",children:o}),e.jsx("div",{ref:h,className:"nice-bottom-sheet__content",children:c})]})]}),B)},Rt=({trigger:n,children:i,placement:c="bottom",triggerMode:o="click",open:d,onOpenChange:m,hoverDelay:u=200,offset:x=8,className:f,showArrow:N=!0})=>{const[z,T]=t.useState(!1),M=t.useRef(null),I=t.useRef(null),k=t.useRef(null),h=Ce(),r=d!==void 0,w=r?d:z,l=t.useCallback(C=>{r||T(C),m?.(C)},[r,m]);g.useClickOutside(I,()=>{o!=="manual"&&w&&l(!1)});const S=o!=="hover";g.useOverlayFocus(I,{open:w&&S,modal:!1,onClose:()=>l(!1)});const a=t.useCallback(()=>{o==="click"&&l(!w)},[o,w,l]),L=t.useCallback(()=>{o==="hover"&&(k.current&&window.clearTimeout(k.current),k.current=window.setTimeout(()=>l(!0),u))},[o,u,l]),_=t.useCallback(()=>{o==="hover"&&(k.current&&window.clearTimeout(k.current),k.current=window.setTimeout(()=>l(!1),u))},[o,u,l]),B=t.useCallback(C=>{const s=C.relatedTarget;!M.current?.contains(s)&&!I.current?.contains(s)&&_()},[_]),V=t.useCallback(C=>{o==="hover"&&w&&C.key==="Escape"&&(C.preventDefault(),C.stopPropagation(),k.current&&window.clearTimeout(k.current),l(!1))},[o,w,l]),[j,F]=t.useState({top:0,left:0});return t.useEffect(()=>{if(!w||!M.current||!I.current)return;const C=M.current.getBoundingClientRect(),s=I.current.getBoundingClientRect(),y=window.innerWidth,E=window.innerHeight;let R=0,O=0;const[H,v="center"]=c.split("-");switch(H){case"top":R=C.top-s.height-x,O=C.left+(C.width-s.width)/2;break;case"bottom":R=C.bottom+x,O=C.left+(C.width-s.width)/2;break;case"left":R=C.top+(C.height-s.height)/2,O=C.left-s.width-x;break;case"right":R=C.top+(C.height-s.height)/2,O=C.right+x;break}H==="top"||H==="bottom"?(v==="start"&&(O=C.left),v==="end"&&(O=C.right-s.width)):(v==="start"&&(R=C.top),v==="end"&&(R=C.bottom-s.height)),O=Math.max(8,Math.min(y-s.width-8,O)),R=Math.max(8,Math.min(E-s.height-8,R)),F({top:R,left:O})},[w,c,x]),e.jsxs(e.Fragment,{children:[e.jsx("div",{ref:M,className:"nice-popover__trigger",onClick:a,onMouseEnter:L,onMouseLeave:_,onFocus:L,onBlur:B,onKeyDown:V,style:{display:"inline-block"},children:n}),w&&je.createPortal(e.jsxs("div",{ref:I,className:`nice-popover nice-popover--${c} ${f||""}`,style:{position:"fixed",top:j.top,left:j.left,zIndex:1100},onMouseEnter:L,onMouseLeave:_,role:S?"dialog":"tooltip",children:[N&&e.jsx("div",{className:"nice-popover__arrow"}),e.jsx("div",{className:"nice-popover__content",children:i})]}),h)]})},Tt=({items:n=yt,children:i,onOpen:c,onClose:o,className:d})=>{const[m,u]=t.useState(!1),[x,f]=t.useState({x:0,y:0}),N=t.useRef(null),z=t.useRef(null),T=Ce();g.useClickOutside(N,()=>{m&&(u(!1),o?.())});const M=t.useCallback(r=>{if(r.preventDefault(),r.clientX===0&&r.clientY===0&&r.target instanceof Element){const w=r.target.getBoundingClientRect();f({x:w.left,y:w.bottom})}else f({x:r.clientX,y:r.clientY});u(!0),c?.()},[c]),I=t.useCallback(()=>{u(!1),o?.()},[o]),k=t.useCallback(r=>{!r.disabled&&r.onClick&&(r.onClick(),I())},[I]);g.useOverlayFocus(N,{open:m,modal:!1,onClose:I}),g.useRovingFocus(N,{orientation:"vertical",wrap:!0,typeahead:!0});const h=r=>e.jsx("ul",{className:"nice-context-menu__list",role:"menu",children:r.map(w=>w.divider?e.jsx("li",{className:"nice-context-menu__divider",role:"separator"},w.key):e.jsx("li",{role:"presentation",children:e.jsxs("button",{type:"button",className:`nice-context-menu__item ${w.disabled?"nice-context-menu__item--disabled":""} ${w.danger?"nice-context-menu__item--danger":""}`,role:"menuitem",disabled:w.disabled,onClick:()=>k(w),children:[w.icon&&e.jsx("span",{className:"nice-context-menu__icon",children:w.icon}),e.jsx("span",{className:"nice-context-menu__label",children:w.label})]})},w.key))});return e.jsxs(e.Fragment,{children:[e.jsx("div",{ref:z,onContextMenu:M,style:{display:"contents"},children:i}),m&&je.createPortal(e.jsx("div",{ref:N,className:`nice-context-menu ${d||""}`,style:{position:"fixed",left:x.x,top:x.y,zIndex:1200},children:h(n)}),T)]})};function Oe(n,i){if(!n)return{score:1,indices:[]};const c=n.toLowerCase(),o=i.toLowerCase();let d=0;const m=[];let u=0,x=-1;for(let f=0;f<o.length&&d<c.length;f++)o[f]===c[d]&&(m.push(f),x===f-1&&(u+=3),(f===0||/[\s\-_/.]/.test(i[f-1]))&&(u+=5),i[f]===n[d]&&(u+=1),u+=1,x=f,d++);return d<c.length?null:(u-=m[0]*.1,{score:u,indices:m})}function Ge(n,i){if(i.length===0)return[n];const c=[];let o=0;const d=new Set(i);for(let m=0;m<n.length;m++)d.has(m)&&(o<m&&c.push(n.slice(o,m)),c.push(t.createElement("mark",{key:`m-${m}`,className:"nice-command-palette__match"},n[m])),o=m+1);return o<n.length&&c.push(n.slice(o)),c}function Mt(n,i){switch(i.type){case"REGISTER":{const c=new Map(n.commands);return c.set(i.command.id,i.command),{...n,commands:c}}case"REGISTER_BATCH":{const c=new Map(n.commands);for(const o of i.commands)c.set(o.id,o);return{...n,commands:c}}case"UNREGISTER":{const c=new Map(n.commands);return c.delete(i.id),{...n,commands:c}}case"OPEN":return{...n,isOpen:!0,query:"",selectedIndex:0};case"CLOSE":return{...n,isOpen:!1,query:"",selectedIndex:0};case"SET_QUERY":return{...n,query:i.query,selectedIndex:0};case"SET_SELECTED":return{...n,selectedIndex:i.index};case"ADD_RECENT":{const c=n.recentIds.filter(o=>o!==i.id);return{...n,recentIds:[i.id,...c].slice(0,i.maxRecent)}}default:return n}}const Qe=t.createContext(null);function Ze(){const n=t.useContext(Qe);if(!n)throw new Error("useCommandPalette must be used within NiceCommandPaletteProvider");return n}const Je=({children:n,commands:i,placeholder:c,maxVisible:o=10,maxRecent:d=5,className:m,emptyText:u,closeOnAction:x=!0,onOpen:f,onClose:N,includeActions:z=!0})=>{const{t:T}=g.useNiceTranslation(),M=g.useNiceActions(),I=T("commandPalette.general","General"),k=Ce(),[h,r]=t.useReducer(Mt,{commands:new Map(i?.map(p=>[p.id,p])??[]),isOpen:!1,query:"",selectedIndex:0,recentIds:[]}),w=t.useRef(null),l=t.useRef(null),[S,a]=t.useState(!1),L=t.useCallback(p=>{r({type:"REGISTER",command:p})},[]),_=t.useCallback(p=>{r({type:"UNREGISTER",id:p})},[]),B=t.useCallback(p=>{r({type:"REGISTER_BATCH",commands:p})},[]),V=t.useCallback(()=>{r({type:"OPEN"}),f?.()},[f]),j=t.useCallback(()=>{r({type:"CLOSE"}),N?.()},[N]),F=t.useCallback(()=>{h.isOpen?j():V()},[h.isOpen,j,V]),C=t.useMemo(()=>{const p=new Map(h.commands);if(z)for(const $ of M){const b=`action:${$.id}`;$.palette===!1||p.has(b)||p.set(b,{id:b,label:$.label,description:$.description,category:$.group,shortcut:typeof $.keyboard=="string"?$.keyboard:$.keyboard?.[0],disabled:$.when?!$.when():!1,action:()=>{g.triggerNiceAction($.id,"keyboard")}})}return p},[h.commands,M,z,h.isOpen]),y=t.useMemo(()=>{const p=Array.from(C.values()).filter(b=>!b.hidden);if(!h.query.trim()){const b=h.recentIds.map(D=>C.get(D)).filter(D=>!!D&&!D.hidden),W=p.filter(D=>!h.recentIds.includes(D.id));return W.sort((D,se)=>D.label.localeCompare(se.label)),[...b,...W].map(D=>({command:D,match:null,isRecent:h.recentIds.includes(D.id)}))}return p.map(b=>{const W=Oe(h.query,b.label),D=b.description?Oe(h.query,b.description):null,se=b.keywords?.map(ne=>Oe(h.query,ne)).filter(Boolean)[0]??null,ae=[W,D,se].filter(Boolean).sort((ne,pe)=>(pe?.score??0)-(ne?.score??0))[0]??null;return{command:b,match:ae,isRecent:!1}}).filter(b=>b.match!==null).sort((b,W)=>(W.match?.score??0)-(b.match?.score??0))},[C,h.query,h.recentIds]).slice(0,o),E=t.useCallback(async p=>{const $=C.get(p);if(!(!$||$.disabled)){a(!0);try{await $.action(),r({type:"ADD_RECENT",id:p,maxRecent:d})}finally{a(!1),x&&j()}}},[C,d,x,j]);g.useIntent("menu",()=>F());const R=t.useRef(null);g.useOverlayFocus(R,{open:h.isOpen,onClose:j,initialFocus:w}),g.useIntent(["navigate","activate"],p=>{const $=y.length;if(p.intent==="activate"){const W=y[h.selectedIndex];return W&&E(W.command.id),!0}if(!$||p.direction!=="up"&&p.direction!=="down")return!1;const b=p.direction==="down"?1:-1;return r({type:"SET_SELECTED",index:(h.selectedIndex+b+$)%$}),!0},{ref:R,enabled:h.isOpen}),g.useInputHints(R,h.isOpen?[{intent:"navigate",label:T("commandPalette.choose","Choose")},{intent:"activate",label:T("commandPalette.run","Run")},{intent:"back",label:T("input.hint.close","Close")}]:[]);const O=t.useCallback(p=>{const $=y.length;if($){if(p.key==="ArrowDown")p.preventDefault(),r({type:"SET_SELECTED",index:(h.selectedIndex+1)%$});else if(p.key==="ArrowUp")p.preventDefault(),r({type:"SET_SELECTED",index:(h.selectedIndex-1+$)%$});else if(p.key==="Enter"){p.preventDefault();const b=y[h.selectedIndex];b&&E(b.command.id)}}},[y,h.selectedIndex,E]);t.useEffect(()=>{if(!l.current)return;l.current.children[h.selectedIndex]?.scrollIntoView?.({block:"nearest"})},[h.selectedIndex]);const H=t.useMemo(()=>({registerCommand:L,unregisterCommand:_,registerCommands:B,open:V,close:j,toggle:F,isOpen:h.isOpen,executeCommand:E}),[L,_,B,V,j,F,h.isOpen,E]),v=t.useMemo(()=>{const p=new Map;for(const $ of y){const b=$.command.category??I;p.has(b)||p.set(b,[]),p.get(b).push($)}return p},[y,I]);let q=0;return e.jsxs(Qe.Provider,{value:H,children:[n,h.isOpen&&je.createPortal(e.jsx("div",{className:`nice-command-palette__overlay ${m??""}`,role:"presentation",onClick:p=>{p.stopPropagation(),p.target===p.currentTarget&&j()},children:e.jsxs("div",{ref:R,className:"nice-command-palette",role:"dialog","aria-label":T("commandPalette.title","Command palette"),"aria-modal":"true",children:[e.jsx("div",{className:"nice-command-palette__input-wrapper",children:e.jsx("input",{ref:w,className:"nice-command-palette__input",type:"text",placeholder:c??T("commandPalette.placeholder","Type a command..."),value:h.query,onChange:p=>r({type:"SET_QUERY",query:p.target.value}),onKeyDown:O,"aria-label":T("commandPalette.search","Search commands"),"aria-autocomplete":"list","aria-controls":"nice-command-palette-list","aria-activedescendant":y[h.selectedIndex]?`nice-cmd-${y[h.selectedIndex].command.id}`:void 0})}),e.jsxs("div",{ref:l,id:"nice-command-palette-list",className:"nice-command-palette__list",role:"listbox",children:[y.length===0&&e.jsx("div",{className:"nice-command-palette__empty",children:u??T("commandPalette.empty","No commands found")}),Array.from(v.entries()).map(([p,$])=>e.jsxs("div",{className:"nice-command-palette__group",children:[e.jsx("div",{className:"nice-command-palette__category",children:p}),$.map(b=>{const W=q++,D=W===h.selectedIndex;return e.jsxs("div",{id:`nice-cmd-${b.command.id}`,className:`nice-command-palette__item ${D?"nice-command-palette__item--selected":""} ${b.command.disabled?"nice-command-palette__item--disabled":""}`,role:"option","aria-selected":D,"aria-disabled":b.command.disabled,onClick:()=>!b.command.disabled&&E(b.command.id),onMouseEnter:()=>r({type:"SET_SELECTED",index:W}),children:[b.command.icon&&e.jsx("span",{className:"nice-command-palette__icon",children:b.command.icon}),e.jsxs("div",{className:"nice-command-palette__label-group",children:[e.jsx("span",{className:"nice-command-palette__label",children:b.match&&h.query?Ge(b.command.label,b.match.indices):b.command.label}),b.command.description&&e.jsx("span",{className:"nice-command-palette__description",children:b.command.description})]}),b.command.shortcut&&e.jsx("kbd",{className:"nice-command-palette__shortcut",children:b.command.shortcut}),b.isRecent&&e.jsx("span",{className:"nice-command-palette__recent-badge",children:T("commandPalette.recent","Recent")})]},b.command.id)})]},p))]}),S&&e.jsx("div",{className:"nice-command-palette__executing",children:T("commandPalette.executing","Executing...")})]})}),k)]})};process.env.NODE_ENV!=="production"&&(Je.displayName="NiceCommandPaletteProvider");function St(n){const{registerCommands:i,unregisterCommand:c}=Ze();t.useEffect(()=>(i(n),()=>{for(const o of n)c(o.id)}),[])}const zt=Object.assign(t.forwardRef(({blocked:n,message:i,spinner:c,blur:o,children:d,className:m,"data-testid":u,style:x,id:f},N)=>{const z=g.useControlId(f);return e.jsxs("div",{ref:N,id:z,className:`nice-block-ui ${m||""}`,style:{position:"relative",...x},"data-testid":u,children:[d,n&&e.jsx("div",{className:`nice-block-ui__overlay${o?" nice-block-ui__overlay--blur":""}`,"aria-busy":"true",role:"alert",children:(c||i)&&e.jsxs("div",{className:"nice-block-ui__content",children:[c&&e.jsx("div",{className:"nice-block-ui__spinner","aria-hidden":"true"}),i&&e.jsx("div",{className:"nice-block-ui__message",children:i})]})})]})}),{displayName:"NiceBlockUI"}),$t=Object.assign(t.forwardRef(({windows:n,children:i,onChange:c,onClose:o,onFocus:d,showTaskbar:m=!0,size:u="md",className:x,style:f,id:N,...z},T)=>{const M=g.useControlId(N),{t:I}=g.useNiceTranslation(),[k,h]=t.useState(null),r=t.useRef(null),w=t.useRef(null);g.useRovingFocus(w,{orientation:"horizontal",itemSelector:".nice-wm__taskbar-btn"});const l=t.useRef(null),S=t.useCallback(s=>{const y=[...r.current?.querySelectorAll("[data-wm-key]")??[]].find(E=>E.getAttribute("data-wm-key")===s);return y?((g.focusCandidates(y)[0]??y).focus(),!0):!1},[]);t.useEffect(()=>{const s=l.current;s&&S(s)&&(l.current=null)});const a=t.useMemo(()=>n??[],[n]),L=Math.max(1,...a.map(s=>s.zIndex??1)),_=t.useCallback((s,y)=>{const E=a.map(R=>R.key===s?{...R,...y}:R);c?.(E)},[a,c]),B=t.useCallback(s=>{_(s,{zIndex:L+1}),d?.(s)},[_,L,d]),V=t.useCallback(s=>{o?.(s),c?.(a.filter(y=>y.key!==s))},[a,c,o]),j=t.useCallback(s=>{const y=a.find(E=>E.key===s);y&&_(s,{minimized:!y.minimized,maximized:!1})},[a,_]),F=t.useCallback(s=>{const y=a.find(E=>E.key===s);y&&_(s,{maximized:!y.maximized,minimized:!1})},[a,_]);t.useEffect(()=>{if(!k)return;const s=E=>{const R=a.find(O=>O.key===k.key);if(R)if(k.mode==="move")_(k.key,{x:E.clientX-k.offsetX,y:E.clientY-k.offsetY});else{const H=r.current?.getBoundingClientRect(),v=H?.left??0,q=H?.top??0;_(k.key,{width:Math.max(200,E.clientX-v-R.x),height:Math.max(100,E.clientY-q-R.y)})}},y=()=>h(null);return document.addEventListener("mousemove",s),document.addEventListener("mouseup",y),()=>{document.removeEventListener("mousemove",s),document.removeEventListener("mouseup",y)}},[k,a,_]);const C=t.useCallback((s,y,E)=>{y.preventDefault();const R=a.find(O=>O.key===s);R&&(B(s),h({key:s,offsetX:E==="move"?y.clientX-R.x:0,offsetY:E==="move"?y.clientY-R.y:0,mode:E}))},[a,B]);return e.jsxs("div",{ref:s=>{r.current=s,typeof T=="function"?T(s):T&&(T.current=s)},id:M,className:`nice-wm nice-wm--${u} ${x??""}`,style:{...f,position:"relative",overflow:"hidden"},...z,children:[a.map(s=>{if(s.minimized)return null;const y=s.maximized,E=y?{position:"absolute",top:0,left:0,width:"100%",height:"100%",zIndex:s.zIndex??1}:{position:"absolute",top:s.y,left:s.x,width:s.width,height:s.height,zIndex:s.zIndex??1};return e.jsxs("div",{className:`nice-wm__window ${y?"nice-wm__window--maximized":""}`,style:E,onMouseDown:()=>B(s.key),onFocus:()=>{(s.zIndex??1)<L&&B(s.key)},role:"dialog","aria-label":s.title,tabIndex:-1,"data-wm-key":s.key,"data-nice-focus-scope":"spatial","data-nice-region":s.title,children:[e.jsxs("div",{className:"nice-wm__titlebar",onMouseDown:R=>!y&&C(s.key,R,"move"),children:[s.icon&&e.jsx("span",{className:"nice-wm__icon",children:s.icon}),e.jsx("span",{className:"nice-wm__title",children:s.title}),e.jsxs("div",{className:"nice-wm__controls",children:[(s.minimizable??!0)&&e.jsx("button",{type:"button",className:"nice-wm__ctrl-btn nice-wm__ctrl-btn--min",onClick:()=>j(s.key),title:I("wm.minimize","Minimize"),children:e.jsx(g.NiceIcon,{name:"minus",size:14})}),(s.maximizable??!0)&&e.jsx("button",{type:"button",className:"nice-wm__ctrl-btn nice-wm__ctrl-btn--max",onClick:()=>F(s.key),title:I("wm.maximize","Maximize"),children:e.jsx(g.NiceIcon,{name:y?"copy":"window",size:14})}),(s.closable??!0)&&e.jsx("button",{type:"button",className:"nice-wm__ctrl-btn nice-wm__ctrl-btn--close",onClick:()=>V(s.key),title:I("wm.close","Close"),children:e.jsx(g.NiceIcon,{name:"close",size:14})})]})]}),e.jsx("div",{className:"nice-wm__body",children:s.content}),(s.resizable??!0)&&!y&&e.jsx("div",{className:"nice-wm__resize-handle",onMouseDown:R=>C(s.key,R,"resize")})]},s.key)}),n===void 0&&i,m&&e.jsx("div",{ref:w,className:"nice-wm__taskbar",role:"toolbar","aria-label":I("wm.taskbar","Taskbar"),"data-nice-region":I("wm.taskbar","Taskbar"),children:a.map(s=>e.jsxs("button",{type:"button",className:`nice-wm__taskbar-btn ${s.minimized?"nice-wm__taskbar-btn--minimized":""}`,onClick:()=>{s.minimized&&j(s.key),B(s.key),(s.minimized||!S(s.key))&&(l.current=s.key)},children:[s.icon&&e.jsx("span",{className:"nice-wm__taskbar-icon",children:s.icon}),e.jsx("span",{className:"nice-wm__taskbar-label",children:s.title})]},s.key))})]})}),{displayName:"NiceWindowManager"});function Pt(n,i){const c=document.querySelector(n);if(!c)return null;const o=c.getBoundingClientRect();return{top:o.top-i+window.scrollY,left:o.left-i+window.scrollX,width:o.width+i*2,height:o.height+i*2}}function Lt(n,i,c,o){const m={w:window.innerWidth,h:window.innerHeight+window.scrollY},u={top:{top:n.top-c-12,left:n.left+n.width/2-i/2},bottom:{top:n.top+n.height+12,left:n.left+n.width/2-i/2},left:{top:n.top+n.height/2-c/2,left:n.left-i-12},right:{top:n.top+n.height/2-c/2,left:n.left+n.width+12}};if(o&&o!=="auto")return{...u[o],actualPlacement:o};for(const x of["bottom","top","right","left"]){const f=u[x];if(f.top>=0&&f.left>=0&&f.top+c<=m.h&&f.left+i<=m.w)return{...f,actualPlacement:x}}return{...u.bottom,actualPlacement:"bottom"}}function Ot(){return e.jsx(g.NiceIcon,{name:"close",size:16})}function Yt(){return e.jsx(g.NiceIcon,{name:"chevron-left",size:16})}function Dt(){return e.jsx(g.NiceIcon,{name:"chevron-right",size:16})}function Ft(){return e.jsx(g.NiceIcon,{name:"skip-forward",size:16})}function Bt(){return e.jsx(g.NiceIcon,{name:"play",size:16})}function Ht(){return e.jsx(g.NiceIcon,{name:"pause",size:16})}function Le(n,i,c){return c==="text"?e.jsx("span",{className:"nice-tutorial__btn-label",children:i}):c==="icon-text"?e.jsxs(e.Fragment,{children:[n,e.jsx("span",{className:"nice-tutorial__btn-label",children:i})]}):n}const Xt=[],We=({steps:n=Xt,active:i,onFinish:c,onSkip:o,onStepChange:d,closeOnEscape:m=!0,closeOnOverlayClick:u=!1,showProgress:x=!0,showSkipButton:f=!0,labels:N,animationDuration:z=300,overlayOpacity:T=.6,zIndex:M=1e4,buttonsPlacement:I="floating-bottom",buttonsDisplay:k="icon",showAutoplay:h=!0,autoplayInterval:r=5e3,autoplaySpeedRange:w={min:2e3,max:15e3},onAutoplayChange:l})=>{const{t:S}=g.useNiceTranslation(),[a,L]=t.useState(0),[_,B]=t.useState(null),[V,j]=t.useState({w:340,h:200}),[F,C]=t.useState(!0),[s,y]=t.useState(!1),[E,R]=t.useState(r),O=t.useRef(null),H=t.useRef(-1),v=n[a],q=a===n.length-1,p=a===0,$=N?.next??"Next",b=N?.back??"Back",W=N?.finish??"Finish",D=N?.skip??"Skip",se=N?.stepOf??"of",ae=N?.play??"Play",ne=N?.pause??"Pause",pe=N?.speed??"Speed",Se=N?.close??"Close";t.useEffect(()=>{i&&(L(0),y(!1),R(r))},[i,r]),t.useEffect(()=>{if(O.current){const P=O.current.getBoundingClientRect();j({w:P.width,h:P.height})}},[a,i]),t.useEffect(()=>{if(!i||!v)return;const P=v.highlightPadding??0,X=()=>{const K=Pt(v.target,P);B(K)};if(X(),v.scrollIntoView!==!1){document.querySelector(v.target)?.scrollIntoView({behavior:"smooth",block:"center"});const Ie=setTimeout(X,350);return()=>clearTimeout(Ie)}},[i,v,a]),t.useEffect(()=>{!i||!v||H.current!==a&&(H.current>=0&&H.current<n.length&&n[H.current]?.onLeave?.(),v.onEnter?.(),H.current=a)},[i,v,a,n]);const oe=t.useCallback(()=>{if(q)v?.onLeave?.(),c?.();else{const P=a+1;L(P),d?.(P)}},[a,q,c,d,v]),xe=t.useCallback(()=>{if(!p){const P=a-1;L(P),d?.(P)}},[a,p,d]),ze=t.useCallback(P=>{P!==a&&P>=0&&P<n.length&&(L(P),d?.(P))},[a,n.length,d]);t.useEffect(()=>{if(!i||!v?.advanceOn)return;const P=document.querySelector(v.target);if(!P)return;const X=()=>oe();return P.addEventListener(v.advanceOn.event,X),()=>P.removeEventListener(v.advanceOn.event,X)},[i,v,a,oe]);const we=t.useRef(null),G=!!(i&&v);g.useOverlayFocus(we,{open:G,modal:!(v?.waitForAction||v?.advanceOn),onClose:()=>o?.(),closeOnEscape:m,closeHint:D}),t.useEffect(()=>{const P=we.current;if(!G||!P)return;const X=K=>{if(!(K.defaultPrevented||K.target instanceof HTMLInputElement)){if(K.key==="ArrowRight")oe();else if(K.key==="ArrowLeft")xe();else if(K.key==="Home"||K.key==="End")ze(K.key==="Home"?0:n.length-1);else return;K.preventDefault()}};return P.addEventListener("keydown",X),()=>P.removeEventListener("keydown",X)},[G,oe,xe,ze,n.length]);const ye=g.useInputEngine(),A=G?v?.title:void 0;t.useEffect(()=>{A&&a>0&&ye?.announce(A)},[ye,A,a]);const Ee=t.useId(),$e=`${Ee}-content`;g.useIntent(["sectionPrev","sectionNext"],P=>{if(P.intent==="sectionNext"){if(v?.waitForAction)return!1;oe()}else xe()},{ref:we,enabled:G}),g.useInputHints(we,G?[...p?[]:[{intent:"sectionPrev",label:b}],...v?.waitForAction?[]:[{intent:"sectionNext",label:q?W:$}]]:[]),t.useEffect(()=>{C(!0);const P=setTimeout(()=>C(!1),z);return()=>clearTimeout(P)},[a,z]),t.useEffect(()=>{if(!i||!s)return;const P=setInterval(()=>{L(X=>{if(X>=n.length-1)return y(!1),l?.(!1),n[X]?.onLeave?.(),c?.(),X;const K=X+1;return d?.(K),K})},Math.max(500,E));return()=>clearInterval(P)},[i,s,E,n,l,c,d]);const ge=t.useCallback(()=>{y(P=>{const X=!P;return l?.(X),X})},[l]),ee=t.useMemo(()=>_?Lt(_,V.w,V.h,v?.placement):{top:typeof window<"u"?window.innerHeight/2:0,left:typeof window<"u"?window.innerWidth/2:0,actualPlacement:"bottom"},[_,V,v?.placement]),re=n.length===0?0:(a+1)/n.length*100,be=t.useCallback(P=>{const X=h&&n.length>1,K=f&&!q&&e.jsx("button",{type:"button",className:`nice-tutorial__btn nice-tutorial__btn--skip nice-tutorial__btn--${k}`,onClick:o,"aria-label":D,title:D,children:Le(e.jsx(Ft,{}),D,k)}),Ie=!p&&e.jsx("button",{type:"button",className:`nice-tutorial__btn nice-tutorial__btn--back nice-tutorial__btn--${k}`,onClick:xe,"aria-label":b,title:b,children:Le(e.jsx(Yt,{}),b,k)}),Fe=!v?.waitForAction&&e.jsx("button",{type:"button",className:`nice-tutorial__btn nice-tutorial__btn--next nice-tutorial__btn--${k}`,onClick:oe,"aria-label":q?W:$,title:q?W:$,children:Le(e.jsx(Dt,{}),q?W:$,k)}),Be=X&&e.jsx("button",{type:"button",className:["nice-tutorial__btn","nice-tutorial__btn--play",`nice-tutorial__btn--${k}`,s?"nice-tutorial__btn--active":""].filter(Boolean).join(" "),onClick:ge,"aria-label":s?ne:ae,title:s?ne:ae,"aria-pressed":s,children:Le(s?e.jsx(Ht,{}):e.jsx(Bt,{}),s?ne:ae,k)});return e.jsxs("div",{className:["nice-tutorial__controls",P?"nice-tutorial__controls--inline":"nice-tutorial__controls--floating-bottom"].join(" "),style:P?void 0:{zIndex:M+2},role:"group","aria-label":S("tutorial.tutorialControls","Tutorial controls"),children:[K,Ie,x&&e.jsxs("span",{className:"nice-tutorial__step-label","aria-live":"polite",children:[a+1," ",se," ",n.length]}),Fe,X&&e.jsx("div",{className:"nice-tutorial__progress-bar",role:"progressbar","aria-valuenow":Math.round(re),"aria-valuemin":0,"aria-valuemax":100,"aria-label":`${a+1} ${se} ${n.length}`,children:e.jsx("div",{className:"nice-tutorial__progress-bar-fill",style:{width:`${re}%`}})}),Be,X&&e.jsxs("label",{className:"nice-tutorial__speed",children:[e.jsx("input",{type:"range",className:"nice-tutorial__speed-slider",min:w.min,max:w.max,step:500,value:w.min+w.max-E,onChange:te=>R(w.min+w.max-Number(te.target.value)),"aria-label":pe}),e.jsxs("span",{className:"nice-tutorial__speed-value",children:[(E/1e3).toFixed(1),"s"]})]})]})},[h,f,x,k,p,q,o,D,b,$,W,ae,ne,pe,se,xe,oe,v,s,ge,a,n.length,re,E,w,M,S]);if(!i||!v)return null;const Ye=typeof document<"u"?Math.max(document.documentElement.scrollWidth,window.innerWidth):0,De=typeof document<"u"?Math.max(document.documentElement.scrollHeight,window.innerHeight):0;return e.jsxs("div",{ref:we,className:"nice-tutorial",style:{zIndex:M},"aria-modal":v.waitForAction||v.advanceOn?void 0:!0,role:"dialog","aria-label":v.title?void 0:S("tutorial.tutorial","Tutorial"),"aria-labelledby":v.title?Ee:void 0,"aria-describedby":v.content?$e:void 0,children:[e.jsxs("svg",{className:"nice-tutorial__overlay",style:{position:"absolute",top:0,left:0,width:Ye,height:De,pointerEvents:"auto"},onClick:u?o:void 0,children:[e.jsx("defs",{children:e.jsxs("mask",{id:"nice-tutorial-mask",children:[e.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:"white"}),_&&e.jsx("rect",{x:_.left,y:_.top,width:_.width,height:_.height,rx:"4",fill:"black",className:F?"nice-tutorial__spotlight--entering":""})]})}),e.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`rgba(0,0,0,${T})`,mask:"url(#nice-tutorial-mask)"})]}),_&&e.jsx("div",{className:`nice-tutorial__highlight ${F?"nice-tutorial__highlight--entering":""}`,style:{position:"absolute",top:_.top,left:_.left,width:_.width,height:_.height,transition:`all ${z}ms ease`}}),v.disableInteraction&&_&&e.jsx("div",{className:"nice-tutorial__blocker",style:{position:"absolute",top:_.top,left:_.left,width:_.width,height:_.height}}),e.jsxs("div",{ref:O,className:`nice-tutorial__tooltip nice-tutorial__tooltip--${ee.actualPlacement} ${F?"nice-tutorial__tooltip--entering":""}`,style:{position:"absolute",top:ee.top,left:ee.left,transition:`all ${z}ms ease`,maxWidth:380,zIndex:M+1},children:[v.showArrow!==!1&&e.jsx("div",{className:`nice-tutorial__arrow nice-tutorial__arrow--${ee.actualPlacement}`}),e.jsxs("div",{className:"nice-tutorial__header",children:[e.jsx("h4",{id:Ee,className:"nice-tutorial__title",children:v.title}),f&&e.jsx("button",{type:"button",className:"nice-tutorial__close",onClick:o,"aria-label":Se,title:Se,children:e.jsx(Ot,{})})]}),e.jsx("div",{id:$e,className:"nice-tutorial__content",dangerouslySetInnerHTML:{__html:g.sanitizeHtml(v.content)}}),I==="inline"&&be(!0)]}),I==="floating-bottom"&&be(!1)]})};process.env.NODE_ENV!=="production"&&(We.displayName="NiceTutorial");const et=t.createContext({startTutorial:()=>{},stopTutorial:()=>{},isActive:!1,currentStep:0,nextStep:()=>{},prevStep:()=>{},goToStep:()=>{}});function qt(){return t.useContext(et)}const tt=({children:n})=>{const[i,c]=t.useState([]),[o,d]=t.useState(!1),[m,u]=t.useState(0),x=t.useCallback(I=>{c(I),u(0),d(!0)},[]),f=t.useCallback(()=>{d(!1),u(0),c([])},[]),N=t.useCallback(()=>{u(I=>Math.min(I+1,i.length-1))},[i.length]),z=t.useCallback(()=>{u(I=>Math.max(I-1,0))},[]),T=t.useCallback(I=>{u(Math.max(0,Math.min(I,i.length-1)))},[i.length]),M={startTutorial:x,stopTutorial:f,isActive:o,currentStep:m,nextStep:N,prevStep:z,goToStep:T};return e.jsxs(et.Provider,{value:M,children:[n,o&&i.length>0&&e.jsx(We,{steps:i,active:o,onFinish:f,onSkip:f,onStepChange:u})]})};process.env.NODE_ENV!=="production"&&(tt.displayName="NiceTutorialProvider");function At(n,i,c,o,d){const m=n<=d,u=n+d>=c,x=i<=d,f=i+d>=o;return x&&m?"top-left":x&&u?"top-right":f&&m?"bottom-left":f&&u?"bottom-right":m?"left":u?"right":x?"top":f?"bottom":"none"}function Wt(n){switch(n){case"left":return{left:0,top:0,width:"50%",height:"100%"};case"right":return{left:"50%",top:0,width:"50%",height:"100%"};case"top":return{left:0,top:0,width:"100%",height:"50%"};case"bottom":return{left:0,top:"50%",width:"100%",height:"50%"};case"top-left":return{left:0,top:0,width:"50%",height:"50%"};case"top-right":return{left:"50%",top:0,width:"50%",height:"50%"};case"bottom-left":return{left:0,top:"50%",width:"50%",height:"50%"};case"bottom-right":return{left:"50%",top:"50%",width:"50%",height:"50%"};default:return null}}const Ut=Object.assign(t.forwardRef(({windowKey:n,title:i,icon:c,children:o,footer:d,x:m,y:u,defaultPosition:x,width:f=480,height:N=360,minWidth:z=200,minHeight:T=120,maxWidth:M,maxHeight:I,zIndex:k=1,closable:h=!0,minimizable:r=!0,maximizable:w=!0,fullscreenable:l=!1,pinnable:S=!1,resizable:a=!0,draggable:L=!0,snappable:_=!0,snapThreshold:B=20,minimized:V,maximized:j,fullscreen:F,pinned:C,focused:s,onClose:y,onMinimize:E,onMaximize:R,onFullscreen:O,onPin:H,onFocus:v,onMove:q,onResize:p,onSnap:$,onTitleBarDoubleClick:b,size:W="md",statusBar:D,titleBarActions:se,className:ae,style:ne,id:pe,accessMode:Se,...oe},xe)=>{const ze=g.useControlId(pe),we=g.useNiceAccessMode(Se,pe),{t:G}=g.useNiceTranslation(),ye=t.useRef(null);ye.current==null&&(ye.current=`nice-window-${Math.random().toString(36).slice(2,10)}`);const A=n??ye.current,Ee=m??x?.x??100,$e=u??x?.y??100,[ge,ee]=t.useState({x:Ee,y:$e}),[re,be]=t.useState({width:f,height:N}),[Ye,De]=t.useState(!1),[P,X]=t.useState(!1),[K,Ie]=t.useState(!1),[Fe,Be]=t.useState(!1),[te,He]=t.useState("none"),nt=V??Ye,ie=j??P,Z=F??K,Re=C??Fe,Pe=s??!0,_e=ge.x,ve=ge.y,le=re.width,de=re.height,ue=t.useRef(null),J=t.useRef(null),U=t.useRef(null),[it,Ue]=t.useState(!1),st=t.useCallback(()=>{y?.(A)},[A,y]),ot=t.useCallback(()=>{De(!0),E?.(A)},[A,E]),Xe=t.useCallback(()=>{const Y=!ie;X(Y),!Y&&U.current?(ee({x:U.current.x,y:U.current.y}),be({width:U.current.w,height:U.current.h}),U.current=null):Y&&(U.current={x:_e,y:ve,w:le,h:de}),He("none"),R?.(A,Y)},[A,ie,_e,ve,le,de,R]),qe=t.useCallback(()=>{const Y=!Z;Ie(Y),Y?U.current={x:_e,y:ve,w:le,h:de}:U.current&&(ee({x:U.current.x,y:U.current.y}),be({width:U.current.w,height:U.current.h}),U.current=null),O?.(A,Y)},[A,Z,_e,ve,le,de,O]),ct=t.useCallback(()=>{const Y=!Re;Be(Y),H?.(A,Y)},[A,Re,H]),Ne=t.useCallback(()=>{v?.(A)},[A,v]),at=t.useCallback(()=>{b?b(A):w&&Xe()},[A,w,Xe,b]);t.useEffect(()=>{const Y=me=>{if(!ue.current)return;const ce=me.clientX-ue.current.startX+ue.current.origX,Te=me.clientY-ue.current.startY+ue.current.origY;ee({x:ce,y:Te}),q?.(A,{x:ce,y:Te})},Q=me=>{if(ue.current){if(_){const ce=At(me.clientX,me.clientY,window.innerWidth,window.innerHeight,B);ce!=="none"&&(U.current={x:ge.x,y:ge.y,w:le,h:de},He(ce),$?.(A,ce))}ue.current=null,Ue(!1)}};return document.addEventListener("mousemove",Y),document.addEventListener("mouseup",Q),()=>{document.removeEventListener("mousemove",Y),document.removeEventListener("mouseup",Q)}});const rt=t.useCallback(Y=>{!L||ie||Z||(Y.preventDefault(),te!=="none"&&(U.current&&(ee({x:U.current.x,y:U.current.y}),be({width:U.current.w,height:U.current.h})),He("none")),Ne(),ue.current={startX:Y.clientX,startY:Y.clientY,origX:_e,origY:ve},Ue(!0))},[L,ie,Z,te,_e,ve,Ne]);t.useEffect(()=>{const Y=me=>{if(!J.current)return;const ce=me.clientX-J.current.startX,Te=me.clientY-J.current.startY,ke=J.current.handle;let fe=J.current.origW,he=J.current.origH;if(ke.includes("e")&&(fe=J.current.origW+ce),ke.includes("w")&&(fe=J.current.origW-ce),ke.includes("s")&&(he=J.current.origH+Te),ke.includes("n")&&(he=J.current.origH-Te),fe=Math.max(z,M?Math.min(M,fe):fe),he=Math.max(T,I?Math.min(I,he):he),ke.includes("w")){const Ae=re.width-fe;ee(Me=>({...Me,x:Me.x+Ae}))}if(ke.includes("n")){const Ae=re.height-he;ee(Me=>({...Me,y:Me.y+Ae}))}be({width:fe,height:he}),p?.(A,{width:fe,height:he})},Q=()=>{J.current=null};return document.addEventListener("mousemove",Y),document.addEventListener("mouseup",Q),()=>{document.removeEventListener("mousemove",Y),document.removeEventListener("mouseup",Q)}});const lt=t.useCallback((Y,Q)=>{!a||ie||Z||te!=="none"||(Q.preventDefault(),Q.stopPropagation(),Ne(),J.current={startX:Q.clientX,startY:Q.clientY,origW:le,origH:de,handle:Y})},[a,ie,Z,te,le,de,Ne]);if(t.useEffect(()=>{if(!Pe)return;const Y=Q=>{Q.key==="Escape"&&Z&&qe()};return document.addEventListener("keydown",Y),()=>document.removeEventListener("keydown",Y)},[Pe,Z,qe]),we==="hidden"||nt)return null;const Ve=te!=="none"?Wt(te):null,Ke=ie||Z,dt=Z?{position:"fixed",top:0,left:0,width:"100vw",height:"100vh",zIndex:999999}:ie?{position:"absolute",top:0,left:0,width:"100%",height:"100%",zIndex:k}:Ve?{position:"absolute",...Ve,zIndex:k}:{position:"absolute",top:ve,left:_e,width:le,height:de,zIndex:k},ut=["n","e","s","w","ne","se","sw","nw"],mt={n:"ns-resize",s:"ns-resize",e:"ew-resize",w:"ew-resize",ne:"nesw-resize",sw:"nesw-resize",nw:"nwse-resize",se:"nwse-resize"};return e.jsxs("div",{ref:xe,id:ze,className:`nice-window nice-window--${W} ${Pe?"nice-window--focused":""} ${Re?"nice-window--pinned":""} ${Ke?"nice-window--maximized":""} ${it?"nice-window--dragging":""} ${te!=="none"?`nice-window--snapped-${te}`:""} ${ae??""}`,style:{...dt,...ne},onMouseDown:Ne,onFocus:Pe?void 0:Ne,role:"dialog","aria-label":i,tabIndex:-1,"data-nice-focus-scope":"spatial","data-nice-region":i,...oe,children:[e.jsxs("div",{className:"nice-window__titlebar",onMouseDown:rt,onDoubleClick:at,children:[c&&e.jsx("span",{className:"nice-window__icon",children:c}),e.jsx("span",{className:"nice-window__title",children:i}),e.jsxs("div",{className:"nice-window__actions",children:[se,S&&e.jsx("button",{type:"button",className:`nice-window__action nice-window__action--pin ${Re?"nice-window__action--active":""}`,onClick:ct,title:Re?G("window.unpin","Unpin"):G("window.pin","Pin"),children:e.jsx(g.NiceIcon,{name:"paperclip",size:14})}),r&&e.jsx("button",{type:"button",className:"nice-window__action nice-window__action--minimize",onClick:ot,title:G("window.minimize","Minimize"),children:e.jsx(g.NiceIcon,{name:"minus",size:14})}),w&&e.jsx("button",{type:"button",className:"nice-window__action nice-window__action--maximize",onClick:Xe,title:ie?G("window.restore","Restore"):G("window.maximize","Maximize"),children:e.jsx(g.NiceIcon,{name:ie?"copy":"window",size:14})}),l&&e.jsx("button",{type:"button",className:"nice-window__action nice-window__action--fullscreen",onClick:qe,title:Z?G("window.exitFullscreen","Exit Full Screen"):G("window.fullscreen","Full Screen"),children:e.jsx(g.NiceIcon,{name:Z?"collapse":"expand",size:14})}),h&&e.jsx("button",{type:"button",className:"nice-window__action nice-window__action--close",onClick:st,title:G("window.close","Close"),children:e.jsx(g.NiceIcon,{name:"close",size:14})})]})]}),e.jsx("div",{className:"nice-window__body",children:o}),d&&e.jsx("div",{className:"nice-window__footer",children:d}),D&&e.jsx("div",{className:"nice-window__statusbar",children:D}),a&&!Ke&&te==="none"&&e.jsx(e.Fragment,{children:ut.map(Y=>e.jsx("div",{className:`nice-window__resize nice-window__resize--${Y}`,style:{cursor:mt[Y]},onMouseDown:Q=>lt(Y,Q)},Y))})]})}),{displayName:"NiceWindow"});exports.NiceActionSheet=ht;exports.NiceBlockUI=zt;exports.NiceBottomSheet=It;exports.NiceBox=wt;exports.NiceCommandPaletteProvider=Je;exports.NiceContextMenu=Tt;exports.NiceDrawer=Et;exports.NiceLoadPanel=xt;exports.NiceModal=Nt;exports.NiceModalBody=jt;exports.NiceModalFooter=Ct;exports.NiceModalHeader=kt;exports.NicePopover=Rt;exports.NicePopover$1=pt;exports.NiceResizable=_t;exports.NiceResponsiveBox=bt;exports.NiceScrollView=vt;exports.NiceTutorial=We;exports.NiceTutorialProvider=tt;exports.NiceWindow=Ut;exports.NiceWindowManager=$t;exports.fuzzyMatch=Oe;exports.highlightMatches=Ge;exports.useCommandPalette=Ze;exports.useNiceTutorial=qt;exports.useRegisterCommands=St;
@@ -1,11 +1,11 @@
1
- import { jsx as r, jsxs as A } from "react/jsx-runtime";
1
+ import { jsx as r, jsxs as N } from "react/jsx-runtime";
2
2
  const L = ({
3
3
  value: i,
4
4
  min: o = 0,
5
- max: d = 100,
6
- width: t = 300,
5
+ max: g = 100,
6
+ width: n = 300,
7
7
  height: c = 60,
8
- orientation: h = "horizontal",
8
+ orientation: A = "horizontal",
9
9
  color: k = "var(--nice-color-primary, #3b82f6)",
10
10
  label: s,
11
11
  formatValue: x,
@@ -15,99 +15,112 @@ const L = ({
15
15
  className: m,
16
16
  style: p,
17
17
  testId: $,
18
- "data-testid": u
18
+ "data-testid": h
19
19
  }) => {
20
- const N = h === "horizontal", n = N ? t - 40 : c - 40, l = Math.max(0, Math.min(1, (i - o) / (d - o || 1))), e = 10;
21
- let g = k;
20
+ const u = A === "horizontal", t = u ? n - 40 : c - 40, a = Math.max(0, Math.min(1, (i - o) / (g - o || 1))), e = 10;
21
+ let f = k;
22
22
  if (y) {
23
- for (const a of y)
24
- if (i >= a.start && i <= a.end) {
25
- g = a.color;
23
+ for (const l of y)
24
+ if (i >= l.start && i <= l.end) {
25
+ f = l.color;
26
26
  break;
27
27
  }
28
28
  }
29
29
  const z = Array.from(
30
30
  { length: _ },
31
- (a, f) => o + (d - o) * (f / (_ - 1))
31
+ (l, d) => o + (g - o) * (d / (_ - 1))
32
32
  );
33
- return N ? /* @__PURE__ */ r(
34
- "div",
35
- {
36
- className: `nice-gauge nice-gauge--linear ${m || ""}`,
37
- style: p,
38
- "data-testid": u ?? $,
39
- children: /* @__PURE__ */ A("svg", { width: t, height: c, children: [
40
- /* @__PURE__ */ r(
41
- "text",
42
- {
43
- x: 20 + n * l,
44
- y: 14,
45
- textAnchor: "middle",
46
- className: "nice-gauge__value",
47
- style: { fontSize: 12 },
48
- children: x ? x(i) : i
49
- }
50
- ),
51
- /* @__PURE__ */ r(
52
- "rect",
53
- {
54
- x: 20,
55
- y: c / 2 - e / 2,
56
- width: n,
57
- height: e,
58
- rx: 5,
59
- fill: "var(--nice-border-color, #e2e8f0)"
60
- }
61
- ),
62
- /* @__PURE__ */ r(
63
- "rect",
64
- {
65
- x: 20,
66
- y: c / 2 - e / 2,
67
- width: n * l,
68
- height: e,
69
- rx: 5,
70
- fill: g
71
- }
72
- ),
73
- /* @__PURE__ */ r(
74
- "polygon",
75
- {
76
- points: `${20 + n * l},${c / 2 - e / 2 - 2} ${20 + n * l - 5},${c / 2 - e / 2 - 8} ${20 + n * l + 5},${c / 2 - e / 2 - 8}`,
77
- fill: "var(--nice-text-primary, #333)"
78
- }
79
- ),
80
- v && z.map((a, f) => {
81
- const b = 20 + (a - o) / (d - o) * n;
82
- return /* @__PURE__ */ r(
33
+ if (u) {
34
+ const l = s ? 14 : 0;
35
+ return /* @__PURE__ */ r(
36
+ "div",
37
+ {
38
+ className: `nice-gauge nice-gauge--linear ${m || ""}`,
39
+ style: p,
40
+ "data-testid": h ?? $,
41
+ children: /* @__PURE__ */ N("svg", { width: n, height: c + l, children: [
42
+ /* @__PURE__ */ r(
83
43
  "text",
84
44
  {
85
- x: b,
86
- y: c / 2 + e / 2 + 12,
45
+ x: 20 + t * a,
46
+ y: 14,
87
47
  textAnchor: "middle",
88
- className: "nice-gauge__tick",
89
- children: a
90
- },
91
- f
92
- );
93
- }),
94
- s && /* @__PURE__ */ r("text", { x: t / 2, y: c - 2, textAnchor: "middle", className: "nice-gauge__label", children: s })
95
- ] })
96
- }
97
- ) : /* @__PURE__ */ r(
48
+ className: "nice-gauge__value",
49
+ style: { fontSize: 12 },
50
+ children: x ? x(i) : i
51
+ }
52
+ ),
53
+ /* @__PURE__ */ r(
54
+ "rect",
55
+ {
56
+ x: 20,
57
+ y: c / 2 - e / 2,
58
+ width: t,
59
+ height: e,
60
+ rx: 5,
61
+ fill: "var(--nice-border-color, #e2e8f0)"
62
+ }
63
+ ),
64
+ /* @__PURE__ */ r(
65
+ "rect",
66
+ {
67
+ x: 20,
68
+ y: c / 2 - e / 2,
69
+ width: t * a,
70
+ height: e,
71
+ rx: 5,
72
+ fill: f
73
+ }
74
+ ),
75
+ /* @__PURE__ */ r(
76
+ "polygon",
77
+ {
78
+ points: `${20 + t * a},${c / 2 - e / 2 - 2} ${20 + t * a - 5},${c / 2 - e / 2 - 8} ${20 + t * a + 5},${c / 2 - e / 2 - 8}`,
79
+ fill: "var(--nice-text-primary, #333)"
80
+ }
81
+ ),
82
+ v && z.map((d, b) => {
83
+ const j = 20 + (d - o) / (g - o) * t;
84
+ return /* @__PURE__ */ r(
85
+ "text",
86
+ {
87
+ x: j,
88
+ y: c / 2 + e / 2 + 12,
89
+ textAnchor: "middle",
90
+ className: "nice-gauge__tick",
91
+ children: d
92
+ },
93
+ b
94
+ );
95
+ }),
96
+ s && /* @__PURE__ */ r(
97
+ "text",
98
+ {
99
+ x: n / 2,
100
+ y: c + l - 2,
101
+ textAnchor: "middle",
102
+ className: "nice-gauge__label",
103
+ children: s
104
+ }
105
+ )
106
+ ] })
107
+ }
108
+ );
109
+ }
110
+ return /* @__PURE__ */ r(
98
111
  "div",
99
112
  {
100
113
  className: `nice-gauge nice-gauge--linear nice-gauge--vertical ${m || ""}`,
101
114
  style: p,
102
- "data-testid": u ?? $,
103
- children: /* @__PURE__ */ A("svg", { width: t, height: c, children: [
115
+ "data-testid": h ?? $,
116
+ children: /* @__PURE__ */ N("svg", { width: n, height: c, children: [
104
117
  /* @__PURE__ */ r(
105
118
  "rect",
106
119
  {
107
- x: t / 2 - e / 2,
120
+ x: n / 2 - e / 2,
108
121
  y: 20,
109
122
  width: e,
110
- height: n,
123
+ height: t,
111
124
  rx: 5,
112
125
  fill: "var(--nice-border-color, #e2e8f0)"
113
126
  }
@@ -115,16 +128,16 @@ const L = ({
115
128
  /* @__PURE__ */ r(
116
129
  "rect",
117
130
  {
118
- x: t / 2 - e / 2,
119
- y: 20 + n * (1 - l),
131
+ x: n / 2 - e / 2,
132
+ y: 20 + t * (1 - a),
120
133
  width: e,
121
- height: n * l,
134
+ height: t * a,
122
135
  rx: 5,
123
- fill: g
136
+ fill: f
124
137
  }
125
138
  ),
126
- /* @__PURE__ */ r("text", { x: t / 2, y: 14, textAnchor: "middle", className: "nice-gauge__value", children: x ? x(i) : i }),
127
- s && /* @__PURE__ */ r("text", { x: t / 2, y: c - 4, textAnchor: "middle", className: "nice-gauge__label", children: s })
139
+ /* @__PURE__ */ r("text", { x: n / 2, y: 14, textAnchor: "middle", className: "nice-gauge__value", children: x ? x(i) : i }),
140
+ s && /* @__PURE__ */ r("text", { x: n / 2, y: c - 4, textAnchor: "middle", className: "nice-gauge__label", children: s })
128
141
  ] })
129
142
  }
130
143
  );