@touchcastllc/napster-companion-api-dev 1.0.0-alpha.49 → 1.0.0-alpha.51
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/lib/index.css +1 -1
- package/lib/index.standalone.js +1 -1
- package/package.json +1 -1
package/lib/index.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.np_companion-live-container,.np_companion-preview-container{height:100%;margin:0;padding:0;position:absolute;transition:opacity .3s ease-in-out;width:100%}.np_companion-preview-container{opacity:1;z-index:2}.np_companion-preview-container.np_companion-fade-out{opacity:0;pointer-events:none;transition:opacity .5s ease-out}.np_companion-live-container{opacity:0;z-index:1}.np_companion-live-container.np_companion-fade-in{opacity:1;z-index:3}:root{--base-border-radius:10px;--base-gap:20px}*,:after,:before{-webkit-box-sizing:border-box;box-sizing:border-box}::-webkit-input-placeholder{color:hsla(0,0%,100%,.4)}::-moz-placeholder{color:hsla(0,0%,100%,.4)}:-ms-input-placeholder{color:hsla(0,0%,100%,.4)}:-moz-placeholder{color:hsla(0,0%,100%,.4)}a,input{outline:none}body,html{background-color:transparent;background:transparent;margin:0;padding:0;width:100%}.np_companion-hide{display:none!important}.np_companion-align-middle{align-items:center;display:flex;justify-content:center}.np_companion-align-between{align-items:center;display:flex;justify-content:space-between}.np_companion-align-end{align-items:center;display:flex;justify-content:flex-end}.np_companion-align-start{align-items:flex-start;display:flex;justify-content:flex-start}.np_companion__d-none{display:none!important}#np_companion-sdk-root.np_companion-container-fixed{height:500px;position:fixed;transition:all .3s ease-in-out;width:400px;z-index:9999}#np_companion-sdk-root.np_companion-container-fixed.np_companion-view-rectangle{height:400px;width:340px}#np_companion-sdk-root.np_companion-container-fixed.np_companion-view-silhouette{height:400px}#np_companion-sdk-root.np_companion-container-fixed.np_companion-view-round{height:360px;width:250px}#np_companion-sdk-root.np_companion-container-fixed.np_companion-view-round.np_companion_disclaimer-disabled{height:320px!important}#np_companion-sdk-root.np_companion-container-fixed.np_companion-bottom-right{bottom:0;right:0}#np_companion-sdk-root.np_companion-container-fixed.np_companion-bottom-left{bottom:0;left:0}#np_companion-sdk-root.np_companion-container-fixed.np_companion-bottom-center{bottom:0;left:50%;transform:translateX(-50%)}#np_companion-sdk-root.np_companion-container-fixed.np_companion-top-right{right:0;top:0}#np_companion-sdk-root.np_companion-container-fixed.np_companion-top-left{left:0;top:0}#np_companion-sdk-root.np_companion-container-fixed.np_companion-top-center{left:50%;top:0;transform:translateX(-50%)}#np_companion-sdk-root.np_companion-container-fixed.np_companion-center{left:50%;top:50%;transform:translate(-50%,-50%)}.np_companion-avatar{height:100%;position:relative;width:100%}#np_companion-avatar-container{background:transparent;border-radius:var(--base-border-radius);height:100%;overflow:hidden;position:absolute;width:100%}#np_companion-avatar-container:not(.np_companion-view-silhouette){box-shadow:0 0 #0000,0 0 #0000,0 0 #0000,0 0 #0000,0 10px 15px -3px color-mix(in oklab,#00000080 100%,transparent),0 4px 6px -4px color-mix(in oklab,#00000080 100%,transparent)}.np_companion-avatar.np_companion-bg-transparent #np_companion-avatar-container.np_companion-view-silhouette{filter:drop-shadow(0 10px 15px rgba(0,0,0,.5)) drop-shadow(0 4px 6px rgba(0,0,0,.5))}.np_companion-container-fixed #np_companion-avatar-container.np_companion-view-round{border-radius:50%;height:212px;left:50%;transform:translate(-50%,12%);width:212px}.np_companion-container-fixed #np_companion-avatar-container.np_companion-view-rectangle,.np_companion-container-fixed #np_companion-avatar-container.np_companion-view-silhouette{left:50%;transform:translateX(-50%)}.np_companion-avatar-video{height:100%;inset:0;object-fit:cover;pointer-events:none;position:absolute;transition:opacity .3s ease-in-out;width:100%;z-index:10}.np_companion-avatar-video.no-opacity{opacity:0}.np_companion-avatar-canvas{background:transparent;height:100%;object-fit:cover;position:relative;width:100%;z-index:1}.np_companion-container-fixed #np_companion-avatar-container.np_companion-loader-pulse:after{animation:pulse 1.5s ease-in-out infinite;background-color:var(--np-loader-bg-color);border-radius:var(--base-border-radius);content:"";display:block;height:100%;left:0;opacity:.6;overflow:hidden;position:absolute;top:0;width:100%}.np_companion-avatar.np_companion-bg-transparent #np_companion-avatar-container:after{display:none}.np_companion-avatar:has(#np_companion-avatar-container.np_companion-view-round):after{display:none}#np_companion-avatar-container.np_companion-loader-pulse.loader-container.np_companion-view-round:after{animation:pulse 1.5s ease-in-out infinite;background-color:var(--np-loader-bg-color);border-radius:50%;content:"";display:block;height:100%;left:0;opacity:.6;overflow:hidden;position:absolute;top:0;width:100%}.np_companion-avatar.np_companion-bg-transparent #np_companion-avatar-container.np_companion-view-round:after{display:none}@keyframes pulse{0%,to{opacity:.5}50%{opacity:.2}}.np_companion-disclaimer-text{-webkit-box-orient:vertical;-webkit-line-clamp:2;line-clamp:2;color:#fff;font-size:10px;line-height:12px;margin:auto auto 16px;max-width:940px;opacity:.7;overflow:hidden;padding:0 16px;text-align:center;z-index:12}.np_companion-disclaimer-text a{color:#fff}.np_companion-disclaimer-text a:hover{color:#fff;text-decoration:underline}.np_companion-disclaimer-text a:focus,.np_companion-disclaimer-text a:visited{color:#fff}.np_companion-action-btn-container-wrapper{pointer-events:auto;width:100%}.np_companion-avatar-control-container{backdrop-filter:blur(19px);background:none;background-color:rgba(52,51,51,.6);border-radius:16px;bottom:0;box-shadow:0 4px 4px 0 rgba(0,0,0,.25),2px 2px 8px 0 rgba(0,0,0,.12);left:50%;max-width:90%;min-width:210px;opacity:1;position:absolute;transform:translateX(-50%);transition:opacity .4s cubic-bezier(.4,0,.2,1);z-index:99}.np_companion-avatar-control-container.np_companion-action-btn-container-collapse{opacity:0}.np_companion-avatar-control-container:not(.np_companion-avatar-control-view-round){bottom:16px}.np_companion-avatar:not(.np_companion-bg-transparent) .np_companion-loader-spinner:not(.np_companion-view-silhouette){backdrop-filter:blur(19px);background-color:color-mix(in oklab,var(--np-loader-bg-color) 100%,transparent)!important;filter:none!important;height:100%;width:100%}.np_companion-loader-spinner .loader-container{left:50%;position:absolute;top:50%;transform:translate(-50%,-50%)}.np_companion-loader-spinner .loader-container .loader{--_m:conic-gradient(#0000 10%,#000),linear-gradient(#000 0 0) content-box;animation:l3 1s linear infinite;aspect-ratio:1;background:var(--np-loader-color);border-radius:50%;-webkit-mask:var(--_m);mask:var(--_m);-webkit-mask-composite:source-out;mask-composite:subtract;padding:4px;width:24px}@keyframes l3{to{transform:rotate(1turn)}}.np_companion-loader-spinner.np_companion-view-round .loader-container .loader{padding:4px;width:212px}.np_companion-bg-transparent .np_companion-loader-spinner .loader-container{display:none}.np_companion-controls-container{align-items:center;background:hsla(0,0%,100%,.3);border:.5px solid #fff;border-radius:12px;bottom:20px;box-shadow:0 1px 1px rgba(0,0,0,.267),0 2px 5px rgba(0,0,0,.267),0 3px 8px rgba(0,0,0,.267);display:flex;gap:8px;left:50%;max-width:360px;pointer-events:auto;position:absolute;transform:translateX(-50%);transform-origin:bottom center;transition:width .3s ease-in-out;-webkit-user-select:none;-moz-user-select:none;user-select:none;width:auto;z-index:99}.np_companion-controls-container.collapsed{gap:0}.np_companion-time-running{color:#fff}.np_companion-controls-time-action-btn-container{align-items:center;background:hsla(0,0%,100%,.1);border-radius:8px;display:flex;filter:grayscale(1);flex-shrink:0;gap:8px;height:32px;padding-left:8px;padding-right:8px;transition:filter .3s ease}.np_companion-controls-mic-control,.np_companion-controls-stop-control{cursor:pointer;display:flex;margin:0 5px;overflow:hidden;transition:opacity .3s ease-in-out,width .3s ease-in-out;width:47px}.np_companion-controls-mic-control.visible,.np_companion-controls-stop-control.visible{opacity:1}.np_companion-controls-mic-control.visible{width:1em}.np_companion-controls-stop-control.visible{width:1.5em}.np_companion-controls-mic-control.hidden,.np_companion-controls-stop-control.hidden{margin:0;opacity:0;padding:0;pointer-events:none;width:0}.np_companion-controls-mic-control:hover svg path{fill:red}.np_companion-controls-stop-control{display:flex;margin:0 5px 0 0}.np_companion-controls-stop-control:hover svg .stop-circle{fill:red}.np_companion-controls-stop-control:hover svg .stop-square{fill:#fff}.np_companion-mic-dropdown{background:#2b2c32;border-radius:4px;border-radius:6px;bottom:35px;box-shadow:0 10px 15px -3px rgba(0,0,0,.2),0 4px 6px -4px rgba(0,0,0,.2),0 0 0 1px #46464d;color:#fff;font-size:14px;list-style-type:none;margin:0;max-height:200px;min-width:300px;overflow-y:auto;overflow:auto;padding:5px;pointer-events:auto;position:absolute;width:auto;z-index:1000}.np_companion-mic-dropdown li{cursor:pointer;padding:8px 12px}.np_companion-mic-dropdown li:hover{background-color:#000}.np_companion-action-btn-container-container{background:transparent;border-radius:80px;gap:8px;padding:16px 16px 12px;transition:all .3s ease-in-out}.np_companion-action-btn-container-container.np_companion_disclaimer-disabled{padding-bottom:16px}.np_companion-action-btn-container-container .np_companion-chat-question-bar-container{border-radius:16px;gap:8px}.np_companion-action-btn-container-container .np_companion-action-btn-container-left{transition:all .3s ease-in-out;width:40px}.np_companion-action-btn-container-container .np_companion-action-btn-container-icon{border-radius:80px;cursor:pointer;height:40px;transition:all .3s ease-in-out;width:40px}.np_companion-dark-grey-bg{background:linear-gradient(0deg,#5e5e5e14 0 100%),#ffffff0f}.np_companion-grey-bg{background:linear-gradient(0deg,rgba(94,94,94,.07),rgba(94,94,94,.07)),hsla(0,0%,100%,.04)}.np_companion-action-btn-container-container .np_companion-action-btn-container-icon svg{height:auto;width:22px}.np_companion-action-btn-container-container .np_companion-action-btn-container-icon.muted svg.np_companion-mic-muted,.np_companion-action-btn-container-container .np_companion-action-btn-container-icon:not(.muted) svg.np_companion-mic-unmuted{display:flex}.np_companion-action-btn-container-container .np_companion-action-btn-container-middle .np_companion-action-btn-container-wave{display:flex;min-width:160px}.np_companion-action-btn-container-container .np_companion-action-btn-container-middle .np_companion-action-btn-container-wave canvas{height:40px;width:100%}.np_companion-action-btn-container-container .np_companion-action-btn-container-right{gap:8px;transition:all .3s ease-in-out}.np_companion-action-btn-container-container .np_companion-action-btn-container-left .np_companion-action-btn-container-icon:hover,.np_companion-action-btn-container-container .np_companion-action-btn-container-right .np_companion-action-btn-container-icon.active,.np_companion-action-btn-container-container .np_companion-action-btn-container-right .np_companion-action-btn-container-icon:hover{background-color:#fff!important}.np_companion-action-btn-container-container .np_companion-action-btn-container-left .np_companion-action-btn-container-icon:not(.np_companion-persist-fill-color):hover svg path{fill:#000}.np_companion-action-btn-container-container .np_companion-action-btn-container-right .np_companion-action-btn-container-icon.np_companion-action-btn-container-call-end svg{height:auto;width:16px}.np_companion-action-btn-container-container .np_companion-action-btn-container-right .np_companion-action-btn-container-icon:not(.np_companion-persist-fill-color).np_companion-action-btn-container-call-end:hover svg path{stroke:#000}.np_companion-action-btn-container-container .np_companion-action-btn-container-right .np_companion-action-btn-container-icon:not(.np_companion-persist-fill-color).active svg path,.np_companion-action-btn-container-container .np_companion-action-btn-container-right .np_companion-action-btn-container-icon:not(.np_companion-persist-fill-color).np_companion-action-btn-container-toggle:hover svg path,.np_companion-action-btn-container-container .np_companion-action-btn-container-right .np_companion-action-btn-container-icon:not(.np_companion-persist-fill-color):hover svg path{fill:#000}.np_companion-mobile-mode{bottom:15px;scale:.7}.np_companion-mobile-mode .np_companion-action-btn-container-container .np_companion-action-btn-container-middle{display:none}.np_companion-mobile-mode .np_companion-action-btn-container-left{opacity:1;width:40px}.np_companion-mobile-mode .np_companion-action-btn-container-right{opacity:1}.np_companion-action-btn-container-container .np_companion-action-btn-container-icon.np_companion-talking{background:rgba(52,199,89,.25);box-shadow:0 0 0 2px rgba(52,199,89,.4);transition:background .2s ease,box-shadow .2s ease}.np_companion-action-btn-container-container .np_companion-action-btn-container-icon.np_companion-talking svg path{fill:#34c759}.np_companion-inactive-overlay{align-items:center;bottom:0;display:flex;justify-content:center;left:0;pointer-events:auto;position:absolute;right:0;top:0;z-index:9999}.np_companion-inactive-dialog{backdrop-filter:blur(19px);background:hsla(0,0%,50%,.3);background-blend-mode:luminosity;border-radius:16px;max-width:500px;overflow:hidden;padding:24px 16px;position:relative;text-align:center;width:100%}.np_companion-inactive-dialog:before{background:linear-gradient(180deg,hsla(0,0%,100%,.4),hsla(0,0%,100%,0),hsla(0,0%,100%,0),hsla(0,0%,100%,.1));border-radius:16px;content:"";inset:0;-webkit-mask:linear-gradient(#fff 0 0) content-box,linear-gradient(#fff 0 0);-webkit-mask-composite:destination-out;mask-composite:exclude;padding:1.473px;pointer-events:none;position:absolute}.np_companion-inactive-message{color:#fff;font-size:16px;line-height:1.5;margin-bottom:24px;margin-top:0}.np_companion-inactive-timer{display:flex;justify-content:center;margin:24px 0;pointer-events:none}.np_companion-timer-circle{align-items:center;display:flex;height:80px;justify-content:center;position:relative;width:80px}.np_companion-timer-circle svg{overflow:visible;transform:rotate(-90deg)}.np_companion-timer-circle path{transition:stroke-dasharray .3s ease}.np_companion-timer-number{color:#fff;font-size:24px;font-weight:500;position:absolute}.np_companion-inactive-buttons{display:flex;gap:12px;justify-content:center}.np_companion-inactive-buttons button{border:none;border-radius:8px;cursor:pointer;font-size:14px;font-weight:500;padding:12px 24px;transition:all .2s ease}.np_companion-end-button{background:hsla(0,0%,100%,.1);color:#fff}.np_companion-end-button:hover{background:hsla(0,0%,100%,.2)}.np_companion-continue-button{background:#3c19cd;color:#fff}.np_companion-continue-button:hover{background:#2f13a0}
|
|
1
|
+
.np_companion-live-container,.np_companion-preview-container{height:100%;margin:0;padding:0;position:absolute;transition:opacity .3s ease-in-out;width:100%}.np_companion-preview-container{opacity:1;z-index:2}.np_companion-preview-container.np_companion-fade-out{opacity:0;pointer-events:none;transition:opacity .5s ease-out}.np_companion-live-container{opacity:0;z-index:1}.np_companion-live-container.np_companion-fade-in{opacity:1;z-index:3}:root{--base-border-radius:10px;--base-gap:20px}*,:after,:before{-webkit-box-sizing:border-box;box-sizing:border-box}::-webkit-input-placeholder{color:hsla(0,0%,100%,.4)}::-moz-placeholder{color:hsla(0,0%,100%,.4)}:-ms-input-placeholder{color:hsla(0,0%,100%,.4)}:-moz-placeholder{color:hsla(0,0%,100%,.4)}a,input{outline:none}body,html{background-color:transparent;background:transparent;margin:0;padding:0;width:100%}.np_companion-hide{display:none!important}.np_companion-align-middle{align-items:center;display:flex;justify-content:center}.np_companion-align-between{align-items:center;display:flex;justify-content:space-between}.np_companion-align-end{align-items:center;display:flex;justify-content:flex-end}.np_companion-align-start{align-items:flex-start;display:flex;justify-content:flex-start}.np_companion__d-none{display:none!important}#np_companion-sdk-root.np_companion-container-fixed{height:500px;position:fixed;transition:all .3s ease-in-out;width:400px;z-index:9999}#np_companion-sdk-root.np_companion-container-fixed.np_companion-view-rectangle{height:400px;width:340px}#np_companion-sdk-root.np_companion-container-fixed.np_companion-view-silhouette{height:400px}#np_companion-sdk-root.np_companion-container-fixed.np_companion-view-round{height:360px;width:250px}#np_companion-sdk-root.np_companion-container-fixed.np_companion-view-round.np_companion_disclaimer-disabled{height:320px!important}#np_companion-sdk-root.np_companion-container-fixed.np_companion-bottom-right{bottom:0;right:0}#np_companion-sdk-root.np_companion-container-fixed.np_companion-bottom-left{bottom:0;left:0}#np_companion-sdk-root.np_companion-container-fixed.np_companion-bottom-center{bottom:0;left:50%;transform:translateX(-50%)}#np_companion-sdk-root.np_companion-container-fixed.np_companion-top-right{right:0;top:0}#np_companion-sdk-root.np_companion-container-fixed.np_companion-top-left{left:0;top:0}#np_companion-sdk-root.np_companion-container-fixed.np_companion-top-center{left:50%;top:0;transform:translateX(-50%)}#np_companion-sdk-root.np_companion-container-fixed.np_companion-center{left:50%;top:50%;transform:translate(-50%,-50%)}.np_companion-avatar{height:100%;position:relative;width:100%}#np_companion-avatar-container{background:transparent;border-radius:var(--base-border-radius);height:100%;overflow:hidden;position:absolute;width:100%}#np_companion-avatar-container:not(.np_companion-view-silhouette){box-shadow:0 0 #0000,0 0 #0000,0 0 #0000,0 0 #0000,0 10px 15px -3px color-mix(in oklab,#00000080 100%,transparent),0 4px 6px -4px color-mix(in oklab,#00000080 100%,transparent)}.np_companion-avatar.np_companion-bg-transparent #np_companion-avatar-container.np_companion-view-silhouette{filter:drop-shadow(0 10px 15px rgba(0,0,0,.5)) drop-shadow(0 4px 6px rgba(0,0,0,.5))}.np_companion-container-fixed #np_companion-avatar-container.np_companion-view-round{border-radius:50%;height:212px;left:50%;transform:translate(-50%,12%);width:212px}.np_companion-container-fixed #np_companion-avatar-container.np_companion-view-rectangle,.np_companion-container-fixed #np_companion-avatar-container.np_companion-view-silhouette{left:50%;transform:translateX(-50%)}.np_companion-avatar-video{height:100%;inset:0;object-fit:cover;pointer-events:none;position:absolute;transition:opacity .3s ease-in-out;width:100%;z-index:10}.np_companion-avatar-video.no-opacity{opacity:0}.np_companion-avatar-canvas{background:transparent;height:100%;object-fit:cover;position:relative;width:100%;z-index:1}.np_companion-container-fixed #np_companion-avatar-container.np_companion-loader-pulse:after{animation:pulse 1.5s ease-in-out infinite;background-color:var(--np-loader-bg-color);border-radius:var(--base-border-radius);content:"";display:block;height:100%;left:0;opacity:.6;overflow:hidden;position:absolute;top:0;width:100%}.np_companion-avatar.np_companion-bg-transparent #np_companion-avatar-container:after{display:none}.np_companion-avatar:has(#np_companion-avatar-container.np_companion-view-round):after{display:none}#np_companion-avatar-container.np_companion-loader-pulse.loader-container.np_companion-view-round:after{animation:pulse 1.5s ease-in-out infinite;background-color:var(--np-loader-bg-color);border-radius:50%;content:"";display:block;height:100%;left:0;opacity:.6;overflow:hidden;position:absolute;top:0;width:100%}.np_companion-avatar.np_companion-bg-transparent #np_companion-avatar-container.np_companion-view-round:after{display:none}@keyframes pulse{0%,to{opacity:.5}50%{opacity:.2}}.np_companion-disclaimer-text{-webkit-box-orient:vertical;-webkit-line-clamp:2;line-clamp:2;color:#fff;font-size:10px;line-height:12px;margin:auto auto 16px;max-width:940px;opacity:.7;overflow:hidden;padding:0 16px;text-align:center;z-index:12}.np_companion-disclaimer-text a{color:#fff}.np_companion-disclaimer-text a:hover{color:#fff;text-decoration:underline}.np_companion-disclaimer-text a:focus,.np_companion-disclaimer-text a:visited{color:#fff}.np_companion-action-btn-container-wrapper{pointer-events:auto;width:100%}.np_companion-avatar-control-container{backdrop-filter:blur(19px);background:none;background-color:rgba(52,51,51,.6);border-radius:16px;bottom:0;box-shadow:0 4px 4px 0 rgba(0,0,0,.25),2px 2px 8px 0 rgba(0,0,0,.12);left:50%;max-width:90%;min-width:210px;opacity:1;position:absolute;transform:translateX(-50%);transition:opacity .4s cubic-bezier(.4,0,.2,1);z-index:99}.np_companion-avatar-control-container.np_companion-action-btn-container-collapse{opacity:0}.np_companion-avatar-control-container:not(.np_companion-avatar-control-view-round){bottom:16px}.np_companion-avatar:not(.np_companion-bg-transparent) .np_companion-loader-spinner:not(.np_companion-view-silhouette){backdrop-filter:blur(19px);background-color:color-mix(in oklab,var(--np-loader-bg-color) 100%,transparent)!important;filter:none!important;height:100%;width:100%}.np_companion-loader-spinner .loader-container{left:50%;position:absolute;top:50%;transform:translate(-50%,-50%)}.np_companion-loader-spinner .loader-container .loader{--_m:conic-gradient(#0000 10%,#000),linear-gradient(#000 0 0) content-box;animation:l3 1s linear infinite;aspect-ratio:1;background:var(--np-loader-color);border-radius:50%;-webkit-mask:var(--_m);mask:var(--_m);-webkit-mask-composite:source-out;mask-composite:subtract;padding:4px;width:24px}@keyframes l3{to{transform:rotate(1turn)}}.np_companion-loader-spinner.np_companion-view-round .loader-container .loader{padding:4px;width:212px}.np_companion-bg-transparent .np_companion-loader-spinner .loader-container{display:none}.np_companion-controls-container{align-items:center;background:hsla(0,0%,100%,.3);border:.5px solid #fff;border-radius:12px;bottom:20px;box-shadow:0 1px 1px rgba(0,0,0,.267),0 2px 5px rgba(0,0,0,.267),0 3px 8px rgba(0,0,0,.267);display:flex;gap:8px;left:50%;max-width:360px;pointer-events:auto;position:absolute;transform:translateX(-50%);transform-origin:bottom center;transition:width .3s ease-in-out;-webkit-user-select:none;-moz-user-select:none;user-select:none;width:auto;z-index:99}.np_companion-controls-container.collapsed{gap:0}.np_companion-time-running{color:#fff}.np_companion-controls-time-action-btn-container{align-items:center;background:hsla(0,0%,100%,.1);border-radius:8px;display:flex;filter:grayscale(1);flex-shrink:0;gap:8px;height:32px;padding-left:8px;padding-right:8px;transition:filter .3s ease}.np_companion-controls-mic-control,.np_companion-controls-stop-control{cursor:pointer;display:flex;margin:0 5px;overflow:hidden;transition:opacity .3s ease-in-out,width .3s ease-in-out;width:47px}.np_companion-controls-mic-control.visible,.np_companion-controls-stop-control.visible{opacity:1}.np_companion-controls-mic-control.visible{width:1em}.np_companion-controls-stop-control.visible{width:1.5em}.np_companion-controls-mic-control.hidden,.np_companion-controls-stop-control.hidden{margin:0;opacity:0;padding:0;pointer-events:none;width:0}.np_companion-controls-mic-control:hover svg path{fill:red}.np_companion-controls-stop-control{display:flex;margin:0 5px 0 0}.np_companion-controls-stop-control:hover svg .stop-circle{fill:red}.np_companion-controls-stop-control:hover svg .stop-square{fill:#fff}.np_companion-mic-dropdown{background:#2b2c32;border-radius:4px;border-radius:6px;bottom:35px;box-shadow:0 10px 15px -3px rgba(0,0,0,.2),0 4px 6px -4px rgba(0,0,0,.2),0 0 0 1px #46464d;color:#fff;font-size:14px;list-style-type:none;margin:0;max-height:200px;min-width:300px;overflow-y:auto;overflow:auto;padding:5px;pointer-events:auto;position:absolute;width:auto;z-index:1000}.np_companion-mic-dropdown li{cursor:pointer;padding:8px 12px}.np_companion-mic-dropdown li:hover{background-color:#000}.np_companion-action-btn-container-container{background:transparent;border-radius:80px;gap:8px;padding:16px 16px 12px;transition:all .3s ease-in-out}.np_companion-action-btn-container-container.np_companion_disclaimer-disabled{padding-bottom:16px}.np_companion-action-btn-container-container .np_companion-chat-question-bar-container{border-radius:16px;gap:8px}.np_companion-action-btn-container-container .np_companion-action-btn-container-left{transition:all .3s ease-in-out;width:40px}.np_companion-action-btn-container-container .np_companion-action-btn-container-icon{border-radius:80px;cursor:pointer;height:40px;transition:all .3s ease-in-out;width:40px}.np_companion-dark-grey-bg{background:linear-gradient(0deg,#5e5e5e14 0 100%),#ffffff0f}.np_companion-grey-bg{background:linear-gradient(0deg,rgba(94,94,94,.07),rgba(94,94,94,.07)),hsla(0,0%,100%,.04)}.np_companion-action-btn-container-container .np_companion-action-btn-container-icon svg{height:auto;width:22px}.np_companion-action-btn-container-container .np_companion-action-btn-container-icon.muted svg.np_companion-mic-muted,.np_companion-action-btn-container-container .np_companion-action-btn-container-icon:not(.muted) svg.np_companion-mic-unmuted{display:flex}.np_companion-action-btn-container-container .np_companion-action-btn-container-middle .np_companion-action-btn-container-wave{display:flex;min-width:160px}.np_companion-action-btn-container-container .np_companion-action-btn-container-middle .np_companion-action-btn-container-wave canvas{height:40px;width:100%}.np_companion-action-btn-container-container .np_companion-action-btn-container-right{gap:8px;transition:all .3s ease-in-out}.np_companion-action-btn-container-container .np_companion-action-btn-container-left .np_companion-action-btn-container-icon:hover,.np_companion-action-btn-container-container .np_companion-action-btn-container-right .np_companion-action-btn-container-icon.active,.np_companion-action-btn-container-container .np_companion-action-btn-container-right .np_companion-action-btn-container-icon:hover{background-color:#fff!important}.np_companion-action-btn-container-container .np_companion-action-btn-container-left .np_companion-action-btn-container-icon:not(.np_companion-persist-fill-color):hover svg path{fill:#000}.np_companion-action-btn-container-container .np_companion-action-btn-container-right .np_companion-action-btn-container-icon.np_companion-action-btn-container-call-end svg{height:auto;width:16px}.np_companion-action-btn-container-container .np_companion-action-btn-container-right .np_companion-action-btn-container-icon:not(.np_companion-persist-fill-color).np_companion-action-btn-container-call-end:hover svg path{stroke:#000}.np_companion-action-btn-container-container .np_companion-action-btn-container-right .np_companion-action-btn-container-icon:not(.np_companion-persist-fill-color).active svg path,.np_companion-action-btn-container-container .np_companion-action-btn-container-right .np_companion-action-btn-container-icon:not(.np_companion-persist-fill-color).np_companion-action-btn-container-toggle:hover svg path,.np_companion-action-btn-container-container .np_companion-action-btn-container-right .np_companion-action-btn-container-icon:not(.np_companion-persist-fill-color):hover svg path{fill:#000}.np_companion-mobile-mode{bottom:15px;scale:.7}.np_companion-mobile-mode .np_companion-action-btn-container-container .np_companion-action-btn-container-middle{display:none}.np_companion-mobile-mode .np_companion-action-btn-container-left{opacity:1;width:40px}.np_companion-mobile-mode .np_companion-action-btn-container-right{opacity:1}.np_companion-action-btn-container-container .np_companion-action-btn-container-icon.np_companion-talking{background:rgba(52,199,89,.25);box-shadow:0 0 0 2px rgba(52,199,89,.4);transition:background .2s ease,box-shadow .2s ease}.np_companion-action-btn-container-container .np_companion-action-btn-container-icon.np_companion-talking svg path{fill:#34c759}.np_companion-inactive-overlay{align-items:center;bottom:0;display:flex;justify-content:center;left:0;pointer-events:auto;position:absolute;right:0;top:0;z-index:9999}.np_companion-inactive-dialog{backdrop-filter:blur(19px);background:hsla(0,0%,50%,.3);background-blend-mode:luminosity;border-radius:16px;max-width:500px;overflow:hidden;padding:24px 16px;position:relative;text-align:center;width:100%}.np_companion-inactive-dialog:before{background:linear-gradient(180deg,hsla(0,0%,100%,.4),hsla(0,0%,100%,0),hsla(0,0%,100%,0),hsla(0,0%,100%,.1));border-radius:16px;content:"";inset:0;-webkit-mask:linear-gradient(#fff 0 0) content-box,linear-gradient(#fff 0 0);-webkit-mask-composite:destination-out;mask-composite:exclude;padding:1.473px;pointer-events:none;position:absolute}.np_companion-inactive-message{color:#fff;font-size:16px;line-height:1.5;margin-bottom:24px;margin-top:0}.np_companion-inactive-timer{display:flex;justify-content:center;margin:24px 0;pointer-events:none}.np_companion-timer-circle{align-items:center;display:flex;height:80px;justify-content:center;position:relative;width:80px}.np_companion-timer-circle svg{height:100%;transform:rotate(-90deg);width:100%}.np_companion-timer-circle path{transition:stroke-dasharray .3s ease}.np_companion-timer-number{color:#fff;font-size:24px;font-weight:500;position:absolute}.np_companion-inactive-buttons{display:flex;gap:12px;justify-content:center}.np_companion-inactive-buttons button{border:none;border-radius:8px;cursor:pointer;font-size:14px;font-weight:500;padding:12px 24px;transition:all .2s ease}.np_companion-end-button{background:hsla(0,0%,100%,.1);color:#fff}.np_companion-end-button:hover{background:hsla(0,0%,100%,.2)}.np_companion-continue-button{background:#3c19cd;color:#fff}.np_companion-continue-button:hover{background:#2f13a0}
|
package/lib/index.standalone.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).napsterCompanionApiSDK=t()}(this,function(){"use strict";class e extends Error{constructor(e,t,n){super(e),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"timestamp",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"context",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name="SDKError",this.code=t,this.timestamp=new Date,this.context=n,Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}toJSON(){return{name:this.name,message:this.message,code:this.code,timestamp:this.timestamp.toISOString(),context:this.context,stack:this.stack}}}class t extends e{constructor(e,t){super(e,"INITIALIZATION_ERROR",t),this.name="InitializationError"}}class n extends e{constructor(e,t){super(e,"TOKEN_ERROR",t),this.name="TokenError"}}class o extends e{constructor(e,t){super(e,"CONNECTION_ERROR",t),this.name="ConnectionError"}}class a extends e{constructor(e,t){super(e,"WEBRTC_ERROR",t),this.name="WebRTCError"}}class i extends e{constructor(e,t){super(e,"FEATURE_ERROR",t),this.name="FeatureError"}}class r extends e{constructor(e,t){super(e,"MEDIA_ERROR",t),this.name="MediaError"}}class s extends e{constructor(e,t,n){super(e,t,n),this.name="FaceTrackingError"}}var c,l;!function(e){e.ALREADY_INITIALIZED="ALREADY_INITIALIZED",e.INVALID_TOKEN="INVALID_TOKEN",e.REACT_VERSION_UNSUPPORTED="REACT_VERSION_UNSUPPORTED",e.CONTAINER_NOT_FOUND="CONTAINER_NOT_FOUND",e.CONNECTION_FAILED="CONNECTION_FAILED",e.TOKEN_GENERATION_FAILED="TOKEN_GENERATION_FAILED",e.MISSING_CREDENTIALS="MISSING_CREDENTIALS",e.WEBRTC_NOT_SUPPORTED="WEBRTC_NOT_SUPPORTED",e.PEER_CONNECTION_FAILED="PEER_CONNECTION_FAILED",e.DATA_CHANNEL_ERROR="DATA_CHANNEL_ERROR",e.API_REQUEST_FAILED="API_REQUEST_FAILED",e.INVALID_RESPONSE="INVALID_RESPONSE",e.RATE_LIMITED="RATE_LIMITED",e.INVALID_CONFIGURATION="INVALID_CONFIGURATION",e.MISSING_REQUIRED_CONFIG="MISSING_REQUIRED_CONFIG",e.FEATURE_NOT_SUPPORTED="FEATURE_NOT_SUPPORTED",e.FEATURE_DISABLED="FEATURE_DISABLED",e.MEDIA_ACCESS_DENIED="MEDIA_ACCESS_DENIED",e.MEDIA_DEVICE_ERROR="MEDIA_DEVICE_ERROR",e.VIDEO_LOAD_ERROR="VIDEO_LOAD_ERROR",e.CAMERA_PERMISSION_DENIED="CAMERA_PERMISSION_DENIED",e.CAMERA_NOT_FOUND="CAMERA_NOT_FOUND",e.MODEL_LOAD_FAILED="MODEL_LOAD_FAILED",e.DETECTION_FAILED="DETECTION_FAILED"}(c||(c={}));class d{static setErrorHandler(e){this.onError=e}static handle(t,n){let o;return function(t){return t instanceof e}(t)?(o=t,n&&(o.context={...o.context,...n})):o=t instanceof Error?new e(t.message,"UNKNOWN_ERROR",{originalError:t.name,...n}):new e("string"==typeof t?t:"Unknown error occurred","UNKNOWN_ERROR",{originalError:t,...n}),this.onError?.(o),o}}function p(e){return`Minified Redux error #${e}; visit https://redux.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}!function(e){e.BOTTOM_RIGHT="bottom-right",e.BOTTOM_CENTER="bottom-center",e.BOTTOM_LEFT="bottom-left",e.TOP_RIGHT="top-right",e.TOP_CENTER="top-center",e.TOP_LEFT="top-left",e.CENTER="center"}(l||(l={}));var u=(()=>"function"==typeof Symbol&&Symbol.observable||"@@observable")(),h=()=>Math.random().toString(36).substring(7).split("").join("."),f={INIT:`@@redux/INIT${h()}`,REPLACE:`@@redux/REPLACE${h()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${h()}`};function m(e){if("object"!=typeof e||null===e)return!1;let t=e;for(;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t||null===Object.getPrototypeOf(e)}function g(e,t,n){if("function"!=typeof e)throw new Error(p(2));if("function"==typeof t&&"function"==typeof n||"function"==typeof n&&"function"==typeof arguments[3])throw new Error(p(0));if("function"==typeof t&&void 0===n&&(n=t,t=void 0),void 0!==n){if("function"!=typeof n)throw new Error(p(1));return n(g)(e,t)}let o=e,a=t,i=new Map,r=i,s=0,c=!1;function l(){r===i&&(r=new Map,i.forEach((e,t)=>{r.set(t,e)}))}function d(){if(c)throw new Error(p(3));return a}function h(e){if("function"!=typeof e)throw new Error(p(4));if(c)throw new Error(p(5));let t=!0;l();const n=s++;return r.set(n,e),function(){if(t){if(c)throw new Error(p(6));t=!1,l(),r.delete(n),i=null}}}function v(e){if(!m(e))throw new Error(p(7));if(void 0===e.type)throw new Error(p(8));if("string"!=typeof e.type)throw new Error(p(17));if(c)throw new Error(p(9));try{c=!0,a=o(a,e)}finally{c=!1}return(i=r).forEach(e=>{e()}),e}return v({type:f.INIT}),{dispatch:v,subscribe:h,getState:d,replaceReducer:function(e){if("function"!=typeof e)throw new Error(p(10));o=e,v({type:f.REPLACE})},[u]:function(){const e=h;return{subscribe(t){if("object"!=typeof t||null===t)throw new Error(p(11));function n(){t.next&&t.next(d())}return n(),{unsubscribe:e(n)}},[u](){return this}}}}}function v(...e){return 0===e.length?e=>e:1===e.length?e[0]:e.reduce((e,t)=>(...n)=>e(t(...n)))}var b=Symbol.for("immer-nothing"),y=Symbol.for("immer-draftable"),_=Symbol.for("immer-state");function w(e,...t){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var S=Object,C=S.getPrototypeOf,E="constructor",x="prototype",k="configurable",T="enumerable",I="writable",O="value",N=e=>!!e&&!!e[_];function A(e){return!!e&&(P(e)||z(e)||!!e[y]||!!e[E]?.[y]||W(e)||U(e))}var D=S[x][E].toString(),R=new WeakMap;function P(e){if(!e||!H(e))return!1;const t=C(e);if(null===t||t===S[x])return!0;const n=S.hasOwnProperty.call(t,E)&&t[E];if(n===Object)return!0;if(!$(n))return!1;let o=R.get(n);return void 0===o&&(o=Function.toString.call(n),R.set(n,o)),o===D}function L(e,t,n=!0){0===M(e)?(n?Reflect.ownKeys(e):S.keys(e)).forEach(n=>{t(n,e[n],e)}):e.forEach((n,o)=>t(o,n,e))}function M(e){const t=e[_];return t?t.type_:z(e)?1:W(e)?2:U(e)?3:0}var j=(e,t,n=M(e))=>2===n?e.has(t):S[x].hasOwnProperty.call(e,t),F=(e,t,n=M(e))=>2===n?e.get(t):e[t],V=(e,t,n,o=M(e))=>{2===o?e.set(t,n):3===o?e.add(n):e[t]=n},z=Array.isArray,W=e=>e instanceof Map,U=e=>e instanceof Set,H=e=>"object"==typeof e,$=e=>"function"==typeof e,B=e=>"boolean"==typeof e,K=e=>e.copy_||e.base_,G=e=>e.modified_?e.copy_:e.base_;function q(e,t){if(W(e))return new Map(e);if(U(e))return new Set(e);if(z(e))return Array[x].slice.call(e);const n=P(e);if(!0===t||"class_only"===t&&!n){const t=S.getOwnPropertyDescriptors(e);delete t[_];let n=Reflect.ownKeys(t);for(let o=0;o<n.length;o++){const a=n[o],i=t[a];!1===i[I]&&(i[I]=!0,i[k]=!0),(i.get||i.set)&&(t[a]={[k]:!0,[I]:!0,[T]:i[T],[O]:e[a]})}return S.create(C(e),t)}{const t=C(e);if(null!==t&&n)return{...e};const o=S.create(t);return S.assign(o,e)}}function Q(e,t=!1){return J(e)||N(e)||!A(e)||(M(e)>1&&S.defineProperties(e,{set:Z,add:Z,clear:Z,delete:Z}),S.freeze(e),t&&L(e,(e,t)=>{Q(t,!0)},!1)),e}var Z={[O]:function(){w(2)}};function J(e){return null===e||!H(e)||S.isFrozen(e)}var Y="MapSet",X="Patches",ee={};function te(e){const t=ee[e];return t||w(0),t}var ne,oe=e=>!!ee[e],ae=()=>ne;function ie(e,t){t&&(e.patchPlugin_=te(X),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function re(e){se(e),e.drafts_.forEach(le),e.drafts_=null}function se(e){e===ne&&(ne=e.parent_)}var ce=e=>ne=((e,t)=>({drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:oe(Y)?te(Y):void 0}))(ne,e);function le(e){const t=e[_];0===t.type_||1===t.type_?t.revoke_():t.revoked_=!0}function de(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];if(void 0!==e&&e!==n){n[_].modified_&&(re(t),w(4)),A(e)&&(e=pe(t,e));const{patchPlugin_:o}=t;o&&o.generateReplacementPatches_(n[_].base_,e,t)}else e=pe(t,n);return function(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&Q(t,n)}(t,e,!0),re(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==b?e:void 0}function pe(e,t){if(J(t))return t;const n=t[_];if(!n)return ve(t,e.handledSet_,e);if(!he(n,e))return t;if(!n.modified_)return n.base_;if(!n.finalized_){const{callbacks_:t}=n;if(t)for(;t.length>0;)t.pop()(e);ge(n,e)}return n.copy_}function ue(e){e.finalized_=!0,e.scope_.unfinalizedDrafts_--}var he=(e,t)=>e.scope_===t,fe=[];function me(e,t,n,o){const a=K(e),i=e.type_;if(void 0!==o&&F(a,o,i)===t)return void V(a,o,n,i);if(!e.draftLocations_){const t=e.draftLocations_=new Map;L(a,(e,n)=>{if(N(n)){const o=t.get(n)||[];o.push(e),t.set(n,o)}})}const r=e.draftLocations_.get(t)??fe;for(const e of r)V(a,e,n,i)}function ge(e,t){if(e.modified_&&!e.finalized_&&(3===e.type_||(e.assigned_?.size??0)>0)){const{patchPlugin_:n}=t;if(n){const o=n.getPath(e);o&&n.generatePatches_(e,o,t)}ue(e)}}function ve(e,t,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||N(e)||t.has(e)||!A(e)||J(e)||(t.add(e),L(e,(o,a)=>{if(N(a)){const t=a[_];if(he(t,n)){const n=G(t);V(e,o,n,e.type_),ue(t)}}else A(a)&&ve(a,t,n)})),e}var be={get(e,t){if(t===_)return e;const n=K(e);if(!j(n,t,e.type_))return function(e,t,n){const o=we(t,n);return o?O in o?o[O]:o.get?.call(e.draft_):void 0}(e,n,t);const o=n[t];if(e.finalized_||!A(o))return o;if(o===_e(e.base_,t)){Ce(e);const n=1===e.type_?+t:t,a=Ee(0,o,e,n);return e.copy_[n]=a}return o},has:(e,t)=>t in K(e),ownKeys:e=>Reflect.ownKeys(K(e)),set(e,t,n){const o=we(K(e),t);if(o?.set)return o.set.call(e.draft_,n),!0;if(!e.modified_){const o=_e(K(e),t),a=o?.[_];if(a&&a.base_===n)return e.copy_[t]=n,e.assigned_.set(t,!1),!0;if(function(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}(n,o)&&(void 0!==n||j(e.base_,t,e.type_)))return!0;Ce(e),Se(e)}return e.copy_[t]===n&&(void 0!==n||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_.set(t,!0),function(e,t,n){const{scope_:o}=e;if(N(n)){const a=n[_];he(a,o)&&a.callbacks_.push(function(){Ce(e);const o=G(a);me(e,n,o,t)})}else A(n)&&e.callbacks_.push(function(){const a=K(e);F(a,t,e.type_)===n&&o.drafts_.length>1&&!0===(e.assigned_.get(t)??!1)&&e.copy_&&ve(F(e.copy_,t,e.type_),o.handledSet_,o)})}(e,t,n)),!0},deleteProperty:(e,t)=>(Ce(e),void 0!==_e(e.base_,t)||t in e.base_?(e.assigned_.set(t,!1),Se(e)):e.assigned_.delete(t),e.copy_&&delete e.copy_[t],!0),getOwnPropertyDescriptor(e,t){const n=K(e),o=Reflect.getOwnPropertyDescriptor(n,t);return o?{[I]:!0,[k]:1!==e.type_||"length"!==t,[T]:o[T],[O]:n[t]}:o},defineProperty(){w(11)},getPrototypeOf:e=>C(e.base_),setPrototypeOf(){w(12)}},ye={};function _e(e,t){const n=e[_];return(n?K(n):e)[t]}function we(e,t){if(!(t in e))return;let n=C(e);for(;n;){const e=Object.getOwnPropertyDescriptor(n,t);if(e)return e;n=C(n)}}function Se(e){e.modified_||(e.modified_=!0,e.parent_&&Se(e.parent_))}function Ce(e){e.copy_||(e.assigned_=new Map,e.copy_=q(e.base_,e.scope_.immer_.useStrictShallowCopy_))}function Ee(e,t,n,o){const[a,i]=W(t)?te(Y).proxyMap_(t,n):U(t)?te(Y).proxySet_(t,n):function(e,t){const n=z(e),o={type_:n?1:0,scope_:t?t.scope_:ae(),modified_:!1,finalized_:!1,assigned_:void 0,parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1,callbacks_:void 0};let a=o,i=be;n&&(a=[o],i=ye);const{revoke:r,proxy:s}=Proxy.revocable(a,i);return o.draft_=s,o.revoke_=r,[s,o]}(t,n);return(n?.scope_??ae()).drafts_.push(a),i.callbacks_=n?.callbacks_??[],i.key_=o,n&&void 0!==o?function(e,t,n){e.callbacks_.push(function(o){const a=t;if(!a||!he(a,o))return;o.mapSetPlugin_?.fixSetContents(a);const i=G(a);me(e,a.draft_??a,i,n),ge(a,o)})}(n,i,o):i.callbacks_.push(function(e){e.mapSetPlugin_?.fixSetContents(i);const{patchPlugin_:t}=e;i.modified_&&t&&t.generatePatches_(i,[],e)}),a}function xe(e){if(!A(e)||J(e))return e;const t=e[_];let n,o=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=q(e,t.scope_.immer_.useStrictShallowCopy_),o=t.scope_.immer_.shouldUseStrictIteration()}else n=q(e,!0);return L(n,(e,t)=>{V(n,e,xe(t))},o),t&&(t.finalized_=!1),n}L(be,(e,t)=>{ye[e]=function(){const e=arguments;return e[0]=e[0][0],t.apply(this,e)}}),ye.deleteProperty=function(e,t){return ye.set.call(this,e,t,void 0)},ye.set=function(e,t,n){return be.set.call(this,e[0],t,n,e[0])};var ke=(new class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(e,t,n)=>{if($(e)&&!$(t)){const n=t;t=e;const o=this;return function(e=n,...a){return o.produce(e,e=>t.call(this,e,...a))}}let o;if($(t)||w(6),void 0===n||$(n)||w(7),A(e)){const a=ce(this),i=Ee(0,e,void 0);let r=!0;try{o=t(i),r=!1}finally{r?re(a):se(a)}return ie(a,n),de(o,a)}if(!e||!H(e)){if(o=t(e),void 0===o&&(o=e),o===b&&(o=void 0),this.autoFreeze_&&Q(o,!0),n){const t=[],a=[];te(X).generateReplacementPatches_(e,o,{patches_:t,inversePatches_:a}),n(t,a)}return o}w(1)},this.produceWithPatches=(e,t)=>{if($(e))return(t,...n)=>this.produceWithPatches(t,t=>e(t,...n));let n,o;return[this.produce(e,t,(e,t)=>{n=e,o=t}),n,o]},B(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),B(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),B(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){A(e)||w(8),N(e)&&(e=function(e){return N(e)||w(10),xe(e)}(e));const t=ce(this),n=Ee(0,e,void 0);return n[_].isManual_=!0,se(t),n}finishDraft(e,t){const n=e&&e[_];n&&n.isManual_||w(9);const{scope_:o}=n;return ie(o,t),de(void 0,o)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}setUseStrictIteration(e){this.useStrictIteration_=e}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){const o=t[n];if(0===o.path.length&&"replace"===o.op){e=o.value;break}}n>-1&&(t=t.slice(n+1));const o=te(X).applyPatches_;return N(e)?o(e,t):this.produce(e,e=>o(e,t))}}).produce;function Te(e){return({dispatch:t,getState:n})=>o=>a=>"function"==typeof a?a(t,n,e):o(a)}var Ie=Te(),Oe=Te,Ne="undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(0!==arguments.length)return"object"==typeof arguments[0]?v:v.apply(null,arguments)};function Ae(e,t){function n(...n){if(t){let o=t(...n);if(!o)throw new Error(He(0));return{type:e,payload:o.payload,..."meta"in o&&{meta:o.meta},..."error"in o&&{error:o.error}}}return{type:e,payload:n[0]}}return n.toString=()=>`${e}`,n.type=e,n.match=t=>function(e){return m(e)&&"type"in e&&"string"==typeof e.type}(t)&&t.type===e,n}var De=class e extends Array{constructor(...t){super(...t),Object.setPrototypeOf(this,e.prototype)}static get[Symbol.species](){return e}concat(...e){return super.concat.apply(this,e)}prepend(...t){return 1===t.length&&Array.isArray(t[0])?new e(...t[0].concat(this)):new e(...t.concat(this))}};function Re(e){return A(e)?ke(e,()=>{}):e}function Pe(e,t,n){return e.has(t)?e.get(t):e.set(t,n(t)).get(t)}var Le=e=>t=>{setTimeout(t,e)};function Me(e){const t={},n=[];let o;const a={addCase(e,n){const o="string"==typeof e?e:e.type;if(!o)throw new Error(He(28));if(o in t)throw new Error(He(29));return t[o]=n,a},addAsyncThunk:(e,o)=>(o.pending&&(t[e.pending.type]=o.pending),o.rejected&&(t[e.rejected.type]=o.rejected),o.fulfilled&&(t[e.fulfilled.type]=o.fulfilled),o.settled&&n.push({matcher:e.settled,reducer:o.settled}),a),addMatcher:(e,t)=>(n.push({matcher:e,reducer:t}),a),addDefaultCase:e=>(o=e,a)};return e(a),[t,n,o]}var je=Symbol.for("rtk-slice-createasyncthunk");function Fe(e,t){return`${e}/${t}`}function Ve({creators:e}={}){const t=e?.asyncThunk?.[je];return function(e){const{name:n,reducerPath:o=n}=e;if(!n)throw new Error(He(11));const a=("function"==typeof e.reducers?e.reducers(function(){function e(e,t){return{_reducerDefinitionType:"asyncThunk",payloadCreator:e,...t}}return e.withTypes=()=>e,{reducer:e=>Object.assign({[e.name]:(...t)=>e(...t)}[e.name],{_reducerDefinitionType:"reducer"}),preparedReducer:(e,t)=>({_reducerDefinitionType:"reducerWithPrepare",prepare:e,reducer:t}),asyncThunk:e}}()):e.reducers)||{},i=Object.keys(a),r={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},s={addCase(e,t){const n="string"==typeof e?e:e.type;if(!n)throw new Error(He(12));if(n in r.sliceCaseReducersByType)throw new Error(He(13));return r.sliceCaseReducersByType[n]=t,s},addMatcher:(e,t)=>(r.sliceMatchers.push({matcher:e,reducer:t}),s),exposeAction:(e,t)=>(r.actionCreators[e]=t,s),exposeCaseReducer:(e,t)=>(r.sliceCaseReducersByName[e]=t,s)};function c(){const[t={},n=[],o]="function"==typeof e.extraReducers?Me(e.extraReducers):[e.extraReducers],a={...t,...r.sliceCaseReducersByType};return function(e){let t,[i,s,c]=Me(e=>{for(let t in a)e.addCase(t,a[t]);for(let t of r.sliceMatchers)e.addMatcher(t.matcher,t.reducer);for(let t of n)e.addMatcher(t.matcher,t.reducer);o&&e.addDefaultCase(o)});if(function(e){return"function"==typeof e}(e))t=()=>Re(e());else{const n=Re(e);t=()=>n}function l(e=t(),n){let o=[i[n.type],...s.filter(({matcher:e})=>e(n)).map(({reducer:e})=>e)];return 0===o.filter(e=>!!e).length&&(o=[c]),o.reduce((e,t)=>{if(t){if(N(e)){const o=t(e,n);return void 0===o?e:o}if(A(e))return ke(e,e=>t(e,n));{const o=t(e,n);if(void 0===o){if(null===e)return e;throw Error("A case reducer on a non-draftable value must not return undefined")}return o}}return e},e)}return l.getInitialState=t,l}(e.initialState)}i.forEach(o=>{const i=a[o],r={reducerName:o,type:Fe(n,o),createNotation:"function"==typeof e.reducers};!function(e){return"asyncThunk"===e._reducerDefinitionType}(i)?function({type:e,reducerName:t,createNotation:n},o,a){let i,r;if("reducer"in o){if(n&&!function(e){return"reducerWithPrepare"===e._reducerDefinitionType}(o))throw new Error(He(17));i=o.reducer,r=o.prepare}else i=o;a.addCase(e,i).exposeCaseReducer(t,i).exposeAction(t,r?Ae(e,r):Ae(e))}(r,i,s):function({type:e,reducerName:t},n,o,a){if(!a)throw new Error(He(18));const{payloadCreator:i,fulfilled:r,pending:s,rejected:c,settled:l,options:d}=n,p=a(e,i,d);o.exposeAction(t,p),r&&o.addCase(p.fulfilled,r),s&&o.addCase(p.pending,s),c&&o.addCase(p.rejected,c),l&&o.addMatcher(p.settled,l),o.exposeCaseReducer(t,{fulfilled:r||Ue,pending:s||Ue,rejected:c||Ue,settled:l||Ue})}(r,i,s,t)});const l=e=>e,d=new Map,p=new WeakMap;let u;function h(e,t){return u||(u=c()),u(e,t)}function f(){return u||(u=c()),u.getInitialState()}function m(t,n=!1){function o(e){let a=e[t];return void 0===a&&n&&(a=Pe(p,o,f)),a}function a(t=l){const o=Pe(d,n,()=>new WeakMap);return Pe(o,t,()=>{const o={};for(const[a,i]of Object.entries(e.selectors??{}))o[a]=ze(i,t,()=>Pe(p,t,f),n);return o})}return{reducerPath:t,getSelectors:a,get selectors(){return a(o)},selectSlice:o}}const g={name:n,reducer:h,actions:r.actionCreators,caseReducers:r.sliceCaseReducersByName,getInitialState:f,...m(o),injectInto(e,{reducerPath:t,...n}={}){const a=t??o;return e.inject({reducerPath:a,reducer:h},n),{...g,...m(a,!0)}}};return g}}function ze(e,t,n,o){function a(a,...i){let r=t(a);return void 0===r&&o&&(r=n()),e(r,...i)}return a.unwrapped=e,a}var We=Ve();function Ue(){}function He(e){return`Minified Redux Toolkit error #${e}; visit https://redux-toolkit.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}const $e=We({name:"avatar",initialState:{avatarReady:!1,dataChannel:null,stopInteraction:!1,muted:!1,volume:70,avatarSpeaking:!1,isScreenSharing:!1,isUserTalking:!1,transcript:void 0,customVoiceId:void 0,defaultVoiceId:void 0,connectionToken:void 0,companionId:void 0,closeConnectionHandler:void 0},reducers:{setSessionId:(e,t)=>{e.sessionId=t.payload},setAvatarReady:(e,t)=>{e.avatarReady=t.payload},setDataChannel:(e,t)=>{e.dataChannel=t.payload},setAvatarId:(e,t)=>{e.avatarId=t.payload},setVideoId:(e,t)=>{e.videoId=t.payload},setStopInteraction:(e,t)=>{e.stopInteraction=t.payload},setMuted:(e,t)=>{e.muted=t.payload},setVolume:(e,t)=>{e.volume=t.payload},setAvatarSpeaking:(e,t)=>{e.avatarSpeaking=t.payload},setScreenSharing:(e,t)=>{e.isScreenSharing=t.payload},setUserTalking:(e,t)=>{e.isUserTalking=t.payload},addTranscript:(e,t)=>{e.transcript=t.payload},setCustomVoiceId:(e,t)=>{e.customVoiceId=t.payload},setDefaultVoiceId:(e,t)=>{e.defaultVoiceId=t.payload},setConnectionToken:(e,t)=>{e.connectionToken=t.payload},setCloseConnectionHandler:(e,t)=>{e.closeConnectionHandler=t.payload}}}),{setSessionId:Be,setDataChannel:Ke,setStopInteraction:Ge,setMuted:qe,setVolume:Qe,setAvatarSpeaking:Ze,setScreenSharing:Je,setUserTalking:Ye,setConnectionToken:Xe,setCloseConnectionHandler:et}=$e.actions,tt=$e.reducer,nt={features:{backgroundRemoval:{enabled:!0},waveform:{enabled:!0,color:"#ffffff"},inactiveTimeout:{enabled:!0,duration:6e4,countdown:30},disclaimer:{enabled:!0,text:"This is an AI avatar. Check important info."},showSDKLoader:{enabled:!0,bgColor:"rgb(222 222 222 / 60%)",color:"#585858ff",type:"spinner"},pictureInPicture:{enabled:!1}},position:void 0,showExperience:!1,debugMode:!1},ot=We({name:"app",initialState:nt,reducers:{setFeatures:(e,t)=>{const{feature:n,config:o}=t.payload,a=e.features[n];e.features[n]={...a,...o,enabled:o?.enabled??!!a?.enabled}},resetFeatures:e=>{e.features=nt.features},setPosition:(e,t)=>{e.position=t.payload},setShowExperience:(e,t)=>{e.showExperience=t.payload},setDebugMode:(e,t)=>{e.debugMode=t.payload}}}),{setFeatures:at,resetFeatures:it,setPosition:rt,setDebugMode:st}=ot.actions;let ct=null;const lt=e=>{ct=e},dt=e=>t=>n=>{const o=e.getState().app.features,a=t(n),i=e.getState().app.features;return ct&&o!==i&&JSON.stringify(o)!==JSON.stringify(i)&&ct(i),a},pt=function(e){const t=function(e){const{thunk:t=!0,immutableCheck:n=!0,serializableCheck:o=!0,actionCreatorCheck:a=!0}=e??{};let i=new De;return t&&(function(e){return"boolean"==typeof e}(t)?i.push(Ie):i.push(Oe(t.extraArgument))),i},{reducer:n,middleware:o,devTools:a=!0,preloadedState:i,enhancers:r}=e||{};let s,c;if("function"==typeof n)s=n;else{if(!m(n))throw new Error(He(1));s=function(e){const t=Object.keys(e),n={};for(let o=0;o<t.length;o++){const a=t[o];"function"==typeof e[a]&&(n[a]=e[a])}const o=Object.keys(n);let a;try{!function(e){Object.keys(e).forEach(t=>{const n=e[t];if(void 0===n(void 0,{type:f.INIT}))throw new Error(p(12));if(void 0===n(void 0,{type:f.PROBE_UNKNOWN_ACTION()}))throw new Error(p(13))})}(n)}catch(e){a=e}return function(e={},t){if(a)throw a;let i=!1;const r={};for(let a=0;a<o.length;a++){const s=o[a],c=e[s],l=(0,n[s])(c,t);if(void 0===l)throw new Error(p(14));r[s]=l,i=i||l!==c}return i=i||o.length!==Object.keys(e).length,i?r:e}}(n)}c="function"==typeof o?o(t):t();let l=v;a&&(l=Ne({trace:!1,..."object"==typeof a&&a}));const d=function(...e){return t=>(n,o)=>{const a=t(n,o);let i=()=>{throw new Error(p(15))};const r={getState:a.getState,dispatch:(e,...t)=>i(e,...t)},s=e.map(e=>e(r));return i=v(...s)(a.dispatch),{...a,dispatch:i}}}(...c),u=(e=>function(t){const{autoBatch:n=!0}=t??{};let o=new De(e);return n&&o.push(((e={type:"raf"})=>t=>(...n)=>{const o=t(...n);let a=!0,i=!1,r=!1;const s=new Set,c="tick"===e.type?queueMicrotask:"raf"===e.type?"undefined"!=typeof window&&window.requestAnimationFrame?window.requestAnimationFrame:Le(10):"callback"===e.type?e.queueNotification:Le(e.timeout),l=()=>{r=!1,i&&(i=!1,s.forEach(e=>e()))};return Object.assign({},o,{subscribe(e){const t=o.subscribe(()=>a&&e());return s.add(e),()=>{t(),s.delete(e)}},dispatch(e){try{return a=!e?.meta?.RTK_autoBatch,i=!a,i&&(r||(r=!0,c(l))),o.dispatch(e)}finally{a=!0}}})})("object"==typeof n?n:void 0)),o})(d);return g(s,i,l(..."function"==typeof r?r(u):u()))}({reducer:{avatar:tt,app:ot.reducer},middleware:e=>e({serializableCheck:!1}).concat(dt)}),ut=e=>e.avatar.dataChannel;var ht;!function(e){e.INFO="info",e.WARN="warn",e.ERROR="error",e.DEBUG="debug"}(ht||(ht={}));const ft=new class{constructor(){Object.defineProperty(this,"prefix",{enumerable:!0,configurable:!0,writable:!0,value:"[Napster SDK]"})}isDebugEnabled(){try{return pt.getState().app.debugMode||!1}catch{return!1}}log(e,...t){if(!this.isDebugEnabled())return;const n=[this.prefix,...t];switch(e){case ht.INFO:console.info(...n);break;case ht.WARN:console.warn(...n);break;case ht.ERROR:console.error(...n);break;case ht.DEBUG:console.debug(...n)}}info(...e){this.log(ht.INFO,"ℹ️",...e)}debug(...e){this.log(ht.DEBUG,"🐞",...e)}warn(...e){this.log(ht.WARN,"⚠️",...e)}error(...e){this.log(ht.ERROR,"❌",...e)}critical_warn(...e){console.warn(this.prefix,"⚠️",...e)}critical_error(...e){console.error(this.prefix,"❌",...e)}webrtc(...e){this.log(ht.INFO,"📡 WebRTC:",...e)}avatar(...e){this.log(ht.INFO,"🎭 Avatar:",...e)}connection(...e){this.log(ht.INFO,"🔌 Connection:",...e)}features(...e){this.log(ht.INFO,"🔄 Features:",...e)}data(...e){this.log(ht.INFO,"📨 Data:",...e)}timer(...e){this.log(ht.INFO,"⏱️ Timer:",...e)}cleanup(...e){this.log(ht.INFO,"🗑️ Cleanup:",...e)}};function mt(...e){const t=[];for(const n of e)if(n)if("string"==typeof n||"number"==typeof n)t.push(String(n));else if(Array.isArray(n)){const e=mt(...n);e&&t.push(e)}else if("object"==typeof n)for(const[e,o]of Object.entries(n))o&&t.push(e);return t.join(" ")}const gt="np_companion-align-between",vt="np_companion-action-btn-container-collapse";class bt{static createElement(e,t){const n=document.createElement(e);return t?.className&&(n.className=t.className),t?.id&&(n.id=t.id),t?.attributes&&Object.entries(t.attributes).forEach(([e,t])=>{n.setAttribute(e,t)}),t?.styles&&Object.assign(n.style,t.styles),n}static createVideo(e){const t=this.createElement("video",{className:e.className});return t.autoplay=e.autoplay??!1,t.muted=e.muted??!1,t.loop=e.loop??!1,t.playsInline=e.playsInline??!1,e.crossOrigin&&(t.crossOrigin=e.crossOrigin),e.poster&&(t.poster=e.poster),e.src&&(t.src=e.src),t}static createAudio(e){const t=this.createElement("audio",{className:e.className});return t.autoplay=e.autoplay??!1,t}static createCanvas(e){const t=this.createElement("canvas",{className:e.className,styles:e.styles});return void 0!==e.width&&(t.width=e.width),void 0!==e.height&&(t.height=e.height),t}static createButton(e){const t=this.createElement("button",{className:e.className,attributes:e.attributes});return e.textContent&&(t.textContent=e.textContent),e.onClick&&t.addEventListener("click",e.onClick),t}static createDiv(e){return this.createElement("div",{className:e})}}class yt{static process(e){const t=e.data;return this.hasGreenScreen(t)?(this.removeGreenScreen(t),e):e}static hasGreenScreen(e){for(let t=0;t<e.length;t+=4)if(this.isGreenPixel(e[t],e[t+1],e[t+2]))return!0;return!1}static isGreenPixel(e,t,n){return e>=0&&e<=120&&t>=150&&t<=255&&n>=0&&n<=120}static removeGreenScreen(e){for(let t=0;t<e.length;t+=4){const n=e[t],o=e[t+1],a=e[t+2];this.isGreenPixel(n,o,a)?e[t+3]=0:this.reduceGreenSpill(e,t,n,o,a)}}static reduceGreenSpill(e,t,n,o,a){const i=o-Math.max(n,a);if(i>0){const r=.5*i;e[t]=Math.min(255,n+.8*r),e[t+2]=Math.min(255,a+.8*r),e[t+1]=Math.max(0,o-r)}}}const _t=new class{constructor(){Object.defineProperty(this,"svgNS",{enumerable:!0,configurable:!0,writable:!0,value:"http://www.w3.org/2000/svg"})}createElement(e){const t=document.createElementNS(this.svgNS,e.tag);return e.attributes&&Object.entries(e.attributes).forEach(([e,n])=>{t.setAttribute(e,String(n))}),e.textContent&&(t.textContent=e.textContent),e.children&&e.children.forEach(e=>{const n=this.createElement(e);t.appendChild(n)}),t}createSVG(e,t,n,o,a){const i=document.createElementNS(this.svgNS,"svg");return i.setAttribute("width",String(e)),i.setAttribute("height",String(t)),i.setAttribute("viewBox",n),i.setAttribute("fill","none"),i.setAttribute("xmlns",this.svgNS),a&&i.setAttribute("class",a),o.forEach(e=>{const t=this.createElement(e);i.appendChild(t)}),i}},wt={micUnmuted:()=>_t.createSVG(17,17,"0 0 17 17",[{tag:"g",attributes:{"clip-path":"url(#clip0_655_3824)"},children:[{tag:"path",attributes:{d:"M8.67241 11.8448C9.49524 11.844 10.2841 11.5167 10.8659 10.9349C11.4478 10.3531 11.775 9.5642 11.7759 8.74138V4.60345C11.7759 3.78036 11.4489 2.99099 10.8669 2.40898C10.2849 1.82697 9.4955 1.5 8.67241 1.5C7.84933 1.5 7.05995 1.82697 6.47794 2.40898C5.89594 2.99099 5.56897 3.78036 5.56897 4.60345V8.74138C5.56982 9.5642 5.89707 10.3531 6.47889 10.9349C7.06071 11.5167 7.84959 11.844 8.67241 11.8448ZM6.60345 4.60345C6.60345 4.05472 6.82143 3.52847 7.20943 3.14047C7.59744 2.75246 8.12369 2.53448 8.67241 2.53448C9.22114 2.53448 9.74739 2.75246 10.1354 3.14047C10.5234 3.52847 10.7414 4.05472 10.7414 4.60345V8.74138C10.7414 9.2901 10.5234 9.81635 10.1354 10.2044C9.74739 10.5924 9.22114 10.8103 8.67241 10.8103C8.12369 10.8103 7.59744 10.5924 7.20943 10.2044C6.82143 9.81635 6.60345 9.2901 6.60345 8.74138V4.60345ZM9.18965 13.8879V15.9828C9.18965 16.1199 9.13516 16.2515 9.03816 16.3485C8.94116 16.4455 8.80959 16.5 8.67241 16.5C8.53523 16.5 8.40367 16.4455 8.30667 16.3485C8.20967 16.2515 8.15517 16.1199 8.15517 15.9828V13.8879C6.87994 13.7582 5.69812 13.1601 4.83826 12.2095C3.9784 11.2589 3.50158 10.0232 3.5 8.74138C3.5 8.6042 3.5545 8.47264 3.6515 8.37563C3.7485 8.27863 3.88006 8.22414 4.01724 8.22414C4.15442 8.22414 4.28598 8.27863 4.38299 8.37563C4.47999 8.47264 4.53448 8.6042 4.53448 8.74138C4.53448 9.83883 4.97044 10.8913 5.74645 11.6673C6.52247 12.4434 7.57497 12.8793 8.67241 12.8793C9.76986 12.8793 10.8224 12.4434 11.5984 11.6673C12.3744 10.8913 12.8103 9.83883 12.8103 8.74138C12.8103 8.6042 12.8648 8.47264 12.9618 8.37563C13.0588 8.27863 13.1904 8.22414 13.3276 8.22414C13.4648 8.22414 13.5963 8.27863 13.6933 8.37563C13.7903 8.47264 13.8448 8.6042 13.8448 8.74138C13.8433 10.0232 13.3664 11.2589 12.5066 12.2095C11.6467 13.1601 10.4649 13.7582 9.18965 13.8879Z",fill:"white"}}]},{tag:"defs",children:[{tag:"clipPath",attributes:{id:"clip0_655_3824"},children:[{tag:"rect",attributes:{width:"16",height:"16",fill:"white",transform:"translate(0.5 0.5)"}}]}]}],"np_companion-mic-unmuted"),micMuted:()=>_t.createSVG(22,22,"0 0 17 18",[{tag:"g",attributes:{"clip-path":"url(#clip0_655_4192)"},children:[{tag:"path",attributes:{d:"M14.2432 14.6L3.89604 3.21808C3.80327 3.11843 3.67498 3.05936 3.53896 3.05368C3.40294 3.048 3.27016 3.09616 3.16941 3.18772C3.06866 3.27928 3.00806 3.40686 3.00075 3.5428C2.99343 3.67874 3.04 3.81208 3.13034 3.91392L5.58263 6.61131V8.7396C5.58251 9.26661 5.71656 9.78497 5.97216 10.2458C6.22776 10.7067 6.59649 11.0949 7.04361 11.3739C7.49073 11.6529 8.00151 11.8134 8.52782 11.8404C9.05414 11.8674 9.57867 11.7599 10.052 11.5282L10.7698 12.3171C10.138 12.6868 9.41878 12.8806 8.68679 12.8785C7.58946 12.8773 6.53741 12.4408 5.76148 11.6649C4.98555 10.889 4.54911 9.83693 4.54791 8.7396C4.54791 8.60239 4.4934 8.47079 4.39638 8.37377C4.29935 8.27675 4.16776 8.22224 4.03055 8.22224C3.89334 8.22224 3.76174 8.27675 3.66472 8.37377C3.5677 8.47079 3.51319 8.60239 3.51319 8.7396C3.51476 10.0217 3.9917 11.2577 4.85176 12.2085C5.71182 13.1594 6.8939 13.7575 8.16943 13.8873V15.9826C8.16943 16.1199 8.22394 16.2514 8.32096 16.3485C8.41798 16.4455 8.54958 16.5 8.68679 16.5C8.824 16.5 8.95559 16.4455 9.05262 16.3485C9.14964 16.2514 9.20415 16.1199 9.20415 15.9826V13.8867C10.0143 13.8085 10.794 13.5376 11.4779 13.0964L13.4775 15.2952C13.523 15.3464 13.5781 15.3881 13.6398 15.4178C13.7015 15.4476 13.7684 15.4648 13.8368 15.4685C13.9051 15.4722 13.9735 15.4622 14.038 15.4393C14.1025 15.4163 14.1618 15.3808 14.2125 15.3347C14.2632 15.2887 14.3042 15.2331 14.3332 15.171C14.3622 15.109 14.3786 15.0419 14.3815 14.9735C14.3843 14.9051 14.3736 14.8368 14.3499 14.7725C14.3261 14.7083 14.2899 14.6495 14.2432 14.5993V14.6ZM8.68679 10.809C8.13794 10.809 7.61157 10.591 7.22347 10.2029C6.83538 9.81482 6.61735 9.28845 6.61735 8.7396V7.7495L9.3115 10.7127C9.10943 10.7766 8.89873 10.8091 8.68679 10.809ZM12.4066 10.5562C12.6841 9.99093 12.8275 9.36929 12.8257 8.7396C12.8257 8.60239 12.8802 8.47079 12.9772 8.37377C13.0742 8.27675 13.2058 8.22224 13.343 8.22224C13.4802 8.22224 13.6118 8.27675 13.7089 8.37377C13.8059 8.47079 13.8604 8.60239 13.8604 8.7396C13.8625 9.52693 13.6831 10.3041 13.3359 11.0108C13.2934 11.0979 13.2273 11.1713 13.145 11.2226C13.0628 11.274 12.9679 11.3012 12.8709 11.3012C12.7922 11.3013 12.7145 11.2831 12.6439 11.2481C12.5207 11.1878 12.4265 11.0811 12.382 10.9513C12.3375 10.8215 12.3463 10.6794 12.4066 10.5562ZM5.84131 3.36358C6.12624 2.71004 6.62746 2.1745 7.26073 1.84696C7.894 1.51943 8.62071 1.41987 9.31874 1.56501C10.0168 1.71015 10.6435 2.09116 11.0938 2.64398C11.544 3.19681 11.7902 3.88776 11.7909 4.60072V8.7396C11.7908 8.8476 11.7852 8.95552 11.7741 9.06295C11.7608 9.19066 11.7005 9.30885 11.6049 9.39455C11.5092 9.48025 11.3852 9.52733 11.2568 9.52663C11.2387 9.52757 11.2205 9.52757 11.2025 9.52663C11.066 9.51229 10.9409 9.44435 10.8545 9.33775C10.7682 9.23115 10.7277 9.09462 10.742 8.95818C10.7491 8.88705 10.753 8.81332 10.753 8.74089V4.60072C10.7516 4.12605 10.5871 3.66628 10.2871 3.29848C9.98701 2.93069 9.56963 2.67722 9.10491 2.58058C8.64018 2.48393 8.15636 2.54998 7.73454 2.76766C7.31273 2.98534 6.97857 3.34141 6.78808 3.77618C6.7639 3.84253 6.72639 3.90322 6.67786 3.95452C6.62934 4.00583 6.57082 4.04665 6.50592 4.07449C6.44102 4.10232 6.37111 4.11658 6.30049 4.11637C6.22987 4.11617 6.16005 4.10151 6.09531 4.07329C6.03057 4.04508 5.9723 4.00392 5.92407 3.95233C5.87584 3.90075 5.83869 3.83983 5.81489 3.77335C5.7911 3.70686 5.78117 3.6362 5.78571 3.56573C5.79025 3.49526 5.80917 3.42646 5.84131 3.36358Z",fill:"white"}}]},{tag:"defs",children:[{tag:"clipPath",attributes:{id:"clip0_655_4192"},children:[{tag:"rect",attributes:{width:"16",height:"16",fill:"white",transform:"translate(0.5 0.5)"}}]}]}],"np_companion-mic-muted"),stop:()=>_t.createSVG(20,20,"0 0 32 32",[{tag:"path",attributes:{d:"M5.92 24.096q0 0.832 0.576 1.408t1.44 0.608h16.128q0.832 0 1.44-0.608t0.576-1.408v-16.16q0-0.832-0.576-1.44t-1.44-0.576h-16.128q-0.832 0-1.44 0.576t-0.576 1.44v16.16z",fill:"#ffffff"}}]),volumeHigh(e){const t=[{tag:"path",attributes:{d:"M80 416L128 416L262.1 535.2C268.5 540.9 276.7 544 285.2 544C304.4 544 320 528.4 320 509.2L320 130.8C320 111.6 304.4 96 285.2 96C276.7 96 268.5 99.1 262.1 104.8L128 224L80 224C53.5 224 32 245.5 32 272L32 368C32 394.5 53.5 416 80 416z",fill:"#ffffff"}}];return e>0&&t.push({tag:"path",attributes:{d:"M412.6 245.5C402.3 237.1 387.2 238.7 378.8 249C370.4 259.3 372 274.4 382.3 282.8C393.1 291.6 400 305 400 320C400 335 393.1 348.4 382.3 357.3C372 365.7 370.5 380.8 378.8 391.1C387.1 401.4 402.3 402.9 412.6 394.6C434.1 376.9 448 350.1 448 320C448 289.9 434.1 263.1 412.6 245.5z",fill:"#ffffff"}}),e>=25&&t.push({tag:"path",attributes:{d:"M473.1 171C462.8 162.6 447.7 164.2 439.3 174.5C430.9 184.8 432.5 199.9 442.8 208.3C475.3 234.7 496 274.9 496 320C496 365.1 475.3 405.3 442.8 431.8C432.5 440.2 431 455.3 439.3 465.6C447.6 475.9 462.8 477.4 473.1 469.1C516.3 433.9 544 380.2 544 320.1C544 260 516.3 206.3 473.1 171.1z",fill:"#ffffff"}}),e>=75&&t.push({tag:"path",attributes:{d:"M533.6 96.5C523.3 88.1 508.2 89.7 499.8 100C491.4 110.3 493 125.4 503.3 133.8C557.5 177.8 592 244.8 592 320C592 395.2 557.5 462.2 503.3 506.3C493 514.7 491.5 529.8 499.8 540.1C508.1 550.4 523.3 551.9 533.6 543.6C598.5 490.7 640 410.2 640 320C640 229.8 598.5 149.2 533.6 96.5z",fill:"#ffffff"}}),_t.createSVG(16,16,"0 0 640 640",t)},volumeMuted:()=>_t.createSVG(16,16,"0 0 640 640",[{tag:"path",attributes:{d:"M80 416L128 416L262.1 535.2C268.5 540.9 276.7 544 285.2 544C304.4 544 320 528.4 320 509.2L320 130.8C320 111.6 304.4 96 285.2 96C276.7 96 268.5 99.1 262.1 104.8L128 224L80 224C53.5 224 32 245.5 32 272L32 368C32 394.5 53.5 416 80 416zM399 239C389.6 248.4 389.6 263.6 399 272.9L446 319.9L399 366.9C389.6 376.3 389.6 391.5 399 400.8C408.4 410.1 423.6 410.2 432.9 400.8L479.9 353.8L526.9 400.8C536.3 410.2 551.5 410.2 560.8 400.8C570.1 391.4 570.2 376.2 560.8 366.9L513.8 319.9L560.8 272.9C570.2 263.5 570.2 248.3 560.8 239C551.4 229.7 536.2 229.6 526.9 239L479.9 286L432.9 239C423.5 229.6 408.3 229.6 399 239z",fill:"#ffffff"}}]),screenShare:()=>_t.createSVG(17,17,"0 0 24 24",[{tag:"path",attributes:{d:"M4 3C2.89543 3 2 3.89543 2 5V15C2 16.1046 2.89543 17 4 17H9V19H7V21H17V19H15V17H20C21.1046 17 22 16.1046 22 15V5C22 3.89543 21.1046 3 20 3H4ZM4 5H20V15H4V5Z",fill:"currentColor",stroke:"currentColor","stroke-width":"0.5"}}]),screenShareActive:()=>_t.createSVG(17,17,"0 0 24 24",[{tag:"path",attributes:{d:"M4 3C2.89543 3 2 3.89543 2 5V15C2 16.1046 2.89543 17 4 17H9V19H7V21H17V19H15V17H20C21.1046 17 22 16.1046 22 15V5C22 3.89543 21.1046 3 20 3H4ZM4 5H20V15H4V5Z",fill:"#4ade80",stroke:"#4ade80","stroke-width":"0.5"}}]),end:()=>_t.createSVG(16,16,"0 0 21 16",[{tag:"path",attributes:{d:"M17.7226 12.2992C18.3148 12.5423 18.991 12.308 19.307 11.7578L19.3954 11.6031C20.434 9.78662 20.2705 7.18344 18.2308 5.85533C13.5438 2.80798 7.45789 2.80798 2.77085 5.85533C0.726753 7.18344 0.567646 9.78662 1.60627 11.6031L1.69466 11.7578C2.01066 12.3125 2.68908 12.5445 3.2769 12.3014L6.32204 11.0462C6.83914 10.8341 7.15515 10.3059 7.0999 9.74684L6.90986 7.85081C9.2346 7.06853 11.7759 7.10831 14.0785 7.97456L13.8973 9.74684C13.8399 10.3037 14.1581 10.8297 14.6752 11.0462L17.7226 12.2992Z",fill:"red"}}])},St=e=>{const t=pt.getState(),n=ut(t),o=(e=>e.avatar.stopInteraction)(t);return n&&"open"===n.readyState&&!o?(ft.avatar("Sending command:",e),n.send(JSON.stringify(e)),!0):(ft.critical_warn(n?"open"!==n.readyState?`Data channel state: ${n.readyState}`:"Interaction stopped":"Data channel not available"),!1)};class Ct{constructor(e=1e3){Object.defineProperty(this,"video",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"canvas",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"ctx",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"worker",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"interval",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.interval=e,this.video=document.createElement("video"),this.video.setAttribute("autoplay","true"),this.video.setAttribute("playsinline","true"),this.video.muted=!0,this.canvas=document.createElement("canvas"),this.canvas.width=1280,this.canvas.height=720;const t=this.canvas.getContext("2d");if(!t)throw new Error("Failed to get canvas 2d context for MediaCapture");this.ctx=t,this.initWorker()}initWorker(){try{const e=new Blob(["\n let intervalId = null;\n self.onmessage = function(e) {\n if (e.data.command === 'start') {\n if (intervalId) clearInterval(intervalId);\n intervalId = setInterval(() => self.postMessage('tick'), e.data.interval);\n } else if (e.data.command === 'stop') {\n if (intervalId) { clearInterval(intervalId); intervalId = null; }\n }\n };\n"],{type:"application/javascript"}),t=URL.createObjectURL(e);this.worker=new Worker(t),URL.revokeObjectURL(t),this.worker.onmessage=()=>{this.drawFrame()}}catch(e){ft.critical_warn("MediaCapture","Failed to create worker:",e)}}drawFrame(){if(this.video.readyState<2)return;const e=this.video.videoWidth||1280,t=this.video.videoHeight||720;this.canvas.width=e,this.canvas.height=t,this.ctx.drawImage(this.video,0,0,e,t)}getCanvas(){return this.canvas}setStream(e){e?(this.video.srcObject=e,this.video.play().catch(e=>{ft.critical_warn("MediaCapture","Failed to play video:",e)}),this.worker?.postMessage({command:"start",interval:this.interval})):(this.worker?.postMessage({command:"stop"}),this.video.pause(),this.video.srcObject=null)}terminate(){this.worker?.postMessage({command:"stop"}),this.worker?.terminate(),this.worker=null,this.video.pause(),this.video.srcObject=null}}const Et=(e,t)=>{if("inactiveTimeout"===e){const e=t;return e?.enabled&&void 0!==e.duration&&e.duration>18e4&&(ft.critical_warn(`Napster Companion API SDK: inactiveTimeout duration of ${e.duration}ms exceeds the recommended maximum of 180000ms. Setting maximum allowed value.`),delete e.duration),t}return t},xt={width:"40px",height:"40px",borderRadius:"80px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:"all 0.3s ease-in-out",background:"linear-gradient(0deg, #5e5e5e14 0% 100%), #ffffff0f"},kt={background:"rgba(52, 199, 89, 0.25)",boxShadow:"0 0 0 2px rgba(52, 199, 89, 0.4)",transition:"background 0.2s ease, box-shadow 0.2s ease"};function Tt(e,{content:t,placement:n="top"}){let o=!1,a=null,i=null;const r=()=>e.ownerDocument,s=()=>r().defaultView,c=()=>{if(!a)return;const t=e.getBoundingClientRect(),o=a.getBoundingClientRect();let i=0,r=0;switch(n){case"top":i=t.top-o.height-8,r=t.left+(t.width-o.width)/2;break;case"bottom":i=t.bottom+8,r=t.left+(t.width-o.width)/2;break;case"left":i=t.top+(t.height-o.height)/2,r=t.left-o.width-8;break;case"right":i=t.top+(t.height-o.height)/2,r=t.right+8}a.style.top=`${i}px`,a.style.left=`${r}px`},l=()=>c(),d=()=>{if(o)return;const e=(()=>{if(a)return a;const e=r(),o=e.createElement("div");o.setAttribute("role","tooltip"),Object.assign(o.style,{position:"fixed",top:"0px",left:"0px",zIndex:"2147483647",opacity:"0",visibility:"hidden",pointerEvents:"none",transition:"opacity 80ms ease",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',fontSize:"14px",lineHeight:"1.5"});const i=e.createElement("div");Object.assign(i.style,{display:"block",color:"#3f4254",backgroundColor:"#fff",padding:"10px 14px",maxWidth:"300px",borderRadius:"0.375rem",boxShadow:"0 0.5rem 1rem rgba(0, 0, 0, 0.15)",textAlign:"center",whiteSpace:"nowrap"}),"string"==typeof t?i.textContent=t:i.appendChild(t);const s=e.createElement("div");return Object.assign(s.style,{top:{position:"absolute",bottom:"-6px",left:"50%",transform:"translateX(-50%)",width:"0",height:"0",borderLeft:"6px solid transparent",borderRight:"6px solid transparent",borderTop:"6px solid #fff"},bottom:{position:"absolute",top:"-6px",left:"50%",transform:"translateX(-50%)",width:"0",height:"0",borderLeft:"6px solid transparent",borderRight:"6px solid transparent",borderBottom:"6px solid #fff"},left:{position:"absolute",right:"-6px",top:"50%",transform:"translateY(-50%)",width:"0",height:"0",borderTop:"6px solid transparent",borderBottom:"6px solid transparent",borderLeft:"6px solid #fff"},right:{position:"absolute",left:"-6px",top:"50%",transform:"translateY(-50%)",width:"0",height:"0",borderTop:"6px solid transparent",borderBottom:"6px solid transparent",borderRight:"6px solid #fff"}}[n]),o.appendChild(i),o.appendChild(s),e.body.appendChild(o),a=o,o})();o=!0,c(),i=(s()??window).setTimeout(c,10),e.style.opacity="1",e.style.visibility="visible";const d=s()??window;d.addEventListener("scroll",l,!0),d.addEventListener("resize",l)},p=()=>{if(!o)return;o=!1,null!=i&&((s()??window).clearTimeout(i),i=null),a&&(a.style.opacity="0",a.style.visibility="hidden");const e=s()??window;e.removeEventListener("scroll",l,!0),e.removeEventListener("resize",l)},u=()=>d(),h=()=>p();return e.addEventListener("mouseenter",u),e.addEventListener("mouseleave",h),e.matches?.(":hover")&&d(),{update:e=>{if(void 0!==e.content&&a){const t=a.querySelector("div");t&&(t.innerHTML="","string"==typeof e.content?t.textContent=e.content:t.appendChild(e.content))}void 0!==e.placement&&(n=e.placement),o&&c()},show:d,hide:p,destroy:()=>{p(),e.removeEventListener("mouseenter",u),e.removeEventListener("mouseleave",h),a&&a.parentNode&&a.parentNode.removeChild(a),a=null}}}function It(){const e=document.createElement("div");Object.assign(e.style,xt);let t=pt.getState().avatar.muted,n=pt.getState().avatar.isUserTalking;i(t),r(t,n),e.addEventListener("click",()=>{const e=pt.getState().avatar.muted;pt.dispatch(qe(!e))});let o=null;o=Tt(e,{content:t?"Unmute":"Mute",placement:"top"});const a=pt.subscribe(()=>{const e=pt.getState().avatar,a=e.muted!==t,s=e.isUserTalking!==n;a&&(t=e.muted,i(t),o?.update({content:t?"Unmute":"Mute"})),(a||s)&&(n=e.isUserTalking,r(t,n))});function i(t){for(;e.firstChild;)e.removeChild(e.firstChild);const n=t?wt.micMuted():wt.micUnmuted();Object.assign(n.style,{width:"22px",height:"auto"}),e.appendChild(n)}function r(t,n){!t&&n?Object.assign(e.style,kt):(e.style.background=xt.background,e.style.boxShadow="none")}return{element:e,destroy:()=>{a(),o?.destroy(),e.parentNode&&e.parentNode.removeChild(e)}}}function Ot(e){const t=document.createElement("div");Object.assign(t.style,xt);const n=wt.end();Object.assign(n.style,{width:"16px",height:"auto"}),t.appendChild(n),t.addEventListener("click",e);const o=Tt(t,{content:"End Session",placement:"top"});return{element:t,destroy:()=>{o.destroy(),t.removeEventListener("click",e),t.parentNode&&t.parentNode.removeChild(t)}}}function Nt(){let e=pt.getState().avatar.volume,t=!1;const n=document.createElement("div");Object.assign(n.style,{position:"relative",display:"inline-flex",flexDirection:"column",alignItems:"center",gap:"12px",zIndex:"1000"});const o=document.createElement("div");Object.assign(o.style,{position:"absolute",bottom:"52px",opacity:"0",visibility:"hidden",transform:"translateY(10px)",transition:"all 0.3s ease",pointerEvents:"none",background:"#6565652e",padding:"8px",borderRadius:"8px",zIndex:"1001"});const a=document.createElement("div");Object.assign(a.style,{position:"relative",width:"8px",height:"120px",background:"rgba(0, 0, 0, 0.4)",backdropFilter:"blur(10px)",borderRadius:"4px",border:"1px solid rgba(255, 255, 255, 0.3)",cursor:"pointer",boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)"});const i=document.createElement("div");Object.assign(i.style,{position:"absolute",bottom:"0",left:"0",right:"0",height:"50%",background:"linear-gradient(to top, rgba(255,255,255,0.9), rgba(255,255,255,0.7))",borderRadius:"4px",transition:"height 0.1s ease",pointerEvents:"none"});const r=document.createElement("div");Object.assign(r.style,{position:"absolute",bottom:"50%",left:"50%",transform:"translate(-50%, 50%)",width:"16px",height:"16px",background:"white",borderRadius:"50%",boxShadow:"0 2px 6px rgba(0, 0, 0, 0.3)",transition:"bottom 0.1s ease",pointerEvents:"none",cursor:"grab"}),a.appendChild(i),a.appendChild(r),o.appendChild(a);const s=document.createElement("div");function c(){s.innerHTML="";const t=0===e?wt.volumeMuted():wt.volumeHigh(e);Object.assign(t.style,{width:"16px",height:"auto"}),s.appendChild(t)}function l(){i.style.height=`${e}%`,r.style.bottom=`${e}%`}function d(){t&&(t=!1,Object.assign(o.style,{opacity:"0",visibility:"hidden",transform:"translateY(10px)",pointerEvents:"none"}))}function p(t){const n=a.getBoundingClientRect(),o=Math.max(0,Math.min(100,(n.bottom-t)/n.height*100));e=o,l(),c(),pt.dispatch(Qe(e))}Object.assign(s.style,xt),s.setAttribute("aria-label","Volume control"),c(),l(),n.appendChild(o),n.appendChild(s),s.addEventListener("click",t=>{t.stopPropagation(),e=0===e?70:0,l(),c(),pt.dispatch(Qe(e))});let u=null;n.addEventListener("mouseenter",()=>{u&&(clearTimeout(u),u=null),t||(t=!0,Object.assign(o.style,{opacity:"1",visibility:"visible",transform:"translateY(0)",pointerEvents:"all"}))}),n.addEventListener("mouseleave",()=>{u=setTimeout(()=>d(),300)}),o.addEventListener("mouseenter",()=>{u&&(clearTimeout(u),u=null)}),o.addEventListener("mouseleave",()=>{u=setTimeout(()=>d(),300)}),a.addEventListener("mousedown",e=>{p(e.clientY),e.preventDefault();const t=n.ownerDocument,o=e=>p(e.clientY),a=()=>{t.removeEventListener("mousemove",o),t.removeEventListener("mouseup",a)};t.addEventListener("mousemove",o),t.addEventListener("mouseup",a)}),r.addEventListener("mousedown",e=>{e.preventDefault();const t=n.ownerDocument,o=e=>p(e.clientY),a=()=>{t.removeEventListener("mousemove",o),t.removeEventListener("mouseup",a)};t.addEventListener("mousemove",o),t.addEventListener("mouseup",a)}),a.addEventListener("touchstart",e=>{p(e.touches[0].clientY),e.preventDefault();const t=n.ownerDocument,o=e=>{e.touches.length>0&&p(e.touches[0].clientY)},a=()=>{t.removeEventListener("touchmove",o),t.removeEventListener("touchend",a)};t.addEventListener("touchmove",o),t.addEventListener("touchend",a)});const h=pt.subscribe(()=>{const t=pt.getState().avatar.volume;t!==e&&(e=t,l(),c())});return{element:n,destroy:()=>{h(),n.parentNode&&n.parentNode.removeChild(n)}}}function At(e){const t=document.createElement("div");Object.assign(t.style,xt,{color:"#fff"}),e.isSupported||(t.style.display="none");let n=pt.getState().avatar.isScreenSharing;i(n),t.addEventListener("click",()=>e.onToggle());let o=null;o=Tt(t,{content:n?"Stop Sharing":"Share Screen",placement:"top"});const a=pt.subscribe(()=>{const e=pt.getState().avatar.isScreenSharing;e!==n&&(n=e,i(e),o?.update({content:e?"Stop Sharing":"Share Screen"}))});function i(e){for(;t.firstChild;)t.removeChild(t.firstChild);const n=e?wt.screenShareActive():wt.screenShare();Object.assign(n.style,{width:"22px",height:"auto"}),t.appendChild(n)}return{element:t,destroy:()=>{a(),o?.destroy(),t.parentNode&&t.parentNode.removeChild(t)}}}const Dt={enabled:!1,batchSize:10,flushInterval:5e3,enablePerformanceTracking:!0,enableErrorTracking:!0,enableUserInteractionTracking:!0};class Rt{constructor(e={}){Object.defineProperty(this,"config",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"eventQueue",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"performanceQueue",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"errorQueue",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"flushTimer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"sessionId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"providers",{enumerable:!0,configurable:!0,writable:!0,value:[]}),this.config={...Dt,...e},this.sessionId=this.config.sessionId||this.generateSessionId(),this.setupProviders(),this.config.enabled&&(this.startFlushTimer(),this.setupErrorTracking(),this.setupPerformanceTracking())}setupProviders(){this.providers=[],this.config.providers&&(this.providers=[...this.config.providers]),this.config.provider&&this.providers.push(this.config.provider),0===this.providers.length&&this.providers.push({type:"custom"})}generateSessionId(){return`session_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}startFlushTimer(){this.flushTimer&&clearInterval(this.flushTimer),this.flushTimer=setInterval(()=>{this.flush()},this.config.flushInterval)}setupErrorTracking(){this.config.enableErrorTracking&&(window.addEventListener("error",e=>{this.trackError(e.error,{source:"window.error",filename:e.filename,lineno:e.lineno,colno:e.colno})}),window.addEventListener("unhandledrejection",e=>{this.trackError(new Error(e.reason),{source:"unhandledrejection",reason:e.reason})}))}setupPerformanceTracking(){this.config.enablePerformanceTracking&&"undefined"!=typeof window&&"performance"in window&&window.addEventListener("load",()=>{setTimeout(()=>{const e=performance.getEntriesByType("navigation")[0];e&&(this.trackPerformance("page_load_time",e.loadEventEnd-e.fetchStart,"ms"),this.trackPerformance("dom_content_loaded",e.domContentLoadedEventEnd-e.fetchStart,"ms"),this.trackPerformance("first_paint",e.responseEnd-e.fetchStart,"ms"))},0)})}trackEvent(e,t){if(!this.config.enabled)return;const n={name:e,properties:t,timestamp:Date.now(),userId:this.config.userId,sessionId:this.sessionId};this.eventQueue.push(n),this.eventQueue.length>=(this.config.batchSize||10)&&this.flush()}trackPerformance(e,t,n,o){if(!this.config.enabled||!this.config.enablePerformanceTracking)return;const a={name:e,value:t,unit:n,timestamp:Date.now(),context:o};this.performanceQueue.push(a)}trackError(e,t){if(!this.config.enabled||!this.config.enableErrorTracking)return;const n={error:e,context:t,timestamp:Date.now(),userId:this.config.userId,sessionId:this.sessionId,stack:e.stack};this.errorQueue.push(n),this.flushErrors()}trackInteraction(e,t,n){this.config.enableUserInteractionTracking&&this.trackEvent("user_interaction",{action:e,target:t,...n})}flush(){this.flushEvents(),this.flushPerformance(),this.flushErrors()}flushEvents(){if(0===this.eventQueue.length)return;const e=[...this.eventQueue];this.eventQueue=[],this.sendData("events",e)}flushPerformance(){if(0===this.performanceQueue.length)return;const e=[...this.performanceQueue];this.performanceQueue=[],this.sendData("performance",e)}flushErrors(){if(0===this.errorQueue.length)return;const e=[...this.errorQueue];this.errorQueue=[],this.sendData("errors",e)}async sendData(e,t){const n=this.providers.map(n=>this.sendToProvider(n,e,t));await Promise.allSettled(n)}async sendToProvider(e,t,n){try{switch(e.type){case"google-analytics-4":await this.sendToGA4(e,n);break;case"mixpanel":await this.sendToMixpanel(e,n);break;case"segment":await this.sendToSegment(e,n);break;case"amplitude":await this.sendToAmplitude(e,n);break;case"posthog":await this.sendToPostHog(e,n);break;case"azure-insights":await this.sendToAzureInsights(e,n);break;default:await this.sendToCustomEndpoint(e,t,n)}}catch(t){ft.critical_warn(`Failed to send data to ${e.type}:`,t)}}async sendToCustomEndpoint(e,t,n){const o=e.endpoint,a=e.apiKey;if(!o)return;const i=await fetch(`${o}/${t}`,{method:"POST",headers:{"Content-Type":"application/json",...a&&{Authorization:`Bearer ${a}`}},body:JSON.stringify({data:n,sessionId:this.sessionId,timestamp:Date.now()})});if(!i.ok)throw new Error(`HTTP ${i.status}`)}async sendToGA4(e,t){const n=e.measurementId||e.apiKey;if(!n)throw new Error("GA4 measurement ID required");const o=`https://www.google-analytics.com/mp/collect?measurement_id=${n}&api_secret=${e.apiKey||"default"}`,a=t.map(e=>({name:e.name,params:{...e.properties,session_id:this.sessionId}}));await fetch(o,{method:"POST",body:JSON.stringify({client_id:this.sessionId,user_id:this.config.userId,events:a})})}async sendToMixpanel(e,t){const n=e.projectToken||e.apiKey;if(!n)throw new Error("Mixpanel project token required");const o=e.endpoint||"https://api.mixpanel.com/batch",a=t.map(e=>{const t=e;return{event:t.name,properties:{token:n,distinct_id:this.config.userId||this.sessionId,time:t.timestamp||Date.now(),...t.properties}}});await fetch(o,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)})}async sendToSegment(e,t){const n=e.writeKey||e.apiKey;if(!n)throw new Error("Segment write key required");const o=e.endpoint||"https://api.segment.io/v1/batch",a=t.map(e=>({type:"track",userId:this.config.userId||this.sessionId,event:e.name,properties:e.properties,timestamp:new Date(e.timestamp||Date.now()).toISOString()}));await fetch(o,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Basic ${btoa(n+":")}`},body:JSON.stringify({batch:a})})}async sendToAmplitude(e,t){const n=e.apiKey;if(!n)throw new Error("Amplitude API key required");const o=e.endpoint||"https://api2.amplitude.com/2/httpapi",a=t.map(e=>({user_id:this.config.userId||this.sessionId,event_type:e.name,event_properties:e.properties,time:e.timestamp||Date.now()}));await fetch(o,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({api_key:n,events:a})})}async sendToPostHog(e,t){const n=e.apiKey,o=e.endpoint||"https://app.posthog.com";if(!n)throw new Error("PostHog API key required");const a=t.map(e=>({event:e.name,properties:{...e.properties,distinct_id:this.config.userId||this.sessionId},timestamp:new Date(e.timestamp||Date.now()).toISOString()}));await fetch(`${o}/batch/`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({api_key:n,batch:a})})}async sendToAzureInsights(e,t){const n=e.apiKey;if(!n)throw new Error("Azure Application Insights instrumentation key required");const o=e.endpoint||"https://dc.services.visualstudio.com/v2/track",a=t.map(e=>{const t=e;return{name:"Microsoft.ApplicationInsights.Event",time:new Date(t.timestamp||Date.now()).toISOString(),iKey:n,data:{baseType:"EventData",baseData:{name:t.name,properties:t.properties}}}});await fetch(o,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)})}updateConfig(e){this.config={...this.config,...e},this.setupProviders(),this.config.enabled&&!this.flushTimer?this.startFlushTimer():!this.config.enabled&&this.flushTimer&&(clearInterval(this.flushTimer),this.flushTimer=void 0)}destroy(){this.flushTimer&&clearInterval(this.flushTimer),this.flush()}}let Pt=null;const Lt=(e,t)=>{Pt?.trackEvent(e,t)},Mt=(e,t,n)=>{Pt?.trackInteraction(e,t,n)};function jt(e,t){void 0===t&&(t={});var n=t.insertAt;if(e&&"undefined"!=typeof document){var o=document.head||document.getElementsByTagName("head")[0],a=document.createElement("style");a.type="text/css","top"===n&&o.firstChild?o.insertBefore(a,o.firstChild):o.appendChild(a),a.styleSheet?a.styleSheet.cssText=e:a.appendChild(document.createTextNode(e))}}jt(".np_companion-live-container,.np_companion-preview-container{height:100%;margin:0;padding:0;position:absolute;transition:opacity .3s ease-in-out;width:100%}.np_companion-preview-container{opacity:1;z-index:2}.np_companion-preview-container.np_companion-fade-out{opacity:0;pointer-events:none;transition:opacity .5s ease-out}.np_companion-live-container{opacity:0;z-index:1}.np_companion-live-container.np_companion-fade-in{opacity:1;z-index:3}"),jt(":root{--base-border-radius:10px;--base-gap:20px}*,:after,:before{-webkit-box-sizing:border-box;box-sizing:border-box}::-webkit-input-placeholder{color:hsla(0,0%,100%,.4)}::-moz-placeholder{color:hsla(0,0%,100%,.4)}:-ms-input-placeholder{color:hsla(0,0%,100%,.4)}:-moz-placeholder{color:hsla(0,0%,100%,.4)}a,input{outline:none}body,html{background-color:transparent;background:transparent;margin:0;padding:0;width:100%}.np_companion-hide{display:none!important}.np_companion-align-middle{align-items:center;display:flex;justify-content:center}.np_companion-align-between{align-items:center;display:flex;justify-content:space-between}.np_companion-align-end{align-items:center;display:flex;justify-content:flex-end}.np_companion-align-start{align-items:flex-start;display:flex;justify-content:flex-start}.np_companion__d-none{display:none!important}#np_companion-sdk-root.np_companion-container-fixed{height:500px;position:fixed;transition:all .3s ease-in-out;width:400px;z-index:9999}#np_companion-sdk-root.np_companion-container-fixed.np_companion-view-rectangle{height:400px;width:340px}#np_companion-sdk-root.np_companion-container-fixed.np_companion-view-silhouette{height:400px}#np_companion-sdk-root.np_companion-container-fixed.np_companion-view-round{height:360px;width:250px}#np_companion-sdk-root.np_companion-container-fixed.np_companion-view-round.np_companion_disclaimer-disabled{height:320px!important}#np_companion-sdk-root.np_companion-container-fixed.np_companion-bottom-right{bottom:0;right:0}#np_companion-sdk-root.np_companion-container-fixed.np_companion-bottom-left{bottom:0;left:0}#np_companion-sdk-root.np_companion-container-fixed.np_companion-bottom-center{bottom:0;left:50%;transform:translateX(-50%)}#np_companion-sdk-root.np_companion-container-fixed.np_companion-top-right{right:0;top:0}#np_companion-sdk-root.np_companion-container-fixed.np_companion-top-left{left:0;top:0}#np_companion-sdk-root.np_companion-container-fixed.np_companion-top-center{left:50%;top:0;transform:translateX(-50%)}#np_companion-sdk-root.np_companion-container-fixed.np_companion-center{left:50%;top:50%;transform:translate(-50%,-50%)}"),jt('.np_companion-avatar{height:100%;position:relative;width:100%}#np_companion-avatar-container{background:transparent;border-radius:var(--base-border-radius);height:100%;overflow:hidden;position:absolute;width:100%}#np_companion-avatar-container:not(.np_companion-view-silhouette){box-shadow:0 0 #0000,0 0 #0000,0 0 #0000,0 0 #0000,0 10px 15px -3px color-mix(in oklab,#00000080 100%,transparent),0 4px 6px -4px color-mix(in oklab,#00000080 100%,transparent)}.np_companion-avatar.np_companion-bg-transparent #np_companion-avatar-container.np_companion-view-silhouette{filter:drop-shadow(0 10px 15px rgba(0,0,0,.5)) drop-shadow(0 4px 6px rgba(0,0,0,.5))}.np_companion-container-fixed #np_companion-avatar-container.np_companion-view-round{border-radius:50%;height:212px;left:50%;transform:translate(-50%,12%);width:212px}.np_companion-container-fixed #np_companion-avatar-container.np_companion-view-rectangle,.np_companion-container-fixed #np_companion-avatar-container.np_companion-view-silhouette{left:50%;transform:translateX(-50%)}.np_companion-avatar-video{height:100%;inset:0;object-fit:cover;pointer-events:none;position:absolute;transition:opacity .3s ease-in-out;width:100%;z-index:10}.np_companion-avatar-video.no-opacity{opacity:0}.np_companion-avatar-canvas{background:transparent;height:100%;object-fit:cover;position:relative;width:100%;z-index:1}.np_companion-container-fixed #np_companion-avatar-container.np_companion-loader-pulse:after{animation:pulse 1.5s ease-in-out infinite;background-color:var(--np-loader-bg-color);border-radius:var(--base-border-radius);content:"";display:block;height:100%;left:0;opacity:.6;overflow:hidden;position:absolute;top:0;width:100%}.np_companion-avatar.np_companion-bg-transparent #np_companion-avatar-container:after{display:none}.np_companion-avatar:has(#np_companion-avatar-container.np_companion-view-round):after{display:none}#np_companion-avatar-container.np_companion-loader-pulse.loader-container.np_companion-view-round:after{animation:pulse 1.5s ease-in-out infinite;background-color:var(--np-loader-bg-color);border-radius:50%;content:"";display:block;height:100%;left:0;opacity:.6;overflow:hidden;position:absolute;top:0;width:100%}.np_companion-avatar.np_companion-bg-transparent #np_companion-avatar-container.np_companion-view-round:after{display:none}@keyframes pulse{0%,to{opacity:.5}50%{opacity:.2}}.np_companion-disclaimer-text{-webkit-box-orient:vertical;-webkit-line-clamp:2;line-clamp:2;color:#fff;font-size:10px;line-height:12px;margin:auto auto 16px;max-width:940px;opacity:.7;overflow:hidden;padding:0 16px;text-align:center;z-index:12}.np_companion-disclaimer-text a{color:#fff}.np_companion-disclaimer-text a:hover{color:#fff;text-decoration:underline}.np_companion-disclaimer-text a:focus,.np_companion-disclaimer-text a:visited{color:#fff}.np_companion-action-btn-container-wrapper{pointer-events:auto;width:100%}.np_companion-avatar-control-container{backdrop-filter:blur(19px);background:none;background-color:rgba(52,51,51,.6);border-radius:16px;bottom:0;box-shadow:0 4px 4px 0 rgba(0,0,0,.25),2px 2px 8px 0 rgba(0,0,0,.12);left:50%;max-width:90%;min-width:210px;opacity:1;position:absolute;transform:translateX(-50%);transition:opacity .4s cubic-bezier(.4,0,.2,1);z-index:99}.np_companion-avatar-control-container.np_companion-action-btn-container-collapse{opacity:0}.np_companion-avatar-control-container:not(.np_companion-avatar-control-view-round){bottom:16px}.np_companion-avatar:not(.np_companion-bg-transparent) .np_companion-loader-spinner:not(.np_companion-view-silhouette){backdrop-filter:blur(19px);background-color:color-mix(in oklab,var(--np-loader-bg-color) 100%,transparent)!important;filter:none!important;height:100%;width:100%}.np_companion-loader-spinner .loader-container{left:50%;position:absolute;top:50%;transform:translate(-50%,-50%)}.np_companion-loader-spinner .loader-container .loader{--_m:conic-gradient(#0000 10%,#000),linear-gradient(#000 0 0) content-box;animation:l3 1s linear infinite;aspect-ratio:1;background:var(--np-loader-color);border-radius:50%;-webkit-mask:var(--_m);mask:var(--_m);-webkit-mask-composite:source-out;mask-composite:subtract;padding:4px;width:24px}@keyframes l3{to{transform:rotate(1turn)}}.np_companion-loader-spinner.np_companion-view-round .loader-container .loader{padding:4px;width:212px}.np_companion-bg-transparent .np_companion-loader-spinner .loader-container{display:none}'),jt(".np_companion-controls-container{align-items:center;background:hsla(0,0%,100%,.3);border:.5px solid #fff;border-radius:12px;bottom:20px;box-shadow:0 1px 1px rgba(0,0,0,.267),0 2px 5px rgba(0,0,0,.267),0 3px 8px rgba(0,0,0,.267);display:flex;gap:8px;left:50%;max-width:360px;pointer-events:auto;position:absolute;transform:translateX(-50%);transform-origin:bottom center;transition:width .3s ease-in-out;-webkit-user-select:none;-moz-user-select:none;user-select:none;width:auto;z-index:99}.np_companion-controls-container.collapsed{gap:0}.np_companion-time-running{color:#fff}.np_companion-controls-time-action-btn-container{align-items:center;background:hsla(0,0%,100%,.1);border-radius:8px;display:flex;filter:grayscale(1);flex-shrink:0;gap:8px;height:32px;padding-left:8px;padding-right:8px;transition:filter .3s ease}.np_companion-controls-mic-control,.np_companion-controls-stop-control{cursor:pointer;display:flex;margin:0 5px;overflow:hidden;transition:opacity .3s ease-in-out,width .3s ease-in-out;width:47px}.np_companion-controls-mic-control.visible,.np_companion-controls-stop-control.visible{opacity:1}.np_companion-controls-mic-control.visible{width:1em}.np_companion-controls-stop-control.visible{width:1.5em}.np_companion-controls-mic-control.hidden,.np_companion-controls-stop-control.hidden{margin:0;opacity:0;padding:0;pointer-events:none;width:0}.np_companion-controls-mic-control:hover svg path{fill:red}.np_companion-controls-stop-control{display:flex;margin:0 5px 0 0}.np_companion-controls-stop-control:hover svg .stop-circle{fill:red}.np_companion-controls-stop-control:hover svg .stop-square{fill:#fff}.np_companion-mic-dropdown{background:#2b2c32;border-radius:4px;border-radius:6px;bottom:35px;box-shadow:0 10px 15px -3px rgba(0,0,0,.2),0 4px 6px -4px rgba(0,0,0,.2),0 0 0 1px #46464d;color:#fff;font-size:14px;list-style-type:none;margin:0;max-height:200px;min-width:300px;overflow-y:auto;overflow:auto;padding:5px;pointer-events:auto;position:absolute;width:auto;z-index:1000}.np_companion-mic-dropdown li{cursor:pointer;padding:8px 12px}.np_companion-mic-dropdown li:hover{background-color:#000}.np_companion-action-btn-container-container{background:transparent;border-radius:80px;gap:8px;padding:16px 16px 12px;transition:all .3s ease-in-out}.np_companion-action-btn-container-container.np_companion_disclaimer-disabled{padding-bottom:16px}.np_companion-action-btn-container-container .np_companion-chat-question-bar-container{border-radius:16px;gap:8px}.np_companion-action-btn-container-container .np_companion-action-btn-container-left{transition:all .3s ease-in-out;width:40px}.np_companion-action-btn-container-container .np_companion-action-btn-container-icon{border-radius:80px;cursor:pointer;height:40px;transition:all .3s ease-in-out;width:40px}.np_companion-dark-grey-bg{background:linear-gradient(0deg,#5e5e5e14 0 100%),#ffffff0f}.np_companion-grey-bg{background:linear-gradient(0deg,rgba(94,94,94,.07),rgba(94,94,94,.07)),hsla(0,0%,100%,.04)}.np_companion-action-btn-container-container .np_companion-action-btn-container-icon svg{height:auto;width:22px}.np_companion-action-btn-container-container .np_companion-action-btn-container-icon.muted svg.np_companion-mic-muted,.np_companion-action-btn-container-container .np_companion-action-btn-container-icon:not(.muted) svg.np_companion-mic-unmuted{display:flex}.np_companion-action-btn-container-container .np_companion-action-btn-container-middle .np_companion-action-btn-container-wave{display:flex;min-width:160px}.np_companion-action-btn-container-container .np_companion-action-btn-container-middle .np_companion-action-btn-container-wave canvas{height:40px;width:100%}.np_companion-action-btn-container-container .np_companion-action-btn-container-right{gap:8px;transition:all .3s ease-in-out}.np_companion-action-btn-container-container .np_companion-action-btn-container-left .np_companion-action-btn-container-icon:hover,.np_companion-action-btn-container-container .np_companion-action-btn-container-right .np_companion-action-btn-container-icon.active,.np_companion-action-btn-container-container .np_companion-action-btn-container-right .np_companion-action-btn-container-icon:hover{background-color:#fff!important}.np_companion-action-btn-container-container .np_companion-action-btn-container-left .np_companion-action-btn-container-icon:not(.np_companion-persist-fill-color):hover svg path{fill:#000}.np_companion-action-btn-container-container .np_companion-action-btn-container-right .np_companion-action-btn-container-icon.np_companion-action-btn-container-call-end svg{height:auto;width:16px}.np_companion-action-btn-container-container .np_companion-action-btn-container-right .np_companion-action-btn-container-icon:not(.np_companion-persist-fill-color).np_companion-action-btn-container-call-end:hover svg path{stroke:#000}.np_companion-action-btn-container-container .np_companion-action-btn-container-right .np_companion-action-btn-container-icon:not(.np_companion-persist-fill-color).active svg path,.np_companion-action-btn-container-container .np_companion-action-btn-container-right .np_companion-action-btn-container-icon:not(.np_companion-persist-fill-color).np_companion-action-btn-container-toggle:hover svg path,.np_companion-action-btn-container-container .np_companion-action-btn-container-right .np_companion-action-btn-container-icon:not(.np_companion-persist-fill-color):hover svg path{fill:#000}.np_companion-mobile-mode{bottom:15px;scale:.7}.np_companion-mobile-mode .np_companion-action-btn-container-container .np_companion-action-btn-container-middle{display:none}.np_companion-mobile-mode .np_companion-action-btn-container-left{opacity:1;width:40px}.np_companion-mobile-mode .np_companion-action-btn-container-right{opacity:1}.np_companion-action-btn-container-container .np_companion-action-btn-container-icon.np_companion-talking{background:rgba(52,199,89,.25);box-shadow:0 0 0 2px rgba(52,199,89,.4);transition:background .2s ease,box-shadow .2s ease}.np_companion-action-btn-container-container .np_companion-action-btn-container-icon.np_companion-talking svg path{fill:#34c759}");const Ft={echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0};let Vt=null;function zt(){return Vt||(Vt=function(){let e,t=null,n=null,o=!1,a=null,i=null,s=null;const c={stream:new Set,muted:new Set,device:new Set,error:new Set};function l(e,t){c[e].forEach(n=>{try{n(t)}catch(t){ft.critical_error("MicrophoneManager",`Listener threw for "${e}"`,t)}})}function d(){try{s?.disconnect()}catch{}s=null;try{i?.disconnect()}catch{}if(i=null,a){try{a.close()}catch{}a=null}}function p(e){d();const t="undefined"!=typeof window?window.AudioContext||window.webkitAudioContext:void 0;if(t)try{a=new t,i=a.createAnalyser(),s=a.createMediaStreamSource(e),s.connect(i)}catch(e){ft.critical_warn("MicrophoneManager","Failed to build analyser graph",e),d()}}function u(e){if(e)try{e.getTracks().forEach(e=>e.stop())}catch{}}async function h(e){const t=function(e){return e?{...Ft,deviceId:{exact:e}}:{...Ft}}(e),n=await navigator.mediaDevices.getUserMedia({audio:t,video:!1}),a=n.getAudioTracks()[0];if(!a)throw u(n),new r("No audio track returned from getUserMedia",{deviceId:e});return a.enabled=!o,n}async function f(o){try{const a=await h(o),i=t;return t=a,n=a.getAudioTracks()[0]??null,e=o,p(a),u(i),l("device",o),l("stream",t),t}catch(e){const t=e instanceof r?e:new r("Failed to switch audio device",{error:e,deviceId:o});throw l("error",t),t}}return{start:async function(o={}){if(t&&t.active)return o.deviceId&&o.deviceId!==e?f(o.deviceId):t;try{const a=await h(o.deviceId);return t=a,n=a.getAudioTracks()[0]??null,e=o.deviceId,p(a),l("device",e),l("stream",t),t}catch(e){const t=e instanceof r?e:new r("Failed to access user media",{error:e,deviceId:o.deviceId});throw l("error",t),t}},stop:function(){const a=!!t;d(),u(t),t=null,n=null,e=void 0,o=!1,a&&(l("stream",null),l("device",void 0))},switchDevice:f,setMuted:function(e){o!==e&&(o=e,n&&(n.enabled=!e),l("muted",o))},isMuted:()=>o,getStream:()=>t,getTrack:()=>n,getAnalyser:()=>i,getCurrentDeviceId:()=>e,on:function(e,t){const n=c[e];return n.add(t),()=>{n.delete(t)}}}}()),Vt}function Wt(e,t){const n=document.createElement(e);return t&&(n.className=t),n}var Ut,Ht,$t,Bt,Kt,Gt,qt;jt('.np_companion-inactive-overlay{align-items:center;bottom:0;display:flex;justify-content:center;left:0;pointer-events:auto;position:absolute;right:0;top:0;z-index:9999}.np_companion-inactive-dialog{backdrop-filter:blur(19px);background:hsla(0,0%,50%,.3);background-blend-mode:luminosity;border-radius:16px;max-width:500px;overflow:hidden;padding:24px 16px;position:relative;text-align:center;width:100%}.np_companion-inactive-dialog:before{background:linear-gradient(180deg,hsla(0,0%,100%,.4),hsla(0,0%,100%,0),hsla(0,0%,100%,0),hsla(0,0%,100%,.1));border-radius:16px;content:"";inset:0;-webkit-mask:linear-gradient(#fff 0 0) content-box,linear-gradient(#fff 0 0);-webkit-mask-composite:destination-out;mask-composite:exclude;padding:1.473px;pointer-events:none;position:absolute}.np_companion-inactive-message{color:#fff;font-size:16px;line-height:1.5;margin-bottom:24px;margin-top:0}.np_companion-inactive-timer{display:flex;justify-content:center;margin:24px 0;pointer-events:none}.np_companion-timer-circle{align-items:center;display:flex;height:80px;justify-content:center;position:relative;width:80px}.np_companion-timer-circle svg{overflow:visible;transform:rotate(-90deg)}.np_companion-timer-circle path{transition:stroke-dasharray .3s ease}.np_companion-timer-number{color:#fff;font-size:24px;font-weight:500;position:absolute}.np_companion-inactive-buttons{display:flex;gap:12px;justify-content:center}.np_companion-inactive-buttons button{border:none;border-radius:8px;cursor:pointer;font-size:14px;font-weight:500;padding:12px 24px;transition:all .2s ease}.np_companion-end-button{background:hsla(0,0%,100%,.1);color:#fff}.np_companion-end-button:hover{background:hsla(0,0%,100%,.2)}.np_companion-continue-button{background:#3c19cd;color:#fff}.np_companion-continue-button:hover{background:#2f13a0}'),function(e){e.LOCAL_TIMEOUT="local_timeout",e.SERVER_WARNING="server_warning"}(Ut||(Ut={}));class Qt{constructor(e,t={}){Object.defineProperty(this,"overlayController",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"currentTrigger",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"isVisible",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"mountElement",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"callbacks",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.mountElement=e,this.callbacks=t}show(e){this.isVisible?ft.warn("Inactive overlay already visible, ignoring show request"):(ft.info(`Showing inactive overlay (trigger: ${e.type})`),this.currentTrigger=e,this.isVisible=!0,this.overlayController=function(e,t){const n={duration:t.duration??30,isInteractionNeeded:t.isInteractionNeeded??!1,message:t.message??"It looks like you've been inactive for a while. Would you like to continue this conversation?",onContinue:t.onContinue,onEnd:t.onEnd},o=document.createElement("div");o.className="np_companion-inactive-overlay";const a=document.createElement("div");a.className="np_companion-inactive-dialog";const i=document.createElement("p");i.className="np_companion-inactive-message",i.textContent=n.message;const r=document.createElement("div");r.className="np_companion-inactive-timer";const s=document.createElement("div");s.className="np_companion-timer-circle";const c=document.createElementNS("http://www.w3.org/2000/svg","svg");c.setAttribute("viewBox","0 0 36 36");const l=document.createElementNS("http://www.w3.org/2000/svg","path");l.setAttribute("d","M18 2.0845 a 15.9155 15.9155 0 0 1 0 31.831 a 15.9155 15.9155 0 0 1 0 -31.831"),l.setAttribute("fill","none"),l.setAttribute("stroke","rgba(255, 255, 255, 0.2)"),l.setAttribute("stroke-width","2");const d=document.createElementNS("http://www.w3.org/2000/svg","path");d.setAttribute("d","M18 2.0845 a 15.9155 15.9155 0 0 1 0 31.831 a 15.9155 15.9155 0 0 1 0 -31.831"),d.setAttribute("fill","none"),d.setAttribute("stroke","#fff"),d.setAttribute("stroke-width","2");const p=document.createElement("span");p.className="np_companion-timer-number",s.appendChild(c),c.appendChild(l),c.appendChild(d),s.appendChild(p),r.appendChild(s);const u=document.createElement("div");u.className="np_companion-inactive-buttons";const h=document.createElement("button");h.className="np_companion-end-button np_companion__d-none",h.textContent="End Conversation";let f=null;const m=e=>{e&&!f?(f=document.createElement("button"),f.className="np_companion-continue-button",f.textContent="Continue Talking",u.appendChild(f),f.addEventListener("click",n.onContinue)):!e&&f&&(f.removeEventListener("click",n.onContinue),f.parentNode&&f.parentNode.removeChild(f),f=null)};u.appendChild(h),m(n.isInteractionNeeded),a.appendChild(i),a.appendChild(r),a.appendChild(u),o.appendChild(a),e.appendChild(o);let g=Math.max(0,Math.floor(n.duration)),v=null;const b=()=>{p.textContent=String(g),d.setAttribute("stroke-dasharray",(n.duration>0?g/n.duration*100:0)+", 100")},y=()=>{if(g<=0)return w(),void n.onEnd();g-=1,b()},_=()=>{w(),b(),v=window.setInterval(y,1e3)},w=()=>{null!=v&&(window.clearInterval(v),v=null)};return h.addEventListener("click",()=>{w(),n.onEnd()}),_(),{update:e=>{if(void 0!==e.message&&(n.message=e.message,i.textContent=n.message),void 0!==e.isInteractionNeeded&&(n.isInteractionNeeded=!!e.isInteractionNeeded,m(n.isInteractionNeeded)),void 0!==e.duration){const t=Math.max(0,Math.floor(e.duration));n.duration=t,g=t,_()}e.onContinue&&(f&&(f.removeEventListener("click",n.onContinue),f.addEventListener("click",e.onContinue)),n.onContinue=e.onContinue),e.onEnd&&(n.onEnd=e.onEnd)},destroy:()=>{w(),h.removeEventListener("click",n.onEnd),f&&f.removeEventListener("click",n.onContinue),o.parentNode&&o.parentNode.removeChild(o)}}}(this.mountElement,{duration:e.duration,message:e.message,isInteractionNeeded:e.isInteractionNeeded,onContinue:()=>this.handleContinue(),onEnd:()=>this.handleEnd()}),this.callbacks.onShow?.(e))}hide(){this.isVisible&&(ft.info("Hiding inactive overlay"),this.isVisible=!1,this.currentTrigger=null,this.overlayController&&(this.overlayController.destroy(),this.overlayController=null),this.callbacks.onHide?.())}isShowing(){return this.isVisible}getCurrentTrigger(){return this.currentTrigger}handleContinue(){ft.info("User clicked continue on inactive overlay"),this.hide(),this.callbacks.onContinue?.()}handleEnd(){ft.info("Inactive overlay countdown ended"),this.hide(),this.callbacks.onEnd?.()}destroy(){this.hide()}}!function(e){e.TALK_STATE_CHANGED="talk_state_changed",e.MESSAGE_RECEIVED="message_received",e.TRANSCRIPT="transcript",e.AUDIO_TRANSCRIPT_DELTA="response.audio_transcript.delta",e.AUDIO_TRANSCRIPT_DONE="response.audio_transcript.done",e.RESPONSE_DONE="response.done"}(Ht||(Ht={})),function(e){e.STARTED="started",e.ENDED="ended",e.CANCELED="canceled"}($t||($t={})),function(e){e.DELTA="delta",e.COMPLETED="completed"}(Bt||(Bt={})),function(e){e.USER="user",e.ASSISTANT="assistant"}(Kt||(Kt={})),function(e){e.SET_REMOTE_DESCRIPTION="set_remote_description",e.SET_LOCAL_DESCRIPTION="set_local_description",e.ADD_ICE_CANDIDATE="add_ice_candidate",e.ERROR="error"}(Gt||(Gt={})),function(e){e.SEND_MESSAGE="send_message",e.CANCEL="cancel",e.SET_SETTINGS="set_settings",e.START_VIDEO="start_video",e.STOP_VIDEO="stop_video"}(qt||(qt={}));const Zt={iceServers:[{urls:"stun:stun1.ciscape.com:3478"},{urls:"turn:stun1.ciscape.com:3478",username:"tcuser",credential:"dw4k_BR2f-Y4A-@aT7ip@Qzs"},{urls:"stun:129.146.43.226:3478"},{urls:"stun:stun.l.google.com:19302"},{urls:"stun:stun1.l.google.com:19302"},{urls:"turn:129.146.43.226:3478",username:"teamtime_turn",credential:"teamtime"}]};function Jt(){return"undefined"!=typeof navigator&&!!navigator.mediaDevices&&"function"==typeof navigator.mediaDevices.getDisplayMedia}function Yt(e,t){if(t)for(const n in t)try{const o=t[n];"string"!=typeof o&&"number"!=typeof o||(e.style[n]=o)}catch{ft.warn(`Failed to apply style for key "${n}: ${t[n]}".`)}}function Xt(e,t,n){const o=[];return o.push("np_companion-align-middle"),e&&(o.push("np_companion-container-fixed"),o.push(`np_companion-${e}`),t&&o.push(`np_companion-view-${t}`)),n&&o.push(n),o.join(" ")}class en{static getInstance(){return en.instance||(en.instance=new en),en.instance}constructor(){Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:"1.0.0-alpha.41"}),Object.defineProperty(this,"mountTarget",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"rootEl",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"embed",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"webrtcController",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"screenShareController",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"faceTrackingController",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"config",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"isInitialized",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"unloadHandler",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"pipController",{enumerable:!0,configurable:!0,writable:!0,value:null}),"undefined"!=typeof window&&(this.unloadHandler=()=>{this.screenShareController?.destroy()},window.addEventListener("beforeunload",this.unloadHandler))}renderApp(){if(!this.mountTarget||!this.config)return;this.rootEl||(this.rootEl=document.createElement("div"),this.rootEl.id="np_companion-sdk-root",this.mountTarget.appendChild(this.rootEl)),this.rootEl.className=Xt(this.config.position,this.config.avatarStyle?.view,this.config.className),Yt(this.rootEl,this.config.style),this.screenShareController||(this.screenShareController=function(e){const t=new Ct(1e3);let n=null,o=!1,a=!1;async function i(){if(!o&&!a)if(Jt()){a=!0;try{const a=await navigator.mediaDevices.getDisplayMedia({video:{frameRate:{max:1},width:{max:1280},height:{max:720}},audio:!1,selfBrowserSurface:"include"});n=a;const i=a.getVideoTracks()[0];i&&i.addEventListener("ended",()=>{r()}),t.setStream(a),o=!0,e?.onStateChange?.(!0),await function(e=5e3){const t=ut(pt.getState());return t&&"open"===t.readyState?Promise.resolve():new Promise((t,n)=>{const o=setTimeout(()=>{a(),n(new Error("Timed out waiting for data channel to open"))},e),a=pt.subscribe(()=>{const e=ut(pt.getState());e&&"open"===e.readyState&&(clearTimeout(o),a(),t())})})}(),St({type:qt.START_VIDEO,data:null}),ft.webrtc("Screen sharing started")}catch(e){throw n&&(n.getTracks().forEach(e=>e.stop()),n=null),t.setStream(null),o=!1,"NotAllowedError"===e.name?ft.warn("ScreenShare","Permission denied by user"):"NotFoundError"===e.name?ft.warn("ScreenShare","No screen sharing source selected"):ft.critical_warn("ScreenShare","Failed to start screen share:",e),e}finally{a=!1}}else ft.critical_warn("ScreenShare","getDisplayMedia is not supported in this browser")}function r(){o&&(n&&(n.getTracks().forEach(e=>e.stop()),n=null),t.setStream(null),o=!1,e?.onStateChange?.(!1),St({type:qt.STOP_VIDEO,data:null}),ft.webrtc("Screen sharing stopped"))}return{start:i,stop:r,toggle:async function(){o||a?o&&r():await i()},isSharing:function(){return o},isSupported:function(){return Jt()},getCapture:function(){return t},destroy:function(){r(),t.terminate()}}}({onStateChange:e=>{pt.dispatch(Je(e)),this.embed?.updateScreenShareState(e),this.config?.onScreenShareStateChange?.(e)}}));const e=Jt(),t=pt.getState().app.features.screenShare?.enabled??!1,n={isScreenSharing:this.screenShareController.isSharing(),isScreenShareSupported:e&&t,onScreenShareToggle:()=>this.handleScreenShareToggle()};this.embed?this.embed.update({avatarStyle:this.config.avatarStyle,features:pt.getState().app.features,onData:this.config.onData,onAvatarReady:this.config.onAvatarReady,onInactivityStatusChange:this.config.onInactivityStatusChange,onDestroy:()=>this.destroyInstance("ui_end"),onError:this.config.onError,...n}):this.embed=function(e,t={}){const n=bt.createDiv("np_companion-live-container np_companion-fade-in");e.appendChild(n);const o=function(e,t={}){const n=bt.createDiv("np_companion-avatar"),o=bt.createDiv(`np_companion-avatar-container np_companion-loader-${t.features?.showSDKLoader?.type??"spinner"}`);o.id="np_companion-avatar-container",t.avatarStyle?.view&&o.classList.add(`np_companion-view-${t.avatarStyle.view}`);const a=bt.createDiv("loader-container"),i=bt.createDiv("loader");a.appendChild(i);const r=bt.createVideo({className:"np_companion-avatar-video",autoplay:!0,muted:!0,playsInline:!0}),s=bt.createAudio({className:"np_companion-avatar-audio",autoplay:!0}),c=bt.createCanvas({className:"np_companion-avatar-canvas",styles:{width:"100%",height:"100%",objectFit:"cover",position:"relative",zIndex:"1"}});t.features?.backgroundRemoval?.enabled&&"silhouette"===t.avatarStyle?.view?r.classList.add("np_companion__d-none"):c.classList.add("np_companion__d-none"),o.appendChild(a),o.appendChild(r),o.appendChild(s),o.appendChild(c);const l=bt.createDiv(`np_companion-action-btn-container-wrapper np_companion-action-btn-container-view-${t.avatarStyle?.view}`),d=bt.createDiv(`np_companion-disclaimer-text np_companion-disclaimer-view-${t.avatarStyle?.view}`);d.style.display="none";const p=bt.createDiv(`np_companion-avatar-control-container np_companion-avatar-control-view-${t.avatarStyle?.view}`);p.appendChild(l),p.appendChild(d),n.appendChild(o),n.appendChild(p),e.appendChild(n);const u=zt();let h=(t.features?.backgroundRemoval?.enabled&&"silhouette"===t.avatarStyle?.view)??!1,f=null,m=null,g=!1,v=!1,b=!1,y=!1,_=null,w=!0,S=null,C=null,E=null;const x=new Qt(n,{onContinue:()=>{z();const e=t.features?.inactiveTimeout;e?.enabled&&W()},onEnd:()=>{t.onDestroy?.()}});let k=pt.getState().avatar.muted,T=pt.getState().avatar.volume,I=pt.getState().avatar.avatarSpeaking;const O=u.on("muted",e=>{pt.getState().avatar.muted!==e&&pt.dispatch(qe(e))}),N=pt.subscribe(()=>{const e=pt.getState();e.avatar.muted!==k&&(k=e.avatar.muted,u.setMuted(k),C?.update({isMuted:k}),L(k)),e.avatar.volume!==T&&(T=e.avatar.volume,s.volume=T/100),e.avatar.avatarSpeaking!==I&&(I=e.avatar.avatarSpeaking,C?.update({isAvatarSpeaking:I}))});let A=null;const D=()=>{w||(w=!0,p.className=P(),null!=S&&window.clearTimeout(S))},R=()=>{null!=S&&window.clearTimeout(S),S=window.setTimeout(()=>{w=!1,p.className=P()},5e3)};function P(){return mt(`np_companion-avatar-control-container np_companion-avatar-control-view-${t.avatarStyle?.view}`,{[vt]:!w})}function L(e){if(!v)return;const n=t.avatarStyle?.borderWidth??("silhouette"!==t.avatarStyle?.view?"4px":void 0);n&&(o.style.borderWidth=n);const a=("silhouette"!==t.avatarStyle?.view?e?"#ec3e41":t.avatarStyle?.borderColor??"#C0C0C0":void 0)??t.avatarStyle?.borderColor;a&&(o.style.borderColor=a);const i=t.avatarStyle?.borderStyle??("silhouette"!==t.avatarStyle?.view?"solid":void 0);i&&(o.style.borderStyle=i)}function M(e){"round"===t.avatarStyle?.view&&(o.style.transform=`translate(-50%, ${e??352-p.offsetHeight-212-12+"px"})`)}function j(){const e=t.features?.disclaimer?.enabled??!1;d.style.display=e&&v?"-webkit-box":"none",C?.update({features:{disclaimer:{enabled:e}}});const n=t.features?.disclaimer?.text??"This is an AI avatar. Check important info.";t.features?.disclaimer?.color&&(d.style.color=t.features?.disclaimer?.color),d.textContent=n,v&&M(e?void 0:"8%")}function F(){v||!t.features?.showSDKLoader?.enabled?n.classList.add("np_companion-bg-transparent"):n.classList.remove("np_companion-bg-transparent")}function V(){t.features?.showSDKLoader?.bgColor&&n.style.setProperty("--np-loader-bg-color",t.features.showSDKLoader.bgColor),t.features?.showSDKLoader?.color&&n.style.setProperty("--np-loader-color",t.features.showSDKLoader.color)}function z(){E&&(ft.timer("Resetting inactive timeout due to activity"),clearTimeout(E),E=null,pt.dispatch(Ge(!1)),t.onInactivityStatusChange?.(!1))}function W(){const e=t.features?.inactiveTimeout;e?.enabled?(z(),E=setTimeout(()=>{ft.timer(`Inactive timeout of ${e?.duration}ms reached, showing inactive overlay`),pt.dispatch(Ge(!0)),t.onInactivityStatusChange?.(!0),u.setMuted(!0),C?.update({isMuted:!0}),L(!0),x.isShowing()||x.show({type:Ut.LOCAL_TIMEOUT,duration:Math.min(e.countdown??30,60),message:void 0,isInteractionNeeded:!0})},e.duration)):(z(),x.isShowing()&&x.hide())}function U(){!C&&v&&(C=function(e,t){let n={...t};const o=zt();let a=null,i=null,r=[],s=!1;const c=document.createElement("div");c.className=E();const l=Wt("div","np_companion-action-btn-container-container"),d=Wt("div",mt("np_companion-chat-question-bar-container",gt)),p=Wt("div","np_companion-action-btn-container-left"),u=It(),h=u.element,f=Wt("div","np_companion-action-btn-container-middle"),m=Wt("div","np_companion-action-btn-container-wave");x();const g=document.createElement("canvas");g.width=160,g.height=40,g.className="np_companion-action-btn-container-canvas",m.appendChild(g);const v=Wt("div",mt("np_companion-action-btn-container-right",gt)),b=Nt(),y=Ot(()=>n.handleEnd?.()),_=y.element;p.appendChild(h),f.appendChild(m),v.appendChild(b.element);const w=At({onToggle:()=>n.onScreenShareToggle?.(),isSupported:n.isScreenShareSupported??!1});v.appendChild(w.element),v.appendChild(_),d.appendChild(p),d.appendChild(v),l.appendChild(d),c.appendChild(l),e.appendChild(c),C();const S=o.on("stream",()=>{C()});function C(){null!=i&&(cancelAnimationFrame(i),i=null),r=[],a=o.getAnalyser(),a&&function(){if(!a)return;const e=g.getContext("2d");if(!e)return;a.fftSize=256;const t=a.frequencyBinCount,o=new Uint8Array(t),c=Math.floor(g.width/3);0===r.length&&(r=new Array(c).fill(0));let l=0;const d=()=>{if(e.clearRect(0,0,g.width,g.height),e.beginPath(),e.moveTo(0,g.height/2),e.lineTo(g.width,g.height/2),e.strokeStyle="#ffffff",e.stroke(),n.isMuted)s=!1,pt.dispatch(Ye(!1)),r.fill(0),x();else{a.getByteFrequencyData(o);const n=4,i=Math.floor(.05*t),c=Math.floor(.4*t);let d=0;for(let e=i;e<c;e++)o[e]>d&&(d=o[e]);const p=d/255*g.height*.8;r.shift(),r.push(p);let u=r.slice(-5).some(e=>e>n);u?l=30:l>0&&(l--,u=!0),s=u,pt.dispatch(Ye(s)),x(),e.fillStyle="#ffffff";for(let t=0;t<r.length;t++){const n=3*t,o=r[t];e.fillRect(n,g.height/2-o/2,2,o),e.fillRect(n,g.height/2+o/2,2,-o)}}i=requestAnimationFrame(d)};d()}()}function E(){return mt("np_companion-align-middle",`np_companion-avatar-${n.avatarStyle?.view}`)}function x(){m.style.filter=!n.isMuted&&s?"brightness(0) saturate(100%) invert(48%) sepia(93%) saturate(1720%) hue-rotate(346deg) brightness(101%) contrast(103%)":"none",m.style.transition="filter 0.3s ease",m.style.height="40px",h.classList.remove("np_companion-talking")}return{update(e){const t=n;n={...n,...e},c.className=E(),t.selectedMicrophone!==n.selectedMicrophone&&C(),x(),n.features?.disclaimer?.enabled?l.classList.remove("np_companion_disclaimer-disabled"):l.classList.add("np_companion_disclaimer-disabled")},destroy(){null!=i&&cancelAnimationFrame(i),S(),u.destroy(),b.destroy(),w.destroy(),y.destroy(),c.parentNode&&c.parentNode.removeChild(c)}}}(l,{avatarStyle:t.avatarStyle,isMuted:!1,isAvatarSpeaking:pt.getState().avatar.avatarSpeaking,isScreenSharing:t.isScreenSharing,isScreenShareSupported:t.isScreenShareSupported,onScreenShareToggle:()=>t.onScreenShareToggle?.(),features:{waveform:{enabled:!1!==t.features?.waveform?.enabled},screenShare:t.features?.screenShare},onVolumeChange:e=>{pt.dispatch(Qe(e))},toggleMute:()=>{const e=pt.getState().avatar.muted;pt.dispatch(qe(!e)),z(),W()},onStopTalking:()=>{try{ft.avatar("stopping avatar"),St({type:qt.CANCEL})}catch(e){ft.critical_error("Avatar","Stop: failed to send interrupt",e)}z(),W()},handleEnd:()=>{t.onDestroy?.()}}))}function H(){const e=ut(pt.getState());return!!e&&"open"===e.readyState}function $(){g||v||b&&y&&(v=!0,t.onAvatarReady?.(!0),L(),U(),F(),j(),W(),M(),R())}function B(){b||(b=!0,$())}n.addEventListener("mouseenter",D),n.addEventListener("mousemove",D),n.addEventListener("mouseleave",R);const K=()=>{if(g)return;const e=c.getContext("2d",{willReadFrequently:!0});if(!e||!r||r.readyState<2)A=requestAnimationFrame(K);else{if(c.width=r.videoWidth,c.height=r.videoHeight,e.drawImage(r,0,0,c.width,c.height),h){const t=e.getImageData(0,0,c.width,c.height),n=yt.process(t);e.putImageData(n,0,0),B()}A=requestAnimationFrame(K)}};j(),V(),F(),y||_||(H()?(y=!0,$()):_=pt.subscribe(()=>{y||H()&&(y=!0,_?.(),_=null,$())}));const G={updateStreams:({videoStream:e,audioStream:n})=>{e&&e instanceof MediaStream?f!==e&&(ft.avatar("New video stream received:",{active:e.active,tracks:e.getTracks().length,videoTracks:e.getVideoTracks().length,id:e.id}),f=e,r.srcObject=e,g||r.play().then(()=>{g||h||B()}).catch(e=>{g||"AbortError"===e?.name||(ft.error("Failed to play video stream",e),t.onError?.(e))}),e.addEventListener("inactive",()=>{ft.avatar("Video stream became inactive")}),e.getTracks().forEach(e=>{e.addEventListener("ended",()=>{ft.avatar("Video track ended:",e.kind)})}),h&&!A&&(A=requestAnimationFrame(K))):(f=null,r.srcObject=null),void 0!==n&&(n&&n instanceof MediaStream?m!==n&&(m=n,s.srcObject=n,navigator.mediaSession.metadata=new MediaMetadata({title:"Napster Companion"}),g||s.play().catch(e=>{g||"AbortError"===e?.name||(ft.error("Failed to play audio stream",e),t.onError?.(e))})):(m=null,s.srcObject=null))},updateWaveform:e=>{U(),C?.update(e)},updateFeatures:e=>{t.features={...t.features||{},...e||{}},h=(t.features?.backgroundRemoval?.enabled&&"silhouette"===t.avatarStyle?.view)??!1,h?(r.classList.add("np_companion__d-none"),c.classList.remove("np_companion__d-none")):(r.classList.remove("np_companion__d-none"),c.classList.add("np_companion__d-none")),C?.update({features:{waveform:{enabled:!1!==t.features?.waveform?.enabled}}}),j(),V(),F(),W()},update:e=>{const n=t.avatarStyle?.view;Object.assign(t,e),e.features&&G.updateFeatures(e.features),e.avatarStyle?.view&&e.avatarStyle.view!==n&&(n&&o.classList.remove(`np_companion-view-${n}`),o.classList.add(`np_companion-view-${e.avatarStyle.view}`),t.features&&G.updateFeatures(t.features))},setAvatarReady:e=>{e||(v=!1,t.onAvatarReady?.(!1))},updateScreenShareState:e=>{t.isScreenSharing=e,C?.update({isScreenSharing:e})},setAudioMuted:e=>{s.muted=e},getAudioMuted:()=>s.muted,setAudioVolume:e=>{const t=Math.max(0,Math.min(1,e));s.volume=t},getAudioVolume:()=>s.volume,handleMessage:e=>{switch("undefined"!=typeof window&&window.parent&&window.parent.postMessage({type:"avatar-data-channel-message",event:e},"*"),e.event){case"avatar_state_changed":break;case"talk_state_changed":pt.dispatch(Ze("ended"!==e.data?.state&&"canceled"!==e.data?.state));break;case"message_received":{const{message:t}=e.data||{};if("completed"===t?.action&&"string"==typeof t.content&&t.role){z(),W();const e=x.getCurrentTrigger();e&&!e.isInteractionNeeded&&x.hide()}break}case"avatar_connection_warning":t.showAvatarInactiveOverlay&&(x.show({type:Ut.SERVER_WARNING,duration:e.data?.disconnect_after??30,message:"Avatar is disconnecting due to inactivity. Say something to keep it active.",isInteractionNeeded:!1}),u.setMuted(!1),C?.update({isMuted:!1}),L(!1))}t.onData?t.onData(e):ft.data("onData callback NOT called. Reason:",{onDataExists:!!t.onData,dataType:typeof e,dataIsNull:null===e})},destroy:e=>{if(!g){g=!0,_&&(_(),_=null),n.removeEventListener("mousemove",D),n.removeEventListener("mouseenter",D),n.removeEventListener("mouseleave",R),null!=S&&window.clearTimeout(S),null!=A&&(cancelAnimationFrame(A),A=null),E&&(clearTimeout(E),E=null);try{r.pause(),r.srcObject=null}catch{}try{s.pause(),s.srcObject=null}catch{}try{f?.getTracks().forEach(e=>e.stop())}catch{}try{m?.getTracks().forEach(e=>e.stop())}catch{}f=null,m=null,C?.destroy(),C=null,x?.destroy(),N(),O(),n.parentNode&&n.parentNode.removeChild(n),v=!1,t.onAvatarReady?.(!1),e||t.onDestroy?.()}}};return G}(n,{avatarStyle:t.avatarStyle,showAvatarInactiveOverlay:!0,onData:t.onData,onDestroy:t.onDestroy,onError:t.onError,onInactivityStatusChange:t.onInactivityStatusChange,onAvatarReady:t.onAvatarReady,features:t.features,onScreenShareToggle:t.onScreenShareToggle,isScreenSharing:t.isScreenSharing,isScreenShareSupported:t.isScreenShareSupported});return{update:e=>{o.update({avatarStyle:e.avatarStyle??t.avatarStyle,onData:e.onData??t.onData,onDestroy:e.onDestroy??t.onDestroy,onError:e.onError??t.onError,onInactivityStatusChange:e.onInactivityStatusChange??t.onInactivityStatusChange,onAvatarReady:e.onAvatarReady??t.onAvatarReady,features:e.features??t.features,onScreenShareToggle:e.onScreenShareToggle??t.onScreenShareToggle,isScreenSharing:e.isScreenSharing??t.isScreenSharing,isScreenShareSupported:e.isScreenShareSupported??t.isScreenShareSupported}),Object.assign(t,e)},updateStreams:e=>{o.updateStreams(e)},handleMessage:e=>{o.handleMessage(e)},updateScreenShareState:e=>{o.updateScreenShareState(e)},setAudioMuted:e=>{o.setAudioMuted(e)},getAudioMuted:()=>o.getAudioMuted(),setAudioVolume:e=>{o.setAudioVolume(e)},getAudioVolume:()=>o.getAudioVolume(),destroy:()=>{o.destroy(!0),n.parentNode===e&&e.removeChild(n),t.onDestroy?.()}}}(this.rootEl,{avatarStyle:this.config.avatarStyle,features:pt.getState().app.features,onData:this.config.onData,onAvatarReady:this.config.onAvatarReady,onInactivityStatusChange:this.config.onInactivityStatusChange,onDestroy:()=>this.destroyInstance("ui_end"),onError:this.config.onError,...n});const o=pt.getState().app.features.pictureInPicture?.enabled;o&&!this.pipController&&(this.pipController=function(e){let t=null,n=[];const o=()=>{if(t){n.forEach(e=>e.destroy()),n=[];try{t.close()}catch{}t=null,ft.info("PiP: window closed")}};try{navigator.mediaSession.setActionHandler("enterpictureinpicture",()=>{(async()=>{if(t)return;const o=window.documentPictureInPicture;if(!o)return void ft.info("PiP: Document PiP API not supported");const a=document.querySelector(".np_companion-avatar-video");if(a&&a.srcObject)try{const i=pt.getState().app.features.pictureInPicture;t=await o.requestWindow({width:i?.width??400,height:i?.height??300,disallowReturnToOpener:!1});const r=t.document.createElement("video");r.srcObject=a.srcObject,r.autoplay=!0,r.muted=!0,r.playsInline=!0,Object.assign(r.style,{position:"absolute",inset:"0",width:"100%",height:"100%",objectFit:"cover",objectPosition:"center"}),Object.assign(t.document.body.style,{margin:"0",overflow:"hidden",background:"#000",position:"relative",width:"100vw",height:"100vh"}),t.document.body.appendChild(r);const s=It(),c=Nt(),l=At({onToggle:e.onScreenShareToggle,isSupported:e.isScreenShareSupported()}),d=Ot(e.onEnd);n=[s,c,l,d];const p=t.document.createElement("div");Object.assign(p.style,{position:"absolute",bottom:"12px",left:"50%",transform:"translateX(-50%)",display:"flex",alignItems:"center",gap:"8px",padding:"16px 16px 12px",borderRadius:"80px",background:"rgba(0, 0, 0, 0.18)",boxShadow:"0px 4px 4px 0px rgba(0, 0, 0, 0.25), 2px 2px 8px 0px rgba(0, 0, 0, 0.12)",backdropFilter:"blur(34px)",zIndex:"10",transition:"all 0.3s ease-in-out"}),p.appendChild(s.element),p.appendChild(c.element),p.appendChild(l.element),p.appendChild(d.element),t.document.body.appendChild(p),ft.info("PiP: window opened, video cloned"),t.addEventListener("pagehide",()=>{n.forEach(e=>e.destroy()),n=[],t=null,ft.info("PiP: window closed by user")})}catch(e){ft.critical_error("PiP: requestWindow failed",e)}else ft.info("PiP: video element or stream not found")})().catch(e=>ft.critical_error("PiP: failed to open",e))})}catch{ft.info("PiP: Media Session enterpictureinpicture not supported")}const a=()=>{document.hidden||o()};return document.addEventListener("visibilitychange",a),{destroy:()=>{document.removeEventListener("visibilitychange",a);try{navigator.mediaSession.setActionHandler("enterpictureinpicture",null)}catch{}o()}}}({onEnd:()=>this.destroyInstance("api"),onScreenShareToggle:()=>this.handleScreenShareToggle(),isScreenShareSupported:()=>Jt()&&(pt.getState().app.features.screenShare?.enabled??!1)})),this.initializeWebRTC().catch(e=>{ft.critical_error("Failed to establish WebRTC connection:",e),this.config?.onError?.(e)})}async handleScreenShareToggle(){if(this.screenShareController)try{await this.screenShareController.toggle();const e=this.screenShareController.isSharing();pt.dispatch(Je(e)),this.embed?.updateScreenShareState(e),this.config?.onScreenShareStateChange?.(e)}catch(e){ft.critical_warn("SDK","Screen share toggle failed:",e),this.config?.onError?.(e);const t=this.screenShareController.isSharing();pt.dispatch(Je(t)),this.embed?.updateScreenShareState(t),this.config?.onScreenShareStateChange?.(t)}}async initializeWebRTC(){const e=pt.getState().avatar.connectionToken;if(e&&!this.webrtcController){ft.connection("Connecting WebRTC..."),this.webrtcController=function(e={}){const{currentAudioDeviceId:t,functions:n,screenShareCapture:i,onChatMessage:r,onConnectionSuccess:s,onConnectionError:c,onStreams:l,onDataChannel:d}=e;let p=null,u=null,h=null,f=null,m=null,g=null;const v=zt();let b=null,y="disconnected",_=0,w=null,S=null;function C(e,t){return e&&e.readyState===WebSocket.OPEN?(e.send(JSON.stringify(t)),!0):(ft.critical_warn("WebRTC",`WS send skipped; state=${e?.readyState}`),!1)}function E(e){S=e,c?.(e)}function x(e){y=e,ft.webrtc(`Connection status changed to: ${e}`)}async function k(e){if(p&&"disconnected"!==y)ft.warn("WebRTC","Connection already in progress, skipping...");else try{x("connecting"),S=null;const c=(e=>{try{const t=atob(e);return JSON.parse(t)}catch(e){return ft.critical_error("decodeToBase64: Error decoding token",e),null}})(e);if(!c)throw new o("Failed to decode connection token",{token:e?"provided":"missing"});w={...c,token:e},pt.dispatch(Be(c.connection.id));const y=await async function(e,t,n=!1){const a=`${e.replace(/\/$/,"")}/ws/connections/${t}/signaling`;u&&u.readyState===WebSocket.OPEN&&u.close();const i=new WebSocket(a);return u=i,await new Promise((e,t)=>{let a=!1;i.onopen=()=>{ft.connection(n?"WebSocket reconnected":"WebSocket connected"),x("connected"),_=0,a=!0,e()},i.onclose=e=>{ft.connection("WebSocket closed:",e),u=null,x("disconnected"),a||t(new o("WebSocket connection closed",{code:e.code,reason:e.reason,wasClean:e.wasClean}))},i.onerror=e=>{u=null;const n=new o("WebSocket connection error",{error:e,timestamp:(new Date).toISOString()});a?"connected"===p?.connectionState||"connected"===p?.iceConnectionState||"completed"===p?.iceConnectionState?x("disconnected"):(x("disconnected"),E(n)):(x("disconnected"),E(n),t(n))}}),pt.dispatch(Xe(void 0)),i}(c.connection.signalingEndpoint,c.connection.id),k=await async function(){ft.webrtc("Create PeerConnection");const e=new RTCPeerConnection(Zt);return p=e,e.addEventListener("connectionstatechange",()=>{"failed"===e.connectionState?E(new o("WebRTC connection failed")):"connected"===e.connectionState&&(x("connected"),_=0)}),function(e){g=e.addTransceiver("audio",{direction:"sendrecv"});const t=e.addTransceiver("video",{direction:"recvonly"});if(i){const t=i.getCanvas().captureStream(1);t.getTracks().forEach(n=>{e.addTrack(n,t)})}ft.webrtc("Added transceivers",{videoTransceiver:t,audioTransceiver:g});const o=e.createDataChannel("chat",{ordered:!0});m=o,o.onopen=()=>{ft.webrtc("Data channel opened"),pt.dispatch(Ke(o)),d?.(o),s?.(),n&&n.length>0&&(St({type:qt.SET_SETTINGS,data:{functions:n}}),ft.webrtc("Functions sent via data channel",n))},o.onclose=()=>{ft.webrtc("Data channel closed"),pt.dispatch(Ke(null))},o.onerror=e=>{ft.critical_error("WebRTC",e),E(new a("Data channel error",{error:e}))},o.onmessage=e=>{try{const t=JSON.parse(e.data);ft.data("Data channel message received:",t),r?.(t)}catch{r?.({event:"message_received",data:{message:{content:e.data,action:"completed"}}})}}}(e),e.ontrack=e=>{const t=e.streams[0];ft.webrtc(`${e.track.kind} stream received`,{streamId:t?.id,trackId:e.track.id,videoTracks:t?.getVideoTracks().length,audioTracks:t?.getAudioTracks().length}),"video"===e.track.kind?(h=t,f=t):"audio"===e.track.kind&&(f=t,h||(h=t)),l?.({videoStream:h,audioStream:f})},e}();await async function(){try{ft.webrtc("Setting up user media"),b||(b=v.on("stream",e=>{(async function(e){if(!g)return;const t=e?.getAudioTracks()[0]??null;await g.sender.replaceTrack(t)})(e).catch(e=>{ft.critical_error("WebRTC","Failed to apply mic track to sender",e),E(new a("Failed to replace audio track",{error:e}))})})),await v.start({deviceId:t})}catch(e){ft.critical_warn("WebRTC",e),E(new o("Failed to access user media",{error:e,deviceId:t}))}}(),await async function(e,t){e.addEventListener("icecandidate",e=>{const n=e.candidate;n&&(ft.webrtc("send ICE candidate"),C(t,{type:"add_ice_candidate",data:{candidate:n}}))}),e.addEventListener("negotiationneeded",async()=>{ft.webrtc("negotiationneeded — creating new offer");try{const n=await e.createOffer();await e.setLocalDescription(n),C(t,{type:"set_remote_description",data:n})}catch(e){ft.critical_error("WebRTC","Failed to renegotiate:",e)}}),ft.webrtc("createOffer → setLocalDescription → set_remote_description");const n=await e.createOffer();await e.setLocalDescription(n),C(t,{type:"set_remote_description",data:n})}(k,y),y.onmessage=e=>async function(e,t,n){try{const o=JSON.parse(n.data);switch(o.type){case"set_remote_description":ft.webrtc("Setting remote description"),await e.setRemoteDescription(o.data),await e.setLocalDescription(),C(t,{type:"set_local_description",data:e.localDescription});break;case"add_ice_candidate":o.data?.candidate&&await e.addIceCandidate(o.data.candidate);break;case"error":ft.critical_error("WebRTC",o.data?.error),E(new a(o.data?.error||"Server error",{serverMessage:o.data})),e.close(),t.close();break;default:ft.webrtc("Unknown message type:",o.type)}}catch(e){ft.critical_error("WebRTC",e),E(new a("Failed to process WebSocket message",{originalError:e,rawMessage:n.data}))}}(k,y,e)}catch(e){const t=e;throw ft.critical_error("WebRTC",t),E(t),x("disconnected"),t}}function T(){_=0;try{if(b&&(b(),b=null),v.stop(),m)try{m.close()}catch{}if(u)try{u.readyState!==WebSocket.OPEN&&u.readyState!==WebSocket.CONNECTING||u.close(1e3,"Connection closed by client")}catch{}try{h?.getTracks().forEach(e=>e.stop())}catch{}try{f?.getTracks().forEach(e=>e.stop())}catch{}if(p)try{p.getSenders().forEach(e=>{e.track&&e.track.stop()}),p.close()}catch{}}catch(e){ft.critical_warn("WebRTC",e)}finally{m=null,u=null,p=null,g=null,h=null,f=null,w=null,x("disconnected"),pt.dispatch(Be(void 0)),pt.dispatch(et(void 0))}}return pt.dispatch(et(T)),{startWithToken:k,close:T,forceReconnect:async function(){if(w){T(),_=0;try{await k(w.token)}catch(e){throw E(e),e}}else E(new o("No connection data available for reconnect"))},getConnectionStatus:function(){return y},getReconnectAttempts:function(){return _},getError:function(){return S},updateAudioDevice:async function(e){if(g)try{await v.switchDevice(e),ft.webrtc(`Audio device updated to: ${e}`)}catch(t){ft.critical_warn("WebRTC","Failed to update audio device:",t),E(new o("Failed to update audio device",{error:t,deviceId:e}))}else ft.warn("WebRTC","No audio transceiver available for device update")}}}({functions:this.config?.functions,screenShareCapture:this.screenShareController?.getCapture()??null,onStreams:e=>{this.embed?.updateStreams(e)},onChatMessage:e=>{this.embed?.handleMessage(e)},onConnectionError:e=>{ft.critical_error("WebRTC connection error:",e),this.config?.onError?.(e),this.webrtcController&&"disconnected"===this.webrtcController.getConnectionStatus()&&(ft.critical_error("SDK","Connection failed. Destroying SDK instance."),this.destroyInstance("internal"))}});try{ft.connection("Initializing WebRTC connection with token:",`${e.substring(0,50)}...`),await this.webrtcController.startWithToken(e),ft.connection("WebRTC initialization completed with token")}catch(e){throw ft.critical_error("SDK","Failed to Initialize WebRTC:",e),this.webrtcController=null,e}}}destroyWebRTC(){if(this.screenShareController?.isSharing()&&(this.screenShareController.stop(),pt.dispatch(Je(!1)),this.embed?.updateScreenShareState(!1),this.config?.onScreenShareStateChange?.(!1)),this.webrtcController){ft.info("SDK","Destroying WebRTC controller");try{this.webrtcController.close()}catch(e){ft.critical_error("SDK","Error closing WebRTC controller:",e)}this.webrtcController=null}}destroyInstance(e,t){if(!e)return void ft.critical_warn("SDK","destroyInstance ignored (no reason)");Lt("sdk_destroyed",{reason:e}),t?.();const n=this.config?.onDestroy;if(lt(null),pt.dispatch(Xe(void 0)),pt.dispatch(et(void 0)),pt.dispatch(qe(!1)),pt.dispatch(it()),pt.dispatch(rt(void 0)),this.pipController&&(this.pipController.destroy(),this.pipController=null),this.embed){try{this.embed.update({onDestroy:void 0}),this.embed.destroy()}catch(e){ft.critical_error("Error during cleanup:",e)}this.embed=null}this.screenShareController&&(this.screenShareController.destroy(),this.screenShareController=null),this.faceTrackingController&&(this.faceTrackingController.destroy(),this.faceTrackingController=null),this.unloadHandler&&"undefined"!=typeof window&&(window.removeEventListener("beforeunload",this.unloadHandler),this.unloadHandler=null),this.destroyWebRTC(),this.rootEl&&this.rootEl.parentNode&&this.rootEl.parentNode.removeChild(this.rootEl),this.rootEl=null,this.mountTarget=null,this.config=null,this.isInitialized=!1,n?.()}async init(e,o={}){try{if(this.isInitialized)throw new t("SDK is already initialized. Call destroy() first.",{code:c.ALREADY_INITIALIZED});o.analytics?.enabled&&(function(e){Pt=new Rt(e)}(o.analytics),Lt("sdk_init_started",{version:this.version,config:{position:o.position,features:Object.keys(o.features||{})}})),function(e){if(!e||"string"!=typeof e||""===e.trim())throw new n("Invalid connection token: expected non-empty string",{providedToken:typeof e,code:c.INVALID_TOKEN})}(e);const a={avatarStyle:{view:"round"},position:l.BOTTOM_RIGHT,...o};this.config=a,pt.dispatch(Xe(e)),pt.dispatch(qe(!1)),pt.dispatch(st(a.debug)),this.config.features&&Object.entries(this.config.features).forEach(([e,t])=>{const n=Et(e,t);pt.dispatch(at({feature:e,config:n}))}),lt(e=>{try{this.embed&&this.embed.update({features:e})}catch(e){ft.critical_error("Unable to update features",e)}this.config?.onFeaturesUpdate?.(e)});const i=function(e){if(!e)return document.body;if("string"==typeof e){const t=document.querySelector(e);return t instanceof HTMLElement?t:(ft.warn(`mountContainer should be a valid CSS selector. Provided selector "${e}" is invalid or did not match any elements. Defaulting to document.body.`),document.body)}return e instanceof HTMLElement?e:document.body}(this.config.mountContainer??void 0);return this.mountTarget=i,this.isInitialized=!0,this.renderApp(),this.config.onReady?.(),Lt("sdk_init_completed",{version:this.version,initTime:Date.now()}),this.createInstanceMethods()}catch(t){const n=d.handle(t,{method:"init",tokenProvided:!!e,config:o});throw o.onError?.(n),n}}createInstanceMethods(){const e=this;return{showAvatar:()=>{const e=document.getElementById("np_companion-avatar-container");e&&(e.style.display="block",Mt("show","avatar_widget"))},hideAvatar:()=>{const e=document.getElementById("np_companion-avatar-container");e&&(e.style.display="none",Mt("hide","avatar_widget"))},avatarIsVisible:()=>{const e=document.getElementById("np_companion-avatar-container");return!!e&&"none"!==e.style.display},destroy:()=>{const{closeConnectionHandler:e}=pt.getState().avatar;this.destroyInstance("api",e)},updateStyles:e=>{this.config&&(this.config.style={...this.config.style??{},...e??{}},this.rootEl&&Yt(this.rootEl,this.config.style))},setPosition:e=>{if(this.config&&(this.config.position=e,pt.dispatch?.(rt(e)),this.rootEl)){const t=Xt(e,this.config.avatarStyle?.view,this.config.className);this.rootEl.className=t}},clearPosition:()=>{this.config&&(pt.dispatch?.(rt(void 0)),this.config.position=void 0,this.rootEl&&(this.rootEl.className=Xt(void 0,this.config.avatarStyle?.view,this.config.className)))},enableFeature:e=>{pt.dispatch?.(at({feature:e,config:{enabled:!0}})),"disclaimer"===e&&this.rootEl&&this.rootEl.classList.remove("np_companion_disclaimer-disabled")},disableFeature:e=>{pt.dispatch?.(at({feature:e,config:{enabled:!1}})),"disclaimer"===e&&this.rootEl&&this.rootEl.classList.add("np_companion_disclaimer-disabled")},updateFeatureConfig:(e,t)=>{const n=Et(e,t);pt.dispatch?.(at({feature:e,config:n})),"disclaimer"===e&&this.rootEl&&(n?.enabled?this.rootEl.classList.remove("np_companion_disclaimer-disabled"):this.rootEl.classList.add("np_companion_disclaimer-disabled"))},updateAvatarStyle:e=>{if(this.config){if(this.config.avatarStyle={view:"round",...this.config.avatarStyle,...e},e.view&&this.rootEl){const t=Xt(this.config.position,e.view,this.config.className);this.rootEl.className=t}this.embed&&this.embed.update({avatarStyle:this.config.avatarStyle})}},sendCommand:e=>{St(e)},startScreenShare:async()=>{if(!this.screenShareController?.isSharing())try{await(this.screenShareController?.start());const e=this.screenShareController?.isSharing()??!1;pt.dispatch(Je(e)),this.embed?.updateScreenShareState(e),this.config?.onScreenShareStateChange?.(e)}catch(e){throw ft.critical_warn("SDK","Failed to start screen share:",e),this.config?.onError?.(e),e}},stopScreenShare:()=>{this.screenShareController?.isSharing()&&(this.screenShareController.stop(),pt.dispatch(Je(!1)),this.embed?.updateScreenShareState(!1),this.config?.onScreenShareStateChange?.(!1))},toggleScreenShare:async()=>{await this.handleScreenShareToggle()},get isScreenSharing(){return e.screenShareController?.isSharing()??!1},get isScreenShareSupported(){return Jt()&&(pt.getState().app.features.screenShare?.enabled??!1)},get sessionId(){return pt.getState().avatar.sessionId},muteAudio:()=>{this.embed?.setAudioMuted(!0),Mt("mute","avatar_audio")},unmuteAudio:()=>{this.embed?.setAudioMuted(!1),Mt("unmute","avatar_audio")},get isAudioMuted(){return e.embed?.getAudioMuted()??!1},setAudioVolume:e=>{this.embed?.setAudioVolume(e)},getAudioVolume:()=>this.embed?.getAudioVolume()??1,startFaceTracking:async()=>{const e=pt.getState().app.features.faceTracking;if(!e?.enabled)throw new i("Face tracking is not enabled. Set features.faceTracking.enabled = true.",{code:c.FEATURE_DISABLED});this.faceTrackingController||(this.faceTrackingController=function(e={},t={}){const n=Math.min(Math.max(e.fps??15,1),30),o=e.talkingThreshold??.015,a=e.videoWidth??640,i=e.videoHeight??480,r=1e3/n;let l=null,d=null,p=null,u=null,h=null,f=null,m=!1,g=!1,v=0;const b=function(e=5){let t=[];return{push:n=>(t.push(n),t.length>e&&t.shift(),t.reduce((e,t)=>e+t,0)/t.length),reset(){t=[]}}}(e.smoothingFrames??5);function y(e,n){const o=new s(e,n);ft.error("FaceTracking:",e),t.onError?.(o)}function _(){p||(p=document.createElement("canvas")),u||(u=p.getContext("2d"))}function w(e){m&&(e-v>=r&&(v=e,async function(){if(d&&h&&!(d.readyState<4))try{_(),p.width=d.videoWidth,p.height=d.videoHeight,u.drawImage(d,0,0);const e=await h.estimateFaces(p);if(e&&e.length>0){const n=e[0].keypoints,r=d.videoWidth||a,s=d.videoHeight||i,c=n.map(e=>({x:e.x/r,y:e.y/s,z:e.z??0})),l=function(e,t,n){if(!e||0===e.length)return null;const o=e[13],a=e[14],i=e[61],r=e[291];if(!(o&&a&&i&&r))return null;const s=Math.abs(o.y-a.y),c=Math.abs(r.x-i.x),l=s/Math.max(c,1),d=t||640,p=n||480;return{mouthLandmarks:{topLip:{x:o.x/d,y:o.y/p},bottomLip:{x:a.x/d,y:a.y/p},leftCorner:{x:i.x/d,y:i.y/p},rightCorner:{x:r.x/d,y:r.y/p}},openingRatio:l}}(n,r,s);let p=!1;l&&(p=b.push(l.openingRatio)>o),t.onData?.({landmarks:c,mouthLandmarks:l?.mouthLandmarks??null,isTalking:p})}else t.onData?.(null)}catch(e){ft.error("FaceTracking: detection error",e)}}()),f=requestAnimationFrame(w))}function S(){m=!1,null!==f&&(cancelAnimationFrame(f),f=null),l&&(l.getTracks().forEach(e=>e.stop()),l=null),d&&(d.srcObject=null,d=null),b.reset(),ft.info("FaceTracking:","Stopped (model kept for restart)")}return{start:async function(){g?y("Cannot start: face tracking service has been destroyed.",c.DETECTION_FAILED):m||(ft.info("FaceTracking:","Starting face tracking..."),await async function(){try{l=await navigator.mediaDevices.getUserMedia({video:{width:a,height:i,facingMode:"user"},audio:!1})}catch(e){throw e instanceof Error?"NotAllowedError"===e.name?y("Camera permission denied. Please allow camera access for face tracking.",c.CAMERA_PERMISSION_DENIED):"NotFoundError"===e.name?y("No camera found. Please ensure a camera is connected.",c.CAMERA_NOT_FOUND):y(`Camera error: ${e.message}`,c.CAMERA_PERMISSION_DENIED):y("Failed to access camera for face tracking.",c.CAMERA_PERMISSION_DENIED),e}d=document.createElement("video"),d.setAttribute("autoplay",""),d.setAttribute("playsinline",""),d.setAttribute("muted",""),d.muted=!0,d.srcObject=l,await new Promise((e,t)=>{if(!d)return t();d.onloadedmetadata=()=>{d.play().then(e).catch(t)}})}(),h||await async function(){try{const[e,t]=await Promise.all([import("@tensorflow/tfjs"),import("@tensorflow-models/face-landmarks-detection")]);await e.ready();const n=t.SupportedModels.MediaPipeFaceMesh;h=await t.createDetector(n,{runtime:"tfjs",maxFaces:1,refineLandmarks:!0}),ft.info("FaceTracking:","MediaPipe Face Mesh model loaded")}catch(e){throw y("Failed to load face detection model.",c.MODEL_LOAD_FAILED),e}}(),_(),b.reset(),m=!0,v=0,f=requestAnimationFrame(w),ft.info("FaceTracking:",`Detection running at ${n} FPS`))},stop:S,isActive:function(){return m},destroy:function(){if(S(),h){try{h.dispose()}catch{}h=null}p=null,u=null,g=!0,ft.info("FaceTracking:","Destroyed")}}}({fps:e.fps,talkingThreshold:e.talkingThreshold},{onData:e=>{this.config?.onFaceTrackingData?.(e)},onError:e=>{this.config?.onFaceTrackingError?.(e),this.config?.onError?.(e)}})),await this.faceTrackingController.start()},stopFaceTracking:()=>{this.faceTrackingController?.stop()}}}}Object.defineProperty(en,"instance",{enumerable:!0,configurable:!0,writable:!0,value:null});const tn=en.getInstance();return"undefined"!=typeof window&&(window.napsterCompanionApiSDK=tn),tn});
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).napsterCompanionApiSDK=t()}(this,function(){"use strict";class e extends Error{constructor(e,t,n){super(e),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"timestamp",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"context",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name="SDKError",this.code=t,this.timestamp=new Date,this.context=n,Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}toJSON(){return{name:this.name,message:this.message,code:this.code,timestamp:this.timestamp.toISOString(),context:this.context,stack:this.stack}}}class t extends e{constructor(e,t){super(e,"INITIALIZATION_ERROR",t),this.name="InitializationError"}}class n extends e{constructor(e,t){super(e,"TOKEN_ERROR",t),this.name="TokenError"}}class o extends e{constructor(e,t){super(e,"CONNECTION_ERROR",t),this.name="ConnectionError"}}class a extends e{constructor(e,t){super(e,"WEBRTC_ERROR",t),this.name="WebRTCError"}}class i extends e{constructor(e,t){super(e,"FEATURE_ERROR",t),this.name="FeatureError"}}class r extends e{constructor(e,t){super(e,"MEDIA_ERROR",t),this.name="MediaError"}}class s extends e{constructor(e,t,n){super(e,t,n),this.name="FaceTrackingError"}}var c,d;!function(e){e.ALREADY_INITIALIZED="ALREADY_INITIALIZED",e.INVALID_TOKEN="INVALID_TOKEN",e.REACT_VERSION_UNSUPPORTED="REACT_VERSION_UNSUPPORTED",e.CONTAINER_NOT_FOUND="CONTAINER_NOT_FOUND",e.CONNECTION_FAILED="CONNECTION_FAILED",e.TOKEN_GENERATION_FAILED="TOKEN_GENERATION_FAILED",e.MISSING_CREDENTIALS="MISSING_CREDENTIALS",e.WEBRTC_NOT_SUPPORTED="WEBRTC_NOT_SUPPORTED",e.PEER_CONNECTION_FAILED="PEER_CONNECTION_FAILED",e.DATA_CHANNEL_ERROR="DATA_CHANNEL_ERROR",e.API_REQUEST_FAILED="API_REQUEST_FAILED",e.INVALID_RESPONSE="INVALID_RESPONSE",e.RATE_LIMITED="RATE_LIMITED",e.INVALID_CONFIGURATION="INVALID_CONFIGURATION",e.MISSING_REQUIRED_CONFIG="MISSING_REQUIRED_CONFIG",e.FEATURE_NOT_SUPPORTED="FEATURE_NOT_SUPPORTED",e.FEATURE_DISABLED="FEATURE_DISABLED",e.MEDIA_ACCESS_DENIED="MEDIA_ACCESS_DENIED",e.MEDIA_DEVICE_ERROR="MEDIA_DEVICE_ERROR",e.VIDEO_LOAD_ERROR="VIDEO_LOAD_ERROR",e.CAMERA_PERMISSION_DENIED="CAMERA_PERMISSION_DENIED",e.CAMERA_NOT_FOUND="CAMERA_NOT_FOUND",e.MODEL_LOAD_FAILED="MODEL_LOAD_FAILED",e.DETECTION_FAILED="DETECTION_FAILED"}(c||(c={}));class l{static setErrorHandler(e){this.onError=e}static handle(t,n){let o;return function(t){return t instanceof e}(t)?(o=t,n&&(o.context={...o.context,...n})):o=t instanceof Error?new e(t.message,"UNKNOWN_ERROR",{originalError:t.name,...n}):new e("string"==typeof t?t:"Unknown error occurred","UNKNOWN_ERROR",{originalError:t,...n}),this.onError?.(o),o}}function p(e){return`Minified Redux error #${e}; visit https://redux.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}!function(e){e.BOTTOM_RIGHT="bottom-right",e.BOTTOM_CENTER="bottom-center",e.BOTTOM_LEFT="bottom-left",e.TOP_RIGHT="top-right",e.TOP_CENTER="top-center",e.TOP_LEFT="top-left",e.CENTER="center"}(d||(d={}));var u=(()=>"function"==typeof Symbol&&Symbol.observable||"@@observable")(),h=()=>Math.random().toString(36).substring(7).split("").join("."),f={INIT:`@@redux/INIT${h()}`,REPLACE:`@@redux/REPLACE${h()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${h()}`};function m(e){if("object"!=typeof e||null===e)return!1;let t=e;for(;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t||null===Object.getPrototypeOf(e)}function g(e,t,n){if("function"!=typeof e)throw new Error(p(2));if("function"==typeof t&&"function"==typeof n||"function"==typeof n&&"function"==typeof arguments[3])throw new Error(p(0));if("function"==typeof t&&void 0===n&&(n=t,t=void 0),void 0!==n){if("function"!=typeof n)throw new Error(p(1));return n(g)(e,t)}let o=e,a=t,i=new Map,r=i,s=0,c=!1;function d(){r===i&&(r=new Map,i.forEach((e,t)=>{r.set(t,e)}))}function l(){if(c)throw new Error(p(3));return a}function h(e){if("function"!=typeof e)throw new Error(p(4));if(c)throw new Error(p(5));let t=!0;d();const n=s++;return r.set(n,e),function(){if(t){if(c)throw new Error(p(6));t=!1,d(),r.delete(n),i=null}}}function v(e){if(!m(e))throw new Error(p(7));if(void 0===e.type)throw new Error(p(8));if("string"!=typeof e.type)throw new Error(p(17));if(c)throw new Error(p(9));try{c=!0,a=o(a,e)}finally{c=!1}return(i=r).forEach(e=>{e()}),e}return v({type:f.INIT}),{dispatch:v,subscribe:h,getState:l,replaceReducer:function(e){if("function"!=typeof e)throw new Error(p(10));o=e,v({type:f.REPLACE})},[u]:function(){const e=h;return{subscribe(t){if("object"!=typeof t||null===t)throw new Error(p(11));function n(){t.next&&t.next(l())}return n(),{unsubscribe:e(n)}},[u](){return this}}}}}function v(...e){return 0===e.length?e=>e:1===e.length?e[0]:e.reduce((e,t)=>(...n)=>e(t(...n)))}var b=Symbol.for("immer-nothing"),y=Symbol.for("immer-draftable"),_=Symbol.for("immer-state");function w(e,...t){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var S=Object,C=S.getPrototypeOf,E="constructor",x="prototype",k="configurable",T="enumerable",I="writable",O="value",N=e=>!!e&&!!e[_];function A(e){return!!e&&(P(e)||z(e)||!!e[y]||!!e[E]?.[y]||W(e)||U(e))}var D=S[x][E].toString(),R=new WeakMap;function P(e){if(!e||!H(e))return!1;const t=C(e);if(null===t||t===S[x])return!0;const n=S.hasOwnProperty.call(t,E)&&t[E];if(n===Object)return!0;if(!$(n))return!1;let o=R.get(n);return void 0===o&&(o=Function.toString.call(n),R.set(n,o)),o===D}function L(e,t,n=!0){0===M(e)?(n?Reflect.ownKeys(e):S.keys(e)).forEach(n=>{t(n,e[n],e)}):e.forEach((n,o)=>t(o,n,e))}function M(e){const t=e[_];return t?t.type_:z(e)?1:W(e)?2:U(e)?3:0}var j=(e,t,n=M(e))=>2===n?e.has(t):S[x].hasOwnProperty.call(e,t),F=(e,t,n=M(e))=>2===n?e.get(t):e[t],V=(e,t,n,o=M(e))=>{2===o?e.set(t,n):3===o?e.add(n):e[t]=n},z=Array.isArray,W=e=>e instanceof Map,U=e=>e instanceof Set,H=e=>"object"==typeof e,$=e=>"function"==typeof e,B=e=>"boolean"==typeof e,K=e=>e.copy_||e.base_,G=e=>e.modified_?e.copy_:e.base_;function q(e,t){if(W(e))return new Map(e);if(U(e))return new Set(e);if(z(e))return Array[x].slice.call(e);const n=P(e);if(!0===t||"class_only"===t&&!n){const t=S.getOwnPropertyDescriptors(e);delete t[_];let n=Reflect.ownKeys(t);for(let o=0;o<n.length;o++){const a=n[o],i=t[a];!1===i[I]&&(i[I]=!0,i[k]=!0),(i.get||i.set)&&(t[a]={[k]:!0,[I]:!0,[T]:i[T],[O]:e[a]})}return S.create(C(e),t)}{const t=C(e);if(null!==t&&n)return{...e};const o=S.create(t);return S.assign(o,e)}}function Q(e,t=!1){return J(e)||N(e)||!A(e)||(M(e)>1&&S.defineProperties(e,{set:Z,add:Z,clear:Z,delete:Z}),S.freeze(e),t&&L(e,(e,t)=>{Q(t,!0)},!1)),e}var Z={[O]:function(){w(2)}};function J(e){return null===e||!H(e)||S.isFrozen(e)}var Y="MapSet",X="Patches",ee={};function te(e){const t=ee[e];return t||w(0),t}var ne,oe=e=>!!ee[e],ae=()=>ne;function ie(e,t){t&&(e.patchPlugin_=te(X),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function re(e){se(e),e.drafts_.forEach(de),e.drafts_=null}function se(e){e===ne&&(ne=e.parent_)}var ce=e=>ne=((e,t)=>({drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:oe(Y)?te(Y):void 0}))(ne,e);function de(e){const t=e[_];0===t.type_||1===t.type_?t.revoke_():t.revoked_=!0}function le(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];if(void 0!==e&&e!==n){n[_].modified_&&(re(t),w(4)),A(e)&&(e=pe(t,e));const{patchPlugin_:o}=t;o&&o.generateReplacementPatches_(n[_].base_,e,t)}else e=pe(t,n);return function(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&Q(t,n)}(t,e,!0),re(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==b?e:void 0}function pe(e,t){if(J(t))return t;const n=t[_];if(!n)return ve(t,e.handledSet_,e);if(!he(n,e))return t;if(!n.modified_)return n.base_;if(!n.finalized_){const{callbacks_:t}=n;if(t)for(;t.length>0;)t.pop()(e);ge(n,e)}return n.copy_}function ue(e){e.finalized_=!0,e.scope_.unfinalizedDrafts_--}var he=(e,t)=>e.scope_===t,fe=[];function me(e,t,n,o){const a=K(e),i=e.type_;if(void 0!==o&&F(a,o,i)===t)return void V(a,o,n,i);if(!e.draftLocations_){const t=e.draftLocations_=new Map;L(a,(e,n)=>{if(N(n)){const o=t.get(n)||[];o.push(e),t.set(n,o)}})}const r=e.draftLocations_.get(t)??fe;for(const e of r)V(a,e,n,i)}function ge(e,t){if(e.modified_&&!e.finalized_&&(3===e.type_||(e.assigned_?.size??0)>0)){const{patchPlugin_:n}=t;if(n){const o=n.getPath(e);o&&n.generatePatches_(e,o,t)}ue(e)}}function ve(e,t,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||N(e)||t.has(e)||!A(e)||J(e)||(t.add(e),L(e,(o,a)=>{if(N(a)){const t=a[_];if(he(t,n)){const n=G(t);V(e,o,n,e.type_),ue(t)}}else A(a)&&ve(a,t,n)})),e}var be={get(e,t){if(t===_)return e;const n=K(e);if(!j(n,t,e.type_))return function(e,t,n){const o=we(t,n);return o?O in o?o[O]:o.get?.call(e.draft_):void 0}(e,n,t);const o=n[t];if(e.finalized_||!A(o))return o;if(o===_e(e.base_,t)){Ce(e);const n=1===e.type_?+t:t,a=Ee(0,o,e,n);return e.copy_[n]=a}return o},has:(e,t)=>t in K(e),ownKeys:e=>Reflect.ownKeys(K(e)),set(e,t,n){const o=we(K(e),t);if(o?.set)return o.set.call(e.draft_,n),!0;if(!e.modified_){const o=_e(K(e),t),a=o?.[_];if(a&&a.base_===n)return e.copy_[t]=n,e.assigned_.set(t,!1),!0;if(function(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}(n,o)&&(void 0!==n||j(e.base_,t,e.type_)))return!0;Ce(e),Se(e)}return e.copy_[t]===n&&(void 0!==n||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_.set(t,!0),function(e,t,n){const{scope_:o}=e;if(N(n)){const a=n[_];he(a,o)&&a.callbacks_.push(function(){Ce(e);const o=G(a);me(e,n,o,t)})}else A(n)&&e.callbacks_.push(function(){const a=K(e);F(a,t,e.type_)===n&&o.drafts_.length>1&&!0===(e.assigned_.get(t)??!1)&&e.copy_&&ve(F(e.copy_,t,e.type_),o.handledSet_,o)})}(e,t,n)),!0},deleteProperty:(e,t)=>(Ce(e),void 0!==_e(e.base_,t)||t in e.base_?(e.assigned_.set(t,!1),Se(e)):e.assigned_.delete(t),e.copy_&&delete e.copy_[t],!0),getOwnPropertyDescriptor(e,t){const n=K(e),o=Reflect.getOwnPropertyDescriptor(n,t);return o?{[I]:!0,[k]:1!==e.type_||"length"!==t,[T]:o[T],[O]:n[t]}:o},defineProperty(){w(11)},getPrototypeOf:e=>C(e.base_),setPrototypeOf(){w(12)}},ye={};function _e(e,t){const n=e[_];return(n?K(n):e)[t]}function we(e,t){if(!(t in e))return;let n=C(e);for(;n;){const e=Object.getOwnPropertyDescriptor(n,t);if(e)return e;n=C(n)}}function Se(e){e.modified_||(e.modified_=!0,e.parent_&&Se(e.parent_))}function Ce(e){e.copy_||(e.assigned_=new Map,e.copy_=q(e.base_,e.scope_.immer_.useStrictShallowCopy_))}function Ee(e,t,n,o){const[a,i]=W(t)?te(Y).proxyMap_(t,n):U(t)?te(Y).proxySet_(t,n):function(e,t){const n=z(e),o={type_:n?1:0,scope_:t?t.scope_:ae(),modified_:!1,finalized_:!1,assigned_:void 0,parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1,callbacks_:void 0};let a=o,i=be;n&&(a=[o],i=ye);const{revoke:r,proxy:s}=Proxy.revocable(a,i);return o.draft_=s,o.revoke_=r,[s,o]}(t,n);return(n?.scope_??ae()).drafts_.push(a),i.callbacks_=n?.callbacks_??[],i.key_=o,n&&void 0!==o?function(e,t,n){e.callbacks_.push(function(o){const a=t;if(!a||!he(a,o))return;o.mapSetPlugin_?.fixSetContents(a);const i=G(a);me(e,a.draft_??a,i,n),ge(a,o)})}(n,i,o):i.callbacks_.push(function(e){e.mapSetPlugin_?.fixSetContents(i);const{patchPlugin_:t}=e;i.modified_&&t&&t.generatePatches_(i,[],e)}),a}function xe(e){if(!A(e)||J(e))return e;const t=e[_];let n,o=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=q(e,t.scope_.immer_.useStrictShallowCopy_),o=t.scope_.immer_.shouldUseStrictIteration()}else n=q(e,!0);return L(n,(e,t)=>{V(n,e,xe(t))},o),t&&(t.finalized_=!1),n}L(be,(e,t)=>{ye[e]=function(){const e=arguments;return e[0]=e[0][0],t.apply(this,e)}}),ye.deleteProperty=function(e,t){return ye.set.call(this,e,t,void 0)},ye.set=function(e,t,n){return be.set.call(this,e[0],t,n,e[0])};var ke=(new class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(e,t,n)=>{if($(e)&&!$(t)){const n=t;t=e;const o=this;return function(e=n,...a){return o.produce(e,e=>t.call(this,e,...a))}}let o;if($(t)||w(6),void 0===n||$(n)||w(7),A(e)){const a=ce(this),i=Ee(0,e,void 0);let r=!0;try{o=t(i),r=!1}finally{r?re(a):se(a)}return ie(a,n),le(o,a)}if(!e||!H(e)){if(o=t(e),void 0===o&&(o=e),o===b&&(o=void 0),this.autoFreeze_&&Q(o,!0),n){const t=[],a=[];te(X).generateReplacementPatches_(e,o,{patches_:t,inversePatches_:a}),n(t,a)}return o}w(1)},this.produceWithPatches=(e,t)=>{if($(e))return(t,...n)=>this.produceWithPatches(t,t=>e(t,...n));let n,o;return[this.produce(e,t,(e,t)=>{n=e,o=t}),n,o]},B(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),B(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),B(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){A(e)||w(8),N(e)&&(e=function(e){return N(e)||w(10),xe(e)}(e));const t=ce(this),n=Ee(0,e,void 0);return n[_].isManual_=!0,se(t),n}finishDraft(e,t){const n=e&&e[_];n&&n.isManual_||w(9);const{scope_:o}=n;return ie(o,t),le(void 0,o)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}setUseStrictIteration(e){this.useStrictIteration_=e}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){const o=t[n];if(0===o.path.length&&"replace"===o.op){e=o.value;break}}n>-1&&(t=t.slice(n+1));const o=te(X).applyPatches_;return N(e)?o(e,t):this.produce(e,e=>o(e,t))}}).produce;function Te(e){return({dispatch:t,getState:n})=>o=>a=>"function"==typeof a?a(t,n,e):o(a)}var Ie=Te(),Oe=Te,Ne="undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(0!==arguments.length)return"object"==typeof arguments[0]?v:v.apply(null,arguments)};function Ae(e,t){function n(...n){if(t){let o=t(...n);if(!o)throw new Error(He(0));return{type:e,payload:o.payload,..."meta"in o&&{meta:o.meta},..."error"in o&&{error:o.error}}}return{type:e,payload:n[0]}}return n.toString=()=>`${e}`,n.type=e,n.match=t=>function(e){return m(e)&&"type"in e&&"string"==typeof e.type}(t)&&t.type===e,n}var De=class e extends Array{constructor(...t){super(...t),Object.setPrototypeOf(this,e.prototype)}static get[Symbol.species](){return e}concat(...e){return super.concat.apply(this,e)}prepend(...t){return 1===t.length&&Array.isArray(t[0])?new e(...t[0].concat(this)):new e(...t.concat(this))}};function Re(e){return A(e)?ke(e,()=>{}):e}function Pe(e,t,n){return e.has(t)?e.get(t):e.set(t,n(t)).get(t)}var Le=e=>t=>{setTimeout(t,e)};function Me(e){const t={},n=[];let o;const a={addCase(e,n){const o="string"==typeof e?e:e.type;if(!o)throw new Error(He(28));if(o in t)throw new Error(He(29));return t[o]=n,a},addAsyncThunk:(e,o)=>(o.pending&&(t[e.pending.type]=o.pending),o.rejected&&(t[e.rejected.type]=o.rejected),o.fulfilled&&(t[e.fulfilled.type]=o.fulfilled),o.settled&&n.push({matcher:e.settled,reducer:o.settled}),a),addMatcher:(e,t)=>(n.push({matcher:e,reducer:t}),a),addDefaultCase:e=>(o=e,a)};return e(a),[t,n,o]}var je=Symbol.for("rtk-slice-createasyncthunk");function Fe(e,t){return`${e}/${t}`}function Ve({creators:e}={}){const t=e?.asyncThunk?.[je];return function(e){const{name:n,reducerPath:o=n}=e;if(!n)throw new Error(He(11));const a=("function"==typeof e.reducers?e.reducers(function(){function e(e,t){return{_reducerDefinitionType:"asyncThunk",payloadCreator:e,...t}}return e.withTypes=()=>e,{reducer:e=>Object.assign({[e.name]:(...t)=>e(...t)}[e.name],{_reducerDefinitionType:"reducer"}),preparedReducer:(e,t)=>({_reducerDefinitionType:"reducerWithPrepare",prepare:e,reducer:t}),asyncThunk:e}}()):e.reducers)||{},i=Object.keys(a),r={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},s={addCase(e,t){const n="string"==typeof e?e:e.type;if(!n)throw new Error(He(12));if(n in r.sliceCaseReducersByType)throw new Error(He(13));return r.sliceCaseReducersByType[n]=t,s},addMatcher:(e,t)=>(r.sliceMatchers.push({matcher:e,reducer:t}),s),exposeAction:(e,t)=>(r.actionCreators[e]=t,s),exposeCaseReducer:(e,t)=>(r.sliceCaseReducersByName[e]=t,s)};function c(){const[t={},n=[],o]="function"==typeof e.extraReducers?Me(e.extraReducers):[e.extraReducers],a={...t,...r.sliceCaseReducersByType};return function(e){let t,[i,s,c]=Me(e=>{for(let t in a)e.addCase(t,a[t]);for(let t of r.sliceMatchers)e.addMatcher(t.matcher,t.reducer);for(let t of n)e.addMatcher(t.matcher,t.reducer);o&&e.addDefaultCase(o)});if(function(e){return"function"==typeof e}(e))t=()=>Re(e());else{const n=Re(e);t=()=>n}function d(e=t(),n){let o=[i[n.type],...s.filter(({matcher:e})=>e(n)).map(({reducer:e})=>e)];return 0===o.filter(e=>!!e).length&&(o=[c]),o.reduce((e,t)=>{if(t){if(N(e)){const o=t(e,n);return void 0===o?e:o}if(A(e))return ke(e,e=>t(e,n));{const o=t(e,n);if(void 0===o){if(null===e)return e;throw Error("A case reducer on a non-draftable value must not return undefined")}return o}}return e},e)}return d.getInitialState=t,d}(e.initialState)}i.forEach(o=>{const i=a[o],r={reducerName:o,type:Fe(n,o),createNotation:"function"==typeof e.reducers};!function(e){return"asyncThunk"===e._reducerDefinitionType}(i)?function({type:e,reducerName:t,createNotation:n},o,a){let i,r;if("reducer"in o){if(n&&!function(e){return"reducerWithPrepare"===e._reducerDefinitionType}(o))throw new Error(He(17));i=o.reducer,r=o.prepare}else i=o;a.addCase(e,i).exposeCaseReducer(t,i).exposeAction(t,r?Ae(e,r):Ae(e))}(r,i,s):function({type:e,reducerName:t},n,o,a){if(!a)throw new Error(He(18));const{payloadCreator:i,fulfilled:r,pending:s,rejected:c,settled:d,options:l}=n,p=a(e,i,l);o.exposeAction(t,p),r&&o.addCase(p.fulfilled,r),s&&o.addCase(p.pending,s),c&&o.addCase(p.rejected,c),d&&o.addMatcher(p.settled,d),o.exposeCaseReducer(t,{fulfilled:r||Ue,pending:s||Ue,rejected:c||Ue,settled:d||Ue})}(r,i,s,t)});const d=e=>e,l=new Map,p=new WeakMap;let u;function h(e,t){return u||(u=c()),u(e,t)}function f(){return u||(u=c()),u.getInitialState()}function m(t,n=!1){function o(e){let a=e[t];return void 0===a&&n&&(a=Pe(p,o,f)),a}function a(t=d){const o=Pe(l,n,()=>new WeakMap);return Pe(o,t,()=>{const o={};for(const[a,i]of Object.entries(e.selectors??{}))o[a]=ze(i,t,()=>Pe(p,t,f),n);return o})}return{reducerPath:t,getSelectors:a,get selectors(){return a(o)},selectSlice:o}}const g={name:n,reducer:h,actions:r.actionCreators,caseReducers:r.sliceCaseReducersByName,getInitialState:f,...m(o),injectInto(e,{reducerPath:t,...n}={}){const a=t??o;return e.inject({reducerPath:a,reducer:h},n),{...g,...m(a,!0)}}};return g}}function ze(e,t,n,o){function a(a,...i){let r=t(a);return void 0===r&&o&&(r=n()),e(r,...i)}return a.unwrapped=e,a}var We=Ve();function Ue(){}function He(e){return`Minified Redux Toolkit error #${e}; visit https://redux-toolkit.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}const $e=We({name:"avatar",initialState:{avatarReady:!1,dataChannel:null,stopInteraction:!1,muted:!1,volume:70,avatarSpeaking:!1,isScreenSharing:!1,isUserTalking:!1,transcript:void 0,customVoiceId:void 0,defaultVoiceId:void 0,connectionToken:void 0,companionId:void 0,closeConnectionHandler:void 0},reducers:{setSessionId:(e,t)=>{e.sessionId=t.payload},setAvatarReady:(e,t)=>{e.avatarReady=t.payload},setDataChannel:(e,t)=>{e.dataChannel=t.payload},setAvatarId:(e,t)=>{e.avatarId=t.payload},setVideoId:(e,t)=>{e.videoId=t.payload},setStopInteraction:(e,t)=>{e.stopInteraction=t.payload},setMuted:(e,t)=>{e.muted=t.payload},setVolume:(e,t)=>{e.volume=t.payload},setAvatarSpeaking:(e,t)=>{e.avatarSpeaking=t.payload},setScreenSharing:(e,t)=>{e.isScreenSharing=t.payload},setUserTalking:(e,t)=>{e.isUserTalking=t.payload},addTranscript:(e,t)=>{e.transcript=t.payload},setCustomVoiceId:(e,t)=>{e.customVoiceId=t.payload},setDefaultVoiceId:(e,t)=>{e.defaultVoiceId=t.payload},setConnectionToken:(e,t)=>{e.connectionToken=t.payload},setCloseConnectionHandler:(e,t)=>{e.closeConnectionHandler=t.payload}}}),{setSessionId:Be,setDataChannel:Ke,setStopInteraction:Ge,setMuted:qe,setVolume:Qe,setAvatarSpeaking:Ze,setScreenSharing:Je,setUserTalking:Ye,setConnectionToken:Xe,setCloseConnectionHandler:et}=$e.actions,tt=$e.reducer,nt={features:{backgroundRemoval:{enabled:!0},waveform:{enabled:!0,color:"#ffffff"},inactiveTimeout:{enabled:!0,duration:6e4,countdown:30},disclaimer:{enabled:!0,text:"This is an AI avatar. Check important info."},showSDKLoader:{enabled:!0,bgColor:"rgb(222 222 222 / 60%)",color:"#585858ff",type:"spinner"},pictureInPicture:{enabled:!1}},position:void 0,showExperience:!1,debugMode:!1},ot=We({name:"app",initialState:nt,reducers:{setFeatures:(e,t)=>{const{feature:n,config:o}=t.payload,a=e.features[n];e.features[n]={...a,...o,enabled:o?.enabled??!!a?.enabled}},resetFeatures:e=>{e.features=nt.features},setPosition:(e,t)=>{e.position=t.payload},setShowExperience:(e,t)=>{e.showExperience=t.payload},setDebugMode:(e,t)=>{e.debugMode=t.payload}}}),{setFeatures:at,resetFeatures:it,setPosition:rt,setDebugMode:st}=ot.actions;let ct=null;const dt=e=>{ct=e},lt=e=>t=>n=>{const o=e.getState().app.features,a=t(n),i=e.getState().app.features;return ct&&o!==i&&JSON.stringify(o)!==JSON.stringify(i)&&ct(i),a},pt=function(e){const t=function(e){const{thunk:t=!0,immutableCheck:n=!0,serializableCheck:o=!0,actionCreatorCheck:a=!0}=e??{};let i=new De;return t&&(function(e){return"boolean"==typeof e}(t)?i.push(Ie):i.push(Oe(t.extraArgument))),i},{reducer:n,middleware:o,devTools:a=!0,preloadedState:i,enhancers:r}=e||{};let s,c;if("function"==typeof n)s=n;else{if(!m(n))throw new Error(He(1));s=function(e){const t=Object.keys(e),n={};for(let o=0;o<t.length;o++){const a=t[o];"function"==typeof e[a]&&(n[a]=e[a])}const o=Object.keys(n);let a;try{!function(e){Object.keys(e).forEach(t=>{const n=e[t];if(void 0===n(void 0,{type:f.INIT}))throw new Error(p(12));if(void 0===n(void 0,{type:f.PROBE_UNKNOWN_ACTION()}))throw new Error(p(13))})}(n)}catch(e){a=e}return function(e={},t){if(a)throw a;let i=!1;const r={};for(let a=0;a<o.length;a++){const s=o[a],c=e[s],d=(0,n[s])(c,t);if(void 0===d)throw new Error(p(14));r[s]=d,i=i||d!==c}return i=i||o.length!==Object.keys(e).length,i?r:e}}(n)}c="function"==typeof o?o(t):t();let d=v;a&&(d=Ne({trace:!1,..."object"==typeof a&&a}));const l=function(...e){return t=>(n,o)=>{const a=t(n,o);let i=()=>{throw new Error(p(15))};const r={getState:a.getState,dispatch:(e,...t)=>i(e,...t)},s=e.map(e=>e(r));return i=v(...s)(a.dispatch),{...a,dispatch:i}}}(...c),u=(e=>function(t){const{autoBatch:n=!0}=t??{};let o=new De(e);return n&&o.push(((e={type:"raf"})=>t=>(...n)=>{const o=t(...n);let a=!0,i=!1,r=!1;const s=new Set,c="tick"===e.type?queueMicrotask:"raf"===e.type?"undefined"!=typeof window&&window.requestAnimationFrame?window.requestAnimationFrame:Le(10):"callback"===e.type?e.queueNotification:Le(e.timeout),d=()=>{r=!1,i&&(i=!1,s.forEach(e=>e()))};return Object.assign({},o,{subscribe(e){const t=o.subscribe(()=>a&&e());return s.add(e),()=>{t(),s.delete(e)}},dispatch(e){try{return a=!e?.meta?.RTK_autoBatch,i=!a,i&&(r||(r=!0,c(d))),o.dispatch(e)}finally{a=!0}}})})("object"==typeof n?n:void 0)),o})(l);return g(s,i,d(..."function"==typeof r?r(u):u()))}({reducer:{avatar:tt,app:ot.reducer},middleware:e=>e({serializableCheck:!1}).concat(lt)}),ut=e=>e.avatar.dataChannel;var ht;!function(e){e.INFO="info",e.WARN="warn",e.ERROR="error",e.DEBUG="debug"}(ht||(ht={}));const ft=new class{constructor(){Object.defineProperty(this,"prefix",{enumerable:!0,configurable:!0,writable:!0,value:"[Napster SDK]"})}isDebugEnabled(){try{return pt.getState().app.debugMode||!1}catch{return!1}}log(e,...t){if(!this.isDebugEnabled())return;const n=[this.prefix,...t];switch(e){case ht.INFO:console.info(...n);break;case ht.WARN:console.warn(...n);break;case ht.ERROR:console.error(...n);break;case ht.DEBUG:console.debug(...n)}}info(...e){this.log(ht.INFO,"ℹ️",...e)}debug(...e){this.log(ht.DEBUG,"🐞",...e)}warn(...e){this.log(ht.WARN,"⚠️",...e)}error(...e){this.log(ht.ERROR,"❌",...e)}critical_warn(...e){console.warn(this.prefix,"⚠️",...e)}critical_error(...e){console.error(this.prefix,"❌",...e)}webrtc(...e){this.log(ht.INFO,"📡 WebRTC:",...e)}avatar(...e){this.log(ht.INFO,"🎭 Avatar:",...e)}connection(...e){this.log(ht.INFO,"🔌 Connection:",...e)}features(...e){this.log(ht.INFO,"🔄 Features:",...e)}data(...e){this.log(ht.INFO,"📨 Data:",...e)}timer(...e){this.log(ht.INFO,"⏱️ Timer:",...e)}cleanup(...e){this.log(ht.INFO,"🗑️ Cleanup:",...e)}};function mt(...e){const t=[];for(const n of e)if(n)if("string"==typeof n||"number"==typeof n)t.push(String(n));else if(Array.isArray(n)){const e=mt(...n);e&&t.push(e)}else if("object"==typeof n)for(const[e,o]of Object.entries(n))o&&t.push(e);return t.join(" ")}const gt="np_companion-align-between",vt="np_companion-action-btn-container-collapse";class bt{static createElement(e,t){const n=document.createElement(e);return t?.className&&(n.className=t.className),t?.id&&(n.id=t.id),t?.attributes&&Object.entries(t.attributes).forEach(([e,t])=>{n.setAttribute(e,t)}),t?.styles&&Object.assign(n.style,t.styles),n}static createVideo(e){const t=this.createElement("video",{className:e.className});return t.autoplay=e.autoplay??!1,t.muted=e.muted??!1,t.loop=e.loop??!1,t.playsInline=e.playsInline??!1,e.crossOrigin&&(t.crossOrigin=e.crossOrigin),e.poster&&(t.poster=e.poster),e.src&&(t.src=e.src),t}static createAudio(e){const t=this.createElement("audio",{className:e.className});return t.autoplay=e.autoplay??!1,t}static createCanvas(e){const t=this.createElement("canvas",{className:e.className,styles:e.styles});return void 0!==e.width&&(t.width=e.width),void 0!==e.height&&(t.height=e.height),t}static createButton(e){const t=this.createElement("button",{className:e.className,attributes:e.attributes});return e.textContent&&(t.textContent=e.textContent),e.onClick&&t.addEventListener("click",e.onClick),t}static createDiv(e){return this.createElement("div",{className:e})}}class yt{static process(e){const t=e.data;return this.hasGreenScreen(t)?(this.removeGreenScreen(t),e):e}static hasGreenScreen(e){for(let t=0;t<e.length;t+=4)if(this.isGreenPixel(e[t],e[t+1],e[t+2]))return!0;return!1}static isGreenPixel(e,t,n){return e>=0&&e<=120&&t>=150&&t<=255&&n>=0&&n<=120}static removeGreenScreen(e){for(let t=0;t<e.length;t+=4){const n=e[t],o=e[t+1],a=e[t+2];this.isGreenPixel(n,o,a)?e[t+3]=0:this.reduceGreenSpill(e,t,n,o,a)}}static reduceGreenSpill(e,t,n,o,a){const i=o-Math.max(n,a);if(i>0){const r=.5*i;e[t]=Math.min(255,n+.8*r),e[t+2]=Math.min(255,a+.8*r),e[t+1]=Math.max(0,o-r)}}}const _t=new class{constructor(){Object.defineProperty(this,"svgNS",{enumerable:!0,configurable:!0,writable:!0,value:"http://www.w3.org/2000/svg"})}createElement(e){const t=document.createElementNS(this.svgNS,e.tag);return e.attributes&&Object.entries(e.attributes).forEach(([e,n])=>{t.setAttribute(e,String(n))}),e.textContent&&(t.textContent=e.textContent),e.children&&e.children.forEach(e=>{const n=this.createElement(e);t.appendChild(n)}),t}createSVG(e,t,n,o,a){const i=document.createElementNS(this.svgNS,"svg");return i.setAttribute("width",String(e)),i.setAttribute("height",String(t)),i.setAttribute("viewBox",n),i.setAttribute("fill","none"),i.setAttribute("xmlns",this.svgNS),a&&i.setAttribute("class",a),o.forEach(e=>{const t=this.createElement(e);i.appendChild(t)}),i}},wt={micUnmuted:()=>_t.createSVG(17,17,"0 0 17 17",[{tag:"g",attributes:{"clip-path":"url(#clip0_655_3824)"},children:[{tag:"path",attributes:{d:"M8.67241 11.8448C9.49524 11.844 10.2841 11.5167 10.8659 10.9349C11.4478 10.3531 11.775 9.5642 11.7759 8.74138V4.60345C11.7759 3.78036 11.4489 2.99099 10.8669 2.40898C10.2849 1.82697 9.4955 1.5 8.67241 1.5C7.84933 1.5 7.05995 1.82697 6.47794 2.40898C5.89594 2.99099 5.56897 3.78036 5.56897 4.60345V8.74138C5.56982 9.5642 5.89707 10.3531 6.47889 10.9349C7.06071 11.5167 7.84959 11.844 8.67241 11.8448ZM6.60345 4.60345C6.60345 4.05472 6.82143 3.52847 7.20943 3.14047C7.59744 2.75246 8.12369 2.53448 8.67241 2.53448C9.22114 2.53448 9.74739 2.75246 10.1354 3.14047C10.5234 3.52847 10.7414 4.05472 10.7414 4.60345V8.74138C10.7414 9.2901 10.5234 9.81635 10.1354 10.2044C9.74739 10.5924 9.22114 10.8103 8.67241 10.8103C8.12369 10.8103 7.59744 10.5924 7.20943 10.2044C6.82143 9.81635 6.60345 9.2901 6.60345 8.74138V4.60345ZM9.18965 13.8879V15.9828C9.18965 16.1199 9.13516 16.2515 9.03816 16.3485C8.94116 16.4455 8.80959 16.5 8.67241 16.5C8.53523 16.5 8.40367 16.4455 8.30667 16.3485C8.20967 16.2515 8.15517 16.1199 8.15517 15.9828V13.8879C6.87994 13.7582 5.69812 13.1601 4.83826 12.2095C3.9784 11.2589 3.50158 10.0232 3.5 8.74138C3.5 8.6042 3.5545 8.47264 3.6515 8.37563C3.7485 8.27863 3.88006 8.22414 4.01724 8.22414C4.15442 8.22414 4.28598 8.27863 4.38299 8.37563C4.47999 8.47264 4.53448 8.6042 4.53448 8.74138C4.53448 9.83883 4.97044 10.8913 5.74645 11.6673C6.52247 12.4434 7.57497 12.8793 8.67241 12.8793C9.76986 12.8793 10.8224 12.4434 11.5984 11.6673C12.3744 10.8913 12.8103 9.83883 12.8103 8.74138C12.8103 8.6042 12.8648 8.47264 12.9618 8.37563C13.0588 8.27863 13.1904 8.22414 13.3276 8.22414C13.4648 8.22414 13.5963 8.27863 13.6933 8.37563C13.7903 8.47264 13.8448 8.6042 13.8448 8.74138C13.8433 10.0232 13.3664 11.2589 12.5066 12.2095C11.6467 13.1601 10.4649 13.7582 9.18965 13.8879Z",fill:"white"}}]},{tag:"defs",children:[{tag:"clipPath",attributes:{id:"clip0_655_3824"},children:[{tag:"rect",attributes:{width:"16",height:"16",fill:"white",transform:"translate(0.5 0.5)"}}]}]}],"np_companion-mic-unmuted"),micMuted:()=>_t.createSVG(22,22,"0 0 17 18",[{tag:"g",attributes:{"clip-path":"url(#clip0_655_4192)"},children:[{tag:"path",attributes:{d:"M14.2432 14.6L3.89604 3.21808C3.80327 3.11843 3.67498 3.05936 3.53896 3.05368C3.40294 3.048 3.27016 3.09616 3.16941 3.18772C3.06866 3.27928 3.00806 3.40686 3.00075 3.5428C2.99343 3.67874 3.04 3.81208 3.13034 3.91392L5.58263 6.61131V8.7396C5.58251 9.26661 5.71656 9.78497 5.97216 10.2458C6.22776 10.7067 6.59649 11.0949 7.04361 11.3739C7.49073 11.6529 8.00151 11.8134 8.52782 11.8404C9.05414 11.8674 9.57867 11.7599 10.052 11.5282L10.7698 12.3171C10.138 12.6868 9.41878 12.8806 8.68679 12.8785C7.58946 12.8773 6.53741 12.4408 5.76148 11.6649C4.98555 10.889 4.54911 9.83693 4.54791 8.7396C4.54791 8.60239 4.4934 8.47079 4.39638 8.37377C4.29935 8.27675 4.16776 8.22224 4.03055 8.22224C3.89334 8.22224 3.76174 8.27675 3.66472 8.37377C3.5677 8.47079 3.51319 8.60239 3.51319 8.7396C3.51476 10.0217 3.9917 11.2577 4.85176 12.2085C5.71182 13.1594 6.8939 13.7575 8.16943 13.8873V15.9826C8.16943 16.1199 8.22394 16.2514 8.32096 16.3485C8.41798 16.4455 8.54958 16.5 8.68679 16.5C8.824 16.5 8.95559 16.4455 9.05262 16.3485C9.14964 16.2514 9.20415 16.1199 9.20415 15.9826V13.8867C10.0143 13.8085 10.794 13.5376 11.4779 13.0964L13.4775 15.2952C13.523 15.3464 13.5781 15.3881 13.6398 15.4178C13.7015 15.4476 13.7684 15.4648 13.8368 15.4685C13.9051 15.4722 13.9735 15.4622 14.038 15.4393C14.1025 15.4163 14.1618 15.3808 14.2125 15.3347C14.2632 15.2887 14.3042 15.2331 14.3332 15.171C14.3622 15.109 14.3786 15.0419 14.3815 14.9735C14.3843 14.9051 14.3736 14.8368 14.3499 14.7725C14.3261 14.7083 14.2899 14.6495 14.2432 14.5993V14.6ZM8.68679 10.809C8.13794 10.809 7.61157 10.591 7.22347 10.2029C6.83538 9.81482 6.61735 9.28845 6.61735 8.7396V7.7495L9.3115 10.7127C9.10943 10.7766 8.89873 10.8091 8.68679 10.809ZM12.4066 10.5562C12.6841 9.99093 12.8275 9.36929 12.8257 8.7396C12.8257 8.60239 12.8802 8.47079 12.9772 8.37377C13.0742 8.27675 13.2058 8.22224 13.343 8.22224C13.4802 8.22224 13.6118 8.27675 13.7089 8.37377C13.8059 8.47079 13.8604 8.60239 13.8604 8.7396C13.8625 9.52693 13.6831 10.3041 13.3359 11.0108C13.2934 11.0979 13.2273 11.1713 13.145 11.2226C13.0628 11.274 12.9679 11.3012 12.8709 11.3012C12.7922 11.3013 12.7145 11.2831 12.6439 11.2481C12.5207 11.1878 12.4265 11.0811 12.382 10.9513C12.3375 10.8215 12.3463 10.6794 12.4066 10.5562ZM5.84131 3.36358C6.12624 2.71004 6.62746 2.1745 7.26073 1.84696C7.894 1.51943 8.62071 1.41987 9.31874 1.56501C10.0168 1.71015 10.6435 2.09116 11.0938 2.64398C11.544 3.19681 11.7902 3.88776 11.7909 4.60072V8.7396C11.7908 8.8476 11.7852 8.95552 11.7741 9.06295C11.7608 9.19066 11.7005 9.30885 11.6049 9.39455C11.5092 9.48025 11.3852 9.52733 11.2568 9.52663C11.2387 9.52757 11.2205 9.52757 11.2025 9.52663C11.066 9.51229 10.9409 9.44435 10.8545 9.33775C10.7682 9.23115 10.7277 9.09462 10.742 8.95818C10.7491 8.88705 10.753 8.81332 10.753 8.74089V4.60072C10.7516 4.12605 10.5871 3.66628 10.2871 3.29848C9.98701 2.93069 9.56963 2.67722 9.10491 2.58058C8.64018 2.48393 8.15636 2.54998 7.73454 2.76766C7.31273 2.98534 6.97857 3.34141 6.78808 3.77618C6.7639 3.84253 6.72639 3.90322 6.67786 3.95452C6.62934 4.00583 6.57082 4.04665 6.50592 4.07449C6.44102 4.10232 6.37111 4.11658 6.30049 4.11637C6.22987 4.11617 6.16005 4.10151 6.09531 4.07329C6.03057 4.04508 5.9723 4.00392 5.92407 3.95233C5.87584 3.90075 5.83869 3.83983 5.81489 3.77335C5.7911 3.70686 5.78117 3.6362 5.78571 3.56573C5.79025 3.49526 5.80917 3.42646 5.84131 3.36358Z",fill:"white"}}]},{tag:"defs",children:[{tag:"clipPath",attributes:{id:"clip0_655_4192"},children:[{tag:"rect",attributes:{width:"16",height:"16",fill:"white",transform:"translate(0.5 0.5)"}}]}]}],"np_companion-mic-muted"),stop:()=>_t.createSVG(20,20,"0 0 32 32",[{tag:"path",attributes:{d:"M5.92 24.096q0 0.832 0.576 1.408t1.44 0.608h16.128q0.832 0 1.44-0.608t0.576-1.408v-16.16q0-0.832-0.576-1.44t-1.44-0.576h-16.128q-0.832 0-1.44 0.576t-0.576 1.44v16.16z",fill:"#ffffff"}}]),volumeHigh(e){const t=[{tag:"path",attributes:{d:"M80 416L128 416L262.1 535.2C268.5 540.9 276.7 544 285.2 544C304.4 544 320 528.4 320 509.2L320 130.8C320 111.6 304.4 96 285.2 96C276.7 96 268.5 99.1 262.1 104.8L128 224L80 224C53.5 224 32 245.5 32 272L32 368C32 394.5 53.5 416 80 416z",fill:"#ffffff"}}];return e>0&&t.push({tag:"path",attributes:{d:"M412.6 245.5C402.3 237.1 387.2 238.7 378.8 249C370.4 259.3 372 274.4 382.3 282.8C393.1 291.6 400 305 400 320C400 335 393.1 348.4 382.3 357.3C372 365.7 370.5 380.8 378.8 391.1C387.1 401.4 402.3 402.9 412.6 394.6C434.1 376.9 448 350.1 448 320C448 289.9 434.1 263.1 412.6 245.5z",fill:"#ffffff"}}),e>=25&&t.push({tag:"path",attributes:{d:"M473.1 171C462.8 162.6 447.7 164.2 439.3 174.5C430.9 184.8 432.5 199.9 442.8 208.3C475.3 234.7 496 274.9 496 320C496 365.1 475.3 405.3 442.8 431.8C432.5 440.2 431 455.3 439.3 465.6C447.6 475.9 462.8 477.4 473.1 469.1C516.3 433.9 544 380.2 544 320.1C544 260 516.3 206.3 473.1 171.1z",fill:"#ffffff"}}),e>=75&&t.push({tag:"path",attributes:{d:"M533.6 96.5C523.3 88.1 508.2 89.7 499.8 100C491.4 110.3 493 125.4 503.3 133.8C557.5 177.8 592 244.8 592 320C592 395.2 557.5 462.2 503.3 506.3C493 514.7 491.5 529.8 499.8 540.1C508.1 550.4 523.3 551.9 533.6 543.6C598.5 490.7 640 410.2 640 320C640 229.8 598.5 149.2 533.6 96.5z",fill:"#ffffff"}}),_t.createSVG(16,16,"0 0 640 640",t)},volumeMuted:()=>_t.createSVG(16,16,"0 0 640 640",[{tag:"path",attributes:{d:"M80 416L128 416L262.1 535.2C268.5 540.9 276.7 544 285.2 544C304.4 544 320 528.4 320 509.2L320 130.8C320 111.6 304.4 96 285.2 96C276.7 96 268.5 99.1 262.1 104.8L128 224L80 224C53.5 224 32 245.5 32 272L32 368C32 394.5 53.5 416 80 416zM399 239C389.6 248.4 389.6 263.6 399 272.9L446 319.9L399 366.9C389.6 376.3 389.6 391.5 399 400.8C408.4 410.1 423.6 410.2 432.9 400.8L479.9 353.8L526.9 400.8C536.3 410.2 551.5 410.2 560.8 400.8C570.1 391.4 570.2 376.2 560.8 366.9L513.8 319.9L560.8 272.9C570.2 263.5 570.2 248.3 560.8 239C551.4 229.7 536.2 229.6 526.9 239L479.9 286L432.9 239C423.5 229.6 408.3 229.6 399 239z",fill:"#ffffff"}}]),screenShare:()=>_t.createSVG(17,17,"0 0 24 24",[{tag:"path",attributes:{d:"M4 3C2.89543 3 2 3.89543 2 5V15C2 16.1046 2.89543 17 4 17H9V19H7V21H17V19H15V17H20C21.1046 17 22 16.1046 22 15V5C22 3.89543 21.1046 3 20 3H4ZM4 5H20V15H4V5Z",fill:"currentColor",stroke:"currentColor","stroke-width":"0.5"}}]),screenShareActive:()=>_t.createSVG(17,17,"0 0 24 24",[{tag:"path",attributes:{d:"M4 3C2.89543 3 2 3.89543 2 5V15C2 16.1046 2.89543 17 4 17H9V19H7V21H17V19H15V17H20C21.1046 17 22 16.1046 22 15V5C22 3.89543 21.1046 3 20 3H4ZM4 5H20V15H4V5Z",fill:"#4ade80",stroke:"#4ade80","stroke-width":"0.5"}}]),end:()=>_t.createSVG(16,16,"0 0 21 16",[{tag:"path",attributes:{d:"M17.7226 12.2992C18.3148 12.5423 18.991 12.308 19.307 11.7578L19.3954 11.6031C20.434 9.78662 20.2705 7.18344 18.2308 5.85533C13.5438 2.80798 7.45789 2.80798 2.77085 5.85533C0.726753 7.18344 0.567646 9.78662 1.60627 11.6031L1.69466 11.7578C2.01066 12.3125 2.68908 12.5445 3.2769 12.3014L6.32204 11.0462C6.83914 10.8341 7.15515 10.3059 7.0999 9.74684L6.90986 7.85081C9.2346 7.06853 11.7759 7.10831 14.0785 7.97456L13.8973 9.74684C13.8399 10.3037 14.1581 10.8297 14.6752 11.0462L17.7226 12.2992Z",fill:"red"}}])},St=e=>{const t=pt.getState(),n=ut(t),o=(e=>e.avatar.stopInteraction)(t);return n&&"open"===n.readyState&&!o?(ft.avatar("Sending command:",e),n.send(JSON.stringify(e)),!0):(ft.critical_warn(n?"open"!==n.readyState?`Data channel state: ${n.readyState}`:"Interaction stopped":"Data channel not available"),!1)};class Ct{constructor(e=1e3){Object.defineProperty(this,"video",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"canvas",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"ctx",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"worker",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"interval",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.interval=e,this.video=document.createElement("video"),this.video.setAttribute("autoplay","true"),this.video.setAttribute("playsinline","true"),this.video.muted=!0,this.canvas=document.createElement("canvas"),this.canvas.width=1280,this.canvas.height=720;const t=this.canvas.getContext("2d");if(!t)throw new Error("Failed to get canvas 2d context for MediaCapture");this.ctx=t,this.initWorker()}initWorker(){try{const e=new Blob(["\n let intervalId = null;\n self.onmessage = function(e) {\n if (e.data.command === 'start') {\n if (intervalId) clearInterval(intervalId);\n intervalId = setInterval(() => self.postMessage('tick'), e.data.interval);\n } else if (e.data.command === 'stop') {\n if (intervalId) { clearInterval(intervalId); intervalId = null; }\n }\n };\n"],{type:"application/javascript"}),t=URL.createObjectURL(e);this.worker=new Worker(t),URL.revokeObjectURL(t),this.worker.onmessage=()=>{this.drawFrame()}}catch(e){ft.critical_warn("MediaCapture","Failed to create worker:",e)}}drawFrame(){if(this.video.readyState<2)return;const e=this.video.videoWidth||1280,t=this.video.videoHeight||720;this.canvas.width=e,this.canvas.height=t,this.ctx.drawImage(this.video,0,0,e,t)}getCanvas(){return this.canvas}setStream(e){e?(this.video.srcObject=e,this.video.play().catch(e=>{ft.critical_warn("MediaCapture","Failed to play video:",e)}),this.worker?.postMessage({command:"start",interval:this.interval})):(this.worker?.postMessage({command:"stop"}),this.video.pause(),this.video.srcObject=null)}terminate(){this.worker?.postMessage({command:"stop"}),this.worker?.terminate(),this.worker=null,this.video.pause(),this.video.srcObject=null}}const Et=(e,t)=>{if("inactiveTimeout"===e){const e=t;return e?.enabled&&void 0!==e.duration&&e.duration>18e4&&(ft.critical_warn(`Napster Companion API SDK: inactiveTimeout duration of ${e.duration}ms exceeds the recommended maximum of 180000ms. Setting maximum allowed value.`),delete e.duration),t}return t},xt={width:"40px",height:"40px",borderRadius:"80px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:"all 0.3s ease-in-out",background:"linear-gradient(0deg, #5e5e5e14 0% 100%), #ffffff0f"},kt={background:"rgba(52, 199, 89, 0.25)",boxShadow:"0 0 0 2px rgba(52, 199, 89, 0.4)",transition:"background 0.2s ease, box-shadow 0.2s ease"};function Tt(e,{content:t,placement:n="top"}){let o=!1,a=null,i=null;const r=()=>e.ownerDocument,s=()=>r().defaultView,c=()=>{if(!a)return;const t=e.getBoundingClientRect(),o=a.getBoundingClientRect();let i=0,r=0;switch(n){case"top":i=t.top-o.height-8,r=t.left+(t.width-o.width)/2;break;case"bottom":i=t.bottom+8,r=t.left+(t.width-o.width)/2;break;case"left":i=t.top+(t.height-o.height)/2,r=t.left-o.width-8;break;case"right":i=t.top+(t.height-o.height)/2,r=t.right+8}a.style.top=`${i}px`,a.style.left=`${r}px`},d=()=>c(),l=()=>{if(o)return;const e=(()=>{if(a)return a;const e=r(),o=e.createElement("div");o.setAttribute("role","tooltip"),Object.assign(o.style,{position:"fixed",top:"0px",left:"0px",zIndex:"2147483647",opacity:"0",visibility:"hidden",pointerEvents:"none",transition:"opacity 80ms ease",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',fontSize:"14px",lineHeight:"1.5"});const i=e.createElement("div");Object.assign(i.style,{display:"block",color:"#3f4254",backgroundColor:"#fff",padding:"10px 14px",maxWidth:"300px",borderRadius:"0.375rem",boxShadow:"0 0.5rem 1rem rgba(0, 0, 0, 0.15)",textAlign:"center",whiteSpace:"nowrap"}),"string"==typeof t?i.textContent=t:i.appendChild(t);const s=e.createElement("div");return Object.assign(s.style,{top:{position:"absolute",bottom:"-6px",left:"50%",transform:"translateX(-50%)",width:"0",height:"0",borderLeft:"6px solid transparent",borderRight:"6px solid transparent",borderTop:"6px solid #fff"},bottom:{position:"absolute",top:"-6px",left:"50%",transform:"translateX(-50%)",width:"0",height:"0",borderLeft:"6px solid transparent",borderRight:"6px solid transparent",borderBottom:"6px solid #fff"},left:{position:"absolute",right:"-6px",top:"50%",transform:"translateY(-50%)",width:"0",height:"0",borderTop:"6px solid transparent",borderBottom:"6px solid transparent",borderLeft:"6px solid #fff"},right:{position:"absolute",left:"-6px",top:"50%",transform:"translateY(-50%)",width:"0",height:"0",borderTop:"6px solid transparent",borderBottom:"6px solid transparent",borderRight:"6px solid #fff"}}[n]),o.appendChild(i),o.appendChild(s),e.body.appendChild(o),a=o,o})();o=!0,c(),i=(s()??window).setTimeout(c,10),e.style.opacity="1",e.style.visibility="visible";const l=s()??window;l.addEventListener("scroll",d,!0),l.addEventListener("resize",d)},p=()=>{if(!o)return;o=!1,null!=i&&((s()??window).clearTimeout(i),i=null),a&&(a.style.opacity="0",a.style.visibility="hidden");const e=s()??window;e.removeEventListener("scroll",d,!0),e.removeEventListener("resize",d)},u=()=>l(),h=()=>p();return e.addEventListener("mouseenter",u),e.addEventListener("mouseleave",h),e.matches?.(":hover")&&l(),{update:e=>{if(void 0!==e.content&&a){const t=a.querySelector("div");t&&(t.innerHTML="","string"==typeof e.content?t.textContent=e.content:t.appendChild(e.content))}void 0!==e.placement&&(n=e.placement),o&&c()},show:l,hide:p,destroy:()=>{p(),e.removeEventListener("mouseenter",u),e.removeEventListener("mouseleave",h),a&&a.parentNode&&a.parentNode.removeChild(a),a=null}}}function It(){const e=document.createElement("div");Object.assign(e.style,xt);let t=pt.getState().avatar.muted,n=pt.getState().avatar.isUserTalking;i(t),r(t,n),e.addEventListener("click",()=>{const e=pt.getState().avatar.muted;pt.dispatch(qe(!e))});let o=null;o=Tt(e,{content:t?"Unmute":"Mute",placement:"top"});const a=pt.subscribe(()=>{const e=pt.getState().avatar,a=e.muted!==t,s=e.isUserTalking!==n;a&&(t=e.muted,i(t),o?.update({content:t?"Unmute":"Mute"})),(a||s)&&(n=e.isUserTalking,r(t,n))});function i(t){for(;e.firstChild;)e.removeChild(e.firstChild);const n=t?wt.micMuted():wt.micUnmuted();Object.assign(n.style,{width:"22px",height:"auto"}),e.appendChild(n)}function r(t,n){!t&&n?Object.assign(e.style,kt):(e.style.background=xt.background,e.style.boxShadow="none")}return{element:e,destroy:()=>{a(),o?.destroy(),e.parentNode&&e.parentNode.removeChild(e)}}}function Ot(e){const t=document.createElement("div");Object.assign(t.style,xt);const n=wt.end();Object.assign(n.style,{width:"16px",height:"auto"}),t.appendChild(n),t.addEventListener("click",e);const o=Tt(t,{content:"End Session",placement:"top"});return{element:t,destroy:()=>{o.destroy(),t.removeEventListener("click",e),t.parentNode&&t.parentNode.removeChild(t)}}}function Nt(){let e=pt.getState().avatar.volume,t=!1;const n=document.createElement("div");Object.assign(n.style,{position:"relative",display:"inline-flex",flexDirection:"column",alignItems:"center",gap:"12px",zIndex:"1000"});const o=document.createElement("div");Object.assign(o.style,{position:"absolute",bottom:"52px",opacity:"0",visibility:"hidden",transform:"translateY(10px)",transition:"all 0.3s ease",pointerEvents:"none",background:"#6565652e",padding:"8px",borderRadius:"8px",zIndex:"1001"});const a=document.createElement("div");Object.assign(a.style,{position:"relative",width:"8px",height:"120px",background:"rgba(0, 0, 0, 0.4)",backdropFilter:"blur(10px)",borderRadius:"4px",border:"1px solid rgba(255, 255, 255, 0.3)",cursor:"pointer",boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)"});const i=document.createElement("div");Object.assign(i.style,{position:"absolute",bottom:"0",left:"0",right:"0",height:"50%",background:"linear-gradient(to top, rgba(255,255,255,0.9), rgba(255,255,255,0.7))",borderRadius:"4px",transition:"height 0.1s ease",pointerEvents:"none"});const r=document.createElement("div");Object.assign(r.style,{position:"absolute",bottom:"50%",left:"50%",transform:"translate(-50%, 50%)",width:"16px",height:"16px",background:"white",borderRadius:"50%",boxShadow:"0 2px 6px rgba(0, 0, 0, 0.3)",transition:"bottom 0.1s ease",pointerEvents:"none",cursor:"grab"}),a.appendChild(i),a.appendChild(r),o.appendChild(a);const s=document.createElement("div");function c(){s.innerHTML="";const t=0===e?wt.volumeMuted():wt.volumeHigh(e);Object.assign(t.style,{width:"16px",height:"auto"}),s.appendChild(t)}function d(){i.style.height=`${e}%`,r.style.bottom=`${e}%`}function l(){t&&(t=!1,Object.assign(o.style,{opacity:"0",visibility:"hidden",transform:"translateY(10px)",pointerEvents:"none"}))}function p(t){const n=a.getBoundingClientRect(),o=Math.max(0,Math.min(100,(n.bottom-t)/n.height*100));e=o,d(),c(),pt.dispatch(Qe(e))}Object.assign(s.style,xt),s.setAttribute("aria-label","Volume control"),c(),d(),n.appendChild(o),n.appendChild(s),s.addEventListener("click",t=>{t.stopPropagation(),e=0===e?70:0,d(),c(),pt.dispatch(Qe(e))});let u=null;n.addEventListener("mouseenter",()=>{u&&(clearTimeout(u),u=null),t||(t=!0,Object.assign(o.style,{opacity:"1",visibility:"visible",transform:"translateY(0)",pointerEvents:"all"}))}),n.addEventListener("mouseleave",()=>{u=setTimeout(()=>l(),300)}),o.addEventListener("mouseenter",()=>{u&&(clearTimeout(u),u=null)}),o.addEventListener("mouseleave",()=>{u=setTimeout(()=>l(),300)}),a.addEventListener("mousedown",e=>{p(e.clientY),e.preventDefault();const t=n.ownerDocument,o=e=>p(e.clientY),a=()=>{t.removeEventListener("mousemove",o),t.removeEventListener("mouseup",a)};t.addEventListener("mousemove",o),t.addEventListener("mouseup",a)}),r.addEventListener("mousedown",e=>{e.preventDefault();const t=n.ownerDocument,o=e=>p(e.clientY),a=()=>{t.removeEventListener("mousemove",o),t.removeEventListener("mouseup",a)};t.addEventListener("mousemove",o),t.addEventListener("mouseup",a)}),a.addEventListener("touchstart",e=>{p(e.touches[0].clientY),e.preventDefault();const t=n.ownerDocument,o=e=>{e.touches.length>0&&p(e.touches[0].clientY)},a=()=>{t.removeEventListener("touchmove",o),t.removeEventListener("touchend",a)};t.addEventListener("touchmove",o),t.addEventListener("touchend",a)});const h=pt.subscribe(()=>{const t=pt.getState().avatar.volume;t!==e&&(e=t,d(),c())});return{element:n,destroy:()=>{h(),n.parentNode&&n.parentNode.removeChild(n)}}}function At(e){const t=document.createElement("div");Object.assign(t.style,xt,{color:"#fff"}),e.isSupported||(t.style.display="none");let n=pt.getState().avatar.isScreenSharing;i(n),t.addEventListener("click",()=>e.onToggle());let o=null;o=Tt(t,{content:n?"Stop Sharing":"Share Screen",placement:"top"});const a=pt.subscribe(()=>{const e=pt.getState().avatar.isScreenSharing;e!==n&&(n=e,i(e),o?.update({content:e?"Stop Sharing":"Share Screen"}))});function i(e){for(;t.firstChild;)t.removeChild(t.firstChild);const n=e?wt.screenShareActive():wt.screenShare();Object.assign(n.style,{width:"22px",height:"auto"}),t.appendChild(n)}return{element:t,destroy:()=>{a(),o?.destroy(),t.parentNode&&t.parentNode.removeChild(t)}}}const Dt={enabled:!1,batchSize:10,flushInterval:5e3,enablePerformanceTracking:!0,enableErrorTracking:!0,enableUserInteractionTracking:!0};class Rt{constructor(e={}){Object.defineProperty(this,"config",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"eventQueue",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"performanceQueue",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"errorQueue",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"flushTimer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"sessionId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"providers",{enumerable:!0,configurable:!0,writable:!0,value:[]}),this.config={...Dt,...e},this.sessionId=this.config.sessionId||this.generateSessionId(),this.setupProviders(),this.config.enabled&&(this.startFlushTimer(),this.setupErrorTracking(),this.setupPerformanceTracking())}setupProviders(){this.providers=[],this.config.providers&&(this.providers=[...this.config.providers]),this.config.provider&&this.providers.push(this.config.provider),0===this.providers.length&&this.providers.push({type:"custom"})}generateSessionId(){return`session_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}startFlushTimer(){this.flushTimer&&clearInterval(this.flushTimer),this.flushTimer=setInterval(()=>{this.flush()},this.config.flushInterval)}setupErrorTracking(){this.config.enableErrorTracking&&(window.addEventListener("error",e=>{this.trackError(e.error,{source:"window.error",filename:e.filename,lineno:e.lineno,colno:e.colno})}),window.addEventListener("unhandledrejection",e=>{this.trackError(new Error(e.reason),{source:"unhandledrejection",reason:e.reason})}))}setupPerformanceTracking(){this.config.enablePerformanceTracking&&"undefined"!=typeof window&&"performance"in window&&window.addEventListener("load",()=>{setTimeout(()=>{const e=performance.getEntriesByType("navigation")[0];e&&(this.trackPerformance("page_load_time",e.loadEventEnd-e.fetchStart,"ms"),this.trackPerformance("dom_content_loaded",e.domContentLoadedEventEnd-e.fetchStart,"ms"),this.trackPerformance("first_paint",e.responseEnd-e.fetchStart,"ms"))},0)})}trackEvent(e,t){if(!this.config.enabled)return;const n={name:e,properties:t,timestamp:Date.now(),userId:this.config.userId,sessionId:this.sessionId};this.eventQueue.push(n),this.eventQueue.length>=(this.config.batchSize||10)&&this.flush()}trackPerformance(e,t,n,o){if(!this.config.enabled||!this.config.enablePerformanceTracking)return;const a={name:e,value:t,unit:n,timestamp:Date.now(),context:o};this.performanceQueue.push(a)}trackError(e,t){if(!this.config.enabled||!this.config.enableErrorTracking)return;const n={error:e,context:t,timestamp:Date.now(),userId:this.config.userId,sessionId:this.sessionId,stack:e.stack};this.errorQueue.push(n),this.flushErrors()}trackInteraction(e,t,n){this.config.enableUserInteractionTracking&&this.trackEvent("user_interaction",{action:e,target:t,...n})}flush(){this.flushEvents(),this.flushPerformance(),this.flushErrors()}flushEvents(){if(0===this.eventQueue.length)return;const e=[...this.eventQueue];this.eventQueue=[],this.sendData("events",e)}flushPerformance(){if(0===this.performanceQueue.length)return;const e=[...this.performanceQueue];this.performanceQueue=[],this.sendData("performance",e)}flushErrors(){if(0===this.errorQueue.length)return;const e=[...this.errorQueue];this.errorQueue=[],this.sendData("errors",e)}async sendData(e,t){const n=this.providers.map(n=>this.sendToProvider(n,e,t));await Promise.allSettled(n)}async sendToProvider(e,t,n){try{switch(e.type){case"google-analytics-4":await this.sendToGA4(e,n);break;case"mixpanel":await this.sendToMixpanel(e,n);break;case"segment":await this.sendToSegment(e,n);break;case"amplitude":await this.sendToAmplitude(e,n);break;case"posthog":await this.sendToPostHog(e,n);break;case"azure-insights":await this.sendToAzureInsights(e,n);break;default:await this.sendToCustomEndpoint(e,t,n)}}catch(t){ft.critical_warn(`Failed to send data to ${e.type}:`,t)}}async sendToCustomEndpoint(e,t,n){const o=e.endpoint,a=e.apiKey;if(!o)return;const i=await fetch(`${o}/${t}`,{method:"POST",headers:{"Content-Type":"application/json",...a&&{Authorization:`Bearer ${a}`}},body:JSON.stringify({data:n,sessionId:this.sessionId,timestamp:Date.now()})});if(!i.ok)throw new Error(`HTTP ${i.status}`)}async sendToGA4(e,t){const n=e.measurementId||e.apiKey;if(!n)throw new Error("GA4 measurement ID required");const o=`https://www.google-analytics.com/mp/collect?measurement_id=${n}&api_secret=${e.apiKey||"default"}`,a=t.map(e=>({name:e.name,params:{...e.properties,session_id:this.sessionId}}));await fetch(o,{method:"POST",body:JSON.stringify({client_id:this.sessionId,user_id:this.config.userId,events:a})})}async sendToMixpanel(e,t){const n=e.projectToken||e.apiKey;if(!n)throw new Error("Mixpanel project token required");const o=e.endpoint||"https://api.mixpanel.com/batch",a=t.map(e=>{const t=e;return{event:t.name,properties:{token:n,distinct_id:this.config.userId||this.sessionId,time:t.timestamp||Date.now(),...t.properties}}});await fetch(o,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)})}async sendToSegment(e,t){const n=e.writeKey||e.apiKey;if(!n)throw new Error("Segment write key required");const o=e.endpoint||"https://api.segment.io/v1/batch",a=t.map(e=>({type:"track",userId:this.config.userId||this.sessionId,event:e.name,properties:e.properties,timestamp:new Date(e.timestamp||Date.now()).toISOString()}));await fetch(o,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Basic ${btoa(n+":")}`},body:JSON.stringify({batch:a})})}async sendToAmplitude(e,t){const n=e.apiKey;if(!n)throw new Error("Amplitude API key required");const o=e.endpoint||"https://api2.amplitude.com/2/httpapi",a=t.map(e=>({user_id:this.config.userId||this.sessionId,event_type:e.name,event_properties:e.properties,time:e.timestamp||Date.now()}));await fetch(o,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({api_key:n,events:a})})}async sendToPostHog(e,t){const n=e.apiKey,o=e.endpoint||"https://app.posthog.com";if(!n)throw new Error("PostHog API key required");const a=t.map(e=>({event:e.name,properties:{...e.properties,distinct_id:this.config.userId||this.sessionId},timestamp:new Date(e.timestamp||Date.now()).toISOString()}));await fetch(`${o}/batch/`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({api_key:n,batch:a})})}async sendToAzureInsights(e,t){const n=e.apiKey;if(!n)throw new Error("Azure Application Insights instrumentation key required");const o=e.endpoint||"https://dc.services.visualstudio.com/v2/track",a=t.map(e=>{const t=e;return{name:"Microsoft.ApplicationInsights.Event",time:new Date(t.timestamp||Date.now()).toISOString(),iKey:n,data:{baseType:"EventData",baseData:{name:t.name,properties:t.properties}}}});await fetch(o,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)})}updateConfig(e){this.config={...this.config,...e},this.setupProviders(),this.config.enabled&&!this.flushTimer?this.startFlushTimer():!this.config.enabled&&this.flushTimer&&(clearInterval(this.flushTimer),this.flushTimer=void 0)}destroy(){this.flushTimer&&clearInterval(this.flushTimer),this.flush()}}let Pt=null;const Lt=(e,t)=>{Pt?.trackEvent(e,t)},Mt=(e,t,n)=>{Pt?.trackInteraction(e,t,n)};function jt(e,t){void 0===t&&(t={});var n=t.insertAt;if(e&&"undefined"!=typeof document){var o=document.head||document.getElementsByTagName("head")[0],a=document.createElement("style");a.type="text/css","top"===n&&o.firstChild?o.insertBefore(a,o.firstChild):o.appendChild(a),a.styleSheet?a.styleSheet.cssText=e:a.appendChild(document.createTextNode(e))}}jt(".np_companion-live-container,.np_companion-preview-container{height:100%;margin:0;padding:0;position:absolute;transition:opacity .3s ease-in-out;width:100%}.np_companion-preview-container{opacity:1;z-index:2}.np_companion-preview-container.np_companion-fade-out{opacity:0;pointer-events:none;transition:opacity .5s ease-out}.np_companion-live-container{opacity:0;z-index:1}.np_companion-live-container.np_companion-fade-in{opacity:1;z-index:3}"),jt(":root{--base-border-radius:10px;--base-gap:20px}*,:after,:before{-webkit-box-sizing:border-box;box-sizing:border-box}::-webkit-input-placeholder{color:hsla(0,0%,100%,.4)}::-moz-placeholder{color:hsla(0,0%,100%,.4)}:-ms-input-placeholder{color:hsla(0,0%,100%,.4)}:-moz-placeholder{color:hsla(0,0%,100%,.4)}a,input{outline:none}body,html{background-color:transparent;background:transparent;margin:0;padding:0;width:100%}.np_companion-hide{display:none!important}.np_companion-align-middle{align-items:center;display:flex;justify-content:center}.np_companion-align-between{align-items:center;display:flex;justify-content:space-between}.np_companion-align-end{align-items:center;display:flex;justify-content:flex-end}.np_companion-align-start{align-items:flex-start;display:flex;justify-content:flex-start}.np_companion__d-none{display:none!important}#np_companion-sdk-root.np_companion-container-fixed{height:500px;position:fixed;transition:all .3s ease-in-out;width:400px;z-index:9999}#np_companion-sdk-root.np_companion-container-fixed.np_companion-view-rectangle{height:400px;width:340px}#np_companion-sdk-root.np_companion-container-fixed.np_companion-view-silhouette{height:400px}#np_companion-sdk-root.np_companion-container-fixed.np_companion-view-round{height:360px;width:250px}#np_companion-sdk-root.np_companion-container-fixed.np_companion-view-round.np_companion_disclaimer-disabled{height:320px!important}#np_companion-sdk-root.np_companion-container-fixed.np_companion-bottom-right{bottom:0;right:0}#np_companion-sdk-root.np_companion-container-fixed.np_companion-bottom-left{bottom:0;left:0}#np_companion-sdk-root.np_companion-container-fixed.np_companion-bottom-center{bottom:0;left:50%;transform:translateX(-50%)}#np_companion-sdk-root.np_companion-container-fixed.np_companion-top-right{right:0;top:0}#np_companion-sdk-root.np_companion-container-fixed.np_companion-top-left{left:0;top:0}#np_companion-sdk-root.np_companion-container-fixed.np_companion-top-center{left:50%;top:0;transform:translateX(-50%)}#np_companion-sdk-root.np_companion-container-fixed.np_companion-center{left:50%;top:50%;transform:translate(-50%,-50%)}"),jt('.np_companion-avatar{height:100%;position:relative;width:100%}#np_companion-avatar-container{background:transparent;border-radius:var(--base-border-radius);height:100%;overflow:hidden;position:absolute;width:100%}#np_companion-avatar-container:not(.np_companion-view-silhouette){box-shadow:0 0 #0000,0 0 #0000,0 0 #0000,0 0 #0000,0 10px 15px -3px color-mix(in oklab,#00000080 100%,transparent),0 4px 6px -4px color-mix(in oklab,#00000080 100%,transparent)}.np_companion-avatar.np_companion-bg-transparent #np_companion-avatar-container.np_companion-view-silhouette{filter:drop-shadow(0 10px 15px rgba(0,0,0,.5)) drop-shadow(0 4px 6px rgba(0,0,0,.5))}.np_companion-container-fixed #np_companion-avatar-container.np_companion-view-round{border-radius:50%;height:212px;left:50%;transform:translate(-50%,12%);width:212px}.np_companion-container-fixed #np_companion-avatar-container.np_companion-view-rectangle,.np_companion-container-fixed #np_companion-avatar-container.np_companion-view-silhouette{left:50%;transform:translateX(-50%)}.np_companion-avatar-video{height:100%;inset:0;object-fit:cover;pointer-events:none;position:absolute;transition:opacity .3s ease-in-out;width:100%;z-index:10}.np_companion-avatar-video.no-opacity{opacity:0}.np_companion-avatar-canvas{background:transparent;height:100%;object-fit:cover;position:relative;width:100%;z-index:1}.np_companion-container-fixed #np_companion-avatar-container.np_companion-loader-pulse:after{animation:pulse 1.5s ease-in-out infinite;background-color:var(--np-loader-bg-color);border-radius:var(--base-border-radius);content:"";display:block;height:100%;left:0;opacity:.6;overflow:hidden;position:absolute;top:0;width:100%}.np_companion-avatar.np_companion-bg-transparent #np_companion-avatar-container:after{display:none}.np_companion-avatar:has(#np_companion-avatar-container.np_companion-view-round):after{display:none}#np_companion-avatar-container.np_companion-loader-pulse.loader-container.np_companion-view-round:after{animation:pulse 1.5s ease-in-out infinite;background-color:var(--np-loader-bg-color);border-radius:50%;content:"";display:block;height:100%;left:0;opacity:.6;overflow:hidden;position:absolute;top:0;width:100%}.np_companion-avatar.np_companion-bg-transparent #np_companion-avatar-container.np_companion-view-round:after{display:none}@keyframes pulse{0%,to{opacity:.5}50%{opacity:.2}}.np_companion-disclaimer-text{-webkit-box-orient:vertical;-webkit-line-clamp:2;line-clamp:2;color:#fff;font-size:10px;line-height:12px;margin:auto auto 16px;max-width:940px;opacity:.7;overflow:hidden;padding:0 16px;text-align:center;z-index:12}.np_companion-disclaimer-text a{color:#fff}.np_companion-disclaimer-text a:hover{color:#fff;text-decoration:underline}.np_companion-disclaimer-text a:focus,.np_companion-disclaimer-text a:visited{color:#fff}.np_companion-action-btn-container-wrapper{pointer-events:auto;width:100%}.np_companion-avatar-control-container{backdrop-filter:blur(19px);background:none;background-color:rgba(52,51,51,.6);border-radius:16px;bottom:0;box-shadow:0 4px 4px 0 rgba(0,0,0,.25),2px 2px 8px 0 rgba(0,0,0,.12);left:50%;max-width:90%;min-width:210px;opacity:1;position:absolute;transform:translateX(-50%);transition:opacity .4s cubic-bezier(.4,0,.2,1);z-index:99}.np_companion-avatar-control-container.np_companion-action-btn-container-collapse{opacity:0}.np_companion-avatar-control-container:not(.np_companion-avatar-control-view-round){bottom:16px}.np_companion-avatar:not(.np_companion-bg-transparent) .np_companion-loader-spinner:not(.np_companion-view-silhouette){backdrop-filter:blur(19px);background-color:color-mix(in oklab,var(--np-loader-bg-color) 100%,transparent)!important;filter:none!important;height:100%;width:100%}.np_companion-loader-spinner .loader-container{left:50%;position:absolute;top:50%;transform:translate(-50%,-50%)}.np_companion-loader-spinner .loader-container .loader{--_m:conic-gradient(#0000 10%,#000),linear-gradient(#000 0 0) content-box;animation:l3 1s linear infinite;aspect-ratio:1;background:var(--np-loader-color);border-radius:50%;-webkit-mask:var(--_m);mask:var(--_m);-webkit-mask-composite:source-out;mask-composite:subtract;padding:4px;width:24px}@keyframes l3{to{transform:rotate(1turn)}}.np_companion-loader-spinner.np_companion-view-round .loader-container .loader{padding:4px;width:212px}.np_companion-bg-transparent .np_companion-loader-spinner .loader-container{display:none}'),jt(".np_companion-controls-container{align-items:center;background:hsla(0,0%,100%,.3);border:.5px solid #fff;border-radius:12px;bottom:20px;box-shadow:0 1px 1px rgba(0,0,0,.267),0 2px 5px rgba(0,0,0,.267),0 3px 8px rgba(0,0,0,.267);display:flex;gap:8px;left:50%;max-width:360px;pointer-events:auto;position:absolute;transform:translateX(-50%);transform-origin:bottom center;transition:width .3s ease-in-out;-webkit-user-select:none;-moz-user-select:none;user-select:none;width:auto;z-index:99}.np_companion-controls-container.collapsed{gap:0}.np_companion-time-running{color:#fff}.np_companion-controls-time-action-btn-container{align-items:center;background:hsla(0,0%,100%,.1);border-radius:8px;display:flex;filter:grayscale(1);flex-shrink:0;gap:8px;height:32px;padding-left:8px;padding-right:8px;transition:filter .3s ease}.np_companion-controls-mic-control,.np_companion-controls-stop-control{cursor:pointer;display:flex;margin:0 5px;overflow:hidden;transition:opacity .3s ease-in-out,width .3s ease-in-out;width:47px}.np_companion-controls-mic-control.visible,.np_companion-controls-stop-control.visible{opacity:1}.np_companion-controls-mic-control.visible{width:1em}.np_companion-controls-stop-control.visible{width:1.5em}.np_companion-controls-mic-control.hidden,.np_companion-controls-stop-control.hidden{margin:0;opacity:0;padding:0;pointer-events:none;width:0}.np_companion-controls-mic-control:hover svg path{fill:red}.np_companion-controls-stop-control{display:flex;margin:0 5px 0 0}.np_companion-controls-stop-control:hover svg .stop-circle{fill:red}.np_companion-controls-stop-control:hover svg .stop-square{fill:#fff}.np_companion-mic-dropdown{background:#2b2c32;border-radius:4px;border-radius:6px;bottom:35px;box-shadow:0 10px 15px -3px rgba(0,0,0,.2),0 4px 6px -4px rgba(0,0,0,.2),0 0 0 1px #46464d;color:#fff;font-size:14px;list-style-type:none;margin:0;max-height:200px;min-width:300px;overflow-y:auto;overflow:auto;padding:5px;pointer-events:auto;position:absolute;width:auto;z-index:1000}.np_companion-mic-dropdown li{cursor:pointer;padding:8px 12px}.np_companion-mic-dropdown li:hover{background-color:#000}.np_companion-action-btn-container-container{background:transparent;border-radius:80px;gap:8px;padding:16px 16px 12px;transition:all .3s ease-in-out}.np_companion-action-btn-container-container.np_companion_disclaimer-disabled{padding-bottom:16px}.np_companion-action-btn-container-container .np_companion-chat-question-bar-container{border-radius:16px;gap:8px}.np_companion-action-btn-container-container .np_companion-action-btn-container-left{transition:all .3s ease-in-out;width:40px}.np_companion-action-btn-container-container .np_companion-action-btn-container-icon{border-radius:80px;cursor:pointer;height:40px;transition:all .3s ease-in-out;width:40px}.np_companion-dark-grey-bg{background:linear-gradient(0deg,#5e5e5e14 0 100%),#ffffff0f}.np_companion-grey-bg{background:linear-gradient(0deg,rgba(94,94,94,.07),rgba(94,94,94,.07)),hsla(0,0%,100%,.04)}.np_companion-action-btn-container-container .np_companion-action-btn-container-icon svg{height:auto;width:22px}.np_companion-action-btn-container-container .np_companion-action-btn-container-icon.muted svg.np_companion-mic-muted,.np_companion-action-btn-container-container .np_companion-action-btn-container-icon:not(.muted) svg.np_companion-mic-unmuted{display:flex}.np_companion-action-btn-container-container .np_companion-action-btn-container-middle .np_companion-action-btn-container-wave{display:flex;min-width:160px}.np_companion-action-btn-container-container .np_companion-action-btn-container-middle .np_companion-action-btn-container-wave canvas{height:40px;width:100%}.np_companion-action-btn-container-container .np_companion-action-btn-container-right{gap:8px;transition:all .3s ease-in-out}.np_companion-action-btn-container-container .np_companion-action-btn-container-left .np_companion-action-btn-container-icon:hover,.np_companion-action-btn-container-container .np_companion-action-btn-container-right .np_companion-action-btn-container-icon.active,.np_companion-action-btn-container-container .np_companion-action-btn-container-right .np_companion-action-btn-container-icon:hover{background-color:#fff!important}.np_companion-action-btn-container-container .np_companion-action-btn-container-left .np_companion-action-btn-container-icon:not(.np_companion-persist-fill-color):hover svg path{fill:#000}.np_companion-action-btn-container-container .np_companion-action-btn-container-right .np_companion-action-btn-container-icon.np_companion-action-btn-container-call-end svg{height:auto;width:16px}.np_companion-action-btn-container-container .np_companion-action-btn-container-right .np_companion-action-btn-container-icon:not(.np_companion-persist-fill-color).np_companion-action-btn-container-call-end:hover svg path{stroke:#000}.np_companion-action-btn-container-container .np_companion-action-btn-container-right .np_companion-action-btn-container-icon:not(.np_companion-persist-fill-color).active svg path,.np_companion-action-btn-container-container .np_companion-action-btn-container-right .np_companion-action-btn-container-icon:not(.np_companion-persist-fill-color).np_companion-action-btn-container-toggle:hover svg path,.np_companion-action-btn-container-container .np_companion-action-btn-container-right .np_companion-action-btn-container-icon:not(.np_companion-persist-fill-color):hover svg path{fill:#000}.np_companion-mobile-mode{bottom:15px;scale:.7}.np_companion-mobile-mode .np_companion-action-btn-container-container .np_companion-action-btn-container-middle{display:none}.np_companion-mobile-mode .np_companion-action-btn-container-left{opacity:1;width:40px}.np_companion-mobile-mode .np_companion-action-btn-container-right{opacity:1}.np_companion-action-btn-container-container .np_companion-action-btn-container-icon.np_companion-talking{background:rgba(52,199,89,.25);box-shadow:0 0 0 2px rgba(52,199,89,.4);transition:background .2s ease,box-shadow .2s ease}.np_companion-action-btn-container-container .np_companion-action-btn-container-icon.np_companion-talking svg path{fill:#34c759}");const Ft={echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0};let Vt=null;function zt(){return Vt||(Vt=function(){let e,t=null,n=null,o=!1,a=null,i=null,s=null;const c={stream:new Set,muted:new Set,device:new Set,error:new Set};function d(e,t){c[e].forEach(n=>{try{n(t)}catch(t){ft.critical_error("MicrophoneManager",`Listener threw for "${e}"`,t)}})}function l(){try{s?.disconnect()}catch{}s=null;try{i?.disconnect()}catch{}if(i=null,a){try{a.close()}catch{}a=null}}function p(e){l();const t="undefined"!=typeof window?window.AudioContext||window.webkitAudioContext:void 0;if(t)try{a=new t,i=a.createAnalyser(),s=a.createMediaStreamSource(e),s.connect(i)}catch(e){ft.critical_warn("MicrophoneManager","Failed to build analyser graph",e),l()}}function u(e){if(e)try{e.getTracks().forEach(e=>e.stop())}catch{}}async function h(e){const t=function(e){return e?{...Ft,deviceId:{exact:e}}:{...Ft}}(e),n=await navigator.mediaDevices.getUserMedia({audio:t,video:!1}),a=n.getAudioTracks()[0];if(!a)throw u(n),new r("No audio track returned from getUserMedia",{deviceId:e});return a.enabled=!o,n}async function f(o){try{const a=await h(o),i=t;return t=a,n=a.getAudioTracks()[0]??null,e=o,p(a),u(i),d("device",o),d("stream",t),t}catch(e){const t=e instanceof r?e:new r("Failed to switch audio device",{error:e,deviceId:o});throw d("error",t),t}}return{start:async function(o={}){if(t&&t.active)return o.deviceId&&o.deviceId!==e?f(o.deviceId):t;try{const a=await h(o.deviceId);return t=a,n=a.getAudioTracks()[0]??null,e=o.deviceId,p(a),d("device",e),d("stream",t),t}catch(e){const t=e instanceof r?e:new r("Failed to access user media",{error:e,deviceId:o.deviceId});throw d("error",t),t}},stop:function(){const a=!!t;l(),u(t),t=null,n=null,e=void 0,o=!1,a&&(d("stream",null),d("device",void 0))},switchDevice:f,setMuted:function(e){o!==e&&(o=e,n&&(n.enabled=!e),d("muted",o))},isMuted:()=>o,getStream:()=>t,getTrack:()=>n,getAnalyser:()=>i,getCurrentDeviceId:()=>e,on:function(e,t){const n=c[e];return n.add(t),()=>{n.delete(t)}}}}()),Vt}function Wt(e,t){const n=document.createElement(e);return t&&(n.className=t),n}var Ut,Ht,$t,Bt,Kt,Gt,qt;jt('.np_companion-inactive-overlay{align-items:center;bottom:0;display:flex;justify-content:center;left:0;pointer-events:auto;position:absolute;right:0;top:0;z-index:9999}.np_companion-inactive-dialog{backdrop-filter:blur(19px);background:hsla(0,0%,50%,.3);background-blend-mode:luminosity;border-radius:16px;max-width:500px;overflow:hidden;padding:24px 16px;position:relative;text-align:center;width:100%}.np_companion-inactive-dialog:before{background:linear-gradient(180deg,hsla(0,0%,100%,.4),hsla(0,0%,100%,0),hsla(0,0%,100%,0),hsla(0,0%,100%,.1));border-radius:16px;content:"";inset:0;-webkit-mask:linear-gradient(#fff 0 0) content-box,linear-gradient(#fff 0 0);-webkit-mask-composite:destination-out;mask-composite:exclude;padding:1.473px;pointer-events:none;position:absolute}.np_companion-inactive-message{color:#fff;font-size:16px;line-height:1.5;margin-bottom:24px;margin-top:0}.np_companion-inactive-timer{display:flex;justify-content:center;margin:24px 0;pointer-events:none}.np_companion-timer-circle{align-items:center;display:flex;height:80px;justify-content:center;position:relative;width:80px}.np_companion-timer-circle svg{height:100%;transform:rotate(-90deg);width:100%}.np_companion-timer-circle path{transition:stroke-dasharray .3s ease}.np_companion-timer-number{color:#fff;font-size:24px;font-weight:500;position:absolute}.np_companion-inactive-buttons{display:flex;gap:12px;justify-content:center}.np_companion-inactive-buttons button{border:none;border-radius:8px;cursor:pointer;font-size:14px;font-weight:500;padding:12px 24px;transition:all .2s ease}.np_companion-end-button{background:hsla(0,0%,100%,.1);color:#fff}.np_companion-end-button:hover{background:hsla(0,0%,100%,.2)}.np_companion-continue-button{background:#3c19cd;color:#fff}.np_companion-continue-button:hover{background:#2f13a0}'),function(e){e.LOCAL_TIMEOUT="local_timeout",e.SERVER_WARNING="server_warning"}(Ut||(Ut={}));class Qt{constructor(e,t={}){Object.defineProperty(this,"overlayController",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"currentTrigger",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"isVisible",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"mountElement",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"callbacks",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.mountElement=e,this.callbacks=t}show(e){this.isVisible?ft.warn("Inactive overlay already visible, ignoring show request"):(ft.info(`Showing inactive overlay (trigger: ${e.type})`),this.currentTrigger=e,this.isVisible=!0,this.overlayController=function(e,t){const n={duration:t.duration??30,isInteractionNeeded:t.isInteractionNeeded??!1,message:t.message??"It looks like you've been inactive for a while. Would you like to continue this conversation?",onContinue:t.onContinue,onEnd:t.onEnd},o=document.createElement("div");o.className="np_companion-inactive-overlay";const a=document.createElement("div");a.className="np_companion-inactive-dialog";const i=document.createElement("p");i.className="np_companion-inactive-message",i.textContent=n.message;const r=document.createElement("div");r.className="np_companion-inactive-timer";const s=document.createElement("div");s.className="np_companion-timer-circle";const c=document.createElementNS("http://www.w3.org/2000/svg","svg");c.setAttribute("viewBox","0 0 36 36");const d=document.createElementNS("http://www.w3.org/2000/svg","path");d.setAttribute("d","M18 2.0845 a 15.9155 15.9155 0 0 1 0 31.831 a 15.9155 15.9155 0 0 1 0 -31.831"),d.setAttribute("fill","none"),d.setAttribute("stroke","rgba(255, 255, 255, 0.2)"),d.setAttribute("stroke-width","2");const l=document.createElementNS("http://www.w3.org/2000/svg","path");l.setAttribute("d","M18 2.0845 a 15.9155 15.9155 0 0 1 0 31.831 a 15.9155 15.9155 0 0 1 0 -31.831"),l.setAttribute("fill","none"),l.setAttribute("stroke","#fff"),l.setAttribute("stroke-width","2");const p=document.createElement("span");p.className="np_companion-timer-number",s.appendChild(c),c.appendChild(d),c.appendChild(l),s.appendChild(p),r.appendChild(s);const u=document.createElement("div");u.className="np_companion-inactive-buttons";const h=document.createElement("button");h.className="np_companion-end-button np_companion__d-none",h.textContent="End Conversation";let f=null;const m=e=>{e&&!f?(f=document.createElement("button"),f.className="np_companion-continue-button",f.textContent="Continue Talking",u.appendChild(f),f.addEventListener("click",n.onContinue)):!e&&f&&(f.removeEventListener("click",n.onContinue),f.parentNode&&f.parentNode.removeChild(f),f=null)};u.appendChild(h),m(n.isInteractionNeeded),a.appendChild(i),a.appendChild(r),a.appendChild(u),o.appendChild(a),e.appendChild(o);let g=Math.max(0,Math.floor(n.duration)),v=null;const b=()=>{p.textContent=String(g),l.setAttribute("stroke-dasharray",(n.duration>0?g/n.duration*100:0)+", 100")},y=()=>{if(g<=0)return w(),void n.onEnd();g-=1,b()},_=()=>{w(),b(),v=window.setInterval(y,1e3)},w=()=>{null!=v&&(window.clearInterval(v),v=null)};return h.addEventListener("click",()=>{w(),n.onEnd()}),_(),{update:e=>{if(void 0!==e.message&&(n.message=e.message,i.textContent=n.message),void 0!==e.isInteractionNeeded&&(n.isInteractionNeeded=!!e.isInteractionNeeded,m(n.isInteractionNeeded)),void 0!==e.duration){const t=Math.max(0,Math.floor(e.duration));n.duration=t,g=t,_()}e.onContinue&&(f&&(f.removeEventListener("click",n.onContinue),f.addEventListener("click",e.onContinue)),n.onContinue=e.onContinue),e.onEnd&&(n.onEnd=e.onEnd)},destroy:()=>{w(),h.removeEventListener("click",n.onEnd),f&&f.removeEventListener("click",n.onContinue),o.parentNode&&o.parentNode.removeChild(o)}}}(this.mountElement,{duration:e.duration,message:e.message,isInteractionNeeded:e.isInteractionNeeded,onContinue:()=>this.handleContinue(),onEnd:()=>this.handleEnd()}),this.callbacks.onShow?.(e))}hide(){this.isVisible&&(ft.info("Hiding inactive overlay"),this.isVisible=!1,this.currentTrigger=null,this.overlayController&&(this.overlayController.destroy(),this.overlayController=null),this.callbacks.onHide?.())}isShowing(){return this.isVisible}getCurrentTrigger(){return this.currentTrigger}handleContinue(){ft.info("User clicked continue on inactive overlay"),this.hide(),this.callbacks.onContinue?.()}handleEnd(){ft.info("Inactive overlay countdown ended"),this.hide(),this.callbacks.onEnd?.()}destroy(){this.hide()}}!function(e){e.TALK_STATE_CHANGED="talk_state_changed",e.MESSAGE_RECEIVED="message_received",e.TRANSCRIPT="transcript",e.AUDIO_TRANSCRIPT_DELTA="response.audio_transcript.delta",e.AUDIO_TRANSCRIPT_DONE="response.audio_transcript.done",e.RESPONSE_DONE="response.done"}(Ht||(Ht={})),function(e){e.STARTED="started",e.ENDED="ended",e.CANCELED="canceled"}($t||($t={})),function(e){e.DELTA="delta",e.COMPLETED="completed"}(Bt||(Bt={})),function(e){e.USER="user",e.ASSISTANT="assistant"}(Kt||(Kt={})),function(e){e.SET_REMOTE_DESCRIPTION="set_remote_description",e.SET_LOCAL_DESCRIPTION="set_local_description",e.ADD_ICE_CANDIDATE="add_ice_candidate",e.ERROR="error"}(Gt||(Gt={})),function(e){e.SEND_MESSAGE="send_message",e.CANCEL="cancel",e.SET_SETTINGS="set_settings",e.START_VIDEO="start_video",e.STOP_VIDEO="stop_video"}(qt||(qt={}));const Zt={iceServers:[{urls:"stun:stun1.ciscape.com:3478"},{urls:"turn:stun1.ciscape.com:3478",username:"tcuser",credential:"dw4k_BR2f-Y4A-@aT7ip@Qzs"},{urls:"stun:129.146.43.226:3478"},{urls:"stun:stun.l.google.com:19302"},{urls:"stun:stun1.l.google.com:19302"},{urls:"turn:129.146.43.226:3478",username:"teamtime_turn",credential:"teamtime"}]};function Jt(){return"undefined"!=typeof navigator&&!!navigator.mediaDevices&&"function"==typeof navigator.mediaDevices.getDisplayMedia}function Yt(e,t){if(t)for(const n in t)try{const o=t[n];"string"!=typeof o&&"number"!=typeof o||(e.style[n]=o)}catch{ft.warn(`Failed to apply style for key "${n}: ${t[n]}".`)}}function Xt(e,t,n){const o=[];return o.push("np_companion-align-middle"),e&&(o.push("np_companion-container-fixed"),o.push(`np_companion-${e}`),t&&o.push(`np_companion-view-${t}`)),n&&o.push(n),o.join(" ")}class en{static getInstance(){return en.instance||(en.instance=new en),en.instance}constructor(){Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:"1.0.0-alpha.41"}),Object.defineProperty(this,"mountTarget",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"rootEl",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"embed",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"webrtcController",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"screenShareController",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"faceTrackingController",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"config",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"isInitialized",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"unloadHandler",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"pipController",{enumerable:!0,configurable:!0,writable:!0,value:null}),"undefined"!=typeof window&&(this.unloadHandler=()=>{this.screenShareController?.destroy()},window.addEventListener("beforeunload",this.unloadHandler))}renderApp(){if(!this.mountTarget||!this.config)return;this.rootEl||(this.rootEl=document.createElement("div"),this.rootEl.id="np_companion-sdk-root",this.mountTarget.appendChild(this.rootEl)),this.rootEl.className=Xt(this.config.position,this.config.avatarStyle?.view,this.config.className),Yt(this.rootEl,this.config.style),this.screenShareController||(this.screenShareController=function(e){const t=new Ct(1e3);let n=null,o=!1,a=!1;async function i(){if(!o&&!a)if(Jt()){a=!0;try{const a=await navigator.mediaDevices.getDisplayMedia({video:{frameRate:{max:1},width:{max:1280},height:{max:720}},audio:!1,selfBrowserSurface:"include"});n=a;const i=a.getVideoTracks()[0];i&&i.addEventListener("ended",()=>{r()}),t.setStream(a),o=!0,e?.onStateChange?.(!0),await function(e=5e3){const t=ut(pt.getState());return t&&"open"===t.readyState?Promise.resolve():new Promise((t,n)=>{const o=setTimeout(()=>{a(),n(new Error("Timed out waiting for data channel to open"))},e),a=pt.subscribe(()=>{const e=ut(pt.getState());e&&"open"===e.readyState&&(clearTimeout(o),a(),t())})})}(),St({type:qt.START_VIDEO,data:null}),ft.webrtc("Screen sharing started")}catch(e){throw n&&(n.getTracks().forEach(e=>e.stop()),n=null),t.setStream(null),o=!1,"NotAllowedError"===e.name?ft.warn("ScreenShare","Permission denied by user"):"NotFoundError"===e.name?ft.warn("ScreenShare","No screen sharing source selected"):ft.critical_warn("ScreenShare","Failed to start screen share:",e),e}finally{a=!1}}else ft.critical_warn("ScreenShare","getDisplayMedia is not supported in this browser")}function r(){o&&(n&&(n.getTracks().forEach(e=>e.stop()),n=null),t.setStream(null),o=!1,e?.onStateChange?.(!1),St({type:qt.STOP_VIDEO,data:null}),ft.webrtc("Screen sharing stopped"))}return{start:i,stop:r,toggle:async function(){o||a?o&&r():await i()},isSharing:function(){return o},isSupported:function(){return Jt()},getCapture:function(){return t},destroy:function(){r(),t.terminate()}}}({onStateChange:e=>{pt.dispatch(Je(e)),this.embed?.updateScreenShareState(e),this.config?.onScreenShareStateChange?.(e)}}));const e=Jt(),t=pt.getState().app.features.screenShare?.enabled??!1,n={isScreenSharing:this.screenShareController.isSharing(),isScreenShareSupported:e&&t,onScreenShareToggle:()=>this.handleScreenShareToggle()};this.embed?this.embed.update({avatarStyle:this.config.avatarStyle,features:pt.getState().app.features,onData:this.config.onData,onAvatarReady:this.config.onAvatarReady,onInactivityStatusChange:this.config.onInactivityStatusChange,onDestroy:()=>this.destroyInstance("ui_end"),onError:this.config.onError,...n}):this.embed=function(e,t={}){const n=bt.createDiv("np_companion-live-container np_companion-fade-in");e.appendChild(n);const o=function(e,t={}){const n=bt.createDiv("np_companion-avatar"),o=bt.createDiv(`np_companion-avatar-container np_companion-loader-${t.features?.showSDKLoader?.type??"spinner"}`);o.id="np_companion-avatar-container",t.avatarStyle?.view&&o.classList.add(`np_companion-view-${t.avatarStyle.view}`);const a=bt.createDiv("loader-container"),i=bt.createDiv("loader");a.appendChild(i);const r=bt.createVideo({className:"np_companion-avatar-video",autoplay:!0,muted:!0,playsInline:!0}),s=bt.createAudio({className:"np_companion-avatar-audio",autoplay:!0}),c=bt.createCanvas({className:"np_companion-avatar-canvas",styles:{width:"100%",height:"100%",objectFit:"cover",position:"relative",zIndex:"1"}});t.features?.backgroundRemoval?.enabled&&"silhouette"===t.avatarStyle?.view?r.classList.add("np_companion__d-none"):c.classList.add("np_companion__d-none"),o.appendChild(a),o.appendChild(r),o.appendChild(s),o.appendChild(c);const d=bt.createDiv(`np_companion-action-btn-container-wrapper np_companion-action-btn-container-view-${t.avatarStyle?.view}`),l=bt.createDiv(`np_companion-disclaimer-text np_companion-disclaimer-view-${t.avatarStyle?.view}`);l.style.display="none";const p=bt.createDiv(`np_companion-avatar-control-container np_companion-avatar-control-view-${t.avatarStyle?.view}`);p.appendChild(d),p.appendChild(l),n.appendChild(o),n.appendChild(p),e.appendChild(n);const u=zt();let h=(t.features?.backgroundRemoval?.enabled&&"silhouette"===t.avatarStyle?.view)??!1,f=null,m=null,g=!1,v=!1,b=!1,y=!1,_=null,w=!0,S=null,C=null,E=null;const x=new Qt(n,{onContinue:()=>{z();const e=t.features?.inactiveTimeout;e?.enabled&&W()},onEnd:()=>{t.onDestroy?.()}});let k=pt.getState().avatar.muted,T=pt.getState().avatar.volume,I=pt.getState().avatar.avatarSpeaking;const O=u.on("muted",e=>{pt.getState().avatar.muted!==e&&pt.dispatch(qe(e))}),N=pt.subscribe(()=>{const e=pt.getState();e.avatar.muted!==k&&(k=e.avatar.muted,u.setMuted(k),C?.update({isMuted:k}),L(k)),e.avatar.volume!==T&&(T=e.avatar.volume,s.volume=T/100),e.avatar.avatarSpeaking!==I&&(I=e.avatar.avatarSpeaking,C?.update({isAvatarSpeaking:I}))});let A=null;const D=()=>{w||(w=!0,p.className=P(),null!=S&&window.clearTimeout(S))},R=()=>{null!=S&&window.clearTimeout(S),S=window.setTimeout(()=>{w=!1,p.className=P()},5e3)};function P(){return mt(`np_companion-avatar-control-container np_companion-avatar-control-view-${t.avatarStyle?.view}`,{[vt]:!w})}function L(e){if(!v)return;const n=t.avatarStyle?.borderWidth??("silhouette"!==t.avatarStyle?.view?"4px":void 0);n&&(o.style.borderWidth=n);const a=("silhouette"!==t.avatarStyle?.view?e?"#ec3e41":t.avatarStyle?.borderColor??"#C0C0C0":void 0)??t.avatarStyle?.borderColor;a&&(o.style.borderColor=a);const i=t.avatarStyle?.borderStyle??("silhouette"!==t.avatarStyle?.view?"solid":void 0);i&&(o.style.borderStyle=i)}function M(e){"round"===t.avatarStyle?.view&&(o.style.transform=`translate(-50%, ${e??352-p.offsetHeight-212-12+"px"})`)}function j(){const e=t.features?.disclaimer?.enabled??!1;l.style.display=e&&v?"-webkit-box":"none",C?.update({features:{disclaimer:{enabled:e}}});const n=t.features?.disclaimer?.text??"This is an AI avatar. Check important info.";t.features?.disclaimer?.color&&(l.style.color=t.features?.disclaimer?.color),l.textContent=n,v&&M(e?void 0:"8%")}function F(){v||!t.features?.showSDKLoader?.enabled?n.classList.add("np_companion-bg-transparent"):n.classList.remove("np_companion-bg-transparent")}function V(){t.features?.showSDKLoader?.bgColor&&n.style.setProperty("--np-loader-bg-color",t.features.showSDKLoader.bgColor),t.features?.showSDKLoader?.color&&n.style.setProperty("--np-loader-color",t.features.showSDKLoader.color)}function z(){E&&(ft.timer("Resetting inactive timeout due to activity"),clearTimeout(E),E=null,pt.dispatch(Ge(!1)),t.onInactivityStatusChange?.(!1))}function W(){const e=t.features?.inactiveTimeout;e?.enabled?(z(),E=setTimeout(()=>{ft.timer(`Inactive timeout of ${e?.duration}ms reached, showing inactive overlay`),pt.dispatch(Ge(!0)),t.onInactivityStatusChange?.(!0),u.setMuted(!0),C?.update({isMuted:!0}),L(!0),x.isShowing()||x.show({type:Ut.LOCAL_TIMEOUT,duration:Math.min(e.countdown??30,60),message:void 0,isInteractionNeeded:!0})},e.duration)):(z(),x.isShowing()&&x.hide())}function U(){!C&&v&&(C=function(e,t){let n={...t};const o=zt();let a=null,i=null,r=[],s=!1;const c=document.createElement("div");c.className=E();const d=Wt("div","np_companion-action-btn-container-container"),l=Wt("div",mt("np_companion-chat-question-bar-container",gt)),p=Wt("div","np_companion-action-btn-container-left"),u=It(),h=u.element,f=Wt("div","np_companion-action-btn-container-middle"),m=Wt("div","np_companion-action-btn-container-wave");x();const g=document.createElement("canvas");g.width=160,g.height=40,g.className="np_companion-action-btn-container-canvas",m.appendChild(g);const v=Wt("div",mt("np_companion-action-btn-container-right",gt)),b=Nt(),y=Ot(()=>n.handleEnd?.()),_=y.element;p.appendChild(h),f.appendChild(m),v.appendChild(b.element);const w=At({onToggle:()=>n.onScreenShareToggle?.(),isSupported:n.isScreenShareSupported??!1});v.appendChild(w.element),v.appendChild(_),l.appendChild(p),l.appendChild(v),d.appendChild(l),c.appendChild(d),e.appendChild(c),C();const S=o.on("stream",()=>{C()});function C(){null!=i&&(cancelAnimationFrame(i),i=null),r=[],a=o.getAnalyser(),a&&function(){if(!a)return;const e=g.getContext("2d");if(!e)return;a.fftSize=256;const t=a.frequencyBinCount,o=new Uint8Array(t),c=Math.floor(g.width/3);0===r.length&&(r=new Array(c).fill(0));let d=0;const l=()=>{if(e.clearRect(0,0,g.width,g.height),e.beginPath(),e.moveTo(0,g.height/2),e.lineTo(g.width,g.height/2),e.strokeStyle="#ffffff",e.stroke(),n.isMuted)s=!1,pt.dispatch(Ye(!1)),r.fill(0),x();else{a.getByteFrequencyData(o);const n=4,i=Math.floor(.05*t),c=Math.floor(.4*t);let l=0;for(let e=i;e<c;e++)o[e]>l&&(l=o[e]);const p=l/255*g.height*.8;r.shift(),r.push(p);let u=r.slice(-5).some(e=>e>n);u?d=30:d>0&&(d--,u=!0),s=u,pt.dispatch(Ye(s)),x(),e.fillStyle="#ffffff";for(let t=0;t<r.length;t++){const n=3*t,o=r[t];e.fillRect(n,g.height/2-o/2,2,o),e.fillRect(n,g.height/2+o/2,2,-o)}}i=requestAnimationFrame(l)};l()}()}function E(){return mt("np_companion-align-middle",`np_companion-avatar-${n.avatarStyle?.view}`)}function x(){m.style.filter=!n.isMuted&&s?"brightness(0) saturate(100%) invert(48%) sepia(93%) saturate(1720%) hue-rotate(346deg) brightness(101%) contrast(103%)":"none",m.style.transition="filter 0.3s ease",m.style.height="40px",h.classList.remove("np_companion-talking")}return{update(e){const t=n;n={...n,...e},c.className=E(),t.selectedMicrophone!==n.selectedMicrophone&&C(),x(),n.features?.disclaimer?.enabled?d.classList.remove("np_companion_disclaimer-disabled"):d.classList.add("np_companion_disclaimer-disabled")},destroy(){null!=i&&cancelAnimationFrame(i),S(),u.destroy(),b.destroy(),w.destroy(),y.destroy(),c.parentNode&&c.parentNode.removeChild(c)}}}(d,{avatarStyle:t.avatarStyle,isMuted:!1,isAvatarSpeaking:pt.getState().avatar.avatarSpeaking,isScreenSharing:t.isScreenSharing,isScreenShareSupported:t.isScreenShareSupported,onScreenShareToggle:()=>t.onScreenShareToggle?.(),features:{waveform:{enabled:!1!==t.features?.waveform?.enabled},screenShare:t.features?.screenShare},onVolumeChange:e=>{pt.dispatch(Qe(e))},toggleMute:()=>{const e=pt.getState().avatar.muted;pt.dispatch(qe(!e)),z(),W()},onStopTalking:()=>{try{ft.avatar("stopping avatar"),St({type:qt.CANCEL})}catch(e){ft.critical_error("Avatar","Stop: failed to send interrupt",e)}z(),W()},handleEnd:()=>{t.onDestroy?.()}}))}function H(){const e=ut(pt.getState());return!!e&&"open"===e.readyState}function $(){g||v||b&&y&&(v=!0,t.onAvatarReady?.(!0),L(),U(),F(),j(),W(),M(),R())}function B(){b||(b=!0,$())}n.addEventListener("mouseenter",D),n.addEventListener("mousemove",D),n.addEventListener("mouseleave",R);const K=()=>{if(g)return;const e=c.getContext("2d",{willReadFrequently:!0});if(!e||!r||r.readyState<2)A=requestAnimationFrame(K);else{if(c.width=r.videoWidth,c.height=r.videoHeight,e.drawImage(r,0,0,c.width,c.height),h){const t=e.getImageData(0,0,c.width,c.height),n=yt.process(t);e.putImageData(n,0,0),B()}A=requestAnimationFrame(K)}};j(),V(),F(),y||_||(H()?(y=!0,$()):_=pt.subscribe(()=>{y||H()&&(y=!0,_?.(),_=null,$())}));const G={updateStreams:({videoStream:e,audioStream:n})=>{e&&e instanceof MediaStream?f!==e&&(ft.avatar("New video stream received:",{active:e.active,tracks:e.getTracks().length,videoTracks:e.getVideoTracks().length,id:e.id}),f=e,r.srcObject=e,g||r.play().then(()=>{g||h||B()}).catch(e=>{g||"AbortError"===e?.name||(ft.error("Failed to play video stream",e),t.onError?.(e))}),e.addEventListener("inactive",()=>{ft.avatar("Video stream became inactive")}),e.getTracks().forEach(e=>{e.addEventListener("ended",()=>{ft.avatar("Video track ended:",e.kind)})}),h&&!A&&(A=requestAnimationFrame(K))):(f=null,r.srcObject=null),void 0!==n&&(n&&n instanceof MediaStream?m!==n&&(m=n,s.srcObject=n,navigator.mediaSession.metadata=new MediaMetadata({title:"Napster Companion"}),g||s.play().catch(e=>{g||"AbortError"===e?.name||(ft.error("Failed to play audio stream",e),t.onError?.(e))})):(m=null,s.srcObject=null))},updateWaveform:e=>{U(),C?.update(e)},updateFeatures:e=>{t.features={...t.features||{},...e||{}},h=(t.features?.backgroundRemoval?.enabled&&"silhouette"===t.avatarStyle?.view)??!1,h?(r.classList.add("np_companion__d-none"),c.classList.remove("np_companion__d-none")):(r.classList.remove("np_companion__d-none"),c.classList.add("np_companion__d-none")),C?.update({features:{waveform:{enabled:!1!==t.features?.waveform?.enabled}}}),j(),V(),F(),W()},update:e=>{const n=t.avatarStyle?.view;Object.assign(t,e),e.features&&G.updateFeatures(e.features),e.avatarStyle?.view&&e.avatarStyle.view!==n&&(n&&o.classList.remove(`np_companion-view-${n}`),o.classList.add(`np_companion-view-${e.avatarStyle.view}`),t.features&&G.updateFeatures(t.features))},setAvatarReady:e=>{e||(v=!1,t.onAvatarReady?.(!1))},updateScreenShareState:e=>{t.isScreenSharing=e,C?.update({isScreenSharing:e})},setAudioMuted:e=>{s.muted=e},getAudioMuted:()=>s.muted,setAudioVolume:e=>{const t=Math.max(0,Math.min(1,e));s.volume=t},getAudioVolume:()=>s.volume,handleMessage:e=>{switch("undefined"!=typeof window&&window.parent&&window.parent.postMessage({type:"avatar-data-channel-message",event:e},"*"),e.event){case"avatar_state_changed":break;case"talk_state_changed":pt.dispatch(Ze("ended"!==e.data?.state&&"canceled"!==e.data?.state));break;case"message_received":{const{message:t}=e.data||{};if("completed"===t?.action&&"string"==typeof t.content&&t.role){z(),W();const e=x.getCurrentTrigger();e&&!e.isInteractionNeeded&&x.hide()}break}case"avatar_connection_warning":t.showAvatarInactiveOverlay&&(x.show({type:Ut.SERVER_WARNING,duration:e.data?.disconnect_after??30,message:"Avatar is disconnecting due to inactivity. Say something to keep it active.",isInteractionNeeded:!1}),u.setMuted(!1),C?.update({isMuted:!1}),L(!1))}t.onData?t.onData(e):ft.data("onData callback NOT called. Reason:",{onDataExists:!!t.onData,dataType:typeof e,dataIsNull:null===e})},destroy:e=>{if(!g){g=!0,_&&(_(),_=null),n.removeEventListener("mousemove",D),n.removeEventListener("mouseenter",D),n.removeEventListener("mouseleave",R),null!=S&&window.clearTimeout(S),null!=A&&(cancelAnimationFrame(A),A=null),E&&(clearTimeout(E),E=null);try{r.pause(),r.srcObject=null}catch{}try{s.pause(),s.srcObject=null}catch{}try{f?.getTracks().forEach(e=>e.stop())}catch{}try{m?.getTracks().forEach(e=>e.stop())}catch{}f=null,m=null,C?.destroy(),C=null,x?.destroy(),N(),O(),n.parentNode&&n.parentNode.removeChild(n),v=!1,t.onAvatarReady?.(!1),e||t.onDestroy?.()}}};return G}(n,{avatarStyle:t.avatarStyle,showAvatarInactiveOverlay:!0,onData:t.onData,onDestroy:t.onDestroy,onError:t.onError,onInactivityStatusChange:t.onInactivityStatusChange,onAvatarReady:t.onAvatarReady,features:t.features,onScreenShareToggle:t.onScreenShareToggle,isScreenSharing:t.isScreenSharing,isScreenShareSupported:t.isScreenShareSupported});return{update:e=>{o.update({avatarStyle:e.avatarStyle??t.avatarStyle,onData:e.onData??t.onData,onDestroy:e.onDestroy??t.onDestroy,onError:e.onError??t.onError,onInactivityStatusChange:e.onInactivityStatusChange??t.onInactivityStatusChange,onAvatarReady:e.onAvatarReady??t.onAvatarReady,features:e.features??t.features,onScreenShareToggle:e.onScreenShareToggle??t.onScreenShareToggle,isScreenSharing:e.isScreenSharing??t.isScreenSharing,isScreenShareSupported:e.isScreenShareSupported??t.isScreenShareSupported}),Object.assign(t,e)},updateStreams:e=>{o.updateStreams(e)},handleMessage:e=>{o.handleMessage(e)},updateScreenShareState:e=>{o.updateScreenShareState(e)},setAudioMuted:e=>{o.setAudioMuted(e)},getAudioMuted:()=>o.getAudioMuted(),setAudioVolume:e=>{o.setAudioVolume(e)},getAudioVolume:()=>o.getAudioVolume(),destroy:()=>{o.destroy(!0),n.parentNode===e&&e.removeChild(n),t.onDestroy?.()}}}(this.rootEl,{avatarStyle:this.config.avatarStyle,features:pt.getState().app.features,onData:this.config.onData,onAvatarReady:this.config.onAvatarReady,onInactivityStatusChange:this.config.onInactivityStatusChange,onDestroy:()=>this.destroyInstance("ui_end"),onError:this.config.onError,...n});const o=pt.getState().app.features.pictureInPicture?.enabled;o&&!this.pipController&&(this.pipController=function(e){let t=null,n=[];const o=()=>{if(t){n.forEach(e=>e.destroy()),n=[];try{t.close()}catch{}t=null,ft.info("PiP: window closed")}};try{navigator.mediaSession.setActionHandler("enterpictureinpicture",()=>{(async()=>{if(t)return;const o=window.documentPictureInPicture;if(!o)return void ft.info("PiP: Document PiP API not supported");const a=document.querySelector(".np_companion-avatar-video");if(a&&a.srcObject)try{const i=pt.getState().app.features.pictureInPicture;t=await o.requestWindow({width:i?.width??400,height:i?.height??300,disallowReturnToOpener:!1});const r=t.document.createElement("video");r.srcObject=a.srcObject,r.autoplay=!0,r.muted=!0,r.playsInline=!0,Object.assign(r.style,{position:"absolute",inset:"0",width:"100%",height:"100%",objectFit:"cover",objectPosition:"center"}),Object.assign(t.document.body.style,{margin:"0",overflow:"hidden",background:"#000",position:"relative",width:"100vw",height:"100vh"}),t.document.body.appendChild(r);const s=It(),c=Nt(),d=At({onToggle:e.onScreenShareToggle,isSupported:e.isScreenShareSupported()}),l=Ot(e.onEnd);n=[s,c,d,l];const p=t.document.createElement("div");Object.assign(p.style,{position:"absolute",bottom:"12px",left:"50%",transform:"translateX(-50%)",display:"flex",alignItems:"center",gap:"8px",padding:"16px 16px 12px",borderRadius:"80px",background:"rgba(0, 0, 0, 0.18)",boxShadow:"0px 4px 4px 0px rgba(0, 0, 0, 0.25), 2px 2px 8px 0px rgba(0, 0, 0, 0.12)",backdropFilter:"blur(34px)",zIndex:"10",transition:"all 0.3s ease-in-out"}),p.appendChild(s.element),p.appendChild(c.element),p.appendChild(d.element),p.appendChild(l.element),t.document.body.appendChild(p),ft.info("PiP: window opened, video cloned"),t.addEventListener("pagehide",()=>{n.forEach(e=>e.destroy()),n=[],t=null,ft.info("PiP: window closed by user")})}catch(e){ft.critical_error("PiP: requestWindow failed",e)}else ft.info("PiP: video element or stream not found")})().catch(e=>ft.critical_error("PiP: failed to open",e))})}catch{ft.info("PiP: Media Session enterpictureinpicture not supported")}const a=()=>{document.hidden||o()};return document.addEventListener("visibilitychange",a),{destroy:()=>{document.removeEventListener("visibilitychange",a);try{navigator.mediaSession.setActionHandler("enterpictureinpicture",null)}catch{}o()}}}({onEnd:()=>this.destroyInstance("api"),onScreenShareToggle:()=>this.handleScreenShareToggle(),isScreenShareSupported:()=>Jt()&&(pt.getState().app.features.screenShare?.enabled??!1)})),this.initializeWebRTC().catch(e=>{ft.critical_error("Failed to establish WebRTC connection:",e),this.config?.onError?.(e)})}async handleScreenShareToggle(){if(this.screenShareController)try{await this.screenShareController.toggle();const e=this.screenShareController.isSharing();pt.dispatch(Je(e)),this.embed?.updateScreenShareState(e),this.config?.onScreenShareStateChange?.(e)}catch(e){ft.critical_warn("SDK","Screen share toggle failed:",e),this.config?.onError?.(e);const t=this.screenShareController.isSharing();pt.dispatch(Je(t)),this.embed?.updateScreenShareState(t),this.config?.onScreenShareStateChange?.(t)}}async initializeWebRTC(){const e=pt.getState().avatar.connectionToken;if(e&&!this.webrtcController){ft.connection("Connecting WebRTC..."),this.webrtcController=function(e={}){const{currentAudioDeviceId:t,functions:n,screenShareCapture:i,onChatMessage:r,onConnectionSuccess:s,onConnectionError:c,onStreams:d,onDataChannel:l}=e;let p=null,u=null,h=null,f=null,m=null,g=null;const v=zt();let b=null,y="disconnected",_=0,w=null,S=null;function C(e,t){return e&&e.readyState===WebSocket.OPEN?(e.send(JSON.stringify(t)),!0):(ft.critical_warn("WebRTC",`WS send skipped; state=${e?.readyState}`),!1)}function E(e){S=e,c?.(e)}function x(e){y=e,ft.webrtc(`Connection status changed to: ${e}`)}async function k(e){if(p&&"disconnected"!==y)ft.warn("WebRTC","Connection already in progress, skipping...");else try{x("connecting"),S=null;const c=(e=>{try{const t=atob(e);return JSON.parse(t)}catch(e){return ft.critical_error("decodeToBase64: Error decoding token",e),null}})(e);if(!c)throw new o("Failed to decode connection token",{token:e?"provided":"missing"});w={...c,token:e},pt.dispatch(Be(c.connection.id));const y=await async function(e,t,n=!1){const a=`${e.replace(/\/$/,"")}/ws/connections/${t}/signaling`;u&&u.readyState===WebSocket.OPEN&&u.close();const i=new WebSocket(a);return u=i,await new Promise((e,t)=>{let a=!1;i.onopen=()=>{ft.connection(n?"WebSocket reconnected":"WebSocket connected"),x("connected"),_=0,a=!0,e()},i.onclose=e=>{ft.connection("WebSocket closed:",e),u=null,x("disconnected"),a||t(new o("WebSocket connection closed",{code:e.code,reason:e.reason,wasClean:e.wasClean}))},i.onerror=e=>{u=null;const n=new o("WebSocket connection error",{error:e,timestamp:(new Date).toISOString()});a?"connected"===p?.connectionState||"connected"===p?.iceConnectionState||"completed"===p?.iceConnectionState?x("disconnected"):(x("disconnected"),E(n)):(x("disconnected"),E(n),t(n))}}),pt.dispatch(Xe(void 0)),i}(c.connection.signalingEndpoint,c.connection.id),k=await async function(){ft.webrtc("Create PeerConnection");const e=new RTCPeerConnection(Zt);return p=e,e.addEventListener("connectionstatechange",()=>{"failed"===e.connectionState?E(new o("WebRTC connection failed")):"connected"===e.connectionState&&(x("connected"),_=0)}),function(e){g=e.addTransceiver("audio",{direction:"sendrecv"});const t=e.addTransceiver("video",{direction:"recvonly"});if(i){const t=i.getCanvas().captureStream(1);t.getTracks().forEach(n=>{e.addTrack(n,t)})}ft.webrtc("Added transceivers",{videoTransceiver:t,audioTransceiver:g});const o=e.createDataChannel("chat",{ordered:!0});m=o,o.onopen=()=>{ft.webrtc("Data channel opened"),pt.dispatch(Ke(o)),l?.(o),s?.(),n&&n.length>0&&(St({type:qt.SET_SETTINGS,data:{functions:n}}),ft.webrtc("Functions sent via data channel",n))},o.onclose=()=>{ft.webrtc("Data channel closed"),pt.dispatch(Ke(null))},o.onerror=e=>{ft.critical_error("WebRTC",e),E(new a("Data channel error",{error:e}))},o.onmessage=e=>{try{const t=JSON.parse(e.data);ft.data("Data channel message received:",t),r?.(t)}catch{r?.({event:"message_received",data:{message:{content:e.data,action:"completed"}}})}}}(e),e.ontrack=e=>{const t=e.streams[0];ft.webrtc(`${e.track.kind} stream received`,{streamId:t?.id,trackId:e.track.id,videoTracks:t?.getVideoTracks().length,audioTracks:t?.getAudioTracks().length}),"video"===e.track.kind?(h=t,f=t):"audio"===e.track.kind&&(f=t,h||(h=t)),d?.({videoStream:h,audioStream:f})},e}();await async function(){try{ft.webrtc("Setting up user media"),b||(b=v.on("stream",e=>{(async function(e){if(!g)return;const t=e?.getAudioTracks()[0]??null;await g.sender.replaceTrack(t)})(e).catch(e=>{ft.critical_error("WebRTC","Failed to apply mic track to sender",e),E(new a("Failed to replace audio track",{error:e}))})})),await v.start({deviceId:t})}catch(e){ft.critical_warn("WebRTC",e),E(new o("Failed to access user media",{error:e,deviceId:t}))}}(),await async function(e,t){e.addEventListener("icecandidate",e=>{const n=e.candidate;n&&(ft.webrtc("send ICE candidate"),C(t,{type:"add_ice_candidate",data:{candidate:n}}))}),e.addEventListener("negotiationneeded",async()=>{ft.webrtc("negotiationneeded — creating new offer");try{const n=await e.createOffer();await e.setLocalDescription(n),C(t,{type:"set_remote_description",data:n})}catch(e){ft.critical_error("WebRTC","Failed to renegotiate:",e)}}),ft.webrtc("createOffer → setLocalDescription → set_remote_description");const n=await e.createOffer();await e.setLocalDescription(n),C(t,{type:"set_remote_description",data:n})}(k,y),y.onmessage=e=>async function(e,t,n){try{const o=JSON.parse(n.data);switch(o.type){case"set_remote_description":ft.webrtc("Setting remote description"),await e.setRemoteDescription(o.data),await e.setLocalDescription(),C(t,{type:"set_local_description",data:e.localDescription});break;case"add_ice_candidate":o.data?.candidate&&await e.addIceCandidate(o.data.candidate);break;case"error":ft.critical_error("WebRTC",o.data?.error),E(new a(o.data?.error||"Server error",{serverMessage:o.data})),e.close(),t.close();break;default:ft.webrtc("Unknown message type:",o.type)}}catch(e){ft.critical_error("WebRTC",e),E(new a("Failed to process WebSocket message",{originalError:e,rawMessage:n.data}))}}(k,y,e)}catch(e){const t=e;throw ft.critical_error("WebRTC",t),E(t),x("disconnected"),t}}function T(){_=0;try{if(b&&(b(),b=null),v.stop(),m)try{m.close()}catch{}if(u)try{u.readyState!==WebSocket.OPEN&&u.readyState!==WebSocket.CONNECTING||u.close(1e3,"Connection closed by client")}catch{}try{h?.getTracks().forEach(e=>e.stop())}catch{}try{f?.getTracks().forEach(e=>e.stop())}catch{}if(p)try{p.getSenders().forEach(e=>{e.track&&e.track.stop()}),p.close()}catch{}}catch(e){ft.critical_warn("WebRTC",e)}finally{m=null,u=null,p=null,g=null,h=null,f=null,w=null,x("disconnected"),pt.dispatch(Be(void 0)),pt.dispatch(et(void 0))}}return pt.dispatch(et(T)),{startWithToken:k,close:T,forceReconnect:async function(){if(w){T(),_=0;try{await k(w.token)}catch(e){throw E(e),e}}else E(new o("No connection data available for reconnect"))},getConnectionStatus:function(){return y},getReconnectAttempts:function(){return _},getError:function(){return S},updateAudioDevice:async function(e){if(g)try{await v.switchDevice(e),ft.webrtc(`Audio device updated to: ${e}`)}catch(t){ft.critical_warn("WebRTC","Failed to update audio device:",t),E(new o("Failed to update audio device",{error:t,deviceId:e}))}else ft.warn("WebRTC","No audio transceiver available for device update")}}}({functions:this.config?.functions,screenShareCapture:this.screenShareController?.getCapture()??null,onStreams:e=>{this.embed?.updateStreams(e)},onChatMessage:e=>{this.embed?.handleMessage(e)},onConnectionError:e=>{ft.critical_error("WebRTC connection error:",e),this.config?.onError?.(e),this.webrtcController&&"disconnected"===this.webrtcController.getConnectionStatus()&&(ft.critical_error("SDK","Connection failed. Destroying SDK instance."),this.destroyInstance("internal"))}});try{ft.connection("Initializing WebRTC connection with token:",`${e.substring(0,50)}...`),await this.webrtcController.startWithToken(e),ft.connection("WebRTC initialization completed with token")}catch(e){throw ft.critical_error("SDK","Failed to Initialize WebRTC:",e),this.webrtcController=null,e}}}destroyWebRTC(){if(this.screenShareController?.isSharing()&&(this.screenShareController.stop(),pt.dispatch(Je(!1)),this.embed?.updateScreenShareState(!1),this.config?.onScreenShareStateChange?.(!1)),this.webrtcController){ft.info("SDK","Destroying WebRTC controller");try{this.webrtcController.close()}catch(e){ft.critical_error("SDK","Error closing WebRTC controller:",e)}this.webrtcController=null}}destroyInstance(e,t){if(!e)return void ft.critical_warn("SDK","destroyInstance ignored (no reason)");Lt("sdk_destroyed",{reason:e}),t?.();const n=this.config?.onDestroy;if(dt(null),pt.dispatch(Xe(void 0)),pt.dispatch(et(void 0)),pt.dispatch(qe(!1)),pt.dispatch(it()),pt.dispatch(rt(void 0)),this.pipController&&(this.pipController.destroy(),this.pipController=null),this.embed){try{this.embed.update({onDestroy:void 0}),this.embed.destroy()}catch(e){ft.critical_error("Error during cleanup:",e)}this.embed=null}this.screenShareController&&(this.screenShareController.destroy(),this.screenShareController=null),this.faceTrackingController&&(this.faceTrackingController.destroy(),this.faceTrackingController=null),this.unloadHandler&&"undefined"!=typeof window&&(window.removeEventListener("beforeunload",this.unloadHandler),this.unloadHandler=null),this.destroyWebRTC(),this.rootEl&&this.rootEl.parentNode&&this.rootEl.parentNode.removeChild(this.rootEl),this.rootEl=null,this.mountTarget=null,this.config=null,this.isInitialized=!1,n?.()}async init(e,o={}){try{if(this.isInitialized)throw new t("SDK is already initialized. Call destroy() first.",{code:c.ALREADY_INITIALIZED});o.analytics?.enabled&&(function(e){Pt=new Rt(e)}(o.analytics),Lt("sdk_init_started",{version:this.version,config:{position:o.position,features:Object.keys(o.features||{})}})),function(e){if(!e||"string"!=typeof e||""===e.trim())throw new n("Invalid connection token: expected non-empty string",{providedToken:typeof e,code:c.INVALID_TOKEN})}(e);const a={avatarStyle:{view:"round"},position:d.BOTTOM_RIGHT,...o};this.config=a,pt.dispatch(Xe(e)),pt.dispatch(qe(!1)),pt.dispatch(st(a.debug)),this.config.features&&Object.entries(this.config.features).forEach(([e,t])=>{const n=Et(e,t);pt.dispatch(at({feature:e,config:n}))}),dt(e=>{try{this.embed&&this.embed.update({features:e})}catch(e){ft.critical_error("Unable to update features",e)}this.config?.onFeaturesUpdate?.(e)});const i=function(e){if(!e)return document.body;if("string"==typeof e){const t=document.querySelector(e);return t instanceof HTMLElement?t:(ft.warn(`mountContainer should be a valid CSS selector. Provided selector "${e}" is invalid or did not match any elements. Defaulting to document.body.`),document.body)}return e instanceof HTMLElement?e:document.body}(this.config.mountContainer??void 0);return this.mountTarget=i,this.isInitialized=!0,this.renderApp(),this.config.onReady?.(),Lt("sdk_init_completed",{version:this.version,initTime:Date.now()}),this.createInstanceMethods()}catch(t){const n=l.handle(t,{method:"init",tokenProvided:!!e,config:o});throw o.onError?.(n),n}}createInstanceMethods(){const e=this;return{showAvatar:()=>{const e=document.getElementById("np_companion-avatar-container");e&&(e.style.display="block",Mt("show","avatar_widget"))},hideAvatar:()=>{const e=document.getElementById("np_companion-avatar-container");e&&(e.style.display="none",Mt("hide","avatar_widget"))},avatarIsVisible:()=>{const e=document.getElementById("np_companion-avatar-container");return!!e&&"none"!==e.style.display},destroy:()=>{const{closeConnectionHandler:e}=pt.getState().avatar;this.destroyInstance("api",e)},updateStyles:e=>{this.config&&(this.config.style={...this.config.style??{},...e??{}},this.rootEl&&Yt(this.rootEl,this.config.style))},setPosition:e=>{if(this.config&&(this.config.position=e,pt.dispatch?.(rt(e)),this.rootEl)){const t=Xt(e,this.config.avatarStyle?.view,this.config.className);this.rootEl.className=t}},clearPosition:()=>{this.config&&(pt.dispatch?.(rt(void 0)),this.config.position=void 0,this.rootEl&&(this.rootEl.className=Xt(void 0,this.config.avatarStyle?.view,this.config.className)))},enableFeature:e=>{pt.dispatch?.(at({feature:e,config:{enabled:!0}})),"disclaimer"===e&&this.rootEl&&this.rootEl.classList.remove("np_companion_disclaimer-disabled")},disableFeature:e=>{pt.dispatch?.(at({feature:e,config:{enabled:!1}})),"disclaimer"===e&&this.rootEl&&this.rootEl.classList.add("np_companion_disclaimer-disabled")},updateFeatureConfig:(e,t)=>{const n=Et(e,t);pt.dispatch?.(at({feature:e,config:n})),"disclaimer"===e&&this.rootEl&&(n?.enabled?this.rootEl.classList.remove("np_companion_disclaimer-disabled"):this.rootEl.classList.add("np_companion_disclaimer-disabled"))},updateAvatarStyle:e=>{if(this.config){if(this.config.avatarStyle={view:"round",...this.config.avatarStyle,...e},e.view&&this.rootEl){const t=Xt(this.config.position,e.view,this.config.className);this.rootEl.className=t}this.embed&&this.embed.update({avatarStyle:this.config.avatarStyle})}},sendCommand:e=>{St(e)},startScreenShare:async()=>{if(!this.screenShareController?.isSharing())try{await(this.screenShareController?.start());const e=this.screenShareController?.isSharing()??!1;pt.dispatch(Je(e)),this.embed?.updateScreenShareState(e),this.config?.onScreenShareStateChange?.(e)}catch(e){throw ft.critical_warn("SDK","Failed to start screen share:",e),this.config?.onError?.(e),e}},stopScreenShare:()=>{this.screenShareController?.isSharing()&&(this.screenShareController.stop(),pt.dispatch(Je(!1)),this.embed?.updateScreenShareState(!1),this.config?.onScreenShareStateChange?.(!1))},toggleScreenShare:async()=>{await this.handleScreenShareToggle()},get isScreenSharing(){return e.screenShareController?.isSharing()??!1},get isScreenShareSupported(){return Jt()&&(pt.getState().app.features.screenShare?.enabled??!1)},get sessionId(){return pt.getState().avatar.sessionId},muteAudio:()=>{this.embed?.setAudioMuted(!0),Mt("mute","avatar_audio")},unmuteAudio:()=>{this.embed?.setAudioMuted(!1),Mt("unmute","avatar_audio")},get isAudioMuted(){return e.embed?.getAudioMuted()??!1},setAudioVolume:e=>{this.embed?.setAudioVolume(e)},getAudioVolume:()=>this.embed?.getAudioVolume()??1,startFaceTracking:async()=>{const e=pt.getState().app.features.faceTracking;if(!e?.enabled)throw new i("Face tracking is not enabled. Set features.faceTracking.enabled = true.",{code:c.FEATURE_DISABLED});this.faceTrackingController||(this.faceTrackingController=function(e={},t={}){const n=Math.min(Math.max(e.fps??15,1),30),o=e.talkingThreshold??.015,a=e.videoWidth??640,i=e.videoHeight??480,r=1e3/n;let d=null,l=null,p=null,u=null,h=null,f=null,m=!1,g=!1,v=0;const b=function(e=5){let t=[];return{push:n=>(t.push(n),t.length>e&&t.shift(),t.reduce((e,t)=>e+t,0)/t.length),reset(){t=[]}}}(e.smoothingFrames??5);function y(e,n){const o=new s(e,n);ft.error("FaceTracking:",e),t.onError?.(o)}function _(){p||(p=document.createElement("canvas")),u||(u=p.getContext("2d"))}function w(e){m&&(e-v>=r&&(v=e,async function(){if(l&&h&&!(l.readyState<4))try{_(),p.width=l.videoWidth,p.height=l.videoHeight,u.drawImage(l,0,0);const e=await h.estimateFaces(p);if(e&&e.length>0){const n=e[0].keypoints,r=l.videoWidth||a,s=l.videoHeight||i,c=n.map(e=>({x:e.x/r,y:e.y/s,z:e.z??0})),d=function(e,t,n){if(!e||0===e.length)return null;const o=e[13],a=e[14],i=e[61],r=e[291];if(!(o&&a&&i&&r))return null;const s=Math.abs(o.y-a.y),c=Math.abs(r.x-i.x),d=s/Math.max(c,1),l=t||640,p=n||480;return{mouthLandmarks:{topLip:{x:o.x/l,y:o.y/p},bottomLip:{x:a.x/l,y:a.y/p},leftCorner:{x:i.x/l,y:i.y/p},rightCorner:{x:r.x/l,y:r.y/p}},openingRatio:d}}(n,r,s);let p=!1;d&&(p=b.push(d.openingRatio)>o),t.onData?.({landmarks:c,mouthLandmarks:d?.mouthLandmarks??null,isTalking:p})}else t.onData?.(null)}catch(e){ft.error("FaceTracking: detection error",e)}}()),f=requestAnimationFrame(w))}function S(){m=!1,null!==f&&(cancelAnimationFrame(f),f=null),d&&(d.getTracks().forEach(e=>e.stop()),d=null),l&&(l.srcObject=null,l=null),b.reset(),ft.info("FaceTracking:","Stopped (model kept for restart)")}return{start:async function(){g?y("Cannot start: face tracking service has been destroyed.",c.DETECTION_FAILED):m||(ft.info("FaceTracking:","Starting face tracking..."),await async function(){try{d=await navigator.mediaDevices.getUserMedia({video:{width:a,height:i,facingMode:"user"},audio:!1})}catch(e){throw e instanceof Error?"NotAllowedError"===e.name?y("Camera permission denied. Please allow camera access for face tracking.",c.CAMERA_PERMISSION_DENIED):"NotFoundError"===e.name?y("No camera found. Please ensure a camera is connected.",c.CAMERA_NOT_FOUND):y(`Camera error: ${e.message}`,c.CAMERA_PERMISSION_DENIED):y("Failed to access camera for face tracking.",c.CAMERA_PERMISSION_DENIED),e}l=document.createElement("video"),l.setAttribute("autoplay",""),l.setAttribute("playsinline",""),l.setAttribute("muted",""),l.muted=!0,l.srcObject=d,await new Promise((e,t)=>{if(!l)return t();l.onloadedmetadata=()=>{l.play().then(e).catch(t)}})}(),h||await async function(){try{const[e,t]=await Promise.all([import("@tensorflow/tfjs"),import("@tensorflow-models/face-landmarks-detection")]);await e.ready();const n=t.SupportedModels.MediaPipeFaceMesh;h=await t.createDetector(n,{runtime:"tfjs",maxFaces:1,refineLandmarks:!0}),ft.info("FaceTracking:","MediaPipe Face Mesh model loaded")}catch(e){throw y("Failed to load face detection model.",c.MODEL_LOAD_FAILED),e}}(),_(),b.reset(),m=!0,v=0,f=requestAnimationFrame(w),ft.info("FaceTracking:",`Detection running at ${n} FPS`))},stop:S,isActive:function(){return m},destroy:function(){if(S(),h){try{h.dispose()}catch{}h=null}p=null,u=null,g=!0,ft.info("FaceTracking:","Destroyed")}}}({fps:e.fps,talkingThreshold:e.talkingThreshold},{onData:e=>{this.config?.onFaceTrackingData?.(e)},onError:e=>{this.config?.onFaceTrackingError?.(e),this.config?.onError?.(e)}})),await this.faceTrackingController.start()},stopFaceTracking:()=>{this.faceTrackingController?.stop()}}}}Object.defineProperty(en,"instance",{enumerable:!0,configurable:!0,writable:!0,value:null});const tn=en.getInstance();return"undefined"!=typeof window&&(window.napsterCompanionApiSDK=tn),tn});
|