"use strict";Liferay.Loader.define("@liferay!analytics-settings-web$testing-library/dom@8.20.0/dist/role-helpers",["module","exports","require","liferay!analytics-settings-web$aria-query","liferay!analytics-settings-web$dom-accessibility-api","./pretty-dom","./config"],(function(e,t,i){window;{var r=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var i=arguments[t];for(var r in i)Object.prototype.hasOwnProperty.call(i,r)&&(e[r]=i[r])}return e};Object.defineProperty(t,"__esModule",{value:!0}),t.computeAriaChecked=function computeAriaChecked(e){if("indeterminate"in e&&e.indeterminate)return;if("checked"in e)return e.checked;return checkBooleanAttribute(e,"aria-checked")},t.computeAriaCurrent=function computeAriaCurrent(e){var t,i;return null!=(t=null!=(i=checkBooleanAttribute(e,"aria-current"))?i:e.getAttribute("aria-current"))&&t},t.computeAriaExpanded=function computeAriaExpanded(e){return checkBooleanAttribute(e,"aria-expanded")},t.computeAriaPressed=function computeAriaPressed(e){return checkBooleanAttribute(e,"aria-pressed")},t.computeAriaSelected=function computeAriaSelected(e){if("OPTION"===e.tagName)return e.selected;return checkBooleanAttribute(e,"aria-selected")},t.computeHeadingLevel=function computeHeadingLevel(e){return e.getAttribute("aria-level")&&Number(e.getAttribute("aria-level"))||{H1:1,H2:2,H3:3,H4:4,H5:5,H6:6}[e.tagName]},t.getImplicitAriaRoles=getImplicitAriaRoles,t.getRoles=getRoles,t.isInaccessible=isInaccessible,t.isSubtreeInaccessible=isSubtreeInaccessible,t.logRoles=void 0,t.prettyRoles=prettyRoles;var n=i("liferay!analytics-settings-web$aria-query"),c=i("liferay!analytics-settings-web$dom-accessibility-api"),o=i("./pretty-dom"),s=i("./config");const e=function buildElementRoleList(e){function getSelectorSpecificity({attributes:e=[]}){return e.length}function match(e){let{attributes:t=[]}=e;const i=t.findIndex((e=>e.value&&"type"===e.name&&"text"===e.value));i>=0&&(t=[...t.slice(0,i),...t.slice(i+1)]);const n=function makeElementSelector({name:e,attributes:t}){return`${e}${t.map((({name:e,value:t,constraints:i=[]})=>-1!==i.indexOf("undefined")?`:not([${e}])`:t?`[${e}="${t}"]`:`[${e}]`)).join("")}`}(r({},e,{attributes:t}));return e=>!(i>=0&&"text"!==e.type)&&e.matches(n)}let t=[];for(const[i,r]of e.entries())t=[...t,{match:match(i),roles:Array.from(r),specificity:getSelectorSpecificity(i)}];return t.sort((function bySelectorSpecificity({specificity:e},{specificity:t}){return t-e}))}(n.elementRoles);function isSubtreeInaccessible(e){if(!0===e.hidden)return!0;if("true"===e.getAttribute("aria-hidden"))return!0;return"none"===e.ownerDocument.defaultView.getComputedStyle(e).display}function isInaccessible(e,t={}){const{isSubtreeInaccessible:i=isSubtreeInaccessible}=t;if("hidden"===e.ownerDocument.defaultView.getComputedStyle(e).visibility)return!0;let r=e;for(;r;){if(i(r))return!0;r=r.parentElement}return!1}function getImplicitAriaRoles(t){for(const i of e){const{match:e,roles:r}=i;if(e(t))return[...r]}return[]}function getRoles(e,{hidden:t=!1}={}){return function flattenDOM(e){return[e,...Array.from(e.children).reduce(((e,t)=>[...e,...flattenDOM(t)]),[])]}(e).filter((e=>!1!==t||!1===isInaccessible(e))).reduce(((e,t)=>{let i=[];return i=t.hasAttribute("role")?t.getAttribute("role").split(" ").slice(0,1):getImplicitAriaRoles(t),i.reduce(((e,i)=>Array.isArray(e[i])?r({},e,{[i]:[...e[i],t]}):r({},e,{[i]:[t]})),e)}),{})}function prettyRoles(e,{hidden:t,includeDescription:i}){const r=getRoles(e,{hidden:t});return Object.entries(r).filter((([e])=>"generic"!==e)).map((([e,t])=>{const r="-".repeat(50);return`${e}:\n\n${t.map((e=>{const t=`Name "${(0,c.computeAccessibleName)(e,{computedStyleSupportsPseudoElements:(0,s.getConfig)().computedStyleSupportsPseudoElements})}":\n`,r=(0,o.prettyDOM)(e.cloneNode(!1));if(i){return`${t}${`Description "${(0,c.computeAccessibleDescription)(e,{computedStyleSupportsPseudoElements:(0,s.getConfig)().computedStyleSupportsPseudoElements})}":\n`}${r}`}return`${t}${r}`})).join("\n\n")}\n\n${r}`})).join("\n")}const logRoles=(e,{hidden:t=!1}={})=>console.log(prettyRoles(e,{hidden:t}));function checkBooleanAttribute(e,t){const i=e.getAttribute(t);return"true"===i||"false"!==i&&void 0}t.logRoles=logRoles}}));
//# sourceMappingURL=role-helpers.js.map