"use strict";Liferay.Loader.define("@liferay!analytics-settings-web$testing-library/dom@8.20.0/dist/suggestions",["module","exports","require","liferay!analytics-settings-web$dom-accessibility-api","./matches","./get-node-text","./config","./role-helpers","./label-helpers"],(function(e,t,n){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.getSuggestedQuery=function getSuggestedQuery(t,n="get",a){var u,l;if(t.matches((0,s.getConfig)().defaultIgnore))return;const c=null!=(u=t.getAttribute("role"))?u:null==(l=(0,g.getImplicitAriaRoles)(t))?void 0:l[0];if("generic"!==c&&canSuggest("Role",a,c))return makeSuggestion("Role",t,c,{variant:n,name:(0,i.computeAccessibleName)(t,{computedStyleSupportsPseudoElements:(0,s.getConfig)().computedStyleSupportsPseudoElements})});const d=(0,o.getLabels)(document,t).map((e=>e.content)).join(" ");if(canSuggest("LabelText",a,d))return makeSuggestion("LabelText",t,d,{variant:n});const m=t.getAttribute("placeholder");if(canSuggest("PlaceholderText",a,m))return makeSuggestion("PlaceholderText",t,m,{variant:n});const p=e((0,r.getNodeText)(t));if(canSuggest("Text",a,p))return makeSuggestion("Text",t,p,{variant:n});if(canSuggest("DisplayValue",a,t.value))return makeSuggestion("DisplayValue",t,e(t.value),{variant:n});const f=t.getAttribute("alt");if(canSuggest("AltText",a,f))return makeSuggestion("AltText",t,f,{variant:n});const h=t.getAttribute("title");if(canSuggest("Title",a,h))return makeSuggestion("Title",t,h,{variant:n});const y=t.getAttribute((0,s.getConfig)().testIdAttribute);if(canSuggest("TestId",a,y))return makeSuggestion("TestId",t,y,{variant:n});return};var i=n("liferay!analytics-settings-web$dom-accessibility-api"),a=n("./matches"),r=n("./get-node-text"),s=n("./config"),g=n("./role-helpers"),o=n("./label-helpers");const e=(0,a.getDefaultNormalizer)();function getRegExpMatcher(e){return new RegExp(function escapeRegExp(e){return e.replace(/[.*+\-?^${}()|[\]\\]/g,"\\$&")}(e.toLowerCase()),"i")}function makeSuggestion(e,t,n,{variant:i,name:a}){let r="";const s={},o=[["Role","TestId"].includes(e)?n:getRegExpMatcher(n)];a&&(s.name=getRegExpMatcher(a)),"Role"===e&&(0,g.isInaccessible)(t)&&(s.hidden=!0,r="Element is inaccessible. This means that the element and all its children are invisible to screen readers.\n    If you are using the aria-hidden prop, make sure this is the right choice for your case.\n    "),Object.keys(s).length>0&&o.push(s);const u=`${i}By${e}`;return{queryName:e,queryMethod:u,queryArgs:o,variant:i,warning:r,toString(){r&&console.warn(r);let[e,t]=o;return e="string"==typeof e?`'${e}'`:e,t=t?`, { ${Object.entries(t).map((([e,t])=>`${e}: ${t}`)).join(", ")} }`:"",`${u}(${e}${t})`}}}function canSuggest(e,t,n){return n&&(!t||t.toLowerCase()===e.toLowerCase())}}}));
//# sourceMappingURL=suggestions.js.map