1"use strict";(self.webpackChunkwebclient_webpack=self.webpackChunkwebclient_webpack||[]).push([[5519],{55519(V,D,g){g.r(D),g.d(D,{initHandler:()=>X});var i=g(6488),A=g(71985),p=g(18530),L=g(57786),O=g(77498),T=g(96354);class v{static rawUsageFrom(e,t){return(e<<16|t)>>>0}static usagePageFromRaw(e){return e>>>16}static usageFromRaw(e){return e<<16>>>16}}class B{constructor(e){this.devices=new Map,this.deviceInputSubscriptions=new Map,this.onHidInput=new p.B,this.onGetFeatureReportResponse=new p.B;const t=new p.B;this.deviceAdded=t;const s=new p.B;this.deviceRemoved=s,e.deviceAdded.subscribe(o=>{if(!this.devices.has(o.id)){this.devices.set(o.id,o);const r=o.inputHandler.inputReports.pipe((0,T.T)(n=>new i.W(o.id,v.usagePageFromRaw(n.usage),v.usageFromRaw(n.usage),n.value))).subscribe(n=>this.onHidInput.next(n));this.deviceInputSubscriptions.set(o.id,r),t.next(o)}}),e.deviceRemoved.subscribe(o=>{var r;const n=this.devices.get(o);n&&(this.devices.delete(o),null===(r=this.deviceInputSubscriptions.get(o))||void 0===r||r.unsubscribe(),this.deviceInputSubscriptions.delete(o),s.next(n))})}sendOutputUsage(e,t,s,o){var r,n;const a=v.rawUsageFrom(t,s);return null!==(n=null===(r=this.devices.get(e))||void 0===r?void 0:r.outputHandler.sendOutputUsage(a,o))&&void 0!==n?n:Promise.resolve()}setFeatureUsage(e,t,s,o){var r;const n=v.rawUsageFrom(t,s);null===(r=this.devices.get(e))||void 0===r||r.featureHandler.setFeatureUsage(n,o)}getFeatureUsage(e,t,s,o){return(0,i._)(this,void 0,void 0,function*(){var r;const n=v.rawUsageFrom(s,o),a=yield null===(r=this.devices.get(e))||void 0===r?void 0:r.featureHandler.getFeatureUsage(n);void 0!==a&&this.onGetFeatureReportResponse.next(new i.a(t,a))})}}class k{constructor(e){this.data=new Uint8Array(e)}get buffer(){return new DataView(this.data.buffer)}getBits(e,t){if(t>8*this.data.length-e)throw new Error("Not enough bits to read from the buffer");let s=e,o=0;for(let r=0;r<t;){const a=7&s,d=this.data[s>>3],u=Math.min(t-r,8-a);o|=(d>>a&~(255<<u))<<r,s+=u,r+=u}return o>>>0}setBits(e,t,s){if(s>8*this.data.length-e)throw new Error("Not enough bits to read from the buffer");let o=e,r=t;for(let n=0;n<s;){const d=7&o,u=o>>3,R=Math.min(s-n,8-d),c=~(255<<R),l=r&c;r>>=R,this.data[u]=this.data[u]&~(c<<d)|l<<d,o+=R,n+=R}}}class U{constructor(e,t){this.device=e,this.inputReportDescriptors=t;const s=new Map;this.inputReportDescriptors.forEach(r=>{r.usages.forEach((n,a)=>{s.set(a,[0])})});const o=new p.B;this.inputReports=o,this.device.oninputreport=r=>{if(r.currentTarget!==this.device)return;const n=this.inputReportDescriptors.get(r.reportId);if(!n)return;const a=new k(r.data.buffer);let d=Array.from(n.usages.entries(),u=>U.makeWebHidInputReport(a,u));9!==r.reportId&&(d=d.filter(u=>U.compareReportToCachedValue(u,s)),d.forEach(u=>{s.set(u.usage,u.value)})),d.forEach(u=>{o.next(u)})}}static makeWebHidInputReport(e,[t,s]){let o=s.offset,r=s.size*s.count,n=[];for(;r>0;)n.push(e.getBits(o,Math.min(r,8))),o+=8,r-=8;return n=s.onInput(n),new i.I.UsageReport(t,n)}static compareReportToCachedValue(e,t){const s=t.get(e.usage);return!s||s.length!==e.value.length||s.some((o,r)=>e.value[r]!==o)}}class C{constructor(e){this.report=e}reportSizeInBits(){return this.report.fullReportSize}reportSizeInBytes(){return Math.ceil(this.reportSizeInBits()/8)}createBitViewIfNeeded(){if(!this.bitView){const e=this.reportSizeInBytes(),t=new ArrayBuffer(e);this.bitView=new k(t)}return this.bitView}getUsageInformationOrThrow(e){if(!this.report.usages.has(e))throw new i.J(`Unable to write usage (0x${e.toString(16).padStart(8,"0")}). It is not known by the device.`,i.E.UNEXPECTED_ERROR);return this.report.usages.get(e)}writeUsage(e,t){const s=this.getUsageInformationOrThrow(e);let o=this.createBitViewIfNeeded();if(!s.absolute){const a=function(d){const u=new ArrayBuffer(d.byteLength);return new Uint8Array(u).set(new Uint8Array(d.buffer)),u}(o.buffer);o=new k(a)}let r=s.offset,n=s.size*s.count;return t.forEach(a=>{o.setBits(r,a,n),r+=8,n-=8}),new Uint8Array(o.buffer.buffer)}}class N{constructor(e,t,s){this.device=e,this.outputReports=t,this.outputUsages=s,this.outputCacheByReportId=new Map}getReportIdForUsage(e){if(!this.outputUsages.has(e))throw new i.J(`Unknown usagePage: 0x${e.toString(16).padStart(8,"0")}.`,i.E.UNEXPECTED_ERROR);return this.outputUsages.get(e)}getReportLayoutForReportId(e){if(!this.outputReports.has(e))throw new i.J(`Unknown reportId: ${e}.`,i.E.UNEXPECTED_ERROR);return this.outputReports.get(e)}getUsageInReportForUsage(e){const t=this.getReportIdForUsage(e),s=this.getReportLayoutForReportId(t);if(!s.usages.has(e))throw new i.J(`Unknown rawUsage inside ReportLayout: ${e}.`,i.E.UNEXPECTED_ERROR);return s.usages.get(e)}getOrCreateCacheForReportId(e){if(!this.outputCacheByReportId.has(e)){const t=this.getReportLayoutForReportId(e),s=new C(t);this.outputCacheByReportId.set(e,s)}return this.outputCacheByReportId.get(e)}sendOutputUsage(e,t){return(0,i._)(this,void 0,void 0,function*(){const s=this.getReportIdForUsage(e),o=this.getOrCreateCacheForReportId(s),r=this.getUsageInReportForUsage(e).onOutput(t),n=o.writeUsage(e,r);try{yield this.device.sendReport(s,n)}catch(a){throw"NotAllowedError"===a.name?new i.J("The request could not be sent to the device. The device may have been disconnected.",i.E.DEVICE_ERROR):a}})}}class _{constructor(e=new Map,t=0){this.usages=e,this.fullReportSize=t}}class x{constructor(e,t,s,o){this.offset=e,this.size=t,this.count=s,this.absolute=o}onInput(e){return e}onOutput(e){return e}}class m{constructor(e,t,s,o,r){this.offset=e,this.size=t,this.count=s,this.absolute=o,this.rangeIndex=r}onInput(e){if(e.length>1)throw new i.J(`Usages of type ${m.name}
1 should not hold more than 1 byte of information.`,i.E.UNEXPECTED_ERROR);return e[0]===this.rangeIndex?[1]:[0]}onOutput(e){if(e.length>1)throw new i.J(`Usages of type ${m.name} should not hold more than 1 byte of information.`,i.E.UNEXPECTED_ERROR);return e[0]>0?[this.rangeIndex]:e}}class E{constructor(e){const t=new Map;this.buildReportLayouts(e.collections,"input",t),this.inputReports=t,this.inputUsages=E.buildUsageMap(t);const s=new Map;this.buildReportLayouts(e.collections,"output",s),this.outputReports=s,this.outputUsages=E.buildUsageMap(s);const o=new Map;this.buildReportLayouts(e.collections,"feature",o),this.featureReports=o,this.featureUsages=E.buildUsageMap(o)}static buildUsageMap(e){const t=new Map;return e.forEach((s,o)=>{s.usages.forEach((r,n)=>{t.set(n,o)})}),t}buildReportLayouts(e,t,s){e.forEach(o=>{var r;null===(r=E.reportsOfType(o,t))||void 0===r||r.forEach(n=>{var a;const d=n.reportId;s.has(d)||s.set(d,new _);const u=s.get(d);let R=0;null===(a=n.items)||void 0===a||a.forEach(c=>{let l=c.usages;if(c.isRange){l=[];for(let w=c.usageMinimum;w<=c.usageMaximum;w+=1)l.push(w)}let f,y=R;if(c.isRange&&c.isArray&&(f=1),l.length>0&&l.filter(w=>u.usages.has(w)).length===l.length)return;l.forEach(w=>{let M;const P=l.length>1?c.reportCount/l.length:c.reportCount;M=f?new m(y,c.reportSize,P,c.isAbsolute,f):new x(y,c.reportSize,P,c.isAbsolute),u.usages.set(w,M),f?f+=1:y+=c.reportSize});const F=c.reportCount*c.reportSize;u.fullReportSize+=F,R+=F})}),o.children&&this.buildReportLayouts(o.children,t,s)})}static reportsOfType(e,t){if("input"===t)return e.inputReports;if("output"===t)return e.outputReports;if("feature"===t)return e.featureReports;throw new i.J(`Unexpected report type: ${t}!`,i.E.UNEXPECTED_ERROR)}}class H{constructor(e,t,s){this.device=e,this.featureReports=t,this.featureUsages=s,this.outputCacheByReportId=new Map}getReportIdForUsage(e){if(!this.featureUsages.has(e))throw new i.J(`Unknown usagePage: 0x${e.toString(16).padStart(8,"0")}.`,i.E.UNEXPECTED_ERROR);return this.featureUsages.get(e)}getReportLayoutForReportId(e){if(!this.featureReports.has(e))throw new i.J(`Unknown reportId: ${e}.`,i.E.UNEXPECTED_ERROR);return this.featureReports.get(e)}getUsageInReportForUsage(e){const t=this.getReportIdForUsage(e),s=this.getReportLayoutForReportId(t);if(!s.usages.has(e))throw new i.J(`Unknown rawUsage inside ReportLayout: ${e}.`,i.E.UNEXPECTED_ERROR);return s.usages.get(e)}getOrCreateCacheForReportId(e){if(!this.outputCacheByReportId.has(e)){const t=this.getReportLayoutForReportId(e),s=new C(t);this.outputCacheByReportId.set(e,s)}return this.outputCacheByReportId.get(e)}getFeatureUsage(e){return(0,i._)(this,void 0,void 0,function*(){const t=this.getReportIdForUsage(e),s=yield this.device.receiveFeatureReport(t),o=this.getUsageInReportForUsage(e),r=[];for(let n=1;n<=Math.ceil(o.size/8);n+=1)r.push(s.getUint8(n));return r})}setFeatureUsage(e,t){return(0,i._)(this,void 0,void 0,function*(){const s=this.getReportIdForUsage(e),o=this.getOrCreateCacheForReportId(s),r=this.getUsageInReportForUsage(e).onOutput(t),n=o.writeUsage(e,r);yield this.device.sendFeatureReport(s,n)})}}class z{constructor(e,t,s,o){this.name=e,this.vid=t,this.pid=s,this.id=o.sessionId;const r=new E(o);this.inputReports=r.inputReports,this.outputReports=r.outputReports,this.featureReports=r.featureReports,this.inputHandler=new U(o,r.inputReports),this.outputHandler=new N(o,r.outputReports,r.outputUsages),this.featureHandler=new H(o,r.featureReports,r.featureUsages)}}class I{constructor(e,t){this.hid=e,this.broadcastChannel=t,this.deviceAddedSubject=new p.B,this.deviceAdded=this.deviceAddedSubject,this.deviceRemovedSubject=ne
1w p.B,this.deviceRemoved=this.deviceRemovedSubject}setupListeners(){this.hid.onconnect=e=>this.onConnect(e),this.hid.ondisconnect=e=>this.onDisconnect(e),this.broadcastChannel.onmessage=()=>this.getPairedDevices()}addNewDevice(e){return(0,i._)(this,void 0,void 0,function*(){if(I.hasGeneratedDeviceId(e))return;I.getOrGenerateDeviceId(e);const t=new z(e.productName,e.vendorId,e.productId,e);e.opened||(yield e.open()),this.deviceAddedSubject.next(t)})}onConnect(e){return(0,i._)(this,void 0,void 0,function*(){setTimeout(()=>(0,i._)(this,void 0,void 0,function*(){yield this.addNewDevice(e.device)}),1e3)})}onDisconnect(e){const t=I.getOrGenerateDeviceId(e.device);this.deviceRemovedSubject.next(t)}getPairedDevices(){return(0,i._)(this,void 0,void 0,function*(){(yield this.hid.getDevices()).filter(e=>e.vendorId===i.b.VENDOR_ID).forEach(e=>(0,i._)(this,void 0,void 0,function*(){yield this.addNewDevice(e)}))})}static hasGeneratedDeviceId(e){return void 0!==e.sessionId}static getOrGenerateDeviceId(e){if(!I.hasGeneratedDeviceId(e)){const t=new i.U(4).toString();return e.sessionId=t,t}return e.sessionId}}class W{constructor(e,t,s,o,r){this.usagePage=e,this.usage=t,this.valueType=s,this.reportType=o,this.reportSize=r}}class b{constructor(e){this.deviceManagement=e,this.events=new p.B,this.setupDeviceHandler()}setupDeviceHandler(){this.deviceManagement.deviceAdded.subscribe(e=>{this.events.next({event:"attach",id:e.id,vid:e.vid,pid:e.pid,name:e.name,serialNumber:e.id,descriptor:b.generateDescriptors(e)})}),this.deviceManagement.deviceRemoved.subscribe(e=>{this.events.next({event:"detach",id:e.id})}),this.deviceManagement.onHidInput.subscribe(e=>{this.events.next({event:"hid-input",id:e.deviceId,usagePage:e.usagePage,usage:e.usage,value:1===e.value.length?e.value[0]:e.value})}),this.deviceManagement.onGetFeatureReportResponse.subscribe(e=>{this.events.next({event:"response-hid-feature",token:e.token,value:1===e.value.length?e.value[0]:e.value})})}static generateDescriptors(e){let t=b.convertReportLayoutsToDescriptors(e.inputReports,"input");return t=t.concat(b.convertReportLayoutsToDescriptors(e.outputReports,"output")),t=t.concat(b.convertReportLayoutsToDescriptors(e.featureReports,"feature")),t}static convertReportLayoutsToDescriptors(e,t){const s=[];return e.forEach(o=>{o.usages.forEach((r,n)=>{const a=v.usagePageFromRaw(n);65280===a&&"output"===t||s.push(new W(a,v.usageFromRaw(n),r.absolute?"absolute":"relative",t,Math.ceil(r.size*r.count/8)))})}),s}}class G{constructor(e,t,s){this.deviceManagement=e,this.callLockManagement=t,this.logger=s,this.gnpLockAcquired=new p.B,this.callLockAcquired=new p.B,this.softphoneInFocus=new p.B,this.events=(0,L.h)(this.gnpLockAcquired.pipe((0,O.c)(0)),this.callLockAcquired.pipe((0,O.c)(0)),this.softphoneInFocus)}onNewSdkInput(e){return(0,i._)(this,void 0,void 0,function*(){if(!e.action)throw new i.J("Provided input has no action property.",i.E.UNEXPECTED_ERROR);switch(e.action){case"hid-output":{const t=Array.isArray(e.value)?e.value:[e.value];yield this.deviceManagement.sendOutputUsage(e.id,e.usagePage,e.usage,t);break}case"request-hid-feature":this.deviceManagement.getFeatureUsage(e.id,e.token,e.usagePage,e.usage);break;case"set-hid-feature":{const t=Array.isArray(e.value)?e.value:[e.value];this.deviceManagement.setFeatureUsage(e.id,e.usagePage,e.usage,t);break}case"request-gnp-lock":this.gnpLockAcquired.next({event:"response-gnp-lock",token:e.token}),(0,i.l)("GNP lock requested with WebHID backend. This should not happen!",this.logger,i.L.ERROR,i.S.NATIVE_CONSOLE);break;case"release-gnp-lock":break;case"request-call-lock":this.callLockManagement.tryAcquireCallLock(e.id).then(t=>{this.callLockAcquired.next({event:"response-call-lock",id:e.id,acquired:t})});break;case"release-call-lock":this.callLockManagement.releaseCallLock(e.id);break;case"set-softphone-info":this.softphoneInFocus.next({event:"softphone-in-focus",infocus:!1}),this.softphoneInFocus.complete();break;default:throw new i.J(`Provided action is not recognized - ${e.action}.`,i.E.UNEXPECTED_ERROR)}})}}class J{constructor(e,t,s){this.navigatorLocks=e,this.logger=s,this.releaseGlobalLock=null,this.localLockedDevices=new Set,t.deviceRemoved.subscribe(o=>{this.localLockedDevices.has(o.id)&&this.releaseCallLock(o.id)})}tryAcquireCallLock(e){return(0,i._)(this,void 0,void 0,function*(){return!(yield this.checkWebL
1ocksSupport())||(this.localLockedDevices.size>0&&!this.localLockedDevices.has(e)?(this.localLockedDevices.add(e),!0):new Promise(t=>{this.navigatorLocks.request("jabra-call-lock",{ifAvailable:!0},s=>s?(this.localLockedDevices.add(e),t(!0),new Promise(o=>{this.releaseGlobalLock=o})):(t(!1),Promise.resolve()))}))})}releaseCallLock(e){this.localLockedDevices.delete(e),this.releaseGlobalLock&&0===this.localLockedDevices.size&&this.releaseGlobalLock()}checkWebLocksSupport(){return(0,i._)(this,void 0,void 0,function*(){return!!(yield this.navigatorLocks.query().catch(()=>{(0,i.l)("WebLocks unsupported. The cross-tab call lock is disabled.",this.logger,i.L.WARNING)}))})}}class j{constructor(e,t,s,o){this.scanner=e,this.deviceEventHandler=t,this.sdkInputEventHandler=s,this.logger=o,this.readyEvent=new p.B,this.events=new A.c,this.events=(0,L.h)(this.readyEvent,this.deviceEventHandler.events,this.sdkInputEventHandler.events)}start(){this.readyEvent.next({event:"ready",version:null,jabraDirectInstalled:!1}),this.readyEvent.complete(),this.scanner.getPairedDevices(),this.scanner.setupListeners()}sendMessage(e){var t,s;return null!==(s=null===(t=this.sdkInputEventHandler)||void 0===t?void 0:t.onNewSdkInput(e))&&void 0!==s?s:Promise.resolve()}}function X(h){if(typeof window>"u")throw new i.J("WebHID is not supported outside of a browser environment.",i.E.INIT_ERROR);if(void 0===window.navigator||void 0===window.navigator.hid)throw new i.J("WebHID is not supported on this platform/browser.",i.E.INIT_ERROR);if(void 0===window.navigator.locks)throw new i.J("WebLocks is not supported on this platform/browser.",i.E.INIT_ERROR);const e=window.navigator.hid,t=window.navigator.locks,s=new BroadcastChannel(i.b.PAIRING_CHANNEL),o=new I(e,s),r=new B(o),n=new b(r),a=new G(r,new J(t,r,h));return new j(o,n,a,h)}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.