%PDF- %PDF-
Direktori : /home1/dimen328/.trash/espace/verification/index/ |
Current File : //home1/dimen328/.trash/espace/verification/index/sharer.min.js.tВlВchargement |
!function(){"use strict";const e="color:red;font-weight:bold",t="color:white;background:#6495ed",n="color:#555;font-style:italic",o="color:#6495ed;font-weight:bold";class i{constructor(e,t,n){this.appName=e,this.className=t,this.level=n,this.saveToBuffer=!1,this.loggerBuffer=[],this.errorBuffer=[],n?this.setLogLevel(n):this.saveToBuffer=!0}getFormattedMessage(e){return`%c${this.appName}:${this.className}%c ${e}`}info(e,...o){const i=[this.getFormattedMessage(e),t,n].concat(o);this.saveToBuffer?this.loggerBuffer.push(i):"ERROR"!==this.level&&console.log(...i)}debug(e,...t){const i=[this.getFormattedMessage(e),o,n].concat(t);this.saveToBuffer?this.loggerBuffer.push(i):"DEBUG"===this.level&&console.log(...i)}error(t,...n){const o=[this.getFormattedMessage(t),e,e].concat(n);this.saveToBuffer?this.errorBuffer.push(o):console.warn(...o)}setLogLevel(e){this.level=e,this.saveToBuffer=!1;for(const e of this.loggerBuffer)console.log(...e);this.loggerBuffer=[];for(const e of this.errorBuffer)console.warn(e);this.errorBuffer=[]}}function s(e,t){return function(e,t,n){const o=new i(e,t,n),s=o.debug.bind(o);return s.info=o.info.bind(o),s.error=o.error.bind(o),s.setLogLevel=o.setLogLevel.bind(o),s}("cobrowse",e,t)}function r(e,t,n,o){return new(n||(n=Promise))((function(i,s){function r(e){try{l(o.next(e))}catch(e){s(e)}}function a(e){try{l(o.throw(e))}catch(e){s(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(r,a)}l((o=o.apply(e,t||[])).next())}))}class a{constructor(e){this.eventTarget=new EventTarget,this.registeredListeners=new Set,this.log=s("pub-sub",e)}notify(e,t){this.log(`dispatching ${e}`,t),this.eventTarget.dispatchEvent(new CustomEvent(e,{detail:t}))}listen(e,t){this.log(`adding listener to ${e}`),this.addListener(e,t)}listenForever(e,t){this.log(`adding per-page listener to ${e}`),this.addListener(e,t,{forever:!0})}addListener(e,t,n={forever:!1}){const o=function(e){const n=e.detail;return t({data:n})};!1===n.forever&&this.registeredListeners.add({name:e,listener:o}),this.eventTarget.addEventListener(e,o)}clearEventListeners(){this.registeredListeners.forEach((e=>{this.eventTarget.removeEventListener(e.name,e.listener)})),this.registeredListeners.clear()}}function l(e,t){const n=new Event(t);e.dispatchEvent(n)}const d={replayTyping:function(e,t){l(e,"keydown"),l(e,"keypress"),e.value=t,l(e,"input"),l(e,"keyup")},replayClick:function(e){l(e,"touchstart"),l(e,"touchend"),l(e,"mousedown"),l(e,"mouseup"),e.click()},replayMouseEnter:function(e){l(e,"mouseenter")},replayMouseLeave:function(e){l(e,"mouseleave")},replayMouseOver:function(e){l(e,"mouseover")},replayMouseOut:function(e){l(e,"mouseout")},replaySelectChange:function(e,t){e.value=t,l(e,"change")},replayFocusIn:function(e){l(e,"focusin")},replayFocusOut:function(e){l(e,"focusout")},replayChange:function(e){l(e,"change")},replayWheel:function(e){const t=new WheelEvent("wheel",{bubbles:!0,cancelable:!0,deltaY:0-e});document.body.dispatchEvent(t)}};class c{constructor(e,t,n){var o,i;this.serviceDiscovery=t,this.l10n=n,this.modules=new Map,this.env=(null===(i=null===(o=document.currentScript)||void 0===o?void 0:o.getAttribute("src"))||void 0===i?void 0:i.includes("localhost:8081"))?"localhost":e.env,this.logLevel=e.logLevel||"ERROR",this.log=this.createLogger("core"),this.pubsub=new a(this.logLevel),this.events=d,this.network=this.getNetwork()}start(e){if(this.modules.has(e)){const t=this.modules.get(e);(null==t?void 0:t.instance)&&t.instance.init()}}stop(e){if(this.modules.has(e)){const t=this.modules.get(e);(null==t?void 0:t.instance)&&t.instance.destroy()}}startAll(){var e;for(const t of this.modules.values())null===(e=t.instance)||void 0===e||e.init()}stopAll(){var e;for(const t of this.modules.values())null===(e=t.instance)||void 0===e||e.destroy()}deregisterAll(){this.modules=new Map}getRootUIElement(){return document.body}getWindow(){return window}getDOMRoot(){throw new Error("getDOMRoot() not implemented")}getWorkRootUIElement(){throw new Error("getWorkRootUIElement() not implemented")}getWorkWindow(){}getWorkFrame(){throw new Error("getWorkFrame() not implemented")}getPrimaryColor(){throw new Error("getPrimaryColor() not implemented")}exposeGlobalVariable(e,t){window[e]=t}reloadWindow(){return this.getWindow().location.reload()}createLogger(e){return s(e,this.logLevel)}setDeploymentOptions(e){const t=Object.assign({},e);if(null==t||delete t.agentName,!("allowAgentControl"in e)||!("allowedDomains"in e)||!("maskSelectors"in e))throw this.log(`invalid deploymentOptions format: ${JSON.stringify(t)}`),new Error("deploymentOptions do not look like deployment options");this.log(`deploymentOptions set: ${JSON.stringify(t)}`),this.deploymentOptions=e}getDeploymentOptions(){if(!this.deploymentOptions)throw new Error("deploymentOptions requested from core before init");return this.deploymentOptions}getAssetsURL(){return this.serviceDiscovery.getUri("staticAssets")}getFontsURL(){return this.serviceDiscovery.getUri("fonts")}loadi18n(){return r(this,void 0,void 0,(function*(){try{const e=yield this.l10n.loadJsLocale();this.i18n=e.cobrowse}catch(e){throw new Error("Could not fetch localization, aborting cobrowse")}}))}geti18n(){if(!this.i18n)throw new Error("Localization not loaded");return this.i18n}getLang(){if(!this.l10n)throw new Error("Localization not loaded");return this.l10n.lang}getDeploymentId(){throw new Error("getDeploymentId not implemented")}sendMessageToWebDirectory(e){this.getWindow().parent.postMessage({protocol:"purecloud-client-apps",action:e,protocolAgentName:"cobrowse-next",protocolAgentVersion:"1.0.0"},"*")}}if(void 0===MutationObserver)throw console.error("DOM Mutation Observers are required."),console.error("https://developer.mozilla.org/en-US/docs/DOM/MutationObserver"),Error("DOM Mutation Observers are required");class h{constructor(){this.nodes=[],this.values=[]}isIndex(e){return+e==e>>>0}nodeId(e){let t=e[h.ID_PROP];return t||(t=e[h.ID_PROP]=h.nextId_++),t}set(e,t){const n=this.nodeId(e);this.nodes[n]=e,this.values[n]=t}get(e){const t=this.nodeId(e);return this.values[t]}has(e){return this.nodeId(e)in this.nodes}delete(e){const t=this.nodeId(e);delete this.nodes[t],this.values[t]=void 0}keys(){const e=[];for(const t in this.nodes)this.isIndex(t)&&e.push(this.nodes[t]);return e}}var u;h.ID_PROP="__mutation_summary_node_map_id__",h.nextId_=1,function(e){e[e.STAYED_OUT=0]="STAYED_OUT",e[e.ENTERED=1]="ENTERED",e[e.STAYED_IN=2]="STAYED_IN",e[e.REPARENTED=3]="REPARENTED",e[e.REORDERED=4]="REORDERED",e[e.EXITED=5]="EXITED"}(u||(u={}));class g{constructor(e,t=!1,n=!1,o=!1,i=null,s=!1,r=null,a=null){this.node=e,this.childList=t,this.attributes=n,this.characterData=o,this.oldParentNode=i,this.added=s,this.attributeOldValues=r,this.characterDataOldValue=a,this.isCaseInsensitive=this.node.nodeType===Node.ELEMENT_NODE&&this.node instanceof HTMLElement&&this.node.ownerDocument instanceof HTMLDocument}getAttributeOldValue(e){if(this.attributeOldValues)return this.isCaseInsensitive&&(e=e.toLowerCase()),this.attributeOldValues[e]}getAttributeNamesMutated(){const e=[];if(!this.attributeOldValues)return e;for(const t in this.attributeOldValues)e.push(t);return e}attributeMutated(e,t){this.attributes=!0,this.attributeOldValues=this.attributeOldValues||{},e in this.attributeOldValues||(this.attributeOldValues[e]=t)}characterDataMutated(e){this.characterData||(this.characterData=!0,this.characterDataOldValue=e)}removedFromParent(e){this.childList=!0,this.added||this.oldParentNode?this.added=!1:this.oldParentNode=e}insertedIntoParent(){this.childList=!0,this.added=!0}getOldParent(){if(this.childList){if(this.oldParentNode)return this.oldParentNode;if(this.added)return null}return this.node.parentNode}}class p{constructor(){this.added=new h,this.removed=new h,this.maybeMoved=new h,this.oldPrevious=new h,this.moved=void 0}}class m extends h{constructor(e,t){super(),this.rootNode=e,this.reachableCache=void 0,this.wasReachableCache=void 0,this.anyParentsChanged=!1,this.anyAttributesChanged=!1,this.anyCharacterDataChanged=!1;for(let e=0;e<t.length;e++){const i=t[e];switch(i.type){case"childList":this.anyParentsChanged=!0;for(var n=0;n<i.removedNodes.length;n++){var o=i.removedNodes[n];this.getChange(o).removedFromParent(i.target)}for(n=0;n<i.addedNodes.length;n++){o=i.addedNodes[n];this.getChange(o).insertedIntoParent()}break;case"attributes":this.anyAttributesChanged=!0,this.getChange(i.target).attributeMutated(i.attributeName,i.oldValue);break;case"characterData":this.anyCharacterDataChanged=!0,this.getChange(i.target).characterDataMutated(i.oldValue)}}}getChange(e){let t=this.get(e);return t||(t=new g(e),this.set(e,t)),t}getOldParent(e){const t=this.get(e);return t?t.getOldParent():e.parentNode}getIsReachable(e){if(e===this.rootNode)return!0;if(!e)return!1;this.reachableCache=this.reachableCache||new h;let t=this.reachableCache.get(e);return void 0===t&&(t=this.getIsReachable(e.parentNode),this.reachableCache.set(e,t)),t}getWasReachable(e){if(e===this.rootNode)return!0;if(!e)return!1;this.wasReachableCache=this.wasReachableCache||new h;let t=this.wasReachableCache.get(e);return void 0===t&&(t=this.getWasReachable(this.getOldParent(e)),this.wasReachableCache.set(e,t)),t}reachabilityChange(e){return this.getIsReachable(e)?this.getWasReachable(e)?u.STAYED_IN:u.ENTERED:this.getWasReachable(e)?u.EXITED:u.STAYED_OUT}}class f{constructor(e,t,n,o,i){this.rootNode=e,this.mutations=t,this.selectors=n,this.calcReordered=o,this.calcOldPreviousSibling=i,this.treeChanges=new m(e,t),this.entered=[],this.exited=[],this.stayedIn=new h,this.visited=new h,this.childListChangeMap=void 0,this.characterDataOnly=void 0,this.matchCache=void 0,this.processMutations()}processMutations(){if(!this.treeChanges.anyParentsChanged&&!this.treeChanges.anyAttributesChanged)return;const e=this.treeChanges.keys();for(let t=0;t<e.length;t++)this.visitNode(e[t],void 0)}visitNode(e,t){if(this.visited.has(e))return;this.visited.set(e,!0);const n=this.treeChanges.get(e);let o=t;if((n&&n.childList||null==o)&&(o=this.treeChanges.reachabilityChange(e)),o!==u.STAYED_OUT){if(this.matchabilityChange(e),o===u.ENTERED)this.entered.push(e);else if(o===u.EXITED)this.exited.push(e),this.ensureHasOldPreviousSiblingIfNeeded(e);else if(o===u.STAYED_IN){let t=u.STAYED_IN;n&&n.childList&&(n.oldParentNode!==e.parentNode?(t=u.REPARENTED,this.ensureHasOldPreviousSiblingIfNeeded(e)):this.calcReordered&&this.wasReordered(e)&&(t=u.REORDERED)),this.stayedIn.set(e,t)}if(o!==u.STAYED_IN)for(let t=e.firstChild;t;t=t.nextSibling)this.visitNode(t,o)}}ensureHasOldPreviousSiblingIfNeeded(e){if(!this.calcOldPreviousSibling)return;this.processChildlistChanges();let t=e.parentNode;const n=this.treeChanges.get(e);n&&n.oldParentNode&&(t=n.oldParentNode);let o=this.childListChangeMap.get(t);o||(o=new p,this.childListChangeMap.set(t,o)),o.oldPrevious.has(e)||o.oldPrevious.set(e,e.previousSibling)}getChanged(e,t,n){this.selectors=t,this.characterDataOnly=n;for(var o=0;o<this.entered.length;o++){var i=this.entered[o];(r=this.matchabilityChange(i))!==u.ENTERED&&r!==u.STAYED_IN||e.added.push(i)}const s=this.stayedIn.keys();for(o=0;o<s.length;o++){i=s[o];if((r=this.matchabilityChange(i))===u.ENTERED)e.added.push(i);else if(r===u.EXITED)e.removed.push(i);else if(r===u.STAYED_IN&&(e.reparented||e.reordered)){const t=this.stayedIn.get(i);e.reparented&&t===u.REPARENTED?e.reparented.push(i):e.reordered&&t===u.REORDERED&&e.reordered.push(i)}}for(o=0;o<this.exited.length;o++){var r;i=this.exited[o];(r=this.matchabilityChange(i))!==u.EXITED&&r!==u.STAYED_IN||e.removed.push(i)}}getOldParentNode(e){const t=this.treeChanges.get(e);if(t&&t.childList)return t.oldParentNode?t.oldParentNode:null;const n=this.treeChanges.reachabilityChange(e);if(n===u.STAYED_OUT||n===u.ENTERED)throw Error("getOldParentNode requested on invalid node.");return e.parentNode}getOldPreviousSibling(e){let t=e.parentNode;const n=this.treeChanges.get(e);n&&n.oldParentNode&&(t=n.oldParentNode);const o=this.childListChangeMap.get(t);if(!o)throw Error("getOldPreviousSibling requested on invalid node.");return o.oldPrevious.get(e)}getOldAttribute(e,t){const n=this.treeChanges.get(e);if(!n||!n.attributes)throw Error("getOldAttribute requested on invalid node.");const o=n.getAttributeOldValue(t);if(void 0===o)throw Error("getOldAttribute requested for unchanged attribute name.");return o}attributeChangedNodes(e){if(!this.treeChanges.anyAttributesChanged)return{};let t,n;if(e){t={},n={};for(var o=0;o<e.length;o++){t[r=e[o]]=!0,n[r.toLowerCase()]=r}}const i={},s=this.treeChanges.keys();for(o=0;o<s.length;o++){const e=s[o],a=this.treeChanges.get(e);if(!a.attributes)continue;if(u.STAYED_IN!==this.treeChanges.reachabilityChange(e)||u.STAYED_IN!==this.matchabilityChange(e))continue;const l=e,d=a.getAttributeNamesMutated();for(let e=0;e<d.length;e++){var r=d[e];if(t&&!t[r]&&(!a.isCaseInsensitive||!n[r]))continue;a.getAttributeOldValue(r)!==l.getAttribute(r)&&(n&&a.isCaseInsensitive&&(r=n[r]),i[r]=i[r]||[],i[r].push(l))}}return i}getOldCharacterData(e){const t=this.treeChanges.get(e);if(!t||!t.characterData)throw Error("getOldCharacterData requested on invalid node.");return t.characterDataOldValue}getCharacterDataChanged(){if(!this.treeChanges.anyCharacterDataChanged)return[];const e=this.treeChanges.keys(),t=[];for(let n=0;n<e.length;n++){const o=e[n];if(u.STAYED_IN!==this.treeChanges.reachabilityChange(o))continue;const i=this.treeChanges.get(o);i.characterData&&o.textContent!=i.characterDataOldValue&&t.push(o)}return t}computeMatchabilityChange(e,t){this.matchCache||(this.matchCache=[]),this.matchCache[e.uid]||(this.matchCache[e.uid]=new h);const n=this.matchCache[e.uid];let o=n.get(t);return void 0===o&&(o=e.matchabilityChange(t,this.treeChanges.get(t)),n.set(t,o)),o}matchabilityChange(e){if(this.characterDataOnly)switch(e.nodeType){case Node.COMMENT_NODE:case Node.TEXT_NODE:return u.STAYED_IN;default:return u.STAYED_OUT}if(!this.selectors)return u.STAYED_IN;if(e.nodeType!==Node.ELEMENT_NODE)return u.STAYED_OUT;const t=e,n=this.selectors.map((e=>this.computeMatchabilityChange(e,t)));let o=u.STAYED_OUT,i=0;for(;o!==u.STAYED_IN&&i<n.length;){switch(n[i]){case u.STAYED_IN:o=u.STAYED_IN;break;case u.ENTERED:o=o===u.EXITED?u.STAYED_IN:u.ENTERED;break;case u.EXITED:o=o===u.ENTERED?u.STAYED_IN:u.EXITED}i++}return o}getChildlistChange(e){let t=this.childListChangeMap.get(e);return t||(t=new p,this.childListChangeMap.set(e,t)),t}processChildlistChanges(){if(!this.childListChangeMap){this.childListChangeMap=new h;for(let o=0;o<this.mutations.length;o++){const i=this.mutations[o];if("childList"!=i.type)continue;if(this.treeChanges.reachabilityChange(i.target)!==u.STAYED_IN&&!this.calcOldPreviousSibling)continue;var e=this.getChildlistChange(i.target);let s=i.previousSibling;function r(t,n){!t||e.oldPrevious.has(t)||e.added.has(t)||e.maybeMoved.has(t)||n&&(e.added.has(n)||e.maybeMoved.has(n))||e.oldPrevious.set(t,n)}for(var t=0;t<i.removedNodes.length;t++){r(n=i.removedNodes[t],s),e.added.has(n)?e.added.delete(n):(e.removed.set(n,!0),e.maybeMoved.delete(n)),s=n}r(i.nextSibling,s);for(t=0;t<i.addedNodes.length;t++){var n=i.addedNodes[t];e.removed.has(n)?(e.removed.delete(n),e.maybeMoved.set(n,!0)):e.added.set(n,!0)}}}}wasReordered(e){if(!this.treeChanges.anyParentsChanged)return!1;this.processChildlistChanges();let t=e.parentNode;const n=this.treeChanges.get(e);n&&n.oldParentNode&&(t=n.oldParentNode);const o=this.childListChangeMap.get(t);if(!o)return!1;if(o.moved)return o.moved.get(e);o.moved=new h;const i=new h;function s(e){if(!e)return!1;if(!o.maybeMoved.has(e))return!1;let t=o.moved.get(e);return void 0!==t||(i.has(e)?t=!0:(i.set(e,!0),t=function(e){if(l.has(e))return l.get(e);let t=e.previousSibling;for(;t&&(o.added.has(t)||s(t));)t=t.previousSibling;return l.set(e,t),t}(e)!==a(e)),i.has(e)?(i.delete(e),o.moved.set(e,t)):t=o.moved.get(e)),t}const r=new h;function a(e){let t=r.get(e);if(void 0!==t)return t;for(t=o.oldPrevious.get(e);t&&(o.removed.has(t)||s(t));)t=a(t);return void 0===t&&(t=e.previousSibling),r.set(e,t),t}const l=new h;return o.maybeMoved.keys().forEach(s),o.moved.get(e)}}class v{constructor(e,t){if(this.projection=e,this.added=[],this.removed=[],this.reparented=t.all||t.element||t.characterData?[]:void 0,this.reordered=t.all?[]:void 0,e.getChanged(this,t.elementFilter,t.characterData),t.all||t.attribute||t.attributeList){const n=t.attribute?[t.attribute]:t.attributeList,o=e.attributeChangedNodes(n);t.attribute?this.valueChanged=o[t.attribute]||[]:(this.attributeChanged=o,t.attributeList&&t.attributeList.forEach((e=>{this.attributeChanged.hasOwnProperty(e)||(this.attributeChanged[e]=[])})))}if(t.all||t.characterData){const n=e.getCharacterDataChanged();t.characterData?this.valueChanged=n:this.characterDataChanged=n}this.reordered&&(this.getOldPreviousSibling=e.getOldPreviousSibling.bind(e))}getOldParentNode(e){return this.projection.getOldParentNode(e)}getOldAttribute(e,t){return this.projection.getOldAttribute(e,t)}getOldCharacterData(e){return this.projection.getOldCharacterData(e)}getOldPreviousSibling(e){return this.projection.getOldPreviousSibling(e)}}const b=/[a-zA-Z_]+/,y=/[a-zA-Z0-9_\-]+/;function w(e){return'"'+e.replace(/"/,'\\"')+'"'}class E{constructor(){}matches(e){if(null===e)return!1;if(void 0===this.attrValue)return!0;if(!this.contains)return this.attrValue==e;const t=e.split(" ");for(let e=0;e<t.length;e++)if(this.attrValue===t[e])return!0;return!1}toString(){return"class"===this.attrName&&this.contains?"."+this.attrValue:"id"!==this.attrName||this.contains?this.contains?"["+this.attrName+"~="+w(this.attrValue)+"]":"attrValue"in this?"["+this.attrName+"="+w(this.attrValue)+"]":"["+this.attrName+"]":"#"+this.attrValue}}class C{get caseInsensitiveTagName(){return this.tagName.toUpperCase()}get selectorString(){return this.tagName+this.qualifiers.join("")}constructor(){this.uid=C.nextUid++,this.qualifiers=[]}isMatching(e){return e[C.matchesSelector](this.selectorString)}wasMatching(e,t,n){if(!t||!t.attributes)return n;const o=t.isCaseInsensitive?this.caseInsensitiveTagName:this.tagName;if("*"!==o&&o!==e.tagName)return!1;const i=[];let s=!1;for(var r=0;r<this.qualifiers.length;r++){var a=this.qualifiers[r],l=t.getAttributeOldValue(a.attrName);i.push(l),s=s||void 0!==l}if(!s)return n;for(r=0;r<this.qualifiers.length;r++){a=this.qualifiers[r];if(void 0===(l=i[r])&&(l=e.getAttribute(a.attrName)),!a.matches(l))return!1}return!0}matchabilityChange(e,t){const n=this.isMatching(e);return n?this.wasMatching(e,t,n)?u.STAYED_IN:u.ENTERED:this.wasMatching(e,t,n)?u.EXITED:u.STAYED_OUT}static parseSelectors(e){const t=[];let n,o;function i(){n&&(o&&(n.qualifiers.push(o),o=void 0),t.push(n)),n=new C}function s(){o&&n.qualifiers.push(o),o=new E}const r=/\s/;let a;const l="Invalid or unsupported selector syntax.";let d=1,c=0;for(;c<e.length;){const t=e[c++];switch(d){case 1:if(t.match(b)){i(),n.tagName=t,d=2;break}if("*"==t){i(),n.tagName="*",d=3;break}if("."==t){i(),s(),n.tagName="*",o.attrName="class",o.contains=!0,d=4;break}if("#"==t){i(),s(),n.tagName="*",o.attrName="id",d=4;break}if("["==t){i(),s(),n.tagName="*",o.attrName="",d=6;break}if(t.match(r))break;throw Error(l);case 2:if(t.match(y)){n.tagName+=t;break}if("."==t){s(),o.attrName="class",o.contains=!0,d=4;break}if("#"==t){s(),o.attrName="id",d=4;break}if("["==t){s(),o.attrName="",d=6;break}if(t.match(r)){d=14;break}if(","==t){d=1;break}throw Error(l);case 3:if("."==t){s(),o.attrName="class",o.contains=!0,d=4;break}if("#"==t){s(),o.attrName="id",d=4;break}if("["==t){s(),o.attrName="",d=6;break}if(t.match(r)){d=14;break}if(","==t){d=1;break}throw Error(l);case 4:if(t.match(b)){o.attrValue=t,d=5;break}throw Error(l);case 5:if(t.match(y)){o.attrValue+=t;break}if("."==t){s(),o.attrName="class",o.contains=!0,d=4;break}if("#"==t){s(),o.attrName="id",d=4;break}if("["==t){s(),d=6;break}if(t.match(r)){d=14;break}if(","==t){d=1;break}throw Error(l);case 6:if(t.match(b)){o.attrName=t,d=7;break}if(t.match(r))break;throw Error(l);case 7:if(t.match(y)){o.attrName+=t;break}if(t.match(r)){d=8;break}if("~"==t){o.contains=!0,d=9;break}if("="==t){o.attrValue="",d=11;break}if("]"==t){d=3;break}throw Error(l);case 8:if("~"==t){o.contains=!0,d=9;break}if("="==t){o.attrValue="",d=11;break}if("]"==t){d=3;break}if(t.match(r))break;throw Error(l);case 9:if("="==t){o.attrValue="",d=11;break}throw Error(l);case 10:if("]"==t){d=3;break}if(t.match(r))break;throw Error(l);case 11:if(t.match(r))break;if('"'==t||"'"==t){a=t,d=13;break}o.attrValue+=t,d=12;break;case 12:if(t.match(r)){d=10;break}if("]"==t){d=3;break}if("'"==t||'"'==t)throw Error(l);o.attrValue+=t;break;case 13:if(t==a){d=10;break}o.attrValue+=t;break;case 14:if(t.match(r))break;if(","==t){d=1;break}throw Error(l)}}switch(d){case 1:case 2:case 3:case 5:case 14:i();break;default:throw Error(l)}if(!t.length)throw Error(l);return t}}C.nextUid=1,C.matchesSelector=function(){const e=document.createElement("div");return"function"==typeof e.webkitMatchesSelector?"webkitMatchesSelector":"function"==typeof e.mozMatchesSelector?"mozMatchesSelector":"function"==typeof e.msMatchesSelector?"msMatchesSelector":"matchesSelector"}();const T=/^([a-zA-Z:_]+[a-zA-Z0-9_\-:\.]*)$/;function x(e){if("string"!=typeof e)throw Error("Invalid request opion. attribute must be a non-zero length string.");if(!(e=e.trim()))throw Error("Invalid request opion. attribute must be a non-zero length string.");if(!e.match(T))throw Error("Invalid request option. invalid attribute name: "+e);return e}function S(e){if(!e.trim().length)throw Error("Invalid request option: elementAttributes must contain at least one attribute.");const t={},n={},o=e.split(/\s+/);for(let e=0;e<o.length;e++){var i;if(!(i=o[e]))continue;const s=(i=x(i)).toLowerCase();if(t[s])throw Error("Invalid request option: observing multiple case variations of the same attribute is not supported.");n[i]=!0,t[s]=!0}return Object.keys(n)}class I{static createObserverOptions(e){const t={childList:!0,subtree:!0};let n;function o(e){t.attributes&&!n||(t.attributes=!0,t.attributeOldValue=!0,e?(n=n||{},e.forEach((e=>{n[e]=!0,n[e.toLowerCase()]=!0}))):n=void 0)}return e.forEach((e=>{if(e.characterData)return t.characterData=!0,void(t.characterDataOldValue=!0);if(e.all)return o(),t.characterData=!0,void(t.characterDataOldValue=!0);if(e.attribute)return void o([e.attribute.trim()]);const n=function(e){const t={};return e.forEach((e=>{e.qualifiers.forEach((e=>{t[e.attrName]=!0}))})),Object.keys(t)}(e.elementFilter).concat(e.attributeList||[]);n.length&&o(n)})),n&&(t.attributeFilter=Object.keys(n)),t}static validateOptions(e){for(const t in e)if(!(t in I.optionKeys))throw Error("Invalid option: "+t);if("function"!=typeof e.callback)throw Error("Invalid options: callback is required and must be a function");if(!e.queries||!e.queries.length)throw Error("Invalid options: queries must contain at least one query request object.");const t={callback:e.callback,rootNode:e.rootNode||document,observeOwnChanges:!!e.observeOwnChanges,oldPreviousSibling:!!e.oldPreviousSibling,queries:[]};for(let o=0;o<e.queries.length;o++){const i=e.queries[o];if(i.all){if(Object.keys(i).length>1)throw Error("Invalid request option. all has no options.");t.queries.push({all:!0})}else if("attribute"in i){if((n={attribute:x(i.attribute)}).elementFilter=C.parseSelectors("*["+n.attribute+"]"),Object.keys(i).length>1)throw Error("Invalid request option. attribute has no options.");t.queries.push(n)}else if("element"in i){let e=Object.keys(i).length;var n={element:i.element,elementFilter:C.parseSelectors(i.element)};if(i.hasOwnProperty("elementAttributes")&&(n.attributeList=S(i.elementAttributes),e--),e>1)throw Error("Invalid request option. element only allows elementAttributes option.");t.queries.push(n)}else{if(!i.characterData)throw Error("Invalid request option. Unknown query request.");if(Object.keys(i).length>1)throw Error("Invalid request option. characterData has no options.");t.queries.push({characterData:!0})}}return t}createSummaries(e){if(!e||!e.length)return[];const t=new f(this.root,e,this.elementFilter,this.calcReordered,this.options.oldPreviousSibling),n=[];for(let e=0;e<this.options.queries.length;e++)n.push(new v(t,this.options.queries[e]));return n}checkpointQueryValidators(){this.queryValidators.forEach((e=>{e&&e.recordPreviousState()}))}runQueryValidators(e){this.queryValidators.forEach(((t,n)=>{t&&t.validate(e[n])}))}changesToReport(e){return e.some((e=>{if(["added","removed","reordered","reparented","valueChanged","characterDataChanged"].some((function(t){return e[t]&&e[t].length})))return!0;if(e.attributeChanged){if(Object.keys(e.attributeChanged).some((t=>!!e.attributeChanged[t].length)))return!0}return!1}))}constructor(e){this.connected=!1,this.options=I.validateOptions(e),this.observerOptions=I.createObserverOptions(this.options.queries),this.root=this.options.rootNode,this.callback=this.options.callback,this.elementFilter=Array.prototype.concat.apply([],this.options.queries.map((e=>e.elementFilter?e.elementFilter:[]))),this.elementFilter.length||(this.elementFilter=void 0),this.calcReordered=this.options.queries.some((e=>e.all)),this.queryValidators=[],I.createQueryValidator&&(this.queryValidators=this.options.queries.map((e=>I.createQueryValidator(this.root,e)))),this.observer=new MutationObserver((e=>{this.observerCallback(e)})),this.reconnect()}observerCallback(e){this.options.observeOwnChanges||this.observer.disconnect();const t=this.createSummaries(e);this.runQueryValidators(t),this.options.observeOwnChanges&&this.checkpointQueryValidators(),this.changesToReport(t)&&this.callback(t),!this.options.observeOwnChanges&&this.connected&&(this.checkpointQueryValidators(),this.observer.observe(this.root,this.observerOptions))}reconnect(){if(this.connected)throw Error("Already connected");this.observer.observe(this.root,this.observerOptions),this.connected=!0,this.checkpointQueryValidators()}takeSummaries(){if(!this.connected)throw Error("Not connected");const e=this.createSummaries(this.observer.takeRecords());return this.changesToReport(e)?e:void 0}disconnect(){const e=this.takeSummaries();return this.observer.disconnect(),this.connected=!1,e}}function O(e){return!(!k(e)||""!==e.innerHTML.trim())&&(null!==e.sheet&&0!==e.sheet.cssRules.length)}function k(e){return"STYLE"===e.nodeName}function D(e){return!("IFRAME"!==e.nodeName||!e.contentDocument)}I.NodeMap=h,I.parseElementFilter=C.parseSelectors,I.optionKeys={callback:!0,queries:!0,rootNode:!0,oldPreviousSibling:!0,observeOwnChanges:!0};var N=32,L=!0,_={enabled:!1};function R(e,t,n){let o;switch(e.nodeType){case Node.DOCUMENT_TYPE_NODE:return"doctype";case Node.COMMENT_NODE:return"comment";case Node.TEXT_NODE:return o=e,Z(o,!0,t)?"maskedText":"text";case Node.ELEMENT_NODE:return o=e,(o.matches('input[type="checkbox"]')||o.matches('input[type="radio"]'))&&ee(o,!0,n)?"readonlyMultiValueInput":("INPUT"===o.tagName||"TEXTAREA"===o.tagName)&&ee(o,!0,n)&&Z(o,!0,t)?"maskedTextualInput":"INPUT"!==o.tagName&&"TEXTAREA"!==o.tagName||!ee(o,!0,n)?"SELECT"!==o.tagName&&"OPTION"!==o.tagName&&"OPTGROUP"!==o.tagName||!ee(o,!0,n)?"BUTTON"===o.tagName&&ee(o,!0,n)?"readonlyButton":"SELECT"===o.tagName?"select":"INPUT"!==o.tagName&&"TEXTAREA"!==o.tagName||!Z(o,!0,t)?o.matches('input[type="checkbox"]')||o.matches('input[type="radio"]')?"checkbox":"IFRAME"===o.tagName?D(o)?"cobrowsableIframe":"crossDomainIframe":"IMG"===o.tagName&&Z(o,!0,t)?"maskedImage":"EMBED"===o.tagName||"OBJECT"===o.tagName?"embedOrObject":Z(o,!1,t)?"maskedContainerElement":ee(o,!1,n)?"readonlyContainerElement":"INPUT"===o.tagName||"TEXTAREA"===o.tagName?"textualInput":"HEAD"===o.tagName?"head":function(e){return null!==e.closest("svg")}(o)?"svg":O(o)?"cssInJsStyle":"LINK"===o.tagName?"link":"STYLE"===o.tagName?"style":"generalElement":"maskedTextualInput":"readonlyMultiValueInput":"readonlyTextualInput";default:return"otherNode"}}class A{constructor(e,t){this.node=e,this.id=t}serialize(){return{nodeType:this.node.nodeType,id:this.id}}}class M extends A{constructor(e,t){super(e,t),this.node=e,this.id=t}serialize(){const e=super.serialize();return e.name=this.node.name,e.publicId=this.node.publicId,e.systemId=this.node.systemId,e}}class B extends A{constructor(e,t,n){super(e,t),this.node=e,this.id=t,this.config=n,(null==n?void 0:n.markElementAsMasked)&&this.markMasked(this.node),(null==n?void 0:n.markElementAsReadonly)&&this.markReadonly(this.node)}serialize(){const e=super.serialize(),t=this.node;if(e.tagName=t.tagName,t.hasAttributes()){e.attributes={};for(const n of t.attributes)e.attributes[n.name]=n.value}return e}markReadonly(e){e.setAttribute("data-gcobrowse-readonly","true")}markMasked(e){e.setAttribute("data-gcobrowse-masked","true")}}class U extends A{constructor(e,t){super(e,t),this.node=e,this.id=t}serialize(){const e=super.serialize(),t=H(this.node.textContent);return this.node.parentNode&&"style"===R(this.node.parentNode)&&L?(e.cssContent=t,e.baseURL=document.baseURI):e.textContent=t,e}}class P extends B{constructor(e,t,n){super(e,t,n),this.node=e,this.id=t,this.config=n}serialize(){var e;const t=super.serialize();t.attributes||(t.attributes={}),this.config.markElementAsReadonly&&(t.attributes.disabled="true");const n=this.config.markElementAsMasked?F(this.node.value):this.node.value;if(t.attributes.value=n,t.value=n,this.isCheckboxOrRadio()&&(null===(e=t.attributes)||void 0===e||delete e.value,t.checked=this.node.checked,this.config.markElementAsReadonly)){const e=this.node.labels;if(e)for(const t of e)super.markReadonly(t)}return t}isCheckboxOrRadio(){return this.node.matches('input[type="checkbox"]')||this.node.matches('input[type="radio"]')}}class j extends B{serialize(){const e=super.serialize(),t=this.node;if(!k(t)||!O(t))throw new Error(`Unexpected type of node passed to CssInJSStyleSerializer: ${t.toString()}`);return e.cssContent=j.getCss(t),e.baseURL=document.baseURI,e}static getCss(e){let t="";if(!k(e)||!O(e))throw new Error(`Unexpected type of node passed to CssInJSStyleSerializer: ${e.toString()}`);for(const n of e.sheet.cssRules)t+=n.cssText+"\n";return t}}class z extends B{constructor(e,t){var n,o,i;super(e,t),this.node=e,this.id=t;const s=null===(n=this.node.ownerDocument)||void 0===n?void 0:n.location.href,r=s.substring(0,s.lastIndexOf("/")+1),a=this.node.getElementsByTagName("base");if(0===a.length)this.node.insertAdjacentHTML("afterbegin",`<base href="${r}">`);else{const e=a[0];try{const t=null!==(o=e.getAttribute("href"))&&void 0!==o?o:"",n=new URL(t,null===(i=e.ownerDocument)||void 0===i?void 0:i.location.href).href;e.setAttribute("href",n)}catch(t){e.setAttribute("href",r)}this.node.prepend(e)}}serialize(){return super.serialize()}}class $ extends B{constructor(e,t){super(e,t),this.node=e,this.id=t,super.markMasked(this.node)}serialize(){const e=super.serialize(),t=this.node.getBoundingClientRect();return e.attributes&&(e.attributes.src="data:image/gif;base64,R0lGODlhAQABAIAAAMLCwgAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw==",e.attributes.height=t.height.toString(),e.attributes.width=t.width.toString()),e}}class V extends B{constructor(e,t){super(e,t),this.node=e,this.id=t,super.markMasked(this.node)}serialize(){const e=super.serialize();return e.attributes||(e.attributes={}),e.attributes.src&&(e.attributes["data-src"]=e.attributes.src,e.attributes.src="about://blank",e.attributes.frameborder="1"),e.width=this.node.getBoundingClientRect().width,e.height=this.node.getBoundingClientRect().height,e}}class q extends B{serialize(){const e=super.serialize();return e.attributes||(e.attributes={}),e.attributes.src&&(e.attributes["data-src"]=e.attributes.src,e.attributes.src="about://blank",e.attributes.frameborder="1"),e.width=this.node.getBoundingClientRect().width,e.height=this.node.getBoundingClientRect().height,e}}class W extends B{serialize(){const e=super.serialize();return e.value=H(this.node.value),e}}function H(e){const t=/(?:\d{2,4}[ -]?){4}(?:\d{3})?/,n=t.exec(e);if(!n)return e;let o=n[0];return o=o.replace(/[\s-]+/g,""),function(e){let t=0,n=!1;for(let o=(e=e.replace(/\D/g,"")).length-1;o>=0;o--){const i=e.charAt(o);let s=parseInt(i,10);n&&(s*=2)>9&&(s-=9),t+=s,n=!n}return t%10==0}(o)?e.replace(t,"●●●● ●●●● ●●●● ●●●●"):e}function F(e){return e.replace(/[^\s]/g,"●")}class G extends A{constructor(e,t){super(e,t),this.node=e,this.id=t}serialize(){const e=super.serialize();return e.textContent=F(this.node.textContent),e}}class Y extends B{serialize(){const e=super.serialize();return e.svg=1,e}}class X extends B{constructor(e,t,n){super(e,t,n),this.node=e,this.id=t,this.config=n,super.markMasked(this.node)}serialize(){const e=super.serialize();return e.width=this.node.getBoundingClientRect().width,e.height=this.node.getBoundingClientRect().height,e.tagName="DIV",e.isEmbedOrObject=!0,e.attributes||(e.attributes={}),delete e.attributes.data,delete e.attributes.src,delete e.attributes.width,delete e.attributes.height,delete e.attributes.type,delete e.attributes.typemustmatch,delete e.attributes.usemap,e.attributes.frameborder="1",e}}class K{constructor(e,t){this.node=e,this.id=t,this.allowedRelTypes=["icon","stylesheet","apple-icon-touch"],this.allowedAsAttributes=["font","image","style"],this.elementSerializer=new B(e,t)}serialize(){var e,t;const n=this.elementSerializer.serialize();{n.attributes&&(n.attributes.crossorigin="anonymous");const o=null===(e=n.attributes)||void 0===e?void 0:e.as;if(o&&!this.isAttributeAllowed(o,this.allowedAsAttributes))return;const i=null===(t=n.attributes)||void 0===t?void 0:t.rel;if(i&&!this.isAttributeAllowed(i,this.allowedRelTypes))return;this.rewriteHref(n)}return n}isAttributeAllowed(e,t){return t.includes(e.toLowerCase())}rewriteHref(e){var t;if(null==e?void 0:e.attributes){const n=null===(t=e.attributes)||void 0===t?void 0:t.href;n&&(e.attributes.href=new URL(n,document.baseURI).href)}}}class J extends B{serialize(){return super.serialize()}}function Q(e){if(!e.cssSelectors)return!1;for(const t of e.cssSelectors){if(e.elem.nodeType!==Node.ELEMENT_NODE&&e.elem.nodeType!==Node.TEXT_NODE)continue;const n=e.elem.nodeType===Node.TEXT_NODE?te(e.elem):e.elem;if(null===n)throw new Error(`Cannot determine if element ${e.elem.outerHTML} is of type ${e.selectorType}`);if(n.matches(t))return!0;if(e.checkParent&&n.closest(t))return!0}return!1}function Z(e,t,n){return Q({selectorType:"masking",elem:e,checkParent:t,cssSelectors:n})}function ee(e,t,n){return Q({selectorType:"readonly",elem:e,checkParent:t,cssSelectors:n})}function te(e){if(null===e.parentNode)throw new Error("parent node must not be null");return e.parentNode instanceof ShadowRoot?e.getRootNode().host:e.parentNode}function ne(e,...t){if(!("GENESYS_COBROWSE_DEBUG_DOM"in window))return;const n=[`%ccobrowse:DOM%c ${e}`,"color:#FF8FDD;font-weight:bold","color:#555;font-style:italic"].concat(t);console.log(...n)}function oe(e,t){for(;e.parentNode;){const n=e.parentNode;if(n.nodeType===Node.ELEMENT_NODE&&n.matches(t))return!0;e=n}return!1}function ie(e,t){return null!==e.parentNode&&t.includes(e.parentNode)?ie(e.parentNode,t):e}class se{constructor(e,t,n,o){var i;this.target=e,this.mirror=t,this.config=o,this.nextId=1,this.nodeToId=new Map,this.idToNode=new Map,this.cssInJsTimers=new Map,this.ignoredSelectors=(null===(i=this.config)||void 0===i?void 0:i.ignore)||[],this.cobrowsableIframes=[],ne("recording current DOM snapshot, root node: ",e);const s=this.serializeNode(e).id,r=this.serializeChildren(e);ne("recorded DOM snapshot"),this.mirror.initialize(s,r);let a=[{all:!0}];n&&(a=a.concat(n)),ne("creating Mutation Summary"),this.mutationSummary=new I({rootNode:e,callback:e=>{ne("got Mutations callback with this: ",e),this.applyChanged(e[0]),ne("finished with a mutation")},queries:a}),this.onInputEvent=this.onInputEvent.bind(this),e.addEventListener("input",this.onInputEvent)}processSubTree(e){var t;ne("adding input listener for a subtree",e),e.addEventListener("input",this.onInputEvent.bind(this)),ne("creating Mutation Summary for a subtree",e);const n=new I({rootNode:e,callback:e=>{ne("Subtree got mutations. Summaries: ",e),this.applyChanged(e[0]),ne("finished with subtree mutations",e)},queries:[{all:!0}]});null===(t=this.subTreeMutationSummaries)||void 0===t||t.push(n)}onInputEvent(e){var t,n;if(!e.target)return;const o=e.target;if("INPUT"===o.tagName||"TEXTAREA"===o.tagName){const e=o,i=R(o,null===(t=this.config)||void 0===t?void 0:t.masking,null===(n=this.config)||void 0===n?void 0:n.readonly);"textualInput"===i||"readonlyTextualInput"===i?this.applyValueChanged(e):"readonlyMultiValueInput"===i?this.applyCheckedChanged(e):"maskedTextualInput"===i?this.applyMaskedValueChanged(e):"checkbox"===i&&this.applyCheckedChanged(e)}"SELECT"===o.tagName&&this.applySelectChanged(o)}disconnect(){var e;this.mutationSummary&&(this.mutationSummary.disconnect(),ne("Mutation Summary disconnected"),this.mutationSummary=void 0),(null===(e=this.subTreeMutationSummaries)||void 0===e?void 0:e.length)&&(this.subTreeMutationSummaries.forEach((e=>e.disconnect())),ne("Subtree Mutation Summary disconnected"),this.subTreeMutationSummaries=void 0),this.target.removeEventListener("input",this.onInputEvent),this.nodeToId.clear(),this.idToNode.clear();for(const e of this.cssInJsTimers.values())clearTimeout(e);this.cssInJsTimers.clear(),this.cobrowsableIframes=[]}rememberNode(e){const t=this.nextId++;return this.nodeToId.set(e,t),this.idToNode.set(t,e),ne(`remembered node with id ${t}: `,e),t}forgetNode(e){const t=this.nodeToId.get(e);"number"==typeof t&&this.idToNode.delete(t),this.nodeToId.delete(e),ne("forgot node with id ",t,e)}getNodeById(e){const t=this.idToNode.get(e);if(!t)throw new Error(`trying to get node with unknown id "${e}"`);return t}getNodeId(e){const t=this.nodeToId.get(e);if(!t)throw new Error("trying to get id of unknown node");return t}serializeChildren(e){const t=[];ne("serializing children of: ",e);for(let n=e.firstChild;n;n=n.nextSibling)if(this.isIgnored(n))ne("ignoring node: ",n);else{const e=this.serializeNode(n,!0);e&&t.push(e)}return ne("serialized children of: ",e,t),t}serializeNode(e,t){var n,o;if(null===e)throw new Error("cannot serialize null");ne("serializing node",e);let i=this.nodeToId.get(e);if(void 0!==i)return ne(`serialized known node with id ${i}`,e),{id:i};ne("this node was not serialized before"),i=this.rememberNode(e);const s=function(e,t,n,o){switch(R(e,n,o)){case"doctype":return new M(e,t);case"text":case"comment":return new U(e,t);case"cobrowsableIframe":return new q(e,t);case"crossDomainIframe":return new V(e,t);case"maskedText":return new G(e,t);case"generalElement":return new B(e,t);case"svg":return new Y(e,t);case"readonlyContainerElement":return new B(e,t,{markElementAsMasked:Z(e,!1,n),markElementAsReadonly:!0});case"maskedContainerElement":return new B(e,t,{markElementAsMasked:!0,markElementAsReadonly:ee(e,!1,o)});case"textualInput":return new W(e,t);case"maskedTextualInput":return new P(e,t,{markElementAsMasked:!0,markElementAsReadonly:!0});case"maskedImage":return new $(e,t);case"select":case"checkbox":return new P(e,t,{markElementAsMasked:Z(e,!0,n),markElementAsReadonly:ee(e,!0,o)});case"readonlyTextualInput":case"readonlyMultiValueInput":case"readonlyButton":return new P(e,t,{markElementAsMasked:Z(e,!0,n),markElementAsReadonly:!0});case"head":return new z(e,t);case"cssInJsStyle":return new j(e,t);case"link":return new K(e,t);case"style":return new J(e,t);case"embedOrObject":return new X(e,t,{markElementAsReadonly:ee(e,!0,o)});default:return new A(e,t)}}(e,i,null===(n=this.config)||void 0===n?void 0:n.masking,null===(o=this.config)||void 0===o?void 0:o.readonly);ne("serailizer for the node is: ",s);const r=s.serialize();if(r)return ne("serialized (without children) as ",r),function(e){return"OBJECT"===e.nodeName}(e)?(ne("going to drop children of Object element",e),r):(function(e){return!(e.nodeType!==Node.ELEMENT_NODE||!e.childNodes.length)}(e)&&t&&(ne("now going to recursively serialize children"),r.childNodes=this.serializeChildren(e)),function(e){const t=e;return!(t.nodeType!==Node.ELEMENT_NODE||!t.shadowRoot||"open"!==t.shadowRoot.mode)}(e)&&t&&(ne("now going to recursively serialize children of shadowRoot",e),r.shadowNodes=this.serializeChildren(e.shadowRoot),this.processSubTree(e.shadowRoot)),D(e)&&(this.cobrowsableIframes.push(e),ne("now going to recursively serialize children of same-domain iframe",e),this.isIframeLoaded(e)?(ne("looks like this iframe is loaded alright, lets get inside it"),r.iframeChildNodes=this.serializeChildren(e.contentDocument),this.processSubTree(e.contentDocument)):(ne("looks like this iframe is still loading"),e.addEventListener("load",(()=>{ne("NOW this iframe is loaded alright, we are ready to get inside it",e);const t={iframeId:r.id,children:this.serializeChildren(e.contentDocument)};this.processSubTree(e.contentDocument),this.mirror.onLoadedIframe?(ne("calling onLoadedIframe callback"),this.mirror.onLoadedIframe(e,t)):ne("onLoadedIframe callback not setup, not calling")})))),O(e)&&this.treatCssInJsNode(e,r),ne("finished serializing node: ",r),r);ne("serialized to no data ",r)}isIframeLoaded(e){return"<head></head><body></body>"!==e.contentDocument.documentElement.innerHTML}treatCssInJsNode(e,t){let n=t.cssContent;ne("encountered css-in-js node: ",e),ne("it has css:",n),ne("it isConnected:",e.isConnected);const o=this.cssInJsTimers,i=setTimeout((function i(){if(ne("checking for css changes"),!e.isConnected)return;const a=j.getCss(e);a!==n&&(ne(`got css changed from:\n\n${n} \n\nto:\n\nf${a}`),r(s,a),n=a);const l=setTimeout(i,500);o.set(t.id,l)}),500),s=t.id,r=this.applyCssInJsChanged.bind(this);o.set(t.id,i)}serializePreviousSibling(e){var t;ne("looking for previous sibling of node",e);let n=e.previousSibling;for(;n&&this.isIgnored(n);)ne('previous sibling is "ignored", trying next previous sibling',n),n=n.previousSibling;return ne("final previous sibling: ",n),n&&null!==(t=this.serializeNode(n))&&void 0!==t?t:null}serializeAddedAndMoved(e,t,n){ne("serializing added, reparented and reordered nodes: ",e,t,n);const o=e.concat(t).concat(n).filter((e=>!this.isIgnored(e)));ne("added/moved nodes minus ignored nodes: ",o);const i=new I.NodeMap;o.forEach((e=>{const t=e.parentNode;if(null===t)throw new Error("parent node must not be null");let n=i.get(t);n||(n=new I.NodeMap,i.set(t,n)),n.set(e,!0)}));const s=[];return i.keys().forEach((e=>{const t=i.get(e);let n=t.keys();for(;n.length;){let e=n[0];for(;e.previousSibling&&t.has(e.previousSibling);)e=e.previousSibling;let o=e;for(;o&&t.has(o);){e=o,ne("1) serializing node itself",e);const n=this.serializeNode(e);if(n){if(ne("2) adding info about its previous sibling"),n.previousSibling=this.serializePreviousSibling(e),null===e.parentNode)throw new Error("parent node must not be null");ne("3) adding info about its parent");const i=this.serializeNode(te(e));i&&(n.parentNode=i),s.push(n),t.delete(e),o=e.nextSibling}}n=t.keys()}})),s}serializeRemoved(e,t){ne("serializing removed nodes",e);const n=[];return e.filter((n=>!this.isRemovedIgnored(n,e,t))).forEach((e=>{const t=this.serializeNode(e);t&&n.push(t)})),n}serializeCharacterData(e){return ne("serializing character data: ",e),e.filter((e=>!this.isIgnored(e))).map((e=>{var t,n;const o=this.serializeNode(e);if(o){const i=null!==(t=e.textContent)&&void 0!==t?t:"";Z(e,!0,null===(n=this.config)||void 0===n?void 0:n.masking)?o.textContent=F(i):o.textContent=H(i)}return o}))}serializeAttributeChanges(e){const t=new I.NodeMap;return ne("serializing attribute changes",e),Object.keys(e).forEach((n=>{e[n].filter((e=>!this.isIgnored(e))).forEach((e=>{let o=t.get(e);o||(o=this.serializeNode(e),o.attributes={},t.set(e,o)),"gcobrowse-draw-active"!=e.getAttribute(n)&&(o.attributes[n]=e.getAttribute(n))}))})),t.keys().map((e=>t.get(e)))}serializeValueChanged(e){if(this.isIgnored(e))return null;const t=this.nodeToId.get(e);if(void 0===t)throw new Error("cannot serialize unknown node");return{id:t,value:H(e.value)}}serializeMaskedValueChanged(e){if(this.isIgnored(e))return null;const t=this.nodeToId.get(e);if(void 0===t)throw new Error("cannot serialize unknown node");return{id:t,value:F(e.value)}}serializeCheckedChanged(e){if(this.isIgnored(e))return null;const t=this.nodeToId.get(e);if(void 0===t)throw new Error("cannot serialize unknown node");return{id:t,checked:e.checked}}serializeSelectedIndex(e){if(this.isIgnored(e))return null;const t=this.nodeToId.get(e);if(void 0===t)throw new Error("cannot serialize unknown node");return{id:t,index:e.selectedIndex}}applySelectChanged(e){const t=this.serializeSelectedIndex(e);t&&this.mirror.applySelectChanged&&this.mirror.applySelectChanged([t])}applyValueChanged(e){const t=this.serializeValueChanged(e);t&&this.mirror.applyValueChanged&&this.mirror.applyValueChanged([t])}applyMaskedValueChanged(e){const t=this.serializeMaskedValueChanged(e);t&&this.mirror.applyValueChanged&&this.mirror.applyValueChanged([t])}applyCheckedChanged(e){const t=this.serializeCheckedChanged(e);t&&this.mirror.applyCheckedChanged&&this.mirror.applyCheckedChanged([t])}applyCssInJsChanged(e,t){this.mirror.applyCssInJsChanged&&this.mirror.applyCssInJsChanged({id:e,cssContent:t})}isIgnored(e){if(ne('checking if a node is "ignored"',e),0===this.ignoredSelectors.length)return!1;for(const t of this.ignoredSelectors){const n=e;if(n.nodeType===Node.ELEMENT_NODE&&n.matches(t))return ne("yes, node matches ignored selector"),!0;if(oe(n,t))return ne("yes, node is a child of ignored node"),!0}return ne("no, node is not ignored"),!1}isRemovedIgnored(e,t,n){const o=n(ie(e,t));return ne("checking if deleted node should be ignored by its non-deleted ancestor:",o),this.isIgnored(o)}applyChanged(e){const t=this.serializeRemoved(e.removed,e.getOldParentNode.bind(e));ne("serialized removed nodes: ",t);const n=this.serializeAddedAndMoved(e.added,e.reparented,e.reordered);ne("serialized added and moved nodes: ",n);const o=this.serializeAttributeChanges(e.attributeChanged);ne("serialized attribute changes: ",o);const i=this.serializeCharacterData(e.characterDataChanged);ne("serialized text changes: ",i),(t.length||n.length||o.length||i.length)&&this.mirror.applyChanged(t,n,o,i),e.removed.forEach((e=>{this.forgetNode(e)}))}}class re{constructor(e,t){var n;this.rootElement=e,this.config=t;let o=["script",'input[type="hidden"]',".genesys-cbx-ignore"];(null===(n=this.config)||void 0===n?void 0:n.ignore.length)&&(o=o.concat(this.config.ignore)),this.config={ignore:o}}takeSnapshot(e,t){let n=[];const o={initialize:function(e,t){n=t},applyChanged:()=>{}};return e&&this.config&&(this.config.masking=e),t&&this.config&&(this.config.readonly=t),this.treeMirrorClient=new se(this.rootElement,o,[],this.config),n}onLoadedIframe(e){if(!this.treeMirrorClient)throw new Error("Call serializeDom() before calling onLoadedIframe");this.treeMirrorClient.mirror.onLoadedIframe=e}onChange(e){if(!this.treeMirrorClient)throw new Error("Call serializeDom() before calling onChange");this.treeMirrorClient.mirror.applyChanged=function(t,n,o,i){e({removed:t,moved:n,attributes:o,text:i})},this.treeMirrorClient.mirror.applyValueChanged=t=>{e({values:t})},this.treeMirrorClient.mirror.applyCheckedChanged=t=>{e({checked:t})},this.treeMirrorClient.mirror.applySelectChanged=t=>{e({selected:t})},this.treeMirrorClient.mirror.applyCssInJsChanged=t=>{e({cssInJs:t})}}disconnect(){this.treeMirrorClient&&this.treeMirrorClient.disconnect()}getCobrowsableIframes(){return this.treeMirrorClient?this.treeMirrorClient.cobrowsableIframes:[]}getNodeId(e){if(this.treeMirrorClient)return this.treeMirrorClient.getNodeId(e);throw new Error("trying to get node id while mirroring is not initialized")}getNodeById(e){if(this.treeMirrorClient)return this.treeMirrorClient.getNodeById(e);throw new Error("trying to get node y id while mirroring is not initialized")}isIgnored(e){return e.classList.contains("genesys-cbx-ignore")}}class ae{constructor(e,t=""){this.core=e,this.network=e.network,this.log=e.createLogger(t),this.events=e.events,this.notify=e.pubsub.notify.bind(e.pubsub),this.listen=e.pubsub.listen.bind(e.pubsub)}clearEventListeners(){throw new Error("Not implemented!")}getRootUIElement(){return this.core.getRootUIElement()}getWindow(){return this.core.getWindow()}getRole(){return this.core.getRole()}exposeGlobalVariable(e,t){return this.core.exposeGlobalVariable(e,t)}reloadWindow(){return this.core.reloadWindow()}getDOMRoot(){return this.core.getDOMRoot()}getWorkRootUIElement(){return this.core.getWorkRootUIElement()}getWorkWindow(){return this.core.getWorkWindow()}setDeploymentOptions(e){this.core.setDeploymentOptions(e)}getDeploymentOptions(){return this.core.getDeploymentOptions()}geti18n(){return this.core.geti18n()}getFontsURL(){return this.core.getFontsURL()}loadi18n(){return r(this,void 0,void 0,(function*(){return yield this.core.loadi18n()}))}getPrimaryColor(){return this.core.getPrimaryColor()}getAssetsURL(){return this.core.getAssetsURL()}getDeploymentId(){return this.core.getDeploymentId()}sendMessageToWebDirectory(e){return this.core.sendMessageToWebDirectory(e)}}class le extends ae{constructor(e,t=""){super(e,t),this.dom=e.dom,this.getInstrumentedDocument=e.getInstrumentedDocument.bind(e)}}class de{constructor({origin:e,clientRole:t,level:n}){this.crossDomainOrigins=[],this.log=s("browser-storage",n);const o="__genesys_cobrowse_n_";this.userIdKey=`${o}${t}_user_id`,this.controlEnabledSessionKey=`${o}_control_enabled_session`,this.websocketUrlKey=`${o}_websocket_url`,this.conversationId=`${o}_conversation_id_`,this.offerStateId=`${o}_offer_state`,this.deploymentId=`${o}_deployment_id_`,this.crossDomainOrigins.push(e),this.localStorage=window.localStorage}getKey(e){return this.localStorage.getItem(e)}putUserID(e){this.localStorage.setItem(this.userIdKey,e)}setCrossDomainOrigins(e){e&&this.crossDomainOrigins.push(...e)}getUserID(){var e;return null!==(e=this.getKey(this.userIdKey))&&void 0!==e?e:void 0}removeUserID(){this.localStorage.removeItem(this.userIdKey)}putControlEnabledSession(e){this.localStorage.setItem(this.controlEnabledSessionKey,e)}getControlEnabledSession(){var e;return null!==(e=this.getKey(this.controlEnabledSessionKey))&&void 0!==e?e:void 0}removeControlEnabledSession(){this.localStorage.removeItem(this.controlEnabledSessionKey)}setWebSocketUrl(e){this.localStorage.setItem(this.websocketUrlKey,e)}getWebSocketUrl(){var e;return null!==(e=this.getKey(this.websocketUrlKey))&&void 0!==e?e:void 0}getDeploymentIdWithSessionId(e){var t;return null!==(t=this.getKey(this.deploymentId+e))&&void 0!==t?t:void 0}setDeploymentIdWithSessionId(e,t){return this.localStorage.setItem(this.deploymentId+e,t)}removeDeploymentIdWithSessionId(e){this.localStorage.removeItem(this.conversationId+e)}getSessionWithConversationId(e){return this.getKey(this.conversationId+e)}setSessionWithConversationId(e,t){this.localStorage.setItem(this.conversationId+e,t)}removeSessionWithConversationId(e){this.localStorage.removeItem(this.conversationId+e)}setOfferState(e){const t=this.getOfferState();t.push(e),this.log("saving offerState: ",e,t),this.localStorage.setItem(this.offerStateId,JSON.stringify(t))}getOfferState(e){this.log(`retrieving offerState for session ${e}`);const t=this.getKey(this.offerStateId);let n=[];return t&&(n=JSON.parse(t),this.log("retrieved offerStates: ",n),e&&(n=n.filter((t=>t.sessionId===e))),this.log("parsed offerStates: ",n),n=n.sort(((e,t)=>e.timestamp-t.timestamp)),this.log("sorted offerStates: ",n)),this.log(`resolving with offerState for session ${e}=${JSON.stringify(n)}`),n}clearStorage(){this.localStorage.clear()}}var ce="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function he(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var ue,ge={exports:{}};ue=ge,function(e,t,n,o){t[e]=n.call(t);for(var i=0;i<o.length;i++)o[i](t[e]);ue.exports&&(ue.exports=t[e])}("Primus",ce||{},(function(){var e=function e(t,n,o){function i(r,a){if(!n[r]){if(!t[r]){if(!a&&he)return he(r);if(s)return s(r,!0);var l=new Error("Cannot find module '"+r+"'");throw l.code="MODULE_NOT_FOUND",l}var d=n[r]={exports:{}};t[r][0].call(d.exports,(function(e){return i(t[r][1][e]||e)}),d,d.exports,e,t,n,o)}return n[r].exports}for(var s=he,r=0;r<o.length;r++)i(o[r]);return i}({1:[function(e,t,n){t.exports=function(e,t){var n=/[, ]+/;function o(e,o){if(t[e]){if("string"==typeof t[e]&&(t[e]=t[e].split(n)),"function"==typeof t[e])return t[e].call(o);for(var i,s,r=0;r<t[e].length;r++)"function"==(i=typeof(s=t[e][r]))?s.call(o):"string"===i&&"function"==typeof o[s]&&o[s]()}}return t=t||{},"string"==typeof(e=e||[])&&(e=e.split(n)),function(){var t,n=this,i=0;if(null===n[e[0]])return!1;for(o("before",n);i<e.length;i++)n[t=e[i]]&&("function"==typeof n[t].destroy&&n[t].destroy(),n[t]=null);return n.emit&&n.emit("destroy"),o("after",n),!0}}},{}],2:[function(e,t,n){t.exports=function(){for(var e,t=this,n=0,o=arguments.length,i=new Array(o);n<o;n++)i[n]=arguments[n];return"function"!=typeof i[i.length-1]?function(){for(var e=0,n=arguments.length,o=new Array(n);e<n;e++)o[e]=arguments[e];return t.emit.apply(t,i.concat(o))}:(e=i.pop(),function(){for(var n=0,o=arguments.length,s=new Array(o+1);n<o;n++)s[n+1]=arguments[n];return s[0]=function(e,n){if(e)return t.emit("error",e);s=void 0===n?s.slice(1):null===n?[]:n,t.emit.apply(t,i.concat(s))},e.apply(t,s),!0})}},{}],3:[function(e,t,n){var o=Object.prototype.hasOwnProperty,i="~";function s(){}function r(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function a(e,t,n,o,s){if("function"!=typeof n)throw new TypeError("The listener must be a function");var a=new r(n,o||e,s),l=i?i+t:t;return e._events[l]?e._events[l].fn?e._events[l]=[e._events[l],a]:e._events[l].push(a):(e._events[l]=a,e._eventsCount++),e}function l(e,t){0==--e._eventsCount?e._events=new s:delete e._events[t]}function d(){this._events=new s,this._eventsCount=0}Object.create&&(s.prototype=Object.create(null),(new s).__proto__||(i=!1)),d.prototype.eventNames=function(){var e,t,n=[];if(0===this._eventsCount)return n;for(t in e=this._events)o.call(e,t)&&n.push(i?t.slice(1):t);return Object.getOwnPropertySymbols?n.concat(Object.getOwnPropertySymbols(e)):n},d.prototype.listeners=function(e){var t=i?i+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var o=0,s=n.length,r=new Array(s);o<s;o++)r[o]=n[o].fn;return r},d.prototype.listenerCount=function(e){var t=i?i+e:e,n=this._events[t];return n?n.fn?1:n.length:0},d.prototype.emit=function(e,t,n,o,s,r){var a=i?i+e:e;if(!this._events[a])return!1;var l,d,c=this._events[a],h=arguments.length;if(c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),h){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,n),!0;case 4:return c.fn.call(c.context,t,n,o),!0;case 5:return c.fn.call(c.context,t,n,o,s),!0;case 6:return c.fn.call(c.context,t,n,o,s,r),!0}for(d=1,l=new Array(h-1);d<h;d++)l[d-1]=arguments[d];c.fn.apply(c.context,l)}else{var u,g=c.length;for(d=0;d<g;d++)switch(c[d].once&&this.removeListener(e,c[d].fn,void 0,!0),h){case 1:c[d].fn.call(c[d].context);break;case 2:c[d].fn.call(c[d].context,t);break;case 3:c[d].fn.call(c[d].context,t,n);break;case 4:c[d].fn.call(c[d].context,t,n,o);break;default:if(!l)for(u=1,l=new Array(h-1);u<h;u++)l[u-1]=arguments[u];c[d].fn.apply(c[d].context,l)}}return!0},d.prototype.on=function(e,t,n){return a(this,e,t,n,!1)},d.prototype.once=function(e,t,n){return a(this,e,t,n,!0)},d.prototype.removeListener=function(e,t,n,o){var s=i?i+e:e;if(!this._events[s])return this;if(!t)return l(this,s),this;var r=this._events[s];if(r.fn)r.fn!==t||o&&!r.once||n&&r.context!==n||l(this,s);else{for(var a=0,d=[],c=r.length;a<c;a++)(r[a].fn!==t||o&&!r[a].once||n&&r[a].context!==n)&&d.push(r[a]);d.length?this._events[s]=1===d.length?d[0]:d:l(this,s)}return this},d.prototype.removeAllListeners=function(e){var t;return e?(t=i?i+e:e,this._events[t]&&l(this,t)):(this._events=new s,this._eventsCount=0),this},d.prototype.off=d.prototype.removeListener,d.prototype.addListener=d.prototype.on,d.prefixed=i,d.EventEmitter=d,void 0!==t&&(t.exports=d)},{}],4:[function(e,t,n){"function"==typeof Object.create?t.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(e,t){if(t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}}},{}],5:[function(e,t,n){var o=new RegExp("^((?:\\d+)?\\.?\\d+) *("+["milliseconds?","msecs?","ms","seconds?","secs?","s","minutes?","mins?","m","hours?","hrs?","h","days?","d","weeks?","wks?","w","years?","yrs?","y"].join("|")+")?$","i"),i=36e5,s=24*i;t.exports=function(e){var t,n,r=typeof e;if("number"===r)return e;if("string"!==r||"0"===e||!e)return 0;if(+e)return+e;if(e.length>1e4||!(n=o.exec(e)))return 0;switch(t=parseFloat(n[1]),n[2].toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 31536e6*t;case"weeks":case"week":case"wks":case"wk":case"w":return 6048e5*t;case"days":case"day":case"d":return t*s;case"hours":case"hour":case"hrs":case"hr":case"h":return t*i;case"minutes":case"minute":case"mins":case"min":case"m":return 6e4*t;case"seconds":case"second":case"secs":case"sec":case"s":return 1e3*t;default:return t}}},{}],6:[function(e,t,n){t.exports=function(e){var t,n=0;function o(){return n||(n=1,t=e.apply(this,arguments),e=null),t}return o.displayName=e.displayName||e.name||o.displayName||o.name,o}},{}],7:[function(e,t,n){var o,i,s=t.exports={};function r(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}function l(e){if(o===setTimeout)return setTimeout(e,0);if((o===r||!o)&&setTimeout)return o=setTimeout,setTimeout(e,0);try{return o(e,0)}catch(t){try{return o.call(null,e,0)}catch(t){return o.call(this,e,0)}}}!function(){try{o="function"==typeof setTimeout?setTimeout:r}catch(e){o=r}try{i="function"==typeof clearTimeout?clearTimeout:a}catch(e){i=a}}();var d,c=[],h=!1,u=-1;function g(){h&&d&&(h=!1,d.length?c=d.concat(c):u=-1,c.length&&p())}function p(){if(!h){var e=l(g);h=!0;for(var t=c.length;t;){for(d=c,c=[];++u<t;)d&&d[u].run();u=-1,t=c.length}d=null,h=!1,function(e){if(i===clearTimeout)return clearTimeout(e);if((i===a||!i)&&clearTimeout)return i=clearTimeout,clearTimeout(e);try{return i(e)}catch(t){try{return i.call(null,e)}catch(t){return i.call(this,e)}}}(e)}}function m(e,t){this.fun=e,this.array=t}function f(){}s.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];c.push(new m(e,t)),1!==c.length||h||l(p)},m.prototype.run=function(){this.fun.apply(null,this.array)},s.title="browser",s.browser=!0,s.env={},s.argv=[],s.version="",s.versions={},s.on=f,s.addListener=f,s.once=f,s.off=f,s.removeListener=f,s.removeAllListeners=f,s.emit=f,s.prependListener=f,s.prependOnceListener=f,s.listeners=function(e){return[]},s.binding=function(e){throw new Error("process.binding is not supported")},s.cwd=function(){return"/"},s.chdir=function(e){throw new Error("process.chdir is not supported")},s.umask=function(){return 0}},{}],8:[function(e,t,n){var o,i=Object.prototype.hasOwnProperty;function s(e){try{return decodeURIComponent(e.replace(/\+/g," "))}catch(e){return null}}function r(e){try{return encodeURIComponent(e)}catch(e){return null}}n.stringify=function(e,t){t=t||"";var n,s,a=[];for(s in"string"!=typeof t&&(t="?"),e)if(i.call(e,s)){if((n=e[s])||null!==n&&n!==o&&!isNaN(n)||(n=""),s=r(s),n=r(n),null===s||null===n)continue;a.push(s+"="+n)}return a.length?t+a.join("&"):""},n.parse=function(e){for(var t,n=/([^=?#&]+)=?([^&]*)/g,o={};t=n.exec(e);){var i=s(t[1]),r=s(t[2]);null===i||null===r||i in o||(o[i]=r)}return o}},{}],9:[function(e,t,n){var o=e("eventemitter3"),i=e("millisecond"),s=e("demolish"),r=e("tick-tock"),a=e("one-time");function l(e,t,n){return i(e in n?n[e]:e in t?t[e]:d[e])}function d(e){var t=this;if(!(t instanceof d))return new d(e);e=e||{},t.attempt=null,t._fn=null,t["reconnect timeout"]=l("reconnect timeout",t,e),t.retries=l("retries",t,e),t.factor=l("factor",t,e),t.max=l("max",t,e),t.min=l("min",t,e),t.timers=new r(t)}d.prototype=new o,d.prototype.constructor=d,d["reconnect timeout"]="30 seconds",d.max=1/0,d.min="500 ms",d.retries=10,d.factor=2,d.prototype.reconnect=function(){var e=this;return e.backoff((function(t,n){if(n.duration=+new Date-n.start,t)return e.emit("reconnect failed",t,n);e.emit("reconnected",n)}),e.attempt)},d.prototype.backoff=function(e,t){var n=this;return(t=t||n.attempt||{}).backoff?n:(t["reconnect timeout"]=l("reconnect timeout",n,t),t.retries=l("retries",n,t),t.factor=l("factor",n,t),t.max=l("max",n,t),t.min=l("min",n,t),t.start=+t.start||+new Date,t.duration=+t.duration||0,t.attempt=+t.attempt||0,t.attempt===t.retries?(e.call(n,new Error("Unable to recover"),t),n):(t.backoff=!0,t.attempt++,n.attempt=t,t.scheduled=1!==t.attempt?Math.min(Math.round((Math.random()+1)*t.min*Math.pow(t.factor,t.attempt-1)),t.max):t.min,n.timers.setTimeout("reconnect",(function(){t.duration=+new Date-t.start,t.backoff=!1,n.timers.clear("reconnect, timeout");var o=n._fn=a((function(o){if(n.reset(),o)return n.backoff(e,t);e.call(n,void 0,t)}));n.emit("reconnect",t,o),n.timers.setTimeout("timeout",(function(){var e=new Error("Failed to reconnect in a timely manner");t.duration=+new Date-t.start,n.emit("reconnect timeout",e,t),o(e)}),t["reconnect timeout"])}),t.scheduled),n.emit("reconnect scheduled",t),n))},d.prototype.reconnecting=function(){return!!this.attempt},d.prototype.reconnected=function(e){return this._fn&&this._fn(e),this},d.prototype.reset=function(){return this._fn=this.attempt=null,this.timers.clear("reconnect, timeout"),this},d.prototype.destroy=s("timers attempt _fn"),t.exports=d},{demolish:1,eventemitter3:10,millisecond:5,"one-time":6,"tick-tock":12}],10:[function(e,t,n){var o="function"!=typeof Object.create&&"~";function i(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function s(){}s.prototype._events=void 0,s.prototype.listeners=function(e,t){var n=o?o+e:e,i=this._events&&this._events[n];if(t)return!!i;if(!i)return[];if(i.fn)return[i.fn];for(var s=0,r=i.length,a=new Array(r);s<r;s++)a[s]=i[s].fn;return a},s.prototype.emit=function(e,t,n,i,s,r){var a=o?o+e:e;if(!this._events||!this._events[a])return!1;var l,d,c=this._events[a],h=arguments.length;if("function"==typeof c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),h){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,n),!0;case 4:return c.fn.call(c.context,t,n,i),!0;case 5:return c.fn.call(c.context,t,n,i,s),!0;case 6:return c.fn.call(c.context,t,n,i,s,r),!0}for(d=1,l=new Array(h-1);d<h;d++)l[d-1]=arguments[d];c.fn.apply(c.context,l)}else{var u,g=c.length;for(d=0;d<g;d++)switch(c[d].once&&this.removeListener(e,c[d].fn,void 0,!0),h){case 1:c[d].fn.call(c[d].context);break;case 2:c[d].fn.call(c[d].context,t);break;case 3:c[d].fn.call(c[d].context,t,n);break;default:if(!l)for(u=1,l=new Array(h-1);u<h;u++)l[u-1]=arguments[u];c[d].fn.apply(c[d].context,l)}}return!0},s.prototype.on=function(e,t,n){var s=new i(t,n||this),r=o?o+e:e;return this._events||(this._events=o?{}:Object.create(null)),this._events[r]?this._events[r].fn?this._events[r]=[this._events[r],s]:this._events[r].push(s):this._events[r]=s,this},s.prototype.once=function(e,t,n){var s=new i(t,n||this,!0),r=o?o+e:e;return this._events||(this._events=o?{}:Object.create(null)),this._events[r]?this._events[r].fn?this._events[r]=[this._events[r],s]:this._events[r].push(s):this._events[r]=s,this},s.prototype.removeListener=function(e,t,n,i){var s=o?o+e:e;if(!this._events||!this._events[s])return this;var r=this._events[s],a=[];if(t)if(r.fn)(r.fn!==t||i&&!r.once||n&&r.context!==n)&&a.push(r);else for(var l=0,d=r.length;l<d;l++)(r[l].fn!==t||i&&!r[l].once||n&&r[l].context!==n)&&a.push(r[l]);return a.length?this._events[s]=1===a.length?a[0]:a:delete this._events[s],this},s.prototype.removeAllListeners=function(e){return this._events?(e?delete this._events[o?o+e:e]:this._events=o?{}:Object.create(null),this):this},s.prototype.off=s.prototype.removeListener,s.prototype.addListener=s.prototype.on,s.prototype.setMaxListeners=function(){return this},s.prefixed=o,void 0!==t&&(t.exports=s)},{}],11:[function(e,t,n){t.exports=function(e,t){if(t=t.split(":")[0],!(e=+e))return!1;switch(t){case"http":case"ws":return 80!==e;case"https":case"wss":return 443!==e;case"ftp":return 21!==e;case"gopher":return 70!==e;case"file":return!1}return 0!==e}},{}],12:[function(e,t,n){(function(n,o){(function(){var i=Object.prototype.hasOwnProperty,s=e("millisecond");function r(e,t,n,o){this.start=+new Date,this.duration=n,this.clear=t,this.timer=e,this.fns=[o]}function a(e){clearTimeout(e)}function l(e){clearInterval(e)}function d(e){o(e)}function c(e){if(!(this instanceof c))return new c(e);this.timers={},this.context=e||this}r.prototype.remaining=function(){return this.duration-this.taken()},r.prototype.taken=function(){return+new Date-this.start},c.prototype.tock=function(e,t){var n=this;return function(){if(e in n.timers){var o=n.timers[e].fns.slice(),i=o.length,s=0;for(t?n.clear(e):n.start=+new Date;s<i;s++)o[s].call(n.context)}}},c.prototype.setTimeout=function(e,t,n){var o,i=this;return i.timers[e]?(i.timers[e].fns.push(t),i):(o=s(n),i.timers[e]=new r(setTimeout(i.tock(e,!0),s(n)),a,o,t),i)},c.prototype.setInterval=function(e,t,n){var o,i=this;return i.timers[e]?(i.timers[e].fns.push(t),i):(o=s(n),i.timers[e]=new r(setInterval(i.tock(e),s(n)),l,o,t),i)},c.prototype.setImmediate=function(e,t){var o=this;return"function"!=typeof n?o.setTimeout(e,t,0):o.timers[e]?(o.timers[e].fns.push(t),o):(o.timers[e]=new r(n(o.tock(e,!0)),d,0,t),o)},c.prototype.active=function(e){return e in this.timers},c.prototype.clear=function(){var e,t,n,o=arguments.length?arguments:[],s=this;if(1===o.length&&"string"==typeof o[0]&&(o=o[0].split(/[, ]+/)),!o.length)for(e in s.timers)i.call(s.timers,e)&&o.push(e);for(t=0,n=o.length;t<n;t++)(e=s.timers[o[t]])&&(e.clear(e.timer),e.fns=e.timer=e.clear=null,delete s.timers[o[t]]);return s},c.prototype.adjust=function(e,t){var n,o=this,i=s(t),r=o.timers[e];return r?(n=r.clear===l,r.clear(r.timer),r.start=+new Date,r.duration=i,r.timer=(n?setInterval:setTimeout)(o.tock(e,!n),i),o):o},c.prototype.end=c.prototype.destroy=function(){return!!this.context&&(this.clear(),this.context=this.timers=null,!0)},c.Timer=r,t.exports=c}).call(this)}).call(this,e("timers").setImmediate,e("timers").clearImmediate)},{millisecond:5,timers:13}],13:[function(e,t,n){(function(t,o){(function(){var i=e("process/browser.js").nextTick,s=Function.prototype.apply,r=Array.prototype.slice,a={},l=0;function d(e,t){this._id=e,this._clearFn=t}n.setTimeout=function(){return new d(s.call(setTimeout,window,arguments),clearTimeout)},n.setInterval=function(){return new d(s.call(setInterval,window,arguments),clearInterval)},n.clearTimeout=n.clearInterval=function(e){e.close()},d.prototype.unref=d.prototype.ref=function(){},d.prototype.close=function(){this._clearFn.call(window,this._id)},n.enroll=function(e,t){clearTimeout(e._idleTimeoutId),e._idleTimeout=t},n.unenroll=function(e){clearTimeout(e._idleTimeoutId),e._idleTimeout=-1},n._unrefActive=n.active=function(e){clearTimeout(e._idleTimeoutId);var t=e._idleTimeout;t>=0&&(e._idleTimeoutId=setTimeout((function(){e._onTimeout&&e._onTimeout()}),t))},n.setImmediate="function"==typeof t?t:function(e){var t=l++,o=!(arguments.length<2)&&r.call(arguments,1);return a[t]=!0,i((function(){a[t]&&(o?e.apply(null,o):e.call(null),n.clearImmediate(t))})),t},n.clearImmediate="function"==typeof o?o:function(e){delete a[e]}}).call(this)}).call(this,e("timers").setImmediate,e("timers").clearImmediate)},{"process/browser.js":7,timers:13}],14:[function(e,t,n){(function(n){(function(){var o=e("requires-port"),i=e("querystringify"),s=/^[A-Za-z][A-Za-z0-9+-.]*:\/\//,r=/^([a-z][a-z0-9.+-]*:)?(\/\/)?([\\/]+)?([\S\s]*)/i,a=/^[a-zA-Z]:/,l=new RegExp("^[\\x09\\x0A\\x0B\\x0C\\x0D\\x20\\xA0\\u1680\\u180E\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200A\\u202F\\u205F\\u3000\\u2028\\u2029\\uFEFF]+");function d(e){return(e||"").toString().replace(l,"")}var c=[["#","hash"],["?","query"],function(e,t){return g(t.protocol)?e.replace(/\\/g,"/"):e},["/","pathname"],["@","auth",1],[NaN,"host",void 0,1,1],[/:(\d+)$/,"port",void 0,1],[NaN,"hostname",void 0,1,1]],h={hash:1,query:1};function u(e){var t,o=("undefined"!=typeof window?window:void 0!==n?n:"undefined"!=typeof self?self:{}).location||{},i={},r=typeof(e=e||o);if("blob:"===e.protocol)i=new m(unescape(e.pathname),{});else if("string"===r)for(t in i=new m(e,{}),h)delete i[t];else if("object"===r){for(t in e)t in h||(i[t]=e[t]);void 0===i.slashes&&(i.slashes=s.test(e.href))}return i}function g(e){return"file:"===e||"ftp:"===e||"http:"===e||"https:"===e||"ws:"===e||"wss:"===e}function p(e,t){e=d(e),t=t||{};var n,o=r.exec(e),i=o[1]?o[1].toLowerCase():"",s=!!o[2],a=!!o[3],l=0;return s?a?(n=o[2]+o[3]+o[4],l=o[2].length+o[3].length):(n=o[2]+o[4],l=o[2].length):a?(n=o[3]+o[4],l=o[3].length):n=o[4],"file:"===i?l>=2&&(n=n.slice(2)):g(i)?n=o[4]:i?s&&(n=n.slice(2)):l>=2&&g(t.protocol)&&(n=o[4]),{protocol:i,slashes:s||g(i),slashesCount:l,rest:n}}function m(e,t,n){if(e=d(e),!(this instanceof m))return new m(e,t,n);var s,r,l,h,f,v,b=c.slice(),y=typeof t,w=this,E=0;for("object"!==y&&"string"!==y&&(n=t,t=null),n&&"function"!=typeof n&&(n=i.parse),s=!(r=p(e||"",t=u(t))).protocol&&!r.slashes,w.slashes=r.slashes||s&&t.slashes,w.protocol=r.protocol||t.protocol||"",e=r.rest,("file:"===r.protocol&&(2!==r.slashesCount||a.test(e))||!r.slashes&&(r.protocol||r.slashesCount<2||!g(w.protocol)))&&(b[3]=[/(.*)/,"pathname"]);E<b.length;E++)"function"!=typeof(h=b[E])?(l=h[0],v=h[1],l!=l?w[v]=e:"string"==typeof l?~(f=e.indexOf(l))&&("number"==typeof h[2]?(w[v]=e.slice(0,f),e=e.slice(f+h[2])):(w[v]=e.slice(f),e=e.slice(0,f))):(f=l.exec(e))&&(w[v]=f[1],e=e.slice(0,f.index)),w[v]=w[v]||s&&h[3]&&t[v]||"",h[4]&&(w[v]=w[v].toLowerCase())):e=h(e,w);n&&(w.query=n(w.query)),s&&t.slashes&&"/"!==w.pathname.charAt(0)&&(""!==w.pathname||""!==t.pathname)&&(w.pathname=function(e,t){if(""===e)return t;for(var n=(t||"/").split("/").slice(0,-1).concat(e.split("/")),o=n.length,i=n[o-1],s=!1,r=0;o--;)"."===n[o]?n.splice(o,1):".."===n[o]?(n.splice(o,1),r++):r&&(0===o&&(s=!0),n.splice(o,1),r--);return s&&n.unshift(""),"."!==i&&".."!==i||n.push(""),n.join("/")}(w.pathname,t.pathname)),"/"!==w.pathname.charAt(0)&&g(w.protocol)&&(w.pathname="/"+w.pathname),o(w.port,w.protocol)||(w.host=w.hostname,w.port=""),w.username=w.password="",w.auth&&(h=w.auth.split(":"),w.username=h[0]||"",w.password=h[1]||""),w.origin="file:"!==w.protocol&&g(w.protocol)&&w.host?w.protocol+"//"+w.host:"null",w.href=w.toString()}m.prototype={set:function(e,t,n){var s=this;switch(e){case"query":"string"==typeof t&&t.length&&(t=(n||i.parse)(t)),s[e]=t;break;case"port":s[e]=t,o(t,s.protocol)?t&&(s.host=s.hostname+":"+t):(s.host=s.hostname,s[e]="");break;case"hostname":s[e]=t,s.port&&(t+=":"+s.port),s.host=t;break;case"host":s[e]=t,/:\d+$/.test(t)?(t=t.split(":"),s.port=t.pop(),s.hostname=t.join(":")):(s.hostname=t,s.port="");break;case"protocol":s.protocol=t.toLowerCase(),s.slashes=!n;break;case"pathname":case"hash":if(t){var r="pathname"===e?"/":"#";s[e]=t.charAt(0)!==r?r+t:t}else s[e]=t;break;default:s[e]=t}for(var a=0;a<c.length;a++){var l=c[a];l[4]&&(s[l[1]]=s[l[1]].toLowerCase())}return s.origin="file:"!==s.protocol&&g(s.protocol)&&s.host?s.protocol+"//"+s.host:"null",s.href=s.toString(),s},toString:function(e){e&&"function"==typeof e||(e=i.stringify);var t,n=this,o=n.protocol;o&&":"!==o.charAt(o.length-1)&&(o+=":");var s=o+(n.slashes||g(n.protocol)?"//":"");return n.username&&(s+=n.username,n.password&&(s+=":"+n.password),s+="@"),s+=n.host+n.pathname,(t="object"==typeof n.query?e(n.query):n.query)&&(s+="?"!==t.charAt(0)?"?"+t:t),n.hash&&(s+=n.hash),s}},m.extractProtocol=p,m.location=u,m.trimLeft=d,m.qs=i,t.exports=m}).call(this)}).call(this,void 0!==ce?ce:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{querystringify:8,"requires-port":11}],15:[function(e,t,n){var o,i="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),s=64,r={},a=0,l=0;function d(e){var t="";do{t=i[e%s]+t,e=Math.floor(e/s)}while(e>0);return t}function c(){var e=d(+new Date);return e!==o?(a=0,o=e):e+"."+d(a++)}for(;l<s;l++)r[i[l]]=l;c.encode=d,c.decode=function(e){var t=0;for(l=0;l<e.length;l++)t=t*s+r[e.charAt(l)];return t},t.exports=c},{}],16:[function(e,t,n){var o,i=e("eventemitter3"),s=e("tick-tock"),r=e("recovery"),a=e("querystringify"),l=e("inherits"),d=e("demolish"),c=e("yeast"),h=/\u2028/g,u=/\u2029/g;function g(e,t){if(!(e instanceof p)){var n=new Error("Primus#"+t+"'s context should called with a Primus instance");if("function"!=typeof e.listeners||!e.listeners("error").length)throw n;e.emit("error",n)}}try{o=location.origin?location.origin:location.protocol+"//"+location.host}catch(e){o="http://127.0.0.1"}function p(e,t){if(!(this instanceof p))return new p(e,t);if(p.Stream.call(this),"function"!=typeof this.client)return this.critical(new Error("The client library has not been compiled correctly, see https://github.com/primus/primus#client-library for more details"));if("object"==typeof e?e=(t=e).url||t.uri||o:t=t||{},"ping"in t||"pong"in t)return this.critical(new Error("The `ping` and `pong` options have been removed"));var n=this;t.queueSize="queueSize"in t?t.queueSize:1/0,t.timeout="timeout"in t?t.timeout:1e4,t.reconnect="reconnect"in t?t.reconnect:{},t.pingTimeout="pingTimeout"in t?t.pingTimeout:45e3,t.strategy="strategy"in t?t.strategy:[],t.transport="transport"in t?t.transport:{},n.buffer=[],n.writable=!0,n.readable=!0,n.url=n.parse(e||o),n.readyState=p.CLOSED,n.options=t,n.timers=new s(this),n.socket=null,n.disconnect=!1,n.transport=t.transport,n.transformers={outgoing:[],incoming:[]},n.recovery=new r(t.reconnect),"string"==typeof t.strategy&&(t.strategy=t.strategy.split(/\s?,\s?/g)),!1===t.strategy?t.strategy=[]:t.strategy.length||(t.strategy.push("disconnect","online"),this.authorization||t.strategy.push("timeout")),t.strategy=t.strategy.join(",").toLowerCase(),"websockets"in t&&(n.AVOID_WEBSOCKETS=!t.websockets),"network"in t&&(n.NETWORK_EVENTS=t.network),t.manual||n.timers.setTimeout("open",(function(){n.timers.clear("open"),n.open()}),0),n.initialise(t)}p.requires=p.require=function(t){if("function"==typeof e)return e(t)};try{p.Stream=p.requires("stream")}catch(e){}p.Stream||(p.Stream=i),l(p,p.Stream),p.OPENING=1,p.CLOSED=2,p.OPEN=3,p.prototype.AVOID_WEBSOCKETS=!1,p.prototype.NETWORK_EVENTS=!1,p.prototype.online=!0;try{(p.prototype.NETWORK_EVENTS="onLine"in navigator&&(window.addEventListener||document.body.attachEvent))&&(navigator.onLine||(p.prototype.online=!1))}catch(e){}if(p.prototype.ark={},p.prototype.emits=e("emits"),p.prototype.plugin=function(e){if(g(this,"plugin"),e)return this.ark[e];var t={};for(e in this.ark)t[e]=this.ark[e];return t},p.prototype.reserved=function(e){return/^(incoming|outgoing)::/.test(e)||e in this.reserved.events},p.prototype.reserved.events={"reconnect scheduled":1,"reconnect timeout":1,readyStateChange:1,"reconnect failed":1,reconnected:1,reconnect:1,offline:1,timeout:1,destroy:1,online:1,error:1,close:1,open:1,data:1,end:1},p.prototype.initialise=function(e){var t=this;for(var n in t.recovery.on("reconnected",t.emits("reconnected")).on("reconnect failed",t.emits("reconnect failed",(function(e){t.emit("end"),e()}))).on("reconnect timeout",t.emits("reconnect timeout")).on("reconnect scheduled",t.emits("reconnect scheduled")).on("reconnect",t.emits("reconnect",(function(e){t.emit("outgoing::reconnect"),e()}))),t.on("outgoing::open",(function(){var e=t.readyState;t.readyState=p.OPENING,e!==t.readyState&&t.emit("readyStateChange","opening")})),t.on("incoming::open",(function(){var e=t.readyState;if(t.recovery.reconnecting()&&t.recovery.reconnected(),t.writable=!0,t.readable=!0,t.online||(t.online=!0,t.emit("online")),t.readyState=p.OPEN,e!==t.readyState&&t.emit("readyStateChange","open"),t.heartbeat(),t.buffer.length){var n=t.buffer.slice(),o=n.length,i=0;for(t.buffer.length=0;i<o;i++)t._write(n[i])}t.emit("open")})),t.on("incoming::ping",(function(e){t.online=!0,t.heartbeat(),t.emit("outgoing::pong",e),t._write("primus::pong::"+e)})),t.on("incoming::error",(function(e){var n=t.timers.active("connect"),o=e;if("string"==typeof e)o=new Error(e);else if(!(e instanceof Error)&&"object"==typeof e)for(var i in o=new Error(e.message||e.reason),e)Object.prototype.hasOwnProperty.call(e,i)&&(o[i]=e[i]);if(t.recovery.reconnecting())return t.recovery.reconnected(o);t.listeners("error").length&&t.emit("error",o),n&&(~t.options.strategy.indexOf("timeout")?t.recovery.reconnect():t.end())})),t.on("incoming::data",(function(e){t.decoder(e,(function(n,o){if(n)return t.listeners("error").length&&t.emit("error",n);t.protocol(o)||t.transforms(t,t,"incoming",o,e)}))})),t.on("incoming::end",(function(){var e=t.readyState;return t.disconnect?(t.disconnect=!1,t.end()):(t.readyState=p.CLOSED,e!==t.readyState&&t.emit("readyStateChange","end"),t.timers.active("connect")&&t.end(),e!==p.OPEN?!!t.recovery.reconnecting()&&t.recovery.reconnect():(this.writable=!1,this.readable=!1,this.timers.clear(),t.emit("close"),~t.options.strategy.indexOf("disconnect")?t.recovery.reconnect():(t.emit("outgoing::end"),void t.emit("end"))))})),t.client(),t.ark)t.ark[n].call(t,t,e);return t.NETWORK_EVENTS?(t.offlineHandler=function(){t.online&&(t.online=!1,t.emit("offline"),t.end(),t.recovery.reset())},t.onlineHandler=function(){t.online||(t.online=!0,t.emit("online"),~t.options.strategy.indexOf("online")&&t.recovery.reconnect())},window.addEventListener?(window.addEventListener("offline",t.offlineHandler,!1),window.addEventListener("online",t.onlineHandler,!1)):document.body.attachEvent&&(document.body.attachEvent("onoffline",t.offlineHandler),document.body.attachEvent("ononline",t.onlineHandler)),t):t},p.prototype.protocol=function(e){if("string"!=typeof e||0!==e.indexOf("primus::"))return!1;var t=e.indexOf(":",8),n=e.slice(t+2);switch(e.slice(8,t)){case"ping":this.emit("incoming::ping",+n);break;case"server":"close"===n&&(this.disconnect=!0);break;case"id":this.emit("incoming::id",n);break;default:return!1}return!0},p.prototype.transforms=function(e,t,n,o,i){var s={data:o},r=e.transformers[n];return function e(n,o){var i=r[n++];if(!i)return o();if(1===i.length){if(!1===i.call(t,s))return;return e(n,o)}i.call(t,s,(function(i,s){if(i)return t.emit("error",i);!1!==s&&e(n,o)}))}(0,(function(){if("incoming"===n)return t.emit("data",s.data,i);t._write(s.data)})),this},p.prototype.id=function(e){return this.socket&&this.socket.id?e(this.socket.id):(this._write("primus::id::"),this.once("incoming::id",e))},p.prototype.open=function(){return g(this,"open"),!this.recovery.reconnecting()&&this.options.timeout&&this.timeout(),this.emit("outgoing::open"),this},p.prototype.write=function(e){return g(this,"write"),this.transforms(this,this,"outgoing",e),!0},p.prototype._write=function(e){var t=this;return p.OPEN!==t.readyState?(this.buffer.length===this.options.queueSize&&this.buffer.splice(0,1),this.buffer.push(e),!1):(t.encoder(e,(function(e,n){if(e)return t.listeners("error").length&&t.emit("error",e);"string"==typeof n&&(~n.indexOf("\u2028")&&(n=n.replace(h,"\\u2028")),~n.indexOf("\u2029")&&(n=n.replace(u,"\\u2029"))),t.emit("outgoing::data",n)})),!0)},p.prototype.heartbeat=function(){return this.options.pingTimeout?(this.timers.clear("heartbeat"),this.timers.setTimeout("heartbeat",(function(){this.online&&(this.online=!1,this.emit("offline"),this.emit("incoming::end"))}),this.options.pingTimeout),this):this},p.prototype.timeout=function(){var e=this;function t(){e.removeListener("error",t).removeListener("open",t).removeListener("end",t).timers.clear("connect")}return e.timers.setTimeout("connect",(function(){t(),e.readyState===p.OPEN||e.recovery.reconnecting()||(e.emit("timeout"),~e.options.strategy.indexOf("timeout")?e.recovery.reconnect():e.end())}),e.options.timeout),e.on("error",t).on("open",t).on("end",t)},p.prototype.end=function(e){if(g(this,"end"),this.readyState===p.CLOSED&&!this.timers.active("connect")&&!this.timers.active("open"))return this.recovery.reconnecting()&&(this.recovery.reset(),this.emit("end")),this;void 0!==e&&this.write(e),this.writable=!1,this.readable=!1;var t=this.readyState;return this.readyState=p.CLOSED,t!==this.readyState&&this.emit("readyStateChange","end"),this.timers.clear(),this.emit("outgoing::end"),this.emit("close"),this.emit("end"),this},p.prototype.destroy=d("url timers options recovery socket transport transformers",{before:"end",after:["removeAllListeners",function(){this.NETWORK_EVENTS&&(window.addEventListener?(window.removeEventListener("offline",this.offlineHandler),window.removeEventListener("online",this.onlineHandler)):document.body.attachEvent&&(document.body.detachEvent("onoffline",this.offlineHandler),document.body.detachEvent("ononline",this.onlineHandler)))}]}),p.prototype.clone=function(e){return this.merge({},e)},p.prototype.merge=function(e){for(var t,n,o=1;o<arguments.length;o++)for(t in n=arguments[o])Object.prototype.hasOwnProperty.call(n,t)&&(e[t]=n[t]);return e},p.prototype.parse=e("url-parse"),p.prototype.querystring=a.parse,p.prototype.querystringify=a.stringify,p.prototype.uri=function(e){var t=this.url,n=[],o=!1;e.query&&(o=!0),(e=e||{}).protocol="protocol"in e?e.protocol:"http:",e.query=!(!t.query||!o)&&t.query.slice(1),e.secure="secure"in e?e.secure:"https:"===t.protocol||"wss:"===t.protocol,e.auth="auth"in e?e.auth:t.auth,e.pathname="pathname"in e?e.pathname:this.pathname,e.port="port"in e?+e.port:+t.port||(e.secure?443:80);var i=this.querystring(e.query||"");return i._primuscb=c(),e.query=this.querystringify(i),this.emit("outgoing::url",e),n.push(e.secure?e.protocol.replace(":","s:"):e.protocol,""),n.push(e.auth?e.auth+"@"+t.host:t.host),e.pathname&&n.push(e.pathname.slice(1)),o?n[n.length-1]+="?"+e.query:delete e.query,e.object?e:n.join("/")},p.prototype.transform=function(e,t){return g(this,"transform"),e in this.transformers?(this.transformers[e].push(t),this):this.critical(new Error("Invalid transformer type"))},p.prototype.critical=function(e){if(this.emit("error",e))return this;throw e},p.connect=function(e,t){return new p(e,t)},p.EventEmitter=i,p.prototype.client=function(){var e,t=this,n=function(){if("undefined"!=typeof WebSocket)return WebSocket;if("undefined"!=typeof MozWebSocket)return MozWebSocket;try{return p.requires("ws")}catch(e){}}();if(!n)return t.critical(new Error("Missing required `ws` module. Please run `npm install --save ws`"));t.on("outgoing::open",(function(){t.emit("outgoing::end");try{var o={protocol:"ws+unix:"===t.url.protocol?"ws+unix:":"ws:",query:!0};3===n.length?("ws+unix:"===o.protocol&&(o.pathname="/"+t.url.hostname+t.url.pathname+":"+t.pathname),t.socket=e=new n(t.uri(o),[],t.transport)):(t.socket=e=new n(t.uri(o)),e.binaryType="arraybuffer")}catch(e){return t.emit("error",e)}e.onopen=t.emits("incoming::open"),e.onerror=t.emits("incoming::error"),e.onclose=t.emits("incoming::end"),e.onmessage=t.emits("incoming::data",(function(e,t){e(void 0,t.data)}))})),t.on("outgoing::data",(function(o){if(e&&e.readyState===n.OPEN)try{e.send(o)}catch(e){t.emit("incoming::error",e)}})),t.on("outgoing::reconnect",(function(){t.emit("outgoing::open")})),t.on("outgoing::end",(function(){e&&(e.onerror=e.onopen=e.onclose=e.onmessage=function(){},e.close(),e=null)}))},p.prototype.authorization=!1,p.prototype.pathname="/cobrowse",p.prototype.encoder=function(e,t){var n;try{e=JSON.stringify(e)}catch(e){n=e}t(n,e)},p.prototype.decoder=function(e,t){var n;if("string"!=typeof e)return t(n,e);try{e=JSON.parse(e)}catch(e){n=e}t(n,e)},p.prototype.version="8.0.5","undefined"!=typeof document&&"undefined"!=typeof navigator){document.addEventListener&&document.addEventListener("keydown",(function(e){27===e.keyCode&&e.preventDefault&&e.preventDefault()}),!1);var m=(navigator.userAgent||"").toLowerCase(),f=m.match(/.+(?:rv|it|ra|ie)[/: ](\d+)\.(\d+)(?:\.(\d+))?/)||[],v=+[f[1],f[2]].join(".");!~m.indexOf("chrome")&&~m.indexOf("safari")&&v<534.54&&(p.prototype.AVOID_WEBSOCKETS=!0)}t.exports=p},{demolish:1,emits:2,eventemitter3:3,inherits:4,querystringify:8,recovery:9,"tick-tock":12,"url-parse":14,yeast:15}]},{},[16])(16);return e.prototype.ark.emit=function(e){var t=Object.prototype.toString,n=e.emit;e.transform("incoming",(function(o){var i=o.data;if(this===e&&"object"==typeof i&&~t.call(i.emit).indexOf(" Array]"))return this.reserved(i.emit[0])||n.apply(e,i.emit),!1})),e.emit=function(t){return e.reserved(t)||"newListener"===t||"removeListener"===t?n.apply(this,arguments):(e.write({emit:Array.prototype.slice.call(arguments,0)}),!0)}},e}),[]);var pe=ge.exports; /*! ***************************************************************************** Copyright (c) Microsoft Corporation. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */function me(e,t,n,o){return new(n||(n=Promise))((function(i,s){function r(e){try{l(o.next(e))}catch(e){s(e)}}function a(e){try{l(o.throw(e))}catch(e){s(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(r,a)}l((o=o.apply(e,t||[])).next())}))}const fe={strategy:"disconnect",reconnect:{retries:30,max:4e3,min:500}};class ve{constructor(e,t,n){this.networkPromiseTimeout=5e3,this.id=n,this.role=t,this.apiUrl=e,this.handlersMap=new Map,this.connected=!1}setWebsocketUrl(e){this.websocketUrl=e}subscribe(e,t){var n;this.handlersMap.get(e)||this.handlersMap.set(e,[]),null===(n=this.handlersMap.get(e))||void 0===n||n.push(t)}send(e,t){if(!this.socket)throw new Error("Trying to send data before connection is open");if(!e)throw new Error("Please define a topic for sending data");if(!this.connected)throw new Error("Trying to send data before connecting");this.socket.emit("cb:data",{topic:e,data:t})}onEvent(e,t){this.socket&&this.socket.once(e,t)}close(){if(!this.socket)throw new Error("socket already closed");this.socket.end(),this.connected=!1}_dataHandler(e){const t=e,n=this.handlersMap.get(t.topic);n?n.forEach((e=>{var n;e(null!==(n=t.data)&&void 0!==n?n:{})})):this.log(`got message with topic "${t.topic}" but can't find handler for it, ${JSON.stringify(t)}`)}_errorHandler(e){const t=e;this.log(`Error ${t.code}: ${t.message}`),this._dataHandler({topic:t.code,data:t.message})}_listenSocket(){this.socket&&(this.socket.on("cb:data",this._dataHandler.bind(this)),this.socket.on("cb:error",this._errorHandler.bind(this)))}_connect(e){return me(this,void 0,void 0,(function*(){this.connected?this.log(`User ${String(this._id())} is already connected. Role: ${this.role}.`):(this.socket=this.createSocket(null!=e?e:fe),this._listenSocket(),yield this.registerSocketEventHandlers())}))}registerSocketEventHandlers(){return me(this,void 0,void 0,(function*(){const e=new Promise(((e,t)=>{if(!this.socket)throw new Error("Socket should be created before connecting");this.socket.once("open",(()=>{var n;this.awaitConnectionAcknowledged().then((()=>e(null))).catch((e=>t(e))),null===(n=this.socket)||void 0===n||n.once("cb:error",(e=>{t(e)}))})),this.socket.once("error",(e=>{t(e)})),this.socket.on("reconnected",(()=>{this.reconnect().then((()=>e(null))).catch((e=>t(e)))}))}));return this.promiseWithTimeout(e,this.networkPromiseTimeout)}))}reconnect(){return me(this,void 0,void 0,(function*(){const e=new Promise(((e,t)=>{this.awaitConnectionAcknowledged().then((()=>{this.log(`User: ${this._id()} reconnected. Role: ${this.role}`),e(null)})).catch((e=>t(e)))}));return this.promiseWithTimeout(e,this.networkPromiseTimeout)}))}awaitConnectionAcknowledged(){return me(this,void 0,void 0,(function*(){yield this._awaitMessageAcknowledged("open"),this._auth()}))}_auth(){var e,t,n;this.socket?(null===(e=this.socket)||void 0===e||e.emit("cb:auth",{id:this._id(),role:this.role}),null===(t=this.socket)||void 0===t||t.once("cb:id",(e=>this._assignId(e.id))),this.connected=!0):this.log(`There is no socket connected for ${null!==(n=this._id())&&void 0!==n?n:"unknown"}`)}_assignId(e){this.log(`User ID assigned (${e})`),this.id=e}_id(){var e;return null!==(e=null==this?void 0:this.id)&&void 0!==e?e:void 0}_awaitMessageAcknowledged(e){return me(this,void 0,void 0,(function*(){const t=new Promise(((t,n)=>{if(!this.socket)throw new Error("Trying to await an ack msg but socket is closed");this.socket.once(`cb:ack:${e}`,(e=>{t(e)})),this.socket.once(`cb:error:${e}`,(t=>{this.log(`_awaitMessageAckowledged(${e}): got error`,t),n(t)})),this.socket.once("end",(()=>{this.log(`_awaitMessageAckowledged(${e}): 'Server closed connection.'`),n(new Error("Server closed connection."))}))}));return this.promiseWithTimeout(t,this.networkPromiseTimeout)}))}promiseWithTimeout(e,t){return me(this,void 0,void 0,(function*(){let n;const o=new Promise(((e,o)=>{n=setTimeout(o,t,new Error("promise timed out"))}));return Promise.race([e,o]).finally((()=>clearTimeout(n)))}))}}class be extends ve{rejoinSession(){return me(this,void 0,void 0,(function*(){this.connected||(yield this._connect());const e=this._awaitMessageAcknowledged("rejoin");this.socket&&this.socket.emit("cb:rejoin",{});const t=yield e;if(!("object"==typeof(n=t)&&n&&n.hasOwnProperty("options")&&n.hasOwnProperty("joinCode")&&"string"==typeof n.joinCode))throw new Error("Wrong data returned on rejoin");var n;return t}))}joinSession(e){return me(this,void 0,void 0,(function*(){if(this.connected||(yield this._connect()),!this.socket)throw new Error("Trying to join session before connection is open");const t=this._awaitMessageAcknowledged("join");this.socket.emit("cb:join",{sessionId:e});const n=yield t;if("object"!=typeof(o=n)||!o||!o.hasOwnProperty("options"))throw new Error("Join response looks wrong");var o;return n}))}leaveSession(){return me(this,void 0,void 0,(function*(){if(!this.socket)throw new Error("Trying to exit session before connection is open");if(!this.connected)throw new Error("Trying to exit session before connecting");const e=this._awaitMessageAcknowledged("leave");return this.socket.emit("cb:leave",{}),yield e,this.close(),e}))}}class ye extends be{constructor({apiUrl:e,storage:t,clientRole:n,level:o}){super(e,n),ye.storage=t,this.log=s("network",o)}createSocket(e){return new pe(this.websocketUrl,e)}leaveSession(){const e=Object.create(null,{leaveSession:{get:()=>super.leaveSession}});return r(this,void 0,void 0,(function*(){this.clearStorage(),yield e.leaveSession.call(this)}))}joinSession(e){const t=Object.create(null,{joinSession:{get:()=>super.joinSession}});return r(this,void 0,void 0,(function*(){try{this.restoreWebSocketUrl();const n=yield t.joinSession.call(this,e);return this.rememberUserId(),n}catch(e){throw this.log("joinSession failed",e),this.clearStorage(),e}}))}rejoinSession(){return this.restoreUserId(),this.restoreWebSocketUrl(),super.rejoinSession()}clearStorage(){ye.storage.removeUserID()}setOfferState(e){ye.storage.setOfferState(e)}getOfferState(e){return ye.storage.getOfferState(e)}rememberUserId(){const e=super._id();if("string"!=typeof e)throw this.log("Unexpected userId: ",e),new Error("Unexpected userId");ye.storage.putUserID(e)}restoreUserId(){if(!this.id){const e=ye.storage.getUserID();if(!e)throw new Error("failed to retrieve clientId from localStorage");this._assignId(e)}}restoreWebSocketUrl(){if(!this.websocketUrl){const e=ye.storage.getWebSocketUrl();if(!e)throw new Error("failed to get websocketUrl from localStorage");this.websocketUrl=e}}}class we extends ye{constructor({apiUrl:e,origin:t,clientRole:n,deploymentId:o,pubsub:i,level:s}){e&&(e.startsWith("http")||e.startsWith("https"))&&(we.storage=new de({origin:t,clientRole:n,level:s})),super({apiUrl:e,storage:we.storage,clientRole:n,pubsub:i,level:s}),this.deploymentId=o}setWebsocketUrl(e){const t=new URL(e);t.searchParams.set("deploymentId",this.deploymentId),super.setWebsocketUrl(t.toString())}fetch(e,t){return fetch(e,t)}cookGetSessionUrl(e){const t=new URL(this.apiUrl);return t.pathname=`/api/v2/webdeployments/deployments/${this.deploymentId}/cobrowse/${e}`,t.toString()}cookDeleteSessionUrl(e){const t=new URL(this.apiUrl);return t.pathname=`/api/v2/webdeployments/deployments/${this.deploymentId}/cobrowse/${e}`,t.toString()}fetchSessionInfo(e){const t=this.cookGetSessionUrl(e);return this.fetch(t,{method:"GET"})}getSessionInfo(e){return r(this,void 0,void 0,(function*(){const t=yield this.fetchSessionInfo(e);if(!t.ok)throw new Error("getting session failed");const n=yield t.json();if(!n.websocketUrl||!n.id||!n.joinCode)throw new Error("get session returned wrong payload");return n}))}deleteSession(e){return r(this,void 0,void 0,(function*(){const t=this.cookDeleteSessionUrl(e);if(!(yield this.fetch(t.toString(),{method:"DELETE"})).ok)throw new Error(`Delete session ${e} failed`)}))}putControlEnabledSession(e){we.storage.putControlEnabledSession(e)}getControlEnabledSession(){return we.storage.getControlEnabledSession()}removeControlEnabledSession(){we.storage.removeControlEnabledSession()}generateCreateSessionUrl(e){throw new Error(`generateCreateSessionUrl(${e}) not implemented`)}createSession(){throw new Error("createSession() not implemented")}getHawkUrl(e){throw new Error(`getHawkUrl(${e}) not implemented`)}connectToHawk(e){throw new Error(`connectToHawk(${e}) not implemented`)}}class Ee extends c{constructor(e,t,n){super(e,t,n),this.serviceDiscovery=t,this.l10n=n,this.dom=new re(this.getDOMRoot(),{ignore:e.ignoredSelectors}),this.primaryColor=e.primaryColor,this.deploymentId=e.deploymentId,this.network=new we({apiUrl:e.apiUrl,origin:this.getWindow().origin,clientRole:this.getRole(),deploymentId:e.deploymentId,pubsub:this.pubsub,level:this.logLevel})}register(e,t){this.modules.set(e,{constructor:t,instance:new t(new le(this,e))})}isInIframeButWantsToBreakFree(){return"GENESYS_COBROWSE_START_IN_TOP_WINDOW"in window}getDOMRoot(){if(this.isInIframeButWantsToBreakFree()){if(!window.top||!window.top.document)throw new Error("Co-browse is configured to run in an iframe but cannot access window.top.document");return window.top.document}return document}getWindow(){if(this.isInIframeButWantsToBreakFree()){if(!window.top)throw new Error("Co-browse is configured to run in an iframe but cannot access window.top");return window.top}return window}getInstrumentedDocument(){return document}getNetwork(){return this.network}getRole(){return"sharer"}getPrimaryColor(){return this.primaryColor}getDeploymentId(){return this.deploymentId}}class Ce{constructor(e){this.sandbox=e,this.maskingClass=".cobrowse-masked",this.readonlyClass=".cobrowse-readonly",this.initialMaskSelectors=[this.maskingClass],this.maskSelectors=this.initialMaskSelectors,this.initialReadonlySelectors=[this.readonlyClass],this.readonlySelectors=this.initialReadonlySelectors}init(){this.sandbox.listen("int:session-ready-for-events",(()=>{const e=this.sandbox.getDeploymentOptions();e.maskSelectors&&this.maskSelectors.push(...e.maskSelectors),e.readonlySelectors&&this.readonlySelectors.push(...e.readonlySelectors),this.sandbox.log("Sharer DOM module initialized...",{maskSelectors:this.maskSelectors,readonlySelectors:this.readonlySelectors});const t=this.sandbox.dom.takeSnapshot(this.maskSelectors,this.readonlySelectors);this.sandbox.network.send("sharer:dom-snapshot",t),this.sandbox.log("sent DOM snapshot",t),this.captureUrl(),this.listenToDomChanges(),this.sandbox.notify("int:dom-initialized");for(const e of this.sandbox.dom.getCobrowsableIframes())this.sandbox.notify("int:dom-new-cobrowsable-iframe",{iframe:e});this.sandbox.dom.onLoadedIframe(((e,t)=>{this.sandbox.notify("int:dom-new-cobrowsable-iframe",{iframe:e}),this.sandbox.network.send("sharer:dom-iframe-changes",t),this.sandbox.log("sent DOM changes",t)}))}))}captureUrl(){const e=this.sandbox.getWindow().location.href;this.sandbox.network.send("sharer:url",{url:e})}listenToDomChanges(){this.sandbox.dom.onChange((e=>{this.filterOutCobrowseChanges(e);try{this.sandbox.network.send("sharer:dom-changes",e),this.sandbox.notify("int:dom-changed"),this.sandbox.log("sent DOM changes",e)}catch(e){this.sandbox.log("not sending anything")}}))}filterOutCobrowseChanges(e){if(e.attributes){const t=e.attributes.filter((e=>{var t,n;return!(null===(n=null===(t=null==e?void 0:e.attributes)||void 0===t?void 0:t.class)||void 0===n?void 0:n.includes(Ce.filterPrefix))}));e.attributes=t}}destroy(){this.sandbox.log("disconnecting the DOM"),this.sandbox.dom.disconnect()}}function Te(e){var t,n,o;return{enableMouseCursors:!1!==(null==e?void 0:e.enableMouseCursors),allowAgentControl:!0===(null==e?void 0:e.allowAgentControl),maskSelectors:null!==(t=null==e?void 0:e.maskSelectors)&&void 0!==t?t:[],readonlySelectors:null!==(n=null==e?void 0:e.readonlySelectors)&&void 0!==n?n:[],allowedDomains:null!==(o=null==e?void 0:e.allowedDomains)&&void 0!==o?o:[]}}Ce.filterPrefix="gcobrowse";class xe{constructor(e){this.sandbox=e,this.isViewerReady=!1,this.handleNetworkEvents()}init(){this.sandbox.listen("int:user-requested-rejoin",(()=>{this.rejoinSession()})),this.sandbox.listen("int:user-requested-join",(e=>{this.joinSession(e.data.joinCode)})),this.sandbox.listen("int:user-requested-stop",(()=>{this.leaveSession()}))}handleNetworkEvents(){this.sandbox.network.subscribe("viewer:ready",(()=>{this.sandbox.notify("int:viewer-ready"),this.sandbox.network.send("session-options",this.sandbox.getDeploymentOptions()),this.isViewerReady||(this.isViewerReady=!0,this.sandbox.notify("int:session-ready-for-events"))})),this.sandbox.network.subscribe("leave",(()=>{this.isViewerReady=!1,this.sandbox.log("viewer left")})),this.sandbox.network.subscribe("session-end",(()=>{this.isViewerReady=!1,this.sandbox.log("session ended by other party"),this.sandbox.notify("int:session-ended-by-viewer"),this.endSession()})),this.sandbox.network.subscribe("session-timeout",(e=>{this.isViewerReady=!1,this.sandbox.log(`disconnected by timeout from session ${null==e?void 0:e.sessionId}`),this.sandbox.notify("int:session-expired",{sessionId:e.sessionId}),this.endSession()})),this.sandbox.network.subscribe("join",(()=>{this.sandbox.log("viewer joined")})),this.sandbox.network.subscribe("viewer:reconnected",(()=>{this.sandbox.log("viewer reconnected"),this.sandbox.notify("int:session-ready-for-events")})),this.sandbox.network.subscribe("session-offering-sent",(e=>{this.sandbox.notify("int:session-offering-sent",{sessionId:e.sessionId,offerTimeout:e.timeout})}))}assumeViewerReady(){this.sandbox.log("assuming viewer is ready"),this.isViewerReady=!0,this.sandbox.notify("int:session-ready-for-events"),this.sandbox.notify("int:viewer-ready")}joinSession(e){var t;return r(this,void 0,void 0,(function*(){let n,o;this.sandbox.log("joinSession, fetching session");try{n=yield this.sandbox.network.getSessionInfo(e)}catch(t){const n=t;return this.sandbox.log.info(`Session with join code: ${e} not found.`),this.sandbox.log(`Error: ${n.message}`),void this.sandbox.notify("int:session-load-failed")}if(!n)return this.sandbox.log.info(`Session with join code: ${e} not found.`),void this.sandbox.notify("int:session-load-failed");this.sandbox.log("joinSession, fetched session",n),this.sandbox.notify("int:session-loaded",{joinCode:e}),this.sandbox.network.setWebsocketUrl(n.websocketUrl);try{o=null===(t=yield this.sandbox.network.joinSession(e))||void 0===t?void 0:t.options}catch(e){return this.sandbox.log.info("Failed while joining session",e),void this.sandbox.notify("int:session-load-failed")}if(!o)return this.sandbox.log("Did not get session options, got:",o),void this.sandbox.notify("int:session-load-failed");this.sandbox.setDeploymentOptions(o),this.sandbox.notify("int:session-options-ready",Te(o)),this.sandbox.network.send("session-deploymentId",{id:this.sandbox.getDeploymentId()}),this.assumeViewerReady();const i=Object.assign({},o);null==i||delete i.agentName,this.sandbox.log.info(`Session options: ${JSON.stringify(i)}`),this.sandbox.notify("int:session-ready",{id:n.id,joinCode:e}),this.sandbox.network.send("ext:sharer-joined",{id:e,deviceType:this.getDeviceInfo()})}))}rejoinSession(){return r(this,void 0,void 0,(function*(){this.sandbox.log("rejoining session");try{const e=yield this.sandbox.network.rejoinSession();this.sandbox.log.info("rejoined session",e);const t=null==e?void 0:e.options;if(!t)throw this.sandbox.log("Did not get session options, got:",t),new Error("Did not get session options");this.sandbox.setDeploymentOptions(t),this.sandbox.notify("int:session-options-ready",Te(t)),this.assumeViewerReady(),this.sandbox.notify("int:session-ready",{id:e.joinCode,joinCode:e.joinCode}),this.sandbox.notify("int:sharer-reconnected",{joinCode:e.joinCode})}catch(e){return this.sandbox.log.info("Failed while rejoining session",e),void this.sandbox.notify("int:session-load-failed")}}))}getDeviceInfo(){let e;const t=navigator.userAgent;return e=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(t)?"Mobile":"Desktop",e}leaveSession(){return r(this,void 0,void 0,(function*(){this.isViewerReady=!1,this.sandbox.network.send("sharer-leave"),this.sandbox.network.send("session-end",{userLeft:"sharer"}),yield this.sandbox.network.leaveSession(),this.endSession()}))}endSession(){this.sandbox.notify("int:session-end");try{this.sandbox.log("closing the socket"),this.sandbox.network.close()}catch(e){this.sandbox.log("socket already closed")}finally{this.sandbox.log("Session ended")}}destroy(){}}class Se{constructor(e){this.sandbox=e,this.listenersAttached=!1,this.iframeListeners=new Map,this.boundOnMouseMove=this.onMouseMove.bind(this),this.sendMouseMove=this.createThrottledCoordsSender()}init(){this.sandbox.listen("int:dom-new-cobrowsable-iframe",(e=>{this.handleIframe(e.data.iframe)}))}attachEventListeners(){this.listenersAttached?this.sandbox.log("listeners already attached, not reattaching"):(this.addMouseMoveListener(),this.addNetworkListener(),this.listenersAttached=!0)}handleIframe(e){const t=e.contentDocument;this.sandbox.log("handling iframe",e),t&&this.addIframeMouseListener(t,e)}addIframeMouseListener(e,t){this.sandbox.log("adding mousemove listener to iframe",t);const n=this.createBoundIframeListener(t);e.addEventListener("mousemove",n),this.iframeListeners.set(t,n)}createBoundIframeListener(e){return(t=>{const n=e.getBoundingClientRect(),o=t.clientX+n.x,i=t.clientY+n.y;this.sendMouseMove({x:o,y:i})}).bind(this)}createThrottledCoordsSender(){let e=!1,t={x:0,y:0};return n=>{e||n.x===t.x||n.y===t.y||(this.sandbox.network.send("ext:mouse-move",n),e=!0,t=n,setTimeout((function(){e=!1}),N))}}addMouseMoveListener(){const e=this.sandbox.getDOMRoot();e&&e.addEventListener("mousemove",this.boundOnMouseMove)}onNetworkMouseMove(e){if("object"!=typeof e||"number"!=typeof e.x||"number"!=typeof e.y)throw new Error(`unexpected network data for "ext:mouse-move": ${JSON.stringify(e)}`);this.sandbox.notify("int:mouse-move",e)}addNetworkListener(){this.sandbox.network.subscribe("ext:mouse-move",this.onNetworkMouseMove.bind(this))}onMouseMove(e){this.sendMouseMove({x:e.clientX,y:e.clientY})}destroy(){this.listenersAttached=!1;const e=this.sandbox.getDOMRoot();null==e||e.removeEventListener("mousemove",this.boundOnMouseMove)}}class Ie extends Se{constructor(e){super(e),this.sandbox=e}init(){this.sandbox.listen("int:viewer-ready",(()=>{this.attachEventListeners()})),super.init()}destroy(){var e;super.destroy();for(const[t,n]of this.iframeListeners)null===(e=null==t?void 0:t.contentDocument)||void 0===e||e.removeEventListener("mousemove",n)}}class Oe{constructor(e){this.sandbox=e,this.i18n=this.sandbox.geti18n()}init(){}destroy(){}}class ke extends Oe{constructor(e){super(e),this.sandbox=e}init(){this.sandbox.network.subscribe("ext:draw-enabled",(()=>{const e=this.getGhostPointer();e&&(e.innerHTML=this.getDrawingCursorHTML())})),this.sandbox.network.subscribe("ext:draw-disabled",(()=>{const e=this.getGhostPointer();e&&(e.innerHTML=this.getPointingCursorHTML())}))}getPointingCursorHTML(){return`<svg\n\t\t\taria-hidden="true" \n\t\t\tclass="genesys-cbx-ignore"\n\t\t\tfill="${this.sandbox.getPrimaryColor()}"\n\t\t\txmlns="http://www.w3.org/2000/svg"\n\t\t\tviewBox="0 0 512 512">\n\t\t\t\t<title>Cobrowse Ghost Pointer</title>\n\t\t\t\t<path id="gcobrowse-ghost-pointer-glyph" d="M449.87,248.29c.94-7.2-2.19-14.71-8.45-18.46L90.74,3A18.21,18.21,0,0,0,71.66,2.4,19.2,19.2,0,0,0,62,19V420a19.28,19.28,0,0,0,10.32,16.9A18.76,18.76,0,0,0,92,435l99.48-74.45,91,142.65a18.72,18.72,0,0,0,16,8.76,20.06,20.06,0,0,0,9.39-2.5l92.91-53.81a18.9,18.9,0,0,0,8.76-11.89A17.83,17.83,0,0,0,407,429.41L322.24,295.84l114.5-32.22a19,19,0,0,0,13.14-15.33ZM287.51,266.43A19.51,19.51,0,0,0,275,277.69a18.94,18.94,0,0,0,1.56,16.9l87.6,138.27-60.38,35L212.12,323.36a18.66,18.66,0,0,0-12.51-8.45,12.88,12.88,0,0,0-3.45-.31,18.76,18.76,0,0,0-11.26,3.75L99.19,382.49V53.39L386.37,238.9Zm0,0" />\n\t\t</svg>${this.getPointerTitleHTML()}`}getDrawingCursorHTML(){return`<svg \n\t\t\tclass="genesys-cbx-ignore" \n\t\t\txmlns="http://www.w3.org/2000/svg"\n\t\t\tfill="${this.sandbox.getPrimaryColor()}"\n\t\t\tviewBox="0 0 24 24">\n\t\t\t\t<title>arrow-pointer-outline-glyph</title>\n\t\t\t\t<path d="M0 0h24v24H0z" fill="none"/><path d="M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04c.39-.39.39-1.02 0-1.41l-2.34-2.34c-.39-.39-1.02-.39-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z"/>\n\t\t</svg>${this.getPointerTitleHTML()}`}getPointerTitleHTML(){return`<span role="complementary" id="${ke.POINTER_TITLE_ID}" class="genesys-cbx-ignore" aria-hidden="true">${this.getPointerTitleText()}</span>`}destroy(){var e;try{null===(e=this.getGhostPointer())||void 0===e||e.remove()}catch(e){this.sandbox.log(`Couldn't find ghost pointer. ${e}`)}}getCursorParent(){return this.getDocument().body}createGhostPointer(){var e;this.getDocument().getElementById(ke.GHOST_POINTER_ID)||null===(e=this.getCursorParent())||void 0===e||e.insertAdjacentHTML("beforeend",`<div id="${ke.GHOST_POINTER_ID}">${this.getPointingCursorHTML()}</div>`)}getGhostPointer(){return this.getDocument().getElementById(ke.GHOST_POINTER_ID)}}ke.GHOST_POINTER_ID="gcobrowse-ghost-pointer",ke.POINTER_TITLE_ID="gcobrowse-ghost-pointer-title",ke.TOOLBAR_ID="gcobrowse-viewer-toolbar",ke.URL_ID="url-area";class De extends ke{constructor(e){super(e),this.sandbox=e}init(){super.init(),this.sandbox.listen("int:viewer-ready",(()=>{this.createGhostPointer()})),this.sandbox.listen("int:mouse-move",(e=>{this.setGhostPointerPosition(e.data)}))}getPointerTitleText(){var e;const t=null===(e=this.sandbox.getDeploymentOptions())||void 0===e?void 0:e.agentName;return t?t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"):this.i18n.viewer}getDocument(){const e=this.sandbox.getDOMRoot();if(!e)throw new Error("Cannot get document");return e}setGhostPointerPosition(e){var t,n;null===(t=this.getGhostPointer())||void 0===t||t.style.setProperty("left",`${e.x}px`),null===(n=this.getGhostPointer())||void 0===n||n.style.setProperty("top",`${e.y}px`)}}class Ne{constructor(e){this.sandbox=e,this.iframeListeners=new Map,this.pointerOnMouseClick=this.onMouseClick.bind(this),this.preventDefault=this.preventDefaultHandler.bind(this),this.controlAllowed=!1,this.viewerZoomValue=1,this.isDrawEnabled=!1,this.listenersAttached=!1}init(){this.sandbox.listen("int:draw-start",(()=>{this.isDrawEnabled=!0})),this.sandbox.listen("int:draw-end",(()=>{this.isDrawEnabled=!1})),this.sandbox.listen("int:control-granted",(()=>{this.controlAllowed=!0})),this.sandbox.listen("int:control-revoked",(()=>{this.controlAllowed=!1})),this.sandbox.listen("int:dom-new-cobrowsable-iframe",(e=>{this.handleIframe(e.data.iframe)}))}handleIframe(e){const t=e.contentDocument;this.sandbox.log("mousclick module handling iframe",e),t&&this.addIframeMouseListener(t,e)}addIframeMouseListener(e,t){this.sandbox.log("adding click listener to iframe",t);const n=this.createBoundIframeListener(t);e.addEventListener("click",n),this.iframeListeners.set(t,n)}createBoundIframeListener(e){throw new Error("method createBoundIframeListener not implemented")}attachEventListeners(){this.listenersAttached?this.sandbox.log("listeners already attached, not reattaching"):(this.handleMouseClick(),this.handleIncomingMouseClick(),this.listenersAttached=!0)}preventDefaultHandler(e){return e.preventDefault(),!1}handleMouseClick(){var e;null===(e=this.sandbox.getDOMRoot())||void 0===e||e.addEventListener("click",this.pointerOnMouseClick)}handleIncomingMouseClick(){this.sandbox.network.subscribe("ext:mouse-click",this.onNetworkMouseClick.bind(this))}sendNodeIdForHighlight(e){if(!this.sandbox.dom.isIgnored(e)&&!this.isDrawEnabled){const t=this.sandbox.dom.getNodeId(e);this.sandbox.network.send("ext:mouse-click-dom-highlight",{nodeId:t})}}onMouseClick(e){throw new Error("method onMouseClick not implemented")}onNetworkMouseClick(e){if("object"!=typeof e||"number"!=typeof e.x||"number"!=typeof e.y)throw new Error(`unexpected network data for "ext:mouse-click": ${JSON.stringify(e)}`);this.sandbox.notify("int:mouse-click",e)}destroy(){var e,t;this.controlAllowed=!1,this.listenersAttached=!1,null===(e=this.sandbox.getDOMRoot())||void 0===e||e.removeEventListener("click",this.pointerOnMouseClick);for(const[e,n]of this.iframeListeners)null===(t=null==e?void 0:e.contentDocument)||void 0===t||t.removeEventListener("click",n)}}class Le extends Ne{constructor(e){super(e),this.sandbox=e,this.pointerOnMouseClick=this.onMouseClick.bind(this),this.sandbox.listen("int:viewer-reconnected",(()=>{this.attachEventListeners()}))}init(){super.init(),this.sandbox.listen("int:viewer-ready",(()=>{this.attachEventListeners()})),this.sandbox.network.subscribe("viewer:zoom",(e=>{this.viewerZoomValue=e.factor})),this.sandbox.network.subscribe("ext:mouse-click-on-node",(e=>{this.replayClick(e.nodeId)}))}createBoundIframeListener(e){return(t=>{const n=e.getBoundingClientRect();let o=t.clientX+n.x,i=t.clientY+n.y;0!=o&&0!=i&&(o*=this.viewerZoomValue,i*=this.viewerZoomValue),this.sandbox.network.send("ext:mouse-click",{x:o,y:i})}).bind(this)}onMouseClick(e){const t=e;let n=t.clientX,o=t.clientY;0!=n&&0!=o&&(n*=this.viewerZoomValue,o*=this.viewerZoomValue,this.sandbox.network.send("ext:mouse-click",{x:n,y:o})),this.sendNodeIdForHighlight(t.target)}replayClick(e){if(this.controlAllowed){const t=this.sandbox.dom.getNodeById(e);t.dataset.gcobrowseReadonly||this.sandbox.events.replayClick(t)}}}class _e{constructor(e){this.sandbox=e}init(){this.sandbox.listen("int:pointer-created",(()=>{this.addClickListener(),this.stopAnimationHandler()})),this.sandbox.listen("int:session-ready-for-events",(()=>{this.addClickListener(),this.stopAnimationHandler()}))}destroy(){}startClickAnimation(){var e;null===(e=this.getGhostClickElement())||void 0===e||e.classList.add("active")}moveClick(e){throw new Error("method moveClick not implemented")}stopClickAnimation(){var e;null===(e=this.getGhostClickElement())||void 0===e||e.classList.remove("active")}getGhostClickElement(){throw new Error("method getGhostClickElement not implemented")}stopAnimationHandler(){var e;null===(e=this.getGhostClickElement())||void 0===e||e.addEventListener("transitionend",this.stopClickAnimation.bind(this))}clickHandler(e){const t=e.data;this.moveClick({x:t.x,y:t.y}),this.startClickAnimation()}addClickListener(){this.sandbox.listen("int:mouse-click",this.clickHandler.bind(this))}}_e.CLICK_ELEMENT_ID="gcobrowse-click",_e.TOOLBAR_ID="gcobrowse-viewer-toolbar",_e.URL_ID="url-area";class Re extends _e{constructor(e){super(e),this.sandbox=e}init(){super.init(),this.createGhostPointerClick(),this.sandbox.listen("int:viewer-after-ready",(()=>{this.addClickListener(),this.stopAnimationHandler()}))}createGhostPointerClick(){var e;null===(e=this.sandbox.getDOMRoot())||void 0===e||e.body.insertAdjacentHTML("beforeend",'<i id="gcobrowse-click" class="genesys-cbx-ignore" aria-hidden="true"></i>')}moveClick(e){const t=this.getGhostClickElement();null==t||t.style.setProperty("left",`${e.x}px`),null==t||t.style.setProperty("top",`${e.y}px`)}getGhostClickElement(){const e=this.sandbox.getDOMRoot();return e?e.getElementById(_e.CLICK_ELEMENT_ID):null}destroy(){const e=this.getGhostClickElement();e&&e.remove()}}class Ae{constructor(e){this.sandbox=e,this.boundSendScroll=this.sendScroll.bind(this),this.controlAllowed=!1}init(){this.sandbox.listen("int:session-ready-for-events",(()=>{this.addEventListener()})),this.sandbox.listen("int:control-granted",(()=>{this.controlAllowed=!0})),this.sandbox.listen("int:control-revoked",(()=>{this.controlAllowed=!1})),this.sandbox.network.subscribe("viewer:scroll",(e=>this.onNetworkScroll(e))),this.sandbox.network.subscribe("viewer:wheel",(e=>this.onNetworkWheel(e))),this.sandbox.listen("int:viewer-ready",(()=>this.sendScroll()))}addEventListener(){var e;null===(e=this.sandbox.getDOMRoot())||void 0===e||e.addEventListener("scroll",this.boundSendScroll)}removeEventListener(){var e;null===(e=this.sandbox.getDOMRoot())||void 0===e||e.removeEventListener("scroll",this.boundSendScroll)}sendScroll(){this.sandbox.network.send("sharer:scroll",{x:this.sandbox.getWindow().scrollX,y:this.sandbox.getWindow().scrollY})}onNetworkScroll(e){if(this.controlAllowed){if("object"!=typeof e||"number"!=typeof e.x||"number"!=typeof e.y)throw new Error(`unexpected network data for "viewer:scroll": ${JSON.stringify(e)}`);this.removeEventListener(),this.sandbox.getWindow().scroll(e.x,e.y),setTimeout(this.addEventListener.bind(this),70)}}onNetworkWheel(e){this.controlAllowed&&"object"==typeof e&&"number"==typeof e.deltaY&&(this.sandbox.log("dispathing wheelEvt: ",e.deltaY),this.sandbox.events.replayWheel(e.deltaY))}destroy(){this.removeEventListener()}}class Me{constructor(e){this.sandbox=e,this.controlAllowed=!1}init(){this.sandbox.network.subscribe("viewer:input",this.onViewerInput.bind(this)),this.sandbox.network.subscribe("viewer:input-change",this.onViewerInputChange.bind(this)),this.sandbox.listen("int:control-granted",(()=>{this.controlAllowed=!0})),this.sandbox.listen("int:control-revoked",(()=>{this.controlAllowed=!1}))}onViewerInput(e){if(!this.controlAllowed)return void this.sandbox.log.error('got "input" event while control was not allowed');this.sandbox.log.info("got input event",e);const t=e,n=this.sandbox.dom.getNodeById(t.id);this.sandbox.log("input event is on element:",n),"INPUT"!==n.nodeName&&"TEXTAREA"!==n.nodeName||this.sandbox.events.replayTyping(n,H(t.value))}onViewerInputChange(e){if(this.controlAllowed){if(this.sandbox.log.info("got change event",e),e){const t=this.sandbox.dom.getNodeById(e.nodeId);this.sandbox.log("change event is on element:",t),"INPUT"!==t.nodeName&&"TEXTAREA"!==t.nodeName||this.sandbox.events.replayChange(t)}}else this.sandbox.log.error('got "change" event while control was not allowed')}destroy(){}}class Be extends Oe{constructor(e){super(e),this.sandbox=e,this.tooltipCss=`\n\t\tdiv {\n\t\t\tbackground: #6d6d6d;\n\t\t\tcolor: white;\n\t\t\tfont-size: 14px;\n\t\t\theight: 24px;\n\t\t\tpadding: 0 8px;\n\t\t\tfont-family: sans-serif;\n\t\t\tborder-radius: 4px;\n\t\t\tline-height: 24px;\n\t\t}\n\t\t\n\t\tdiv.${Be.onClassName} {\n\t\t\tanimation: fadeIn 0.1s ease-in;\n\t\t}\n\t\t\n\t\tdiv.${Be.offClassName} {\n\t\t\tanimation: fadeOut 0.5s ease-in;\n\t\t\tanimation-fill-mode: forwards; /* stay hidden */\n\t\t}\n\t\t\n\t\t@keyframes fadeIn {\n\t\t\tfrom {\n\t\t\t\topacity: 0;\n\t\t\t\ttransform: scale3d(0.7, 0.7, 0.7);\n\t\t\t}\n\t\t\n\t\t\t50% {\n\t\t\t\topacity: 1;\n\t\t\t}\n\t\t}\n\t\t@keyframes fadeOut {\n\t\t\tfrom {\n\t\t\t\topacity: 1;\n\t\t\t}\n\t\t\n\t\t\tto {\n\t\t\t\topacity: 0;\n\t\t\t}\n\t\t}`}init(){}createTooltipEl(e){var t,n;const o=document.createElement("div");o.setAttribute("id",Be.tooltipContainerId),o.setAttribute("style","position: absolute; display: none;"),o.attachShadow({mode:"open"});const i=document.createElement("div");i.className=Be.offClassName,i.innerText=e;const s=document.createElement("style");return s.innerText=this.tooltipCss,null===(t=o.shadowRoot)||void 0===t||t.appendChild(i),null===(n=o.shadowRoot)||void 0===n||n.appendChild(s),o}displayTooltip(e){var t;const n=this.tooltipContainer;if(n){n.style.display="block",n.style.top=e.offsetTop+e.offsetHeight+15-e.scrollTop+"px",n.style.left=`${e.offsetLeft+(e.offsetWidth-n.offsetWidth)/2}px`;const o=null===(t=n.shadowRoot)||void 0===t?void 0:t.querySelector("div");o&&(o.className=Be.onClassName)}}getTooltipEl(){var e,t;return null===(t=null===(e=this.tooltipContainer)||void 0===e?void 0:e.shadowRoot)||void 0===t?void 0:t.querySelector("div")}hideTooltip(){const e=this.getTooltipEl();e&&(e.className=Be.offClassName)}destroy(){}}Be.onClassName="fade-in",Be.offClassName="fade-out",Be.tooltipContainerId="gcobrowse-tooltip-container";class Ue extends Be{constructor(e){super(e),this.sandbox=e,this.sandbox.listen("int:dom-initialized",(()=>{var e,t;this.tooltipContainer=this.createTooltipEl(this.i18n.maskedTooltip),this.tooltipContainer.classList.add("genesys-cbx-ignore"),null===(t=null===(e=this.sandbox.getDOMRoot())||void 0===e?void 0:e.body)||void 0===t||t.appendChild(this.tooltipContainer),this.attachTooltip()})),this.sandbox.listen("int:dom-changed",(()=>{this.attachTooltip()}))}attachTooltip(){var e;null===(e=this.getElsThatShouldHaveTooltip())||void 0===e||e.forEach((e=>{e.addEventListener("mouseenter",(()=>this.displayTooltip(e))),e.addEventListener("mouseleave",(()=>this.hideTooltip()))}))}detachTooltip(){var e;null===(e=this.getElsThatShouldHaveTooltip())||void 0===e||e.forEach((e=>{e.removeEventListener("mouseenter",(()=>this.displayTooltip(e))),e.removeEventListener("mouseleave",(()=>this.hideTooltip()))}))}getElsThatShouldHaveTooltip(){var e;return null===(e=this.sandbox.getDOMRoot())||void 0===e?void 0:e.querySelectorAll("[data-gcobrowse-masked]")}destroy(){var e;this.detachTooltip(),null===(e=this.tooltipContainer)||void 0===e||e.remove(),super.destroy()}}class Pe{constructor(e){this.sandbox=e}init(){this.sandbox.listen("int:session-ready",(e=>{this.currentSessionCode=e.data.joinCode})),this.sandbox.network.subscribe("viewer:control-request",(()=>{this.handleViewerControlRequest()})),this.sandbox.network.subscribe("viewer:control-revoke",(()=>{this.handleViewerControlRevoke()})),this.sandbox.listen("int:control-enable",(()=>{this.giveControl().catch((e=>{this.sandbox.log.error(e)}))})),this.sandbox.listen("int:control-disable",(()=>{this.revokeControl()})),this.sandbox.listen("int:sharer-reconnected",(e=>{this.handleSessionReconnect(e.data.joinCode).catch((e=>{this.sandbox.log.error(e)}))}))}handleViewerControlRequest(){this.sandbox.notify("int:control-requested"),this.sandbox.log("viewer requested input control")}handleViewerControlRevoke(){this.sandbox.notify("int:control-revoked"),this.sandbox.log.info("viewer revoked input control"),this.sandbox.log.info("removing control enabled key"),this.clearControlEnabled()}giveControl(){return r(this,void 0,void 0,(function*(){this.sandbox.network.send("sharer:control-response",{allowed:!0}),yield this.storeControlEnabled(),this.sandbox.notify("int:control-granted")}))}revokeControl(){this.sandbox.network.send("sharer:control-revoke"),this.sandbox.notify("int:control-revoked"),this.sandbox.log.info("viewer control disabled"),this.sandbox.log.info("removing control enabled key"),this.clearControlEnabled()}handleSessionReconnect(e){return r(this,void 0,void 0,(function*(){this.sandbox.log("checking control enabled key on reconnect");(yield this.checkControlEnabledForSession(e))&&(this.sandbox.log("found control enabled key for current session, enabling control"),this.sandbox.notify("int:control-granted"))}))}checkControlEnabledForSession(e){return r(this,void 0,void 0,(function*(){const t=yield this.sandbox.network.getControlEnabledSession();return!!t&&(t===e||(this.sandbox.log(`found control enabled key for ${t}, but current session is ${e}`),yield this.clearControlEnabled(),!1))}))}storeControlEnabled(){return r(this,void 0,void 0,(function*(){if(!this.currentSessionCode)throw new Error("Trying to give control within an undefined session");this.sandbox.log(`storing control enabled key for session ${this.currentSessionCode}`),yield this.sandbox.network.putControlEnabledSession(this.currentSessionCode)}))}clearControlEnabled(){return r(this,void 0,void 0,(function*(){yield this.sandbox.network.removeControlEnabledSession()}))}destroy(){return r(this,void 0,void 0,(function*(){this.currentSessionCode=void 0,yield this.clearControlEnabled()}))}}class je{constructor(e){this.sandbox=e,this.boundSendResizeEvent=this.sendResizeEvent.bind(this)}init(){this.sandbox.getWindow().addEventListener("resize",this.boundSendResizeEvent),this.sandbox.listen("int:viewer-ready",(()=>{this.sendResizeEvent()}))}sendResizeEvent(){const e=this.sandbox.getWindow().innerWidth,t=this.sandbox.getWindow().innerHeight;this.sandbox.network.send("sharer:resize",{x:e,y:t})}destroy(){this.sandbox.getWindow().removeEventListener("resize",this.boundSendResizeEvent)}}class ze{constructor(e){this.sandbox=e,this.controlAllowed=!1}init(){this.sandbox.network.subscribe("viewer:input-select",this.onViewerInput.bind(this)),this.sandbox.listen("int:control-granted",(()=>{this.controlAllowed=!0})),this.sandbox.listen("int:control-revoked",(()=>{this.controlAllowed=!1}))}onViewerInput(e){if(!this.controlAllowed)return void this.sandbox.log.error('got "input" event while control was not allowed');this.sandbox.log.info("got input:select event",e);const t=this.sandbox.dom.getNodeById(e.id);this.sandbox.log("change event is on select element:",t),"SELECT"===t.nodeName&&this.sandbox.events.replaySelectChange(t,e.value)}destroy(){}}function $e(e){const t=e.currentTarget;if(t){const n=document.createElement("span"),o=Math.max(t.clientWidth,t.clientHeight),i=o/2;n.style.width=n.style.height=`${o}px`,n.style.left=e.clientX-(t.offsetLeft+i)+"px",n.style.top=e.clientY-(t.offsetTop+i)+"px",n.classList.add("ripple");const s=t.getElementsByClassName("ripple")[0];s&&s.remove(),t.appendChild(n)}}class Ve{constructor(e,t,n){this.i18n=e,this.cxbus=t,this.parent=n,this.boundEndSession=this.sendStopSession.bind(this)}init(){this.createStopSessionUIButton(),this.addEventListener()}createStopSessionUIButton(){this.getStopSessionButton()||this.parent.addToControlDisabledPane(`<button\n\t\tid="${Ve.BUTTON_ID}"\n\t\tclass="genesys-cbx-ignore">\n\t\t\t${this.i18n.endScreenShare}\n\t\t</button>`)}addEventListener(){var e,t;null===(e=this.getStopSessionButton())||void 0===e||e.addEventListener("click",this.boundEndSession),null===(t=this.parent.getToolbar())||void 0===t||t.addEventListener("load",(()=>{var e;null===(e=this.getStopSessionButton())||void 0===e||e.addEventListener("click",this.boundEndSession)}))}sendStopSession(e){this.cxbus.command("CobrowseService.stopSession"),$e(e)}getStopSessionButton(){var e;const t=null===(e=this.parent.getToolbar())||void 0===e?void 0:e.contentDocument;return t?t.getElementById(Ve.BUTTON_ID):null}destroy(){var e;null===(e=this.getStopSessionButton())||void 0===e||e.remove()}}Ve.BUTTON_ID="gcobrowse-stop-session-ui",Ve.ACTIONS_ID="gcobrowse-sharer-actions";class qe{constructor(e,t,n){this.i18n=e,this.cxbus=t,this.parent=n,this.drawEnabled=!1}init(){this.createDrawUIButton(),this.addClickListener(),this.cxbus.subscribe("CobrowseService.controlRequested",(()=>{this.drawEnabled&&(this.stopDrawing(),this.drawEnabled=!1)}))}createDrawUIButton(){this.getDrawButton()||this.parent.addToControlDisabledPane(`\n\t\t<button\n\t\t\trole="button"\n\t\t\ttabindex="0"\n\t\t\ttitle="${this.i18n.enableDraw}"\n\t\t\tid="${qe.BUTTON_ID}"\n\t\t\tclass="genesys-cbx-ignore">\n\t\t\t<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000DE"><path d="M0 0h24v24H0z" fill="none"/><path d="M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04c.39-.39.39-1.02 0-1.41l-2.34-2.34c-.39-.39-1.02-.39-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z"/></svg>\n\t\t</button>`)}getDrawButton(){var e,t;return null===(t=null===(e=this.parent.getToolbar())||void 0===e?void 0:e.contentDocument)||void 0===t?void 0:t.getElementById(qe.BUTTON_ID)}addClickListener(){var e;null===(e=this.getDrawButton())||void 0===e||e.addEventListener("click",(e=>{this.onClick(e)}))}onClick(e){$e(e),this.drawEnabled?this.stopDrawing():this.startDrawing(),this.drawEnabled=!this.drawEnabled}startDrawing(){var e;this.cxbus.command("CobrowseService.startDrawing"),null===(e=this.getDrawButton())||void 0===e||e.setAttribute("title",this.i18n.disableDraw),this.setCssClasses({active:!0})}stopDrawing(){var e;this.cxbus.command("CobrowseService.stopDrawing"),null===(e=this.getDrawButton())||void 0===e||e.setAttribute("title",this.i18n.enableDraw),this.setCssClasses({active:!1})}setCssClasses({active:e}){const t=this.getDrawButton();null==t||t.classList.toggle("active",e),t&&(t.title=e?this.i18n.disableDraw:this.i18n.enableDraw)}destroy(){var e;null===(e=this.getDrawButton())||void 0===e||e.remove(),this.drawEnabled=!1}}qe.BUTTON_ID="gcobrowse-draw-ui";class We{constructor(e,t,n){this.i18n=e,this.cxbus=t,this.parent=n,this.acceptDeclineHTMLButtons=`\n\t\t\t<button\n\t\t\tid="${We.BUTTON_ACCEPT_ID}"\n\t\t\tclass="genesys-cbx-ignore">\n\t\t\t\t${this.i18n.accept}\n\t\t\t</button>\n\n\t\t\t<button\n\t\t\tid="${We.BUTTON_DECLINE_ID}"\n\t\t\tclass="genesys-cbx-ignore">\n\t\t\t\t${this.i18n.decline}\n\t\t\t</button>`,this.revokeEndHTMLButtons=`\n\t\t\t<button\n\t\t\tid="${We.BUTTON_REVOKE_ID}"\n\t\t\tclass="genesys-cbx-ignore">\n\t\t\t\t${this.i18n.revokeControl}\n\t\t\t</button>\n\t\t\t\t\n\t\t\t<button\n\t\t\tid="${We.BUTTON_END_SESSION_ID}"\n\t\t\tclass="genesys-cbx-ignore">\n\t\t\t\t${this.i18n.endSession}\n\t\t\t</button>`,this.infoHTMLTooltip=`\n\t\t\t<div\n\t\t\t\tid="${We.TOOLTIP_REQUEST_CONTROL}"\n\t\t\t\trole="tooltip"\n\t\t\t\ttabindex="0"\n\t\t\t\taria-title="${this.i18n.requestControlInfo}"\n\t\t\t\tclass="genesys-cbx-ignore"\n\t\t\t>\n\t\t\t\t<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000DE">\n\t\t\t\t\t<path d='M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z'></path>\n\t\t\t\t</svg>\n\t\t\t</div>\n\t\t\t<div id="${We.TOOLTIP_REQUEST_CONTROL_TEXT}">\n\t\t\t\t<p>${this.i18n.requestControlInfo}</p>\n\t\t\t</div>\n\t\t`,this.toolTipClicked=!1}init(){this.createControlAcceptDeclineButtons(),this.createControlRevokeEndSessionButtons(),this.createInfoTooltip(),this.addEventListenerAccept(),this.addEventListenerDecline(),this.addEventListenerRevoke(),this.addEventListenerEndSession(),this.addEventListenerRequestControlInfo()}createControlAcceptDeclineButtons(){this.parent.getToolbarElement(We.BUTTON_ACCEPT_ID)&&this.parent.getToolbarElement(We.BUTTON_DECLINE_ID)||this.parent.addToControlRequestedPane(this.acceptDeclineHTMLButtons)}createControlRevokeEndSessionButtons(){this.parent.getToolbarElement(We.BUTTON_REVOKE_ID)&&this.parent.getToolbarElement(We.BUTTON_END_SESSION_ID)||this.parent.addToControlEnabledPane(this.revokeEndHTMLButtons)}createInfoTooltip(){this.parent.getToolbarElement(We.TOOLTIP_REQUEST_CONTROL)||this.parent.addToControlRequestedPane(this.infoHTMLTooltip)}addEventListenerAccept(){var e;null===(e=this.parent.getToolbarElement(We.BUTTON_ACCEPT_ID))||void 0===e||e.addEventListener("click",(()=>{this.cxbus.command("CobrowseService.acceptControl")}))}addEventListenerDecline(){var e;null===(e=this.parent.getToolbarElement(We.BUTTON_DECLINE_ID))||void 0===e||e.addEventListener("click",(()=>{this.cxbus.command("CobrowseService.declineControl")}))}addEventListenerRequestControlInfo(){var e;null===(e=this.parent.getToolbarElement(We.TOOLTIP_REQUEST_CONTROL))||void 0===e||e.addEventListener("touchstart",(()=>{const e=this.parent.getToolbarElement(We.TOOLTIP_REQUEST_CONTROL_TEXT);e&&(this.toolTipClicked?(e.style.visibility="hidden",e.style.opacity="0"):(e.style.visibility="visible",e.style.opacity="1"),this.toolTipClicked=!this.toolTipClicked)}))}addEventListenerRevoke(){var e;null===(e=this.parent.getToolbarElement(We.BUTTON_REVOKE_ID))||void 0===e||e.addEventListener("click",(()=>{this.cxbus.command("CobrowseService.declineControl")}))}addEventListenerEndSession(){var e;null===(e=this.parent.getToolbarElement(We.BUTTON_END_SESSION_ID))||void 0===e||e.addEventListener("click",(()=>{this.cxbus.command("CobrowseService.stopSession")}))}destroy(){[We.BUTTON_ACCEPT_ID,We.BUTTON_DECLINE_ID,We.BUTTON_END_SESSION_ID,We.BUTTON_REVOKE_ID,We.TOOLTIP_REQUEST_CONTROL].forEach((e=>{var t;return null===(t=this.parent.getToolbarElement(e))||void 0===t?void 0:t.remove()}))}}var He;We.BUTTON_ACCEPT_ID="gcobrowse-control-accept",We.BUTTON_DECLINE_ID="gcobrowse-control-decline",We.BUTTON_REVOKE_ID="gcobrowse-control-revoke",We.BUTTON_END_SESSION_ID="gcobrowse-end-session",We.TOOLTIP_REQUEST_CONTROL="gcobrowse-request-control-info-tooltip",We.TOOLTIP_REQUEST_CONTROL_TEXT="gcobrowse-request-control-info-text",function(e){e.ControlDisabled="gcobrowse-toolbar-screen-share",e.ControlRequested="gcobrowse-toolbar-request-control",e.ControlEnabled="gcobrowse-toolbar-control-granted"}(He||(He={}));class Fe{constructor(e,t,n){this.i18n=e,this.cxbus=t,this.toolbarUrl=n,this.stopSessionButton=new Ve(e,t,this),this.drawUIButton=new qe(e,t,this),this.controlButtons=new We(e,t,this),this.log=s("toolbar","DEBUG")}init(){this.createOldToolbar(),this.subscribeToCxBus(),this.eventListeners(),this.toolbarResize()}createNewToolbar(){let e=this.getNewToolbar();e?(e.style.height="100px",e.style.width="400px"):(this.cxbus.command("MessengerHelper.injectFrame",{htmlUrl:this.toolbarUrl,id:Fe.NEW_TOOLBAR_ID,title:"Genesys Cobrowse",name:"Genesys Cobrowse",styles:{width:"400px",height:"100px",top:"20px"}}),this.cxbus.subscribe("Cobrowse.onDrag",(t=>{const n=t.data;if(e=this.getNewToolbar(),e){const t=e.getBoundingClientRect();e.style.top=`${t.y+n.y}px`,e.style.left=`${t.x+n.x}px`}})))}createOldToolbar(){const e=`<iframe class="genesys-cbx-ignore" \n id="${Fe.TOOLBAR_ID}"\n referrerpolicy="strict-origin-when-cross-origin"\n name="${this.i18n.sharerToolbar}"\n frameBorder="0" \n srcdoc="<html><body>\n\t\t\t<div id='${He.ControlDisabled}' class='active'>\n\t\t\t\t<h1>${this.i18n.screenShare}</h1>\n\t\t\t\t<p>${this.i18n.sharingWithAgent}</p>\n\t\t\t\t<div id='${Fe.BTNS_CONTROL_DISABLED}' style=''></div>\n\t\t\t</div>\n\t\t\t<div id='${He.ControlRequested}'>\n\t\t\t\t<h1>${this.i18n.requestControlHeader}</h1>\n\t\t\t\t<p>${this.i18n.requestControlDescription}</p>\n\t\t\t\t<div id='${Fe.BTNS_CONTROL_REQUESTED}' style=''></div>\n\t\t\t</div>\n\t\t\t<div id='${He.ControlEnabled}'>\n\t\t\t\t<h1>${this.i18n.remoteControl}</h1>\n\t\t\t\t<p>${this.i18n.remoteControlDescription}</p>\n\t\t\t\t<div id='${Fe.BTNS_CONTROL_ENABLED}' style=''></div>\n\t\t\t</div>\n </body></html>">\n </iframe>`;if(!document.head.querySelector('meta[name="viewport"]')){this.log('meta[name="viewport"] not found, adding a default-ish one for Android Chrome');const e=document.createElement("meta");e.name="viewport",e.content="height=device-height, \n\t\t\twidth=device-width, initial-scale=1.0, \n\t\t\tuser-scalable=yes, target-densitydpi=device-dpi",e.id=Fe.VIEWPORT_ID,document.head.appendChild(e)}this.getToolbar()||document.body.insertAdjacentHTML("beforeend",e)}makeActive(e){var t;null===(t=this.getToolbarElement(e))||void 0===t||t.classList.add("active")}removeActive(e){var t;null===(t=this.getToolbarElement(e))||void 0===t||t.classList.remove("active")}getToolbar(){const e=document.getElementById(Fe.TOOLBAR_ID);return e||null}getNewToolbar(){const e=document.getElementById(Fe.NEW_TOOLBAR_ID);return e||null}addToControlDisabledPane(e){var t;this.getToolbar()&&(null===(t=this.getToolbarElement(Fe.BTNS_CONTROL_DISABLED))||void 0===t||t.append(this.stringToHTML(e)))}addToControlRequestedPane(e){var t;this.getToolbar()&&(null===(t=this.getToolbarElement(Fe.BTNS_CONTROL_REQUESTED))||void 0===t||t.append(this.stringToHTML(e)))}addToControlEnabledPane(e){var t;this.getToolbar()&&(null===(t=this.getToolbarElement(Fe.BTNS_CONTROL_ENABLED))||void 0===t||t.append(this.stringToHTML(e)))}stringToHTML(e){const t=document.createElement("div");return t.innerHTML=e,t}getToolbarElement(e){var t;if(this.getToolbar()){return(null===(t=this.getToolbar())||void 0===t?void 0:t.contentDocument).getElementById(e)}return null}getViewportElement(){return document.querySelector(Fe.VIEWPORT_ID)}getLeftToolbarGroup(){return null}getRightToolbarGroup(){return null}subscribeToCxBus(){this.cxbus.subscribe("CobrowseService.controlRequested",(()=>{this.removeActive(He.ControlEnabled),this.removeActive(He.ControlDisabled),this.makeActive(He.ControlRequested),this.toolbarResize()})),this.cxbus.subscribe("CobrowseService.controlGranted",(()=>{setTimeout((()=>{this.removeActive(He.ControlDisabled),this.removeActive(He.ControlRequested),this.makeActive(He.ControlEnabled)}),1)})),this.cxbus.subscribe("CobrowseService.controlDeclined",(()=>{this.removeActive(He.ControlEnabled),this.removeActive(He.ControlRequested),this.makeActive(He.ControlDisabled),this.toolbarResize()})),this.cxbus.subscribe("CobrowseService.controlRevoked",(()=>{this.removeActive(He.ControlEnabled),this.removeActive(He.ControlRequested),this.makeActive(He.ControlDisabled),this.toolbarResize()})),this.cxbus.subscribe("CobrowseService.sessionEnded",(()=>{this.removeActive(He.ControlEnabled),this.removeActive(He.ControlDisabled),this.makeActive(He.ControlRequested),this.toolbarResize(),this.destroy()}))}eventListeners(){var e;null===(e=this.getToolbar())||void 0===e||e.addEventListener("load",(()=>{this.stopSessionButton.init(),this.drawUIButton.init(),this.controlButtons.init()}))}closeNewToolbar(){const e=this.getNewToolbar();e&&(e.style.height="0px",e.style.width="0px")}destroy(){var e,t,n,o,i;null===(e=this.getToolbar())||void 0===e||e.remove(),this.closeNewToolbar(),null===(t=this.getViewportElement())||void 0===t||t.remove(),null===(n=this.stopSessionButton)||void 0===n||n.destroy(),null===(o=this.drawUIButton)||void 0===o||o.destroy(),null===(i=this.controlButtons)||void 0===i||i.destroy()}toolbarResize(){var e,t,n;const o=this.getToolbar();o&&(o.height=`${Number(null===(n=null===(t=null===(e=o.contentWindow)||void 0===e?void 0:e.document)||void 0===t?void 0:t.body)||void 0===n?void 0:n.scrollHeight)}px`)}}Fe.TOOLBAR_ID="gcobrowse-sharer-toolbar",Fe.NEW_TOOLBAR_ID="gcobrowse-new-sharer-toolbar",Fe.BTNS_CONTROL_DISABLED="gcobrowse-sharer-actions",Fe.BTNS_CONTROL_REQUESTED="gcobrowse-sharer-actions-request-control",Fe.BTNS_CONTROL_ENABLED="gcobrowse-sharer-actions-grant-control",Fe.VIEWPORT_ID="gcobrowse-viewport";class Ge{constructor(e){this.sandbox=e,this.boundOnMouseDown=this.onMouseDown.bind(this),this.boundOnMouseMove=this.onMouseMove.bind(this),this.boundOnMouseUp=this.onMouseUp.bind(this),this.boundTouchStart=this.onTouchStart.bind(this),this.boundTouchMove=this.onTouchMove.bind(this),this.boundTouchEnd=this.onTouchEnd.bind(this),this.activeCanvas=!1}init(){this.sandbox.network.subscribe("ext:draw",(e=>{const{x:t,y:n,isMultiTouchEvent:o}=e;this.draw({x:t,y:n,isExternalEvent:!0,isMultiTouchEvent:o})})),this.sandbox.network.subscribe("ext:draw-end",(()=>this.removeAndAnimateCanvasHide())),this.sandbox.network.subscribe("ext:draw-disabled",(()=>this.removeAndAnimateCanvasHide())),this.sandbox.listen("int:draw-start",(()=>this.startDrawing())),this.sandbox.listen("int:draw-end",(()=>this.stopDrawing())),this.sandbox.listen("int:control-requested",(()=>this.stopDrawing()))}createCanvas(){var e,t,n,o,i,s;Ge.count+=1,null===(e=this.getUIElement())||void 0===e||e.insertAdjacentHTML("beforebegin",Ge.CANVAS_ELEMENT.replace("<uniqueId>",Ge.count.toString())),null===(t=this.getUIElement())||void 0===t||t.insertAdjacentHTML("beforeend",Ge.CANVAS_STYLE.replace(new RegExp("<uniqueId>","g"),Ge.count.toString())),this.canvas=null!==(n=this.getCanvasElement(Ge.count))&&void 0!==n?n:void 0,this.canvasStyle=null!==(o=this.getCanvasStyleElement(Ge.count))&&void 0!==o?o:void 0,this.ctx=null!==(s=null===(i=this.canvas)||void 0===i?void 0:i.getContext("2d"))&&void 0!==s?s:void 0,this.resizeCanvas(),this.activeCanvas=!0}createCursorStyleElement(e){const t=e.createElement("style");return t.setAttribute("id",Ge.CURSOR_VIEWER_STYLE_ID),t.textContent=`body.${Ge.ACTIVE_DRAWING}{\n\t\tcursor: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGhlaWdodD0iMjRweCIgdmlld0JveD0iMCAwIDI0IDI0IiB3aWR0aD0iMjRweCIgZmlsbD0iIzAwMDAwMERFIj48cGF0aCBkPSJNMCAwaDI0djI0SDB6IiBmaWxsPSJub25lIj48L3BhdGg+PHBhdGggZD0iTTMgMTcuMjVWMjFoMy43NUwxNy44MSA5Ljk0bC0zLjc1LTMuNzVMMyAxNy4yNXpNMjAuNzEgNy4wNGMuMzktLjM5LjM5LTEuMDIgMC0xLjQxbC0yLjM0LTIuMzRjLS4zOS0uMzktMS4wMi0uMzktMS40MSAwbC0xLjgzIDEuODMgMy43NSAzLjc1IDEuODMtMS44M3oiPjwvcGF0aD48L3N2Zz4=),\n\t\t\tauto !important;\n\t\t}`,t}resizeCanvas(){if(!this.ctx)return;const e=this.sandbox.getDOMRoot();e&&(this.ctx.canvas.width=e.body.scrollWidth>this.sandbox.getWindow().innerWidth?e.body.scrollWidth:e.documentElement.clientWidth,this.ctx.canvas.height=e.body.scrollHeight>this.sandbox.getWindow().innerHeight?e.body.scrollHeight:this.sandbox.getWindow().innerHeight)}removeAndAnimateCanvasHide(){const e=Ge.count;this.activeCanvas=!1,this.startX=void 0,this.startY=void 0;const t=this.getCanvasElement(e),n=this.getCanvasStyleElement(e);t&&null!==t&&(t.classList.add("gcobrowse-hide"),setTimeout((()=>{t.remove(),n&&null!==n&&n.remove()}),Ge.HIDE_TIMEOUT))}draw(e){this.activeCanvas||this.createCanvas();const{isMultiTouchEvent:t}=e;if(t)return;const{isExternalEvent:n}=e;this.toggleSharerScroll(n);const{x:o,y:i}=e;void 0===this.startX&&void 0===this.startY&&(this.startX=o,this.startY=i),this.ctx&&void 0!==this.startX&&void 0!==this.startY&&(this.ctx.beginPath(),this.ctx.lineWidth=Ge.LINE_WIDTH,this.ctx.lineCap="round",this.ctx.strokeStyle=Ge.STROKE_COLOR,this.ctx.moveTo(this.startX,this.startY),this.ctx.lineTo(o,i),this.startX=o,this.startY=i,this.ctx.stroke())}toggleSharerScroll(e){const t="sharer"===this.sandbox.getRole();this.canvas&&(this.canvas.style.touchAction=e&&t?"auto":"none")}onTouchStart(e){this.createCanvas(),this.isMultiTouchEvent(e)&&this.onMultiTouch(e)}onTouchMove(e){var t,n,o,i;this.isMultiTouchEvent(e)&&this.onMultiTouch(e);const s=e,r=null!==(n=null===(t=this.getWindowElement())||void 0===t?void 0:t.scrollX)&&void 0!==n?n:0,a=null!==(i=null===(o=this.getWindowElement())||void 0===o?void 0:o.scrollY)&&void 0!==i?i:0,l=s.targetTouches[0].clientX+r,d=s.targetTouches[0].clientY+a,c=this.isMultiTouchEvent(e);this.draw({x:l,y:d,isExternalEvent:!1,isMultiTouchEvent:c}),this.sandbox.network.send("ext:draw",{x:l,y:d,isMultiTouchEvent:c})}onTouchEnd(){this.removeAndAnimateCanvasHide(),this.sandbox.network.send("ext:draw-end")}onMultiTouch(e){this.isMultiTouchEvent(e)&&this.canvas&&(this.canvas.style.touchAction="auto")}isMultiTouchEvent(e){var t;const n=e;return(null===(t=null==n?void 0:n.touches)||void 0===t?void 0:t.length)>=2}startDrawing(){this.sandbox.network.send("ext:draw-enabled"),this.createCanvas();const e=this.sandbox.getDOMRoot();if(!e)return;e.addEventListener("mousedown",this.boundOnMouseDown),e.addEventListener("touchstart",this.boundTouchStart),e.addEventListener("touchmove",this.boundTouchMove),e.addEventListener("touchend",this.boundTouchEnd);const t=e.body;t&&t.classList.add("gcobrowse-draw-active"),"viewer"===this.sandbox.getRole()&&e.head.appendChild(this.createCursorStyleElement(e))}stopDrawing(){this.cleanupExistingDrawingsAndStyles(),this.removeEventListeners(),this.cleanBodyAndCanvas(),this.removeViewerStyles(),this.sendDrawDisabledMessage()}removeEventListeners(){[{event:"touchstart",listener:this.boundTouchStart},{event:"touchmove",listener:this.boundTouchMove},{event:"touchend",listener:this.boundTouchEnd},{event:"mousemove",listener:this.boundOnMouseMove},{event:"mousedown",listener:this.boundOnMouseDown},{event:"mouseup",listener:this.boundOnMouseUp}].forEach((({event:e,listener:t})=>{var n;return null===(n=this.sandbox.getDOMRoot())||void 0===n?void 0:n.removeEventListener(e,t)}))}cleanBodyAndCanvas(){var e,t,n;const o=null===(e=this.sandbox.getDOMRoot())||void 0===e?void 0:e.body;o&&o.classList.remove("gcobrowse-draw-active"),this.activeCanvas=!1,null===(t=this.canvas)||void 0===t||t.remove(),null===(n=this.canvasStyle)||void 0===n||n.remove(),this.canvasStyle=void 0,this.canvas=void 0,this.ctx=void 0,this.startX=void 0,this.startY=void 0}removeViewerStyles(){var e,t;if("viewer"===this.sandbox.getRole()){const n=this.sandbox.getDOMRoot();null===(e=null==n?void 0:n.querySelector(`#${Ge.CURSOR_VIEWER_STYLE_ID}`))||void 0===e||e.remove(),null===(t=null==n?void 0:n.body)||void 0===t||t.classList.remove("gcobrowse-draw-active")}}sendDrawDisabledMessage(){try{this.sandbox.network.send("ext:draw-disabled")}catch(e){this.sandbox.log("not sending anything, already disconnected")}}onMouseDown(){var e,t,n;this.createCanvas(),null===(e=this.canvas)||void 0===e||e.classList.add(Ge.CURSOR_DRAW_CLASS),null===(t=this.sandbox.getDOMRoot())||void 0===t||t.addEventListener("mouseup",this.boundOnMouseUp),null===(n=this.sandbox.getDOMRoot())||void 0===n||n.addEventListener("mousemove",this.boundOnMouseMove)}onMouseUp(){var e;null===(e=this.sandbox.getDOMRoot())||void 0===e||e.removeEventListener("mousemove",this.boundOnMouseMove),this.removeAndAnimateCanvasHide(),this.sandbox.network.send("ext:draw-end")}onMouseMove(e){var t,n,o,i;e.preventDefault();const s=e;if(1!==s.buttons)return void this.onMouseUp();const r=null!==(n=null===(t=this.getWindowElement())||void 0===t?void 0:t.scrollX)&&void 0!==n?n:0,a=null!==(i=null===(o=this.getWindowElement())||void 0===o?void 0:o.scrollY)&&void 0!==i?i:0,l=s.clientX+r,d=s.clientY+a,c=this.isMultiTouchEvent(e);this.draw({x:l,y:d,isExternalEvent:!1,isMultiTouchEvent:c}),this.sandbox.network.send("ext:draw",{x:l,y:d,isMultiTouchEvent:c})}getCanvasElement(e){var t;return null===(t=this.sandbox.getDOMRoot())||void 0===t?void 0:t.getElementById(`${Ge.CANVAS_ID}-${e}`)}getCanvasStyleElement(e){const t=this.sandbox.getDOMRoot();return t?t.getElementById(`${Ge.CANVAS_STYLE_ID}-${e}`):null}getUIElement(){return"sharer"===this.sandbox.getRole()?this.sandbox.getRootUIElement():this.sandbox.getWorkRootUIElement()}getWindowElement(){return"sharer"===this.sandbox.getRole()?this.sandbox.getWindow():this.sandbox.getWorkWindow()}cleanupExistingDrawingsAndStyles(){var e;const t=null===(e=this.sandbox.getDOMRoot())||void 0===e?void 0:e.querySelectorAll(`[id^="${Ge.CANVAS_ID}-"]`);if(t&&t.length>0)for(const e of t)e.remove()}destroy(){this.stopDrawing()}}Ge.count=0,Ge.CANVAS_ID="gcobrowse-draw",Ge.CANVAS_STYLE_ID="gcobrowse-draw-style",Ge.CURSOR_DRAW_CLASS="gcobrowse-draw-cursor",Ge.CURSOR_VIEWER_STYLE_ID="gcobrowse-draw-cursor-style",Ge.ACTIVE_DRAWING="gcobrowse-draw-active",Ge.HIDE_TIMEOUT=3e3,Ge.LINE_WIDTH=1,Ge.STROKE_COLOR="#00000",Ge.CANVAS_ELEMENT=`<canvas id="${Ge.CANVAS_ID}-<uniqueId>" class="genesys-cbx-ignore"></canvas>`,Ge.CANVAS_STYLE=`\n <style id='${Ge.CANVAS_STYLE_ID}-<uniqueId>' class="genesys-cbx-ignore">\n #${Ge.CANVAS_ID}-<uniqueId> {\n position: absolute;\n\t\t\ttouch-action: none;\n opacity: 1;\n visibility: visible;\n\t\t\tz-index: 9999999;\n }\n\t\t#${Ge.CANVAS_ID}-<uniqueId>.${Ge.CURSOR_DRAW_CLASS} {\n\t\t\tcursor: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGhlaWdodD0iMjRweCIgdmlld0JveD0iMCAwIDI0IDI0IiB3aWR0aD0iMjRweCIgZmlsbD0iIzAwMDAwMERFIj48cGF0aCBkPSJNMCAwaDI0djI0SDB6IiBmaWxsPSJub25lIj48L3BhdGg+PHBhdGggZD0iTTMgMTcuMjVWMjFoMy43NUwxNy44MSA5Ljk0bC0zLjc1LTMuNzVMMyAxNy4yNXpNMjAuNzEgNy4wNGMuMzktLjM5LjM5LTEuMDIgMC0xLjQxbC0yLjM0LTIuMzRjLS4zOS0uMzktMS4wMi0uMzktMS40MSAwbC0xLjgzIDEuODMgMy43NSAzLjc1IDEuODMtMS44M3oiPjwvcGF0aD48L3N2Zz4=) 0 24, auto;\n\t\t}\n #${Ge.CANVAS_ID}-<uniqueId>.gcobrowse-hide {\n transition: visibility 0s linear ${Ge.HIDE_TIMEOUT}ms, opacity ${Ge.HIDE_TIMEOUT}ms linear;\n visibility: hidden;\n opacity: 0;\n }\n </style>\n `;class Ye extends ae{constructor(e,t=""){super(e,t),this.dom=e.dom,this.iframe=e.getWorkFrame(),this.auth=e.auth,this.getDocument=e.getDocument.bind(e)}getWorkFrame(){return this.iframe}}class Xe{constructor(e){this.sandbox=e,this.primaryColor=this.sandbox.getPrimaryColor()}init(){this.sandbox.listen("int:toolbar-ready",(()=>{this.waitForFrameAndAddCss()})),this.createRootElementStyles()}waitForFrameAndAddCss(){const e=this.sandbox.getInstrumentedDocument().getElementById(Xe.TOOLBAR_ID);null==e||e.addEventListener("load",(()=>{var t;const n=null===(t=e.contentWindow)||void 0===t?void 0:t.document;(null==n?void 0:n.querySelector(Xe.IFRAME_STYLES))||null==n||n.head.appendChild(this.combineToolbariFrameStyles())}))}createRootElementStyles(){const e=this.sandbox.getDOMRoot();e&&this.addRootStylesToDoc(e),this.addRootStylesToDoc(this.sandbox.getInstrumentedDocument())}addRootStylesToDoc(e){const t=[this.createToolbarIframeStyles(),this.mouseClickStyles(),this.domHighlightActiveStyles(),this.ghostPointerStyles(),this.controlBorderStyles(),this.setDrawCursor(),this.tooltipOutlineStyles()],n=e.createElement("style");n.classList.add("genesys-cbx-ignore"),n.id=Xe.ROOT_STYLES,t.forEach((e=>{n.innerHTML+=e})),e.head.appendChild(n)}combineToolbariFrameStyles(){var e;const t=null===(e=this.sandbox.getInstrumentedDocument().getElementById(Xe.TOOLBAR_ID).contentDocument)||void 0===e?void 0:e.createElement("style");if(t)return t.id=Xe.IFRAME_STYLES,t.innerHTML=this.importFonts()+this.iframeReset()+this.iframeBasicStyles()+this.drawButtonStyles()+this.stopButtonStyles()+this.infoButtonStyle()+this.activeHelperStyles(),t;throw new Error("Could not load Sharer Styles Tag")}iframeReset(){return"\n /* Box sizing rules */\n *, *::before, *::after {\n box-sizing: border-box;\n }\n \n /* Remove default margin */\n body, h1, h2, h3, h4, p, figure, blockquote, dl, dd {\n margin: 0;\n }\n \n /* Remove list styles on ul, ol elements with a list role, which suggests default styling will be removed */\n ul[role='list'], ol[role='list'] {\n list-style: none;\n }\n \n /* Set core root defaults */\n html:focus-within {\n scroll-behavior: smooth;\n }\n \n /* Set core body defaults */\n body {\n min-height: 100%;\n text-rendering: optimizeSpeed;\n line-height: 1.25;\n }\n \n /* A elements that don't have a class get default styles */\n a:not([class]) {\n text-decoration-skip-ink: auto;\n }\n \n /* Make images easier to work with */\n img, picture {\n max-width: 100%;\n display: block;\n }\n \n /* Inherit fonts for inputs and buttons */\n input, button, textarea, select {\n font: inherit;\n }\n \n /* Remove all animations, transitions and smooth scroll for people that prefer not to see them */\n @media (prefers-reduced-motion: reduce) {\n html:focus-within {\n scroll-behavior: auto;\n }\n }\n \n *, *::before, *::after {\n animation-duration: 0.01ms !important;\n animation-iteration-count: 1 !important;\n transition-duration: 0.01ms !important;\n scroll-behavior: auto !important;\n }\n "}iframeBasicStyles(){return`\n body {\n padding: 18px 12px;\n overflow: hidden;\n }\n\n h1 {\n letter-spacing: 0.15px;\n font-family: Roboto, Helvetica, sans-serif;\n font-size: 20px;\n color: #000000DE;\n font-weight:500;\n }\n\n h3 {\n letter-spacing: 0.15px;\n font-family: Roboto, Helvetica, sans-serif;\n font-size: 16px;\n margin-block-start: 4px;\n margin-block-end: 4px;\n color: #000000DE;\n font-weight:500;\n }\n\n p {\n margin-block-start: 10px;\n margin-block-end: 10px;\n letter-spacing:.25px;\n color: #00000099;\n font-family: Roboto, Helvetica, sans-serif;\n font-size: 14px;\n font-weight:400;\n \n }\n\n #${Xe.SHARER_ACTIONS} {\n display:flex;\n justify-content: space-between;\n align-items: center;\n }`}importFonts(){const e=this.sandbox.getFontsURL();return`\n @import url('${e}/roboto.css');\n @import url('${e}/material-icons.css');\n .icons {\n font-family: 'material-icons';\n font-weight: normal;\n font-style: normal;\n font-size: 24px; /* Preferred icon size */\n display: inline-block;\n line-height: 1;\n text-transform: none;\n letter-spacing: normal;\n word-wrap: normal;\n white-space: nowrap;\n direction: ltr;\n \n /* Support for all WebKit browsers. */\n -webkit-font-smoothing: antialiased;\n /* Support for Safari and Chrome. */\n text-rendering: optimizeLegibility;\n \n /* Support for Firefox. */\n -moz-osx-font-smoothing: grayscale;\n \n /* Support for IE. */\n font-feature-settings: 'liga';\n }`}activeHelperStyles(){return`\n #${Xe.TOOLBAR_SCREEN_SHARE}, #${Xe.TOOLBAR_REQUEST_CONTROL}, \n #${Xe.TOOLBAR_CONTROL_GRANTED} {\n display: none;\n }\n #${Xe.TOOLBAR_SCREEN_SHARE}.active, #${Xe.TOOLBAR_REQUEST_CONTROL}.active, \n #${Xe.TOOLBAR_CONTROL_GRANTED}.active {\n display: block;\n }\n `}infoButtonStyle(){return`\n #${Xe.TOOLTIP_REQUEST_CONTROL} {\n height: 35px;\n width: 35px;\n padding: 5px;\n border-radius: 50%;\n position: absolute;\n top: 17px;\n left: 309px;\n overflow: hidden;\n border: none;\n background: transparent;\n }\n\n #${Xe.TOOLTIP_REQUEST_CONTROL}:hover {\n background: rgba(0,0,0,0.12) !important;\n transition: background 400ms;\n }\n\n #${Xe.TOOLTIP_REQUEST_CONTROL_TEXT} {\n filter: drop-shadow(0px 0px 1px black);\n border-radius: 5px;\n z-index: 100;\n background: #444950;\n width: 310px;\n height: 83px;\n position: absolute;\n margin-top: -75px;\n margin-left: 29px;\n padding: 10px;\n visibility: hidden;\n opacity: 0;\n transition: opacity 0.3s;\n }\n\n #${Xe.TOOLTIP_REQUEST_CONTROL} ~ #${Xe.TOOLTIP_REQUEST_CONTROL_TEXT} {\n visibility: hidden;\n opacity: 0;\n }\n\n #${Xe.TOOLTIP_REQUEST_CONTROL_TEXT} p {\n color: white;\n }\n \n #${Xe.TOOLTIP_REQUEST_CONTROL_TEXT}::before {\n z-index: 99;\n position: absolute;\n top: -5px;\n left: 292px;\n width: 0; \n height: 0; \n border-left: 5px solid transparent;\n border-right: 5px solid transparent;\n border-bottom: 5px solid #444950;\n content: '';\n }\n\n #${Xe.TOOLTIP_REQUEST_CONTROL}:hover ~ #${Xe.TOOLTIP_REQUEST_CONTROL_TEXT},\n #${Xe.TOOLTIP_REQUEST_CONTROL}:focus-visible ~ #${Xe.TOOLTIP_REQUEST_CONTROL_TEXT} {\n visibility: visible;\n opacity: 1;\n }\n `}drawButtonStyles(){return`\n #${Xe.DRAW_BUTTON_ID} {\n top: 10px;\n left: 320px;\n height: 35px;\n width: 35px;\n border-radius: 50%;\n padding: 5px;\n font-size: 14px; \n line-height: 24px;\n cursor: pointer;\n font-weight: bold;\n box-sizing: border-box;\n text-align: center;\n transition: background 400ms;\n position: fixed;\n overflow: hidden;\n border: none;\n background: transparent;\n }\n \n #${Xe.DRAW_BUTTON_ID}.active {\n background: rgba(0, 0, 0, 0.08) !important;\n border: 1px solid rgba(0, 0, 0, 0.12);\n }\n #${Xe.DRAW_BUTTON_ID}:hover {\n background: rgba(0,0,0,0.12) !important;\n transition: background 400ms;\n }\n #${Xe.DRAW_BUTTON_ID}:focus-visible {\n background: rgba(0, 0, 0, 0.2);\n border: none;\n animation: breathing 1.5s infinite;\n outline: none;\n }\n #${Xe.DRAW_BUTTON_ID} span.ripple {\n position: absolute; \n border-radius: 50%;\n transform: scale(0);\n animation: ripple 600ms linear;\n background-color: rgba(0, 0, 0, 0.2) !important;\n }\n \n \n body.${Xe.DRAW_ACTIVE}{\n cursor: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGhlaWdodD0iMjRweCIgdmlld0JveD0iMCAwIDI0IDI0IiB3aWR0aD0iMjRweCIgZmlsbD0iIzAwMDAwMERFIj48cGF0aCBkPSJNMCAwaDI0djI0SDB6IiBmaWxsPSJub25lIj48L3BhdGg+PHBhdGggZD0iTTMgMTcuMjVWMjFoMy43NUwxNy44MSA5Ljk0bC0zLjc1LTMuNzVMMyAxNy4yNXpNMjAuNzEgNy4wNGMuMzktLjM5LjM5LTEuMDIgMC0xLjQxbC0yLjM0LTIuMzRjLS4zOS0uMzktMS4wMi0uMzktMS40MSAwbC0xLjgzIDEuODMgMy43NSAzLjc1IDEuODMtMS44M3oiPjwvcGF0aD48L3N2Zz4=), auto !important;\n }\n @keyframes ripple {\n to {\n transform: scale(4);\n opacity: 0;\n }\n }\n \n @keyframes breathing {\n 0% {\n transform: scale(1.0);\n }\n \n 25% {\n transform: scale(1.1);\n }\n \n 60% {\n transform: scale(1.1);\n }\n \n 100% {\n transform: scale(1.0);\n }\n }\n \n `}stopButtonStyles(){return`\n #${Xe.SHARER_BUTTON_ID}, #${Xe.BUTTON_ACCEPT_ID}, \n #${Xe.BUTTON_DECLINE_ID}, #${Xe.BUTTON_REVOKE_ID}, \n #${Xe.BUTTON_END_SESSION_ID} {\n padding: 10px 15px;\n height: 36px;\n font-family: Roboto, Helvetica, sans-serif;\n line-height: 16px;\n background-color: ${this.primaryColor};\n color: #fdfdfd;\n text-align: center; \n cursor: pointer;\n box-sizing: border-box;\n font-weight: 500;\n text-transform: uppercase;\n font-size: 14px;\n letter-spacing: 1.25px;\n border-radius: 4px;\n flex-grow: 2;\n cursor: pointer;\n position: relative;\n overflow: hidden;\n box-shadow: 0px 3px 1px -2px rgb(0 0 0 / 20%), 0px 2px 2px 0px rgb(0 0 0 / 14%), 0px 1px 5px 0px rgb(0 0 0 / 12%);\n transition: background 400ms, box-shadow 280ms cubic-bezier(0.4, 0, 0.2, 1);\n border: none;\n margin-top: 10px;\n margin-bottom: 10px;\n }\n\n #${Xe.SHARER_BUTTON_ID}:hover, #${Xe.BUTTON_ACCEPT_ID}:hover,\n #${Xe.BUTTON_DECLINE_ID}:hover, #${Xe.BUTTON_REVOKE_ID}:hover,\n #${Xe.BUTTON_END_SESSION_ID}:hover {\n box-shadow: 0px 2px 4px -1px rgb(0 0 0 / 20%), 0px 4px 5px 0px rgb(0 0 0 / 14%), 0px 1px 10px 0px rgb(0 0 0 / 12%) !important;\n }\n \n #${Xe.SHARER_BUTTON_ID} span.ripple, #${Xe.BUTTON_ACCEPT_ID} span.ripple,\n #${Xe.BUTTON_DECLINE_ID} span.ripple, #${Xe.BUTTON_REVOKE_ID} span.ripple,\n #${Xe.BUTTON_END_SESSION_ID} span.ripplle {\n position: absolute; \n border-radius: 50%;\n transform: scale(0);\n animation: ripple 600ms linear;\n background-color: rgba(255, 255, 255, 0.7);\n }`}createToolbarIframeStyles(){return`\n #${Xe.TOOLBAR_ID} {\n position: fixed; \n border-radius: 4px;\n background-color: #fff; \n box-shadow: 0 1px 3px rgba(0,0,0,0.16), 0 1px 3px rgba(0,0,0,0.23);\n min-width: 375px;\n overflow: hidden;\n box-sizing: border-box;\n float: left; top: 20px;\n z-index: 9999999;\n right: 32px;\n letter-spacing: initial;\n display: flex;\n }\n\n @media (max-width:600px) {\n #${Xe.TOOLBAR_ID} {\n right: 50%;\n transform: translateX(50%);\n }\n }\n `}mouseClickStyles(){return` \n #${Xe.CLICK_ID} {\n position: absolute;\n background: red;\n height: 60px;\n width: 60px;\n margin: -30px;\n opacity: 1;\n transform: scale(0) !important;\n border-radius: 100%;\n z-index: 9999999;\n }\n #${Xe.CLICK_ID}.active {\n transition: transform 400ms ease, opacity 400ms ease;\n opacity: 0;\n transform: scale(1) !important;\n }`}domHighlightActiveStyles(){return`\n .${Xe.DOM_HIGHLIGHT_ACTIVE_CLASS}{\n background-color: rgba(255,0,0,0.5);\n animation: fade-in-out 1500ms ease;\n }\n\n @keyframes fade-in-out {\n 0% {\n background-color: rgba(255,0,0,0.0);\n }\n\n 50% {\n background-color: rgba(255,0,0,0.5);\n }\n\n 100% {\n background-color: rgba(255,0,0,0.0);\n }\n }`}ghostPointerStyles(){return`\n #${Xe.GHOST_POINTER_ID} {\n position: fixed;\n z-index: 9999999;\n pointer-events: none;\n top:100px;\n left:100px;\n }\n \n #${Xe.GHOST_POINTER_ID} svg {\n width: 16px;\n height: auto;\n fill: fill: ${this.primaryColor};\n }\n \n #${Xe.GHOST_POINTER_TITLE_ID} {\n font-size: 16px;\n font-weight: bold;\n color: ${this.primaryColor};\n font-family: Roboto, helvetica, sans-serif;\n vertical-align: super;\n margin-left: 5px;\n }`}controlBorderStyles(){return`\n #${Xe.BORDER_ID} {\n position: fixed;\n top: 0;\n left: 0;\n bottom: 0;\n right: 0;\n border: ${Xe.BORDER_SIZE}px solid ${this.primaryColor};\n pointer-events: none;\n z-index: 2147483647;\n }\n html.${Xe.ACTIVE_SCREEN_SHARED_CLASS} {\n overscroll-behavior: none;\n }\n `}tooltipOutlineStyles(){return`\n [data-gcobrowse-masked] {\n outline: 1px solid transparent;\n transition: outline 0.5s;\n }\n [data-gcobrowse-masked]:hover {\n outline-color: ${this.sandbox.getPrimaryColor()};\n }\n `}setDrawCursor(){return`body.${Xe.DRAW_ACTIVE} {\n cursor: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGhlaWdodD0iMjRweCIgdmlld0JveD0iMCAwIDI0IDI0IiB3aWR0aD0iMjRweCIgZmlsbD0iIzAwMDAwMERFIj48cGF0aCBkPSJNMCAwaDI0djI0SDB6IiBmaWxsPSJub25lIj48L3BhdGg+PHBhdGggZD0iTTMgMTcuMjVWMjFoMy43NUwxNy44MSA5Ljk0bC0zLjc1LTMuNzVMMyAxNy4yNXpNMjAuNzEgNy4wNGMuMzktLjM5LjM5LTEuMDIgMC0xLjQxbC0yLjM0LTIuMzRjLS4zOS0uMzktMS4wMi0uMzktMS40MSAwbC0xLjgzIDEuODMgMy43NSAzLjc1IDEuODMtMS44M3oiPjwvcGF0aD48L3N2Zz4=), auto !important;\n }`}destroy(){var e,t,n;null===(t=null===(e=this.sandbox.getDOMRoot())||void 0===e?void 0:e.querySelector(Xe.ROOT_STYLES))||void 0===t||t.remove(),null===(n=this.sandbox.getInstrumentedDocument().querySelector(Xe.ROOT_STYLES))||void 0===n||n.remove()}}Xe.TOOLBAR_ID="gcobrowse-sharer-toolbar",Xe.TOOLBAR_SCREEN_SHARE="gcobrowse-toolbar-screen-share",Xe.TOOLBAR_REQUEST_CONTROL="gcobrowse-toolbar-request-control",Xe.TOOLBAR_CONTROL_GRANTED="gcobrowse-toolbar-control-granted",Xe.DRAW_BUTTON_ID="gcobrowse-draw-ui",Xe.SHARER_BUTTON_ID="gcobrowse-stop-session-ui",Xe.BUTTON_ACCEPT_ID="gcobrowse-control-accept",Xe.BUTTON_DECLINE_ID="gcobrowse-control-decline",Xe.BUTTON_REVOKE_ID="gcobrowse-control-revoke",Xe.BUTTON_END_SESSION_ID="gcobrowse-end-session",Xe.TOOLTIP_REQUEST_CONTROL="gcobrowse-request-control-info-tooltip",Xe.TOOLTIP_REQUEST_CONTROL_TEXT="gcobrowse-request-control-info-text",Xe.DOM_HIGHLIGHT_ACTIVE_CLASS="gcobrowse-element-highlight",Xe.GHOST_POINTER_TITLE_ID="gcobrowse-ghost-pointer-title",Xe.GHOST_POINTER_ID="gcobrowse-ghost-pointer",Xe.SHARER_ACTIONS="gcobrowse-sharer-actions",Xe.DRAW_ACTIVE="gcobrowse-draw-active",Xe.CLICK_ID="gcobrowse-click",Xe.ACTIVE_SCREEN_SHARED_CLASS="gcobrowse_screen_being_shared",Xe.BORDER_SIZE=5,Xe.BORDER_ID="gcobrowse-border",Xe.CANVAS_STYLE_ID="gcobrowse-draw-style",Xe.IFRAME_STYLES="gcobrowse-iframe-styles",Xe.ROOT_STYLES="gcobrowse-styles";class Ke{constructor(e){this.sandbox=e}init(){this.sandbox.network.subscribe("ext:mouse-click-dom-highlight",(e=>{this.highlightDOMelement(e.nodeId)}))}highlightDOMelement(e){let t;t=this.sandbox instanceof le||this.sandbox instanceof Ye?this.sandbox.dom.getNodeById(e):null,t&&(t.classList.add(Ke.ACTIVE_CLASS),this.stopAnimationHandler(t))}stopAnimationHandler(e){e.addEventListener("animationend",(()=>{e.classList.remove(Ke.ACTIVE_CLASS),e.removeEventListener("animationend",(()=>!1))}))}destroy(){var e;null===(e=document.getElementsByClassName(Ke.ACTIVE_CLASS)[0])||void 0===e||e.removeEventListener("animationend",(()=>!1))}}Ke.ACTIVE_CLASS=Xe.DOM_HIGHLIGHT_ACTIVE_CLASS;class Je{constructor(e){this.sandbox=e,this.visibilityChanged=this.handleVisibilityChange.bind(this)}init(){this.sandbox.listen("int:toolbar-ready",(()=>{this.setVisibilityEventListener()}))}setVisibilityEventListener(){var e;null===(e=this.sandbox.getDOMRoot())||void 0===e||e.addEventListener("visibilitychange",this.visibilityChanged)}handleVisibilityChange(){var e;this.sandbox.network.send("sharer:focus",{hidden:"hidden"===(null===(e=this.sandbox.getDOMRoot())||void 0===e?void 0:e.visibilityState)})}destroy(){var e;null===(e=this.sandbox.getDOMRoot())||void 0===e||e.removeEventListener("visibilitychange",this.visibilityChanged)}}const Qe=Xe.ACTIVE_SCREEN_SHARED_CLASS;class Ze{constructor(e){this.sandbox=e}init(){this.sandbox.listen("int:session-ready-for-events",(()=>{this.initBorder()}))}destroy(){var e,t;const n=null===(e=this.sandbox.getDOMRoot())||void 0===e?void 0:e.getElementById(Xe.BORDER_ID);null==n||n.remove(),null===(t=this.sandbox.getDOMRoot())||void 0===t||t.documentElement.classList.remove(Qe)}initBorder(){const e=this.sandbox.getDOMRoot();if(!(null==e?void 0:e.getElementById(Xe.BORDER_ID))&&e){const t=e.createElement("div");t.setAttribute("id",Xe.BORDER_ID),t.classList.add("genesys-cbx-ignore"),e.body.appendChild(t),e.documentElement.classList.add(Qe)}}}class et{constructor(e){this.sandbox=e,this.boundOnViewerFocusingEvent=this.onViewerFocusingEvent.bind(this),this.boundOnViewerFocusOutEvent=this.onViewerFocusOutEvent.bind(this),this.boundOnSharerFocusingEvent=this.onSharerFocusingEvent.bind(this),this.boundOnSharerFocusOutEvent=this.onSharerFocusOutEvent.bind(this)}init(){this.sandbox.listen("int:toolbar-ready",(()=>{const e=this.sandbox.getDOMRoot();null==e||e.addEventListener("click",this.boundOnSharerFocusingEvent),null==e||e.addEventListener("mousedown",this.boundOnSharerFocusingEvent),null==e||e.addEventListener("keydown",this.boundOnSharerFocusingEvent),null==e||e.addEventListener("focusin",this.boundOnSharerFocusingEvent),null==e||e.addEventListener("focusout",this.boundOnSharerFocusOutEvent),this.sandbox.network.subscribe("viewer:input-focus",this.boundOnViewerFocusingEvent),this.sandbox.network.subscribe("viewer:input-focusout",this.boundOnViewerFocusOutEvent)}))}onSharerFocusingEvent(e){const t=e.target;if("INPUT"===t.tagName.toUpperCase()||"TEXTAREA"===t.tagName.toUpperCase()){const e=this.sandbox.dom.getNodeId(t);this.sandbox.network.send("ext:sharer-input-focus",{nodeId:e})}}onSharerFocusOutEvent(e){const t=e.target;if("INPUT"===t.tagName.toUpperCase()||"TEXTAREA"===t.tagName.toUpperCase()){const e=this.sandbox.dom.getNodeId(t);this.sandbox.network.send("ext:sharer-input-focusout",{nodeId:e})}}onViewerFocusingEvent(e){const t=this.getFocusedNodeById(e.nodeId);this.setFocus(t)}onViewerFocusOutEvent(e){const t=this.getFocusedNodeById(e.nodeId);this.sandbox.events.replayFocusOut(t)}setFocus(e){e.focus()}getFocusedNodeById(e){const t=this.sandbox.dom.getNodeById(e);if(t)return t;throw new Error("Could not find Node")}destroy(){const e=this.sandbox.getDOMRoot();null==e||e.removeEventListener("mousedown",this.boundOnSharerFocusingEvent),null==e||e.removeEventListener("click",this.boundOnSharerFocusingEvent),null==e||e.removeEventListener("keydown",this.boundOnSharerFocusingEvent),null==e||e.removeEventListener("focusin",this.boundOnSharerFocusingEvent),null==e||e.removeEventListener("focusout",this.boundOnSharerFocusOutEvent)}}class tt{constructor(e){this.sandbox=e,this.boundOnMouseOverEvent=this.onMouseOver.bind(this),this.boundOnMouseOutEvent=this.onMouseOut.bind(this),this.currentElem=null,this.proxyEnabled=L}init(){const e=this.sandbox.getDOMRoot();this.proxyEnabled&&this.sandbox.listen("int:toolbar-ready",(()=>{null==e||e.addEventListener("mouseover",this.boundOnMouseOverEvent),null==e||e.addEventListener("mouseout",this.boundOnMouseOutEvent)}))}onMouseOver(e){const t=e.target;if(t){const n=e.composedPath();t.classList.add(tt.HOVER_CLASS);n.filter((e=>null!==e&&e!==window&&e!==document)).forEach((e=>{const t=e;t&&t.classList&&(t.classList.contains(tt.HOVER_CLASS)||t.classList.add(tt.HOVER_CLASS))}))}}onMouseOut(e){const t=e.target;if(t){t.classList.remove(tt.HOVER_CLASS);e.composedPath().filter((e=>null!==e&&e!==window&&e!==document)).forEach((e=>{const t=e;t&&t.classList.contains(tt.HOVER_CLASS)&&t.classList.remove(tt.HOVER_CLASS)}))}}destroy(){const e=this.sandbox.getDOMRoot();null==e||e.removeEventListener("mouseover",this.boundOnMouseOverEvent),null==e||e.removeEventListener("mouseout",this.boundOnMouseOutEvent)}}tt.HOVER_CLASS="genesys_hover";class nt{constructor(e){this.sandbox=e}init(){this.sandbox.network.subscribe("viewer:navigation-request",(e=>{this.sandbox.notify("int:navigation-requested",e)})),this.sandbox.listen("int:navigate",(e=>{this.sandbox.getWindow().location.assign(e.data.url)}))}destroy(){}}class ot{constructor(e,t,n){this.core=e,this.plugin=t,this.headlessMode=n,this.sessionStateKey="__genesys_cobrowse_n__ongoing_session",this.log=e.createLogger("Sharer"),e.pubsub.listenForever("int:session-ready",(e=>{var t;null===(t=this.core.getRootUIElement())||void 0===t||t.classList.add("gcobrowse_screen_being_shared"),this.renderUI(),this.storeSessionState(e.data.joinCode)})),this.core.pubsub.listenForever("int:session-end",(()=>{this.onSessionEnd()})),this.core.pubsub.listenForever("int:session-load-failed",(()=>{this.onSessionEnd()})),this.onPageLoad()}onPageLoad(){return r(this,void 0,void 0,(function*(){this.log("page loaded - check if there is an ongoing session");const e=this.getRememberedSession();e&&(this.log(`rejoining session ${e}`),yield this.core.loadi18n(),this.log("fetched i18n, about to register modules"),this.startModules(),this.core.pubsub.notify("int:user-requested-rejoin"))}))}startModules(){this.registerAllModules(),this.core.startAll()}stopAndDestroyAllModules(){var e;this.log("stopping all modules"),this.core.stopAll(),this.core.deregisterAll(),null===(e=this.toolbar)||void 0===e||e.destroy(),this.toolbar=void 0,this.log("stopped all modules")}registerAllModules(){const e=this.core;this.log("registering modules"),e.register("session",xe),e.register("dom",Ce),e.register("mousemove",Ie),e.register("mousemoveUI",De),e.register("mousemoveUI",De),e.register("click",Le),e.register("mouseclickUI",Re),e.register("input",Me),e.register("scroll",Ae),e.register("tooltip",Ue),e.register("CSS",Xe),e.register("sharercontrol",Pe),e.register("sharerresize",je),e.register("sharerselectinput",ze),e.register("draw",Ge),e.register("DomHighlight",Ke),e.register("pageinfocus",Je),e.register("border",Ze),e.register("focus",et),e.register("pushUrl",nt),e.register("hover",tt),this.log("registered modules")}onSessionEnd(){var e;null===(e=this.core.getRootUIElement())||void 0===e||e.classList.remove("gcobrowse_screen_being_shared"),this.removeStoredSessionState(),setTimeout((()=>{this.stopAndDestroyAllModules(),this.log("clearing registered event listeners"),this.core.pubsub.clearEventListeners(),this.log("event listeners removed")}),0)}storeSessionState(e){window.localStorage.setItem(this.sessionStateKey,e)}getStoredSessionState(){return window.localStorage.getItem(this.sessionStateKey)}removeStoredSessionState(){window.localStorage.removeItem(this.sessionStateKey)}getRememberedSession(){const e=this.getStoredSessionState();return this.log(`session state stored: ${e}`),e}renderUI(){if(this.headlessMode)return void this.log("headless mode - no built-in UI");this.log("creating the toolbar UI");const e=this.core.getAssetsURL()+"/sharer-toolbar.html?lang="+this.core.getLang();this.toolbar=new Fe(this.core.geti18n(),this.plugin,e),this.toolbar.init(),this.log("toolbar started"),this.core.pubsub.notify("int:toolbar-ready")}}function it(e,t){const n=t.replace(/[[]/,"\\[").replace(/[\]]/,"\\]"),o=new RegExp("[\\#&]"+n+"=([^&#]*)").exec(e.hash);return null===o?null:decodeURIComponent(o[1].replace(/\+/g," "))}var st,rt={},at={},lt=Object.prototype.hasOwnProperty;function dt(e){try{return decodeURIComponent(e.replace(/\+/g," "))}catch(e){return null}}function ct(e){try{return encodeURIComponent(e)}catch(e){return null}}at.stringify=function(e,t){t=t||"";var n,o,i=[];for(o in"string"!=typeof t&&(t="?"),e)if(lt.call(e,o)){if((n=e[o])||null!==n&&n!==st&&!isNaN(n)||(n=""),o=ct(o),n=ct(n),null===o||null===n)continue;i.push(o+"="+n)}return i.length?t+i.join("&"):""},at.parse=function(e){for(var t,n=/([^=?#&]+)=?([^&]*)/g,o={};t=n.exec(e);){var i=dt(t[1]),s=dt(t[2]);null===i||null===s||i in o||(o[i]=s)}return o};var ht=function(e,t){if(t=t.split(":")[0],!(e=+e))return!1;switch(t){case"http":case"ws":return 80!==e;case"https":case"wss":return 443!==e;case"ftp":return 21!==e;case"gopher":return 70!==e;case"file":return!1}return 0!==e},ut=at,gt=/^[\x00-\x20\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]+/,pt=/[\n\r\t]/g,mt=/^[A-Za-z][A-Za-z0-9+-.]*:\/\//,ft=/:\d+$/,vt=/^([a-z][a-z0-9.+-]*:)?(\/\/)?([\\/]+)?([\S\s]*)/i,bt=/^[a-zA-Z]:/;function yt(e){return(e||"").toString().replace(gt,"")}var wt=[["#","hash"],["?","query"],function(e,t){return Tt(t.protocol)?e.replace(/\\/g,"/"):e},["/","pathname"],["@","auth",1],[NaN,"host",void 0,1,1],[/:(\d*)$/,"port",void 0,1],[NaN,"hostname",void 0,1,1]],Et={hash:1,query:1};function Ct(e){var t,n=("undefined"!=typeof window?window:void 0!==ce?ce:"undefined"!=typeof self?self:{}).location||{},o={},i=typeof(e=e||n);if("blob:"===e.protocol)o=new St(unescape(e.pathname),{});else if("string"===i)for(t in o=new St(e,{}),Et)delete o[t];else if("object"===i){for(t in e)t in Et||(o[t]=e[t]);void 0===o.slashes&&(o.slashes=mt.test(e.href))}return o}function Tt(e){return"file:"===e||"ftp:"===e||"http:"===e||"https:"===e||"ws:"===e||"wss:"===e}function xt(e,t){e=(e=yt(e)).replace(pt,""),t=t||{};var n,o=vt.exec(e),i=o[1]?o[1].toLowerCase():"",s=!!o[2],r=!!o[3],a=0;return s?r?(n=o[2]+o[3]+o[4],a=o[2].length+o[3].length):(n=o[2]+o[4],a=o[2].length):r?(n=o[3]+o[4],a=o[3].length):n=o[4],"file:"===i?a>=2&&(n=n.slice(2)):Tt(i)?n=o[4]:i?s&&(n=n.slice(2)):a>=2&&Tt(t.protocol)&&(n=o[4]),{protocol:i,slashes:s||Tt(i),slashesCount:a,rest:n}}function St(e,t,n){if(e=(e=yt(e)).replace(pt,""),!(this instanceof St))return new St(e,t,n);var o,i,s,r,a,l,d=wt.slice(),c=typeof t,h=this,u=0;for("object"!==c&&"string"!==c&&(n=t,t=null),n&&"function"!=typeof n&&(n=ut.parse),o=!(i=xt(e||"",t=Ct(t))).protocol&&!i.slashes,h.slashes=i.slashes||o&&t.slashes,h.protocol=i.protocol||t.protocol||"",e=i.rest,("file:"===i.protocol&&(2!==i.slashesCount||bt.test(e))||!i.slashes&&(i.protocol||i.slashesCount<2||!Tt(h.protocol)))&&(d[3]=[/(.*)/,"pathname"]);u<d.length;u++)"function"!=typeof(r=d[u])?(s=r[0],l=r[1],s!=s?h[l]=e:"string"==typeof s?~(a="@"===s?e.lastIndexOf(s):e.indexOf(s))&&("number"==typeof r[2]?(h[l]=e.slice(0,a),e=e.slice(a+r[2])):(h[l]=e.slice(a),e=e.slice(0,a))):(a=s.exec(e))&&(h[l]=a[1],e=e.slice(0,a.index)),h[l]=h[l]||o&&r[3]&&t[l]||"",r[4]&&(h[l]=h[l].toLowerCase())):e=r(e,h);n&&(h.query=n(h.query)),o&&t.slashes&&"/"!==h.pathname.charAt(0)&&(""!==h.pathname||""!==t.pathname)&&(h.pathname=function(e,t){if(""===e)return t;for(var n=(t||"/").split("/").slice(0,-1).concat(e.split("/")),o=n.length,i=n[o-1],s=!1,r=0;o--;)"."===n[o]?n.splice(o,1):".."===n[o]?(n.splice(o,1),r++):r&&(0===o&&(s=!0),n.splice(o,1),r--);return s&&n.unshift(""),"."!==i&&".."!==i||n.push(""),n.join("/")}(h.pathname,t.pathname)),"/"!==h.pathname.charAt(0)&&Tt(h.protocol)&&(h.pathname="/"+h.pathname),ht(h.port,h.protocol)||(h.host=h.hostname,h.port=""),h.username=h.password="",h.auth&&(~(a=h.auth.indexOf(":"))?(h.username=h.auth.slice(0,a),h.username=encodeURIComponent(decodeURIComponent(h.username)),h.password=h.auth.slice(a+1),h.password=encodeURIComponent(decodeURIComponent(h.password))):h.username=encodeURIComponent(decodeURIComponent(h.auth)),h.auth=h.password?h.username+":"+h.password:h.username),h.origin="file:"!==h.protocol&&Tt(h.protocol)&&h.host?h.protocol+"//"+h.host:"null",h.href=h.toString()}St.prototype={set:function(e,t,n){var o=this;switch(e){case"query":"string"==typeof t&&t.length&&(t=(n||ut.parse)(t)),o[e]=t;break;case"port":o[e]=t,ht(t,o.protocol)?t&&(o.host=o.hostname+":"+t):(o.host=o.hostname,o[e]="");break;case"hostname":o[e]=t,o.port&&(t+=":"+o.port),o.host=t;break;case"host":o[e]=t,ft.test(t)?(t=t.split(":"),o.port=t.pop(),o.hostname=t.join(":")):(o.hostname=t,o.port="");break;case"protocol":o.protocol=t.toLowerCase(),o.slashes=!n;break;case"pathname":case"hash":if(t){var i="pathname"===e?"/":"#";o[e]=t.charAt(0)!==i?i+t:t}else o[e]=t;break;case"username":case"password":o[e]=encodeURIComponent(t);break;case"auth":var s=t.indexOf(":");~s?(o.username=t.slice(0,s),o.username=encodeURIComponent(decodeURIComponent(o.username)),o.password=t.slice(s+1),o.password=encodeURIComponent(decodeURIComponent(o.password))):o.username=encodeURIComponent(decodeURIComponent(t))}for(var r=0;r<wt.length;r++){var a=wt[r];a[4]&&(o[a[1]]=o[a[1]].toLowerCase())}return o.auth=o.password?o.username+":"+o.password:o.username,o.origin="file:"!==o.protocol&&Tt(o.protocol)&&o.host?o.protocol+"//"+o.host:"null",o.href=o.toString(),o},toString:function(e){e&&"function"==typeof e||(e=ut.stringify);var t,n=this,o=n.host,i=n.protocol;i&&":"!==i.charAt(i.length-1)&&(i+=":");var s=i+(n.protocol&&n.slashes||Tt(n.protocol)?"//":"");return n.username?(s+=n.username,n.password&&(s+=":"+n.password),s+="@"):n.password?(s+=":"+n.password,s+="@"):"file:"!==n.protocol&&Tt(n.protocol)&&!o&&"/"!==n.pathname&&(s+="@"),(":"===o[o.length-1]||ft.test(n.hostname)&&!n.port)&&(o+=":"),s+=o+n.pathname,(t="object"==typeof n.query?e(n.query):n.query)&&(s+="?"!==t.charAt(0)?"?"+t:t),n.hash&&(s+=n.hash),s}},St.extractProtocol=xt,St.location=Ct,St.trimLeft=yt,St.qs=ut;var It=St;function Ot(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}Object.defineProperty(rt,"__esModule",{value:!0});var kt=Ot(It),Dt=function(){return Dt=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},Dt.apply(this,arguments)};function Nt(e,t,n){if(n||2===arguments.length)for(var o,i=0,s=t.length;i<s;i++)!o&&i in t||(o||(o=Array.prototype.slice.call(t,0,i)),o[i]=t[i]);return e.concat(o||Array.prototype.slice.call(t))}function Lt(e,t){if(!e)throw new Error(t)}function _t(e){Lt("string"==typeof e,"url is not a string");var t=kt.default(e,{});return Lt(t.protocol&&t.hostname,"invalid url: '".concat(e,"', unable to parse hostname")),t}function Rt(e){Lt(!!e&&"object"==typeof e,"Provided filters must be an object");var t=e;void 0!==t.env&&(Lt(t.env instanceof Array,"filters.env must be an array"),Lt(t.env.every((function(e){return Mt.indexOf(e)>=0})),"'".concat(t.env,"' - filters.env must be an array containing only: ").concat(Mt.join(",")))),void 0!==t.status&&(Lt(t.status instanceof Array,"filters.status must be an array"),Lt(t.status.every((function(e){return Bt.indexOf(e)>=0})),"'".concat(t.status,"' - filters.status must be an array containing only: ").concat(Bt.join(","))))}var At=[{name:"dev",env:"dev",region:"us-east-1",status:"stable",publicDomainName:"inindca.com",publicDomainAliases:[]},{name:"fedramp-use2-core",env:"fedramp",region:"us-east-2",status:"stable",publicDomainName:"use2.us-gov-pure.cloud",publicDomainAliases:[]},{name:"prod",env:"prod",region:"us-east-1",status:"stable",publicDomainName:"mypurecloud.com",publicDomainAliases:[]},{name:"prod-apne1",env:"prod",region:"ap-northeast-1",status:"stable",publicDomainName:"mypurecloud.jp",publicDomainAliases:[]},{name:"prod-apne2",env:"prod",region:"ap-northeast-2",status:"stable",publicDomainName:"apne2.pure.cloud",publicDomainAliases:[]},{name:"prod-aps1",env:"prod",region:"ap-south-1",status:"stable",publicDomainName:"aps1.pure.cloud",publicDomainAliases:[]},{name:"prod-apse2",env:"prod",region:"ap-southeast-2",status:"stable",publicDomainName:"mypurecloud.com.au",publicDomainAliases:[]},{name:"prod-cac1",env:"prod",region:"ca-central-1",status:"stable",publicDomainName:"cac1.pure.cloud",publicDomainAliases:[]},{name:"prod-euc1",env:"prod",region:"eu-central-1",status:"stable",publicDomainName:"mypurecloud.de",publicDomainAliases:[]},{name:"prod-euw1",env:"prod",region:"eu-west-1",status:"stable",publicDomainName:"mypurecloud.ie",publicDomainAliases:[]},{name:"prod-euw2",env:"prod",region:"eu-west-2",status:"stable",publicDomainName:"euw2.pure.cloud",publicDomainAliases:[]},{name:"prod-sae1",env:"prod",region:"sa-east-1",status:"stable",publicDomainName:"sae1.pure.cloud",publicDomainAliases:[]},{name:"prod-usw2",env:"prod",region:"us-west-2",status:"stable",publicDomainName:"usw2.pure.cloud",publicDomainAliases:[]},{name:"test",env:"test",region:"us-east-1",status:"stable",publicDomainName:"inintca.com",publicDomainAliases:[]}],Mt=["dev","test","prod","fedramp"],Bt=["alpha","beta","stable","archived"],Ut=["localhost","127.0.0.1"],Pt={env:["prod","fedramp"],status:["stable"]},jt={},zt=function(e){return function(t){return e===t||(n=e,o=".".concat(t),n.slice(n.length-o.length)===o);var n,o}},$t=function(e){void 0===e&&(e=Pt),Rt(e);var t=e.env,n=e.status;return At.filter((function(e){return void 0===t||t.indexOf(e.env)>=0})).filter((function(e){return void 0===n||n.indexOf(e.status)>=0}))},Vt=function(e,t){var n=_t(e).hostname;return $t(t).find((function(e){return Nt([e.publicDomainName],e.publicDomainAliases,!0).filter((function(e){return!!e})).some(zt(n))}))},qt=function(e,t){void 0===e&&(e=window.location.href),void 0===t&&(t=jt),Rt(t);var n=_t(e).hostname,o=Vt(e,t);if(o)return Dt(Dt({},o),{local:!1,currentDomainName:Nt([o.publicDomainName],o.publicDomainAliases,!0).filter((function(e){return!!e})).find(zt(n))})},Wt=function(e){return void 0===e&&(e=Ut),function(t,n){void 0===t&&(t=window.location.href),void 0===n&&(n=jt),Rt(n),function(e,t){void 0===t&&(t="value"),Lt(e instanceof Array,"".concat(t," must be an array of strings"));for(var n=0,o=e;n<o.length;n++)Lt("string"==typeof o[n],"Each item in ".concat(t," must be a string"))}(e,"localHostnames");var o=_t(t),i=o.hostname,s=o.pathname;if(e.indexOf(i)>=0){var r=s.split("/")[1],a=$t(n).find((function(e){return e.name===r}));if(!a)return;return Dt(Dt({},a),{local:!0,currentDomainName:a.publicDomainName})}}};rt.ENVS=Mt,rt.STATUSES=Bt;var Ht=rt.getEnvironments=$t;rt.isKnown=function(e,t){return!!Vt(e,t)},rt.parse=Vt,rt.parseDeployedRuntime=qt,rt.parseRuntime=function(e,t){return void 0===e&&(e=window.location.href),void 0===t&&(t=jt),Wt()(e,t)||qt(e,t)},rt.parseRuntimeFromLocalPath=Wt; /*! * Service Discovery * Resolves URIs and domains for the current env */ const Ft="apps",Gt=Ht({}),Yt=new Map(Gt.map((e=>[e.name,e.publicDomainName])));Yt.set("mock","localhost");const Xt={staticAssets:{subdomain:"app",path:"/cobrowse-next",localPort:"8081"},api:{subdomain:"api",localPort:"8080"},auth:{localhostEnv:"dev",subdomain:"login",path:"/oauth/authorize"},fonts:{subdomain:"app",path:"/webfonts",localPort:"8081"},proxy:{subdomain:"cobrowse-v2",name:"proxy"}};class Kt{constructor(e,t){let n=e.toLowerCase();if(!this.getKeyByValue(Yt,n)){const t=new RegExp("^prod(?:-[a-zA-Z0-9]+)*$");"use1"===n?n="prod":"fedramp-use2"===n?n="fedramp-use2-core":["dev","test","mock","localhost"].includes(n)||t.test(e)||(n=`prod-${n}`)}const o=this.getKeyByValue(Yt,n),i=this.getDomain(n);if("string"!=typeof i&&"mock"!==n)throw new Error(`Unknown environment '${e}'`);t&&(this.apps=this.isSubdomainApps(t)),this.environment=null!=o?o:e,this.domain=i}getDomain(e){if(!Yt.get(e)){const t=this.getKeyByValue(Yt,e);if(t)return Yt.get(t)}return Yt.get(e)}getKeyByValue(e,t){for(const[n,o]of e.entries())if(o===t)return n}getUri(e){const t=Xt[e],{subdomain:n,localPort:o,path:i,localhostEnv:s}=t;let r=this.domain;if("mock"===this.environment){if("proxy"===(null==t?void 0:t.name)){return`https://${n}.${this.getDomain("dev")}/proxy`}if(!s)return`http://localhost:${null!=o?o:"UNKNOWNPORT"}`;r=Yt.get(s)}let a=`https://${n}.${r}`;return"proxy"===(null==t?void 0:t.name)?`${a}/proxy`:(this.apps&&"app"===t.subdomain&&(a=`https://${Ft}.${r}`),i&&(a+=i),a)}isSubdomainApps(e){return new URL(e).host.startsWith(Ft)}static discoverEnvFromDomain(e){for(const[t,n]of Yt.entries()){if(new RegExp(`^.*?${n}$`).test(e.hostname)){const e=it(window.location,"state");if(!e)return t;const n=decodeURIComponent(e),o=new URLSearchParams(n).get("env");return o||t}}throw new Error(`Cannot discover environment from URL: '${e.href}'`)}}Kt.SERVICES=Xt;class Jt{constructor(e,t,n){this.log=s("l10n",n),this.baseUrl=new URL(t);let o=e;Jt.supportedLangs.includes(e)||(this.log.info(`unsupported lang ${e}`),o="en-us"),this.log(`locale: ${o}`),this.lang=o}loadJsLocale(){return r(this,void 0,void 0,(function*(){this.log(`fetching locale: ${this.lang}`);const e=new URL(this.baseUrl);e.pathname+=`/${this.lang}.json`,e.pathname=e.pathname.replace("//","/");const t=yield this.fetch(e.toString());if(!t.ok)throw new Error("Network response for localization was not OK");return t.json()}))}fetch(e){return fetch(e)}}Jt.supportedLangs="ar cs da de en-us es fi fr he it ja ko nl no pl pt-br pt-pt ru sv tr zh-cn".split(" ");let Qt="ERROR",Zt="#0071BC",en=!1;let tn,nn;const on=s("CXBusPlugin");function sn(e){return e.data("offerState")}function rn(e,t=window.navigator){const n=function(e=window.navigator){const t=e.languages&&e.languages[0]||e.language;return t&&"string"==typeof t?t.toLowerCase():""}(t);if(e){const t=e.defaultLanguage;let o=e.languages||void 0;return o&&(o=o.map((e=>e.toLowerCase()))),o&&-1!==o.indexOf(n)?tn=n:t&&(tn=t),tn}const o="Default language not specified";throw on.error(o),Error(o)}const an=new class{registerWithCXBus2(){const e=window;if(!function(e){return"Genesys"in e}(e))throw new Error("Failed to register with CXBus. Make sure you have genesys.js loaded on the page to use cobrowse");on("detected global Genesys function, registering as CXBus plugin"),function(e,t,n){e.Genesys("registerPlugin",t,n)}(e,"CobrowseService",(e=>{var t,n,o,i,s,a;const l=e.data("GenesysJS.deploymentConfig"),d=e.data("GenesysJS.snippetConfig");if("string"!=typeof(null==d?void 0:d.deploymentId))return void on.error("configuration error, exiting (deployment id is not found)");if("boolean"!=typeof(null===(t=null==l?void 0:l.cobrowse)||void 0===t?void 0:t.allowAgentControl))return void on.error("configuration error, exiting (allowAgentControl is not found)");if("object"!=typeof(null===(n=null==l?void 0:l.cobrowse)||void 0===n?void 0:n.maskSelectors))return void on.error("configuration error, exiting (maskSelectors is not found)");(null===(o=null==d?void 0:d.cobrowse)||void 0===o?void 0:o.logLevel)&&(Qt=d.cobrowse.logLevel),(null==d?void 0:d.debug)&&(Qt="DEBUG"),on.setLogLevel(Qt),(null==d?void 0:d.environment)&&(nn=d.environment),(null===(s=null===(i=null==l?void 0:l.messenger)||void 0===i?void 0:i.styles)||void 0===s?void 0:s.primaryColor)&&(Zt=l.messenger.styles.primaryColor),(null==l?void 0:l.headlessMode)&&(null===(a=null==l?void 0:l.headlessMode)||void 0===a?void 0:a.enabled)&&(en=l.headlessMode.enabled);const c=rn(l),h=new Kt(nn);let u=h.getUri("api");"cobrowseUrl"in window&&(on("window.cobrowseUrl is set, overriding the API URL"),u=window.cobrowseUrl);const g=new Jt(c,h.getUri("staticAssets"),Qt),p={apiUrl:u,logLevel:Qt,primaryColor:Zt,env:nn,ignoredSelectors:[".genesys-mxg-frame"],deploymentId:d.deploymentId},[m,f]=this.initCobrowseCore(p,e,g,h,en);!function(e,t,n){function o(n,o,i){const s={sessionId:o,offerState:n,timeout:i||null,timestamp:Date.now()};return e.data("offerState",s),t.network.setOfferState(s)}function i(){const t=e.data("activeSession");return t&&"object"==typeof t&&"sessionId"in t}e.registerEvents(["sessionStarted","sessionDeclined","sessionEnded","controlRequested","controlGranted","controlRevoked","navigationRequested","navigationGranted","navigationDeclined"]),e.registerCommand("offerState",(n=>r(this,void 0,void 0,(function*(){const s=n.data.sessionId,r=n.data.joinCode;let a,l;on("CXBus offerState command called with: ",n);try{a=t.network.getOfferState(s||r)}catch(t){on.error("Error while getting offer states",t),e.data("offerState",!1),n.reject(t.message)}if(a&&a.length&&(on(`offer state found in storage for session ${r}: `,a,a[0]),l=a[0]),!l&&i()&&(o("failed",s||r),l=sn(e),on(`another session in progress, setting offer state to "failed" for session ${s||r}`)),!l){on(`offer state not found in storage for session ${r}`);try{let e="expired",n=null;on(`offer state not found in storage for session ${r}, assuming it has expired`);const o=yield t.network.fetchSessionInfo(r);if(o.ok){on(`actually, turns out user has not yet accepted, so marking offer as "active" for session ${r}`),e="active";const t=(yield o.json()).dateOfferEnds;n=Date.parse(t)}l={sessionId:s,offerState:e,timeout:n,timestamp:Date.now()}}catch(t){return on(`error getting state data, rejecting offerState command for session ${r}`,t),e.data("offerState",!1),void n.reject(t.message)}}e.data("offerState",l),on(`resolving offerState command for session ${r} with: `,l.offerState,l),n.resolve(l)})))),e.registerCommand("acceptSession",(e=>r(this,void 0,void 0,(function*(){let s;on("CXBus acceptSession",e.data),s="string"==typeof e.data?e.data:e.data.joinToken||e.data.joinCode;const r=e.data.sessionId||s;if("string"!=typeof s||"string"!=typeof r)throw on.error("Got wrong data from CXBus caller: ",e),new Error("acceptSession requires cobrowse `joinCode` as a string");if(i())return on.error("Cannot call acceptSession while another session is in progress"),void e.reject({code:"COBROWSEACTIVE"});o("accepted",r);try{t.geti18n(),on("localization was already loaded")}catch(e){on("localization was not loaded, loading"),yield t.loadi18n()}on(`begin session ${s}`),n.startModules(),t.pubsub.notify("int:user-requested-join",{joinCode:s}),t.pubsub.listen("int:session-ready",(t=>{t.data.joinCode===s&&e.resolve()})),t.pubsub.listen("int:session-load-failed",(()=>{e.reject({code:"JOINFAILURE"})}))})))),e.registerCommand("declineSession",(n=>r(this,void 0,void 0,(function*(){on("CXBus declineSession",n.data);const i=n.data.sessionId,s=n.data.joinToken||n.data.joinCode;e.publish("sessionDeclined",{sessionId:i,joinCode:s}),e.publish("sessionDeleted",{sessionId:i,joinCode:s}),o("rejected",null!=i?i:s);try{yield t.network.deleteSession(null!=i?i:s)}catch(e){on("Failed to delete session: ",e)}n.resolve()})))),e.registerCommand("stopSession",(n=>{on("CXBus stopSession");const o=e.data("activeSession"),i=null==o?void 0:o.sessionId,s=null==o?void 0:o.joinCode;i||s?t.pubsub.notify("int:user-requested-stop"):(on("Looks like there is no active session to stop"),n.reject()),n.resolve()})),e.registerCommand("acceptControl",(n=>{if(on("CXBus acceptControl"),i()&&e.data("controlRequested"))return t.pubsub.notify("int:control-enable"),e.data("controlRequested",!1),void n.resolve();on("Cannot accept control as it was not requested"),n.reject()})),e.registerCommand("declineControl",(n=>{if(on("CXBus declineControl"),e.data("controlRequested",!1),!i())return on("Cannot decline control as no active session"),void n.reject();t.pubsub.notify("int:control-disable"),n.resolve()})),e.registerCommand("acceptNavigation",(n=>{var o;if(on("CXBus acceptNavigation"),e.data("navigationRequested",!1),!i())return on("no active session, exiting"),n.reject();if("string"!=typeof(null===(o=null==n?void 0:n.data)||void 0===o?void 0:o.url))return on("Unexpected event data: ",n),void n.reject();const s=n.data.url;if("string"!=typeof s)return on("Unexpected url ",s),void n.reject();e.publish("navigationGranted"),t.pubsub.notify("int:navigate",{url:s}),n.resolve()})),e.registerCommand("declineNavigation",(t=>{if(on("CXBus declineNavigation"),e.data("navigationRequested",!1),!i())return on("Cannot decline navigation as no active session"),void t.reject();e.publish("navigationDeclined"),t.resolve()})),e.registerCommand("startDrawing",(e=>{if(on("CXBus startDrawing"),!i())return on("no active session, exiting"),e.reject();t.pubsub.notify("int:draw-start"),e.resolve()})),e.registerCommand("stopDrawing",(e=>{if(on("CXBus stopDrawing"),!i())return on("no active session, exiting"),e.reject();t.pubsub.notify("int:draw-end"),e.resolve()})),e.subscribe("Toaster.accepted",(()=>{const t=e.data("navigationRequested"),n=e.data("controlRequested");t&&e.command("acceptNavigation"),n&&e.command("acceptControl")})),e.subscribe("Toaster.declined",(()=>{const t=e.data("navigationRequested"),n=e.data("controlRequested");t&&e.command("declineNavigation"),n&&e.command("declineControl")})),e.subscribe("MessengerHelper.onWebSocketClose",(()=>{e.command("stopSession")})),e.subscribe("Auth.loggedOut",(()=>{e.command("stopSession")})),t.pubsub.listenForever("int:session-ready",(t=>{const n=t.data,i=sn(e);(null==i?void 0:i.sessionId)&&(i.sessionId===n.joinCode&&"active"===i.offerState?o("accepted",n.joinCode):i.sessionId===n.id&&"active"===i.offerState&&o("accepted",n.id)),e.publish("sessionStarted",{sessionId:n.id,joinCode:n.joinCode}),e.data("activeSession",{sessionId:t.data.id,joinCode:t.data.joinCode})})),t.pubsub.listenForever("int:session-offering-sent",(e=>{o("active",e.data.sessionId,e.data.offerTimeout)})),t.pubsub.listenForever("int:session-end",(()=>{on("Session ended");const t=e.data("activeSession"),n=null==t?void 0:t.sessionId;e.data("activeSession",!1),e.data("controlRequested",!1),e.data("navigationRequested",!1),n?(o("expired",n),e.publish("sessionEnded")):on("Looks like there is no active session")})),t.pubsub.listenForever("int:session-expired",(e=>{o("expired",e.data.sessionId)})),t.pubsub.listenForever("int:control-requested",(()=>{var n,o,i,s;const r=t.getDeploymentOptions();e.data("controlRequested",!0),e.publish("controlRequested"),!r.isNewToolbarEnabled&&!_.enabled||en||e.command("Toaster.open",{title:null===(n=t.i18n)||void 0===n?void 0:n.requestControlHeader,body:null===(o=t.i18n)||void 0===o?void 0:o.requestControlDescription,buttons:{type:"binary",primary:null===(i=t.i18n)||void 0===i?void 0:i.accept,secondary:null===(s=t.i18n)||void 0===s?void 0:s.decline}}).catch((e=>{on(`Error while calling Toaster Open: ${e.message}`)}))})),t.pubsub.listenForever("int:control-granted",(()=>{e.publish("controlGranted"),e.data("controlRequested",!1)})),t.pubsub.listenForever("int:control-revoked",(()=>{e.publish("controlRevoked"),e.data("controlRequested",!1)})),t.pubsub.listenForever("int:navigation-requested",(n=>{var o,i,s,r;e.data("navigationRequested",!0),e.publish("navigationRequested",{url:n.data.url}),e.command("Toaster.open",{title:null===(o=t.i18n)||void 0===o?void 0:o.requestNavigationTitle,body:null===(i=t.i18n)||void 0===i?void 0:i.requestNavigationBody,buttons:{type:"binary",primary:null===(s=t.i18n)||void 0===s?void 0:s.requestNavigationAccept,secondary:null===(r=t.i18n)||void 0===r?void 0:r.requestNavigationDecline}}).catch((e=>{on(`Error while calling Toaster Open. Error: ${e.message}`)}))})),e.data("activeSession",!1),e.data("controlRequested",!1),e.data("navigationRequested",!1),e.ready()}(e,m,f)}))}initCobrowseCore(e,t,n,o,i){const s=new Ee(e,o,n);return[s,new ot(s,t,i)]}getLogLevel(){return Qt}getPrimaryColor(){return Zt}isHeadlessModeOn(){return en}},ln=s("cobrowseSharerApp",an.getLogLevel());try{an.registerWithCXBus2()}catch(e){ln(e.message,e),ln("not starting cobrowse")}}();