"use strict";Liferay.Loader.define("@liferay!analytics-settings-web$testing-library/dom@8.20.0/dist/queries/role",["module","exports","require","liferay!analytics-settings-web$dom-accessibility-api","liferay!analytics-settings-web$aria-query","../role-helpers","../query-helpers","../helpers","./all-utils"],(function(e,r,t){window;{Object.defineProperty(r,"__esModule",{value:!0}),r.queryByRole=r.queryAllByRole=r.getByRole=r.getAllByRole=r.findByRole=r.findAllByRole=void 0;var o=t("liferay!analytics-settings-web$dom-accessibility-api"),i=t("liferay!analytics-settings-web$aria-query"),l=t("../role-helpers"),n=t("../query-helpers"),s=t("../helpers"),a=t("./all-utils");function queryAllByRole(e,r,{exact:t=!0,collapseWhitespace:n,hidden:d=(0,a.getConfig)().defaultHidden,name:c,description:u,trim:p,normalizer:y,queryFallbacks:m=!1,selected:f,checked:h,pressed:g,current:v,level:b,expanded:$}={}){(0,s.checkContainerType)(e);const A=t?a.matches:a.fuzzyMatches,w=(0,a.makeNormalizer)({collapseWhitespace:n,trim:p,normalizer:y});var R,B,q,S,E;if(void 0!==f&&void 0===(null==(R=i.roles.get(r))?void 0:R.props["aria-selected"]))throw new Error(`"aria-selected" is not supported on role "${r}".`);if(void 0!==h&&void 0===(null==(B=i.roles.get(r))?void 0:B.props["aria-checked"]))throw new Error(`"aria-checked" is not supported on role "${r}".`);if(void 0!==g&&void 0===(null==(q=i.roles.get(r))?void 0:q.props["aria-pressed"]))throw new Error(`"aria-pressed" is not supported on role "${r}".`);if(void 0!==v&&void 0===(null==(S=i.roles.get(r))?void 0:S.props["aria-current"]))throw new Error(`"aria-current" is not supported on role "${r}".`);if(void 0!==b&&"heading"!==r)throw new Error(`Role "${r}" cannot have "level" property.`);if(void 0!==$&&void 0===(null==(E=i.roles.get(r))?void 0:E.props["aria-expanded"]))throw new Error(`"aria-expanded" is not supported on role "${r}".`);const k=new WeakMap;function cachedIsSubtreeInaccessible(e){return k.has(e)||k.set(e,(0,l.isSubtreeInaccessible)(e)),k.get(e)}return Array.from(e.querySelectorAll(function makeRoleSelector(e,r,t){var o;if("string"!=typeof e)return"*";const l=r&&!t?`*[role~="${e}"]`:"*[role]",n=null!=(o=i.roleElements.get(e))?o:new Set,s=new Set(Array.from(n).map((({name:e})=>e)));return[l].concat(Array.from(s)).join(",")}(r,t,y?w:void 0))).filter((e=>{if(e.hasAttribute("role")){const t=e.getAttribute("role");if(m)return t.split(" ").filter(Boolean).some((t=>A(t,e,r,w)));if(y)return A(t,e,r,w);const[o]=t.split(" ");return A(o,e,r,w)}return(0,l.getImplicitAriaRoles)(e).some((t=>A(t,e,r,w)))})).filter((e=>void 0!==f?f===(0,l.computeAriaSelected)(e):void 0!==h?h===(0,l.computeAriaChecked)(e):void 0!==g?g===(0,l.computeAriaPressed)(e):void 0!==v?v===(0,l.computeAriaCurrent)(e):void 0!==$?$===(0,l.computeAriaExpanded)(e):void 0===b||b===(0,l.computeHeadingLevel)(e))).filter((e=>void 0===c||(0,a.matches)((0,o.computeAccessibleName)(e,{computedStyleSupportsPseudoElements:(0,a.getConfig)().computedStyleSupportsPseudoElements}),e,c,(e=>e)))).filter((e=>void 0===u||(0,a.matches)((0,o.computeAccessibleDescription)(e,{computedStyleSupportsPseudoElements:(0,a.getConfig)().computedStyleSupportsPseudoElements}),e,u,(e=>e)))).filter((e=>!1!==d||!1===(0,l.isInaccessible)(e,{isSubtreeInaccessible:cachedIsSubtreeInaccessible})))}const getNameHint=e=>{let r="";return r=void 0===e?"":"string"==typeof e?` and name "${e}"`:` and name \`${e}\``,r},getMultipleError=(e,r,{name:t}={})=>`Found multiple elements with the role "${r}"${getNameHint(t)}`,getMissingError=(e,r,{hidden:t=(0,a.getConfig)().defaultHidden,name:o,description:i}={})=>{if((0,a.getConfig)()._disableExpensiveErrorDiagnostics)return`Unable to find role="${r}"${getNameHint(o)}`;let n,s="";Array.from(e.children).forEach((e=>{s+=(0,l.prettyRoles)(e,{hidden:t,includeDescription:void 0!==i})})),n=0===s.length?!1===t?"There are no accessible roles. But there might be some inaccessible roles. If you wish to access them, then set the `hidden` option to `true`. Learn more about this here: https://testing-library.com/docs/dom-testing-library/api-queries#byrole":"There are no available roles.":`\nHere are the ${!1===t?"accessible":"available"} roles:\n\n  ${s.replace(/\n/g,"\n  ").replace(/\n\s\s\n/g,"\n\n")}\n`.trim();let d="";d=void 0===o?"":"string"==typeof o?` and name "${o}"`:` and name \`${o}\``;let c="";return c=void 0===i?"":"string"==typeof i?` and description "${i}"`:` and description \`${i}\``,`\nUnable to find an ${!1===t?"accessible ":""}element with the role "${r}"${d}${c}\n\n${n}`.trim()},e=(0,n.wrapAllByQueryWithSuggestion)(queryAllByRole,queryAllByRole.name,"queryAll");r.queryAllByRole=e;const[d,c,u,p,y]=(0,a.buildQueries)(queryAllByRole,getMultipleError,getMissingError);r.findByRole=y,r.findAllByRole=p,r.getByRole=u,r.getAllByRole=c,r.queryByRole=d}}));
//# sourceMappingURL=role.js.map