@nice2dev/ui-platform 1.2.2 → 1.3.1
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/dist/index.cjs +1 -1
- package/dist/index.mjs +605 -588
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var Ct=Object.defineProperty;var kt=(s,g,c)=>g in s?Ct(s,g,{enumerable:!0,configurable:!0,writable:!0,value:c}):s[g]=c;var ue=(s,g,c)=>kt(s,typeof g!="symbol"?g+"":g,c);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),ae=require("@nice2dev/ui-core"),e=require("react"),fe=e.createContext(null),St=()=>{const s=e.useContext(fe);if(!s)throw new Error("useAutoStart must be used within NiceAutoStartProvider");return s},Nt={showSplash:!0,splashDuration:2e3,autoHideSplash:!0,showProgress:!0,showTaskNames:!0,globalTimeout:6e4,autoRecovery:!0,recoveryAttempts:3,recoveryDelay:2e3,checkUpdates:!1,sendAnalytics:!1},De=Object.assign(e.forwardRef((s,g)=>{const{t:c}=ae.useNiceTranslation(),{tasks:w=[],config:N,splash:x,errorScreen:A,onComplete:G,onTaskComplete:C,onError:D,onRecovery:a,children:y}=s,E={...Nt,...N},f=e.useRef(0),m=e.useRef(w),I=e.useRef(null),[F,B]=e.useState(E.showSplash),[$,Y]=e.useState({phase:"initializing",isLoading:!0,isReady:!1,hasError:!1,progress:0,completedTasks:0,totalTasks:w.length,results:[],recoveryAttempt:0,totalDuration:0}),H=e.useCallback(async r=>{const d=Date.now();let n=0;const l=async()=>{try{const o=r.timeout||E.globalTimeout,h=new Promise((v,b)=>{setTimeout(()=>b(new Error("Task timeout")),o)});return await Promise.race([r.execute(),h]),{taskId:r.id,success:!0,duration:Date.now()-d,retriesUsed:n}}catch(o){const h=r.retries??0;return n<h?(n++,await new Promise(v=>setTimeout(v,500)),l()):{taskId:r.id,success:!1,error:o instanceof Error?o:new Error(String(o)),duration:Date.now()-d,retriesUsed:n}}};return l()},[E.globalTimeout]),X=e.useCallback(r=>{const d=[],n=[...r],l=new Set;for(;n.length>0;){const o=n.filter(v=>v.dependencies?v.dependencies.every(b=>l.has(b)):!0);if(o.length===0){d.push(...n);break}o.sort((v,b)=>(b.priority??0)-(v.priority??0));const h=o[0];d.push(h),l.add(h.id),n.splice(n.indexOf(h),1)}return d},[]),O=e.useCallback(async()=>{f.current=Date.now();const r=new AbortController;I.current=r;const d=X(m.current),n=[];Y(o=>({...o,phase:"loading",isLoading:!0,isReady:!1,hasError:!1,errorMessage:void 0,progress:0,completedTasks:0,totalTasks:d.length,results:[]}));for(let o=0;o<d.length;o++){if(r.signal.aborted)return;const h=d[o];Y(b=>({...b,currentTask:h.name,progress:Math.round(o/d.length*100)}));const v=await H(h);if(r.signal.aborted)return;if(n.push(v),Y(b=>({...b,completedTasks:o+1,results:[...b.results,v]})),C==null||C(v),!v.success&&h.critical){const b=v.error||new Error("Critical task failed");D==null||D(b,h.id),Y(k=>({...k,phase:"error",isLoading:!1,hasError:!0,errorMessage:b.message}));return}}const l=Date.now()-f.current;if(Y(o=>({...o,phase:"ready",isLoading:!1,isReady:!0,currentTask:void 0,progress:100,totalDuration:l})),G==null||G(n),E.autoHideSplash){const o=Date.now()-f.current,h=Math.max(0,E.splashDuration-o);setTimeout(()=>{B(!1)},h)}},[X,H,E.autoHideSplash,E.splashDuration,C,D,G]),z=e.useCallback(async()=>{I.current&&I.current.abort(),Y(r=>({...r,recoveryAttempt:0})),B(E.showSplash),await O()},[E.showSplash,O]),T=e.useCallback(()=>{I.current&&I.current.abort(),Y(r=>({...r,phase:"ready",isLoading:!1,isReady:!0,progress:100})),B(!1)},[]),M=e.useCallback(()=>{B(!1)},[]),j=e.useCallback(async()=>{const r=$.recoveryAttempt+1;r>E.recoveryAttempts||(Y(d=>({...d,phase:"recovery",recoveryAttempt:r})),a==null||a(r),await new Promise(d=>setTimeout(d,E.recoveryDelay)),await O())},[$.recoveryAttempt,E.recoveryAttempts,E.recoveryDelay,a,O]),S=e.useCallback(r=>{m.current=[...m.current,r]},[]),P=e.useCallback(r=>{m.current=m.current.filter(d=>d.id!==r)},[]),W=e.useCallback(r=>$.results.find(d=>d.taskId===r),[$.results]);e.useEffect(()=>{$.hasError&&E.autoRecovery&&$.recoveryAttempt<E.recoveryAttempts&&j()},[$.hasError,E.autoRecovery,E.recoveryAttempts,$.recoveryAttempt,j]),e.useEffect(()=>(O(),()=>{I.current&&I.current.abort()}),[]),e.useImperativeHandle(g,()=>({getState:()=>$,restart:z,skip:T,addTask:S,removeTask:P,getTaskResult:W,hideSplash:M,recover:j}),[$,z,T,S,P,W,M,j]);const i={...$,restart:z,skip:T,hideSplash:M};return $.hasError&&$.recoveryAttempt>=E.recoveryAttempts?t.jsx(fe.Provider,{value:i,children:A||t.jsxs("div",{className:"nice-auto-start__error",children:[t.jsx("div",{className:"nice-auto-start__error-icon","aria-hidden":"true",children:t.jsx("span",{className:"nice-platform-mark nice-platform-mark--alert"})}),t.jsx("h2",{className:"nice-auto-start__error-title",children:c("autoStart.startupFailed","Startup Failed")}),t.jsx("p",{className:"nice-auto-start__error-message",children:$.errorMessage}),t.jsx("button",{className:"nice-auto-start__error-retry",onClick:z,children:c("autoStart.retry","Retry")})]})}):F&&!$.isReady?t.jsx(fe.Provider,{value:i,children:x||t.jsx("div",{className:"nice-auto-start__splash",children:t.jsxs("div",{className:"nice-auto-start__splash-content",children:[t.jsx("div",{className:"nice-auto-start__splash-logo","aria-hidden":"true"}),t.jsx("h1",{className:"nice-auto-start__splash-title",children:c("autoStart.loading","Loading...")}),E.showProgress&&t.jsx("div",{className:"nice-auto-start__splash-progress",children:t.jsx("div",{className:"nice-auto-start__splash-progress-bar",style:{width:`${$.progress}%`}})}),E.showTaskNames&&$.currentTask&&t.jsx("div",{className:"nice-auto-start__splash-task",children:$.currentTask}),$.phase==="recovery"&&t.jsx("div",{className:"nice-auto-start__splash-recovery",children:c("autoStart.recoveryAttemptOf","Recovery attempt {recoveryAttempt} of {recoveryAttempts}").replace("{recoveryAttempt}",String($.recoveryAttempt)).replace("{recoveryAttempts}",String(E.recoveryAttempts))})]})})}):t.jsx(fe.Provider,{value:i,children:y})}),{displayName:"NiceAutoStart"}),Ae=De;process.env.NODE_ENV!=="production"&&(Ae.displayName="NiceAutoStartProvider");const Ee=e.createContext(null),Le=()=>{const s=e.useContext(Ee);if(!s)throw new Error("useExternalDisplay must be used within NiceExternalDisplayProvider");return s},_t={autoDetect:!0,pollInterval:2e3,defaultFeatures:{resizable:!0,scrollbars:!0},allowMultiWindow:!0,syncContent:!1},It=()=>typeof window>"u"?!1:"getScreenDetails"in window,jt=()=>`window-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,Dt=s=>{const g=[];return s.width!==void 0&&g.push(`width=${s.width}`),s.height!==void 0&&g.push(`height=${s.height}`),s.left!==void 0&&g.push(`left=${s.left}`),s.top!==void 0&&g.push(`top=${s.top}`),s.menubar!==void 0&&g.push(`menubar=${s.menubar?"yes":"no"}`),s.toolbar!==void 0&&g.push(`toolbar=${s.toolbar?"yes":"no"}`),s.location!==void 0&&g.push(`location=${s.location?"yes":"no"}`),s.status!==void 0&&g.push(`status=${s.status?"yes":"no"}`),s.resizable!==void 0&&g.push(`resizable=${s.resizable?"yes":"no"}`),s.scrollbars!==void 0&&g.push(`scrollbars=${s.scrollbars?"yes":"no"}`),g.join(",")},he="Primary Display";function we(s,g){if(s.id==="primary"&&s.label===he)return g("externalDisplay.primaryDisplay",he);const c=/^Display (\d+)$/.exec(s.label);return c?g("externalDisplay.displayN","Display {n}").replace("{n}",c[1]):s.label}const xe=()=>{var g;if(typeof window>"u")return{id:"primary",label:he,width:0,height:0,availWidth:0,availHeight:0,left:0,top:0,devicePixelRatio:1,isPrimary:!0,orientation:"landscape-primary",colorDepth:24};const s=window.screen;return{id:"primary",label:he,width:s.width,height:s.height,availWidth:s.availWidth,availHeight:s.availHeight,left:s.availLeft||0,top:s.availTop||0,devicePixelRatio:window.devicePixelRatio,isPrimary:!0,orientation:((g=s.orientation)==null?void 0:g.type)||"landscape-primary",colorDepth:s.colorDepth}},At=async()=>{try{return(await navigator.permissions.query({name:"window-management"})).state}catch{return"unknown"}},Ce=async()=>(await window.getScreenDetails()).screens.map((g,c)=>{var w;return{id:`screen-${c}`,label:g.label||`Display ${c+1}`,width:g.width,height:g.height,availWidth:g.availWidth,availHeight:g.availHeight,left:g.left,top:g.top,devicePixelRatio:g.devicePixelRatio,isPrimary:g.isPrimary,isInternal:g.isInternal,orientation:((w=g.orientation)==null?void 0:w.type)||"landscape-primary",colorDepth:g.colorDepth}}),ke=(s,g)=>JSON.stringify(s)===JSON.stringify(g),Pe=Object.assign(e.forwardRef((s,g)=>{const{config:c,onScreensChange:w,onWindowOpen:N,onWindowClose:x,onPermissionChange:A,children:G}=s,C={..._t,...c},D=e.useRef(new Map),a=e.useRef(null),[y,E]=e.useState([xe()]),[f,m]=e.useState([]),[I,F]=e.useState("unknown"),[B]=e.useState(It),$=e.useRef(w),Y=e.useRef(A);e.useEffect(()=>{$.current=w,Y.current=A});const H=e.useRef([]),X=e.useCallback(o=>{var h;E(v=>ke(v,o)?v:o),ke(H.current,o)||(H.current=o,(h=$.current)==null||h.call($,o))},[]),O=e.useRef("unknown"),z=e.useCallback(o=>{var h;O.current!==o&&(O.current=o,F(o),(h=Y.current)==null||h.call(Y,o))},[]),T=e.useCallback(async()=>{if(B){const h=await At();if(z(h),h==="granted")try{const v=await Ce();return X(v),v}catch{}}const o=[xe()];return X(o),o},[B,z,X]),M=e.useCallback(async()=>{if(!B)return z("denied"),!1;try{return X(await Ce()),z("granted"),!0}catch(o){return z(o instanceof DOMException&&o.name==="NotAllowedError"?"denied":"unknown"),!1}},[B,z,X]),j=e.useCallback(async(o,h="about:blank",v={})=>{if(!C.allowMultiWindow&&f.length>0)return console.warn("Multi-window mode is disabled"),null;const b=jt(),k={...C.defaultFeatures,...v,width:v.width??o.availWidth,height:v.height??o.availHeight,left:v.left??o.left,top:v.top??o.top},u=Dt(k),p={window:null,screen:o,id:b,state:"opening",isFullscreen:!1,features:k};m(R=>[...R,p]);try{const R=window.open(h,b,u);if(!R)return m(L=>L.map(q=>q.id===b?{...q,state:"error"}:q)),null;D.current.set(b,R);const K={...p,window:R,state:"open"};m(L=>L.map(q=>q.id===b?K:q));const _=setInterval(()=>{R.closed&&(clearInterval(_),D.current.delete(b),m(L=>L.filter(q=>q.id!==b)),x==null||x(K))},500);return k.fullscreen&&R.addEventListener("load",()=>{var L,q;(q=(L=R.document.documentElement).requestFullscreen)==null||q.call(L)}),N==null||N(K),K}catch(R){return console.error("Failed to open window:",R),m(K=>K.map(_=>_.id===b?{..._,state:"error"}:_)),null}},[C.allowMultiWindow,C.defaultFeatures,f.length,N,x]),S=e.useCallback(o=>{const h=D.current.get(o);h&&!h.closed&&h.close(),D.current.delete(o),m(v=>v.filter(b=>b.id!==o))},[]),P=e.useCallback(()=>{for(const[o,h]of D.current)h.closed||h.close(),D.current.delete(o);m([])},[]),W=e.useCallback((o,h)=>{const v=D.current.get(o);v&&!v.closed&&(v.moveTo(h.left,h.top),v.resizeTo(h.availWidth,h.availHeight),m(b=>b.map(k=>k.id===o?{...k,screen:h}:k)))},[]),i=e.useCallback(async o=>{const h=D.current.get(o);if(!h||h.closed)return!1;try{const v=!!h.document.fullscreenElement;return v?await h.document.exitFullscreen():await h.document.documentElement.requestFullscreen(),m(b=>b.map(k=>k.id===o?{...k,isFullscreen:!v}:k)),!0}catch{return!1}},[]),r=e.useCallback((o,h)=>{const v=D.current.get(o);v&&!v.closed&&v.postMessage(h,"*")},[]),d=e.useCallback(o=>{for(const h of D.current.values())h.closed||h.postMessage(o,"*")},[]);e.useEffect(()=>{C.autoDetect&&T()},[C.autoDetect,T]),e.useEffect(()=>(C.autoDetect&&C.pollInterval>0&&(a.current=setInterval(T,C.pollInterval)),()=>{a.current&&clearInterval(a.current)}),[C.autoDetect,C.pollInterval,T]),e.useEffect(()=>{if(!B)return;const o=()=>{T()};return window.addEventListener("screenschange",o),()=>{window.removeEventListener("screenschange",o)}},[B,T]),e.useEffect(()=>()=>{P()},[P]);const n=e.useMemo(()=>({screens:y,primaryScreen:y.find(o=>o.isPrimary)||null,externalScreens:y.filter(o=>!o.isPrimary),windows:f,isApiAvailable:B,permissionState:I}),[y,f,B,I]);e.useImperativeHandle(g,()=>({getState:()=>n,requestPermission:M,getScreens:T,openWindow:j,closeWindow:S,closeAllWindows:P,moveWindowToScreen:W,toggleFullscreen:i,sendMessage:r,broadcast:d}),[n,M,T,j,S,P,W,i,r,d]);const l={...n,requestPermission:M,openWindow:j,closeWindow:S,moveWindowToScreen:W};return t.jsx(Ee.Provider,{value:l,children:t.jsx("div",{className:"nice-external-display",children:G})})}),{displayName:"NiceExternalDisplay"}),Re=Pe;process.env.NODE_ENV!=="production"&&(Re.displayName="NiceExternalDisplayProvider");const Oe=({onSelect:s,selectedId:g,showPreview:c=!0,className:w})=>{const{t:N}=ae.useNiceTranslation(),{screens:x,primaryScreen:A}=Le(),G=y=>{s==null||s(y)},D=(()=>{let y=0,E=0,f=0,m=0;for(const I of x)y=Math.min(y,I.left),E=Math.min(E,I.top),f=Math.max(f,I.left+I.width),m=Math.max(m,I.top+I.height);return{minX:y,minY:E,maxX:f,maxY:m,width:f-y,height:m-E}})(),a=Math.min(280/D.width,160/D.height,1);return t.jsxs("div",{className:`nice-screen-selector ${w||""}`,children:[c&&t.jsx("div",{className:"nice-screen-selector__preview",style:{width:D.width*a,height:D.height*a},children:x.map(y=>t.jsx("button",{className:`nice-screen-selector__screen ${g===y.id?"nice-screen-selector__screen--selected":""} ${y.isPrimary?"nice-screen-selector__screen--primary":""}`,style:{left:(y.left-D.minX)*a,top:(y.top-D.minY)*a,width:y.width*a,height:y.height*a},onClick:()=>G(y),title:we(y,N),children:t.jsx("span",{className:"nice-screen-selector__screen-label",children:y.isPrimary?"P":x.indexOf(y)+1})},y.id))}),t.jsx("div",{className:"nice-screen-selector__list",children:x.map(y=>t.jsxs("button",{className:`nice-screen-selector__item ${g===y.id?"nice-screen-selector__item--selected":""}`,onClick:()=>G(y),children:[t.jsx("span",{className:"nice-screen-selector__item-name",children:we(y,N)}),t.jsxs("span",{className:"nice-screen-selector__item-resolution",children:[y.width," × ",y.height]}),y.isPrimary&&t.jsx("span",{className:"nice-screen-selector__item-badge",children:N("externalDisplay.primary","Primary")})]},y.id))})]})};process.env.NODE_ENV!=="production"&&(Oe.displayName="NiceScreenSelector");const Te=e.createContext(null),Et=()=>{const s=e.useContext(Te);if(!s)throw new Error("useKioskMode must be used within NiceKioskModeProvider");return s},Lt={autoFullscreen:!0,lockNavigation:!0,disableContextMenu:!0,disableShortcuts:!0,disableSelection:!0,disableCopyPaste:!0,exitPin:"1234",exitShortcut:"ctrl+shift+k",adminTapCount:5,adminTapTimeout:2e3,inactivityTimeout:300*1e3,showCursor:!0,allowScrolling:!0,className:""},Me=Object.assign(e.forwardRef((s,g)=>{const{t:c}=ae.useNiceTranslation(),{config:w,children:N,screensaver:x,adminPanel:A,onModeChange:G,onFullscreenChange:C,onAdminAccess:D,onInactivity:a,onActivity:y,onExitRequest:E}=s,f={...Lt,...w},m=e.useRef(null),I=e.useRef(null),F=e.useRef({count:0,timer:null}),[B,$]=e.useState({mode:"windowed",isFullscreen:!1,isLocked:!1,isAdminMode:!1,isScreensaverActive:!1,idleTime:0,isPinDialogOpen:!1}),[Y,H]=e.useState(""),[X,O]=e.useState(!1),z=e.useCallback(async()=>{const u=m.current;if(u)try{u.requestFullscreen?await u.requestFullscreen():u.webkitRequestFullscreen?await u.webkitRequestFullscreen():u.msRequestFullscreen&&await u.msRequestFullscreen()}catch(p){console.warn("Failed to enter fullscreen:",p)}},[]),T=e.useCallback(async()=>{try{document.exitFullscreen?await document.exitFullscreen():document.webkitExitFullscreen?await document.webkitExitFullscreen():document.msExitFullscreen&&await document.msExitFullscreen()}catch(u){console.warn("Failed to exit fullscreen:",u)}},[]),M=e.useCallback(async()=>{B.isFullscreen?await T():await z()},[B.isFullscreen,z,T]),j=e.useCallback(()=>{$(u=>({...u,mode:"locked",isLocked:!0,isAdminMode:!1})),G==null||G("locked")},[G]),S=e.useCallback(u=>f.exitPin&&u!==f.exitPin?(O(!0),setTimeout(()=>O(!1),1e3),!1):($(p=>({...p,mode:p.isFullscreen?"fullscreen":"windowed",isLocked:!1,isPinDialogOpen:!1})),H(""),!0),[f.exitPin]),P=e.useCallback(()=>{$(u=>({...u,isAdminMode:!0})),D==null||D()},[D]),W=e.useCallback(()=>{$(u=>({...u,isAdminMode:!1}))},[]),i=e.useCallback(()=>{F.current.timer&&clearTimeout(F.current.timer),F.current.count++,F.current.count>=f.adminTapCount?(F.current.count=0,P()):F.current.timer=setTimeout(()=>{F.current.count=0},f.adminTapTimeout)},[f.adminTapCount,f.adminTapTimeout,P]),r=e.useCallback(()=>{I.current&&clearTimeout(I.current),B.isScreensaverActive&&($(u=>({...u,isScreensaverActive:!1})),y==null||y()),f.inactivityTimeout>0&&(I.current=setTimeout(()=>{$(u=>({...u,isScreensaverActive:!0})),a==null||a()},f.inactivityTimeout))},[f.inactivityTimeout,B.isScreensaverActive,y,a]),d=e.useCallback(()=>{$(u=>({...u,isScreensaverActive:!0}))},[]),n=e.useCallback(()=>{$(u=>({...u,isScreensaverActive:!1})),r()},[r]),l=e.useCallback(()=>{$(u=>({...u,isPinDialogOpen:!0})),H(""),O(!1)},[]),o=e.useCallback(()=>{$(u=>({...u,isPinDialogOpen:!1})),H(""),O(!1)},[]),h=e.useCallback(()=>{S(Y)},[Y,S]),v=e.useCallback(u=>{u.key==="Enter"&&h()},[h]);e.useEffect(()=>{const u=()=>{const p=!!document.fullscreenElement;$(R=>({...R,mode:R.isLocked?"locked":p?"fullscreen":"windowed",isFullscreen:p})),C==null||C(p)};return document.addEventListener("fullscreenchange",u),document.addEventListener("webkitfullscreenchange",u),()=>{document.removeEventListener("fullscreenchange",u),document.removeEventListener("webkitfullscreenchange",u)}},[C]),e.useEffect(()=>{if(!f.disableContextMenu)return;const u=p=>{B.isAdminMode||p.preventDefault()};return document.addEventListener("contextmenu",u),()=>document.removeEventListener("contextmenu",u)},[f.disableContextMenu,B.isAdminMode]),e.useEffect(()=>{const u=async p=>{const K=f.exitShortcut.toLowerCase().split("+"),_=K.includes("ctrl")===p.ctrlKey,L=K.includes("shift")===p.shiftKey,q=K.includes("alt")===p.altKey,V=K.some(Q=>Q===p.key.toLowerCase());if(_&&L&&q&&V){p.preventDefault(),(E?await E("keyboard"):!0)&&(B.isLocked?l():T());return}if(f.disableShortcuts&&!B.isAdminMode){const Q=["F5","F11","F12"],te=[{ctrl:!0,key:"r"},{ctrl:!0,key:"w"},{ctrl:!0,key:"n"},{ctrl:!0,key:"t"},{ctrl:!0,shift:!0,key:"i"},{ctrl:!0,shift:!0,key:"j"},{alt:!0,key:"F4"}];if(Q.includes(p.key)){p.preventDefault();return}for(const Z of te)if(Z.ctrl===p.ctrlKey&&(Z.shift??!1)===p.shiftKey&&(Z.alt??!1)===p.altKey&&Z.key.toLowerCase()===p.key.toLowerCase()){p.preventDefault();return}}};return document.addEventListener("keydown",u),()=>document.removeEventListener("keydown",u)},[f.disableShortcuts,f.exitShortcut,B.isAdminMode,B.isLocked,T,l,E]),e.useEffect(()=>{if(!f.disableCopyPaste)return;const u=R=>{B.isAdminMode||R.preventDefault()},p=R=>{B.isAdminMode||R.preventDefault()};return document.addEventListener("copy",u),document.addEventListener("paste",p),()=>{document.removeEventListener("copy",u),document.removeEventListener("paste",p)}},[f.disableCopyPaste,B.isAdminMode]),e.useEffect(()=>{const u=["mousedown","mousemove","keydown","touchstart","scroll"],p=()=>{r()};for(const R of u)document.addEventListener(R,p);return r(),()=>{for(const R of u)document.removeEventListener(R,p);I.current&&clearTimeout(I.current)}},[r]),e.useEffect(()=>{if(f.autoFullscreen){const u=setTimeout(()=>{z()},100);return()=>clearTimeout(u)}},[f.autoFullscreen,z]),e.useImperativeHandle(g,()=>({getState:()=>B,enterFullscreen:z,exitFullscreen:T,toggleFullscreen:M,lock:j,unlock:S,enterAdminMode:P,exitAdminMode:W,resetIdleTimer:r,showScreensaver:d,hideScreensaver:n,openPinDialog:l,closePinDialog:o}),[B,z,T,M,j,S,P,W,r,d,n,l,o]);const b={...B,enterFullscreen:z,exitFullscreen:T,toggleFullscreen:M,lock:j,unlock:S,enterAdminMode:P,exitAdminMode:W,resetIdleTimer:r},k=["nice-kiosk-mode",`nice-kiosk-mode--${B.mode}`,B.isFullscreen&&"nice-kiosk-mode--fullscreen",!f.showCursor&&"nice-kiosk-mode--no-cursor",f.disableSelection&&"nice-kiosk-mode--no-select",!f.allowScrolling&&"nice-kiosk-mode--no-scroll",f.className].filter(Boolean).join(" ");return t.jsx(Te.Provider,{value:b,children:t.jsxs("div",{ref:m,className:k,onClick:i,children:[t.jsx("div",{className:"nice-kiosk-mode__content",children:N}),B.isAdminMode&&A&&t.jsxs("div",{className:"nice-kiosk-mode__admin",children:[t.jsxs("div",{className:"nice-kiosk-mode__admin-header",children:[t.jsx("h2",{className:"nice-kiosk-mode__admin-title",children:c("kioskMode.adminMode","Admin Mode")}),t.jsx("button",{className:"nice-kiosk-mode__admin-close",onClick:W,"aria-label":c("kioskMode.closeAdminPanel","Close admin panel"),children:t.jsx("span",{className:"nice-platform-mark nice-platform-mark--close","aria-hidden":"true"})})]}),t.jsx("div",{className:"nice-kiosk-mode__admin-content",children:A})]}),B.isScreensaverActive&&t.jsx("div",{className:"nice-kiosk-mode__screensaver",onClick:n,onTouchStart:n,children:x||t.jsx("div",{className:"nice-kiosk-mode__screensaver-default",children:t.jsx("div",{className:"nice-kiosk-mode__screensaver-text",children:c("kioskMode.touchToContinue","Touch to continue")})})}),B.isPinDialogOpen&&t.jsx("div",{className:"nice-kiosk-mode__pin-overlay",children:t.jsxs("div",{className:"nice-kiosk-mode__pin-dialog",children:[t.jsx("h3",{className:"nice-kiosk-mode__pin-title",children:c("kioskMode.enterPin","Enter PIN")}),t.jsx("input",{type:"password",className:`nice-kiosk-mode__pin-input ${X?"nice-kiosk-mode__pin-input--error":""}`,value:Y,onChange:u=>H(u.target.value),onKeyPress:v,maxLength:8,autoFocus:!0,placeholder:"••••"}),t.jsxs("div",{className:"nice-kiosk-mode__pin-buttons",children:[t.jsx("button",{className:"nice-kiosk-mode__pin-btn nice-kiosk-mode__pin-btn--cancel",onClick:o,children:c("kioskMode.cancel","Cancel")}),t.jsx("button",{className:"nice-kiosk-mode__pin-btn nice-kiosk-mode__pin-btn--submit",onClick:h,children:c("kioskMode.unlock","Unlock")})]}),X&&t.jsx("div",{className:"nice-kiosk-mode__pin-error",children:c("kioskMode.incorrectPin","Incorrect PIN")})]})}),B.isLocked&&!B.isPinDialogOpen&&t.jsx("div",{className:"nice-kiosk-mode__lock-indicator",children:t.jsx("span",{className:"nice-kiosk-mode__lock-text",children:c("kioskMode.kioskLocked","Kiosk Locked")})})]})})}),{displayName:"NiceKioskMode"}),Fe=Me;process.env.NODE_ENV!=="production"&&(Fe.displayName="NiceKioskModeProvider");const Be=e.createContext(null),Pt=()=>{const s=e.useContext(Be);if(!s)throw new Error("useLowPowerMode must be used within NiceLowPowerModeProvider");return s},Rt={normal:{mode:"normal",brightness:1,wakeOnTouch:!0},dim:{mode:"dim",brightness:.6,disableAnimations:!1,wakeOnTouch:!0},low:{mode:"low",brightness:.3,frameRateCap:30,disableAnimations:!0,reduceImageQuality:!0,wakeOnTouch:!0},sleep:{mode:"sleep",brightness:0,frameRateCap:1,disableAnimations:!0,disableBackgroundProcesses:!0,reduceImageQuality:!0,wakeOnTouch:!0,wakeOnMotion:!0}},Ot={initialMode:"normal",autoDimTimeout:120*1e3,autoSleepTimeout:600*1e3,lowBatteryThreshold:20,criticalBatteryThreshold:5,wakeOnTouch:!0,wakeOnMotion:!1,transitionDuration:500},$e=Object.assign(e.forwardRef((s,g)=>{const{t:c}=ae.useNiceTranslation(),{config:w,onModeChange:N,onBrightnessChange:x,onSleep:A,onWake:G,onLowBattery:C,children:D}=s,a={...Ot,...w},y=JSON.stringify((w==null?void 0:w.modes)??null),E=e.useMemo(()=>({...Rt,...JSON.parse(y)}),[y]),f=e.useRef(null),m=e.useRef(null),I=e.useRef(Date.now()),F=e.useRef(null),[B,$]=e.useState({currentMode:a.initialMode,brightness:E[a.initialMode].brightness??1,isPowerSaving:a.initialMode!=="normal",isSleeping:a.initialMode==="sleep",idleTime:0,isDisplayOn:!0}),Y=e.useRef(B);Y.current=B;const H=e.useRef({onModeChange:N,onBrightnessChange:x,onSleep:A,onWake:G});H.current={onModeChange:N,onBrightnessChange:x,onSleep:A,onWake:G};const X=e.useCallback(n=>{const l=E[n];document.documentElement.style.setProperty("--lpm-brightness",String(l.brightness)),document.documentElement.style.setProperty("--lpm-transition",`${a.transitionDuration}ms`),l.disableAnimations?document.documentElement.classList.add("nice-lpm-no-animations"):document.documentElement.classList.remove("nice-lpm-no-animations"),l.reduceImageQuality?document.documentElement.classList.add("nice-lpm-reduced-quality"):document.documentElement.classList.remove("nice-lpm-reduced-quality")},[E,a.transitionDuration]),O=e.useCallback(n=>{$(l=>{var b,k,u,p;if(l.currentMode===n)return l;const o=l.currentMode,h=E[n];X(n);const v=H.current;return(b=v.onModeChange)==null||b.call(v,n,o),(k=v.onBrightnessChange)==null||k.call(v,h.brightness??1),n==="sleep"&&o!=="sleep"?(u=v.onSleep)==null||u.call(v):o==="sleep"&&n!=="sleep"&&((p=v.onWake)==null||p.call(v)),{...l,currentMode:n,brightness:h.brightness??1,isPowerSaving:n!=="normal",isSleeping:n==="sleep",isDisplayOn:n!=="sleep"}})},[E,X]),z=e.useCallback(n=>{const l=Math.max(0,Math.min(1,n));document.documentElement.style.setProperty("--lpm-brightness",String(l)),$(o=>({...o,brightness:l})),x==null||x(l)},[x]),T=e.useCallback(()=>{O("sleep")},[O]),M=e.useCallback(()=>{I.current=Date.now(),f.current&&clearTimeout(f.current),m.current&&clearTimeout(m.current),a.autoDimTimeout>0&&(f.current=setTimeout(()=>{Y.current.currentMode==="normal"&&O("dim")},a.autoDimTimeout)),a.autoSleepTimeout>0&&(m.current=setTimeout(()=>{O("sleep")},a.autoSleepTimeout)),$(n=>n.idleTime===0?n:{...n,idleTime:0})},[a.autoDimTimeout,a.autoSleepTimeout,O]),j=e.useCallback(()=>{Y.current.currentMode!=="normal"&&O("normal"),M()},[O,M]),S=e.useCallback(()=>{O("normal"),j()},[O,j]),P=e.useCallback(()=>{B.currentMode==="normal"?O("low"):O("normal")},[B.currentMode,O]),W=e.useCallback(async()=>{if(typeof navigator<"u"&&"getBattery"in navigator)try{const n=await navigator.getBattery();return{level:Math.round(n.level*100),charging:n.charging}}catch{return{}}return{}},[]),i=e.useCallback(async()=>{const n=await W();n.level!==void 0&&($(l=>({...l,batteryLevel:n.level,isCharging:n.charging})),n.charging||(n.level<=a.criticalBatteryThreshold?(O("sleep"),C==null||C(n.level)):n.level<=a.lowBatteryThreshold&&(B.currentMode==="normal"&&O("low"),C==null||C(n.level))))},[W,a.lowBatteryThreshold,a.criticalBatteryThreshold,B.currentMode,O,C]),r=e.useCallback(()=>{if(!(w!=null&&w.schedule)||w.schedule.length===0)return;const l=new Date().getHours();for(const o of w.schedule){const{startHour:h,endHour:v,mode:b}=o;let k;if(h<=v?k=l>=h&&l<v:k=l>=h||l<v,k){$(u=>({...u,scheduledModeActive:b})),B.currentMode!==b&&O(b);return}}$(o=>({...o,scheduledModeActive:void 0}))},[w==null?void 0:w.schedule,B.currentMode,O]);e.useEffect(()=>{const n=["mousedown","mousemove","keydown","touchstart","scroll"],l=()=>{a.wakeOnTouch&&j()};for(const o of n)document.addEventListener(o,l);return M(),()=>{for(const o of n)document.removeEventListener(o,l);f.current&&clearTimeout(f.current),m.current&&clearTimeout(m.current)}},[a.wakeOnTouch,j,M]),e.useEffect(()=>{i(),(async()=>{if(typeof navigator<"u"&&"getBattery"in navigator)try{const l=await navigator.getBattery();F.current=l,l.addEventListener("levelchange",i),l.addEventListener("chargingchange",i)}catch{}})()},[i]),e.useEffect(()=>{r();const n=setInterval(r,6e4);return()=>clearInterval(n)},[r]),e.useEffect(()=>{X(a.initialMode)},[a.initialMode,X]),e.useImperativeHandle(g,()=>({getState:()=>B,setMode:O,setBrightness:z,sleep:T,wake:S,togglePowerSaving:P,resetIdleTimer:j,getBatteryInfo:W}),[B,O,z,T,S,P,j,W]);const d={...B,setMode:O,setBrightness:z,sleep:T,wake:S,resetIdleTimer:j};return t.jsx(Be.Provider,{value:d,children:t.jsxs("div",{className:`nice-lpm nice-lpm--${B.currentMode}`,children:[t.jsx("div",{className:"nice-lpm__overlay",style:{opacity:1-B.brightness}}),t.jsx("div",{className:"nice-lpm__content",children:D}),B.isSleeping&&t.jsx("div",{className:"nice-lpm__sleep-screen",onClick:a.wakeOnTouch?S:void 0,onTouchStart:a.wakeOnTouch?S:void 0,children:t.jsx("div",{className:"nice-lpm__sleep-message",children:c("lowPowerMode.touchToWake","Touch to wake")})})]})})}),{displayName:"NiceLowPowerMode"}),qe=$e;process.env.NODE_ENV!=="production"&&(qe.displayName="NiceLowPowerModeProvider");const Ue=e.createContext(null),Tt=()=>{const s=e.useContext(Ue);if(!s)throw new Error("useOrientationLock must be used within NiceOrientationLockProvider");return s},Mt={preferredOrientation:"any",allowUserChange:!0,showRotationPrompt:!0,lockOnMount:!1,autoRotateContent:!1,supportedOrientations:["any","portrait","portrait-primary","portrait-secondary","landscape","landscape-primary","landscape-secondary","natural"]},Ve=()=>{if(typeof window>"u")return"portrait";const s=window.screen;return s.orientation?s.orientation.type:window.innerHeight>window.innerWidth?"portrait":"landscape"},Ft=()=>{if(typeof window>"u")return 0;const s=window.screen;return s.orientation?s.orientation.angle:window.orientation||0},ye=()=>{if(typeof window>"u")return{type:"portrait",angle:0,isPortrait:!0,isLandscape:!1,width:0,height:0,aspectRatio:0};const s=Ve(),g=Ft(),c=window.screen.width,w=window.screen.height,N=s.includes("portrait")||window.innerHeight>window.innerWidth,x=s.includes("landscape")||window.innerWidth>window.innerHeight;return{type:s,angle:g,isPortrait:N,isLandscape:x,width:c,height:w,aspectRatio:c/w}},Bt=()=>{if(typeof window>"u")return!1;const s=window.screen;return!!(s.orientation&&typeof s.orientation.lock=="function")},We=Object.assign(e.forwardRef((s,g)=>{const{t:c}=ae.useNiceTranslation(),{config:w,onOrientationChange:N,onLockChange:x,onUnsupportedOrientation:A,rotationPrompt:G,children:C,className:D}=s,a={...Mt,...w},y=e.useRef(!1),[E,f]=e.useState(Ve),[m,I]=e.useState(null),[F,B]=e.useState(ye),[$]=e.useState(Bt),Y=e.useCallback(i=>!!(a.supportedOrientations.includes("any")||a.supportedOrientations.includes(i)||i.includes("portrait")&&a.supportedOrientations.includes("portrait")||i.includes("landscape")&&a.supportedOrientations.includes("landscape")),[a.supportedOrientations]),H=e.useCallback(async i=>{if(!$)return console.warn("Screen Orientation API is not available"),I(i),x==null||x(!0,i),!1;try{return await window.screen.orientation.lock(i),I(i),x==null||x(!0,i),!0}catch(r){return console.warn("Failed to lock orientation:",r),I(i),x==null||x(!0,i),!1}},[$,x]),X=e.useCallback(async()=>{if(I(null),x==null||x(!1,null),!$)return!1;try{return window.screen.orientation.unlock(),!0}catch(i){return console.warn("Failed to unlock orientation:",i),!1}},[$,x]),O=e.useCallback(async()=>m?X():H(E),[m,E,H,X]),z=e.useCallback(()=>ye(),[]),T=e.useCallback(()=>{const i=ye(),r=i.type;f(r),B(i),N==null||N(i),Y(r)||A==null||A(r,a.supportedOrientations)},[a.supportedOrientations,Y,N,A]);e.useEffect(()=>{y.current||(y.current=!0,T(),a.lockOnMount&&a.preferredOrientation!=="any"&&H(a.preferredOrientation))},[a.lockOnMount,a.preferredOrientation,T,H]),e.useEffect(()=>{const i=window.screen.orientation;return i&&i.addEventListener("change",T),window.addEventListener("resize",T),window.addEventListener("orientationchange",T),()=>{i&&i.removeEventListener("change",T),window.removeEventListener("resize",T),window.removeEventListener("orientationchange",T)}},[T]);const M=e.useMemo(()=>({current:E,locked:m,isLocked:m!==null,isSupported:Y(E),info:F,isApiAvailable:$}),[E,m,F,$,Y]);e.useImperativeHandle(g,()=>({getState:()=>M,lock:H,unlock:X,toggleLock:O,getOrientationInfo:z,isOrientationSupported:Y}),[M,H,X,O,z,Y]);const j={...M,lock:H,unlock:X,getOrientationInfo:z},S=e.useCallback(()=>{if(!a.autoRotateContent||!m||m==="any")return;const i=m.includes("portrait"),r=F.isPortrait;return i===r?void 0:{transform:`rotate(${i?90:-90}deg)`,transformOrigin:"center center",width:i?F.height:F.width,height:i?F.width:F.height}},[a.autoRotateContent,m,F]),P=a.showRotationPrompt&&m!==null&&m!=="any"&&!M.isSupported,W=["nice-orientation",`nice-orientation--${E}`,m&&`nice-orientation--locked-${m}`,!M.isSupported&&"nice-orientation--unsupported",D].filter(Boolean).join(" ");return t.jsx(Ue.Provider,{value:j,children:t.jsxs("div",{className:W,style:S(),"data-orientation":E,"data-locked":m||void 0,children:[C,P&&t.jsx("div",{className:"nice-orientation__prompt",children:G||t.jsxs("div",{className:"nice-orientation__prompt-content",children:[t.jsx("div",{className:"nice-orientation__prompt-icon",children:t.jsx("span",{className:"nice-platform-mark nice-platform-mark--device","aria-hidden":"true"})}),t.jsx("p",{className:"nice-orientation__prompt-text",children:m!=null&&m.includes("portrait")?c("orientationLock.rotateToPortrait","Please rotate your device to portrait mode"):c("orientationLock.rotateToLandscape","Please rotate your device to landscape mode")})]})})]})})}),{displayName:"NiceOrientationLock"}),He=We;process.env.NODE_ENV!=="production"&&(He.displayName="NiceOrientationLockProvider");const ze=e.createContext(null),$t=()=>{const s=e.useContext(ze);if(!s)throw new Error("useRemoteManagement must be used within NiceRemoteManagementProvider");return s},qt={heartbeatInterval:3e4,reconnectDelay:5e3,maxReconnectAttempts:10,enableHealthMonitoring:!0,healthReportInterval:6e4,enableScreenshot:!0,enableLogs:!0,logBufferSize:100},Ge=Object.assign(e.forwardRef((s,g)=>{const{config:c,onConnectionChange:w,onCommandReceived:N,onCustomCommand:x,onCaptureScreenshot:A,children:G}=s,C={...qt,...c},D=e.useRef(null),a=e.useRef(null),y=e.useRef(null),E=e.useRef([]),f=e.useRef(Date.now()),m=e.useRef(0),[I,F]=e.useState({status:"disconnected",isConnected:!1,reconnectAttempts:0,pendingCommands:[],commandHistory:[]}),B=e.useCallback(()=>{const i=typeof navigator<"u"?navigator:null,r=typeof window<"u"?window:null;return{deviceId:C.deviceId,name:C.deviceName||C.deviceId,type:"embedded-display",os:i==null?void 0:i.platform,browser:i==null?void 0:i.userAgent,resolution:r?`${r.screen.width}x${r.screen.height}`:void 0,uptime:Math.floor((Date.now()-f.current)/1e3),metadata:{}}},[C.deviceId,C.deviceName]),$=e.useCallback(async()=>{const i={isOnline:typeof navigator<"u"?navigator.onLine:!0,lastUpdated:new Date};if(typeof performance<"u"&&"memory"in performance){const r=performance.memory;r&&(i.memory=Math.round(r.usedJSHeapSize/r.jsHeapSizeLimit*100))}if(typeof navigator<"u"&&"getBattery"in navigator)try{const r=await navigator.getBattery();i.battery=Math.round(r.level*100)}catch{}if(typeof navigator<"u"&&"storage"in navigator&&"estimate"in navigator.storage)try{const r=await navigator.storage.estimate();r.quota&&r.usage&&(i.storageFree=r.quota-r.usage)}catch{}return i},[]),Y=e.useRef({enabled:C.enableScreenshot,capture:A});e.useEffect(()=>{Y.current={enabled:C.enableScreenshot,capture:A}});const H=e.useCallback(async()=>{const{enabled:i,capture:r}=Y.current;if(!i)throw new Error("Screenshots are disabled on this device (enableScreenshot: false)");if(!r)throw new Error("This device cannot take screenshots: no onCaptureScreenshot handler");const d=await r();if(!d)throw new Error("The screenshot handler returned no image");return d},[]),X=e.useCallback(()=>H().catch(()=>{}),[H]),O=e.useRef({onConnectionChange:w,onCommandReceived:N,onCustomCommand:x});e.useEffect(()=>{O.current={onConnectionChange:w,onCommandReceived:N,onCustomCommand:x}});const z=e.useCallback(async()=>{var i,r,d,n,l;if(((i=D.current)==null?void 0:i.readyState)!==WebSocket.OPEN){F(o=>({...o,status:"connecting"})),(d=(r=O.current).onConnectionChange)==null||d.call(r,"connecting");try{const o=new URL(C.serverUrl);o.searchParams.set("deviceId",C.deviceId),C.apiKey&&o.searchParams.set("apiKey",C.apiKey);const h=new WebSocket(o.toString());D.current=h,h.onopen=()=>{var v,b;m.current=0,F(k=>({...k,status:"connected",isConnected:!0,reconnectAttempts:0,error:void 0})),(b=(v=O.current).onConnectionChange)==null||b.call(v,"connected"),h.send(JSON.stringify({type:"register",payload:B()}))},h.onmessage=async v=>{var b,k;try{const u=JSON.parse(v.data);if(u.type==="command"){const p={id:u.id,type:u.commandType,payload:u.payload,timestamp:new Date,acknowledged:!0,executed:!1};F(_=>({..._,pendingCommands:[..._.pendingCommands,p]})),(k=(b=O.current).onCommandReceived)==null||k.call(b,p);let R,K;try{switch(p.type){case"restart":typeof window<"u"&&window.location.reload();break;case"screenshot":R=await H();break;case"logs":R=E.current;break;case"custom":O.current.onCustomCommand&&(R=await O.current.onCustomCommand(p));break}p.executed=!0,p.result=R}catch(_){K=_ instanceof Error?_.message:String(_),p.error=K}h.send(JSON.stringify({type:"commandResult",commandId:p.id,result:R,error:K})),F(_=>({..._,pendingCommands:_.pendingCommands.filter(L=>L.id!==p.id),commandHistory:[..._.commandHistory.slice(-49),p]}))}}catch{}},h.onerror=()=>{D.current===h&&F(v=>({...v,status:"error",error:"WebSocket error"}))},h.onclose=()=>{var v,b;D.current===h&&(D.current=null,F(k=>({...k,status:"disconnected",isConnected:!1})),m.current<C.maxReconnectAttempts&&setTimeout(()=>{m.current>=C.maxReconnectAttempts||(m.current+=1,F(k=>({...k,reconnectAttempts:m.current})),z())},C.reconnectDelay),(b=(v=O.current).onConnectionChange)==null||b.call(v,"disconnected"))}}catch(o){F(h=>({...h,status:"error",error:o instanceof Error?o.message:"Connection failed"})),(l=(n=O.current).onConnectionChange)==null||l.call(n,"error")}}},[C.serverUrl,C.deviceId,C.apiKey,C.maxReconnectAttempts,C.reconnectDelay,B,H]),T=e.useCallback(()=>{m.current=C.maxReconnectAttempts,D.current&&(D.current.close(),D.current=null),F(i=>({...i,status:"disconnected",isConnected:!1,reconnectAttempts:C.maxReconnectAttempts}))},[C.maxReconnectAttempts]),M=e.useCallback(async()=>{var i;((i=D.current)==null?void 0:i.readyState)===WebSocket.OPEN&&(D.current.send(JSON.stringify({type:"heartbeat",timestamp:new Date().toISOString(),deviceId:C.deviceId})),F(r=>({...r,lastHeartbeat:new Date})))},[C.deviceId]),j=e.useCallback(async i=>{var d;if(((d=D.current)==null?void 0:d.readyState)!==WebSocket.OPEN)return;const r=i||await $();D.current.send(JSON.stringify({type:"health",metrics:r,deviceId:C.deviceId})),F(n=>({...n,healthMetrics:r}))},[C.deviceId,$]),S=e.useCallback(async(i,r,d)=>{var n;((n=D.current)==null?void 0:n.readyState)===WebSocket.OPEN&&D.current.send(JSON.stringify({type:"commandResult",commandId:i,result:r,error:d}))},[]),P=e.useCallback((i,r,d)=>{var l;const n={level:i,message:r,data:d,timestamp:new Date};E.current=[...E.current.slice(-(C.logBufferSize-1)),n],C.enableLogs&&((l=D.current)==null?void 0:l.readyState)===WebSocket.OPEN&&D.current.send(JSON.stringify({type:"log",...n,deviceId:C.deviceId}))},[C.deviceId,C.enableLogs,C.logBufferSize]);e.useEffect(()=>(m.current=0,z(),()=>{T(),a.current&&clearInterval(a.current),y.current&&clearInterval(y.current)}),[]),e.useEffect(()=>{if(I.isConnected)return a.current=setInterval(M,C.heartbeatInterval),()=>{a.current&&clearInterval(a.current)}},[I.isConnected,C.heartbeatInterval,M]),e.useEffect(()=>{if(!(!I.isConnected||!C.enableHealthMonitoring))return y.current=setInterval(()=>{j()},C.healthReportInterval),j(),()=>{y.current&&clearInterval(y.current)}},[I.isConnected,C.enableHealthMonitoring,C.healthReportInterval,j]),e.useImperativeHandle(g,()=>({getState:()=>I,connect:z,disconnect:T,sendHeartbeat:M,sendHealthMetrics:j,reportCommandResult:S,sendLog:P,captureScreenshot:X,getDeviceInfo:B}),[I,z,T,M,j,S,P,X,B]);const W={...I,deviceInfo:B(),connect:z,disconnect:T,sendLog:P};return t.jsx(ze.Provider,{value:W,children:G})}),{displayName:"NiceRemoteManagement"}),Ye=Ge;process.env.NODE_ENV!=="production"&&(Ye.displayName="NiceRemoteManagementProvider");const Ut={modes:["pixel-shift","dimming"],inactivityTimeout:300*1e3,pixelShift:{maxShift:3,interval:6e4,smooth:!0},colorCycle:{colors:["var(--nice-text-primary, #000000)","var(--nice-text, #111111)","var(--nice-bg, #0a0a0a)"],interval:3e4,transitionDuration:1e3},dimming:{level:.3,fadeDuration:2e3},screensaver:{type:"blank"},staticDetectionThreshold:3e4,autoDetectStatic:!1},Vt=Object.assign(e.forwardRef((s,g)=>{var o,h,v,b,k,u;const{config:c,enabled:w=!0,onActivate:N,onDeactivate:x,onModeChange:A,children:G}=s,C={...Ut,...c},D=e.useRef(null),a=e.useRef(null),y=e.useRef(null),E=e.useRef(null),[f,m]=e.useState({isActive:!1,activeModes:[],shiftX:0,shiftY:0,isDimmed:!1,isScreensaverActive:!1,idleTime:0}),[I,F]=e.useState(0),[B,$]=e.useState({x:50,y:50,dx:1,dy:1}),Y=e.useCallback(()=>{if(!C.pixelShift)return;const{maxShift:p}=C.pixelShift,R=Math.floor(Math.random()*(p*2+1))-p,K=Math.floor(Math.random()*(p*2+1))-p;m(_=>({..._,shiftX:R,shiftY:K}))},[C.pixelShift]),H=e.useCallback(()=>{!C.pixelShift||y.current||(Y(),y.current=setInterval(Y,C.pixelShift.interval))},[C.pixelShift,Y]),X=e.useCallback(()=>{y.current&&(clearInterval(y.current),y.current=null),m(p=>({...p,shiftX:0,shiftY:0}))},[]),O=e.useCallback(()=>{!C.colorCycle||E.current||(E.current=setInterval(()=>{F(p=>{var R;return(p+1)%(((R=C.colorCycle)==null?void 0:R.colors.length)||1)})},C.colorCycle.interval))},[C.colorCycle]),z=e.useCallback(()=>{E.current&&(clearInterval(E.current),E.current=null),F(0)},[]),T=e.useCallback(()=>{if(!w||f.isActive)return;const p=C.modes;m(R=>({...R,isActive:!0,activeModes:p})),p.includes("pixel-shift")&&H(),p.includes("color-cycling")&&O(),p.includes("dimming")&&m(R=>({...R,isDimmed:!0})),p.includes("screensaver")&&m(R=>({...R,isScreensaverActive:!0})),N==null||N(),A==null||A(p)},[w,f.isActive,C.modes,H,O,N,A]),M=e.useCallback(()=>{f.isActive&&(X(),z(),m(p=>({...p,isActive:!1,activeModes:[],isDimmed:!1,isScreensaverActive:!1})),x==null||x(),A==null||A([]))},[f.isActive,X,z,x,A]),j=e.useCallback(()=>{f.isActive?M():T()},[f.isActive,T,M]),S=e.useCallback(()=>{a.current&&clearTimeout(a.current),f.isActive&&M(),w&&C.inactivityTimeout>0&&(a.current=setTimeout(()=>{T()},C.inactivityTimeout))},[w,f.isActive,C.inactivityTimeout,T,M]),P=e.useCallback(()=>{m(p=>({...p,isScreensaverActive:!0}))},[]),W=e.useCallback(()=>{m(p=>({...p,isScreensaverActive:!1})),S()},[S]),i=e.useCallback(p=>{m(R=>({...R,isDimmed:p>0}))},[]);e.useEffect(()=>{var R;if(!f.isScreensaverActive||((R=C.screensaver)==null?void 0:R.type)!=="bounce")return;const p=setInterval(()=>{$(K=>{let{x:_,y:L,dx:q,dy:V}=K;return _+=q*.5,L+=V*.5,(_<=0||_>=90)&&(q=-q),(L<=0||L>=90)&&(V=-V),{x:_,y:L,dx:q,dy:V}})},50);return()=>clearInterval(p)},[f.isScreensaverActive,(o=C.screensaver)==null?void 0:o.type]),e.useEffect(()=>{if(!w)return;const p=["mousedown","mousemove","keydown","touchstart","scroll","wheel"],R=()=>{S()};for(const K of p)document.addEventListener(K,R);return S(),()=>{for(const K of p)document.removeEventListener(K,R);a.current&&clearTimeout(a.current),X(),z()}},[w,S,X,z]),e.useImperativeHandle(g,()=>({getState:()=>f,activate:T,deactivate:M,toggle:j,resetIdleTimer:S,forceShift:Y,showScreensaver:P,hideScreensaver:W,setDimLevel:i}),[f,T,M,j,S,Y,P,W,i]);const r=()=>{if(!f.isScreensaverActive)return null;const p=C.screensaver||{type:"blank"};switch(p.type){case"blank":return t.jsx("div",{className:"nice-sbp__screensaver nice-sbp__screensaver--blank",onClick:W,onTouchStart:W});case"bounce":return t.jsx("div",{className:"nice-sbp__screensaver nice-sbp__screensaver--bounce",onClick:W,onTouchStart:W,children:t.jsx("div",{className:"nice-sbp__bounce-logo",style:{left:`${B.x}%`,top:`${B.y}%`},children:t.jsx("span",{"aria-hidden":"true",style:{display:"inline-block",width:"1em",height:"1em",background:"currentColor",clipPath:"polygon(25% 5%, 75% 5%, 100% 50%, 75% 95%, 25% 95%, 0% 50%)"}})})});case"matrix":return t.jsx("div",{className:"nice-sbp__screensaver nice-sbp__screensaver--matrix",onClick:W,onTouchStart:W,children:Array.from({length:20}).map((R,K)=>t.jsx("div",{className:"nice-sbp__matrix-column",style:{left:`${K*5}%`,animationDelay:`${Math.random()*5}s`,animationDuration:`${5+Math.random()*5}s`},children:Array.from({length:20}).map((_,L)=>t.jsx("span",{children:String.fromCharCode(12448+Math.random()*96)},L))},K))});case"noise":return t.jsx("div",{className:"nice-sbp__screensaver nice-sbp__screensaver--noise",onClick:W,onTouchStart:W});case"custom":return t.jsx("div",{className:"nice-sbp__screensaver nice-sbp__screensaver--custom",onClick:W,onTouchStart:W,children:p.component});default:return null}},d={transform:f.isActive&&C.modes.includes("pixel-shift")?`translate(${f.shiftX}px, ${f.shiftY}px)`:void 0,transition:(h=C.pixelShift)!=null&&h.smooth?"transform 0.5s ease":void 0},n={"--dim-level":f.isDimmed?((v=C.dimming)==null?void 0:v.level)||.3:0,"--dim-duration":`${((b=C.dimming)==null?void 0:b.fadeDuration)||2e3}ms`},l=f.isActive&&C.modes.includes("color-cycling")?{backgroundColor:(k=C.colorCycle)==null?void 0:k.colors[I],transition:`background-color ${((u=C.colorCycle)==null?void 0:u.transitionDuration)||1e3}ms ease`}:{};return t.jsxs("div",{ref:D,className:`nice-sbp ${f.isActive?"nice-sbp--active":""}`,style:{...l},children:[t.jsx("div",{className:"nice-sbp__content",style:d,children:G}),f.isDimmed&&t.jsx("div",{className:"nice-sbp__dim-overlay",style:n,onClick:S,onTouchStart:S}),r(),f.isActive&&C.modes.includes("invert")&&t.jsx("div",{className:"nice-sbp__invert-overlay"})]})}),{displayName:"NiceScreenBurnPrevention"}),Wt={pointCount:5,targetSize:40,accuracyThreshold:20,pointTimeout:1e4,showAccuracy:!0,allowRetry:!0,persistCalibration:!0,storageKey:"nice-touch-calibration"},Ht=s=>({4:[{targetX:10,targetY:10},{targetX:90,targetY:10},{targetX:90,targetY:90},{targetX:10,targetY:90}],5:[{targetX:10,targetY:10},{targetX:90,targetY:10},{targetX:50,targetY:50},{targetX:10,targetY:90},{targetX:90,targetY:90}],9:[{targetX:10,targetY:10},{targetX:50,targetY:10},{targetX:90,targetY:10},{targetX:10,targetY:50},{targetX:50,targetY:50},{targetX:90,targetY:50},{targetX:10,targetY:90},{targetX:50,targetY:90},{targetX:90,targetY:90}]})[s],zt=Object.assign(e.forwardRef((s,g)=>{const{t:c}=ae.useNiceTranslation(),{config:w,autoStart:N=!1,onStart:x,onPointCalibrated:A,onComplete:G,onCancel:C,children:D}=s,a={...Wt,...w},y=e.useRef(null),E=e.useRef(null),[f,m]=e.useState({isActive:!1,currentPointIndex:0,totalPoints:a.pointCount,points:[],isCompleted:!1,isSuccessful:!1,matrix:null,averageError:0}),I=e.useCallback(S=>{const P=S.filter(q=>q.calibrated&&q.actualX!==void 0&&q.actualY!==void 0);if(P.length<3)return{scaleX:1,scaleY:1,offsetX:0,offsetY:0,rotation:0};let W=0,i=0,r=0,d=0;const n=P.length;for(const q of P)W+=q.targetX,i+=q.targetY,r+=q.actualX,d+=q.actualY;const l=W/n,o=i/n,h=r/n,v=d/n;let b=0,k=0,u=0,p=0;for(const q of P){const V=q.targetX-l,Q=q.targetY-o,te=q.actualX-h,Z=q.actualY-v;b+=V*V,k+=V*te,u+=Q*Q,p+=Q*Z}const R=k!==0?b/k:1,K=p!==0?u/p:1,_=l-R*h,L=o-K*v;return{scaleX:R,scaleY:K,offsetX:_,offsetY:L,rotation:0}},[]),F=e.useCallback((S,P)=>{const W=S.filter(r=>r.calibrated);if(W.length===0)return 0;let i=0;for(const r of W){if(r.actualX===void 0||r.actualY===void 0)continue;const d=P.scaleX*r.actualX+P.offsetX,n=P.scaleY*r.actualY+P.offsetY,l=r.targetX-d,o=r.targetY-n;i+=Math.sqrt(l*l+o*o)}return i/W.length},[]),B=e.useCallback(()=>{const P=Ht(a.pointCount).map(W=>({...W,calibrated:!1}));m({isActive:!0,currentPointIndex:0,totalPoints:a.pointCount,points:P,isCompleted:!1,isSuccessful:!1,matrix:null,averageError:0}),x==null||x()},[a.pointCount,x]),$=e.useCallback(()=>{E.current&&clearTimeout(E.current),m(S=>({...S,isActive:!1,isCompleted:!1})),C==null||C()},[C]),Y=e.useCallback(()=>{m(S=>({...S,isCompleted:!1}))},[]),H=e.useCallback(()=>{if(a.persistCalibration)try{localStorage.removeItem(a.storageKey)}catch{}m({isActive:!1,currentPointIndex:0,totalPoints:a.pointCount,points:[],isCompleted:!1,isSuccessful:!1,matrix:null,averageError:0})},[a.persistCalibration,a.storageKey,a.pointCount]),X=e.useCallback(S=>{const P=I(S),W=F(S,P),i=W<=a.accuracyThreshold;if(a.persistCalibration&&i)try{localStorage.setItem(a.storageKey,JSON.stringify({matrix:P,points:S}))}catch{}m(r=>({...r,points:S,isActive:!1,isCompleted:!0,isSuccessful:i,matrix:P,averageError:W})),G==null||G(P,i)},[a.accuracyThreshold,a.persistCalibration,a.storageKey,I,F,G]),O=e.useCallback(S=>{if(!f.isActive||!y.current)return;S.preventDefault();const P=y.current.getBoundingClientRect();let W,i;"touches"in S?(W=S.touches[0].clientX,i=S.touches[0].clientY):(W=S.clientX,i=S.clientY);const r=(W-P.left)/P.width*100,d=(i-P.top)/P.height*100,n=f.currentPointIndex,l=[...f.points];l[n]={...l[n],actualX:r,actualY:d,calibrated:!0};const o=n+1;A==null||A(l[n],n),o>=f.totalPoints?X(l):m(h=>({...h,currentPointIndex:o,points:l}))},[f.isActive,f.currentPointIndex,f.points,f.totalPoints,X,A]),z=e.useCallback((S,P)=>{const W=f.matrix;return W?{x:W.scaleX*S+W.offsetX,y:W.scaleY*P+W.offsetY}:{x:S,y:P}},[f.matrix]),T=e.useCallback(()=>{if(f.matrix)return!0;if(a.persistCalibration)try{return!!localStorage.getItem(a.storageKey)}catch{return!1}return!1},[f.matrix,a.persistCalibration,a.storageKey]),M=e.useCallback(()=>{if(a.persistCalibration)try{localStorage.removeItem(a.storageKey)}catch{}m(S=>({...S,matrix:null}))},[a.persistCalibration,a.storageKey]);if(e.useEffect(()=>{if(a.persistCalibration)try{const S=localStorage.getItem(a.storageKey);if(S){const P=JSON.parse(S);m(W=>({...W,matrix:P.matrix,points:P.points||[],isCompleted:!0,isSuccessful:!0}))}}catch{}},[a.persistCalibration,a.storageKey]),e.useEffect(()=>{if(!f.isActive)return;const S=y.current;if(S)return S.addEventListener("touchstart",O,{passive:!1}),S.addEventListener("mousedown",O),()=>{S.removeEventListener("touchstart",O),S.removeEventListener("mousedown",O)}},[f.isActive,O]),e.useEffect(()=>{if(!(!f.isActive||a.pointTimeout<=0))return E.current=setTimeout(()=>{f.currentPointIndex<f.totalPoints-1?m(S=>({...S,currentPointIndex:S.currentPointIndex+1})):X(f.points)},a.pointTimeout),()=>{E.current&&clearTimeout(E.current)}},[f.isActive,f.currentPointIndex,f.points,f.totalPoints,a.pointTimeout,X]),e.useEffect(()=>{N&&!T()&&B()},[N,T,B]),e.useImperativeHandle(g,()=>({getState:()=>f,start:B,cancel:$,reset:H,getMatrix:()=>f.matrix,transformPoint:z,hasCalibration:T,clearCalibration:M}),[f,B,$,H,z,T,M]),!f.isActive&&!f.isCompleted)return t.jsx(t.Fragment,{children:D});const j=f.isActive?f.points[f.currentPointIndex]:void 0;return t.jsxs("div",{ref:y,className:"nice-touch-calibration",children:[t.jsxs("div",{className:"nice-touch-calibration__overlay",children:[t.jsxs("div",{className:"nice-touch-calibration__instructions",children:[t.jsx("h2",{className:"nice-touch-calibration__title",children:c("touchCalibration.touchScreenCalibration","Touch Screen Calibration")}),t.jsx("p",{className:"nice-touch-calibration__text",children:c("touchCalibration.touchTheCenterOfEach","Touch the center of each target to calibrate your screen.")}),t.jsx("div",{className:"nice-touch-calibration__progress",children:c("touchCalibration.pointOf","Point {currentPointIndex} of {totalPoints}").replace("{currentPointIndex}",String(f.currentPointIndex+1)).replace("{totalPoints}",String(f.totalPoints))})]}),j&&t.jsx("div",{className:"nice-touch-calibration__target",style:{left:`${j.targetX}%`,top:`${j.targetY}%`,width:a.targetSize,height:a.targetSize},children:(w==null?void 0:w.targetComponent)||t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"nice-touch-calibration__target-outer"}),t.jsx("div",{className:"nice-touch-calibration__target-inner"}),t.jsx("div",{className:"nice-touch-calibration__target-center"})]})}),f.points.map((S,P)=>S.calibrated&&t.jsx("div",{className:"nice-touch-calibration__calibrated",style:{left:`${S.actualX}%`,top:`${S.actualY}%`}},P)),f.isActive&&t.jsx("button",{className:"nice-touch-calibration__cancel",onClick:$,children:c("touchCalibration.cancel","Cancel")})]}),f.isCompleted&&t.jsxs("div",{className:"nice-touch-calibration__result",children:[t.jsx("div",{className:`nice-touch-calibration__result-icon ${f.isSuccessful?"nice-touch-calibration__result-icon--success":"nice-touch-calibration__result-icon--error"}`,children:t.jsx("span",{className:`nice-platform-mark nice-platform-mark--${f.isSuccessful?"check":"alert"}`,"aria-hidden":"true"})}),t.jsx("h3",{className:"nice-touch-calibration__result-title",children:f.isSuccessful?c("touchCalibration.calibrationComplete","Calibration Complete"):c("touchCalibration.calibrationFailed","Calibration Failed")}),a.showAccuracy&&t.jsx("p",{className:"nice-touch-calibration__result-accuracy",children:c("touchCalibration.averageErrorPx","Average error: {averageError}px").replace("{averageError}",String(f.averageError.toFixed(1)))}),!f.isSuccessful&&a.allowRetry&&t.jsx("button",{className:"nice-touch-calibration__retry",onClick:B,children:c("touchCalibration.retryCalibration","Retry Calibration")}),t.jsx("button",{className:"nice-touch-calibration__retry nice-touch-calibration__done",onClick:Y,children:c("touchCalibration.done","Done")})]})]})}),{displayName:"NiceTouchCalibration"}),Gt={format:"code128",width:2,height:100,displayValue:!0,font:"monospace",fontSize:14,textAlign:"center",textPosition:"bottom",textMargin:2,background:"#ffffff",lineColor:"#000000",margin:10,flat:!1},Se=104,Yt=106,Xt=" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~",de=["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"],Ne=s=>{let g=de[Se],c=Se;for(let w=0;w<s.length;w++){const N=s[w],x=Xt.indexOf(N);x!==-1&&(g+=de[x],c+=x*(w+1))}return c=c%103,g+=de[c],g+=de[Yt],g},Xe=["0001101","0011001","0010011","0111101","0100011","0110001","0101111","0111011","0110111","0001011"],Kt=["0100111","0110011","0011011","0100001","0011101","0111001","0000101","0010001","0001001","0010111"],Ke=["1110010","1100110","1101100","1000010","1011100","1001110","1010000","1000100","1001000","1110100"],Qt=["LLLLLL","LLGLGG","LLGGLG","LLGGGL","LGLLGG","LGGLLG","LGGGLL","LGLGLG","LGLGGL","LGGLGL"],Jt=s=>{let g=0;for(let c=0;c<12;c++)g+=parseInt(s[c])*(c%2===0?1:3);return(10-g%10)%10},Zt=s=>{let g=s.replace(/\D/g,"").slice(0,12).padStart(12,"0");const c=Jt(g);g+=c;const w=parseInt(g[0]),N=Qt[w];let x="101";for(let A=1;A<=6;A++){const G=parseInt(g[A]);x+=N[A-1]==="L"?Xe[G]:Kt[G]}x+="01010";for(let A=7;A<=12;A++){const G=parseInt(g[A]);x+=Ke[G]}return x+="101",x},en=s=>{let g=s.replace(/\D/g,"").slice(0,7).padStart(7,"0"),c=0;for(let x=0;x<7;x++)c+=parseInt(g[x])*(x%2===0?3:1);const w=(10-c%10)%10;g+=w;let N="101";for(let x=0;x<4;x++)N+=Xe[parseInt(g[x])];N+="01010";for(let x=4;x<8;x++)N+=Ke[parseInt(g[x])];return N+="101",N},tn={0:"101001101101",1:"110100101011",2:"101100101011",3:"110110010101",4:"101001101011",5:"110100110101",6:"101100110101",7:"101001011011",8:"110100101101",9:"101100101101",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",".":"110010101101"," ":"100110101101",$:"100100100101","/":"100100101001","+":"100101001001","%":"101001001001","*":"100101101101"},nn=s=>{const g=("*"+s.toUpperCase()+"*").split("");let c="";for(const w of g){const N=tn[w];N&&(c+=N+"0")}return c.slice(0,-1)},_e=s=>{switch(s){case"code128":return Ne;case"code39":case"code93":return nn;case"ean13":return Zt;case"ean8":return en;default:return Ne}},sn=Object.assign(e.forwardRef((s,g)=>{const{t:c}=ae.useNiceTranslation(),{value:w,options:N,onGenerate:x,onError:A,showBorder:G=!1,className:C}=s,D=JSON.stringify(N??null),a=e.useMemo(()=>({...Gt,...JSON.parse(D)}),[D]),y=e.useRef(null),E=e.useRef(null),[f,m]=e.useState(null),[I,F]=e.useState(null),B=e.useCallback(()=>{if(!y.current||!w)return;const T=y.current,M=T.getContext("2d");if(M)try{const S=_e(a.format)(w),P=a.width,W=S.length*P,i=a.marginTop??a.margin,r=a.marginBottom??a.margin,d=a.marginLeft??a.margin,n=a.marginRight??a.margin,l=a.displayValue&&!a.flat?a.fontSize+a.textMargin*2:0,o=W+d+n,h=a.height+i+r+l;T.width=o,T.height=h,M.fillStyle=a.background,M.fillRect(0,0,o,h),M.fillStyle=a.lineColor;let v=d;const b=a.textPosition==="top"&&a.displayValue?i+l:i;for(let u=0;u<S.length;u++)S[u]==="1"&&M.fillRect(v,b,P,a.height),v+=P;if(a.displayValue&&!a.flat){M.fillStyle=a.lineColor,M.font=`${a.fontSize}px ${a.font}`,M.textBaseline=a.textPosition==="top"?"top":"bottom";let u=d;a.textAlign==="center"?(u=d+W/2,M.textAlign="center"):a.textAlign==="right"?(u=d+W,M.textAlign="right"):M.textAlign="left";const p=a.textPosition==="top"?i+a.textMargin:h-r-a.textMargin;M.fillText(w,u,p)}const k=T.toDataURL("image/png");F(k),m(null),x==null||x(k)}catch(j){const S=j instanceof Error?j.message:c("barcodeGenerator.failedToGenerateBarcode","Failed to generate barcode");m(S),A==null||A(new Error(S))}},[w,a,x,A,c]);e.useEffect(()=>{B()},[B]);const $=e.useCallback((T="image/png",M=1)=>{var j;return((j=y.current)==null?void 0:j.toDataURL(T,M))||null},[]),Y=e.useCallback(()=>{if(!y.current||!w)return null;try{const M=_e(a.format)(w),j=a.width,S=a.marginTop??a.margin,P=a.marginBottom??a.margin,W=a.marginLeft??a.margin,i=a.marginRight??a.margin,r=a.displayValue&&!a.flat?a.fontSize+a.textMargin*2:0,d=M.length*j,n=d+W+i,l=a.height+S+P+r,o=[];let h=W;const v=a.textPosition==="top"&&a.displayValue?S+r:S;for(let k=0;k<M.length;k++)M[k]==="1"&&o.push(`<rect x="${h}" y="${v}" width="${j}" height="${a.height}" fill="${a.lineColor}"/>`),h+=j;let b="";if(a.displayValue&&!a.flat){const k=a.textAlign==="center"?"middle":a.textAlign==="right"?"end":"start";let u=W;a.textAlign==="center"?u=W+d/2:a.textAlign==="right"&&(u=W+d);const p=a.textPosition==="top"?S+a.fontSize:l-P-a.textMargin;b=`<text x="${u}" y="${p}" font-family="${a.font}" font-size="${a.fontSize}" text-anchor="${k}" fill="${a.lineColor}">${w}</text>`}return`<svg xmlns="http://www.w3.org/2000/svg" width="${n}" height="${l}" viewBox="0 0 ${n} ${l}">
|
|
1
|
+
"use strict";var Ct=Object.defineProperty;var kt=(s,g,c)=>g in s?Ct(s,g,{enumerable:!0,configurable:!0,writable:!0,value:c}):s[g]=c;var ue=(s,g,c)=>kt(s,typeof g!="symbol"?g+"":g,c);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),ae=require("@nice2dev/ui-core"),e=require("react"),fe=e.createContext(null),St=()=>{const s=e.useContext(fe);if(!s)throw new Error("useAutoStart must be used within NiceAutoStartProvider");return s},Nt={showSplash:!0,splashDuration:2e3,autoHideSplash:!0,showProgress:!0,showTaskNames:!0,globalTimeout:6e4,autoRecovery:!0,recoveryAttempts:3,recoveryDelay:2e3,checkUpdates:!1,sendAnalytics:!1},De=Object.assign(e.forwardRef((s,g)=>{const{t:c}=ae.useNiceTranslation(),{tasks:w=[],config:N,splash:x,errorScreen:A,onComplete:G,onTaskComplete:C,onError:D,onRecovery:a,children:y}=s,E={...Nt,...N},f=e.useRef(0),m=e.useRef(w),I=e.useRef(null),[F,B]=e.useState(E.showSplash),[$,Y]=e.useState({phase:"initializing",isLoading:!0,isReady:!1,hasError:!1,progress:0,completedTasks:0,totalTasks:w.length,results:[],recoveryAttempt:0,totalDuration:0}),H=e.useCallback(async r=>{const d=Date.now();let n=0;const l=async()=>{try{const o=r.timeout||E.globalTimeout,h=new Promise((v,b)=>{setTimeout(()=>b(new Error("Task timeout")),o)});return await Promise.race([r.execute(),h]),{taskId:r.id,success:!0,duration:Date.now()-d,retriesUsed:n}}catch(o){const h=r.retries??0;return n<h?(n++,await new Promise(v=>setTimeout(v,500)),l()):{taskId:r.id,success:!1,error:o instanceof Error?o:new Error(String(o)),duration:Date.now()-d,retriesUsed:n}}};return l()},[E.globalTimeout]),X=e.useCallback(r=>{const d=[],n=[...r],l=new Set;for(;n.length>0;){const o=n.filter(v=>v.dependencies?v.dependencies.every(b=>l.has(b)):!0);if(o.length===0){d.push(...n);break}o.sort((v,b)=>(b.priority??0)-(v.priority??0));const h=o[0];d.push(h),l.add(h.id),n.splice(n.indexOf(h),1)}return d},[]),O=e.useCallback(async()=>{f.current=Date.now();const r=new AbortController;I.current=r;const d=X(m.current),n=[];Y(o=>({...o,phase:"loading",isLoading:!0,isReady:!1,hasError:!1,errorMessage:void 0,progress:0,completedTasks:0,totalTasks:d.length,results:[]}));for(let o=0;o<d.length;o++){if(r.signal.aborted)return;const h=d[o];Y(b=>({...b,currentTask:h.name,progress:Math.round(o/d.length*100)}));const v=await H(h);if(r.signal.aborted)return;if(n.push(v),Y(b=>({...b,completedTasks:o+1,results:[...b.results,v]})),C==null||C(v),!v.success&&h.critical){const b=v.error||new Error("Critical task failed");D==null||D(b,h.id),Y(k=>({...k,phase:"error",isLoading:!1,hasError:!0,errorMessage:b.message}));return}}const l=Date.now()-f.current;if(Y(o=>({...o,phase:"ready",isLoading:!1,isReady:!0,currentTask:void 0,progress:100,totalDuration:l})),G==null||G(n),E.autoHideSplash){const o=Date.now()-f.current,h=Math.max(0,E.splashDuration-o);setTimeout(()=>{B(!1)},h)}},[X,H,E.autoHideSplash,E.splashDuration,C,D,G]),z=e.useCallback(async()=>{I.current&&I.current.abort(),Y(r=>({...r,recoveryAttempt:0})),B(E.showSplash),await O()},[E.showSplash,O]),T=e.useCallback(()=>{I.current&&I.current.abort(),Y(r=>({...r,phase:"ready",isLoading:!1,isReady:!0,progress:100})),B(!1)},[]),M=e.useCallback(()=>{B(!1)},[]),j=e.useCallback(async()=>{const r=$.recoveryAttempt+1;r>E.recoveryAttempts||(Y(d=>({...d,phase:"recovery",recoveryAttempt:r})),a==null||a(r),await new Promise(d=>setTimeout(d,E.recoveryDelay)),await O())},[$.recoveryAttempt,E.recoveryAttempts,E.recoveryDelay,a,O]),S=e.useCallback(r=>{m.current=[...m.current,r]},[]),P=e.useCallback(r=>{m.current=m.current.filter(d=>d.id!==r)},[]),W=e.useCallback(r=>$.results.find(d=>d.taskId===r),[$.results]);e.useEffect(()=>{$.hasError&&E.autoRecovery&&$.recoveryAttempt<E.recoveryAttempts&&j()},[$.hasError,E.autoRecovery,E.recoveryAttempts,$.recoveryAttempt,j]),e.useEffect(()=>(O(),()=>{I.current&&I.current.abort()}),[]),e.useImperativeHandle(g,()=>({getState:()=>$,restart:z,skip:T,addTask:S,removeTask:P,getTaskResult:W,hideSplash:M,recover:j}),[$,z,T,S,P,W,M,j]);const i={...$,restart:z,skip:T,hideSplash:M};return $.hasError&&$.recoveryAttempt>=E.recoveryAttempts?t.jsx(fe.Provider,{value:i,children:A||t.jsxs("div",{className:"nice-auto-start__error",children:[t.jsx("div",{className:"nice-auto-start__error-icon","aria-hidden":"true",children:t.jsx("span",{className:"nice-platform-mark nice-platform-mark--alert"})}),t.jsx("h2",{className:"nice-auto-start__error-title",children:c("autoStart.startupFailed","Startup Failed")}),t.jsx("p",{className:"nice-auto-start__error-message",children:$.errorMessage}),t.jsx("button",{className:"nice-auto-start__error-retry",onClick:z,children:c("autoStart.retry","Retry")})]})}):F&&!$.isReady?t.jsx(fe.Provider,{value:i,children:x||t.jsx("div",{className:"nice-auto-start__splash",children:t.jsxs("div",{className:"nice-auto-start__splash-content",children:[t.jsx("div",{className:"nice-auto-start__splash-logo","aria-hidden":"true"}),t.jsx("h1",{className:"nice-auto-start__splash-title",children:c("autoStart.loading","Loading...")}),E.showProgress&&t.jsx("div",{className:"nice-auto-start__splash-progress",children:t.jsx("div",{className:"nice-auto-start__splash-progress-bar",style:{width:`${$.progress}%`}})}),E.showTaskNames&&$.currentTask&&t.jsx("div",{className:"nice-auto-start__splash-task",children:$.currentTask}),$.phase==="recovery"&&t.jsx("div",{className:"nice-auto-start__splash-recovery",children:c("autoStart.recoveryAttemptOf","Recovery attempt {recoveryAttempt} of {recoveryAttempts}").replace("{recoveryAttempt}",String($.recoveryAttempt)).replace("{recoveryAttempts}",String(E.recoveryAttempts))})]})})}):t.jsx(fe.Provider,{value:i,children:y})}),{displayName:"NiceAutoStart"}),Ae=De;process.env.NODE_ENV!=="production"&&(Ae.displayName="NiceAutoStartProvider");const Ee=e.createContext(null),Le=()=>{const s=e.useContext(Ee);if(!s)throw new Error("useExternalDisplay must be used within NiceExternalDisplayProvider");return s},_t={autoDetect:!0,pollInterval:2e3,defaultFeatures:{resizable:!0,scrollbars:!0},allowMultiWindow:!0,syncContent:!1},It=()=>typeof window>"u"?!1:"getScreenDetails"in window,jt=()=>`window-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,Dt=s=>{const g=[];return s.width!==void 0&&g.push(`width=${s.width}`),s.height!==void 0&&g.push(`height=${s.height}`),s.left!==void 0&&g.push(`left=${s.left}`),s.top!==void 0&&g.push(`top=${s.top}`),s.menubar!==void 0&&g.push(`menubar=${s.menubar?"yes":"no"}`),s.toolbar!==void 0&&g.push(`toolbar=${s.toolbar?"yes":"no"}`),s.location!==void 0&&g.push(`location=${s.location?"yes":"no"}`),s.status!==void 0&&g.push(`status=${s.status?"yes":"no"}`),s.resizable!==void 0&&g.push(`resizable=${s.resizable?"yes":"no"}`),s.scrollbars!==void 0&&g.push(`scrollbars=${s.scrollbars?"yes":"no"}`),g.join(",")},he="Primary Display";function we(s,g){if(s.id==="primary"&&s.label===he)return g("externalDisplay.primaryDisplay",he);const c=/^Display (\d+)$/.exec(s.label);return c?g("externalDisplay.displayN","Display {n}").replace("{n}",c[1]):s.label}const xe=()=>{var g;if(typeof window>"u")return{id:"primary",label:he,width:0,height:0,availWidth:0,availHeight:0,left:0,top:0,devicePixelRatio:1,isPrimary:!0,orientation:"landscape-primary",colorDepth:24};const s=window.screen;return{id:"primary",label:he,width:s.width,height:s.height,availWidth:s.availWidth,availHeight:s.availHeight,left:s.availLeft||0,top:s.availTop||0,devicePixelRatio:window.devicePixelRatio,isPrimary:!0,orientation:((g=s.orientation)==null?void 0:g.type)||"landscape-primary",colorDepth:s.colorDepth}},At=async()=>{try{return(await navigator.permissions.query({name:"window-management"})).state}catch{return"unknown"}},Ce=async()=>(await window.getScreenDetails()).screens.map((g,c)=>{var w;return{id:`screen-${c}`,label:g.label||`Display ${c+1}`,width:g.width,height:g.height,availWidth:g.availWidth,availHeight:g.availHeight,left:g.left,top:g.top,devicePixelRatio:g.devicePixelRatio,isPrimary:g.isPrimary,isInternal:g.isInternal,orientation:((w=g.orientation)==null?void 0:w.type)||"landscape-primary",colorDepth:g.colorDepth}}),ke=(s,g)=>JSON.stringify(s)===JSON.stringify(g),Pe=Object.assign(e.forwardRef((s,g)=>{const{config:c,onScreensChange:w,onWindowOpen:N,onWindowClose:x,onPermissionChange:A,children:G}=s,C={..._t,...c},D=e.useRef(new Map),a=e.useRef(null),[y,E]=e.useState([xe()]),[f,m]=e.useState([]),[I,F]=e.useState("unknown"),[B]=e.useState(It),$=e.useRef(w),Y=e.useRef(A);e.useEffect(()=>{$.current=w,Y.current=A});const H=e.useRef([]),X=e.useCallback(o=>{var h;E(v=>ke(v,o)?v:o),ke(H.current,o)||(H.current=o,(h=$.current)==null||h.call($,o))},[]),O=e.useRef("unknown"),z=e.useCallback(o=>{var h;O.current!==o&&(O.current=o,F(o),(h=Y.current)==null||h.call(Y,o))},[]),T=e.useCallback(async()=>{if(B){const h=await At();if(z(h),h==="granted")try{const v=await Ce();return X(v),v}catch{}}const o=[xe()];return X(o),o},[B,z,X]),M=e.useCallback(async()=>{if(!B)return z("denied"),!1;try{return X(await Ce()),z("granted"),!0}catch(o){return z(o instanceof DOMException&&o.name==="NotAllowedError"?"denied":"unknown"),!1}},[B,z,X]),j=e.useCallback(async(o,h="about:blank",v={})=>{if(!C.allowMultiWindow&&f.length>0)return console.warn("Multi-window mode is disabled"),null;const b=jt(),k={...C.defaultFeatures,...v,width:v.width??o.availWidth,height:v.height??o.availHeight,left:v.left??o.left,top:v.top??o.top},u=Dt(k),p={window:null,screen:o,id:b,state:"opening",isFullscreen:!1,features:k};m(R=>[...R,p]);try{const R=window.open(h,b,u);if(!R)return m(L=>L.map(q=>q.id===b?{...q,state:"error"}:q)),null;D.current.set(b,R);const K={...p,window:R,state:"open"};m(L=>L.map(q=>q.id===b?K:q));const _=setInterval(()=>{R.closed&&(clearInterval(_),D.current.delete(b),m(L=>L.filter(q=>q.id!==b)),x==null||x(K))},500);return k.fullscreen&&R.addEventListener("load",()=>{var L,q;(q=(L=R.document.documentElement).requestFullscreen)==null||q.call(L)}),N==null||N(K),K}catch(R){return console.error("Failed to open window:",R),m(K=>K.map(_=>_.id===b?{..._,state:"error"}:_)),null}},[C.allowMultiWindow,C.defaultFeatures,f.length,N,x]),S=e.useCallback(o=>{const h=D.current.get(o);h&&!h.closed&&h.close(),D.current.delete(o),m(v=>v.filter(b=>b.id!==o))},[]),P=e.useCallback(()=>{for(const[o,h]of D.current)h.closed||h.close(),D.current.delete(o);m([])},[]),W=e.useCallback((o,h)=>{const v=D.current.get(o);v&&!v.closed&&(v.moveTo(h.left,h.top),v.resizeTo(h.availWidth,h.availHeight),m(b=>b.map(k=>k.id===o?{...k,screen:h}:k)))},[]),i=e.useCallback(async o=>{const h=D.current.get(o);if(!h||h.closed)return!1;try{const v=!!h.document.fullscreenElement;return v?await h.document.exitFullscreen():await h.document.documentElement.requestFullscreen(),m(b=>b.map(k=>k.id===o?{...k,isFullscreen:!v}:k)),!0}catch{return!1}},[]),r=e.useCallback((o,h)=>{const v=D.current.get(o);v&&!v.closed&&v.postMessage(h,"*")},[]),d=e.useCallback(o=>{for(const h of D.current.values())h.closed||h.postMessage(o,"*")},[]);e.useEffect(()=>{C.autoDetect&&T()},[C.autoDetect,T]),e.useEffect(()=>(C.autoDetect&&C.pollInterval>0&&(a.current=setInterval(T,C.pollInterval)),()=>{a.current&&clearInterval(a.current)}),[C.autoDetect,C.pollInterval,T]),e.useEffect(()=>{if(!B)return;const o=()=>{T()};return window.addEventListener("screenschange",o),()=>{window.removeEventListener("screenschange",o)}},[B,T]),e.useEffect(()=>()=>{P()},[P]);const n=e.useMemo(()=>({screens:y,primaryScreen:y.find(o=>o.isPrimary)||null,externalScreens:y.filter(o=>!o.isPrimary),windows:f,isApiAvailable:B,permissionState:I}),[y,f,B,I]);e.useImperativeHandle(g,()=>({getState:()=>n,requestPermission:M,getScreens:T,openWindow:j,closeWindow:S,closeAllWindows:P,moveWindowToScreen:W,toggleFullscreen:i,sendMessage:r,broadcast:d}),[n,M,T,j,S,P,W,i,r,d]);const l={...n,requestPermission:M,openWindow:j,closeWindow:S,moveWindowToScreen:W};return t.jsx(Ee.Provider,{value:l,children:t.jsx("div",{className:"nice-external-display",children:G})})}),{displayName:"NiceExternalDisplay"}),Re=Pe;process.env.NODE_ENV!=="production"&&(Re.displayName="NiceExternalDisplayProvider");const Oe=({onSelect:s,selectedId:g,showPreview:c=!0,className:w})=>{const{t:N}=ae.useNiceTranslation(),{screens:x,primaryScreen:A}=Le(),G=y=>{s==null||s(y)},D=(()=>{let y=0,E=0,f=0,m=0;for(const I of x)y=Math.min(y,I.left),E=Math.min(E,I.top),f=Math.max(f,I.left+I.width),m=Math.max(m,I.top+I.height);return{minX:y,minY:E,maxX:f,maxY:m,width:f-y,height:m-E}})(),a=Math.min(280/D.width,160/D.height,1);return t.jsxs("div",{className:`nice-screen-selector ${w||""}`,children:[c&&t.jsx("div",{className:"nice-screen-selector__preview",style:{width:D.width*a,height:D.height*a},children:x.map(y=>t.jsx("button",{className:`nice-screen-selector__screen ${g===y.id?"nice-screen-selector__screen--selected":""} ${y.isPrimary?"nice-screen-selector__screen--primary":""}`,style:{left:(y.left-D.minX)*a,top:(y.top-D.minY)*a,width:y.width*a,height:y.height*a},onClick:()=>G(y),title:we(y,N),children:t.jsx("span",{className:"nice-screen-selector__screen-label",children:y.isPrimary?"P":x.indexOf(y)+1})},y.id))}),t.jsx("div",{className:"nice-screen-selector__list",children:x.map(y=>t.jsxs("button",{className:`nice-screen-selector__item ${g===y.id?"nice-screen-selector__item--selected":""}`,onClick:()=>G(y),children:[t.jsx("span",{className:"nice-screen-selector__item-name",children:we(y,N)}),t.jsxs("span",{className:"nice-screen-selector__item-resolution",children:[y.width," × ",y.height]}),y.isPrimary&&t.jsx("span",{className:"nice-screen-selector__item-badge",children:N("externalDisplay.primary","Primary")})]},y.id))})]})};process.env.NODE_ENV!=="production"&&(Oe.displayName="NiceScreenSelector");const Te=e.createContext(null),Et=()=>{const s=e.useContext(Te);if(!s)throw new Error("useKioskMode must be used within NiceKioskModeProvider");return s},Lt={autoFullscreen:!0,lockNavigation:!0,disableContextMenu:!0,disableShortcuts:!0,disableSelection:!0,disableCopyPaste:!0,exitPin:"1234",exitShortcut:"ctrl+shift+k",adminTapCount:5,adminTapTimeout:2e3,inactivityTimeout:300*1e3,showCursor:!0,allowScrolling:!0,className:""},Me=Object.assign(e.forwardRef((s,g)=>{const{t:c}=ae.useNiceTranslation(),{config:w,children:N,screensaver:x,adminPanel:A,onModeChange:G,onFullscreenChange:C,onAdminAccess:D,onInactivity:a,onActivity:y,onExitRequest:E}=s,f={...Lt,...w},m=e.useRef(null),I=e.useRef(null),F=e.useRef({count:0,timer:null}),[B,$]=e.useState({mode:"windowed",isFullscreen:!1,isLocked:!1,isAdminMode:!1,isScreensaverActive:!1,idleTime:0,isPinDialogOpen:!1}),[Y,H]=e.useState(""),[X,O]=e.useState(!1),z=e.useCallback(async()=>{const u=m.current;if(u)try{u.requestFullscreen?await u.requestFullscreen():u.webkitRequestFullscreen?await u.webkitRequestFullscreen():u.msRequestFullscreen&&await u.msRequestFullscreen()}catch(p){console.warn("Failed to enter fullscreen:",p)}},[]),T=e.useCallback(async()=>{try{document.exitFullscreen?await document.exitFullscreen():document.webkitExitFullscreen?await document.webkitExitFullscreen():document.msExitFullscreen&&await document.msExitFullscreen()}catch(u){console.warn("Failed to exit fullscreen:",u)}},[]),M=e.useCallback(async()=>{B.isFullscreen?await T():await z()},[B.isFullscreen,z,T]),j=e.useCallback(()=>{$(u=>({...u,mode:"locked",isLocked:!0,isAdminMode:!1})),G==null||G("locked")},[G]),S=e.useCallback(u=>f.exitPin&&u!==f.exitPin?(O(!0),setTimeout(()=>O(!1),1e3),!1):($(p=>({...p,mode:p.isFullscreen?"fullscreen":"windowed",isLocked:!1,isPinDialogOpen:!1})),H(""),!0),[f.exitPin]),P=e.useCallback(()=>{$(u=>({...u,isAdminMode:!0})),D==null||D()},[D]),W=e.useCallback(()=>{$(u=>({...u,isAdminMode:!1}))},[]),i=e.useCallback(()=>{F.current.timer&&clearTimeout(F.current.timer),F.current.count++,F.current.count>=f.adminTapCount?(F.current.count=0,P()):F.current.timer=setTimeout(()=>{F.current.count=0},f.adminTapTimeout)},[f.adminTapCount,f.adminTapTimeout,P]),r=e.useCallback(()=>{I.current&&clearTimeout(I.current),B.isScreensaverActive&&($(u=>({...u,isScreensaverActive:!1})),y==null||y()),f.inactivityTimeout>0&&(I.current=setTimeout(()=>{$(u=>({...u,isScreensaverActive:!0})),a==null||a()},f.inactivityTimeout))},[f.inactivityTimeout,B.isScreensaverActive,y,a]),d=e.useCallback(()=>{$(u=>({...u,isScreensaverActive:!0}))},[]),n=e.useCallback(()=>{$(u=>({...u,isScreensaverActive:!1})),r()},[r]),l=e.useCallback(()=>{$(u=>({...u,isPinDialogOpen:!0})),H(""),O(!1)},[]),o=e.useCallback(()=>{$(u=>({...u,isPinDialogOpen:!1})),H(""),O(!1)},[]),h=e.useCallback(()=>{S(Y)},[Y,S]),v=e.useCallback(u=>{u.key==="Enter"&&h()},[h]);e.useEffect(()=>{const u=()=>{const p=!!document.fullscreenElement;$(R=>({...R,mode:R.isLocked?"locked":p?"fullscreen":"windowed",isFullscreen:p})),C==null||C(p)};return document.addEventListener("fullscreenchange",u),document.addEventListener("webkitfullscreenchange",u),()=>{document.removeEventListener("fullscreenchange",u),document.removeEventListener("webkitfullscreenchange",u)}},[C]),e.useEffect(()=>{if(!f.disableContextMenu)return;const u=p=>{B.isAdminMode||p.preventDefault()};return document.addEventListener("contextmenu",u),()=>document.removeEventListener("contextmenu",u)},[f.disableContextMenu,B.isAdminMode]),e.useEffect(()=>{const u=async p=>{const K=f.exitShortcut.toLowerCase().split("+"),_=K.includes("ctrl")===p.ctrlKey,L=K.includes("shift")===p.shiftKey,q=K.includes("alt")===p.altKey,V=K.some(Q=>Q===p.key.toLowerCase());if(_&&L&&q&&V){p.preventDefault(),(E?await E("keyboard"):!0)&&(B.isLocked?l():T());return}if(f.disableShortcuts&&!B.isAdminMode){const Q=["F5","F11","F12"],te=[{ctrl:!0,key:"r"},{ctrl:!0,key:"w"},{ctrl:!0,key:"n"},{ctrl:!0,key:"t"},{ctrl:!0,shift:!0,key:"i"},{ctrl:!0,shift:!0,key:"j"},{alt:!0,key:"F4"}];if(Q.includes(p.key)){p.preventDefault();return}for(const Z of te)if(Z.ctrl===p.ctrlKey&&(Z.shift??!1)===p.shiftKey&&(Z.alt??!1)===p.altKey&&Z.key.toLowerCase()===p.key.toLowerCase()){p.preventDefault();return}}};return document.addEventListener("keydown",u),()=>document.removeEventListener("keydown",u)},[f.disableShortcuts,f.exitShortcut,B.isAdminMode,B.isLocked,T,l,E]),e.useEffect(()=>{if(!f.disableCopyPaste)return;const u=R=>{B.isAdminMode||R.preventDefault()},p=R=>{B.isAdminMode||R.preventDefault()};return document.addEventListener("copy",u),document.addEventListener("paste",p),()=>{document.removeEventListener("copy",u),document.removeEventListener("paste",p)}},[f.disableCopyPaste,B.isAdminMode]),e.useEffect(()=>{const u=["mousedown","mousemove","keydown","touchstart","scroll"],p=()=>{r()};for(const R of u)document.addEventListener(R,p);return r(),()=>{for(const R of u)document.removeEventListener(R,p);I.current&&clearTimeout(I.current)}},[r]),e.useEffect(()=>{if(f.autoFullscreen){const u=setTimeout(()=>{z()},100);return()=>clearTimeout(u)}},[f.autoFullscreen,z]),e.useImperativeHandle(g,()=>({getState:()=>B,enterFullscreen:z,exitFullscreen:T,toggleFullscreen:M,lock:j,unlock:S,enterAdminMode:P,exitAdminMode:W,resetIdleTimer:r,showScreensaver:d,hideScreensaver:n,openPinDialog:l,closePinDialog:o}),[B,z,T,M,j,S,P,W,r,d,n,l,o]);const b={...B,enterFullscreen:z,exitFullscreen:T,toggleFullscreen:M,lock:j,unlock:S,enterAdminMode:P,exitAdminMode:W,resetIdleTimer:r},k=["nice-kiosk-mode",`nice-kiosk-mode--${B.mode}`,B.isFullscreen&&"nice-kiosk-mode--fullscreen",!f.showCursor&&"nice-kiosk-mode--no-cursor",f.disableSelection&&"nice-kiosk-mode--no-select",!f.allowScrolling&&"nice-kiosk-mode--no-scroll",f.className].filter(Boolean).join(" ");return t.jsx(Te.Provider,{value:b,children:t.jsxs("div",{role:"presentation",ref:m,className:k,onClick:i,children:[t.jsx("div",{className:"nice-kiosk-mode__content",children:N}),B.isAdminMode&&A&&t.jsxs("div",{className:"nice-kiosk-mode__admin",children:[t.jsxs("div",{className:"nice-kiosk-mode__admin-header",children:[t.jsx("h2",{className:"nice-kiosk-mode__admin-title",children:c("kioskMode.adminMode","Admin Mode")}),t.jsx("button",{className:"nice-kiosk-mode__admin-close",onClick:W,"aria-label":c("kioskMode.closeAdminPanel","Close admin panel"),children:t.jsx("span",{className:"nice-platform-mark nice-platform-mark--close","aria-hidden":"true"})})]}),t.jsx("div",{className:"nice-kiosk-mode__admin-content",children:A})]}),B.isScreensaverActive&&t.jsx("div",{role:"presentation",className:"nice-kiosk-mode__screensaver",onClick:n,onTouchStart:n,children:x||t.jsx("div",{className:"nice-kiosk-mode__screensaver-default",children:t.jsx("div",{className:"nice-kiosk-mode__screensaver-text",children:c("kioskMode.touchToContinue","Touch to continue")})})}),B.isPinDialogOpen&&t.jsx("div",{className:"nice-kiosk-mode__pin-overlay",children:t.jsxs("div",{className:"nice-kiosk-mode__pin-dialog",children:[t.jsx("h3",{className:"nice-kiosk-mode__pin-title",children:c("kioskMode.enterPin","Enter PIN")}),t.jsx("input",{type:"password",className:`nice-kiosk-mode__pin-input ${X?"nice-kiosk-mode__pin-input--error":""}`,value:Y,onChange:u=>H(u.target.value),onKeyPress:v,maxLength:8,autoFocus:!0,placeholder:"••••"}),t.jsxs("div",{className:"nice-kiosk-mode__pin-buttons",children:[t.jsx("button",{className:"nice-kiosk-mode__pin-btn nice-kiosk-mode__pin-btn--cancel",onClick:o,children:c("kioskMode.cancel","Cancel")}),t.jsx("button",{className:"nice-kiosk-mode__pin-btn nice-kiosk-mode__pin-btn--submit",onClick:h,children:c("kioskMode.unlock","Unlock")})]}),X&&t.jsx("div",{className:"nice-kiosk-mode__pin-error",children:c("kioskMode.incorrectPin","Incorrect PIN")})]})}),B.isLocked&&!B.isPinDialogOpen&&t.jsx("div",{className:"nice-kiosk-mode__lock-indicator",children:t.jsx("span",{className:"nice-kiosk-mode__lock-text",children:c("kioskMode.kioskLocked","Kiosk Locked")})})]})})}),{displayName:"NiceKioskMode"}),Fe=Me;process.env.NODE_ENV!=="production"&&(Fe.displayName="NiceKioskModeProvider");const Be=e.createContext(null),Pt=()=>{const s=e.useContext(Be);if(!s)throw new Error("useLowPowerMode must be used within NiceLowPowerModeProvider");return s},Rt={normal:{mode:"normal",brightness:1,wakeOnTouch:!0},dim:{mode:"dim",brightness:.6,disableAnimations:!1,wakeOnTouch:!0},low:{mode:"low",brightness:.3,frameRateCap:30,disableAnimations:!0,reduceImageQuality:!0,wakeOnTouch:!0},sleep:{mode:"sleep",brightness:0,frameRateCap:1,disableAnimations:!0,disableBackgroundProcesses:!0,reduceImageQuality:!0,wakeOnTouch:!0,wakeOnMotion:!0}},Ot={initialMode:"normal",autoDimTimeout:120*1e3,autoSleepTimeout:600*1e3,lowBatteryThreshold:20,criticalBatteryThreshold:5,wakeOnTouch:!0,wakeOnMotion:!1,transitionDuration:500},$e=Object.assign(e.forwardRef((s,g)=>{const{t:c}=ae.useNiceTranslation(),{config:w,onModeChange:N,onBrightnessChange:x,onSleep:A,onWake:G,onLowBattery:C,children:D}=s,a={...Ot,...w},y=JSON.stringify((w==null?void 0:w.modes)??null),E=e.useMemo(()=>({...Rt,...JSON.parse(y)}),[y]),f=e.useRef(null),m=e.useRef(null),I=e.useRef(Date.now()),F=e.useRef(null),[B,$]=e.useState({currentMode:a.initialMode,brightness:E[a.initialMode].brightness??1,isPowerSaving:a.initialMode!=="normal",isSleeping:a.initialMode==="sleep",idleTime:0,isDisplayOn:!0}),Y=e.useRef(B);Y.current=B;const H=e.useRef({onModeChange:N,onBrightnessChange:x,onSleep:A,onWake:G});H.current={onModeChange:N,onBrightnessChange:x,onSleep:A,onWake:G};const X=e.useCallback(n=>{const l=E[n];document.documentElement.style.setProperty("--lpm-brightness",String(l.brightness)),document.documentElement.style.setProperty("--lpm-transition",`${a.transitionDuration}ms`),l.disableAnimations?document.documentElement.classList.add("nice-lpm-no-animations"):document.documentElement.classList.remove("nice-lpm-no-animations"),l.reduceImageQuality?document.documentElement.classList.add("nice-lpm-reduced-quality"):document.documentElement.classList.remove("nice-lpm-reduced-quality")},[E,a.transitionDuration]),O=e.useCallback(n=>{$(l=>{var b,k,u,p;if(l.currentMode===n)return l;const o=l.currentMode,h=E[n];X(n);const v=H.current;return(b=v.onModeChange)==null||b.call(v,n,o),(k=v.onBrightnessChange)==null||k.call(v,h.brightness??1),n==="sleep"&&o!=="sleep"?(u=v.onSleep)==null||u.call(v):o==="sleep"&&n!=="sleep"&&((p=v.onWake)==null||p.call(v)),{...l,currentMode:n,brightness:h.brightness??1,isPowerSaving:n!=="normal",isSleeping:n==="sleep",isDisplayOn:n!=="sleep"}})},[E,X]),z=e.useCallback(n=>{const l=Math.max(0,Math.min(1,n));document.documentElement.style.setProperty("--lpm-brightness",String(l)),$(o=>({...o,brightness:l})),x==null||x(l)},[x]),T=e.useCallback(()=>{O("sleep")},[O]),M=e.useCallback(()=>{I.current=Date.now(),f.current&&clearTimeout(f.current),m.current&&clearTimeout(m.current),a.autoDimTimeout>0&&(f.current=setTimeout(()=>{Y.current.currentMode==="normal"&&O("dim")},a.autoDimTimeout)),a.autoSleepTimeout>0&&(m.current=setTimeout(()=>{O("sleep")},a.autoSleepTimeout)),$(n=>n.idleTime===0?n:{...n,idleTime:0})},[a.autoDimTimeout,a.autoSleepTimeout,O]),j=e.useCallback(()=>{Y.current.currentMode!=="normal"&&O("normal"),M()},[O,M]),S=e.useCallback(()=>{O("normal"),j()},[O,j]),P=e.useCallback(()=>{B.currentMode==="normal"?O("low"):O("normal")},[B.currentMode,O]),W=e.useCallback(async()=>{if(typeof navigator<"u"&&"getBattery"in navigator)try{const n=await navigator.getBattery();return{level:Math.round(n.level*100),charging:n.charging}}catch{return{}}return{}},[]),i=e.useCallback(async()=>{const n=await W();n.level!==void 0&&($(l=>({...l,batteryLevel:n.level,isCharging:n.charging})),n.charging||(n.level<=a.criticalBatteryThreshold?(O("sleep"),C==null||C(n.level)):n.level<=a.lowBatteryThreshold&&(B.currentMode==="normal"&&O("low"),C==null||C(n.level))))},[W,a.lowBatteryThreshold,a.criticalBatteryThreshold,B.currentMode,O,C]),r=e.useCallback(()=>{if(!(w!=null&&w.schedule)||w.schedule.length===0)return;const l=new Date().getHours();for(const o of w.schedule){const{startHour:h,endHour:v,mode:b}=o;let k;if(h<=v?k=l>=h&&l<v:k=l>=h||l<v,k){$(u=>({...u,scheduledModeActive:b})),B.currentMode!==b&&O(b);return}}$(o=>({...o,scheduledModeActive:void 0}))},[w==null?void 0:w.schedule,B.currentMode,O]);e.useEffect(()=>{const n=["mousedown","mousemove","keydown","touchstart","scroll"],l=()=>{a.wakeOnTouch&&j()};for(const o of n)document.addEventListener(o,l);return M(),()=>{for(const o of n)document.removeEventListener(o,l);f.current&&clearTimeout(f.current),m.current&&clearTimeout(m.current)}},[a.wakeOnTouch,j,M]),e.useEffect(()=>{i(),(async()=>{if(typeof navigator<"u"&&"getBattery"in navigator)try{const l=await navigator.getBattery();F.current=l,l.addEventListener("levelchange",i),l.addEventListener("chargingchange",i)}catch{}})()},[i]),e.useEffect(()=>{r();const n=setInterval(r,6e4);return()=>clearInterval(n)},[r]),e.useEffect(()=>{X(a.initialMode)},[a.initialMode,X]),e.useImperativeHandle(g,()=>({getState:()=>B,setMode:O,setBrightness:z,sleep:T,wake:S,togglePowerSaving:P,resetIdleTimer:j,getBatteryInfo:W}),[B,O,z,T,S,P,j,W]);const d={...B,setMode:O,setBrightness:z,sleep:T,wake:S,resetIdleTimer:j};return t.jsx(Be.Provider,{value:d,children:t.jsxs("div",{className:`nice-lpm nice-lpm--${B.currentMode}`,children:[t.jsx("div",{className:"nice-lpm__overlay",style:{opacity:1-B.brightness}}),t.jsx("div",{className:"nice-lpm__content",children:D}),B.isSleeping&&t.jsx("div",{role:"presentation",className:"nice-lpm__sleep-screen",onClick:a.wakeOnTouch?S:void 0,onTouchStart:a.wakeOnTouch?S:void 0,children:t.jsx("div",{className:"nice-lpm__sleep-message",children:c("lowPowerMode.touchToWake","Touch to wake")})})]})})}),{displayName:"NiceLowPowerMode"}),qe=$e;process.env.NODE_ENV!=="production"&&(qe.displayName="NiceLowPowerModeProvider");const Ue=e.createContext(null),Tt=()=>{const s=e.useContext(Ue);if(!s)throw new Error("useOrientationLock must be used within NiceOrientationLockProvider");return s},Mt={preferredOrientation:"any",allowUserChange:!0,showRotationPrompt:!0,lockOnMount:!1,autoRotateContent:!1,supportedOrientations:["any","portrait","portrait-primary","portrait-secondary","landscape","landscape-primary","landscape-secondary","natural"]},Ve=()=>{if(typeof window>"u")return"portrait";const s=window.screen;return s.orientation?s.orientation.type:window.innerHeight>window.innerWidth?"portrait":"landscape"},Ft=()=>{if(typeof window>"u")return 0;const s=window.screen;return s.orientation?s.orientation.angle:window.orientation||0},ye=()=>{if(typeof window>"u")return{type:"portrait",angle:0,isPortrait:!0,isLandscape:!1,width:0,height:0,aspectRatio:0};const s=Ve(),g=Ft(),c=window.screen.width,w=window.screen.height,N=s.includes("portrait")||window.innerHeight>window.innerWidth,x=s.includes("landscape")||window.innerWidth>window.innerHeight;return{type:s,angle:g,isPortrait:N,isLandscape:x,width:c,height:w,aspectRatio:c/w}},Bt=()=>{if(typeof window>"u")return!1;const s=window.screen;return!!(s.orientation&&typeof s.orientation.lock=="function")},We=Object.assign(e.forwardRef((s,g)=>{const{t:c}=ae.useNiceTranslation(),{config:w,onOrientationChange:N,onLockChange:x,onUnsupportedOrientation:A,rotationPrompt:G,children:C,className:D}=s,a={...Mt,...w},y=e.useRef(!1),[E,f]=e.useState(Ve),[m,I]=e.useState(null),[F,B]=e.useState(ye),[$]=e.useState(Bt),Y=e.useCallback(i=>!!(a.supportedOrientations.includes("any")||a.supportedOrientations.includes(i)||i.includes("portrait")&&a.supportedOrientations.includes("portrait")||i.includes("landscape")&&a.supportedOrientations.includes("landscape")),[a.supportedOrientations]),H=e.useCallback(async i=>{if(!$)return console.warn("Screen Orientation API is not available"),I(i),x==null||x(!0,i),!1;try{return await window.screen.orientation.lock(i),I(i),x==null||x(!0,i),!0}catch(r){return console.warn("Failed to lock orientation:",r),I(i),x==null||x(!0,i),!1}},[$,x]),X=e.useCallback(async()=>{if(I(null),x==null||x(!1,null),!$)return!1;try{return window.screen.orientation.unlock(),!0}catch(i){return console.warn("Failed to unlock orientation:",i),!1}},[$,x]),O=e.useCallback(async()=>m?X():H(E),[m,E,H,X]),z=e.useCallback(()=>ye(),[]),T=e.useCallback(()=>{const i=ye(),r=i.type;f(r),B(i),N==null||N(i),Y(r)||A==null||A(r,a.supportedOrientations)},[a.supportedOrientations,Y,N,A]);e.useEffect(()=>{y.current||(y.current=!0,T(),a.lockOnMount&&a.preferredOrientation!=="any"&&H(a.preferredOrientation))},[a.lockOnMount,a.preferredOrientation,T,H]),e.useEffect(()=>{const i=window.screen.orientation;return i&&i.addEventListener("change",T),window.addEventListener("resize",T),window.addEventListener("orientationchange",T),()=>{i&&i.removeEventListener("change",T),window.removeEventListener("resize",T),window.removeEventListener("orientationchange",T)}},[T]);const M=e.useMemo(()=>({current:E,locked:m,isLocked:m!==null,isSupported:Y(E),info:F,isApiAvailable:$}),[E,m,F,$,Y]);e.useImperativeHandle(g,()=>({getState:()=>M,lock:H,unlock:X,toggleLock:O,getOrientationInfo:z,isOrientationSupported:Y}),[M,H,X,O,z,Y]);const j={...M,lock:H,unlock:X,getOrientationInfo:z},S=e.useCallback(()=>{if(!a.autoRotateContent||!m||m==="any")return;const i=m.includes("portrait"),r=F.isPortrait;return i===r?void 0:{transform:`rotate(${i?90:-90}deg)`,transformOrigin:"center center",width:i?F.height:F.width,height:i?F.width:F.height}},[a.autoRotateContent,m,F]),P=a.showRotationPrompt&&m!==null&&m!=="any"&&!M.isSupported,W=["nice-orientation",`nice-orientation--${E}`,m&&`nice-orientation--locked-${m}`,!M.isSupported&&"nice-orientation--unsupported",D].filter(Boolean).join(" ");return t.jsx(Ue.Provider,{value:j,children:t.jsxs("div",{className:W,style:S(),"data-orientation":E,"data-locked":m||void 0,children:[C,P&&t.jsx("div",{className:"nice-orientation__prompt",children:G||t.jsxs("div",{className:"nice-orientation__prompt-content",children:[t.jsx("div",{className:"nice-orientation__prompt-icon",children:t.jsx("span",{className:"nice-platform-mark nice-platform-mark--device","aria-hidden":"true"})}),t.jsx("p",{className:"nice-orientation__prompt-text",children:m!=null&&m.includes("portrait")?c("orientationLock.rotateToPortrait","Please rotate your device to portrait mode"):c("orientationLock.rotateToLandscape","Please rotate your device to landscape mode")})]})})]})})}),{displayName:"NiceOrientationLock"}),He=We;process.env.NODE_ENV!=="production"&&(He.displayName="NiceOrientationLockProvider");const ze=e.createContext(null),$t=()=>{const s=e.useContext(ze);if(!s)throw new Error("useRemoteManagement must be used within NiceRemoteManagementProvider");return s},qt={heartbeatInterval:3e4,reconnectDelay:5e3,maxReconnectAttempts:10,enableHealthMonitoring:!0,healthReportInterval:6e4,enableScreenshot:!0,enableLogs:!0,logBufferSize:100},Ge=Object.assign(e.forwardRef((s,g)=>{const{config:c,onConnectionChange:w,onCommandReceived:N,onCustomCommand:x,onCaptureScreenshot:A,children:G}=s,C={...qt,...c},D=e.useRef(null),a=e.useRef(null),y=e.useRef(null),E=e.useRef([]),f=e.useRef(Date.now()),m=e.useRef(0),[I,F]=e.useState({status:"disconnected",isConnected:!1,reconnectAttempts:0,pendingCommands:[],commandHistory:[]}),B=e.useCallback(()=>{const i=typeof navigator<"u"?navigator:null,r=typeof window<"u"?window:null;return{deviceId:C.deviceId,name:C.deviceName||C.deviceId,type:"embedded-display",os:i==null?void 0:i.platform,browser:i==null?void 0:i.userAgent,resolution:r?`${r.screen.width}x${r.screen.height}`:void 0,uptime:Math.floor((Date.now()-f.current)/1e3),metadata:{}}},[C.deviceId,C.deviceName]),$=e.useCallback(async()=>{const i={isOnline:typeof navigator<"u"?navigator.onLine:!0,lastUpdated:new Date};if(typeof performance<"u"&&"memory"in performance){const r=performance.memory;r&&(i.memory=Math.round(r.usedJSHeapSize/r.jsHeapSizeLimit*100))}if(typeof navigator<"u"&&"getBattery"in navigator)try{const r=await navigator.getBattery();i.battery=Math.round(r.level*100)}catch{}if(typeof navigator<"u"&&"storage"in navigator&&"estimate"in navigator.storage)try{const r=await navigator.storage.estimate();r.quota&&r.usage&&(i.storageFree=r.quota-r.usage)}catch{}return i},[]),Y=e.useRef({enabled:C.enableScreenshot,capture:A});e.useEffect(()=>{Y.current={enabled:C.enableScreenshot,capture:A}});const H=e.useCallback(async()=>{const{enabled:i,capture:r}=Y.current;if(!i)throw new Error("Screenshots are disabled on this device (enableScreenshot: false)");if(!r)throw new Error("This device cannot take screenshots: no onCaptureScreenshot handler");const d=await r();if(!d)throw new Error("The screenshot handler returned no image");return d},[]),X=e.useCallback(()=>H().catch(()=>{}),[H]),O=e.useRef({onConnectionChange:w,onCommandReceived:N,onCustomCommand:x});e.useEffect(()=>{O.current={onConnectionChange:w,onCommandReceived:N,onCustomCommand:x}});const z=e.useCallback(async()=>{var i,r,d,n,l;if(((i=D.current)==null?void 0:i.readyState)!==WebSocket.OPEN){F(o=>({...o,status:"connecting"})),(d=(r=O.current).onConnectionChange)==null||d.call(r,"connecting");try{const o=new URL(C.serverUrl);o.searchParams.set("deviceId",C.deviceId),C.apiKey&&o.searchParams.set("apiKey",C.apiKey);const h=new WebSocket(o.toString());D.current=h,h.onopen=()=>{var v,b;m.current=0,F(k=>({...k,status:"connected",isConnected:!0,reconnectAttempts:0,error:void 0})),(b=(v=O.current).onConnectionChange)==null||b.call(v,"connected"),h.send(JSON.stringify({type:"register",payload:B()}))},h.onmessage=async v=>{var b,k;try{const u=JSON.parse(v.data);if(u.type==="command"){const p={id:u.id,type:u.commandType,payload:u.payload,timestamp:new Date,acknowledged:!0,executed:!1};F(_=>({..._,pendingCommands:[..._.pendingCommands,p]})),(k=(b=O.current).onCommandReceived)==null||k.call(b,p);let R,K;try{switch(p.type){case"restart":typeof window<"u"&&window.location.reload();break;case"screenshot":R=await H();break;case"logs":R=E.current;break;case"custom":O.current.onCustomCommand&&(R=await O.current.onCustomCommand(p));break}p.executed=!0,p.result=R}catch(_){K=_ instanceof Error?_.message:String(_),p.error=K}h.send(JSON.stringify({type:"commandResult",commandId:p.id,result:R,error:K})),F(_=>({..._,pendingCommands:_.pendingCommands.filter(L=>L.id!==p.id),commandHistory:[..._.commandHistory.slice(-49),p]}))}}catch{}},h.onerror=()=>{D.current===h&&F(v=>({...v,status:"error",error:"WebSocket error"}))},h.onclose=()=>{var v,b;D.current===h&&(D.current=null,F(k=>({...k,status:"disconnected",isConnected:!1})),m.current<C.maxReconnectAttempts&&setTimeout(()=>{m.current>=C.maxReconnectAttempts||(m.current+=1,F(k=>({...k,reconnectAttempts:m.current})),z())},C.reconnectDelay),(b=(v=O.current).onConnectionChange)==null||b.call(v,"disconnected"))}}catch(o){F(h=>({...h,status:"error",error:o instanceof Error?o.message:"Connection failed"})),(l=(n=O.current).onConnectionChange)==null||l.call(n,"error")}}},[C.serverUrl,C.deviceId,C.apiKey,C.maxReconnectAttempts,C.reconnectDelay,B,H]),T=e.useCallback(()=>{m.current=C.maxReconnectAttempts,D.current&&(D.current.close(),D.current=null),F(i=>({...i,status:"disconnected",isConnected:!1,reconnectAttempts:C.maxReconnectAttempts}))},[C.maxReconnectAttempts]),M=e.useCallback(async()=>{var i;((i=D.current)==null?void 0:i.readyState)===WebSocket.OPEN&&(D.current.send(JSON.stringify({type:"heartbeat",timestamp:new Date().toISOString(),deviceId:C.deviceId})),F(r=>({...r,lastHeartbeat:new Date})))},[C.deviceId]),j=e.useCallback(async i=>{var d;if(((d=D.current)==null?void 0:d.readyState)!==WebSocket.OPEN)return;const r=i||await $();D.current.send(JSON.stringify({type:"health",metrics:r,deviceId:C.deviceId})),F(n=>({...n,healthMetrics:r}))},[C.deviceId,$]),S=e.useCallback(async(i,r,d)=>{var n;((n=D.current)==null?void 0:n.readyState)===WebSocket.OPEN&&D.current.send(JSON.stringify({type:"commandResult",commandId:i,result:r,error:d}))},[]),P=e.useCallback((i,r,d)=>{var l;const n={level:i,message:r,data:d,timestamp:new Date};E.current=[...E.current.slice(-(C.logBufferSize-1)),n],C.enableLogs&&((l=D.current)==null?void 0:l.readyState)===WebSocket.OPEN&&D.current.send(JSON.stringify({type:"log",...n,deviceId:C.deviceId}))},[C.deviceId,C.enableLogs,C.logBufferSize]);e.useEffect(()=>(m.current=0,z(),()=>{T(),a.current&&clearInterval(a.current),y.current&&clearInterval(y.current)}),[]),e.useEffect(()=>{if(I.isConnected)return a.current=setInterval(M,C.heartbeatInterval),()=>{a.current&&clearInterval(a.current)}},[I.isConnected,C.heartbeatInterval,M]),e.useEffect(()=>{if(!(!I.isConnected||!C.enableHealthMonitoring))return y.current=setInterval(()=>{j()},C.healthReportInterval),j(),()=>{y.current&&clearInterval(y.current)}},[I.isConnected,C.enableHealthMonitoring,C.healthReportInterval,j]),e.useImperativeHandle(g,()=>({getState:()=>I,connect:z,disconnect:T,sendHeartbeat:M,sendHealthMetrics:j,reportCommandResult:S,sendLog:P,captureScreenshot:X,getDeviceInfo:B}),[I,z,T,M,j,S,P,X,B]);const W={...I,deviceInfo:B(),connect:z,disconnect:T,sendLog:P};return t.jsx(ze.Provider,{value:W,children:G})}),{displayName:"NiceRemoteManagement"}),Ye=Ge;process.env.NODE_ENV!=="production"&&(Ye.displayName="NiceRemoteManagementProvider");const Ut={modes:["pixel-shift","dimming"],inactivityTimeout:300*1e3,pixelShift:{maxShift:3,interval:6e4,smooth:!0},colorCycle:{colors:["var(--nice-text-primary, #000000)","var(--nice-text, #111111)","var(--nice-bg, #0a0a0a)"],interval:3e4,transitionDuration:1e3},dimming:{level:.3,fadeDuration:2e3},screensaver:{type:"blank"},staticDetectionThreshold:3e4,autoDetectStatic:!1},Vt=Object.assign(e.forwardRef((s,g)=>{var o,h,v,b,k,u;const{config:c,enabled:w=!0,onActivate:N,onDeactivate:x,onModeChange:A,children:G}=s,C={...Ut,...c},D=e.useRef(null),a=e.useRef(null),y=e.useRef(null),E=e.useRef(null),[f,m]=e.useState({isActive:!1,activeModes:[],shiftX:0,shiftY:0,isDimmed:!1,isScreensaverActive:!1,idleTime:0}),[I,F]=e.useState(0),[B,$]=e.useState({x:50,y:50,dx:1,dy:1}),Y=e.useCallback(()=>{if(!C.pixelShift)return;const{maxShift:p}=C.pixelShift,R=Math.floor(Math.random()*(p*2+1))-p,K=Math.floor(Math.random()*(p*2+1))-p;m(_=>({..._,shiftX:R,shiftY:K}))},[C.pixelShift]),H=e.useCallback(()=>{!C.pixelShift||y.current||(Y(),y.current=setInterval(Y,C.pixelShift.interval))},[C.pixelShift,Y]),X=e.useCallback(()=>{y.current&&(clearInterval(y.current),y.current=null),m(p=>({...p,shiftX:0,shiftY:0}))},[]),O=e.useCallback(()=>{!C.colorCycle||E.current||(E.current=setInterval(()=>{F(p=>{var R;return(p+1)%(((R=C.colorCycle)==null?void 0:R.colors.length)||1)})},C.colorCycle.interval))},[C.colorCycle]),z=e.useCallback(()=>{E.current&&(clearInterval(E.current),E.current=null),F(0)},[]),T=e.useCallback(()=>{if(!w||f.isActive)return;const p=C.modes;m(R=>({...R,isActive:!0,activeModes:p})),p.includes("pixel-shift")&&H(),p.includes("color-cycling")&&O(),p.includes("dimming")&&m(R=>({...R,isDimmed:!0})),p.includes("screensaver")&&m(R=>({...R,isScreensaverActive:!0})),N==null||N(),A==null||A(p)},[w,f.isActive,C.modes,H,O,N,A]),M=e.useCallback(()=>{f.isActive&&(X(),z(),m(p=>({...p,isActive:!1,activeModes:[],isDimmed:!1,isScreensaverActive:!1})),x==null||x(),A==null||A([]))},[f.isActive,X,z,x,A]),j=e.useCallback(()=>{f.isActive?M():T()},[f.isActive,T,M]),S=e.useCallback(()=>{a.current&&clearTimeout(a.current),f.isActive&&M(),w&&C.inactivityTimeout>0&&(a.current=setTimeout(()=>{T()},C.inactivityTimeout))},[w,f.isActive,C.inactivityTimeout,T,M]),P=e.useCallback(()=>{m(p=>({...p,isScreensaverActive:!0}))},[]),W=e.useCallback(()=>{m(p=>({...p,isScreensaverActive:!1})),S()},[S]),i=e.useCallback(p=>{m(R=>({...R,isDimmed:p>0}))},[]);e.useEffect(()=>{var R;if(!f.isScreensaverActive||((R=C.screensaver)==null?void 0:R.type)!=="bounce")return;const p=setInterval(()=>{$(K=>{let{x:_,y:L,dx:q,dy:V}=K;return _+=q*.5,L+=V*.5,(_<=0||_>=90)&&(q=-q),(L<=0||L>=90)&&(V=-V),{x:_,y:L,dx:q,dy:V}})},50);return()=>clearInterval(p)},[f.isScreensaverActive,(o=C.screensaver)==null?void 0:o.type]),e.useEffect(()=>{if(!w)return;const p=["mousedown","mousemove","keydown","touchstart","scroll","wheel"],R=()=>{S()};for(const K of p)document.addEventListener(K,R);return S(),()=>{for(const K of p)document.removeEventListener(K,R);a.current&&clearTimeout(a.current),X(),z()}},[w,S,X,z]),e.useImperativeHandle(g,()=>({getState:()=>f,activate:T,deactivate:M,toggle:j,resetIdleTimer:S,forceShift:Y,showScreensaver:P,hideScreensaver:W,setDimLevel:i}),[f,T,M,j,S,Y,P,W,i]);const r=()=>{if(!f.isScreensaverActive)return null;const p=C.screensaver||{type:"blank"};switch(p.type){case"blank":return t.jsx("div",{role:"presentation",className:"nice-sbp__screensaver nice-sbp__screensaver--blank",onClick:W,onTouchStart:W});case"bounce":return t.jsx("div",{role:"presentation",className:"nice-sbp__screensaver nice-sbp__screensaver--bounce",onClick:W,onTouchStart:W,children:t.jsx("div",{className:"nice-sbp__bounce-logo",style:{left:`${B.x}%`,top:`${B.y}%`},children:t.jsx("span",{"aria-hidden":"true",style:{display:"inline-block",width:"1em",height:"1em",background:"currentColor",clipPath:"polygon(25% 5%, 75% 5%, 100% 50%, 75% 95%, 25% 95%, 0% 50%)"}})})});case"matrix":return t.jsx("div",{role:"presentation",className:"nice-sbp__screensaver nice-sbp__screensaver--matrix",onClick:W,onTouchStart:W,children:Array.from({length:20}).map((R,K)=>t.jsx("div",{className:"nice-sbp__matrix-column",style:{left:`${K*5}%`,animationDelay:`${Math.random()*5}s`,animationDuration:`${5+Math.random()*5}s`},children:Array.from({length:20}).map((_,L)=>t.jsx("span",{children:String.fromCharCode(12448+Math.random()*96)},L))},K))});case"noise":return t.jsx("div",{role:"presentation",className:"nice-sbp__screensaver nice-sbp__screensaver--noise",onClick:W,onTouchStart:W});case"custom":return t.jsx("div",{role:"presentation",className:"nice-sbp__screensaver nice-sbp__screensaver--custom",onClick:W,onTouchStart:W,children:p.component});default:return null}},d={transform:f.isActive&&C.modes.includes("pixel-shift")?`translate(${f.shiftX}px, ${f.shiftY}px)`:void 0,transition:(h=C.pixelShift)!=null&&h.smooth?"transform 0.5s ease":void 0},n={"--dim-level":f.isDimmed?((v=C.dimming)==null?void 0:v.level)||.3:0,"--dim-duration":`${((b=C.dimming)==null?void 0:b.fadeDuration)||2e3}ms`},l=f.isActive&&C.modes.includes("color-cycling")?{backgroundColor:(k=C.colorCycle)==null?void 0:k.colors[I],transition:`background-color ${((u=C.colorCycle)==null?void 0:u.transitionDuration)||1e3}ms ease`}:{};return t.jsxs("div",{ref:D,className:`nice-sbp ${f.isActive?"nice-sbp--active":""}`,style:{...l},children:[t.jsx("div",{className:"nice-sbp__content",style:d,children:G}),f.isDimmed&&t.jsx("div",{role:"presentation",className:"nice-sbp__dim-overlay",style:n,onClick:S,onTouchStart:S}),r(),f.isActive&&C.modes.includes("invert")&&t.jsx("div",{className:"nice-sbp__invert-overlay"})]})}),{displayName:"NiceScreenBurnPrevention"}),Wt={pointCount:5,targetSize:40,accuracyThreshold:20,pointTimeout:1e4,showAccuracy:!0,allowRetry:!0,persistCalibration:!0,storageKey:"nice-touch-calibration"},Ht=s=>({4:[{targetX:10,targetY:10},{targetX:90,targetY:10},{targetX:90,targetY:90},{targetX:10,targetY:90}],5:[{targetX:10,targetY:10},{targetX:90,targetY:10},{targetX:50,targetY:50},{targetX:10,targetY:90},{targetX:90,targetY:90}],9:[{targetX:10,targetY:10},{targetX:50,targetY:10},{targetX:90,targetY:10},{targetX:10,targetY:50},{targetX:50,targetY:50},{targetX:90,targetY:50},{targetX:10,targetY:90},{targetX:50,targetY:90},{targetX:90,targetY:90}]})[s],zt=Object.assign(e.forwardRef((s,g)=>{const{t:c}=ae.useNiceTranslation(),{config:w,autoStart:N=!1,onStart:x,onPointCalibrated:A,onComplete:G,onCancel:C,children:D}=s,a={...Wt,...w},y=e.useRef(null),E=e.useRef(null),[f,m]=e.useState({isActive:!1,currentPointIndex:0,totalPoints:a.pointCount,points:[],isCompleted:!1,isSuccessful:!1,matrix:null,averageError:0}),I=e.useCallback(S=>{const P=S.filter(q=>q.calibrated&&q.actualX!==void 0&&q.actualY!==void 0);if(P.length<3)return{scaleX:1,scaleY:1,offsetX:0,offsetY:0,rotation:0};let W=0,i=0,r=0,d=0;const n=P.length;for(const q of P)W+=q.targetX,i+=q.targetY,r+=q.actualX,d+=q.actualY;const l=W/n,o=i/n,h=r/n,v=d/n;let b=0,k=0,u=0,p=0;for(const q of P){const V=q.targetX-l,Q=q.targetY-o,te=q.actualX-h,Z=q.actualY-v;b+=V*V,k+=V*te,u+=Q*Q,p+=Q*Z}const R=k!==0?b/k:1,K=p!==0?u/p:1,_=l-R*h,L=o-K*v;return{scaleX:R,scaleY:K,offsetX:_,offsetY:L,rotation:0}},[]),F=e.useCallback((S,P)=>{const W=S.filter(r=>r.calibrated);if(W.length===0)return 0;let i=0;for(const r of W){if(r.actualX===void 0||r.actualY===void 0)continue;const d=P.scaleX*r.actualX+P.offsetX,n=P.scaleY*r.actualY+P.offsetY,l=r.targetX-d,o=r.targetY-n;i+=Math.sqrt(l*l+o*o)}return i/W.length},[]),B=e.useCallback(()=>{const P=Ht(a.pointCount).map(W=>({...W,calibrated:!1}));m({isActive:!0,currentPointIndex:0,totalPoints:a.pointCount,points:P,isCompleted:!1,isSuccessful:!1,matrix:null,averageError:0}),x==null||x()},[a.pointCount,x]),$=e.useCallback(()=>{E.current&&clearTimeout(E.current),m(S=>({...S,isActive:!1,isCompleted:!1})),C==null||C()},[C]),Y=e.useCallback(()=>{m(S=>({...S,isCompleted:!1}))},[]),H=e.useCallback(()=>{if(a.persistCalibration)try{localStorage.removeItem(a.storageKey)}catch{}m({isActive:!1,currentPointIndex:0,totalPoints:a.pointCount,points:[],isCompleted:!1,isSuccessful:!1,matrix:null,averageError:0})},[a.persistCalibration,a.storageKey,a.pointCount]),X=e.useCallback(S=>{const P=I(S),W=F(S,P),i=W<=a.accuracyThreshold;if(a.persistCalibration&&i)try{localStorage.setItem(a.storageKey,JSON.stringify({matrix:P,points:S}))}catch{}m(r=>({...r,points:S,isActive:!1,isCompleted:!0,isSuccessful:i,matrix:P,averageError:W})),G==null||G(P,i)},[a.accuracyThreshold,a.persistCalibration,a.storageKey,I,F,G]),O=e.useCallback(S=>{if(!f.isActive||!y.current)return;S.preventDefault();const P=y.current.getBoundingClientRect();let W,i;"touches"in S?(W=S.touches[0].clientX,i=S.touches[0].clientY):(W=S.clientX,i=S.clientY);const r=(W-P.left)/P.width*100,d=(i-P.top)/P.height*100,n=f.currentPointIndex,l=[...f.points];l[n]={...l[n],actualX:r,actualY:d,calibrated:!0};const o=n+1;A==null||A(l[n],n),o>=f.totalPoints?X(l):m(h=>({...h,currentPointIndex:o,points:l}))},[f.isActive,f.currentPointIndex,f.points,f.totalPoints,X,A]),z=e.useCallback((S,P)=>{const W=f.matrix;return W?{x:W.scaleX*S+W.offsetX,y:W.scaleY*P+W.offsetY}:{x:S,y:P}},[f.matrix]),T=e.useCallback(()=>{if(f.matrix)return!0;if(a.persistCalibration)try{return!!localStorage.getItem(a.storageKey)}catch{return!1}return!1},[f.matrix,a.persistCalibration,a.storageKey]),M=e.useCallback(()=>{if(a.persistCalibration)try{localStorage.removeItem(a.storageKey)}catch{}m(S=>({...S,matrix:null}))},[a.persistCalibration,a.storageKey]);if(e.useEffect(()=>{if(a.persistCalibration)try{const S=localStorage.getItem(a.storageKey);if(S){const P=JSON.parse(S);m(W=>({...W,matrix:P.matrix,points:P.points||[],isCompleted:!0,isSuccessful:!0}))}}catch{}},[a.persistCalibration,a.storageKey]),e.useEffect(()=>{if(!f.isActive)return;const S=y.current;if(S)return S.addEventListener("touchstart",O,{passive:!1}),S.addEventListener("mousedown",O),()=>{S.removeEventListener("touchstart",O),S.removeEventListener("mousedown",O)}},[f.isActive,O]),e.useEffect(()=>{if(!(!f.isActive||a.pointTimeout<=0))return E.current=setTimeout(()=>{f.currentPointIndex<f.totalPoints-1?m(S=>({...S,currentPointIndex:S.currentPointIndex+1})):X(f.points)},a.pointTimeout),()=>{E.current&&clearTimeout(E.current)}},[f.isActive,f.currentPointIndex,f.points,f.totalPoints,a.pointTimeout,X]),e.useEffect(()=>{N&&!T()&&B()},[N,T,B]),e.useImperativeHandle(g,()=>({getState:()=>f,start:B,cancel:$,reset:H,getMatrix:()=>f.matrix,transformPoint:z,hasCalibration:T,clearCalibration:M}),[f,B,$,H,z,T,M]),!f.isActive&&!f.isCompleted)return t.jsx(t.Fragment,{children:D});const j=f.isActive?f.points[f.currentPointIndex]:void 0;return t.jsxs("div",{ref:y,className:"nice-touch-calibration",children:[t.jsxs("div",{className:"nice-touch-calibration__overlay",children:[t.jsxs("div",{className:"nice-touch-calibration__instructions",children:[t.jsx("h2",{className:"nice-touch-calibration__title",children:c("touchCalibration.touchScreenCalibration","Touch Screen Calibration")}),t.jsx("p",{className:"nice-touch-calibration__text",children:c("touchCalibration.touchTheCenterOfEach","Touch the center of each target to calibrate your screen.")}),t.jsx("div",{className:"nice-touch-calibration__progress",children:c("touchCalibration.pointOf","Point {currentPointIndex} of {totalPoints}").replace("{currentPointIndex}",String(f.currentPointIndex+1)).replace("{totalPoints}",String(f.totalPoints))})]}),j&&t.jsx("div",{className:"nice-touch-calibration__target",style:{left:`${j.targetX}%`,top:`${j.targetY}%`,width:a.targetSize,height:a.targetSize},children:(w==null?void 0:w.targetComponent)||t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"nice-touch-calibration__target-outer"}),t.jsx("div",{className:"nice-touch-calibration__target-inner"}),t.jsx("div",{className:"nice-touch-calibration__target-center"})]})}),f.points.map((S,P)=>S.calibrated&&t.jsx("div",{className:"nice-touch-calibration__calibrated",style:{left:`${S.actualX}%`,top:`${S.actualY}%`}},P)),f.isActive&&t.jsx("button",{className:"nice-touch-calibration__cancel",onClick:$,children:c("touchCalibration.cancel","Cancel")})]}),f.isCompleted&&t.jsxs("div",{className:"nice-touch-calibration__result",children:[t.jsx("div",{className:`nice-touch-calibration__result-icon ${f.isSuccessful?"nice-touch-calibration__result-icon--success":"nice-touch-calibration__result-icon--error"}`,children:t.jsx("span",{className:`nice-platform-mark nice-platform-mark--${f.isSuccessful?"check":"alert"}`,"aria-hidden":"true"})}),t.jsx("h3",{className:"nice-touch-calibration__result-title",children:f.isSuccessful?c("touchCalibration.calibrationComplete","Calibration Complete"):c("touchCalibration.calibrationFailed","Calibration Failed")}),a.showAccuracy&&t.jsx("p",{className:"nice-touch-calibration__result-accuracy",children:c("touchCalibration.averageErrorPx","Average error: {averageError}px").replace("{averageError}",String(f.averageError.toFixed(1)))}),!f.isSuccessful&&a.allowRetry&&t.jsx("button",{className:"nice-touch-calibration__retry",onClick:B,children:c("touchCalibration.retryCalibration","Retry Calibration")}),t.jsx("button",{className:"nice-touch-calibration__retry nice-touch-calibration__done",onClick:Y,children:c("touchCalibration.done","Done")})]})]})}),{displayName:"NiceTouchCalibration"}),Gt={format:"code128",width:2,height:100,displayValue:!0,font:"monospace",fontSize:14,textAlign:"center",textPosition:"bottom",textMargin:2,background:"#ffffff",lineColor:"#000000",margin:10,flat:!1},Se=104,Yt=106,Xt=" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~",de=["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"],Ne=s=>{let g=de[Se],c=Se;for(let w=0;w<s.length;w++){const N=s[w],x=Xt.indexOf(N);x!==-1&&(g+=de[x],c+=x*(w+1))}return c=c%103,g+=de[c],g+=de[Yt],g},Xe=["0001101","0011001","0010011","0111101","0100011","0110001","0101111","0111011","0110111","0001011"],Kt=["0100111","0110011","0011011","0100001","0011101","0111001","0000101","0010001","0001001","0010111"],Ke=["1110010","1100110","1101100","1000010","1011100","1001110","1010000","1000100","1001000","1110100"],Qt=["LLLLLL","LLGLGG","LLGGLG","LLGGGL","LGLLGG","LGGLLG","LGGGLL","LGLGLG","LGLGGL","LGGLGL"],Jt=s=>{let g=0;for(let c=0;c<12;c++)g+=parseInt(s[c])*(c%2===0?1:3);return(10-g%10)%10},Zt=s=>{let g=s.replace(/\D/g,"").slice(0,12).padStart(12,"0");const c=Jt(g);g+=c;const w=parseInt(g[0]),N=Qt[w];let x="101";for(let A=1;A<=6;A++){const G=parseInt(g[A]);x+=N[A-1]==="L"?Xe[G]:Kt[G]}x+="01010";for(let A=7;A<=12;A++){const G=parseInt(g[A]);x+=Ke[G]}return x+="101",x},en=s=>{let g=s.replace(/\D/g,"").slice(0,7).padStart(7,"0"),c=0;for(let x=0;x<7;x++)c+=parseInt(g[x])*(x%2===0?3:1);const w=(10-c%10)%10;g+=w;let N="101";for(let x=0;x<4;x++)N+=Xe[parseInt(g[x])];N+="01010";for(let x=4;x<8;x++)N+=Ke[parseInt(g[x])];return N+="101",N},tn={0:"101001101101",1:"110100101011",2:"101100101011",3:"110110010101",4:"101001101011",5:"110100110101",6:"101100110101",7:"101001011011",8:"110100101101",9:"101100101101",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",".":"110010101101"," ":"100110101101",$:"100100100101","/":"100100101001","+":"100101001001","%":"101001001001","*":"100101101101"},nn=s=>{const g=("*"+s.toUpperCase()+"*").split("");let c="";for(const w of g){const N=tn[w];N&&(c+=N+"0")}return c.slice(0,-1)},_e=s=>{switch(s){case"code128":return Ne;case"code39":case"code93":return nn;case"ean13":return Zt;case"ean8":return en;default:return Ne}},sn=Object.assign(e.forwardRef((s,g)=>{const{t:c}=ae.useNiceTranslation(),{value:w,options:N,onGenerate:x,onError:A,showBorder:G=!1,className:C}=s,D=JSON.stringify(N??null),a=e.useMemo(()=>({...Gt,...JSON.parse(D)}),[D]),y=e.useRef(null),E=e.useRef(null),[f,m]=e.useState(null),[I,F]=e.useState(null),B=e.useCallback(()=>{if(!y.current||!w)return;const T=y.current,M=T.getContext("2d");if(M)try{const S=_e(a.format)(w),P=a.width,W=S.length*P,i=a.marginTop??a.margin,r=a.marginBottom??a.margin,d=a.marginLeft??a.margin,n=a.marginRight??a.margin,l=a.displayValue&&!a.flat?a.fontSize+a.textMargin*2:0,o=W+d+n,h=a.height+i+r+l;T.width=o,T.height=h,M.fillStyle=a.background,M.fillRect(0,0,o,h),M.fillStyle=a.lineColor;let v=d;const b=a.textPosition==="top"&&a.displayValue?i+l:i;for(let u=0;u<S.length;u++)S[u]==="1"&&M.fillRect(v,b,P,a.height),v+=P;if(a.displayValue&&!a.flat){M.fillStyle=a.lineColor,M.font=`${a.fontSize}px ${a.font}`,M.textBaseline=a.textPosition==="top"?"top":"bottom";let u=d;a.textAlign==="center"?(u=d+W/2,M.textAlign="center"):a.textAlign==="right"?(u=d+W,M.textAlign="right"):M.textAlign="left";const p=a.textPosition==="top"?i+a.textMargin:h-r-a.textMargin;M.fillText(w,u,p)}const k=T.toDataURL("image/png");F(k),m(null),x==null||x(k)}catch(j){const S=j instanceof Error?j.message:c("barcodeGenerator.failedToGenerateBarcode","Failed to generate barcode");m(S),A==null||A(new Error(S))}},[w,a,x,A,c]);e.useEffect(()=>{B()},[B]);const $=e.useCallback((T="image/png",M=1)=>{var j;return((j=y.current)==null?void 0:j.toDataURL(T,M))||null},[]),Y=e.useCallback(()=>{if(!y.current||!w)return null;try{const M=_e(a.format)(w),j=a.width,S=a.marginTop??a.margin,P=a.marginBottom??a.margin,W=a.marginLeft??a.margin,i=a.marginRight??a.margin,r=a.displayValue&&!a.flat?a.fontSize+a.textMargin*2:0,d=M.length*j,n=d+W+i,l=a.height+S+P+r,o=[];let h=W;const v=a.textPosition==="top"&&a.displayValue?S+r:S;for(let k=0;k<M.length;k++)M[k]==="1"&&o.push(`<rect x="${h}" y="${v}" width="${j}" height="${a.height}" fill="${a.lineColor}"/>`),h+=j;let b="";if(a.displayValue&&!a.flat){const k=a.textAlign==="center"?"middle":a.textAlign==="right"?"end":"start";let u=W;a.textAlign==="center"?u=W+d/2:a.textAlign==="right"&&(u=W+d);const p=a.textPosition==="top"?S+a.fontSize:l-P-a.textMargin;b=`<text x="${u}" y="${p}" font-family="${a.font}" font-size="${a.fontSize}" text-anchor="${k}" fill="${a.lineColor}">${w}</text>`}return`<svg xmlns="http://www.w3.org/2000/svg" width="${n}" height="${l}" viewBox="0 0 ${n} ${l}">
|
|
2
2
|
<rect width="100%" height="100%" fill="${a.background}"/>
|
|
3
3
|
${o.join(`
|
|
4
4
|
`)}
|