text: define("Vdom/_private/Synchronizer/resources/TabIndex",["require","exports","Vdom/_private/Utils/Functional"],function(e,t,E){"use strict";Object.defineProperty(t,"__esModule",{value:true});var u=1,y={a:true,link:true,button:true,input:true,select:true,textarea:true},f=1,c=2,d=4,b=8,m=16,g={hidden:f,disabled:c,"delegates-tabfocus":d,"creates-context":b,"tab-cycling":m};function x(e,t){return window.getComputedStyle(e)[t]}function n(e){var t=/\bws-(hidden|disabled)\b/g,n=e.getAttribute("class"),i,r,l,o,a,u,s;a=0;while(i=n&&t.exec(n))a|=g[i[1]];if("true"===e["ws-creates-context"]||"true"===e.getAttribute("ws-creates-context"))a|=g["creates-context"];if("true"===e["ws-delegates-tabfocus"]||"true"===e.getAttribute("ws-delegates-tabfocus"))a|=g["delegates-tabfocus"];if("true"===e["ws-tab-cycling"]||"true"===e.getAttribute("ws-tab-cycling"))a|=g["tab-cycling"];if(u=0===(a&(f|c)))u="none"!==x(e,"display")&&"invisible"!==x(e,"visibility");if(u)l=e.getAttribute("tabindex"),r=parseInt(l,10),s={enabled:true,tabStop:(o=!isNaN(r))&&r>=0||null===l&&y.hasOwnProperty(e.tagName.toLowerCase())||-1!==r&&e.hasAttribute("contenteditable"),createsContext:0!==(a&b),tabIndex:r||0,delegateFocusToChildren:0!==(a&d),tabCycling:0!==(a&m)};else s={enabled:false,tabStop:false,createsContext:false,tabIndex:0,delegateFocusToChildren:false,tabCycling:false};return s}function I(e){return e.firstElementChild?e.firstElementChild:null}function S(e){return e.lastElementChild?e.lastElementChild:null}function A(e){return e.previousElementSibling?e.previousElementSibling:null}function F(e){return e.nextElementSibling?e.nextElementSibling:null}function T(o,e,t,n,i){function r(e,t,n){var i;if(E.assert("number"===typeof e&&"number"===typeof t),e=0===e?1/0:e>0?e:-1,-1===(t=0===t?1/0:t>0?t:-1)&&-1!==e)return 1;if(-1===e&&-1!==t)return-1;if(e>t)i=n?-1:1;else if(e<t)i=n?1:-1;else i=0;return i}function l(e,t,n){var i,r,l;if(t.enabled&&!t.createsContext)r=n?S(e):I(e);if(!r)if(!(r=n?A(e):F(e))){l=e.parentNode;while(l!==o&&!r)if(!(r=n?A(l):F(l)))l=l.parentNode}return r||o}function a(e){return T(e,void 0,n?0:1,n,i)}function u(e){return n?S(e):I(e)}function s(e,t){if(t.delegateFocusToChildren&&e.childElementCount)if(e.wsControl&&e.wsControl.canAcceptFocus&&e.wsControl.canAcceptFocus())v=e;else v=a(e);return!!(!t.delegateFocusToChildren||y.hasOwnProperty(e.tagName.toLowerCase())||v)}E.assert(o&&(e||void 0!==t)&&i&&o!==e);var f,c,d,b,m,g,x=null,p,h=null,v,w;if(e)t=(g=i(e)).tabIndex,f=l(e,g,n);else f=(f=n?S(o):I(o))||o;var C=false;for(d=0;2!==d&&!b;d++){while(f!==o&&f!==e&&!b){if((c=i(f)).enabled&&c.tabStop)if(0===(m=r(c.tabIndex,t,n))&&0===d){if(s(f,c))b=f,w=v}else if(m>0)if(!b)if(0===d){if(null===x||r(c.tabIndex,x.tabIndex,n)<0)if(s(f,c))x=f,h=c.tabIndex,p=d,w=v}else if(null===x||r(c.tabIndex,x.tabIndex,n)<0||C&&r(c.tabIndex,x.tabIndex,n)<=0)if(s(f,c))x=f,h=c.tabIndex,p=d,w=v,C=false;if(-1===t&&x)b=x;if(!b)f=l(f,c,n)}if(f===o&&0===d)if(e&&(false===n&&t>0||true===n&&1!==t&&-1!==t))f=u(o);if(0===d)C=true}if(E.assert(!!b||f===e||f===o),!b&&x)if(h>=0)b=x;if(b&&w)b=w,E.assert(!!b);return b}function s(e,t,n){return T(e,void 0,t?0:1,t,n)}function i(l,e,t,o){function n(e){var t,n=null,i,r=e;while(r&&r!==l){if(!o(r).enabled)n=r;r=r.parentElement}if(!r)throw new Error("Узел fromElement должен лежать внутри узла rootElement");if((i=n||e)!==l){r=i.parentElement;while(r!==l&&!o(r).createsContext)r=r.parentElement;t=r}return{element:e,context:t}}function i(e,t){var n=e===document.documentElement||!!e.parentElement;if(!e||!e.ownerDocument||!n||e.nodeType!==u)throw new Error("Плохой параметр "+t)}i(e,"fromElement"),i(l,"rootElement");var r=n(e),a=r.element;if(a!==l)do{if(!(a=T(r.context,r.element,void 0,t,o)))if(o(r.context).tabCycling)break;else r=n(r.context)}while(!a&&r.element!==l);if(a===l)a=s(l,t,o);if(!a&&o(r.context||l).tabCycling)if(void 0===(a=s(r.context||l,t,o)))a=e;return a}function r(){var e=document.createElement("div");return e.innerHTML='<svg><foreignObject width="30" height="30">'+'<input type="text"/>'+"</foreignObject></svg>",e.firstChild.firstChild}function l(e){var t;if(!(e.ownerSVGElement||"svg"===e.nodeName.toLowerCase()))return false;var n=r();e.appendChild(n);var i=n.querySelector("input");return i.focus(),i.disabled=true,e.removeChild(n),true}function o(t){if(t.focus)t.focus();else try{HTMLElement.prototype.focus.call(t)}catch(e){l(t)}}t.getElementProps=n,t.findFirstInContext=s,t.findWithContexts=i,t.focus=o});