| Current Path : /var/www/homesaver/www/bitrix/js/ui/bbcode/ast-processor/dist/ |
| Current File : /var/www/homesaver/www/bitrix/js/ui/bbcode/ast-processor/dist/ast-processor.bundle.min.js |
this.BX=this.BX||{};this.BX.UI=this.BX.UI||{};(function(e,t){"use strict";function r(e,r){if(!t.Type.isArray(e)){throw new TypeError("array is not a array")}if(!t.Type.isInteger(r)){throw new TypeError("index is not a integer")}const n=r<0?e.length+r:r;return e[n]}class n{static flattenAst(e){if(e&&e.getChildren){const t=e.getChildren();return[...t,...t.flatMap((e=>n.flattenAst(e)))]}return[]}static parseSelector(e){const t=/(\w+)\[(.*?)]|\s*(>)\s*|\w+/g;const r=[...e.matchAll(t)];return r.map((([e,t,r,n])=>{if(n){return">"}if(r){const e=/(\w+)=["'](.*?)["']/g;const n=[...r.matchAll(e)];const i=n.map((([,e,t])=>[e,t]));return{nodeName:t,props:i}}return{nodeName:e,props:[]}}))}static matchesNodeWithSelector(e,r){if(e&&e.constructor.name===r.nodeName){if(r.props.length>0){return r.props.every((([r,n])=>{const i=(()=>{const n=`${r.charAt(0).toUpperCase()}${r.slice(1)}`;if(t.Type.isFunction(e[`get${n}`])){return e[`get${n}`]()}if(t.Type.isFunction(e[`is${n}`])){return e[`is${n}`]()}return null})();if(["true","false"].includes(n)){return i===(n==="true")}return i===n}))}return true}return false}static findParentNode(e,r){if(e){const i=(()=>{if(t.Type.isStringFilled(r)){return n.parseSelector(r)[0]}return r})();const s=e.getParent();if(n.matchesNodeWithSelector(s,i)){return s}return n.findParentNode(s,i)}return null}static findParentNodeByName(e,t){if(e){const r=e.getParent();if(r&&r.getName()===t){return r}return n.findParentNodeByName(r,t)}return null}static findElements(e,i){const s=n.flattenAst(e);const o=n.parseSelector(i);const a=r(o,-1);let c=false;return o.reduceRight(((e,r)=>{if(t.Type.isPlainObject(r)){if(r===a){return e.filter((e=>n.matchesNodeWithSelector(e,r)))}if(c){c=false;return e.filter((e=>n.matchesNodeWithSelector(e.getParent(),r)))}return e.filter((e=>n.findParentNode(e,r)!==null))}if(r===">"){c=true}return e}),s)}static reduceAst(e,r){const i=e.getChildren==null?void 0:e.getChildren().reduce(((e,i)=>{const s=[n.reduceAst(i,r)].flat();if(!t.Type.isNil(s)){e.replaceChild(i,...s)}return e}),e);return r(e,i)}}e.AstProcessor=n})(this.BX.UI.BBCode=this.BX.UI.BBCode||{},BX);
//# sourceMappingURL=ast-processor.bundle.map.js