@nice2dev/ui 1.4.21 → 1.4.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +79 -0
- package/dist/NiceCodeEditor-CBgbzwjx.cjs +297 -0
- package/dist/{NiceMention-DhaTUqvR.cjs → NiceMention-D330ovOt.cjs} +1 -1
- package/dist/{NicePivotGrid-BshofJh1.cjs → NicePivotGrid-B5Fgi5E_.cjs} +1 -1
- package/dist/charts/NiceAdvancedCharts.mjs +657 -613
- package/dist/charts/NiceBarGauge.mjs +100 -65
- package/dist/charts/NiceBullet.mjs +103 -98
- package/dist/charts/NiceChart.mjs +269 -266
- package/dist/charts/NiceCircularGauge.mjs +99 -70
- package/dist/charts/NiceLinearGauge.mjs +168 -119
- package/dist/charts/NicePieChart.mjs +94 -49
- package/dist/charts/NicePolarChart.mjs +2 -2
- package/dist/charts-C9B548D2.cjs +924 -0
- package/dist/charts.cjs +1 -1
- package/dist/charts.d.ts +24 -2
- package/dist/{core-lazy-DirbU7jp.cjs → core-lazy-B54FdghB.cjs} +1 -1
- package/dist/data.cjs +1 -1
- package/dist/editors/rich/NiceCodeEditor.mjs +525 -504
- package/dist/editors.cjs +1 -1
- package/dist/index.cjs +8 -3
- package/dist/index.d.ts +29 -2
- package/dist/lazy.cjs +1 -1
- package/dist/lazy.d.ts +8 -0
- package/dist/style.css +1 -1
- package/dist/tools/NiceGitManager.mjs +5 -0
- package/dist/workflow/NiceTaskInbox.mjs +14 -12
- package/package.json +4 -4
- package/dist/NiceCodeEditor-DhdjnDLV.cjs +0 -289
- package/dist/charts-C3Q3r8Yz.cjs +0 -918
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("@nice2dev/ui-core"),Ft=require("./core-lBFqvT0V.cjs"),r=require("react"),Oe=require("./no-code-DPc82kyy.cjs"),dt=require("./NiceForm-DM2tARZT.cjs"),Vt=require("./pickerCommons-CQnae2FM.cjs"),bn=require("./NiceColorPicker-79rkvaSk.cjs"),it=require("./NiceMention-DhaTUqvR.cjs"),Zl=require("./NiceHtmlEditor-BEWNA_UI.cjs"),pi=require("./NiceCodeEditor-DhdjnDLV.cjs"),Be=require("./NiceModuleLifecyclePanel-jckyVqqt.cjs"),Fe=require("./NiceButton-DzCqkG5a.cjs"),At=require("./NiceScheduler-Dff8fuq_.cjs"),Wn=require("./NicePivotGrid-BshofJh1.cjs"),e=require("react/jsx-runtime"),Fr=require("react-dom"),ft=require("./NiceSavedQueryPanel-DJKEOqy5.cjs"),_t=require("./devops-o6Zm0VKB.cjs"),hn=require("./NiceAlert-RVTgQxCE.cjs"),Fi=require("./NiceModal-BRVzjuUN.cjs"),qt=require("./NiceLoginForm-Bkm5j80r.cjs"),qr=require("./NicePagination-CnKYyKI5.cjs"),fn=require("./NiceDataGrid-Cszjz8NV.cjs"),Qe=require("./charts-C3Q3r8Yz.cjs"),kt=require("./NiceWindow-DQyf5wat.cjs"),ed=require("./NiceGantt-Drl4gvw9.cjs"),En=require("./injectStyleOnce-DeWaxcdf.cjs"),Vr=require("@nice2dev/i18n"),kh=require("./NiceDocumentViewer-CDXAmPp7.cjs"),In=require("./core-lazy-DirbU7jp.cjs"),qi=require("./data-branching-7rpktFJ-.cjs");function td({className:t="",size:n="md",showTooltip:i=!0,showLabel:a=!0,onClick:s,label:o,tooltipPosition:c="bottom"}){const{t:d}=l.useNiceTranslation(),{badgeInfo:p,isLoading:m}=Ft.useTracelessPolicySafe(),[h,u]=r.useState(!1),x={sm:"nice-traceless-badge--sm",md:"nice-traceless-badge--md",lg:"nice-traceless-badge--lg"},f=o||p.label;return r.createElement("div",{className:`nice-traceless-badge ${p.cssClass} ${x[n]} ${t}`.trim(),onClick:s,onMouseEnter:()=>u(!0),onMouseLeave:()=>u(!1),role:s?"button":"status",tabIndex:s?0:void 0,onKeyDown:s?b=>{(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),s())}:void 0,"aria-label":d("traceless.badgeAria","Privacy mode: {mode}").replace("{mode}",f),style:{display:"inline-flex",alignItems:"center",gap:"0.375rem",padding:n==="sm"?"0.25rem 0.5rem":n==="lg"?"0.5rem 1rem":"0.375rem 0.75rem",borderRadius:"9999px",fontSize:n==="sm"?"0.75rem":n==="lg"?"1rem":"0.875rem",fontWeight:500,backgroundColor:`${p.color}20`,color:p.color,border:`1px solid ${p.color}40`,cursor:s?"pointer":"default",transition:"all 0.2s ease",position:"relative",userSelect:"none"}},r.createElement("span",{"aria-hidden":!0},r.createElement(l.NiceIcon,{name:m?"clock":p.icon,size:14})),a&&r.createElement("span",null,f),i&&h&&r.createElement("div",{role:"tooltip",style:{position:"absolute",[c==="top"?"bottom":c==="bottom"?"top":c==="left"?"right":"left"]:"100%",[c==="top"||c==="bottom"?"left":"top"]:"50%",transform:c==="top"||c==="bottom"?"translateX(-50%)":"translateY(-50%)",marginTop:c==="bottom"?"0.5rem":void 0,marginBottom:c==="top"?"0.5rem":void 0,marginLeft:c==="right"?"0.5rem":void 0,marginRight:c==="left"?"0.5rem":void 0,padding:"0.5rem 0.75rem",backgroundColor:"var(--nice-text-primary, #1f2937)",color:"var(--nice-text-inverse, #fff)",borderRadius:"0.375rem",fontSize:"0.75rem",whiteSpace:"nowrap",zIndex:50,boxShadow:"0 4px 6px -1px var(--nice-overlay-10, rgba(0, 0, 0, 0.1))",maxWidth:"280px",textAlign:"left"}},p.tooltip))}function Ch({className:t="",showReport:n=!0,showAudit:i=!0,showModeSelector:a=!0,availableModes:s=["traceless","ephemeral","private"],onModeChange:o}){const{t:c}=l.useNiceTranslation(),{policy:d,badgeInfo:p,setUserPreference:m,generateReport:h}=Ft.useTracelessPolicySafe(),{result:u,run:x}=Ft.useStorageAudit(),[f,b]=r.useState(null),g=r.useCallback(w=>{m({preferredMode:w}),o?.(w)},[m,o]),v=r.useCallback(()=>{b(h())},[h]),y={traceless:c("traceless.mode.traceless","Traceless"),ephemeral:c("traceless.mode.ephemeral","Ephemeral"),private:c("traceless.mode.private","Private"),balanced:c("traceless.mode.balanced","Balanced"),full:c("traceless.mode.full","Full"),custom:c("traceless.mode.custom","Custom")},C={traceless:c("traceless.modeDesc.traceless","Zero storage. Maximum privacy. Data resets on every page load."),ephemeral:c("traceless.modeDesc.ephemeral","Session-only. Data clears when you close the tab."),private:c("traceless.modeDesc.private","Minimal storage with secure authentication."),balanced:c("traceless.modeDesc.balanced","Local preferences saved. No tracking cookies."),full:c("traceless.modeDesc.full","All storage enabled with consent controls."),custom:c("traceless.modeDesc.custom","Custom configuration.")};return r.createElement("div",{className:`nice-traceless-panel ${t}`.trim(),style:{padding:"1.5rem",backgroundColor:"var(--nice-bg-secondary, #f9fafb)",borderRadius:"0.75rem",border:"1px solid var(--nice-border-color, #e5e7eb)"}},r.createElement("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem",marginBottom:"1.5rem"}},r.createElement(td,{size:"lg",showTooltip:!1}),r.createElement("div",null,r.createElement("h3",{style:{margin:0,fontSize:"1.125rem",fontWeight:600}},c("traceless.title","Privacy Settings")),r.createElement("p",{style:{margin:0,fontSize:"0.875rem",color:"var(--nice-text-muted, #6b7280)"}},C[d.effectiveMode]))),a&&r.createElement("div",{style:{marginBottom:"1.5rem"}},r.createElement("label",{style:{display:"block",marginBottom:"0.5rem",fontWeight:500}},c("traceless.level","Privacy Level")),r.createElement("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap"}},s.map(w=>r.createElement("button",{key:w,onClick:()=>g(w),style:{padding:"0.5rem 1rem",borderRadius:"0.5rem",border:d.effectiveMode===w?"2px solid var(--nice-primary, #3b82f6)":"1px solid var(--nice-border-color, #d1d5db)",backgroundColor:d.effectiveMode===w?"var(--nice-info-bg, #eff6ff)":"var(--nice-bg-primary, #fff)",cursor:"pointer",fontWeight:d.effectiveMode===w?600:400}},y[w])))),r.createElement("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:"1rem",marginBottom:"1.5rem"}},r.createElement(Ms,{title:c("traceless.cookies","Cookies"),allowed:d.cookiesAllowed,icon:r.createElement(l.NiceIcon,{name:"file",size:24})}),r.createElement(Ms,{title:"localStorage",allowed:d.localStorageAllowed,icon:r.createElement(l.NiceIcon,{name:"save",size:24})}),r.createElement(Ms,{title:"sessionStorage",allowed:d.sessionStorageAllowed,icon:r.createElement(l.NiceIcon,{name:"clipboard",size:24})})),r.createElement("div",{style:{display:"flex",gap:"0.75rem",flexWrap:"wrap"}},i&&r.createElement("button",{onClick:x,style:{padding:"0.5rem 1rem",borderRadius:"0.5rem",border:"1px solid var(--nice-border-color, #d1d5db)",backgroundColor:"var(--nice-bg-primary, #fff)",color:"var(--nice-text-primary, #0f172a)",cursor:"pointer",display:"inline-flex",alignItems:"center",gap:"0.375rem"}},r.createElement(l.NiceIcon,{name:"search",size:16}),c("traceless.runAudit","Run Audit")),n&&r.createElement("button",{onClick:v,style:{padding:"0.5rem 1rem",borderRadius:"0.5rem",border:"1px solid var(--nice-border-color, #d1d5db)",backgroundColor:"var(--nice-bg-primary, #fff)",color:"var(--nice-text-primary, #0f172a)",cursor:"pointer",display:"inline-flex",alignItems:"center",gap:"0.375rem"}},r.createElement(l.NiceIcon,{name:"file",size:16}),c("traceless.generateReport","Generate Report"))),u&&r.createElement("div",{style:{marginTop:"1rem",padding:"1rem",backgroundColor:u.compliant?"var(--nice-success-bg, #ecfdf5)":"var(--nice-danger-bg, #fef2f2)",borderRadius:"0.5rem",border:`1px solid ${u.compliant?"var(--nice-color-success, #10b981)":"var(--nice-color-error, #ef4444)"}`}},r.createElement("p",{style:{margin:0,fontWeight:500,color:u.compliant?"var(--nice-success, #059669)":"var(--nice-color-error, #dc2626)",display:"inline-flex",alignItems:"center",gap:"0.375rem"}},r.createElement(l.NiceIcon,{name:u.compliant?"check":"close",size:16}),u.compliant?c("traceless.compliant","Compliant"):c("traceless.violations","Violations Found")),!u.compliant&&u.violations.map((w,E)=>r.createElement("p",{key:E,style:{margin:"0.5rem 0 0",fontSize:"0.875rem"}},`• ${w.message}`))),f&&r.createElement("div",{style:{marginTop:"1rem",padding:"1rem",backgroundColor:"var(--nice-bg-primary, #fff)",color:"var(--nice-text-primary, #0f172a)",borderRadius:"0.5rem",border:"1px solid var(--nice-border-color, #d1d5db)"}},r.createElement("h4",{style:{margin:"0 0 0.5rem",fontSize:"0.875rem",fontWeight:600}},c("traceless.statement","Compliance Statement")),r.createElement("p",{style:{margin:0,fontSize:"0.875rem",color:"var(--nice-text-secondary, #4b5563)"}},f.statement)))}function Ms({title:t,allowed:n,icon:i}){const{t:a}=l.useNiceTranslation();return r.createElement("div",{style:{padding:"0.75rem",backgroundColor:"var(--nice-bg-primary, #fff)",color:"var(--nice-text-primary, #0f172a)",borderRadius:"0.5rem",border:"1px solid var(--nice-border-color, #e5e7eb)",textAlign:"center"}},r.createElement("div",{style:{fontSize:"1.5rem",marginBottom:"0.25rem"}},i),r.createElement("div",{style:{fontSize:"0.75rem",fontWeight:500,marginBottom:"0.25rem"}},t),r.createElement("div",{style:{fontSize:"0.75rem",color:n?"var(--nice-color-success, #10b981)":"var(--nice-text-muted, #6b7280)",fontWeight:500,display:"inline-flex",alignItems:"center",gap:"0.25rem"}},r.createElement(l.NiceIcon,{name:n?"check":"close",size:12}),n?a("enabled","Enabled"):a("disabled","Disabled")))}function Sh({className:t="",position:n="bottom",onAccept:i,onDecline:a,onCustomize:s,privacyPolicyUrl:o,acceptText:c,declineText:d}){const{t:p}=l.useNiceTranslation(),{shouldShow:m,mode:h,dismiss:u}=Ft.useCookieBannerVisibility(),x=r.useCallback(()=>{i?.(),u()},[i,u]),f=r.useCallback(()=>{a?.(),u()},[a,u]);if(!m)return null;const b=n==="top"?{top:0,borderBottom:"1px solid var(--nice-border-color, #e5e7eb)"}:{bottom:0,borderTop:"1px solid var(--nice-border-color, #e5e7eb)"};return r.createElement("div",{className:`nice-consent-banner ${t}`.trim(),role:"dialog","aria-label":p("cookie.title","Cookie consent"),style:{position:"fixed",left:0,right:0,padding:"1rem 1.5rem",backgroundColor:"var(--nice-bg-primary, #fff)",color:"var(--nice-text-primary, #0f172a)",boxShadow:"0 -4px 6px -1px var(--nice-overlay-10, rgba(0, 0, 0, 0.1))",zIndex:9999,display:"flex",alignItems:"center",justifyContent:"space-between",gap:"1rem",flexWrap:"wrap",...b}},r.createElement("div",{style:{flex:1,minWidth:"200px"}},r.createElement("p",{style:{margin:0,fontSize:"0.875rem"}},`${p("cookie.message","This site uses cookies to improve your experience.")} `,o&&r.createElement("a",{href:o,target:"_blank",rel:"noopener noreferrer",style:{color:"var(--nice-color-primary, #3b82f6)"}},p("cookie.learnMore","Learn more")))),r.createElement("div",{style:{display:"flex",gap:"0.5rem",flexShrink:0}},s&&r.createElement("button",{onClick:s,style:{padding:"0.5rem 1rem",borderRadius:"0.375rem",border:"1px solid var(--nice-border-color, #d1d5db)",backgroundColor:"var(--nice-bg-primary, #fff)",color:"var(--nice-text-primary, #0f172a)",cursor:"pointer"}},p("cookie.customize","Customize")),r.createElement("button",{onClick:f,style:{padding:"0.5rem 1rem",borderRadius:"0.375rem",border:"1px solid var(--nice-border-color, #d1d5db)",backgroundColor:"var(--nice-bg-primary, #fff)",color:"var(--nice-text-primary, #0f172a)",cursor:"pointer"}},d??p("cookie.reject","Reject all")),r.createElement("button",{onClick:x,style:{padding:"0.5rem 1rem",borderRadius:"0.375rem",border:"none",backgroundColor:"var(--nice-color-primary, #3b82f6)",color:"var(--nice-text-on-primary, #fff)",cursor:"pointer",fontWeight:500}},c??p("cookie.accept","Accept all"))))}function Th({useCase:t,className:n="",message:i,variant:a="inline",dismissible:s=!1,onDismiss:o}){const{t:c}=l.useNiceTranslation(),{warningMessage:d}=Ft.useTracelessPolicySafe().policy.effectiveMode==="traceless"?{warningMessage:i||c("traceless.limitedFeature","This feature has limited functionality in Traceless mode.")}:{warningMessage:void 0},[p,m]=r.useState(!1),h=r.useCallback(()=>{m(!0),o?.()},[o]);if(!d||p)return null;const u={inline:{padding:"0.5rem 0.75rem",backgroundColor:"var(--nice-warning-bg, #fef3c7)",border:"1px solid var(--nice-warning-light, #fbbf24)",borderRadius:"0.375rem",fontSize:"0.875rem"},banner:{padding:"0.75rem 1rem",backgroundColor:"var(--nice-warning-bg, #fef3c7)",borderBottom:"1px solid var(--nice-warning-light, #fbbf24)",fontSize:"0.875rem"},toast:{padding:"0.75rem 1rem",backgroundColor:"var(--nice-text-primary, #1f2937)",color:"var(--nice-text-inverse, #fff)",borderRadius:"0.5rem",boxShadow:"0 4px 6px -1px var(--nice-overlay-10, rgba(0, 0, 0, 0.1))",fontSize:"0.875rem"}};return r.createElement("div",{className:`nice-traceless-warning nice-traceless-warning--${a} ${n}`.trim(),role:"alert",style:{display:"flex",alignItems:"center",gap:"0.5rem",...u[a]}},r.createElement("span",{"aria-hidden":!0},r.createElement(l.NiceIcon,{name:"warning",size:16})),r.createElement("span",{style:{flex:1}},d),s&&r.createElement("button",{onClick:h,"aria-label":c("traceless.dismissWarning","Dismiss warning"),style:{background:"none",border:"none",cursor:"pointer",padding:"0.25rem",opacity:.7}},r.createElement(l.NiceIcon,{name:"close",size:14})))}const nd=r.createContext(null);function Eh(){const t=r.useContext(nd);return t||{isActive:!1,trackEvent:()=>{},trackPageView:()=>{},setUserProperties:()=>{},mode:"traceless",provider:"custom"}}function Ih({children:t,provider:n,trackingId:i,endpoint:a,customHandler:s,cookies:o=!0,localStorage:c=!1,minMode:d="balanced",autoTrackPageViews:p=!0,respectDoNotTrack:m=!0,debug:h=!1,domain:u,scriptUrl:x,anonymizeIp:f=!0,cookieless:b=!1}){const{policy:g,mode:v}=Ft.useTracelessPolicySafe(),y=r.useMemo(()=>{if(m&&typeof navigator<"u"){const j=navigator.doNotTrack||window.doNotTrack;if(j==="1"||j==="yes")return h&&Rn("Disabled: Do Not Track is set"),!1}const N=["traceless","ephemeral","private","balanced","full"],_=N.indexOf(v),k=N.indexOf(d);return _<k?(h&&Rn(`Disabled: mode ${v} < minMode ${d}`),!1):o&&!g.cookiesAllowed&&!b?(h&&Rn("Disabled: cookies required but not allowed"),!1):c&&!g.localStorageAllowed?(h&&Rn("Disabled: localStorage required but not allowed"),!1):!0},[v,d,g,o,c,b,m,h]);r.useEffect(()=>{if(y){if(n==="custom"&&s){s.init();return}switch(n){case"plausible":ea(x||"https://plausible.io/js/script.js",{"data-domain":i||u});break;case"simple-analytics":ea(x||"https://scripts.simpleanalyticscdn.com/latest.js");break;case"umami":ea(x||a||"",{"data-website-id":i});break;case"fathom":ea(x||"https://cdn.usefathom.com/script.js",{"data-site":i});break;case"matomo":Ah(a||"",i||"",f);break;case"google-analytics":b||(ea(`https://www.googletagmanager.com/gtag/js?id=${i}`),Dh(i||"",f));break;case"google-tag-manager":b||Ph(i||"");break;default:h&&console.warn(`[NiceAnalyticsTracker] Unknown provider: ${n}`)}h&&Rn(`Initialized: ${n}`)}},[y,n,i,a,x,u,f,b,s,h]);const C=r.useCallback(N=>{if(y){if(h&&Rn("trackPageView:",N),n==="custom"&&s){s.trackPageView(N);return}switch(n){case"plausible":window.plausible?.("pageview");break;case"umami":window.umami?.track();break;case"fathom":window.fathom?.trackPageview();break;case"matomo":window._paq?.push(["trackPageView"]);break;case"google-analytics":window.gtag?.("event","page_view",{page_path:N.path,page_title:N.title});break}}},[y,n,s,h]);r.useEffect(()=>{if(!y||!p)return;C({path:typeof window<"u"?window.location.pathname:"/",title:typeof document<"u"?document.title:""});const N=()=>{C({path:window.location.pathname,title:document.title})};return window.addEventListener("popstate",N),()=>window.removeEventListener("popstate",N)},[y,p,C]);const w=r.useCallback(N=>{if(y){if(h&&Rn("trackEvent:",N),n==="custom"&&s){s.trackEvent(N);return}switch(n){case"plausible":window.plausible?.(N.name,{props:N.properties});break;case"umami":window.umami?.track(N.name,N.properties);break;case"fathom":window.fathom?.trackGoal(N.name,N.value??0);break;case"matomo":window._paq?.push(["trackEvent",N.category,N.name,N.label,N.value]);break;case"google-analytics":window.gtag?.("event",N.name,{event_category:N.category,event_label:N.label,value:N.value,...N.properties});break}}},[y,n,s,h]),E=r.useCallback(N=>{if(y){if(h&&Rn("setUserProperties:",N),n==="custom"&&s?.setUserProperties){s.setUserProperties(N);return}switch(n){case"google-analytics":window.gtag?.("set","user_properties",N);break;case"matomo":Object.entries(N).forEach(([_,k])=>{window._paq?.push(["setCustomVariable",_,String(k)])});break}}},[y,n,s,h]),S=r.useMemo(()=>({isActive:y,trackEvent:w,trackPageView:C,setUserProperties:E,mode:v,provider:n}),[y,w,C,E,v,n]);return r.createElement(nd.Provider,{value:S},t)}function Rn(...t){console.log("[NiceAnalyticsTracker]",...t)}function ea(t,n){if(typeof document>"u"||!t||document.querySelector(`script[src="${t}"]`))return;const a=document.createElement("script");a.src=t,a.async=!0,a.defer=!0,n&&Object.entries(n).forEach(([s,o])=>{o!==void 0&&a.setAttribute(s,o)}),document.head.appendChild(a)}function Dh(t,n){if(typeof window>"u")return;window.dataLayer=window.dataLayer||[];function i(...a){window.dataLayer.push(arguments)}window.gtag=i,i("js",new Date),i("config",t,{anonymize_ip:n})}function Ph(t){if(typeof window>"u")return;window.dataLayer=window.dataLayer||[],window.dataLayer.push({"gtm.start":new Date().getTime(),event:"gtm.js"});const n=document.createElement("script");n.async=!0,n.src=`https://www.googletagmanager.com/gtm.js?id=${t}`,document.head.appendChild(n)}function Ah(t,n,i){if(typeof window>"u"||!t)return;window._paq=window._paq||[];const a=window._paq;i&&a.push(["setAnonymizeIp",!0]),a.push(["trackPageView"]),a.push(["enableLinkTracking"]),a.push(["setTrackerUrl",`${t}/matomo.php`]),a.push(["setSiteId",n]);const s=document.createElement("script");s.async=!0,s.src=`${t}/matomo.js`,document.head.appendChild(s)}function kn(t,n=2){return String(t).padStart(n,"0")}function Os(t){return kn(t.getUTCFullYear(),4)+kn(t.getUTCMonth()+1)+kn(t.getUTCDate())+"T"+kn(t.getUTCHours())+kn(t.getUTCMinutes())+kn(t.getUTCSeconds())+"Z"}function sc(t){return kn(t.getFullYear(),4)+kn(t.getMonth()+1)+kn(t.getDate())}function ta(t){return t.replace(/\\/g,"\\\\").replace(/;/g,"\\;").replace(/,/g,"\\,").replace(/\r?\n/g,"\\n")}function Rh(t){if(t.length<=75)return t;const n=[];let i=0;for(;i<t.length;)n.push(t.slice(i,i+75)),i+=75;return n.join(`\r
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("@nice2dev/ui-core"),Ft=require("./core-lBFqvT0V.cjs"),r=require("react"),Oe=require("./no-code-DPc82kyy.cjs"),dt=require("./NiceForm-DM2tARZT.cjs"),Vt=require("./pickerCommons-CQnae2FM.cjs"),bn=require("./NiceColorPicker-79rkvaSk.cjs"),it=require("./NiceMention-D330ovOt.cjs"),Zl=require("./NiceHtmlEditor-BEWNA_UI.cjs"),pi=require("./NiceCodeEditor-CBgbzwjx.cjs"),Be=require("./NiceModuleLifecyclePanel-jckyVqqt.cjs"),Fe=require("./NiceButton-DzCqkG5a.cjs"),At=require("./NiceScheduler-Dff8fuq_.cjs"),Wn=require("./NicePivotGrid-B5Fgi5E_.cjs"),e=require("react/jsx-runtime"),Fr=require("react-dom"),ft=require("./NiceSavedQueryPanel-DJKEOqy5.cjs"),_t=require("./devops-o6Zm0VKB.cjs"),hn=require("./NiceAlert-RVTgQxCE.cjs"),Fi=require("./NiceModal-BRVzjuUN.cjs"),qt=require("./NiceLoginForm-Bkm5j80r.cjs"),qr=require("./NicePagination-CnKYyKI5.cjs"),fn=require("./NiceDataGrid-Cszjz8NV.cjs"),Qe=require("./charts-C9B548D2.cjs"),kt=require("./NiceWindow-DQyf5wat.cjs"),ed=require("./NiceGantt-Drl4gvw9.cjs"),En=require("./injectStyleOnce-DeWaxcdf.cjs"),Vr=require("@nice2dev/i18n"),kh=require("./NiceDocumentViewer-CDXAmPp7.cjs"),In=require("./core-lazy-B54FdghB.cjs"),qi=require("./data-branching-7rpktFJ-.cjs");function td({className:t="",size:n="md",showTooltip:i=!0,showLabel:a=!0,onClick:s,label:o,tooltipPosition:c="bottom"}){const{t:d}=l.useNiceTranslation(),{badgeInfo:p,isLoading:m}=Ft.useTracelessPolicySafe(),[h,u]=r.useState(!1),x={sm:"nice-traceless-badge--sm",md:"nice-traceless-badge--md",lg:"nice-traceless-badge--lg"},f=o||p.label;return r.createElement("div",{className:`nice-traceless-badge ${p.cssClass} ${x[n]} ${t}`.trim(),onClick:s,onMouseEnter:()=>u(!0),onMouseLeave:()=>u(!1),role:s?"button":"status",tabIndex:s?0:void 0,onKeyDown:s?b=>{(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),s())}:void 0,"aria-label":d("traceless.badgeAria","Privacy mode: {mode}").replace("{mode}",f),style:{display:"inline-flex",alignItems:"center",gap:"0.375rem",padding:n==="sm"?"0.25rem 0.5rem":n==="lg"?"0.5rem 1rem":"0.375rem 0.75rem",borderRadius:"9999px",fontSize:n==="sm"?"0.75rem":n==="lg"?"1rem":"0.875rem",fontWeight:500,backgroundColor:`${p.color}20`,color:p.color,border:`1px solid ${p.color}40`,cursor:s?"pointer":"default",transition:"all 0.2s ease",position:"relative",userSelect:"none"}},r.createElement("span",{"aria-hidden":!0},r.createElement(l.NiceIcon,{name:m?"clock":p.icon,size:14})),a&&r.createElement("span",null,f),i&&h&&r.createElement("div",{role:"tooltip",style:{position:"absolute",[c==="top"?"bottom":c==="bottom"?"top":c==="left"?"right":"left"]:"100%",[c==="top"||c==="bottom"?"left":"top"]:"50%",transform:c==="top"||c==="bottom"?"translateX(-50%)":"translateY(-50%)",marginTop:c==="bottom"?"0.5rem":void 0,marginBottom:c==="top"?"0.5rem":void 0,marginLeft:c==="right"?"0.5rem":void 0,marginRight:c==="left"?"0.5rem":void 0,padding:"0.5rem 0.75rem",backgroundColor:"var(--nice-text-primary, #1f2937)",color:"var(--nice-text-inverse, #fff)",borderRadius:"0.375rem",fontSize:"0.75rem",whiteSpace:"nowrap",zIndex:50,boxShadow:"0 4px 6px -1px var(--nice-overlay-10, rgba(0, 0, 0, 0.1))",maxWidth:"280px",textAlign:"left"}},p.tooltip))}function Ch({className:t="",showReport:n=!0,showAudit:i=!0,showModeSelector:a=!0,availableModes:s=["traceless","ephemeral","private"],onModeChange:o}){const{t:c}=l.useNiceTranslation(),{policy:d,badgeInfo:p,setUserPreference:m,generateReport:h}=Ft.useTracelessPolicySafe(),{result:u,run:x}=Ft.useStorageAudit(),[f,b]=r.useState(null),g=r.useCallback(w=>{m({preferredMode:w}),o?.(w)},[m,o]),v=r.useCallback(()=>{b(h())},[h]),y={traceless:c("traceless.mode.traceless","Traceless"),ephemeral:c("traceless.mode.ephemeral","Ephemeral"),private:c("traceless.mode.private","Private"),balanced:c("traceless.mode.balanced","Balanced"),full:c("traceless.mode.full","Full"),custom:c("traceless.mode.custom","Custom")},C={traceless:c("traceless.modeDesc.traceless","Zero storage. Maximum privacy. Data resets on every page load."),ephemeral:c("traceless.modeDesc.ephemeral","Session-only. Data clears when you close the tab."),private:c("traceless.modeDesc.private","Minimal storage with secure authentication."),balanced:c("traceless.modeDesc.balanced","Local preferences saved. No tracking cookies."),full:c("traceless.modeDesc.full","All storage enabled with consent controls."),custom:c("traceless.modeDesc.custom","Custom configuration.")};return r.createElement("div",{className:`nice-traceless-panel ${t}`.trim(),style:{padding:"1.5rem",backgroundColor:"var(--nice-bg-secondary, #f9fafb)",borderRadius:"0.75rem",border:"1px solid var(--nice-border-color, #e5e7eb)"}},r.createElement("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem",marginBottom:"1.5rem"}},r.createElement(td,{size:"lg",showTooltip:!1}),r.createElement("div",null,r.createElement("h3",{style:{margin:0,fontSize:"1.125rem",fontWeight:600}},c("traceless.title","Privacy Settings")),r.createElement("p",{style:{margin:0,fontSize:"0.875rem",color:"var(--nice-text-muted, #6b7280)"}},C[d.effectiveMode]))),a&&r.createElement("div",{style:{marginBottom:"1.5rem"}},r.createElement("label",{style:{display:"block",marginBottom:"0.5rem",fontWeight:500}},c("traceless.level","Privacy Level")),r.createElement("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap"}},s.map(w=>r.createElement("button",{key:w,onClick:()=>g(w),style:{padding:"0.5rem 1rem",borderRadius:"0.5rem",border:d.effectiveMode===w?"2px solid var(--nice-primary, #3b82f6)":"1px solid var(--nice-border-color, #d1d5db)",backgroundColor:d.effectiveMode===w?"var(--nice-info-bg, #eff6ff)":"var(--nice-bg-primary, #fff)",cursor:"pointer",fontWeight:d.effectiveMode===w?600:400}},y[w])))),r.createElement("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:"1rem",marginBottom:"1.5rem"}},r.createElement(Ms,{title:c("traceless.cookies","Cookies"),allowed:d.cookiesAllowed,icon:r.createElement(l.NiceIcon,{name:"file",size:24})}),r.createElement(Ms,{title:"localStorage",allowed:d.localStorageAllowed,icon:r.createElement(l.NiceIcon,{name:"save",size:24})}),r.createElement(Ms,{title:"sessionStorage",allowed:d.sessionStorageAllowed,icon:r.createElement(l.NiceIcon,{name:"clipboard",size:24})})),r.createElement("div",{style:{display:"flex",gap:"0.75rem",flexWrap:"wrap"}},i&&r.createElement("button",{onClick:x,style:{padding:"0.5rem 1rem",borderRadius:"0.5rem",border:"1px solid var(--nice-border-color, #d1d5db)",backgroundColor:"var(--nice-bg-primary, #fff)",color:"var(--nice-text-primary, #0f172a)",cursor:"pointer",display:"inline-flex",alignItems:"center",gap:"0.375rem"}},r.createElement(l.NiceIcon,{name:"search",size:16}),c("traceless.runAudit","Run Audit")),n&&r.createElement("button",{onClick:v,style:{padding:"0.5rem 1rem",borderRadius:"0.5rem",border:"1px solid var(--nice-border-color, #d1d5db)",backgroundColor:"var(--nice-bg-primary, #fff)",color:"var(--nice-text-primary, #0f172a)",cursor:"pointer",display:"inline-flex",alignItems:"center",gap:"0.375rem"}},r.createElement(l.NiceIcon,{name:"file",size:16}),c("traceless.generateReport","Generate Report"))),u&&r.createElement("div",{style:{marginTop:"1rem",padding:"1rem",backgroundColor:u.compliant?"var(--nice-success-bg, #ecfdf5)":"var(--nice-danger-bg, #fef2f2)",borderRadius:"0.5rem",border:`1px solid ${u.compliant?"var(--nice-color-success, #10b981)":"var(--nice-color-error, #ef4444)"}`}},r.createElement("p",{style:{margin:0,fontWeight:500,color:u.compliant?"var(--nice-success, #059669)":"var(--nice-color-error, #dc2626)",display:"inline-flex",alignItems:"center",gap:"0.375rem"}},r.createElement(l.NiceIcon,{name:u.compliant?"check":"close",size:16}),u.compliant?c("traceless.compliant","Compliant"):c("traceless.violations","Violations Found")),!u.compliant&&u.violations.map((w,E)=>r.createElement("p",{key:E,style:{margin:"0.5rem 0 0",fontSize:"0.875rem"}},`• ${w.message}`))),f&&r.createElement("div",{style:{marginTop:"1rem",padding:"1rem",backgroundColor:"var(--nice-bg-primary, #fff)",color:"var(--nice-text-primary, #0f172a)",borderRadius:"0.5rem",border:"1px solid var(--nice-border-color, #d1d5db)"}},r.createElement("h4",{style:{margin:"0 0 0.5rem",fontSize:"0.875rem",fontWeight:600}},c("traceless.statement","Compliance Statement")),r.createElement("p",{style:{margin:0,fontSize:"0.875rem",color:"var(--nice-text-secondary, #4b5563)"}},f.statement)))}function Ms({title:t,allowed:n,icon:i}){const{t:a}=l.useNiceTranslation();return r.createElement("div",{style:{padding:"0.75rem",backgroundColor:"var(--nice-bg-primary, #fff)",color:"var(--nice-text-primary, #0f172a)",borderRadius:"0.5rem",border:"1px solid var(--nice-border-color, #e5e7eb)",textAlign:"center"}},r.createElement("div",{style:{fontSize:"1.5rem",marginBottom:"0.25rem"}},i),r.createElement("div",{style:{fontSize:"0.75rem",fontWeight:500,marginBottom:"0.25rem"}},t),r.createElement("div",{style:{fontSize:"0.75rem",color:n?"var(--nice-color-success, #10b981)":"var(--nice-text-muted, #6b7280)",fontWeight:500,display:"inline-flex",alignItems:"center",gap:"0.25rem"}},r.createElement(l.NiceIcon,{name:n?"check":"close",size:12}),n?a("enabled","Enabled"):a("disabled","Disabled")))}function Sh({className:t="",position:n="bottom",onAccept:i,onDecline:a,onCustomize:s,privacyPolicyUrl:o,acceptText:c,declineText:d}){const{t:p}=l.useNiceTranslation(),{shouldShow:m,mode:h,dismiss:u}=Ft.useCookieBannerVisibility(),x=r.useCallback(()=>{i?.(),u()},[i,u]),f=r.useCallback(()=>{a?.(),u()},[a,u]);if(!m)return null;const b=n==="top"?{top:0,borderBottom:"1px solid var(--nice-border-color, #e5e7eb)"}:{bottom:0,borderTop:"1px solid var(--nice-border-color, #e5e7eb)"};return r.createElement("div",{className:`nice-consent-banner ${t}`.trim(),role:"dialog","aria-label":p("cookie.title","Cookie consent"),style:{position:"fixed",left:0,right:0,padding:"1rem 1.5rem",backgroundColor:"var(--nice-bg-primary, #fff)",color:"var(--nice-text-primary, #0f172a)",boxShadow:"0 -4px 6px -1px var(--nice-overlay-10, rgba(0, 0, 0, 0.1))",zIndex:9999,display:"flex",alignItems:"center",justifyContent:"space-between",gap:"1rem",flexWrap:"wrap",...b}},r.createElement("div",{style:{flex:1,minWidth:"200px"}},r.createElement("p",{style:{margin:0,fontSize:"0.875rem"}},`${p("cookie.message","This site uses cookies to improve your experience.")} `,o&&r.createElement("a",{href:o,target:"_blank",rel:"noopener noreferrer",style:{color:"var(--nice-color-primary, #3b82f6)"}},p("cookie.learnMore","Learn more")))),r.createElement("div",{style:{display:"flex",gap:"0.5rem",flexShrink:0}},s&&r.createElement("button",{onClick:s,style:{padding:"0.5rem 1rem",borderRadius:"0.375rem",border:"1px solid var(--nice-border-color, #d1d5db)",backgroundColor:"var(--nice-bg-primary, #fff)",color:"var(--nice-text-primary, #0f172a)",cursor:"pointer"}},p("cookie.customize","Customize")),r.createElement("button",{onClick:f,style:{padding:"0.5rem 1rem",borderRadius:"0.375rem",border:"1px solid var(--nice-border-color, #d1d5db)",backgroundColor:"var(--nice-bg-primary, #fff)",color:"var(--nice-text-primary, #0f172a)",cursor:"pointer"}},d??p("cookie.reject","Reject all")),r.createElement("button",{onClick:x,style:{padding:"0.5rem 1rem",borderRadius:"0.375rem",border:"none",backgroundColor:"var(--nice-color-primary, #3b82f6)",color:"var(--nice-text-on-primary, #fff)",cursor:"pointer",fontWeight:500}},c??p("cookie.accept","Accept all"))))}function Th({useCase:t,className:n="",message:i,variant:a="inline",dismissible:s=!1,onDismiss:o}){const{t:c}=l.useNiceTranslation(),{warningMessage:d}=Ft.useTracelessPolicySafe().policy.effectiveMode==="traceless"?{warningMessage:i||c("traceless.limitedFeature","This feature has limited functionality in Traceless mode.")}:{warningMessage:void 0},[p,m]=r.useState(!1),h=r.useCallback(()=>{m(!0),o?.()},[o]);if(!d||p)return null;const u={inline:{padding:"0.5rem 0.75rem",backgroundColor:"var(--nice-warning-bg, #fef3c7)",border:"1px solid var(--nice-warning-light, #fbbf24)",borderRadius:"0.375rem",fontSize:"0.875rem"},banner:{padding:"0.75rem 1rem",backgroundColor:"var(--nice-warning-bg, #fef3c7)",borderBottom:"1px solid var(--nice-warning-light, #fbbf24)",fontSize:"0.875rem"},toast:{padding:"0.75rem 1rem",backgroundColor:"var(--nice-text-primary, #1f2937)",color:"var(--nice-text-inverse, #fff)",borderRadius:"0.5rem",boxShadow:"0 4px 6px -1px var(--nice-overlay-10, rgba(0, 0, 0, 0.1))",fontSize:"0.875rem"}};return r.createElement("div",{className:`nice-traceless-warning nice-traceless-warning--${a} ${n}`.trim(),role:"alert",style:{display:"flex",alignItems:"center",gap:"0.5rem",...u[a]}},r.createElement("span",{"aria-hidden":!0},r.createElement(l.NiceIcon,{name:"warning",size:16})),r.createElement("span",{style:{flex:1}},d),s&&r.createElement("button",{onClick:h,"aria-label":c("traceless.dismissWarning","Dismiss warning"),style:{background:"none",border:"none",cursor:"pointer",padding:"0.25rem",opacity:.7}},r.createElement(l.NiceIcon,{name:"close",size:14})))}const nd=r.createContext(null);function Eh(){const t=r.useContext(nd);return t||{isActive:!1,trackEvent:()=>{},trackPageView:()=>{},setUserProperties:()=>{},mode:"traceless",provider:"custom"}}function Ih({children:t,provider:n,trackingId:i,endpoint:a,customHandler:s,cookies:o=!0,localStorage:c=!1,minMode:d="balanced",autoTrackPageViews:p=!0,respectDoNotTrack:m=!0,debug:h=!1,domain:u,scriptUrl:x,anonymizeIp:f=!0,cookieless:b=!1}){const{policy:g,mode:v}=Ft.useTracelessPolicySafe(),y=r.useMemo(()=>{if(m&&typeof navigator<"u"){const j=navigator.doNotTrack||window.doNotTrack;if(j==="1"||j==="yes")return h&&Rn("Disabled: Do Not Track is set"),!1}const N=["traceless","ephemeral","private","balanced","full"],_=N.indexOf(v),k=N.indexOf(d);return _<k?(h&&Rn(`Disabled: mode ${v} < minMode ${d}`),!1):o&&!g.cookiesAllowed&&!b?(h&&Rn("Disabled: cookies required but not allowed"),!1):c&&!g.localStorageAllowed?(h&&Rn("Disabled: localStorage required but not allowed"),!1):!0},[v,d,g,o,c,b,m,h]);r.useEffect(()=>{if(y){if(n==="custom"&&s){s.init();return}switch(n){case"plausible":ea(x||"https://plausible.io/js/script.js",{"data-domain":i||u});break;case"simple-analytics":ea(x||"https://scripts.simpleanalyticscdn.com/latest.js");break;case"umami":ea(x||a||"",{"data-website-id":i});break;case"fathom":ea(x||"https://cdn.usefathom.com/script.js",{"data-site":i});break;case"matomo":Ah(a||"",i||"",f);break;case"google-analytics":b||(ea(`https://www.googletagmanager.com/gtag/js?id=${i}`),Dh(i||"",f));break;case"google-tag-manager":b||Ph(i||"");break;default:h&&console.warn(`[NiceAnalyticsTracker] Unknown provider: ${n}`)}h&&Rn(`Initialized: ${n}`)}},[y,n,i,a,x,u,f,b,s,h]);const C=r.useCallback(N=>{if(y){if(h&&Rn("trackPageView:",N),n==="custom"&&s){s.trackPageView(N);return}switch(n){case"plausible":window.plausible?.("pageview");break;case"umami":window.umami?.track();break;case"fathom":window.fathom?.trackPageview();break;case"matomo":window._paq?.push(["trackPageView"]);break;case"google-analytics":window.gtag?.("event","page_view",{page_path:N.path,page_title:N.title});break}}},[y,n,s,h]);r.useEffect(()=>{if(!y||!p)return;C({path:typeof window<"u"?window.location.pathname:"/",title:typeof document<"u"?document.title:""});const N=()=>{C({path:window.location.pathname,title:document.title})};return window.addEventListener("popstate",N),()=>window.removeEventListener("popstate",N)},[y,p,C]);const w=r.useCallback(N=>{if(y){if(h&&Rn("trackEvent:",N),n==="custom"&&s){s.trackEvent(N);return}switch(n){case"plausible":window.plausible?.(N.name,{props:N.properties});break;case"umami":window.umami?.track(N.name,N.properties);break;case"fathom":window.fathom?.trackGoal(N.name,N.value??0);break;case"matomo":window._paq?.push(["trackEvent",N.category,N.name,N.label,N.value]);break;case"google-analytics":window.gtag?.("event",N.name,{event_category:N.category,event_label:N.label,value:N.value,...N.properties});break}}},[y,n,s,h]),E=r.useCallback(N=>{if(y){if(h&&Rn("setUserProperties:",N),n==="custom"&&s?.setUserProperties){s.setUserProperties(N);return}switch(n){case"google-analytics":window.gtag?.("set","user_properties",N);break;case"matomo":Object.entries(N).forEach(([_,k])=>{window._paq?.push(["setCustomVariable",_,String(k)])});break}}},[y,n,s,h]),S=r.useMemo(()=>({isActive:y,trackEvent:w,trackPageView:C,setUserProperties:E,mode:v,provider:n}),[y,w,C,E,v,n]);return r.createElement(nd.Provider,{value:S},t)}function Rn(...t){console.log("[NiceAnalyticsTracker]",...t)}function ea(t,n){if(typeof document>"u"||!t||document.querySelector(`script[src="${t}"]`))return;const a=document.createElement("script");a.src=t,a.async=!0,a.defer=!0,n&&Object.entries(n).forEach(([s,o])=>{o!==void 0&&a.setAttribute(s,o)}),document.head.appendChild(a)}function Dh(t,n){if(typeof window>"u")return;window.dataLayer=window.dataLayer||[];function i(...a){window.dataLayer.push(arguments)}window.gtag=i,i("js",new Date),i("config",t,{anonymize_ip:n})}function Ph(t){if(typeof window>"u")return;window.dataLayer=window.dataLayer||[],window.dataLayer.push({"gtm.start":new Date().getTime(),event:"gtm.js"});const n=document.createElement("script");n.async=!0,n.src=`https://www.googletagmanager.com/gtm.js?id=${t}`,document.head.appendChild(n)}function Ah(t,n,i){if(typeof window>"u"||!t)return;window._paq=window._paq||[];const a=window._paq;i&&a.push(["setAnonymizeIp",!0]),a.push(["trackPageView"]),a.push(["enableLinkTracking"]),a.push(["setTrackerUrl",`${t}/matomo.php`]),a.push(["setSiteId",n]);const s=document.createElement("script");s.async=!0,s.src=`${t}/matomo.js`,document.head.appendChild(s)}function kn(t,n=2){return String(t).padStart(n,"0")}function Os(t){return kn(t.getUTCFullYear(),4)+kn(t.getUTCMonth()+1)+kn(t.getUTCDate())+"T"+kn(t.getUTCHours())+kn(t.getUTCMinutes())+kn(t.getUTCSeconds())+"Z"}function sc(t){return kn(t.getFullYear(),4)+kn(t.getMonth()+1)+kn(t.getDate())}function ta(t){return t.replace(/\\/g,"\\\\").replace(/;/g,"\\;").replace(/,/g,"\\,").replace(/\r?\n/g,"\\n")}function Rh(t){if(t.length<=75)return t;const n=[];let i=0;for(;i<t.length;)n.push(t.slice(i,i+75)),i+=75;return n.join(`\r
|
|
2
2
|
`)}function id(t,n={}){const{prodId:i="-//nice2dev//NiceToDev.UI//EN",calendarName:a,method:s}=n,o=["BEGIN:VCALENDAR","VERSION:2.0",`PRODID:${i}`,"CALSCALE:GREGORIAN"];s&&o.push(`METHOD:${s}`),a&&o.push(`X-WR-CALNAME:${ta(a)}`);const c=Os(new Date);for(const d of t)o.push("BEGIN:VEVENT"),o.push(`UID:${d.uid}`),o.push(`DTSTAMP:${c}`),d.allDay?(o.push(`DTSTART;VALUE=DATE:${sc(d.start)}`),d.end&&o.push(`DTEND;VALUE=DATE:${sc(d.end)}`)):(o.push(`DTSTART:${Os(d.start)}`),d.end&&o.push(`DTEND:${Os(d.end)}`)),o.push(`SUMMARY:${ta(d.summary)}`),d.description&&o.push(`DESCRIPTION:${ta(d.description)}`),d.location&&o.push(`LOCATION:${ta(d.location)}`),d.url&&o.push(`URL:${d.url}`),d.status&&o.push(`STATUS:${d.status}`),d.rrule&&o.push(`RRULE:${d.rrule}`),d.categories&&d.categories.length>0&&o.push(`CATEGORIES:${d.categories.map(ta).join(",")}`),o.push("END:VEVENT");return o.push("END:VCALENDAR"),o.map(Rh).join(`\r
|
|
3
3
|
`)}function ad(t,n={}){const i=id(t,n);return new Blob([i],{type:"text/calendar;charset=utf-8"})}function $h(t,n="calendar.ics",i={}){if(typeof window>"u"||typeof URL.createObjectURL!="function")return;const a=ad(t,i),s=URL.createObjectURL(a),o=document.createElement("a");o.href=s,o.download=n,document.body.appendChild(o),o.click(),o.remove(),URL.revokeObjectURL(s)}const Mh=[];function Oh(t){const n=t?.closest?.("[data-theme], .nice-dark, .nice-light, .dark");if(!n)return"";const i=n.getAttribute("data-theme");return i==="dark"||n.classList.contains("nice-dark")||n.classList.contains("dark")?"nice-dark":i==="light"||n.classList.contains("nice-light")?"nice-light":""}const sd=({icon:t,items:n=Mh,direction:i="right",position:a={bottom:24,right:24},disabled:s=!1,className:o,style:c,id:d,"data-testid":p})=>{const[m,h]=r.useState(!1),u=m&&!s,x=r.useRef(null),f=r.useRef(null),[b,g]=r.useState(null),[v,y]=r.useState(""),C=r.useRef(null);l.useMenuButton(f,C,{open:u,onOpenChange:h,orientation:i==="up"||i==="down"?"vertical":"horizontal"}),r.useLayoutEffect(()=>{if(!u||!f.current)return;const E=f.current,S=()=>g(E.getBoundingClientRect());return S(),y(Oh(x.current)),window.addEventListener("scroll",S,!0),window.addEventListener("resize",S),()=>{window.removeEventListener("scroll",S,!0),window.removeEventListener("resize",S)}},[u]);const w=e.jsx("div",{className:"nice-speed-dial__items",role:"menu",ref:C,children:n.map(E=>e.jsx("button",{type:"button",role:"menuitem",className:"nice-speed-dial__item nice-btn nice-btn--secondary",onClick:()=>{E.onClick?.(),h(!1)},title:E.label,"aria-label":E.label,children:E.icon},E.key))});return e.jsxs("div",{ref:x,id:d,"data-testid":p,className:["nice-speed-dial",`nice-speed-dial--${i}`,u?"nice-speed-dial--open":"",s?"nice-speed-dial--disabled":"",o||""].filter(Boolean).join(" "),style:{...a,...c},children:[e.jsx("button",{ref:f,type:"button",className:"nice-speed-dial__trigger nice-btn nice-btn--primary",onClick:()=>h(E=>!E),"aria-expanded":u,"aria-haspopup":"menu",disabled:s,children:e.jsx("span",{className:"nice-speed-dial__trigger-icon",children:t??e.jsx(l.NiceIcon,{name:"plus",size:24})})}),u&&b&&typeof document<"u"&&Fr.createPortal(e.jsx("div",{className:["nice-speed-dial","nice-speed-dial--portal",`nice-speed-dial--${i}`,"nice-speed-dial--open",v].filter(Boolean).join(" "),"data-theme":v==="nice-dark"?"dark":v==="nice-light"?"light":void 0,style:{position:"fixed",left:b.left,top:b.top,width:b.width,height:b.height,right:"auto",bottom:"auto",margin:0},children:w}),document.body)]})},Jt=({children:t,variant:n="primary",size:i="md",dot:a,outline:s,subtle:o,pulse:c,icon:d,removable:p,onRemove:m,className:h,style:u,displayStyle:x,testId:f,"data-testid":b})=>{const{t:g}=l.useNiceTranslation(),v=l.useComponentDisplayStyle("badge",x),y=l.useComponentDisplayClass("badge",x),C={...v};for(const w of["fontSize","padding","paddingLeft","paddingRight","paddingTop","paddingBottom","paddingInline","paddingBlock"])delete C[w];if(n!=="primary"||s||o)for(const w of["background","backgroundColor","color"])delete C[w];if(s||o)for(const w of["border","borderColor","borderWidth","borderStyle","boxShadow"])delete C[w];return e.jsxs("span",{className:`nice-badge nice-badge--${n} nice-badge--${i} nice-badge--ds-${y} ${a?"nice-badge--dot":""} ${s?"nice-badge--outline":""} ${o?"nice-badge--subtle":""} ${c?"nice-badge--pulse":""} ${p?"nice-badge--removable":""} ${h||""}`,style:{...C,...u},"data-testid":b??f,children:[d&&e.jsx("span",{className:"nice-badge__icon",children:d}),t,p&&e.jsx("button",{type:"button",className:"nice-badge__remove",onClick:m,"aria-label":g("badge.remove","Remove"),children:e.jsx(l.NiceIcon,{name:"close",size:14})})]})},Lh=Object.freeze(Object.defineProperty({__proto__:null,NiceBadge:Jt},Symbol.toStringTag,{value:"Module"})),us=({children:t,selected:n,removable:i,onClick:a,onRemove:s,color:o,size:c="md",className:d,style:p,testId:m,"data-testid":h})=>{const{t:u}=l.useNiceTranslation(),x=typeof t=="string"||typeof t=="number"?`${u("tag.remove","Remove")}: ${t}`:u("tag.remove","Remove");return e.jsxs("span",{className:`nice-tag nice-tag--${c} ${a?"nice-tag--clickable":""} ${n?"nice-tag--selected":""} ${d||""}`,style:{...p,...o&&!n?{borderColor:o,color:o}:{}},"data-testid":h??m,...a&&{onClick:a,role:"button",tabIndex:0,"aria-pressed":n,onKeyDown:f=>{f.target===f.currentTarget&&(f.key==="Enter"||f.key===" "?(f.preventDefault(),a()):i&&(f.key==="Delete"||f.key==="Backspace")&&(f.preventDefault(),s?.()))}},children:[t,i&&e.jsx("button",{type:"button",className:"nice-tag__remove",onClick:f=>{f.stopPropagation(),s?.()},"aria-label":x,children:e.jsx(l.NiceIcon,{name:"close",size:14})})]})};function zh(t){return t.split(" ").map(n=>n[0]).filter(Boolean).slice(0,2).join("").toUpperCase()}const Ht=({src:t,alt:n,name:i,size:a="md",square:s,color:o,badge:c,badgePosition:d="bottom-right",className:p,style:m,testId:h,"data-testid":u})=>{const x=e.jsx("div",{className:`nice-avatar nice-avatar--${a} ${s?"nice-avatar--square":""} ${c==null&&p||""}`,style:c==null?{...m,...o?{background:o}:{}}:o?{background:o}:void 0,"aria-label":n||i,"data-testid":c==null?u??h:void 0,children:t?e.jsx("img",{src:t,alt:n||i||""}):i?zh(i):e.jsx(l.NiceIcon,{name:"user",size:"md",className:"nice-avatar__fallback-icon"})});return c==null?x:e.jsxs("span",{className:`nice-avatar-wrap ${p||""}`,style:m,"data-testid":u??h,children:[x,e.jsx("span",{className:`nice-avatar__badge nice-avatar__badge--${d}`,children:c})]})};function Bh(t){return t?t.trim().split(/\s+/).map(n=>n[0]).join("").slice(0,2).toUpperCase():""}const Ur=({children:t,items:n,max:i,size:a="md",className:s,style:o,testId:c,"data-testid":d})=>{const p=`nice-avatar nice-avatar--${a}`;let m,h;if(n&&n.length>0)h=n.length,m=(i?n.slice(0,i):n).map((f,b)=>{const g=f.src?e.jsx("img",{src:f.src,alt:f.name??""}):e.jsx("span",{children:Bh(f.name)});return f.href?e.jsx("a",{className:p,href:f.href,title:f.name,onClick:f.onClick,children:g},b):f.onClick?e.jsx("button",{type:"button",className:p,title:f.name,onClick:f.onClick,children:g},b):e.jsx("span",{className:p,title:f.name,children:g},b)});else{const x=r.Children.toArray(t);h=x.length,m=(i?x.slice(0,i):x).map(b=>r.isValidElement(b)&&b.props.size==null?r.cloneElement(b,{size:a}):b)}const u=i?Math.max(0,h-i):0;return e.jsxs("div",{className:`nice-avatar-group nice-avatar-group--${a} ${s||""}`,style:o,"data-testid":d??c,children:[m,u>0&&e.jsxs("div",{className:p,style:{background:"var(--nice-text-muted)"},children:["+",u]})]})},Fh={xxs:4,xs:6,sm:8,md:12,lg:16,xl:20,xxl:28},rd=Object.assign(r.forwardRef(({children:t,items:n,renderCard:i,searchable:a,searchField:s="text",searchPlaceholder:o,emptyText:c,onCardClick:d,size:p="md",minColumnWidth:m=240,columns:h,gap:u,align:x="stretch",equalHeight:f=!1,value:b,onChange:g,name:v,disabled:y,readOnly:C,loading:w,error:E,errorText:S,className:N,style:_,testId:k,"data-testid":j},T)=>{const{t:P}=l.useNiceTranslation(),[B,R]=r.useState(""),I=h?`repeat(${h}, minmax(0, 1fr))`:`repeat(auto-fill, minmax(${m}px, 1fr))`,D=u??Fh[p]??12,M=typeof E=="string"?E.length>0:!!E,O=typeof E=="string"?E:E?S??"":"",L=n!=null&&i!=null,V=r.useMemo(()=>{if(!L||!B)return n??[];const se=B.toLowerCase();return(n??[]).filter(ce=>String(ce[s]??"").toLowerCase().includes(se))},[L,n,B,s]),ee=g!=null||b!=null,z=r.useMemo(()=>({value:b,onChange:se=>{!y&&!C&&g?.(se)},name:v}),[b,g,v,y,C]),U=f?"stretch":x,re=f?"1fr":void 0,Y=`nice-card-group nice-card-group--${p}${f?" nice-card-group--equal":""}${y?" nice-card-group--disabled":""}${C?" nice-card-group--readonly":""}${w?" nice-card-group--loading":""}${M?" nice-card-group--error":""}${N?` ${N}`:""}`;if(L)return e.jsx(Be.NiceCardGroupSizeContext.Provider,{value:p,children:e.jsxs("div",{ref:T,className:Y,style:{position:"relative",..._},"aria-disabled":y||void 0,"aria-busy":w||void 0,"data-testid":j??k,children:[a&&e.jsx("div",{className:"nice-card-group__search",children:e.jsx("input",{type:"text",value:B,onChange:se=>R(se.target.value),placeholder:o||P("controls.search","Search...")})}),w?e.jsx("div",{className:"nice-card-group__empty",children:e.jsx("span",{className:"nice-spinner nice-spinner--md"})}):V.length===0?e.jsx("div",{className:"nice-card-group__empty",children:c||P("controls.noData","No data available")}):e.jsx("div",{className:"nice-card-group__grid",style:{display:"grid",gridTemplateColumns:I,gridAutoRows:re,gap:D,alignItems:U},children:V.map(se=>e.jsx("div",{className:"nice-card-group__data-card",onClick:d?()=>d(se):void 0,onKeyDown:d?ce=>{ce.target===ce.currentTarget&&(ce.key==="Enter"||ce.key===" ")&&(ce.preventDefault(),d(se))}:void 0,role:d?"button":void 0,tabIndex:d?0:void 0,style:d?{cursor:"pointer"}:void 0,children:i(se)},se.key))}),O&&e.jsx("div",{className:"nice-card-group__error",role:"alert",children:O})]})});const oe=e.jsxs("div",{ref:T,className:Y,style:{display:"grid",gridTemplateColumns:I,gridAutoRows:re,gap:D,alignItems:U,position:w?"relative":void 0,..._},role:ee?"radiogroup":void 0,"aria-label":ee?v:void 0,"aria-disabled":y||void 0,"aria-busy":w||void 0,"data-testid":j??k,children:[t,w&&e.jsx("span",{className:"nice-card-group__spinner","aria-hidden":"true",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})}),O&&!f&&e.jsx("div",{className:"nice-card-group__error",role:"alert",style:{gridColumn:"1 / -1"},children:O})]}),q=O&&f&&e.jsx("div",{className:"nice-card-group__error",role:"alert",children:O});return e.jsxs(Be.NiceCardGroupSizeContext.Provider,{value:p,children:[ee?e.jsx(Be.NiceCardRadioContext.Provider,{value:z,children:oe}):oe,q]})}),{displayName:"NiceCardGroup"}),qh={color:!0,description:!0,volume:!0,gain:!0},Hr=r.forwardRef(function(n,i){const{t:a}=l.useNiceTranslation(),{children:s,name:o,description:c,defaultDescription:d,onDescriptionChange:p,labelPlacement:m="bottom",number:h,color:u="transparent",onColorChange:x,volume:f,defaultVolume:b,onVolumeChange:g,gain:v,defaultGain:y,onGainChange:C,contextMenu:w=!0,quickControls:E,onOpenConfig:S,fullConfigLabel:N=a("deviceTile.fullConfiguration","Full configuration"),selected:_,onClick:k,focusId:j,className:T,style:P,title:B,"data-testid":R}=n,I={...qh,...E},D=r.useRef(null),M=J=>{D.current=J,typeof i=="function"?i(J):i&&(i.current=J)},O=D;l.useSpatialFocusable(O,{id:j??"",onActivate:k,disabled:!j});const[L,V]=l.useControllableState({value:c,defaultValue:d,fallbackValue:"",onChange:p,componentName:"NiceDeviceTile"}),[ee,z]=l.useControllableState({value:f,defaultValue:b,fallbackValue:80,onChange:g,componentName:"NiceDeviceTile"}),[U,re]=l.useControllableState({value:v,defaultValue:y,fallbackValue:50,onChange:C,componentName:"NiceDeviceTile"}),Y=l.useSpatialNavOptional(),[oe,q]=r.useState(null),se=r.useRef(null);l.useClickOutside(se,()=>q(null)),r.useEffect(()=>{if(oe)return Y?.pauseNavigation(),()=>{Y?.resumeNavigation()}},[oe,Y]),l.useOverlayFocus(se,{open:oe!=null,modal:!1,onClose:()=>q(null)});const ce=J=>{if(!w)return;J.preventDefault();let{clientX:me,clientY:je}=J;if(me===0&&je===0){const H=J.currentTarget.getBoundingClientRect();me=H.left,je=H.bottom}const ue=Math.min(me,window.innerWidth-256),F=Math.min(je,window.innerHeight-320);q({x:Math.max(8,ue),y:Math.max(8,F)})},le=u!=="transparent"&&u!=="";return e.jsxs("div",{ref:M,className:["nice-device-tile",`nice-device-tile--label-${m}`,_?"nice-device-tile--selected":"",le?"nice-device-tile--colored":"",T??""].filter(Boolean).join(" "),style:{...P,"--device-color":u},title:B,"data-testid":R,onClick:k,onKeyDown:k?J=>{J.target===J.currentTarget&&(J.key==="Enter"||J.key===" ")&&(J.preventDefault(),J.currentTarget.click())}:void 0,onContextMenu:ce,role:k?"button":void 0,tabIndex:j||k?0:void 0,children:[e.jsxs("div",{className:"nice-device-tile__device",children:[h!=null&&e.jsx("span",{className:"nice-device-tile__badge",children:h}),s]}),(o||L)&&e.jsxs("div",{className:"nice-device-tile__caption",children:[o&&e.jsx("span",{className:"nice-device-tile__name",children:o}),L&&e.jsx("span",{className:"nice-device-tile__description",children:L})]}),oe&&e.jsx("div",{ref:se,className:"nice-device-tile__menu",style:{position:"fixed",left:oe.x,top:oe.y},role:"dialog","aria-label":o,children:e.jsxs("div",{style:{display:"contents"},onClick:J=>J.stopPropagation(),onKeyDown:J=>{J.key!=="Escape"&&J.stopPropagation()},children:[o&&e.jsx("div",{className:"nice-device-tile__menu-title",children:o}),I.color&&e.jsxs("div",{className:"nice-device-tile__menu-row",children:[e.jsx("span",{className:"nice-device-tile__menu-label",children:a("deviceTile.color","Color")}),e.jsx(bn.NiceColorPicker,{compact:!0,value:le?u:"#3b82f6",onChange:J=>x?.(J)})]}),I.description&&e.jsxs("div",{className:"nice-device-tile__menu-row nice-device-tile__menu-row--stack",children:[e.jsx("span",{className:"nice-device-tile__menu-label",children:a("deviceTile.description","Description")}),e.jsx(Oe.NiceTextInput,{value:L,onChange:J=>V(J),size:"sm"})]}),I.volume&&e.jsxs("div",{className:"nice-device-tile__menu-row",children:[e.jsx("span",{className:"nice-device-tile__menu-label",children:a("deviceTile.volume","Volume")}),e.jsx(dt.NiceSlider,{value:ee,onChange:J=>z(J),min:0,max:100})]}),I.gain&&e.jsxs("div",{className:"nice-device-tile__menu-row",children:[e.jsx("span",{className:"nice-device-tile__menu-label",children:a("deviceTile.gain","Gain")}),e.jsx(dt.NiceSlider,{value:U,onChange:J=>re(J),min:0,max:100})]}),S&&e.jsx(Fe.NiceButton,{size:"sm",variant:"outline",className:"nice-device-tile__menu-config",onClick:()=>{q(null),S()},children:N})]})})]})}),Vh={xxs:20,xs:24,sm:32,md:40,lg:56,xl:72,xxl:96},Ma=15,wi=18,Oa=6,na=30,od=({level:t=0,size:n="md",muted:i=!1,...a})=>{const{t:s}=l.useNiceTranslation(),c=`nice-mic-clip-${l.useControlId()}`,d=typeof n=="number"?n:Vh[n]??40,p=Math.max(0,Math.min(1,t)),m=Oa+(1-p)*na,h=p*na;return e.jsx(Hr,{...a,children:e.jsxs("svg",{className:`nice-microphone${i?" nice-microphone--muted":""}`,width:d,height:d*(64/48),viewBox:"0 0 48 64",role:"img","aria-label":a.name?s("microphone.microphone","Microphone: {name}").replace("{name}",String(a.name)):s("microphone.microphone2","Microphone"),children:[e.jsx("defs",{children:e.jsx("clipPath",{id:c,children:e.jsx("rect",{x:Ma,y:Oa,width:wi,height:na,rx:wi/2})})}),e.jsxs("g",{clipPath:`url(#${c})`,children:[e.jsx("rect",{x:Ma,y:Oa,width:wi,height:na,className:"nice-microphone__body"}),h>0&&e.jsx("rect",{x:Ma,y:m,width:wi,height:h,className:"nice-microphone__level"})]}),e.jsx("rect",{x:Ma,y:Oa,width:wi,height:na,rx:wi/2,className:"nice-microphone__outline"}),e.jsx("path",{d:"M10 30 a14 14 0 0 0 28 0",className:"nice-microphone__stand"}),e.jsx("line",{x1:"24",y1:"44",x2:"24",y2:"56",className:"nice-microphone__stand"}),e.jsx("line",{x1:"16",y1:"56",x2:"32",y2:"56",className:"nice-microphone__stand"}),i&&e.jsx("line",{x1:"9",y1:"9",x2:"39",y2:"49",className:"nice-microphone__slash"})]})})},Uh={xxs:22,xs:28,sm:36,md:48,lg:64,xl:84,xxl:110},Hh=[{id:"LT",shape:{kind:"rect",x:18,y:3,w:16,h:5,rx:2},label:[26,1]},{id:"RT",shape:{kind:"rect",x:66,y:3,w:16,h:5,rx:2},label:[74,1]},{id:"LB",shape:{kind:"rect",x:18,y:10,w:16,h:5,rx:2},label:[26,9]},{id:"RB",shape:{kind:"rect",x:66,y:10,w:16,h:5,rx:2},label:[74,9]},{id:"DpadUp",shape:{kind:"rect",x:25,y:26,w:5,h:6,rx:1},label:[27,24]},{id:"DpadDown",shape:{kind:"rect",x:25,y:38,w:5,h:6,rx:1},label:[27,50]},{id:"DpadLeft",shape:{kind:"rect",x:18,y:32,w:6,h:5,rx:1},label:[16,35]},{id:"DpadRight",shape:{kind:"rect",x:31,y:32,w:6,h:5,rx:1},label:[40,35]},{id:"Y",shape:{kind:"circle",cx:74,cy:25,r:4},label:[74,19]},{id:"A",shape:{kind:"circle",cx:74,cy:41,r:4},label:[74,51]},{id:"X",shape:{kind:"circle",cx:66,cy:33,r:4},label:[58,35]},{id:"B",shape:{kind:"circle",cx:82,cy:33,r:4},label:[90,35]},{id:"Back",shape:{kind:"circle",cx:44,cy:26,r:2.6},label:[44,20]},{id:"Start",shape:{kind:"circle",cx:56,cy:26,r:2.6},label:[56,20]},{id:"LS",shape:{kind:"circle",cx:42,cy:42,r:6},label:[42,54]},{id:"RS",shape:{kind:"circle",cx:60,cy:44,r:6},label:[60,56]}],Gh="M50 18 C66 18 72 20 76 26 L90 48 C94 58 86 64 80 58 L66 46 L34 46 L20 58 C14 64 6 58 10 48 L24 26 C28 20 34 18 50 18 Z";function Wh({shape:t}){return t.kind==="circle"?e.jsx("circle",{cx:t.cx,cy:t.cy,r:t.r}):e.jsx("rect",{x:t.x,y:t.y,width:t.w,height:t.h,rx:t.rx??1})}const cd=({view:t="compact",size:n="md",onButtonPress:i,pressedButtons:a,highlightedButtons:s,live:o=!1,gamepadIndex:c=0,buttonLabels:d,actionTree:p,assignments:m,onAssign:h,...u})=>{const{t:x}=l.useNiceTranslation(),f=typeof n=="number"?n:Uh[n]??48,[b,g]=r.useState(()=>new Set),[v,y]=r.useState(null);l.useGamepad({index:c,enabled:o,onButtonDown:P=>{g(B=>{const R=new Set(B);return R.add(P),R}),i?.(P)},onButtonUp:P=>{g(B=>{const R=new Set(B);return R.delete(P),R})}});const C=P=>!!s?.includes(P)||!!a?.includes(P)||b.has(P),w=f*1.5,E=w*(68/100),S=(P,B)=>{P.stopPropagation(),i?.(B),p&&y(R=>R===B?null:B)},N=t==="compact",_=!N&&(!!i||!!p),k=r.useRef(null);l.useRovingFocus(k,{orientation:"grid",itemSelector:".nice-gamepad__btn",enabled:_});const j=e.jsxs("svg",{className:`nice-gamepad nice-gamepad--${t}${_?" nice-gamepad--interactive":""}`,width:w,height:E,viewBox:"0 0 100 68",role:_?"group":"img","aria-label":u.name?x("gamepad.gamepad","Gamepad: {name}").replace("{name}",String(u.name)):x("gamepad.gamepad2","Gamepad"),children:[e.jsx("path",{d:Gh,className:"nice-gamepad__body"}),!N&&Hh.map(({id:P,shape:B,label:R})=>{const I=d?.[P]??m?.[P];return e.jsxs("g",{"data-button":P,"data-pressed":C(P)?"true":void 0,className:`nice-gamepad__btn${v===P?" nice-gamepad__btn--armed":""}`,role:_?"button":void 0,"aria-label":_?I?`${P} ${I}`:P:void 0,"aria-pressed":_&&p?v===P:void 0,onClick:D=>S(D,P),onKeyDown:D=>{_&&(D.key==="Enter"||D.key===" ")&&(D.preventDefault(),S(D,P))},children:[e.jsx(Wh,{shape:B}),I&&e.jsx("text",{x:R[0],y:R[1],className:"nice-gamepad__label",children:I})]},P)})]}),T=_?e.jsx("div",{ref:k,className:"nice-gamepad__pad",children:j}):j;return e.jsx(Hr,{...u,children:p&&!N?e.jsxs("div",{className:"nice-gamepad__assign",children:[T,e.jsxs("div",{className:"nice-gamepad__tree",children:[e.jsx("div",{className:"nice-gamepad__tree-hint",children:v?x("gamepad.assignTo",'Assign to "{armed}"…').replace("{armed}",String(v)):x("gamepad.clickAButtonThenA","Click a button, then a node")}),e.jsx(ft.NiceTreeView,{nodes:p,selectionMode:"single",onNodeClick:P=>{v&&(h?.(v,P),y(null))}})]})]}):T})},Kh=[],Yh=({devices:t,defaultDevices:n,onDevicesChange:i,autoDetect:a=!0,kinds:s=["microphone","gamepad"],slots:o,onAssign:c,onOpenConfig:d,columns:p,minColumnWidth:m=160,className:h,style:u,id:x,"data-testid":f})=>{const{t:b}=l.useNiceTranslation(),[g,v]=l.useControllableState({value:t,defaultValue:n,fallbackValue:Kh,onChange:i,componentName:"NiceDeviceManager"}),y=r.useCallback(N=>{N.length!==0&&v(_=>{const k=new Set(_.map(T=>T.id)),j=N.filter(T=>!k.has(T.id));return j.length?[..._,...j]:_})},[v]);r.useEffect(()=>{if(!a||!s.includes("microphone")||!navigator.mediaDevices?.enumerateDevices)return;let N=!1;const _=()=>{navigator.mediaDevices.enumerateDevices().then(k=>{if(N)return;const j=k.filter(T=>T.kind==="audioinput").map((T,P)=>({id:`mic:${T.deviceId||P}`,kind:"microphone",name:T.label||`Microphone ${P+1}`,deviceId:T.deviceId}));y(j)}).catch(()=>{})};return _(),navigator.mediaDevices.addEventListener?.("devicechange",_),()=>{N=!0,navigator.mediaDevices.removeEventListener?.("devicechange",_)}},[a,s,y]);const C=l.useConnectedGamepads(),w=a&&s.includes("gamepad");r.useEffect(()=>{w&&y(C.map(N=>({id:`pad:${N.index}`,kind:"gamepad",name:N.id.split("(")[0]?.trim()||`Controller ${N.index+1}`,deviceId:String(N.index)})))},[w,C,y]);const E=r.useCallback((N,_)=>{v(k=>k.map(j=>j.id===N?{...j,..._}:j))},[v]),S=r.useCallback((N,_)=>{E(N,{assignedTo:_}),c?.(N,_)},[E,c]);return e.jsx("div",{id:x,"data-testid":f,className:`nice-device-manager ${h??""}`.trim(),style:u,children:g.length===0?e.jsx("p",{className:"nice-device-manager__empty",children:b("deviceManager.noDevicesDetected","No devices detected.")}):e.jsx(rd,{columns:p,minColumnWidth:m,gap:12,children:g.map((N,_)=>{const k={name:N.name,description:N.description,number:N.number??_+1,color:N.color??"transparent",volume:N.volume,gain:N.gain,onColorChange:j=>E(N.id,{color:j}),onDescriptionChange:j=>E(N.id,{description:j}),onVolumeChange:j=>E(N.id,{volume:j}),onGainChange:j=>E(N.id,{gain:j}),onOpenConfig:()=>d?.(N)};return e.jsxs("div",{className:"nice-device-manager__cell",children:[N.kind==="microphone"?e.jsx(od,{...k,level:N.level}):e.jsx(cd,{...k,view:"compact",live:!0}),o&&o.length>0&&e.jsx("div",{className:"nice-device-manager__slots",children:o.map(j=>e.jsx(Fe.NiceButton,{size:"sm",variant:N.assignedTo===j.id?"primary":"ghost",onClick:()=>S(N.id,N.assignedTo===j.id?null:j.id),children:j.label},j.id))})]},N.id)})})})},Jh=[];function rc(t,n){const i=t.getBoundingClientRect(),a=n.getBoundingClientRect(),s=getComputedStyle(t),o=parseFloat(s.borderLeftWidth)||0,c=parseFloat(s.borderTopWidth)||0;return{width:a.width,height:a.height,left:0,top:0,transform:`translate(${a.left-i.left-o}px, ${a.top-i.top-c}px)`,opacity:1}}function on({options:t=Jh,value:n,defaultValue:i,onChange:a,size:s="md",block:o=!1,disabled:c=!1,readOnly:d=!1,loading:p=!1,error:m,highlightFill:h=!0,errorPlacement:u="bottom",className:x="",style:f,"data-testid":b="nice-segmented-control"}){const{t:g}=l.useNiceTranslation(),v=r.useRef(null),[y,C]=r.useState(i),[w,E]=r.useState({}),S=n!==void 0?n:y,N=t.findIndex(j=>j.value===S);r.useEffect(()=>{if(!v.current||N<0){E({opacity:0});return}const j=v.current,P=j.querySelectorAll(".nice-segmented-control__option")[N];if(!P){E({opacity:0});return}E(rc(j,P))},[N,t.length,h,s,o]),r.useEffect(()=>{const j=()=>{if(!v.current||N<0)return;const T=v.current,B=T.querySelectorAll(".nice-segmented-control__option")[N];B&&E(rc(T,B))};return window.addEventListener("resize",j),()=>window.removeEventListener("resize",j)},[N]);const _=r.useCallback(j=>{c||d||p||t.find(P=>P.value===j)?.disabled||(n===void 0&&C(j),a?.(j))},[c,d,p,t,n,a]);l.useRovingFocus(v,{orientation:"both",wrap:!0,activateOnMove:!0});const k=e.jsxs("div",{ref:v,className:`nice-segmented-control nice-segmented-control--${s} ${o?"nice-segmented-control--block":""} ${c?"nice-segmented-control--disabled":""} ${d?"nice-segmented-control--readonly":""} ${p?"nice-segmented-control--loading":""} ${m?"nice-segmented-control--error":""} ${h?"nice-segmented-control--fill":""} ${x}`,style:f,role:"radiogroup","aria-label":g("controls.select","Select option"),"aria-busy":p||void 0,"aria-invalid":!!m||void 0,"data-testid":b,children:[e.jsx("div",{className:"nice-segmented-control__thumb",style:w}),t.map((j,T)=>{const P=j.value===S,B=c||j.disabled;return e.jsxs("button",{type:"button",className:`nice-segmented-control__option ${P?"nice-segmented-control__option--selected":""} ${B?"nice-segmented-control__option--disabled":""}`,onClick:()=>_(j.value),disabled:B||p,role:"radio","aria-checked":P,"data-testid":`${b}-option-${T}`,children:[j.icon&&e.jsx("span",{className:"nice-segmented-control__icon",children:j.icon}),e.jsx("span",{className:"nice-segmented-control__label",children:j.label})]},String(j.value))}),p&&e.jsx("div",{className:"nice-segmented-control__spinner","aria-hidden":"true",children:e.jsx("div",{className:"nice-spinner nice-spinner--sm"})})]});return m?e.jsxs("div",{className:`nice-segmented-control-field${u==="right"?" nice-segmented-control-field--err-right":""}`,children:[k,e.jsx("div",{className:"nice-segmented-control__error",role:"alert",children:m})]}):k}process.env.NODE_ENV!=="production"&&(on.displayName="NiceSegmentedControl");const Qh=["gamepad","hints","navigation","bindings"],Xh=["activate","back","secondary","tertiary","menu","view","sectionPrev","sectionNext","pagePrev","pageNext","first","last","toggleHints"],Ls={navigate:"Move",activate:"Select",back:"Back",secondary:"Options",tertiary:"More",menu:"Menu",view:"Switch area",sectionPrev:"Previous section",sectionNext:"Next section",pagePrev:"Previous page",pageNext:"Next page",first:"First",last:"Last",scroll:"Scroll",toggleHints:"Show or hide hints"},Zh=Object.assign(function({sections:n=Qh,className:i,style:a,id:s,"data-testid":o}){const{t:c}=l.useNiceTranslation(),[d,p]=l.useInputPreferences(),[m,h]=r.useState(null);r.useEffect(()=>{if(!(!m||typeof window>"u"))return l.getInputEngine().captureNextInput(g=>{m.device==="gamepad"&&g.button?p({gamepadBindings:{...d.gamepadBindings,[m.intent]:[g.button]}}):m.device==="keyboard"&&g.keys&&p({keyboardBindings:{...d.keyboardBindings,[m.intent]:[g.keys]}}),h(null)})},[m,d.gamepadBindings,d.keyboardBindings,p]);const u=(g,v)=>p({[g]:v}),x=c("inputSettings.auto","Automatic"),f=g=>{const{[g]:v,...y}=d.gamepadBindings,{[g]:C,...w}=d.keyboardBindings;p({gamepadBindings:y,keyboardBindings:w})},b=g=>{switch(g){case"gamepad":return e.jsxs("section",{className:"nice-input-settings__section",children:[e.jsx("h3",{className:"nice-input-settings__title",children:c("inputSettings.section.gamepad","Gamepad")}),e.jsxs("div",{className:"nice-input-settings__field",children:[e.jsx("span",{className:"nice-input-settings__label",children:c("inputSettings.confirmButton","Confirm with")}),e.jsx(on,{value:d.confirmButton,onChange:v=>u("confirmButton",v),options:[{value:"auto",label:x},{value:"south",label:c("input.pad.bottomButton","Bottom button")},{value:"east",label:c("input.pad.rightButton","Right button")}]})]}),e.jsx(Oe.NiceSelect,{label:c("inputSettings.glyphFamily","Button symbols"),value:d.glyphFamily,onChange:v=>u("glyphFamily",v),options:[{value:"auto",label:x},{value:"xbox",label:"Xbox"},{value:"playstation",label:"PlayStation"},{value:"nintendo",label:"Nintendo"},{value:"steam",label:"Steam"},{value:"generic",label:c("inputSettings.family.generic","Generic")}]}),e.jsx(dt.NiceSlider,{label:c("inputSettings.stickThreshold","Stick push needed to move"),min:.2,max:.9,step:.05,value:d.stickThreshold,onChange:v=>u("stickThreshold",v),showValue:!0}),e.jsx(dt.NiceSlider,{label:c("inputSettings.repeatDelay","Repeat after (ms)"),min:200,max:800,step:20,value:d.repeatDelay,onChange:v=>u("repeatDelay",v),showValue:!0}),e.jsx(dt.NiceSlider,{label:c("inputSettings.repeatInterval","Repeat every (ms)"),min:50,max:250,step:10,value:d.repeatInterval,onChange:v=>u("repeatInterval",v),showValue:!0}),e.jsx(Vt.NiceToggle,{label:c("inputSettings.invertScroll","Invert scrolling with the right stick"),checked:d.invertScroll,onChange:v=>u("invertScroll",v)}),e.jsx(Vt.NiceToggle,{label:c("inputSettings.vibration","Vibration"),checked:d.vibration,onChange:v=>u("vibration",v)})]},g);case"hints":return e.jsxs("section",{className:"nice-input-settings__section",children:[e.jsx("h3",{className:"nice-input-settings__title",children:c("inputSettings.section.hints","Button hints")}),e.jsxs("div",{className:"nice-input-settings__field",children:[e.jsx("span",{className:"nice-input-settings__label",children:c("inputSettings.hints","Show hints")}),e.jsx(on,{value:d.hints,onChange:v=>u("hints",v),options:[{value:"auto",label:c("inputSettings.hints.auto","With keyboard or pad")},{value:"always",label:c("inputSettings.always","Always")},{value:"never",label:c("inputSettings.never","Never")}]})]}),e.jsxs("div",{className:"nice-input-settings__field",children:[e.jsx("span",{className:"nice-input-settings__label",children:c("inputSettings.hintDensity","Where")}),e.jsx(on,{value:d.hintDensity,onChange:v=>u("hintDensity",v),options:[{value:"bar",label:c("inputSettings.density.bar","Hint bar")},{value:"bar-and-controls",label:c("inputSettings.density.barAndControls","Bar and controls")}]})]})]},g);case"navigation":return e.jsxs("section",{className:"nice-input-settings__section",children:[e.jsx("h3",{className:"nice-input-settings__title",children:c("inputSettings.section.navigation","Navigation")}),e.jsxs("div",{className:"nice-input-settings__field",children:[e.jsx("span",{className:"nice-input-settings__label",children:c("inputSettings.arrowNavigation","Arrow keys outside lists")}),e.jsx(on,{value:d.arrowNavigation,onChange:v=>u("arrowNavigation",v),options:[{value:"auto",label:c("inputSettings.arrows.auto","Depends on the area")},{value:"spatial",label:c("inputSettings.arrows.spatial","Move focus")},{value:"native",label:c("inputSettings.arrows.native","Scroll")}]})]}),e.jsxs("div",{className:"nice-input-settings__field",children:[e.jsx("span",{className:"nice-input-settings__label",children:c("inputSettings.onScreenKeyboard","On-screen keyboard")}),e.jsx(on,{value:d.onScreenKeyboard,onChange:v=>u("onScreenKeyboard",v),options:[{value:"auto",label:c("inputSettings.osk.auto","With a pad")},{value:"always",label:c("inputSettings.always","Always")},{value:"never",label:c("inputSettings.never","Never")}]})]})]},g);default:return e.jsxs("section",{className:"nice-input-settings__section",children:[e.jsx("h3",{className:"nice-input-settings__title",children:c("inputSettings.section.bindings","Buttons and keys")}),e.jsxs("table",{className:"nice-input-settings__bindings",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",children:c("inputSettings.actionColumn","Action")}),e.jsx("th",{scope:"col",children:c("inputSettings.gamepadColumn","Gamepad")}),e.jsx("th",{scope:"col",children:c("inputSettings.keyboardColumn","Keyboard")}),e.jsx("th",{scope:"col",children:e.jsx("span",{className:"nice-sr-only",children:c("inputSettings.reset","Reset")})})]})}),e.jsx("tbody",{children:Xh.map(v=>{const y=w=>m?.intent===v&&m.device===w,C=(d.keyboardBindings[v]??l.NICE_DEFAULT_KEYBOARD_BINDINGS[v])[0];return e.jsxs("tr",{children:[e.jsx("th",{scope:"row",className:"nice-input-settings__action",children:c(`input.intent.${v}`,Ls[v])}),e.jsx("td",{children:e.jsx(Fe.NiceButton,{size:"sm",variant:"ghost",onClick:()=>h({intent:v,device:"gamepad"}),"aria-label":`${c("inputSettings.change","Change")}: ${c(`input.intent.${v}`,Ls[v])}`,children:y("gamepad")?c("inputSettings.pressButton","Press a button…"):e.jsx(l.NiceButtonPrompt,{intent:v,device:"gamepad",size:"sm"})})}),e.jsx("td",{children:e.jsx(Fe.NiceButton,{size:"sm",variant:"ghost",onClick:()=>h({intent:v,device:"keyboard"}),"aria-label":`${c("inputSettings.change","Change")}: ${c(`input.intent.${v}`,Ls[v])}`,children:y("keyboard")?c("inputSettings.pressKey","Press a key…"):C?e.jsx(l.NiceKeyCap,{keys:C,size:"sm"}):c("inputSettings.none","None")})}),e.jsx("td",{children:e.jsx(Fe.NiceButton,{size:"sm",variant:"ghost",onClick:()=>f(v),children:c("inputSettings.reset","Reset")})})]},v)})})]}),e.jsxs("div",{className:"nice-input-settings__actions",children:[m&&e.jsx(Fe.NiceButton,{size:"sm",onClick:()=>h(null),children:c("inputSettings.cancel","Cancel")}),e.jsx(Fe.NiceButton,{size:"sm",variant:"secondary",onClick:()=>p({gamepadBindings:{},keyboardBindings:{}}),children:c("inputSettings.resetAll","Reset all bindings")})]})]},g)}};return e.jsx("div",{id:s,"data-testid":o,className:`nice-input-settings${i?` ${i}`:""}`,style:a,children:n.map(b)})},{displayName:"NiceInputSettings"}),rs=({value:t,max:n=100,label:i,helperText:a,error:s,required:o,disabled:c,loading:d,showValue:p=!0,text:m,variant:h="primary",size:u="md",striped:x,animated:f,formatValue:b,labelPlacement:g="top",errorPlacement:v="bottom",labelWidth:y,controlWidth:C,className:w,style:E,id:S})=>{const N=l.useControlId(S),_=Math.min(100,Math.max(0,t/n*100)),k=m??(b?b(t,n):`${Math.round(_)}%`),j=p,T=i?e.jsxs("label",{className:"nice-field__label",htmlFor:N,children:[i,o&&e.jsx("span",{className:"nice-field__required",children:"*"})]}):null,P=s?e.jsx("div",{id:`${N}-error`,className:"nice-field__error",role:"alert",children:s}):null,B=!s&&a?e.jsx("div",{id:`${N}-helper`,className:"nice-field__helper",children:a}):null,R=e.jsxs("div",{className:`nice-progress ${c?"nice-progress--disabled":""} ${d?"nice-progress--loading":""}`,role:"progressbar",id:N,"aria-valuenow":t,"aria-valuemin":0,"aria-valuemax":n,"aria-busy":d||void 0,"aria-disabled":c||void 0,children:[e.jsx("div",{className:`nice-progress__track ${u!=="md"?`nice-progress__track--${u}`:""}`,children:e.jsx("div",{className:`nice-progress__fill nice-progress__fill--${h} ${x||d?"nice-progress__fill--striped":""} ${f||d?"nice-progress__fill--animated":""}`,style:{width:d?"100%":`${_}%`}})}),j&&(g==="left"||g==="right")&&e.jsx("span",{className:"nice-progress__value",children:k})]}),I=e.jsxs("div",{className:"nice-progress__header",children:[T,j&&e.jsx("span",{className:"nice-progress__value",children:k})]});return e.jsxs("div",{className:`nice-field nice-field--${u} nice-field--progress ${g==="left"?"nice-field--label-left":""} ${w||""}`,style:{...E,...y!=null&&{"--nice-field-label-width":typeof y=="number"?`${y}px`:y},...C!=null&&{"--nice-field-control-width":typeof C=="number"?`${C}px`:C}},children:[g==="top"&&(j?I:T),g==="left"||g==="right"?e.jsxs("div",{className:"nice-field__control",style:{display:"flex",alignItems:"center",gap:"var(--nice-space-2, 8px)",flex:"1 1 auto"},children:[g==="right"?e.jsxs(e.Fragment,{children:[R,T]}):e.jsxs(e.Fragment,{children:[T,R]}),v==="right"&&P,v==="right"&&!s&&B]}):e.jsx("div",{className:"nice-field__control",children:R}),g==="bottom"&&(j?I:T),v!=="right"&&P,v!=="right"&&B]})},ps=({vertical:t,text:n,size:i="md",className:a,style:s,testId:o,"data-testid":c})=>t?e.jsx("hr",{className:`nice-divider nice-divider--vertical nice-divider--${i} ${a||""}`,style:s,"data-testid":c??o}):n?e.jsx("div",{className:`nice-divider--with-text nice-divider--${i} ${a||""}`,style:s,"data-testid":c??o,children:n}):e.jsx("hr",{className:`nice-divider nice-divider--${i} ${a||""}`,style:s,"data-testid":c??o}),oc=t=>typeof t=="number"?t:/^\d+(\.\d+)?$/.test(t.trim())?`${t}px`:t,eg={text:14,rect:80,circle:40},tg={xxs:{text:6,rect:28,circle:16},xs:{text:8,rect:40,circle:24},sm:{text:11,rect:60,circle:32},small:{text:11,rect:60,circle:32},md:{text:14,rect:80,circle:40},medium:{text:14,rect:80,circle:40},lg:{text:20,rect:120,circle:56},large:{text:20,rect:120,circle:56},xl:{text:28,rect:160,circle:72},xxl:{text:36,rect:220,circle:96}},ha=({variant:t="text",width:n,height:i,count:a=1,size:s="md",orientation:o="vertical",animationSpeed:c,className:d,style:p,testId:m,"data-testid":h})=>{const u=tg[s]??eg,x=oc(n??(t==="circle"?u.circle:"100%")),f=oc(i??(t==="text"?u.text:t==="circle"?u.circle:u.rect)),b=c!=null&&c>0?{"--nice-skeleton-speed":`${c}s`}:null;if(a<=1)return e.jsx("div",{className:`nice-skeleton nice-skeleton--${t} nice-skeleton--${s} ${d||""}`,style:{width:x,height:f,...b,...p},"data-testid":h??m});const g=o==="horizontal";return e.jsx("div",{className:`nice-skeleton-group ${d||""}`,style:{display:"flex",flexDirection:g?"row":"column",gap:"var(--nice-space-2, 8px)",width:"100%",...b,...p},"data-testid":h??m,children:Array.from({length:a}).map((v,y)=>e.jsx("div",{className:`nice-skeleton nice-skeleton--${t} nice-skeleton--${s}`,style:g?{flex:"1 1 0",minWidth:0,height:f}:{width:x,height:f}},y))})},Gr=({icon:t,title:n,description:i,action:a,size:s="md",className:o,style:c,testId:d,"data-testid":p})=>e.jsxs("div",{className:`nice-empty nice-empty--${s} ${o||""}`,style:c,"data-testid":p??d,role:"status","aria-label":n,children:[t&&e.jsx("div",{className:"nice-empty__icon","aria-hidden":"true",children:t}),e.jsx("div",{className:"nice-empty__title",children:n}),i&&e.jsx("div",{className:"nice-empty__desc",children:i}),a]}),ng=[],cc={xxs:9,xs:11,sm:13,small:13,md:16,medium:16,lg:20,large:20,xl:24,xxl:28},ld=Object.assign(r.forwardRef(({items:t=ng,mode:n="left",size:i="md",isFragment:a=!1,renderItem:s,className:o,style:c,id:d,testId:p,"data-testid":m,...h},u)=>{const{renderIcon:x}=l.useNiceIcon(),f=cc[i]??cc.md;return e.jsx("div",{ref:u,id:d,className:`nice-timeline nice-timeline--${n} nice-timeline--${i} ${a?"nice-timeline--fragment":""} ${o||""}`,style:c,"data-testid":m??p,...h,children:t.map((b,g)=>{const v=n==="alternate"?g%2===0?"left":"right":n;return e.jsxs("div",{className:`nice-timeline__item nice-timeline__item--${v}`,children:[e.jsx("div",{className:"nice-timeline__dot",style:b.color?{borderColor:b.color,color:b.color}:void 0,children:x(b.icon,f)??e.jsx("span",{className:"nice-timeline__dot-inner",style:b.color?{background:b.color}:void 0})}),a&&g===0&&e.jsx("div",{className:"nice-timeline__connector nice-timeline__connector--leading"}),(g<t.length-1||a)&&e.jsx("div",{className:"nice-timeline__connector"}),e.jsx("div",{className:"nice-timeline__content",children:s?s(b,g):e.jsxs(e.Fragment,{children:[b.title&&e.jsx("div",{className:"nice-timeline__title",children:b.title}),b.subtitle&&e.jsx("div",{className:"nice-timeline__subtitle",children:b.subtitle}),b.content&&e.jsx("div",{className:"nice-timeline__body",children:b.content})]})})]},b.key)})})}),{displayName:"NiceTimeline"}),ig=[],dd=Object.assign(r.forwardRef(({items:t=ig,visibleCount:n=1,showArrows:i=!0,showDots:a=!0,autoPlay:s=7e3,circular:o=!0,activeIndex:c,onChange:d,size:p="md",fullWidth:m=!0,className:h,style:u,id:x,testId:f,"data-testid":b,...g},v)=>{const{t:y}=l.useNiceTranslation(),[C,w]=r.useState(0),E=r.useRef(void 0),N=c!=null&&typeof d=="function"?c:C,_=Math.max(1,Math.floor(n||1)),k=Math.max(0,t.length-_),j=r.useCallback(q=>{let se=q;o?se=(q%t.length+t.length)%t.length:se=Math.max(0,Math.min(k,q)),w(se),d?.(se)},[t.length,k,o,d]),T=r.useCallback(()=>j(N+1),[j,N]),P=r.useCallback(()=>j(N-1),[j,N]),[B,R]=r.useState(!1),[I,D]=r.useState(!1),[M,O]=r.useState(!1),L=s>0&&!M&&!B&&!I;r.useEffect(()=>{if(L)return E.current=setInterval(T,s),()=>clearInterval(E.current)},[L,s,T]);const V=o||N>0,ee=o||N<k,z=r.useRef(null);r.useEffect(()=>{const q=z.current?.children;q&&Array.from(q).forEach((se,ce)=>{se.toggleAttribute("inert",ce<N||ce>=N+_)})},[N,_,t.length]);const U=r.useRef(null),re=r.useCallback(q=>{U.current=q,typeof v=="function"?v(q):v&&(v.current=q)},[v]);l.useIntent(["sectionPrev","sectionNext"],q=>{if(q.intent==="sectionNext"?!ee:!V)return!1;q.intent==="sectionNext"?T():P()},{ref:U,enabled:t.length>_}),l.useInputHints(U,[{intent:"sectionPrev",label:y("carousel.prev","Previous slide")},{intent:"sectionNext",label:y("carousel.next","Next slide")}],{enabled:t.length>_});const Y=r.useCallback(q=>{q.target===q.currentTarget&&(q.key==="ArrowLeft"&&V?(q.preventDefault(),P()):q.key==="ArrowRight"&&ee?(q.preventDefault(),T()):q.key==="Home"?(q.preventDefault(),j(0)):q.key==="End"&&(q.preventDefault(),j(k)))},[P,T,j,V,ee,k]),oe=r.useRef(null);return l.useRovingFocus(oe,{orientation:"horizontal",activateOnMove:!0}),e.jsxs("div",{ref:re,id:x,className:`nice-carousel nice-carousel--${p} ${m?"nice-carousel--full-width":""} ${h||""}`,style:u,"data-testid":b??f,role:"region","aria-roledescription":"carousel","aria-label":y("carousel.label","Carousel"),tabIndex:0,onKeyDown:Y,onMouseEnter:()=>R(!0),onMouseLeave:()=>R(!1),onFocus:()=>D(!0),onBlur:q=>{q.currentTarget.contains(q.relatedTarget)||D(!1)},...g,children:[s>0&&e.jsx("button",{type:"button",className:"nice-carousel__rotation",onClick:()=>O(q=>!q),"aria-label":M?y("carousel.startRotation","Start automatic slide show"):y("carousel.stopRotation","Stop automatic slide show"),children:e.jsx(l.NiceIcon,{name:M?"play":"pause",size:16})}),e.jsx("div",{className:"nice-carousel__viewport","aria-live":L?"off":"polite",children:e.jsx("div",{ref:z,className:"nice-carousel__track",style:{transform:`translateX(-${N*(100/_)}%)`,"--nice-carousel-slide-basis":`${100/_}%`},children:t.map((q,se)=>e.jsx("div",{className:"nice-carousel__slide",role:"group","aria-roledescription":"slide","aria-label":`${se+1} / ${t.length}`,children:q},se))})}),i&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"nice-carousel__arrow nice-carousel__arrow--prev",onClick:P,disabled:!V,"aria-label":y("carousel.prev","Previous"),children:e.jsx(l.NiceIcon,{name:"chevron-left",size:20})}),e.jsx("button",{type:"button",className:"nice-carousel__arrow nice-carousel__arrow--next",onClick:T,disabled:!ee,"aria-label":y("carousel.next","Next"),children:e.jsx(l.NiceIcon,{name:"chevron-right",size:20})})]}),a&&t.length>_&&e.jsx("div",{className:"nice-carousel__dots",role:"tablist",ref:oe,children:Array.from({length:k+1},(q,se)=>e.jsx("button",{type:"button",className:`nice-carousel__dot ${se===N?"nice-carousel__dot--active":""}`,onClick:()=>j(se),role:"tab","aria-selected":se===N,"aria-label":`${y("carousel.goTo","Go to slide")} ${se+1}`},se))})]})}),{displayName:"NiceCarousel"}),ag=[];function sg({items:t=ag,itemHeight:n,height:i=400,overscan:a=3,renderItem:s,itemKey:o,className:c,style:d,size:p="md",disabled:m,readOnly:h,loading:u,error:x,testId:f,"data-testid":b,...g},v){const y=r.useRef(null),[C,w]=r.useState(0),E=typeof i=="number"?i:parseFloat(String(i)),S=Number.isFinite(E)?E:400,N=Number.isFinite(n)&&n>0?n:1,_=Number.isFinite(a)&&a>=0?Math.floor(a):0,k=t.length*N,{startIndex:j,endIndex:T}=r.useMemo(()=>{const R=Math.max(1,Math.ceil(S/N)),I=Math.floor(C/N),D=Math.max(0,I-_),M=Math.min(t.length-1,I+R+_);return{startIndex:D,endIndex:M}},[C,S,N,t.length,_]),P=r.useCallback(R=>{w(R.currentTarget.scrollTop)},[]);r.useEffect(()=>{v&&(typeof v=="function"?v(y.current):v.current=y.current)},[v]);const B=r.useMemo(()=>{const R=[];for(let I=j;I<=T;I++){const D=o?o(t[I],I):I;R.push(e.jsx("div",{className:"nice-virtual-scroller__item",style:{position:"absolute",top:I*N,left:0,right:0,height:N},children:s(t[I],I)},D))}return R},[j,T,t,N,s,o]);return e.jsxs("div",{ref:y,className:`nice-virtual-scroller nice-virtual-scroller--${p} ${m?"nice-virtual-scroller--disabled":""} ${x?"nice-virtual-scroller--error":""} ${c||""}`,style:{width:"100%",...d,height:typeof i=="string"&&!/^\d+(\.\d+)?$/.test(i)?i:S,overflow:"auto",position:"relative"},onScroll:P,role:"list","aria-disabled":m||void 0,"aria-busy":u||void 0,"data-testid":b??f,...g,children:[x?e.jsx("div",{className:"nice-virtual-scroller__error",role:"alert",children:x}):e.jsx("div",{style:{height:k,position:"relative",width:"100%"},children:B}),u&&e.jsx("div",{className:"nice-virtual-scroller__loading","aria-hidden":"true",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})})]})}const ud=Object.assign(r.forwardRef(sg),{displayName:"NiceVirtualScroller"}),rg=[],pd=r.createContext(null);function Ts(){const t=r.useContext(pd);if(!t)throw new Error("useFAQ must be used within NiceFAQ");return t}function La(t,n){if(!n)return{score:1,indices:[]};const i=t.toLowerCase(),s=n.toLowerCase().split(/\s+/).filter(Boolean);let o=0;const c=[];for(const p of s){let m=!1,h=0;for(;(h=i.indexOf(p,h))!==-1;){m=!0,c.push([h,h+p.length]);const u=h===0||/\s/.test(t[h-1]),x=h+p.length===t.length||/\s/.test(t[h+p.length]);u&&x?o+=2:u?o+=1.5:o+=1,h+=1}if(!m){let u=0,x=-1;for(let f=0;f<i.length&&u<p.length;f++)if(i[f]===p[u]){if(x===-1||f===x+1)if(x===-1)c.push([f,f+1]);else{const b=c[c.length-1];b[1]=f+1}else c.push([f,f+1]);x=f,u++}if(u===p.length)o+=.5;else return null}}const d=og(c);return{score:o/s.length,indices:d}}function og(t){if(t.length===0)return[];const n=[...t].sort((a,s)=>a[0]-s[0]),i=[n[0]];for(let a=1;a<n.length;a++){const s=i[i.length-1],o=n[a];o[0]<=s[1]?s[1]=Math.max(s[1],o[1]):i.push(o)}return i}function cg(t,n){if(!n.trim())return t.map(a=>({item:a,score:1,matches:[]}));const i=[];for(const a of t){const s=[];let o=0;const c=La(a.question,n);if(c&&c.score>0&&(s.push({field:"question",indices:c.indices}),o+=c.score*3),typeof a.answer=="string"){const d=La(a.answer,n);d&&d.score>0&&(s.push({field:"answer",indices:d.indices}),o+=d.score*1)}if(a.tags)for(const d of a.tags){const p=La(d,n);if(p&&p.score>0){s.push({field:"tags",indices:p.indices}),o+=p.score*2;break}}if(a.keywords)for(const d of a.keywords){const p=La(d,n);if(p&&p.score>0){s.push({field:"keywords",indices:p.indices}),o+=p.score*2.5;break}}s.length>0&&(a.featured&&(o*=1.2),i.push({item:a,score:o,matches:s}))}return i.sort((a,s)=>s.score-a.score)}const lg=({text:t,indices:n})=>{if(n.length===0)return e.jsx(e.Fragment,{children:t});const i=[];let a=0;for(const[s,o]of n)s>a&&i.push(e.jsx("span",{children:t.slice(a,s)},`text-${a}`)),i.push(e.jsx("mark",{className:"nice-faq-highlight",children:t.slice(s,o)},`mark-${s}`)),a=o;return a<t.length&&i.push(e.jsx("span",{children:t.slice(a)},`text-${a}`)),e.jsx(e.Fragment,{children:i})},md=({placeholder:t,autoFocus:n=!1,showIcon:i=!0,debounceMs:a=200})=>{const{t:s}=l.useNiceTranslation(),o=t??s("faq.searchFaqPlaceholder","Search FAQ..."),{searchQuery:c,setSearchQuery:d}=Ts(),[p,m]=r.useState(c),h=r.useRef(null),u=r.useRef(null);r.useEffect(()=>(u.current&&clearTimeout(u.current),u.current=setTimeout(()=>{d(p)},a),()=>{u.current&&clearTimeout(u.current)}),[p,a,d]);const x=r.useCallback(()=>{m(""),d(""),h.current?.focus()},[d]);return e.jsxs("div",{className:"nice-faq-search",children:[i&&e.jsx("span",{className:"nice-faq-search-icon",children:e.jsx(l.NiceIcon,{name:"search",size:16})}),e.jsx("input",{ref:h,type:"text",className:"nice-faq-search-input",placeholder:o,value:p,onChange:f=>m(f.target.value),autoFocus:n,"aria-label":s("faq.searchFaq","Search FAQ")}),p&&e.jsx("button",{className:"nice-faq-search-clear",onClick:x,"aria-label":s("faq.clearSearch","Clear search"),children:e.jsx(l.NiceIcon,{name:"close",size:14})})]})},hd=({showCounts:t=!0,layout:n="horizontal"})=>{const{t:i}=l.useNiceTranslation(),{categories:a,items:s,selectedCategory:o,setSelectedCategory:c}=Ts(),d=r.useMemo(()=>{const p={all:s.length};for(const m of s)m.category&&(p[m.category]=(p[m.category]||0)+1);return p},[s]);return a.length===0?null:n==="dropdown"?e.jsx("div",{className:"nice-faq-category-dropdown",children:e.jsxs("select",{value:o||"all",onChange:p=>c(p.target.value==="all"?null:p.target.value),className:"nice-faq-category-select",children:[e.jsxs("option",{value:"all",children:[i("faq.allCategories","All Categories")," ",t&&`(${d.all})`]}),a.map(p=>e.jsxs("option",{value:p.id,children:[p.name," ",t&&`(${d[p.id]||0})`]},p.id))]})}):e.jsxs("div",{className:`nice-faq-categories nice-faq-categories--${n}`,children:[e.jsxs("button",{className:`nice-faq-category-btn ${o?"":"nice-faq-category-btn--active"}`,onClick:()=>c(null),children:[e.jsx("span",{children:i("faq.all","All")}),t&&e.jsx("span",{className:"nice-faq-category-count",children:d.all})]}),a.map(p=>e.jsxs("button",{className:`nice-faq-category-btn ${o===p.id?"nice-faq-category-btn--active":""}`,onClick:()=>c(p.id),style:p.color?{"--cat-color":p.color}:void 0,children:[p.icon&&e.jsx("span",{className:"nice-faq-category-icon",children:p.icon}),e.jsx("span",{children:p.name}),t&&e.jsx("span",{className:"nice-faq-category-count",children:d[p.id]||0})]},p.id))]})},Wr=({result:t,showFeedback:n=!0,showRelated:i=!0,animateExpand:a=!0})=>{const{t:s}=l.useNiceTranslation(),{item:o,matches:c}=t,{expandedIds:d,toggleExpanded:p,items:m,submitFeedback:h}=Ts(),[u,x]=r.useState(null),[f,b]=r.useState(!1),[g,v]=r.useState(""),y=r.useRef(null),C=d.has(o.id);r.useEffect(()=>{y.current?.toggleAttribute("inert",!C)},[C]);const w=c.find(_=>_.field==="question")?.indices||[],E=r.useMemo(()=>!i||!o.relatedIds||o.relatedIds.length===0?[]:m.filter(_=>o.relatedIds?.includes(_.id)),[i,o.relatedIds,m]),S=_=>{x(_),_?h(o.id,_):b(!0)},N=()=>{h(o.id,!1,g),b(!1),v("")};return e.jsxs("div",{className:`nice-faq-item ${C?"nice-faq-item--expanded":""} ${o.featured?"nice-faq-item--featured":""}`,"data-question-id":o.id,children:[e.jsxs("button",{className:"nice-faq-question",onClick:()=>p(o.id),"aria-expanded":C,"aria-controls":`faq-answer-${o.id}`,children:[o.icon&&e.jsx("span",{className:"nice-faq-question-icon",children:o.icon}),e.jsx("span",{className:"nice-faq-question-text",children:e.jsx(lg,{text:o.question,indices:w})}),e.jsx("span",{className:`nice-faq-chevron ${C?"nice-faq-chevron--open":""}`,children:e.jsx(l.NiceIcon,{name:"chevron-down",size:16})})]}),e.jsx("div",{id:`faq-answer-${o.id}`,className:`nice-faq-answer ${a?"nice-faq-answer--animated":""}`,ref:y,style:{maxHeight:C?a?y.current?.scrollHeight??1e3:void 0:0},"aria-hidden":!C,children:e.jsxs("div",{className:"nice-faq-answer-content",children:[typeof o.answer=="string"?e.jsx("p",{children:o.answer}):o.answer,o.tags&&o.tags.length>0&&e.jsx("div",{className:"nice-faq-tags",children:o.tags.map(_=>e.jsx("span",{className:"nice-faq-tag",children:_},_))}),E.length>0&&e.jsxs("div",{className:"nice-faq-related",children:[e.jsx("span",{className:"nice-faq-related-label",children:s("faq.related","Related:")}),E.map(_=>e.jsx("button",{className:"nice-faq-related-link",onClick:k=>{k.stopPropagation(),p(_.id),document.querySelector(`[data-question-id="${_.id}"]`)?.scrollIntoView({behavior:"smooth",block:"center"})},children:_.question},_.id))]}),n&&e.jsxs("div",{className:"nice-faq-feedback",children:[u===null?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"nice-faq-feedback-label",children:s("faq.wasThisHelpful","Was this helpful?")}),e.jsxs("button",{className:"nice-faq-feedback-btn nice-faq-feedback-btn--yes",onClick:()=>S(!0),"aria-label":s("faq.yesThisWasHelpful","Yes, this was helpful"),children:[e.jsx(l.NiceIcon,{name:"check",size:14})," ",s("faq.yes","Yes")]}),e.jsxs("button",{className:"nice-faq-feedback-btn nice-faq-feedback-btn--no",onClick:()=>S(!1),"aria-label":s("faq.noThisWasNotHelpful","No, this was not helpful"),children:[e.jsx(l.NiceIcon,{name:"close",size:14})," ",s("faq.no","No")]})]}):e.jsx("span",{className:"nice-faq-feedback-thanks",children:u?s("faq.thanksForYourFeedback","Thanks for your feedback!"):""}),f&&e.jsxs("div",{className:"nice-faq-feedback-form",children:[e.jsx("textarea",{placeholder:s("faq.howCanWeImproveThis","How can we improve this answer?"),value:g,onChange:_=>v(_.target.value),className:"nice-faq-feedback-textarea",rows:3}),e.jsxs("div",{className:"nice-faq-feedback-actions",children:[e.jsx("button",{className:"nice-faq-feedback-submit",onClick:N,children:s("faq.submit","Submit")}),e.jsx("button",{className:"nice-faq-feedback-cancel",onClick:()=>{b(!1),x(null)},children:s("faq.cancel","Cancel")})]})]})]})]})})]})},xr=({category:t,results:n,showFeedback:i,showRelated:a,collapsible:s=!0})=>{const{t:o}=l.useNiceTranslation(),[c,d]=r.useState(!1),p=r.useId();return n.length===0?null:e.jsxs("div",{className:"nice-faq-group",children:[e.jsxs("div",{className:`nice-faq-group-header ${s?"nice-faq-group-header--collapsible":""}`,role:"presentation",onClick:s?()=>d(!c):void 0,style:t.color?{borderColor:t.color}:void 0,children:[t.icon&&e.jsx("span",{className:"nice-faq-group-icon",children:t.icon}),e.jsx("h3",{className:"nice-faq-group-title",children:t.name}),t.description&&e.jsx("p",{className:"nice-faq-group-desc",children:t.description}),e.jsx("span",{className:"nice-faq-group-count",children:n.length}),s&&e.jsx("button",{type:"button",className:`nice-faq-group-chevron ${c?"":"nice-faq-group-chevron--open"}`,"aria-expanded":!c,"aria-controls":c?void 0:p,"aria-label":`${c?o("faq.expandGroup","Expand"):o("faq.collapseGroup","Collapse")}: ${t.name}`,onClick:m=>{m.stopPropagation(),d(!c)},children:e.jsx(l.NiceIcon,{name:"chevron-down",size:16})})]}),!c&&e.jsx("div",{id:p,className:"nice-faq-group-items",children:n.map(m=>e.jsx(Wr,{result:m,showFeedback:i,showRelated:a},m.item.id))})]})},dg=({items:t=rg,categories:n=[],showSearch:i=!0,searchPlaceholder:a,autoFocusSearch:s=!1,showCategories:o=!0,categoryLayout:c="horizontal",groupByCategory:d=!0,allowMultiple:p=!0,defaultExpanded:m=[],showFeedback:h=!0,showRelated:u=!0,onFeedback:x,onAnalytics:f,showExpandControls:b=!0,animateExpand:g=!0,emptyMessage:v,generateSchema:y=!0,header:C,footer:w,size:E="md",className:S,style:N,testId:_,"data-testid":k})=>{const{t:j}=l.useNiceTranslation(),T=a??j("faq.searchFrequentlyAskedQuestions","Search frequently asked questions..."),P=v??j("faq.noQuestionsFoundMatchingYour","No questions found matching your search."),[B,R]=r.useState(new Set(m)),[I,D]=r.useState(""),[M,O]=r.useState(null),L=r.useMemo(()=>[...t].sort((le,J)=>le.featured&&!J.featured?-1:!le.featured&&J.featured?1:(le.order??999)-(J.order??999)),[t]),V=r.useMemo(()=>M?L.filter(le=>le.category===M):L,[L,M]),ee=r.useMemo(()=>cg(V,I),[V,I]),z=r.useMemo(()=>{if(!d||n.length===0)return null;const le={},J=[];for(const me of ee){const je=me.item.category;je?(le[je]||(le[je]=[]),le[je].push(me)):J.push(me)}return{groups:le,uncategorized:J}},[d,n,ee]),U=r.useCallback(le=>{R(J=>{const me=new Set(J);return me.has(le)?(me.delete(le),f?.({type:"collapse",questionId:le,timestamp:new Date().toISOString()})):(p||me.clear(),me.add(le),f?.({type:"expand",questionId:le,timestamp:new Date().toISOString()})),me})},[p,f]),re=r.useCallback(()=>{R(new Set(t.map(le=>le.id)))},[t]),Y=r.useCallback(()=>{R(new Set)},[]),oe=r.useCallback(le=>{D(le),le.trim()&&f?.({type:"search",searchQuery:le,timestamp:new Date().toISOString()})},[f]),q=r.useCallback((le,J,me)=>{const je={questionId:le,helpful:J,comment:me,timestamp:new Date().toISOString()};x?.(je),f?.({type:"feedback",questionId:le,timestamp:je.timestamp,metadata:{helpful:J,comment:me}})},[x,f]),se=r.useMemo(()=>{if(!y)return null;const le={"@context":"https://schema.org","@type":"FAQPage",mainEntity:t.map(J=>({"@type":"Question",name:J.question,acceptedAnswer:{"@type":"Answer",text:typeof J.answer=="string"?J.answer:""}}))};return e.jsx("script",{type:"application/ld+json",dangerouslySetInnerHTML:{__html:JSON.stringify(le)}})},[y,t]),ce={items:L,categories:n,expandedIds:B,searchQuery:I,selectedCategory:M,toggleExpanded:U,expandAll:re,collapseAll:Y,setSearchQuery:oe,setSelectedCategory:O,submitFeedback:q};return e.jsx(pd.Provider,{value:ce,children:e.jsxs("div",{className:`nice-faq nice-faq--${E} ${S||""}`,style:N,"data-testid":k??_,children:[se,C&&e.jsx("div",{className:"nice-faq-header",children:C}),e.jsxs("div",{className:"nice-faq-controls",children:[i&&e.jsx(md,{placeholder:T,autoFocus:s}),o&&n.length>0&&e.jsx(hd,{layout:c,showCounts:!0}),b&&e.jsxs("div",{className:"nice-faq-expand-controls",children:[e.jsx("button",{className:"nice-faq-expand-btn",onClick:re,children:j("faq.expandAll","Expand All")}),e.jsx("button",{className:"nice-faq-expand-btn",onClick:Y,children:j("faq.collapseAll","Collapse All")})]})]}),I&&e.jsx("div",{className:"nice-faq-results-info",children:(ee.length===1?j("faq.foundOneResult",'Found 1 result for "{query}"'):j("faq.foundResults",'Found {count} results for "{query}"')).replace("{count}",String(ee.length)).replace("{query}",I)}),e.jsx("div",{className:"nice-faq-list",children:ee.length===0?e.jsx("div",{className:"nice-faq-empty",children:typeof P=="string"?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"nice-faq-empty-icon",children:e.jsx(l.NiceIcon,{name:"search",size:32})}),e.jsx("p",{children:P})]}):P}):z?e.jsxs(e.Fragment,{children:[n.sort((le,J)=>(le.order??999)-(J.order??999)).map(le=>e.jsx(xr,{category:le,results:z.groups[le.id]||[],showFeedback:h,showRelated:u},le.id)),z.uncategorized.length>0&&e.jsx(xr,{category:{id:"other",name:"Other Questions"},results:z.uncategorized,showFeedback:h,showRelated:u})]}):ee.map(le=>e.jsx(Wr,{result:le,showFeedback:h,showRelated:u,animateExpand:g},le.item.id))}),w&&e.jsx("div",{className:"nice-faq-footer",children:w})]})})},ug=[];function zs(t,n){return n.split(".").reduce((i,a)=>{if(i&&typeof i=="object")return i[a]},t)}const pg=({status:t})=>{const{t:n}=l.useNiceTranslation(),a={connecting:{color:"var(--nice-color-warning, #f59e0b)",label:n("liveGrid.connecting","Connecting...")},connected:{color:"var(--nice-color-success, #22c55e)",label:n("liveGrid.live","Live")},disconnected:{color:"var(--nice-text-muted, #6b7280)",label:n("liveGrid.disconnected","Disconnected")},error:{color:"var(--nice-color-error, #ef4444)",label:n("error","Error")}}[t];return e.jsxs("div",{className:"nice-live-grid-status",children:[e.jsx("span",{className:"nice-live-grid-status-dot",style:{backgroundColor:a.color}}),e.jsx("span",{className:"nice-live-grid-status-label",children:a.label})]})};function mg({columns:t=ug,data:n=[],dataSource:i,rowKey:a="id",showConnectionStatus:s=!0,highlightDuration:o=2e3,updateAnimation:c="flash",maxRows:d,selectable:p=!1,selectedIds:m,onSelectionChange:h,onRowClick:u,onUpdate:x,onConnectionStatusChange:f,emptyContent:b,loadingContent:g,sortable:v=!1,sortField:y,sortDirection:C,onSortChange:w,virtualized:E=!1,rowHeight:S=40,height:N=400,className:_="",style:k,"data-testid":j},T){const{t:P}=l.useNiceTranslation(),[B,R]=r.useState(n),[I,D]=r.useState(!1),[M,O]=r.useState("disconnected"),[L,V]=r.useState(new Map),[ee,z]=r.useState(m||new Set),U=r.useRef(null),re=r.useRef(null),Y=r.useRef(new Map),oe=m??ee,q=h??z,se=r.useCallback(A=>A[a],[a]),ce=r.useCallback((A,Z,fe=[])=>{V(Q=>{const ne=new Map(Q);return ne.set(A,{operation:Z,changedFields:new Set(fe),timestamp:Date.now()}),ne});const Ne=Y.current.get(A);Ne&&clearTimeout(Ne);const K=setTimeout(()=>{V(Q=>{const ne=new Map(Q);return ne.delete(A),ne}),Y.current.delete(A)},o);Y.current.set(A,K)},[o]),le=r.useCallback(A=>{const Z=se(A.row);if(R(fe=>{switch(A.operation){case"insert":{if(fe.some(Q=>se(Q)===Z))return fe;const K=[A.row,...fe];return d&&K.length>d?K.slice(0,d):K}case"update":return fe.map(Ne=>se(Ne)===Z?{...Ne,...A.row,...A.changes||{}}:Ne);case"upsert":{if(fe.some(Q=>se(Q)===Z))return fe.map(Q=>se(Q)===Z?{...Q,...A.row,...A.changes||{}}:Q);const K=[A.row,...fe];return d&&K.length>d?K.slice(0,d):K}case"delete":return fe.filter(Ne=>se(Ne)!==Z);default:return fe}}),c!=="none"){const fe=A.changes?Object.keys(A.changes):[];ce(Z,A.operation,fe)}x?.(A)},[se,d,c,ce,x]),J=r.useCallback(A=>{"updates"in A?A.fullRefresh?R(A.updates.map(Z=>Z.row)):A.updates.forEach(le):le(A)},[le]);r.useEffect(()=>{if(!i)return;i.fetchInitial&&(D(!0),i.fetchInitial().then(Z=>{R(Z),D(!1)})),re.current=i.subscribe(J);let A;return i.onStatusChange?A=i.onStatusChange(Z=>{O(Z),f?.(Z)}):(O("connected"),f?.("connected")),()=>{re.current?.(),A?.()}},[i,J,f]),r.useEffect(()=>{const A=Y.current;return()=>{A.forEach(Z=>clearTimeout(Z))}},[]),r.useImperativeHandle(T,()=>({getData:()=>B,addRow:A=>le({operation:"insert",row:A}),updateRow:(A,Z)=>{const fe=B.find(Ne=>se(Ne)===A);fe&&le({operation:"update",row:fe,changes:Z})},deleteRow:A=>{const Z=B.find(fe=>se(fe)===A);Z&&le({operation:"delete",row:Z})},refresh:()=>{i?.fetchInitial&&(D(!0),i.fetchInitial().then(A=>{R(A),D(!1)}))},getConnectionStatus:()=>M}));const me=r.useMemo(()=>!y||!C?B:[...B].sort((A,Z)=>{const fe=zs(A,y),Ne=zs(Z,y);if(fe===Ne)return 0;if(fe==null)return 1;if(Ne==null)return-1;const K=fe<Ne?-1:1;return C==="asc"?K:-K}),[B,y,C]),je=r.useCallback((A,Z)=>{if(p){const fe=se(A),Ne=new Set(oe);Ne.has(fe)?Ne.delete(fe):Ne.add(fe),q(Ne)}u?.(A,Z)},[p,se,oe,q,u]),ue=r.useCallback(A=>{if(!v)return;let Z="asc";y===A&&(Z=C==="asc"?"desc":"asc"),w?.(A,Z)},[v,y,C,w]),F=r.useCallback(A=>{const Z=se(A),fe=L.get(Z),Ne=oe.has(Z),K=["nice-live-grid-row"];return Ne&&K.push("nice-live-grid-row--selected"),fe&&(K.push(`nice-live-grid-row--${fe.operation}`),K.push(`nice-live-grid-row--${c}`)),K.join(" ")},[se,L,oe,c]),H=r.useCallback((A,Z)=>{const fe=se(A);return L.get(fe)?.changedFields.has(Z)?"nice-live-grid-cell--changed":""},[se,L]);return I&&B.length===0?e.jsx("div",{className:`nice-live-grid nice-live-grid--loading ${_}`,style:k,"data-testid":j,children:g===void 0?P("loading","Loading…"):g}):e.jsxs("div",{ref:U,className:`nice-live-grid ${_}`,style:{...k,height:N},"data-testid":j,children:[s&&e.jsxs("div",{className:"nice-live-grid-header",children:[e.jsx(pg,{status:M}),e.jsx("span",{className:"nice-live-grid-count",children:P("liveGrid.rows","{count} rows").replace("{count}",String(B.length))})]}),e.jsx("div",{className:"nice-live-grid-table-wrapper",children:e.jsxs("table",{className:"nice-live-grid-table",children:[e.jsx("thead",{children:e.jsx("tr",{children:t.map(A=>e.jsxs("th",{className:`nice-live-grid-th ${v&&A.sortable!==!1?"nice-live-grid-th--sortable":""}`,style:{width:A.width,minWidth:A.minWidth,maxWidth:A.maxWidth,textAlign:A.align||"left"},onClick:()=>A.sortable!==!1&&ue(String(A.field)),children:[A.headerRender?A.headerRender(A):A.header,y===String(A.field)&&e.jsx("span",{className:"nice-live-grid-sort-icon",children:e.jsx(l.NiceIcon,{name:C==="asc"?"sort-asc":"sort-desc",size:12})})]},String(A.field)))})}),e.jsx("tbody",{children:me.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:t.length,className:"nice-live-grid-empty",children:b===void 0?P("noData","No data"):b})}):me.map(A=>e.jsx("tr",{className:F(A),onClick:Z=>je(A,Z),style:{height:S},children:t.map(Z=>{const fe=zs(A,String(Z.field));return e.jsx("td",{className:`nice-live-grid-td ${H(A,String(Z.field))}`,style:{textAlign:Z.align||"left"},children:Z.render?Z.render(fe,A,Z):String(fe??"")},String(Z.field))})},String(se(A))))})]})})]})}const hg=Object.assign(r.forwardRef(mg),{displayName:"NiceLiveDataGrid"});function Vi(t){return{key:t?.keyField??"id",children:t?.childrenField??"children"}}function Li(t,n){return String(t[n])}function zi(t,n){const i=t[n];return Array.isArray(i)?i:void 0}function lc(t,n,i){return{...t,[n]:i}}function sn(t,n,i){const a=Vi(i),s=(o,c,d)=>{o.forEach((p,m)=>{const h={node:p,parent:c,parentId:c===null?null:Li(c,a.key),index:m,siblings:o,ancestors:d,depth:d.length};if(n(p,h)===!1)return;const u=zi(p,a.children);u?.length&&s(u,p,[...d,p])})};s(t,null,[])}function It(t,n,i){const a=Vi(i),s=(o,c,d)=>{for(let p=0;p<o.length;p++){const m=o[p];if(Li(m,a.key)===n)return{node:m,parent:c,parentId:c===null?null:Li(c,a.key),index:p,siblings:o,ancestors:d,depth:d.length};const h=zi(m,a.children);if(h?.length){const u=s(h,m,[...d,m]);if(u)return u}}};return s(t,null,[])}function si(t,n,i){return It(t,n,i)?.node}function Kr(t,n,i,a){const s=Vi(a);return!!It(t,n,a)?.ancestors.some(c=>Li(c,s.key)===i)}function _a(t,n){const i=Vi(n),a=zi(t,i.children);return a?.length?1+Math.max(...a.map(s=>_a(s,n))):1}function Yr(t,n,i,a){const s=Vi(a);if(n===null)return i(t);let o=!1;const c=d=>{let p=null;for(let m=0;m<d.length&&!o;m++){const h=d[m];let u=null;if(Li(h,s.key)===n)u=lc(h,s.children,i(zi(h,s.children)??[])),o=!0;else{const x=zi(h,s.children),f=x?.length?c(x):null;f&&(u=lc(h,s.children,f))}u&&(p=p??[...d],p[m]=u)}return p};return c(t)??[...t]}function Hn(t,n,i,a){return i.parentId!==null&&!si(t,i.parentId,a)?t:Yr(t,i.parentId,s=>{const o=[...s];return o.splice(Math.max(0,Math.min(i.index,o.length)),0,n),o},a)}function mi(t,n,i){const a=It(t,n,i);return a?Yr(t,a.parentId,s=>s.filter((o,c)=>c!==a.index),i):t}function ka(t,n,i,a){const s=It(t,n,a);if(!s)return t;const o=typeof i=="function"?i(s.node):{...s.node,...i};return Yr(t,s.parentId,c=>c.map((d,p)=>p===s.index?o:d),a)}function Ui(t,n,i,a){const s=It(t,n,a);if(!s||i.parentId!==null&&(i.parentId===n||Kr(t,i.parentId,n,a)||!si(t,i.parentId,a)))return t;let o=i.index;if(s.parentId===i.parentId&&(o>s.index&&(o-=1),o=Math.max(0,Math.min(o,s.siblings.length-1)),o===s.index))return t;const c=mi(t,n,a);return Hn(c,s.node,{parentId:i.parentId,index:o},a)}function ms(t,n,i,a){const s=It(t,n,a);if(!s)return t;const o=Math.max(0,Math.min(s.index+i,s.siblings.length-1));return o===s.index?t:Ui(t,n,{parentId:s.parentId,index:o>s.index?o+1:o},a)}function Jr(t,n,i){const a=Vi(i),s=It(t,n,i);if(!s||s.index===0)return t;const o=s.siblings[s.index-1];return Ui(t,n,{parentId:Li(o,a.key),index:zi(o,a.children)?.length??0},i)}function Qr(t,n,i){const a=It(t,n,i);if(!a||a.parentId===null)return t;const s=It(t,a.parentId,i);return s?Ui(t,n,{parentId:s.parentId,index:s.index+1},i):t}const gg=[],bg=["moveUp","moveDown","indent","outdent","rename","remove"],fg=5,dc=28,vg=600,xg=16,yg=10;function Ng(t){const{value:n,defaultValue:i,onChange:a,keyField:s="id",childrenField:o="children",labelField:c="label",getLabel:d,renderLabel:p,getIcon:m,renderRowEnd:h,selectedId:u,defaultSelectedId:x,onSelect:f,collapsedIds:b,defaultCollapsedIds:g,onCollapsedChange:v,canHaveChildren:y,canDrag:C,canDrop:w,maxDepth:E,editable:S=!1,removable:N=!1,actions:_=!0,contextMenuItems:k,onExternalDrop:j,emptyText:T,"aria-label":P,height:B,size:R="md",readOnly:I=!1,disabled:D=!1,className:M,style:O,id:L,title:V,accessMode:ee,"data-testid":z}=t,{t:U}=l.useNiceTranslation(),re=l.useNiceAccessMode(ee,L),Y=D||re==="disabled",oe=I||re==="readOnly"||Y,q=r.useMemo(()=>({keyField:s,childrenField:o}),[s,o]),[se,ce]=l.useControllableState({value:n,defaultValue:i,fallbackValue:[],componentName:"NiceSortableTree"}),[le,J]=l.useControllableState({value:u,defaultValue:x,fallbackValue:null,componentName:"NiceSortableTree"}),[me,je]=l.useControllableState({value:b,defaultValue:g,fallbackValue:gg,componentName:"NiceSortableTree"}),ue=r.useCallback(de=>String(de[s]),[s]),F=r.useCallback(de=>{const De=de[o];return Array.isArray(De)?De:[]},[o]),H=r.useCallback(de=>{if(d)return d(de);const De=de[c];return De==null?ue(de):String(De)},[d,c,ue]),A=(de,De)=>!oe&&(typeof de=="function"?de(De):de),Z=r.useCallback(de=>y?y(de):!0,[y]),fe=r.useMemo(()=>new Set(me),[me]),Ne=r.useMemo(()=>{const de=[];return sn(se,(De,Ge)=>{const Ze=ue(De),lt=F(De).length>0,yt=lt&&!fe.has(Ze);return de.push({node:De,id:Ze,depth:Ge.depth,parentId:Ge.parentId,index:Ge.index,setSize:Ge.siblings.length,hasChildren:lt,expanded:yt}),yt?void 0:!1},q),de},[se,fe,ue,F,q]),K=r.useMemo(()=>new Map(Ne.map(de=>[de.id,de])),[Ne]),Q=r.useRef(null),ne=r.useRef(null),[G,Se]=r.useState(""),te=r.useRef(null),we=r.useCallback(de=>{je(de),v?.(de)},[je,v]),ie=r.useCallback((de,De)=>{const Ge=me.includes(de);De&&Ge?we(me.filter(Ze=>Ze!==de)):!De&&!Ge&&we([...me,de])},[me,we]),xe=r.useCallback(de=>{J(de),f?.(de,de===null?null:si(se,de,q)??null)},[J,f,se,q]);l.useTreeFocus(ne,{onToggle:(de,De)=>{const Ge=de.dataset.nodeId;Ge!==void 0&&ie(Ge,De)}});const W=de=>{const De=It(se,de,q);return De?{parentId:De.parentId,index:De.index}:null},be=(de,De)=>{const Ge=It(de,De,q);if(!Ge)return;const Ze=Ge.parent?H(Ge.parent):U("sortableTree.root","top level");Se(U("sortableTree.announceMoved","{label} moved to {parent}, position {position} of {count}").replace("{label}",H(Ge.node)).replace("{parent}",Ze).replace("{position}",String(Ge.index+1)).replace("{count}",String(Ge.siblings.length)))},Te=(de,De)=>de===se?!1:(ce(de),a?.(de,De),!0),Me=(de,De,Ge,Ze)=>{let lt=0;if(De.parentId!==null){if(de!==null&&(De.parentId===de||Kr(se,De.parentId,de,q)))return!1;const yt=It(se,De.parentId,q);if(!yt||!Z(yt.node))return!1;lt=yt.depth+1}return E!==void 0&<+Ge>E?!1:w?w(de,De,Ze):!0},$=(de,De,Ge,Ze)=>{const lt=W(de);if(!lt)return;const yt=si(se,de,q);if(!yt||!Me(de,De,_a(yt,q)))return;const ct=It(Ze,de,q),wt=ct?{parentId:ct.parentId,index:ct.index}:De;Te(Ze,{type:Ge,id:de,from:lt,to:wt})&&(te.current=de,wt.parentId!==null&&ie(wt.parentId,!0),be(Ze,de))},X=(de,De)=>{const Ge=ms(se,de,De,q),Ze=It(Ge,de,q);Ze&&$(de,{parentId:Ze.parentId,index:Ze.index},"move",Ge)},ae=de=>{const De=Jr(se,de,q),Ge=It(De,de,q);Ge&&De!==se&&$(de,{parentId:Ge.parentId,index:Ge.index},"indent",De)},ve=de=>{const De=Qr(se,de,q),Ge=It(De,de,q);Ge&&De!==se&&$(de,{parentId:Ge.parentId,index:Ge.index},"outdent",De)},Ce=de=>{const De=W(de);if(!De)return;const Ge=Ne.findIndex(Nt=>Nt.id===de),Ze=new Set,lt=si(se,de,q);lt&&sn([lt],Nt=>{Ze.add(ue(Nt))},q);const yt=Ne.slice(Ge+1).find(Nt=>!Ze.has(Nt.id)),ct=Ne.slice(0,Math.max(0,Ge)).reverse().find(Nt=>!Ze.has(Nt.id)),wt=yt?.id??ct?.id??null;Te(mi(se,de,q),{type:"remove",id:de,from:De})&&(le!==null&&Ze.has(le)&&xe(wt),te.current=wt,Se(U("sortableTree.announceRemoved","{label} removed").replace("{label}",lt?H(lt):de)))},[_e,ke]=r.useState(null),Ee=r.useRef(null);r.useEffect(()=>{_e!==null&&(Ee.current?.focus(),Ee.current?.select())},[_e]);const Re=(de,De)=>{ke(null),te.current=de;const Ge=si(se,de,q),Ze=De?.trim();!Ge||!Ze||Ze===H(Ge)||Te(ka(se,de,{[c]:Ze},q),{type:"rename",id:de,label:Ze})};r.useLayoutEffect(()=>{const de=te.current;if(de===null||_e!==null)return;te.current=null;const De=[...ne.current?.querySelectorAll("[data-node-id]")??[]].find(Ge=>Ge.dataset.nodeId===de);De&&(De.focus(),De.scrollIntoView?.({block:"nearest"}))});const qe=(de,De)=>{const Ge=ne.current;if(!Ge)return null;const Ze=[...Ge.querySelectorAll("[data-node-id]")];if(Ze.length===0)return{target:{parentId:null,index:0},line:null,insideId:null,invalid:!1};const lt=Ze[0],yt=Ze[Ze.length-1],ct=(wt,Nt,jt)=>({top:Nt==="top"?wt.offsetTop:wt.offsetTop+wt.offsetHeight,depth:jt});if(de<lt.getBoundingClientRect().top){const wt=K.get(lt.dataset.nodeId??"");return wt&&!De.has(wt.id)?{target:{parentId:null,index:0},line:ct(lt,"top",0),insideId:null,invalid:!1}:null}for(const wt of Ze){const Nt=wt.getBoundingClientRect();if(de<Nt.top||de>=Nt.bottom)continue;const jt=K.get(wt.dataset.nodeId??"");if(!jt||De.has(jt.id))return null;const Gt=(de-Nt.top)/Math.max(1,Nt.height),xn=Z(jt.node)?Gt<.25?"before":Gt>.75?"after":"inside":Gt<.5?"before":"after";return xn==="before"?{target:{parentId:jt.parentId,index:jt.index},line:ct(wt,"top",jt.depth),insideId:null,invalid:!1}:xn==="inside"?{target:{parentId:jt.id,index:F(jt.node).length},line:null,insideId:jt.id,invalid:!1}:jt.expanded?{target:{parentId:jt.id,index:0},line:ct(wt,"bottom",jt.depth+1),insideId:null,invalid:!1}:{target:{parentId:jt.parentId,index:jt.index+1},line:ct(wt,"bottom",jt.depth),insideId:null,invalid:!1}}return{target:{parentId:null,index:se.length},line:ct(yt,"bottom",0),insideId:null,invalid:!1}},Ye=r.useRef(null),[We,ot]=r.useState(null),[st,rt]=r.useState(null),mt=r.useRef(!1),Ke=de=>{clearTimeout(de.hoverTimer),de.hoverTimer=void 0,de.hoverId=null},he=(de,De)=>{const Ge=De?.insideId??null;if(Ge===de.hoverId)return;Ke(de);const Ze=Ge?K.get(Ge):void 0;Ze&&Ze.hasChildren&&!Ze.expanded&&(de.hoverId=Ge,de.hoverTimer=setTimeout(()=>ie(Ze.id,!0),vg))},Pe=de=>{const De=Q.current;if(!De||De.scrollHeight<=De.clientHeight)return;const Ge=De.getBoundingClientRect();de<Ge.top+dc?De.scrollTop-=10:de>Ge.bottom-dc&&(De.scrollTop+=10)},He=(de,De)=>{const Ge=!!de.target.closest(".nice-sortable-tree__grip");if(oe||de.button!==0||_e!==null||de.pointerType==="touch"&&!Ge||de.target.closest(".nice-sortable-tree__toggle, input, button")||C&&!C(De.node))return;const Ze=new Set;sn([De.node],lt=>{Ze.add(ue(lt))},q),Ye.current={id:De.id,pointerId:de.pointerId,startY:de.clientY,startX:de.clientX,startScroll:Q.current?.scrollTop??0,rowTop:de.currentTarget.getBoundingClientRect().top,started:!1,height:_a(De.node,q),block:Ze,view:null,hoverId:null,hoverTimer:void 0}},pt=de=>{const De=Ye.current;if(!De||de.pointerId!==De.pointerId)return;const Ge=(Q.current?.scrollTop??0)-De.startScroll,Ze=de.clientY+yg-De.rowTop+Ge;if(!De.started){if(Math.hypot(de.clientX-De.startX,de.clientY-De.startY)<fg)return;De.started=!0,de.currentTarget.setPointerCapture?.(de.pointerId),de.currentTarget.focus()}Pe(de.clientY);const lt=qe(de.clientY,De.block),yt=lt?{...lt,invalid:!Me(De.id,lt.target,De.height)}:null;De.view=yt,he(De,yt),ot({ids:De.block,dy:Ze}),rt(yt)},Xe=de=>{const De=Ye.current;if(Ye.current=null,!!De){if(Ke(De),De.started){if(de&&De.view&&!De.view.invalid){const Ge=Ui(se,De.id,De.view.target,q),Ze=It(Ge,De.id,q);Ze&&Ge!==se&&$(De.id,{parentId:Ze.parentId,index:Ze.index},"move",Ge)}mt.current=!0,window.setTimeout(()=>{mt.current=!1},0)}ot(null),rt(null)}},ut=Be.useTreeDragSession(),ge=r.useRef({view:null,hoverId:null,hoverTimer:void 0}),Le=r.useRef(()=>{});Le.current=de=>{const De=ge.current,Ge=Q.current?.getBoundingClientRect(),Ze=!!Ge&&de.x>=Ge.left&&de.x<=Ge.right&&de.y>=Ge.top&&de.y<=Ge.bottom;if(de.type==="move"){if(!Ze||oe||!j){De.view&&(De.view=null,Ke(De),rt(null));return}Pe(de.y);const yt=qe(de.y,new Set),ct=yt?{...yt,invalid:!Me(null,yt.target,1,de.payload)}:null;De.view=ct,he(De,ct),rt(ct);return}const lt=De.view;De.view=null,Ke(De),rt(null),de.commit&&Ze&<&&!lt.invalid&&j?.(de.payload,lt.target)},r.useEffect(()=>ut?.subscribe(de=>Le.current(de)),[ut]);const[et,pe]=r.useState(null),Ie=r.useRef(null);l.useOverlayFocus(Ie,{open:et!==null,modal:!1,onClose:()=>pe(null)}),l.useRovingFocus(Ie,{orientation:"vertical",wrap:!0,enabled:et!==null}),r.useLayoutEffect(()=>{const de=Ie.current;if(!et||!de||typeof window>"u")return;const De=de.getBoundingClientRect(),Ge=Math.max(8,Math.min(et.x,window.innerWidth-De.width-8)),Ze=Math.max(8,Math.min(et.y,window.innerHeight-De.height-8));(Ge!==et.x||Ze!==et.y)&&pe({...et,x:Ge,y:Ze})},[et]),r.useEffect(()=>{if(!et)return;const de=De=>{Ie.current?.contains(De.target)||pe(null)};return document.addEventListener("mousedown",de),()=>document.removeEventListener("mousedown",de)},[et]);const ze=_===!0?bg:_===!1?[]:_,Je=et?K.get(et.id):void 0,ht=[];if(Je){const de=Je.node,De=!oe&&(!C||C(de)),Ge=Je.index>0,Ze=(lt,yt,ct,wt,Nt)=>{ze.includes(lt)&&ht.push({id:lt,label:yt,icon:e.jsx(l.NiceIcon,{name:ct,size:14}),disabled:!wt,onClick:Nt})};Ze("moveUp",U("sortableTree.moveUp","Move up"),"chevron-up",De&&Ge,()=>X(Je.id,-1)),Ze("moveDown",U("sortableTree.moveDown","Move down"),"chevron-down",De&&Je.index<Je.setSize-1,()=>X(Je.id,1)),Ze("indent",U("sortableTree.indent","Indent"),"indent",De&&Ge,()=>ae(Je.id)),Ze("outdent",U("sortableTree.outdent","Outdent"),"outdent",De&&Je.parentId!==null,()=>ve(Je.id)),Ze("rename",U("sortableTree.rename","Rename"),"edit",A(S,de),()=>ke(Je.id)),Ze("remove",U("sortableTree.remove","Remove"),"trash",A(N,de),()=>Ce(Je.id)),ht.push(...k?.(de)??[])}const Bt=(de,De)=>{if(de.target!==de.currentTarget)return;if(de.key==="Escape"&&Ye.current?.started){de.preventDefault(),Xe(!1);return}if(!oe&&(!C||C(De.node))&&de.ctrlKey&&de.shiftKey&&!de.altKey){const Ze=typeof window<"u"&&Q.current!==null&&window.getComputedStyle(Q.current).direction==="rtl",lt=Ze&&de.key==="ArrowLeft"?"ArrowRight":Ze&&de.key==="ArrowRight"?"ArrowLeft":de.key,yt={ArrowUp:()=>X(De.id,-1),ArrowDown:()=>X(De.id,1),ArrowRight:()=>ae(De.id),ArrowLeft:()=>ve(De.id)};if(yt[lt]){de.preventDefault(),yt[lt]();return}}de.key==="F2"&&A(S,De.node)?(de.preventDefault(),ke(De.id)):de.key==="Delete"&&A(N,De.node)&&(de.preventDefault(),Ce(De.id))};if(re==="hidden")return null;const Dt=We?.ids;return e.jsxs("div",{ref:Q,id:L,title:V,"data-testid":z,className:["nice-sortable-tree",`nice-sortable-tree--${R}`,We?"nice-sortable-tree--dragging":"",st&&Ne.length===0&&!st.invalid?"nice-sortable-tree--drop-empty":"",Y?"nice-sortable-tree--disabled":"",M??""].filter(Boolean).join(" "),style:{...B!==void 0?{height:B,overflow:"auto"}:{},...O},"aria-disabled":Y||void 0,children:[Ne.length===0&&e.jsx("div",{className:"nice-sortable-tree__empty",children:T??U("sortableTree.empty","Nothing here yet")}),e.jsxs("ul",{ref:ne,role:"tree","aria-label":P,"aria-disabled":Y||void 0,className:"nice-sortable-tree__list",children:[Ne.map(de=>{const De=de.id===le,Ge=!!Dt?.has(de.id),Ze={depth:de.depth,hasChildren:de.hasChildren,expanded:de.expanded,selected:De,dragging:Ge},lt=_e===de.id,yt={"--nice-sortable-tree-depth":de.depth,...Ge&&We?{transform:`translate(${xg}px, ${We.dy}px)`}:{}};return e.jsxs("li",{role:"treeitem","data-node-id":de.id,"aria-level":de.depth+1,"aria-setsize":de.setSize,"aria-posinset":de.index+1,"aria-expanded":de.hasChildren?de.expanded:void 0,"aria-selected":De,"aria-label":H(de.node),tabIndex:-1,className:["nice-sortable-tree__row",De?"nice-sortable-tree__row--selected":"",Ge?"nice-sortable-tree__row--dragging":"",st?.insideId===de.id?st.invalid?"nice-sortable-tree__row--drop-invalid":"nice-sortable-tree__row--drop-inside":""].filter(Boolean).join(" "),style:yt,onClick:ct=>{if(mt.current){mt.current=!1;return}if(!Y){if(de.hasChildren&&ct.target.closest(".nice-sortable-tree__toggle")){ie(de.id,!de.expanded);return}xe(de.id)}},onDoubleClick:()=>{A(S,de.node)&&ke(de.id)},onKeyDown:ct=>Bt(ct,de),onPointerDown:ct=>He(ct,de),onPointerMove:pt,onPointerUp:()=>Xe(!0),onPointerCancel:()=>Xe(!1),onContextMenu:ct=>{if(Y||ze.length===0&&!k)return;ct.preventDefault(),ct.stopPropagation();const wt=ct.currentTarget.getBoundingClientRect(),Nt=ct.clientX===0&&ct.clientY===0;pe({id:de.id,x:Nt?wt.left+24:ct.clientX,y:Nt?wt.bottom:ct.clientY})},children:[!oe&&(!C||C(de.node))&&e.jsx("span",{className:"nice-sortable-tree__grip","aria-hidden":"true",children:e.jsx(l.NiceIcon,{name:"grip",size:14})}),de.hasChildren?e.jsx("span",{className:"nice-sortable-tree__toggle","aria-hidden":"true",children:e.jsx(l.NiceIcon,{name:de.expanded?"chevron-down":"chevron-right",size:14})}):e.jsx("span",{className:"nice-sortable-tree__toggle nice-sortable-tree__toggle--leaf","aria-hidden":"true"}),m&&e.jsx("span",{className:"nice-sortable-tree__icon","aria-hidden":"true",children:m(de.node,Ze)}),lt?e.jsx("input",{ref:Ee,className:"nice-sortable-tree__input","aria-label":U("sortableTree.renameField","New name"),defaultValue:H(de.node),onClick:ct=>ct.stopPropagation(),onPointerDown:ct=>ct.stopPropagation(),onKeyDown:ct=>{ct.stopPropagation(),ct.key==="Enter"?(ct.preventDefault(),Re(de.id,ct.currentTarget.value)):ct.key==="Escape"&&(ct.preventDefault(),Re(de.id,null))},onBlur:ct=>{_e===de.id&&Re(de.id,ct.currentTarget.value)}}):e.jsx("span",{className:"nice-sortable-tree__label",children:p?p(de.node,Ze):H(de.node)}),h&&e.jsx("span",{className:"nice-sortable-tree__end",children:h(de.node,Ze)})]},de.id)}),st?.line&&e.jsx("li",{role:"none",className:`nice-sortable-tree__drop-line${st.invalid?" nice-sortable-tree__drop-line--invalid":""}`,style:{top:st.line.top,"--nice-sortable-tree-depth":st.line.depth}})]}),e.jsx("div",{className:"nice-sr-only","aria-live":"polite",role:"status",children:G}),et&&ht.length>0&&e.jsx("ul",{ref:Ie,role:"menu","aria-label":U("sortableTree.menu","Node actions"),className:"nice-contextmenu nice-contextmenu__list nice-sortable-tree__menu",style:{position:"fixed",left:et.x,top:et.y},children:ht.map((de,De)=>e.jsx("li",{role:"none",className:"nice-contextmenu__item",children:e.jsxs("button",{type:"button",role:"menuitem",className:`nice-contextmenu__btn${de.danger?" nice-contextmenu__btn--danger":""}`,disabled:de.disabled,onClick:Ge=>{pe(null),de.onClick?.(Ge)},children:[de.icon&&e.jsx("span",{className:"nice-contextmenu__icon","aria-hidden":"true",children:de.icon}),e.jsx("span",{children:de.label??de.text})]})},de.id??de.key??De))})]})}const gd=Object.assign(Ng,{displayName:"NiceSortableTree"}),uc=new WeakMap;function Dn(t){const n=uc.get(t);if(n)return n;const i=new Map;return sn(t,(a,s)=>{i.set(a.id,{node:a,ancestors:[...s.ancestors],order:i.size})}),uc.set(t,i),i}function bd(t,n){return Dn(t).get(n)?.node}function _g(t,n){const i=Dn(t),a=new Set;for(const s of n){const o=i.get(s);o&&sn([o.node],c=>{c.route&&!c.disabled&&a.add(c.id)})}return[...a].sort((s,o)=>(i.get(s)?.order??0)-(i.get(o)?.order??0))}function Ri(t,n){let i;return sn(t,a=>{if(i)return!1;n(a)&&(i=a)}),i}function Xr(t){const n=new Set;return sn(t,i=>{n.add(i.id)}),n}function $i(t,n){let i=n;for(let a=2;t.has(i);a++)i=`${n}-${a}`;return t.add(i),i}function Zr(t){const n=[];return sn(t,i=>{i.ref&&n.push(i.ref)}),n}function fd(t,n){const i=Dn(n),a=[];return sn(t,s=>{s.ref&&!i.get(s.ref)?.node.route&&a.push(s.id)}),a}function eo(t,n){if(t.label)return t.label;const i=Dn(n);return(t.ref?i.get(t.ref)?.node.label:void 0)??(t.from?i.get(t.from)?.node.label:void 0)??t.ref??t.from??t.id}function hs(t,n){const i=Dn(n);return(t.ref?i.get(t.ref):void 0)?.node??(t.from?i.get(t.from):void 0)?.node}function vd(t,n){return Dn(t).get(n)?.ancestors.map(i=>i.label)??[]}function pc(t,n,i){let a=null,s=t;for(const o of n){const c=Ri(s,m=>m.from===o.id);if(c){a=c.id;continue}const d={id:$i(i,`g:${o.id}`),from:o.id,children:[]},p=a===null?s:It(s,a)?.node.children??[];s=Hn(s,d,{parentId:a,index:p.length}),a=d.id}return{menu:s,parentId:a}}function xd(t,n,i,a={}){const s=Dn(n),o=Math.max(0,a.skipLevels??0),c=new Set(Zr(t)),d=Xr(t);let p=t;const m=[...new Set(i)].filter(h=>s.get(h)?.node.route&&!s.get(h)?.node.disabled).sort((h,u)=>(s.get(h)?.order??0)-(s.get(u)?.order??0));for(const h of m){const u=s.get(h);if(!u||c.has(h))continue;c.add(h);const x=u.ancestors.slice(o);if(u.node.children?.length){const g=pc(p,[...x,u.node],d);p=g.menu,g.parentId!==null&&(p=ka(p,g.parentId,{ref:h}));continue}const f=pc(p,x,d);p=f.menu;const b=f.parentId===null?p:It(p,f.parentId)?.node.children??[];p=Hn(p,{id:$i(d,`p:${h}`),ref:h},{parentId:f.parentId,index:b.length})}return p}function yd(t){let n=t;for(;;){const i=Ri(n,a=>!!a.from&&!a.ref&&!a.children?.length);if(!i)return n;n=mi(n,i.id)}}function Nd(t,n){const i=new Set(n);let a=t;for(const s of i){const o=Ri(a,c=>c.ref===s);o&&(o.children?.length?a=ka(a,o.id,c=>{const{ref:d,...p}=c;return{...p,from:p.from??s}}):a=mi(a,o.id))}return a===t?a:yd(a)}function _d(t,n,i,a,s={}){const o=Dn(n),c=Xr(t);let d=t,p=a.index;const m=h=>{const u=(h.children??[]).map(m).filter(b=>b!==null),x=!!h.route&&!h.disabled,f=x?Ri(d,b=>b.ref===h.id):void 0;return f&&(d=mi(d,f.id),c.delete(f.id)),h.children?.length?!u.length&&!x?null:{id:$i(c,`g:${h.id}`),from:h.id,...x?{ref:h.id}:{},children:u}:x?{id:$i(c,`p:${h.id}`),ref:h.id}:null};for(const h of i){const u=o.get(h);if(!u)continue;const x=!!u.node.route&&!u.node.disabled,f=!u.node.children?.length||s.asPage,b=x?Ri(d,v=>v.ref===h):void 0;if(f){if(b)d=Ui(d,b.id,{parentId:a.parentId,index:p});else if(x)d=Hn(d,{id:$i(c,`p:${h}`),ref:h},{parentId:a.parentId,index:p});else continue;const v=Ri(d,y=>y.ref===h);p=(v?It(d,v.id)?.index??p:p)+1;continue}const g=m(u.node);g&&(a.parentId!==null&&!It(d,a.parentId)?d=Hn(d,g,{parentId:null,index:d.length}):(d=Hn(d,g,{parentId:a.parentId,index:p}),p+=1))}return yd(d)}function jd(t,n,i){const a=Xr(t),s=$i(a,"group");return{menu:Hn(t,{id:s,label:n,children:[]},i??{parentId:null,index:t.length}),id:s}}function jg(t,n,i){if(t.icon)return i?i(t.icon):void 0;const a=n?.icon;return typeof a=="string"?i?i(a):void 0:a}function wd(t,n,i={}){const a=Dn(n),s=o=>o.flatMap(c=>{const p=(c.ref?a.get(c.ref)?.node:void 0)?.route,m=s(c.children??[]);return!p&&m.length===0?[]:[{id:c.id,label:eo(c,n),icon:jg(c,hs(c,n),i.renderIcon),...p?{route:p}:{},...m.length?{children:m}:{}}]});return s(t)}function kd(t,n,i={}){const a=wd(t,n,i),s=[];let o=[];const c=()=>{o.length&&(s.push({id:`${o[0].id}:other`,label:i.otherLabel??"Other",views:o}),o=[])};for(const d of a){if(!d.children?.length){o.push(d);continue}c();const p=d.route?[{id:`${d.id}:page`,label:d.label,icon:d.icon,route:d.route}]:[];s.push({id:d.id,label:d.label,icon:d.icon,views:[...p,...d.children]})}return c(),[{source:i.source??{id:"menu",label:i.otherLabel??"Menu"},modules:s,roles:[],units:[]}]}function wg(t,n={}){const i=n.key??"id",a=(d,p)=>typeof i=="function"?i(d,p):i==="route"?d.route??d.id:d.id,s=(d,p)=>d.map(m=>({id:a(m,p),label:m.label,icon:m.icon,...m.route?{route:m.route}:{},...m.children?.length?{children:s(m.children,p)}:{}})),o=d=>d.modules.map(p=>({id:p.id,label:p.label,icon:p.icon,children:s(p.views,p)}));return n.includeSources??t.length>1?t.map(d=>({id:d.source.id,label:d.source.label,icon:d.source.icon,children:o(d)})):t.flatMap(o)}const kg=[],Cg=[],Sg={},Tg=60,Eg=t=>e.jsx(l.NiceIcon,{name:t,size:16});function Cd(t){return t.map(n=>{const i=n.children?.length?Cd(n.children):void 0,a=!!i?.some(s=>s.placeable);return n.route&&i?{key:`${n.id}::branch`,nodeId:n.id,label:n.label,icon:n.icon,placeable:!0,disabled:n.disabled,children:[{key:n.id,nodeId:n.id,label:n.label,icon:n.icon,route:n.route,own:!0,placeable:!0,disabled:n.disabled},...i]}:{key:n.id,nodeId:n.id,label:n.label,icon:n.icon,route:n.route,placeable:!!n.route||a,disabled:n.disabled,children:i}})}function Sd(t,n){return n<=0?[]:t.flatMap(i=>i.children?.length?[i.key,...Sd(i.children,n-1)]:[])}const Ig=({drag:t,label:n,title:i})=>{const a=Be.useTreeDragSession();return e.jsx("span",{className:"nice-menu-builder__grip",title:i,"aria-hidden":"true",onPointerDown:s=>{a&&(s.stopPropagation(),Be.startTreeDrag(a,s,t,n))},children:e.jsx(l.NiceIcon,{name:"grip",size:14})})},Dg=({value:t,onChange:n,renderIcon:i})=>{const{t:a}=l.useNiceTranslation(),[s,o]=r.useState(""),c=r.useRef(null);l.useRovingFocus(c,{orientation:"grid",itemSelector:"button"});const d=r.useMemo(()=>{const p=s.trim().toLowerCase(),m=p?l.NICE_BUILTIN_ICONS.filter(u=>u.includes(p)):l.NICE_BUILTIN_ICONS,h=m.slice(0,Tg);return t&&m.includes(t)&&!h.includes(t)?[t,...h]:h},[s,t]);return e.jsxs("div",{className:"nice-menu-builder__icon-picker",children:[e.jsx(Oe.NiceTextInput,{type:"search",size:"sm",label:a("menuBuilder.iconSearch","Search icons"),value:s,onChange:o}),e.jsxs("div",{ref:c,role:"group","aria-label":a("menuBuilder.icons","Icons"),className:"nice-menu-builder__icon-grid",children:[d.map(p=>e.jsx("button",{type:"button",title:p,"aria-label":p,"aria-pressed":p===t,className:`nice-menu-builder__icon-option${p===t?" nice-menu-builder__icon-option--on":""}`,onClick:()=>n(p),children:i(p)},p)),d.length===0&&e.jsx("span",{className:"nice-menu-builder__hint",children:a("menuBuilder.noIcons","No icons found")})]})]})},Pg=({catalog:t=kg,value:n,defaultValue:i,onChange:a,skipLevels:s=0,maxDepth:o,renderIcon:c=Eg,renderIconPicker:d,showPreview:p=!0,previewProps:m,toolbar:h,height:u,size:x="md",readOnly:f=!1,disabled:b=!1,className:g,style:v,id:y,title:C,accessMode:w,"data-testid":E})=>{const{t:S}=l.useNiceTranslation(),N=l.useNiceAccessMode(w,y),_=b||N==="disabled",k=f||N==="readOnly"||_,[j,T]=l.useControllableState({value:n,defaultValue:i,fallbackValue:Cg,componentName:"NiceMenuBuilder"}),P=ne=>{ne===j||k||(T(ne),a?.(ne))},[B,R]=r.useState(null),I=r.useRef(null),[D,M]=r.useState(0);r.useEffect(()=>{D>0&&I.current?.querySelector("input")?.focus()},[D]);const O=r.useMemo(()=>Cd(t),[t]),L=r.useMemo(()=>Zr(j),[j]),V=r.useMemo(()=>new Set(fd(j,t)),[j,t]),ee=r.useMemo(()=>Sd(O,2),[O]),z=ne=>{const G=new Set(ne),Se=new Set(L),te=ne.filter(xe=>!Se.has(xe)),we=L.filter(xe=>!G.has(xe));let ie=j;te.length&&(ie=xd(ie,t,te,{skipLevels:s})),we.length&&(ie=Nd(ie,we)),P(ie)},U=r.useMemo(()=>[{field:"label",header:S("menuBuilder.catalogColumn","View"),render:(ne,G)=>e.jsxs("span",{className:"nice-menu-builder__catalog-cell",children:[!k&&!G.disabled&&e.jsx(Ig,{drag:{ids:[G.nodeId],asPage:!!G.own},label:G.label,title:S("menuBuilder.dragHint","Drag into the menu")}),G.icon!==void 0&&e.jsx("span",{className:"nice-menu-builder__icon","aria-hidden":"true",children:typeof G.icon=="string"?c(G.icon):G.icon}),e.jsx("span",{className:"nice-menu-builder__label",children:G.label}),G.own&&e.jsx("span",{className:"nice-menu-builder__hint",children:S("menuBuilder.ownPage","(page)")})]})}],[S,k,c]),re=B?It(j,B)?.node:void 0,Y=ne=>!ne.ref||ne.children!==void 0,oe=ne=>It(j,ne)?.depth??0,q=(ne,G)=>{const Se=ne;!Se||!Array.isArray(Se.ids)||P(_d(j,t,Se.ids,G,{asPage:Se.asPage}))},se=()=>{let ne;if(re){const Se=It(j,re.id);Y(re)&&(o===void 0||(Se?.depth??0)+2<=o)?ne={parentId:re.id,index:re.children?.length??0}:Se&&(ne={parentId:Se.parentId,index:Se.index+1})}const G=jd(j,S("menuBuilder.newGroup","New group"),ne);P(G.menu),R(G.id),M(Se=>Se+1)},ce=ne=>{const G=It(j,ne.id);if(!G||G.index===0)return!1;const Se=G.siblings[G.index-1];return Y(Se)&&(o===void 0||G.depth+1+_a(ne)<=o)},le=re?It(j,re.id):void 0,J=ne=>{re&&P(ne(j,re.id))},me=()=>{if(!re||!le)return;const ne=le.siblings[le.index+1]??le.siblings[le.index-1];P(mi(j,re.id)),R(ne?.id??le.parentId)},je=ne=>{if(ne.icon)return c(ne.icon);const G=hs(ne,t);return typeof G?.icon=="string"?c(G.icon):G?.icon!==void 0?G.icon:e.jsx(l.NiceIcon,{name:ne.ref?"file":"folder",size:16})},ue=ne=>{re&&P(ka(j,re.id,G=>{const Se={...G,...ne};return Object.keys(ne).forEach(te=>{ne[te]===void 0&&delete Se[te]}),Se}))},F=re?hs(re,t):void 0,H=re?.ref?bd(t,re.ref):void 0,A=F?.label,Z=F?[...vd(t,F.id),F.label].join(" / "):"",fe=re?(d??(ne=>e.jsx(Dg,{...ne,renderIcon:c})))({value:re.icon,onChange:ne=>ue({icon:ne})}):null,Ne=r.useMemo(()=>p?kd(j,t,{renderIcon:c,otherLabel:S("menuBuilder.other","Other"),source:{id:"menu-preview",label:S("menuBuilder.preview","Preview")}}):[],[p,j,t,c,S]);if(N==="hidden")return null;const K=(ne,G,Se,te,we)=>e.jsx(Fe.NiceButton,{variant:"ghost",size:"sm",ariaLabel:G,title:G,disabled:!te,onClick:we,children:e.jsx(l.NiceIcon,{name:Se,size:16})},ne),Q=!k;return e.jsx(Be.TreeDragSessionProvider,{children:e.jsx("div",{id:y,title:C,"data-testid":E,className:["nice-menu-builder",_?"nice-menu-builder--disabled":"",g??""].filter(Boolean).join(" "),style:{...u!==void 0?{height:u}:{},...v},"aria-disabled":_||void 0,children:e.jsxs("div",{className:"nice-menu-builder__grid",children:[e.jsxs("section",{className:"nice-menu-builder__column nice-menu-builder__column--catalog","aria-label":S("menuBuilder.catalog","Available views"),children:[e.jsx("header",{className:"nice-menu-builder__head",children:e.jsx("span",{className:"nice-menu-builder__title",children:S("menuBuilder.catalog","Available views")})}),e.jsx("div",{className:"nice-menu-builder__body nice-menu-builder__body--flush",children:e.jsx(ft.NiceTreeGrid,{data:O,nested:!0,keyField:"key",columns:U,checkable:!0,checkStrategy:"leaves",checkedKeys:L,onCheckedChange:z,isRowCheckable:ne=>ne.placeable,isRowDisabled:ne=>!!ne.disabled,getRowLabel:ne=>ne.label,defaultExpandedKeys:ee,searchable:!0,searchPlaceholder:S("menuBuilder.searchViews","Search views"),searchFields:["label"],toolbarActions:["onlyChecked"],showSelectAll:!1,size:x,compact:!0,readOnly:k,emptyText:S("menuBuilder.catalogEmpty","No views to choose from")})})]}),e.jsxs("section",{className:"nice-menu-builder__column nice-menu-builder__column--menu","aria-label":S("menuBuilder.menu","Menu"),children:[e.jsxs("header",{className:"nice-menu-builder__head",children:[e.jsx("span",{className:"nice-menu-builder__title",children:S("menuBuilder.menu","Menu")}),Q&&e.jsxs("span",{className:"nice-menu-builder__tools",role:"group","aria-label":S("menuBuilder.tools","Menu tools"),children:[K("group",S("menuBuilder.addGroup","New group"),"folder",!0,se),K("up",S("sortableTree.moveUp","Move up"),"chevron-up",!!le&&le.index>0,()=>J((ne,G)=>ms(ne,G,-1))),K("down",S("sortableTree.moveDown","Move down"),"chevron-down",!!le&&le.index<le.siblings.length-1,()=>J((ne,G)=>ms(ne,G,1))),K("indent",S("sortableTree.indent","Indent"),"indent",!!re&&ce(re),()=>J(Jr)),K("outdent",S("sortableTree.outdent","Outdent"),"outdent",!!le&&le.parentId!==null,()=>J(Qr)),K("remove",S("sortableTree.remove","Remove"),"trash",!!re,me)]}),h]}),e.jsx("div",{className:"nice-menu-builder__body",children:e.jsx(gd,{"aria-label":S("menuBuilder.menu","Menu"),value:j,onChange:ne=>P(ne),selectedId:B,onSelect:ne=>R(ne),getLabel:ne=>eo(ne,t),getIcon:ne=>je(ne),renderRowEnd:ne=>V.has(ne.id)?e.jsx("span",{className:"nice-menu-builder__badge",children:S("menuBuilder.unavailable","unavailable")}):null,canHaveChildren:Y,canDrop:(ne,G)=>G.parentId===null||o===void 0||ne!==null||oe(G.parentId)+2<=o,maxDepth:o,editable:Q,removable:Q,onExternalDrop:q,emptyText:S("menuBuilder.menuEmpty","Check views on the left or drag them here"),size:x,readOnly:k})})]}),e.jsxs("div",{className:"nice-menu-builder__side",children:[e.jsxs("section",{className:"nice-menu-builder__column nice-menu-builder__column--item","aria-label":S("menuBuilder.item","Item"),children:[e.jsxs("header",{className:"nice-menu-builder__head",children:[e.jsx("span",{className:"nice-menu-builder__title",children:S("menuBuilder.item","Item")}),re&&e.jsx("span",{className:"nice-menu-builder__kind",children:re.ref?S("menuBuilder.page","Page"):S("menuBuilder.group","Group")})]}),e.jsxs("div",{className:"nice-menu-builder__body nice-menu-builder__props",children:[!re&&e.jsx("p",{className:"nice-menu-builder__hint",children:S("menuBuilder.selectHint","Select an item of the menu to rename it or change its icon.")}),re&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"nice-menu-builder__field",ref:I,children:[e.jsx(Oe.NiceTextInput,{label:S("menuBuilder.name","Name"),size:"sm",value:re.label??"",placeholder:A??S("menuBuilder.newGroup","New group"),onChange:ne=>ue({label:ne.trim()?ne:void 0}),readOnly:k}),Q&&re.label&&A&&e.jsx(Fe.NiceButton,{variant:"ghost",size:"sm",ariaLabel:S("menuBuilder.resetName","Name from the catalog"),title:S("menuBuilder.resetName","Name from the catalog"),onClick:()=>ue({label:void 0}),children:e.jsx(l.NiceIcon,{name:"undo",size:16})})]}),e.jsxs("div",{className:"nice-menu-builder__field nice-menu-builder__field--icon",children:[e.jsx("span",{className:"nice-menu-builder__field-label",children:S("menuBuilder.icon","Icon")}),e.jsx("span",{className:"nice-menu-builder__icon-now","aria-hidden":"true",children:je(re)}),Q&&re.icon&&e.jsx(Fe.NiceButton,{variant:"ghost",size:"sm",ariaLabel:S("menuBuilder.resetIcon","Icon from the catalog"),title:S("menuBuilder.resetIcon","Icon from the catalog"),onClick:()=>ue({icon:void 0}),children:e.jsx(l.NiceIcon,{name:"undo",size:16})})]}),Q&&fe,(H?.route||Z)&&e.jsxs("dl",{className:"nice-menu-builder__facts",children:[H?.route&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:S("menuBuilder.route","Opens")}),e.jsx("dd",{children:e.jsx("code",{children:H.route})})]}),Z&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:S("menuBuilder.source","In the catalog")}),e.jsx("dd",{children:Z})]})]}),V.has(re.id)&&e.jsx("p",{className:"nice-menu-builder__warning",role:"note",children:S("menuBuilder.orphan","This view is no longer in the catalog — it will not show in the menu.")})]})]})]}),p&&e.jsxs("section",{className:"nice-menu-builder__column nice-menu-builder__column--preview","aria-label":S("menuBuilder.preview","Preview"),children:[e.jsx("header",{className:"nice-menu-builder__head",children:e.jsx("span",{className:"nice-menu-builder__title",children:S("menuBuilder.preview","Preview")})}),e.jsx("div",{className:"nice-menu-builder__body nice-menu-builder__body--flush",children:e.jsx(Be.NiceSidebarNav,{data:Ne,minimal:!0,readonly:!0,contextMenu:!1,preferences:Sg,...m})})]})]})]})})})},Td=r.createContext(null),Ag=({children:t,type:n="single",value:i,defaultValue:a,disabled:s=!1,onChange:o,className:c="",style:d,testId:p,"data-testid":m})=>{const[h,u]=r.useState(a??(n==="single"?"":[])),x=i!==void 0,f=x?i:h,b=r.useCallback(y=>n==="single"?f===y:Array.isArray(f)&&f.includes(y),[n,f]),g=r.useCallback(y=>{let C;if(n==="single")C=f===y?"":y;else{const w=Array.isArray(f)?f:[];C=w.includes(y)?w.filter(E=>E!==y):[...w,y]}x||u(C),o?.(C)},[n,f,x,o]),v=r.useMemo(()=>({type:n,isPressed:b,toggle:g,disabled:s}),[n,b,g,s]);return e.jsx(Td.Provider,{value:v,children:e.jsx("div",{role:"group",className:`nice-toggle-group nice-toggle-group--${n} ${c}`,style:d,"data-testid":m??p,children:t})})},Rg=Object.assign(({value:t,children:n,disabled:i=!1})=>{const a=r.useContext(Td);if(!a)throw new Error("NiceToggleGroup.Item must be rendered inside <NiceToggleGroup>");const s=a.isPressed(t),o=a.disabled||i;return e.jsx("button",{type:"button",className:`nice-toggle-group__item ${s?"nice-toggle-group__item--pressed":""}`,"aria-pressed":s,disabled:o,onClick:()=>a.toggle(t),children:n})},{displayName:"NiceToggleGroup.Item"}),yr=Object.assign(Ag,{displayName:"NiceToggleGroup",Item:Rg}),$g=["daily","weekly","monthly","yearly"],Mg={daily:"Daily",weekly:"Weekly",monthly:"Monthly",yearly:"Yearly"},Og={daily:"Repeat every (days)",weekly:"Repeat every (weeks)",monthly:"Repeat every (months)",yearly:"Repeat every (years)"},Lg={daily:{single:"Every day",other:"Every {n} days"},weekly:{single:"Every week",other:"Every {n} weeks"},monthly:{single:"Every month",other:"Every {n} months"},yearly:{single:"Every year",other:"Every {n} years"}},mc=10,Ed=864e5,zg=new Date(2023,0,1);function hc(t,n){try{return new Intl.PluralRules(t).select(n)}catch{return n===1?"one":"other"}}function Nr(t,n,i){const a=new Date(zg.getTime()+n*Ed);try{return new Intl.DateTimeFormat(t,{weekday:i}).format(a)}catch{return new Intl.DateTimeFormat("en",{weekday:i}).format(a)}}function Id(t,n){try{return new Intl.DateTimeFormat(t,n)}catch{return new Intl.DateTimeFormat("en",n)}}function gc(t){const n=i=>String(i).padStart(2,"0");return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}`}function Bg(t,n,i,a){const s=Math.max(1,Math.floor(t.interval??1)),o=Lg[t.freq],c=[s===1?n(`recurrence.summary.${t.freq}.single`,o.single):n(`recurrence.summary.${t.freq}.${hc(i,s)}`,o.other).replace("{n}",String(s))];if(t.freq==="weekly"&&t.byDay?.length&&c.push(a.filter(d=>t.byDay?.includes(d)).map(d=>Nr(i,d,"short")).join(", ")),t.count&&t.count>0)c.push(n(`recurrence.summary.times.${hc(i,t.count)}`,t.count===1?"once":"{n} times").replace("{n}",String(t.count)));else if(t.until){const d=Id(i,{day:"numeric",month:"short",year:"numeric"});c.push(`${n("recurrence.summary.until","until")} ${d.format(new Date(t.until))}`)}return c.join(" · ")}const Fg=({value:t,defaultValue:n=null,onChange:i,start:a,allowNone:s=!0,previewCount:o=5,weekStartsOn:c=1,label:d,size:p="md",disabled:m=!1,readOnly:h=!1,className:u="",style:x,id:f,accessMode:b,"data-testid":g})=>{const{t:v,lang:y}=l.useNiceTranslation(),C=l.useNiceAccessMode(b,f),[w,E]=l.useControllableState({value:t,defaultValue:n,onChange:i,componentName:"NiceRecurrenceEditor"}),[S]=r.useState(()=>new Date),N=a??S,_=m||h||C==="disabled"||C==="readOnly",k=l.normalizeSize(p),j=k==="xxs"||k==="xs"?k:"sm",T=r.useMemo(()=>Array.from({length:7},(L,V)=>(V+c)%7),[c]),P=r.useMemo(()=>{if(!w||o<=0)return[];const L=new Date(N.getTime()+100*365*Ed);return At.recurrenceDates(w,N,L,o)},[w,N,o]);if(C==="hidden")return null;const B=L=>{w&&E({...w,...L})},R=L=>{if(L==="none"){E(null);return}const V=L,ee=w?{...w,freq:V}:{freq:V,interval:1};V==="weekly"?ee.byDay=w?.byDay?.length?w.byDay:[N.getDay()]:delete ee.byDay,E(ee)},I=w?.count?"after":w?.until?"on":"never",D=L=>{if(!w)return;const V={...w};if(delete V.count,delete V.until,L==="after")E({...V,count:mc});else if(L==="on"){const ee=new Date(N);ee.setMonth(ee.getMonth()+3),E({...V,until:ee})}else E(V)},M=[...s?[{value:"none",label:v("recurrence.freq.none","Does not repeat")}]:[],...$g.map(L=>({value:L,label:v(`recurrence.freq.${L}`,Mg[L])}))],O=Id(y,{weekday:"short",day:"numeric",month:"short",year:"numeric"});return e.jsxs("div",{id:f,className:`nice-recurrence nice-recurrence--${k} ${u}`,style:x,"data-testid":g,children:[e.jsx(Oe.NiceSelect,{size:j,label:d??v("recurrence.frequency","Repeats"),value:w?w.freq:"none",options:M,onChange:L=>R(Array.isArray(L)?L[0]??"none":L),disabled:_}),w&&e.jsxs(e.Fragment,{children:[e.jsx(Oe.NiceNumberInput,{size:j,className:"nice-recurrence__interval",label:v(`recurrence.interval.${w.freq}`,Og[w.freq]),min:1,max:999,value:w.interval??1,onChange:L=>B({interval:Math.max(1,Math.round(L??1))}),disabled:_}),w.freq==="weekly"&&e.jsxs("div",{className:"nice-recurrence__days",role:"group","aria-label":v("recurrence.days","On days"),children:[e.jsx("span",{className:"nice-recurrence__caption",children:v("recurrence.days","On days")}),e.jsx(yr,{type:"multiple",disabled:_,value:(w.byDay??[]).map(String),onChange:L=>{const V=(Array.isArray(L)?L:[L]).map(Number);V.length>0&&B({byDay:V.sort((ee,z)=>ee-z)})},children:T.map(L=>e.jsx(yr.Item,{value:String(L),children:e.jsx("span",{title:Nr(y,L,"long"),children:Nr(y,L,"short")})},L))})]}),e.jsxs("div",{className:"nice-recurrence__ends",children:[e.jsx(dt.NiceRadioGroup,{size:j,label:v("recurrence.endsLabel","Ends"),direction:"vertical",value:I,onChange:D,disabled:_,options:[{value:"never",label:v("recurrence.ends.never","Never")},{value:"on",label:v("recurrence.ends.on","On a date")},{value:"after",label:v("recurrence.ends.after","After a number of occurrences")}]}),I==="on"&&w.until&&e.jsx(dt.NiceDateTimePicker,{size:j,label:v("recurrence.endDate","End date"),dateFormatPreset:"date-local",value:gc(new Date(w.until)),min:gc(N),onChange:L=>{const[V,ee,z]=L.split("-").map(Number);V&&ee&&z&&B({until:new Date(V,ee-1,z,23,59,59)})},disabled:_}),I==="after"&&e.jsx(Oe.NiceNumberInput,{size:j,className:"nice-recurrence__count",label:v("recurrence.count","Occurrences"),min:1,max:9999,value:w.count??mc,onChange:L=>B({count:Math.max(1,Math.round(L??1))}),disabled:_})]}),e.jsx("p",{className:"nice-recurrence__summary","aria-live":"polite",children:Bg(w,v,y,T)}),P.length>0&&e.jsxs("div",{className:"nice-recurrence__preview",children:[e.jsx("span",{className:"nice-recurrence__caption",children:v("recurrence.next","Next dates")}),e.jsx("ol",{className:"nice-recurrence__dates",children:P.map(L=>e.jsx("li",{children:e.jsx("time",{dateTime:L.toISOString(),children:O.format(L)})},L.getTime()))})]})]})]})};function qg(t,n=1){let i;if(typeof t.quantity=="number"){const s=t.quantity*n;i=Number.isInteger(s)?String(s):String(Math.round(s*100)/100)}else i=t.quantity!=null?String(t.quantity):"";const a=t.unit??"";return[i,a].filter(Boolean).join(" ").trim()}const Vg=({photos:t})=>{const{t:n}=l.useNiceTranslation(),i=[...t].sort((c,d)=>+!!d.primary-+!!c.primary),[a,s]=r.useState(i[0]?.id),o=i.find(c=>c.id===a)??i[0];return e.jsxs("div",{className:"nice-recipe__gallery",children:[o&&e.jsxs("div",{className:"nice-recipe__photo-main",children:[e.jsx("img",{src:o.url,alt:o.caption??""}),o.caption&&e.jsx("div",{className:"nice-recipe__photo-caption",children:o.caption})]}),i.length>1&&e.jsx("div",{className:"nice-recipe__photo-thumbs",children:i.map(c=>e.jsx("button",{type:"button",className:`nice-recipe__thumb${c.id===o?.id?" nice-recipe__thumb--active":""}`,onClick:()=>s(c.id),"aria-label":c.caption??n("recipe.photo","Photo"),children:e.jsx("img",{src:c.url,alt:c.caption??""})},c.id))})]})},Ug=({recipe:t,compact:n=!1,hidePhotos:i=!1,hideIngredients:a=!1,hideSteps:s=!1,onIngredientToggle:o,onStepToggle:c,className:d,style:p,accessMode:m,id:h,"data-testid":u})=>{const{t:x}=l.useNiceTranslation(),f=l.useNiceAccessMode(m,h),b=t.servings,[g,v]=r.useState(b);if(r.useEffect(()=>{v(b)},[b]),f==="hidden")return null;const y=f==="readOnly"||f==="disabled",C=At.recipeTotalMinutes(t),w=t.photos??[],E=[...t.steps].sort((k,j)=>k.order-j.order),S=!y&&typeof b=="number"&&b>0&&typeof g=="number"&&g>0?g/b:1,N=!n&&typeof b=="number"&&b>0&&!y,_=()=>{typeof window<"u"&&window.print()};return e.jsxs("div",{className:`nice-recipe${n?" nice-recipe--compact":""} ${d??""}`,style:p,"data-testid":u,children:[e.jsxs("header",{className:"nice-recipe__header",children:[e.jsx("h3",{className:"nice-recipe__title",children:t.title||x("recipe.untitled","Untitled recipe")}),!n&&t.description&&e.jsx("p",{className:"nice-recipe__description",children:t.description}),e.jsxs("div",{className:"nice-recipe__meta",children:[t.servings!=null&&e.jsxs("span",{className:"nice-recipe__meta-item",children:[e.jsx(l.NiceIcon,{name:"box",size:14})," ",g??t.servings," ",x("recipe.servings","servings")]}),C!=null&&e.jsxs("span",{className:"nice-recipe__meta-item",children:[e.jsx(l.NiceIcon,{name:"clock",size:14})," ",C," ",x("recipe.minutes","min")]}),t.difficulty&&e.jsx("span",{className:`nice-recipe__badge nice-recipe__badge--${t.difficulty}`,children:x(`recipe.difficulty.${t.difficulty}`,t.difficulty)}),t.cuisine&&e.jsxs("span",{className:"nice-recipe__meta-item",children:[e.jsx(l.NiceIcon,{name:"globe",size:14})," ",t.cuisine]}),t.sourceUrl&&e.jsxs("a",{className:"nice-recipe__meta-item nice-recipe__source",href:t.sourceUrl,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(l.NiceIcon,{name:"link",size:14})," ",x("recipe.source","Source")]})]}),(N||!n)&&e.jsxs("div",{className:"nice-recipe__actions",children:[N&&e.jsxs("span",{className:"nice-recipe__servings-stepper",children:[e.jsx("button",{type:"button",className:"nice-recipe__servings-btn","aria-label":x("recipe.servingsDecrease","Decrease servings"),onClick:()=>v(k=>Math.max(1,(k??b??1)-1)),disabled:(g??b??1)<=1,children:"−"}),e.jsxs("span",{"aria-live":"polite",className:"nice-recipe__servings-value",children:[g??b," ×"]}),e.jsx("button",{type:"button",className:"nice-recipe__servings-btn","aria-label":x("recipe.servingsIncrease","Increase servings"),onClick:()=>v(k=>Math.min(99,(k??b??1)+1)),disabled:(g??b??1)>=99,children:"+"}),S!==1&&e.jsx("button",{type:"button",className:"nice-recipe__servings-reset",onClick:()=>v(b),children:x("recipe.reset","Reset")})]}),!n&&e.jsxs("button",{type:"button",className:"nice-recipe__print",onClick:_,"aria-label":x("recipe.print","Print recipe"),children:[e.jsx(l.NiceIcon,{name:"printer",size:14})," ",x("recipe.print","Print")]})]}),t.tags&&t.tags.length>0&&e.jsx("div",{className:"nice-recipe__tags",children:t.tags.map(k=>e.jsxs("span",{className:"nice-recipe__tag",children:["#",k]},k))})]}),!i&&w.length>0&&e.jsx(Vg,{photos:w}),e.jsxs("div",{className:"nice-recipe__body",children:[!a&&t.ingredients.length>0&&e.jsxs("section",{className:"nice-recipe__section nice-recipe__section--ingredients",children:[e.jsx("h4",{className:"nice-recipe__section-title",children:x("recipe.ingredients","Ingredients")}),e.jsx("ul",{className:"nice-recipe__ingredients",children:t.ingredients.map(k=>e.jsx("li",{className:"nice-recipe__ingredient",children:e.jsxs("label",{className:`nice-recipe__ingredient-row${k.checked?" nice-recipe__ingredient-row--checked":""}`,children:[e.jsx("input",{type:"checkbox",checked:!!k.checked,disabled:y||!o,onChange:()=>o?.(k)}),e.jsx("span",{className:"nice-recipe__ingredient-qty",children:qg(k,S)}),e.jsx("span",{className:"nice-recipe__ingredient-name",children:k.name}),k.notes&&e.jsxs("span",{className:"nice-recipe__ingredient-notes",children:["— ",k.notes]})]})},k.id))})]}),!s&&E.length>0&&e.jsxs("section",{className:"nice-recipe__section nice-recipe__section--steps",children:[e.jsx("h4",{className:"nice-recipe__section-title",children:x("recipe.steps","Steps")}),e.jsx("ol",{className:"nice-recipe__steps",children:E.map(k=>e.jsx("li",{className:`nice-recipe__step${k.done?" nice-recipe__step--done":""}`,children:e.jsxs("label",{className:"nice-recipe__step-row",children:[e.jsx("input",{type:"checkbox",checked:!!k.done,disabled:y||!c,onChange:()=>c?.(k)}),e.jsxs("div",{className:"nice-recipe__step-body",children:[e.jsx("div",{className:"nice-recipe__step-instruction",children:k.instruction}),k.durationMinutes!=null&&e.jsxs("div",{className:"nice-recipe__step-duration",children:[e.jsx(l.NiceIcon,{name:"clock",size:14})," ",k.durationMinutes," ",x("recipe.minutes","min")]}),k.image&&e.jsx("img",{className:"nice-recipe__step-image",src:k.image,alt:""})]})]})},k.id))})]})]}),!n&&t.nutrition&&e.jsxs("footer",{className:"nice-recipe__nutrition",children:[t.nutrition.calories!=null&&e.jsx("span",{children:x("recipe.kcal","{label}: {value} kcal").replace("{label}",x("recipe.nutrition.calories","Calories")).replace("{value}",String(t.nutrition.calories))}),t.nutrition.protein!=null&&e.jsxs("span",{children:[x("recipe.nutrition.protein","Protein"),": ",t.nutrition.protein," g"]}),t.nutrition.fat!=null&&e.jsxs("span",{children:[x("recipe.nutrition.fat","Fat"),": ",t.nutrition.fat," g"]}),t.nutrition.carbs!=null&&e.jsxs("span",{children:[x("recipe.nutrition.carbs","Carbs"),": ",t.nutrition.carbs," g"]}),t.nutrition.fiber!=null&&e.jsxs("span",{children:[x("recipe.nutrition.fiber","Fiber"),": ",t.nutrition.fiber," g"]}),t.nutrition.sugar!=null&&e.jsxs("span",{children:[x("recipe.nutrition.sugar","Sugar"),": ",t.nutrition.sugar," g"]}),t.nutrition.sodium!=null&&e.jsx("span",{children:x("recipe.mg","{label}: {value} mg").replace("{label}",x("recipe.nutrition.sodium","Sodium")).replace("{value}",String(t.nutrition.sodium))})]})]})},Hg=[],Gg=[{value:"",label:"All"},{value:"easy",label:"Easy"},{value:"medium",label:"Medium"},{value:"hard",label:"Hard"}],Dd=({recipes:t=Hg,onSelect:n,initialQuery:i="",hideFilters:a,emptyMessage:s,className:o,style:c,"data-testid":d})=>{const{t:p}=l.useNiceTranslation(),[m,h]=r.useState(i),[u,x]=r.useState(""),[f,b]=r.useState(""),g=r.useMemo(()=>{const y=new Set;for(const C of t)for(const w of C.tags??[])y.add(w);return Array.from(y).sort()},[t]),v=r.useMemo(()=>{const y=m.trim().toLowerCase();return t.filter(C=>u&&C.difficulty!==u||f&&!(C.tags??[]).includes(f)?!1:y?[C.title,C.description??"",C.cuisine??"",...C.tags??[]].join(" ").toLowerCase().includes(y):!0)},[t,m,u,f]);return e.jsxs("div",{className:`nice-recipe-list ${o??""}`,style:c,"data-testid":d,children:[e.jsxs("div",{className:"nice-recipe-list__toolbar",children:[e.jsx("input",{type:"search",className:"nice-recipe-list__search",value:m,placeholder:p("recipe.list.search","Search recipes…"),onChange:y=>h(y.target.value),"aria-label":p("recipe.list.search","Search recipes")}),!a&&e.jsxs(e.Fragment,{children:[e.jsx("select",{className:"nice-recipe-list__filter",value:u,onChange:y=>x(y.target.value),"aria-label":p("recipe.difficulty","Difficulty"),children:Gg.map(y=>e.jsx("option",{value:y.value,children:y.label},y.value||"all"))}),g.length>0&&e.jsxs("select",{className:"nice-recipe-list__filter",value:f,onChange:y=>b(y.target.value),"aria-label":p("recipe.tags","Tags"),children:[e.jsx("option",{value:"",children:p("recipe.list.allTags","All tags")}),g.map(y=>e.jsxs("option",{value:y,children:["#",y]},y))]})]}),e.jsxs("span",{className:"nice-recipe-list__count","aria-live":"polite",children:[v.length," / ",t.length]})]}),v.length===0?e.jsx("div",{className:"nice-recipe-list__empty",children:s??p("recipe.list.empty","No recipes match the current filters.")}):e.jsx("ul",{className:"nice-recipe-list__grid",children:v.map(y=>{const C=y.photos?.find(E=>E.primary)??y.photos?.[0],w=At.recipeTotalMinutes(y);return e.jsx("li",{className:"nice-recipe-list__item",children:e.jsxs("button",{type:"button",className:"nice-recipe-list__card",onClick:()=>n?.(y),children:[C&&e.jsx("span",{className:"nice-recipe-list__thumb",children:e.jsx("img",{src:C.url,alt:C.caption??y.title,loading:"lazy"})}),e.jsxs("span",{className:"nice-recipe-list__body",children:[e.jsx("span",{className:"nice-recipe-list__title",children:y.title}),y.description&&e.jsx("span",{className:"nice-recipe-list__desc",children:y.description}),e.jsxs("span",{className:"nice-recipe-list__meta",children:[typeof y.servings=="number"&&e.jsxs("span",{className:"nice-recipe-list__meta-item",children:[e.jsx(l.NiceIcon,{name:"utensils",size:12})," ",y.servings]}),w!=null&&w>0&&e.jsxs("span",{className:"nice-recipe-list__meta-item",children:[e.jsx(l.NiceIcon,{name:"clock",size:12})," ",p("recipe.min","{total} min").replace("{total}",String(w))]}),y.difficulty&&e.jsx("span",{className:`nice-recipe__badge nice-recipe__badge--${y.difficulty}`,children:y.difficulty})]}),y.tags&&y.tags.length>0&&e.jsx("span",{className:"nice-recipe-list__tags",children:y.tags.slice(0,4).map(E=>e.jsxs("span",{className:"nice-recipe__tag",children:["#",E]},E))})]})]})},y.id)})})]})},Wg=[],Kg=[],Yg=["breakfast","lunch","dinner"],Jg=1440*60*1e3;function Qg(t){const n=new Date(t);n.setHours(0,0,0,0);const i=n.getDay(),a=i===0?-6:1-i;return n.setDate(n.getDate()+a),n}function bc(t,n){return t.getFullYear()===n.getFullYear()&&t.getMonth()===n.getMonth()&&t.getDate()===n.getDate()}const Xg=({recipes:t=Wg,meals:n=Kg,onChange:i,weekStart:a,rows:s=Yg,readOnly:o,className:c,style:d,"data-testid":p})=>{const{t:m,lang:h}=l.useNiceTranslation(),u=r.useMemo(()=>Qg(a??new Date),[a]),x=r.useMemo(()=>Array.from({length:7},(E,S)=>new Date(u.getTime()+S*Jg)),[u]),f=r.useMemo(()=>{const E=new Map;for(const S of t)E.set(S.id,S);return E},[t]),b=r.useCallback((E,S)=>n.filter(N=>N.kind===S&&N.servedAt instanceof Date&&bc(N.servedAt,E)),[n]),g=r.useCallback((E,S,N)=>{if(!N||o)return;const _=f.get(N),k=new Date(E);k.setHours(S==="breakfast"?8:S==="lunch"?13:S==="dinner"?19:16,0,0,0);const j={id:At.newRecipeId("meal"),name:_?.title??m("mealplan.untitled","Meal"),kind:S,servedAt:k,recipeIds:[N],servings:_?.servings};i?.([...n,j])},[n,i,o,f,m]),v=r.useCallback(E=>{o||i?.(n.filter(S=>S.id!==E))},[n,i,o]),y=E=>E.toLocaleDateString(h,{weekday:"short",day:"numeric",month:"short"}),C=E=>m(`mealplan.kind.${E}`,E.charAt(0).toUpperCase()+E.slice(1)),w=new Date;return e.jsx("div",{className:`nice-mealplan ${c??""}`,style:d,"data-testid":p,children:e.jsxs("div",{className:"nice-mealplan__grid",style:{gridTemplateColumns:"auto repeat(7, minmax(8rem, 1fr))"},children:[e.jsx("div",{className:"nice-mealplan__corner"}),x.map(E=>e.jsx("div",{className:`nice-mealplan__day-head${bc(E,w)?" nice-mealplan__day-head--today":""}`,children:y(E)},E.toISOString())),s.map(E=>e.jsxs(r.Fragment,{children:[e.jsx("div",{className:"nice-mealplan__row-head",children:C(E)}),x.map(S=>{const N=b(S,E);return e.jsxs("div",{className:"nice-mealplan__cell",children:[N.map(_=>{const k=_.recipeIds[0]?f.get(_.recipeIds[0]):void 0;return e.jsxs("div",{className:"nice-mealplan__chip",title:_.name,children:[e.jsx("span",{className:"nice-mealplan__chip-title",children:k?.title??_.name}),!o&&e.jsx("button",{type:"button",className:"nice-mealplan__chip-remove","aria-label":m("mealplan.remove","Remove meal"),onClick:()=>v(_.id),children:e.jsx(l.NiceIcon,{name:"close",size:14})})]},_.id)}),!o&&t.length>0&&e.jsxs("select",{className:"nice-mealplan__add",value:"","aria-label":m("mealplan.addRecipe","Add recipe"),onChange:_=>{const k=_.target.value;k&&g(S,E,k),_.target.value=""},children:[e.jsxs("option",{value:"",children:["+ ",m("mealplan.add","Add")]}),t.map(_=>e.jsx("option",{value:_.id,children:_.title},_.id))]})]},`${E}-${S.toISOString()}`)})]},E))]})})},Zg=[],eb=[],tb=({recipes:t=Zg,collections:n=eb,onChange:i,readOnly:a,onSelectRecipe:s,className:o,style:c,"data-testid":d})=>{const{t:p}=l.useNiceTranslation(),{prompt:m,element:h}=_t.useNiceDialogs(),[u,x]=r.useState(n[0]?.id??null),[f,b]=r.useState(null),g=r.useMemo(()=>{const j=new Map;for(const T of t)j.set(T.id,T);return j},[t]),v=r.useMemo(()=>n.find(j=>j.id===u)??n[0]??null,[n,u]),y=r.useMemo(()=>v?v.recipeIds.map(j=>g.get(j)).filter(j=>!!j):[],[v,g]),C=r.useCallback(j=>{i?.(j)},[i]),w=r.useCallback(()=>{a||m({title:p("collections.namePrompt","Collection name")}).then(j=>{if(!j||!j.trim())return;const T={id:At.newRecipeId("coll"),name:j.trim(),recipeIds:[]};C([...n,T]),x(T.id)})},[n,a,p,C,m]),E=r.useCallback(j=>{if(a)return;const T=n.filter(P=>P.id!==j);C(T),u===j&&x(T[0]?.id??null)},[u,n,a,C]),S=r.useCallback(()=>{if(!f)return;const j=f.value.trim();j&&C(n.map(T=>T.id===f.id?{...T,name:j}:T)),b(null)},[n,f,C]),N=r.useCallback(j=>{!v||!j||a||v.recipeIds.includes(j)||C(n.map(T=>T.id===v.id?{...T,recipeIds:[...T.recipeIds,j]}:T))},[v,n,a,C]),_=r.useCallback(j=>{!v||a||C(n.map(T=>T.id===v.id?{...T,recipeIds:T.recipeIds.filter(P=>P!==j)}:T))},[v,n,a,C]),k=r.useMemo(()=>v?t.filter(j=>!v.recipeIds.includes(j.id)):[],[v,t]);return e.jsxs("div",{className:`nice-recipe-collections ${o??""}`,style:c,"data-testid":d,children:[h,e.jsxs("aside",{className:"nice-recipe-collections__sidebar",children:[e.jsxs("div",{className:"nice-recipe-collections__sidebar-head",children:[e.jsx("span",{className:"nice-recipe-collections__sidebar-title",children:p("collections.title","Collections")}),!a&&e.jsx("button",{type:"button",className:"nice-recipe-collections__sidebar-add",onClick:w,"aria-label":p("collections.create","Create collection"),children:e.jsx(l.NiceIcon,{name:"plus",size:14})})]}),e.jsx("ul",{className:"nice-recipe-collections__list",children:n.map(j=>{const T=v?.id===j.id,P=f?.id===j.id;return e.jsxs("li",{className:`nice-recipe-collections__item${T?" nice-recipe-collections__item--active":""}`,children:[P?e.jsx("input",{autoFocus:!0,className:"nice-recipe-collections__rename",value:f.value,onChange:B=>b({id:j.id,value:B.target.value}),onBlur:S,onKeyDown:B=>{B.key==="Enter"?S():B.key==="Escape"&&b(null)}}):e.jsxs("button",{type:"button",className:"nice-recipe-collections__item-btn",onClick:()=>x(j.id),onDoubleClick:()=>!a&&b({id:j.id,value:j.name}),children:[e.jsx("span",{className:"nice-recipe-collections__item-name",children:j.name}),e.jsx("span",{className:"nice-recipe-collections__item-count",children:j.recipeIds.length})]}),!a&&!P&&e.jsx("button",{type:"button",className:"nice-recipe-collections__item-remove",onClick:()=>E(j.id),"aria-label":p("collections.delete","Delete collection"),title:p("collections.delete","Delete collection"),children:e.jsx(l.NiceIcon,{name:"close",size:14})})]},j.id)})})]}),e.jsx("section",{className:"nice-recipe-collections__main",children:v?e.jsxs(e.Fragment,{children:[e.jsxs("header",{className:"nice-recipe-collections__header",children:[e.jsx("h3",{className:"nice-recipe-collections__name",children:v.name}),!a&&k.length>0&&e.jsxs("select",{className:"nice-recipe-collections__add-recipe",value:"","aria-label":p("collections.addRecipe","Add recipe"),onChange:j=>{const T=j.target.value;T&&N(T),j.target.value=""},children:[e.jsxs("option",{value:"",children:["+ ",p("collections.addRecipe","Add recipe")]}),k.map(j=>e.jsx("option",{value:j.id,children:j.title},j.id))]})]}),y.length===0?e.jsx("div",{className:"nice-recipe-collections__empty",children:p("collections.empty","No recipes in this collection yet.")}):e.jsx(Dd,{recipes:y,hideFilters:!0,onSelect:j=>s?.(j)}),!a&&y.length>0&&e.jsxs("details",{className:"nice-recipe-collections__manage",children:[e.jsx("summary",{children:p("collections.manage","Manage recipes")}),e.jsx("ul",{className:"nice-recipe-collections__manage-list",children:y.map(j=>e.jsxs("li",{children:[e.jsx("span",{children:j.title}),e.jsx("button",{type:"button",onClick:()=>_(j.id),"aria-label":p("collections.removeRecipe","Remove recipe from collection"),children:p("collections.removeShort","Remove")})]},j.id))})]})]}):e.jsx("div",{className:"nice-recipe-collections__empty",children:p("collections.emptyState","No collection selected.")})})]})},nb=[],ki=["hour","day","week","month","quarter","year"],ib=t=>{switch(t){case"hour":return{msPerPixel:6e4,unitMs:36e5,unitLabel:"HH:mm",headerFormat:"MMM d, yyyy"};case"day":return{msPerPixel:36e5,unitMs:864e5,unitLabel:"d",headerFormat:"MMM yyyy"};case"week":return{msPerPixel:864e5/2,unitMs:6048e5,unitLabel:"W",headerFormat:"MMM yyyy"};case"month":return{msPerPixel:864e5*2,unitMs:2592e6,unitLabel:"MMM",headerFormat:"yyyy"};case"quarter":return{msPerPixel:864e5*7,unitMs:7776e6,unitLabel:"Q",headerFormat:"yyyy"};case"year":return{msPerPixel:864e5*30,unitMs:31536e6,unitLabel:"yyyy",headerFormat:""};default:return{msPerPixel:864e5,unitMs:864e5,unitLabel:"d",headerFormat:"MMM yyyy"}}},Ci=(t,n,i="pl-PL")=>{const a={};if(n.includes("yyyy")&&(a.year="numeric"),n.includes("MMM")&&(a.month="short"),n.includes("MM")&&!n.includes("MMM")&&(a.month="2-digit"),(n.includes("dd")||n.includes("d"))&&(a.day="2-digit"),n.includes("EEE")&&(a.weekday="short"),n.includes("HH")&&(a.hour="2-digit",a.hour12=!1),n.includes("mm")&&!n.includes("MMM")&&(a.minute="2-digit"),n==="W")return`T${ab(t)}`;if(n==="Q")return`Q${Math.ceil((t.getMonth()+1)/3)}`;const s=a.year||a.month||a.day||a.weekday;return(a.hour||a.minute)&&!s?t.toLocaleTimeString(i,a):t.toLocaleDateString(i,a)},ab=t=>{const n=new Date(t);n.setHours(0,0,0,0),n.setDate(n.getDate()+4-(n.getDay()||7));const i=new Date(n.getFullYear(),0,1);return Math.ceil(((n.getTime()-i.getTime())/864e5+1)/7)},fc=(t,n)=>new Date(t.getTime()+n),sb=["var(--nice-color-primary, #3b82f6)","var(--nice-color-error, #ef4444)","var(--nice-color-success, #22c55e)","var(--nice-color-warning, #f59e0b)","var(--nice-color-accent, #8b5cf6)","var(--nice-color-accent-pink, #ec4899)","var(--nice-color-info, #06b6d4)","var(--nice-success, #84cc16)","var(--nice-warning, #f97316)","var(--nice-color-accent, #6366f1)"],rb=Object.assign(r.forwardRef((t,n)=>{const{t:i}=l.useNiceTranslation(),{events:a=nb,groups:s=[],markers:o=[],initialZoom:c="week",initialDate:d,width:p=800,height:m=400,showToday:h=!0,showZoomControls:u=!0,showNavControls:x=!0,showMinimap:f=!1,onEventClick:b,onEventHover:g,onDateChange:v,onZoomChange:y,renderEvent:C,colors:w=sb,locale:E="pl-PL",className:S,style:N,..._}=t,[k,j]=r.useState(c),[T,P]=r.useState(d||new Date),[B,R]=r.useState(!1),[I,D]=r.useState({x:0,date:new Date}),[M,O]=r.useState(null),[L,V]=r.useState(new Set),ee=r.useRef(null),z=r.useMemo(()=>ib(k),[k]),U=p*z.msPerPixel,re=T.getTime()-U/2,Y=T.getTime()+U/2,oe=r.useMemo(()=>new Date(re),[re]),q=r.useMemo(()=>new Date(Y),[Y]),se=r.useCallback(W=>(W.getTime()-oe.getTime())/z.msPerPixel,[oe,z.msPerPixel]);r.useCallback(W=>{const be=W*z.msPerPixel;return new Date(oe.getTime()+be)},[oe,z.msPerPixel]);const ce=r.useMemo(()=>{const W=[];let be=new Date(oe);switch(k){case"hour":be.setMinutes(0,0,0);break;case"day":be.setHours(0,0,0,0);break;case"week":{const Te=be.getDay();be.setDate(be.getDate()-Te+1),be.setHours(0,0,0,0);break}case"month":be.setDate(1),be.setHours(0,0,0,0);break;case"quarter":be.setMonth(Math.floor(be.getMonth()/3)*3),be.setDate(1),be.setHours(0,0,0,0);break;case"year":be.setMonth(0,1),be.setHours(0,0,0,0);break}for(;be<=q;){const Te=se(be),Me=k==="day"?be.getDay()===1:k==="week"?be.getDate()===1:k==="month"?be.getMonth()%3===0:k==="quarter"?be.getMonth()===0:!0;W.push({date:new Date(be),x:Te,isMain:Me,isWeekend:k==="day"&&(be.getDay()===0||be.getDay()===6)}),be=fc(be,z.unitMs)}return W},[oe,q,k,z,se]),le=r.useMemo(()=>{const W=z.unitMs/z.msPerPixel;return W<=0?1:Math.max(1,Math.ceil(40/W))},[z]),J=r.useMemo(()=>{const W=new Map;return W.set("__default",[]),s.forEach(be=>W.set(be.id,[])),a.forEach(be=>{const Te=be.group&&W.has(be.group)?be.group:"__default",Me=W.get(Te)||[];Me.push(be),W.set(Te,Me)}),W},[a,s]),me=r.useMemo(()=>{const W=[];return J.get("__default")?.length&&W.push({id:"__default",title:"",events:J.get("__default")||[],isGroup:!1}),s.forEach(be=>{L.has(be.id)||W.push({id:be.id,title:be.title,events:J.get(be.id)||[],isGroup:!0})}),W},[J,s,L]),je=r.useCallback(W=>{P(W),v?.(W)},[v]),ue=r.useCallback(()=>{const W=ki.indexOf(k);if(W>0){const be=ki[W-1];j(be),y?.(be)}},[k,y]),F=r.useCallback(()=>{const W=ki.indexOf(k);if(W<ki.length-1){const be=ki[W+1];j(be),y?.(be)}},[k,y]),H=r.useCallback(W=>{j(W),y?.(W)},[y]),A=r.useCallback(W=>{const be=fc(T,W*U*.5);je(be)},[T,U,je]),Z=r.useCallback(W=>{W.button===0&&(R(!0),D({x:W.clientX,date:T}))},[T]),fe=r.useCallback(W=>{if(!B)return;const Te=(I.x-W.clientX)*z.msPerPixel,Me=new Date(I.date.getTime()+Te);P(Me)},[B,I,z.msPerPixel]),Ne=r.useCallback(()=>{B&&(R(!1),v?.(T))},[B,T,v]),K=r.useCallback(W=>{W.preventDefault(),W.deltaY<0?ue():F()},[ue,F]),Q=r.useCallback(W=>{O(W),g?.(W)},[g]),ne=r.useCallback(()=>{O(null),g?.(null)},[g]),G=r.useRef(null);l.useRovingFocus(G,{orientation:"grid",itemSelector:".nice-timeline-event, .nice-timeline-milestone"});const Se=W=>be=>{(be.key==="Enter"||be.key===" ")&&(be.preventDefault(),b?.(W))};r.useImperativeHandle(n,()=>({goToDate:je,zoomIn:ue,zoomOut:F,setZoom:H,getCurrentDate:()=>T,getCurrentZoom:()=>k}),[je,ue,F,H,T,k]);const te=40,we=60,ie=Math.max(me.length*te,m-we-40),xe=se(new Date);return e.jsxs("div",{className:`nice-timeline ${S||""}`,style:{width:p,...N},..._,children:[e.jsxs("div",{className:"nice-timeline-toolbar",children:[x&&e.jsx("div",{className:"nice-timeline-nav",children:e.jsxs(At.NiceButtonGroup,{size:"sm",children:[e.jsx(Fe.NiceButton,{onClick:()=>A(-1),"aria-label":i("planning.previous","Previous"),children:e.jsx(l.NiceIcon,{name:"chevron-left",size:14})}),e.jsx(Fe.NiceButton,{onClick:()=>je(new Date),children:i("scheduling.today","Today")}),e.jsx(Fe.NiceButton,{onClick:()=>A(1),"aria-label":i("planning.next","Next"),children:e.jsx(l.NiceIcon,{name:"chevron-right",size:14})})]})}),e.jsx("div",{className:"nice-timeline-center",children:e.jsxs("span",{className:"nice-timeline-range",children:[Ci(oe,"MMM d, yyyy",E)," —"," ",Ci(q,"MMM d, yyyy",E)]})}),u&&e.jsx("div",{className:"nice-timeline-zoom",children:e.jsx(At.NiceButtonGroup,{size:"sm",children:ki.map(W=>e.jsx(Fe.NiceButton,{variant:k===W?"primary":"secondary",onClick:()=>H(W),children:W==="hour"?i("planning.hourShort","hr"):W==="day"?i("planning.dayShort","day"):W==="week"?i("planning.weekShort","wk"):W==="month"?i("planning.monthShort","mo"):W==="quarter"?i("planning.quarterShort","qtr"):i("planning.yearShort","yr")},W))})})]}),e.jsxs("div",{ref:ee,className:"nice-timeline-container",onMouseDown:Z,onMouseMove:fe,onMouseUp:Ne,onMouseLeave:Ne,onWheel:K,style:{cursor:B?"grabbing":"grab"},children:[e.jsxs("div",{className:"nice-timeline-header",style:{height:we},children:[e.jsx("div",{className:"nice-timeline-header-main",children:z.headerFormat&&e.jsx("span",{children:Ci(T,z.headerFormat,E)})}),e.jsx("div",{className:"nice-timeline-header-units",children:ce.map((W,be)=>{const Te=be%le===0||W.isMain,Me=k==="hour"&&W.date.getHours()===0,$=Me?"d MMM":z.unitLabel;return e.jsx("div",{className:`nice-timeline-unit ${W.isMain?"main":""} ${W.isWeekend?"nice-timeline-unit--weekend":""} ${Me?"nice-timeline-unit--midnight":""} ${Te?"":"nice-timeline-unit--no-label"}`,style:{left:W.x},children:Te&&e.jsx("span",{children:Ci(W.date,$,E)})},be)})})]}),e.jsxs("div",{ref:G,className:"nice-timeline-chart",style:{height:ie},role:"group","aria-label":i("timeline.events","Events"),children:[e.jsxs("svg",{className:"nice-timeline-grid",width:p,height:ie,children:[ce.map((W,be)=>{if(!W.isWeekend)return null;const Te=ce[be+1],Me=(Te?Te.x:W.x+z.unitMs/z.msPerPixel)-W.x;return e.jsx("rect",{x:W.x,y:0,width:Me,height:ie,className:"nice-timeline-weekend-band"},`wk-${be}`)}),ce.map((W,be)=>e.jsx("line",{x1:W.x,y1:0,x2:W.x,y2:ie,className:W.isMain?"main":"minor"},be)),h&&xe>=0&&xe<=p&&e.jsx("line",{x1:xe,y1:0,x2:xe,y2:ie,className:"today"}),me.map((W,be)=>e.jsx("line",{x1:0,y1:(be+1)*te,x2:p,y2:(be+1)*te,className:"row-sep"},be))]}),o.map((W,be)=>{const Te=se(W.date);return Te<0||Te>p?null:e.jsx("div",{className:`nice-timeline-marker ${W.type||"line"}`,style:{left:Te,borderColor:W.color},children:e.jsx("span",{className:"nice-timeline-marker-label",children:W.label})},be)}),me.map((W,be)=>e.jsx("div",{className:"nice-timeline-row",style:{top:be*te,height:te},children:W.events.map((Te,Me)=>{const $=se(Te.start),X=Te.end?se(Te.end):$+10,ae=Math.max(X-$,20),ve=Te.color||w[Me%w.length];return $>p||X<0?null:Te.type==="milestone"?e.jsx("div",{className:`nice-timeline-milestone ${M?.id===Te.id?"hovered":""}`,style:{left:$,borderColor:ve},onClick:()=>b?.(Te),onKeyDown:Se(Te),onMouseEnter:()=>Q(Te),onMouseLeave:ne,onFocus:()=>Q(Te),onBlur:ne,role:"button","aria-label":Te.title,title:Te.title,children:Te.icon||e.jsx(l.NiceIcon,{name:"diamond",size:12})},Te.id):e.jsx("div",{className:`nice-timeline-event ${Te.type||"event"} ${M?.id===Te.id?"hovered":""}`,style:{left:Math.max($,0),width:ae,backgroundColor:ve},onClick:()=>b?.(Te),onKeyDown:Se(Te),onMouseEnter:()=>Q(Te),onMouseLeave:ne,onFocus:()=>Q(Te),onBlur:ne,role:"button","aria-label":Te.title,title:Te.description||Te.title,children:C?C(Te):e.jsx("span",{className:"nice-timeline-event-title",children:Te.title})},Te.id)})},W.id)),h&&xe>=0&&xe<=p&&e.jsx("div",{className:"nice-timeline-today-marker",style:{left:xe},children:e.jsx("span",{children:i("scheduling.today","Today")})})]}),M&&e.jsxs("div",{className:"nice-timeline-tooltip",style:{left:se(M.start)+10},children:[e.jsx("strong",{children:M.title}),M.description&&e.jsx("p",{children:M.description}),e.jsxs("small",{children:[Ci(M.start,"MMM d, yyyy HH:mm",E),M.end&&` — ${Ci(M.end,"MMM d, yyyy HH:mm",E)}`]})]})]}),f&&e.jsx("div",{className:"nice-timeline-minimap"}),e.jsx("style",{children:`
|
|
4
4
|
.nice-timeline {
|
|
@@ -889,6 +889,11 @@
|
|
|
889
889
|
|
|
890
890
|
display: flex;
|
|
891
891
|
flex-direction: column;
|
|
892
|
+
/* 1.4.22 ("Kontrolka zmienia szerokość jak przechodzę po tabsach"): it fills its container instead of
|
|
893
|
+
shrinking to whatever the current tab holds. */
|
|
894
|
+
width: 100%;
|
|
895
|
+
min-width: 0;
|
|
896
|
+
box-sizing: border-box;
|
|
892
897
|
background: var(--nice-git-bg);
|
|
893
898
|
border: 1px solid var(--nice-git-border);
|
|
894
899
|
border-radius: var(--nice-git-radius);
|
|
@@ -1284,7 +1289,7 @@ ${ae}
|
|
|
1284
1289
|
color: var(--nice-primary, #2563eb); border-radius: var(--nice-radius-sm, 4px); padding: 4px 12px;
|
|
1285
1290
|
font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; margin-top: 2px;
|
|
1286
1291
|
}
|
|
1287
|
-
`;class eu{constructor(){this.components=new Map,this.actionHandlers=new Map}register(n){return this.components.set(n.type,n),this}registerAll(n){for(const i of n)this.register(i);return this}unregister(n){return this.components.delete(n)}get(n){return this.components.get(n)}has(n){return this.components.has(n)}getAll(){return Array.from(this.components.values())}getByCategory(n){return this.getAll().filter(i=>i.category===n)}getCategories(){return[...new Set(this.getAll().map(n=>n.category))]}registerAction(n,i){return this.actionHandlers.set(n,i),this}getAction(n){return this.actionHandlers.get(n)}hasAction(n){return this.actionHandlers.has(n)}getActionNames(){return Array.from(this.actionHandlers.keys())}validateTypes(n){const i=[];for(const a of n)this.has(a)||i.push(a);return i}clear(){this.components.clear(),this.actionHandlers.clear()}}const co=kf();function kf(){const t=new eu;return Cf(t),Sf(t),t}function Cf(t){t.registerAll([{type:"text",label:"Text",category:"content",component:(n=>r.createElement("p",{className:"nice-view-v2__text"},String(n.content??n.text??"")))},{type:"heading",label:"Heading",category:"content",component:(n=>{const a=`h${Math.min(6,Math.max(1,Number(n.level??2)))}`;return r.createElement(a,{className:"nice-view-v2__heading"},String(n.text??""))})},{type:"container",label:"Container",category:"layout",component:(n=>r.createElement("div",{className:"nice-view-v2__container",style:{flexDirection:n.direction??"column",gap:typeof n.gap=="number"?n.gap:8}},n.children))},{type:"button",label:"Button",category:"actions",component:(n=>r.createElement("button",{type:"button",className:"nice-btn nice-btn--primary"},String(n.label??n.text??"Button")))}])}function Yt(t,n,i,a){const s=r.lazy(()=>n().then(c=>({default:i(c)}))),o=c=>r.createElement(r.Suspense,{fallback:null},r.createElement(s,c));t.register({...a,component:o})}function Sf(t){Yt(t,()=>Promise.resolve().then(()=>require("./no-code-DPc82kyy.cjs")).then(n=>n.NiceTextInput$1),n=>n.NiceTextInput,{type:"textInput",label:"Text Input",category:"input"}),Yt(t,()=>Promise.resolve().then(()=>require("./NiceForm-DM2tARZT.cjs")).then(n=>n.NiceTextArea$1),n=>n.NiceTextArea,{type:"textArea",label:"Text Area",category:"input"}),Yt(t,()=>Promise.resolve().then(()=>require("./no-code-DPc82kyy.cjs")).then(n=>n.NiceNumberInput$1),n=>n.NiceNumberInput,{type:"numberInput",label:"Number Input",category:"input"}),Yt(t,()=>Promise.resolve().then(()=>require("./no-code-DPc82kyy.cjs")).then(n=>n.NiceCheckbox$1),n=>n.NiceCheckbox,{type:"checkbox",label:"Checkbox",category:"input"}),Yt(t,()=>Promise.resolve().then(()=>require("./no-code-DPc82kyy.cjs")).then(n=>n.NiceSelect$1),n=>n.NiceSelect,{type:"select",label:"Select",category:"input"}),Yt(t,()=>Promise.resolve().then(()=>require("./NiceForm-DM2tARZT.cjs")).then(n=>n.NiceSlider$1),n=>n.NiceSlider,{type:"slider",label:"Slider",category:"input"}),Yt(t,()=>Promise.resolve().then(()=>require("./NiceForm-DM2tARZT.cjs")).then(n=>n.NiceRating$1),n=>n.NiceRating,{type:"rating",label:"Rating",category:"input"}),Yt(t,()=>Promise.resolve().then(()=>require("./NiceForm-DM2tARZT.cjs")).then(n=>n.NiceRadioGroup$1),n=>n.NiceRadioGroup,{type:"radioGroup",label:"Radio Group",category:"input"}),Yt(t,()=>Promise.resolve().then(()=>require("./NiceForm-DM2tARZT.cjs")).then(n=>n.NiceDateTimePicker$1),n=>n.NiceDateTimePicker,{type:"datePicker",label:"Date Picker",category:"input"}),Yt(t,()=>Promise.resolve().then(()=>require("./NiceForm-DM2tARZT.cjs")).then(n=>n.NiceDateTimePicker$1),n=>n.NiceDateTimePicker,{type:"timePicker",label:"Time Picker",category:"input"}),Yt(t,()=>Promise.resolve().then(()=>require("./NiceColorPicker-79rkvaSk.cjs")),n=>n.NiceColorPicker,{type:"colorPicker",label:"Color Picker",category:"input"}),Yt(t,()=>Promise.resolve().then(()=>require("./NiceModuleLifecyclePanel-jckyVqqt.cjs")).then(n=>n.NiceCard$1),n=>n.NiceCard,{type:"card",label:"Card",category:"layout"}),Yt(t,()=>Promise.resolve().then(()=>require("./NiceDataGrid-Cszjz8NV.cjs")).then(n=>n.NiceDataGrid$1),n=>(i=>r.createElement(n.NiceDataGrid,{...i,data:Array.isArray(i.data)?i.data:[]})),{type:"dataGrid",label:"Data Grid",category:"data"}),Yt(t,()=>Promise.resolve().then(()=>require("./charts-C3Q3r8Yz.cjs")).then(n=>n.NiceChart$1),n=>(i=>r.createElement(n.NiceChart,{...i,series:Array.isArray(i.series)?i.series:[]})),{type:"chart",label:"Chart",category:"data"}),Yt(t,()=>Promise.resolve().then(()=>nE),n=>(i=>r.createElement(n.NiceStatistic,{...i,title:String(i.title??i.label??"KPI"),value:typeof i.value=="number"||typeof i.value=="string"?i.value:"—"})),{type:"kpi",label:"KPI",category:"data"}),Yt(t,()=>Promise.resolve().then(()=>Lh),n=>(i=>r.createElement(n.NiceBadge,{...i,children:i.children??String(i.text??i.label??"Badge")})),{type:"badge",label:"Badge",category:"display"})}function fs(t,n){let i=t;for(const a of n.split(".")){if(i==null||typeof i!="object")return;i=i[a]}return i}const Tf={toUpperCase:t=>typeof t=="string"?t.toUpperCase():t,toLowerCase:t=>typeof t=="string"?t.toLowerCase():t,trim:t=>typeof t=="string"?t.trim():t,toFixed2:t=>typeof t=="number"?t.toFixed(2):t,toFixed0:t=>typeof t=="number"?t.toFixed(0):t,toString:t=>String(t??""),toNumber:t=>Number(t)||0,boolean:t=>!!t,not:t=>!t,length:t=>Array.isArray(t)||typeof t=="string"?t.length:0,json:t=>{try{return JSON.stringify(t)}catch{return""}},date:t=>{try{return new Date(t).toLocaleDateString()}catch{return String(t)}},datetime:t=>{try{return new Date(t).toLocaleString()}catch{return String(t)}},currency:t=>typeof t=="number"?t.toLocaleString(void 0,{style:"currency",currency:"USD"}):t,percent:t=>typeof t=="number"?`${(t*100).toFixed(1)}%`:t};function Ef(t,n,i){const a=t.split("|").map(o=>o.trim());let s=n;for(const o of a){if(o.startsWith("field:")){s=fs(i,o.slice(6));continue}const c=Tf[o];c&&(s=c(s,i))}return s}function If(t,n,i){if(!n)return;const a=n.getRecord(t.source,i);if(!a)return;const s=fs(a,t.field);if(t.transform)try{return Ef(t.transform,s,a)}catch{return s}return s}function tu(t,n,i){const a=t.trim();if(a.startsWith("!"))return!tu(a.slice(1),n,i);const s=a.match(/^([a-zA-Z_]\w*(?:\.[a-zA-Z_]\w*)*)\s*(===?|!==?|>=?|<=?)\s*(.+)$/);if(s){const[,d,p,m]=s,[h,...u]=d.split("."),x=n.getRecord(h,i),f=x?fs(x,u.join(".")):void 0;let b=m.trim();switch(b==="true"?b=!0:b==="false"?b=!1:b==="null"||b==="undefined"?b=void 0:/^-?\d+(\.\d+)?$/.test(b)?b=Number(b):(b.startsWith("'")&&b.endsWith("'")||b.startsWith('"')&&b.endsWith('"'))&&(b=b.slice(1,-1)),p){case"==":case"===":return f===b;case"!=":case"!==":return f!==b;case">":return Number(f)>Number(b);case">=":return Number(f)>=Number(b);case"<":return Number(f)<Number(b);case"<=":return Number(f)<=Number(b);default:return!0}}const[o,...c]=a.split(".");if(o){const d=n.getRecord(o,i);return d?!!(c.length?fs(d,c.join(".")):d):!1}return!0}function Pc(t,n,i){if(!t||!n)return!0;try{return tu(t,n,i)}catch{return!0}}function Ac(t,n){if(!t||t.length===0)return"editable";if(!n||n.length===0)return"hidden";let i="hidden";const a={hidden:0,readonly:1,editable:2};for(const s of t)(n.includes(s.role)||s.role==="*")&&a[s.access]>a[i]&&(i=s.access);return i}function Df(t,n){return t+1}const nu=Object.assign(r.forwardRef(({view:t,registry:n=co,dataStore:i,userRoles:a,onNavigate:s,onNotify:o,onOpenDialog:c,onCloseDialog:d,fallback:p,recordIndex:m,onRunScript:h,className:u,style:x,id:f,...b},g)=>{const{t:v}=l.useNiceTranslation(),{confirm:y,element:C}=_t.useNiceDialogs(),[,w]=r.useReducer(Df,0),E=r.useRef(w);E.current=w;const S=r.useMemo(()=>({dataSources:new Proxy({},{get:(I,D)=>i?.get(D)}),navigate:I=>s?.(I),notify:(I,D)=>o?.(I,D),refreshDataSource:I=>{i?.refresh(I),E.current({type:"tick"})},openDialog:I=>c?.(I),closeDialog:()=>d?.()}),[i,s,o,c,d]),N=r.useCallback(async I=>{for(const D of I)if(!(D.confirm&&!await y({message:D.confirm})))try{switch(D.type){case"navigate":D.target&&S.navigate(D.target);break;case"apiCall":if(D.endpoint){const M=D.endpoint.trim().toLowerCase();if(!M.startsWith("http://")&&!M.startsWith("https://")&&!M.startsWith("/")){console.warn("[NiceViewRenderer] Blocked unsafe endpoint:",D.endpoint);break}await fetch(D.endpoint,{method:D.method??"POST",headers:{"Content-Type":"application/json"},body:D.body?JSON.stringify(D.body):void 0})}D.successMessage&&S.notify(D.successMessage,"success");break;case"setField":if(D.field&&i){const[M,...O]=D.field.split(".");i.setField(M,O.join("."),D.value,m)}break;case"refresh":D.dataSourceKey&&S.refreshDataSource(D.dataSourceKey);break;case"openDialog":D.dialogViewId&&S.openDialog(D.dialogViewId);break;case"closeDialog":S.closeDialog();break;case"submit":break;case"custom":{const M=D.handler?n.getAction(D.handler):void 0;M&&await M(D.params??{},S);break}case"script":D.script&&(h?await h(D.script,{language:D.language??"js",action:D,context:S}):typeof console<"u"&&console.warn("[NiceViewRenderer] script action skipped: no onRunScript handler provided.",D));break}}catch(M){const O=D.errorMessage??`Action failed: ${M.message}`;S.notify(O,"error")}},[S,i,m,n,h,y]),_=r.useCallback(I=>{if(!Pc(I.visibleWhen,i,m))return null;const D=Ac(I.permissions,a);if(D==="hidden")return null;const M={...I.props};if(I.bindings){for(const[V,ee]of Object.entries(I.bindings))if(M[V]=If(ee,i,m),ee.twoWay){const z=`on${V.charAt(0).toUpperCase()}${V.slice(1)}Change`;M[z]=U=>{i?.setField(ee.source,ee.field,U,m),E.current({type:"tick"})}}}if(D==="readonly"&&(M.disabled=!0,M.readOnly=!0),I.events)for(const V of I.events)M[V.event]=(...ee)=>{N(V.actions)};const O=n.get(I.controlType);if(!O)return p?e.jsx(p,{controlType:I.controlType}):e.jsx("div",{className:"nice-view-v2__unknown",children:v("view.unknownControl","Unknown control: {type}").replace("{type}",I.controlType)});const L=O.component;return e.jsx(L,{...O.defaultProps??{},...M})},[n,i,a,m,N,p,v]),k=r.useCallback((I,D)=>I.map(M=>Pc(M.visibleWhen,i,m)?e.jsx("div",{className:`nice-view-v2__row ${M.cssClass??""}`,style:{gridTemplateColumns:`repeat(${D}, 1fr)`,...M.height?{minHeight:M.height}:{}},children:M.cells.map(O=>e.jsx("div",{className:`nice-view-v2__cell ${O.cssClass??""}`,style:{gridColumn:O.colSpan?`span ${O.colSpan}`:void 0,gridRow:O.rowSpan?`span ${O.rowSpan}`:void 0},children:_(O)},O.id))},M.id):null),[_,i,m]),j=r.useCallback((I,D)=>{switch(I.type){case"tabs":return e.jsx("div",{className:"nice-view-v2__tabs",children:I.sections.map(M=>e.jsxs("div",{className:"nice-view-v2__tab-panel",children:[M.label&&e.jsx("div",{className:"nice-view-v2__tab-label",children:M.label}),M.rows&&k(M.rows,D),M.container&&j(M.container,D)]},M.id))});case"accordion":return e.jsx("div",{className:"nice-view-v2__accordion",children:I.sections.map(M=>e.jsxs("details",{className:"nice-view-v2__accordion-panel",children:[e.jsx("summary",{children:M.label??M.id}),M.rows&&k(M.rows,D),M.container&&j(M.container,D)]},M.id))});case"splitter":{const M=I.props?.sizes??I.sections.map(()=>"1fr");return e.jsx("div",{className:"nice-view-v2__splitter",style:{gridTemplateColumns:M.join(" ")},children:I.sections.map(O=>e.jsxs("div",{className:"nice-view-v2__splitter-panel",children:[O.rows&&k(O.rows,D),O.container&&j(O.container,D)]},O.id))})}case"stack":return e.jsx("div",{className:"nice-view-v2__stack",children:I.sections.map(M=>e.jsxs("div",{children:[M.label&&e.jsx("h3",{className:"nice-view-v2__section-label",children:M.label}),M.rows&&k(M.rows,D),M.container&&j(M.container,D)]},M.id))});default:return e.jsx(e.Fragment,{children:I.sections.map(M=>e.jsxs("div",{children:[M.label&&e.jsx("h3",{className:"nice-view-v2__section-label",children:M.label}),M.rows&&k(M.rows,D),M.container&&j(M.container,D)]},M.id))})}},[k]),T=r.useCallback(I=>!I||I.length===0?null:I.map((D,M)=>e.jsx("div",{className:`nice-view-v2__toolbar nice-view-v2__toolbar--${D.position}`,children:D.items.map(O=>O.type==="separator"?e.jsx("span",{className:"nice-view-v2__toolbar-sep"},O.id):O.type==="spacer"?e.jsx("span",{className:"nice-view-v2__toolbar-spacer"},O.id):e.jsxs("button",{type:"button",className:"nice-view-v2__toolbar-btn",disabled:typeof O.disabled=="boolean"?O.disabled:!1,onClick:()=>O.actions&&void N(O.actions),children:[O.icon&&e.jsx("span",{className:"nice-view-v2__toolbar-icon",children:e.jsx(l.NiceIcon,{name:O.icon,size:14})}),O.label]},O.id))},M)),[N]);if(Ac(t.permissions?.map(I=>({...I})),a)==="hidden")return null;const B=t.toolbars?.filter(I=>I.position==="top"),R=t.toolbars?.filter(I=>I.position==="bottom");return e.jsxs("div",{ref:g,id:f,className:`nice-view-v2 ${u??""}`,style:x,"data-view-id":t.id,"data-view-module":t.module,...b,children:[C,T(B),t.container?j(t.container,t.columns??12):t.rows&&k(t.rows,t.columns??12),T(R)]})}),{displayName:"NiceViewRenderer"});function Pf(t){const n=[];for(const i of t??[])for(const a of i.cells??[])n.push(a);return n}function lo(t,n){if(Array.isArray(n))return n;if(n&&typeof n=="object"){const i=n,a=t.dataSources?.[0]?.key;if(a&&Array.isArray(i[a]))return i[a];const s=Object.values(i).find(o=>Array.isArray(o));if(Array.isArray(s))return s}return[]}function uo(t,n){const i=[],a=new Set;for(const s of Pf(t.rows)){const o=s,c=o.binding?.field??o.props?.field;c&&!a.has(c)&&(a.add(c),i.push({field:c,header:o.label??o.props?.label??c}))}if(i.length===0&&n.length>0)for(const s of Object.keys(n[0]))i.push({field:s,header:s});return i}function Us(t){return String(t??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function _r(t,n,i={}){const a=lo(t,n),s=i.columns??uo(t,a),o=Us(t.name||"Report"),c=s.length>0?`<table><thead><tr>${s.map(d=>`<th>${Us(d.header)}</th>`).join("")}</tr></thead><tbody>${a.map(d=>`<tr>${s.map(p=>`<td>${Us(d[p.field])}</td>`).join("")}</tr>`).join("")}</tbody></table>`:"<p>No data.</p>";return`<!doctype html><html><head><meta charset="utf-8"><title>${o}</title><style>body{font-family:Inter,system-ui,Arial,sans-serif;color:#111;margin:24px;}h1{font-size:18px;margin:0 0 16px;}table{border-collapse:collapse;width:100%;font-size:12px;}th,td{border:1px solid #ccc;padding:6px 8px;text-align:left;}thead th{background:#f3f4f6;}@media print{body{margin:0;}@page{margin:16mm;}}</style></head><body><h1>${o}</h1>${c}</body></html>`}function Rc(t,n,i){if(typeof document>"u")return;const a=new Blob([t],{type:n}),s=URL.createObjectURL(a),o=document.createElement("a");o.href=s,o.download=i,document.body.appendChild(o),o.click(),o.remove(),setTimeout(()=>URL.revokeObjectURL(s),0)}async function iu(t,n,i,a={}){const s=lo(t,n);if(a.onExport){await a.onExport(t,s,i);return}const o=a.columns??uo(t,s),c=a.fileName??t.name??"export";switch(i){case"csv":Qe.downloadCSV(s,o,{fileName:c});return;case"xlsx":Qe.downloadXLSX(s,o,{fileName:c,sheetName:t.name||"Sheet1"});return;case"html":Rc(_r(t,n,{columns:o}),"text/html;charset=utf-8",`${c}.html`);return;case"docx":Rc(_r(t,n,{columns:o}),"application/msword",`${c}.doc`);return;case"pdf":default:Qe.exportToPDF(s,o,{title:t.name});return}}const Af=[{target:".nice-view-editor",titleKey:"tutorial.viewEditor.intro.title",title:"View editor",contentKey:"tutorial.viewEditor.intro.content",content:"Author any view kind from one place: choose the kind (or scaffold from an entity), drag controls from the palette into the grid cells, then configure each cell — data binding, role permissions and event actions. Switch Design / Preview / Source, and Save when valid.",placement:"auto"},{target:".nice-view-editor__palette",titleKey:"tutorial.viewEditor.palette.title",title:"Palette",contentKey:"tutorial.viewEditor.palette.content",content:"Add controls from the palette into the grid — inputs, data grids, charts, KPIs, buttons and display blocks.",placement:"right"},{target:".nice-view-editor__canvas",titleKey:"tutorial.viewEditor.canvas.title",title:"Canvas",contentKey:"tutorial.viewEditor.canvas.content",content:"Arrange cells into rows and set each cell’s column span. Click a cell to configure it.",placement:"auto"},{target:".nice-view-editor__props",titleKey:"tutorial.viewEditor.props.title",title:"Properties",contentKey:"tutorial.viewEditor.props.content",content:"Configure the selected control: props, data binding, role permissions and event actions. With nothing selected, manage the view’s data sources.",placement:"left"},{target:".nice-view-editor__modes",titleKey:"tutorial.viewEditor.modes.title",title:"Design / Preview / Source",contentKey:"tutorial.viewEditor.modes.content",content:"Switch between the visual designer, a live preview, and the raw NiceViewDefinition JSON. Save when the view is valid.",placement:"bottom"}],Rf=[{category:"Inputs",items:[{type:"textInput",label:"Text"},{type:"textArea",label:"Text area"},{type:"numberInput",label:"Number"},{type:"select",label:"Select"},{type:"checkbox",label:"Checkbox"},{type:"datePicker",label:"Date"}]},{category:"Data",items:[{type:"dataGrid",label:"Data grid"}]},{category:"BI",items:[{type:"chart",label:"Chart"},{type:"kpi",label:"KPI"}]},{category:"Actions",items:[{type:"button",label:"Button"}]},{category:"Display",items:[{type:"text",label:"Text"},{type:"heading",label:"Heading"},{type:"badge",label:"Badge"},{type:"card",label:"Card"}]}],$f=["rest","odata","graphql","static","query","entity"],Mf=["hidden","readonly","editable"],Of=[{value:"form",label:"Form"},{value:"detail",label:"Detail"},{value:"grid",label:"Grid"},{value:"dashboard",label:"Dashboard"},{value:"content",label:"Content"},{value:"report",label:"Report"},{value:"print",label:"Print"},{value:"mix",label:"Mix"}],Lf=new Set(["report","print","grid"]),zf=["pdf","docx","xlsx","csv","html"];let Bf=0;const os=t=>`${t}-${Date.now().toString(36)}-${(Bf++).toString(36)}`;function Ff(){return{id:os("view"),name:"New View",version:2,columns:12,rows:[],dataSources:[]}}function qf(t){const n={};for(const i of t.dataSources??[]){const a=i.data;n[i.key]=Array.isArray(a)&&a.length>0?a:[{}]}return{get:i=>n[i],getRecord:(i,a=0)=>n[i]?.[a]??{},setField:(i,a,s,o=0)=>{const c=n[i]??(n[i]=[{}]),d=c[o]??(c[o]={});d[a]=s},refresh:()=>{}}}const Vf=r.forwardRef(function(n,i){const a=r.useRef(null);l.useRovingFocus(a,{orientation:"horizontal",wrap:!0,activateOnMove:!0}),En.injectStyleOnce(Gf,Wf);const{value:s,onChange:o,registry:c=co,entities:d,dataSourceOptions:p,onSave:m,onExport:h,height:u=560,tutorial:x,className:f,style:b,id:g,"data-testid":v}=n,{t:y}=l.useNiceTranslation(),[C,w]=r.useState(()=>s??Ff()),E=s??C,[S,N]=r.useState(null),[_,k]=r.useState("design"),j=r.useCallback(F=>{o?o(F):w(F)},[o]),T=r.useMemo(()=>E.rows??[],[E.rows]),P=(E.dataSources??[]).map(F=>F.key),B=r.useMemo(()=>c.getActionNames(),[c]),I=r.useCallback(F=>{if(!F)return null;for(const H of T){const A=H.cells.find(Z=>Z.id===F);if(A)return{row:H,cell:A}}return null},[T])(S),D=F=>j({...E,rows:F}),M=(F,H)=>D(T.map(A=>({...A,cells:A.cells.map(Z=>Z.id===F?{...Z,...H}:Z)}))),O=()=>D([...T,{id:os("row"),cells:[]}]),L=F=>{const H={id:os("cell"),controlType:F,props:{label:F},colSpan:6},A=T.length>0?T.slice():[{id:os("row"),cells:[]}];A[A.length-1]={...A[A.length-1],cells:[...A[A.length-1].cells,H]},D(A),N(H.id)},V=F=>{D(T.map(H=>({...H,cells:H.cells.filter(A=>A.id!==F)}))),S===F&&N(null)},ee=(F,H)=>{const A=d?.find(Z=>Z.name===F);A&&(j(Xd(A,H)),N(null))},z=r.useMemo(()=>(d??[]).map(F=>F.name).filter(F=>!!F),[d]),U=r.useMemo(()=>oo(E),[E]),re=r.useMemo(()=>qf(E),[E]),Y=r.useMemo(()=>{const F={};for(const H of E.dataSources??[]){const A=H.data;F[H.key]=Array.isArray(A)?A:[]}return F},[E]),oe=E.kind??E.meta?.kind??"form",q=F=>{iu(E,Y,F,{onExport:h})},se=e.jsxs("div",{className:"nice-view-editor__toolbar",children:[e.jsx("input",{className:"nice-view-editor__name",value:E.name,onChange:F=>j({...E,name:F.target.value}),placeholder:y("viewEditor.name","View name"),"aria-label":y("viewEditor.name","View name")}),e.jsx("select",{className:"nice-view-editor__kind",value:oe,onChange:F=>j({...E,kind:F.target.value}),"aria-label":y("viewEditor.kindAria","View kind"),children:Of.map(F=>e.jsx("option",{value:F.value,children:y("viewEditor.kind."+F.value,F.label)},F.value))}),d&&d.length>0&&e.jsxs("select",{className:"nice-view-editor__from-entity",value:"",onChange:F=>{const[H,A]=F.target.value.split("::");H&&ee(H,A)},"aria-label":y("viewEditor.fromEntityAria","New view from entity"),children:[e.jsx("option",{value:"",children:y("viewEditor.fromEntity","New from entity…")}),d.map(F=>["form","detail","grid"].map(H=>e.jsxs("option",{value:`${F.name}::${H}`,children:[F.name," · ",H]},`${F.name}-${H}`)))]}),Lf.has(oe)&&e.jsxs("select",{className:"nice-view-editor__export",value:"",onChange:F=>{const H=F.target.value;H&&q(H)},"aria-label":y("viewEditor.exportAria","Export view"),children:[e.jsx("option",{value:"",children:y("viewEditor.export","Export…")}),zf.map(F=>e.jsx("option",{value:F,children:F.toUpperCase()},F))]}),e.jsx("span",{className:"nice-view-editor__spacer"}),e.jsx("div",{className:"nice-view-editor__modes",ref:a,role:"tablist",children:["design","preview","source"].map(F=>e.jsx("button",{type:"button",role:"tab","aria-selected":_===F,className:"nice-view-editor__mode"+(_===F?" nice-view-editor__mode--active":""),onClick:()=>k(F),children:y("viewEditor.mode."+F,F[0].toUpperCase()+F.slice(1))},F))}),e.jsxs("span",{className:"nice-view-editor__status"+(U.length?" nice-view-editor__status--err":""),title:U.join(`
|
|
1292
|
+
`;class eu{constructor(){this.components=new Map,this.actionHandlers=new Map}register(n){return this.components.set(n.type,n),this}registerAll(n){for(const i of n)this.register(i);return this}unregister(n){return this.components.delete(n)}get(n){return this.components.get(n)}has(n){return this.components.has(n)}getAll(){return Array.from(this.components.values())}getByCategory(n){return this.getAll().filter(i=>i.category===n)}getCategories(){return[...new Set(this.getAll().map(n=>n.category))]}registerAction(n,i){return this.actionHandlers.set(n,i),this}getAction(n){return this.actionHandlers.get(n)}hasAction(n){return this.actionHandlers.has(n)}getActionNames(){return Array.from(this.actionHandlers.keys())}validateTypes(n){const i=[];for(const a of n)this.has(a)||i.push(a);return i}clear(){this.components.clear(),this.actionHandlers.clear()}}const co=kf();function kf(){const t=new eu;return Cf(t),Sf(t),t}function Cf(t){t.registerAll([{type:"text",label:"Text",category:"content",component:(n=>r.createElement("p",{className:"nice-view-v2__text"},String(n.content??n.text??"")))},{type:"heading",label:"Heading",category:"content",component:(n=>{const a=`h${Math.min(6,Math.max(1,Number(n.level??2)))}`;return r.createElement(a,{className:"nice-view-v2__heading"},String(n.text??""))})},{type:"container",label:"Container",category:"layout",component:(n=>r.createElement("div",{className:"nice-view-v2__container",style:{flexDirection:n.direction??"column",gap:typeof n.gap=="number"?n.gap:8}},n.children))},{type:"button",label:"Button",category:"actions",component:(n=>r.createElement("button",{type:"button",className:"nice-btn nice-btn--primary"},String(n.label??n.text??"Button")))}])}function Yt(t,n,i,a){const s=r.lazy(()=>n().then(c=>({default:i(c)}))),o=c=>r.createElement(r.Suspense,{fallback:null},r.createElement(s,c));t.register({...a,component:o})}function Sf(t){Yt(t,()=>Promise.resolve().then(()=>require("./no-code-DPc82kyy.cjs")).then(n=>n.NiceTextInput$1),n=>n.NiceTextInput,{type:"textInput",label:"Text Input",category:"input"}),Yt(t,()=>Promise.resolve().then(()=>require("./NiceForm-DM2tARZT.cjs")).then(n=>n.NiceTextArea$1),n=>n.NiceTextArea,{type:"textArea",label:"Text Area",category:"input"}),Yt(t,()=>Promise.resolve().then(()=>require("./no-code-DPc82kyy.cjs")).then(n=>n.NiceNumberInput$1),n=>n.NiceNumberInput,{type:"numberInput",label:"Number Input",category:"input"}),Yt(t,()=>Promise.resolve().then(()=>require("./no-code-DPc82kyy.cjs")).then(n=>n.NiceCheckbox$1),n=>n.NiceCheckbox,{type:"checkbox",label:"Checkbox",category:"input"}),Yt(t,()=>Promise.resolve().then(()=>require("./no-code-DPc82kyy.cjs")).then(n=>n.NiceSelect$1),n=>n.NiceSelect,{type:"select",label:"Select",category:"input"}),Yt(t,()=>Promise.resolve().then(()=>require("./NiceForm-DM2tARZT.cjs")).then(n=>n.NiceSlider$1),n=>n.NiceSlider,{type:"slider",label:"Slider",category:"input"}),Yt(t,()=>Promise.resolve().then(()=>require("./NiceForm-DM2tARZT.cjs")).then(n=>n.NiceRating$1),n=>n.NiceRating,{type:"rating",label:"Rating",category:"input"}),Yt(t,()=>Promise.resolve().then(()=>require("./NiceForm-DM2tARZT.cjs")).then(n=>n.NiceRadioGroup$1),n=>n.NiceRadioGroup,{type:"radioGroup",label:"Radio Group",category:"input"}),Yt(t,()=>Promise.resolve().then(()=>require("./NiceForm-DM2tARZT.cjs")).then(n=>n.NiceDateTimePicker$1),n=>n.NiceDateTimePicker,{type:"datePicker",label:"Date Picker",category:"input"}),Yt(t,()=>Promise.resolve().then(()=>require("./NiceForm-DM2tARZT.cjs")).then(n=>n.NiceDateTimePicker$1),n=>n.NiceDateTimePicker,{type:"timePicker",label:"Time Picker",category:"input"}),Yt(t,()=>Promise.resolve().then(()=>require("./NiceColorPicker-79rkvaSk.cjs")),n=>n.NiceColorPicker,{type:"colorPicker",label:"Color Picker",category:"input"}),Yt(t,()=>Promise.resolve().then(()=>require("./NiceModuleLifecyclePanel-jckyVqqt.cjs")).then(n=>n.NiceCard$1),n=>n.NiceCard,{type:"card",label:"Card",category:"layout"}),Yt(t,()=>Promise.resolve().then(()=>require("./NiceDataGrid-Cszjz8NV.cjs")).then(n=>n.NiceDataGrid$1),n=>(i=>r.createElement(n.NiceDataGrid,{...i,data:Array.isArray(i.data)?i.data:[]})),{type:"dataGrid",label:"Data Grid",category:"data"}),Yt(t,()=>Promise.resolve().then(()=>require("./charts-C9B548D2.cjs")).then(n=>n.NiceChart$1),n=>(i=>r.createElement(n.NiceChart,{...i,series:Array.isArray(i.series)?i.series:[]})),{type:"chart",label:"Chart",category:"data"}),Yt(t,()=>Promise.resolve().then(()=>nE),n=>(i=>r.createElement(n.NiceStatistic,{...i,title:String(i.title??i.label??"KPI"),value:typeof i.value=="number"||typeof i.value=="string"?i.value:"—"})),{type:"kpi",label:"KPI",category:"data"}),Yt(t,()=>Promise.resolve().then(()=>Lh),n=>(i=>r.createElement(n.NiceBadge,{...i,children:i.children??String(i.text??i.label??"Badge")})),{type:"badge",label:"Badge",category:"display"})}function fs(t,n){let i=t;for(const a of n.split(".")){if(i==null||typeof i!="object")return;i=i[a]}return i}const Tf={toUpperCase:t=>typeof t=="string"?t.toUpperCase():t,toLowerCase:t=>typeof t=="string"?t.toLowerCase():t,trim:t=>typeof t=="string"?t.trim():t,toFixed2:t=>typeof t=="number"?t.toFixed(2):t,toFixed0:t=>typeof t=="number"?t.toFixed(0):t,toString:t=>String(t??""),toNumber:t=>Number(t)||0,boolean:t=>!!t,not:t=>!t,length:t=>Array.isArray(t)||typeof t=="string"?t.length:0,json:t=>{try{return JSON.stringify(t)}catch{return""}},date:t=>{try{return new Date(t).toLocaleDateString()}catch{return String(t)}},datetime:t=>{try{return new Date(t).toLocaleString()}catch{return String(t)}},currency:t=>typeof t=="number"?t.toLocaleString(void 0,{style:"currency",currency:"USD"}):t,percent:t=>typeof t=="number"?`${(t*100).toFixed(1)}%`:t};function Ef(t,n,i){const a=t.split("|").map(o=>o.trim());let s=n;for(const o of a){if(o.startsWith("field:")){s=fs(i,o.slice(6));continue}const c=Tf[o];c&&(s=c(s,i))}return s}function If(t,n,i){if(!n)return;const a=n.getRecord(t.source,i);if(!a)return;const s=fs(a,t.field);if(t.transform)try{return Ef(t.transform,s,a)}catch{return s}return s}function tu(t,n,i){const a=t.trim();if(a.startsWith("!"))return!tu(a.slice(1),n,i);const s=a.match(/^([a-zA-Z_]\w*(?:\.[a-zA-Z_]\w*)*)\s*(===?|!==?|>=?|<=?)\s*(.+)$/);if(s){const[,d,p,m]=s,[h,...u]=d.split("."),x=n.getRecord(h,i),f=x?fs(x,u.join(".")):void 0;let b=m.trim();switch(b==="true"?b=!0:b==="false"?b=!1:b==="null"||b==="undefined"?b=void 0:/^-?\d+(\.\d+)?$/.test(b)?b=Number(b):(b.startsWith("'")&&b.endsWith("'")||b.startsWith('"')&&b.endsWith('"'))&&(b=b.slice(1,-1)),p){case"==":case"===":return f===b;case"!=":case"!==":return f!==b;case">":return Number(f)>Number(b);case">=":return Number(f)>=Number(b);case"<":return Number(f)<Number(b);case"<=":return Number(f)<=Number(b);default:return!0}}const[o,...c]=a.split(".");if(o){const d=n.getRecord(o,i);return d?!!(c.length?fs(d,c.join(".")):d):!1}return!0}function Pc(t,n,i){if(!t||!n)return!0;try{return tu(t,n,i)}catch{return!0}}function Ac(t,n){if(!t||t.length===0)return"editable";if(!n||n.length===0)return"hidden";let i="hidden";const a={hidden:0,readonly:1,editable:2};for(const s of t)(n.includes(s.role)||s.role==="*")&&a[s.access]>a[i]&&(i=s.access);return i}function Df(t,n){return t+1}const nu=Object.assign(r.forwardRef(({view:t,registry:n=co,dataStore:i,userRoles:a,onNavigate:s,onNotify:o,onOpenDialog:c,onCloseDialog:d,fallback:p,recordIndex:m,onRunScript:h,className:u,style:x,id:f,...b},g)=>{const{t:v}=l.useNiceTranslation(),{confirm:y,element:C}=_t.useNiceDialogs(),[,w]=r.useReducer(Df,0),E=r.useRef(w);E.current=w;const S=r.useMemo(()=>({dataSources:new Proxy({},{get:(I,D)=>i?.get(D)}),navigate:I=>s?.(I),notify:(I,D)=>o?.(I,D),refreshDataSource:I=>{i?.refresh(I),E.current({type:"tick"})},openDialog:I=>c?.(I),closeDialog:()=>d?.()}),[i,s,o,c,d]),N=r.useCallback(async I=>{for(const D of I)if(!(D.confirm&&!await y({message:D.confirm})))try{switch(D.type){case"navigate":D.target&&S.navigate(D.target);break;case"apiCall":if(D.endpoint){const M=D.endpoint.trim().toLowerCase();if(!M.startsWith("http://")&&!M.startsWith("https://")&&!M.startsWith("/")){console.warn("[NiceViewRenderer] Blocked unsafe endpoint:",D.endpoint);break}await fetch(D.endpoint,{method:D.method??"POST",headers:{"Content-Type":"application/json"},body:D.body?JSON.stringify(D.body):void 0})}D.successMessage&&S.notify(D.successMessage,"success");break;case"setField":if(D.field&&i){const[M,...O]=D.field.split(".");i.setField(M,O.join("."),D.value,m)}break;case"refresh":D.dataSourceKey&&S.refreshDataSource(D.dataSourceKey);break;case"openDialog":D.dialogViewId&&S.openDialog(D.dialogViewId);break;case"closeDialog":S.closeDialog();break;case"submit":break;case"custom":{const M=D.handler?n.getAction(D.handler):void 0;M&&await M(D.params??{},S);break}case"script":D.script&&(h?await h(D.script,{language:D.language??"js",action:D,context:S}):typeof console<"u"&&console.warn("[NiceViewRenderer] script action skipped: no onRunScript handler provided.",D));break}}catch(M){const O=D.errorMessage??`Action failed: ${M.message}`;S.notify(O,"error")}},[S,i,m,n,h,y]),_=r.useCallback(I=>{if(!Pc(I.visibleWhen,i,m))return null;const D=Ac(I.permissions,a);if(D==="hidden")return null;const M={...I.props};if(I.bindings){for(const[V,ee]of Object.entries(I.bindings))if(M[V]=If(ee,i,m),ee.twoWay){const z=`on${V.charAt(0).toUpperCase()}${V.slice(1)}Change`;M[z]=U=>{i?.setField(ee.source,ee.field,U,m),E.current({type:"tick"})}}}if(D==="readonly"&&(M.disabled=!0,M.readOnly=!0),I.events)for(const V of I.events)M[V.event]=(...ee)=>{N(V.actions)};const O=n.get(I.controlType);if(!O)return p?e.jsx(p,{controlType:I.controlType}):e.jsx("div",{className:"nice-view-v2__unknown",children:v("view.unknownControl","Unknown control: {type}").replace("{type}",I.controlType)});const L=O.component;return e.jsx(L,{...O.defaultProps??{},...M})},[n,i,a,m,N,p,v]),k=r.useCallback((I,D)=>I.map(M=>Pc(M.visibleWhen,i,m)?e.jsx("div",{className:`nice-view-v2__row ${M.cssClass??""}`,style:{gridTemplateColumns:`repeat(${D}, 1fr)`,...M.height?{minHeight:M.height}:{}},children:M.cells.map(O=>e.jsx("div",{className:`nice-view-v2__cell ${O.cssClass??""}`,style:{gridColumn:O.colSpan?`span ${O.colSpan}`:void 0,gridRow:O.rowSpan?`span ${O.rowSpan}`:void 0},children:_(O)},O.id))},M.id):null),[_,i,m]),j=r.useCallback((I,D)=>{switch(I.type){case"tabs":return e.jsx("div",{className:"nice-view-v2__tabs",children:I.sections.map(M=>e.jsxs("div",{className:"nice-view-v2__tab-panel",children:[M.label&&e.jsx("div",{className:"nice-view-v2__tab-label",children:M.label}),M.rows&&k(M.rows,D),M.container&&j(M.container,D)]},M.id))});case"accordion":return e.jsx("div",{className:"nice-view-v2__accordion",children:I.sections.map(M=>e.jsxs("details",{className:"nice-view-v2__accordion-panel",children:[e.jsx("summary",{children:M.label??M.id}),M.rows&&k(M.rows,D),M.container&&j(M.container,D)]},M.id))});case"splitter":{const M=I.props?.sizes??I.sections.map(()=>"1fr");return e.jsx("div",{className:"nice-view-v2__splitter",style:{gridTemplateColumns:M.join(" ")},children:I.sections.map(O=>e.jsxs("div",{className:"nice-view-v2__splitter-panel",children:[O.rows&&k(O.rows,D),O.container&&j(O.container,D)]},O.id))})}case"stack":return e.jsx("div",{className:"nice-view-v2__stack",children:I.sections.map(M=>e.jsxs("div",{children:[M.label&&e.jsx("h3",{className:"nice-view-v2__section-label",children:M.label}),M.rows&&k(M.rows,D),M.container&&j(M.container,D)]},M.id))});default:return e.jsx(e.Fragment,{children:I.sections.map(M=>e.jsxs("div",{children:[M.label&&e.jsx("h3",{className:"nice-view-v2__section-label",children:M.label}),M.rows&&k(M.rows,D),M.container&&j(M.container,D)]},M.id))})}},[k]),T=r.useCallback(I=>!I||I.length===0?null:I.map((D,M)=>e.jsx("div",{className:`nice-view-v2__toolbar nice-view-v2__toolbar--${D.position}`,children:D.items.map(O=>O.type==="separator"?e.jsx("span",{className:"nice-view-v2__toolbar-sep"},O.id):O.type==="spacer"?e.jsx("span",{className:"nice-view-v2__toolbar-spacer"},O.id):e.jsxs("button",{type:"button",className:"nice-view-v2__toolbar-btn",disabled:typeof O.disabled=="boolean"?O.disabled:!1,onClick:()=>O.actions&&void N(O.actions),children:[O.icon&&e.jsx("span",{className:"nice-view-v2__toolbar-icon",children:e.jsx(l.NiceIcon,{name:O.icon,size:14})}),O.label]},O.id))},M)),[N]);if(Ac(t.permissions?.map(I=>({...I})),a)==="hidden")return null;const B=t.toolbars?.filter(I=>I.position==="top"),R=t.toolbars?.filter(I=>I.position==="bottom");return e.jsxs("div",{ref:g,id:f,className:`nice-view-v2 ${u??""}`,style:x,"data-view-id":t.id,"data-view-module":t.module,...b,children:[C,T(B),t.container?j(t.container,t.columns??12):t.rows&&k(t.rows,t.columns??12),T(R)]})}),{displayName:"NiceViewRenderer"});function Pf(t){const n=[];for(const i of t??[])for(const a of i.cells??[])n.push(a);return n}function lo(t,n){if(Array.isArray(n))return n;if(n&&typeof n=="object"){const i=n,a=t.dataSources?.[0]?.key;if(a&&Array.isArray(i[a]))return i[a];const s=Object.values(i).find(o=>Array.isArray(o));if(Array.isArray(s))return s}return[]}function uo(t,n){const i=[],a=new Set;for(const s of Pf(t.rows)){const o=s,c=o.binding?.field??o.props?.field;c&&!a.has(c)&&(a.add(c),i.push({field:c,header:o.label??o.props?.label??c}))}if(i.length===0&&n.length>0)for(const s of Object.keys(n[0]))i.push({field:s,header:s});return i}function Us(t){return String(t??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function _r(t,n,i={}){const a=lo(t,n),s=i.columns??uo(t,a),o=Us(t.name||"Report"),c=s.length>0?`<table><thead><tr>${s.map(d=>`<th>${Us(d.header)}</th>`).join("")}</tr></thead><tbody>${a.map(d=>`<tr>${s.map(p=>`<td>${Us(d[p.field])}</td>`).join("")}</tr>`).join("")}</tbody></table>`:"<p>No data.</p>";return`<!doctype html><html><head><meta charset="utf-8"><title>${o}</title><style>body{font-family:Inter,system-ui,Arial,sans-serif;color:#111;margin:24px;}h1{font-size:18px;margin:0 0 16px;}table{border-collapse:collapse;width:100%;font-size:12px;}th,td{border:1px solid #ccc;padding:6px 8px;text-align:left;}thead th{background:#f3f4f6;}@media print{body{margin:0;}@page{margin:16mm;}}</style></head><body><h1>${o}</h1>${c}</body></html>`}function Rc(t,n,i){if(typeof document>"u")return;const a=new Blob([t],{type:n}),s=URL.createObjectURL(a),o=document.createElement("a");o.href=s,o.download=i,document.body.appendChild(o),o.click(),o.remove(),setTimeout(()=>URL.revokeObjectURL(s),0)}async function iu(t,n,i,a={}){const s=lo(t,n);if(a.onExport){await a.onExport(t,s,i);return}const o=a.columns??uo(t,s),c=a.fileName??t.name??"export";switch(i){case"csv":Qe.downloadCSV(s,o,{fileName:c});return;case"xlsx":Qe.downloadXLSX(s,o,{fileName:c,sheetName:t.name||"Sheet1"});return;case"html":Rc(_r(t,n,{columns:o}),"text/html;charset=utf-8",`${c}.html`);return;case"docx":Rc(_r(t,n,{columns:o}),"application/msword",`${c}.doc`);return;case"pdf":default:Qe.exportToPDF(s,o,{title:t.name});return}}const Af=[{target:".nice-view-editor",titleKey:"tutorial.viewEditor.intro.title",title:"View editor",contentKey:"tutorial.viewEditor.intro.content",content:"Author any view kind from one place: choose the kind (or scaffold from an entity), drag controls from the palette into the grid cells, then configure each cell — data binding, role permissions and event actions. Switch Design / Preview / Source, and Save when valid.",placement:"auto"},{target:".nice-view-editor__palette",titleKey:"tutorial.viewEditor.palette.title",title:"Palette",contentKey:"tutorial.viewEditor.palette.content",content:"Add controls from the palette into the grid — inputs, data grids, charts, KPIs, buttons and display blocks.",placement:"right"},{target:".nice-view-editor__canvas",titleKey:"tutorial.viewEditor.canvas.title",title:"Canvas",contentKey:"tutorial.viewEditor.canvas.content",content:"Arrange cells into rows and set each cell’s column span. Click a cell to configure it.",placement:"auto"},{target:".nice-view-editor__props",titleKey:"tutorial.viewEditor.props.title",title:"Properties",contentKey:"tutorial.viewEditor.props.content",content:"Configure the selected control: props, data binding, role permissions and event actions. With nothing selected, manage the view’s data sources.",placement:"left"},{target:".nice-view-editor__modes",titleKey:"tutorial.viewEditor.modes.title",title:"Design / Preview / Source",contentKey:"tutorial.viewEditor.modes.content",content:"Switch between the visual designer, a live preview, and the raw NiceViewDefinition JSON. Save when the view is valid.",placement:"bottom"}],Rf=[{category:"Inputs",items:[{type:"textInput",label:"Text"},{type:"textArea",label:"Text area"},{type:"numberInput",label:"Number"},{type:"select",label:"Select"},{type:"checkbox",label:"Checkbox"},{type:"datePicker",label:"Date"}]},{category:"Data",items:[{type:"dataGrid",label:"Data grid"}]},{category:"BI",items:[{type:"chart",label:"Chart"},{type:"kpi",label:"KPI"}]},{category:"Actions",items:[{type:"button",label:"Button"}]},{category:"Display",items:[{type:"text",label:"Text"},{type:"heading",label:"Heading"},{type:"badge",label:"Badge"},{type:"card",label:"Card"}]}],$f=["rest","odata","graphql","static","query","entity"],Mf=["hidden","readonly","editable"],Of=[{value:"form",label:"Form"},{value:"detail",label:"Detail"},{value:"grid",label:"Grid"},{value:"dashboard",label:"Dashboard"},{value:"content",label:"Content"},{value:"report",label:"Report"},{value:"print",label:"Print"},{value:"mix",label:"Mix"}],Lf=new Set(["report","print","grid"]),zf=["pdf","docx","xlsx","csv","html"];let Bf=0;const os=t=>`${t}-${Date.now().toString(36)}-${(Bf++).toString(36)}`;function Ff(){return{id:os("view"),name:"New View",version:2,columns:12,rows:[],dataSources:[]}}function qf(t){const n={};for(const i of t.dataSources??[]){const a=i.data;n[i.key]=Array.isArray(a)&&a.length>0?a:[{}]}return{get:i=>n[i],getRecord:(i,a=0)=>n[i]?.[a]??{},setField:(i,a,s,o=0)=>{const c=n[i]??(n[i]=[{}]),d=c[o]??(c[o]={});d[a]=s},refresh:()=>{}}}const Vf=r.forwardRef(function(n,i){const a=r.useRef(null);l.useRovingFocus(a,{orientation:"horizontal",wrap:!0,activateOnMove:!0}),En.injectStyleOnce(Gf,Wf);const{value:s,onChange:o,registry:c=co,entities:d,dataSourceOptions:p,onSave:m,onExport:h,height:u=560,tutorial:x,className:f,style:b,id:g,"data-testid":v}=n,{t:y}=l.useNiceTranslation(),[C,w]=r.useState(()=>s??Ff()),E=s??C,[S,N]=r.useState(null),[_,k]=r.useState("design"),j=r.useCallback(F=>{o?o(F):w(F)},[o]),T=r.useMemo(()=>E.rows??[],[E.rows]),P=(E.dataSources??[]).map(F=>F.key),B=r.useMemo(()=>c.getActionNames(),[c]),I=r.useCallback(F=>{if(!F)return null;for(const H of T){const A=H.cells.find(Z=>Z.id===F);if(A)return{row:H,cell:A}}return null},[T])(S),D=F=>j({...E,rows:F}),M=(F,H)=>D(T.map(A=>({...A,cells:A.cells.map(Z=>Z.id===F?{...Z,...H}:Z)}))),O=()=>D([...T,{id:os("row"),cells:[]}]),L=F=>{const H={id:os("cell"),controlType:F,props:{label:F},colSpan:6},A=T.length>0?T.slice():[{id:os("row"),cells:[]}];A[A.length-1]={...A[A.length-1],cells:[...A[A.length-1].cells,H]},D(A),N(H.id)},V=F=>{D(T.map(H=>({...H,cells:H.cells.filter(A=>A.id!==F)}))),S===F&&N(null)},ee=(F,H)=>{const A=d?.find(Z=>Z.name===F);A&&(j(Xd(A,H)),N(null))},z=r.useMemo(()=>(d??[]).map(F=>F.name).filter(F=>!!F),[d]),U=r.useMemo(()=>oo(E),[E]),re=r.useMemo(()=>qf(E),[E]),Y=r.useMemo(()=>{const F={};for(const H of E.dataSources??[]){const A=H.data;F[H.key]=Array.isArray(A)?A:[]}return F},[E]),oe=E.kind??E.meta?.kind??"form",q=F=>{iu(E,Y,F,{onExport:h})},se=e.jsxs("div",{className:"nice-view-editor__toolbar",children:[e.jsx("input",{className:"nice-view-editor__name",value:E.name,onChange:F=>j({...E,name:F.target.value}),placeholder:y("viewEditor.name","View name"),"aria-label":y("viewEditor.name","View name")}),e.jsx("select",{className:"nice-view-editor__kind",value:oe,onChange:F=>j({...E,kind:F.target.value}),"aria-label":y("viewEditor.kindAria","View kind"),children:Of.map(F=>e.jsx("option",{value:F.value,children:y("viewEditor.kind."+F.value,F.label)},F.value))}),d&&d.length>0&&e.jsxs("select",{className:"nice-view-editor__from-entity",value:"",onChange:F=>{const[H,A]=F.target.value.split("::");H&&ee(H,A)},"aria-label":y("viewEditor.fromEntityAria","New view from entity"),children:[e.jsx("option",{value:"",children:y("viewEditor.fromEntity","New from entity…")}),d.map(F=>["form","detail","grid"].map(H=>e.jsxs("option",{value:`${F.name}::${H}`,children:[F.name," · ",H]},`${F.name}-${H}`)))]}),Lf.has(oe)&&e.jsxs("select",{className:"nice-view-editor__export",value:"",onChange:F=>{const H=F.target.value;H&&q(H)},"aria-label":y("viewEditor.exportAria","Export view"),children:[e.jsx("option",{value:"",children:y("viewEditor.export","Export…")}),zf.map(F=>e.jsx("option",{value:F,children:F.toUpperCase()},F))]}),e.jsx("span",{className:"nice-view-editor__spacer"}),e.jsx("div",{className:"nice-view-editor__modes",ref:a,role:"tablist",children:["design","preview","source"].map(F=>e.jsx("button",{type:"button",role:"tab","aria-selected":_===F,className:"nice-view-editor__mode"+(_===F?" nice-view-editor__mode--active":""),onClick:()=>k(F),children:y("viewEditor.mode."+F,F[0].toUpperCase()+F.slice(1))},F))}),e.jsxs("span",{className:"nice-view-editor__status"+(U.length?" nice-view-editor__status--err":""),title:U.join(`
|
|
1288
1293
|
`),children:[e.jsx(l.NiceIcon,{name:U.length===0?"check":"warning",size:14})," ",U.length===0?y("viewEditor.valid","Valid"):U.length]}),m&&e.jsx("button",{type:"button",className:"nice-view-editor__save",onClick:()=>m(E),disabled:U.length>0,children:y("viewEditor.save","Save")}),e.jsx(l.NiceTutorialButton,{steps:l.resolveTutorial(x,Af)})]}),ce=e.jsxs("div",{className:"nice-view-editor__palette",children:[Rf.map(F=>e.jsxs("div",{className:"nice-view-editor__pal-group",children:[e.jsx("div",{className:"nice-view-editor__pal-cat",children:y("viewEditor.cat."+F.category,F.category)}),F.items.map(H=>{const A=y("viewEditor.pal."+H.type,H.label);return e.jsx("button",{type:"button",className:"nice-view-editor__pal-item",onClick:()=>L(H.type),title:`${y("viewEditor.add","Add")} ${A}`,children:A},H.type)})]},F.category)),e.jsxs("button",{type:"button",className:"nice-view-editor__add-row",onClick:O,children:["+ ",y("viewEditor.addRow","Add row")]})]}),le=e.jsxs("div",{className:"nice-view-editor__canvas",children:[T.length===0&&e.jsx("div",{className:"nice-view-editor__canvas-empty",children:y("viewEditor.canvasEmpty","Add a row, then drop controls from the palette — or start “New from entity”.")}),T.map(F=>e.jsxs("div",{className:"nice-view-editor__row",style:{gridTemplateColumns:`repeat(${E.columns??12}, 1fr)`},children:[F.cells.map(H=>e.jsxs("button",{type:"button",className:"nice-view-editor__cell"+(H.id===S?" nice-view-editor__cell--sel":""),style:{gridColumn:`span ${H.colSpan??6}`},onClick:()=>N(H.id),onKeyDown:A=>{A.key==="Delete"&&(A.preventDefault(),V(H.id))},children:[e.jsx("span",{className:"nice-view-editor__cell-type",children:H.controlType}),H.bindings?.value?.field&&e.jsxs("span",{className:"nice-view-editor__cell-field",children:[e.jsx(l.NiceIcon,{name:"link",size:12})," ",H.bindings.value.field]}),e.jsx("span",{className:"nice-view-editor__cell-x",role:"button",tabIndex:-1,"aria-label":y("viewEditor.removeCell","Remove cell"),onClick:A=>{A.stopPropagation(),V(H.id)},onKeyDown:A=>{(A.key==="Enter"||A.key===" ")&&(A.preventDefault(),A.stopPropagation(),V(H.id))},children:e.jsx(l.NiceIcon,{name:"close",size:14})})]},H.id)),F.cells.length===0&&e.jsx("span",{className:"nice-view-editor__row-empty",children:y("viewEditor.emptyRow","empty row")})]},F.id))]}),J=I?e.jsx(Uf,{cell:I.cell,dsKeys:P,handlerNames:B,onPatch:F=>M(I.cell.id,F)}):e.jsx(Hf,{dataSources:E.dataSources??[],onChange:F=>j({...E,dataSources:F}),queryOptions:p,entityNames:z}),me="nice-view-editor"+(f?` ${f}`:""),je=_==="design",ue=_==="source"?e.jsx("pre",{className:"nice-view-editor__source",children:Jd(E)}):_==="preview"?e.jsx("div",{className:"nice-view-editor__preview",children:e.jsx(nu,{view:E,registry:c,dataStore:re})}):le;return e.jsx(_t.NiceAppShell,{ref:i,id:g,className:me,style:{height:u,...b},"data-testid":v,flush:!0,toolbar:se,sidebar:je?ce:void 0,rightSidebar:je?e.jsx("div",{className:"nice-view-editor__props",children:J}):void 0,children:ue})});function Uf({cell:t,dsKeys:n,handlerNames:i,onPatch:a}){const{t:s}=l.useNiceTranslation(),o=t.bindings?.value,c=u=>{const x={source:"",field:"",...o,...u};a({bindings:{...t.bindings,value:x}})},d=t.events??[],p=u=>a({events:u}),m=t.permissions??[],h=u=>a({permissions:u});return e.jsxs("div",{className:"nice-view-editor__panel",children:[e.jsxs("div",{className:"nice-view-editor__panel-title",children:[s("viewEditor.control","Control")," · ",t.controlType]}),e.jsx("label",{className:"nice-view-editor__lbl",children:s("viewEditor.cp.label","Label")}),e.jsx("input",{className:"nice-view-editor__in",value:t.props.label??"",onChange:u=>a({props:{...t.props,label:u.target.value}})}),e.jsx("label",{className:"nice-view-editor__lbl",children:s("viewEditor.cp.colSpan","Column span")}),e.jsx("input",{className:"nice-view-editor__in",type:"number",min:1,max:12,value:t.colSpan??6,onChange:u=>a({colSpan:Number(u.target.value)||6})}),e.jsx("div",{className:"nice-view-editor__panel-sub",children:s("viewEditor.cp.binding","Binding")}),e.jsx("label",{className:"nice-view-editor__lbl",children:s("viewEditor.cp.dataSource","Data source")}),e.jsxs("select",{className:"nice-view-editor__in",value:o?.source??"",onChange:u=>c({source:u.target.value}),children:[e.jsx("option",{value:"",children:s("viewEditor.cp.none","— none —")}),n.map(u=>e.jsx("option",{value:u,children:u},u))]}),e.jsx("label",{className:"nice-view-editor__lbl",children:s("viewEditor.cp.field","Field")}),e.jsx("input",{className:"nice-view-editor__in",value:o?.field??"",onChange:u=>c({field:u.target.value}),placeholder:s("viewEditor.cp.fieldPath","field path")}),e.jsxs("label",{className:"nice-view-editor__chk",children:[e.jsx("input",{type:"checkbox",checked:!!o?.twoWay,onChange:u=>c({twoWay:u.target.checked})}),s("viewEditor.cp.twoWay","Two-way")]}),e.jsx("div",{className:"nice-view-editor__panel-sub",children:s("viewEditor.cp.permissions","Permissions")}),m.map((u,x)=>e.jsxs("div",{className:"nice-view-editor__perm",children:[e.jsx("input",{className:"nice-view-editor__in",value:u.role,placeholder:s("viewEditor.cp.role","role"),onChange:f=>h(m.map((b,g)=>g===x?{...b,role:f.target.value}:b))}),e.jsx("select",{className:"nice-view-editor__in",value:u.access,onChange:f=>h(m.map((b,g)=>g===x?{...b,access:f.target.value}:b)),children:Mf.map(f=>e.jsx("option",{value:f,children:f},f))}),e.jsx("button",{type:"button",onClick:()=>h(m.filter((f,b)=>b!==x)),"aria-label":s("viewEditor.remove","Remove"),children:e.jsx(l.NiceIcon,{name:"close",size:14})})]},x)),e.jsxs("button",{type:"button",className:"nice-view-editor__mini-add",onClick:()=>h([...m,{role:"*",access:"editable"}]),children:["+ ",s("viewEditor.cp.addPermission","Permission")]}),e.jsx("div",{className:"nice-view-editor__panel-sub",children:s("viewEditor.cp.events","Events")}),d.map((u,x)=>e.jsxs("div",{className:"nice-view-editor__event",children:[e.jsx("input",{className:"nice-view-editor__in",value:u.event,placeholder:s("viewEditor.cp.eventPlaceholder","event (onClick / onValueChange…)"),onChange:f=>p(d.map((b,g)=>g===x?{...b,event:f.target.value}:b))}),e.jsx(Zd,{value:u.actions,handlers:i,dataSources:n,onChange:f=>p(d.map((b,g)=>g===x?{...b,actions:f}:b))}),e.jsx("button",{type:"button",className:"nice-view-editor__mini-remove",onClick:()=>p(d.filter((f,b)=>b!==x)),children:s("viewEditor.cp.removeEvent","Remove event")})]},x)),e.jsxs("button",{type:"button",className:"nice-view-editor__mini-add",onClick:()=>p([...d,{event:"onClick",actions:[]}]),children:["+ ",s("viewEditor.cp.addEvent","Event")]})]})}function Hf({dataSources:t,onChange:n,queryOptions:i,entityNames:a}){const{t:s}=l.useNiceTranslation(),o=(d,p)=>n(t.map((m,h)=>h===d?{...m,...p}:m)),c=(d,p)=>d.type==="query"&&i&&i.length>0?e.jsxs("select",{className:"nice-view-editor__in",value:d.ref??"","aria-label":s("viewEditor.ds.ref","Module data source"),onChange:m=>o(p,{ref:m.target.value||void 0}),children:[e.jsx("option",{value:"",children:s("viewEditor.ds.refPick","Pick a data source…")}),i.map(m=>e.jsx("option",{value:m.key,children:m.label??m.key},m.key))]}):d.type==="query"?e.jsx("input",{className:"nice-view-editor__in",value:d.ref??"",placeholder:s("viewEditor.ds.ref","Module data source"),onChange:m=>o(p,{ref:m.target.value||void 0})}):d.type==="entity"&&a.length>0?e.jsxs("select",{className:"nice-view-editor__in",value:d.entity??"","aria-label":s("viewEditor.ds.entity","Entity"),onChange:m=>o(p,{entity:m.target.value||void 0}),children:[e.jsx("option",{value:"",children:s("viewEditor.ds.entityPick","Pick an entity…")}),a.map(m=>e.jsx("option",{value:m,children:m},m))]}):d.type==="entity"?e.jsx("input",{className:"nice-view-editor__in",value:d.entity??"",placeholder:s("viewEditor.ds.entity","Entity"),onChange:m=>o(p,{entity:m.target.value||void 0})}):e.jsx("input",{className:"nice-view-editor__in",value:d.endpoint??"",placeholder:s("viewEditor.ds.endpoint","endpoint"),onChange:m=>o(p,{endpoint:m.target.value})});return e.jsxs("div",{className:"nice-view-editor__panel",children:[e.jsx("div",{className:"nice-view-editor__panel-title",children:s("viewEditor.ds.title","Data sources")}),e.jsx("div",{className:"nice-view-editor__hint",children:s("viewEditor.ds.hint","Select a control to edit its props, binding & events.")}),t.map((d,p)=>e.jsxs("div",{className:"nice-view-editor__ds",children:[e.jsx("input",{className:"nice-view-editor__in",value:d.key,placeholder:s("viewEditor.ds.key","key"),onChange:m=>o(p,{key:m.target.value})}),e.jsx("select",{className:"nice-view-editor__in",value:d.type,onChange:m=>o(p,{type:m.target.value}),children:$f.map(m=>e.jsx("option",{value:m,children:m},m))}),c(d,p),e.jsxs("label",{className:"nice-view-editor__chk",children:[e.jsx("input",{type:"checkbox",checked:!!d.autoLoad,onChange:m=>o(p,{autoLoad:m.target.checked})}),s("viewEditor.ds.autoLoad","auto-load")]}),e.jsx("button",{type:"button",onClick:()=>n(t.filter((m,h)=>h!==p)),"aria-label":s("viewEditor.remove","Remove"),children:e.jsx(l.NiceIcon,{name:"close",size:14})})]},p)),e.jsxs("button",{type:"button",className:"nice-view-editor__mini-add",onClick:()=>n([...t,{key:`ds${t.length+1}`,type:"rest",autoLoad:!0}]),children:["+ ",s("viewEditor.ds.add","Data source")]})]})}const Gf="nice-view-editor-styles",Wf=`
|
|
1289
1294
|
.nice-view-editor { display: flex; flex-direction: column; border: 1px solid var(--nice-border-color, #e5e7eb); border-radius: 8px; overflow: hidden; background: var(--nice-bg-primary, #fff); color: var(--nice-text-primary, #111827); }
|
|
1290
1295
|
.nice-view-editor__toolbar { display: flex; align-items: center; gap: 8px; padding: 8px; border-bottom: 1px solid var(--nice-border-color, #e5e7eb); flex-wrap: wrap; }
|
|
@@ -2791,7 +2796,7 @@ This is **Markdown**.`);return e.jsx(it.NiceMarkdownEditor,{value:t,onChange:n,m
|
|
|
2791
2796
|
padding: var(--nice-space-4, 16px);
|
|
2792
2797
|
text-align: center;
|
|
2793
2798
|
}
|
|
2794
|
-
`,tn=(t,n,i)=>({id:t,label:n,entries:i.map(a=>({name:a.name,theme:a,category:t}))}),j_=(()=>{const t=l.NICE_THEME_ARCHIVE.gallery,n=(i,a,s,o)=>({id:i,label:a,entries:s.map(c=>({name:c.theme.name,theme:c.theme,pack:c,packList:o,category:i}))});return[n("packs","Theme Packs",l.NICE_THEME_ARCHIVE.packs,"base"),n("packs-2","Theme Packs Vol. 2",l.NICE_THEME_ARCHIVE.packsExtended,"extended"),tn("core","Core",l.NICE_THEME_ARCHIVE.core),tn("neutral","Neutral",t.slice(0,8)),tn("vibrant","Vibrant",t.slice(8,22)),tn("dark","Dark",t.slice(22,32)),tn("nature","Nature",t.slice(32,42)),tn("pastel","Pastel",t.slice(42,50)),tn("industry","Industry",t.slice(50,58)),tn("design-system","Design System",t.slice(58,64)),tn("retro","Retro",t.slice(64,72)),tn("seasonal","Seasonal",t.slice(72,80)),tn("cultural","Cultural",t.slice(80,88)),tn("accessibility","Accessibility",t.slice(88,92)),tn("modern-ui","Modern UI",t.slice(92))]})(),Eu=Object.assign(r.forwardRef(({src:t,page:n,totalPages:i,size:a="md",editorSize:s="standard",showToolbar:o=!0,showPageNav:c=!0,showZoom:d=!0,showDownload:p=!0,showPrint:m=!0,zoom:h,minZoom:u=25,maxZoom:x=400,height:f=600,aspectRatio:b="210 / 297",fit:g="page",onPageChange:v,onZoomChange:y,onLoad:C,onError:w,renderPage:E,className:S,style:N,id:_,testId:k,"data-testid":j,...T},P)=>{const B=l.useControlId(_),{t:R}=l.useNiceTranslation(),I=r.useRef(null),D=r.useRef(null);l.useRovingFocus(D,{orientation:"horizontal",itemSelector:"button"});const[M,O]=r.useState(n??1),[L,V]=r.useState(i??0),[ee,z]=r.useState(h??100),[U,re]=r.useState(null),[Y,oe]=r.useState(!1),q=n&&n>0?n:M,se=h&&h>0?h:ee;r.useEffect(()=>{n!==void 0&&n>0&&O(n)},[n]),r.useEffect(()=>{h!==void 0&&h>0&&z(h)},[h]),r.useEffect(()=>{i!==void 0&&V(i)},[i]),r.useEffect(()=>{if(!(!E||!I.current)){oe(!0),re(null);try{E({page:q,zoom:se,container:I.current}),oe(!1)}catch(F){const H=F instanceof Error?F.message:String(F);re(H),oe(!1),w?.(H)}}},[q,se,E,w]);const ce=r.useCallback(F=>{const H=Math.max(1,Math.min(L||F,F));O(H),v?.(H)},[L,v]),le=r.useCallback(F=>{const H=Math.max(u,Math.min(x,F));z(H),y?.(H)},[u,x,y]),J=r.useCallback(()=>{if(typeof t=="string"){const F=document.createElement("a");F.href=t,F.download="document.pdf",F.click()}else if(t instanceof ArrayBuffer||t instanceof Uint8Array){const F=t instanceof Uint8Array?t.buffer:t,H=new Blob([F],{type:"application/pdf"}),A=URL.createObjectURL(H),Z=document.createElement("a");Z.href=A,Z.download="document.pdf",Z.click(),URL.revokeObjectURL(A)}},[t]),me=r.useCallback(()=>{if(typeof t!="string")return;let F=t,H=null;if(t.startsWith("data:"))try{const Z=t.indexOf(","),fe=t.slice(5,Z),Ne=t.slice(Z+1),K=fe.split(";")[0]||"application/pdf",Q=/;base64/i.test(fe)?Uint8Array.from(atob(Ne),ne=>ne.charCodeAt(0)):new TextEncoder().encode(decodeURIComponent(Ne));H=URL.createObjectURL(new Blob([Q],{type:K})),F=H}catch{}const A=window.open(F);if(A&&A.addEventListener("load",()=>A.print()),H){const Z=H;window.setTimeout(()=>URL.revokeObjectURL(Z),6e4)}},[t]),je=typeof t=="string"&&!E,ue=g==="page";return e.jsxs("div",{ref:P,id:B,className:`nice-pdfviewer nice-pdfviewer--${a} nice-pdfviewer--fit-${g} nice-editor--${s} ${S??""}`,style:{...N,...ue?null:{height:f},"--nice-pdf-aspect":b},role:"document","aria-label":R("pdfviewer.label","PDF Viewer"),"data-testid":j??k,...T,children:[o&&e.jsxs("div",{ref:D,className:"nice-pdfviewer__toolbar",role:"toolbar","aria-label":R("pdfViewer.toolbar","PDF tools"),children:[c&&e.jsxs("div",{className:"nice-pdfviewer__page-nav",children:[e.jsx("button",{type:"button",className:"nice-pdfviewer__btn",disabled:q<=1,onClick:()=>ce(q-1),"aria-label":R("pdfviewer.prevPage","Previous page"),children:e.jsx(l.NiceIcon,{name:"chevron-left",size:16})}),e.jsxs("span",{className:"nice-pdfviewer__page-info",children:[q," / ",L||"?"]}),e.jsx("button",{type:"button",className:"nice-pdfviewer__btn",disabled:L>0&&q>=L,onClick:()=>ce(q+1),"aria-label":R("pdfviewer.nextPage","Next page"),children:e.jsx(l.NiceIcon,{name:"chevron-right",size:16})})]}),d&&e.jsxs("div",{className:"nice-pdfviewer__zoom-controls",children:[e.jsx("button",{type:"button",className:"nice-pdfviewer__btn",onClick:()=>le(se-25),disabled:se<=u,"aria-label":R("pdfviewer.zoomOut","Zoom out"),children:e.jsx(l.NiceIcon,{name:"minus",size:16})}),e.jsxs("span",{className:"nice-pdfviewer__zoom-label",children:[se,"%"]}),e.jsx("button",{type:"button",className:"nice-pdfviewer__btn",onClick:()=>le(se+25),disabled:se>=x,"aria-label":R("pdfviewer.zoomIn","Zoom in"),children:e.jsx(l.NiceIcon,{name:"plus",size:16})})]}),e.jsxs("div",{className:"nice-pdfviewer__actions",children:[p&&e.jsx("button",{type:"button",className:"nice-pdfviewer__btn",onClick:J,"aria-label":R("pdfviewer.download","Download"),children:e.jsx(l.NiceIcon,{name:"download",size:16})}),m&&typeof t=="string"&&e.jsx("button",{type:"button",className:"nice-pdfviewer__btn",onClick:me,"aria-label":R("pdfviewer.print","Print"),children:e.jsx(l.NiceIcon,{name:"printer",size:16})})]})]}),U&&e.jsx("div",{className:"nice-pdfviewer__error",role:"alert",children:U}),Y&&e.jsx("div",{className:"nice-pdfviewer__loading",children:R("pdfviewer.loading","Loading...")}),e.jsx("div",{className:"nice-pdfviewer__content",children:je?e.jsx("div",{className:"nice-pdfviewer__iframe-wrap",style:{transform:`scale(${se/100})`,transformOrigin:"top center"},children:e.jsx("iframe",{className:"nice-pdfviewer__iframe",src:`${t}#page=${q}&toolbar=0&view=FitH`,title:R("pdfviewer.label","PDF Viewer"),onLoad:()=>C?.(L)})}):e.jsx("div",{ref:I,className:"nice-pdfviewer__canvas",style:{transform:`scale(${se/100})`,transformOrigin:"top left"}})})]})}),{displayName:"NicePDFViewer"}),w_={heat:["var(--nice-color-warning, #f59e0b)","var(--nice-color-error, #ef4444)"],cool:["var(--nice-color-info, #06b6d4)","var(--nice-color-primary, #3b82f6)"],auto:["var(--nice-color-accent, #8b5cf6)","var(--nice-color-accent-pink, #ec4899)"],off:["var(--nice-text-muted, #9ca3af)","var(--nice-text-muted, #6b7280)"]},k_={xxs:60,xs:80,sm:110,md:150,lg:190,xl:230,xxl:280,small:110,medium:150,large:190},$n=-130,ca=260,Iu=({value:t,defaultValue:n,currentTemp:i,min:a=16,max:s=30,step:o=.5,onChange:c,mode:d="auto",size:p="md",showCurrentTemp:m=!0,disabled:h=!1,className:u,style:x,"data-testid":f})=>{const{t:b}=l.useNiceTranslation(),[g,v]=l.useControllableState({value:t,defaultValue:n,fallbackValue:a,onChange:c,componentName:"NiceTempDial"}),[y,C]=r.useState(!1),w=r.useRef(null),E=k_[p],S=E/2,N=E/2,_=E*.38,k=$n+(g-a)/(s-a)*ca,[j,T]=w_[d],P=r.useCallback(V=>{const ee=(V-$n)/ca,z=a+ee*(s-a);return Math.round(z/o)*o},[a,s,o]),B=r.useCallback((V,ee)=>{const z=w.current?.getBoundingClientRect();if(!z)return k;const U=V-(z.left+z.width/2),re=ee-(z.top+z.height/2);let Y=Math.atan2(re,U)*(180/Math.PI)+90;return Y>180&&(Y-=360),Y},[k]),R=r.useCallback(V=>{if(!y||h)return;const ee=B(V.clientX,V.clientY),z=Math.max($n,Math.min($n+ca,ee));v(Math.max(a,Math.min(s,P(z))))},[y,h,B,P,a,s,v]),I=r.useCallback(()=>C(!1),[]);r.useEffect(()=>(y&&(window.addEventListener("pointermove",R),window.addEventListener("pointerup",I)),()=>{window.removeEventListener("pointermove",R),window.removeEventListener("pointerup",I)}),[y,R,I]);const D=(V,ee)=>{const z=(V-90)*(Math.PI/180);return{x:S+ee*Math.cos(z),y:N+ee*Math.sin(z)}},M=(V,ee,z)=>{const U=D(V,z),re=D(ee,z),Y=ee-V>180?1:0;return`M ${U.x} ${U.y} A ${z} ${z} 0 ${Y} 1 ${re.x} ${re.y}`},O=D(k,_),L=`tempDial-${d}-${p}`;return e.jsx("div",{className:`nice-temp-dial nice-temp-dial--${p} nice-temp-dial--${d}${h?" nice-temp-dial--disabled":""} ${u??""}`,style:x,"data-testid":f,role:"slider","aria-valuemin":a,"aria-valuemax":s,"aria-valuenow":g,"aria-label":`${b("smartHome.temperature","Temperature")}: ${g}°C, ${b("smartHome.mode","mode")}: ${d}`,tabIndex:h?-1:0,onKeyDown:V=>{if(h)return;const ee=Math.max(o,(s-a)/10),z=V.key==="ArrowUp"||V.key==="ArrowRight"?g+o:V.key==="ArrowDown"||V.key==="ArrowLeft"?g-o:V.key==="PageUp"?g+ee:V.key==="PageDown"?g-ee:V.key==="Home"?a:V.key==="End"?s:null;z!==null&&(V.preventDefault(),v(Math.max(a,Math.min(s,z))))},children:e.jsxs("svg",{ref:w,viewBox:`0 0 ${E} ${E}`,width:E,height:E,"aria-hidden":"true",style:{cursor:h?"default":"grab",touchAction:"none"},onPointerDown:V=>{h||(V.target.setPointerCapture(V.pointerId),C(!0))},children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:L,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:[e.jsx("stop",{offset:"0%",stopColor:j}),e.jsx("stop",{offset:"100%",stopColor:T})]})}),e.jsx("path",{d:M($n,$n+ca,_),fill:"none",stroke:"var(--nice-bg-tertiary, #e5e7eb)",strokeWidth:E*.06,strokeLinecap:"round"}),d!=="off"&&e.jsx("path",{d:M($n,k,_),fill:"none",stroke:`url(#${L})`,strokeWidth:E*.06,strokeLinecap:"round"}),m&&i!==void 0&&(()=>{const V=$n+(i-a)/(s-a)*ca,ee=D(V,_-E*.06),z=D(V,_+E*.06);return e.jsx("line",{x1:ee.x,y1:ee.y,x2:z.x,y2:z.y,stroke:"var(--nice-success, #22c55e)",strokeWidth:2,strokeLinecap:"round"})})(),e.jsx("circle",{cx:O.x,cy:O.y,r:E*.065,fill:T,stroke:"white",strokeWidth:2,style:{filter:y?"drop-shadow(0 2px 6px var(--nice-overlay-40, rgba(0, 0, 0, 0.4)))":void 0}}),e.jsx("text",{x:S,y:N-E*.06,textAnchor:"middle",fontSize:E*.22,fontWeight:700,fill:"currentColor",children:g.toFixed(1)}),e.jsx("text",{x:S,y:N+E*.04,textAnchor:"middle",fontSize:E*.09,fill:"var(--nice-text-muted, #6b7280)",children:"°C"}),m&&i!==void 0&&e.jsxs("text",{x:S,y:N+E*.15,textAnchor:"middle",fontSize:E*.08,fill:"var(--nice-success, #22c55e)",children:[b("controls.now","Now"),": ",i.toFixed(1),"°"]}),e.jsx("text",{x:S,y:N+E*.36,textAnchor:"middle",fontSize:E*.08,fill:"var(--nice-text-muted, #9ca3af)",children:d.toUpperCase()})]})})},C_={xxs:32,xs:44,sm:56,md:72,lg:88,xl:104,xxl:128,small:56,medium:72,large:88},Du=({isLocked:t,onLockChange:n,requireConfirm:i=!0,confirmCode:a,size:s="md",loading:o=!1,disabled:c=!1,label:d,className:p,style:m,"data-testid":h})=>{const{t:u}=l.useNiceTranslation(),[x,f]=r.useState(!1),[b,g]=r.useState(""),[v,y]=r.useState(!1),[C,w]=r.useState(!1),E=r.useRef(null),S=r.useRef(null),N=C_[s];l.useOverlayFocus(S,{open:x,modal:!1,initialFocus:a?E:"first",onClose:()=>f(!1),closeHint:u("smartHome.cancel","Cancel")});const _=()=>{c||o||C||(i||a?(f(!0),g(""),y(!1)):k())},k=()=>{w(!0),f(!1),g(""),setTimeout(()=>{w(!1),n(!t)},400)},j=()=>{if(a&&b!==a){y(!0);return}k()},T=P=>{g(P),y(!1),a&&P.length>=a.length&&(P===a?k():y(!0))};return e.jsxs("div",{className:`nice-lock ${p??""}`,style:m,"data-testid":h,children:[e.jsx("button",{type:"button",className:`nice-lock__btn nice-lock__btn--${t?"locked":"unlocked"} nice-lock__btn--${s}${C?" nice-lock__btn--animating":""}`,onClick:_,disabled:c||o,"aria-label":t?u("smartHome.unlock","Unlock"):u("smartHome.lock","Lock"),"aria-pressed":!t,style:{width:N,height:N},children:o?e.jsx("span",{className:"nice-lock__spinner","aria-hidden":"true"}):e.jsx("svg",{viewBox:"0 0 24 24",width:N*.5,height:N*.5,fill:"none","aria-hidden":"true",children:t?e.jsxs(e.Fragment,{children:[e.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",fill:C?"var(--nice-color-warning, #f59e0b)":"var(--nice-color-primary, #3b82f6)"}),e.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4",stroke:C?"var(--nice-color-warning, #f59e0b)":"var(--nice-color-primary, #3b82f6)",strokeWidth:"2.5",strokeLinecap:"round",fill:"none"}),e.jsx("circle",{cx:"12",cy:"16",r:"1.5",fill:"white"})]}):e.jsxs(e.Fragment,{children:[e.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",fill:"var(--nice-success, #22c55e)"}),e.jsx("path",{d:"M7 11V7a5 5 0 0 1 9.9-1",stroke:"var(--nice-success, #22c55e)",strokeWidth:"2.5",strokeLinecap:"round",fill:"none"}),e.jsx("circle",{cx:"12",cy:"16",r:"1.5",fill:"white"})]})})}),d&&e.jsx("span",{className:"nice-lock__label",children:d}),x&&e.jsxs("div",{ref:S,className:"nice-lock__confirm",role:"dialog","aria-label":u("smartHome.confirmAction","Confirm action"),children:[e.jsxs("p",{className:"nice-lock__confirm-prompt",children:[t?u("smartHome.unlockQuestion","Unlock?"):u("smartHome.lockQuestion","Lock?"),a&&` ${u("smartHome.enterCode","Enter the code:")}`]}),a?e.jsx("input",{ref:E,type:"password",value:b,onChange:P=>T(P.target.value),maxLength:a.length,className:`nice-lock__pin-input${v?" nice-lock__pin-input--error":""}`,placeholder:"••••","aria-label":u("smartHome.confirmationCode","Confirmation code"),"aria-invalid":v}):e.jsxs("div",{className:"nice-lock__confirm-btns",children:[e.jsx("button",{type:"button",className:"nice-lock__confirm-yes",onClick:j,children:u("smartHome.yes","Yes")}),e.jsx("button",{type:"button",className:"nice-lock__confirm-no",onClick:()=>f(!1),children:u("smartHome.cancel","Cancel")})]}),v&&e.jsx("p",{className:"nice-lock__pin-error",role:"alert",children:u("smartHome.wrongCode","Wrong code")})]})]})},S_={light:"lightbulb",thermostat:"bar-chart",lock:"lock",switch:"plug",cover:"window",climate:"cloud",alarm:"bell","media-player":"music",gate:"arrow-right","energy-meter":"zap"};function T_({level:t}){const{t:n}=l.useNiceTranslation();return e.jsx("span",{className:"nice-device-card__signal","aria-label":`${n("smartHome.signal","Signal")}: ${t}/4`,title:`${n("smartHome.signal","Signal")}: ${t}/4`,children:[1,2,3,4].map(i=>e.jsx("span",{className:`nice-device-card__signal-bar${i<=t?" nice-device-card__signal-bar--active":""}`},i))})}function E_({level:t}){const{t:n}=l.useNiceTranslation(),i=t<=20?"var(--nice-color-error, #ef4444)":t<=50?"var(--nice-color-warning, #f59e0b)":"var(--nice-color-success, #22c55e)";return e.jsxs("span",{className:"nice-device-card__battery","aria-label":n("smartHome.battery","Battery: {level}%").replace("{level}",String(t)),title:n("smartHome.battery","Battery: {level}%").replace("{level}",String(t)),style:{color:i},children:[t,"%"]})}function I_(t){if(!t)return"";const n=typeof t=="string"?new Date(t):t,i=Date.now()-n.getTime();return i<6e4?"tylko co":i<36e5?`${Math.floor(i/6e4)} min temu`:i<864e5?`${Math.floor(i/36e5)}h temu`:n.toLocaleDateString("pl-PL")}function D_({device:t,onStateChange:n}){const{t:i}=l.useNiceTranslation(),a=t.state.on??!1,s=t.state.brightness??100;return e.jsxs("div",{className:"nice-device-card__control",children:[e.jsxs("button",{type:"button",className:`nice-device-card__toggle${a?" nice-device-card__toggle--on":""}`,onClick:()=>n(t.id,{on:!a}),"aria-pressed":a,"aria-label":a?i("smartHome.turnLightOff","Turn light off"):i("smartHome.turnLightOn","Turn light on"),children:[e.jsx(l.NiceIcon,{name:"lightbulb",size:14})," ",a?i("smartHome.onShort","On"):i("smartHome.offShort","Off")]}),a&&e.jsxs("label",{className:"nice-device-card__slider-label",children:[e.jsxs("span",{children:[i("smartHome.brightness","Brightness"),": ",s,"%"]}),e.jsx("input",{type:"range",min:1,max:100,value:s,onChange:o=>n(t.id,{on:!0,brightness:Number(o.target.value)}),"aria-label":i("smartHome.brightness","Brightness")})]})]})}function P_({device:t,onStateChange:n}){const i=t.state.setpoint??21,a=t.state.currentTemp,s=t.state.mode??"auto";return e.jsx("div",{className:"nice-device-card__control nice-device-card__control--thermostat",children:e.jsx(Iu,{value:i,currentTemp:a,min:16,max:30,step:.5,mode:s,size:"sm",onChange:o=>n(t.id,{setpoint:o,mode:s,currentTemp:a})})})}function A_({device:t,onStateChange:n}){const{t:i}=l.useNiceTranslation(),a=t.state.locked??!0;return e.jsx("div",{className:"nice-device-card__control",children:e.jsx(Du,{isLocked:a,onLockChange:s=>n(t.id,{locked:s}),requireConfirm:!0,size:"md",label:a?i("smartHome.locked","Locked"):i("smartHome.unlocked","Unlocked")})})}function R_({device:t,onStateChange:n}){const{t:i}=l.useNiceTranslation(),a=t.state.on??!1;return e.jsx("div",{className:"nice-device-card__control",children:e.jsxs("button",{type:"button",className:`nice-device-card__toggle${a?" nice-device-card__toggle--on":""}`,onClick:()=>n(t.id,{on:!a}),"aria-pressed":a,"aria-label":a?i("smartHome.turnOff","Turn off"):i("smartHome.turnOn","Turn on"),children:[e.jsx(l.NiceIcon,{name:a?"check":"circle",size:14})," ",a?i("smartHome.switchedOn","On"):i("smartHome.switchedOff","Off")]})})}function $_({device:t,onStateChange:n}){const{t:i}=l.useNiceTranslation(),a=t.state.position??0;return e.jsxs("div",{className:"nice-device-card__control",children:[e.jsxs("label",{className:"nice-device-card__slider-label",children:[e.jsx("span",{children:i("smartHome.open2","Open: {position}%").replace("{position}",String(a))}),e.jsx("input",{type:"range",min:0,max:100,value:a,onChange:s=>n(t.id,{position:Number(s.target.value)}),"aria-label":i("smartHome.blindsOpening","Blinds opening")})]}),e.jsxs("div",{className:"nice-device-card__blind-btns",children:[e.jsx("button",{type:"button",onClick:()=>n(t.id,{position:0}),"aria-label":i("smartHome.close","Close"),children:e.jsx(l.NiceIcon,{name:"arrow-down",size:16})}),e.jsx("button",{type:"button",onClick:()=>n(t.id,{position:50}),"aria-label":i("smartHome.half","Half"),children:"50%"}),e.jsx("button",{type:"button",onClick:()=>n(t.id,{position:100}),"aria-label":i("smartHome.open","Open"),children:e.jsx(l.NiceIcon,{name:"arrow-up",size:16})})]})]})}function M_(t,n){switch(t.category){case"light":return e.jsx(D_,{device:t,onStateChange:n});case"thermostat":return e.jsx(P_,{device:t,onStateChange:n});case"lock":return e.jsx(A_,{device:t,onStateChange:n});case"switch":return e.jsx(R_,{device:t,onStateChange:n});case"cover":return e.jsx($_,{device:t,onStateChange:n});default:return e.jsxs("div",{className:"nice-device-card__control nice-device-card__control--readonly",children:[e.jsx("span",{className:"nice-device-card__state-badge",children:t.isOnline?"Online":"Offline"}),Object.entries(t.state).slice(0,3).map(([i,a])=>e.jsxs("span",{className:"nice-device-card__state-kv",children:[i,": ",e.jsx("strong",{children:String(a)})]},i))]})}}const O_=({device:t,onStateChange:n,showBattery:i=!0,showSignal:a=!0,showLastSeen:s=!0,compact:o=!1,controlLayout:c="card",className:d,style:p,"data-testid":m})=>{const{t:h}=l.useNiceTranslation(),[u,x]=r.useState(!o),f=S_[t.category]??"settings";return e.jsxs("div",{className:`nice-device-card nice-device-card--${c}${t.isOnline?"":" nice-device-card--offline"} ${d??""}`,style:p,"data-testid":m,role:"region","aria-label":`${h("smartHome.device","Device")}: ${t.name}`,children:[e.jsxs("div",{className:"nice-device-card__header",children:[e.jsx("span",{className:"nice-device-card__icon","aria-hidden":"true",children:e.jsx(l.NiceIcon,{name:f,size:20})}),e.jsxs("div",{className:"nice-device-card__info",children:[e.jsx("span",{className:"nice-device-card__name",children:t.name}),t.roomId&&e.jsx("span",{className:"nice-device-card__room",children:t.roomId})]}),e.jsxs("div",{className:"nice-device-card__meta",children:[a&&t.signalStrength!==void 0&&e.jsx(T_,{level:Math.round(t.signalStrength/25)}),i&&t.batteryLevel!==void 0&&e.jsx(E_,{level:t.batteryLevel}),e.jsx("span",{className:`nice-device-card__status${t.isOnline?" nice-device-card__status--online":" nice-device-card__status--offline"}`,"aria-label":t.isOnline?h("smartHome.online","Online"):h("smartHome.offline","Offline"),children:e.jsx(l.NiceIcon,{name:"circle",size:12})})]}),o&&e.jsx("button",{type:"button",className:"nice-device-card__expand-btn",onClick:()=>x(b=>!b),"aria-expanded":u,"aria-label":u?h("smartHome.collapse","Collapse"):h("smartHome.expand","Expand"),children:e.jsx(l.NiceIcon,{name:u?"arrow-up":"arrow-down",size:16})})]}),u&&e.jsxs("div",{className:"nice-device-card__body",children:[M_(t,n),s&&t.lastSeen&&e.jsxs("p",{className:"nice-device-card__last-seen",children:[h("smartHome.lastSeen","Last seen"),": ",I_(t.lastSeen)]})]})]})},L_=[];function Hc(t,n,i,a){const s=(a-90)*(Math.PI/180);return{x:t+i*Math.cos(s),y:n+i*Math.sin(s)}}function Gc(t,n,i,a,s){const o=Hc(t,n,i,a),c=Hc(t,n,i,s),d=s-a>180?1:0;return`M ${o.x} ${o.y} A ${i} ${i} 0 ${d} 1 ${c.x} ${c.y}`}const z_=({label:t,value:n,min:i,max:a,unit:s,threshold:o,animate:c})=>{const p=(Math.max(i,Math.min(a,n))-i)/(a-i),m=-135,h=135,u=h-m,x=m+p*u,f=60,b=60,g=45;let v="var(--nice-color-primary, #3b82f6)";if(o){const C=o.warning,w=o.critical;o.reverse?n<=w?v="var(--nice-color-error, #dc2626)":n<=C&&(v="var(--nice-color-warning, #f59e0b)"):n>=w?v="var(--nice-color-error, #dc2626)":n>=C&&(v="var(--nice-color-warning, #f59e0b)")}const y=r.useRef(m);return r.useEffect(()=>{y.current=x},[x]),e.jsxs("div",{className:"nice-gauge__item",role:"meter","aria-valuenow":n,"aria-valuemin":i,"aria-valuemax":a,"aria-label":t,children:[e.jsxs("svg",{viewBox:"0 0 120 100",width:"120",height:"100","aria-hidden":"true",children:[e.jsx("path",{d:Gc(f,b,g,m,h),fill:"none",stroke:"var(--nice-border, #e5e7eb)",strokeWidth:8,strokeLinecap:"round"}),e.jsx("path",{d:Gc(f,b,g,m,x),fill:"none",stroke:v,strokeWidth:8,strokeLinecap:"round",style:c?{transition:"stroke-dashoffset 0.5s ease"}:void 0}),e.jsx("text",{x:f,y:b+6,textAnchor:"middle",fontSize:18,fontWeight:700,fill:"currentColor",children:n}),e.jsx("text",{x:f,y:b+22,textAnchor:"middle",fontSize:10,fill:"var(--nice-text-secondary, #6b7280)",children:s})]}),e.jsx("p",{className:"nice-gauge__label",children:t})]})},B_={temperature:"°C",humidity:"%",co2:"ppm",pressure:"hPa",lux:"lx",noise:"dB",pm25:"µg/m³",voc:"ppb"},F_={temperature:[0,50],humidity:[0,100],co2:[300,2e3],pressure:[950,1050],lux:[0,1e4],noise:[20,100],pm25:[0,150],voc:[0,1e3]},q_=({sensors:t=L_,layout:n="grid",gaugeTypes:i,thresholds:a={},unit:s={},animate:o=!0,className:c,style:d,"data-testid":p})=>{const{t:m}=l.useNiceTranslation();return e.jsxs("div",{className:`nice-gauge-panel nice-gauge-panel--${n} ${c??""}`,style:d,"data-testid":p,children:[t.map(h=>{const u=h.type.toLowerCase(),x=s[u]??B_[u]??"",[f,b]=F_[u]??[0,100],g=a[u];return e.jsx(z_,{label:h.type,value:h.value,min:f,max:b,unit:x,threshold:g,animate:o},h.deviceId+h.type)}),t.length===0&&e.jsx("p",{className:"nice-gauge-panel__empty",role:"status",children:m("smartHome.noSensorData","No sensor data.")})]})},V_=[],U_=[{target:".nice-scene-action-builder",titleKey:"tutorial.sceneActionBuilder.intro.title",title:"Scene action builder",contentKey:"tutorial.sceneActionBuilder.intro.content",content:"Add an action per device, set its target state and an optional delay, reorder them, and preview the scene sequence.",placement:"auto"}];function H_(){return`action-${Date.now()}-${Math.random().toString(36).slice(2,7)}`}function G_(t){switch(t.category){case"light":return[{key:"on",labelKey:"smartHome.prop.state",label:"State",type:"boolean"},{key:"brightness",labelKey:"smartHome.prop.brightness",label:"Brightness (1-100)",type:"number"}];case"thermostat":return[{key:"setpoint",labelKey:"smartHome.prop.temperature",label:"Temperature (°C)",type:"number"},{key:"mode",labelKey:"smartHome.prop.mode",label:"Mode",type:"select",options:["heat","cool","auto","off"]}];case"lock":return[{key:"locked",labelKey:"smartHome.prop.locked",label:"Locked",type:"boolean"}];case"cover":return[{key:"position",labelKey:"smartHome.prop.position",label:"Open (0-100%)",type:"number"}];case"switch":return[{key:"on",labelKey:"smartHome.prop.state",label:"State",type:"boolean"}];case"climate":return[{key:"on",labelKey:"smartHome.prop.state",label:"State",type:"boolean"},{key:"speed",labelKey:"smartHome.prop.speed",label:"Speed (1-5)",type:"number"}];default:return[]}}function W_({action:t,devices:n,index:i,totalCount:a,onUpdate:s,onRemove:o,onMoveUp:c,onMoveDown:d}){const{t:p}=l.useNiceTranslation(),m=n.find(u=>u.id===t.deviceId),h=m?G_(m):[];return e.jsxs("div",{className:"nice-scene-action__card",draggable:!0,children:[e.jsxs("div",{className:"nice-scene-action__card-header",children:[e.jsx("span",{className:"nice-scene-action__order",children:i+1}),e.jsxs("select",{value:t.deviceId,onChange:u=>s({...t,deviceId:u.target.value,targetState:{}}),className:"nice-scene-action__device-select","aria-label":p("smartHome.device","Device"),children:[e.jsx("option",{value:"",children:p("smartHome.selectDevice","— select a device —")}),n.map(u=>e.jsxs("option",{value:u.id,children:[u.name," (",u.roomId??"—",")"]},u.id))]}),e.jsxs("div",{className:"nice-scene-action__card-btns",children:[e.jsx("button",{type:"button",onClick:c,disabled:i===0,"aria-label":p("smartHome.moveUp","Move up"),children:e.jsx(l.NiceIcon,{name:"arrow-up",size:14})}),e.jsx("button",{type:"button",onClick:d,disabled:i===a-1,"aria-label":p("smartHome.moveDown","Move down"),children:e.jsx(l.NiceIcon,{name:"arrow-down",size:14})}),e.jsx("button",{type:"button",onClick:o,"aria-label":p("smartHome.removeAction","Remove action"),className:"nice-scene-action__remove-btn",children:e.jsx(l.NiceIcon,{name:"close",size:14})})]})]}),m&&e.jsx("div",{className:"nice-scene-action__state-fields",children:h.map(u=>e.jsxs("label",{className:"nice-scene-action__field",children:[e.jsxs("span",{children:[p(u.labelKey,u.label),":"]}),u.type==="boolean"?e.jsx("input",{type:"checkbox",checked:!!t.targetState[u.key],onChange:x=>s({...t,targetState:{...t.targetState,[u.key]:x.target.checked}}),"aria-label":p(u.labelKey,u.label)}):u.type==="select"&&u.options?e.jsx("select",{value:t.targetState[u.key]??"",onChange:x=>s({...t,targetState:{...t.targetState,[u.key]:x.target.value}}),"aria-label":p(u.labelKey,u.label),children:u.options.map(x=>e.jsx("option",{value:x,children:x},x))}):e.jsx("input",{type:"number",value:t.targetState[u.key]??0,onChange:x=>s({...t,targetState:{...t.targetState,[u.key]:Number(x.target.value)}}),"aria-label":p(u.labelKey,u.label)})]},u.key))}),e.jsxs("label",{className:"nice-scene-action__delay",children:[e.jsxs("span",{children:[p("smartHome.delay","Delay"),":"]}),e.jsx("input",{type:"number",min:0,max:3600,value:t.delayMs?t.delayMs/1e3:0,onChange:u=>s({...t,delayMs:Number(u.target.value)*1e3}),"aria-label":p("smartHome.delaySeconds","Delay in seconds")}),e.jsx("span",{children:"s"})]})]})}const K_=({actions:t,defaultActions:n,onActionsChange:i,availableDevices:a=V_,showPreview:s=!0,maxActions:o=20,tutorial:c,className:d,style:p,"data-testid":m})=>{const{t:h}=l.useNiceTranslation(),[u,x]=l.useControllableState({value:t,defaultValue:n,fallbackValue:[],onChange:i,componentName:"NiceSceneActionBuilder"}),f=r.useCallback(()=>{u.length>=o||x([...u,{id:H_(),deviceId:"",targetState:{},delayMs:0}])},[u,x,o]),b=r.useCallback((C,w)=>{const E=[...u];E[C]=w,x(E)},[u,x]),g=r.useCallback(C=>{x(u.filter((w,E)=>E!==C))},[u,x]),v=r.useCallback(C=>{if(C===0)return;const w=[...u];[w[C-1],w[C]]=[w[C],w[C-1]],x(w)},[u,x]),y=r.useCallback(C=>{if(C===u.length-1)return;const w=[...u];[w[C],w[C+1]]=[w[C+1],w[C]],x(w)},[u,x]);return e.jsxs("div",{className:`nice-scene-action-builder ${d??""}`,style:{position:"relative",...p},"data-testid":m,children:[e.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:20},children:e.jsx(l.NiceTutorialButton,{steps:l.resolveTutorial(c,U_)})}),e.jsxs("div",{className:"nice-scene-action__list",role:"list",children:[u.length===0&&e.jsx("p",{className:"nice-scene-action__empty",role:"status",children:h("smartHome.noActions","No actions yet. Add the devices this scene should control.")}),u.map((C,w)=>e.jsx("div",{role:"listitem",children:e.jsx(W_,{action:C,devices:a,index:w,totalCount:u.length,onUpdate:E=>b(w,E),onRemove:()=>g(w),onMoveUp:()=>v(w),onMoveDown:()=>y(w)})},C.id))]}),e.jsxs("button",{type:"button",onClick:f,disabled:u.length>=o,className:"nice-scene-action__add-btn","aria-label":h("smartHome.addAction","Add action"),children:[e.jsx(l.NiceIcon,{name:"plus",size:14})," ",h("smartHome.addAction","Add action")]}),s&&u.length>0&&e.jsxs("div",{className:"nice-scene-action__preview","aria-live":"polite",children:[e.jsx("h4",{className:"nice-scene-action__preview-title",children:h("smartHome.sceneSummary","Scene summary:")}),e.jsx("ol",{className:"nice-scene-action__preview-list",children:u.filter(C=>C.deviceId).map((C,w)=>{const E=a.find(N=>N.id===C.deviceId);if(!E)return null;const S=Object.entries(C.targetState).map(([N,_])=>`${N}=${_}`).join(", ");return e.jsxs("li",{children:[w+1,". ",e.jsx("strong",{children:E.name})," ",e.jsx(l.NiceIcon,{name:"arrow-right",size:12})," ",S||h("smartHome.noStateChange","(no changes)"),C.delayMs?` ${h("smartHome.afterDelay","(after {seconds}s)").replace("{seconds}",String(C.delayMs/1e3))}`:""]},C.id)})})]})]})},Y_=[],J_=[{target:".nice-automation-editor",titleKey:"tutorial.automationRuleEditor.intro.title",title:"Automation rule editor",contentKey:"tutorial.automationRuleEditor.intro.content",content:"Define the trigger, add optional conditions, then list the actions to run — switch between the three sections using the tabs.",placement:"auto"}],Q_=[{value:"StateChange",key:"smartHome.trigger.stateChange",label:"Device state change"},{value:"Schedule",key:"smartHome.trigger.schedule",label:"Schedule (time)"},{value:"Sunrise",key:"smartHome.trigger.sunrise",label:"Sunrise"},{value:"Sunset",key:"smartHome.trigger.sunset",label:"Sunset"},{value:"Webhook",key:"smartHome.trigger.manual",label:"Manual trigger"}];function X_({trigger:t,devices:n,onChange:i}){const{t:a}=l.useNiceTranslation();return e.jsxs("div",{className:"nice-automation__section-body",children:[e.jsxs("label",{className:"nice-automation__field",children:[e.jsxs("span",{children:[a("smartHome.triggerType","Trigger type"),":"]}),e.jsx("select",{value:t.type,onChange:s=>i({...t,type:s.target.value,config:{}}),"aria-label":a("smartHome.triggerType","Trigger type"),children:Q_.map(s=>e.jsx("option",{value:s.value,children:a(s.key,s.label)},s.value))})]}),t.type==="StateChange"&&e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"nice-automation__field",children:[e.jsxs("span",{children:[a("smartHome.device","Device"),":"]}),e.jsxs("select",{value:t.config.deviceId??"",onChange:s=>i({...t,config:{...t.config,deviceId:s.target.value}}),"aria-label":a("smartHome.device","Device"),children:[e.jsx("option",{value:"",children:a("smartHome.selectPlaceholder","— select —")}),n.map(s=>e.jsx("option",{value:s.id,children:s.name},s.id))]})]}),e.jsxs("label",{className:"nice-automation__field",children:[e.jsxs("span",{children:[a("smartHome.propertyHint",'Property (e.g. "on", "temperature")'),":"]}),e.jsx("input",{type:"text",value:t.config.property??"",onChange:s=>i({...t,config:{...t.config,property:s.target.value}}),placeholder:"on","aria-label":a("smartHome.property","Property")})]}),e.jsxs("label",{className:"nice-automation__field",children:[e.jsxs("span",{children:[a("smartHome.newValue","New value"),":"]}),e.jsx("input",{type:"text",value:t.config.toValue??"",onChange:s=>i({...t,config:{...t.config,toValue:s.target.value}}),placeholder:"true","aria-label":a("smartHome.targetValue","Target value")})]})]}),t.type==="Schedule"&&e.jsxs("label",{className:"nice-automation__field",children:[e.jsxs("span",{children:[a("smartHome.cronExpression","Cron expression / time"),":"]}),e.jsx("input",{type:"text",value:t.config.cron??"",onChange:s=>i({...t,config:{...t.config,cron:s.target.value}}),placeholder:"0 7 * * *","aria-label":a("smartHome.schedule","Schedule")})]})]})}function Z_({condition:t,devices:n,index:i,total:a,onChange:s,onRemove:o,onMoveUp:c,onMoveDown:d}){const{t:p}=l.useNiceTranslation(),{t:m}=l.useNiceTranslation();return e.jsxs("div",{className:"nice-automation__condition-row",children:[i>0&&e.jsxs("select",{value:t.operator??"AND",onChange:h=>s({...t,operator:h.target.value}),className:"nice-automation__conjunction","aria-label":m("smartHome.logicalOperator","Logical operator"),children:[e.jsx("option",{value:"AND",children:p("automationRuleEditor.and","AND")}),e.jsx("option",{value:"OR",children:p("automationRuleEditor.or","OR")})]}),e.jsxs("select",{value:t.config.deviceId??"",onChange:h=>s({...t,config:{...t.config,deviceId:h.target.value}}),"aria-label":m("smartHome.device","Device"),children:[e.jsx("option",{value:"",children:m("smartHome.devicePlaceholder","— device —")}),n.map(h=>e.jsx("option",{value:h.id,children:h.name},h.id))]}),e.jsx("input",{type:"text",value:t.config.property??"",onChange:h=>s({...t,config:{...t.config,property:h.target.value}}),placeholder:m("smartHome.property","Property"),"aria-label":m("smartHome.property","Property")}),e.jsxs("select",{value:t.config.compOp??"eq",onChange:h=>s({...t,config:{...t.config,compOp:h.target.value}}),"aria-label":p("automationRuleEditor.operator","Operator"),children:[e.jsx("option",{value:"eq",children:"="}),e.jsx("option",{value:"neq",children:"≠"}),e.jsx("option",{value:"gt",children:">"}),e.jsx("option",{value:"lt",children:"<"}),e.jsx("option",{value:"gte",children:"≥"}),e.jsx("option",{value:"lte",children:"≤"})]}),e.jsx("input",{type:"text",value:String(t.config.value??""),onChange:h=>s({...t,config:{...t.config,value:h.target.value}}),placeholder:m("smartHome.value","Value"),"aria-label":m("smartHome.value","Value")}),e.jsxs("div",{className:"nice-automation__row-btns",children:[e.jsx("button",{type:"button",onClick:c,disabled:i===0,"aria-label":m("smartHome.moveUp","Move up"),children:e.jsx(l.NiceIcon,{name:"arrow-up",size:14})}),e.jsx("button",{type:"button",onClick:d,disabled:i===a-1,"aria-label":m("smartHome.moveDown","Move down"),children:e.jsx(l.NiceIcon,{name:"arrow-down",size:14})}),e.jsx("button",{type:"button",onClick:o,"aria-label":m("smartHome.removeCondition","Remove condition"),className:"nice-automation__remove",children:e.jsx(l.NiceIcon,{name:"close",size:14})})]})]})}function ej({action:t,devices:n,scenes:i,index:a,total:s,onChange:o,onRemove:c,onMoveUp:d,onMoveDown:p}){const{t:m}=l.useNiceTranslation(),{t:h}=l.useNiceTranslation();return e.jsxs("div",{className:"nice-automation__action-row",children:[e.jsxs("select",{value:t.type,onChange:u=>o({...t,type:u.target.value,config:{}}),"aria-label":h("smartHome.actionType","Action type"),children:[e.jsx("option",{value:"device",children:h("smartHome.action.setDeviceState","Set device state")}),e.jsx("option",{value:"scene",children:h("smartHome.activateScene","Activate scene")}),e.jsx("option",{value:"notify",children:h("smartHome.action.notify","Send notification")}),e.jsx("option",{value:"delay",children:h("smartHome.delay","Delay")})]}),t.type==="device"&&e.jsxs(e.Fragment,{children:[e.jsxs("select",{value:t.config.deviceId??"",onChange:u=>o({...t,config:{...t.config,deviceId:u.target.value}}),"aria-label":h("smartHome.device","Device"),children:[e.jsx("option",{value:"",children:h("smartHome.devicePlaceholder","— device —")}),n.map(u=>e.jsx("option",{value:u.id,children:u.name},u.id))]}),e.jsx("input",{type:"text",value:t.config.property??"",onChange:u=>o({...t,config:{...t.config,property:u.target.value}}),placeholder:h("smartHome.property","Property"),"aria-label":h("smartHome.property","Property")}),e.jsx("input",{type:"text",value:t.config.value??"",onChange:u=>o({...t,config:{...t.config,value:u.target.value}}),placeholder:h("smartHome.value","Value"),"aria-label":h("smartHome.value","Value")})]}),t.type==="scene"&&e.jsxs("select",{value:t.config.sceneId??"",onChange:u=>o({...t,config:{sceneId:u.target.value}}),"aria-label":h("smartHome.scene","Scene"),children:[e.jsx("option",{value:"",children:m("automationRuleEditor.scene","-- scene --")}),i.map(u=>e.jsx("option",{value:u.id,children:u.name},u.id))]}),t.type==="notify"&&e.jsx("input",{type:"text",value:t.config.message??"",onChange:u=>o({...t,config:{message:u.target.value}}),placeholder:h("smartHome.notificationText","Notification text"),"aria-label":h("smartHome.notificationText","Notification text")}),t.type==="delay"&&e.jsxs("label",{children:[e.jsx("span",{children:m("automationRuleEditor.seconds","Seconds:")}),e.jsx("input",{type:"number",min:1,max:3600,value:t.config.seconds??1,onChange:u=>o({...t,config:{seconds:Number(u.target.value)}}),"aria-label":h("smartHome.delaySeconds","Delay in seconds")})]}),e.jsxs("div",{className:"nice-automation__row-btns",children:[e.jsx("button",{type:"button",onClick:d,disabled:a===0,"aria-label":h("smartHome.moveUp","Move up"),children:e.jsx(l.NiceIcon,{name:"arrow-up",size:14})}),e.jsx("button",{type:"button",onClick:p,disabled:a===s-1,"aria-label":h("smartHome.moveDown","Move down"),children:e.jsx(l.NiceIcon,{name:"arrow-down",size:14})}),e.jsx("button",{type:"button",onClick:c,"aria-label":h("smartHome.removeAction","Remove action"),className:"nice-automation__remove",children:e.jsx(l.NiceIcon,{name:"close",size:14})})]})]})}const tj=({rule:t,onChange:n,availableDevices:i=Y_,availableScenes:a=[],tutorial:s,className:o,style:c,"data-testid":d})=>{const p=r.useRef(null);l.useRovingFocus(p,{orientation:"horizontal",wrap:!0,activateOnMove:!0});const{t:m}=l.useNiceTranslation(),{t:h}=l.useNiceTranslation(),[u,x]=r.useState("trigger"),f=r.useCallback(w=>n({...t,trigger:w}),[t,n]),b=r.useCallback(w=>n({...t,conditions:w}),[t,n]),g=r.useCallback(w=>n({...t,actions:w}),[t,n]),v=()=>b([...t.conditions??[],{operator:"AND",type:"device",config:{deviceId:"",property:"",compOp:"eq",value:""}}]),y=()=>g([...t.actions??[],{type:"device",config:{}}]),C=[{id:"trigger",label:h("smartHome.trigger","Trigger"),icon:"zap",badge:void 0},{id:"conditions",label:h("smartHome.conditions","Conditions"),icon:"search",badge:t.conditions?.length},{id:"actions",label:h("smartHome.actions","Actions"),icon:"play",badge:t.actions?.length}];return e.jsxs("div",{className:`nice-automation-editor ${o??""}`,style:{position:"relative",...c},"data-testid":d,children:[e.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:20},children:e.jsx(l.NiceTutorialButton,{steps:l.resolveTutorial(s,J_)})}),e.jsxs("div",{className:"nice-automation__header",children:[e.jsx("input",{type:"text",value:t.name,onChange:w=>n({...t,name:w.target.value}),className:"nice-automation__name-input",placeholder:h("smartHome.ruleNamePlaceholder","Automation rule name"),"aria-label":h("smartHome.ruleName","Rule name")}),e.jsxs("label",{className:"nice-automation__enable",children:[e.jsx("input",{type:"checkbox",checked:t.enabled,onChange:w=>n({...t,enabled:w.target.checked}),"aria-label":h("smartHome.enableRule","Enable rule")}),e.jsx("span",{children:m("automationRuleEditor.active","Active")})]})]}),e.jsx("div",{className:"nice-automation__section-tabs",ref:p,role:"tablist",children:C.map(w=>e.jsxs("button",{type:"button",role:"tab","aria-selected":u===w.id,className:`nice-automation__section-tab${u===w.id?" nice-automation__section-tab--active":""}`,onClick:()=>x(w.id),children:[e.jsx(l.NiceIcon,{name:w.icon,size:14})," ",w.label,w.badge?e.jsx("span",{className:"nice-automation__badge",children:w.badge}):null]},w.id))}),e.jsxs("div",{className:"nice-automation__section-content",role:"tabpanel",children:[u==="trigger"&&e.jsx(X_,{trigger:t.trigger,devices:i,onChange:f}),u==="conditions"&&e.jsxs("div",{className:"nice-automation__section-body",children:[(t.conditions??[]).length===0&&e.jsx("p",{className:"nice-automation__empty",children:h("smartHome.noConditions","No conditions — the rule always runs its actions when triggered.")}),(t.conditions??[]).map((w,E)=>e.jsx(Z_,{condition:w,devices:i,index:E,total:(t.conditions??[]).length,onChange:S=>{const N=[...t.conditions??[]];N[E]=S,b(N)},onRemove:()=>b((t.conditions??[]).filter((S,N)=>N!==E)),onMoveUp:()=>{const S=[...t.conditions??[]];[S[E-1],S[E]]=[S[E],S[E-1]],b(S)},onMoveDown:()=>{const S=[...t.conditions??[]];[S[E],S[E+1]]=[S[E+1],S[E]],b(S)}},E)),e.jsxs("button",{type:"button",onClick:v,className:"nice-automation__add-btn",children:[e.jsx(l.NiceIcon,{name:"plus",size:14})," ",h("smartHome.addCondition","Add condition")]})]}),u==="actions"&&e.jsxs("div",{className:"nice-automation__section-body",children:[(t.actions??[]).length===0&&e.jsx("p",{className:"nice-automation__empty",children:h("smartHome.noActionsShort","No actions.")}),(t.actions??[]).map((w,E)=>e.jsx(ej,{action:w,devices:i,scenes:a,index:E,total:(t.actions??[]).length,onChange:S=>{const N=[...t.actions??[]];N[E]=S,g(N)},onRemove:()=>g((t.actions??[]).filter((S,N)=>N!==E)),onMoveUp:()=>{const S=[...t.actions??[]];[S[E-1],S[E]]=[S[E],S[E-1]],g(S)},onMoveDown:()=>{const S=[...t.actions??[]];[S[E],S[E+1]]=[S[E+1],S[E]],g(S)}},E)),e.jsxs("button",{type:"button",onClick:y,className:"nice-automation__add-btn",children:[e.jsx(l.NiceIcon,{name:"plus",size:14})," ",h("smartHome.addAction","Add action")]})]})]})]})},nj=[];function ij(t,n){const i=typeof t=="string"?new Date(t):t;switch(n){case"hour":return`${i.getHours().toString().padStart(2,"0")}:00`;case"day":return i.toLocaleDateString("pl-PL",{day:"2-digit",month:"short"});case"week":return`tyg. ${Math.ceil(i.getDate()/7)}`;case"month":return i.toLocaleDateString("pl-PL",{month:"short"})}}function aj(t,n){const i=new Map;for(const a of t){const s=new Date(a.timestamp);let o;switch(n){case"hour":o=`${s.getFullYear()}-${s.getMonth()}-${s.getDate()}-${s.getHours()}`;break;case"day":o=`${s.getFullYear()}-${s.getMonth()}-${s.getDate()}`;break;case"week":o=`${s.getFullYear()}-W${Math.ceil(s.getDate()/7)}`;break;case"month":o=`${s.getFullYear()}-${s.getMonth()}`;break}i.set(o,(i.get(o)??0)+a.value)}return Array.from(i.entries()).sort(([a],[s])=>a.localeCompare(s)).map(([a,s])=>({bucketKey:a,label:ij(t.find(o=>{const c=new Date(o.timestamp);switch(n){case"hour":return`${c.getFullYear()}-${c.getMonth()}-${c.getDate()}-${c.getHours()}`===a;case"day":return`${c.getFullYear()}-${c.getMonth()}-${c.getDate()}`===a;case"week":return`${c.getFullYear()}-W${Math.ceil(c.getDate()/7)}`===a;case"month":return`${c.getFullYear()}-${c.getMonth()}`===a}})?.timestamp??new Date,n),value:Math.round(s*100)/100}))}const Wc=["var(--nice-accent, #6c5ce7)","var(--nice-color-success, #00b894)","var(--nice-warning, #f39c12)","var(--nice-color-accent-pink, #e84393)","var(--nice-info, #00cec9)","var(--nice-warning, #e17055)","var(--nice-primary, #0984e3)","var(--nice-accent, #6c5ce7)"],sj=({data:t=nj,period:n="week",groupBy:i="day",breakdown:a=!1,chartType:s="bar",showTrend:o=!1,unit:c="kWh",onDrillDown:d,className:p,style:m,"data-testid":h})=>{const{t:u}=l.useNiceTranslation(),x=r.useMemo(()=>aj(t,i),[t,i]),f=r.useMemo(()=>Math.max(...x.map(R=>R.value),1),[x]),b=r.useMemo(()=>x.reduce((R,I)=>R+I.value,0),[x]),g=b/(x.length||1),v=r.useMemo(()=>a?Array.from(new Set(t.map(R=>R.groupKey).filter(Boolean))):[],[t,a]),y=380,C=140,w=40,E=8,S=12,N=24,_=y-w-E,k=C-S-N,j=x.length,T=j>0?_/j*.7:0,P=j>0?_/j:0,B=r.useMemo(()=>{if(!o||x.length<2)return"";const R=x.map((U,re)=>re),I=x.map(U=>U.value),D=R.length,M=R.reduce((U,re)=>U+re,0),O=I.reduce((U,re)=>U+re,0),L=R.reduce((U,re,Y)=>U+re*I[Y],0),V=R.reduce((U,re)=>U+re*re,0),ee=(D*L-M*O)/(D*V-M*M),z=(O-ee*M)/D;return`${w+P*.15},${S+k-z/f*k} ${w+P*(D-.5)},${S+k-(ee*(D-1)+z)/f*k}`},[o,x,f,w,S,k,P]);return t.length===0?e.jsx("div",{className:`nice-energy-chart ${p??""}`,style:m,"data-testid":h,role:"status",children:e.jsx("p",{className:"nice-energy-chart__empty",children:u("smartHome.noEnergyData","No energy usage data.")})}):e.jsxs("div",{className:`nice-energy-chart nice-energy-chart--${s} ${p??""}`,style:m,"data-testid":h,children:[e.jsxs("div",{className:"nice-energy-chart__stats","aria-label":u("smartHome.statistics","Statistics"),children:[e.jsxs("div",{className:"nice-energy-chart__stat",children:[e.jsx("span",{className:"nice-energy-chart__stat-label",children:u("smartHome.total","Total")}),e.jsxs("strong",{className:"nice-energy-chart__stat-value",children:[b.toFixed(2)," ",c]})]}),e.jsxs("div",{className:"nice-energy-chart__stat",children:[e.jsx("span",{className:"nice-energy-chart__stat-label",children:u("smartHome.average","Average")}),e.jsxs("strong",{className:"nice-energy-chart__stat-value",children:[g.toFixed(2)," ",c]})]}),e.jsxs("div",{className:"nice-energy-chart__stat",children:[e.jsx("span",{className:"nice-energy-chart__stat-label",children:u("smartHome.max","Max.")}),e.jsxs("strong",{className:"nice-energy-chart__stat-value",children:[f.toFixed(2)," ",c]})]})]}),e.jsxs("svg",{viewBox:`0 0 ${y} ${C}`,className:"nice-energy-chart__svg",role:"img","aria-label":`${u("smartHome.energyChart","Energy usage chart")} — ${n}`,children:[[0,.25,.5,.75,1].map(R=>e.jsxs("g",{children:[e.jsx("line",{x1:w,x2:y-E,y1:S+k*(1-R),y2:S+k*(1-R),stroke:"var(--nice-border-color,#e5e7eb)",strokeWidth:.5}),e.jsx("text",{x:w-4,y:S+k*(1-R)+3,textAnchor:"end",fontSize:8,fill:"var(--nice-text-muted,#9ca3af)",children:(f*R).toFixed(1)})]},R)),x.map((R,I)=>{const D=R.value/f*k,M=w+P*I+(P-T)/2,O=S+k-D;return e.jsxs("g",{className:"nice-energy-chart__bar-group",onClick:()=>d?.(R.bucketKey),style:{cursor:d?"pointer":"default"},children:[e.jsx("rect",{x:M,y:O,width:T,height:D,fill:"var(--nice-accent, #6c5ce7)",rx:2,opacity:.85,children:e.jsxs("title",{children:[R.label,": ",R.value," ",c]})}),j<=12&&e.jsx("text",{x:M+T/2,y:C-N+10,textAnchor:"middle",fontSize:8,fill:"var(--nice-text-muted,#9ca3af)",children:R.label})]},R.bucketKey)}),s==="area"&&x.length>1&&e.jsx("path",{d:`M ${w+P*.15} ${S+k} `+x.map((R,I)=>`L ${w+P*I+P/2} ${S+k-R.value/f*k}`).join(" ")+` L ${w+P*(j-.15)} ${S+k} Z`,fill:"var(--nice-accent, #6c5ce7)",fillOpacity:.15,stroke:"none"}),(s==="line"||s==="area")&&x.length>1&&e.jsx("polyline",{points:x.map((R,I)=>`${w+P*I+P/2},${S+k-R.value/f*k}`).join(" "),fill:"none",stroke:"var(--nice-accent, #6c5ce7)",strokeWidth:2,strokeLinejoin:"round"}),o&&B&&e.jsx("line",{x1:B.split(" ")[0].split(",")[0],y1:B.split(" ")[0].split(",")[1],x2:B.split(" ")[1].split(",")[0],y2:B.split(" ")[1].split(",")[1],stroke:"var(--nice-warning, #f39c12)",strokeWidth:1.5,strokeDasharray:"4 2"})]}),a&&v.length>0&&e.jsx("div",{className:"nice-energy-chart__legend","aria-label":u("smartHome.deviceLegend","Device legend"),children:v.map((R,I)=>e.jsxs("span",{className:"nice-energy-chart__legend-item",children:[e.jsx("span",{className:"nice-energy-chart__legend-dot",style:{background:Wc[I%Wc.length]}}),R]},R))})]})},rj=[];function Ws(t,n,i){return i?.find(a=>a.deviceId===t&&a.type.toLowerCase()===n)}function oj({occupied:t}){const{t:n}=l.useNiceTranslation();return t===void 0?null:e.jsx("span",{className:`nice-room-card__occupancy${t?" nice-room-card__occupancy--yes":" nice-room-card__occupancy--no"}`,"aria-label":t?n("smartHome.occupied","Occupied"):n("smartHome.vacant","Vacant"),title:t?n("smartHome.roomOccupied","Room occupied"):n("smartHome.roomVacant","Room vacant"),children:t?e.jsxs(e.Fragment,{children:[e.jsx(l.NiceIcon,{name:"user",size:14})," ",n("smartHome.occupied","Occupied")]}):e.jsxs(e.Fragment,{children:[e.jsx(l.NiceIcon,{name:"minus",size:14})," ",n("smartHome.vacant","Vacant")]})})}function Ks({icon:t,value:n,unit:i,limit:a,reverse:s}){if(n===void 0)return null;let o="var(--nice-text-primary)";return a!==void 0&&(o=(s?n<a:n>a)?"var(--nice-color-error, #ef4444)":"var(--nice-color-success, #22c55e)"),e.jsxs("span",{className:"nice-room-card__sensor",style:{color:o},"aria-label":`${n}${i}`,children:[e.jsx(l.NiceIcon,{name:t,size:14})," ",e.jsx("strong",{children:n.toFixed(1)}),i]})}function cj({room:t,layout:n,showSensors:i,showDeviceCount:a,showOccupancy:s,sensorReadings:o,onClick:c}){const{t:d}=l.useNiceTranslation(),p=Ws(t.id,"temperature",o),m=Ws(t.id,"humidity",o),h=Ws(t.id,"co2",o);return e.jsxs("button",{type:"button",className:`nice-room-card nice-room-card--${n}`,onClick:()=>c(t.id),"aria-label":d("roomGrid.room","Room: {name}").replace("{name}",String(t.name)),children:[e.jsxs("div",{className:"nice-room-card__header",children:[e.jsx("span",{className:"nice-room-card__icon","aria-hidden":"true",children:e.jsx(l.NiceIcon,{name:"home",size:18})}),e.jsx("span",{className:"nice-room-card__name",children:t.name}),t.floor!==void 0&&e.jsxs("span",{className:"nice-room-card__floor",children:["P",t.floor]})]}),s&&e.jsx(oj,{occupied:t.occupancy}),i&&e.jsxs("div",{className:"nice-room-card__sensors",children:[e.jsx(Ks,{icon:"bar-chart",value:p?.value,unit:"°C",limit:28}),e.jsx(Ks,{icon:"cloud",value:m?.value,unit:"%",limit:30,reverse:!0}),e.jsx(Ks,{icon:"globe",value:h?.value,unit:" ppm",limit:1e3})]}),a&&t.deviceIds&&e.jsx("div",{className:"nice-room-card__devices",children:e.jsxs("span",{children:[e.jsx(l.NiceIcon,{name:"plug",size:14})," ",t.deviceIds.length," ",d("smartHome.devices","devices")]})})]})}const lj=({rooms:t=rj,onClick:n,layout:i="grid",showSensors:a=!0,showDeviceCount:s=!0,showOccupancy:o=!0,groupByFloor:c=!1,sensorReadings:d=[],className:p,style:m,"data-testid":h})=>{const{t:u}=l.useNiceTranslation(),x=r.useMemo(()=>{if(!c)return[{floor:null,rooms:t}];const f=new Map;for(const b of t){const g=b.floor??0;f.has(g)||f.set(g,[]),f.get(g).push(b)}return Array.from(f.entries()).sort(([b],[g])=>b-g).map(([b,g])=>({floor:b,rooms:g}))},[t,c]);return t.length===0?e.jsx("div",{className:`nice-room-grid ${p??""}`,style:m,"data-testid":h,role:"status",children:e.jsx("p",{className:"nice-room-grid__empty",children:u("smartHome.noRooms","No rooms.")})}):e.jsx("div",{className:`nice-room-grid nice-room-grid--${i} ${p??""}`,style:m,"data-testid":h,role:"list",children:x.map(f=>e.jsxs("div",{className:"nice-room-grid__group",children:[c&&f.floor!==null&&e.jsx("h3",{className:"nice-room-grid__floor-heading",children:f.floor===0?u("smartHome.groundFloor","Ground floor"):`${u("smartHome.floor","Floor")} ${f.floor}`}),e.jsx("div",{className:`nice-room-grid__cards nice-room-grid__cards--${i}`,role:"list",children:f.rooms.map(b=>e.jsx("div",{role:"listitem",children:e.jsx(cj,{room:b,layout:i,showSensors:a,showDeviceCount:s,showOccupancy:o,sensorReadings:d,onClick:n})},b.id))})]},f.floor??"all"))})},dj=[];function uj(t,n,i){if(!i)return"";const a=typeof i=="string"?new Date(i):i,s=Date.now()-a.getTime();return s<6e4?t("smartHome.justNow","just now"):s<36e5?`${Math.floor(s/6e4)} ${t("smartHome.minutesAgo","min ago")}`:s<864e5?`${Math.floor(s/36e5)}${t("smartHome.hoursAgo","h ago")}`:a.toLocaleDateString(n)}const pj=({scenes:t=dj,onActivate:n,confirm:i=!1,compact:a=!1,showLastActivated:s=!0,className:o,style:c,"data-testid":d})=>{const{t:p,lang:m}=l.useNiceTranslation(),[h,u]=r.useState(null),[x,f]=r.useState(null),[b,g]=r.useState(null),v=r.useRef(void 0),y=r.useRef(null),C=r.useRef(null);l.useRovingFocus(y,{orientation:"horizontal",itemSelector:".nice-scene-bar__btn"}),l.useOverlayFocus(C,{open:x!=null,onClose:()=>f(null),closeHint:p("smartHome.cancel","Cancel")});const w=N=>{if(i){f(N);return}E(N)},E=N=>{f(null),u(N),g(N),n(N),clearTimeout(v.current),v.current=setTimeout(()=>u(null),1200)},S=t.filter(N=>N.isQuickAccess!==!1);return e.jsxs("div",{ref:y,className:`nice-scene-bar${a?" nice-scene-bar--compact":""} ${o??""}`,style:c,"data-testid":d,role:"toolbar","aria-label":p("smartHome.sceneBar","Scene bar"),children:[S.length===0&&e.jsx("p",{className:"nice-scene-bar__empty",children:p("smartHome.noQuickScenes","No quick-access scenes.")}),S.map(N=>{const _=h===N.id,k=b===N.id;return e.jsxs("div",{className:"nice-scene-bar__item",children:[e.jsxs("button",{type:"button",className:`nice-scene-bar__btn${_?" nice-scene-bar__btn--activating":""}${k?" nice-scene-bar__btn--last":""}`,style:{"--scene-color":N.color??"var(--nice-accent, #6c5ce7)"},onClick:()=>w(N.id),"aria-label":`${p("smartHome.activateScene","Activate scene")}: ${N.name}`,"aria-pressed":_,children:[N.icon&&e.jsx("span",{className:"nice-scene-bar__icon","aria-hidden":"true",children:e.jsx(l.NiceIcon,{name:N.icon,size:a?16:22})}),!a&&e.jsx("span",{className:"nice-scene-bar__name",children:N.name}),_&&e.jsx("span",{className:"nice-scene-bar__pulse","aria-hidden":"true"})]}),s&&!a&&N.lastActivatedAt&&e.jsx("span",{className:"nice-scene-bar__last-activated",children:uj(p,m,N.lastActivatedAt)})]},N.id)}),x&&(()=>{const N=t.find(_=>_.id===x);return N?e.jsxs("div",{ref:C,className:"nice-scene-bar__confirm",role:"dialog","aria-modal":"true","aria-label":`${p("smartHome.confirmActivation","Confirm scene activation")}: ${N.name}`,children:[e.jsxs("p",{children:[p("smartHome.activateQuestion","Activate scene")," ",e.jsx("strong",{children:N.name}),"?"]}),e.jsxs("div",{className:"nice-scene-bar__confirm-btns",children:[e.jsx("button",{type:"button",className:"nice-scene-bar__confirm-yes",onClick:()=>E(x),children:p("smartHome.confirmActivate","Yes, activate")}),e.jsx("button",{type:"button",className:"nice-scene-bar__confirm-no",onClick:()=>f(null),children:p("smartHome.cancel","Cancel")})]})]}):null})()]})};function mj({url:t,timeout:n=15e3,slowThreshold:i=3e3,onTimeout:a,retryOnTimeout:s=!1,toastOnTimeout:o=!0,fetcher:c}){const[d,p]=r.useState(null),[m,h]=r.useState(!1),[u,x]=r.useState(null),[f,b]=r.useState(!1),[g,v]=r.useState(!1),y=r.useRef(null),C=r.useRef(null),w=r.useRef(null),E=r.useCallback(async()=>{C.current&&clearTimeout(C.current),w.current&&clearTimeout(w.current),y.current?.abort(),y.current=new AbortController,h(!0),b(!1),v(!1),x(null),C.current=setTimeout(()=>b(!0),i),w.current=setTimeout(()=>{y.current?.abort(),v(!0),h(!1),b(!1),a?.(t)},n);try{let S;if(c)S=await c(t);else{const N=await fetch(t,{signal:y.current.signal});if(!N.ok)throw new Error(`HTTP ${N.status}`);S=await N.json()}clearTimeout(C.current),clearTimeout(w.current),p(S)}catch(S){S.name!=="AbortError"&&x(S)}finally{h(!1),b(!1)}},[t,n,i,a,o,c]);return r.useEffect(()=>(E(),()=>{y.current?.abort(),C.current&&clearTimeout(C.current),w.current&&clearTimeout(w.current)}),[E]),{data:d,loading:m,error:u,isSlow:f,isTimedOut:g,refetch:E}}const hj=[],gj=({locales:t=hj,translations:n,defaultTranslations:i,onTranslationChange:a,onTranslationsChange:s,onLocaleAdd:o,onLocaleRemove:c,onExport:d,onImport:p,referenceLocale:m="en",showCompletionBadge:h=!0,filterUntranslated:u=!1,className:x,style:f,"data-testid":b})=>{const g=r.useRef(null);l.useRovingFocus(g,{orientation:"horizontal",wrap:!0,activateOnMove:!0});const{t:v}=l.useNiceTranslation(),[y,C]=r.useState("grid"),[w,E]=r.useState(null),[S,N]=r.useState(""),[_,k]=l.useControllableState({value:n,defaultValue:i,fallbackValue:{},onChange:s,componentName:"NiceLocaleManager"}),j=_[m]??{},P=Object.keys(j).filter(R=>u&&w&&_[w]?.[R]?!1:S?R.toLowerCase().includes(S.toLowerCase()):!0),B=R=>{const I=R.target.files?.[0];I&&w&&p(w,I)};return e.jsxs("div",{className:`nice-locale-manager ${x??""}`,style:f,"data-testid":b,children:[e.jsx("div",{className:"nice-locale-manager__tabs",ref:g,role:"tablist",children:["grid","editor","import-export"].map(R=>e.jsx("button",{role:"tab","aria-selected":y===R,className:`nice-locale-manager__tab${y===R?" nice-locale-manager__tab--active":""}`,onClick:()=>C(R),type:"button",children:R==="grid"?v("localeManager.languages","Languages"):R==="editor"?v("localeManager.translations","Translations"):v("localeManager.importExport","Import / Export")},R))}),y==="grid"&&e.jsx("div",{className:"nice-locale-manager__locale-grid",role:"tabpanel",children:t.map(R=>e.jsxs("div",{className:"nice-locale-manager__locale-card",children:[R.flag&&e.jsx("span",{className:"nice-locale-manager__flag",children:R.flag}),e.jsx("span",{className:"nice-locale-manager__locale-name",children:R.name}),e.jsx("span",{className:"nice-locale-manager__locale-native",children:R.nativeName}),h&&R.completionPercent!==void 0&&e.jsxs("span",{className:"nice-locale-manager__completion",children:[R.completionPercent,"%"]}),e.jsx("button",{onClick:()=>{E(R.code),C("editor")},type:"button",children:v("localeManager.edit","Edit")}),e.jsx("button",{onClick:()=>d(R.code,"json"),type:"button",children:v("localeManager.exportJson","Export JSON")}),e.jsx("button",{onClick:()=>c(R.code),type:"button","aria-label":`${v("localeManager.remove","Remove")} ${R.name}`,children:v("localeManager.remove","Remove")})]},R.code))}),y==="editor"&&e.jsxs("div",{className:"nice-locale-manager__editor",role:"tabpanel",children:[e.jsxs("div",{className:"nice-locale-manager__editor-toolbar",children:[e.jsxs("select",{value:w??"",onChange:R=>E(R.target.value),"aria-label":v("localeManager.selectLanguage","Select a language"),children:[e.jsxs("option",{value:"",children:["— ",v("localeManager.selectLanguage","Select a language")," —"]}),t.map(R=>e.jsx("option",{value:R.code,children:R.name},R.code))]}),e.jsx("input",{type:"search",placeholder:v("localeManager.searchKey","Search keys…"),value:S,onChange:R=>N(R.target.value),"aria-label":v("localeManager.searchKeyLabel","Search translation keys")})]}),e.jsxs("table",{className:"nice-locale-manager__table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:v("localeManager.key","Key")}),e.jsxs("th",{children:[m," (",v("localeManager.reference","reference"),")"]}),e.jsx("th",{children:w??"—"})]})}),e.jsx("tbody",{children:P.map(R=>e.jsxs("tr",{className:_[w??""]?.[R]?"":"nice-locale-manager__row--missing",children:[e.jsx("td",{children:e.jsx("code",{children:R})}),e.jsx("td",{children:j[R]}),e.jsx("td",{children:w?e.jsx("input",{type:"text",value:_[w]?.[R]??"",onChange:I=>{const D=I.target.value;a?.(w,R,D),k({..._,[w]:{..._[w],[R]:D}})},"aria-label":v("localeManager.translationOfKey","Translation of key {key}").replace("{key}",R)}):"—"})]},R))})]})]}),y==="import-export"&&e.jsxs("div",{className:"nice-locale-manager__io",role:"tabpanel",children:[e.jsxs("div",{className:"nice-locale-manager__io-row",children:[e.jsxs("label",{htmlFor:"nice-locale-import-file",children:[v("localeManager.importFile","Import a translation file"),":"]}),e.jsxs("select",{value:w??"",onChange:R=>E(R.target.value),"aria-label":v("localeManager.importLanguage","Language to import"),children:[e.jsxs("option",{value:"",children:["— ",v("localeManager.selectLanguage","Select a language")," —"]}),t.map(R=>e.jsx("option",{value:R.code,children:R.name},R.code))]}),e.jsx("input",{id:"nice-locale-import-file",type:"file",accept:".json,.csv,.xliff,.xlf",onChange:B})]}),e.jsxs("div",{className:"nice-locale-manager__io-row",children:[e.jsxs("span",{children:[v("localeManager.export","Export"),":"]}),t.map(R=>e.jsxs("span",{children:[e.jsx("button",{onClick:()=>d(R.code,"json"),type:"button",children:v("localeManager.json","{name} JSON").replace("{name}",String(R.name))}),e.jsxs("button",{onClick:()=>d(R.code,"csv"),type:"button",children:[R.name," CSV"]}),e.jsx("button",{onClick:()=>d(R.code,"xliff"),type:"button",children:v("localeManager.xliff","{name} XLIFF").replace("{name}",String(R.name))})]},R.code))]})]})]})};function bj(t,n){const i=[];t.elements.filter(o=>o.elementType==="event"&&o.eventType==="startEvent").length===0&&i.push({type:"error",message:n("workflowDesigner.val.bpmnNoStart","Process must have at least one start event")}),t.elements.filter(o=>o.elementType==="event"&&o.eventType==="endEvent").length===0&&i.push({type:"error",message:n("workflowDesigner.val.bpmnNoEnd","Process must have at least one end event")});for(const o of t.elements){const c=o.id,d=t.sequenceFlows.some(m=>m.targetRef===c),p=t.sequenceFlows.some(m=>m.sourceRef===c);o.elementType==="event"?(o.eventType==="startEvent"&&!p&&i.push({type:"warning",message:n("workflowDesigner.val.startNoOut",'Start event "{name}" has no outgoing flow').replace("{name}",o.name),elementId:c}),o.eventType==="endEvent"&&!d&&i.push({type:"warning",message:n("workflowDesigner.val.endNoIn",'End event "{name}" has no incoming flow').replace("{name}",o.name),elementId:c})):(o.elementType==="task"||o.elementType==="gateway")&&(d||i.push({type:"warning",message:n("workflowDesigner.val.unreachable",'Element "{name}" is unreachable').replace("{name}",o.name||c),elementId:c}),p||i.push({type:"warning",message:n("workflowDesigner.val.elemNoOut",'Element "{name}" has no outgoing flow').replace("{name}",o.name||c),elementId:c}))}for(const o of t.elements)if(o.elementType==="gateway"&&o.gatewayType==="exclusiveGateway"){const c=t.sequenceFlows.filter(p=>p.sourceRef===o.id),d=c.filter(p=>p.conditionExpression||p.isDefault);c.length>1&&d.length<c.length-1&&i.push({type:"warning",message:n("workflowDesigner.val.xorNoConditions",'Exclusive gateway "{name}" should have conditions on its flows').replace("{name}",o.name||o.id),elementId:o.id})}return i}const fj={none:"circle",message:"mail",timer:"clock",error:"zap",escalation:"target",cancel:"close",compensation:"refresh",signal:"target",terminate:"circle",link:"arrow-right"},vj={task:"check-square",userTask:"user",serviceTask:"settings",scriptTask:"file",businessRuleTask:"clipboard",sendTask:"upload",receiveTask:"download",manualTask:"cursor",callActivity:"arrow-right"},xj={events:"circle",tasks:"square",gateways:"diamond",subprocesses:"layers",artifacts:"file"},Kc={events:"Events",tasks:"Tasks",gateways:"Gateways",subprocesses:"Subprocesses",artifacts:"Artifacts"},yj={exclusiveGateway:"close",parallelGateway:"plus",inclusiveGateway:"circle",eventBasedGateway:"target",complexGateway:"star"},Nj=[{id:"startEvent",label:"Start Event",icon:"circle",category:"events",elementType:"startEvent"},{id:"endEvent",label:"End Event",icon:"circle",category:"events",elementType:"endEvent"},{id:"timerStartEvent",label:"Timer Start",icon:"clock",category:"events",elementType:"startEvent",eventDefinition:"timer"},{id:"messageStartEvent",label:"Message Start",icon:"mail",category:"events",elementType:"startEvent",eventDefinition:"message"},{id:"timerIntermediateEvent",label:"Timer Catch",icon:"clock",category:"events",elementType:"intermediateCatchEvent",eventDefinition:"timer"},{id:"messageIntermediateEvent",label:"Message Catch",icon:"mail",category:"events",elementType:"intermediateCatchEvent",eventDefinition:"message"},{id:"errorEndEvent",label:"Error End",icon:"zap",category:"events",elementType:"endEvent",eventDefinition:"error"},{id:"terminateEndEvent",label:"Terminate End",icon:"circle",category:"events",elementType:"endEvent",eventDefinition:"terminate"},{id:"task",label:"Task",icon:"check-square",category:"tasks",elementType:"task"},{id:"userTask",label:"User Task",icon:"user",category:"tasks",elementType:"userTask"},{id:"serviceTask",label:"Service Task",icon:"settings",category:"tasks",elementType:"serviceTask"},{id:"scriptTask",label:"Script Task",icon:"file",category:"tasks",elementType:"scriptTask"},{id:"businessRuleTask",label:"Business Rule",icon:"clipboard",category:"tasks",elementType:"businessRuleTask"},{id:"sendTask",label:"Send Task",icon:"upload",category:"tasks",elementType:"sendTask"},{id:"receiveTask",label:"Receive Task",icon:"download",category:"tasks",elementType:"receiveTask"},{id:"manualTask",label:"Manual Task",icon:"cursor",category:"tasks",elementType:"manualTask"},{id:"callActivity",label:"Call Activity",icon:"arrow-right",category:"tasks",elementType:"callActivity"},{id:"exclusiveGateway",label:"Exclusive (XOR)",icon:"close",category:"gateways",elementType:"exclusiveGateway"},{id:"parallelGateway",label:"Parallel (AND)",icon:"plus",category:"gateways",elementType:"parallelGateway"},{id:"inclusiveGateway",label:"Inclusive (OR)",icon:"circle",category:"gateways",elementType:"inclusiveGateway"},{id:"eventBasedGateway",label:"Event-Based",icon:"target",category:"gateways",elementType:"eventBasedGateway"},{id:"subProcess",label:"Subprocess",icon:"box",category:"subprocesses",elementType:"subProcess"},{id:"transaction",label:"Transaction",icon:"box",category:"subprocesses",elementType:"transaction"},{id:"textAnnotation",label:"Annotation",icon:"edit",category:"artifacts",elementType:"textAnnotation"},{id:"dataObject",label:"Data Object",icon:"file",category:"artifacts",elementType:"dataObject"}];function Sr(t){return`${t}_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}function Yc(t,n){const i=Sr(t.elementType);return t.category==="events"?{id:i,name:t.label,elementType:"event",eventType:t.elementType,eventDefinition:t.eventDefinition||"none",position:n}:t.category==="tasks"?{id:i,name:t.label,elementType:"task",taskType:t.elementType,position:n,size:{width:100,height:80}}:t.category==="gateways"?{id:i,name:"",elementType:"gateway",gatewayType:t.elementType,position:n}:t.category==="subprocesses"?{id:i,name:t.label,elementType:"subprocess",position:n,size:{width:300,height:200},isExpanded:!0,elements:[],sequenceFlows:[]}:null}function Ua(t,n){return Math.round(t/n)*n}const _j=({process:t,onChange:n,availableUsers:i=[],availableRoles:a=[],readOnly:s=!1,showMinimap:o=!0,showToolbar:c=!0,showValidation:d=!0,showPalette:p=!0,showProperties:m=!0,showVariables:h=!1,gridSize:u=20,snapToGrid:x=!0,onTest:f,onPublish:b,onExportBPMN:g,onImportBPMN:v,className:y,style:C,"data-testid":w})=>{const E=r.useRef(null);l.useRovingFocus(E,{orientation:"horizontal",wrap:!0,activateOnMove:!0});const{t:S}=l.useNiceTranslation(),{t:N}=l.useNiceTranslation(),[_,k]=r.useState(null),[j,T]=r.useState(null),[P,B]=r.useState(null),[R,I]=r.useState(null),[D,M]=r.useState({x:0,y:0}),[O,L]=r.useState(1),[V,ee]=r.useState(!1),z=r.useRef(null),[U,re]=r.useState("tasks"),[Y,oe]=r.useState(!1),[q,se]=r.useState(null),ce=r.useMemo(()=>d?bj(t,N):[],[t,d,N]),le=ce.filter($=>$.type==="error"),J=ce.filter($=>$.type==="warning"),me=r.useMemo(()=>t.elements.find($=>$.id===_),[t.elements,_]),je=r.useMemo(()=>t.sequenceFlows.find($=>$.id===j),[t.sequenceFlows,j]),ue=r.useMemo(()=>Nj.filter($=>$.category===U).map($=>({...$,label:N(`workflowDesigner.palette.${$.id}`,$.label)})),[U,N]),F=r.useCallback($=>{if(s||!P)return;const X=$.currentTarget.getBoundingClientRect();let ae=($.clientX-X.left-D.x)/O,ve=($.clientY-X.top-D.y)/O;x&&(ae=Ua(ae,u),ve=Ua(ve,u));const Ce=Yc(P,{x:ae,y:ve});Ce&&(n?.({...t,elements:[...t.elements,Ce]}),k(Ce.id)),B(null)},[s,P,D,O,x,u,t,n]),H=r.useCallback($=>{if(s)return;const X=t.elements.length%8*30;let ae=(40-D.x)/O+X,ve=(40-D.y)/O+X;x&&(ae=Ua(ae,u),ve=Ua(ve,u));const Ce=Yc($,{x:ae,y:ve});Ce&&(n?.({...t,elements:[...t.elements,Ce]}),k(Ce.id))},[s,D,O,x,u,t,n]),A=r.useRef(null),Z=r.useRef(null);l.useRovingFocus(A,{orientation:"vertical",typeahead:!0}),l.useRovingFocus(Z,{orientation:"horizontal",itemSelector:"button"});const fe=r.useCallback($=>{if(R){const X={id:Sr("flow"),sourceRef:R.fromId,targetRef:$};n?.({...t,sequenceFlows:[...t.sequenceFlows,X]}),I(null)}else k($),T(null)},[R,t,n]),Ne=r.useCallback($=>{s||I({fromId:$})},[s]),K=r.useCallback($=>{s||(n?.({...t,elements:t.elements.filter(X=>X.id!==$),sequenceFlows:t.sequenceFlows.filter(X=>X.sourceRef!==$&&X.targetRef!==$)}),_===$&&k(null))},[s,t,n,_]),Q=r.useCallback($=>{s||(n?.({...t,sequenceFlows:t.sequenceFlows.filter(X=>X.id!==$)}),j===$&&T(null))},[s,t,n,j]),ne=r.useCallback(($,X)=>{s||n?.({...t,elements:t.elements.map(ae=>ae.id===$?{...ae,...X}:ae)})},[s,t,n]),G=r.useCallback(($,X)=>{s||n?.({...t,sequenceFlows:t.sequenceFlows.map(ae=>ae.id===$?{...ae,...X}:ae)})},[s,t,n]),Se=r.useCallback(()=>{if(s)return;const $={id:Sr("var"),name:"newVariable",type:"string"};n?.({...t,variables:[...t.variables||[],$]})},[s,t,n]),te=r.useCallback(()=>{const $=t.elements.find(X=>X.elementType==="event"&&X.eventType==="startEvent");$&&(se($.id),oe(!0))},[t.elements]),we=r.useCallback($=>{const X=t.sequenceFlows.find(ae=>ae.id===$);X&&se(X.targetRef)},[t.sequenceFlows]),ie=r.useCallback($=>{const X=_===$.id,ae=Y&&q===$.id,ve=ce.some(Re=>Re.elementId===$.id),Ce=Y?t.sequenceFlows.filter(Re=>Re.sourceRef===$.id):[];let _e,ke="nice-bpmn-element",Ee={left:$.position.x,top:$.position.y};if($.elementType==="event"){const Re=fj[$.eventDefinition],qe=$.eventType==="startEvent",Ye=$.eventType==="endEvent",We=$.eventType==="boundaryEvent";ke+=" nice-bpmn-event",ke+=qe?" nice-bpmn-event--start":"",ke+=Ye?" nice-bpmn-event--end":"",ke+=We?" nice-bpmn-event--boundary":"",_e=e.jsx("div",{className:"nice-bpmn-event__icon",title:$.name,children:e.jsx(l.NiceIcon,{name:Re,size:16})})}else if($.elementType==="task"){const Re=vj[$.taskType];ke+=" nice-bpmn-task",ke+=` nice-bpmn-task--${$.taskType}`,Ee={...Ee,width:$.size?.width||100,height:$.size?.height||80},_e=e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"nice-bpmn-task__icon",children:e.jsx(l.NiceIcon,{name:Re,size:16})}),e.jsx("span",{className:"nice-bpmn-task__name",children:$.name}),$.assignee&&e.jsxs("span",{className:"nice-bpmn-task__assignee",children:[e.jsx(l.NiceIcon,{name:"user",size:14})," ",$.assignee]}),$.sla&&e.jsx("span",{className:"nice-bpmn-task__sla",title:S("workflowDesigner.slaHH","SLA: {warningHours}h / {criticalHours}h").replace("{warningHours}",String($.sla.warningHours)).replace("{criticalHours}",String($.sla.criticalHours)),children:e.jsx(l.NiceIcon,{name:"clock",size:14})}),$.loopCharacteristics&&e.jsx("span",{className:"nice-bpmn-task__loop",children:e.jsx(l.NiceIcon,{name:$.loopCharacteristics.type==="multiInstanceParallel"?"bars-vertical":$.loopCharacteristics.type==="multiInstanceSequential"?"menu":"refresh",size:12})})]})}else if($.elementType==="gateway"){const Re=yj[$.gatewayType];ke+=" nice-bpmn-gateway",ke+=` nice-bpmn-gateway--${$.gatewayType}`,_e=e.jsx("div",{className:"nice-bpmn-gateway__diamond",children:e.jsx("span",{children:e.jsx(l.NiceIcon,{name:Re,size:16})})})}else $.elementType==="subprocess"&&(ke+=" nice-bpmn-subprocess",ke+=$.isExpanded?" nice-bpmn-subprocess--expanded":"",Ee={...Ee,width:$.size.width,height:$.size.height},_e=e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"nice-bpmn-subprocess__header",children:[e.jsx("span",{children:$.name}),e.jsx("button",{type:"button",onClick:Re=>{Re.stopPropagation(),ne($.id,{isExpanded:!$.isExpanded})},"aria-label":$.isExpanded?N("workflowDesigner.collapse","Collapse"):N("workflowDesigner.expand","Expand"),children:$.isExpanded?"−":"+"})]}),$.isExpanded&&e.jsx("div",{className:"nice-bpmn-subprocess__content"})]}));return X&&(ke+=" nice-bpmn-element--selected"),ae&&(ke+=" nice-bpmn-element--active"),ve&&(ke+=" nice-bpmn-element--has-issue"),e.jsxs("div",{className:ke,style:Ee,onClick:Re=>{Re.stopPropagation(),fe($.id)},role:"button",tabIndex:0,"aria-label":`${$.elementType}: ${$.name||$.id}`,onKeyDown:Re=>{Re.key==="Enter"&&fe($.id),Re.key==="Delete"&&!s&&K($.id)},children:[_e,!s&&X&&e.jsxs("div",{className:"nice-bpmn-element__actions",children:[e.jsx("button",{type:"button",className:"nice-bpmn-element__action nice-bpmn-element__action--connect",onClick:Re=>{Re.stopPropagation(),Ne($.id)},title:N("workflowDesigner.connect","Connect"),"aria-label":N("workflowDesigner.startConnect","Start connection"),children:e.jsx(l.NiceIcon,{name:"arrow-right",size:14})}),e.jsx("button",{type:"button",className:"nice-bpmn-element__action nice-bpmn-element__action--delete",onClick:Re=>{Re.stopPropagation(),K($.id)},title:N("workflowDesigner.delete","Delete"),"aria-label":N("workflowDesigner.deleteElement","Delete element"),children:e.jsx(l.NiceIcon,{name:"close",size:12})})]}),ae&&Ce.map(Re=>e.jsxs("button",{type:"button",className:"nice-bpmn-element__sim-action",onClick:qe=>{qe.stopPropagation(),we(Re.id)},children:[e.jsx(l.NiceIcon,{name:"arrow-right",size:12}),Re.name||t.elements.find(qe=>qe.id===Re.targetRef)?.name||N("workflowDesigner.next","Next")]},Re.id))]},$.id)},[_,Y,q,ce,t.sequenceFlows,t.elements,s,fe,Ne,K,ne,we,N,S]),xe=r.useCallback(()=>e.jsxs("svg",{className:"nice-bpmn-flows",style:{position:"absolute",inset:0,pointerEvents:"none",overflow:"visible"},children:[e.jsxs("defs",{children:[e.jsx("marker",{id:"arrowhead",markerWidth:"10",markerHeight:"7",refX:"9",refY:"3.5",orient:"auto",children:e.jsx("polygon",{points:"0 0, 10 3.5, 0 7",fill:"var(--nice-text-secondary, #64748b)"})}),e.jsx("marker",{id:"arrowhead-selected",markerWidth:"10",markerHeight:"7",refX:"9",refY:"3.5",orient:"auto",children:e.jsx("polygon",{points:"0 0, 10 3.5, 0 7",fill:"var(--nice-color-primary, #3b82f6)"})})]}),t.sequenceFlows.map($=>{const X=t.elements.find(qe=>qe.id===$.sourceRef),ae=t.elements.find(qe=>qe.id===$.targetRef);if(!X||!ae)return null;const ve=j===$.id,Ce=X.position.x+(X.elementType==="task"?X.size?.width||100:X.elementType==="gateway"?25:15),_e=X.position.y+(X.elementType==="task"?(X.size?.height||80)/2:X.elementType==="gateway"?25:15),ke=ae.position.x,Ee=ae.position.y+(ae.elementType==="task"?(ae.size?.height||80)/2:ae.elementType==="gateway"?25:15),Re=$.waypoints&&$.waypoints.length>0?`M ${Ce} ${_e} ${$.waypoints.map(qe=>`L ${qe.x} ${qe.y}`).join(" ")} L ${ke} ${Ee}`:`M ${Ce} ${_e} L ${ke} ${Ee}`;return e.jsxs("g",{children:[e.jsx("path",{d:Re,fill:"none",stroke:ve?"var(--nice-color-primary, #3b82f6)":"var(--nice-text-muted, #64748b)",strokeWidth:ve?3:2,strokeDasharray:$.isDefault?"5,5":void 0,markerEnd:ve?"url(#arrowhead-selected)":"url(#arrowhead)",style:{pointerEvents:"stroke",cursor:"pointer"},onClick:()=>{T($.id),k(null)}}),$.name&&e.jsx("text",{x:(Ce+ke)/2,y:(_e+Ee)/2-5,textAnchor:"middle",fontSize:"11",fill:"var(--nice-text-secondary, #64748b)",children:$.name}),$.conditionExpression&&e.jsxs("text",{x:(Ce+ke)/2,y:(_e+Ee)/2+10,textAnchor:"middle",fontSize:"10",fill:"var(--nice-text-muted, #94a3b8)",fontStyle:"italic",children:["[",$.conditionExpression.substring(0,20),"...]"]})]},$.id)}),R&&e.jsx("line",{x1:t.elements.find($=>$.id===R.fromId)?.position.x||0,y1:t.elements.find($=>$.id===R.fromId)?.position.y||0,x2:t.elements.find($=>$.id===R.fromId)?.position.x||0,y2:t.elements.find($=>$.id===R.fromId)?.position.y||0,stroke:"var(--nice-color-primary, #3b82f6)",strokeWidth:"2",strokeDasharray:"5,5"})]}),[t.sequenceFlows,t.elements,j,R]),W=c?e.jsxs("div",{ref:Z,className:"nice-bpmn-designer__toolbar",role:"toolbar","aria-label":N("workflowDesigner.bpmnToolbar","BPMN designer toolbar"),children:[e.jsxs("div",{className:"nice-bpmn-designer__toolbar-group",children:[e.jsx("button",{type:"button",onClick:()=>L($=>Math.min($+.1,2)),title:N("workflowDesigner.zoomIn","Zoom in"),"aria-label":N("workflowDesigner.zoomIn","Zoom in"),children:e.jsx(l.NiceIcon,{name:"plus",size:14})}),e.jsxs("span",{className:"nice-bpmn-designer__zoom-label",children:[Math.round(O*100),"%"]}),e.jsx("button",{type:"button",onClick:()=>L($=>Math.max($-.1,.5)),title:N("workflowDesigner.zoomOut","Zoom out"),"aria-label":N("workflowDesigner.zoomOut","Zoom out"),children:e.jsx(l.NiceIcon,{name:"minus",size:14})}),e.jsx("button",{type:"button",onClick:()=>{L(1),M({x:0,y:0})},title:N("workflowDesigner.resetView","Reset view"),"aria-label":N("workflowDesigner.resetView","Reset view"),children:e.jsx(l.NiceIcon,{name:"refresh",size:14})})]}),e.jsxs("div",{className:"nice-bpmn-designer__toolbar-group",children:[!s&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",onClick:te,disabled:le.length>0||Y,title:N("workflowDesigner.simulateFlow","Simulate flow"),children:[e.jsx(l.NiceIcon,{name:"play",size:14})," ",N("workflowDesigner.simulate","Simulate")]}),Y&&e.jsxs("button",{type:"button",onClick:()=>{oe(!1),se(null)},children:[e.jsx(l.NiceIcon,{name:"stop",size:14})," ",N("workflowDesigner.stop","Stop")]})]}),f&&e.jsxs("button",{type:"button",onClick:()=>f(t),title:N("workflowDesigner.testProcess","Test process"),children:[e.jsx(l.NiceIcon,{name:"flask",size:14})," ",N("workflowDesigner.test","Test")]}),b&&!s&&e.jsxs("button",{type:"button",onClick:()=>b(t),disabled:le.length>0,title:N("workflowDesigner.publishProcess","Publish process"),children:[e.jsx(l.NiceIcon,{name:"rocket",size:14})," ",N("workflowDesigner.publish","Publish")]}),g&&e.jsxs("button",{type:"button",onClick:()=>g("<bpmn>"),title:N("workflowDesigner.exportBpmn","Export BPMN XML"),children:[e.jsx(l.NiceIcon,{name:"upload",size:14})," ",N("workflowDesigner.export","Export")]}),v&&!s&&e.jsxs("button",{type:"button",onClick:v,title:N("workflowDesigner.importBpmn","Import BPMN XML"),children:[e.jsx(l.NiceIcon,{name:"download",size:14})," ",N("workflowDesigner.import","Import")]})]})]}):void 0,be=p&&!s?e.jsxs("aside",{className:"nice-bpmn-designer__palette","aria-label":N("workflowDesigner.palette","BPMN element palette"),children:[e.jsx("div",{className:"nice-bpmn-designer__palette-tabs",ref:E,role:"tablist",children:["events","tasks","gateways","subprocesses","artifacts"].map($=>e.jsx("button",{type:"button",role:"tab","aria-selected":U===$,className:`nice-bpmn-designer__palette-tab${U===$?" nice-bpmn-designer__palette-tab--active":""}`,onClick:()=>re($),"aria-label":N(`workflowDesigner.cat.${$}`,Kc[$]),title:N(`workflowDesigner.cat.${$}`,Kc[$]),children:e.jsx(l.NiceIcon,{name:xj[$],size:16})},$))}),e.jsx("div",{ref:A,className:"nice-bpmn-designer__palette-items",role:"listbox","aria-label":N("workflowDesigner.palette","BPMN element palette"),children:ue.map($=>e.jsxs("div",{className:"nice-bpmn-designer__palette-item",draggable:!0,onDragStart:()=>B($),onDragEnd:()=>B(null),onKeyDown:X=>{(X.key==="Enter"||X.key===" ")&&(X.preventDefault(),H($))},role:"option","aria-selected":!1,"aria-label":$.label,children:[e.jsx("span",{className:"nice-bpmn-designer__palette-icon",children:e.jsx(l.NiceIcon,{name:$.icon,size:16})}),e.jsx("span",{className:"nice-bpmn-designer__palette-label",children:$.label})]},$.id))})]}):void 0,Te=m&&(me||je)&&!s,Me=Te||h?e.jsxs("div",{style:{display:"flex",height:"100%",minHeight:0},children:[Te&&e.jsxs("aside",{className:"nice-bpmn-designer__properties","aria-label":N("workflowDesigner.properties","Properties"),children:[me&&e.jsxs(e.Fragment,{children:[e.jsx("h3",{children:N("workflowDesigner.propertiesOf","Properties: {name}").replace("{name}",me.name||me.id)}),e.jsxs("div",{className:"nice-bpmn-designer__property",children:[e.jsx("label",{htmlFor:"prop-name",children:N("workflowDesigner.name","Name")}),e.jsx("input",{id:"prop-name",type:"text",value:me.name||"",onChange:$=>ne(me.id,{name:$.target.value})})]}),me.elementType==="task"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"nice-bpmn-designer__property",children:[e.jsx("label",{htmlFor:"prop-assignee",children:N("workflowDesigner.assignee","Assigned to")}),e.jsxs("select",{id:"prop-assignee",value:me.assignee||"",onChange:$=>ne(me.id,{assignee:$.target.value}),children:[e.jsx("option",{value:"",children:N("workflowDesigner.select","— Select —")}),i.map($=>e.jsx("option",{value:$.id,children:$.name},$.id))]})]}),e.jsxs("div",{className:"nice-bpmn-designer__property",children:[e.jsx("label",{htmlFor:"prop-dueDate",children:N("workflowDesigner.dueDate","Due date")}),e.jsx("input",{id:"prop-dueDate",type:"text",placeholder:N("workflowDesigner.dueDatePlaceholder","P3D (3 days)"),value:me.dueDate||"",onChange:$=>ne(me.id,{dueDate:$.target.value})})]}),e.jsxs("div",{className:"nice-bpmn-designer__property",children:[e.jsx("label",{htmlFor:"prop-priority",children:N("workflowDesigner.priority","Priority")}),e.jsx("input",{id:"prop-priority",type:"number",min:"0",max:"100",value:me.priority||50,onChange:$=>ne(me.id,{priority:parseInt($.target.value)})})]}),e.jsxs("div",{className:"nice-bpmn-designer__property",children:[e.jsx("label",{htmlFor:"prop-documentation",children:N("workflowDesigner.documentation","Documentation")}),e.jsx("textarea",{id:"prop-documentation",value:me.documentation||"",onChange:$=>ne(me.id,{documentation:$.target.value}),rows:3})]})]}),me.elementType==="event"&&me.eventDefinition==="timer"&&e.jsxs("div",{className:"nice-bpmn-designer__property",children:[e.jsx("label",{htmlFor:"prop-timer",children:N("workflowDesigner.timer","Timer (ISO 8601)")}),e.jsx("input",{id:"prop-timer",type:"text",placeholder:N("workflowDesigner.timerPlaceholder","PT1H (1 hour) or R3/PT1H (3 repetitions)"),value:me.timerDefinition?.expression||"",onChange:$=>ne(me.id,{timerDefinition:{type:"duration",expression:$.target.value}})})]}),me.elementType==="gateway"&&me.gatewayType==="exclusiveGateway"&&e.jsxs("div",{className:"nice-bpmn-designer__property",children:[e.jsx("label",{htmlFor:"prop-default",children:N("workflowDesigner.defaultFlow","Default flow")}),e.jsxs("select",{id:"prop-default",value:me.defaultFlow||"",onChange:$=>ne(me.id,{defaultFlow:$.target.value}),children:[e.jsx("option",{value:"",children:N("workflowDesigner.select","— Select —")}),t.sequenceFlows.filter($=>$.sourceRef===me.id).map($=>e.jsx("option",{value:$.id,children:$.name||$.id},$.id))]})]})]}),je&&e.jsxs(e.Fragment,{children:[e.jsx("h3",{children:N("workflowDesigner.flowOf","Flow: {name}").replace("{name}",je.name||je.id)}),e.jsxs("div",{className:"nice-bpmn-designer__property",children:[e.jsx("label",{htmlFor:"flow-name",children:N("workflowDesigner.name","Name")}),e.jsx("input",{id:"flow-name",type:"text",value:je.name||"",onChange:$=>G(je.id,{name:$.target.value})})]}),e.jsxs("div",{className:"nice-bpmn-designer__property",children:[e.jsx("label",{htmlFor:"flow-condition",children:N("workflowDesigner.condition","Condition")}),e.jsx("input",{id:"flow-condition",type:"text",placeholder:"${amount > 1000}",value:je.conditionExpression||"",onChange:$=>G(je.id,{conditionExpression:$.target.value})})]}),e.jsx("div",{className:"nice-bpmn-designer__property",children:e.jsxs("label",{children:[e.jsx("input",{type:"checkbox",checked:je.isDefault||!1,onChange:$=>G(je.id,{isDefault:$.target.checked})}),N("workflowDesigner.defaultFlow","Default flow")]})}),e.jsxs("button",{type:"button",className:"nice-bpmn-designer__delete-flow",onClick:()=>Q(je.id),children:[e.jsx(l.NiceIcon,{name:"trash",size:14})," ",N("workflowDesigner.deleteFlow","Delete flow")]})]})]}),h&&e.jsxs("aside",{className:"nice-bpmn-designer__variables","aria-label":N("workflowDesigner.variables","Process variables"),children:[e.jsx("h3",{children:N("workflowDesigner.variables","Process variables")}),e.jsx("ul",{className:"nice-bpmn-designer__variable-list",children:(t.variables||[]).map($=>e.jsxs("li",{className:"nice-bpmn-designer__variable-item",children:[e.jsx("span",{className:"nice-bpmn-designer__variable-name",children:$.name}),e.jsx("span",{className:"nice-bpmn-designer__variable-type",children:$.type})]},$.id))}),!s&&e.jsxs("button",{type:"button",onClick:Se,children:["+ ",N("workflowDesigner.addVariable","Add variable")]})]})]}):void 0;return e.jsx(_t.NiceAppShell,{flush:!0,className:`nice-bpmn-designer${s?" nice-bpmn-designer--readonly":""} ${y??""}`,style:C,"data-testid":w,toolbar:W,sidebar:be,rightSidebar:Me,bottomPanel:Y?e.jsx("div",{className:"nice-bpmn-designer__simulation-bar",children:e.jsxs("span",{children:[e.jsx(l.NiceIcon,{name:"video",size:14}),N("workflowDesigner.simActiveElement","Simulation active — current element:")," ",e.jsx("strong",{children:t.elements.find($=>$.id===q)?.name||q})]})}):void 0,children:e.jsxs("div",{style:{position:"relative",height:"100%",overflow:"hidden"},children:[e.jsxs("div",{className:`nice-bpmn-designer__canvas${V?" nice-bpmn-designer__canvas--panning":""}`,onDragOver:$=>$.preventDefault(),onDrop:F,onClick:()=>{k(null),T(null),I(null)},onWheel:$=>{if($.ctrlKey||$.metaKey){$.preventDefault();const ve=-$.deltaY*.0015;L(Ce=>Math.max(.25,Math.min(3,Ce+ve)));return}const X=$.shiftKey?$.deltaY:$.deltaX,ae=$.shiftKey?0:$.deltaY;M(ve=>({x:ve.x-X,y:ve.y-ae}))},onPointerDown:$=>{($.button===1||$.button===0&&$.altKey)&&($.preventDefault(),ee(!0),z.current={x:$.clientX,y:$.clientY,offX:D.x,offY:D.y},$.currentTarget.setPointerCapture($.pointerId))},onPointerMove:$=>{if(!V||!z.current)return;const{x:X,y:ae,offX:ve,offY:Ce}=z.current;M({x:ve+($.clientX-X),y:Ce+($.clientY-ae)})},onPointerUp:$=>{V&&(ee(!1),z.current=null,$.currentTarget.releasePointerCapture($.pointerId))},role:"application","aria-label":N("workflowDesigner.bpmnCanvas","BPMN canvas"),style:{backgroundSize:`${u*O}px ${u*O}px`,backgroundPosition:`${D.x}px ${D.y}px`},children:[e.jsxs("div",{className:"nice-bpmn-designer__canvas-content",style:{transform:`translate(${D.x}px, ${D.y}px) scale(${O})`,transformOrigin:"0 0"},children:[xe(),t.elements.map(ie)]}),R&&e.jsx("div",{className:"nice-bpmn-designer__connect-hint",children:N("workflowDesigner.connectHint","Click a target element to connect, or click empty space to cancel")})]}),o&&e.jsx("div",{className:"nice-bpmn-designer__minimap","aria-label":N("workflowDesigner.minimap","Minimap"),"aria-hidden":"true",children:t.elements.map($=>e.jsx("div",{className:`nice-bpmn-designer__minimap-dot nice-bpmn-designer__minimap-dot--${$.elementType}`,style:{left:$.position.x/10,top:$.position.y/10}},$.id))}),d&&ce.length>0&&e.jsxs("div",{className:"nice-bpmn-designer__validation",role:"status","aria-live":"polite",children:[le.map(($,X)=>e.jsxs("div",{className:"nice-bpmn-designer__issue nice-bpmn-designer__issue--error",children:[e.jsx(l.NiceIcon,{name:"error",size:14})," ",$.message]},X)),J.map(($,X)=>e.jsxs("div",{className:"nice-bpmn-designer__issue nice-bpmn-designer__issue--warning",children:[e.jsx(l.NiceIcon,{name:"warning",size:14})," ",$.message]},X))]})]})})},jj=[];function Ys(t){return t?new Date(t)<new Date:!1}function wj(t){if(!t)return!1;const n=new Date(t),i=new Date,a=(n.getTime()-i.getTime())/(1e3*60*60);return a>0&&a<=24}function kj(t,n){const i=new Date(n).getTime()-Date.now(),a=new Intl.RelativeTimeFormat(t,{numeric:"auto",style:"short"}),s=Math.round(i/6e4);if(Math.abs(s)<60)return a.format(s,"minute");const o=Math.round(i/36e5);return Math.abs(o)<24?a.format(o,"hour"):a.format(Math.round(i/864e5),"day")}function Cj(t,n){switch(n){case"low":return t("workflow.taskInbox.priority.low","Low");case"medium":return t("workflow.taskInbox.priority.medium","Medium");case"high":return t("workflow.taskInbox.priority.high","High");case"critical":return t("workflow.taskInbox.priority.critical","Critical")}}const Jc={approval:"check",review:"eye",input:"edit",default:"clipboard"},Pu=({tasks:t=jj,selectedTaskId:n,onTaskSelect:i,onTaskClaim:a,currentUserId:s,showFilters:o=!0,showSearch:c=!0,emptyMessage:d,groupByProcess:p=!1,refreshInterval:m=0,onRefresh:h,className:u,style:x,"data-testid":f})=>{const b=r.useRef(null);l.useRovingFocus(b,{orientation:"horizontal",wrap:!0,activateOnMove:!0});const g=r.useRef(null);l.useRovingFocus(g,{orientation:"vertical",typeahead:!0,pageSize:10});const{t:v,lang:y}=l.useNiceTranslation(),[C,w]=r.useState({}),[E,S]=r.useState(""),[N,_]=r.useState("all");r.useEffect(()=>{if(m>0&&h){const I=setInterval(h,m);return()=>clearInterval(I)}},[m,h]);const k=r.useMemo(()=>{let I=[...t];if(N!=="all"&&(I=I.filter(D=>D.status===N)),E.trim()){const D=E.toLowerCase();I=I.filter(M=>M.name.toLowerCase().includes(D)||M.processName.toLowerCase().includes(D)||M.description?.toLowerCase().includes(D))}return I.sort((D,M)=>{const O=Ys(D.dueDate),L=Ys(M.dueDate);if(O!==L)return O?-1:1;const V={critical:0,high:1,medium:2,low:3};return V[D.priority]!==V[M.priority]?V[D.priority]-V[M.priority]:D.dueDate&&M.dueDate?new Date(D.dueDate).getTime()-new Date(M.dueDate).getTime():0}),I},[t,N,E]),j=r.useMemo(()=>{if(!p)return null;const I={};for(const D of k){const M=D.processName;I[M]||(I[M]=[]),I[M].push(D)}return I},[k,p]),T=r.useCallback(I=>{i?.(I)},[i]),P=r.useMemo(()=>{const I={all:t.length};for(const D of t)I[D.status]=(I[D.status]||0)+1;return I},[t]),B=I=>{const D=Ys(I.dueDate),M=!D&&wj(I.dueDate),O=n===I.id,L=Jc[I.taskDefinitionKey]||Jc.default;return e.jsxs("div",{className:`nice-task-inbox__item${O?" nice-task-inbox__item--selected":""}${D?" nice-task-inbox__item--overdue":""}${M?" nice-task-inbox__item--warning":""}`,onClick:()=>T(I),role:"option","aria-selected":O,onKeyDown:V=>{V.target===V.currentTarget&&(V.key==="Enter"||V.key===" ")&&(V.preventDefault(),T(I))},children:[e.jsx("div",{className:"nice-task-inbox__item-icon",children:e.jsx(l.NiceIcon,{name:L,size:16})}),e.jsxs("div",{className:"nice-task-inbox__item-content",children:[e.jsx("div",{className:"nice-task-inbox__item-name",children:I.name}),e.jsx("div",{className:"nice-task-inbox__item-process",children:I.processName}),e.jsxs("div",{className:"nice-task-inbox__item-meta",children:[I.dueDate&&e.jsxs("span",{className:`nice-task-inbox__item-due${D?" nice-task-inbox__item-due--overdue":""}`,children:[e.jsx(l.NiceIcon,{name:"clock",size:14})," ",D?v("workflow.taskInbox.overdue","Overdue:"):v("workflow.taskInbox.due","Due:")," ",kj(y,I.dueDate)]}),e.jsx("span",{className:`nice-task-inbox__item-priority nice-task-inbox__item-priority--${I.priority}`,children:Cj(v,I.priority)})]})]}),a&&!I.assignee&&I.candidateUsers?.includes(s||"")&&e.jsx("button",{type:"button",className:"nice-task-inbox__claim-btn",onClick:V=>{V.stopPropagation(),a(I)},"aria-label":v("workflow.taskInbox.claimTask","Claim task"),children:v("workflow.taskInbox.claim","Claim")})]},I.id)},R=(I,D)=>e.jsxs("button",{type:"button",role:"tab","aria-selected":N===I,className:`nice-task-inbox__filter${N===I?" nice-task-inbox__filter--active":""}`,onClick:()=>_(I),children:[D," (",P[I]||0,")"]});return e.jsxs("div",{className:`nice-task-inbox ${u??""}`,style:x,"data-testid":f,children:[e.jsxs("div",{className:"nice-task-inbox__header",children:[e.jsxs("h2",{className:"nice-task-inbox__title",children:[v("workflow.taskInbox.title","My tasks"),e.jsx("span",{className:"nice-task-inbox__badge",children:k.length})]}),h&&e.jsx("button",{type:"button",onClick:h,"aria-label":v("workflow.taskInbox.refresh","Refresh"),children:e.jsx(l.NiceIcon,{name:"refresh",size:16})})]}),o&&e.jsxs("div",{className:"nice-task-inbox__filters",ref:b,role:"tablist",children:[R("all",v("workflow.taskInbox.filter.all","All")),R("pending",v("workflow.taskInbox.filter.pending","Pending")),R("claimed",v("workflow.taskInbox.filter.claimed","Claimed")),R("inProgress",v("workflow.taskInbox.filter.inProgress","In progress"))]}),c&&e.jsx("div",{className:"nice-task-inbox__search",children:e.jsx("input",{type:"search",placeholder:v("workflow.taskInbox.searchPlaceholder","Search tasks..."),value:E,onChange:I=>S(I.target.value),"aria-label":v("workflow.taskInbox.search","Search tasks")})}),e.jsx("div",{ref:g,className:"nice-task-inbox__list",role:"listbox","aria-label":v("workflow.taskInbox.list","Task list"),children:k.length===0?e.jsxs("div",{className:"nice-task-inbox__empty",children:[e.jsx("span",{className:"nice-task-inbox__empty-icon",children:e.jsx(l.NiceIcon,{name:"mail",size:32})}),e.jsx("span",{children:d??v("workflow.taskInbox.empty","No tasks to do")})]}):j?Object.entries(j).map(([I,D])=>e.jsxs("div",{className:"nice-task-inbox__group",children:[e.jsx("div",{className:"nice-task-inbox__group-header",children:I}),D.map(B)]},I)):k.map(B)})]})},Sj=[];function Qc(t){if(!t)return"-";const n=Math.floor(t/1e3),i=Math.floor(n/60),a=Math.floor(i/60),s=Math.floor(a/24);return s>0?`${s}d ${a%24}h`:a>0?`${a}h ${i%60}m`:i>0?`${i}m ${n%60}s`:`${n}s`}function Tj(t,n){return new Date(n).toLocaleString(t,{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit"})}function Ej(t,n){switch(n){case"running":return t("workflow.instanceMonitor.status.running","Running");case"completed":return t("workflow.instanceMonitor.status.completed","Completed");case"failed":return t("workflow.instanceMonitor.status.failed","Failed");case"suspended":return t("workflow.instanceMonitor.status.suspended","Suspended");case"terminated":return t("workflow.instanceMonitor.status.terminated","Terminated");case"incident":return t("workflow.instanceMonitor.status.incident","Incident")}}const Ij={running:"play",completed:"check",failed:"close",suspended:"pause",terminated:"stop",incident:"warning"},Au=({instances:t=Sj,selectedInstanceId:n,onInstanceSelect:i,onSuspend:a,onResume:s,onTerminate:o,onRetry:c,onViewDetails:d,onViewDiagram:p,showStats:m=!0,showFilters:h=!0,refreshInterval:u=0,onRefresh:x,processDefinitions:f=[],className:b,style:g,"data-testid":v})=>{const{t:y,lang:C}=l.useNiceTranslation(),[w,E]=r.useState({}),[S,N]=r.useState(""),[_,k]=r.useState("all"),[j,T]=r.useState("all");r.useEffect(()=>{if(u>0&&x){const D=setInterval(x,u);return()=>clearInterval(D)}},[u,x]);const P=r.useMemo(()=>{const D={total:t.length,running:0,completed:0,failed:0,suspended:0,incidents:0};for(const M of t)M.status==="running"?D.running++:M.status==="completed"?D.completed++:M.status==="failed"||M.status==="incident"?D.failed++:M.status==="suspended"&&D.suspended++,M.incidentCount&&M.incidentCount>0&&(D.incidents+=M.incidentCount);return D},[t]),B=r.useMemo(()=>{let D=[...t];if(_!=="all"&&(D=D.filter(M=>M.status===_)),j!=="all"&&(D=D.filter(M=>M.processDefinitionKey===j)),S.trim()){const M=S.toLowerCase();D=D.filter(O=>O.id.toLowerCase().includes(M)||O.businessKey?.toLowerCase().includes(M)||O.processDefinitionName.toLowerCase().includes(M))}return D.sort((M,O)=>new Date(O.startTime).getTime()-new Date(M.startTime).getTime()),D},[t,_,j,S]),R=r.useCallback(D=>{i?.(D)},[i]),I={running:y("workflow.instanceMonitor.stats.running","Running"),completed:y("workflow.instanceMonitor.stats.completed","Completed"),errors:y("workflow.instanceMonitor.stats.errors","Errors"),incidents:y("workflow.instanceMonitor.stats.incidents","Incidents")};return e.jsxs("div",{className:`nice-instance-monitor ${b??""}`,style:g,"data-testid":v,children:[e.jsxs("div",{className:"nice-instance-monitor__header",children:[e.jsx("h2",{className:"nice-instance-monitor__title",children:y("workflow.instanceMonitor.title","Instance monitor")}),x&&e.jsx("button",{type:"button",onClick:x,"aria-label":y("workflow.instanceMonitor.refresh","Refresh"),children:e.jsx(l.NiceIcon,{name:"refresh",size:16})})]}),m&&e.jsxs("div",{className:"nice-instance-monitor__stats",children:[e.jsxs("div",{className:"nice-instance-monitor__stat",children:[e.jsx("div",{className:"nice-instance-monitor__stat-value",children:P.total}),e.jsx("div",{className:"nice-instance-monitor__stat-label",children:y("workflow.instanceMonitor.stats.total","Total")})]}),e.jsxs("div",{className:"nice-instance-monitor__stat nice-instance-monitor__stat--running",children:[e.jsx("div",{className:"nice-instance-monitor__stat-value",children:P.running}),e.jsx("div",{className:"nice-instance-monitor__stat-label",children:I.running})]}),e.jsxs("div",{className:"nice-instance-monitor__stat nice-instance-monitor__stat--completed",children:[e.jsx("div",{className:"nice-instance-monitor__stat-value",children:P.completed}),e.jsx("div",{className:"nice-instance-monitor__stat-label",children:I.completed})]}),e.jsxs("div",{className:"nice-instance-monitor__stat nice-instance-monitor__stat--failed",children:[e.jsx("div",{className:"nice-instance-monitor__stat-value",children:P.failed}),e.jsx("div",{className:"nice-instance-monitor__stat-label",children:I.errors})]}),P.incidents>0&&e.jsxs("div",{className:"nice-instance-monitor__stat nice-instance-monitor__stat--failed",children:[e.jsx("div",{className:"nice-instance-monitor__stat-value",children:P.incidents}),e.jsx("div",{className:"nice-instance-monitor__stat-label",children:I.incidents})]})]}),h&&e.jsxs("div",{className:"nice-instance-monitor__filters",children:[e.jsxs("select",{value:_,onChange:D=>k(D.target.value),"aria-label":y("workflow.instanceMonitor.filterStatus","Filter by status"),children:[e.jsx("option",{value:"all",children:y("workflow.instanceMonitor.allStatuses","All statuses")}),e.jsx("option",{value:"running",children:I.running}),e.jsx("option",{value:"completed",children:I.completed}),e.jsx("option",{value:"failed",children:I.errors}),e.jsx("option",{value:"suspended",children:y("workflow.instanceMonitor.status.suspended","Suspended")}),e.jsx("option",{value:"incident",children:I.incidents})]}),f.length>0&&e.jsxs("select",{value:j,onChange:D=>T(D.target.value),"aria-label":y("workflow.instanceMonitor.filterProcess","Filter by process"),children:[e.jsx("option",{value:"all",children:y("workflow.instanceMonitor.allProcesses","All processes")}),f.map(D=>e.jsx("option",{value:D.key,children:D.name},D.key))]}),e.jsx("input",{type:"search",placeholder:y("workflow.instanceMonitor.searchPlaceholder","Search..."),value:S,onChange:D=>N(D.target.value),"aria-label":y("workflow.instanceMonitor.search","Search instances")})]}),e.jsxs("div",{className:"nice-instance-monitor__list",children:[e.jsxs("div",{className:"nice-instance-monitor__row nice-instance-monitor__row-header",children:[e.jsx("span",{children:y("workflow.instanceMonitor.col.process","Process / ID")}),e.jsx("span",{children:y("workflow.instanceMonitor.col.status","Status")}),e.jsx("span",{children:y("workflow.instanceMonitor.col.started","Started")}),e.jsx("span",{children:y("workflow.instanceMonitor.col.duration","Duration")}),e.jsx("span",{children:y("workflow.instanceMonitor.col.actions","Actions")})]}),B.length===0?e.jsx("div",{className:"nice-instance-monitor__empty",children:e.jsx("span",{children:y("workflow.instanceMonitor.empty","No instances match the filters")})}):B.map(D=>{const M=n===D.id;return e.jsxs("div",{className:`nice-instance-monitor__row${M?" nice-instance-monitor__row--selected":""}`,onClick:()=>R(D),role:"button",tabIndex:0,"aria-selected":M,onKeyDown:O=>O.key==="Enter"&&R(D),children:[e.jsxs("span",{className:"nice-instance-monitor__process",children:[e.jsx("strong",{children:D.processDefinitionName}),e.jsx("small",{children:D.businessKey||D.id.substring(0,8)})]}),e.jsxs("span",{className:`nice-instance-monitor__status nice-instance-monitor__status--${D.status}`,children:[e.jsx(l.NiceIcon,{name:Ij[D.status],size:14})," ",Ej(y,D.status),D.incidentCount&&D.incidentCount>0&&e.jsx("span",{className:"nice-instance-monitor__incident-badge",children:D.incidentCount})]}),e.jsx("span",{children:Tj(C,D.startTime)}),e.jsx("span",{children:D.status==="completed"||D.status==="terminated"?Qc(D.durationMs):Qc(Date.now()-new Date(D.startTime).getTime())}),e.jsxs("div",{role:"presentation",className:"nice-instance-monitor__actions",onClick:O=>O.stopPropagation(),children:[d&&e.jsx("button",{type:"button",className:"nice-instance-monitor__action",onClick:()=>d(D),title:y("workflow.instanceMonitor.details","Details"),"aria-label":y("workflow.instanceMonitor.viewDetails","View details"),children:e.jsx(l.NiceIcon,{name:"clipboard",size:16})}),p&&e.jsx("button",{type:"button",className:"nice-instance-monitor__action",onClick:()=>p(D),title:y("workflow.instanceMonitor.diagram","Diagram"),"aria-label":y("workflow.instanceMonitor.viewDiagram","View diagram"),children:e.jsx(l.NiceIcon,{name:"map-pin",size:16})}),D.status==="running"&&a&&e.jsx("button",{type:"button",className:"nice-instance-monitor__action",onClick:()=>a(D),title:y("workflow.instanceMonitor.suspend","Suspend"),"aria-label":y("workflow.instanceMonitor.suspendInstance","Suspend instance"),children:e.jsx(l.NiceIcon,{name:"pause",size:16})}),D.status==="suspended"&&s&&e.jsx("button",{type:"button",className:"nice-instance-monitor__action",onClick:()=>s(D),title:y("workflow.instanceMonitor.resume","Resume"),"aria-label":y("workflow.instanceMonitor.resumeInstance","Resume instance"),children:e.jsx(l.NiceIcon,{name:"play",size:16})}),(D.status==="failed"||D.status==="incident")&&c&&e.jsx("button",{type:"button",className:"nice-instance-monitor__action",onClick:()=>c(D),title:y("workflow.instanceMonitor.retry","Retry"),"aria-label":y("workflow.instanceMonitor.retryInstance","Retry instance"),children:e.jsx(l.NiceIcon,{name:"refresh",size:16})}),D.status==="running"&&o&&e.jsx("button",{type:"button",className:"nice-instance-monitor__action nice-instance-monitor__action--danger",onClick:()=>o(D),title:y("workflow.instanceMonitor.terminate","Terminate"),"aria-label":y("workflow.instanceMonitor.terminateInstance","Terminate instance"),children:e.jsx(l.NiceIcon,{name:"stop",size:16})})]})]},D.id)})]})]})},Dj=[],Pj=[],Aj=t=>Array.from({length:7},(n,i)=>new Date(Date.UTC(2024,0,7+i)).toLocaleDateString(t,{weekday:"short"})),Rj=({preferences:t,onChange:n,onSave:i,channels:a=Dj,categories:s=Pj,showQuietHours:o=!0,showDigest:c=!0,showTestButton:d=!0,className:p,style:m,"data-testid":h})=>{const u=r.useRef(null);l.useRovingFocus(u,{orientation:"horizontal",wrap:!0,activateOnMove:!0});const{t:x,lang:f}=l.useNiceTranslation(),b=r.useMemo(()=>Aj(f),[f]),[g,v]=r.useState("channels"),[y,C]=r.useState(!1),w=k=>n({...t,...k}),E=k=>w({channels:{...t.channels,[k]:!t.channels[k]}}),S=(k,j)=>{const T=t.categoryPrefs.find(R=>R.categoryId===k),P=T?.channels??{},B={categoryId:k,channels:{...P,[j]:!P[j]},priority:T?.priority??"all"};w({categoryPrefs:t.categoryPrefs.some(R=>R.categoryId===k)?t.categoryPrefs.map(R=>R.categoryId===k?B:R):[...t.categoryPrefs,B]})},N=async()=>{C(!0);try{await i(t)}finally{C(!1)}},_=[{id:"channels",label:x("notifications.channels","Channels"),show:!0},{id:"categories",label:x("notifications.categories","Categories"),show:!0},{id:"quietHours",label:x("notifications.quietHours2","Quiet Hours"),show:o},{id:"digest",label:x("notifications.digest","Digest"),show:c}];return e.jsxs("div",{className:`nice-notification-prefs ${p??""}`,style:m,"data-testid":h,children:[e.jsx("div",{className:"nice-notification-prefs__global",children:e.jsxs("label",{className:"nice-notification-prefs__global-label",children:[e.jsx("input",{type:"checkbox",checked:t.globalEnabled,onChange:k=>w({globalEnabled:k.target.checked}),"aria-label":x("notifications.enableAll","Enable all notifications")}),x("notifications.global","Global notifications")]})}),e.jsx("div",{className:"nice-notification-prefs__tabs",ref:u,role:"tablist",children:_.filter(k=>k.show).map(k=>e.jsx("button",{role:"tab","aria-selected":g===k.id,className:`nice-notification-prefs__tab${g===k.id?" nice-notification-prefs__tab--active":""}`,onClick:()=>v(k.id),type:"button",children:k.label},k.id))}),g==="channels"&&e.jsx("div",{className:"nice-notification-prefs__channels",role:"tabpanel",children:a.map(k=>e.jsxs("div",{className:"nice-notification-prefs__channel-row",children:[e.jsx("span",{className:"nice-notification-prefs__channel-icon","aria-hidden":"true",children:e.jsx(l.NiceIcon,{name:k.icon,size:16})}),e.jsx("span",{className:"nice-notification-prefs__channel-name",children:k.name}),k.configRequired&&!k.enabled&&e.jsx("a",{href:k.configUrl??"#",className:"nice-notification-prefs__config-link",children:x("notifications.configure","Configure")}),e.jsx("label",{className:"nice-notification-prefs__toggle-label",children:e.jsx("input",{type:"checkbox",checked:t.channels[k.id]??!1,onChange:()=>E(k.id),disabled:!t.globalEnabled,"aria-label":`${x("notifications.channel","Channel")} ${k.name}`})}),d&&t.channels[k.id]&&e.jsx("button",{type:"button",className:"nice-notification-prefs__test-btn",onClick:()=>{},children:x("notifications.test","Test")})]},k.id))}),g==="categories"&&e.jsx("div",{className:"nice-notification-prefs__categories",role:"tabpanel",children:e.jsxs("table",{className:"nice-notification-prefs__matrix",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:x("notifications.category","Category")}),a.map(k=>e.jsx("th",{children:k.name},k.id)),e.jsx("th",{children:x("notifications.priority","Priority")})]})}),e.jsx("tbody",{children:s.map(k=>{const j=t.categoryPrefs.find(T=>T.categoryId===k.id);return e.jsxs("tr",{children:[e.jsxs("td",{children:[e.jsx(l.NiceIcon,{name:k.icon,size:14})," ",k.name]}),a.map(T=>e.jsx("td",{children:e.jsx("input",{type:"checkbox",checked:j?.channels[T.id]??k.defaultChannels.includes(T.id),onChange:()=>S(k.id,T.id),disabled:!t.globalEnabled,"aria-label":`${k.name} — ${T.name}`})},T.id)),e.jsx("td",{children:e.jsxs("select",{value:j?.priority??"all",onChange:T=>{const P=t.categoryPrefs.find(R=>R.categoryId===k.id),B={categoryId:k.id,channels:P?.channels??{},priority:T.target.value};w({categoryPrefs:t.categoryPrefs.some(R=>R.categoryId===k.id)?t.categoryPrefs.map(R=>R.categoryId===k.id?B:R):[...t.categoryPrefs,B]})},"aria-label":`${x("notifications.categoryPriority","Category priority")} ${k.name}`,children:[e.jsx("option",{value:"all",children:x("notifications.priorityAll","All")}),e.jsx("option",{value:"high",children:x("notifications.priorityHigh","High and above")}),e.jsx("option",{value:"critical",children:x("notifications.priorityCritical","Critical")})]})})]},k.id)})})]})}),g==="quietHours"&&o&&e.jsxs("div",{className:"nice-notification-prefs__quiet-hours",role:"tabpanel",children:[e.jsxs("label",{children:[e.jsx("input",{type:"checkbox",checked:t.quietHours?.enabled??!1,onChange:k=>w({quietHours:{...t.quietHours??{startTime:"22:00",endTime:"07:00",timezone:"Europe/Warsaw",daysOfWeek:[0,1,2,3,4,5,6]},enabled:k.target.checked}}),"aria-label":x("notifications.enableQuietHours","Enable quiet hours")}),x("notifications.quietHours","Quiet hours")]}),t.quietHours?.enabled&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"nice-notification-prefs__time-row",children:[e.jsxs("label",{children:[x("notifications.from","From:"),e.jsx("input",{type:"time",value:t.quietHours.startTime,onChange:k=>w({quietHours:{...t.quietHours,startTime:k.target.value}}),"aria-label":x("notifications.quietStart","Quiet hours start")})]}),e.jsxs("label",{children:[x("notifications.to","To:"),e.jsx("input",{type:"time",value:t.quietHours.endTime,onChange:k=>w({quietHours:{...t.quietHours,endTime:k.target.value}}),"aria-label":x("notifications.quietEnd","Quiet hours end")})]})]}),e.jsx("div",{className:"nice-notification-prefs__days-row",role:"group","aria-label":x("notifications.daysOfTheWeek","Days of the week"),children:b.map((k,j)=>e.jsxs("label",{className:"nice-notification-prefs__day-check",children:[e.jsx("input",{type:"checkbox",checked:t.quietHours.daysOfWeek.includes(j),onChange:()=>{const T=t.quietHours.daysOfWeek;w({quietHours:{...t.quietHours,daysOfWeek:T.includes(j)?T.filter(P=>P!==j):[...T,j]}})},"aria-label":k}),k]},j))})]})]}),g==="digest"&&c&&e.jsxs("div",{className:"nice-notification-prefs__digest",role:"tabpanel",children:[e.jsxs("label",{children:[e.jsx("input",{type:"checkbox",checked:t.digest?.enabled??!1,onChange:k=>w({digest:{...t.digest??{frequency:"daily"},enabled:k.target.checked}}),"aria-label":x("notifications.enableDigest","Enable the digest")}),x("notifications.digest","Digest")]}),t.digest?.enabled&&e.jsxs(e.Fragment,{children:[e.jsxs("label",{children:[x("notifications.frequency","Frequency"),":",e.jsxs("select",{value:t.digest.frequency,onChange:k=>w({digest:{...t.digest,frequency:k.target.value}}),"aria-label":x("notifications.digestFrequency","Digest frequency"),children:[e.jsx("option",{value:"realtime",children:x("notifications.realtime","Real time")}),e.jsx("option",{value:"hourly",children:x("notifications.hourly","Hourly")}),e.jsx("option",{value:"daily",children:x("notifications.daily","Daily")}),e.jsx("option",{value:"weekly",children:x("notifications.weekly","Weekly")})]})]}),["daily","weekly"].includes(t.digest.frequency)&&e.jsxs("label",{children:[x("notifications.deliveryTime","Delivery time"),":",e.jsx("input",{type:"time",value:t.digest.deliveryTime??"09:00",onChange:k=>w({digest:{...t.digest,deliveryTime:k.target.value}}),"aria-label":x("notifications.digestDeliveryTime","Digest delivery time")})]})]})]}),e.jsx("div",{className:"nice-notification-prefs__footer",children:e.jsx("button",{type:"button",className:"nice-notification-prefs__save-btn",onClick:N,disabled:y,children:y?x("notifications.saving","Saving…"):x("notifications.savePreferences","Save preferences")})})]})},$j=[],Ha={online:"var(--nice-color-success, #22c55e)",offline:"var(--nice-color-error, #ef4444)",warning:"var(--nice-color-warning, #f59e0b)"},Ga={router:"shuffle",switch:"plug","access-point":"wifi",server:"server",workstation:"monitor",printer:"printer",camera:"camera",iot:"home",unknown:"help"},Mj=({nodes:t=$j,topology:n,onScan:i,onNodeClick:a,onNodeAction:s,showTopologyView:o=!0,showMapView:c=!0,showListView:d=!0,autoRefreshMs:p=3e4,className:m,style:h,"data-testid":u})=>{const x=r.useRef(null);l.useRovingFocus(x,{orientation:"horizontal",wrap:!0,activateOnMove:!0});const{t:f}=l.useNiceTranslation(),[b,g]=r.useState("list"),[v,y]=r.useState(!1),[C,w]=r.useState(""),[E,S]=r.useState(""),[N,_]=r.useState(""),[k,j]=r.useState(null),[T,P]=r.useState("");r.useEffect(()=>{if(!p)return;const D=setInterval(()=>i(),p);return()=>clearInterval(D)},[p,i]);const B=t.filter(D=>{if(E&&D.category!==E||N&&D.status!==N||k!==null&&D.isRogue!==k)return!1;if(T){const M=T.toLowerCase();return D.ipAddress.includes(M)||(D.hostname?.toLowerCase().includes(M)??!1)||(D.vendor?.toLowerCase().includes(M)??!1)}return!0}),R=async()=>{y(!0);try{await i(C||void 0)}finally{y(!1)}},I=[{id:"list",label:f("networkDiscovery.list","List"),show:d},{id:"cards",label:f("networkDiscovery.cards","Cards"),show:!0},{id:"topology",label:f("networkDiscovery.topology","Topology"),show:o},{id:"map",label:f("networkDiscovery.map","Map"),show:c}];return e.jsxs("div",{className:`nice-network-discovery ${m??""}`,style:h,"data-testid":u,children:[e.jsxs("div",{className:"nice-network-discovery__toolbar",children:[e.jsx("input",{type:"text",placeholder:f("networkDiscovery.subnetPlaceholder","Subnet (e.g. 192.168.1.0/24)"),value:C,onChange:D=>w(D.target.value),className:"nice-network-discovery__subnet-input","aria-label":f("networkDiscovery.subnet","Subnet to scan")}),e.jsx("button",{onClick:R,disabled:v,type:"button",className:"nice-network-discovery__scan-btn",children:v?f("networkDiscovery.scanning","Scanning…"):e.jsxs(e.Fragment,{children:[e.jsx(l.NiceIcon,{name:"search",size:14})," ",f("networkDiscovery.scan","Scan network")]})}),e.jsx("input",{type:"search",placeholder:f("networkDiscovery.searchPlaceholder","Search (IP, hostname, vendor)…"),value:T,onChange:D=>P(D.target.value),"aria-label":f("networkDiscovery.searchDevice","Search devices")}),e.jsxs("select",{value:E,onChange:D=>S(D.target.value),"aria-label":f("networkDiscovery.filterCategory","Filter by category"),children:[e.jsx("option",{value:"",children:f("networkDiscovery.allCategories","All categories")}),["router","switch","access-point","server","workstation","printer","camera","iot","unknown"].map(D=>e.jsx("option",{value:D,children:D},D))]}),e.jsxs("select",{value:N,onChange:D=>_(D.target.value),"aria-label":f("networkDiscovery.filterStatus","Filter by status"),children:[e.jsx("option",{value:"",children:f("networkDiscovery.allStatuses","All statuses")}),e.jsx("option",{value:"online",children:f("networkDiscovery.online","Online")}),e.jsx("option",{value:"offline",children:f("networkDiscovery.offline","Offline")}),e.jsx("option",{value:"warning",children:f("networkDiscovery.warning","Warning")})]}),e.jsxs("label",{children:[e.jsx("input",{type:"checkbox",checked:k===!0,onChange:D=>j(D.target.checked?!0:null),"aria-label":f("networkDiscovery.rogueOnly","Rogue only")}),f("networkDiscovery.rogueOnly","Rogue only")]}),e.jsxs("span",{className:"nice-network-discovery__count",children:[B.length," / ",t.length," ",f("networkDiscovery.devices","devices")]})]}),e.jsx("div",{className:"nice-network-discovery__tabs",ref:x,role:"tablist",children:I.filter(D=>D.show).map(D=>e.jsx("button",{role:"tab","aria-selected":b===D.id,className:`nice-network-discovery__tab${b===D.id?" nice-network-discovery__tab--active":""}`,onClick:()=>g(D.id),type:"button",children:D.label},D.id))}),b==="list"&&e.jsx("div",{className:"nice-network-discovery__list",role:"tabpanel",children:e.jsxs("table",{className:"nice-network-discovery__table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:f("networkDiscovery.status","Status")}),e.jsx("th",{children:f("networkDiscovery.category","Category")}),e.jsx("th",{children:f("networkDiscovery.hostname","Hostname")}),e.jsx("th",{children:"IP"}),e.jsx("th",{children:"MAC"}),e.jsx("th",{children:f("networkDiscovery.vendor","Vendor")}),e.jsx("th",{children:f("networkDiscovery.os","OS")}),e.jsx("th",{children:f("networkDiscovery.approved","Approved")}),e.jsx("th",{children:f("networkDiscovery.actions","Actions")})]})}),e.jsx("tbody",{children:B.map(D=>e.jsxs("tr",{className:`nice-network-discovery__row${D.isRogue?" nice-network-discovery__row--rogue":""}`,onClick:()=>a(D.id),style:{cursor:"pointer"},children:[e.jsx("td",{children:e.jsx("span",{className:"nice-network-discovery__status-dot",style:{background:Ha[D.status]},"aria-label":D.status})}),e.jsxs("td",{children:[e.jsx(l.NiceIcon,{name:Ga[D.category],size:16})," ",D.category]}),e.jsx("td",{children:D.hostname??"—"}),e.jsx("td",{children:D.ipAddress}),e.jsx("td",{children:D.macAddress??"—"}),e.jsx("td",{children:D.vendor??"—"}),e.jsx("td",{children:D.os??"—"}),e.jsx("td",{children:D.isApproved?e.jsx(l.NiceIcon,{name:"check",size:16}):D.isRogue?e.jsx(l.NiceIcon,{name:"slash",size:16}):"—"}),e.jsxs("td",{onClick:M=>M.stopPropagation(),children:[!D.isApproved&&!D.isRogue&&e.jsx("button",{onClick:()=>s(D.id,"approve"),type:"button",title:f("networkDiscovery.approve","Approve"),"aria-label":f("networkDiscovery.approve","Approve"),children:e.jsx(l.NiceIcon,{name:"check",size:16})}),!D.isRogue&&e.jsx("button",{onClick:()=>s(D.id,"block"),type:"button",title:f("networkDiscovery.block","Block"),"aria-label":f("networkDiscovery.block","Block"),children:e.jsx(l.NiceIcon,{name:"slash",size:16})}),e.jsx("button",{onClick:()=>s(D.id,"tag"),type:"button",title:f("networkDiscovery.tag","Tag"),"aria-label":f("networkDiscovery.tag","Tag"),children:e.jsx(l.NiceIcon,{name:"tag",size:16})}),e.jsx("button",{onClick:()=>s(D.id,"provision"),type:"button",title:f("networkDiscovery.provision","Provision"),"aria-label":f("networkDiscovery.provision","Provision"),children:e.jsx(l.NiceIcon,{name:"settings",size:16})})]})]},D.id))})]})}),b==="cards"&&e.jsx("div",{className:"nice-network-discovery__cards",role:"tabpanel",children:B.map(D=>e.jsxs("div",{className:`nice-network-discovery__card nice-network-discovery__card--${D.status}${D.isRogue?" nice-network-discovery__card--rogue":""}`,onClick:()=>a(D.id),role:"button",tabIndex:0,onKeyDown:M=>M.key==="Enter"&&a(D.id),"aria-label":`${f("networkDiscovery.device","Device")} ${D.hostname??D.ipAddress}`,children:[e.jsx("span",{className:"nice-network-discovery__card-icon","aria-hidden":"true",children:e.jsx(l.NiceIcon,{name:Ga[D.category],size:24})}),e.jsx("div",{className:"nice-network-discovery__card-status",style:{background:Ha[D.status]},"aria-label":D.status}),e.jsx("div",{className:"nice-network-discovery__card-hostname",children:D.hostname??D.ipAddress}),e.jsx("div",{className:"nice-network-discovery__card-ip",children:D.ipAddress}),D.vendor&&e.jsx("div",{className:"nice-network-discovery__card-vendor",children:D.vendor}),D.isRogue&&e.jsx("span",{className:"nice-network-discovery__rogue-badge",children:f("networkDiscovery.rogue","Rogue!")}),D.tags?.map(M=>e.jsx("span",{className:"nice-network-discovery__tag",children:M},M))]},D.id))}),b==="topology"&&e.jsx("div",{className:"nice-network-discovery__topology",role:"tabpanel","aria-label":f("networkDiscovery.networkTopology","Network topology"),children:e.jsxs("svg",{width:"100%",height:"400","aria-label":f("networkDiscovery.networkTopologyDiagram","Network topology diagram"),children:[n?.links.map((D,M)=>{const O=t.find(q=>q.id===D.sourceId),L=t.find(q=>q.id===D.targetId);if(!O||!L)return null;const V=t.indexOf(O),ee=t.indexOf(L),z=6,U=V%z*140+70,re=Math.floor(V/z)*120+60,Y=ee%z*140+70,oe=Math.floor(ee/z)*120+60;return e.jsx("line",{x1:U,y1:re,x2:Y,y2:oe,stroke:"var(--nice-text-muted, #94a3b8)",strokeWidth:1.5},M)}),B.map((D,M)=>{const L=M%6*140+70,V=Math.floor(M/6)*120+60;return e.jsxs("g",{onClick:()=>a(D.id),role:"button","aria-label":D.hostname??D.ipAddress,style:{cursor:"pointer"},children:[e.jsx("circle",{cx:L,cy:V,r:22,fill:Ha[D.status],opacity:.2}),e.jsx("circle",{cx:L,cy:V,r:18,fill:"white",stroke:Ha[D.status],strokeWidth:2}),e.jsx("foreignObject",{x:L-10,y:V-10,width:20,height:20,"aria-hidden":"true",style:{pointerEvents:"none"},children:e.jsx(l.NiceIcon,{name:Ga[D.category],size:20})}),e.jsx("text",{x:L,y:V+36,textAnchor:"middle",fontSize:10,fill:"var(--nice-text-secondary, #475569)",children:(D.hostname??D.ipAddress).substring(0,14)})]},D.id)})]})}),b==="map"&&e.jsxs("div",{className:"nice-network-discovery__map",role:"tabpanel",children:[e.jsxs("p",{className:"nice-network-discovery__map-hint",children:[f("networkDiscovery.mapHint","The map view needs the")," ",e.jsx("code",{children:"NiceMap"})," ",f("networkDiscovery.mapHintEnd","component.")]}),e.jsx("div",{className:"nice-network-discovery__map-pins",children:B.filter(D=>D.location).map(D=>e.jsx("button",{className:`nice-network-discovery__map-pin nice-network-discovery__map-pin--${D.status}`,onClick:()=>a(D.id),type:"button","aria-label":`${D.hostname??D.ipAddress} — ${D.location?.room??""}`,title:`${D.hostname??D.ipAddress} (${D.location?.room??""})`,children:e.jsx(l.NiceIcon,{name:Ga[D.category],size:16})},D.id))})]})]})},Xc={get:"var(--nice-color-success, #22c55e)",post:"var(--nice-color-primary, #3b82f6)",put:"var(--nice-color-warning, #f59e0b)",patch:"var(--nice-accent, #a855f7)",delete:"var(--nice-color-error, #ef4444)",head:"var(--nice-text-muted, #6b7280)",options:"var(--nice-text-muted, #6b7280)"};function Oj(t){if(!t?.paths)return[];const n=[];for(const[i,a]of Object.entries(t.paths))for(const[s,o]of Object.entries(a))n.push({...o,method:s,path:i});return n}const Lj=({specUrl:t,spec:n,baseUrl:i,authToken:a,onRequest:s,onResponse:o,showTryIt:c=!0,showSchemas:d=!0,showSearch:p=!0,groupBy:m="tag",theme:h="light",layout:u="sidebar",className:x,style:f,"data-testid":b})=>{const{t:g}=l.useNiceTranslation(),[v]=r.useState(n??null),[y,C]=r.useState(""),[w,E]=r.useState(null),[S,N]=r.useState({}),[_,k]=r.useState(""),[j,T]=r.useState(null),[P,B]=r.useState(!1),[R,I]=r.useState("detail"),D=i??v?.servers?.[0]?.url??"",O=Oj(v).filter(z=>{if(!y)return!0;const U=y.toLowerCase();return z.path.toLowerCase().includes(U)||(z.summary?.toLowerCase().includes(U)??!1)||z.method.toLowerCase().includes(U)}),L={};for(const z of O){let U=z.path;m==="tag"?U=z.tags?.[0]??"default":m==="method"&&(U=z.method.toUpperCase()),L[U]||(L[U]=[]),L[U].push(z)}const V=async()=>{if(!w)return;let z=w.path;for(const[q,se]of Object.entries(S))z=z.replace(`{${q}}`,encodeURIComponent(se));const U=`${D}${z}`,re={"Content-Type":"application/json"};a&&(re.Authorization=`Bearer ${a}`);const Y={method:w.method,path:w.path,params:S,body:_?JSON.parse(_):void 0};s?.(Y),B(!0);const oe=Date.now();try{const q=await fetch(U,{method:w.method.toUpperCase(),headers:re,body:["post","put","patch"].includes(w.method)&&_?_:void 0}),se=await q.text(),ce=Date.now()-oe;T({status:q.status,body:se,duration:ce}),o?.({status:q.status,body:JSON.parse(se),durationMs:ce})}catch(q){T({status:0,body:String(q),duration:Date.now()-oe})}finally{B(!1)}},ee=z=>{if(!z)return"";const U=a?` -H "Authorization: Bearer ${a}"`:"";return`curl -X ${z.method.toUpperCase()}${U} "${D}${z.path}"`};return e.jsxs("div",{className:`nice-api-explorer nice-api-explorer--${u} nice-api-explorer--${h} ${x??""}`,style:f,"data-testid":b,children:[e.jsxs("aside",{className:"nice-api-explorer__sidebar","aria-label":g("devTools.endpointList","Endpoint list"),children:[v?.info&&e.jsxs("div",{className:"nice-api-explorer__api-info",children:[e.jsx("h2",{className:"nice-api-explorer__api-title",children:v.info.title}),e.jsxs("span",{className:"nice-api-explorer__api-version",children:["v",v.info.version]})]}),!v&&t&&e.jsxs("p",{className:"nice-api-explorer__loading",children:[g("devTools.loadingSpecFrom","Loading the specification from")," ",e.jsx("code",{children:t}),"…"]}),p&&e.jsx("input",{type:"search",placeholder:g("devTools.searchEndpointPlaceholder","Search endpoints…"),value:y,onChange:z=>C(z.target.value),className:"nice-api-explorer__search","aria-label":g("devTools.searchEndpoint","Search endpoints")}),Object.entries(L).map(([z,U])=>e.jsxs("div",{className:"nice-api-explorer__group",children:[e.jsx("h3",{className:"nice-api-explorer__group-title",children:z}),U.map(re=>e.jsxs("button",{className:`nice-api-explorer__endpoint-btn${w?.path===re.path&&w?.method===re.method?" nice-api-explorer__endpoint-btn--active":""}`,onClick:()=>{E(re),N({}),T(null)},type:"button",children:[e.jsx("span",{className:"nice-api-explorer__method-badge",style:{background:Xc[re.method]??"var(--nice-bg-tertiary, #6b7280)"},children:re.method.toUpperCase()}),e.jsx("span",{className:"nice-api-explorer__path",children:re.path})]},`${re.method}:${re.path}`))]},z)),d&&v?.components?.schemas&&e.jsxs("div",{className:"nice-api-explorer__group",children:[e.jsx("h3",{className:"nice-api-explorer__group-title",children:g("devTools.schemas","Schemas")}),Object.keys(v.components.schemas).map(z=>e.jsx("button",{className:"nice-api-explorer__schema-btn",onClick:()=>{E(null),I("schemas")},type:"button",children:z},z))]})]}),e.jsx("main",{className:"nice-api-explorer__detail","aria-label":g("devTools.endpointDetails","Endpoint details"),children:w?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"nice-api-explorer__endpoint-header",children:[e.jsx("span",{className:"nice-api-explorer__method-badge nice-api-explorer__method-badge--lg",style:{background:Xc[w.method]},children:w.method.toUpperCase()}),e.jsx("code",{className:"nice-api-explorer__path-display",children:w.path})]}),w.summary&&e.jsx("p",{className:"nice-api-explorer__summary",children:w.summary}),w.description&&e.jsx("p",{className:"nice-api-explorer__desc",children:w.description}),(w.parameters??[]).length>0&&e.jsxs("section",{className:"nice-api-explorer__params","aria-labelledby":"nice-api-params-title",children:[e.jsx("h4",{id:"nice-api-params-title",children:g("devTools.parameters","Parameters")}),e.jsxs("table",{className:"nice-api-explorer__params-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:g("devTools.columnName","Name")}),e.jsx("th",{children:g("devTools.columnIn","In")}),e.jsx("th",{children:g("devTools.columnRequired","Required")}),e.jsx("th",{children:g("devTools.columnType","Type")}),e.jsx("th",{children:g("devTools.columnValue","Value")})]})}),e.jsx("tbody",{children:(w.parameters??[]).map(z=>e.jsxs("tr",{children:[e.jsx("td",{children:e.jsx("code",{children:z.name})}),e.jsx("td",{children:z.in}),e.jsx("td",{children:z.required?e.jsx(l.NiceIcon,{name:"check",size:14}):"—"}),e.jsx("td",{children:z.schema?.type??"—"}),e.jsx("td",{children:c&&(z.schema?.enum?e.jsxs("select",{value:S[z.name]??"",onChange:U=>N(re=>({...re,[z.name]:U.target.value})),"aria-label":`${g("devTools.parameterValue","Parameter value")}: ${z.name}`,children:[e.jsx("option",{value:"",children:"—"}),z.schema.enum.map(U=>e.jsx("option",{value:U,children:U},U))]}):e.jsx("input",{type:"text",value:S[z.name]??"",onChange:U=>N(re=>({...re,[z.name]:U.target.value})),placeholder:String(z.schema?.example??""),"aria-label":`${g("devTools.parameterValue","Parameter value")}: ${z.name}`}))})]},z.name))})]})]}),w.requestBody&&c&&e.jsxs("section",{className:"nice-api-explorer__body-section","aria-labelledby":"nice-api-body-title",children:[e.jsx("h4",{id:"nice-api-body-title",children:g("devTools.requestBody","Request Body")}),e.jsx("textarea",{className:"nice-api-explorer__body-editor",value:_,onChange:z=>k(z.target.value),rows:8,placeholder:g("devTools.jsonBody","JSON body…"),"aria-label":g("devTools.requestBodyJson","Request body (JSON)"),spellCheck:!1})]}),c&&e.jsxs("section",{className:"nice-api-explorer__try-it","aria-labelledby":"nice-api-try-title",children:[e.jsx("h4",{id:"nice-api-try-title",children:g("devTools.tryItOut","Try it out")}),e.jsx("button",{className:"nice-api-explorer__send-btn",onClick:V,disabled:P,type:"button",children:P?g("devTools.sending","Sending…"):e.jsxs(e.Fragment,{children:[e.jsx(l.NiceIcon,{name:"play",size:14})," ",g("devTools.send","Send")]})}),j&&e.jsxs("div",{className:"nice-api-explorer__response",children:[e.jsxs("div",{className:"nice-api-explorer__response-meta",children:[e.jsx("span",{className:`nice-api-explorer__status-badge nice-api-explorer__status-badge--${Math.floor(j.status/100)}xx`,children:j.status}),e.jsxs("span",{className:"nice-api-explorer__duration",children:[j.duration,"ms"]})]}),e.jsx("pre",{className:"nice-api-explorer__response-body",children:(()=>{try{return JSON.stringify(JSON.parse(j.body),null,2)}catch{return j.body}})()})]})]}),e.jsxs("section",{className:"nice-api-explorer__code-samples","aria-labelledby":"nice-api-code-title",children:[e.jsx("h4",{id:"nice-api-code-title",children:g("devTools.codeSamples","Code samples")}),e.jsx("pre",{className:"nice-api-explorer__code-block",children:e.jsx("code",{children:ee(w)})}),e.jsx("button",{className:"nice-api-explorer__copy-btn",onClick:()=>navigator.clipboard.writeText(ee(w)),type:"button","aria-label":g("devTools.copyCurl","Copy cURL"),children:g("devTools.copyCurl","Copy cURL")})]}),w.responses&&e.jsxs("section",{className:"nice-api-explorer__responses","aria-labelledby":"nice-api-responses-title",children:[e.jsx("h4",{id:"nice-api-responses-title",children:g("devTools.responses","Responses")}),Object.entries(w.responses).map(([z,U])=>e.jsxs("div",{className:"nice-api-explorer__response-schema",children:[e.jsx("span",{className:`nice-api-explorer__status-badge nice-api-explorer__status-badge--${z[0]}xx`,children:z}),e.jsx("span",{children:U.description})]},z))]})]}):e.jsx("div",{className:"nice-api-explorer__empty",children:g("devTools.selectEndpoint","Select an endpoint from the list on the left")})})]})},zj=[{label:"Mobile",width:375},{label:"Tablet",width:768},{label:"Desktop",width:1280},{label:"Wide",width:1920},{label:"Custom",width:0}],Bj=["white","transparent","dark","checkerboard"];function Fj(t,n){const i=Object.entries(n).filter(([,a])=>a!==void 0).map(([a,s])=>typeof s=="boolean"?s?a:`${a}={false}`:typeof s=="string"?`${a}="${s}"`:`${a}={${JSON.stringify(s)}}`).join(" ");return`<${t}${i?" "+i:""} />`}const qj=({components:t,componentName:n,defaultProps:i,showPropsPanel:a=!0,showCodePreview:s=!0,showA11yAudit:o=!0,showResponsivePreview:c=!0,showThemeSwitch:d=!0,showHistory:p=!1,layout:m="sidebar",className:h,style:u,"data-testid":x})=>{const f=r.useRef(null);l.useRovingFocus(f,{orientation:"horizontal",wrap:!0,activateOnMove:!0});const b=r.useRef(null);l.useRovingFocus(b,{orientation:"horizontal",itemSelector:"button"});const{t:g}=l.useNiceTranslation(),v=r.useMemo(()=>t&&t.length>0?t:n?[{name:n,component:H=>e.jsx("pre",{style:{margin:0,fontSize:12},children:`<${n} ${Object.entries(H).filter(([,A])=>A!==void 0).map(([A,Z])=>`${A}=${JSON.stringify(Z)}`).join(" ")} />`}),category:"preview",description:g("devTools.quickPreviewOf","Quick preview of {componentName}").replace("{componentName}",String(n)),props:Object.entries(i??{}).map(([H,A])=>({name:H,type:typeof A,defaultValue:A,label:H}))}]:[],[t,n,i,g]),[y,C]=r.useState(""),[w,E]=r.useState(v[0]??null),[S,N]=r.useState({}),[_,k]=r.useState([]),[j,T]=r.useState(-1),[P,B]=r.useState("white"),[R,I]=r.useState(100),[D,M]=r.useState(1280),[O,L]=r.useState(800),[V,ee]=r.useState("detail"),[z,U]=r.useState(!1),re=F=>{const H={};for(const A of F.props)A.defaultValue!==void 0&&(H[A.name]=A.defaultValue);N(H),k([H]),T(0)},Y=F=>{E(F),re(F),ee("detail")},oe=(F,H)=>{const A={...S,[F]:H};if(N(A),p){const Z=_.slice(0,j+1);Z.push(A),k(Z),T(Z.length-1)}},q=()=>{if(j>0){const F=j-1;T(F),N(_[F])}},se=()=>{if(j<_.length-1){const F=j+1;T(F),N(_[F])}},ce=F=>{N(F.props)},le=v.filter(F=>F.name.toLowerCase().includes(y.toLowerCase())||F.category.toLowerCase().includes(y.toLowerCase())),J=[...new Set(le.map(F=>F.category))],me=w?w.examples?.find(F=>JSON.stringify(F.props)===JSON.stringify(S))?.code??Fj(w.name,S):"",je=F=>{const H=S[F.name];switch(F.control??(F.type==="boolean"?"toggle":F.type==="number"?"number":F.enumValues?"select":"text")){case"toggle":return e.jsxs("label",{className:"nice-playground__prop-row",children:[e.jsxs("span",{className:"nice-playground__prop-name",children:[F.name,F.required&&e.jsx("span",{"aria-label":g("devTools.required","required"),children:" *"})]}),e.jsx("input",{type:"checkbox",checked:!!H,onChange:Z=>oe(F.name,Z.target.checked),"aria-label":F.name})]},F.name);case"number":return e.jsxs("label",{className:"nice-playground__prop-row",children:[e.jsxs("span",{className:"nice-playground__prop-name",children:[F.name,F.required&&e.jsx("span",{"aria-label":g("devTools.required","required"),children:" *"})]}),e.jsx("input",{type:"number",value:Number(H??0),onChange:Z=>oe(F.name,Number(Z.target.value)),"aria-label":F.name})]},F.name);case"select":return e.jsxs("label",{className:"nice-playground__prop-row",children:[e.jsxs("span",{className:"nice-playground__prop-name",children:[F.name,F.required&&e.jsx("span",{"aria-label":g("devTools.required","required"),children:" *"})]}),e.jsxs("select",{value:String(H??""),onChange:Z=>oe(F.name,Z.target.value),"aria-label":F.name,children:[!F.required&&e.jsx("option",{value:"",children:"—"}),F.enumValues?.map(Z=>e.jsx("option",{value:Z,children:Z},Z))]})]},F.name);case"color":return e.jsxs("label",{className:"nice-playground__prop-row",children:[e.jsxs("span",{className:"nice-playground__prop-name",children:[F.name,F.required&&e.jsx("span",{"aria-label":g("devTools.required","required"),children:" *"})]}),e.jsx("input",{type:"color",value:String(H??"#000000"),onChange:Z=>oe(F.name,Z.target.value),"aria-label":F.name})]},F.name);case"slider":return e.jsxs("label",{className:"nice-playground__prop-row",children:[e.jsxs("span",{className:"nice-playground__prop-name",children:[F.name,F.required&&e.jsx("span",{"aria-label":g("devTools.required","required"),children:" *"})]}),e.jsx("input",{type:"range",value:Number(H??0),onChange:Z=>oe(F.name,Number(Z.target.value)),"aria-label":F.name}),e.jsx("span",{children:String(H??0)})]},F.name);case"json":case"code":return e.jsxs("label",{className:"nice-playground__prop-row nice-playground__prop-row--code",children:[e.jsxs("span",{className:"nice-playground__prop-name",children:[F.name,F.required&&e.jsx("span",{"aria-label":g("devTools.required","required"),children:" *"})]}),e.jsx("textarea",{value:typeof H=="object"?JSON.stringify(H,null,2):String(H??""),onChange:Z=>{try{oe(F.name,JSON.parse(Z.target.value))}catch{oe(F.name,Z.target.value)}},rows:4,"aria-label":F.name,spellCheck:!1})]},F.name);default:return e.jsxs("label",{className:"nice-playground__prop-row",children:[e.jsxs("span",{className:"nice-playground__prop-name",children:[F.name,F.required&&e.jsx("span",{"aria-label":g("devTools.required","required"),children:" *"})]}),e.jsx("input",{type:"text",value:String(H??""),onChange:Z=>oe(F.name,Z.target.value),"aria-label":F.name})]},F.name)}},ue=w?.component;return e.jsxs("div",{className:`nice-playground nice-playground--${m} ${h??""}`,style:u,"data-testid":x,children:[e.jsxs("aside",{className:"nice-playground__tree","aria-label":g("devTools.componentList","Component list"),children:[e.jsx("input",{type:"search",placeholder:g("devTools.searchComponentPlaceholder","Search components (Ctrl+P)…"),value:y,onChange:F=>C(F.target.value),className:"nice-playground__tree-search","aria-label":g("devTools.searchComponent","Search components")}),J.map(F=>e.jsxs("div",{className:"nice-playground__tree-group",children:[e.jsx("h3",{className:"nice-playground__tree-group-title",children:F}),le.filter(H=>H.category===F).map(H=>e.jsx("button",{className:`nice-playground__tree-item${w?.name===H.name?" nice-playground__tree-item--active":""}`,onClick:()=>Y(H),type:"button",children:H.name},H.name))]},F))]}),e.jsxs("div",{className:"nice-playground__main",children:[e.jsxs("div",{ref:b,className:"nice-playground__canvas-toolbar",role:"toolbar","aria-label":g("devTools.canvasTools","Canvas tools"),children:[Bj.map(F=>e.jsx("button",{className:`nice-playground__bg-btn${P===F?" nice-playground__bg-btn--active":""}`,onClick:()=>B(F),type:"button","aria-pressed":P===F,children:F==="white"?g("devTools.canvasBgWhite","White"):F==="transparent"?g("devTools.canvasBgTransparent","Transparent"):F==="dark"?g("devTools.canvasBgDark","Dark"):g("devTools.canvasBgCheckerboard","Checkerboard")},F)),e.jsxs("label",{className:"nice-playground__zoom",children:[g("devTools.zoom","Zoom"),e.jsx("select",{value:R,onChange:F=>I(Number(F.target.value)),"aria-label":g("devTools.zoomCanvas","Zoom canvas"),children:[50,75,100,125,150,200].map(F=>e.jsxs("option",{value:F,children:[F,"%"]},F))})]}),d&&e.jsx("button",{onClick:()=>U(F=>!F),type:"button","aria-pressed":z,children:z?g("devTools.lightPreview","Light"):g("devTools.darkPreview","Dark")}),p&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:q,disabled:j<=0,type:"button","aria-label":g("devTools.undoPropChanges","Undo prop changes"),children:[e.jsx(l.NiceIcon,{name:"reply",size:14})," ",g("devTools.undo","Undo")]}),e.jsxs("button",{onClick:se,disabled:j>=_.length-1,type:"button","aria-label":g("devTools.redoPropChanges","Redo prop changes"),children:[e.jsx(l.NiceIcon,{name:"forward",size:14})," ",g("devTools.redo","Redo")]})]})]}),e.jsx("div",{className:`nice-playground__canvas nice-playground__canvas--${P}${z?" nice-playground__canvas--dark":""}`,style:{transform:`scale(${R/100})`,transformOrigin:"top left"},"aria-label":g("devTools.componentPreview","Component preview"),children:ue?e.jsx(ue,{...S}):e.jsx("div",{className:"nice-playground__canvas-empty",children:g("devTools.selectComponent","Select a component from the list")})}),w&&e.jsxs("div",{className:"nice-playground__panels",children:[e.jsxs("div",{className:"nice-playground__panel-tabs",ref:f,role:"tablist",children:[e.jsx("button",{role:"tab","aria-selected":V==="detail",onClick:()=>ee("detail"),className:V==="detail"?"nice-playground__panel-tab--active":"",type:"button",children:g("devTools.tabProps","Props")}),s&&e.jsx("button",{role:"tab","aria-selected":!1,onClick:()=>{},className:"",type:"button",children:g("devTools.tabCode","Code")}),c&&e.jsx("button",{role:"tab","aria-selected":V==="responsive",onClick:()=>ee("responsive"),className:V==="responsive"?"nice-playground__panel-tab--active":"",type:"button",children:g("devTools.responsive","Responsive")}),o&&e.jsx("button",{role:"tab","aria-selected":V==="a11y",onClick:()=>ee("a11y"),className:V==="a11y"?"nice-playground__panel-tab--active":"",type:"button",children:"A11y"}),e.jsx("button",{role:"tab","aria-selected":V==="examples",onClick:()=>ee("examples"),className:V==="examples"?"nice-playground__panel-tab--active":"",type:"button",children:g("devTools.tabExamples","Examples")}),w.changelog&&e.jsx("button",{role:"tab","aria-selected":V==="changelog",onClick:()=>ee("changelog"),className:V==="changelog"?"nice-playground__panel-tab--active":"",type:"button",children:g("devTools.changelog","Changelog")})]}),V==="detail"&&a&&e.jsxs("div",{className:"nice-playground__props-panel",role:"tabpanel",children:[e.jsx("p",{className:"nice-playground__component-desc",children:w.description}),w.props.map(je)]}),s&&e.jsxs("div",{className:"nice-playground__code-panel",role:"tabpanel","aria-label":g("devTools.codePreview","Code preview"),children:[e.jsx("pre",{className:"nice-playground__code-block",children:e.jsx("code",{children:me})}),e.jsx("button",{onClick:()=>navigator.clipboard.writeText(me),type:"button",className:"nice-playground__copy-btn","aria-label":g("devTools.copyJsx","Copy JSX"),children:g("devTools.copy","Copy")})]}),V==="responsive"&&c&&e.jsxs("div",{className:"nice-playground__responsive-panel",role:"tabpanel",children:[e.jsxs("div",{className:"nice-playground__responsive-presets",role:"group","aria-label":g("devTools.responsivePresets","Resolution presets"),children:[zj.map((F,H)=>e.jsxs("button",{className:`nice-playground__preset-btn${D===(F.width||O)?" nice-playground__preset-btn--active":""}`,onClick:()=>{F.width>0?M(F.width):M(O)},type:"button","aria-keyshortcuts":`${H+1}`,children:[F.label,F.width>0?` (${F.width}px)`:""]},F.label)),e.jsx("input",{type:"number",value:O,onChange:F=>{L(Number(F.target.value)),M(Number(F.target.value))},min:200,max:3840,"aria-label":g("devTools.customWidthPx","Custom width in pixels")})]}),e.jsx("div",{className:"nice-playground__responsive-frame",style:{width:D,overflow:"hidden",border:"1px dashed var(--nice-border-color, #94a3b8)",resize:"horizontal"},children:ue&&e.jsx(ue,{...S})})]}),V==="a11y"&&o&&e.jsxs("div",{className:"nice-playground__a11y-panel",role:"tabpanel",children:[e.jsx("p",{className:"nice-playground__a11y-hint",children:g("devTools.a11yHint","The automatic accessibility audit checks colour contrast, ARIA roles, tab order and keyboard navigation. A full audit requires integrating a library such as axe-core.")}),e.jsxs("ul",{className:"nice-playground__a11y-checks",children:[e.jsxs("li",{className:"nice-playground__a11y-check nice-playground__a11y-check--info",children:[e.jsx(l.NiceIcon,{name:"info",size:14})," ",g("devTools.a11yCheckFocus","Check manually: every interactive element has a visible focus ring")]}),e.jsxs("li",{className:"nice-playground__a11y-check nice-playground__a11y-check--info",children:[e.jsx(l.NiceIcon,{name:"info",size:14})," ",g("devTools.a11yCheckAlt","Check manually: images have an alt attribute")]}),e.jsxs("li",{className:"nice-playground__a11y-check nice-playground__a11y-check--info",children:[e.jsx(l.NiceIcon,{name:"info",size:14})," ",g("devTools.a11yCheckLabels","Check manually: form fields have associated labels")]})]})]}),V==="examples"&&e.jsx("div",{className:"nice-playground__examples-panel",role:"tabpanel",children:(w.examples??[]).length===0?e.jsx("p",{children:g("devTools.noExamples","No examples for this component")}):w.examples.map((F,H)=>e.jsxs("div",{className:"nice-playground__example",children:[e.jsxs("div",{className:"nice-playground__example-header",children:[e.jsx("strong",{children:F.name}),e.jsx("button",{onClick:()=>ce(F),type:"button",children:g("devTools.applyExample","Apply")})]}),e.jsx("p",{children:F.description})]},H))}),V==="changelog"&&w.changelog&&e.jsx("div",{className:"nice-playground__changelog-panel",role:"tabpanel",children:w.changelog.map((F,H)=>e.jsxs("div",{className:"nice-playground__changelog-entry",children:[e.jsxs("h4",{children:["v",F.version,F.date?` — ${F.date}`:""]}),e.jsx("ul",{children:F.changes.map((A,Z)=>e.jsx("li",{children:A},Z))})]},H))})]})]})]})},Zc=104,Vj=106;function el(t){const n=[Zc];let i=Zc;for(let a=0;a<t.length;a++){const s=t.charCodeAt(a)-32;n.push(s),i+=s*(a+1)}return n.push(i%103),n.push(Vj),n}const tl=["11011001100","11001101100","11001100110","10010011000","10010001100","10001001100","10011001000","10011000100","10001100100","11001001000","11001000100","11000100100","10110011100","10011011100","10011001110","10111001100","10011101100","10011100110","11001110010","11001011100","11001001110","11011100100","11001110100","11101101110","11101001100","11100101100","11100100110","11101100100","11100110100","11100110010","11011011000","11011000110","11000110110","10100011000","10001011000","10001000110","10110001000","10001101000","10001100010","11010001000","11000101000","11000100010","10110111000","10110001110","10001101110","10111011000","10111000110","10001110110","11101110110","11010001110","11000101110","11011101000","11011100010","11011101110","11101011000","11101000110","11100010110","11101101000","11101100010","11100011010","11101111010","11001000010","11110001010","10100110000","10100001100","10010110000","10010000110","10000101100","10000100110","10110010000","10110000100","10011010000","10011000010","10000110100","10000110010","11000010010","11001010000","11110111010","11000010100","10001111010","10100111100","10010111100","10010011110","10111100100","10011110100","10011110010","11110100100","11110010100","11110010010","11011011110","11011110110","11110110110","10101111000","10100011110","10001011110","10111101000","10111100010","11110101000","11110100010","10111011110","10111101110","11101011110","11110101110","11010000100","11010010000","11010011100","1100011101011"];function Uj(t){const n={0:"101001101101",1:"110100101011",2:"101100101011",3:"110110010101",4:"101001101011",5:"110100110101",6:"101100110101",7:"101001011011",8:"110100101101",9:"110110010110",A:"110101001011",B:"101101001011",C:"110110100101",D:"101011001011",E:"110101100101",F:"101101100101",G:"101010011011",H:"110101001101",I:"101101001101",J:"101011001101",K:"110101010011",L:"101101010011",M:"110110101001",N:"101011010011",O:"110101101001",P:"101101101001",Q:"101010110011",R:"110101011001",S:"101101011001",T:"101011011001",U:"110010101011",V:"100110101011",W:"110011010101",X:"100101101011",Y:"110010110101",Z:"100110110101","-":"100101011011"," ":"100110101101",".":"110010101101","*":"100101101101"},i=[],a=`*${t.toUpperCase()}*`;for(const s of a){const o=n[s];o&&i.push(o)}return i}const Ru=Object.assign(r.forwardRef(({value:t,defaultValue:n,format:i="CODE128",width:a,height:s=80,barWidth:o=2,barColor:c,background:d,showText:p=!0,fontSize:m=14,size:h="md",showInput:u=!1,editable:x,inputLabel:f,inputPlaceholder:b,labelPlacement:g,inputProps:v,onValueChange:y,className:C,style:w,id:E,testId:S,"data-testid":N,..._},k)=>{const{t:j}=l.useNiceTranslation(),T=x??u,P=l.useControlId(E),B=r.useRef(null),R=k??B,I=l.useThemeIsDark(R),D=c||(I?"#f8fafc":"#111827"),M=d||"transparent",[O,L]=l.useControllableState({value:t,defaultValue:n,fallbackValue:"",onChange:y,componentName:"NiceBarcode"}),[V,ee]=r.useState(O);r.useEffect(()=>{ee(O)},[O]);const z=T?V:O,U=Y=>{ee(Y),L(Y)};r.useEffect(()=>{const Y=typeof R=="object"&&R?.current?R.current:B.current;if(!Y)return;const oe=Y.getContext("2d");if(!oe)return;let q="";i==="CODE128"?q=el(z).map(ue=>tl[ue]??"").join(""):i==="CODE39"?q=Uj(z).join("0"):q=el(z).map(ue=>tl[ue]??"").join("");const se=o&&o>0?o:2,ce=q.length*se,le=p?m+8:0,J=a&&a>0?a:ce+20;Y.width=J,Y.height=s+le,oe.clearRect(0,0,Y.width,Y.height),M!=="transparent"&&(oe.fillStyle=M,oe.fillRect(0,0,Y.width,Y.height));const me=(J-ce)/2;oe.fillStyle=D;for(let je=0;je<q.length;je++)q[je]==="1"&&oe.fillRect(me+je*se,0,se,s);p&&(oe.fillStyle=D,oe.font=`${m}px monospace`,oe.textAlign="center",oe.fillText(z,Y.width/2,s+m+2))},[z,i,a,s,o,D,M,p,m,R,T]);const re=e.jsx("canvas",{ref:B,id:T?void 0:P,className:`nice-barcode nice-barcode--${h}${T?"":` ${C??""}`}`,style:T?void 0:w,"data-testid":T?void 0:N??S,role:"img","aria-label":j("barcodeGenerator.barcode","Barcode: {encodedValue}").replace("{encodedValue}",String(z)),...T?{}:_});return T?e.jsxs("div",{id:P,className:`nice-barcode-field nice-barcode-field--${h} ${C??""}`,style:{display:"inline-flex",flexDirection:"column",gap:8,...w},"data-testid":N??S,..._,children:[e.jsx(Oe.NiceTextInput,{...v,label:f??v?.label,placeholder:b??v?.placeholder,labelPlacement:g??v?.labelPlacement,size:h,value:V,onChange:U}),re]}):re}),{displayName:"NiceBarcode"}),Hj={L:0,M:1,Q:2,H:3},Gj={M:0,L:1,H:2,Q:3},$u=Wj();function Wj(){const t=new Uint8Array(256),n=new Uint8Array(256);let i=1;for(let a=0;a<255;a++)t[a]=i,i<<=1,i&256&&(i^=285);for(let a=0;a<255;a++)n[t[a]]=a;return{exp:t,log:n}}function fo(t){for(;t<0;)t+=255;for(;t>=255;)t-=255;return $u.exp[t]}function ys(t){return $u.log[t]}function Kj(t,n){const i=new Array(t.length+n.length-1).fill(0);for(let a=0;a<t.length;a++)for(let s=0;s<n.length;s++)i[a+s]^=fo(ys(t[a])+ys(n[s]));return i}function Yj(t){let n=[1];for(let i=0;i<t;i++)n=Kj(n,[1,fo(i)]);return n}function Jj(t,n){const i=Yj(n),a=t.concat(new Array(n).fill(0));for(let s=0;s<t.length;s++){const o=a[s];if(o!==0){const c=ys(o);for(let d=0;d<i.length;d++)a[s+d]^=fo(ys(i[d])+c)}}return a.slice(t.length)}const Qj=[[1,26,19],[1,26,16],[1,26,13],[1,26,9],[1,44,34],[1,44,28],[1,44,22],[1,44,16],[1,70,55],[1,70,44],[2,35,17],[2,35,13],[1,100,80],[2,50,32],[2,50,24],[4,25,9],[1,134,108],[2,67,43],[2,33,15,2,34,16],[2,33,11,2,34,12],[2,86,68],[4,43,27],[4,43,19],[4,43,15],[2,98,78],[4,49,31],[2,32,14,4,33,15],[4,39,13,1,40,14],[2,121,97],[2,60,38,2,61,39],[4,40,18,2,41,19],[4,40,14,2,41,15],[2,146,116],[3,58,36,2,59,37],[4,36,16,4,37,17],[4,36,12,4,37,13],[2,86,68,2,87,69],[4,69,43,1,70,44],[6,43,19,2,44,20],[6,43,15,2,44,16],[4,101,81],[1,80,50,4,81,51],[4,50,22,4,51,23],[3,36,12,8,37,13],[2,116,92,2,117,93],[6,58,36,2,59,37],[4,46,20,6,47,21],[7,42,14,4,43,15],[4,133,107],[8,59,37,1,60,38],[8,44,20,4,45,21],[12,33,11,4,34,12],[3,145,115,1,146,116],[4,64,40,5,65,41],[11,36,16,5,37,17],[11,36,12,5,37,13],[5,109,87,1,110,88],[5,65,41,5,66,42],[5,54,24,7,55,25],[11,36,12,7,37,13],[5,122,98,1,123,99],[7,73,45,3,74,46],[15,43,19,2,44,20],[3,45,15,13,46,16],[1,135,107,5,136,108],[10,74,46,1,75,47],[1,50,22,15,51,23],[2,42,14,17,43,15],[5,150,120,1,151,121],[9,69,43,4,70,44],[17,50,22,1,51,23],[2,42,14,19,43,15],[3,141,113,4,142,114],[3,70,44,11,71,45],[17,47,21,4,48,22],[9,39,13,16,40,14],[3,135,107,5,136,108],[3,67,41,13,68,42],[15,54,24,5,55,25],[15,43,15,10,44,16],[4,144,116,4,145,117],[17,68,42],[17,50,22,6,51,23],[19,46,16,6,47,17],[2,139,111,7,140,112],[17,74,46],[7,54,24,16,55,25],[34,37,13],[4,151,121,5,152,122],[4,75,47,14,76,48],[11,54,24,14,55,25],[16,45,15,14,46,16],[6,147,117,4,148,118],[6,73,45,14,74,46],[11,54,24,16,55,25],[30,46,16,2,47,17],[8,132,106,4,133,107],[8,75,47,13,76,48],[7,54,24,22,55,25],[22,45,15,13,46,16],[10,142,114,2,143,115],[19,74,46,4,75,47],[28,50,22,6,51,23],[33,46,16,4,47,17],[8,152,122,4,153,123],[22,73,45,3,74,46],[8,53,23,26,54,24],[12,45,15,28,46,16],[3,147,117,10,148,118],[3,73,45,23,74,46],[4,54,24,31,55,25],[11,45,15,31,46,16],[7,146,116,7,147,117],[21,73,45,7,74,46],[1,53,23,37,54,24],[19,45,15,26,46,16],[5,145,115,10,146,116],[19,75,47,10,76,48],[15,54,24,25,55,25],[23,45,15,25,46,16],[13,145,115,3,146,116],[2,74,46,29,75,47],[42,54,24,1,55,25],[23,45,15,28,46,16],[17,145,115],[10,74,46,23,75,47],[10,54,24,35,55,25],[19,45,15,35,46,16],[17,145,115,1,146,116],[14,74,46,21,75,47],[29,54,24,19,55,25],[11,45,15,46,46,16],[13,145,115,6,146,116],[14,74,46,23,75,47],[44,54,24,7,55,25],[59,46,16,1,47,17],[12,151,121,7,152,122],[12,75,47,26,76,48],[39,54,24,14,55,25],[22,45,15,41,46,16],[6,151,121,14,152,122],[6,75,47,34,76,48],[46,54,24,10,55,25],[2,45,15,64,46,16],[17,152,122,4,153,123],[29,74,46,14,75,47],[49,54,24,10,55,25],[24,45,15,46,46,16],[4,152,122,18,153,123],[13,74,46,32,75,47],[48,54,24,14,55,25],[42,45,15,32,46,16],[20,147,117,4,148,118],[40,75,47,7,76,48],[43,54,24,22,55,25],[10,45,15,67,46,16],[19,148,118,6,149,119],[18,75,47,31,76,48],[34,54,24,34,55,25],[20,45,15,61,46,16]];function Mu(t,n){const i=Qj[(t-1)*4+Hj[n]],a=[];for(let s=0;s<i.length;s+=3){const o=i[s],c=i[s+1],d=i[s+2];for(let p=0;p<o;p++)a.push({totalCount:c,dataCount:d})}return a}const Xj=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],Js=1335,Zj=21522,Qs=7973;function qn(t){let n=0;for(;t!==0;)n++,t>>>=1;return n}function ew(t){let n=t<<10;for(;qn(n)-qn(Js)>=0;)n^=Js<<qn(n)-qn(Js);return(t<<10|n)^Zj}function tw(t){let n=t<<12;for(;qn(n)-qn(Qs)>=0;)n^=Qs<<qn(n)-qn(Qs);return t<<12|n}class nw{constructor(){this.bits=[]}put(n,i){for(let a=i-1;a>=0;a--)this.bits.push((n>>>a&1)===1?1:0)}get length(){return this.bits.length}}function Ou(t){return t<=9?8:(t<=26,16)}function nl(t){return Array.from({length:t},()=>new Array(t).fill(null))}function Xs(t,n,i){for(let a=-1;a<=7;a++)for(let s=-1;s<=7;s++){const o=n+a,c=i+s;if(o<0||o>=t.length||c<0||c>=t.length)continue;const d=a>=0&&a<=6&&(s===0||s===6)||s>=0&&s<=6&&(a===0||a===6)||a>=2&&a<=4&&s>=2&&s<=4;t[o][c]=d}}function iw(t,n){const i=Xj[n-1];for(const a of i)for(const s of i)if(t[a][s]===null)for(let o=-2;o<=2;o++)for(let c=-2;c<=2;c++){const d=Math.max(Math.abs(o),Math.abs(c))!==1;t[a+o][s+c]=d}}function aw(t){const n=t.length;for(let i=8;i<n-8;i++){const a=i%2===0;t[6][i]===null&&(t[6][i]=a),t[i][6]===null&&(t[i][6]=a)}}function sw(t,n){const i=t.length;t[i-8][8]=!0}function rw(t,n,i){const a=t.length,s=Gj[n]<<3|i,o=ew(s);for(let c=0;c<15;c++){const d=(o>>c&1)===1;c<6?t[c][8]=d:c<8?t[c+1][8]=d:t[a-15+c][8]=d}for(let c=0;c<15;c++){const d=(o>>c&1)===1;c<8?t[8][a-c-1]=d:c<9?t[8][15-c]=d:t[8][15-c-1]=d}t[a-8][8]=!0}function ow(t,n){if(n<7)return;const i=t.length,a=tw(n);for(let s=0;s<18;s++){const o=(a>>s&1)===1,c=Math.floor(s/3),d=s%3+i-8-3;t[c][d]=o,t[d][c]=o}}function cw(t,n,i){switch(t){case 0:return(n+i)%2===0;case 1:return n%2===0;case 2:return i%3===0;case 3:return(n+i)%3===0;case 4:return(Math.floor(n/2)+Math.floor(i/3))%2===0;case 5:return n*i%2+n*i%3===0;case 6:return(n*i%2+n*i%3)%2===0;case 7:return(n*i%3+(n+i)%2)%2===0;default:return!1}}function lw(t){const n=t.length;let i=0;for(let m=0;m<n;m++){let h=1,u=1;for(let x=1;x<n;x++)t[m][x]===t[m][x-1]?h++:(h>=5&&(i+=3+(h-5)),h=1),t[x][m]===t[x-1][m]?u++:(u>=5&&(i+=3+(u-5)),u=1);h>=5&&(i+=3+(h-5)),u>=5&&(i+=3+(u-5))}for(let m=0;m<n-1;m++)for(let h=0;h<n-1;h++){const u=t[m][h];u===t[m][h+1]&&u===t[m+1][h]&&u===t[m+1][h+1]&&(i+=3)}const a=[!0,!1,!0,!0,!0,!1,!0,!1,!1,!1,!1],s=[!1,!1,!1,!1,!0,!1,!0,!0,!0,!1,!0],o=(m,h,u,x)=>{for(let f=0;f<11;f++){const b=x?h:h+f,g=x?u+f:u;if(m[f]!==t[b][g])return!1}return!0};for(let m=0;m<n;m++)for(let h=0;h<n;h++)h+11<=n&&(o(a,m,h,!0)||o(s,m,h,!0))&&(i+=40),m+11<=n&&(o(a,m,h,!1)||o(s,m,h,!1))&&(i+=40);let c=0;for(let m=0;m<n;m++)for(let h=0;h<n;h++)t[m][h]&&c++;const d=c*100/(n*n),p=Math.abs(Math.floor(d/5)*5-50)/5;return i+=p*10,i}function dw(t,n,i){const a=Mu(n,i),s=a.reduce((y,C)=>y+C.dataCount,0),o=new nw;o.put(4,4),o.put(t.length,Ou(n));for(const y of t)o.put(y,8);const c=s*8,d=Math.min(4,c-o.length);for(d>0&&o.put(0,d);o.length%8!==0;)o.bits.push(0);const p=[];for(let y=0;y<o.length;y+=8){let C=0;for(let w=0;w<8;w++)C=C<<1|o.bits[y+w];p.push(C)}const m=[236,17];let h=0;for(;p.length<s;)p.push(m[h++%2]);const u=[],x=[];let f=0;for(const y of a){const C=p.slice(f,f+y.dataCount);f+=y.dataCount,u.push(C),x.push(Jj(C,y.totalCount-y.dataCount))}const b=[],g=Math.max(...a.map(y=>y.dataCount));for(let y=0;y<g;y++)for(const C of u)y<C.length&&b.push(C[y]);const v=Math.max(...x.map(y=>y.length));for(let y=0;y<v;y++)for(const C of x)y<C.length&&b.push(C[y]);return b}function uw(t,n){for(let i=1;i<=40;i++){const s=Mu(i,n).reduce((c,d)=>c+d.dataCount,0);if(4+Ou(i)+t*8<=s*8)return i}return 40}function il(t,n="M"){const i=Array.from(new TextEncoder().encode(t)),a=uw(i.length,n),s=a*4+17,o=dw(i,a,n),c=nl(s);Xs(c,0,0),Xs(c,0,s-7),Xs(c,s-7,0),iw(c,a),aw(c),sw(c),ow(c,a);const d=nl(s);for(let f=0;f<s;f++)for(let b=0;b<s;b++)d[f][b]=c[f][b]!==null;for(let f=0;f<9;f++)d[8][f]=!0,d[f][8]=!0;for(let f=0;f<8;f++)d[8][s-1-f]=!0,d[s-1-f][8]=!0;d[s-8][8]=!0;const p=[];for(const f of o)for(let b=7;b>=0;b--)p.push(f>>b&1);let m=0,h=!0;for(let f=s-1;f>0;f-=2){const b=f===6?f-1:f;for(let g=0;g<s;g++){const v=h?s-1-g:g;for(let y=0;y<2;y++){const C=b-y;if(d[v][C])continue;const w=m<p.length?p[m]===1:!1;c[v][C]=w,m++}}h=!h}for(let f=0;f<s;f++)for(let b=0;b<s;b++)c[f][b]===null&&(c[f][b]=!1);let u=null,x=1/0;for(let f=0;f<8;f++){const b=c.map(v=>v.map(y=>y));for(let v=0;v<s;v++)for(let y=0;y<s;y++)!d[v][y]&&cw(f,v,y)&&(b[v][y]=!b[v][y]);rw(b,n,f);const g=lw(b);g<x&&(x=g,u=b)}return u}const Lu=Object.assign(r.forwardRef(({value:t,defaultValue:n,qrSize:i=200,color:a,background:s,errorCorrection:o="M",size:c="md",renderAs:d="canvas",quiet:p=4,logo:m,logoSize:h=40,showInput:u=!1,editable:x,inputLabel:f,inputPlaceholder:b,labelPlacement:g,inputProps:v,onValueChange:y,className:C,style:w,id:E,testId:S,"data-testid":N,..._},k)=>{const{t:j}=l.useNiceTranslation(),T=x??u,P=l.useControlId(E),B=r.useRef(null),R=l.useThemeIsDark(B),I=a||(R?"#f8fafc":"#111827"),D=s||"transparent",[M,O]=l.useControllableState({value:t,defaultValue:n,fallbackValue:"",onChange:y,componentName:"NiceQRCode"}),[L,V]=r.useState(M);r.useEffect(()=>{V(M)},[M]);const ee=T?L:M,z=se=>{V(se),O(se)};r.useEffect(()=>{const se=(k&&typeof k=="object"&&"current"in k?k.current:null)??B.current;if(!se||d!=="canvas")return;const ce=se.getContext("2d");if(!ce)return;const le=il(ee,o),J=le.length,me=J+p*2,je=i/me;se.width=i,se.height=i,ce.clearRect(0,0,i,i),D!=="transparent"&&(ce.fillStyle=D,ce.fillRect(0,0,i,i)),ce.fillStyle=I;for(let ue=0;ue<J;ue++)for(let F=0;F<J;F++)le[ue][F]&&ce.fillRect((F+p)*je,(ue+p)*je,je,je);if(m){const ue=new Image;ue.crossOrigin="anonymous",ue.onload=()=>{const F=(i-h)/2,H=(i-h)/2;ce.fillStyle=D==="transparent"?R?"#111827":"#f8fafc":D,ce.fillRect(F-2,H-2,h+4,h+4),ce.drawImage(ue,F,H,h,h)},ue.src=m}},[ee,o,i,I,D,p,m,h,d,k,R,T]);const U=T?void 0:P,re=T?`nice-qrcode nice-qrcode--${c}`:`nice-qrcode nice-qrcode--${c} ${C??""}`,Y=T?void 0:w,oe=T?{}:_;let q;if(d==="svg"){const se=il(ee,o),le=se.length+p*2,J=i/le;q=e.jsxs("svg",{id:U,className:re,style:Y,"data-testid":T?void 0:N??S,width:i,height:i,viewBox:`0 0 ${i} ${i}`,role:"img","aria-label":j("qrCode.qrCode","QR Code: {encodedValue}").replace("{encodedValue}",String(ee)),...oe,children:[D!=="transparent"&&e.jsx("rect",{width:i,height:i,fill:D}),se.map((me,je)=>me.map((ue,F)=>ue?e.jsx("rect",{x:(F+p)*J,y:(je+p)*J,width:J,height:J,fill:I},`${je}-${F}`):null))]})}else q=e.jsx("canvas",{ref:B,id:U,className:re,style:Y,"data-testid":T?void 0:N??S,role:"img","aria-label":j("qrCode.qrCode","QR Code: {encodedValue}").replace("{encodedValue}",String(ee)),...oe});return T?e.jsxs("div",{id:P,className:`nice-qrcode-field nice-qrcode-field--${c} ${C??""}`,style:{display:"inline-flex",flexDirection:"column",gap:8,...w},"data-testid":N??S,..._,children:[e.jsx(Oe.NiceTextInput,{...v,label:f??v?.label,placeholder:b??v?.placeholder,labelPlacement:g??v?.labelPlacement,size:c,value:L,onChange:z}),q]}):q}),{displayName:"NiceQRCode"});function pw(t){return typeof t=="number"?t:/^\d+(\.\d+)?$/.test(t.trim())?`${t}px`:t}const zu=Object.assign(r.forwardRef(({lines:t,prompt:n="$ ",onCommand:i,readOnly:a=!1,disabled:s=!1,error:o,theme:c="auto",loading:d=!1,size:p="md",height:m=400,maxHistory:h=100,greeting:u,fontFamily:x,showTimestamp:f=!1,className:b,style:g,id:v,testId:y,"data-testid":C,...w},E)=>{const S=l.useControlId(v),{t:N}=l.useNiceTranslation(),_=r.useRef(null),k=r.useRef(null),[j,T]=r.useState(()=>{const Y=[];return u&&Y.push({type:"system",text:u,timestamp:new Date}),Y}),[P,B]=r.useState(""),[R,I]=r.useState([]),[D,M]=r.useState(-1),O=t??j,L=s||d,V=typeof o=="string"?o:"";r.useEffect(()=>{k.current&&(k.current.scrollTop=k.current.scrollHeight)},[O]);const ee=r.useCallback(Y=>{t||T(oe=>{const q=[...oe,Y];return q.length>h?q.slice(q.length-h):q})},[t,h]),z=r.useCallback(Y=>{Y.preventDefault();const oe=P.trim();oe&&(ee({type:"input",text:`${n}${oe}`,timestamp:new Date}),I(q=>[...q,oe]),M(-1),B(""),i?.(oe))},[P,n,ee,i]),U=r.useCallback(Y=>{Y.key==="ArrowUp"?(Y.preventDefault(),M(oe=>{const q=oe===-1?R.length-1:Math.max(0,oe-1);return B(R[q]??""),q})):Y.key==="ArrowDown"&&(Y.preventDefault(),M(oe=>{if(oe===-1)return-1;const q=oe+1;return q>=R.length?(B(""),-1):(B(R[q]??""),q)}))},[R]),re=r.useCallback(()=>{L||_.current?.focus()},[L]);return e.jsxs("div",{ref:E,id:S,className:`nice-terminal nice-terminal--${p} nice-terminal--theme-${c}${a?" nice-terminal--readonly":""}${s?" nice-terminal--disabled":""}${d?" nice-terminal--loading":""}${V?" nice-terminal--error":""}${b?` ${b}`:""}`,style:{...g,height:pw(m),...x?{fontFamily:x}:null},onClick:re,role:"log","aria-label":N("terminal.label","Terminal"),"aria-live":"polite","aria-disabled":s||void 0,"aria-busy":d||void 0,"data-testid":C??y,...w,children:[V&&e.jsx("div",{className:"nice-terminal__error-banner",role:"alert",children:V}),e.jsx("div",{className:"nice-terminal__output",ref:k,children:O.map((Y,oe)=>e.jsxs("div",{className:`nice-terminal__line nice-terminal__line--${Y.type}`,children:[f&&Y.timestamp&&e.jsxs("span",{className:"nice-terminal__timestamp",children:["[",Y.timestamp.toLocaleTimeString(),"]"]}),e.jsx("span",{className:"nice-terminal__text",children:Y.text})]},oe))}),!a&&e.jsxs("form",{className:"nice-terminal__input-row",onSubmit:z,children:[e.jsx("span",{className:"nice-terminal__prompt",children:n}),e.jsx("input",{ref:_,className:"nice-terminal__input",type:"text",value:P,onChange:Y=>B(Y.target.value),onKeyDown:U,disabled:L,spellCheck:!1,autoComplete:"off","aria-label":N("terminal.input","Command input")})]}),d&&e.jsx("div",{className:"nice-terminal__loading","aria-hidden":"true",children:e.jsx("span",{className:"nice-spinner nice-spinner--md"})})]})}),{displayName:"NiceTerminalUI"}),mw=({enabled:t=!0,labels:n,tutorialProps:i,children:a})=>{const{t:s}=l.useNiceTranslation(),[o,c]=r.useState([]),[d,p]=r.useState(!1),m=r.useCallback(u=>{c(u),p(!0)},[]),h=r.useMemo(()=>({next:s("tutorial.next","Next"),back:s("tutorial.back","Back"),finish:s("tutorial.finish","Finish"),skip:s("tutorial.skip","Skip"),stepOf:s("tutorial.stepOf","of"),play:s("tutorial.play","Play"),pause:s("tutorial.pause","Pause"),speed:s("tutorial.speed","Speed"),close:s("tutorial.close","Close"),...n}),[s,n]);return e.jsxs(l.NiceTutorialsProvider,{enabled:t,active:d,onRun:m,children:[a,e.jsx(kt.NiceTutorial,{...i,steps:o,active:d,labels:h,onFinish:()=>p(!1),onSkip:()=>p(!1)})]})},Bu=({value:t,onChange:n,layout:i="pills",size:a="md",showDescription:s=!1,showPreview:o=!0,label:c,styles:d,compact:p=!1,className:m,style:h,"data-testid":u})=>{const{t:x}=l.useNiceTranslation(),f=l.useNiceDisplayStyle(),b=t??f.displayStyle,[g,v]=r.useState(!1),y=p?"dropdown":i,C=r.useCallback(I=>{n?n(I):f.setDisplayStyle(I),v(!1)},[n,f]),w=r.useMemo(()=>(d??l.NICE_DISPLAY_STYLES).map(D=>{const M=l.NICE_DISPLAY_STYLE_INFO.find(O=>O.name===D);return{name:D,label:M?.label??D,description:M?.description??"",density:M?.density??"normal",animation:M?.animation??"normal"}}),[d]),E=r.useRef(null);l.useRovingFocus(E,{orientation:y==="pills"?"both":"grid",wrap:!0,activateOnMove:!0,enabled:y!=="dropdown"});const{activeIndex:S,setActiveIndex:N,handleKeyDown:_}=Vt.useListKeyboardNav(w,{open:g,onSelect:I=>C(I.name),onClose:()=>v(!1),onOpen:()=>k()}),k=()=>{N(Math.max(0,w.findIndex(I=>I.name===b))),v(!0)},T=`${r.useId()}-styles`,P=r.useCallback(I=>{if(!o)return null;const D=l.resolveDisplayStyleConfig(I),M=D.radius==="none",L=D.radius==="full"?"50%":M?"0":D.radius==="sm"?"3px":D.radius==="lg"?"10px":D.radius==="xl"?"16px":D.radius==="2xl"?"24px":"6px",V=D.shadow==="none"?"none":D.shadow==="glow"?"0 0 8px color-mix(in srgb, var(--nice-color-primary, #6366f1) 40%, transparent)":D.shadow==="colored"?"0 2px 8px color-mix(in srgb, var(--nice-color-primary, #6366f1) 30%, transparent)":D.shadow==="inner"?"inset 0 1px 3px color-mix(in srgb, var(--nice-text-primary, #000) 10%, transparent)":D.shadow==="subtle"?"0 1px 2px color-mix(in srgb, var(--nice-text-primary, #000) 5%, transparent)":D.shadow==="lg"?"0 4px 12px color-mix(in srgb, var(--nice-text-primary, #000) 15%, transparent)":"0 2px 6px color-mix(in srgb, var(--nice-text-primary, #000) 10%, transparent)",ee=D.fill==="glass"?"color-mix(in srgb, var(--nice-color-primary, #6366f1) 15%, transparent)":D.fill==="frosted"?"color-mix(in srgb, var(--nice-color-white, #fff) 70%, transparent)":D.fill==="gradient-linear"?"linear-gradient(135deg, var(--nice-color-primary, #6366f1), var(--nice-color-accent, #8b5cf6))":D.fill==="mesh"?"radial-gradient(at 40% 20%, var(--nice-color-primary, #6366f1) 0%, transparent 50%), radial-gradient(at 80% 0%, var(--nice-color-accent, #8b5cf6) 0%, transparent 50%)":"var(--nice-color-accent, #6366f1)";return e.jsx("span",{style:{display:"inline-block",width:20,height:20,background:ee,borderRadius:L,boxShadow:V,border:D.buttonStyle==="brutal"?"2px solid var(--nice-border-color, #000)":D.buttonStyle==="outlined"?"2px solid var(--nice-color-primary, #6366f1)":"none",marginRight:6,flexShrink:0}})},[o]);if(y==="dropdown")return e.jsxs("div",{className:`nice-ds-picker nice-ds-picker--dropdown ${m||""}`,style:h,children:[c&&e.jsx("label",{className:"nice-ds-picker__label",children:c}),e.jsxs("button",{type:"button",className:`nice-ds-picker__trigger nice-ds-picker__trigger--${a}`,onClick:()=>g?v(!1):k(),onKeyDown:_,role:"combobox","aria-expanded":g,"aria-haspopup":"listbox","aria-controls":g?T:void 0,"aria-activedescendant":g&&w[S]?`${T}-${S}`:void 0,children:[P(b),e.jsx("span",{children:w.find(I=>I.name===b)?.label??b}),e.jsx(l.NiceIcon,{name:"chevron-down",size:12,style:{marginLeft:"auto"}})]}),g&&e.jsx("div",{className:"nice-ds-picker__menu",role:"listbox",id:T,children:w.map((I,D)=>e.jsxs("button",{id:`${T}-${D}`,type:"button",role:"option",tabIndex:-1,"aria-selected":I.name===b,className:`nice-ds-picker__option ${I.name===b?"nice-ds-picker__option--active":""} ${D===S?"nice-ds-picker__option--highlighted":""}`,onMouseEnter:()=>N(D),onClick:()=>C(I.name),children:[P(I.name),e.jsx("span",{children:I.label}),s&&e.jsx("span",{className:"nice-ds-picker__desc",children:I.description})]},I.name))})]});const B=y==="pills"?"nice-ds-picker__pills":y==="grid"?"nice-ds-picker__grid":"nice-ds-picker__cards",R=I=>{const D=I.name===b,M={type:"button",role:"radio","aria-checked":D,onClick:()=>C(I.name)};if(y==="pills")return e.jsxs("button",{...M,className:`nice-ds-picker__pill nice-ds-picker__pill--${a} ${D?"nice-ds-picker__pill--active":""}`,title:I.description,children:[P(I.name),e.jsx("span",{children:I.label})]},I.name);if(y==="grid")return e.jsxs("button",{...M,className:`nice-ds-picker__grid-item ${D?"nice-ds-picker__grid-item--active":""}`,children:[P(I.name),e.jsx("span",{className:"nice-ds-picker__grid-label",children:I.label})]},I.name);const O=l.resolveDisplayStyleConfig(I.name);return e.jsxs("button",{...M,className:`nice-ds-picker__card ${D?"nice-ds-picker__card--active":""}`,children:[e.jsx("div",{className:"nice-ds-picker__card-preview",children:P(I.name)}),e.jsxs("div",{className:"nice-ds-picker__card-info",children:[e.jsx("strong",{children:I.label}),s&&e.jsx("span",{className:"nice-ds-picker__desc",children:I.description}),e.jsxs("div",{className:"nice-ds-picker__card-meta",children:[e.jsx("span",{title:x("displayStyle.density","Density"),children:O.density}),e.jsx("span",{title:x("displayStyle.buttons","Buttons"),children:O.buttonStyle}),e.jsx("span",{title:x("displayStyle.inputs","Inputs"),children:O.inputStyle})]})]})]},I.name)};return e.jsxs("div",{className:`nice-ds-picker nice-ds-picker--${y} ${m||""}`,style:h,"data-testid":u,children:[c&&e.jsx("label",{className:"nice-ds-picker__label",children:c}),e.jsx("div",{ref:E,className:B,role:"radiogroup","aria-label":c||x("displayStyle.label","Display Style"),children:w.map(R)})]})};process.env.NODE_ENV!=="production"&&(Bu.displayName="NiceDisplayStylePicker");function hw(t,n){if(typeof t=="number")return n.includes("opacity")||n.includes("alpha")?"opacity":n.includes("weight")?"fontWeight":n.includes("duration")||n.includes("delay")?"duration":"dimension";const i=String(t).toLowerCase();return(i.startsWith("#")||i.startsWith("rgb")||i.startsWith("hsl")||i.startsWith("var(--"))&&(n.includes("color")||n.includes("background")||n.includes("border")||n.includes("shadow")||n.includes("text")||n.includes("fill")||n.includes("stroke"))?"color":i.includes("box-shadow")||i.includes("px")&&i.includes("rgba")?"shadow":n.includes("family")||n.includes("font")&&i.includes(",")?"fontFamily":n.includes("weight")?"fontWeight":n.includes("size")&&n.includes("font")?"fontSize":n.includes("line")&&n.includes("height")?"lineHeight":n.includes("letter")||n.includes("tracking")?"letterSpacing":n.includes("radius")?"borderRadius":n.includes("border")&&n.includes("width")?"borderWidth":n.includes("duration")||n.includes("delay")||i.endsWith("ms")||i.endsWith("s")?"duration":i.includes("cubic-bezier")||n.includes("easing")||n.includes("timing")?"cubicBezier":n.includes("spacing")||n.includes("gap")||n.includes("margin")||n.includes("padding")?"spacing":/^\d+(\.\d+)?(px|rem|em|%|vh|vw)$/.test(i)?"dimension":"other"}function Fu(t,n={}){const{prefix:i="ntd"}=n,a={};function s(o,c,d){if(o!=null)if(typeof o=="object"&&!Array.isArray(o))for(const[p,m]of Object.entries(o))s(m,[...c,p],d);else{const p=`${i}-${c.join("-")}`,m=String(o),h=hw(m,c.join("-"));a[p]={value:m,type:h,category:d,cssProperty:`--${p}`}}}return t.colors&&s(t.colors,["color"],"colors"),t.backgrounds&&s(t.backgrounds,["bg"],"backgrounds"),t.text&&s(t.text,["text"],"typography"),t.borders&&s(t.borders,["border"],"borders"),t.shadows&&s(t.shadows,["shadow"],"shadows"),t.spacing&&s(t.spacing,["spacing"],"spacing"),t.typography&&s(t.typography,["font"],"typography"),t.transitions&&s(t.transitions,["transition"],"motion"),a}function gw(t,n={}){const{includeDescriptions:i=!0,minify:a=!1}=n,s=[],o=a?"":`
|
|
2799
|
+
`,tn=(t,n,i)=>({id:t,label:n,entries:i.map(a=>({name:a.name,theme:a,category:t}))}),j_=(()=>{const t=l.NICE_THEME_ARCHIVE.gallery,n=(i,a,s,o)=>({id:i,label:a,entries:s.map(c=>({name:c.theme.name,theme:c.theme,pack:c,packList:o,category:i}))});return[n("packs","Theme Packs",l.NICE_THEME_ARCHIVE.packs,"base"),n("packs-2","Theme Packs Vol. 2",l.NICE_THEME_ARCHIVE.packsExtended,"extended"),tn("core","Core",l.NICE_THEME_ARCHIVE.core),tn("neutral","Neutral",t.slice(0,8)),tn("vibrant","Vibrant",t.slice(8,22)),tn("dark","Dark",t.slice(22,32)),tn("nature","Nature",t.slice(32,42)),tn("pastel","Pastel",t.slice(42,50)),tn("industry","Industry",t.slice(50,58)),tn("design-system","Design System",t.slice(58,64)),tn("retro","Retro",t.slice(64,72)),tn("seasonal","Seasonal",t.slice(72,80)),tn("cultural","Cultural",t.slice(80,88)),tn("accessibility","Accessibility",t.slice(88,92)),tn("modern-ui","Modern UI",t.slice(92))]})(),Eu=Object.assign(r.forwardRef(({src:t,page:n,totalPages:i,size:a="md",editorSize:s="standard",showToolbar:o=!0,showPageNav:c=!0,showZoom:d=!0,showDownload:p=!0,showPrint:m=!0,zoom:h,minZoom:u=25,maxZoom:x=400,height:f=600,aspectRatio:b="210 / 297",fit:g="page",onPageChange:v,onZoomChange:y,onLoad:C,onError:w,renderPage:E,className:S,style:N,id:_,testId:k,"data-testid":j,...T},P)=>{const B=l.useControlId(_),{t:R}=l.useNiceTranslation(),I=r.useRef(null),D=r.useRef(null);l.useRovingFocus(D,{orientation:"horizontal",itemSelector:"button"});const[M,O]=r.useState(n??1),[L,V]=r.useState(i??0),[ee,z]=r.useState(h??100),[U,re]=r.useState(null),[Y,oe]=r.useState(!1),q=n&&n>0?n:M,se=h&&h>0?h:ee;r.useEffect(()=>{n!==void 0&&n>0&&O(n)},[n]),r.useEffect(()=>{h!==void 0&&h>0&&z(h)},[h]),r.useEffect(()=>{i!==void 0&&V(i)},[i]),r.useEffect(()=>{if(!(!E||!I.current)){oe(!0),re(null);try{E({page:q,zoom:se,container:I.current}),oe(!1)}catch(F){const H=F instanceof Error?F.message:String(F);re(H),oe(!1),w?.(H)}}},[q,se,E,w]);const ce=r.useCallback(F=>{const H=Math.max(1,Math.min(L||F,F));O(H),v?.(H)},[L,v]),le=r.useCallback(F=>{const H=Math.max(u,Math.min(x,F));z(H),y?.(H)},[u,x,y]),J=r.useCallback(()=>{if(typeof t=="string"){const F=document.createElement("a");F.href=t,F.download="document.pdf",F.click()}else if(t instanceof ArrayBuffer||t instanceof Uint8Array){const F=t instanceof Uint8Array?t.buffer:t,H=new Blob([F],{type:"application/pdf"}),A=URL.createObjectURL(H),Z=document.createElement("a");Z.href=A,Z.download="document.pdf",Z.click(),URL.revokeObjectURL(A)}},[t]),me=r.useCallback(()=>{if(typeof t!="string")return;let F=t,H=null;if(t.startsWith("data:"))try{const Z=t.indexOf(","),fe=t.slice(5,Z),Ne=t.slice(Z+1),K=fe.split(";")[0]||"application/pdf",Q=/;base64/i.test(fe)?Uint8Array.from(atob(Ne),ne=>ne.charCodeAt(0)):new TextEncoder().encode(decodeURIComponent(Ne));H=URL.createObjectURL(new Blob([Q],{type:K})),F=H}catch{}const A=window.open(F);if(A&&A.addEventListener("load",()=>A.print()),H){const Z=H;window.setTimeout(()=>URL.revokeObjectURL(Z),6e4)}},[t]),je=typeof t=="string"&&!E,ue=g==="page";return e.jsxs("div",{ref:P,id:B,className:`nice-pdfviewer nice-pdfviewer--${a} nice-pdfviewer--fit-${g} nice-editor--${s} ${S??""}`,style:{...N,...ue?null:{height:f},"--nice-pdf-aspect":b},role:"document","aria-label":R("pdfviewer.label","PDF Viewer"),"data-testid":j??k,...T,children:[o&&e.jsxs("div",{ref:D,className:"nice-pdfviewer__toolbar",role:"toolbar","aria-label":R("pdfViewer.toolbar","PDF tools"),children:[c&&e.jsxs("div",{className:"nice-pdfviewer__page-nav",children:[e.jsx("button",{type:"button",className:"nice-pdfviewer__btn",disabled:q<=1,onClick:()=>ce(q-1),"aria-label":R("pdfviewer.prevPage","Previous page"),children:e.jsx(l.NiceIcon,{name:"chevron-left",size:16})}),e.jsxs("span",{className:"nice-pdfviewer__page-info",children:[q," / ",L||"?"]}),e.jsx("button",{type:"button",className:"nice-pdfviewer__btn",disabled:L>0&&q>=L,onClick:()=>ce(q+1),"aria-label":R("pdfviewer.nextPage","Next page"),children:e.jsx(l.NiceIcon,{name:"chevron-right",size:16})})]}),d&&e.jsxs("div",{className:"nice-pdfviewer__zoom-controls",children:[e.jsx("button",{type:"button",className:"nice-pdfviewer__btn",onClick:()=>le(se-25),disabled:se<=u,"aria-label":R("pdfviewer.zoomOut","Zoom out"),children:e.jsx(l.NiceIcon,{name:"minus",size:16})}),e.jsxs("span",{className:"nice-pdfviewer__zoom-label",children:[se,"%"]}),e.jsx("button",{type:"button",className:"nice-pdfviewer__btn",onClick:()=>le(se+25),disabled:se>=x,"aria-label":R("pdfviewer.zoomIn","Zoom in"),children:e.jsx(l.NiceIcon,{name:"plus",size:16})})]}),e.jsxs("div",{className:"nice-pdfviewer__actions",children:[p&&e.jsx("button",{type:"button",className:"nice-pdfviewer__btn",onClick:J,"aria-label":R("pdfviewer.download","Download"),children:e.jsx(l.NiceIcon,{name:"download",size:16})}),m&&typeof t=="string"&&e.jsx("button",{type:"button",className:"nice-pdfviewer__btn",onClick:me,"aria-label":R("pdfviewer.print","Print"),children:e.jsx(l.NiceIcon,{name:"printer",size:16})})]})]}),U&&e.jsx("div",{className:"nice-pdfviewer__error",role:"alert",children:U}),Y&&e.jsx("div",{className:"nice-pdfviewer__loading",children:R("pdfviewer.loading","Loading...")}),e.jsx("div",{className:"nice-pdfviewer__content",children:je?e.jsx("div",{className:"nice-pdfviewer__iframe-wrap",style:{transform:`scale(${se/100})`,transformOrigin:"top center"},children:e.jsx("iframe",{className:"nice-pdfviewer__iframe",src:`${t}#page=${q}&toolbar=0&view=FitH`,title:R("pdfviewer.label","PDF Viewer"),onLoad:()=>C?.(L)})}):e.jsx("div",{ref:I,className:"nice-pdfviewer__canvas",style:{transform:`scale(${se/100})`,transformOrigin:"top left"}})})]})}),{displayName:"NicePDFViewer"}),w_={heat:["var(--nice-color-warning, #f59e0b)","var(--nice-color-error, #ef4444)"],cool:["var(--nice-color-info, #06b6d4)","var(--nice-color-primary, #3b82f6)"],auto:["var(--nice-color-accent, #8b5cf6)","var(--nice-color-accent-pink, #ec4899)"],off:["var(--nice-text-muted, #9ca3af)","var(--nice-text-muted, #6b7280)"]},k_={xxs:60,xs:80,sm:110,md:150,lg:190,xl:230,xxl:280,small:110,medium:150,large:190},$n=-130,ca=260,Iu=({value:t,defaultValue:n,currentTemp:i,min:a=16,max:s=30,step:o=.5,onChange:c,mode:d="auto",size:p="md",showCurrentTemp:m=!0,disabled:h=!1,className:u,style:x,"data-testid":f})=>{const{t:b}=l.useNiceTranslation(),[g,v]=l.useControllableState({value:t,defaultValue:n,fallbackValue:a,onChange:c,componentName:"NiceTempDial"}),[y,C]=r.useState(!1),w=r.useRef(null),E=k_[p],S=E/2,N=E/2,_=E*.38,k=$n+(g-a)/(s-a)*ca,[j,T]=w_[d],P=r.useCallback(V=>{const ee=(V-$n)/ca,z=a+ee*(s-a);return Math.round(z/o)*o},[a,s,o]),B=r.useCallback((V,ee)=>{const z=w.current?.getBoundingClientRect();if(!z)return k;const U=V-(z.left+z.width/2),re=ee-(z.top+z.height/2);let Y=Math.atan2(re,U)*(180/Math.PI)+90;return Y>180&&(Y-=360),Y},[k]),R=r.useCallback(V=>{if(!y||h)return;const ee=B(V.clientX,V.clientY),z=Math.max($n,Math.min($n+ca,ee));v(Math.max(a,Math.min(s,P(z))))},[y,h,B,P,a,s,v]),I=r.useCallback(()=>C(!1),[]);r.useEffect(()=>(y&&(window.addEventListener("pointermove",R),window.addEventListener("pointerup",I)),()=>{window.removeEventListener("pointermove",R),window.removeEventListener("pointerup",I)}),[y,R,I]);const D=(V,ee)=>{const z=(V-90)*(Math.PI/180);return{x:S+ee*Math.cos(z),y:N+ee*Math.sin(z)}},M=(V,ee,z)=>{const U=D(V,z),re=D(ee,z),Y=ee-V>180?1:0;return`M ${U.x} ${U.y} A ${z} ${z} 0 ${Y} 1 ${re.x} ${re.y}`},O=D(k,_),L=`tempDial-${d}-${p}`;return e.jsx("div",{className:`nice-temp-dial nice-temp-dial--${p} nice-temp-dial--${d}${h?" nice-temp-dial--disabled":""} ${u??""}`,style:x,"data-testid":f,role:"slider","aria-valuemin":a,"aria-valuemax":s,"aria-valuenow":g,"aria-label":`${b("smartHome.temperature","Temperature")}: ${g}°C, ${b("smartHome.mode","mode")}: ${d}`,tabIndex:h?-1:0,onKeyDown:V=>{if(h)return;const ee=Math.max(o,(s-a)/10),z=V.key==="ArrowUp"||V.key==="ArrowRight"?g+o:V.key==="ArrowDown"||V.key==="ArrowLeft"?g-o:V.key==="PageUp"?g+ee:V.key==="PageDown"?g-ee:V.key==="Home"?a:V.key==="End"?s:null;z!==null&&(V.preventDefault(),v(Math.max(a,Math.min(s,z))))},children:e.jsxs("svg",{ref:w,viewBox:`0 0 ${E} ${E}`,width:E,height:E,"aria-hidden":"true",style:{cursor:h?"default":"grab",touchAction:"none"},onPointerDown:V=>{h||(V.target.setPointerCapture(V.pointerId),C(!0))},children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:L,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:[e.jsx("stop",{offset:"0%",stopColor:j}),e.jsx("stop",{offset:"100%",stopColor:T})]})}),e.jsx("path",{d:M($n,$n+ca,_),fill:"none",stroke:"var(--nice-bg-tertiary, #e5e7eb)",strokeWidth:E*.06,strokeLinecap:"round"}),d!=="off"&&e.jsx("path",{d:M($n,k,_),fill:"none",stroke:`url(#${L})`,strokeWidth:E*.06,strokeLinecap:"round"}),m&&i!==void 0&&(()=>{const V=$n+(i-a)/(s-a)*ca,ee=D(V,_-E*.06),z=D(V,_+E*.06);return e.jsx("line",{x1:ee.x,y1:ee.y,x2:z.x,y2:z.y,stroke:"var(--nice-success, #22c55e)",strokeWidth:2,strokeLinecap:"round"})})(),e.jsx("circle",{cx:O.x,cy:O.y,r:E*.065,fill:T,stroke:"white",strokeWidth:2,style:{filter:y?"drop-shadow(0 2px 6px var(--nice-overlay-40, rgba(0, 0, 0, 0.4)))":void 0}}),e.jsx("text",{x:S,y:N-E*.06,textAnchor:"middle",fontSize:E*.22,fontWeight:700,fill:"currentColor",children:g.toFixed(1)}),e.jsx("text",{x:S,y:N+E*.04,textAnchor:"middle",fontSize:E*.09,fill:"var(--nice-text-muted, #6b7280)",children:"°C"}),m&&i!==void 0&&e.jsxs("text",{x:S,y:N+E*.15,textAnchor:"middle",fontSize:E*.08,fill:"var(--nice-success, #22c55e)",children:[b("controls.now","Now"),": ",i.toFixed(1),"°"]}),e.jsx("text",{x:S,y:N+E*.36,textAnchor:"middle",fontSize:E*.08,fill:"var(--nice-text-muted, #9ca3af)",children:d.toUpperCase()})]})})},C_={xxs:32,xs:44,sm:56,md:72,lg:88,xl:104,xxl:128,small:56,medium:72,large:88},Du=({isLocked:t,onLockChange:n,requireConfirm:i=!0,confirmCode:a,size:s="md",loading:o=!1,disabled:c=!1,label:d,className:p,style:m,"data-testid":h})=>{const{t:u}=l.useNiceTranslation(),[x,f]=r.useState(!1),[b,g]=r.useState(""),[v,y]=r.useState(!1),[C,w]=r.useState(!1),E=r.useRef(null),S=r.useRef(null),N=C_[s];l.useOverlayFocus(S,{open:x,modal:!1,initialFocus:a?E:"first",onClose:()=>f(!1),closeHint:u("smartHome.cancel","Cancel")});const _=()=>{c||o||C||(i||a?(f(!0),g(""),y(!1)):k())},k=()=>{w(!0),f(!1),g(""),setTimeout(()=>{w(!1),n(!t)},400)},j=()=>{if(a&&b!==a){y(!0);return}k()},T=P=>{g(P),y(!1),a&&P.length>=a.length&&(P===a?k():y(!0))};return e.jsxs("div",{className:`nice-lock ${p??""}`,style:m,"data-testid":h,children:[e.jsx("button",{type:"button",className:`nice-lock__btn nice-lock__btn--${t?"locked":"unlocked"} nice-lock__btn--${s}${C?" nice-lock__btn--animating":""}`,onClick:_,disabled:c||o,"aria-label":t?u("smartHome.unlock","Unlock"):u("smartHome.lock","Lock"),"aria-pressed":!t,style:{width:N,height:N},children:o?e.jsx("span",{className:"nice-lock__spinner","aria-hidden":"true"}):e.jsx("svg",{viewBox:"0 0 24 24",width:N*.5,height:N*.5,fill:"none","aria-hidden":"true",children:t?e.jsxs(e.Fragment,{children:[e.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",fill:C?"var(--nice-color-warning, #f59e0b)":"var(--nice-color-primary, #3b82f6)"}),e.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4",stroke:C?"var(--nice-color-warning, #f59e0b)":"var(--nice-color-primary, #3b82f6)",strokeWidth:"2.5",strokeLinecap:"round",fill:"none"}),e.jsx("circle",{cx:"12",cy:"16",r:"1.5",fill:"white"})]}):e.jsxs(e.Fragment,{children:[e.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",fill:"var(--nice-success, #22c55e)"}),e.jsx("path",{d:"M7 11V7a5 5 0 0 1 9.9-1",stroke:"var(--nice-success, #22c55e)",strokeWidth:"2.5",strokeLinecap:"round",fill:"none"}),e.jsx("circle",{cx:"12",cy:"16",r:"1.5",fill:"white"})]})})}),d&&e.jsx("span",{className:"nice-lock__label",children:d}),x&&e.jsxs("div",{ref:S,className:"nice-lock__confirm",role:"dialog","aria-label":u("smartHome.confirmAction","Confirm action"),children:[e.jsxs("p",{className:"nice-lock__confirm-prompt",children:[t?u("smartHome.unlockQuestion","Unlock?"):u("smartHome.lockQuestion","Lock?"),a&&` ${u("smartHome.enterCode","Enter the code:")}`]}),a?e.jsx("input",{ref:E,type:"password",value:b,onChange:P=>T(P.target.value),maxLength:a.length,className:`nice-lock__pin-input${v?" nice-lock__pin-input--error":""}`,placeholder:"••••","aria-label":u("smartHome.confirmationCode","Confirmation code"),"aria-invalid":v}):e.jsxs("div",{className:"nice-lock__confirm-btns",children:[e.jsx("button",{type:"button",className:"nice-lock__confirm-yes",onClick:j,children:u("smartHome.yes","Yes")}),e.jsx("button",{type:"button",className:"nice-lock__confirm-no",onClick:()=>f(!1),children:u("smartHome.cancel","Cancel")})]}),v&&e.jsx("p",{className:"nice-lock__pin-error",role:"alert",children:u("smartHome.wrongCode","Wrong code")})]})]})},S_={light:"lightbulb",thermostat:"bar-chart",lock:"lock",switch:"plug",cover:"window",climate:"cloud",alarm:"bell","media-player":"music",gate:"arrow-right","energy-meter":"zap"};function T_({level:t}){const{t:n}=l.useNiceTranslation();return e.jsx("span",{className:"nice-device-card__signal","aria-label":`${n("smartHome.signal","Signal")}: ${t}/4`,title:`${n("smartHome.signal","Signal")}: ${t}/4`,children:[1,2,3,4].map(i=>e.jsx("span",{className:`nice-device-card__signal-bar${i<=t?" nice-device-card__signal-bar--active":""}`},i))})}function E_({level:t}){const{t:n}=l.useNiceTranslation(),i=t<=20?"var(--nice-color-error, #ef4444)":t<=50?"var(--nice-color-warning, #f59e0b)":"var(--nice-color-success, #22c55e)";return e.jsxs("span",{className:"nice-device-card__battery","aria-label":n("smartHome.battery","Battery: {level}%").replace("{level}",String(t)),title:n("smartHome.battery","Battery: {level}%").replace("{level}",String(t)),style:{color:i},children:[t,"%"]})}function I_(t){if(!t)return"";const n=typeof t=="string"?new Date(t):t,i=Date.now()-n.getTime();return i<6e4?"tylko co":i<36e5?`${Math.floor(i/6e4)} min temu`:i<864e5?`${Math.floor(i/36e5)}h temu`:n.toLocaleDateString("pl-PL")}function D_({device:t,onStateChange:n}){const{t:i}=l.useNiceTranslation(),a=t.state.on??!1,s=t.state.brightness??100;return e.jsxs("div",{className:"nice-device-card__control",children:[e.jsxs("button",{type:"button",className:`nice-device-card__toggle${a?" nice-device-card__toggle--on":""}`,onClick:()=>n(t.id,{on:!a}),"aria-pressed":a,"aria-label":a?i("smartHome.turnLightOff","Turn light off"):i("smartHome.turnLightOn","Turn light on"),children:[e.jsx(l.NiceIcon,{name:"lightbulb",size:14})," ",a?i("smartHome.onShort","On"):i("smartHome.offShort","Off")]}),a&&e.jsxs("label",{className:"nice-device-card__slider-label",children:[e.jsxs("span",{children:[i("smartHome.brightness","Brightness"),": ",s,"%"]}),e.jsx("input",{type:"range",min:1,max:100,value:s,onChange:o=>n(t.id,{on:!0,brightness:Number(o.target.value)}),"aria-label":i("smartHome.brightness","Brightness")})]})]})}function P_({device:t,onStateChange:n}){const i=t.state.setpoint??21,a=t.state.currentTemp,s=t.state.mode??"auto";return e.jsx("div",{className:"nice-device-card__control nice-device-card__control--thermostat",children:e.jsx(Iu,{value:i,currentTemp:a,min:16,max:30,step:.5,mode:s,size:"sm",onChange:o=>n(t.id,{setpoint:o,mode:s,currentTemp:a})})})}function A_({device:t,onStateChange:n}){const{t:i}=l.useNiceTranslation(),a=t.state.locked??!0;return e.jsx("div",{className:"nice-device-card__control",children:e.jsx(Du,{isLocked:a,onLockChange:s=>n(t.id,{locked:s}),requireConfirm:!0,size:"md",label:a?i("smartHome.locked","Locked"):i("smartHome.unlocked","Unlocked")})})}function R_({device:t,onStateChange:n}){const{t:i}=l.useNiceTranslation(),a=t.state.on??!1;return e.jsx("div",{className:"nice-device-card__control",children:e.jsxs("button",{type:"button",className:`nice-device-card__toggle${a?" nice-device-card__toggle--on":""}`,onClick:()=>n(t.id,{on:!a}),"aria-pressed":a,"aria-label":a?i("smartHome.turnOff","Turn off"):i("smartHome.turnOn","Turn on"),children:[e.jsx(l.NiceIcon,{name:a?"check":"circle",size:14})," ",a?i("smartHome.switchedOn","On"):i("smartHome.switchedOff","Off")]})})}function $_({device:t,onStateChange:n}){const{t:i}=l.useNiceTranslation(),a=t.state.position??0;return e.jsxs("div",{className:"nice-device-card__control",children:[e.jsxs("label",{className:"nice-device-card__slider-label",children:[e.jsx("span",{children:i("smartHome.open2","Open: {position}%").replace("{position}",String(a))}),e.jsx("input",{type:"range",min:0,max:100,value:a,onChange:s=>n(t.id,{position:Number(s.target.value)}),"aria-label":i("smartHome.blindsOpening","Blinds opening")})]}),e.jsxs("div",{className:"nice-device-card__blind-btns",children:[e.jsx("button",{type:"button",onClick:()=>n(t.id,{position:0}),"aria-label":i("smartHome.close","Close"),children:e.jsx(l.NiceIcon,{name:"arrow-down",size:16})}),e.jsx("button",{type:"button",onClick:()=>n(t.id,{position:50}),"aria-label":i("smartHome.half","Half"),children:"50%"}),e.jsx("button",{type:"button",onClick:()=>n(t.id,{position:100}),"aria-label":i("smartHome.open","Open"),children:e.jsx(l.NiceIcon,{name:"arrow-up",size:16})})]})]})}function M_(t,n){switch(t.category){case"light":return e.jsx(D_,{device:t,onStateChange:n});case"thermostat":return e.jsx(P_,{device:t,onStateChange:n});case"lock":return e.jsx(A_,{device:t,onStateChange:n});case"switch":return e.jsx(R_,{device:t,onStateChange:n});case"cover":return e.jsx($_,{device:t,onStateChange:n});default:return e.jsxs("div",{className:"nice-device-card__control nice-device-card__control--readonly",children:[e.jsx("span",{className:"nice-device-card__state-badge",children:t.isOnline?"Online":"Offline"}),Object.entries(t.state).slice(0,3).map(([i,a])=>e.jsxs("span",{className:"nice-device-card__state-kv",children:[i,": ",e.jsx("strong",{children:String(a)})]},i))]})}}const O_=({device:t,onStateChange:n,showBattery:i=!0,showSignal:a=!0,showLastSeen:s=!0,compact:o=!1,controlLayout:c="card",className:d,style:p,"data-testid":m})=>{const{t:h}=l.useNiceTranslation(),[u,x]=r.useState(!o),f=S_[t.category]??"settings";return e.jsxs("div",{className:`nice-device-card nice-device-card--${c}${t.isOnline?"":" nice-device-card--offline"} ${d??""}`,style:p,"data-testid":m,role:"region","aria-label":`${h("smartHome.device","Device")}: ${t.name}`,children:[e.jsxs("div",{className:"nice-device-card__header",children:[e.jsx("span",{className:"nice-device-card__icon","aria-hidden":"true",children:e.jsx(l.NiceIcon,{name:f,size:20})}),e.jsxs("div",{className:"nice-device-card__info",children:[e.jsx("span",{className:"nice-device-card__name",children:t.name}),t.roomId&&e.jsx("span",{className:"nice-device-card__room",children:t.roomId})]}),e.jsxs("div",{className:"nice-device-card__meta",children:[a&&t.signalStrength!==void 0&&e.jsx(T_,{level:Math.round(t.signalStrength/25)}),i&&t.batteryLevel!==void 0&&e.jsx(E_,{level:t.batteryLevel}),e.jsx("span",{className:`nice-device-card__status${t.isOnline?" nice-device-card__status--online":" nice-device-card__status--offline"}`,"aria-label":t.isOnline?h("smartHome.online","Online"):h("smartHome.offline","Offline"),children:e.jsx(l.NiceIcon,{name:"circle",size:12})})]}),o&&e.jsx("button",{type:"button",className:"nice-device-card__expand-btn",onClick:()=>x(b=>!b),"aria-expanded":u,"aria-label":u?h("smartHome.collapse","Collapse"):h("smartHome.expand","Expand"),children:e.jsx(l.NiceIcon,{name:u?"arrow-up":"arrow-down",size:16})})]}),u&&e.jsxs("div",{className:"nice-device-card__body",children:[M_(t,n),s&&t.lastSeen&&e.jsxs("p",{className:"nice-device-card__last-seen",children:[h("smartHome.lastSeen","Last seen"),": ",I_(t.lastSeen)]})]})]})},L_=[];function Hc(t,n,i,a){const s=(a-90)*(Math.PI/180);return{x:t+i*Math.cos(s),y:n+i*Math.sin(s)}}function Gc(t,n,i,a,s){const o=Hc(t,n,i,a),c=Hc(t,n,i,s),d=s-a>180?1:0;return`M ${o.x} ${o.y} A ${i} ${i} 0 ${d} 1 ${c.x} ${c.y}`}const z_=({label:t,value:n,min:i,max:a,unit:s,threshold:o,animate:c})=>{const p=(Math.max(i,Math.min(a,n))-i)/(a-i),m=-135,h=135,u=h-m,x=m+p*u,f=60,b=60,g=45;let v="var(--nice-color-primary, #3b82f6)";if(o){const C=o.warning,w=o.critical;o.reverse?n<=w?v="var(--nice-color-error, #dc2626)":n<=C&&(v="var(--nice-color-warning, #f59e0b)"):n>=w?v="var(--nice-color-error, #dc2626)":n>=C&&(v="var(--nice-color-warning, #f59e0b)")}const y=r.useRef(m);return r.useEffect(()=>{y.current=x},[x]),e.jsxs("div",{className:"nice-gauge__item",role:"meter","aria-valuenow":n,"aria-valuemin":i,"aria-valuemax":a,"aria-label":t,children:[e.jsxs("svg",{viewBox:"0 0 120 100",width:"120",height:"100","aria-hidden":"true",children:[e.jsx("path",{d:Gc(f,b,g,m,h),fill:"none",stroke:"var(--nice-border, #e5e7eb)",strokeWidth:8,strokeLinecap:"round"}),e.jsx("path",{d:Gc(f,b,g,m,x),fill:"none",stroke:v,strokeWidth:8,strokeLinecap:"round",style:c?{transition:"stroke-dashoffset 0.5s ease"}:void 0}),e.jsx("text",{x:f,y:b+6,textAnchor:"middle",fontSize:18,fontWeight:700,fill:"currentColor",children:n}),e.jsx("text",{x:f,y:b+22,textAnchor:"middle",fontSize:10,fill:"var(--nice-text-secondary, #6b7280)",children:s})]}),e.jsx("p",{className:"nice-gauge__label",children:t})]})},B_={temperature:"°C",humidity:"%",co2:"ppm",pressure:"hPa",lux:"lx",noise:"dB",pm25:"µg/m³",voc:"ppb"},F_={temperature:[0,50],humidity:[0,100],co2:[300,2e3],pressure:[950,1050],lux:[0,1e4],noise:[20,100],pm25:[0,150],voc:[0,1e3]},q_=({sensors:t=L_,layout:n="grid",gaugeTypes:i,thresholds:a={},unit:s={},animate:o=!0,className:c,style:d,"data-testid":p})=>{const{t:m}=l.useNiceTranslation();return e.jsxs("div",{className:`nice-gauge-panel nice-gauge-panel--${n} ${c??""}`,style:d,"data-testid":p,children:[t.map(h=>{const u=h.type.toLowerCase(),x=s[u]??B_[u]??"",[f,b]=F_[u]??[0,100],g=a[u];return e.jsx(z_,{label:h.type,value:h.value,min:f,max:b,unit:x,threshold:g,animate:o},h.deviceId+h.type)}),t.length===0&&e.jsx("p",{className:"nice-gauge-panel__empty",role:"status",children:m("smartHome.noSensorData","No sensor data.")})]})},V_=[],U_=[{target:".nice-scene-action-builder",titleKey:"tutorial.sceneActionBuilder.intro.title",title:"Scene action builder",contentKey:"tutorial.sceneActionBuilder.intro.content",content:"Add an action per device, set its target state and an optional delay, reorder them, and preview the scene sequence.",placement:"auto"}];function H_(){return`action-${Date.now()}-${Math.random().toString(36).slice(2,7)}`}function G_(t){switch(t.category){case"light":return[{key:"on",labelKey:"smartHome.prop.state",label:"State",type:"boolean"},{key:"brightness",labelKey:"smartHome.prop.brightness",label:"Brightness (1-100)",type:"number"}];case"thermostat":return[{key:"setpoint",labelKey:"smartHome.prop.temperature",label:"Temperature (°C)",type:"number"},{key:"mode",labelKey:"smartHome.prop.mode",label:"Mode",type:"select",options:["heat","cool","auto","off"]}];case"lock":return[{key:"locked",labelKey:"smartHome.prop.locked",label:"Locked",type:"boolean"}];case"cover":return[{key:"position",labelKey:"smartHome.prop.position",label:"Open (0-100%)",type:"number"}];case"switch":return[{key:"on",labelKey:"smartHome.prop.state",label:"State",type:"boolean"}];case"climate":return[{key:"on",labelKey:"smartHome.prop.state",label:"State",type:"boolean"},{key:"speed",labelKey:"smartHome.prop.speed",label:"Speed (1-5)",type:"number"}];default:return[]}}function W_({action:t,devices:n,index:i,totalCount:a,onUpdate:s,onRemove:o,onMoveUp:c,onMoveDown:d}){const{t:p}=l.useNiceTranslation(),m=n.find(u=>u.id===t.deviceId),h=m?G_(m):[];return e.jsxs("div",{className:"nice-scene-action__card",draggable:!0,children:[e.jsxs("div",{className:"nice-scene-action__card-header",children:[e.jsx("span",{className:"nice-scene-action__order",children:i+1}),e.jsxs("select",{value:t.deviceId,onChange:u=>s({...t,deviceId:u.target.value,targetState:{}}),className:"nice-scene-action__device-select","aria-label":p("smartHome.device","Device"),children:[e.jsx("option",{value:"",children:p("smartHome.selectDevice","— select a device —")}),n.map(u=>e.jsxs("option",{value:u.id,children:[u.name," (",u.roomId??"—",")"]},u.id))]}),e.jsxs("div",{className:"nice-scene-action__card-btns",children:[e.jsx("button",{type:"button",onClick:c,disabled:i===0,"aria-label":p("smartHome.moveUp","Move up"),children:e.jsx(l.NiceIcon,{name:"arrow-up",size:14})}),e.jsx("button",{type:"button",onClick:d,disabled:i===a-1,"aria-label":p("smartHome.moveDown","Move down"),children:e.jsx(l.NiceIcon,{name:"arrow-down",size:14})}),e.jsx("button",{type:"button",onClick:o,"aria-label":p("smartHome.removeAction","Remove action"),className:"nice-scene-action__remove-btn",children:e.jsx(l.NiceIcon,{name:"close",size:14})})]})]}),m&&e.jsx("div",{className:"nice-scene-action__state-fields",children:h.map(u=>e.jsxs("label",{className:"nice-scene-action__field",children:[e.jsxs("span",{children:[p(u.labelKey,u.label),":"]}),u.type==="boolean"?e.jsx("input",{type:"checkbox",checked:!!t.targetState[u.key],onChange:x=>s({...t,targetState:{...t.targetState,[u.key]:x.target.checked}}),"aria-label":p(u.labelKey,u.label)}):u.type==="select"&&u.options?e.jsx("select",{value:t.targetState[u.key]??"",onChange:x=>s({...t,targetState:{...t.targetState,[u.key]:x.target.value}}),"aria-label":p(u.labelKey,u.label),children:u.options.map(x=>e.jsx("option",{value:x,children:x},x))}):e.jsx("input",{type:"number",value:t.targetState[u.key]??0,onChange:x=>s({...t,targetState:{...t.targetState,[u.key]:Number(x.target.value)}}),"aria-label":p(u.labelKey,u.label)})]},u.key))}),e.jsxs("label",{className:"nice-scene-action__delay",children:[e.jsxs("span",{children:[p("smartHome.delay","Delay"),":"]}),e.jsx("input",{type:"number",min:0,max:3600,value:t.delayMs?t.delayMs/1e3:0,onChange:u=>s({...t,delayMs:Number(u.target.value)*1e3}),"aria-label":p("smartHome.delaySeconds","Delay in seconds")}),e.jsx("span",{children:"s"})]})]})}const K_=({actions:t,defaultActions:n,onActionsChange:i,availableDevices:a=V_,showPreview:s=!0,maxActions:o=20,tutorial:c,className:d,style:p,"data-testid":m})=>{const{t:h}=l.useNiceTranslation(),[u,x]=l.useControllableState({value:t,defaultValue:n,fallbackValue:[],onChange:i,componentName:"NiceSceneActionBuilder"}),f=r.useCallback(()=>{u.length>=o||x([...u,{id:H_(),deviceId:"",targetState:{},delayMs:0}])},[u,x,o]),b=r.useCallback((C,w)=>{const E=[...u];E[C]=w,x(E)},[u,x]),g=r.useCallback(C=>{x(u.filter((w,E)=>E!==C))},[u,x]),v=r.useCallback(C=>{if(C===0)return;const w=[...u];[w[C-1],w[C]]=[w[C],w[C-1]],x(w)},[u,x]),y=r.useCallback(C=>{if(C===u.length-1)return;const w=[...u];[w[C],w[C+1]]=[w[C+1],w[C]],x(w)},[u,x]);return e.jsxs("div",{className:`nice-scene-action-builder ${d??""}`,style:{position:"relative",...p},"data-testid":m,children:[e.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:20},children:e.jsx(l.NiceTutorialButton,{steps:l.resolveTutorial(c,U_)})}),e.jsxs("div",{className:"nice-scene-action__list",role:"list",children:[u.length===0&&e.jsx("p",{className:"nice-scene-action__empty",role:"status",children:h("smartHome.noActions","No actions yet. Add the devices this scene should control.")}),u.map((C,w)=>e.jsx("div",{role:"listitem",children:e.jsx(W_,{action:C,devices:a,index:w,totalCount:u.length,onUpdate:E=>b(w,E),onRemove:()=>g(w),onMoveUp:()=>v(w),onMoveDown:()=>y(w)})},C.id))]}),e.jsxs("button",{type:"button",onClick:f,disabled:u.length>=o,className:"nice-scene-action__add-btn","aria-label":h("smartHome.addAction","Add action"),children:[e.jsx(l.NiceIcon,{name:"plus",size:14})," ",h("smartHome.addAction","Add action")]}),s&&u.length>0&&e.jsxs("div",{className:"nice-scene-action__preview","aria-live":"polite",children:[e.jsx("h4",{className:"nice-scene-action__preview-title",children:h("smartHome.sceneSummary","Scene summary:")}),e.jsx("ol",{className:"nice-scene-action__preview-list",children:u.filter(C=>C.deviceId).map((C,w)=>{const E=a.find(N=>N.id===C.deviceId);if(!E)return null;const S=Object.entries(C.targetState).map(([N,_])=>`${N}=${_}`).join(", ");return e.jsxs("li",{children:[w+1,". ",e.jsx("strong",{children:E.name})," ",e.jsx(l.NiceIcon,{name:"arrow-right",size:12})," ",S||h("smartHome.noStateChange","(no changes)"),C.delayMs?` ${h("smartHome.afterDelay","(after {seconds}s)").replace("{seconds}",String(C.delayMs/1e3))}`:""]},C.id)})})]})]})},Y_=[],J_=[{target:".nice-automation-editor",titleKey:"tutorial.automationRuleEditor.intro.title",title:"Automation rule editor",contentKey:"tutorial.automationRuleEditor.intro.content",content:"Define the trigger, add optional conditions, then list the actions to run — switch between the three sections using the tabs.",placement:"auto"}],Q_=[{value:"StateChange",key:"smartHome.trigger.stateChange",label:"Device state change"},{value:"Schedule",key:"smartHome.trigger.schedule",label:"Schedule (time)"},{value:"Sunrise",key:"smartHome.trigger.sunrise",label:"Sunrise"},{value:"Sunset",key:"smartHome.trigger.sunset",label:"Sunset"},{value:"Webhook",key:"smartHome.trigger.manual",label:"Manual trigger"}];function X_({trigger:t,devices:n,onChange:i}){const{t:a}=l.useNiceTranslation();return e.jsxs("div",{className:"nice-automation__section-body",children:[e.jsxs("label",{className:"nice-automation__field",children:[e.jsxs("span",{children:[a("smartHome.triggerType","Trigger type"),":"]}),e.jsx("select",{value:t.type,onChange:s=>i({...t,type:s.target.value,config:{}}),"aria-label":a("smartHome.triggerType","Trigger type"),children:Q_.map(s=>e.jsx("option",{value:s.value,children:a(s.key,s.label)},s.value))})]}),t.type==="StateChange"&&e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"nice-automation__field",children:[e.jsxs("span",{children:[a("smartHome.device","Device"),":"]}),e.jsxs("select",{value:t.config.deviceId??"",onChange:s=>i({...t,config:{...t.config,deviceId:s.target.value}}),"aria-label":a("smartHome.device","Device"),children:[e.jsx("option",{value:"",children:a("smartHome.selectPlaceholder","— select —")}),n.map(s=>e.jsx("option",{value:s.id,children:s.name},s.id))]})]}),e.jsxs("label",{className:"nice-automation__field",children:[e.jsxs("span",{children:[a("smartHome.propertyHint",'Property (e.g. "on", "temperature")'),":"]}),e.jsx("input",{type:"text",value:t.config.property??"",onChange:s=>i({...t,config:{...t.config,property:s.target.value}}),placeholder:"on","aria-label":a("smartHome.property","Property")})]}),e.jsxs("label",{className:"nice-automation__field",children:[e.jsxs("span",{children:[a("smartHome.newValue","New value"),":"]}),e.jsx("input",{type:"text",value:t.config.toValue??"",onChange:s=>i({...t,config:{...t.config,toValue:s.target.value}}),placeholder:"true","aria-label":a("smartHome.targetValue","Target value")})]})]}),t.type==="Schedule"&&e.jsxs("label",{className:"nice-automation__field",children:[e.jsxs("span",{children:[a("smartHome.cronExpression","Cron expression / time"),":"]}),e.jsx("input",{type:"text",value:t.config.cron??"",onChange:s=>i({...t,config:{...t.config,cron:s.target.value}}),placeholder:"0 7 * * *","aria-label":a("smartHome.schedule","Schedule")})]})]})}function Z_({condition:t,devices:n,index:i,total:a,onChange:s,onRemove:o,onMoveUp:c,onMoveDown:d}){const{t:p}=l.useNiceTranslation(),{t:m}=l.useNiceTranslation();return e.jsxs("div",{className:"nice-automation__condition-row",children:[i>0&&e.jsxs("select",{value:t.operator??"AND",onChange:h=>s({...t,operator:h.target.value}),className:"nice-automation__conjunction","aria-label":m("smartHome.logicalOperator","Logical operator"),children:[e.jsx("option",{value:"AND",children:p("automationRuleEditor.and","AND")}),e.jsx("option",{value:"OR",children:p("automationRuleEditor.or","OR")})]}),e.jsxs("select",{value:t.config.deviceId??"",onChange:h=>s({...t,config:{...t.config,deviceId:h.target.value}}),"aria-label":m("smartHome.device","Device"),children:[e.jsx("option",{value:"",children:m("smartHome.devicePlaceholder","— device —")}),n.map(h=>e.jsx("option",{value:h.id,children:h.name},h.id))]}),e.jsx("input",{type:"text",value:t.config.property??"",onChange:h=>s({...t,config:{...t.config,property:h.target.value}}),placeholder:m("smartHome.property","Property"),"aria-label":m("smartHome.property","Property")}),e.jsxs("select",{value:t.config.compOp??"eq",onChange:h=>s({...t,config:{...t.config,compOp:h.target.value}}),"aria-label":p("automationRuleEditor.operator","Operator"),children:[e.jsx("option",{value:"eq",children:"="}),e.jsx("option",{value:"neq",children:"≠"}),e.jsx("option",{value:"gt",children:">"}),e.jsx("option",{value:"lt",children:"<"}),e.jsx("option",{value:"gte",children:"≥"}),e.jsx("option",{value:"lte",children:"≤"})]}),e.jsx("input",{type:"text",value:String(t.config.value??""),onChange:h=>s({...t,config:{...t.config,value:h.target.value}}),placeholder:m("smartHome.value","Value"),"aria-label":m("smartHome.value","Value")}),e.jsxs("div",{className:"nice-automation__row-btns",children:[e.jsx("button",{type:"button",onClick:c,disabled:i===0,"aria-label":m("smartHome.moveUp","Move up"),children:e.jsx(l.NiceIcon,{name:"arrow-up",size:14})}),e.jsx("button",{type:"button",onClick:d,disabled:i===a-1,"aria-label":m("smartHome.moveDown","Move down"),children:e.jsx(l.NiceIcon,{name:"arrow-down",size:14})}),e.jsx("button",{type:"button",onClick:o,"aria-label":m("smartHome.removeCondition","Remove condition"),className:"nice-automation__remove",children:e.jsx(l.NiceIcon,{name:"close",size:14})})]})]})}function ej({action:t,devices:n,scenes:i,index:a,total:s,onChange:o,onRemove:c,onMoveUp:d,onMoveDown:p}){const{t:m}=l.useNiceTranslation(),{t:h}=l.useNiceTranslation();return e.jsxs("div",{className:"nice-automation__action-row",children:[e.jsxs("select",{value:t.type,onChange:u=>o({...t,type:u.target.value,config:{}}),"aria-label":h("smartHome.actionType","Action type"),children:[e.jsx("option",{value:"device",children:h("smartHome.action.setDeviceState","Set device state")}),e.jsx("option",{value:"scene",children:h("smartHome.activateScene","Activate scene")}),e.jsx("option",{value:"notify",children:h("smartHome.action.notify","Send notification")}),e.jsx("option",{value:"delay",children:h("smartHome.delay","Delay")})]}),t.type==="device"&&e.jsxs(e.Fragment,{children:[e.jsxs("select",{value:t.config.deviceId??"",onChange:u=>o({...t,config:{...t.config,deviceId:u.target.value}}),"aria-label":h("smartHome.device","Device"),children:[e.jsx("option",{value:"",children:h("smartHome.devicePlaceholder","— device —")}),n.map(u=>e.jsx("option",{value:u.id,children:u.name},u.id))]}),e.jsx("input",{type:"text",value:t.config.property??"",onChange:u=>o({...t,config:{...t.config,property:u.target.value}}),placeholder:h("smartHome.property","Property"),"aria-label":h("smartHome.property","Property")}),e.jsx("input",{type:"text",value:t.config.value??"",onChange:u=>o({...t,config:{...t.config,value:u.target.value}}),placeholder:h("smartHome.value","Value"),"aria-label":h("smartHome.value","Value")})]}),t.type==="scene"&&e.jsxs("select",{value:t.config.sceneId??"",onChange:u=>o({...t,config:{sceneId:u.target.value}}),"aria-label":h("smartHome.scene","Scene"),children:[e.jsx("option",{value:"",children:m("automationRuleEditor.scene","-- scene --")}),i.map(u=>e.jsx("option",{value:u.id,children:u.name},u.id))]}),t.type==="notify"&&e.jsx("input",{type:"text",value:t.config.message??"",onChange:u=>o({...t,config:{message:u.target.value}}),placeholder:h("smartHome.notificationText","Notification text"),"aria-label":h("smartHome.notificationText","Notification text")}),t.type==="delay"&&e.jsxs("label",{children:[e.jsx("span",{children:m("automationRuleEditor.seconds","Seconds:")}),e.jsx("input",{type:"number",min:1,max:3600,value:t.config.seconds??1,onChange:u=>o({...t,config:{seconds:Number(u.target.value)}}),"aria-label":h("smartHome.delaySeconds","Delay in seconds")})]}),e.jsxs("div",{className:"nice-automation__row-btns",children:[e.jsx("button",{type:"button",onClick:d,disabled:a===0,"aria-label":h("smartHome.moveUp","Move up"),children:e.jsx(l.NiceIcon,{name:"arrow-up",size:14})}),e.jsx("button",{type:"button",onClick:p,disabled:a===s-1,"aria-label":h("smartHome.moveDown","Move down"),children:e.jsx(l.NiceIcon,{name:"arrow-down",size:14})}),e.jsx("button",{type:"button",onClick:c,"aria-label":h("smartHome.removeAction","Remove action"),className:"nice-automation__remove",children:e.jsx(l.NiceIcon,{name:"close",size:14})})]})]})}const tj=({rule:t,onChange:n,availableDevices:i=Y_,availableScenes:a=[],tutorial:s,className:o,style:c,"data-testid":d})=>{const p=r.useRef(null);l.useRovingFocus(p,{orientation:"horizontal",wrap:!0,activateOnMove:!0});const{t:m}=l.useNiceTranslation(),{t:h}=l.useNiceTranslation(),[u,x]=r.useState("trigger"),f=r.useCallback(w=>n({...t,trigger:w}),[t,n]),b=r.useCallback(w=>n({...t,conditions:w}),[t,n]),g=r.useCallback(w=>n({...t,actions:w}),[t,n]),v=()=>b([...t.conditions??[],{operator:"AND",type:"device",config:{deviceId:"",property:"",compOp:"eq",value:""}}]),y=()=>g([...t.actions??[],{type:"device",config:{}}]),C=[{id:"trigger",label:h("smartHome.trigger","Trigger"),icon:"zap",badge:void 0},{id:"conditions",label:h("smartHome.conditions","Conditions"),icon:"search",badge:t.conditions?.length},{id:"actions",label:h("smartHome.actions","Actions"),icon:"play",badge:t.actions?.length}];return e.jsxs("div",{className:`nice-automation-editor ${o??""}`,style:{position:"relative",...c},"data-testid":d,children:[e.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:20},children:e.jsx(l.NiceTutorialButton,{steps:l.resolveTutorial(s,J_)})}),e.jsxs("div",{className:"nice-automation__header",children:[e.jsx("input",{type:"text",value:t.name,onChange:w=>n({...t,name:w.target.value}),className:"nice-automation__name-input",placeholder:h("smartHome.ruleNamePlaceholder","Automation rule name"),"aria-label":h("smartHome.ruleName","Rule name")}),e.jsxs("label",{className:"nice-automation__enable",children:[e.jsx("input",{type:"checkbox",checked:t.enabled,onChange:w=>n({...t,enabled:w.target.checked}),"aria-label":h("smartHome.enableRule","Enable rule")}),e.jsx("span",{children:m("automationRuleEditor.active","Active")})]})]}),e.jsx("div",{className:"nice-automation__section-tabs",ref:p,role:"tablist",children:C.map(w=>e.jsxs("button",{type:"button",role:"tab","aria-selected":u===w.id,className:`nice-automation__section-tab${u===w.id?" nice-automation__section-tab--active":""}`,onClick:()=>x(w.id),children:[e.jsx(l.NiceIcon,{name:w.icon,size:14})," ",w.label,w.badge?e.jsx("span",{className:"nice-automation__badge",children:w.badge}):null]},w.id))}),e.jsxs("div",{className:"nice-automation__section-content",role:"tabpanel",children:[u==="trigger"&&e.jsx(X_,{trigger:t.trigger,devices:i,onChange:f}),u==="conditions"&&e.jsxs("div",{className:"nice-automation__section-body",children:[(t.conditions??[]).length===0&&e.jsx("p",{className:"nice-automation__empty",children:h("smartHome.noConditions","No conditions — the rule always runs its actions when triggered.")}),(t.conditions??[]).map((w,E)=>e.jsx(Z_,{condition:w,devices:i,index:E,total:(t.conditions??[]).length,onChange:S=>{const N=[...t.conditions??[]];N[E]=S,b(N)},onRemove:()=>b((t.conditions??[]).filter((S,N)=>N!==E)),onMoveUp:()=>{const S=[...t.conditions??[]];[S[E-1],S[E]]=[S[E],S[E-1]],b(S)},onMoveDown:()=>{const S=[...t.conditions??[]];[S[E],S[E+1]]=[S[E+1],S[E]],b(S)}},E)),e.jsxs("button",{type:"button",onClick:v,className:"nice-automation__add-btn",children:[e.jsx(l.NiceIcon,{name:"plus",size:14})," ",h("smartHome.addCondition","Add condition")]})]}),u==="actions"&&e.jsxs("div",{className:"nice-automation__section-body",children:[(t.actions??[]).length===0&&e.jsx("p",{className:"nice-automation__empty",children:h("smartHome.noActionsShort","No actions.")}),(t.actions??[]).map((w,E)=>e.jsx(ej,{action:w,devices:i,scenes:a,index:E,total:(t.actions??[]).length,onChange:S=>{const N=[...t.actions??[]];N[E]=S,g(N)},onRemove:()=>g((t.actions??[]).filter((S,N)=>N!==E)),onMoveUp:()=>{const S=[...t.actions??[]];[S[E-1],S[E]]=[S[E],S[E-1]],g(S)},onMoveDown:()=>{const S=[...t.actions??[]];[S[E],S[E+1]]=[S[E+1],S[E]],g(S)}},E)),e.jsxs("button",{type:"button",onClick:y,className:"nice-automation__add-btn",children:[e.jsx(l.NiceIcon,{name:"plus",size:14})," ",h("smartHome.addAction","Add action")]})]})]})]})},nj=[];function ij(t,n){const i=typeof t=="string"?new Date(t):t;switch(n){case"hour":return`${i.getHours().toString().padStart(2,"0")}:00`;case"day":return i.toLocaleDateString("pl-PL",{day:"2-digit",month:"short"});case"week":return`tyg. ${Math.ceil(i.getDate()/7)}`;case"month":return i.toLocaleDateString("pl-PL",{month:"short"})}}function aj(t,n){const i=new Map;for(const a of t){const s=new Date(a.timestamp);let o;switch(n){case"hour":o=`${s.getFullYear()}-${s.getMonth()}-${s.getDate()}-${s.getHours()}`;break;case"day":o=`${s.getFullYear()}-${s.getMonth()}-${s.getDate()}`;break;case"week":o=`${s.getFullYear()}-W${Math.ceil(s.getDate()/7)}`;break;case"month":o=`${s.getFullYear()}-${s.getMonth()}`;break}i.set(o,(i.get(o)??0)+a.value)}return Array.from(i.entries()).sort(([a],[s])=>a.localeCompare(s)).map(([a,s])=>({bucketKey:a,label:ij(t.find(o=>{const c=new Date(o.timestamp);switch(n){case"hour":return`${c.getFullYear()}-${c.getMonth()}-${c.getDate()}-${c.getHours()}`===a;case"day":return`${c.getFullYear()}-${c.getMonth()}-${c.getDate()}`===a;case"week":return`${c.getFullYear()}-W${Math.ceil(c.getDate()/7)}`===a;case"month":return`${c.getFullYear()}-${c.getMonth()}`===a}})?.timestamp??new Date,n),value:Math.round(s*100)/100}))}const Wc=["var(--nice-accent, #6c5ce7)","var(--nice-color-success, #00b894)","var(--nice-warning, #f39c12)","var(--nice-color-accent-pink, #e84393)","var(--nice-info, #00cec9)","var(--nice-warning, #e17055)","var(--nice-primary, #0984e3)","var(--nice-accent, #6c5ce7)"],sj=({data:t=nj,period:n="week",groupBy:i="day",breakdown:a=!1,chartType:s="bar",showTrend:o=!1,unit:c="kWh",onDrillDown:d,className:p,style:m,"data-testid":h})=>{const{t:u}=l.useNiceTranslation(),x=r.useMemo(()=>aj(t,i),[t,i]),f=r.useMemo(()=>Math.max(...x.map(R=>R.value),1),[x]),b=r.useMemo(()=>x.reduce((R,I)=>R+I.value,0),[x]),g=b/(x.length||1),v=r.useMemo(()=>a?Array.from(new Set(t.map(R=>R.groupKey).filter(Boolean))):[],[t,a]),y=380,C=140,w=40,E=8,S=12,N=24,_=y-w-E,k=C-S-N,j=x.length,T=j>0?_/j*.7:0,P=j>0?_/j:0,B=r.useMemo(()=>{if(!o||x.length<2)return"";const R=x.map((U,re)=>re),I=x.map(U=>U.value),D=R.length,M=R.reduce((U,re)=>U+re,0),O=I.reduce((U,re)=>U+re,0),L=R.reduce((U,re,Y)=>U+re*I[Y],0),V=R.reduce((U,re)=>U+re*re,0),ee=(D*L-M*O)/(D*V-M*M),z=(O-ee*M)/D;return`${w+P*.15},${S+k-z/f*k} ${w+P*(D-.5)},${S+k-(ee*(D-1)+z)/f*k}`},[o,x,f,w,S,k,P]);return t.length===0?e.jsx("div",{className:`nice-energy-chart ${p??""}`,style:m,"data-testid":h,role:"status",children:e.jsx("p",{className:"nice-energy-chart__empty",children:u("smartHome.noEnergyData","No energy usage data.")})}):e.jsxs("div",{className:`nice-energy-chart nice-energy-chart--${s} ${p??""}`,style:m,"data-testid":h,children:[e.jsxs("div",{className:"nice-energy-chart__stats","aria-label":u("smartHome.statistics","Statistics"),children:[e.jsxs("div",{className:"nice-energy-chart__stat",children:[e.jsx("span",{className:"nice-energy-chart__stat-label",children:u("smartHome.total","Total")}),e.jsxs("strong",{className:"nice-energy-chart__stat-value",children:[b.toFixed(2)," ",c]})]}),e.jsxs("div",{className:"nice-energy-chart__stat",children:[e.jsx("span",{className:"nice-energy-chart__stat-label",children:u("smartHome.average","Average")}),e.jsxs("strong",{className:"nice-energy-chart__stat-value",children:[g.toFixed(2)," ",c]})]}),e.jsxs("div",{className:"nice-energy-chart__stat",children:[e.jsx("span",{className:"nice-energy-chart__stat-label",children:u("smartHome.max","Max.")}),e.jsxs("strong",{className:"nice-energy-chart__stat-value",children:[f.toFixed(2)," ",c]})]})]}),e.jsxs("svg",{viewBox:`0 0 ${y} ${C}`,className:"nice-energy-chart__svg",role:"img","aria-label":`${u("smartHome.energyChart","Energy usage chart")} — ${n}`,children:[[0,.25,.5,.75,1].map(R=>e.jsxs("g",{children:[e.jsx("line",{x1:w,x2:y-E,y1:S+k*(1-R),y2:S+k*(1-R),stroke:"var(--nice-border-color,#e5e7eb)",strokeWidth:.5}),e.jsx("text",{x:w-4,y:S+k*(1-R)+3,textAnchor:"end",fontSize:8,fill:"var(--nice-text-muted,#9ca3af)",children:(f*R).toFixed(1)})]},R)),x.map((R,I)=>{const D=R.value/f*k,M=w+P*I+(P-T)/2,O=S+k-D;return e.jsxs("g",{className:"nice-energy-chart__bar-group",onClick:()=>d?.(R.bucketKey),style:{cursor:d?"pointer":"default"},children:[e.jsx("rect",{x:M,y:O,width:T,height:D,fill:"var(--nice-accent, #6c5ce7)",rx:2,opacity:.85,children:e.jsxs("title",{children:[R.label,": ",R.value," ",c]})}),j<=12&&e.jsx("text",{x:M+T/2,y:C-N+10,textAnchor:"middle",fontSize:8,fill:"var(--nice-text-muted,#9ca3af)",children:R.label})]},R.bucketKey)}),s==="area"&&x.length>1&&e.jsx("path",{d:`M ${w+P*.15} ${S+k} `+x.map((R,I)=>`L ${w+P*I+P/2} ${S+k-R.value/f*k}`).join(" ")+` L ${w+P*(j-.15)} ${S+k} Z`,fill:"var(--nice-accent, #6c5ce7)",fillOpacity:.15,stroke:"none"}),(s==="line"||s==="area")&&x.length>1&&e.jsx("polyline",{points:x.map((R,I)=>`${w+P*I+P/2},${S+k-R.value/f*k}`).join(" "),fill:"none",stroke:"var(--nice-accent, #6c5ce7)",strokeWidth:2,strokeLinejoin:"round"}),o&&B&&e.jsx("line",{x1:B.split(" ")[0].split(",")[0],y1:B.split(" ")[0].split(",")[1],x2:B.split(" ")[1].split(",")[0],y2:B.split(" ")[1].split(",")[1],stroke:"var(--nice-warning, #f39c12)",strokeWidth:1.5,strokeDasharray:"4 2"})]}),a&&v.length>0&&e.jsx("div",{className:"nice-energy-chart__legend","aria-label":u("smartHome.deviceLegend","Device legend"),children:v.map((R,I)=>e.jsxs("span",{className:"nice-energy-chart__legend-item",children:[e.jsx("span",{className:"nice-energy-chart__legend-dot",style:{background:Wc[I%Wc.length]}}),R]},R))})]})},rj=[];function Ws(t,n,i){return i?.find(a=>a.deviceId===t&&a.type.toLowerCase()===n)}function oj({occupied:t}){const{t:n}=l.useNiceTranslation();return t===void 0?null:e.jsx("span",{className:`nice-room-card__occupancy${t?" nice-room-card__occupancy--yes":" nice-room-card__occupancy--no"}`,"aria-label":t?n("smartHome.occupied","Occupied"):n("smartHome.vacant","Vacant"),title:t?n("smartHome.roomOccupied","Room occupied"):n("smartHome.roomVacant","Room vacant"),children:t?e.jsxs(e.Fragment,{children:[e.jsx(l.NiceIcon,{name:"user",size:14})," ",n("smartHome.occupied","Occupied")]}):e.jsxs(e.Fragment,{children:[e.jsx(l.NiceIcon,{name:"minus",size:14})," ",n("smartHome.vacant","Vacant")]})})}function Ks({icon:t,value:n,unit:i,limit:a,reverse:s}){if(n===void 0)return null;let o="var(--nice-text-primary)";return a!==void 0&&(o=(s?n<a:n>a)?"var(--nice-color-error, #ef4444)":"var(--nice-color-success, #22c55e)"),e.jsxs("span",{className:"nice-room-card__sensor",style:{color:o},"aria-label":`${n}${i}`,children:[e.jsx(l.NiceIcon,{name:t,size:14})," ",e.jsx("strong",{children:n.toFixed(1)}),i]})}function cj({room:t,layout:n,showSensors:i,showDeviceCount:a,showOccupancy:s,sensorReadings:o,onClick:c}){const{t:d}=l.useNiceTranslation(),p=Ws(t.id,"temperature",o),m=Ws(t.id,"humidity",o),h=Ws(t.id,"co2",o);return e.jsxs("button",{type:"button",className:`nice-room-card nice-room-card--${n}`,onClick:()=>c(t.id),"aria-label":d("roomGrid.room","Room: {name}").replace("{name}",String(t.name)),children:[e.jsxs("div",{className:"nice-room-card__header",children:[e.jsx("span",{className:"nice-room-card__icon","aria-hidden":"true",children:e.jsx(l.NiceIcon,{name:"home",size:18})}),e.jsx("span",{className:"nice-room-card__name",children:t.name}),t.floor!==void 0&&e.jsxs("span",{className:"nice-room-card__floor",children:["P",t.floor]})]}),s&&e.jsx(oj,{occupied:t.occupancy}),i&&e.jsxs("div",{className:"nice-room-card__sensors",children:[e.jsx(Ks,{icon:"bar-chart",value:p?.value,unit:"°C",limit:28}),e.jsx(Ks,{icon:"cloud",value:m?.value,unit:"%",limit:30,reverse:!0}),e.jsx(Ks,{icon:"globe",value:h?.value,unit:" ppm",limit:1e3})]}),a&&t.deviceIds&&e.jsx("div",{className:"nice-room-card__devices",children:e.jsxs("span",{children:[e.jsx(l.NiceIcon,{name:"plug",size:14})," ",t.deviceIds.length," ",d("smartHome.devices","devices")]})})]})}const lj=({rooms:t=rj,onClick:n,layout:i="grid",showSensors:a=!0,showDeviceCount:s=!0,showOccupancy:o=!0,groupByFloor:c=!1,sensorReadings:d=[],className:p,style:m,"data-testid":h})=>{const{t:u}=l.useNiceTranslation(),x=r.useMemo(()=>{if(!c)return[{floor:null,rooms:t}];const f=new Map;for(const b of t){const g=b.floor??0;f.has(g)||f.set(g,[]),f.get(g).push(b)}return Array.from(f.entries()).sort(([b],[g])=>b-g).map(([b,g])=>({floor:b,rooms:g}))},[t,c]);return t.length===0?e.jsx("div",{className:`nice-room-grid ${p??""}`,style:m,"data-testid":h,role:"status",children:e.jsx("p",{className:"nice-room-grid__empty",children:u("smartHome.noRooms","No rooms.")})}):e.jsx("div",{className:`nice-room-grid nice-room-grid--${i} ${p??""}`,style:m,"data-testid":h,role:"list",children:x.map(f=>e.jsxs("div",{className:"nice-room-grid__group",children:[c&&f.floor!==null&&e.jsx("h3",{className:"nice-room-grid__floor-heading",children:f.floor===0?u("smartHome.groundFloor","Ground floor"):`${u("smartHome.floor","Floor")} ${f.floor}`}),e.jsx("div",{className:`nice-room-grid__cards nice-room-grid__cards--${i}`,role:"list",children:f.rooms.map(b=>e.jsx("div",{role:"listitem",children:e.jsx(cj,{room:b,layout:i,showSensors:a,showDeviceCount:s,showOccupancy:o,sensorReadings:d,onClick:n})},b.id))})]},f.floor??"all"))})},dj=[];function uj(t,n,i){if(!i)return"";const a=typeof i=="string"?new Date(i):i,s=Date.now()-a.getTime();return s<6e4?t("smartHome.justNow","just now"):s<36e5?`${Math.floor(s/6e4)} ${t("smartHome.minutesAgo","min ago")}`:s<864e5?`${Math.floor(s/36e5)}${t("smartHome.hoursAgo","h ago")}`:a.toLocaleDateString(n)}const pj=({scenes:t=dj,onActivate:n,confirm:i=!1,compact:a=!1,showLastActivated:s=!0,className:o,style:c,"data-testid":d})=>{const{t:p,lang:m}=l.useNiceTranslation(),[h,u]=r.useState(null),[x,f]=r.useState(null),[b,g]=r.useState(null),v=r.useRef(void 0),y=r.useRef(null),C=r.useRef(null);l.useRovingFocus(y,{orientation:"horizontal",itemSelector:".nice-scene-bar__btn"}),l.useOverlayFocus(C,{open:x!=null,onClose:()=>f(null),closeHint:p("smartHome.cancel","Cancel")});const w=N=>{if(i){f(N);return}E(N)},E=N=>{f(null),u(N),g(N),n(N),clearTimeout(v.current),v.current=setTimeout(()=>u(null),1200)},S=t.filter(N=>N.isQuickAccess!==!1);return e.jsxs("div",{ref:y,className:`nice-scene-bar${a?" nice-scene-bar--compact":""} ${o??""}`,style:c,"data-testid":d,role:"toolbar","aria-label":p("smartHome.sceneBar","Scene bar"),children:[S.length===0&&e.jsx("p",{className:"nice-scene-bar__empty",children:p("smartHome.noQuickScenes","No quick-access scenes.")}),S.map(N=>{const _=h===N.id,k=b===N.id;return e.jsxs("div",{className:"nice-scene-bar__item",children:[e.jsxs("button",{type:"button",className:`nice-scene-bar__btn${_?" nice-scene-bar__btn--activating":""}${k?" nice-scene-bar__btn--last":""}`,style:{"--scene-color":N.color??"var(--nice-accent, #6c5ce7)"},onClick:()=>w(N.id),"aria-label":`${p("smartHome.activateScene","Activate scene")}: ${N.name}`,"aria-pressed":_,children:[N.icon&&e.jsx("span",{className:"nice-scene-bar__icon","aria-hidden":"true",children:e.jsx(l.NiceIcon,{name:N.icon,size:a?16:22})}),!a&&e.jsx("span",{className:"nice-scene-bar__name",children:N.name}),_&&e.jsx("span",{className:"nice-scene-bar__pulse","aria-hidden":"true"})]}),s&&!a&&N.lastActivatedAt&&e.jsx("span",{className:"nice-scene-bar__last-activated",children:uj(p,m,N.lastActivatedAt)})]},N.id)}),x&&(()=>{const N=t.find(_=>_.id===x);return N?e.jsxs("div",{ref:C,className:"nice-scene-bar__confirm",role:"dialog","aria-modal":"true","aria-label":`${p("smartHome.confirmActivation","Confirm scene activation")}: ${N.name}`,children:[e.jsxs("p",{children:[p("smartHome.activateQuestion","Activate scene")," ",e.jsx("strong",{children:N.name}),"?"]}),e.jsxs("div",{className:"nice-scene-bar__confirm-btns",children:[e.jsx("button",{type:"button",className:"nice-scene-bar__confirm-yes",onClick:()=>E(x),children:p("smartHome.confirmActivate","Yes, activate")}),e.jsx("button",{type:"button",className:"nice-scene-bar__confirm-no",onClick:()=>f(null),children:p("smartHome.cancel","Cancel")})]})]}):null})()]})};function mj({url:t,timeout:n=15e3,slowThreshold:i=3e3,onTimeout:a,retryOnTimeout:s=!1,toastOnTimeout:o=!0,fetcher:c}){const[d,p]=r.useState(null),[m,h]=r.useState(!1),[u,x]=r.useState(null),[f,b]=r.useState(!1),[g,v]=r.useState(!1),y=r.useRef(null),C=r.useRef(null),w=r.useRef(null),E=r.useCallback(async()=>{C.current&&clearTimeout(C.current),w.current&&clearTimeout(w.current),y.current?.abort(),y.current=new AbortController,h(!0),b(!1),v(!1),x(null),C.current=setTimeout(()=>b(!0),i),w.current=setTimeout(()=>{y.current?.abort(),v(!0),h(!1),b(!1),a?.(t)},n);try{let S;if(c)S=await c(t);else{const N=await fetch(t,{signal:y.current.signal});if(!N.ok)throw new Error(`HTTP ${N.status}`);S=await N.json()}clearTimeout(C.current),clearTimeout(w.current),p(S)}catch(S){S.name!=="AbortError"&&x(S)}finally{h(!1),b(!1)}},[t,n,i,a,o,c]);return r.useEffect(()=>(E(),()=>{y.current?.abort(),C.current&&clearTimeout(C.current),w.current&&clearTimeout(w.current)}),[E]),{data:d,loading:m,error:u,isSlow:f,isTimedOut:g,refetch:E}}const hj=[],gj=({locales:t=hj,translations:n,defaultTranslations:i,onTranslationChange:a,onTranslationsChange:s,onLocaleAdd:o,onLocaleRemove:c,onExport:d,onImport:p,referenceLocale:m="en",showCompletionBadge:h=!0,filterUntranslated:u=!1,className:x,style:f,"data-testid":b})=>{const g=r.useRef(null);l.useRovingFocus(g,{orientation:"horizontal",wrap:!0,activateOnMove:!0});const{t:v}=l.useNiceTranslation(),[y,C]=r.useState("grid"),[w,E]=r.useState(null),[S,N]=r.useState(""),[_,k]=l.useControllableState({value:n,defaultValue:i,fallbackValue:{},onChange:s,componentName:"NiceLocaleManager"}),j=_[m]??{},P=Object.keys(j).filter(R=>u&&w&&_[w]?.[R]?!1:S?R.toLowerCase().includes(S.toLowerCase()):!0),B=R=>{const I=R.target.files?.[0];I&&w&&p(w,I)};return e.jsxs("div",{className:`nice-locale-manager ${x??""}`,style:f,"data-testid":b,children:[e.jsx("div",{className:"nice-locale-manager__tabs",ref:g,role:"tablist",children:["grid","editor","import-export"].map(R=>e.jsx("button",{role:"tab","aria-selected":y===R,className:`nice-locale-manager__tab${y===R?" nice-locale-manager__tab--active":""}`,onClick:()=>C(R),type:"button",children:R==="grid"?v("localeManager.languages","Languages"):R==="editor"?v("localeManager.translations","Translations"):v("localeManager.importExport","Import / Export")},R))}),y==="grid"&&e.jsx("div",{className:"nice-locale-manager__locale-grid",role:"tabpanel",children:t.map(R=>e.jsxs("div",{className:"nice-locale-manager__locale-card",children:[R.flag&&e.jsx("span",{className:"nice-locale-manager__flag",children:R.flag}),e.jsx("span",{className:"nice-locale-manager__locale-name",children:R.name}),e.jsx("span",{className:"nice-locale-manager__locale-native",children:R.nativeName}),h&&R.completionPercent!==void 0&&e.jsxs("span",{className:"nice-locale-manager__completion",children:[R.completionPercent,"%"]}),e.jsx("button",{onClick:()=>{E(R.code),C("editor")},type:"button",children:v("localeManager.edit","Edit")}),e.jsx("button",{onClick:()=>d(R.code,"json"),type:"button",children:v("localeManager.exportJson","Export JSON")}),e.jsx("button",{onClick:()=>c(R.code),type:"button","aria-label":`${v("localeManager.remove","Remove")} ${R.name}`,children:v("localeManager.remove","Remove")})]},R.code))}),y==="editor"&&e.jsxs("div",{className:"nice-locale-manager__editor",role:"tabpanel",children:[e.jsxs("div",{className:"nice-locale-manager__editor-toolbar",children:[e.jsxs("select",{value:w??"",onChange:R=>E(R.target.value),"aria-label":v("localeManager.selectLanguage","Select a language"),children:[e.jsxs("option",{value:"",children:["— ",v("localeManager.selectLanguage","Select a language")," —"]}),t.map(R=>e.jsx("option",{value:R.code,children:R.name},R.code))]}),e.jsx("input",{type:"search",placeholder:v("localeManager.searchKey","Search keys…"),value:S,onChange:R=>N(R.target.value),"aria-label":v("localeManager.searchKeyLabel","Search translation keys")})]}),e.jsxs("table",{className:"nice-locale-manager__table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:v("localeManager.key","Key")}),e.jsxs("th",{children:[m," (",v("localeManager.reference","reference"),")"]}),e.jsx("th",{children:w??"—"})]})}),e.jsx("tbody",{children:P.map(R=>e.jsxs("tr",{className:_[w??""]?.[R]?"":"nice-locale-manager__row--missing",children:[e.jsx("td",{children:e.jsx("code",{children:R})}),e.jsx("td",{children:j[R]}),e.jsx("td",{children:w?e.jsx("input",{type:"text",value:_[w]?.[R]??"",onChange:I=>{const D=I.target.value;a?.(w,R,D),k({..._,[w]:{..._[w],[R]:D}})},"aria-label":v("localeManager.translationOfKey","Translation of key {key}").replace("{key}",R)}):"—"})]},R))})]})]}),y==="import-export"&&e.jsxs("div",{className:"nice-locale-manager__io",role:"tabpanel",children:[e.jsxs("div",{className:"nice-locale-manager__io-row",children:[e.jsxs("label",{htmlFor:"nice-locale-import-file",children:[v("localeManager.importFile","Import a translation file"),":"]}),e.jsxs("select",{value:w??"",onChange:R=>E(R.target.value),"aria-label":v("localeManager.importLanguage","Language to import"),children:[e.jsxs("option",{value:"",children:["— ",v("localeManager.selectLanguage","Select a language")," —"]}),t.map(R=>e.jsx("option",{value:R.code,children:R.name},R.code))]}),e.jsx("input",{id:"nice-locale-import-file",type:"file",accept:".json,.csv,.xliff,.xlf",onChange:B})]}),e.jsxs("div",{className:"nice-locale-manager__io-row",children:[e.jsxs("span",{children:[v("localeManager.export","Export"),":"]}),t.map(R=>e.jsxs("span",{children:[e.jsx("button",{onClick:()=>d(R.code,"json"),type:"button",children:v("localeManager.json","{name} JSON").replace("{name}",String(R.name))}),e.jsxs("button",{onClick:()=>d(R.code,"csv"),type:"button",children:[R.name," CSV"]}),e.jsx("button",{onClick:()=>d(R.code,"xliff"),type:"button",children:v("localeManager.xliff","{name} XLIFF").replace("{name}",String(R.name))})]},R.code))]})]})]})};function bj(t,n){const i=[];t.elements.filter(o=>o.elementType==="event"&&o.eventType==="startEvent").length===0&&i.push({type:"error",message:n("workflowDesigner.val.bpmnNoStart","Process must have at least one start event")}),t.elements.filter(o=>o.elementType==="event"&&o.eventType==="endEvent").length===0&&i.push({type:"error",message:n("workflowDesigner.val.bpmnNoEnd","Process must have at least one end event")});for(const o of t.elements){const c=o.id,d=t.sequenceFlows.some(m=>m.targetRef===c),p=t.sequenceFlows.some(m=>m.sourceRef===c);o.elementType==="event"?(o.eventType==="startEvent"&&!p&&i.push({type:"warning",message:n("workflowDesigner.val.startNoOut",'Start event "{name}" has no outgoing flow').replace("{name}",o.name),elementId:c}),o.eventType==="endEvent"&&!d&&i.push({type:"warning",message:n("workflowDesigner.val.endNoIn",'End event "{name}" has no incoming flow').replace("{name}",o.name),elementId:c})):(o.elementType==="task"||o.elementType==="gateway")&&(d||i.push({type:"warning",message:n("workflowDesigner.val.unreachable",'Element "{name}" is unreachable').replace("{name}",o.name||c),elementId:c}),p||i.push({type:"warning",message:n("workflowDesigner.val.elemNoOut",'Element "{name}" has no outgoing flow').replace("{name}",o.name||c),elementId:c}))}for(const o of t.elements)if(o.elementType==="gateway"&&o.gatewayType==="exclusiveGateway"){const c=t.sequenceFlows.filter(p=>p.sourceRef===o.id),d=c.filter(p=>p.conditionExpression||p.isDefault);c.length>1&&d.length<c.length-1&&i.push({type:"warning",message:n("workflowDesigner.val.xorNoConditions",'Exclusive gateway "{name}" should have conditions on its flows').replace("{name}",o.name||o.id),elementId:o.id})}return i}const fj={none:"circle",message:"mail",timer:"clock",error:"zap",escalation:"target",cancel:"close",compensation:"refresh",signal:"target",terminate:"circle",link:"arrow-right"},vj={task:"check-square",userTask:"user",serviceTask:"settings",scriptTask:"file",businessRuleTask:"clipboard",sendTask:"upload",receiveTask:"download",manualTask:"cursor",callActivity:"arrow-right"},xj={events:"circle",tasks:"square",gateways:"diamond",subprocesses:"layers",artifacts:"file"},Kc={events:"Events",tasks:"Tasks",gateways:"Gateways",subprocesses:"Subprocesses",artifacts:"Artifacts"},yj={exclusiveGateway:"close",parallelGateway:"plus",inclusiveGateway:"circle",eventBasedGateway:"target",complexGateway:"star"},Nj=[{id:"startEvent",label:"Start Event",icon:"circle",category:"events",elementType:"startEvent"},{id:"endEvent",label:"End Event",icon:"circle",category:"events",elementType:"endEvent"},{id:"timerStartEvent",label:"Timer Start",icon:"clock",category:"events",elementType:"startEvent",eventDefinition:"timer"},{id:"messageStartEvent",label:"Message Start",icon:"mail",category:"events",elementType:"startEvent",eventDefinition:"message"},{id:"timerIntermediateEvent",label:"Timer Catch",icon:"clock",category:"events",elementType:"intermediateCatchEvent",eventDefinition:"timer"},{id:"messageIntermediateEvent",label:"Message Catch",icon:"mail",category:"events",elementType:"intermediateCatchEvent",eventDefinition:"message"},{id:"errorEndEvent",label:"Error End",icon:"zap",category:"events",elementType:"endEvent",eventDefinition:"error"},{id:"terminateEndEvent",label:"Terminate End",icon:"circle",category:"events",elementType:"endEvent",eventDefinition:"terminate"},{id:"task",label:"Task",icon:"check-square",category:"tasks",elementType:"task"},{id:"userTask",label:"User Task",icon:"user",category:"tasks",elementType:"userTask"},{id:"serviceTask",label:"Service Task",icon:"settings",category:"tasks",elementType:"serviceTask"},{id:"scriptTask",label:"Script Task",icon:"file",category:"tasks",elementType:"scriptTask"},{id:"businessRuleTask",label:"Business Rule",icon:"clipboard",category:"tasks",elementType:"businessRuleTask"},{id:"sendTask",label:"Send Task",icon:"upload",category:"tasks",elementType:"sendTask"},{id:"receiveTask",label:"Receive Task",icon:"download",category:"tasks",elementType:"receiveTask"},{id:"manualTask",label:"Manual Task",icon:"cursor",category:"tasks",elementType:"manualTask"},{id:"callActivity",label:"Call Activity",icon:"arrow-right",category:"tasks",elementType:"callActivity"},{id:"exclusiveGateway",label:"Exclusive (XOR)",icon:"close",category:"gateways",elementType:"exclusiveGateway"},{id:"parallelGateway",label:"Parallel (AND)",icon:"plus",category:"gateways",elementType:"parallelGateway"},{id:"inclusiveGateway",label:"Inclusive (OR)",icon:"circle",category:"gateways",elementType:"inclusiveGateway"},{id:"eventBasedGateway",label:"Event-Based",icon:"target",category:"gateways",elementType:"eventBasedGateway"},{id:"subProcess",label:"Subprocess",icon:"box",category:"subprocesses",elementType:"subProcess"},{id:"transaction",label:"Transaction",icon:"box",category:"subprocesses",elementType:"transaction"},{id:"textAnnotation",label:"Annotation",icon:"edit",category:"artifacts",elementType:"textAnnotation"},{id:"dataObject",label:"Data Object",icon:"file",category:"artifacts",elementType:"dataObject"}];function Sr(t){return`${t}_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}function Yc(t,n){const i=Sr(t.elementType);return t.category==="events"?{id:i,name:t.label,elementType:"event",eventType:t.elementType,eventDefinition:t.eventDefinition||"none",position:n}:t.category==="tasks"?{id:i,name:t.label,elementType:"task",taskType:t.elementType,position:n,size:{width:100,height:80}}:t.category==="gateways"?{id:i,name:"",elementType:"gateway",gatewayType:t.elementType,position:n}:t.category==="subprocesses"?{id:i,name:t.label,elementType:"subprocess",position:n,size:{width:300,height:200},isExpanded:!0,elements:[],sequenceFlows:[]}:null}function Ua(t,n){return Math.round(t/n)*n}const _j=({process:t,onChange:n,availableUsers:i=[],availableRoles:a=[],readOnly:s=!1,showMinimap:o=!0,showToolbar:c=!0,showValidation:d=!0,showPalette:p=!0,showProperties:m=!0,showVariables:h=!1,gridSize:u=20,snapToGrid:x=!0,onTest:f,onPublish:b,onExportBPMN:g,onImportBPMN:v,className:y,style:C,"data-testid":w})=>{const E=r.useRef(null);l.useRovingFocus(E,{orientation:"horizontal",wrap:!0,activateOnMove:!0});const{t:S}=l.useNiceTranslation(),{t:N}=l.useNiceTranslation(),[_,k]=r.useState(null),[j,T]=r.useState(null),[P,B]=r.useState(null),[R,I]=r.useState(null),[D,M]=r.useState({x:0,y:0}),[O,L]=r.useState(1),[V,ee]=r.useState(!1),z=r.useRef(null),[U,re]=r.useState("tasks"),[Y,oe]=r.useState(!1),[q,se]=r.useState(null),ce=r.useMemo(()=>d?bj(t,N):[],[t,d,N]),le=ce.filter($=>$.type==="error"),J=ce.filter($=>$.type==="warning"),me=r.useMemo(()=>t.elements.find($=>$.id===_),[t.elements,_]),je=r.useMemo(()=>t.sequenceFlows.find($=>$.id===j),[t.sequenceFlows,j]),ue=r.useMemo(()=>Nj.filter($=>$.category===U).map($=>({...$,label:N(`workflowDesigner.palette.${$.id}`,$.label)})),[U,N]),F=r.useCallback($=>{if(s||!P)return;const X=$.currentTarget.getBoundingClientRect();let ae=($.clientX-X.left-D.x)/O,ve=($.clientY-X.top-D.y)/O;x&&(ae=Ua(ae,u),ve=Ua(ve,u));const Ce=Yc(P,{x:ae,y:ve});Ce&&(n?.({...t,elements:[...t.elements,Ce]}),k(Ce.id)),B(null)},[s,P,D,O,x,u,t,n]),H=r.useCallback($=>{if(s)return;const X=t.elements.length%8*30;let ae=(40-D.x)/O+X,ve=(40-D.y)/O+X;x&&(ae=Ua(ae,u),ve=Ua(ve,u));const Ce=Yc($,{x:ae,y:ve});Ce&&(n?.({...t,elements:[...t.elements,Ce]}),k(Ce.id))},[s,D,O,x,u,t,n]),A=r.useRef(null),Z=r.useRef(null);l.useRovingFocus(A,{orientation:"vertical",typeahead:!0}),l.useRovingFocus(Z,{orientation:"horizontal",itemSelector:"button"});const fe=r.useCallback($=>{if(R){const X={id:Sr("flow"),sourceRef:R.fromId,targetRef:$};n?.({...t,sequenceFlows:[...t.sequenceFlows,X]}),I(null)}else k($),T(null)},[R,t,n]),Ne=r.useCallback($=>{s||I({fromId:$})},[s]),K=r.useCallback($=>{s||(n?.({...t,elements:t.elements.filter(X=>X.id!==$),sequenceFlows:t.sequenceFlows.filter(X=>X.sourceRef!==$&&X.targetRef!==$)}),_===$&&k(null))},[s,t,n,_]),Q=r.useCallback($=>{s||(n?.({...t,sequenceFlows:t.sequenceFlows.filter(X=>X.id!==$)}),j===$&&T(null))},[s,t,n,j]),ne=r.useCallback(($,X)=>{s||n?.({...t,elements:t.elements.map(ae=>ae.id===$?{...ae,...X}:ae)})},[s,t,n]),G=r.useCallback(($,X)=>{s||n?.({...t,sequenceFlows:t.sequenceFlows.map(ae=>ae.id===$?{...ae,...X}:ae)})},[s,t,n]),Se=r.useCallback(()=>{if(s)return;const $={id:Sr("var"),name:"newVariable",type:"string"};n?.({...t,variables:[...t.variables||[],$]})},[s,t,n]),te=r.useCallback(()=>{const $=t.elements.find(X=>X.elementType==="event"&&X.eventType==="startEvent");$&&(se($.id),oe(!0))},[t.elements]),we=r.useCallback($=>{const X=t.sequenceFlows.find(ae=>ae.id===$);X&&se(X.targetRef)},[t.sequenceFlows]),ie=r.useCallback($=>{const X=_===$.id,ae=Y&&q===$.id,ve=ce.some(Re=>Re.elementId===$.id),Ce=Y?t.sequenceFlows.filter(Re=>Re.sourceRef===$.id):[];let _e,ke="nice-bpmn-element",Ee={left:$.position.x,top:$.position.y};if($.elementType==="event"){const Re=fj[$.eventDefinition],qe=$.eventType==="startEvent",Ye=$.eventType==="endEvent",We=$.eventType==="boundaryEvent";ke+=" nice-bpmn-event",ke+=qe?" nice-bpmn-event--start":"",ke+=Ye?" nice-bpmn-event--end":"",ke+=We?" nice-bpmn-event--boundary":"",_e=e.jsx("div",{className:"nice-bpmn-event__icon",title:$.name,children:e.jsx(l.NiceIcon,{name:Re,size:16})})}else if($.elementType==="task"){const Re=vj[$.taskType];ke+=" nice-bpmn-task",ke+=` nice-bpmn-task--${$.taskType}`,Ee={...Ee,width:$.size?.width||100,height:$.size?.height||80},_e=e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"nice-bpmn-task__icon",children:e.jsx(l.NiceIcon,{name:Re,size:16})}),e.jsx("span",{className:"nice-bpmn-task__name",children:$.name}),$.assignee&&e.jsxs("span",{className:"nice-bpmn-task__assignee",children:[e.jsx(l.NiceIcon,{name:"user",size:14})," ",$.assignee]}),$.sla&&e.jsx("span",{className:"nice-bpmn-task__sla",title:S("workflowDesigner.slaHH","SLA: {warningHours}h / {criticalHours}h").replace("{warningHours}",String($.sla.warningHours)).replace("{criticalHours}",String($.sla.criticalHours)),children:e.jsx(l.NiceIcon,{name:"clock",size:14})}),$.loopCharacteristics&&e.jsx("span",{className:"nice-bpmn-task__loop",children:e.jsx(l.NiceIcon,{name:$.loopCharacteristics.type==="multiInstanceParallel"?"bars-vertical":$.loopCharacteristics.type==="multiInstanceSequential"?"menu":"refresh",size:12})})]})}else if($.elementType==="gateway"){const Re=yj[$.gatewayType];ke+=" nice-bpmn-gateway",ke+=` nice-bpmn-gateway--${$.gatewayType}`,_e=e.jsx("div",{className:"nice-bpmn-gateway__diamond",children:e.jsx("span",{children:e.jsx(l.NiceIcon,{name:Re,size:16})})})}else $.elementType==="subprocess"&&(ke+=" nice-bpmn-subprocess",ke+=$.isExpanded?" nice-bpmn-subprocess--expanded":"",Ee={...Ee,width:$.size.width,height:$.size.height},_e=e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"nice-bpmn-subprocess__header",children:[e.jsx("span",{children:$.name}),e.jsx("button",{type:"button",onClick:Re=>{Re.stopPropagation(),ne($.id,{isExpanded:!$.isExpanded})},"aria-label":$.isExpanded?N("workflowDesigner.collapse","Collapse"):N("workflowDesigner.expand","Expand"),children:$.isExpanded?"−":"+"})]}),$.isExpanded&&e.jsx("div",{className:"nice-bpmn-subprocess__content"})]}));return X&&(ke+=" nice-bpmn-element--selected"),ae&&(ke+=" nice-bpmn-element--active"),ve&&(ke+=" nice-bpmn-element--has-issue"),e.jsxs("div",{className:ke,style:Ee,onClick:Re=>{Re.stopPropagation(),fe($.id)},role:"button",tabIndex:0,"aria-label":`${$.elementType}: ${$.name||$.id}`,onKeyDown:Re=>{Re.key==="Enter"&&fe($.id),Re.key==="Delete"&&!s&&K($.id)},children:[_e,!s&&X&&e.jsxs("div",{className:"nice-bpmn-element__actions",children:[e.jsx("button",{type:"button",className:"nice-bpmn-element__action nice-bpmn-element__action--connect",onClick:Re=>{Re.stopPropagation(),Ne($.id)},title:N("workflowDesigner.connect","Connect"),"aria-label":N("workflowDesigner.startConnect","Start connection"),children:e.jsx(l.NiceIcon,{name:"arrow-right",size:14})}),e.jsx("button",{type:"button",className:"nice-bpmn-element__action nice-bpmn-element__action--delete",onClick:Re=>{Re.stopPropagation(),K($.id)},title:N("workflowDesigner.delete","Delete"),"aria-label":N("workflowDesigner.deleteElement","Delete element"),children:e.jsx(l.NiceIcon,{name:"close",size:12})})]}),ae&&Ce.map(Re=>e.jsxs("button",{type:"button",className:"nice-bpmn-element__sim-action",onClick:qe=>{qe.stopPropagation(),we(Re.id)},children:[e.jsx(l.NiceIcon,{name:"arrow-right",size:12}),Re.name||t.elements.find(qe=>qe.id===Re.targetRef)?.name||N("workflowDesigner.next","Next")]},Re.id))]},$.id)},[_,Y,q,ce,t.sequenceFlows,t.elements,s,fe,Ne,K,ne,we,N,S]),xe=r.useCallback(()=>e.jsxs("svg",{className:"nice-bpmn-flows",style:{position:"absolute",inset:0,pointerEvents:"none",overflow:"visible"},children:[e.jsxs("defs",{children:[e.jsx("marker",{id:"arrowhead",markerWidth:"10",markerHeight:"7",refX:"9",refY:"3.5",orient:"auto",children:e.jsx("polygon",{points:"0 0, 10 3.5, 0 7",fill:"var(--nice-text-secondary, #64748b)"})}),e.jsx("marker",{id:"arrowhead-selected",markerWidth:"10",markerHeight:"7",refX:"9",refY:"3.5",orient:"auto",children:e.jsx("polygon",{points:"0 0, 10 3.5, 0 7",fill:"var(--nice-color-primary, #3b82f6)"})})]}),t.sequenceFlows.map($=>{const X=t.elements.find(qe=>qe.id===$.sourceRef),ae=t.elements.find(qe=>qe.id===$.targetRef);if(!X||!ae)return null;const ve=j===$.id,Ce=X.position.x+(X.elementType==="task"?X.size?.width||100:X.elementType==="gateway"?25:15),_e=X.position.y+(X.elementType==="task"?(X.size?.height||80)/2:X.elementType==="gateway"?25:15),ke=ae.position.x,Ee=ae.position.y+(ae.elementType==="task"?(ae.size?.height||80)/2:ae.elementType==="gateway"?25:15),Re=$.waypoints&&$.waypoints.length>0?`M ${Ce} ${_e} ${$.waypoints.map(qe=>`L ${qe.x} ${qe.y}`).join(" ")} L ${ke} ${Ee}`:`M ${Ce} ${_e} L ${ke} ${Ee}`;return e.jsxs("g",{children:[e.jsx("path",{d:Re,fill:"none",stroke:ve?"var(--nice-color-primary, #3b82f6)":"var(--nice-text-muted, #64748b)",strokeWidth:ve?3:2,strokeDasharray:$.isDefault?"5,5":void 0,markerEnd:ve?"url(#arrowhead-selected)":"url(#arrowhead)",style:{pointerEvents:"stroke",cursor:"pointer"},onClick:()=>{T($.id),k(null)}}),$.name&&e.jsx("text",{x:(Ce+ke)/2,y:(_e+Ee)/2-5,textAnchor:"middle",fontSize:"11",fill:"var(--nice-text-secondary, #64748b)",children:$.name}),$.conditionExpression&&e.jsxs("text",{x:(Ce+ke)/2,y:(_e+Ee)/2+10,textAnchor:"middle",fontSize:"10",fill:"var(--nice-text-muted, #94a3b8)",fontStyle:"italic",children:["[",$.conditionExpression.substring(0,20),"...]"]})]},$.id)}),R&&e.jsx("line",{x1:t.elements.find($=>$.id===R.fromId)?.position.x||0,y1:t.elements.find($=>$.id===R.fromId)?.position.y||0,x2:t.elements.find($=>$.id===R.fromId)?.position.x||0,y2:t.elements.find($=>$.id===R.fromId)?.position.y||0,stroke:"var(--nice-color-primary, #3b82f6)",strokeWidth:"2",strokeDasharray:"5,5"})]}),[t.sequenceFlows,t.elements,j,R]),W=c?e.jsxs("div",{ref:Z,className:"nice-bpmn-designer__toolbar",role:"toolbar","aria-label":N("workflowDesigner.bpmnToolbar","BPMN designer toolbar"),children:[e.jsxs("div",{className:"nice-bpmn-designer__toolbar-group",children:[e.jsx("button",{type:"button",onClick:()=>L($=>Math.min($+.1,2)),title:N("workflowDesigner.zoomIn","Zoom in"),"aria-label":N("workflowDesigner.zoomIn","Zoom in"),children:e.jsx(l.NiceIcon,{name:"plus",size:14})}),e.jsxs("span",{className:"nice-bpmn-designer__zoom-label",children:[Math.round(O*100),"%"]}),e.jsx("button",{type:"button",onClick:()=>L($=>Math.max($-.1,.5)),title:N("workflowDesigner.zoomOut","Zoom out"),"aria-label":N("workflowDesigner.zoomOut","Zoom out"),children:e.jsx(l.NiceIcon,{name:"minus",size:14})}),e.jsx("button",{type:"button",onClick:()=>{L(1),M({x:0,y:0})},title:N("workflowDesigner.resetView","Reset view"),"aria-label":N("workflowDesigner.resetView","Reset view"),children:e.jsx(l.NiceIcon,{name:"refresh",size:14})})]}),e.jsxs("div",{className:"nice-bpmn-designer__toolbar-group",children:[!s&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",onClick:te,disabled:le.length>0||Y,title:N("workflowDesigner.simulateFlow","Simulate flow"),children:[e.jsx(l.NiceIcon,{name:"play",size:14})," ",N("workflowDesigner.simulate","Simulate")]}),Y&&e.jsxs("button",{type:"button",onClick:()=>{oe(!1),se(null)},children:[e.jsx(l.NiceIcon,{name:"stop",size:14})," ",N("workflowDesigner.stop","Stop")]})]}),f&&e.jsxs("button",{type:"button",onClick:()=>f(t),title:N("workflowDesigner.testProcess","Test process"),children:[e.jsx(l.NiceIcon,{name:"flask",size:14})," ",N("workflowDesigner.test","Test")]}),b&&!s&&e.jsxs("button",{type:"button",onClick:()=>b(t),disabled:le.length>0,title:N("workflowDesigner.publishProcess","Publish process"),children:[e.jsx(l.NiceIcon,{name:"rocket",size:14})," ",N("workflowDesigner.publish","Publish")]}),g&&e.jsxs("button",{type:"button",onClick:()=>g("<bpmn>"),title:N("workflowDesigner.exportBpmn","Export BPMN XML"),children:[e.jsx(l.NiceIcon,{name:"upload",size:14})," ",N("workflowDesigner.export","Export")]}),v&&!s&&e.jsxs("button",{type:"button",onClick:v,title:N("workflowDesigner.importBpmn","Import BPMN XML"),children:[e.jsx(l.NiceIcon,{name:"download",size:14})," ",N("workflowDesigner.import","Import")]})]})]}):void 0,be=p&&!s?e.jsxs("aside",{className:"nice-bpmn-designer__palette","aria-label":N("workflowDesigner.palette","BPMN element palette"),children:[e.jsx("div",{className:"nice-bpmn-designer__palette-tabs",ref:E,role:"tablist",children:["events","tasks","gateways","subprocesses","artifacts"].map($=>e.jsx("button",{type:"button",role:"tab","aria-selected":U===$,className:`nice-bpmn-designer__palette-tab${U===$?" nice-bpmn-designer__palette-tab--active":""}`,onClick:()=>re($),"aria-label":N(`workflowDesigner.cat.${$}`,Kc[$]),title:N(`workflowDesigner.cat.${$}`,Kc[$]),children:e.jsx(l.NiceIcon,{name:xj[$],size:16})},$))}),e.jsx("div",{ref:A,className:"nice-bpmn-designer__palette-items",role:"listbox","aria-label":N("workflowDesigner.palette","BPMN element palette"),children:ue.map($=>e.jsxs("div",{className:"nice-bpmn-designer__palette-item",draggable:!0,onDragStart:()=>B($),onDragEnd:()=>B(null),onKeyDown:X=>{(X.key==="Enter"||X.key===" ")&&(X.preventDefault(),H($))},role:"option","aria-selected":!1,"aria-label":$.label,children:[e.jsx("span",{className:"nice-bpmn-designer__palette-icon",children:e.jsx(l.NiceIcon,{name:$.icon,size:16})}),e.jsx("span",{className:"nice-bpmn-designer__palette-label",children:$.label})]},$.id))})]}):void 0,Te=m&&(me||je)&&!s,Me=Te||h?e.jsxs("div",{style:{display:"flex",height:"100%",minHeight:0},children:[Te&&e.jsxs("aside",{className:"nice-bpmn-designer__properties","aria-label":N("workflowDesigner.properties","Properties"),children:[me&&e.jsxs(e.Fragment,{children:[e.jsx("h3",{children:N("workflowDesigner.propertiesOf","Properties: {name}").replace("{name}",me.name||me.id)}),e.jsxs("div",{className:"nice-bpmn-designer__property",children:[e.jsx("label",{htmlFor:"prop-name",children:N("workflowDesigner.name","Name")}),e.jsx("input",{id:"prop-name",type:"text",value:me.name||"",onChange:$=>ne(me.id,{name:$.target.value})})]}),me.elementType==="task"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"nice-bpmn-designer__property",children:[e.jsx("label",{htmlFor:"prop-assignee",children:N("workflowDesigner.assignee","Assigned to")}),e.jsxs("select",{id:"prop-assignee",value:me.assignee||"",onChange:$=>ne(me.id,{assignee:$.target.value}),children:[e.jsx("option",{value:"",children:N("workflowDesigner.select","— Select —")}),i.map($=>e.jsx("option",{value:$.id,children:$.name},$.id))]})]}),e.jsxs("div",{className:"nice-bpmn-designer__property",children:[e.jsx("label",{htmlFor:"prop-dueDate",children:N("workflowDesigner.dueDate","Due date")}),e.jsx("input",{id:"prop-dueDate",type:"text",placeholder:N("workflowDesigner.dueDatePlaceholder","P3D (3 days)"),value:me.dueDate||"",onChange:$=>ne(me.id,{dueDate:$.target.value})})]}),e.jsxs("div",{className:"nice-bpmn-designer__property",children:[e.jsx("label",{htmlFor:"prop-priority",children:N("workflowDesigner.priority","Priority")}),e.jsx("input",{id:"prop-priority",type:"number",min:"0",max:"100",value:me.priority||50,onChange:$=>ne(me.id,{priority:parseInt($.target.value)})})]}),e.jsxs("div",{className:"nice-bpmn-designer__property",children:[e.jsx("label",{htmlFor:"prop-documentation",children:N("workflowDesigner.documentation","Documentation")}),e.jsx("textarea",{id:"prop-documentation",value:me.documentation||"",onChange:$=>ne(me.id,{documentation:$.target.value}),rows:3})]})]}),me.elementType==="event"&&me.eventDefinition==="timer"&&e.jsxs("div",{className:"nice-bpmn-designer__property",children:[e.jsx("label",{htmlFor:"prop-timer",children:N("workflowDesigner.timer","Timer (ISO 8601)")}),e.jsx("input",{id:"prop-timer",type:"text",placeholder:N("workflowDesigner.timerPlaceholder","PT1H (1 hour) or R3/PT1H (3 repetitions)"),value:me.timerDefinition?.expression||"",onChange:$=>ne(me.id,{timerDefinition:{type:"duration",expression:$.target.value}})})]}),me.elementType==="gateway"&&me.gatewayType==="exclusiveGateway"&&e.jsxs("div",{className:"nice-bpmn-designer__property",children:[e.jsx("label",{htmlFor:"prop-default",children:N("workflowDesigner.defaultFlow","Default flow")}),e.jsxs("select",{id:"prop-default",value:me.defaultFlow||"",onChange:$=>ne(me.id,{defaultFlow:$.target.value}),children:[e.jsx("option",{value:"",children:N("workflowDesigner.select","— Select —")}),t.sequenceFlows.filter($=>$.sourceRef===me.id).map($=>e.jsx("option",{value:$.id,children:$.name||$.id},$.id))]})]})]}),je&&e.jsxs(e.Fragment,{children:[e.jsx("h3",{children:N("workflowDesigner.flowOf","Flow: {name}").replace("{name}",je.name||je.id)}),e.jsxs("div",{className:"nice-bpmn-designer__property",children:[e.jsx("label",{htmlFor:"flow-name",children:N("workflowDesigner.name","Name")}),e.jsx("input",{id:"flow-name",type:"text",value:je.name||"",onChange:$=>G(je.id,{name:$.target.value})})]}),e.jsxs("div",{className:"nice-bpmn-designer__property",children:[e.jsx("label",{htmlFor:"flow-condition",children:N("workflowDesigner.condition","Condition")}),e.jsx("input",{id:"flow-condition",type:"text",placeholder:"${amount > 1000}",value:je.conditionExpression||"",onChange:$=>G(je.id,{conditionExpression:$.target.value})})]}),e.jsx("div",{className:"nice-bpmn-designer__property",children:e.jsxs("label",{children:[e.jsx("input",{type:"checkbox",checked:je.isDefault||!1,onChange:$=>G(je.id,{isDefault:$.target.checked})}),N("workflowDesigner.defaultFlow","Default flow")]})}),e.jsxs("button",{type:"button",className:"nice-bpmn-designer__delete-flow",onClick:()=>Q(je.id),children:[e.jsx(l.NiceIcon,{name:"trash",size:14})," ",N("workflowDesigner.deleteFlow","Delete flow")]})]})]}),h&&e.jsxs("aside",{className:"nice-bpmn-designer__variables","aria-label":N("workflowDesigner.variables","Process variables"),children:[e.jsx("h3",{children:N("workflowDesigner.variables","Process variables")}),e.jsx("ul",{className:"nice-bpmn-designer__variable-list",children:(t.variables||[]).map($=>e.jsxs("li",{className:"nice-bpmn-designer__variable-item",children:[e.jsx("span",{className:"nice-bpmn-designer__variable-name",children:$.name}),e.jsx("span",{className:"nice-bpmn-designer__variable-type",children:$.type})]},$.id))}),!s&&e.jsxs("button",{type:"button",onClick:Se,children:["+ ",N("workflowDesigner.addVariable","Add variable")]})]})]}):void 0;return e.jsx(_t.NiceAppShell,{flush:!0,className:`nice-bpmn-designer${s?" nice-bpmn-designer--readonly":""} ${y??""}`,style:C,"data-testid":w,toolbar:W,sidebar:be,rightSidebar:Me,bottomPanel:Y?e.jsx("div",{className:"nice-bpmn-designer__simulation-bar",children:e.jsxs("span",{children:[e.jsx(l.NiceIcon,{name:"video",size:14}),N("workflowDesigner.simActiveElement","Simulation active — current element:")," ",e.jsx("strong",{children:t.elements.find($=>$.id===q)?.name||q})]})}):void 0,children:e.jsxs("div",{style:{position:"relative",height:"100%",overflow:"hidden"},children:[e.jsxs("div",{className:`nice-bpmn-designer__canvas${V?" nice-bpmn-designer__canvas--panning":""}`,onDragOver:$=>$.preventDefault(),onDrop:F,onClick:()=>{k(null),T(null),I(null)},onWheel:$=>{if($.ctrlKey||$.metaKey){$.preventDefault();const ve=-$.deltaY*.0015;L(Ce=>Math.max(.25,Math.min(3,Ce+ve)));return}const X=$.shiftKey?$.deltaY:$.deltaX,ae=$.shiftKey?0:$.deltaY;M(ve=>({x:ve.x-X,y:ve.y-ae}))},onPointerDown:$=>{($.button===1||$.button===0&&$.altKey)&&($.preventDefault(),ee(!0),z.current={x:$.clientX,y:$.clientY,offX:D.x,offY:D.y},$.currentTarget.setPointerCapture($.pointerId))},onPointerMove:$=>{if(!V||!z.current)return;const{x:X,y:ae,offX:ve,offY:Ce}=z.current;M({x:ve+($.clientX-X),y:Ce+($.clientY-ae)})},onPointerUp:$=>{V&&(ee(!1),z.current=null,$.currentTarget.releasePointerCapture($.pointerId))},role:"application","aria-label":N("workflowDesigner.bpmnCanvas","BPMN canvas"),style:{backgroundSize:`${u*O}px ${u*O}px`,backgroundPosition:`${D.x}px ${D.y}px`},children:[e.jsxs("div",{className:"nice-bpmn-designer__canvas-content",style:{transform:`translate(${D.x}px, ${D.y}px) scale(${O})`,transformOrigin:"0 0"},children:[xe(),t.elements.map(ie)]}),R&&e.jsx("div",{className:"nice-bpmn-designer__connect-hint",children:N("workflowDesigner.connectHint","Click a target element to connect, or click empty space to cancel")})]}),o&&e.jsx("div",{className:"nice-bpmn-designer__minimap","aria-label":N("workflowDesigner.minimap","Minimap"),"aria-hidden":"true",children:t.elements.map($=>e.jsx("div",{className:`nice-bpmn-designer__minimap-dot nice-bpmn-designer__minimap-dot--${$.elementType}`,style:{left:$.position.x/10,top:$.position.y/10}},$.id))}),d&&ce.length>0&&e.jsxs("div",{className:"nice-bpmn-designer__validation",role:"status","aria-live":"polite",children:[le.map(($,X)=>e.jsxs("div",{className:"nice-bpmn-designer__issue nice-bpmn-designer__issue--error",children:[e.jsx(l.NiceIcon,{name:"error",size:14})," ",$.message]},X)),J.map(($,X)=>e.jsxs("div",{className:"nice-bpmn-designer__issue nice-bpmn-designer__issue--warning",children:[e.jsx(l.NiceIcon,{name:"warning",size:14})," ",$.message]},X))]})]})})},jj=[];function Ys(t){return t?new Date(t)<new Date:!1}function wj(t){if(!t)return!1;const n=new Date(t),i=new Date,a=(n.getTime()-i.getTime())/(1e3*60*60);return a>0&&a<=24}function kj(t,n){const i=new Date(n).getTime()-Date.now(),a=new Intl.RelativeTimeFormat(t,{numeric:"auto",style:"short"}),s=Math.round(i/6e4);if(Math.abs(s)<60)return a.format(s,"minute");const o=Math.round(i/36e5);return Math.abs(o)<24?a.format(o,"hour"):a.format(Math.round(i/864e5),"day")}function Cj(t,n){switch(n){case"low":return t("workflow.taskInbox.priority.low","Low");case"medium":return t("workflow.taskInbox.priority.medium","Medium");case"high":return t("workflow.taskInbox.priority.high","High");case"critical":return t("workflow.taskInbox.priority.critical","Critical")}}const Jc={approval:"check",review:"eye",input:"edit",default:"clipboard"},Pu=({tasks:t=jj,selectedTaskId:n,onTaskSelect:i,onTaskClaim:a,currentUserId:s,showFilters:o=!0,showSearch:c=!0,emptyMessage:d,groupByProcess:p=!1,refreshInterval:m=0,onRefresh:h,className:u,style:x,"data-testid":f})=>{const b=r.useRef(null);l.useRovingFocus(b,{orientation:"horizontal",wrap:!0,activateOnMove:!0});const g=r.useRef(null);l.useRovingFocus(g,{orientation:"vertical",typeahead:!0,pageSize:10});const{t:v,lang:y}=l.useNiceTranslation(),[C,w]=r.useState({}),[E,S]=r.useState(""),[N,_]=r.useState("all");r.useEffect(()=>{if(m>0&&h){const I=setInterval(h,m);return()=>clearInterval(I)}},[m,h]);const k=r.useMemo(()=>{let I=[...t];if(N!=="all"&&(I=I.filter(D=>D.status===N)),E.trim()){const D=E.toLowerCase();I=I.filter(M=>M.name.toLowerCase().includes(D)||M.processName.toLowerCase().includes(D)||M.description?.toLowerCase().includes(D))}return I.sort((D,M)=>{const O=Ys(D.dueDate),L=Ys(M.dueDate);if(O!==L)return O?-1:1;const V={critical:0,high:1,medium:2,low:3};return V[D.priority]!==V[M.priority]?V[D.priority]-V[M.priority]:D.dueDate&&M.dueDate?new Date(D.dueDate).getTime()-new Date(M.dueDate).getTime():0}),I},[t,N,E]),j=r.useMemo(()=>{if(!p)return null;const I={};for(const D of k){const M=D.processName;I[M]||(I[M]=[]),I[M].push(D)}return I},[k,p]),T=r.useCallback(I=>{i?.(I)},[i]),P=r.useMemo(()=>{const I={all:t.length};for(const D of t)I[D.status]=(I[D.status]||0)+1;return I},[t]),B=I=>{const D=Ys(I.dueDate),M=!D&&wj(I.dueDate),O=n===I.id,L=Jc[I.taskDefinitionKey]||Jc.default;return e.jsxs("div",{className:`nice-task-inbox__item${O?" nice-task-inbox__item--selected":""}${D?" nice-task-inbox__item--overdue":""}${M?" nice-task-inbox__item--warning":""}`,onClick:()=>T(I),role:"option","aria-selected":O,onKeyDown:V=>{V.target===V.currentTarget&&(V.key==="Enter"||V.key===" ")&&(V.preventDefault(),T(I))},children:[e.jsx("div",{className:"nice-task-inbox__item-icon",children:e.jsx(l.NiceIcon,{name:L,size:16})}),e.jsxs("div",{className:"nice-task-inbox__item-content",children:[e.jsx("div",{className:"nice-task-inbox__item-name",children:I.name}),e.jsx("div",{className:"nice-task-inbox__item-process",children:I.processName}),e.jsxs("div",{className:"nice-task-inbox__item-meta",children:[I.dueDate&&e.jsxs("span",{className:`nice-task-inbox__item-due${D?" nice-task-inbox__item-due--overdue":""}`,children:[e.jsx(l.NiceIcon,{name:"clock",size:14})," ",D?v("workflow.taskInbox.overdue","Overdue:"):v("workflow.taskInbox.due","Due:")," ",kj(y,I.dueDate)]}),e.jsx("span",{className:`nice-task-inbox__item-priority nice-task-inbox__item-priority--${I.priority}`,children:Cj(v,I.priority)})]})]}),a&&!I.assignee&&I.candidateUsers?.includes(s||"")&&e.jsx("button",{type:"button",className:"nice-task-inbox__claim-btn",onClick:V=>{V.stopPropagation(),a(I)},"aria-label":v("workflow.taskInbox.claimTask","Claim task"),children:v("workflow.taskInbox.claim","Claim")})]},I.id)},R=(I,D)=>e.jsxs("button",{type:"button",role:"tab","aria-selected":N===I,className:`nice-task-inbox__filter${N===I?" nice-task-inbox__filter--active":""}`,onClick:()=>_(I),children:[D," (",P[I]||0,")"]});return e.jsxs("div",{className:`nice-task-inbox ${u??""}`,style:x,"data-testid":f,children:[e.jsxs("div",{className:"nice-task-inbox__header",children:[e.jsxs("h2",{className:"nice-task-inbox__title",children:[v("workflow.taskInbox.title","My tasks"),e.jsx("span",{className:"nice-task-inbox__badge",children:k.length})]}),h&&e.jsx("button",{type:"button",className:"nice-task-inbox__refresh",onClick:h,"aria-label":v("workflow.taskInbox.refresh","Refresh"),title:v("workflow.taskInbox.refresh","Refresh"),children:e.jsx(l.NiceIcon,{name:"refresh",size:16})})]}),o&&e.jsxs("div",{className:"nice-task-inbox__filters",ref:b,role:"tablist",children:[R("all",v("workflow.taskInbox.filter.all","All")),R("pending",v("workflow.taskInbox.filter.pending","Pending")),R("claimed",v("workflow.taskInbox.filter.claimed","Claimed")),R("inProgress",v("workflow.taskInbox.filter.inProgress","In progress"))]}),c&&e.jsx("div",{className:"nice-task-inbox__search",children:e.jsx("input",{type:"search",placeholder:v("workflow.taskInbox.searchPlaceholder","Search tasks..."),value:E,onChange:I=>S(I.target.value),"aria-label":v("workflow.taskInbox.search","Search tasks")})}),e.jsx("div",{ref:g,className:"nice-task-inbox__list",role:"listbox","aria-label":v("workflow.taskInbox.list","Task list"),children:k.length===0?e.jsxs("div",{className:"nice-task-inbox__empty",children:[e.jsx("span",{className:"nice-task-inbox__empty-icon",children:e.jsx(l.NiceIcon,{name:"mail",size:32})}),e.jsx("span",{children:d??v("workflow.taskInbox.empty","No tasks to do")})]}):j?Object.entries(j).map(([I,D])=>e.jsxs("div",{className:"nice-task-inbox__group",children:[e.jsx("div",{className:"nice-task-inbox__group-header",children:I}),D.map(B)]},I)):k.map(B)})]})},Sj=[];function Qc(t){if(!t)return"-";const n=Math.floor(t/1e3),i=Math.floor(n/60),a=Math.floor(i/60),s=Math.floor(a/24);return s>0?`${s}d ${a%24}h`:a>0?`${a}h ${i%60}m`:i>0?`${i}m ${n%60}s`:`${n}s`}function Tj(t,n){return new Date(n).toLocaleString(t,{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit"})}function Ej(t,n){switch(n){case"running":return t("workflow.instanceMonitor.status.running","Running");case"completed":return t("workflow.instanceMonitor.status.completed","Completed");case"failed":return t("workflow.instanceMonitor.status.failed","Failed");case"suspended":return t("workflow.instanceMonitor.status.suspended","Suspended");case"terminated":return t("workflow.instanceMonitor.status.terminated","Terminated");case"incident":return t("workflow.instanceMonitor.status.incident","Incident")}}const Ij={running:"play",completed:"check",failed:"close",suspended:"pause",terminated:"stop",incident:"warning"},Au=({instances:t=Sj,selectedInstanceId:n,onInstanceSelect:i,onSuspend:a,onResume:s,onTerminate:o,onRetry:c,onViewDetails:d,onViewDiagram:p,showStats:m=!0,showFilters:h=!0,refreshInterval:u=0,onRefresh:x,processDefinitions:f=[],className:b,style:g,"data-testid":v})=>{const{t:y,lang:C}=l.useNiceTranslation(),[w,E]=r.useState({}),[S,N]=r.useState(""),[_,k]=r.useState("all"),[j,T]=r.useState("all");r.useEffect(()=>{if(u>0&&x){const D=setInterval(x,u);return()=>clearInterval(D)}},[u,x]);const P=r.useMemo(()=>{const D={total:t.length,running:0,completed:0,failed:0,suspended:0,incidents:0};for(const M of t)M.status==="running"?D.running++:M.status==="completed"?D.completed++:M.status==="failed"||M.status==="incident"?D.failed++:M.status==="suspended"&&D.suspended++,M.incidentCount&&M.incidentCount>0&&(D.incidents+=M.incidentCount);return D},[t]),B=r.useMemo(()=>{let D=[...t];if(_!=="all"&&(D=D.filter(M=>M.status===_)),j!=="all"&&(D=D.filter(M=>M.processDefinitionKey===j)),S.trim()){const M=S.toLowerCase();D=D.filter(O=>O.id.toLowerCase().includes(M)||O.businessKey?.toLowerCase().includes(M)||O.processDefinitionName.toLowerCase().includes(M))}return D.sort((M,O)=>new Date(O.startTime).getTime()-new Date(M.startTime).getTime()),D},[t,_,j,S]),R=r.useCallback(D=>{i?.(D)},[i]),I={running:y("workflow.instanceMonitor.stats.running","Running"),completed:y("workflow.instanceMonitor.stats.completed","Completed"),errors:y("workflow.instanceMonitor.stats.errors","Errors"),incidents:y("workflow.instanceMonitor.stats.incidents","Incidents")};return e.jsxs("div",{className:`nice-instance-monitor ${b??""}`,style:g,"data-testid":v,children:[e.jsxs("div",{className:"nice-instance-monitor__header",children:[e.jsx("h2",{className:"nice-instance-monitor__title",children:y("workflow.instanceMonitor.title","Instance monitor")}),x&&e.jsx("button",{type:"button",onClick:x,"aria-label":y("workflow.instanceMonitor.refresh","Refresh"),children:e.jsx(l.NiceIcon,{name:"refresh",size:16})})]}),m&&e.jsxs("div",{className:"nice-instance-monitor__stats",children:[e.jsxs("div",{className:"nice-instance-monitor__stat",children:[e.jsx("div",{className:"nice-instance-monitor__stat-value",children:P.total}),e.jsx("div",{className:"nice-instance-monitor__stat-label",children:y("workflow.instanceMonitor.stats.total","Total")})]}),e.jsxs("div",{className:"nice-instance-monitor__stat nice-instance-monitor__stat--running",children:[e.jsx("div",{className:"nice-instance-monitor__stat-value",children:P.running}),e.jsx("div",{className:"nice-instance-monitor__stat-label",children:I.running})]}),e.jsxs("div",{className:"nice-instance-monitor__stat nice-instance-monitor__stat--completed",children:[e.jsx("div",{className:"nice-instance-monitor__stat-value",children:P.completed}),e.jsx("div",{className:"nice-instance-monitor__stat-label",children:I.completed})]}),e.jsxs("div",{className:"nice-instance-monitor__stat nice-instance-monitor__stat--failed",children:[e.jsx("div",{className:"nice-instance-monitor__stat-value",children:P.failed}),e.jsx("div",{className:"nice-instance-monitor__stat-label",children:I.errors})]}),P.incidents>0&&e.jsxs("div",{className:"nice-instance-monitor__stat nice-instance-monitor__stat--failed",children:[e.jsx("div",{className:"nice-instance-monitor__stat-value",children:P.incidents}),e.jsx("div",{className:"nice-instance-monitor__stat-label",children:I.incidents})]})]}),h&&e.jsxs("div",{className:"nice-instance-monitor__filters",children:[e.jsxs("select",{value:_,onChange:D=>k(D.target.value),"aria-label":y("workflow.instanceMonitor.filterStatus","Filter by status"),children:[e.jsx("option",{value:"all",children:y("workflow.instanceMonitor.allStatuses","All statuses")}),e.jsx("option",{value:"running",children:I.running}),e.jsx("option",{value:"completed",children:I.completed}),e.jsx("option",{value:"failed",children:I.errors}),e.jsx("option",{value:"suspended",children:y("workflow.instanceMonitor.status.suspended","Suspended")}),e.jsx("option",{value:"incident",children:I.incidents})]}),f.length>0&&e.jsxs("select",{value:j,onChange:D=>T(D.target.value),"aria-label":y("workflow.instanceMonitor.filterProcess","Filter by process"),children:[e.jsx("option",{value:"all",children:y("workflow.instanceMonitor.allProcesses","All processes")}),f.map(D=>e.jsx("option",{value:D.key,children:D.name},D.key))]}),e.jsx("input",{type:"search",placeholder:y("workflow.instanceMonitor.searchPlaceholder","Search..."),value:S,onChange:D=>N(D.target.value),"aria-label":y("workflow.instanceMonitor.search","Search instances")})]}),e.jsxs("div",{className:"nice-instance-monitor__list",children:[e.jsxs("div",{className:"nice-instance-monitor__row nice-instance-monitor__row-header",children:[e.jsx("span",{children:y("workflow.instanceMonitor.col.process","Process / ID")}),e.jsx("span",{children:y("workflow.instanceMonitor.col.status","Status")}),e.jsx("span",{children:y("workflow.instanceMonitor.col.started","Started")}),e.jsx("span",{children:y("workflow.instanceMonitor.col.duration","Duration")}),e.jsx("span",{children:y("workflow.instanceMonitor.col.actions","Actions")})]}),B.length===0?e.jsx("div",{className:"nice-instance-monitor__empty",children:e.jsx("span",{children:y("workflow.instanceMonitor.empty","No instances match the filters")})}):B.map(D=>{const M=n===D.id;return e.jsxs("div",{className:`nice-instance-monitor__row${M?" nice-instance-monitor__row--selected":""}`,onClick:()=>R(D),role:"button",tabIndex:0,"aria-selected":M,onKeyDown:O=>O.key==="Enter"&&R(D),children:[e.jsxs("span",{className:"nice-instance-monitor__process",children:[e.jsx("strong",{children:D.processDefinitionName}),e.jsx("small",{children:D.businessKey||D.id.substring(0,8)})]}),e.jsxs("span",{className:`nice-instance-monitor__status nice-instance-monitor__status--${D.status}`,children:[e.jsx(l.NiceIcon,{name:Ij[D.status],size:14})," ",Ej(y,D.status),D.incidentCount&&D.incidentCount>0&&e.jsx("span",{className:"nice-instance-monitor__incident-badge",children:D.incidentCount})]}),e.jsx("span",{children:Tj(C,D.startTime)}),e.jsx("span",{children:D.status==="completed"||D.status==="terminated"?Qc(D.durationMs):Qc(Date.now()-new Date(D.startTime).getTime())}),e.jsxs("div",{role:"presentation",className:"nice-instance-monitor__actions",onClick:O=>O.stopPropagation(),children:[d&&e.jsx("button",{type:"button",className:"nice-instance-monitor__action",onClick:()=>d(D),title:y("workflow.instanceMonitor.details","Details"),"aria-label":y("workflow.instanceMonitor.viewDetails","View details"),children:e.jsx(l.NiceIcon,{name:"clipboard",size:16})}),p&&e.jsx("button",{type:"button",className:"nice-instance-monitor__action",onClick:()=>p(D),title:y("workflow.instanceMonitor.diagram","Diagram"),"aria-label":y("workflow.instanceMonitor.viewDiagram","View diagram"),children:e.jsx(l.NiceIcon,{name:"map-pin",size:16})}),D.status==="running"&&a&&e.jsx("button",{type:"button",className:"nice-instance-monitor__action",onClick:()=>a(D),title:y("workflow.instanceMonitor.suspend","Suspend"),"aria-label":y("workflow.instanceMonitor.suspendInstance","Suspend instance"),children:e.jsx(l.NiceIcon,{name:"pause",size:16})}),D.status==="suspended"&&s&&e.jsx("button",{type:"button",className:"nice-instance-monitor__action",onClick:()=>s(D),title:y("workflow.instanceMonitor.resume","Resume"),"aria-label":y("workflow.instanceMonitor.resumeInstance","Resume instance"),children:e.jsx(l.NiceIcon,{name:"play",size:16})}),(D.status==="failed"||D.status==="incident")&&c&&e.jsx("button",{type:"button",className:"nice-instance-monitor__action",onClick:()=>c(D),title:y("workflow.instanceMonitor.retry","Retry"),"aria-label":y("workflow.instanceMonitor.retryInstance","Retry instance"),children:e.jsx(l.NiceIcon,{name:"refresh",size:16})}),D.status==="running"&&o&&e.jsx("button",{type:"button",className:"nice-instance-monitor__action nice-instance-monitor__action--danger",onClick:()=>o(D),title:y("workflow.instanceMonitor.terminate","Terminate"),"aria-label":y("workflow.instanceMonitor.terminateInstance","Terminate instance"),children:e.jsx(l.NiceIcon,{name:"stop",size:16})})]})]},D.id)})]})]})},Dj=[],Pj=[],Aj=t=>Array.from({length:7},(n,i)=>new Date(Date.UTC(2024,0,7+i)).toLocaleDateString(t,{weekday:"short"})),Rj=({preferences:t,onChange:n,onSave:i,channels:a=Dj,categories:s=Pj,showQuietHours:o=!0,showDigest:c=!0,showTestButton:d=!0,className:p,style:m,"data-testid":h})=>{const u=r.useRef(null);l.useRovingFocus(u,{orientation:"horizontal",wrap:!0,activateOnMove:!0});const{t:x,lang:f}=l.useNiceTranslation(),b=r.useMemo(()=>Aj(f),[f]),[g,v]=r.useState("channels"),[y,C]=r.useState(!1),w=k=>n({...t,...k}),E=k=>w({channels:{...t.channels,[k]:!t.channels[k]}}),S=(k,j)=>{const T=t.categoryPrefs.find(R=>R.categoryId===k),P=T?.channels??{},B={categoryId:k,channels:{...P,[j]:!P[j]},priority:T?.priority??"all"};w({categoryPrefs:t.categoryPrefs.some(R=>R.categoryId===k)?t.categoryPrefs.map(R=>R.categoryId===k?B:R):[...t.categoryPrefs,B]})},N=async()=>{C(!0);try{await i(t)}finally{C(!1)}},_=[{id:"channels",label:x("notifications.channels","Channels"),show:!0},{id:"categories",label:x("notifications.categories","Categories"),show:!0},{id:"quietHours",label:x("notifications.quietHours2","Quiet Hours"),show:o},{id:"digest",label:x("notifications.digest","Digest"),show:c}];return e.jsxs("div",{className:`nice-notification-prefs ${p??""}`,style:m,"data-testid":h,children:[e.jsx("div",{className:"nice-notification-prefs__global",children:e.jsxs("label",{className:"nice-notification-prefs__global-label",children:[e.jsx("input",{type:"checkbox",checked:t.globalEnabled,onChange:k=>w({globalEnabled:k.target.checked}),"aria-label":x("notifications.enableAll","Enable all notifications")}),x("notifications.global","Global notifications")]})}),e.jsx("div",{className:"nice-notification-prefs__tabs",ref:u,role:"tablist",children:_.filter(k=>k.show).map(k=>e.jsx("button",{role:"tab","aria-selected":g===k.id,className:`nice-notification-prefs__tab${g===k.id?" nice-notification-prefs__tab--active":""}`,onClick:()=>v(k.id),type:"button",children:k.label},k.id))}),g==="channels"&&e.jsx("div",{className:"nice-notification-prefs__channels",role:"tabpanel",children:a.map(k=>e.jsxs("div",{className:"nice-notification-prefs__channel-row",children:[e.jsx("span",{className:"nice-notification-prefs__channel-icon","aria-hidden":"true",children:e.jsx(l.NiceIcon,{name:k.icon,size:16})}),e.jsx("span",{className:"nice-notification-prefs__channel-name",children:k.name}),k.configRequired&&!k.enabled&&e.jsx("a",{href:k.configUrl??"#",className:"nice-notification-prefs__config-link",children:x("notifications.configure","Configure")}),e.jsx("label",{className:"nice-notification-prefs__toggle-label",children:e.jsx("input",{type:"checkbox",checked:t.channels[k.id]??!1,onChange:()=>E(k.id),disabled:!t.globalEnabled,"aria-label":`${x("notifications.channel","Channel")} ${k.name}`})}),d&&t.channels[k.id]&&e.jsx("button",{type:"button",className:"nice-notification-prefs__test-btn",onClick:()=>{},children:x("notifications.test","Test")})]},k.id))}),g==="categories"&&e.jsx("div",{className:"nice-notification-prefs__categories",role:"tabpanel",children:e.jsxs("table",{className:"nice-notification-prefs__matrix",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:x("notifications.category","Category")}),a.map(k=>e.jsx("th",{children:k.name},k.id)),e.jsx("th",{children:x("notifications.priority","Priority")})]})}),e.jsx("tbody",{children:s.map(k=>{const j=t.categoryPrefs.find(T=>T.categoryId===k.id);return e.jsxs("tr",{children:[e.jsxs("td",{children:[e.jsx(l.NiceIcon,{name:k.icon,size:14})," ",k.name]}),a.map(T=>e.jsx("td",{children:e.jsx("input",{type:"checkbox",checked:j?.channels[T.id]??k.defaultChannels.includes(T.id),onChange:()=>S(k.id,T.id),disabled:!t.globalEnabled,"aria-label":`${k.name} — ${T.name}`})},T.id)),e.jsx("td",{children:e.jsxs("select",{value:j?.priority??"all",onChange:T=>{const P=t.categoryPrefs.find(R=>R.categoryId===k.id),B={categoryId:k.id,channels:P?.channels??{},priority:T.target.value};w({categoryPrefs:t.categoryPrefs.some(R=>R.categoryId===k.id)?t.categoryPrefs.map(R=>R.categoryId===k.id?B:R):[...t.categoryPrefs,B]})},"aria-label":`${x("notifications.categoryPriority","Category priority")} ${k.name}`,children:[e.jsx("option",{value:"all",children:x("notifications.priorityAll","All")}),e.jsx("option",{value:"high",children:x("notifications.priorityHigh","High and above")}),e.jsx("option",{value:"critical",children:x("notifications.priorityCritical","Critical")})]})})]},k.id)})})]})}),g==="quietHours"&&o&&e.jsxs("div",{className:"nice-notification-prefs__quiet-hours",role:"tabpanel",children:[e.jsxs("label",{children:[e.jsx("input",{type:"checkbox",checked:t.quietHours?.enabled??!1,onChange:k=>w({quietHours:{...t.quietHours??{startTime:"22:00",endTime:"07:00",timezone:"Europe/Warsaw",daysOfWeek:[0,1,2,3,4,5,6]},enabled:k.target.checked}}),"aria-label":x("notifications.enableQuietHours","Enable quiet hours")}),x("notifications.quietHours","Quiet hours")]}),t.quietHours?.enabled&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"nice-notification-prefs__time-row",children:[e.jsxs("label",{children:[x("notifications.from","From:"),e.jsx("input",{type:"time",value:t.quietHours.startTime,onChange:k=>w({quietHours:{...t.quietHours,startTime:k.target.value}}),"aria-label":x("notifications.quietStart","Quiet hours start")})]}),e.jsxs("label",{children:[x("notifications.to","To:"),e.jsx("input",{type:"time",value:t.quietHours.endTime,onChange:k=>w({quietHours:{...t.quietHours,endTime:k.target.value}}),"aria-label":x("notifications.quietEnd","Quiet hours end")})]})]}),e.jsx("div",{className:"nice-notification-prefs__days-row",role:"group","aria-label":x("notifications.daysOfTheWeek","Days of the week"),children:b.map((k,j)=>e.jsxs("label",{className:"nice-notification-prefs__day-check",children:[e.jsx("input",{type:"checkbox",checked:t.quietHours.daysOfWeek.includes(j),onChange:()=>{const T=t.quietHours.daysOfWeek;w({quietHours:{...t.quietHours,daysOfWeek:T.includes(j)?T.filter(P=>P!==j):[...T,j]}})},"aria-label":k}),k]},j))})]})]}),g==="digest"&&c&&e.jsxs("div",{className:"nice-notification-prefs__digest",role:"tabpanel",children:[e.jsxs("label",{children:[e.jsx("input",{type:"checkbox",checked:t.digest?.enabled??!1,onChange:k=>w({digest:{...t.digest??{frequency:"daily"},enabled:k.target.checked}}),"aria-label":x("notifications.enableDigest","Enable the digest")}),x("notifications.digest","Digest")]}),t.digest?.enabled&&e.jsxs(e.Fragment,{children:[e.jsxs("label",{children:[x("notifications.frequency","Frequency"),":",e.jsxs("select",{value:t.digest.frequency,onChange:k=>w({digest:{...t.digest,frequency:k.target.value}}),"aria-label":x("notifications.digestFrequency","Digest frequency"),children:[e.jsx("option",{value:"realtime",children:x("notifications.realtime","Real time")}),e.jsx("option",{value:"hourly",children:x("notifications.hourly","Hourly")}),e.jsx("option",{value:"daily",children:x("notifications.daily","Daily")}),e.jsx("option",{value:"weekly",children:x("notifications.weekly","Weekly")})]})]}),["daily","weekly"].includes(t.digest.frequency)&&e.jsxs("label",{children:[x("notifications.deliveryTime","Delivery time"),":",e.jsx("input",{type:"time",value:t.digest.deliveryTime??"09:00",onChange:k=>w({digest:{...t.digest,deliveryTime:k.target.value}}),"aria-label":x("notifications.digestDeliveryTime","Digest delivery time")})]})]})]}),e.jsx("div",{className:"nice-notification-prefs__footer",children:e.jsx("button",{type:"button",className:"nice-notification-prefs__save-btn",onClick:N,disabled:y,children:y?x("notifications.saving","Saving…"):x("notifications.savePreferences","Save preferences")})})]})},$j=[],Ha={online:"var(--nice-color-success, #22c55e)",offline:"var(--nice-color-error, #ef4444)",warning:"var(--nice-color-warning, #f59e0b)"},Ga={router:"shuffle",switch:"plug","access-point":"wifi",server:"server",workstation:"monitor",printer:"printer",camera:"camera",iot:"home",unknown:"help"},Mj=({nodes:t=$j,topology:n,onScan:i,onNodeClick:a,onNodeAction:s,showTopologyView:o=!0,showMapView:c=!0,showListView:d=!0,autoRefreshMs:p=3e4,className:m,style:h,"data-testid":u})=>{const x=r.useRef(null);l.useRovingFocus(x,{orientation:"horizontal",wrap:!0,activateOnMove:!0});const{t:f}=l.useNiceTranslation(),[b,g]=r.useState("list"),[v,y]=r.useState(!1),[C,w]=r.useState(""),[E,S]=r.useState(""),[N,_]=r.useState(""),[k,j]=r.useState(null),[T,P]=r.useState("");r.useEffect(()=>{if(!p)return;const D=setInterval(()=>i(),p);return()=>clearInterval(D)},[p,i]);const B=t.filter(D=>{if(E&&D.category!==E||N&&D.status!==N||k!==null&&D.isRogue!==k)return!1;if(T){const M=T.toLowerCase();return D.ipAddress.includes(M)||(D.hostname?.toLowerCase().includes(M)??!1)||(D.vendor?.toLowerCase().includes(M)??!1)}return!0}),R=async()=>{y(!0);try{await i(C||void 0)}finally{y(!1)}},I=[{id:"list",label:f("networkDiscovery.list","List"),show:d},{id:"cards",label:f("networkDiscovery.cards","Cards"),show:!0},{id:"topology",label:f("networkDiscovery.topology","Topology"),show:o},{id:"map",label:f("networkDiscovery.map","Map"),show:c}];return e.jsxs("div",{className:`nice-network-discovery ${m??""}`,style:h,"data-testid":u,children:[e.jsxs("div",{className:"nice-network-discovery__toolbar",children:[e.jsx("input",{type:"text",placeholder:f("networkDiscovery.subnetPlaceholder","Subnet (e.g. 192.168.1.0/24)"),value:C,onChange:D=>w(D.target.value),className:"nice-network-discovery__subnet-input","aria-label":f("networkDiscovery.subnet","Subnet to scan")}),e.jsx("button",{onClick:R,disabled:v,type:"button",className:"nice-network-discovery__scan-btn",children:v?f("networkDiscovery.scanning","Scanning…"):e.jsxs(e.Fragment,{children:[e.jsx(l.NiceIcon,{name:"search",size:14})," ",f("networkDiscovery.scan","Scan network")]})}),e.jsx("input",{type:"search",placeholder:f("networkDiscovery.searchPlaceholder","Search (IP, hostname, vendor)…"),value:T,onChange:D=>P(D.target.value),"aria-label":f("networkDiscovery.searchDevice","Search devices")}),e.jsxs("select",{value:E,onChange:D=>S(D.target.value),"aria-label":f("networkDiscovery.filterCategory","Filter by category"),children:[e.jsx("option",{value:"",children:f("networkDiscovery.allCategories","All categories")}),["router","switch","access-point","server","workstation","printer","camera","iot","unknown"].map(D=>e.jsx("option",{value:D,children:D},D))]}),e.jsxs("select",{value:N,onChange:D=>_(D.target.value),"aria-label":f("networkDiscovery.filterStatus","Filter by status"),children:[e.jsx("option",{value:"",children:f("networkDiscovery.allStatuses","All statuses")}),e.jsx("option",{value:"online",children:f("networkDiscovery.online","Online")}),e.jsx("option",{value:"offline",children:f("networkDiscovery.offline","Offline")}),e.jsx("option",{value:"warning",children:f("networkDiscovery.warning","Warning")})]}),e.jsxs("label",{children:[e.jsx("input",{type:"checkbox",checked:k===!0,onChange:D=>j(D.target.checked?!0:null),"aria-label":f("networkDiscovery.rogueOnly","Rogue only")}),f("networkDiscovery.rogueOnly","Rogue only")]}),e.jsxs("span",{className:"nice-network-discovery__count",children:[B.length," / ",t.length," ",f("networkDiscovery.devices","devices")]})]}),e.jsx("div",{className:"nice-network-discovery__tabs",ref:x,role:"tablist",children:I.filter(D=>D.show).map(D=>e.jsx("button",{role:"tab","aria-selected":b===D.id,className:`nice-network-discovery__tab${b===D.id?" nice-network-discovery__tab--active":""}`,onClick:()=>g(D.id),type:"button",children:D.label},D.id))}),b==="list"&&e.jsx("div",{className:"nice-network-discovery__list",role:"tabpanel",children:e.jsxs("table",{className:"nice-network-discovery__table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:f("networkDiscovery.status","Status")}),e.jsx("th",{children:f("networkDiscovery.category","Category")}),e.jsx("th",{children:f("networkDiscovery.hostname","Hostname")}),e.jsx("th",{children:"IP"}),e.jsx("th",{children:"MAC"}),e.jsx("th",{children:f("networkDiscovery.vendor","Vendor")}),e.jsx("th",{children:f("networkDiscovery.os","OS")}),e.jsx("th",{children:f("networkDiscovery.approved","Approved")}),e.jsx("th",{children:f("networkDiscovery.actions","Actions")})]})}),e.jsx("tbody",{children:B.map(D=>e.jsxs("tr",{className:`nice-network-discovery__row${D.isRogue?" nice-network-discovery__row--rogue":""}`,onClick:()=>a(D.id),style:{cursor:"pointer"},children:[e.jsx("td",{children:e.jsx("span",{className:"nice-network-discovery__status-dot",style:{background:Ha[D.status]},"aria-label":D.status})}),e.jsxs("td",{children:[e.jsx(l.NiceIcon,{name:Ga[D.category],size:16})," ",D.category]}),e.jsx("td",{children:D.hostname??"—"}),e.jsx("td",{children:D.ipAddress}),e.jsx("td",{children:D.macAddress??"—"}),e.jsx("td",{children:D.vendor??"—"}),e.jsx("td",{children:D.os??"—"}),e.jsx("td",{children:D.isApproved?e.jsx(l.NiceIcon,{name:"check",size:16}):D.isRogue?e.jsx(l.NiceIcon,{name:"slash",size:16}):"—"}),e.jsxs("td",{onClick:M=>M.stopPropagation(),children:[!D.isApproved&&!D.isRogue&&e.jsx("button",{onClick:()=>s(D.id,"approve"),type:"button",title:f("networkDiscovery.approve","Approve"),"aria-label":f("networkDiscovery.approve","Approve"),children:e.jsx(l.NiceIcon,{name:"check",size:16})}),!D.isRogue&&e.jsx("button",{onClick:()=>s(D.id,"block"),type:"button",title:f("networkDiscovery.block","Block"),"aria-label":f("networkDiscovery.block","Block"),children:e.jsx(l.NiceIcon,{name:"slash",size:16})}),e.jsx("button",{onClick:()=>s(D.id,"tag"),type:"button",title:f("networkDiscovery.tag","Tag"),"aria-label":f("networkDiscovery.tag","Tag"),children:e.jsx(l.NiceIcon,{name:"tag",size:16})}),e.jsx("button",{onClick:()=>s(D.id,"provision"),type:"button",title:f("networkDiscovery.provision","Provision"),"aria-label":f("networkDiscovery.provision","Provision"),children:e.jsx(l.NiceIcon,{name:"settings",size:16})})]})]},D.id))})]})}),b==="cards"&&e.jsx("div",{className:"nice-network-discovery__cards",role:"tabpanel",children:B.map(D=>e.jsxs("div",{className:`nice-network-discovery__card nice-network-discovery__card--${D.status}${D.isRogue?" nice-network-discovery__card--rogue":""}`,onClick:()=>a(D.id),role:"button",tabIndex:0,onKeyDown:M=>M.key==="Enter"&&a(D.id),"aria-label":`${f("networkDiscovery.device","Device")} ${D.hostname??D.ipAddress}`,children:[e.jsx("span",{className:"nice-network-discovery__card-icon","aria-hidden":"true",children:e.jsx(l.NiceIcon,{name:Ga[D.category],size:24})}),e.jsx("div",{className:"nice-network-discovery__card-status",style:{background:Ha[D.status]},"aria-label":D.status}),e.jsx("div",{className:"nice-network-discovery__card-hostname",children:D.hostname??D.ipAddress}),e.jsx("div",{className:"nice-network-discovery__card-ip",children:D.ipAddress}),D.vendor&&e.jsx("div",{className:"nice-network-discovery__card-vendor",children:D.vendor}),D.isRogue&&e.jsx("span",{className:"nice-network-discovery__rogue-badge",children:f("networkDiscovery.rogue","Rogue!")}),D.tags?.map(M=>e.jsx("span",{className:"nice-network-discovery__tag",children:M},M))]},D.id))}),b==="topology"&&e.jsx("div",{className:"nice-network-discovery__topology",role:"tabpanel","aria-label":f("networkDiscovery.networkTopology","Network topology"),children:e.jsxs("svg",{width:"100%",height:"400","aria-label":f("networkDiscovery.networkTopologyDiagram","Network topology diagram"),children:[n?.links.map((D,M)=>{const O=t.find(q=>q.id===D.sourceId),L=t.find(q=>q.id===D.targetId);if(!O||!L)return null;const V=t.indexOf(O),ee=t.indexOf(L),z=6,U=V%z*140+70,re=Math.floor(V/z)*120+60,Y=ee%z*140+70,oe=Math.floor(ee/z)*120+60;return e.jsx("line",{x1:U,y1:re,x2:Y,y2:oe,stroke:"var(--nice-text-muted, #94a3b8)",strokeWidth:1.5},M)}),B.map((D,M)=>{const L=M%6*140+70,V=Math.floor(M/6)*120+60;return e.jsxs("g",{onClick:()=>a(D.id),role:"button","aria-label":D.hostname??D.ipAddress,style:{cursor:"pointer"},children:[e.jsx("circle",{cx:L,cy:V,r:22,fill:Ha[D.status],opacity:.2}),e.jsx("circle",{cx:L,cy:V,r:18,fill:"white",stroke:Ha[D.status],strokeWidth:2}),e.jsx("foreignObject",{x:L-10,y:V-10,width:20,height:20,"aria-hidden":"true",style:{pointerEvents:"none"},children:e.jsx(l.NiceIcon,{name:Ga[D.category],size:20})}),e.jsx("text",{x:L,y:V+36,textAnchor:"middle",fontSize:10,fill:"var(--nice-text-secondary, #475569)",children:(D.hostname??D.ipAddress).substring(0,14)})]},D.id)})]})}),b==="map"&&e.jsxs("div",{className:"nice-network-discovery__map",role:"tabpanel",children:[e.jsxs("p",{className:"nice-network-discovery__map-hint",children:[f("networkDiscovery.mapHint","The map view needs the")," ",e.jsx("code",{children:"NiceMap"})," ",f("networkDiscovery.mapHintEnd","component.")]}),e.jsx("div",{className:"nice-network-discovery__map-pins",children:B.filter(D=>D.location).map(D=>e.jsx("button",{className:`nice-network-discovery__map-pin nice-network-discovery__map-pin--${D.status}`,onClick:()=>a(D.id),type:"button","aria-label":`${D.hostname??D.ipAddress} — ${D.location?.room??""}`,title:`${D.hostname??D.ipAddress} (${D.location?.room??""})`,children:e.jsx(l.NiceIcon,{name:Ga[D.category],size:16})},D.id))})]})]})},Xc={get:"var(--nice-color-success, #22c55e)",post:"var(--nice-color-primary, #3b82f6)",put:"var(--nice-color-warning, #f59e0b)",patch:"var(--nice-accent, #a855f7)",delete:"var(--nice-color-error, #ef4444)",head:"var(--nice-text-muted, #6b7280)",options:"var(--nice-text-muted, #6b7280)"};function Oj(t){if(!t?.paths)return[];const n=[];for(const[i,a]of Object.entries(t.paths))for(const[s,o]of Object.entries(a))n.push({...o,method:s,path:i});return n}const Lj=({specUrl:t,spec:n,baseUrl:i,authToken:a,onRequest:s,onResponse:o,showTryIt:c=!0,showSchemas:d=!0,showSearch:p=!0,groupBy:m="tag",theme:h="light",layout:u="sidebar",className:x,style:f,"data-testid":b})=>{const{t:g}=l.useNiceTranslation(),[v]=r.useState(n??null),[y,C]=r.useState(""),[w,E]=r.useState(null),[S,N]=r.useState({}),[_,k]=r.useState(""),[j,T]=r.useState(null),[P,B]=r.useState(!1),[R,I]=r.useState("detail"),D=i??v?.servers?.[0]?.url??"",O=Oj(v).filter(z=>{if(!y)return!0;const U=y.toLowerCase();return z.path.toLowerCase().includes(U)||(z.summary?.toLowerCase().includes(U)??!1)||z.method.toLowerCase().includes(U)}),L={};for(const z of O){let U=z.path;m==="tag"?U=z.tags?.[0]??"default":m==="method"&&(U=z.method.toUpperCase()),L[U]||(L[U]=[]),L[U].push(z)}const V=async()=>{if(!w)return;let z=w.path;for(const[q,se]of Object.entries(S))z=z.replace(`{${q}}`,encodeURIComponent(se));const U=`${D}${z}`,re={"Content-Type":"application/json"};a&&(re.Authorization=`Bearer ${a}`);const Y={method:w.method,path:w.path,params:S,body:_?JSON.parse(_):void 0};s?.(Y),B(!0);const oe=Date.now();try{const q=await fetch(U,{method:w.method.toUpperCase(),headers:re,body:["post","put","patch"].includes(w.method)&&_?_:void 0}),se=await q.text(),ce=Date.now()-oe;T({status:q.status,body:se,duration:ce}),o?.({status:q.status,body:JSON.parse(se),durationMs:ce})}catch(q){T({status:0,body:String(q),duration:Date.now()-oe})}finally{B(!1)}},ee=z=>{if(!z)return"";const U=a?` -H "Authorization: Bearer ${a}"`:"";return`curl -X ${z.method.toUpperCase()}${U} "${D}${z.path}"`};return e.jsxs("div",{className:`nice-api-explorer nice-api-explorer--${u} nice-api-explorer--${h} ${x??""}`,style:f,"data-testid":b,children:[e.jsxs("aside",{className:"nice-api-explorer__sidebar","aria-label":g("devTools.endpointList","Endpoint list"),children:[v?.info&&e.jsxs("div",{className:"nice-api-explorer__api-info",children:[e.jsx("h2",{className:"nice-api-explorer__api-title",children:v.info.title}),e.jsxs("span",{className:"nice-api-explorer__api-version",children:["v",v.info.version]})]}),!v&&t&&e.jsxs("p",{className:"nice-api-explorer__loading",children:[g("devTools.loadingSpecFrom","Loading the specification from")," ",e.jsx("code",{children:t}),"…"]}),p&&e.jsx("input",{type:"search",placeholder:g("devTools.searchEndpointPlaceholder","Search endpoints…"),value:y,onChange:z=>C(z.target.value),className:"nice-api-explorer__search","aria-label":g("devTools.searchEndpoint","Search endpoints")}),Object.entries(L).map(([z,U])=>e.jsxs("div",{className:"nice-api-explorer__group",children:[e.jsx("h3",{className:"nice-api-explorer__group-title",children:z}),U.map(re=>e.jsxs("button",{className:`nice-api-explorer__endpoint-btn${w?.path===re.path&&w?.method===re.method?" nice-api-explorer__endpoint-btn--active":""}`,onClick:()=>{E(re),N({}),T(null)},type:"button",children:[e.jsx("span",{className:"nice-api-explorer__method-badge",style:{background:Xc[re.method]??"var(--nice-bg-tertiary, #6b7280)"},children:re.method.toUpperCase()}),e.jsx("span",{className:"nice-api-explorer__path",children:re.path})]},`${re.method}:${re.path}`))]},z)),d&&v?.components?.schemas&&e.jsxs("div",{className:"nice-api-explorer__group",children:[e.jsx("h3",{className:"nice-api-explorer__group-title",children:g("devTools.schemas","Schemas")}),Object.keys(v.components.schemas).map(z=>e.jsx("button",{className:"nice-api-explorer__schema-btn",onClick:()=>{E(null),I("schemas")},type:"button",children:z},z))]})]}),e.jsx("main",{className:"nice-api-explorer__detail","aria-label":g("devTools.endpointDetails","Endpoint details"),children:w?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"nice-api-explorer__endpoint-header",children:[e.jsx("span",{className:"nice-api-explorer__method-badge nice-api-explorer__method-badge--lg",style:{background:Xc[w.method]},children:w.method.toUpperCase()}),e.jsx("code",{className:"nice-api-explorer__path-display",children:w.path})]}),w.summary&&e.jsx("p",{className:"nice-api-explorer__summary",children:w.summary}),w.description&&e.jsx("p",{className:"nice-api-explorer__desc",children:w.description}),(w.parameters??[]).length>0&&e.jsxs("section",{className:"nice-api-explorer__params","aria-labelledby":"nice-api-params-title",children:[e.jsx("h4",{id:"nice-api-params-title",children:g("devTools.parameters","Parameters")}),e.jsxs("table",{className:"nice-api-explorer__params-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:g("devTools.columnName","Name")}),e.jsx("th",{children:g("devTools.columnIn","In")}),e.jsx("th",{children:g("devTools.columnRequired","Required")}),e.jsx("th",{children:g("devTools.columnType","Type")}),e.jsx("th",{children:g("devTools.columnValue","Value")})]})}),e.jsx("tbody",{children:(w.parameters??[]).map(z=>e.jsxs("tr",{children:[e.jsx("td",{children:e.jsx("code",{children:z.name})}),e.jsx("td",{children:z.in}),e.jsx("td",{children:z.required?e.jsx(l.NiceIcon,{name:"check",size:14}):"—"}),e.jsx("td",{children:z.schema?.type??"—"}),e.jsx("td",{children:c&&(z.schema?.enum?e.jsxs("select",{value:S[z.name]??"",onChange:U=>N(re=>({...re,[z.name]:U.target.value})),"aria-label":`${g("devTools.parameterValue","Parameter value")}: ${z.name}`,children:[e.jsx("option",{value:"",children:"—"}),z.schema.enum.map(U=>e.jsx("option",{value:U,children:U},U))]}):e.jsx("input",{type:"text",value:S[z.name]??"",onChange:U=>N(re=>({...re,[z.name]:U.target.value})),placeholder:String(z.schema?.example??""),"aria-label":`${g("devTools.parameterValue","Parameter value")}: ${z.name}`}))})]},z.name))})]})]}),w.requestBody&&c&&e.jsxs("section",{className:"nice-api-explorer__body-section","aria-labelledby":"nice-api-body-title",children:[e.jsx("h4",{id:"nice-api-body-title",children:g("devTools.requestBody","Request Body")}),e.jsx("textarea",{className:"nice-api-explorer__body-editor",value:_,onChange:z=>k(z.target.value),rows:8,placeholder:g("devTools.jsonBody","JSON body…"),"aria-label":g("devTools.requestBodyJson","Request body (JSON)"),spellCheck:!1})]}),c&&e.jsxs("section",{className:"nice-api-explorer__try-it","aria-labelledby":"nice-api-try-title",children:[e.jsx("h4",{id:"nice-api-try-title",children:g("devTools.tryItOut","Try it out")}),e.jsx("button",{className:"nice-api-explorer__send-btn",onClick:V,disabled:P,type:"button",children:P?g("devTools.sending","Sending…"):e.jsxs(e.Fragment,{children:[e.jsx(l.NiceIcon,{name:"play",size:14})," ",g("devTools.send","Send")]})}),j&&e.jsxs("div",{className:"nice-api-explorer__response",children:[e.jsxs("div",{className:"nice-api-explorer__response-meta",children:[e.jsx("span",{className:`nice-api-explorer__status-badge nice-api-explorer__status-badge--${Math.floor(j.status/100)}xx`,children:j.status}),e.jsxs("span",{className:"nice-api-explorer__duration",children:[j.duration,"ms"]})]}),e.jsx("pre",{className:"nice-api-explorer__response-body",children:(()=>{try{return JSON.stringify(JSON.parse(j.body),null,2)}catch{return j.body}})()})]})]}),e.jsxs("section",{className:"nice-api-explorer__code-samples","aria-labelledby":"nice-api-code-title",children:[e.jsx("h4",{id:"nice-api-code-title",children:g("devTools.codeSamples","Code samples")}),e.jsx("pre",{className:"nice-api-explorer__code-block",children:e.jsx("code",{children:ee(w)})}),e.jsx("button",{className:"nice-api-explorer__copy-btn",onClick:()=>navigator.clipboard.writeText(ee(w)),type:"button","aria-label":g("devTools.copyCurl","Copy cURL"),children:g("devTools.copyCurl","Copy cURL")})]}),w.responses&&e.jsxs("section",{className:"nice-api-explorer__responses","aria-labelledby":"nice-api-responses-title",children:[e.jsx("h4",{id:"nice-api-responses-title",children:g("devTools.responses","Responses")}),Object.entries(w.responses).map(([z,U])=>e.jsxs("div",{className:"nice-api-explorer__response-schema",children:[e.jsx("span",{className:`nice-api-explorer__status-badge nice-api-explorer__status-badge--${z[0]}xx`,children:z}),e.jsx("span",{children:U.description})]},z))]})]}):e.jsx("div",{className:"nice-api-explorer__empty",children:g("devTools.selectEndpoint","Select an endpoint from the list on the left")})})]})},zj=[{label:"Mobile",width:375},{label:"Tablet",width:768},{label:"Desktop",width:1280},{label:"Wide",width:1920},{label:"Custom",width:0}],Bj=["white","transparent","dark","checkerboard"];function Fj(t,n){const i=Object.entries(n).filter(([,a])=>a!==void 0).map(([a,s])=>typeof s=="boolean"?s?a:`${a}={false}`:typeof s=="string"?`${a}="${s}"`:`${a}={${JSON.stringify(s)}}`).join(" ");return`<${t}${i?" "+i:""} />`}const qj=({components:t,componentName:n,defaultProps:i,showPropsPanel:a=!0,showCodePreview:s=!0,showA11yAudit:o=!0,showResponsivePreview:c=!0,showThemeSwitch:d=!0,showHistory:p=!1,layout:m="sidebar",className:h,style:u,"data-testid":x})=>{const f=r.useRef(null);l.useRovingFocus(f,{orientation:"horizontal",wrap:!0,activateOnMove:!0});const b=r.useRef(null);l.useRovingFocus(b,{orientation:"horizontal",itemSelector:"button"});const{t:g}=l.useNiceTranslation(),v=r.useMemo(()=>t&&t.length>0?t:n?[{name:n,component:H=>e.jsx("pre",{style:{margin:0,fontSize:12},children:`<${n} ${Object.entries(H).filter(([,A])=>A!==void 0).map(([A,Z])=>`${A}=${JSON.stringify(Z)}`).join(" ")} />`}),category:"preview",description:g("devTools.quickPreviewOf","Quick preview of {componentName}").replace("{componentName}",String(n)),props:Object.entries(i??{}).map(([H,A])=>({name:H,type:typeof A,defaultValue:A,label:H}))}]:[],[t,n,i,g]),[y,C]=r.useState(""),[w,E]=r.useState(v[0]??null),[S,N]=r.useState({}),[_,k]=r.useState([]),[j,T]=r.useState(-1),[P,B]=r.useState("white"),[R,I]=r.useState(100),[D,M]=r.useState(1280),[O,L]=r.useState(800),[V,ee]=r.useState("detail"),[z,U]=r.useState(!1),re=F=>{const H={};for(const A of F.props)A.defaultValue!==void 0&&(H[A.name]=A.defaultValue);N(H),k([H]),T(0)},Y=F=>{E(F),re(F),ee("detail")},oe=(F,H)=>{const A={...S,[F]:H};if(N(A),p){const Z=_.slice(0,j+1);Z.push(A),k(Z),T(Z.length-1)}},q=()=>{if(j>0){const F=j-1;T(F),N(_[F])}},se=()=>{if(j<_.length-1){const F=j+1;T(F),N(_[F])}},ce=F=>{N(F.props)},le=v.filter(F=>F.name.toLowerCase().includes(y.toLowerCase())||F.category.toLowerCase().includes(y.toLowerCase())),J=[...new Set(le.map(F=>F.category))],me=w?w.examples?.find(F=>JSON.stringify(F.props)===JSON.stringify(S))?.code??Fj(w.name,S):"",je=F=>{const H=S[F.name];switch(F.control??(F.type==="boolean"?"toggle":F.type==="number"?"number":F.enumValues?"select":"text")){case"toggle":return e.jsxs("label",{className:"nice-playground__prop-row",children:[e.jsxs("span",{className:"nice-playground__prop-name",children:[F.name,F.required&&e.jsx("span",{"aria-label":g("devTools.required","required"),children:" *"})]}),e.jsx("input",{type:"checkbox",checked:!!H,onChange:Z=>oe(F.name,Z.target.checked),"aria-label":F.name})]},F.name);case"number":return e.jsxs("label",{className:"nice-playground__prop-row",children:[e.jsxs("span",{className:"nice-playground__prop-name",children:[F.name,F.required&&e.jsx("span",{"aria-label":g("devTools.required","required"),children:" *"})]}),e.jsx("input",{type:"number",value:Number(H??0),onChange:Z=>oe(F.name,Number(Z.target.value)),"aria-label":F.name})]},F.name);case"select":return e.jsxs("label",{className:"nice-playground__prop-row",children:[e.jsxs("span",{className:"nice-playground__prop-name",children:[F.name,F.required&&e.jsx("span",{"aria-label":g("devTools.required","required"),children:" *"})]}),e.jsxs("select",{value:String(H??""),onChange:Z=>oe(F.name,Z.target.value),"aria-label":F.name,children:[!F.required&&e.jsx("option",{value:"",children:"—"}),F.enumValues?.map(Z=>e.jsx("option",{value:Z,children:Z},Z))]})]},F.name);case"color":return e.jsxs("label",{className:"nice-playground__prop-row",children:[e.jsxs("span",{className:"nice-playground__prop-name",children:[F.name,F.required&&e.jsx("span",{"aria-label":g("devTools.required","required"),children:" *"})]}),e.jsx("input",{type:"color",value:String(H??"#000000"),onChange:Z=>oe(F.name,Z.target.value),"aria-label":F.name})]},F.name);case"slider":return e.jsxs("label",{className:"nice-playground__prop-row",children:[e.jsxs("span",{className:"nice-playground__prop-name",children:[F.name,F.required&&e.jsx("span",{"aria-label":g("devTools.required","required"),children:" *"})]}),e.jsx("input",{type:"range",value:Number(H??0),onChange:Z=>oe(F.name,Number(Z.target.value)),"aria-label":F.name}),e.jsx("span",{children:String(H??0)})]},F.name);case"json":case"code":return e.jsxs("label",{className:"nice-playground__prop-row nice-playground__prop-row--code",children:[e.jsxs("span",{className:"nice-playground__prop-name",children:[F.name,F.required&&e.jsx("span",{"aria-label":g("devTools.required","required"),children:" *"})]}),e.jsx("textarea",{value:typeof H=="object"?JSON.stringify(H,null,2):String(H??""),onChange:Z=>{try{oe(F.name,JSON.parse(Z.target.value))}catch{oe(F.name,Z.target.value)}},rows:4,"aria-label":F.name,spellCheck:!1})]},F.name);default:return e.jsxs("label",{className:"nice-playground__prop-row",children:[e.jsxs("span",{className:"nice-playground__prop-name",children:[F.name,F.required&&e.jsx("span",{"aria-label":g("devTools.required","required"),children:" *"})]}),e.jsx("input",{type:"text",value:String(H??""),onChange:Z=>oe(F.name,Z.target.value),"aria-label":F.name})]},F.name)}},ue=w?.component;return e.jsxs("div",{className:`nice-playground nice-playground--${m} ${h??""}`,style:u,"data-testid":x,children:[e.jsxs("aside",{className:"nice-playground__tree","aria-label":g("devTools.componentList","Component list"),children:[e.jsx("input",{type:"search",placeholder:g("devTools.searchComponentPlaceholder","Search components (Ctrl+P)…"),value:y,onChange:F=>C(F.target.value),className:"nice-playground__tree-search","aria-label":g("devTools.searchComponent","Search components")}),J.map(F=>e.jsxs("div",{className:"nice-playground__tree-group",children:[e.jsx("h3",{className:"nice-playground__tree-group-title",children:F}),le.filter(H=>H.category===F).map(H=>e.jsx("button",{className:`nice-playground__tree-item${w?.name===H.name?" nice-playground__tree-item--active":""}`,onClick:()=>Y(H),type:"button",children:H.name},H.name))]},F))]}),e.jsxs("div",{className:"nice-playground__main",children:[e.jsxs("div",{ref:b,className:"nice-playground__canvas-toolbar",role:"toolbar","aria-label":g("devTools.canvasTools","Canvas tools"),children:[Bj.map(F=>e.jsx("button",{className:`nice-playground__bg-btn${P===F?" nice-playground__bg-btn--active":""}`,onClick:()=>B(F),type:"button","aria-pressed":P===F,children:F==="white"?g("devTools.canvasBgWhite","White"):F==="transparent"?g("devTools.canvasBgTransparent","Transparent"):F==="dark"?g("devTools.canvasBgDark","Dark"):g("devTools.canvasBgCheckerboard","Checkerboard")},F)),e.jsxs("label",{className:"nice-playground__zoom",children:[g("devTools.zoom","Zoom"),e.jsx("select",{value:R,onChange:F=>I(Number(F.target.value)),"aria-label":g("devTools.zoomCanvas","Zoom canvas"),children:[50,75,100,125,150,200].map(F=>e.jsxs("option",{value:F,children:[F,"%"]},F))})]}),d&&e.jsx("button",{onClick:()=>U(F=>!F),type:"button","aria-pressed":z,children:z?g("devTools.lightPreview","Light"):g("devTools.darkPreview","Dark")}),p&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:q,disabled:j<=0,type:"button","aria-label":g("devTools.undoPropChanges","Undo prop changes"),children:[e.jsx(l.NiceIcon,{name:"reply",size:14})," ",g("devTools.undo","Undo")]}),e.jsxs("button",{onClick:se,disabled:j>=_.length-1,type:"button","aria-label":g("devTools.redoPropChanges","Redo prop changes"),children:[e.jsx(l.NiceIcon,{name:"forward",size:14})," ",g("devTools.redo","Redo")]})]})]}),e.jsx("div",{className:`nice-playground__canvas nice-playground__canvas--${P}${z?" nice-playground__canvas--dark":""}`,style:{transform:`scale(${R/100})`,transformOrigin:"top left"},"aria-label":g("devTools.componentPreview","Component preview"),children:ue?e.jsx(ue,{...S}):e.jsx("div",{className:"nice-playground__canvas-empty",children:g("devTools.selectComponent","Select a component from the list")})}),w&&e.jsxs("div",{className:"nice-playground__panels",children:[e.jsxs("div",{className:"nice-playground__panel-tabs",ref:f,role:"tablist",children:[e.jsx("button",{role:"tab","aria-selected":V==="detail",onClick:()=>ee("detail"),className:V==="detail"?"nice-playground__panel-tab--active":"",type:"button",children:g("devTools.tabProps","Props")}),s&&e.jsx("button",{role:"tab","aria-selected":!1,onClick:()=>{},className:"",type:"button",children:g("devTools.tabCode","Code")}),c&&e.jsx("button",{role:"tab","aria-selected":V==="responsive",onClick:()=>ee("responsive"),className:V==="responsive"?"nice-playground__panel-tab--active":"",type:"button",children:g("devTools.responsive","Responsive")}),o&&e.jsx("button",{role:"tab","aria-selected":V==="a11y",onClick:()=>ee("a11y"),className:V==="a11y"?"nice-playground__panel-tab--active":"",type:"button",children:"A11y"}),e.jsx("button",{role:"tab","aria-selected":V==="examples",onClick:()=>ee("examples"),className:V==="examples"?"nice-playground__panel-tab--active":"",type:"button",children:g("devTools.tabExamples","Examples")}),w.changelog&&e.jsx("button",{role:"tab","aria-selected":V==="changelog",onClick:()=>ee("changelog"),className:V==="changelog"?"nice-playground__panel-tab--active":"",type:"button",children:g("devTools.changelog","Changelog")})]}),V==="detail"&&a&&e.jsxs("div",{className:"nice-playground__props-panel",role:"tabpanel",children:[e.jsx("p",{className:"nice-playground__component-desc",children:w.description}),w.props.map(je)]}),s&&e.jsxs("div",{className:"nice-playground__code-panel",role:"tabpanel","aria-label":g("devTools.codePreview","Code preview"),children:[e.jsx("pre",{className:"nice-playground__code-block",children:e.jsx("code",{children:me})}),e.jsx("button",{onClick:()=>navigator.clipboard.writeText(me),type:"button",className:"nice-playground__copy-btn","aria-label":g("devTools.copyJsx","Copy JSX"),children:g("devTools.copy","Copy")})]}),V==="responsive"&&c&&e.jsxs("div",{className:"nice-playground__responsive-panel",role:"tabpanel",children:[e.jsxs("div",{className:"nice-playground__responsive-presets",role:"group","aria-label":g("devTools.responsivePresets","Resolution presets"),children:[zj.map((F,H)=>e.jsxs("button",{className:`nice-playground__preset-btn${D===(F.width||O)?" nice-playground__preset-btn--active":""}`,onClick:()=>{F.width>0?M(F.width):M(O)},type:"button","aria-keyshortcuts":`${H+1}`,children:[F.label,F.width>0?` (${F.width}px)`:""]},F.label)),e.jsx("input",{type:"number",value:O,onChange:F=>{L(Number(F.target.value)),M(Number(F.target.value))},min:200,max:3840,"aria-label":g("devTools.customWidthPx","Custom width in pixels")})]}),e.jsx("div",{className:"nice-playground__responsive-frame",style:{width:D,overflow:"hidden",border:"1px dashed var(--nice-border-color, #94a3b8)",resize:"horizontal"},children:ue&&e.jsx(ue,{...S})})]}),V==="a11y"&&o&&e.jsxs("div",{className:"nice-playground__a11y-panel",role:"tabpanel",children:[e.jsx("p",{className:"nice-playground__a11y-hint",children:g("devTools.a11yHint","The automatic accessibility audit checks colour contrast, ARIA roles, tab order and keyboard navigation. A full audit requires integrating a library such as axe-core.")}),e.jsxs("ul",{className:"nice-playground__a11y-checks",children:[e.jsxs("li",{className:"nice-playground__a11y-check nice-playground__a11y-check--info",children:[e.jsx(l.NiceIcon,{name:"info",size:14})," ",g("devTools.a11yCheckFocus","Check manually: every interactive element has a visible focus ring")]}),e.jsxs("li",{className:"nice-playground__a11y-check nice-playground__a11y-check--info",children:[e.jsx(l.NiceIcon,{name:"info",size:14})," ",g("devTools.a11yCheckAlt","Check manually: images have an alt attribute")]}),e.jsxs("li",{className:"nice-playground__a11y-check nice-playground__a11y-check--info",children:[e.jsx(l.NiceIcon,{name:"info",size:14})," ",g("devTools.a11yCheckLabels","Check manually: form fields have associated labels")]})]})]}),V==="examples"&&e.jsx("div",{className:"nice-playground__examples-panel",role:"tabpanel",children:(w.examples??[]).length===0?e.jsx("p",{children:g("devTools.noExamples","No examples for this component")}):w.examples.map((F,H)=>e.jsxs("div",{className:"nice-playground__example",children:[e.jsxs("div",{className:"nice-playground__example-header",children:[e.jsx("strong",{children:F.name}),e.jsx("button",{onClick:()=>ce(F),type:"button",children:g("devTools.applyExample","Apply")})]}),e.jsx("p",{children:F.description})]},H))}),V==="changelog"&&w.changelog&&e.jsx("div",{className:"nice-playground__changelog-panel",role:"tabpanel",children:w.changelog.map((F,H)=>e.jsxs("div",{className:"nice-playground__changelog-entry",children:[e.jsxs("h4",{children:["v",F.version,F.date?` — ${F.date}`:""]}),e.jsx("ul",{children:F.changes.map((A,Z)=>e.jsx("li",{children:A},Z))})]},H))})]})]})]})},Zc=104,Vj=106;function el(t){const n=[Zc];let i=Zc;for(let a=0;a<t.length;a++){const s=t.charCodeAt(a)-32;n.push(s),i+=s*(a+1)}return n.push(i%103),n.push(Vj),n}const tl=["11011001100","11001101100","11001100110","10010011000","10010001100","10001001100","10011001000","10011000100","10001100100","11001001000","11001000100","11000100100","10110011100","10011011100","10011001110","10111001100","10011101100","10011100110","11001110010","11001011100","11001001110","11011100100","11001110100","11101101110","11101001100","11100101100","11100100110","11101100100","11100110100","11100110010","11011011000","11011000110","11000110110","10100011000","10001011000","10001000110","10110001000","10001101000","10001100010","11010001000","11000101000","11000100010","10110111000","10110001110","10001101110","10111011000","10111000110","10001110110","11101110110","11010001110","11000101110","11011101000","11011100010","11011101110","11101011000","11101000110","11100010110","11101101000","11101100010","11100011010","11101111010","11001000010","11110001010","10100110000","10100001100","10010110000","10010000110","10000101100","10000100110","10110010000","10110000100","10011010000","10011000010","10000110100","10000110010","11000010010","11001010000","11110111010","11000010100","10001111010","10100111100","10010111100","10010011110","10111100100","10011110100","10011110010","11110100100","11110010100","11110010010","11011011110","11011110110","11110110110","10101111000","10100011110","10001011110","10111101000","10111100010","11110101000","11110100010","10111011110","10111101110","11101011110","11110101110","11010000100","11010010000","11010011100","1100011101011"];function Uj(t){const n={0:"101001101101",1:"110100101011",2:"101100101011",3:"110110010101",4:"101001101011",5:"110100110101",6:"101100110101",7:"101001011011",8:"110100101101",9:"110110010110",A:"110101001011",B:"101101001011",C:"110110100101",D:"101011001011",E:"110101100101",F:"101101100101",G:"101010011011",H:"110101001101",I:"101101001101",J:"101011001101",K:"110101010011",L:"101101010011",M:"110110101001",N:"101011010011",O:"110101101001",P:"101101101001",Q:"101010110011",R:"110101011001",S:"101101011001",T:"101011011001",U:"110010101011",V:"100110101011",W:"110011010101",X:"100101101011",Y:"110010110101",Z:"100110110101","-":"100101011011"," ":"100110101101",".":"110010101101","*":"100101101101"},i=[],a=`*${t.toUpperCase()}*`;for(const s of a){const o=n[s];o&&i.push(o)}return i}const Ru=Object.assign(r.forwardRef(({value:t,defaultValue:n,format:i="CODE128",width:a,height:s=80,barWidth:o=2,barColor:c,background:d,showText:p=!0,fontSize:m=14,size:h="md",showInput:u=!1,editable:x,inputLabel:f,inputPlaceholder:b,labelPlacement:g,inputProps:v,onValueChange:y,className:C,style:w,id:E,testId:S,"data-testid":N,..._},k)=>{const{t:j}=l.useNiceTranslation(),T=x??u,P=l.useControlId(E),B=r.useRef(null),R=k??B,I=l.useThemeIsDark(R),D=c||(I?"#f8fafc":"#111827"),M=d||"transparent",[O,L]=l.useControllableState({value:t,defaultValue:n,fallbackValue:"",onChange:y,componentName:"NiceBarcode"}),[V,ee]=r.useState(O);r.useEffect(()=>{ee(O)},[O]);const z=T?V:O,U=Y=>{ee(Y),L(Y)};r.useEffect(()=>{const Y=typeof R=="object"&&R?.current?R.current:B.current;if(!Y)return;const oe=Y.getContext("2d");if(!oe)return;let q="";i==="CODE128"?q=el(z).map(ue=>tl[ue]??"").join(""):i==="CODE39"?q=Uj(z).join("0"):q=el(z).map(ue=>tl[ue]??"").join("");const se=o&&o>0?o:2,ce=q.length*se,le=p?m+8:0,J=a&&a>0?a:ce+20;Y.width=J,Y.height=s+le,oe.clearRect(0,0,Y.width,Y.height),M!=="transparent"&&(oe.fillStyle=M,oe.fillRect(0,0,Y.width,Y.height));const me=(J-ce)/2;oe.fillStyle=D;for(let je=0;je<q.length;je++)q[je]==="1"&&oe.fillRect(me+je*se,0,se,s);p&&(oe.fillStyle=D,oe.font=`${m}px monospace`,oe.textAlign="center",oe.fillText(z,Y.width/2,s+m+2))},[z,i,a,s,o,D,M,p,m,R,T]);const re=e.jsx("canvas",{ref:B,id:T?void 0:P,className:`nice-barcode nice-barcode--${h}${T?"":` ${C??""}`}`,style:T?void 0:w,"data-testid":T?void 0:N??S,role:"img","aria-label":j("barcodeGenerator.barcode","Barcode: {encodedValue}").replace("{encodedValue}",String(z)),...T?{}:_});return T?e.jsxs("div",{id:P,className:`nice-barcode-field nice-barcode-field--${h} ${C??""}`,style:{display:"inline-flex",flexDirection:"column",gap:8,...w},"data-testid":N??S,..._,children:[e.jsx(Oe.NiceTextInput,{...v,label:f??v?.label,placeholder:b??v?.placeholder,labelPlacement:g??v?.labelPlacement,size:h,value:V,onChange:U}),re]}):re}),{displayName:"NiceBarcode"}),Hj={L:0,M:1,Q:2,H:3},Gj={M:0,L:1,H:2,Q:3},$u=Wj();function Wj(){const t=new Uint8Array(256),n=new Uint8Array(256);let i=1;for(let a=0;a<255;a++)t[a]=i,i<<=1,i&256&&(i^=285);for(let a=0;a<255;a++)n[t[a]]=a;return{exp:t,log:n}}function fo(t){for(;t<0;)t+=255;for(;t>=255;)t-=255;return $u.exp[t]}function ys(t){return $u.log[t]}function Kj(t,n){const i=new Array(t.length+n.length-1).fill(0);for(let a=0;a<t.length;a++)for(let s=0;s<n.length;s++)i[a+s]^=fo(ys(t[a])+ys(n[s]));return i}function Yj(t){let n=[1];for(let i=0;i<t;i++)n=Kj(n,[1,fo(i)]);return n}function Jj(t,n){const i=Yj(n),a=t.concat(new Array(n).fill(0));for(let s=0;s<t.length;s++){const o=a[s];if(o!==0){const c=ys(o);for(let d=0;d<i.length;d++)a[s+d]^=fo(ys(i[d])+c)}}return a.slice(t.length)}const Qj=[[1,26,19],[1,26,16],[1,26,13],[1,26,9],[1,44,34],[1,44,28],[1,44,22],[1,44,16],[1,70,55],[1,70,44],[2,35,17],[2,35,13],[1,100,80],[2,50,32],[2,50,24],[4,25,9],[1,134,108],[2,67,43],[2,33,15,2,34,16],[2,33,11,2,34,12],[2,86,68],[4,43,27],[4,43,19],[4,43,15],[2,98,78],[4,49,31],[2,32,14,4,33,15],[4,39,13,1,40,14],[2,121,97],[2,60,38,2,61,39],[4,40,18,2,41,19],[4,40,14,2,41,15],[2,146,116],[3,58,36,2,59,37],[4,36,16,4,37,17],[4,36,12,4,37,13],[2,86,68,2,87,69],[4,69,43,1,70,44],[6,43,19,2,44,20],[6,43,15,2,44,16],[4,101,81],[1,80,50,4,81,51],[4,50,22,4,51,23],[3,36,12,8,37,13],[2,116,92,2,117,93],[6,58,36,2,59,37],[4,46,20,6,47,21],[7,42,14,4,43,15],[4,133,107],[8,59,37,1,60,38],[8,44,20,4,45,21],[12,33,11,4,34,12],[3,145,115,1,146,116],[4,64,40,5,65,41],[11,36,16,5,37,17],[11,36,12,5,37,13],[5,109,87,1,110,88],[5,65,41,5,66,42],[5,54,24,7,55,25],[11,36,12,7,37,13],[5,122,98,1,123,99],[7,73,45,3,74,46],[15,43,19,2,44,20],[3,45,15,13,46,16],[1,135,107,5,136,108],[10,74,46,1,75,47],[1,50,22,15,51,23],[2,42,14,17,43,15],[5,150,120,1,151,121],[9,69,43,4,70,44],[17,50,22,1,51,23],[2,42,14,19,43,15],[3,141,113,4,142,114],[3,70,44,11,71,45],[17,47,21,4,48,22],[9,39,13,16,40,14],[3,135,107,5,136,108],[3,67,41,13,68,42],[15,54,24,5,55,25],[15,43,15,10,44,16],[4,144,116,4,145,117],[17,68,42],[17,50,22,6,51,23],[19,46,16,6,47,17],[2,139,111,7,140,112],[17,74,46],[7,54,24,16,55,25],[34,37,13],[4,151,121,5,152,122],[4,75,47,14,76,48],[11,54,24,14,55,25],[16,45,15,14,46,16],[6,147,117,4,148,118],[6,73,45,14,74,46],[11,54,24,16,55,25],[30,46,16,2,47,17],[8,132,106,4,133,107],[8,75,47,13,76,48],[7,54,24,22,55,25],[22,45,15,13,46,16],[10,142,114,2,143,115],[19,74,46,4,75,47],[28,50,22,6,51,23],[33,46,16,4,47,17],[8,152,122,4,153,123],[22,73,45,3,74,46],[8,53,23,26,54,24],[12,45,15,28,46,16],[3,147,117,10,148,118],[3,73,45,23,74,46],[4,54,24,31,55,25],[11,45,15,31,46,16],[7,146,116,7,147,117],[21,73,45,7,74,46],[1,53,23,37,54,24],[19,45,15,26,46,16],[5,145,115,10,146,116],[19,75,47,10,76,48],[15,54,24,25,55,25],[23,45,15,25,46,16],[13,145,115,3,146,116],[2,74,46,29,75,47],[42,54,24,1,55,25],[23,45,15,28,46,16],[17,145,115],[10,74,46,23,75,47],[10,54,24,35,55,25],[19,45,15,35,46,16],[17,145,115,1,146,116],[14,74,46,21,75,47],[29,54,24,19,55,25],[11,45,15,46,46,16],[13,145,115,6,146,116],[14,74,46,23,75,47],[44,54,24,7,55,25],[59,46,16,1,47,17],[12,151,121,7,152,122],[12,75,47,26,76,48],[39,54,24,14,55,25],[22,45,15,41,46,16],[6,151,121,14,152,122],[6,75,47,34,76,48],[46,54,24,10,55,25],[2,45,15,64,46,16],[17,152,122,4,153,123],[29,74,46,14,75,47],[49,54,24,10,55,25],[24,45,15,46,46,16],[4,152,122,18,153,123],[13,74,46,32,75,47],[48,54,24,14,55,25],[42,45,15,32,46,16],[20,147,117,4,148,118],[40,75,47,7,76,48],[43,54,24,22,55,25],[10,45,15,67,46,16],[19,148,118,6,149,119],[18,75,47,31,76,48],[34,54,24,34,55,25],[20,45,15,61,46,16]];function Mu(t,n){const i=Qj[(t-1)*4+Hj[n]],a=[];for(let s=0;s<i.length;s+=3){const o=i[s],c=i[s+1],d=i[s+2];for(let p=0;p<o;p++)a.push({totalCount:c,dataCount:d})}return a}const Xj=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],Js=1335,Zj=21522,Qs=7973;function qn(t){let n=0;for(;t!==0;)n++,t>>>=1;return n}function ew(t){let n=t<<10;for(;qn(n)-qn(Js)>=0;)n^=Js<<qn(n)-qn(Js);return(t<<10|n)^Zj}function tw(t){let n=t<<12;for(;qn(n)-qn(Qs)>=0;)n^=Qs<<qn(n)-qn(Qs);return t<<12|n}class nw{constructor(){this.bits=[]}put(n,i){for(let a=i-1;a>=0;a--)this.bits.push((n>>>a&1)===1?1:0)}get length(){return this.bits.length}}function Ou(t){return t<=9?8:(t<=26,16)}function nl(t){return Array.from({length:t},()=>new Array(t).fill(null))}function Xs(t,n,i){for(let a=-1;a<=7;a++)for(let s=-1;s<=7;s++){const o=n+a,c=i+s;if(o<0||o>=t.length||c<0||c>=t.length)continue;const d=a>=0&&a<=6&&(s===0||s===6)||s>=0&&s<=6&&(a===0||a===6)||a>=2&&a<=4&&s>=2&&s<=4;t[o][c]=d}}function iw(t,n){const i=Xj[n-1];for(const a of i)for(const s of i)if(t[a][s]===null)for(let o=-2;o<=2;o++)for(let c=-2;c<=2;c++){const d=Math.max(Math.abs(o),Math.abs(c))!==1;t[a+o][s+c]=d}}function aw(t){const n=t.length;for(let i=8;i<n-8;i++){const a=i%2===0;t[6][i]===null&&(t[6][i]=a),t[i][6]===null&&(t[i][6]=a)}}function sw(t,n){const i=t.length;t[i-8][8]=!0}function rw(t,n,i){const a=t.length,s=Gj[n]<<3|i,o=ew(s);for(let c=0;c<15;c++){const d=(o>>c&1)===1;c<6?t[c][8]=d:c<8?t[c+1][8]=d:t[a-15+c][8]=d}for(let c=0;c<15;c++){const d=(o>>c&1)===1;c<8?t[8][a-c-1]=d:c<9?t[8][15-c]=d:t[8][15-c-1]=d}t[a-8][8]=!0}function ow(t,n){if(n<7)return;const i=t.length,a=tw(n);for(let s=0;s<18;s++){const o=(a>>s&1)===1,c=Math.floor(s/3),d=s%3+i-8-3;t[c][d]=o,t[d][c]=o}}function cw(t,n,i){switch(t){case 0:return(n+i)%2===0;case 1:return n%2===0;case 2:return i%3===0;case 3:return(n+i)%3===0;case 4:return(Math.floor(n/2)+Math.floor(i/3))%2===0;case 5:return n*i%2+n*i%3===0;case 6:return(n*i%2+n*i%3)%2===0;case 7:return(n*i%3+(n+i)%2)%2===0;default:return!1}}function lw(t){const n=t.length;let i=0;for(let m=0;m<n;m++){let h=1,u=1;for(let x=1;x<n;x++)t[m][x]===t[m][x-1]?h++:(h>=5&&(i+=3+(h-5)),h=1),t[x][m]===t[x-1][m]?u++:(u>=5&&(i+=3+(u-5)),u=1);h>=5&&(i+=3+(h-5)),u>=5&&(i+=3+(u-5))}for(let m=0;m<n-1;m++)for(let h=0;h<n-1;h++){const u=t[m][h];u===t[m][h+1]&&u===t[m+1][h]&&u===t[m+1][h+1]&&(i+=3)}const a=[!0,!1,!0,!0,!0,!1,!0,!1,!1,!1,!1],s=[!1,!1,!1,!1,!0,!1,!0,!0,!0,!1,!0],o=(m,h,u,x)=>{for(let f=0;f<11;f++){const b=x?h:h+f,g=x?u+f:u;if(m[f]!==t[b][g])return!1}return!0};for(let m=0;m<n;m++)for(let h=0;h<n;h++)h+11<=n&&(o(a,m,h,!0)||o(s,m,h,!0))&&(i+=40),m+11<=n&&(o(a,m,h,!1)||o(s,m,h,!1))&&(i+=40);let c=0;for(let m=0;m<n;m++)for(let h=0;h<n;h++)t[m][h]&&c++;const d=c*100/(n*n),p=Math.abs(Math.floor(d/5)*5-50)/5;return i+=p*10,i}function dw(t,n,i){const a=Mu(n,i),s=a.reduce((y,C)=>y+C.dataCount,0),o=new nw;o.put(4,4),o.put(t.length,Ou(n));for(const y of t)o.put(y,8);const c=s*8,d=Math.min(4,c-o.length);for(d>0&&o.put(0,d);o.length%8!==0;)o.bits.push(0);const p=[];for(let y=0;y<o.length;y+=8){let C=0;for(let w=0;w<8;w++)C=C<<1|o.bits[y+w];p.push(C)}const m=[236,17];let h=0;for(;p.length<s;)p.push(m[h++%2]);const u=[],x=[];let f=0;for(const y of a){const C=p.slice(f,f+y.dataCount);f+=y.dataCount,u.push(C),x.push(Jj(C,y.totalCount-y.dataCount))}const b=[],g=Math.max(...a.map(y=>y.dataCount));for(let y=0;y<g;y++)for(const C of u)y<C.length&&b.push(C[y]);const v=Math.max(...x.map(y=>y.length));for(let y=0;y<v;y++)for(const C of x)y<C.length&&b.push(C[y]);return b}function uw(t,n){for(let i=1;i<=40;i++){const s=Mu(i,n).reduce((c,d)=>c+d.dataCount,0);if(4+Ou(i)+t*8<=s*8)return i}return 40}function il(t,n="M"){const i=Array.from(new TextEncoder().encode(t)),a=uw(i.length,n),s=a*4+17,o=dw(i,a,n),c=nl(s);Xs(c,0,0),Xs(c,0,s-7),Xs(c,s-7,0),iw(c,a),aw(c),sw(c),ow(c,a);const d=nl(s);for(let f=0;f<s;f++)for(let b=0;b<s;b++)d[f][b]=c[f][b]!==null;for(let f=0;f<9;f++)d[8][f]=!0,d[f][8]=!0;for(let f=0;f<8;f++)d[8][s-1-f]=!0,d[s-1-f][8]=!0;d[s-8][8]=!0;const p=[];for(const f of o)for(let b=7;b>=0;b--)p.push(f>>b&1);let m=0,h=!0;for(let f=s-1;f>0;f-=2){const b=f===6?f-1:f;for(let g=0;g<s;g++){const v=h?s-1-g:g;for(let y=0;y<2;y++){const C=b-y;if(d[v][C])continue;const w=m<p.length?p[m]===1:!1;c[v][C]=w,m++}}h=!h}for(let f=0;f<s;f++)for(let b=0;b<s;b++)c[f][b]===null&&(c[f][b]=!1);let u=null,x=1/0;for(let f=0;f<8;f++){const b=c.map(v=>v.map(y=>y));for(let v=0;v<s;v++)for(let y=0;y<s;y++)!d[v][y]&&cw(f,v,y)&&(b[v][y]=!b[v][y]);rw(b,n,f);const g=lw(b);g<x&&(x=g,u=b)}return u}const Lu=Object.assign(r.forwardRef(({value:t,defaultValue:n,qrSize:i=200,color:a,background:s,errorCorrection:o="M",size:c="md",renderAs:d="canvas",quiet:p=4,logo:m,logoSize:h=40,showInput:u=!1,editable:x,inputLabel:f,inputPlaceholder:b,labelPlacement:g,inputProps:v,onValueChange:y,className:C,style:w,id:E,testId:S,"data-testid":N,..._},k)=>{const{t:j}=l.useNiceTranslation(),T=x??u,P=l.useControlId(E),B=r.useRef(null),R=l.useThemeIsDark(B),I=a||(R?"#f8fafc":"#111827"),D=s||"transparent",[M,O]=l.useControllableState({value:t,defaultValue:n,fallbackValue:"",onChange:y,componentName:"NiceQRCode"}),[L,V]=r.useState(M);r.useEffect(()=>{V(M)},[M]);const ee=T?L:M,z=se=>{V(se),O(se)};r.useEffect(()=>{const se=(k&&typeof k=="object"&&"current"in k?k.current:null)??B.current;if(!se||d!=="canvas")return;const ce=se.getContext("2d");if(!ce)return;const le=il(ee,o),J=le.length,me=J+p*2,je=i/me;se.width=i,se.height=i,ce.clearRect(0,0,i,i),D!=="transparent"&&(ce.fillStyle=D,ce.fillRect(0,0,i,i)),ce.fillStyle=I;for(let ue=0;ue<J;ue++)for(let F=0;F<J;F++)le[ue][F]&&ce.fillRect((F+p)*je,(ue+p)*je,je,je);if(m){const ue=new Image;ue.crossOrigin="anonymous",ue.onload=()=>{const F=(i-h)/2,H=(i-h)/2;ce.fillStyle=D==="transparent"?R?"#111827":"#f8fafc":D,ce.fillRect(F-2,H-2,h+4,h+4),ce.drawImage(ue,F,H,h,h)},ue.src=m}},[ee,o,i,I,D,p,m,h,d,k,R,T]);const U=T?void 0:P,re=T?`nice-qrcode nice-qrcode--${c}`:`nice-qrcode nice-qrcode--${c} ${C??""}`,Y=T?void 0:w,oe=T?{}:_;let q;if(d==="svg"){const se=il(ee,o),le=se.length+p*2,J=i/le;q=e.jsxs("svg",{id:U,className:re,style:Y,"data-testid":T?void 0:N??S,width:i,height:i,viewBox:`0 0 ${i} ${i}`,role:"img","aria-label":j("qrCode.qrCode","QR Code: {encodedValue}").replace("{encodedValue}",String(ee)),...oe,children:[D!=="transparent"&&e.jsx("rect",{width:i,height:i,fill:D}),se.map((me,je)=>me.map((ue,F)=>ue?e.jsx("rect",{x:(F+p)*J,y:(je+p)*J,width:J,height:J,fill:I},`${je}-${F}`):null))]})}else q=e.jsx("canvas",{ref:B,id:U,className:re,style:Y,"data-testid":T?void 0:N??S,role:"img","aria-label":j("qrCode.qrCode","QR Code: {encodedValue}").replace("{encodedValue}",String(ee)),...oe});return T?e.jsxs("div",{id:P,className:`nice-qrcode-field nice-qrcode-field--${c} ${C??""}`,style:{display:"inline-flex",flexDirection:"column",gap:8,...w},"data-testid":N??S,..._,children:[e.jsx(Oe.NiceTextInput,{...v,label:f??v?.label,placeholder:b??v?.placeholder,labelPlacement:g??v?.labelPlacement,size:c,value:L,onChange:z}),q]}):q}),{displayName:"NiceQRCode"});function pw(t){return typeof t=="number"?t:/^\d+(\.\d+)?$/.test(t.trim())?`${t}px`:t}const zu=Object.assign(r.forwardRef(({lines:t,prompt:n="$ ",onCommand:i,readOnly:a=!1,disabled:s=!1,error:o,theme:c="auto",loading:d=!1,size:p="md",height:m=400,maxHistory:h=100,greeting:u,fontFamily:x,showTimestamp:f=!1,className:b,style:g,id:v,testId:y,"data-testid":C,...w},E)=>{const S=l.useControlId(v),{t:N}=l.useNiceTranslation(),_=r.useRef(null),k=r.useRef(null),[j,T]=r.useState(()=>{const Y=[];return u&&Y.push({type:"system",text:u,timestamp:new Date}),Y}),[P,B]=r.useState(""),[R,I]=r.useState([]),[D,M]=r.useState(-1),O=t??j,L=s||d,V=typeof o=="string"?o:"";r.useEffect(()=>{k.current&&(k.current.scrollTop=k.current.scrollHeight)},[O]);const ee=r.useCallback(Y=>{t||T(oe=>{const q=[...oe,Y];return q.length>h?q.slice(q.length-h):q})},[t,h]),z=r.useCallback(Y=>{Y.preventDefault();const oe=P.trim();oe&&(ee({type:"input",text:`${n}${oe}`,timestamp:new Date}),I(q=>[...q,oe]),M(-1),B(""),i?.(oe))},[P,n,ee,i]),U=r.useCallback(Y=>{Y.key==="ArrowUp"?(Y.preventDefault(),M(oe=>{const q=oe===-1?R.length-1:Math.max(0,oe-1);return B(R[q]??""),q})):Y.key==="ArrowDown"&&(Y.preventDefault(),M(oe=>{if(oe===-1)return-1;const q=oe+1;return q>=R.length?(B(""),-1):(B(R[q]??""),q)}))},[R]),re=r.useCallback(()=>{L||_.current?.focus()},[L]);return e.jsxs("div",{ref:E,id:S,className:`nice-terminal nice-terminal--${p} nice-terminal--theme-${c}${a?" nice-terminal--readonly":""}${s?" nice-terminal--disabled":""}${d?" nice-terminal--loading":""}${V?" nice-terminal--error":""}${b?` ${b}`:""}`,style:{...g,height:pw(m),...x?{fontFamily:x}:null},onClick:re,role:"log","aria-label":N("terminal.label","Terminal"),"aria-live":"polite","aria-disabled":s||void 0,"aria-busy":d||void 0,"data-testid":C??y,...w,children:[V&&e.jsx("div",{className:"nice-terminal__error-banner",role:"alert",children:V}),e.jsx("div",{className:"nice-terminal__output",ref:k,children:O.map((Y,oe)=>e.jsxs("div",{className:`nice-terminal__line nice-terminal__line--${Y.type}`,children:[f&&Y.timestamp&&e.jsxs("span",{className:"nice-terminal__timestamp",children:["[",Y.timestamp.toLocaleTimeString(),"]"]}),e.jsx("span",{className:"nice-terminal__text",children:Y.text})]},oe))}),!a&&e.jsxs("form",{className:"nice-terminal__input-row",onSubmit:z,children:[e.jsx("span",{className:"nice-terminal__prompt",children:n}),e.jsx("input",{ref:_,className:"nice-terminal__input",type:"text",value:P,onChange:Y=>B(Y.target.value),onKeyDown:U,disabled:L,spellCheck:!1,autoComplete:"off","aria-label":N("terminal.input","Command input")})]}),d&&e.jsx("div",{className:"nice-terminal__loading","aria-hidden":"true",children:e.jsx("span",{className:"nice-spinner nice-spinner--md"})})]})}),{displayName:"NiceTerminalUI"}),mw=({enabled:t=!0,labels:n,tutorialProps:i,children:a})=>{const{t:s}=l.useNiceTranslation(),[o,c]=r.useState([]),[d,p]=r.useState(!1),m=r.useCallback(u=>{c(u),p(!0)},[]),h=r.useMemo(()=>({next:s("tutorial.next","Next"),back:s("tutorial.back","Back"),finish:s("tutorial.finish","Finish"),skip:s("tutorial.skip","Skip"),stepOf:s("tutorial.stepOf","of"),play:s("tutorial.play","Play"),pause:s("tutorial.pause","Pause"),speed:s("tutorial.speed","Speed"),close:s("tutorial.close","Close"),...n}),[s,n]);return e.jsxs(l.NiceTutorialsProvider,{enabled:t,active:d,onRun:m,children:[a,e.jsx(kt.NiceTutorial,{...i,steps:o,active:d,labels:h,onFinish:()=>p(!1),onSkip:()=>p(!1)})]})},Bu=({value:t,onChange:n,layout:i="pills",size:a="md",showDescription:s=!1,showPreview:o=!0,label:c,styles:d,compact:p=!1,className:m,style:h,"data-testid":u})=>{const{t:x}=l.useNiceTranslation(),f=l.useNiceDisplayStyle(),b=t??f.displayStyle,[g,v]=r.useState(!1),y=p?"dropdown":i,C=r.useCallback(I=>{n?n(I):f.setDisplayStyle(I),v(!1)},[n,f]),w=r.useMemo(()=>(d??l.NICE_DISPLAY_STYLES).map(D=>{const M=l.NICE_DISPLAY_STYLE_INFO.find(O=>O.name===D);return{name:D,label:M?.label??D,description:M?.description??"",density:M?.density??"normal",animation:M?.animation??"normal"}}),[d]),E=r.useRef(null);l.useRovingFocus(E,{orientation:y==="pills"?"both":"grid",wrap:!0,activateOnMove:!0,enabled:y!=="dropdown"});const{activeIndex:S,setActiveIndex:N,handleKeyDown:_}=Vt.useListKeyboardNav(w,{open:g,onSelect:I=>C(I.name),onClose:()=>v(!1),onOpen:()=>k()}),k=()=>{N(Math.max(0,w.findIndex(I=>I.name===b))),v(!0)},T=`${r.useId()}-styles`,P=r.useCallback(I=>{if(!o)return null;const D=l.resolveDisplayStyleConfig(I),M=D.radius==="none",L=D.radius==="full"?"50%":M?"0":D.radius==="sm"?"3px":D.radius==="lg"?"10px":D.radius==="xl"?"16px":D.radius==="2xl"?"24px":"6px",V=D.shadow==="none"?"none":D.shadow==="glow"?"0 0 8px color-mix(in srgb, var(--nice-color-primary, #6366f1) 40%, transparent)":D.shadow==="colored"?"0 2px 8px color-mix(in srgb, var(--nice-color-primary, #6366f1) 30%, transparent)":D.shadow==="inner"?"inset 0 1px 3px color-mix(in srgb, var(--nice-text-primary, #000) 10%, transparent)":D.shadow==="subtle"?"0 1px 2px color-mix(in srgb, var(--nice-text-primary, #000) 5%, transparent)":D.shadow==="lg"?"0 4px 12px color-mix(in srgb, var(--nice-text-primary, #000) 15%, transparent)":"0 2px 6px color-mix(in srgb, var(--nice-text-primary, #000) 10%, transparent)",ee=D.fill==="glass"?"color-mix(in srgb, var(--nice-color-primary, #6366f1) 15%, transparent)":D.fill==="frosted"?"color-mix(in srgb, var(--nice-color-white, #fff) 70%, transparent)":D.fill==="gradient-linear"?"linear-gradient(135deg, var(--nice-color-primary, #6366f1), var(--nice-color-accent, #8b5cf6))":D.fill==="mesh"?"radial-gradient(at 40% 20%, var(--nice-color-primary, #6366f1) 0%, transparent 50%), radial-gradient(at 80% 0%, var(--nice-color-accent, #8b5cf6) 0%, transparent 50%)":"var(--nice-color-accent, #6366f1)";return e.jsx("span",{style:{display:"inline-block",width:20,height:20,background:ee,borderRadius:L,boxShadow:V,border:D.buttonStyle==="brutal"?"2px solid var(--nice-border-color, #000)":D.buttonStyle==="outlined"?"2px solid var(--nice-color-primary, #6366f1)":"none",marginRight:6,flexShrink:0}})},[o]);if(y==="dropdown")return e.jsxs("div",{className:`nice-ds-picker nice-ds-picker--dropdown ${m||""}`,style:h,children:[c&&e.jsx("label",{className:"nice-ds-picker__label",children:c}),e.jsxs("button",{type:"button",className:`nice-ds-picker__trigger nice-ds-picker__trigger--${a}`,onClick:()=>g?v(!1):k(),onKeyDown:_,role:"combobox","aria-expanded":g,"aria-haspopup":"listbox","aria-controls":g?T:void 0,"aria-activedescendant":g&&w[S]?`${T}-${S}`:void 0,children:[P(b),e.jsx("span",{children:w.find(I=>I.name===b)?.label??b}),e.jsx(l.NiceIcon,{name:"chevron-down",size:12,style:{marginLeft:"auto"}})]}),g&&e.jsx("div",{className:"nice-ds-picker__menu",role:"listbox",id:T,children:w.map((I,D)=>e.jsxs("button",{id:`${T}-${D}`,type:"button",role:"option",tabIndex:-1,"aria-selected":I.name===b,className:`nice-ds-picker__option ${I.name===b?"nice-ds-picker__option--active":""} ${D===S?"nice-ds-picker__option--highlighted":""}`,onMouseEnter:()=>N(D),onClick:()=>C(I.name),children:[P(I.name),e.jsx("span",{children:I.label}),s&&e.jsx("span",{className:"nice-ds-picker__desc",children:I.description})]},I.name))})]});const B=y==="pills"?"nice-ds-picker__pills":y==="grid"?"nice-ds-picker__grid":"nice-ds-picker__cards",R=I=>{const D=I.name===b,M={type:"button",role:"radio","aria-checked":D,onClick:()=>C(I.name)};if(y==="pills")return e.jsxs("button",{...M,className:`nice-ds-picker__pill nice-ds-picker__pill--${a} ${D?"nice-ds-picker__pill--active":""}`,title:I.description,children:[P(I.name),e.jsx("span",{children:I.label})]},I.name);if(y==="grid")return e.jsxs("button",{...M,className:`nice-ds-picker__grid-item ${D?"nice-ds-picker__grid-item--active":""}`,children:[P(I.name),e.jsx("span",{className:"nice-ds-picker__grid-label",children:I.label})]},I.name);const O=l.resolveDisplayStyleConfig(I.name);return e.jsxs("button",{...M,className:`nice-ds-picker__card ${D?"nice-ds-picker__card--active":""}`,children:[e.jsx("div",{className:"nice-ds-picker__card-preview",children:P(I.name)}),e.jsxs("div",{className:"nice-ds-picker__card-info",children:[e.jsx("strong",{children:I.label}),s&&e.jsx("span",{className:"nice-ds-picker__desc",children:I.description}),e.jsxs("div",{className:"nice-ds-picker__card-meta",children:[e.jsx("span",{title:x("displayStyle.density","Density"),children:O.density}),e.jsx("span",{title:x("displayStyle.buttons","Buttons"),children:O.buttonStyle}),e.jsx("span",{title:x("displayStyle.inputs","Inputs"),children:O.inputStyle})]})]})]},I.name)};return e.jsxs("div",{className:`nice-ds-picker nice-ds-picker--${y} ${m||""}`,style:h,"data-testid":u,children:[c&&e.jsx("label",{className:"nice-ds-picker__label",children:c}),e.jsx("div",{ref:E,className:B,role:"radiogroup","aria-label":c||x("displayStyle.label","Display Style"),children:w.map(R)})]})};process.env.NODE_ENV!=="production"&&(Bu.displayName="NiceDisplayStylePicker");function hw(t,n){if(typeof t=="number")return n.includes("opacity")||n.includes("alpha")?"opacity":n.includes("weight")?"fontWeight":n.includes("duration")||n.includes("delay")?"duration":"dimension";const i=String(t).toLowerCase();return(i.startsWith("#")||i.startsWith("rgb")||i.startsWith("hsl")||i.startsWith("var(--"))&&(n.includes("color")||n.includes("background")||n.includes("border")||n.includes("shadow")||n.includes("text")||n.includes("fill")||n.includes("stroke"))?"color":i.includes("box-shadow")||i.includes("px")&&i.includes("rgba")?"shadow":n.includes("family")||n.includes("font")&&i.includes(",")?"fontFamily":n.includes("weight")?"fontWeight":n.includes("size")&&n.includes("font")?"fontSize":n.includes("line")&&n.includes("height")?"lineHeight":n.includes("letter")||n.includes("tracking")?"letterSpacing":n.includes("radius")?"borderRadius":n.includes("border")&&n.includes("width")?"borderWidth":n.includes("duration")||n.includes("delay")||i.endsWith("ms")||i.endsWith("s")?"duration":i.includes("cubic-bezier")||n.includes("easing")||n.includes("timing")?"cubicBezier":n.includes("spacing")||n.includes("gap")||n.includes("margin")||n.includes("padding")?"spacing":/^\d+(\.\d+)?(px|rem|em|%|vh|vw)$/.test(i)?"dimension":"other"}function Fu(t,n={}){const{prefix:i="ntd"}=n,a={};function s(o,c,d){if(o!=null)if(typeof o=="object"&&!Array.isArray(o))for(const[p,m]of Object.entries(o))s(m,[...c,p],d);else{const p=`${i}-${c.join("-")}`,m=String(o),h=hw(m,c.join("-"));a[p]={value:m,type:h,category:d,cssProperty:`--${p}`}}}return t.colors&&s(t.colors,["color"],"colors"),t.backgrounds&&s(t.backgrounds,["bg"],"backgrounds"),t.text&&s(t.text,["text"],"typography"),t.borders&&s(t.borders,["border"],"borders"),t.shadows&&s(t.shadows,["shadow"],"shadows"),t.spacing&&s(t.spacing,["spacing"],"spacing"),t.typography&&s(t.typography,["font"],"typography"),t.transitions&&s(t.transitions,["transition"],"motion"),a}function gw(t,n={}){const{includeDescriptions:i=!0,minify:a=!1}=n,s=[],o=a?"":`
|
|
2795
2800
|
`,c=a?"":" ";s.push(":root {");for(const[d,p]of Object.entries(t))i&&p.description&&!a&&s.push(`${c}/* ${p.description} */`),s.push(`${c}--${d}: ${p.value};`);return s.push("}"),s.join(o)}function bw(t,n={}){const{includeDescriptions:i=!0}=n,a=[];a.push("// Nice2Dev Design Tokens"),a.push("// Generated automatically - do not edit"),a.push("");const s=qu(t);for(const[o,c]of Object.entries(s)){a.push(`// ${o.charAt(0).toUpperCase()+o.slice(1)}`);for(const[d,p]of Object.entries(c))i&&p.description&&a.push(`// ${p.description}`),a.push(`$${d}: ${p.value};`);a.push("")}a.push("// CSS Custom Properties map"),a.push("$ntd-tokens: (");for(const[o,c]of Object.entries(t))a.push(` '${o}': ${c.value},`);return a.push(");"),a.join(`
|
|
2796
2801
|
`)}function fw(t,n={}){const{includeDescriptions:i=!0}=n,a=[];a.push("// Nice2Dev Design Tokens"),a.push("// Generated automatically - do not edit"),a.push("");for(const[s,o]of Object.entries(t))i&&o.description&&a.push(`// ${o.description}`),a.push(`@${s}: ${o.value};`);return a.join(`
|
|
2797
2802
|
`)}function vw(t,n={}){const{includeTypes:i=!0,minify:a=!1}=n,s={};for(const[o,c]of Object.entries(t))i?s[o]={value:c.value,type:c.type,...c.description&&{description:c.description},...c.category&&{category:c.category}}:s[o]=c.value;return JSON.stringify(s,null,a?0:2)}function xw(t,n={}){const{minify:i=!1}=n,a={};for(const[s,o]of Object.entries(t)){const c=s.split("-");let d=a;for(let m=0;m<c.length-1;m++){const h=c[m];d[h]||(d[h]={}),d=d[h]}const p=c[c.length-1];d[p]={$value:o.value,$type:o.type,...o.description&&{$description:o.description}}}return JSON.stringify(a,null,i?0:2)}function yw(t,n={}){const i={},a={},s={},o={},c={},d={},p={},m={},h={};for(const[x,f]of Object.entries(t)){const b=x.replace(/^ntd-/,"").replace(/-/g,"."),g=`var(--${x})`;switch(f.type){case"color":i[b]=g;break;case"spacing":case"dimension":(x.includes("spacing")||x.includes("gap"))&&(a[b]=g);break;case"borderRadius":s[b]=g;break;case"shadow":o[b]=String(f.value);break;case"fontFamily":c[b]=String(f.value);break;case"fontSize":d[b]=g;break;case"fontWeight":p[b]=String(f.value);break;case"duration":m[b]=String(f.value);break;case"cubicBezier":h[b]=String(f.value);break}}return`// Nice2Dev Tailwind Config Extension
|