text: self["EventListeners"]=self["EventListeners"]||{};EventListeners.EventListenersResult;EventListeners.EventListenersView=class extends UI.VBox{constructor(e){super();this._changeCallback=e;this._treeOutline=new UI.TreeOutlineInShadow;this._treeOutline.hideOverflow();this._treeOutline.registerRequiredCSS("object_ui/objectValue.css");this._treeOutline.registerRequiredCSS("event_listeners/eventListenersView.css");this._treeOutline.setComparator(EventListeners.EventListenersTreeElement.comparator);this._treeOutline.element.classList.add("monospace");this._treeOutline.setShowSelectionOnKeyboardFocus(true);this._treeOutline.setFocusable(true);this.element.appendChild(this._treeOutline.element);this._emptyHolder=createElementWithClass("div","gray-info-message");this._emptyHolder.textContent=Common.UIString("No event listeners");this._linkifier=new Components.Linkifier;this._treeItemMap=new Map}async addObjects(e){this.reset();await Promise.all(e.map(e=>e?this._addObject(e):Promise.resolve()));this.addEmptyHolderIfNeeded();this._eventListenersArrivedForTest()}_addObject(e){let t;let n=null;const r=[];const i=e.runtimeModel().target().model(SDK.DOMDebuggerModel);if(i)r.push(i.eventListeners(e).then(s));r.push(EventListeners.frameworkEventListeners(e).then(o));return Promise.all(r).then(l).then(c.bind(this));function s(e){t=e}function o(e){n=e}function l(){if(!n.internalHandlers)return Promise.resolve(undefined);return n.internalHandlers.object().callFunctionJSON(r,t.map(e)).then(i);function e(e){return SDK.RemoteObject.toCallArgument(e.handler())}function r(){const e=[];const t=new Set(this);for(const n of arguments)e.push(t.has(n));return e}function i(e){for(let n=0;n<t.length;++n){if(e[n])t[n].markAsFramework()}}}function c(){this._addObjectEventListeners(e,t);this._addObjectEventListeners(e,n.eventListeners)}}_addObjectEventListeners(e,t){if(!t)return;for(const n of t){const t=this._getOrCreateTreeElementForType(n.type());t.addObjectEventListener(n,e)}}showFrameworkListeners(e,t,n){const r=this._treeOutline.rootElement().children();for(const i of r){let r=true;for(const s of i.children()){const i=s.eventListener().origin();let o=false;if(i===SDK.EventListener.Origin.FrameworkUser&&!e)o=true;if(i===SDK.EventListener.Origin.Framework&&e)o=true;if(!t&&s.eventListener().passive())o=true;if(!n&&!s.eventListener().passive())o=true;s.hidden=o;r=r&&o}i.hidden=r}}_getOrCreateTreeElementForType(e){let t=this._treeItemMap.get(e);if(!t){t=new EventListeners.EventListenersTreeElement(e,this._linkifier,this._changeCallback);this._treeItemMap.set(e,t);t.hidden=true;this._treeOutline.appendChild(t)}this._emptyHolder.remove();return t}addEmptyHolderIfNeeded(){let e=true;let t=null;for(const n of this._treeOutline.rootElement().children()){n.hidden=!n.firstChild();e=e&&n.hidden;if(!t&&!n.hidden)t=n}if(e&&!this._emptyHolder.parentNode)this.element.appendChild(this._emptyHolder);if(t)t.select(true)}reset(){const e=this._treeOutline.rootElement().children();for(const t of e)t.removeChildren();this._linkifier.reset()}_eventListenersArrivedForTest(){}};EventListeners.EventListenersTreeElement=class extends UI.TreeElement{constructor(e,t,n){super(e);this.toggleOnClick=true;this._linkifier=t;this._changeCallback=n}static comparator(e,t){if(e.title===t.title)return 0;return e.title>t.title?1:-1}addObjectEventListener(e,t){const n=new EventListeners.ObjectEventListenerBar(e,t,this._linkifier,this._changeCallback);this.appendChild(n)}};EventListeners.ObjectEventListenerBar=class extends UI.TreeElement{constructor(e,t,n,r){super("",true);this._eventListener=e;this.editable=false;this._setTitle(t,n);this._changeCallback=r}async onpopulate(){const e=[];const t=this._eventListener;const n=t.domDebuggerModel().runtimeModel();e.push(n.createRemotePropertyFromPrimitiveValue("useCapture",t.useCapture()));e.push(n.createRemotePropertyFromPrimitiveValue("passive",t.passive()));e.push(n.createRemotePropertyFromPrimitiveValue("once",t.once()));if(typeof t.handler()!=="undefined")e.push(new SDK.RemoteObjectProperty("handler",t.handler()));ObjectUI.ObjectPropertyTreeElement.populateWithProperties(this,e,[],true,null)}_setTitle(e,t){const n=this.listItemElement.createChild("span");const r=this.listItemElement.createChild("span","event-listener-tree-subtitle");r.appendChild(t.linkifyRawLocation(this._eventListener.location(),this._eventListener.sourceURL()));n.appendChild(ObjectUI.ObjectPropertiesSection.createValueElement(e,false,false));if(this._eventListener.canRemove()){const e=n.createChild("span","event-listener-button");e.textContent=Common.UIString("Remove");e.title=Common.UIString("Delete event listener");e.addEventListener("click",i.bind(this),false);n.appendChild(e)}if(this._eventListener.isScrollBlockingType()&&this._eventListener.canTogglePassive()){const e=n.createChild("span","event-listener-button");e.textContent=Common.UIString("Toggle Passive");e.title=Common.UIString("Toggle whether event listener is passive or blocking");e.addEventListener("click",s.bind(this),false);n.appendChild(e)}function i(e){e.consume();this._removeListenerBar();this._eventListener.remove()}function s(e){e.consume();this._eventListener.togglePassive().then(this._changeCallback())}}_removeListenerBar(){const e=this.parent;e.removeChild(this);if(!e.childCount())e.collapse();let t=true;for(let n=0;n<e.childCount();++n){if(!e.childAt(n).hidden)t=false}e.hidden=t}eventListener(){return this._eventListener}};EventListeners.FrameworkEventListenersObject;EventListeners.EventListenerObjectInInspectedPage;EventListeners.frameworkEventListeners=function(e){const t=e.runtimeModel().target().model(SDK.DOMDebuggerModel);if(!t){return Promise.resolve({eventListeners:[],internalHandlers:null})}const n={eventListeners:[]};return e.callFunction(p,undefined).then(f).then(r).then(i).then(h).catchException(n);function r(e){return e.getOwnProperties(false)}function i(e){if(!e.properties)throw new Error("Object properties is empty");const t=[];for(const n of e.properties){if(n.name==="eventListeners"&&n.value)t.push(s(n.value).then(c));if(n.name==="internalHandlers"&&n.value)t.push(o(n.value).then(a));if(n.name==="errorString"&&n.value)u(n.value)}return Promise.all(t)}function s(n){return SDK.RemoteArray.objectAsArray(n).map(r).then(d);function r(n){let r;let i;let s;let o;let c=null;let a=null;let u=null;let h=null;const d=[];d.push(n.callFunctionJSON(p,undefined).then(v));function p(){return{type:this.type,useCapture:this.useCapture,passive:this.passive,once:this.once}}function v(e){r=e.type;i=e.useCapture;s=e.passive;o=e.once}d.push(n.callFunction(m).then(f).then(L).then(l).then(g));function m(){return this.handler}function L(e){a=e;return a}function g(e){c=e;return e.debuggerModel().functionDetailsPromise(e).then(b)}function b(e){u=e?e.location:null}d.push(n.callFunction(y).then(f).then(E));function y(){return this.remove}function E(e){if(e.type!=="function")return;h=e}return Promise.all(d).then(_).catchException(null);function _(){if(!u)throw new Error("Empty event listener's location");return new SDK.EventListener(t,e,r,i,s,o,c,a,u,h,SDK.EventListener.Origin.FrameworkUser)}}}function o(e){return SDK.RemoteArray.objectAsArray(e).map(l).then(SDK.RemoteArray.createFromRemoteObjects)}function l(e){return SDK.RemoteFunction.objectAsFunction(e).targetFunction()}function c(e){n.eventListeners=e}function a(e){n.internalHandlers=e}function u(e){Common.console.error(String(e.value))}function h(){return n}function f(e){if(e.wasThrown||!e.object)throw new Error("Exception in callFunction or empty result");return e.object}function d(e){return e.filter(t);function t(e){return!!e}}function p(){const e=[];let t=[];let n=[];let r=[u];try{if(self.devtoolsFrameworkEventListeners&&s(self.devtoolsFrameworkEventListeners))r=r.concat(self.devtoolsFrameworkEventListeners)}catch(t){e.push("devtoolsFrameworkEventListeners call produced error: "+c(t))}for(let i=0;i<r.length;++i){try{const u=r[i](this);if(u.eventListeners&&s(u.eventListeners)){t=t.concat(u.eventListeners.map(o).filter(a))}if(u.internalHandlers&&s(u.internalHandlers)){n=n.concat(u.internalHandlers.map(l).filter(a))}}catch(t){e.push("fetcher call produced error: "+c(t))}}const i={eventListeners:t};if(n.length)i.internalHandlers=n;if(e.length){let t="Framework Event Listeners API Errors:\n\t"+e.join("\n\t");t=t.substr(0,t.length-1);i.errorString=t}return i;function s(e){if(!e||typeof e!=="object")return false;try{if(typeof e.splice==="function"){const t=e.length;return typeof t==="number"&&(t>>>0===t&&(t>0||1/t>0))}}catch(e){}return false}function o(t){try{let n="";if(!t)n+="empty event listener, ";const r=t.type;if(!r||typeof r!=="string")n+="event listener's type isn't string or empty, ";const i=t.useCapture;if(typeof i!=="boolean")n+="event listener's useCapture isn't boolean or undefined, ";const s=t.passive;if(typeof s!=="boolean")n+="event listener's passive isn't boolean or undefined, ";const o=t.once;if(typeof o!=="boolean")n+="event listener's once isn't boolean or undefined, ";const l=t.handler;if(!l||typeof l!=="function")n+="event listener's handler isn't a function or empty, ";const a=t.remove;if(a&&typeof a!=="function")n+="event listener's remove isn't a function, ";if(!n){return{type:r,useCapture:i,passive:s,once:o,handler:l,remove:a}}else{e.push(n.substr(0,n.length-2));return null}}catch(t){e.push(c(t));return null}}function l(t){if(t&&typeof t==="function")return t;e.push("internal handler isn't a function or empty");return null}function c(e){try{return""+e}catch(e){return"<error>"}}function a(e){return!!e}function u(e){if(!e||!(e instanceof Node))return{eventListeners:[]};const t=window["jQuery"];if(!t||!t.fn)return{eventListeners:[]};const n=t;const r=t._data||t.data;const i=[];const s=[];if(typeof r==="function"){const t=r(e,"events");for(const n in t){for(const r in t[n]){const s=t[n][r];if(typeof s==="object"||typeof s==="function"){const t={handler:s.handler||s,useCapture:true,passive:false,once:false,type:n};t.remove=h.bind(e,s.selector);i.push(t)}}}const n=r(e);if(n&&typeof n.handle==="function")s.push(n.handle)}const o=n(e)[0];if(o){const e=o["$events"];for(const t in e){const n=e[t];for(const e in n){if(typeof n[e]==="function"){const r={handler:n[e],useCapture:true,passive:false,once:false,type:t};i.push(r)}}}if(o&&o["$handle"])s.push(o["$handle"])}return{eventListeners:i,internalHandlers:s}}function h(e,t,n){if(!this||!(this instanceof Node))return;const r=this;const i=window["jQuery"];if(!i||!i.fn)return;const s=i;s(r).off(t,e,n)}}};Runtime.cachedResources["event_listeners/eventListenersView.css"]="/*\n * Copyright 2015 The Chromium Authors. All rights reserved.\n * Use of this source code is governed by a BSD-style license that can be\n * found in the LICENSE file.\n */\n\n.tree-outline-disclosure li {\n    padding: 2px 0 0 5px;\n    overflow: hidden;\n    display: list-item;\n    min-height: 17px;\n}\n\n.tree-outline-disclosure > li {\n    border-top: 1px solid #f0f0f0;\n}\n\n.tree-outline-disclosure > li:first-of-type {\n    border-top: none;\n}\n\n.tree-outline-disclosure {\n    padding-left: 0 !important;\n    padding-right: 3px;\n}\n\n.tree-outline-disclosure li.parent::before {\n    top: 0 !important;\n}\n\n.tree-outline-disclosure .name {\n    color: rgb(136, 19, 145);\n}\n\n.event-listener-tree-subtitle {\n    float: right;\n    margin-left: 5px;\n}\n\n.event-listener-button {\n    padding: 0 3px;\n    background-color: #f2f2f2;\n    border-radius: 3px;\n    border: 1px solid #c3c3c3;\n    margin-left: 10px;\n    display: none;\n    cursor: pointer;\n}\n\n.event-listener-button:hover {\n    background-color: #e0e0e0;\n}\n\n.tree-outline-disclosure li:hover .event-listener-button {\n    display: inline;\n}\n";