blob: b425d1455fa57b04668edde964a7227693c3271a [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.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,e){if(b==Array.prototype||b==Object.prototype)return b;b[c]=e.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 e=b[c];if(e&&e.Math==Math)return e}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 e=$jscomp.propertyToPolyfillSymbol[c];if(null==e)return b[c];e=b[e];return void 0!==e?e:b[c]};$jscomp.polyfill=function(b,c,e,f){c&&($jscomp.ISOLATE_POLYFILLS?$jscomp.polyfillIsolated(b,c,e,f):$jscomp.polyfillUnisolated(b,c,e,f))};
$jscomp.polyfillUnisolated=function(b,c,e,f){e=$jscomp.global;b=b.split(".");for(f=0;f<b.length-1;f++){var g=b[f];if(!(g in e))return;e=e[g]}b=b[b.length-1];f=e[b];c=c(f);c!=f&&null!=c&&$jscomp.defineProperty(e,b,{configurable:!0,writable:!0,value:c})};
$jscomp.polyfillIsolated=function(b,c,e,f){var g=b.split(".");b=1===g.length;f=g[0];f=!b&&f in $jscomp.polyfills?$jscomp.polyfills:$jscomp.global;for(var m=0;m<g.length-1;m++){var k=g[m];if(!(k in f))return;f=f[k]}g=g[g.length-1];e=$jscomp.IS_SYMBOL_NATIVE&&"es6"===e?f[g]:null;c=c(e);null!=c&&(b?$jscomp.defineProperty($jscomp.polyfills,g,{configurable:!0,writable:!0,value:c}):c!==e&&($jscomp.propertyToPolyfillSymbol[g]=$jscomp.IS_SYMBOL_NATIVE?$jscomp.global.Symbol(g):$jscomp.POLYFILL_PREFIX+g,g=
$jscomp.propertyToPolyfillSymbol[g],$jscomp.defineProperty(f,g,{configurable:!0,writable:!0,value:c})))};$jscomp.polyfill("Object.is",function(b){return b?b:function(c,e){return c===e?0!==c||1/c===1/e:c!==c&&e!==e}},"es6","es3");$jscomp.polyfill("Array.prototype.includes",function(b){return b?b:function(c,e){var f=this;f instanceof String&&(f=String(f));var g=f.length;e=e||0;for(0>e&&(e=Math.max(e+g,0));e<g;e++){var m=f[e];if(m===c||Object.is(m,c))return!0}return!1}},"es7","es3");
$jscomp.checkStringArgs=function(b,c,e){if(null==b)throw new TypeError("The 'this' value for String.prototype."+e+" must not be null or undefined");if(c instanceof RegExp)throw new TypeError("First argument to String.prototype."+e+" must not be a regular expression");return b+""};$jscomp.polyfill("String.prototype.includes",function(b){return b?b:function(c,e){return-1!==$jscomp.checkStringArgs(this,c,"includes").indexOf(c,e||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 d=window.getComputedStyle(a),h=function(p,n){return!(void 0===d[p]||d[p]===n)};if(1>d.opacity||h("zIndex","auto")||h("transform","none")||h("mixBlendMode","normal")||h("filter","none")||h("perspective","none")||"isolate"===d.isolation||"fixed"===d.position||"touch"===
d.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 e(a){a&&a.blur&&a!==document.body&&a.blur()}function f(a){return a&&a.hasAttribute("method")?"dialog"===a.getAttribute("method").toLowerCase():!1}function g(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 d=!1,h=function(){d?this.downgradeModal():this.maybeHideModal();d=!1}.bind(this),p,n=function(l){l.target===a&&(d|="DOMNodeRemoved"===l.type.substr(0,14),window.clearTimeout(p),p=window.setTimeout(h,0))};["DOMAttrModified","DOMNodeRemoved","DOMNodeRemovedFromDocument"].forEach(function(l){a.addEventListener(l,
n)})}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 m=window.CustomEvent;m&&"object"!==typeof m||(m=function(a,d){d=d||{};var h=document.createEvent("CustomEvent");h.initCustomEvent(a,!!d.bubbles,!!d.cancelable,d.detail||null);return h},m.prototype=window.Event.prototype);g.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_),k.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 d=document.createElement("div");this.dialog_.insertBefore(d,this.dialog_.firstChild);d.tabIndex=-1;d.focus();this.dialog_.removeChild(d)}d=document.createEvent("MouseEvents");d.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(d);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(d){return d+":not([disabled])"}),a.push('[tabindex]:not([disabled]):not([tabindex=""])'),a=this.dialog_.querySelector(a.join(", ")));e(document.activeElement);a&&a.focus()},updateZIndex:function(a,d){if(a<d)throw Error("dialogZ should never be < backdropZ");this.dialog_.style.zIndex=a;this.backdrop_.style.zIndex=
d},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(!k.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;k.needsCentering(this.dialog_)?(k.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 m("close",{bubbles:!1,cancelable:!1});if(this.dialog_.onclose instanceof Function)this.dialog_.onclose(a);this.dialog_.dispatchEvent(a)}};var k={reposition:function(a){var d=document.body.scrollTop||document.documentElement.scrollTop;a.style.top=Math.max(d,d+(window.innerHeight-a.offsetHeight)/2)+"px"},isInlinePositionSetByStylesheet:function(a){for(var d=0;d<document.styleSheets.length;++d){var h=document.styleSheets[d],p=null;try{p=
h.cssRules}catch(t){}if(p)for(h=0;h<p.length;++h){var n=p[h],l=null;try{l=document.querySelectorAll(n.selectorText)}catch(t){}var r;if(!(r=!l)){a:{for(r=0;r<l.length;++r)if(l[r]===a){l=!0;break a}l=!1}r=!l}if(!r&&(l=n.style.getPropertyValue("top"),n=n.style.getPropertyValue("bottom"),l&&"auto"!==l||n&&"auto"!==n))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:!k.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 g(a)},registerDialog:function(a){a.showModal||k.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(d){this.forwardTab_=void 0;d.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(d){var h=[];d.forEach(function(p){for(var n=0,l;l=p.removedNodes[n];++n)l instanceof Element&&("dialog"===l.localName&&h.push(l),
h=h.concat(l.querySelectorAll("dialog")))});h.length&&a(h)}))}};k.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})};k.DialogManager.prototype.unblockDocument=function(){document.documentElement.removeEventListener("focus",this.handleFocus_,!0);document.removeEventListener("keydown",this.handleKey_);this.mo_&&this.mo_.disconnect()};
k.DialogManager.prototype.updateStacking=function(){for(var a=this.zIndexHigh_,d=0,h;h=this.pendingDialogStack[d];++d)h.updateZIndex(--a,--a),0===d&&(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)};k.DialogManager.prototype.containedByTopDialog_=function(a){for(;a=c(a);){for(var d=0,h;h=this.pendingDialogStack[d];++d)if(h.dialog===a)return 0===d;
a=a.parentElement}return!1};k.DialogManager.prototype.handleFocus_=function(a){if(!this.containedByTopDialog_(a.target)&&document.activeElement!==document.documentElement&&(a.preventDefault(),a.stopPropagation(),e(a.target),void 0!==this.forwardTab_)){var d=this.pendingDialogStack[0];d.dialog.compareDocumentPosition(a.target)&Node.DOCUMENT_POSITION_PRECEDING&&(this.forwardTab_?d.focus_():a.target!==document.documentElement&&document.documentElement.focus());return!1}};k.DialogManager.prototype.handleKey_=
function(a){this.forwardTab_=void 0;if(27===a.keyCode){a.preventDefault();a.stopPropagation();a=new m("cancel",{bubbles:!1,cancelable:!0});var d=this.pendingDialogStack[0];d&&d.dialog.dispatchEvent(a)&&d.dialog.close()}else 9===a.keyCode&&(this.forwardTab_=!a.shiftKey)};k.DialogManager.prototype.checkDOM_=function(a){this.pendingDialogStack.slice().forEach(function(d){-1!==a.indexOf(d.dialog)?d.downgradeModal():d.maybeHideModal()})};k.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};k.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())};k.dm=new k.DialogManager;k.formSubmitter=null;k.useValue=null;if(void 0===window.HTMLDialogElement){var q=document.createElement("form");q.setAttribute("method",
"dialog");if("dialog"!==q.method&&(q=Object.getOwnPropertyDescriptor(HTMLFormElement.prototype,"method"))){var u=q.get;q.get=function(){return f(this)?"dialog":u.call(this)};var v=q.set;q.set=function(a){return"string"===typeof a&&"dialog"===a.toLowerCase()?this.setAttribute("method",a):v.call(this,a)};Object.defineProperty(HTMLFormElement.prototype,"method",q)}document.addEventListener("click",function(a){k.formSubmitter=null;k.useValue=null;if(!a.defaultPrevented){var d=a.target;if(d&&f(d.form)){if(!("submit"===
d.type&&-1<["button","input"].indexOf(d.localName))){if("input"!==d.localName||"image"!==d.type)return;k.useValue=a.offsetX+","+a.offsetY}c(d)&&(k.formSubmitter=d)}}},!1);var w=HTMLFormElement.prototype.submit;HTMLFormElement.prototype.submit=function(){if(!f(this))return w.call(this);var a=c(this);a&&a.close()};document.addEventListener("submit",function(a){if(!a.defaultPrevented){var d=a.target;if(f(d)&&(a.preventDefault(),a=c(d))){var h=k.formSubmitter;h&&h.form===d?a.close(k.useValue||h.value):
a.close();k.formSubmitter=null}}},!1)}return k});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"),docIndex=document.querySelector(".js-docIndex");jumpDialog.showModal||dialogPolyfill.registerDialog(jumpDialog);var jumpListItems;
function collectJumpListItems(){for(var b=[],c=$jscomp.makeIterator(doc.querySelectorAll("[data-kind]")),e=c.next();!e.done;e=c.next())b.push(newJumpListItem(e.value));0==b.length&&(b=collectJumpListItemsFallback(doc));c=$jscomp.makeIterator(b);for(e=c.next();!e.done;e=c.next())e.value.link.addEventListener("click",function(){jumpDialog.close()});b.sort(function(f,g){return f.lower.localeCompare(g.lower)});return b}
function collectJumpListItemsFallback(b){var c=[],e={};b=$jscomp.makeIterator(b.querySelectorAll("*[id]"));for(var f=b.next();!f.done;f=b.next()){f=f.value;var g=f.getAttribute("id");!e[g]&&/^[^_][^-]*$/.test(g)&&(e[g]=!0,c.push(newJumpListItem(f)))}return c}
function newJumpListItem(b){var c=document.createElement("a"),e=b.getAttribute("id");c.setAttribute("href","#"+e);c.setAttribute("tabindex","-1");var f=b.getAttribute("data-kind");f||(f=guessKind(b));return{link:c,name:e,kind:f,lower:e.toLowerCase()}}
function guessKind(b){switch(b.getAttribute("class")){case "Documentation-functionHeader":case "Documentation-typeFuncHeader":return"function";case "Documentation-typeHeader":return"type";case "Documentation-typeMethodHeader":return"method";default:switch(b.closest("section").getAttribute("class")){case "Documentation-variables":return"variable";case "Documentation-constants":return"constant";case "Documentation-types":return"field";default:return""}}}var lastFilterValue,activeJumpItem=-1;
function updateJumpList(b){lastFilterValue=b;jumpListItems||(jumpListItems=collectJumpListItems());for(setActiveJumpItem(-1);jumpList.firstChild;)jumpList.firstChild.remove();for(var c=new RegExp(b.replace(/([.*+?^=!:${}()|\[\]\/\\])/g,"\\$1"),"gi"),e=$jscomp.makeIterator(jumpListItems),f=e.next();!f.done;f=e.next()){f=f.value;var g=f.name;if(b&&(g=g.replace(c,function(m){return"<b>"+m+"</b>"}),g==f.name))continue;f.link.innerHTML=g+" <i>"+f.kind+"</i>";jumpList.appendChild(f.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 e=c[b].offsetTop-c[0].offsetTop;c=e+c[b].clientHeight;e<jumpBody.scrollTop?jumpBody.scrollTop=e: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="";showJumpDialogModal();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="";showJumpDialogModal();updateJumpList("")}),docIndex||jumpOutlineInput.setAttribute("disabled",!0));function showJumpDialogModal(){docIndex&&jumpDialog.showModal()};