import{DOMModel,SDKModel,OverlayModel}from'../sdk/sdk.js';import{Linkifier,Revealer}from'../common/common.js';import{View,TreeOutline,UIUtils,TextPrompt,ARIAUtils,ContextMenu,ThrottledWidget,ViewManager}from'../ui/ui.js';class AccessibilityNode{constructor(accessibilityModel,payload){this._accessibilityModel=accessibilityModel;this._agent=accessibilityModel._agent;this._id=payload.nodeId;accessibilityModel._setAXNodeForAXId(this._id,this);if(payload.backendDOMNodeId){accessibilityModel._setAXNodeForBackendDOMNodeId(payload.backendDOMNodeId,this);this._backendDOMNodeId=payload.backendDOMNodeId;this._deferredDOMNode=new DOMModel.DeferredDOMNode(accessibilityModel.target(),payload.backendDOMNodeId);}else{this._backendDOMNodeId=null;this._deferredDOMNode=null;}
this._ignored=payload.ignored;if(this._ignored&&'ignoredReasons'in payload){this._ignoredReasons=payload.ignoredReasons;}
this._role=payload.role||null;this._name=payload.name||null;this._description=payload.description||null;this._value=payload.value||null;this._properties=payload.properties||null;this._childIds=payload.childIds||null;this._parentNode=null;}
accessibilityModel(){return this._accessibilityModel;}
ignored(){return this._ignored;}
ignoredReasons(){return this._ignoredReasons||null;}
role(){return this._role||null;}
coreProperties(){const properties=[];if(this._name){properties.push(({name:'name',value:this._name}));}
if(this._description){properties.push(({name:'description',value:this._description}));}
if(this._value){properties.push(({name:'value',value:this._value}));}
return properties;}
name(){return this._name||null;}
description(){return this._description||null;}
value(){return this._value||null;}
properties(){return this._properties||null;}
parentNode(){return this._parentNode;}
_setParentNode(parentNode){this._parentNode=parentNode;}
isDOMNode(){return!!this._backendDOMNodeId;}
backendDOMNodeId(){return this._backendDOMNodeId;}
deferredDOMNode(){return this._deferredDOMNode;}
highlightDOMNode(){if(!this.deferredDOMNode()){return;}
this.deferredDOMNode().highlight();}
children(){const children=[];if(!this._childIds){return children;}
for(const childId of this._childIds){const child=this._accessibilityModel.axNodeForId(childId);if(child){children.push(child);}}
return children;}
numChildren(){if(!this._childIds){return 0;}
return this._childIds.length;}
hasOnlyUnloadedChildren(){if(!this._childIds||!this._childIds.length){return false;}
return!this._childIds.some(id=>this._accessibilityModel.axNodeForId(id)!==undefined);}}
class AccessibilityModel extends SDKModel.SDKModel{constructor(target){super(target);this._agent=target.accessibilityAgent();this._axIdToAXNode=new Map();this._backendDOMNodeIdToAXNode=new Map();}
clear(){this._axIdToAXNode.clear();}
async requestPartialAXTree(node){const payloads=await this._agent.getPartialAXTree(node.id,undefined,undefined,true);if(!payloads){return;}
for(const payload of payloads){new AccessibilityNode(this,payload);}
for(const axNode of this._axIdToAXNode.values()){for(const axChild of axNode.children()){axChild._setParentNode(axNode);}}}
axNodeForId(axId){return this._axIdToAXNode.get(axId);}
_setAXNodeForAXId(axId,axNode){this._axIdToAXNode.set(axId,axNode);}
axNodeForDOMNode(domNode){if(!domNode){return null;}
return this._backendDOMNodeIdToAXNode.get(domNode.backendNodeId());}
_setAXNodeForBackendDOMNodeId(backendDOMNodeId,axNode){this._backendDOMNodeIdToAXNode.set(backendDOMNodeId,axNode);}}
SDKModel.SDKModel.register(AccessibilityModel,SDKModel.Capability.DOM,false);var AccessibilityModel$1=Object.freeze({__proto__:null,AccessibilityNode:AccessibilityNode,AccessibilityModel:AccessibilityModel});const AXAttributes={'disabled':{name:ls`Disabled`,description:ls`If true, this element currently cannot be interacted with.`,group:'AXGlobalStates'},'invalid':{name:ls`Invalid user entry`,description:ls`If true, this element's user-entered value does not conform to validation requirement.`,group:'AXGlobalStates'},'editable':{name:ls`Editable`,description:ls`If and how this element can be edited.`},'focusable':{name:ls`Focusable`,description:ls`If true, this element can receive focus.`},'focused':{name:ls`Focused`,description:ls`If true, this element currently has focus.`},'settable':{name:ls`Can set value`,description:ls`Whether the value of this element can be set.`},'live':{name:ls`Live region`,description:ls`Whether and what priority of live updates may be expected for this element.`,group:'AXLiveRegionAttributes'},'atomic':{name:ls`Atomic (live regions)`,description:ls`If this element may receive live updates, whether the entire live region should be presented to the user on changes, or only changed nodes.`,group:'AXLiveRegionAttributes'},'relevant':{name:ls`Relevant (live regions)`,description:ls`If this element may receive live updates, what type of updates should trigger a notification.`,group:'AXLiveRegionAttributes'},'busy':{name:ls`Busy (live regions)`,description:ls`Whether this element or its subtree are currently being updated (and thus may be in an inconsistent state).`,group:'AXLiveRegionAttributes'},'root':{name:ls`Live region root`,description:ls`If this element may receive live updates, the root element of the containing live region.`,group:'AXLiveRegionAttributes'},'autocomplete':{name:ls`Has autocomplete`,description:ls`Whether and what type of autocomplete suggestions are currently provided by this element.`,group:'AXWidgetAttributes'},'haspopup':{name:ls`Has popup`,description:ls`Whether this element has caused some kind of pop-up (such as a menu) to appear.`,group:'AXWidgetAttributes'},'level':{name:ls`Level`,description:ls`The hierarchical level of this element.`,group:'AXWidgetAttributes'},'multiselectable':{name:ls`Multi-selectable`,description:ls`Whether a user may select more than one option from this widget.`,group:'AXWidgetAttributes'},'orientation':{name:ls`Orientation`,description:ls`Whether this linear element's orientation is horizontal or vertical.`,group:'AXWidgetAttributes'},'multiline':{name:ls`Multi-line`,description:ls`Whether this text box may have more than one line.`,group:'AXWidgetAttributes'},'readonly':{name:ls`Read-only`,description:ls`If true, this element may be interacted with, but its value cannot be changed.`,group:'AXWidgetAttributes'},'required':{name:ls`Required`,description:ls`Whether this element is a required field in a form.`,group:'AXWidgetAttributes'},'valuemin':{name:ls`Minimum value`,description:ls`For a range widget, the minimum allowed value.`,group:'AXWidgetAttributes'},'valuemax':{name:ls`Maximum value`,description:ls`For a range widget, the maximum allowed value.`,group:'AXWidgetAttributes'},'valuetext':{name:ls`Value description`,description:ls`A human-readable version of the value of a range widget (where necessary).`,group:'AXWidgetAttributes'},'checked':{name:ls`Checked`,description:ls`Whether this checkbox, radio button or tree item is checked, unchecked, or mixed (e.g. has both checked and un-checked children).`,group:'AXWidgetStates'},'expanded':{name:ls`Expanded`,description:ls`Whether this element, or another grouping element it controls, is expanded.`,group:'AXWidgetStates'},'pressed':{name:ls`Pressed`,description:ls`Whether this toggle button is currently in a pressed state.`,group:'AXWidgetStates'},'selected':{name:ls`Selected`,description:ls`Whether the option represented by this element is currently selected.`,group:'AXWidgetStates'},'activedescendant':{name:ls`Active descendant`,description:ls`The descendant of this element which is active; i.e. the element to which focus should be delegated.`,group:'AXRelationshipAttributes'},'flowto':{name:ls`Flows to`,description:ls`Element to which the user may choose to navigate after this one, instead of the next element in the DOM order.`,group:'AXRelationshipAttributes'},'controls':{name:ls`Controls`,description:ls`Element or elements whose content or presence is/are controlled by this widget.`,group:'AXRelationshipAttributes'},'describedby':{name:ls`Described by`,description:ls`Element or elements which form the description of this element.`,group:'AXRelationshipAttributes'},'labelledby':{name:ls`Labeled by`,description:ls`Element or elements which may form the name of this element.`,group:'AXRelationshipAttributes'},'owns':{name:ls`Owns`,description:ls`Element or elements which should be considered descendants of this element, despite not being descendants in the DOM.`,group:'AXRelationshipAttributes'},'name':{name:ls`Name`,description:ls`The computed name of this element.`,group:'Default'},'role':{name:ls`Role`,description:ls`Indicates the purpose of this element, such as a user interface idiom for a widget, or structural role within a document.`,group:'Default'},'value':{name:ls`Value`,description:ls`The value of this element; this may be user-provided or developer-provided, depending on the element.`,group:'Default'},'help':{name:ls`Help`,description:ls`The computed help text for this element.`,group:'Default'},'description':{name:ls`Description`,description:ls`The accessible description for this element.`,group:'Default'}};const AXSourceTypes={'attribute':{name:ls`From attribute`,description:ls`Value from attribute.`},'implicit':{name:ls`Implicit`,description:ls`Implicit value.`,},'style':{name:ls`From style`,description:ls`Value from style.`},'contents':{name:ls`Contents`,description:ls`Value from element contents.`},'placeholder':{name:ls`From placeholder attribute`,description:ls`Value from placeholder attribute.`},'relatedElement':{name:ls`Related element`,description:ls`Value from related element.`}};const AXNativeSourceTypes={'figcaption':{name:ls`From caption`,description:ls`Value from figcaption element.`},'label':{name:ls`From label`,description:ls`Value from label element.`},'labelfor':{name:ls`From label (for)`,description:ls`Value from label element with for= attribute.`},'labelwrapped':{name:ls`From label (wrapped)`,description:ls`Value from label element wrapped.`},'tablecaption':{name:ls`From caption`,description:ls`Value from table caption.`},'title':{name:ls`From title`,description:ls`Value from title attribute.`},'other':{name:ls`From native HTML`,description:ls`Value from native HTML (unknown source).`},};var AccessibilityStrings=Object.freeze({__proto__:null,AXAttributes:AXAttributes,AXSourceTypes:AXSourceTypes,AXNativeSourceTypes:AXNativeSourceTypes});class AccessibilitySubPane extends View.SimpleView{constructor(name){super(name);this._axNode=null;this.registerRequiredCSS('accessibility/accessibilityProperties.css');}
setAXNode(axNode){}
node(){return this._node;}
setNode(node){this._node=node;}
createInfo(textContent,className){const classNameOrDefault=className||'gray-info-message';const info=this.element.createChild('div',classNameOrDefault);info.textContent=textContent;return info;}
createTreeOutline(){const treeOutline=new TreeOutline.TreeOutlineInShadow();treeOutline.registerRequiredCSS('accessibility/accessibilityNode.css');treeOutline.registerRequiredCSS('accessibility/accessibilityProperties.css');treeOutline.registerRequiredCSS('object_ui/objectValue.css');treeOutline.element.classList.add('hidden');treeOutline.hideOverflow();this.element.appendChild(treeOutline.element);return treeOutline;}}
var AccessibilitySubPane$1=Object.freeze({__proto__:null,AccessibilitySubPane:AccessibilitySubPane});class AXNodeSubPane extends AccessibilitySubPane{constructor(){super(ls`Computed Properties`);this._axNode=null;this.contentElement.classList.add('ax-subpane');this._noNodeInfo=this.createInfo(ls`No accessibility node`);this._ignoredInfo=this.createInfo(ls`Accessibility node not exposed`,'ax-ignored-info hidden');this._treeOutline=this.createTreeOutline();this._ignoredReasonsTree=this.createTreeOutline();this.element.classList.add('accessibility-computed');this.registerRequiredCSS('accessibility/accessibilityNode.css');this._treeOutline.setFocusable(true);}
setAXNode(axNode){if(this._axNode===axNode){return;}
this._axNode=axNode;const treeOutline=this._treeOutline;treeOutline.removeChildren();const ignoredReasons=this._ignoredReasonsTree;ignoredReasons.removeChildren();if(!axNode){treeOutline.element.classList.add('hidden');this._ignoredInfo.classList.add('hidden');ignoredReasons.element.classList.add('hidden');this._noNodeInfo.classList.remove('hidden');this.element.classList.add('ax-ignored-node-pane');return;}
if(axNode.ignored()){this._noNodeInfo.classList.add('hidden');treeOutline.element.classList.add('hidden');this.element.classList.add('ax-ignored-node-pane');this._ignoredInfo.classList.remove('hidden');ignoredReasons.element.classList.remove('hidden');function addIgnoredReason(property){ignoredReasons.appendChild(new AXNodeIgnoredReasonTreeElement(property,(axNode)));}
const ignoredReasonsArray=(axNode.ignoredReasons());for(const reason of ignoredReasonsArray){addIgnoredReason(reason);}
if(!ignoredReasons.firstChild()){ignoredReasons.element.classList.add('hidden');}
return;}
this.element.classList.remove('ax-ignored-node-pane');this._ignoredInfo.classList.add('hidden');ignoredReasons.element.classList.add('hidden');this._noNodeInfo.classList.add('hidden');treeOutline.element.classList.remove('hidden');function addProperty(property){treeOutline.appendChild(new AXNodePropertyTreePropertyElement(property,(axNode)));}
for(const property of axNode.coreProperties()){addProperty(property);}
const roleProperty=({name:'role',value:axNode.role()});addProperty(roleProperty);for(const property of(axNode.properties())){addProperty(property);}
const firstNode=treeOutline.firstChild();if(firstNode){firstNode.select(true,false);}}
setNode(node){super.setNode(node);this._axNode=null;}}
class AXNodePropertyTreeElement extends TreeOutline.TreeElement{constructor(axNode){super('');this._axNode=axNode;}
static createSimpleValueElement(type,value){let valueElement;const AXValueType=Protocol.Accessibility.AXValueType;if(!type||type===AXValueType.ValueUndefined||type===AXValueType.ComputedString){valueElement=createElement('span');}else{valueElement=document.createElement('span');valueElement.classList.add('monospace');}
let valueText;const isStringProperty=type&&StringProperties.has(type);if(isStringProperty){valueText='"'+value.replace(/\n/g,'\u21B5')+'"';valueElement._originalTextContent=value;}else{valueText=String(value);}
if(type&&type in TypeStyles){valueElement.classList.add(TypeStyles[type]);}
valueElement.setTextContentTruncatedIfNeeded(valueText||'');valueElement.title=String(value)||'';return valueElement;}
static createExclamationMark(tooltip){const exclamationElement=createElement('span','dt-icon-label');exclamationElement.type='smallicon-warning';exclamationElement.title=tooltip;return exclamationElement;}
appendNameElement(name){const nameElement=createElement('span');if(name in AXAttributes){nameElement.textContent=AXAttributes[name].name;nameElement.title=AXAttributes[name].description;nameElement.classList.add('ax-readable-name');}else{nameElement.textContent=name;nameElement.classList.add('ax-name');nameElement.classList.add('monospace');}
this.listItemElement.appendChild(nameElement);}
appendValueElement(value){const AXValueType=Protocol.Accessibility.AXValueType;if(value.type===AXValueType.Idref||value.type===AXValueType.Node||value.type===AXValueType.IdrefList||value.type===AXValueType.NodeList){this.appendRelatedNodeListValueElement(value);return;}
if(value.sources){const sources=value.sources;for(let i=0;i<sources.length;i++){const source=sources[i];const child=new AXValueSourceTreeElement(source,this._axNode);this.appendChild(child);}
this.expand();}
const element=AXNodePropertyTreeElement.createSimpleValueElement(value.type,String(value.value));this.listItemElement.appendChild(element);}
appendRelatedNode(relatedNode,index){const deferredNode=new DOMModel.DeferredDOMNode(this._axNode.accessibilityModel().target(),relatedNode.backendDOMNodeId);const nodeTreeElement=new AXRelatedNodeSourceTreeElement({deferredNode:deferredNode},relatedNode);this.appendChild(nodeTreeElement);}
appendRelatedNodeInline(relatedNode){const deferredNode=new DOMModel.DeferredDOMNode(this._axNode.accessibilityModel().target(),relatedNode.backendDOMNodeId);const linkedNode=new AXRelatedNodeElement({deferredNode:deferredNode},relatedNode);this.listItemElement.appendChild(linkedNode.render());}
appendRelatedNodeListValueElement(value){if(value.relatedNodes.length===1&&!value.value){this.appendRelatedNodeInline(value.relatedNodes[0]);return;}
value.relatedNodes.forEach(this.appendRelatedNode,this);if(value.relatedNodes.length<=3){this.expand();}else{this.collapse();}}}
const TypeStyles={attribute:'ax-value-string',boolean:'object-value-boolean',booleanOrUndefined:'object-value-boolean',computedString:'ax-readable-string',idref:'ax-value-string',idrefList:'ax-value-string',integer:'object-value-number',internalRole:'ax-internal-role',number:'ax-value-number',role:'ax-role',string:'ax-value-string',tristate:'object-value-boolean',valueUndefined:'ax-value-undefined'};const StringProperties=new Set([Protocol.Accessibility.AXValueType.String,Protocol.Accessibility.AXValueType.ComputedString,Protocol.Accessibility.AXValueType.IdrefList,Protocol.Accessibility.AXValueType.Idref]);class AXNodePropertyTreePropertyElement extends AXNodePropertyTreeElement{constructor(property,axNode){super(axNode);this._property=property;this.toggleOnClick=true;this.listItemElement.classList.add('property');}
onattach(){this._update();}
_update(){this.listItemElement.removeChildren();this.appendNameElement(this._property.name);this.listItemElement.createChild('span','separator').textContent=':\xA0';this.appendValueElement(this._property.value);}}
class AXValueSourceTreeElement extends AXNodePropertyTreeElement{constructor(source,axNode){super(axNode);this._source=source;}
onattach(){this._update();}
appendRelatedNodeWithIdref(relatedNode,idref){const deferredNode=new DOMModel.DeferredDOMNode(this._axNode.accessibilityModel().target(),relatedNode.backendDOMNodeId);const nodeTreeElement=new AXRelatedNodeSourceTreeElement({deferredNode:deferredNode,idref:idref},relatedNode);this.appendChild(nodeTreeElement);}
appendIDRefValueElement(value){if(value.value===null){return;}
const relatedNodes=value.relatedNodes||[];if(value.value===''){for(const node of relatedNodes){const idref=node.idref||'';this.appendRelatedNodeWithIdref(node,idref);}
return;}
const idrefs=value.value.trim().split(/\s+/);for(const idref of idrefs){const matchingNode=relatedNodes.find(node=>node.idref===idref);if(matchingNode){this.appendRelatedNodeWithIdref(matchingNode,idref);}else if(idrefs.length===1){this.listItemElement.appendChild(new Accessibility.AXRelatedNodeElement({idref:idref}).render());}else{this.appendChild(new Accessibility.AXRelatedNodeSourceTreeElement({idref:idref}));}}}
appendRelatedNodeListValueElement(value){const relatedNodes=value.relatedNodes;const numNodes=relatedNodes.length;if(value.type===Protocol.Accessibility.AXValueType.IdrefList||value.type===Protocol.Accessibility.AXValueType.Idref){this.appendIDRefValueElement(value);}else{super.appendRelatedNodeListValueElement(value);}
if(numNodes<=3){this.expand();}else{this.collapse();}}
appendSourceNameElement(source){const nameElement=createElement('span');const AXValueSourceType=Protocol.Accessibility.AXValueSourceType;const type=source.type;switch(type){case AXValueSourceType.Attribute:case AXValueSourceType.Placeholder:case AXValueSourceType.RelatedElement:if(source.nativeSource){const nativeSource=source.nativeSource;nameElement.textContent=AXNativeSourceTypes[nativeSource].name;nameElement.title=AXNativeSourceTypes[nativeSource].description;nameElement.classList.add('ax-readable-name');break;}
nameElement.textContent=source.attribute;nameElement.classList.add('ax-name');nameElement.classList.add('monospace');break;default:if(type in AXSourceTypes){nameElement.textContent=AXSourceTypes[type].name;nameElement.title=AXSourceTypes[type].description;nameElement.classList.add('ax-readable-name');}else{console.warn(type,'not in AXSourceTypes');nameElement.textContent=type;}}
this.listItemElement.appendChild(nameElement);}
_update(){this.listItemElement.removeChildren();if(this._source.invalid){const exclamationMark=AXNodePropertyTreeElement.createExclamationMark(ls`Invalid source.`);this.listItemElement.appendChild(exclamationMark);this.listItemElement.classList.add('ax-value-source-invalid');}else if(this._source.superseded){this.listItemElement.classList.add('ax-value-source-unused');}
this.appendSourceNameElement(this._source);this.listItemElement.createChild('span','separator').textContent=':\xA0';if(this._source.attributeValue){this.appendValueElement(this._source.attributeValue);this.listItemElement.createTextChild('\xA0');}else if(this._source.nativeSourceValue){this.appendValueElement(this._source.nativeSourceValue);this.listItemElement.createTextChild('\xA0');if(this._source.value){this.appendValueElement(this._source.value);}}else if(this._source.value){this.appendValueElement(this._source.value);}else{const valueElement=AXNodePropertyTreeElement.createSimpleValueElement(Protocol.Accessibility.AXValueType.ValueUndefined,ls`Not specified`);this.listItemElement.appendChild(valueElement);this.listItemElement.classList.add('ax-value-source-unused');}
if(this._source.value&&this._source.superseded){this.listItemElement.classList.add('ax-value-source-superseded');}}}
class AXRelatedNodeSourceTreeElement extends TreeOutline.TreeElement{constructor(node,value){super('');this._value=value;this._axRelatedNodeElement=new AXRelatedNodeElement(node,value);this.selectable=true;}
onattach(){this.listItemElement.appendChild(this._axRelatedNodeElement.render());if(!this._value){return;}
if(this._value.text){this.listItemElement.appendChild(AXNodePropertyTreeElement.createSimpleValueElement(Protocol.Accessibility.AXValueType.ComputedString,this._value.text));}}
onenter(){this._axRelatedNodeElement.revealNode();return true;}}
class AXRelatedNodeElement{constructor(node,value){this._deferredNode=node.deferredNode;this._idref=node.idref;this._value=value;}
render(){const element=createElement('span');let valueElement;if(this._deferredNode){valueElement=createElement('span');element.appendChild(valueElement);this._deferredNode.resolvePromise().then(node=>{Linkifier.Linkifier.linkify(node,{preventKeyboardFocus:true}).then(linkfied=>valueElement.appendChild(linkfied));});}else if(this._idref){element.classList.add('invalid');valueElement=AXNodePropertyTreeElement.createExclamationMark(ls`No node with this ID.`);valueElement.createTextChild(this._idref);element.appendChild(valueElement);}
return element;}
revealNode(){this._deferredNode.resolvePromise().then(node=>Revealer.reveal(node));}}
class AXNodeIgnoredReasonTreeElement extends AXNodePropertyTreeElement{constructor(property,axNode){super(axNode);this._property=property;this._axNode=axNode;this.toggleOnClick=true;this.selectable=false;}
static createReasonElement(reason,axNode){let reasonElement=null;switch(reason){case'activeModalDialog':reasonElement=UIUtils.formatLocalized('Element is hidden by active modal dialog:\xA0',[]);break;case'ancestorIsLeafNode':reasonElement=UIUtils.formatLocalized('Ancestor\'s children are all presentational:\xA0',[]);break;case'ariaHiddenElement':{const ariaHiddenSpan=createElement('span','source-code').textContent='aria-hidden';reasonElement=UIUtils.formatLocalized('Element is %s.',[ariaHiddenSpan]);break;}
case'ariaHiddenSubtree':{const ariaHiddenSpan=createElement('span','source-code').textContent='aria-hidden';const trueSpan=createElement('span','source-code').textContent='true';reasonElement=UIUtils.formatLocalized('%s is %s on ancestor:\xA0',[ariaHiddenSpan,trueSpan]);break;}
case'emptyAlt':reasonElement=UIUtils.formatLocalized('Element has empty alt text.',[]);break;case'emptyText':reasonElement=UIUtils.formatLocalized('No text content.',[]);break;case'inertElement':reasonElement=UIUtils.formatLocalized('Element is inert.',[]);break;case'inertSubtree':reasonElement=UIUtils.formatLocalized('Element is in an inert subtree from\xA0',[]);break;case'inheritsPresentation':reasonElement=UIUtils.formatLocalized('Element inherits presentational role from\xA0',[]);break;case'labelContainer':reasonElement=UIUtils.formatLocalized('Part of label element:\xA0',[]);break;case'labelFor':reasonElement=UIUtils.formatLocalized('Label for\xA0',[]);break;case'notRendered':reasonElement=UIUtils.formatLocalized('Element is not rendered.',[]);break;case'notVisible':reasonElement=UIUtils.formatLocalized('Element is not visible.',[]);break;case'presentationalRole':{const rolePresentationSpan=createElement('span','source-code').textContent='role='+axNode.role().value;reasonElement=UIUtils.formatLocalized('Element has %s.',[rolePresentationSpan]);break;}
case'probablyPresentational':reasonElement=UIUtils.formatLocalized('Element is presentational.',[]);break;case'staticTextUsedAsNameFor':reasonElement=UIUtils.formatLocalized('Static text node is used as name for\xA0',[]);break;case'uninteresting':reasonElement=UIUtils.formatLocalized('Element not interesting for accessibility.',[]);break;}
if(reasonElement){reasonElement.classList.add('ax-reason');}
return reasonElement;}
onattach(){this.listItemElement.removeChildren();this._reasonElement=AXNodeIgnoredReasonTreeElement.createReasonElement(this._property.name,this._axNode);this.listItemElement.appendChild(this._reasonElement);const value=this._property.value;if(value.type===Protocol.Accessibility.AXValueType.Idref){this.appendRelatedNodeListValueElement(value);}}}
var AccessibilityNodeView=Object.freeze({__proto__:null,AXNodeSubPane:AXNodeSubPane,AXNodePropertyTreeElement:AXNodePropertyTreeElement,TypeStyles:TypeStyles,StringProperties:StringProperties,AXNodePropertyTreePropertyElement:AXNodePropertyTreePropertyElement,AXValueSourceTreeElement:AXValueSourceTreeElement,AXRelatedNodeSourceTreeElement:AXRelatedNodeSourceTreeElement,AXRelatedNodeElement:AXRelatedNodeElement,AXNodeIgnoredReasonTreeElement:AXNodeIgnoredReasonTreeElement});const config={'attributes':[{'type':'IDREF','name':'aria-activedescendant'},{'default':'false','type':'boolean','name':'aria-atomic'},{'default':'none','enum':['inline','list','both','none'],'type':'token','name':'aria-autocomplete'},{'default':'false','type':'boolean','name':'aria-busy'},{'default':'undefined','enum':['true','false','mixed','undefined'],'type':'token','name':'aria-checked'},{'type':'integer','name':'aria-colcount'},{'type':'integer','name':'aria-colindex'},{'type':'integer','name':'aria-colspan'},{'type':'IDREF_list','name':'aria-controls'},{'default':'false','enum':['page','step','location','date','time','true','false'],'type':'token','name':'aria-current'},{'type':'IDREF_list','name':'aria-describedby'},{'type':'string','name':'aria-description'},{'type':'IDREF','name':'aria-details'},{'default':'false','type':'boolean','name':'aria-disabled'},{'default':'none','enum':['copy','move','link','execute','popup','none'],'type':'token_list','name':'aria-dropeffect'},{'type':'IDREF','name':'aria-errormessage'},{'default':'undefined','enum':['true','false','undefined'],'type':'token','name':'aria-expanded'},{'type':'IDREF_list','name':'aria-flowto'},{'default':'undefined','enum':['true','false','undefined'],'type':'token','name':'aria-grabbed'},{'default':'false','enum':['false','true','menu','listbox','tree','grid','dialog'],'type':'token','name':'aria-haspopup'},{'default':'undefined','enum':['true','false','undefined'],'type':'token','name':'aria-hidden'},{'default':'false','enum':['grammar','false','spelling','true'],'type':'token','name':'aria-invalid'},{'type':'string','name':'aria-keyshortcuts'},{'type':'string','name':'aria-label'},{'type':'IDREF_list','name':'aria-labelledby'},{'type':'IDREF_list','name':'aria-labeledby'},{'type':'integer','name':'aria-level'},{'default':'off','enum':['off','polite','assertive'],'type':'token','name':'aria-live'},{'default':'false','type':'boolean','name':'aria-modal'},{'default':'false','type':'boolean','name':'aria-multiline'},{'default':'false','type':'boolean','name':'aria-multiselectable'},{'default':'undefined','enum':['horizontal','undefined','vertical'],'type':'token','name':'aria-orientation'},{'type':'IDREF_list','name':'aria-owns'},{'type':'string','name':'aria-placeholder'},{'type':'integer','name':'aria-posinset'},{'default':'undefined','enum':['true','false','mixed','undefined'],'type':'token','name':'aria-pressed'},{'default':'false','type':'boolean','name':'aria-readonly'},{'default':'additions text','enum':['additions','removals','text','all'],'type':'token_list','name':'aria-relevant'},{'default':'false','type':'boolean','name':'aria-required'},{'type':'string','name':'aria-roledescription'},{'type':'integer','name':'aria-rowcount'},{'type':'integer','name':'aria-rowindex'},{'type':'integer','name':'aria-rowspan'},{'default':'undefined','enum':['true','false','undefined'],'type':'token','name':'aria-selected'},{'type':'integer','name':'aria-setsize'},{'default':'none','enum':['ascending','descending','none','other'],'type':'token','name':'aria-sort'},{'type':'decimal','name':'aria-valuemax'},{'type':'decimal','name':'aria-valuemin'},{'type':'decimal','name':'aria-valuenow'},{'type':'string','name':'aria-valuetext'}],'roles':[{'implicitValues':{'aria-atomic':'true','aria-live':'assertive'},'superclasses':['section'],'name':'alert','nameFrom':['author']},{'superclasses':['alert','dialog'],'name':'alertdialog','nameRequired':true,'nameFrom':['author']},{'superclasses':['structure'],'name':'application','nameRequired':true,'nameFrom':['author']},{'supportedAttributes':['aria-posinset','aria-setsize'],'superclasses':['document'],'name':'article','nameFrom':['author']},{'superclasses':['landmark'],'name':'banner','nameFrom':['author']},{'name':'button','nameRequired':true,'nameFrom':['contents','author'],'supportedAttributes':['aria-expanded','aria-pressed'],'superclasses':['command'],'childrenPresentational':true},{'scope':'row','supportedAttributes':['aria-colindex','aria-colspan','aria-rowindex','aria-rowspan'],'superclasses':['section'],'name':'cell','namefrom':['contents','author']},{'name':'checkbox','nameRequired':true,'implicitValues':{'aria-checked':false},'requiredAttributes':['aria-checked'],'nameFrom':['contents','author'],'supportedAttributes':['aria-readonly'],'superclasses':['input']},{'name':'columnheader','nameRequired':true,'nameFrom':['contents','author'],'supportedAttributes':['aria-sort'],'superclasses':['gridcell','sectionhead','widget'],'scope':['row']},{'name':'combobox','nameRequired':true,'implicitValues':{'aria-haspopup':'listbox','aria-expanded':'false'},'requiredAttributes':['aria-controls','aria-expanded'],'mustContain':['textbox'],'nameFrom':['author'],'supportedAttributes':['aria-autocomplete','aria-readonly','aria-required'],'superclasses':['select']},{'abstract':true,'superclasses':['widget'],'name':'command','nameFrom':['author']},{'superclasses':['landmark'],'name':'complementary','nameFrom':['author']},{'supportedAttributes':['aria-activedescendant'],'abstract':true,'superclasses':['widget'],'name':'composite','nameFrom':['author']},{'superclasses':['landmark'],'name':'contentinfo','nameFrom':['author']},{'superclasses':['section'],'name':'definition','nameFrom':['author']},{'superclasses':['window'],'name':'dialog','nameRequired':true,'nameFrom':['author']},{'superclasses':['list'],'name':'directory','nameFrom':['author']},{'supportedAttributes':['aria-expanded'],'superclasses':['structure'],'name':'document','nameRequired':false,'nameFrom':['author']},{'nameRequired':false,'superclasses':['list'],'name':'feed','mustContain':['article'],'nameFrom':['author']},{'superclasses':['section'],'name':'figure','nameRequired':false,'namefrom':['author']},{'superclasses':['landmark'],'name':'form','nameFrom':['author']},{'name':'grid','nameRequired':true,'nameFrom':['author'],'mustContain':['row'],'supportedAttributes':['aria-level','aria-multiselectable','aria-readonly'],'superclasses':['composite','table']},{'name':'gridcell','nameRequired':true,'nameFrom':['contents','author'],'supportedAttributes':['aria-readonly','aria-required','aria-selected'],'superclasses':['cell','widget'],'scope':['row']},{'supportedAttributes':['aria-activedescendant'],'superclasses':['section'],'name':'group','nameFrom':['author']},{'name':'heading','nameRequired':true,'implicitValues':{'aria-level':'2'},'namefrom':['contents','author'],'supportedAttributes':['aria-level'],'superclasses':['sectionhead']},{'childrenPresentational':true,'superclasses':['section'],'name':'img','nameRequired':true,'nameFrom':['author']},{'abstract':true,'superclasses':['widget'],'name':'input','nameFrom':['author']},{'abstract':true,'superclasses':['section'],'name':'landmark','nameRequired':false,'nameFrom':['author']},{'supportedAttributes':['aria-expanded'],'superclasses':['command'],'name':'link','nameRequired':true,'nameFrom':['contents','author']},{'implicitValues':{'aria-orientation':'vertical'},'superclasses':['section'],'name':'list','mustContain':['listitem'],'nameFrom':['author']},{'name':'listbox','nameRequired':true,'implicitValues':{'aria-orientation':'vertical'},'nameFrom':['author'],'mustContain':['option'],'supportedAttributes':['aria-multiselectable','aria-readonly','aria-required'],'superclasses':['select']},{'scope':['group','list'],'supportedAttributes':['aria-level','aria-posinset','aria-setsize'],'superclasses':['section'],'name':'listitem','nameFrom':['author']},{'implicitValues':{'aria-live':'polite'},'superclasses':['section'],'name':'log','nameRequired':true,'nameFrom':['author']},{'superclasses':['landmark'],'name':'main','nameFrom':['author']},{'superclasses':['section'],'name':'marquee','nameRequired':true,'nameFrom':['author']},{'childrenPresentational':true,'superclasses':['section'],'name':'math','nameRequired':true,'nameFrom':['author']},{'implicitValues':{'aria-orientation':'vertical'},'superclasses':['select'],'name':'menu','mustContain':['group','menuitemradio','menuitem','menuitemcheckbox','menuitemradio'],'nameFrom':['author']},{'implicitValues':{'aria-orientation':'horizontal'},'superclasses':['menu'],'name':'menubar','mustContain':['menuitem','menuitemradio','menuitemcheckbox'],'nameFrom':['author']},{'scope':['group','menu','menubar'],'superclasses':['command'],'name':'menuitem','nameRequired':true,'nameFrom':['contents','author']},{'name':'menuitemcheckbox','nameRequired':true,'implicitValues':{'aria-checked':false},'nameFrom':['contents','author'],'superclasses':['checkbox','menuitem'],'childrenPresentational':true,'scope':['menu','menubar']},{'name':'menuitemradio','nameRequired':true,'implicitValues':{'aria-checked':false},'nameFrom':['contents','author'],'superclasses':['menuitemcheckbox','radio'],'childrenPresentational':true,'scope':['menu','menubar','group']},{'superclasses':['landmark'],'name':'navigation','nameFrom':['author']},{'name':'none','superclasses':['structure']},{'superclasses':['section'],'name':'note','nameFrom':['author']},{'name':'option','nameRequired':true,'implicitValues':{'aria-selected':'false'},'requiredAttributes':['aria-selected'],'nameFrom':['contents','author'],'supportedAttributes':['aria-checked','aria-posinset','aria-setsize'],'superclasses':['input'],'childrenPresentational':true,'scope':['listbox']},{'name':'presentation','superclasses':['structure']},{'childrenPresentational':true,'superclasses':['range'],'name':'progressbar','nameRequired':true,'nameFrom':['author']},{'name':'radio','nameRequired':true,'implicitValues':{'aria-checked':'false'},'requiredAttributes':['aria-checked'],'nameFrom':['contents','author'],'supportedAttributes':['aria-posinset','aria-setsize'],'superclasses':['input'],'childrenPresentational':true},{'name':'radiogroup','nameRequired':true,'nameFrom':['author'],'mustContain':['radio'],'supportedAttributes':['aria-readonly','aria-required'],'superclasses':['select']},{'supportedAttributes':['aria-valuemax','aria-valuemin','aria-valuenow','aria-valuetext'],'abstract':true,'superclasses':['widget'],'name':'range','nameFrom':['author']},{'superclasses':['landmark'],'name':'region','nameRequired':true,'nameFrom':['author']},{'supportedAttributes':['aria-atomic','aria-busy','aria-controls','aria-current','aria-describedby','aria-details','aria-disabled','aria-dropeffect','aria-errormessage','aria-flowto','aria-grabbed','aria-haspopup','aria-hidden','aria-invalid','aria-keyshortcuts','aria-label','aria-labelledby','aria-live','aria-owns','aria-relevant','aria-roledescription'],'abstract':true,'name':'roletype'},{'name':'row','nameFrom':['contents','author'],'mustContain':['cell','columnheader','gridcell','rowheader'],'supportedAttributes':['aria-colindex','aria-level','aria-rowindex','aria-selected','aria-setsize','aria-posinset'],'superclasses':['group','widget'],'scope':['grid','rowgroup','table','treegrid']},{'scope':['grid','table','treegrid'],'superclasses':['structure'],'name':'rowgroup','mustContain':['row'],'nameFrom':['contents','author']},{'name':'rowheader','nameRequired':true,'nameFrom':['contents','author'],'supportedAttributes':['aria-sort'],'superclasses':['cell','gridcell','sectionhead'],'scope':['row']},{'name':'scrollbar','nameRequired':false,'implicitValues':{'aria-valuemax':'100','aria-valuemin':'0','aria-orientation':'vertical'},'nameFrom':['author'],'requiredAttributes':['aria-controls','aria-orientation','aria-valuemax','aria-valuemin','aria-valuenow'],'superclasses':['range'],'childrenPresentational':true},{'superclasses':['landmark'],'name':'search','nameFrom':['author']},{'superclasses':['textbox'],'name':'searchbox','nameRequired':true,'nameFrom':['author']},{'supportedAttributes':['aria-expanded'],'abstract':true,'name':'section','superclasses':['structure']},{'supportedAttributes':['aria-expanded'],'abstract':true,'superclasses':['structure'],'name':'sectionhead','nameFrom':['contents','author']},{'abstract':true,'superclasses':['composite','group'],'name':'select','nameFrom':['author']},{'supportedAttributes':['aria-orientation','aria-valuemin','aria-valuemax','aria-valuenow','aria-valuetext'],'superclasses':['structure'],'name':'separator','nameFrom':['author']},{'name':'slider','nameRequired':true,'implicitValues':{'aria-valuemax':'100','aria-valuemin':'0','aria-orientation':'horizontal'},'requiredAttributes':['aria-valuemax','aria-valuemin','aria-valuenow'],'nameFrom':['author'],'supportedAttributes':['aria-orientation'],'superclasses':['input','range'],'childrenPresentational':true},{'name':'spinbutton','nameRequired':true,'implicitValues':{'aria-valuenow':'0'},'requiredAttributes':['aria-valuemax','aria-valuemin','aria-valuenow'],'nameFrom':['author'],'supportedAttributes':['aria-required','aria-readonly'],'superclasses':['composite','input','range']},{'implicitValues':{'aria-atomic':'true','aria-live':'polite'},'superclasses':['section'],'name':'status','nameFrom':['author']},{'abstract':true,'name':'structure','superclasses':['roletype']},{'name':'switch','nameRequired':true,'implicitValues':{'aria-checked':'false'},'nameFrom':['contents','author'],'requiredAttributes':['aria-checked'],'superclasses':['checkbox'],'childrenPresentational':true},{'name':'tab','implicitValues':{'aria-selected':'false'},'nameFrom':['contents','author'],'supportedAttributes':['aria-selected'],'superclasses':['sectionhead','widget'],'childrenPresentational':true,'scope':['tablist']},{'name':'table','nameRequired':true,'nameFrom':['author'],'mustContain':['row'],'supportedAttributes':['aria-colcount','aria-rowcount'],'superclasses':['section']},{'name':'tablist','implicitValues':{'aria-orientation':'horizontal'},'nameFrom':['author'],'mustContain':['tab'],'supportedAttributes':['aria-level','aria-multiselectable','aria-orientation'],'superclasses':['composite']},{'superclasses':['section'],'name':'tabpanel','nameRequired':true,'nameFrom':['author']},{'superclasses':['section'],'name':'term','nameFrom':['author']},{'supportedAttributes':['aria-activedescendant','aria-autocomplete','aria-multiline','aria-placeholder','aria-readonly','aria-required'],'superclasses':['input'],'name':'textbox','nameRequired':true,'nameFrom':['author']},{'superclasses':['status'],'name':'timer','nameFrom':['author']},{'implicitValues':{'aria-orientation':'horizontal'},'supportedAttributes':['aria-orientation'],'superclasses':['group'],'name':'toolbar','nameFrom':['author']},{'superclasses':['section'],'name':'tooltip','nameRequired':true,'nameFrom':['contents','author']},{'name':'tree','nameRequired':true,'implicitValues':{'aria-orientation':'vertical'},'nameFrom':['author'],'mustContain':['group','treeitem'],'supportedAttributes':['aria-multiselectable','aria-required'],'superclasses':['select']},{'nameRequired':true,'superclasses':['grid','tree'],'name':'treegrid','mustContain':['row'],'nameFrom':['author']},{'scope':['group','tree'],'superclasses':['listitem','option'],'name':'treeitem','nameRequired':true,'nameFrom':['contents','author']},{'abstract':true,'name':'widget','superclasses':['roletype']},{'supportedAttributes':['aria-expanded','aria-modal'],'abstract':true,'superclasses':['roletype'],'name':'window','nameFrom':['author']}],'metadata':{'namespaceURI':'http://www.w3.org/1999/xhtml','attrsNullNamespace':true,'namespace':'HTML','export':'CORE_EXPORT','namespacePrefix':'xhtml'}};class ARIAMetadata{constructor(config){this._attributes=new Map();if(config){this._initialize(config);}}
_initialize(config){const attributes=config['attributes'];const booleanEnum=['true','false'];for(const attributeConfig of attributes){if(attributeConfig.type==='boolean'){attributeConfig.enum=booleanEnum;}
this._attributes.set(attributeConfig.name,new Attribute(attributeConfig));}
this._roleNames=config['roles'].map(roleConfig=>roleConfig.name);}
valuesForProperty(property){if(this._attributes.has(property)){return this._attributes.get(property).getEnum();}
if(property==='role'){return this._roleNames;}
return[];}}
function ariaMetadata(){if(!ARIAMetadata._instance){ARIAMetadata._instance=new ARIAMetadata(config||null);}
return ARIAMetadata._instance;}
class Attribute{constructor(config){this._enum=[];if('enum'in config){this._enum=config.enum;}}
getEnum(){return this._enum;}}
var ARIAMetadata$1=Object.freeze({__proto__:null,ARIAMetadata:ARIAMetadata,ariaMetadata:ariaMetadata,Attribute:Attribute});class ARIAAttributesPane extends AccessibilitySubPane{constructor(){super(ls`ARIA Attributes`);this._noPropertiesInfo=this.createInfo(ls`No ARIA attributes`);this._treeOutline=this.createTreeOutline();}
setNode(node){super.setNode(node);this._treeOutline.removeChildren();if(!this.node()){return;}
const target=this.node().domModel().target();const attributes=node.attributes();for(let i=0;i<attributes.length;++i){const attribute=attributes[i];if(!this._isARIAAttribute(attribute)){continue;}
this._treeOutline.appendChild(new ARIAAttributesTreeElement(this,attribute,target));}
const foundAttributes=(this._treeOutline.rootElement().childCount()!==0);this._noPropertiesInfo.classList.toggle('hidden',foundAttributes);this._treeOutline.element.classList.toggle('hidden',!foundAttributes);}
_isARIAAttribute(attribute){return _attributes.has(attribute.name);}}
class ARIAAttributesTreeElement extends TreeOutline.TreeElement{constructor(parentPane,attribute,target){super('');this._parentPane=parentPane;this._attribute=attribute;this.selectable=false;}
static createARIAValueElement(value){const valueElement=document.createElement('span');valueElement.classList.add('monospace');valueElement.setTextContentTruncatedIfNeeded(value||'');return valueElement;}
onattach(){this._populateListItem();this.listItemElement.addEventListener('click',this._mouseClick.bind(this));}
_populateListItem(){this.listItemElement.removeChildren();this.appendNameElement(this._attribute.name);this.listItemElement.createChild('span','separator').textContent=':\xA0';this.appendAttributeValueElement(this._attribute.value);}
appendNameElement(name){this._nameElement=createElement('span');this._nameElement.textContent=name;this._nameElement.classList.add('ax-name');this._nameElement.classList.add('monospace');this.listItemElement.appendChild(this._nameElement);}
appendAttributeValueElement(value){this._valueElement=ARIAAttributesTreeElement.createARIAValueElement(value);this.listItemElement.appendChild(this._valueElement);}
_mouseClick(event){if(event.target===this.listItemElement){return;}
event.consume(true);this._startEditing();}
_startEditing(){const valueElement=this._valueElement;if(UIUtils.isBeingEdited(valueElement)){return;}
const previousContent=valueElement.textContent;function blurListener(previousContent,event){const text=event.target.textContent;this._editingCommitted(text,previousContent);}
this._prompt=new ARIAAttributePrompt(ariaMetadata().valuesForProperty(this._nameElement.textContent),this);this._prompt.setAutocompletionTimeout(0);const proxyElement=this._prompt.attachAndStartEditing(valueElement,blurListener.bind(this,previousContent));proxyElement.addEventListener('keydown',this._editingValueKeyDown.bind(this,previousContent),false);valueElement.getComponentSelection().selectAllChildren(valueElement);}
_removePrompt(){if(!this._prompt){return;}
this._prompt.detach();delete this._prompt;}
_editingCommitted(userInput,previousContent){this._removePrompt();if(userInput!==previousContent){this._parentPane.node().setAttributeValue(this._attribute.name,userInput);}}
_editingCancelled(){this._removePrompt();this._populateListItem();}
_editingValueKeyDown(previousContent,event){if(event.handled){return;}
if(isEnterKey(event)){this._editingCommitted(event.target.textContent,previousContent);event.consume();return;}
if(isEscKey(event)){this._editingCancelled();event.consume();return;}}}
class ARIAAttributePrompt extends TextPrompt.TextPrompt{constructor(ariaCompletions,treeElement){super();this.initialize(this._buildPropertyCompletions.bind(this));this._ariaCompletions=ariaCompletions;this._treeElement=treeElement;}
_buildPropertyCompletions(expression,prefix,force){prefix=prefix.toLowerCase();if(!prefix&&!force&&(this._isEditingName||expression)){return Promise.resolve([]);}
return Promise.resolve(this._ariaCompletions.filter(value=>value.startsWith(prefix)).map(c=>({text:c})));}}
const _attributes=new Set(['role','aria-activedescendant','aria-atomic','aria-autocomplete','aria-brailleroledescription','aria-busy','aria-checked','aria-colcount','aria-colindex','aria-colindextext','aria-colspan','aria-controls','aria-current','aria-describedby','aria-details','aria-disabled','aria-dropeffect','aria-errormessage','aria-expanded','aria-flowto','aria-grabbed','aria-haspopup','aria-hidden','aria-invalid','aria-keyshortcuts','aria-label','aria-labelledby','aria-level','aria-live','aria-modal','aria-multiline','aria-multiselectable','aria-orientation','aria-owns','aria-placeholder','aria-posinset','aria-pressed','aria-readonly','aria-relevant','aria-required','aria-roledescription','aria-rowcount','aria-rowindex','aria-rowindextext','aria-rowspan','aria-selected','aria-setsize','aria-sort','aria-valuemax','aria-valuemin','aria-valuenow','aria-valuetext',]);var ARIAAttributesView=Object.freeze({__proto__:null,ARIAAttributesPane:ARIAAttributesPane,ARIAAttributesTreeElement:ARIAAttributesTreeElement,ARIAAttributePrompt:ARIAAttributePrompt});class AXBreadcrumbsPane extends AccessibilitySubPane{constructor(axSidebarView){super(ls`Accessibility Tree`);this.element.classList.add('ax-subpane');ARIAUtils.markAsTree(this.element);this.element.tabIndex=-1;this._axSidebarView=axSidebarView;this._preselectedBreadcrumb=null;this._inspectedNodeBreadcrumb=null;this._collapsingBreadcrumbId=-1;this._hoveredBreadcrumb=null;this._rootElement=this.element.createChild('div','ax-breadcrumbs');this._rootElement.addEventListener('keydown',this._onKeyDown.bind(this),true);this._rootElement.addEventListener('mousemove',this._onMouseMove.bind(this),false);this._rootElement.addEventListener('mouseleave',this._onMouseLeave.bind(this),false);this._rootElement.addEventListener('click',this._onClick.bind(this),false);this._rootElement.addEventListener('contextmenu',this._contextMenuEventFired.bind(this),false);this._rootElement.addEventListener('focusout',this._onFocusOut.bind(this),false);this.registerRequiredCSS('accessibility/axBreadcrumbs.css');}
focus(){if(this._inspectedNodeBreadcrumb){this._inspectedNodeBreadcrumb.nodeElement().focus();}else{this.element.focus();}}
setAXNode(axNode){const hadFocus=this.element.hasFocus();super.setAXNode(axNode);this._rootElement.removeChildren();if(!axNode){return;}
const ancestorChain=[];let ancestor=axNode;while(ancestor){ancestorChain.push(ancestor);ancestor=ancestor.parentNode();}
ancestorChain.reverse();let depth=0;let breadcrumb=null;let parent=null;for(ancestor of ancestorChain){breadcrumb=new AXBreadcrumb(ancestor,depth,(ancestor===axNode));if(parent){parent.appendChild(breadcrumb);}else{this._rootElement.appendChild(breadcrumb.element());}
parent=breadcrumb;depth++;}
this._inspectedNodeBreadcrumb=breadcrumb;this._inspectedNodeBreadcrumb.setPreselected(true,hadFocus);this._setPreselectedBreadcrumb(this._inspectedNodeBreadcrumb);function append(parentBreadcrumb,axNode,localDepth){const childBreadcrumb=new AXBreadcrumb(axNode,localDepth,false);parentBreadcrumb.appendChild(childBreadcrumb);for(const child of axNode.children()){append(childBreadcrumb,child,localDepth+1);}}
for(const child of axNode.children()){append(this._inspectedNodeBreadcrumb,child,depth);if(child.backendDOMNodeId()===this._collapsingBreadcrumbId){this._setPreselectedBreadcrumb(this._inspectedNodeBreadcrumb.lastChild());}}
this._collapsingBreadcrumbId=-1;}
willHide(){this._setPreselectedBreadcrumb(null);}
_onKeyDown(event){if(!this._preselectedBreadcrumb){return;}
if(!event.composedPath().some(element=>element===this._preselectedBreadcrumb.element())){return;}
if(event.shiftKey||event.metaKey||event.ctrlKey){return;}
let handled=false;if(event.key==='ArrowUp'&&!event.altKey){handled=this._preselectPrevious();}else if((event.key==='ArrowDown')&&!event.altKey){handled=this._preselectNext();}else if(event.key==='ArrowLeft'&&!event.altKey){if(this._preselectedBreadcrumb.hasExpandedChildren()){this._collapseBreadcrumb(this._preselectedBreadcrumb);}else{handled=this._preselectParent();}}else if((isEnterKey(event)||(event.key==='ArrowRight'&&!event.altKey&&this._preselectedBreadcrumb.axNode().hasOnlyUnloadedChildren()))){handled=this._inspectDOMNode(this._preselectedBreadcrumb.axNode());}
if(handled){event.consume(true);}}
_preselectPrevious(){const previousBreadcrumb=this._preselectedBreadcrumb.previousBreadcrumb();if(!previousBreadcrumb){return false;}
this._setPreselectedBreadcrumb(previousBreadcrumb);return true;}
_preselectNext(){const nextBreadcrumb=this._preselectedBreadcrumb.nextBreadcrumb();if(!nextBreadcrumb){return false;}
this._setPreselectedBreadcrumb(nextBreadcrumb);return true;}
_preselectParent(){const parentBreadcrumb=this._preselectedBreadcrumb.parentBreadcrumb();if(!parentBreadcrumb){return false;}
this._setPreselectedBreadcrumb(parentBreadcrumb);return true;}
_setPreselectedBreadcrumb(breadcrumb){if(breadcrumb===this._preselectedBreadcrumb){return;}
const hadFocus=this.element.hasFocus();if(this._preselectedBreadcrumb){this._preselectedBreadcrumb.setPreselected(false,hadFocus);}
if(breadcrumb){this._preselectedBreadcrumb=breadcrumb;}else{this._preselectedBreadcrumb=this._inspectedNodeBreadcrumb;}
this._preselectedBreadcrumb.setPreselected(true,hadFocus);if(!breadcrumb&&hadFocus){OverlayModel.OverlayModel.hideDOMNodeHighlight();}}
_collapseBreadcrumb(breadcrumb){if(!breadcrumb.parentBreadcrumb()){return;}
this._collapsingBreadcrumbId=breadcrumb.axNode().backendDOMNodeId();this._inspectDOMNode(breadcrumb.parentBreadcrumb().axNode());}
_onMouseLeave(event){this._setHoveredBreadcrumb(null);}
_onMouseMove(event){const breadcrumbElement=event.target.enclosingNodeOrSelfWithClass('ax-breadcrumb');if(!breadcrumbElement){this._setHoveredBreadcrumb(null);return;}
const breadcrumb=breadcrumbElement.breadcrumb;if(!breadcrumb.isDOMNode()){return;}
this._setHoveredBreadcrumb(breadcrumb);}
_onFocusOut(event){if(!this._preselectedBreadcrumb||event.target!==this._preselectedBreadcrumb.nodeElement()){return;}
this._setPreselectedBreadcrumb(null);}
_onClick(event){const breadcrumbElement=event.target.enclosingNodeOrSelfWithClass('ax-breadcrumb');if(!breadcrumbElement){this._setHoveredBreadcrumb(null);return;}
const breadcrumb=breadcrumbElement.breadcrumb;if(breadcrumb.inspected()){this._collapseBreadcrumb(breadcrumb);breadcrumb.nodeElement().focus();return;}
if(!breadcrumb.isDOMNode()){return;}
this._inspectDOMNode(breadcrumb.axNode());}
_setHoveredBreadcrumb(breadcrumb){if(breadcrumb===this._hoveredBreadcrumb){return;}
if(this._hoveredBreadcrumb){this._hoveredBreadcrumb.setHovered(false);}
if(breadcrumb){breadcrumb.setHovered(true);}else if(this.node()){this.node().domModel().overlayModel().nodeHighlightRequested(this.node().id);}
this._hoveredBreadcrumb=breadcrumb;}
_inspectDOMNode(axNode){if(!axNode.isDOMNode()){return false;}
axNode.deferredDOMNode().resolve(domNode=>{this._axSidebarView.setNode(domNode,true);Revealer.reveal(domNode,true);});return true;}
_contextMenuEventFired(event){const breadcrumbElement=event.target.enclosingNodeOrSelfWithClass('ax-breadcrumb');if(!breadcrumbElement){return;}
const axNode=breadcrumbElement.breadcrumb.axNode();if(!axNode.isDOMNode()||!axNode.deferredDOMNode()){return;}
const contextMenu=new ContextMenu.ContextMenu(event);contextMenu.viewSection().appendItem(ls`Scroll into view`,()=>{axNode.deferredDOMNode().resolvePromise().then(domNode=>{if(!domNode){return;}
domNode.scrollIntoView();});});contextMenu.appendApplicableItems(axNode.deferredDOMNode());contextMenu.show();}}
class AXBreadcrumb{constructor(axNode,depth,inspected){this._axNode=axNode;this._element=document.createElement('div');this._element.classList.add('ax-breadcrumb');this._element.breadcrumb=this;this._nodeElement=document.createElement('div');this._nodeElement.classList.add('ax-node');ARIAUtils.markAsTreeitem(this._nodeElement);this._nodeElement.tabIndex=-1;this._element.appendChild(this._nodeElement);this._nodeWrapper=document.createElement('div');this._nodeWrapper.classList.add('wrapper');this._nodeElement.appendChild(this._nodeWrapper);this._selectionElement=document.createElement('div');this._selectionElement.classList.add('selection');this._selectionElement.classList.add('fill');this._nodeElement.appendChild(this._selectionElement);this._childrenGroupElement=document.createElement('div');this._childrenGroupElement.classList.add('children');ARIAUtils.markAsGroup(this._childrenGroupElement);this._element.appendChild(this._childrenGroupElement);this._children=[];this._hovered=false;this._preselected=false;this._parent=null;this._inspected=inspected;this._nodeElement.classList.toggle('inspected',inspected);this._nodeElement.style.paddingLeft=(16*depth+4)+'px';if(this._axNode.ignored()){this._appendIgnoredNodeElement();}else{this._appendRoleElement(this._axNode.role());if(this._axNode.name()&&this._axNode.name().value){this._nodeWrapper.createChild('span','separator').textContent='\xA0';this._appendNameElement((this._axNode.name().value));}}
if(this._axNode.hasOnlyUnloadedChildren()){this._nodeElement.classList.add('children-unloaded');ARIAUtils.setExpanded(this._nodeElement,false);}
if(!this._axNode.isDOMNode()){this._nodeElement.classList.add('no-dom-node');}}
element(){return this._element;}
nodeElement(){return this._nodeElement;}
appendChild(breadcrumb){this._children.push(breadcrumb);breadcrumb.setParent(this);this._nodeElement.classList.add('parent');ARIAUtils.setExpanded(this._nodeElement,true);this._childrenGroupElement.appendChild(breadcrumb.element());}
hasExpandedChildren(){return this._children.length;}
setParent(breadcrumb){this._parent=breadcrumb;}
preselected(){return this._preselected;}
setPreselected(preselected,selectedByUser){if(this._preselected===preselected){return;}
this._preselected=preselected;this._nodeElement.classList.toggle('preselected',preselected);if(preselected){this._nodeElement.setAttribute('tabIndex',0);}else{this._nodeElement.setAttribute('tabIndex',-1);}
if(this._preselected){if(selectedByUser){this._nodeElement.focus();}
if(!this._inspected){this._axNode.highlightDOMNode();}else{OverlayModel.OverlayModel.hideDOMNodeHighlight();}}}
setHovered(hovered){if(this._hovered===hovered){return;}
this._hovered=hovered;this._nodeElement.classList.toggle('hovered',hovered);if(this._hovered){this._nodeElement.classList.toggle('hovered',true);this._axNode.highlightDOMNode();}}
axNode(){return this._axNode;}
inspected(){return this._inspected;}
isDOMNode(){return this._axNode.isDOMNode();}
nextBreadcrumb(){if(this._children.length){return this._children[0];}
const nextSibling=this.element().nextSibling;if(nextSibling){return nextSibling.breadcrumb;}
return null;}
previousBreadcrumb(){const previousSibling=this.element().previousSibling;if(previousSibling){return previousSibling.breadcrumb;}
return this._parent;}
parentBreadcrumb(){return this._parent;}
lastChild(){return this._children[this._children.length-1];}
_appendNameElement(name){const nameElement=createElement('span');nameElement.textContent='"'+name+'"';nameElement.classList.add('ax-readable-string');this._nodeWrapper.appendChild(nameElement);}
_appendRoleElement(role){if(!role){return;}
const roleElement=document.createElement('span');roleElement.classList.add('monospace');roleElement.classList.add(RoleStyles[role.type]);roleElement.setTextContentTruncatedIfNeeded(role.value||'');this._nodeWrapper.appendChild(roleElement);}
_appendIgnoredNodeElement(){const ignoredNodeElement=document.createElement('span');ignoredNodeElement.classList.add('monospace');ignoredNodeElement.textContent=ls`Ignored`;ignoredNodeElement.classList.add('ax-breadcrumbs-ignored-node');this._nodeWrapper.appendChild(ignoredNodeElement);}}
const RoleStyles={internalRole:'ax-internal-role',role:'ax-role',};var AXBreadcrumbsPane$1=Object.freeze({__proto__:null,AXBreadcrumbsPane:AXBreadcrumbsPane,AXBreadcrumb:AXBreadcrumb,RoleStyles:RoleStyles});class AccessibilitySidebarView extends ThrottledWidget.ThrottledWidget{constructor(){super();this._node=null;this._axNode=null;this._skipNextPullNode=false;this._sidebarPaneStack=ViewManager.ViewManager.instance().createStackLocation();this._breadcrumbsSubPane=new AXBreadcrumbsPane(this);this._sidebarPaneStack.showView(this._breadcrumbsSubPane);this._ariaSubPane=new ARIAAttributesPane();this._sidebarPaneStack.showView(this._ariaSubPane);this._axNodeSubPane=new AXNodeSubPane();this._sidebarPaneStack.showView(this._axNodeSubPane);this._sidebarPaneStack.widget().show(this.element);self.UI.context.addFlavorChangeListener(DOMModel.DOMNode,this._pullNode,this);this._pullNode();}
node(){return this._node;}
axNode(){return this._axNode;}
setNode(node,fromAXTree){this._skipNextPullNode=!!fromAXTree;this._node=node;this.update();}
accessibilityNodeCallback(axNode){if(!axNode){return;}
this._axNode=axNode;if(axNode.isDOMNode()){this._sidebarPaneStack.showView(this._ariaSubPane,this._axNodeSubPane);}else{this._sidebarPaneStack.removeView(this._ariaSubPane);}
if(this._axNodeSubPane){this._axNodeSubPane.setAXNode(axNode);}
if(this._breadcrumbsSubPane){this._breadcrumbsSubPane.setAXNode(axNode);}}
doUpdate(){const node=this.node();this._axNodeSubPane.setNode(node);this._ariaSubPane.setNode(node);this._breadcrumbsSubPane.setNode(node);if(!node){return Promise.resolve();}
const accessibilityModel=node.domModel().target().model(AccessibilityModel);accessibilityModel.clear();return accessibilityModel.requestPartialAXTree(node).then(()=>{this.accessibilityNodeCallback(accessibilityModel.axNodeForDOMNode(node));});}
wasShown(){super.wasShown();this.doUpdate();SDKModel.TargetManager.instance().addModelListener(DOMModel.DOMModel,DOMModel.Events.AttrModified,this._onAttrChange,this);SDKModel.TargetManager.instance().addModelListener(DOMModel.DOMModel,DOMModel.Events.AttrRemoved,this._onAttrChange,this);SDKModel.TargetManager.instance().addModelListener(DOMModel.DOMModel,DOMModel.Events.CharacterDataModified,this._onNodeChange,this);SDKModel.TargetManager.instance().addModelListener(DOMModel.DOMModel,DOMModel.Events.ChildNodeCountUpdated,this._onNodeChange,this);}
willHide(){SDKModel.TargetManager.instance().removeModelListener(DOMModel.DOMModel,DOMModel.Events.AttrModified,this._onAttrChange,this);SDKModel.TargetManager.instance().removeModelListener(DOMModel.DOMModel,DOMModel.Events.AttrRemoved,this._onAttrChange,this);SDKModel.TargetManager.instance().removeModelListener(DOMModel.DOMModel,DOMModel.Events.CharacterDataModified,this._onNodeChange,this);SDKModel.TargetManager.instance().removeModelListener(DOMModel.DOMModel,DOMModel.Events.ChildNodeCountUpdated,this._onNodeChange,this);}
_pullNode(){if(this._skipNextPullNode){this._skipNextPullNode=false;return;}
this.setNode(self.UI.context.flavor(DOMModel.DOMNode));}
_onAttrChange(event){if(!this.node()){return;}
const node=event.data.node;if(this.node()!==node){return;}
this.update();}
_onNodeChange(event){if(!this.node()){return;}
const node=event.data;if(this.node()!==node){return;}
this.update();}}
var AccessibilitySidebarView$1=Object.freeze({__proto__:null,AccessibilitySidebarView:AccessibilitySidebarView});export{ARIAAttributesView,ARIAMetadata$1 as ARIAMetadata,AXBreadcrumbsPane$1 as AXBreadcrumbsPane,AccessibilityModel$1 as AccessibilityModel,AccessibilityNodeView,AccessibilitySidebarView$1 as AccessibilitySidebarView,AccessibilityStrings,AccessibilitySubPane$1 as AccessibilitySubPane};