blob: 75f208586989d5d11e081f476313d57e6432973c [file] [log] [blame]
/*
Copyright 2019-2020 The Go Authors. All rights reserved.
Use of this source code is governed by a BSD-style
license that can be found in the LICENSE file.
*/
var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.arrayIteratorImpl=function(b){var c=0;return function(){return c<b.length?{done:!1,value:b[c++]}:{done:!0}}};$jscomp.arrayIterator=function(b){return{next:$jscomp.arrayIteratorImpl(b)}};$jscomp.makeIterator=function(b){var c="undefined"!=typeof Symbol&&Symbol.iterator&&b[Symbol.iterator];return c?c.call(b):$jscomp.arrayIterator(b)};
$jscomp.checkStringArgs=function(b,c,d){if(null==b)throw new TypeError("The 'this' value for String.prototype."+d+" must not be null or undefined");if(c instanceof RegExp)throw new TypeError("First argument to String.prototype."+d+" must not be a regular expression");return b+""};$jscomp.ASSUME_ES5=!1;$jscomp.ASSUME_NO_NATIVE_MAP=!1;$jscomp.ASSUME_NO_NATIVE_SET=!1;$jscomp.SIMPLE_FROUND_POLYFILL=!1;$jscomp.ISOLATE_POLYFILLS=!1;
$jscomp.defineProperty=$jscomp.ASSUME_ES5||"function"==typeof Object.defineProperties?Object.defineProperty:function(b,c,d){if(b==Array.prototype||b==Object.prototype)return b;b[c]=d.value;return b};$jscomp.getGlobal=function(b){b=["object"==typeof globalThis&&globalThis,b,"object"==typeof window&&window,"object"==typeof self&&self,"object"==typeof global&&global];for(var c=0;c<b.length;++c){var d=b[c];if(d&&d.Math==Math)return d}throw Error("Cannot find global object");};$jscomp.global=$jscomp.getGlobal(this);
$jscomp.IS_SYMBOL_NATIVE="function"===typeof Symbol&&"symbol"===typeof Symbol("x");$jscomp.TRUST_ES6_POLYFILLS=!$jscomp.ISOLATE_POLYFILLS||$jscomp.IS_SYMBOL_NATIVE;$jscomp.polyfills={};$jscomp.propertyToPolyfillSymbol={};$jscomp.POLYFILL_PREFIX="$jscp$";var $jscomp$lookupPolyfilledValue=function(b,c){var d=$jscomp.propertyToPolyfillSymbol[c];if(null==d)return b[c];d=b[d];return void 0!==d?d:b[c]};
$jscomp.polyfill=function(b,c,d,f){c&&($jscomp.ISOLATE_POLYFILLS?$jscomp.polyfillIsolated(b,c,d,f):$jscomp.polyfillUnisolated(b,c,d,f))};$jscomp.polyfillUnisolated=function(b,c,d,f){d=$jscomp.global;b=b.split(".");for(f=0;f<b.length-1;f++){var l=b[f];if(!(l in d))return;d=d[l]}b=b[b.length-1];f=d[b];c=c(f);c!=f&&null!=c&&$jscomp.defineProperty(d,b,{configurable:!0,writable:!0,value:c})};
$jscomp.polyfillIsolated=function(b,c,d,f){var l=b.split(".");b=1===l.length;f=l[0];f=!b&&f in $jscomp.polyfills?$jscomp.polyfills:$jscomp.global;for(var n=0;n<l.length-1;n++){var g=l[n];if(!(g in f))return;f=f[g]}l=l[l.length-1];d=$jscomp.IS_SYMBOL_NATIVE&&"es6"===d?f[l]:null;c=c(d);null!=c&&(b?$jscomp.defineProperty($jscomp.polyfills,l,{configurable:!0,writable:!0,value:c}):c!==d&&($jscomp.propertyToPolyfillSymbol[l]=$jscomp.IS_SYMBOL_NATIVE?$jscomp.global.Symbol(l):$jscomp.POLYFILL_PREFIX+l,l=
$jscomp.propertyToPolyfillSymbol[l],$jscomp.defineProperty(f,l,{configurable:!0,writable:!0,value:c})))};$jscomp.polyfill("String.prototype.startsWith",function(b){return b?b:function(c,d){var f=$jscomp.checkStringArgs(this,c,"startsWith");c+="";var l=f.length,n=c.length;d=Math.max(0,Math.min(d|0,f.length));for(var g=0;g<n&&d<l;)if(f[d++]!=c[g++])return!1;return g>=n}},"es6","es3");
$jscomp.polyfill("Object.is",function(b){return b?b:function(c,d){return c===d?0!==c||1/c===1/d:c!==c&&d!==d}},"es6","es3");$jscomp.polyfill("Array.prototype.includes",function(b){return b?b:function(c,d){var f=this;f instanceof String&&(f=String(f));var l=f.length;d=d||0;for(0>d&&(d=Math.max(d+l,0));d<l;d++){var n=f[d];if(n===c||Object.is(n,c))return!0}return!1}},"es7","es3");
$jscomp.polyfill("String.prototype.includes",function(b){return b?b:function(c,d){return-1!==$jscomp.checkStringArgs(this,c,"includes").indexOf(c,d||0)}},"es6","es3");
(function(b,c){"object"===typeof exports&&"undefined"!==typeof module?module.exports=c():"function"===typeof define&&define.amd?define(c):(b=b||self,b.dialogPolyfill=c())})(this,function(){function b(a){for(;a&&a!==document.body;){var e=window.getComputedStyle(a),h=function(q,p){return!(void 0===e[q]||e[q]===p)};if(1>e.opacity||h("zIndex","auto")||h("transform","none")||h("mixBlendMode","normal")||h("filter","none")||h("perspective","none")||"isolate"===e.isolation||"fixed"===e.position||"touch"===
e.webkitOverflowScrolling)return!0;a=a.parentElement}return!1}function c(a){for(;a;){if("dialog"===a.localName)return a;a=a.parentElement}return null}function d(a){a&&a.blur&&a!==document.body&&a.blur()}function f(a){return a&&a.hasAttribute("method")?"dialog"===a.getAttribute("method").toLowerCase():!1}function l(a){this.dialog_=a;this.openAsModal_=this.replacedStyleTop_=!1;a.hasAttribute("role")||a.setAttribute("role","dialog");a.show=this.show.bind(this);a.showModal=this.showModal.bind(this);a.close=
this.close.bind(this);"returnValue"in a||(a.returnValue="");if("MutationObserver"in window)(new MutationObserver(this.maybeHideModal.bind(this))).observe(a,{attributes:!0,attributeFilter:["open"]});else{var e=!1,h=function(){e?this.downgradeModal():this.maybeHideModal();e=!1}.bind(this),q,p=function(m){m.target===a&&(e|="DOMNodeRemoved"===m.type.substr(0,14),window.clearTimeout(q),q=window.setTimeout(h,0))};["DOMAttrModified","DOMNodeRemoved","DOMNodeRemovedFromDocument"].forEach(function(m){a.addEventListener(m,
p)})}Object.defineProperty(a,"open",{set:this.setOpen.bind(this),get:a.hasAttribute.bind(a,"open")});this.backdrop_=document.createElement("div");this.backdrop_.className="backdrop";this.backdrop_.addEventListener("click",this.backdropClick_.bind(this))}var n=window.CustomEvent;n&&"object"!==typeof n||(n=function(a,e){e=e||{};var h=document.createEvent("CustomEvent");h.initCustomEvent(a,!!e.bubbles,!!e.cancelable,e.detail||null);return h},n.prototype=window.Event.prototype);l.prototype={get dialog(){return this.dialog_},
maybeHideModal:function(){this.dialog_.hasAttribute("open")&&document.body.contains(this.dialog_)||this.downgradeModal()},downgradeModal:function(){this.openAsModal_&&(this.openAsModal_=!1,this.dialog_.style.zIndex="",this.replacedStyleTop_&&(this.dialog_.style.top="",this.replacedStyleTop_=!1),this.backdrop_.parentNode&&this.backdrop_.parentNode.removeChild(this.backdrop_),g.dm.removeDialog(this))},setOpen:function(a){a?this.dialog_.hasAttribute("open")||this.dialog_.setAttribute("open",""):(this.dialog_.removeAttribute("open"),
this.maybeHideModal())},backdropClick_:function(a){if(this.dialog_.hasAttribute("tabindex"))this.dialog_.focus();else{var e=document.createElement("div");this.dialog_.insertBefore(e,this.dialog_.firstChild);e.tabIndex=-1;e.focus();this.dialog_.removeChild(e)}e=document.createEvent("MouseEvents");e.initMouseEvent(a.type,a.bubbles,a.cancelable,window,a.detail,a.screenX,a.screenY,a.clientX,a.clientY,a.ctrlKey,a.altKey,a.shiftKey,a.metaKey,a.button,a.relatedTarget);this.dialog_.dispatchEvent(e);a.stopPropagation()},
focus_:function(){var a=this.dialog_.querySelector("[autofocus]:not([disabled])");!a&&0<=this.dialog_.tabIndex&&(a=this.dialog_);a||(a=["button","input","keygen","select","textarea"].map(function(e){return e+":not([disabled])"}),a.push('[tabindex]:not([disabled]):not([tabindex=""])'),a=this.dialog_.querySelector(a.join(", ")));d(document.activeElement);a&&a.focus()},updateZIndex:function(a,e){if(a<e)throw Error("dialogZ should never be < backdropZ");this.dialog_.style.zIndex=a;this.backdrop_.style.zIndex=
e},show:function(){this.dialog_.open||(this.setOpen(!0),this.focus_())},showModal:function(){if(this.dialog_.hasAttribute("open"))throw Error("Failed to execute 'showModal' on dialog: The element is already open, and therefore cannot be opened modally.");if(!document.body.contains(this.dialog_))throw Error("Failed to execute 'showModal' on dialog: The element is not in a Document.");if(!g.dm.pushDialog(this))throw Error("Failed to execute 'showModal' on dialog: There are too many open modal dialogs.");
b(this.dialog_.parentElement)&&console.warn("A dialog is being shown inside a stacking context. This may cause it to be unusable. For more information, see this link: https://github.com/GoogleChrome/dialog-polyfill/#stacking-context");this.setOpen(!0);this.openAsModal_=!0;g.needsCentering(this.dialog_)?(g.reposition(this.dialog_),this.replacedStyleTop_=!0):this.replacedStyleTop_=!1;this.dialog_.parentNode.insertBefore(this.backdrop_,this.dialog_.nextSibling);this.focus_()},close:function(a){if(!this.dialog_.hasAttribute("open"))throw Error("Failed to execute 'close' on dialog: The element does not have an 'open' attribute, and therefore cannot be closed.");
this.setOpen(!1);void 0!==a&&(this.dialog_.returnValue=a);a=new n("close",{bubbles:!1,cancelable:!1});if(this.dialog_.onclose instanceof Function)this.dialog_.onclose(a);this.dialog_.dispatchEvent(a)}};var g={reposition:function(a){var e=document.body.scrollTop||document.documentElement.scrollTop;a.style.top=Math.max(e,e+(window.innerHeight-a.offsetHeight)/2)+"px"},isInlinePositionSetByStylesheet:function(a){for(var e=0;e<document.styleSheets.length;++e){var h=document.styleSheets[e],q=null;try{q=
h.cssRules}catch(w){}if(q)for(h=0;h<q.length;++h){var p=q[h],m=null;try{m=document.querySelectorAll(p.selectorText)}catch(w){}var t;if(!(t=!m)){a:{for(t=0;t<m.length;++t)if(m[t]===a){m=!0;break a}m=!1}t=!m}if(!t&&(m=p.style.getPropertyValue("top"),p=p.style.getPropertyValue("bottom"),m&&"auto"!==m||p&&"auto"!==p))return!0}}return!1},needsCentering:function(a){return"absolute"!==window.getComputedStyle(a).position||"auto"!==a.style.top&&""!==a.style.top||"auto"!==a.style.bottom&&""!==a.style.bottom?
!1:!g.isInlinePositionSetByStylesheet(a)},forceRegisterDialog:function(a){(window.HTMLDialogElement||a.showModal)&&console.warn("This browser already supports <dialog>, the polyfill may not work correctly",a);if("dialog"!==a.localName)throw Error("Failed to register dialog: The element is not a dialog.");new l(a)},registerDialog:function(a){a.showModal||g.forceRegisterDialog(a)},DialogManager:function(){this.pendingDialogStack=[];var a=this.checkDOM_.bind(this);this.overlay=document.createElement("div");
this.overlay.className="_dialog_overlay";this.overlay.addEventListener("click",function(e){this.forwardTab_=void 0;e.stopPropagation();a([])}.bind(this));this.handleKey_=this.handleKey_.bind(this);this.handleFocus_=this.handleFocus_.bind(this);this.zIndexLow_=1E5;this.zIndexHigh_=100150;this.forwardTab_=void 0;"MutationObserver"in window&&(this.mo_=new MutationObserver(function(e){var h=[];e.forEach(function(q){for(var p=0,m;m=q.removedNodes[p];++p)m instanceof Element&&("dialog"===m.localName&&h.push(m),
h=h.concat(m.querySelectorAll("dialog")))});h.length&&a(h)}))}};g.DialogManager.prototype.blockDocument=function(){document.documentElement.addEventListener("focus",this.handleFocus_,!0);document.addEventListener("keydown",this.handleKey_);this.mo_&&this.mo_.observe(document,{childList:!0,subtree:!0})};g.DialogManager.prototype.unblockDocument=function(){document.documentElement.removeEventListener("focus",this.handleFocus_,!0);document.removeEventListener("keydown",this.handleKey_);this.mo_&&this.mo_.disconnect()};
g.DialogManager.prototype.updateStacking=function(){for(var a=this.zIndexHigh_,e=0,h;h=this.pendingDialogStack[e];++e)h.updateZIndex(--a,--a),0===e&&(this.overlay.style.zIndex=--a);(a=this.pendingDialogStack[0])?(a.dialog.parentNode||document.body).appendChild(this.overlay):this.overlay.parentNode&&this.overlay.parentNode.removeChild(this.overlay)};g.DialogManager.prototype.containedByTopDialog_=function(a){for(;a=c(a);){for(var e=0,h;h=this.pendingDialogStack[e];++e)if(h.dialog===a)return 0===e;
a=a.parentElement}return!1};g.DialogManager.prototype.handleFocus_=function(a){if(!this.containedByTopDialog_(a.target)&&document.activeElement!==document.documentElement&&(a.preventDefault(),a.stopPropagation(),d(a.target),void 0!==this.forwardTab_)){var e=this.pendingDialogStack[0];e.dialog.compareDocumentPosition(a.target)&Node.DOCUMENT_POSITION_PRECEDING&&(this.forwardTab_?e.focus_():a.target!==document.documentElement&&document.documentElement.focus());return!1}};g.DialogManager.prototype.handleKey_=
function(a){this.forwardTab_=void 0;if(27===a.keyCode){a.preventDefault();a.stopPropagation();a=new n("cancel",{bubbles:!1,cancelable:!0});var e=this.pendingDialogStack[0];e&&e.dialog.dispatchEvent(a)&&e.dialog.close()}else 9===a.keyCode&&(this.forwardTab_=!a.shiftKey)};g.DialogManager.prototype.checkDOM_=function(a){this.pendingDialogStack.slice().forEach(function(e){-1!==a.indexOf(e.dialog)?e.downgradeModal():e.maybeHideModal()})};g.DialogManager.prototype.pushDialog=function(a){if(this.pendingDialogStack.length>=
(this.zIndexHigh_-this.zIndexLow_)/2-1)return!1;1===this.pendingDialogStack.unshift(a)&&this.blockDocument();this.updateStacking();return!0};g.DialogManager.prototype.removeDialog=function(a){a=this.pendingDialogStack.indexOf(a);-1!==a&&(this.pendingDialogStack.splice(a,1),0===this.pendingDialogStack.length&&this.unblockDocument(),this.updateStacking())};g.dm=new g.DialogManager;g.formSubmitter=null;g.useValue=null;if(void 0===window.HTMLDialogElement){var k=document.createElement("form");k.setAttribute("method",
"dialog");if("dialog"!==k.method&&(k=Object.getOwnPropertyDescriptor(HTMLFormElement.prototype,"method"))){var r=k.get;k.get=function(){return f(this)?"dialog":r.call(this)};var u=k.set;k.set=function(a){return"string"===typeof a&&"dialog"===a.toLowerCase()?this.setAttribute("method",a):u.call(this,a)};Object.defineProperty(HTMLFormElement.prototype,"method",k)}document.addEventListener("click",function(a){g.formSubmitter=null;g.useValue=null;if(!a.defaultPrevented){var e=a.target;if(e&&f(e.form)){if(!("submit"===
e.type&&-1<["button","input"].indexOf(e.localName))){if("input"!==e.localName||"image"!==e.type)return;g.useValue=a.offsetX+","+a.offsetY}c(e)&&(g.formSubmitter=e)}}},!1);var v=HTMLFormElement.prototype.submit;HTMLFormElement.prototype.submit=function(){if(!f(this))return v.call(this);var a=c(this);a&&a.close()};document.addEventListener("submit",function(a){if(!a.defaultPrevented){var e=a.target;if(f(e)&&(a.preventDefault(),a=c(e))){var h=g.formSubmitter;h&&h.form===e?a.close(g.useValue||h.value):
a.close();g.formSubmitter=null}}},!1)}return g});var jumpDialog=document.querySelector(".JumpDialog"),jumpBody=jumpDialog.querySelector(".JumpDialog-body"),jumpList=jumpDialog.querySelector(".JumpDialog-list"),jumpFilter=jumpDialog.querySelector(".JumpDialog-input"),searchInput=document.querySelector(".js-searchFocus"),doc=document.querySelector(".js-documentation");jumpDialog.showModal||dialogPolyfill.registerDialog(jumpDialog);var jumpListItems;
function collectJumpListItems(){for(var b=[],c=$jscomp.makeIterator(doc.querySelectorAll("[data-kind]")),d=c.next();!d.done;d=c.next())b.push(newJumpListItem(d.value));c=$jscomp.makeIterator(b);for(d=c.next();!d.done;d=c.next())d.value.link.addEventListener("click",function(){jumpDialog.close()});b.sort(function(f,l){return f.lower.localeCompare(l.lower)});return b}
function newJumpListItem(b){var c=document.createElement("a"),d=b.getAttribute("id");c.setAttribute("href","#"+d);c.setAttribute("tabindex","-1");b=b.getAttribute("data-kind");return{link:c,name:d,kind:b,lower:d.toLowerCase()}}var lastFilterValue,activeJumpItem=-1;
function updateJumpList(b){lastFilterValue=b;jumpListItems||(jumpListItems=collectJumpListItems());for(setActiveJumpItem(-1);jumpList.firstChild;)jumpList.firstChild.remove();if(b){for(var c=b.toLowerCase(),d=[],f=[],l=[],n=function(u,v,a){return u.name.substring(0,v)+"<b>"+u.name.substring(v,a)+"</b>"+u.name.substring(a)},g=$jscomp.makeIterator(jumpListItems),k=g.next();!k.done;k=g.next()){k=k.value;var r=k.name.toLowerCase();r===c?(k.link.innerHTML=n(k,0,k.name.length),d.push(k)):r.startsWith(c)?
(k.link.innerHTML=n(k,0,b.length),f.push(k)):(r=r.indexOf(c),-1<r&&(k.link.innerHTML=n(k,r,r+b.length),l.push(k)))}b=$jscomp.makeIterator(d.concat(f).concat(l));for(k=b.next();!k.done;k=b.next())jumpList.appendChild(k.value.link)}else for(b=$jscomp.makeIterator(jumpListItems),k=b.next();!k.done;k=b.next())c=k.value,c.link.innerHTML=c.name+" <i>"+c.kind+"</i>",jumpList.appendChild(c.link);jumpBody.scrollTop=0;0<jumpList.children.length&&setActiveJumpItem(0)}
function setActiveJumpItem(b){var c=jumpList.children;0<=activeJumpItem&&c[activeJumpItem].classList.remove("JumpDialog-active");b>=c.length&&(b=c.length-1);if(0<=b){c[b].classList.add("JumpDialog-active");var d=c[b].offsetTop-c[0].offsetTop;c=d+c[b].clientHeight;d<jumpBody.scrollTop?jumpBody.scrollTop=d:c>jumpBody.scrollTop+jumpBody.clientHeight&&(jumpBody.scrollTop=c-jumpBody.clientHeight)}activeJumpItem=b}
function incActiveJumpItem(b){0>activeJumpItem||(b=activeJumpItem+b,0>b&&(b=0),setActiveJumpItem(b))}jumpFilter.addEventListener("keyup",function(b){jumpFilter.value.toUpperCase()!=lastFilterValue.toUpperCase()&&updateJumpList(jumpFilter.value)});jumpFilter.addEventListener("keydown",function(b){switch(b.which){case 38:incActiveJumpItem(-1);b.preventDefault();break;case 40:incActiveJumpItem(1);b.preventDefault();break;case 13:0<=activeJumpItem&&jumpList.children[activeJumpItem].click()}});
var shortcutsDialog=document.querySelector(".ShortcutsDialog");shortcutsDialog.showModal||dialogPolyfill.registerDialog(shortcutsDialog);
document.addEventListener("keypress",function(b){if(!jumpDialog.open&&!shortcutsDialog.open&&doc){var c=b.target.tagName;if("INPUT"!=c&&"SELECT"!=c&&"TEXTAREA"!=c&&!(b.target.contentEditable&&"true"==b.target.contentEditable||b.metaKey||b.ctrlKey))switch(String.fromCharCode(b.which)){case "f":case "F":b.preventDefault();jumpFilter.value="";jumpDialog.showModal();updateJumpList("");break;case "?":shortcutsDialog.showModal();break;case "/":searchInput&&!window.navigator.userAgent.includes("Firefox")&&
(b.preventDefault(),searchInput.focus())}}});var jumpOutlineInput=document.querySelector(".js-jumpToInput");jumpOutlineInput&&jumpOutlineInput.addEventListener("click",function(){jumpFilter.value="";jumpDialog.showModal();updateJumpList("")});