@qualweb/qw-page
Version:
Utilities module for qualweb
1 lines • 24.7 kB
JavaScript
(()=>{"use strict";var e={715(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.QWElement=void 0;const l=n(300);class r{constructor(e,t){this.selector="",this.element=e,this.elementsCSSRules=t;const n=e.getAttribute("qw-selector");n&&(this.selector=n)}addCSSRulesPropertyToElement(e){var t;e&&(null===(t=this.elementsCSSRules)||void 0===t?void 0:t.has(e))&&e.setAttribute("qw-css-rules","true")}hasCSSRules(){return"true"===this.element.getAttribute("qw-css-rules")}getCSSRules(){var e;return null===(e=this.elementsCSSRules)||void 0===e?void 0:e.get(this.element)}hasCSSProperty(e,t,n){var l,r;if(null===(l=this.elementsCSSRules)||void 0===l?void 0:l.has(this.element)){const l=null===(r=this.elementsCSSRules)||void 0===r?void 0:r.get(this.element);if(l){if(t&&n)return void 0!==l.media[n][t][e];if(t)return void 0!==l[t][e];if(n)return void 0!==l.media[n][e]}return!l||void 0!==l[e]}return!1}getCSSProperty(e,t,n){var l,r;if(null===(l=this.elementsCSSRules)||void 0===l?void 0:l.has(this.element)){const l=null===(r=this.elementsCSSRules)||void 0===r?void 0:r.get(this.element);if(l)return t&&n?l.media[n][t][e]:t?l[t][e]:n?l.media[n][e]:l[e]}}getCSSMediaRules(){var e,t;if(null===(e=this.elementsCSSRules)||void 0===e?void 0:e.has(this.element)){const e=null===(t=this.elementsCSSRules)||void 0===t?void 0:t.get(this.element);if(e)return e.media}}getCSSPseudoSelectorRules(e){var t,n;if(null===(t=this.elementsCSSRules)||void 0===t?void 0:t.has(this.element)){const t=null===(n=this.elementsCSSRules)||void 0===n?void 0:n.get(this.element);if(t)return t[e]}}elementHasAttribute(e){return this.element.getAttributeNames().includes(e)}elementHasAttributes(){return this.element.getAttributeNames().length>0}elementHasChild(e){const t=this.element.children;for(let n=0;n<t.length;n++){const l=t.item(n);if(l&&l.tagName.toLowerCase()===e.toLowerCase())return!0}return!1}elementHasChildren(){return this.element.children.length>0}elementHasParent(e){const t=this.element.parentElement;return!!t&&t.tagName.toLowerCase()===e.toLowerCase()}hasTextNode(){let e=!1;return this.element.childNodes.forEach(t=>{var n;3===t.nodeType&&""!==(null===(n=t.textContent)||void 0===n?void 0:n.trim())&&(e=!0)}),e}getElementAttribute(e){return this.element.getAttribute(e)}getElementAttributes(){var e;const t={};for(const n of null!==(e=this.element.getAttributeNames())&&void 0!==e?e:[]){const e=this.element.getAttribute(n);e&&(t[n]=e)}return t}getElementAttributesName(){return this.element.getAttributeNames()}getElementChildren(){const e=new Array,t=this.element.children;for(let n=0;n<t.length;n++){const l=t.item(n);l&&(this.addCSSRulesPropertyToElement(l),e.push(new r(l,this.elementsCSSRules)))}return e}getElementChildTextContent(e){var t;const n=this.element.children;for(let l=0;l<n.length;l++){const r=n.item(l);if(r&&r.tagName.toLowerCase()===e.toLowerCase())return null!==(t=r.textContent)&&void 0!==t?t:void 0}}getElementHtmlCode(e,t){const n=this.element.getAttribute("qw-css-rules"),l=this.element.getAttribute("qw-selector"),r=this.element.getAttribute("_documentSelector");let o;if(this.element.removeAttribute("qw-css-rules"),this.element.removeAttribute("qw-selector"),this.element.removeAttribute("_documentSelector"),t){const e=this.element.children,t=new Array;for(let n=0;n<e.length;n++){const l=e.item(n);if(l){const e=l.getAttribute("qw-css-rules"),n=l.getAttribute("qw-selector"),r=l.getAttribute("_documentSelector");t.push({cssRulesValue:e,selectorValue:n,documentSelectorValue:r}),l.removeAttribute("qw-css-rules"),l.removeAttribute("qw-selector"),l.removeAttribute("_documentSelector")}}o=this.element.outerHTML;for(let n=0;n<e.length;n++){const l=e.item(n);if(l){const e=t[n];e.cssRulesValue&&l.setAttribute("qw-css-rules",e.cssRulesValue),e.selectorValue&&l.setAttribute("qw-selector",e.selectorValue),e.documentSelectorValue&&l.setAttribute("_documentSelector",e.documentSelectorValue)}}}else if(e){const e=this.element.cloneNode(!1),t=this.getElementText();e.innerHTML=void 0!==t?t:"",o=e.outerHTML}else{const e=this.element.cloneNode(!1);e.innerHTML="",o=e.outerHTML}return n&&this.element.setAttribute("qw-css-rules",n),l&&this.element.setAttribute("qw-selector",l),r&&this.element.setAttribute("_documentSelector",r),o}getElement(e){const t=this.element.querySelector(e);return this.addCSSRulesPropertyToElement(t),this.convertElementToQWElement(t)}getClosestAncestor(e,t){let n=this.getElementParent(),l=0;const r=e.toLowerCase();for(;n&&!(void 0!==t&&l>=t);){const e=n.getElementTagName().toLowerCase();if("html"===e||"body"===e)break;if(e===r)return n;n=n.getElementParent(),l++}return null}isBefore(e){return!!(this.element.compareDocumentPosition(e.element)&Node.DOCUMENT_POSITION_FOLLOWING)}getElementsBetween(e,t=[]){const n=this.isBefore(e),l=n?this.element:e.element,r=n?e.element:this.element,o=new Set(t.map(e=>e.toLowerCase())),s=[];let i=this.findCommonAncestor(e);if(!i)return s;const m=document.createTreeWalker(i.element,NodeFilter.SHOW_ELEMENT);m.currentNode=l;let u=m.nextNode();for(;u&&u!==r;){const e=u.nodeName.toLowerCase();o.has(e)||s.push(e),u=m.nextNode()}return s}findCommonAncestor(e){const t=new Set;let n=this.element;for(;n;)t.add(n),n=n.parentElement;let l=e.element;for(;l;){if(t.has(l))return new r(l,this.elementsCSSRules);l=l.parentElement}return null}convertElementToQWElement(e){return e?(this.addCSSRulesPropertyToElement(e),new r(e,this.elementsCSSRules)):null}convertElementsToQWElement(e){const t=new Array;return null==e||e.forEach(e=>{this.addCSSRulesPropertyToElement(e),t.push(new r(e,this.elementsCSSRules))}),t}getElements(e){return this.convertElementsToQWElement(this.element.querySelectorAll(e))}getElementNextSibling(){return this.convertElementToQWElement(this.element.nextElementSibling)}getAllPreviousSiblings(){const e=new Array;let t=this.element.previousSibling;for(;null!==t;){if(1===t.nodeType){const n=this.convertElementToQWElement(t);n&&e.unshift(n)}else 3===t.nodeType&&t.textContent&&e.unshift(t.textContent);t=t.previousSibling}return e}getAllNextSiblings(){const e=new Array;let t=this.element.nextSibling;for(;null!==t;){if(1===t.nodeType){const n=this.convertElementToQWElement(t);n&&e.push(n)}else 3===t.nodeType&&t.textContent&&e.push(t.textContent);t=t.nextSibling}return e}getPreviousSibling(){const e=this.element.previousSibling;if(e){if(1===e.nodeType)return this.convertElementToQWElement(e);if(3===e.nodeType)return e.textContent;{let t=e.previousSibling,n=null;for(;null!==t;){if(1===t.nodeType){n=this.convertElementToQWElement(t);break}3===t.nodeType&&(n=t.textContent),t=t.previousSibling}return n}}return null}getNextSibling(){const e=this.element.nextSibling;if(e){if(1===e.nodeType)return this.convertElementToQWElement(e);if(3===e.nodeType)return e.textContent;{let t=e.nextSibling,n=null;for(;null!==t;){if(1===t.nodeType){n=this.convertElementToQWElement(t);break}3===t.nodeType&&(n=t.textContent),t=t.nextSibling}return n}}return null}getElementParent(){return this.convertElementToQWElement(this.element.parentElement)}getParentAllContexts(){let e=this.element.parentElement;if(!e){const t=this.element.getAttribute("_documentSelector");t&&(e=document.querySelector(t))}return this.convertElementToQWElement(this.element.parentElement)}getElementPreviousSibling(){return this.convertElementToQWElement(this.element.previousElementSibling)}getElementProperty(e){var t;const n=this.element[e];return null!==(t=null==n?void 0:n.toString())&&void 0!==t?t:""}getElementSelector(){if(""===this.selector){if("html"===this.element.tagName.toLowerCase())return"html";if("head"===this.element.tagName.toLowerCase())return"html > head";if("body"===this.element.tagName.toLowerCase())return"html > body";let e="";const t=new Array;let n=this.element.parentElement;for(;n;)t.unshift(this.getSelfLocationInParent(n)),n=n.parentElement;t.length>0?(e+=t.join(" > "),e+=" > "+this.getSelfLocationInParent(this.element)):e+=this.getSelfLocationInParent(this.element);const l=this.element.getAttribute("_documentSelector");return l&&(e=l+e),this.selector=e,e}return this.selector}getSelfLocationInParent(e){let t="";if("body"===e.tagName.toLowerCase()||"head"===e.tagName.toLowerCase())return e.tagName.toLowerCase();let n=0,l=e.previousElementSibling;for(;l;)l.tagName.toLowerCase()===e.tagName.toLowerCase()&&n++,l=l.previousElementSibling;return t+=`${e.tagName.toLowerCase()}:nth-of-type(${n+1})`,t}getElementStyleProperty(e,t){return getComputedStyle(this.element,t).getPropertyValue(e)}getElementTagName(){return this.element.tagName.toLowerCase()}getElementText(){var e,t;return this.element.shadowRoot?null!==(e=this.element.shadowRoot.textContent)&&void 0!==e?e:"":null!==(t=this.element.textContent)&&void 0!==t?t:""}getElementOwnText(){let e;e=this.element.shadowRoot?this.element.shadowRoot.childNodes:this.element.childNodes;let t,n="";return e.forEach(e=>{t=e.textContent,3===e.nodeType&&t&&""!==t.trim()&&(n+=t.trim())}),n}getElementType(){return 1===this.element.nodeType?"tag":2===this.element.nodeType?"attribute":3===this.element.nodeType?"text":"comment"}getNumberOfSiblingsWithTheSameTag(){let e=1,t=this.element.nextElementSibling;for(;t;)"a"===t.tagName.toLowerCase()&&e++,t=t.nextElementSibling;return e}setElementAttribute(e,t){this.element.setAttribute(e,t)}concatANames(e){const t=this.element.childNodes;let n,l="",r=0,o=0;return t.forEach(t=>{n=t.textContent,3===t.nodeType&&n&&""!==n.trim()?(l=l+(0===o?"":" ")+n.trim(),o++):1===t.nodeType&&(l=l+(o>0&&e[r]?" ":"")+e[r],r++)}),l||(l=""),l}isOffScreen(){const e=Math.max(document.body.scrollHeight,document.documentElement.scrollHeight,document.body.offsetHeight,document.documentElement.offsetHeight,document.body.clientHeight,document.documentElement.clientHeight),t=Math.max(document.body.scrollWidth,document.documentElement.scrollWidth,document.body.offsetWidth,document.documentElement.offsetWidth,document.body.clientWidth,document.documentElement.clientHeight),n=this.element.getBoundingClientRect(),l=n.left,r=n.right,o=n.bottom,s=n.top,i=this.noParentScrolled(o);return l>t||r<0||o<0&&i||s>e||0===r&&0===l}isElementHTMLElement(){return this.element instanceof HTMLElement}getContentFrame(){let e=null;if("iframe"===this.getElementTagName()){const t=this.element.contentWindow;t&&(e=t.document)}return e}elementHasTextNode(){let e=!1;return null!==this.element.childNodes&&this.element.childNodes.forEach(t=>{var n;3===t.nodeType&&""!==(null===(n=t.textContent)||void 0===n?void 0:n.trim())&&(e=!0)}),e}getChildrenTextNodes(){const e=[];return this.element.childNodes&&this.element.childNodes.forEach(t=>{var n;3===t.nodeType&&""!==(null===(n=t.textContent)||void 0===n?void 0:n.trim())&&e.push(new l.QWTextNode(t))}),e.length>0?e:null}getDescendantTextNodes(e=this.element){let t=[];return e.childNodes?(e.childNodes.forEach(e=>{var n;if(3===e.nodeType&&""!==(null===(n=e.textContent)||void 0===n?void 0:n.trim()))t.push(new l.QWTextNode(e));else if(1===e.nodeType){const n=this.getDescendantTextNodes(e);n&&(t=[...t,...n])}}),t.length>0?t:null):null}noParentScrolled(e){let t=this.element.parentElement;for(;t&&"html"!==t.nodeName.toLowerCase();){if(t.scrollTop&&(e+=t.scrollTop)>=0)return!1;t=t.parentElement}return!0}focusElement(){this.element.focus()}dispatchEvent(e){this.element.dispatchEvent(e)}click(){this.element.click()}getBoundingBox(){return this.element.getBoundingClientRect()}visualOrientationTo(e){const t=this.getBoundingBox(),n=e.getBoundingBox();if(!t||!n)return{primary:"none",deltaX:0,deltaY:0};const l=Math.max(document.documentElement.scrollHeight,document.documentElement.offsetHeight,document.documentElement.clientHeight),r={left:t.left,right:t.right,top:l-t.top,bottom:l-t.bottom},o={left:n.left,right:n.right,top:l-n.top,bottom:l-n.bottom},s=1.1,i=Math.max(r.left,o.left)<Math.min(r.right,o.right),m=Math.max(r.bottom,o.bottom)<Math.min(r.top,o.top);if(i&&m)return{primary:"overlap",deltaX:0,deltaY:0};if(m){if(o.left>=r.right-s)return{primary:"right",deltaX:Math.max(0,o.left-r.right),deltaY:0};if(o.right<=r.left+s)return{primary:"left",deltaX:Math.max(0,r.left-o.right),deltaY:0}}if(i){if(o.bottom>=r.top-s)return{primary:"up",deltaX:0,deltaY:Math.max(0,o.bottom-r.top)};if(o.top<=r.bottom+s)return{primary:"down",deltaX:0,deltaY:Math.max(0,r.bottom-o.top)}}const u=Math.abs(o.bottom-r.top)<s||Math.abs(o.top-r.bottom)<s;if(Math.abs(o.right-r.left)<s||Math.abs(o.left-r.right)<s){if(o.left>=r.right-s)return{primary:"right",deltaX:0,deltaY:0};if(o.right<=r.left+s)return{primary:"left",deltaX:0,deltaY:0}}if(u){if(o.bottom>=r.top-s)return{primary:"up",deltaX:0,deltaY:0};if(o.top<=r.bottom+s)return{primary:"down",deltaX:0,deltaY:0}}return{primary:"none",deltaX:0,deltaY:0}}getShadowElement(e){const t=this.element.shadowRoot;let n=null;return t&&(n=t.querySelector(e)),this.convertElementToQWElement(n)}getShadowElements(e){const t=this.element.shadowRoot;let n=null;return t&&(n=t.querySelectorAll(e)),this.convertElementsToQWElement(n)}getSlotElements(){const e=this.element.assignedElements(),t=new Array;return null==e||e.forEach(e=>{this.addCSSRulesPropertyToElement(e),t.push(new r(e,this.elementsCSSRules))}),t}getSlotNodes(){return this.element.assignedNodes()}isShadowRoot(){return!!this.element.shadowRoot}}t.QWElement=r},300(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.QWTextNode=void 0;const l=n(715);t.QWTextNode=class{constructor(e){this.node=e}getBoundingBox(){const e=this.node.textContent||"",t=e.search(/\S/),n=e.trimEnd().length;if(-1===t)return null;const l=document.createRange();try{l.setStart(this.node,t),l.setEnd(this.node,n);const e=l.getBoundingClientRect();return 0===e.width&&0===e.height?null:e}catch(e){return null}finally{l.detach()}}isVisible(){const e=this.getBoundingBox();if(!e||0===e.width&&0===e.height)return!1;const t=this.getParentElement();if(!t)return!1;const n=t.getElementStyleProperty("display",null),l=t.getElementStyleProperty("visibility",null),r=t.getElementStyleProperty("opacity",null);return!!(n&&l&&r)&&"none"!==n&&"hidden"!==l&&"0"!==r&&""!==this.getText()}getText(){var e;return(null===(e=this.node.textContent)||void 0===e?void 0:e.trim())||""}getParentElement(){const e=this.node.parentElement;return e?new l.QWElement(e):null}}},408(e,t,n){var l=this&&this.__createBinding||(Object.create?function(e,t,n,l){void 0===l&&(l=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,l,r)}:function(e,t,n,l){void 0===l&&(l=n),e[l]=t[n]}),r=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||l(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),r(n(715),t),r(n(300),t),r(n(357),t)},357(e,t){Object.defineProperty(t,"__esModule",{value:!0})},490(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.CSSMapper=void 0;const l=n(408);t.CSSMapper=class{constructor(e){this.pseudoSelectors=["focus","hover","before","after","active","disabled","checked","empty","enabled","in-range","invalid","lang","link","optional","out-of-range","read-only","read-write","required","target","valid","visited","first-letter","first-line","selection"],this.elementsCSSRules=new Map,this.document=e}map(){return this.mapExternalStylesheets(),this.mapHeadStyles(),this.mapInlineStyles(),this.elementsCSSRules}mapExternalStylesheets(){var e;for(let t=0;t<this.document.styleSheets.length;t++){const n=this.document.styleSheets.item(t);if(n&&"link"===(null===(e=n.ownerNode)||void 0===e?void 0:e.nodeName.toLowerCase())){const e=this.getCSSRules(n);if(e)for(let t=0;t<e.length;t++){const l=e.item(t);1===(null==l?void 0:l.type)?this.mapNormalCSSRule(l,void 0,"file",n.href):4===(null==l?void 0:l.type)&&this.mapMediaCSSRule(l,"file",n.href)}}}}mapHeadStyles(){const e=this.document.querySelectorAll("style");for(let t=0;t<e.length;t++){const n=e.item(t),r=this.getCSSRules(n.sheet);if(r)for(let e=0;e<r.length;e++){const t=r.item(e);t&&(1===t.type?this.mapNormalCSSRule(t,void 0,"head",new l.QWElement(n).getElementSelector()):4===t.type&&this.mapMediaCSSRule(t,"head",new l.QWElement(n).getElementSelector()))}}}mapInlineStyles(){const e=this.document.querySelectorAll("[style]");for(let t=0;t<e.length;t++){const n=e.item(t),r=n.getAttribute("style");if(r){const e=r.split(";").map(e=>e.trim()).filter(e=>""!==e)||[r.trim()];this.elementsCSSRules.has(n)?this.addElementCSSRules(n,e,void 0,void 0,"inline",new l.QWElement(n).getElementSelector()||""):this.createElementCSSMapping(n,e,void 0,void 0,"inline",new l.QWElement(n).getElementSelector()||"")}}}mapMediaCSSRule(e,t,n){const l=e.cssRules||new CSSRuleList;for(let r=0;r<l.length;r++){const o=l.item(r);1===(null==o?void 0:o.type)&&this.mapNormalCSSRule(o,e.conditionText,t,n)}}mapNormalCSSRule(e,t,n,l){const r=e.selectorText.trim(),o=e.cssText.replace(r,"").replace("{","").replace("}","").trim().split(";").map(e=>e.trim()).filter(e=>""!==e),s=r.split(",")||[r];for(let e of s||[]){let r;if(e.includes("::")){const t=e.split("::");this.pseudoSelectors.includes(t[1])&&(e=t[0].trim(),r="::"+t[1].trim())}else if(e.includes(":")){const t=e.split(":");e=t[0].trim(),r=":"+t[1].trim()}const s=this.getElements(e);if(s)for(let e=0;e<s.length;e++){const i=s.item(e);this.elementsCSSRules.has(i)?this.addElementCSSRules(i,o,t,r,n,l||""):this.createElementCSSMapping(i,o,t,r,n,l||"")}}}createElementCSSMapping(e,t,n,l,r,o){const s={media:{}};n&&(s.media[n]={},l&&(s.media[n][l]={}));for(const e of t||[]){const t=e.split(":")[0].trim();n?l?s.media[n][l][t]=this.createPropertyObject(e,r,o):s.media[n][t]=this.createPropertyObject(e,r,o):void 0===s[t]?s[t]=this.createPropertyObject(e,r,o):s[t].important&&!e.includes("!important")||(s[t]=this.createPropertyObject(e,r,o))}this.elementsCSSRules.set(e,s)}addElementCSSRules(e,t,n,l,r,o){for(const s of t||[]){const t=this.elementsCSSRules.get(e),i=s.split(":")[0].trim();n?(void 0===t.media&&(t.media={}),void 0===t.media[n]?(t.media[n]={},l?(t.media[n][l]={},t.media[n][l][i]=this.createPropertyObject(s,r,o)):t.media[n][i]=this.createPropertyObject(s,r,o)):l?void 0===t.media[n][l]?(t.media[n][l]={},t.media[n][l][i]=this.createPropertyObject(s,r,o)):void 0===t.media[n][l][i]?t.media[n][l][i]=this.createPropertyObject(s,r,o):t.media[n][l][i].important?s.includes("!important")&&(t.media[n][l][i]=this.createPropertyObject(s,r,o)):t.media[n][l][i]=this.createPropertyObject(s,r,o):void 0===t.media[n][i]?t.media[n][i]=this.createPropertyObject(s,r,o):t.media[n][i].important?s.includes("!important")&&(t.media[n][i]=this.createPropertyObject(s,r,o)):t.media[n][i]=this.createPropertyObject(s,r,o)):l?void 0===t[l]?(t[l]={},t[l][i]=this.createPropertyObject(s,r,o)):void 0===t[l][i]?t[l][i]=this.createPropertyObject(s,r,o):t[l][i].important?s.includes("!important")&&(t[l][i]=this.createPropertyObject(s,r,o)):t[l][i]=this.createPropertyObject(s,r,o):void 0===t[i]?t[i]=this.createPropertyObject(s,r,o):t[i].important?s.includes("!important")&&(t[i]=this.createPropertyObject(s,r,o)):t[i]=this.createPropertyObject(s,r,o),this.elementsCSSRules.set(e,t)}}createPropertyObject(e,t,n){const l=e.includes("!important"),r=e.split(":"),o=r[0].trim(),s=r.splice(1).join("");return{important:l,name:o,value:l?s.replace("!important","").trim():s.trim(),location:t,pointer:n}}getCSSRules(e){try{return(null==e?void 0:e.rules)||(null==e?void 0:e.cssRules)||null}catch(e){return null}}getElements(e){try{return this.document.querySelectorAll(e)}catch(e){return null}}}},865(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.QWPage=void 0;const l=n(408),r=n(454),o=n(490),s=n(555);class i{constructor(e,t){this.cache=new r.Cache,this.extraDocuments=new Map,this.document=e,s.SelectorCalculator.processElementSelector(this.document),t&&(this.elementsCSSRules=new o.CSSMapper(this.document).map()),this.url=this.document.baseURI,this.processIframes(),this.processShadowDom()}createQWElement(e){return new l.QWElement(e)}processShadowDom(){const e=this.document.querySelectorAll("*");for(let t=0;t<e.length;t++){const n=e.item(t);if(null!==n.shadowRoot){const e=new l.QWElement(n).getElementSelector(),t=new i(n.shadowRoot,!0);this.extraDocuments.set(e,t)}}}processIframes(){const e=this.document.querySelectorAll("iframe");for(let t=0;t<e.length;t++)try{const n=e.item(t),r=new l.QWElement(n),o=r.getContentFrame();if(o&&o.defaultView){const e=r.getElementSelector(),t=new i(o,!0);this.extraDocuments.set(e,t)}}catch(e){}}addCSSRulesPropertyToElement(e){var t;e&&(null===(t=this.elementsCSSRules)||void 0===t?void 0:t.has(e))&&e.setAttribute("qw-css-rules","true")}addIframeAttribute(e,t){for(const n of e)n.setElementAttribute("_documentSelector",t)}cacheValue(e,t,n){this.cache.put(e+","+t,n)}getCachedValue(e,t){return this.cache.get(e+","+t)}isValueCached(e,t){return this.cache.exists(e+","+t)}getURL(){return this.url}getElementFromDocument(e){const t=this.document.querySelector(e);return this.addCSSRulesPropertyToElement(t),t?new l.QWElement(t,this.elementsCSSRules):null}getElementsFromDocument(e){const t=this.document.querySelectorAll(e),n=new Array;return t.forEach(e=>{this.addCSSRulesPropertyToElement(e),n.push(new l.QWElement(e,this.elementsCSSRules))}),n}getElement(e,t,n){let l=null,r=null;if(t||n)if(r=t?t.getElementAttribute("_documentSelector"):n,r&&this.extraDocuments.has(r)){const n=this.extraDocuments.get(r);n&&(l=n.getElement(e,t))}else l=this.getElementFromDocument(e);else l=this.getElementFromDocument(e),l||this.extraDocuments.forEach((t,n)=>{l||(l=t.getElement(e),r=n)});return l&&r&&this.addIframeAttribute([l],r),l}getElements(e,t,n){let l;const r=new Array;if(t||n)if(l=t?t.getElementAttribute("_documentSelector"):n,l&&this.extraDocuments.has(l)){const n=this.extraDocuments.get(l);n&&(r.push(...n.getElements(e,t)),this.addIframeAttribute(r,l))}else r.push(...this.getElementsFromDocument(e));else r.push(...this.getElementsFromDocument(e)),this.extraDocuments.forEach((t,n)=>{const l=t.getElements(e);this.addIframeAttribute(l,n),r.push(...l)});return r}getElementByID(e){const t=this.document.querySelector(`[id='${e}']`);return this.addCSSRulesPropertyToElement(t),t?new l.QWElement(t,this.elementsCSSRules):null}getElementByAttributeName(e){const t=this.document.querySelector(`[name='${e}']`);return this.addCSSRulesPropertyToElement(t),t?new l.QWElement(t,this.elementsCSSRules):null}getPageRootElement(){if(this.document instanceof Document){const e=this.document.documentElement;return this.addCSSRulesPropertyToElement(e),e?new l.QWElement(e,this.elementsCSSRules):null}return null}getHTMLContent(){return this.document instanceof ShadowRoot?this.document.innerHTML:this.document.documentElement.outerHTML}getFocusedElement(){const e=this.document.activeElement;return this.addCSSRulesPropertyToElement(e),e?new l.QWElement(e,this.elementsCSSRules):null}pageHasOpenDialog(){return this.getElements("dialog").some(e=>e.getElementProperty("open"))}cleanAllElements(){const e=this.document.querySelector("html");this.cleanElement(e)}cleanAllElementsAux(e){for(let t=0;t<e.length;t++){const n=e.item(t);this.cleanElement(n)}}cleanElement(e){if(e){e.removeAttribute("qw-selector"),e.removeAttribute("qw-css-rules"),e.removeAttribute("_documentSelector");const t=e.children;t&&t.length>0&&this.cleanAllElementsAux(t)}}}t.QWPage=i,window.qwPage=new i(document,!0)},454(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.Cache=void 0,t.Cache=class{constructor(){this.cache=new Map}get(e){return this.cache.get(e)}put(e,t){this.cache.set(e,t)}exists(e){return this.cache.has(e)}}},555(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.SelectorCalculator=void 0,t.SelectorCalculator=class{static processElementSelector(e){const t=e.querySelector("html");if(t){t.setAttribute("qw-selector","html");const e=t.children;e&&this.processElementSelectorAux(e)}}static processElementSelectorAux(e){const t=e[0].parentElement;if(t){const n=t.getAttribute("qw-selector");if(n){this.addSelectorAttribute(e,n);for(let t=0;t<e.length;t++){const n=e.item(t);if(n){const e=n.children;e&&e.length>0&&this.processElementSelectorAux(e)}}}}}static addSelectorAttribute(e,t){let n=1;for(let l=0;l<e.length;l++){const r=e.item(l);if(r){const e=r.tagName.toLowerCase();r.setAttribute("qw-selector",t+" > "+e+":nth-child("+n+")"),n++}}}}}},t={};function n(l){var r=t[l];if(void 0!==r)return r.exports;var o=t[l]={exports:{}};return e[l].call(o.exports,o,o.exports,n),o.exports}var l={};for(var r in(()=>{var e=l;Object.defineProperty(e,"__esModule",{value:!0}),e.QWPage=void 0;const t=n(865);Object.defineProperty(e,"QWPage",{enumerable:!0,get:function(){return t.QWPage}})})(),l)this[r]=l[r];l.__esModule&&Object.defineProperty(this,"__esModule",{value:!0})})();