!function(g,I){"object"==typeof exports&&"undefined"!=typeof module?I(exports):"function"==typeof define&&define.amd?define(["exports"],I):I((g="undefined"!=typeof globalThis?globalThis:g||self).ranui={})}(this,(function(g){"use strict";var I=Object.defineProperty,C=(g,C,A)=>(((g,C,A)=>{C in g?I(g,C,{enumerable:!0,configurable:!0,writable:!0,value:A}):g[C]=A})(g,"symbol"!=typeof C?C+"":C,A),A);function A(g,I){for(var C=0;CA[I]})}}return Object.freeze(Object.defineProperty(g,Symbol.toStringTag,{value:"Module"}))}const i=(g,I="text/xml")=>{if(window.DOMParser)return(new window.DOMParser).parseFromString(g,I).documentElement;if(void 0!==window.ActiveXObject){const I=new window.ActiveXObject("Microsoft.XMLDOM");return I.async="false",I.loadXML(g),I}};var e=Object.defineProperty,l=(g,I,C)=>(((g,I,C)=>{I in g?e(g,I,{enumerable:!0,configurable:!0,writable:!0,value:C}):g[I]=C})(g,"symbol"!=typeof I?I+"":I,C),C);const t=()=>{},s=()=>{if("undefined"!=typeof window){const g=navigator.userAgent.toLowerCase();return/ipad|ipod/.test(g)?"ipad":/android/.test(g)?"android":/iphone/.test(g)?"iphone":"pc"}return"pc"},c="undefined"!=typeof window,d=()=>{if(!c)return!1;const g=window.navigator.userAgent;return!!/Android|webOS|iPhone|iPod|iPad|BlackBerry/i.test(g)},o=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];class n{constructor(g,I){l(this,"highOrder"),l(this,"lowOrder"),this.highOrder=g,this.lowOrder=I}}function a(g){return g<10?`0${g}`:g}function Z(g){let I=new Date;return g&&(I=new Date(g)),I.format=(g="YYYY-MM-DD HH:mm:ss")=>{const C=I.getFullYear(),A=a(I.getMonth()+1),i=a(I.getDate()),e=a(I.getHours()),l=a(I.getMinutes()),t=a(I.getSeconds());return g.replace(/Y+/gi,`${C}`).replace(/M+/g,`${A}`).replace(/D+/gi,`${i}`).replace(/H+/gi,`${e}`).replace(/m+/g,`${l}`).replace(/S+/gi,`${t}`)},I}new n(o[0],3609767458),new n(o[1],602891725),new n(o[2],3964484399),new n(o[3],2173295548),new n(o[4],4081628472),new n(o[5],3053834265),new n(o[6],2937671579),new n(o[7],3664609560),new n(o[8],2734883394),new n(o[9],1164996542),new n(o[10],1323610764),new n(o[11],3590304994),new n(o[12],4068182383),new n(o[13],991336113),new n(o[14],633803317),new n(o[15],3479774868),new n(o[16],2666613458),new n(o[17],944711139),new n(o[18],2341262773),new n(o[19],2007800933),new n(o[20],1495990901),new n(o[21],1856431235),new n(o[22],3175218132),new n(o[23],2198950837),new n(o[24],3999719339),new n(o[25],766784016),new n(o[26],2566594879),new n(o[27],3203337956),new n(o[28],1034457026),new n(o[29],2466948901),new n(o[30],3758326383),new n(o[31],168717936),new n(o[32],1188179964),new n(o[33],1546045734),new n(o[34],1522805485),new n(o[35],2643833823),new n(o[36],2343527390),new n(o[37],1014477480),new n(o[38],1206759142),new n(o[39],344077627),new n(o[40],1290863460),new n(o[41],3158454273),new n(o[42],3505952657),new n(o[43],106217008),new n(o[44],3606008344),new n(o[45],1432725776),new n(o[46],1467031594),new n(o[47],851169720),new n(o[48],3100823752),new n(o[49],1363258195),new n(o[50],3750685593),new n(o[51],3785050280),new n(o[52],3318307427),new n(o[53],3812723403),new n(o[54],2003034995),new n(o[55],3602036899),new n(o[56],1575990012),new n(o[57],1125592928),new n(o[58],2716904306),new n(o[59],442776044),new n(o[60],593698344),new n(o[61],3733110249),new n(o[62],2999351573),new n(o[63],3815920427),new n(3391569614,3928383900),new n(3515267271,566280711),new n(3940187606,3454069534),new n(4118630271,4000239992),new n(116418474,1914138554),new n(174292421,2731055270),new n(289380356,3203993006),new n(460393269,320620315),new n(685471733,587496836),new n(852142971,1086792851),new n(1017036298,365543100),new n(1126000580,2618297676),new n(1288033470,3409855158),new n(1501505948,4234509866),new n(1607167915,987167468),new n(1816402316,1246189591),new n(0,1),new n(0,32898),new n(2147483648,32906),new n(2147483648,2147516416),new n(0,32907),new n(0,2147483649),new n(2147483648,2147516545),new n(2147483648,32777),new n(0,138),new n(0,136),new n(0,2147516425),new n(0,2147483658),new n(0,2147516555),new n(2147483648,139),new n(2147483648,32905),new n(2147483648,32771),new n(2147483648,32770),new n(2147483648,128),new n(0,32778),new n(2147483648,2147483658),new n(2147483648,2147516545),new n(2147483648,32896),new n(0,2147483649),new n(2147483648,2147516424);const b=g=>{if(0===g)return"00:00";if(!g)return"";const I=Math.trunc(g/3600),C=Math.trunc(g%3600/60),A=a(Math.trunc(g-3600*I-60*C));return 0===I?`${a(C)}:${A}`:`${a(I)}:${a(C)}:${A}`},r=g=>{const I=g.backingStorePixelRatio||g.webkitBackingStorePixelRatio||g.mozBackingStorePixelRatio||g.msBackingStorePixelRatio||g.oBackingStorePixelRatio||1;return(c&&window.devicePixelRatio||1)/I},m=(g,I)=>{if("undefined"==typeof document)return;const C=g.classList;C.contains(I)||C.add(I)},h=(g,I)=>{if("undefined"==typeof document)return;const C=g.classList;C.contains(I)&&C.remove(I)},G=g=>{if("undefined"==typeof document)return;const I=document.createDocumentFragment();return g.forEach((g=>I.appendChild(g))),I},u=()=>{let g;return function(I,C=300){return function(...A){g&&(clearTimeout(g),g=void 0);const i=this;g||(g=setTimeout((()=>{I.apply(i,A),clearTimeout(g),g=void 0}),C))}}},B=new Map([[100,"Continue"],[101,"Switching Protocols"],[102,"Processing"],[103,"Early Hints"],[200,"OK"],[201,"Created"],[202,"Accepted"],[203,"Non-Authoritative Information"],[204,"No Content"],[205,"Reset Content"],[206,"Partial Content"],[207,"Multi-Status"],[208,"Already Reported"],[226,"IM Used"],[300,"Multiple Choices"],[301,"Moved Permanently"],[302,"Found"],[303,"See Other"],[304,"Not Modified"],[305,"Use Proxy"],[307,"Temporary Redirect"],[308,"Permanent Redirect"],[400,"Bad Request"],[401,"Unauthorized"],[402,"Payment Required"],[403,"Forbidden"],[404,"Not Found"],[405,"Method Not Allowed"],[406,"Not Acceptable"],[407,"Proxy Authentication Required"],[408,"Request Timeout"],[409,"Conflict"],[410,"Gone"],[411,"Length Required"],[412,"Precondition Failed"],[413,"Payload Too Large"],[414,"URI Too Long"],[415,"Unsupported Media Type"],[416,"Range Not Satisfiable"],[417,"Expectation Failed"],[418,"I'm a Teapot"],[421,"Misdirected Request"],[422,"Unprocessable Entity"],[423,"Locked"],[424,"Failed Dependency"],[425,"Too Early"],[426,"Upgrade Required"],[428,"Precondition Required"],[429,"Too Many Requests"],[431,"Request Header Fields Too Large"],[451,"Unavailable For Legal Reasons"],[500,"Internal Server Error"],[501,"Not Implemented"],[502,"Bad Gateway"],[503,"Service Unavailable"],[504,"Gateway Timeout"],[505,"HTTP Version Not Supported"],[506,"Variant Also Negotiates"],[507,"Insufficient Storage"],[508,"Loop Detected"],[509,"Bandwidth Limit Exceeded"],[510,"Not Extended"],[511,"Network Authentication Required"]]);(function(g){const I=new Map;for(const[C,A]of g)I.set(A.toLowerCase(),C)})(B),function(g){const I=[];for(const[C,A]of g)I.push(C)}(B);const w=(g="")=>{if(0===g.length)return 0;if(g.endsWith("%")){const I=Number(g.replace("%",""));return I>1?I/100:I}return Number(g)},W=(g,I=0,C=1)=>Math.min(C,Math.max(I,g)),p=class{constructor(){l(this,"getDecimalLength",(g=>{const[I,C]=g.toString().split(".");return C?C.length:0})),l(this,"amend",((g,I=15)=>parseFloat(Number(g).toPrecision(I)))),l(this,"power",((g,I)=>Math.pow(10,Math.max(this.getDecimalLength(g),this.getDecimalLength(I)))))}};l(p,"handleMethod",((g,I)=>{const C=new p,{power:A,amend:i}=C,e=A(g,I),l=i(g*e),t=i(I*e);return g=>{switch(g){case"+":return(l+t)/e;case"-":return(l-t)/e;case"*":return l*t/(e*e);case"/":return l/t}}})),l(p,"add",((g,I)=>p.handleMethod(g,I)("+"))),l(p,"divide",((g,I)=>p.handleMethod(g,I)("/"))),l(p,"multiply",((g,I)=>p.handleMethod(g,I)("*"))),l(p,"subtract",((g,I)=>p.handleMethod(g,I)("-")));const V="NEW_LISTENER";class y{constructor(){l(this,"_events"),l(this,"tap",((g,I)=>{this._events[g]&&g!==Symbol.for(V)&&this.call(Symbol.for(V),g);const C=this._events[g]||[];"function"==typeof I?C.push({name:g,callback:I}):C.push(I),this._events[g]=C})),l(this,"call",((g,...I)=>{(this._events[g]||[]).forEach((g=>{const{callback:C}=g;C(...I)}))})),l(this,"callSync",(async(g,...I)=>{const C=this._events[g]||[];for(const A of C){const{callback:g}=A;await g(...I)}})),l(this,"once",((g,I)=>{let C;if("function"==typeof I)C={name:g,callback:(...A)=>{I(...A),this.off(g,C)},initialCallback:I};else{const{callback:A}=I;C={name:g,callback:(...I)=>{A(...I),this.off(g,C)},initialCallback:A}}this.tap(g,C)})),l(this,"off",((g,I)=>{const C=(this._events[g]||[]).filter((g=>{if("function"==typeof I)return g.callback!==I&&g.initialCallback!==I;{const{callback:C}=I;return g.callback!==C&&g.initialCallback!==C}}));this._events[g]=C})),this._events={}}}const X=[!1,"false",null,void 0],Y=g=>{const I=g.hasAttribute("disabled"),C=g.getAttribute("disabled");return!(!I||X.includes(C))};function R(g=""){return class{constructor(I=g){C(this,"message"),this.message=I}}}const N=()=>"undefined"!=typeof document?HTMLElement:null,H=(g,I)=>{const C={value:g,subscribers:new Set,comparator:null==I?void 0:I.equals},{subscriber:A}=I||{};A&&Array.isArray(A)&&A.forEach((g=>{"function"!=typeof g||C.subscribers.has(g)||C.subscribers.add(g)}));const i=g=>{C.value!==g&&(C.value=g,C.subscribers.forEach((I=>I(g))))};return[()=>C.value,g=>{const{comparator:I}=C;if(I instanceof Function)return!I(C.value,g)&&i(g);void 0===I?C.value!==g&&i(g):!I&&i(g)}]};let K=class extends(N()){constructor(){super(),C(this,"_btn"),C(this,"_btnContent"),C(this,"_iconElement"),C(this,"_slot"),C(this,"_shadowDom"),C(this,"debounceTimeId"),C(this,"setIcon",(()=>{if(this.icon){const{width:g,height:I}=this._slot.getBoundingClientRect(),C=Math.min(g,I);this._iconElement?this._iconElement.setAttribute("name",this.icon):(this._iconElement=document.createElement("r-icon"),this._iconElement.setAttribute("name",this.icon),this._iconElement.setAttribute("color","currentColor"),this._iconElement.setAttribute("class","icon"),this._slot.insertAdjacentElement("beforebegin",this._iconElement)),this.iconSize?this._iconElement.setAttribute("size",this.iconSize):this._iconElement.setAttribute("size",""+(C-5))}})),C(this,"mousedown",(g=>{if("pc"===s()&&(!this.disabled||"false"===this.disabled)){this.debounceMouseEvent();const{left:I,top:C}=this.getBoundingClientRect();this._btn.style.setProperty("--ran-x",g.clientX-I+"px"),this._btn.style.setProperty("--ran-y",g.clientY-C+"px")}})),C(this,"mouseup",(g=>{"pc"===s()&&(this.debounceTimeId||(this.debounceTimeId=setTimeout((()=>{this._btn.style.removeProperty("--ran-x"),this._btn.style.removeProperty("--ran-y"),this.debounceMouseEvent()}),600)))})),C(this,"debounceMouseEvent",(()=>{clearTimeout(this.debounceTimeId),this.debounceTimeId=void 0})),C(this,"handlerExternalCss",(()=>{if(this.sheet)try{const g=new CSSStyleSheet;g.insertRule(this.sheet),this._shadowDom.adoptedStyleSheets=[g]}catch(g){console.error(`Failed to parse the rule in CSSStyleSheet: ${this.sheet}`)}})),this._slot=document.createElement("slot"),this._btnContent=document.createElement("div"),this._btn=document.createElement("div"),this._btn.setAttribute("class","ran-btn"),this._btn.setAttribute("part","ran-btn"),this._btnContent.setAttribute("class","ran-btn-content"),this._btnContent.setAttribute("part","ran-btn-content"),this._btnContent.appendChild(this._slot),this._slot.setAttribute("class","slot");const g=this.attachShadow({mode:"closed"}),I=document.createElement("style");I.textContent='.remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}html.dark .r-preview-mask .r-preview-contain{background-color:#191919!important}:host{position:var(--ran-btn-position, relative);display:var(--ran-btn-display, inline-block);background-image:var(--ran-btn-background-image, none);box-shadow:var(--ran-btn-box-shadow, 0 2px #00000004);cursor:var(--ran-btn-cursor, pointer);-webkit-user-select:var(--ran-btn-user-select, none);user-select:var(--ran-btn-user-select, none);touch-action:var(--ran-btn-touch-action, manipulation);overflow:var(--ran-btn-overflow, hidden);pointer-events:var(--ran-btn-pointer-events, auto)}:host .ran-btn{position:relative;display:inline-block;background-image:none;cursor:pointer;transition:all .3s cubic-bezier(.645,.045,.355,1);-webkit-user-select:none;user-select:none;touch-action:manipulation;background:#fff}:host,:host(:active),:host(:focus){outline:0;-webkit-tap-highlight-color:transparent}:host .ran-btn,:host(:active) .ran-btn,:host(:focus) .ran-btn{outline:0}:host(:not([disabled]):hover) .ran-btn-content{border-color:var(--ran-btn-content-hover-border-color, #1890ff);color:var(--ran-btn-content-hover-color, #1890ff)}:host([type="primary"]) .ran-btn-content{background-color:var(--ran-btn-content-background-color, #1890ff);border-color:var(--ran-btn-content-border-color, #1890ff);color:var(--ran-btn-content-color, #fff)}:host([type="primary"]:not([disabled])) .ran-btn:after{background-image:var(--ran-btn-after-background-image, radial-gradient(circle, #fff 10%, transparent 10.01%))}:host([type="primary"]:not([disabled]):hover) .ran-btn-content{background-color:var(--ran-btn-content-hover-background-color, #40a9ff);color:var(--ran-btn-content-hover-color, #fff)}:host([type="warning"]) .ran-btn-content{border-color:#ff4d4f;background-color:#ff4d4f;color:#fff}:host([type="warning"]:not([disabled])) .ran-btn:after{background-image:radial-gradient(circle,#fff 10%,transparent 10.01%)}:host([type="warning"]:not([disabled]):hover) .ran-btn-content{border-color:#ff4d4f;background-color:#ff4d4f;color:#fff}:host([type="text"]) .ran-btn-content{border:none}:host([disabled]){cursor:not-allowed;pointer-events:all;opacity:.6}:host([disabled]) .ran-btn{cursor:not-allowed;pointer-events:all;opacity:.6}:host(:not([disabled]):active) .ran-btn:after{transform:translate(-50%,-50%) scale(0);opacity:.3;transition:0s}@media (min-width: 1024px){:host(:not([disabled],[effect])) .ran-btn:after{content:"";display:block;position:absolute;width:100%;height:100%;left:var(--ran-x, 0);top:var(--ran-y, 0);pointer-events:none;background-image:radial-gradient(circle,#1890ff 10%,transparent 10.01%);background-repeat:no-repeat;background-position:50%;transform:translate(-50%,-50%) scale(10);opacity:0;transition:transform .3s,opacity .8s}}:host .slot{display:block}.ran-btn-content{display:flex;justify-content:space-between;align-items:center;padding:4px 15px;border:1px solid transparent;border-radius:2px;border-color:#d9d9d9;color:#000000d9;line-height:22px;font-size:14px;font-weight:400;white-space:nowrap;text-align:center}.ran-btn-content .icon{margin-right:2px}',g.appendChild(I),this._shadowDom=g,this._btn.appendChild(this._btnContent),g.appendChild(this._btn)}static get observedAttributes(){return["disabled","icon","effect","iconSize","sheet"]}get sheet(){return this.getAttribute("sheet")||""}set sheet(g){this.setAttribute("sheet",g||"")}get disabled(){return Y(this)}set disabled(g){g&&"false"!==g?(this.setAttribute("disabled",""),this.setAttribute("aria-disabled","true")):(this.removeAttribute("disabled"),this.removeAttribute("aria-disabled"))}get iconSize(){return this.getAttribute("iconSize")||""}set iconSize(g){g&&"false"!==g?(this.setAttribute("iconSize",g),this.setIcon()):this.removeAttribute("iconSize")}get icon(){return this.getAttribute("icon")||""}set icon(g){g&&"false"!==g?(this.setAttribute("icon",g),this.setIcon()):this.removeAttribute("icon")}get effect(){return this.getAttribute("effect")||""}set effect(g){X.includes(g)||!g?this.removeAttribute("effect"):this.setAttribute("effect",g)}connectedCallback(){this._btn.addEventListener("mousedown",this.mousedown),this._btn.addEventListener("mouseup",this.mouseup),this.handlerExternalCss(),this.setIcon(),this.setAttribute("role","button"),this.setAttribute("tabindex","0")}disconnectCallback(){this._btn.removeEventListener("mousedown",this.mousedown),this._btn.removeEventListener("mouseup",this.mouseup)}attributeChangedCallback(g,I,C){"disabled"===g&&this._btnContent&&(C&&"false"!==C?this._btnContent.removeAttribute("disabled"):this._btnContent.setAttribute("disabled","")),"icon"===g&&this._btnContent&&I!==C&&this.setIcon(),"iconSize"===g&&this._btnContent&&I!==C&&this._btnContent.setAttribute("iconSize",C),"sheet"===g&&this._shadowDom&&I!==C&&this.handlerExternalCss()}};const F="undefined"==typeof document||customElements.get("r-button")?R("document is undefined or r-button is exist"):(customElements.define("r-button",K),K),M=Object.freeze(Object.defineProperty({__proto__:null,Button:K,default:F},Symbol.toStringTag,{value:"Module"})),J=(g,I,C)=>{const A=g[I];return A?"function"==typeof A?A():Promise.resolve(A):new Promise(((g,A)=>{("function"==typeof queueMicrotask?queueMicrotask:setTimeout)(A.bind(null,new Error("Unknown variable dynamic import: "+I+(I.split("/").length!==C?". Note that variables only represent file names one level deep.":""))))}))},S="http://www.w3.org/1999/xlink",f="xlink:href";const k=function(){if("undefined"!=typeof window&&!customElements.get("r-icon")){class g extends HTMLElement{constructor(){super(),C(this,"_icon"),C(this,"_div"),C(this,"loadLocal",(()=>new Promise(((g,I)=>{J(Object.assign({"../../assets/icons/add-user.svg":()=>Promise.resolve().then((()=>II)),"../../assets/icons/arrow-down.svg":()=>Promise.resolve().then((()=>CI)),"../../assets/icons/book.svg":()=>Promise.resolve().then((()=>AI)),"../../assets/icons/check-circle-fill.svg":()=>Promise.resolve().then((()=>iI)),"../../assets/icons/check-circle.svg":()=>Promise.resolve().then((()=>eI)),"../../assets/icons/close-circle-fill.svg":()=>Promise.resolve().then((()=>lI)),"../../assets/icons/close-circle.svg":()=>Promise.resolve().then((()=>tI)),"../../assets/icons/close.svg":()=>Promise.resolve().then((()=>sI)),"../../assets/icons/eye-close.svg":()=>Promise.resolve().then((()=>cI)),"../../assets/icons/eye.svg":()=>Promise.resolve().then((()=>dI)),"../../assets/icons/home.svg":()=>Promise.resolve().then((()=>oI)),"../../assets/icons/info-circle-fill.svg":()=>Promise.resolve().then((()=>nI)),"../../assets/icons/info-circle.svg":()=>Promise.resolve().then((()=>aI)),"../../assets/icons/loading.svg":()=>Promise.resolve().then((()=>ZI)),"../../assets/icons/lock.svg":()=>Promise.resolve().then((()=>bI)),"../../assets/icons/message.svg":()=>Promise.resolve().then((()=>rI)),"../../assets/icons/power-off.svg":()=>Promise.resolve().then((()=>mI)),"../../assets/icons/preview.svg":()=>Promise.resolve().then((()=>hI)),"../../assets/icons/setting.svg":()=>Promise.resolve().then((()=>GI)),"../../assets/icons/sprite.svg":()=>Promise.resolve().then((()=>BI)),"../../assets/icons/team.svg":()=>Promise.resolve().then((()=>wI)),"../../assets/icons/unlock.svg":()=>Promise.resolve().then((()=>WI)),"../../assets/icons/user.svg":()=>Promise.resolve().then((()=>pI)),"../../assets/icons/warning-circle-fill.svg":()=>Promise.resolve().then((()=>VI)),"../../assets/icons/warning-circle.svg":()=>Promise.resolve().then((()=>yI))}),`../../assets/icons/${this.name}.svg`,5).then((C=>{if(C&&C.default&&C.default._identification){const{data:I}=C.default;this._icon&&this._div.removeChild(this._icon),this._icon=i(I,"image/svg+xml"),this._icon&&(this._div.appendChild(this._icon),this.setSize(),this.setColor(),g())}else this.loadNs(),I(`\n couldn't be loaded by r-icon, message: ${this.name} icon is undefined`)})).catch((g=>{this.loadNs()}))})))),C(this,"loadNs",(()=>{this._icon&&this._div&&this._div.removeChild(this._icon),this._icon=document.createElement("svg"),this._icon.setAttribute("class","icon"),this._icon.setAttribute("viewBox","0 0 1024 1024"),this._icon.setAttribute("width","100"),this._icon.setAttribute("height","100");const g=document.createElementNS(S,"use");g.setAttributeNS(S,f,`../../assets/iconfont/icon.svg#icon-${this.name}`),this._icon.appendChild(g),this._div.appendChild(this._icon)})),C(this,"setIcon",(async()=>{this.name&&this.loadLocal()})),C(this,"setSize",(()=>{this._icon&&this.size&&(this._icon.setAttribute("width",this.size),this._icon.setAttribute("height",this.size))})),C(this,"setColor",(()=>{this._icon&&(this.color?this._icon.setAttribute("fill",this.color):this._icon.setAttribute("fill","currentColor"))})),C(this,"setSpin",(()=>{this.spin&&this.style.setProperty("animation-duration",`${this.spin}s`)})),this._div=document.createElement("div"),this._div.setAttribute("class","ran-icon"),this._div.setAttribute("part","ran-icon");const g=this.attachShadow({mode:"closed"}),I=document.createElement("style");I.textContent=".remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}html.dark .r-preview-mask .r-preview-contain{background-color:#191919!important}:host{display:inline-flex}:host([spin]){animation-name:rotate;animation-duration:1.4s;animation-timing-function:linear;animation-iteration-count:infinite}.ran-icon{display:flex;align-items:center;justify-content:center}@keyframes rotate{to{transform:rotate(360deg)}}",g.appendChild(I),g.appendChild(this._div)}static get observedAttributes(){return["name","size","color","spin"]}get name(){return this.getAttribute("name")}set name(g){g&&this.setAttribute("name",g)}get size(){return this.getAttribute("size")}set size(g){g&&this.setAttribute("size",g)}get color(){return this.getAttribute("color")}set color(g){g&&this.setAttribute("color",g)}get spin(){return this.getAttribute("spin")}set spin(g){null!=g&&this.setAttribute("spin",g)}connectedCallback(){this.setIcon()}attributeChangedCallback(g,I,C){C!==I&&("name"===g&&this.setIcon(),"size"===g&&this.setSize(),"color"===g&&this.setColor(),"spin"===g&&this.setSpin())}}customElements.define("r-icon",g)}if("undefined"!=typeof window&&!customElements.get("ra-icon")){class g extends HTMLElement{constructor(){super(),C(this,"_icon"),C(this,"_div"),C(this,"loadLocal",(()=>new Promise(((g,I)=>{J(Object.assign({"../../assets/icons/add-user.svg":()=>Promise.resolve().then((()=>II)),"../../assets/icons/arrow-down.svg":()=>Promise.resolve().then((()=>CI)),"../../assets/icons/book.svg":()=>Promise.resolve().then((()=>AI)),"../../assets/icons/check-circle-fill.svg":()=>Promise.resolve().then((()=>iI)),"../../assets/icons/check-circle.svg":()=>Promise.resolve().then((()=>eI)),"../../assets/icons/close-circle-fill.svg":()=>Promise.resolve().then((()=>lI)),"../../assets/icons/close-circle.svg":()=>Promise.resolve().then((()=>tI)),"../../assets/icons/close.svg":()=>Promise.resolve().then((()=>sI)),"../../assets/icons/eye-close.svg":()=>Promise.resolve().then((()=>cI)),"../../assets/icons/eye.svg":()=>Promise.resolve().then((()=>dI)),"../../assets/icons/home.svg":()=>Promise.resolve().then((()=>oI)),"../../assets/icons/info-circle-fill.svg":()=>Promise.resolve().then((()=>nI)),"../../assets/icons/info-circle.svg":()=>Promise.resolve().then((()=>aI)),"../../assets/icons/loading.svg":()=>Promise.resolve().then((()=>ZI)),"../../assets/icons/lock.svg":()=>Promise.resolve().then((()=>bI)),"../../assets/icons/message.svg":()=>Promise.resolve().then((()=>rI)),"../../assets/icons/power-off.svg":()=>Promise.resolve().then((()=>mI)),"../../assets/icons/preview.svg":()=>Promise.resolve().then((()=>hI)),"../../assets/icons/setting.svg":()=>Promise.resolve().then((()=>GI)),"../../assets/icons/sprite.svg":()=>Promise.resolve().then((()=>BI)),"../../assets/icons/team.svg":()=>Promise.resolve().then((()=>wI)),"../../assets/icons/unlock.svg":()=>Promise.resolve().then((()=>WI)),"../../assets/icons/user.svg":()=>Promise.resolve().then((()=>pI)),"../../assets/icons/warning-circle-fill.svg":()=>Promise.resolve().then((()=>VI)),"../../assets/icons/warning-circle.svg":()=>Promise.resolve().then((()=>yI))}),`../../assets/icons/${this.name}.svg`,5).then((C=>{if(C&&C.default&&C.default._identification){const{data:I}=C.default;this._icon&&this._div.removeChild(this._icon),this._icon=i(I,"image/svg+xml"),this._icon&&(this._div.appendChild(this._icon),this.setSize(),this.setColor(),g())}else this.loadNs(),I(`\n couldn't be loaded by r-icon, message: ${this.name} icon is undefined`)})).catch((g=>{this.loadNs()}))})))),C(this,"loadNs",(()=>{this._icon&&this._div&&this._div.removeChild(this._icon),this._icon=document.createElement("svg"),this._icon.setAttribute("class","icon"),this._icon.setAttribute("viewBox","0 0 1024 1024"),this._icon.setAttribute("width","100"),this._icon.setAttribute("height","100");const g=document.createElementNS(S,"use");g.setAttributeNS(S,f,`../../assets/iconfont/icon.svg#icon-${this.name}`),this._icon.appendChild(g),this._div.appendChild(this._icon)})),C(this,"setIcon",(async()=>{this.name&&this.loadLocal()})),C(this,"setSize",(()=>{this._icon&&this.size&&(this._icon.setAttribute("width",this.size),this._icon.setAttribute("height",this.size))})),C(this,"setColor",(()=>{this._icon&&(this.color?this._icon.setAttribute("fill",this.color):this._icon.setAttribute("fill","currentColor"))})),C(this,"setSpin",(()=>{this.spin&&this.style.setProperty("animation-duration",`${this.spin}s`)})),this._div=document.createElement("div"),this._div.setAttribute("class","ran-icon"),this._div.setAttribute("part","ran-icon")}static get observedAttributes(){return["name","size","color","spin"]}get name(){return this.getAttribute("name")}set name(g){g&&this.setAttribute("name",g)}get size(){return this.getAttribute("size")}set size(g){g&&this.setAttribute("size",g)}get color(){return this.getAttribute("color")}set color(g){g&&this.setAttribute("color",g)}get spin(){return this.getAttribute("spin")}set spin(g){null!=g&&this.setAttribute("spin",g)}connectedCallback(){this.appendChild(this._div),this.setIcon()}attributeChangedCallback(g,I,C){C!==I&&("name"===g&&this.setIcon(),"size"===g&&this.setSize(),"color"===g&&this.setColor(),"spin"===g&&this.setSpin())}}customElements.define("ra-icon",g)}}(),D=Object.freeze(Object.defineProperty({__proto__:null,default:k},Symbol.toStringTag,{value:"Module"}));const L=function(){if("undefined"!=typeof window&&!customElements.get("r-img")){class g extends HTMLElement{constructor(){super(),C(this,"_image"),C(this,"_container"),this._container=document.createElement("div"),this._container.setAttribute("class","ran-image");const g=this.attachShadow({mode:"closed"}),I=document.createElement("style");I.textContent=".remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}html.dark .r-preview-mask .r-preview-contain{background-color:#191919!important}",g.appendChild(I),g.appendChild(this._container)}static get observedAttributes(){return["fallback"]}get fallback(){return this.getAttribute("fallback")||"\n data:image/png;base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0gi/41ztHnfQG26HbGel/crVrm7tNY+/1btkOEAZ2M05r4FB7r9GbAIdxaZYrHdOsgJ/wCEQY0J74TmOKnbxxT9n3FgGGWWsVdowHtjt9Nnvf7yQM2aZU/TIAIAxrw6dOnAWtZZcoEnBpNuTuObWMEiLAx1HY0ZQJEmHJ3HNvGCBBhY6jtaMoEiJB0Z29vL6ls58vxPcO8/zfrdo5qvKO+d3Fx8Wu8zf1dW4p/cPzLly/dtv9Ts/EbcvGAHhHyfBIhZ6NSiIBTo0LNNtScABFyNiqFCBChULMNNSdAhJyNSiECRCjUbEPNCRAhZ6NSiAARCjXbUHMCRMjZqBQiQIRCzTbUnAARcjYqhQgQoVCzDTUnQIScjUohAkQo1GxDzQkQIWejUogAEQo121BzAkTI2agUIkCEQs021JwAEXI2KoUIEKFQsw01J0CEnI1KIQJEKNRsQ80JECFno1KIABEKNdtQcwJEyNmoFCJAhELNNtScABFyNiqFCBChULMNNSdAhJyNSiECRCjUbEPNCRAhZ6NSiAARCjXbUHMCRMjZqBQiQIRCzTbUnAARcjYqhQgQoVCzDTUnQIScjUohAkQo1GxDzQkQIWejUogAEQo121BzAkTI2agUIkCEQs021JwAEXI2KoUIEKFQsw01J0CEnI1KIQJEKNRsQ80JECFno1KIABEKNdtQcwJEyNmoFCJAhELNNtScABFyNiqFCBChULMNNSdAhJyNSiECRCjUbEPNCRAhZ6NSiAARCjXbUHMCRMjZqBQiQIRCzTbUnAARcjYqhQgQoVCzDTUnQIScjUohAkQo1GxDzQkQIWejUogAEQo121BzAkTI2agUIkCEQs021JwAEXI2KoUIEKFQsw01J0CEnI1KIQJEKNRsQ80JECFno1KIABEKNdtQcwJEyNmoFCJAhELNNtScABFyNiqFCBChULMNNSdAhJyNSiEC/wGgKKC4YMA4TAAAAABJRU5ErkJggg==\n"}set fallback(g){g?this.setAttribute("fallback",g):this.removeAttribute("fallback")}listenFallback(g,I){"fallback"===g&&this._image&&(I?this._image.setAttribute("fallback",I):this._image.removeAttribute("fallback"))}connectedCallback(){const g=this.getAttribute("src")||"";this._image=new Image,this._image.src=g,this._image.addEventListener("error",(()=>{this._image&&this.fallback&&(this._image.src=this.fallback)})),this._image.addEventListener("load",(()=>{this._image&&this._container.appendChild(this._image)}))}attributeChangedCallback(g,I,C){this.listenFallback(g,C)}}customElements.define("r-img",g)}}(),z=Object.freeze(Object.defineProperty({__proto__:null,default:L},Symbol.toStringTag,{value:"Module"}));let v=class extends(N()){constructor(){super(),C(this,"_input"),C(this,"_label"),C(this,"_inputContent"),C(this,"_icon"),C(this,"customInput",(g=>{g.stopPropagation(),g.preventDefault();const{target:I,data:C=""}=g;this.value=(null==I?void 0:I.value)||C||"",this.customChange(),this.dispatchEvent(new CustomEvent("input",{detail:{value:this.value}}))})),C(this,"customChange",(()=>{this.dispatchEvent(new CustomEvent("change",{detail:{value:this.value}}))})),C(this,"listenPlaceholder",((g,I)=>{"placeholder"===g&&this._inputContent&&(null!=I?this._inputContent.setAttribute("placeholder",I):this._inputContent.removeAttribute("placeholder"))})),C(this,"listenLabel",((g,I)=>{"label"===g&&this._inputContent&&(null!=I?this._label?this._label.innerHTML=I:(this._label=document.createElement("label"),this._label.innerHTML=I,this._label.setAttribute("class","ran-input-label"),this._label.setAttribute("part","ran-input-label"),this._input.appendChild(this._label)):(this._input.removeAttribute("label"),this._label&&(this._input.removeChild(this._label),this._label=void 0)))})),C(this,"listenType",((g,I)=>{"type"===g&&this._inputContent&&(I?this._inputContent.setAttribute("type",I):(this._inputContent.removeAttribute("type"),this._inputContent.removeAttribute("min"),this._inputContent.removeAttribute("max"),this._inputContent.removeAttribute("step")))})),C(this,"listenStatus",((g,I)=>{"status"===g&&this._input&&(I?this._input.setAttribute("status",I):this._input.removeAttribute("status"))})),C(this,"listenDisabled",((g,I)=>{"disabled"===g&&this._input&&(X.includes(I)?this._input.removeAttribute("disabled"):(this._input.setAttribute("disabled",""),this._inputContent.setAttribute("disabled","")))})),C(this,"listenIcon",((g,I,C)=>{"icon"===g&&I&&I!==C&&(this.removeAttribute("label"),this.setAttribute("icon",I),this.dealIcon())})),C(this,"dealIcon",(()=>{if(!this._icon){this._icon=document.createElement("ra-icon");const{width:g,height:I}=this._inputContent.getBoundingClientRect(),C=Math.min(g,I);this._icon.setAttribute("size",`${C}`),this._inputContent.insertAdjacentElement("beforebegin",this._icon)}this.icon&&this._icon.setAttribute("name",this.icon)})),C(this,"listenEvent",((g,I,C)=>{this.listenPlaceholder(g,C),this.listenLabel(g,C),this.listenStatus(g,C),this.listenDisabled(g,C),this.listenIcon(g,C,I),"value"===g&&I!==C&&(this._inputContent.value=C,this._input.setAttribute("value",C))}));const g=this.attachShadow({mode:"closed"}),I=document.createElement("style");I.textContent='.remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}html.dark .r-preview-mask .r-preview-contain{background-color:#191919!important}.ran-input{position:relative;display:flex;width:var(--ran-input-width, calc(100% - 16px) );height:var(--ran-input-height, calc(100% - 4px) );min-width:0;padding:var(--ran-input-padding, 2px 8px);color:#000000d9;font-size:var(--ran-input-font-size, 12px);line-height:var(--ran-input-line-height, 1.5715);background-color:var(--ran-input-background-color, #fff);background-image:var(--ran-input-background-image, none);border:var(--ran-input-border, 1px solid #d9d9d9);border-radius:var(--ran-input-border-radius, 2px);transition:var(--ran-input-transition, all .3s)}.ran-input .ran-icon{display:flex;align-items:center;justify-content:center}.ran-input:active{border-color:#40a9ff;box-shadow:0 0 0 2px #1890ff33;border-right-width:1px;outline:0}.ran-input:hover{border-color:#40a9ff;border-right-width:1px}.ran-input>.ran-input-content:hover~.ran-input-label{color:#40a9ff}.ran-input[value]>.ran-input-label{transform:translateY(calc(-50% - .43em)) scale(.8);color:#00000040}.ran-input[status=error]{border-color:#ff4d4f}.ran-input[status=error]>.ran-input-content~.ran-input-label{color:#ff4d4f}.ran-input[status=warning]{border-color:#ff7875}.ran-input[status=warning]>.ran-input-content~.ran-input-label{color:#ff7875}.ran-input[disabled]{color:#00000040;background-color:#f5f5f5;border-color:#d9d9d9;box-shadow:none;cursor:not-allowed;opacity:1}.ran-input[disabled]>.ran-input-content{color:#00000040;background-color:#f5f5f5;border-color:#d9d9d9;box-shadow:none;cursor:not-allowed;opacity:1}.ran-input[disabled]>.ran-input-content~.ran-input-label{color:#00000040;background-color:#f5f5f5}.ran-input[disabled]>.ran-input-label{color:#999;border-color:#d9d9d9;box-shadow:none;cursor:not-allowed}.ran-input-content{writing-mode:horizontal-tb;text-rendering:auto;letter-spacing:normal;word-spacing:normal;text-transform:none;text-indent:0px;text-shadow:none;text-align:start;-webkit-rtl-ordering:logical;cursor:text;touch-action:manipulation;-webkit-appearance:none;text-overflow:ellipsis;box-sizing:border-box;margin:0;font-variant:tabular-nums;list-style:none;font-feature-settings:"tnum";position:relative;border:none;width:100%;min-width:0;color:#000000d9;font-size:14px;line-height:1.48;background-color:#fff;background-image:none;transition:all .3s;outline:none}.ran-input-content:focus,.ran-input-content:hover{border:none;outline:0}.ran-input-content::placeholder{color:#999}.ran-input-content:placeholder-shown~.ran-input-label{transform:translateY(calc(-50% - .43em)) scale(.8)}.ran-input-content:focus~.ran-input-label{transform:translateY(calc(-50% - .43em)) scale(.8)}.ran-input-content::-webkit-search-cancel-button{display:none;-webkit-appearance:none}.ran-input-label{pointer-events:none;position:absolute;font-size:14px;left:8px;transition:transform .3s,color .3s,background-color .3s,backdrop-filter .3s;transform-origin:left;padding:0 .2em;color:#999;background:#fff;opacity:.9}',g.appendChild(I),this._input=document.createElement("div"),this._input.setAttribute("class","ran-input"),this._input.setAttribute("part","ran-input"),this._inputContent=document.createElement("input"),this._inputContent.setAttribute("class","ran-input-content"),this._inputContent.setAttribute("part","ran-input-content"),this._input.appendChild(this._inputContent),g.appendChild(this._input)}static get observedAttributes(){return["label","disabled","name","placeholder","type","icon","value","status","prefix","suffix","allowclear","count","maxlength","showcount","onPressEnter","variant","minrows","maxrows"]}get value(){return this.getAttribute("value")||""}set value(g){!Y(this)&&g?(this.setAttribute("value",g),this._input.setAttribute("value",g)):(this.removeAttribute("value"),this._input.removeAttribute("value"))}get placeholder(){return this.getAttribute("placeholder")||""}set placeholder(g){g?this.setAttribute("placeholder",g):this.removeAttribute("placeholder")}get required(){return this.getAttribute("required")||""}set required(g){g&&"false"!==g?this.setAttribute("required",""):this.removeAttribute("required")}get disabled(){return`${Y(this)}`}set disabled(g){X.includes(g)?(this.removeAttribute("disabled"),this._input.removeAttribute("disabled"),this._inputContent.removeAttribute("disabled")):(this.setAttribute("disabled",""),this._input.setAttribute("disabled",""),this._inputContent.setAttribute("disabled",""))}get label(){return this.getAttribute("label")||""}set label(g){this.setAttribute("label",g)}get status(){return this.getAttribute("status")||""}set status(g){g?(this.setAttribute("status",g),this._input.setAttribute("status",g)):(this.removeAttribute("status"),this._input.removeAttribute("status"))}get name(){return this.getAttribute("name")||""}set name(g){this.setAttribute("name",g)}get min(){return this.getAttribute("min")||""}set min(g){"number"===this.type&&this.setAttribute("min",g)}get max(){return this.getAttribute("max")||""}set max(g){"number"===this.type&&this.setAttribute("max",g)}get step(){return this.getAttribute("step")||""}set step(g){"number"===this.type&&this.setAttribute("step",g)}get icon(){return this.getAttribute("icon")||""}set icon(g){g?this.setAttribute("icon",g):this.removeAttribute("icon")}get prefix(){return this.getAttribute("prefix")||""}set prefix(g){g?this.setAttribute("prefix",g):this.removeAttribute("prefix")}get suffix(){return this.getAttribute("suffix")||""}set suffix(g){g?this.setAttribute("suffix",g):this.removeAttribute("suffix")}get type(){return this.getAttribute("type")||""}set type(g){g?this.setAttribute("type",g):this.removeAttribute("type")}connectedCallback(){this.value&&(this._inputContent.value=this.value,this._input.setAttribute("value",this.value)),this.status&&this._input.setAttribute("status",this.status),Y(this)&&(this._input.setAttribute("disabled",""),this._inputContent.setAttribute("disabled","")),this.type&&this._inputContent.setAttribute("type",this.type),this._inputContent.addEventListener("input",this.customInput),"complete"===document.readyState&&this.dealIcon()}disconnectCallback(){this._inputContent.removeEventListener("input",this.customInput)}attributeChangedCallback(g,I,C){this.listenEvent(g,I,C)}};const T="undefined"==typeof window||customElements.get("r-input")?R("document is undefined or r-input is exist"):(customElements.define("r-input",v),v),x=Object.freeze(Object.defineProperty({__proto__:null,Input:v,default:T},Symbol.toStringTag,{value:"Module"})),U=new Map([["success","check-circle-fill"],["warning","warning-circle-fill"],["error","close-circle-fill"],["info","info-circle-fill"],["toast",null]]),Q=new Map([["success","#52c41a"],["warning","#faad14"],["error","#ff4d4f"],["info","#1890ff"],["toast","rgba(0, 0, 0, 0.7)"]]);const j=function(){if("undefined"!=typeof window&&!customElements.get("r-message")){class g extends HTMLElement{constructor(){super(),C(this,"_info"),C(this,"_notice"),C(this,"_content"),C(this,"_icon"),C(this,"_span"),C(this,"timeId"),C(this,"close"),C(this,"setIcon",(g=>{var I,C,A,i;const e=U.get(g),l=Q.get(g);e&&(null==(I=this._icon)||I.setAttribute("name",e),null==(C=this._icon)||C.style.setProperty("margin-right","8px"),null==(A=this._icon)||A.setAttribute("size","18"),l&&(null==(i=this._icon)||i.setAttribute("color",l)))})),this._notice=document.createElement("div"),this._notice.setAttribute("class","ran-message-notice"),this._content=document.createElement("div"),this._content.setAttribute("class","ran-message-notice-content"),this._info=document.createElement("div"),this._info.setAttribute("class","ran-message-notice-content-info"),this._icon=document.createElement("r-icon"),this._span=document.createElement("span"),this._info.appendChild(this._icon),this._info.appendChild(this._span),this._content.appendChild(this._info),this._notice.appendChild(this._content);const g=this.attachShadow({mode:"closed"}),I=document.createElement("style");I.textContent='.remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}html.dark .r-preview-mask .r-preview-contain{background-color:#191919!important}:host([type="toast"]){--ranui-message-background: rgba(0, 0, 0, .7);--ranui-message-color: #fff;--ranui-message-border-radius: 7px}.ran-message-notice{padding:8px;text-align:center;max-width:90%;margin:0 auto;word-break:break-all}.ran-message-notice-content{display:inline-block;padding:10px 16px;background:var(--ranui-message-background, #fff);border-radius:var(--ranui-message-border-radius, 8px);box-shadow:0 3px 6px -4px #0000001f,0 6px 16px #00000014,0 9px 28px 8px #0000000d;pointer-events:all}.ran-message-notice-content-info{align-items:center;display:flex}.ran-message-notice-content-info span{margin:0;padding:0;color:var(--ranui-message-color, #000000d9);font-size:14px;font-variant:tabular-nums;list-style:none;font-feature-settings:"tnum";z-index:1010;width:100%;pointer-events:none}@keyframes rotate{to{transform:rotate(360deg)}}@keyframes MessageMoveIn{0%{padding:0;transform:translateY(-100%);opacity:0}to{padding:8px;transform:translateY(0);opacity:1}}@keyframes MessageMoveOut{0%{max-height:150px;padding:8px;opacity:1}to{max-height:0;padding:0;opacity:0}}.ranui-message{box-sizing:border-box;margin:0;padding:0;color:#000000d9;font-size:14px;font-variant:tabular-nums;line-height:1.5715;list-style:none;font-feature-settings:"tnum";position:fixed;top:8px;left:0;z-index:1010;width:100%;pointer-events:none}.ranui-message .message-in{animation-name:MessageMoveIn;animation-duration:.3s;animation-timing-function:cubic-bezier(.78,.14,.15,.86)}.ranui-message .message-leave{animation-name:MessageMoveOut;animation-duration:.3s;animation-timing-function:cubic-bezier(.78,.14,.15,.86)}',g.appendChild(I),g.appendChild(this._notice)}static get observedAttributes(){return["type","content"]}get type(){return this.getAttribute("type")}set type(g){g&&this.setAttribute("type",g)}get content(){return this.getAttribute("content")}set content(g){g&&this.setAttribute("content",g)}attributeChangedCallback(g,I,C){"content"===g&&I!==C&&(this._span.textContent=C),"type"===g&&I!==C&&this.setIcon(C)}}customElements.define("r-message",g);const I=document.createElement("div"),A=document.createElement("div");A.setAttribute("class","ranui-message"),document.body.appendChild(I),I.appendChild(A);const i=I=>C=>{const i=new g;i.setAttribute("class","message"),i.timeId&&clearTimeout(i.timeId),i.setAttribute("type",I);let e,l=3e3;if(!C)return;"string"==typeof C?i.setAttribute("content",C):(i.setAttribute("content",C.content),e=C.close,l=C.duration||3e3);const t=setTimeout((()=>{i.classList.remove("message-in"),i.classList.add("message-leave"),clearTimeout(t)}),l-300);i.timeId=setTimeout((()=>{i.classList.remove("message-leave"),A.removeChild(i),e&&e()}),l),A.appendChild(i),i.classList.add("message-in"),setTimeout((()=>{i.classList.remove("message-in")}),300)};return{info:i("info"),success:i("success"),error:i("error"),warning:i("warning"),toast:i("toast")}}return{}}();"undefined"!=typeof window&&j&&(window.message=j,window.ranui||(window.ranui={}),window.ranui.message=j);const O=Object.freeze(Object.defineProperty({__proto__:null,default:j},Symbol.toStringTag,{value:"Module"})),E="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",P="application/vnd.ms-excel",{warning:_=t}=j;const q=async function(){if("undefined"!=typeof document&&!customElements.get("r-preview")){const{renderPptx:g}=await Promise.resolve().then((()=>OI)),{renderDocx:I}=await Promise.resolve().then((()=>QA)),{renderPdf:A}=await Promise.resolve().then((()=>OA)),{renderExcel:i}=await Promise.resolve().then((()=>bc)),e=(g,I)=>{if("undefined"==typeof XMLHttpRequest)throw new Error("XMLHttpRequest is not defined");return"undefined"==typeof document?Promise.reject("document is not defined"):new Promise((function(C,A){const i=new XMLHttpRequest;i.open(I.method||"GET",g,!0),i.responseType=I.responseType||"arraybuffer",i.onload=function(){if(200===i.status){const g={success:!0,data:i.response,message:""};I.onLoad&&I.onLoad(g),C(g)}else{const g={success:!1,data:i.status,message:`The request status is${i.status}`};I.onError&&I.onError(g),A(g)}},i.onerror=function(g){const C={success:!1,data:g,message:""};I.onError&&I.onError(C),A(C)},i.onprogress=g=>{I.onProgress&&I.onProgress(g)},i.withCredentials=I.withCredentials||!1,I.headers&&Object.keys(I.headers).forEach((function(g){(null==I?void 0:I.headers)&&i.setRequestHeader(g,I.headers[g])})),i.send(I.body)}))},l=new Map([["application/pdf",A],["application/vnd.openxmlformats-officedocument.presentationml.presentation",(I,C)=>{const{dom:A,onError:i,onLoad:e}=C;return new Promise(((C,l)=>{const t=new FileReader;t.readAsArrayBuffer(I),t.onload=()=>{var I;if(t.result&&A){const l={pptx:t.result,resultElement:A,onError:i,onLoad:e};null==(I=g(l))||I.then((()=>{C()}))}},t.onerror=g=>{l(g)},t.onabort=g=>{l(g)}}))}],["application/vnd.openxmlformats-officedocument.wordprocessingml.document",(g,C)=>{const{dom:A,onError:i,onLoad:e}=C;return Promise.resolve().then((()=>I({buffer:g,bodyContainer:A}))).then((()=>{e&&e({success:!0,message:""})})).catch((g=>{i&&i({success:!0,data:g,message:""})}))}],[E,i],[P,i]]);class t extends HTMLElement{constructor(){super(),C(this,"_loadingText"),C(this,"preview"),C(this,"previewContext"),C(this,"_slot"),C(this,"_div"),C(this,"_loadingElement"),C(this,"createLoading",(()=>{this._loadingElement=document.createElement("div"),this._loadingElement.setAttribute("class","r-preview-loading");const g=document.createElement("r-icon");return g.setAttribute("name","loading"),g.setAttribute("size","100"),g.setAttribute("color"," var(--el-loading-color)"),g.setAttribute("spin",""),this._loadingText=document.createElement("div"),this._loadingElement.appendChild(g),this._loadingText.setAttribute("class","r-preview-loading-text"),this._loadingElement.appendChild(this._loadingText),this._loadingElement})),C(this,"onProgress",(g=>{const I=g.loaded/g.total*100,C=Math.min(99,I).toFixed(2)+"%";this._loadingText&&this._loadingElement&&(this._loadingText.innerText=`Loading ${C}`,I>=100&&setTimeout((()=>{this._loadingText.innerText="Loading..."}),300))})),C(this,"onError",(()=>{var g;null==(g=this.preview)||g.removeChild(this._loadingElement)})),C(this,"onLoad",(()=>{var g;null==(g=this.preview)||g.removeChild(this._loadingElement),this.dispatchEvent(new CustomEvent("loaded",{detail:{isComplete:!0},bubbles:!0,composed:!0}))})),C(this,"handleFile",(async g=>{try{if("string"==typeof g){const{success:I,data:C,message:A}=await e(g,{onProgress:this.onProgress,onError:this.onError,responseType:"blob"});if(I&&C){g=new File([C],C.name,{type:C.type});const{type:I}=g,A=l.get(I);if(A&&this.previewContext){this.previewContext.style.setProperty("width","100%");A(g,{dom:this.previewContext,onError:this.onError,onLoad:this.onLoad})}}else _(A)}}catch(I){}})),C(this,"closePreview",(()=>{this.preview=this.preview||document.getElementById("r-preview-mask"),this.preview&&("true"===this.isContain?this._div.removeChild(this.preview):document.body.removeChild(this.preview),this.preview=void 0)})),C(this,"showPreview",(()=>{var g;if(this.src){if(this.preview)this.preview.style.display="block";else{this.preview=document.createElement("div"),this.preview.setAttribute("class","r-preview-mask"),this.preview.setAttribute("id","r-preview-mask"),"true"===this.isContain&&this.preview.classList.add("r-preview-mask-contain");const I=document.createElement("div");if(I.setAttribute("class","r-preview-options"),"false"!==this.closeable){const g=document.createElement("r-icon");g.setAttribute("class","r-preview-options-close"),g.setAttribute("name","close-circle-fill"),g.setAttribute("size","40"),g.addEventListener("click",this.closePreview),I.appendChild(g)}else I.classList.add("r-preview-options-false");const C=document.createElement("div");C.setAttribute("class","r-preview-contain"),this.previewContext=document.createElement("div"),this.previewContext.setAttribute("class","r-preview-context"),C.appendChild(this.previewContext),this.preview.appendChild(I),null==(g=this.preview)||g.appendChild(C),this._loadingElement=this.createLoading(),this.preview.appendChild(this._loadingElement),"true"===this.isContain?(console.log(this.preview,this._div),this._div.appendChild(this.preview)):document.body.appendChild(this.preview)}this.handleFile(this.src)}})),this._div=document.createElement("div"),this.preview=document.getElementById("r-preview-mask"),this._slot=document.createElement("slot"),this._div.appendChild(this._slot),this._slot.setAttribute("class","r-preview-slot"),this._div.setAttribute("class","r-preview");const g=this.attachShadow({mode:"open"}),I=document.createElement("style");I.textContent='.remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}html.dark .r-preview-mask .r-preview-contain{background-color:#191919!important}.r-preview{width:100%;height:100%}.r-preview-slot{display:block}:host{cursor:pointer;--el-text-color-primary: #303133;--el-loading-color: #409eff}.r-preview-mask{display:flex;flex-flow:column nowrap;position:fixed;top:0;left:0;width:100%;height:100%;background-color:#00000073;z-index:1081}.r-preview-mask .r-preview-loading{position:absolute;top:30%;left:50%;transform:translate(-50%);display:flex;flex-flow:column;align-items:center}.r-preview-mask .r-preview-loading-text{color:var(--el-text-color-primary);font-size:16px}.r-preview-mask .r-preview-options{width:100%;pointer-events:auto;display:flex;flex-flow:row-reverse nowrap;align-items:center;justify-content:space-between;flex:0 0 68px}.r-preview-mask .r-preview-options-close{margin:14px;border:none;cursor:pointer;transition:all .3s;-webkit-user-select:none;user-select:none}.r-preview-mask .r-preview-options-false{flex:0 0 0px}.r-preview-mask .r-preview-contain{width:100%;margin:0 auto;display:flex;flex-flow:column nowrap;align-items:center;justify-content:center;flex:1;overflow:hidden}.r-preview-mask .r-preview-contain .r-preview-context{margin:0 auto;height:100%;display:flex;flex-flow:column nowrap;justify-content:flex-start;align-items:safe center;overflow:auto}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main{width:100%;height:100%;margin-bottom:10px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet{font-size:13px;line-height:normal;-webkit-user-select:none;user-select:none;-moz-user-select:none;font-family:Lato,Source Sans Pro,Roboto,Helvetica,Arial,sans-serif;box-sizing:content-box;background:#fff;-webkit-font-smoothing:antialiased}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet textarea{font:400 13px Arial,Lato,Source Sans Pro,Roboto,Helvetica,sans-serif}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-sheet{position:relative;overflow:hidden}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-table{vertical-align:bottom}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-tooltip{font-family:inherit;position:absolute;padding:5px 10px;color:#fff;border-radius:1px;background:#000;font-size:12px;z-index:201}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-tooltip:before{pointer-events:none;position:absolute;left:calc(50% - 4px);top:-4px;content:"";width:8px;height:8px;background:inherit;-webkit-transform:rotate(45deg);transform:rotate(45deg);z-index:1;box-shadow:1px 1px 3px -1px #0000004d}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-color-palette{padding:5px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-color-palette table{margin:0;padding:0;border-collapse:separate;border-spacing:2;background:#fff}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-color-palette table td{margin:0;cursor:pointer;border:1px solid transparent}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-color-palette table td:hover{border-color:#ddd}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-color-palette table td .x-spreadsheet-color-palette-cell{width:16px;height:16px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-border-palette{padding:6px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-border-palette table{margin:0;padding:0;border-collapse:separate;border-spacing:0;background:#fff;table-layout:fixed}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-border-palette table td{margin:0}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-border-palette .x-spreadsheet-border-palette-left{border-right:1px solid #eee;padding-right:6px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-border-palette .x-spreadsheet-border-palette-left .x-spreadsheet-border-palette-cell{width:30px;height:30px;cursor:pointer;text-align:center}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-border-palette .x-spreadsheet-border-palette-left .x-spreadsheet-border-palette-cell:hover{background-color:#eee}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-border-palette .x-spreadsheet-border-palette-right{padding-left:6px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-border-palette .x-spreadsheet-border-palette-right .x-spreadsheet-line-type{position:relative;left:0;top:-3px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-dropdown{position:relative}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-dropdown .x-spreadsheet-dropdown-content{position:absolute;z-index:200;background:#fff;box-shadow:1px 2px 5px 2px #33333326}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-dropdown.bottom-left .x-spreadsheet-dropdown-content{top:calc(100% + 5px);left:0}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-dropdown.bottom-right .x-spreadsheet-dropdown-content{top:calc(100% + 5px);right:0}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-dropdown.top-left .x-spreadsheet-dropdown-content{bottom:calc(100% + 5px);left:0}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-dropdown.top-right .x-spreadsheet-dropdown-content{bottom:calc(100% + 5px);right:0}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-dropdown .x-spreadsheet-dropdown-title{padding:0 5px;display:inline-block}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-resizer{position:absolute;z-index:11}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-resizer .x-spreadsheet-resizer-hover{background-color:#4b89ff40}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-resizer .x-spreadsheet-resizer-line{position:absolute}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-resizer.horizontal{cursor:row-resize}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-resizer.horizontal .x-spreadsheet-resizer-line{border-bottom:2px dashed #4b89ff;left:0;bottom:0}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-resizer.vertical{cursor:col-resize}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-resizer.vertical .x-spreadsheet-resizer-line{border-right:2px dashed #4b89ff;top:0;right:0}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-scrollbar{position:absolute;bottom:0;right:0;background-color:#f4f5f8;opacity:.9;z-index:12}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-scrollbar.horizontal{right:15px;overflow-x:scroll;overflow-y:hidden}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-scrollbar.horizontal>div{height:1px;background:#ddd}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-scrollbar.vertical{bottom:15px;overflow-x:hidden;overflow-y:scroll}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-scrollbar.vertical>div{width:1px;background:#ddd}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-overlayer{position:absolute;left:0;top:0;z-index:10}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-overlayer .x-spreadsheet-overlayer-content{position:absolute;overflow:hidden;pointer-events:none;width:100%;height:100%}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-editor,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-selector{box-sizing:content-box;position:absolute;overflow:hidden;pointer-events:none;top:0;left:0;width:100%;height:100%}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-selector .hide-input{position:absolute;z-index:0}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-selector .hide-input input{padding:0;width:0;border:none!important}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-selector .x-spreadsheet-selector-area{position:absolute;border:2px solid #4b89ff;background:#4b89ff1a;z-index:5}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-selector .x-spreadsheet-selector-clipboard,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-selector .x-spreadsheet-selector-autofill{position:absolute;background:transparent;z-index:100}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-selector .x-spreadsheet-selector-clipboard{border:2px dashed #4b89ff}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-selector .x-spreadsheet-selector-autofill{border:1px dashed rgba(0,0,0,.45)}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-selector .x-spreadsheet-selector-corner{pointer-events:auto;position:absolute;cursor:crosshair;font-size:0;height:5px;width:5px;right:-5px;bottom:-5px;border:2px solid #ffffff;background:#4b89ff}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-editor{z-index:20}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-editor .x-spreadsheet-editor-area{position:absolute;text-align:left;border:2px solid #4b89ff;line-height:0;z-index:100;pointer-events:auto}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-editor .x-spreadsheet-editor-area textarea{box-sizing:content-box;border:none;padding:0 3px;outline:none;resize:none;text-align:start;overflow-y:hidden;font:400 13px Arial,Lato,Source Sans Pro,Roboto,Helvetica,sans-serif;color:inherit;white-space:normal;word-wrap:break-word;line-height:22px;margin:0}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-editor .x-spreadsheet-editor-area .textline{overflow:hidden;visibility:hidden;position:fixed;top:0;left:0}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-item{-webkit-user-select:none;user-select:none;background:0;border:1px solid transparent;outline:none;height:26px;color:#000000e6;line-height:26px;list-style:none;padding:2px 10px;cursor:default;text-align:left;overflow:hidden}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-item.disabled{pointer-events:none;opacity:.5}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-item:hover,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-item.active{background:#0000000d}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-item.divider{height:0;padding:0;margin:5px 0;border:none;border-bottom:1px solid rgba(0,0,0,.1)}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-item .label{float:right;opacity:.65;font-size:1em}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-item.state,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-header.state{padding-left:35px!important;position:relative}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-item.state:before,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-header.state:before{content:"";position:absolute;width:10px;height:10px;left:12px;top:calc(50% - 5px);background:#00000014;border-radius:2px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-item.state.checked:before,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-header.state.checked:before{background:#4b89ff}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-checkbox{position:relative;display:inline-block;backface-visibility:hidden;outline:0;vertical-align:baseline;font-style:normal;font-size:1rem;line-height:1em}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-checkbox>input{position:absolute;top:0;left:0;opacity:0!important;outline:0;z-index:-1}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-suggest,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-contextmenu,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-sort-filter{position:absolute;box-shadow:1px 2px 5px 2px #33333326;background:#fff;z-index:100;width:260px;pointer-events:auto;overflow:auto}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-suggest{width:200px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-filter{border:1px solid #e9e9e9;font-size:12px;margin:10px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-filter .x-spreadsheet-header{padding:.5em .75em;background:#f8f8f9;border-bottom:1px solid #e9e9e9;border-left:1px solid transparent}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-filter .x-spreadsheet-body{height:200px;overflow-y:auto}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-filter .x-spreadsheet-body .x-spreadsheet-item{height:20px;line-height:20px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-sort-filter .x-spreadsheet-buttons{margin:10px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-bottombar{height:40px;padding:0 30px;text-align:left;background:#f5f6f7;display:flex}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-bottombar{position:relative;border-top:1px solid #e0e2e4}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-bottombar .x-spreadsheet-menu>li{line-height:40px;height:40px;padding-top:0;padding-bottom:0;vertical-align:middle;border-right:1px solid #e8eaed}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-menu{list-style:none;margin:0;padding:0;-webkit-user-select:none;user-select:none}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-menu>li{float:left;line-height:1.25em;padding:.785em 1em;margin:0;vertical-align:middle;text-align:left;font-weight:400;color:#80868b;white-space:nowrap;cursor:pointer;transition:all .3s;font-weight:700}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-menu>li.active{background-color:#fff;color:#000000a6}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-menu>li .x-spreadsheet-dropdown{display:inline-block}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-print{position:absolute;left:0;top:0;z-index:100;width:100%;height:100%;display:flex;flex-direction:column}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-print-bar{background:#424242;height:60px;line-height:60px;padding:0 30px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-print-bar .-title{color:#fff;font-weight:700;font-size:1.2em;float:left}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-print-bar .-right{float:right;margin-top:12px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-print-content{display:flex;flex:auto;flex-direction:row;background:#d0d0d0;height:calc(100% - 60px)}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-print-content .-sider{flex:0 0 300px;width:300px;border-left:2px solid #ccc;background:#fff}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-print-content .-content{flex:auto;overflow-x:auto;overflow-y:scroll;height:100%}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-canvas-card-wraper{margin:40px 20px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-canvas-card{background:#fff;margin:auto;page-break-before:auto;page-break-after:always;box-shadow:0 8px 10px 1px #00000024,0 3px 14px 3px #0000001f,0 4px 5px #0003}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-calendar{color:#000000a6;background:#fff;-webkit-user-select:none;user-select:none}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-calendar .calendar-header{font-weight:700;line-height:30px;text-align:center;width:100%;float:left;background:#f9fafb}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-calendar .calendar-header .calendar-header-left{padding-left:5px;float:left}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-calendar .calendar-header .calendar-header-right{float:right}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-calendar .calendar-header .calendar-header-right a{padding:3px 0;margin-right:2px;border-radius:2px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-calendar .calendar-header .calendar-header-right a:hover{background:#00000014}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-calendar .calendar-body{border-collapse:collapse;border-spacing:0}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-calendar .calendar-body th,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-calendar .calendar-body td{width:14.28571429%;min-width:32px;text-align:center;font-weight:700;line-height:30px;padding:0}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-calendar .calendar-body td>.cell:hover{background:#ecf6fd}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-calendar .calendar-body td>.cell.active,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-calendar .calendar-body td>.cell.active:hover{background:#ecf6fd;color:#2185d0}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-calendar .calendar-body td>.cell.disabled{pointer-events:none;opacity:.5}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-datepicker{box-shadow:2px 2px 5px #0003;position:absolute;left:0;top:calc(100% + 5px);z-index:10;width:auto}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-buttons{display:flex;justify-content:flex-end}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-buttons .x-spreadsheet-button{margin-left:8px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-button{display:inline-block;border-radius:3px;line-height:1em;min-height:1em;white-space:nowrap;text-align:center;cursor:pointer;font-size:1em;font-weight:700;padding:.75em 1em;color:#0009;background:#e0e1e2;text-decoration:none;font-family:Lato,proxima-nova,Helvetica Neue,Arial,sans-serif;outline:none;vertical-align:baseline;zoom:1;-webkit-user-select:none;user-select:none;transition:all .1s linear}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-button.active,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-button:hover{background-color:#c0c1c2;color:#000c}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-button.primary{color:#fff;background-color:#2185d0}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-button.primary:hover,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-button.primary.active{color:#fff;background-color:#1678c2}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-form-input{font-size:1em;position:relative;font-weight:400;display:inline-flex;color:#000000de}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-form-input input{z-index:1;margin:0;max-width:100%;flex:1 0 auto;outline:0;-webkit-tap-highlight-color:rgba(255,255,255,0);text-align:left;line-height:30px;height:30px;padding:0 8px;background:#fff;border:1px solid #e9e9e9;border-radius:3px;transition:box-shadow .1s ease,border-color .1s ease;box-shadow:inset 0 1px 2px #0a0a0a0f}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-form-input input:focus{border-color:#4b89ff;box-shadow:inset 0 1px 2px #4b89ff33}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-form-select{position:relative;display:inline-block;background:#fff;border:1px solid #e9e9e9;border-radius:2px;cursor:pointer;color:#000000de;-webkit-user-select:none;user-select:none;box-shadow:inset 0 1px 2px #0a0a0a0f}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-form-select .input-text{text-overflow:ellipsis;white-space:nowrap;min-width:60px;width:auto;height:30px;line-height:30px;padding:0 8px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-form-fields{display:flex;flex-direction:row;flex-wrap:wrap}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-form-fields .x-spreadsheet-form-field{flex:0 1 auto}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-form-fields .x-spreadsheet-form-field .label{display:inline-block;margin:0 10px 0 0}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-form-field{display:block;vertical-align:middle;margin-left:10px;margin-bottom:10px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-form-field:first-child{margin-left:0}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-form-field.error .x-spreadsheet-form-select,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-form-field.error input{border-color:#f04134}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-form-field .tip{color:#f04134;font-size:.9em}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-dimmer{display:none;position:absolute;top:0!important;left:0!important;width:100%;height:100%;text-align:center;vertical-align:middle;background-color:#0009;opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:.5s;animation-duration:.5s;transition:background-color .5s linear;-webkit-user-select:none;user-select:none;z-index:1000}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-dimmer.active{display:block;opacity:1}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main form fieldset{border:none}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main form fieldset label{display:block;margin-bottom:.5em;font-size:1em;color:#666}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main form fieldset select{font-size:1.1em;width:100%;background-color:#fff;border:none;border-bottom:2px solid #ddd;padding:.5em .85em;border-radius:2px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-modal,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-toast{font-size:13px;position:fixed;z-index:1001;text-align:left;line-height:1.25em;min-width:360px;color:#000000de;font-family:Lato,Source Sans Pro,Roboto,Helvetica,Arial,sans-serif;border-radius:4px;border:1px solid rgba(0,0,0,.1);background-color:#fff;background-clip:padding-box;box-shadow:#0003 0 2px 8px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-toast{background-color:#ffffffd9}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-modal-header,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-toast-header{font-weight:600;background-clip:padding-box;background-color:#ffffffd9;border-bottom:1px solid rgba(0,0,0,.05);border-radius:4px 4px 0 0}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-toast-header{color:#f2711c}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-modal-header{border-bottom:1px solid #e0e2e4;background:#00000014;font-size:1.0785em}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-modal-header,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-modal-content,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-toast-header,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-toast-content{padding:.75em 1em}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-menu li:first-child{display:none}.r-preview-mask .r-preview-contain .r-preview-context .docx-wrapper{background:none}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section{width:100%;height:690px;position:relative;border:1px solid #333;background-color:#efefef;text-align:center;border-radius:10px;box-shadow:1px 1px 3px #aaa;overflow:hidden}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section div.block{position:absolute;top:0;left:0;width:100%}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section div.content{display:flex;flex-direction:column}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section div.v-up{justify-content:flex-start}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section div.v-mid{justify-content:center}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section div.v-down{justify-content:flex-end}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section div.h-left{align-items:flex-start;text-align:left}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section div.h-mid{align-items:center;text-align:center}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section div.h-right{align-items:flex-end;text-align:right}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section div.up-left{justify-content:flex-start;align-items:flex-start;text-align:left}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section div.up-center{justify-content:flex-start;align-items:center}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section div.up-right{justify-content:flex-start;align-items:flex-end}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section div.center-left{justify-content:center;align-items:flex-start;text-align:left}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section div.center-center{justify-content:center;align-items:center}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section div.center-right{justify-content:center;align-items:flex-end}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section div.down-left{justify-content:flex-end;align-items:flex-start;text-align:left}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section div.down-center{justify-content:flex-end;align-items:center}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section div.down-right{justify-content:flex-end;align-items:flex-end}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main li.slide{margin:10px 0;font-size:18px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main div.footer{text-align:center}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section table{position:absolute}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section table,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section th,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section td{border:1px solid black}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section svg.drawing{position:absolute;overflow:visible}.r-preview-mask-contain{position:relative!important;width:100%!important;height:100%!important;background-color:#fff!important}',g.appendChild(I),g.appendChild(this._div)}static get observedAttributes(){return["src","closeable","isContain"]}get label(){return this.getAttribute("label")}set label(g){g&&this.setAttribute("label",g)}get src(){return this.getAttribute("src")}set src(g){g&&this.setAttribute("src",g)}get closeable(){return this.getAttribute("closeable")}set closeable(g){g&&this.setAttribute("closeable",g)}get isContain(){return this.getAttribute("isContain")}set isContain(g){g&&this.setAttribute("isContain",g)}connectedCallback(){this.preview=document.getElementById("r-preview-mask"),this.isContain=this.getAttribute("isContain")||"false",this.closeable=this.getAttribute("closeable")||"true"}disconnectedCallback(){}attributeChangedCallback(g,I,C){C!==I&&("src"===g&&C&&this.setAttribute("src",C),"isContain"===g&&C&&this.setAttribute("isContain",C),"closeable"===g&&C&&this.setAttribute("closeable",C),this.src&&this.isContain&&this.closeable&&(this.closePreview(),this.showPreview()))}}customElements.define("r-preview",t)}}(),$=Object.freeze(Object.defineProperty({__proto__:null,default:q},Symbol.toStringTag,{value:"Module"}));const gg=function(){if("undefined"!=typeof window&&!customElements.get("r-skeleton")){class g extends HTMLElement{constructor(){super(),C(this,"_div"),this._div=document.createElement("div"),this._div.setAttribute("class","ran-skeleton");const g=this.attachShadow({mode:"closed"}),I=document.createElement("style");I.textContent='.remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}html.dark .r-preview-mask .r-preview-contain{background-color:#191919!important}@keyframes skeleton{0%{transform:translate(-37.5%)}to{transform:translate(37.5%)}}.ran-skeleton{position:relative;z-index:0;overflow:hidden;background:0 0;width:100%;height:16px;background:#0000000f;border-radius:4px}.ran-skeleton:after{position:absolute;top:0;inset-inline-end:-150%;bottom:0;inset-inline-start:-150%;background:linear-gradient(90deg,#0000000f 25%,#00000026 37%,#0000000f 63%);animation-name:skeleton;animation-duration:1.4s;animation-timing-function:ease;animation-iteration-count:infinite;content:""}',g.appendChild(I),g.appendChild(this._div)}static get observedAttributes(){return["disabled"]}connectedCallback(){}disconnectCallback(){}attributeChangedCallback(g,I,C){}}window.customElements.define("r-skeleton",g)}}(),Ig=Object.freeze(Object.defineProperty({__proto__:null,default:gg},Symbol.toStringTag,{value:"Module"}));const Cg=function(){if("undefined"!=typeof window&&!customElements.get("r-tab")){class g extends HTMLElement{constructor(){super(),C(this,"_div"),C(this,"parent"),C(this,"initAttribute",(()=>{var g,I,C;this.parent=this.parentNode,this.key&&(null==(g=this.parent)||g.updateAttribute(this.key,"icon",this.icon)),this.key&&(null==(I=this.parent)||I.updateAttribute(this.key,"iconSize",this.iconSize)),this.key&&(null==(C=this.parent)||C.updateAttribute(this.key,"effect",this.effect))})),this._div=document.createElement("slot");const g=this.attachShadow({mode:"closed"}),I=document.createElement("style");I.textContent=".remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}html.dark .r-preview-mask .r-preview-contain{background-color:#191919!important}",g.appendChild(I),g.appendChild(this._div)}static get observedAttributes(){return["label","key","disabled","icon","effect","iconSize"]}get label(){return this.getAttribute("label")||""}set label(g){this.setAttribute("label",g)}get icon(){return this.getAttribute("icon")}set icon(g){g&&"false"!==g?this.setAttribute("icon",g):this.removeAttribute("icon")}get iconSize(){return this.getAttribute("iconSize")}set iconSize(g){g&&"false"!==g?this.setAttribute("iconSize",g):this.removeAttribute("iconSize")}get key(){return this.getAttribute("r-key")}set key(g){g?this.setAttribute("r-key",g):this.removeAttribute("r-key")}get disabled(){return this.getAttribute("disabled")}set disabled(g){g&&"false"!==g?this.setAttribute("disabled",g):this.removeAttribute("disabled")}get effect(){return this.getAttribute("effect")}set effect(g){g&&"false"!==g?this.setAttribute("effect",g):this.removeAttribute("effect")}onClick(g){}connectedCallback(){this._div.addEventListener("click",this.onClick),document.addEventListener("DOMContentLoaded",this.initAttribute)}disconnectCallback(){document.removeEventListener("DOMContentLoaded",this.initAttribute)}attributeChangedCallback(g,I,C){var A,i,e,l,t;I!==C&&this.key&&(null==(A=this.parent)?void 0:A.updateAttribute)&&("icon"===g&&(null==(i=this.parent)||i.updateAttribute(this.key,"icon",C)),"iconSize"===g&&(null==(e=this.parent)||e.updateAttribute(this.key,"iconSize",C)),"effect"===g&&(null==(l=this.parent)||l.updateAttribute(this.key,"effect",C)),"disabled"===g&&(null==(t=this.parent)||t.updateAttribute(this.key,"disabled",C)))}}return customElements.define("r-tab",g),g}}(),Ag=Object.freeze(Object.defineProperty({__proto__:null,default:Cg},Symbol.toStringTag,{value:"Module"}));const ig=function(){if("undefined"!=typeof window&&!customElements.get("r-tabs")){class g extends HTMLElement{constructor(){super(),C(this,"_container"),C(this,"_header"),C(this,"_nav"),C(this,"_line"),C(this,"_content"),C(this,"_wrap"),C(this,"_slot"),C(this,"tabHeaderKeyMapIndex"),C(this,"initTabHeaderKeyMapIndex",((g,I)=>{if(this.tabHeaderKeyMapIndex[g])throw new Error("tab 组件的 key 值存在重复, 或者某个 tab 组件缺少 key 属性");this.tabHeaderKeyMapIndex[g]=I})),C(this,"initTabLineAlignCenter",(()=>{const{length:g}=this._nav.children;let I=0;for(let C=0;C{const{length:g}=this._nav.children;let I=0;for(let C=0;C{if(g){const I=this.tabHeaderKeyMapIndex[g],C=this._nav.children[I],{width:A=0}=C.getBoundingClientRect();this._line.style.setProperty("width",`${A}px`);let i=0;for(let g=0;g{if(g){const I=this.tabHeaderKeyMapIndex[g];this._wrap.style.setProperty("transform",`translateX(${-100*I}%)`)}})),C(this,"clickTabHead",(g=>{const I=g.target,C=I.getAttribute("r-key");!Y(I)&&C&&(this.setAttribute("active",C),this.setTabLine(C),this.setTabContent(C),((g,I)=>{const C=g.querySelectorAll(`.${I}`);C.length>0&&C.forEach((g=>g.classList.remove(I)))})(this._nav,"active"),m(I,"active"))})),C(this,"updateAttribute",((g,I,C="")=>{var A,i;const e=this.tabHeaderKeyMapIndex[g];g&&C&&this._nav.children[e]?null==(A=this._nav.children[e])||A.setAttribute(I,C):null==(i=this._nav.children[e])||i.removeAttribute(I)})),C(this,"initActive",(()=>{const g=[...this._nav.children],I=g.filter((g=>!Y(g)));let C;if(null!=this.active&&(C=I.find((g=>g.getAttribute("r-key")===this.active)),null==C||C.setAttribute("r-key",this.active)),C||(C=I.shift()),!C)return;const A=g.findIndex((g=>g===C)),i=(null==C?void 0:C.getAttribute("r-key"))||`${A}`;null!=i&&(this.setAttribute("active",`${i}`),m(C,"active"),this.setTabContent(i),setTimeout((()=>{this.setTabLine(i)}),200))})),C(this,"listenSlotChange",(()=>{this._slot.assignedElements().forEach(((g,I)=>{const C=this.createTabHeader(g,I);this._nav.appendChild(C),C.addEventListener("click",this.clickTabHead)})),this.initActive(),this.align&&("center"===this.align&&this.initTabLineAlignCenter(),"end"===this.align&&this.initTabLineAlignEnd())})),C(this,"initTab",(()=>{this._slot.addEventListener("slotchange",this.listenSlotChange)})),C(this,"unloadTab",(()=>{this._slot.removeEventListener("slotchange",this.listenSlotChange)})),this._container=document.createElement("div"),this._container.setAttribute("class","ran-tab"),this._header=document.createElement("div"),this._header.setAttribute("class","ran-tab-header"),this._nav=document.createElement("div"),this._nav.setAttribute("class","ran-tab-header-nav"),this._line=document.createElement("div"),this._line.setAttribute("class","ran-tab-header-line"),this._content=document.createElement("div"),this._content.setAttribute("class","ran-tab-content"),this._wrap=document.createElement("div"),this._wrap.setAttribute("class","ran-tab-content-wrap"),this._slot=document.createElement("slot"),this._wrap.appendChild(this._slot),this._content.appendChild(this._wrap),this._header.appendChild(G([this._nav,this._line])),this._container.appendChild(G([this._header,this._content])),this.tabHeaderKeyMapIndex={};const g=this.attachShadow({mode:"closed"}),I=document.createElement("style");I.textContent='.remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}html.dark .r-preview-mask .r-preview-contain{background-color:#191919!important}.ran-tab ::slotted(r-tab){box-sizing:border-box;width:100%;height:100%;padding:10px;flex-shrink:0;overflow:auto;text-align:start}.ran-tab-header{position:relative;overflow:hidden;scroll-behavior:smooth}.ran-tab-header-nav{display:flex;flex-flow:row nowrap;justify-content:flex-start;align-items:center}.ran-tab-header-nav::-webkit-scrollbar{display:none}.ran-tab-header-nav-item{flex-shrink:0}.ran-tab-header-nav .active{color:var(--active-color, #1890ff)}.ran-tab-header-line{position:absolute;width:0;margin-top:-2px;height:2px;border-radius:2px;background:var(--line-color, #1890ff);transition:.2s}.ran-tab-content{overflow:hidden}.ran-tab-content-wrap{display:flex;width:100%;height:100%;transition:.2s}:host([type="line"]) .ran-tab-header-nav-item{border:solid 1px transparent}:host([type="line"]) .ran-tab-header-nav .active{color:var(--line-color, #1890ff);border:solid 1px transparent;border-color:var(--border-color, rgba(0, 0, 0, .2)) var(--border-color, rgba(0, 0, 0, .2)) transparent;border-radius:var(--border-radius, .25em) var(--border-radius, .25em) 0 0}:host([type="line"]) .ran-tab-header-line{transition:none;visibility:hidden}:host([type="line"]) .ran-tab-header-line:after,:host([type="line"]) .ran-tab-header-line:before{content:"";position:absolute;visibility:visible;width:9999px;height:1px;bottom:0;background:var(--border-color, rgba(0, 0, 0, .2))}:host([type="line"]) .ran-tab-header-line:after{left:100%}:host([type="line"]) .ran-tab-header-line:before{right:100%}:host([align="center"]) .ran-tab-header-nav{justify-content:center}:host([align="center"]) .ran-tab-header-line{left:50%}:host([align="end"]) .ran-tab-header-nav{justify-content:flex-end}',g.appendChild(I),g.appendChild(this._container)}static get observedAttributes(){return["active","forceRender","type","align","effect"]}get align(){return this.getAttribute("align")||"start"}set align(g){this.setAttribute("align",g)}set type(g){this.setAttribute("type",g)}get type(){return this.getAttribute("type")||"flat"}get active(){return this.getAttribute("active")}set active(g){g?(this.setAttribute("active",g),this.setTabLine(g),this.setTabContent(g)):this.removeAttribute("active")}get effect(){return this.getAttribute("effect")}set effect(g){g&&"false"!==g?this.setAttribute("effect",g):this.removeAttribute("effect")}createTabHeader(g,I){const C=g.getAttribute("label")||"",A=g.getAttribute("icon")||"",i=g.getAttribute("iconSize")||"",e=g.getAttribute("r-key")||`${I}`,l=g.getAttribute("type")||"text";this.initTabHeaderKeyMapIndex(e,I);const t=document.createElement("r-button");return t.setAttribute("class","tab-header-nav-item"),t.setAttribute("type",l),A&&t.setAttribute("icon",A),i&&t.setAttribute("iconSize",i),Y(g)&&t.setAttribute("disabled",""),t.setAttribute("r-key",e),this.effect&&(g.setAttribute("effect",this.effect),this._line.style.setProperty("display","none")),g.setAttribute("r-key",e),t.innerHTML=C,t}connectedCallback(){this.initTab()}disconnectCallback(){this.unloadTab()}attributeChangedCallback(g,I,C){if(I!==C){if(this.dispatchEvent(new CustomEvent("change",{detail:{active:this.active}})),"align"===g&&("center"===C&&this.initTabLineAlignCenter(),"end"===C&&this.initTabLineAlignEnd()),"effect"===g){[...this._nav.children].forEach((g=>{this.effect&&"false"!==this.effect?g.setAttribute("effect",C):g.removeAttribute("effect")}))}"active"===g&&this.setAttribute(g,C)}}}return customElements.define("r-tabs",g),g}}(),eg=Object.freeze(Object.defineProperty({__proto__:null,default:ig},Symbol.toStringTag,{value:"Module"})),lg="#e6e6e6",tg="#e6e6e6",sg="rgba(255,121,35,0.60)",cg="rgba(255,121,35,0.60)";const dg=function(){if("undefined"==typeof document||customElements.get("r-radar"))return R("document is undefined or r-radar is exist");{class g extends HTMLElement{constructor(){super(),C(this,"mData"),C(this,"mCount"),C(this,"mW"),C(this,"mCenter"),C(this,"mRadius"),C(this,"mAngle"),C(this,"abilityRadarChartContainer"),C(this,"abilityRadarChart"),C(this,"_iconElement"),C(this,"_shadowDom"),this.abilityRadarChartContainer=document.createElement("div"),this.abilityRadarChartContainer.setAttribute("class","ran-radar"),this.abilityRadarChart=document.createElement("canvas"),this.abilityRadarChart.style.setProperty("width","100%"),this.abilityRadarChart.style.setProperty("height","100%"),this.abilityRadarChartContainer.appendChild(this.abilityRadarChart);const g=this.attachShadow({mode:"closed"}),I=document.createElement("style");I.textContent=".remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}html.dark .r-preview-mask .r-preview-contain{background-color:#191919!important}.ran-radar{position:relative;width:100%;height:100%;display:block}",g.appendChild(I),this._shadowDom=g,g.appendChild(this.abilityRadarChartContainer)}static get observedAttributes(){return["abilitys","colorPolygon","colorLine","fillColor","strokeColor"]}get abilitys(){const g=this.getAttribute("abilitys");if("string"==typeof g)try{return JSON.parse(g)}catch(I){return g}return g}set abilitys(g){"string"==typeof g?this.setAttribute("abilitys",g||""):this.setAttribute("abilitys",JSON.stringify(g)||"")}get colorPolygon(){return this.getAttribute("colorPolygon")||lg}set colorPolygon(g){this.setAttribute("colorPolygon",g||lg)}get colorLine(){return this.getAttribute("colorLine")||tg}set colorLine(g){this.setAttribute("colorLine",g||tg)}get fillColor(){return this.getAttribute("fillColor")||sg}set fillColor(g){this.setAttribute("fillColor",g||sg)}get strokeColor(){return this.getAttribute("strokeColor")||cg}set strokeColor(g){this.setAttribute("strokeColor",g||cg)}refreshData(){var g;const I=this.abilityRadarChart.getContext("2d");if(!this.abilityRadarChartContainer||!I)return;const C=r(I),A=this.abilityRadarChartContainer.clientWidth*C,i=this.abilityRadarChartContainer.clientHeight*C;this.abilityRadarChart.width=A,this.abilityRadarChart.height=i,this.mW=A,this.mData=this.abilitys,this.mCount=(null==(g=this.mData)?void 0:g.length)||1,this.mCenter=this.mW/2,this.mRadius=this.mCenter-50*C,this.mAngle=2*Math.PI/this.mCount,this.drawPolygon(I),this.drawSide(I),this.drawLines(I),this.drawText(I),this.drawRegion(I),this.drawCircle(I)}drawSide(g){if(!(this.mRadius&&this.mCount&&this.mCenter&&this.mAngle))return;g.save(),g.strokeStyle=this.colorLine;const I=this.mRadius;for(let C=0;C=0&&this.mAngle*t=Math.PI/2&&this.mAngle*t=Math.PI&&this.mAngle*t<3*Math.PI/2?this.drawButton(g,d,s-44*e,c-24*e,44*e,24*e,12*e,this.mData[t].abilityName,o,n,a):this.drawButton(g,d,s-44*e,c,44*e,24*e,12*e,this.mData[t].abilityName,o,n,a)}g.restore()}drawButton(g,I,C,A,i,e,l,t,s,c,d){g.beginPath();const o=r(g);g.fillStyle=I,g.moveTo(C+l,A),g.lineTo(C+i-l,A),g.arc(C+i-l,A+l,l,3*Math.PI/2,2*Math.PI),g.lineTo(C+i,A+e-l),g.arc(C+i-l,A+e-l,l,Math.PI,Math.PI/2),g.lineTo(C+l,A+e),g.arc(C+l,A+e-l,l,Math.PI/2,Math.PI),g.lineTo(C,A+l),g.arc(C+l,A+l,l,Math.PI,3*Math.PI/2),g.fill(),g.closePath(),g.beginPath(),g.fillStyle=s,g.font=`${d||12*o}px ${c}`,g.textAlign="center",g.textBaseline="middle",g.fillText(t,C+i/2,A+e/2)}drawRegion(g){if(!(this.mRadius&&this.mCount&&this.mCenter&&this.mAngle&&this.mData))return;const I=r(g);g.save(),g.beginPath();for(let C=0;Cg.length)&&(I=g.length);for(var C=0,A=new Array(I);C=g.length?{done:!0}:{done:!1,value:g[A++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function b(g){var I=function(g,I){if("object"!=typeof g||null===g)return g;var C=g[Symbol.toPrimitive];if(void 0!==C){var A=C.call(g,"string");if("object"!=typeof A)return A;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(g)}(g);return"symbol"==typeof I?I:String(I)}var r,m,h,G,u,B={exports:{}};r=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,m=/^(?=([^\/?#]*))\1([^]*)$/,h=/(?:\/|^)\.(?=\/)/g,G=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,B.exports=u={buildAbsoluteURL:function(g,I,C){if(C=C||{},g=g.trim(),!(I=I.trim())){if(!C.alwaysNormalize)return g;var A=u.parseURL(g);if(!A)throw new Error("Error trying to parse base URL.");return A.path=u.normalizePath(A.path),u.buildURLFromParts(A)}var i=u.parseURL(I);if(!i)throw new Error("Error trying to parse relative URL.");if(i.scheme)return C.alwaysNormalize?(i.path=u.normalizePath(i.path),u.buildURLFromParts(i)):I;var e=u.parseURL(g);if(!e)throw new Error("Error trying to parse base URL.");if(!e.netLoc&&e.path&&"/"!==e.path[0]){var l=m.exec(e.path);e.netLoc=l[1],e.path=l[2]}e.netLoc&&!e.path&&(e.path="/");var t={scheme:e.scheme,netLoc:i.netLoc,path:null,params:i.params,query:i.query,fragment:i.fragment};if(!i.netLoc&&(t.netLoc=e.netLoc,"/"!==i.path[0]))if(i.path){var s=e.path,c=s.substring(0,s.lastIndexOf("/")+1)+i.path;t.path=u.normalizePath(c)}else t.path=e.path,i.params||(t.params=e.params,i.query||(t.query=e.query));return null===t.path&&(t.path=C.alwaysNormalize?u.normalizePath(i.path):i.path),u.buildURLFromParts(t)},parseURL:function(g){var I=r.exec(g);return I?{scheme:I[1]||"",netLoc:I[2]||"",path:I[3]||"",params:I[4]||"",query:I[5]||"",fragment:I[6]||""}:null},normalizePath:function(g){for(g=g.split("").reverse().join("").replace(h,"");g.length!==(g=g.replace(G,"")).length;);return g.split("").reverse().join("")},buildURLFromParts:function(g){return g.scheme+g.netLoc+g.path+g.params+g.query+g.fragment}};var w=B.exports,W=Number.isFinite||function(g){return"number"==typeof g&&isFinite(g)},p=function(g){return g.MEDIA_ATTACHING="hlsMediaAttaching",g.MEDIA_ATTACHED="hlsMediaAttached",g.MEDIA_DETACHING="hlsMediaDetaching",g.MEDIA_DETACHED="hlsMediaDetached",g.BUFFER_RESET="hlsBufferReset",g.BUFFER_CODECS="hlsBufferCodecs",g.BUFFER_CREATED="hlsBufferCreated",g.BUFFER_APPENDING="hlsBufferAppending",g.BUFFER_APPENDED="hlsBufferAppended",g.BUFFER_EOS="hlsBufferEos",g.BUFFER_FLUSHING="hlsBufferFlushing",g.BUFFER_FLUSHED="hlsBufferFlushed",g.MANIFEST_LOADING="hlsManifestLoading",g.MANIFEST_LOADED="hlsManifestLoaded",g.MANIFEST_PARSED="hlsManifestParsed",g.LEVEL_SWITCHING="hlsLevelSwitching",g.LEVEL_SWITCHED="hlsLevelSwitched",g.LEVEL_LOADING="hlsLevelLoading",g.LEVEL_LOADED="hlsLevelLoaded",g.LEVEL_UPDATED="hlsLevelUpdated",g.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",g.LEVELS_UPDATED="hlsLevelsUpdated",g.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",g.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",g.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",g.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",g.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",g.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",g.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",g.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",g.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",g.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",g.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",g.CUES_PARSED="hlsCuesParsed",g.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",g.INIT_PTS_FOUND="hlsInitPtsFound",g.FRAG_LOADING="hlsFragLoading",g.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",g.FRAG_LOADED="hlsFragLoaded",g.FRAG_DECRYPTED="hlsFragDecrypted",g.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",g.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",g.FRAG_PARSING_METADATA="hlsFragParsingMetadata",g.FRAG_PARSED="hlsFragParsed",g.FRAG_BUFFERED="hlsFragBuffered",g.FRAG_CHANGED="hlsFragChanged",g.FPS_DROP="hlsFpsDrop",g.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",g.ERROR="hlsError",g.DESTROYING="hlsDestroying",g.KEY_LOADING="hlsKeyLoading",g.KEY_LOADED="hlsKeyLoaded",g.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",g.BACK_BUFFER_REACHED="hlsBackBufferReached",g}({}),V=function(g){return g.NETWORK_ERROR="networkError",g.MEDIA_ERROR="mediaError",g.KEY_SYSTEM_ERROR="keySystemError",g.MUX_ERROR="muxError",g.OTHER_ERROR="otherError",g}({}),y=function(g){return g.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",g.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",g.KEY_SYSTEM_NO_SESSION="keySystemNoSession",g.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",g.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",g.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",g.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",g.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",g.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",g.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",g.MANIFEST_LOAD_ERROR="manifestLoadError",g.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",g.MANIFEST_PARSING_ERROR="manifestParsingError",g.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",g.LEVEL_EMPTY_ERROR="levelEmptyError",g.LEVEL_LOAD_ERROR="levelLoadError",g.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",g.LEVEL_PARSING_ERROR="levelParsingError",g.LEVEL_SWITCH_ERROR="levelSwitchError",g.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",g.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",g.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",g.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",g.FRAG_LOAD_ERROR="fragLoadError",g.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",g.FRAG_DECRYPT_ERROR="fragDecryptError",g.FRAG_PARSING_ERROR="fragParsingError",g.FRAG_GAP="fragGap",g.REMUX_ALLOC_ERROR="remuxAllocError",g.KEY_LOAD_ERROR="keyLoadError",g.KEY_LOAD_TIMEOUT="keyLoadTimeOut",g.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",g.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",g.BUFFER_APPEND_ERROR="bufferAppendError",g.BUFFER_APPENDING_ERROR="bufferAppendingError",g.BUFFER_STALLED_ERROR="bufferStalledError",g.BUFFER_FULL_ERROR="bufferFullError",g.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",g.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",g.INTERNAL_EXCEPTION="internalException",g.INTERNAL_ABORTED="aborted",g.UNKNOWN="unknown",g}({}),X=function(){},Y={trace:X,debug:X,log:X,warn:X,info:X,error:X},R=Y;function N(g,I){if(self.console&&!0===g||"object"==typeof g){!function(g){for(var I=arguments.length,C=new Array(I>1?I-1:0),A=1;A"):X}(I)}))}(g,"debug","log","info","warn","error");try{R.log('Debug logs enabled for "'+I+'" in hls.js version 1.4.12')}catch(C){R=Y}}else R=Y}var H=R,K=/^(\d+)x(\d+)$/,F=/(.+?)=(".*?"|.*?)(?:,|$)/g,M=function(){function g(I){for(var C in"string"==typeof I&&(I=g.parseAttrList(I)),I)I.hasOwnProperty(C)&&("X-"===C.substring(0,2)&&(this.clientAttrs=this.clientAttrs||[],this.clientAttrs.push(C)),this[C]=I[C])}var I=g.prototype;return I.decimalInteger=function(g){var I=parseInt(this[g],10);return I>Number.MAX_SAFE_INTEGER?1/0:I},I.hexadecimalInteger=function(g){if(this[g]){var I=(this[g]||"0x").slice(2);I=(1&I.length?"0":"")+I;for(var C=new Uint8Array(I.length/2),A=0;ANumber.MAX_SAFE_INTEGER?1/0:I},I.decimalFloatingPoint=function(g){return parseFloat(this[g])},I.optionalFloat=function(g,I){var C=this[g];return C?parseFloat(C):I},I.enumeratedString=function(g){return this[g]},I.bool=function(g){return"YES"===this[g]},I.decimalResolution=function(g){var I=K.exec(this[g]);if(null!==I)return{width:parseInt(I[1],10),height:parseInt(I[2],10)}},g.parseAttrList=function(g){var I,C={};for(F.lastIndex=0;null!==(I=F.exec(g));){var A=I[2];0===A.indexOf('"')&&A.lastIndexOf('"')===A.length-1&&(A=A.slice(1,-1)),C[I[1].trim()]=A}return C},g}();function J(g){return"SCTE35-OUT"===g||"SCTE35-IN"===g}var S=function(){function g(g,I){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,I){var C=I.attr;for(var A in C)if(Object.prototype.hasOwnProperty.call(g,A)&&g[A]!==C[A]){H.warn('DATERANGE tag attribute: "'+A+'" does not match for tags with ID: "'+g.ID+'"'),this._badValueForSameId=A;break}g=t(new M({}),C,g)}if(this.attr=g,this._startDate=new Date(g["START-DATE"]),"END-DATE"in this.attr){var i=new Date(this.attr["END-DATE"]);W(i.getTime())&&(this._endDate=i)}}return e(g,[{key:"id",get:function(){return this.attr.ID}},{key:"class",get:function(){return this.attr.CLASS}},{key:"startDate",get:function(){return this._startDate}},{key:"endDate",get:function(){if(this._endDate)return this._endDate;var g=this.duration;return null!==g?new Date(this._startDate.getTime()+1e3*g):null}},{key:"duration",get:function(){if("DURATION"in this.attr){var g=this.attr.decimalFloatingPoint("DURATION");if(W(g))return g}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}},{key:"plannedDuration",get:function(){return"PLANNED-DURATION"in this.attr?this.attr.decimalFloatingPoint("PLANNED-DURATION"):null}},{key:"endOnNext",get:function(){return this.attr.bool("END-ON-NEXT")}},{key:"isValid",get:function(){return!!this.id&&!this._badValueForSameId&&W(this.startDate.getTime())&&(null===this.duration||this.duration>=0)&&(!this.endOnNext||!!this.class)}}]),g}(),f=function(){this.aborted=!1,this.loaded=0,this.retry=0,this.total=0,this.chunkCount=0,this.bwEstimate=0,this.loading={start:0,first:0,end:0},this.parsing={start:0,end:0},this.buffering={start:0,first:0,end:0}},k="audio",D="video",L="audiovideo",z=function(){function g(g){var I;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=((I={})[k]=null,I[D]=null,I[L]=null,I),this.baseurl=g}return g.prototype.setByteRange=function(g,I){var C=g.split("@",2),A=[];1===C.length?A[0]=I?I.byteRangeEndOffset:0:A[0]=parseInt(C[1]),A[1]=parseInt(C[0])+A[0],this._byteRange=A},e(g,[{key:"byteRange",get:function(){return this._byteRange?this._byteRange:[]}},{key:"byteRangeStartOffset",get:function(){return this.byteRange[0]}},{key:"byteRangeEndOffset",get:function(){return this.byteRange[1]}},{key:"url",get:function(){return!this._url&&this.baseurl&&this.relurl&&(this._url=w.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(g){this._url=g}}]),g}(),v=function(g){function I(I,C){var A;return(A=g.call(this,C)||this)._decryptdata=null,A.rawProgramDateTime=null,A.programDateTime=null,A.tagList=[],A.duration=0,A.sn=0,A.levelkeys=void 0,A.type=void 0,A.loader=null,A.keyLoader=null,A.level=-1,A.cc=0,A.startPTS=void 0,A.endPTS=void 0,A.startDTS=void 0,A.endDTS=void 0,A.start=0,A.deltaPTS=void 0,A.maxStartPTS=void 0,A.minEndPTS=void 0,A.stats=new f,A.urlId=0,A.data=void 0,A.bitrateTest=!1,A.title=null,A.initSegment=null,A.endList=void 0,A.gap=void 0,A.type=I,A}s(I,g);var C=I.prototype;return C.setKeyFormat=function(g){if(this.levelkeys){var I=this.levelkeys[g];I&&!this._decryptdata&&(this._decryptdata=I.getDecryptData(this.sn))}},C.abortRequests=function(){var g,I;null==(g=this.loader)||g.abort(),null==(I=this.keyLoader)||I.abort()},C.setElementaryStreamInfo=function(g,I,C,A,i,e){void 0===e&&(e=!1);var l=this.elementaryStreams,t=l[g];t?(t.startPTS=Math.min(t.startPTS,I),t.endPTS=Math.max(t.endPTS,C),t.startDTS=Math.min(t.startDTS,A),t.endDTS=Math.max(t.endDTS,i)):l[g]={startPTS:I,endPTS:C,startDTS:A,endDTS:i,partial:e}},C.clearElementaryStreamInfo=function(){var g=this.elementaryStreams;g[k]=null,g[D]=null,g[L]=null},e(I,[{key:"decryptdata",get:function(){if(!this.levelkeys&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){var g=this.levelkeys.identity;if(g)this._decryptdata=g.getDecryptData(this.sn);else{var I=Object.keys(this.levelkeys);if(1===I.length)return this._decryptdata=this.levelkeys[I[0]].getDecryptData(this.sn)}}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(null===this.programDateTime)return null;if(!W(this.programDateTime))return null;var g=W(this.duration)?this.duration:0;return this.programDateTime+1e3*g}},{key:"encrypted",get:function(){var g;if(null!=(g=this._decryptdata)&&g.encrypted)return!0;if(this.levelkeys){var I=Object.keys(this.levelkeys),C=I.length;if(C>1||1===C&&this.levelkeys[I[0]].encrypted)return!0}return!1}}]),I}(z),T=function(g){function I(I,C,A,i,e){var l;(l=g.call(this,A)||this).fragOffset=0,l.duration=0,l.gap=!1,l.independent=!1,l.relurl=void 0,l.fragment=void 0,l.index=void 0,l.stats=new f,l.duration=I.decimalFloatingPoint("DURATION"),l.gap=I.bool("GAP"),l.independent=I.bool("INDEPENDENT"),l.relurl=I.enumeratedString("URI"),l.fragment=C,l.index=i;var t=I.enumeratedString("BYTERANGE");return t&&l.setByteRange(t,e),e&&(l.fragOffset=e.fragOffset+e.duration),l}return s(I,g),e(I,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var g=this.elementaryStreams;return!!(g.audio||g.video||g.audiovideo)}}]),I}(z),x=function(){function g(g){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.live=!0,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 0,this.misses=0,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.encryptedFragments=void 0,this.playlistParsingError=null,this.variableList=null,this.hasVariableRefs=!1,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=g}return g.prototype.reloaded=function(g){if(!g)return this.advanced=!0,void(this.updated=!0);var I=this.lastPartSn-g.lastPartSn,C=this.lastPartIndex-g.lastPartIndex;this.updated=this.endSN!==g.endSN||!!C||!!I||!this.live,this.advanced=this.endSN>g.endSN||I>0||0===I&&C>0,this.updated||this.advanced?this.misses=Math.floor(.6*g.misses):this.misses=g.misses+1,this.availabilityDelay=g.availabilityDelay},e(g,[{key:"hasProgramDateTime",get:function(){return!!this.fragments.length&&W(this.fragments[this.fragments.length-1].programDateTime)}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||10}},{key:"drift",get:function(){var g=this.driftEndTime-this.driftStartTime;return g>0?1e3*(this.driftEnd-this.driftStart)/g:1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var g;return null!=(g=this.partList)&&g.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var g;return null!=(g=this.fragments)&&g.length?this.fragments[this.fragments.length-1].end:0}},{key:"age",get:function(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}},{key:"lastPartIndex",get:function(){var g;return null!=(g=this.partList)&&g.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var g;return null!=(g=this.partList)&&g.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}]),g}();function U(g){return Uint8Array.from(atob(g),(function(g){return g.charCodeAt(0)}))}function Q(g){return Uint8Array.from(unescape(encodeURIComponent(g)),(function(g){return g.charCodeAt(0)}))}var j={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},O="org.w3.clearkey",E="com.apple.streamingkeydelivery",P="com.microsoft.playready",_="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed";function q(g){switch(g){case E:return j.FAIRPLAY;case P:return j.PLAYREADY;case _:return j.WIDEVINE;case O:return j.CLEARKEY}}var $="edef8ba979d64acea3c827dcd51d21ed";function gg(g){switch(g){case j.FAIRPLAY:return E;case j.PLAYREADY:return P;case j.WIDEVINE:return _;case j.CLEARKEY:return O}}function Ig(g){var I=g.drmSystems,C=g.widevineLicenseUrl,A=I?[j.FAIRPLAY,j.WIDEVINE,j.PLAYREADY,j.CLEARKEY].filter((function(g){return!!I[g]})):[];return!A[j.WIDEVINE]&&C&&A.push(j.WIDEVINE),A}var Cg="undefined"!=typeof self&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null;function Ag(g,I,C){return Uint8Array.prototype.slice?g.slice(I,C):new Uint8Array(Array.prototype.slice.call(g,I,C))}var ig,eg=function(g,I){return I+10<=g.length&&73===g[I]&&68===g[I+1]&&51===g[I+2]&&g[I+3]<255&&g[I+4]<255&&g[I+6]<128&&g[I+7]<128&&g[I+8]<128&&g[I+9]<128},lg=function(g,I){return I+10<=g.length&&51===g[I]&&68===g[I+1]&&73===g[I+2]&&g[I+3]<255&&g[I+4]<255&&g[I+6]<128&&g[I+7]<128&&g[I+8]<128&&g[I+9]<128},tg=function(g,I){for(var C=I,A=0;eg(g,I);)A+=10,A+=sg(g,I+6),lg(g,I+10)&&(A+=10),I+=A;if(A>0)return g.subarray(C,C+A)},sg=function(g,I){var C=0;return C=(127&g[I])<<21,C|=(127&g[I+1])<<14,(C|=(127&g[I+2])<<7)|127&g[I+3]},cg=function(g,I){return eg(g,I)&&sg(g,I+6)+10<=g.length-I},dg=function(g){return g&&"PRIV"===g.key&&"com.apple.streaming.transportStreamTimestamp"===g.info},og=function(g){var I=String.fromCharCode(g[0],g[1],g[2],g[3]),C=sg(g,4);return{type:I,size:C,data:g.subarray(10,10+C)}},ng=function(g){for(var I=0,C=[];eg(g,I);){for(var A=sg(g,I+6),i=(I+=10)+A;I+8>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:c+=String.fromCharCode(e);break;case 12:case 13:l=g[d++],c+=String.fromCharCode((31&e)<<6|63&l);break;case 14:l=g[d++],t=g[d++],c+=String.fromCharCode((15&e)<<12|(63&l)<<6|63&t)}}return c};var Gg=function(g){for(var I="",C=0;C>24,g[I+1]=C>>16&255,g[I+2]=C>>8&255,g[I+3]=255&C}function Yg(g,I){var C=[];if(!I.length)return C;for(var A=g.byteLength,i=0;i1?i+e:A;if(Wg(g.subarray(i+4,i+8))===I[0])if(1===I.length)C.push(g.subarray(i+8,l));else{var t=Yg(g.subarray(i+8,l),I.slice(1));t.length&&Bg.apply(C,t)}i=l}return C}function Rg(g){var I=[],C=g[0],A=8,i=Vg(g,A);A+=4,A+=0===C?8:16,A+=2;var e=g.length+0,l=pg(g,A);A+=2;for(var t=0;t>>31)return H.warn("SIDX has hierarchical references (not supported)"),null;var o=Vg(g,s);s+=4,I.push({referenceSize:d,subsegmentDuration:o,info:{duration:o/i,start:e,end:e+d-1}}),e+=d,A=s+=4}return{earliestPresentationTime:0,timescale:i,version:C,referencesCount:l,references:I}}function Ng(g){for(var I=[],C=Yg(g,["moov","trak"]),A=0;A>1&63;return 39===C||40===C}return 6==(31&I)}function Sg(g,I,C,A){var i=fg(g),e=0;e+=I;for(var l=0,t=0,s=!1,c=0;e=i.length)break;l+=c=i[e++]}while(255===c);t=0;do{if(e>=i.length)break;t+=c=i[e++]}while(255===c);var d=i.length-e;if(!s&&4===l&&e16){for(var G=[],u=0;u<16;u++){var B=i[e++].toString(16);G.push(1==B.length?"0"+B:B),3!==u&&5!==u&&7!==u&&9!==u||G.push("-")}for(var w=t-16,W=new Uint8Array(w),p=0;pd)break}}function fg(g){for(var I=g.byteLength,C=[],A=1;A>8*(15-C)&255;return I}(I);return new g(this.method,this.uri,"identity",this.keyFormatVersions,C)}var A,i,e=function(g){var I,C,A=g.split(":"),i=null;if("data"===A[0]&&2===A.length){var e=A[1].split(";"),l=e[e.length-1].split(",");if(2===l.length){var t="base64"===l[0],s=l[1];t?(e.splice(-1,1),i=U(s)):(I=Q(s).subarray(0,16),(C=new Uint8Array(16)).set(I,16-I.length),i=C)}}return i}(this.uri);if(e)switch(this.keyFormat){case _:this.pssh=e,e.length>=22&&(this.keyId=e.subarray(e.length-22,e.length-6));break;case P:var l=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=function(g,I,C){if(16!==g.byteLength)throw new RangeError("Invalid system id");var A,i;A=new Uint8Array,i=new Uint8Array;var e=new Uint8Array(4);return C&&C.byteLength>0&&new DataView(e.buffer).setUint32(0,C.byteLength,!1),function(g){for(var I=arguments.length,C=new Array(I>1?I-1:0),A=1;A>24&255,t[1]=e>>16&255,t[2]=e>>8&255,t[3]=255&e,t.set(g,4),l=0,e=8;l2){var C=I.shift()+".";return(C+=parseInt(I.shift()).toString(16))+("000"+parseInt(I.shift()).toString(16)).slice(-4)}return g},g.resolve=function(g,I){return w.buildAbsoluteURL(I,g,{alwaysNormalize:!0})},g.isMediaPlaylist=function(g){return qg.test(g)},g.parseMasterPlaylist=function(I,C){var A,i={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:zg(I)},e=[];for(Pg.lastIndex=0;null!=(A=Pg.exec(I));)if(A[1]){var l,t=new M(A[1]);vg(i,t,["CODECS","SUPPLEMENTAL-CODECS","ALLOWED-CPC","PATHWAY-ID","STABLE-VARIANT-ID","AUDIO","VIDEO","SUBTITLES","CLOSED-CAPTIONS","NAME"]);var s=Tg(i,A[2]),c={attrs:t,bitrate:t.decimalInteger("AVERAGE-BANDWIDTH")||t.decimalInteger("BANDWIDTH"),name:t.NAME,url:g.resolve(s,C)},d=t.decimalResolution("RESOLUTION");d&&(c.width=d.width,c.height=d.height),iI((t.CODECS||"").split(/[ ,]+/).filter((function(g){return g})),c),c.videoCodec&&-1!==c.videoCodec.indexOf("avc1")&&(c.videoCodec=g.convertAVC1ToAVCOTI(c.videoCodec)),null!=(l=c.unknownCodecs)&&l.length||e.push(c),i.levels.push(c)}else if(A[3]){var o=A[3],n=A[4];switch(o){case"SESSION-DATA":var a=new M(n);vg(i,a,["DATA-ID","LANGUAGE","VALUE","URI"]);var Z=a["DATA-ID"];Z&&(null===i.sessionData&&(i.sessionData={}),i.sessionData[Z]=a);break;case"SESSION-KEY":var b=CI(n,C,i);b.encrypted&&b.isSupported()?(null===i.sessionKeys&&(i.sessionKeys=[]),i.sessionKeys.push(b)):H.warn('[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "'+n+'"');break;case"DEFINE":var r=new M(n);vg(i,r,["NAME","VALUE","QUERYPARAM"]),xg(i,r,C);break;case"CONTENT-STEERING":var m=new M(n);vg(i,m,["SERVER-URI","PATHWAY-ID"]),i.contentSteering={uri:g.resolve(m["SERVER-URI"],C),pathwayId:m["PATHWAY-ID"]||"."};break;case"START":i.startTimeOffset=AI(n)}}var h=e.length>0&&e.length0&&U.bool("CAN-SKIP-DATERANGES"),d.partHoldBack=U.optionalFloat("PART-HOLD-BACK",0),d.holdBack=U.optionalFloat("HOLD-BACK",0);break;case"PART-INF":var Q=new M(X);d.partTarget=Q.decimalFloatingPoint("PART-TARGET");break;case"PART":var j=d.partList;j||(j=d.partList=[]);var O=Z>0?j[j.length-1]:void 0,E=Z++,P=new M(X);vg(d,P,["BYTERANGE","URI"]);var _=new T(P,h,I,E,O);j.push(_),h.duration+=_.duration;break;case"PRELOAD-HINT":var q=new M(X);vg(d,q,["URI"]),d.preloadHint=q;break;case"RENDITION-REPORT":var $=new M(X);vg(d,$,["URI"]),d.renditionReports=d.renditionReports||[],d.renditionReports.push($);break;default:H.warn("line parsed but not handled: "+l)}}}m&&!m.relurl?(o.pop(),b-=m.duration,d.partList&&(d.fragmentHint=m)):d.partList&&(lI(h,m),h.cc=r,d.fragmentHint=h,c&&sI(h,c,d));var gg=o.length,Ig=o[0],Cg=o[gg-1];if((b+=d.skippedSegments*d.targetduration)>0&&gg&&Cg){d.averagetargetduration=b/gg;var Ag=Cg.sn;d.endSN="initSegment"!==Ag?Ag:0,d.live||(Cg.endList=!0),Ig&&(d.startCC=Ig.cc)}else d.endSN=0,d.startCC=0;return d.fragmentHint&&(b+=d.fragmentHint.duration),d.totalduration=b,d.endCC=r,G>0&&function(g,I){for(var C=g[I],A=I;A--;){var i=g[A];if(!i)return;i.programDateTime=C.programDateTime-1e3*i.duration,C=i}}(o,G),d},g}();function CI(g,I,C){var A,i,e=new M(g);vg(C,e,["KEYFORMAT","KEYFORMATVERSIONS","URI","IV","URI"]);var l=null!=(A=e.METHOD)?A:"",t=e.URI,s=e.hexadecimalInteger("IV"),c=e.KEYFORMATVERSIONS,d=null!=(i=e.KEYFORMAT)?i:"identity";t&&e.IV&&!s&&H.error("Invalid IV: "+e.IV);var o=t?II.resolve(t,I):"",n=(c||"1").split("/").map(Number).filter(Number.isFinite);return new Dg(l,o,d,n,s)}function AI(g){var I=new M(g).decimalFloatingPoint("TIME-OFFSET");return W(I)?I:null}function iI(g,I){["video","audio","text"].forEach((function(C){var A=g.filter((function(g){return I=g,!!(A=jg[C])&&!0===A[I.slice(0,4)];var I,A}));if(A.length){var i=A.filter((function(g){return 0===g.lastIndexOf("avc1",0)||0===g.lastIndexOf("mp4a",0)}));I[C+"Codec"]=i.length>0?i[0]:A[0],g=g.filter((function(g){return-1===A.indexOf(g)}))}})),I.unknownCodecs=g}function eI(g,I,C){var A=I[C];A&&(g[C]=A)}function lI(g,I){g.rawProgramDateTime?g.programDateTime=Date.parse(g.rawProgramDateTime):null!=I&&I.programDateTime&&(g.programDateTime=I.endProgramDateTime),W(g.programDateTime)||(g.programDateTime=null,g.rawProgramDateTime=null)}function tI(g,I,C,A){g.relurl=I.URI,I.BYTERANGE&&g.setByteRange(I.BYTERANGE),g.level=C,g.sn="initSegment",A&&(g.levelkeys=A),g.initSegment=null}function sI(g,I,C){g.levelkeys=I;var A=C.encryptedFragments;A.length&&A[A.length-1].levelkeys===I||!Object.keys(I).some((function(g){return I[g].isCommonEncryption}))||A.push(g)}var cI="manifest",dI="level",oI="audioTrack",nI="subtitleTrack",aI="main",ZI="audio",bI="subtitle";function rI(g){switch(g.type){case oI:return ZI;case nI:return bI;default:return aI}}function mI(g,I){var C=g.url;return void 0!==C&&0!==C.indexOf("data:")||(C=I.url),C}var hI=function(){function g(g){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.hls=g,this.registerListeners()}var I=g.prototype;return I.startLoad=function(g){},I.stopLoad=function(){this.destroyInternalLoaders()},I.registerListeners=function(){var g=this.hls;g.on(p.MANIFEST_LOADING,this.onManifestLoading,this),g.on(p.LEVEL_LOADING,this.onLevelLoading,this),g.on(p.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),g.on(p.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},I.unregisterListeners=function(){var g=this.hls;g.off(p.MANIFEST_LOADING,this.onManifestLoading,this),g.off(p.LEVEL_LOADING,this.onLevelLoading,this),g.off(p.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),g.off(p.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},I.createInternalLoader=function(g){var I=this.hls.config,C=I.pLoader,A=I.loader,i=new(C||A)(I);return this.loaders[g.type]=i,i},I.getInternalLoader=function(g){return this.loaders[g.type]},I.resetInternalLoader=function(g){this.loaders[g]&&delete this.loaders[g]},I.destroyInternalLoaders=function(){for(var g in this.loaders){var I=this.loaders[g];I&&I.destroy(),this.resetInternalLoader(g)}},I.destroy=function(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()},I.onManifestLoading=function(g,I){var C=I.url;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:cI,url:C,deliveryDirectives:null})},I.onLevelLoading=function(g,I){var C=I.id,A=I.level,i=I.url,e=I.deliveryDirectives;this.load({id:C,level:A,responseType:"text",type:dI,url:i,deliveryDirectives:e})},I.onAudioTrackLoading=function(g,I){var C=I.id,A=I.groupId,i=I.url,e=I.deliveryDirectives;this.load({id:C,groupId:A,level:null,responseType:"text",type:oI,url:i,deliveryDirectives:e})},I.onSubtitleTrackLoading=function(g,I){var C=I.id,A=I.groupId,i=I.url,e=I.deliveryDirectives;this.load({id:C,groupId:A,level:null,responseType:"text",type:nI,url:i,deliveryDirectives:e})},I.load=function(g){var I,C,A,i=this,e=this.hls.config,l=this.getInternalLoader(g);if(l){var s=l.context;if(s&&s.url===g.url)return void H.trace("[playlist-loader]: playlist request ongoing");H.log("[playlist-loader]: aborting previous loader for type: "+g.type),l.abort()}if(C=g.type===cI?e.manifestLoadPolicy.default:t({},e.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),l=this.createInternalLoader(g),null!=(I=g.deliveryDirectives)&&I.part&&(g.type===dI&&null!==g.level?A=this.hls.levels[g.level].details:g.type===oI&&null!==g.id?A=this.hls.audioTracks[g.id].details:g.type===nI&&null!==g.id&&(A=this.hls.subtitleTracks[g.id].details),A)){var c=A.partTarget,d=A.targetduration;if(c&&d){var o=1e3*Math.max(3*c,.8*d);C=t({},C,{maxTimeToFirstByteMs:Math.min(o,C.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(o,C.maxTimeToFirstByteMs)})}}var n=C.errorRetry||C.timeoutRetry||{},a={loadPolicy:C,timeout:C.maxLoadTimeMs,maxRetry:n.maxNumRetry||0,retryDelay:n.retryDelayMs||0,maxRetryDelay:n.maxRetryDelayMs||0},Z={onSuccess:function(g,I,C,A){var e=i.getInternalLoader(C);i.resetInternalLoader(C.type);var l=g.data;0===l.indexOf("#EXTM3U")?(I.parsing.start=performance.now(),II.isMediaPlaylist(l)?i.handleTrackOrLevelPlaylist(g,I,C,A||null,e):i.handleMasterPlaylist(g,I,C,A)):i.handleManifestParsingError(g,C,new Error("no EXTM3U delimiter"),A||null,I)},onError:function(g,I,C,A){i.handleNetworkError(I,C,!1,g,A)},onTimeout:function(g,I,C){i.handleNetworkError(I,C,!0,void 0,g)}};l.load(g,a,Z)},I.handleMasterPlaylist=function(g,I,C,A){var i=this.hls,e=g.data,l=mI(g,C),t=II.parseMasterPlaylist(e,l);if(t.playlistParsingError)this.handleManifestParsingError(g,C,t.playlistParsingError,A,I);else{var s=t.contentSteering,c=t.levels,d=t.sessionData,o=t.sessionKeys,n=t.startTimeOffset,a=t.variableList;this.variableList=a;var Z=II.parseMasterPlaylistMedia(e,l,t),b=Z.AUDIO,r=void 0===b?[]:b,m=Z.SUBTITLES,h=Z["CLOSED-CAPTIONS"];r.length&&(r.some((function(g){return!g.url}))||!c[0].audioCodec||c[0].attrs.AUDIO||(H.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),r.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new M({}),bitrate:0,url:""}))),i.trigger(p.MANIFEST_LOADED,{levels:c,audioTracks:r,subtitles:m,captions:h,contentSteering:s,url:l,stats:I,networkDetails:A,sessionData:d,sessionKeys:o,startTimeOffset:n,variableList:a})}},I.handleTrackOrLevelPlaylist=function(g,I,C,A,i){var e=this.hls,l=C.id,t=C.level,s=C.type,c=mI(g,C),d=W(l)?l:0,o=W(t)?t:d,n=rI(C),a=II.parseLevelPlaylist(g.data,c,o,n,d,this.variableList);if(s===cI){var Z={attrs:new M({}),bitrate:0,details:a,name:"",url:c};e.trigger(p.MANIFEST_LOADED,{levels:[Z],audioTracks:[],url:c,stats:I,networkDetails:A,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}I.parsing.end=performance.now(),C.levelDetails=a,this.handlePlaylistLoaded(a,g,I,C,A,i)},I.handleManifestParsingError=function(g,I,C,A,i){this.hls.trigger(p.ERROR,{type:V.NETWORK_ERROR,details:y.MANIFEST_PARSING_ERROR,fatal:I.type===cI,url:g.url,err:C,error:C,reason:C.message,response:g,context:I,networkDetails:A,stats:i})},I.handleNetworkError=function(g,I,C,i,e){void 0===C&&(C=!1);var l="A network "+(C?"timeout":"error"+(i?" (status "+i.code+")":""))+" occurred while loading "+g.type;g.type===dI?l+=": "+g.level+" id: "+g.id:g.type!==oI&&g.type!==nI||(l+=" id: "+g.id+' group-id: "'+g.groupId+'"');var t=new Error(l);H.warn("[playlist-loader]: "+l);var s=y.UNKNOWN,c=!1,d=this.getInternalLoader(g);switch(g.type){case cI:s=C?y.MANIFEST_LOAD_TIMEOUT:y.MANIFEST_LOAD_ERROR,c=!0;break;case dI:s=C?y.LEVEL_LOAD_TIMEOUT:y.LEVEL_LOAD_ERROR,c=!1;break;case oI:s=C?y.AUDIO_TRACK_LOAD_TIMEOUT:y.AUDIO_TRACK_LOAD_ERROR,c=!1;break;case nI:s=C?y.SUBTITLE_TRACK_LOAD_TIMEOUT:y.SUBTITLE_LOAD_ERROR,c=!1}d&&this.resetInternalLoader(g.type);var o={type:V.NETWORK_ERROR,details:s,fatal:c,url:g.url,loader:d,context:g,error:t,networkDetails:I,stats:e};if(i){var n=(null==I?void 0:I.url)||g.url;o.response=A({url:n,data:void 0},i)}this.hls.trigger(p.ERROR,o)},I.handlePlaylistLoaded=function(g,I,C,A,i,e){var l=this.hls,t=A.type,s=A.level,c=A.id,d=A.groupId,o=A.deliveryDirectives,n=mI(I,A),a=rI(A),Z="number"==typeof A.level&&a===aI?s:void 0;if(g.fragments.length){g.targetduration||(g.playlistParsingError=new Error("Missing Target Duration"));var b=g.playlistParsingError;if(b)l.trigger(p.ERROR,{type:V.NETWORK_ERROR,details:y.LEVEL_PARSING_ERROR,fatal:!1,url:n,error:b,reason:b.message,response:I,context:A,level:Z,parent:a,networkDetails:i,stats:C});else switch(g.live&&e&&(e.getCacheAge&&(g.ageHeader=e.getCacheAge()||0),e.getCacheAge&&!isNaN(g.ageHeader)||(g.ageHeader=0)),t){case cI:case dI:l.trigger(p.LEVEL_LOADED,{details:g,level:Z||0,id:c||0,stats:C,networkDetails:i,deliveryDirectives:o});break;case oI:l.trigger(p.AUDIO_TRACK_LOADED,{details:g,id:c||0,groupId:d||"",stats:C,networkDetails:i,deliveryDirectives:o});break;case nI:l.trigger(p.SUBTITLE_TRACK_LOADED,{details:g,id:c||0,groupId:d||"",stats:C,networkDetails:i,deliveryDirectives:o})}}else{var r=new Error("No Segments found in Playlist");l.trigger(p.ERROR,{type:V.NETWORK_ERROR,details:y.LEVEL_EMPTY_ERROR,fatal:!1,url:n,error:r,reason:r.message,response:I,context:A,level:Z,parent:a,networkDetails:i,stats:C})}},g}();function GI(g,I){var C;try{C=new Event("addtrack")}catch(A){(C=document.createEvent("Event")).initEvent("addtrack",!1,!1)}C.track=g,I.dispatchEvent(C)}function uI(g,I){var C=g.mode;if("disabled"===C&&(g.mode="hidden"),g.cues&&!g.cues.getCueById(I.id))try{if(g.addCue(I),!g.cues.getCueById(I.id))throw new Error("addCue is failed for: "+I)}catch(i){H.debug("[texttrack-utils]: "+i);try{var A=new self.TextTrackCue(I.startTime,I.endTime,I.text);A.id=I.id,g.addCue(A)}catch(e){H.debug("[texttrack-utils]: Legacy TextTrackCue fallback failed: "+e)}}"disabled"===C&&(g.mode=C)}function BI(g){var I=g.mode;if("disabled"===I&&(g.mode="hidden"),g.cues)for(var C=g.cues.length;C--;)g.removeCue(g.cues[C]);"disabled"===I&&(g.mode=I)}function wI(g,I,C,A){var i=g.mode;if("disabled"===i&&(g.mode="hidden"),g.cues&&g.cues.length>0)for(var e=function(g,I,C){var A=[],i=function(g,I){if(Ig[C].endTime)return-1;for(var A=0,i=C;A<=i;){var e=Math.floor((i+A)/2);if(Ig[e].startTime&&A-1)for(var e=i,l=g.length;e=I&&t.endTime<=C)A.push(t);else if(t.startTime>C)return A}return A}(g.cues,I,C),l=0;lyI&&(o=yI),o-d<=0&&(o=d+.25);for(var n=0;nI.startDate&&g.push(A),g}),[]).sort((function(g,I){return g.startDate.getTime()-I.startDate.getTime()}))[0];Z&&(d=XI(Z.startDate,n),s=!0)}for(var r,m,h=Object.keys(I.attr),G=0;G.05&&this.forwardBufferLength>1){var c=Math.min(2,Math.max(1,e)),d=Math.round(2/(1+Math.exp(-.75*t-this.edgeStalled))*20)/20;g.playbackRate=Math.min(c,Math.max(1,d))}else 1!==g.playbackRate&&0!==g.playbackRate&&(g.playbackRate=1)}}}}},I.estimateLiveEdge=function(){var g=this.levelDetails;return null===g?null:g.edge+g.age},I.computeLatency=function(){var g=this.estimateLiveEdge();return null===g?null:g-this.currentTime},e(g,[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var g=this.config,I=this.levelDetails;return void 0!==g.liveMaxLatencyDuration?g.liveMaxLatencyDuration:I?g.liveMaxLatencyDurationCount*I.targetduration:0}},{key:"targetLatency",get:function(){var g=this.levelDetails;if(null===g)return null;var I=g.holdBack,C=g.partHoldBack,A=g.targetduration,i=this.config,e=i.liveSyncDuration,l=i.liveSyncDurationCount,t=i.lowLatencyMode,s=this.hls.userConfig,c=t&&C||I;(s.liveSyncDuration||s.liveSyncDurationCount||0===c)&&(c=void 0!==e?e:l*A);var d=A;return c+Math.min(1*this.stallCount,d)}},{key:"liveSyncPosition",get:function(){var g=this.estimateLiveEdge(),I=this.targetLatency,C=this.levelDetails;if(null===g||null===I||null===C)return null;var A=C.edge,i=g-I-this.edgeStalled,e=A-C.totalduration,l=A-(this.config.lowLatencyMode&&C.partTarget||C.targetduration);return Math.min(Math.max(e,i),l)}},{key:"drift",get:function(){var g=this.levelDetails;return null===g?1:g.drift}},{key:"edgeStalled",get:function(){var g=this.levelDetails;if(null===g)return 0;var I=3*(this.config.lowLatencyMode&&g.partTarget||g.targetduration);return Math.max(g.age-I,0)}},{key:"forwardBufferLength",get:function(){var g=this.media,I=this.levelDetails;if(!g||!I)return 0;var C=g.buffered.length;return(C?g.buffered.end(C-1):I.edge)-this.currentTime}}]),g}(),NI=["NONE","TYPE-0","TYPE-1",null],HI=function(){function g(g,I,C){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=g,this.part=I,this.skip=C}return g.prototype.addDirectives=function(g){var I=new self.URL(g);return void 0!==this.msn&&I.searchParams.set("_HLS_msn",this.msn.toString()),void 0!==this.part&&I.searchParams.set("_HLS_part",this.part.toString()),this.skip&&I.searchParams.set("_HLS_skip",this.skip),I.href},g}(),KI=function(){function g(g){this._attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.unknownCodecs=void 0,this.audioGroupIds=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.textGroupIds=void 0,this.url=void 0,this._urlId=0,this.url=[g.url],this._attrs=[g.attrs],this.bitrate=g.bitrate,g.details&&(this.details=g.details),this.id=g.id||0,this.name=g.name,this.width=g.width||0,this.height=g.height||0,this.audioCodec=g.audioCodec,this.videoCodec=g.videoCodec,this.unknownCodecs=g.unknownCodecs,this.codecSet=[g.videoCodec,g.audioCodec].filter((function(g){return g})).join(",").replace(/\.[^.,]+/g,"")}return g.prototype.addFallback=function(g){this.url.push(g.url),this._attrs.push(g.attrs)},e(g,[{key:"maxBitrate",get:function(){return Math.max(this.realBitrate,this.bitrate)}},{key:"attrs",get:function(){return this._attrs[this._urlId]}},{key:"pathwayId",get:function(){return this.attrs["PATHWAY-ID"]||"."}},{key:"uri",get:function(){return this.url[this._urlId]||""}},{key:"urlId",get:function(){return this._urlId},set:function(g){var I=g%this.url.length;this._urlId!==I&&(this.fragmentError=0,this.loadError=0,this.details=void 0,this._urlId=I)}},{key:"audioGroupId",get:function(){var g;return null==(g=this.audioGroupIds)?void 0:g[this.urlId]}},{key:"textGroupId",get:function(){var g;return null==(g=this.textGroupIds)?void 0:g[this.urlId]}}]),g}();function FI(g,I){var C=I.startPTS;if(W(C)){var A,i=0;I.sn>g.sn?(i=C-g.start,A=g):(i=g.start-C,A=I),A.duration!==i&&(A.duration=i)}else I.sn>g.sn?g.cc===I.cc&&g.minEndPTS?I.start=g.start+(g.minEndPTS-g.start):I.start=g.start+g.duration:I.start=Math.max(g.start-I.duration,0)}function MI(g,I,C,A,i,e){A-C<=0&&(H.warn("Fragment should have a positive duration",I),A=C+I.duration,e=i+I.duration);var l=C,t=A,s=I.startPTS,c=I.endPTS;if(W(s)){var d=Math.abs(s-C);W(I.deltaPTS)?I.deltaPTS=Math.max(d,I.deltaPTS):I.deltaPTS=d,l=Math.max(C,s),C=Math.min(C,s),i=Math.min(i,I.startDTS),t=Math.min(A,c),A=Math.max(A,c),e=Math.max(e,I.endDTS)}var o=C-I.start;0!==I.start&&(I.start=C),I.duration=A-I.start,I.startPTS=C,I.maxStartPTS=l,I.startDTS=i,I.endPTS=A,I.minEndPTS=t,I.endDTS=e;var n,a=I.sn;if(!g||ag.endSN)return 0;var Z=a-g.startSN,b=g.fragments;for(b[Z]=I,n=Z;n>0;n--)FI(b[n],b[n-1]);for(n=Z;n=A.length||SI(I,A[C].start)}function SI(g,I){if(I){for(var C=g.fragments,A=g.skippedSegments;A499)||!!C);var i}var xI=function(g,I){for(var C=0,A=g.length-1,i=null,e=null;C<=A;){var l=I(e=g[i=(C+A)/2|0]);if(l>0)C=i+1;else{if(!(l<0))return e;A=i-1}}return null};function UI(g,I,C,A){void 0===C&&(C=0),void 0===A&&(A=0);var i=null;if(g?i=I[g.sn-I[0].sn+1]||null:0===C&&0===I[0].start&&(i=I[0]),i&&0===QI(C,A,i))return i;var e=xI(I,QI.bind(null,C,A));return!e||e===g&&i?i:e}function QI(g,I,C){if(void 0===g&&(g=0),void 0===I&&(I=0),C.start<=g&&C.start+C.duration>g)return 0;var A=Math.min(I,C.duration+(C.deltaPTS?C.deltaPTS:0));return C.start+C.duration-A<=g?1:C.start-A>g&&C.start?-1:0}function jI(g,I,C){var A=1e3*Math.min(I,C.duration+(C.deltaPTS?C.deltaPTS:0));return(C.endProgramDateTime||0)-A>g}var OI,EI=function(){function g(g){this.hls=void 0,this.playlistError=0,this.penalizedRenditions={},this.log=void 0,this.warn=void 0,this.error=void 0,this.hls=g,this.log=H.log.bind(H,"[info]:"),this.warn=H.warn.bind(H,"[warning]:"),this.error=H.error.bind(H,"[error]:"),this.registerListeners()}var I=g.prototype;return I.registerListeners=function(){var g=this.hls;g.on(p.ERROR,this.onError,this),g.on(p.MANIFEST_LOADING,this.onManifestLoading,this),g.on(p.LEVEL_UPDATED,this.onLevelUpdated,this)},I.unregisterListeners=function(){var g=this.hls;g&&(g.off(p.ERROR,this.onError,this),g.off(p.ERROR,this.onErrorOut,this),g.off(p.MANIFEST_LOADING,this.onManifestLoading,this),g.off(p.LEVEL_UPDATED,this.onLevelUpdated,this))},I.destroy=function(){this.unregisterListeners(),this.hls=null,this.penalizedRenditions={}},I.startLoad=function(g){this.playlistError=0},I.stopLoad=function(){},I.getVariantLevelIndex=function(g){return(null==g?void 0:g.type)===aI?g.level:this.hls.loadLevel},I.onManifestLoading=function(){this.playlistError=0,this.penalizedRenditions={}},I.onLevelUpdated=function(){this.playlistError=0},I.onError=function(g,I){var C,A;if(!I.fatal){var i=this.hls,e=I.context;switch(I.details){case y.FRAG_LOAD_ERROR:case y.FRAG_LOAD_TIMEOUT:case y.KEY_LOAD_ERROR:case y.KEY_LOAD_TIMEOUT:return void(I.errorAction=this.getFragRetryOrSwitchAction(I));case y.FRAG_PARSING_ERROR:if(null!=(C=I.frag)&&C.gap)return void(I.errorAction={action:0,flags:0});case y.FRAG_GAP:case y.FRAG_DECRYPT_ERROR:return I.errorAction=this.getFragRetryOrSwitchAction(I),void(I.errorAction.action=2);case y.LEVEL_EMPTY_ERROR:case y.LEVEL_PARSING_ERROR:var l,t,s=I.parent===aI?I.level:i.loadLevel;return void(I.details===y.LEVEL_EMPTY_ERROR&&null!=(l=I.context)&&null!=(t=l.levelDetails)&&t.live?I.errorAction=this.getPlaylistRetryOrSwitchAction(I,s):(I.levelRetry=!1,I.errorAction=this.getLevelSwitchAction(I,s)));case y.LEVEL_LOAD_ERROR:case y.LEVEL_LOAD_TIMEOUT:return void("number"==typeof(null==e?void 0:e.level)&&(I.errorAction=this.getPlaylistRetryOrSwitchAction(I,e.level)));case y.AUDIO_TRACK_LOAD_ERROR:case y.AUDIO_TRACK_LOAD_TIMEOUT:case y.SUBTITLE_LOAD_ERROR:case y.SUBTITLE_TRACK_LOAD_TIMEOUT:if(e){var c=i.levels[i.loadLevel];if(c&&(e.type===oI&&e.groupId===c.audioGroupId||e.type===nI&&e.groupId===c.textGroupId))return I.errorAction=this.getPlaylistRetryOrSwitchAction(I,i.loadLevel),I.errorAction.action=2,void(I.errorAction.flags=1)}return;case y.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:var d=i.levels[i.loadLevel],o=null==d?void 0:d.attrs["HDCP-LEVEL"];return void(o&&(I.errorAction={action:2,flags:2,hdcpLevel:o}));case y.BUFFER_ADD_CODEC_ERROR:case y.REMUX_ALLOC_ERROR:return void(I.errorAction=this.getLevelSwitchAction(I,null!=(A=I.level)?A:i.loadLevel));case y.INTERNAL_EXCEPTION:case y.BUFFER_APPENDING_ERROR:case y.BUFFER_APPEND_ERROR:case y.BUFFER_FULL_ERROR:case y.LEVEL_SWITCH_ERROR:case y.BUFFER_STALLED_ERROR:case y.BUFFER_SEEK_OVER_HOLE:case y.BUFFER_NUDGE_ON_STALL:return void(I.errorAction={action:0,flags:0})}if(I.type===V.KEY_SYSTEM_ERROR){var n=this.getVariantLevelIndex(I.frag);return I.levelRetry=!1,void(I.errorAction=this.getLevelSwitchAction(I,n))}}},I.getPlaylistRetryOrSwitchAction=function(g,I){var C,A=LI(this.hls.config.playlistLoadPolicy,g),i=this.playlistError++,e=null==(C=g.response)?void 0:C.code;if(TI(A,i,DI(g),e))return{action:5,flags:0,retryConfig:A,retryCount:i};var l=this.getLevelSwitchAction(g,I);return A&&(l.retryConfig=A,l.retryCount=i),l},I.getFragRetryOrSwitchAction=function(g){var I=this.hls,C=this.getVariantLevelIndex(g.frag),A=I.levels[C],i=I.config,e=i.fragLoadPolicy,l=i.keyLoadPolicy,t=LI(g.details.startsWith("key")?l:e,g),s=I.levels.reduce((function(g,I){return g+I.fragmentError}),0);if(A){var c;g.details!==y.FRAG_GAP&&A.fragmentError++;var d=null==(c=g.response)?void 0:c.code;if(TI(t,s,DI(g),d))return{action:5,flags:0,retryConfig:t,retryCount:s}}var o=this.getLevelSwitchAction(g,C);return t&&(o.retryConfig=t,o.retryCount=s),o},I.getLevelSwitchAction=function(g,I){var C=this.hls;null==I&&(I=C.loadLevel);var A=this.hls.levels[I];if(A&&(A.loadError++,C.autoLevelEnabled)){for(var i,e,l=-1,t=C.levels,s=C.loadLevel,c=C.minAutoLevel,d=C.maxAutoLevel,o=null==(i=g.frag)?void 0:i.type,n=null!=(e=g.context)?e:{},a=n.type,Z=n.groupId,b=t.length;b--;){var r=(b+s)%t.length;if(r!==s&&r>=c&&r<=d&&0===t[r].loadError){var m=t[r];if(g.details===y.FRAG_GAP&&g.frag){var h=t[r].details;if(h){var G=UI(g.frag,h.fragments,g.frag.start);if(null!=G&&G.gap)continue}}else{if(a===oI&&Z===m.audioGroupId||a===nI&&Z===m.textGroupId)continue;if(o===ZI&&A.audioGroupId===m.audioGroupId||o===bI&&A.textGroupId===m.textGroupId)continue}l=r;break}}if(l>-1&&C.loadLevel!==l)return g.levelRetry=!0,this.playlistError=0,{action:2,flags:0,nextAutoLevel:l}}return{action:2,flags:1}},I.onErrorOut=function(g,I){var C;switch(null==(C=I.errorAction)?void 0:C.action){case 0:break;case 2:this.sendAlternateToPenaltyBox(I),I.errorAction.resolved||I.details===y.FRAG_GAP||(I.fatal=!0)}I.fatal&&this.hls.stopLoad()},I.sendAlternateToPenaltyBox=function(g){var I=this.hls,C=g.errorAction;if(C){var A=C.flags,i=C.hdcpLevel,e=C.nextAutoLevel;switch(A){case 0:this.switchLevel(g,e);break;case 1:C.resolved||(C.resolved=this.redundantFailover(g));break;case 2:i&&(I.maxHdcpLevel=NI[NI.indexOf(i)-1],C.resolved=!0),this.warn('Restricting playback to HDCP-LEVEL of "'+I.maxHdcpLevel+'" or lower')}C.resolved||this.switchLevel(g,e)}},I.switchLevel=function(g,I){void 0!==I&&g.errorAction&&(this.warn("switching to level "+I+" after "+g.details),this.hls.nextAutoLevel=I,g.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel)},I.redundantFailover=function(g){var I=this,C=this.hls,A=this.penalizedRenditions,i=g.parent===aI?g.level:C.loadLevel,e=C.levels[i],l=e.url.length,t=g.frag?g.frag.urlId:e.urlId;e.urlId!==t||g.frag&&!e.details||this.penalizeRendition(e,g);for(var s=function(){var s=(t+c)%l,d=A[s];if(!d||function(g,I,C){if(performance.now()-g.lastErrorPerfMs>3e5)return!0;var A=g.details;if(I.details===y.FRAG_GAP&&A&&I.frag){var i=I.frag.start,e=UI(null,A.fragments,i);if(e&&!e.gap)return!0}if(C&&g.errors.length3*A.targetduration)return!0}return!1}(d,g,A[t]))return I.warn("Switching to Redundant Stream "+(s+1)+"/"+l+': "'+e.url[s]+'" after '+g.details),I.playlistError=0,C.levels.forEach((function(g){g.urlId=s})),C.nextLoadLevel=i,{v:!0}},c=1;c=0&&d>I.partTarget&&(c+=1)}return new HI(s,c>=0?c:void 0,"")}}},I.loadPlaylist=function(g){-1===this.requestScheduled&&(this.requestScheduled=self.performance.now())},I.shouldLoadPlaylist=function(g){return this.canLoad&&!!g&&!!g.url&&(!g.details||g.details.live)},I.shouldReloadPlaylist=function(g){return-1===this.timer&&-1===this.requestScheduled&&this.shouldLoadPlaylist(g)},I.playlistLoaded=function(g,I,C){var A=this,i=I.details,e=I.stats,l=self.performance.now(),s=e.loading.first?Math.max(0,l-e.loading.first):0;if(i.advancedDateTime=Date.now()-s,i.live||null!=C&&C.live){if(i.reloaded(C),C&&this.log("live playlist "+g+" "+(i.advanced?"REFRESHED "+i.lastPartSn+"-"+i.lastPartIndex:i.updated?"UPDATED":"MISSED")),C&&i.fragments.length>0&&function(g,I){for(var C=null,A=g.fragments,i=A.length-1;i>=0;i--){var e=A[i].initSegment;if(e){C=e;break}}g.fragmentHint&&delete g.fragmentHint.endPTS;var l,s,c,d,o,n=0;if(function(g,I,C){for(var A=I.skippedSegments,i=Math.max(g.startSN,I.startSN)-I.startSN,e=(g.fragmentHint?1:0)+(A?I.endSN:Math.min(g.endSN,I.endSN))-I.startSN,l=I.startSN-g.startSN,t=I.fragmentHint?I.fragments.concat(I.fragmentHint):I.fragments,s=g.fragmentHint?g.fragments.concat(g.fragmentHint):g.fragments,c=i;c<=e;c++){var d=s[l+c],o=t[c];A&&!o&&c0){if(C&&G>C.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+C.tuneInGoal+" to: "+G+" with playlist age: "+i.age),G=0;else{var u=Math.floor(G/i.targetduration);d+=u,void 0!==o&&(o+=Math.round(G%i.targetduration/i.partTarget)),this.log("CDN Tune-in age: "+i.ageHeader+"s last advanced "+m.toFixed(2)+"s goal: "+G+" skip sn "+u+" to part "+o)}i.tuneInGoal=G}if(c=this.getDeliveryDirectives(i,I.deliveryDirectives,d,o),n||!r)return void this.loadPlaylist(c)}else(i.canBlockReload||i.canSkipUntil)&&(c=this.getDeliveryDirectives(i,I.deliveryDirectives,d,o));var B=this.hls.mainForwardBufferInfo,w=B?B.end-B.len:0,p=function(g,I){void 0===I&&(I=1/0);var C=1e3*g.targetduration;if(g.updated){var A=g.fragments;if(A.length&&4*C>I){var i=1e3*A[A.length-1].duration;ithis.requestScheduled+p&&(this.requestScheduled=e.loading.start),void 0!==d&&i.canBlockReload?this.requestScheduled=e.loading.first+p-(1e3*i.partTarget||1e3):-1===this.requestScheduled||this.requestScheduled+p=c.maxNumRetry)return!1;if(A&&null!=(o=g.context)&&o.deliveryDirectives)this.warn("Retrying playlist loading "+(s+1)+"/"+c.maxNumRetry+' after "'+C+'" without delivery-directives'),this.loadPlaylist();else{var n=zI(c,s);this.timer=self.setTimeout((function(){return I.loadPlaylist()}),n),this.warn("Retrying playlist loading "+(s+1)+"/"+c.maxNumRetry+' after "'+C+'" in '+n+"ms")}g.levelRetry=!0,i.resolved=!0}return d},g}(),_I=function(g){function I(I,C){var A;return(A=g.call(this,I,"[level-controller]")||this)._levels=[],A._firstLevel=-1,A._startLevel=void 0,A.currentLevel=null,A.currentLevelIndex=-1,A.manualLevelIndex=-1,A.steering=void 0,A.onParsedComplete=void 0,A.steering=C,A._registerListeners(),A}s(I,g);var C=I.prototype;return C._registerListeners=function(){var g=this.hls;g.on(p.MANIFEST_LOADING,this.onManifestLoading,this),g.on(p.MANIFEST_LOADED,this.onManifestLoaded,this),g.on(p.LEVEL_LOADED,this.onLevelLoaded,this),g.on(p.LEVELS_UPDATED,this.onLevelsUpdated,this),g.on(p.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),g.on(p.FRAG_LOADED,this.onFragLoaded,this),g.on(p.ERROR,this.onError,this)},C._unregisterListeners=function(){var g=this.hls;g.off(p.MANIFEST_LOADING,this.onManifestLoading,this),g.off(p.MANIFEST_LOADED,this.onManifestLoaded,this),g.off(p.LEVEL_LOADED,this.onLevelLoaded,this),g.off(p.LEVELS_UPDATED,this.onLevelsUpdated,this),g.off(p.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),g.off(p.FRAG_LOADED,this.onFragLoaded,this),g.off(p.ERROR,this.onError,this)},C.destroy=function(){this._unregisterListeners(),this.steering=null,this.resetLevels(),g.prototype.destroy.call(this)},C.startLoad=function(){this._levels.forEach((function(g){g.loadError=0,g.fragmentError=0})),g.prototype.startLoad.call(this)},C.resetLevels=function(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[]},C.onManifestLoading=function(g,I){this.resetLevels()},C.onManifestLoaded=function(g,I){var C,A=[],i={};I.levels.forEach((function(g){var I,e=g.attrs;-1!==(null==(I=g.audioCodec)?void 0:I.indexOf("mp4a.40.34"))&&(OI||(OI=/chrome|firefox/i.test(navigator.userAgent)),OI&&(g.audioCodec=void 0));var l=e.AUDIO,t=e.CODECS,s=e["FRAME-RATE"],c=e["PATHWAY-ID"],d=e.RESOLUTION,o=e.SUBTITLES,n=(c||".")+"-"+g.bitrate+"-"+d+"-"+s+"-"+t;(C=i[n])?C.addFallback(g):(C=new KI(g),i[n]=C,A.push(C)),qI(C,"audio",l),qI(C,"text",o)})),this.filterAndSortMediaOptions(A,I)},C.filterAndSortMediaOptions=function(g,I){var C=this,A=[],i=[],e=!1,l=!1,t=!1,s=g.filter((function(g){var I=g.audioCodec,C=g.videoCodec,A=g.width,i=g.height,s=g.unknownCodecs;return e||(e=!(!A||!i)),l||(l=!!C),t||(t=!!I),!(null!=s&&s.length)&&(!I||Eg(I,"audio"))&&(!C||Eg(C,"video"))}));if((e||l)&&t&&(s=s.filter((function(g){var I=g.videoCodec,C=g.width,A=g.height;return!!I||!(!C||!A)}))),0!==s.length){I.audioTracks&&$I(A=I.audioTracks.filter((function(g){return!g.audioCodec||Eg(g.audioCodec,"audio")}))),I.subtitles&&$I(i=I.subtitles);var c=s.slice(0);s.sort((function(g,I){return g.attrs["HDCP-LEVEL"]!==I.attrs["HDCP-LEVEL"]?(g.attrs["HDCP-LEVEL"]||"")>(I.attrs["HDCP-LEVEL"]||"")?1:-1:g.bitrate!==I.bitrate?g.bitrate-I.bitrate:g.attrs["FRAME-RATE"]!==I.attrs["FRAME-RATE"]?g.attrs.decimalFloatingPoint("FRAME-RATE")-I.attrs.decimalFloatingPoint("FRAME-RATE"):g.attrs.SCORE!==I.attrs.SCORE?g.attrs.decimalFloatingPoint("SCORE")-I.attrs.decimalFloatingPoint("SCORE"):e&&g.height!==I.height?g.height-I.height:0}));var d=c[0];if(this.steering&&(s=this.steering.filterParsedLevels(s)).length!==c.length)for(var o=0;o1&&void 0!==I?(i.url=i.url.filter(A),i.audioGroupIds&&(i.audioGroupIds=i.audioGroupIds.filter(A)),i.textGroupIds&&(i.textGroupIds=i.textGroupIds.filter(A)),i.urlId=0,!0):(C.steering&&C.steering.removeLevel(i),!1))}));this.hls.trigger(p.LEVELS_UPDATED,{levels:i})},C.onLevelsUpdated=function(g,I){var C=I.levels;C.forEach((function(g,I){var C=g.details;null!=C&&C.fragments&&C.fragments.forEach((function(g){g.level=I}))})),this._levels=C},e(I,[{key:"levels",get:function(){return 0===this._levels.length?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(g){var I=this._levels;if(0!==I.length){if(g<0||g>=I.length){var C=new Error("invalid level idx"),A=g<0;if(this.hls.trigger(p.ERROR,{type:V.OTHER_ERROR,details:y.LEVEL_SWITCH_ERROR,level:g,fatal:A,error:C,reason:C.message}),A)return;g=Math.min(g,I.length-1)}var i=this.currentLevelIndex,e=this.currentLevel,l=e?e.attrs["PATHWAY-ID"]:void 0,s=I[g],c=s.attrs["PATHWAY-ID"];if(this.currentLevelIndex=g,this.currentLevel=s,i!==g||!s.details||!e||l!==c){this.log("Switching to level "+g+(c?" with Pathway "+c:"")+" from level "+i+(l?" with Pathway "+l:""));var d=t({},s,{level:g,maxBitrate:s.maxBitrate,attrs:s.attrs,uri:s.uri,urlId:s.urlId});delete d._attrs,delete d._urlId,this.hls.trigger(p.LEVEL_SWITCHING,d);var o=s.details;if(!o||o.live){var n=this.switchParams(s.uri,null==e?void 0:e.details);this.loadPlaylist(n)}}}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(g){this.manualLevelIndex=g,void 0===this._startLevel&&(this._startLevel=g),-1!==g&&(this.level=g)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(g){this._firstLevel=g}},{key:"startLevel",get:function(){if(void 0===this._startLevel){var g=this.hls.config.startLevel;return void 0!==g?g:this._firstLevel}return this._startLevel},set:function(g){this._startLevel=g}},{key:"nextLoadLevel",get:function(){return-1!==this.manualLevelIndex?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(g){this.level=g,-1===this.manualLevelIndex&&(this.hls.nextAutoLevel=g)}}]),I}(PI);function qI(g,I,C){C&&("audio"===I?(g.audioGroupIds||(g.audioGroupIds=[]),g.audioGroupIds[g.url.length-1]=C):"text"===I&&(g.textGroupIds||(g.textGroupIds=[]),g.textGroupIds[g.url.length-1]=C))}function $I(g){var I={};g.forEach((function(g){var C=g.groupId||"";g.id=I[C]=I[C]||0,I[C]++}))}var gC="NOT_LOADED",IC="APPENDING",CC="PARTIAL",AC="OK",iC=function(){function g(g){this.activePartLists=Object.create(null),this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hasGaps=!1,this.hls=g,this._registerListeners()}var I=g.prototype;return I._registerListeners=function(){var g=this.hls;g.on(p.BUFFER_APPENDED,this.onBufferAppended,this),g.on(p.FRAG_BUFFERED,this.onFragBuffered,this),g.on(p.FRAG_LOADED,this.onFragLoaded,this)},I._unregisterListeners=function(){var g=this.hls;g.off(p.BUFFER_APPENDED,this.onBufferAppended,this),g.off(p.FRAG_BUFFERED,this.onFragBuffered,this),g.off(p.FRAG_LOADED,this.onFragLoaded,this)},I.destroy=function(){this._unregisterListeners(),this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null},I.getAppendedFrag=function(g,I){var C=this.activePartLists[I];if(C)for(var A=C.length;A--;){var i=C[A];if(!i)break;var e=i.end;if(i.start<=g&&null!==e&&g<=e)return i}return this.getBufferedFrag(g,I)},I.getBufferedFrag=function(g,I){for(var C=this.fragments,A=Object.keys(C),i=A.length;i--;){var e=C[A[i]];if((null==e?void 0:e.body.type)===I&&e.buffered){var l=e.body;if(l.start<=g&&g<=l.end)return l}}return null},I.detectEvictedFragments=function(g,I,C,A){var i=this;this.timeRanges&&(this.timeRanges[g]=I);var e=(null==A?void 0:A.fragment.sn)||-1;Object.keys(this.fragments).forEach((function(A){var l=i.fragments[A];if(l&&!(e>=l.body.sn))if(l.buffered||l.loaded){var t=l.range[g];t&&t.time.some((function(g){var C=!i.isTimeBuffered(g.startPTS,g.endPTS,I);return C&&i.removeFragment(l.body),C}))}else l.body.type===C&&i.removeFragment(l.body)}))},I.detectPartialFragments=function(g){var I=this,C=this.timeRanges,A=g.frag,i=g.part;if(C&&"initSegment"!==A.sn){var e=lC(A),l=this.fragments[e];if(!(!l||l.buffered&&A.gap)){var t=!A.relurl;Object.keys(C).forEach((function(g){var e=A.elementaryStreams[g];if(e){var s=C[g],c=t||!0===e.partial;l.range[g]=I.getBufferedTimes(A,i,c,s)}})),l.loaded=null,Object.keys(l.range).length?(l.buffered=!0,(l.body.endList=A.endList||l.body.endList)&&(this.endListFragments[l.body.type]=l),eC(l)||this.removeParts(A.sn-1,A.type)):this.removeFragment(l.body)}}},I.removeParts=function(g,I){var C=this.activePartLists[I];C&&(this.activePartLists[I]=C.filter((function(I){return I.fragment.sn>=g})))},I.fragBuffered=function(g,I){var C=lC(g),A=this.fragments[C];!A&&I&&(A=this.fragments[C]={body:g,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},g.gap&&(this.hasGaps=!0)),A&&(A.loaded=null,A.buffered=!0)},I.getBufferedTimes=function(g,I,C,A){for(var i={time:[],partial:C},e=g.start,l=g.end,t=g.minEndPTS||l,s=g.maxStartPTS||e,c=0;c=d&&t<=o){i.time.push({startPTS:Math.max(e,A.start(c)),endPTS:Math.min(l,A.end(c))});break}if(ed)i.partial=!0,i.time.push({startPTS:Math.max(e,A.start(c)),endPTS:Math.min(l,A.end(c))});else if(l<=d)break}return i},I.getPartialFragment=function(g){var I,C,A,i=null,e=0,l=this.bufferPadding,t=this.fragments;return Object.keys(t).forEach((function(s){var c=t[s];c&&eC(c)&&(C=c.body.start-l,A=c.body.end+l,g>=C&&g<=A&&(I=Math.min(g-C,A-g),e<=I&&(i=c.body,e=I)))})),i},I.isEndListAppended=function(g){var I=this.endListFragments[g];return void 0!==I&&(I.buffered||eC(I))},I.getState=function(g){var I=lC(g),C=this.fragments[I];return C?C.buffered?eC(C)?CC:AC:IC:gC},I.isTimeBuffered=function(g,I,C){for(var A,i,e=0;e=A&&I<=i)return!0;if(I<=A)return!1}return!1},I.onFragLoaded=function(g,I){var C=I.frag,A=I.part;if("initSegment"!==C.sn&&!C.bitrateTest){var i=A?null:I,e=lC(C);this.fragments[e]={body:C,appendedPTS:null,loaded:i,buffered:!1,range:Object.create(null)}}},I.onBufferAppended=function(g,I){var C=this,A=I.frag,i=I.part,e=I.timeRanges;if("initSegment"!==A.sn){var l=A.type;if(i){var t=this.activePartLists[l];t||(this.activePartLists[l]=t=[]),t.push(i)}this.timeRanges=e,Object.keys(e).forEach((function(g){var I=e[g];C.detectEvictedFragments(g,I,l,i)}))}},I.onFragBuffered=function(g,I){this.detectPartialFragments(I)},I.hasFragment=function(g){var I=lC(g);return!!this.fragments[I]},I.hasParts=function(g){var I;return!(null==(I=this.activePartLists[g])||!I.length)},I.removeFragmentsInRange=function(g,I,C,A,i){var e=this;A&&!this.hasGaps||Object.keys(this.fragments).forEach((function(l){var t=e.fragments[l];if(t){var s=t.body;s.type!==C||A&&!s.gap||s.startg&&(t.buffered||i)&&e.removeFragment(s)}}))},I.removeFragment=function(g){var I=lC(g);g.stats.loaded=0,g.clearElementaryStreamInfo();var C=this.activePartLists[g.type];if(C){var A=g.sn;this.activePartLists[g.type]=C.filter((function(g){return g.fragment.sn!==A}))}delete this.fragments[I],g.endList&&delete this.endListFragments[g.type]},I.removeAllFragments=function(){this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1},g}();function eC(g){var I,C,A;return g.buffered&&(g.body.gap||(null==(I=g.range.video)?void 0:I.partial)||(null==(C=g.range.audio)?void 0:C.partial)||(null==(A=g.range.audiovideo)?void 0:A.partial))}function lC(g){return g.type+"_"+g.level+"_"+g.urlId+"_"+g.sn}var tC=Math.pow(2,17),sC=function(){function g(g){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=g}var I=g.prototype;return I.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},I.abort=function(){this.loader&&this.loader.abort()},I.load=function(g,I){var C=this,i=g.url;if(!i)return Promise.reject(new oC({type:V.NETWORK_ERROR,details:y.FRAG_LOAD_ERROR,fatal:!1,frag:g,error:new Error("Fragment does not have a "+(i?"part list":"url")),networkDetails:null}));this.abort();var e=this.config,l=e.fLoader,t=e.loader;return new Promise((function(s,c){if(C.loader&&C.loader.destroy(),g.gap){if(g.tagList.some((function(g){return"GAP"===g[0]})))return void c(dC(g));g.gap=!1}var d=C.loader=g.loader=l?new l(e):new t(e),o=cC(g),n=vI(e.fragLoadPolicy.default),a={loadPolicy:n,timeout:n.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:"initSegment"===g.sn?1/0:tC};g.stats=d.stats,d.load(o,a,{onSuccess:function(I,A,i,e){C.resetLoader(g,d);var l=I.data;i.resetIV&&g.decryptdata&&(g.decryptdata.iv=new Uint8Array(l.slice(0,16)),l=l.slice(16)),s({frag:g,part:null,payload:l,networkDetails:e})},onError:function(I,e,l,t){C.resetLoader(g,d),c(new oC({type:V.NETWORK_ERROR,details:y.FRAG_LOAD_ERROR,fatal:!1,frag:g,response:A({url:i,data:void 0},I),error:new Error("HTTP Error "+I.code+" "+I.text),networkDetails:l,stats:t}))},onAbort:function(I,A,i){C.resetLoader(g,d),c(new oC({type:V.NETWORK_ERROR,details:y.INTERNAL_ABORTED,fatal:!1,frag:g,error:new Error("Aborted"),networkDetails:i,stats:I}))},onTimeout:function(I,A,i){C.resetLoader(g,d),c(new oC({type:V.NETWORK_ERROR,details:y.FRAG_LOAD_TIMEOUT,fatal:!1,frag:g,error:new Error("Timeout after "+a.timeout+"ms"),networkDetails:i,stats:I}))},onProgress:function(C,A,i,e){I&&I({frag:g,part:null,payload:i,networkDetails:e})}})}))},I.loadPart=function(g,I,C){var i=this;this.abort();var e=this.config,l=e.fLoader,t=e.loader;return new Promise((function(s,c){if(i.loader&&i.loader.destroy(),g.gap||I.gap)c(dC(g,I));else{var d=i.loader=g.loader=l?new l(e):new t(e),o=cC(g,I),n=vI(e.fragLoadPolicy.default),a={loadPolicy:n,timeout:n.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:tC};I.stats=d.stats,d.load(o,a,{onSuccess:function(A,e,l,t){i.resetLoader(g,d),i.updateStatsFromPart(g,I);var c={frag:g,part:I,payload:A.data,networkDetails:t};C(c),s(c)},onError:function(C,e,l,t){i.resetLoader(g,d),c(new oC({type:V.NETWORK_ERROR,details:y.FRAG_LOAD_ERROR,fatal:!1,frag:g,part:I,response:A({url:o.url,data:void 0},C),error:new Error("HTTP Error "+C.code+" "+C.text),networkDetails:l,stats:t}))},onAbort:function(C,A,e){g.stats.aborted=I.stats.aborted,i.resetLoader(g,d),c(new oC({type:V.NETWORK_ERROR,details:y.INTERNAL_ABORTED,fatal:!1,frag:g,part:I,error:new Error("Aborted"),networkDetails:e,stats:C}))},onTimeout:function(C,A,e){i.resetLoader(g,d),c(new oC({type:V.NETWORK_ERROR,details:y.FRAG_LOAD_TIMEOUT,fatal:!1,frag:g,part:I,error:new Error("Timeout after "+a.timeout+"ms"),networkDetails:e,stats:C}))}})}}))},I.updateStatsFromPart=function(g,I){var C=g.stats,A=I.stats,i=A.total;if(C.loaded+=A.loaded,i){var e=Math.round(g.duration/I.duration),l=Math.min(Math.round(C.loaded/i),e),t=(e-l)*Math.round(C.loaded/l);C.total=C.loaded+t}else C.total=Math.max(C.loaded,C.total);var s=C.loading,c=A.loading;s.start?s.first+=c.first-c.start:(s.start=c.start,s.first=c.first),s.end=c.end},I.resetLoader=function(g,I){g.loader=null,this.loader===I&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),I.destroy()},g}();function cC(g,I){void 0===I&&(I=null);var C=I||g,A={frag:g,part:I,responseType:"arraybuffer",url:C.url,headers:{},rangeStart:0,rangeEnd:0},i=C.byteRangeStartOffset,e=C.byteRangeEndOffset;if(W(i)&&W(e)){var l,t=i,s=e;if("initSegment"===g.sn&&"AES-128"===(null==(l=g.decryptdata)?void 0:l.method)){var c=e-i;c%16&&(s=e+(16-c%16)),0!==i&&(A.resetIV=!0,t=i-16)}A.rangeStart=t,A.rangeEnd=s}return A}function dC(g,I){var C=new Error("GAP "+(g.gap?"tag":"attribute")+" found"),A={type:V.MEDIA_ERROR,details:y.FRAG_GAP,fatal:!1,frag:g,error:C,networkDetails:null};return I&&(A.part=I),(I||g).stats.aborted=!0,new oC(A)}var oC=function(g){function I(I){var C;return(C=g.call(this,I.error.message)||this).data=void 0,C.data=I,C}return s(I,g),I}(n(Error)),nC=function(){function g(g){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=g}var I=g.prototype;return I.abort=function(g){for(var I in this.keyUriToKeyInfo){var C=this.keyUriToKeyInfo[I].loader;if(C){if(g&&g!==C.context.frag.type)return;C.abort()}}},I.detach=function(){for(var g in this.keyUriToKeyInfo){var I=this.keyUriToKeyInfo[g];(I.mediaKeySessionContext||I.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[g]}},I.destroy=function(){for(var g in this.detach(),this.keyUriToKeyInfo){var I=this.keyUriToKeyInfo[g].loader;I&&I.destroy()}this.keyUriToKeyInfo={}},I.createKeyLoadError=function(g,I,C,A,i){return void 0===I&&(I=y.KEY_LOAD_ERROR),new oC({type:V.NETWORK_ERROR,details:I,fatal:!1,frag:g,response:i,error:C,networkDetails:A})},I.loadClear=function(g,I){var C=this;if(this.emeController&&this.config.emeEnabled)for(var A=g.sn,i=g.cc,e=function(){var g=I[l];if(i<=g.cc&&("initSegment"===A||"initSegment"===g.sn||A1&&this.tickImmediate(),this._tickCallCount=0)},I.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},I.doTick=function(){},g}(),ZC={length:0,start:function(){return 0},end:function(){return 0}},bC=function(){function g(){}return g.isBuffered=function(I,C){try{if(I)for(var A=g.getBuffered(I),i=0;i=A.start(i)&&C<=A.end(i))return!0}catch(e){}return!1},g.bufferInfo=function(I,C,A){try{if(I){var i,e=g.getBuffered(I),l=[];for(i=0;il&&(A[e-1].end=g[i].end):A.push(g[i])}else A.push(g[i])}else A=g;for(var t,s=0,c=I,d=I,o=0;o=n&&I>>8^255&r^99,g[a]=r,I[r]=a;var m=n[a],h=n[m],G=n[h],u=257*n[r]^16843008*r;A[a]=u<<24|u>>>8,i[a]=u<<16|u>>>16,e[a]=u<<8|u>>>24,l[a]=u,u=16843009*G^65537*h^257*m^16843008*a,s[r]=u<<24|u>>>8,c[r]=u<<16|u>>>16,d[r]=u<<8|u>>>24,o[r]=u,a?(a=m^n[n[n[G^m]]],Z^=n[n[Z]]):a=Z=1}},I.expandKey=function(g){for(var I=this.uint8ArrayToUint32Array_(g),C=!0,A=0;Al.end){var d=e>c;(e0&&e&&e.key&&e.iv&&"AES-128"===e.method){var l=self.performance.now();return C.decrypter.decrypt(new Uint8Array(i),e.key.buffer,e.iv.buffer).catch((function(I){throw A.trigger(p.ERROR,{type:V.MEDIA_ERROR,details:y.FRAG_DECRYPT_ERROR,fatal:!1,error:I,reason:I.message,frag:g}),I})).then((function(C){var i=self.performance.now();return A.trigger(p.FRAG_DECRYPTED,{frag:g,payload:C,stats:{tstart:l,tdecrypt:i}}),I.payload=C,I}))}return I})).then((function(A){var i=C.fragCurrent,e=C.hls;if(!C.levels)throw new Error("init load aborted, missing levels");var l=g.stats;C.state=yC,I.fragmentError=0,g.data=new Uint8Array(A.payload),l.parsing.start=l.buffering.start=self.performance.now(),l.parsing.end=l.buffering.end=self.performance.now(),A.frag===i&&e.trigger(p.FRAG_BUFFERED,{stats:l,frag:i,part:null,id:g.type}),C.tick()})).catch((function(I){C.state!==VC&&C.state!==MC&&(C.warn(I),C.resetFragmentLoading(g))}))},C.fragContextChanged=function(g){var I=this.fragCurrent;return!g||!I||g.level!==I.level||g.sn!==I.sn||g.urlId!==I.urlId},C.fragBufferedComplete=function(g,I){var C,A,i,e,l=this.mediaBuffer?this.mediaBuffer:this.media;this.log("Buffered "+g.type+" sn: "+g.sn+(I?" part: "+I.index:"")+" of "+(this.playlistType===aI?"level":"track")+" "+g.level+" (frag:["+(null!=(C=g.startPTS)?C:NaN).toFixed(3)+"-"+(null!=(A=g.endPTS)?A:NaN).toFixed(3)+"] > buffer:"+(l?function(g){for(var I="",C=g.length,A=0;Ag.end&&l.fragmentHint&&(g=l.fragmentHint);var c=this.getNextPart(s,g,C);if(c>-1){var d,o=s[c];return this.log("Loading part sn: "+g.sn+" p: "+o.index+" cc: "+g.cc+" of playlist ["+l.startSN+"-"+l.endSN+"] parts [0-"+c+"-"+(s.length-1)+"] "+("[stream-controller]"===this.logPrefix?"level":"track")+": "+g.level+", target: "+parseFloat(C.toFixed(3))),this.nextLoadPosition=o.start+o.duration,this.state=YC,d=t?t.then((function(C){return!C||e.fragContextChanged(C.frag)?null:e.doFragPartsLoad(g,o,I,A)})).catch((function(g){return e.handleFragLoadError(g)})):this.doFragPartsLoad(g,o,I,A).catch((function(g){return e.handleFragLoadError(g)})),this.hls.trigger(p.FRAG_LOADING,{frag:g,part:o,targetBufferTime:C}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):d}if(!g.url||this.loadedEndOfParts(s,C))return Promise.resolve(null)}}this.log("Loading fragment "+g.sn+" cc: "+g.cc+" "+(l?"of ["+l.startSN+"-"+l.endSN+"] ":"")+("[stream-controller]"===this.logPrefix?"level":"track")+": "+g.level+", target: "+parseFloat(C.toFixed(3))),W(g.sn)&&!this.bitrateTest&&(this.nextLoadPosition=g.start+g.duration),this.state=YC;var n,a=this.config.progressive;return n=a&&t?t.then((function(I){return!I||e.fragContextChanged(null==I?void 0:I.frag)?null:e.fragmentLoader.load(g,A)})).catch((function(g){return e.handleFragLoadError(g)})):Promise.all([this.fragmentLoader.load(g,a?A:void 0),t]).then((function(g){var I=g[0];return!a&&I&&A&&A(I),I})).catch((function(g){return e.handleFragLoadError(g)})),this.hls.trigger(p.FRAG_LOADING,{frag:g,targetBufferTime:C}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):n},C.doFragPartsLoad=function(g,I,C,A){var i=this;return new Promise((function(e,l){var t,s=[],c=null==(t=C.details)?void 0:t.partList;!function I(t){i.fragmentLoader.loadPart(g,t,A).then((function(A){s[t.index]=A;var l=A.part;i.hls.trigger(p.FRAG_LOADED,A);var d=fI(C,g.sn,t.index+1)||kI(c,g.sn,t.index+1);if(!d)return e({frag:g,part:l,partsLoaded:s});I(d)})).catch(l)}(I)}))},C.handleFragLoadError=function(g){if("data"in g){var I=g.data;g.data&&I.details===y.INTERNAL_ABORTED?this.handleFragLoadAborted(I.frag,I.part):this.hls.trigger(p.ERROR,I)}else this.hls.trigger(p.ERROR,{type:V.OTHER_ERROR,details:y.INTERNAL_EXCEPTION,err:g,error:g,fatal:!0});return null},C._handleTransmuxerFlush=function(g){var I=this.getCurrentContext(g);if(I&&this.state===HC){var C=I.frag,A=I.part,i=I.level,e=self.performance.now();C.stats.parsing.end=e,A&&(A.stats.parsing.end=e),this.updateLevelTiming(C,A,i,g.partial)}else this.fragCurrent||this.state===VC||this.state===MC||(this.state=yC)},C.getCurrentContext=function(g){var I=this.levels,C=this.fragCurrent,A=g.level,i=g.sn,e=g.part;if(null==I||!I[A])return this.warn("Levels object was unset while buffering fragment "+i+" of level "+A+". The current chunk will not be buffered."),null;var l=I[A],t=e>-1?fI(l,i,e):null,s=t?t.fragment:function(g,I,C){if(null==g||!g.details)return null;var A=g.details,i=A.fragments[I-A.startSN];return i||((i=A.fragmentHint)&&i.sn===I?i:Ie&&this.flushMainBuffer(l,g.start)}else this.flushMainBuffer(0,g.start)},C.getFwdBufferInfo=function(g,I){var C=this.getLoadPosition();return W(C)?this.getFwdBufferInfoAtPos(g,C,I):null},C.getFwdBufferInfoAtPos=function(g,I,C){var A=this.config.maxBufferHole,i=bC.bufferInfo(g,I,A);if(0===i.len&&void 0!==i.nextStart){var e=this.fragmentTracker.getBufferedFrag(I,C);if(e&&i.nextStart=C&&(I.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+I.maxMaxBufferLength+"s"),!0)},C.getAppendedFrag=function(g,I){var C=this.fragmentTracker.getAppendedFrag(g,aI);return C&&"fragment"in C?C.fragment:C},C.getNextFragment=function(g,I){var C=I.fragments,A=C.length;if(!A)return null;var i,e=this.config,l=C[0].start;if(I.live){var t=e.initialLiveManifestSize;if(AI},C.getNextFragmentLoopLoading=function(g,I,C,A,i){var e=g.gap,l=this.getNextFragment(this.nextLoadPosition,I);if(null===l)return l;if(g=l,e&&g&&!g.gap&&C.nextStart){var t=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,C.nextStart,A);if(null!==t&&C.len+t.len>=i)return this.log('buffer full after gaps in "'+A+'" playlist starting at sn: '+g.sn),null}return g},C.mapToInitFragWhenRequired=function(g){return null==g||!g.initSegment||null!=g&&g.initSegment.data||this.bitrateTest?g:g.initSegment},C.getNextPart=function(g,I,C){for(var A=-1,i=!1,e=!0,l=0,t=g.length;l-1&&CC.start&&C.loaded},C.getInitialLiveFragment=function(g,I){var C,A,i=this.fragPrevious,e=null;if(i){if(g.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+i.programDateTime),e=function(g,I,C){if(null===I||!Array.isArray(g)||!g.length||!W(I))return null;if(I<(g[0].programDateTime||0))return null;if(I>=(g[g.length-1].endProgramDateTime||0))return null;C=C||0;for(var A=0;A=g.startSN&&l<=g.endSN){var t=I[l-g.startSN];i.cc===t.cc&&(e=t,this.log("Live playlist, switching playlist, load frag with next SN: "+e.sn))}e||(C=I,A=i.cc,(e=xI(C,(function(g){return g.ccA?-1:0})))&&this.log("Live playlist, switching playlist, load frag with same CC: "+e.sn))}}else{var s=this.hls.liveSyncPosition;null!==s&&(e=this.getFragmentAtPosition(s,this.bitrateTest?g.fragmentEnd:g.edge,g))}return e},C.getFragmentAtPosition=function(g,I,C){var A,i=this.config,e=this.fragPrevious,l=C.fragments,t=C.endSN,s=C.fragmentHint,c=i.maxFragLookUpTolerance,d=C.partList,o=!!(i.lowLatencyMode&&null!=d&&d.length&&s);if(o&&s&&!this.bitrateTest&&(l=l.concat(s),t=s.sn),A=gI-c?0:c):l[l.length-1]){var n=A.sn-C.startSN,a=this.fragmentTracker.getState(A);if((a===AC||a===CC&&A.gap)&&(e=A),e&&A.sn===e.sn&&(!o||d[0].fragment.sn>A.sn)&&e&&A.level===e.level){var Z=l[n+1];A=A.sn=e-I.maxFragLookUpTolerance&&i<=l;if(null!==A&&C.duration>A&&(ie.startCC||i&&i.cc"+g.startSN+" prev-sn: "+(i?i.sn:"na")+" fragments: "+l),d}return t},C.waitForCdnTuneIn=function(g){return g.live&&g.canBlockReload&&g.partTarget&&g.tuneInGoal>Math.max(g.partHoldBack,3*g.partTarget)},C.setStartPosition=function(g,I){var C=this.startPosition;if(C "+(null==(i=this.fragCurrent)?void 0:i.url))}else{var e=I.details===y.FRAG_GAP;e&&this.fragmentTracker.fragBuffered(A,!0);var l=I.errorAction,t=l||{},s=t.action,c=t.retryCount,d=void 0===c?0:c,o=t.retryConfig;if(l&&5===s&&o){var n;this.resetStartWhenNotLoaded(null!=(n=this.levelLastLoaded)?n:A.level);var a=zI(o,d);this.warn("Fragment "+A.sn+" of "+g+" "+A.level+" errored with "+I.details+", retrying loading "+(d+1)+"/"+o.maxNumRetry+" in "+a+"ms"),l.resolved=!0,this.retryDate=self.performance.now()+a,this.state=RC}else o&&l?(this.resetFragmentErrors(g),d.5;A&&this.reduceMaxBufferLength(C.len);var i=!A;return i&&this.warn("Buffer full error while media.currentTime is not buffered, flush "+I+" buffer"),g.frag&&(this.fragmentTracker.removeFragment(g.frag),this.nextLoadPosition=g.frag.start),this.resetLoadingState(),i}return!1},C.resetFragmentErrors=function(g){g===ZI&&(this.fragCurrent=null),this.loadedmetadata||(this.startFragRequested=!1),this.state!==VC&&(this.state=yC)},C.afterBufferFlushed=function(g,I,C){if(g){var A=bC.getBuffered(g);this.fragmentTracker.detectEvictedFragments(I,A,C),this.state===FC&&this.resetLoadingState()}},C.resetLoadingState=function(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=yC},C.resetStartWhenNotLoaded=function(g){if(!this.loadedmetadata){this.startFragRequested=!1;var I=this.levels?this.levels[g].details:null;null!=I&&I.live?(this.startPosition=-1,this.setStartPosition(I,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}},C.resetWhenMissingContext=function(g){var I;this.warn("The loading context changed while buffering fragment "+g.sn+" of level "+g.level+". This chunk will not be buffered."),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded(null!=(I=this.levelLastLoaded)?I:g.level),this.resetLoadingState()},C.removeUnbufferedFrags=function(g){void 0===g&&(g=0),this.fragmentTracker.removeFragmentsInRange(g,1/0,this.playlistType,!1,!0)},C.updateLevelTiming=function(g,I,C,A){var i,e=this,l=C.details;if(l){if(Object.keys(g.elementaryStreams).reduce((function(I,i){var t=g.elementaryStreams[i];if(t){var s=t.endPTS-t.startPTS;if(s<=0)return e.warn("Could not parse fragment "+g.sn+" "+i+" duration reliably ("+s+")"),I||!1;var c=A?0:MI(l,g,t.startPTS,t.endPTS,t.startDTS,t.endDTS);return e.hls.trigger(p.LEVEL_PTS_UPDATED,{details:l,level:C,drift:c,type:i,frag:g,start:t.startPTS,end:t.endPTS}),!0}return I}),!1))C.fragmentError=0;else if(null===(null==(i=this.transmuxer)?void 0:i.error)){var t=new Error("Found no media in fragment "+g.sn+" of level "+g.level+" resetting transmuxer to fallback to playlist timing");if(0===C.fragmentError&&(C.fragmentError++,g.gap=!0,this.fragmentTracker.removeFragment(g),this.fragmentTracker.fragBuffered(g,!0)),this.warn(t.message),this.hls.trigger(p.ERROR,{type:V.MEDIA_ERROR,details:y.FRAG_PARSING_ERROR,fatal:!1,error:t,frag:g,reason:"Found no media in msn "+g.sn+' of level "'+C.url+'"'}),!this.hls)return;this.resetTransmuxer()}this.state=KC,this.hls.trigger(p.FRAG_PARSED,{frag:g,part:I})}else this.warn("level.details undefined")},C.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},C.recoverWorkerError=function(g){var I,C,A;"demuxerWorker"===g.event&&(this.fragmentTracker.removeAllFragments(),this.resetTransmuxer(),this.resetStartWhenNotLoaded(null!=(I=null!=(C=this.levelLastLoaded)?C:null==(A=this.fragCurrent)?void 0:A.level)?I:0),this.resetLoadingState())},e(I,[{key:"state",get:function(){return this._state},set:function(g){var I=this._state;I!==g&&(this._state=g,this.log(I+"->"+g))}}]),I}(aC);function kC(){return self.SourceBuffer||self.WebKitSourceBuffer}function DC(g,I){return void 0===g&&(g=""),void 0===I&&(I=9e4),{type:g,id:-1,pid:-1,inputTimeScale:I,sequenceNumber:-1,samples:[],dropped:0}}var LC=function(){function g(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}var I=g.prototype;return I.resetInitSegment=function(g,I,C,A){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},I.resetTimeStamp=function(g){this.initPTS=g,this.resetContiguity()},I.resetContiguity=function(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0},I.canParse=function(g,I){return!1},I.appendFrame=function(g,I,C){},I.demux=function(g,I){this.cachedData&&(g=Fg(this.cachedData,g),this.cachedData=null);var C,A=tg(g,0),i=A?A.length:0,e=this._audioTrack,l=this._id3Track,t=A?function(g){for(var I=ng(g),C=0;C0&&l.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:A,type:WI,duration:Number.POSITIVE_INFINITY});i>>5}function UC(g,I){return I+1=g.length)return!1;var A=xC(g,I);if(A<=C)return!1;var i=I+A;return i===g.length||UC(g,i)}return!1}function jC(g,I,C,A,i){if(!g.samplerate){var e=function(g,I,C,A){var i,e,l,t,s=navigator.userAgent.toLowerCase(),c=A,d=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];i=1+((192&I[C+2])>>>6);var o=(60&I[C+2])>>>2;if(!(o>d.length-1))return l=(1&I[C+2])<<2,l|=(192&I[C+3])>>>6,H.log("manifest codec:"+A+", ADTS type:"+i+", samplingIndex:"+o),/firefox/i.test(s)?o>=6?(i=5,t=new Array(4),e=o-3):(i=2,t=new Array(2),e=o):-1!==s.indexOf("android")?(i=2,t=new Array(2),e=o):(i=5,t=new Array(4),A&&(-1!==A.indexOf("mp4a.40.29")||-1!==A.indexOf("mp4a.40.5"))||!A&&o>=6?e=o-3:((A&&-1!==A.indexOf("mp4a.40.2")&&(o>=6&&1===l||/vivaldi/i.test(s))||!A&&1===l)&&(i=2,t=new Array(2)),e=o)),t[0]=i<<3,t[0]|=(14&o)>>1,t[1]|=(1&o)<<7,t[1]|=l<<3,5===i&&(t[1]|=(14&e)>>1,t[2]=(1&e)<<7,t[2]|=8,t[3]=0),{config:t,samplerate:d[o],channelCount:l,codec:"mp4a.40."+i,manifestCodec:c};g.trigger(p.ERROR,{type:V.MEDIA_ERROR,details:y.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+o})}(I,C,A,i);if(!e)return;g.config=e.config,g.samplerate=e.samplerate,g.channelCount=e.channelCount,g.codec=e.codec,g.manifestCodec=e.manifestCodec,H.log("parsed codec:"+g.codec+", rate:"+e.samplerate+", channels:"+e.channelCount)}}function OC(g){return 9216e4/g}function EC(g,I,C,A,i){var e,l=A+i*OC(g.samplerate),t=function(g,I){var C=TC(g,I);if(I+C<=g.length){var A=xC(g,I)-C;if(A>0)return{headerLength:C,frameLength:A}}}(I,C);if(t){var s=t.frameLength,c=t.headerLength,d=c+s,o=Math.max(0,C+d-I.length);o?(e=new Uint8Array(d-c)).set(I.subarray(C+c,I.length),0):e=I.subarray(C+c,C+d);var n={unit:e,pts:l};return o||g.samples.push(n),{sample:n,length:d,missing:o}}var a=I.length-C;return(e=new Uint8Array(a)).set(I.subarray(C,I.length),0),{sample:{unit:e,pts:l},length:a,missing:-1}}var PC=function(g){function I(I,C){var A;return(A=g.call(this)||this).observer=void 0,A.config=void 0,A.observer=I,A.config=C,A}s(I,g);var C=I.prototype;return C.resetInitSegment=function(I,C,A,i){g.prototype.resetInitSegment.call(this,I,C,A,i),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:C,duration:i,inputTimeScale:9e4,dropped:0}},I.probe=function(g){if(!g)return!1;for(var I=(tg(g,0)||[]).length,C=g.length;I16384?g.subarray(0,16384):g,["moof"]).length>0},I.demux=function(g,I){this.timeOffset=I;var C=g,A=this.videoTrack,i=this.txtTrack;if(this.config.progressive){this.remainderData&&(C=Fg(this.remainderData,g));var e=function(g){var I={valid:null,remainder:null},C=Yg(g,["moof"]);if(!C)return I;if(C.length<2)return I.remainder=g,I;var A=C[C.length-1];return I.valid=Ag(g,0,A.byteOffset-8),I.remainder=Ag(g,A.byteOffset-8),I}(C);this.remainderData=e.remainder,A.samples=e.valid||new Uint8Array}else A.samples=C;var l=this.extractID3Track(A,I);return i.samples=Mg(I,A),{videoTrack:A,audioTrack:this.audioTrack,id3Track:l,textTrack:this.txtTrack}},I.flush=function(){var g=this.timeOffset,I=this.videoTrack,C=this.txtTrack;I.samples=this.remainderData||new Uint8Array,this.remainderData=null;var A=this.extractID3Track(I,this.timeOffset);return C.samples=Mg(g,I),{videoTrack:I,audioTrack:DC(),id3Track:A,textTrack:DC()}},I.extractID3Track=function(g,I){var C=this.id3Track;if(g.samples.length){var A=Yg(g.samples,["emsg"]);A&&A.forEach((function(g){var A=function(g){var I=g[0],C="",A="",i=0,e=0,l=0,t=0,s=0,c=0;if(0===I){for(;"\0"!==Wg(g.subarray(c,c+1));)C+=Wg(g.subarray(c,c+1)),c+=1;for(C+=Wg(g.subarray(c,c+1)),c+=1;"\0"!==Wg(g.subarray(c,c+1));)A+=Wg(g.subarray(c,c+1)),c+=1;A+=Wg(g.subarray(c,c+1)),c+=1,i=Vg(g,12),e=Vg(g,16),t=Vg(g,20),s=Vg(g,24),c=28}else if(1===I){i=Vg(g,c+=4);var d=Vg(g,c+=4),o=Vg(g,c+=4);for(c+=4,l=Math.pow(2,32)*d+o,Number.isSafeInteger(l)||(l=Number.MAX_SAFE_INTEGER,H.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),t=Vg(g,c),s=Vg(g,c+=4),c+=4;"\0"!==Wg(g.subarray(c,c+1));)C+=Wg(g.subarray(c,c+1)),c+=1;for(C+=Wg(g.subarray(c,c+1)),c+=1;"\0"!==Wg(g.subarray(c,c+1));)A+=Wg(g.subarray(c,c+1)),c+=1;A+=Wg(g.subarray(c,c+1)),c+=1}return{schemeIdUri:C,value:A,timeScale:i,presentationTime:l,presentationTimeDelta:e,eventDuration:t,id:s,payload:g.subarray(c,g.byteLength)}}(g);if(_C.test(A.schemeIdUri)){var i=W(A.presentationTime)?A.presentationTime/A.timeScale:I+A.presentationTimeDelta/A.timeScale,e=4294967295===A.eventDuration?Number.POSITIVE_INFINITY:A.eventDuration/A.timeScale;e<=.001&&(e=Number.POSITIVE_INFINITY);var l=A.payload;C.samples.push({data:l,len:l.byteLength,dts:i,pts:i,type:pI,duration:e})}}))}return C},I.demuxSampleAes=function(g,I,C){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},I.destroy=function(){},g}(),$C=null,gA=[32,64,96,128,160,192,224,256,288,320,352,384,416,448,32,48,56,64,80,96,112,128,160,192,224,256,320,384,32,40,48,56,64,80,96,112,128,160,192,224,256,320,32,48,56,64,80,96,112,128,144,160,176,192,224,256,8,16,24,32,40,48,56,64,80,96,112,128,144,160],IA=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],CA=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],AA=[0,1,1,4];function iA(g,I,C,A,i){if(!(C+24>I.length)){var e=eA(I,C);if(e&&C+e.frameLength<=I.length){var l=A+i*(9e4*e.samplesPerFrame/e.sampleRate),t={unit:I.subarray(C,C+e.frameLength),pts:l,dts:l};return g.config=[],g.channelCount=e.channelCount,g.samplerate=e.sampleRate,g.samples.push(t),{sample:t,length:e.frameLength,missing:0}}}}function eA(g,I){var C=g[I+1]>>3&3,A=g[I+1]>>1&3,i=g[I+2]>>4&15,e=g[I+2]>>2&3;if(1!==C&&0!==i&&15!==i&&3!==e){var l=g[I+2]>>1&1,t=g[I+3]>>6,s=1e3*gA[14*(3===C?3-A:3===A?3:4)+i-1],c=IA[3*(3===C?0:2===C?1:2)+e],d=3===t?1:2,o=CA[C][A],n=AA[A],a=8*o*n,Z=Math.floor(o*s/c+l)*n;if(null===$C){var b=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);$C=b?parseInt(b[1]):0}return!!$C&&$C<=87&&2===A&&s>=224e3&&0===t&&(g[I+3]=128|g[I+3]),{sampleRate:c,channelCount:d,frameLength:Z,samplesPerFrame:a}}}function lA(g,I){return!(255!==g[I]||224&~g[I+1]||!(6&g[I+1]))}function tA(g,I){return I+1g?(this.word<<=g,this.bitsAvailable-=g):(g-=this.bitsAvailable,g-=(I=g>>3)<<3,this.bytesAvailable-=I,this.loadWord(),this.word<<=g,this.bitsAvailable-=g)},I.readBits=function(g){var I=Math.min(this.bitsAvailable,g),C=this.word>>>32-I;if(g>32&&H.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=I,this.bitsAvailable>0)this.word<<=I;else{if(!(this.bytesAvailable>0))throw new Error("no bits available");this.loadWord()}return(I=g-I)>0&&this.bitsAvailable?C<>>g)return this.word<<=g,this.bitsAvailable-=g,g;return this.loadWord(),g+this.skipLZ()},I.skipUEG=function(){this.skipBits(1+this.skipLZ())},I.skipEG=function(){this.skipBits(1+this.skipLZ())},I.readUEG=function(){var g=this.skipLZ();return this.readBits(g+1)-1},I.readEG=function(){var g=this.readUEG();return 1&g?1+g>>>1:-1*(g>>>1)},I.readBoolean=function(){return 1===this.readBits(1)},I.readUByte=function(){return this.readBits(8)},I.readUShort=function(){return this.readBits(16)},I.readUInt=function(){return this.readBits(32)},I.skipScalingList=function(g){for(var I=8,C=8,A=0;A=g.length)return void C();if(!(g[I].unit.length<32||(this.decryptAacSample(g,I,C),this.decrypter.isSync())))return}},I.getAvcEncryptedData=function(g){for(var I=16*Math.floor((g.length-48)/160)+16,C=new Int8Array(I),A=0,i=32;i=g.length)return void A();for(var i=g[I].units;!(C>=i.length);C++){var e=i[C];if(!(e.data.length<=48||1!==e.type&&5!==e.type||(this.decryptAvcSample(g,I,C,A,e),this.decrypter.isSync())))return}}},g}(),oA=188,nA=function(){function g(g,I,C){this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._duration=0,this._pmtId=-1,this._avcTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.observer=g,this.config=I,this.typeSupported=C}g.probe=function(I){var C=g.syncOffset(I);return C>0&&H.warn("MPEG2-TS detected but first sync word found @ offset "+C),-1!==C},g.syncOffset=function(g){for(var I=g.length,C=Math.min(940,g.length-oA)+1,A=0;A1&&(0===e&&l>2||t+oA>C))return e}A++}return-1},g.createTrack=function(g,I){return{container:"video"===g||"audio"===g?"video/mp2t":void 0,type:g,id:wg[g],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:"audio"===g?I:void 0}};var I=g.prototype;return I.resetInitSegment=function(I,C,A,i){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=g.createTrack("video"),this._audioTrack=g.createTrack("audio",i),this._id3Track=g.createTrack("id3"),this._txtTrack=g.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.audioCodec=C,this.videoCodec=A,this._duration=i},I.resetTimeStamp=function(){},I.resetContiguity=function(){var g=this._audioTrack,I=this._avcTrack,C=this._id3Track;g&&(g.pesData=null),I&&(I.pesData=null),C&&(C.pesData=null),this.aacOverFlow=null,this.avcSample=null,this.remainderData=null},I.demux=function(I,C,A,i){var e;void 0===A&&(A=!1),void 0===i&&(i=!1),A||(this.sampleAes=null);var l=this._avcTrack,t=this._audioTrack,s=this._id3Track,c=this._txtTrack,d=l.pid,o=l.pesData,n=t.pid,a=s.pid,Z=t.pesData,b=s.pesData,r=null,m=this.pmtParsed,h=this._pmtId,G=I.length;if(this.remainderData&&(G=(I=Fg(this.remainderData,I)).length,this.remainderData=null),G>4>1){if((Y=w+5+I[w+4])===w+oA)continue}else Y=w+4;switch(X){case d:W&&(o&&(e=mA(o))&&this.parseAVCPES(l,c,e,!1),o={data:[],size:0}),o&&(o.data.push(I.subarray(Y,w+oA)),o.size+=w+oA-Y);break;case n:if(W){if(Z&&(e=mA(Z)))switch(t.segmentCodec){case"aac":this.parseAACPES(t,e);break;case"mp3":this.parseMPEGPES(t,e)}Z={data:[],size:0}}Z&&(Z.data.push(I.subarray(Y,w+oA)),Z.size+=w+oA-Y);break;case a:W&&(b&&(e=mA(b))&&this.parseID3PES(s,e),b={data:[],size:0}),b&&(b.data.push(I.subarray(Y,w+oA)),b.size+=w+oA-Y);break;case 0:W&&(Y+=I[Y]+1),h=this._pmtId=bA(I,Y);break;case h:W&&(Y+=I[Y]+1);var R=rA(I,Y,this.typeSupported,A);(d=R.avc)>0&&(l.pid=d),(n=R.audio)>0&&(t.pid=n,t.segmentCodec=R.segmentCodec),(a=R.id3)>0&&(s.pid=a),null===r||m||(H.warn("MPEG-TS PMT found at "+w+" after unknown PID '"+r+"'. Backtracking to sync byte @"+u+" to parse all TS packets."),r=null,w=u-188),m=this.pmtParsed=!0;break;case 17:case 8191:break;default:r=X}}else B++;if(B>0){var N=new Error("Found "+B+" TS packet/s that do not start with 0x47");this.observer.emit(p.ERROR,p.ERROR,{type:V.MEDIA_ERROR,details:y.FRAG_PARSING_ERROR,fatal:!1,error:N,reason:N.message})}l.pesData=o,t.pesData=Z,s.pesData=b;var K={audioTrack:t,videoTrack:l,id3Track:s,textTrack:c};return i&&this.extractRemainingSamples(K),K},I.flush=function(){var g,I=this.remainderData;return this.remainderData=null,g=I?this.demux(I,-1,!1,!0):{videoTrack:this._avcTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(g),this.sampleAes?this.decrypt(g,this.sampleAes):g},I.extractRemainingSamples=function(g){var I,C=g.audioTrack,A=g.videoTrack,i=g.id3Track,e=g.textTrack,l=A.pesData,t=C.pesData,s=i.pesData;if(l&&(I=mA(l))?(this.parseAVCPES(A,e,I,!0),A.pesData=null):A.pesData=l,t&&(I=mA(t))){switch(C.segmentCodec){case"aac":this.parseAACPES(C,I);break;case"mp3":this.parseMPEGPES(C,I)}C.pesData=null}else null!=t&&t.size&&H.log("last AAC PES packet truncated,might overlap between fragments"),C.pesData=t;s&&(I=mA(s))?(this.parseID3PES(i,I),i.pesData=null):i.pesData=s},I.demuxSampleAes=function(g,I,C){var A=this.demux(g,C,!0,!this.config.progressive),i=this.sampleAes=new dA(this.observer,this.config,I);return this.decrypt(A,i)},I.decrypt=function(g,I){return new Promise((function(C){var A=g.audioTrack,i=g.videoTrack;A.samples&&"aac"===A.segmentCodec?I.decryptAacSamples(A.samples,0,(function(){i.samples?I.decryptAvcSamples(i.samples,0,0,(function(){C(g)})):C(g)})):i.samples&&I.decryptAvcSamples(i.samples,0,0,(function(){C(g)}))}))},I.destroy=function(){this._duration=0},I.parseAVCPES=function(g,I,C,A){var i,e=this,l=this.parseAVCNALu(g,C.data),t=this.avcSample,s=!1;C.data=null,t&&l.length&&!g.audFound&&(hA(t,g),t=this.avcSample=aA(!1,C.pts,C.dts,"")),l.forEach((function(A){var l;switch(A.type){case 1:var c=!1;i=!0;var d,o=A.data;if(s&&o.length>4){var n=new cA(o).readSliceType();2!==n&&4!==n&&7!==n&&9!==n||(c=!0)}c&&null!=(d=t)&&d.frame&&!t.key&&(hA(t,g),t=e.avcSample=null),t||(t=e.avcSample=aA(!0,C.pts,C.dts,"")),t.frame=!0,t.key=c;break;case 5:i=!0,null!=(l=t)&&l.frame&&!t.key&&(hA(t,g),t=e.avcSample=null),t||(t=e.avcSample=aA(!0,C.pts,C.dts,"")),t.key=!0,t.frame=!0;break;case 6:i=!0,Sg(A.data,1,C.pts,I.samples);break;case 7:if(i=!0,s=!0,!g.sps){var a=A.data,Z=new cA(a).readSPS();g.width=Z.width,g.height=Z.height,g.pixelRatio=Z.pixelRatio,g.sps=[a],g.duration=e._duration;for(var b=a.subarray(1,4),r="avc1.",m=0;m<3;m++){var h=b[m].toString(16);h.length<2&&(h="0"+h),r+=h}g.codec=r}break;case 8:i=!0,g.pps||(g.pps=[A.data]);break;case 9:i=!1,g.audFound=!0,t&&hA(t,g),t=e.avcSample=aA(!1,C.pts,C.dts,"");break;case 12:i=!0;break;default:i=!1,t&&(t.debug+="unknown NAL "+A.type+" ")}t&&i&&t.units.push(A)})),A&&t&&(hA(t,g),this.avcSample=null)},I.getLastNalUnit=function(g){var I,C,A=this.avcSample;if(A&&0!==A.units.length||(A=g[g.length-1]),null!=(I=A)&&I.units){var i=A.units;C=i[i.length-1]}return C},I.parseAVCNALu=function(g,I){var C,A,i=I.byteLength,e=g.naluState||0,l=e,t=[],s=0,c=-1,d=0;for(-1===e&&(c=0,d=31&I[0],e=0,s=1);s=0){var o={data:I.subarray(c,s-e-1),type:d};t.push(o)}else{var n=this.getLastNalUnit(g.samples);if(n&&(l&&s<=4-l&&n.state&&(n.data=n.data.subarray(0,n.data.byteLength-l)),(A=s-e-1)>0)){var a=new Uint8Array(n.data.byteLength+A);a.set(n.data,0),a.set(I.subarray(0,A),n.data.byteLength),n.data=a,n.state=0}}s=0&&e>=0){var Z={data:I.subarray(c,i),type:d,state:e};t.push(Z)}if(0===t.length){var b=this.getLastNalUnit(g.samples);if(b){var r=new Uint8Array(b.data.byteLength+I.byteLength);r.set(b.data,0),r.set(I,b.data.byteLength),b.data=r}}return g.naluState=e,t},I.parseAACPES=function(g,I){var C,A,i,e=0,l=this.aacOverFlow,t=I.data;if(l){this.aacOverFlow=null;var s=l.missing,c=l.sample.unit.byteLength;if(-1===s){var d=new Uint8Array(c+t.byteLength);d.set(l.sample.unit,0),d.set(t,c),t=d}else{var o=c-s;l.sample.unit.set(t.subarray(0,s),o),g.samples.push(l.sample),e=l.missing}}for(C=e,A=t.length;C1;){var s=new Uint8Array(t[0].length+t[1].length);s.set(t[0]),s.set(t[1],t[0].length),t[0]=s,t.splice(1,1)}if(1===((I=t[0])[0]<<16)+(I[1]<<8)+I[2]){if((C=(I[4]<<8)+I[5])&&C>g.size-6)return null;var c=I[7];192&c&&(i=536870912*(14&I[9])+4194304*(255&I[10])+16384*(254&I[11])+128*(255&I[12])+(254&I[13])/2,64&c?i-(e=536870912*(14&I[14])+4194304*(255&I[15])+16384*(254&I[16])+128*(255&I[17])+(254&I[18])/2)>54e5&&(H.warn(Math.round((i-e)/9e4)+"s delta between PTS and DTS, align them"),i=e):e=i);var d=(A=I[8])+9;if(g.size<=d)return null;g.size-=d;for(var o=new Uint8Array(g.size),n=0,a=t.length;nZ){d-=Z;continue}I=I.subarray(d),Z-=d,d=0}o.set(I,l),l+=Z}return C&&(C-=A+3),{data:o,pts:i,dts:e,len:C}}return null}function hA(g,I){if(g.units.length&&g.frame){if(void 0===g.pts){var C=I.samples,A=C.length;if(!A)return void I.dropped++;var i=C[A-1];g.pts=i.pts,g.dts=i.dts}I.samples.push(g)}g.debug.length&&H.log(g.pts+"/"+g.dts+":"+g.debug)}var GA=function(g){function I(){return g.apply(this,arguments)||this}s(I,g);var C=I.prototype;return C.resetInitSegment=function(I,C,A,i){g.prototype.resetInitSegment.call(this,I,C,A,i),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:C,duration:i,inputTimeScale:9e4,dropped:0}},I.probe=function(g){if(!g)return!1;for(var I=(tg(g,0)||[]).length,C=g.length;I1?C-1:0),i=1;i>24&255,t[1]=I>>16&255,t[2]=I>>8&255,t[3]=255&I,t.set(g,4),e=0,I=8;e>24&255,I>>16&255,I>>8&255,255&I,A>>24,A>>16&255,A>>8&255,255&A,i>>24,i>>16&255,i>>8&255,255&i,85,196,0,0]))},g.mdia=function(I){return g.box(g.types.mdia,g.mdhd(I.timescale,I.duration),g.hdlr(I.type),g.minf(I))},g.mfhd=function(I){return g.box(g.types.mfhd,new Uint8Array([0,0,0,0,I>>24,I>>16&255,I>>8&255,255&I]))},g.minf=function(I){return"audio"===I.type?g.box(g.types.minf,g.box(g.types.smhd,g.SMHD),g.DINF,g.stbl(I)):g.box(g.types.minf,g.box(g.types.vmhd,g.VMHD),g.DINF,g.stbl(I))},g.moof=function(I,C,A){return g.box(g.types.moof,g.mfhd(I),g.traf(A,C))},g.moov=function(I){for(var C=I.length,A=[];C--;)A[C]=g.trak(I[C]);return g.box.apply(null,[g.types.moov,g.mvhd(I[0].timescale,I[0].duration)].concat(A).concat(g.mvex(I)))},g.mvex=function(I){for(var C=I.length,A=[];C--;)A[C]=g.trex(I[C]);return g.box.apply(null,[g.types.mvex].concat(A))},g.mvhd=function(I,C){C*=I;var A=Math.floor(C/(BA+1)),i=Math.floor(C%(BA+1)),e=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,I>>24&255,I>>16&255,I>>8&255,255&I,A>>24,A>>16&255,A>>8&255,255&A,i>>24,i>>16&255,i>>8&255,255&i,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return g.box(g.types.mvhd,e)},g.sdtp=function(I){var C,A,i=I.samples||[],e=new Uint8Array(4+i.length);for(C=0;C>>8&255),e.push(255&i),e=e.concat(Array.prototype.slice.call(A));for(C=0;C>>8&255),l.push(255&i),l=l.concat(Array.prototype.slice.call(A));var t=g.box(g.types.avcC,new Uint8Array([1,e[3],e[4],e[5],255,224|I.sps.length].concat(e).concat([I.pps.length]).concat(l))),s=I.width,c=I.height,d=I.pixelRatio[0],o=I.pixelRatio[1];return g.box(g.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,s>>8&255,255&s,c>>8&255,255&c,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),t,g.box(g.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),g.box(g.types.pasp,new Uint8Array([d>>24,d>>16&255,d>>8&255,255&d,o>>24,o>>16&255,o>>8&255,255&o])))},g.esds=function(g){var I=g.config.length;return new Uint8Array([0,0,0,0,3,23+I,0,1,0,4,15+I,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([I]).concat(g.config).concat([6,1,2]))},g.mp4a=function(I){var C=I.samplerate;return g.box(g.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,I.channelCount,0,16,0,0,0,0,C>>8&255,255&C,0,0]),g.box(g.types.esds,g.esds(I)))},g.mp3=function(I){var C=I.samplerate;return g.box(g.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,I.channelCount,0,16,0,0,0,0,C>>8&255,255&C,0,0]))},g.stsd=function(I){return"audio"===I.type?"mp3"===I.segmentCodec&&"mp3"===I.codec?g.box(g.types.stsd,g.STSD,g.mp3(I)):g.box(g.types.stsd,g.STSD,g.mp4a(I)):g.box(g.types.stsd,g.STSD,g.avc1(I))},g.tkhd=function(I){var C=I.id,A=I.duration*I.timescale,i=I.width,e=I.height,l=Math.floor(A/(BA+1)),t=Math.floor(A%(BA+1));return g.box(g.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,C>>24&255,C>>16&255,C>>8&255,255&C,0,0,0,0,l>>24,l>>16&255,l>>8&255,255&l,t>>24,t>>16&255,t>>8&255,255&t,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,i>>8&255,255&i,0,0,e>>8&255,255&e,0,0]))},g.traf=function(I,C){var A=g.sdtp(I),i=I.id,e=Math.floor(C/(BA+1)),l=Math.floor(C%(BA+1));return g.box(g.types.traf,g.box(g.types.tfhd,new Uint8Array([0,0,0,0,i>>24,i>>16&255,i>>8&255,255&i])),g.box(g.types.tfdt,new Uint8Array([1,0,0,0,e>>24,e>>16&255,e>>8&255,255&e,l>>24,l>>16&255,l>>8&255,255&l])),g.trun(I,A.length+16+20+8+16+8+8),A)},g.trak=function(I){return I.duration=I.duration||4294967295,g.box(g.types.trak,g.tkhd(I),g.mdia(I))},g.trex=function(I){var C=I.id;return g.box(g.types.trex,new Uint8Array([0,0,0,0,C>>24,C>>16&255,C>>8&255,255&C,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},g.trun=function(I,C){var A,i,e,l,t,s,c=I.samples||[],d=c.length,o=12+16*d,n=new Uint8Array(o);for(C+=8+o,n.set(["video"===I.type?1:0,0,15,1,d>>>24&255,d>>>16&255,d>>>8&255,255&d,C>>>24&255,C>>>16&255,C>>>8&255,255&C],0),A=0;A>>24&255,e>>>16&255,e>>>8&255,255&e,l>>>24&255,l>>>16&255,l>>>8&255,255&l,t.isLeading<<2|t.dependsOn,t.isDependedOn<<6|t.hasRedundancy<<4|t.paddingValue<<1|t.isNonSync,61440&t.degradPrio,15&t.degradPrio,s>>>24&255,s>>>16&255,s>>>8&255,255&s],12+16*A);return g.box(g.types.trun,n)},g.initSegment=function(I){g.types||g.init();var C=g.moov(I),A=new Uint8Array(g.FTYP.byteLength+C.byteLength);return A.set(g.FTYP),A.set(C,g.FTYP.byteLength),A},g}();function WA(g,I,C,A){void 0===C&&(C=1),void 0===A&&(A=!1);var i=g*I*C;return A?Math.round(i):i}function pA(g,I){return WA(g,1e3,1/9e4,I)}wA.types=void 0,wA.HDLR_TYPES=void 0,wA.STTS=void 0,wA.STSC=void 0,wA.STCO=void 0,wA.STSZ=void 0,wA.VMHD=void 0,wA.SMHD=void 0,wA.STSD=void 0,wA.FTYP=void 0,wA.DINF=void 0;var VA=null,yA=null,XA=function(){function g(g,I,C,A){if(this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=null,this._initDTS=null,this.nextAvcDts=null,this.nextAudioPts=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.observer=g,this.config=I,this.typeSupported=C,this.ISGenerated=!1,null===VA){var i=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);VA=i?parseInt(i[1]):0}if(null===yA){var e=navigator.userAgent.match(/Safari\/(\d+)/i);yA=e?parseInt(e[1]):0}}var I=g.prototype;return I.destroy=function(){},I.resetTimeStamp=function(g){H.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=g},I.resetNextTimestamp=function(){H.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},I.resetInitSegment=function(){H.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1},I.getVideoStartPts=function(g){var I=!1,C=g.reduce((function(g,C){var A=C.pts-g;return A<-4294967296?(I=!0,YA(g,C.pts)):A>0?g:C.pts}),g[0].pts);return I&&H.debug("PTS rollover detected"),C},I.remux=function(g,I,C,A,i,e,l,t){var s,c,d,o,n,a,Z=i,b=i,r=g.pid>-1,m=I.pid>-1,h=I.samples.length,G=g.samples.length>0,u=l&&h>0||h>1;if((!r||G)&&(!m||u)||this.ISGenerated||l){this.ISGenerated||(d=this.generateIS(g,I,i,e));var B,w=this.isVideoContiguous,W=-1;if(u&&(W=function(g){for(var I=0;I0){H.warn("[mp4-remuxer]: Dropped "+W+" out of "+h+" video samples due to a missing keyframe");var p=this.getVideoStartPts(I.samples);I.samples=I.samples.slice(W),I.dropped+=W,B=b+=(I.samples[0].pts-p)/I.inputTimeScale}else-1===W&&(H.warn("[mp4-remuxer]: No keyframe found out of "+h+" video samples"),a=!1);if(this.ISGenerated){if(G&&u){var V=this.getVideoStartPts(I.samples),y=(YA(g.samples[0].pts,V)-V)/I.inputTimeScale;Z+=Math.max(0,y),b+=Math.max(0,-y)}if(G){if(g.samplerate||(H.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),d=this.generateIS(g,I,i,e)),c=this.remuxAudio(g,Z,this.isAudioContiguous,e,m||u||t===ZI?b:void 0),u){var X=c?c.endPTS-c.startPTS:0;I.inputTimeScale||(H.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),d=this.generateIS(g,I,i,e)),s=this.remuxVideo(I,b,w,X)}}else u&&(s=this.remuxVideo(I,b,w,0));s&&(s.firstKeyFrame=W,s.independent=-1!==W,s.firstKeyFramePTS=B)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(C.samples.length&&(n=RA(C,i,this._initPTS,this._initDTS)),A.samples.length&&(o=NA(A,i,this._initPTS))),{audio:c,video:s,initSegment:d,independent:a,text:o,id3:n}},I.generateIS=function(g,I,C,A){var i,e,l,t=g.samples,s=I.samples,c=this.typeSupported,d={},o=this._initPTS,n=!o||A,a="audio/mp4";if(n&&(i=e=1/0),g.config&&t.length&&(g.timescale=g.samplerate,"mp3"===g.segmentCodec&&(c.mpeg?(a="audio/mpeg",g.codec=""):c.mp3&&(g.codec="mp3")),d.audio={id:"audio",container:a,codec:g.codec,initSegment:"mp3"===g.segmentCodec&&c.mpeg?new Uint8Array(0):wA.initSegment([g]),metadata:{channelCount:g.channelCount}},n&&(l=g.inputTimeScale,o&&l===o.timescale?n=!1:i=e=t[0].pts-Math.round(l*C))),I.sps&&I.pps&&s.length&&(I.timescale=I.inputTimeScale,d.video={id:"main",container:"video/mp4",codec:I.codec,initSegment:wA.initSegment([I]),metadata:{width:I.width,height:I.height}},n))if(l=I.inputTimeScale,o&&l===o.timescale)n=!1;else{var Z=this.getVideoStartPts(s),b=Math.round(l*C);e=Math.min(e,YA(s[0].dts,Z)-b),i=Math.min(i,Z-b)}if(Object.keys(d).length)return this.ISGenerated=!0,n?(this._initPTS={baseTime:i,timescale:l},this._initDTS={baseTime:e,timescale:l}):i=l=void 0,{tracks:d,initPTS:i,timescale:l}},I.remuxVideo=function(g,I,C,A){var i,e,l=g.inputTimeScale,s=g.samples,c=[],d=s.length,o=this._initPTS,n=this.nextAvcDts,a=8,Z=this.videoSampleDuration,b=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY,m=!1;C&&null!==n||(n=I*l-(s[0].pts-YA(s[0].dts,s[0].pts)));for(var h=o.baseTime*l/o.timescale,G=0;G0?G-1:G].dts&&(m=!0)}m&&s.sort((function(g,I){var C=g.dts-I.dts,A=g.pts-I.pts;return C||A})),i=s[0].dts;var B=s[s.length-1].dts-i,w=B?Math.round(B/(d-1)):Z||g.inputTimeScale/30;if(C){var W=i-n,X=W>w,Y=W<-1;if((X||Y)&&(X?H.warn("AVC: "+pA(W,!0)+" ms ("+W+"dts) hole between fragments detected, filling it"):H.warn("AVC: "+pA(-W,!0)+" ms ("+W+"dts) overlapping between fragments detected"),!Y||n>=s[0].pts)){i=n;var R=s[0].pts-W;s[0].dts=i,s[0].pts=R,H.log("Video: First PTS/DTS adjusted: "+pA(R,!0)+"/"+pA(i,!0)+", delta: "+pA(W,!0)+" ms")}}i=Math.max(0,i);for(var N=0,K=0,F=0;F0?O.dts-s[j-1].dts:w;if(Cg=j>0?O.pts-s[j-1].pts:w,Ag.stretchShortVideoTrack&&null!==this.nextAudioPts){var eg=Math.floor(Ag.maxBufferHole*l),lg=(A?b+A*l:this.nextAudioPts)-O.pts;lg>eg?((Z=lg-ig)<0?Z=ig:v=!0,H.log("[mp4-remuxer]: It is approximately "+lg/90+" ms to the next segment; using duration "+Z/90+" ms for the last video frame.")):Z=ig}else Z=ig}var tg=Math.round(O.pts-O.dts);T=Math.min(T,Z),U=Math.max(U,Z),x=Math.min(x,Cg),Q=Math.max(Q,Cg),c.push(new KA(O.key,Z,P,tg))}if(c.length)if(VA){if(VA<70){var sg=c[0].flags;sg.dependsOn=2,sg.isNonSync=0}}else if(yA&&Q-x0&&(A&&Math.abs(m-r)<9e3||Math.abs(YA(Z[0].pts-h,m)-r)<20*c),Z.forEach((function(g){g.pts=YA(g.pts-h,m)})),!C||r<0){if(!(Z=Z.filter((function(g){return g.pts>=0}))).length)return;r=0===i?0:A&&!a?Math.max(0,m):Z[0].pts}if("aac"===g.segmentCodec)for(var G=this.config.maxAudioFramesDrift,u=0,B=r;u=G*c&&Y<1e4&&a){var R=Math.round(X/c);(B=W-R*c)<0&&(R--,B+=c),0===u&&(this.nextAudioPts=r=B),H.warn("[mp4-remuxer]: Injecting "+R+" audio frame @ "+(B/e).toFixed(3)+"s due to "+Math.round(1e3*X/e)+" ms gap.");for(var N=0;N0))return;f+=b;try{M=new Uint8Array(f)}catch(_){return void this.observer.emit(p.ERROR,p.ERROR,{type:V.MUX_ERROR,details:y.REMUX_ALLOC_ERROR,fatal:!1,error:_,bytes:f,reason:"fail allocating audio mdat "+f})}o||(new DataView(M.buffer).setUint32(0,f),M.set(wA.types.mdat,4))}M.set(v,b);var x=v.byteLength;b+=x,n.push(new KA(!0,s,x,0)),S=T}var U=n.length;if(U){var Q=n[n.length-1];this.nextAudioPts=r=S+l*Q.duration;var j=o?new Uint8Array(0):wA.moof(g.sequenceNumber++,J/l,t({},g,{samples:n}));g.samples=[];var O=J/e,E=r/e,P={data1:j,data2:M,startPTS:O,endPTS:E,startDTS:O,endDTS:E,type:"audio",hasAudio:!0,hasVideo:!1,nb:U};return this.isAudioContiguous=!0,P}},I.remuxEmptyAudio=function(g,I,C,A){var i=g.inputTimeScale,e=i/(g.samplerate?g.samplerate:i),l=this.nextAudioPts,t=this._initDTS,s=9e4*t.baseTime/t.timescale,c=(null!==l?l:A.startDTS*i)+s,d=A.endDTS*i+s,o=1024*e,n=Math.ceil((d-c)/o),a=uA.getSilentFrame(g.manifestCodec||g.codec,g.channelCount);if(H.warn("[mp4-remuxer]: remux empty Audio"),a){for(var Z=[],b=0;b4294967296;)g+=C;return g}function RA(g,I,C,A){var i=g.samples.length;if(i){for(var e=g.inputTimeScale,l=0;l0;i||(A=Yg(I,["encv"])),A.forEach((function(g){Yg(i?g.subarray(28):g.subarray(78),["sinf"]).forEach((function(g){var I=Hg(g);if(I){var A=I.subarray(8,24);A.some((function(g){return 0!==g}))||(H.log("[eme] Patching keyId in 'enc"+(i?"a":"v")+">sinf>>tenc' box: "+Gg(A)+" -> "+Gg(C)),I.set(C,8))}}))}))})),g}(g,A)),this.emitInitSegment=!0},I.generateInitSegment=function(g){var I=this.audioCodec,C=this.videoCodec;if(null==g||!g.byteLength)return this.initTracks=void 0,void(this.initData=void 0);var A=this.initData=Ng(g);I||(I=JA(A.audio,k)),C||(C=JA(A.video,D));var i={};A.audio&&A.video?i.audiovideo={container:"video/mp4",codec:I+","+C,initSegment:g,id:"main"}:A.audio?i.audio={container:"audio/mp4",codec:I,initSegment:g,id:"audio"}:A.video?i.video={container:"video/mp4",codec:C,initSegment:g,id:"main"}:H.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=i},I.remux=function(g,I,C,A,i,e){var l,t,s=this.initPTS,c=this.lastEndTime,d={audio:void 0,video:void 0,text:A,id3:C,initSegment:void 0};W(c)||(c=this.lastEndTime=i||0);var o=I.samples;if(null==o||!o.length)return d;var n={initPTS:void 0,timescale:1},a=this.initData;if(null!=(l=a)&&l.length||(this.generateInitSegment(o),a=this.initData),null==(t=a)||!t.length)return H.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),d;this.emitInitSegment&&(n.tracks=this.initTracks,this.emitInitSegment=!1);var Z,b=function(g,I){for(var C=0,A=0,i=0,e=Yg(g,["moof","traf"]),l=0;li}(s,m,i,b)||n.timescale!==s.timescale&&e)&&(n.initPTS=m-i,s&&1===s.timescale&&H.warn("Adjusting initPTS by "+(n.initPTS-s.baseTime)),this.initPTS=s={baseTime:n.initPTS,timescale:1});var h=g?m-s.baseTime/s.timescale:c,G=h+b;!function(g,I,C){Yg(I,["moof","traf"]).forEach((function(I){Yg(I,["tfhd"]).forEach((function(A){var i=Vg(A,4),e=g[i];if(e){var l=e.timescale||9e4;Yg(I,["tfdt"]).forEach((function(g){var I=g[0],A=Vg(g,4);if(0===I)A-=C*l,Xg(g,4,A=Math.max(A,0));else{A*=Math.pow(2,32),A+=Vg(g,8),A-=C*l,A=Math.max(A,0);var i=Math.floor(A/(ug+1)),e=Math.floor(A%(ug+1));Xg(g,4,i),Xg(g,8,e)}}))}}))}))}(a,o,s.baseTime/s.timescale),b>0?this.lastEndTime=G:(H.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var u=!!a.audio,B=!!a.video,w="";u&&(w+="audio"),B&&(w+="video");var p={data1:o,startPTS:h,startDTS:h,endPTS:G,endDTS:G,type:w,hasAudio:u,hasVideo:B,nb:1,dropped:0};return d.audio="audio"===p.type?p:void 0,d.video="audio"!==p.type?p:void 0,d.initSegment=n,d.id3=RA(C,i,s,s),A.samples.length&&(d.text=NA(A,i,s)),d},g}();function JA(g,I){var C=null==g?void 0:g.codec;return C&&C.length>4?C:"hvc1"===C||"hev1"===C?"hvc1.1.6.L120.90":"av01"===C?"av01.0.04M.08":"avc1"===C||I===D?"avc1.42e01e":"mp4a.40.5"}try{HA=self.performance.now.bind(self.performance)}catch(Xe){H.debug("Unable to use Performance API on this environment"),HA="undefined"!=typeof self&&self.Date.now}var SA=[{demux:qC,remux:MA},{demux:nA,remux:XA},{demux:PC,remux:XA},{demux:GA,remux:XA}],fA=function(){function g(g,I,C,A,i){this.async=!1,this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.vendor=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.observer=g,this.typeSupported=I,this.config=C,this.vendor=A,this.id=i}var I=g.prototype;return I.configure=function(g){this.transmuxConfig=g,this.decrypter&&this.decrypter.reset()},I.push=function(g,I,C,A){var i=this,e=C.transmuxing;e.executeStart=HA();var l=new Uint8Array(g),t=this.currentTransmuxState,s=this.transmuxConfig;A&&(this.currentTransmuxState=A);var c,d,o=A||t,n=o.contiguous,a=o.discontinuity,Z=o.trackSwitch,b=o.accurateTimeOffset,r=o.timeOffset,m=o.initSegmentChange,h=s.audioCodec,G=s.videoCodec,u=s.defaultInitPts,B=s.duration,w=s.initSegmentData,W=(c=I,d=null,l.byteLength>0&&null!=c&&null!=c.key&&null!==c.iv&&null!=c.method&&(d=c),d);if(W&&"AES-128"===W.method){var X=this.getDecrypter();if(!X.isSync())return this.decryptionPromise=X.webCryptoDecrypt(l,W.key.buffer,W.iv.buffer).then((function(g){var I=i.push(g,null,C);return i.decryptionPromise=null,I})),this.decryptionPromise;var Y=X.softwareDecrypt(l,W.key.buffer,W.iv.buffer);if(C.part>-1&&(Y=X.flush()),!Y)return e.executeEnd=HA(),kA(C);l=new Uint8Array(Y)}var R=this.needsProbing(a,Z);if(R){var N=this.configureTransmuxer(l);if(N)return H.warn("[transmuxer] "+N.message),this.observer.emit(p.ERROR,p.ERROR,{type:V.MEDIA_ERROR,details:y.FRAG_PARSING_ERROR,fatal:!1,error:N,reason:N.message}),e.executeEnd=HA(),kA(C)}(a||Z||m||R)&&this.resetInitSegment(w,h,G,B,I),(a||m||R)&&this.resetInitialTimestamp(u),n||this.resetContiguity();var K=this.transmux(l,W,r,b,C),F=this.currentTransmuxState;return F.contiguous=!0,F.discontinuity=!1,F.trackSwitch=!1,e.executeEnd=HA(),K},I.flush=function(g){var I=this,C=g.transmuxing;C.executeStart=HA();var A=this.decrypter,i=this.currentTransmuxState,e=this.decryptionPromise;if(e)return e.then((function(){return I.flush(g)}));var l=[],t=i.timeOffset;if(A){var s=A.flush();s&&l.push(this.push(s,null,g))}var c=this.demuxer,d=this.remuxer;if(!c||!d)return C.executeEnd=HA(),[kA(g)];var o=c.flush(t);return DA(o)?o.then((function(C){return I.flushRemux(l,C,g),l})):(this.flushRemux(l,o,g),l)},I.flushRemux=function(g,I,C){var A=I.audioTrack,i=I.videoTrack,e=I.id3Track,l=I.textTrack,t=this.currentTransmuxState,s=t.accurateTimeOffset,c=t.timeOffset;H.log("[transmuxer.ts]: Flushed fragment "+C.sn+(C.part>-1?" p: "+C.part:"")+" of level "+C.level);var d=this.remuxer.remux(A,i,e,l,c,s,!0,this.id);g.push({remuxResult:d,chunkMeta:C}),C.transmuxing.executeEnd=HA()},I.resetInitialTimestamp=function(g){var I=this.demuxer,C=this.remuxer;I&&C&&(I.resetTimeStamp(g),C.resetTimeStamp(g))},I.resetContiguity=function(){var g=this.demuxer,I=this.remuxer;g&&I&&(g.resetContiguity(),I.resetNextTimestamp())},I.resetInitSegment=function(g,I,C,A,i){var e=this.demuxer,l=this.remuxer;e&&l&&(e.resetInitSegment(g,I,C,A),l.resetInitSegment(g,I,C,i))},I.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},I.transmux=function(g,I,C,A,i){return I&&"SAMPLE-AES"===I.method?this.transmuxSampleAes(g,I,C,A,i):this.transmuxUnencrypted(g,C,A,i)},I.transmuxUnencrypted=function(g,I,C,A){var i=this.demuxer.demux(g,I,!1,!this.config.progressive),e=i.audioTrack,l=i.videoTrack,t=i.id3Track,s=i.textTrack;return{remuxResult:this.remuxer.remux(e,l,t,s,I,C,!1,this.id),chunkMeta:A}},I.transmuxSampleAes=function(g,I,C,A,i){var e=this;return this.demuxer.demuxSampleAes(g,I,C).then((function(g){return{remuxResult:e.remuxer.remux(g.audioTrack,g.videoTrack,g.id3Track,g.textTrack,C,A,!1,e.id),chunkMeta:i}}))},I.configureTransmuxer=function(g){for(var I,C=this.config,A=this.observer,i=this.typeSupported,e=this.vendor,l=0,t=SA.length;l1&&s.id===(null==r?void 0:r.stats.chunkCount),w=!h&&(1===G||0===G&&(1===u||B&&u<=0)),W=self.performance.now();(h||G||0===i.stats.parsing.start)&&(i.stats.parsing.start=W),!e||!u&&w||(e.stats.parsing.start=W);var p=!(r&&(null==(d=i.initSegment)?void 0:d.url)===(null==(o=r.initSegment)?void 0:o.url)),V=new zA(m,w,t,h,Z,p);if(!w||m||p){H.log("[transmuxer-interface, "+i.type+"]: Starting new transmux session for sn: "+s.sn+" p: "+s.part+" level: "+s.level+" id: "+s.id+"\n discontinuity: "+m+"\n trackSwitch: "+h+"\n contiguous: "+w+"\n accurateTimeOffset: "+t+"\n timeOffset: "+Z+"\n initSegmentChange: "+p);var y=new LA(C,A,I,l,c);this.configureTransmuxer(y)}if(this.frag=i,this.part=e,this.workerContext)this.workerContext.worker.postMessage({cmd:"demux",data:g,decryptdata:b,chunkMeta:s,state:V},g instanceof ArrayBuffer?[g]:[]);else if(a){var X=a.push(g,b,s,V);DA(X)?(a.async=!0,X.then((function(g){n.handleTransmuxComplete(g)})).catch((function(g){n.transmuxerError(g,s,"transmuxer-interface push error")}))):(a.async=!1,this.handleTransmuxComplete(X))}},C.flush=function(g){var I=this;g.transmuxing.start=self.performance.now();var C=this.transmuxer;if(this.workerContext)this.workerContext.worker.postMessage({cmd:"flush",chunkMeta:g});else if(C){var A=C.flush(g);DA(A)||C.async?(DA(A)||(A=Promise.resolve(A)),A.then((function(C){I.handleFlushResult(C,g)})).catch((function(C){I.transmuxerError(C,g,"transmuxer-interface flush error")}))):this.handleFlushResult(A,g)}},C.transmuxerError=function(g,I,C){this.hls&&(this.error=g,this.hls.trigger(p.ERROR,{type:V.MEDIA_ERROR,details:y.FRAG_PARSING_ERROR,chunkMeta:I,fatal:!1,error:g,err:g,reason:C}))},C.handleFlushResult=function(g,I){var C=this;g.forEach((function(g){C.handleTransmuxComplete(g)})),this.onFlush(I)},C.onWorkerMessage=function(g){var I=g.data,C=this.hls;switch(I.event){case"init":var A,i=null==(A=this.workerContext)?void 0:A.objectURL;i&&self.URL.revokeObjectURL(i);break;case"transmuxComplete":this.handleTransmuxComplete(I.data);break;case"flush":this.onFlush(I.data);break;case"workerLog":H[I.data.logType]&&H[I.data.logType](I.data.message);break;default:I.data=I.data||{},I.data.frag=this.frag,I.data.id=this.id,C.trigger(I.event,I.data)}},C.configureTransmuxer=function(g){var I=this.transmuxer;this.workerContext?this.workerContext.worker.postMessage({cmd:"configure",config:g}):I&&I.configure(g)},C.handleTransmuxComplete=function(g){g.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(g)},g}(),EA=function(){function g(g,I,C,A){this.config=void 0,this.media=null,this.fragmentTracker=void 0,this.hls=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.config=g,this.media=I,this.fragmentTracker=C,this.hls=A}var I=g.prototype;return I.destroy=function(){this.media=null,this.hls=this.fragmentTracker=null},I.poll=function(g,I){var C=this.config,A=this.media,i=this.stalled;if(null!==A){var e=A.currentTime,l=A.seeking,t=this.seeking&&!l,s=!this.seeking&&l;if(this.seeking=l,e===g){if(s||t)this.stalled=null;else if(!(A.paused&&!l||A.ended||0===A.playbackRate)&&bC.getBuffered(A).length){var c=bC.bufferInfo(A,e,0),d=c.len>0,o=c.nextStart||0;if(d||o){if(l){var n=c.len>2,a=!o||I&&I.start<=e||o-e>2&&!this.fragmentTracker.getPartialFragment(e);if(n||a)return;this.moved=!1}if(!this.moved&&null!==this.stalled){var Z,b=Math.max(o,c.start||0)-e,r=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,m=(null==r||null==(Z=r.details)?void 0:Z.live)?2*r.details.targetduration:2,h=this.fragmentTracker.getPartialFragment(e);if(b>0&&(b<=m||h))return void this._trySkipBufferHole(h)}var G=self.performance.now();if(null!==i){var u=G-i;if(l||!(u>=250)||(this._reportStall(c),this.media)){var B=bC.bufferInfo(A,e,C.maxBufferHole);this._tryFixBufferStall(B,u)}}else this.stalled=G}}}else if(this.moved=!0,null!==i){if(this.stallReported){var w=self.performance.now()-i;H.warn("playback not stuck anymore @"+e+", after "+Math.round(w)+"ms"),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}}},I._tryFixBufferStall=function(g,I){var C=this.config,A=this.fragmentTracker,i=this.media;if(null!==i){var e=i.currentTime,l=A.getPartialFragment(e);if(l&&(this._trySkipBufferHole(l)||!this.media))return;(g.len>C.maxBufferHole||g.nextStart&&g.nextStart-e1e3*C.highBufferWatchdogPeriod&&(H.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}},I._reportStall=function(g){var I=this.hls,C=this.media;if(!this.stallReported&&C){this.stallReported=!0;var A=new Error("Playback stalling at @"+C.currentTime+" due to low buffer ("+JSON.stringify(g)+")");H.warn(A.message),I.trigger(p.ERROR,{type:V.MEDIA_ERROR,details:y.BUFFER_STALLED_ERROR,fatal:!1,error:A,buffer:g.len})}},I._trySkipBufferHole=function(g){var I=this.config,C=this.hls,A=this.media;if(null===A)return 0;var i=A.currentTime,e=bC.bufferInfo(A,i,0),l=i0&&e.len<1&&A.readyState<3,c=l-i;if(c>0&&(t||s)){if(c>I.maxBufferHole){var d=this.fragmentTracker,o=!1;if(0===i){var n=d.getAppendedFrag(0,aI);n&&l1?(A=0,this.bitrateTest=!0):A=C.nextAutoLevel),this.level=C.nextLoadLevel=A,this.loadedmetadata=!1}I>0&&-1===g&&(this.log("Override startPosition with lastCurrentTime @"+I.toFixed(3)),g=I),this.state=yC,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=g,this.tick()}else this._forceStartLoad=!0,this.state=VC},C.stopLoad=function(){this._forceStartLoad=!1,g.prototype.stopLoad.call(this)},C.doTick=function(){switch(this.state){case SC:var g,I=this.levels,C=this.level,A=null==I||null==(g=I[C])?void 0:g.details;if(A&&(!A.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(A))break;this.state=yC;break}if(this.hls.nextLoadLevel!==this.level){this.state=yC;break}break;case RC:var i,e=self.performance.now(),l=this.retryDate;(!l||e>=l||null!=(i=this.media)&&i.seeking)&&(this.resetStartWhenNotLoaded(this.level),this.state=yC)}this.state===yC&&this.doTickIdle(),this.onTickEnd()},C.onTickEnd=function(){g.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},C.doTickIdle=function(){var g=this.hls,I=this.levelLastLoaded,C=this.levels,A=this.media,i=g.config,e=g.nextLoadLevel;if(null!==I&&(A||!this.startFragRequested&&i.startFragPrefetch)&&(!this.altAudio||!this.audioOnly)&&null!=C&&C[e]){var l=C[e],t=this.getMainFwdBufferInfo();if(null!==t){var s=this.getLevelDetails();if(s&&this._streamEnded(t,s)){var c={};return this.altAudio&&(c.type="video"),this.hls.trigger(p.BUFFER_EOS,c),void(this.state=FC)}g.loadLevel!==e&&-1===g.manualLevel&&this.log("Adapting to level "+e+" from level "+this.level),this.level=g.nextLoadLevel=e;var d=l.details;if(!d||this.state===SC||d.live&&this.levelLastLoaded!==e)return this.level=e,void(this.state=SC);var o=t.len,n=this.getMaxBufferLength(l.maxBitrate);if(!(o>=n)){this.backtrackFragment&&this.backtrackFragment.start>t.end&&(this.backtrackFragment=null);var a=this.backtrackFragment?this.backtrackFragment.start:t.end,Z=this.getNextFragment(a,d);if(this.couldBacktrack&&!this.fragPrevious&&Z&&"initSegment"!==Z.sn&&this.fragmentTracker.getState(Z)!==AC){var b,r=(null!=(b=this.backtrackFragment)?b:Z).sn-d.startSN,m=d.fragments[r-1];m&&Z.cc===m.cc&&(Z=m,this.fragmentTracker.removeFragment(m))}else this.backtrackFragment&&t.len&&(this.backtrackFragment=null);if(Z&&this.isLoopLoading(Z,a)){if(!Z.gap){var h=this.audioOnly&&!this.altAudio?k:D,G=(h===D?this.videoBuffer:this.mediaBuffer)||this.media;G&&this.afterBufferFlushed(G,h,aI)}Z=this.getNextFragmentLoopLoading(Z,d,t,aI,n)}Z&&(!Z.initSegment||Z.initSegment.data||this.bitrateTest||(Z=Z.initSegment),this.loadFragment(Z,l,a))}}}},C.loadFragment=function(I,C,A){var i=this.fragmentTracker.getState(I);this.fragCurrent=I,i===gC||i===CC?"initSegment"===I.sn?this._loadInitSegment(I,C):this.bitrateTest?(this.log("Fragment "+I.sn+" of level "+I.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(I,C)):(this.startFragRequested=!0,g.prototype.loadFragment.call(this,I,C,A)):this.clearTrackerIfNeeded(I)},C.getBufferedFrag=function(g){return this.fragmentTracker.getBufferedFrag(g,aI)},C.followingBufferedFrag=function(g){return g?this.getBufferedFrag(g.end+.5):null},C.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},C.nextLevelSwitch=function(){var g=this.levels,I=this.media;if(null!=I&&I.readyState){var C,A=this.getAppendedFrag(I.currentTime);A&&A.start>1&&this.flushMainBuffer(0,A.start-1);var i=this.getLevelDetails();if(null!=i&&i.live){var e=this.getMainFwdBufferInfo();if(!e||e.len<2*i.targetduration)return}if(!I.paused&&g){var l=g[this.hls.nextLoadLevel],t=this.fragLastKbps;C=t&&this.fragCurrent?this.fragCurrent.duration*l.maxBitrate/(1e3*t)+1:0}else C=0;var s=this.getBufferedFrag(I.currentTime+C);if(s){var c=this.followingBufferedFrag(s);if(c){this.abortCurrentFrag();var d=c.maxStartPTS?c.maxStartPTS:c.start,o=c.duration,n=Math.max(s.end,d+Math.min(Math.max(o-this.config.maxFragLookUpTolerance,.5*o),.75*o));this.flushMainBuffer(n,Number.POSITIVE_INFINITY)}}}},C.abortCurrentFrag=function(){var g=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,g&&(g.abortRequests(),this.fragmentTracker.removeFragment(g)),this.state){case XC:case YC:case RC:case HC:case KC:this.state=yC}this.nextLoadPosition=this.getLoadPosition()},C.flushMainBuffer=function(I,C){g.prototype.flushMainBuffer.call(this,I,C,this.altAudio?"video":null)},C.onMediaAttached=function(I,C){g.prototype.onMediaAttached.call(this,I,C);var A=C.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),A.addEventListener("playing",this.onvplaying),A.addEventListener("seeked",this.onvseeked),this.gapController=new EA(this.config,A,this.fragmentTracker,this.hls)},C.onMediaDetaching=function(){var I=this.media;I&&this.onvplaying&&this.onvseeked&&(I.removeEventListener("playing",this.onvplaying),I.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),g.prototype.onMediaDetaching.call(this)},C.onMediaPlaying=function(){this.tick()},C.onMediaSeeked=function(){var g=this.media,I=g?g.currentTime:null;W(I)&&this.log("Media seeked to "+I.toFixed(3));var C=this.getMainFwdBufferInfo();null!==C&&0!==C.len?this.tick():this.warn('Main forward buffer length on "seeked" event '+(C?C.len:"empty")+")")},C.onManifestLoading=function(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(p.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=!1,this.startPosition=this.lastCurrentTime=0,this.levels=this.fragPlaying=this.backtrackFragment=null,this.altAudio=this.audioOnly=!1},C.onManifestParsed=function(g,I){var C,A,i,e=!1,l=!1;I.levels.forEach((function(g){(C=g.audioCodec)&&(-1!==C.indexOf("mp4a.40.2")&&(e=!0),-1!==C.indexOf("mp4a.40.5")&&(l=!0))})),this.audioCodecSwitch=e&&l&&!("function"==typeof(null==(i=kC())||null==(A=i.prototype)?void 0:A.changeType)),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=I.levels,this.startFragRequested=!1},C.onLevelLoading=function(g,I){var C=this.levels;if(C&&this.state===yC){var A=C[I.level];(!A.details||A.details.live&&this.levelLastLoaded!==I.level||this.waitForCdnTuneIn(A.details))&&(this.state=SC)}},C.onLevelLoaded=function(g,I){var C,A=this.levels,i=I.level,e=I.details,l=e.totalduration;if(A){this.log("Level "+i+" loaded ["+e.startSN+","+e.endSN+"]"+(e.lastPartSn?"[part-"+e.lastPartSn+"-"+e.lastPartIndex+"]":"")+", cc ["+e.startCC+", "+e.endCC+"] duration:"+l);var t=A[i],s=this.fragCurrent;!s||this.state!==YC&&this.state!==RC||s.level===I.level&&s.urlId===t.urlId||!s.loader||this.abortCurrentFrag();var c=0;if(e.live||null!=(C=t.details)&&C.live){if(this.checkLiveUpdate(e),e.deltaUpdateFailed)return;c=this.alignPlaylists(e,t.details)}if(t.details=e,this.levelLastLoaded=i,this.hls.trigger(p.LEVEL_UPDATED,{details:e,level:i}),this.state===SC){if(this.waitForCdnTuneIn(e))return;this.state=yC}this.startFragRequested?e.live&&this.synchronizeToLiveEdge(e):this.setStartPosition(e,c),this.tick()}else this.warn("Levels were reset while loading level "+i)},C._handleFragmentLoadProgress=function(g){var I,C=g.frag,A=g.part,i=g.payload,e=this.levels;if(e){var l=e[C.level],t=l.details;if(!t)return this.warn("Dropping fragment "+C.sn+" of level "+C.level+" after level details were reset"),void this.fragmentTracker.removeFragment(C);var s=l.videoCodec,c=t.PTSKnown||!t.live,d=null==(I=C.initSegment)?void 0:I.data,o=this._getAudioCodec(l),n=this.transmuxer=this.transmuxer||new OA(this.hls,aI,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),a=A?A.index:-1,Z=-1!==a,b=new rC(C.level,C.sn,C.stats.chunkCount,i.byteLength,a,Z),r=this.initPTS[C.cc];n.push(i,d,o,s,C,A,t.totalduration,c,b,r)}else this.warn("Levels were reset while fragment load was in progress. Fragment "+C.sn+" of level "+C.level+" will not be buffered")},C.onAudioTrackSwitching=function(g,I){var C=this.altAudio;if(!I.url){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var A=this.fragCurrent;A&&(this.log("Switching to main audio track, cancel main fragment load"),A.abortRequests(),this.fragmentTracker.removeFragment(A)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var i=this.hls;C&&(i.trigger(p.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null}),this.fragmentTracker.removeAllFragments()),i.trigger(p.AUDIO_TRACK_SWITCHED,I)}},C.onAudioTrackSwitched=function(g,I){var C=I.id,A=!!this.hls.audioTracks[C].url;if(A){var i=this.videoBuffer;i&&this.mediaBuffer!==i&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=i)}this.altAudio=A,this.tick()},C.onBufferCreated=function(g,I){var C,A,i=I.tracks,e=!1;for(var l in i){var t=i[l];if("main"===t.id){if(A=l,C=t,"video"===l){var s=i[l];s&&(this.videoBuffer=s.buffer)}}else e=!0}e&&C?(this.log("Alternate track found, use "+A+".buffered to schedule main fragment loading"),this.mediaBuffer=C.buffer):this.mediaBuffer=this.media},C.onFragBuffered=function(g,I){var C=I.frag,A=I.part;if(!C||C.type===aI){if(this.fragContextChanged(C))return this.warn("Fragment "+C.sn+(A?" p: "+A.index:"")+" of level "+C.level+" finished buffering, but was aborted. state: "+this.state),void(this.state===KC&&(this.state=yC));var i=A?A.stats:C.stats;this.fragLastKbps=Math.round(8*i.total/(i.buffering.end-i.loading.first)),"initSegment"!==C.sn&&(this.fragPrevious=C),this.fragBufferedComplete(C,A)}},C.onError=function(g,I){var C;if(I.fatal)this.state=MC;else switch(I.details){case y.FRAG_GAP:case y.FRAG_PARSING_ERROR:case y.FRAG_DECRYPT_ERROR:case y.FRAG_LOAD_ERROR:case y.FRAG_LOAD_TIMEOUT:case y.KEY_LOAD_ERROR:case y.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(aI,I);break;case y.LEVEL_LOAD_ERROR:case y.LEVEL_LOAD_TIMEOUT:case y.LEVEL_PARSING_ERROR:I.levelRetry||this.state!==SC||(null==(C=I.context)?void 0:C.type)!==dI||(this.state=yC);break;case y.BUFFER_FULL_ERROR:if(!I.parent||"main"!==I.parent)return;this.reduceLengthAndFlushBuffer(I)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case y.INTERNAL_EXCEPTION:this.recoverWorkerError(I)}},C.checkBuffer=function(){var g=this.media,I=this.gapController;if(g&&I&&g.readyState){if(this.loadedmetadata||!bC.getBuffered(g).length){var C=this.state!==yC?this.fragCurrent:null;I.poll(this.lastCurrentTime,C)}this.lastCurrentTime=g.currentTime}},C.onFragLoadEmergencyAborted=function(){this.state=yC,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},C.onBufferFlushed=function(g,I){var C=I.type;if(C!==k||this.audioOnly&&!this.altAudio){var A=(C===D?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(A,C,aI)}},C.onLevelsUpdated=function(g,I){this.levels=I.levels},C.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},C.seekToStartPos=function(){var g=this.media;if(g){var I=g.currentTime,C=this.startPosition;if(C>=0&&I0&&(iG.cc;if(!1!==i.independent){var w=d.startPTS,V=d.endPTS,y=d.startDTS,X=d.endDTS;if(s)s.elementaryStreams[d.type]={startPTS:w,endPTS:V,startDTS:y,endDTS:X};else if(d.firstKeyFrame&&d.independent&&1===e.id&&!B&&(this.couldBacktrack=!0),d.dropped&&d.independent){var Y=this.getMainFwdBufferInfo(),R=(Y?Y.end:this.getLoadPosition())+this.config.maxBufferHole,N=d.firstKeyFramePTS?d.firstKeyFramePTS:w;if(!u&&R1&&!1===g.seeking){var C=g.currentTime;if(bC.isBuffered(g,C)?I=this.getAppendedFrag(C):bC.isBuffered(g,C+.1)&&(I=this.getAppendedFrag(C+.1)),I){this.backtrackFragment=null;var A=this.fragPlaying,i=I.level;A&&I.sn===A.sn&&A.level===i&&I.urlId===A.urlId||(this.fragPlaying=I,this.hls.trigger(p.FRAG_CHANGED,{frag:I}),A&&A.level===i||this.hls.trigger(p.LEVEL_SWITCHED,{level:i}))}}},e(I,[{key:"nextLevel",get:function(){var g=this.nextBufferedFrag;return g?g.level:-1}},{key:"currentFrag",get:function(){var g=this.media;return g?this.fragPlaying||this.getAppendedFrag(g.currentTime):null}},{key:"currentProgramDateTime",get:function(){var g=this.media;if(g){var I=g.currentTime,C=this.currentFrag;if(C&&W(I)&&W(C.programDateTime)){var A=C.programDateTime+1e3*(I-C.start);return new Date(A)}}return null}},{key:"currentLevel",get:function(){var g=this.currentFrag;return g?g.level:-1}},{key:"nextBufferedFrag",get:function(){var g=this.currentFrag;return g?this.followingBufferedFrag(g):null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}]),I}(fC),_A=function(){function g(g,I,C){void 0===I&&(I=0),void 0===C&&(C=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=g,this.alpha_=g?Math.exp(Math.log(.5)/g):0,this.estimate_=I,this.totalWeight_=C}var I=g.prototype;return I.sample=function(g,I){var C=Math.pow(this.alpha_,g);this.estimate_=I*(1-C)+C*this.estimate_,this.totalWeight_+=g},I.getTotalWeight=function(){return this.totalWeight_},I.getEstimate=function(){if(this.alpha_){var g=1-Math.pow(this.alpha_,this.totalWeight_);if(g)return this.estimate_/g}return this.estimate_},g}(),qA=function(){function g(g,I,C,A){void 0===A&&(A=100),this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultTTFB_=void 0,this.ttfb_=void 0,this.defaultEstimate_=C,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new _A(g),this.fast_=new _A(I),this.defaultTTFB_=A,this.ttfb_=new _A(g)}var I=g.prototype;return I.update=function(g,I){var C=this.slow_,A=this.fast_,i=this.ttfb_;C.halfLife!==g&&(this.slow_=new _A(g,C.getEstimate(),C.getTotalWeight())),A.halfLife!==I&&(this.fast_=new _A(I,A.getEstimate(),A.getTotalWeight())),i.halfLife!==g&&(this.ttfb_=new _A(g,i.getEstimate(),i.getTotalWeight()))},I.sample=function(g,I){var C=(g=Math.max(g,this.minDelayMs_))/1e3,A=8*I/C;this.fast_.sample(C,A),this.slow_.sample(C,A)},I.sampleTTFB=function(g){var I=g/1e3,C=Math.sqrt(2)*Math.exp(-Math.pow(I,2)/2);this.ttfb_.sample(C,Math.max(g,5))},I.canEstimate=function(){return this.fast_.getTotalWeight()>=this.minWeight_},I.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},I.getEstimateTTFB=function(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_},I.destroy=function(){},g}(),$A=function(){function g(g){this.hls=void 0,this.lastLevelLoadSec=0,this.lastLoadedFragLevel=0,this._nextAutoLevel=-1,this.timer=-1,this.onCheck=this._abandonRulesCheck.bind(this),this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.bwEstimator=void 0,this.hls=g;var I=g.config;this.bwEstimator=new qA(I.abrEwmaSlowVoD,I.abrEwmaFastVoD,I.abrEwmaDefaultEstimate),this.registerListeners()}var I=g.prototype;return I.registerListeners=function(){var g=this.hls;g.on(p.FRAG_LOADING,this.onFragLoading,this),g.on(p.FRAG_LOADED,this.onFragLoaded,this),g.on(p.FRAG_BUFFERED,this.onFragBuffered,this),g.on(p.LEVEL_SWITCHING,this.onLevelSwitching,this),g.on(p.LEVEL_LOADED,this.onLevelLoaded,this)},I.unregisterListeners=function(){var g=this.hls;g.off(p.FRAG_LOADING,this.onFragLoading,this),g.off(p.FRAG_LOADED,this.onFragLoaded,this),g.off(p.FRAG_BUFFERED,this.onFragBuffered,this),g.off(p.LEVEL_SWITCHING,this.onLevelSwitching,this),g.off(p.LEVEL_LOADED,this.onLevelLoaded,this)},I.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null},I.onFragLoading=function(g,I){var C,A=I.frag;this.ignoreFragment(A)||(this.fragCurrent=A,this.partCurrent=null!=(C=I.part)?C:null,this.clearTimer(),this.timer=self.setInterval(this.onCheck,100))},I.onLevelSwitching=function(g,I){this.clearTimer()},I.getTimeToLoadFrag=function(g,I,C,A){return g+C/I+(A?this.lastLevelLoadSec:0)},I.onLevelLoaded=function(g,I){var C=this.hls.config,A=I.stats,i=A.total,e=A.bwEstimate;W(i)&&W(e)&&(this.lastLevelLoadSec=8*i/e),I.details.live?this.bwEstimator.update(C.abrEwmaSlowLive,C.abrEwmaFastLive):this.bwEstimator.update(C.abrEwmaSlowVoD,C.abrEwmaFastVoD)},I._abandonRulesCheck=function(){var g=this.fragCurrent,I=this.partCurrent,C=this.hls,A=C.autoLevelEnabled,i=C.media;if(g&&i){var e=performance.now(),l=I?I.stats:g.stats,t=I?I.duration:g.duration,s=e-l.loading.start;if(l.aborted||l.loaded&&l.loaded===l.total||0===g.level)return this.clearTimer(),void(this._nextAutoLevel=-1);if(A&&!i.paused&&i.playbackRate&&i.readyState){var c=C.mainForwardBufferInfo;if(null!==c){var d=this.bwEstimator.getEstimateTTFB(),o=Math.abs(i.playbackRate);if(!(s<=Math.max(d,t/(2*o)*1e3))){var n=c.len/o;if(!(n>=2*t/o)){var a=l.loading.first?l.loading.first-l.loading.start:-1,Z=l.loaded&&a>-1,b=this.bwEstimator.getEstimate(),r=C.levels,m=C.minAutoLevel,h=r[g.level],G=l.total||Math.max(l.loaded,Math.round(t*h.maxBitrate/8)),u=s-a;u<1&&Z&&(u=Math.min(s,8*l.loaded/b));var B=Z?1e3*l.loaded/u:0,w=B?(G-l.loaded)/B:8*G/b+d/1e3;if(!(w<=n)){var V,y=B?8*B:b,X=Number.POSITIVE_INFINITY;for(V=g.level-1;V>m;V--){var Y=r[V].maxBitrate;if((X=this.getTimeToLoadFrag(d/1e3,y,t*Y,!r[V].details))=w||X>10*t||(C.nextLoadLevel=V,Z?this.bwEstimator.sample(s-Math.min(d,a),l.loaded):this.bwEstimator.sampleTTFB(s),this.clearTimer(),H.warn("[abr] Fragment "+g.sn+(I?" part "+I.index:"")+" of level "+g.level+" is loading too slowly;\n Time to underbuffer: "+n.toFixed(3)+" s\n Estimated load time for current fragment: "+w.toFixed(3)+" s\n Estimated load time for down switch fragment: "+X.toFixed(3)+" s\n TTFB estimate: "+a+"\n Current BW estimate: "+(W(b)?(b/1024).toFixed(3):"Unknown")+" Kb/s\n New BW estimate: "+(this.bwEstimator.getEstimate()/1024).toFixed(3)+" Kb/s\n Aborting and switching to level "+V),g.loader&&(this.fragCurrent=this.partCurrent=null,g.abortRequests()),C.trigger(p.FRAG_LOAD_EMERGENCY_ABORTED,{frag:g,part:I,stats:l}))}}}}}}},I.onFragLoaded=function(g,I){var C=I.frag,A=I.part,i=A?A.stats:C.stats;if(C.type===aI&&this.bwEstimator.sampleTTFB(i.loading.first-i.loading.start),!this.ignoreFragment(C)){if(this.clearTimer(),this.lastLoadedFragLevel=C.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var e=A?A.duration:C.duration,l=this.hls.levels[C.level],t=(l.loaded?l.loaded.bytes:0)+i.loaded,s=(l.loaded?l.loaded.duration:0)+e;l.loaded={bytes:t,duration:s},l.realBitrate=Math.round(8*t/s)}if(C.bitrateTest){var c={stats:i,frag:C,part:A,id:C.type};this.onFragBuffered(p.FRAG_BUFFERED,c),C.bitrateTest=!1}}},I.onFragBuffered=function(g,I){var C=I.frag,A=I.part,i=null!=A&&A.stats.loaded?A.stats:C.stats;if(!i.aborted&&!this.ignoreFragment(C)){var e=i.parsing.end-i.loading.start-Math.min(i.loading.first-i.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(e,i.loaded),i.bwEstimate=this.bwEstimator.getEstimate(),C.bitrateTest?this.bitrateTestDelay=e/1e3:this.bitrateTestDelay=0}},I.ignoreFragment=function(g){return g.type!==aI||"initSegment"===g.sn},I.clearTimer=function(){self.clearInterval(this.timer)},I.getNextABRAutoLevel=function(){var g=this.fragCurrent,I=this.partCurrent,C=this.hls,A=C.maxAutoLevel,i=C.config,e=C.minAutoLevel,l=C.media,t=I?I.duration:g?g.duration:0,s=l&&0!==l.playbackRate?Math.abs(l.playbackRate):1,c=this.bwEstimator?this.bwEstimator.getEstimate():i.abrEwmaDefaultEstimate,d=C.mainForwardBufferInfo,o=(d?d.len:0)/s,n=this.findBestLevel(c,e,A,o,i.abrBandWidthFactor,i.abrBandWidthUpFactor);if(n>=0)return n;H.trace("[abr] "+(o?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var a=t?Math.min(t,i.maxStarvationDelay):i.maxStarvationDelay,Z=i.abrBandWidthFactor,b=i.abrBandWidthUpFactor;if(!o){var r=this.bitrateTestDelay;r&&(a=(t?Math.min(t,i.maxLoadingDelay):i.maxLoadingDelay)-r,H.trace("[abr] bitrate test took "+Math.round(1e3*r)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*a)+" ms"),Z=b=1)}return n=this.findBestLevel(c,e,A,o+a,Z,b),Math.max(n,0)},I.findBestLevel=function(g,I,C,A,i,e){for(var l,t=this.fragCurrent,s=this.partCurrent,c=this.lastLoadedFragLevel,d=this.hls.levels,o=d[c],n=!(null==o||null==(l=o.details)||!l.live),a=null==o?void 0:o.codecSet,Z=s?s.duration:t?t.duration:0,b=this.bwEstimator.getEstimateTTFB()/1e3,r=I,m=-1,h=C;h>=I;h--){var G=d[h];if(!G||a&&G.codecSet!==a)G&&(r=Math.min(h,r),m=Math.max(h,m));else{-1!==m&&H.trace("[abr] Skipped level(s) "+r+"-"+m+' with CODECS:"'+d[m].attrs.CODECS+'"; not compatible with "'+o.attrs.CODECS+'"');var u,B=G.details,w=(s?null==B?void 0:B.partTarget:null==B?void 0:B.averagetargetduration)||Z;u=h<=c?i*g:e*g;var p=d[h].maxBitrate,V=this.getTimeToLoadFrag(b,u,p*w,void 0===B);if(H.trace("[abr] level:"+h+" adjustedbw-bitrate:"+Math.round(u-p)+" avgDuration:"+w.toFixed(1)+" maxFetchDuration:"+A.toFixed(1)+" fetchDuration:"+V.toFixed(1)),u>p&&(0===V||!W(V)||n&&!this.bitrateTestDelay||VMath.max(g,C)&&A[g].loadError<=A[C].loadError)return g}return-1!==g&&(C=Math.min(g,C)),C},set:function(g){this._nextAutoLevel=g}}]),g}(),gi=function(){function g(){this.chunks=[],this.dataLength=0}var I=g.prototype;return I.push=function(g){this.chunks.push(g),this.dataLength+=g.length},I.flush=function(){var g,I=this.chunks,C=this.dataLength;return I.length?(g=1===I.length?I[0]:function(g,I){for(var C=new Uint8Array(I),A=0,i=0;i0&&-1===g?(this.log("Override startPosition with lastCurrentTime @"+I.toFixed(3)),g=I,this.state=yC):(this.loadedmetadata=!1,this.state=NC),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=g,this.tick()},C.doTick=function(){switch(this.state){case yC:this.doTickIdle();break;case NC:var I,C=this.levels,A=this.trackId,i=null==C||null==(I=C[A])?void 0:I.details;if(i){if(this.waitForCdnTuneIn(i))break;this.state=JC}break;case RC:var e,l=performance.now(),t=this.retryDate;(!t||l>=t||null!=(e=this.media)&&e.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.trackId),this.state=yC);break;case JC:var s=this.waitingData;if(s){var c=s.frag,d=s.part,o=s.cache,n=s.complete;if(void 0!==this.initPTS[c.cc]){this.waitingData=null,this.waitingVideoCC=-1,this.state=YC;var a={frag:c,part:d,payload:o.flush(),networkDetails:null};this._handleFragmentLoadProgress(a),n&&g.prototype._handleFragmentLoadComplete.call(this,a)}else if(this.videoTrackCC!==this.waitingVideoCC)this.log("Waiting fragment cc ("+c.cc+") cancelled because video is at cc "+this.videoTrackCC),this.clearWaitingFragment();else{var Z=this.getLoadPosition(),b=bC.bufferInfo(this.mediaBuffer,Z,this.config.maxBufferHole);QI(b.end,this.config.maxFragLookUpTolerance,c)<0&&(this.log("Waiting fragment cc ("+c.cc+") @ "+c.start+" cancelled because another fragment at "+b.end+" is needed"),this.clearWaitingFragment())}}else this.state=yC}this.onTickEnd()},C.clearWaitingFragment=function(){var g=this.waitingData;g&&(this.fragmentTracker.removeFragment(g.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=yC)},C.resetLoadingState=function(){this.clearWaitingFragment(),g.prototype.resetLoadingState.call(this)},C.onTickEnd=function(){var g=this.media;null!=g&&g.readyState&&(this.lastCurrentTime=g.currentTime)},C.doTickIdle=function(){var g=this.hls,I=this.levels,C=this.media,A=this.trackId,i=g.config;if(null!=I&&I[A]&&(C||!this.startFragRequested&&i.startFragPrefetch)){var e=I[A],l=e.details;if(!l||l.live&&this.levelLastLoaded!==A||this.waitForCdnTuneIn(l))this.state=NC;else{var t=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&t&&(this.bufferFlushed=!1,this.afterBufferFlushed(t,k,ZI));var s=this.getFwdBufferInfo(t,ZI);if(null!==s){var c=this.bufferedTrack,d=this.switchingTrack;if(!d&&this._streamEnded(s,l))return g.trigger(p.BUFFER_EOS,{type:"audio"}),void(this.state=FC);var o=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,aI),n=s.len,a=this.getMaxBufferLength(null==o?void 0:o.len);if(!(n>=a)||d){var Z=l.fragments[0].start,b=s.end;if(d&&C){var r=this.getLoadPosition();c&&d.attrs!==c.attrs&&(b=r),l.PTSKnown&&rZ||s.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),C.currentTime=Z+.05)}var m=this.getNextFragment(b,l),h=!1;if(m&&this.isLoopLoading(m,b)&&(h=!!m.gap,m=this.getNextFragmentLoopLoading(m,l,s,aI,a)),m){var G=o&&m.start>o.end+l.targetduration;if(G||(null==o||!o.len)&&s.len){var u=this.getAppendedFrag(m.start,aI);if(null===u)return;if(h||(h=!!u.gap||!!G&&0===o.len),G&&!h||h&&s.nextStart&&s.nextStart=I.length)this.warn("Invalid id passed to audio-track controller");else{this.clearTimer();var C=this.currentTrack;I[this.trackId];var i=I[g],e=i.groupId,l=i.name;if(this.log("Switching to audio-track "+g+' "'+l+'" lang:'+i.lang+" group:"+e),this.trackId=g,this.currentTrack=i,this.selectDefaultTrack=!1,this.hls.trigger(p.AUDIO_TRACK_SWITCHING,A({},i)),!i.details||i.details.live){var t=this.switchParams(i.url,null==C?void 0:C.details);this.loadPlaylist(t)}}},C.selectInitialTrack=function(){var g=this.tracksInGroup,I=this.findTrackId(this.currentTrack)|this.findTrackId(null);if(-1!==I)this.setAudioTrack(I);else{var C=new Error("No track found for running audio group-ID: "+this.groupId+" track count: "+g.length);this.warn(C.message),this.hls.trigger(p.ERROR,{type:V.MEDIA_ERROR,details:y.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:C})}},C.findTrackId=function(g){for(var I=this.tracksInGroup,C=0;C=i[t].start&&l<=i[t].end){e=i[t];break}var s=C.start+C.duration;e?e.end=s:(e={start:l,end:s},i.push(e)),this.fragmentTracker.fragBuffered(C)}}},C.onBufferFlushing=function(g,I){var C=I.startOffset,A=I.endOffset;if(0===C&&A!==Number.POSITIVE_INFINITY){var i=A-1;if(i<=0)return;I.endOffsetSubtitles=Math.max(0,i),this.tracksBuffered.forEach((function(g){for(var I=0;I=l.length||i!==e)&&t){this.mediaBuffer=this.mediaBufferTimeRanges;var s=0;if(A.live||null!=(C=t.details)&&C.live){var c=this.mainDetails;if(A.deltaUpdateFailed||!c)return;var d=c.fragments[0];t.details?0===(s=this.alignPlaylists(A,t.details))&&d&&SI(A,s=d.start):A.hasProgramDateTime&&c.hasProgramDateTime?(uC(A,c),s=A.fragments[0].start):d&&SI(A,s=d.start)}t.details=A,this.levelLastLoaded=i,this.startFragRequested||!this.mainDetails&&A.live||this.setStartPosition(t.details,s),this.tick(),A.live&&!this.fragCurrent&&this.media&&this.state===yC&&(UI(null,A.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),t.details=void 0))}}},C._handleFragmentLoadComplete=function(g){var I=this,C=g.frag,A=g.payload,i=C.decryptdata,e=this.hls;if(!this.fragContextChanged(C)&&A&&A.byteLength>0&&i&&i.key&&i.iv&&"AES-128"===i.method){var l=performance.now();this.decrypter.decrypt(new Uint8Array(A),i.key.buffer,i.iv.buffer).catch((function(g){throw e.trigger(p.ERROR,{type:V.MEDIA_ERROR,details:y.FRAG_DECRYPT_ERROR,fatal:!1,error:g,reason:g.message,frag:C}),g})).then((function(g){var I=performance.now();e.trigger(p.FRAG_DECRYPTED,{frag:C,payload:g,stats:{tstart:l,tdecrypt:I}})})).catch((function(g){I.warn(g.name+": "+g.message),I.state=yC}))}},C.doTick=function(){if(this.media){if(this.state===yC){var g=this.currentTrackId,I=this.levels,C=I[g];if(!I.length||!C||!C.details)return;var A=this.config,i=this.getLoadPosition(),e=bC.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],i,A.maxBufferHole),l=e.end,t=e.len,s=this.getFwdBufferInfo(this.media,aI),c=C.details;if(t>this.getMaxBufferLength(null==s?void 0:s.len)+c.levelTargetDuration)return;var d=c.fragments,o=d.length,n=c.edge,a=null,Z=this.fragPrevious;if(ln-b?0:b;!(a=UI(Z,d,Math.max(d[0].start,l),r))&&Z&&Z.start>>=0)>A-1)throw new DOMException("Failed to execute '"+I+"' on 'TimeRanges': The index provided ("+C+") is greater than the maximum bound ("+A+")");return g[C][I]};this.buffered={get length(){return g.length},end:function(C){return I("end",C,g.length)},start:function(C){return I("start",C,g.length)}}},ti=function(g){function I(I){var C;return(C=g.call(this,I,"[subtitle-track-controller]")||this).media=null,C.tracks=[],C.groupId=null,C.tracksInGroup=[],C.trackId=-1,C.selectDefaultTrack=!0,C.queuedDefaultTrack=-1,C.trackChangeListener=function(){return C.onTextTracksChanged()},C.asyncPollTrackChange=function(){return C.pollTrackChange(0)},C.useTextTrackPolling=!1,C.subtitlePollingInterval=-1,C._subtitleDisplay=!0,C.registerListeners(),C}s(I,g);var C=I.prototype;return C.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,g.prototype.destroy.call(this)},C.registerListeners=function(){var g=this.hls;g.on(p.MEDIA_ATTACHED,this.onMediaAttached,this),g.on(p.MEDIA_DETACHING,this.onMediaDetaching,this),g.on(p.MANIFEST_LOADING,this.onManifestLoading,this),g.on(p.MANIFEST_PARSED,this.onManifestParsed,this),g.on(p.LEVEL_LOADING,this.onLevelLoading,this),g.on(p.LEVEL_SWITCHING,this.onLevelSwitching,this),g.on(p.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),g.on(p.ERROR,this.onError,this)},C.unregisterListeners=function(){var g=this.hls;g.off(p.MEDIA_ATTACHED,this.onMediaAttached,this),g.off(p.MEDIA_DETACHING,this.onMediaDetaching,this),g.off(p.MANIFEST_LOADING,this.onManifestLoading,this),g.off(p.MANIFEST_PARSED,this.onManifestParsed,this),g.off(p.LEVEL_LOADING,this.onLevelLoading,this),g.off(p.LEVEL_SWITCHING,this.onLevelSwitching,this),g.off(p.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),g.off(p.ERROR,this.onError,this)},C.onMediaAttached=function(g,I){this.media=I.media,this.media&&(this.queuedDefaultTrack>-1&&(this.subtitleTrack=this.queuedDefaultTrack,this.queuedDefaultTrack=-1),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?this.pollTrackChange(500):this.media.textTracks.addEventListener("change",this.asyncPollTrackChange))},C.pollTrackChange=function(g){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,g)},C.onMediaDetaching=function(){this.media&&(self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId),si(this.media.textTracks).forEach((function(g){BI(g)})),this.subtitleTrack=-1,this.media=null)},C.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0},C.onManifestParsed=function(g,I){this.tracks=I.subtitleTracks},C.onSubtitleTrackLoaded=function(g,I){var C=I.id,A=I.details,i=this.trackId,e=this.tracksInGroup[i];if(e){var l=e.details;e.details=I.details,this.log("subtitle track "+C+" loaded ["+A.startSN+"-"+A.endSN+"]"),C===this.trackId&&this.playlistLoaded(C,I,l)}else this.warn("Invalid subtitle track id "+C)},C.onLevelLoading=function(g,I){this.switchLevel(I.level)},C.onLevelSwitching=function(g,I){this.switchLevel(I.level)},C.switchLevel=function(g){var I=this.hls.levels[g];if(null!=I&&I.textGroupIds){var C=I.textGroupIds[I.urlId],A=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;if(this.groupId!==C){var i=this.tracks.filter((function(g){return!C||g.groupId===C}));this.tracksInGroup=i;var e=this.findTrackId(null==A?void 0:A.name)||this.findTrackId();this.groupId=C||null;var l={subtitleTracks:i};this.log("Updating subtitle tracks, "+i.length+' track(s) found in "'+C+'" group-id'),this.hls.trigger(p.SUBTITLE_TRACKS_UPDATED,l),-1!==e&&this.setSubtitleTrack(e,A)}else this.shouldReloadPlaylist(A)&&this.setSubtitleTrack(this.trackId,A)}},C.findTrackId=function(g){for(var I=this.tracksInGroup,C=0;C=A.length)){this.clearTimer();var i=A[g];if(this.log("Switching to subtitle-track "+g+(i?' "'+i.name+'" lang:'+i.lang+" group:"+i.groupId:"")),this.trackId=g,i){var e=i.id,l=i.groupId,t=void 0===l?"":l,s=i.name,c=i.type,d=i.url;this.hls.trigger(p.SUBTITLE_TRACK_SWITCH,{id:e,groupId:t,name:s,type:c,url:d});var o=this.switchParams(i.url,null==I?void 0:I.details);this.loadPlaylist(o)}else this.hls.trigger(p.SUBTITLE_TRACK_SWITCH,{id:g})}}else this.queuedDefaultTrack=g},C.onTextTracksChanged=function(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),this.media&&this.hls.config.renderTextTracksNatively){for(var g=-1,I=si(this.media.textTracks),C=0;C-1&&this.toggleTrackModes(this.trackId)}},{key:"subtitleTracks",get:function(){return this.tracksInGroup}},{key:"subtitleTrack",get:function(){return this.trackId},set:function(g){this.selectDefaultTrack=!1;var I=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;this.setSubtitleTrack(g,I)}}]),I}(PI);function si(g){for(var I=[],C=0;C "+g.src+")")},this.hls=g,this._initSourceBuffer(),this.registerListeners()}var I=g.prototype;return I.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},I.destroy=function(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=null},I.registerListeners=function(){var g=this.hls;g.on(p.MEDIA_ATTACHING,this.onMediaAttaching,this),g.on(p.MEDIA_DETACHING,this.onMediaDetaching,this),g.on(p.MANIFEST_LOADING,this.onManifestLoading,this),g.on(p.MANIFEST_PARSED,this.onManifestParsed,this),g.on(p.BUFFER_RESET,this.onBufferReset,this),g.on(p.BUFFER_APPENDING,this.onBufferAppending,this),g.on(p.BUFFER_CODECS,this.onBufferCodecs,this),g.on(p.BUFFER_EOS,this.onBufferEos,this),g.on(p.BUFFER_FLUSHING,this.onBufferFlushing,this),g.on(p.LEVEL_UPDATED,this.onLevelUpdated,this),g.on(p.FRAG_PARSED,this.onFragParsed,this),g.on(p.FRAG_CHANGED,this.onFragChanged,this)},I.unregisterListeners=function(){var g=this.hls;g.off(p.MEDIA_ATTACHING,this.onMediaAttaching,this),g.off(p.MEDIA_DETACHING,this.onMediaDetaching,this),g.off(p.MANIFEST_LOADING,this.onManifestLoading,this),g.off(p.MANIFEST_PARSED,this.onManifestParsed,this),g.off(p.BUFFER_RESET,this.onBufferReset,this),g.off(p.BUFFER_APPENDING,this.onBufferAppending,this),g.off(p.BUFFER_CODECS,this.onBufferCodecs,this),g.off(p.BUFFER_EOS,this.onBufferEos,this),g.off(p.BUFFER_FLUSHING,this.onBufferFlushing,this),g.off(p.LEVEL_UPDATED,this.onLevelUpdated,this),g.off(p.FRAG_PARSED,this.onFragParsed,this),g.off(p.FRAG_CHANGED,this.onFragChanged,this)},I._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new ci(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]},this.lastMpegAudioChunk=null},I.onManifestLoading=function(){this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=0,this.details=null},I.onManifestParsed=function(g,I){var C=2;(I.audio&&!I.video||!I.altAudio)&&(C=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=C,H.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},I.onMediaAttaching=function(g,I){var C=this.media=I.media;if(C&&di){var A=this.mediaSource=new di;A.addEventListener("sourceopen",this._onMediaSourceOpen),A.addEventListener("sourceended",this._onMediaSourceEnded),A.addEventListener("sourceclose",this._onMediaSourceClose),C.src=self.URL.createObjectURL(A),this._objectUrl=C.src,C.addEventListener("emptied",this._onMediaEmptied)}},I.onMediaDetaching=function(){var g=this.media,I=this.mediaSource,C=this._objectUrl;if(I){if(H.log("[buffer-controller]: media source detaching"),"open"===I.readyState)try{I.endOfStream()}catch(A){H.warn("[buffer-controller]: onMediaDetaching: "+A.message+" while calling endOfStream")}this.onBufferReset(),I.removeEventListener("sourceopen",this._onMediaSourceOpen),I.removeEventListener("sourceended",this._onMediaSourceEnded),I.removeEventListener("sourceclose",this._onMediaSourceClose),g&&(g.removeEventListener("emptied",this._onMediaEmptied),C&&self.URL.revokeObjectURL(C),g.src===C?(g.removeAttribute("src"),g.load()):H.warn("[buffer-controller]: media.src was changed by a third party - skip cleanup")),this.mediaSource=null,this.media=null,this._objectUrl=null,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal,this.pendingTracks={},this.tracks={}}this.hls.trigger(p.MEDIA_DETACHED,void 0)},I.onBufferReset=function(){var g=this;this.getSourceBufferTypes().forEach((function(I){var C=g.sourceBuffer[I];try{C&&(g.removeBufferListeners(I),g.mediaSource&&g.mediaSource.removeSourceBuffer(C),g.sourceBuffer[I]=void 0)}catch(A){H.warn("[buffer-controller]: Failed to reset the "+I+" buffer",A)}})),this._initSourceBuffer()},I.onBufferCodecs=function(g,I){var C=this,A=this.getSourceBufferTypes().length;Object.keys(I).forEach((function(g){if(A){var i=C.tracks[g];if(i&&"function"==typeof i.buffer.changeType){var e=I[g],l=e.id,t=e.codec,s=e.levelCodec,c=e.container,d=e.metadata,o=(i.levelCodec||i.codec).replace(oi,"$1"),n=(s||t).replace(oi,"$1");if(o!==n){var a=c+";codecs="+(s||t);C.appendChangeType(g,a),H.log("[buffer-controller]: switching codec "+o+" to "+n),C.tracks[g]={buffer:i.buffer,codec:t,container:c,levelCodec:s,metadata:d,id:l}}}}else C.pendingTracks[g]=I[g]})),A||(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&"open"===this.mediaSource.readyState&&this.checkPendingTracks())},I.appendChangeType=function(g,I){var C=this,A=this.operationQueue,i={execute:function(){var i=C.sourceBuffer[g];i&&(H.log("[buffer-controller]: changing "+g+" sourceBuffer type to "+I),i.changeType(I)),A.shiftAndExecuteNext(g)},onStart:function(){},onComplete:function(){},onError:function(I){H.warn("[buffer-controller]: Failed to change "+g+" SourceBuffer type",I)}};A.append(i,g)},I.onBufferAppending=function(g,I){var C=this,A=this.hls,i=this.operationQueue,e=this.tracks,l=I.data,t=I.type,s=I.frag,c=I.part,d=I.chunkMeta,o=d.buffering[t],n=self.performance.now();o.start=n;var a=s.stats.buffering,Z=c?c.stats.buffering:null;0===a.start&&(a.start=n),Z&&0===Z.start&&(Z.start=n);var b=e.audio,r=!1;"audio"===t&&"audio/mpeg"===(null==b?void 0:b.container)&&(r=!this.lastMpegAudioChunk||1===d.id||this.lastMpegAudioChunk.sn!==d.sn,this.lastMpegAudioChunk=d);var m=s.start,h={execute:function(){if(o.executeStart=self.performance.now(),r){var g=C.sourceBuffer[t];if(g){var I=m-g.timestampOffset;Math.abs(I)>=.1&&(H.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+m+" (delta: "+I+") sn: "+s.sn+")"),g.timestampOffset=m)}}C.appendExecutor(l,t)},onStart:function(){},onComplete:function(){var g=self.performance.now();o.executeEnd=o.end=g,0===a.first&&(a.first=g),Z&&0===Z.first&&(Z.first=g);var I=C.sourceBuffer,A={};for(var i in I)A[i]=bC.getBuffered(I[i]);C.appendError=0,C.hls.trigger(p.BUFFER_APPENDED,{type:t,frag:s,part:c,chunkMeta:d,parent:s.type,timeRanges:A})},onError:function(g){H.error("[buffer-controller]: Error encountered while trying to append to the "+t+" SourceBuffer",g);var I={type:V.MEDIA_ERROR,parent:s.type,details:y.BUFFER_APPEND_ERROR,frag:s,part:c,chunkMeta:d,error:g,err:g,fatal:!1};g.code===DOMException.QUOTA_EXCEEDED_ERR?I.details=y.BUFFER_FULL_ERROR:(C.appendError++,I.details=y.BUFFER_APPEND_ERROR,C.appendError>A.config.appendErrorMaxRetry&&(H.error("[buffer-controller]: Failed "+A.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),I.fatal=!0)),A.trigger(p.ERROR,I)}};i.append(h,t)},I.onBufferFlushing=function(g,I){var C=this,A=this.operationQueue,i=function(g){return{execute:C.removeExecutor.bind(C,g,I.startOffset,I.endOffset),onStart:function(){},onComplete:function(){C.hls.trigger(p.BUFFER_FLUSHED,{type:g})},onError:function(I){H.warn("[buffer-controller]: Failed to remove from "+g+" SourceBuffer",I)}}};I.type?A.append(i(I.type),I.type):this.getSourceBufferTypes().forEach((function(g){A.append(i(g),g)}))},I.onFragParsed=function(g,I){var C=this,A=I.frag,i=I.part,e=[],l=i?i.elementaryStreams:A.elementaryStreams;l[L]?e.push("audiovideo"):(l[k]&&e.push("audio"),l[D]&&e.push("video")),0===e.length&&H.warn("Fragments must have at least one ElementaryStreamType set. type: "+A.type+" level: "+A.level+" sn: "+A.sn),this.blockBuffers((function(){var g=self.performance.now();A.stats.buffering.end=g,i&&(i.stats.buffering.end=g);var I=i?i.stats:A.stats;C.hls.trigger(p.FRAG_BUFFERED,{frag:A,part:i,stats:I,id:A.type})}),e)},I.onFragChanged=function(g,I){this.flushBackBuffer()},I.onBufferEos=function(g,I){var C=this;this.getSourceBufferTypes().reduce((function(g,A){var i=C.sourceBuffer[A];return!i||I.type&&I.type!==A||(i.ending=!0,i.ended||(i.ended=!0,H.log("[buffer-controller]: "+A+" sourceBuffer now EOS"))),g&&!(i&&!i.ended)}),!0)&&(H.log("[buffer-controller]: Queueing mediaSource.endOfStream()"),this.blockBuffers((function(){C.getSourceBufferTypes().forEach((function(g){var I=C.sourceBuffer[g];I&&(I.ending=!1)}));var g=C.mediaSource;g&&"open"===g.readyState?(H.log("[buffer-controller]: Calling mediaSource.endOfStream()"),g.endOfStream()):g&&H.info("[buffer-controller]: Could not call mediaSource.endOfStream(). mediaSource.readyState: "+g.readyState)})))},I.onLevelUpdated=function(g,I){var C=I.details;C.fragments.length&&(this.details=C,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())},I.flushBackBuffer=function(){var g=this.hls,I=this.details,C=this.media,A=this.sourceBuffer;if(C&&null!==I){var i=this.getSourceBufferTypes();if(i.length){var e=I.live&&null!==g.config.liveBackBufferLength?g.config.liveBackBufferLength:g.config.backBufferLength;if(W(e)&&!(e<0)){var l=C.currentTime,t=I.levelTargetDuration,s=Math.max(e,t),c=Math.floor(l/t)*t-s;i.forEach((function(C){var i=A[C];if(i){var e=bC.getBuffered(i);if(e.length>0&&c>e.start(0)){if(g.trigger(p.BACK_BUFFER_REACHED,{bufferEnd:c}),I.live)g.trigger(p.LIVE_BACK_BUFFER_REACHED,{bufferEnd:c});else if(i.ended&&e.end(e.length-1)-l<2*t)return void H.info("[buffer-controller]: Cannot flush "+C+" back buffer while SourceBuffer is in ended state");g.trigger(p.BUFFER_FLUSHING,{startOffset:0,endOffset:c,type:C})}}}))}}}},I.updateMediaElementDuration=function(){if(this.details&&this.media&&this.mediaSource&&"open"===this.mediaSource.readyState){var g=this.details,I=this.hls,C=this.media,A=this.mediaSource,i=g.fragments[0].start+g.totalduration,e=C.duration,l=W(A.duration)?A.duration:0;g.live&&I.config.liveDurationInfinity?(H.log("[buffer-controller]: Media Source duration is set to Infinity"),A.duration=1/0,this.updateSeekableRange(g)):(i>l&&i>e||!W(e))&&(H.log("[buffer-controller]: Updating Media Source duration to "+i.toFixed(3)),A.duration=i)}},I.updateSeekableRange=function(g){var I=this.mediaSource,C=g.fragments;if(C.length&&g.live&&null!=I&&I.setLiveSeekableRange){var A=Math.max(0,C[0].start),i=Math.max(A,A+g.totalduration);I.setLiveSeekableRange(A,i)}},I.checkPendingTracks=function(){var g=this.bufferCodecEventsExpected,I=this.operationQueue,C=this.pendingTracks,A=Object.keys(C).length;if(A&&!g||2===A){this.createSourceBuffers(C),this.pendingTracks={};var i=this.getSourceBufferTypes();if(i.length)this.hls.trigger(p.BUFFER_CREATED,{tracks:this.tracks}),i.forEach((function(g){I.executeNext(g)}));else{var e=new Error("could not create source buffer for media codec(s)");this.hls.trigger(p.ERROR,{type:V.MEDIA_ERROR,details:y.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:e,reason:e.message})}}},I.createSourceBuffers=function(g){var I=this.sourceBuffer,C=this.mediaSource;if(!C)throw Error("createSourceBuffers called when mediaSource was null");for(var A in g)if(!I[A]){var i=g[A];if(!i)throw Error("source buffer exists for track "+A+", however track does not");var e=i.levelCodec||i.codec,l=i.container+";codecs="+e;H.log("[buffer-controller]: creating sourceBuffer("+l+")");try{var t=I[A]=C.addSourceBuffer(l),s=A;this.addBufferListener(s,"updatestart",this._onSBUpdateStart),this.addBufferListener(s,"updateend",this._onSBUpdateEnd),this.addBufferListener(s,"error",this._onSBUpdateError),this.tracks[A]={buffer:t,codec:e,container:i.container,levelCodec:i.levelCodec,metadata:i.metadata,id:i.id}}catch(c){H.error("[buffer-controller]: error while trying to add sourceBuffer: "+c.message),this.hls.trigger(p.ERROR,{type:V.MEDIA_ERROR,details:y.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:c,mimeType:l})}}},I._onSBUpdateStart=function(g){this.operationQueue.current(g).onStart()},I._onSBUpdateEnd=function(g){var I=this.operationQueue;I.current(g).onComplete(),I.shiftAndExecuteNext(g)},I._onSBUpdateError=function(g,I){var C=new Error(g+" SourceBuffer error");H.error("[buffer-controller]: "+C,I),this.hls.trigger(p.ERROR,{type:V.MEDIA_ERROR,details:y.BUFFER_APPENDING_ERROR,error:C,fatal:!1});var A=this.operationQueue.current(g);A&&A.onError(I)},I.removeExecutor=function(g,I,C){var A=this.media,i=this.mediaSource,e=this.operationQueue,l=this.sourceBuffer[g];if(!A||!i||!l)return H.warn("[buffer-controller]: Attempting to remove from the "+g+" SourceBuffer, but it does not exist"),void e.shiftAndExecuteNext(g);var t=W(A.duration)?A.duration:1/0,s=W(i.duration)?i.duration:1/0,c=Math.max(0,I),d=Math.min(C,t,s);d>c&&!l.ending?(l.ended=!1,H.log("[buffer-controller]: Removing ["+c+","+d+"] from the "+g+" SourceBuffer"),l.remove(c,d)):e.shiftAndExecuteNext(g)},I.appendExecutor=function(g,I){var C=this.operationQueue,A=this.sourceBuffer[I];if(!A)return H.warn("[buffer-controller]: Attempting to append to the "+I+" SourceBuffer, but it does not exist"),void C.shiftAndExecuteNext(I);A.ended=!1,A.appendBuffer(g)},I.blockBuffers=function(g,I){var C=this;if(void 0===I&&(I=this.getSourceBufferTypes()),!I.length)return H.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),void Promise.resolve().then(g);var A=this.operationQueue,i=I.map((function(g){return A.appendBlocker(g)}));Promise.all(i).then((function(){g(),I.forEach((function(g){var I=C.sourceBuffer[g];null!=I&&I.updating||A.shiftAndExecuteNext(g)}))}))},I.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},I.addBufferListener=function(g,I,C){var A=this.sourceBuffer[g];if(A){var i=C.bind(this,g);this.listeners[g].push({event:I,listener:i}),A.addEventListener(I,i)}},I.removeBufferListeners=function(g){var I=this.sourceBuffer[g];I&&this.listeners[g].forEach((function(g){I.removeEventListener(g.event,g.listener)}))},g}(),ai={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,128:174,129:176,130:189,131:191,132:8482,133:162,134:163,135:9834,136:224,137:32,138:232,139:226,140:234,141:238,142:244,143:251,144:193,145:201,146:211,147:218,148:220,149:252,150:8216,151:161,152:42,153:8217,154:9473,155:169,156:8480,157:8226,158:8220,159:8221,160:192,161:194,162:199,163:200,164:202,165:203,166:235,167:206,168:207,169:239,170:212,171:217,172:249,173:219,174:171,175:187,176:195,177:227,178:205,179:204,180:236,181:210,182:242,183:213,184:245,185:123,186:125,187:92,188:94,189:95,190:124,191:8764,192:196,193:228,194:214,195:246,196:223,197:165,198:164,199:9475,200:197,201:229,202:216,203:248,204:9487,205:9491,206:9495,207:9499},Zi=function(g){var I=g;return ai.hasOwnProperty(g)&&(I=ai[g]),String.fromCharCode(I)},bi=15,ri=100,mi={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},hi={17:2,18:4,21:6,22:8,23:10,19:13,20:15},Gi={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},ui={25:2,26:4,29:6,30:8,31:10,27:13,28:15},Bi=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],wi=function(){function g(){this.time=null,this.verboseLevel=0}return g.prototype.log=function(g,I){if(this.verboseLevel>=g){var C="function"==typeof I?I():I;H.log(this.time+" ["+g+"] "+C)}},g}(),Wi=function(g){for(var I=[],C=0;Cri&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=ri)},I.moveCursor=function(g){var I=this.pos+g;if(g>1)for(var C=this.pos+1;C=144&&this.backSpace();var C=Zi(g);this.pos>=ri?this.logger.log(0,(function(){return"Cannot insert "+g.toString(16)+" ("+C+") at position "+I.pos+". Skipping it!"})):(this.chars[this.pos].setChar(C,this.currPenState),this.moveCursor(1))},I.clearFromPos=function(g){var I;for(I=g;I0&&(C=g?"["+I.join(" | ")+"]":I.join("\n")),C},I.getTextAndFormat=function(){return this.rows},g}(),Yi=function(){function g(g,I,C){this.chNr=void 0,this.outputFilter=void 0,this.mode=void 0,this.verbose=void 0,this.displayedMemory=void 0,this.nonDisplayedMemory=void 0,this.lastOutputScreen=void 0,this.currRollUpRow=void 0,this.writeScreen=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chNr=g,this.outputFilter=I,this.mode=null,this.verbose=0,this.displayedMemory=new Xi(C),this.nonDisplayedMemory=new Xi(C),this.lastOutputScreen=new Xi(C),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=C}var I=g.prototype;return I.reset=function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null},I.getHandler=function(){return this.outputFilter},I.setHandler=function(g){this.outputFilter=g},I.setPAC=function(g){this.writeScreen.setPAC(g)},I.setBkgData=function(g){this.writeScreen.setBkgData(g)},I.setMode=function(g){g!==this.mode&&(this.mode=g,this.logger.log(2,(function(){return"MODE="+g})),"MODE_POP-ON"===this.mode?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),"MODE_ROLL-UP"!==this.mode&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=g)},I.insertChars=function(g){for(var I=this,C=0;C=46,I.italics)I.foreground="white";else{var C=Math.floor(g/2)-16;I.foreground=["white","green","blue","cyan","red","yellow","magenta"][C]}this.logger.log(2,"MIDROW: "+JSON.stringify(I)),this.writeScreen.setPen(I)},I.outputDataUpdate=function(g){void 0===g&&(g=!1);var I=this.logger.time;null!==I&&this.outputFilter&&(null!==this.cueStartTime||this.displayedMemory.isEmpty()?this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,I,this.lastOutputScreen),g&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:I):this.cueStartTime=I,this.lastOutputScreen.copy(this.displayedMemory))},I.cueSplitAtTime=function(g){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,g,this.displayedMemory),this.cueStartTime=g))},g}(),Ri=function(){function g(g,I,C){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var A=new wi;this.channels=[null,new Yi(g,I,A),new Yi(g+1,C,A)],this.cmdHistory={a:null,b:null},this.logger=A}var I=g.prototype;return I.getHandler=function(g){return this.channels[g].getHandler()},I.setHandler=function(g,I){this.channels[g].setHandler(I)},I.addData=function(g,I){var C,A,i,e=!1;this.logger.time=g;for(var l=0;l ("+Wi([A,i])+")"),(C=this.parseCmd(A,i))||(C=this.parseMidrow(A,i)),C||(C=this.parsePAC(A,i)),C||(C=this.parseBackgroundAttributes(A,i)),!C&&(e=this.parseChars(A,i))){var t=this.currentChannel;t&&t>0?this.channels[t].insertChars(e):this.logger.log(2,"No channel found yet. TEXT-MODE?")}C||e||this.logger.log(2,"Couldn't parse cleaned data "+Wi([A,i])+" orig: "+Wi([I[l],I[l+1]]))}},I.parseCmd=function(g,I){var C=this.cmdHistory;if(!((20===g||28===g||21===g||29===g)&&I>=32&&I<=47||(23===g||31===g)&&I>=33&&I<=35))return!1;if(Hi(g,I,C))return Ni(null,null,C),this.logger.log(3,"Repeated command ("+Wi([g,I])+") is dropped"),!0;var A=20===g||21===g||23===g?1:2,i=this.channels[A];return 20===g||21===g||28===g||29===g?32===I?i.ccRCL():33===I?i.ccBS():34===I?i.ccAOF():35===I?i.ccAON():36===I?i.ccDER():37===I?i.ccRU(2):38===I?i.ccRU(3):39===I?i.ccRU(4):40===I?i.ccFON():41===I?i.ccRDC():42===I?i.ccTR():43===I?i.ccRTD():44===I?i.ccEDM():45===I?i.ccCR():46===I?i.ccENM():47===I&&i.ccEOC():i.ccTO(I-32),Ni(g,I,C),this.currentChannel=A,!0},I.parseMidrow=function(g,I){var C=0;if((17===g||25===g)&&I>=32&&I<=47){if((C=17===g?1:2)!==this.currentChannel)return this.logger.log(0,"Mismatch channel in midrow parsing"),!1;var A=this.channels[C];return!!A&&(A.ccMIDROW(I),this.logger.log(3,"MIDROW ("+Wi([g,I])+")"),!0)}return!1},I.parsePAC=function(g,I){var C,A=this.cmdHistory;if(!((g>=17&&g<=23||g>=25&&g<=31)&&I>=64&&I<=127||(16===g||24===g)&&I>=64&&I<=95))return!1;if(Hi(g,I,A))return Ni(null,null,A),!0;var i=g<=23?1:2;C=I>=64&&I<=95?1===i?mi[g]:Gi[g]:1===i?hi[g]:ui[g];var e=this.channels[i];return!!e&&(e.setPAC(this.interpretPAC(C,I)),Ni(g,I,A),this.currentChannel=i,!0)},I.interpretPAC=function(g,I){var C,A={color:null,italics:!1,indent:null,underline:!1,row:g};return C=I>95?I-96:I-64,A.underline=!(1&~C),C<=13?A.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(C/2)]:C<=15?(A.italics=!0,A.color="white"):A.indent=4*Math.floor((C-16)/2),A},I.parseChars=function(g,I){var C,A,i=null,e=null;if(g>=25?(C=2,e=g-8):(C=1,e=g),e>=17&&e<=19?(A=17===e?I+80:18===e?I+112:I+144,this.logger.log(2,"Special char '"+Zi(A)+"' in channel "+C),i=[A]):g>=32&&g<=127&&(i=0===I?[g]:[g,I]),i){var l=Wi(i);this.logger.log(3,"Char codes = "+l.join(",")),Ni(g,I,this.cmdHistory)}return i},I.parseBackgroundAttributes=function(g,I){var C;if(!((16===g||24===g)&&I>=32&&I<=47||(23===g||31===g)&&I>=45&&I<=47))return!1;var A={};16===g||24===g?(C=Math.floor((I-32)/2),A.background=Bi[C],I%2==1&&(A.background=A.background+"_semi")):45===I?A.background="transparent":(A.foreground="black",47===I&&(A.underline=!0));var i=g<=23?1:2;return this.channels[i].setBkgData(A),Ni(g,I,this.cmdHistory),!0},I.reset=function(){for(var g=0;gg)&&(this.startTime=g),this.endTime=I,this.screen=C,this.timelineController.createCaptionsTrack(this.trackName)},I.reset=function(){this.cueRanges=[],this.startTime=null},g}(),Fi=function(){if("undefined"!=typeof self&&self.VTTCue)return self.VTTCue;var g=["","lr","rl"],I=["start","middle","end","left","right"];function C(g,I){if("string"!=typeof I)return!1;if(!Array.isArray(g))return!1;var C=I.toLowerCase();return!!~g.indexOf(C)&&C}function A(g){return C(I,g)}function i(g){for(var I=arguments.length,C=new Array(I>1?I-1:0),A=1;A100)throw new Error("Position must be between 0 and 100.");G=g,this.hasBeenReset=!0}})),Object.defineProperty(t,"positionAlign",i({},s,{get:function(){return u},set:function(g){var I=A(g);if(!I)throw new SyntaxError("An invalid or illegal string was specified.");u=I,this.hasBeenReset=!0}})),Object.defineProperty(t,"size",i({},s,{get:function(){return B},set:function(g){if(g<0||g>100)throw new Error("Size must be between 0 and 100.");B=g,this.hasBeenReset=!0}})),Object.defineProperty(t,"align",i({},s,{get:function(){return w},set:function(g){var I=A(g);if(!I)throw new SyntaxError("An invalid or illegal string was specified.");w=I,this.hasBeenReset=!0}})),t.displayState=void 0}return e.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},e}(),Mi=function(){function g(){}return g.prototype.decode=function(g,I){if(!g)return"";if("string"!=typeof g)throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(g))},g}();function Ji(g){function I(g,I,C,A){return 3600*(0|g)+60*(0|I)+(0|C)+parseFloat(A||0)}var C=g.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return C?parseFloat(C[2])>59?I(C[2],C[3],0,C[4]):I(C[1],C[2],C[3],C[4]):null}var Si=function(){function g(){this.values=Object.create(null)}var I=g.prototype;return I.set=function(g,I){this.get(g)||""===I||(this.values[g]=I)},I.get=function(g,I,C){return C?this.has(g)?this.values[g]:I[C]:this.has(g)?this.values[g]:I},I.has=function(g){return g in this.values},I.alt=function(g,I,C){for(var A=0;A=0&&C<=100)return this.set(g,C),!0}return!1},g}();function fi(g,I,C,A){var i=A?g.split(A):[g];for(var e in i)if("string"==typeof i[e]){var l=i[e].split(C);2===l.length&&I(l[0],l[1])}}var ki=new Fi(0,0,""),Di="middle"===ki.align?"middle":"center";function Li(g,I,C){var A=g;function i(){var I=Ji(g);if(null===I)throw new Error("Malformed timestamp: "+A);return g=g.replace(/^[^\sa-zA-Z-]+/,""),I}function e(){g=g.replace(/^\s+/,"")}if(e(),I.startTime=i(),e(),"--\x3e"!==g.slice(0,3))throw new Error("Malformed time stamp (time stamps must be separated by '--\x3e'): "+A);g=g.slice(3),e(),I.endTime=i(),e(),function(g,I){var A=new Si;fi(g,(function(g,I){var i;switch(g){case"region":for(var e=C.length-1;e>=0;e--)if(C[e].id===I){A.set(g,C[e].region);break}break;case"vertical":A.alt(g,I,["rl","lr"]);break;case"line":i=I.split(","),A.integer(g,i[0]),A.percent(g,i[0])&&A.set("snapToLines",!1),A.alt(g,i[0],["auto"]),2===i.length&&A.alt("lineAlign",i[1],["start",Di,"end"]);break;case"position":i=I.split(","),A.percent(g,i[0]),2===i.length&&A.alt("positionAlign",i[1],["start",Di,"end","line-left","line-right","auto"]);break;case"size":A.percent(g,I);break;case"align":A.alt(g,I,["start",Di,"end","left","right"])}}),/:/,/\s/),I.region=A.get("region",null),I.vertical=A.get("vertical","");var i=A.get("line","auto");"auto"===i&&-1===ki.line&&(i=-1),I.line=i,I.lineAlign=A.get("lineAlign","start"),I.snapToLines=A.get("snapToLines",!0),I.size=A.get("size",100),I.align=A.get("align",Di);var e=A.get("position","auto");"auto"===e&&50===ki.position&&(e="start"===I.align||"left"===I.align?0:"end"===I.align||"right"===I.align?100:50),I.position=e}(g,I)}function zi(g){return g.replace(//gi,"\n")}var vi=function(){function g(){this.state="INITIAL",this.buffer="",this.decoder=new Mi,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}var I=g.prototype;return I.parse=function(g){var I=this;function C(){var g=I.buffer,C=0;for(g=zi(g);C>>0).toString()};function Qi(g,I,C){return Ui(g.toString())+Ui(I.toString())+Ui(C)}var ji="stpp.ttml.im1t",Oi=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,Ei=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,Pi={left:"start",center:"center",right:"end",start:"start",end:"end"};function _i(g,I,C,A){var i=Yg(new Uint8Array(g),["mdat"]);if(0!==i.length){var e,l,s,c=i.map((function(g){return hg(g)})),d=(e=I.baseTime,1,void 0===(l=I.timescale)&&(l=1),void 0===s&&(s=!1),WA(e,1,1/l,s));try{c.forEach((function(g){return C(function(g,I){var C=(new DOMParser).parseFromString(g,"text/xml").getElementsByTagName("tt")[0];if(!C)throw new Error("Invalid ttml");var A={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},i=Object.keys(A).reduce((function(g,I){return g[I]=C.getAttribute("ttp:"+I)||A[I],g}),{}),e="preserve"!==C.getAttribute("xml:space"),l=$i(qi(C,"styling","style")),s=$i(qi(C,"layout","region")),c=qi(C,"body","[begin]");return[].map.call(c,(function(g){var C=ge(g,e);if(!C||!g.hasAttribute("begin"))return null;var A=Ae(g.getAttribute("begin"),i),c=Ae(g.getAttribute("dur"),i),d=Ae(g.getAttribute("end"),i);if(null===A)throw Ce(g);if(null===d){if(null===c)throw Ce(g);d=A+c}var o=new Fi(A-I,d-I,C);o.id=Qi(o.startTime,o.endTime,o.text);var n,a,Z,b,r,m,h=(n=s[g.getAttribute("region")],a=l[g.getAttribute("style")],Z=l,b="http://www.w3.org/ns/ttml#styling",r=null,(m=null!=n&&n.hasAttribute("style")?n.getAttribute("style"):null)&&Z.hasOwnProperty(m)&&(r=Z[m]),["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"].reduce((function(g,I){var C=Ie(a,b,I)||Ie(n,b,I)||Ie(r,b,I);return C&&(g[I]=C),g}),{})),G=h.textAlign;if(G){var u=Pi[G];u&&(o.lineAlign=u),o.align=G}return t(o,h),o})).filter((function(g){return null!==g}))}(g,d))}))}catch(o){A(o)}}else A(new Error("Could not parse IMSC1 mdat"))}function qi(g,I,C){var A=g.getElementsByTagName(I)[0];return A?[].slice.call(A.querySelectorAll(C)):[]}function $i(g){return g.reduce((function(g,I){var C=I.getAttribute("xml:id");return C&&(g[C]=I),g}),{})}function ge(g,I){return[].slice.call(g.childNodes).reduce((function(g,C,A){var i;return"br"===C.nodeName&&A?g+"\n":null!=(i=C.childNodes)&&i.length?ge(C,I):I?g+C.textContent.trim().replace(/\s+/g," "):g+C.textContent}),"")}function Ie(g,I,C){return g&&g.hasAttributeNS(I,C)?g.getAttributeNS(I,C):null}function Ce(g){return new Error("Could not parse ttml timestamp "+g)}function Ae(g,I){if(!g)return null;var C=Ji(g);return null===C&&(Oi.test(g)?C=function(g,I){var C=Oi.exec(g),A=(0|C[4])+(0|C[5])/I.subFrameRate;return 3600*(0|C[1])+60*(0|C[2])+(0|C[3])+A/I.frameRate}(g,I):Ei.test(g)&&(C=function(g,I){var C=Ei.exec(g),A=Number(C[1]);switch(C[2]){case"h":return 3600*A;case"m":return 60*A;case"ms":return 1e3*A;case"f":return A/I.frameRate;case"t":return A/I.tickRate}return A}(g,I))),C}var ie=function(){function g(g){if(this.hls=void 0,this.media=null,this.config=void 0,this.enabled=!0,this.Cues=void 0,this.textTracks=[],this.tracks=[],this.initPTS=[],this.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}},this.captionsProperties=void 0,this.hls=g,this.config=g.config,this.Cues=g.config.cueHandler,this.captionsProperties={textTrack1:{label:this.config.captionsTextTrack1Label,languageCode:this.config.captionsTextTrack1LanguageCode},textTrack2:{label:this.config.captionsTextTrack2Label,languageCode:this.config.captionsTextTrack2LanguageCode},textTrack3:{label:this.config.captionsTextTrack3Label,languageCode:this.config.captionsTextTrack3LanguageCode},textTrack4:{label:this.config.captionsTextTrack4Label,languageCode:this.config.captionsTextTrack4LanguageCode}},this.config.enableCEA708Captions){var I=new Ki(this,"textTrack1"),C=new Ki(this,"textTrack2"),A=new Ki(this,"textTrack3"),i=new Ki(this,"textTrack4");this.cea608Parser1=new Ri(1,I,C),this.cea608Parser2=new Ri(3,A,i)}g.on(p.MEDIA_ATTACHING,this.onMediaAttaching,this),g.on(p.MEDIA_DETACHING,this.onMediaDetaching,this),g.on(p.MANIFEST_LOADING,this.onManifestLoading,this),g.on(p.MANIFEST_LOADED,this.onManifestLoaded,this),g.on(p.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),g.on(p.FRAG_LOADING,this.onFragLoading,this),g.on(p.FRAG_LOADED,this.onFragLoaded,this),g.on(p.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),g.on(p.FRAG_DECRYPTED,this.onFragDecrypted,this),g.on(p.INIT_PTS_FOUND,this.onInitPtsFound,this),g.on(p.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),g.on(p.BUFFER_FLUSHING,this.onBufferFlushing,this)}var I=g.prototype;return I.destroy=function(){var g=this.hls;g.off(p.MEDIA_ATTACHING,this.onMediaAttaching,this),g.off(p.MEDIA_DETACHING,this.onMediaDetaching,this),g.off(p.MANIFEST_LOADING,this.onManifestLoading,this),g.off(p.MANIFEST_LOADED,this.onManifestLoaded,this),g.off(p.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),g.off(p.FRAG_LOADING,this.onFragLoading,this),g.off(p.FRAG_LOADED,this.onFragLoaded,this),g.off(p.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),g.off(p.FRAG_DECRYPTED,this.onFragDecrypted,this),g.off(p.INIT_PTS_FOUND,this.onInitPtsFound,this),g.off(p.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),g.off(p.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null},I.addCues=function(g,I,C,A,i){for(var e,l,t,s,c=!1,d=i.length;d--;){var o=i[d],n=(e=o[0],l=o[1],t=I,s=C,Math.min(l,s)-Math.max(e,t));if(n>=0&&(o[0]=Math.min(o[0],I),o[1]=Math.max(o[1],C),c=!0,n/(C-I)>.5))return}if(c||i.push([I,C]),this.config.renderTextTracksNatively){var a=this.captionsTracks[g];this.Cues.newCue(a,I,C,A)}else{var Z=this.Cues.newCue(null,I,C,A);this.hls.trigger(p.CUES_PARSED,{type:"captions",cues:Z,track:g})}},I.onInitPtsFound=function(g,I){var C=this,A=I.frag,i=I.id,e=I.initPTS,l=I.timescale,t=this.unparsedVttFrags;"main"===i&&(this.initPTS[A.cc]={baseTime:e,timescale:l}),t.length&&(this.unparsedVttFrags=[],t.forEach((function(g){C.onFragLoaded(p.FRAG_LOADED,g)})))},I.getExistingTrack=function(g){var I=this.media;if(I)for(var C=0;C0&&n.push(g)},d.onparsingerror=function(g){c=g},d.onflush=function(){c?l(c):e(n)},o.forEach((function(g){if(m){if(xi(g,"X-TIMESTAMP-MAP=")){m=!1,g.slice(16).split(",").forEach((function(g){xi(g,"LOCAL:")?Z=g.slice(6):xi(g,"MPEGTS:")&&(b=parseInt(g.slice(7)))}));try{r=function(g){var I=parseInt(g.slice(-3)),C=parseInt(g.slice(-6,-4)),A=parseInt(g.slice(-9,-7)),i=g.length>9?parseInt(g.substring(0,g.indexOf(":"))):0;if(!(W(I)&&W(C)&&W(A)&&W(i)))throw Error("Malformed X-TIMESTAMP-MAP: Local:"+g);return I+=1e3*C,(I+=6e4*A)+36e5*i}(Z)/1e3}catch(I){c=I}return}""===g&&(m=!1)}d.parse(g+"\n")})),d.flush()}(null!=(I=A.initSegment)&&I.data?Fg(A.initSegment.data,new Uint8Array(i)):i,this.initPTS[A.cc],this.vttCCs,A.cc,A.start,(function(g){C._appendCues(g,A.level),s.trigger(p.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:A})}),(function(I){var e="Missing initPTS for VTT MPEGTS"===I.message;e?l.push(g):C._fallbackToIMSC1(A,i),H.log("Failed to parse VTT cue: "+I),e&&t>A.cc||s.trigger(p.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:A,error:I})}))}else l.push(g)},I._fallbackToIMSC1=function(g,I){var C=this,A=this.tracks[g.level];A.textCodec||_i(I,this.initPTS[g.cc],(function(){A.textCodec=ji,C._parseIMSC1(g,I)}),(function(){A.textCodec="wvtt"}))},I._appendCues=function(g,I){var C=this.hls;if(this.config.renderTextTracksNatively){var A=this.textTracks[I];if(!A||"disabled"===A.mode)return;g.forEach((function(g){return uI(A,g)}))}else{var i=this.tracks[I];if(!i)return;var e=i.default?"default":"subtitles"+I;C.trigger(p.CUES_PARSED,{type:"subtitles",cues:g,track:e})}},I.onFragDecrypted=function(g,I){I.frag.type===bI&&this.onFragLoaded(p.FRAG_LOADED,I)},I.onSubtitleTracksCleared=function(){this.tracks=[],this.captionsTracks={}},I.onFragParsingUserdata=function(g,I){var C=this.cea608Parser1,A=this.cea608Parser2;if(this.enabled&&C&&A){var i=I.frag,e=I.samples;if(i.type!==aI||"NONE"!==this.closedCaptionsForLevel(i))for(var l=0;l0&&this.mediaWidth>0){var g=this.hls.levels;if(g.length){var I=this.hls;I.autoLevelCapping=this.getMaxLevel(g.length-1),I.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=I.autoLevelCapping}}},I.getMaxLevel=function(I){var C=this,A=this.hls.levels;if(!A.length)return-1;var i=A.filter((function(g,A){return C.isLevelAllowed(g)&&A<=I}));return this.clientRect=null,g.getMaxLevelByMediaSize(i,this.mediaWidth,this.mediaHeight)},I.startCapping=function(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,this.hls.firstLevel=this.getMaxLevel(this.firstLevel),self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())},I.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},I.getDimensions=function(){if(this.clientRect)return this.clientRect;var g=this.media,I={width:0,height:0};if(g){var C=g.getBoundingClientRect();I.width=C.width,I.height=C.height,I.width||I.height||(I.width=C.right-C.left||g.width||0,I.height=C.bottom-C.top||g.height||0)}return this.clientRect=I,I},I.isLevelAllowed=function(g){return!this.restrictedLevels.some((function(I){return g.bitrate===I.bitrate&&g.width===I.width&&g.height===I.height}))},g.getMaxLevelByMediaSize=function(g,I,C){if(null==g||!g.length)return-1;for(var A,i,e=g.length-1,l=0;l=I||t.height>=C)&&(A=t,!(i=g[l+1])||A.width!==i.width||A.height!==i.height)){e=l;break}}return e},e(g,[{key:"mediaWidth",get:function(){return this.getDimensions().width*this.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*this.contentScaleFactor}},{key:"contentScaleFactor",get:function(){var g=1;if(!this.hls.config.ignoreDevicePixelRatio)try{g=self.devicePixelRatio}catch(I){}return g}}]),g}(),te=function(){function g(g){this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=g,this.registerListeners()}var I=g.prototype;return I.setStreamController=function(g){this.streamController=g},I.registerListeners=function(){this.hls.on(p.MEDIA_ATTACHING,this.onMediaAttaching,this)},I.unregisterListeners=function(){this.hls.off(p.MEDIA_ATTACHING,this.onMediaAttaching,this)},I.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},I.onMediaAttaching=function(g,I){var C=this.hls.config;if(C.capLevelOnFPSDrop){var A=I.media instanceof self.HTMLVideoElement?I.media:null;this.media=A,A&&"function"==typeof A.getVideoPlaybackQuality&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),C.fpsDroppedMonitoringPeriod)}},I.checkFPS=function(g,I,C){var A=performance.now();if(I){if(this.lastTime){var i=A-this.lastTime,e=C-this.lastDroppedFrames,l=I-this.lastDecodedFrames,t=1e3*e/i,s=this.hls;if(s.trigger(p.FPS_DROP,{currentDropped:e,currentDecoded:l,totalDroppedFrames:C}),t>0&&e>s.config.fpsDroppedMonitoringThreshold*l){var c=s.currentLevel;H.warn("drop FPS ratio greater than max allowed value for currentLevel: "+c),c>0&&(-1===s.autoLevelCapping||s.autoLevelCapping>=c)&&(c-=1,s.trigger(p.FPS_DROP_LEVEL_CAPPING,{level:c,droppedLevel:s.currentLevel}),s.autoLevelCapping=c,this.streamController.nextLevelSwitch())}}this.lastTime=A,this.lastDroppedFrames=C,this.lastDecodedFrames=I}},I.checkFPSInterval=function(){var g=this.media;if(g)if(this.isVideoPlaybackQualityAvailable){var I=g.getVideoPlaybackQuality();this.checkFPS(g,I.totalVideoFrames,I.droppedVideoFrames)}else this.checkFPS(g,g.webkitDecodedFrameCount,g.webkitDroppedFrameCount)},g}(),se="[eme]",ce=function(){function g(I){this.hls=void 0,this.config=void 0,this.media=null,this.keyFormatPromise=null,this.keySystemAccessPromises={},this._requestLicenseFailureCount=0,this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},this.setMediaKeysQueue=g.CDMCleanupPromise?[g.CDMCleanupPromise]:[],this.onMediaEncrypted=this._onMediaEncrypted.bind(this),this.onWaitingForKey=this._onWaitingForKey.bind(this),this.debug=H.debug.bind(H,se),this.log=H.log.bind(H,se),this.warn=H.warn.bind(H,se),this.error=H.error.bind(H,se),this.hls=I,this.config=I.config,this.registerListeners()}var I=g.prototype;return I.destroy=function(){this.unregisterListeners(),this.onMediaDetached();var g=this.config;g.requestMediaKeySystemAccessFunc=null,g.licenseXhrSetup=g.licenseResponseCallback=void 0,g.drmSystems=g.drmSystemOptions={},this.hls=this.onMediaEncrypted=this.onWaitingForKey=this.keyIdToKeySessionPromise=null,this.config=null},I.registerListeners=function(){this.hls.on(p.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(p.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(p.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(p.MANIFEST_LOADED,this.onManifestLoaded,this)},I.unregisterListeners=function(){this.hls.off(p.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(p.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(p.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(p.MANIFEST_LOADED,this.onManifestLoaded,this)},I.getLicenseServerUrl=function(g){var I=this.config,C=I.drmSystems,A=I.widevineLicenseUrl,i=C[g];if(i)return i.licenseUrl;if(g===j.WIDEVINE&&A)return A;throw new Error('no license server URL configured for key-system "'+g+'"')},I.getServerCertificateUrl=function(g){var I=this.config.drmSystems[g];if(I)return I.serverCertificateUrl;this.log('No Server Certificate in config.drmSystems["'+g+'"]')},I.attemptKeySystemAccess=function(g){var I=this,C=this.hls.levels,A=function(g,I,C){return!!g&&C.indexOf(g)===I},i=C.map((function(g){return g.audioCodec})).filter(A),e=C.map((function(g){return g.videoCodec})).filter(A);return i.length+e.length===0&&e.push("avc1.42e01e"),new Promise((function(C,A){!function g(l){var t=l.shift();I.getMediaKeysPromise(t,i,e).then((function(g){return C({keySystem:t,mediaKeys:g})})).catch((function(I){l.length?g(l):A(I instanceof de?I:new de({type:V.KEY_SYSTEM_ERROR,details:y.KEY_SYSTEM_NO_ACCESS,error:I,fatal:!0},I.message))}))}(g)}))},I.requestMediaKeySystemAccess=function(g,I){var C=this.config.requestMediaKeySystemAccessFunc;if("function"!=typeof C){var A="Configured requestMediaKeySystemAccess is not a function "+C;return null===Cg&&"http:"===self.location.protocol&&(A="navigator.requestMediaKeySystemAccess is not available over insecure protocol "+location.protocol),Promise.reject(new Error(A))}return C(g,I)},I.getMediaKeysPromise=function(g,I,C){var A=this,i=function(g,I,C,A){var i,e,l,t;switch(g){case j.FAIRPLAY:i=["cenc","sinf"];break;case j.WIDEVINE:case j.PLAYREADY:i=["cenc"];break;case j.CLEARKEY:i=["cenc","keyids"];break;default:throw new Error("Unknown key-system: "+g)}return e=I,l=C,[{initDataTypes:i,persistentState:(t=A).persistentState||"not-allowed",distinctiveIdentifier:t.distinctiveIdentifier||"not-allowed",sessionTypes:t.sessionTypes||[t.sessionType||"temporary"],audioCapabilities:e.map((function(g){return{contentType:'audio/mp4; codecs="'+g+'"',robustness:t.audioRobustness||"",encryptionScheme:t.audioEncryptionScheme||null}})),videoCapabilities:l.map((function(g){return{contentType:'video/mp4; codecs="'+g+'"',robustness:t.videoRobustness||"",encryptionScheme:t.videoEncryptionScheme||null}}))}]}(g,I,C,this.config.drmSystemOptions),e=this.keySystemAccessPromises[g],l=null==e?void 0:e.keySystemAccess;if(!l){this.log('Requesting encrypted media "'+g+'" key-system access with config: '+JSON.stringify(i)),l=this.requestMediaKeySystemAccess(g,i);var t=this.keySystemAccessPromises[g]={keySystemAccess:l};return l.catch((function(I){A.log('Failed to obtain access to key-system "'+g+'": '+I)})),l.then((function(I){A.log('Access for key-system "'+I.keySystem+'" obtained');var C=A.fetchServerCertificate(g);return A.log('Create media-keys for "'+g+'"'),t.mediaKeys=I.createMediaKeys().then((function(I){return A.log('Media-keys created for "'+g+'"'),C.then((function(C){return C?A.setMediaKeysServerCertificate(I,g,C):I}))})),t.mediaKeys.catch((function(I){A.error('Failed to create media-keys for "'+g+'"}: '+I)})),t.mediaKeys}))}return l.then((function(){return e.mediaKeys}))},I.createMediaKeySessionContext=function(g){var I=g.decryptdata,C=g.keySystem,A=g.mediaKeys;this.log('Creating key-system session "'+C+'" keyId: '+Gg(I.keyId||[]));var i=A.createSession(),e={decryptdata:I,keySystem:C,mediaKeys:A,mediaKeysSession:i,keyStatus:"status-pending"};return this.mediaKeySessions.push(e),e},I.renewKeySession=function(g){var I=g.decryptdata;if(I.pssh){var C=this.createMediaKeySessionContext(g),A=this.getKeyIdString(I);this.keyIdToKeySessionPromise[A]=this.generateRequestWithPreferredKeySession(C,"cenc",I.pssh,"expired")}else this.warn("Could not renew expired session. Missing pssh initData.");this.removeSession(g)},I.getKeyIdString=function(g){if(!g)throw new Error("Could not read keyId of undefined decryptdata");if(null===g.keyId)throw new Error("keyId is null");return Gg(g.keyId)},I.updateKeySession=function(g,I){var C,A=g.mediaKeysSession;return this.log('Updating key-session "'+A.sessionId+'" for keyID '+Gg((null==(C=g.decryptdata)?void 0:C.keyId)||[])+"\n } (data length: "+(I?I.byteLength:I)+")"),A.update(I)},I.selectKeySystemFormat=function(g){var I=Object.keys(g.levelkeys||{});return this.keyFormatPromise||(this.log("Selecting key-system from fragment (sn: "+g.sn+" "+g.type+": "+g.level+") key formats "+I.join(", ")),this.keyFormatPromise=this.getKeyFormatPromise(I)),this.keyFormatPromise},I.getKeyFormatPromise=function(g){var I=this;return new Promise((function(C,A){var i=Ig(I.config),e=g.map(q).filter((function(g){return!!g&&-1!==i.indexOf(g)}));return I.getKeySystemSelectionPromise(e).then((function(g){var I=g.keySystem,i=gg(I);i?C(i):A(new Error('Unable to find format for key-system "'+I+'"'))})).catch(A)}))},I.loadKey=function(g){var I=this,C=g.keyInfo.decryptdata,A=this.getKeyIdString(C),i="(keyId: "+A+' format: "'+C.keyFormat+'" method: '+C.method+" uri: "+C.uri+")";this.log("Starting session for key "+i);var e=this.keyIdToKeySessionPromise[A];return e||(e=this.keyIdToKeySessionPromise[A]=this.getKeySystemForKeyPromise(C).then((function(A){var e=A.keySystem,l=A.mediaKeys;return I.throwIfDestroyed(),I.log("Handle encrypted media sn: "+g.frag.sn+" "+g.frag.type+": "+g.frag.level+" using key "+i),I.attemptSetMediaKeys(e,l).then((function(){I.throwIfDestroyed();var g=I.createMediaKeySessionContext({keySystem:e,mediaKeys:l,decryptdata:C});return I.generateRequestWithPreferredKeySession(g,"cenc",C.pssh,"playlist-key")}))}))).catch((function(g){return I.handleError(g)})),e},I.throwIfDestroyed=function(g){if(!this.hls)throw new Error("invalid state")},I.handleError=function(g){this.hls&&(this.error(g.message),g instanceof de?this.hls.trigger(p.ERROR,g.data):this.hls.trigger(p.ERROR,{type:V.KEY_SYSTEM_ERROR,details:y.KEY_SYSTEM_NO_KEYS,error:g,fatal:!0}))},I.getKeySystemForKeyPromise=function(g){var I=this.getKeyIdString(g),C=this.keyIdToKeySessionPromise[I];if(!C){var A=q(g.keyFormat),i=A?[A]:Ig(this.config);return this.attemptKeySystemAccess(i)}return C},I.getKeySystemSelectionPromise=function(g){if(g.length||(g=Ig(this.config)),0===g.length)throw new de({type:V.KEY_SYSTEM_ERROR,details:y.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},"Missing key-system license configuration options "+JSON.stringify({drmSystems:this.config.drmSystems}));return this.attemptKeySystemAccess(g)},I._onMediaEncrypted=function(g){var I=this,C=g.initDataType,A=g.initData;if(this.debug('"'+g.type+'" event: init data type: "'+C+'"'),null!==A){var i,e;if("sinf"===C&&this.config.drmSystems[j.FAIRPLAY]){var l=Wg(new Uint8Array(A));try{var t=U(JSON.parse(l).sinf),s=Hg(new Uint8Array(t));if(!s)return;i=s.subarray(8,24),e=j.FAIRPLAY}catch(m){return void this.warn('Failed to parse sinf "encrypted" event message initData')}}else{var c=function(g){if(!(g instanceof ArrayBuffer)||g.byteLength<32)return null;var I={version:0,systemId:"",kids:null,data:null},C=new DataView(g),A=C.getUint32(0);if(g.byteLength!==A&&A>44)return null;if(1886614376!==C.getUint32(4))return null;if(I.version=C.getUint32(8)>>>24,I.version>1)return null;I.systemId=Gg(new Uint8Array(g,12,16));var i=C.getUint32(28);if(0===I.version){if(A-32o||t.status>=400&&t.status<500)e(new de({type:V.KEY_SYSTEM_ERROR,details:y.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0,networkDetails:t,response:{url:l,data:void 0,code:t.status,text:t.statusText}},"License Request XHR failed ("+l+"). Status: "+t.status+" ("+t.statusText+")"));else{var n=o-C._requestLicenseFailureCount+1;C.warn("Retrying license request, "+n+" attempts left"),C.requestLicense(g,I).then(i,e)}}},g.licenseXhr&&g.licenseXhr.readyState!==XMLHttpRequest.DONE&&g.licenseXhr.abort(),g.licenseXhr=t,C.setupLicenseXHR(t,l,g,I).then((function(g){var I=g.xhr,C=g.licenseChallenge;I.send(C)}))}))},I.onMediaAttached=function(g,I){if(this.config.emeEnabled){var C=I.media;this.media=C,C.addEventListener("encrypted",this.onMediaEncrypted),C.addEventListener("waitingforkey",this.onWaitingForKey)}},I.onMediaDetached=function(){var I=this,C=this.media,A=this.mediaKeySessions;C&&(C.removeEventListener("encrypted",this.onMediaEncrypted),C.removeEventListener("waitingforkey",this.onWaitingForKey),this.media=null),this._requestLicenseFailureCount=0,this.setMediaKeysQueue=[],this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},Dg.clearKeyUriToKeyIdMap();var i=A.length;g.CDMCleanupPromise=Promise.all(A.map((function(g){return I.removeSession(g)})).concat(null==C?void 0:C.setMediaKeys(null).catch((function(g){I.log("Could not clear media keys: "+g+". media.src: "+(null==C?void 0:C.src))})))).then((function(){i&&(I.log("finished closing key sessions and clearing media keys"),A.length=0)})).catch((function(g){I.log("Could not close sessions and clear media keys: "+g+". media.src: "+(null==C?void 0:C.src))}))},I.onManifestLoading=function(){this.keyFormatPromise=null},I.onManifestLoaded=function(g,I){var C=I.sessionKeys;if(C&&this.config.emeEnabled&&!this.keyFormatPromise){var A=C.reduce((function(g,I){return-1===g.indexOf(I.keyFormat)&&g.push(I.keyFormat),g}),[]);this.log("Selecting key-system from session-keys "+A.join(", ")),this.keyFormatPromise=this.getKeyFormatPromise(A)}},I.removeSession=function(g){var I=this,C=g.mediaKeysSession,A=g.licenseXhr;if(C){this.log("Remove licenses and keys and close session "+C.sessionId),C.onmessage=null,C.onkeystatuseschange=null,A&&A.readyState!==XMLHttpRequest.DONE&&A.abort(),g.mediaKeysSession=g.decryptdata=g.licenseXhr=void 0;var i=this.mediaKeySessions.indexOf(g);return i>-1&&this.mediaKeySessions.splice(i,1),C.remove().catch((function(g){I.log("Could not remove session: "+g)})).then((function(){return C.close()})).catch((function(g){I.log("Could not close session: "+g)}))}},g}();ce.CDMCleanupPromise=void 0;var de=function(g){function I(I,C){var A;return(A=g.call(this,C)||this).data=void 0,I.error||(I.error=new Error(C)),A.data=I,I.err=I.error,A}return s(I,g),I}(n(Error)),oe="a",ne="av",ae=function(){function g(I){var C=this;this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=function(){C.initialized&&(C.starved=!0),C.buffering=!0},this.onPlaying=function(){C.initialized||(C.initialized=!0),C.buffering=!1},this.applyPlaylistData=function(g){try{C.apply(g,{ot:"m",su:!C.initialized})}catch(I){H.warn("Could not generate manifest CMCD data.",I)}},this.applyFragmentData=function(g){try{var I=g.frag,A=C.hls.levels[I.level],i=C.getObjectType(I),e={d:1e3*I.duration,ot:i};"v"!==i&&i!==oe&&i!=ne||(e.br=A.bitrate/1e3,e.tb=C.getTopBandwidth(i)/1e3,e.bl=C.getBufferLength(i)),C.apply(g,e)}catch(l){H.warn("Could not generate segment CMCD data.",l)}},this.hls=I;var A=this.config=I.config,i=A.cmcd;null!=i&&(A.pLoader=this.createPlaylistLoader(),A.fLoader=this.createFragmentLoader(),this.sid=i.sessionId||g.uuid(),this.cid=i.contentId,this.useHeaders=!0===i.useHeaders,this.registerListeners())}var I=g.prototype;return I.registerListeners=function(){var g=this.hls;g.on(p.MEDIA_ATTACHED,this.onMediaAttached,this),g.on(p.MEDIA_DETACHED,this.onMediaDetached,this),g.on(p.BUFFER_CREATED,this.onBufferCreated,this)},I.unregisterListeners=function(){var g=this.hls;g.off(p.MEDIA_ATTACHED,this.onMediaAttached,this),g.off(p.MEDIA_DETACHED,this.onMediaDetached,this),g.off(p.BUFFER_CREATED,this.onBufferCreated,this)},I.destroy=function(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null},I.onMediaAttached=function(g,I){this.media=I.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)},I.onMediaDetached=function(){this.media&&(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)},I.onBufferCreated=function(g,I){var C,A;this.audioBuffer=null==(C=I.tracks.audio)?void 0:C.buffer,this.videoBuffer=null==(A=I.tracks.video)?void 0:A.buffer},I.createData=function(){var g;return{v:1,sf:"h",sid:this.sid,cid:this.cid,pr:null==(g=this.media)?void 0:g.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}},I.apply=function(I,C){void 0===C&&(C={}),t(C,this.createData());var A="i"===C.ot||"v"===C.ot||C.ot===ne;if(this.starved&&A&&(C.bs=!0,C.su=!0,this.starved=!1),null==C.su&&(C.su=this.buffering),this.useHeaders){var i=g.toHeaders(C);if(!Object.keys(i).length)return;I.headers||(I.headers={}),t(I.headers,i)}else{var e=g.toQuery(C);if(!e)return;I.url=g.appendQueryToUri(I.url,e)}},I.getObjectType=function(g){var I=g.type;return"subtitle"===I?"tt":"initSegment"===g.sn?"i":"audio"===I?oe:"main"===I?this.hls.audioTracks.length?"v":ne:void 0},I.getTopBandwidth=function(g){var I,C=0,A=this.hls;if(g===oe)I=A.audioTracks;else{var i=A.maxAutoLevel,e=i>-1?i+1:A.levels.length;I=A.levels.slice(0,e)}for(var l,t=Z(I);!(l=t()).done;){var s=l.value;s.bitrate>C&&(C=s.bitrate)}return C>0?C:NaN},I.getBufferLength=function(g){var I=this.hls.media,C=g===oe?this.audioBuffer:this.videoBuffer;return C&&I?1e3*bC.bufferInfo(C,I.currentTime,this.config.maxBufferHole).len:NaN},I.createPlaylistLoader=function(){var g=this.config.pLoader,I=this.applyPlaylistData,C=g||this.config.loader;return function(){function g(g){this.loader=void 0,this.loader=new C(g)}var A=g.prototype;return A.destroy=function(){this.loader.destroy()},A.abort=function(){this.loader.abort()},A.load=function(g,C,A){I(g),this.loader.load(g,C,A)},e(g,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),g}()},I.createFragmentLoader=function(){var g=this.config.fLoader,I=this.applyFragmentData,C=g||this.config.loader;return function(){function g(g){this.loader=void 0,this.loader=new C(g)}var A=g.prototype;return A.destroy=function(){this.loader.destroy()},A.abort=function(){this.loader.abort()},A.load=function(g,C,A){I(g),this.loader.load(g,C,A)},e(g,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),g}()},g.uuid=function(){var g=URL.createObjectURL(new Blob),I=g.toString();return URL.revokeObjectURL(g),I.slice(I.lastIndexOf("/")+1)},g.serialize=function(g){for(var I,C=[],A=function(g){return Math.round(g)},i=function(g){return 100*A(g/100)},e={br:A,d:A,bl:i,dl:i,mtp:i,nor:function(g){return encodeURIComponent(g)},rtp:i,tb:A},l=Z(Object.keys(g||{}).sort());!(I=l()).done;){var t=I.value,s=g[t];if(!(n=s,Number.isNaN(n)||null==n||""===n||!1===n||"v"===t&&1===s||"pr"==t&&1===s)){var c=e[t];c&&(s=c(s));var d,o=typeof s;d="ot"===t||"sf"===t||"st"===t?t+"="+s:"boolean"===o?t:"number"===o?t+"="+s:t+"="+JSON.stringify(s),C.push(d)}}var n;return C.join(",")},g.toHeaders=function(I){for(var C={},A=["Object","Request","Session","Status"],i=[{},{},{},{}],e={br:0,d:0,ot:0,tb:0,bl:1,dl:1,mtp:1,nor:1,nrr:1,su:1,cid:2,pr:2,sf:2,sid:2,st:2,v:2,bs:3,rtp:3},l=0,t=Object.keys(I);l1&&(this.updatePathwayPriority(A),C.resolved=this.pathwayId!==i)}},I.filterParsedLevels=function(g){this.levels=g;var I=this.getLevelsForPathway(this.pathwayId);if(0===I.length){var C=g[0].pathwayId;this.log("No levels found in Pathway "+this.pathwayId+'. Setting initial Pathway to "'+C+'"'),I=this.getLevelsForPathway(C),this.pathwayId=C}return I.length!==g.length?(this.log("Found "+I.length+"/"+g.length+' levels in Pathway "'+this.pathwayId+'"'),I):g},I.getLevelsForPathway=function(g){return null===this.levels?[]:this.levels.filter((function(I){return g===I.pathwayId}))},I.updatePathwayPriority=function(g){var I;this.pathwayPriority=g;var C=this.penalizedPathways,A=performance.now();Object.keys(C).forEach((function(g){A-C[g]>3e5&&delete C[g]}));for(var i=0;i0){this.log('Setting Pathway to "'+e+'"'),this.pathwayId=e,this.hls.trigger(p.LEVELS_UPDATED,{levels:I});var s=this.hls.levels[l];t&&s&&this.levels&&(s.attrs["STABLE-VARIANT-ID"]!==t.attrs["STABLE-VARIANT-ID"]&&s.bitrate!==t.bitrate&&this.log("Unstable Pathways change from bitrate "+t.bitrate+" to "+s.bitrate),this.hls.nextLoadLevel=l);break}}}},I.clonePathways=function(g){var I=this,C=this.levels;if(C){var A={},i={};g.forEach((function(g){var e=g.ID,l=g["BASE-ID"],s=g["URI-REPLACEMENT"];if(!C.some((function(g){return g.pathwayId===e}))){var c=I.getLevelsForPathway(l).map((function(g){var I=t({},g);I.details=void 0,I.url=re(g.uri,g.attrs["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",s);var C=new M(g.attrs);C["PATHWAY-ID"]=e;var l=C.AUDIO&&C.AUDIO+"_clone_"+e,c=C.SUBTITLES&&C.SUBTITLES+"_clone_"+e;l&&(A[C.AUDIO]=l,C.AUDIO=l),c&&(i[C.SUBTITLES]=c,C.SUBTITLES=c),I.attrs=C;var d=new KI(I);return qI(d,"audio",l),qI(d,"text",c),d}));C.push.apply(C,c),be(I.audioTracks,A,s,e),be(I.subtitleTracks,i,s,e)}}))}},I.loadSteeringManifest=function(g){var I,C=this,A=this.hls.config,i=A.loader;this.loader&&this.loader.destroy(),this.loader=new i(A);try{I=new self.URL(g)}catch(o){return this.enabled=!1,void this.log("Failed to parse Steering Manifest URI: "+g)}if("data:"!==I.protocol){var e=0|(this.hls.bandwidthEstimate||A.abrEwmaDefaultEstimate);I.searchParams.set("_HLS_pathway",this.pathwayId),I.searchParams.set("_HLS_throughput",""+e)}var l={responseType:"json",url:I.href},t=A.steeringManifestLoadPolicy.default,s=t.errorRetry||t.timeoutRetry||{},c={loadPolicy:t,timeout:t.maxLoadTimeMs,maxRetry:s.maxNumRetry||0,retryDelay:s.retryDelayMs||0,maxRetryDelay:s.maxRetryDelayMs||0},d={onSuccess:function(g,A,i,e){C.log('Loaded steering manifest: "'+I+'"');var l=g.data;if(1===l.VERSION){C.updated=performance.now(),C.timeToLoad=l.TTL;var t=l["RELOAD-URI"],s=l["PATHWAY-CLONES"],c=l["PATHWAY-PRIORITY"];if(t)try{C.uri=new self.URL(t,I).href}catch(d){return C.enabled=!1,void C.log("Failed to parse Steering Manifest RELOAD-URI: "+t)}C.scheduleRefresh(C.uri||i.url),s&&C.clonePathways(s),c&&C.updatePathwayPriority(c)}else C.log("Steering VERSION "+l.VERSION+" not supported!")},onError:function(g,I,A,i){if(C.log("Error loading steering manifest: "+g.code+" "+g.text+" ("+I.url+")"),C.stopLoad(),410===g.code)return C.enabled=!1,void C.log("Steering manifest "+I.url+" no longer available");var e=1e3*C.timeToLoad;if(429!==g.code)C.scheduleRefresh(C.uri||I.url,e);else{var l=C.loader;if("function"==typeof(null==l?void 0:l.getResponseHeader)){var t=l.getResponseHeader("Retry-After");t&&(e=1e3*parseFloat(t))}C.log("Steering manifest "+I.url+" rate limited")}},onTimeout:function(g,I,A){C.log("Timeout loading steering manifest ("+I.url+")"),C.scheduleRefresh(C.uri||I.url)}};this.log("Requesting steering manifest: "+I),this.loader.load(l,c,d)},I.scheduleRefresh=function(g,I){var C=this;void 0===I&&(I=1e3*this.timeToLoad),self.clearTimeout(this.reloadTimer),this.reloadTimer=self.setTimeout((function(){C.loadSteeringManifest(g)}),I)},g}();function be(g,I,C,A){g&&Object.keys(I).forEach((function(i){var e=g.filter((function(g){return g.groupId===i})).map((function(g){var e=t({},g);return e.details=void 0,e.attrs=new M(e.attrs),e.url=e.attrs.URI=re(g.url,g.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",C),e.groupId=e.attrs["GROUP-ID"]=I[i],e.attrs["PATHWAY-ID"]=A,e}));g.push.apply(g,e)}))}function re(g,I,C,A){var i,e=A.HOST,l=A.PARAMS,t=A[C];I&&(i=null==t?void 0:t[I])&&(g=i);var s=new self.URL(g);return e&&!i&&(s.host=e),l&&Object.keys(l).sort().forEach((function(g){g&&s.searchParams.set(g,l[g])})),s.href}var me=/^age:\s*[\d.]+\s*$/im,he=function(){function g(g){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=void 0,this.loader=null,this.stats=void 0,this.xhrSetup=g&&g.xhrSetup||null,this.stats=new f,this.retryDelay=0}var I=g.prototype;return I.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},I.abortInternal=function(){var g=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),g&&(g.onreadystatechange=null,g.onprogress=null,4!==g.readyState&&(this.stats.aborted=!0,g.abort()))},I.abort=function(){var g;this.abortInternal(),null!=(g=this.callbacks)&&g.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},I.load=function(g,I,C){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=g,this.config=I,this.callbacks=C,this.loadInternal()},I.loadInternal=function(){var g=this,I=this.config,C=this.context;if(I){var A=this.loader=new self.XMLHttpRequest,i=this.stats;i.loading.first=0,i.loaded=0,i.aborted=!1;var e=this.xhrSetup;e?Promise.resolve().then((function(){if(!g.stats.aborted)return e(A,C.url)})).catch((function(g){return A.open("GET",C.url,!0),e(A,C.url)})).then((function(){g.stats.aborted||g.openAndSendXhr(A,C,I)})).catch((function(I){g.callbacks.onError({code:A.status,text:I.message},C,A,i)})):this.openAndSendXhr(A,C,I)}},I.openAndSendXhr=function(g,I,C){g.readyState||g.open("GET",I.url,!0);var A=this.context.headers,i=C.loadPolicy,e=i.maxTimeToFirstByteMs,l=i.maxLoadTimeMs;if(A)for(var t in A)g.setRequestHeader(t,A[t]);I.rangeEnd&&g.setRequestHeader("Range","bytes="+I.rangeStart+"-"+(I.rangeEnd-1)),g.onreadystatechange=this.readystatechange.bind(this),g.onprogress=this.loadprogress.bind(this),g.responseType=I.responseType,self.clearTimeout(this.requestTimeout),C.timeout=e&&W(e)?e:l,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),C.timeout),g.send()},I.readystatechange=function(){var g=this.context,I=this.loader,C=this.stats;if(g&&I){var A=I.readyState,i=this.config;if(!C.aborted&&A>=2&&(0===C.loading.first&&(C.loading.first=Math.max(self.performance.now(),C.loading.start),i.timeout!==i.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),i.timeout=i.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),i.loadPolicy.maxLoadTimeMs-(C.loading.first-C.loading.start)))),4===A)){self.clearTimeout(this.requestTimeout),I.onreadystatechange=null,I.onprogress=null;var e=I.status,l="text"!==I.responseType;if(e>=200&&e<300&&(l&&I.response||null!==I.responseText)){C.loading.end=Math.max(self.performance.now(),C.loading.first);var t=l?I.response:I.responseText,s="arraybuffer"===I.responseType?t.byteLength:t.length;if(C.loaded=C.total=s,C.bwEstimate=8e3*C.total/(C.loading.end-C.loading.first),!this.callbacks)return;var c=this.callbacks.onProgress;if(c&&c(C,g,t,I),!this.callbacks)return;var d={url:I.responseURL,data:t,code:e};this.callbacks.onSuccess(d,C,g,I)}else{var o=i.loadPolicy.errorRetry;TI(o,C.retry,!1,e)?this.retry(o):(H.error(e+" while loading "+g.url),this.callbacks.onError({code:e,text:I.statusText},g,I,C))}}}},I.loadtimeout=function(){var g,I=null==(g=this.config)?void 0:g.loadPolicy.timeoutRetry;if(TI(I,this.stats.retry,!0))this.retry(I);else{H.warn("timeout while loading "+this.context.url);var C=this.callbacks;C&&(this.abortInternal(),C.onTimeout(this.stats,this.context,this.loader))}},I.retry=function(g){var I=this.context,C=this.stats;this.retryDelay=zI(g,C.retry),C.retry++,H.warn((status?"HTTP Status "+status:"Timeout")+" while loading "+I.url+", retrying "+C.retry+"/"+g.maxNumRetry+" in "+this.retryDelay+"ms"),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay)},I.loadprogress=function(g){var I=this.stats;I.loaded=g.loaded,g.lengthComputable&&(I.total=g.total)},I.getCacheAge=function(){var g=null;if(this.loader&&me.test(this.loader.getAllResponseHeaders())){var I=this.loader.getResponseHeader("age");g=I?parseFloat(I):null}return g},I.getResponseHeader=function(g){return this.loader&&new RegExp("^"+g+":\\s*[\\d.]+\\s*$","im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(g):null},g}(),Ge=/(\d+)-(\d+)\/(\d+)/,ue=function(){function g(g){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=void 0,this.response=void 0,this.controller=void 0,this.context=void 0,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=g.fetchSetup||Be,this.controller=new self.AbortController,this.stats=new f}var I=g.prototype;return I.destroy=function(){this.loader=this.callbacks=null,this.abortInternal()},I.abortInternal=function(){var g=this.response;null!=g&&g.ok||(this.stats.aborted=!0,this.controller.abort())},I.abort=function(){var g;this.abortInternal(),null!=(g=this.callbacks)&&g.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},I.load=function(g,I,C){var A=this,i=this.stats;if(i.loading.start)throw new Error("Loader can only be used once.");i.loading.start=self.performance.now();var e,l,s,c=(e=g,l=this.controller.signal,s={method:"GET",mode:"cors",credentials:"same-origin",signal:l,headers:new self.Headers(t({},e.headers))},e.rangeEnd&&s.headers.set("Range","bytes="+e.rangeStart+"-"+String(e.rangeEnd-1)),s),d=C.onProgress,o="arraybuffer"===g.responseType,n=o?"byteLength":"length",a=I.loadPolicy,Z=a.maxTimeToFirstByteMs,b=a.maxLoadTimeMs;this.context=g,this.config=I,this.callbacks=C,this.request=this.fetchSetup(g,c),self.clearTimeout(this.requestTimeout),I.timeout=Z&&W(Z)?Z:b,this.requestTimeout=self.setTimeout((function(){A.abortInternal(),C.onTimeout(i,g,A.response)}),I.timeout),self.fetch(this.request).then((function(e){A.response=A.loader=e;var l=Math.max(self.performance.now(),i.loading.start);if(self.clearTimeout(A.requestTimeout),I.timeout=b,A.requestTimeout=self.setTimeout((function(){A.abortInternal(),C.onTimeout(i,g,A.response)}),b-(l-i.loading.start)),!e.ok){var t=e.status,s=e.statusText;throw new we(s||"fetch, bad network response",t,e)}return i.loading.first=l,i.total=function(g){var I=g.get("Content-Range");if(I){var C=function(g){var I=Ge.exec(g);if(I)return parseInt(I[2])-parseInt(I[1])+1}(I);if(W(C))return C}var A=g.get("Content-Length");if(A)return parseInt(A)}(e.headers)||i.total,d&&W(I.highWaterMark)?A.loadProgressively(e,i,g,I.highWaterMark,d):o?e.arrayBuffer():"json"===g.responseType?e.json():e.text()})).then((function(e){var l=A.response;self.clearTimeout(A.requestTimeout),i.loading.end=Math.max(self.performance.now(),i.loading.first);var t=e[n];t&&(i.loaded=i.total=t);var s={url:l.url,data:e,code:l.status};d&&!W(I.highWaterMark)&&d(i,g,e,l),C.onSuccess(s,i,g,l)})).catch((function(I){if(self.clearTimeout(A.requestTimeout),!i.aborted){var e=I&&I.code||0,l=I?I.message:null;C.onError({code:e,text:l},g,I?I.details:null,i)}}))},I.getCacheAge=function(){var g=null;if(this.response){var I=this.response.headers.get("age");g=I?parseFloat(I):null}return g},I.getResponseHeader=function(g){return this.response?this.response.headers.get(g):null},I.loadProgressively=function(g,I,C,A,i){void 0===A&&(A=0);var e=new gi,l=g.body.getReader();return function t(){return l.read().then((function(l){if(l.done)return e.dataLength&&i(I,C,e.flush(),g),Promise.resolve(new ArrayBuffer(0));var s=l.value,c=s.length;return I.loaded+=c,c=A&&i(I,C,e.flush(),g)):i(I,C,s,g),t()})).catch((function(){return Promise.reject()}))}()},g}();function Be(g,I){return new self.Request(g.url,I)}var we=function(g){function I(I,C,A){var i;return(i=g.call(this,I)||this).code=void 0,i.details=void 0,i.code=C,i.details=A,i}return s(I,g),I}(n(Error)),We=/\s/,pe=A(A({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,maxBufferSize:6e7,maxBufferHole:.1,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:!0,workerPath:null,enableSoftwareAES:!0,startLevel:void 0,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:he,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:$A,bufferController:ni,capLevelController:le,errorController:EI,fpsController:te,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystems:{},drmSystemOptions:{},requestMediaKeySystemAccessFunc:Cg,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0,certLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null}},keyLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"},errorRetry:{maxNumRetry:8,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"}}},manifestLoadPolicy:{default:{maxTimeToFirstByteMs:1/0,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},playlistLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:2,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},fragLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:12e4,timeoutRetry:{maxNumRetry:4,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:6,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},steeringManifestLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3},{cueHandler:{newCue:function(g,I,C,A){for(var i,e,l,t,s,c=[],d=self.VTTCue||self.TextTrackCue,o=0;o=16?t--:t++;var Z=zi(s.trim()),b=Qi(I,C,Z);null!=g&&null!=(n=g.cues)&&n.getCueById(b)||((e=new d(I,C,Z)).id=b,e.line=o+1,e.align="left",e.position=10+Math.min(80,10*Math.floor(8*t/32)),c.push(e))}return g&&c.length&&(c.sort((function(g,I){return"auto"===g.line||"auto"===I.line?0:g.line>8&&I.line>8?I.line-g.line:g.line-I.line})),c.forEach((function(I){return uI(g,I)}))),c}},enableWebVTT:!0,enableIMSC1:!0,enableCEA708Captions:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}),{},{subtitleStreamController:ei,subtitleTrackController:ti,timelineController:ie,audioStreamController:Ii,audioTrackController:Ci,emeController:ce,cmcdController:ae,contentSteeringController:Ze});function Ve(g){return g&&"object"==typeof g?Array.isArray(g)?g.map(Ve):Object.keys(g).reduce((function(I,C){return I[C]=Ve(g[C]),I}),{}):g}var ye=function(){function g(I){void 0===I&&(I={}),this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new TA,this._autoLevelCapping=void 0,this._maxHdcpLevel=null,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this.url=null,N(I.debug||!1,"Hls instance");var C=this.config=function(g,I){if((I.liveSyncDurationCount||I.liveMaxLatencyDurationCount)&&(I.liveSyncDuration||I.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(void 0!==I.liveMaxLatencyDurationCount&&(void 0===I.liveSyncDurationCount||I.liveMaxLatencyDurationCount<=I.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(void 0!==I.liveMaxLatencyDuration&&(void 0===I.liveSyncDuration||I.liveMaxLatencyDuration<=I.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');var C=Ve(g),i=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return["manifest","level","frag"].forEach((function(g){var A=("level"===g?"playlist":g)+"LoadPolicy",e=void 0===I[A],l=[];i.forEach((function(i){var t=g+"Loading"+i,s=I[t];if(void 0!==s&&e){l.push(t);var c=C[A].default;switch(I[A]={default:c},i){case"TimeOut":c.maxLoadTimeMs=s,c.maxTimeToFirstByteMs=s;break;case"MaxRetry":c.errorRetry.maxNumRetry=s,c.timeoutRetry.maxNumRetry=s;break;case"RetryDelay":c.errorRetry.retryDelayMs=s,c.timeoutRetry.retryDelayMs=s;break;case"MaxRetryTimeout":c.errorRetry.maxRetryDelayMs=s,c.timeoutRetry.maxRetryDelayMs=s}}})),l.length&&H.warn('hls.js config: "'+l.join('", "')+'" setting(s) are deprecated, use "'+A+'": '+JSON.stringify(I[A]))})),A(A({},C),I)}(g.DefaultConfig,I);this.userConfig=I,this._autoLevelCapping=-1,C.progressive&&function(g){var I=g.loader;I!==ue&&I!==he?(H.log("[config]: Custom loader detected, cannot enable progressive streaming"),g.progressive=!1):function(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch(g){}return!1}()&&(g.loader=ue,g.progressive=!0,g.enableSoftwareAES=!0,H.log("[config]: Progressive streaming enabled, using FetchLoader"))}(C);var i=C.abrController,e=C.bufferController,l=C.capLevelController,t=C.errorController,s=C.fpsController,c=new t(this),d=this.abrController=new i(this),o=this.bufferController=new e(this),n=this.capLevelController=new l(this),a=new s(this),Z=new hI(this),b=new YI(this),r=C.contentSteeringController,m=r?new r(this):null,h=this.levelController=new _I(this,m),G=new iC(this),u=new nC(this.config),B=this.streamController=new PA(this,G,u);n.setStreamController(B),a.setStreamController(B);var w=[Z,h,B];m&&w.splice(1,0,m),this.networkControllers=w;var W=[d,o,n,a,b,G];this.audioTrackController=this.createController(C.audioTrackController,w);var V=C.audioStreamController;V&&w.push(new V(this,G,u)),this.subtitleTrackController=this.createController(C.subtitleTrackController,w);var y=C.subtitleStreamController;y&&w.push(new y(this,G,u)),this.createController(C.timelineController,W),u.emeController=this.emeController=this.createController(C.emeController,W),this.cmcdController=this.createController(C.cmcdController,W),this.latencyController=this.createController(RI,W),this.coreComponents=W,w.push(c);var X=c.onErrorOut;"function"==typeof X&&this.on(p.ERROR,X,c)}g.isSupported=function(){return function(){var g=Qg();if(!g)return!1;var I=kC(),C=g&&"function"==typeof g.isTypeSupported&&g.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),A=!I||I.prototype&&"function"==typeof I.prototype.appendBuffer&&"function"==typeof I.prototype.remove;return!!C&&!!A}()};var I=g.prototype;return I.createController=function(g,I){if(g){var C=new g(this);return I&&I.push(C),C}return null},I.on=function(g,I,C){void 0===C&&(C=this),this._emitter.on(g,I,C)},I.once=function(g,I,C){void 0===C&&(C=this),this._emitter.once(g,I,C)},I.removeAllListeners=function(g){this._emitter.removeAllListeners(g)},I.off=function(g,I,C,A){void 0===C&&(C=this),this._emitter.off(g,I,C,A)},I.listeners=function(g){return this._emitter.listeners(g)},I.emit=function(g,I,C){return this._emitter.emit(g,I,C)},I.trigger=function(g,I){if(this.config.debug)return this.emit(g,g,I);try{return this.emit(g,g,I)}catch(C){H.error("An internal error happened while handling event "+g+'. Error message: "'+C.message+'". Here is a stacktrace:',C),this.trigger(p.ERROR,{type:V.OTHER_ERROR,details:y.INTERNAL_EXCEPTION,fatal:!1,event:g,error:C})}return!1},I.listenerCount=function(g){return this._emitter.listenerCount(g)},I.destroy=function(){H.log("destroy"),this.trigger(p.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach((function(g){return g.destroy()})),this.networkControllers.length=0,this.coreComponents.forEach((function(g){return g.destroy()})),this.coreComponents.length=0;var g=this.config;g.xhrSetup=g.fetchSetup=void 0,this.userConfig=null},I.attachMedia=function(g){H.log("attachMedia"),this._media=g,this.trigger(p.MEDIA_ATTACHING,{media:g})},I.detachMedia=function(){H.log("detachMedia"),this.trigger(p.MEDIA_DETACHING,void 0),this._media=null},I.loadSource=function(g){this.stopLoad();var I=this.media,C=this.url,A=this.url=w.buildAbsoluteURL(self.location.href,g,{alwaysNormalize:!0});H.log("loadSource:"+A),I&&C&&(C!==A||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(I)),this.trigger(p.MANIFEST_LOADING,{url:g})},I.startLoad=function(g){void 0===g&&(g=-1),H.log("startLoad("+g+")"),this.networkControllers.forEach((function(I){I.startLoad(g)}))},I.stopLoad=function(){H.log("stopLoad"),this.networkControllers.forEach((function(g){g.stopLoad()}))},I.swapAudioCodec=function(){H.log("swapAudioCodec"),this.streamController.swapAudioCodec()},I.recoverMediaError=function(){H.log("recoverMediaError");var g=this._media;this.detachMedia(),g&&this.attachMedia(g)},I.removeLevel=function(g,I){void 0===I&&(I=0),this.levelController.removeLevel(g,I)},e(g,[{key:"levels",get:function(){return this.levelController.levels||[]}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(g){H.log("set currentLevel:"+g),this.loadLevel=g,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(g){H.log("set nextLevel:"+g),this.levelController.manualLevel=g,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(g){H.log("set loadLevel:"+g),this.levelController.manualLevel=g}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(g){this.levelController.nextLoadLevel=g}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(g){H.log("set firstLevel:"+g),this.levelController.firstLevel=g}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(g){H.log("set startLevel:"+g),-1!==g&&(g=Math.max(g,this.minAutoLevel)),this.levelController.startLevel=g}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(g){var I=!!g;I!==this.config.capLevelToPlayerSize&&(I?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=I)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(g){this._autoLevelCapping!==g&&(H.log("set autoLevelCapping:"+g),this._autoLevelCapping=g)}},{key:"bandwidthEstimate",get:function(){var g=this.abrController.bwEstimator;return g?g.getEstimate():NaN}},{key:"ttfbEstimate",get:function(){var g=this.abrController.bwEstimator;return g?g.getEstimateTTFB():NaN}},{key:"maxHdcpLevel",get:function(){return this._maxHdcpLevel},set:function(g){NI.indexOf(g)>-1&&(this._maxHdcpLevel=g)}},{key:"autoLevelEnabled",get:function(){return-1===this.levelController.manualLevel}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var g=this.levels,I=this.config.minAutoBitrate;if(!g)return 0;for(var C=g.length,A=0;A=I)return A;return 0}},{key:"maxAutoLevel",get:function(){var g,I=this.levels,C=this.autoLevelCapping,A=this.maxHdcpLevel;if(g=-1===C&&I&&I.length?I.length-1:C,A)for(var i=g;i--;){var e=I[i].attrs["HDCP-LEVEL"];if(e&&e<=A)return i}return g}},{key:"nextAutoLevel",get:function(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)},set:function(g){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,g)}},{key:"playingDate",get:function(){return this.streamController.currentProgramDateTime}},{key:"mainForwardBufferInfo",get:function(){return this.streamController.getMainFwdBufferInfo()}},{key:"audioTracks",get:function(){var g=this.audioTrackController;return g?g.audioTracks:[]}},{key:"audioTrack",get:function(){var g=this.audioTrackController;return g?g.audioTrack:-1},set:function(g){var I=this.audioTrackController;I&&(I.audioTrack=g)}},{key:"subtitleTracks",get:function(){var g=this.subtitleTrackController;return g?g.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var g=this.subtitleTrackController;return g?g.subtitleTrack:-1},set:function(g){var I=this.subtitleTrackController;I&&(I.subtitleTrack=g)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var g=this.subtitleTrackController;return!!g&&g.subtitleDisplay},set:function(g){var I=this.subtitleTrackController;I&&(I.subtitleDisplay=g)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(g){this.config.lowLatencyMode=g}},{key:"liveSyncPosition",get:function(){return this.latencyController.liveSyncPosition}},{key:"latency",get:function(){return this.latencyController.latency}},{key:"maxLatency",get:function(){return this.latencyController.maxLatency}},{key:"targetLatency",get:function(){return this.latencyController.targetLatency}},{key:"drift",get:function(){return this.latencyController.drift}},{key:"forceStartLoad",get:function(){return this.streamController.forceStartLoad}}],[{key:"version",get:function(){return"1.4.12"}},{key:"Events",get:function(){return p}},{key:"ErrorTypes",get:function(){return V}},{key:"ErrorDetails",get:function(){return y}},{key:"DefaultConfig",get:function(){return g.defaultConfig?g.defaultConfig:pe},set:function(I){g.defaultConfig=I}}]),g}();return ye.defaultConfig=void 0,ye},"object"==typeof g&&"undefined"!=typeof module?module.exports=i():"function"==typeof define&&define.amd?define(i):(A="undefined"!=typeof globalThis?globalThis:A||self).Hls=i()}(!1);!function(){if("undefined"==typeof document||customElements.get("r-option"))return R("document is undefined or r-option is exist");{class g extends HTMLElement{constructor(){super(),C(this,"_option"),C(this,"_optionContent"),C(this,"_shadowDom"),C(this,"_slot"),this._slot=document.createElement("slot"),this._option=document.createElement("div"),this._option.setAttribute("class","ran-option"),this._optionContent=document.createElement("div"),this._optionContent.setAttribute("class","ran-option-content"),this._optionContent.appendChild(this._slot),this._option.appendChild(this._optionContent);const g=this.attachShadow({mode:"closed"}),I=document.createElement("style");I.textContent='.remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}html.dark .r-preview-mask .r-preview-contain{background-color:#191919!important}@keyframes ranui-select-dropdown-down-in{0%{transform:scaleY(.8);transform-origin:100% 100%;opacity:0}to{transform:scaleY(1);transform-origin:100% 100%;opacity:1}}@keyframes ranui-select-dropdown-down-out{0%{transform:scaleY(1);transform-origin:100% 100%;opacity:1}to{transform:scaleY(.8);transform-origin:100% 100%;opacity:0}}@keyframes ranui-select-dropdown-up-in{0%{transform:scaleY(.8);transform-origin:0% 0%;opacity:0}to{transform:scaleY(1);transform-origin:0% 0%;opacity:1}}@keyframes ranui-select-dropdown-up-out{0%{transform:scaleY(1);transform-origin:0% 0%;opacity:1}to{transform:scaleY(.8);transform-origin:0% 0%;opacity:0}}.ran-select-dropdown-down-in{animation:ranui-select-dropdown-up-in .2s;animation-fill-mode:forwards}.ran-select-dropdown-down-out{animation:ranui-select-dropdown-up-out .2s;animation-fill-mode:forwards}.ran-select-dropdown-up-in{animation:ranui-select-dropdown-down-in .2s;animation-fill-mode:forwards}.ran-select-dropdown-up-out{animation:ranui-select-dropdown-down-out .2s;animation-fill-mode:forwards}.ranui-select-dropdown{position:absolute;transform-origin:var(--ran-x, 50%) var(--ran-y, 50%);box-sizing:border-box;margin:0;padding:4px;color:#000000e0;font-size:14px;list-style:none;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji";z-index:1050;overflow:hidden;font-variant:initial;background:#fff;border-radius:8px;outline:none;box-shadow:0 6px 16px #00000014,0 3px 6px -4px #0000001f,0 9px 28px 8px #0000000d;cursor:pointer}.ranui-select-dropdown-option-item{position:relative;display:block;padding:5px 12px;color:#000000e0;font-weight:400;font-size:14px;transition:background .3s ease;border-radius:4px}.ranui-select-dropdown-option-item:hover{background-color:#0000000a}.ranui-select-dropdown-option-item-content{overflow:hidden;white-space:nowrap;text-overflow:ellipsis;color:#000000e0;font-size:14px;line-height:1.57142857;box-sizing:border-box;list-style:none;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji";font-variant:initial}.ranui-select-dropdown-option-active{background-color:#e6f7ff;font-weight:700}.ranui-select-dropdown-option-active:hover{background-color:#e6f7ff}',g.appendChild(I),this._shadowDom=g,g.appendChild(this._option)}static get observedAttributes(){return["disabled","sheet","value"]}get value(){return this.getAttribute("value")}set value(g){this.setAttribute("value",g||"")}get sheet(){return this.getAttribute("sheet")}set sheet(g){this.setAttribute("sheet",g||"")}get disabled(){return Y(this)}set disabled(g){g&&"false"!==g?this.setAttribute("disabled",""):this.removeAttribute("disabled")}handlerExternalCss(){if(this.sheet)try{const g=new CSSStyleSheet;g.insertRule(this.sheet),this._shadowDom.adoptedStyleSheets=[g]}catch(g){console.error(`Failed to parse the rule in CSSStyleSheet: ${this.sheet}`)}}connectedCallback(){}disconnectCallback(){}attributeChangedCallback(g,I,C){"disabled"===g&&this._option&&(C&&"false"!==C?this._option.removeAttribute("disabled"):this._option.setAttribute("disabled","")),"sheet"===g&&this._shadowDom&&I!==C&&this.handlerExternalCss()}}}}();const ng={bottom:{add:"ran-select-dropdown-down-in",remove:"ran-select-dropdown-down-out"},top:{add:"ran-select-dropdown-up-in",remove:"ran-select-dropdown-up-out"}},ag=u();let Zg=class extends(N()){constructor(){super(),C(this,"removeTimeId"),C(this,"_slot"),C(this,"_shadowDom"),C(this,"_select"),C(this,"_selection"),C(this,"_search"),C(this,"_icon"),C(this,"_selectDropdown"),C(this,"_selectionDropdown"),C(this,"_selectDropDownInTimeId"),C(this,"_selectDropDownOutTimeId"),C(this,"_optionList"),C(this,"_optionLabelMapValue"),C(this,"_optionValueMapLabel"),C(this,"_activeOption"),C(this,"_text"),C(this,"_selector"),C(this,"onSearch"),C(this,"setSelectDropdownDisplayNone",(()=>{this._selectDropDownOutTimeId||this._selectionDropdown&&"none"!==this._selectionDropdown.style.display&&(m(this._selectionDropdown,ng[this.placement].remove),this._selectDropDownOutTimeId=setTimeout((()=>{var g;null==(g=this._selectionDropdown)||g.style.setProperty("display","none"),this._selectionDropdown&&h(this._selectionDropdown,ng[this.placement].remove),clearTimeout(this._selectDropDownOutTimeId),this._selectDropDownOutTimeId=void 0}),300))})),C(this,"setSelectDropdownDisplayBlock",(()=>{var g;this._selectDropDownInTimeId||this._selectionDropdown&&"block"!==this._selectionDropdown.style.display&&(m(this._selectionDropdown,ng[this.placement].add),null==(g=this._selectionDropdown)||g.style.setProperty("display","block"),this._selectDropDownInTimeId=setTimeout((()=>{this._selectionDropdown&&h(this._selectionDropdown,ng[this.placement].add),clearTimeout(this._selectDropDownInTimeId),this._selectDropDownInTimeId=void 0}),200))})),C(this,"placementPosition",(()=>{if(!this._selectionDropdown||!this._selectDropdown)return;const g=this.getBoundingClientRect(),{top:I,left:C,bottom:A,width:i,height:e,x:l,y:t,right:s}=g,c=document.getElementById(this.getPopupContainerId);this._selectionDropdown.style.setProperty("--ran-x",`${I+window.scrollX}`),this._selectionDropdown.style.setProperty("--ran-y",`${C+window.scrollY}`);let d=A+window.scrollY;const o=C+window.scrollX;this._selectionDropdown.style.setProperty("width",`${i}px`),"top"===this.placement&&(d=I+window.scrollY-this._selectionDropdown.clientHeight),this.getPopupContainerId&&c&&(d="top"===this.placement?I-c.getBoundingClientRect().top-this._selectionDropdown.clientHeight:c.getBoundingClientRect().height),this._selectionDropdown.style.setProperty("inset",`${d}px auto auto ${o}px`)})),C(this,"selectMouseDown",(g=>{g.stopPropagation(),Y(this)||(this.removeDropDownTimeId(),this.setSelectDropdownDisplayNone(),this.setSelectDropdownDisplayBlock(),this.placementPosition())})),C(this,"removeDropDownTimeId",(()=>{this._search.setAttribute("value",""),this.trigger.includes("hover")&&!d()&&(clearTimeout(this.removeTimeId),this.removeTimeId=void 0)})),C(this,"selectBlur",(()=>{this.removeTimeId&&this.removeDropDownTimeId(),this.removeTimeId=setTimeout((()=>{this.removeDropDownTimeId(),this.setSelectDropdownDisplayNone()}),100)})),C(this,"clickOption",(g=>{var I,C;g.stopPropagation();let A=g.target;if((null==(I=A.classList)?void 0:I.contains("ranui-select-dropdown-option-item"))&&(A=A.children[0]),!(null==(C=A.classList)?void 0:C.contains("ranui-select-dropdown-option-item-content")))return;const i=A.innerHTML,e=this._optionLabelMapValue.get(i);e&&(this.setAttribute("value",e),this._text.innerHTML=i,this._text.setAttribute("title",i),this._search.setAttribute("placeholder",i));const l=this.getBoundingClientRect(),{height:t}=l;this._text.style.setProperty("line-height",`${t}px`),this._activeOption&&h(this._activeOption,"ranui-select-dropdown-option-active"),setTimeout((()=>{this._activeOption=(null==A?void 0:A.parentElement)||void 0,this._activeOption&&m(this._activeOption,"ranui-select-dropdown-option-active")}),200),this.setSelectDropdownDisplayNone(),this.dispatchEvent(new CustomEvent("change",{detail:{value:e,label:i}})),this.removeDropDownTimeId()})),C(this,"createOption",(()=>{if(!this._selectDropdown){const g=document.getElementById(this.getPopupContainerId)||document.body;this._selectDropdown=document.createElement("div"),this._selectDropdown.style.setProperty("-webkit-tap-highlight-color","transparent"),this._selectDropdown.style.setProperty("outline","0"),this._selectDropdown.addEventListener("click",this.clickOption),this._selectionDropdown=document.createElement("div"),this._selectionDropdown.style.setProperty("-webkit-tap-highlight-color","transparent"),this._selectionDropdown.style.setProperty("outline","0"),this.dropdownclass?this._selectionDropdown.setAttribute("class",`${this.dropdownclass} ranui-select-dropdown`):this._selectionDropdown.setAttribute("class","ranui-select-dropdown"),this.trigger.includes("hover")&&!d()&&(this._selectDropdown.addEventListener("mouseleave",this.selectBlur),this._selectDropdown.addEventListener("mouseenter",this.removeDropDownTimeId)),this._selectDropdown.appendChild(this._selectionDropdown),this._selectionDropdown.style.setProperty("display","none"),g.appendChild(this._selectDropdown)}})),C(this,"removeSelectDropdown",(()=>{try{if(this._selectDropdown){(document.getElementById(this.getPopupContainerId)||document.body).removeChild(this._selectDropdown)}}catch(g){}})),C(this,"addOptionToSlot",(()=>{this._slot.assignedElements().forEach((g=>{var I;if("R-OPTION"!==g.tagName)return;const C=g.innerHTML,A=g.getAttribute("value")||"";null==(I=this._optionList)||I.push({label:C,value:A}),this._optionLabelMapValue.get(C)&&console.warn(`${C} is repeat option`),this._optionValueMapLabel.get(A)&&console.warn(`${A} is repeat option`),this._optionLabelMapValue.set(C,A),this._optionValueMapLabel.set(A,C)})),this.createSelectDropdownContent(this._optionList)})),C(this,"createSelectDropdownContent",((g=[])=>{var I,C;0===g.length?null==(I=this._selectDropdown)||I.style.setProperty("display","none"):null==(C=this._selectDropdown)||C.style.setProperty("display","block"),g.forEach((g=>{if(this._selectionDropdown){const{label:I,value:C}=g,A=document.createElement("div");(this.getAttribute("defaultValue")||this.getAttribute("value"))===C?(A.setAttribute("class","ranui-select-dropdown-option-active ranui-select-dropdown-option-item"),this._activeOption=A):A.setAttribute("class","ranui-select-dropdown-option-item");const i=document.createElement("div");i.setAttribute("class","ranui-select-dropdown-option-item-content"),i.innerHTML=`${I}`,i.setAttribute("value",`${C}`),i.setAttribute("title",`${I}`),A.appendChild(i),this._selectionDropdown.appendChild(A)}})),this.setDefaultValue()})),C(this,"setDefaultValue",(()=>{const g=this.getAttribute("defaultValue")||this.getAttribute("value");if(!g)return;const I=this._optionValueMapLabel.get(g);if(!I)return;this.setAttribute("value",g);const C=this.getBoundingClientRect(),{height:A}=C;this._text.style.setProperty("line-height",`${A}px`),this._text.innerHTML=I,this._text.setAttribute("title",I)})),C(this,"changeSearch",(g=>{const I=g.detail.value||"";if(this.dispatchEvent(new CustomEvent("search",{detail:{value:I}})),this._selectionDropdown&&(this._selectionDropdown.innerHTML=""),I.length>0){const g=this._optionList.map((g=>{const{label:C}=g;if(`${C}`.toLowerCase().includes(I))return{label:C,value:g.value}})).filter((g=>g));this.createSelectDropdownContent(g)}else this.createSelectDropdownContent(this._optionList)})),C(this,"setShowSearch",(()=>{this.onSearch=ag(this.changeSearch),this.onSearch&&this._search.addEventListener("change",this.onSearch),this.onSearch&&this._search.addEventListener("click",this.onSearch)})),C(this,"removeShowSearch",(()=>{this.onSearch&&this._search.removeEventListener("change",this.onSearch),this.onSearch&&this._search.removeEventListener("click",this.onSearch)})),C(this,"listenSlotChange",(()=>{this._slot.addEventListener("slotchange",this.addOptionToSlot)})),C(this,"removeListenSlotChange",(()=>{this._slot.removeEventListener("slotchange",this.addOptionToSlot)})),C(this,"listenActionEvent",(()=>{this.removeEventListener("mouseenter",this.selectMouseDown),this.removeEventListener("mouseleave",this.selectBlur),this.removeEventListener("click",this.selectMouseDown),this.removeEventListener("blur",this.selectBlur),this.trigger.includes("hover")&&!d()&&(this.addEventListener("mouseenter",this.selectMouseDown),this.addEventListener("mouseleave",this.selectBlur)),this.trigger.includes("click")&&(this.addEventListener("click",this.selectMouseDown),this.addEventListener("blur",this.selectBlur))})),C(this,"clickRemoveSelect",(g=>{g.stopPropagation(),this.setSelectDropdownDisplayNone()})),this._slot=document.createElement("slot"),this._select=document.createElement("div"),this._select.setAttribute("class","ran-select"),this._select.setAttribute("part","select"),this._selection=document.createElement("div"),this._selection.setAttribute("class","selection"),this._selection.setAttribute("part","selection"),this._selector=document.createElement("div"),this._search=document.createElement("r-input"),this._search.setAttribute("class","selection-search"),this._search.setAttribute("part","search"),this._search.setAttribute("type","search"),this._search.setAttribute("autocomplete","off"),this._text=document.createElement("span"),this._text.setAttribute("class","selection-item"),this._text.setAttribute("part","selection-item"),this._icon=document.createElement("ra-icon"),this._icon.setAttribute("class","icon"),this._icon.setAttribute("part","icon"),this._icon.setAttribute("name","arrow-down"),this._icon.setAttribute("color","#d9d9d9"),this._icon.setAttribute("size","16"),this._selector.appendChild(this._text),this._selector.appendChild(this._search),this._selection.appendChild(this._icon),this._selection.appendChild(this._selector),this._slot.setAttribute("class","slot"),this._select.appendChild(this._selection),this._select.appendChild(this._slot),this._optionList=[],this._optionLabelMapValue=new Map,this._optionValueMapLabel=new Map;const g=this.attachShadow({mode:"closed"}),I=document.createElement("style");I.textContent='.remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}html.dark .r-preview-mask .r-preview-contain{background-color:#191919!important}r-select{position:relative;width:120px;height:40px}:host{position:relative;display:inline-block;cursor:pointer;height:32px;outline:0;-webkit-tap-highlight-color:transparent}:host,:host(:focus),:host(:active){outline:0;-webkit-tap-highlight-color:transparent}:host ::slotted(r-option){display:none}:host([disabled]){cursor:not-allowed;pointer-events:all;opacity:.6}:host([type="text"])::part(selection){border:none}:host([type="text"])::part(icon){display:none}:host(:not([disabled]):hover) .select{cursor:pointer}:host(:not([disabled]):hover) .selection{border:1px solid #1890ff}:host(:not([disabled]):hover) .selection-search{cursor:pointer}:host(:not([disabled]):hover) .selection-item{cursor:pointer;color:#bfbfbf}:host(:not([disabled]):focus) .selection{border:1px solid #1890ff}:host(:not([disabled]):focus) .selection-search{cursor:pointer}:host(:not([disabled]):focus) .selection-item{cursor:pointer;color:#bfbfbf}:host .selection-search{display:none}:host([showSearch]:not([disabled])) .selection-search{cursor:text;display:block}:host([showSearch]:not([disabled])) .selection-item{cursor:pointer}:host([showSearch]:not([disabled]):focus) .selection-search{display:block;cursor:text;opacity:1}.ran-select{width:100%;height:100%;box-sizing:border-box;margin:0;padding:0;color:#000000e0;font-size:14px;line-height:1.57142857;list-style:none;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji";position:relative;display:inline-block}.ran-select .selection{position:relative;background-color:#fff;border:1px solid #d9d9d9;transition:all .2s cubic-bezier(.645,.045,.355,1);width:100%;height:100%;padding:0 11px;box-sizing:border-box;margin:0;color:#000000e0;font-size:14px;line-height:1.57142857;list-style:none;font-family:inherit;display:flex;border-radius:6px}.ran-select .selection-search{position:absolute;top:0;left:0;height:100%;inset-inline-start:11px;inset-inline-end:11px;opacity:0;margin:0;padding:0;background:transparent;border:none;outline:none;-webkit-appearance:none;-moz-appearance:none;appearance:none;font-family:inherit;cursor:not-allowed}.ran-select .selection-search::-webkit-search-cancel-button{display:none;-webkit-appearance:none}.ran-select .selection-search::part(ran-input){border:none;padding:0;height:100%;outline:none}.ran-select .selection-search::part(ran-input):active{border:none;padding:0;height:100%;outline:none;border-color:transparent;box-shadow:none;border-right-width:0px}.ran-select .selection-item{position:absolute;top:0;left:12px;margin:0;padding:0;background:transparent;border:none;outline:none;-webkit-appearance:none;-moz-appearance:none;appearance:none;font-family:inherit;height:100%;-webkit-user-select:none;user-select:none;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;cursor:pointer}.ran-select .selection-select{color:#00000040}.ran-select .selection .icon{display:flex;align-items:center;color:#00000040;font-style:normal;text-align:center;text-transform:none;text-rendering:optimizeLegibility;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;position:absolute;top:50%;inset-inline-start:auto;inset-inline-end:8px;height:12px;margin-top:-3px;font-size:12px;pointer-events:none}',g.appendChild(I),this._shadowDom=g,this._shadowDom.appendChild(this._select)}static get observedAttributes(){return["disabled","sheet","clear","type","defaultValue","showSearch","placement","getPopupContainerId","dropdownclass","trigger"]}get value(){return this.getAttribute("value")||""}set value(g){!Y(this)&&g?this.setAttribute("value",g):this.removeAttribute("value")}get defaultValue(){return this.getAttribute("defaultValue")||""}set defaultValue(g){this.setAttribute("defaultValue",g||"")}get showSearch(){return this.getAttribute("showSearch")||""}set showSearch(g){this.setAttribute("showSearch",g||"")}get type(){return this.getAttribute("type")||""}set type(g){this.setAttribute("type",g||"")}get placement(){return this.getAttribute("placement")||"bottom"}set placement(g){this.setAttribute("placement",g||"")}get sheet(){return this.getAttribute("sheet")||""}set sheet(g){this.setAttribute("sheet",g||"")}get getPopupContainerId(){return this.getAttribute("getPopupContainerId")||""}set getPopupContainerId(g){this.setAttribute("getPopupContainerId",g||"")}get dropdownclass(){return this.getAttribute("dropdownclass")||""}set dropdownclass(g){this.setAttribute("dropdownclass",g||"")}get trigger(){return this.getAttribute("trigger")||"click"}set trigger(g){this.setAttribute("trigger",g||"")}get disabled(){return Y(this)}set disabled(g){g&&"false"!==g?(this.setAttribute("disabled",""),this._selection.setAttribute("disabled","")):(this.removeAttribute("disabled"),this._selection.removeAttribute("disabled"))}handlerExternalCss(){if(this.sheet)try{const g=new CSSStyleSheet;g.insertRule(this.sheet),this._shadowDom.adoptedStyleSheets=[g]}catch(g){console.error(`Failed to parse the rule in CSSStyleSheet: ${this.sheet}`)}}connectedCallback(){this.handlerExternalCss(),this.createOption(),this.listenActionEvent(),this.listenSlotChange(),this.setShowSearch(),document.addEventListener("click",this.clickRemoveSelect)}disconnectCallback(){var g;this.removeEventListener("mouseenter",this.selectMouseDown),this.removeEventListener("mouseleave",this.selectBlur),this.removeEventListener("click",this.selectMouseDown),this.removeEventListener("blur",this.selectBlur),this.removeSelectDropdown(),null==(g=this._selectDropdown)||g.removeEventListener("click",this.clickOption),this.removeListenSlotChange(),document.removeEventListener("click",this.clickRemoveSelect)}attributeChangedCallback(g,I,C){"disabled"===g&&this._select&&(C&&"false"!==C?(this._select.removeAttribute("disabled"),this._selection.removeAttribute("disabled")):(this._select.setAttribute("disabled",""),this._selection.setAttribute("disabled",""))),"sheet"===g&&this._shadowDom&&I!==C&&this.handlerExternalCss()}};const bg="undefined"==typeof document||customElements.get("r-select")?R("document is undefined or r-select is exist"):(customElements.define("r-select",Zg),Zg),rg=Object.freeze(Object.defineProperty({__proto__:null,Select:Zg,default:bg},Symbol.toStringTag,{value:"Module"})),mg=["play","playing","timeupdate"],hg=u(),Gg=[{label:"2.0X",value:2},{label:"1.5X",value:1.5},{label:"1.0X",value:1},{label:"0.8X",value:.8},{label:"0.5X",value:.5}];class ug extends(N()){constructor(){super(),C(this,"ctx"),C(this,"_player"),C(this,"_container"),C(this,"_slot"),C(this,"_playerController"),C(this,"_playerBtn"),C(this,"_progress"),C(this,"_progressDot"),C(this,"_progressWrap"),C(this,"_progressWrapValue"),C(this,"requestAnimationFrameId"),C(this,"moveProgress"),C(this,"_playerControllerBottom"),C(this,"_playerControllerBottomRight"),C(this,"_playerControllerBottomLeft"),C(this,"_playerControllerBottomPlayBtn"),C(this,"_playerControllerBottomTimeCurrent"),C(this,"_playerControllerBottomTimeDuration"),C(this,"_playerControllerBottomTimeDivide"),C(this,"_playControllerBottomClarity"),C(this,"_playControllerBottomSpeed"),C(this,"_playControllerBottomSpeedIcon"),C(this,"_playControllerBottomVolumeProgress"),C(this,"_playControllerBottomRightFullScreen"),C(this,"_playControllerBottomVolume"),C(this,"_playControllerBottomSpeedPopover"),C(this,"controllerBarTimeId"),C(this,"_playerTip"),C(this,"_playerTipTime"),C(this,"_playerTipText"),C(this,"_volume"),C(this,"_video"),C(this,"_hls"),C(this,"changeClarityToSetVideo",(()=>{const{currentTime:g,playbackRate:I,volume:C,currentState:A}=this.ctx;this.setCurrentTime(g),this.setPlaybackRate(I),this.setVolume(C),mg.includes(A)?this.play():this.pause()})),C(this,"changeClarity",(g=>{this.ctx.clarity=g.detail.value;const I=this.ctx.levelMap.get(g.detail.value);I&&this._hls&&(this._hls.loadSource(I),this._hls.startLoad(),this.changeClarityToSetVideo())})),C(this,"createClaritySelect",(()=>{const{levels:g,url:I}=this.ctx;if(this._playControllerBottomClarity.innerHTML="",g.length<=0)return;const C=document.createDocumentFragment();g.forEach((g=>{const{name:I,url:A}=g;if(!I||!A)return;this.ctx.levelMap.set(I,A);const i=document.createElement("r-option");i.setAttribute("value",I),i.innerHTML=I,C.appendChild(i)}));const A=document.createElement("r-select");A.setAttribute("value",this.ctx.clarity||"Auto"),A.appendChild(C),A.setAttribute("type","text"),A.setAttribute("trigger","hover,click"),A.setAttribute("placement","top");const i=this._player.getAttribute("id");i&&A.setAttribute("getPopupContainerId",i),A.setAttribute("dropdownclass","video-clarity-dropdown"),A.addEventListener("change",this.changeClarity),this._playControllerBottomClarity.appendChild(A)})),C(this,"manifestLoaded",((g,I)=>{if("hlsManifestLoaded"===g){const{url:g,levels:C=[]}=I;if(C.length<=0)return;C.forEach((g=>{this.ctx.levelMap.get(g.name)!==g.url&&this.ctx.levels.push(g)})),this.ctx.levelMap.get("Auto")||(this.ctx.levels.push({name:"Auto",url:g}),this.ctx.levelMap.set("Auto",g)),this.ctx.url=g,this.createClaritySelect(),this.change("hlsManifestLoaded",{data:I})}})),C(this,"updatePlayer",(()=>{var g;const{Hls:I}=window;this.innerHTML="",this.contains(this._player)||this.appendChild(this._player),this._hls&&(this._hls.destroy(),this._hls=void 0),this._video=document.createElement("video"),this._video.setAttribute("class","ran-player-video"),this._video.setAttribute("preload","auto"),this._video.setAttribute("x5-video-player-type","h5"),this._video.setAttribute("x5-video-orientation","portrait"),this._video.setAttribute("webkit-playsinline","true"),this._video.setAttribute("playsinline","true"),this._video.setAttribute("controls","false"),this._video.controls=!1,this._video.setAttribute("initial-time","0.01");try{this._video.canPlayType("application/vnd.apple.mpegurl")&&this.src?this._video.src=this.src:(null==I?void 0:I.isSupported())&&this.src&&(this._hls=new I,this._hls&&(this._hls.off(I.Events.MANIFEST_LOADED,this.manifestLoaded),this._hls.on(I.Events.MANIFEST_LOADED,this.manifestLoaded),this._hls.off(I.Events.ERROR,this.hlsError),this._hls.on(I.Events.ERROR,this.hlsError),this._hls.loadSource(this.src),this._hls.attachMedia(this._video)),this._container.appendChild(this._video),null==(g=this._video.parentElement)||g.setAttribute("class","ran-player-contain")),this.listenEvent()}catch(C){}})),C(this,"hlsError",((g,I)=>{this.change("hlsError",{event:g,data:I}),this._video&&(this._video.src=this.src)})),C(this,"change",((g,I)=>{const C=this.getCurrentTime(),A=this.getTotalTime();this.debug&&console.log(g,I),this.dispatchEvent(new CustomEvent("change",{detail:{type:g,data:I,currentTime:C,duration:A,tag:this}}))})),C(this,"onCanplay",(g=>{this.ctx.currentState=g.type,h(this._playerControllerBottomPlayBtn,"ran-player-controller-bottom-left-btn-pause"),m(this._playerControllerBottomPlayBtn,"ran-player-controller-bottom-left-btn-play"),this.change("canplay",g),this.resize()})),C(this,"onCanplaythrough",(g=>{this.ctx.currentState=g.type,this.change("canplaythrough",g)})),C(this,"onComplete",(g=>{this.ctx.currentState=g.type,this.change("complete",g)})),C(this,"onDurationchange",(g=>{this.ctx.currentState=g.type,this.change("durationchange",g)})),C(this,"onEmptied",(g=>{this.ctx.currentState=g.type,this.change("emptied",g)})),C(this,"onEnded",(g=>{this.ctx.currentState=g.type,this.change("ended",g)})),C(this,"onError",(g=>{this.ctx.currentState=g.type,this.change("error",g)})),C(this,"onLoadedmetadata",(g=>{this.ctx.currentState=g.type,this.change("loadedmetadata",g)})),C(this,"onLoadstart",(g=>{this.ctx.currentState=g.type,this.change("loadstart",g)})),C(this,"onProgress",(g=>{this.ctx.currentState=g.type,this.change("progress",g)})),C(this,"onRatechange",(g=>{this.ctx.currentState=g.type,this.change("ratechange",g)})),C(this,"onSeeked",(g=>{this.ctx.currentState=g.type,this.change("seeked",g)})),C(this,"onSeeking",(g=>{this.ctx.currentState=g.type,this.change("seeking",g)})),C(this,"onStalled",(g=>{this.ctx.currentState=g.type,this.change("stalled",g)})),C(this,"onSuspend",(g=>{this.ctx.currentState=g.type,this.change("suspend",g)})),C(this,"onLoadeddata",(g=>{this.ctx.currentState=g.type;const I=this.getTotalTime();this.ctx.duration=I,this._playerControllerBottomTimeCurrent.innerText="00:00",this._playerControllerBottomTimeDivide.innerText="/",this._playerControllerBottomTimeDuration.innerText=b(this.ctx.duration),this.change("loadeddata",g)})),C(this,"onTimeupdate",(g=>{this.ctx.currentState=g.type,this.change("timeupdate",g)})),C(this,"onVolumechange",(g=>{this.ctx.currentState=g.type,this.change("volumechange",g)})),C(this,"onWaiting",(g=>{this.ctx.currentState=g.type,this.change("waiting",g)})),C(this,"onPlay",(g=>{this.ctx.currentState=g.type,this.requestAnimationFrame(this.updateCurrentProgress),h(this._playerControllerBottomPlayBtn,"ran-player-controller-bottom-left-btn-play"),m(this._playerControllerBottomPlayBtn,"ran-player-controller-bottom-left-btn-pause"),this.showControllerBar(),this.change("play",g)})),C(this,"onPlaying",(g=>{this.ctx.currentState=g.type,this._playerBtn.style.setProperty("display","none"),h(this._playerControllerBottomPlayBtn,"ran-player-controller-bottom-left-btn-play"),m(this._playerControllerBottomPlayBtn,"ran-player-controller-bottom-left-btn-pause"),this.requestAnimationFrame(this.updateCurrentProgress),this.showControllerBar(),this.change("playing",g)})),C(this,"onPause",(g=>{this.ctx.currentState=g.type,this._playerBtn.style.setProperty("display","block"),this.change("pause",g),h(this._playerControllerBottomPlayBtn,"ran-player-controller-bottom-left-btn-pause"),m(this._playerControllerBottomPlayBtn,"ran-player-controller-bottom-left-btn-play"),this.cancelAnimationFrame(),this._playerController.style.setProperty("opacity","1"),this.controllerBarTimeId&&(clearTimeout(this.controllerBarTimeId),this.controllerBarTimeId=void 0)})),C(this,"clearListenerEvent",(()=>{this._video&&(this._video.removeEventListener("canplay",this.onCanplay),this._video.removeEventListener("canplaythrough",this.onCanplaythrough),this._video.removeEventListener("complete",this.onComplete),this._video.removeEventListener("durationchange",this.onDurationchange),this._video.removeEventListener("emptied",this.onEmptied),this._video.removeEventListener("ended",this.onEnded),this._video.removeEventListener("error",this.onError),this._video.removeEventListener("loadeddata",this.onLoadeddata),this._video.removeEventListener("loadedmetadata",this.onLoadedmetadata),this._video.removeEventListener("loadstart",this.onLoadstart),this._video.removeEventListener("pause",this.onPause),this._video.removeEventListener("play",this.onPlay),this._video.removeEventListener("playing",this.onPlaying),this._video.removeEventListener("progress",this.onProgress),this._video.removeEventListener("ratechange",this.onRatechange),this._video.removeEventListener("seeked",this.onSeeked),this._video.removeEventListener("seeking",this.onSeeking),this._video.removeEventListener("stalled",this.onStalled),this._video.removeEventListener("suspend",this.onSuspend),this._video.removeEventListener("timeupdate",this.onTimeupdate),this._video.removeEventListener("volumechange",this.onVolumechange),this._video.removeEventListener("waiting",this.onWaiting))})),C(this,"listenEvent",(()=>{this._video&&(this.clearListenerEvent(),this._video.addEventListener("canplay",this.onCanplay),this._video.addEventListener("canplaythrough",this.onCanplaythrough),this._video.addEventListener("complete",this.onComplete),this._video.addEventListener("durationchange",this.onDurationchange),this._video.addEventListener("emptied",this.onEmptied),this._video.addEventListener("ended",this.onEnded),this._video.addEventListener("error",this.onError),this._video.addEventListener("loadeddata",this.onLoadeddata),this._video.addEventListener("loadedmetadata",this.onLoadedmetadata),this._video.addEventListener("loadstart",this.onLoadstart),this._video.addEventListener("pause",this.onPause),this._video.addEventListener("play",this.onPlay),this._video.addEventListener("playing",this.onPlaying),this._video.addEventListener("progress",this.onProgress),this._video.addEventListener("ratechange",this.onRatechange),this._video.addEventListener("seeked",this.onSeeked),this._video.addEventListener("seeking",this.onSeeking),this._video.addEventListener("stalled",this.onStalled),this._video.addEventListener("suspend",this.onSuspend),this._video.addEventListener("timeupdate",this.onTimeupdate),this._video.addEventListener("volumechange",this.onVolumechange),this._video.addEventListener("waiting",this.onWaiting))})),C(this,"showControllerBar",(g=>{if(g){if(g.target.classList.value.includes("ran-player-controller"))return this._playerController.style.setProperty("opacity","1"),void(this.controllerBarTimeId&&(clearTimeout(this.controllerBarTimeId),this.controllerBarTimeId=void 0))}mg.includes(this.ctx.currentState)?(this._playerController.style.setProperty("opacity","1"),this.controllerBarTimeId&&(clearTimeout(this.controllerBarTimeId),this.controllerBarTimeId=void 0),this.controllerBarTimeId=setTimeout((()=>{this._playerController.style.setProperty("opacity","0"),clearTimeout(this.controllerBarTimeId),this.controllerBarTimeId=void 0}),2e3)):(this._playerController.style.setProperty("opacity","1"),this.controllerBarTimeId&&(clearTimeout(this.controllerBarTimeId),this.controllerBarTimeId=void 0))})),C(this,"progressClick",(g=>{const I=this._progressWrap.getBoundingClientRect(),C=g.clientX-I.left,A=W(C/this._progress.offsetWidth);this.setCurrentTime(this.ctx.duration*A),this.updateCurrentProgress()})),C(this,"progressDotMouseDown",(g=>{this._playerBtn.style.setProperty("display","none"),this.moveProgress.mouseDown=!0,this.cancelAnimationFrame()})),C(this,"progressDotMouseMove",(g=>{if(this.showControllerBar(g),!this.moveProgress.mouseDown)return;const I=this._progress.getBoundingClientRect(),C=g.clientX-I.left-9,A=W(C/this._progress.offsetWidth);this._progressWrapValue.style.setProperty("transform",`scaleX(${A})`),this._progressDot.style.setProperty("transform",`translateX(${A*this._progress.offsetWidth}px)`),this.moveProgress.percentage=Math.floor(100*A)/100})),C(this,"progressDotMouseUp",(()=>{if(!this.moveProgress.mouseDown)return;const g=this.moveProgress.percentage;this.setCurrentTime(this.ctx.duration*g),this.play(),this.moveProgress.mouseDown=!1,this.requestAnimationFrame(this.updateCurrentProgress)})),C(this,"requestAnimationFrame",(g=>{this.requestAnimationFrameId||(this.requestAnimationFrameId=window.requestAnimationFrame((()=>{g(),this.requestAnimationFrameId&&cancelAnimationFrame(this.requestAnimationFrameId),this.requestAnimationFrameId=void 0,this.requestAnimationFrame(g)})))})),C(this,"cancelAnimationFrame",(()=>{this.requestAnimationFrameId&&(cancelAnimationFrame(this.requestAnimationFrameId),this.requestAnimationFrameId=void 0)})),C(this,"updateCurrentProgress",(()=>{const g=this.getCurrentTime();this.ctx.currentTime=g;const{duration:I}=this.ctx;this._progressWrapValue.style.setProperty("transform",`scaleX(${g/I})`),this._progressDot.style.setProperty("transform",`translateX(${g/I*this._progress.offsetWidth}px)`),g>=0&&(this._playerControllerBottomTimeCurrent.innerText=b(g))})),C(this,"changeAttribute",((g,I,C,A,i)=>{g===A&&I!==C&&hg(i)()})),C(this,"dispatchClickPlayerContainerAction",(g=>{g.stopPropagation(),g.preventDefault(),mg.includes(this.ctx.currentState)?(this.pause(),this._playerBtn.style.setProperty("display","block")):(this.play(),this._playerBtn.style.setProperty("display","none"))})),C(this,"SpaceKeyDown",(g=>{const{currentTime:I,duration:C}=this.ctx;if("Space"===g.code&&this.dispatchClickPlayerBtnAction(g),"Escape"===g.code&&this.customExitFullscreen().then((()=>{this.ctx.fullScreen=!1})).catch((g=>{})),"ArrowLeft"===g.code){const g=W(I-5,0,C);this.setCurrentTime(g),this.play()}if("ArrowRight"===g.code){const g=W(I+5,0,C);this.setCurrentTime(g),this.play()}})),C(this,"dispatchClickPlayerBtnAction",(g=>{g.stopPropagation(),g.preventDefault(),mg.includes(this.ctx.currentState)?(this.pause(),this._playerBtn.style.setProperty("display","block")):(this.play(),this._playerBtn.style.setProperty("display","none"))})),C(this,"changeVolumeProgress",(g=>{this._video&&(this.setVolume(g.detail.value),this.change("volume",g.detail.value),g.detail.value>0&&(this._volume=g.detail.value))})),C(this,"customRequestFullscreen",(g=>this._player.requestFullscreen()||this._player.mozRequestFullScreen()||this._player.msRequestFullscreen()||this._player.oRequestFullscreen()||this._player.webkitRequestFullscreen()||this._player.webkitEnterFullscreen())),C(this,"customExitFullscreen",(()=>document.exitFullscreen()||document.msExitFullscreen()||document.mozCancelFullScreen()||document.oCancelFullScreen()||document.webkitExitFullscreen())),C(this,"openFullScreen",(()=>{this.ctx.fullScreen?this.customExitFullscreen().then((()=>{this.resize(),this.ctx.fullScreen=!1})).catch((g=>{})):this.customRequestFullscreen().then((()=>{this.resize(),this.ctx.fullScreen=!0})).catch((g=>{}))})),C(this,"changeSpeed",(g=>{this.change("speed",g.detail.value),this.setPlaybackRate(g.detail.value)})),C(this,"progressMouseEnter",(g=>{this._playerTip.style.setProperty("opacity","1");const I=this._progress.getBoundingClientRect(),C=g.clientX-I.left;this._playerTipText.innerText?this._playerTip.style.setProperty("transform",`translate(calc(${C}px - 50%),-20px)`):this._playerTip.style.setProperty("transform",`translateX(calc(${C}px - 50%))`),this._playerTipTime.innerText=b(C/this._progress.clientWidth*this.ctx.duration)})),C(this,"progressMouseLeave",(g=>{g.target.classList.contains("ran-player-controller-progress-wrap-dot")||this._playerTip.style.setProperty("opacity","0")})),C(this,"progressMouseMove",(g=>{const I=this._progress.getBoundingClientRect();this._playerTip.style.setProperty("opacity","1");const C=g.clientX-I.left;this._playerTipText.innerText?this._playerTip.style.setProperty("transform",`translate(calc(${C}px - 50%),-20px)`):this._playerTip.style.setProperty("transform",`translateX(calc(${C}px - 50%))`),this._playerTipTime.innerText=b(C/this._progress.clientWidth*this.ctx.duration)})),C(this,"changePlayerVolume",(()=>{if(!this._video)return;const{volume:g}=this.ctx;g>0?(m(this._playControllerBottomSpeedIcon,"ran-player-controller-bottom-right-volume-icon-mute"),h(this._playControllerBottomSpeedIcon,"ran-player-controller-bottom-right-volume-icon-volume"),this._playControllerBottomVolumeProgress.setAttribute("percent","0"),this.setVolume(0),this.change("volume",0)):(m(this._playControllerBottomSpeedIcon,"ran-player-controller-bottom-right-volume-icon-volume"),h(this._playControllerBottomSpeedIcon,"ran-player-controller-bottom-right-volume-icon-mute"),this._playControllerBottomVolumeProgress.setAttribute("percent",`${this._volume||.5}`),this.setVolume(.5),this.change("volume",this._volume||.5))})),C(this,"resize",(()=>{if(this._video){const{width:g,height:I}=this._player.getBoundingClientRect();this._video.style.setProperty("width",`${g}px`),this._video.style.setProperty("height",`${I}px`),document.body.clientWidth<500?this._playControllerBottomVolume.style.setProperty("display","none"):this._playControllerBottomVolume.style.setProperty("display","flex")}this.updateCurrentProgress()})),C(this,"fullScreenChange",(()=>{var g;(null==(g=document.fullscreenElement)?void 0:g.classList.contains("ran-player"))?(this.change("fullscreen",!0),this.ctx.fullScreen=!0):(this.change("fullscreen",!1),this.ctx.fullScreen=!1)})),C(this,"getPlaybackRate",(()=>(this._video&&(this.ctx.playbackRate=this._video.playbackRate||0),this.ctx.playbackRate))),C(this,"setPlaybackRate",(g=>(this._video&&(this.ctx.playbackRate=g,this._video.playbackRate=g),this.ctx.playbackRate))),C(this,"setVolume",(g=>(this._video&&(this.ctx.volume=g,this._video.volume=g),this.ctx.volume))),C(this,"getVolume",(()=>(this._video&&(this.ctx.volume=this._video.volume||0),this.ctx.volume))),C(this,"setCurrentTime",(g=>(this._video&&(this.ctx.currentTime=g,this._video.currentTime=g),this.ctx.currentTime))),C(this,"getCurrentTime",(()=>(this._video&&(this.ctx.currentTime=this._video.currentTime||0),this.ctx.currentTime))),C(this,"getTotalTime",(()=>(this._video&&(this.ctx.duration=this._video.duration||0),this.ctx.duration))),C(this,"play",(g=>{this._video&&(void 0!==g&&g>=0&&(this.ctx.currentTime=g,this._video.currentTime=g),this._video.play())})),C(this,"pause",(()=>{this._video&&this._video.pause()})),this.innerHTML="",this._player=document.createElement("div"),this._container=document.createElement("div"),this._slot=document.createElement("slot"),this._playerBtn=document.createElement("div"),this._progress=document.createElement("div"),this._progressWrap=document.createElement("div"),this._progressWrapValue=document.createElement("div"),this._progressDot=document.createElement("div"),this._playerControllerBottom=document.createElement("div"),this._playerControllerBottomRight=document.createElement("div"),this._playerControllerBottomLeft=document.createElement("div"),this._player.setAttribute("class","ran-player"),this._player.setAttribute("id","ran-player"+`${performance.now()}`.replace(".","")),this._playerBtn.setAttribute("class","ran-player-play-btn"),this._progress.setAttribute("class","ran-player-controller-progress"),this._progressWrap.setAttribute("class","ran-player-controller-progress-wrap"),this._progressWrapValue.setAttribute("class","ran-player-controller-progress-wrap-value"),this._progressDot.setAttribute("class","ran-player-controller-progress-dot"),this._playerControllerBottom.setAttribute("class","ran-player-controller-bottom"),this._playerControllerBottomRight.setAttribute("class","ran-player-controller-bottom-right"),this._playerControllerBottomLeft.setAttribute("class","ran-player-controller-bottom-left"),this._playerControllerBottomPlayBtn=document.createElement("div"),this._playerControllerBottomPlayBtn.setAttribute("class","ran-player-controller-bottom-left-btn"),this._playerControllerBottomTimeCurrent=document.createElement("div"),this._playerControllerBottomTimeCurrent.setAttribute("class","ran-player-controller-bottom-left-time-current"),this._playerControllerBottomTimeDivide=document.createElement("div"),this._playerControllerBottomTimeDivide.setAttribute("class","ran-player-controller-bottom-left-time-divide"),this._playerControllerBottomTimeDuration=document.createElement("div"),this._playerControllerBottomTimeDuration.setAttribute("class","ran-player-controller-bottom-left-time-duration"),this._playControllerBottomSpeed=document.createElement("div"),this._playControllerBottomSpeed.setAttribute("class","ran-player-controller-bottom-right-speed"),this._playControllerBottomSpeedPopover=document.createElement("r-select"),this._playControllerBottomSpeedPopover.setAttribute("value","1"),this._playControllerBottomSpeedPopover.setAttribute("trigger","hover,click"),this._playControllerBottomSpeedPopover.setAttribute("type","text"),this._playControllerBottomSpeedPopover.setAttribute("placement","top");const g=this._player.getAttribute("id");g&&this._playControllerBottomSpeedPopover.setAttribute("getPopupContainerId",g),this._playControllerBottomSpeedPopover.setAttribute("dropdownclass","video-speed-dropdown"),this._playControllerBottomSpeedPopover.addEventListener("change",this.changeSpeed);const I=document.createDocumentFragment();Gg.forEach((g=>{const{label:C,value:A}=g,i=document.createElement("r-option");i.innerHTML=C,i.setAttribute("value",`${A}`),I.appendChild(i)})),this._playControllerBottomSpeedPopover.appendChild(I),this._playControllerBottomSpeed.appendChild(this._playControllerBottomSpeedPopover),this._playControllerBottomVolume=document.createElement("div"),this._playControllerBottomVolume.setAttribute("class","ran-player-controller-bottom-right-volume"),this._playControllerBottomVolumeProgress=document.createElement("r-progress"),this._playControllerBottomVolumeProgress.setAttribute("class","ran-player-controller-bottom-right-volume-progress"),this._playControllerBottomVolumeProgress.setAttribute("percent","0.5"),this._playControllerBottomVolumeProgress.setAttribute("type","drag"),this._playControllerBottomSpeedIcon=document.createElement("div"),this._playControllerBottomSpeedIcon.setAttribute("class","ran-player-controller-bottom-right-volume-icon ran-player-controller-bottom-right-volume-icon-volume"),this._playControllerBottomClarity=document.createElement("div"),this._playControllerBottomClarity.setAttribute("class","ran-player-controller-bottom-right-clarity"),this._playControllerBottomRightFullScreen=document.createElement("div"),this._playControllerBottomRightFullScreen.setAttribute("class","ran-player-controller-bottom-right-full"),this._playerController=document.createElement("div"),this._playerController.setAttribute("class","ran-player-controller"),this._playerTip=document.createElement("div"),this._playerTip.setAttribute("class","ran-player-controller-tip"),this._playerTipTime=document.createElement("div"),this._playerTipTime.setAttribute("class","ran-player-controller-tip-time"),this._playerTipText=document.createElement("div"),this._playerTipText.setAttribute("class","ran-player-controller-tip-text"),this._playerTip.appendChild(G([this._playerTipTime,this._playerTipText])),this._playerController.appendChild(G([this._playerTip,this._progress,this._playerControllerBottom])),this._player.appendChild(G([this._container,this._slot,this._playerBtn,this._playerController])),this._progressWrap.appendChild(this._progressWrapValue),this._progress.appendChild(G([this._progressWrap,this._progressDot])),this._playerControllerBottom.appendChild(G([this._playerControllerBottomLeft,this._playerControllerBottomRight])),this._playerControllerBottomLeft.appendChild(G([this._playerControllerBottomPlayBtn,this._playerControllerBottomTimeCurrent,this._playerControllerBottomTimeDivide,this._playerControllerBottomTimeDuration])),this._playControllerBottomVolume.appendChild(G([this._playControllerBottomSpeedIcon,this._playControllerBottomVolumeProgress])),this._playerControllerBottomRight.appendChild(G([this._playControllerBottomClarity,this._playControllerBottomSpeed,this._playControllerBottomVolume,this._playControllerBottomRightFullScreen])),this.ctx={currentTime:0,duration:0,currentState:"",action:new y,volume:.5,playbackRate:1,clarity:"",fullScreen:!1,levels:[],url:"",levelMap:new Map},this.moveProgress={percentage:0,mouseDown:!1}}static get observedAttributes(){return["src","volume","currentTime","playbackRate","debug"]}get src(){return this.getAttribute("src")||""}set src(g){this.setAttribute("src",g||"")}get debug(){return this.getAttribute("debug")||""}set debug(g){this.setAttribute("debug",g||"")}get volume(){return this.getAttribute("volume")||""}set volume(g){this.setAttribute("volume",g||"")}get currentTime(){return this.getAttribute("currentTime")||""}set currentTime(g){this.setAttribute("currentTime",g||"")}get playbackRate(){return this.getAttribute("playbackRate")||""}set playbackRate(g){this.setAttribute("playbackRate",g||"")}connectedCallback(){this._container.addEventListener("click",this.dispatchClickPlayerContainerAction),this._playerBtn.addEventListener("click",this.dispatchClickPlayerBtnAction),this.addEventListener("keydown",this.SpaceKeyDown),this._progressDot.addEventListener("mousedown",this.progressDotMouseDown),this._playerControllerBottomPlayBtn.addEventListener("click",this.dispatchClickPlayerBtnAction),this._progress.addEventListener("click",this.progressClick),this._progress.addEventListener("mouseenter",this.progressMouseEnter),this._progress.addEventListener("mousemove",this.progressMouseMove),this._progress.addEventListener("mouseleave",this.progressMouseLeave),this._player.addEventListener("mousemove",this.progressDotMouseMove),this._player.addEventListener("mouseup",this.progressDotMouseUp),this._playControllerBottomVolumeProgress.addEventListener("change",this.changeVolumeProgress),this._playControllerBottomRightFullScreen.addEventListener("click",this.openFullScreen),this._playControllerBottomSpeedIcon.addEventListener("click",this.changePlayerVolume),document.addEventListener("fullscreenchange",this.fullScreenChange),window.addEventListener("resize",this.resize),this.updatePlayer()}disconnectCallback(){this._container.removeEventListener("click",this.dispatchClickPlayerContainerAction),this._playerBtn.removeEventListener("click",this.dispatchClickPlayerBtnAction),this._playerControllerBottomPlayBtn.removeEventListener("click",this.dispatchClickPlayerBtnAction),this.cancelAnimationFrame(),this.removeEventListener("keydown",this.SpaceKeyDown),this._progress.removeEventListener("click",this.progressClick),this._progress.removeEventListener("mouseenter",this.progressMouseEnter),this._progress.removeEventListener("mousemove",this.progressMouseMove),this._progress.removeEventListener("mouseleave",this.progressMouseLeave),this._progressDot.removeEventListener("mousedown",this.progressDotMouseDown),this._player.removeEventListener("mousemove",this.progressDotMouseMove),this._player.removeEventListener("mouseup",this.progressDotMouseUp),this._playControllerBottomVolumeProgress.removeEventListener("change",this.changeVolumeProgress),this._playControllerBottomRightFullScreen.removeEventListener("click",this.openFullScreen),window.removeEventListener("resize",this.resize),document.removeEventListener("fullscreenchange",this.fullScreenChange)}attributeChangedCallback(g,I,C){}}const Bg=function(){if("undefined"!=typeof document&&!customElements.get("r-player"))return customElements.define("r-player",ug),ug}(),wg=Object.freeze(Object.defineProperty({__proto__:null,RanPlayer:ug,default:Bg},Symbol.toStringTag,{value:"Module"}));const Wg=function(){if("undefined"!=typeof window&&!customElements.get("r-modal")){class g extends HTMLElement{constructor(){super()}}customElements.define("r-modal",g)}}(),pg=Object.freeze(Object.defineProperty({__proto__:null,default:Wg},Symbol.toStringTag,{value:"Module"})),Vg=["percent","type","total","dot"];class yg extends(N()){constructor(){super(),C(this,"_progress"),C(this,"_progressWrap"),C(this,"_progressWrapValue"),C(this,"_progressDot"),C(this,"moveProgress"),C(this,"progressClick",(g=>{const I=this._progress.getBoundingClientRect(),C=g.clientX-I.left,A=Math.min(1,Math.max(0,C/this._progress.offsetWidth));this.percent=""+A*Number(this.total),this._progressWrapValue.style.setProperty("transform",`scaleX(${A})`),this._progressDot.style.setProperty("transform",`translateX(${A*this._progress.offsetWidth}px)`),this.change()})),C(this,"progressDotMouseDown",(()=>{this.moveProgress.mouseDown=!0})),C(this,"progressDotMouseMove",(g=>{if(!this.moveProgress.mouseDown)return;const I=this._progress.getBoundingClientRect(),C=g.clientX-I.left,A=Math.min(1,Math.max(0,C/this._progress.offsetWidth));this.percent=""+A*Number(this.total),this._progressWrapValue.style.setProperty("transform",`scaleX(${A})`),this._progressDot.style.setProperty("transform",`translateX(${A*this._progress.offsetWidth}px)`),this.change()})),C(this,"progressDotMouseUp",(g=>{this.moveProgress.mouseDown&&(this.moveProgress.mouseDown=!1)})),C(this,"change",(()=>{this.dispatchEvent(new CustomEvent("change",{detail:{value:this.percent,percent:this.percent,total:this.total}}))})),C(this,"appendProgressDot",(()=>{"true"!==this.dot||this._progress.contains(this._progressDot)||this._progress.appendChild(this._progressDot),"false"===this.dot&&this._progress.contains(this._progressDot)&&this._progress.removeChild(this._progressDot)})),C(this,"updateCurrentProgress",(()=>{const g=Number(this.percent)/Number(this.total);this._progressWrapValue.style.setProperty("transform",`scaleX(${g})`),this._progressDot.style.setProperty("transform",`translateX(${g*this._progress.offsetWidth}px)`)})),C(this,"dragEvent",(()=>{"drag"===this.type&&(this._progress.addEventListener("click",this.progressClick),this._progressDot.addEventListener("mousedown",this.progressDotMouseDown),document.addEventListener("mousemove",this.progressDotMouseMove),document.addEventListener("mouseup",this.progressDotMouseUp))})),C(this,"createProgress",(()=>{this.children.length>0&&[...this.children].some((g=>"ran-progress"===g.className))||(this._progress.appendChild(this._progressDot),this.appendChild(this._progress))})),C(this,"resize",(()=>{this.updateCurrentProgress()})),this._progress=document.createElement("div"),this._progress.setAttribute("class","ran-progress"),this._progress.setAttribute("role","progressbar"),this._progressWrap=document.createElement("div"),this._progressWrap.setAttribute("class","ran-progress-wrap"),this._progress.appendChild(this._progressWrap),this._progressWrapValue=document.createElement("div"),this._progressWrapValue.setAttribute("class","ran-progress-wrap-value"),this._progressWrap.appendChild(this._progressWrapValue),this._progressDot=document.createElement("div"),this._progressDot.setAttribute("class","ran-progress-dot"),this.moveProgress={mouseDown:!1}}static get observedAttributes(){return Vg}get percent(){const g=this.getAttribute("percent")||"",I=w(g);return Number(I)>Number(this.total)?(console.error("percent must be < total"),this.total):`${w(g)}`}set percent(g){this.setAttribute("percent",`${g||0}`),this.setAttribute("aria-valuenow",`${g||0}`)}get total(){const g=this.getAttribute("total");return g?`${w(g)}`:"1"}set total(g){this.setAttribute("total",g||"")}get type(){const g=this.getAttribute("type")||"";return["primary","drag"].includes(g)?g:"primary"}set type(g){this.setAttribute("type",g||"primary")}get animation(){const g=this.getAttribute("animation")||"";return["play","pause"].includes(g)?g:"pause"}set animation(g){this.setAttribute("animation",g||"pause")}get dot(){const g=this.getAttribute("dot")||"";return["true","false"].includes(g)?g:"true"}set dot(g){this.setAttribute("dot",g||"true")}connectedCallback(){this.getAttribute("type")||this.setAttribute("type","primary"),this.dragEvent(),this.updateCurrentProgress(),window.addEventListener("resize",this.resize)}disconnectCallback(){this._progress.removeEventListener("click",this.progressClick),this._progressDot.removeEventListener("mousedown",this.progressDotMouseDown),document.removeEventListener("mousemove",this.progressDotMouseMove),document.removeEventListener("mouseup",this.progressDotMouseUp),window.removeEventListener("resize",this.resize)}attributeChangedCallback(g,I,C){I!==C&&("type"===g&&this.createProgress(),"dot"===g&&this.appendProgressDot(),"percent"===g&&this.updateCurrentProgress())}}const Xg="undefined"==typeof document||customElements.get("r-progress")?R("document is undefined or r-progress is exist"):(yg&&customElements.define("r-progress",yg),yg),Yg=Object.freeze(Object.defineProperty({__proto__:null,Progress:yg,default:Xg},Symbol.toStringTag,{value:"Module"}));class Rg extends(N()){constructor(){super(),C(this,"checkInput"),C(this,"checkInner"),C(this,"context"),C(this,"updateChecked",(()=>{const{checked:g}=this.context;g?m(this,"ran-checkbox-checked"):h(this,"ran-checkbox-checked")})),C(this,"update",(()=>{this.updateChecked()})),C(this,"onChange",(()=>{const{checked:g}=this.context;this.context.checked=!g,this.dispatchEvent(new CustomEvent("change",{detail:{checked:this.context.checked}})),this.update()})),this.checkInput=document.createElement("input"),this.checkInput.setAttribute("class","ran-checkbox-input"),this.checkInput.setAttribute("type","checkbox"),this.checkInner=document.createElement("span"),this.checkInner.setAttribute("class","ran-checkbox-inner"),this.context={checked:!1}}static get observedAttributes(){return["disabled","checked"]}get disabled(){return this.getAttribute("disabled")||""}set disabled(g){this.setAttribute("disabled",g)}get checked(){const g=this.getAttribute("checked");return X.includes(g)&&(this.context.checked=!1),`${this.context.checked}`}set checked(g){X.includes(g)?(this.setAttribute("checked","false"),this.context.checked=!1):(this.setAttribute("checked","true"),this.context.checked=!0),this.updateChecked()}connectedCallback(){this.setAttribute("class","ran-checkbox"),this.appendChild(this.checkInput),this.appendChild(this.checkInner),this.addEventListener("click",this.onChange)}disconnectCallback(){this.removeEventListener("click",this.onChange)}attributeChangedCallback(g,I,C){}}const Ng="undefined"==typeof document||customElements.get("r-checkbox")?R("document is undefined or r-checkbox is exist"):(customElements.define("r-checkbox",Rg),Rg),Hg=Object.freeze(Object.defineProperty({__proto__:null,Checkbox:Rg,default:Ng},Symbol.toStringTag,{value:"Module"})),Kg=g=>("#"===g[0]&&(g=g.substr(1)),3===g.length?{r:parseInt(g[0]+g[0],16),g:parseInt(g[1]+g[1],16),b:parseInt(g[2]+g[2],16)}:{r:parseInt(g.substr(0,2),16),g:parseInt(g.substr(2,2),16),b:parseInt(g.substr(4,2),16)}),Fg=(g,I,C)=>{let A;const i=Math.max(g,I,C),e=i-Math.min(g,I,C);A=0===e?0:g===i?(I-C)/e%6:I===i?(C-g)/e+2:(g-I)/e+4,A=Math.round(60*A),A<0&&(A+=360);return{h:A,s:Math.round(100*(0===i?0:e/i)),v:Math.round(i/255*100)}},Mg=(g,I,C)=>{let A=[];const i=(C/=100)*(I/=100),e=g/60,l=i*(1-Math.abs(e%2-1)),t=C-i;return A=e>=0&&e<1?[i,l,0]:e>=1&&e<2?[l,i,0]:e>=2&&e<3?[0,i,l]:g>=3&&e<4?[0,l,i]:g>=4&&e<5?[l,0,i]:g>=5&&e<=6?[i,0,l]:[0,0,0],{r:Math.round(255*(A[0]+t)),g:Math.round(255*(A[1]+t)),b:Math.round(255*(A[2]+t))}},Jg=/^#([\da-f]{6}|[\da-f]{3})$/i,Sg=/^rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)$/,fg=/^rgba\((\d{1,3}),(\d{1,3}),(\d{1,3}),(\d{1,3}(\.\d+)?)\)$/;class kg extends(N()){constructor(){super(),C(this,"_slot"),C(this,"popoverBlock"),C(this,"popoverContent"),C(this,"popoverArrow"),C(this,"popoverInner"),C(this,"popoverInnerBlock"),C(this,"removePopoverTimeId"),C(this,"createContent",(g=>{if(g){if(!this.popoverContent){const g=document.createElement("div");this.popoverContent=document.createElement("div"),this.popoverContent.setAttribute("class","ran-popover-content"),this.popoverContent.addEventListener("click",this.clickContent),this.popoverArrow=document.createElement("div"),this.popoverArrow.setAttribute("class","ran-popover-content-arrow"),this.popoverInner=document.createElement("div"),this.popoverInner.setAttribute("class","ran-popover-content-inner"),this.popoverInnerBlock=document.createElement("div"),this.popoverInnerBlock.setAttribute("class","ran-popover-content-inner-block"),this.popoverContent.appendChild(this.popoverArrow),this.popoverContent.appendChild(this.popoverInner),this.popoverInner.appendChild(this.popoverInnerBlock),g.appendChild(this.popoverContent),document.body.appendChild(g)}if(this.popoverInnerBlock&&g.length>0){this.popoverInnerBlock.innerHTML="";const I=document.createDocumentFragment();for(const C of g)I.appendChild(C);this.popoverInnerBlock.appendChild(I)}}})),C(this,"watchContent",(g=>{const{value:I}=g.detail;this.createContent(I.content),this.placementPosition()})),C(this,"placementPosition",(()=>{var g,I,C,A;if(!this.popoverInnerBlock||!this.popoverContent)return;null==(g=this.popoverContent)||g.style.setProperty("display","block"),null==(I=this.popoverContent)||I.style.setProperty("opacity","1");const i=this.getBoundingClientRect(),{top:e,left:l,bottom:t,width:s}=i;this.popoverContent.style.setProperty("--ran-x",`${(l+window.scrollX).toFixed(2)}px`),this.popoverContent.style.setProperty("--ran-y",`${(e+window.scrollY).toFixed(2)}px`);let c=t+window.scrollY,d=l+window.scrollX;const o=document.getElementById(this.getPopupContainerId);let n="translateX(-50%) translateY(-40%) rotate(0deg)",a=-8,Z=l+this.popoverContent.clientWidth/2-4;"top"===this.placement&&(c=e+window.scrollY-this.popoverContent.clientHeight-8,this.getPopupContainerId&&o&&(c=e-o.getBoundingClientRect().top-this.popoverContent.clientHeight,d=l-o.getBoundingClientRect().left),n="translateX(-50%) translateY(40%) rotate(180deg)",a=this.popoverContent.clientHeight-8,Z=s/2),null==(C=this.popoverArrow)||C.style.setProperty("inset",`${a}px auto auto ${Z}px`),null==(A=this.popoverArrow)||A.style.setProperty("transform",n),this.popoverContent.style.setProperty("inset",`${c}px auto auto ${d}px`)})),C(this,"hoverPopover",(()=>{this.removePopoverTimeId&&(clearTimeout(this.removePopoverTimeId),this.removePopoverTimeId=void 0)})),C(this,"clickContent",(g=>{g.stopPropagation()})),C(this,"clickPopover",(g=>{g.stopPropagation(),this.placementPosition()})),C(this,"clickRemovePopover",(()=>{this.hoverRemovePopover()})),C(this,"popoverTrigger",(()=>{this.removeEventListener("mouseenter",this.hoverPopover),this.removeEventListener("click",this.hoverPopover),this.removeEventListener("mouseleave",this.hoverRemovePopover),this.removeEventListener("click",this.clickPopover),document.removeEventListener("click",this.clickRemovePopover),"hover"===this.trigger?(this.addEventListener("mouseenter",this.placementPosition),this.addEventListener("mouseleave",this.hoverRemovePopover)):(this.addEventListener("click",this.clickPopover),document.addEventListener("click",this.clickRemovePopover))})),C(this,"hoverRemovePopover",(()=>{this.removePopoverTimeId&&(clearTimeout(this.removePopoverTimeId),this.removePopoverTimeId=void 0),this.removePopoverTimeId=setTimeout((()=>{var g;null==(g=this.popoverContent)||g.style.setProperty("opacity","0"),setTimeout((()=>{var g;null==(g=this.popoverContent)||g.style.setProperty("display","none")}),300)}),100)})),this._slot=document.createElement("slot"),this.popoverBlock=document.createElement("div"),this.popoverBlock.setAttribute("class","ran-popover-block"),this.popoverBlock.setAttribute("role","tooltip"),this.popoverBlock.appendChild(this._slot)}static get observedAttributes(){return["placement","arrow","trigger"]}get placement(){return this.getAttribute("placement")||"top"}set placement(g){this.setAttribute("placement",g)}get arrow(){return this.getAttribute("arrow")||""}set arrow(g){this.setAttribute("arrow",g)}get trigger(){return this.getAttribute("trigger")||""}set trigger(g){this.setAttribute("trigger",g)}get getPopupContainerId(){return this.getAttribute("getPopupContainerId")||""}set getPopupContainerId(g){this.setAttribute("getPopupContainerId",g)}connectedCallback(){this.setAttribute("class","ran-popover"),this.appendChild(this.popoverBlock);for(const g of this.children)"R-CONTENT"===g.tagName&&(g.addEventListener("change",this.watchContent),this.createContent(g.children));this.popoverTrigger()}disconnectCallback(){var g;this.removeEventListener("mouseenter",this.hoverPopover),this.removeEventListener("mouseleave",this.hoverRemovePopover),this.removeEventListener("click",this.hoverPopover),this.removeEventListener("click",this.placementPosition),document.removeEventListener("click",this.clickRemovePopover),null==(g=this.popoverContent)||g.removeEventListener("click",this.clickContent)}attributeChangedCallback(g,I,C){I!==C&&"trigger"===g&&this.popoverTrigger()}}const Dg="undefined"==typeof document||customElements.get("r-popover")?R("document is undefined or r-popover is exist"):(customElements.define("r-popover",kg),kg),Lg=Object.freeze(Object.defineProperty({__proto__:null,Popover:kg,default:Dg},Symbol.toStringTag,{value:"Module"}));class zg extends(N()){constructor(){super(),C(this,"observer"),C(this,"callback",((g,I)=>{for(const C of g)("childList"===C.type||"attributes"===C.type)&&this.onChange(C)})),C(this,"onChange",(g=>{this.dispatchEvent(new CustomEvent("change",{detail:{type:g.type,value:{content:this.children,mutation:g}}}))})),this.observer=new MutationObserver(this.callback)}connectedCallback(){this.setAttribute("class","ran-content"),this.observer.observe(this,{attributes:!0,childList:!0,subtree:!0})}disconnectCallback(){this.observer.disconnect()}}const vg="undefined"==typeof document||customElements.get("r-content")?R("document is undefined or r-content is exist"):(customElements.define("r-content",zg),zg),Tg=Object.freeze(Object.defineProperty({__proto__:null,Content:zg,default:vg},Symbol.toStringTag,{value:"Module"}));class xg extends(N()){constructor(){super(),C(this,"_input"),C(this,"_label"),C(this,"_inputContent"),C(this,"_icon"),C(this,"customInput",(g=>{g.stopPropagation(),g.preventDefault();const{target:I,data:C=""}=g;this.value=(null==I?void 0:I.value)||C||"",this.customChange(),this.dispatchEvent(new CustomEvent("input",{detail:{value:this.value}}))})),C(this,"customChange",(()=>{this.dispatchEvent(new CustomEvent("change",{detail:{value:this.value}}))})),C(this,"listenPlaceholder",((g,I)=>{"placeholder"===g&&this._inputContent&&(null!=I?this._inputContent.setAttribute("placeholder",I):this._inputContent.removeAttribute("placeholder"))})),C(this,"listenLabel",((g,I)=>{"label"===g&&this._inputContent&&(null!=I?this._label?this._label.innerHTML=I:(this._label=document.createElement("label"),this._label.innerHTML=I,this._label.setAttribute("class","ran-input-label"),this._label.setAttribute("part","ran-input-label"),this._input.appendChild(this._label)):(this._input.removeAttribute("label"),this._label&&(this._input.removeChild(this._label),this._label=void 0)))})),C(this,"listenType",((g,I)=>{"type"===g&&this._inputContent&&(I?this._inputContent.setAttribute("type",I):(this._inputContent.removeAttribute("type"),this._inputContent.removeAttribute("min"),this._inputContent.removeAttribute("max"),this._inputContent.removeAttribute("step")))})),C(this,"listenStatus",((g,I)=>{"status"===g&&this._input&&(I?this._input.setAttribute("status",I):this._input.removeAttribute("status"))})),C(this,"listenDisabled",((g,I)=>{"disabled"===g&&this._input&&(X.includes(I)?this._input.removeAttribute("disabled"):(this._input.setAttribute("disabled",""),this._inputContent.setAttribute("disabled","")))})),C(this,"listenIcon",((g,I,C)=>{"icon"===g&&I&&I!==C&&(this.removeAttribute("label"),this.setAttribute("icon",I),this.dealIcon())})),C(this,"dealIcon",(()=>{if(!this._icon){this._icon=document.createElement("ra-icon");const{width:g,height:I}=this._inputContent.getBoundingClientRect(),C=Math.min(g,I);this._icon.setAttribute("size",`${C}`),this._inputContent.insertAdjacentElement("beforebegin",this._icon)}this.icon&&this._icon.setAttribute("name",this.icon)})),C(this,"listenEvent",((g,I,C)=>{this.listenPlaceholder(g,C),this.listenLabel(g,C),this.listenStatus(g,C),this.listenDisabled(g,C),this.listenIcon(g,C,I),"value"===g&&I!==C&&(this._inputContent.value=C,this._input.setAttribute("value",C))})),this._input=document.createElement("div"),this._input.setAttribute("class","ran-input"),this._input.setAttribute("part","ran-input"),this._inputContent=document.createElement("input"),this._inputContent.setAttribute("class","ran-input-content"),this._inputContent.setAttribute("part","ran-input-content"),this._input.appendChild(this._inputContent)}static get observedAttributes(){return["label","disabled","name","placeholder","type","icon","value","status","prefix","suffix","allowclear","count","maxlength","showcount","onPressEnter","variant","minrows","maxrows"]}get value(){return this.getAttribute("value")||""}set value(g){!Y(this)&&g?(this.setAttribute("value",g),this._input.setAttribute("value",g)):(this.removeAttribute("value"),this._input.removeAttribute("value"))}get placeholder(){return this.getAttribute("placeholder")||""}set placeholder(g){g?this.setAttribute("placeholder",g):this.removeAttribute("placeholder")}get required(){return this.getAttribute("required")||""}set required(g){g&&"false"!==g?this.setAttribute("required",""):this.removeAttribute("required")}get disabled(){return`${Y(this)}`}set disabled(g){X.includes(g)?(this.removeAttribute("disabled"),this._input.removeAttribute("disabled"),this._inputContent.removeAttribute("disabled")):(this.setAttribute("disabled",""),this._input.setAttribute("disabled",""),this._inputContent.setAttribute("disabled",""))}get label(){return this.getAttribute("label")||""}set label(g){this.setAttribute("label",g)}get status(){return this.getAttribute("status")||""}set status(g){g?(this.setAttribute("status",g),this._input.setAttribute("status",g)):(this.removeAttribute("status"),this._input.removeAttribute("status"))}get name(){return this.getAttribute("name")||""}set name(g){this.setAttribute("name",g)}get min(){return this.getAttribute("min")||""}set min(g){"number"===this.type&&this.setAttribute("min",g)}get max(){return this.getAttribute("max")||""}set max(g){"number"===this.type&&this.setAttribute("max",g)}get step(){return this.getAttribute("step")||""}set step(g){"number"===this.type&&this.setAttribute("step",g)}get icon(){return this.getAttribute("icon")||""}set icon(g){g?this.setAttribute("icon",g):this.removeAttribute("icon")}get prefix(){return this.getAttribute("prefix")||""}set prefix(g){g?this.setAttribute("prefix",g):this.removeAttribute("prefix")}get suffix(){return this.getAttribute("suffix")||""}set suffix(g){g?this.setAttribute("suffix",g):this.removeAttribute("suffix")}get type(){return this.getAttribute("type")||""}set type(g){g?this.setAttribute("type",g):this.removeAttribute("type")}connectedCallback(){this.value&&(this._inputContent.value=this.value,this._input.setAttribute("value",this.value)),this.status&&this._input.setAttribute("status",this.status),Y(this)&&(this._input.setAttribute("disabled",""),this._inputContent.setAttribute("disabled","")),this.type&&this._inputContent.setAttribute("type",this.type),this._inputContent.addEventListener("input",this.customInput),"complete"===document.readyState&&this.dealIcon(),this.appendChild(this._input)}disconnectCallback(){this._inputContent.removeEventListener("input",this.customInput)}attributeChangedCallback(g,I,C){this.listenEvent(g,I,C)}}"undefined"==typeof window||customElements.get("ra-input")?R("document is undefined or ra-input is exist"):customElements.define("ra-input",xg);const Ug="http://www.w3.org/1999/xlink";!function(){if("undefined"!=typeof window&&!customElements.get("ra-icon")){class g extends HTMLElement{constructor(){super(),C(this,"_icon"),C(this,"_div"),C(this,"loadLocal",(()=>new Promise(((g,I)=>{J(Object.assign({"../../assets/icons/add-user.svg":()=>Promise.resolve().then((()=>II)),"../../assets/icons/arrow-down.svg":()=>Promise.resolve().then((()=>CI)),"../../assets/icons/book.svg":()=>Promise.resolve().then((()=>AI)),"../../assets/icons/check-circle-fill.svg":()=>Promise.resolve().then((()=>iI)),"../../assets/icons/check-circle.svg":()=>Promise.resolve().then((()=>eI)),"../../assets/icons/close-circle-fill.svg":()=>Promise.resolve().then((()=>lI)),"../../assets/icons/close-circle.svg":()=>Promise.resolve().then((()=>tI)),"../../assets/icons/close.svg":()=>Promise.resolve().then((()=>sI)),"../../assets/icons/eye-close.svg":()=>Promise.resolve().then((()=>cI)),"../../assets/icons/eye.svg":()=>Promise.resolve().then((()=>dI)),"../../assets/icons/home.svg":()=>Promise.resolve().then((()=>oI)),"../../assets/icons/info-circle-fill.svg":()=>Promise.resolve().then((()=>nI)),"../../assets/icons/info-circle.svg":()=>Promise.resolve().then((()=>aI)),"../../assets/icons/loading.svg":()=>Promise.resolve().then((()=>ZI)),"../../assets/icons/lock.svg":()=>Promise.resolve().then((()=>bI)),"../../assets/icons/message.svg":()=>Promise.resolve().then((()=>rI)),"../../assets/icons/power-off.svg":()=>Promise.resolve().then((()=>mI)),"../../assets/icons/preview.svg":()=>Promise.resolve().then((()=>hI)),"../../assets/icons/setting.svg":()=>Promise.resolve().then((()=>GI)),"../../assets/icons/sprite.svg":()=>Promise.resolve().then((()=>BI)),"../../assets/icons/team.svg":()=>Promise.resolve().then((()=>wI)),"../../assets/icons/unlock.svg":()=>Promise.resolve().then((()=>WI)),"../../assets/icons/user.svg":()=>Promise.resolve().then((()=>pI)),"../../assets/icons/warning-circle-fill.svg":()=>Promise.resolve().then((()=>VI)),"../../assets/icons/warning-circle.svg":()=>Promise.resolve().then((()=>yI))}),`../../assets/icons/${this.name}.svg`,5).then((C=>{if(C&&C.default&&C.default._identification){const{data:I}=C.default;this._icon&&this._div.removeChild(this._icon),this._icon=i(I,"image/svg+xml"),this._icon&&(this._div.appendChild(this._icon),this.setSize(),this.setColor(),g())}else this.loadNs(),I(`\n couldn't be loaded by ra-icon, message: ${this.name} icon is undefined`)})).catch((g=>{this.loadNs()}))})))),C(this,"loadNs",(()=>{this._icon&&this._div&&this._div.removeChild(this._icon),this._icon=document.createElement("svg"),this._icon.setAttribute("class","icon"),this._icon.setAttribute("viewBox","0 0 1024 1024"),this._icon.setAttribute("width","100"),this._icon.setAttribute("height","100");const g=document.createElementNS(Ug,"use");g.setAttributeNS(Ug,"xlink:href",`../../assets/iconfont/icon.svg#icon-${this.name}`),this._icon.appendChild(g),this._div.appendChild(this._icon)})),C(this,"setIcon",(async()=>{this.name&&this.loadLocal()})),C(this,"setSize",(()=>{this._icon&&this.size&&(this._icon.setAttribute("width",this.size),this._icon.setAttribute("height",this.size))})),C(this,"setColor",(()=>{this._icon&&(this.color?this._icon.setAttribute("fill",this.color):this._icon.setAttribute("fill","currentColor"))})),C(this,"setSpin",(()=>{this.spin&&this.style.setProperty("animation-duration",`${this.spin}s`)})),this._div=document.createElement("div"),this._div.setAttribute("class","ran-icon"),this._div.setAttribute("part","ran-icon")}static get observedAttributes(){return["name","size","color","spin"]}get name(){return this.getAttribute("name")}set name(g){g&&this.setAttribute("name",g)}get size(){return this.getAttribute("size")}set size(g){g&&this.setAttribute("size",g)}get color(){return this.getAttribute("color")}set color(g){g&&this.setAttribute("color",g)}get spin(){return this.getAttribute("spin")}set spin(g){null!=g&&this.setAttribute("spin",g)}connectedCallback(){this.appendChild(this._div),this.setIcon()}attributeChangedCallback(g,I,C){C!==I&&("name"===g&&this.setIcon(),"size"===g&&this.setSize(),"color"===g&&this.setColor(),"spin"===g&&this.setSpin())}}customElements.define("ra-icon",g)}}();const Qg={bottom:{add:"ran-select-dropdown-down-in",remove:"ran-select-dropdown-down-out"},top:{add:"ran-select-dropdown-up-in",remove:"ran-select-dropdown-up-out"}},jg=u();class Og extends(N()){constructor(){super(),C(this,"removeTimeId"),C(this,"_select"),C(this,"_selection"),C(this,"_search"),C(this,"_icon"),C(this,"_selectDropdown"),C(this,"_selectionDropdown"),C(this,"_selectDropDownInTimeId"),C(this,"_selectDropDownOutTimeId"),C(this,"_optionList"),C(this,"_optionLabelMapValue"),C(this,"_optionValueMapLabel"),C(this,"_activeOption"),C(this,"_text"),C(this,"_selector"),C(this,"onSearch"),C(this,"setSelectDropdownDisplayNone",(()=>{this._selectDropDownOutTimeId||this._selectionDropdown&&"none"!==this._selectionDropdown.style.display&&(m(this._selectionDropdown,Qg[this.placement].remove),this._selectDropDownOutTimeId=setTimeout((()=>{var g;null==(g=this._selectionDropdown)||g.style.setProperty("display","none"),this._selectionDropdown&&h(this._selectionDropdown,Qg[this.placement].remove),clearTimeout(this._selectDropDownOutTimeId),this._selectDropDownOutTimeId=void 0}),300))})),C(this,"setSelectDropdownDisplayBlock",(()=>{var g;this._selectDropDownInTimeId||this._selectionDropdown&&"block"!==this._selectionDropdown.style.display&&(m(this._selectionDropdown,Qg[this.placement].add),null==(g=this._selectionDropdown)||g.style.setProperty("display","block"),this._selectDropDownInTimeId=setTimeout((()=>{this._selectionDropdown&&h(this._selectionDropdown,Qg[this.placement].add),clearTimeout(this._selectDropDownInTimeId),this._selectDropDownInTimeId=void 0}),200))})),C(this,"placementPosition",(()=>{if(!this._selectionDropdown||!this._selectDropdown)return;const g=this.getBoundingClientRect(),{top:I,left:C,bottom:A,width:i,height:e,x:l,y:t,right:s}=g,c=document.getElementById(this.getPopupContainerId);this._selectionDropdown.style.setProperty("--ran-x",`${I+window.scrollX}`),this._selectionDropdown.style.setProperty("--ran-y",`${C+window.scrollY}`);let d=A+window.scrollY,o=C+window.scrollX;this._selectionDropdown.style.setProperty("width",`${i}px`),"top"===this.placement&&(d=I+window.scrollY-this._selectionDropdown.clientHeight),this.getPopupContainerId&&c&&(d="top"===this.placement?I-c.getBoundingClientRect().top-this._selectionDropdown.clientHeight:c.getBoundingClientRect().height,o=0),this._selectionDropdown.style.setProperty("inset",`${d}px auto auto ${o}px`)})),C(this,"selectMouseDown",(g=>{g.stopPropagation(),Y(this)||(this.removeDropDownTimeId(),this.setSelectDropdownDisplayNone(),this.setSelectDropdownDisplayBlock(),this.placementPosition())})),C(this,"removeDropDownTimeId",(()=>{this._search.setAttribute("value",""),this.trigger.includes("hover")&&!d()&&(clearTimeout(this.removeTimeId),this.removeTimeId=void 0)})),C(this,"selectBlur",(()=>{this.removeTimeId&&this.removeDropDownTimeId(),this.removeTimeId=setTimeout((()=>{this.removeDropDownTimeId(),this.setSelectDropdownDisplayNone()}),100)})),C(this,"clickOption",(g=>{var I,C;g.stopPropagation();let A=g.target;if((null==(I=A.classList)?void 0:I.contains("ranui-select-dropdown-option-item"))&&(A=A.children[0]),!(null==(C=A.classList)?void 0:C.contains("ranui-select-dropdown-option-item-content")))return;const i=A.innerHTML,e=this._optionLabelMapValue.get(i);e&&(this.setAttribute("value",e),this._text.innerHTML=i,this._text.setAttribute("title",i),this._search.setAttribute("placeholder",i));const l=this.getBoundingClientRect(),{height:t}=l;this._text.style.setProperty("line-height",`${t}px`),this._activeOption&&h(this._activeOption,"ranui-select-dropdown-option-active"),setTimeout((()=>{this._activeOption=(null==A?void 0:A.parentElement)||void 0,this._activeOption&&m(this._activeOption,"ranui-select-dropdown-option-active")}),200),this.setSelectDropdownDisplayNone(),this.dispatchEvent(new CustomEvent("change",{detail:{value:e,label:i}})),this.removeDropDownTimeId()})),C(this,"createOption",(()=>{if(!this._selectDropdown){this.appendChild(this._select);const g=document.getElementById(this.getPopupContainerId)||document.body;this._selectDropdown=document.createElement("div"),this._selectDropdown.style.setProperty("-webkit-tap-highlight-color","transparent"),this._selectDropdown.style.setProperty("outline","0"),this._selectDropdown.addEventListener("click",this.clickOption),this._selectionDropdown=document.createElement("div"),this._selectionDropdown.style.setProperty("-webkit-tap-highlight-color","transparent"),this._selectionDropdown.style.setProperty("outline","0"),this.dropdownclass?this._selectionDropdown.setAttribute("class",`${this.dropdownclass} ranui-select-dropdown`):this._selectionDropdown.setAttribute("class","ranui-select-dropdown"),this.trigger.includes("hover")&&!d()&&(this._selectDropdown.addEventListener("mouseleave",this.selectBlur),this._selectDropdown.addEventListener("mouseenter",this.removeDropDownTimeId)),this._selectDropdown.appendChild(this._selectionDropdown),this._selectionDropdown.style.setProperty("display","none"),g.appendChild(this._selectDropdown)}this.addOptionToSlot()})),C(this,"removeSelectDropdown",(()=>{try{if(this._selectDropdown){(document.getElementById(this.getPopupContainerId)||document.body).removeChild(this._selectDropdown)}}catch(g){}})),C(this,"addOptionToSlot",(()=>{var g;const I=this.children||[];this._optionList=[];for(const C of I)if("R-OPTION"===C.tagName){const I=C.innerHTML,A=C.getAttribute("value")||"";null==(g=this._optionList)||g.push({label:I,value:A}),this._optionLabelMapValue.set(I,A),this._optionValueMapLabel.set(A,I)}this.createSelectDropdownContent(this._optionList)})),C(this,"createSelectDropdownContent",((g=[])=>{var I,C;0===g.length?null==(I=this._selectDropdown)||I.style.setProperty("display","none"):null==(C=this._selectDropdown)||C.style.setProperty("display","block"),this._selectionDropdown&&(this._selectionDropdown.innerHTML=""),g.forEach((g=>{if(this._selectionDropdown){const{label:I,value:C}=g,A=document.createElement("div");(this.getAttribute("defaultValue")||this.getAttribute("value"))===C?(A.setAttribute("class","ranui-select-dropdown-option-active ranui-select-dropdown-option-item"),this._activeOption=A):A.setAttribute("class","ranui-select-dropdown-option-item");const i=document.createElement("div");i.setAttribute("class","ranui-select-dropdown-option-item-content"),i.innerHTML=`${I}`,i.setAttribute("value",`${C}`),i.setAttribute("title",`${I}`),A.appendChild(i),this._selectionDropdown.appendChild(A)}})),this.setDefaultValue()})),C(this,"setDefaultValue",(()=>{const g=this.getAttribute("defaultValue")||this.getAttribute("value");if(!g)return;const I=this._optionValueMapLabel.get(g);if(!I)return;this.setAttribute("value",g);const C=this.getBoundingClientRect(),{height:A}=C;this._text.style.setProperty("line-height",`${A}px`),this._text.innerHTML=I,this._text.setAttribute("title",I)})),C(this,"changeSearch",(g=>{const I=g.detail.value||"";if(this.dispatchEvent(new CustomEvent("search",{detail:{value:I}})),this._selectionDropdown&&(this._selectionDropdown.innerHTML=""),I.length>0){const g=this._optionList.map((g=>{const{label:C}=g;if(`${C}`.toLowerCase().includes(I))return{label:C,value:g.value}})).filter((g=>g));this.createSelectDropdownContent(g)}else this.createSelectDropdownContent(this._optionList)})),C(this,"setShowSearch",(()=>{this.onSearch=jg(this.changeSearch),this.onSearch&&this._search.addEventListener("change",this.onSearch),this.onSearch&&this._search.addEventListener("click",this.onSearch)})),C(this,"removeShowSearch",(()=>{this.onSearch&&this._search.removeEventListener("change",this.onSearch),this.onSearch&&this._search.removeEventListener("click",this.onSearch)})),C(this,"listenActionEvent",(()=>{this.removeEventListener("mouseenter",this.selectMouseDown),this.removeEventListener("mouseleave",this.selectBlur),this.removeEventListener("click",this.selectMouseDown),this.removeEventListener("blur",this.selectBlur),this.trigger.includes("hover")&&!d()&&(this.addEventListener("mouseenter",this.selectMouseDown),this.addEventListener("mouseleave",this.selectBlur)),this.trigger.includes("click")&&(this.addEventListener("click",this.selectMouseDown),this.addEventListener("blur",this.selectBlur))})),C(this,"clickRemoveSelect",(g=>{g.stopPropagation(),this.setSelectDropdownDisplayNone()})),this._select=document.createElement("div"),this._select.setAttribute("class","ran-select"),this._select.setAttribute("part","select"),this._selection=document.createElement("div"),this._selection.setAttribute("class","selection"),this._selection.setAttribute("part","selection"),this._selector=document.createElement("div"),this._search=document.createElement("ra-input"),this._search.setAttribute("class","selection-search"),this._search.setAttribute("part","search"),this._search.setAttribute("type","search"),this._search.setAttribute("autocomplete","off"),this._text=document.createElement("span"),this._text.setAttribute("class","selection-item"),this._text.setAttribute("part","selection-item"),this._icon=document.createElement("ra-icon"),this._icon.setAttribute("class","icon"),this._icon.setAttribute("part","icon"),this._icon.setAttribute("name","arrow-down"),this._icon.setAttribute("color","#d9d9d9"),this._icon.setAttribute("size","16"),this._selector.appendChild(this._text),this._selector.appendChild(this._search),this._selection.appendChild(this._icon),this._selection.appendChild(this._selector),this._select.appendChild(this._selection),this._optionList=[],this._optionLabelMapValue=new Map,this._optionValueMapLabel=new Map}static get observedAttributes(){return["disabled","sheet","clear","type","defaultValue","showSearch","placement","getPopupContainerId","dropdownclass","trigger"]}get value(){return this.getAttribute("value")||""}set value(g){!Y(this)&&g?this.setAttribute("value",g):this.removeAttribute("value")}get defaultValue(){return this.getAttribute("defaultValue")||""}set defaultValue(g){this.setAttribute("defaultValue",g||"")}get showSearch(){return this.getAttribute("showSearch")||""}set showSearch(g){this.setAttribute("showSearch",g||"")}get type(){return this.getAttribute("type")||""}set type(g){this.setAttribute("type",g||"")}get placement(){return this.getAttribute("placement")||"bottom"}set placement(g){this.setAttribute("placement",g||"")}get sheet(){return this.getAttribute("sheet")||""}set sheet(g){this.setAttribute("sheet",g||"")}get getPopupContainerId(){return this.getAttribute("getPopupContainerId")||""}set getPopupContainerId(g){this.setAttribute("getPopupContainerId",g||"")}get dropdownclass(){return this.getAttribute("dropdownclass")||""}set dropdownclass(g){this.setAttribute("dropdownclass",g||"")}get trigger(){return this.getAttribute("trigger")||"click"}set trigger(g){this.setAttribute("trigger",g||"")}get disabled(){return Y(this)}set disabled(g){g&&"false"!==g?(this.setAttribute("disabled",""),this._selection.setAttribute("disabled","")):(this.removeAttribute("disabled"),this._selection.removeAttribute("disabled"))}connectedCallback(){this.createOption(),this.listenActionEvent(),this.setShowSearch(),document.addEventListener("click",this.clickRemoveSelect)}disconnectCallback(){var g;this.removeEventListener("mouseenter",this.selectMouseDown),this.removeEventListener("mouseleave",this.selectBlur),this.removeEventListener("click",this.selectMouseDown),this.removeEventListener("blur",this.selectBlur),this.removeSelectDropdown(),null==(g=this._selectDropdown)||g.removeEventListener("click",this.clickOption),document.removeEventListener("click",this.clickRemoveSelect)}attributeChangedCallback(g,I,C){"disabled"===g&&this._select&&(C&&"false"!==C?(this._select.removeAttribute("disabled"),this._selection.removeAttribute("disabled")):(this._select.setAttribute("disabled",""),this._selection.setAttribute("disabled","")))}}"undefined"==typeof document||customElements.get("ra-select")?R("document is undefined or ra-select is exist"):customElements.define("ra-select",Og);class Eg extends(N()){constructor(){super(),C(this,"colorpicker"),C(this,"colorpickerInner"),C(this,"context"),C(this,"popoverBlock"),C(this,"popoverContent"),C(this,"colorPickerInner"),C(this,"colorPickerInnerContent"),C(this,"colorPickerPanel"),C(this,"colorPickerInputContainer"),C(this,"colorPickerPanelDot"),C(this,"colorPickerPanelSliderContainer"),C(this,"colorPickerPanelSliderGroup"),C(this,"colorPickerPanelSliderHue"),C(this,"colorPickerPanelSliderAlpha"),C(this,"colorPickerColorBlockInner"),C(this,"colorPickerColorBlock"),C(this,"colorPickerInnerContentSelect"),C(this,"colorPickerPanelPalette"),C(this,"colorPickerPanelSaturation"),C(this,"colorPickerInputContainerSelect"),C(this,"colorPickerInputContainerInputColor"),C(this,"colorPickerInputContainerInputNumber"),C(this,"colorPickerInputContainerSelectItem"),C(this,"colorPickerPaletteSelect"),C(this,"colorPickerPanelDotInner"),C(this,"createContext",(()=>{this.context={value:this.createColorValueSignal(),disabled:this.createColorDisabled(),hue:this.createColorHue(),saturation:this.createColorSaturation(),lightness:this.createColorLightness(),transparency:this.createColorTransparency()}})),C(this,"createColorHue",(()=>{const[g,I]=H(0,{subscriber:[this.updateColorPickerPanelSaturationBackground,this.updateColorPickerPanelSliderHueProgressPercent,this.updateColorPickerPanelSliderAlphaProgressWrap,this.updateColorPickerPanelSliderAlphaProgressDot,this.updateColorPickerColorBlockInnerBackground,this.updateColorPickerPanelSliderHueProgressDot]});return{getter:g,setter:I}})),C(this,"createColorSaturation",(()=>{const[g,I]=H(100,{subscriber:[this.updateColorPickerPanelSliderAlphaProgressWrap,this.updateColorPickerPanelSliderAlphaProgressDot,this.updateColorPickerColorBlockInnerBackground]});return{getter:g,setter:I}})),C(this,"createColorLightness",(()=>{const[g,I]=H(100,{subscriber:[this.updateColorPickerPanelSliderAlphaProgressWrap,this.updateColorPickerPanelSliderAlphaProgressDot,this.updateColorPickerColorBlockInnerBackground]});return{getter:g,setter:I}})),C(this,"createColorTransparency",(()=>{const[g,I]=H(80,{subscriber:[this.updateColorPickerPanelSliderAlphaProgressPercent,this.updateColorPickerColorBlockInnerBackground,this.updateColorPickerPanelSliderAlphaProgressDot]});return{getter:g,setter:I}})),C(this,"createColorDisabled",(()=>{const[g,I]=H(!0,{subscriber:[]});return{getter:g,setter:I}})),C(this,"createColorValueSignal",(()=>{const[g,I]=H("",{subscriber:[this.updateColorValue]});return{getter:g,setter:I}})),C(this,"generateHue2rgb",(()=>{const{hue:g}=this.context,{r:I,g:C,b:A}=Mg(g.getter(),100,100);return`rgb(${I}, ${C}, ${A})`})),C(this,"generateHsv2Rgb",(()=>{const{r:g,g:I,b:C}=this.generateHsv2Rgba();return`rgb(${g}, ${I}, ${C})`})),C(this,"generateHsv2Rgba",(()=>{const{hue:g,saturation:I,lightness:C,transparency:A}=this.context,{r:i,g:e,b:l}=Mg(g.getter(),I.getter(),C.getter());return{r:i,g:e,b:l,a:A.getter()/100}})),C(this,"generateHsv2RgbaValue",(()=>{const{r:g,g:I,b:C,a:A}=this.generateHsv2Rgba();return`rgb(${g}, ${I}, ${C}, ${A})`})),C(this,"generateColorPickerProgress",(()=>{const{r:g,g:I,b:C}=this.generateHsv2Rgba();return`linear-gradient(to right, rgba(255, 0, 4, 0), rgba(${g}, ${I}, ${C}, 1))`})),C(this,"updateColorValue",(g=>{var I,C;if(g!==(null==(I=this.context)?void 0:I.value.getter())){const I=Jg.exec(g),A=Sg.exec(g.replace(/\s+/g,"")),i=fg.exec(g.replace(/\s+/g,""));if(I){const{h:g,s:C,v:A}=(g=>{const{r:I,g:C,b:A}=Kg(g);return Fg(I,C,A)})(I[0]);this.context.hue.setter(g),this.context.saturation.setter(C),this.context.lightness.setter(A),this.context.transparency.setter(100)}else if(i){const{h:g,s:I,v:C}=Fg(Number(i[1]),Number(i[2]),Number(i[3]));this.context.hue.setter(g),this.context.saturation.setter(I),this.context.lightness.setter(C),this.context.transparency.setter(Number(i[4]))}else{if(!A)return;{const{h:g,s:I,v:C}=Fg(Number(A[1]),Number(A[2]),Number(A[3]));this.context.hue.setter(g),this.context.saturation.setter(I),this.context.lightness.setter(C),this.context.transparency.setter(100)}}this.setAttribute("value",g),this.colorpickerInner.style.setProperty("background",g),null==(C=this.context)||C.value.setter(g)}})),C(this,"updateColorPickerPanelSliderHueProgressPercent",(g=>{var I;null==(I=this.colorPickerPanelSliderHue)||I.setAttribute("percent",""+g/360)})),C(this,"updateColorPickerPanelSliderAlphaProgressPercent",(g=>{var I;null==(I=this.colorPickerPanelSliderAlpha)||I.setAttribute("percent",""+g/100)})),C(this,"updateColorPickerPanelSliderAlphaProgressWrap",(()=>{var g;null==(g=this.colorPickerPanelSliderAlpha)||g.style.setProperty("--ran-progress-wrap",this.generateColorPickerProgress())})),C(this,"updateColorPickerPanelSliderAlphaProgressDot",(()=>{var g;null==(g=this.colorPickerPanelSliderAlpha)||g.style.setProperty("--ran-progress-dot",this.generateHsv2RgbaValue())})),C(this,"updateColorPickerPanelSliderHueProgressDot",(()=>{var g;null==(g=this.colorPickerPanelSliderHue)||g.style.setProperty("--ran-progress-dot",this.generateHue2rgb())})),C(this,"updateColorPickerColorBlockInnerBackground",(()=>{var g;null==(g=this.colorPickerColorBlockInner)||g.style.setProperty("background",this.generateHsv2RgbaValue())})),C(this,"updateColorPickerPanelSaturationBackground",(()=>{var g;null==(g=this.colorPickerPanelSaturation)||g.style.setProperty("background-color",this.generateHue2rgb())})),C(this,"clickStop",(g=>{g.stopPropagation(),g.preventDefault()})),C(this,"changeColorPalettePositionByContext",(()=>{window.requestAnimationFrame((()=>{var g,I,C,A,i;if(this.updateColorValue(this.value),!this.colorPickerPanelPalette)return;if(!(null==(g=this.context)?void 0:g.lightness.getter)||!(null==(I=this.context)?void 0:I.saturation.getter))return;const{width:e,height:l}=(null==(C=this.colorPickerPanelPalette)?void 0:C.getBoundingClientRect())||{},t=l-this.context.lightness.getter()/100*l,s=this.context.saturation.getter()/100*e;null==(A=this.colorPickerPanelDot)||A.style.setProperty("top",t-8+"px"),null==(i=this.colorPickerPanelDot)||i.style.setProperty("left",s-8+"px")}))})),C(this,"changeColorPalettePosition",((g,I)=>{var C,A,i;if(!this.colorPickerPanelPalette)return;if(!(null==(C=this.context)?void 0:C.lightness.getter)||!(null==(A=this.context)?void 0:A.saturation.getter))return;const{width:e,height:l}=(null==(i=this.colorPickerPanelPalette)?void 0:i.getBoundingClientRect())||{},t=l-W(I,0,l),s=W(g,0,e);this.context.saturation.setter(s/e*100),this.context.lightness.setter(t/l*100),window.requestAnimationFrame((()=>{var C,A;null==(C=this.colorPickerPanelDot)||C.style.setProperty("top",I-8+"px"),null==(A=this.colorPickerPanelDot)||A.style.setProperty("left",g-8+"px")}))})),C(this,"clickColorPalette",(g=>{const{offsetX:I,offsetY:C}=g;this.changeColorPalettePosition(I,C)})),C(this,"createColorPickerProgress",(()=>{this.colorPickerPanelSliderContainer=document.createElement("div"),this.colorPickerPanelSliderContainer.setAttribute("class","ran-color-picker-slider-container"),this.colorPickerPanelSliderGroup=document.createElement("div"),this.colorPickerPanelSliderGroup.setAttribute("class","ran-color-picker-slider-container-group"),this.colorPickerPanelSliderHue=document.createElement("r-progress"),this.updateColorPickerPanelSliderHueProgressDot(),this.colorPickerPanelSliderHue.style.setProperty("--ran-progress-wrap","linear-gradient(to right, #ff0000, #ffff00, #00ff00, #00ffff, #0000ff, #ff00ff, #ff0000)"),this.colorPickerPanelSliderHue.setAttribute("percent",""+this.context.hue.getter()/360),this.colorPickerPanelSliderHue.addEventListener("change",this.changeColorPickerHue),this.colorPickerPanelSliderHue.setAttribute("type","drag"),this.colorPickerPanelSliderHue.setAttribute("class","ran-color-picker-slider-container-group-hue"),this.colorPickerPanelSliderAlpha=document.createElement("r-progress"),this.updateColorPickerPanelSliderAlphaProgressDot(),this.colorPickerPanelSliderAlpha.setAttribute("percent",""+this.context.transparency.getter()/100),this.updateColorPickerPanelSliderAlphaProgressWrap(),this.colorPickerPanelSliderAlpha.addEventListener("change",this.changeColorPickerAlpha),this.colorPickerPanelSliderAlpha.setAttribute("type","drag"),this.colorPickerPanelSliderAlpha.setAttribute("class","ran-color-picker-slider-container-group-alpha"),this.colorPickerPanelSliderGroup.appendChild(this.colorPickerPanelSliderHue),this.colorPickerPanelSliderGroup.appendChild(this.colorPickerPanelSliderAlpha),this.colorPickerPanelSliderContainer.appendChild(this.colorPickerPanelSliderGroup),this.colorPickerColorBlock=document.createElement("div"),this.colorPickerColorBlock.setAttribute("class","ran-color-picker-slider-container-color-block"),this.colorPickerColorBlockInner=document.createElement("div"),this.colorPickerColorBlockInner.setAttribute("class","ran-color-picker-slider-container-color-block-inner"),this.updateColorPickerColorBlockInnerBackground(),this.colorPickerColorBlock.appendChild(this.colorPickerColorBlockInner),this.colorPickerPanelSliderContainer.appendChild(this.colorPickerColorBlock)})),C(this,"changeColorPickerHue",(g=>{this.context.hue.setter(360*g.detail.value)})),C(this,"changeColorPickerAlpha",(g=>{this.context.transparency.setter(100*g.detail.value)})),C(this,"createColorPickerSelect",(()=>{this.colorPickerPanel=document.createElement("div"),this.colorPickerPanel.setAttribute("class","ran-color-picker-panel"),this.colorPickerInnerContentSelect=document.createElement("div"),this.colorPickerInnerContentSelect.setAttribute("class","ran-color-picker-select"),this.colorPickerPanel.appendChild(this.colorPickerInnerContentSelect),this.colorPickerPanelPalette=document.createElement("div"),this.colorPickerPanelPalette.setAttribute("class","ran-color-picker-palette"),this.colorPickerInnerContentSelect.appendChild(this.colorPickerPanelPalette),this.colorPickerPanelSaturation=document.createElement("div"),this.colorPickerPanelSaturation.setAttribute("class","ran-color-picker-saturation"),this.updateColorPickerPanelSaturationBackground(),this.colorPickerPanelDot=document.createElement("div"),this.colorPickerPanelDotInner=document.createElement("div"),this.colorPickerPanelDotInner.setAttribute("class","ran-color-picker-palette-dot-inner"),this.colorPickerPanelDot.setAttribute("class","ran-color-picker-palette-dot"),this.colorPickerPanelDot.addEventListener("mousedown",this.mouseDownColorPickerPalette),document.body.addEventListener("mousemove",this.mouseMoveColorPickerPalette),this.colorPickerPanelDot.addEventListener("mouseup",this.mouseUpColorPickerPalette),this.colorPickerPanelDot.appendChild(this.colorPickerPanelDotInner),this.colorPickerPanelPalette.appendChild(this.colorPickerPanelDot),this.colorPickerPanelPalette.appendChild(this.colorPickerPanelSaturation),this.colorPickerPanelPalette.addEventListener("mousedown",this.clickColorPalette)})),C(this,"createColorPickerInput",(()=>{this.colorPickerInputContainer=document.createElement("div"),this.colorPickerInputContainer.setAttribute("class","ran-color-picker-input-container");const g=`${performance.now()}`.replace(".","");this.colorPickerInputContainerSelect=document.createElement("div"),this.colorPickerInputContainerSelect.setAttribute("class","ran-color-picker-input-container-select"),this.colorPickerInputContainerSelect.setAttribute("id",g),this.colorPickerInputContainerSelectItem=document.createElement("ra-select"),this.colorPickerInputContainerSelectItem.setAttribute("value","HEX"),this.colorPickerInputContainerSelectItem.setAttribute("class","ran-color-picker-input-container-select-item"),this.colorPickerInputContainerSelectItem.setAttribute("type","text"),this.colorPickerInputContainerSelectItem.setAttribute("getPopupContainerId",g);const I=document.createDocumentFragment();["HEX","HSB","RGB"].forEach((g=>{const C=document.createElement("r-option");C.setAttribute("value",g),C.innerText=g,I.appendChild(C)})),this.colorPickerInputContainerSelectItem.appendChild(I),this.colorPickerInputContainerSelect.appendChild(this.colorPickerInputContainerSelectItem),this.colorPickerInputContainer.appendChild(this.colorPickerInputContainerSelect),this.colorPickerInputContainerInputColor=document.createElement("ra-input"),this.colorPickerInputContainerInputColor.setAttribute("class","ran-color-picker-input-container-input-color"),this.colorPickerInputContainerInputNumber=document.createElement("ra-input"),this.colorPickerInputContainerInputNumber.setAttribute("class","ran-color-picker-input-container-input-number"),this.colorPickerInputContainer.appendChild(this.colorPickerInputContainerInputColor),this.colorPickerInputContainer.appendChild(this.colorPickerInputContainerInputNumber)})),C(this,"openColorPicker",(()=>{this.colorPickerInner||(this.colorPickerInner=document.createElement("div"),this.colorPickerInner.setAttribute("class","ran-color-picker-inner"),this.colorPickerInnerContent=document.createElement("div"),this.colorPickerInnerContent.setAttribute("class","ran-color-picker-inner-content"),this.createColorPickerProgress(),this.createColorPickerSelect(),this.createColorPickerInput(),this.colorPickerPanel&&this.colorPickerInnerContent.appendChild(this.colorPickerPanel),this.colorPickerPanelSliderContainer&&this.colorPickerInnerContent.appendChild(this.colorPickerPanelSliderContainer),this.colorPickerInputContainer&&this.colorPickerInnerContent.appendChild(this.colorPickerInputContainer),this.colorPickerInner.appendChild(this.colorPickerInnerContent),this.popoverContent.appendChild(this.colorPickerInner),this.changeColorPalettePositionByContext())})),C(this,"mouseMoveColorPickerPalette",(g=>{var I;if(!this.colorPickerPanelPalette||!this.colorPickerPaletteSelect)return;const{pageX:C,pageY:A}=g,{top:i=0,left:e=0,width:l,height:t}=(null==(I=this.colorPickerPanelPalette)?void 0:I.getBoundingClientRect())||{},s=W(A-i-8,-8,t-8),c=W(C-e-8,-8,l-8);this.context.saturation.setter(c/l*100),this.context.lightness.setter(s/t*100),window.requestAnimationFrame((()=>{var g,I;null==(g=this.colorPickerPanelDot)||g.style.setProperty("top",`${s}px`),null==(I=this.colorPickerPanelDot)||I.style.setProperty("left",`${c}px`)}))})),C(this,"mouseDownColorPickerPalette",(g=>{g.stopPropagation(),g.preventDefault(),this.colorPickerPaletteSelect=!0})),C(this,"mouseUpColorPickerPalette",(g=>{this.colorPickerPaletteSelect=!1})),this.setAttribute("class","ran-colorpicker"),this.popoverBlock=document.createElement("r-popover"),this.popoverBlock.setAttribute("class","ran-popover"),this.popoverContent=document.createElement("r-content"),this.popoverContent.setAttribute("class","ran-content"),this.colorpicker=document.createElement("div"),this.colorpicker.setAttribute("class","ran-colorpicker-block"),this.colorpickerInner=document.createElement("div"),this.colorpickerInner.setAttribute("class","ran-colorpicker-inner"),this.popoverBlock.appendChild(this.colorpicker),this.popoverBlock.appendChild(this.popoverContent),this.colorpicker.appendChild(this.colorpickerInner),this.appendChild(this.popoverBlock),this.colorPickerPaletteSelect=!1,this.createContext()}static get observedAttributes(){return["disabled","value"]}get value(){var g;return(null==(g=this.context)?void 0:g.value.getter())||""}set value(g){this.setAttribute("value",g),this.updateColorValue(g)}connectedCallback(){this.popoverBlock.addEventListener("click",this.openColorPicker)}disconnectCallback(){var g,I,C;this.popoverBlock.removeEventListener("click",this.openColorPicker),null==(g=this.colorPickerPanelDot)||g.removeEventListener("mousedown",this.mouseDownColorPickerPalette),document.body.removeEventListener("mousemove",this.mouseMoveColorPickerPalette),null==(I=this.colorPickerPanelDot)||I.removeEventListener("mouseup",this.mouseUpColorPickerPalette),null==(C=this.colorPickerPanelPalette)||C.removeEventListener("mousedown",this.clickColorPalette)}attributeChangedCallback(g,I,C){I!==C&&"value"===g&&this.updateColorValue(C)}}const Pg="undefined"==typeof document||customElements.get("r-colorpicker")?R("document is undefined or r-colorpicker is exist"):(customElements.define("r-colorpicker",Eg),Eg),_g=Object.freeze(Object.defineProperty({__proto__:null,ColorPicker:Eg,default:Pg},Symbol.toStringTag,{value:"Module"}));class qg extends(N()){constructor(){super(),C(this,"contain"),C(this,"rotateLoading",(()=>{const g=document.createElement("div");g.setAttribute("class","rotate"),this.contain.appendChild(g)})),C(this,"stretchLoading",(()=>{const g=document.createElement("div");g.setAttribute("class","stretch");[1,2,3,4,5].forEach((I=>{const C=document.createElement("div");C.setAttribute("class",`rect${I}`),g.appendChild(C)})),this.contain.appendChild(g)})),C(this,"doubleBounceLoading",(()=>{const g=document.createElement("div");g.setAttribute("class","double-bounce");[1,2].forEach((I=>{const C=document.createElement("div");C.setAttribute("class",`double-bounce${I}`),g.appendChild(C)})),this.contain.appendChild(g)})),C(this,"cubeLoading",(()=>{const g=document.createElement("div");g.setAttribute("class","cube");[1,2].forEach((I=>{const C=document.createElement("div");C.setAttribute("class",`cube${I}`),g.appendChild(C)})),this.contain.appendChild(g)})),C(this,"dotLoading",(()=>{const g=document.createElement("div");g.setAttribute("class","dot");[1,2].forEach((I=>{const C=document.createElement("div");C.setAttribute("class",`dot${I}`),g.appendChild(C)})),this.contain.appendChild(g)})),C(this,"tripleBounceLoading",(()=>{const g=document.createElement("div");g.setAttribute("class","triple-bounce");[1,2,3].forEach((I=>{const C=document.createElement("div");C.setAttribute("class",`triple-bounce${I}`),g.appendChild(C)})),this.contain.appendChild(g)})),C(this,"scaleOutLoading",(()=>{const g=document.createElement("div");g.setAttribute("class","scale-out"),this.contain.appendChild(g)})),C(this,"circleLoading",(()=>{const g=document.createElement("div");g.setAttribute("class","circle"),[[1,2,3,4],[1,2,3,4],[1,2,3,4]].forEach(((I,C)=>{const A=document.createElement("div");A.setAttribute("class",`circle-container container${C+1}`),I.forEach((g=>{const I=document.createElement("div");I.setAttribute("class",`circle${g}`),A.appendChild(I)})),g.appendChild(A)})),this.contain.appendChild(g)})),C(this,"createLoading",(()=>{this.contain.innerHTML="";const g={stretch:this.stretchLoading,rotate:this.rotateLoading,"double-bounce":this.doubleBounceLoading,cube:this.cubeLoading,dot:this.dotLoading,"triple-bounce":this.tripleBounceLoading,"scale-out":this.scaleOutLoading,circle:this.circleLoading}[this.name];g&&g(),this.contains(this.contain)||this.appendChild(this.contain)})),this.contain=document.createElement("div"),this.contain.setAttribute("class","ran-loading")}static get observedAttributes(){return["name"]}get name(){const g=this.getAttribute("name")||"";return g||"circle"}set name(g){this.setAttribute("name",g||"")}connectedCallback(){}disconnectCallback(){}attributeChangedCallback(g,I,C){I!==C&&"name"===g&&this.createLoading()}}const $g="undefined"==typeof document||customElements.get("r-loading")?R("document is undefined or r-loading is exist"):(customElements.define("r-loading",qg),qg),gI=Object.freeze(Object.defineProperty({__proto__:null,Loading:qg,default:$g},Symbol.toStringTag,{value:"Module"}));if("undefined"!=typeof document){const g=document.createElement("style");g.textContent=":host([type=\"toast\"]){--ranui-message-background: rgba(0, 0, 0, .7);--ranui-message-color: #fff;--ranui-message-border-radius: 7px}.ran-message-notice{padding:8px;text-align:center;max-width:90%;margin:0 auto;word-break:break-all}.ran-message-notice-content{display:inline-block;padding:10px 16px;background:var(--ranui-message-background, #fff);border-radius:var(--ranui-message-border-radius, 8px);box-shadow:0 3px 6px -4px #0000001f,0 6px 16px #00000014,0 9px 28px 8px #0000000d;pointer-events:all}.ran-message-notice-content-info{align-items:center;display:flex}.ran-message-notice-content-info span{margin:0;padding:0;color:var(--ranui-message-color, #000000d9);font-size:14px;font-variant:tabular-nums;list-style:none;font-feature-settings:\"tnum\";z-index:1010;width:100%;pointer-events:none}@keyframes rotate{to{transform:rotate(360deg)}}@keyframes MessageMoveIn{0%{padding:0;transform:translateY(-100%);opacity:0}to{padding:8px;transform:translateY(0);opacity:1}}@keyframes MessageMoveOut{0%{max-height:150px;padding:8px;opacity:1}to{max-height:0;padding:0;opacity:0}}.ranui-message{box-sizing:border-box;margin:0;padding:0;color:#000000d9;font-size:14px;font-variant:tabular-nums;line-height:1.5715;list-style:none;font-feature-settings:\"tnum\";position:fixed;top:8px;left:0;z-index:1010;width:100%;pointer-events:none}.ranui-message .message-in{animation-name:MessageMoveIn;animation-duration:.3s;animation-timing-function:cubic-bezier(.78,.14,.15,.86)}.ranui-message .message-leave{animation-name:MessageMoveOut;animation-duration:.3s;animation-timing-function:cubic-bezier(.78,.14,.15,.86)}r-progress:active,r-progress:focus{outline:0;-webkit-tap-highlight-color:transparent}.ran-progress{position:relative;cursor:pointer;width:100%;height:100%}.ran-progress:active,.ran-progress:focus{outline:0;-webkit-tap-highlight-color:transparent}.ran-progress-wrap{width:100%;height:8px;border-radius:20px;background:var(--ran-progress-wrap, #5b5b5b);position:relative;overflow:hidden}.ran-progress-wrap-value{position:absolute;top:0;left:0;height:100%;width:100%;transform:scaleX(0);transform-origin:0 0;will-change:transform;background:var(--ran-progress-wrap-value, linear-gradient(90deg, #0bc8bb 2.42%, #00d297 98.79%));border-radius:20px}.ran-progress-dot{position:absolute;top:-5px;left:-9px;border-radius:50%;width:18px;height:18px;background:var(--ran-progress-dot, linear-gradient(90deg, #0bc8bb 2.42%, #00d297 98.79%));cursor:pointer}.remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}html.dark .r-preview-mask .r-preview-contain{background-color:#191919!important}.r-preview{width:100%;height:100%}.r-preview-slot{display:block}:host{cursor:pointer;--el-text-color-primary: #303133;--el-loading-color: #409eff}.r-preview-mask{display:flex;flex-flow:column nowrap;position:fixed;top:0;left:0;width:100%;height:100%;background-color:#00000073;z-index:1081}.r-preview-mask .r-preview-loading{position:absolute;top:30%;left:50%;transform:translate(-50%);display:flex;flex-flow:column;align-items:center}.r-preview-mask .r-preview-loading-text{color:var(--el-text-color-primary);font-size:16px}.r-preview-mask .r-preview-options{width:100%;pointer-events:auto;display:flex;flex-flow:row-reverse nowrap;align-items:center;justify-content:space-between;flex:0 0 68px}.r-preview-mask .r-preview-options-close{margin:14px;border:none;cursor:pointer;transition:all .3s;-webkit-user-select:none;user-select:none}.r-preview-mask .r-preview-options-false{flex:0 0 0px}.r-preview-mask .r-preview-contain{width:100%;margin:0 auto;display:flex;flex-flow:column nowrap;align-items:center;justify-content:center;flex:1;overflow:hidden}.r-preview-mask .r-preview-contain .r-preview-context{margin:0 auto;height:100%;display:flex;flex-flow:column nowrap;justify-content:flex-start;align-items:safe center;overflow:auto}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main{width:100%;height:100%;margin-bottom:10px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet{font-size:13px;line-height:normal;-webkit-user-select:none;user-select:none;-moz-user-select:none;font-family:Lato,Source Sans Pro,Roboto,Helvetica,Arial,sans-serif;box-sizing:content-box;background:#fff;-webkit-font-smoothing:antialiased}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet textarea{font:400 13px Arial,Lato,Source Sans Pro,Roboto,Helvetica,sans-serif}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-sheet{position:relative;overflow:hidden}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-table{vertical-align:bottom}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-tooltip{font-family:inherit;position:absolute;padding:5px 10px;color:#fff;border-radius:1px;background:#000;font-size:12px;z-index:201}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-tooltip:before{pointer-events:none;position:absolute;left:calc(50% - 4px);top:-4px;content:\"\";width:8px;height:8px;background:inherit;-webkit-transform:rotate(45deg);transform:rotate(45deg);z-index:1;box-shadow:1px 1px 3px -1px #0000004d}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-color-palette{padding:5px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-color-palette table{margin:0;padding:0;border-collapse:separate;border-spacing:2;background:#fff}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-color-palette table td{margin:0;cursor:pointer;border:1px solid transparent}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-color-palette table td:hover{border-color:#ddd}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-color-palette table td .x-spreadsheet-color-palette-cell{width:16px;height:16px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-border-palette{padding:6px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-border-palette table{margin:0;padding:0;border-collapse:separate;border-spacing:0;background:#fff;table-layout:fixed}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-border-palette table td{margin:0}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-border-palette .x-spreadsheet-border-palette-left{border-right:1px solid #eee;padding-right:6px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-border-palette .x-spreadsheet-border-palette-left .x-spreadsheet-border-palette-cell{width:30px;height:30px;cursor:pointer;text-align:center}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-border-palette .x-spreadsheet-border-palette-left .x-spreadsheet-border-palette-cell:hover{background-color:#eee}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-border-palette .x-spreadsheet-border-palette-right{padding-left:6px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-border-palette .x-spreadsheet-border-palette-right .x-spreadsheet-line-type{position:relative;left:0;top:-3px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-dropdown{position:relative}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-dropdown .x-spreadsheet-dropdown-content{position:absolute;z-index:200;background:#fff;box-shadow:1px 2px 5px 2px #33333326}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-dropdown.bottom-left .x-spreadsheet-dropdown-content{top:calc(100% + 5px);left:0}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-dropdown.bottom-right .x-spreadsheet-dropdown-content{top:calc(100% + 5px);right:0}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-dropdown.top-left .x-spreadsheet-dropdown-content{bottom:calc(100% + 5px);left:0}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-dropdown.top-right .x-spreadsheet-dropdown-content{bottom:calc(100% + 5px);right:0}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-dropdown .x-spreadsheet-dropdown-title{padding:0 5px;display:inline-block}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-resizer{position:absolute;z-index:11}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-resizer .x-spreadsheet-resizer-hover{background-color:#4b89ff40}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-resizer .x-spreadsheet-resizer-line{position:absolute}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-resizer.horizontal{cursor:row-resize}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-resizer.horizontal .x-spreadsheet-resizer-line{border-bottom:2px dashed #4b89ff;left:0;bottom:0}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-resizer.vertical{cursor:col-resize}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-resizer.vertical .x-spreadsheet-resizer-line{border-right:2px dashed #4b89ff;top:0;right:0}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-scrollbar{position:absolute;bottom:0;right:0;background-color:#f4f5f8;opacity:.9;z-index:12}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-scrollbar.horizontal{right:15px;overflow-x:scroll;overflow-y:hidden}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-scrollbar.horizontal>div{height:1px;background:#ddd}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-scrollbar.vertical{bottom:15px;overflow-x:hidden;overflow-y:scroll}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-scrollbar.vertical>div{width:1px;background:#ddd}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-overlayer{position:absolute;left:0;top:0;z-index:10}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-overlayer .x-spreadsheet-overlayer-content{position:absolute;overflow:hidden;pointer-events:none;width:100%;height:100%}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-editor,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-selector{box-sizing:content-box;position:absolute;overflow:hidden;pointer-events:none;top:0;left:0;width:100%;height:100%}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-selector .hide-input{position:absolute;z-index:0}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-selector .hide-input input{padding:0;width:0;border:none!important}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-selector .x-spreadsheet-selector-area{position:absolute;border:2px solid #4b89ff;background:#4b89ff1a;z-index:5}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-selector .x-spreadsheet-selector-clipboard,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-selector .x-spreadsheet-selector-autofill{position:absolute;background:transparent;z-index:100}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-selector .x-spreadsheet-selector-clipboard{border:2px dashed #4b89ff}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-selector .x-spreadsheet-selector-autofill{border:1px dashed rgba(0,0,0,.45)}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-selector .x-spreadsheet-selector-corner{pointer-events:auto;position:absolute;cursor:crosshair;font-size:0;height:5px;width:5px;right:-5px;bottom:-5px;border:2px solid #ffffff;background:#4b89ff}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-editor{z-index:20}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-editor .x-spreadsheet-editor-area{position:absolute;text-align:left;border:2px solid #4b89ff;line-height:0;z-index:100;pointer-events:auto}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-editor .x-spreadsheet-editor-area textarea{box-sizing:content-box;border:none;padding:0 3px;outline:none;resize:none;text-align:start;overflow-y:hidden;font:400 13px Arial,Lato,Source Sans Pro,Roboto,Helvetica,sans-serif;color:inherit;white-space:normal;word-wrap:break-word;line-height:22px;margin:0}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-editor .x-spreadsheet-editor-area .textline{overflow:hidden;visibility:hidden;position:fixed;top:0;left:0}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-item{-webkit-user-select:none;user-select:none;background:0;border:1px solid transparent;outline:none;height:26px;color:#000000e6;line-height:26px;list-style:none;padding:2px 10px;cursor:default;text-align:left;overflow:hidden}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-item.disabled{pointer-events:none;opacity:.5}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-item:hover,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-item.active{background:#0000000d}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-item.divider{height:0;padding:0;margin:5px 0;border:none;border-bottom:1px solid rgba(0,0,0,.1)}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-item .label{float:right;opacity:.65;font-size:1em}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-item.state,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-header.state{padding-left:35px!important;position:relative}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-item.state:before,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-header.state:before{content:\"\";position:absolute;width:10px;height:10px;left:12px;top:calc(50% - 5px);background:#00000014;border-radius:2px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-item.state.checked:before,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-header.state.checked:before{background:#4b89ff}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-checkbox{position:relative;display:inline-block;backface-visibility:hidden;outline:0;vertical-align:baseline;font-style:normal;font-size:1rem;line-height:1em}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-checkbox>input{position:absolute;top:0;left:0;opacity:0!important;outline:0;z-index:-1}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-suggest,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-contextmenu,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-sort-filter{position:absolute;box-shadow:1px 2px 5px 2px #33333326;background:#fff;z-index:100;width:260px;pointer-events:auto;overflow:auto}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-suggest{width:200px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-filter{border:1px solid #e9e9e9;font-size:12px;margin:10px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-filter .x-spreadsheet-header{padding:.5em .75em;background:#f8f8f9;border-bottom:1px solid #e9e9e9;border-left:1px solid transparent}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-filter .x-spreadsheet-body{height:200px;overflow-y:auto}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-filter .x-spreadsheet-body .x-spreadsheet-item{height:20px;line-height:20px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-sort-filter .x-spreadsheet-buttons{margin:10px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-bottombar{height:40px;padding:0 30px;text-align:left;background:#f5f6f7;display:flex}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-bottombar{position:relative;border-top:1px solid #e0e2e4}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-bottombar .x-spreadsheet-menu>li{line-height:40px;height:40px;padding-top:0;padding-bottom:0;vertical-align:middle;border-right:1px solid #e8eaed}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-menu{list-style:none;margin:0;padding:0;-webkit-user-select:none;user-select:none}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-menu>li{float:left;line-height:1.25em;padding:.785em 1em;margin:0;vertical-align:middle;text-align:left;font-weight:400;color:#80868b;white-space:nowrap;cursor:pointer;transition:all .3s;font-weight:700}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-menu>li.active{background-color:#fff;color:#000000a6}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-menu>li .x-spreadsheet-dropdown{display:inline-block}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-print{position:absolute;left:0;top:0;z-index:100;width:100%;height:100%;display:flex;flex-direction:column}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-print-bar{background:#424242;height:60px;line-height:60px;padding:0 30px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-print-bar .-title{color:#fff;font-weight:700;font-size:1.2em;float:left}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-print-bar .-right{float:right;margin-top:12px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-print-content{display:flex;flex:auto;flex-direction:row;background:#d0d0d0;height:calc(100% - 60px)}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-print-content .-sider{flex:0 0 300px;width:300px;border-left:2px solid #ccc;background:#fff}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-print-content .-content{flex:auto;overflow-x:auto;overflow-y:scroll;height:100%}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-canvas-card-wraper{margin:40px 20px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-canvas-card{background:#fff;margin:auto;page-break-before:auto;page-break-after:always;box-shadow:0 8px 10px 1px #00000024,0 3px 14px 3px #0000001f,0 4px 5px #0003}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-calendar{color:#000000a6;background:#fff;-webkit-user-select:none;user-select:none}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-calendar .calendar-header{font-weight:700;line-height:30px;text-align:center;width:100%;float:left;background:#f9fafb}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-calendar .calendar-header .calendar-header-left{padding-left:5px;float:left}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-calendar .calendar-header .calendar-header-right{float:right}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-calendar .calendar-header .calendar-header-right a{padding:3px 0;margin-right:2px;border-radius:2px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-calendar .calendar-header .calendar-header-right a:hover{background:#00000014}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-calendar .calendar-body{border-collapse:collapse;border-spacing:0}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-calendar .calendar-body th,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-calendar .calendar-body td{width:14.28571429%;min-width:32px;text-align:center;font-weight:700;line-height:30px;padding:0}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-calendar .calendar-body td>.cell:hover{background:#ecf6fd}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-calendar .calendar-body td>.cell.active,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-calendar .calendar-body td>.cell.active:hover{background:#ecf6fd;color:#2185d0}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-calendar .calendar-body td>.cell.disabled{pointer-events:none;opacity:.5}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-datepicker{box-shadow:2px 2px 5px #0003;position:absolute;left:0;top:calc(100% + 5px);z-index:10;width:auto}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-buttons{display:flex;justify-content:flex-end}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-buttons .x-spreadsheet-button{margin-left:8px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-button{display:inline-block;border-radius:3px;line-height:1em;min-height:1em;white-space:nowrap;text-align:center;cursor:pointer;font-size:1em;font-weight:700;padding:.75em 1em;color:#0009;background:#e0e1e2;text-decoration:none;font-family:Lato,proxima-nova,Helvetica Neue,Arial,sans-serif;outline:none;vertical-align:baseline;zoom:1;-webkit-user-select:none;user-select:none;transition:all .1s linear}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-button.active,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-button:hover{background-color:#c0c1c2;color:#000c}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-button.primary{color:#fff;background-color:#2185d0}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-button.primary:hover,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-button.primary.active{color:#fff;background-color:#1678c2}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-form-input{font-size:1em;position:relative;font-weight:400;display:inline-flex;color:#000000de}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-form-input input{z-index:1;margin:0;max-width:100%;flex:1 0 auto;outline:0;-webkit-tap-highlight-color:rgba(255,255,255,0);text-align:left;line-height:30px;height:30px;padding:0 8px;background:#fff;border:1px solid #e9e9e9;border-radius:3px;transition:box-shadow .1s ease,border-color .1s ease;box-shadow:inset 0 1px 2px #0a0a0a0f}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-form-input input:focus{border-color:#4b89ff;box-shadow:inset 0 1px 2px #4b89ff33}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-form-select{position:relative;display:inline-block;background:#fff;border:1px solid #e9e9e9;border-radius:2px;cursor:pointer;color:#000000de;-webkit-user-select:none;user-select:none;box-shadow:inset 0 1px 2px #0a0a0a0f}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-form-select .input-text{text-overflow:ellipsis;white-space:nowrap;min-width:60px;width:auto;height:30px;line-height:30px;padding:0 8px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-form-fields{display:flex;flex-direction:row;flex-wrap:wrap}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-form-fields .x-spreadsheet-form-field{flex:0 1 auto}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-form-fields .x-spreadsheet-form-field .label{display:inline-block;margin:0 10px 0 0}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-form-field{display:block;vertical-align:middle;margin-left:10px;margin-bottom:10px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-form-field:first-child{margin-left:0}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-form-field.error .x-spreadsheet-form-select,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-form-field.error input{border-color:#f04134}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-form-field .tip{color:#f04134;font-size:.9em}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-dimmer{display:none;position:absolute;top:0!important;left:0!important;width:100%;height:100%;text-align:center;vertical-align:middle;background-color:#0009;opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:.5s;animation-duration:.5s;transition:background-color .5s linear;-webkit-user-select:none;user-select:none;z-index:1000}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-dimmer.active{display:block;opacity:1}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main form fieldset{border:none}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main form fieldset label{display:block;margin-bottom:.5em;font-size:1em;color:#666}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main form fieldset select{font-size:1.1em;width:100%;background-color:#fff;border:none;border-bottom:2px solid #ddd;padding:.5em .85em;border-radius:2px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-modal,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-toast{font-size:13px;position:fixed;z-index:1001;text-align:left;line-height:1.25em;min-width:360px;color:#000000de;font-family:Lato,Source Sans Pro,Roboto,Helvetica,Arial,sans-serif;border-radius:4px;border:1px solid rgba(0,0,0,.1);background-color:#fff;background-clip:padding-box;box-shadow:#0003 0 2px 8px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-toast{background-color:#ffffffd9}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-modal-header,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-toast-header{font-weight:600;background-clip:padding-box;background-color:#ffffffd9;border-bottom:1px solid rgba(0,0,0,.05);border-radius:4px 4px 0 0}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-toast-header{color:#f2711c}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-modal-header{border-bottom:1px solid #e0e2e4;background:#00000014;font-size:1.0785em}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-modal-header,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-modal-content,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-toast-header,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-toast-content{padding:.75em 1em}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-menu li:first-child{display:none}.r-preview-mask .r-preview-contain .r-preview-context .docx-wrapper{background:none}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section{width:100%;height:690px;position:relative;border:1px solid #333;background-color:#efefef;text-align:center;border-radius:10px;box-shadow:1px 1px 3px #aaa;overflow:hidden}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section div.block{position:absolute;top:0;left:0;width:100%}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section div.content{display:flex;flex-direction:column}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section div.v-up{justify-content:flex-start}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section div.v-mid{justify-content:center}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section div.v-down{justify-content:flex-end}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section div.h-left{align-items:flex-start;text-align:left}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section div.h-mid{align-items:center;text-align:center}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section div.h-right{align-items:flex-end;text-align:right}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section div.up-left{justify-content:flex-start;align-items:flex-start;text-align:left}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section div.up-center{justify-content:flex-start;align-items:center}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section div.up-right{justify-content:flex-start;align-items:flex-end}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section div.center-left{justify-content:center;align-items:flex-start;text-align:left}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section div.center-center{justify-content:center;align-items:center}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section div.center-right{justify-content:center;align-items:flex-end}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section div.down-left{justify-content:flex-end;align-items:flex-start;text-align:left}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section div.down-center{justify-content:flex-end;align-items:center}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section div.down-right{justify-content:flex-end;align-items:flex-end}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main li.slide{margin:10px 0;font-size:18px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main div.footer{text-align:center}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section table{position:absolute}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section table,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section th,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section td{border:1px solid black}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section svg.drawing{position:absolute;overflow:visible}.r-preview-mask-contain{position:relative!important;width:100%!important;height:100%!important;background-color:#fff!important}@keyframes ranui-select-dropdown-down-in{0%{transform:scaleY(.8);transform-origin:100% 100%;opacity:0}to{transform:scaleY(1);transform-origin:100% 100%;opacity:1}}@keyframes ranui-select-dropdown-down-out{0%{transform:scaleY(1);transform-origin:100% 100%;opacity:1}to{transform:scaleY(.8);transform-origin:100% 100%;opacity:0}}@keyframes ranui-select-dropdown-up-in{0%{transform:scaleY(.8);transform-origin:0% 0%;opacity:0}to{transform:scaleY(1);transform-origin:0% 0%;opacity:1}}@keyframes ranui-select-dropdown-up-out{0%{transform:scaleY(1);transform-origin:0% 0%;opacity:1}to{transform:scaleY(.8);transform-origin:0% 0%;opacity:0}}.ran-select-dropdown-down-in{animation:ranui-select-dropdown-up-in .2s;animation-fill-mode:forwards}.ran-select-dropdown-down-out{animation:ranui-select-dropdown-up-out .2s;animation-fill-mode:forwards}.ran-select-dropdown-up-in{animation:ranui-select-dropdown-down-in .2s;animation-fill-mode:forwards}.ran-select-dropdown-up-out{animation:ranui-select-dropdown-down-out .2s;animation-fill-mode:forwards}.ranui-select-dropdown{position:absolute;transform-origin:var(--ran-x, 50%) var(--ran-y, 50%);box-sizing:border-box;margin:0;padding:4px;color:#000000e0;font-size:14px;list-style:none;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\",Segoe UI Symbol,\"Noto Color Emoji\";z-index:1050;overflow:hidden;font-variant:initial;background:#fff;border-radius:8px;outline:none;box-shadow:0 6px 16px #00000014,0 3px 6px -4px #0000001f,0 9px 28px 8px #0000000d;cursor:pointer}.ranui-select-dropdown-option-item{position:relative;display:block;padding:5px 12px;color:#000000e0;font-weight:400;font-size:14px;transition:background .3s ease;border-radius:4px}.ranui-select-dropdown-option-item:hover{background-color:#0000000a}.ranui-select-dropdown-option-item-content{overflow:hidden;white-space:nowrap;text-overflow:ellipsis;color:#000000e0;font-size:14px;line-height:1.57142857;box-sizing:border-box;list-style:none;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\",Segoe UI Symbol,\"Noto Color Emoji\";font-variant:initial}.ranui-select-dropdown-option-active{background-color:#e6f7ff;font-weight:700}.ranui-select-dropdown-option-active:hover{background-color:#e6f7ff}@keyframes loading{2.04%{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAYAAACtWK6eAAAACXBIWXMAAAABAAAAAQBPJcTWAAAAJHpUWHRDcmVhdG9yAAAImXNMyU9KVXBMK0ktUnBNS0tNLikGAEF6Bs5qehXFAAAQM0lEQVR4nO2de5CXVRnHP3sRFBUML6FugC6I5jqKkKiUrBMXDW1qpvGWJo33UmuyBBStBC856kxqiplGWmq30QlBbuV6Qy0JGW6iLIqudwXBS4Lsbn887LTB7vnd3uec877v85nZgT+W7zn83vf7e87lOc+pam9vxzCMrqkO3QHDiBkziGE4MIMYhgMziGE4MIMYhgMziGE4MIMYhgMziGE4MIMYhgMziGE4MIMYhgMziGE4MIMYhgMziGE4MIMYhgMziGE4MIMYhgMziGE4MIMYhgMziGE4MIMYhgMziGE4MIMYhgMziGE4MIMYhgMziGE4MIMYhgMziGE4qA3dgZzSE9gD2BP4DHgLeD9oj4wuMYPo0Qs4GGjY+rM/sB/QH/hcF7+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6C3WxtrwO9K46GYAp1GQnYBZ0R1kQ2p0vanlWOeRPSlZOEB3kI1thfVo6hd7IImYiC33z/pIisLQHWRDi4FzYg8iAa9i3zWOosThAAWkIxOwd/tlNBf7pjGChNuB5klTrM6dDdyE/6ExKWjDDq9J5nTZVCggYcOwE6/GxB6IkyeBG7ADcurdyNWQFJDKDAXOAk4H+kQeS73mAXdiTeOSOU02VQpIdbphnUJOAcbiexxylhYC47GmEk9S/+ldpaGA1K4H1iFwLLaHPZUOImvNxM7emIC1JlIoaqCAZOcz2MlWo4DPYwf/tOR07ZXYTr4p2Dqpp4H/5HTthqaA+NkMe126B7Z8ZVesG8kAwj22QuZhP/hzseeHmVhPrqkUoFN6ESkgcfQAtlnvTyt2gM36FmDLPD7ClpZ/gKZJuVNARAL0JV0kQAERCVBARAIUEJEABUQkQAERCVBARAIUEJEABUQkQAERCVBARAIUEJEABUQkQAERCVBARAIUEJEABUQkQAERCVBARAIUEJEABUQkQAERCVBARAIUEJEABUQkQAERCVBARAIUEJGA/wGoO9WRqPBNhgAAAABJRU5ErkJggg==)}8.16%{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAYAAACtWK6eAAAACXBIWXMAAAABAAAAAQBPJcTWAAAAJHpUWHRDcmVhdG9yAAAImXNMyU9KVXBMK0ktUnBNS0tNLikGAEF6Bs5qehXFAAAOF0lEQVR4nO3de5Cf0x3H8fcmu6tKhURQIlpEiohbqlH3S6Kson9kqDJtelFaOnQGMWgN6tqpGepS01KDDtWpSyVt4l631J2wCbooqYoSkhYlt/7x3ZVNbM4+v98+3+ec53k+r5nfrHE5z8naz57nOec839OybNkyRKRvg2J3QCRlCohIgAIiEqCAiAQoICIBCohIgAIiEqCAiAQoICIBCohIgAIiEqCAiAQoICIBCohIgAIiEqCAiAQoICIBCohIgAIiEqCAiAQoICIBCohIgAIiEqCAiAQoICIBCohIgAIiEqCAiAS0xu5AjQ0D1u3+tHX/vcHAZ7r/+r/AO8C7vb4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HX5rcFjKcpj0QOoonYNSJ8ngQOBA6h3i5/ngUXRg6iidg9In9uwJ11HYaGpm2vQF34zaYd9kGYNA44ETqEeLz6+jrVwXRw9kCrSDPJ2q7Gjsztib8POjB1Oy76NwpGZZpDGjMPe6/oM1dqRvwk4FJ00zEwBaU4nsDfWeuhQyt3k+nrgk9gTO8lIAcmuE2v5sz+wL+V5lWMFtsdzMboxb5kCkp+xwJ7Arthu/U7YDX8RurDDUdcBP8NapUoOFBA/I7BZZSL2FGki1nxhc+w+ptmvWfUAS4CnsQ6Ti7AzHvN7/34zl1HLAApIjGHAxtg9zMjeP6MG/cxr2HJpee/fL6MQFE4BEUnQPohIggIikqCAiCQoICIJCohIggIikqCAiCQoICIJCohIggIikqCAiCQoICIJCohIggIikqCAiCQoICIJCohIggIikqCAiCQoICIJCohIggIikqCAiCQoICIJCohIggIikqCAiCQoICIJ/wXQTHy71qwxPwAAAABJRU5ErkJggg==)}20.41%{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAYAAACtWK6eAAAACXBIWXMAAAABAAAAAQBPJcTWAAAAJHpUWHRDcmVhdG9yAAAImXNMyU9KVXBMK0ktUnBNS0tNLikGAEF6Bs5qehXFAAAMaUlEQVR4nO3de9BVVRnH8e8LCugEYqII0RUVEG9o5o3KUUlkvI3aOE46MeO1sWZsbLz1hzpTXmqamkkb791snCYta1AkTSzAMhEJURAxi4iLGoqYgeD79scjyTSyzj7n3c9+1t7n9/nPP3jWGuF31tp7rb1WT19fHyLy/gZEd0AkZwqISIICIpKggIgkKCAiCQqISIICIpKggIgkKCAiCQqISIICIpKggIgkKCAiCQqISIICIpKggIgkKCAiCQqISIICIpKggIgkKCAiCQqISIICIpKggIgkKCAiCQqISIICIpKggIgkKCAiCTtEd0CSRgGnA5OBscBgYCPwd2ApsAxYAiwC3g7qY6P16PqDLI0GvgmcTbEfsbexkDwF/AF4FFjj1rsuooDk5wTgbuCD/azzPDALuB+YA2zpZ72upIDk5Q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6eAPYlXqOgI3R9BFkq5XYlOUa7GC6OhhGPdd1GqVbAgLvndh4BLaSXQejozvQ7bopIFvNBw7CRpNNsV1pSdvog3VjQMCCcS22f+u3wX1JeTm6A92uWx7SW5kKfAvYP7oj29gEDEX7s0J16wjy/x7Cpl3TsYvtczAbhSOcAvKeXuDHwHjsHK4lsd3RfYo50BRr+wZgU6+vYFtXqnxgXggcgtZAwikgxewNnA+cDYxybmsj9ip6oXM7UoAC0p6BwLFYUE7EVrrL1AucCdxbcl3pkALSuR2w1flTsSnYuH7WW4cFb2Y/60iJFJDy7AkcA3wGe344ABhU4M9tAe4Gvo6+AcmOAuJnEBaSCcA+2Nuxj2KXAW3CXifPxa6kXh3UR2lBARFJ0DqISIICIpKggIgkKCAiCQqISIICIpKggIgkKCAiCQqISIICIpKggIgkKCAiCQqISIICIpKggIgkKCAiCQqISIICIpKggIgkKCAiCQqISIICIpKggIgkKCAiCQqISIICIpKggIgkKCAiCQqISMJ/AQTLWspwuVXaAAAAAElFTkSuQmCC)}22.45%{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAYAAACtWK6eAAAACXBIWXMAAAABAAAAAQBPJcTWAAAAJHpUWHRDcmVhdG9yAAAImXNMyU9KVXBMK0ktUnBNS0tNLikGAEF6Bs5qehXFAAAL4ElEQVR4nO3daaxdVRnG8X8HoMxShtRSBiFQCkhpwCJDBYoyCFgUTABDhFACRmOQKBBCQCgRSYxBjAmIiBOIiAIOFKkiBIIiVAppoRWLgAxlsKVQLJX2Xj+8PdqG23XPud3vetfe+/kl91Obd617z37O2tNaa1h/fz8iMrDh0R0QKZkCIpKggIgkKCAiCQqISIICIpKggIgkKCAiCQqISIICIpKggIgkKCAiCQqISIICIpKggIgkKCAiCQqISIICIpKggIgkKCAiCQqISIICIpKggIgkKCAiCQqISIICIpKggIgkKCAiCQqISIICIpKggIgkKCAiCQqISIICIpIwMroDktVYYG9gDNAHvATMARZHdqpkCkjzbQxMB84EJg7w7/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ef/FrcCXlbfsBG4Bnqu8o5d8DtKNc4HLgNMpdy/ZBWyhnGDcSnlotoN/z8jPBo6kXON1IuVGD4uBJZTL1uc2PO6rwP306xzNQfmOQh3MYuBC4GLgAko4RwO7ga8pD+9epNzIYewYiBT4KpY0IgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECmbVHjAmlgE3AcuBpcDRwG7gG+AD4D3gfWBTrYGanokuDzY5Odnl4bqwFHgUuKbh1/8GfE4JZxPwI7AN+An4E9g59XWzgHnAfGABsBA4CThm6mu+AtYAH7fxh+ibiYnu/tsayPTdDDwNzK644UvgIeAF4O+KOzplIKPvduDZ2iP2sYYS7A+1h3TBQEbb+cA64IjaQ/azGVgBbKw9ZNgMZHTNAD4Bzqo95AA2ABcA22sPGaYuA/Fl3sFcz+jGAeVFg4drjxgnBjKY22oPaOAu4IzaI8aFgTQ3E7ii9ogGZlAiUQsMpLlTqPuS7iCurT1gXBhIc/NrDxjAUsqJRh0iA2mubyfiFtYeMA4MpLnvaw8YkNfZtcBAmvuZfl1suKX2gHFgIINZVXtAQ1soF0DqEBnIYB4D9tYe0cAbtQeMCwMZzAbg8dojGniy9oBx4bVYg5tDeQPUstpDDuBNYGXtEcPkxYqjbxHwNnBa7SH72Q6cB3xbe8gwebHi6NsMXASsrj1kH7uAGxnzOLpmINP3C3Ad5bKOtZW3bAWuBl6vvGPs+BCrPYuAy4FLpj6WUS5wHKY9wDPAA5TzNIcFn4OMh6OAM4GzKZefLwFOpVz0eOI0f8+tlBs9rAfeBV6e+txhxUDG30zgBEoox1LuVjKP/z7k3Um5C8oO4FdKCHu6nTmaDEQKfBVLGhEGIgUGIgUGIgUGIgUGIgUGIgUGIgUGIgUGIgUGIgUGIgUGIgUGIgUGIgUGIgUGIgUGIgUGIgUGIgUGIgUGIgUGIgUGIgUGIgUGIgUGIgUGIgX/ACtN2/R85LfmAAAAAElFTkSuQmCC)}40.82%{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAYAAACtWK6eAAAACXBIWXMAAAABAAAAAQBPJcTWAAAAJHpUWHRDcmVhdG9yAAAImXNMyU9KVXBMK0ktUnBNS0tNLikGAEF6Bs5qehXFAAAGXUlEQVR4nO3dW6ilYxzH8e8ae5TzqbiYDDKGRCQihZwmkkJKDnHhxoXTBckFMlNKXIxwqRwGiVCIyAgRJZkGySGnXFDDOGdmWC7epdkze83P3rP3ep9n7ff7qXWzZ+33+Tezv/s9rHfN6jFEv98f9mVpXuv1elO+tqDAHNLYMBApMBApMBApMBApMBApMBApMBApMBApMBApMBApMBApMBApMBApMBApMBApMBApMBApMBApMBApMBApMBApMBApMBApMBApMBApMBApMBApMBApmCg9gGZkB+BIYAmwK/An8DmwFthQcK55y0DGwxLgBuAiYM8hf74BeB94d/B4A/iutenmsakfiICfD1KRhcBy4EaavcdMrAFeHDzeBjbN7Wjzz7DPBzGQeu0GPAucNgfbWg88BawC3gT+mYNtzjsGMj52oPnNf+YItv0N8BjwAM35iwYMZHzcDNwx4jX6wAvASuDVEa81FgxkPOwHfAns1OKaHwJ30uxZOnv45WcUjoeraDcOgCOAR2hO5g9qee2quQepz1qaH9hS1gGn01wF6xQPseq3G/Az2/h3adEPwLHAt4XnaJWHWPVbTPk4APYFHio9RA0MpC4LSw8wyanAOaWHKM1A6vJH6QG2ck3pAUrzHKQuC4HfqWdPsgnYB/il9CBt8BykfhtpLrXWYgI4pvQQJRlIfR4uPcBWFpUeoCQDqc8qmvulalHL4V4RBlKfDcDVpYeY5KfSA5RkIHV6DlhReoiBj0sPUJKB1OtW4LbCM3wNfFZ4hqIMpG7LgWWU+yF9sNC61fB1kPEwAZwHXAycQvPaxKitBw4GfmxhrSp4s+L8cQhwPHACzZ23h41gjSuo75LzSBnI/HUgzX1T59O8h322NzzeA1w/y22MHQPphkXApcCVwNLt+P4VNBcHOvdDYCDd0gPOotkTLJvG8z8YPPf1UQ5VMwPprqU0e5VTgUNp/vO532jeEPUW8DSwmg7uNSYzECnwbl5phgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxkuB5wOnA/sAZYB/wFfA+8AdwOLC02nVrTG/bFfr/f9hw1OQVYCRw9jee+PHjuS0Cn/9Lmg15vag4GslmPZs9wy3Z876fAA8CjwHdzOZTaYyDZSuC6WW6jD6wGngFeAL6a5fbUIgPZtsuBh0aw3U+AV4F3gHeBz0awhuaIgQy3N/AFsGcLa60DXgceB54FNrWwpqZpWCBexYJraScOgH2AC4AngY+BM1taV9vJPUhznnBAwfVvA5YXXF8D7kGmOoSycUBz5cxAKtX1QA4vPcDALcC5pYfQVF0PZK/SA0xyH7Bj6SG0pa4HsrH0AJMsBi4rPYS21PVAanvV+/LSA2hLXb+KtTvNaxMTpQcZ2AjsQl17ts7wKtZUv9C80l2LhcBBpYfQZl0PBODe0gNsZefSA2gzA2luKnyt9BCTeHhVka6fg/xnf+A9YN/Cc/SBPYBfC8/RSZ6DbNu3wDKaE/aSPsI4qmIgm60BjqO5Lb2UpwqurSE8xJpqAXAJcBNwRIvr/klzBev7FtfUJB5iTc8/wCrgSOAM4Hnaeb/5CoyjOu5BpmcJcCXNnmXxCLb/CnA28PcItq1p8h2Fs7cAOInmnqkLmZs3Wq0GzsOT8+IMZG5NACfS/OY/Gzhqht//N3AXcCu+9lEFAxmtRcDJwPGDxzEMv319PfAEcDfweWvT6X8ZSLt2pDnRXwLsBPxGE8RaPNeokoFIgZd5pRkyECkwECkwECkwECkwECkwECkwECkwECkwECkwECkwECkwECkwECkwECkwECkwECkwECkwECkwECkwECkwECkwECkwECkwECkwECkwECkwECkwECn4F109/5jz2BfBAAAAAElFTkSuQmCC)}42.86%{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAYAAACtWK6eAAAACXBIWXMAAAABAAAAAQBPJcTWAAAAJHpUWHRDcmVhdG9yAAAImXNMyU9KVXBMK0ktUnBNS0tNLikGAEF6Bs5qehXFAAAGGklEQVR4nO3dR4hdVRzH8e/EKLZNrFhAsxAxlgQLBOwLRbAgiBtBEQyxFxCN2FYq6kKwRiSCKLoJLiIKRhciKgQbCZaQuFBh1KjRIFgGS8bFNTDI8HPie/fc9879frZ5c/5n8+Xcm7n3zcT09DSSZjev6w1Io8xApMBApMBApMBApMBApMBApMBApMBApMBApMBApMBApMBApMBApMBApMBApMBApMBApMBApMBApMBApMBApMBApMBApMBApMBApMBApMBApMBApMBApMBApMBApMBApMBApMBApGB+1xtQUQuBC4ATgEOAXYAfgY+B14F3gO2d7W4ETfhHPHvhOOAB4Jz/+Nxm4B7geQwFMJA+uBW4j+a0mKsNwApgbSs7GiMGUreHgRsG+PlXgOuBz4eznfHjTXq9rmOwOADOBT4F7gJ2HXhHY8gTpE6HAxuB3Ye45gbgcmD9ENcceZ4gdbqT4cYBsBh4j+Y02Zn7mbHmCVKfvYHvGX4gM70FXAJMtjhjJHiC1OcM2o0D4FSaS61TWp7TOQOpz5JCc/YFXgOWFprXCQOpz34FZ+0BvAgsKDizKAPRoA4G7u16E20xkPp818HMZZQ9uYoxkPp08XuKXYGLO5jbOgOpz5vALx3MPbODma0zkPr8A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qF3pOBsVaS2l3lHG6b5yPrSArPvAI4VmKvK1HqCQPN+xUrgcMtzP8M4NKLmQKD5fvOHafeWyA8t6l+1BwLNK1pLaCeS94EDLczRgKj5GWSsOTQ/1WTRFK8/QHMaXWptR6reIJwgXaeBxcDBKVy7C3gE49AYgxQIwBngIeBZJvZm4jGab8B6Cn/CicYxSLdYY10PPEbzMvDdNLdgf9N8P8k3wF5gH/5UEwWDHIg0bYN2iyW1ykCkwECkwECkwECkwECkwECkwECkwECkwECkwECkwECkwECkwECkwECkwECkwECkwECkwECkwECkwECkwECkwECkwECkwECkwECkwECkwECkwECkwECkwECkwECkwECkwECkwECkwECkwECkwECkwECkwECkwECkwECkwECkwECkwECk4B9ond6XzYmBagAAAABJRU5ErkJggg==)}46.94%{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAYAAACtWK6eAAAACXBIWXMAAAABAAAAAQBPJcTWAAAAJHpUWHRDcmVhdG9yAAAImXNMyU9KVXBMK0ktUnBNS0tNLikGAEF6Bs5qehXFAAAFj0lEQVR4nO3dS6iUZQCH8eeY6EKiCFuVKWUYZkVRBNXpAkEZQVBQdCHIRUREUuQyirZFF4qWYdFlEQVtilzYRYnACKyUIpM8JgRpGNFCJafFlxuTfzPf977Od2ae30rwzJ93cZ4zl2/OmZnBYICkE1sw7gNIfWYgUmAgUmAgUmAgUmAgUmAgUmAgUmAgUmAgUmAgUmAgUmAgUmAgUmAgUmAgUmAgUmAgUmAgUmAgUmAgUmAgUmAgUmAgUmAgUmAgUmAgUmAgUmAgUmAgUmAgUmAgUmAgUmAgUmAgUmAgUmAgUmAgUmAgUmAgUmAgUmAgUmAgUmAgUmAgUmAgUmAgUmAgUmAgUmAgUmAgUmAgUmAgUmAgUmAgUmAgUmAgUmAgUrBw3AfQRJkF7gCuApYDi4E/gB+AT4B3gJ/Hdbg2ZgaDwbjPoPnvGuAF4PL/+boB8BawAfi19qFKMBB1MQM8CTz977+HdQC4E9hc4UxFGYi6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WZNrWcg9zaet7HxPGZ3V+N5dzaeN7Fef2KdlOHZxiw35sfyZZKzGs5jNsdleK6xmPvKv7M+w1vAS6rXb5AL0zaOJDkzf334RB/r0z6OJDl/hJn/qFcgp48097SR5jK5sX5IrR1pbqlXIGNtcVk50lwm98tIc38daW6pVyD7Rpq7d6S5TG73SHO7POfqFcinI8w8kOSrEeYynb0Z3jBp6WCSjxvPnEivQHYm2dF45vvpvG+HP21tPO/dJD80njmRns9BXmo878XG85jdc43nPd943sR6bjVZl+GMx5oGs75IckHGu0Fkeq9n2OGwWNuSXJ7ktwazptbzN8ieJA82mrUp4pg3m7P4G/YDSe5OpziS/mfSn82wpXkxHslwypD5sivDUYb9M15/MMN+vY+arWgGvQNJhj1UW2a4biHDeYMn2i6HhrYluSLDzt5p7Mxwzuet5iua0jwEcijJfUluz+R7bXYkuTbJk2Mtima2Zziv81iG49KVH5M8neSiDO9Kdtf7wNTRVmUI5dYM/7Rh9RFf25vhRXs5wwnELk9WWZQTMhykuirDGY+1GTY2fp7hnzZsPfz53Ji3QI62LsnJSb45/AFLat4Dga7m4R4E5pZAoCAQKAgECgKBgkCgIBAoCAQKAoGCQKAgECgIBAoCgYJAoCAQKAgECgKBgkCgIBAoCAQKAoGCQKAgECgIBAoCgYJAoCAQKAgECgKBgkCgIBAoCAQKAoGCQKAgECgIBAoCgYJAoCAQKAgECgKBgkAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAPjv+R02e5WvOhUGtgAAAABJRU5ErkJggg==)}53.06%{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAYAAACtWK6eAAAACXBIWXMAAAABAAAAAQBPJcTWAAAAJHpUWHRDcmVhdG9yAAAImXNMyU9KVXBMK0ktUnBNS0tNLikGAEF6Bs5qehXFAAAFEElEQVR4nO3dTehlcxzH8c8wiIXyEAkRIrKgmISQsCDJUvKwsNJEQllLUh6ahZqlLGRhYeNhYSJCoqZRIjKiIZkI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mI+s3l9x2DOFd5vygDUb+ZPmM1V99V3i/KQNRvQcXtHt0nfZthIOp3oeL2AeBsxf3iDET9TlXavQq8Xmm7GgNRv6OVdrcDP1barsaPmqjfPOAXYHnBzT3AloJ7Q+MdRP0mgTcK7h0FthXcGyrvIJrKBN13ytfMcecE3XdBLs75RCNiIJrOEuAbYMUsrz8FPAz8WexEI+AjlqZzAVgFHJvFtd8yBnGAgSg7DzwEvAZcGuD1F4FXgUcYgzjARywNbhGwie5rs/fSPYLdAPwBfA8covsTP4OE1AwDkQIfsaTAQKTAQKTAQKTAQKTAQKTAQKTAQKTAQKTAQKTAQKTAQKTAQKTAQKTAQKTAQKTAQKTAQKTAQKTAQKTAQKTAQKTAQKTAQKTAQKTAQKTAQKTAQKTAQKTAQKTAQKTAQKTAQKTAQKTAQKTAQKTAQKTAQKTAQKTAQKTAQKTAQKTAQKTAQKTAQKTAQKTAQKTgH82MsyJpg53RAAAAAElFTkSuQmCC)}59.18%{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAYAAACtWK6eAAAACXBIWXMAAAABAAAAAQBPJcTWAAAAJHpUWHRDcmVhdG9yAAAImXNMyU9KVXBMK0ktUnBNS0tNLikGAEF6Bs5qehXFAAAFz0lEQVR4nO3dS6hVVRzH8a9pmdKkN2VEJUlRYhSGI4lsUoFJDaJCKirpQUTmwIJqGkRBI0mCsrKQJtagcCCVNIhedDGIDC1CC/LRpCzzcRvsBAfxy+vde5191/5+xves/wLv17X3OWfrtPHxcST9t5NGvQGpzwxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgxECgykMR94HvgC+AMYBw4C24H1wK3AjJHtTiMzbeD/DfRc4EVg6XH87A7gCWBjpztSrww1kJOBJ4GngJkTfO0a4FHgcNubUv8MMZCrgNeABZNY4w3gbppLMVVsSPcg04Gngc+ZX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kwECkwECkwECkwECkwECkwECkwECkwECkwECkwECkwECkwECkwECkwECkwECkwECkwECkwECkwECkwECkwECkwECkwECkwECkwECkwECkwECkwECkwECkwECkwECkwECkwECkwECkwECkwECkwECkwECkwECkYO/SA3rUbOBs4ATgAOA34AtgNbCj3Cx1moHUczGwDLiEsY++O4FVwPPACmBj96apCQNT/QBDQ0Od2NF2s4HHgCU13+8z4J3ht3epjjLqooGBqf0XN5CJzQHeAE7swMf6DVgPrAO+Ab4DNgPbgL+AP4f/3l7AQcAfwFfAlg489rRkIM2aCbwPLCy8YyPwHPAI8GXhLT3FQJr1BHBD6RF72AU8DNzByNFGgYE051TgIzrwOWrAGmAxPvWa0FQD8XWQ8d1CO+MAOI3q+6KZpYf0O48gYxuk+ub50NJDJrAcuLb0iDbzKVYz5tE7P5K9EFhZekRb+RSrGXNLD6jh9tID+pmBjG3f0gNqWEz7nwr2LAMZ29bSA2oYBM4qPaJfGcjY1pceUNP80gP6lYGM7Wfgw9IjaphVekC/MpDxPVV6QA2/lB7QrwxkfI8D35ceMUmen9UQAxnf78DS0iMmYTfVqfRqgIFkK4B7So+YwOvAT6VH9CsDmdhdwJ1AW08ZeKD0gH5mIJNzH3A+1Vm0bfIs8GrpEf3Mc7HqGaS6Lv064ArK/nh1A9ULhNsLbmg9T1YsZx+qEwUvBy4DFnTxsdcClwKbuviYPclA2mMOcAFwHnAGcAqdv2vMENXNI5YBv3b4Y/clA2mvfYFFo96OpwrpCKobM0zWD4xck762szP7m4H0pkHgSOBwYAawP9XVgf/90GQX1RFiJ/At1R1Q9D8YiBR4wZTUIAORAgORAgORAgORAgORAgORAgORAgORAgORAgORAgORAgORAgORAgORAgORAgORAgORAgORAgORAgORAgORAgORAgORAgORAgORAgORAgORgn8BLyjxnaJDDwEAAAAASUVORK5CYII=)}67.35%{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAYAAACtWK6eAAAACXBIWXMAAAABAAAAAQBPJcTWAAAAJHpUWH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/vZWXoAhUEMBOJF4neJx6o17tlyy3wlBjWQXZ4DzgJOJhbztXii9AAKgx7ILquJDY4XABsLzwJwb+kBFAZxkT6RacB5xBqlxEL+X8D+wOsFzq338Aryv0aJTwQuIF4yPtDj81+HcVTDK8jkHAQsAy4E9u3ieR4i1kN+AUQlDKQz04GTgK8CZwIfbPDY64BTcA9WVQzk/7cHcALx8d5TgEOmcKy7ga8Br019LDXJQJqzP/B5YkvLQuAwYM8J/syTwDXEt8mrQgbSPTOAecARxN6qTxAfhnqReJS8mrrevWgcBiIlfMwrJQxEShiIlDAQKWEgUsJApISBSAkDkRIGIiUMREoYiJQwEClhIFLCQKSEgUgJA5ESBiIlDERKGIiUMBApYSBSwkCkhIFICQOREgYiJQxEShiIlDAQKWEgUuJtHEpN14taYyIAAAAASUVORK5CYII=)}69.39%{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAYAAACtWK6eAAAACXBIWXMAAAABAAAAAQBPJcTWAAAAJHpUWHRDcmVhdG9yAAAImXNMyU9KVXBMK0ktUnBNS0tNLikGAEF6Bs5qehXFAAAIjklEQVR4nO3df6jddR3H8eeuc7rWnITLiDWVNLEUmdRAoeEiZ24ilWCFFmUlRjOzRZOosIJMCcrK8Aca5YY0FC1MKjcspRk6HDF1yTZkcwiyqDvdpm3u3v743BuX293be875fr+f8/me5wPEP3bv5/1m+jrvz/d8z+d7ZoyOjiJpakO5G5D6mQGRAgZEChgQKWBApIABkQIGRAoYEClgQKSAAZECBkQKGBApYECkgAGRAgZEChgQKWBApIABkQIGRAoYEClgQKSAAZECBkQKGBApYECkgAGRAgZEChgQKWBApIABkQIGRAoYEClgQNrlfcCNwBPAv4FR4ADwHHAXsAKYma27As3wG6ZaYSFwC/DRafzsy8AaUmC21tlUGxiQ8i0H7gWO6+J3HwF+DjwEjFTZVFsYkLKtAB4Aju5xna3ATcBa4I1em2oTA1Ku04DNwJwK13wBuIG0BXOi4EV6yX5BteEAOAX4FfB30tZt4D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NES6230D6Sulq7Kf9NGXbRWuqYYM+gSZaAT4NfAe0te0ba1gzUPAJzAcxXKCHNkQ6SzHStLTFjv1CvAp4OEqm1KzDMj0nAF8nrQFm84jhx4EriU98E4FMyCdmQlcCHwcOBc4mfQExmHgH8CfgTXAs3naU9UMiBTwIl0KGBApYECkgAGRAgZEChgQKWBApIABkQIGRAoYEClgQKSAAZECBkQKGBApYECkgAGRAgZEChgQKWBApIABkQIGRAoYEClgQKSAAZECBkQKGBApYECkgAGRAgZEChgQKWBApIABkQL/BUc+hdEKzAiuAAAAAElFTkSuQmCC)}71.43%{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAYAAACtWK6eAAAACXBIWXMAAAABAAAAAQBPJcTWAAAAJHpUWHRDcmVhdG9yAAAImXNMyU9KVXBMK0ktUnBNS0tNLikGAEF6Bs5qehXFAAAJkUlEQVR4nO3dfcxXZR3H8TcC4uyBHjDI2aqxigebC3UxpdIyZDq25qLHLaVIcz2YtVJqK2prin/kWmWplau1HjbXKpOAKI3ULNByKVLmqsUISWpIKQje9MeXe7tz9y5+D+c65/qd8379xQb393v+4HNf1znXua4z5fDhw0ia3DFNX4BUMgMiJRgQKcGASAkGREowIFKCAZESDIiUYECkBAMiJRgQKcGASAkGREowIFKCAZESDIiUYECkBAMiJRgQKcGASAkGREowIFKCAZESDIiUYECkBAMiJRgQKcGASAkGREowIFKCAZESDIiUYECkBAMiJRgQKcGASAnTmr4ANeZ44HTgFUf+/CTwF+A3wL8avK6iGJDuOQX4OHABcNwkfz8GbAKuBdbXeF1FmuJnoDvjWOAa4EPAlB5/Zj3wAeDhXBdVOgPSDc8CfgqcOcDPHgDWAlcB+6u8qFFgQNpvKnArcO6QdbYBFwJbh76iEeJTrPa7nOHDAbAA+DWwBpheQb2R4AjSbrOAvwLPqLjuXcBbgR0V1y2OI0i7raT6cACcAfweWJqhdlEMSLtdkLH284mnXFdk7NE4p1jtNR14nHrWum4C3kcsNraKI0h7zaG+he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bRvgO4nwrsg5sjBcTPrti5e6dh52542og9mp0PPADMo2IbtOVKAfHXBxyHLSaaCkzERpZ2nyAOYC8klwMvAs9i54ovAp7C3nhLwRSQGL3Ah7HdScZik/qtJ/brsAVIrwGvYuHI8hy/OlNARBL0olAkQQERSVBARBIUEJEEBUQkQQERSVBARBIUEJEEBUQkQQERSVBARBIUEJEEBUQkQQERSVBARBIUEJEEBUQkQQERSVBARBIUEJEEBUQkQQERSVBARBIUEJEEBUQkQQERSVBARBIUEJGE/wMkpE6tIAqrOgAAAABJRU5ErkJggg==)}85.71%{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAYAAACtWK6eAAAACXBIWXMAAAABAAAAAQBPJcTWAAAAJHpUWHRDcmVhdG9yAAAImXNMyU9KVXBMK0ktUnBNS0tNLikGAEF6Bs5qehXFAAAMfklEQVR4nO3de7BWVRnH8e974HhpVERBkTBRNIwQNUPRQRTRLlI5WtJoMjXYYDU6pdaQlWl003HMsbKIUavRKfOSWl4iQAEZNJRAINQAxTIURMDLIAad0x/PoQ5wWOe97LWftd/9+8ycOf/A2s+B93fWWnuvvValvb0dEelai3cBIilTQEQCFBCRAAVEJEABEQlQQEQCFBCRAAVEJEABEQlQQEQCFBCRAAVEJEABEQlQQEQCFBCRAAVEJEABEQlQQEQCFBCRAAVEJEABEQlQQEQCFBCRAAVEJEABEQlQQEQCFBCRAAVEJKCndwEltQfQu9PXPsDuO/yZ14G3gU3AOmAtsDXHGgUFJKbdgCHA0cBRwMCOr0OAPnW0146FZDXwArAM+HvH96XAO40WLDur6PiDzPQHRgGnACdh4cjrF9AWYBEwH3gceAR4OadrNzUFpH49gZHAWcBY4AjfcnayFJgOPAjMRsOzuiggtWkBTgPGAx/H5g9FsAG4F7gLmIHCUjUFpDpHABOwYLzbuZZGvQzc2vH1vHMtyVNAdq0CjAG+jA2hKr7lZK4dG4Jd3/FdH4QuKCA7awHGAd8EhjrXkpfFwHXAHWj4tR0F5P+2BePbw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D8j3qQXatg73Jf3vG94ltO5tqxtx5vxJ5n6IPQBQWkOodhOwFOwN75LrJ/Abdh66eWO9eSPAWkNj2xd77PBc4GevuWU7UN2DFqt2GvF2sIVSUFpH49sXfCx2JDsKG+5exkOTaEuh9bGqJnPXVQQLJzELal5onA8dimc605XXsrsAzbHGI2drOhFEtBYlNA4tkd61WGAO/t+H4o0B84gPom/euAF4FVHV9LsCUgyyjotjqpU0B89MRC0gc7e3xPbBeTzt7BdkHZ0Olrc441CgqISJAeFIoEKCAiAQqISIACIhKggIgEKCAiAQqISIACIhKggIgEKCAiAQqISIACIhKggIgEKCAiAQqISIACIhKggIgEKCAiAQqISIACIhKggIgEKCAiAQqISIACIhKggIgEKCAiAQqISIACIhLwX0RtpuHcxjHsAAAAAElFTkSuQmCC)}87.76%{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAYAAACtWK6eAAAACXBIWXMAAAABAAAAAQBPJcTWAAAAJHpUWHRDcmVhdG9yAAAImXNMyU9KVXBMK0ktUnBNS0tNLikGAEF6Bs5qehXFAAANVUlEQVR4nO3de7CXRR3H8ffvHOBo6IgmiEoqgRcUFTALNcsbaorgVJqXUcsUtLS0nDRLxzFRUtIaNK9DjeW9mlBRMBXGG4ZjeBRExZNp3hBLUElR4PTH98dw5LL+Ls8+u/s8n9fMGWbssPuNcz6/fZ59dvepdHZ2IiJr1xK6AJGYKSAiDgqIiIMCIuKggIg4KCAiDgqIiIMCIuKggIg4KCAiDgqIiIMCIuKggIg4KCAiDgqIiIMCIuKggIg4KCAiDgqIiIMCIuKggIg4KCAiDgqIiIMCIuKggIg4KCAiDgqIiIMCIuLQLXQBJVUBegN9gA2A9bp8AXwE/K/65/vAW8BCYHnulZacAuJPGzAI2KH6NQgYAGyBBaO1zvY6saC8CXQA84Dnq3/OBT7IpGr5hIpef5CZLYAvA8OBPYFhQPec+l4GtAOPV78eAl7Jqe9CU0Aa1wrsBRxa/dopbDlrmAtMrX49DCwNW06aF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Th+G91skssl12+iM/LXo50FyV/5mQoHpH29gRHAnigs68VtzqdMQ+f1x6MHbm/abIMDUpxV0JWaI7q+hqEQVeEjdM79IRSGe0j8tQK5cEDK0w/YANio62swOju/KrqIodU37M4D/o1O6/0L3ZAyFc1APYOHTaVwQOIZAKyEgrTgEullUa/zQdfX211/voMerj1MqpgDYhbglXSzAAfELMABMQtwQMwCHBCzAAfELMABMQtwQMwCHBCzAAfELMABMQtwQMwCHBCzAAfELMABMQtwQMwCHBCzAAfELMABMQtwQMwCHBCzAAfELMABMQtwQMwCHBCzAAfELMABMQtwQMwC/g/tf+FHXlzLOAAAAABJRU5ErkJggg==)}91.84%{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAYAAACtWK6eAAAACXBIWXMAAAABAAAAAQBPJcTWAAAAJHpUWHRDcmVhdG9yAAAImXNMyU9KVXBMK0ktUnBNS0tNLikGAEF6Bs5qehXFAAAOTElEQVR4nO3debCXVR3H8fddQCwVzT1wQ3FBQFMwEE3cEBiXaRPNcMktzdHGyVwySzKXrJlq1FJz3CLTTMdlWNyAKZVMSQXEhUVJckFKrpagXG5/fO8dfyL38FvOec55nufzmvmN46jnHO/l8zvPec7W1NHRgYisXXPsBoikTAERcVBARBwUEBEHBUTEQQERcVBARBwUEBEHBUTEQQERcVBARBwUEBEHBUTEQQERcVBARBwUEBEHBUTEQQERcVBARBwUEBEHBUTEQQERcVBARBwUEBEHBUTEQQERcVBARBwUEBGH1tgNKKkmYLOKTwv2ZbVRxb/zPvAusLzz8y7wYbbNFAUknPWB3YBdgV0q/ro1Fop6eu+3gQXAworPbGAOsLLxJsuamnT9gTd9gBHAcGBfYC+y+wJqx0LyBPA4MB1YklHdhaaA1K8FGAYcBRyO9RYpmQc8BNwP/AX4KG5z8kkBqU0zMBIYDxwBbBq1NdVbDtwD3AU8jPU4UgUFpDo7ACcCJwDbxW1Kw94EbgVuAl6J3JbkKSBuBwPfA0bHbkggU4FfA5MB/UFYCwX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btqIQuyNVxj5K92WPthoat5kh1saJdVItBQB7ICCSZl3dGIsvIWV1rtiIjnVLMRYZVVWEOqC6DwNbh1hPWDcmAnZGhVhYLEDEm6E8hhs79sGpbqs0gICsmJwB3G7cjC7oBv0NKFVXC34FVlTenTe5Dqr3ndrWqLarRICCrQecg+6byvrmwL/D9CjU+RJJ1WdMEXAGcRU7zHKWohmXeUoxGEne7WjekAhqR6wAq+RHuieRldsykRdIjnQH8OSO9JKnWHmRbZiLjeK0rp2PQk8on7CuA72bQFpC80xCq3BxQDIOArKocjdS/Sq44WZkcmYHGFOCmCv79ZqSo30jS2UajSlEMAvJwJyLLkPON29IRssqLXILMG9o7N1sEDEfqiOX1JdNuimSQFl5AznJMIAdnorchq7kDyK7ew5E9YqVYhRwvGExOjslmSREm6SHqkfsotO+8yAKtLeMDgS8jV0Lsi9TGWo3sDZuJnFtfpxA3F1TDXqxKaECKWB8L3Ij8WFJFaxvNvOaP0wpFHGK1xmPIWelxpFvIbJZ1A4pI0YdYrVEHnI6cwNO86ao9LAP2I/9Jz9zhPcj2bEK2TgxEdtfOsG0OADfg5jDBe5Dy6IfU7R2HZKRj8hJwBAVaWk0JN0j7qEPOV5+GXN+mfc9hI2KO15XjOG3gBuk4XZCDQWObP1kf+V2GlBR6JWNdpx24QbKjF2KYo5C3/gAkp9ARHkD2Tb2TScucDuMG0aMrYpKBzZ/9kZWo3rReOvUt5IDUZORknpMAbhAbugC7Ibt0NwHLgXdNW+S0ihvEcQJ4HsRxArhBHCeAG8RxArhBHCeAG8RxArhBHCeAG8RxArhBHCeAG8RxArhBHCeAG8RxArhBHCeAG8RxArhBHCeAG8RxArhBHCeAG8RxArhBHCeAG8RxArhBHCeAG8RxArhBHCeAG8RxArhBHCeAG8RxArhBHCeAG8RxArhBHCfA/wAuDSDlTBJcZgAAAABJRU5ErkJggg==)}}.video-speed-dropdown{background-color:#595959}.video-speed-dropdown .ranui-select-dropdown-option-item{padding:2px 4px}.video-speed-dropdown .ranui-select-dropdown-option-item .ranui-select-dropdown-option-item-content{font-size:12px;color:#fff;text-align:center}.video-speed-dropdown .ranui-select-dropdown-option-active{background-color:transparent}.video-speed-dropdown .ranui-select-dropdown-option-active .ranui-select-dropdown-option-item-content{color:#1890ff}.video-clarity-dropdown{background-color:#595959}.video-clarity-dropdown .ranui-select-dropdown-option-item{padding:2px 4px}.video-clarity-dropdown .ranui-select-dropdown-option-item .ranui-select-dropdown-option-item-content{font-size:12px;color:#fff;text-align:center}.video-clarity-dropdown .ranui-select-dropdown-option-active{background-color:transparent}.video-clarity-dropdown .ranui-select-dropdown-option-active .ranui-select-dropdown-option-item-content{color:#1890ff}.video-control_loading{z-index:10;top:calc(50vh - 60px);left:calc(50vw - 60px);position:fixed;width:120px;height:120px;background-position:center;background-repeat:no-repeat;background-size:contain;animation:loading 1s infinite}.ran-player{display:block;height:100%;width:100%;position:relative;overflow:hidden}.ran-player-contain,.ran-player-contain-video{width:100%;height:100%}.ran-player video::-webkit-media-controls-fullscreen-button{display:none}.ran-player video::-webkit-media-controls-play-button{display:none}.ran-player video::-webkit-media-controls-timeline{display:none}.ran-player video::-webkit-media-controls-current-time-display{display:none}.ran-player video::-webkit-media-controls-time-remaining-display{display:none}.ran-player video::-webkit-media-controls-mute-button{display:none}.ran-player video::-webkit-media-controls-toggle-closed-captions-button{display:none}.ran-player video::-webkit-media-controls-volume-slider{display:none}.ran-player video::-webkit-media-controls-enclosure{display:none}.ran-player video{outline:none}.ran-player .prism-player{position:relative}.ran-player-play-btn{background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAPQAAAD0CAYAAACsLwv+AAAAAXNSR0IArs4c6QAAG7pJREFUeAHtnXusFUWexxu5C1xMBHlsQJR3hMkwyhIyGXEFoyYzjghkBOWls5vwcFZAwkvIJOvF8Z91NkYXnY2a7AAaVnQzipJxJlEioGj8A8FxM0rk6fBwQUZM5DVw2e/3pPtyzr19zunu04+q7m8lv9vvql99qr63qru663RyFKwgcOnSpSvg6DWwIb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JOkC5QdjNOO1+GCcs5Hi2QnoEOH78HOxFCPlMesnamZIEHbLcIG4Kei6MD9CuCnm5Tg9G4FucxgddL0DEhXghJBiW+mdJ0PUZ+Z4BYXP8+j4Y77PHwwrzkg7ymkRoRaTbYLw/3gghF24MOQ6oEnQMFCFu/nLmNBifjvNtNHEFhACBT6o5bxefVr8KER8LcI1OqUFAFa8GnCiHIO4BuI7ingi7BdYFpnCZwHmsbodxlhCK+PDlQ1prlIAE3SjBGtdD3Ffi8G2wO10bjGURwwFk+i3XtkDE3xURQhp5lqDToOymAYFfj1W22uyW07idx7AHmWJXmrYdAua2QgoEJOgUIFdLAgLvi2PjYDfBboTdALsGZlM4Amc/gfH3kj+A7YCANU4MEFkECToL6jXShMh74TCFTfs+bChsMGwgLKv78fNI+xDsAGwf7H9hFPEnEO9JLBUMISBBG1IQ9dyA0K/AOWy9h8AGwdi68+213mVLrnM4rSuM4qd561h1KEz+FCqX3jqHhzipPI1vY3lLtrIHYfthRyBcDispGE7g/wFAEx//6c86OAAAAABJRU5ErkJggg==) no-repeat;background-size:contain;width:64px;height:64px;position:absolute;top:50%;left:50%;transform:translate(-50%,-50%)}.ran-player .prism-auto-stream-selector{display:none}.ran-player-controller{position:absolute;bottom:0;left:0;background:linear-gradient(180deg,#d9d9d980,#5b5b5b80);width:calc(100% - 32px);height:34px;padding:16px;opacity:0;transition:opacity .5s;box-sizing:content-box}.ran-player-controller-tip{position:absolute;top:-12px;max-width:60px;height:24px;line-height:9px;transform-origin:var(--ran-x, 50%) var(--ran-y, 50%);box-sizing:border-box;margin:0;padding:4px 6px;color:#fff;font-size:10px;list-style:none;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\",Segoe UI Symbol,\"Noto Color Emoji\";z-index:1000;font-variant:initial;background:#00000080;border-radius:8px;outline:none;box-shadow:0 6px 16px #00000014,0 3px 6px -4px #0000001f,0 9px 28px 8px #0000000d;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;opacity:0;text-align:center}.ran-player-controller-tip-time,.ran-player-controller-tip-text{margin-top:4px;max-width:80px;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;text-align:center}.ran-player-controller-progress{position:relative;width:100%;height:4px;cursor:pointer;box-sizing:content-box}.ran-player-controller-progress:focus{outline:0;-webkit-tap-highlight-color:transparent}.ran-player-controller-progress:active{outline:0;-webkit-tap-highlight-color:transparent}.ran-player-controller-progress-wrap{width:100%;height:100%;border-radius:20px;background:#ffffff4d;position:relative;overflow:hidden;pointer-events:none;box-sizing:content-box}.ran-player-controller-progress-wrap-value{position:absolute;top:0;left:0;height:100%;width:100%;transform:scaleX(0);transform-origin:0 0;will-change:transform;background:#fffc;border-radius:20px;box-sizing:content-box;cursor:pointer}.ran-player-controller-progress-dot{position:absolute;top:-2px;left:-2px;border-radius:50%;z-index:9;width:8px;height:8px;background:#fff;cursor:pointer}.ran-player-controller-bottom{margin-top:8px;width:100%;display:flex;justify-content:space-between;align-items:center}.ran-player-controller-bottom-left{-webkit-user-select:none;user-select:none;display:flex;justify-content:flex-start;align-items:center}.ran-player-controller-bottom-left-btn{width:20px;height:20px;cursor:pointer;outline:0;-webkit-tap-highlight-color:transparent}.ran-player-controller-bottom-left-btn:active,.ran-player-controller-bottom-left-btn:focus{outline:0;-webkit-tap-highlight-color:transparent}.ran-player-controller-bottom-left-btn-play{background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAAAXNSR0IArs4c6QAAA8JJREFUeAHtmktoE0EYxzPZpA001M1mRVFQUETBixcP3r148SYIgngRm7ZQKSgqUlAQUdCD9VBE0INY8HHw4gMfIB5EraBIsRX0pijdTZqa2qZ5jP+tNp2mSbvZ7mOmnYWw385jM//ffDP7zeyGQvKQBCQBSUASkAQkAUmgQQKGYTxIp9MbGqzGXfGw0xbRUGhvqVz+bKTTxymlUaf3CboecdqAEcMAg38HIW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kSuQmCC) no-repeat;background-size:contain}.ran-player-controller-bottom-left-btn-pause{background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAAHdbkFIAAAAAXNSR0IArs4c6QAAAQdJREFUeAHtmdkOwjAMBFv+/5+hllhkKrlRz0B38uIoh2OPVyGiw3BYe75bOMz9R+uECxa0QjhyPnKXv9y/IM3mEYrrPDvOXWcE49Q0X43vzgEHQuxtP0oLDJXaqvHYg5Bg8Bs6iChofQl8XSfzUPI1kufyD14eX7s+9u6+jnIAW/oEAAEIQKA7gS2XF3sgAIF7EeBJ1v0qJgAIQAACEIAABCAAge4E7vXGJxsIQAACEIDAvxFY/H9qKZnq82C1p/rMWK0/27/OtX8LAUBScLUowLXyyhsFiISrRQGulVfeKEAkXC0KcK288kYBIuFqUYBr5ZU3ChAJV4sCXCtP3hCAAAQgMBF4AShmQIQewFksAAAAAElFTkSuQmCC) no-repeat;background-size:contain}.ran-player-controller-bottom-left-time{margin-left:16px;display:flex;justify-content:flex-start;align-items:center}.ran-player-controller-bottom-left-time-current{color:#fff;font-family:PingFang SC;font-size:12px;min-width:40px;font-style:normal;font-weight:400;line-height:normal;text-align:center;position:relative;top:2px}.ran-player-controller-bottom-left-time-divide{color:#fff;font-family:PingFang SC;font-size:12px;font-style:normal;font-weight:400;line-height:normal;margin:0 2px;text-align:center;position:relative;top:2px}.ran-player-controller-bottom-left-time-duration{color:#fff;font-family:PingFang SC;font-size:12px;font-style:normal;font-weight:400;line-height:normal;min-width:40px;text-align:center;position:relative;top:2px}.ran-player-controller-bottom-right{-webkit-user-select:none;user-select:none;display:flex;justify-content:flex-end;align-items:center}.ran-player-controller-bottom-right-volume{display:flex;justify-content:space-between;align-items:center;margin-right:12px;cursor:pointer}.ran-player-controller-bottom-right-volume-icon-volume{background:url(\"data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%3e%3cg%20opacity='0.8'%3e%3cpath%20d='M7.12053%2017.4845L7.42033%2016.797L7.27695%2016.7345H7.12053V17.4845ZM7.00016%207.48447V8.23447H7.1541L7.2956%208.17383L7.00016%207.48447ZM12.6061%205.08193L12.3106%204.39257L12.3106%204.39257L12.6061%205.08193ZM12.6003%2019.8741L12.3005%2020.5616L12.6003%2019.8741ZM7.12053%2016.7345H5V18.2345H7.12053V16.7345ZM5%2016.7345C4.30964%2016.7345%203.75%2016.1748%203.75%2015.4845H2.25C2.25%2017.0033%203.48122%2018.2345%205%2018.2345V16.7345ZM3.75%2015.4845V9.48447H2.25V15.4845H3.75ZM3.75%209.48447C3.75%208.79411%204.30964%208.23447%205%208.23447V6.73447C3.48122%206.73447%202.25%207.96569%202.25%209.48447H3.75ZM5%208.23447H7.00016V6.73447H5V8.23447ZM7.2956%208.17383L12.9015%205.77129L12.3106%204.39257L6.70472%206.79511L7.2956%208.17383ZM12.9015%205.77129C13.0665%205.70059%2013.25%205.8216%2013.25%206.00108H14.75C14.75%204.74472%2013.4654%203.89767%2012.3106%204.39257L12.9015%205.77129ZM13.25%206.00108V18.9575H14.75V6.00108H13.25ZM13.25%2018.9575C13.25%2019.1377%2013.0652%2019.2587%2012.9001%2019.1867L12.3005%2020.5616C13.4565%2021.0657%2014.75%2020.2186%2014.75%2018.9575H13.25ZM12.9001%2019.1867L7.42033%2016.797L6.82073%2018.1719L12.3005%2020.5616L12.9001%2019.1867Z'%20fill='white'/%3e%3cpath%20d='M17.625%2010.4849C17.8679%2011.2753%2017.9986%2012.1148%2017.9986%2012.9849C17.9986%2013.8549%2017.8679%2014.6944%2017.625%2015.4849'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'/%3e%3cpath%20d='M19.3359%206.48486C20.3972%208.41302%2021.0009%2010.6284%2021.0009%2012.9849C21.0009%2014.9436%2020%2017.4849%2019.3359%2018.4849'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3c/g%3e%3c/svg%3e\") no-repeat;background-size:contain}.ran-player-controller-bottom-right-volume-icon-mute{background:url(\"data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%3e%3cg%20opacity='0.8'%3e%3cpath%20d='M7.15802%2017.4845L7.4592%2016.7976L7.31522%2016.7345H7.15802V17.4845ZM7.00016%207.48447V8.23447H7.1541L7.2956%208.17383L7.00016%207.48447ZM12.6061%205.08193L12.3106%204.39257L12.3106%204.39257L12.6061%205.08193ZM12.5984%2019.87L12.8996%2019.1831H12.8996L12.5984%2019.87ZM7.15802%2016.7345H5V18.2345H7.15802V16.7345ZM5%2016.7345C4.30964%2016.7345%203.75%2016.1748%203.75%2015.4845H2.25C2.25%2017.0033%203.48122%2018.2345%205%2018.2345V16.7345ZM3.75%2015.4845V9.48447H2.25V15.4845H3.75ZM3.75%209.48447C3.75%208.79411%204.30964%208.23447%205%208.23447V6.73447C3.48122%206.73447%202.25%207.96569%202.25%209.48447H3.75ZM5%208.23447H7.00016V6.73447H5V8.23447ZM7.2956%208.17383L12.9015%205.77129L12.3106%204.39257L6.70472%206.79511L7.2956%208.17383ZM12.9015%205.77129C13.0665%205.70059%2013.25%205.8216%2013.25%206.00108H14.75C14.75%204.74472%2013.4654%203.89767%2012.3106%204.39257L12.9015%205.77129ZM13.25%206.00108V18.9542H14.75V6.00108H13.25ZM13.25%2018.9542C13.25%2019.1345%2013.0648%2019.2555%2012.8996%2019.1831L12.2972%2020.5568C13.4536%2021.0639%2014.75%2020.2168%2014.75%2018.9542H13.25ZM12.8996%2019.1831L7.4592%2016.7976L6.85684%2018.1713L12.2972%2020.5568L12.8996%2019.1831Z'%20fill='white'/%3e%3c/g%3e%3cg%20opacity='0.8'%3e%3cpath%20d='M18%2014.2427L22.2426%2010'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M22.2422%2014.2427L17.9995%2010'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3c/g%3e%3c/svg%3e\") no-repeat;background-size:contain}.ran-player-controller-bottom-right-volume-icon{width:18px;height:18px;margin-right:6px}.ran-player-controller-bottom-right-volume-progress{width:50px}.ran-player-controller-bottom-right-volume-progress .ran-progress{position:relative}.ran-player-controller-bottom-right-volume-progress .ran-progress-wrap{width:100%;height:4px;border-radius:20px;background:#ffffff4d;position:relative;overflow:hidden}.ran-player-controller-bottom-right-volume-progress .ran-progress-wrap-value{background:#fffc;transform-origin:0px 0px;height:100%}.ran-player-controller-bottom-right-volume-progress .ran-progress-dot{position:absolute;top:-2px;left:-4px;border-radius:50%;width:8px;height:8px;background:#fff;cursor:pointer}.ran-player-controller-bottom-right-speed{color:#fff;font-family:PingFang SC;font-size:14px;width:30px;height:20px;font-style:normal;font-weight:400;line-height:normal;margin-right:22px;cursor:pointer;outline:0;-webkit-tap-highlight-color:transparent}.ran-player-controller-bottom-right-speed:active,.ran-player-controller-bottom-right-speed:focus{outline:0;-webkit-tap-highlight-color:transparent}.ran-player-controller-bottom-right-speed r-select{width:46px;height:20px;outline:0;-webkit-tap-highlight-color:transparent}.ran-player-controller-bottom-right-speed r-select:active,.ran-player-controller-bottom-right-speed r-select:focus{outline:0;-webkit-tap-highlight-color:transparent}.ran-player-controller-bottom-right-speed r-select::part(selection){background-color:transparent}.ran-player-controller-bottom-right-speed r-select::part(selection-item){top:1px;color:#fff;font-size:12px}.ran-player-controller-bottom-right-clarity{width:60px;color:#fff;font-family:PingFang SC;font-size:14px;width:30px;height:20px;font-style:normal;font-weight:400;line-height:normal;cursor:pointer;margin-right:12px;outline:0;-webkit-tap-highlight-color:transparent}.ran-player-controller-bottom-right-clarity:active,.ran-player-controller-bottom-right-clarity:focus{outline:0;-webkit-tap-highlight-color:transparent}.ran-player-controller-bottom-right-clarity r-select{width:46px;height:20px;outline:0;-webkit-tap-highlight-color:transparent}.ran-player-controller-bottom-right-clarity r-select:active,.ran-player-controller-bottom-right-clarity r-select:focus{outline:0;-webkit-tap-highlight-color:transparent}.ran-player-controller-bottom-right-clarity r-select::part(selection){background-color:transparent}.ran-player-controller-bottom-right-clarity r-select::part(selection-item){top:1px;color:#fff;font-size:12px}.ran-player-controller-bottom-right-knowledge{color:#fff;font-family:PingFang SC;font-size:14px;font-style:normal;font-weight:400;line-height:normal;margin-right:24px;cursor:pointer}.ran-player-controller-bottom-right-full{background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACQAAAAkCAYAAADhAJiYAAAACXBIWXMAABYlAAAWJQFJUiTwAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAGFSURBVHgB7VjRcYJAEN1j/KUAKcAUYAGhAK3AAvxPA1pAGrCAVBD/QwGhACnAFGABZF+yMMt5es4IBx/3ZnaUu2PfOzjg9hlyoK7rlH9yjrmj+2yMOdID4DzrGzkqjhPn+bE7Zg4hbxxruk9EPlEiZucZgxwHLSxRnZjJh09Mz1hBkHD/wSgxB45MDS7p/9JerCR93LKlRJuTY8N5L82JO45viS+OJQ0M5siFq+HdNx1z1YjIKRAwcYs7xRp6UWNKvmwFBQJzYVmUqukVghaqoaTwqNT/LKHx0XlopiCogyjIBwjS35Mzhcc1P96oHCsaCWPzR0RERFxhSi/Gma4OHqkmhhCj+fEt05vwjMKjwx+3Hz5MXlBKI8PeoC0oPHRRWkFQoTtDVK0NpCjVfKdE6ulP1fgeonqViWt35AgXpDEbsHbgfNhmg6twfNZsABeWhm02bFtBcrLLAbmFfR/+kC0GB+1TJg1b6t6+oYFJbbRhZVyj5GrBhHA9dX34QxBQtH6Qwi//yug9jgFQZgAAAABJRU5ErkJggg==);background-size:contain;width:16px;height:16px;cursor:pointer}.ran-popover{box-sizing:border-box;position:relative;display:inline-block;margin:0;padding:0}.ran-popover-content{box-sizing:border-box;margin:0;padding:0;color:#000000e0;font-size:14px;list-style:none;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\",Segoe UI Symbol,\"Noto Color Emoji\";position:absolute;z-index:1030;font-weight:400;white-space:normal;text-align:start;cursor:auto;-webkit-user-select:text;user-select:text;transform-origin:var(--ran-x, 50%) var(--ran-y, 50%);background:#fff;opacity:0;transition:opacity .2s;cursor:pointer}.ran-popover-content-inner{background-color:#fff;background-clip:padding-box;border-radius:8px;box-shadow:0 6px 16px #00000014,0 3px 6px -4px #0000001f,0 9px 28px 8px #0000000d;padding:12px}.ran-popover-content-arrow{transform:translate(-50%) translateY(100%) rotate(180deg);z-index:1;display:block;pointer-events:none;width:16px;height:16px;overflow:hidden;position:absolute}.ran-popover-content-arrow:before{position:absolute;bottom:0;inset-inline-start:0;width:16px;height:8px;background:#fff;clip-path:polygon(1.65685425px 100%,50% 1.65685425px,14.34314575px 100%,1.65685425px 100%);clip-path:path(\"M 0 8 A 4 4 0 0 0 2.82842712474619 6.82842712474619 L 6.585786437626905 3.0710678118654755 A 2 2 0 0 1 9.414213562373096 3.0710678118654755 L 13.17157287525381 6.82842712474619 A 4 4 0 0 0 16 8 Z\");content:\"\"}.ran-popover-content-arrow:after{content:\"\";position:absolute;width:8.97056275px;height:8.97056275px;bottom:0;inset-inline:0;margin:auto;border-radius:0 0 2px;transform:translateY(50%) rotate(-135deg);box-shadow:2px 2px 5px #0000000d;z-index:0;background:transparent}.ran-content{display:none}.ran-loading{margin:10px}.ran-loading .stretch{width:50px;height:60px;text-align:center;font-size:10px;display:flex;flex-flow:row nowrap;justify-content:space-between;align-items:center}@keyframes ran-loading-stretch{0%,40%,to{transform:scaleY(.4)}20%{transform:scaleY(1)}}.ran-loading .stretch div{background-color:#67cf22;height:100%;width:6px;animation:ran-loading-stretch 1.2s infinite ease-in-out}.ran-loading .stretch .rect2{animation-delay:-1.1s}.ran-loading .stretch .rect3{animation-delay:-1s}.ran-loading .stretch .rect4{animation-delay:-.9s}.ran-loading .stretch .rect5{animation-delay:-.8s}.ran-loading .rotate{width:60px;height:60px;background-color:#67cf22;animation:ran-loading-rotate 1.2s infinite ease-in-out}@keyframes ran-loading-rotate{0%{transform:perspective(120px) rotateX(0) rotateY(0)}50%{transform:perspective(120px) rotateX(-180.1deg) rotateY(0)}to{transform:perspective(120px) rotateX(-180deg) rotateY(-179.9deg)}}.ran-loading .double-bounce{width:60px;height:60px;position:relative}.ran-loading .double-bounce .double-bounce1,.ran-loading .double-bounce .double-bounce2{width:100%;height:100%;border-radius:50%;background-color:#67cf22;opacity:.6;position:absolute;top:0;left:0;animation:ran-loading-bounce 2s infinite ease-in-out}.ran-loading .double-bounce .double-bounce2{animation-delay:-1s}@keyframes ran-loading-bounce{0%,to{transform:scale(0)}50%{transform:scale(1)}}.ran-loading .cube{width:32px;height:32px;position:relative}.ran-loading .cube .cube1,.ran-loading .cube .cube2{background-color:#67cf22;width:30px;height:30px;position:absolute;top:0;left:0;animation:ran-loading-cube 1.8s infinite ease-in-out}.ran-loading .cube .cube2{animation-delay:-.9s}@keyframes ran-loading-cube{25%{transform:translate(42px) rotate(-90deg) scale(.5)}50%{transform:translate(42px) translateY(42px) rotate(-179deg)}50.1%{transform:translate(42px) translateY(42px) rotate(-180deg)}75%{transform:translate(0) translateY(42px) rotate(-270deg) scale(.5)}to{transform:rotate(-360deg)}}.ran-loading .dot{width:90px;height:90px;position:relative;text-align:center;animation:ran-loading-dot-rotate 2s infinite linear}.ran-loading .dot .dot1,.ran-loading .dot .dot2{width:60%;height:60%;display:inline-block;position:absolute;top:0;background-color:#67cf22;border-radius:100%;animation:ran-loading-dot-bounce 2s infinite ease-in-out}.ran-loading .dot .dot2{top:auto;bottom:0;animation-delay:-1s}@keyframes ran-loading-dot-rotate{to{transform:rotate(360deg)}}@keyframes ran-loading-dot-bounce{0%,to{transform:scale(0)}50%{transform:scale(1)}}.ran-loading .triple-bounce{width:150px;text-align:center}.ran-loading .triple-bounce div{width:30px;height:30px;background-color:#67cf22;border-radius:100%;display:inline-block;animation:ran-loading-triple-bounce 1.4s infinite ease-in-out;animation-fill-mode:both}.ran-loading .triple-bounce .triple-bounce1{animation-delay:-.32s}.ran-loading .triple-bounce .triple-bounce2{animation-delay:-.16s}@keyframes ran-loading-triple-bounce{0%,80%,to{transform:scale(0)}40%{transform:scale(1)}}.ran-loading .scale-out{width:40px;height:40px;background-color:#333;border-radius:100%;animation:ran-loading-scale-out 1s infinite ease-in-out}@keyframes ran-loading-scale-out{0%{transform:scale(0)}to{transform:scale(1);opacity:0}}.ran-loading .circle{width:20px;height:20px;position:relative}.ran-loading .circle-container{position:absolute;width:100%;height:100%}.ran-loading .circle-container div{width:6px;height:6px;background-color:#333;border-radius:100%;position:absolute;animation:ran-loading-circle 1.2s infinite ease-in-out;animation-fill-mode:both}.ran-loading .circle .container1 .circle2{animation-delay:-.9s}.ran-loading .circle .container1 .circle3{animation-delay:-.6s}.ran-loading .circle .container1 .circle4{animation-delay:-.3s}.ran-loading .circle .container2{transform:rotate(45deg)}.ran-loading .circle .container2 .circle1{animation-delay:-1.1s}.ran-loading .circle .container2 .circle2{animation-delay:-.8s}.ran-loading .circle .container2 .circle3{animation-delay:-.5s}.ran-loading .circle .container2 .circle4{animation-delay:-.2s}.ran-loading .circle .container3{transform:rotate(90deg)}.ran-loading .circle .container3 .circle1{animation-delay:-1s}.ran-loading .circle .container3 .circle2{animation-delay:-.7s}.ran-loading .circle .container3 .circle3{animation-delay:-.4s}.ran-loading .circle .container3 .circle4{animation-delay:-.1s}.ran-loading .circle .circle1{top:0;left:0}.ran-loading .circle .circle2{top:0;right:0}.ran-loading .circle .circle3{right:0;bottom:0}.ran-loading .circle .circle4{left:0;bottom:0}@keyframes ran-loading-circle{0%,80%,to{transform:scale(0)}40%{transform:scale(1)}}",document.body.appendChild(g)}const II=Object.freeze(Object.defineProperty({__proto__:null,default:{success:!0,_identification:!0,data:'\r\n \r\n'}},Symbol.toStringTag,{value:"Module"})),CI=Object.freeze(Object.defineProperty({__proto__:null,default:{success:!0,_identification:!0,data:'\r\n \r\n'}},Symbol.toStringTag,{value:"Module"})),AI=Object.freeze(Object.defineProperty({__proto__:null,default:{success:!0,_identification:!0,data:''}},Symbol.toStringTag,{value:"Module"})),iI=Object.freeze(Object.defineProperty({__proto__:null,default:{success:!0,_identification:!0,data:''}},Symbol.toStringTag,{value:"Module"})),eI=Object.freeze(Object.defineProperty({__proto__:null,default:{success:!0,_identification:!0,data:''}},Symbol.toStringTag,{value:"Module"})),lI=Object.freeze(Object.defineProperty({__proto__:null,default:{success:!0,_identification:!0,data:''}},Symbol.toStringTag,{value:"Module"})),tI=Object.freeze(Object.defineProperty({__proto__:null,default:{success:!0,_identification:!0,data:''}},Symbol.toStringTag,{value:"Module"})),sI=Object.freeze(Object.defineProperty({__proto__:null,default:{success:!0,_identification:!0,data:''}},Symbol.toStringTag,{value:"Module"})),cI=Object.freeze(Object.defineProperty({__proto__:null,default:{success:!0,_identification:!0,data:'\r\n \r\n \r\n'}},Symbol.toStringTag,{value:"Module"})),dI=Object.freeze(Object.defineProperty({__proto__:null,default:{success:!0,_identification:!0,data:'\r\n \r\n \r\n'}},Symbol.toStringTag,{value:"Module"})),oI=Object.freeze(Object.defineProperty({__proto__:null,default:{success:!0,_identification:!0,data:''}},Symbol.toStringTag,{value:"Module"})),nI=Object.freeze(Object.defineProperty({__proto__:null,default:{success:!0,_identification:!0,data:''}},Symbol.toStringTag,{value:"Module"})),aI=Object.freeze(Object.defineProperty({__proto__:null,default:{success:!0,_identification:!0,data:'\r\n \r\n \r\n \r\n'}},Symbol.toStringTag,{value:"Module"})),ZI=Object.freeze(Object.defineProperty({__proto__:null,default:{success:!0,_identification:!0,data:''}},Symbol.toStringTag,{value:"Module"})),bI=Object.freeze(Object.defineProperty({__proto__:null,default:{success:!0,_identification:!0,data:'\r\n \r\n \r\n'}},Symbol.toStringTag,{value:"Module"})),rI=Object.freeze(Object.defineProperty({__proto__:null,default:{success:!0,_identification:!0,data:''}},Symbol.toStringTag,{value:"Module"})),mI=Object.freeze(Object.defineProperty({__proto__:null,default:{success:!0,_identification:!0,data:''}},Symbol.toStringTag,{value:"Module"})),hI=Object.freeze(Object.defineProperty({__proto__:null,default:{success:!0,_identification:!0,data:''}},Symbol.toStringTag,{value:"Module"})),GI=Object.freeze(Object.defineProperty({__proto__:null,default:{success:!0,_identification:!0,data:''}},Symbol.toStringTag,{value:"Module"})),uI={success:!0,_identification:!0,data:'\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n \r\n \r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n \r\n \r\n \r\n \r\n \r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n \r\n \r\n \r\n \r\n\r\n\r\n \r\n \r\n \r\n \r\n\r\n\r\n \r\n \r\n \r\n \r\n\r\n\r\n \r\n \r\n \r\n \r\n\r\n\r\n \r\n \r\n \r\n \r\n\r\n\r\n \r\n \r\n \r\n \r\n\r\n\r\n \r\n \r\n \r\n \r\n\r\n\r\n \r\n \r\n \r\n \r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n'},BI=Object.freeze(Object.defineProperty({__proto__:null,default:uI},Symbol.toStringTag,{value:"Module"})),wI=Object.freeze(Object.defineProperty({__proto__:null,default:{success:!0,_identification:!0,data:''}},Symbol.toStringTag,{value:"Module"})),WI=Object.freeze(Object.defineProperty({__proto__:null,default:{success:!0,_identification:!0,data:'\r\n \r\n \r\n'}},Symbol.toStringTag,{value:"Module"})),pI=Object.freeze(Object.defineProperty({__proto__:null,default:{success:!0,_identification:!0,data:''}},Symbol.toStringTag,{value:"Module"})),VI=Object.freeze(Object.defineProperty({__proto__:null,default:{success:!0,_identification:!0,data:''}},Symbol.toStringTag,{value:"Module"})),yI=Object.freeze(Object.defineProperty({__proto__:null,default:{success:!0,_identification:!0,data:''}},Symbol.toStringTag,{value:"Module"}));window.E0DD32CBDCB63F=function(){var g={version:"3.5.9"},I=[].slice,C=function(g){return I.call(g)},A=this.document;function i(g){return g&&(g.ownerDocument||g.document||g).documentElement}function e(g){return g&&(g.ownerDocument&&g.ownerDocument.defaultView||g.document&&g||g.defaultView)}if(A)try{C(A.documentElement.childNodes)[0].nodeType}catch(gs){C=function(g){for(var I=g.length,C=new Array(I);I--;)C[I]=g[I];return C}}if(Date.now||(Date.now=function(){return+new Date}),A)try{A.createElement("DIV").style.setProperty("opacity",0,"")}catch(Is){var l=this.Element.prototype,t=l.setAttribute,s=l.setAttributeNS,c=this.CSSStyleDeclaration.prototype,d=c.setProperty;l.setAttribute=function(g,I){t.call(this,g,I+"")},l.setAttributeNS=function(g,I,C){s.call(this,g,I,C+"")},c.setProperty=function(g,I,C){d.call(this,g,I+"",C)}}function o(g,I){return gI?1:g>=I?0:NaN}function n(g){return null===g?NaN:+g}function a(g){return!isNaN(g)}function Z(g){return{left:function(I,C,A,i){for(arguments.length<3&&(A=0),arguments.length<4&&(i=I.length);A>>1;g(I[e],C)<0?A=e+1:i=e}return A},right:function(I,C,A,i){for(arguments.length<3&&(A=0),arguments.length<4&&(i=I.length);A>>1;g(I[e],C)>0?i=e:A=e+1}return A}}}g.ascending=o,g.descending=function(g,I){return Ig?1:I>=g?0:NaN},g.min=function(g,I){var C,A,i=-1,e=g.length;if(1===arguments.length){for(;++i=A){C=A;break}for(;++iA&&(C=A)}else{for(;++i=A){C=A;break}for(;++iA&&(C=A)}return C},g.max=function(g,I){var C,A,i=-1,e=g.length;if(1===arguments.length){for(;++i=A){C=A;break}for(;++iC&&(C=A)}else{for(;++i=A){C=A;break}for(;++iC&&(C=A)}return C},g.extent=function(g,I){var C,A,i,e=-1,l=g.length;if(1===arguments.length){for(;++e=A){C=i=A;break}for(;++eA&&(C=A),i=A){C=i=A;break}for(;++eA&&(C=A),i1)return l/(s-1)},g.deviation=function(){var I=g.variance.apply(this,arguments);return I?Math.sqrt(I):I};var b=Z(o);function r(g){return g.length}g.bisectLeft=b.left,g.bisect=g.bisectRight=b.right,g.bisector=function(g){return Z(1===g.length?function(I,C){return o(g(I),C)}:g)},g.shuffle=function(g,I,C){(e=arguments.length)<3&&(C=g.length,e<2&&(I=0));for(var A,i,e=C-I;e;)i=Math.random()*e--|0,A=g[e+I],g[e+I]=g[i+I],g[i+I]=A;return g},g.permute=function(g,I){for(var C=I.length,A=new Array(C);C--;)A[C]=g[I[C]];return A},g.pairs=function(g){for(var I=0,C=g.length-1,A=g[0],i=new Array(C<0?0:C);I=0;)for(I=(A=g[i]).length;--I>=0;)C[--l]=A[I];return C};var m=Math.abs;function h(g,I){for(var C in I)Object.defineProperty(g.prototype,C,{value:I[C],enumerable:!1})}function G(){this._=Object.create(null)}g.range=function(g,I,C){if(arguments.length<3&&(C=1,arguments.length<2&&(I=g,g=0)),(I-g)/C==1/0)throw new Error("infinite range");var A,i=[],e=function(g){var I=1;for(;g*I%1;)I*=10;return I}(m(C)),l=-1;if(g*=e,I*=e,(C*=e)<0)for(;(A=g+C*++l)>I;)i.push(A/e);else for(;(A=g+C*++l)=i.length)return C?C.call(A,e):I?e.sort(I):e;for(var s,c,d,o,n=-1,a=e.length,Z=i[t++],b=new G;++n=i.length)return g;var C=[],A=e[I++];return g.forEach((function(g,A){C.push({key:g,values:t(A,I)})})),A?C.sort((function(g,I){return A(g.key,I.key)})):C}return A.map=function(g,I){return l(I,g,0)},A.entries=function(I){return t(l(g.map,I,0),0)},A.key=function(g){return i.push(g),A},A.sortKeys=function(g){return e[i.length-1]=g,A},A.sortValues=function(g){return I=g,A},A.rollup=function(g){return C=g,A},A},g.set=function(g){var I=new R;if(g)for(var C=0,A=g.length;C=0&&(A=g.slice(C+1),g=g.slice(0,C)),g)return arguments.length<2?this[g].on(A):this[g].on(A,I);if(2===arguments.length){if(null==I)for(g in this)this.hasOwnProperty(g)&&this[g].on(A,null);return this}},g.event=null,g.requote=function(g){return g.replace(L,"\\$&")};var L=/[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g,z={}.__proto__?function(g,I){g.__proto__=I}:function(g,I){for(var C in I)g[C]=I[C]};function v(g){return z(g,Q),g}var T=function(g,I){return I.querySelector(g)},x=function(g,I){return I.querySelectorAll(g)},U=function(g,I){var C=g.matches||g[K(g,"matchesSelector")];return(U=function(g,I){return C.call(g,I)})(g,I)};"function"==typeof Sizzle&&(T=function(g,I){return Sizzle(g,I)[0]||null},x=Sizzle,U=Sizzle.matchesSelector),g.selection=function(){return g.select(A.documentElement)};var Q=g.selection.prototype=[];function j(g){return"function"==typeof g?g:function(){return T(g,this)}}function O(g){return"function"==typeof g?g:function(){return x(g,this)}}Q.select=function(g){var I,C,A,i,e=[];g=j(g);for(var l=-1,t=this.length;++l=0&&"xmlns"!==(C=g.slice(0,I))&&(g=g.slice(I+1)),E.hasOwnProperty(C)?{space:E[C],local:g}:g}},Q.attr=function(I,C){if(arguments.length<2){if("string"==typeof I){var A=this.node();return(I=g.ns.qualify(I)).local?A.getAttributeNS(I.space,I.local):A.getAttribute(I)}for(C in I)this.each(P(C,I[C]));return this}return this.each(P(I,C))},Q.classed=function(g,I){if(arguments.length<2){if("string"==typeof g){var C=this.node(),A=(g=$(g)).length,i=-1;if(I=C.classList){for(;++i=0;)(C=A[i])&&(e&&e!==C.nextSibling&&e.parentNode.insertBefore(C,e),e=C);return this},Q.sort=function(g){g=sg.apply(this,arguments);for(var I=-1,C=this.length;++I0&&(I=I.slice(0,l));var s=ag.get(I);function c(){var g=this[e];g&&(this.removeEventListener(I,g,g.$),delete this[e])}return s&&(I=s,t=bg),l?A?function(){var g=t(A,C(arguments));c.call(this),this.addEventListener(I,this[e]=g,g.$=i),g._=A}:c:A?M:function(){var C,A=new RegExp("^__on([^.]+)"+g.requote(I)+"$");for(var i in this)if(C=i.match(A)){var e=this[i];this.removeEventListener(C[1],e,e.$),delete this[i]}}}g.selection.enter=dg,g.selection.enter.prototype=og,og.append=Q.append,og.empty=Q.empty,og.node=Q.node,og.call=Q.call,og.size=Q.size,og.select=function(g){for(var I,C,A,i,e,l=[],t=-1,s=this.length;++t=A&&(A=I+1);!(l=t[A])&&++A0?1:g<0?-1:0}function Hg(g,I,C){return(I[0]-g[0])*(C[1]-g[1])-(I[1]-g[1])*(C[0]-g[0])}function Kg(g){return g>1?0:g<-1?pg:Math.acos(g)}function Fg(g){return g>1?Xg:g<-1?-Xg:Math.asin(g)}function Mg(g){return((g=Math.exp(g))+1/g)/2}function Jg(g){return(g=Math.sin(g/2))*g}var Sg=Math.SQRT2;g.interpolateZoom=function(g,I){var C,A,i=g[0],e=g[1],l=g[2],t=I[0],s=I[1],c=I[2],d=t-i,o=s-e,n=d*d+o*o;if(n0&&(I=I.transition().duration(b)),I.call(w.event)}function X(){c&&c.domain(s.range().map((function(g){return(g-n.x)/n.k})).map(s.invert)),o&&o.domain(d.range().map((function(g){return(g-n.y)/n.k})).map(d.invert))}function Y(g){r++||g({type:"zoomstart"})}function R(g){X(),g({type:"zoom",scale:n.k,translate:[n.x,n.y]})}function N(g){--r||(g({type:"zoomend"}),C=null)}function H(){var I=this,C=B.of(I,arguments),A=0,i=g.select(e(I)).on(h,(function(){A=1,V(g.mouse(I),l),R(C)})).on(G,(function(){i.on(h,null).on(G,null),t(A),N(C)})),l=W(g.mouse(I)),t=hg(I);Wt.call(I),Y(C)}function K(){var I,C=this,A=B.of(C,arguments),i={},e=0,l=".zoom-"+g.event.changedTouches[0].identifier,s="touchmove"+l,c="touchend"+l,d=[],o=g.select(C),a=hg(C);function Z(){var A=g.touches(C);return I=n.k,A.forEach((function(g){g.identifier in i&&(i[g.identifier]=W(g))})),A}function b(){var I=g.event.target;g.select(I).on(s,r).on(c,h),d.push(I);for(var A=g.event.changedTouches,l=0,o=A.length;l1){m=a[0];var G=a[1],u=m[0]-G[0],B=m[1]-G[1];e=u*u+B*B}}function r(){var l,s,c,d,o=g.touches(C);Wt.call(C);for(var n=0,a=o.length;n360?g-=360:g<0&&(g+=360),g<60?A+(i-A)*g/60:g<180?i:g<240?A+(i-A)*(240-g)/60:A}(g))}return g=isNaN(g)?0:(g%=360)<0?g+360:g,I=isNaN(I)||I<0?0:I>1?1:I,A=2*(C=C<0?0:C>1?1:C)-(i=C<=.5?C*(1+I):C+I-C*I),new iI(e(g+120),e(g),e(g-120))}function xg(I,C,A){return this instanceof xg?(this.h=+I,this.c=+C,void(this.l=+A)):arguments.length<2?I instanceof xg?new xg(I.h,I.c,I.l):gI(I instanceof jg?I.l:(I=oI((I=g.rgb(I)).r,I.g,I.b)).l,I.a,I.b):new xg(I,C,A)}vg.brighter=function(g){return g=Math.pow(.7,arguments.length?g:1),new zg(this.h,this.s,this.l/g)},vg.darker=function(g){return g=Math.pow(.7,arguments.length?g:1),new zg(this.h,this.s,g*this.l)},vg.rgb=function(){return Tg(this.h,this.s,this.l)},g.hcl=xg;var Ug=xg.prototype=new Lg;function Qg(g,I,C){return isNaN(g)&&(g=0),isNaN(I)&&(I=0),new jg(C,Math.cos(g*=Yg)*I,Math.sin(g)*I)}function jg(g,I,C){return this instanceof jg?(this.l=+g,this.a=+I,void(this.b=+C)):arguments.length<2?g instanceof jg?new jg(g.l,g.a,g.b):g instanceof xg?Qg(g.h,g.c,g.l):oI((g=iI(g)).r,g.g,g.b):new jg(g,I,C)}Ug.brighter=function(g){return new xg(this.h,this.c,Math.min(100,this.l+Og*(arguments.length?g:1)))},Ug.darker=function(g){return new xg(this.h,this.c,Math.max(0,this.l-Og*(arguments.length?g:1)))},Ug.rgb=function(){return Qg(this.h,this.c,this.l).rgb()},g.lab=jg;var Og=18,Eg=.95047,Pg=1,_g=1.08883,qg=jg.prototype=new Lg;function $g(g,I,C){var A=(g+16)/116,i=A+I/500,e=A-C/200;return new iI(AI(3.2404542*(i=II(i)*Eg)-1.5371385*(A=II(A)*Pg)-.4985314*(e=II(e)*_g)),AI(-.969266*i+1.8760108*A+.041556*e),AI(.0556434*i-.2040259*A+1.0572252*e))}function gI(g,I,C){return g>0?new xg(Math.atan2(C,I)*Rg,Math.sqrt(I*I+C*C),g):new xg(NaN,NaN,g)}function II(g){return g>.206893034?g*g*g:(g-4/29)/7.787037}function CI(g){return g>.008856?Math.pow(g,1/3):7.787037*g+4/29}function AI(g){return Math.round(255*(g<=.00304?12.92*g:1.055*Math.pow(g,1/2.4)-.055))}function iI(g,I,C){return this instanceof iI?(this.r=~~g,this.g=~~I,void(this.b=~~C)):arguments.length<2?g instanceof iI?new iI(g.r,g.g,g.b):cI(""+g,iI,Tg):new iI(g,I,C)}function eI(g){return new iI(g>>16,g>>8&255,255&g)}function lI(g){return eI(g)+""}qg.brighter=function(g){return new jg(Math.min(100,this.l+Og*(arguments.length?g:1)),this.a,this.b)},qg.darker=function(g){return new jg(Math.max(0,this.l-Og*(arguments.length?g:1)),this.a,this.b)},qg.rgb=function(){return $g(this.l,this.a,this.b)},g.rgb=iI;var tI=iI.prototype=new Lg;function sI(g){return g<16?"0"+Math.max(0,g).toString(16):Math.min(255,g).toString(16)}function cI(g,I,C){var A,i,e,l=0,t=0,s=0;if(A=/([a-z]+)\((.*)\)/.exec(g=g.toLowerCase()))switch(i=A[2].split(","),A[1]){case"hsl":return C(parseFloat(i[0]),parseFloat(i[1])/100,parseFloat(i[2])/100);case"rgb":return I(aI(i[0]),aI(i[1]),aI(i[2]))}return(e=ZI.get(g))?I(e.r,e.g,e.b):(null==g||"#"!==g.charAt(0)||isNaN(e=parseInt(g.slice(1),16))||(4===g.length?(l=(3840&e)>>4,l|=l>>4,t=240&e,t|=t>>4,s=15&e,s|=s<<4):7===g.length&&(l=(16711680&e)>>16,t=(65280&e)>>8,s=255&e)),I(l,t,s))}function dI(g,I,C){var A,i,e=Math.min(g/=255,I/=255,C/=255),l=Math.max(g,I,C),t=l-e,s=(l+e)/2;return t?(i=s<.5?t/(l+e):t/(2-l-e),A=g==l?(I-C)/t+(I0&&s<1?0:A),new zg(A,i,s)}function oI(g,I,C){var A=CI((.4124564*(g=nI(g))+.3575761*(I=nI(I))+.1804375*(C=nI(C)))/Eg),i=CI((.2126729*g+.7151522*I+.072175*C)/Pg);return jg(116*i-16,500*(A-i),200*(i-CI((.0193339*g+.119192*I+.9503041*C)/_g)))}function nI(g){return(g/=255)<=.04045?g/12.92:Math.pow((g+.055)/1.055,2.4)}function aI(g){var I=parseFloat(g);return"%"===g.charAt(g.length-1)?Math.round(2.55*I):I}tI.brighter=function(g){g=Math.pow(.7,arguments.length?g:1);var I=this.r,C=this.g,A=this.b,i=30;return I||C||A?(I&&I=200&&I<300||304===I){try{g=i.call(l,c)}catch(gs){return void t.error.call(l,gs)}t.load.call(l,g)}else t.error.call(l,c)}return this.XDomainRequest&&!("withCredentials"in c)&&/^(http(s)?:)?\/\//.test(I)&&(c=new XDomainRequest),"onload"in c?c.onload=c.onerror=o:c.onreadystatechange=function(){c.readyState>3&&o()},c.onprogress=function(I){var C=g.event;g.event=I;try{t.progress.call(l,c)}finally{g.event=C}},l.header=function(g,I){return g=(g+"").toLowerCase(),arguments.length<2?s[g]:(null==I?delete s[g]:s[g]=I+"",l)},l.mimeType=function(g){return arguments.length?(A=null==g?null:g+"",l):A},l.responseType=function(g){return arguments.length?(d=g,l):d},l.response=function(g){return i=g,l},["get","post"].forEach((function(g){l[g]=function(){return l.send.apply(l,[g].concat(C(arguments)))}})),l.send=function(g,C,i){if(2===arguments.length&&"function"==typeof C&&(i=C,C=null),c.open(g,I,!0),null==A||"accept"in s||(s.accept=A+",*/*"),c.setRequestHeader)for(var e in s)c.setRequestHeader(e,s[e]);return null!=A&&c.overrideMimeType&&c.overrideMimeType(A),null!=d&&(c.responseType=d),null!=i&&l.on("error",i).on("load",(function(g){i(null,g)})),t.beforesend.call(l,c),c.send(null==C?null:C),l},l.abort=function(){return c.abort(),l},g.rebind(l,t,"on"),null==e?l:l.get(function(g){return 1===g.length?function(I,C){g(null==I?C:null)}:g}(e))}ZI.forEach((function(g,I){ZI.set(g,eI(I))})),g.functor=bI,g.xhr=rI(N),g.dsv=function(g,I){var C=new RegExp('["'+g+"\n]"),A=g.charCodeAt(0);function i(g,C,A){arguments.length<3&&(A=C,C=null);var i=mI(g,I,null==C?e:l(C),A);return i.row=function(g){return arguments.length?i.response(null==(C=g)?e:l(g)):C},i}function e(g){return i.parse(g.responseText)}function l(g){return function(I){return i.parse(I.responseText,g)}}function t(I){return I.map(s).join(g)}function s(g){return C.test(g)?'"'+g.replace(/\"/g,'""')+'"':g}return i.parse=function(g,I){var C;return i.parseRows(g,(function(g,A){if(C)return C(g,A-1);var i=new Function("d","return {"+g.map((function(g,I){return JSON.stringify(g)+": d["+I+"]"})).join(",")+"}");C=I?function(g,C){return I(i(g),C)}:i}))},i.parseRows=function(g,I){var C,i,e={},l={},t=[],s=g.length,c=0,d=0;function o(){if(c>=s)return l;if(i)return i=!1,e;var I=c;if(34===g.charCodeAt(I)){for(var C=I;C++24?(isFinite(I)&&(clearTimeout(BI),BI=setTimeout(pI,I)),uI=0):(uI=1,wI(pI))}function VI(){for(var g=Date.now(),I=hI;I;)g>=I.t&&I.c(g-I.t)&&(I.c=null),I=I.n;return g}function yI(){for(var g,I=hI,C=1/0;I;)I.c?(I.t8?function(g){return g/C}:function(g){return g*C},symbol:g}}));function RI(I){var C=I.decimal,A=I.thousands,i=I.grouping,e=I.currency,l=i&&A?function(g,I){for(var C=g.length,e=[],l=0,t=i[0],s=0;C>0&&t>0&&(s+t+1>I&&(t=Math.max(1,I-s)),e.push(g.substring(C-=t,C+t)),!((s+=t+1)>I));)t=i[l=(l+1)%i.length];return e.reverse().join(A)}:N;return function(I){var A=NI.exec(I),i=A[1]||" ",t=A[2]||">",s=A[3]||"-",c=A[4]||"",d=A[5],o=+A[6],n=A[7],a=A[8],Z=A[9],b=1,r="",m="",h=!1,G=!0;switch(a&&(a=+a.substring(1)),(d||"0"===i&&"="===t)&&(d=i="0",t="="),Z){case"n":n=!0,Z="g";break;case"%":b=100,m="%",Z="f";break;case"p":b=100,m="%",Z="r";break;case"b":case"o":case"x":case"X":"#"===c&&(r="0"+Z.toLowerCase());case"c":G=!1;case"d":h=!0,a=0;break;case"s":b=-1,Z="r"}"$"===c&&(r=e[0],m=e[1]),"r"!=Z||a||(Z="g"),null!=a&&("g"==Z?a=Math.max(1,Math.min(21,a)):"e"!=Z&&"f"!=Z||(a=Math.max(0,Math.min(20,a)))),Z=HI.get(Z)||KI;var u=d&&n;return function(I){var A=m;if(h&&I%1)return"";var e=I<0||0===I&&1/I<0?(I=-I,"-"):"-"===s?"":s;if(b<0){var c=g.formatPrefix(I,a);I=c.scale(I),A=c.symbol+m}else I*=b;var B,w,W=(I=Z(I,a)).lastIndexOf(".");if(W<0){var p=G?I.lastIndexOf("e"):-1;p<0?(B=I,w=""):(B=I.substring(0,p),w=I.substring(p))}else B=I.substring(0,W),w=C+I.substring(W+1);!d&&n&&(B=l(B,1/0));var V=r.length+B.length+w.length+(u?0:e.length),y=V"===t?y+e+I:"^"===t?y.substring(0,V>>=1)+e+I+y.substring(V):e+(u?I:y+I))+A}}}g.formatPrefix=function(I,C){var A=0;return(I=+I)&&(I<0&&(I*=-1),C&&(I=g.round(I,XI(I,C))),A=1+Math.floor(1e-12+Math.log(I)/Math.LN10),A=Math.max(-24,Math.min(24,3*Math.floor((A-1)/3)))),YI[8+A/3]};var NI=/(?:([^{])?([<>=^]))?([+\- ])?([$#])?(0)?(\d+)?(,)?(\.-?\d+)?([a-z%])?/i,HI=g.map({b:function(g){return g.toString(2)},c:function(g){return String.fromCharCode(g)},o:function(g){return g.toString(8)},x:function(g){return g.toString(16)},X:function(g){return g.toString(16).toUpperCase()},g:function(g,I){return g.toPrecision(I)},e:function(g,I){return g.toExponential(I)},f:function(g,I){return g.toFixed(I)},r:function(I,C){return(I=g.round(I,XI(I,C))).toFixed(Math.max(0,Math.min(20,XI(I*(1+1e-15),C))))}});function KI(g){return g+""}var FI=g.time={},MI=Date;function JI(){this._=new Date(arguments.length>1?Date.UTC.apply(this,arguments):arguments[0])}JI.prototype={getDate:function(){return this._.getUTCDate()},getDay:function(){return this._.getUTCDay()},getFullYear:function(){return this._.getUTCFullYear()},getHours:function(){return this._.getUTCHours()},getMilliseconds:function(){return this._.getUTCMilliseconds()},getMinutes:function(){return this._.getUTCMinutes()},getMonth:function(){return this._.getUTCMonth()},getSeconds:function(){return this._.getUTCSeconds()},getTime:function(){return this._.getTime()},getTimezoneOffset:function(){return 0},valueOf:function(){return this._.valueOf()},setDate:function(){SI.setUTCDate.apply(this._,arguments)},setDay:function(){SI.setUTCDay.apply(this._,arguments)},setFullYear:function(){SI.setUTCFullYear.apply(this._,arguments)},setHours:function(){SI.setUTCHours.apply(this._,arguments)},setMilliseconds:function(){SI.setUTCMilliseconds.apply(this._,arguments)},setMinutes:function(){SI.setUTCMinutes.apply(this._,arguments)},setMonth:function(){SI.setUTCMonth.apply(this._,arguments)},setSeconds:function(){SI.setUTCSeconds.apply(this._,arguments)},setTime:function(){SI.setTime.apply(this._,arguments)}};var SI=Date.prototype;function fI(g,I,C){function A(I){var C=g(I),A=e(C,1);return I-C1)for(;l=c)return-1;if(37===(i=I.charCodeAt(t++))){if(l=I.charAt(t++),!(e=w[l in LI?I.charAt(t++):l])||(A=e(g,C,A))<0)return-1}else if(i!=C.charCodeAt(A++))return-1}return A}d.utc=function(g){var I=d(g);function C(g){try{var C=new(MI=JI);return C._=g,I(C)}finally{MI=Date}}return C.parse=function(g){try{MI=JI;var C=I.parse(g);return C&&C._}finally{MI=Date}},C.toString=I.toString,C},d.multi=d.utc.multi=tC;var n=g.map(),a=xI(l),Z=UI(l),b=xI(t),r=UI(t),m=xI(s),h=UI(s),G=xI(c),u=UI(c);e.forEach((function(g,I){n.set(g.toLowerCase(),I)}));var B={a:function(g){return t[g.getDay()]},A:function(g){return l[g.getDay()]},b:function(g){return c[g.getMonth()]},B:function(g){return s[g.getMonth()]},c:d(C),d:function(g,I){return TI(g.getDate(),I,2)},e:function(g,I){return TI(g.getDate(),I,2)},H:function(g,I){return TI(g.getHours(),I,2)},I:function(g,I){return TI(g.getHours()%12||12,I,2)},j:function(g,I){return TI(1+FI.dayOfYear(g),I,3)},L:function(g,I){return TI(g.getMilliseconds(),I,3)},m:function(g,I){return TI(g.getMonth()+1,I,2)},M:function(g,I){return TI(g.getMinutes(),I,2)},p:function(g){return e[+(g.getHours()>=12)]},S:function(g,I){return TI(g.getSeconds(),I,2)},U:function(g,I){return TI(FI.sundayOfYear(g),I,2)},w:function(g){return g.getDay()},W:function(g,I){return TI(FI.mondayOfYear(g),I,2)},x:d(A),X:d(i),y:function(g,I){return TI(g.getFullYear()%100,I,2)},Y:function(g,I){return TI(g.getFullYear()%1e4,I,4)},Z:eC,"%":function(){return"%"}},w={a:function(g,I,C){b.lastIndex=0;var A=b.exec(I.slice(C));return A?(g.w=r.get(A[0].toLowerCase()),C+A[0].length):-1},A:function(g,I,C){a.lastIndex=0;var A=a.exec(I.slice(C));return A?(g.w=Z.get(A[0].toLowerCase()),C+A[0].length):-1},b:function(g,I,C){G.lastIndex=0;var A=G.exec(I.slice(C));return A?(g.m=u.get(A[0].toLowerCase()),C+A[0].length):-1},B:function(g,I,C){m.lastIndex=0;var A=m.exec(I.slice(C));return A?(g.m=h.get(A[0].toLowerCase()),C+A[0].length):-1},c:function(g,I,C){return o(g,B.c.toString(),I,C)},d:$I,e:$I,H:IC,I:IC,j:gC,L:iC,m:qI,M:CC,p:function(g,I,C){var A=n.get(I.slice(C,C+=2).toLowerCase());return null==A?-1:(g.p=A,C)},S:AC,U:jI,w:QI,W:OI,x:function(g,I,C){return o(g,B.x.toString(),I,C)},X:function(g,I,C){return o(g,B.X.toString(),I,C)},y:PI,Y:EI,Z:_I,"%":lC};return d}FI.year=fI((function(g){return(g=FI.day(g)).setMonth(0,1),g}),(function(g,I){g.setFullYear(g.getFullYear()+I)}),(function(g){return g.getFullYear()})),FI.years=FI.year.range,FI.years.utc=FI.year.utc.range,FI.day=fI((function(g){var I=new MI(2e3,0);return I.setFullYear(g.getFullYear(),g.getMonth(),g.getDate()),I}),(function(g,I){g.setDate(g.getDate()+I)}),(function(g){return g.getDate()-1})),FI.days=FI.day.range,FI.days.utc=FI.day.utc.range,FI.dayOfYear=function(g){var I=FI.year(g);return Math.floor((g-I-6e4*(g.getTimezoneOffset()-I.getTimezoneOffset()))/864e5)},["sunday","monday","tuesday","wednesday","thursday","friday","saturday"].forEach((function(g,I){I=7-I;var C=FI[g]=fI((function(g){return(g=FI.day(g)).setDate(g.getDate()-(g.getDay()+I)%7),g}),(function(g,I){g.setDate(g.getDate()+7*Math.floor(I))}),(function(g){var C=FI.year(g).getDay();return Math.floor((FI.dayOfYear(g)+(C+I)%7)/7)-(C!==I)}));FI[g+"s"]=C.range,FI[g+"s"].utc=C.utc.range,FI[g+"OfYear"]=function(g){var C=FI.year(g).getDay();return Math.floor((FI.dayOfYear(g)+(C+I)%7)/7)}})),FI.week=FI.sunday,FI.weeks=FI.sunday.range,FI.weeks.utc=FI.sunday.utc.range,FI.weekOfYear=FI.sundayOfYear;var LI={"-":"",_:" ",0:"0"},zI=/^\s*\d+/,vI=/^%/;function TI(g,I,C){var A=g<0?"-":"",i=(A?-g:g)+"",e=i.length;return A+(e68?1900:2e3),C+i[0].length):-1}function _I(g,I,C){return/^[+-]\d{4}$/.test(I=I.slice(C,C+5))?(g.Z=-I,C+5):-1}function qI(g,I,C){zI.lastIndex=0;var A=zI.exec(I.slice(C,C+2));return A?(g.m=A[0]-1,C+A[0].length):-1}function $I(g,I,C){zI.lastIndex=0;var A=zI.exec(I.slice(C,C+2));return A?(g.d=+A[0],C+A[0].length):-1}function gC(g,I,C){zI.lastIndex=0;var A=zI.exec(I.slice(C,C+3));return A?(g.j=+A[0],C+A[0].length):-1}function IC(g,I,C){zI.lastIndex=0;var A=zI.exec(I.slice(C,C+2));return A?(g.H=+A[0],C+A[0].length):-1}function CC(g,I,C){zI.lastIndex=0;var A=zI.exec(I.slice(C,C+2));return A?(g.M=+A[0],C+A[0].length):-1}function AC(g,I,C){zI.lastIndex=0;var A=zI.exec(I.slice(C,C+2));return A?(g.S=+A[0],C+A[0].length):-1}function iC(g,I,C){zI.lastIndex=0;var A=zI.exec(I.slice(C,C+3));return A?(g.L=+A[0],C+A[0].length):-1}function eC(g){var I=g.getTimezoneOffset(),C=I>0?"-":"+",A=m(I)/60|0,i=m(I)%60;return C+TI(A,"0",2)+TI(i,"0",2)}function lC(g,I,C){vI.lastIndex=0;var A=vI.exec(I.slice(C,C+1));return A?C+A[0].length:-1}function tC(g){for(var I=g.length,C=-1;++C=0?1:-1,t=l*e,s=Math.cos(I),c=Math.sin(I),d=i*c,o=A*s+d*Math.cos(t),n=d*l*Math.sin(t);RC.add(Math.atan2(n,o)),C=g,A=s,i=c}NC.point=function(l,t){NC.point=e,C=(g=l)*Yg,A=Math.cos(t=(I=t)*Yg/2+pg/4),i=Math.sin(t)},NC.lineEnd=function(){e(g,I)}}function KC(g){var I=g[0],C=g[1],A=Math.cos(C);return[A*Math.cos(I),A*Math.sin(I),Math.sin(C)]}function FC(g,I){return g[0]*I[0]+g[1]*I[1]+g[2]*I[2]}function MC(g,I){return[g[1]*I[2]-g[2]*I[1],g[2]*I[0]-g[0]*I[2],g[0]*I[1]-g[1]*I[0]]}function JC(g,I){g[0]+=I[0],g[1]+=I[1],g[2]+=I[2]}function SC(g,I){return[g[0]*I,g[1]*I,g[2]*I]}function fC(g){var I=Math.sqrt(g[0]*g[0]+g[1]*g[1]+g[2]*g[2]);g[0]/=I,g[1]/=I,g[2]/=I}function kC(g){return[Math.atan2(g[1],g[0]),Fg(g[2])]}function DC(g,I){return m(g[0]-I[0])wg?i=90:c<-wg&&(C=-90),o[0]=I,o[1]=A}};function a(g,e){d.push(o=[I=g,A=g]),ei&&(i=e)}function Z(g,l){var t=KC([g*Yg,l*Yg]);if(s){var c=MC(s,t),d=MC([c[1],-c[0],0],c);fC(d),d=kC(d);var o=g-e,n=o>0?1:-1,Z=d[0]*Rg*n,b=m(o)>180;if(b^(n*ei&&(i=r);else if(b^(n*e<(Z=(Z+360)%360-180)&&Zi&&(i=l);b?gB(I,A)&&(A=g):B(g,A)>B(I,A)&&(I=g):A>=I?(gA&&(A=g)):g>e?B(I,g)>B(I,A)&&(A=g):B(g,A)>B(I,A)&&(I=g)}else a(g,l);s=t,e=g}function b(){n.point=Z}function r(){o[0]=I,o[1]=A,n.point=a,s=null}function h(g,I){if(s){var C=g-e;c+=m(C)>180?C+(C>0?360:-360):C}else l=g,t=I;NC.point(g,I),Z(g,I)}function G(){NC.lineStart()}function u(){h(l,t),NC.lineEnd(),m(c)>wg&&(I=-(A=180)),o[0]=I,o[1]=A,s=null}function B(g,I){return(I-=g)<0?I+360:I}function w(g,I){return g[0]-I[0]}function W(g,I){return I[0]<=I[1]?I[0]<=g&&g<=I[1]:gB(b[0],b[1])&&(b[1]=a[1]),B(a[0],b[1])>B(b[0],b[1])&&(b[0]=a[0])):t.push(b=a);for(var s,c,a,Z=-1/0,b=(l=0,t[c=t.length-1]);l<=c;b=a,++l)a=t[l],(s=B(b[1],a[0]))>Z&&(Z=s,I=a[0],A=b[1])}return d=o=null,I===1/0||C===1/0?[[NaN,NaN],[NaN,NaN]]:[[I,C],[A,i]]}}(),g.geo.centroid=function(I){hC=GC=uC=BC=wC=WC=pC=VC=yC=XC=YC=0,g.geo.stream(I,LC);var C=yC,A=XC,i=YC,e=C*C+A*A+i*i;return e=0;--t)i.point((o=d[t])[0],o[1]);else A(a.x,a.p.x,-1,i);a=a.p}d=(a=a.o).z,Z=!Z}while(!a.v);i.lineEnd()}}}function EC(g){if(I=g.length){for(var I,C,A=0,i=g[0];++A=0?1:-1,W=w*B,p=W>pg,V=Z*G;if(RC.add(Math.atan2(V*w*Math.sin(W),b*u+V*Math.cos(W))),e+=p?B+w*Vg:B,p^n>=C^m>=C){var y=MC(KC(o),KC(g));fC(y);var X=MC(i,y);fC(X);var Y=(p^B>=0?-1:1)*Fg(X[2]);(A>Y||A===Y&&(y[0]||y[1]))&&(l+=p^B>=0?1:-1)}if(!r++)break;n=m,Z=G,b=u,o=g}}return(e<-wg||e0){for(G||(l.polygonStart(),G=!0),l.lineStart();++e1&&2&I&&C.push(C.pop().concat(C.shift())),t.push(C.filter(qC))}return d}}function qC(g){return g.length>1}function $C(){var g,I=[];return{lineStart:function(){I.push(g=[])},point:function(I,C){g.push([I,C])},lineEnd:M,buffer:function(){var C=I;return I=[],g=null,C},rejoin:function(){I.length>1&&I.push(I.pop().concat(I.shift()))}}}function gA(g,I){return((g=g.x)[0]<0?g[1]-Xg-wg:Xg-g[1])-((I=I.x)[0]<0?I[1]-Xg-wg:Xg-I[1])}var IA=_C(jC,(function(g){var I,C=NaN,A=NaN,i=NaN;return{lineStart:function(){g.lineStart(),I=1},point:function(e,l){var t=e>0?pg:-pg,s=m(e-C);m(s-pg)0?Xg:-Xg),g.point(i,A),g.lineEnd(),g.lineStart(),g.point(t,A),g.point(e,A),I=0):i!==t&&s>=pg&&(m(C-i)wg?Math.atan((Math.sin(I)*(e=Math.cos(A))*Math.sin(C)-Math.sin(A)*(i=Math.cos(I))*Math.sin(g))/(i*e*l)):(I+A)/2}(C,A,e,l),g.point(i,A),g.lineEnd(),g.lineStart(),g.point(t,A),I=0),g.point(C=e,A=l),i=t},lineEnd:function(){g.lineEnd(),C=A=NaN},clean:function(){return 2-I}}}),(function(g,I,C,A){var i;if(null==g)i=C*Xg,A.point(-pg,i),A.point(0,i),A.point(pg,i),A.point(pg,0),A.point(pg,-i),A.point(0,-i),A.point(-pg,-i),A.point(-pg,0),A.point(-pg,i);else if(m(g[0]-I[0])>wg){var e=g[0]0)){if(e/=n,n<0){if(e0){if(e>o)return;e>d&&(d=e)}if(e=C-s,n||!(e<0)){if(e/=n,n<0){if(e>o)return;e>d&&(d=e)}else if(n>0){if(e0)){if(e/=a,a<0){if(e0){if(e>o)return;e>d&&(d=e)}if(e=A-c,a||!(e<0)){if(e/=a,a<0){if(e>o)return;e>d&&(d=e)}else if(a>0){if(e0&&(i.a={x:s+d*n,y:c+d*a}),o<1&&(i.b={x:s+o*n,y:c+o*a}),i}}}}}}var AA=1e9;function iA(I,C,A,i){return function(s){var c,d,o,n,a,Z,b,r,m,h,G,u=s,B=$C(),w=CA(I,C,A,i),W={point:y,lineStart:function(){W.point=X,d&&d.push(o=[]);h=!0,m=!1,b=r=NaN},lineEnd:function(){c&&(X(n,a),Z&&m&&B.rejoin(),c.push(B.buffer()));W.point=y,m&&s.lineEnd()},polygonStart:function(){s=B,c=[],d=[],G=!0},polygonEnd:function(){s=u,c=g.merge(c);var C=function(g){for(var I=0,C=d.length,A=g[1],i=0;iA&&Hg(c,e,g)>0&&++I:e[1]<=A&&Hg(c,e,g)<0&&--I,c=e;return 0!==I}([I,i]),A=G&&C,e=c.length;(A||e)&&(s.polygonStart(),A&&(s.lineStart(),p(null,null,1,s),s.lineEnd()),e&&OC(c,l,C,p,s),s.polygonEnd()),c=d=o=null}};function p(g,l,s,c){var d=0,o=0;if(null==g||(d=e(g,s))!==(o=e(l,s))||t(g,l)<0^s>0)do{c.point(0===d||3===d?I:A,d>1?i:C)}while((d=(d+s+4)%4)!==o);else c.point(l[0],l[1])}function V(g,e){return I<=g&&g<=A&&C<=e&&e<=i}function y(g,I){V(g,I)&&s.point(g,I)}function X(g,I){var C=V(g=Math.max(-AA,Math.min(AA,g)),I=Math.max(-AA,Math.min(AA,I)));if(d&&o.push([g,I]),h)n=g,a=I,Z=C,h=!1,C&&(s.lineStart(),s.point(g,I));else if(C&&m)s.point(g,I);else{var A={a:{x:b,y:r},b:{x:g,y:I}};w(A)?(m||(s.lineStart(),s.point(A.a.x,A.a.y)),s.point(A.b.x,A.b.y),C||s.lineEnd(),G=!1):C&&(s.lineStart(),s.point(g,I),G=!1)}b=g,r=I,m=C}return W};function e(g,i){return m(g[0]-I)0?0:3:m(g[0]-A)0?2:1:m(g[1]-C)0?1:0:i>0?3:2}function l(g,I){return t(g.x,I.x)}function t(g,I){var C=e(g,1),A=e(I,1);return C!==A?C-A:0===C?I[1]-g[1]:1===C?g[0]-I[0]:2===C?g[1]-I[1]:I[0]-g[0]}}function eA(g){var I=0,C=pg/3,A=RA(g),i=A(I,C);return i.parallels=function(g){return arguments.length?A(I=g[0]*pg/180,C=g[1]*pg/180):[I/pg*180,C/pg*180]},i}function lA(g,I){var C=Math.sin(g),A=(C+Math.sin(I))/2,i=1+C*(2*A-C),e=Math.sqrt(i)/A;function l(g,I){var C=Math.sqrt(i-2*A*Math.sin(I))/A;return[C*Math.sin(g*=A),e-C*Math.cos(g)]}return l.invert=function(g,I){var C=e-I;return[Math.atan2(g,C)/A,Fg((i-(g*g+C*C)*A*A)/(2*A))]},l}g.geo.clipExtent=function(){var g,I,C,A,i,e,l={stream:function(g){return i&&(i.valid=!1),(i=e(g)).valid=!0,i},extent:function(t){return arguments.length?(e=iA(g=+t[0][0],I=+t[0][1],C=+t[1][0],A=+t[1][1]),i&&(i.valid=!1,i=null),l):[[g,I],[C,A]]}};return l.extent([[0,0],[960,500]])},(g.geo.conicEqualArea=function(){return eA(lA)}).raw=lA,g.geo.albers=function(){return g.geo.conicEqualArea().rotate([96,0]).center([-.6,38.7]).parallels([29.5,45.5]).scale(1070)},g.geo.albersUsa=function(){var I,C,A,i,e=g.geo.albers(),l=g.geo.conicEqualArea().rotate([154,0]).center([-2,58.5]).parallels([55,65]),t=g.geo.conicEqualArea().rotate([157,0]).center([-3,19.9]).parallels([8,18]),s={point:function(g,C){I=[g,C]}};function c(g){var e=g[0],l=g[1];return I=null,C(e,l),I||(A(e,l),I)||i(e,l),I}return c.invert=function(g){var I=e.scale(),C=e.translate(),A=(g[0]-C[0])/I,i=(g[1]-C[1])/I;return(i>=.12&&i<.234&&A>=-.425&&A<-.214?l:i>=.166&&i<.234&&A>=-.214&&A<-.115?t:e).invert(g)},c.stream=function(g){var I=e.stream(g),C=l.stream(g),A=t.stream(g);return{point:function(g,i){I.point(g,i),C.point(g,i),A.point(g,i)},sphere:function(){I.sphere(),C.sphere(),A.sphere()},lineStart:function(){I.lineStart(),C.lineStart(),A.lineStart()},lineEnd:function(){I.lineEnd(),C.lineEnd(),A.lineEnd()},polygonStart:function(){I.polygonStart(),C.polygonStart(),A.polygonStart()},polygonEnd:function(){I.polygonEnd(),C.polygonEnd(),A.polygonEnd()}}},c.precision=function(g){return arguments.length?(e.precision(g),l.precision(g),t.precision(g),c):e.precision()},c.scale=function(g){return arguments.length?(e.scale(g),l.scale(.35*g),t.scale(g),c.translate(e.translate())):e.scale()},c.translate=function(g){if(!arguments.length)return e.translate();var I=e.scale(),d=+g[0],o=+g[1];return C=e.translate(g).clipExtent([[d-.455*I,o-.238*I],[d+.455*I,o+.238*I]]).stream(s).point,A=l.translate([d-.307*I,o+.201*I]).clipExtent([[d-.425*I+wg,o+.12*I+wg],[d-.214*I-wg,o+.234*I-wg]]).stream(s).point,i=t.translate([d-.205*I,o+.212*I]).clipExtent([[d-.214*I+wg,o+.166*I+wg],[d-.115*I-wg,o+.234*I-wg]]).stream(s).point,c},c.scale(1070)};var tA,sA,cA,dA,oA,nA,aA={point:M,lineStart:M,lineEnd:M,polygonStart:function(){sA=0,aA.lineStart=ZA},polygonEnd:function(){aA.lineStart=aA.lineEnd=aA.point=M,tA+=m(sA/2)}};function ZA(){var g,I,C,A;function i(g,I){sA+=A*g-C*I,C=g,A=I}aA.point=function(e,l){aA.point=i,g=C=e,I=A=l},aA.lineEnd=function(){i(g,I)}}var bA={point:function(g,I){goA&&(oA=g);InA&&(nA=I)},lineStart:M,lineEnd:M,polygonStart:M,polygonEnd:M};function rA(){var g=mA(4.5),I=[],C={point:A,lineStart:function(){C.point=i},lineEnd:l,polygonStart:function(){C.lineEnd=t},polygonEnd:function(){C.lineEnd=l,C.point=A},pointRadius:function(I){return g=mA(I),C},result:function(){if(I.length){var g=I.join("");return I=[],g}}};function A(C,A){I.push("M",C,",",A,g)}function i(g,A){I.push("M",g,",",A),C.point=e}function e(g,C){I.push("L",g,",",C)}function l(){C.point=A}function t(){I.push("Z")}return C}function mA(g){return"m0,"+g+"a"+g+","+g+" 0 1,1 0,"+-2*g+"a"+g+","+g+" 0 1,1 0,"+2*g+"z"}var hA,GA={point:uA,lineStart:BA,lineEnd:wA,polygonStart:function(){GA.lineStart=WA},polygonEnd:function(){GA.point=uA,GA.lineStart=BA,GA.lineEnd=wA}};function uA(g,I){uC+=g,BC+=I,++wC}function BA(){var g,I;function C(C,A){var i=C-g,e=A-I,l=Math.sqrt(i*i+e*e);WC+=l*(g+C)/2,pC+=l*(I+A)/2,VC+=l,uA(g=C,I=A)}GA.point=function(A,i){GA.point=C,uA(g=A,I=i)}}function wA(){GA.point=uA}function WA(){var g,I,C,A;function i(g,I){var i=g-C,e=I-A,l=Math.sqrt(i*i+e*e);WC+=l*(C+g)/2,pC+=l*(A+I)/2,VC+=l,yC+=(l=A*g-C*I)*(C+g),XC+=l*(A+I),YC+=3*l,uA(C=g,A=I)}GA.point=function(e,l){GA.point=i,uA(g=C=e,I=A=l)},GA.lineEnd=function(){i(g,I)}}function pA(g){var I=4.5,C={point:A,lineStart:function(){C.point=i},lineEnd:l,polygonStart:function(){C.lineEnd=t},polygonEnd:function(){C.lineEnd=l,C.point=A},pointRadius:function(g){return I=g,C},result:M};function A(C,A){g.moveTo(C+I,A),g.arc(C,A,I,0,Vg)}function i(I,A){g.moveTo(I,A),C.point=e}function e(I,C){g.lineTo(I,C)}function l(){C.point=A}function t(){g.closePath()}return C}function VA(g){var I=.5,C=Math.cos(30*Yg),A=16;function i(g){return(A?l:e)(g)}function e(I){return XA(I,(function(C,A){C=g(C,A),I.point(C[0],C[1])}))}function l(I){var C,i,e,l,s,c,d,o,n,a,Z,b,r={point:m,lineStart:h,lineEnd:u,polygonStart:function(){I.polygonStart(),r.lineStart=B},polygonEnd:function(){I.polygonEnd(),r.lineStart=h}};function m(C,A){C=g(C,A),I.point(C[0],C[1])}function h(){o=NaN,r.point=G,I.lineStart()}function G(C,i){var e=KC([C,i]),l=g(C,i);t(o,n,d,a,Z,b,o=l[0],n=l[1],d=C,a=e[0],Z=e[1],b=e[2],A,I),I.point(o,n)}function u(){r.point=m,I.lineEnd()}function B(){h(),r.point=w,r.lineEnd=W}function w(g,I){G(C=g,I),i=o,e=n,l=a,s=Z,c=b,r.point=G}function W(){t(o,n,d,a,Z,b,i,e,C,l,s,c,A,I),r.lineEnd=u,u()}return r}function t(A,i,e,l,s,c,d,o,n,a,Z,b,r,h){var G=d-A,u=o-i,B=G*G+u*u;if(B>4*I&&r--){var w=l+a,W=s+Z,p=c+b,V=Math.sqrt(w*w+W*W+p*p),y=Math.asin(p/=V),X=m(m(p)-1)I||m((G*H+u*K)/B-.5)>.3||l*a+s*Z+c*b0&&16,i):Math.sqrt(I)},i}function yA(g){this.stream=g}function XA(g,I){return{point:I,sphere:function(){g.sphere()},lineStart:function(){g.lineStart()},lineEnd:function(){g.lineEnd()},polygonStart:function(){g.polygonStart()},polygonEnd:function(){g.polygonEnd()}}}function YA(g){return RA((function(){return g}))()}function RA(I){var C,A,i,e,l,t,s=VA((function(g,I){return[(g=C(g,I))[0]*c+e,l-g[1]*c]})),c=150,d=480,o=250,n=0,a=0,Z=0,b=0,r=0,h=IA,G=N,u=null,B=null;function w(g){return[(g=i(g[0]*Yg,g[1]*Yg))[0]*c+e,l-g[1]*c]}function W(g){return(g=i.invert((g[0]-e)/c,(l-g[1])/c))&&[g[0]*Rg,g[1]*Rg]}function p(){i=QC(A=FA(Z,b,r),C);var g=C(n,a);return e=d-g[0]*c,l=o+g[1]*c,V()}function V(){return t&&(t.valid=!1,t=null),w}return w.stream=function(g){return t&&(t.valid=!1),(t=NA(h(A,s(G(g))))).valid=!0,t},w.clipAngle=function(g){return arguments.length?(h=null==g?(u=g,IA):function(g){var I=Math.cos(g),C=I>0,A=m(I)>wg;return _C(i,(function(g){var I,t,s,c,d;return{lineStart:function(){c=s=!1,d=1},point:function(o,n){var a,Z=[o,n],b=i(o,n),r=C?b?0:l(o,n):b?l(o+(o<0?pg:-pg),n):0;if(!I&&(c=s=b)&&g.lineStart(),b!==s&&(a=e(I,Z),(DC(I,a)||DC(Z,a))&&(Z[0]+=wg,Z[1]+=wg,b=i(Z[0],Z[1]))),b!==s)d=0,b?(g.lineStart(),a=e(Z,I),g.point(a[0],a[1])):(a=e(I,Z),g.point(a[0],a[1]),g.lineEnd()),I=a;else if(A&&I&&C^b){var m;r&t||!(m=e(Z,I,!0))||(d=0,C?(g.lineStart(),g.point(m[0][0],m[0][1]),g.point(m[1][0],m[1][1]),g.lineEnd()):(g.point(m[1][0],m[1][1]),g.lineEnd(),g.lineStart(),g.point(m[0][0],m[0][1])))}!b||I&&DC(I,Z)||g.point(Z[0],Z[1]),I=Z,s=b,t=r},lineEnd:function(){s&&g.lineEnd(),I=null},clean:function(){return d|(c&&s)<<1}}}),fA(g,6*Yg),C?[0,-g]:[-pg,g-pg]);function i(g,C){return Math.cos(g)*Math.cos(C)>I}function e(g,C,A){var i=[1,0,0],e=MC(KC(g),KC(C)),l=FC(e,e),t=e[0],s=l-t*t;if(!s)return!A&&g;var c=I*l/s,d=-I*t/s,o=MC(i,e),n=SC(i,c);JC(n,SC(e,d));var a=o,Z=FC(n,a),b=FC(a,a),r=Z*Z-b*(FC(n,n)-1);if(!(r<0)){var h=Math.sqrt(r),G=SC(a,(-Z-h)/b);if(JC(G,n),G=kC(G),!A)return G;var u,B=g[0],w=C[0],W=g[1],p=C[1];w0^G[1]<(m(G[0]-B)pg^(B<=G[0]&&G[0]<=w)){var X=SC(a,(-Z+h)/b);return JC(X,n),[G,kC(X)]}}}function l(I,A){var i=C?g:pg-g,e=0;return I<-i?e|=1:I>i&&(e|=2),A<-i?e|=4:A>i&&(e|=8),e}}((u=+g)*Yg),V()):u},w.clipExtent=function(g){return arguments.length?(B=g,G=g?iA(g[0][0],g[0][1],g[1][0],g[1][1]):N,V()):B},w.scale=function(g){return arguments.length?(c=+g,p()):c},w.translate=function(g){return arguments.length?(d=+g[0],o=+g[1],p()):[d,o]},w.center=function(g){return arguments.length?(n=g[0]%360*Yg,a=g[1]%360*Yg,p()):[n*Rg,a*Rg]},w.rotate=function(g){return arguments.length?(Z=g[0]%360*Yg,b=g[1]%360*Yg,r=g.length>2?g[2]%360*Yg:0,p()):[Z*Rg,b*Rg,r*Rg]},g.rebind(w,s,"precision"),function(){return C=I.apply(this,arguments),w.invert=C.invert&&W,p()}}function NA(g){return XA(g,(function(I,C){g.point(I*Yg,C*Yg)}))}function HA(g,I){return[g,I]}function KA(g,I){return[g>pg?g-Vg:g<-pg?g+Vg:g,I]}function FA(g,I,C){return g?I||C?QC(JA(g),SA(I,C)):JA(g):I||C?SA(I,C):KA}function MA(g){return function(I,C){return[(I+=g)>pg?I-Vg:I<-pg?I+Vg:I,C]}}function JA(g){var I=MA(g);return I.invert=MA(-g),I}function SA(g,I){var C=Math.cos(g),A=Math.sin(g),i=Math.cos(I),e=Math.sin(I);function l(g,I){var l=Math.cos(I),t=Math.cos(g)*l,s=Math.sin(g)*l,c=Math.sin(I),d=c*C+t*A;return[Math.atan2(s*i-d*e,t*C-c*A),Fg(d*i+s*e)]}return l.invert=function(g,I){var l=Math.cos(I),t=Math.cos(g)*l,s=Math.sin(g)*l,c=Math.sin(I),d=c*i-s*e;return[Math.atan2(s*i+c*e,t*C+d*A),Fg(d*C-t*A)]},l}function fA(g,I){var C=Math.cos(g),A=Math.sin(g);return function(i,e,l,t){var s=l*I;null!=i?(i=kA(C,i),e=kA(C,e),(l>0?ie)&&(i+=l*Vg)):(i=g+l*Vg,e=g-.5*s);for(var c,d=i;l>0?d>e:d2?g[2]*Yg:0),I.invert=function(I){return(I=g.invert(I[0]*Yg,I[1]*Yg))[0]*=Rg,I[1]*=Rg,I},I},KA.invert=HA,g.geo.circle=function(){var g,I,C=[0,0],A=6;function i(){var g="function"==typeof C?C.apply(this,arguments):C,A=FA(-g[0]*Yg,-g[1]*Yg,0).invert,i=[];return I(null,null,1,{point:function(g,I){i.push(g=A(g,I)),g[0]*=Rg,g[1]*=Rg}}),{type:"Polygon",coordinates:[i]}}return i.origin=function(g){return arguments.length?(C=g,i):C},i.angle=function(C){return arguments.length?(I=fA((g=+C)*Yg,A*Yg),i):g},i.precision=function(C){return arguments.length?(I=fA(g*Yg,(A=+C)*Yg),i):A},i.angle(90)},g.geo.distance=function(g,I){var C,A=(I[0]-g[0])*Yg,i=g[1]*Yg,e=I[1]*Yg,l=Math.sin(A),t=Math.cos(A),s=Math.sin(i),c=Math.cos(i),d=Math.sin(e),o=Math.cos(e);return Math.atan2(Math.sqrt((C=o*l)*C+(C=c*d-s*o*t)*C),s*d+c*o*t)},g.geo.graticule=function(){var I,C,A,i,e,l,t,s,c,d,o,n,a=10,Z=a,b=90,r=360,h=2.5;function G(){return{type:"MultiLineString",coordinates:u()}}function u(){return g.range(Math.ceil(i/b)*b,A,b).map(o).concat(g.range(Math.ceil(s/r)*r,t,r).map(n)).concat(g.range(Math.ceil(C/a)*a,I,a).filter((function(g){return m(g%b)>wg})).map(c)).concat(g.range(Math.ceil(l/Z)*Z,e,Z).filter((function(g){return m(g%r)>wg})).map(d))}return G.lines=function(){return u().map((function(g){return{type:"LineString",coordinates:g}}))},G.outline=function(){return{type:"Polygon",coordinates:[o(i).concat(n(t).slice(1),o(A).reverse().slice(1),n(s).reverse().slice(1))]}},G.extent=function(g){return arguments.length?G.majorExtent(g).minorExtent(g):G.minorExtent()},G.majorExtent=function(g){return arguments.length?(i=+g[0][0],A=+g[1][0],s=+g[0][1],t=+g[1][1],i>A&&(g=i,i=A,A=g),s>t&&(g=s,s=t,t=g),G.precision(h)):[[i,s],[A,t]]},G.minorExtent=function(g){return arguments.length?(C=+g[0][0],I=+g[1][0],l=+g[0][1],e=+g[1][1],C>I&&(g=C,C=I,I=g),l>e&&(g=l,l=e,e=g),G.precision(h)):[[C,l],[I,e]]},G.step=function(g){return arguments.length?G.majorStep(g).minorStep(g):G.minorStep()},G.majorStep=function(g){return arguments.length?(b=+g[0],r=+g[1],G):[b,r]},G.minorStep=function(g){return arguments.length?(a=+g[0],Z=+g[1],G):[a,Z]},G.precision=function(g){return arguments.length?(h=+g,c=DA(l,e,90),d=LA(C,I,h),o=DA(s,t,90),n=LA(i,A,h),G):h},G.majorExtent([[-180,-90+wg],[180,90-wg]]).minorExtent([[-180,-80-wg],[180,80+wg]])},g.geo.greatArc=function(){var I,C,A=zA,i=vA;function e(){return{type:"LineString",coordinates:[I||A.apply(this,arguments),C||i.apply(this,arguments)]}}return e.distance=function(){return g.geo.distance(I||A.apply(this,arguments),C||i.apply(this,arguments))},e.source=function(g){return arguments.length?(A=g,I="function"==typeof g?null:g,e):A},e.target=function(g){return arguments.length?(i=g,C="function"==typeof g?null:g,e):i},e.precision=function(){return arguments.length?e:0},e},g.geo.interpolate=function(g,I){return C=g[0]*Yg,A=g[1]*Yg,i=I[0]*Yg,e=I[1]*Yg,l=Math.cos(A),t=Math.sin(A),s=Math.cos(e),c=Math.sin(e),d=l*Math.cos(C),o=l*Math.sin(C),n=s*Math.cos(i),a=s*Math.sin(i),Z=2*Math.asin(Math.sqrt(Jg(e-A)+l*s*Jg(i-C))),b=1/Math.sin(Z),(r=Z?function(g){var I=Math.sin(g*=Z)*b,C=Math.sin(Z-g)*b,A=C*d+I*n,i=C*o+I*a,e=C*t+I*c;return[Math.atan2(i,A)*Rg,Math.atan2(e,Math.sqrt(A*A+i*i))*Rg]}:function(){return[C*Rg,A*Rg]}).distance=Z,r;var C,A,i,e,l,t,s,c,d,o,n,a,Z,b,r},g.geo.length=function(I){return hA=0,g.geo.stream(I,TA),hA};var TA={sphere:M,point:M,lineStart:function(){var g,I,C;function A(A,i){var e=Math.sin(i*=Yg),l=Math.cos(i),t=m((A*=Yg)-g),s=Math.cos(t);hA+=Math.atan2(Math.sqrt((t=l*Math.sin(t))*t+(t=C*e-I*l*s)*t),I*e+C*l*s),g=A,I=e,C=l}TA.point=function(i,e){g=i*Yg,I=Math.sin(e*=Yg),C=Math.cos(e),TA.point=A},TA.lineEnd=function(){TA.point=TA.lineEnd=M}},lineEnd:M,polygonStart:M,polygonEnd:M};function xA(g,I){function C(I,C){var A=Math.cos(I),i=Math.cos(C),e=g(A*i);return[e*i*Math.sin(I),e*Math.sin(C)]}return C.invert=function(g,C){var A=Math.sqrt(g*g+C*C),i=I(A),e=Math.sin(i),l=Math.cos(i);return[Math.atan2(g*e,A*l),Math.asin(A&&C*e/A)]},C}var UA=xA((function(g){return Math.sqrt(2/(1+g))}),(function(g){return 2*Math.asin(g/2)}));(g.geo.azimuthalEqualArea=function(){return YA(UA)}).raw=UA;var QA=xA((function(g){var I=Math.acos(g);return I&&I/Math.sin(I)}),N);function jA(g,I){var C=Math.cos(g),A=function(g){return Math.tan(pg/4+g/2)},i=g===I?Math.sin(g):Math.log(C/Math.cos(I))/Math.log(A(I)/A(g)),e=C*Math.pow(A(g),i)/i;if(!i)return PA;function l(g,I){e>0?I<-Xg+wg&&(I=-Xg+wg):I>Xg-wg&&(I=Xg-wg);var C=e/Math.pow(A(I),i);return[C*Math.sin(i*g),e-C*Math.cos(i*g)]}return l.invert=function(g,I){var C=e-I,A=Ng(i)*Math.sqrt(g*g+C*C);return[Math.atan2(g,C)/i,2*Math.atan(Math.pow(e/A,1/i))-Xg]},l}function OA(g,I){var C=Math.cos(g),A=g===I?Math.sin(g):(C-Math.cos(I))/(I-g),i=C/A+g;if(m(A)1&&Hg(g[C[A-2]],g[C[A-1]],g[i])<=0;)--A;C[A++]=i}return C.slice(0,A)}function ii(g,I){return g[0]-I[0]||g[1]-I[1]}(g.geo.stereographic=function(){return YA($A)}).raw=$A,gi.invert=function(g,I){return[-I,2*Math.atan(Math.exp(g))-Xg]},(g.geo.transverseMercator=function(){var g=_A(gi),I=g.center,C=g.rotate;return g.center=function(g){return g?I([-g[1],g[0]]):[(g=I())[1],-g[0]]},g.rotate=function(g){return g?C([g[0],g[1],g.length>2?g[2]+90:90]):[(g=C())[0],g[1],g[2]-90]},C([0,0,90])}).raw=gi,g.geom={},g.geom.hull=function(g){var I=Ii,C=Ci;if(arguments.length)return A(g);function A(g){if(g.length<3)return[];var A,i=bI(I),e=bI(C),l=g.length,t=[],s=[];for(A=0;A=0;--A)a.push(g[t[c[A]][2]]);for(A=+o;Awg)t=t.L;else{if(!((i=e-wi(t,l))>wg)){A>-wg?(I=t.P,C=t):i>-wg?(I=t,C=t.N):I=C=t;break}if(!t.R){I=t;break}t=t.R}var s=mi(g);if(oi.insert(I,s),I||C){if(I===C)return Xi(I),C=mi(I.site),oi.insert(s,C),s.edge=C.edge=Ni(I.site,s.site),yi(I),void yi(C);if(C){Xi(I),Xi(C);var c=I.site,d=c.x,o=c.y,n=g.x-d,a=g.y-o,Z=C.site,b=Z.x-d,r=Z.y-o,m=2*(n*r-a*b),h=n*n+a*a,G=b*b+r*r,u={x:(r*h-a*G)/m+d,y:(n*G-b*h)/m+o};Ki(C.edge,c,Z,u),s.edge=Ni(c,g,null,u),C.edge=Ni(g,Z,null,u),yi(I),yi(C)}else s.edge=Ni(I.site,s.site)}}function Bi(g,I){var C=g.site,A=C.x,i=C.y,e=i-I;if(!e)return A;var l=g.P;if(!l)return-1/0;var t=(C=l.site).x,s=C.y,c=s-I;if(!c)return t;var d=t-A,o=1/e-1/c,n=d/c;return o?(-n+Math.sqrt(n*n-2*o*(d*d/(-2*c)-s+c/2+i-e/2)))/o+A:(A+t)/2}function wi(g,I){var C=g.N;if(C)return Bi(C,I);var A=g.site;return A.y===I?A.x:1/0}function Wi(g){this.site=g,this.edges=[]}function pi(g,I){return I.angle-g.angle}function Vi(){Ji(this),this.x=this.y=this.arc=this.site=this.cy=null}function yi(g){var I=g.P,C=g.N;if(I&&C){var A=I.site,i=g.site,e=C.site;if(A!==e){var l=i.x,t=i.y,s=A.x-l,c=A.y-t,d=e.x-l,o=2*(s*(r=e.y-t)-c*d);if(!(o>=-Wg)){var n=s*s+c*c,a=d*d+r*r,Z=(r*n-c*a)/o,b=(s*a-d*n)/o,r=b+t,m=bi.pop()||new Vi;m.arc=g,m.site=i,m.x=Z+l,m.y=r+Math.sqrt(Z*Z+b*b),m.cy=r,g.circle=m;for(var h=null,G=ai._;G;)if(m.y=t)return;if(n>Z){if(e){if(e.y>=c)return}else e={x:r,y:s};C={x:r,y:c}}else{if(e){if(e.y1)if(n>Z){if(e){if(e.y>=c)return}else e={x:(s-i)/A,y:s};C={x:(c-i)/A,y:c}}else{if(e){if(e.y=t)return}else e={x:l,y:A*l+i};C={x:t,y:A*t+i}}else{if(e){if(e.xwg||m(i-C)>wg)&&(t.splice(l,0,new Fi(Hi(e.site,d,m(A-o)wg?{x:o,y:m(I-o)wg?{x:m(C-Z)wg?{x:n,y:m(I-n)wg?{x:m(C-a)=C&&c.x<=i&&c.y>=A&&c.y<=l?[[C,l],[i,l],[i,A],[C,A]]:[]).point=g[t]})),I}function t(g){return g.map((function(g,I){return{x:Math.round(A(g,I)/wg)*wg,y:Math.round(i(g,I)/wg)*wg,i:I}}))}return l.links=function(g){return Di(t(g)).edges.filter((function(g){return g.l&&g.r})).map((function(I){return{source:g[I.l.i],target:g[I.r.i]}}))},l.triangles=function(g){var I=[];return Di(t(g)).cells.forEach((function(C,A){for(var i,e,l,t,s=C.site,c=C.edges.sort(pi),d=-1,o=c.length,n=c[o-1].edge,a=n.l===s?n.r:n.l;++de&&(i=I.slice(e,i),t[l]?t[l]+=i:t[++l]=i),(C=C[0])===(A=A[0])?t[l]?t[l]+=A:t[++l]=A:(t[++l]=null,s.push({i:l,x:ji(C,A)})),e=Pi.lastIndex;return eb&&(b=s.x),s.y>r&&(r=s.y),c.push(s.x),d.push(s.y);else for(o=0;ob&&(b=u),B>r&&(r=B),c.push(u),d.push(B)}var w=b-a,W=r-Z;function p(g,I,C,A,i,e,l,t){if(!isNaN(C)&&!isNaN(A))if(g.leaf){var s=g.x,c=g.y;if(null!=s)if(m(s-C)+m(c-A)<.01)V(g,I,C,A,i,e,l,t);else{var d=g.point;g.x=g.y=g.point=null,V(g,d,s,c,i,e,l,t),V(g,I,C,A,i,e,l,t)}else g.x=C,g.y=A,g.point=I}else V(g,I,C,A,i,e,l,t)}function V(g,I,C,A,i,e,l,t){var s=.5*(i+l),c=.5*(e+t),d=C>=s,o=A>=c,n=o<<1|d;g.leaf=!1,d?i=s:l=s,o?e=c:t=c,p(g=g.nodes[n]||(g.nodes[n]={leaf:!0,nodes:[],point:null,x:null,y:null}),I,C,A,i,e,l,t)}w>W?r=Z+w:b=a+W;var y={leaf:!0,nodes:[],point:null,x:null,y:null,add:function(g){p(y,g,+h(g,++o),+G(g,o),a,Z,b,r)}};if(y.visit=function(g){xi(g,y,a,Z,b,r)},y.find=function(g){return function(g,I,C,A,i,e,l){var t,s=1/0;return function g(c,d,o,n,a){if(!(d>e||o>l||n=B)<<1|I>=u,W=w+4;w=0&&!(A=g.interpolators[i](I,C)););return A}function qi(g,I){var C,A=[],i=[],e=g.length,l=I.length,t=Math.min(g.length,I.length);for(C=0;C=1)return 1;var I=g*g,C=I*g;return 4*(g<.5?C:3*(g-I)+C-.75)}function te(g){return 1-Math.cos(g*Xg)}function se(g){return Math.pow(2,10*(g-1))}function ce(g){return 1-Math.sqrt(1-g*g)}function de(g){return g<1/2.75?7.5625*g*g:g<2/2.75?7.5625*(g-=1.5/2.75)*g+.75:g<2.5/2.75?7.5625*(g-=2.25/2.75)*g+.9375:7.5625*(g-=2.625/2.75)*g+.984375}function oe(g,I){return I-=g,function(C){return Math.round(g+I*C)}}function ne(g){var I,C,A,i=[g.a,g.b],e=[g.c,g.d],l=Ze(i),t=ae(i,e),s=Ze(((I=e)[0]+=(A=-t)*(C=i)[0],I[1]+=A*C[1],I))||0;i[0]*e[1]=0?g.slice(0,A):g,e=A>=0?g.slice(A+1):"in";return i=ge.get(i)||$i,e=Ie.get(e)||N,C=e(i.apply(null,I.call(arguments,1))),function(g){return g<=0?0:g>=1?1:C(g)}},g.interpolateHcl=function(I,C){I=g.hcl(I),C=g.hcl(C);var A=I.h,i=I.c,e=I.l,l=C.h-A,t=C.c-i,s=C.l-e;isNaN(t)&&(t=0,i=isNaN(i)?C.c:i);isNaN(l)?(l=0,A=isNaN(A)?C.h:A):l>180?l-=360:l<-180&&(l+=360);return function(g){return Qg(A+l*g,i+t*g,e+s*g)+""}},g.interpolateHsl=function(I,C){I=g.hsl(I),C=g.hsl(C);var A=I.h,i=I.s,e=I.l,l=C.h-A,t=C.s-i,s=C.l-e;isNaN(t)&&(t=0,i=isNaN(i)?C.s:i);isNaN(l)?(l=0,A=isNaN(A)?C.h:A):l>180?l-=360:l<-180&&(l+=360);return function(g){return Tg(A+l*g,i+t*g,e+s*g)+""}},g.interpolateLab=function(I,C){I=g.lab(I),C=g.lab(C);var A=I.l,i=I.a,e=I.b,l=C.l-A,t=C.a-i,s=C.b-e;return function(g){return $g(A+l*g,i+t*g,e+s*g)+""}},g.interpolateRound=oe,g.transform=function(I){var C=A.createElementNS(g.ns.prefix.svg,"g");return(g.transform=function(g){if(null!=g){C.setAttribute("transform",g);var I=C.transform.baseVal.consolidate()}return new ne(I?I.matrix:be)})(I)},ne.prototype.toString=function(){return"translate("+this.translate+")rotate("+this.rotate+")skewX("+this.skew+")scale("+this.scale+")"};var be={a:1,b:0,c:0,d:1,e:0,f:0};function re(g){return g.length?g.pop()+",":""}function me(I,C){var A=[],i=[];return I=g.transform(I),C=g.transform(C),function(g,I,C,A){if(g[0]!==I[0]||g[1]!==I[1]){var i=C.push("translate(",null,",",null,")");A.push({i:i-4,x:ji(g[0],I[0])},{i:i-2,x:ji(g[1],I[1])})}else(I[0]||I[1])&&C.push("translate("+I+")")}(I.translate,C.translate,A,i),function(g,I,C,A){g!==I?(g-I>180?I+=360:I-g>180&&(g+=360),A.push({i:C.push(re(C)+"rotate(",null,")")-2,x:ji(g,I)})):I&&C.push(re(C)+"rotate("+I+")")}(I.rotate,C.rotate,A,i),function(g,I,C,A){g!==I?A.push({i:C.push(re(C)+"skewX(",null,")")-2,x:ji(g,I)}):I&&C.push(re(C)+"skewX("+I+")")}(I.skew,C.skew,A,i),function(g,I,C,A){if(g[0]!==I[0]||g[1]!==I[1]){var i=C.push(re(C)+"scale(",null,",",null,")");A.push({i:i-4,x:ji(g[0],I[0])},{i:i-2,x:ji(g[1],I[1])})}else 1===I[0]&&1===I[1]||C.push(re(C)+"scale("+I+")")}(I.scale,C.scale,A,i),I=C=null,function(g){for(var I,C=-1,e=i.length;++C0?A=g:(I.c=null,I.t=NaN,I=null,s.start({type:"end",alpha:A=0})):g>0&&(s.start({type:"start",alpha:A=g}),I=WI(t.tick)),t):A},t.start=function(){var g,I,C,A=m.length,s=h.length,d=c[0],Z=c[1];for(g=0;g=0;)C.push(i[A])}function Ke(g,I){for(var C=[g],A=[];null!=(g=C.pop());)if(A.push(g),(e=g.children)&&(i=e.length))for(var i,e,l=-1;++l=0;)l.push(d=c[s]),d.parent=e,d.depth=e.depth+1;C&&(e.value=0),e.children=c}else C&&(e.value=+C.call(A,e,e.depth)||0),delete e.children;return Ke(i,(function(I){var A,i;g&&(A=I.children)&&A.sort(g),C&&(i=I.parent)&&(i.value+=I.value)})),t}return A.sort=function(I){return arguments.length?(g=I,A):g},A.children=function(g){return arguments.length?(I=g,A):I},A.value=function(g){return arguments.length?(C=g,A):C},A.revalue=function(g){return C&&(He(g,(function(g){g.children&&(g.value=0)})),Ke(g,(function(g){var I;g.children||(g.value=+C.call(A,g,g.depth)||0),(I=g.parent)&&(I.value+=g.value)}))),g},A},g.layout.partition=function(){var I=g.layout.hierarchy(),C=[1,1];function A(g,I,C,i){var e=g.children;if(g.x=I,g.y=g.depth*i,g.dx=C,g.dy=i,e&&(l=e.length)){var l,t,s,c=-1;for(C=g.value?C/g.value:0;++ct&&(t=A),l.push(A)}for(C=0;Ci&&(A=C,i=I);return A}function Qe(g){return g.reduce(je,0)}function je(g,I){return g+I[1]}function Oe(g,I){return Ee(g,Math.ceil(Math.log(I.length)/Math.LN2+1))}function Ee(g,I){for(var C=-1,A=+g[0],i=(g[1]-A)/I,e=[];++C<=I;)e[C]=i*C+A;return e}function Pe(I){return[g.min(I),g.max(I)]}function _e(g,I){return g.value-I.value}function qe(g,I){var C=g._pack_next;g._pack_next=I,I._pack_prev=g,I._pack_next=C,C._pack_prev=I}function $e(g,I){g._pack_next=I,I._pack_prev=g}function gl(g,I){var C=I.x-g.x,A=I.y-g.y,i=g.r+I.r;return.999*i*i>C*C+A*A}function Il(g){if((I=g.children)&&(s=I.length)){var I,C,A,i,e,l,t,s,c=1/0,d=-1/0,o=1/0,n=-1/0;if(I.forEach(Cl),(C=I[0]).x=-C.r,C.y=0,G(C),s>1&&((A=I[1]).x=A.r,A.y=0,G(A),s>2))for(el(C,A,i=I[2]),G(i),qe(C,i),C._pack_prev=i,qe(i,A),A=C._pack_next,e=3;e0)for(l=-1;++l=o[0]&&s<=o[1]&&((t=c[g.bisect(n,s,1,Z)-1]).y+=b,t.push(e[l]));return c}return e.value=function(g){return arguments.length?(C=g,e):C},e.range=function(g){return arguments.length?(A=bI(g),e):A},e.bins=function(g){return arguments.length?(i="number"==typeof g?function(I){return Ee(I,g)}:bI(g),e):i},e.frequency=function(g){return arguments.length?(I=!!g,e):I},e},g.layout.pack=function(){var I,C=g.layout.hierarchy().sort(_e),A=0,i=[1,1];function e(g,e){var l=C.call(this,g,e),t=l[0],s=i[0],c=i[1],d=null==I?Math.sqrt:"function"==typeof I?I:function(){return I};if(t.x=t.y=0,Ke(t,(function(g){g.r=+d(g.value)})),Ke(t,Il),A){var o=A*(I?1:Math.max(2*t.r/s,2*t.r/c))/2;Ke(t,(function(g){g.r+=o})),Ke(t,Il),Ke(t,(function(g){g.r-=o}))}return il(t,s/2,c/2,I?1:1/Math.max(2*t.r/s,2*t.r/c)),l}return e.size=function(g){return arguments.length?(i=g,e):i},e.radius=function(g){return arguments.length?(I=null==g||"function"==typeof g?g:+g,e):I},e.padding=function(g){return arguments.length?(A=+g,e):A},Ne(e,C)},g.layout.tree=function(){var I=g.layout.hierarchy().sort(null).value(null),C=ll,A=[1,1],i=null;function e(g,e){var c=I.call(this,g,e),d=c[0],o=function(g){var I,C={A:null,children:[g]},A=[C];for(;null!=(I=A.pop());)for(var i,e=I.children,l=0,t=e.length;la.x&&(a=g),g.depth>Z.depth&&(Z=g)}));var b=C(n,a)/2-n.x,r=A[0]/(a.x+C(a,n)/2+b),m=A[1]/(Z.depth||1);He(d,(function(g){g.x=(g.x+b)*r,g.y=g.depth*m}))}return c}function l(g){var I=g.children,A=g.parent.children,i=g.i?A[g.i-1]:null;if(I.length){!function(g){var I,C=0,A=0,i=g.children,e=i.length;for(;--e>=0;)(I=i[e]).z+=C,I.m+=C,C+=I.s+(A+=I.c)}(g);var e=(I[0].z+I[I.length-1].z)/2;i?(g.z=i.z+C(g._,i._),g.m=g.z-e):g.z=e}else i&&(g.z=i.z+C(g._,i._));g.parent.A=function(g,I,A){if(I){for(var i,e=g,l=g,t=I,s=e.parent.children[0],c=e.m,d=l.m,o=t.m,n=s.m;t=sl(t),e=tl(e),t&&e;)s=tl(s),(l=sl(l)).a=g,(i=t.z+o-e.z-c+C(t._,e._))>0&&(cl(dl(t,g,A),g,i),c+=i,d+=i),o+=t.m,c+=e.m,n+=s.m,d+=l.m;t&&!sl(l)&&(l.t=t,l.m+=o-d),e&&!tl(s)&&(s.t=e,s.m+=c-n,A=g)}return A}(g,i,g.parent.A||A[0])}function t(g){g._.x=g.z+g.parent.m,g.m+=g.parent.m}function s(g){g.x*=A[0],g.y=g.depth*A[1]}return e.separation=function(g){return arguments.length?(C=g,e):C},e.size=function(g){return arguments.length?(i=null==(A=g)?s:null,e):i?null:A},e.nodeSize=function(g){return arguments.length?(i=null==(A=g)?null:s,e):i?A:null},Ne(e,I)},g.layout.cluster=function(){var I=g.layout.hierarchy().sort(null).value(null),C=ll,A=[1,1],i=!1;function e(e,l){var t,s=I.call(this,e,l),c=s[0],d=0;Ke(c,(function(I){var A=I.children;A&&A.length?(I.x=function(g){return g.reduce((function(g,I){return g+I.x}),0)/g.length}(A),I.y=function(I){return 1+g.max(I,(function(g){return g.y}))}(A)):(I.x=t?d+=C(I,t):0,I.y=0,t=I)}));var o=ol(c),n=nl(c),a=o.x-C(o,n)/2,Z=n.x+C(n,o)/2;return Ke(c,i?function(g){g.x=(g.x-c.x)*A[0],g.y=(c.y-g.y)*A[1]}:function(g){g.x=(g.x-a)/(Z-a)*A[0],g.y=(1-(c.y?g.y/c.y:1))*A[1]}),s}return e.separation=function(g){return arguments.length?(C=g,e):C},e.size=function(g){return arguments.length?(i=null==(A=g),e):i?null:A},e.nodeSize=function(g){return arguments.length?(i=null!=(A=g),e):i?A:null},Ne(e,I)},g.layout.treemap=function(){var I,C=g.layout.hierarchy(),A=Math.round,i=[1,1],e=null,l=al,t=!1,s="squarify",c=.5*(1+Math.sqrt(5));function d(g,I){for(var C,A,i=-1,e=g.length;++i0;)t.push(C=c[i-1]),t.area+=C.area,"squarify"!==s||(A=a(t,b))<=n?(c.pop(),n=A):(t.area-=t.pop().area,Z(t,b,e,!1),b=Math.min(e.dx,e.dy),t.length=t.area=0,n=1/0);t.length&&(Z(t,b,e,!0),t.length=t.area=0),I.forEach(o)}}function n(g){var I=g.children;if(I&&I.length){var C,A=l(g),i=I.slice(),e=[];for(d(i,A.dx*A.dy/g.value),e.area=0;C=i.pop();)e.push(C),e.area+=C.area,null!=C.z&&(Z(e,C.z?A.dx:A.dy,A,!i.length),e.length=e.area=0);I.forEach(n)}}function a(g,I){for(var C,A=g.area,i=0,e=1/0,l=-1,t=g.length;++li&&(i=C));return I*=I,(A*=A)?Math.max(I*i*c/A,A/(I*e*c)):1/0}function Z(g,I,C,i){var e,l=-1,t=g.length,s=C.x,c=C.y,d=I?A(g.area/I):0;if(I==C.dx){for((i||d>C.dy)&&(d=C.dy);++lC.dx)&&(d=C.dx);++l1);return g+I*C*Math.sqrt(-2*Math.log(i)/i)}},logNormal:function(){var I=g.random.normal.apply(g,arguments);return function(){return Math.exp(I())}},bates:function(I){var C=g.random.irwinHall(I);return function(){return C()/I}},irwinHall:function(g){return function(){for(var I=0,C=0;C2?ul:ml,s=A?Ge:he;return i=l(g,I,s,C),e=l(I,g,s,_i),t}function t(g){return i(g)}return t.invert=function(g){return e(g)},t.domain=function(I){return arguments.length?(g=I.map(Number),l()):g},t.range=function(g){return arguments.length?(I=g,l()):I},t.rangeRound=function(g){return t.range(g).interpolate(oe)},t.clamp=function(g){return arguments.length?(A=g,l()):A},t.interpolate=function(g){return arguments.length?(C=g,l()):C},t.ticks=function(I){return Vl(g,I)},t.tickFormat=function(I,C){return yl(g,I,C)},t.nice=function(I){return Wl(g,I),l()},t.copy=function(){return Bl(g,I,C,A)},l()}function wl(I,C){return g.rebind(I,C,"range","rangeRound","interpolate","clamp")}function Wl(g,I){return hl(g,(C=pl(g,I)[2])?{floor:function(g){return Math.floor(g/C)*C},ceil:function(g){return Math.ceil(g/C)*C}}:Gl);var C}function pl(g,I){null==I&&(I=10);var C=bl(g),A=C[1]-C[0],i=Math.pow(10,Math.floor(Math.log(A/I)/Math.LN10)),e=I/A*i;return e<=.15?i*=10:e<=.35?i*=5:e<=.75&&(i*=2),C[0]=Math.ceil(C[0]/i)*i,C[1]=Math.floor(C[1]/i)*i+.5*i,C[2]=i,C}function Vl(I,C){return g.range.apply(g,pl(I,C))}function yl(I,C,A){var i=pl(I,C);if(A){var e=NI.exec(A);if(e.shift(),"s"===e[8]){var l=g.formatPrefix(Math.max(m(i[0]),m(i[1])));return e[7]||(e[7]="."+Yl(l.scale(i[2]))),e[8]="f",A=g.format(e.join("")),function(g){return A(l.scale(g))+l.symbol}}e[7]||(e[7]="."+function(g,I){var C=Yl(I[2]);return g in Xl?Math.abs(C-Yl(Math.max(m(I[0]),m(I[1]))))+ +("e"!==g):C-2*("%"===g)}(e[8],i)),A=e.join("")}else A=",."+Yl(i[2])+"f";return g.format(A)}g.scale.linear=function(){return Bl([0,1],[0,1],_i,!1)};var Xl={s:1,g:1,p:1,r:1,e:1};function Yl(g){return-Math.floor(Math.log(g)/Math.LN10+.01)}function Rl(I,C,A,i){function e(g){return(A?Math.log(g<0?0:g):-Math.log(g>0?0:-g))/Math.log(C)}function l(g){return A?Math.pow(C,g):-Math.pow(C,-g)}function t(g){return I(e(g))}return t.invert=function(g){return l(I.invert(g))},t.domain=function(g){return arguments.length?(A=g[0]>=0,I.domain((i=g.map(Number)).map(e)),t):i},t.base=function(g){return arguments.length?(C=+g,I.domain(i.map(e)),t):C},t.nice=function(){var g=hl(i.map(e),A?Math:Hl);return I.domain(g),i=g.map(l),t},t.ticks=function(){var g=bl(i),I=[],t=g[0],s=g[1],c=Math.floor(e(t)),d=Math.ceil(e(s)),o=C%1?2:C;if(isFinite(d-c)){if(A){for(;c0;n--)I.push(l(c)*n);for(c=0;I[c]s;d--);I=I.slice(c,d)}return I},t.tickFormat=function(I,C){if(!arguments.length)return Nl;arguments.length<2?C=Nl:"function"!=typeof C&&(C=g.format(C));var i,s=Math.max(.1,I/t.ticks().length),c=A?(i=1e-12,Math.ceil):(i=-1e-12,Math.floor);return function(g){return g/l(c(e(g)+i))<=s?C(g):""}},t.copy=function(){return Rl(I.copy(),C,A,i)},wl(t,I)}g.scale.log=function(){return Rl(g.scale.linear().domain([0,1]),10,!0,[1,10])};var Nl=g.format(".0e"),Hl={floor:function(g){return-Math.ceil(-g)},ceil:function(g){return-Math.floor(-g)}};function Kl(g,I,C){var A=Fl(I),i=Fl(1/I);function e(I){return g(A(I))}return e.invert=function(I){return i(g.invert(I))},e.domain=function(I){return arguments.length?(g.domain((C=I.map(Number)).map(A)),e):C},e.ticks=function(g){return Vl(C,g)},e.tickFormat=function(g,I){return yl(C,g,I)},e.nice=function(g){return e.domain(Wl(C,g))},e.exponent=function(l){return arguments.length?(A=Fl(I=l),i=Fl(1/I),g.domain(C.map(A)),e):I},e.copy=function(){return Kl(g.copy(),I,C)},wl(e,g)}function Fl(g){return function(I){return I<0?-Math.pow(-I,g):Math.pow(I,g)}}function Ml(I,C){var A,i,e;function l(g){return i[((A.get(g)||("range"===C.t?A.set(g,I.push(g)):NaN))-1)%i.length]}function t(C,A){return g.range(I.length).map((function(g){return C+A*g}))}return l.domain=function(g){if(!arguments.length)return I;I=[],A=new G;for(var i,e=-1,t=g.length;++e0?A[g-1]:I[0],go?0:1;if(c=yg)return s(c,a)+(t?s(t,1-a):"")+"Z";var Z,b,r,m,h,G,u,B,w,W,p,V,y=0,X=0,Y=[];if((m=(+l.apply(this,arguments)||0)/2)&&(r=A===xl?Math.sqrt(t*t+c*c):+A.apply(this,arguments),a||(X*=-1),c&&(X=Fg(r/c*Math.sin(m))),t&&(y=Fg(r/t*Math.sin(m)))),c){h=c*Math.cos(d+X),G=c*Math.sin(d+X),u=c*Math.cos(o-X),B=c*Math.sin(o-X);var R=Math.abs(o-d-2*X)<=pg?0:1;if(X&&Pl(h,G,u,B)===a^R){var N=(d+o)/2;h=c*Math.cos(N),G=c*Math.sin(N),u=B=null}}else h=G=0;if(t){w=t*Math.cos(o-y),W=t*Math.sin(o-y),p=t*Math.cos(d+y),V=t*Math.sin(d+y);var H=Math.abs(d-o+2*y)<=pg?0:1;if(y&&Pl(w,W,p,V)===1-a^H){var K=(d+o)/2;w=t*Math.cos(K),W=t*Math.sin(K),p=V=null}}else w=W=0;if(n>wg&&(Z=Math.min(Math.abs(c-t)/2,+C.apply(this,arguments)))>.001){b=t0?0:1}function _l(g,I,C,A,i){var e=g[0]-I[0],l=g[1]-I[1],t=(i?A:-A)/Math.sqrt(e*e+l*l),s=t*l,c=-t*e,d=g[0]+s,o=g[1]+c,n=I[0]+s,a=I[1]+c,Z=(d+n)/2,b=(o+a)/2,r=n-d,m=a-o,h=r*r+m*m,G=C-A,u=d*a-n*o,B=(m<0?-1:1)*Math.sqrt(Math.max(0,G*G*h-u*u)),w=(u*m-r*B)/h,W=(-u*r-m*B)/h,p=(u*m+r*B)/h,V=(-u*r+m*B)/h,y=w-Z,X=W-b,Y=p-Z,R=V-b;return y*y+X*X>Y*Y+R*R&&(w=p,W=V),[[w-s,W-c],[w*C/G,W*C/G]]}function ql(g){var I=Ii,C=Ci,A=jC,i=gt,e=i.key,l=.7;function t(e){var t,s=[],c=[],d=-1,o=e.length,n=bI(I),a=bI(C);function Z(){s.push("M",i(g(c),l))}for(;++d1&&i.push("H",A[0]);return i.join("")},"step-before":Ct,"step-after":At,basis:lt,"basis-open":function(g){if(g.length<4)return gt(g);var I,C=[],A=-1,i=g.length,e=[0],l=[0];for(;++A<3;)I=g[A],e.push(I[0]),l.push(I[1]);C.push(tt(dt,e)+","+tt(dt,l)),--A;for(;++A9&&(i=3*I/Math.sqrt(i),l[t]=i*C,l[t+1]=i*A);t=-1;for(;++t<=s;)i=(g[Math.min(s,t+1)][0]-g[Math.max(0,t-1)][0])/(6*(1+l[t]*l[t])),e.push([i||0,l[t]*i||0]);return e}(g))}});function gt(g){return g.length>1?g.join("L"):g+"Z"}function It(g){return g.join("L")+"Z"}function Ct(g){for(var I=0,C=g.length,A=g[0],i=[A[0],",",A[1]];++I1){t=I[1],e=g[s],s++,A+="C"+(i[0]+l[0])+","+(i[1]+l[1])+","+(e[0]-t[0])+","+(e[1]-t[1])+","+e[0]+","+e[1];for(var c=2;cpg)+",1 "+I}function s(g,I,C,A){return"Q 0,0 "+A}return e.radius=function(g){return arguments.length?(C=bI(g),e):C},e.source=function(I){return arguments.length?(g=bI(I),e):g},e.target=function(g){return arguments.length?(I=bI(g),e):I},e.startAngle=function(g){return arguments.length?(A=bI(g),e):A},e.endAngle=function(g){return arguments.length?(i=bI(g),e):i},e},g.svg.diagonal=function(){var g=zA,I=vA,C=rt;function A(A,i){var e=g.call(this,A,i),l=I.call(this,A,i),t=(e.y+l.y)/2,s=[e,{x:e.x,y:t},{x:l.x,y:t},l];return"M"+(s=s.map(C))[0]+"C"+s[1]+" "+s[2]+" "+s[3]}return A.source=function(I){return arguments.length?(g=bI(I),A):g},A.target=function(g){return arguments.length?(I=bI(g),A):I},A.projection=function(g){return arguments.length?(C=g,A):C},A},g.svg.diagonal.radial=function(){var I=g.svg.diagonal(),C=rt,A=I.projection;return I.projection=function(g){return arguments.length?A(function(g){return function(){var I=g.apply(this,arguments),C=I[0],A=I[1]-Xg;return[C*Math.cos(A),C*Math.sin(A)]}}(C=g)):C},I},g.svg.symbol=function(){var g=ht,I=mt;function C(C,A){return(ut.get(g.call(this,C,A))||Gt)(I.call(this,C,A))}return C.type=function(I){return arguments.length?(g=bI(I),C):g},C.size=function(g){return arguments.length?(I=bI(g),C):I},C};var ut=g.map({circle:Gt,cross:function(g){var I=Math.sqrt(g/5)/2;return"M"+-3*I+","+-I+"H"+-I+"V"+-3*I+"H"+I+"V"+-I+"H"+3*I+"V"+I+"H"+I+"V"+3*I+"H"+-I+"V"+I+"H"+-3*I+"Z"},diamond:function(g){var I=Math.sqrt(g/(2*wt)),C=I*wt;return"M0,"+-I+"L"+C+",0 0,"+I+" "+-C+",0Z"},square:function(g){var I=Math.sqrt(g)/2;return"M"+-I+","+-I+"L"+I+","+-I+" "+I+","+I+" "+-I+","+I+"Z"},"triangle-down":function(g){var I=Math.sqrt(g/Bt),C=I*Bt/2;return"M0,"+C+"L"+I+","+-C+" "+-I+","+-C+"Z"},"triangle-up":function(g){var I=Math.sqrt(g/Bt),C=I*Bt/2;return"M0,"+-C+"L"+I+","+C+" "+-I+","+C+"Z"}});g.svg.symbolTypes=ut.keys();var Bt=Math.sqrt(3),wt=Math.tan(30*Yg);Q.transition=function(g){for(var I,C,A=yt||++Rt,i=Kt(g),e=[],l=Xt||{time:Date.now(),ease:le,delay:0,duration:250},t=-1,s=this.length;++t0;)c[--n].call(g,l);if(e>=1)return o.event&&o.event.end.call(g,g.__data__,I),--d.count?delete d[A]:delete g[C],1}o||(e=i.time,l=WI((function(g){var I=o.delay;if(l.t=I+e,I<=g)return n(g-I);l.c=n}),0,e),o=d[A]={tween:new G,time:e,timer:l,delay:i.delay,duration:i.duration,ease:i.ease,index:I},i=null,++d.count)}Yt.call=Q.call,Yt.empty=Q.empty,Yt.node=Q.node,Yt.size=Q.size,g.transition=function(I,C){return I&&I.transition?yt?I.transition(C):I:g.selection().transition(I)},g.transition.prototype=Yt,Yt.select=function(g){var I,C,A,i=this.id,e=this.namespace,l=[];g=j(g);for(var t=-1,s=this.length;++trect,.s>rect").attr("width",t[1]-t[0])}function b(g){g.select(".extent").attr("y",s[0]),g.selectAll(".extent,.e>rect,.w>rect").attr("height",s[1]-s[0])}function r(){var o,r,m=this,h=g.select(g.event.target),G=A.of(m,arguments),u=g.select(m),B=h.datum(),w=!/^(n|s)$/.test(B)&&i,W=!/^(e|w)$/.test(B)&&l,p=h.classed("extent"),V=hg(m),y=g.mouse(m),X=g.select(e(m)).on("keydown.brush",(function(){32==g.event.keyCode&&(p||(o=null,y[0]-=t[1],y[1]-=s[1],p=2),f())})).on("keyup.brush",(function(){32==g.event.keyCode&&2==p&&(y[0]+=t[1],y[1]+=s[1],p=0,f())}));if(g.event.changedTouches?X.on("touchmove.brush",N).on("touchend.brush",K):X.on("mousemove.brush",N).on("mouseup.brush",K),u.interrupt().selectAll("*").interrupt(),p)y[0]=t[0]-y[0],y[1]=s[0]-y[1];else if(B){var Y=+/w$/.test(B),R=+/^n/.test(B);r=[t[1-Y]-y[0],s[1-R]-y[1]],y[0]=t[Y],y[1]=s[R]}else g.event.altKey&&(o=y.slice());function N(){var I=g.mouse(m),C=!1;r&&(I[0]+=r[0],I[1]+=r[1]),p||(g.event.altKey?(o||(o=[(t[0]+t[1])/2,(s[0]+s[1])/2]),y[0]=t[+(I[0]1?{floor:function(I){for(;t(I=g.floor(I));)I=Ut(I-1);return I},ceil:function(I){for(;t(I=g.ceil(I));)I=Ut(+I+1);return I}}:g))},i.ticks=function(g,I){var C=bl(i.domain()),A=null==g?e(C,10):"number"==typeof g?e(C,g):!g.range&&[{range:g},I];return A&&(g=A[0],I=A[1]),g.range(C[0],Ut(+C[1]+1),I<1?1:I)},i.tickFormat=function(){return A},i.copy=function(){return xt(I.copy(),C,A)},wl(i,I)}function Ut(g){return new Date(g)}Lt.iso=Date.prototype.toISOString&&+new Date("2000-01-01T00:00:00.000Z")?Tt:vt,Tt.parse=function(g){var I=new Date(g);return isNaN(I)?null:I},Tt.toString=vt.toString,FI.second=fI((function(g){return new MI(1e3*Math.floor(g/1e3))}),(function(g,I){g.setTime(g.getTime()+1e3*Math.floor(I))}),(function(g){return g.getSeconds()})),FI.seconds=FI.second.range,FI.seconds.utc=FI.second.utc.range,FI.minute=fI((function(g){return new MI(6e4*Math.floor(g/6e4))}),(function(g,I){g.setTime(g.getTime()+6e4*Math.floor(I))}),(function(g){return g.getMinutes()})),FI.minutes=FI.minute.range,FI.minutes.utc=FI.minute.utc.range,FI.hour=fI((function(g){var I=g.getTimezoneOffset()/60;return new MI(36e5*(Math.floor(g/36e5-I)+I))}),(function(g,I){g.setTime(g.getTime()+36e5*Math.floor(I))}),(function(g){return g.getHours()})),FI.hours=FI.hour.range,FI.hours.utc=FI.hour.utc.range,FI.month=fI((function(g){return(g=FI.day(g)).setDate(1),g}),(function(g,I){g.setMonth(g.getMonth()+I)}),(function(g){return g.getMonth()})),FI.months=FI.month.range,FI.months.utc=FI.month.utc.range;var Qt=[1e3,5e3,15e3,3e4,6e4,3e5,9e5,18e5,36e5,108e5,216e5,432e5,864e5,1728e5,6048e5,2592e6,7776e6,31536e6],jt=[[FI.second,1],[FI.second,5],[FI.second,15],[FI.second,30],[FI.minute,1],[FI.minute,5],[FI.minute,15],[FI.minute,30],[FI.hour,1],[FI.hour,3],[FI.hour,6],[FI.hour,12],[FI.day,1],[FI.day,2],[FI.week,1],[FI.month,1],[FI.month,3],[FI.year,1]],Ot=Lt.multi([[".%L",function(g){return g.getMilliseconds()}],[":%S",function(g){return g.getSeconds()}],["%I:%M",function(g){return g.getMinutes()}],["%I %p",function(g){return g.getHours()}],["%a %d",function(g){return g.getDay()&&1!=g.getDate()}],["%b %d",function(g){return 1!=g.getDate()}],["%B",function(g){return g.getMonth()}],["%Y",jC]]),Et={range:function(I,C,A){return g.range(Math.ceil(I/A)*A,+C,A).map(Ut)},floor:N,ceil:N};jt.year=FI.year,FI.scale=function(){return xt(g.scale.linear(),jt,Ot)};var Pt=jt.map((function(g){return[g[0].utc,g[1]]})),_t=zt.multi([[".%L",function(g){return g.getUTCMilliseconds()}],[":%S",function(g){return g.getUTCSeconds()}],["%I:%M",function(g){return g.getUTCMinutes()}],["%I %p",function(g){return g.getUTCHours()}],["%a %d",function(g){return g.getUTCDay()&&1!=g.getUTCDate()}],["%b %d",function(g){return 1!=g.getUTCDate()}],["%B",function(g){return g.getUTCMonth()}],["%Y",jC]]);function qt(g){return JSON.parse(g.responseText)}function $t(g){var I=A.createRange();return I.selectNode(A.body),I.createContextualFragment(g.responseText)}return Pt.year=FI.year.utc,FI.scale.utc=function(){return xt(g.scale.linear(),Pt,_t)},g.text=rI((function(g){return g.responseText})),g.json=function(g,I){return mI(g,"application/json",qt,I)},g.html=function(g,I){return mI(g,"text/html",$t,I)},g.xml=rI((function(g){return g.responseXML})),g};const XI=window.E0DD32CBDCB63F();let YI=1;function RI(g){const I="<".charCodeAt(0),C=">".charCodeAt(0),A="-".charCodeAt(0),i="/".charCodeAt(0),e="!".charCodeAt(0),l="'".charCodeAt(0),t='"'.charCodeAt(0),s="?".charCodeAt(0),c="\r\n\t>/= ";let d=0;return YI=1,NI(function o(){const n=[];for(;g[d];){if(g.charCodeAt(d)===I){if(g.charCodeAt(d+1)===i)return d=g.indexOf(">",d),n;if(g.charCodeAt(d+1)===e){if(g.charCodeAt(d+2)===A){for(;g.charCodeAt(d)!==C||g.charCodeAt(d-1)!==A||g.charCodeAt(d-2)!==A||-1===d;)d=g.indexOf(">",d+1);-1===d&&(d=g.length)}else for(d+=2;g.charCodeAt(d)!==C;d++);d++;continue}if(g.charCodeAt(d+1)===s){d=g.indexOf(">",d),d++;continue}d++;let I=d;for(;-1===c.indexOf(g[d]);d++);const a=g.slice(I,d);let Z,b=!1,r={};for(;g.charCodeAt(d)!==C;d++){const C=g.charCodeAt(d);if(C>64&&C<91||C>96&&C<123){for(I=d;-1===c.indexOf(g[d]);d++);const C=g.slice(I,d);let A=g.charCodeAt(d);for(;A!==l&&A!==t;)d++,A=g.charCodeAt(d);const i=g[d],e=++d;d=g.indexOf(i,e);const s=g.slice(e,d);b||(r={},b=!0),r[C]=s}}g.charCodeAt(d-1)!==i&&(d++,Z=o()),n.push({children:Z,tagName:a,attrs:r})}else{const I=d;d=g.indexOf("<",d)-1,-2===d&&(d=g.length);const C=g.slice(I,d+1);C.trim().length>0&&n.push(C)}d++}return n}())}function NI(g){const I={};if(void 0===g)return{};if(1===g.length&&("string"==typeof g[0]||g[0]instanceof String))return new String(g[0]);g.forEach((function(g){if("string"!=typeof g&&(I[g.tagName]||(I[g.tagName]=[])),"object"==typeof g){const C=NI(g.children);g.attrs&&(C.attrs=g.attrs),void 0===C.attrs?C.attrs={order:YI}:C.attrs.order=YI,YI++,I[g.tagName].push(C)}}));for(const C in I)1===I[C].length&&(I[C]=I[C][0]);return I}const HI=Math.round;class KI{constructor(g){C(this,"r"),C(this,"g"),C(this,"b"),this.r=g[0],this.g=g[1],this.b=g[2]}toString(){return`rgb(${this.r},${this.g},${this.b})`}}class FI extends KI{constructor(g){super(g),C(this,"a"),this.a=g[3]}toString(){return`rgba(${this.r},${this.g},${this.b},${this.a})`}}class MI{constructor(g){C(this,"h"),C(this,"s"),C(this,"l"),this.h=g[0],this.s=g[1],this.l=g[2]}toString(){return`hsl(${this.h},${this.s}%,${this.l}%)`}}class JI extends MI{constructor(g){super(g),C(this,"a"),this.a=g[3]}toString(){return`hsla(${this.h},${this.s}%,${this.l}%,${this.a})`}}class SI{constructor(g,I=0,A=0,i=1){if(C(this,"r"),C(this,"g"),C(this,"b"),C(this,"a"),C(this,"rgb"),C(this,"rgba"),C(this,"hex"),C(this,"hsl"),C(this,"hsla"),C(this,"h"),C(this,"s"),C(this,"l"),"string"==typeof g){let C=g;"#"!==C.charAt(0)&&(C="#"+C),C.length<7&&(C="#"+C[1]+C[1]+C[2]+C[2]+C[3]+C[3]),[g,I,A]=fI(C)}else g instanceof Array&&(i=g[3]||i,A=g[2],I=g[1],g=g[0]);this.r=Number(g),this.g=Number(I),this.b=Number(A),this.a=i,this.rgb=new KI([this.r,this.g,this.b]),this.rgba=new FI([this.r,this.g,this.b,this.a]),this.hex=LI(this.r,this.g,this.b),this.hsl=new MI(zI(this.r,this.g,this.b)),this.h=this.hsl.h,this.s=this.hsl.s,this.l=this.hsl.l,this.hsla=new JI([this.h,this.s,this.l,this.a])}setHue(g){this.h=g,this.hsl.h=g,this.hsla.h=g,this.updateFromHsl()}setSat(g){this.s=g,this.hsl.s=g,this.hsla.s=g,this.updateFromHsl()}setLum(g){this.l=g,this.hsl.l=g,this.hsla.l=g,this.updateFromHsl()}setAlpha(g){this.a=g,this.hsla.a=g,this.rgba.a=g}updateFromHsl(){this.rgb=new KI(TI(this.h,this.s,this.l)),this.r=this.rgb.r,this.g=this.rgb.g,this.b=this.rgb.b,this.rgba.r=this.rgb.r,this.rgba.g=this.rgb.g,this.rgba.b=this.rgb.b,this.hex=LI([this.r,this.g,this.b])}}const fI=function(g){const I=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(g);return I?[parseInt(I[1],16),parseInt(I[2],16),parseInt(I[3],16)]:null},kI=(g,I)=>{const C=fI(g)||[];for(let A=0;A<3;A++)C[A]=Math.floor(Number(C[A])*(1-I));return LI(C[0],C[1],C[2])};const DI=function(g){const I=g.toString(16);return 1===I.length?"0"+I:I},LI=function(g,I=0,C=0){return g instanceof Array&&(C=g[2],I=g[1],g=g[0]),"#"+DI(g)+DI(I)+DI(C)},zI=function(g,I=0,C=0){g instanceof Array&&(C=g[2],I=g[1],g=g[0]);let A,i,e,l=0;g/=255,I/=255,C/=255;const t=Math.max(g,I,C),s=Math.min(g,I,C);if(i=(t+s)/2,t===s)l=A=0;else{switch(e=t-s,A=i>.5?e/(2-t-s):e/(t+s),t){case g:l=(I-C)/e+(I1&&(C-=1),C<1/6?g+6*(I-g)*C:C<.5?I:C<2/3?g+(I-g)*(2/3-C)*6:g},TI=function(g,I,C){let A,i,e,l,t;return g instanceof Array&&(C=g[2],I=g[1],g=g[0]),g=Number(g)/360,I=Number(I)/100,C=Number(C)/100,0===I?A=i=e=C:(l=C<.5?C*(1+I):C+I-C*I,t=2*C-l,A=vI(t,l,g+1/3),i=vI(t,l,g),e=vI(t,l,g-1/3)),[HI(255*A),HI(255*i),HI(255*e)]};function xI(g){const I=new Uint8Array(g);let C="";for(let A=0;A0&&I<1e3);else if(I>1e3){const C=I-1e3,A=i["a:theme"]["a:themeElements"]["a:fmtScheme"]["a:bgFillStyleLst"],l=[];Object.keys(A).forEach((function(g){const I=A[g];if("attrs"!==g)if(I.constructor===Array)for(let C=0;C0&&I<1e3);else if(I>1e3){const C=I-1e3,A=i["a:theme"]["a:themeElements"]["a:fmtScheme"]["a:bgFillStyleLst"],l=[];Object.keys(A).forEach((function(g){const I=A[g];if("attrs"!==g)if(I.constructor===Array)for(let C=0;C";for(const I in H)if(H[I].constructor===Array)for(let g=0;g"}function d(g){const I=g[Object.keys(g)[0]]["p:cSld"]["p:spTree"],C={},A={},i={};for(const e in I){if("p:nvGrpSpPr"===e||"p:grpSpPr"===e)continue;const g=I[e];if(g.constructor===Array)for(let I=0;I"}(I,i);break;case"p:graphicFrame":e=await async function(g,I){let i="";switch(J(g,["a:graphic","a:graphicData","attrs","uri"])){case"http://schemas.openxmlformats.org/drawingml/2006/table":i=await async function(g,I){const C=g.attrs.order,A=J(g,["a:graphic","a:graphicData","a:tbl"]),i=J(g,["p:xfrm"]),e=J(g,["a:graphic","a:graphicData","a:tbl","a:tblPr"]),l=J(g,["a:graphic","a:graphicData","a:tbl","a:tblGrid","a:gridCol"]);let s="";if(void 0!==e){s=1===e.attrs.rtl?"dir=rtl":"dir=ltr"}const c=e.attrs.firstRow,d=e.attrs.bandRow;let o="";const n=A["a:tr"];if(n.constructor===Array)for(let Z=0;Z0&&void 0!==d){let g="fff",I=1;if(Z%2==0){if(void 0!==i["a:band2H"]){const C=J(i,["a:band2H","a:tcStyle","a:fill","a:solidFill"]);void 0!==C&&(g=R(C),I=K(C));const e=J(i,["a:band2H","a:tcStyle","a:tcBdr"]);if(void 0!==e){A+=W(e)}J(i,["a:band2H","a:tcTxStyle"])}}else if(void 0!==i["a:band1H"]){const C=J(i,["a:band1H","a:tcStyle","a:fill","a:solidFill"]);void 0!==C&&(g=R(C),I=K(C));const e=J(i,["a:band1H","a:tcStyle","a:tcBdr"]);if(void 0!==e){A+=W(e)}J(i,["a:band1H","a:tcTxStyle"])}A+=" background-color:#"+g+"; opacity:"+I+";"}o+="";const b=n[Z]["a:tc"];if(b.constructor===Array)for(let c=0;c"+g+"":void 0!==A?o+="":void 0===i&&void 0===s&&(o+="")}else{const g=await a(b["a:txBody"]),I=l[0].attrs.w;let C="";if(void 0!==I){C+="width:"+96*parseInt(I)/914400+"px;"}const A=b["a:tcPr"]["a:solidFill"];let i="",e=1;void 0!==A&&(i=R(A),e=K(A)),""!==i&&(C+=" background-color:#"+i+";",C+=" opacity"+e+";"),o+=""}o+=""}else{const g=n.attrs.h;let I=0;void 0!==g?(I=96*parseInt(g)/914400,o+=""):o+="";const C=n["a:tc"];if(C.constructor===Array)for(let A=0;A"+g+""}else{const g=await a(C["a:txBody"]),I=l[0].attrs.w;let A="";if(void 0!==I){A+="width:"+96*parseInt(I)/914400+"px;"}const i=C["a:tcPr"]["a:solidFill"];let e="",t=1;void 0!==i&&(e=R(i),t=K(i)),""!==e&&(A+=" background-color:#"+e+";",A+=" opacity"+t+";"),o+=""}o+=""}return o}(g,I);break;case"http://schemas.openxmlformats.org/drawingml/2006/chart":i=await async function(g,I){const i=g.attrs.order,e=J(g,["p:xfrm"]),l="
",t=g["a:graphic"]["a:graphicData"]["c:chart"].attrs["r:id"],c=I.slideResObj[t].target,d=await s(I.zip,c),o=J(d,["c:chartSpace","c:chart","c:plotArea"]);let n=null;for(const C in o)switch(C){case"c:lineChart":n={type:"createChart",data:{chartID:"chart"+A,chartType:"lineChart",chartData:M(o[C]["c:ser"])}};break;case"c:barChart":n={type:"createChart",data:{chartID:"chart"+A,chartType:"barChart",chartData:M(o[C]["c:ser"])}};break;case"c:pieChart":n={type:"createChart",data:{chartID:"chart"+A,chartType:"pieChart",chartData:M(o[C]["c:ser"])}};break;case"c:pie3DChart":n={type:"createChart",data:{chartID:"chart"+A,chartType:"pie3DChart",chartData:M(o[C]["c:ser"])}};break;case"c:areaChart":n={type:"createChart",data:{chartID:"chart"+A,chartType:"areaChart",chartData:M(o[C]["c:ser"])}};break;case"c:scatterChart":n={type:"createChart",data:{chartID:"chart"+A,chartType:"scatterChart",chartData:M(o[C]["c:ser"])}}}null!=n&&C.push(n);return A++,l}(g,I);break;case"http://schemas.openxmlformats.org/drawingml/2006/diagram":i=function(g){const I=J(g,["p:xfrm"]);return"
TODO: diagram
"}(g)}return i}(I,i);break;case"p:grpSp":e=await async function(g,I){const C=96/914400,A=g["p:grpSpPr"]["a:xfrm"],i=parseInt(A["a:off"].attrs.x)*C,e=parseInt(A["a:off"].attrs.y)*C,l=parseInt(A["a:chOff"].attrs.x)*C,t=parseInt(A["a:chOff"].attrs.y)*C,s=parseInt(A["a:ext"].attrs.cx)*C,c=parseInt(A["a:ext"].attrs.cy)*C,d=parseInt(A["a:chExt"].attrs.cx)*C,n=parseInt(A["a:chExt"].attrs.cy)*C;let a="
";for(const Z in g)if(g[Z].constructor===Array)for(let C=0;C",Z+="",Y=await y(g,!0,s);const C=X(J(g,["p:spPr"]));if("GRADIENT_FILL"===C){K=!0;const g=Y.color,I=Y.rot,C=function(g,I,C,A,i){const e=function(g){const I=["0%","100%"];if(0===g)return!0;{let C=g;for(;C--;){const A=100-100/(g+1)*(C+1)+"%";I.splice(-1,0,A)}}return I}(A.length-2),l=function(g,I,C){const A=parseFloat(C),i=parseFloat(I),e=parseFloat(g);let l=2,t=2;const s=A/2,c=i/2;let d=2,o=2,n=2,a=2;const Z=(e%360+360)%360,b=(360-Z)*Math.PI/180,r=Math.tan(b),m=c-r*s;0===Z?(d=A,o=c,n=0,a=c):Z<90?(t=A,l=0):90===Z?(d=s,o=0,n=s,a=i):Z<180?(t=0,l=0):180===Z?(d=0,o=c,n=A,a=c):Z<270?(t=0,l=i):270===Z?(d=s,o=i,n=s,a=0):(t=A,l=i);const h=l+t/r;d=2===d?r*(h-m)/(Math.pow(r,2)+1):d,o=2===o?r*d+m:o,n=2===n?A-d:n,a=2===a?i-o:a;const G=Math.round(n/A*100*100)/100,u=Math.round(a/i*100*100)/100,B=Math.round(d/A*100*100)/100,w=Math.round(o/i*100*100)/100;return[G,u,B,w]}(C,I,g),t=l[0],s=l[1],c=l[2],d=l[3],o=e.length,n=o<20?100:1e3;let a='\n';for(let Z=0;Z';return C+='',C+="",C}(Y,b);Z+=g}if(H=p(g,!0),W=J(g,["p:spPr","a:ln","a:headEnd","attrs"]),V=J(g,["p:spPr","a:ln","a:tailEnd","attrs"]),void 0!==W&&("triangle"===W.type||"arrow"===W.type)||void 0!==V&&("triangle"===V.type||"arrow"===V.type)){Z+=""}Z+=""}if(void 0!==r&&void 0===G){switch(r){case"accentBorderCallout1":case"accentBorderCallout2":case"accentBorderCallout3":case"accentCallout1":case"accentCallout2":case"accentCallout3":case"actionButtonBackPrevious":case"actionButtonBeginning":case"actionButtonBlank":case"actionButtonDocument":case"actionButtonEnd":case"actionButtonForwardNext":case"actionButtonHelp":case"actionButtonHome":case"actionButtonInformation":case"actionButtonMovie":case"actionButtonReturn":case"actionButtonSound":case"arc":case"bevel":case"blockArc":case"borderCallout1":case"borderCallout2":case"borderCallout3":case"bracePair":case"bracketPair":case"callout1":case"callout2":case"callout3":case"can":case"chartPlus":case"chartStar":case"chartX":case"chevron":case"chord":case"cloud":case"cloudCallout":case"corner":case"cornerTabs":case"cube":case"diagStripe":case"donut":case"doubleWave":case"downArrowCallout":case"ellipseRibbon":case"ellipseRibbon2":case"flowChartAlternateProcess":case"flowChartCollate":case"flowChartConnector":case"flowChartDecision":case"flowChartDelay":case"flowChartDisplay":case"flowChartDocument":case"flowChartExtract":case"flowChartInputOutput":case"flowChartInternalStorage":case"flowChartMagneticDisk":case"flowChartMagneticDrum":case"flowChartMagneticTape":case"flowChartManualInput":case"flowChartManualOperation":case"flowChartMerge":case"flowChartMultidocument":case"flowChartOfflineStorage":case"flowChartOffpageConnector":case"flowChartOnlineStorage":case"flowChartOr":case"flowChartPredefinedProcess":case"flowChartPreparation":case"flowChartProcess":case"flowChartPunchedCard":case"flowChartPunchedTape":case"flowChartSort":case"flowChartSummingJunction":case"flowChartTerminator":case"folderCorner":case"frame":case"funnel":case"gear6":case"gear9":case"halfFrame":case"heart":case"homePlate":case"horizontalScroll":case"irregularSeal1":case"irregularSeal2":case"leftArrowCallout":case"leftBrace":case"leftBracket":case"leftRightArrowCallout":case"leftRightRibbon":case"lightningBolt":case"lineInv":case"mathDivide":case"mathEqual":case"mathMinus":case"mathMultiply":case"mathNotEqual":case"mathPlus":case"moon":case"nonIsoscelesTrapezoid":case"noSmoking":case"pie":case"pieWedge":case"plaque":case"plaqueTabs":case"quadArrowCallout":case"rect":case"ribbon":case"ribbon2":case"rightArrowCallout":case"rightBrace":case"rightBracket":case"round1Rect":case"round2DiagRect":case"round2SameRect":case"smileyFace":case"snip1Rect":case"snip2DiagRect":case"snip2SameRect":case"snipRoundRect":case"squareTabs":case"star10":case"star12":case"star16":case"star24":case"star32":case"star4":case"star5":case"star6":case"star7":case"star8":case"sun":case"teardrop":case"upArrowCallout":case"upDownArrowCallout":case"verticalScroll":case"wave":case"wedgeEllipseCallout":case"wedgeRectCallout":case"wedgeRoundRectCallout":Z+="";break;case"ellipse":Z+="";break;case"roundRect":Z+="";break;case"bentConnector2":{let g;g=B?"M 0 "+R+" L "+N+" "+R+" L "+N+" 0":"M "+R+" 0 L "+R+" "+N+" L 0 "+N,Z+="";break;case"triangle":{const I=J(g,["p:spPr","a:prstGeom","a:avLst","a:gd","attrs","fmla"]);let C=.5;void 0!==I&&(C=96*parseInt(I.substr(4))/9144e3),Z+=" ";break}case"diamond":Z+=" ";break;case"trapezoid":{const I=J(g,["p:spPr","a:prstGeom","a:avLst","a:gd","attrs","fmla"]);let C=.25;const A=.7407;if(void 0!==I){C=.5*(96*parseInt(I.substr(4))/9144e3)/A}Z+=" ";break}case"parallelogram":{const I=J(g,["p:spPr","a:prstGeom","a:avLst","a:gd","attrs","fmla"]);let C,A=.25;if(C=R>N?R/N:N/R,void 0!==I){A=parseInt(I.substr(4))/1e5/C}Z+=" ";break}case"pentagon":Z+=" ";break;case"hexagon":{const I=J(g,["p:spPr","a:prstGeom","a:avLst","a:gd"])||[];let C;for(let g=0;g";break}case"heptagon":Z+=" ";break;case"octagon":{const I=J(g,["p:spPr","a:prstGeom","a:avLst","a:gd","attrs","fmla"]);let C=.25;void 0!==I&&(C=parseInt(I.substr(4))/1e5);const A=1-C;Z+=" ";break}case"decagon":Z+=" ";break;case"dodecagon":Z+=" ";break;case"bentConnector3":{const I=J(g,["p:spPr","a:prstGeom","a:avLst","a:gd","attrs","fmla"]);let C=.5;void 0!==I&&(C=parseInt(I.substr(4))/1e5,Z+=B?" ";break}case"line":case"straightConnector1":case"bentConnector4":case"bentConnector5":case"curvedConnector2":case"curvedConnector3":case"curvedConnector4":case"curvedConnector5":Z+=B?"";break}case"leftArrow":{const I=J(g,["p:spPr","a:prstGeom","a:avLst","a:gd"]);let C,A,i=.5,e=.5;const l=R/N;if(void 0!==I)for(let g=0;g";break}case"downArrow":{const I=J(g,["p:spPr","a:prstGeom","a:avLst","a:gd"]);let C,A,i=.5,e=.5;const l=N/R;if(void 0!==I)for(let g=0;g";break}case"upArrow":{const I=J(g,["p:spPr","a:prstGeom","a:avLst","a:gd"]);let C,A,i=.5,e=.5;const l=N/R;if(void 0!==I)for(let g=0;g";break}case"leftRightArrow":{const I=J(g,["p:spPr","a:prstGeom","a:avLst","a:gd"]);let C,A,i=.5,e=.5;const l=R/N;if(void 0!==I)for(let g=0;g";break}case"upDownArrow":{const I=J(g,["p:spPr","a:prstGeom","a:avLst","a:gd"]);let C,A,i=.5,e=.5;const l=N/R;if(void 0!==I)for(let g=0;g";break}case"bentArrow":case"bentUpArrow":case"stripedRightArrow":case"quadArrow":case"circularArrow":case"swooshArrow":case"leftRightUpArrow":case"leftUpArrow":case"leftCircularArrow":case"notchedRightArrow":case"curvedDownArrow":case"curvedLeftArrow":case"curvedRightArrow":case"curvedUpArrow":case"uturnArrow":case"leftRightCircularArrow":break;default:console.warn("Undefine shape type.")}Z+="",Z+="
",void 0!==g["p:txBody"]&&(Z+=await a(g["p:txBody"],I,C,l,s)),Z+="
"}else if(void 0!==G){const c=J(G,["a:pathLst"]),r=J(c,["a:path","a:close"]),B=J(c,["a:path","a:moveTo","a:pt","attrs"])||{x:"0",y:"0"};let p="M"+96*parseInt(B.x)/914400+","+96*parseInt(B.y)/914400;const y=J(c,["a:path"]),X=y["a:lnTo"],R=y["a:cubicBezTo"],N=[];void 0!==X&&Object.keys(X).forEach((function(g){const I=X[g]["a:pt"];void 0!==I&&Object.keys(I).forEach((function(g){const C={},A=I[g],i=A.x,e=A.y,l=A.order;C.type="lnto",C.order=l,C.x=i,C.y=e,N.push(C)}))})),void 0!==R&&Object.keys(R).forEach((function(g){const I=R[g]["a:pt"];void 0!==I&&Object.keys(I).forEach((function(g){const C=I[g];Object.keys(C).forEach((function(g){const I={},A=C[g],i=A.x,e=A.y,l=A.order;I.type="cubicBezTo",I.order=l,I.x=i,I.y=e,N.push(I)}))}))}));const M=N.slice(0);M.sort((function(g,I){return g.order-I.order}));let S=0;for(;S",void 0!==g["p:txBody"]&&(Z+=await a(g["p:txBody"],I,C,l,s)),Z+="
"}else Z+="
",void 0!==g["p:txBody"]&&(Z+=await a(g["p:txBody"],I,C,l="",s)),Z+="
";return Z}async function a(g,I,C,A,i){let e="";const l=i&&i.slideMasterTextStyles;if(void 0===g)return e;let t,s;if(g["a:p"].constructor===Array)for(let c=0;c",e+=await Z(t,I,C,A,i||{}),void 0===s)e+=b(t,I,C,A,i||{});else if(s.constructor===Array)for(let g=0;g");else e+=b(s,I,C,A,i||{});e+=""}else{if(t=g["a:p"],s=t["a:r"],e+="
",e+=await Z(t,I,C,A,i),void 0===s)e+=b(t,I,C,A,i||{});else if(s.constructor===Array)for(let g=0;g");else e+=b(s,I,C,A,i||{});e+="
"}return e}async function Z(g,I,C,A,i){const e=i&&i.slideMasterTextStyles,l=g["a:r"];let t,s,c,d;void 0!==l?(t=B(l),s=w(l,I,C,A,e)):(t=B(g),s=w(g,I,C,A,e));let o="";const n=g["a:pPr"],a=J(n,["attrs","rtl"]);let Z=!1;void 0!==a&&"1"===a&&(Z=!0);let b=parseInt(J(n,["attrs","lvl"]));isNaN(b)&&(b=0);const r=J(n,["a:buChar","attrs","char"]);let m="TYPE_NONE";const h=J(n,["a:buAutoNum","attrs","type"]),G=J(n,["a:buBlip"]);void 0!==r&&(m="TYPE_BULLET"),void 0!==h&&(m="TYPE_NUMERIC"),void 0!==G&&(m="TYPE_BULPIC");let u={};"TYPE_NONE"!==m&&(u=J(n,["a:buFont","attrs"]));let W,p,V,y="NoNe";if(n){const g=n["a:buClr"];void 0!==g&&(y=R(g)||"")}if(c="NoNe"===y?t:"#"+y,W=J(n,["a:buSzPts","attrs","val"]),void 0!==W)d=parseInt(W)/100+"pt";else if(W=J(n,["a:buSzPct","attrs","val"]),void 0!==W){const g=parseInt(W)/1e5,I=s.substr(0,s.length-2);d=g*parseInt(I)+"pt"}else d=s;if("TYPE_BULLET"===m)if(void 0!==u){p=96*parseInt(J(n,["attrs","marL"]))/914400,V=parseInt(u.pitchFamily),isNaN(p)&&(p=31545600/914400),isNaN(V)&&(V=0);o=""+r+""}else p=31545600/914400*b,o=""+r+"";else if("TYPE_NUMERIC"===m)void 0!==u?(p=96*parseInt(J(n,["attrs","marL"]))/914400,V=parseInt(u.pitchFamily),isNaN(p)&&(p=31545600/914400),isNaN(V)&&(V=0),o=""):(p=31545600/914400*b,o="");else if("TYPE_BULPIC"===m){p=96*parseInt(J(n,["attrs","marL"]))/914400,V=96*parseInt(J(n,["attrs","marR"]))/914400,isNaN(V)&&(V=0),p=isNaN(p)?31545600/914400:0;const g=J(G,["a:blip","attrs","r:embed"]);let I;if(void 0!==g){const C=i&&i.slideResObj[g].target,A=i&&await i.zip.file(C).async("arraybuffer");I=""}void 0===g&&(I="‣"),o=""+I+" "}else o="";return o}function b(g,I,C,A,e){const t=e.slideMasterTextStyles;let s=g["a:t"];"string"==typeof s||s instanceof String||(s=J(g,["a:fld","a:t"]),"string"==typeof s||s instanceof String||(s=" "));let c="color:"+B(g)+";font-size:"+w(g,I,C,A,t)+";font-family:"+function(g,I,C){let A=J(g,["a:rPr","a:latin","attrs","typeface"]);if(void 0===A){const g=J(i,["a:theme","a:themeElements","a:fontScheme"]);A=J(g,"title"===I||"subTitle"===I||"ctrTitle"===I?["a:majorFont","a:latin","attrs","typeface"]:["a:minorFont","a:latin","attrs","typeface"])}return void 0===A?"inherit":A}(g,A)+";font-weight:"+function(g,I,C){return void 0!==g["a:rPr"]&&"1"===g["a:rPr"].attrs.b?"bold":"initial"}(g)+";font-style:"+function(g,I,C){return void 0!==g["a:rPr"]&&"1"===g["a:rPr"].attrs.i?"italic":"normal"}(g)+";text-decoration:"+function(g,I,C){if(void 0!==g["a:rPr"]){const I=void 0!==g["a:rPr"].attrs.u?g["a:rPr"].attrs.u:"none",C=void 0!==g["a:rPr"].attrs.strike?g["a:rPr"].attrs.strike:"noStrike";return"none"!==I&&"noStrike"===C?"underline":"none"===I&&"noStrike"!==C?"line-through":"none"!==I&&"noStrike"!==C?"underline line-through":"initial"}return"initial"}(g)+";text-align:"+function(g,I,C){const A=J(g,["a:pPr","attrs","algn"]);let i="initial";if(void 0!==A)switch(A){case"l":i="left";break;case"r":i="right";break;case"ctr":i="center";break;case"just":case"dist":i="justify";break;default:i="initial"}return i}(g)+";vertical-align:"+function(g,I,C){const A=J(g,["a:rPr","attrs","baseline"]);return void 0===A?"baseline":parseInt(A)/1e3+"%"}(g)+";";const d=J(g,["a:rPr","a:highlight"]);void 0!==d&&(c+="background-color:#"+R(d)+";",c+="Opacity:"+K(d)+";");let o="";c in l?o=l[c].name:(o="_css_"+(Object.keys(l).length+1),l[c]={name:o,text:c});const n=J(g,["a:rPr","a:hlinkClick","attrs","r:id"]);if(void 0!==n){return""+s.replace(/\s/," ")+""}return""+s.replace(/\s/," ")+""}function r(){let g="";for(const I in l)g+="section ."+l[I].name+"{"+l[I].text+"}\n";return g}function m(g,I,C){let A,i=-1,e=-1;return void 0!==g?A=g["a:off"].attrs:void 0!==I?A=I["a:off"].attrs:void 0!==C&&(A=C["a:off"].attrs),void 0===A?"":(i=96*parseInt(A.x)/914400,e=96*parseInt(A.y)/914400,isNaN(i)||isNaN(e)?"":"top:"+e+"px; left:"+i+"px;")}function h(g,I,C){let A,i=-1,e=-1;return void 0!==g?A=g["a:ext"].attrs:void 0!==I?A=I["a:ext"].attrs:void 0!==C&&(A=C["a:ext"].attrs),void 0===A?"":(i=96*parseInt(A.cx)/914400,e=96*parseInt(A.cy)/914400,isNaN(i)||isNaN(e)?"":"width:"+i+"px; height:"+e+"px;")}function G(g,I,C,A,i){let e=J(g,["a:pPr","attrs","algn"]);if(void 0===e&&(e=J(I,["p:txBody","a:p","a:pPr","attrs","algn"]),void 0===e&&(e=J(C,["p:txBody","a:p","a:pPr","attrs","algn"]),void 0===e)))switch(A){case"title":case"subTitle":case"ctrTitle":e=J(i,["p:titleStyle","a:lvl1pPr","attrs","alng"]);break;default:e=J(i,["p:otherStyle","a:lvl1pPr","attrs","alng"])}if(void 0===e){if("title"===A||"subTitle"===A||"ctrTitle"===A)return"h-mid";if("sldNum"===A)return"h-right"}return"ctr"===e?"h-mid":"r"===e?"h-right":"h-left"}function u(g,I,C,A,i){let e=J(g,["p:txBody","a:bodyPr","attrs","anchor"]);return void 0===e&&(e=J(I,["p:txBody","a:bodyPr","attrs","anchor"]),void 0===e&&(e=J(C,["p:txBody","a:bodyPr","attrs","anchor"]))),"ctr"===e?"v-mid":"b"===e?"v-down":"v-up"}function B(g,I,C){const A=function(g,I){return J(g,I.trim().split(/\s+/))}(g,"a:rPr a:solidFill"),i=R(A);return void 0===i||"FFF"===i?"#000":"#"+i}function w(g,I,C,A,i){let e=16,l="";void 0!==g["a:rPr"]&&(e=parseInt(g["a:rPr"].attrs.sz)/100),(isNaN(e)||void 0===e)&&(l=J(I,["p:txBody","a:lstStyle","a:lvl1pPr","a:defRPr","attrs","sz"]),e=parseInt(l)/100),(isNaN(e)||void 0===e)&&("title"===A||"subTitle"===A||"ctrTitle"===A?l=J(i,["p:titleStyle","a:lvl1pPr","a:defRPr","attrs","sz"]):"body"===A?l=J(i,["p:bodyStyle","a:lvl1pPr","a:defRPr","attrs","sz"]):"dt"===A||"sldNum"===A?l="1200":void 0===A&&(l=J(i,["p:otherStyle","a:lvl1pPr","a:defRPr","attrs","sz"])),e=parseInt(l)/100);return void 0===J(g,["a:rPr","attrs","baseline"])||isNaN(e)||(e-=10),isNaN(e)?"inherit":e+"pt"}function W(g){let I,C,A="";return void 0!==g["a:bottom"]&&(I={"p:spPr":{"a:ln":g["a:bottom"]["a:ln"]}},C=p(I,!1),A+=C.replace("border","border-bottom")),void 0!==g["a:top"]&&(I={"p:spPr":{"a:ln":g["a:top"]["a:ln"]}},C=p(I,!1),A+=C.replace("border","border-top")),void 0!==g["a:right"]&&(I={"p:spPr":{"a:ln":g["a:right"]["a:ln"]}},C=p(I,!1),A+=C.replace("border","border-right")),void 0!==g["a:left"]&&(I={"p:spPr":{"a:ln":g["a:left"]["a:ln"]}},C=p(I,!1),A+=C.replace("border","border-left")),A}function p(g,I){let C="border: ";const A=g["p:spPr"]["a:ln"],i=parseInt(J(A,["attrs","w"]))/12700;isNaN(i)||i<1?C+="1pt ":C+=i+"pt ";const e=J(A,["a:prstDash","attrs","val"]);let l="0";switch(e){case"solid":default:C+="solid",l="0";break;case"dash":C+="dashed",l="5";break;case"dashDot":C+="dashed",l="5, 5, 1, 5";break;case"dot":C+="dotted",l="1, 5";break;case"lgDash":C+="dashed",l="10, 5";break;case"lgDashDotDot":C+="dashed",l="10, 5, 1, 5, 1, 5";break;case"sysDash":C+="dashed",l="5, 2";break;case"sysDashDot":C+="dashed",l="5, 2, 1, 5";break;case"sysDashDotDot":C+="dashed",l="5, 2, 1, 5, 1, 5";break;case"sysDot":C+="dotted",l="2, 5"}let t=J(A,["a:solidFill","a:srgbClr","attrs","val"]);if(void 0===t){const g=J(A,["a:solidFill","a:schemeClr"]);if(void 0!==g){t=F("a:"+J(g,["attrs","val"]),void 0)}}if(void 0===t){const I=J(g,["p:style","a:lnRef","a:schemeClr"]);if(void 0!==I){t=F("a:"+J(I,["attrs","val"]),void 0)}if(void 0!==t){let g=J(I,["a:shade","attrs","val"]);if(void 0!==g){g=(parseInt(g)/1e5).toString();const I=new SI("#"+t);I.setLum(Number(I.hsl.l)*Number(g)),t=I.hex.replace("#","")}}}return t=void 0===t?I?"none":"#000":"#"+t,C+=" "+t+" ",I?{color:t,width:i,type:e,strokeDasharray:l}:C+";"}function V(g="FFFFFF"){const I=new ArrayBuffer(4);new DataView(I).setUint32(0,parseInt(g,16),!1);const C=new Uint8Array(I);return C[1]+","+C[2]+","+C[3]}async function y(g,I,C){const A=X(J(g,["p:spPr"]));let i;if("NO_FILL"===A)return I?"none":"background-color: initial;";if("SOLID_FILL"===A){i=R(g["p:spPr"]["a:solidFill"])}else if("GRADIENT_FILL"===A){i=function(g){const I=g["a:gsLst"]["a:gs"],C=[];for(let e=0;e=6&&(C-=6),C<1?(I-g)*C+g:C<3?I:C<4?(I-g)*(4-C)+g:g}function K(g){if(void 0===g)return;let I=1;if(void 0!==g["a:srgbClr"]){const C=J(g,["a:srgbClr","a:tint","attrs","val"]);void 0!==C&&(I=parseInt(C)/1e5)}else if(void 0!==g["a:schemeClr"]){const C=J(g,["a:schemeClr","a:tint","attrs","val"]);void 0!==C&&(I=parseInt(C)/1e5)}else if(void 0!==g["a:scrgbClr"]){const C=J(g,["a:scrgbClr","a:tint","attrs","val"]);void 0!==C&&(I=parseInt(C)/1e5)}else if(void 0!==g["a:prstClr"]){const C=J(g,["a:prstClr","a:tint","attrs","val"]);void 0!==C&&(I=parseInt(C)/1e5)}else if(void 0!==g["a:hslClr"]){const C=J(g,["a:hslClr","a:tint","attrs","val"]);void 0!==C&&(I=parseInt(C)/1e5)}else if(void 0!==g["a:sysClr"]){const C=J(g,["a:sysClr","a:tint","attrs","val"]);void 0!==C&&(I=parseInt(C)/1e5)}return I}function F(g,I){""!==e&&void 0!==e||(e=J(I,["p:sldMaster","p:clrMap","attrs"])||{});const C=g.substr(2);switch(C){case"tx1":case"tx2":case"bg1":case"bg2":g="a:"+e[C.toString()]}const A=J(i,["a:theme","a:themeElements","a:clrScheme",g]);let l=J(A,["a:srgbClr","attrs","val"]);return void 0===l&&(l=J(A,["a:sysClr","attrs","lastClr"])),l}function M(g){const I=[];if(void 0===g)return I;if(void 0!==g["c:xVal"]){let C=[];S(g["c:xVal"]["c:numRef"]["c:numCache"]["c:pt"],(function(g,I){return C.push(parseFloat(g["c:v"])),""})),I.push(C),C=[],S(g["c:yVal"]["c:numRef"]["c:numCache"]["c:pt"],(function(g,I){return C.push(parseFloat(g["c:v"])),""})),I.push(C)}else S(g,(function(g,C){const A=[],i=J(g,["c:tx","c:strRef","c:strCache","c:pt","c:v"])||C,e={};return void 0!==J(g,["c:cat","c:strRef","c:strCache","c:pt"])?S(g["c:cat"]["c:strRef"]["c:strCache"]["c:pt"],(function(g,I){return e[g.attrs.idx]=g["c:v"],""})):void 0!==J(g,["c:cat","c:numRef","c:numCache","c:pt"])&&S(g["c:cat"]["c:numRef"]["c:numCache"]["c:pt"],(function(g,I){return e[g.attrs.idx]=g["c:v"],""})),void 0!==J(g,["c:val","c:numRef","c:numCache","c:pt"])&&S(g["c:val"]["c:numRef"]["c:numCache"]["c:pt"],(function(g,I){return A.push({x:g.attrs.idx,y:parseFloat(g["c:v"])}),""})),I.push({key:i,values:A,xlabels:e}),""}));return I}function J(g,I){if(I.constructor!==Array)throw Error("Error of path type! path is not array.");if(void 0===g)return;const C=I.length;for(let A=0;A{if("processPPTX"===g.type)try{await async function(g){var A;const e=await Promise.resolve().then((()=>IC)),l=await e.loadAsync(g),d=Date.now();if(l.file("docProps/thumbnail.jpeg")){const g=await(null==(A=l.file("docProps/thumbnail.jpeg"))?void 0:A.async("base64"));I({type:"pptx-thumb",data:g})}const o=await async function(g){const I=await s(g,"[Content_Types].xml"),C=I.Types.Override,A=[],i=[];for(let e=0;e0?C=C.concat(I.data):A=!0);A&&this.chart.data&&(C=C.concat(this.chart.data))}return C},this._getFontSize=function(){return this.fontSize&&"auto"!==this.fontSize.toString().toLowerCase()?isNaN(this.fontSize)?this.fontSize:this.fontSize+"px":(this.chart._heightPixels()/35>10?this.chart._heightPixels()/35:10)+"px"},this._getFormat=function(){var g,I,C,A,i,e,l;return null!==this.tickFormat&&void 0!==this.tickFormat?g=this._hasTimeField()?XI.timeFormat(this.tickFormat):XI.format(this.tickFormat):this.showPercent?g=XI.format(".0%"):this.useLog&&null!==this.measure?g=function(g){var I=Math.floor(Math.abs(g),0).toString().length,C=Math.min(Math.floor((I-1)/3),4),A="kmBT".substring(C-1,C),i="0"===Math.round(g/Math.pow(1e3,C)*10).toString().slice(-1)?0:1;return 0===g?0:XI.format(",."+i+"f")(g/Math.pow(1e3,C))+A}:null!==this.measure?(I=Math.floor(Math.abs(this._max),0).toString(),C=Math.floor(Math.abs(this._min),0).toString(),(A=Math.max(C.length,I.length))>3?(i=Math.min(Math.floor((A-1)/3),4),e="kmBT".substring(i-1,i),l=A-3*i<=1?1:0,g=function(g){return 0===g?0:XI.format(",."+l+"f")(g/Math.pow(1e3,i))+e}):(l=Math.max(-(this._tick_step?Math.floor(Math.log(this._tick_step)/Math.LN10):0),0),g=XI.format(",."+l+"f"))):g=function(g){return g},g},this._getTimePeriod=function(){var g=this.timePeriod,I=30,C=this._max-this._min;return this._hasTimeField()&&!this.timePeriod&&(g=C/1e3<=I?XI.timeSecond:C/6e4<=I?XI.timeMinute:C/36e5<=I?XI.timeHour:C/864e5<=I?XI.timeHay:C/6048e5<=I?XI.timeWeek:C/26298e5<=I?XI.timeMonth:XI.timeYear),g},this._getTooltipText=function(g,I){if(this._hasTimeField())I[this.position+"Field"][0]&&g.push(this.timeField+": "+this._getFormat()(I[this.position+"Field"][0]));else if(this._hasCategories())this.categoryFields.forEach((function(C,A){null!=C&&I[this.position+"Field"][A]&&g.push(C+(I[this.position+"Field"][A]!==C?": "+I[this.position+"Field"][A]:""))}),this);else if(this._hasMeasure())switch(this.position){case"x":g.push(this.measure+": "+this._getFormat()(I.width));break;case"y":g.push(this.measure+": "+this._getFormat()(I.height));break;case"p":g.push(this.measure+": "+this._getFormat()(I.angle)+" ("+XI.format(".0%")(I.piePct)+")");break;default:g.push(this.measure+": "+this._getFormat()(I[this.position+"Value"]))}},this._getTopMaster=function(){var g=this;return null!==this.master&&void 0!==this.master&&(g=this.master._getTopMaster()),g},this._hasCategories=function(){return null!==this.categoryFields&&void 0!==this.categoryFields&&this.categoryFields.length>0},this._hasMeasure=function(){return null!==this.measure&&void 0!==this.measure},this._hasTimeField=function(){return null!==this.timeField&&void 0!==this.timeField},this._parseDate=function(g){return null===this.dateParseFormat||void 0===this.dateParseFormat?isNaN(g)?Date.parse(g):new Date(g):XI.timeParse(this.dateParseFormat)(g)},this._update=function(g){var I,C,A,i,e=[],l=this.ticks||10,t=function(g,I,C){var A,i,e=g.categoryFields[0],l=g._getAxisData(),t=e,s=!1,c=!0,d=null;for(A=0;A1?1:this._max,this._min=null!==this.overrideMin?this.overrideMin:this._min,this._max=null!==this.overrideMax?this.overrideMax:this._max,"x"!==this.position||null!==this._scale&&!g){if("y"!==this.position||null!==this._scale&&!g)this.position.length>0&&"z"===this.position[0]&&null===this._scale?this.useLog?this._scale=XI.scaleLog().range([this.chart._heightPixels()/300,this.chart._heightPixels()/10]).domain([0===this._min?Math.pow(this.logBase,-1):this._min,0===this._max?-1*Math.pow(this.logBase,-1):this._max]).clamp(this.clamp).base(this.logBase):this._scale=XI.scaleLinear().range([1,this.chart._heightPixels()/10]).domain([this._min,this._max]).clamp(this.clamp):this.position.length>0&&"p"===this.position[0]&&null===this._scale?this.useLog?this._scale=XI.scaleLog().range([0,360]).domain([0===this._min?Math.pow(this.logBase,-1):this._min,0===this._max?-1*Math.pow(this.logBase,-1):this._max]).clamp(this.clamp).base(this.logBase):this._scale=XI.scaleLinear().range([0,360]).domain([this._min,this._max]).clamp(this.clamp):this.position.length>0&&"c"===this.position[0]&&null===this._scale&&(this._scale=XI.scaleLinear().range([0,null===this.colors||1===this.colors.length?1:this.colors.length-1]).domain([this._min,this._max]).clamp(this.clamp));else if(this._hasTimeField()?this._scale=XI.scaleTime().range([this.chart._yPixels()+this.chart._heightPixels(),this.chart._yPixels()]).domain([this._min,this._max]).clamp(this.clamp):this.useLog?this._scale=XI.scaleLog().range([this.chart._yPixels()+this.chart._heightPixels(),this.chart._yPixels()]).domain([0===this._min?Math.pow(this.logBase,-1):this._min,0===this._max?-1*Math.pow(this.logBase,-1):this._max]).clamp(this.clamp).base(this.logBase).nice():null===this.measure||void 0===this.measure?(e=t(this,"y","x"),null!==this._slaves&&void 0!==this._slaves&&this._slaves.forEach((function(g){e=e.concat(t(g,"y","x"))}),this),this._scale=XI.scalePoint().range([this.chart._yPixels()+this.chart._heightPixels(),this.chart._yPixels()]).domain(e.concat([""]))):this._scale=XI.scaleLinear().range([this.chart._yPixels()+this.chart._heightPixels(),this.chart._yPixels()]).domain([this._min,this._max]).clamp(this.clamp).nice(),!this.hidden)switch(this.chart._axisIndex(this,"y")){case 0:this._draw=XI.axisLeft().scale(this._scale),this.ticks&&this._draw.ticks(l);break;case 1:this._draw=XI.axisRight().scale(this._scale),this.ticks&&this._draw.ticks(l)}}else if(this._hasTimeField()?this._scale=XI.scaleTime().range([this.chart._xPixels(),this.chart._xPixels()+this.chart._widthPixels()]).domain([this._min,this._max]).clamp(this.clamp):this.useLog?this._scale=XI.scaleLog().range([this.chart._xPixels(),this.chart._xPixels()+this.chart._widthPixels()]).domain([0===this._min?Math.pow(this.logBase,-1):this._min,0===this._max?-1*Math.pow(this.logBase,-1):this._max]).clamp(this.clamp).base(this.logBase).nice():null===this.measure||void 0===this.measure?(e=t(this,"x","y"),null!==this._slaves&&void 0!==this._slaves&&this._slaves.forEach((function(g){e=e.concat(t(g,"x","y"))}),this),this._scale=XI.scalePoint().range([this.chart._xPixels(),this.chart._xPixels()+this.chart._widthPixels()]).domain(e.concat([""]))):this._scale=XI.scaleLinear().range([this.chart._xPixels(),this.chart._xPixels()+this.chart._widthPixels()]).domain([this._min,this._max]).clamp(this.clamp).nice(),!this.hidden)switch(this.chart._axisIndex(this,"x")){case 0:this._draw=XI.axisBottom().scale(this._scale),this.ticks&&this._draw.ticks(l);break;case 1:this._draw=XI.axisTop().scale(this._scale),this.ticks&&this._draw.ticks(l)}return null!==this._slaves&&void 0!==this._slaves&&this._slaves.length>0&&this._slaves.forEach((function(g){g._scale=this._scale}),this),null!=g&&!1!==g||this._hasTimeField()||null===this._scale||null===this._scale.ticks||void 0===this._scale.ticks||!(this._scale.ticks(l).length>0)||"x"!==this.position&&"y"!==this.position||(C=(I=this._scale.ticks(l))[1]-I[0],A=((this._max-this._min)%C).toFixed(0),this._tick_step=C,0!==A&&(this._max=Math.ceil(this._max/C)*C,this._min=Math.floor(this._min/C)*C,this._update(!0))),i=null!=e&&e.length>0?this._scale.copy()(e[0]):this._min>0?this._scale.copy()(this._min):this._max<0?this._scale.copy()(this._max):this._scale.copy()(0),this._origin!==i&&(this._previousOrigin=null===this._origin?i:this._origin,this._origin=i),this},this.addGroupOrderRule=function(g,I){this._groupOrderRules.push({ordering:g,desc:I})},this.addOrderRule=function(g,I){this._orderRules.push({ordering:g,desc:I})}},chart:function(g,I){this.svg=g,this.x="10%",this.y="10%",this.width="80%",this.height="80%",this.data=I,this.noFormats=!1,this.axes=[],this.series=[],this.legends=[],this.storyboard=null,this.titleShape=null,this.shapes=null,this.ease=XI.easeCubicInOut,this.staggerDraw=!1,this.transition={},this._group=g.append("g"),this._group.attr("class","dimple-chart"),this._gridlines_group=this._group.insert("g"),this._gridlines_group.attr("class","dimple-gridlines-group"),this._axis_group=this._group.insert("g"),this._axis_group.attr("class","dimple-axis-group"),this._tooltipGroup=null,this._assignedColors={},this._assignedClasses={},this._nextColor=0,this._nextClass=0,this._axisIndex=function(g,I){var C=0,A=0,i=-1;for(C=0;C0&&(g=g.concat(this.data)),null!==this.series&&void 0!==this.series&&this.series.length>0&&this.series.forEach((function(I){null!==I.data&&void 0!==I.data&&I.data.length>0&&(g=g.concat(I.data))})),g},this._getData=function(g,I,C,A,i,e,l,t,s,c){var d,o,n=[],a=function(g,I){var C=[];return null!==g&&(g._hasTimeField()?C.push(g._parseDate(I[g.timeField])):g._hasCategories()&&g.categoryFields.forEach((function(g){C.push(I[g])}),this)),C},Z={x:!1,y:!1,z:!1,p:!1,c:!1},b={x:[],y:[]},r={x:[],y:[],z:[],p:[]},m={min:null,max:null},h={x:[],y:[],z:[],p:[]},G=[],u={},B={x:0,y:0,z:0,p:0},w="",W=[],p=[],V=[],y="",X=[],Y="",R=[],N="",H=[],K=[],F=g,M=[];for(o in this.storyboard&&this.storyboard.categoryFields.length>0&&(w=this.storyboard.categoryFields[0],W=QI._getOrderedList(F,w,this.storyboard._orderRules)),e&&e._hasCategories()&&e._hasMeasure()&&(y=e.categoryFields[0],X=QI._getOrderedList(F,y,e._orderRules.concat([{ordering:e.measure,desc:!0}]))),l&&l._hasCategories()&&l._hasMeasure()&&(Y=l.categoryFields[0],R=QI._getOrderedList(F,Y,l._orderRules.concat([{ordering:l.measure,desc:!0}]))),s&&s._hasCategories()&&s._hasMeasure()&&(N=s.categoryFields[0],H=QI._getOrderedList(F,N,s._orderRules.concat([{ordering:s.measure,desc:!0}]))),F.length>0&&I&&I.length>0&&(K=[].concat(A),p=[],I.forEach((function(g){void 0!==F[0][g]&&p.push(g)}),this),s&&s._hasMeasure()?K.push({ordering:s.measure,desc:!0}):c&&c._hasMeasure()?K.push({ordering:c.measure,desc:!0}):t&&t._hasMeasure()?K.push({ordering:t.measure,desc:!0}):e&&e._hasMeasure()?K.push({ordering:e.measure,desc:!0}):l&&l._hasMeasure()&&K.push({ordering:l.measure,desc:!0}),V=QI._getOrderedList(F,p,K)),F.sort((function(g,I){var C,A,i,e,l,t,s=0;if(""!==w&&(s=W.indexOf(g[w])-W.indexOf(I[w])),""!==y&&0===s&&(s=X.indexOf(g[y])-X.indexOf(I[y])),""!==Y&&0===s&&(s=R.indexOf(g[Y])-R.indexOf(I[Y])),""!==N&&0===s&&(s=H.indexOf(g[N])-R.indexOf(I[N])),p&&p.length>0&&0===s)for(C=[].concat(p),s=0,i=0;i0&&(c+="/"),c+=g[I],l=c===i}),this)),null!=I&&l&&(e=n[r],I._hasMeasure()&&null!==g[I.measure]&&void 0!==g[I.measure]&&(-1===e[I.position+"ValueList"].indexOf(g[I.measure])&&e[I.position+"ValueList"].push(g[I.measure]),isNaN(parseFloat(g[I.measure]))&&(Z[I.position]=!0),t.value=e[I.position+"Value"],t.count=e[I.position+"Count"],s.value=g[I.measure],e[I.position+"Value"]=C(t,s),e[I.position+"Count"]+=1))})(e,this.storyboard),b(l,this.storyboard),b(t,this.storyboard),b(s,this.storyboard),b(c,this.storyboard)}),this),e&&e._hasCategories()&&e.categoryFields.length>1&&void 0!==b.x&&(M=[],l._hasMeasure()&&M.push({ordering:l.measure,desc:!0}),b.x=QI._getOrderedList(F,e.categoryFields[1],e._groupOrderRules.concat(M))),l&&l._hasCategories()&&l.categoryFields.length>1&&void 0!==b.y&&(M=[],e._hasMeasure()&&M.push({ordering:e.measure,desc:!0}),b.y=QI._getOrderedList(F,l.categoryFields[1],l._groupOrderRules.concat(M)),b.y.reverse()),n.forEach((function(g){null!==e&&(!0===Z.x&&(g.xValue=g.xValueList.length),d=e._hasMeasure()&&e._hasCategories()?(r.x[g.xField.join("/")]||0)+(e._hasMeasure()?Math.abs(g.xValue):0):(r.x[g.xField.join("/")]||0)+(l._hasMeasure()?Math.abs(g.yValue):0),r.x[g.xField.join("/")]=d),null!==l&&(!0===Z.y&&(g.yValue=g.yValueList.length),d=l._hasMeasure()&&l._hasCategories()?(r.y[g.yField.join("/")]||0)+(l._hasMeasure()?Math.abs(g.yValue):0):(r.y[g.yField.join("/")]||0)+(e._hasMeasure()?Math.abs(g.xValue):0),r.y[g.yField.join("/")]=d),null!==s&&(!0===Z.p&&(g.pValue=g.pValueList.length),d=(r.p[g.pField.join("/")]||0)+(s._hasMeasure()?Math.abs(g.pValue):0),r.p[g.pField.join("/")]=d),null!==t&&(!0===Z.z&&(g.zValue=g.zValueList.length),d=(r.z[g.zField.join("/")]||0)+(t._hasMeasure()?Math.abs(g.zValue):0),r.z[g.zField.join("/")]=d),null!==c&&((null===m.min||g.cValuem.max)&&(m.max=g.cValue))}),this),r.x)Object.prototype.hasOwnProperty.call(r.x,o)&&(B.x+=r.x[o]);for(o in r.y)Object.prototype.hasOwnProperty.call(r.y,o)&&(B.y+=r.y[o]);for(o in r.p)Object.prototype.hasOwnProperty.call(r.p,o)&&(B.p+=r.p[o]);for(o in r.z)Object.prototype.hasOwnProperty.call(r.z,o)&&(B.z+=r.z[o]);return n.forEach((function(g){var I,C,A,d,o=function(I,C,A){var e,l,t,s,c;null!=I&&(s=I.position,I._hasCategories()?I._hasMeasure()?(e=g[I.position+"Field"].join("/"),l=I.showPercent?r[I.position][e]/B[I.position]:r[I.position][e],-1===G.indexOf(e)&&(u[e]=l+(G.length>0?u[G[G.length-1]]:0),G.push(e)),t=g[s+"Bound"]=g["c"+s]="x"!==s&&"y"!==s||!i?l:u[e],g[A]=l,g[s]=t-("x"===s&&l>=0||"y"===s&&l<=0?l:0)):(g[s]=g["c"+s]=g[s+"Field"][0],g[A]=1,void 0!==b[s]&&null!==b[s]&&b[s].length>=2&&(g[s+"Offset"]=b[s].indexOf(g[s+"Field"][1]),g[A]=1/b[s].length)):(l=I.showPercent?g[s+"Value"]/r[C][g[C+"Field"].join("/")]:g[s+"Value"],e=g[C+"Field"].join("/")+(g[s+"Value"]>=0),c=h[s][e]=(null===h[s][e]||void 0===h[s][e]||"z"===s||"p"===s?0:h[s][e])+l,t=g[s+"Bound"]=g["c"+s]="x"!==s&&"y"!==s||!i?l:c,g[A]=l,g[s]=t-("x"===s&&l>=0||"y"===s&&l<=0?l:0)))};o(e,"y","width"),o(l,"x","height"),o(t,"z","r"),o(s,"p","angle"),null!==c&&null!==m.min&&null!==m.max&&(m.min===m.max&&(m.min-=.5,m.max+=.5),m.min=c.overrideMin||m.min,m.max=c.overrideMax||m.max,g.cValue=g.cValue>m.max?m.max:g.cValue1?(I=XI.rgb(c.colors[Math.floor(A)]),C=XI.rgb(c.colors[Math.ceil(A)])):(I=XI.rgb("white"),C=XI.rgb(this.getColor(g.aggField.slice(-1)[0]).fill)),I.r=Math.floor(I.r+(C.r-I.r)*d),I.g=Math.floor(I.g+(C.g-I.g)*d),I.b=Math.floor(I.b+(C.b-I.b)*d),g.fill=I.toString(),g.stroke=I.darker(.5).toString())}),this),n},this._getDelay=function(g,I,C){return function(A){var i=0;return C&&I.staggerDraw&&(C.x._hasCategories()?i=QI._helpers.cx(A,I,C)/I._widthPixels()*g:C.y._hasCategories()&&(i=(1-QI._helpers.cy(A,I,C)/I._heightPixels())*g)),i}},this._getSeriesData=function(){null!==this.series&&void 0!==this.series&&this.series.forEach((function(g){var I,C,A,i,e,l=g.data||this.data||[],t=[].concat(g.categoryFields||"All"),s=this._getData(l,t,g.aggregate,g._orderRules,g._isStacked(),g.x,g.y,g.z,g.p,g.c),c=[],d={},o=g.startAngle*(Math.PI/180)||0,n=(g.endAngle||360)*(Math.PI/180);if(o>n&&(o-=2*Math.PI),g.p&&t.length>0){if(g.x&&g.y){for(t.pop(),c=this._getData(l,["__dimple_placeholder__"].concat(t),g.aggregate,g._orderRules,g._isStacked(),g.x,g.y,g.z,g.p,g.c),I=0;I0&&g._eventHandlers.forEach((function(I){var C,A=function(C){var A=new QI.eventArgs;null!==g.chart.storyboard&&(A.frameValue=g.chart.storyboard.getFrameValue()),A.seriesValue=C.aggField,A.xValue=C.x,A.yValue=C.y,A.zValue=C.z,A.pValue=C.p,A.colorValue=C.cValue,A.seriesShapes=g.shapes,A.selectedShape=XI.select(this),I.handler(A)};if(null!==I.handler&&"function"==typeof I.handler)if(null!==g._markers&&void 0!==g._markers)for(C in g._markers)Object.prototype.hasOwnProperty.call(g._markers,C)&&g._markers[C].on(I.event,A);else g.shapes.on(I.event,A)}),this)},this._widthPixels=function(){return QI._parseXPosition(this.width,this.svg.node())},this._xPixels=function(){return QI._parseXPosition(this.x,this.svg.node())},this._yPixels=function(){return QI._parseYPosition(this.y,this.svg.node())},this.addAxis=function(g,I,C,A){var i,e=null,l=null;if(null!=I&&(I=[].concat(I)),"string"==typeof g||g instanceof String)e=new QI.axis(this,g,I,C,A),this.axes.push(e);else{if(l=g,(e=new QI.axis(this,l.position,I,C,A))._hasMeasure()!==l._hasMeasure()?i="You have specified a composite axis where some but not all axes have a measure - this is not supported, all axes must be of the same type.":e._hasTimeField()!==l._hasTimeField()?i="You have specified a composite axis where some but not all axes have a time field - this is not supported, all axes must be of the same type.":(null===e.categoryFields||void 0===e.categoryFields?0:e.categoryFields.length)!==(null===l.categoryFields||void 0===l.categoryFields?0:l.categoryFields.length)&&(i="You have specified a composite axis where axes have differing numbers of category fields - this is not supported, all axes must be of the same type."),i)throw i;l._slaves.push(e)}return e},this.addCategoryAxis=function(g,I){return this.addAxis(g,I,null)},this.addColorAxis=function(g,I){var C=this.addAxis("c",null,g);return C.colors=null==I?null:[].concat(I),C},this.addLegend=function(g,I,C,A,i,e){e=null==e?this.series:[].concat(e),i=null==i?"left":i;var l=new QI.legend(this,g,I,C,A,i,e);return this.legends.push(l),l},this.addLogAxis=function(g,I,C){var A=this.addAxis(g,null,I,null);return null!=C&&(A.logBase=C),A.useLog=!0,A},this.addMeasureAxis=function(g,I){return this.addAxis(g,null,I)},this.addPctAxis=function(g,I,C){var A=null;return(A=null!=C?this.addAxis(g,C,I):this.addMeasureAxis(g,I)).showPercent=!0,A},this.addSeries=function(g,I,C){null==C&&(C=this.axes),null==I&&(I=QI.plot.bubble);var A,i=null,e=null,l=null,t=null,s=null;return C.forEach((function(g){null!==g&&I.supportedAxes.indexOf(g.position)>-1&&(null===i&&"x"===g.position[0]?i=g:null===e&&"y"===g.position[0]?e=g:null===l&&"z"===g.position[0]?l=g:null===t&&"c"===g.position[0]?t=g:null===t&&"p"===g.position[0]&&(s=g))}),this),g&&(g=[].concat(g)),A=new QI.series(this,g,i,e,l,t,s,I,QI.aggregateMethod.sum,I.stacked),this.series.push(A),A},this.addTimeAxis=function(g,I,C,A){var i=this.addAxis(g,null,null,I);return i.tickFormat=A,i.dateParseFormat=C,i},this.assignClass=function(g,I){return this._assignedClasses[g]=I,this._assignedClasses[g]},this.assignColor=function(g,I,C,A){return this._assignedColors[g]=new QI.color(I,C,A),this._assignedColors[g]},this.customClassList={axisLine:"dimple-custom-axis-line",axisLabel:"dimple-custom-axis-label",axisTitle:"dimple-custom-axis-title",tooltipBox:"dimple-custom-tooltip-box",tooltipLabel:"dimple-custom-tooltip-label",tooltipDropLine:"dimple-custom-tooltip-dropline",lineMarker:"dimple-custom-line-marker",lineMarkerCircle:"dimple-custom-line-marker-circle",legendLabel:"dimple-custom-legend-label",legendKey:"dimple-custom-legend-key",areaSeries:"dimple-custom-series-area",barSeries:"dimple-custom-series-bar",bubbleSeries:"dimple-custom-series-bubble",lineSeries:"dimple-custom-series-line",pieSeries:"dimple-custom-series-pie",gridline:"dimple-custom-gridline",colorClasses:["dimple-custom-format-1","dimple-custom-format-2","dimple-custom-format-3","dimple-custom-format-4","dimple-custom-format-5","dimple-custom-format-6","dimple-custom-format-7","dimple-custom-format-8","dimple-custom-format-9","dimple-custom-format-10"]},this.defaultColors=[new QI.color("#80B1D3"),new QI.color("#FB8072"),new QI.color("#FDB462"),new QI.color("#B3DE69"),new QI.color("#FFED6F"),new QI.color("#BC80BD"),new QI.color("#8DD3C7"),new QI.color("#CCEBC5"),new QI.color("#FFFFB3"),new QI.color("#BEBADA"),new QI.color("#FCCDE5"),new QI.color("#D9D9D9")],this.draw=function(g,I){g=g||0;var C,A,i=null,e=null,l=!1,t=!1,s=this._xPixels(),c=this._yPixels(),d=this._widthPixels(),o=this._heightPixels();return null!=I&&!1!==I||this._getSeriesData(),this.axes.forEach((function(g){g._scale=null}),this),this.axes.forEach((function(g){if(g._min=0,g._max=0,A=[],g._hasMeasure()){var I=!1;this.series.forEach((function(C){if(C._deepMatch(g)){var A=C._axisBounds(g.position);g._min>A.min&&(g._min=A.min),g._maxI[g.measure]&&(g._min=I[g.measure]),g._maxg._max)&&(g._max=A)}),this)}),this)):g._hasCategories()&&(g._min=0,C=[],this.series.forEach((function(I){I._deepMatch(g)&&null!==I[g.position].categoryFields[0]&&void 0!==I[g.position].categoryFields[0]&&-1===A.indexOf(I[g.position].categoryFields[0])&&A.push(I[g.position].categoryFields[0])}),this),g._getAxisData().forEach((function(g){A.forEach((function(I){-1===C.indexOf(g[I])&&C.push(g[I])}),this)}),this),g._max=C.length);null!==g._slaves&&void 0!==g._slaves&&g._slaves.length>0&&g._slaves.forEach((function(I){I._min=g._min,I._max=g._max}),this),g._update(),null===i&&"x"===g.position?i=g:null===e&&"y"===g.position&&(e=g)}),this),this.axes.forEach((function(I){var C=!1,A=null,n=0,a=null,Z=!1,b=0,r={l:null,t:null,r:null,b:null},m=0,h=0,G="",u=this,B=function(I){return null===A||0===g||C?I:u._handleTransition(I,g,u)},w=function(){var g=XI.select(this).selectAll("text");return!I.measure&&I._max>0&&("x"===I.position?g.attr("x",d/I._max/2):"y"===I.position&&g.attr("y",o/I._max*-1/2)),I.categoryFields&&I.categoryFields.length>0&&(I!==i||null!==e.categoryFields&&0!==e.categoryFields.length||g.attr("y",c+o-e._scale(0)+9),I!==e||null!==i.categoryFields&&0!==i.categoryFields.length||g.attr("x",-1*(i._scale(0)-s)-9)),this},W=function(g){return function(){var I=XI.select(this).attr("class")||"";return-1===I.indexOf(g)&&(I+=" "+g),I.trim()}};null===I.gridlineShapes?(I.showGridlines||null===I.showGridlines&&!I._hasCategories()&&(!l&&"x"===I.position||!t&&"y"===I.position))&&(I.gridlineShapes=this._gridlines_group.append("g").attr("class","dimple-gridline"),"x"===I.position?l=!0:t=!0):"x"===I.position?l=!0:t=!0,null===I.shapes&&(I.shapes=this._axis_group.append("g").attr("class","dimple-axis dimple-axis-"+I.position).each((function(){u.noFormats||XI.select(this).style("font-family",I.fontFamily).style("font-size",I._getFontSize())})),C=!0),I===i&&null!==e?(A="translate(0, "+(null===e.categoryFields||0===e.categoryFields.length?e._scale(0):c+o)+")",a="translate(0, "+(I===i?c+o:c)+")",n=-o):I===e&&null!==i?(A="translate("+(null===i.categoryFields||0===i.categoryFields.length?i._scale(0):s)+", 0)",a="translate("+(I===e?s:s+d)+", 0)",n=-d):"x"===I.position?(a=A="translate(0, "+(I===i?c+o:c)+")",n=-o):"y"===I.position&&(a=A="translate("+(I===e?s:s+d)+", 0)",n=-d),null!==A&&null!==I._draw&&(I._hasTimeField()?B(I.shapes).call(I._draw.ticks(I._getTimePeriod(),I.timeInterval).tickFormat(I._getFormat())).attr("transform",A).each(w):I.useLog?B(I.shapes).call(I._draw.ticks(4,I._getFormat())).attr("transform",A).each(w):B(I.shapes).call(I._draw.tickFormat(I._getFormat())).attr("transform",A).each(w),null!==I.gridlineShapes&&B(I.gridlineShapes).call(I._draw.tickSize(n,0,0).tickFormat("")).attr("transform",a)),B(I.shapes.selectAll("text")).attr("class",W(u.customClassList.axisLabel)).call((function(g){u.noFormats||g.style("font-family",I.fontFamily).style("font-size",I._getFontSize())})),B(I.shapes.selectAll("path, line")).attr("class",W(u.customClassList.axisLine)).call((function(g){u.noFormats||g.style("fill","none").style("stroke","black").style("shape-rendering","crispEdges")})),null!==I.gridlineShapes&&(I.gridlineShapes.selectAll("path").remove(),B(I.gridlineShapes.selectAll("line")).attr("class",W(u.customClassList.gridline)).call((function(g){u.noFormats||g.style("fill","none").style("stroke","lightgray").style("opacity",.8)}))),null!==I.measure&&void 0!==I.measure||(I.autoRotateLabel?I===i?(b=0,I.shapes.selectAll("text").each((function(){var g=this.getComputedTextLength();b=g>b?g:b})),b>d/I.shapes.selectAll("text").nodes().length?(Z=!0,I.shapes.selectAll("text").style("text-anchor","start").each((function(){var g=this.getBBox();XI.select(this).attr("transform","rotate(90,"+g.x+","+(g.y+g.height/2)+") translate(-5, 0)")}))):(Z=!1,I.shapes.selectAll("text").style("text-anchor","middle").attr("transform",""))):"x"===I.position&&(b=0,I.shapes.selectAll("text").each((function(){var g=this.getComputedTextLength();b=g>b?g:b})),b>d/I.shapes.selectAll("text").nodes().length?(Z=!0,I.shapes.selectAll("text").style("text-anchor","end").each((function(){var g=this.getBBox();XI.select(this).attr("transform","rotate(90,"+(g.x+g.width)+","+(g.y+g.height/2)+") translate(5, 0)")}))):(Z=!1,I.shapes.selectAll("text").style("text-anchor","middle").attr("transform",""))):(Z=!1,I.shapes.selectAll("text").style("text-anchor","middle").attr("transform",""))),null!==I.titleShape&&void 0!==I.titleShape&&I.titleShape.remove(),I.shapes.selectAll("text").each((function(){var g=this.getBBox();(null===r.l||-9-g.widthr.r)&&(r.r=g.x+g.width),Z?((null===r.t||g.y+g.height-g.widthr.b)&&(r.b=g.height+g.width)):((null===r.t||g.yr.b)&&(r.b=9+g.height))})),"x"===I.position?(h=I===i?c+o+r.b+5:c+r.t-10,m=s+d/2):"y"===I.position&&(G="rotate(270, "+(m=I===e?s+r.l-10:s+d+r.r+20)+", "+(h=c+o/2)+")"),I.hidden||"x"!==I.position&&"y"!==I.position||null===I.title||(I.titleShape=this._axis_group.append("text").attr("class","dimple-axis dimple-title "+u.customClassList.axisTitle+" dimple-axis-"+I.position),I.titleShape.attr("x",m).attr("y",h).attr("text-anchor","middle").attr("transform",G).text(void 0!==I.title?I.title:null===I.categoryFields||void 0===I.categoryFields||0===I.categoryFields.length?I.measure:I.categoryFields.join("/")).each((function(){u.noFormats||XI.select(this).style("font-family",I.fontFamily).style("font-size",I._getFontSize())})),I===i?I.titleShape.each((function(){XI.select(this).attr("y",h+this.getBBox().height/1.65)})):I===e&&I.titleShape.each((function(){XI.select(this).attr("x",m+this.getBBox().height/1.65)})))}),this),this.series.forEach((function(I){I.plot.draw(this,I,g),this._registerEventHandlers(I)}),this),this.legends.forEach((function(g){g._draw()}),this),this.storyboard&&(this.storyboard._drawText(),this.storyboard.autoplay&&this.storyboard.startAnimation()),this},this.getClass=function(g){return this._assignedClasses[g]||(this._assignedClasses[g]=this.customClassList.colorClasses[this._nextClass],this._nextClass=(this._nextClass+1)%this.customClassList.colorClasses.length),this._assignedClasses[g]},this.getColor=function(g){return null!==this._assignedColors[g]&&void 0!==this._assignedColors[g]||(this._assignedColors[g]=this.defaultColors[this._nextColor],this._nextColor=(this._nextColor+1)%this.defaultColors.length),this._assignedColors[g]},this.setBounds=function(g,I,C,A){return this.x=g,this.y=I,this.width=C,this.height=A,this._xPixels=function(){return QI._parseXPosition(this.x,this.svg.node())},this.draw(0,!0),this._yPixels=function(){return QI._parseYPosition(this.y,this.svg.node())},this._widthPixels=function(){return QI._parseXPosition(this.width,this.svg.node())},this._heightPixels=function(){return QI._parseYPosition(this.height,this.svg.node())},this},this.setMargins=function(g,I,C,A){return this.x=g,this.y=I,this.width=0,this.height=0,this._xPixels=function(){return QI._parseXPosition(this.x,this.svg.node())},this._yPixels=function(){return QI._parseYPosition(this.y,this.svg.node())},this._widthPixels=function(){return QI._parentWidth(this.svg.node())-this._xPixels()-QI._parseXPosition(C,this.svg.node())},this._heightPixels=function(){return QI._parentHeight(this.svg.node())-this._yPixels()-QI._parseYPosition(A,this.svg.node())},this},this.setStoryboard=function(g,I){return this.storyboard=new QI.storyboard(this,g),null!=I&&(this.storyboard.onTick=I),this.storyboard}},color:function(g,I,C){this.fill=g,this.stroke=null==I?XI.rgb(g).darker(.5).toString():I,this.opacity=null==C?.8:C},eventArgs:function(){this.seriesValue=null,this.xValue=null,this.yValue=null,this.zValue=null,this.pValue=null,this.colorValue=null,this.frameValue=null,this.seriesShapes=null,this.selectedShape=null},legend:function(g,I,C,A,i,e,l){this.chart=g,this.series=l,this.x=I,this.y=C,this.width=A,this.height=i,this.horizontalAlign=e,this.shapes=null,this.fontSize="10px",this.fontFamily="sans-serif",this._draw=function(){var g,I=this._getEntries(),C=0,A=0,i=0,e=0,l=this;this.shapes&&this.shapes.remove(),(g=this.chart._group.selectAll(".dimple-dont-select-any").data(I).enter().append("g").attr("class",(function(g){return"dimple-legend "+QI._createClass(g.aggField)})).attr("opacity",1)).append("text").attr("class",(function(g){return"dimple-legend dimple-legend-text "+QI._createClass(g.aggField)+" "+l.chart.customClassList.legendLabel})).text((function(g){return g.key})).call((function(g){l.chart.noFormats||g.style("font-family",l.fontFamily).style("font-size",l._getFontSize()).style("shape-rendering","crispEdges")})).each((function(){var g=this.getBBox();g.width>C&&(C=g.width),g.height>A&&(A=g.height)})),g.append("rect").attr("class",(function(g){return"dimple-legend dimple-legend-key "+QI._createClass(g.aggField)})).attr("height",9).attr("width",15),A=(A<9?9:A)+l._getVerticalPadding(),C+=15+l._getHorizontalPadding(),g.each((function(g){i+C>l._widthPixels()&&(i=0,e+=A),e>l._heightPixels()?XI.select(this).remove():(XI.select(this).select("text").attr("x","left"===l.horizontalAlign?l._xPixels()+15+5+i:l._xPixels()+(l._widthPixels()-i-C)+15+5).attr("y",(function(){return l._yPixels()+e+this.getBBox().height/1.65})).attr("width",l._widthPixels()).attr("height",l._heightPixels()),XI.select(this).select("rect").attr("class",(function(g){return"dimple-legend dimple-legend-key "+QI._createClass(g.aggField)+" "+l.chart.customClassList.legendKey+" "+g.css})).attr("x","left"===l.horizontalAlign?l._xPixels()+i:l._xPixels()+(l._widthPixels()-i-C)).attr("y",l._yPixels()+e).attr("height",9).attr("width",15).call((function(I){l.chart.noFormats||I.style("fill",g.fill).style("stroke",g.stroke).style("opacity",g.opacity).style("shape-rendering","crispEdges")})),i+=C)})),this.shapes=g},this._getEntries=function(){var g=[];return this.series&&this.series.forEach((function(I){I._positionData.forEach((function(C){var A,i=-1,e=I.plot.grouped&&!I.x._hasCategories()&&!I.y._hasCategories()&&C.aggField.length<2?"All":C.aggField.slice(-1)[0];for(A=0;A10?this.chart._heightPixels()/35:10)+"px"},this._getHorizontalPadding=function(){return isNaN(this.horizontalPadding)?20:this.horizontalPadding},this._getVerticalPadding=function(){return isNaN(this.verticalPadding)?2:this.verticalPadding},this._heightPixels=function(){return QI._parseYPosition(this.height,this.chart.svg.node())},this._widthPixels=function(){return QI._parseXPosition(this.width,this.chart.svg.node())},this._xPixels=function(){return QI._parseXPosition(this.x,this.chart.svg.node())},this._yPixels=function(){return QI._parseYPosition(this.y,this.chart.svg.node())}},series:function(g,I,C,A,i,e,l,t,s,c){this.chart=g,this.x=C,this.y=A,this.z=i,this.c=e,this.p=l,this.plot=t,this.categoryFields=I,this.aggregate=s,this.stacked=c,this.barGap=.2,this.clusterBarGap=.1,this.lineWeight=2,this.lineMarkers=!1,this.afterDraw=null,this.interpolation="linear",this.tooltipFontSize="10px",this.tooltipFontFamily="sans-serif",this.radius="auto",this._group=g._group.append("g"),this._group.attr("class","dimple-series-group-"+g.series.length),this._eventHandlers=[],this._positionData=[],this._orderRules=[],this._axisBounds=function(g){var I,C,A,i={min:0,max:0},e=null,l=null,t=[],s=this._positionData;return"x"===g?(e=this.x,l=this.y):"y"===g?(e=this.y,l=this.x):"z"===g?e=this.z:"p"===g?e=this.p:"c"===g&&(e=this.c),e.showPercent?s.forEach((function(g){g[e.position+"Bound"]i.max&&(i.max=g[e.position+"Bound"])}),this):null===l||null===l.categoryFields||0===l.categoryFields.length?s.forEach((function(g){!this._isStacked()||"x"!==e.position&&"y"!==e.position?(g[e.position+"Value"]i.max&&(i.max=g[e.position+"Value"])):g[e.position+"Value"]<0?i.min=i.min+g[e.position+"Value"]:i.max=i.max+g[e.position+"Value"]}),this):(I=e.position+"Value",C=l.position+"Field",A=[],s.forEach((function(g){var i=g[C].join("/"),e=A.indexOf(i);-1===e&&(A.push(i),e=A.length-1),void 0===t[e]&&(t[e]={min:0,max:0}),this.stacked?g[I]<0?t[e].min=t[e].min+g[I]:t[e].max=t[e].max+g[I]:(g[I]t[e].max&&(t[e].max=g[I]))}),this),t.forEach((function(g){void 0!==g&&(g.mini.max&&(i.max=g.max))}),this)),i},this._deepMatch=function(g){var I=!1;return this[g.position]===g?I=!0:void 0!==g._slaves&&null!==g._slaves&&g._slaves.length>0&&g._slaves.forEach((function(g){I=I||this._deepMatch(g)}),this),I},this._dropLineOrigin=function(){var g=0,I=0,C={x:null,y:null},A={x:null,y:null};return this.chart.axes.forEach((function(g){"x"===g.position&&null===A.x?g._hasTimeField()?A.x=this.chart._xPixels():A.x=g._origin:"y"===g.position&&null===A.y&&(g._hasTimeField()?A.y=this.chart._yPixels()+this.chart._heightPixels():A.y=g._origin)}),this),this.chart.axes.forEach((function(i){"x"!==i.position||this.x.hidden?"y"!==i.position||this.y.hidden||(this._deepMatch(i)&&(0===I?C.x=A.x:1===I&&(C.x=this.chart._xPixels()+this.chart._widthPixels())),I+=1):(this._deepMatch(i)&&(0===g?C.y=A.y:1===g&&(C.y=this.chart._yPixels())),g+=1)}),this),C},this._getTooltipFontSize=function(){return this.tooltipFontSize&&"auto"!==this.tooltipFontSize.toString().toLowerCase()?isNaN(this.tooltipFontSize)?this.tooltipFontSize:this.tooltipFontSize+"px":(this.chart._heightPixels()/35>10?this.chart._heightPixels()/35:10)+"px"},this._isStacked=function(){return this.stacked&&(this.x._hasCategories()||this.y._hasCategories())},this.addEventHandler=function(g,I){this._eventHandlers.push({event:g,handler:I})},this.addOrderRule=function(g,I){this._orderRules.push({ordering:g,desc:I})},this.getTooltipText=function(g){var I=[];return null!==this.categoryFields&&void 0!==this.categoryFields&&this.categoryFields.length>0&&this.categoryFields.forEach((function(C,A){null!=C&&null!==g.aggField[A]&&void 0!==g.aggField[A]&&I.push(C+(g.aggField[A]!==C?": "+g.aggField[A]:""))}),this),this.p?(this.x&&this.x._hasCategories()&&this.x._getTooltipText(I,g),this.y&&this.y._hasCategories()&&this.y._getTooltipText(I,g),this.z&&this.z._hasCategories()&&this.z._getTooltipText(I,g),this.p._getTooltipText(I,g)):(this.x&&this.x._getTooltipText(I,g),this.y&&this.y._getTooltipText(I,g),this.z&&this.z._getTooltipText(I,g)),this.c&&this.c._getTooltipText(I,g),I.filter((function(g,C){return I.indexOf(g)===C}))}},storyboard:function(g,I){null!=I&&(I=[].concat(I)),this.chart=g,this.categoryFields=I,this.autoplay=!0,this.frameDuration=3e3,this.storyLabel=null,this.onTick=null,this.fontSize="10px",this.fontFamily="sans-serif",this._frame=0,this._animationTimer=null,this._categories=[],this._cachedCategoryFields=[],this._orderRules=[],this._drawText=function(){var I=this,C=0;I.storyLabel||(I.chart.axes.forEach((function(g){"x"===g.position&&(C+=1)}),I),I.storyLabel=I.chart._group.append("text").attr("class","dimple-storyboard-label").attr("opacity",1).attr("x",I.chart._xPixels()+.01*I.chart._widthPixels()).attr("y",I.chart._yPixels()+(I.chart._heightPixels()/35>10?I.chart._heightPixels()/35:10)*(C>1?1.25:-1)).call((function(C){g.noFormats||C.style("font-family",I.fontFamily).style("font-size",I._getFontSize())}))),I.storyLabel.text(I.categoryFields.join("\\")+": "+I.getFrameValue())},this._getCategories=function(){return this._categoryFields!==this._cachedCategoryFields&&(this._categories=[],this.chart._getAllData().forEach((function(g){var I="";null!==this.categoryFields&&(this.categoryFields.forEach((function(C,A){A>0&&(I+="/"),I+=g[C]}),this),-1===this._categories.indexOf(I)&&(this._categories.push(I),this._categories.length))}),this),this._cachedCategoryFields=this._categoryFields),this._categories},this._getFontSize=function(){return this.fontSize&&"auto"!==this.fontSize.toString().toLowerCase()?isNaN(this.fontSize)?this.fontSize:this.fontSize+"px":(this.chart._heightPixels()/35>10?this.chart._heightPixels()/35:10)+"px"},this._goToFrameIndex=function(g){this._frame=g%this._getCategories().length,this.chart.draw(this.frameDuration/2)},this.addOrderRule=function(g,I){this._orderRules.push({ordering:g,desc:I})},this.getFrameValue=function(){var g=null;return this._frame>=0&&this._getCategories().length>this._frame&&(g=this._getCategories()[this._frame]),g},this.goToFrame=function(g){if(this._getCategories().length>0){var I=this._getCategories().indexOf(g);this._goToFrameIndex(I)}},this.pauseAnimation=function(){null!==this._animationTimer&&(clearInterval(this._animationTimer),this._animationTimer=null)},this.startAnimation=function(){null===this._animationTimer&&(null!==this.onTick&&this.onTick(this.getFrameValue()),this._animationTimer=setInterval(function(g){return function(){g._goToFrameIndex(g._frame+1),null!==g.onTick&&g.onTick(g.getFrameValue()),g._drawText(g.frameDuration/2)}}(this),this.frameDuration))},this.stopAnimation=function(){null!==this._animationTimer&&(clearInterval(this._animationTimer),this._animationTimer=null,this._frame=0)}}};QI.aggregateMethod.avg=function(g,I){return g.value=null===g.value||void 0===g.value?0:parseFloat(g.value),g.count=null===g.count||void 0===g.count?1:parseFloat(g.count),I.value=null===I.value||void 0===I.value?0:parseFloat(I.value),I.count=null===I.count||void 0===I.count?1:parseFloat(I.count),(g.value*g.count+I.value*I.count)/(g.count+I.count)},QI.aggregateMethod.count=function(g,I){return g.count=null===g.count||void 0===g.count?0:parseFloat(g.count),I.count=null===I.count||void 0===I.count?0:parseFloat(I.count),g.count+I.count},QI.aggregateMethod.max=function(g,I){return g.value=null===g.value||void 0===g.value?0:parseFloat(g.value),I.value=null===I.value||void 0===I.value?0:parseFloat(I.value),g.value>I.value?g.value:I.value},QI.aggregateMethod.min=function(g,I){return null===g.value?parseFloat(I.value):parseFloat(g.value)C&&i=2?X[i][V+"Field"][0]:"All"})),Y[c].data.push(X[i])}for(a&&Y.sort((function(g,I){return QI._arrayIndexCompare(a,g.key,I.key)})),i=0;i1&&V&&(I.x._hasCategories()?(Z.push({x:2*Z[Z.length-1].x-Z[Z.length-2].x,y:Z[Z.length-1].y}),F[Y[i].group][Z[Z.length-1][V]]=I[y]._origin):I.y._hasCategories()&&(Z=[{x:Z[0].x,y:2*Z[0].y-Z[1].y}].concat(Z),F[Y[i].group][Z[0][V]]=I[y]._origin,Y[i].points=Z))}for(m in F)if(Object.prototype.hasOwnProperty.call(F,m)){for(h in M[m]=[],F[m])Object.prototype.hasOwnProperty.call(F[m],h)&&M[m].push(parseFloat(h));M[m].sort(D)}for(i=0;i0)for(e=0,l=0;e=Z[0][V]&&M[G][e]<=Z[Z.length-1][V]&&((r={})[V]=M[G][e],r[y]=F[G][M[G][e]],b.push(r),Z[l][V]>M[G][e]?J.push(r):(J.push(Z[l]),F[Y[i].group][M[G][e]]=Z[l][y],l+=1));else if(I._orderRules&&I._orderRules.length>0)J=Z.concat(Z[0]);else{Z=Z.sort(L),J.push(Z[0]),p=0;do{p=z(Z,J,p)}while(J.length<=Z.length&&(J[0].x!==J[J.length-1].x||J[0].y!==J[J.length-1].y))}b=b.reverse(),u=k(A,"_previousOrigin")(J),B=k("step-after"===A?"step-before":"step-before"===A?"step-after":A,"_previousOrigin")(b),W=-1===(w=k("linear","_previousOrigin")(J)).indexOf("L")?void 0:w.indexOf("L"),Y[i].entry=u+(B&&B.length>0?"L"+B.substring(1):"")+(w&&w.length>0?"L"+w.substring(1,W):0),u=k(A)(J),B=k("step-after"===A?"step-before":"step-before"===A?"step-after":A)(b),W=-1===(w=k("linear")(J)).indexOf("L")?void 0:w.indexOf("L"),Y[i].update=u+(B&&B.length>0?"L"+B.substring(1):"")+(w&&w.length>0?"L"+w.substring(1,W):0),u=k(A,"_origin")(J),B=k("step-after"===A?"step-before":"step-before"===A?"step-after":A,"_origin")(b),W=-1===(w=k("linear","_origin")(J)).indexOf("L")?void 0:w.indexOf("L"),Y[i].exit=u+(B&&B.length>0?"L"+B.substring(1):"")+(w&&w.length>0?"L"+w.substring(1,W):0),Y[i].color=g.getColor(Y[i].key.length>0?Y[i].key[Y[i].key.length-1]:"All"),Y[i].css=g.getClass(Y[i].key.length>0?Y[i].key[Y[i].key.length-1]:"All")}g._tooltipGroup&&g._tooltipGroup.remove(),d=(R=I.shapes?I.shapes.data(Y,(function(g){return g.key})):I._group.selectAll("."+N).data(Y,(function(g){return g.key}))).enter().append("path").attr("id",(function(g){return QI._createClass([g.key])})).attr("class",(function(I){return N+" dimple-line "+I.keyString+" "+g.customClassList.areaSeries+" "+I.css})).attr("d",(function(g){return g.entry})).call((function(C){g.noFormats||C.attr("opacity",(function(g){return K?1:g.color.opacity})).style("fill",(function(g){return K?"url(#"+QI._createClass(["fill-area-gradient-"+g.keyString])+")":g.color.fill})).style("stroke",(function(g){return K?"url(#"+QI._createClass(["stroke-area-gradient-"+g.keyString])+")":g.color.stroke})).style("stroke-width",I.lineWeight)})).each((function(g){g.markerData=g.data,S(g,this)})),o=g._handleTransition(R.merge(d),C,g).attr("d",(function(g){return g.update})).each((function(g){g.markerData=g.data,S(g,this)})),n=g._handleTransition(R.exit(),C,g).attr("d",(function(g){return g.exit})).each((function(g){g.markerData=[],S(g,this)})),QI._postDrawHandling(I,o,n,C),I.shapes=I._group.selectAll("."+N)}},QI.plot.bar={stacked:!0,grouped:!1,supportedAxes:["x","y","c"],draw:function(g,I,C){var A,i,e,l=I._positionData,t=null,s=["dimple-series-"+g.series.indexOf(I),"dimple-bar"],c=!I._isStacked()&&I.x._hasMeasure(),d=!I._isStacked()&&I.y._hasMeasure(),o="none";I.x._hasCategories()&&I.y._hasCategories()?o="both":I.x._hasCategories()?o="x":I.y._hasCategories()&&(o="y"),g._tooltipGroup&&g._tooltipGroup.remove(),A=(t=I.shapes?I.shapes.data(l,(function(g){return g.key})):I._group.selectAll("."+s.join(".")).data(l,(function(g){return g.key}))).enter().append("rect").attr("id",(function(g){return QI._createClass([g.key])})).attr("class",(function(I){var C=[];return C=(C=(C=C.concat(I.aggField)).concat(I.xField)).concat(I.yField),s.join(" ")+" "+QI._createClass(C)+" "+g.customClassList.barSeries+" "+QI._helpers.css(I,g)})).attr("x",(function(C){var A=I.x._previousOrigin;return"x"===o?A=QI._helpers.x(C,g,I):"both"===o&&(A=QI._helpers.cx(C,g,I)),A})).attr("y",(function(C){var A=I.y._previousOrigin;return"y"===o?A=QI._helpers.y(C,g,I):"both"===o&&(A=QI._helpers.cy(C,g,I)),A})).attr("width",(function(C){return"x"===o?QI._helpers.width(C,g,I):0})).attr("height",(function(C){return"y"===o?QI._helpers.height(C,g,I):0})).on("mouseover",(function(C){QI._showBarTooltip(C,this,g,I)})).on("mouseleave",(function(C){QI._removeTooltip(C,this,g,I)})).call((function(C){g.noFormats||C.attr("opacity",(function(C){return QI._helpers.opacity(C,g,I)})).style("fill",(function(C){return QI._helpers.fill(C,g,I)})).style("stroke",(function(C){return QI._helpers.stroke(C,g,I)}))})),i=g._handleTransition(t.merge(A),C,g,I).attr("x",(function(C){return c?QI._helpers.cx(C,g,I)-I.x.floatingBarWidth/2:QI._helpers.x(C,g,I)})).attr("y",(function(C){return d?QI._helpers.cy(C,g,I)-I.y.floatingBarWidth/2:QI._helpers.y(C,g,I)})).attr("width",(function(C){return c?I.x.floatingBarWidth:QI._helpers.width(C,g,I)})).attr("height",(function(C){return d?I.y.floatingBarWidth:QI._helpers.height(C,g,I)})).call((function(C){g.noFormats||C.attr("fill",(function(C){return QI._helpers.fill(C,g,I)})).attr("stroke",(function(C){return QI._helpers.stroke(C,g,I)}))})),e=g._handleTransition(t.exit(),C,g,I).attr("x",(function(C){var A=I.x._origin;return"x"===o?A=QI._helpers.x(C,g,I):"both"===o&&(A=QI._helpers.cx(C,g,I)),A})).attr("y",(function(C){var A=I.y._origin;return"y"===o?A=QI._helpers.y(C,g,I):"both"===o&&(A=QI._helpers.cy(C,g,I)),A})).attr("width",(function(C){return"x"===o?QI._helpers.width(C,g,I):0})).attr("height",(function(C){return"y"===o?QI._helpers.height(C,g,I):0})),QI._postDrawHandling(I,i,e,C),I.shapes=I._group.selectAll("."+s.join("."))}},QI.plot.bubble={stacked:!1,grouped:!1,supportedAxes:["x","y","z","c"],draw:function(g,I,C){var A,i,e,l=I._positionData,t=null,s=["dimple-series-"+g.series.indexOf(I),"dimple-bubble"];g._tooltipGroup&&g._tooltipGroup.remove(),A=(t=I.shapes?I.shapes.data(l,(function(g){return g.key})):I._group.selectAll("."+s.join(".")).data(l,(function(g){return g.key}))).enter().append("circle").attr("id",(function(g){return QI._createClass([g.key])})).attr("class",(function(I){var C=[];return C=(C=(C=(C=C.concat(I.aggField)).concat(I.xField)).concat(I.yField)).concat(I.zField),s.join(" ")+" "+QI._createClass(C)+" "+g.customClassList.bubbleSeries+" "+QI._helpers.css(I,g)})).attr("cx",(function(C){return I.x._hasCategories()?QI._helpers.cx(C,g,I):I.x._previousOrigin})).attr("cy",(function(C){return I.y._hasCategories()?QI._helpers.cy(C,g,I):I.y._previousOrigin})).attr("r",0).on("mouseover",(function(C){QI._showPointTooltip(C,this,g,I)})).on("mouseleave",(function(C){QI._removeTooltip(C,this,g,I)})).call((function(C){g.noFormats||C.attr("opacity",(function(C){return QI._helpers.opacity(C,g,I)})).style("fill",(function(C){return QI._helpers.fill(C,g,I)})).style("stroke",(function(C){return QI._helpers.stroke(C,g,I)}))})),i=g._handleTransition(t.merge(A),C,g,I).attr("cx",(function(C){return QI._helpers.cx(C,g,I)})).attr("cy",(function(C){return QI._helpers.cy(C,g,I)})).attr("r",(function(C){return QI._helpers.r(C,g,I)})).call((function(C){g.noFormats||C.attr("fill",(function(C){return QI._helpers.fill(C,g,I)})).attr("stroke",(function(C){return QI._helpers.stroke(C,g,I)}))})),e=g._handleTransition(t.exit(),C,g,I).attr("r",0).attr("cx",(function(C){return I.x._hasCategories()?QI._helpers.cx(C,g,I):I.x._origin})).attr("cy",(function(C){return I.y._hasCategories()?QI._helpers.cy(C,g,I):I.y._origin})),QI._postDrawHandling(I,i,e,C),I.shapes=I._group.selectAll("."+s.join("."))}},QI.plot.line={stacked:!1,grouped:!0,supportedAxes:["x","y","c"],draw:function(g,I,C){var A,i,e,l,t,s,c,d,o,n,a,Z=I._positionData,b=[],r=null,m="dimple-series-"+g.series.indexOf(I),h=I.x._hasCategories()||I.y._hasCategories()?0:1,G=!1,u=function(A,i){var e;QI._drawMarkers(A,g,I,C,m,G,(function(g,I,C,A){XI.select(I).style("opacity",1),QI._showPointTooltip(g,I,C,A)}),(e=A,function(g,I,C,A){XI.select(I).style("opacity",A.lineMarkers||e.data.length<2?QI._helpers.opacity(g,C,A):0),QI._removeTooltip(g,I,C,A)}),i)},B=function(C,A){var i;return"step"===I.interpolation&&I[C]._hasCategories()?(I.barGap=0,I.clusterBarGap=0,i=QI._helpers[C](A,g,I)+("y"===C?QI._helpers.height(A,g,I):0)):i=QI._helpers["c"+C](A,g,I),parseFloat(i.toFixed(1))},w=function(g,C){var A=XI.line().x((function(g){return I.x._hasCategories()||!C?g.x:I.x[C]})).y((function(g){return I.y._hasCategories()||!C?g.y:I.y[C]}));return QI._interpolate(A,g),A};for(A="step"===I.interpolation?"step-after":I.interpolation,a=QI._getSeriesOrder(I.data||g.data,I),I.c&&(I.x._hasCategories()&&I.y._hasMeasure()||I.y._hasCategories()&&I.x._hasMeasure())&&(G=!0),i=0;i1&&(I.x._hasCategories()?b[i].points.push({x:2*b[i].points[b[i].points.length-1].x-b[i].points[b[i].points.length-2].x,y:b[i].points[b[i].points.length-1].y}):I.y._hasCategories()&&(b[i].points=[{x:b[i].points[0].x,y:2*b[i].points[0].y-b[i].points[1].y}].concat(b[i].points))),b&&b[i]&&b[i].points&&1===b[i].points.length&&b[i].points.push({x:b[i].points[0].x,y:b[i].points[0].y}),b[i].entry=w(A,"_previousOrigin")(b[i].points),b[i].update=w(A)(b[i].points),b[i].exit=w(A,"_origin")(b[i].points),b[i].color=g.getColor(b[i].key.length>0?b[i].key[b[i].key.length-1]:"All"),b[i].css=g.getClass(b[i].key.length>0?b[i].key[b[i].key.length-1]:"All")}g._tooltipGroup&&g._tooltipGroup.remove(),d=(r=I.shapes?I.shapes.data(b,(function(g){return g.key})):I._group.selectAll("."+m).data(b,(function(g){return g.key}))).enter().append("path").attr("id",(function(g){return QI._createClass([g.key])})).attr("class",(function(I){return m+" dimple-line "+I.keyString+" "+g.customClassList.lineSeries+" "+I.css})).attr("d",(function(g){return g.entry})).call((function(C){g.noFormats||C.attr("opacity",(function(g){return G?1:g.color.opacity})).style("fill","none").style("stroke",(function(g){return G?"url(#"+QI._createClass(["fill-line-gradient-"+g.keyString])+")":g.color.stroke})).style("stroke-width",I.lineWeight)})).each((function(g){g.markerData=g.data,u(g,this)})),o=g._handleTransition(r.merge(d),C,g).attr("d",(function(g){return g.update})).each((function(g){g.markerData=g.data,u(g,this)})),n=g._handleTransition(r.exit(),C,g).attr("d",(function(g){return g.exit})).each((function(g){g.markerData=[],u(g,this)})),QI._postDrawHandling(I,o,n,C),I.shapes=I._group.selectAll("."+m)}},QI.plot.pie={stacked:!1,grouped:!1,supportedAxes:["x","y","c","z","p"],draw:function(g,I,C){var A,i,e,l=I._positionData,t=null,s=["dimple-series-"+g.series.indexOf(I),"dimple-pie"],c=function(C){return I.x&&I.y?QI._helpers.r(C,g,I):g._widthPixels()0?A.attrTween("d",a):A.attr("d",n),g.noFormats||A.attr("fill",(function(C){return QI._helpers.fill(C,g,I)})).attr("stroke",(function(C){return QI._helpers.stroke(C,g,I)}))})).attr("transform",Z(!1)),e=g._handleTransition(t.exit(),C,g,I).attr("transform",Z(!0)).attr("d",n),QI._postDrawHandling(I,i,e,C),I.shapes=I._group.selectAll("."+s.join("."))}},QI._addGradient=function(g,I,C,A,i,e,l){var t=[].concat(g),s=i.svg.select("#"+QI._createClass([I])),c=[],d=C.position+"Field",o=!0,n=[];A.forEach((function(g){-1===c.indexOf(g[d])&&g.aggField.join("_")===t.join("_")&&c.push(g[d])}),this),c=c.sort((function(g,I){return C._scale(g)-C._scale(I)})),null===s.node()&&(o=!1,s=i.svg.append("defs").append("linearGradient").attr("id",QI._createClass([I])).attr("gradientUnits","userSpaceOnUse").attr("x1","x"===C.position?C._scale(c[0])+i._widthPixels()/c.length/2:0).attr("y1","y"===C.position?C._scale(c[0])-i._heightPixels()/c.length/2:0).attr("x2","x"===C.position?C._scale(c[c.length-1])+i._widthPixels()/c.length/2:0).attr("y2","y"===C.position?C._scale(c[c.length-1])-i._heightPixels()/c.length/2:0)),c.forEach((function(g,I){var C={},i=0;for(i=0;i=65&&I<=90&&(C=g.toLowerCase()),C},g.length>0)for(I=0;I0?g.aggField[g.aggField.length-1]:"All");return C.x._hasCategories()&&(A=A.concat(g.xField)),C.y._hasCategories()&&(A=A.concat(g.yField)),QI._createClass(A)+" "+n.join(" ")+" "+I.customClassList.lineMarker+" "+i})).on("mouseover",(function(g){l(g,this,I,C)})).on("mouseleave",(function(g){t(g,this,I,C)})).attr("cx",(function(g){return C.x._hasCategories()?QI._helpers.cx(g,I,C):C.x._previousOrigin})).attr("cy",(function(g){return C.y._hasCategories()?QI._helpers.cy(g,I,C):C.y._previousOrigin})).attr("r",0).attr("opacity",C.lineMarkers||g.data.length<2?g.color.opacity:0).call((function(A){I.noFormats||A.attr("fill","white").style("stroke-width",C.lineWeight).attr("stroke",(function(A){return e?QI._helpers.fill(A,I,C):g.color.stroke}))})),I._handleTransition(c.merge(o),A,I).attr("cx",(function(g){return QI._helpers.cx(g,I,C)})).attr("cy",(function(g){return QI._helpers.cy(g,I,C)})).attr("r",2+C.lineWeight).attr("opacity",C.lineMarkers||g.data.length<2?g.color.opacity:0).call((function(A){I.noFormats||A.attr("fill","white").style("stroke-width",C.lineWeight).attr("stroke",(function(A){return e?QI._helpers.fill(A,I,C):g.color.stroke}))})),d=I._handleTransition(c.exit(),A,I).attr("cx",(function(g){return C.x._hasCategories()?QI._helpers.cx(g,I,C):C.x._origin})).attr("cy",(function(g){return C.y._hasCategories()?QI._helpers.cy(g,I,C):C.y._origin})).attr("r",0),0===A?d.remove():d.each("end",(function(){XI.select(this).remove()})),void 0!==C._markers&&null!==C._markers||(C._markers={}),C._markers[g.keyString]=c,QI._drawMarkerBacks(g,I,C,A,i,s)},QI._ease=function(g,I){if(g&&I&&"[object String]"===Object.prototype.toString.call(I)){switch(I){case"linear":I=XI.easeLinear;break;case"poly":I=XI.easePoly;break;case"quad":I=XI.easeQuad;break;case"cubic":I=XI.easeCubic;break;case"sin":I=XI.easeSin;break;case"exp":I=XI.easeExp;break;case"circle":I=XI.easeCircle;break;case"elastic":I=XI.easeElastic;break;case"back":I=XI.easeBack;break;case"bounce":I=XI.easeBounce}g.ease(I)}},QI._getOrderedList=function(g,I,C){var A,i=[],e=[],l=[].concat(I),t=[].concat(I),s=[];return null!=C&&(s=s.concat(C)),(s=s.concat({ordering:l,desc:!1})).forEach((function(I){var C,A=[],i=[];if("function"==typeof I.ordering){if(g&&g.length>0)for(C in g[0])Object.prototype.hasOwnProperty.call(g[0],C)&&-1===t.indexOf(C)&&t.push(C)}else if(I.ordering instanceof Array){for(C=0;C0&&Object.prototype.hasOwnProperty.call(g[0],I.ordering[C])&&i.push(I.ordering[C]),A.push(I.ordering[C]);i.length>A.length/2?t.concat(i):I.values=A}else t.push(I.ordering)}),this),A=QI._rollUp(g,l,t),s.length>=1&&(s.forEach((function(g){var I=null!==g.desc&&void 0!==g.desc&&g.desc,C=g.ordering,A=[],e=function(g){var I,C=0;for(I=0;I0?(g.values.forEach((function(g){A.push([].concat(g).join("|"))}),this),i.push((function(g,C){var i,e,t,s="",c="";for(t=0;t0&&(s+="|",c+="|"),s+=g[l[t]],c+=C[l[t]];return i=A.indexOf(s),e=A.indexOf(c),i=i<0?I?-1:A.length:i,e=e<0?I?-1:A.length:e,(I?-1:1)*(i-e)}))):[].concat(g.ordering).forEach((function(g){i.push((function(C,A){var i=0;return void 0!==C[g]&&void 0!==A[g]&&(i=function(g,I){var C=0,A=e(g),i=e(I);return isNaN(A)||isNaN(i)?isNaN(Date.parse(g[0]))||isNaN(Date.parse(I[0]))?g[0]I[0]&&(C=1):C=Date.parse(g[0])-Date.parse(I[0]):C=parseFloat(A)-parseFloat(i),C}([].concat(C[g]),[].concat(A[g]))),(I?-1:1)*i}))}))})),A.sort((function(g,I){for(var C=0,A=0;C0&&(null!==I.c&&void 0!==I.c&&I.c._hasMeasure()&&C.push({ordering:I.c.measure,desc:!0}),I.x._hasMeasure()&&C.push({ordering:I.x.measure,desc:!0}),I.y._hasMeasure()&&C.push({ordering:I.y.measure,desc:!0}),i=QI._getOrderedList(g,A,C)),i},QI._getSeriesSortPredicate=function(g,I,C){return function(A,i){var e=0;return I.x._hasCategories()&&(e=QI._helpers.cx(A,g,I)-QI._helpers.cx(i,g,I)),0===e&&I.y._hasCategories()&&(e=QI._helpers.cy(A,g,I)-QI._helpers.cy(i,g,I)),0===e&&C&&(e=QI._arrayIndexCompare(C,A.aggField,i.aggField)),e}},QI._helpers={cx:function(g,I,C){return null!==C.x.measure&&void 0!==C.x.measure?C.x._scale(g.cx):C.x._hasCategories()&&C.x.categoryFields.length>=2?C.x._scale(g.cx)+QI._helpers.xGap(I,C)+(g.xOffset+.5)*((I._widthPixels()/C.x._max-2*QI._helpers.xGap(I,C))*g.width):C.x._scale(g.cx)+I._widthPixels()/C.x._max/2},cy:function(g,I,C){return null!==C.y.measure&&void 0!==C.y.measure?C.y._scale(g.cy):null!==C.y.categoryFields&&void 0!==C.y.categoryFields&&C.y.categoryFields.length>=2?C.y._scale(g.cy)-I._heightPixels()/C.y._max+QI._helpers.yGap(I,C)+(g.yOffset+.5)*((I._heightPixels()/C.y._max-2*QI._helpers.yGap(I,C))*g.height):C.y._scale(g.cy)-I._heightPixels()/C.y._max/2},r:function(g,I,C){var A=0,i=1;return null===C.z||void 0===C.z?A=C.radius&&"auto"!==C.radius?C.radius:5:(C.radius&&"auto"!==C.radius&&C.radius>1&&(i=C.radius/C.z._scale(C.z._max)),A=C.z._hasMeasure()?C.z._scale(g.r)*i:C.z._scale(I._heightPixels()/100)*i),A},xGap:function(g,I){var C=0;return(null===I.x.measure||void 0===I.x.measure)&&I.barGap>0&&(C=g._widthPixels()/I.x._max*(I.barGap>.99?.99:I.barGap)/2),C},xClusterGap:function(g,I,C){var A=0;return null!==C.x.categoryFields&&void 0!==C.x.categoryFields&&C.x.categoryFields.length>=2&&C.clusterBarGap>0&&!C.x._hasMeasure()&&(A=g.width*(I._widthPixels()/C.x._max-2*QI._helpers.xGap(I,C))*(C.clusterBarGap>.99?.99:C.clusterBarGap)/2),A},yGap:function(g,I){var C=0;return(null===I.y.measure||void 0===I.y.measure)&&I.barGap>0&&(C=g._heightPixels()/I.y._max*(I.barGap>.99?.99:I.barGap)/2),C},yClusterGap:function(g,I,C){var A=0;return null!==C.y.categoryFields&&void 0!==C.y.categoryFields&&C.y.categoryFields.length>=2&&C.clusterBarGap>0&&!C.y._hasMeasure()&&(A=g.height*(I._heightPixels()/C.y._max-2*QI._helpers.yGap(I,C))*(C.clusterBarGap>.99?.99:C.clusterBarGap)/2),A},x:function(g,I,C){return C.x._hasTimeField()?C.x._scale(g.x)-QI._helpers.width(g,I,C)/2:null!==C.x.measure&&void 0!==C.x.measure?C.x._scale(g.x):C.x._scale(g.x)+QI._helpers.xGap(I,C)+g.xOffset*(QI._helpers.width(g,I,C)+2*QI._helpers.xClusterGap(g,I,C))+QI._helpers.xClusterGap(g,I,C)},y:function(g,I,C){return C.y._hasTimeField()?C.y._scale(g.y)-QI._helpers.height(g,I,C)/2:null!==C.y.measure&&void 0!==C.y.measure?C.y._scale(g.y):C.y._scale(g.y)-I._heightPixels()/C.y._max+QI._helpers.yGap(I,C)+g.yOffset*(QI._helpers.height(g,I,C)+2*QI._helpers.yClusterGap(g,I,C))+QI._helpers.yClusterGap(g,I,C)},width:function(g,I,C){return null!==C.x.measure&&void 0!==C.x.measure?Math.abs(C.x._scale(g.x<0?g.x-g.width:g.x+g.width)-C.x._scale(g.x)):C.x._hasTimeField()?C.x.floatingBarWidth:g.width*(I._widthPixels()/C.x._max-2*QI._helpers.xGap(I,C))-2*QI._helpers.xClusterGap(g,I,C)},height:function(g,I,C){return C.y._hasTimeField()?C.y.floatingBarWidth:null!==C.y.measure&&void 0!==C.y.measure?Math.abs(C.y._scale(g.y)-C.y._scale(g.y<=0?g.y+g.height:g.y-g.height)):g.height*(I._heightPixels()/C.y._max-2*QI._helpers.yGap(I,C))-2*QI._helpers.yClusterGap(g,I,C)},opacity:function(g,I,C){return null!==C.c&&void 0!==C.c?g.opacity:I.getColor(g.aggField.slice(-1)[0]).opacity},fill:function(g,I,C){return null!==C.c&&void 0!==C.c?g.fill:I.getColor(g.aggField.slice(-1)[0]).fill},stroke:function(g,I,C){return null!==C.c&&void 0!==C.c?g.stroke:I.getColor(g.aggField.slice(-1)[0]).stroke},css:function(g,I){return I.getClass(g.aggField.slice(-1)[0])}},QI._interpolate=function(g,I){if(g&&I){if("[object String]"===Object.prototype.toString.call(I))switch(I){case"linear":I=XI.curveLinear;break;case"linear-closed":I=XI.curveLinearClosed;break;case"step":I=XI.curveStep;break;case"step-before":I=XI.curveStepBefore;break;case"step-after":I=XI.curveStepAfter;break;case"basis":I=XI.curveBasis;break;case"basis-open":I=XI.curveBasisOpen;break;case"basis-closed":I=XI.curveBasisClosed;break;case"bundle":I=XI.curveBundle;break;case"cardinal":I=XI.curveCardinal;break;case"cardinal-open":I=XI.curveCardinalOpen;break;case"cardinal-closed":I=XI.curveCardinalClosed;break;case"monotone":I=XI.curveMonotoneX}g.curve(I)}},QI._parentHeight=function(g){var I=g.getBoundingClientRect().height;return(!I||I<0)&&(I=g.clientHeight),I},QI._parentWidth=function(g){var I=g.getBoundingClientRect().width;return(!I||I<0)&&(I=g.clientWidth),I},QI._parsePosition=function(g,I){var C=0;return g&&g.toString().split(",").forEach((function(A){A&&(isNaN(A)?"%"===A.slice(-1)?C+=I*(parseFloat(A.slice(0,A.length-1))/100):"px"===A.slice(-2)?C+=parseFloat(A.slice(0,A.length-2)):C=g:C+=parseFloat(A))}),this),C<0&&(C=I+C),C},QI._parseXPosition=function(g,I){return QI._parsePosition(g,QI._parentWidth(I))},QI._parseYPosition=function(g,I){return QI._parsePosition(g,QI._parentHeight(I))},QI._postDrawHandling=function(g,I,C,A){0===A?(I.each((function(I,C){g.afterDraw&&g.afterDraw(this,I,C)})),C.remove()):(I.on("end",(function(I,C){g.afterDraw&&g.afterDraw(this,I,C)})),C.call((function(){g.shapes&&g.shapes.exit().remove()})))},QI._removeTooltip=function(g,I,C,A){C._tooltipGroup&&C._tooltipGroup.remove()},QI._rollUp=function(g,I,C){var A=[];return I=null!=I?[].concat(I):[],g.forEach((function(g){var i=-1,e={},l=!0;A.forEach((function(C,A){-1===i&&(l=!0,I.forEach((function(I){l=l&&g[I]===C[I]}),this),l&&(i=A))}),this),-1!==i?e=A[i]:(I.forEach((function(I){e[I]=g[I]}),this),A.push(e),i=A.length-1),C.forEach((function(C){-1===I.indexOf(C)&&(void 0===e[C]&&(e[C]=[]),e[C]=e[C].concat(g[C]))}),this),A[i]=e}),this),A},QI._showBarTooltip=function(g,I,C,A){var i,e,l,t,s,c,d=10,o=XI.select(I),n=o.node().getBBox().x,a=o.node().getBBox().y,Z=o.node().getBBox().width,b=o.node().getBBox().height,r=o.attr("opacity"),m=o.attr("fill"),h=A._dropLineOrigin(),G=XI.rgb(XI.rgb(m).r+.6*(255-XI.rgb(m).r),XI.rgb(m).g+.6*(255-XI.rgb(m).g),XI.rgb(m).b+.6*(255-XI.rgb(m).b)),u=XI.rgb(XI.rgb(m).r+.8*(255-XI.rgb(m).r),XI.rgb(m).g+.8*(255-XI.rgb(m).g),XI.rgb(m).b+.8*(255-XI.rgb(m).b)),B=A.getTooltipText(g),w=0,W=0,p=0,V=function(g,I){var A=o.node().getCTM(),i=C.svg.node().createSVGPoint();return i.x=g||0,i.y=I||0,i.matrixTransform(A)};null!==C._tooltipGroup&&void 0!==C._tooltipGroup&&C._tooltipGroup.remove(),C._tooltipGroup=C.svg.append("g"),A.p||(c=A._isStacked()?1:Z/2,A.x._hasCategories()||null===h.y||C._tooltipGroup.append("line").attr("class","dimple-tooltip-dropline "+C.customClassList.tooltipDropLine).attr("x1",nW?this.getBBox().width:W,p=this.getBBox().width>p?this.getBBox().height:p})),i.selectAll("text").attr("x",0).attr("y",(function(){return(w+=this.getBBox().height)-this.getBBox().height/2})),e.attr("x",-5).attr("y",-5).attr("height",Math.floor(w+5)-.5).attr("width",W+10).attr("rx",5).attr("ry",5).call((function(g){C.noFormats||g.style("fill",u).style("stroke",G).style("stroke-width",2).style("opacity",.95)})),V(n+Z+5+d+W).x0?(l=n-(15+W),t=a+b/2-(w-(p-5))/2):V(0,a+b+w+d+5).y0?l:d)+W0?l:d)+WG?this.getBBox().width:G,u=this.getBBox().width>u?this.getBBox().height:u})),i.selectAll("text").attr("x",0).attr("y",(function(){return(h+=this.getBBox().height)-this.getBBox().height/2})),e.attr("x",-5).attr("y",-5).attr("height",Math.floor(h+5)-.5).attr("width",G+10).attr("rx",5).attr("ry",5).call((function(g){C.noFormats||g.style("fill",m).style("stroke",r).style("stroke-width",2).style("opacity",.95)})),d+n+5+s+G0?(l=d-n-(15+G),t=o-(h-(u-5))/2):o+n+h+s+50?l:s)+G0?l:s)+G-1)&&A.push(g)}),this)),A},QI.getUniqueValues=function(g,I){var C=[];return null!=I&&(I=[].concat(I),g.forEach((function(g){var A="";I.forEach((function(I,C){C>0&&(A+="/"),A+=g[I]}),this),-1===C.indexOf(A)&&C.push(A)}),this)),C},QI.newSvg=function(g,I,C){var A=null;if(null==g&&(g="body"),(A=XI.select(g)).empty())throw"The '"+g+"' selector did not match any elements. Please prefix with '#' to select by id or '.' to select by class";return A.append("svg").attr("width",I).attr("height",C)};const jI=(g,I,C)=>{null!=g&&void 0!==g||(g="body");const A=XI.select(g);if(A.empty())throw"The '"+g+"' selector did not match any elements. Please prefix with '#' to select by id or '.' to select by class";return A.append("svg").attr("width",I).attr("height",C)},OI=Object.freeze(Object.defineProperty({__proto__:null,renderPptx:g=>{if("undefined"!=typeof window){const{pptx:I,resultElement:A,thumbElement:e,onError:l,onLoad:t}=g,s=document.createElement("div");s.setAttribute("class","r-preview-pptx-main"),A.innerHTML="",A.appendChild(s);let c=!1;return new Promise(((g,A)=>{const i={postMessage:postMessage};UI((g=>{i.postMessage=g}),(I=>{if(c)return;const i=document.createElement("div"),d=document.createElement("style");switch(I.type){case"slide":i.innerHTML=I.data,s.appendChild(i);break;case"pptx-thumb":e&&(null==e||e.setAttribute("src",`data:image/jpeg;base64,${I.data}`));break;case"slideSize":break;case"globalCSS":d.innerHTML=I.data,s.appendChild(d);break;case"Done":c=!0,function(g){for(let I=0;I{const I=()=>{const g=Math.max(...Array.from(s.children).filter((g=>"section"===g.nodeName)).map((g=>g.offsetWidth))),I=s.children[0].offsetWidth;s.setAttribute("style",`transform: scale(${I/g}),transform-origin': 'top left'`)};return I(),window.addEventListener("resize",I),i(document.getElementsByClassName("block")),i(document.getElementsByTagName("td")),g}))}function I(g){const I=[],C=[],A=[];return g.forEach(((g,i)=>{const e=g.key;A[i]=g.key,g.values.forEach(((A,i)=>{const l=g.xlabels[i];C[i]=g.xlabels[i],I.push({name:l,group:e,value:A.y})}))})),{data:I,xLabels:C,groupLabels:A}}function C(g){const C=g.chartID,A=g.chartType,i=g.chartData;let e=[];switch(A){case"lineChart":{const{data:g,xLabels:A,groupLabels:l}=I(i);e=g;const t=document.getElementById(C)||document.body,s=t&&jI(`#${C}`,t.style.width,t.style.height),c=new QI.chart(s,e),d=c.addCategoryAxis("x","name");d.addOrderRule(A),d.addGroupOrderRule(l),d.title=null;c.addMeasureAxis("y","value").title=null,c.addSeries("group",QI.plot.line),c.addLegend(60,10,500,20,"right"),c.draw();break}case"barChart":{const{data:g,xLabels:A,groupLabels:l}=I(i);e=g;const t=document.getElementById(C)||document.body,s=jI("#"+C,t.style.width,t.style.height),c=new QI.chart(s,e),d=c.addCategoryAxis("x",["name","group"]);d.addOrderRule(A),d.addGroupOrderRule(l),d.title=null;c.addMeasureAxis("y","value").title=null,c.addSeries("group",QI.plot.bar),c.addLegend(60,10,500,20,"right"),c.draw();break}case"pieChart":case"pie3DChart":{const{data:g,groupLabels:A}=I(i);e=g;const l=document.getElementById(C)||document.body,t=jI(`#${C}`,l.style.width,l.style.height),s=new QI.chart(t,e);s.addMeasureAxis("p","value").addOrderRule(A),s.addSeries("name",QI.plot.pie),s.addLegend(50,20,400,300,"left"),s.draw();break}case"areaChart":{const{data:g,xLabels:A,groupLabels:l}=I(i);e=g;const t=document.getElementById(C)||document.body,s=jI("#"+C,t.style.width,t.style.height),c=new QI.chart(s,e),d=c.addCategoryAxis("x","name");d.addOrderRule(A),d.addGroupOrderRule(l),d.title=null;c.addMeasureAxis("y","value").title=null,c.addSeries("group",QI.plot.area),c.addLegend(60,10,500,20,"right"),c.draw();break}case"scatterChart":for(let g=0;g{g.forEach((g=>{g.children.length>0&&A(Array.from(g.children)),Array.from(g.classList).includes(I)&&C.push(g)}))};return g.children.length>0&&A(Array.from(g.children)),C}function i(g){const I=Array.from(g);for(let C=0;C0){let I="",C="",A=0;const i=[];let l=0;const t=[];for(let s=0;sNumber(C)?(I=c,C=d,l++,i[l]=A,t[l]=c,A=1):c!==I&&Number(d){const A=C[0];if(parseInt(A.toString())>0)for(;g>=Number(A);g-=Number(A))I+=C[1];else I=I.replace(A.toString(),C[1])})),I}});var s;function c(g,I){g=Number(g)-1;let C="";return"upperCase"===I?C=((g/26>=1?String.fromCharCode(g/26+64):"")+String.fromCharCode(g%26+65)).toUpperCase():"lowerCase"===I&&(C=((g/26>=1?String.fromCharCode(g/26+64):"")+String.fromCharCode(g%26+65)).toLowerCase()),C}}},Symbol.toStringTag,{value:"Module"}));var EI="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function PI(g){return g&&g.__esModule&&Object.prototype.hasOwnProperty.call(g,"default")?g.default:g}function _I(g){throw new Error('Could not dynamically require "'+g+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var qI={exports:{}}; /*! JSZip v3.10.1 - A JavaScript class for generating and reading zip files (c) 2009-2016 Stuart Knightley Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip/main/LICENSE.markdown. JSZip uses the library pako released under the MIT license : https://github.com/nodeca/pako/blob/main/LICENSE */qI.exports=function g(I,C,A){function i(l,t){if(!C[l]){if(!I[l]){if(!t&&_I)return _I(l);if(e)return e(l,!0);var s=new Error("Cannot find module '"+l+"'");throw s.code="MODULE_NOT_FOUND",s}var c=C[l]={exports:{}};I[l][0].call(c.exports,(function(g){return i(I[l][1][g]||g)}),c,c.exports,g,I,C,A)}return C[l].exports}for(var e=_I,l=0;l>2,t=(3&I)<<4|C>>4,s=1>6:64,c=2>4,C=(15&l)<<4|(t=e.indexOf(g.charAt(c++)))>>2,A=(3&t)<<6|(s=e.indexOf(g.charAt(c++))),n[d++]=I,64!==t&&(n[d++]=C),64!==s&&(n[d++]=A);return n}},{"./support":30,"./utils":32}],2:[function(g,I,C){var A=g("./external"),i=g("./stream/DataWorker"),e=g("./stream/Crc32Probe"),l=g("./stream/DataLengthProbe");function t(g,I,C,A,i){this.compressedSize=g,this.uncompressedSize=I,this.crc32=C,this.compression=A,this.compressedContent=i}t.prototype={getContentWorker:function(){var g=new i(A.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new l("data_length")),I=this;return g.on("end",(function(){if(this.streamInfo.data_length!==I.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")})),g},getCompressedWorker:function(){return new i(A.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},t.createWorkerFrom=function(g,I,C){return g.pipe(new e).pipe(new l("uncompressedSize")).pipe(I.compressWorker(C)).pipe(new l("compressedSize")).withStreamInfo("compression",I)},I.exports=t},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(g,I,C){var A=g("./stream/GenericWorker");C.STORE={magic:"\0\0",compressWorker:function(){return new A("STORE compression")},uncompressWorker:function(){return new A("STORE decompression")}},C.DEFLATE=g("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(g,I,C){var A=g("./utils"),i=function(){for(var g,I=[],C=0;C<256;C++){g=C;for(var A=0;A<8;A++)g=1&g?3988292384^g>>>1:g>>>1;I[C]=g}return I}();I.exports=function(g,I){return void 0!==g&&g.length?"string"!==A.getTypeOf(g)?function(g,I,C,A){var e=i,l=A+C;g^=-1;for(var t=A;t>>8^e[255&(g^I[t])];return~g}(0|I,g,g.length,0):function(g,I,C,A){var e=i,l=A+C;g^=-1;for(var t=A;t>>8^e[255&(g^I.charCodeAt(t))];return~g}(0|I,g,g.length,0):0}},{"./utils":32}],5:[function(g,I,C){C.base64=!1,C.binary=!1,C.dir=!1,C.createFolders=!0,C.date=null,C.compression=null,C.compressionOptions=null,C.comment=null,C.unixPermissions=null,C.dosPermissions=null},{}],6:[function(g,I,C){var A=null;A="undefined"!=typeof Promise?Promise:g("lie"),I.exports={Promise:A}},{lie:37}],7:[function(g,I,C){var A="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Uint32Array,i=g("pako"),e=g("./utils"),l=g("./stream/GenericWorker"),t=A?"uint8array":"array";function s(g,I){l.call(this,"FlateWorker/"+g),this._pako=null,this._pakoAction=g,this._pakoOptions=I,this.meta={}}C.magic="\b\0",e.inherits(s,l),s.prototype.processChunk=function(g){this.meta=g.meta,null===this._pako&&this._createPako(),this._pako.push(e.transformTo(t,g.data),!1)},s.prototype.flush=function(){l.prototype.flush.call(this),null===this._pako&&this._createPako(),this._pako.push([],!0)},s.prototype.cleanUp=function(){l.prototype.cleanUp.call(this),this._pako=null},s.prototype._createPako=function(){this._pako=new i[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var g=this;this._pako.onData=function(I){g.push({data:I,meta:g.meta})}},C.compressWorker=function(g){return new s("Deflate",g)},C.uncompressWorker=function(){return new s("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(g,I,C){function A(g,I){var C,A="";for(C=0;C>>=8;return A}function i(g,I,C,i,l,d){var o,n,a=g.file,Z=g.compression,b=d!==t.utf8encode,r=e.transformTo("string",d(a.name)),m=e.transformTo("string",t.utf8encode(a.name)),h=a.comment,G=e.transformTo("string",d(h)),u=e.transformTo("string",t.utf8encode(h)),B=m.length!==a.name.length,w=u.length!==h.length,W="",p="",V="",y=a.dir,X=a.date,Y={crc32:0,compressedSize:0,uncompressedSize:0};I&&!C||(Y.crc32=g.crc32,Y.compressedSize=g.compressedSize,Y.uncompressedSize=g.uncompressedSize);var R=0;I&&(R|=8),b||!B&&!w||(R|=2048);var N,H,K,F=0,M=0;y&&(F|=16),"UNIX"===l?(M=798,F|=(N=a.unixPermissions,H=y,K=N,N||(K=H?16893:33204),(65535&K)<<16)):(M=20,F|=function(g){return 63&(g||0)}(a.dosPermissions)),o=X.getUTCHours(),o<<=6,o|=X.getUTCMinutes(),o<<=5,o|=X.getUTCSeconds()/2,n=X.getUTCFullYear()-1980,n<<=4,n|=X.getUTCMonth()+1,n<<=5,n|=X.getUTCDate(),B&&(p=A(1,1)+A(s(r),4)+m,W+="up"+A(p.length,2)+p),w&&(V=A(1,1)+A(s(G),4)+u,W+="uc"+A(V.length,2)+V);var J="";return J+="\n\0",J+=A(R,2),J+=Z.magic,J+=A(o,2),J+=A(n,2),J+=A(Y.crc32,4),J+=A(Y.compressedSize,4),J+=A(Y.uncompressedSize,4),J+=A(r.length,2),J+=A(W.length,2),{fileRecord:c.LOCAL_FILE_HEADER+J+r+W,dirRecord:c.CENTRAL_FILE_HEADER+A(M,2)+J+A(G.length,2)+"\0\0\0\0"+A(F,4)+A(i,4)+r+W+G}}var e=g("../utils"),l=g("../stream/GenericWorker"),t=g("../utf8"),s=g("../crc32"),c=g("../signature");function d(g,I,C,A){l.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=I,this.zipPlatform=C,this.encodeFileName=A,this.streamFiles=g,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}e.inherits(d,l),d.prototype.push=function(g){var I=g.meta.percent||0,C=this.entriesCount,A=this._sources.length;this.accumulate?this.contentBuffer.push(g):(this.bytesWritten+=g.data.length,l.prototype.push.call(this,{data:g.data,meta:{currentFile:this.currentFile,percent:C?(I+100*(C-A-1))/C:100}}))},d.prototype.openedSource=function(g){this.currentSourceOffset=this.bytesWritten,this.currentFile=g.file.name;var I=this.streamFiles&&!g.file.dir;if(I){var C=i(g,I,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:C.fileRecord,meta:{percent:0}})}else this.accumulate=!0},d.prototype.closedSource=function(g){this.accumulate=!1;var I,C=this.streamFiles&&!g.file.dir,e=i(g,C,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(e.dirRecord),C)this.push({data:(I=g,c.DATA_DESCRIPTOR+A(I.crc32,4)+A(I.compressedSize,4)+A(I.uncompressedSize,4)),meta:{percent:100}});else for(this.push({data:e.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},d.prototype.flush=function(){for(var g=this.bytesWritten,I=0;I=this.index;I--)C=(C<<8)+this.byteAt(I);return this.index+=g,C},readString:function(g){return A.transformTo("string",this.readData(g))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var g=this.readInt(4);return new Date(Date.UTC(1980+(g>>25&127),(g>>21&15)-1,g>>16&31,g>>11&31,g>>5&63,(31&g)<<1))}},I.exports=i},{"../utils":32}],19:[function(g,I,C){var A=g("./Uint8ArrayReader");function i(g){A.call(this,g)}g("../utils").inherits(i,A),i.prototype.readData=function(g){this.checkOffset(g);var I=this.data.slice(this.zero+this.index,this.zero+this.index+g);return this.index+=g,I},I.exports=i},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(g,I,C){var A=g("./DataReader");function i(g){A.call(this,g)}g("../utils").inherits(i,A),i.prototype.byteAt=function(g){return this.data.charCodeAt(this.zero+g)},i.prototype.lastIndexOfSignature=function(g){return this.data.lastIndexOf(g)-this.zero},i.prototype.readAndCheckSignature=function(g){return g===this.readData(4)},i.prototype.readData=function(g){this.checkOffset(g);var I=this.data.slice(this.zero+this.index,this.zero+this.index+g);return this.index+=g,I},I.exports=i},{"../utils":32,"./DataReader":18}],21:[function(g,I,C){var A=g("./ArrayReader");function i(g){A.call(this,g)}g("../utils").inherits(i,A),i.prototype.readData=function(g){if(this.checkOffset(g),0===g)return new Uint8Array(0);var I=this.data.subarray(this.zero+this.index,this.zero+this.index+g);return this.index+=g,I},I.exports=i},{"../utils":32,"./ArrayReader":17}],22:[function(g,I,C){var A=g("../utils"),i=g("../support"),e=g("./ArrayReader"),l=g("./StringReader"),t=g("./NodeBufferReader"),s=g("./Uint8ArrayReader");I.exports=function(g){var I=A.getTypeOf(g);return A.checkSupport(I),"string"!==I||i.uint8array?"nodebuffer"===I?new t(g):i.uint8array?new s(A.transformTo("uint8array",g)):new e(A.transformTo("array",g)):new l(g)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(g,I,C){C.LOCAL_FILE_HEADER="PK",C.CENTRAL_FILE_HEADER="PK",C.CENTRAL_DIRECTORY_END="PK",C.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK",C.ZIP64_CENTRAL_DIRECTORY_END="PK",C.DATA_DESCRIPTOR="PK\b"},{}],24:[function(g,I,C){var A=g("./GenericWorker"),i=g("../utils");function e(g){A.call(this,"ConvertWorker to "+g),this.destType=g}i.inherits(e,A),e.prototype.processChunk=function(g){this.push({data:i.transformTo(this.destType,g.data),meta:g.meta})},I.exports=e},{"../utils":32,"./GenericWorker":28}],25:[function(g,I,C){var A=g("./GenericWorker"),i=g("../crc32");function e(){A.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}g("../utils").inherits(e,A),e.prototype.processChunk=function(g){this.streamInfo.crc32=i(g.data,this.streamInfo.crc32||0),this.push(g)},I.exports=e},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(g,I,C){var A=g("../utils"),i=g("./GenericWorker");function e(g){i.call(this,"DataLengthProbe for "+g),this.propName=g,this.withStreamInfo(g,0)}A.inherits(e,i),e.prototype.processChunk=function(g){if(g){var I=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=I+g.data.length}i.prototype.processChunk.call(this,g)},I.exports=e},{"../utils":32,"./GenericWorker":28}],27:[function(g,I,C){var A=g("../utils"),i=g("./GenericWorker");function e(g){i.call(this,"DataWorker");var I=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,g.then((function(g){I.dataIsReady=!0,I.data=g,I.max=g&&g.length||0,I.type=A.getTypeOf(g),I.isPaused||I._tickAndRepeat()}),(function(g){I.error(g)}))}A.inherits(e,i),e.prototype.cleanUp=function(){i.prototype.cleanUp.call(this),this.data=null},e.prototype.resume=function(){return!!i.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,A.delay(this._tickAndRepeat,[],this)),!0)},e.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(A.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},e.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var g=null,I=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":g=this.data.substring(this.index,I);break;case"uint8array":g=this.data.subarray(this.index,I);break;case"array":case"nodebuffer":g=this.data.slice(this.index,I)}return this.index=I,this.push({data:g,meta:{percent:this.max?this.index/this.max*100:0}})},I.exports=e},{"../utils":32,"./GenericWorker":28}],28:[function(g,I,C){function A(g){this.name=g||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}A.prototype={push:function(g){this.emit("data",g)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(g){this.emit("error",g)}return!0},error:function(g){return!this.isFinished&&(this.isPaused?this.generatedError=g:(this.isFinished=!0,this.emit("error",g),this.previous&&this.previous.error(g),this.cleanUp()),!0)},on:function(g,I){return this._listeners[g].push(I),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(g,I){if(this._listeners[g])for(var C=0;C "+g:g}},I.exports=A},{}],29:[function(g,I,C){var A=g("../utils"),i=g("./ConvertWorker"),e=g("./GenericWorker"),l=g("../base64"),t=g("../support"),s=g("../external"),c=null;if(t.nodestream)try{c=g("../nodejs/NodejsStreamOutputAdapter")}catch(n){}function d(g,I){return new s.Promise((function(C,i){var e=[],t=g._internalType,s=g._outputType,c=g._mimeType;g.on("data",(function(g,C){e.push(g),I&&I(C)})).on("error",(function(g){e=[],i(g)})).on("end",(function(){try{var g=function(g,I,C){switch(g){case"blob":return A.newBlob(A.transformTo("arraybuffer",I),C);case"base64":return l.encode(I);default:return A.transformTo(g,I)}}(s,function(g,I){var C,A=0,i=null,e=0;for(C=0;C>>6:(C<65536?I[l++]=224|C>>>12:(I[l++]=240|C>>>18,I[l++]=128|C>>>12&63),I[l++]=128|C>>>6&63),I[l++]=128|63&C);return I}(g)},C.utf8decode=function(g){return i.nodebuffer?A.transformTo("nodebuffer",g).toString("utf-8"):function(g){var I,C,i,e,l=g.length,s=new Array(2*l);for(I=C=0;I>10&1023,s[C++]=56320|1023&i)}return s.length!==C&&(s.subarray?s=s.subarray(0,C):s.length=C),A.applyFromCharCode(s)}(g=A.transformTo(i.uint8array?"uint8array":"array",g))},A.inherits(c,l),c.prototype.processChunk=function(g){var I=A.transformTo(i.uint8array?"uint8array":"array",g.data);if(this.leftOver&&this.leftOver.length){if(i.uint8array){var e=I;(I=new Uint8Array(e.length+this.leftOver.length)).set(this.leftOver,0),I.set(e,this.leftOver.length)}else I=this.leftOver.concat(I);this.leftOver=null}var l=function(g,I){var C;for((I=I||g.length)>g.length&&(I=g.length),C=I-1;0<=C&&128==(192&g[C]);)C--;return C<0||0===C?I:C+t[g[C]]>I?C:I}(I),s=I;l!==I.length&&(i.uint8array?(s=I.subarray(0,l),this.leftOver=I.subarray(l,I.length)):(s=I.slice(0,l),this.leftOver=I.slice(l,I.length))),this.push({data:C.utf8decode(s),meta:g.meta})},c.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:C.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},C.Utf8DecodeWorker=c,A.inherits(d,l),d.prototype.processChunk=function(g){this.push({data:C.utf8encode(g.data),meta:g.meta})},C.Utf8EncodeWorker=d},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(g,I,C){var A=g("./support"),i=g("./base64"),e=g("./nodejsUtils"),l=g("./external");function t(g){return g}function s(g,I){for(var C=0;C>8;this.dir=!!(16&this.externalFileAttributes),0==g&&(this.dosPermissions=63&this.externalFileAttributes),3==g&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||"/"!==this.fileNameStr.slice(-1)||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var g=A(this.extraFields[1].value);this.uncompressedSize===i.MAX_VALUE_32BITS&&(this.uncompressedSize=g.readInt(8)),this.compressedSize===i.MAX_VALUE_32BITS&&(this.compressedSize=g.readInt(8)),this.localHeaderOffset===i.MAX_VALUE_32BITS&&(this.localHeaderOffset=g.readInt(8)),this.diskNumberStart===i.MAX_VALUE_32BITS&&(this.diskNumberStart=g.readInt(4))}},readExtraFields:function(g){var I,C,A,i=g.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});g.index+4>>6:(C<65536?I[l++]=224|C>>>12:(I[l++]=240|C>>>18,I[l++]=128|C>>>12&63),I[l++]=128|C>>>6&63),I[l++]=128|63&C);return I},C.buf2binstring=function(g){return s(g,g.length)},C.binstring2buf=function(g){for(var I=new A.Buf8(g.length),C=0,i=I.length;C>10&1023,c[A++]=56320|1023&i)}return s(c,A)},C.utf8border=function(g,I){var C;for((I=I||g.length)>g.length&&(I=g.length),C=I-1;0<=C&&128==(192&g[C]);)C--;return C<0||0===C?I:C+l[g[C]]>I?C:I}},{"./common":41}],43:[function(g,I,C){I.exports=function(g,I,C,A){for(var i=65535&g,e=g>>>16&65535,l=0;0!==C;){for(C-=l=2e3>>1:g>>>1;I[C]=g}return I}();I.exports=function(g,I,C,i){var e=A,l=i+C;g^=-1;for(var t=i;t>>8^e[255&(g^I[t])];return~g}},{}],46:[function(g,I,C){var A,i=g("../utils/common"),e=g("./trees"),l=g("./adler32"),t=g("./crc32"),s=g("./messages"),c=0,d=4,o=0,n=-2,a=-1,Z=4,b=2,r=8,m=9,h=286,G=30,u=19,B=2*h+1,w=15,W=3,p=258,V=p+W+1,y=42,X=113,Y=1,R=2,N=3,H=4;function K(g,I){return g.msg=s[I],I}function F(g){return(g<<1)-(4g.avail_out&&(C=g.avail_out),0!==C&&(i.arraySet(g.output,I.pending_buf,I.pending_out,C,g.next_out),g.next_out+=C,I.pending_out+=C,g.total_out+=C,g.avail_out-=C,I.pending-=C,0===I.pending&&(I.pending_out=0))}function S(g,I){e._tr_flush_block(g,0<=g.block_start?g.block_start:-1,g.strstart-g.block_start,I),g.block_start=g.strstart,J(g.strm)}function f(g,I){g.pending_buf[g.pending++]=I}function k(g,I){g.pending_buf[g.pending++]=I>>>8&255,g.pending_buf[g.pending++]=255&I}function D(g,I){var C,A,i=g.max_chain_length,e=g.strstart,l=g.prev_length,t=g.nice_match,s=g.strstart>g.w_size-V?g.strstart-(g.w_size-V):0,c=g.window,d=g.w_mask,o=g.prev,n=g.strstart+p,a=c[e+l-1],Z=c[e+l];g.prev_length>=g.good_match&&(i>>=2),t>g.lookahead&&(t=g.lookahead);do{if(c[(C=I)+l]===Z&&c[C+l-1]===a&&c[C]===c[e]&&c[++C]===c[e+1]){e+=2,C++;do{}while(c[++e]===c[++C]&&c[++e]===c[++C]&&c[++e]===c[++C]&&c[++e]===c[++C]&&c[++e]===c[++C]&&c[++e]===c[++C]&&c[++e]===c[++C]&&c[++e]===c[++C]&&es&&0!=--i);return l<=g.lookahead?l:g.lookahead}function L(g){var I,C,A,e,s,c,d,o,n,a,Z=g.w_size;do{if(e=g.window_size-g.lookahead-g.strstart,g.strstart>=Z+(Z-V)){for(i.arraySet(g.window,g.window,Z,Z,0),g.match_start-=Z,g.strstart-=Z,g.block_start-=Z,I=C=g.hash_size;A=g.head[--I],g.head[I]=Z<=A?A-Z:0,--C;);for(I=C=Z;A=g.prev[--I],g.prev[I]=Z<=A?A-Z:0,--C;);e+=Z}if(0===g.strm.avail_in)break;if(c=g.strm,d=g.window,o=g.strstart+g.lookahead,a=void 0,(n=e)<(a=c.avail_in)&&(a=n),C=0===a?0:(c.avail_in-=a,i.arraySet(d,c.input,c.next_in,a,o),1===c.state.wrap?c.adler=l(c.adler,d,a,o):2===c.state.wrap&&(c.adler=t(c.adler,d,a,o)),c.next_in+=a,c.total_in+=a,a),g.lookahead+=C,g.lookahead+g.insert>=W)for(s=g.strstart-g.insert,g.ins_h=g.window[s],g.ins_h=(g.ins_h<=W&&(g.ins_h=(g.ins_h<=W)if(A=e._tr_tally(g,g.strstart-g.match_start,g.match_length-W),g.lookahead-=g.match_length,g.match_length<=g.max_lazy_match&&g.lookahead>=W){for(g.match_length--;g.strstart++,g.ins_h=(g.ins_h<=W&&(g.ins_h=(g.ins_h<=W&&g.match_length<=g.prev_length){for(i=g.strstart+g.lookahead-W,A=e._tr_tally(g,g.strstart-1-g.prev_match,g.prev_length-W),g.lookahead-=g.prev_length-1,g.prev_length-=2;++g.strstart<=i&&(g.ins_h=(g.ins_h<g.pending_buf_size-5&&(C=g.pending_buf_size-5);;){if(g.lookahead<=1){if(L(g),0===g.lookahead&&I===c)return Y;if(0===g.lookahead)break}g.strstart+=g.lookahead,g.lookahead=0;var A=g.block_start+C;if((0===g.strstart||g.strstart>=A)&&(g.lookahead=g.strstart-A,g.strstart=A,S(g,!1),0===g.strm.avail_out))return Y;if(g.strstart-g.block_start>=g.w_size-V&&(S(g,!1),0===g.strm.avail_out))return Y}return g.insert=0,I===d?(S(g,!0),0===g.strm.avail_out?N:H):(g.strstart>g.block_start&&(S(g,!1),g.strm.avail_out),Y)})),new T(4,4,8,4,z),new T(4,5,16,8,z),new T(4,6,32,32,z),new T(4,4,16,16,v),new T(8,16,32,32,v),new T(8,16,128,128,v),new T(8,32,128,256,v),new T(32,128,258,1024,v),new T(32,258,258,4096,v)],C.deflateInit=function(g,I){return j(g,I,r,15,8,0)},C.deflateInit2=j,C.deflateReset=Q,C.deflateResetKeep=U,C.deflateSetHeader=function(g,I){return g&&g.state?2!==g.state.wrap?n:(g.state.gzhead=I,o):n},C.deflate=function(g,I){var C,i,l,s;if(!g||!g.state||5>8&255),f(i,i.gzhead.time>>16&255),f(i,i.gzhead.time>>24&255),f(i,9===i.level?2:2<=i.strategy||i.level<2?4:0),f(i,255&i.gzhead.os),i.gzhead.extra&&i.gzhead.extra.length&&(f(i,255&i.gzhead.extra.length),f(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(g.adler=t(g.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=69):(f(i,0),f(i,0),f(i,0),f(i,0),f(i,0),f(i,9===i.level?2:2<=i.strategy||i.level<2?4:0),f(i,3),i.status=X);else{var a=r+(i.w_bits-8<<4)<<8;a|=(2<=i.strategy||i.level<2?0:i.level<6?1:6===i.level?2:3)<<6,0!==i.strstart&&(a|=32),a+=31-a%31,i.status=X,k(i,a),0!==i.strstart&&(k(i,g.adler>>>16),k(i,65535&g.adler)),g.adler=1}if(69===i.status)if(i.gzhead.extra){for(l=i.pending;i.gzindex<(65535&i.gzhead.extra.length)&&(i.pending!==i.pending_buf_size||(i.gzhead.hcrc&&i.pending>l&&(g.adler=t(g.adler,i.pending_buf,i.pending-l,l)),J(g),l=i.pending,i.pending!==i.pending_buf_size));)f(i,255&i.gzhead.extra[i.gzindex]),i.gzindex++;i.gzhead.hcrc&&i.pending>l&&(g.adler=t(g.adler,i.pending_buf,i.pending-l,l)),i.gzindex===i.gzhead.extra.length&&(i.gzindex=0,i.status=73)}else i.status=73;if(73===i.status)if(i.gzhead.name){l=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>l&&(g.adler=t(g.adler,i.pending_buf,i.pending-l,l)),J(g),l=i.pending,i.pending===i.pending_buf_size)){s=1;break}s=i.gzindexl&&(g.adler=t(g.adler,i.pending_buf,i.pending-l,l)),0===s&&(i.gzindex=0,i.status=91)}else i.status=91;if(91===i.status)if(i.gzhead.comment){l=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>l&&(g.adler=t(g.adler,i.pending_buf,i.pending-l,l)),J(g),l=i.pending,i.pending===i.pending_buf_size)){s=1;break}s=i.gzindexl&&(g.adler=t(g.adler,i.pending_buf,i.pending-l,l)),0===s&&(i.status=103)}else i.status=103;if(103===i.status&&(i.gzhead.hcrc?(i.pending+2>i.pending_buf_size&&J(g),i.pending+2<=i.pending_buf_size&&(f(i,255&g.adler),f(i,g.adler>>8&255),g.adler=0,i.status=X)):i.status=X),0!==i.pending){if(J(g),0===g.avail_out)return i.last_flush=-1,o}else if(0===g.avail_in&&F(I)<=F(C)&&I!==d)return K(g,-5);if(666===i.status&&0!==g.avail_in)return K(g,-5);if(0!==g.avail_in||0!==i.lookahead||I!==c&&666!==i.status){var Z=2===i.strategy?function(g,I){for(var C;;){if(0===g.lookahead&&(L(g),0===g.lookahead)){if(I===c)return Y;break}if(g.match_length=0,C=e._tr_tally(g,0,g.window[g.strstart]),g.lookahead--,g.strstart++,C&&(S(g,!1),0===g.strm.avail_out))return Y}return g.insert=0,I===d?(S(g,!0),0===g.strm.avail_out?N:H):g.last_lit&&(S(g,!1),0===g.strm.avail_out)?Y:R}(i,I):3===i.strategy?function(g,I){for(var C,A,i,l,t=g.window;;){if(g.lookahead<=p){if(L(g),g.lookahead<=p&&I===c)return Y;if(0===g.lookahead)break}if(g.match_length=0,g.lookahead>=W&&0g.lookahead&&(g.match_length=g.lookahead)}if(g.match_length>=W?(C=e._tr_tally(g,1,g.match_length-W),g.lookahead-=g.match_length,g.strstart+=g.match_length,g.match_length=0):(C=e._tr_tally(g,0,g.window[g.strstart]),g.lookahead--,g.strstart++),C&&(S(g,!1),0===g.strm.avail_out))return Y}return g.insert=0,I===d?(S(g,!0),0===g.strm.avail_out?N:H):g.last_lit&&(S(g,!1),0===g.strm.avail_out)?Y:R}(i,I):A[i.level].func(i,I);if(Z!==N&&Z!==H||(i.status=666),Z===Y||Z===N)return 0===g.avail_out&&(i.last_flush=-1),o;if(Z===R&&(1===I?e._tr_align(i):5!==I&&(e._tr_stored_block(i,0,0,!1),3===I&&(M(i.head),0===i.lookahead&&(i.strstart=0,i.block_start=0,i.insert=0))),J(g),0===g.avail_out))return i.last_flush=-1,o}return I!==d?o:i.wrap<=0?1:(2===i.wrap?(f(i,255&g.adler),f(i,g.adler>>8&255),f(i,g.adler>>16&255),f(i,g.adler>>24&255),f(i,255&g.total_in),f(i,g.total_in>>8&255),f(i,g.total_in>>16&255),f(i,g.total_in>>24&255)):(k(i,g.adler>>>16),k(i,65535&g.adler)),J(g),0=C.w_size&&(0===t&&(M(C.head),C.strstart=0,C.block_start=0,C.insert=0),a=new i.Buf8(C.w_size),i.arraySet(a,I,Z-C.w_size,C.w_size,0),I=a,Z=C.w_size),s=g.avail_in,c=g.next_in,d=g.input,g.avail_in=Z,g.next_in=0,g.input=I,L(C);C.lookahead>=W;){for(A=C.strstart,e=C.lookahead-(W-1);C.ins_h=(C.ins_h<>>=u=G>>>24,Z-=u,0==(u=G>>>16&255))y[e++]=65535&G;else{if(!(16&u)){if(!(64&u)){G=b[(65535&G)+(a&(1<>>=u,Z-=u),Z<15&&(a+=V[A++]<>>=u=G>>>24,Z-=u,!(16&(u=G>>>16&255))){if(!(64&u)){G=r[(65535&G)+(a&(1<>>=u,Z-=u,(u=e-l)>3,a&=(1<<(Z-=B<<3))-1,g.next_in=A,g.next_out=e,g.avail_in=A>>24&255)+(g>>>8&65280)+((65280&g)<<8)+((255&g)<<24)}function r(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new A.Buf16(320),this.work=new A.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function m(g){var I;return g&&g.state?(I=g.state,g.total_in=g.total_out=I.total=0,g.msg="",I.wrap&&(g.adler=1&I.wrap),I.mode=n,I.last=0,I.havedict=0,I.dmax=32768,I.head=null,I.hold=0,I.bits=0,I.lencode=I.lendyn=new A.Buf32(a),I.distcode=I.distdyn=new A.Buf32(Z),I.sane=1,I.back=-1,d):o}function h(g){var I;return g&&g.state?((I=g.state).wsize=0,I.whave=0,I.wnext=0,m(g)):o}function G(g,I){var C,A;return g&&g.state?(A=g.state,I<0?(C=0,I=-I):(C=1+(I>>4),I<48&&(I&=15)),I&&(I<8||15=l.wsize?(A.arraySet(l.window,I,C-l.wsize,l.wsize,0),l.wnext=0,l.whave=l.wsize):(i<(e=l.wsize-l.wnext)&&(e=i),A.arraySet(l.window,I,C-i,e,l.wnext),(i-=e)?(A.arraySet(l.window,I,C-i,i,0),l.wnext=i,l.whave=l.wsize):(l.wnext+=e,l.wnext===l.wsize&&(l.wnext=0),l.whave>>8&255,C.check=e(C.check,L,2,0),B=u=0,C.mode=2;break}if(C.flags=0,C.head&&(C.head.done=!1),!(1&C.wrap)||(((255&u)<<8)+(u>>8))%31){g.msg="incorrect header check",C.mode=30;break}if(8!=(15&u)){g.msg="unknown compression method",C.mode=30;break}if(B-=4,J=8+(15&(u>>>=4)),0===C.wbits)C.wbits=J;else if(J>C.wbits){g.msg="invalid window size",C.mode=30;break}C.dmax=1<>8&1),512&C.flags&&(L[0]=255&u,L[1]=u>>>8&255,C.check=e(C.check,L,2,0)),B=u=0,C.mode=3;case 3:for(;B<32;){if(0===h)break g;h--,u+=a[r++]<>>8&255,L[2]=u>>>16&255,L[3]=u>>>24&255,C.check=e(C.check,L,4,0)),B=u=0,C.mode=4;case 4:for(;B<16;){if(0===h)break g;h--,u+=a[r++]<>8),512&C.flags&&(L[0]=255&u,L[1]=u>>>8&255,C.check=e(C.check,L,2,0)),B=u=0,C.mode=5;case 5:if(1024&C.flags){for(;B<16;){if(0===h)break g;h--,u+=a[r++]<>>8&255,C.check=e(C.check,L,2,0)),B=u=0}else C.head&&(C.head.extra=null);C.mode=6;case 6:if(1024&C.flags&&(h<(y=C.length)&&(y=h),y&&(C.head&&(J=C.head.extra_len-C.length,C.head.extra||(C.head.extra=new Array(C.head.extra_len)),A.arraySet(C.head.extra,a,r,y,J)),512&C.flags&&(C.check=e(C.check,a,y,r)),h-=y,r+=y,C.length-=y),C.length))break g;C.length=0,C.mode=7;case 7:if(2048&C.flags){if(0===h)break g;for(y=0;J=a[r+y++],C.head&&J&&C.length<65536&&(C.head.name+=String.fromCharCode(J)),J&&y>9&1,C.head.done=!0),g.adler=C.check=0,C.mode=12;break;case 10:for(;B<32;){if(0===h)break g;h--,u+=a[r++]<>>=7&B,B-=7&B,C.mode=27;break}for(;B<3;){if(0===h)break g;h--,u+=a[r++]<>>=1)){case 0:C.mode=14;break;case 1:if(p(C),C.mode=20,6!==I)break;u>>>=2,B-=2;break g;case 2:C.mode=17;break;case 3:g.msg="invalid block type",C.mode=30}u>>>=2,B-=2;break;case 14:for(u>>>=7&B,B-=7&B;B<32;){if(0===h)break g;h--,u+=a[r++]<>>16^65535)){g.msg="invalid stored block lengths",C.mode=30;break}if(C.length=65535&u,B=u=0,C.mode=15,6===I)break g;case 15:C.mode=16;case 16:if(y=C.length){if(h>>=5,B-=5,C.ndist=1+(31&u),u>>>=5,B-=5,C.ncode=4+(15&u),u>>>=4,B-=4,286>>=3,B-=3}for(;C.have<19;)C.lens[z[C.have++]]=0;if(C.lencode=C.lendyn,C.lenbits=7,f={bits:C.lenbits},S=t(0,C.lens,0,19,C.lencode,0,C.work,f),C.lenbits=f.bits,S){g.msg="invalid code lengths set",C.mode=30;break}C.have=0,C.mode=19;case 19:for(;C.have>>16&255,H=65535&D,!((R=D>>>24)<=B);){if(0===h)break g;h--,u+=a[r++]<>>=R,B-=R,C.lens[C.have++]=H;else{if(16===H){for(k=R+2;B>>=R,B-=R,0===C.have){g.msg="invalid bit length repeat",C.mode=30;break}J=C.lens[C.have-1],y=3+(3&u),u>>>=2,B-=2}else if(17===H){for(k=R+3;B>>=R)),u>>>=3,B-=3}else{for(k=R+7;B>>=R)),u>>>=7,B-=7}if(C.have+y>C.nlen+C.ndist){g.msg="invalid bit length repeat",C.mode=30;break}for(;y--;)C.lens[C.have++]=J}}if(30===C.mode)break;if(0===C.lens[256]){g.msg="invalid code -- missing end-of-block",C.mode=30;break}if(C.lenbits=9,f={bits:C.lenbits},S=t(s,C.lens,0,C.nlen,C.lencode,0,C.work,f),C.lenbits=f.bits,S){g.msg="invalid literal/lengths set",C.mode=30;break}if(C.distbits=6,C.distcode=C.distdyn,f={bits:C.distbits},S=t(c,C.lens,C.nlen,C.ndist,C.distcode,0,C.work,f),C.distbits=f.bits,S){g.msg="invalid distances set",C.mode=30;break}if(C.mode=20,6===I)break g;case 20:C.mode=21;case 21:if(6<=h&&258<=G){g.next_out=m,g.avail_out=G,g.next_in=r,g.avail_in=h,C.hold=u,C.bits=B,l(g,W),m=g.next_out,Z=g.output,G=g.avail_out,r=g.next_in,a=g.input,h=g.avail_in,u=C.hold,B=C.bits,12===C.mode&&(C.back=-1);break}for(C.back=0;N=(D=C.lencode[u&(1<>>16&255,H=65535&D,!((R=D>>>24)<=B);){if(0===h)break g;h--,u+=a[r++]<>K)])>>>16&255,H=65535&D,!(K+(R=D>>>24)<=B);){if(0===h)break g;h--,u+=a[r++]<>>=K,B-=K,C.back+=K}if(u>>>=R,B-=R,C.back+=R,C.length=H,0===N){C.mode=26;break}if(32&N){C.back=-1,C.mode=12;break}if(64&N){g.msg="invalid literal/length code",C.mode=30;break}C.extra=15&N,C.mode=22;case 22:if(C.extra){for(k=C.extra;B>>=C.extra,B-=C.extra,C.back+=C.extra}C.was=C.length,C.mode=23;case 23:for(;N=(D=C.distcode[u&(1<>>16&255,H=65535&D,!((R=D>>>24)<=B);){if(0===h)break g;h--,u+=a[r++]<>K)])>>>16&255,H=65535&D,!(K+(R=D>>>24)<=B);){if(0===h)break g;h--,u+=a[r++]<>>=K,B-=K,C.back+=K}if(u>>>=R,B-=R,C.back+=R,64&N){g.msg="invalid distance code",C.mode=30;break}C.offset=H,C.extra=15&N,C.mode=24;case 24:if(C.extra){for(k=C.extra;B>>=C.extra,B-=C.extra,C.back+=C.extra}if(C.offset>C.dmax){g.msg="invalid distance too far back",C.mode=30;break}C.mode=25;case 25:if(0===G)break g;if(y=W-G,C.offset>y){if((y=C.offset-y)>C.whave&&C.sane){g.msg="invalid distance too far back",C.mode=30;break}X=y>C.wnext?(y-=C.wnext,C.wsize-y):C.wnext-y,y>C.length&&(y=C.length),Y=C.window}else Y=Z,X=m-C.offset,y=C.length;for(Gh?(u=f[k+o[p]],F[M+o[p]]):(u=96,0),a=1<>R)+(Z-=a)]=G<<24|u<<16|B,0!==Z;);for(a=1<>=1;if(0!==a?(K&=a-1,K+=a):K=0,p++,0==--J[W]){if(W===y)break;W=I[C+o[p]]}if(X>>7)]}function f(g,I){g.pending_buf[g.pending++]=255&I,g.pending_buf[g.pending++]=I>>>8&255}function k(g,I,C){g.bi_valid>b-C?(g.bi_buf|=I<>b-g.bi_valid,g.bi_valid+=C-b):(g.bi_buf|=I<>>=1,C<<=1,0<--I;);return C>>>1}function z(g,I,C){var A,i,e=new Array(Z+1),l=0;for(A=1;A<=Z;A++)e[A]=l=l+C[A-1]<<1;for(i=0;i<=I;i++){var t=g[2*i+1];0!==t&&(g[2*i]=L(e[t]++,t))}}function v(g){var I;for(I=0;I>1;1<=C;C--)U(g,e,C);for(i=s;C=g.heap[1],g.heap[1]=g.heap[g.heap_len--],U(g,e,1),A=g.heap[1],g.heap[--g.heap_max]=C,g.heap[--g.heap_max]=A,e[2*i]=e[2*C]+e[2*A],g.depth[i]=(g.depth[C]>=g.depth[A]?g.depth[C]:g.depth[A])+1,e[2*C+1]=e[2*A+1]=i,g.heap[1]=i++,U(g,e,1),2<=g.heap_len;);g.heap[--g.heap_max]=g.heap[1],function(g,I){var C,A,i,e,l,t,s=I.dyn_tree,c=I.max_code,d=I.stat_desc.static_tree,o=I.stat_desc.has_stree,n=I.stat_desc.extra_bits,b=I.stat_desc.extra_base,r=I.stat_desc.max_length,m=0;for(e=0;e<=Z;e++)g.bl_count[e]=0;for(s[2*g.heap[g.heap_max]+1]=0,C=g.heap_max+1;C>=7;A>>=1)if(1&C&&0!==g.dyn_ltree[2*I])return i;if(0!==g.dyn_ltree[18]||0!==g.dyn_ltree[20]||0!==g.dyn_ltree[26])return e;for(I=32;I>>3,(t=g.static_len+3+7>>>3)<=l&&(l=t)):l=t=C+5,C+4<=l&&-1!==I?_(g,I,C,A):4===g.strategy||t===l?(k(g,2+(A?1:0),3),Q(g,V,y)):(k(g,4+(A?1:0),3),function(g,I,C,A){var i;for(k(g,I-257,5),k(g,C-1,5),k(g,A-4,4),i=0;i>>8&255,g.pending_buf[g.d_buf+2*g.last_lit+1]=255&I,g.pending_buf[g.l_buf+g.last_lit]=255&C,g.last_lit++,0===I?g.dyn_ltree[2*C]++:(g.matches++,I--,g.dyn_ltree[2*(Y[C]+c+1)]++,g.dyn_dtree[2*S(I)]++),g.last_lit===g.lit_bufsize-1},C._tr_align=function(g){var I;k(g,2,3),D(g,m,V),16===(I=g).bi_valid?(f(I,I.bi_buf),I.bi_buf=0,I.bi_valid=0):8<=I.bi_valid&&(I.pending_buf[I.pending++]=255&I.bi_buf,I.bi_buf>>=8,I.bi_valid-=8)}},{"../utils/common":41}],53:[function(g,I,C){I.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(g,I,C){(function(g){!function(g,I){if(!g.setImmediate){var C,A,i,e,l=1,t={},s=!1,c=g.document,d=Object.getPrototypeOf&&Object.getPrototypeOf(g);d=d&&d.setTimeout?d:g,C="[object process]"==={}.toString.call(g.process)?function(g){process.nextTick((function(){n(g)}))}:function(){if(g.postMessage&&!g.importScripts){var I=!0,C=g.onmessage;return g.onmessage=function(){I=!1},g.postMessage("","*"),g.onmessage=C,I}}()?(e="setImmediate$"+Math.random()+"$",g.addEventListener?g.addEventListener("message",a,!1):g.attachEvent("onmessage",a),function(I){g.postMessage(e+I,"*")}):g.MessageChannel?((i=new MessageChannel).port1.onmessage=function(g){n(g.data)},function(g){i.port2.postMessage(g)}):c&&"onreadystatechange"in c.createElement("script")?(A=c.documentElement,function(g){var I=c.createElement("script");I.onreadystatechange=function(){n(g),I.onreadystatechange=null,A.removeChild(I),I=null},A.appendChild(I)}):function(g){setTimeout(n,0,g)},d.setImmediate=function(g){"function"!=typeof g&&(g=new Function(""+g));for(var I=new Array(arguments.length-1),A=0;Afunction(g,I){let C={name:I.attr(g,"name"),embedFontRefs:[]};for(let A of I.elements(g))switch(A.localName){case"family":C.family=I.attr(A,"val");break;case"altName":C.altName=I.attr(A,"val");break;case"embedRegular":case"embedBold":case"embedItalic":case"embedBoldItalic":C.embedFontRefs.push(aC(A,I))}return C}(g,I)))}function aC(g,I){return{id:I.attr(g,"id"),key:I.attr(g,"fontKey"),type:oC[g.localName]}}class ZC extends dC{parseXml(g){this.fonts=nC(g,this._package.xmlParser)}}function bC(g){let I=g.lastIndexOf("/")+1;return[0==I?"":g.substring(0,I),0==I?g:g.substring(I)]}function rC(g,I){try{const C="http://docx/";return new URL(g,C+I).toString().substring(C.length)}catch{return`${I}${g}`}}function mC(g,I){return g.reduce(((g,C)=>(g[I(C)]=C,g)),{})}function hC(g){return g&&"object"==typeof g&&!Array.isArray(g)}function GC(g,...I){if(!I.length)return g;const C=I.shift();if(hC(g)&&hC(C))for(const A in C)if(hC(C[A])){GC(g[A]??(g[A]={}),C[A])}else g[A]=C[A];return GC(g,...I)}function uC(g){return Array.isArray(g)?g:[g]}class BC{constructor(g,I){this._zip=g,this.options=I,this.xmlParser=new sC}get(g){return this._zip.files[function(g){return g.startsWith("/")?g.substr(1):g}(g)]}update(g,I){this._zip.file(g,I)}static async load(g,I){const C=await gC.loadAsync(g);return new BC(C,I)}save(g="blob"){return this._zip.generateAsync({type:g})}load(g,I="string"){var C;return(null==(C=this.get(g))?void 0:C.async(I))??Promise.resolve(null)}async loadRelationships(g=null){let I="_rels/.rels";if(null!=g){const[C,A]=bC(g);I=`${C}_rels/${A}.rels`}const C=await this.load(I);return C?(A=this.parseXmlDocument(C).firstElementChild,(i=this.xmlParser).elements(A).map((g=>({id:i.attr(g,"Id"),type:i.attr(g,"Type"),target:i.attr(g,"Target"),targetMode:i.attr(g,"TargetMode")})))):null;var A,i}parseXmlDocument(g){return function(g,I=!1){var C;I&&(g=g.replace(/<[?].*[?]>/,"")),g=65279===(C=g).charCodeAt(0)?C.substring(1):C;const A=(new DOMParser).parseFromString(g,"application/xml"),i=null==(e=A.getElementsByTagName("parsererror")[0])?void 0:e.textContent;var e;if(i)throw new Error(i);return A}(g,this.options.trimXmlDeclaration)}}class wC extends dC{constructor(g,I,C){super(g,I),this._documentParser=C}parseXml(g){this.body=this._documentParser.parseDocumentFile(g)}}function WC(g,I){return{type:I.attr(g,"val"),color:I.attr(g,"color"),size:I.lengthAttr(g,"sz",eC.Border),offset:I.lengthAttr(g,"space",eC.Point),frame:I.boolAttr(g,"frame"),shadow:I.boolAttr(g,"shadow")}}function pC(g,I){var C={};for(let A of I.elements(g))switch(A.localName){case"left":C.left=WC(A,I);break;case"top":C.top=WC(A,I);break;case"right":C.right=WC(A,I);break;case"bottom":C.bottom=WC(A,I)}return C}var VC,yC,XC,YC;function RC(g,I=cC){var C={};for(let A of I.elements(g))switch(A.localName){case"pgSz":C.pageSize={width:I.lengthAttr(A,"w"),height:I.lengthAttr(A,"h"),orientation:I.attr(A,"orient")};break;case"type":C.type=I.attr(A,"val");break;case"pgMar":C.pageMargins={left:I.lengthAttr(A,"left"),right:I.lengthAttr(A,"right"),top:I.lengthAttr(A,"top"),bottom:I.lengthAttr(A,"bottom"),header:I.lengthAttr(A,"header"),footer:I.lengthAttr(A,"footer"),gutter:I.lengthAttr(A,"gutter")};break;case"cols":C.columns=NC(A,I);break;case"headerReference":(C.headerRefs??(C.headerRefs=[])).push(KC(A,I));break;case"footerReference":(C.footerRefs??(C.footerRefs=[])).push(KC(A,I));break;case"titlePg":C.titlePage=I.boolAttr(A,"val",!0);break;case"pgBorders":C.pageBorders=pC(A,I);break;case"pgNumType":C.pageNumber=HC(A,I)}return C}function NC(g,I){return{numberOfColumns:I.intAttr(g,"num"),space:I.lengthAttr(g,"space"),separator:I.boolAttr(g,"sep"),equalWidth:I.boolAttr(g,"equalWidth",!0),columns:I.elements(g,"col").map((g=>({width:I.lengthAttr(g,"w"),space:I.lengthAttr(g,"space")})))}}function HC(g,I){return{chapSep:I.attr(g,"chapSep"),chapStyle:I.attr(g,"chapStyle"),format:I.attr(g,"fmt"),start:I.intAttr(g,"start")}}function KC(g,I){return{id:I.attr(g,"id"),type:I.attr(g,"type")}}function FC(g,I){let C={};for(let A of I.elements(g))MC(A,C,I);return C}function MC(g,I,C){return!!tC(g,I,C)}function JC(g,I){let C={};for(let A of I.elements(g))SC(A,C,I);return C}function SC(g,I,C){if(g.namespaceURI!=iC.wordml)return!1;if(tC(g,I,C))return!0;switch(g.localName){case"tabs":I.tabs=function(g,I){return I.elements(g,"tab").map((g=>({position:I.lengthAttr(g,"pos"),leader:I.attr(g,"leader"),style:I.attr(g,"val")})))}(g,C);break;case"sectPr":I.sectionProps=RC(g,C);break;case"numPr":I.numbering=function(g,I){var C={};for(let A of I.elements(g))switch(A.localName){case"numId":C.id=I.attr(A,"val");break;case"ilvl":C.level=I.intAttr(A,"val")}return C}(g,C);break;case"spacing":return I.lineSpacing=function(g,I){return{before:I.lengthAttr(g,"before"),after:I.lengthAttr(g,"after"),line:I.intAttr(g,"line"),lineRule:I.attr(g,"lineRule")}}(g,C),!1;case"textAlignment":return I.textAlignment=C.attr(g,"val"),!1;case"keepLines":I.keepLines=C.boolAttr(g,"val",!0);break;case"keepNext":I.keepNext=C.boolAttr(g,"val",!0);break;case"pageBreakBefore":I.pageBreakBefore=C.boolAttr(g,"val",!0);break;case"outlineLvl":I.outlineLevel=C.intAttr(g,"val");break;case"pStyle":I.styleName=C.attr(g,"val");break;case"rPr":I.runProps=FC(g,C);break;default:return!1}return!0}function fC(g,I){let C={id:I.attr(g,"numId"),overrides:[]};for(let A of I.elements(g))switch(A.localName){case"abstractNumId":C.abstractId=I.attr(A,"val");break;case"lvlOverride":C.overrides.push(LC(A,I))}return C}function kC(g,I){let C={id:I.attr(g,"abstractNumId"),levels:[]};for(let A of I.elements(g))switch(A.localName){case"name":C.name=I.attr(A,"val");break;case"multiLevelType":C.multiLevelType=I.attr(A,"val");break;case"numStyleLink":C.numberingStyleLink=I.attr(A,"val");break;case"styleLink":C.styleLink=I.attr(A,"val");break;case"lvl":C.levels.push(DC(A,I))}return C}function DC(g,I){let C={level:I.intAttr(g,"ilvl")};for(let A of I.elements(g))switch(A.localName){case"start":C.start=I.attr(A,"val");break;case"lvlRestart":C.restart=I.intAttr(A,"val");break;case"numFmt":C.format=I.attr(A,"val");break;case"lvlText":C.text=I.attr(A,"val");break;case"lvlJc":C.justification=I.attr(A,"val");break;case"lvlPicBulletId":C.bulletPictureId=I.attr(A,"val");break;case"pStyle":C.paragraphStyle=I.attr(A,"val");break;case"pPr":C.paragraphProps=JC(A,I);break;case"rPr":C.runProps=FC(A,I)}return C}function LC(g,I){let C={level:I.intAttr(g,"ilvl")};for(let A of I.elements(g))switch(A.localName){case"startOverride":C.start=I.intAttr(A,"val");break;case"lvl":C.numberingLevel=DC(A,I)}return C}function zC(g,I){var C=I.element(g,"pict"),A=C&&I.element(C,"shape"),i=A&&I.element(A,"imagedata");return i?{id:I.attr(g,"numPicBulletId"),referenceId:I.attr(i,"id"),style:I.attr(A,"style")}:null}(yC=VC||(VC={})).Continuous="continuous",yC.NextPage="nextPage",yC.NextColumn="nextColumn",yC.EvenPage="evenPage",yC.OddPage="oddPage";class vC extends dC{constructor(g,I,C){super(g,I),this._documentParser=C}parseXml(g){Object.assign(this,function(g,I){let C={numberings:[],abstractNumberings:[],bulletPictures:[]};for(let A of I.elements(g))switch(A.localName){case"num":C.numberings.push(fC(A,I));break;case"abstractNum":C.abstractNumberings.push(kC(A,I));break;case"numPicBullet":C.bulletPictures.push(zC(A,I))}return C}(g,this._package.xmlParser)),this.domNumberings=this._documentParser.parseNumberingFile(g)}}class TC extends dC{constructor(g,I,C){super(g,I),this._documentParser=C}parseXml(g){this.styles=this._documentParser.parseStylesFile(g)}}(YC=XC||(XC={})).Document="document",YC.Paragraph="paragraph",YC.Run="run",YC.Break="break",YC.NoBreakHyphen="noBreakHyphen",YC.Table="table",YC.Row="row",YC.Cell="cell",YC.Hyperlink="hyperlink",YC.Drawing="drawing",YC.Image="image",YC.Text="text",YC.Tab="tab",YC.Symbol="symbol",YC.BookmarkStart="bookmarkStart",YC.BookmarkEnd="bookmarkEnd",YC.Footer="footer",YC.Header="header",YC.FootnoteReference="footnoteReference",YC.EndnoteReference="endnoteReference",YC.Footnote="footnote",YC.Endnote="endnote",YC.SimpleField="simpleField",YC.ComplexField="complexField",YC.Instruction="instruction",YC.VmlPicture="vmlPicture",YC.MmlMath="mmlMath",YC.MmlMathParagraph="mmlMathParagraph",YC.MmlFraction="mmlFraction",YC.MmlFunction="mmlFunction",YC.MmlFunctionName="mmlFunctionName",YC.MmlNumerator="mmlNumerator",YC.MmlDenominator="mmlDenominator",YC.MmlRadical="mmlRadical",YC.MmlBase="mmlBase",YC.MmlDegree="mmlDegree",YC.MmlSuperscript="mmlSuperscript",YC.MmlSubscript="mmlSubscript",YC.MmlPreSubSuper="mmlPreSubSuper",YC.MmlSubArgument="mmlSubArgument",YC.MmlSuperArgument="mmlSuperArgument",YC.MmlNary="mmlNary",YC.MmlDelimiter="mmlDelimiter",YC.MmlRun="mmlRun",YC.MmlEquationArray="mmlEquationArray",YC.MmlLimit="mmlLimit",YC.MmlLimitLower="mmlLimitLower",YC.MmlMatrix="mmlMatrix",YC.MmlMatrixRow="mmlMatrixRow",YC.MmlBox="mmlBox",YC.MmlBar="mmlBar",YC.MmlGroupChar="mmlGroupChar",YC.VmlElement="vmlElement",YC.Inserted="inserted",YC.Deleted="deleted",YC.DeletedText="deletedText";class xC{constructor(){this.children=[],this.cssStyle={}}}class UC extends xC{constructor(){super(...arguments),this.type=XC.Header}}class QC extends xC{constructor(){super(...arguments),this.type=XC.Footer}}class jC extends dC{constructor(g,I,C){super(g,I),this._documentParser=C}parseXml(g){this.rootElement=this.createRootElement(),this.rootElement.children=this._documentParser.parseBodyElements(g)}}class OC extends jC{createRootElement(){return new UC}}class EC extends jC{createRootElement(){return new QC}}function PC(g){if(void 0!==g)return parseInt(g)}class _C extends dC{parseXml(g){this.props=function(g,I){const C={};for(let A of I.elements(g))switch(A.localName){case"Template":C.template=A.textContent;break;case"Pages":C.pages=PC(A.textContent);break;case"Words":C.words=PC(A.textContent);break;case"Characters":C.characters=PC(A.textContent);break;case"Application":C.application=A.textContent;break;case"Lines":C.lines=PC(A.textContent);break;case"Paragraphs":C.paragraphs=PC(A.textContent);break;case"Company":C.company=A.textContent;break;case"AppVersion":C.appVersion=A.textContent}return C}(g,this._package.xmlParser)}}class qC extends dC{parseXml(g){this.props=function(g,I){const C={};for(let A of I.elements(g))switch(A.localName){case"title":C.title=A.textContent;break;case"description":C.description=A.textContent;break;case"subject":C.subject=A.textContent;break;case"creator":C.creator=A.textContent;break;case"keywords":C.keywords=A.textContent;break;case"language":C.language=A.textContent;break;case"lastModifiedBy":C.lastModifiedBy=A.textContent;break;case"revision":A.textContent&&(C.revision=parseInt(A.textContent))}return C}(g,this._package.xmlParser)}}class $C{}function gA(g,I){var C={name:I.attr(g,"name"),colors:{}};for(let e of I.elements(g)){var A=I.element(e,"srgbClr"),i=I.element(e,"sysClr");A?C.colors[e.localName]=I.attr(A,"val"):i&&(C.colors[e.localName]=I.attr(i,"lastClr"))}return C}function IA(g,I){var C={name:I.attr(g,"name")};for(let A of I.elements(g))switch(A.localName){case"majorFont":C.majorFont=CA(A,I);break;case"minorFont":C.minorFont=CA(A,I)}return C}function CA(g,I){return{latinTypeface:I.elementAttr(g,"latin","typeface"),eaTypeface:I.elementAttr(g,"ea","typeface"),csTypeface:I.elementAttr(g,"cs","typeface")}}class AA extends dC{constructor(g,I){super(g,I)}parseXml(g){this.theme=function(g,I){var C=new $C,A=I.element(g,"themeElements");for(let i of I.elements(A))switch(i.localName){case"clrScheme":C.colorScheme=gA(i,I);break;case"fontScheme":C.fontScheme=IA(i,I)}return C}(g,this._package.xmlParser)}}class iA{}class eA extends iA{constructor(){super(...arguments),this.type=XC.Footnote}}class lA extends iA{constructor(){super(...arguments),this.type=XC.Endnote}}class tA extends dC{constructor(g,I,C){super(g,I),this._documentParser=C}}class sA extends tA{constructor(g,I,C){super(g,I,C)}parseXml(g){this.notes=this._documentParser.parseNotes(g,"footnote",eA)}}class cA extends tA{constructor(g,I,C){super(g,I,C)}parseXml(g){this.notes=this._documentParser.parseNotes(g,"endnote",lA)}}function dA(g,I){var C={defaultNoteIds:[]};for(let A of I.elements(g))switch(A.localName){case"numFmt":C.nummeringFormat=I.attr(A,"val");break;case"footnote":case"endnote":C.defaultNoteIds.push(I.attr(A,"id"))}return C}class oA extends dC{constructor(g,I){super(g,I)}parseXml(g){this.settings=function(g,I){var C={};for(let A of I.elements(g))switch(A.localName){case"defaultTabStop":C.defaultTabStop=I.lengthAttr(A,"val");break;case"footnotePr":C.footnoteProps=dA(A,I);break;case"endnotePr":C.endnoteProps=dA(A,I);break;case"autoHyphenation":C.autoHyphenation=I.boolAttr(A,"val")}return C}(g,this._package.xmlParser)}}class nA extends dC{parseXml(g){this.props=function(g,I){return I.elements(g,"property").map((g=>{const C=g.firstChild;return{formatId:I.attr(g,"fmtid"),name:I.attr(g,"name"),type:C.nodeName,value:C.textContent}}))}(g,this._package.xmlParser)}}const aA=[{type:CC.OfficeDocument,target:"word/document.xml"},{type:CC.ExtendedProperties,target:"docProps/app.xml"},{type:CC.CoreProperties,target:"docProps/core.xml"},{type:CC.CustomProperties,target:"docProps/custom.xml"}];class ZA{constructor(){this.parts=[],this.partsMap={}}static async load(g,I,C){var A=new ZA;return A._options=C,A._parser=I,A._package=await BC.load(g,C),A.rels=await A._package.loadRelationships(),await Promise.all(aA.map((g=>{const I=A.rels.find((I=>I.type===g.type))??g;return A.loadRelationshipPart(I.target,I.type)}))),A}save(g="blob"){return this._package.save(g)}async loadRelationshipPart(g,I){var C;if(this.partsMap[g])return this.partsMap[g];if(!this._package.get(g))return null;let A=null;switch(I){case CC.OfficeDocument:this.documentPart=A=new wC(this._package,g,this._parser);break;case CC.FontTable:this.fontTablePart=A=new ZC(this._package,g);break;case CC.Numbering:this.numberingPart=A=new vC(this._package,g,this._parser);break;case CC.Styles:this.stylesPart=A=new TC(this._package,g,this._parser);break;case CC.Theme:this.themePart=A=new AA(this._package,g);break;case CC.Footnotes:this.footnotesPart=A=new sA(this._package,g,this._parser);break;case CC.Endnotes:this.endnotesPart=A=new cA(this._package,g,this._parser);break;case CC.Footer:A=new EC(this._package,g,this._parser);break;case CC.Header:A=new OC(this._package,g,this._parser);break;case CC.CoreProperties:this.corePropsPart=A=new qC(this._package,g);break;case CC.ExtendedProperties:this.extendedPropsPart=A=new _C(this._package,g);break;case CC.CustomProperties:A=new nA(this._package,g);break;case CC.Settings:this.settingsPart=A=new oA(this._package,g)}if(null==A)return Promise.resolve(null);if(this.partsMap[g]=A,this.parts.push(A),await A.load(),(null==(C=A.rels)?void 0:C.length)>0){const[g]=bC(A.path);await Promise.all(A.rels.map((I=>this.loadRelationshipPart(rC(I.target,g),I.type))))}return A}async loadDocumentImage(g,I){const C=await this.loadResource(I??this.documentPart,g,"blob");return this.blobToURL(C)}async loadNumberingImage(g){const I=await this.loadResource(this.numberingPart,g,"blob");return this.blobToURL(I)}async loadFont(g,I){const C=await this.loadResource(this.fontTablePart,g,"uint8array");return C?this.blobToURL(new Blob([bA(C,I)])):C}blobToURL(g){return g?this._options.useBase64URL?function(g){return new Promise(((I,C)=>{const A=new FileReader;A.onloadend=()=>I(A.result),A.onerror=()=>C(),A.readAsDataURL(g)}))}(g):URL.createObjectURL(g):null}findPartByRelId(g,I=null){var C=(I.rels??this.rels).find((I=>I.id==g));const A=I?bC(I.path)[0]:"";return C?this.partsMap[rC(C.target,A)]:null}getPathById(g,I){const C=g.rels.find((g=>g.id==I)),[A]=bC(g.path);return C?rC(C.target,A):null}loadResource(g,I,C){const A=this.getPathById(g,I);return A?this._package.load(A,C):Promise.resolve(null)}}function bA(g,I){const C=I.replace(/{|}|-/g,""),A=new Array(16);for(let i=0;i<16;i++)A[16-i-1]=parseInt(C.substr(2*i,2),16);for(let i=0;i<32;i++)g[i]=g[i]^A[i%16];return g}function rA(g,I){return{type:XC.BookmarkEnd,id:I.attr(g,"id")}}class mA extends xC{constructor(){super(...arguments),this.type=XC.VmlElement,this.attrs={}}}function hA(g,I){var C=new mA;switch(g.localName){case"rect":C.tagName="rect",Object.assign(C.attrs,{width:"100%",height:"100%"});break;case"oval":C.tagName="ellipse",Object.assign(C.attrs,{cx:"50%",cy:"50%",rx:"50%",ry:"50%"});break;case"line":C.tagName="line";break;case"shape":C.tagName="g";break;case"textbox":C.tagName="foreignObject",Object.assign(C.attrs,{width:"100%",height:"100%"});break;default:return null}for(const A of cC.attrs(g))switch(A.localName){case"style":C.cssStyleText=A.value;break;case"fillcolor":C.attrs.fill=A.value;break;case"from":const[g,I]=uA(A.value);Object.assign(C.attrs,{x1:g,y1:I});break;case"to":const[i,e]=uA(A.value);Object.assign(C.attrs,{x2:i,y2:e})}for(const A of cC.elements(g))switch(A.localName){case"stroke":Object.assign(C.attrs,GA(A));break;case"fill":Object.assign(C.attrs,{});break;case"imagedata":C.tagName="image",Object.assign(C.attrs,{width:"100%",height:"100%"}),C.imageHref={id:cC.attr(A,"id"),title:cC.attr(A,"title")};break;case"txbxContent":C.children.push(...I.parseBodyElements(A));break;default:const g=hA(A,I);g&&C.children.push(g)}return C}function GA(g){return{stroke:cC.attr(g,"color"),"stroke-width":cC.lengthAttr(g,"weight",eC.Emu)??"1px"}}function uA(g){return g.split(",")}var BA="inherit",wA="black",WA="black",pA="transparent";const VA=[],yA={oMath:XC.MmlMath,oMathPara:XC.MmlMathParagraph,f:XC.MmlFraction,func:XC.MmlFunction,fName:XC.MmlFunctionName,num:XC.MmlNumerator,den:XC.MmlDenominator,rad:XC.MmlRadical,deg:XC.MmlDegree,e:XC.MmlBase,sSup:XC.MmlSuperscript,sSub:XC.MmlSubscript,sPre:XC.MmlPreSubSuper,sup:XC.MmlSuperArgument,sub:XC.MmlSubArgument,d:XC.MmlDelimiter,nary:XC.MmlNary,eqArr:XC.MmlEquationArray,lim:XC.MmlLimit,limLow:XC.MmlLimitLower,m:XC.MmlMatrix,mr:XC.MmlMatrixRow,box:XC.MmlBox,bar:XC.MmlBar,groupChr:XC.MmlGroupChar};class XA{constructor(g){this.options={ignoreWidth:!1,debug:!1,...g}}parseNotes(g,I,C){var A=[];for(let i of cC.elements(g,I)){const g=new C;g.id=cC.attr(i,"id"),g.noteType=cC.attr(i,"type"),g.children=this.parseBodyElements(i),A.push(g)}return A}parseDocumentFile(g){var I=cC.element(g,"body"),C=cC.element(g,"background"),A=cC.element(I,"sectPr");return{type:XC.Document,children:this.parseBodyElements(I),props:A?RC(A,cC):{},cssStyle:C?this.parseBackground(C):{}}}parseBackground(g){var I={},C=RA.colorAttr(g,"color");return C&&(I["background-color"]=C),I}parseBodyElements(g){var I=[];for(let C of cC.elements(g))switch(C.localName){case"p":I.push(this.parseParagraph(C));break;case"tbl":I.push(this.parseTable(C));break;case"sdt":I.push(...this.parseSdt(C,(g=>this.parseBodyElements(g))))}return I}parseStylesFile(g){var I=[];return RA.foreach(g,(g=>{switch(g.localName){case"style":I.push(this.parseStyle(g));break;case"docDefaults":I.push(this.parseDefaultStyles(g))}})),I}parseDefaultStyles(g){var I={id:null,name:null,target:null,basedOn:null,styles:[]};return RA.foreach(g,(g=>{switch(g.localName){case"rPrDefault":var C=cC.element(g,"rPr");C&&I.styles.push({target:"span",values:this.parseDefaultProperties(C,{})});break;case"pPrDefault":var A=cC.element(g,"pPr");A&&I.styles.push({target:"p",values:this.parseDefaultProperties(A,{})})}})),I}parseStyle(g){var I={id:cC.attr(g,"styleId"),isDefault:cC.boolAttr(g,"default"),name:null,target:null,basedOn:null,styles:[],linked:null};switch(cC.attr(g,"type")){case"paragraph":I.target="p";break;case"table":I.target="table";break;case"character":I.target="span"}return RA.foreach(g,(g=>{switch(g.localName){case"basedOn":I.basedOn=cC.attr(g,"val");break;case"name":I.name=cC.attr(g,"val");break;case"link":I.linked=cC.attr(g,"val");break;case"next":I.next=cC.attr(g,"val");break;case"aliases":I.aliases=cC.attr(g,"val").split(",");break;case"pPr":I.styles.push({target:"p",values:this.parseDefaultProperties(g,{})}),I.paragraphProps=JC(g,cC);break;case"rPr":I.styles.push({target:"span",values:this.parseDefaultProperties(g,{})}),I.runProps=FC(g,cC);break;case"tblPr":case"tcPr":I.styles.push({target:"td",values:this.parseDefaultProperties(g,{})});break;case"tblStylePr":for(let C of this.parseTableStyle(g))I.styles.push(C);break;case"rsid":case"qFormat":case"hidden":case"semiHidden":case"unhideWhenUsed":case"autoRedefine":case"uiPriority":break;default:this.options.debug&&console.warn(`DOCX: Unknown style element: ${g.localName}`)}})),I}parseTableStyle(g){var I=[],C=cC.attr(g,"type"),A="",i="";switch(C){case"firstRow":i=".first-row",A="tr.first-row td";break;case"lastRow":i=".last-row",A="tr.last-row td";break;case"firstCol":i=".first-col",A="td.first-col";break;case"lastCol":i=".last-col",A="td.last-col";break;case"band1Vert":i=":not(.no-vband)",A="td.odd-col";break;case"band2Vert":i=":not(.no-vband)",A="td.even-col";break;case"band1Horz":i=":not(.no-hband)",A="tr.odd-row";break;case"band2Horz":i=":not(.no-hband)",A="tr.even-row";break;default:return[]}return RA.foreach(g,(g=>{switch(g.localName){case"pPr":I.push({target:`${A} p`,mod:i,values:this.parseDefaultProperties(g,{})});break;case"rPr":I.push({target:`${A} span`,mod:i,values:this.parseDefaultProperties(g,{})});break;case"tblPr":case"tcPr":I.push({target:A,mod:i,values:this.parseDefaultProperties(g,{})})}})),I}parseNumberingFile(g){var I=[],C={},A=[];return RA.foreach(g,(g=>{switch(g.localName){case"abstractNum":this.parseAbstractNumbering(g,A).forEach((g=>I.push(g)));break;case"numPicBullet":A.push(this.parseNumberingPicBullet(g));break;case"num":var i=cC.attr(g,"numId"),e=cC.elementAttr(g,"abstractNumId","val");C[e]=i}})),I.forEach((g=>g.id=C[g.id])),I}parseNumberingPicBullet(g){var I=cC.element(g,"pict"),C=I&&cC.element(I,"shape"),A=C&&cC.element(C,"imagedata");return A?{id:cC.intAttr(g,"numPicBulletId"),src:cC.attr(A,"id"),style:cC.attr(C,"style")}:null}parseAbstractNumbering(g,I){var C=[],A=cC.attr(g,"abstractNumId");return RA.foreach(g,(g=>{if("lvl"===g.localName)C.push(this.parseNumberingLevel(A,g,I))})),C}parseNumberingLevel(g,I,C){var A={id:g,level:cC.intAttr(I,"ilvl"),start:1,pStyleName:void 0,pStyle:{},rStyle:{},suff:"tab"};return RA.foreach(I,(g=>{switch(g.localName){case"start":A.start=cC.intAttr(g,"val");break;case"pPr":this.parseDefaultProperties(g,A.pStyle);break;case"rPr":this.parseDefaultProperties(g,A.rStyle);break;case"lvlPicBulletId":var I=cC.intAttr(g,"val");A.bullet=C.find((g=>g.id==I));break;case"lvlText":A.levelText=cC.attr(g,"val");break;case"pStyle":A.pStyleName=cC.attr(g,"val");break;case"numFmt":A.format=cC.attr(g,"val");break;case"suff":A.suff=cC.attr(g,"val")}})),A}parseSdt(g,I){const C=cC.element(g,"sdtContent");return C?I(C):[]}parseInserted(g,I){var C;return{type:XC.Inserted,children:(null==(C=I(g))?void 0:C.children)??[]}}parseDeleted(g,I){var C;return{type:XC.Deleted,children:(null==(C=I(g))?void 0:C.children)??[]}}parseParagraph(g){var I,C,A={type:XC.Paragraph,children:[]};for(let i of cC.elements(g))switch(i.localName){case"pPr":this.parseParagraphProperties(i,A);break;case"r":A.children.push(this.parseRun(i,A));break;case"hyperlink":A.children.push(this.parseHyperlink(i,A));break;case"bookmarkStart":A.children.push((I=i,C=cC,{type:XC.BookmarkStart,id:C.attr(I,"id"),name:C.attr(I,"name"),colFirst:C.intAttr(I,"colFirst"),colLast:C.intAttr(I,"colLast")}));break;case"bookmarkEnd":A.children.push(rA(i,cC));break;case"oMath":case"oMathPara":A.children.push(this.parseMathElement(i));break;case"sdt":A.children.push(...this.parseSdt(i,(g=>this.parseParagraph(g).children)));break;case"ins":A.children.push(this.parseInserted(i,(g=>this.parseParagraph(g))));break;case"del":A.children.push(this.parseDeleted(i,(g=>this.parseParagraph(g))))}return A}parseParagraphProperties(g,I){this.parseDefaultProperties(g,I.cssStyle={},null,(g=>{if(SC(g,I,cC))return!0;switch(g.localName){case"pStyle":I.styleName=cC.attr(g,"val");break;case"cnfStyle":I.className=NA.classNameOfCnfStyle(g);break;case"framePr":this.parseFrame(g,I);break;case"rPr":break;default:return!1}return!0}))}parseFrame(g,I){"drop"==cC.attr(g,"dropCap")&&(I.cssStyle.float="left")}parseHyperlink(g,I){var C={type:XC.Hyperlink,parent:I,children:[]},A=cC.attr(g,"anchor"),i=cC.attr(g,"id");return A&&(C.href="#"+A),i&&(C.id=i),RA.foreach(g,(g=>{if("r"===g.localName)C.children.push(this.parseRun(g,C))})),C}parseRun(g,I){var C={type:XC.Run,parent:I,children:[]};return RA.foreach(g,(g=>{switch((g=this.checkAlternateContent(g)).localName){case"t":C.children.push({type:XC.Text,text:g.textContent});break;case"delText":C.children.push({type:XC.DeletedText,text:g.textContent});break;case"fldSimple":C.children.push({type:XC.SimpleField,instruction:cC.attr(g,"instr"),lock:cC.boolAttr(g,"lock",!1),dirty:cC.boolAttr(g,"dirty",!1)});break;case"instrText":C.fieldRun=!0,C.children.push({type:XC.Instruction,text:g.textContent});break;case"fldChar":C.fieldRun=!0,C.children.push({type:XC.ComplexField,charType:cC.attr(g,"fldCharType"),lock:cC.boolAttr(g,"lock",!1),dirty:cC.boolAttr(g,"dirty",!1)});break;case"noBreakHyphen":C.children.push({type:XC.NoBreakHyphen});break;case"br":C.children.push({type:XC.Break,break:cC.attr(g,"type")||"textWrapping"});break;case"lastRenderedPageBreak":C.children.push({type:XC.Break,break:"lastRenderedPageBreak"});break;case"sym":C.children.push({type:XC.Symbol,font:cC.attr(g,"font"),char:cC.attr(g,"char")});break;case"tab":C.children.push({type:XC.Tab});break;case"footnoteReference":C.children.push({type:XC.FootnoteReference,id:cC.attr(g,"id")});break;case"endnoteReference":C.children.push({type:XC.EndnoteReference,id:cC.attr(g,"id")});break;case"drawing":let I=this.parseDrawing(g);I&&(C.children=[I]);break;case"pict":C.children.push(this.parseVmlPicture(g));break;case"rPr":this.parseRunProperties(g,C)}})),C}parseMathElement(g){const I=`${g.localName}Pr`,C={type:yA[g.localName],children:[]};for(const i of cC.elements(g)){if(yA[i.localName])C.children.push(this.parseMathElement(i));else if("r"==i.localName){var A=this.parseRun(i);A.type=XC.MmlRun,C.children.push(A)}else i.localName==I&&(C.props=this.parseMathProperies(i))}return C}parseMathProperies(g){const I={};for(const C of cC.elements(g))switch(C.localName){case"chr":I.char=cC.attr(C,"val");break;case"vertJc":I.verticalJustification=cC.attr(C,"val");break;case"pos":I.position=cC.attr(C,"val");break;case"degHide":I.hideDegree=cC.boolAttr(C,"val");break;case"begChr":I.beginChar=cC.attr(C,"val");break;case"endChr":I.endChar=cC.attr(C,"val")}return I}parseRunProperties(g,I){this.parseDefaultProperties(g,I.cssStyle={},null,(g=>{switch(g.localName){case"rStyle":I.styleName=cC.attr(g,"val");break;case"vertAlign":I.verticalAlign=NA.valueOfVertAlign(g,!0);break;default:return!1}return!0}))}parseVmlPicture(g){const I={type:XC.VmlPicture,children:[]};for(const C of cC.elements(g)){const g=hA(C,this);g&&I.children.push(g)}return I}checkAlternateContent(g){var I;if("AlternateContent"!=g.localName)return g;var C=cC.element(g,"Choice");if(C){var A=cC.attr(C,"Requires"),i=g.lookupNamespaceURI(A);if(VA.includes(i))return C.firstElementChild}return null==(I=cC.element(g,"Fallback"))?void 0:I.firstElementChild}parseDrawing(g){for(var I of cC.elements(g))switch(I.localName){case"inline":case"anchor":return this.parseDrawingWrapper(I)}}parseDrawingWrapper(g){var I={type:XC.Drawing,children:[],cssStyle:{}},C="anchor"==g.localName;let A=null,i=cC.boolAttr(g,"simplePos"),e={relative:"page",align:"left",offset:"0"},l={relative:"page",align:"top",offset:"0"};for(var t of cC.elements(g))switch(t.localName){case"simplePos":i&&(e.offset=cC.lengthAttr(t,"x",eC.Emu),l.offset=cC.lengthAttr(t,"y",eC.Emu));break;case"extent":I.cssStyle.width=cC.lengthAttr(t,"cx",eC.Emu),I.cssStyle.height=cC.lengthAttr(t,"cy",eC.Emu);break;case"positionH":case"positionV":if(!i){let g="positionH"==t.localName?e:l;var s=cC.element(t,"align"),c=cC.element(t,"posOffset");g.relative=cC.attr(t,"relativeFrom")??g.relative,s&&(g.align=s.textContent),c&&(g.offset=RA.sizeValue(c,eC.Emu))}break;case"wrapTopAndBottom":A="wrapTopAndBottom";break;case"wrapNone":A="wrapNone";break;case"graphic":var d=this.parseGraphic(t);d&&I.children.push(d)}return"wrapTopAndBottom"==A?(I.cssStyle.display="block",e.align&&(I.cssStyle["text-align"]=e.align,I.cssStyle.width="100%")):"wrapNone"==A?(I.cssStyle.display="block",I.cssStyle.position="relative",I.cssStyle.width="0px",I.cssStyle.height="0px",e.offset&&(I.cssStyle.left=e.offset),l.offset&&(I.cssStyle.top=l.offset)):!C||"left"!=e.align&&"right"!=e.align||(I.cssStyle.float=e.align),I}parseGraphic(g){var I=cC.element(g,"graphicData");for(let C of cC.elements(I))if("pic"===C.localName)return this.parsePicture(C);return null}parsePicture(g){var I={type:XC.Image,src:"",cssStyle:{}},C=cC.element(g,"blipFill"),A=cC.element(C,"blip");I.src=cC.attr(A,"embed");var i=cC.element(g,"spPr"),e=cC.element(i,"xfrm");for(var l of(I.cssStyle.position="relative",cC.elements(e)))switch(l.localName){case"ext":I.cssStyle.width=cC.lengthAttr(l,"cx",eC.Emu),I.cssStyle.height=cC.lengthAttr(l,"cy",eC.Emu);break;case"off":I.cssStyle.left=cC.lengthAttr(l,"x",eC.Emu),I.cssStyle.top=cC.lengthAttr(l,"y",eC.Emu)}return I}parseTable(g){var I={type:XC.Table,children:[]};return RA.foreach(g,(g=>{switch(g.localName){case"tr":I.children.push(this.parseTableRow(g));break;case"tblGrid":I.columns=this.parseTableColumns(g);break;case"tblPr":this.parseTableProperties(g,I)}})),I}parseTableColumns(g){var I=[];return RA.foreach(g,(g=>{if("gridCol"===g.localName)I.push({width:cC.lengthAttr(g,"w")})})),I}parseTableProperties(g,I){switch(I.cssStyle={},I.cellStyle={},this.parseDefaultProperties(g,I.cssStyle,I.cellStyle,(g=>{switch(g.localName){case"tblStyle":I.styleName=cC.attr(g,"val");break;case"tblLook":I.className=NA.classNameOftblLook(g);break;case"tblpPr":this.parseTablePosition(g,I);break;case"tblStyleColBandSize":I.colBandSize=cC.intAttr(g,"val");break;case"tblStyleRowBandSize":I.rowBandSize=cC.intAttr(g,"val");break;default:return!1}return!0})),I.cssStyle["text-align"]){case"center":delete I.cssStyle["text-align"],I.cssStyle["margin-left"]="auto",I.cssStyle["margin-right"]="auto";break;case"right":delete I.cssStyle["text-align"],I.cssStyle["margin-left"]="auto"}}parseTablePosition(g,I){var C=cC.lengthAttr(g,"topFromText"),A=cC.lengthAttr(g,"bottomFromText"),i=cC.lengthAttr(g,"rightFromText"),e=cC.lengthAttr(g,"leftFromText");I.cssStyle.float="left",I.cssStyle["margin-bottom"]=NA.addSize(I.cssStyle["margin-bottom"],A),I.cssStyle["margin-left"]=NA.addSize(I.cssStyle["margin-left"],e),I.cssStyle["margin-right"]=NA.addSize(I.cssStyle["margin-right"],i),I.cssStyle["margin-top"]=NA.addSize(I.cssStyle["margin-top"],C)}parseTableRow(g){var I={type:XC.Row,children:[]};return RA.foreach(g,(g=>{switch(g.localName){case"tc":I.children.push(this.parseTableCell(g));break;case"trPr":this.parseTableRowProperties(g,I)}})),I}parseTableRowProperties(g,I){I.cssStyle=this.parseDefaultProperties(g,{},null,(g=>{switch(g.localName){case"cnfStyle":I.className=NA.classNameOfCnfStyle(g);break;case"tblHeader":I.isHeader=cC.boolAttr(g,"val");break;default:return!1}return!0}))}parseTableCell(g){var I={type:XC.Cell,children:[]};return RA.foreach(g,(g=>{switch(g.localName){case"tbl":I.children.push(this.parseTable(g));break;case"p":I.children.push(this.parseParagraph(g));break;case"tcPr":this.parseTableCellProperties(g,I)}})),I}parseTableCellProperties(g,I){I.cssStyle=this.parseDefaultProperties(g,{},null,(g=>{switch(g.localName){case"gridSpan":I.span=cC.intAttr(g,"val",null);break;case"vMerge":I.verticalMerge=cC.attr(g,"val")??"continue";break;case"cnfStyle":I.className=NA.classNameOfCnfStyle(g);break;default:return!1}return!0}))}parseDefaultProperties(g,I=null,C=null,A=null){return I=I||{},RA.foreach(g,(i=>{if(!(null==A?void 0:A(i)))switch(i.localName){case"jc":I["text-align"]=NA.valueOfJc(i);break;case"textAlignment":I["vertical-align"]=NA.valueOfTextAlignment(i);break;case"color":I.color=RA.colorAttr(i,"val",null,wA);break;case"sz":I["font-size"]=I["min-height"]=cC.lengthAttr(i,"val",eC.FontSize);break;case"shd":I["background-color"]=RA.colorAttr(i,"fill",null,BA);break;case"highlight":I["background-color"]=RA.colorAttr(i,"val",null,pA);break;case"vertAlign":break;case"position":I.verticalAlign=cC.lengthAttr(i,"val",eC.FontSize);break;case"tcW":if(this.options.ignoreWidth)break;case"tblW":I.width=NA.valueOfSize(i,"w");break;case"trHeight":this.parseTrHeight(i,I);break;case"strike":I["text-decoration"]=cC.boolAttr(i,"val",!0)?"line-through":"none";break;case"b":I["font-weight"]=cC.boolAttr(i,"val",!0)?"bold":"normal";break;case"i":I["font-style"]=cC.boolAttr(i,"val",!0)?"italic":"normal";break;case"caps":I["text-transform"]=cC.boolAttr(i,"val",!0)?"uppercase":"none";break;case"smallCaps":I["font-variant"]=cC.boolAttr(i,"val",!0)?"small-caps":"none";break;case"u":this.parseUnderline(i,I);break;case"ind":case"tblInd":this.parseIndentation(i,I);break;case"rFonts":this.parseFont(i,I);break;case"tblBorders":this.parseBorderProperties(i,C||I);break;case"tblCellSpacing":I["border-spacing"]=NA.valueOfMargin(i),I["border-collapse"]="separate";break;case"pBdr":this.parseBorderProperties(i,I);break;case"bdr":I.border=NA.valueOfBorder(i);break;case"tcBorders":this.parseBorderProperties(i,I);break;case"vanish":cC.boolAttr(i,"val",!0)&&(I.display="none");break;case"kern":case"noWrap":break;case"tblCellMar":case"tcMar":this.parseMarginProperties(i,C||I);break;case"tblLayout":I["table-layout"]=NA.valueOfTblLayout(i);break;case"vAlign":I["vertical-align"]=NA.valueOfTextAlignment(i);break;case"spacing":"pPr"==g.localName&&this.parseSpacing(i,I);break;case"wordWrap":cC.boolAttr(i,"val")&&(I["overflow-wrap"]="break-word");break;case"suppressAutoHyphens":I.hyphens=cC.boolAttr(i,"val",!0)?"none":"auto";break;case"lang":I.$lang=cC.attr(i,"val");break;case"bCs":case"iCs":case"szCs":case"tabs":case"outlineLvl":case"contextualSpacing":case"tblStyleColBandSize":case"tblStyleRowBandSize":case"webHidden":case"pageBreakBefore":case"suppressLineNumbers":case"keepLines":case"keepNext":case"widowControl":case"bidi":case"rtl":case"noProof":break;default:this.options.debug&&console.warn(`DOCX: Unknown document element: ${g.localName}.${i.localName}`)}})),I}parseUnderline(g,I){var C=cC.attr(g,"val");if(null!=C){switch(C){case"dash":case"dashDotDotHeavy":case"dashDotHeavy":case"dashedHeavy":case"dashLong":case"dashLongHeavy":case"dotDash":case"dotDotDash":I["text-decoration"]="underline dashed";break;case"dotted":case"dottedHeavy":I["text-decoration"]="underline dotted";break;case"double":I["text-decoration"]="underline double";break;case"single":case"thick":case"words":I["text-decoration"]="underline";break;case"wave":case"wavyDouble":case"wavyHeavy":I["text-decoration"]="underline wavy";break;case"none":I["text-decoration"]="none"}var A=RA.colorAttr(g,"color");A&&(I["text-decoration-color"]=A)}}parseFont(g,I){var C=[cC.attr(g,"ascii"),NA.themeValue(g,"asciiTheme")].filter((g=>g)).join(", ");C.length>0&&(I["font-family"]=C)}parseIndentation(g,I){var C=cC.lengthAttr(g,"firstLine"),A=cC.lengthAttr(g,"hanging"),i=cC.lengthAttr(g,"left"),e=cC.lengthAttr(g,"start"),l=cC.lengthAttr(g,"right"),t=cC.lengthAttr(g,"end");C&&(I["text-indent"]=C),A&&(I["text-indent"]=`-${A}`),(i||e)&&(I["margin-left"]=i||e),(l||t)&&(I["margin-right"]=l||t)}parseSpacing(g,I){var C=cC.lengthAttr(g,"before"),A=cC.lengthAttr(g,"after"),i=cC.intAttr(g,"line",null),e=cC.attr(g,"lineRule");if(C&&(I["margin-top"]=C),A&&(I["margin-bottom"]=A),null!==i)switch(e){case"auto":I["line-height"]=`${(i/240).toFixed(2)}`;break;case"atLeast":I["line-height"]=`calc(100% + ${i/20}pt)`;break;default:I["line-height"]=I["min-height"]=i/20+"pt"}}parseMarginProperties(g,I){RA.foreach(g,(g=>{switch(g.localName){case"left":I["padding-left"]=NA.valueOfMargin(g);break;case"right":I["padding-right"]=NA.valueOfMargin(g);break;case"top":I["padding-top"]=NA.valueOfMargin(g);break;case"bottom":I["padding-bottom"]=NA.valueOfMargin(g)}}))}parseTrHeight(g,I){cC.attr(g,"hRule"),I.height=cC.lengthAttr(g,"val")}parseBorderProperties(g,I){RA.foreach(g,(g=>{switch(g.localName){case"start":case"left":I["border-left"]=NA.valueOfBorder(g);break;case"end":case"right":I["border-right"]=NA.valueOfBorder(g);break;case"top":I["border-top"]=NA.valueOfBorder(g);break;case"bottom":I["border-bottom"]=NA.valueOfBorder(g)}}))}}const YA=["black","blue","cyan","darkBlue","darkCyan","darkGray","darkGreen","darkMagenta","darkRed","darkYellow","green","lightGray","magenta","none","red","white","yellow"];class RA{static foreach(g,I){for(var C=0;C"1"==I[C])).join(" ")}static valueOfJc(g){var I=cC.attr(g,"val");switch(I){case"start":case"left":return"left";case"center":return"center";case"end":case"right":return"right";case"both":return"justify"}return I}static valueOfVertAlign(g,I=!1){var C=cC.attr(g,"val");switch(C){case"subscript":return"sub";case"superscript":return I?"sup":"super"}return I?null:C}static valueOfTextAlignment(g){var I=cC.attr(g,"val");switch(I){case"auto":case"baseline":return"baseline";case"top":return"top";case"center":return"middle";case"bottom":return"bottom"}return I}static addSize(g,I){return null==g?I:null==I?g:`calc(${g} + ${I})`}static classNameOftblLook(g){const I=cC.hexAttr(g,"val",0);let C="";return(cC.boolAttr(g,"firstRow")||32&I)&&(C+=" first-row"),(cC.boolAttr(g,"lastRow")||64&I)&&(C+=" last-row"),(cC.boolAttr(g,"firstColumn")||128&I)&&(C+=" first-col"),(cC.boolAttr(g,"lastColumn")||256&I)&&(C+=" last-col"),(cC.boolAttr(g,"noHBand")||512&I)&&(C+=" no-hband"),(cC.boolAttr(g,"noVBand")||1024&I)&&(C+=" no-vband"),C.trim()}}const HA={pos:0,leader:"none",style:"left"};function KA(g,I,C,A=.75){const i=g.closest("p"),e=g.getBoundingClientRect(),l=i.getBoundingClientRect(),t=getComputedStyle(i),s=(null==I?void 0:I.length)>0?I.map((g=>({pos:FA(g.position),leader:g.leader,style:g.style}))).sort(((g,I)=>g.pos-I.pos)):[HA],c=s[s.length-1],d=l.width*A,o=FA(C);let n=c.pos+o;if(n"clear"!=g.style&&g.pos>b));if(null==r)return;let m=1;if("right"==r.style||"center"==r.style){const I=Array.from(i.querySelectorAll(`.${g.className}`)),C=I.indexOf(g)+1,e=document.createRange();e.setStart(g,1),Cg.id))),g.endnotesPart&&(this.endnoteMap=mC(g.endnotesPart.notes,(g=>g.id))),g.settingsPart&&(this.defaultTabSize=null==(i=g.settingsPart.settings)?void 0:i.defaultTabStop),!A.ignoreFonts&&g.fontTablePart&&this.renderFontTable(g.fontTablePart,C);var e=this.renderSections(g.documentPart.body);this.options.inWrapper?I.appendChild(this.renderWrapper(e)):zA(I,e),this.refreshTabStops()}renderTheme(g,I){var C,A;const i={},e=null==(C=g.theme)?void 0:C.fontScheme;e&&(e.majorFont&&(i["--docx-majorHAnsi-font"]=e.majorFont.latinTypeface),e.minorFont&&(i["--docx-minorHAnsi-font"]=e.minorFont.latinTypeface));const l=null==(A=g.theme)?void 0:A.colorScheme;if(l)for(let[s,c]of Object.entries(l.colors))i[`--docx-${s}-color`]=`#${c}`;const t=this.styleToString(`.${this.className}`,i);I.appendChild(vA(t))}renderFontTable(g,I){for(let C of g.fonts)for(let g of C.embedFontRefs)this.tasks.push(this.document.loadFont(g.id,g.key).then((A=>{const i={"font-family":C.name,src:`url(${A})`};"bold"!=g.type&&"boldItalic"!=g.type||(i["font-weight"]="bold"),"italic"!=g.type&&"boldItalic"!=g.type||(i["font-style"]="italic"),TA(I,`docxjs ${C.name} font`);const e=this.styleToString("@font-face",i);I.appendChild(vA(e)),this.refreshTabStops()})))}processStyleName(g){return g?`${this.className}_${function(g){return null==g?void 0:g.replace(/[ .]+/g,"-").replace(/[&]+/g,"and").toLowerCase()}(g)}`:this.className}processStyles(g){const I=mC(g.filter((g=>null!=g.id)),(g=>g.id));for(const A of g.filter((g=>g.basedOn))){var C=I[A.basedOn];if(C){A.paragraphProps=GC(A.paragraphProps,C.paragraphProps),A.runProps=GC(A.runProps,C.runProps);for(const g of C.styles){const I=A.styles.find((I=>I.target==g.target));I?this.copyStyleProperties(g.values,I.values):A.styles.push({...g,values:{...g.values}})}}else this.options.debug&&console.warn(`Can't find base style ${A.basedOn}`)}for(let A of g)A.cssName=this.processStyleName(A.id);return I}prodessNumberings(g){var I;for(let C of g.filter((g=>g.pStyleName))){const g=this.findStyle(C.pStyleName);(null==(I=null==g?void 0:g.paragraphProps)?void 0:I.numbering)&&(g.paragraphProps.numbering.level=C.level)}}processElement(g){if(g.children)for(var I of g.children)I.parent=g,I.type==XC.Table?this.processTable(I):this.processElement(I)}processTable(g){for(var I of g.children)for(var C of I.children)C.cssStyle=this.copyStyleProperties(g.cellStyle,C.cssStyle,["border-left","border-right","border-top","border-bottom","padding-left","padding-right","padding-top","padding-bottom"]),this.processElement(C)}copyStyleProperties(g,I,C=null){if(!g)return I;for(var A of(null==I&&(I={}),null==C&&(C=Object.getOwnPropertyNames(g)),C))g.hasOwnProperty(A)&&!I.hasOwnProperty(A)&&(I[A]=g[A]);return I}createSection(g,I){var C=this.createElement("section",{className:g});return I&&(I.pageMargins&&(C.style.paddingLeft=I.pageMargins.left,C.style.paddingRight=I.pageMargins.right,C.style.paddingTop=I.pageMargins.top,C.style.paddingBottom=I.pageMargins.bottom),I.pageSize&&(this.options.ignoreWidth||(C.style.width=I.pageSize.width),this.options.ignoreHeight||(C.style.minHeight=I.pageSize.height)),I.columns&&I.columns.numberOfColumns&&(C.style.columnCount=`${I.columns.numberOfColumns}`,C.style.columnGap=I.columns.space,I.columns.separator&&(C.style.columnRule="1px solid black"))),C}renderSections(g){const I=[];this.processElement(g);const C=this.splitBySection(g.children);let A=null;for(let e=0,l=C.length;e"first"==g.type)):null)??(C%2==1?g.find((g=>"even"==g.type)):null)??g.find((g=>"default"==g.type)),l=e&&this.document.findPartByRelId(e.id,this.document.documentPart);if(l){this.currentPart=l,this.usedHederFooterParts.includes(l.path)||(this.processElement(l.rootElement),this.usedHederFooterParts.push(l.path));const[g]=this.renderElements([l.rootElement],i);(null==I?void 0:I.pageMargins)&&(l.rootElement.type===XC.Header?(g.style.marginTop=`calc(${I.pageMargins.header} - ${I.pageMargins.top})`,g.style.minHeight=`calc(${I.pageMargins.top} - ${I.pageMargins.header})`):l.rootElement.type===XC.Footer&&(g.style.marginBottom=`calc(${I.pageMargins.footer} - ${I.pageMargins.bottom})`,g.style.minHeight=`calc(${I.pageMargins.bottom} - ${I.pageMargins.footer})`)),this.currentPart=null}}}isPageBreakElement(g){return g.type==XC.Break&&("lastRenderedPageBreak"==g.break?!this.options.ignoreLastRenderedPageBreak:"page"==g.break)}splitBySection(g){var I,C={sectProps:null,elements:[]},A=[C];for(let d of g){if(d.type==XC.Paragraph){const g=this.findStyle(d.styleName);(null==(I=null==g?void 0:g.paragraphProps)?void 0:I.pageBreakBefore)&&(C.sectProps=i,C={sectProps:null,elements:[]},A.push(C))}if(C.elements.push(d),d.type==XC.Paragraph){const g=d;var i=g.sectionProps,e=-1,l=-1;if(this.options.breakPages&&g.children&&(e=g.children.findIndex((g=>{var I;return-1!=(l=(null==(I=g.children)?void 0:I.findIndex(this.isPageBreakElement.bind(this)))??-1)}))),(i||-1!=e)&&(C.sectProps=i,C={sectProps:null,elements:[]},A.push(C)),-1!=e){let I=g.children[e],A=l=0;d--)null==A[d].sectProps?A[d].sectProps=c:c=A[d].sectProps;return A}renderWrapper(g){return this.createElement("div",{className:`${this.className}-wrapper`},g)}renderDefaultStyle(){var g=this.className;return vA(`\n.${g}-wrapper { background: gray; padding: 30px; padding-bottom: 0px; display: flex; flex-flow: column; align-items: center; } \n.${g}-wrapper>section.${g} { background: white; box-shadow: 0 0 10px rgba(0, 0, 0, 0.5); margin-bottom: 30px; }\n.${g} { color: black; hyphens: auto; text-underline-position: from-font; }\nsection.${g} { box-sizing: border-box; display: flex; flex-flow: column nowrap; position: relative; overflow: hidden; }\nsection.${g}>article { margin-bottom: auto; z-index: 1; }\nsection.${g}>footer { z-index: 1; }\n.${g} table { border-collapse: collapse; }\n.${g} table td, .${g} table th { vertical-align: top; }\n.${g} p { margin: 0pt; min-height: 1em; }\n.${g} span { white-space: pre-wrap; overflow-wrap: break-word; }\n.${g} a { color: inherit; text-decoration: inherit; }\n`)}renderNumbering(g,I){var C="",A=[];for(var i of g){var e=`p.${this.numberingClass(i.id,i.level)}`,l="none";if(i.bullet){let g=`--${this.className}-${i.bullet.src}`.toLowerCase();C+=this.styleToString(`${e}:before`,{content:"' '",display:"inline-block",background:`var(${g})`},i.bullet.style),this.tasks.push(this.document.loadNumberingImage(i.bullet.src).then((C=>{var A=`${this.rootSelector} { ${g}: url(${C}) }`;I.appendChild(vA(A))})))}else if(i.levelText){let g=this.numberingCounter(i.id,i.level);const I=g+" "+(i.start-1);i.level>0&&(C+=this.styleToString(`p.${this.numberingClass(i.id,i.level-1)}`,{"counter-reset":I})),A.push(I),C+=this.styleToString(`${e}:before`,{content:this.levelTextToContent(i.levelText,i.suff,i.id,this.numFormatToCssValue(i.format)),"counter-increment":g,...i.rStyle})}else l=this.numFormatToCssValue(i.format);C+=this.styleToString(e,{display:"list-item","list-style-position":"inside","list-style-type":l,...i.pStyle})}return A.length>0&&(C+=this.styleToString(this.rootSelector,{"counter-reset":A.join(" ")})),vA(C)}renderStyles(g){var I="";const C=this.styleMap,A=mC(g.filter((g=>g.isDefault)),(g=>g.target));for(const t of g){var i=t.styles;if(t.linked){var e=t.linked&&C[t.linked];e?i=i.concat(e.styles):this.options.debug&&console.warn(`Can't find linked style ${t.linked}`)}for(const g of i){var l=`${t.target??""}.${t.cssName}`;t.target!=g.target&&(l+=` ${g.target}`),A[t.target]==t&&(l=`.${this.className} ${t.target}, `+l),I+=this.styleToString(l,g.values)}}return vA(I)}renderNotes(g,I,C){var A=g.map((g=>I[g])).filter((g=>g));if(A.length>0){var i=this.createElement("ol",null,this.renderElements(A));C.appendChild(i)}}renderElement(g){switch(g.type){case XC.Paragraph:return this.renderParagraph(g);case XC.BookmarkStart:return this.renderBookmarkStart(g);case XC.BookmarkEnd:return null;case XC.Run:return this.renderRun(g);case XC.Table:return this.renderTable(g);case XC.Row:return this.renderTableRow(g);case XC.Cell:return this.renderTableCell(g);case XC.Hyperlink:return this.renderHyperlink(g);case XC.Drawing:return this.renderDrawing(g);case XC.Image:return this.renderImage(g);case XC.Text:case XC.Text:return this.renderText(g);case XC.DeletedText:return this.renderDeletedText(g);case XC.Tab:return this.renderTab(g);case XC.Symbol:return this.renderSymbol(g);case XC.Break:return this.renderBreak(g);case XC.Footer:return this.renderContainer(g,"footer");case XC.Header:return this.renderContainer(g,"header");case XC.Footnote:case XC.Endnote:return this.renderContainer(g,"li");case XC.FootnoteReference:return this.renderFootnoteReference(g);case XC.EndnoteReference:return this.renderEndnoteReference(g);case XC.NoBreakHyphen:return this.createElement("wbr");case XC.VmlPicture:return this.renderVmlPicture(g);case XC.VmlElement:return this.renderVmlElement(g);case XC.MmlMath:return this.renderContainerNS(g,JA,"math",{xmlns:JA});case XC.MmlMathParagraph:return this.renderContainer(g,"span");case XC.MmlFraction:return this.renderContainerNS(g,JA,"mfrac");case XC.MmlBase:return this.renderContainerNS(g,JA,g.parent.type==XC.MmlMatrixRow?"mtd":"mrow");case XC.MmlNumerator:case XC.MmlDenominator:case XC.MmlFunction:case XC.MmlLimit:case XC.MmlBox:return this.renderContainerNS(g,JA,"mrow");case XC.MmlGroupChar:return this.renderMmlGroupChar(g);case XC.MmlLimitLower:return this.renderContainerNS(g,JA,"munder");case XC.MmlMatrix:return this.renderContainerNS(g,JA,"mtable");case XC.MmlMatrixRow:return this.renderContainerNS(g,JA,"mtr");case XC.MmlRadical:return this.renderMmlRadical(g);case XC.MmlSuperscript:return this.renderContainerNS(g,JA,"msup");case XC.MmlSubscript:return this.renderContainerNS(g,JA,"msub");case XC.MmlDegree:case XC.MmlSuperArgument:case XC.MmlSubArgument:return this.renderContainerNS(g,JA,"mn");case XC.MmlFunctionName:return this.renderContainerNS(g,JA,"ms");case XC.MmlDelimiter:return this.renderMmlDelimiter(g);case XC.MmlRun:return this.renderMmlRun(g);case XC.MmlNary:return this.renderMmlNary(g);case XC.MmlPreSubSuper:return this.renderMmlPreSubSuper(g);case XC.MmlBar:return this.renderMmlBar(g);case XC.MmlEquationArray:return this.renderMllList(g);case XC.Inserted:return this.renderInserted(g);case XC.Deleted:return this.renderDeleted(g)}return null}renderChildren(g,I){return this.renderElements(g.children,I)}renderElements(g,I){if(null==g)return null;var C=g.flatMap((g=>this.renderElement(g))).filter((g=>null!=g));return I&&zA(I,C),C}renderContainer(g,I,C){return this.createElement(I,C,this.renderChildren(g))}renderContainerNS(g,I,C,A){return DA(I,C,A,this.renderChildren(g))}renderParagraph(g){var I,C,A=this.createElement("p");const i=this.findStyle(g.styleName);g.tabs??(g.tabs=null==(I=null==i?void 0:i.paragraphProps)?void 0:I.tabs),this.renderClass(g,A),this.renderChildren(g,A),this.renderStyleValues(g.cssStyle,A),this.renderCommonProperties(A.style,g);const e=g.numbering??(null==(C=null==i?void 0:i.paragraphProps)?void 0:C.numbering);return e&&A.classList.add(this.numberingClass(e.id,e.level)),A}renderRunProperties(g,I){this.renderCommonProperties(g,I)}renderCommonProperties(g,I){null!=I&&(I.color&&(g.color=I.color),I.fontSize&&(g["font-size"]=I.fontSize))}renderHyperlink(g){var I=this.createElement("a");if(this.renderChildren(g,I),this.renderStyleValues(g.cssStyle,I),g.href)I.href=g.href;else if(g.id){const C=this.document.documentPart.rels.find((I=>I.id==g.id&&"External"===I.targetMode));I.href=null==C?void 0:C.target}return I}renderDrawing(g){var I=this.createElement("div");return I.style.display="inline-block",I.style.position="relative",I.style.textIndent="0px",this.renderChildren(g,I),this.renderStyleValues(g.cssStyle,I),I}renderImage(g){let I=this.createElement("img");return this.renderStyleValues(g.cssStyle,I),this.document&&this.tasks.push(this.document.loadDocumentImage(g.src,this.currentPart).then((g=>{I.src=g}))),I}renderText(g){return this.htmlDocument.createTextNode(g.text)}renderDeletedText(g){return this.options.renderEndnotes?this.htmlDocument.createTextNode(g.text):null}renderBreak(g){return"textWrapping"==g.break?this.createElement("br"):null}renderInserted(g){return this.options.renderChanges?this.renderContainer(g,"ins"):this.renderChildren(g)}renderDeleted(g){return this.options.renderChanges?this.renderContainer(g,"del"):null}renderSymbol(g){var I=this.createElement("span");return I.style.fontFamily=g.font,I.innerHTML=`&#x${g.char};`,I}renderFootnoteReference(g){var I=this.createElement("sup");return this.currentFootnoteIds.push(g.id),I.textContent=`${this.currentFootnoteIds.length}`,I}renderEndnoteReference(g){var I=this.createElement("sup");return this.currentEndnoteIds.push(g.id),I.textContent=`${this.currentEndnoteIds.length}`,I}renderTab(g){var I,C=this.createElement("span");if(C.innerHTML=" ",this.options.experimental){C.className=this.tabStopClass();var A=null==(I=function(g,I){var C=g.parent;for(;null!=C&&C.type!=I;)C=C.parent;return C}(g,XC.Paragraph))?void 0:I.tabs;this.currentTabs.push({stops:A,span:C})}return C}renderBookmarkStart(g){var I=this.createElement("span");return I.id=g.name,I}renderRun(g){if(g.fieldRun)return null;const I=this.createElement("span");if(g.id&&(I.id=g.id),this.renderClass(g,I),this.renderStyleValues(g.cssStyle,I),g.verticalAlign){const C=this.createElement(g.verticalAlign);this.renderChildren(g,C),I.appendChild(C)}else this.renderChildren(g,I);return I}renderTable(g){let I=this.createElement("table");return this.tableCellPositions.push(this.currentCellPosition),this.tableVerticalMerges.push(this.currentVerticalMerge),this.currentVerticalMerge={},this.currentCellPosition={col:0,row:0},g.columns&&I.appendChild(this.renderTableColumns(g.columns)),this.renderClass(g,I),this.renderChildren(g,I),this.renderStyleValues(g.cssStyle,I),this.currentVerticalMerge=this.tableVerticalMerges.pop(),this.currentCellPosition=this.tableCellPositions.pop(),I}renderTableColumns(g){let I=this.createElement("colgroup");for(let C of g){let g=this.createElement("col");C.width&&(g.style.width=C.width),I.appendChild(g)}return I}renderTableRow(g){let I=this.createElement("tr");return this.currentCellPosition.col=0,this.renderClass(g,I),this.renderChildren(g,I),this.renderStyleValues(g.cssStyle,I),this.currentCellPosition.row++,I}renderTableCell(g){let I=this.createElement("td");const C=this.currentCellPosition.col;return g.verticalMerge?"restart"==g.verticalMerge?(this.currentVerticalMerge[C]=I,I.rowSpan=1):this.currentVerticalMerge[C]&&(this.currentVerticalMerge[C].rowSpan+=1,I.style.display="none"):this.currentVerticalMerge[C]=null,this.renderClass(g,I),this.renderChildren(g,I),this.renderStyleValues(g.cssStyle,I),g.span&&(I.colSpan=g.span),this.currentCellPosition.col+=I.colSpan,I}renderVmlPicture(g){var I=fA("div");return this.renderChildren(g,I),I}renderVmlElement(g){var I,C,A=kA("svg");A.setAttribute("style",g.cssStyleText);const i=this.renderVmlChildElement(g);return(null==(I=g.imageHref)?void 0:I.id)&&this.tasks.push(null==(C=this.document)?void 0:C.loadDocumentImage(g.imageHref.id,this.currentPart).then((g=>i.setAttribute("href",g)))),A.appendChild(i),requestAnimationFrame((()=>{const g=A.firstElementChild.getBBox();A.setAttribute("width",`${Math.ceil(g.x+g.width)}`),A.setAttribute("height",`${Math.ceil(g.y+g.height)}`)})),A}renderVmlChildElement(g){const I=kA(g.tagName);Object.entries(g.attrs).forEach((([g,C])=>I.setAttribute(g,C)));for(let C of g.children)C.type==XC.VmlElement?I.appendChild(this.renderVmlChildElement(C)):I.appendChild(...uC(this.renderElement(C)));return I}renderMmlRadical(g){var I;const C=g.children.find((g=>g.type==XC.MmlBase));if(null==(I=g.props)?void 0:I.hideDegree)return DA(JA,"msqrt",null,this.renderElements([C]));const A=g.children.find((g=>g.type==XC.MmlDegree));return DA(JA,"mroot",null,this.renderElements([C,A]))}renderMmlDelimiter(g){const I=[];return I.push(DA(JA,"mo",null,[g.props.beginChar??"("])),I.push(...this.renderElements(g.children)),I.push(DA(JA,"mo",null,[g.props.endChar??")"])),DA(JA,"mrow",null,I)}renderMmlNary(g){var I;const C=[],A=mC(g.children,(g=>g.type)),i=A[XC.MmlSuperArgument],e=A[XC.MmlSubArgument],l=i?DA(JA,"mo",null,uC(this.renderElement(i))):null,t=e?DA(JA,"mo",null,uC(this.renderElement(e))):null,s=DA(JA,"mo",null,[(null==(I=g.props)?void 0:I.char)??"∫"]);return l||t?C.push(DA(JA,"munderover",null,[s,t,l])):l?C.push(DA(JA,"mover",null,[s,l])):t?C.push(DA(JA,"munder",null,[s,t])):C.push(s),C.push(...this.renderElements(A[XC.MmlBase].children)),DA(JA,"mrow",null,C)}renderMmlPreSubSuper(g){const I=[],C=mC(g.children,(g=>g.type)),A=C[XC.MmlSuperArgument],i=C[XC.MmlSubArgument],e=A?DA(JA,"mo",null,uC(this.renderElement(A))):null,l=i?DA(JA,"mo",null,uC(this.renderElement(i))):null,t=DA(JA,"mo",null);return I.push(DA(JA,"msubsup",null,[t,l,e])),I.push(...this.renderElements(C[XC.MmlBase].children)),DA(JA,"mrow",null,I)}renderMmlGroupChar(g){const I="bot"===g.props.verticalJustification?"mover":"munder",C=this.renderContainerNS(g,JA,I);return g.props.char&&C.appendChild(DA(JA,"mo",null,[g.props.char])),C}renderMmlBar(g){const I=this.renderContainerNS(g,JA,"mrow");switch(g.props.position){case"top":I.style.textDecoration="overline";break;case"bottom":I.style.textDecoration="underline"}return I}renderMmlRun(g){const I=DA(JA,"ms");return this.renderClass(g,I),this.renderStyleValues(g.cssStyle,I),this.renderChildren(g,I),I}renderMllList(g){const I=DA(JA,"mtable");this.renderClass(g,I),this.renderStyleValues(g.cssStyle,I),this.renderChildren(g);for(let C of this.renderChildren(g))I.appendChild(DA(JA,"mtr",null,[DA(JA,"mtd",null,[C])]));return I}renderStyleValues(g,I){for(let C in g)C.startsWith("$")?I.setAttribute(C.slice(1),g[C]):I.style[C]=g[C]}renderClass(g,I){g.className&&(I.className=g.className),g.styleName&&I.classList.add(this.processStyleName(g.styleName))}findStyle(g){var I;return g&&(null==(I=this.styleMap)?void 0:I[g])}numberingClass(g,I){return`${this.className}-num-${g}-${I}`}tabStopClass(){return`${this.className}-tab-stop`}styleToString(g,I,C=null){let A=`${g} {\r\n`;for(const i in I)i.startsWith("$")||(A+=` ${i}: ${I[i]};\r\n`);return C&&(A+=C),A+"}\r\n"}numberingCounter(g,I){return`${this.className}-num-${g}-${I}`}levelTextToContent(g,I,C,A){return`"${g.replace(/%\d*/g,(g=>{let I=parseInt(g.substring(1),10)-1;return`"counter(${this.numberingCounter(C,I)}, ${A})"`}))}${{tab:"\\9",space:"\\a0"}[I]??""}"`}numFormatToCssValue(g){return{none:"none",bullet:"disc",decimal:"decimal",lowerLetter:"lower-alpha",upperLetter:"upper-alpha",lowerRoman:"lower-roman",upperRoman:"upper-roman",decimalZero:"decimal-leading-zero",aiueo:"katakana",aiueoFullWidth:"katakana",chineseCounting:"simp-chinese-informal",chineseCountingThousand:"simp-chinese-informal",chineseLegalSimplified:"simp-chinese-formal",chosung:"hangul-consonant",ideographDigital:"cjk-ideographic",ideographTraditional:"cjk-heavenly-stem",ideographLegalTraditional:"trad-chinese-formal",ideographZodiac:"cjk-earthly-branch",iroha:"katakana-iroha",irohaFullWidth:"katakana-iroha",japaneseCounting:"japanese-informal",japaneseDigitalTenThousand:"cjk-decimal",japaneseLegal:"japanese-formal",thaiNumbers:"thai",koreanCounting:"korean-hangul-formal",koreanDigital:"korean-hangul-formal",koreanDigital2:"korean-hanja-informal",hebrew1:"hebrew",hebrew2:"hebrew",hindiNumbers:"devanagari",ganada:"hangul",taiwaneseCounting:"cjk-ideographic",taiwaneseCountingThousand:"cjk-ideographic",taiwaneseDigital:"cjk-decimal"}[g]??g}refreshTabStops(){this.options.experimental&&(clearTimeout(this.tabsTimeout),this.tabsTimeout=setTimeout((()=>{const g=function(g=document.body){const I=document.createElement("div");I.style.width="100pt",g.appendChild(I);const C=100/I.offsetWidth;return g.removeChild(I),C}();for(let I of this.currentTabs)KA(I.span,I.stops,this.defaultTabSize,g)}),500))}}function fA(g,I,C){return DA(void 0,g,I,C)}function kA(g,I,C){return DA(MA,g,I,C)}function DA(g,I,C,A){var i=g?document.createElementNS(g,I):document.createElement(I);return Object.assign(i,C),A&&zA(i,A),i}function LA(g){g.innerHTML=""}function zA(g,I){I.forEach((I=>{return g.appendChild("string"==typeof(C=I)||C instanceof String?document.createTextNode(I):I);var C}))}function vA(g){return fA("style",{innerHTML:g})}function TA(g,I){g.appendChild(document.createComment(I))}const xA={ignoreHeight:!1,ignoreWidth:!1,ignoreFonts:!1,breakPages:!0,debug:!1,experimental:!1,className:"docx",inWrapper:!0,trimXmlDeclaration:!0,ignoreLastRenderedPageBreak:!0,renderHeaders:!0,renderFooters:!0,renderFootnotes:!0,renderEndnotes:!0,useBase64URL:!1,renderChanges:!1};async function UA(g,I,C,A){const i=await function(g,I){const C={...xA,...I};return ZA.load(g,new XA(C),C)}(g,A);return await async function(g,I,C,A){const i={...xA,...A},e=new SA(window.document);return e.render(g,I,C,i),Promise.allSettled(e.tasks.filter((g=>g)))}(i,I,C,A),i}const QA=Object.freeze(Object.defineProperty({__proto__:null,renderDocx:async g=>{if("undefined"!=typeof document){const{bodyContainer:I,styleContainer:C,buffer:A,docxOptions:i={}}=g,e={className:"docx"},l=Object.assign({},e,i);if(I)return UA(A,I,C,l);{const g=document.createElement("div");return document.body.appendChild(g),UA(A,g,C,l)}}}},Symbol.toStringTag,{value:"Module"}));class jA{constructor(g,I){C(this,"pdfDoc"),C(this,"pageNumber"),C(this,"total"),C(this,"dom"),C(this,"pdf"),C(this,"onError"),C(this,"onLoad"),C(this,"getPdfPage",(g=>new Promise(((I,C)=>{this.pdfDoc?this.pdfDoc.getPage(g).then((g=>{const C=g.getViewport(),A=document.createElement("canvas");this.dom.appendChild(A);const i=A.getContext("2d"),e=document.body.clientWidth-20,[l,t,s,c]=C.viewBox,d=s>e?e/s:1;A.width=s,A.height=c,C.width=s,C.height=c,A.style.width=Math.floor(C.width)*d+"px",A.style.height=Math.floor(C.height)*d+"px";const o={canvasContext:i,viewport:C,transform:[1,0,0,-1,0,C.height]};g.render(o),I({success:!0,data:g})})):C({success:!1,data:null,message:"pdfDoc is undefined"})})))),C(this,"pdfPreview",(()=>{var g;(g="data:text/javascript;base64,LyoqCiAqIEBsaWNzdGFydCBUaGUgZm9sbG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WxlRGVmaW5pdGlvbihyb290LCBmYWN0b3J5KSB7CiAgICBpZih0eXBlb2YgZXhwb3J0cyA9PT0gJ29iamVjdCcgJiYgdHlwZW9mIG1vZHVsZSA9PT0gJ29iamVjdCcpCiAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmYWN0b3J5KCk7CiAgICBlbHNlIGlmKHR5cGVvZiBkZWZpbmUgPT09ICdmdW5jdGlvbicgJiYgZGVmaW5lLmFtZCkKICAgICAgICBkZWZpbmUoInBkZmpzLWRpc3QvYnVpbGQvcGRmIiwgW10sIGZhY3RvcnkpOwogICAgZWxzZSBpZih0eXBlb2YgZXhwb3J0cyA9PT0gJ29iamVjdCcpCiAgICAgICAgZXhwb3J0c1sicGRmanMtZGlzdC9idWlsZC9wZGYiXSA9IGZhY3RvcnkoKTsKICAgIGVsc2UKICAgICAgICByb290WyJwZGZqcy1kaXN0L2J1aWxkL3BkZiJdID0gcm9vdC5wZGZqc0xpYiA9IGZhY3RvcnkoKTsKfSkoZ2xvYmFsVGhpcywgKCkgPT4gewogICAgcmV0dXJuIC8qKioqKiovICgoKSA9PiB7IC8vIHdlYnBhY2tCb290c3RyYXAKICAgICAgICAvKioqKioqLyAJdmFyIF9fd2VicGFja19tb2R1bGVzX18gPSAoWwogICAgICAgICAgICAvKiAwICovLAogICAgICAgICAgICAvKiAxICovCiAgICAgICAgICAgIC8qKiovICgoX191bnVzZWRfd2VicGFja19tb2R1bGUsIGV4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICAidXNlIHN0cmljdCI7CgoKICAgICAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAiX19lc01vZHVsZSIsICh7CiAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRydWUKICAgICAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuVmVyYm9zaXR5TGV2ZWwgPSBleHBvcnRzLlV0aW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ID0gb2JqZWN0RnJvbU1hcDsKICAgICAgICAgICAgICAgIGV4cG9ydHMub2JqZWN0U2l6ZSA9IG9iamVjdFNpemU7CiAgICAgICAgICAgICAgICBleHBvcnRzLnNldFZlcmJvc2l0eUxldmVsID0gc2V0VmVyYm9zaXR5TGV2ZWw7CiAgICAgICAgICAgICAgICBleHBvcnRzLnNoYWRvdyA9IHNoYWRvdzsKICAgICAgICAgICAgICAgIGV4cG9ydHMuc3RyaW5nMzIgPSBzdHJpbmczMjsKICAgICAgICAgICAgICAgIGV4cG9ydHMuc3RyaW5nVG9CeXRlcyA9IHN0cmluZ1RvQnl0ZXM7CiAgICAgICAgICAgICAgICBleHBvcnRzLnN0cmluZ1RvUERGU3RyaW5nID0gc3RyaW5nVG9QREZTdHJpbmc7CiAgICAgICAgICAgICAgICBleHBvcnRzLnN0cmluZ1RvVVRGOFN0cmluZyA9IHN0cmluZ1RvVVRGOFN0cmluZzsKICAgICAgICAgICAgICAgIGV4cG9ydHMudW5yZWFjaGFibGUgPSB1bnJlYWNoYWJsZTsKICAgICAgICAgICAgICAgIGV4cG9ydHMudXRmOFN0cmluZ1RvU3RyaW5nID0gdXRmOFN0cmluZ1RvU3RyaW5nOwogICAgICAgICAgICAgICAgZXhwb3J0cy53YXJuID0gd2FybjsKICAgICAgICAgICAgICAgIGlmICghZ2xvYmFsVGhpcy5fcGRmanNDb21wYXRpYmlsaXR5Q2hlY2tlZCkgewogICAgICAgICAgICAgICAgICAgIGdsb2JhbFRoaXMuX3BkZmpzQ29tcGF0aWJpbGl0eUNoZWNrZWQgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgIF9fd19wZGZqc19yZXF1aXJlX18oMik7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjb25zdCBJREVOVElUWV9NQVRSSVggPSBbMSwgMCwgMCwgMSwgMCwgMF07CiAgICAgICAgICAgICAgICBleHBvcnRzLklERU5USVRZX01BVFJJWCA9IElERU5USVRZX01BVFJJWDsKICAgICAgICAgICAgICAgIGNvbnN0IEZPTlRfSURFTlRJVFlfTUFUUklYID0gWzAuMDAxLCAwLCAwLCAwLjAwMSwgMCwgMF07CiAgICAgICAgICAgICAgICBleHBvcnRzLkZPTlRfSURFTlRJVFlfTUFUUklYID0gRk9OVF9JREVOVElUWV9NQVRSSVg7CiAgICAgICAgICAgICAgICBjb25zdCBNQVhfSU1BR0VfU0laRV9UT19DQUNIRSA9IDEwZTY7CiAgICAgICAgICAgICAgICBleHBvcnRzLk1BWF9JTUFHRV9TSVpFX1RPX0NBQ0hFID0gTUFYX0lNQUdFX1NJWkVfVE9fQ0FDSEU7CiAgICAgICAgICAgICAgICBjb25zdCBMSU5FX0ZBQ1RPUiA9IDEuMzU7CiAgICAgICAgICAgICAgICBleHBvcnRzLkxJTkVfRkFDVE9SID0gTElORV9GQUNUT1I7CiAgICAgICAgICAgICAgICBjb25zdCBMSU5FX0RFU0NFTlRfRkFDVE9SID0gMC4zNTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuTElORV9ERVNDRU5UX0ZBQ1RPUiA9IExJTkVfREVTQ0VOVF9GQUNUT1I7CiAgICAgICAgICAgICAgICBjb25zdCBCQVNFTElORV9GQUNUT1IgPSBMSU5FX0RFU0NFTlRfRkFDVE9SIC8gTElORV9GQUNUT1I7CiAgICAgICAgICAgICAgICBleHBvcnRzLkJBU0VMSU5FX0ZBQ1RPUiA9IEJBU0VMSU5FX0ZBQ1RPUjsKICAgICAgICAgICAgICAgIGNvbnN0IFJlbmRlcmluZ0ludGVudEZsYWcgPSB7CiAgICAgICAgICAgICAgICAgICAgQU5ZOiAweDAxLAogICAgICAgICAgICAgICAgICAgIERJU1BMQVk6IDB4MDIsCiAgICAgICAgICAgICAgICAgICAgUFJJTlQ6IDB4MDQsCiAgICAgICAgICAgICAgICAgICAgU0FWRTogMHgwOCwKICAgICAgICAgICAgICAgICAgICBBTk5PVEFUSU9OU19GT1JNUzogMHgxMCwKICAgICAgICAgICAgICAgICAgICBBTk5PVEFUSU9OU19TVE9SQUdFOiAweDIwLAogICAgICAgICAgICAgICAgICAgIEFOTk9UQVRJT05TX0RJU0FCTEU6IDB4NDAsCiAgICAgICAgICAgICAgICAgICAgT1BMSVNUOiAweDEwMAogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuUmVuZGVyaW5nSW50ZW50RmxhZyA9IFJlbmRlcmluZ0ludGVudEZsYWc7CiAgICAgICAgICAgICAgICBjb25zdCBBbm5vdGF0aW9uTW9kZSA9IHsKICAgICAgICAgICAgICAgICAgICBESVNBQkxFOiAwLAogICAgICAgICAgICAgICAgICAgIEVOQUJMRTogMSwKICAgICAgICAgICAgICAgICAgICBFTkFCTEVfRk9STVM6IDIsCiAgICAgICAgICAgICAgICAgICAgRU5BQkxFX1NUT1JBR0U6IDMKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBleHBvcnRzLkFubm90YXRpb25Nb2RlID0gQW5ub3RhdGlvbk1vZGU7CiAgICAgICAgICAgICAgICBjb25zdCBBbm5vdGF0aW9uRWRpdG9yUHJlZml4ID0gInBkZmpzX2ludGVybmFsX2VkaXRvcl8iOwogICAgICAgICAgICAgICAgZXhwb3J0cy5Bbm5vdGF0aW9uRWRpdG9yUHJlZml4ID0gQW5ub3RhdGlvbkVkaXRvclByZWZpeDsKICAgICAgICAgICAgICAgIGNvbnN0IEFubm90YXRpb25FZGl0b3JUeXBlID0gewogICAgICAgICAgICAgICAgICAgIERJU0FCTEU6IC0xLAogICAgICAgICAgICAgICAgICAgIE5PTkU6IDAsCiAgICAgICAgICAgICAgICAgICAgRlJFRVRFWFQ6IDMsCiAgICAgICAgICAgICAgICAgICAgSU5LOiAxNQogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuQW5ub3RhdGlvbkVkaXRvclR5cGUgPSBBbm5vdGF0aW9uRWRpdG9yVHlwZTsKICAgICAgICAgICAgICAgIGNvbnN0IEFubm90YXRpb25FZGl0b3JQYXJhbXNUeXBlID0gewogICAgICAgICAgICAgICAgICAgIEZSRUVURVhUX1NJWkU6IDEsCiAgICAgICAgICAgICAgICAgICAgRlJFRVRFWFRfQ09MT1I6IDIsCiAgICAgICAgICAgICAgICAgICAgRlJFRVRFWFRfT1BBQ0lUWTogMywKICAgICAgICAgICAgICAgICAgICBJTktfQ09MT1I6IDExLAogICAgICAgICAgICAgICAgICAgIElOS19USElDS05FU1M6IDEyLAogICAgICAgICAgICAgICAgICAgIElOS19PUEFDSVRZOiAxMwogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuQW5ub3RhdGlvbkVkaXRvclBhcmFtc1R5cGUgPSBBbm5vdGF0aW9uRWRpdG9yUGFyYW1zVHlwZTsKICAgICAgICAgICAgICAgIGNvbnN0IFBlcm1pc3Npb25GbGFnID0gewogICAgICAgICAgICAgICAgICAgIFBSSU5UOiAweDA0LAogICAgICAgICAgICAgICAgICAgIE1PRElGWV9DT05URU5UUzogMHgwOCwKICAgICAgICAgICAgICAgICAgICBDT1BZOiAweDEwLAogICAgICAgICAgICAgICAgICAgIE1PRElGWV9BTk5PVEFUSU9OUzogMHgyMCwKICAgICAgICAgICAgICAgICAgICBGSUxMX0lOVEVSQUNUSVZFX0ZPUk1TOiAweDEwMCwKICAgICAgICAgICAgICAgICAgICBDT1BZX0ZPUl9BQ0NFU1NJQklMSVRZOiAweDIwMCwKICAgICAgICAgICAgICAgICAgICBBU1NFTUJMRTogMHg0MDAsCiAgICAgICAgICAgICAgICAgICAgUFJJTlRfSElHSF9RVUFMSVRZOiAweDgwMAogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuUGVybWlzc2lvbkZsYWcgPSBQZXJtaXNzaW9uRmxhZzsKICAgICAgICAgICAgICAgIGNvbnN0IFRleHRSZW5kZXJpbmdNb2RlID0gewogICAgICAgICAgICAgICAgICAgIEZJTEw6IDAsCiAgICAgICAgICAgICAgICAgICAgU1RST0tFOiAxLAogICAgICAgICAgICAgICAgICAgIEZJTExfU1RST0tFOiAyLAogICAgICAgICAgICAgICAgICAgIElOVklTSUJMRTogMywKICAgICAgICAgICAgICAgICAgICBGSUxMX0FERF9UT19QQVRIOiA0LAogICAgICAgICAgICAgICAgICAgIFNUUk9LRV9BRERfVE9fUEFUSDogNSwKICAgICAgICAgICAgICAgICAgICBGSUxMX1NUUk9LRV9BRERfVE9fUEFUSDogNiwKICAgICAgICAgICAgICAgICAgICBBRERfVE9fUEFUSDogNywKICAgICAgICAgICAgICAgICAgICBGSUxMX1NUUk9LRV9NQVNLOiAzLAogICAgICAgICAgICAgICAgICAgIEFERF9UT19QQVRIX0ZMQUc6IDQKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBleHBvcnRzLlRleHRSZW5kZXJpbmdNb2RlID0gVGV4dFJlbmRlcmluZ01vZGU7CiAgICAgICAgICAgICAgICBjb25zdCBJbWFnZUtpbmQgPSB7CiAgICAgICAgICAgICAgICAgICAgR1JBWVNDQUxFXzFCUFA6IDEsCiAgICAgICAgICAgICAgICAgICAgUkdCXzI0QlBQOiAyLAogICAgICAgICAgICAgICAgICAgIFJHQkFfMzJCUFA6IDMKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBleHBvcnRzLkltYWdlS2luZCA9IEltYWdlS2luZDsKICAgICAgICAgICAgICAgIGNvbnN0IEFubm90YXRpb25UeXBlID0gewogICAgICAgICAgICAgICAgICAgIFRFWFQ6IDEsCiAgICAgICAgICAgICAgICAgICAgTElOSzogMiwKICAgICAgICAgICAgICAgICAgICBGUkVFVEVYVDogMywKICAgICAgICAgICAgICAgICAgICBMSU5FOiA0LAogICAgICAgICAgICAgICAgICAgIFNRVUFSRTogNSwKICAgICAgICAgICAgICAgICAgICBDSVJDTEU6IDYsCiAgICAgICAgICAgICAgICAgICAgUE9MWUdPTjogNywKICAgICAgICAgICAgICAgICAgICBQT0xZTElORTogOCwKICAgICAgICAgICAgICAgICAgICBISUdITElHSFQ6IDksCiAgICAgICAgICAgICAgICAgICAgVU5ERVJMSU5FOiAxMCwKICAgICAgICAgICAgICAgICAgICBTUVVJR0dMWTogMTEsCiAgICAgICAgICAgICAgICAgICAgU1RSSUtFT1VUOiAxMiwKICAgICAgICAgICAgICAgICAgICBTVEFNUDogMTMsCiAgICAgICAgICAgICAgICAgICAgQ0FSRVQ6IDE0LAogICAgICAgICAgICAgICAgICAgIElOSzogMTUsCiAgICAgICAgICAgICAgICAgICAgUE9QVVA6IDE2LAogICAgICAgICAgICAgICAgICAgIEZJTEVBVFRBQ0hNRU5UOiAxNywKICAgICAgICAgICAgICAgICAgICBTT1VORDogMTgsCiAgICAgICAgICAgICAgICAgICAgTU9WSUU6IDE5LAogICAgICAgICAgICAgICAgICAgIFdJREdFVDogMjAsCiAgICAgICAgICAgICAgICAgICAgU0NSRUVOOiAyMSwKICAgICAgICAgICAgICAgICAgICBQUklOVEVSTUFSSzogMjIsCiAgICAgICAgICAgICAgICAgICAgVFJBUE5FVDogMjMsCiAgICAgICAgICAgICAgICAgICAgV0FURVJNQVJLOiAyNCwKICAgICAgICAgICAgICAgICAgICBUSFJFRUQ6IDI1LAogICAgICAgICAgICAgICAgICAgIFJFREFDVDogMjYKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBleHBvcnRzLkFubm90YXRpb25UeXBlID0gQW5ub3RhdGlvblR5cGU7CiAgICAgICAgICAgICAgICBjb25zdCBBbm5vdGF0aW9uU3RhdGVNb2RlbFR5cGUgPSB7CiAgICAgICAgICAgICAgICAgICAgTUFSS0VEOiAiTWFya2VkIiwKICAgICAgICAgICAgICAgICAgICBSRVZJRVc6ICJSZXZpZXciCiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgZXhwb3J0cy5Bbm5vdGF0aW9uU3RhdGVNb2RlbFR5cGUgPSBBbm5vdGF0aW9uU3RhdGVNb2RlbFR5cGU7CiAgICAgICAgICAgICAgICBjb25zdCBBbm5vdGF0aW9uTWFya2VkU3RhdGUgPSB7CiAgICAgICAgICAgICAgICAgICAgTUFSS0VEOiAiTWFya2VkIiwKICAgICAgICAgICAgICAgICAgICBVTk1BUktFRDogIlVubWFya2VkIgogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuQW5ub3RhdGlvbk1hcmtlZFN0YXRlID0gQW5ub3RhdGlvbk1hcmtlZFN0YXRlOwogICAgICAgICAgICAgICAgY29uc3QgQW5ub3RhdGlvblJldmlld1N0YXRlID0gewogICAgICAgICAgICAgICAgICAgIEFDQ0VQVEVEOiAiQWNjZXB0ZWQiLAogICAgICAgICAgICAgICAgICAgIFJFSkVDVEVEOiAiUmVqZWN0ZWQiLAogICAgICAgICAgICAgICAgICAgIENBTkNFTExFRDogIkNhbmNlbGxlZCIsCiAgICAgICAgICAgICAgICAgICAgQ09NUExFVEVEOiAiQ29tcGxldGVkIiwKICAgICAgICAgICAgICAgICAgICBOT05FOiAiTm9uZSIKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBleHBvcnRzLkFubm90YXRpb25SZXZpZXdTdGF0ZSA9IEFubm90YXRpb25SZXZpZXdTdGF0ZTsKICAgICAgICAgICAgICAgIGNvbnN0IEFubm90YXRpb25SZXBseVR5cGUgPSB7CiAgICAgICAgICAgICAgICAgICAgR1JPVVA6ICJHcm91cCIsCiAgICAgICAgICAgICAgICAgICAgUkVQTFk6ICJSIgogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuQW5ub3RhdGlvblJlcGx5VHlwZSA9IEFubm90YXRpb25SZXBseVR5cGU7CiAgICAgICAgICAgICAgICBjb25zdCBBbm5vdGF0aW9uRmxhZyA9IHsKICAgICAgICAgICAgICAgICAgICBJTlZJU0lCTEU6IDB4MDEsCiAgICAgICAgICAgICAgICAgICAgSElEREVOOiAweDAyLAogICAgICAgICAgICAgICAgICAgIFBSSU5UOiAweDA0LAogICAgICAgICAgICAgICAgICAgIE5PWk9PTTogMHgwOCwKICAgICAgICAgICAgICAgICAgICBOT1JPVEFURTogMHgxMCwKICAgICAgICAgICAgICAgICAgICBOT1ZJRVc6IDB4MjAsCiAgICAgICAgICAgICAgICAgICAgUkVBRE9OTFk6IDB4NDAsCiAgICAgICAgICAgICAgICAgICAgTE9DS0VEOiAweDgwLAogICAgICAgICAgICAgICAgICAgIFRPR0dMRU5PVklFVzogMHgxMDAsCiAgICAgICAgICAgICAgICAgICAgTE9DS0VEQ09OVEVOVFM6IDB4MjAwCiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgZXhwb3J0cy5Bbm5vdGF0aW9uRmxhZyA9IEFubm90YXRpb25GbGFnOwogICAgICAgICAgICAgICAgY29uc3QgQW5ub3RhdGlvbkZpZWxkRmxhZyA9IHsKICAgICAgICAgICAgICAgICAgICBSRUFET05MWTogMHgwMDAwMDAxLAogICAgICAgICAgICAgICAgICAgIFJFUVVJUkVEOiAweDAwMDAwMDIsCiAgICAgICAgICAgICAgICAgICAgTk9FWFBPUlQ6IDB4MDAwMDAwNCwKICAgICAgICAgICAgICAgICAgICBNVUxUSUxJTkU6IDB4MDAwMTAwMCwKICAgICAgICAgICAgICAgICAgICBQQVNTV09SRDogMHgwMDAyMDAwLAogICAgICAgICAgICAgICAgICAgIE5PVE9HR0xFVE9PRkY6IDB4MDAwNDAwMCwKICAgICAgICAgICAgICAgICAgICBSQURJTzogMHgwMDA4MDAwLAogICAgICAgICAgICAgICAgICAgIFBVU0hCVVRUT046IDB4MDAxMDAwMCwKICAgICAgICAgICAgICAgICAgICBDT01CTzogMHgwMDIwMDAwLAogICAgICAgICAgICAgICAgICAgIEVESVQ6IDB4MDA0MDAwMCwKICAgICAgICAgICAgICAgICAgICBTT1JUOiAweDAwODAwMDAsCiAgICAgICAgICAgICAgICAgICAgRklMRVNFTEVDVDogMHgwMTAwMDAwLAogICAgICAgICAgICAgICAgICAgIE1VTFRJU0VMRUNUOiAweDAyMDAwMDAsCiAgICAgICAgICAgICAgICAgICAgRE9OT1RTUEVMTENIRUNLOiAweDA0MDAwMDAsCiAgICAgICAgICAgICAgICAgICAgRE9OT1RTQ1JPTEw6IDB4MDgwMDAwMCwKICAgICAgICAgICAgICAgICAgICBDT01COiAweDEwMDAwMDAsCiAgICAgICAgICAgICAgICAgICAgUklDSFRFWFQ6IDB4MjAwMDAwMCwKICAgICAgICAgICAgICAgICAgICBSQURJT1NJTlVOSVNPTjogMHgyMDAwMDAwLAogICAgICAgICAgICAgICAgICAgIENPTU1JVE9OU0VMQ0hBTkdFOiAweDQwMDAwMDAKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBleHBvcnRzLkFubm90YXRpb25GaWVsZEZsYWcgPSBBbm5vdGF0aW9uRmllbGRGbGFnOwogICAgICAgICAgICAgICAgY29uc3QgQW5ub3RhdGlvbkJvcmRlclN0eWxlVHlwZSA9IHsKICAgICAgICAgICAgICAgICAgICBTT0xJRDogMSwKICAgICAgICAgICAgICAgICAgICBEQVNIRUQ6IDIsCiAgICAgICAgICAgICAgICAgICAgQkVWRUxFRDogMywKICAgICAgICAgICAgICAgICAgICBJTlNFVDogNCwKICAgICAgICAgICAgICAgICAgICBVTkRFUkxJTkU6IDUKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBleHBvcnRzLkFubm90YXRpb25Cb3JkZXJTdHlsZVR5cGUgPSBBbm5vdGF0aW9uQm9yZGVyU3R5bGVUeXBlOwogICAgICAgICAgICAgICAgY29uc3QgQW5ub3RhdGlvbkFjdGlvbkV2ZW50VHlwZSA9IHsKICAgICAgICAgICAgICAgICAgICBFOiAiTW91c2UgRW50ZXIiLAogICAgICAgICAgICAgICAgICAgIFg6ICJNb3VzZSBFeGl0IiwKICAgICAgICAgICAgICAgICAgICBEOiAiTW91c2UgRG93biIsCiAgICAgICAgICAgICAgICAgICAgVTogIk1vdXNlIFVwIiwKICAgICAgICAgICAgICAgICAgICBGbzogIkZvY3VzIiwKICAgICAgICAgICAgICAgICAgICBCbDogIkJsdXIiLAogICAgICAgICAgICAgICAgICAgIFBPOiAiUGFnZU9wZW4iLAogICAgICAgICAgICAgICAgICAgIFBDOiAiUGFnZUNsb3NlIiwKICAgICAgICAgICAgICAgICAgICBQVjogIlBhZ2VWaXNpYmxlIiwKICAgICAgICAgICAgICAgICAgICBQSTogIlBhZ2VJbnZpc2libGUiLAogICAgICAgICAgICAgICAgICAgIEs6ICJLZXlzdHJva2UiLAogICAgICAgICAgICAgICAgICAgIEY6ICJGb3JtYXQiLAogICAgICAgICAgICAgICAgICAgIFY6ICJWYWxpZGF0ZSIsCiAgICAgICAgICAgICAgICAgICAgQzogIkNhbGN1bGF0ZSIKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBleHBvcnRzLkFubm90YXRpb25BY3Rpb25FdmVudFR5cGUgPSBBbm5vdGF0aW9uQWN0aW9uRXZlbnRUeXBlOwogICAgICAgICAgICAgICAgY29uc3QgRG9jdW1lbnRBY3Rpb25FdmVudFR5cGUgPSB7CiAgICAgICAgICAgICAgICAgICAgV0M6ICJXaWxsQ2xvc2UiLAogICAgICAgICAgICAgICAgICAgIFdTOiAiV2lsbFNhdmUiLAogICAgICAgICAgICAgICAgICAgIERTOiAiRGlkU2F2ZSIsCiAgICAgICAgICAgICAgICAgICAgV1A6ICJXaWxsUHJpbnQiLAogICAgICAgICAgICAgICAgICAgIERQOiAiRGlkUHJpbnQiCiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgZXhwb3J0cy5Eb2N1bWVudEFjdGlvbkV2ZW50VHlwZSA9IERvY3VtZW50QWN0aW9uRXZlbnRUeXBlOwogICAgICAgICAgICAgICAgY29uc3QgUGFnZUFjdGlvbkV2ZW50VHlwZSA9IHsKICAgICAgICAgICAgICAgICAgICBPOiAiUGFnZU9wZW4iLAogICAgICAgICAgICAgICAgICAgIEM6ICJQYWdlQ2xvc2UiCiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgZXhwb3J0cy5QYWdlQWN0aW9uRXZlbnRUeXBlID0gUGFnZUFjdGlvbkV2ZW50VHlwZTsKICAgICAgICAgICAgICAgIGNvbnN0IFZlcmJvc2l0eUxldmVsID0gewogICAgICAgICAgICAgICAgICAgIEVSUk9SUzogMCwKICAgICAgICAgICAgICAgICAgICBXQVJOSU5HUzogMSwKICAgICAgICAgICAgICAgICAgICBJTkZPUzogNQogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuVmVyYm9zaXR5TGV2ZWwgPSBWZXJib3NpdHlMZXZlbDsKICAgICAgICAgICAgICAgIGNvbnN0IENNYXBDb21wcmVzc2lvblR5cGUgPSB7CiAgICAgICAgICAgICAgICAgICAgTk9ORTogMCwKICAgICAgICAgICAgICAgICAgICBCSU5BUlk6IDEKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBleHBvcnRzLkNNYXBDb21wcmVzc2lvblR5cGUgPSBDTWFwQ29tcHJlc3Npb25UeXBlOwogICAgICAgICAgICAgICAgY29uc3QgT1BTID0gewogICAgICAgICAgICAgICAgICAgIGRlcGVuZGVuY3k6IDEsCiAgICAgICAgICAgICAgICAgICAgc2V0TGluZVdpZHRoOiAyLAogICAgICAgICAgICAgICAgICAgIHNldExpbmVDYXA6IDMsCiAgICAgICAgICAgICAgICAgICAgc2V0TGluZUpvaW46IDQsCiAgICAgICAgICAgICAgICAgICAgc2V0TWl0ZXJMaW1pdDogNSwKICAgICAgICAgICAgICAgICAgICBzZXREYXNoOiA2LAogICAgICAgICAgICAgICAgICAgIHNldFJlbmRlcmluZ0ludGVudDogNywKICAgICAgICAgICAgICAgICAgICBzZXRGbGF0bmVzczogOCwKICAgICAgICAgICAgICAgICAgICBzZXRHU3RhdGU6IDksCiAgICAgICAgICAgICAgICAgICAgc2F2ZTogMTAsCiAgICAgICAgICAgICAgICAgICAgcmVzdG9yZTogMTEsCiAgICAgICAgICAgICAgICAgICAgdHJhbnNmb3JtOiAxMiwKICAgICAgICAgICAgICAgICAgICBtb3ZlVG86IDEzLAogICAgICAgICAgICAgICAgICAgIGxpbmVUbzogMTQsCiAgICAgICAgICAgICAgICAgICAgY3VydmVUbzogMTUsCiAgICAgICAgICAgICAgICAgICAgY3VydmVUbzI6IDE2LAogICAgICAgICAgICAgICAgICAgIGN1cnZlVG8zOiAxNywKICAgICAgICAgICAgICAgICAgICBjbG9zZVBhdGg6IDE4LAogICAgICAgICAgICAgICAgICAgIHJlY3RhbmdsZTogMTksCiAgICAgICAgICAgICAgICAgICAgc3Ryb2tlOiAyMCwKICAgICAgICAgICAgICAgICAgICBjbG9zZVN0cm9rZTogMjEsCiAgICAgICAgICAgICAgICAgICAgZmlsbDogMjIsCiAgICAgICAgICAgICAgICAgICAgZW9GaWxsOiAyMywKICAgICAgICAgICAgICAgICAgICBmaWxsU3Ryb2tlOiAyNCwKICAgICAgICAgICAgICAgICAgICBlb0ZpbGxTdHJva2U6IDI1LAogICAgICAgICAgICAgICAgICAgIGNsb3NlRmlsbFN0cm9rZTogMjYsCiAgICAgICAgICAgICAgICAgICAgY2xvc2VFT0ZpbGxTdHJva2U6IDI3LAogICAgICAgICAgICAgICAgICAgIGVuZFBhdGg6IDI4LAogICAgICAgICAgICAgICAgICAgIGNsaXA6IDI5LAogICAgICAgICAgICAgICAgICAgIGVvQ2xpcDogMzAsCiAgICAgICAgICAgICAgICAgICAgYmVnaW5UZXh0OiAzMSwKICAgICAgICAgICAgICAgICAgICBlbmRUZXh0OiAzMiwKICAgICAgICAgICAgICAgICAgICBzZXRDaGFyU3BhY2luZzogMzMsCiAgICAgICAgICAgICAgICAgICAgc2V0V29yZFNwYWNpbmc6IDM0LAogICAgICAgICAgICAgICAgICAgIHNldEhTY2FsZTogMzUsCiAgICAgICAgICAgICAgICAgICAgc2V0TGVhZGluZzogMzYsCiAgICAgICAgICAgICAgICAgICAgc2V0Rm9udDogMzcsCiAgICAgICAgICAgICAgICAgICAgc2V0VGV4dFJlbmRlcmluZ01vZGU6IDM4LAogICAgICAgICAgICAgICAgICAgIHNldFRleHRSaXNlOiAzOSwKICAgICAgICAgICAgICAgICAgICBtb3ZlVGV4dDogNDAsCiAgICAgICAgICAgICAgICAgICAgc2V0TGVhZGluZ01vdmVUZXh0OiA0MSwKICAgICAgICAgICAgICAgICAgICBzZXRUZXh0TWF0cml4OiA0MiwKICAgICAgICAgICAgICAgICAgICBuZXh0TGluZTogNDMsCiAgICAgICAgICAgICAgICAgICAgc2hvd1RleHQ6IDQ0LAogICAgICAgICAgICAgICAgICAgIHNob3dTcGFjZWRUZXh0OiA0NSwKICAgICAgICAgICAgICAgICAgICBuZXh0TGluZVNob3dUZXh0OiA0NiwKICAgICAgICAgICAgICAgICAgICBuZXh0TGluZVNldFNwYWNpbmdTaG93VGV4dDogNDcsCiAgICAgICAgICAgICAgICAgICAgc2V0Q2hhcldpZHRoOiA0OCwKICAgICAgICAgICAgICAgICAgICBzZXRDaGFyV2lkdGhBbmRCb3VuZHM6IDQ5LAogICAgICAgICAgICAgICAgICAgIHNldFN0cm9rZUNvbG9yU3BhY2U6IDUwLAogICAgICAgICAgICAgICAgICAgIHNldEZpbGxDb2xvclNwYWNlOiA1MSwKICAgICAgICAgICAgICAgICAgICBzZXRTdHJva2VDb2xvcjogNTIsCiAgICAgICAgICAgICAgICAgICAgc2V0U3Ryb2tlQ29sb3JOOiA1MywKICAgICAgICAgICAgICAgICAgICBzZXRGaWxsQ29sb3I6IDU0LAogICAgICAgICAgICAgICAgICAgIHNldEZpbGxDb2xvck46IDU1LAogICAgICAgICAgICAgICAgICAgIHNldFN0cm9rZUdyYXk6IDU2LAogICAgICAgICAgICAgICAgICAgIHNldEZpbGxHcmF5OiA1NywKICAgICAgICAgICAgICAgICAgICBzZXRTdHJva2VSR0JDb2xvcjogNTgsCiAgICAgICAgICAgICAgICAgICAgc2V0RmlsbFJHQkNvbG9yOiA1OSwKICAgICAgICAgICAgICAgICAgICBzZXRTdHJva2VDTVlLQ29sb3I6IDYwLAogICAgICAgICAgICAgICAgICAgIHNldEZpbGxDTVlLQ29sb3I6IDYxLAogICAgICAgICAgICAgICAgICAgIHNoYWRpbmdGaWxsOiA2MiwKICAgICAgICAgICAgICAgICAgICBiZWdpbklubGluZUltYWdlOiA2MywKICAgICAgICAgICAgICAgICAgICBiZWdpbkltYWdlRGF0YTogNjQsCiAgICAgICAgICAgICAgICAgICAgZW5kSW5saW5lSW1hZ2U6IDY1LAogICAgICAgICAgICAgICAgICAgIHBhaW50WE9iamVjdDogNjYsCiAgICAgICAgICAgICAgICAgICAgbWFya1BvaW50OiA2NywKICAgICAgICAgICAgICAgICAgICBtYXJrUG9pbnRQcm9wczogNjgsCiAgICAgICAgICAgICAgICAgICAgYmVnaW5NYXJrZWRDb250ZW50OiA2OSwKICAgICAgICAgICAgICAgICAgICBiZWdpbk1hcmtlZENvbnRlbnRQcm9wczogNzAsCiAgICAgICAgICAgICAgICAgICAgZW5kTWFya2VkQ29udGVudDogNzEsCiAgICAgICAgICAgICAgICAgICAgYmVnaW5Db21wYXQ6IDcyLAogICAgICAgICAgICAgICAgICAgIGVuZENvbXBhdDogNzMsCiAgICAgICAgICAgICAgICAgICAgcGFpbnRGb3JtWE9iamVjdEJlZ2luOiA3NCwKICAgICAgICAgICAgICAgICAgICBwYWludEZvcm1YT2JqZWN0RW5kOiA3NSwKICAgICAgICAgICAgICAgICAgICBiZWdpbkdyb3VwOiA3NiwKICAgICAgICAgICAgICAgICAgICBlbmRHcm91cDogNzcsCiAgICAgICAgICAgICAgICAgICAgYmVnaW5Bbm5vdGF0aW9uOiA4MCwKICAgICAgICAgICAgICAgICAgICBlbmRBbm5vdGF0aW9uOiA4MSwKICAgICAgICAgICAgICAgICAgICBwYWludEltYWdlTWFza1hPYmplY3Q6IDgzLAogICAgICAgICAgICAgICAgICAgIHBhaW50SW1hZ2VNYXNrWE9iamVjdEdyb3VwOiA4NCwKICAgICAgICAgICAgICAgICAgICBwYWludEltYWdlWE9iamVjdDogODUsCiAgICAgICAgICAgICAgICAgICAgcGFpbnRJbmxpbmVJbWFnZVhPYmplY3Q6IDg2LAogICAgICAgICAgICAgICAgICAgIHBhaW50SW5saW5lSW1hZ2VYT2JqZWN0R3JvdXA6IDg3LAogICAgICAgICAgICAgICAgICAgIHBhaW50SW1hZ2VYT2JqZWN0UmVwZWF0OiA4OCwKICAgICAgICAgICAgICAgICAgICBwYWludEltYWdlTWFza1hPYmplY3RSZXBlYXQ6IDg5LAogICAgICAgICAgICAgICAgICAgIHBhaW50U29saWRDb2xvckltYWdlTWFzazogOTAsCiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0UGF0aDogOTEKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBleHBvcnRzLk9QUyA9IE9QUzsKICAgICAgICAgICAgICAgIGNvbnN0IFBhc3N3b3JkUmVzcG9uc2VzID0gewogICAgICAgICAgICAgICAgICAgIE5FRURfUEFTU1dPUkQ6IDEsCiAgICAgICAgICAgICAgICAgICAgSU5DT1JSRUNUX1BBU1NXT1JEOiAyCiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgZXhwb3J0cy5QYXNzd29yZFJlc3BvbnNlcyA9IFBhc3N3b3JkUmVzcG9uc2VzOwogICAgICAgICAgICAgICAgbGV0IHZlcmJvc2l0eSA9IFZlcmJvc2l0eUxldmVsLldBUk5JTkdTOwogICAgICAgICAgICAgICAgZnVuY3Rpb24gc2V0VmVyYm9zaXR5TGV2ZWwobGV2ZWwpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoTnVtYmVyLmlzSW50ZWdlcihsZXZlbCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmVyYm9zaXR5ID0gbGV2ZWw7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gZ2V0VmVyYm9zaXR5TGV2ZWwoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHZlcmJvc2l0eTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGluZm8obXNnKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKHZlcmJvc2l0eSA+PSBWZXJib3NpdHlMZXZlbC5JTkZPUykgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zb2xlLmxvZyhgSW5mbzogJHttc2d9YCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gd2Fybihtc2cpIHsKICAgICAgICAgICAgICAgICAgICBpZiAodmVyYm9zaXR5ID49IFZlcmJvc2l0eUxldmVsLldBUk5JTkdTKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnNvbGUubG9nKGBXYXJuaW5nOiAke21zZ31gKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiB1bnJlYWNoYWJsZShtc2cpIHsKICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IobXNnKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGFzc2VydChjb25kLCBtc2cpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoIWNvbmQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdW5yZWFjaGFibGUobXNnKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfaXNWYWxpZFByb3RvY29sKHVybCkgewogICAgICAgICAgICAgICAgICAgIGlmICghdXJsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3dpdGNoICh1cmwucHJvdG9jb2wpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiaHR0cDoiOgogICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJodHRwczoiOgogICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJmdHA6IjoKICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAibWFpbHRvOiI6CiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgInRlbDoiOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gY3JlYXRlVmFsaWRBYnNvbHV0ZVVybCh1cmwpIHsKICAgICAgICAgICAgICAgICAgICBsZXQgYmFzZVVybCA9IGFyZ3VtZW50cy5sZW5ndGggPiAxICYmIGFyZ3VtZW50c1sxXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzFdIDogbnVsbDsKICAgICAgICAgICAgICAgICAgICBsZXQgb3B0aW9ucyA9IGFyZ3VtZW50cy5sZW5ndGggPiAyICYmIGFyZ3VtZW50c1syXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzJdIDogbnVsbDsKICAgICAgICAgICAgICAgICAgICBpZiAoIXVybCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG9wdGlvbnMgJiYgdHlwZW9mIHVybCA9PT0gInN0cmluZyIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChvcHRpb25zLmFkZERlZmF1bHRQcm90b2NvbCAmJiB1cmwuc3RhcnRzV2l0aCgid3d3LiIpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZG90cyA9IHVybC5tYXRjaCgvXC4vZyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGRvdHMgJiYgZG90cy5sZW5ndGggPj0gMikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB1cmwgPSBgaHR0cDovLyR7dXJsfWA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG9wdGlvbnMudHJ5Q29udmVydEVuY29kaW5nKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdXJsID0gc3RyaW5nVG9VVEY4U3RyaW5nKHVybCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZXgpIHt9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYWJzb2x1dGVVcmwgPSBiYXNlVXJsID8gbmV3IFVSTCh1cmwsIGJhc2VVcmwpIDogbmV3IFVSTCh1cmwpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoX2lzVmFsaWRQcm90b2NvbChhYnNvbHV0ZVVybCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBhYnNvbHV0ZVVybDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGV4KSB7fQogICAgICAgICAgICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gc2hhZG93KG9iaiwgcHJvcCwgdmFsdWUpIHsKICAgICAgICAgICAgICAgICAgICBsZXQgbm9uU2VyaWFsaXphYmxlID0gYXJndW1lbnRzLmxlbmd0aCA+IDMgJiYgYXJndW1lbnRzWzNdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbM10gOiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkob2JqLCBwcm9wLCB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlLAogICAgICAgICAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiAhbm9uU2VyaWFsaXphYmxlLAogICAgICAgICAgICAgICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiBmYWxzZQogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIHJldHVybiB2YWx1ZTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNvbnN0IEJhc2VFeGNlcHRpb24gPSBmdW5jdGlvbiBCYXNlRXhjZXB0aW9uQ2xvc3VyZSgpIHsKICAgICAgICAgICAgICAgICAgICBmdW5jdGlvbiBCYXNlRXhjZXB0aW9uKG1lc3NhZ2UsIG5hbWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuY29uc3RydWN0b3IgPT09IEJhc2VFeGNlcHRpb24pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVucmVhY2hhYmxlKCJDYW5ub3QgaW5pdGlhbGl6ZSBCYXNlRXhjZXB0aW9uLiIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubWVzc2FnZSA9IG1lc3NhZ2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubmFtZSA9IG5hbWU7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIEJhc2VFeGNlcHRpb24ucHJvdG90eXBlID0gbmV3IEVycm9yKCk7CiAgICAgICAgICAgICAgICAgICAgQmFzZUV4Y2VwdGlvbi5jb25zdHJ1Y3RvciA9IEJhc2VFeGNlcHRpb247CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIEJhc2VFeGNlcHRpb247CiAgICAgICAgICAgICAgICB9KCk7CiAgICAgICAgICAgICAgICBleHBvcnRzLkJhc2VFeGNlcHRpb24gPSBCYXNlRXhjZXB0aW9uOwogICAgICAgICAgICAgICAgY2xhc3MgUGFzc3dvcmRFeGNlcHRpb24gZXh0ZW5kcyBCYXNlRXhjZXB0aW9uIHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3Rvcihtc2csIGNvZGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIobXNnLCAiUGFzc3dvcmRFeGNlcHRpb24iKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb2RlID0gY29kZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLlBhc3N3b3JkRXhjZXB0aW9uID0gUGFzc3dvcmRFeGNlcHRpb247CiAgICAgICAgICAgICAgICBjbGFzcyBVbmtub3duRXJyb3JFeGNlcHRpb24gZXh0ZW5kcyBCYXNlRXhjZXB0aW9uIHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3Rvcihtc2csIGRldGFpbHMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIobXNnLCAiVW5rbm93bkVycm9yRXhjZXB0aW9uIik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGV0YWlscyA9IGRldGFpbHM7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5Vbmtub3duRXJyb3JFeGNlcHRpb24gPSBVbmtub3duRXJyb3JFeGNlcHRpb247CiAgICAgICAgICAgICAgICBjbGFzcyBJbnZhbGlkUERGRXhjZXB0aW9uIGV4dGVuZHMgQmFzZUV4Y2VwdGlvbiB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IobXNnKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHN1cGVyKG1zZywgIkludmFsaWRQREZFeGNlcHRpb24iKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLkludmFsaWRQREZFeGNlcHRpb24gPSBJbnZhbGlkUERGRXhjZXB0aW9uOwogICAgICAgICAgICAgICAgY2xhc3MgTWlzc2luZ1BERkV4Y2VwdGlvbiBleHRlbmRzIEJhc2VFeGNlcHRpb24gewogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKG1zZykgewogICAgICAgICAgICAgICAgICAgICAgICBzdXBlcihtc2csICJNaXNzaW5nUERGRXhjZXB0aW9uIik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5NaXNzaW5nUERGRXhjZXB0aW9uID0gTWlzc2luZ1BERkV4Y2VwdGlvbjsKICAgICAgICAgICAgICAgIGNsYXNzIFVuZXhwZWN0ZWRSZXNwb25zZUV4Y2VwdGlvbiBleHRlbmRzIEJhc2VFeGNlcHRpb24gewogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKG1zZywgc3RhdHVzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHN1cGVyKG1zZywgIlVuZXhwZWN0ZWRSZXNwb25zZUV4Y2VwdGlvbiIpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnN0YXR1cyA9IHN0YXR1czsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLlVuZXhwZWN0ZWRSZXNwb25zZUV4Y2VwdGlvbiA9IFVuZXhwZWN0ZWRSZXNwb25zZUV4Y2VwdGlvbjsKICAgICAgICAgICAgICAgIGNsYXNzIEZvcm1hdEVycm9yIGV4dGVuZHMgQmFzZUV4Y2VwdGlvbiB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IobXNnKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHN1cGVyKG1zZywgIkZvcm1hdEVycm9yIik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5Gb3JtYXRFcnJvciA9IEZvcm1hdEVycm9yOwogICAgICAgICAgICAgICAgY2xhc3MgQWJvcnRFeGNlcHRpb24gZXh0ZW5kcyBCYXNlRXhjZXB0aW9uIHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3Rvcihtc2cpIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIobXNnLCAiQWJvcnRFeGNlcHRpb24iKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLkFib3J0RXhjZXB0aW9uID0gQWJvcnRFeGNlcHRpb247CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBieXRlc1RvU3RyaW5nKGJ5dGVzKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKHR5cGVvZiBieXRlcyAhPT0gIm9iamVjdCIgfHwgYnl0ZXMgPT09IG51bGwgfHwgYnl0ZXMubGVuZ3RoID09PSB1bmRlZmluZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdW5yZWFjaGFibGUoIkludmFsaWQgYXJndW1lbnQgZm9yIGJ5dGVzVG9TdHJpbmciKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY29uc3QgbGVuZ3RoID0gYnl0ZXMubGVuZ3RoOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IE1BWF9BUkdVTUVOVF9DT1VOVCA9IDgxOTI7CiAgICAgICAgICAgICAgICAgICAgaWYgKGxlbmd0aCA8IE1BWF9BUkdVTUVOVF9DT1VOVCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gU3RyaW5nLmZyb21DaGFyQ29kZS5hcHBseShudWxsLCBieXRlcyk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0ckJ1ZiA9IFtdOwogICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgbGVuZ3RoOyBpICs9IE1BWF9BUkdVTUVOVF9DT1VOVCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjaHVua0VuZCA9IE1hdGgubWluKGkgKyBNQVhfQVJHVU1FTlRfQ09VTlQsIGxlbmd0aCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNodW5rID0gYnl0ZXMuc3ViYXJyYXkoaSwgY2h1bmtFbmQpOwogICAgICAgICAgICAgICAgICAgICAgICBzdHJCdWYucHVzaChTdHJpbmcuZnJvbUNoYXJDb2RlLmFwcGx5KG51bGwsIGNodW5rKSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJldHVybiBzdHJCdWYuam9pbigiIik7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBzdHJpbmdUb0J5dGVzKHN0cikgewogICAgICAgICAgICAgICAgICAgIGlmICh0eXBlb2Ygc3RyICE9PSAic3RyaW5nIikgewogICAgICAgICAgICAgICAgICAgICAgICB1bnJlYWNoYWJsZSgiSW52YWxpZCBhcmd1bWVudCBmb3Igc3RyaW5nVG9CeXRlcyIpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjb25zdCBsZW5ndGggPSBzdHIubGVuZ3RoOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IGJ5dGVzID0gbmV3IFVpbnQ4QXJyYXkobGVuZ3RoKTsKICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGxlbmd0aDsgKytpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGJ5dGVzW2ldID0gc3RyLmNoYXJDb2RlQXQoaSkgJiAweGZmOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gYnl0ZXM7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBzdHJpbmczMih2YWx1ZSkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBTdHJpbmcuZnJvbUNoYXJDb2RlKHZhbHVlID4+IDI0ICYgMHhmZiwgdmFsdWUgPj4gMTYgJiAweGZmLCB2YWx1ZSA+PiA4ICYgMHhmZiwgdmFsdWUgJiAweGZmKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIG9iamVjdFNpemUob2JqKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIE9iamVjdC5rZXlzKG9iaikubGVuZ3RoOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gb2JqZWN0RnJvbU1hcChtYXApIHsKICAgICAgICAgICAgICAgICAgICBjb25zdCBvYmogPSBPYmplY3QuY3JlYXRlKG51bGwpOwogICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgW2tleSwgdmFsdWVdIG9mIG1hcCkgewogICAgICAgICAgICAgICAgICAgICAgICBvYmpba2V5XSA9IHZhbHVlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gb2JqOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gaXNMaXR0bGVFbmRpYW4oKSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgYnVmZmVyOCA9IG5ldyBVaW50OEFycmF5KDQpOwogICAgICAgICAgICAgICAgICAgIGJ1ZmZlcjhbMF0gPSAxOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHZpZXczMiA9IG5ldyBVaW50MzJBcnJheShidWZmZXI4LmJ1ZmZlciwgMCwgMSk7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHZpZXczMlswXSA9PT0gMTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGlzRXZhbFN1cHBvcnRlZCgpIHsKICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICBuZXcgRnVuY3Rpb24oIiIpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIChlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBGZWF0dXJlVGVzdCB7CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIGdldCBpc0xpdHRsZUVuZGlhbigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHNoYWRvdyh0aGlzLCAiaXNMaXR0bGVFbmRpYW4iLCBpc0xpdHRsZUVuZGlhbigpKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIGdldCBpc0V2YWxTdXBwb3J0ZWQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBzaGFkb3codGhpcywgImlzRXZhbFN1cHBvcnRlZCIsIGlzRXZhbFN1cHBvcnRlZCgpKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIGdldCBpc09mZnNjcmVlbkNhbnZhc1N1cHBvcnRlZCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHNoYWRvdyh0aGlzLCAiaXNPZmZzY3JlZW5DYW52YXNTdXBwb3J0ZWQiLCB0eXBlb2YgT2Zmc2NyZWVuQ2FudmFzICE9PSAidW5kZWZpbmVkIik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBnZXQgcGxhdGZvcm0oKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0eXBlb2YgbmF2aWdhdG9yID09PSAidW5kZWZpbmVkIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHNoYWRvdyh0aGlzLCAicGxhdGZvcm0iLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNXaW46IGZhbHNlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlzTWFjOiBmYWxzZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHNoYWRvdyh0aGlzLCAicGxhdGZvcm0iLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc1dpbjogbmF2aWdhdG9yLnBsYXRmb3JtLmluY2x1ZGVzKCJXaW4iKSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlzTWFjOiBuYXZpZ2F0b3IucGxhdGZvcm0uaW5jbHVkZXMoIk1hYyIpCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGV4cG9ydHMuRmVhdHVyZVRlc3QgPSBGZWF0dXJlVGVzdDsKICAgICAgICAgICAgICAgIGNvbnN0IGhleE51bWJlcnMgPSBbLi4uQXJyYXkoMjU2KS5rZXlzKCldLm1hcChuID0+IG4udG9TdHJpbmcoMTYpLnBhZFN0YXJ0KDIsICIwIikpOwogICAgICAgICAgICAgICAgY2xhc3MgVXRpbCB7CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIG1ha2VIZXhDb2xvcihyLCBnLCBiKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBgIyR7aGV4TnVtYmVyc1tyXX0ke2hleE51bWJlcnNbZ119JHtoZXhOdW1iZXJzW2JdfWA7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBzY2FsZU1pbk1heCh0cmFuc2Zvcm0sIG1pbk1heCkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgdGVtcDsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRyYW5zZm9ybVswXSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRyYW5zZm9ybVswXSA8IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0ZW1wID0gbWluTWF4WzBdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1pbk1heFswXSA9IG1pbk1heFsxXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtaW5NYXhbMV0gPSB0ZW1wOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgbWluTWF4WzBdICo9IHRyYW5zZm9ybVswXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1pbk1heFsxXSAqPSB0cmFuc2Zvcm1bMF07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodHJhbnNmb3JtWzNdIDwgMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRlbXAgPSBtaW5NYXhbMl07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbWluTWF4WzJdID0gbWluTWF4WzNdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1pbk1heFszXSA9IHRlbXA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtaW5NYXhbMl0gKj0gdHJhbnNmb3JtWzNdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbWluTWF4WzNdICo9IHRyYW5zZm9ybVszXTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRlbXAgPSBtaW5NYXhbMF07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtaW5NYXhbMF0gPSBtaW5NYXhbMl07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtaW5NYXhbMl0gPSB0ZW1wOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGVtcCA9IG1pbk1heFsxXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1pbk1heFsxXSA9IG1pbk1heFszXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1pbk1heFszXSA9IHRlbXA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodHJhbnNmb3JtWzFdIDwgMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRlbXAgPSBtaW5NYXhbMl07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbWluTWF4WzJdID0gbWluTWF4WzNdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1pbk1heFszXSA9IHRlbXA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtaW5NYXhbMl0gKj0gdHJhbnNmb3JtWzFdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbWluTWF4WzNdICo9IHRyYW5zZm9ybVsxXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0cmFuc2Zvcm1bMl0gPCAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGVtcCA9IG1pbk1heFswXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtaW5NYXhbMF0gPSBtaW5NYXhbMV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbWluTWF4WzFdID0gdGVtcDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1pbk1heFswXSAqPSB0cmFuc2Zvcm1bMl07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtaW5NYXhbMV0gKj0gdHJhbnNmb3JtWzJdOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIG1pbk1heFswXSArPSB0cmFuc2Zvcm1bNF07CiAgICAgICAgICAgICAgICAgICAgICAgIG1pbk1heFsxXSArPSB0cmFuc2Zvcm1bNF07CiAgICAgICAgICAgICAgICAgICAgICAgIG1pbk1heFsyXSArPSB0cmFuc2Zvcm1bNV07CiAgICAgICAgICAgICAgICAgICAgICAgIG1pbk1heFszXSArPSB0cmFuc2Zvcm1bNV07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyB0cmFuc2Zvcm0obTEsIG0yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbbTFbMF0gKiBtMlswXSArIG0xWzJdICogbTJbMV0sIG0xWzFdICogbTJbMF0gKyBtMVszXSAqIG0yWzFdLCBtMVswXSAqIG0yWzJdICsgbTFbMl0gKiBtMlszXSwgbTFbMV0gKiBtMlsyXSArIG0xWzNdICogbTJbM10sIG0xWzBdICogbTJbNF0gKyBtMVsyXSAqIG0yWzVdICsgbTFbNF0sIG0xWzFdICogbTJbNF0gKyBtMVszXSAqIG0yWzVdICsgbTFbNV1dOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzdGF0aWMgYXBwbHlUcmFuc2Zvcm0ocCwgbSkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB4dCA9IHBbMF0gKiBtWzBdICsgcFsxXSAqIG1bMl0gKyBtWzRdOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB5dCA9IHBbMF0gKiBtWzFdICsgcFsxXSAqIG1bM10gKyBtWzVdOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gW3h0LCB5dF07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBhcHBseUludmVyc2VUcmFuc2Zvcm0ocCwgbSkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBkID0gbVswXSAqIG1bM10gLSBtWzFdICogbVsyXTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgeHQgPSAocFswXSAqIG1bM10gLSBwWzFdICogbVsyXSArIG1bMl0gKiBtWzVdIC0gbVs0XSAqIG1bM10pIC8gZDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgeXQgPSAoLXBbMF0gKiBtWzFdICsgcFsxXSAqIG1bMF0gKyBtWzRdICogbVsxXSAtIG1bNV0gKiBtWzBdKSAvIGQ7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbeHQsIHl0XTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIGdldEF4aWFsQWxpZ25lZEJvdW5kaW5nQm94KHIsIG0pIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcDEgPSBVdGlsLmFwcGx5VHJhbnNmb3JtKHIsIG0pOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwMiA9IFV0aWwuYXBwbHlUcmFuc2Zvcm0oci5zbGljZSgyLCA0KSwgbSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHAzID0gVXRpbC5hcHBseVRyYW5zZm9ybShbclswXSwgclszXV0sIG0pOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwNCA9IFV0aWwuYXBwbHlUcmFuc2Zvcm0oW3JbMl0sIHJbMV1dLCBtKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFtNYXRoLm1pbihwMVswXSwgcDJbMF0sIHAzWzBdLCBwNFswXSksIE1hdGgubWluKHAxWzFdLCBwMlsxXSwgcDNbMV0sIHA0WzFdKSwgTWF0aC5tYXgocDFbMF0sIHAyWzBdLCBwM1swXSwgcDRbMF0pLCBNYXRoLm1heChwMVsxXSwgcDJbMV0sIHAzWzFdLCBwNFsxXSldOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzdGF0aWMgaW52ZXJzZVRyYW5zZm9ybShtKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGQgPSBtWzBdICogbVszXSAtIG1bMV0gKiBtWzJdOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gW21bM10gLyBkLCAtbVsxXSAvIGQsIC1tWzJdIC8gZCwgbVswXSAvIGQsIChtWzJdICogbVs1XSAtIG1bNF0gKiBtWzNdKSAvIGQsIChtWzRdICogbVsxXSAtIG1bNV0gKiBtWzBdKSAvIGRdOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzdGF0aWMgc2luZ3VsYXJWYWx1ZURlY29tcG9zZTJkU2NhbGUobSkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB0cmFuc3Bvc2UgPSBbbVswXSwgbVsyXSwgbVsxXSwgbVszXV07CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGEgPSBtWzBdICogdHJhbnNwb3NlWzBdICsgbVsxXSAqIHRyYW5zcG9zZVsyXTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYiA9IG1bMF0gKiB0cmFuc3Bvc2VbMV0gKyBtWzFdICogdHJhbnNwb3NlWzNdOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjID0gbVsyXSAqIHRyYW5zcG9zZVswXSArIG1bM10gKiB0cmFuc3Bvc2VbMl07CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGQgPSBtWzJdICogdHJhbnNwb3NlWzFdICsgbVszXSAqIHRyYW5zcG9zZVszXTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZmlyc3QgPSAoYSArIGQpIC8gMjsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2Vjb25kID0gTWF0aC5zcXJ0KChhICsgZCkgKiogMiAtIDQgKiAoYSAqIGQgLSBjICogYikpIC8gMjsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3ggPSBmaXJzdCArIHNlY29uZCB8fCAxOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzeSA9IGZpcnN0IC0gc2Vjb25kIHx8IDE7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbTWF0aC5zcXJ0KHN4KSwgTWF0aC5zcXJ0KHN5KV07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBub3JtYWxpemVSZWN0KHJlY3QpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgciA9IHJlY3Quc2xpY2UoMCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChyZWN0WzBdID4gcmVjdFsyXSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgclswXSA9IHJlY3RbMl07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByWzJdID0gcmVjdFswXTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAocmVjdFsxXSA+IHJlY3RbM10pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJbMV0gPSByZWN0WzNdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgclszXSA9IHJlY3RbMV07CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHI7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBpbnRlcnNlY3QocmVjdDEsIHJlY3QyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHhMb3cgPSBNYXRoLm1heChNYXRoLm1pbihyZWN0MVswXSwgcmVjdDFbMl0pLCBNYXRoLm1pbihyZWN0MlswXSwgcmVjdDJbMl0pKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgeEhpZ2ggPSBNYXRoLm1pbihNYXRoLm1heChyZWN0MVswXSwgcmVjdDFbMl0pLCBNYXRoLm1heChyZWN0MlswXSwgcmVjdDJbMl0pKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHhMb3cgPiB4SGlnaCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgeUxvdyA9IE1hdGgubWF4KE1hdGgubWluKHJlY3QxWzFdLCByZWN0MVszXSksIE1hdGgubWluKHJlY3QyWzFdLCByZWN0MlszXSkpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB5SGlnaCA9IE1hdGgubWluKE1hdGgubWF4KHJlY3QxWzFdLCByZWN0MVszXSksIE1hdGgubWF4KHJlY3QyWzFdLCByZWN0MlszXSkpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoeUxvdyA+IHlIaWdoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gW3hMb3csIHlMb3csIHhIaWdoLCB5SGlnaF07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBiZXppZXJCb3VuZGluZ0JveCh4MCwgeTAsIHgxLCB5MSwgeDIsIHkyLCB4MywgeTMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdHZhbHVlcyA9IFtdLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgYm91bmRzID0gW1tdLCBbXV07CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBhLCBiLCBjLCB0LCB0MSwgdDIsIGIyYWMsIHNxcnRiMmFjOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IDI7ICsraSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGkgPT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBiID0gNiAqIHgwIC0gMTIgKiB4MSArIDYgKiB4MjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhID0gLTMgKiB4MCArIDkgKiB4MSAtIDkgKiB4MiArIDMgKiB4MzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjID0gMyAqIHgxIC0gMyAqIHgwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBiID0gNiAqIHkwIC0gMTIgKiB5MSArIDYgKiB5MjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhID0gLTMgKiB5MCArIDkgKiB5MSAtIDkgKiB5MiArIDMgKiB5MzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjID0gMyAqIHkxIC0gMyAqIHkwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKE1hdGguYWJzKGEpIDwgMWUtMTIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoTWF0aC5hYnMoYikgPCAxZS0xMikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdCA9IC1jIC8gYjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoMCA8IHQgJiYgdCA8IDEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHZhbHVlcy5wdXNoKHQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGIyYWMgPSBiICogYiAtIDQgKiBjICogYTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNxcnRiMmFjID0gTWF0aC5zcXJ0KGIyYWMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGIyYWMgPCAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0MSA9ICgtYiArIHNxcnRiMmFjKSAvICgyICogYSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoMCA8IHQxICYmIHQxIDwgMSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHR2YWx1ZXMucHVzaCh0MSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0MiA9ICgtYiAtIHNxcnRiMmFjKSAvICgyICogYSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoMCA8IHQyICYmIHQyIDwgMSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHR2YWx1ZXMucHVzaCh0Mik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGogPSB0dmFsdWVzLmxlbmd0aCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG10OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBqbGVuID0gajsKICAgICAgICAgICAgICAgICAgICAgICAgd2hpbGUgKGotLSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdCA9IHR2YWx1ZXNbal07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtdCA9IDEgLSB0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgYm91bmRzWzBdW2pdID0gbXQgKiBtdCAqIG10ICogeDAgKyAzICogbXQgKiBtdCAqIHQgKiB4MSArIDMgKiBtdCAqIHQgKiB0ICogeDIgKyB0ICogdCAqIHQgKiB4MzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJvdW5kc1sxXVtqXSA9IG10ICogbXQgKiBtdCAqIHkwICsgMyAqIG10ICogbXQgKiB0ICogeTEgKyAzICogbXQgKiB0ICogdCAqIHkyICsgdCAqIHQgKiB0ICogeTM7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgYm91bmRzWzBdW2psZW5dID0geDA7CiAgICAgICAgICAgICAgICAgICAgICAgIGJvdW5kc1sxXVtqbGVuXSA9IHkwOwogICAgICAgICAgICAgICAgICAgICAgICBib3VuZHNbMF1bamxlbiArIDFdID0geDM7CiAgICAgICAgICAgICAgICAgICAgICAgIGJvdW5kc1sxXVtqbGVuICsgMV0gPSB5MzsKICAgICAgICAgICAgICAgICAgICAgICAgYm91bmRzWzBdLmxlbmd0aCA9IGJvdW5kc1sxXS5sZW5ndGggPSBqbGVuICsgMjsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFtNYXRoLm1pbiguLi5ib3VuZHNbMF0pLCBNYXRoLm1pbiguLi5ib3VuZHNbMV0pLCBNYXRoLm1heCguLi5ib3VuZHNbMF0pLCBNYXRoLm1heCguLi5ib3VuZHNbMV0pXTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLlV0aWwgPSBVdGlsOwogICAgICAgICAgICAgICAgY29uc3QgUERGU3RyaW5nVHJhbnNsYXRlVGFibGUgPSBbMCwgMCwgMCwgMCwgMCwgMCwgMCwgMCwgMCwgMCwgMCwgMCwgMCwgMCwgMCwgMCwgMCwgMCwgMCwgMCwgMCwgMCwgMCwgMCwgMHgyZDgsIDB4MmM3LCAweDJjNiwgMHgyZDksIDB4MmRkLCAweDJkYiwgMHgyZGEsIDB4MmRjLCAwLCAwLCAwLCAwLCAwLCAwLCAwLCAwLCAwLCAwLCAwLCAwLCAwLCAwLCAwLCAwLCAwLCAwLCAwLCAwLCAwLCAwLCAwLCAwLCAwLCAwLCAwLCAwLCAwLCAwLCAwLCAwLCAwLCAwLCAwLCAwLCAwLCAwLCAwLCAwLCAwLCAwLCAwLCAwLCAwLCAwLCAwLCAwLCAwLCAwLCAwLCAwLCAwLCAwLCAw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lx4QkYiKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbmNvZGluZyA9ICJ1dGYtOCI7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGVuY29kaW5nKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGRlY29kZXIgPSBuZXcgVGV4dERlY29kZXIoZW5jb2RpbmcsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZmF0YWw6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBidWZmZXIgPSBzdHJpbmdUb0J5dGVzKHN0cik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGRlY29kZXIuZGVjb2RlKGJ1ZmZlcik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIChleCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdhcm4oYHN0cmluZ1RvUERGU3RyaW5nOiAiJHtleH0iLmApOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0ckJ1ZiA9IFtdOwogICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBpaSA9IHN0ci5sZW5ndGg7IGkgPCBpaTsgaSsrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNvZGUgPSBQREZTdHJpbmdUcmFuc2xhdGVUYWJsZVtzdHIuY2hhckNvZGVBdChpKV07CiAgICAgICAgICAgICAgICAgICAgICAgIHN0ckJ1Zi5wdXNoKGNvZGUgPyBTdHJpbmcuZnJvbUNoYXJDb2RlKGNvZGUpIDogc3RyLmNoYXJBdChpKSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJldHVybiBzdHJCdWYuam9pbigiIik7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBzdHJpbmdUb1VURjhTdHJpbmcoc3RyKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGRlY29kZVVSSUNvbXBvbmVudChlc2NhcGUoc3RyKSk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiB1dGY4U3RyaW5nVG9TdHJpbmcoc3RyKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHVuZXNjYXBlKGVuY29kZVVSSUNvbXBvbmVudChzdHIpKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGlzQXJyYXlCdWZmZXIodikgewogICAgICAgICAgICAgICAgICAgIHJldHVybiB0eXBlb2YgdiA9PT0gIm9iamVjdCIgJiYgdiAhPT0gbnVsbCAmJiB2LmJ5dGVMZW5ndGggIT09IHVuZGVmaW5lZDsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGlzQXJyYXlFcXVhbChhcnIxLCBhcnIyKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKGFycjEubGVuZ3RoICE9PSBhcnIyLmxlbmd0aCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBpaSA9IGFycjEubGVuZ3RoOyBpIDwgaWk7IGkrKykgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoYXJyMVtpXSAhPT0gYXJyMltpXSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gZ2V0TW9kaWZpY2F0aW9uRGF0ZSgpIHsKICAgICAgICAgICAgICAgICAgICBsZXQgZGF0ZSA9IGFyZ3VtZW50cy5sZW5ndGggPiAwICYmIGFyZ3VtZW50c1swXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzBdIDogbmV3IERhdGUoKTsKICAgICAgICAgICAgICAgICAgICBjb25zdCBidWZmZXIgPSBbZGF0ZS5nZXRVVENGdWxsWWVhcigpLnRvU3RyaW5nKCksIChkYXRlLmdldFVUQ01vbnRoKCkgKyAxKS50b1N0cmluZygpLnBhZFN0YXJ0KDIsICIwIiksIGRhdGUuZ2V0VVRDRGF0ZSgpLnRvU3RyaW5nKCkucGFkU3RhcnQoMiwgIjAiKSwgZGF0ZS5nZXRVVENIb3VycygpLnRvU3RyaW5nKCkucGFkU3RhcnQoMiwgIjAiKSwgZGF0ZS5nZXRVVENNaW51dGVzKCkudG9TdHJpbmcoKS5wYWRTdGFydCgyLCAiMCIpLCBkYXRlLmdldFVUQ1NlY29uZHMoKS50b1N0cmluZygpLnBhZFN0YXJ0KDIsICIwIildOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBidWZmZXIuam9pbigiIik7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBjcmVhdGVQcm9taXNlQ2FwYWJpbGl0eSgpIHsKICAgICAgICAgICAgICAgICAgICBjb25zdCBjYXBhYmlsaXR5ID0gT2JqZWN0LmNyZWF0ZShudWxsKTsKICAgICAgICAgICAgICAgICAgICBsZXQgaXNTZXR0bGVkID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGNhcGFiaWxpdHksICJzZXR0bGVkIiwgewogICAgICAgICAgICAgICAgICAgICAgICBnZXQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gaXNTZXR0bGVkOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgY2FwYWJpbGl0eS5wcm9taXNlID0gbmV3IFByb21pc2UoZnVuY3Rpb24gKHJlc29sdmUsIHJlamVjdCkgewogICAgICAgICAgICAgICAgICAgICAgICBjYXBhYmlsaXR5LnJlc29sdmUgPSBmdW5jdGlvbiAoZGF0YSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNTZXR0bGVkID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlc29sdmUoZGF0YSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgIGNhcGFiaWxpdHkucmVqZWN0ID0gZnVuY3Rpb24gKHJlYXNvbikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNTZXR0bGVkID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlamVjdChyZWFzb24pOwogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBjYXBhYmlsaXR5OwogICAgICAgICAgICAgICAgfQoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAyICovCiAgICAgICAgICAgIC8qKiovICgoX191bnVzZWRfd2VicGFja19tb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgICJ1c2Ugc3RyaWN0IjsKCgogICAgICAgICAgICAgICAgdmFyIF9pc19ub2RlID0gX193X3BkZmpzX3JlcXVpcmVfXygzKTsKICAgICAgICAgICAgICAgIChmdW5jdGlvbiBjaGVja0RPTU1hdHJpeCgpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoZ2xvYmFsVGhpcy5ET01NYXRyaXggfHwgIV9pc19ub2RlLmlzTm9kZUpTKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2xvYmFsVGhpcy5ET01NYXRyaXggPSByZXF1aXJlKCJjYW52YXMiKS5ET01NYXRyaXg7CiAgICAgICAgICAgICAgICB9KSgpOwogICAgICAgICAgICAgICAgKGZ1bmN0aW9uIGNoZWNrUGF0aDJEKCkgewogICAgICAgICAgICAgICAgICAgIGlmIChnbG9iYWxUaGlzLlBhdGgyRCB8fCAhX2lzX25vZGUuaXNOb2RlSlMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgIENhbnZhc1JlbmRlcmluZ0NvbnRleHQyRAogICAgICAgICAgICAgICAgICAgIH0gPSByZXF1aXJlKCJjYW52YXMiKTsKICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgIHBvbHlmaWxsUGF0aDJECiAgICAgICAgICAgICAgICAgICAgfSA9IHJlcXVpcmUoInBhdGgyZC1wb2x5ZmlsbCIpOwogICAgICAgICAgICAgICAgICAgIGdsb2JhbFRoaXMuQ2FudmFzUmVuZGVyaW5nQ29udGV4dDJEID0gQ2FudmFzUmVuZGVyaW5nQ29udGV4dDJEOwogICAgICAgICAgICAgICAgICAgIHBvbHlmaWxsUGF0aDJEKGdsb2JhbFRoaXMpOwogICAgICAgICAgICAgICAgfSkoKTsKICAgICAgICAgICAgICAgIChmdW5jdGlvbiBjaGVja1JlYWRhYmxlU3RyZWFtKCkgewogICAgICAgICAgICAgICAgICAgIGlmIChnbG9iYWxUaGlzLlJlYWRhYmxlU3RyZWFtIHx8ICFfaXNfbm9kZS5pc05vZGVKUykgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdsb2JhbFRoaXMuUmVhZGFibGVTdHJlYW0gPSByZXF1aXJlKCJ3ZWItc3RyZWFtcy1wb2x5ZmlsbC9kaXN0L3BvbnlmaWxsLmpzIikuUmVhZGFibGVTdHJlYW07CiAgICAgICAgICAgICAgICB9KSgpOwogICAgICAgICAgICAgICAgKGZ1bmN0aW9uIGNoZWNrQXJyYXlBdCgpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoQXJyYXkucHJvdG90eXBlLmF0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX193X3BkZmpzX3JlcXVpcmVfXyg0KTsKICAgICAgICAgICAgICAgIH0pKCk7CiAgICAgICAgICAgICAgICAoZnVuY3Rpb24gY2hlY2tUeXBlZEFycmF5QXQoKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKFVpbnQ4QXJyYXkucHJvdG90eXBlLmF0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX193X3BkZmpzX3JlcXVpcmVfXyg3OCk7CiAgICAgICAgICAgICAgICB9KSgpOwogICAgICAgICAgICAgICAgKGZ1bmN0aW9uIGNoZWNrU3RydWN0dXJlZENsb25lKCkgewogICAgICAgICAgICAgICAgICAgIGlmIChnbG9iYWxUaGlzLnN0cnVjdHVyZWRDbG9uZSkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9fd19wZGZqc19yZXF1aXJlX18oOTApOwogICAgICAgICAgICAgICAgfSkoKTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMyAqLwogICAgICAgICAgICAvKioqLyAoKF9fdW51c2VkX3dlYnBhY2tfbW9kdWxlLCBleHBvcnRzKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKCiAgICAgICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIl9fZXNNb2R1bGUiLCAoewogICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0cnVlCiAgICAgICAgICAgICAgICB9KSk7CiAgICAgICAgICAgICAgICBleHBvcnRzLmlzTm9kZUpTID0gdm9pZCAwOwogICAgICAgICAgICAgICAgY29uc3QgaXNOb2RlSlMgPSB0eXBlb2YgcHJvY2VzcyA9PT0gIm9iamVjdCIgJiYgcHJvY2VzcyArICIiID09PSAiW29iamVjdCBwcm9jZXNzXSIgJiYgIXByb2Nlc3MudmVyc2lvbnMubncgJiYgIShwcm9jZXNzLnZlcnNpb25zLmVsZWN0cm9uICYmIHByb2Nlc3MudHlwZSAmJiBwcm9jZXNzLnR5cGUgIT09ICJicm93c2VyIik7CiAgICAgICAgICAgICAgICBleHBvcnRzLmlzTm9kZUpTID0gaXNOb2RlSlM7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDQgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIF9fd19wZGZqc19yZXF1aXJlX18oNSk7CiAgICAgICAgICAgICAgICB2YXIgZW50cnlVbmJpbmQgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDc3KTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZW50cnlVbmJpbmQoJ0FycmF5JywgJ2F0Jyk7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDUgKi8KICAgICAgICAgICAgLyoqKi8gKChfX3VudXNlZF93ZWJwYWNrX21vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKICAgICAgICAgICAgICAgIHZhciAkID0gX193X3BkZmpzX3JlcXVpcmVfXyg2KTsKICAgICAgICAgICAgICAgIHZhciB0b09iamVjdCA9IF9fd19wZGZqc19yZXF1aXJlX18oNDMpOwogICAgICAgICAgICAgICAgdmFyIGxlbmd0aE9mQXJyYXlMaWtlID0gX193X3BkZmpzX3JlcXVpcmVfXyg2Nyk7CiAgICAgICAgICAgICAgICB2YXIgdG9JbnRlZ2VyT3JJbmZpbml0eSA9IF9fd19wZGZqc19yZXF1aXJlX18oNjUpOwogICAgICAgICAgICAgICAgdmFyIGFkZFRvVW5zY29wYWJsZXMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDcyKTsKICAgICAgICAgICAgICAgICQoewogICAgICAgICAgICAgICAgICAgIHRhcmdldDogJ0FycmF5JywKICAgICAgICAgICAgICAgICAgICBwcm90bzogdHJ1ZQogICAgICAgICAgICAgICAgfSwgewogICAgICAgICAgICAgICAgICAgIGF0OiBmdW5jdGlvbiBhdChpbmRleCkgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgTyA9IHRvT2JqZWN0KHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICB2YXIgbGVuID0gbGVuZ3RoT2ZBcnJheUxpa2UoTyk7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciByZWxhdGl2ZUluZGV4ID0gdG9JbnRlZ2VyT3JJbmZpbml0eShpbmRleCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBrID0gcmVsYXRpdmVJbmRleCA+PSAwID8gcmVsYXRpdmVJbmRleCA6IGxlbiArIHJlbGF0aXZlSW5kZXg7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBrIDwgMCB8fCBrID49IGxlbiA/IHVuZGVmaW5lZCA6IE9ba107CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICBhZGRUb1Vuc2NvcGFibGVzKCdhdCcpOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiA2ICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgZ2xvYmFsID0gX193X3BkZmpzX3JlcXVpcmVfXyg3KTsKICAgICAgICAgICAgICAgIHZhciBnZXRPd25Qcm9wZXJ0eURlc2NyaXB0b3IgPSAoX193X3BkZmpzX3JlcXVpcmVfXyg4KS5mKTsKICAgICAgICAgICAgICAgIHZhciBjcmVhdGVOb25FbnVtZXJhYmxlUHJvcGVydHkgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDQ3KTsKICAgICAgICAgICAgICAgIHZhciBkZWZpbmVCdWlsdEluID0gX193X3BkZmpzX3JlcXVpcmVfXyg1MSk7CiAgICAgICAgICAgICAgICB2YXIgZGVmaW5lR2xvYmFsUHJvcGVydHkgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDQxKTsKICAgICAgICAgICAgICAgIHZhciBjb3B5Q29uc3RydWN0b3JQcm9wZXJ0aWVzID0gX193X3BkZmpzX3JlcXVpcmVfXyg1OSk7CiAgICAgICAgICAgICAgICB2YXIgaXNGb3JjZWQgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDcxKTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKG9wdGlvbnMsIHNvdXJjZSkgewogICAgICAgICAgICAgICAgICAgIHZhciBUQVJHRVQgPSBvcHRpb25zLnRhcmdldDsKICAgICAgICAgICAgICAgICAgICB2YXIgR0xPQkFMID0gb3B0aW9ucy5nbG9iYWw7CiAgICAgICAgICAgICAgICAgICAgdmFyIFNUQVRJQyA9IG9wdGlvbnMuc3RhdDsKICAgICAgICAgICAgICAgICAgICB2YXIgRk9SQ0VELCB0YXJnZXQsIGtleSwgdGFyZ2V0UHJvcGVydHksIHNvdXJjZVByb3BlcnR5LCBkZXNjcmlwdG9yOwogICAgICAgICAgICAgICAgICAgIGlmIChHTE9CQUwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGFyZ2V0ID0gZ2xvYmFsOwogICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoU1RBVElDKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRhcmdldCA9IGdsb2JhbFtUQVJHRVRdIHx8IGRlZmluZUdsb2JhbFByb3BlcnR5KFRBUkdFVCwge30pOwogICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRhcmdldCA9IChnbG9iYWxbVEFSR0VUXSB8fCB7fSkucHJvdG90eXBlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBpZiAodGFyZ2V0KQogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGtleSBpbiBzb3VyY2UpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNvdXJjZVByb3BlcnR5ID0gc291cmNlW2tleV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAob3B0aW9ucy5kb250Q2FsbEdldFNldCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlc2NyaXB0b3IgPSBnZXRPd25Qcm9wZXJ0eURlc2NyaXB0b3IodGFyZ2V0LCBrZXkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRhcmdldFByb3BlcnR5ID0gZGVzY3JpcHRvciAmJiBkZXNjcmlwdG9yLnZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGFyZ2V0UHJvcGVydHkgPSB0YXJnZXRba2V5XTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIEZPUkNFRCA9IGlzRm9yY2VkKEdMT0JBTCA/IGtleSA6IFRBUkdFVCArIChTVEFUSUMgPyAnLicgOiAnIycpICsga2V5LCBvcHRpb25zLmZvcmNlZCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIUZPUkNFRCAmJiB0YXJnZXRQcm9wZXJ0eSAhPT0gdW5kZWZpbmVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHR5cGVvZiBzb3VyY2VQcm9wZXJ0eSA9PSB0eXBlb2YgdGFyZ2V0UHJvcGVydHkpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvcHlDb25zdHJ1Y3RvclByb3BlcnRpZXMoc291cmNlUHJvcGVydHksIHRhcmdldFByb3BlcnR5KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChvcHRpb25zLnNoYW0gfHwgdGFyZ2V0UHJvcGVydHkgJiYgdGFyZ2V0UHJvcGVydHkuc2hhbSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNyZWF0ZU5vbkVudW1lcmFibGVQcm9wZXJ0eShzb3VyY2VQcm9wZXJ0eSwgJ3NoYW0nLCB0cnVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlZmluZUJ1aWx0SW4odGFyZ2V0LCBrZXksIHNvdXJjZVByb3BlcnR5LCBvcHRpb25zKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogNyAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSkgPT4gewoKICAgICAgICAgICAgICAgIHZhciBjaGVjayA9IGZ1bmN0aW9uIChpdCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBpdCAmJiBpdC5NYXRoID09IE1hdGggJiYgaXQ7CiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBjaGVjayh0eXBlb2YgZ2xvYmFsVGhpcyA9PSAnb2JqZWN0JyAmJiBnbG9iYWxUaGlzKSB8fCBjaGVjayh0eXBlb2Ygd2luZG93ID09ICdvYmplY3QnICYmIHdpbmRvdykgfHwgY2hlY2sodHlwZW9mIHNlbGYgPT0gJ29iamVjdCcgJiYgc2VsZikgfHwgY2hlY2sodHlwZW9mIGdsb2JhbCA9PSAnb2JqZWN0JyAmJiBnbG9iYWwpIHx8IChmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXM7CiAgICAgICAgICAgICAgICB9KCkpIHx8IEZ1bmN0aW9uKCdyZXR1cm4gdGhpcycpKCk7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDggKi8KICAgICAgICAgICAgLyoqKi8gKChfX3VudXNlZF93ZWJwYWNrX21vZHVsZSwgZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBERVNDUklQVE9SUyA9IF9fd19wZGZqc19yZXF1aXJlX18oOSk7CiAgICAgICAgICAgICAgICB2YXIgY2FsbCA9IF9fd19wZGZqc19yZXF1aXJlX18oMTEpOwogICAgICAgICAgICAgICAgdmFyIHByb3BlcnR5SXNFbnVtZXJhYmxlTW9kdWxlID0gX193X3BkZmpzX3JlcXVpcmVfXygxMyk7CiAgICAgICAgICAgICAgICB2YXIgY3JlYXRlUHJvcGVydHlEZXNjcmlwdG9yID0gX193X3BkZmpzX3JlcXVpcmVfXygxNCk7CiAgICAgICAgICAgICAgICB2YXIgdG9JbmRleGVkT2JqZWN0ID0gX193X3BkZmpzX3JlcXVpcmVfXygxNSk7CiAgICAgICAgICAgICAgICB2YXIgdG9Qcm9wZXJ0eUtleSA9IF9fd19wZGZqc19yZXF1aXJlX18oMjEpOwogICAgICAgICAgICAgICAgdmFyIGhhc093biA9IF9fd19wZGZqc19yZXF1aXJlX18oNDIpOwogICAgICAgICAgICAgICAgdmFyIElFOF9ET01fREVGSU5FID0gX193X3BkZmpzX3JlcXVpcmVfXyg0NSk7CiAgICAgICAgICAgICAgICB2YXIgJGdldE93blByb3BlcnR5RGVzY3JpcHRvciA9IE9iamVjdC5nZXRPd25Qcm9wZXJ0eURlc2NyaXB0b3I7CiAgICAgICAgICAgICAgICBleHBvcnRzLmYgPSBERVNDUklQVE9SUyA/ICRnZXRPd25Qcm9wZXJ0eURlc2NyaXB0b3IgOiBmdW5jdGlvbiBnZXRPd25Qcm9wZXJ0eURlc2NyaXB0b3IoTywgUCkgewogICAgICAgICAgICAgICAgICAgIE8gPSB0b0luZGV4ZWRPYmplY3QoTyk7CiAgICAgICAgICAgICAgICAgICAgUCA9IHRvUHJvcGVydHlLZXkoUCk7CiAgICAgICAgICAgICAgICAgICAgaWYgKElFOF9ET01fREVGSU5FKQogICAgICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICRnZXRPd25Qcm9wZXJ0eURlc2NyaXB0b3IoTywgUCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBpZiAoaGFzT3duKE8sIFApKQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gY3JlYXRlUHJvcGVydHlEZXNjcmlwdG9yKCFjYWxsKHByb3BlcnR5SXNFbnVtZXJhYmxlTW9kdWxlLmYsIE8sIFApLCBPW1BdKTsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDkgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBmYWlscyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTApOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSAhZmFpbHMoZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBPYmplY3QuZGVmaW5lUHJvcGVydHkoe30sIDEsIHsKICAgICAgICAgICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gNzsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0pWzFdICE9IDc7CiAgICAgICAgICAgICAgICB9KTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTAgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUpID0+IHsKCiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uIChleGVjKSB7CiAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICEhZXhlYygpOwogICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDExICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgTkFUSVZFX0JJTkQgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEyKTsKICAgICAgICAgICAgICAgIHZhciBjYWxsID0gRnVuY3Rpb24ucHJvdG90eXBlLmNhbGw7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IE5BVElWRV9CSU5EID8gY2FsbC5iaW5kKGNhbGwpIDogZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBjYWxsLmFwcGx5KGNhbGwsIGFyZ3VtZW50cyk7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxMiAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIGZhaWxzID0gX193X3BkZmpzX3JlcXVpcmVfXygxMCk7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9ICFmYWlscyhmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgdmFyIHRlc3QgPSBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgfS5iaW5kKCk7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHR5cGVvZiB0ZXN0ICE9ICdmdW5jdGlvbicgfHwgdGVzdC5oYXNPd25Qcm9wZXJ0eSgncHJvdG90eXBlJyk7CiAgICAgICAgICAgICAgICB9KTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTMgKi8KICAgICAgICAgICAgLyoqKi8gKChfX3VudXNlZF93ZWJwYWNrX21vZHVsZSwgZXhwb3J0cykgPT4gewoKICAgICAgICAgICAgICAgICJ1c2Ugc3RyaWN0IjsKCiAgICAgICAgICAgICAgICB2YXIgJHByb3BlcnR5SXNFbnVtZXJhYmxlID0ge30ucHJvcGVydHlJc0VudW1lcmFibGU7CiAgICAgICAgICAgICAgICB2YXIgZ2V0T3duUHJvcGVydHlEZXNjcmlwdG9yID0gT2JqZWN0LmdldE93blByb3BlcnR5RGVzY3JpcHRvcjsKICAgICAgICAgICAgICAgIHZhciBOQVNIT1JOX0JVRyA9IGdldE93blByb3BlcnR5RGVzY3JpcHRvciAmJiAhJHByb3BlcnR5SXNFbnVtZXJhYmxlLmNhbGwoeyAxOiAyIH0sIDEpOwogICAgICAgICAgICAgICAgZXhwb3J0cy5mID0gTkFTSE9STl9CVUcgPyBmdW5jdGlvbiBwcm9wZXJ0eUlzRW51bWVyYWJsZShWKSB7CiAgICAgICAgICAgICAgICAgICAgdmFyIGRlc2NyaXB0b3IgPSBnZXRPd25Qcm9wZXJ0eURlc2NyaXB0b3IodGhpcywgVik7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuICEhZGVzY3JpcHRvciAmJiBkZXNjcmlwdG9yLmVudW1lcmFibGU7CiAgICAgICAgICAgICAgICB9IDogJHByb3BlcnR5SXNFbnVtZXJhYmxlOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxNCAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSkgPT4gewoKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKGJpdG1hcCwgdmFsdWUpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiAhKGJpdG1hcCAmIDEpLAogICAgICAgICAgICAgICAgICAgICAgICBjb25maWd1cmFibGU6ICEoYml0bWFwICYgMiksCiAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiAhKGJpdG1hcCAmIDQpLAogICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdmFsdWUKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTUgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBJbmRleGVkT2JqZWN0ID0gX193X3BkZmpzX3JlcXVpcmVfXygxNik7CiAgICAgICAgICAgICAgICB2YXIgcmVxdWlyZU9iamVjdENvZXJjaWJsZSA9IF9fd19wZGZqc19yZXF1aXJlX18oMTkpOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoaXQpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gSW5kZXhlZE9iamVjdChyZXF1aXJlT2JqZWN0Q29lcmNpYmxlKGl0KSk7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxNiAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIHVuY3VycnlUaGlzID0gX193X3BkZmpzX3JlcXVpcmVfXygxNyk7CiAgICAgICAgICAgICAgICB2YXIgZmFpbHMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEwKTsKICAgICAgICAgICAgICAgIHZhciBjbGFzc29mID0gX193X3BkZmpzX3JlcXVpcmVfXygxOCk7CiAgICAgICAgICAgICAgICB2YXIgJE9iamVjdCA9IE9iamVjdDsKICAgICAgICAgICAgICAgIHZhciBzcGxpdCA9IHVuY3VycnlUaGlzKCcnLnNwbGl0KTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZmFpbHMoZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiAhJE9iamVjdCgneicpLnByb3BlcnR5SXNFbnVtZXJhYmxlKDApOwogICAgICAgICAgICAgICAgfSkgPyBmdW5jdGlvbiAoaXQpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gY2xhc3NvZihpdCkgPT0gJ1N0cmluZycgPyBzcGxpdChpdCwgJycpIDogJE9iamVjdChpdCk7CiAgICAgICAgICAgICAgICB9IDogJE9iamVjdDsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTcgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBOQVRJVkVfQklORCA9IF9fd19wZGZqc19yZXF1aXJlX18oMTIpOwogICAgICAgICAgICAgICAgdmFyIEZ1bmN0aW9uUHJvdG90eXBlID0gRnVuY3Rpb24ucHJvdG90eXBlOwogICAgICAgICAgICAgICAgdmFyIGNhbGwgPSBGdW5jdGlvblByb3RvdHlwZS5jYWxsOwogICAgICAgICAgICAgICAgdmFyIHVuY3VycnlUaGlzV2l0aEJpbmQgPSBOQVRJVkVfQklORCAmJiBGdW5jdGlvblByb3RvdHlwZS5iaW5kLmJpbmQoY2FsbCwgY2FsbCk7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IE5BVElWRV9CSU5EID8gdW5jdXJyeVRoaXNXaXRoQmluZCA6IGZ1bmN0aW9uIChmbikgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBjYWxsLmFwcGx5KGZuLCBhcmd1bWVudHMpOwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxOCAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIHVuY3VycnlUaGlzID0gX193X3BkZmpzX3JlcXVpcmVfXygxNyk7CiAgICAgICAgICAgICAgICB2YXIgdG9TdHJpbmcgPSB1bmN1cnJ5VGhpcyh7fS50b1N0cmluZyk7CiAgICAgICAgICAgICAgICB2YXIgc3RyaW5nU2xpY2UgPSB1bmN1cnJ5VGhpcygnJy5zbGljZSk7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uIChpdCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBzdHJpbmdTbGljZSh0b1N0cmluZyhpdCksIDgsIC0xKTsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDE5ICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgaXNOdWxsT3JVbmRlZmluZWQgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDIwKTsKICAgICAgICAgICAgICAgIHZhciAkVHlwZUVycm9yID0gVHlwZUVycm9yOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoaXQpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoaXNOdWxsT3JVbmRlZmluZWQoaXQpKQogICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyAkVHlwZUVycm9yKCJDYW4ndCBjYWxsIG1ldGhvZCBvbiAiICsgaXQpOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBpdDsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDIwICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlKSA9PiB7CgogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoaXQpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gaXQgPT09IG51bGwgfHwgaXQgPT09IHVuZGVmaW5lZDsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDIxICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgdG9QcmltaXRpdmUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDIyKTsKICAgICAgICAgICAgICAgIHZhciBpc1N5bWJvbCA9IF9fd19wZGZqc19yZXF1aXJlX18oMjYpOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoYXJndW1lbnQpIHsKICAgICAgICAgICAgICAgICAgICB2YXIga2V5ID0gdG9QcmltaXRpdmUoYXJndW1lbnQsICdzdHJpbmcnKTsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gaXNTeW1ib2woa2V5KSA/IGtleSA6IGtleSArICcnOwogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMjIgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBjYWxsID0gX193X3BkZmpzX3JlcXVpcmVfXygxMSk7CiAgICAgICAgICAgICAgICB2YXIgaXNPYmplY3QgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDIzKTsKICAgICAgICAgICAgICAgIHZhciBpc1N5bWJvbCA9IF9fd19wZGZqc19yZXF1aXJlX18oMjYpOwogICAgICAgICAgICAgICAgdmFyIGdldE1ldGhvZCA9IF9fd19wZGZqc19yZXF1aXJlX18oMzMpOwogICAgICAgICAgICAgICAgdmFyIG9yZGluYXJ5VG9QcmltaXRpdmUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDM2KTsKICAgICAgICAgICAgICAgIHZhciB3ZWxsS25vd25TeW1ib2wgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDM3KTsKICAgICAgICAgICAgICAgIHZhciAkVHlwZUVycm9yID0gVHlwZUVycm9yOwogICAgICAgICAgICAgICAgdmFyIFRPX1BSSU1JVElWRSA9IHdlbGxLbm93blN5bWJvbCgndG9QcmltaXRpdmUnKTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKGlucHV0LCBwcmVmKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKCFpc09iamVjdChpbnB1dCkgfHwgaXNTeW1ib2woaW5wdXQpKQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gaW5wdXQ7CiAgICAgICAgICAgICAgICAgICAgdmFyIGV4b3RpY1RvUHJpbSA9IGdldE1ldGhvZChpbnB1dCwgVE9fUFJJTUlUSVZFKTsKICAgICAgICAgICAgICAgICAgICB2YXIgcmVzdWx0OwogICAgICAgICAgICAgICAgICAgIGlmIChleG90aWNUb1ByaW0pIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHByZWYgPT09IHVuZGVmaW5lZCkKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHByZWYgPSAnZGVmYXVsdCc7CiAgICAgICAgICAgICAgICAgICAgICAgIHJlc3VsdCA9IGNhbGwoZXhvdGljVG9QcmltLCBpbnB1dCwgcHJlZik7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghaXNPYmplY3QocmVzdWx0KSB8fCBpc1N5bWJvbChyZXN1bHQpKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHJlc3VsdDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgJFR5cGVFcnJvcigiQ2FuJ3QgY29udmVydCBvYmplY3QgdG8gcHJpbWl0aXZlIHZhbHVlIik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmIChwcmVmID09PSB1bmRlZmluZWQpCiAgICAgICAgICAgICAgICAgICAgICAgIHByZWYgPSAnbnVtYmVyJzsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gb3JkaW5hcnlUb1ByaW1pdGl2ZShpbnB1dCwgcHJlZik7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAyMyAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIGlzQ2FsbGFibGUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDI0KTsKICAgICAgICAgICAgICAgIHZhciAkZG9jdW1lbnRBbGwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDI1KTsKICAgICAgICAgICAgICAgIHZhciBkb2N1bWVudEFsbCA9ICRkb2N1bWVudEFsbC5hbGw7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9ICRkb2N1bWVudEFsbC5JU19IVE1MRERBID8gZnVuY3Rpb24gKGl0KSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHR5cGVvZiBpdCA9PSAnb2JqZWN0JyA/IGl0ICE9PSBudWxsIDogaXNDYWxsYWJsZShpdCkgfHwgaXQgPT09IGRvY3VtZW50QWxsOwogICAgICAgICAgICAgICAgfSA6IGZ1bmN0aW9uIChpdCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiB0eXBlb2YgaXQgPT0gJ29iamVjdCcgPyBpdCAhPT0gbnVsbCA6IGlzQ2FsbGFibGUoaXQpOwogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMjQgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciAkZG9jdW1lbnRBbGwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDI1KTsKICAgICAgICAgICAgICAgIHZhciBkb2N1bWVudEFsbCA9ICRkb2N1bWVudEFsbC5hbGw7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9ICRkb2N1bWVudEFsbC5JU19IVE1MRERBID8gZnVuY3Rpb24gKGFyZ3VtZW50KSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHR5cGVvZiBhcmd1bWVudCA9PSAnZnVuY3Rpb24nIHx8IGFyZ3VtZW50ID09PSBkb2N1bWVudEFsbDsKICAgICAgICAgICAgICAgIH0gOiBmdW5jdGlvbiAoYXJndW1lbnQpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHlwZW9mIGFyZ3VtZW50ID09ICdmdW5jdGlvbic7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAyNSAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSkgPT4gewoKICAgICAgICAgICAgICAgIHZhciBkb2N1bWVudEFsbCA9IHR5cGVvZiBkb2N1bWVudCA9PSAnb2JqZWN0JyAmJiBkb2N1bWVudC5hbGw7CiAgICAgICAgICAgICAgICB2YXIgSVNfSFRNTEREQSA9IHR5cGVvZiBkb2N1bWVudEFsbCA9PSAndW5kZWZpbmVkJyAmJiBkb2N1bWVudEFsbCAhPT0gdW5kZWZpbmVkOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSB7CiAgICAgICAgICAgICAgICAgICAgYWxsOiBkb2N1bWVudEFsbCwKICAgICAgICAgICAgICAgICAgICBJU19IVE1MRERBOiBJU19IVE1MRERBCiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAyNiAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIGdldEJ1aWx0SW4gPSBfX3dfcGRmanNfcmVxdWlyZV9fKDI3KTsKICAgICAgICAgICAgICAgIHZhciBpc0NhbGxhYmxlID0gX193X3BkZmpzX3JlcXVpcmVfXygyNCk7CiAgICAgICAgICAgICAgICB2YXIgaXNQcm90b3R5cGVPZiA9IF9fd19wZGZqc19yZXF1aXJlX18oMjgpOwogICAgICAgICAgICAgICAgdmFyIFVTRV9TWU1CT0xfQVNfVUlEID0gX193X3BkZmpzX3JlcXVpcmVfXygyOSk7CiAgICAgICAgICAgICAgICB2YXIgJE9iamVjdCA9IE9iamVjdDsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gVVNFX1NZTUJPTF9BU19VSUQgPyBmdW5jdGlvbiAoaXQpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHlwZW9mIGl0ID09ICdzeW1ib2wnOwogICAgICAgICAgICAgICAgfSA6IGZ1bmN0aW9uIChpdCkgewogICAgICAgICAgICAgICAgICAgIHZhciAkU3ltYm9sID0gZ2V0QnVpbHRJbignU3ltYm9sJyk7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGlzQ2FsbGFibGUoJFN5bWJvbCkgJiYgaXNQcm90b3R5cGVPZigkU3ltYm9sLnByb3RvdHlwZSwgJE9iamVjdChpdCkpOwogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMjcgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBnbG9iYWwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDcpOwogICAgICAgICAgICAgICAgdmFyIGlzQ2FsbGFibGUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDI0KTsKICAgICAgICAgICAgICAgIHZhciBhRnVuY3Rpb24gPSBmdW5jdGlvbiAoYXJndW1lbnQpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gaXNDYWxsYWJsZShhcmd1bWVudCkgPyBhcmd1bWVudCA6IHVuZGVmaW5lZDsKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uIChuYW1lc3BhY2UsIG1ldGhvZCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBhcmd1bWVudHMubGVuZ3RoIDwgMiA/IGFGdW5jdGlvbihnbG9iYWxbbmFtZXNwYWNlXSkgOiBnbG9iYWxbbmFtZXNwYWNlXSAmJiBnbG9iYWxbbmFtZXNwYWNlXVttZXRob2RdOwogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMjggKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciB1bmN1cnJ5VGhpcyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTcpOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSB1bmN1cnJ5VGhpcyh7fS5pc1Byb3RvdHlwZU9mKTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMjkgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBOQVRJVkVfU1lNQk9MID0gX193X3BkZmpzX3JlcXVpcmVfXygzMCk7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IE5BVElWRV9TWU1CT0wgJiYgIVN5bWJvbC5zaGFtICYmIHR5cGVvZiBTeW1ib2wuaXRlcmF0b3IgPT0gJ3N5bWJvbCc7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDMwICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgVjhfVkVSU0lPTiA9IF9fd19wZGZqc19yZXF1aXJlX18oMzEpOwogICAgICAgICAgICAgICAgdmFyIGZhaWxzID0gX193X3BkZmpzX3JlcXVpcmVfXygxMCk7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9ICEhT2JqZWN0LmdldE93blByb3BlcnR5U3ltYm9scyAmJiAhZmFpbHMoZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHZhciBzeW1ib2wgPSBTeW1ib2woKTsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gIVN0cmluZyhzeW1ib2wpIHx8ICEoT2JqZWN0KHN5bWJvbCkgaW5zdGFuY2VvZiBTeW1ib2wpIHx8ICFTeW1ib2wuc2hhbSAmJiBWOF9WRVJTSU9OICYmIFY4X1ZFUlNJT04gPCA0MTsKICAgICAgICAgICAgICAgIH0pOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAzMSAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIGdsb2JhbCA9IF9fd19wZGZqc19yZXF1aXJlX18oNyk7CiAgICAgICAgICAgICAgICB2YXIgdXNlckFnZW50ID0gX193X3BkZmpzX3JlcXVpcmVfXygzMik7CiAgICAgICAgICAgICAgICB2YXIgcHJvY2VzcyA9IGdsb2JhbC5wcm9jZXNzOwogICAgICAgICAgICAgICAgdmFyIERlbm8gPSBnbG9iYWwuRGVubzsKICAgICAgICAgICAgICAgIHZhciB2ZXJzaW9ucyA9IHByb2Nlc3MgJiYgcHJvY2Vzcy52ZXJzaW9ucyB8fCBEZW5vICYmIERlbm8udmVyc2lvbjsKICAgICAgICAgICAgICAgIHZhciB2OCA9IHZlcnNpb25zICYmIHZlcnNpb25zLnY4OwogICAgICAgICAgICAgICAgdmFyIG1hdGNoLCB2ZXJzaW9uOwogICAgICAgICAgICAgICAgaWYgKHY4KSB7CiAgICAgICAgICAgICAgICAgICAgbWF0Y2ggPSB2OC5zcGxpdCgnLicpOwogICAgICAgICAgICAgICAgICAgIHZlcnNpb24gPSBtYXRjaFswXSA+IDAgJiYgbWF0Y2hbMF0gPCA0ID8gMSA6ICsobWF0Y2hbMF0gKyBtYXRjaFsxXSk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBpZiAoIXZlcnNpb24gJiYgdXNlckFnZW50KSB7CiAgICAgICAgICAgICAgICAgICAgbWF0Y2ggPSB1c2VyQWdlbnQubWF0Y2goL0VkZ2VcLyhcZCspLyk7CiAgICAgICAgICAgICAgICAgICAgaWYgKCFtYXRjaCB8fCBtYXRjaFsxXSA+PSA3NCkgewogICAgICAgICAgICAgICAgICAgICAgICBtYXRjaCA9IHVzZXJBZ2VudC5tYXRjaCgvQ2hyb21lXC8oXGQrKS8pOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAobWF0Y2gpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2ZXJzaW9uID0gK21hdGNoWzFdOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gdmVyc2lvbjsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMzIgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUpID0+IHsKCiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IHR5cGVvZiBuYXZpZ2F0b3IgIT0gJ3VuZGVmaW5lZCcgJiYgU3RyaW5nKG5hdmlnYXRvci51c2VyQWdlbnQpIHx8ICcnOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAzMyAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIGFDYWxsYWJsZSA9IF9fd19wZGZqc19yZXF1aXJlX18oMzQpOwogICAgICAgICAgICAgICAgdmFyIGlzTnVsbE9yVW5kZWZpbmVkID0gX193X3BkZmpzX3JlcXVpcmVfXygyMCk7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uIChWLCBQKSB7CiAgICAgICAgICAgICAgICAgICAgdmFyIGZ1bmMgPSBWW1BdOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBpc051bGxPclVuZGVmaW5lZChmdW5jKSA/IHVuZGVmaW5lZCA6IGFDYWxsYWJsZShmdW5jKTsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDM0ICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgaXNDYWxsYWJsZSA9IF9fd19wZGZqc19yZXF1aXJlX18oMjQpOwogICAgICAgICAgICAgICAgdmFyIHRyeVRvU3RyaW5nID0gX193X3BkZmpzX3JlcXVpcmVfXygzNSk7CiAgICAgICAgICAgICAgICB2YXIgJFR5cGVFcnJvciA9IFR5cGVFcnJvcjsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKGFyZ3VtZW50KSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKGlzQ2FsbGFibGUoYXJndW1lbnQpKQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gYXJndW1lbnQ7CiAgICAgICAgICAgICAgICAgICAgdGhyb3cgJFR5cGVFcnJvcih0cnlUb1N0cmluZyhhcmd1bWVudCkgKyAnIGlzIG5vdCBhIGZ1bmN0aW9uJyk7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAzNSAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSkgPT4gewoKICAgICAgICAgICAgICAgIHZhciAkU3RyaW5nID0gU3RyaW5nOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoYXJndW1lbnQpIHsKICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gJFN0cmluZyhhcmd1bWVudCk7CiAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZXJyb3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICdPYmplY3QnOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDM2ICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgY2FsbCA9IF9fd19wZGZqc19yZXF1aXJlX18oMTEpOwogICAgICAgICAgICAgICAgdmFyIGlzQ2FsbGFibGUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDI0KTsKICAgICAgICAgICAgICAgIHZhciBpc09iamVjdCA9IF9fd19wZGZqc19yZXF1aXJlX18oMjMpOwogICAgICAgICAgICAgICAgdmFyICRUeXBlRXJyb3IgPSBUeXBlRXJyb3I7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uIChpbnB1dCwgcHJlZikgewogICAgICAgICAgICAgICAgICAgIHZhciBmbiwgdmFsOwogICAgICAgICAgICAgICAgICAgIGlmIChwcmVmID09PSAnc3RyaW5nJyAmJiBpc0NhbGxhYmxlKGZuID0gaW5wdXQudG9TdHJpbmcpICYmICFpc09iamVjdCh2YWwgPSBjYWxsKGZuLCBpbnB1dCkpKQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdmFsOwogICAgICAgICAgICAgICAgICAgIGlmIChpc0NhbGxhYmxlKGZuID0gaW5wdXQudmFsdWVPZikgJiYgIWlzT2JqZWN0KHZhbCA9IGNhbGwoZm4sIGlucHV0KSkpCiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB2YWw7CiAgICAgICAgICAgICAgICAgICAgaWYgKHByZWYgIT09ICdzdHJpbmcnICYmIGlzQ2FsbGFibGUoZm4gPSBpbnB1dC50b1N0cmluZykgJiYgIWlzT2JqZWN0KHZhbCA9IGNhbGwoZm4sIGlucHV0KSkpCiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB2YWw7CiAgICAgICAgICAgICAgICAgICAgdGhyb3cgJFR5cGVFcnJvcigiQ2FuJ3QgY29udmVydCBvYmplY3QgdG8gcHJpbWl0aXZlIHZhbHVlIik7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAzNyAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIGdsb2JhbCA9IF9fd19wZGZqc19yZXF1aXJlX18oNyk7CiAgICAgICAgICAgICAgICB2YXIgc2hhcmVkID0gX193X3BkZmpzX3JlcXVpcmVfXygzOCk7CiAgICAgICAgICAgICAgICB2YXIgaGFzT3duID0gX193X3BkZmpzX3JlcXVpcmVfXyg0Mik7CiAgICAgICAgICAgICAgICB2YXIgdWlkID0gX193X3BkZmpzX3JlcXVpcmVfXyg0NCk7CiAgICAgICAgICAgICAgICB2YXIgTkFUSVZFX1NZTUJPTCA9IF9fd19wZGZqc19yZXF1aXJlX18oMzApOwogICAgICAgICAgICAgICAgdmFyIFVTRV9TWU1CT0xfQVNfVUlEID0gX193X3BkZmpzX3JlcXVpcmVfXygyOSk7CiAgICAgICAgICAgICAgICB2YXIgU3ltYm9sID0gZ2xvYmFsLlN5bWJvbDsKICAgICAgICAgICAgICAgIHZhciBXZWxsS25vd25TeW1ib2xzU3RvcmUgPSBzaGFyZWQoJ3drcycpOwogICAgICAgICAgICAgICAgdmFyIGNyZWF0ZVdlbGxLbm93blN5bWJvbCA9IFVTRV9TWU1CT0xfQVNfVUlEID8gU3ltYm9sWydmb3InXSB8fCBTeW1ib2wgOiBTeW1ib2wgJiYgU3ltYm9sLndpdGhvdXRTZXR0ZXIgfHwgdWlkOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAobmFtZSkgewogICAgICAgICAgICAgICAgICAgIGlmICghaGFzT3duKFdlbGxLbm93blN5bWJvbHNTdG9yZSwgbmFtZSkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgV2VsbEtub3duU3ltYm9sc1N0b3JlW25hbWVdID0gTkFUSVZFX1NZTUJPTCAmJiBoYXNPd24oU3ltYm9sLCBuYW1lKSA/IFN5bWJvbFtuYW1lXSA6IGNyZWF0ZVdlbGxLbm93blN5bWJvbCgnU3ltYm9sLicgKyBuYW1lKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFdlbGxLbm93blN5bWJvbHNTdG9yZVtuYW1lXTsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDM4ICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgSVNfUFVSRSA9IF9fd19wZGZqc19yZXF1aXJlX18oMzkpOwogICAgICAgICAgICAgICAgdmFyIHN0b3JlID0gX193X3BkZmpzX3JlcXVpcmVfXyg0MCk7CiAgICAgICAgICAgICAgICAobW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoa2V5LCB2YWx1ZSkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBzdG9yZVtrZXldIHx8IChzdG9yZVtrZXldID0gdmFsdWUgIT09IHVuZGVmaW5lZCA/IHZhbHVlIDoge30pOwogICAgICAgICAgICAgICAgfSkoJ3ZlcnNpb25zJywgW10pLnB1c2goewogICAgICAgICAgICAgICAgICAgIHZlcnNpb246ICczLjI5LjEnLAogICAgICAgICAgICAgICAgICAgIG1vZGU6IElTX1BVUkUgPyAncHVyZScgOiAnZ2xvYmFsJywKICAgICAgICAgICAgICAgICAgICBjb3B5cmlnaHQ6ICfCqSAyMDE0LTIwMjMgRGVuaXMgUHVzaGthcmV2ICh6bG9pcm9jay5ydSknLAogICAgICAgICAgICAgICAgICAgIGxpY2Vuc2U6ICdodHRwczovL2dpdGh1Yi5jb20vemxvaXJvY2svY29yZS1qcy9ibG9iL3YzLjI5LjEvTElDRU5TRScsCiAgICAgICAgICAgICAgICAgICAgc291cmNlOiAnaHR0cHM6Ly9naXRodWIuY29tL3psb2lyb2NrL2NvcmUtanMnCiAgICAgICAgICAgICAgICB9KTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMzkgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUpID0+IHsKCiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IGZhbHNlOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiA0MCAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIGdsb2JhbCA9IF9fd19wZGZqc19yZXF1aXJlX18oNyk7CiAgICAgICAgICAgICAgICB2YXIgZGVmaW5lR2xvYmFsUHJvcGVydHkgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDQxKTsKICAgICAgICAgICAgICAgIHZhciBTSEFSRUQgPSAnX19jb3JlLWpzX3NoYXJlZF9fJzsKICAgICAgICAgICAgICAgIHZhciBzdG9yZSA9IGdsb2JhbFtTSEFSRURdIHx8IGRlZmluZUdsb2JhbFByb3BlcnR5KFNIQVJFRCwge30pOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBzdG9yZTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogNDEgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBnbG9iYWwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDcpOwogICAgICAgICAgICAgICAgdmFyIGRlZmluZVByb3BlcnR5ID0gT2JqZWN0LmRlZmluZVByb3BlcnR5OwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoa2V5LCB2YWx1ZSkgewogICAgICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGRlZmluZVByb3BlcnR5KGdsb2JhbCwga2V5LCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdmFsdWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIChlcnJvcikgewogICAgICAgICAgICAgICAgICAgICAgICBnbG9iYWxba2V5XSA9IHZhbHVlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gdmFsdWU7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiA0MiAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIHVuY3VycnlUaGlzID0gX193X3BkZmpzX3JlcXVpcmVfXygxNyk7CiAgICAgICAgICAgICAgICB2YXIgdG9PYmplY3QgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDQzKTsKICAgICAgICAgICAgICAgIHZhciBoYXNPd25Qcm9wZXJ0eSA9IHVuY3VycnlUaGlzKHt9Lmhhc093blByb3BlcnR5KTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gT2JqZWN0Lmhhc093biB8fCBmdW5jdGlvbiBoYXNPd24oaXQsIGtleSkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBoYXNPd25Qcm9wZXJ0eSh0b09iamVjdChpdCksIGtleSk7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiA0MyAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIHJlcXVpcmVPYmplY3RDb2VyY2libGUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE5KTsKICAgICAgICAgICAgICAgIHZhciAkT2JqZWN0ID0gT2JqZWN0OwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoYXJndW1lbnQpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gJE9iamVjdChyZXF1aXJlT2JqZWN0Q29lcmNpYmxlKGFyZ3VtZW50KSk7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiA0NCAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIHVuY3VycnlUaGlzID0gX193X3BkZmpzX3JlcXVpcmVfXygxNyk7CiAgICAgICAgICAgICAgICB2YXIgaWQgPSAwOwogICAgICAgICAgICAgICAgdmFyIHBvc3RmaXggPSBNYXRoLnJhbmRvbSgpOwogICAgICAgICAgICAgICAgdmFyIHRvU3RyaW5nID0gdW5jdXJyeVRoaXMoMS4wLnRvU3RyaW5nKTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKGtleSkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiAnU3ltYm9sKCcgKyAoa2V5ID09PSB1bmRlZmluZWQgPyAnJyA6IGtleSkgKyAnKV8nICsgdG9TdHJpbmcoKytpZCArIHBvc3RmaXgsIDM2KTsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDQ1ICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgREVTQ1JJUFRPUlMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDkpOwogICAgICAgICAgICAgICAgdmFyIGZhaWxzID0gX193X3BkZmpzX3JlcXVpcmVfXygxMCk7CiAgICAgICAgICAgICAgICB2YXIgY3JlYXRlRWxlbWVudCA9IF9fd19wZGZqc19yZXF1aXJlX18oNDYpOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSAhREVTQ1JJUFRPUlMgJiYgIWZhaWxzKGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gT2JqZWN0LmRlZmluZVByb3BlcnR5KGNyZWF0ZUVsZW1lbnQoJ2RpdicpLCAnYScsIHsKICAgICAgICAgICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gNzsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0pLmEgIT0gNzsKICAgICAgICAgICAgICAgIH0pOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiA0NiAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIGdsb2JhbCA9IF9fd19wZGZqc19yZXF1aXJlX18oNyk7CiAgICAgICAgICAgICAgICB2YXIgaXNPYmplY3QgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDIzKTsKICAgICAgICAgICAgICAgIHZhciBkb2N1bWVudCA9IGdsb2JhbC5kb2N1bWVudDsKICAgICAgICAgICAgICAgIHZhciBFWElTVFMgPSBpc09iamVjdChkb2N1bWVudCkgJiYgaXNPYmplY3QoZG9jdW1lbnQuY3JlYXRlRWxlbWVudCk7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uIChpdCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBFWElTVFMgPyBkb2N1bWVudC5jcmVhdGVFbGVtZW50KGl0KSA6IHt9OwogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogNDcgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBERVNDUklQVE9SUyA9IF9fd19wZGZqc19yZXF1aXJlX18oOSk7CiAgICAgICAgICAgICAgICB2YXIgZGVmaW5lUHJvcGVydHlNb2R1bGUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDQ4KTsKICAgICAgICAgICAgICAgIHZhciBjcmVhdGVQcm9wZXJ0eURlc2NyaXB0b3IgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE0KTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gREVTQ1JJUFRPUlMgPyBmdW5jdGlvbiAob2JqZWN0LCBrZXksIHZhbHVlKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGRlZmluZVByb3BlcnR5TW9kdWxlLmYob2JqZWN0LCBrZXksIGNyZWF0ZVByb3BlcnR5RGVzY3JpcHRvcigxLCB2YWx1ZSkpOwogICAgICAgICAgICAgICAgfSA6IGZ1bmN0aW9uIChvYmplY3QsIGtleSwgdmFsdWUpIHsKICAgICAgICAgICAgICAgICAgICBvYmplY3Rba2V5XSA9IHZhbHVlOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBvYmplY3Q7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiA0OCAqLwogICAgICAgICAgICAvKioqLyAoKF9fdW51c2VkX3dlYnBhY2tfbW9kdWxlLCBleHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIERFU0NSSVBUT1JTID0gX193X3BkZmpzX3JlcXVpcmVfXyg5KTsKICAgICAgICAgICAgICAgIHZhciBJRThfRE9NX0RFRklORSA9IF9fd19wZGZqc19yZXF1aXJlX18oNDUpOwogICAgICAgICAgICAgICAgdmFyIFY4X1BST1RPVFlQRV9ERUZJTkVfQlVHID0gX193X3BkZmpzX3JlcXVpcmVfXyg0OSk7CiAgICAgICAgICAgICAgICB2YXIgYW5PYmplY3QgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDUwKTsKICAgICAgICAgICAgICAgIHZhciB0b1Byb3BlcnR5S2V5ID0gX193X3BkZmpzX3JlcXVpcmVfXygyMSk7CiAgICAgICAgICAgICAgICB2YXIgJFR5cGVFcnJvciA9IFR5cGVFcnJvcjsKICAgICAgICAgICAgICAgIHZhciAkZGVmaW5lUHJvcGVydHkgPSBPYmplY3QuZGVmaW5lUHJvcGVydHk7CiAgICAgICAgICAgICAgICB2YXIgJGdldE93blByb3BlcnR5RGVzY3JpcHRvciA9IE9iamVjdC5nZXRPd25Qcm9wZXJ0eURlc2NyaXB0b3I7CiAgICAgICAgICAgICAgICB2YXIgRU5VTUVSQUJMRSA9ICdlbnVtZXJhYmxlJzsKICAgICAgICAgICAgICAgIHZhciBDT05GSUdVUkFCTEUgPSAnY29uZmlndXJhYmxlJzsKICAgICAgICAgICAgICAgIHZhciBXUklUQUJMRSA9ICd3cml0YWJsZSc7CiAgICAgICAgICAgICAgICBleHBvcnRzLmYgPSBERVNDUklQVE9SUyA/IFY4X1BST1RPVFlQRV9ERUZJTkVfQlVHID8gZnVuY3Rpb24gZGVmaW5lUHJvcGVydHkoTywgUCwgQXR0cmlidXRlcykgewogICAgICAgICAgICAgICAgICAgIGFuT2JqZWN0KE8pOwogICAgICAgICAgICAgICAgICAgIFAgPSB0b1Byb3BlcnR5S2V5KFApOwogICAgICAgICAgICAgICAgICAgIGFuT2JqZWN0KEF0dHJpYnV0ZXMpOwogICAgICAgICAgICAgICAgICAgIGlmICh0eXBlb2YgTyA9PT0gJ2Z1bmN0aW9uJyAmJiBQID09PSAncHJvdG90eXBlJyAmJiAndmFsdWUnIGluIEF0dHJpYnV0ZXMgJiYgV1JJVEFCTEUgaW4gQXR0cmlidXRlcyAmJiAhQXR0cmlidXRlc1tXUklUQUJMRV0pIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGN1cnJlbnQgPSAkZ2V0T3duUHJvcGVydHlEZXNjcmlwdG9yKE8sIFApOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoY3VycmVudCAmJiBjdXJyZW50W1dSSVRBQkxFXSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgT1tQXSA9IEF0dHJpYnV0ZXMudmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBBdHRyaWJ1dGVzID0gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogQ09ORklHVVJBQkxFIGluIEF0dHJpYnV0ZXMgPyBBdHRyaWJ1dGVzW0NPTkZJR1VSQUJMRV0gOiBjdXJyZW50W0NPTkZJR1VSQUJMRV0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZW51bWVyYWJsZTogRU5VTUVSQUJMRSBpbiBBdHRyaWJ1dGVzID8gQXR0cmlidXRlc1tFTlVNRVJBQkxFXSA6IGN1cnJlbnRbRU5VTUVSQUJMRV0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IGZhbHNlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJldHVybiAkZGVmaW5lUHJvcGVydHkoTywgUCwgQXR0cmlidXRlcyk7CiAgICAgICAgICAgICAgICB9IDogJGRlZmluZVByb3BlcnR5IDogZnVuY3Rpb24gZGVmaW5lUHJvcGVydHkoTywgUCwgQXR0cmlidXRlcykgewogICAgICAgICAgICAgICAgICAgIGFuT2JqZWN0KE8pOwogICAgICAgICAgICAgICAgICAgIFAgPSB0b1Byb3BlcnR5S2V5KFApOwogICAgICAgICAgICAgICAgICAgIGFuT2JqZWN0KEF0dHJpYnV0ZXMpOwogICAgICAgICAgICAgICAgICAgIGlmIChJRThfRE9NX0RFRklORSkKICAgICAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAkZGVmaW5lUHJvcGVydHkoTywgUCwgQXR0cmlidXRlcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBpZiAoJ2dldCcgaW4gQXR0cmlidXRlcyB8fCAnc2V0JyBpbiBBdHRyaWJ1dGVzKQogICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyAkVHlwZUVycm9yKCdBY2Nlc3NvcnMgbm90IHN1cHBvcnRlZCcpOwogICAgICAgICAgICAgICAgICAgIGlmICgndmFsdWUnIGluIEF0dHJpYnV0ZXMpCiAgICAgICAgICAgICAgICAgICAgICAgIE9bUF0gPSBBdHRyaWJ1dGVzLnZhbHVlOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBPOwogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogNDkgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBERVNDUklQVE9SUyA9IF9fd19wZGZqc19yZXF1aXJlX18oOSk7CiAgICAgICAgICAgICAgICB2YXIgZmFpbHMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEwKTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gREVTQ1JJUFRPUlMgJiYgZmFpbHMoZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBPYmplY3QuZGVmaW5lUHJvcGVydHkoZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIH0sICdwcm90b3R5cGUnLCB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiA0MiwKICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IGZhbHNlCiAgICAgICAgICAgICAgICAgICAgfSkucHJvdG90eXBlICE9IDQyOwogICAgICAgICAgICAgICAgfSk7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDUwICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgaXNPYmplY3QgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDIzKTsKICAgICAgICAgICAgICAgIHZhciAkU3RyaW5nID0gU3RyaW5nOwogICAgICAgICAgICAgICAgdmFyICRUeXBlRXJyb3IgPSBUeXBlRXJyb3I7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uIChhcmd1bWVudCkgewogICAgICAgICAgICAgICAgICAgIGlmIChpc09iamVjdChhcmd1bWVudCkpCiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBhcmd1bWVudDsKICAgICAgICAgICAgICAgICAgICB0aHJvdyAkVHlwZUVycm9yKCRTdHJpbmcoYXJndW1lbnQpICsgJyBpcyBub3QgYW4gb2JqZWN0Jyk7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiA1MSAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIGlzQ2FsbGFibGUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDI0KTsKICAgICAgICAgICAgICAgIHZhciBkZWZpbmVQcm9wZXJ0eU1vZHVsZSA9IF9fd19wZGZqc19yZXF1aXJlX18oNDgpOwogICAgICAgICAgICAgICAgdmFyIG1ha2VCdWlsdEluID0gX193X3BkZmpzX3JlcXVpcmVfXyg1Mik7CiAgICAgICAgICAgICAgICB2YXIgZGVmaW5lR2xvYmFsUHJvcGVydHkgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDQxKTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKE8sIGtleSwgdmFsdWUsIG9wdGlvbnMpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoIW9wdGlvbnMpCiAgICAgICAgICAgICAgICAgICAgICAgIG9wdGlvbnMgPSB7fTsKICAgICAgICAgICAgICAgICAgICB2YXIgc2ltcGxlID0gb3B0aW9ucy5lbnVtZXJhYmxlOwogICAgICAgICAgICAgICAgICAgIHZhciBuYW1lID0gb3B0aW9ucy5uYW1lICE9PSB1bmRlZmluZWQgPyBvcHRpb25zLm5hbWUgOiBrZXk7CiAgICAgICAgICAgICAgICAgICAgaWYgKGlzQ2FsbGFibGUodmFsdWUpKQogICAgICAgICAgICAgICAgICAgICAgICBtYWtlQnVpbHRJbih2YWx1ZSwgbmFtZSwgb3B0aW9ucyk7CiAgICAgICAgICAgICAgICAgICAgaWYgKG9wdGlvbnMuZ2xvYmFsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChzaW1wbGUpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBPW2tleV0gPSB2YWx1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgZWxzZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVmaW5lR2xvYmFsUHJvcGVydHkoa2V5LCB2YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghb3B0aW9ucy51bnNhZmUpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVsZXRlIE9ba2V5XTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsc2UgaWYgKE9ba2V5XSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzaW1wbGUgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIChlcnJvcikgewogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChzaW1wbGUpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBPW2tleV0gPSB2YWx1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgZWxzZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVmaW5lUHJvcGVydHlNb2R1bGUuZihPLCBrZXksIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdmFsdWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZW51bWVyYWJsZTogZmFsc2UsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uZmlndXJhYmxlOiAhb3B0aW9ucy5ub25Db25maWd1cmFibGUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6ICFvcHRpb25zLm5vbldyaXRhYmxlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIE87CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiA1MiAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIHVuY3VycnlUaGlzID0gX193X3BkZmpzX3JlcXVpcmVfXygxNyk7CiAgICAgICAgICAgICAgICB2YXIgZmFpbHMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEwKTsKICAgICAgICAgICAgICAgIHZhciBpc0NhbGxhYmxlID0gX193X3BkZmpzX3JlcXVpcmVfXygyNCk7CiAgICAgICAgICAgICAgICB2YXIgaGFzT3duID0gX193X3BkZmpzX3JlcXVpcmVfXyg0Mik7CiAgICAgICAgICAgICAgICB2YXIgREVTQ1JJUFRPUlMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDkpOwogICAgICAgICAgICAgICAgdmFyIENPTkZJR1VSQUJMRV9GVU5DVElPTl9OQU1FID0gKF9fd19wZGZqc19yZXF1aXJlX18oNTMpLkNPTkZJR1VSQUJMRSk7CiAgICAgICAgICAgICAgICB2YXIgaW5zcGVjdFNvdXJjZSA9IF9fd19wZGZqc19yZXF1aXJlX18oNTQpOwogICAgICAgICAgICAgICAgdmFyIEludGVybmFsU3RhdGVNb2R1bGUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDU1KTsKICAgICAgICAgICAgICAgIHZhciBlbmZvcmNlSW50ZXJuYWxTdGF0ZSA9IEludGVybmFsU3RhdGVNb2R1bGUuZW5mb3JjZTsKICAgICAgICAgICAgICAgIHZhciBnZXRJbnRlcm5hbFN0YXRlID0gSW50ZXJuYWxTdGF0ZU1vZHVsZS5nZXQ7CiAgICAgICAgICAgICAgICB2YXIgJFN0cmluZyA9IFN0cmluZzsKICAgICAgICAgICAgICAgIHZhciBkZWZpbmVQcm9wZXJ0eSA9IE9iamVjdC5kZWZpbmVQcm9wZXJ0eTsKICAgICAgICAgICAgICAgIHZhciBzdHJpbmdTbGljZSA9IHVuY3VycnlUaGlzKCcnLnNsaWNlKTsKICAgICAgICAgICAgICAgIHZhciByZXBsYWNlID0gdW5jdXJyeVRoaXMoJycucmVwbGFjZSk7CiAgICAgICAgICAgICAgICB2YXIgam9pbiA9IHVuY3VycnlUaGlzKFtdLmpvaW4pOwogICAgICAgICAgICAgICAgdmFyIENPTkZJR1VSQUJMRV9MRU5HVEggPSBERVNDUklQVE9SUyAmJiAhZmFpbHMoZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBkZWZpbmVQcm9wZXJ0eShmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgfSwgJ2xlbmd0aCcsIHsgdmFsdWU6IDggfSkubGVuZ3RoICE9PSA4OwogICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICB2YXIgVEVNUExBVEUgPSBTdHJpbmcoU3RyaW5nKS5zcGxpdCgnU3RyaW5nJyk7CiAgICAgICAgICAgICAgICB2YXIgbWFrZUJ1aWx0SW4gPSBtb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uICh2YWx1ZSwgbmFtZSwgb3B0aW9ucykgewogICAgICAgICAgICAgICAgICAgIGlmIChzdHJpbmdTbGljZSgkU3RyaW5nKG5hbWUpLCAwLCA3KSA9PT0gJ1N5bWJvbCgnKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIG5hbWUgPSAnWycgKyByZXBsYWNlKCRTdHJpbmcobmFtZSksIC9eU3ltYm9sXCgoW14pXSopXCkvLCAnJDEnKSArICddJzsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaWYgKG9wdGlvbnMgJiYgb3B0aW9ucy5nZXR0ZXIpCiAgICAgICAgICAgICAgICAgICAgICAgIG5hbWUgPSAnZ2V0ICcgKyBuYW1lOwogICAgICAgICAgICAgICAgICAgIGlmIChvcHRpb25zICYmIG9wdGlvbnMuc2V0dGVyKQogICAgICAgICAgICAgICAgICAgICAgICBuYW1lID0gJ3NldCAnICsgbmFtZTsKICAgICAgICAgICAgICAgICAgICBpZiAoIWhhc093bih2YWx1ZSwgJ25hbWUnKSB8fCBDT05GSUdVUkFCTEVfRlVOQ1RJT05fTkFNRSAmJiB2YWx1ZS5uYW1lICE9PSBuYW1lKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChERVNDUklQVE9SUykKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlZmluZVByb3BlcnR5KHZhbHVlLCAnbmFtZScsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogbmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBlbHNlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZS5uYW1lID0gbmFtZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaWYgKENPTkZJR1VSQUJMRV9MRU5HVEggJiYgb3B0aW9ucyAmJiBoYXNPd24ob3B0aW9ucywgJ2FyaXR5JykgJiYgdmFsdWUubGVuZ3RoICE9PSBvcHRpb25zLmFyaXR5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGRlZmluZVByb3BlcnR5KHZhbHVlLCAnbGVuZ3RoJywgeyB2YWx1ZTogb3B0aW9ucy5hcml0eSB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG9wdGlvbnMgJiYgaGFzT3duKG9wdGlvbnMsICdjb25zdHJ1Y3RvcicpICYmIG9wdGlvbnMuY29uc3RydWN0b3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChERVNDUklQVE9SUykKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZpbmVQcm9wZXJ0eSh2YWx1ZSwgJ3Byb3RvdHlwZScsIHsgd3JpdGFibGU6IGZhbHNlIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHZhbHVlLnByb3RvdHlwZSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlLnByb3RvdHlwZSA9IHVuZGVmaW5lZDsKICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIChlcnJvcikgewogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB2YXIgc3RhdGUgPSBlbmZvcmNlSW50ZXJuYWxTdGF0ZSh2YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgaWYgKCFoYXNPd24oc3RhdGUsICdzb3VyY2UnKSkgewogICAgICAgICAgICAgICAgICAgICAgICBzdGF0ZS5zb3VyY2UgPSBqb2luKFRFTVBMQVRFLCB0eXBlb2YgbmFtZSA9PSAnc3RyaW5nJyA/IG5hbWUgOiAnJyk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJldHVybiB2YWx1ZTsKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBGdW5jdGlvbi5wcm90b3R5cGUudG9TdHJpbmcgPSBtYWtlQnVpbHRJbihmdW5jdGlvbiB0b1N0cmluZygpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gaXNDYWxsYWJsZSh0aGlzKSAmJiBnZXRJbnRlcm5hbFN0YXRlKHRoaXMpLnNvdXJjZSB8fCBpbnNwZWN0U291cmNlKHRoaXMpOwogICAgICAgICAgICAgICAgfSwgJ3RvU3RyaW5nJyk7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDUzICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgREVTQ1JJUFRPUlMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDkpOwogICAgICAgICAgICAgICAgdmFyIGhhc093biA9IF9fd19wZGZqc19yZXF1aXJlX18oNDIpOwogICAgICAgICAgICAgICAgdmFyIEZ1bmN0aW9uUHJvdG90eXBlID0gRnVuY3Rpb24ucHJvdG90eXBlOwogICAgICAgICAgICAgICAgdmFyIGdldERlc2NyaXB0b3IgPSBERVNDUklQVE9SUyAmJiBPYmplY3QuZ2V0T3duUHJvcGVydHlEZXNjcmlwdG9yOwogICAgICAgICAgICAgICAgdmFyIEVYSVNUUyA9IGhhc093bihGdW5jdGlvblByb3RvdHlwZSwgJ25hbWUnKTsKICAgICAgICAgICAgICAgIHZhciBQUk9QRVIgPSBFWElTVFMgJiYgZnVuY3Rpb24gc29tZXRoaW5nKCkgewogICAgICAgICAgICAgICAgfS5uYW1lID09PSAnc29tZXRoaW5nJzsKICAgICAgICAgICAgICAgIHZhciBDT05GSUdVUkFCTEUgPSBFWElTVFMgJiYgKCFERVNDUklQVE9SUyB8fCBERVNDUklQVE9SUyAmJiBnZXREZXNjcmlwdG9yKEZ1bmN0aW9uUHJvdG90eXBlLCAnbmFtZScpLmNvbmZpZ3VyYWJsZSk7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IHsKICAgICAgICAgICAgICAgICAgICBFWElTVFM6IEVYSVNUUywKICAgICAgICAgICAgICAgICAgICBQUk9QRVI6IFBST1BFUiwKICAgICAgICAgICAgICAgICAgICBDT05GSUdVUkFCTEU6IENPTkZJR1VSQUJMRQogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogNTQgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciB1bmN1cnJ5VGhpcyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTcpOwogICAgICAgICAgICAgICAgdmFyIGlzQ2FsbGFibGUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDI0KTsKICAgICAgICAgICAgICAgIHZhciBzdG9yZSA9IF9fd19wZGZqc19yZXF1aXJlX18oNDApOwogICAgICAgICAgICAgICAgdmFyIGZ1bmN0aW9uVG9TdHJpbmcgPSB1bmN1cnJ5VGhpcyhGdW5jdGlvbi50b1N0cmluZyk7CiAgICAgICAgICAgICAgICBpZiAoIWlzQ2FsbGFibGUoc3RvcmUuaW5zcGVjdFNvdXJjZSkpIHsKICAgICAgICAgICAgICAgICAgICBzdG9yZS5pbnNwZWN0U291cmNlID0gZnVuY3Rpb24gKGl0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmdW5jdGlvblRvU3RyaW5nKGl0KTsKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBzdG9yZS5pbnNwZWN0U291cmNlOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiA1NSAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIE5BVElWRV9XRUFLX01BUCA9IF9fd19wZGZqc19yZXF1aXJlX18oNTYpOwogICAgICAgICAgICAgICAgdmFyIGdsb2JhbCA9IF9fd19wZGZqc19yZXF1aXJlX18oNyk7CiAgICAgICAgICAgICAgICB2YXIgaXNPYmplY3QgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDIzKTsKICAgICAgICAgICAgICAgIHZhciBjcmVhdGVOb25FbnVtZXJhYmxlUHJvcGVydHkgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDQ3KTsKICAgICAgICAgICAgICAgIHZhciBoYXNPd24gPSBfX3dfcGRmanNfcmVxdWlyZV9fKDQyKTsKICAgICAgICAgICAgICAgIHZhciBzaGFyZWQgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDQwKTsKICAgICAgICAgICAgICAgIHZhciBzaGFyZWRLZXkgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDU3KTsKICAgICAgICAgICAgICAgIHZhciBoaWRkZW5LZXlzID0gX193X3BkZmpzX3JlcXVpcmVfXyg1OCk7CiAgICAgICAgICAgICAgICB2YXIgT0JKRUNUX0FMUkVBRFlfSU5JVElBTElaRUQgPSAnT2JqZWN0IGFscmVhZHkgaW5pdGlhbGl6ZWQnOwogICAgICAgICAgICAgICAgdmFyIFR5cGVFcnJvciA9IGdsb2JhbC5UeXBlRXJyb3I7CiAgICAgICAgICAgICAgICB2YXIgV2Vha01hcCA9IGdsb2JhbC5XZWFrTWFwOwogICAgICAgICAgICAgICAgdmFyIHNldCwgZ2V0LCBoYXM7CiAgICAgICAgICAgICAgICB2YXIgZW5mb3JjZSA9IGZ1bmN0aW9uIChpdCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBoYXMoaXQpID8gZ2V0KGl0KSA6IHNldChpdCwge30pOwogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIHZhciBnZXR0ZXJGb3IgPSBmdW5jdGlvbiAoVFlQRSkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBmdW5jdGlvbiAoaXQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHN0YXRlOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWlzT2JqZWN0KGl0KSB8fCAoc3RhdGUgPSBnZXQoaXQpKS50eXBlICE9PSBUWVBFKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBUeXBlRXJyb3IoJ0luY29tcGF0aWJsZSByZWNlaXZlciwgJyArIFRZUEUgKyAnIHJlcXVpcmVkJyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHN0YXRlOwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgaWYgKE5BVElWRV9XRUFLX01BUCB8fCBzaGFyZWQuc3RhdGUpIHsKICAgICAgICAgICAgICAgICAgICB2YXIgc3RvcmUgPSBzaGFyZWQuc3RhdGUgfHwgKHNoYXJlZC5zdGF0ZSA9IG5ldyBXZWFrTWFwKCkpOwogICAgICAgICAgICAgICAgICAgIHN0b3JlLmdldCA9IHN0b3JlLmdldDsKICAgICAgICAgICAgICAgICAgICBzdG9yZS5oYXMgPSBzdG9yZS5oYXM7CiAgICAgICAgICAgICAgICAgICAgc3RvcmUuc2V0ID0gc3RvcmUuc2V0OwogICAgICAgICAgICAgICAgICAgIHNldCA9IGZ1bmN0aW9uIChpdCwgbWV0YWRhdGEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHN0b3JlLmhhcyhpdCkpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBUeXBlRXJyb3IoT0JKRUNUX0FMUkVBRFlfSU5JVElBTElaRUQpOwogICAgICAgICAgICAgICAgICAgICAgICBtZXRhZGF0YS5mYWNhZGUgPSBpdDsKICAgICAgICAgICAgICAgICAgICAgICAgc3RvcmUuc2V0KGl0LCBtZXRhZGF0YSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBtZXRhZGF0YTsKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIGdldCA9IGZ1bmN0aW9uIChpdCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gc3RvcmUuZ2V0KGl0KSB8fCB7fTsKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIGhhcyA9IGZ1bmN0aW9uIChpdCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gc3RvcmUuaGFzKGl0KTsKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICB2YXIgU1RBVEUgPSBzaGFyZWRLZXkoJ3N0YXRlJyk7CiAgICAgICAgICAgICAgICAgICAgaGlkZGVuS2V5c1tTVEFURV0gPSB0cnVlOwogICAgICAgICAgICAgICAgICAgIHNldCA9IGZ1bmN0aW9uIChpdCwgbWV0YWRhdGEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGhhc093bihpdCwgU1RBVEUpKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgVHlwZUVycm9yKE9CSkVDVF9BTFJFQURZX0lOSVRJQUxJWkVEKTsKICAgICAgICAgICAgICAgICAgICAgICAgbWV0YWRhdGEuZmFjYWRlID0gaXQ7CiAgICAgICAgICAgICAgICAgICAgICAgIGNyZWF0ZU5vbkVudW1lcmFibGVQcm9wZXJ0eShpdCwgU1RBVEUsIG1ldGFkYXRhKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG1ldGFkYXRhOwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgZ2V0ID0gZnVuY3Rpb24gKGl0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBoYXNPd24oaXQsIFNUQVRFKSA/IGl0W1NUQVRFXSA6IHt9OwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgaGFzID0gZnVuY3Rpb24gKGl0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBoYXNPd24oaXQsIFNUQVRFKTsKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSB7CiAgICAgICAgICAgICAgICAgICAgc2V0OiBzZXQsCiAgICAgICAgICAgICAgICAgICAgZ2V0OiBnZXQsCiAgICAgICAgICAgICAgICAgICAgaGFzOiBoYXMsCiAgICAgICAgICAgICAgICAgICAgZW5mb3JjZTogZW5mb3JjZSwKICAgICAgICAgICAgICAgICAgICBnZXR0ZXJGb3I6IGdldHRlckZvcgogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogNTYgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBnbG9iYWwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDcpOwogICAgICAgICAgICAgICAgdmFyIGlzQ2FsbGFibGUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDI0KTsKICAgICAgICAgICAgICAgIHZhciBXZWFrTWFwID0gZ2xvYmFsLldlYWtNYXA7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IGlzQ2FsbGFibGUoV2Vha01hcCkgJiYgL25hdGl2ZSBjb2RlLy50ZXN0KFN0cmluZyhXZWFrTWFwKSk7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDU3ICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgc2hhcmVkID0gX193X3BkZmpzX3JlcXVpcmVfXygzOCk7CiAgICAgICAgICAgICAgICB2YXIgdWlkID0gX193X3BkZmpzX3JlcXVpcmVfXyg0NCk7CiAgICAgICAgICAgICAgICB2YXIga2V5cyA9IHNoYXJlZCgna2V5cycpOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoa2V5KSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGtleXNba2V5XSB8fCAoa2V5c1trZXldID0gdWlkKGtleSkpOwogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogNTggKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUpID0+IHsKCiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IHt9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiA1OSAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIGhhc093biA9IF9fd19wZGZqc19yZXF1aXJlX18oNDIpOwogICAgICAgICAgICAgICAgdmFyIG93bktleXMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDYwKTsKICAgICAgICAgICAgICAgIHZhciBnZXRPd25Qcm9wZXJ0eURlc2NyaXB0b3JNb2R1bGUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDgpOwogICAgICAgICAgICAgICAgdmFyIGRlZmluZVByb3BlcnR5TW9kdWxlID0gX193X3BkZmpzX3JlcXVpcmVfXyg0OCk7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uICh0YXJnZXQsIHNvdXJjZSwgZXhjZXB0aW9ucykgewogICAgICAgICAgICAgICAgICAgIHZhciBrZXlzID0gb3duS2V5cyhzb3VyY2UpOwogICAgICAgICAgICAgICAgICAgIHZhciBkZWZpbmVQcm9wZXJ0eSA9IGRlZmluZVByb3BlcnR5TW9kdWxlLmY7CiAgICAgICAgICAgICAgICAgICAgdmFyIGdldE93blByb3BlcnR5RGVzY3JpcHRvciA9IGdldE93blByb3BlcnR5RGVzY3JpcHRvck1vZHVsZS5mOwogICAgICAgICAgICAgICAgICAgIGZvciAodmFyIGkgPSAwOyBpIDwga2V5cy5sZW5ndGg7IGkrKykgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIga2V5ID0ga2V5c1tpXTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFoYXNPd24odGFyZ2V0LCBrZXkpICYmICEoZXhjZXB0aW9ucyAmJiBoYXNPd24oZXhjZXB0aW9ucywga2V5KSkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlZmluZVByb3BlcnR5KHRhcmdldCwga2V5LCBnZXRPd25Qcm9wZXJ0eURlc2NyaXB0b3Ioc291cmNlLCBrZXkpKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDYwICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgZ2V0QnVpbHRJbiA9IF9fd19wZGZqc19yZXF1aXJlX18oMjcpOwogICAgICAgICAgICAgICAgdmFyIHVuY3VycnlUaGlzID0gX193X3BkZmpzX3JlcXVpcmVfXygxNyk7CiAgICAgICAgICAgICAgICB2YXIgZ2V0T3duUHJvcGVydHlOYW1lc01vZHVsZSA9IF9fd19wZGZqc19yZXF1aXJlX18oNjEpOwogICAgICAgICAgICAgICAgdmFyIGdldE93blByb3BlcnR5U3ltYm9sc01vZHVsZSA9IF9fd19wZGZqc19yZXF1aXJlX18oNzApOwogICAgICAgICAgICAgICAgdmFyIGFuT2JqZWN0ID0gX193X3BkZmpzX3JlcXVpcmVfXyg1MCk7CiAgICAgICAgICAgICAgICB2YXIgY29uY2F0ID0gdW5jdXJyeVRoaXMoW10uY29uY2F0KTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZ2V0QnVpbHRJbignUmVmbGVjdCcsICdvd25LZXlzJykgfHwgZnVuY3Rpb24gb3duS2V5cyhpdCkgewogICAgICAgICAgICAgICAgICAgIHZhciBrZXlzID0gZ2V0T3duUHJvcGVydHlOYW1lc01vZHVsZS5mKGFuT2JqZWN0KGl0KSk7CiAgICAgICAgICAgICAgICAgICAgdmFyIGdldE93blByb3BlcnR5U3ltYm9scyA9IGdldE93blByb3BlcnR5U3ltYm9sc01vZHVsZS5mOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBnZXRPd25Qcm9wZXJ0eVN5bWJvbHMgPyBjb25jYXQoa2V5cywgZ2V0T3duUHJvcGVydHlTeW1ib2xzKGl0KSkgOiBrZXlzOwogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogNjEgKi8KICAgICAgICAgICAgLyoqKi8gKChfX3VudXNlZF93ZWJwYWNrX21vZHVsZSwgZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBpbnRlcm5hbE9iamVjdEtleXMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDYyKTsKICAgICAgICAgICAgICAgIHZhciBlbnVtQnVnS2V5cyA9IF9fd19wZGZqc19yZXF1aXJlX18oNjkpOwogICAgICAgICAgICAgICAgdmFyIGhpZGRlbktleXMgPSBlbnVtQnVnS2V5cy5jb25jYXQoJ2xlbmd0aCcsICdwcm90b3R5cGUnKTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuZiA9IE9iamVjdC5nZXRPd25Qcm9wZXJ0eU5hbWVzIHx8IGZ1bmN0aW9uIGdldE93blByb3BlcnR5TmFtZXMoTykgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBpbnRlcm5hbE9iamVjdEtleXMoTywgaGlkZGVuS2V5cyk7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiA2MiAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIHVuY3VycnlUaGlzID0gX193X3BkZmpzX3JlcXVpcmVfXygxNyk7CiAgICAgICAgICAgICAgICB2YXIgaGFzT3duID0gX193X3BkZmpzX3JlcXVpcmVfXyg0Mik7CiAgICAgICAgICAgICAgICB2YXIgdG9JbmRleGVkT2JqZWN0ID0gX193X3BkZmpzX3JlcXVpcmVfXygxNSk7CiAgICAgICAgICAgICAgICB2YXIgaW5kZXhPZiA9IChfX3dfcGRmanNfcmVxdWlyZV9fKDYzKS5pbmRleE9mKTsKICAgICAgICAgICAgICAgIHZhciBoaWRkZW5LZXlzID0gX193X3BkZmpzX3JlcXVpcmVfXyg1OCk7CiAgICAgICAgICAgICAgICB2YXIgcHVzaCA9IHVuY3VycnlUaGlzKFtdLnB1c2gpOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAob2JqZWN0LCBuYW1lcykgewogICAgICAgICAgICAgICAgICAgIHZhciBPID0gdG9JbmRleGVkT2JqZWN0KG9iamVjdCk7CiAgICAgICAgICAgICAgICAgICAgdmFyIGkgPSAwOwogICAgICAgICAgICAgICAgICAgIHZhciByZXN1bHQgPSBbXTsKICAgICAgICAgICAgICAgICAgICB2YXIga2V5OwogICAgICAgICAgICAgICAgICAgIGZvciAoa2V5IGluIE8pCiAgICAgICAgICAgICAgICAgICAgICAgICFoYXNPd24oaGlkZGVuS2V5cywga2V5KSAmJiBoYXNPd24oTywga2V5KSAmJiBwdXNoKHJlc3VsdCwga2V5KTsKICAgICAgICAgICAgICAgICAgICB3aGlsZSAobmFtZXMubGVuZ3RoID4gaSkKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGhhc093bihPLCBrZXkgPSBuYW1lc1tpKytdKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgfmluZGV4T2YocmVzdWx0LCBrZXkpIHx8IHB1c2gocmVzdWx0LCBrZXkpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHJlc3VsdDsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDYzICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgdG9JbmRleGVkT2JqZWN0ID0gX193X3BkZmpzX3JlcXVpcmVfXygxNSk7CiAgICAgICAgICAgICAgICB2YXIgdG9BYnNvbHV0ZUluZGV4ID0gX193X3BkZmpzX3JlcXVpcmVfXyg2NCk7CiAgICAgICAgICAgICAgICB2YXIgbGVuZ3RoT2ZBcnJheUxpa2UgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDY3KTsKICAgICAgICAgICAgICAgIHZhciBjcmVhdGVNZXRob2QgPSBmdW5jdGlvbiAoSVNfSU5DTFVERVMpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gZnVuY3Rpb24gKCR0aGlzLCBlbCwgZnJvbUluZGV4KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBPID0gdG9JbmRleGVkT2JqZWN0KCR0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGxlbmd0aCA9IGxlbmd0aE9mQXJyYXlMaWtlKE8pOwogICAgICAgICAgICAgICAgICAgICAgICB2YXIgaW5kZXggPSB0b0Fic29sdXRlSW5kZXgoZnJvbUluZGV4LCBsZW5ndGgpOwogICAgICAgICAgICAgICAgICAgICAgICB2YXIgdmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChJU19JTkNMVURFUyAmJiBlbCAhPSBlbCkKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdoaWxlIChsZW5ndGggPiBpbmRleCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlID0gT1tpbmRleCsrXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodmFsdWUgIT0gdmFsdWUpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBlbHNlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKDsgbGVuZ3RoID4gaW5kZXg7IGluZGV4KyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoKElTX0lOQ0xVREVTIHx8IGluZGV4IGluIE8pICYmIE9baW5kZXhdID09PSBlbCkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIElTX0lOQ0xVREVTIHx8IGluZGV4IHx8IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAhSVNfSU5DTFVERVMgJiYgLTE7CiAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IHsKICAgICAgICAgICAgICAgICAgICBpbmNsdWRlczogY3JlYXRlTWV0aG9kKHRydWUpLAogICAgICAgICAgICAgICAgICAgIGluZGV4T2Y6IGNyZWF0ZU1ldGhvZChmYWxzZSkKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDY0ICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgdG9JbnRlZ2VyT3JJbmZpbml0eSA9IF9fd19wZGZqc19yZXF1aXJlX18oNjUpOwogICAgICAgICAgICAgICAgdmFyIG1heCA9IE1hdGgubWF4OwogICAgICAgICAgICAgICAgdmFyIG1pbiA9IE1hdGgubWluOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoaW5kZXgsIGxlbmd0aCkgewogICAgICAgICAgICAgICAgICAgIHZhciBpbnRlZ2VyID0gdG9JbnRlZ2VyT3JJbmZpbml0eShpbmRleCk7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGludGVnZXIgPCAwID8gbWF4KGludGVnZXIgKyBsZW5ndGgsIDApIDogbWluKGludGVnZXIsIGxlbmd0aCk7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiA2NSAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIHRydW5jID0gX193X3BkZmpzX3JlcXVpcmVfXyg2Nik7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uIChhcmd1bWVudCkgewogICAgICAgICAgICAgICAgICAgIHZhciBudW1iZXIgPSArYXJndW1lbnQ7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG51bWJlciAhPT0gbnVtYmVyIHx8IG51bWJlciA9PT0gMCA/IDAgOiB0cnVuYyhudW1iZXIpOwogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogNjYgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUpID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgY2VpbCA9IE1hdGguY2VpbDsKICAgICAgICAgICAgICAgIHZhciBmbG9vciA9IE1hdGguZmxvb3I7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IE1hdGgudHJ1bmMgfHwgZnVuY3Rpb24gdHJ1bmMoeCkgewogICAgICAgICAgICAgICAgICAgIHZhciBuID0gK3g7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIChuID4gMCA/IGZsb29yIDogY2VpbCkobik7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiA2NyAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIHRvTGVuZ3RoID0gX193X3BkZmpzX3JlcXVpcmVfXyg2OCk7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uIChvYmopIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gdG9MZW5ndGgob2JqLmxlbmd0aCk7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiA2OCAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIHRvSW50ZWdlck9ySW5maW5pdHkgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDY1KTsKICAgICAgICAgICAgICAgIHZhciBtaW4gPSBNYXRoLm1pbjsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKGFyZ3VtZW50KSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGFyZ3VtZW50ID4gMCA/IG1pbih0b0ludGVnZXJPckluZmluaXR5KGFyZ3VtZW50KSwgMHgxRkZGRkZGRkZGRkZGRikgOiAwOwogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogNjkgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUpID0+IHsKCiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IFsKICAgICAgICAgICAgICAgICAgICAnY29uc3RydWN0b3InLAogICAgICAgICAgICAgICAgICAgICdoYXNPd25Qcm9wZXJ0eScsCiAgICAgICAgICAgICAgICAgICAgJ2lzUHJvdG90eXBlT2YnLAogICAgICAgICAgICAgICAgICAgICdwcm9wZXJ0eUlzRW51bWVyYWJsZScsCiAgICAgICAgICAgICAgICAgICAgJ3RvTG9jYWxlU3RyaW5nJywKICAgICAgICAgICAgICAgICAgICAndG9TdHJpbmcnLAogICAgICAgICAgICAgICAgICAgICd2YWx1ZU9mJwogICAgICAgICAgICAgICAgXTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogNzAgKi8KICAgICAgICAgICAgLyoqKi8gKChfX3VudXNlZF93ZWJwYWNrX21vZHVsZSwgZXhwb3J0cykgPT4gewoKICAgICAgICAgICAgICAgIGV4cG9ydHMuZiA9IE9iamVjdC5nZXRPd25Qcm9wZXJ0eVN5bWJvbHM7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDcxICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgZmFpbHMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEwKTsKICAgICAgICAgICAgICAgIHZhciBpc0NhbGxhYmxlID0gX193X3BkZmpzX3JlcXVpcmVfXygyNCk7CiAgICAgICAgICAgICAgICB2YXIgcmVwbGFjZW1lbnQgPSAvI3xcLnByb3RvdHlwZVwuLzsKICAgICAgICAgICAgICAgIHZhciBpc0ZvcmNlZCA9IGZ1bmN0aW9uIChmZWF0dXJlLCBkZXRlY3Rpb24pIHsKICAgICAgICAgICAgICAgICAgICB2YXIgdmFsdWUgPSBkYXRhW25vcm1hbGl6ZShmZWF0dXJlKV07CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHZhbHVlID09IFBPTFlGSUxMID8gdHJ1ZSA6IHZhbHVlID09IE5BVElWRSA/IGZhbHNlIDogaXNDYWxsYWJsZShkZXRlY3Rpb24pID8gZmFpbHMoZGV0ZWN0aW9uKSA6ICEhZGV0ZWN0aW9uOwogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIHZhciBub3JtYWxpemUgPSBpc0ZvcmNlZC5ub3JtYWxpemUgPSBmdW5jdGlvbiAoc3RyaW5nKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFN0cmluZyhzdHJpbmcpLnJlcGxhY2UocmVwbGFjZW1lbnQsICcuJykudG9Mb3dlckNhc2UoKTsKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB2YXIgZGF0YSA9IGlzRm9yY2VkLmRhdGEgPSB7fTsKICAgICAgICAgICAgICAgIHZhciBOQVRJVkUgPSBpc0ZvcmNlZC5OQVRJVkUgPSAnTic7CiAgICAgICAgICAgICAgICB2YXIgUE9MWUZJTEwgPSBpc0ZvcmNlZC5QT0xZRklMTCA9ICdQJzsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gaXNGb3JjZWQ7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDcyICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgd2VsbEtub3duU3ltYm9sID0gX193X3BkZmpzX3JlcXVpcmVfXygzNyk7CiAgICAgICAgICAgICAgICB2YXIgY3JlYXRlID0gX193X3BkZmpzX3JlcXVpcmVfXyg3Myk7CiAgICAgICAgICAgICAgICB2YXIgZGVmaW5lUHJvcGVydHkgPSAoX193X3BkZmpzX3JlcXVpcmVfXyg0OCkuZik7CiAgICAgICAgICAgICAgICB2YXIgVU5TQ09QQUJMRVMgPSB3ZWxsS25vd25TeW1ib2woJ3Vuc2NvcGFibGVzJyk7CiAgICAgICAgICAgICAgICB2YXIgQXJyYXlQcm90b3R5cGUgPSBBcnJheS5wcm90b3R5cGU7CiAgICAgICAgICAgICAgICBpZiAoQXJyYXlQcm90b3R5cGVbVU5TQ09QQUJMRVNdID09IHVuZGVmaW5lZCkgewogICAgICAgICAgICAgICAgICAgIGRlZmluZVByb3BlcnR5KEFycmF5UHJvdG90eXBlLCBVTlNDT1BBQkxFUywgewogICAgICAgICAgICAgICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBjcmVhdGUobnVsbCkKICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKGtleSkgewogICAgICAgICAgICAgICAgICAgIEFycmF5UHJvdG90eXBlW1VOU0NPUEFCTEVTXVtrZXldID0gdHJ1ZTsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDczICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgYW5PYmplY3QgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDUwKTsKICAgICAgICAgICAgICAgIHZhciBkZWZpbmVQcm9wZXJ0aWVzTW9kdWxlID0gX193X3BkZmpzX3JlcXVpcmVfXyg3NCk7CiAgICAgICAgICAgICAgICB2YXIgZW51bUJ1Z0tleXMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDY5KTsKICAgICAgICAgICAgICAgIHZhciBoaWRkZW5LZXlzID0gX193X3BkZmpzX3JlcXVpcmVfXyg1OCk7CiAgICAgICAgICAgICAgICB2YXIgaHRtbCA9IF9fd19wZGZqc19yZXF1aXJlX18oNzYpOwogICAgICAgICAgICAgICAgdmFyIGRvY3VtZW50Q3JlYXRlRWxlbWVudCA9IF9fd19wZGZqc19yZXF1aXJlX18oNDYpOwogICAgICAgICAgICAgICAgdmFyIHNoYXJlZEtleSA9IF9fd19wZGZqc19yZXF1aXJlX18oNTcpOwogICAgICAgICAgICAgICAgdmFyIEdUID0gJz4nOwogICAgICAgICAgICAgICAgdmFyIExUID0gJzwnOwogICAgICAgICAgICAgICAgdmFyIFBST1RPVFlQRSA9ICdwcm90b3R5cGUnOwogICAgICAgICAgICAgICAgdmFyIFNDUklQVCA9ICdzY3JpcHQnOwogICAgICAgICAgICAgICAgdmFyIElFX1BST1RPID0gc2hhcmVkS2V5KCdJRV9QUk9UTycpOwogICAgICAgICAgICAgICAgdmFyIEVtcHR5Q29uc3RydWN0b3IgPSBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgdmFyIHNjcmlwdFRhZyA9IGZ1bmN0aW9uIChjb250ZW50KSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIExUICsgU0NSSVBUICsgR1QgKyBjb250ZW50ICsgTFQgKyAnLycgKyBTQ1JJUFQgKyBHVDsKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB2YXIgTnVsbFByb3RvT2JqZWN0VmlhQWN0aXZlWCA9IGZ1bmN0aW9uIChhY3RpdmVYRG9jdW1lbnQpIHsKICAgICAgICAgICAgICAgICAgICBhY3RpdmVYRG9jdW1lbnQud3JpdGUoc2NyaXB0VGFnKCcnKSk7CiAgICAgICAgICAgICAgICAgICAgYWN0aXZlWERvY3VtZW50LmNsb3NlKCk7CiAgICAgICAgICAgICAgICAgICAgdmFyIHRlbXAgPSBhY3RpdmVYRG9jdW1lbnQucGFyZW50V2luZG93Lk9iamVjdDsKICAgICAgICAgICAgICAgICAgICBhY3RpdmVYRG9jdW1lbnQgPSBudWxsOwogICAgICAgICAgICAgICAgICAgIHJldHVybiB0ZW1wOwogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIHZhciBOdWxsUHJvdG9PYmplY3RWaWFJRnJhbWUgPSBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgdmFyIGlmcmFtZSA9IGRvY3VtZW50Q3JlYXRlRWxlbWVudCgnaWZyYW1lJyk7CiAgICAgICAgICAgICAgICAgICAgdmFyIEpTID0gJ2phdmEnICsgU0NSSVBUICsgJzonOwogICAgICAgICAgICAgICAgICAgIHZhciBpZnJhbWVEb2N1bWVudDsKICAgICAgICAgICAgICAgICAgICBpZnJhbWUuc3R5bGUuZGlzcGxheSA9ICdub25lJzsKICAgICAgICAgICAgICAgICAgICBodG1sLmFwcGVuZENoaWxkKGlmcmFtZSk7CiAgICAgICAgICAgICAgICAgICAgaWZyYW1lLnNyYyA9IFN0cmluZyhKUyk7CiAgICAgICAgICAgICAgICAgICAgaWZyYW1lRG9jdW1lbnQgPSBpZnJhbWUuY29udGVudFdpbmRvdy5kb2N1bWVudDsKICAgICAgICAgICAgICAgICAgICBpZnJhbWVEb2N1bWVudC5vcGVuKCk7CiAgICAgICAgICAgICAgICAgICAgaWZyYW1lRG9jdW1lbnQud3JpdGUoc2NyaXB0VGFnKCdkb2N1bWVudC5GPU9iamVjdCcpKTsKICAgICAgICAgICAgICAgICAgICBpZnJhbWVEb2N1bWVudC5jbG9zZSgpOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBpZnJhbWVEb2N1bWVudC5GOwogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIHZhciBhY3RpdmVYRG9jdW1lbnQ7CiAgICAgICAgICAgICAgICB2YXIgTnVsbFByb3RvT2JqZWN0ID0gZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGFjdGl2ZVhEb2N1bWVudCA9IG5ldyBBY3RpdmVYT2JqZWN0KCdodG1sZmlsZScpOwogICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIE51bGxQcm90b09iamVjdCA9IHR5cGVvZiBkb2N1bWVudCAhPSAndW5kZWZpbmVkJyA/IGRvY3VtZW50LmRvbWFpbiAmJiBhY3RpdmVYRG9jdW1lbnQgPyBOdWxsUHJvdG9PYmplY3RWaWFBY3RpdmVYKGFjdGl2ZVhEb2N1bWVudCkgOiBOdWxsUHJvdG9PYmplY3RWaWFJRnJhbWUoKSA6IE51bGxQcm90b09iamVjdFZpYUFjdGl2ZVgoYWN0aXZlWERvY3VtZW50KTsKICAgICAgICAgICAgICAgICAgICB2YXIgbGVuZ3RoID0gZW51bUJ1Z0tleXMubGVuZ3RoOwogICAgICAgICAgICAgICAgICAgIHdoaWxlIChsZW5ndGgtLSkKICAgICAgICAgICAgICAgICAgICAgICAgZGVsZXRlIE51bGxQcm90b09iamVjdFtQUk9UT1RZUEVdW2VudW1CdWdLZXlzW2xlbmd0aF1dOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBOdWxsUHJvdG9PYmplY3QoKTsKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBoaWRkZW5LZXlzW0lFX1BST1RPXSA9IHRydWU7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IE9iamVjdC5jcmVhdGUgfHwgZnVuY3Rpb24gY3JlYXRlKE8sIFByb3BlcnRpZXMpIHsKICAgICAgICAgICAgICAgICAgICB2YXIgcmVzdWx0OwogICAgICAgICAgICAgICAgICAgIGlmIChPICE9PSBudWxsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIEVtcHR5Q29uc3RydWN0b3JbUFJPVE9UWVBFXSA9IGFuT2JqZWN0KE8pOwogICAgICAgICAgICAgICAgICAgICAgICByZXN1bHQgPSBuZXcgRW1wdHlDb25zdHJ1Y3RvcigpOwogICAgICAgICAgICAgICAgICAgICAgICBFbXB0eUNvbnN0cnVjdG9yW1BST1RPVFlQRV0gPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICByZXN1bHRbSUVfUFJPVE9dID0gTzsKICAgICAgICAgICAgICAgICAgICB9IGVsc2UKICAgICAgICAgICAgICAgICAgICAgICAgcmVzdWx0ID0gTnVsbFByb3RvT2JqZWN0KCk7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFByb3BlcnRpZXMgPT09IHVuZGVmaW5lZCA/IHJlc3VsdCA6IGRlZmluZVByb3BlcnRpZXNNb2R1bGUuZihyZXN1bHQsIFByb3BlcnRpZXMpOwogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogNzQgKi8KICAgICAgICAgICAgLyoqKi8gKChfX3VudXNlZF93ZWJwYWNrX21vZHVsZSwgZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBERVNDUklQVE9SUyA9IF9fd19wZGZqc19yZXF1aXJlX18oOSk7CiAgICAgICAgICAgICAgICB2YXIgVjhfUFJPVE9UWVBFX0RFRklORV9CVUcgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDQ5KTsKICAgICAgICAgICAgICAgIHZhciBkZWZpbmVQcm9wZXJ0eU1vZHVsZSA9IF9fd19wZGZqc19yZXF1aXJlX18oNDgpOwogICAgICAgICAgICAgICAgdmFyIGFuT2JqZWN0ID0gX193X3BkZmpzX3JlcXVpcmVfXyg1MCk7CiAgICAgICAgICAgICAgICB2YXIgdG9JbmRleGVkT2JqZWN0ID0gX193X3BkZmpzX3JlcXVpcmVfXygxNSk7CiAgICAgICAgICAgICAgICB2YXIgb2JqZWN0S2V5cyA9IF9fd19wZGZqc19yZXF1aXJlX18oNzUpOwogICAgICAgICAgICAgICAgZXhwb3J0cy5mID0gREVTQ1JJUFRPUlMgJiYgIVY4X1BST1RPVFlQRV9ERUZJTkVfQlVHID8gT2JqZWN0LmRlZmluZVByb3BlcnRpZXMgOiBmdW5jdGlvbiBkZWZpbmVQcm9wZXJ0aWVzKE8sIFByb3BlcnRpZXMpIHsKICAgICAgICAgICAgICAgICAgICBhbk9iamVjdChPKTsKICAgICAgICAgICAgICAgICAgICB2YXIgcHJvcHMgPSB0b0luZGV4ZWRPYmplY3QoUHJvcGVydGllcyk7CiAgICAgICAgICAgICAgICAgICAgdmFyIGtleXMgPSBvYmplY3RLZXlzKFByb3BlcnRpZXMpOwogICAgICAgICAgICAgICAgICAgIHZhciBsZW5ndGggPSBrZXlzLmxlbmd0aDsKICAgICAgICAgICAgICAgICAgICB2YXIgaW5kZXggPSAwOwogICAgICAgICAgICAgICAgICAgIHZhciBrZXk7CiAgICAgICAgICAgICAgICAgICAgd2hpbGUgKGxlbmd0aCA+IGluZGV4KQogICAgICAgICAgICAgICAgICAgICAgICBkZWZpbmVQcm9wZXJ0eU1vZHVsZS5mKE8sIGtleSA9IGtleXNbaW5kZXgrK10sIHByb3BzW2tleV0pOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBPOwogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogNzUgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBpbnRlcm5hbE9iamVjdEtleXMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDYyKTsKICAgICAgICAgICAgICAgIHZhciBlbnVtQnVnS2V5cyA9IF9fd19wZGZqc19yZXF1aXJlX18oNjkpOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBPYmplY3Qua2V5cyB8fCBmdW5jdGlvbiBrZXlzKE8pIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gaW50ZXJuYWxPYmplY3RLZXlzKE8sIGVudW1CdWdLZXlzKTsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDc2ICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgZ2V0QnVpbHRJbiA9IF9fd19wZGZqc19yZXF1aXJlX18oMjcpOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBnZXRCdWlsdEluKCdkb2N1bWVudCcsICdkb2N1bWVudEVsZW1lbnQnKTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogNzcgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBnbG9iYWwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDcpOwogICAgICAgICAgICAgICAgdmFyIHVuY3VycnlUaGlzID0gX193X3BkZmpzX3JlcXVpcmVfXygxNyk7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uIChDT05TVFJVQ1RPUiwgTUVUSE9EKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHVuY3VycnlUaGlzKGdsb2JhbFtDT05TVFJVQ1RPUl0ucHJvdG90eXBlW01FVEhPRF0pOwogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogNzggKi8KICAgICAgICAgICAgLyoqKi8gKChfX3VudXNlZF93ZWJwYWNrX21vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgX193X3BkZmpzX3JlcXVpcmVfXyg3OSk7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDc5ICovCiAgICAgICAgICAgIC8qKiovICgoX191bnVzZWRfd2VicGFja19tb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgICJ1c2Ugc3RyaWN0IjsKCiAgICAgICAgICAgICAgICB2YXIgQXJyYXlCdWZmZXJWaWV3Q29yZSA9IF9fd19wZGZqc19yZXF1aXJlX18oODApOwogICAgICAgICAgICAgICAgdmFyIGxlbmd0aE9mQXJyYXlMaWtlID0gX193X3BkZmpzX3JlcXVpcmVfXyg2Nyk7CiAgICAgICAgICAgICAgICB2YXIgdG9JbnRlZ2VyT3JJbmZpbml0eSA9IF9fd19wZGZqc19yZXF1aXJlX18oNjUpOwogICAgICAgICAgICAgICAgdmFyIGFUeXBlZEFycmF5ID0gQXJyYXlCdWZmZXJWaWV3Q29yZS5hVHlwZWRBcnJheTsKICAgICAgICAgICAgICAgIHZhciBleHBvcnRUeXBlZEFycmF5TWV0aG9kID0gQXJyYXlCdWZmZXJWaWV3Q29yZS5leHBvcnRUeXBlZEFycmF5TWV0aG9kOwogICAgICAgICAgICAgICAgZXhwb3J0VHlwZWRBcnJheU1ldGhvZCgnYXQnLCBmdW5jdGlvbiBhdChpbmRleCkgewogICAgICAgICAgICAgICAgICAgIHZhciBPID0gYVR5cGVkQXJyYXkodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgdmFyIGxlbiA9IGxlbmd0aE9mQXJyYXlMaWtlKE8pOwogICAgICAgICAgICAgICAgICAgIHZhciByZWxhdGl2ZUluZGV4ID0gdG9JbnRlZ2VyT3JJbmZpbml0eShpbmRleCk7CiAgICAgICAgICAgICAgICAgICAgdmFyIGsgPSByZWxhdGl2ZUluZGV4ID49IDAgPyByZWxhdGl2ZUluZGV4IDogbGVuICsgcmVsYXRpdmVJbmRleDsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gayA8IDAgfHwgayA+PSBsZW4gPyB1bmRlZmluZWQgOiBPW2tdOwogICAgICAgICAgICAgICAgfSk7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDgwICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICAidXNlIHN0cmljdCI7CgogICAgICAgICAgICAgICAgdmFyIE5BVElWRV9BUlJBWV9CVUZGRVIgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDgxKTsKICAgICAgICAgICAgICAgIHZhciBERVNDUklQVE9SUyA9IF9fd19wZGZqc19yZXF1aXJlX18oOSk7CiAgICAgICAgICAgICAgICB2YXIgZ2xvYmFsID0gX193X3BkZmpzX3JlcXVpcmVfXyg3KTsKICAgICAgICAgICAgICAgIHZhciBpc0NhbGxhYmxlID0gX193X3BkZmpzX3JlcXVpcmVfXygyNCk7CiAgICAgICAgICAgICAgICB2YXIgaXNPYmplY3QgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDIzKTsKICAgICAgICAgICAgICAgIHZhciBoYXNPd24gPSBfX3dfcGRmanNfcmVxdWlyZV9fKDQyKTsKICAgICAgICAgICAgICAgIHZhciBjbGFzc29mID0gX193X3BkZmpzX3JlcXVpcmVfXyg4Mik7CiAgICAgICAgICAgICAgICB2YXIgdHJ5VG9TdHJpbmcgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDM1KTsKICAgICAgICAgICAgICAgIHZhciBjcmVhdGVOb25FbnVtZXJhYmxlUHJvcGVydHkgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDQ3KTsKICAgICAgICAgICAgICAgIHZhciBkZWZpbmVCdWlsdEluID0gX193X3BkZmpzX3JlcXVpcmVfXyg1MSk7CiAgICAgICAgICAgICAgICB2YXIgZGVmaW5lQnVpbHRJbkFjY2Vzc29yID0gX193X3BkZmpzX3JlcXVpcmVfXyg4NCk7CiAgICAgICAgICAgICAgICB2YXIgaXNQcm90b3R5cGVPZiA9IF9fd19wZGZqc19yZXF1aXJlX18oMjgpOwogICAgICAgICAgICAgICAgdmFyIGdldFByb3RvdHlwZU9mID0gX193X3BkZmpzX3JlcXVpcmVfXyg4NSk7CiAgICAgICAgICAgICAgICB2YXIgc2V0UHJvdG90eXBlT2YgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDg3KTsKICAgICAgICAgICAgICAgIHZhciB3ZWxsS25vd25TeW1ib2wgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDM3KTsKICAgICAgICAgICAgICAgIHZhciB1aWQgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDQ0KTsKICAgICAgICAgICAgICAgIHZhciBJbnRlcm5hbFN0YXRlTW9kdWxlID0gX193X3BkZmpzX3JlcXVpcmVfXyg1NSk7CiAgICAgICAgICAgICAgICB2YXIgZW5mb3JjZUludGVybmFsU3RhdGUgPSBJbnRlcm5hbFN0YXRlTW9kdWxlLmVuZm9yY2U7CiAgICAgICAgICAgICAgICB2YXIgZ2V0SW50ZXJuYWxTdGF0ZSA9IEludGVybmFsU3RhdGVNb2R1bGUuZ2V0OwogICAgICAgICAgICAgICAgdmFyIEludDhBcnJheSA9IGdsb2JhbC5JbnQ4QXJyYXk7CiAgICAgICAgICAgICAgICB2YXIgSW50OEFycmF5UHJvdG90eXBlID0gSW50OEFycmF5ICYmIEludDhBcnJheS5wcm90b3R5cGU7CiAgICAgICAgICAgICAgICB2YXIgVWludDhDbGFtcGVkQXJyYXkgPSBnbG9iYWwuVWludDhDbGFtcGVkQXJyYXk7CiAgICAgICAgICAgICAgICB2YXIgVWludDhDbGFtcGVkQXJyYXlQcm90b3R5cGUgPSBVaW50OENsYW1wZWRBcnJheSAmJiBVaW50OENsYW1wZWRBcnJheS5wcm90b3R5cGU7CiAgICAgICAgICAgICAgICB2YXIgVHlwZWRBcnJheSA9IEludDhBcnJheSAmJiBnZXRQcm90b3R5cGVPZihJbnQ4QXJyYXkpOwogICAgICAgICAgICAgICAgdmFyIFR5cGVkQXJyYXlQcm90b3R5cGUgPSBJbnQ4QXJyYXlQcm90b3R5cGUgJiYgZ2V0UHJvdG90eXBlT2YoSW50OEFycmF5UHJvdG90eXBlKTsKICAgICAgICAgICAgICAgIHZhciBPYmplY3RQcm90b3R5cGUgPSBPYmplY3QucHJvdG90eXBlOwogICAgICAgICAgICAgICAgdmFyIFR5cGVFcnJvciA9IGdsb2JhbC5UeXBlRXJyb3I7CiAgICAgICAgICAgICAgICB2YXIgVE9fU1RSSU5HX1RBRyA9IHdlbGxLbm93blN5bWJvbCgndG9TdHJpbmdUYWcnKTsKICAgICAgICAgICAgICAgIHZhciBUWVBFRF9BUlJBWV9UQUcgPSB1aWQoJ1RZUEVEX0FSUkFZX1RBRycpOwogICAgICAgICAgICAgICAgdmFyIFRZUEVEX0FSUkFZX0NPTlNUUlVDVE9SID0gJ1R5cGVkQXJyYXlDb25zdHJ1Y3Rvcic7CiAgICAgICAgICAgICAgICB2YXIgTkFUSVZFX0FSUkFZX0JVRkZFUl9WSUVXUyA9IE5BVElWRV9BUlJBWV9CVUZGRVIgJiYgISFzZXRQcm90b3R5cGVPZiAmJiBjbGFzc29mKGdsb2JhbC5vcGVyYSkgIT09ICdPcGVyYSc7CiAgICAgICAgICAgICAgICB2YXIgVFlQRURfQVJSQVlfVEFHX1JFUVVJUkVEID0gZmFsc2U7CiAgICAgICAgICAgICAgICB2YXIgTkFNRSwgQ29uc3RydWN0b3IsIFByb3RvdHlwZTsKICAgICAgICAgICAgICAgIHZhciBUeXBlZEFycmF5Q29uc3RydWN0b3JzTGlzdCA9IHsKICAgICAgICAgICAgICAgICAgICBJbnQ4QXJyYXk6IDEsCiAgICAgICAgICAgICAgICAgICAgVWludDhBcnJheTogMSwKICAgICAgICAgICAgICAgICAgICBVaW50OENsYW1wZWRBcnJheTogMSwKICAgICAgICAgICAgICAgICAgICBJbnQxNkFycmF5OiAyLAogICAgICAgICAgICAgICAgICAgIFVpbnQxNkFycmF5OiAyLAogICAgICAgICAgICAgICAgICAgIEludDMyQXJyYXk6IDQsCiAgICAgICAgICAgICAgICAgICAgVWludDMyQXJyYXk6IDQsCiAgICAgICAgICAgICAgICAgICAgRmxvYXQzMkFycmF5OiA0LAogICAgICAgICAgICAgICAgICAgIEZsb2F0NjRBcnJheTogOAogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIHZhciBCaWdJbnRBcnJheUNvbnN0cnVjdG9yc0xpc3QgPSB7CiAgICAgICAgICAgICAgICAgICAgQmlnSW50NjRBcnJheTogOCwKICAgICAgICAgICAgICAgICAgICBCaWdVaW50NjRBcnJheTogOAogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIHZhciBpc1ZpZXcgPSBmdW5jdGlvbiBpc1ZpZXcoaXQpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoIWlzT2JqZWN0KGl0KSkKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgICAgICAgICAgIHZhciBrbGFzcyA9IGNsYXNzb2YoaXQpOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBrbGFzcyA9PT0gJ0RhdGFWaWV3JyB8fCBoYXNPd24oVHlwZWRBcnJheUNvbnN0cnVjdG9yc0xpc3QsIGtsYXNzKSB8fCBoYXNPd24oQmlnSW50QXJyYXlDb25zdHJ1Y3RvcnNMaXN0LCBrbGFzcyk7CiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgdmFyIGdldFR5cGVkQXJyYXlDb25zdHJ1Y3RvciA9IGZ1bmN0aW9uIChpdCkgewogICAgICAgICAgICAgICAgICAgIHZhciBwcm90byA9IGdldFByb3RvdHlwZU9mKGl0KTsKICAgICAgICAgICAgICAgICAgICBpZiAoIWlzT2JqZWN0KHByb3RvKSkKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgIHZhciBzdGF0ZSA9IGdldEludGVybmFsU3RhdGUocHJvdG8pOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBzdGF0ZSAmJiBoYXNPd24oc3RhdGUsIFRZUEVEX0FSUkFZX0NPTlNUUlVDVE9SKSA/IHN0YXRlW1RZUEVEX0FSUkFZX0NPTlNUUlVDVE9SXSA6IGdldFR5cGVkQXJyYXlDb25zdHJ1Y3Rvcihwcm90byk7CiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgdmFyIGlzVHlwZWRBcnJheSA9IGZ1bmN0aW9uIChpdCkgewogICAgICAgICAgICAgICAgICAgIGlmICghaXNPYmplY3QoaXQpKQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgdmFyIGtsYXNzID0gY2xhc3NvZihpdCk7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGhhc093bihUeXBlZEFycmF5Q29uc3RydWN0b3JzTGlzdCwga2xhc3MpIHx8IGhhc093bihCaWdJbnRBcnJheUNvbnN0cnVjdG9yc0xpc3QsIGtsYXNzKTsKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB2YXIgYVR5cGVkQXJyYXkgPSBmdW5jdGlvbiAoaXQpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoaXNUeXBlZEFycmF5KGl0KSkKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGl0OwogICAgICAgICAgICAgICAgICAgIHRocm93IFR5cGVFcnJvcignVGFyZ2V0IGlzIG5vdCBhIHR5cGVkIGFycmF5Jyk7CiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgdmFyIGFUeXBlZEFycmF5Q29uc3RydWN0b3IgPSBmdW5jdGlvbiAoQykgewogICAgICAgICAgICAgICAgICAgIGlmIChpc0NhbGxhYmxlKEMpICYmICghc2V0UHJvdG90eXBlT2YgfHwgaXNQcm90b3R5cGVPZihUeXBlZEFycmF5LCBDKSkpCiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBDOwogICAgICAgICAgICAgICAgICAgIHRocm93IFR5cGVFcnJvcih0cnlUb1N0cmluZyhDKSArICcgaXMgbm90IGEgdHlwZWQgYXJyYXkgY29uc3RydWN0b3InKTsKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB2YXIgZXhwb3J0VHlwZWRBcnJheU1ldGhvZCA9IGZ1bmN0aW9uIChLRVksIHByb3BlcnR5LCBmb3JjZWQsIG9wdGlvbnMpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoIURFU0NSSVBUT1JTKQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgaWYgKGZvcmNlZCkKICAgICAgICAgICAgICAgICAgICAgICAgZm9yICh2YXIgQVJSQVkgaW4gVHlwZWRBcnJheUNvbnN0cnVjdG9yc0xpc3QpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBUeXBlZEFycmF5Q29uc3RydWN0b3IgPSBnbG9iYWxbQVJSQVldOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKFR5cGVkQXJyYXlDb25zdHJ1Y3RvciAmJiBoYXNPd24oVHlwZWRBcnJheUNvbnN0cnVjdG9yLnByb3RvdHlwZSwgS0VZKSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWxldGUgVHlwZWRBcnJheUNvbnN0cnVjdG9yLnByb3RvdHlwZVtLRVldOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBUeXBlZEFycmF5Q29uc3RydWN0b3IucHJvdG90eXBlW0tFWV0gPSBwcm9wZXJ0eTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZXJyb3IyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBpZiAoIVR5cGVkQXJyYXlQcm90b3R5cGVbS0VZXSB8fCBmb3JjZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgZGVmaW5lQnVpbHRJbihUeXBlZEFycmF5UHJvdG90eXBlLCBLRVksIGZvcmNlZCA/IHByb3BlcnR5IDogTkFUSVZFX0FSUkFZX0JVRkZFUl9WSUVXUyAmJiBJbnQ4QXJyYXlQcm90b3R5cGVbS0VZXSB8fCBwcm9wZXJ0eSwgb3B0aW9ucyk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIHZhciBleHBvcnRUeXBlZEFycmF5U3RhdGljTWV0aG9kID0gZnVuY3Rpb24gKEtFWSwgcHJvcGVydHksIGZvcmNlZCkgewogICAgICAgICAgICAgICAgICAgIHZhciBBUlJBWSwgVHlwZWRBcnJheUNvbnN0cnVjdG9yOwogICAgICAgICAgICAgICAgICAgIGlmICghREVTQ1JJUFRPUlMpCiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICBpZiAoc2V0UHJvdG90eXBlT2YpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGZvcmNlZCkKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoQVJSQVkgaW4gVHlwZWRBcnJheUNvbnN0cnVjdG9yc0xpc3QpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBUeXBlZEFycmF5Q29uc3RydWN0b3IgPSBnbG9iYWxbQVJSQVldOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChUeXBlZEFycmF5Q29uc3RydWN0b3IgJiYgaGFzT3duKFR5cGVkQXJyYXlDb25zdHJ1Y3RvciwgS0VZKSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlbGV0ZSBUeXBlZEFycmF5Q29uc3RydWN0b3JbS0VZXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZXJyb3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIVR5cGVkQXJyYXlbS0VZXSB8fCBmb3JjZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGRlZmluZUJ1aWx0SW4oVHlwZWRBcnJheSwgS0VZLCBmb3JjZWQgPyBwcm9wZXJ0eSA6IE5BVElWRV9BUlJBWV9CVUZGRVJfVklFV1MgJiYgVHlwZWRBcnJheVtLRVldIHx8IHByb3BlcnR5KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBmb3IgKEFSUkFZIGluIFR5cGVkQXJyYXlDb25zdHJ1Y3RvcnNMaXN0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIFR5cGVkQXJyYXlDb25zdHJ1Y3RvciA9IGdsb2JhbFtBUlJBWV07CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChUeXBlZEFycmF5Q29uc3RydWN0b3IgJiYgKCFUeXBlZEFycmF5Q29uc3RydWN0b3JbS0VZXSB8fCBmb3JjZWQpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZpbmVCdWlsdEluKFR5cGVkQXJyYXlDb25zdHJ1Y3RvciwgS0VZLCBwcm9wZXJ0eSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgZm9yIChOQU1FIGluIFR5cGVkQXJyYXlDb25zdHJ1Y3RvcnNMaXN0KSB7CiAgICAgICAgICAgICAgICAgICAgQ29uc3RydWN0b3IgPSBnbG9iYWxbTkFNRV07CiAgICAgICAgICAgICAgICAgICAgUHJvdG90eXBlID0gQ29uc3RydWN0b3IgJiYgQ29uc3RydWN0b3IucHJvdG90eXBlOwogICAgICAgICAgICAgICAgICAgIGlmIChQcm90b3R5cGUpCiAgICAgICAgICAgICAgICAgICAgICAgIGVuZm9yY2VJbnRlcm5hbFN0YXRlKFByb3RvdHlwZSlbVFlQRURfQVJSQVlfQ09OU1RSVUNUT1JdID0gQ29uc3RydWN0b3I7CiAgICAgICAgICAgICAgICAgICAgZWxzZQogICAgICAgICAgICAgICAgICAgICAgICBOQVRJVkVfQVJSQVlfQlVGRkVSX1ZJRVdTID0gZmFsc2U7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmb3IgKE5BTUUgaW4gQmlnSW50QXJyYXlDb25zdHJ1Y3RvcnNMaXN0KSB7CiAgICAgICAgICAgICAgICAgICAgQ29uc3RydWN0b3IgPSBnbG9iYWxbTkFNRV07CiAgICAgICAgICAgICAgICAgICAgUHJvdG90eXBlID0gQ29uc3RydWN0b3IgJiYgQ29uc3RydWN0b3IucHJvdG90eXBlOwogICAgICAgICAgICAgICAgICAgIGlmIChQcm90b3R5cGUpCiAgICAgICAgICAgICAgICAgICAgICAgIGVuZm9yY2VJbnRlcm5hbFN0YXRlKFByb3RvdHlwZSlbVFlQRURfQVJSQVlfQ09OU1RSVUNUT1JdID0gQ29uc3RydWN0b3I7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBpZiAoIU5BVElWRV9BUlJBWV9CVUZGRVJfVklFV1MgfHwgIWlzQ2FsbGFibGUoVHlwZWRBcnJheSkgfHwgVHlwZWRBcnJheSA9PT0gRnVuY3Rpb24ucHJvdG90eXBlKSB7CiAgICAgICAgICAgICAgICAgICAgVHlwZWRBcnJheSA9IGZ1bmN0aW9uIFR5cGVkQXJyYXkoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IFR5cGVFcnJvcignSW5jb3JyZWN0IGludm9jYXRpb24nKTsKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIGlmIChOQVRJVkVfQVJSQVlfQlVGRkVSX1ZJRVdTKQogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKE5BTUUgaW4gVHlwZWRBcnJheUNvbnN0cnVjdG9yc0xpc3QpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChnbG9iYWxbTkFNRV0pCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2V0UHJvdG90eXBlT2YoZ2xvYmFsW05BTUVdLCBUeXBlZEFycmF5KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgaWYgKCFOQVRJVkVfQVJSQVlfQlVGRkVSX1ZJRVdTIHx8ICFUeXBlZEFycmF5UHJvdG90eXBlIHx8IFR5cGVkQXJyYXlQcm90b3R5cGUgPT09IE9iamVjdFByb3RvdHlwZSkgewogICAgICAgICAgICAgICAgICAgIFR5cGVkQXJyYXlQcm90b3R5cGUgPSBUeXBlZEFycmF5LnByb3RvdHlwZTsKICAgICAgICAgICAgICAgICAgICBpZiAoTkFUSVZFX0FSUkFZX0JVRkZFUl9WSUVXUykKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChOQU1FIGluIFR5cGVkQXJyYXlDb25zdHJ1Y3RvcnNMaXN0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZ2xvYmFsW05BTUVdKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNldFByb3RvdHlwZU9mKGdsb2JhbFtOQU1FXS5wcm90b3R5cGUsIFR5cGVkQXJyYXlQcm90b3R5cGUpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBpZiAoTkFUSVZFX0FSUkFZX0JVRkZFUl9WSUVXUyAmJiBnZXRQcm90b3R5cGVPZihVaW50OENsYW1wZWRBcnJheVByb3RvdHlwZSkgIT09IFR5cGVkQXJyYXlQcm90b3R5cGUpIHsKICAgICAgICAgICAgICAgICAgICBzZXRQcm90b3R5cGVPZihVaW50OENsYW1wZWRBcnJheVByb3RvdHlwZSwgVHlwZWRBcnJheVByb3RvdHlwZSk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBpZiAoREVTQ1JJUFRPUlMgJiYgIWhhc093bihUeXBlZEFycmF5UHJvdG90eXBlLCBUT19TVFJJTkdfVEFHKSkgewogICAgICAgICAgICAgICAgICAgIFRZUEVEX0FSUkFZX1RBR19SRVFVSVJFRCA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgZGVmaW5lQnVpbHRJbkFjY2Vzc29yKFR5cGVkQXJyYXlQcm90b3R5cGUsIFRPX1NUUklOR19UQUcsIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICBnZXQ6IGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBpc09iamVjdCh0aGlzKSA/IHRoaXNbVFlQRURfQVJSQVlfVEFHXSA6IHVuZGVmaW5lZDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIGZvciAoTkFNRSBpbiBUeXBlZEFycmF5Q29uc3RydWN0b3JzTGlzdCkKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGdsb2JhbFtOQU1FXSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3JlYXRlTm9uRW51bWVyYWJsZVByb3BlcnR5KGdsb2JhbFtOQU1FXSwgVFlQRURfQVJSQVlfVEFHLCBOQU1FKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSB7CiAgICAgICAgICAgICAgICAgICAgTkFUSVZFX0FSUkFZX0JVRkZFUl9WSUVXUzogTkFUSVZFX0FSUkFZX0JVRkZFUl9WSUVXUywKICAgICAgICAgICAgICAgICAgICBUWVBFRF9BUlJBWV9UQUc6IFRZUEVEX0FSUkFZX1RBR19SRVFVSVJFRCAmJiBUWVBFRF9BUlJBWV9UQUcsCiAgICAgICAgICAgICAgICAgICAgYVR5cGVkQXJyYXk6IGFUeXBlZEFycmF5LAogICAgICAgICAgICAgICAgICAgIGFUeXBlZEFycmF5Q29uc3RydWN0b3I6IGFUeXBlZEFycmF5Q29uc3RydWN0b3IsCiAgICAgICAgICAgICAgICAgICAgZXhwb3J0VHlwZWRBcnJheU1ldGhvZDogZXhwb3J0VHlwZWRBcnJheU1ldGhvZCwKICAgICAgICAgICAgICAgICAgICBleHBvcnRUeXBlZEFycmF5U3RhdGljTWV0aG9kOiBleHBvcnRUeXBlZEFycmF5U3RhdGljTWV0aG9kLAogICAgICAgICAgICAgICAgICAgIGdldFR5cGVkQXJyYXlDb25zdHJ1Y3RvcjogZ2V0VHlwZWRBcnJheUNvbnN0cnVjdG9yLAogICAgICAgICAgICAgICAgICAgIGlzVmlldzogaXNWaWV3LAogICAgICAgICAgICAgICAgICAgIGlzVHlwZWRBcnJheTogaXNUeXBlZEFycmF5LAogICAgICAgICAgICAgICAgICAgIFR5cGVkQXJyYXk6IFR5cGVkQXJyYXksCiAgICAgICAgICAgICAgICAgICAgVHlwZWRBcnJheVByb3RvdHlwZTogVHlwZWRBcnJheVByb3RvdHlwZQogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogODEgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUpID0+IHsKCiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IHR5cGVvZiBBcnJheUJ1ZmZlciAhPSAndW5kZWZpbmVkJyAmJiB0eXBlb2YgRGF0YVZpZXcgIT0gJ3VuZGVmaW5lZCc7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDgyICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgVE9fU1RSSU5HX1RBR19TVVBQT1JUID0gX193X3BkZmpzX3JlcXVpcmVfXyg4Myk7CiAgICAgICAgICAgICAgICB2YXIgaXNDYWxsYWJsZSA9IF9fd19wZGZqc19yZXF1aXJlX18oMjQpOwogICAgICAgICAgICAgICAgdmFyIGNsYXNzb2ZSYXcgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE4KTsKICAgICAgICAgICAgICAgIHZhciB3ZWxsS25vd25TeW1ib2wgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDM3KTsKICAgICAgICAgICAgICAgIHZhciBUT19TVFJJTkdfVEFHID0gd2VsbEtub3duU3ltYm9sKCd0b1N0cmluZ1RhZycpOwogICAgICAgICAgICAgICAgdmFyICRPYmplY3QgPSBPYmplY3Q7CiAgICAgICAgICAgICAgICB2YXIgQ09SUkVDVF9BUkdVTUVOVFMgPSBjbGFzc29mUmF3KChmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGFyZ3VtZW50czsKICAgICAgICAgICAgICAgIH0oKSkpID09ICdBcmd1bWVudHMnOwogICAgICAgICAgICAgICAgdmFyIHRyeUdldCA9IGZ1bmN0aW9uIChpdCwga2V5KSB7CiAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGl0W2tleV07CiAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZXJyb3IpIHsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBUT19TVFJJTkdfVEFHX1NVUFBPUlQgPyBjbGFzc29mUmF3IDogZnVuY3Rpb24gKGl0KSB7CiAgICAgICAgICAgICAgICAgICAgdmFyIE8sIHRhZywgcmVzdWx0OwogICAgICAgICAgICAgICAgICAgIHJldHVybiBpdCA9PT0gdW5kZWZpbmVkID8gJ1VuZGVmaW5lZCcgOiBpdCA9PT0gbnVsbCA/ICdOdWxsJyA6IHR5cGVvZiAodGFnID0gdHJ5R2V0KE8gPSAkT2JqZWN0KGl0KSwgVE9fU1RSSU5HX1RBRykpID09ICdzdHJpbmcnID8gdGFnIDogQ09SUkVDVF9BUkdVTUVOVFMgPyBjbGFzc29mUmF3KE8pIDogKHJlc3VsdCA9IGNsYXNzb2ZSYXcoTykpID09ICdPYmplY3QnICYmIGlzQ2FsbGFibGUoTy5jYWxsZWUpID8gJ0FyZ3VtZW50cycgOiByZXN1bHQ7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiA4MyAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIHdlbGxLbm93blN5bWJvbCA9IF9fd19wZGZqc19yZXF1aXJlX18oMzcpOwogICAgICAgICAgICAgICAgdmFyIFRPX1NUUklOR19UQUcgPSB3ZWxsS25vd25TeW1ib2woJ3RvU3RyaW5nVGFnJyk7CiAgICAgICAgICAgICAgICB2YXIgdGVzdCA9IHt9OwogICAgICAgICAgICAgICAgdGVzdFtUT19TVFJJTkdfVEFHXSA9ICd6JzsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gU3RyaW5nKHRlc3QpID09PSAnW29iamVjdCB6XSc7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDg0ICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgbWFrZUJ1aWx0SW4gPSBfX3dfcGRmanNfcmVxdWlyZV9fKDUyKTsKICAgICAgICAgICAgICAgIHZhciBkZWZpbmVQcm9wZXJ0eSA9IF9fd19wZGZqc19yZXF1aXJlX18oNDgpOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAodGFyZ2V0LCBuYW1lLCBkZXNjcmlwdG9yKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKGRlc2NyaXB0b3IuZ2V0KQogICAgICAgICAgICAgICAgICAgICAgICBtYWtlQnVpbHRJbihkZXNjcmlwdG9yLmdldCwgbmFtZSwgeyBnZXR0ZXI6IHRydWUgfSk7CiAgICAgICAgICAgICAgICAgICAgaWYgKGRlc2NyaXB0b3Iuc2V0KQogICAgICAgICAgICAgICAgICAgICAgICBtYWtlQnVpbHRJbihkZXNjcmlwdG9yLnNldCwgbmFtZSwgeyBzZXR0ZXI6IHRydWUgfSk7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGRlZmluZVByb3BlcnR5LmYodGFyZ2V0LCBuYW1lLCBkZXNjcmlwdG9yKTsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDg1ICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgaGFzT3duID0gX193X3BkZmpzX3JlcXVpcmVfXyg0Mik7CiAgICAgICAgICAgICAgICB2YXIgaXNDYWxsYWJsZSA9IF9fd19wZGZqc19yZXF1aXJlX18oMjQpOwogICAgICAgICAgICAgICAgdmFyIHRvT2JqZWN0ID0gX193X3BkZmpzX3JlcXVpcmVfXyg0Myk7CiAgICAgICAgICAgICAgICB2YXIgc2hhcmVkS2V5ID0gX193X3BkZmpzX3JlcXVpcmVfXyg1Nyk7CiAgICAgICAgICAgICAgICB2YXIgQ09SUkVDVF9QUk9UT1RZUEVfR0VUVEVSID0gX193X3BkZmpzX3JlcXVpcmVfXyg4Nik7CiAgICAgICAgICAgICAgICB2YXIgSUVfUFJPVE8gPSBzaGFyZWRLZXkoJ0lFX1BST1RPJyk7CiAgICAgICAgICAgICAgICB2YXIgJE9iamVjdCA9IE9iamVjdDsKICAgICAgICAgICAgICAgIHZhciBPYmplY3RQcm90b3R5cGUgPSAkT2JqZWN0LnByb3RvdHlwZTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gQ09SUkVDVF9QUk9UT1RZUEVfR0VUVEVSID8gJE9iamVjdC5nZXRQcm90b3R5cGVPZiA6IGZ1bmN0aW9uIChPKSB7CiAgICAgICAgICAgICAgICAgICAgdmFyIG9iamVjdCA9IHRvT2JqZWN0KE8pOwogICAgICAgICAgICAgICAgICAgIGlmIChoYXNPd24ob2JqZWN0LCBJRV9QUk9UTykpCiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBvYmplY3RbSUVfUFJPVE9dOwogICAgICAgICAgICAgICAgICAgIHZhciBjb25zdHJ1Y3RvciA9IG9iamVjdC5jb25zdHJ1Y3RvcjsKICAgICAgICAgICAgICAgICAgICBpZiAoaXNDYWxsYWJsZShjb25zdHJ1Y3RvcikgJiYgb2JqZWN0IGluc3RhbmNlb2YgY29uc3RydWN0b3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGNvbnN0cnVjdG9yLnByb3RvdHlwZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG9iamVjdCBpbnN0YW5jZW9mICRPYmplY3QgPyBPYmplY3RQcm90b3R5cGUgOiBudWxsOwogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogODYgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBmYWlscyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTApOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSAhZmFpbHMoZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIGZ1bmN0aW9uIEYoKSB7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIEYucHJvdG90eXBlLmNvbnN0cnVjdG9yID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gT2JqZWN0LmdldFByb3RvdHlwZU9mKG5ldyBGKCkpICE9PSBGLnByb3RvdHlwZTsKICAgICAgICAgICAgICAgIH0pOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiA4NyAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIHVuY3VycnlUaGlzQWNjZXNzb3IgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDg4KTsKICAgICAgICAgICAgICAgIHZhciBhbk9iamVjdCA9IF9fd19wZGZqc19yZXF1aXJlX18oNTApOwogICAgICAgICAgICAgICAgdmFyIGFQb3NzaWJsZVByb3RvdHlwZSA9IF9fd19wZGZqc19yZXF1aXJlX18oODkpOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBPYmplY3Quc2V0UHJvdG90eXBlT2YgfHwgKCdfX3Byb3RvX18nIGluIHt9ID8gKGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICB2YXIgQ09SUkVDVF9TRVRURVIgPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgICB2YXIgdGVzdCA9IHt9OwogICAgICAgICAgICAgICAgICAgIHZhciBzZXR0ZXI7CiAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgc2V0dGVyID0gdW5jdXJyeVRoaXNBY2Nlc3NvcihPYmplY3QucHJvdG90eXBlLCAnX19wcm90b19fJywgJ3NldCcpOwogICAgICAgICAgICAgICAgICAgICAgICBzZXR0ZXIodGVzdCwgW10pOwogICAgICAgICAgICAgICAgICAgICAgICBDT1JSRUNUX1NFVFRFUiA9IHRlc3QgaW5zdGFuY2VvZiBBcnJheTsKICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIChlcnJvcikgewogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gZnVuY3Rpb24gc2V0UHJvdG90eXBlT2YoTywgcHJvdG8pIHsKICAgICAgICAgICAgICAgICAgICAgICAgYW5PYmplY3QoTyk7CiAgICAgICAgICAgICAgICAgICAgICAgIGFQb3NzaWJsZVByb3RvdHlwZShwcm90byk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChDT1JSRUNUX1NFVFRFUikKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNldHRlcihPLCBwcm90byk7CiAgICAgICAgICAgICAgICAgICAgICAgIGVsc2UKICAgICAgICAgICAgICAgICAgICAgICAgICAgIE8uX19wcm90b19fID0gcHJvdG87CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBPOwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB9KCkpIDogdW5kZWZpbmVkKTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogODggKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciB1bmN1cnJ5VGhpcyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTcpOwogICAgICAgICAgICAgICAgdmFyIGFDYWxsYWJsZSA9IF9fd19wZGZqc19yZXF1aXJlX18oMzQpOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAob2JqZWN0LCBrZXksIG1ldGhvZCkgewogICAgICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB1bmN1cnJ5VGhpcyhhQ2FsbGFibGUoT2JqZWN0LmdldE93blByb3BlcnR5RGVzY3JpcHRvcihvYmplY3QsIGtleSlbbWV0aG9kXSkpOwogICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogODkgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBpc0NhbGxhYmxlID0gX193X3BkZmpzX3JlcXVpcmVfXygyNCk7CiAgICAgICAgICAgICAgICB2YXIgJFN0cmluZyA9IFN0cmluZzsKICAgICAgICAgICAgICAgIHZhciAkVHlwZUVycm9yID0gVHlwZUVycm9yOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoYXJndW1lbnQpIHsKICAgICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIGFyZ3VtZW50ID09ICdvYmplY3QnIHx8IGlzQ2FsbGFibGUoYXJndW1lbnQpKQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gYXJndW1lbnQ7CiAgICAgICAgICAgICAgICAgICAgdGhyb3cgJFR5cGVFcnJvcigiQ2FuJ3Qgc2V0ICIgKyAkU3RyaW5nKGFyZ3VtZW50KSArICcgYXMgYSBwcm90b3R5cGUnKTsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDkwICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICBfX3dfcGRmanNfcmVxdWlyZV9fKDkxKTsKICAgICAgICAgICAgICAgIF9fd19wZGZqc19yZXF1aXJlX18oOTgpOwogICAgICAgICAgICAgICAgX193X3BkZmpzX3JlcXVpcmVfXygxMDApOwogICAgICAgICAgICAgICAgX193X3BkZmpzX3JlcXVpcmVfXygxMjMpOwogICAgICAgICAgICAgICAgX193X3BkZmpzX3JlcXVpcmVfXygxMjUpOwogICAgICAgICAgICAgICAgdmFyIHBhdGggPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEzNyk7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IHBhdGguc3RydWN0dXJlZENsb25lOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiA5MSAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKICAgICAgICAgICAgICAgIHZhciB0b0luZGV4ZWRPYmplY3QgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE1KTsKICAgICAgICAgICAgICAgIHZhciBhZGRUb1Vuc2NvcGFibGVzID0gX193X3BkZmpzX3JlcXVpcmVfXyg3Mik7CiAgICAgICAgICAgICAgICB2YXIgSXRlcmF0b3JzID0gX193X3BkZmpzX3JlcXVpcmVfXyg5Mik7CiAgICAgICAgICAgICAgICB2YXIgSW50ZXJuYWxTdGF0ZU1vZHVsZSA9IF9fd19wZGZqc19yZXF1aXJlX18oNTUpOwogICAgICAgICAgICAgICAgdmFyIGRlZmluZVByb3BlcnR5ID0gKF9fd19wZGZqc19yZXF1aXJlX18oNDgpLmYpOwogICAgICAgICAgICAgICAgdmFyIGRlZmluZUl0ZXJhdG9yID0gX193X3BkZmpzX3JlcXVpcmVfXyg5Myk7CiAgICAgICAgICAgICAgICB2YXIgY3JlYXRlSXRlclJlc3VsdE9iamVjdCA9IF9fd19wZGZqc19yZXF1aXJlX18oOTcpOwogICAgICAgICAgICAgICAgdmFyIElTX1BVUkUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDM5KTsKICAgICAgICAgICAgICAgIHZhciBERVNDUklQVE9SUyA9IF9fd19wZGZqc19yZXF1aXJlX18oOSk7CiAgICAgICAgICAgICAgICB2YXIgQVJSQVlfSVRFUkFUT1IgPSAnQXJyYXkgSXRlcmF0b3InOwogICAgICAgICAgICAgICAgdmFyIHNldEludGVybmFsU3RhdGUgPSBJbnRlcm5hbFN0YXRlTW9kdWxlLnNldDsKICAgICAgICAgICAgICAgIHZhciBnZXRJbnRlcm5hbFN0YXRlID0gSW50ZXJuYWxTdGF0ZU1vZHVsZS5nZXR0ZXJGb3IoQVJSQVlfSVRFUkFUT1IpOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBkZWZpbmVJdGVyYXRvcihBcnJheSwgJ0FycmF5JywgZnVuY3Rpb24gKGl0ZXJhdGVkLCBraW5kKSB7CiAgICAgICAgICAgICAgICAgICAgc2V0SW50ZXJuYWxTdGF0ZSh0aGlzLCB7CiAgICAgICAgICAgICAgICAgICAgICAgIHR5cGU6IEFSUkFZX0lURVJBVE9SLAogICAgICAgICAgICAgICAgICAgICAgICB0YXJnZXQ6IHRvSW5kZXhlZE9iamVjdChpdGVyYXRlZCksCiAgICAgICAgICAgICAgICAgICAgICAgIGluZGV4OiAwLAogICAgICAgICAgICAgICAgICAgICAgICBraW5kOiBraW5kCiAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICB9LCBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgdmFyIHN0YXRlID0gZ2V0SW50ZXJuYWxTdGF0ZSh0aGlzKTsKICAgICAgICAgICAgICAgICAgICB2YXIgdGFyZ2V0ID0gc3RhdGUudGFyZ2V0OwogICAgICAgICAgICAgICAgICAgIHZhciBraW5kID0gc3RhdGUua2luZDsKICAgICAgICAgICAgICAgICAgICB2YXIgaW5kZXggPSBzdGF0ZS5pbmRleCsrOwogICAgICAgICAgICAgICAgICAgIGlmICghdGFyZ2V0IHx8IGluZGV4ID49IHRhcmdldC5sZW5ndGgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3RhdGUudGFyZ2V0ID0gdW5kZWZpbmVkOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gY3JlYXRlSXRlclJlc3VsdE9iamVjdCh1bmRlZmluZWQsIHRydWUpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBpZiAoa2luZCA9PSAna2V5cycpCiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBjcmVhdGVJdGVyUmVzdWx0T2JqZWN0KGluZGV4LCBmYWxzZSk7CiAgICAgICAgICAgICAgICAgICAgaWYgKGtpbmQgPT0gJ3ZhbHVlcycpCiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBjcmVhdGVJdGVyUmVzdWx0T2JqZWN0KHRhcmdldFtpbmRleF0sIGZhbHNlKTsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gY3JlYXRlSXRlclJlc3VsdE9iamVjdChbCiAgICAgICAgICAgICAgICAgICAgICAgIGluZGV4LAogICAgICAgICAgICAgICAgICAgICAgICB0YXJnZXRbaW5kZXhdCiAgICAgICAgICAgICAgICAgICAgXSwgZmFsc2UpOwogICAgICAgICAgICAgICAgfSwgJ3ZhbHVlcycpOwogICAgICAgICAgICAgICAgdmFyIHZhbHVlcyA9IEl0ZXJhdG9ycy5Bcmd1bWVudHMgPSBJdGVyYXRvcnMuQXJyYXk7CiAgICAgICAgICAgICAgICBhZGRUb1Vuc2NvcGFibGVzKCdrZXlzJyk7CiAgICAgICAgICAgICAgICBhZGRUb1Vuc2NvcGFibGVzKCd2YWx1ZXMnKTsKICAgICAgICAgICAgICAgIGFkZFRvVW5zY29wYWJsZXMoJ2VudHJpZXMnKTsKICAgICAgICAgICAgICAgIGlmICghSVNfUFVSRSAmJiBERVNDUklQVE9SUyAmJiB2YWx1ZXMubmFtZSAhPT0gJ3ZhbHVlcycpCiAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgZGVmaW5lUHJvcGVydHkodmFsdWVzLCAnbmFtZScsIHsgdmFsdWU6ICd2YWx1ZXMnIH0pOwogICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgfQoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiA5MiAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSkgPT4gewoKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0ge307CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDkzICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICAidXNlIHN0cmljdCI7CgogICAgICAgICAgICAgICAgdmFyICQgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDYpOwogICAgICAgICAgICAgICAgdmFyIGNhbGwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDExKTsKICAgICAgICAgICAgICAgIHZhciBJU19QVVJFID0gX193X3BkZmpzX3JlcXVpcmVfXygzOSk7CiAgICAgICAgICAgICAgICB2YXIgRnVuY3Rpb25OYW1lID0gX193X3BkZmpzX3JlcXVpcmVfXyg1Myk7CiAgICAgICAgICAgICAgICB2YXIgaXNDYWxsYWJsZSA9IF9fd19wZGZqc19yZXF1aXJlX18oMjQpOwogICAgICAgICAgICAgICAgdmFyIGNyZWF0ZUl0ZXJhdG9yQ29uc3RydWN0b3IgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDk0KTsKICAgICAgICAgICAgICAgIHZhciBnZXRQcm90b3R5cGVPZiA9IF9fd19wZGZqc19yZXF1aXJlX18oODUpOwogICAgICAgICAgICAgICAgdmFyIHNldFByb3RvdHlwZU9mID0gX193X3BkZmpzX3JlcXVpcmVfXyg4Nyk7CiAgICAgICAgICAgICAgICB2YXIgc2V0VG9TdHJpbmdUYWcgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDk2KTsKICAgICAgICAgICAgICAgIHZhciBjcmVhdGVOb25FbnVtZXJhYmxlUHJvcGVydHkgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDQ3KTsKICAgICAgICAgICAgICAgIHZhciBkZWZpbmVCdWlsdEluID0gX193X3BkZmpzX3JlcXVpcmVfXyg1MSk7CiAgICAgICAgICAgICAgICB2YXIgd2VsbEtub3duU3ltYm9sID0gX193X3BkZmpzX3JlcXVpcmVfXygzNyk7CiAgICAgICAgICAgICAgICB2YXIgSXRlcmF0b3JzID0gX193X3BkZmpzX3JlcXVpcmVfXyg5Mik7CiAgICAgICAgICAgICAgICB2YXIgSXRlcmF0b3JzQ29yZSA9IF9fd19wZGZqc19yZXF1aXJlX18oOTUpOwogICAgICAgICAgICAgICAgdmFyIFBST1BFUl9GVU5DVElPTl9OQU1FID0gRnVuY3Rpb25OYW1lLlBST1BFUjsKICAgICAgICAgICAgICAgIHZhciBDT05GSUdVUkFCTEVfRlVOQ1RJT05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AgICAgICAgICAgICAgICAgICAgaWYgKCFCVUdHWV9TQUZBUklfSVRFUkFUT1JTICYmIEtJTkQgaW4gSXRlcmFibGVQcm90b3R5cGUpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gSXRlcmFibGVQcm90b3R5cGVbS0lORF07CiAgICAgICAgICAgICAgICAgICAgICAgIHN3aXRjaCAoS0lORCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBLRVlTOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmdW5jdGlvbiBrZXlzKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IEl0ZXJhdG9yQ29uc3RydWN0b3IodGhpcywgS0lORCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgVkFMVUVTOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmdW5jdGlvbiB2YWx1ZXMoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgSXRlcmF0b3JDb25zdHJ1Y3Rvcih0aGlzLCBLSU5EKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBFTlRSSUVTOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmdW5jdGlvbiBlbnRyaWVzKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IEl0ZXJhdG9yQ29uc3RydWN0b3IodGhpcywgS0lORCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG5ldyBJdGVyYXRvckNvbnN0cnVjdG9yKHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgdmFyIFRPX1NUUklOR19UQUcgPSBOQU1FICsgJyBJdGVyYXRvcic7CiAgICAgICAgICAgICAgICAgICAgdmFyIElOQ09SUkVDVF9WQUxVRVNfTkFNRSA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgIHZhciBJdGVyYWJsZVByb3RvdHlwZSA9IEl0ZXJhYmxlLnByb3RvdHlwZTsKICAgICAgICAgICAgICAgICAgICB2YXIgbmF0aXZlSXRlcmF0b3IgPSBJdGVyYWJsZVByb3RvdHlwZVtJVEVSQVRPUl0gfHwgSXRlcmFibGVQcm90b3R5cGVbJ0BAaXRlcmF0b3InXSB8fCBERUZBVUxUICYmIEl0ZXJhYmxlUHJvdG90eXBlW0RFRkFVTFRdOwogICAgICAgICAgICAgICAgICAgIHZhciBkZWZhdWx0SXRlcmF0b3IgPSAhQlVHR1lfU0FGQVJJX0lURVJBVE9SUyAmJiBuYXRpdmVJdGVyYXRvciB8fCBnZXRJdGVyYXRpb25NZXRob2QoREVGQVVMVCk7CiAgICAgICAgICAgICAgICAgICAgdmFyIGFueU5hdGl2ZUl0ZXJhdG9yID0gTkFNRSA9PSAnQXJyYXknID8gSXRlcmFibGVQcm90b3R5cGUuZW50cmllcyB8fCBuYXRpdmVJdGVyYXRvciA6IG5hdGl2ZUl0ZXJhdG9yOwogICAgICAgICAgICAgICAgICAgIHZhciBDdXJyZW50SXRlcmF0b3JQcm90b3R5cGUsIG1ldGhvZHMsIEtFWTsKICAgICAgICAgICAgICAgICAgICBpZiAoYW55TmF0aXZlSXRlcmF0b3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgQ3VycmVudEl0ZXJhdG9yUHJvdG90eXBlID0gZ2V0UHJvdG90eXBlT2YoYW55TmF0aXZlSXRlcmF0b3IuY2FsbChuZXcgSXRlcmFibGUoKSkpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoQ3VycmVudEl0ZXJhdG9yUHJvdG90eXBlICE9PSBPYmplY3QucHJvdG90eXBlICYmIEN1cnJlbnRJdGVyYXRvclByb3RvdHlwZS5uZXh0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIUlTX1BVUkUgJiYgZ2V0UHJvdG90eXBlT2YoQ3VycmVudEl0ZXJhdG9yUHJvdG90eXBlKSAhPT0gSXRlcmF0b3JQcm90b3R5cGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoc2V0UHJvdG90eXBlT2YpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2V0UHJvdG90eXBlT2YoQ3VycmVudEl0ZXJhdG9yUHJvdG90eXBlLCBJdGVyYXRvclByb3RvdHlwZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmICghaXNDYWxsYWJsZShDdXJyZW50SXRlcmF0b3JQcm90b3R5cGVbSVRFUkFUT1JdKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZpbmVCdWlsdEluKEN1cnJlbnRJdGVyYXRvclByb3RvdHlwZSwgSVRFUkFUT1IsIHJldHVyblRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNldFRvU3RyaW5nVGFnKEN1cnJlbnRJdGVyYXRvclByb3RvdHlwZSwgVE9fU1RSSU5HX1RBRywgdHJ1ZSwgdHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoSVNfUFVSRSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBJdGVyYXRvcnNbVE9fU1RSSU5HX1RBR10gPSByZXR1cm5UaGlzOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmIChQUk9QRVJfRlVOQ1RJT05fTkFNRSAmJiBERUZBVUxUID09IFZBTFVFUyAmJiBuYXRpdmVJdGVyYXRvciAmJiBuYXRpdmVJdGVyYXRvci5uYW1lICE9PSBWQUxVRVMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFJU19QVVJFICYmIENPTkZJR1VSQUJMRV9GVU5DVElPTl9OQU1FKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjcmVhdGVOb25FbnVtZXJhYmxlUHJvcGVydHkoSXRlcmFibGVQcm90b3R5cGUsICduYW1lJywgVkFMVUVTKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIElOQ09SUkVDVF9WQUxVRVNfTkFNRSA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0SXRlcmF0b3IgPSBmdW5jdGlvbiB2YWx1ZXMoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGNhbGwobmF0aXZlSXRlcmF0b3IsIHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBpZiAoREVGQVVMVCkgewogICAgICAgICAgICAgICAgICAgICAgICBtZXRob2RzID0gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWVzOiBnZXRJdGVyYXRpb25NZXRob2QoVkFMVUVTKSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGtleXM6IElTX1NFVCA/IGRlZmF1bHRJdGVyYXRvciA6IGdldEl0ZXJhdGlvbk1ldGhvZChLRVlTKSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVudHJpZXM6IGdldEl0ZXJhdGlvbk1ldGhvZChFTlRSSUVTKQogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoRk9SQ0VEKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChLRVkgaW4gbWV0aG9kcykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChCVUdHWV9TQUZBUklfSVRFUkFUT1JTIHx8IElOQ09SUkVDVF9WQUxVRVNfTkFNRSB8fCAhKEtFWSBpbiBJdGVyYWJsZVByb3RvdHlwZSkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVmaW5lQnVpbHRJbihJdGVyYWJsZVByb3RvdHlwZSwgS0VZLCBtZXRob2RzW0tFWV0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgZWxzZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgJCh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGFyZ2V0OiBOQU1FLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHByb3RvOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvcmNlZDogQlVHR1lfU0FGQVJJX0lURVJBVE9SUyB8fCBJTkNPUlJFQ1RfVkFMVUVTX05BTUUKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sIG1ldGhvZHMpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBpZiAoKCFJU19QVVJFIHx8IEZPUkNFRCkgJiYgSXRlcmFibGVQcm90b3R5cGVbSVRFUkFUT1JdICE9PSBkZWZhdWx0SXRlcmF0b3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgZGVmaW5lQnVpbHRJbihJdGVyYWJsZVByb3RvdHlwZSwgSVRFUkFUT1IsIGRlZmF1bHRJdGVyYXRvciwgeyBuYW1lOiBERUZBVUxUIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBJdGVyYXRvcnNbTkFNRV0gPSBkZWZhdWx0SXRlcmF0b3I7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG1ldGhvZHM7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiA5NCAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKICAgICAgICAgICAgICAgIHZhciBJdGVyYXRvclByb3RvdHlwZSA9IChfX3dfcGRmanNfcmVxdWlyZV9fKDk1KS5JdGVyYXRvclByb3RvdHlwZSk7CiAgICAgICAgICAgICAgICB2YXIgY3JlYXRlID0gX193X3BkZmpzX3JlcXVpcmVfXyg3Myk7CiAgICAgICAgICAgICAgICB2YXIgY3JlYXRlUHJvcGVydHlEZXNjcmlwdG9yID0gX193X3BkZmpzX3JlcXVpcmVfXygxNCk7CiAgICAgICAgICAgICAgICB2YXIgc2V0VG9TdHJpbmdUYWcgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDk2KTsKICAgICAgICAgICAgICAgIHZhciBJdGVyYXRvcnMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDkyKTsKICAgICAgICAgICAgICAgIHZhciByZXR1cm5UaGlzID0gZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzOwogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKEl0ZXJhdG9yQ29uc3RydWN0b3IsIE5BTUUsIG5leHQsIEVOVU1FUkFCTEVfTkVYVCkgewogICAgICAgICAgICAgICAgICAgIHZhciBUT19TVFJJTkdfVEFHID0gTkFNRSArICcgSXRlcmF0b3InOwogICAgICAgICAgICAgICAgICAgIEl0ZXJhdG9yQ29uc3RydWN0b3IucHJvdG90eXBlID0gY3JlYXRlKEl0ZXJhdG9yUHJvdG90eXBlLCB7IG5leHQ6IGNyZWF0ZVByb3BlcnR5RGVzY3JpcHRvcigrIUVOVU1FUkFCTEVfTkVYVCwgbmV4dCkgfSk7CiAgICAgICAgICAgICAgICAgICAgc2V0VG9TdHJpbmdUYWcoSXRlcmF0b3JDb25zdHJ1Y3RvciwgVE9fU1RSSU5HX1RBRywgZmFsc2UsIHRydWUpOwogICAgICAgICAgICAgICAgICAgIEl0ZXJhdG9yc1tUT19TVFJJTkdfVEFHXSA9IHJldHVyblRoaXM7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIEl0ZXJhdG9yQ29uc3RydWN0b3I7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiA5NSAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKICAgICAgICAgICAgICAgIHZhciBmYWlscyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTApOwogICAgICAgICAgICAgICAgdmFyIGlzQ2FsbGFibGUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDI0KTsKICAgICAgICAgICAgICAgIHZhciBpc09iamVjdCA9IF9fd19wZGZqc19yZXF1aXJlX18oMjMpOwogICAgICAgICAgICAgICAgdmFyIGNyZWF0ZSA9IF9fd19wZGZqc19yZXF1aXJlX18oNzMpOwogICAgICAgICAgICAgICAgdmFyIGdldFByb3RvdHlwZU9mID0gX193X3BkZmpzX3JlcXVpcmVfXyg4NSk7CiAgICAgICAgICAgICAgICB2YXIgZGVmaW5lQnVpbHRJbiA9IF9fd19wZGZqc19yZXF1aXJlX18oNTEpOwogICAgICAgICAgICAgICAgdmFyIHdlbGxLbm93blN5bWJvbCA9IF9fd19wZGZqc19yZXF1aXJlX18oMzcpOwogICAgICAgICAgICAgICAgdmFyIElTX1BVUkUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDM5KTsKICAgICAgICAgICAgICAgIHZhciBJVEVSQVRPUiA9IHdlbGxLbm93blN5bWJvbCgnaXRlcmF0b3InKTsKICAgICAgICAgICAgICAgIHZhciBCVUdHWV9TQUZBUklfSVRFUkFUT1JTID0gZmFsc2U7CiAgICAgICAgICAgICAgICB2YXIgSXRlcmF0b3JQcm90b3R5cGUsIFByb3RvdHlwZU9mQXJyYXlJdGVyYXRvclByb3RvdHlwZSwgYXJyYXlJdGVyYXRvcjsKICAgICAgICAgICAgICAgIGlmIChbXS5rZXlzKSB7CiAgICAgICAgICAgICAgICAgICAgYXJyYXlJdGVyYXRvciA9IFtdLmtleXMoKTsKICAgICAgICAgICAgICAgICAgICBpZiAoISgnbmV4dCcgaW4gYXJyYXlJdGVyYXRvcikpCiAgICAgICAgICAgICAgICAgICAgICAgIEJVR0dZX1NBRkFSSV9JVEVSQVRPUlMgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgIGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICBQcm90b3R5cGVPZkFycmF5SXRlcmF0b3JQcm90b3R5cGUgPSBnZXRQcm90b3R5cGVPZihnZXRQcm90b3R5cGVPZihhcnJheUl0ZXJhdG9yKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChQcm90b3R5cGVPZkFycmF5SXRlcmF0b3JQcm90b3R5cGUgIT09IE9iamVjdC5wcm90b3R5cGUpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBJdGVyYXRvclByb3RvdHlwZSA9IFByb3RvdHlwZU9mQXJyYXlJdGVyYXRvclByb3RvdHlwZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB2YXIgTkVXX0lURVJBVE9SX1BST1RPVFlQRSA9ICFpc09iamVjdChJdGVyYXRvclByb3RvdHlwZSkgfHwgZmFpbHMoZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHZhciB0ZXN0ID0ge307CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIEl0ZXJhdG9yUHJvdG90eXBlW0lURVJBVE9SXS5jYWxsKHRlc3QpICE9PSB0ZXN0OwogICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICBpZiAoTkVXX0lURVJBVE9SX1BST1RPVFlQRSkKICAgICAgICAgICAgICAgICAgICBJdGVyYXRvclByb3RvdHlwZSA9IHt9OwogICAgICAgICAgICAgICAgZWxzZSBpZiAoSVNfUFVSRSkKICAgICAgICAgICAgICAgICAgICBJdGVyYXRvclByb3RvdHlwZSA9IGNyZWF0ZShJdGVyYXRvclByb3RvdHlwZSk7CiAgICAgICAgICAgICAgICBpZiAoIWlzQ2FsbGFibGUoSXRlcmF0b3JQcm90b3R5cGVbSVRFUkFUT1JdKSkgewogICAgICAgICAgICAgICAgICAgIGRlZmluZUJ1aWx0SW4oSXRlcmF0b3JQcm90b3R5cGUsIElURVJBVE9SLCBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzOwogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSB7CiAgICAgICAgICAgICAgICAgICAgSXRlcmF0b3JQcm90b3R5cGU6IEl0ZXJhdG9yUHJvdG90eXBlLAogICAgICAgICAgICAgICAgICAgIEJVR0dZX1NBRkFSSV9JVEVSQVRPUlM6IEJVR0dZX1NBRkFSSV9JVEVSQVRPUlMKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDk2ICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgZGVmaW5lUHJvcGVydHkgPSAoX193X3BkZmpzX3JlcXVpcmVfXyg0OCkuZik7CiAgICAgICAgICAgICAgICB2YXIgaGFzT3duID0gX193X3BkZmpzX3JlcXVpcmVfXyg0Mik7CiAgICAgICAgICAgICAgICB2YXIgd2VsbEtub3duU3ltYm9sID0gX193X3BkZmpzX3JlcXVpcmVfXygzNyk7CiAgICAgICAgICAgICAgICB2YXIgVE9fU1RSSU5HX1RBRyA9IHdlbGxLbm93blN5bWJvbCgndG9TdHJpbmdUYWcnKTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKHRhcmdldCwgVEFHLCBTVEFUSUMpIHsKICAgICAgICAgICAgICAgICAgICBpZiAodGFyZ2V0ICYmICFTVEFUSUMpCiAgICAgICAgICAgICAgICAgICAgICAgIHRhcmdldCA9IHRhcmdldC5wcm90b3R5cGU7CiAgICAgICAgICAgICAgICAgICAgaWYgKHRhcmdldCAmJiAhaGFzT3duKHRhcmdldCwgVE9fU1RSSU5HX1RBRykpIHsKICAgICAgICAgICAgICAgICAgICAgICAgZGVmaW5lUHJvcGVydHkodGFyZ2V0LCBUT19TVFJJTkdfVEFHLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogVEFHCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDk3ICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlKSA9PiB7CgogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAodmFsdWUsIGRvbmUpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdmFsdWUsCiAgICAgICAgICAgICAgICAgICAgICAgIGRvbmU6IGRvbmUKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogOTggKi8KICAgICAgICAgICAgLyoqKi8gKChfX3VudXNlZF93ZWJwYWNrX21vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIFRPX1NUUklOR19UQUdfU1VQUE9SVCA9IF9fd19wZGZqc19yZXF1aXJlX18oODMpOwogICAgICAgICAgICAgICAgdmFyIGRlZmluZUJ1aWx0SW4gPSBfX3dfcGRmanNfcmVxdWlyZV9fKDUxKTsKICAgICAgICAgICAgICAgIHZhciB0b1N0cmluZyA9IF9fd19wZGZqc19yZXF1aXJlX18oOTkpOwogICAgICAgICAgICAgICAgaWYgKCFUT19TVFJJTkdfVEFHX1NVUFBPUlQpIHsKICAgICAgICAgICAgICAgICAgICBkZWZpbmVCdWlsdEluKE9iamVjdC5wcm90b3R5cGUsICd0b1N0cmluZycsIHRvU3RyaW5nLCB7IHVuc2FmZTogdHJ1ZSB9KTsKICAgICAgICAgICAgICAgIH0KCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogOTkgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgICJ1c2Ugc3RyaWN0IjsKCiAgICAgICAgICAgICAgICB2YXIgVE9fU1RSSU5HX1RBR19TVVBQT1JUID0gX193X3BkZmpzX3JlcXVpcmVfXyg4Myk7CiAgICAgICAgICAgICAgICB2YXIgY2xhc3NvZiA9IF9fd19wZGZqc19yZXF1aXJlX18oODIpOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBUT19TVFJJTkdfVEFHX1NVUFBPUlQgPyB7fS50b1N0cmluZyA6IGZ1bmN0aW9uIHRvU3RyaW5nKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiAnW29iamVjdCAnICsgY2xhc3NvZih0aGlzKSArICddJzsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDEwMCAqLwogICAgICAgICAgICAvKioqLyAoKF9fdW51c2VkX3dlYnBhY2tfbW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICBfX3dfcGRmanNfcmVxdWlyZV9fKDEwMSk7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDEwMSAqLwogICAgICAgICAgICAvKioqLyAoKF9fdW51c2VkX3dlYnBhY2tfbW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICAidXNlIHN0cmljdCI7CgogICAgICAgICAgICAgICAgdmFyIGNvbGxlY3Rpb24gPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEwMik7CiAgICAgICAgICAgICAgICB2YXIgY29sbGVjdGlvblN0cm9uZyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTIwKTsKICAgICAgICAgICAgICAgIGNvbGxlY3Rpb24oJ01hcCcsIGZ1bmN0aW9uIChpbml0KSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZ1bmN0aW9uIE1hcCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGluaXQodGhpcywgYXJndW1lbnRzLmxlbmd0aCA/IGFyZ3VtZW50c1swXSA6IHVuZGVmaW5lZCk7CiAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIH0sIGNvbGxlY3Rpb25TdHJvbmcpOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxMDIgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgICJ1c2Ugc3RyaWN0IjsKCiAgICAgICAgICAgICAgICB2YXIgJCA9IF9fd19wZGZqc19yZXF1aXJlX18oNik7CiAgICAgICAgICAgICAgICB2YXIgZ2xvYmFsID0gX193X3BkZmpzX3JlcXVpcmVfXyg3KTsKICAgICAgICAgICAgICAgIHZhciB1bmN1cnJ5VGhpcyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTcpOwogICAgICAgICAgICAgICAgdmFyIGlzRm9yY2VkID0gX193X3BkZmpzX3JlcXVpcmVfXyg3MSk7CiAgICAgICAgICAgICAgICB2YXIgZGVmaW5lQnVpbHRJbiA9IF9fd19wZGZqc19yZXF1aXJlX18oNTEpOwogICAgICAgICAgICAgICAgdmFyIEludGVybmFsTWV0YWRhdGFNb2R1bGUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEwMyk7CiAgICAgICAgICAgICAgICB2YXIgaXRlcmF0ZSA9IF9fd19wZGZqc19yZXF1aXJlX18oMTEwKTsKICAgICAgICAgICAgICAgIHZhciBhbkluc3RhbmNlID0gX193X3BkZmpzX3JlcXVpcmVfXygxMTcpOwogICAgICAgICAgICAgICAgdmFyIGlzQ2FsbGFibGUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDI0KTsKICAgICAgICAgICAgICAgIHZhciBpc051bGxPclVuZGVmaW5lZCA9IF9fd19wZGZqc19yZXF1aXJlX18oMjApOwogICAgICAgICAgICAgICAgdmFyIGlzT2JqZWN0ID0gX193X3BkZmpzX3JlcXVpcmVfXygyMyk7CiAgICAgICAgICAgICAgICB2YXIgZmFpbHMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEwKTsKICAgICAgICAgICAgICAgIHZhciBjaGVja0NvcnJlY3RuZXNzT2ZJdGVyYXRpb24gPSBfX3dfcGRmanNfcmVxdWlyZV9fKDExOCk7CiAgICAgICAgICAgICAgICB2YXIgc2V0VG9TdHJpbmdUYWcgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDk2KTsKICAgICAgICAgICAgICAgIHZhciBpbmhlcml0SWZSZXF1aXJlZCA9IF9fd19wZGZqc19yZXF1aXJlX18oMTE5KTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKENPTlNUUlVDVE9SX05BTUUsIHdyYXBwZXIsIGNvbW1vbikgewogICAgICAgICAgICAgICAgICAgIHZhciBJU19NQVAgPSBDT05TVFJVQ1RPUl9OQU1FLmluZGV4T2YoJ01hcCcpICE9PSAtMTsKICAgICAgICAgICAgICAgICAgICB2YXIgSVNfV0VBSyA9IENPTlNUUlVDVE9SX05BTUUuaW5kZXhPZignV2VhaycpICE9PSAtMTsKICAgICAgICAgICAgICAgICAgICB2YXIgQURERVIgPSBJU19NQVAgPyAnc2V0JyA6ICdhZGQnOwogICAgICAgICAgICAgICAgICAgIHZhciBOYXRpdmVDb25zdHJ1Y3RvciA9IGdsb2JhbFtDT05TVFJVQ1RPUl9OQU1FXTsKICAgICAgICAgICAgICAgICAgICB2YXIgTmF0aXZlUHJvdG90eXBlID0gTmF0aXZlQ29uc3RydWN0b3IgJiYgTmF0aXZlQ29uc3RydWN0b3IucHJvdG90eXBlOwogICAgICAgICAgICAgICAgICAgIHZhciBDb25zdHJ1Y3RvciA9IE5hdGl2ZUNvbnN0cnVjdG9yOwogICAgICAgICAgICAgICAgICAgIHZhciBleHBvcnRlZCA9IHt9OwogICAgICAgICAgICAgICAgICAgIHZhciBmaXhNZXRob2QgPSBmdW5jdGlvbiAoS0VZKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciB1bmN1cnJpZWROYXRpdmVNZXRob2QgPSB1bmN1cnJ5VGhpcyhOYXRpdmVQcm90b3R5cGVbS0VZXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGRlZmluZUJ1aWx0SW4oTmF0aXZlUHJvdG90eXBlLCBLRVksIEtFWSA9PSAnYWRkJyA/IGZ1bmN0aW9uIGFkZCh2YWx1ZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdW5jdXJyaWVkTmF0aXZlTWV0aG9kKHRoaXMsIHZhbHVlID09PSAwID8gMCA6IHZhbHVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzOwogICAgICAgICAgICAgICAgICAgICAgICB9IDogS0VZID09ICdkZWxldGUnID8gZnVuY3Rpb24gKGtleSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIElTX1dFQUsgJiYgIWlzT2JqZWN0KGtleSkgPyBmYWxzZSA6IHVuY3VycmllZE5hdGl2ZU1ldGhvZCh0aGlzLCBrZXkgPT09IDAgPyAwIDoga2V5KTsKICAgICAgICAgICAgICAgICAgICAgICAgfSA6IEtFWSA9PSAnZ2V0JyA/IGZ1bmN0aW9uIGdldChrZXkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBJU19XRUFLICYmICFpc09iamVjdChrZXkpID8gdW5kZWZpbmVkIDogdW5jdXJyaWVkTmF0aXZlTWV0aG9kKHRoaXMsIGtleSA9PT0gMCA/IDAgOiBrZXkpOwogICAgICAgICAgICAgICAgICAgICAgICB9IDogS0VZID09ICdoYXMnID8gZnVuY3Rpb24gaGFzKGtleSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIElTX1dFQUsgJiYgIWlzT2JqZWN0KGtleSkgPyBmYWxzZSA6IHVuY3VycmllZE5hdGl2ZU1ldGhvZCh0aGlzLCBrZXkgPT09IDAgPyAwIDoga2V5KTsKICAgICAgICAgICAgICAgICAgICAgICAgfSA6IGZ1bmN0aW9uIHNldChrZXksIHZhbHVlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB1bmN1cnJpZWROYXRpdmVNZXRob2QodGhpcywga2V5ID09PSAwID8gMCA6IGtleSwgdmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXM7CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgdmFyIFJFUExBQ0UgPSBpc0ZvcmNlZChDT05TVFJVQ1RPUl9OQU1FLCAhaXNDYWxsYWJsZShOYXRpdmVDb25zdHJ1Y3RvcikgfHwgIShJU19XRUFLIHx8IE5hdGl2ZVByb3RvdHlwZS5mb3JFYWNoICYmICFmYWlscyhmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIG5ldyBOYXRpdmVDb25zdHJ1Y3RvcigpLmVudHJpZXMoKS5uZXh0KCk7CiAgICAgICAgICAgICAgICAgICAgfSkpKTsKICAgICAgICAgICAgICAgICAgICBpZiAoUkVQTEFDRSkgewogICAgICAgICAgICAgICAgICAgICAgICBDb25zdHJ1Y3RvciA9IGNvbW1vbi5nZXRDb25zdHJ1Y3Rvcih3cmFwcGVyLCBDT05TVFJVQ1RPUl9OQU1FLCBJU19NQVAsIEFEREVSKTsKICAgICAgICAgICAgICAgICAgICAgICAgSW50ZXJuYWxNZXRhZGF0YU1vZHVsZS5lbmFibGUoKTsKICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGlzRm9yY2VkKENPTlNUUlVDVE9SX05BTUUsIHRydWUpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBpbnN0YW5jZSA9IG5ldyBDb25zdHJ1Y3RvcigpOwogICAgICAgICAgICAgICAgICAgICAgICB2YXIgSEFTTlRfQ0hBSU5JTkcgPSBpbnN0YW5jZVtBRERFUl0oSVNfV0VBSyA/IHt9IDogLTAsIDEpICE9IGluc3RhbmNlOwogICAgICAgICAgICAgICAgICAgICAgICB2YXIgVEhST1dTX09OX1BSSU1JVElWRVMgPSBmYWlscyhmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnN0YW5jZS5oYXMoMSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB2YXIgQUNDRVBUX0lURVJBQkxFUyA9IGNoZWNrQ29ycmVjdG5lc3NPZkl0ZXJhdGlvbihmdW5jdGlvbiAoaXRlcmFibGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5ldyBOYXRpdmVDb25zdHJ1Y3RvcihpdGVyYWJsZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB2YXIgQlVHR1lfWkVSTyA9ICFJU19XRUFLICYmIGZhaWxzKGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciAkaW5zdGFuY2UgPSBuZXcgTmF0aXZlQ29uc3RydWN0b3IoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBpbmRleCA9IDU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3aGlsZSAoaW5kZXgtLSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAkaW5zdGFuY2VbQURERVJdKGluZGV4LCBpbmRleCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gISRpbnN0YW5jZS5oYXMoLTApOwogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFBQ0NFUFRfSVRFUkFCTEVTKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBDb25zdHJ1Y3RvciA9IHdyYXBwZXIoZnVuY3Rpb24gKGR1bW15LCBpdGVyYWJsZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFuSW5zdGFuY2UoZHVtbXksIE5hdGl2ZVByb3RvdHlwZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHRoYXQgPSBpbmhlcml0SWZSZXF1aXJlZChuZXcgTmF0aXZlQ29uc3RydWN0b3IoKSwgZHVtbXksIENvbnN0cnVjdG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWlzTnVsbE9yVW5kZWZpbmVkKGl0ZXJhYmxlKSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaXRlcmF0ZShpdGVyYWJsZSwgdGhhdFtBRERFUl0sIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoYXQ6IHRoYXQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBBU19FTlRSSUVTOiBJU19NQVAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoYXQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIENvbnN0cnVjdG9yLnByb3RvdHlwZSA9IE5hdGl2ZVByb3RvdHlwZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIE5hdGl2ZVByb3RvdHlwZS5jb25zdHJ1Y3RvciA9IENvbnN0cnVjdG9yOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChUSFJPV1NfT05fUFJJTUlUSVZFUyB8fCBCVUdHWV9aRVJPKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmaXhNZXRob2QoJ2RlbGV0ZScpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZml4TWV0aG9kKCdoYXMnKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIElTX01BUCAmJiBmaXhNZXRob2QoJ2dldCcpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChCVUdHWV9aRVJPIHx8IEhBU05UX0NIQUlOSU5HKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgZml4TWV0aG9kKEFEREVSKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKElTX1dFQUsgJiYgTmF0aXZlUHJvdG90eXBlLmNsZWFyKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVsZXRlIE5hdGl2ZVByb3RvdHlwZS5jbGVhcjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZXhwb3J0ZWRbQ09OU1RSVUNUT1JfTkFNRV0gPSBDb25zdHJ1Y3RvcjsKICAgICAgICAgICAgICAgICAgICAkKHsKICAgICAgICAgICAgICAgICAgICAgICAgZ2xvYmFsOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcjogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgZm9yY2VkOiBDb25zdHJ1Y3RvciAhPSBOYXRpdmVDb25zdHJ1Y3RvcgogICAgICAgICAgICAgICAgICAgIH0sIGV4cG9ydGVkKTsKICAgICAgICAgICAgICAgICAgICBzZXRUb1N0cmluZ1RhZyhDb25zdHJ1Y3RvciwgQ09OU1RSVUNUT1JfTkFNRSk7CiAgICAgICAgICAgICAgICAgICAgaWYgKCFJU19XRUFLKQogICAgICAgICAgICAgICAgICAgICAgICBjb21tb24uc2V0U3Ryb25nKENvbnN0cnVjdG9yLCBDT05TVFJVQ1RPUl9OQU1FLCBJU19NQVApOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBDb25zdHJ1Y3RvcjsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDEwMyAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyICQgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDYpOwogICAgICAgICAgICAgICAgdmFyIHVuY3VycnlUaGlzID0gX193X3BkZmpzX3JlcXVpcmVfXygxNyk7CiAgICAgICAgICAgICAgICB2YXIgaGlkZGVuS2V5cyA9IF9fd19wZGZqc19yZXF1aXJlX18oNTgpOwogICAgICAgICAgICAgICAgdmFyIGlzT2JqZWN0ID0gX193X3BkZmpzX3JlcXVpcmVfXygyMyk7CiAgICAgICAgICAgICAgICB2YXIgaGFzT3duID0gX193X3BkZmpzX3JlcXVpcmVfXyg0Mik7CiAgICAgICAgICAgICAgICB2YXIgZGVmaW5lUHJvcGVydHkgPSAoX193X3BkZmpzX3JlcXVpcmVfXyg0OCkuZik7CiAgICAgICAgICAgICAgICB2YXIgZ2V0T3duUHJvcGVydHlOYW1lc01vZHVsZSA9IF9fd19wZGZqc19yZXF1aXJlX18oNjEpOwogICAgICAgICAgICAgICAgdmFyIGdldE93blByb3BlcnR5TmFtZXNFeHRlcm5hbE1vZHVsZSA9IF9fd19wZGZqc19yZXF1aXJlX18oMTA0KTsKICAgICAgICAgICAgICAgIHZhciBpc0V4dGVuc2libGUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEwNyk7CiAgICAgICAgICAgICAgICB2YXIgdWlkID0gX193X3BkZmpzX3JlcXVpcmVfXyg0NCk7CiAgICAgICAgICAgICAgICB2YXIgRlJFRVpJTkcgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEwOSk7CiAgICAgICAgICAgICAgICB2YXIgUkVRVUlSRUQgPSBmYWxzZTsKICAgICAgICAgICAgICAgIHZhciBNRVRBREFUQSA9IHVpZCgnbWV0YScpOwogICAgICAgICAgICAgICAgdmFyIGlkID0gMDsKICAgICAgICAgICAgICAgIHZhciBzZXRNZXRhZGF0YSA9IGZ1bmN0aW9uIChpdCkgewogICAgICAgICAgICAgICAgICAgIGRlZmluZVByb3BlcnR5KGl0LCBNRVRBREFUQSwgewogICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogewogICAgICAgICAgICAgICAgICAgICAgICAgICAgb2JqZWN0SUQ6ICdPJyArIGlkKyssCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3ZWFrRGF0YToge30KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIHZhciBmYXN0S2V5ID0gZnVuY3Rpb24gKGl0LCBjcmVhdGUpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoIWlzT2JqZWN0KGl0KSkKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHR5cGVvZiBpdCA9PSAnc3ltYm9sJyA/IGl0IDogKHR5cGVvZiBpdCA9PSAnc3RyaW5nJyA/ICdTJyA6ICdQJykgKyBpdDsKICAgICAgICAgICAgICAgICAgICBpZiAoIWhhc093bihpdCwgTUVUQURBVEEpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghaXNFeHRlbnNpYmxlKGl0KSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAnRic7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghY3JlYXRlKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICdFJzsKICAgICAgICAgICAgICAgICAgICAgICAgc2V0TWV0YWRhdGEoaXQpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gaXRbTUVUQURBVEFdLm9iamVjdElEOwogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIHZhciBnZXRXZWFrRGF0YSA9IGZ1bmN0aW9uIChpdCwgY3JlYXRlKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKCFoYXNPd24oaXQsIE1FVEFEQVRBKSkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWlzRXh0ZW5zaWJsZShpdCkpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFjcmVhdGUpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHNldE1ldGFkYXRhKGl0KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGl0W01FVEFEQVRBXS53ZWFrRGF0YTsKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB2YXIgb25GcmVlemUgPSBmdW5jdGlvbiAoaXQpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoRlJFRVpJTkcgJiYgUkVRVUlSRUQgJiYgaXNFeHRlbnNpYmxlKGl0KSAmJiAhaGFzT3duKGl0LCBNRVRBREFUQSkpCiAgICAgICAgICAgICAgICAgICAgICAgIHNldE1ldGFkYXRhKGl0KTsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gaXQ7CiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgdmFyIGVuYWJsZSA9IGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICBtZXRhLmVuYWJsZSA9IGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIFJFUVVJUkVEID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICB2YXIgZ2V0T3duUHJvcGVydHlOYW1lcyA9IGdldE93blByb3BlcnR5TmFtZXNNb2R1bGUuZjsKICAgICAgICAgICAgICAgICAgICB2YXIgc3BsaWNlID0gdW5jdXJyeVRoaXMoW10uc3BsaWNlKTsKICAgICAgICAgICAgICAgICAgICB2YXIgdGVzdCA9IHt9OwogICAgICAgICAgICAgICAgICAgIHRlc3RbTUVUQURBVEFdID0gMTsKICAgICAgICAgICAgICAgICAgICBpZiAoZ2V0T3duUHJvcGVydHlOYW1lcyh0ZXN0KS5sZW5ndGgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgZ2V0T3duUHJvcGVydHlOYW1lc01vZHVsZS5mID0gZnVuY3Rpb24gKGl0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgcmVzdWx0ID0gZ2V0T3duUHJvcGVydHlOYW1lcyhpdCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKHZhciBpID0gMCwgbGVuZ3RoID0gcmVzdWx0Lmxlbmd0aDsgaSA8IGxlbmd0aDsgaSsrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHJlc3VsdFtpXSA9PT0gTUVUQURBVEEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3BsaWNlKHJlc3VsdCwgaSwgMSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiByZXN1bHQ7CiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgICQoewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGFyZ2V0OiAnT2JqZWN0JywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0YXQ6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3JjZWQ6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgfSwgeyBnZXRPd25Qcm9wZXJ0eU5hbWVzOiBnZXRPd25Qcm9wZXJ0eU5hbWVzRXh0ZXJuYWxNb2R1bGUuZiB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgdmFyIG1ldGEgPSBtb2R1bGUuZXhwb3J0cyA9IHsKICAgICAgICAgICAgICAgICAgICBlbmFibGU6IGVuYWJsZSwKICAgICAgICAgICAgICAgICAgICBmYXN0S2V5OiBmYXN0S2V5LAogICAgICAgICAgICAgICAgICAgIGdldFdlYWtEYXRhOiBnZXRXZWFrRGF0YSwKICAgICAgICAgICAgICAgICAgICBvbkZyZWV6ZTogb25GcmVlemUKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBoaWRkZW5LZXlzW01FVEFEQVRBXSA9IHRydWU7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDEwNCAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIGNsYXNzb2YgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE4KTsKICAgICAgICAgICAgICAgIHZhciB0b0luZGV4ZWRPYmplY3QgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE1KTsKICAgICAgICAgICAgICAgIHZhciAkZ2V0T3duUHJvcGVydHlOYW1lcyA9IChfX3dfcGRmanNfcmVxdWlyZV9fKDYxKS5mKTsKICAgICAgICAgICAgICAgIHZhciBhcnJheVNsaWNlID0gX193X3BkZmpzX3JlcXVpcmVfXygxMDUpOwogICAgICAgICAgICAgICAgdmFyIHdpbmRvd05hbWVzID0gdHlwZW9mIHdpbmRvdyA9PSAnb2JqZWN0JyAmJiB3aW5kb3cgJiYgT2JqZWN0LmdldE93blByb3BlcnR5TmFtZXMgPyBPYmplY3QuZ2V0T3duUHJvcGVydHlOYW1lcyh3aW5kb3cpIDogW107CiAgICAgICAgICAgICAgICB2YXIgZ2V0V2luZG93TmFtZXMgPSBmdW5jdGlvbiAoaXQpIHsKICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gJGdldE93blByb3BlcnR5TmFtZXMoaXQpOwogICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBhcnJheVNsaWNlKHdpbmRvd05hbWVzKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMuZiA9IGZ1bmN0aW9uIGdldE93blByb3BlcnR5TmFtZXMoaXQpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gd2luZG93TmFtZXMgJiYgY2xhc3NvZihpdCkgPT0gJ1dpbmRvdycgPyBnZXRXaW5kb3dOYW1lcyhpdCkgOiAkZ2V0T3duUHJvcGVydHlOYW1lcyh0b0luZGV4ZWRPYmplY3QoaXQpKTsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDEwNSAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIHRvQWJzb2x1dGVJbmRleCA9IF9fd19wZGZqc19yZXF1aXJlX18oNjQpOwogICAgICAgICAgICAgICAgdmFyIGxlbmd0aE9mQXJyYXlMaWtlID0gX193X3BkZmpzX3JlcXVpcmVfXyg2Nyk7CiAgICAgICAgICAgICAgICB2YXIgY3JlYXRlUHJvcGVydHkgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEwNik7CiAgICAgICAgICAgICAgICB2YXIgJEFycmF5ID0gQXJyYXk7CiAgICAgICAgICAgICAgICB2YXIgbWF4ID0gTWF0aC5tYXg7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uIChPLCBzdGFydCwgZW5kKSB7CiAgICAgICAgICAgICAgICAgICAgdmFyIGxlbmd0aCA9IGxlbmd0aE9mQXJyYXlMaWtlKE8pOwogICAgICAgICAgICAgICAgICAgIHZhciBrID0gdG9BYnNvbHV0ZUluZGV4KHN0YXJ0LCBsZW5ndGgpOwogICAgICAgICAgICAgICAgICAgIHZhciBmaW4gPSB0b0Fic29sdXRlSW5kZXgoZW5kID09PSB1bmRlZmluZWQgPyBsZW5ndGggOiBlbmQsIGxlbmd0aCk7CiAgICAgICAgICAgICAgICAgICAgdmFyIHJlc3VsdCA9ICRBcnJheShtYXgoZmluIC0gaywgMCkpOwogICAgICAgICAgICAgICAgICAgIGZvciAodmFyIG4gPSAwOyBrIDwgZmluOyBrKyssIG4rKykKICAgICAgICAgICAgICAgICAgICAgICAgY3JlYXRlUHJvcGVydHkocmVzdWx0LCBuLCBPW2tdKTsKICAgICAgICAgICAgICAgICAgICByZXN1bHQubGVuZ3RoID0gbjsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gcmVzdWx0OwogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTA2ICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICAidXNlIHN0cmljdCI7CgogICAgICAgICAgICAgICAgdmFyIHRvUHJvcGVydHlLZXkgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDIxKTsKICAgICAgICAgICAgICAgIHZhciBkZWZpbmVQcm9wZXJ0eU1vZHVsZSA9IF9fd19wZGZqc19yZXF1aXJlX18oNDgpOwogICAgICAgICAgICAgICAgdmFyIGNyZWF0ZVByb3BlcnR5RGVzY3JpcHRvciA9IF9fd19wZGZqc19yZXF1aXJlX18oMTQpOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAob2JqZWN0LCBrZXksIHZhbHVlKSB7CiAgICAgICAgICAgICAgICAgICAgdmFyIHByb3BlcnR5S2V5ID0gdG9Qcm9wZXJ0eUtleShrZXkpOwogICAgICAgICAgICAgICAgICAgIGlmIChwcm9wZXJ0eUtleSBpbiBvYmplY3QpCiAgICAgICAgICAgICAgICAgICAgICAgIGRlZmluZVByb3BlcnR5TW9kdWxlLmYob2JqZWN0LCBwcm9wZXJ0eUtleSwgY3JlYXRlUHJvcGVydHlEZXNjcmlwdG9yKDAsIHZhbHVlKSk7CiAgICAgICAgICAgICAgICAgICAgZWxzZQogICAgICAgICAgICAgICAgICAgICAgICBvYmplY3RbcHJvcGVydHlLZXldID0gdmFsdWU7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxMDcgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBmYWlscyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTApOwogICAgICAgICAgICAgICAgdmFyIGlzT2JqZWN0ID0gX193X3BkZmpzX3JlcXVpcmVfXygyMyk7CiAgICAgICAgICAgICAgICB2YXIgY2xhc3NvZiA9IF9fd19wZGZqc19yZXF1aXJlX18oMTgpOwogICAgICAgICAgICAgICAgdmFyIEFSUkFZX0JVRkZFUl9OT05fRVhURU5TSUJMRSA9IF9fd19wZGZqc19yZXF1aXJlX18oMTA4KTsKICAgICAgICAgICAgICAgIHZhciAkaXNFeHRlbnNpYmxlID0gT2JqZWN0LmlzRXh0ZW5zaWJsZTsKICAgICAgICAgICAgICAgIHZhciBGQUlMU19PTl9QUklNSVRJVkVTID0gZmFpbHMoZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgICRpc0V4dGVuc2libGUoMSk7CiAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gRkFJTFNfT05fUFJJTUlUSVZFUyB8fCBBUlJBWV9CVUZGRVJfTk9OX0VYVEVOU0lCTEUgPyBmdW5jdGlvbiBpc0V4dGVuc2libGUoaXQpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoIWlzT2JqZWN0KGl0KSkKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgICAgICAgICAgIGlmIChBUlJBWV9CVUZGRVJfTk9OX0VYVEVOU0lCTEUgJiYgY2xhc3NvZihpdCkgPT0gJ0FycmF5QnVmZmVyJykKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgICAgICAgICAgIHJldHVybiAkaXNFeHRlbnNpYmxlID8gJGlzRXh0ZW5zaWJsZShpdCkgOiB0cnVlOwogICAgICAgICAgICAgICAgfSA6ICRpc0V4dGVuc2libGU7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDEwOCAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIGZhaWxzID0gX193X3BkZmpzX3JlcXVpcmVfXygxMCk7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IGZhaWxzKGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIEFycmF5QnVmZmVyID09ICdmdW5jdGlvbicpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGJ1ZmZlciA9IG5ldyBBcnJheUJ1ZmZlcig4KTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKE9iamVjdC5pc0V4dGVuc2libGUoYnVmZmVyKSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShidWZmZXIsICdhJywgeyB2YWx1ZTogOCB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9KTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTA5ICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgZmFpbHMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEwKTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gIWZhaWxzKGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gT2JqZWN0LmlzRXh0ZW5zaWJsZShPYmplY3QucHJldmVudEV4dGVuc2lvbnMoe30pKTsKICAgICAgICAgICAgICAgIH0pOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxMTAgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBiaW5kID0gX193X3BkZmpzX3JlcXVpcmVfXygxMTEpOwogICAgICAgICAgICAgICAgdmFyIGNhbGwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDExKTsKICAgICAgICAgICAgICAgIHZhciBhbk9iamVjdCA9IF9fd19wZGZqc19yZXF1aXJlX18oNTApOwogICAgICAgICAgICAgICAgdmFyIHRyeVRvU3RyaW5nID0gX193X3BkZmpzX3JlcXVpcmVfXygzNSk7CiAgICAgICAgICAgICAgICB2YXIgaXNBcnJheUl0ZXJhdG9yTWV0aG9kID0gX193X3BkZmpzX3JlcXVpcmVfXygxMTMpOwogICAgICAgICAgICAgICAgdmFyIGxlbmd0aE9mQXJyYXlMaWtlID0gX193X3BkZmpzX3JlcXVpcmVfXyg2Nyk7CiAgICAgICAgICAgICAgICB2YXIgaXNQcm90b3R5cGVPZiA9IF9fd19wZGZqc19yZXF1aXJlX18oMjgpOwogICAgICAgICAgICAgICAgdmFyIGdldEl0ZXJhdG9yID0gX193X3BkZmpzX3JlcXVpcmVfXygxMTQpOwogICAgICAgICAgICAgICAgdmFyIGdldEl0ZXJhdG9yTWV0aG9kID0gX193X3BkZmpzX3JlcXVpcmVfXygxMTUpOwogICAgICAgICAgICAgICAgdmFyIGl0ZXJhdG9yQ2xvc2UgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDExNik7CiAgICAgICAgICAgICAgICB2YXIgJFR5cGVFcnJvciA9IFR5cGVFcnJvcjsKICAgICAgICAgICAgICAgIHZhciBSZXN1bHQgPSBmdW5jdGlvbiAoc3RvcHBlZCwgcmVzdWx0KSB7CiAgICAgICAgICAgICAgICAgICAgdGhpcy5zdG9wcGVkID0gc3RvcHBlZDsKICAgICAgICAgICAgICAgICAgICB0aGlzLnJlc3VsdCA9IHJlc3VsdDsKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB2YXIgUmVzdWx0UHJvdG90eXBlID0gUmVzdWx0LnByb3RvdHlwZTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKGl0ZXJhYmxlLCB1bmJvdW5kRnVuY3Rpb24sIG9wdGlvbnMpIHsKICAgICAgICAgICAgICAgICAgICB2YXIgdGhhdCA9IG9wdGlvbnMgJiYgb3B0aW9ucy50aGF0OwogICAgICAgICAgICAgICAgICAgIHZhciBBU19FTlRSSUVTID0gISEob3B0aW9ucyAmJiBvcHRpb25zLkFTX0VOVFJJRVMpOwogICAgICAgICAgICAgICAgICAgIHZhciBJU19SRUNPUkQgPSAhIShvcHRpb25zICYmIG9wdGlvbnMuSVNfUkVDT1JEKTsKICAgICAgICAgICAgICAgICAgICB2YXIgSVNfSVRFUkFUT1IgPSAhIShvcHRpb25zICYmIG9wdGlvbnMuSVNfSVRFUkFUT1IpOwogICAgICAgICAgICAgICAgICAgIHZhciBJTlRFUlJVUFRFRCA9ICEhKG9wdGlvbnMgJiYgb3B0aW9ucy5JTlRFUlJVUFRFRCk7CiAgICAgICAgICAgICAgICAgICAgdmFyIGZuID0gYmluZCh1bmJvdW5kRnVuY3Rpb24sIHRoYXQpOwogICAgICAgICAgICAgICAgICAgIHZhciBpdGVyYXRvciwgaXRlckZuLCBpbmRleCwgbGVuZ3RoLCByZXN1bHQsIG5leHQsIHN0ZXA7CiAgICAgICAgICAgICAgICAgICAgdmFyIHN0b3AgPSBmdW5jdGlvbiAoY29uZGl0aW9uKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpdGVyYXRvcikKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGl0ZXJhdG9yQ2xvc2UoaXRlcmF0b3IsICdub3JtYWwnLCBjb25kaXRpb24pOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IFJlc3VsdCh0cnVlLCBjb25kaXRpb24pOwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgdmFyIGNhbGxGbiA9IGZ1bmN0aW9uICh2YWx1ZSkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoQVNfRU5UUklFUykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgYW5PYmplY3QodmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIElOVEVSUlVQVEVEID8gZm4odmFsdWVbMF0sIHZhbHVlWzFdLCBzdG9wKSA6IGZuKHZhbHVlWzBdLCB2YWx1ZVsxXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIElOVEVSUlVQVEVEID8gZm4odmFsdWUsIHN0b3ApIDogZm4odmFsdWUpOwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgaWYgKElTX1JFQ09SRCkgewogICAgICAgICAgICAgICAgICAgICAgICBpdGVyYXRvciA9IGl0ZXJhYmxlLml0ZXJhdG9yOwogICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoSVNfSVRFUkFUT1IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaXRlcmF0b3IgPSBpdGVyYWJsZTsKICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICBpdGVyRm4gPSBnZXRJdGVyYXRvck1ldGhvZChpdGVyYWJsZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghaXRlckZuKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgJFR5cGVFcnJvcih0cnlUb1N0cmluZyhpdGVyYWJsZSkgKyAnIGlzIG5vdCBpdGVyYWJsZScpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoaXNBcnJheUl0ZXJhdG9yTWV0aG9kKGl0ZXJGbikpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoaW5kZXggPSAwLCBsZW5ndGggPSBsZW5ndGhPZkFycmF5TGlrZShpdGVyYWJsZSk7IGxlbmd0aCA+IGluZGV4OyBpbmRleCsrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVzdWx0ID0gY2FsbEZuKGl0ZXJhYmxlW2luZGV4XSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHJlc3VsdCAmJiBpc1Byb3RvdHlwZU9mKFJlc3VsdFByb3RvdHlwZSwgcmVzdWx0KSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHJlc3VsdDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgUmVzdWx0KGZhbHNlKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpdGVyYXRvciA9IGdldEl0ZXJhdG9yKGl0ZXJhYmxlLCBpdGVyRm4pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBuZXh0ID0gSVNfUkVDT1JEID8gaXRlcmFibGUubmV4dCA6IGl0ZXJhdG9yLm5leHQ7CiAgICAgICAgICAgICAgICAgICAgd2hpbGUgKCEoc3RlcCA9IGNhbGwobmV4dCwgaXRlcmF0b3IpKS5kb25lKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXN1bHQgPSBjYWxsRm4oc3RlcC52YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpdGVyYXRvckNsb3NlKGl0ZXJhdG9yLCAndGhyb3cnLCBlcnJvcik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHR5cGVvZiByZXN1bHQgPT0gJ29iamVjdCcgJiYgcmVzdWx0ICYmIGlzUHJvdG90eXBlT2YoUmVzdWx0UHJvdG90eXBlLCByZXN1bHQpKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHJlc3VsdDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG5ldyBSZXN1bHQoZmFsc2UpOwogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTExICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgdW5jdXJyeVRoaXMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDExMik7CiAgICAgICAgICAgICAgICB2YXIgYUNhbGxhYmxlID0gX193X3BkZmpzX3JlcXVpcmVfXygzNCk7CiAgICAgICAgICAgICAgICB2YXIgTkFUSVZFX0JJTkQgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEyKTsKICAgICAgICAgICAgICAgIHZhciBiaW5kID0gdW5jdXJyeVRoaXModW5jdXJyeVRoaXMuYmluZCk7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uIChmbiwgdGhhdCkgewogICAgICAgICAgICAgICAgICAgIGFDYWxsYWJsZShmbik7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoYXQgPT09IHVuZGVmaW5lZCA/IGZuIDogTkFUSVZFX0JJTkQgPyBiaW5kKGZuLCB0aGF0KSA6IGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZuLmFwcGx5KHRoYXQsIGFyZ3VtZW50cyk7CiAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDExMiAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIGNsYXNzb2ZSYXcgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE4KTsKICAgICAgICAgICAgICAgIHZhciB1bmN1cnJ5VGhpcyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTcpOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoZm4pIHsKICAgICAgICAgICAgICAgICAgICBpZiAoY2xhc3NvZlJhdyhmbikgPT09ICdGdW5jdGlvbicpCiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB1bmN1cnJ5VGhpcyhmbik7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxMTMgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciB3ZWxsS25vd25TeW1ib2wgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDM3KTsKICAgICAgICAgICAgICAgIHZhciBJdGVyYXRvcnMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDkyKTsKICAgICAgICAgICAgICAgIHZhciBJVEVSQVRPUiA9IHdlbGxLbm93blN5bWJvbCgnaXRlcmF0b3InKTsKICAgICAgICAgICAgICAgIHZhciBBcnJheVByb3RvdHlwZSA9IEFycmF5LnByb3RvdHlwZTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKGl0KSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGl0ICE9PSB1bmRlZmluZWQgJiYgKEl0ZXJhdG9ycy5BcnJheSA9PT0gaXQgfHwgQXJyYXlQcm90b3R5cGVbSVRFUkFUT1JdID09PSBpdCk7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxMTQgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBjYWxsID0gX193X3BkZmpzX3JlcXVpcmVfXygxMSk7CiAgICAgICAgICAgICAgICB2YXIgYUNhbGxhYmxlID0gX193X3BkZmpzX3JlcXVpcmVfXygzNCk7CiAgICAgICAgICAgICAgICB2YXIgYW5PYmplY3QgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDUwKTsKICAgICAgICAgICAgICAgIHZhciB0cnlUb1N0cmluZyA9IF9fd19wZGZqc19yZXF1aXJlX18oMzUpOwogICAgICAgICAgICAgICAgdmFyIGdldEl0ZXJhdG9yTWV0aG9kID0gX193X3BkZmpzX3JlcXVpcmVfXygxMTUpOwogICAgICAgICAgICAgICAgdmFyICRUeXBlRXJyb3IgPSBUeXBlRXJyb3I7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uIChhcmd1bWVudCwgdXNpbmdJdGVyYXRvcikgewogICAgICAgICAgICAgICAgICAgIHZhciBpdGVyYXRvck1ldGhvZCA9IGFyZ3VtZW50cy5sZW5ndGggPCAyID8gZ2V0SXRlcmF0b3JNZXRob2QoYXJndW1lbnQpIDogdXNpbmdJdGVyYXRvcjsKICAgICAgICAgICAgICAgICAgICBpZiAoYUNhbGxhYmxlKGl0ZXJhdG9yTWV0aG9kKSkKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGFuT2JqZWN0KGNhbGwoaXRlcmF0b3JNZXRob2QsIGFyZ3VtZW50KSk7CiAgICAgICAgICAgICAgICAgICAgdGhyb3cgJFR5cGVFcnJvcih0cnlUb1N0cmluZyhhcmd1bWVudCkgKyAnIGlzIG5vdCBpdGVyYWJsZScpOwogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTE1ICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgY2xhc3NvZiA9IF9fd19wZGZqc19yZXF1aXJlX18oODIpOwogICAgICAgICAgICAgICAgdmFyIGdldE1ldGhvZCA9IF9fd19wZGZqc19yZXF1aXJlX18oMzMpOwogICAgICAgICAgICAgICAgdmFyIGlzTnVsbE9yVW5kZWZpbmVkID0gX193X3BkZmpzX3JlcXVpcmVfXygyMCk7CiAgICAgICAgICAgICAgICB2YXIgSXRlcmF0b3JzID0gX193X3BkZmpzX3JlcXVpcmVfXyg5Mik7CiAgICAgICAgICAgICAgICB2YXIgd2VsbEtub3duU3ltYm9sID0gX193X3BkZmpzX3JlcXVpcmVfXygzNyk7CiAgICAgICAgICAgICAgICB2YXIgSVRFUkFUT1IgPSB3ZWxsS25vd25TeW1ib2woJ2l0ZXJhdG9yJyk7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uIChpdCkgewogICAgICAgICAgICAgICAgICAgIGlmICghaXNOdWxsT3JVbmRlZmluZWQoaXQpKQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZ2V0TWV0aG9kKGl0LCBJVEVSQVRPUikgfHwgZ2V0TWV0aG9kKGl0LCAnQEBpdGVyYXRvcicpIHx8IEl0ZXJhdG9yc1tjbGFzc29mKGl0KV07CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxMTYgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBjYWxsID0gX193X3BkZmpzX3JlcXVpcmVfXygxMSk7CiAgICAgICAgICAgICAgICB2YXIgYW5PYmplY3QgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDUwKTsKICAgICAgICAgICAgICAgIHZhciBnZXRNZXRob2QgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDMzKTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKGl0ZXJhdG9yLCBraW5kLCB2YWx1ZSkgewogICAgICAgICAgICAgICAgICAgIHZhciBpbm5lclJlc3VsdCwgaW5uZXJFcnJvcjsKICAgICAgICAgICAgICAgICAgICBhbk9iamVjdChpdGVyYXRvcik7CiAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgaW5uZXJSZXN1bHQgPSBnZXRNZXRob2QoaXRlcmF0b3IsICdyZXR1cm4nKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFpbm5lclJlc3VsdCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGtpbmQgPT09ICd0aHJvdycpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgdmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaW5uZXJSZXN1bHQgPSBjYWxsKGlubmVyUmVzdWx0LCBpdGVyYXRvcik7CiAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZXJyb3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaW5uZXJFcnJvciA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIGlubmVyUmVzdWx0ID0gZXJyb3I7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmIChraW5kID09PSAndGhyb3cnKQogICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyB2YWx1ZTsKICAgICAgICAgICAgICAgICAgICBpZiAoaW5uZXJFcnJvcikKICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgaW5uZXJSZXN1bHQ7CiAgICAgICAgICAgICAgICAgICAgYW5PYmplY3QoaW5uZXJSZXN1bHQpOwogICAgICAgICAgICAgICAgICAgIHJldHVybiB2YWx1ZTsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDExNyAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIGlzUHJvdG90eXBlT2YgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDI4KTsKICAgICAgICAgICAgICAgIHZhciAkVHlwZUVycm9yID0gVHlwZUVycm9yOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoaXQsIFByb3RvdHlwZSkgewogICAgICAgICAgICAgICAgICAgIGlmIChpc1Byb3RvdHlwZU9mKFByb3RvdHlwZSwgaXQpKQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gaXQ7CiAgICAgICAgICAgICAgICAgICAgdGhyb3cgJFR5cGVFcnJvcignSW5jb3JyZWN0IGludm9jYXRpb24nKTsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDExOCAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIHdlbGxLbm93blN5bWJvbCA9IF9fd19wZGZqc19yZXF1aXJlX18oMzcpOwogICAgICAgICAgICAgICAgdmFyIElURVJBVE9SID0gd2VsbEtub3duU3ltYm9sKCdpdGVyYXRvcicpOwogICAgICAgICAgICAgICAgdmFyIFNBRkVfQ0xPU0lORyA9IGZhbHNlOwogICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICB2YXIgY2FsbGVkID0gMDsKICAgICAgICAgICAgICAgICAgICB2YXIgaXRlcmF0b3JXaXRoUmV0dXJuID0gewogICAgICAgICAgICAgICAgICAgICAgICBuZXh0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4geyBkb25lOiAhIWNhbGxlZCsrIH07CiAgICAgICAgICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAgICAgICAgICdyZXR1cm4nOiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBTQUZFX0NMT1NJTkcgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICBpdGVyYXRvcldpdGhSZXR1cm5bSVRFUkFUT1JdID0gZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpczsKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIEFycmF5LmZyb20oaXRlcmF0b3JXaXRoUmV0dXJuLCBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IDI7CiAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICB9IGNhdGNoIChlcnJvcikgewogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoZXhlYywgU0tJUF9DTE9TSU5HKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKCFTS0lQX0NMT1NJTkcgJiYgIVNBRkVfQ0xPU0lORykKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgICAgICAgICAgIHZhciBJVEVSQVRJT05fU1VQUE9SVCA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBvYmplY3QgPSB7fTsKICAgICAgICAgICAgICAgICAgICAgICAgb2JqZWN0W0lURVJBVE9SXSA9IGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbmV4dDogZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4geyBkb25lOiBJVEVSQVRJT05fU1VQUE9SVCA9IHRydWUgfTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICBleGVjKG9iamVjdCk7CiAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZXJyb3IpIHsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIElURVJBVElPTl9TVVBQT1JUOwogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTE5ICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgaXNDYWxsYWJsZSA9IF9fd19wZGZqc19yZXF1aXJlX18oMjQpOwogICAgICAgICAgICAgICAgdmFyIGlzT2JqZWN0ID0gX193X3BkZmpzX3JlcXVpcmVfXygyMyk7CiAgICAgICAgICAgICAgICB2YXIgc2V0UHJvdG90eXBlT2YgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDg3KTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKCR0aGlzLCBkdW1teSwgV3JhcHBlcikgewogICAgICAgICAgICAgICAgICAgIHZhciBOZXdUYXJnZXQsIE5ld1RhcmdldFByb3RvdHlwZTsKICAgICAgICAgICAgICAgICAgICBpZiAoc2V0UHJvdG90eXBlT2YgJiYgaXNDYWxsYWJsZShOZXdUYXJnZXQgPSBkdW1teS5jb25zdHJ1Y3RvcikgJiYgTmV3VGFyZ2V0ICE9PSBXcmFwcGVyICYmIGlzT2JqZWN0KE5ld1RhcmdldFByb3RvdHlwZSA9IE5ld1RhcmdldC5wcm90b3R5cGUpICYmIE5ld1RhcmdldFByb3RvdHlwZSAhPT0gV3JhcHBlci5wcm90b3R5cGUpCiAgICAgICAgICAgICAgICAgICAgICAgIHNldFByb3RvdHlwZU9mKCR0aGlzLCBOZXdUYXJnZXRQcm90b3R5cGUpOwogICAgICAgICAgICAgICAgICAgIHJldHVybiAkdGhpczsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDEyMCAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKICAgICAgICAgICAgICAgIHZhciBjcmVhdGUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDczKTsKICAgICAgICAgICAgICAgIHZhciBkZWZpbmVCdWlsdEluQWNjZXNzb3IgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDg0KTsKICAgICAgICAgICAgICAgIHZhciBkZWZpbmVCdWlsdElucyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTIxKTsKICAgICAgICAgICAgICAgIHZhciBiaW5kID0gX193X3BkZmpzX3JlcXVpcmVfXygxMTEpOwogICAgICAgICAgICAgICAgdmFyIGFuSW5zdGFuY2UgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDExNyk7CiAgICAgICAgICAgICAgICB2YXIgaXNOdWxsT3JVbmRlZmluZWQgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDIwKTsKICAgICAgICAgICAgICAgIHZhciBpdGVyYXRlID0gX193X3BkZmpzX3JlcXVpcmVfXygxMTApOwogICAgICAgICAgICAgICAgdmFyIGRlZmluZUl0ZXJhdG9yID0gX193X3BkZmpzX3JlcXVpcmVfXyg5Myk7CiAgICAgICAgICAgICAgICB2YXIgY3JlYXRlSXRlclJlc3VsdE9iamVjdCA9IF9fd19wZGZqc19yZXF1aXJlX18oOTcpOwogICAgICAgICAgICAgICAgdmFyIHNldFNwZWNpZXMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEyMik7CiAgICAgICAgICAgICAgICB2YXIgREVTQ1JJUFRPUlMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDkpOwogICAgICAgICAgICAgICAgdmFyIGZhc3RLZXkgPSAoX193X3BkZmpzX3JlcXVpcmVfXygxMDMpLmZhc3RLZXkpOwogICAgICAgICAgICAgICAgdmFyIEludGVybmFsU3RhdGVNb2R1bGUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDU1KTsKICAgICAgICAgICAgICAgIHZhciBzZXRJbnRlcm5hbFN0YXRlID0gSW50ZXJuYWxTdGF0ZU1vZHVsZS5zZXQ7CiAgICAgICAgICAgICAgICB2YXIgaW50ZXJuYWxTdGF0ZUdldHRlckZvciA9IEludGVybmFsU3RhdGVNb2R1bGUuZ2V0dGVyRm9yOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSB7CiAgICAgICAgICAgICAgICAgICAgZ2V0Q29uc3RydWN0b3I6IGZ1bmN0aW9uICh3cmFwcGVyLCBDT05TVFJVQ1RPUl9OQU1FLCBJU19NQVAsIEFEREVSKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBDb25zdHJ1Y3RvciA9IHdyYXBwZXIoZnVuY3Rpb24gKHRoYXQsIGl0ZXJhYmxlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhbkluc3RhbmNlKHRoYXQsIFByb3RvdHlwZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZXRJbnRlcm5hbFN0YXRlKHRoYXQsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0eXBlOiBDT05TVFJVQ1RPUl9OQU1FLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGluZGV4OiBjcmVhdGUobnVsbCksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZmlyc3Q6IHVuZGVmaW5lZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsYXN0OiB1bmRlZmluZWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2l6ZTogMAogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIURFU0NSSVBUT1JTKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoYXQuc2l6ZSA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWlzTnVsbE9yVW5kZWZpbmVkKGl0ZXJhYmxlKSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpdGVyYXRlKGl0ZXJhYmxlLCB0aGF0W0FEREVSXSwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGF0OiB0aGF0LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBBU19FTlRSSUVTOiBJU19NQVAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBQcm90b3R5cGUgPSBDb25zdHJ1Y3Rvci5wcm90b3R5cGU7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBnZXRJbnRlcm5hbFN0YXRlID0gaW50ZXJuYWxTdGF0ZUdldHRlckZvcihDT05TVFJVQ1RPUl9OQU1FKTsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGRlZmluZSA9IGZ1bmN0aW9uICh0aGF0LCBrZXksIHZhbHVlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgc3RhdGUgPSBnZXRJbnRlcm5hbFN0YXRlKHRoYXQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGVudHJ5ID0gZ2V0RW50cnkodGhhdCwga2V5KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBwcmV2aW91cywgaW5kZXg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZW50cnkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbnRyeS52YWx1ZSA9IHZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGF0ZS5sYXN0ID0gZW50cnkgPSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGluZGV4OiBpbmRleCA9IGZhc3RLZXkoa2V5LCB0cnVlKSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAga2V5OiBrZXksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiB2YWx1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJldmlvdXM6IHByZXZpb3VzID0gc3RhdGUubGFzdCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbmV4dDogdW5kZWZpbmVkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZW1vdmVkOiBmYWxzZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFzdGF0ZS5maXJzdCkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RhdGUuZmlyc3QgPSBlbnRyeTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAocHJldmlvdXMpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHByZXZpb3VzLm5leHQgPSBlbnRyeTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoREVTQ1JJUFRPUlMpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0YXRlLnNpemUrKzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbHNlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoYXQuc2l6ZSsrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpbmRleCAhPT0gJ0YnKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGF0ZS5pbmRleFtpbmRleF0gPSBlbnRyeTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGF0OwogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICB2YXIgZ2V0RW50cnkgPSBmdW5jdGlvbiAodGhhdCwga2V5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgc3RhdGUgPSBnZXRJbnRlcm5hbFN0YXRlKHRoYXQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGluZGV4ID0gZmFzdEtleShrZXkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGVudHJ5OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGluZGV4ICE9PSAnRicpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHN0YXRlLmluZGV4W2luZGV4XTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoZW50cnkgPSBzdGF0ZS5maXJzdDsgZW50cnk7IGVudHJ5ID0gZW50cnkubmV4dCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChlbnRyeS5rZXkgPT0ga2V5KQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZW50cnk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgIGRlZmluZUJ1aWx0SW5zKFByb3RvdHlwZSwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xlYXI6IGZ1bmN0aW9uIGNsZWFyKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciB0aGF0ID0gdGhpczsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgc3RhdGUgPSBnZXRJbnRlcm5hbFN0YXRlKHRoYXQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBkYXRhID0gc3RhdGUuaW5kZXg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGVudHJ5ID0gc3RhdGUuZmlyc3Q7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgd2hpbGUgKGVudHJ5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVudHJ5LnJlbW92ZWQgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZW50cnkucHJldmlvdXMpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbnRyeS5wcmV2aW91cyA9IGVudHJ5LnByZXZpb3VzLm5leHQgPSB1bmRlZmluZWQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlbGV0ZSBkYXRhW2VudHJ5LmluZGV4XTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZW50cnkgPSBlbnRyeS5uZXh0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGF0ZS5maXJzdCA9IHN0YXRlLmxhc3QgPSB1bmRlZmluZWQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKERFU0NSSVBUT1JTKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGF0ZS5zaXplID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbHNlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoYXQuc2l6ZSA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgJ2RlbGV0ZSc6IGZ1bmN0aW9uIChrZXkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgdGhhdCA9IHRoaXM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHN0YXRlID0gZ2V0SW50ZXJuYWxTdGF0ZSh0aGF0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgZW50cnkgPSBnZXRFbnRyeSh0aGF0LCBrZXkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChlbnRyeSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgbmV4dCA9IGVudHJ5Lm5leHQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBwcmV2ID0gZW50cnkucHJldmlvdXM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlbGV0ZSBzdGF0ZS5pbmRleFtlbnRyeS5pbmRleF07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVudHJ5LnJlbW92ZWQgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAocHJldikKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHByZXYubmV4dCA9IG5leHQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChuZXh0KQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbmV4dC5wcmV2aW91cyA9IHByZXY7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChzdGF0ZS5maXJzdCA9PSBlbnRyeSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0YXRlLmZpcnN0ID0gbmV4dDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHN0YXRlLmxhc3QgPT0gZW50cnkpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGF0ZS5sYXN0ID0gcHJldjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKERFU0NSSVBUT1JTKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RhdGUuc2l6ZS0tOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbHNlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGF0LnNpemUtLTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICEhZW50cnk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yRWFjaDogZnVuY3Rpb24gZm9yRWFjaChjYWxsYmFja2ZuKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHN0YXRlID0gZ2V0SW50ZXJuYWxTdGF0ZSh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgYm91bmRGdW5jdGlvbiA9IGJpbmQoY2FsbGJhY2tmbiwgYXJndW1lbnRzLmxlbmd0aCA+IDEgPyBhcmd1bWVudHNbMV0gOiB1bmRlZmluZWQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBlbnRyeTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB3aGlsZSAoZW50cnkgPSBlbnRyeSA/IGVudHJ5Lm5leHQgOiBzdGF0ZS5maXJzdCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBib3VuZEZ1bmN0aW9uKGVudHJ5LnZhbHVlLCBlbnRyeS5rZXksIHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB3aGlsZSAoZW50cnkgJiYgZW50cnkucmVtb3ZlZCkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVudHJ5ID0gZW50cnkucHJldmlvdXM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGhhczogZnVuY3Rpb24gaGFzKGtleSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAhIWdldEVudHJ5KHRoaXMsIGtleSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBkZWZpbmVCdWlsdElucyhQcm90b3R5cGUsIElTX01BUCA/IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24gZ2V0KGtleSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBlbnRyeSA9IGdldEVudHJ5KHRoaXMsIGtleSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGVudHJ5ICYmIGVudHJ5LnZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNldDogZnVuY3Rpb24gc2V0KGtleSwgdmFsdWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZGVmaW5lKHRoaXMsIGtleSA9PT0gMCA/IDAgOiBrZXksIHZhbHVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfSA6IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFkZDogZnVuY3Rpb24gYWRkKHZhbHVlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGRlZmluZSh0aGlzLCB2YWx1ZSA9IHZhbHVlID09PSAwID8gMCA6IHZhbHVlLCB2YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoREVTQ1JJUFRPUlMpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZpbmVCdWlsdEluQWNjZXNzb3IoUHJvdG90eXBlLCAnc2l6ZScsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBnZXRJbnRlcm5hbFN0YXRlKHRoaXMpLnNpemU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBDb25zdHJ1Y3RvcjsKICAgICAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgICAgIHNldFN0cm9uZzogZnVuY3Rpb24gKENvbnN0cnVjdG9yLCBDT05TVFJVQ1RPUl9OQU1FLCBJU19NQVApIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIElURVJBVE9SX05BTUUgPSBDT05TVFJVQ1RPUl9OQU1FICsgJyBJdGVyYXRvcic7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBnZXRJbnRlcm5hbENvbGxlY3Rpb25TdGF0ZSA9IGludGVybmFsU3RhdGVHZXR0ZXJGb3IoQ09OU1RSVUNUT1JfTkFNRSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBnZXRJbnRlcm5hbEl0ZXJhdG9yU3RhdGUgPSBpbnRlcm5hbFN0YXRlR2V0dGVyRm9yKElURVJBVE9SX05BTUUpOwogICAgICAgICAgICAgICAgICAgICAgICBkZWZpbmVJdGVyYXRvcihDb25zdHJ1Y3RvciwgQ09OU1RSVUNUT1JfTkFNRSwgZnVuY3Rpb24gKGl0ZXJhdGVkLCBraW5kKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZXRJbnRlcm5hbFN0YXRlKHRoaXMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0eXBlOiBJVEVSQVRPUl9OQU1FLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRhcmdldDogaXRlcmF0ZWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RhdGU6IGdldEludGVybmFsQ29sbGVjdGlvblN0YXRlKGl0ZXJhdGVkKSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBraW5kOiBraW5kLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxhc3Q6IHVuZGVmaW5lZAogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0sIGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBzdGF0ZSA9IGdldEludGVybmFsSXRlcmF0b3JTdGF0ZSh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBraW5kID0gc3RhdGUua2luZDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBlbnRyeSA9IHN0YXRlLmxhc3Q7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3aGlsZSAoZW50cnkgJiYgZW50cnkucmVtb3ZlZCkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbnRyeSA9IGVudHJ5LnByZXZpb3VzOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFzdGF0ZS50YXJnZXQgfHwgIShzdGF0ZS5sYXN0ID0gZW50cnkgPSBlbnRyeSA/IGVudHJ5Lm5leHQgOiBzdGF0ZS5zdGF0ZS5maXJzdCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGF0ZS50YXJnZXQgPSB1bmRlZmluZWQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGNyZWF0ZUl0ZXJSZXN1bHRPYmplY3QodW5kZWZpbmVkLCB0cnVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChraW5kID09ICdrZXlzJykKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gY3JlYXRlSXRlclJlc3VsdE9iamVjdChlbnRyeS5rZXksIGZhbHNlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChraW5kID09ICd2YWx1ZXMnKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBjcmVhdGVJdGVyUmVzdWx0T2JqZWN0KGVudHJ5LnZhbHVlLCBmYWxzZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gY3JlYXRlSXRlclJlc3VsdE9iamVjdChbCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZW50cnkua2V5LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVudHJ5LnZhbHVlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBdLCBmYWxzZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0sIElTX01BUCA/ICdlbnRyaWVzJyA6ICd2YWx1ZXMnLCAhSVNfTUFQLCB0cnVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgc2V0U3BlY2llcyhDT05TVFJVQ1RPUl9OQU1FKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxMjEgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBkZWZpbmVCdWlsdEluID0gX193X3BkZmpzX3JlcXVpcmVfXyg1MSk7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uICh0YXJnZXQsIHNyYywgb3B0aW9ucykgewogICAgICAgICAgICAgICAgICAgIGZvciAodmFyIGtleSBpbiBzcmMpCiAgICAgICAgICAgICAgICAgICAgICAgIGRlZmluZUJ1aWx0SW4odGFyZ2V0LCBrZXksIHNyY1trZXldLCBvcHRpb25zKTsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGFyZ2V0OwogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTIyICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICAidXNlIHN0cmljdCI7CgogICAgICAgICAgICAgICAgdmFyIGdldEJ1aWx0SW4gPSBfX3dfcGRmanNfcmVxdWlyZV9fKDI3KTsKICAgICAgICAgICAgICAgIHZhciBkZWZpbmVCdWlsdEluQWNjZXNzb3IgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDg0KTsKICAgICAgICAgICAgICAgIHZhciB3ZWxsS25vd25TeW1ib2wgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDM3KTsKICAgICAgICAgICAgICAgIHZhciBERVNDUklQVE9SUyA9IF9fd19wZGZqc19yZXF1aXJlX18oOSk7CiAgICAgICAgICAgICAgICB2YXIgU1BFQ0lFUyA9IHdlbGxLbm93blN5bWJvbCgnc3BlY2llcycpOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoQ09OU1RSVUNUT1JfTkFNRSkgewogICAgICAgICAgICAgICAgICAgIHZhciBDb25zdHJ1Y3RvciA9IGdldEJ1aWx0SW4oQ09OU1RSVUNUT1JfTkFNRSk7CiAgICAgICAgICAgICAgICAgICAgaWYgKERFU0NSSVBUT1JTICYmIENvbnN0cnVjdG9yICYmICFDb25zdHJ1Y3RvcltTUEVDSUVTXSkgewogICAgICAgICAgICAgICAgICAgICAgICBkZWZpbmVCdWlsdEluQWNjZXNzb3IoQ29uc3RydWN0b3IsIFNQRUNJRVMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxMjMgKi8KICAgICAgICAgICAgLyoqKi8gKChfX3VudXNlZF93ZWJwYWNrX21vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgX193X3BkZmpzX3JlcXVpcmVfXygxMjQpOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxMjQgKi8KICAgICAgICAgICAgLyoqKi8gKChfX3VudXNlZF93ZWJwYWNrX21vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKICAgICAgICAgICAgICAgIHZhciBjb2xsZWN0aW9uID0gX193X3BkZmpzX3JlcXVpcmVfXygxMDIpOwogICAgICAgICAgICAgICAgdmFyIGNvbGxlY3Rpb25TdHJvbmcgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEyMCk7CiAgICAgICAgICAgICAgICBjb2xsZWN0aW9uKCdTZXQnLCBmdW5jdGlvbiAoaW5pdCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBmdW5jdGlvbiBTZXQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBpbml0KHRoaXMsIGFyZ3VtZW50cy5sZW5ndGggPyBhcmd1bWVudHNbMF0gOiB1bmRlZmluZWQpOwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB9LCBjb2xsZWN0aW9uU3Ryb25nKTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTI1ICovCiAgICAgICAgICAgIC8qKiovICgoX191bnVzZWRfd2VicGFja19tb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBJU19QVVJFID0gX193X3BkZmpzX3JlcXVpcmVfXygzOSk7CiAgICAgICAgICAgICAgICB2YXIgJCA9IF9fd19wZGZqc19yZXF1aXJlX18oNik7CiAgICAgICAgICAgICAgICB2YXIgZ2xvYmFsID0gX193X3BkZmpzX3JlcXVpcmVfXyg3KTsKICAgICAgICAgICAgICAgIHZhciBnZXRCdWlsdGluID0gX193X3BkZmpzX3JlcXVpcmVfXygyNyk7CiAgICAgICAgICAgICAgICB2YXIgdW5jdXJyeVRoaXMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE3KTsKICAgICAgICAgICAgICAgIHZhciBmYWlscyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTApOwogICAgICAgICAgICAgICAgdmFyIHVpZCA9IF9fd19wZGZqc19yZXF1aXJlX18oNDQpOwogICAgICAgICAgICAgICAgdmFyIGlzQ2FsbGFibGUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDI0KTsKICAgICAgICAgICAgICAgIHZhciBpc0NvbnN0cnVjdG9yID0gX193X3BkZmpzX3JlcXVpcmVfXygxMjYpOwogICAgICAgICAgICAgICAgdmFyIGlzTnVsbE9yVW5kZWZpbmVkID0gX193X3BkZmpzX3JlcXVpcmVfXygyMCk7CiAgICAgICAgICAgICAgICB2YXIgaXNPYmplY3QgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDIzKTsKICAgICAgICAgICAgICAgIHZhciBpc1N5bWJvbCA9IF9fd19wZGZqc19yZXF1aXJlX18oMjYpOwogICAgICAgICAgICAgICAgdmFyIGl0ZXJhdGUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDExMCk7CiAgICAgICAgICAgICAgICB2YXIgYW5PYmplY3QgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDUwKTsKICAgICAgICAgICAgICAgIHZhciBjbGFzc29mID0gX193X3BkZmpzX3JlcXVpcmVfXyg4Mik7CiAgICAgICAgICAgICAgICB2YXIgaGFzT3duID0gX193X3BkZmpzX3JlcXVpcmVfXyg0Mik7CiAgICAgICAgICAgICAgICB2YXIgY3JlYXRlUHJvcGVydHkgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEwNik7CiAgICAgICAgICAgICAgICB2YXIgY3JlYXRlTm9uRW51bWVyYWJsZVByb3BlcnR5ID0gX193X3BkZmpzX3JlcXVpcmVfXyg0Nyk7CiAgICAgICAgICAgICAgICB2YXIgbGVuZ3RoT2ZBcnJheUxpa2UgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDY3KTsKICAgICAgICAgICAgICAgIHZhciB2YWxpZGF0ZUFyZ3VtZW50c0xlbmd0aCA9IF9fd19wZGZqc19yZXF1aXJlX18oMTI3KTsKICAgICAgICAgICAgICAgIHZhciBnZXRSZWdFeHBGbGFncyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTI4KTsKICAgICAgICAgICAgICAgIHZhciBNYXBIZWxwZXJzID0gX193X3BkZmpzX3JlcXVpcmVfXygxMzApOwogICAgICAgICAgICAgICAgdmFyIFNldEhlbHBlcnMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEzMSk7CiAgICAgICAgICAgICAgICB2YXIgRVJST1JfU1RBQ0tfSU5TVEFMTEFCTEUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEzMik7CiAgICAgICAgICAgICAgICB2YXIgUFJPUEVSX1RSQU5TRkVSID0gX193X3BkZmpzX3JlcXVpcmVfXygxMzMpOwogICAgICAgICAgICAgICAgdmFyIE9iamVjdCA9IGdsb2JhbC5PYmplY3Q7CiAgICAgICAgICAgICAgICB2YXIgQXJyYXkgPSBnbG9iYWwuQXJyYXk7CiAgICAgICAgICAgICAgICB2YXIgRGF0ZSA9IGdsb2JhbC5EYXRlOwogICAgICAgICAgICAgICAgdmFyIEVycm9yID0gZ2xvYmFsLkVycm9yOwogICAgICAgICAgICAgICAgdmFyIEV2YWxFcnJvciA9IGdsb2JhbC5FdmFsRXJyb3I7CiAgICAgICAgICAgICAgICB2YXIgUmFuZ2VFcnJvciA9IGdsb2JhbC5SYW5nZUVycm9yOwogICAgICAgICAgICAgICAgdmFyIFJlZmVyZW5jZUVycm9yID0gZ2xvYmFsLlJlZmVyZW5jZUVycm9yOwogICAgICAgICAgICAgICAgdmFyIFN5bnRheEVycm9yID0gZ2xvYmFsLlN5bnRheEVycm9yOwogICAgICAgICAgICAgICAgdmFyIFR5cGVFcnJvciA9IGdsb2JhbC5UeXBlRXJyb3I7CiAgICAgICAgICAgICAgICB2YXIgVVJJRXJyb3IgPSBnbG9iYWwuVVJJRXJyb3I7CiAgICAgICAgICAgICAgICB2YXIgUGVyZm9ybWFuY2VNYXJrID0gZ2xvYmFsLlBlcmZvcm1hbmNlTWFyazsKICAgICAgICAgICAgICAgIHZhciBXZWJBc3NlbWJseSA9IGdsb2JhbC5XZWJBc3NlbWJseTsKICAgICAgICAgICAgICAgIHZhciBDb21waWxlRXJyb3IgPSBXZWJBc3NlbWJseSAmJiBXZWJBc3NlbWJseS5Db21waWxlRXJyb3IgfHwgRXJyb3I7CiAgICAgICAgICAgICAgICB2YXIgTGlua0Vycm9yID0gV2ViQXNzZW1ibHkgJiYgV2ViQXNzZW1ibHkuTGlua0Vycm9yIHx8IEVycm9yOwogICAgICAgICAgICAgICAgdmFyIFJ1bnRpbWVFcnJvciA9IFdlYkFzc2VtYmx5ICYmIFdlYkFzc2VtYmx5LlJ1bnRpbWVFcnJvciB8fCBFcnJvcjsKICAgICAgICAgICAgICAgIHZhciBET01FeGNlcHRpb24gPSBnZXRCdWlsdGluKCdET01FeGNlcHRpb24nKTsKICAgICAgICAgICAgICAgIHZhciBNYXAgPSBNYXBIZWxwZXJzLk1hcDsKICAgICAgICAgICAgICAgIHZhciBtYXBIYXMgPSBNYXBIZWxwZXJzLmhhczsKICAgICAgICAgICAgICAgIHZhciBtYXBHZXQgPSBNYXBIZWxwZXJzLmdldDsKICAgICAgICAgICAgICAgIHZhciBtYXBTZXQgPSBNYXBIZWxwZXJzLnNldDsKICAgICAgICAgICAgICAgIHZhciBTZXQgPSBTZXRIZWxwZXJzLlNldDsKICAgICAgICAgICAgICAgIHZhciBzZXRBZGQgPSBTZXRIZWxwZXJzLmFkZDsKICAgICAgICAgICAgICAgIHZhciBvYmplY3RLZXlzID0gZ2V0QnVpbHRpbignT2JqZWN0JywgJ2tleXMnKTsKICAgICAgICAgICAgICAgIHZhciBwdXNoID0gdW5jdXJyeVRoaXMoW10ucHVzaCk7CiAgICAgICAgICAgICAgICB2YXIgdGhpc0Jvb2xlYW5WYWx1ZSA9IHVuY3VycnlUaGlzKHRydWUudmFsdWVPZik7CiAgICAgICAgICAgICAgICB2YXIgdGhpc051bWJlclZhbHVlID0gdW5jdXJyeVRoaXMoMS4wLnZhbHVlT2YpOwogICAgICAgICAgICAgICAgdmFyIHRoaXNTdHJpbmdWYWx1ZSA9IHVuY3VycnlUaGlzKCcnLnZhbHVlT2YpOwogICAgICAgICAgICAgICAgdmFyIHRoaXNUaW1lVmFsdWUgPSB1bmN1cnJ5VGhpcyhEYXRlLnByb3RvdHlwZS5nZXRUaW1lKTsKICAgICAgICAgICAgICAgIHZhciBQRVJGT1JNQU5DRV9NQVJLID0gdWlkKCdzdHJ1Y3R1cmVkQ2xvbmUnKTsKICAgICAgICAgICAgICAgIHZhciBEQVRBX0NMT05FX0VSUk9SID0gJ0RhdGFDbG9uZUVycm9yJzsKICAgICAgICAgICAgICAgIHZhciBUUkFOU0ZFUlJJTkcgPSAnVHJhbnNmZXJyaW5nJzsKICAgICAgICAgICAgICAgIHZhciBjaGVja0Jhc2ljU2VtYW50aWMgPSBmdW5jdGlvbiAoc3RydWN0dXJlZENsb25lSW1wbGVtZW50YXRpb24pIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gIWZhaWxzKGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHNldDEgPSBuZXcgZ2xvYmFsLlNldChbN10pOwogICAgICAgICAgICAgICAgICAgICAgICB2YXIgc2V0MiA9IHN0cnVjdHVyZWRDbG9uZUltcGxlbWVudGF0aW9uKHNldDEpOwogICAgICAgICAgICAgICAgICAgICAgICB2YXIgbnVtYmVyID0gc3RydWN0dXJlZENsb25lSW1wbGVtZW50YXRpb24oT2JqZWN0KDcpKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHNldDIgPT0gc2V0MSB8fCAhc2V0Mi5oYXMoNykgfHwgdHlwZW9mIG51bWJlciAhPSAnb2JqZWN0JyB8fCBudW1iZXIgIT0gNzsKICAgICAgICAgICAgICAgICAgICB9KSAmJiBzdHJ1Y3R1cmVkQ2xvbmVJbXBsZW1lbnRhdGlvbjsKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB2YXIgY2hlY2tFcnJvcnNDbG9uaW5nID0gZnVuY3Rpb24gKHN0cnVjdHVyZWRDbG9uZUltcGxlbWVudGF0aW9uLCAkRXJyb3IpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gIWZhaWxzKGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGVycm9yID0gbmV3ICRFcnJvcigpOwogICAgICAgICAgICAgICAgICAgICAgICB2YXIgdGVzdCA9IHN0cnVjdHVyZWRDbG9uZUltcGxlbWVudGF0aW9uKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGE6IGVycm9yLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgYjogZXJyb3IKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAhKHRlc3QgJiYgdGVzdC5hID09PSB0ZXN0LmIgJiYgdGVzdC5hIGluc3RhbmNlb2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ICAgICAgICAgIHZhciBzdHJ1Y3R1cmVkQ2xvbmVGcm9tTWFyayA9ICFuYXRpdmVTdHJ1Y3R1cmVkQ2xvbmUgJiYgY2hlY2tCYXNpY1NlbWFudGljKGZ1bmN0aW9uICh2YWx1ZSkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgUGVyZm9ybWFuY2VNYXJrKFBFUkZPUk1BTkNFX01BUkssIHsgZGV0YWlsOiB2YWx1ZSB9KS5kZXRhaWw7CiAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgIHZhciBuYXRpdmVSZXN0cmljdGVkU3RydWN0dXJlZENsb25lID0gY2hlY2tCYXNpY1NlbWFudGljKG5hdGl2ZVN0cnVjdHVyZWRDbG9uZSkgfHwgc3RydWN0dXJlZENsb25lRnJvbU1hcms7CiAgICAgICAgICAgICAgICB2YXIgdGhyb3dVbmNsb25lYWJsZSA9IGZ1bmN0aW9uICh0eXBlKSB7CiAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IERPTUV4Y2VwdGlvbignVW5jbG9uZWFibGUgdHlwZTogJyArIHR5cGUsIERBVEFfQ0xPTkVfRVJST1IpOwogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIHZhciB0aHJvd1VucG9seWZpbGxhYmxlID0gZnVuY3Rpb24gKHR5cGUsIGFjdGlvbikgewogICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBET01FeGNlcHRpb24oKGFjdGlvbiB8fCAnQ2xvbmluZycpICsgJyBvZiAnICsgdHlwZSArICcgY2Fubm90IGJlIHByb3Blcmx5IHBvbHlmaWxsZWQgaW4gdGhpcyBlbmdpbmUnLCBEQVRBX0NMT05FX0VSUk9SKTsKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB2YXIgY3JlYXRlRGF0YVRyYW5zZmVyID0gZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHZhciBkYXRhVHJhbnNmZXI7CiAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgZGF0YVRyYW5zZmVyID0gbmV3IGdsb2JhbC5EYXRhVHJhbnNmZXIoKTsKICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIChlcnJvcikgewogICAgICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGF0YVRyYW5zZmVyID0gbmV3IGdsb2JhbC5DbGlwYm9hcmRFdmVudCgnJykuY2xpcGJvYXJkRGF0YTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZXJyb3IyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGRhdGFUcmFuc2ZlciAmJiBkYXRhVHJhbnNmZXIuaXRlbXMgJiYgZGF0YVRyYW5zZmVyLmZpbGVzID8gZGF0YVRyYW5zZmVyIDogbnVsbDsKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB2YXIgc3RydWN0dXJlZENsb25lSW50ZXJuYWwgPSBmdW5jdGlvbiAodmFsdWUsIG1hcCkgewogICAgICAgICAgICAgICAgICAgIGlmIChpc1N5bWJvbCh2YWx1ZSkpCiAgICAgICAgICAgICAgICAgICAgICAgIHRocm93VW5jbG9uZWFibGUoJ1N5bWJvbCcpOwogICAgICAgICAgICAgICAgICAgIGlmICghaXNPYmplY3QodmFsdWUpKQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdmFsdWU7CiAgICAgICAgICAgICAgICAgICAgaWYgKG1hcCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAobWFwSGFzKG1hcCwgdmFsdWUpKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG1hcEdldChtYXAsIHZhbHVlKTsKICAgICAgICAgICAgICAgICAgICB9IGVsc2UKICAgICAgICAgICAgICAgICAgICAgICAgbWFwID0gbmV3IE1hcCgpOwogICAgICAgICAgICAgICAgICAgIHZhciB0eXBlID0gY2xhc3NvZih2YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgdmFyIGRlZXAgPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgICB2YXIgQywgbmFtZSwgY2xvbmVkLCBkYXRhVHJhbnNmZXIsIGksIGxlbmd0aCwga2V5cywga2V5LCBzb3VyY2UsIHRhcmdldCwgb3B0aW9uczsKICAgICAgICAgICAgICAgICAgICBzd2l0Y2ggKHR5cGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnQXJyYXknOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVkID0gQXJyYXkobGVuZ3RoT2ZBcnJheUxpa2UodmFsdWUpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlZXAgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ09iamVjdCc6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZWQgPSB7fTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlZXAgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ01hcCc6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZWQgPSBuZXcgTWFwKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWVwID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdTZXQnOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVkID0gbmV3IFNldCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVlcCA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnUmVnRXhwJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsb25lZCA9IG5ldyBSZWdFeHAodmFsdWUuc291cmNlLCBnZXRSZWdFeHBGbGFncyh2YWx1ZSkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ0Vycm9yJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5hbWUgPSB2YWx1ZS5uYW1lOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3dpdGNoIChuYW1lKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnQWdncmVnYXRlRXJyb3InOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZWQgPSBnZXRCdWlsdGluKCdBZ2dyZWdhdGVFcnJvcicpKFtdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnRXZhbEVycm9yJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVkID0gRXZhbEVycm9yKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ1JhbmdlRXJyb3InOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZWQgPSBSYW5nZUVycm9yKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ1JlZmVyZW5jZUVycm9yJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVkID0gUmVmZXJlbmNlRXJyb3IoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnU3ludGF4RXJyb3InOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZWQgPSBTeW50YXhFcnJvcigpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdUeXBlRXJyb3InOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZWQgPSBUeXBlRXJyb3IoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnVVJJRXJyb3InOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZWQgPSBVUklFcnJvcigpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdDb21waWxlRXJyb3InOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZWQgPSBDb21waWxlRXJyb3IoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnTGlua0Vycm9yJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVkID0gTGlua0Vycm9yKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ1J1bnRpbWVFcnJvcic6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsb25lZCA9IFJ1bnRpbWVFcnJvcigpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZWQgPSBFcnJvcigpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVlcCA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnRE9NRXhjZXB0aW9uJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsb25lZCA9IG5ldyBET01FeGNlcHRpb24odmFsdWUubWVzc2FnZSwgdmFsdWUubmFtZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWVwID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdEYXRhVmlldyc6CiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ0ludDhBcnJheSc6CiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ1VpbnQ4QXJyYXknOgogICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdVaW50OENsYW1wZWRBcnJheSc6CiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ0ludDE2QXJyYXknOgogICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdVaW50MTZBcnJheSc6CiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ0ludDMyQXJyYXknOgogICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdVaW50MzJBcnJheSc6CiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ0Zsb2F0MzJBcnJheSc6CiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ0Zsb2F0NjRBcnJheSc6CiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ0JpZ0ludDY0QXJyYXknOgogICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdCaWdVaW50NjRBcnJheSc6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBDID0gZ2xvYmFsW3R5cGVdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFpc09iamVjdChDKSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvd1VucG9seWZpbGxhYmxlKHR5cGUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVkID0gbmV3IEMoc3RydWN0dXJlZENsb25lSW50ZXJuYWwodmFsdWUuYnVmZmVyLCBtYXApLCB2YWx1ZS5ieXRlT2Zmc2V0LCB0eXBlID09PSAnRGF0YVZpZXcnID8gdmFsdWUuYnl0ZUxlbmd0aCA6IHZhbHVlLmxlbmd0aCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnRE9NUXVhZCc6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsb25lZCA9IG5ldyBET01RdWFkKHN0cnVjdHVyZWRDbG9uZUludGVybmFsKHZhbHVlLnAxLCBtYXApLCBzdHJ1Y3R1cmVkQ2xvbmVJbnRlcm5hbCh2YWx1ZS5wMiwgbWFwKSwgc3RydWN0dXJlZENsb25lSW50ZXJuYWwodmFsdWUucDMsIG1hcCksIHN0cnVjdHVyZWRDbG9uZUludGVybmFsKHZhbHVlLnA0LCBtYXApKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG5hdGl2ZVJlc3RyaWN0ZWRTdHJ1Y3R1cmVkQ2xvbmUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVkID0gbmF0aXZlUmVzdHJpY3RlZFN0cnVjdHVyZWRDbG9uZSh2YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93VW5wb2x5ZmlsbGFibGUodHlwZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnRmlsZUxpc3QnOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGF0YVRyYW5zZmVyID0gY3JlYXRlRGF0YVRyYW5zZmVyKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZGF0YVRyYW5zZmVyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChpID0gMCwgbGVuZ3RoID0gbGVuZ3RoT2ZBcnJheUxpa2UodmFsdWUpOyBpIDwgbGVuZ3RoOyBpKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGF0YVRyYW5zZmVyLml0ZW1zLmFkZChzdHJ1Y3R1cmVkQ2xvbmVJbnRlcm5hbCh2YWx1ZVtpXSwgbWFwKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsb25lZCA9IGRhdGFUcmFuc2Zlci5maWxlczsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAobmF0aXZlUmVzdHJpY3RlZFN0cnVjdHVyZWRDbG9uZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsb25lZCA9IG5hdGl2ZVJlc3RyaWN0ZWRTdHJ1Y3R1cmVkQ2xvbmUodmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3dVbnBvbHlmaWxsYWJsZSh0eXBlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdJbWFnZURhdGEnOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZWQgPSBuZXcgSW1hZ2VEYXRhKHN0cnVjdHVyZWRDbG9uZUludGVybmFsKHZhbHVlLmRhdGEsIG1hcCksIHZhbHVlLndpZHRoLCB2YWx1ZS5oZWlnaHQsIHsgY29sb3JTcGFjZTogdmFsdWUuY29sb3JTcGFjZSB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG5hdGl2ZVJlc3RyaWN0ZWRTdHJ1Y3R1cmVkQ2xvbmUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVkID0gbmF0aXZlUmVzdHJpY3RlZFN0cnVjdHVyZWRDbG9uZSh2YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93VW5wb2x5ZmlsbGFibGUodHlwZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChuYXRpdmVSZXN0cmljdGVkU3RydWN0dXJlZENsb25lKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVkID0gbmF0aXZlUmVzdHJpY3RlZFN0cnVjdHVyZWRDbG9uZSh2YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzd2l0Y2ggKHR5cGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnQmlnSW50JzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsb25lZCA9IE9iamVjdCh2YWx1ZS52YWx1ZU9mKCkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ0Jvb2xlYW4nOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVkID0gT2JqZWN0KHRoaXNCb29sZWFuVmFsdWUodmFsdWUpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdOdW1iZXInOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVkID0gT2JqZWN0KHRoaXNOdW1iZXJWYWx1ZSh2YWx1ZSkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ1N0cmluZyc6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZWQgPSBPYmplY3QodGhpc1N0cmluZ1ZhbHVlKHZhbHVlKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnRGF0ZSc6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZWQgPSBuZXcgRGF0ZSh0aGlzVGltZVZhbHVlKHZhbHVlKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnQXJyYXlCdWZmZXInOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQyA9IGdsb2JhbC5EYXRhVmlldzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghQyAmJiB0eXBlb2YgdmFsdWUuc2xpY2UgIT0gJ2Z1bmN0aW9uJykKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvd1VucG9seWZpbGxhYmxlKHR5cGUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIHZhbHVlLnNsaWNlID09ICdmdW5jdGlvbicgJiYgIXZhbHVlLnJlc2l6YWJsZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZWQgPSB2YWx1ZS5zbGljZSgwKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZW5ndGggPSB2YWx1ZS5ieXRlTGVuZ3RoOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvcHRpb25zID0gJ21heEJ5dGVMZW5ndGgnIGluIHZhbHVlID8geyBtYXhCeXRlTGVuZ3RoOiB2YWx1ZS5tYXhCeXRlTGVuZ3RoIH0gOiB1bmRlZmluZWQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsb25lZCA9IG5ldyBBcnJheUJ1ZmZlcihsZW5ndGgsIG9wdGlvbnMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzb3VyY2UgPSBuZXcgQyh2YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRhcmdldCA9IG5ldyBDKGNsb25lZCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoaSA9IDA7IGkgPCBsZW5ndGg7IGkrKykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGFyZ2V0LnNldFVpbnQ4KGksIHNvdXJjZS5nZXRVaW50OChpKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIChlcnJvcikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBET01FeGNlcHRpb24oJ0FycmF5QnVmZmVyIGlzIGRldGFjaGVkJywgREFUQV9DTE9ORV9FUlJPUik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnU2hhcmVkQXJyYXlCdWZmZXInOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVkID0gdmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnQmxvYic6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsb25lZCA9IHZhbHVlLnNsaWNlKDAsIHZhbHVlLnNpemUsIHZhbHVlLnR5cGUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZXJyb3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvd1VucG9seWZpbGxhYmxlKHR5cGUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ0RPTVBvaW50JzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnRE9NUG9pbnRSZWFkT25seSc6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBDID0gZ2xvYmFsW3R5cGVdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZWQgPSBDLmZyb21Qb2ludCA/IEMuZnJvbVBvaW50KHZhbHVlKSA6IG5ldyBDKHZhbHVlLngsIHZhbHVlLnksIHZhbHVlLnosIHZhbHVlLncpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZXJyb3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvd1VucG9seWZpbGxhYmxlKHR5cGUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ0RPTVJlY3QnOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdET01SZWN0UmVhZE9ubHknOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQyA9IGdsb2JhbFt0eXBlXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVkID0gQy5mcm9tUmVjdCA/IEMuZnJvbVJlY3QodmFsdWUpIDogbmV3IEModmFsdWUueCwgdmFsdWUueSwgdmFsdWUud2lkdGgsIHZhbHVlLmhlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIChlcnJvcikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93VW5wb2x5ZmlsbGFibGUodHlwZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnRE9NTWF0cml4JzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnRE9NTWF0cml4UmVhZE9ubHknOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQyA9IGdsb2JhbFt0eXBlXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVkID0gQy5mcm9tTWF0cml4ID8gQy5mcm9tTWF0cml4KHZhbHVlKSA6IG5ldyBDKHZhbHVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3dVbnBvbHlmaWxsYWJsZSh0eXBlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdBdWRpb0RhdGEnOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdWaWRlb0ZyYW1lJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghaXNDYWxsYWJsZSh2YWx1ZS5jbG9uZSkpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3dVbnBvbHlmaWxsYWJsZSh0eXBlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVkID0gdmFsdWUuY2xvbmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3dVbmNsb25lYWJsZSh0eXBlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdGaWxlJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVkID0gbmV3IEZpbGUoW3ZhbHVlXSwgdmFsdWUubmFtZSwgdmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZXJyb3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvd1VucG9seWZpbGxhYmxlKHR5cGUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ0Nyb3BUYXJnZXQnOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdDcnlwdG9LZXknOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdGaWxlU3lzdGVtRGlyZWN0b3J5SGFuZGxlJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnRmlsZVN5c3RlbUZpbGVIYW5kbGUnOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdGaWxlU3lzdGVtSGFuZGxlJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnR1BVQ29tcGlsYXRpb25JbmZvJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnR1BVQ29tcGlsYXRpb25NZXNzYWdlJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnSW1hZ2VCaXRtYXAnOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdSVENDZXJ0aWZpY2F0ZSc6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ1dlYkFzc2VtYmx5Lk1vZHVsZSc6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvd1VucG9seWZpbGxhYmxlKHR5cGUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3dVbmNsb25lYWJsZSh0eXBlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIG1hcFNldChtYXAsIHZhbHVlLCBjbG9uZWQpOwogICAgICAgICAgICAgICAgICAgIGlmIChkZWVwKQogICAgICAgICAgICAgICAgICAgICAgICBzd2l0Y2ggKHR5cGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ0FycmF5JzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ09iamVjdCc6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAga2V5cyA9IG9iamVjdEtleXModmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoaSA9IDAsIGxlbmd0aCA9IGxlbmd0aE9mQXJyYXlMaWtlKGtleXMpOyBpIDwgbGVuZ3RoOyBpKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAga2V5ID0ga2V5c1tpXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3JlYXRlUHJvcGVydHkoY2xvbmVkLCBrZXksIHN0cnVjdHVyZWRDbG9uZUludGVybmFsKHZhbHVlW2tleV0sIG1hcCkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ01hcCc6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWUuZm9yRWFjaChmdW5jdGlvbiAodiwgaykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtYXBTZXQoY2xvbmVkLCBzdHJ1Y3R1cmVkQ2xvbmVJbnRlcm5hbChrLCBtYXApLCBzdHJ1Y3R1cmVkQ2xvbmVJbnRlcm5hbCh2LCBtYXApKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ1NldCc6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWUuZm9yRWFjaChmdW5jdGlvbiAodikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZXRBZGQoY2xvbmVkLCBzdHJ1Y3R1cmVkQ2xvbmVJbnRlcm5hbCh2LCBtYXApKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ0Vycm9yJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjcmVhdGVOb25FbnVtZXJhYmxlUHJvcGVydHkoY2xvbmVkLCAnbWVzc2FnZScsIHN0cnVjdHVyZWRDbG9uZUludGVybmFsKHZhbHVlLm1lc3NhZ2UsIG1hcCkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChoYXNPd24odmFsdWUsICdjYXVzZScpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNyZWF0ZU5vbkVudW1lcmFibGVQcm9wZXJ0eShjbG9uZWQsICdjYXVzZScsIHN0cnVjdHVyZWRDbG9uZUludGVybmFsKHZhbHVlLmNhdXNlLCBtYXApKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG5hbWUgPT0gJ0FnZ3JlZ2F0ZUVycm9yJykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZWQuZXJyb3JzID0gc3RydWN0dXJlZENsb25lSW50ZXJuYWwodmFsdWUuZXJyb3JzLCBtYXApOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ0RPTUV4Y2VwdGlvbic6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKEVSUk9SX1NUQUNLX0lOU1RBTExBQkxFKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNyZWF0ZU5vbkVudW1lcmFibGVQcm9wZXJ0eShjbG9uZWQsICdzdGFjaycsIHN0cnVjdHVyZWRDbG9uZUludGVybmFsKHZhbHVlLnN0YWNrLCBtYXApKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gY2xvbmVkOwogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIHZhciB0cnlUb1RyYW5zZmVyID0gZnVuY3Rpb24gKHJhd1RyYW5zZmVyLCBtYXApIHsKICAgICAgICAgICAgICAgICAgICBpZiAoIWlzT2JqZWN0KHJhd1RyYW5zZmVyKSkKICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgVHlwZUVycm9yKCdUcmFuc2ZlciBvcHRpb24gY2Fubm90IGJlIGNvbnZlcnRlZCB0byBhIHNlcXVlbmNlJyk7CiAgICAgICAgICAgICAgICAgICAgdmFyIHRyYW5zZmVyID0gW107CiAgICAgICAgICAgICAgICAgICAgaXRlcmF0ZShyYXdUcmFuc2ZlciwgZnVuY3Rpb24gKHZhbHVlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHB1c2godHJhbnNmZXIsIGFuT2JqZWN0KHZhbHVlKSk7CiAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgdmFyIGkgPSAwOwogICAgICAgICAgICAgICAgICAgIHZhciBsZW5ndGggPSBsZW5ndGhPZkFycmF5TGlrZSh0cmFuc2Zlcik7CiAgICAgICAgICAgICAgICAgICAgdmFyIHZhbHVlLCB0eXBlLCBDLCB0cmFuc2ZlcnJlZEFycmF5LCB0cmFuc2ZlcnJlZCwgY2FudmFzLCBjb250ZXh0OwogICAgICAgICAgICAgICAgICAgIGlmIChQUk9QRVJfVFJBTlNGRVIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdHJhbnNmZXJyZWRBcnJheSA9IG5hdGl2ZVN0cnVjdHVyZWRDbG9uZSh0cmFuc2ZlciwgeyB0cmFuc2ZlcjogdHJhbnNmZXIgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHdoaWxlIChpIDwgbGVuZ3RoKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgbWFwU2V0KG1hcCwgdHJhbnNmZXJbaV0sIHRyYW5zZmVycmVkQXJyYXlbaSsrXSk7CiAgICAgICAgICAgICAgICAgICAgfSBlbHNlCiAgICAgICAgICAgICAgICAgICAgICAgIHdoaWxlIChpIDwgbGVuZ3RoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZSA9IHRyYW5zZmVyW2krK107CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAobWFwSGFzKG1hcCwgdmFsdWUpKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBET01FeGNlcHRpb24oJ0R1cGxpY2F0ZSB0cmFuc2ZlcmFibGUnLCBEQVRBX0NMT05FX0VSUk9SKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHR5cGUgPSBjbGFzc29mKHZhbHVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN3aXRjaCAodHlwZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ0ltYWdlQml0bWFwJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQyA9IGdsb2JhbC5PZmZzY3JlZW5DYW52YXM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghaXNDb25zdHJ1Y3RvcihDKSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93VW5wb2x5ZmlsbGFibGUodHlwZSwgVFJBTlNGRVJSSU5HKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhbnZhcyA9IG5ldyBDKHZhbHVlLndpZHRoLCB2YWx1ZS5oZWlnaHQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGV4dCA9IGNhbnZhcy5nZXRDb250ZXh0KCdiaXRtYXByZW5kZXJlcicpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGV4dC50cmFuc2ZlckZyb21JbWFnZUJpdG1hcCh2YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cmFuc2ZlcnJlZCA9IGNhbnZhcy50cmFuc2ZlclRvSW1hZ2VCaXRtYXAoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZXJyb3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdBdWRpb0RhdGEnOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ1ZpZGVvRnJhbWUnOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWlzQ2FsbGFibGUodmFsdWUuY2xvbmUpIHx8ICFpc0NhbGxhYmxlKHZhbHVlLmNsb3NlKSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93VW5wb2x5ZmlsbGFibGUodHlwZSwgVFJBTlNGRVJSSU5HKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRyYW5zZmVycmVkID0gdmFsdWUuY2xvbmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlLmNsb3NlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnQXJyYXlCdWZmZXInOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWlzQ2FsbGFibGUodmFsdWUudHJhbnNmZXIpKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3dVbnBvbHlmaWxsYWJsZSh0eXBlLCBUUkFOU0ZFUlJJTkcpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cmFuc2ZlcnJlZCA9IHZhbHVlLnRyYW5zZmVyKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ01lZGlhU291cmNlSGFuZGxlJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdNZXNzYWdlUG9ydCc6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnT2Zmc2NyZWVuQ2FudmFzJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdSZWFkYWJsZVN0cmVhbSc6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnVHJhbnNmb3JtU3RyZWFtJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdXcml0YWJsZVN0cmVhbSc6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93VW5wb2x5ZmlsbGFibGUodHlwZSwgVFJBTlNGRVJSSU5HKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0cmFuc2ZlcnJlZCA9PT0gdW5kZWZpbmVkKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBET01FeGNlcHRpb24oJ1RoaXMgb2JqZWN0IGNhbm5vdCBiZSB0cmFuc2ZlcnJlZDogJyArIHR5cGUsIERBVEFfQ0xPTkVfRVJST1IpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbWFwU2V0KG1hcCwgdmFsdWUsIHRyYW5zZmVycmVkKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICQoewogICAgICAgICAgICAgICAgICAgIGdsb2JhbDogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgIHNoYW06ICFQUk9QRVJfVFJBTlNGRVIsCiAgICAgICAgICAgICAgICAgICAgZm9yY2VkOiBGT1JDRURfUkVQTEFDRU1FTlQKICAgICAgICAgICAgICAgIH0sIHsKICAgICAgICAgICAgICAgICAgICBzdHJ1Y3R1cmVkQ2xvbmU6IGZ1bmN0aW9uIHN0cnVjdHVyZWRDbG9uZSh2YWx1ZSkgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgb3B0aW9ucyA9IHZhbGlkYXRlQXJndW1lbnRzTGVuZ3RoKGFyZ3VtZW50cy5sZW5ndGgsIDEpID4gMSAmJiAhaXNOdWxsT3JVbmRlZmluZWQoYXJndW1lbnRzWzFdKSA/IGFuT2JqZWN0KGFyZ3VtZW50c1sxXSkgOiB1bmRlZmluZWQ7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciB0cmFuc2ZlciA9IG9wdGlvbnMgPyBvcHRpb25zLnRyYW5zZmVyIDogdW5kZWZpbmVkOwogICAgICAgICAgICAgICAgICAgICAgICB2YXIgbWFwOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAodHJhbnNmZXIgIT09IHVuZGVmaW5lZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgbWFwID0gbmV3IE1hcCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJ5VG9UcmFuc2Zlcih0cmFuc2ZlciwgbWFwKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gc3RydWN0dXJlZENsb25lSW50ZXJuYWwodmFsdWUsIG1hcCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfSk7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDEyNiAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIHVuY3VycnlUaGlzID0gX193X3BkZmpzX3JlcXVpcmVfXygxNyk7CiAgICAgICAgICAgICAgICB2YXIgZmFpbHMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEwKTsKICAgICAgICAgICAgICAgIHZhciBpc0NhbGxhYmxlID0gX193X3BkZmpzX3JlcXVpcmVfXygyNCk7CiAgICAgICAgICAgICAgICB2YXIgY2xhc3NvZiA9IF9fd19wZGZqc19yZXF1aXJlX18oODIpOwogICAgICAgICAgICAgICAgdmFyIGdldEJ1aWx0SW4gPSBfX3dfcGRmanNfcmVxdWlyZV9fKDI3KTsKICAgICAgICAgICAgICAgIHZhciBpbnNwZWN0U291cmNlID0gX193X3BkZmpzX3JlcXVpcmVfXyg1NCk7CiAgICAgICAgICAgICAgICB2YXIgbm9vcCA9IGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB2YXIgZW1wdHkgPSBbXTsKICAgICAgICAgICAgICAgIHZhciBjb25zdHJ1Y3QgPSBnZXRCdWlsdEluKCdSZWZsZWN0JywgJ2NvbnN0cnVjdCcpOwogICAgICAgICAgICAgICAgdmFyIGNvbnN0cnVjdG9yUmVnRXhwID0gL15ccyooPzpjbGFzc3xmdW5jdGlvbilcYi87CiAgICAgICAgICAgICAgICB2YXIgZXhlYyA9IHVuY3VycnlUaGlzKGNvbnN0cnVjdG9yUmVnRXhwLmV4ZWMpOwogICAgICAgICAgICAgICAgdmFyIElOQ09SUkVDVF9UT19TVFJJTkcgPSAhY29uc3RydWN0b3JSZWdFeHAuZXhlYyhub29wKTsKICAgICAgICAgICAgICAgIHZhciBpc0NvbnN0cnVjdG9yTW9kZXJuID0gZnVuY3Rpb24gaXNDb25zdHJ1Y3Rvcihhcmd1bWVudCkgewogICAgICAgICAgICAgICAgICAgIGlmICghaXNDYWxsYWJsZShhcmd1bWVudCkpCiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3Qobm9vcCwgZW1wdHksIGFyZ3VtZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZXJyb3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB2YXIgaXNDb25zdHJ1Y3RvckxlZ2FjeSA9IGZ1bmN0aW9uIGlzQ29uc3RydWN0b3IoYXJndW1lbnQpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoIWlzQ2FsbGFibGUoYXJndW1lbnQpKQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgc3dpdGNoIChjbGFzc29mKGFyZ3VtZW50KSkgewogICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdBc3luY0Z1bmN0aW9uJzoKICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnR2VuZXJhdG9yRnVuY3Rpb24nOgogICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdBc3luY0dlbmVyYXRvckZ1bmN0aW9uJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIElOQ09SUkVDVF9UT19TVFJJTkcgfHwgISFleGVjKGNvbnN0cnVjdG9yUmVnRXhwLCBpbnNwZWN0U291cmNlKGFyZ3VtZW50KSk7CiAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZXJyb3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIGlzQ29uc3RydWN0b3JMZWdhY3kuc2hhbSA9IHRydWU7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9ICFjb25zdHJ1Y3QgfHwgZmFpbHMoZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHZhciBjYWxsZWQ7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGlzQ29uc3RydWN0b3JNb2Rlcm4oaXNDb25zdHJ1Y3Rvck1vZGVybi5jYWxsKSB8fCAhaXNDb25zdHJ1Y3Rvck1vZGVybihPYmplY3QpIHx8ICFpc0NvbnN0cnVjdG9yTW9kZXJuKGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY2FsbGVkID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICB9KSB8fCBjYWxsZWQ7CiAgICAgICAgICAgICAgICB9KSA/IGlzQ29uc3RydWN0b3JMZWdhY3kgOiBpc0NvbnN0cnVjdG9yTW9kZXJuOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxMjcgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUpID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgJFR5cGVFcnJvciA9IFR5cGVFcnJvcjsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKHBhc3NlZCwgcmVxdWlyZWQpIHsKICAgICAgICAgICAgICAgICAgICBpZiAocGFzc2VkIDwgcmVxdWlyZWQpCiAgICAgICAgICAgICAgICAgICAgICAgIHRocm93ICRUeXBlRXJyb3IoJ05vdCBlbm91Z2ggYXJndW1lbnRzJyk7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHBhc3NlZDsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDEyOCAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIGNhbGwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDExKTsKICAgICAgICAgICAgICAgIHZhciBoYXNPd24gPSBfX3dfcGRmanNfcmVxdWlyZV9fKDQyKTsKICAgICAgICAgICAgICAgIHZhciBpc1Byb3RvdHlwZU9mID0gX193X3BkZmpzX3JlcXVpcmVfXygyOCk7CiAgICAgICAgICAgICAgICB2YXIgcmVnRXhwRmxhZ3MgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEyOSk7CiAgICAgICAgICAgICAgICB2YXIgUmVnRXhwUHJvdG90eXBlID0gUmVnRXhwLnByb3RvdHlwZTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKFIpIHsKICAgICAgICAgICAgICAgICAgICB2YXIgZmxhZ3MgPSBSLmZsYWdzOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBmbGFncyA9PT0gdW5kZWZpbmVkICYmICEoJ2ZsYWdzJyBpbiBSZWdFeHBQcm90b3R5cGUpICYmICFoYXNPd24oUiwgJ2ZsYWdzJykgJiYgaXNQcm90b3R5cGVPZihSZWdFeHBQcm90b3R5cGUsIFIpID8gY2FsbChyZWdFeHBGbGFncywgUikgOiBmbGFnczsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDEyOSAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKICAgICAgICAgICAgICAgIHZhciBhbk9iamVjdCA9IF9fd19wZGZqc19yZXF1aXJlX18oNTApOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgdmFyIHRoYXQgPSBhbk9iamVjdCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICB2YXIgcmVzdWx0ID0gJyc7CiAgICAgICAgICAgICAgICAgICAgaWYgKHRoYXQuaGFzSW5kaWNlcykKICAgICAgICAgICAgICAgICAgICAgICAgcmVzdWx0ICs9ICdkJzsKICAgICAgICAgICAgICAgICAgICBpZiAodGhhdC5nbG9iYWwpCiAgICAgICAgICAgICAgICAgICAgICAgIHJlc3VsdCArPSAnZyc7CiAgICAgICAgICAgICAgICAgICAgaWYgKHRoYXQuaWdub3JlQ2FzZSkKICAgICAgICAgICAgICAgICAgICAgICAgcmVzdWx0ICs9ICdpJzsKICAgICAgICAgICAgICAgICAgICBpZiAodGhhdC5tdWx0aWxpbmUpCiAgICAgICAgICAgICAgICAgICAgICAgIHJlc3VsdCArPSAnbSc7CiAgICAgICAgICAgICAgICAgICAgaWYgKHRoYXQuZG90QWxsKQogICAgICAgICAgICAgICAgICAgICAgICByZXN1bHQgKz0gJ3MnOwogICAgICAgICAgICAgICAgICAgIGlmICh0aGF0LnVuaWNvZGUpCiAgICAgICAgICAgICAgICAgICAgICAgIHJlc3VsdCArPSAndSc7CiAgICAgICAgICAgICAgICAgICAgaWYgKHRoYXQudW5pY29kZVNldHMpCiAgICAgICAgICAgICAgICAgICAgICAgIHJlc3VsdCArPSAndic7CiAgICAgICAgICAgICAgICAgICAgaWYgKHRoYXQuc3RpY2t5KQogICAgICAgICAgICAgICAgICAgICAgICByZXN1bHQgKz0gJ3knOwogICAgICAgICAgICAgICAgICAgIHJldHVybiByZXN1bHQ7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxMzAgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciB1bmN1cnJ5VGhpcyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTcpOwogICAgICAgICAgICAgICAgdmFyIE1hcFByb3RvdHlwZSA9IE1hcC5wcm90b3R5cGU7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IHsKICAgICAgICAgICAgICAgICAgICBNYXA6IE1hcCwKICAgICAgICAgICAgICAgICAgICBzZXQ6IHVuY3VycnlUaGlzKE1hcFByb3RvdHlwZS5zZXQpLAogICAgICAgICAgICAgICAgICAgIGdldDogdW5jdXJyeVRoaXMoTWFwUHJvdG90eXBlLmdldCksCiAgICAgICAgICAgICAgICAgICAgaGFzOiB1bmN1cnJ5VGhpcyhNYXBQcm90b3R5cGUuaGFzKSwKICAgICAgICAgICAgICAgICAgICByZW1vdmU6IHVuY3VycnlUaGlzKE1hcFByb3RvdHlwZVsnZGVsZXRlJ10pLAogICAgICAgICAgICAgICAgICAgIHByb3RvOiBNYXBQcm90b3R5cGUKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDEzMSAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIHVuY3VycnlUaGlzID0gX193X3BkZmpzX3JlcXVpcmVfXygxNyk7CiAgICAgICAgICAgICAgICB2YXIgU2V0UHJvdG90eXBlID0gU2V0LnByb3RvdHlwZTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gewogICAgICAgICAgICAgICAgICAgIFNldDogU2V0LAogICAgICAgICAgICAgICAgICAgIGFkZDogdW5jdXJyeVRoaXMoU2V0UHJvdG90eXBlLmFkZCksCiAgICAgICAgICAgICAgICAgICAgaGFzOiB1bmN1cnJ5VGhpcyhTZXRQcm90b3R5cGUuaGFzKSwKICAgICAgICAgICAgICAgICAgICByZW1vdmU6IHVuY3VycnlUaGlzKFNldFByb3RvdHlwZVsnZGVsZXRlJ10pLAogICAgICAgICAgICAgICAgICAgIHByb3RvOiBTZXRQcm90b3R5cGUsCiAgICAgICAgICAgICAgICAgICAgJGhhczogU2V0UHJvdG90eXBlLmhhcywKICAgICAgICAgICAgICAgICAgICAka2V5czogU2V0UHJvdG90eXBlLmtleXMKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDEzMiAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIGZhaWxzID0gX193X3BkZmpzX3JlcXVpcmVfXygxMCk7CiAgICAgICAgICAgICAgICB2YXIgY3JlYXRlUHJvcGVydHlEZXNjcmlwdG9yID0gX193X3BkZmpzX3JlcXVpcmVfXygxNCk7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9ICFmYWlscyhmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgdmFyIGVycm9yID0gRXJyb3IoJ2EnKTsKICAgICAgICAgICAgICAgICAgICBpZiAoISgnc3RhY2snIGluIGVycm9yKSkKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGVycm9yLCAnc3RhY2snLCBjcmVhdGVQcm9wZXJ0eURlc2NyaXB0b3IoMSwgNykpOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBlcnJvci5zdGFjayAhPT0gNzsKICAgICAgICAgICAgICAgIH0pOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxMzMgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBnbG9iYWwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDcpOwogICAgICAgICAgICAgICAgdmFyIGZhaWxzID0gX193X3BkZmpzX3JlcXVpcmVfXygxMCk7CiAgICAgICAgICAgICAgICB2YXIgVjggPSBfX3dfcGRmanNfcmVxdWlyZV9fKDMxKTsKICAgICAgICAgICAgICAgIHZhciBJU19CUk9XU0VSID0gX193X3BkZmpzX3JlcXVpcmVfXygxMzQpOwogICAgICAgICAgICAgICAgdmFyIElTX0RFTk8gPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEzNSk7CiAgICAgICAgICAgICAgICB2YXIgSVNfTk9ERSA9IF9fd19wZGZqc19yZXF1aXJlX18oMTM2KTsKICAgICAgICAgICAgICAgIHZhciBzdHJ1Y3R1cmVkQ2xvbmUgPSBnbG9iYWwuc3RydWN0dXJlZENsb25lOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSAhIXN0cnVjdHVyZWRDbG9uZSAmJiAhZmFpbHMoZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIGlmIChJU19ERU5PICYmIFY4ID4gOTIgfHwgSVNfTk9ERSAmJiBWOCA+IDk0IHx8IElTX0JST1dTRVIgJiYgVjggPiA5NykKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgICAgICAgICAgIHZhciBidWZmZXIgPSBuZXcgQXJyYXlCdWZmZXIoOCk7CiAgICAgICAgICAgICAgICAgICAgdmFyIGNsb25lID0gc3RydWN0dXJlZENsb25lKGJ1ZmZlciwgeyB0cmFuc2ZlcjogW2J1ZmZlcl0gfSk7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGJ1ZmZlci5ieXRlTGVuZ3RoICE9IDAgfHwgY2xvbmUuYnl0ZUxlbmd0aCAhPSA4OwogICAgICAgICAgICAgICAgfSk7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDEzNCAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIElTX0RFTk8gPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEzNSk7CiAgICAgICAgICAgICAgICB2YXIgSVNfTk9ERSA9IF9fd19wZGZqc19yZXF1aXJlX18oMTM2KTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gIUlTX0RFTk8gJiYgIUlTX05PREUgJiYgdHlwZW9mIHdpbmRvdyA9PSAnb2JqZWN0JyAmJiB0eXBlb2YgZG9jdW1lbnQgPT0gJ29iamVjdCc7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDEzNSAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSkgPT4gewoKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gdHlwZW9mIERlbm8gPT0gJ29iamVjdCcgJiYgRGVubyAmJiB0eXBlb2YgRGVuby52ZXJzaW9uID09ICdvYmplY3QnOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxMzYgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBjbGFzc29mID0gX193X3BkZmpzX3JlcXVpcmVfXygxOCk7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IHR5cGVvZiBwcm9jZXNzICE9ICd1bmRlZmluZWQnICYmIGNsYXNzb2YocHJvY2VzcykgPT0gJ3Byb2Nlc3MnOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxMzcgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBnbG9iYWwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDcpOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBnbG9iYWw7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDEzOCAqLwogICAgICAgICAgICAvKioqLyAoKF9fdW51c2VkX3dlYnBhY2tfbW9kdWxlLCBleHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKCiAgICAgICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIl9fZXNNb2R1bGUiLCAoewogICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0cnVlCiAgICAgICAgICAgICAgICB9KSk7CiAgICAgICAgICAgICAgICBleHBvcnRzLmJ1aWxkID0gZXhwb3J0cy5SZW5kZXJUYXNrID0gZXhwb3J0cy5QREZXb3JrZXJVdGlsID0gZXhwb3J0cy5QREZXb3JrZXIgPSBleHBvcnRzLlBERlBhZ2VQcm94eSA9I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iAgICAgICAgICAgICAgICBleHBvcnRzLkRlZmF1bHRDTWFwUmVhZGVyRmFjdG9yeSA9IERlZmF1bHRDTWFwUmVhZGVyRmFjdG9yeTsKICAgICAgICAgICAgICAgIGxldCBEZWZhdWx0RmlsdGVyRmFjdG9yeSA9IF9kaXNwbGF5X3V0aWxzLkRPTUZpbHRlckZhY3Rvcnk7CiAgICAgICAgICAgICAgICBleHBvcnRzLkRlZmF1bHRGaWx0ZXJGYWN0b3J5ID0gRGVmYXVsdEZpbHRlckZhY3Rvcnk7CiAgICAgICAgICAgICAgICBsZXQgRGVmYXVsdFN0YW5kYXJkRm9udERhdGFGYWN0b3J5ID0gX2Rpc3BsYXlfdXRpbHMuRE9NU3RhbmRhcmRGb250RGF0YUZhY3Rvcnk7CiAgICAgICAgICAgICAgICBleHBvcnRzLkRlZmF1bHRTdGFuZGFyZEZvbnREYXRhRmFjdG9yeSA9IERlZmF1bHRTdGFuZGFyZEZvbnREYXRhRmFjdG9yeTsKICAgICAgICAgICAgICAgIGlmIChfaXNfbm9kZS5pc05vZGVKUykgewogICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgTm9kZUNhbnZhc0ZhY3RvcnksCiAgICAgICAgICAgICAgICAgICAgICAgIE5vZGVDTWFwUmVhZGVyRmFjdG9yeSwKICAgICAgICAgICAgICAgICAgICAgICAgTm9kZUZpbHRlckZhY3RvcnksCiAgICAgICAgICAgICAgICAgICAgICAgIE5vZGVTdGFuZGFyZEZvbnREYXRhRmFjdG9yeQogICAgICAgICAgICAgICAgICAgIH0gPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE1NSk7CiAgICAgICAgICAgICAgICAgICAgZXhwb3J0cy5EZWZhdWx0Q2FudmFzRmFjdG9yeSA9IERlZmF1bHRDYW52YXNGYWN0b3J5ID0gTm9kZUNhbnZhc0ZhY3Rvcnk7CiAgICAgICAgICAgICAgICAgICAgZXhwb3J0cy5EZWZhdWx0Q01hcFJlYWRlckZhY3RvcnkgPSBEZWZhdWx0Q01hcFJlYWRlckZhY3RvcnkgPSBOb2RlQ01hcFJlYWRlckZhY3Rvcnk7CiAgICAgICAgICAgICAgICAgICAgZXhwb3J0cy5EZWZhdWx0RmlsdGVyRmFjdG9yeSA9IERlZmF1bHRGaWx0ZXJGYWN0b3J5ID0gTm9kZUZpbHRlckZhY3Rvcnk7CiAgICAgICAgICAgICAgICAgICAgZXhwb3J0cy5EZWZhdWx0U3RhbmRhcmRGb250RGF0YUZhY3RvcnkgPSBEZWZhdWx0U3RhbmRhcmRGb250RGF0YUZhY3RvcnkgPSBOb2RlU3RhbmRhcmRGb250RGF0YUZhY3Rvcnk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBsZXQgY3JlYXRlUERGTmV0d29ya1N0cmVhbTsKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICBpZiAoX2lzX25vZGUuaXNOb2RlSlMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgUERGTm9kZVN0cmVhbQogICAgICAgICAgICAgICAgICAgICAgICB9ID0gX193X3BkZmpzX3JlcXVpcmVfXygxNTYpOwogICAgICAgICAgICAgICAgICAgICAgICBjcmVhdGVQREZOZXR3b3JrU3RyZWFtID0gcGFyYW1zID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgUERGTm9kZVN0cmVhbShwYXJhbXMpOwogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIFBERk5ldHdvcmtTdHJlYW0KICAgICAgICAgICAgICAgICAgICAgICAgfSA9IF9fd19wZGZqc19yZXF1aXJlX18oMTU5KTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgUERGRmV0Y2hTdHJlYW0KICAgICAgICAgICAgICAgICAgICAgICAgfSA9IF9fd19wZGZqc19yZXF1aXJlX18oMTYwKTsKICAgICAgICAgICAgICAgICAgICAgICAgY3JlYXRlUERGTmV0d29ya1N0cmVhbSA9IHBhcmFtcyA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gKDAsIF9kaXNwbGF5X3V0aWxzLmlzVmFsaWRGZXRjaFVybCkocGFyYW1zLnVybCkgPyBuZXcgUERGRmV0Y2hTdHJlYW0ocGFyYW1zKSA6IG5ldyBQREZOZXR3b3JrU3RyZWFtKHBhcmFtcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gZ2V0RG9jdW1lbnQoc3JjKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKHR5cGVvZiBzcmMgPT09ICJzdHJpbmciIHx8IHNyYyBpbnN0YW5jZW9mIFVSTCkgewogICAgICAgICAgICAgICAgICAgICAgICBzcmMgPSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB1cmw6IHNyYwogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoKDAsIF91dGlsLmlzQXJyYXlCdWZmZXIpKHNyYykpIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3JjID0gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGF0YTogc3JjCiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmICh0eXBlb2Ygc3JjICE9PSAib2JqZWN0IikgewogICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoIkludmFsaWQgcGFyYW1ldGVyIGluIGdldERvY3VtZW50LCBuZWVkIHBhcmFtZXRlciBvYmplY3QuIik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmICghc3JjLnVybCAmJiAhc3JjLmRhdGEgJiYgIXNyYy5yYW5nZSkgewogICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoIkludmFsaWQgcGFyYW1ldGVyIG9iamVjdDogbmVlZCBlaXRoZXIgLmRhdGEsIC5yYW5nZSBvciAudXJsIik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNvbnN0IHRhc2sgPSBuZXcgUERGRG9jdW1lbnRMb2FkaW5nVGFzaygpOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgZG9jSWQKICAgICAgICAgICAgICAgICAgICB9ID0gdGFzazsKICAgICAgICAgICAgICAgICAgICBjb25zdCB1cmwgPSBzcmMudXJsID8gZ2V0VXJsUHJvcChzcmMudXJsKSA6IG51bGw7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgZGF0YSA9IHNyYy5kYXRhID8gZ2V0RGF0YVByb3Aoc3JjLmRhdGEpIDogbnVsbDsKICAgICAgICAgICAgICAgICAgICBjb25zdCBodHRwSGVhZGVycyA9IHNyYy5odHRwSGVhZGVycyB8fCBudWxsOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHdpdGhDcmVkZW50aWFscyA9IHNyYy53aXRoQ3JlZGVudGlhbHMgPT09IHRydWU7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgcGFzc3dvcmQgPSBzcmMucGFzc3dvcmQgPz8gbnVsbDsKICAgICAgICAgICAgICAgICAgICBjb25zdCByYW5nZVRyYW5zcG9ydCA9IHNyYy5yYW5nZSBpbnN0YW5jZW9mIFBERkRhdGFSYW5nZVRyYW5zcG9ydCA/IHNyYy5yYW5nZSA6IG51bGw7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgcmFuZ2VDaHVua1NpemUgPSBOdW1iZXIuaXNJbnRlZ2VyK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yZEZvbnREYXRhRmFjdG9yeSAmJiAoMCwgX2Rpc3BsYXlfdXRpbHMuaXNWYWxpZEZldGNoVXJsKShjTWFwVXJsLCBkb2N1bWVudC5iYXNlVVJJKSAmJiAoMCwgX2Rpc3BsYXlfdXRpbHMuaXNWYWxpZEZldGNoVXJsKShzdGFuZGFyZEZvbnREYXRhVXJsLCBkb2N1bWVudC5iYXNlVVJJKTsKICAgICAgICAgICAgICAgICAgICBjb25zdCBjYW52YXNGYWN0b3J5ID0gc3JjLmNhbnZhc0ZhY3RvcnkgfHwgbmV3IERlZmF1bHRDYW52YXNGYWN0b3J5KHsKICAgICAgICAgICAgICAgICAgICAgICAgb3duZXJEb2N1bWVudAogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IGZpbHRlckZhY3RvcnkgPSBzcmMuZmlsdGVyRmFjdG9yeSB8fCBuZXcgRGVmYXVsdEZpbHRlckZhY3RvcnkoewogICAgICAgICAgICAgICAgICAgICAgICBkb2NJZCwKICAgICAgICAgICAgICAgICAgICAgICAgb3duZXJEb2N1bWVudAogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0eWxlRWxlbWVudCA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLnNldFZlcmJvc2l0eUxldmVsKSh2ZXJib3NpdHkpOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHRyYW5zcG9ydEZhY3RvcnkgPSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNhbnZhc0ZhY3RvcnksCiAgICAgICAgICAgICAgICAgICAgICAgIGZpbHRlckZhY3RvcnkKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIGlmICghdXNlV29ya2VyRmV0Y2gpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdHJhbnNwb3J0RmFjdG9yeS5jTWFwUmVhZGVyRmFjdG9yeSA9IG5ldyBDTWFwUmVhZGVyRmFjdG9yeSh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBiYXNlVXJsOiBjTWFwVXJsLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNDb21wcmVzc2VkOiBjTWFwUGFja2VkCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB0cmFuc3BvcnRGYWN0b3J5LnN0YW5kYXJkRm9udERhdGFGYWN0b3J5ID0gbmV3IFN0YW5kYXJkRm9udERhdGFGYWN0b3J5KHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJhc2VVcmw6IHN0YW5kYXJkRm9udERhdGFVcmwKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmICghd29ya2VyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHdvcmtlclBhcmFtcyA9IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZlcmJvc2l0eSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBvcnQ6IF93b3JrZXJfb3B0aW9ucy5HbG9iYWxXb3JrZXJPcHRpb25zLndvcmtlclBvcnQKICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgd29ya2VyID0gd29ya2VyUGFyYW1zLnBvcnQgPyBQREZXb3JrZXIuZnJvbVBvcnQod29ya2VyUGFyYW1zKSA6IG5ldyBQREZXb3JrZXIod29ya2VyUGFyYW1zKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGFzay5fd29ya2VyID0gd29ya2VyOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjb25zdCBmZXRjaERvY1BhcmFtcyA9IHsKICAgICAgICAgICAgICAgICAgICAgICAgZG9jSWQsCiAgICAgICAgICAgICAgICAgICAgICAgIGFwaVZlcnNpb246ICczLjUuMTIyJywKICAgICAgICAgICAgICAgICAgICAgICAgZGF0YSwKICAgICAgICAgICAgICAgICAgICAgICAgcGFzc3dvcmQsCiAgICAgICAgICAgICAgICAgICAgICAgIGRpc2FibGVBdXRvRmV0Y2gsCiAgICAgICAgICAgICAgICAgICAgICAgIHJhbmdlQ2h1bmtTaXplLAogICAgICAgICAgICAgICAgICAgICAgICBsZW5ndGgsCiAgICAgICAgICAgICAgICAgICAgICAgIGRvY0Jhc2VVcmwsCiAgICAgICAgICAgICAgICAgICAgICAgIGVuYWJsZVhmYSwKICAgICAgICAgICAgICAgICAgICAgICAgZXZhbHVhdG9yT3B0aW9uczogewogICAgICAgICAgICAgICAgICAgICAgICAgICAgbWF4SW1hZ2VTaXplLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGlzYWJsZUZvbnRGYWNlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWdub3JlRXJyb3JzLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNFdmFsU3VwcG9ydGVkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNPZmZzY3JlZW5DYW52YXNTdXBwb3J0ZWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYW52YXNNYXhBcmVhSW5CeXRlcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvbnRFeHRyYVByb3BlcnRpZXMsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB1c2VTeXN0ZW1Gb250cywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNNYXBVcmw6IHVzZVdvcmtlckZldGNoID8gY01hcFVybCA6IG51bGwsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGFuZGFyZEZvbnREYXRhVXJsOiB1c2VXb3JrZXJGZXRjaCA/IHN0YW5kYXJkRm9udERhdGFVcmwgOiBudWxsCiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHRyYW5zcG9ydFBhcmFtcyA9IHsKICAgICAgICAgICAgICAgICAgICAgICAgaWdub3JlRXJyb3JzLAogICAgICAgICAgICAgICAgICAgICAgICBpc0V2YWxTdXBwb3J0ZWQsCiAgICAgICAgICAgICAgICAgICAgICAgIGRpc2FibGVGb250RmFjZSwKICAgICAgICAgICAgICAgICAgICAgICAgZm9udEV4dHJhUHJvcGVydGllcywKICAgICAgICAgICAgICAgICAgICAgICAgZW5hYmxlWGZhLAogICAgICAgICAgICAgICAgICAgICAgICBvd25lckRvY3VtZW50LAogICAgICAgICAgICAgICAgICAgICAgICBkaXNhYmxlQXV0b0ZldGNoLAogICAgICAgICAgICAgICAgICAgICAgICBwZGZCdWcsCiAgICAgICAgICAgICAgICAgICAgICAgIHN0eWxlRWxlbWVudAogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgd29ya2VyLnByb21pc2UudGhlbihmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0YXNrLmRlc3Ryb3llZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCJMb2FkaW5nIGFib3J0ZWQiKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB3b3JrZXJJZFByb21pc2UgPSBfZmV0Y2hEb2N1bWVudCh3b3JrZXIsIGZldGNoRG9jUGFyYW1zKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbmV0d29ya1N0cmVhbVByb21pc2UgPSBuZXcgUHJvbWlzZShmdW5jdGlvbiAocmVzb2x2ZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IG5ldHdvcmtTdHJlYW07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAocmFuZ2VUcmFuc3BvcnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBuZXR3b3JrU3RyZWFtID0gbmV3IF90cmFuc3BvcnRfc3RyZWFtLlBERkRhdGFUcmFuc3BvcnRTdHJlYW0oewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZW5ndGgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGluaXRpYWxEYXRhOiByYW5nZVRyYW5zcG9ydC5pbml0aWFsRGF0YSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJvZ3Jlc3NpdmVEb25lOiByYW5nZVRyYW5zcG9ydC5wcm9ncmVzc2l2ZURvbmUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRlbnREaXNwb3NpdGlvbkZpbGVuYW1lOiByYW5nZVRyYW5zcG9ydC5jb250ZW50RGlzcG9zaXRpb25GaWxlbmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGlzYWJsZVJhbmdlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkaXNhYmxlU3RyZWFtCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSwgcmFuZ2VUcmFuc3BvcnQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmICghZGF0YSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5ldHdvcmtTdHJlYW0gPSBjcmVhdGVQREZOZXR3b3JrU3RyZWFtKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdXJsLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZW5ndGgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGh0dHBIZWFkZXJzLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB3aXRoQ3JlZGVudGlhbHMsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJhbmdlQ2h1bmtTaXplLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkaXNhYmxlUmFuZ2UsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRpc2FibGVTdHJlYW0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlc29sdmUobmV0d29ya1N0cmVhbSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gUHJvbWlzZS5hbGwoW3dvcmtlcklkUHJvbWlzZSwgbmV0d29ya1N0cmVhbVByb21pc2VdKS50aGVuKGZ1bmN0aW9uIChfcmVmKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgW3dvcmtlcklkLCBuZXR3b3JrU3RyZWFtXSA9IF9yZWY7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodGFzay5kZXN0cm95ZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoIkxvYWRpbmcgYWJvcnRlZCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbWVzc2FnZUhhbmRsZXIgPSBuZXcgX21lc3NhZ2VfaGFuZGxlci5NZXNzYWdlSGFuZGxlcihkb2NJZCwgd29ya2VySWQsIHdvcmtlci5wb3J0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHRyYW5zcG9ydCA9IG5ldyBXb3JrZXJUcmFuc3BvcnQobWVzc2FnZUhhbmRsZXIsIHRhc2ssIG5ldHdvcmtTdHJlYW0sIHRyYW5zcG9ydFBhcmFtcywgdHJhbnNwb3J0RmFjdG9yeSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0YXNrLl90cmFuc3BvcnQgPSB0cmFuc3BvcnQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtZXNzYWdlSGFuZGxlci5zZW5kKCJSZWFkeSIsIG51bGwpOwogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9KS5jYXRjaCh0YXNrLl9jYXBhYmlsaXR5LnJlamVjdCk7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRhc2s7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBhc3luYyBmdW5jdGlvbiBfZmV0Y2hEb2N1bWVudCh3b3JrZXIsIHNvdXJjZSkgewogICAgICAgICAgICAgICAgICAgIGlmICh3b3JrZXIuZGVzdHJveWVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcigiV29ya2VyIHdhcyBkZXN0cm95ZWQiKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY29uc3Qgd29ya2VySWQgPSBhd2FpdCB3b3JrZXIubWVzc2FnZUhhbmRsZXIuc2VuZFdpdGhQcm9taXNlKCJHZXREb2NSZXF1ZXN0Iiwgc291cmNlLCBzb3VyY2UuZGF0YSA/IFtzb3VyY2UuZGF0YS5idWZmZXJdIDogbnVsbCk7CiAgICAgICAgICAgICAgICAgICAgaWYgKHdvcmtlci5kZXN0cm95ZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCJXb3JrZXIgd2FzIGRlc3Ryb3llZCIpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gd29ya2VySWQ7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBnZXRVcmxQcm9wKHZhbCkgewogICAgICAgICAgICAgICAgICAgIGlmICh2YWwgaW5zdGFuY2VvZiBVUkwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHZhbC5ocmVmOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IFVSTCh2YWwsIHdpbmRvdy5sb2NhdGlvbikuaHJlZjsKICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIChleCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoX2lzX25vZGUuaXNOb2RlSlMgJiYgdHlwZW9mIHZhbCA9PT0gInN0cmluZyIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB2YWw7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCJJbnZhbGlkIFBERiB1cmwgZGF0YTogIiArICJlaXRoZXIgc3RyaW5nIG9yIFVSTC1vYmplY3QgaXMgZXhwZWN0ZWQgaW4gdGhlIHVybCBwcm9wZXJ0eS4iKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGdldERhdGFQcm9wKHZhbCkgewogICAgICAgICAgICAgICAgICAgIGlmIChfaXNfbm9kZS5pc05vZGVKUyAmJiB0eXBlb2YgQnVmZmVyICE9PSAidW5kZWZpbmVkIiAmJiB2YWwgaW5zdGFuY2VvZiBCdWZmZXIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF9kaXNwbGF5X3V0aWxzLmRlcHJlY2F0ZWQpKCJQbGVhc2UgcHJvdmlkZSBiaW5hcnkgZGF0YSBhcyBgVWludDhBcnJheWAsIHJhdGhlciB0aGFuIGBCdWZmZXJgLiIpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IFVpbnQ4QXJyYXkodmFsKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaWYgKHZhbCBpbnN0YW5jZW9mIFVpbnQ4QXJyYXkgJiYgdmFsLmJ5dGVMZW5ndGggPT09IHZhbC5idWZmZXIuYnl0ZUxlbmd0aCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdmFsOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIHZhbCA9PT0gInN0cmluZyIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICgwLCBfdXRpbC5zdHJpbmdUb0J5dGVzKSh2YWwpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIHZhbCA9PT0gIm9iamVjdCIgJiYgIWlzTmFOKHZhbCA9PT0gbnVsbCB8fCB2YWwgPT09IHZvaWQgMCA/IHZvaWQgMCA6IHZhbC5sZW5ndGgpIHx8ICgwLCBfdXRpbC5pc0FycmF5QnVmZmVyKSh2YWwpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgVWludDhBcnJheSh2YWwpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoIkludmFsaWQgUERGIGJpbmFyeSBkYXRhOiBlaXRoZXIgVHlwZWRBcnJheSwgIiArICJzdHJpbmcsIG9yIGFycmF5LWxpa2Ugb2JqZWN0IGlzIGV4cGVjdGVkIGluIHRoZSBkYXRhIHByb3BlcnR5LiIpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY2xhc3MgUERGRG9jdW1lbnRMb2FkaW5nVGFzayB7CiAgICAgICAgICAgICAgICAgICAgc3RhdGljICNkb2NJZCA9IDA7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NhcGFiaWxpdHkgPSAoMCwgX3V0aWwuY3JlYXRlUHJvbWlzZUNhcGFiaWxpdHkpKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3RyYW5zcG9ydCA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3dvcmtlciA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZG9jSWQgPSBgZCR7UERGRG9jdW1lbnRMb2FkaW5nVGFzay4jZG9jSWQrK31gOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRlc3Ryb3llZCA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm9uUGFzc3dvcmQgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm9uUHJvZ3Jlc3MgPSBudWxsOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgcHJvbWlzZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX2NhcGFiaWxpdHkucHJvbWlzZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYXN5bmMgZGVzdHJveSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF90aGlzJF90cmFuc3BvcnQ7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGVzdHJveWVkID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgYXdhaXQgKChfdGhpcyRfdHJhbnNwb3J0ID0gdGhpcy5fdHJhbnNwb3J0KSA9PT0gbnVsbCB8fCBfdGhpcyRfdHJhbnNwb3J0ID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRfdHJhbnNwb3J0LmRlc3Ryb3koKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3RyYW5zcG9ydCA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl93b3JrZXIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3dvcmtlci5kZXN0cm95KCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl93b3JrZXIgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5QREZEb2N1bWVudExvYWRpbmdUYXNrID0gUERGRG9jdW1lbnRMb2FkaW5nVGFzazsKICAgICAgICAgICAgICAgIGNsYXNzIFBERkRhdGFSYW5nZVRyYW5zcG9ydCB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IobGVuZ3RoLCBpbml0aWFsRGF0YSkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgcHJvZ3Jlc3NpdmVEb25lID0gYXJndW1lbnRzLmxlbmd0aCA+IDIgJiYgYXJndW1lbnRzWzJdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMl0gOiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGNvbnRlbnREaXNwb3NpdGlvbkZpbGVuYW1lID0gYXJndW1lbnRzLmxlbmd0aCA+IDMgJiYgYXJndW1lbnRzWzNdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbM10gOiBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmxlbmd0aCA9IGxlbmd0aDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5pbml0aWFsRGF0YSA9IGluaXRpYWxEYXRhOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnByb2dyZXNzaXZlRG9uZSA9IHByb2dyZXNzaXZlRG9uZTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb250ZW50RGlzcG9zaXRpb25GaWxlbmFtZSA9IGNvbnRlbnREaXNwb3NpdGlvbkZpbGVuYW1lOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yYW5nZUxpc3RlbmVycyA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wcm9ncmVzc0xpc3RlbmVycyA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wcm9ncmVzc2l2ZVJlYWRMaXN0ZW5lcnMgPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcHJvZ3Jlc3NpdmVEb25lTGlzdGVuZXJzID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlYWR5Q2FwYWJpbGl0eSA9ICgwLCBfdXRpbC5jcmVhdGVQcm9taXNlQ2FwYWJpbGl0eSkoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYWRkUmFuZ2VMaXN0ZW5lcihsaXN0ZW5lcikgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yYW5nZUxpc3RlbmVycy5wdXNoKGxpc3RlbmVyKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYWRkUHJvZ3Jlc3NMaXN0ZW5lcihsaXN0ZW5lcikgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wcm9ncmVzc0xpc3RlbmVycy5wdXNoKGxpc3RlbmVyKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYWRkUHJvZ3Jlc3NpdmVSZWFkTGlzdGVuZXIobGlzdGVuZXIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcHJvZ3Jlc3NpdmVSZWFkTGlzdGVuZXJzLnB1c2gobGlzdGVuZXIpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBhZGRQcm9ncmVzc2l2ZURvbmVMaXN0ZW5lcihsaXN0ZW5lcikgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wcm9ncmVzc2l2ZURvbmVMaXN0ZW5lcnMucHVzaChsaXN0ZW5lcik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIG9uRGF0YVJhbmdlKGJlZ2luLCBjaHVuaykgewogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGxpc3RlbmVyIG9mIHRoaXMuX3JhbmdlTGlzdGVuZXJzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsaXN0ZW5lcihiZWdpbiwgY2h1bmspOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIG9uRGF0YVByb2dyZXNzKGxvYWRlZCwgdG90YWwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVhZHlDYXBhYmlsaXR5LnByb21pc2UudGhlbigoKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGxpc3RlbmVyIG9mIHRoaXMuX3Byb2dyZXNzTGlzdGVuZXJzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGlzdGVuZXIobG9hZGVkLCB0b3RhbCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBvbkRhdGFQcm9ncmVzc2l2ZVJlYWQoY2h1bmspIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVhZHlDYXBhYmlsaXR5LnByb21pc2UudGhlbigoKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGxpc3RlbmVyIG9mIHRoaXMuX3Byb2dyZXNzaXZlUmVhZExpc3RlbmVycykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxpc3RlbmVyKGNodW5rKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIG9uRGF0YVByb2dyZXNzaXZlRG9uZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVhZHlDYXBhYmlsaXR5LnByb21pc2UudGhlbigoKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGxpc3RlbmVyIG9mIHRoaXMuX3Byb2dyZXNzaXZlRG9uZUxpc3RlbmVycykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxpc3RlbmVyKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB0cmFuc3BvcnRSZWFkeSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVhZHlDYXBhYmlsaXR5LnJlc29sdmUoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmVxdWVzdERhdGFSYW5nZShiZWdpbiwgZW5kKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC51bnJlYWNoYWJsZSkoIkFic3RyYWN0IG1ldGhvZCBQREZEYXRhUmFuZ2VUcmFuc3BvcnQucmVxdWVzdERhdGFSYW5nZSIpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBhYm9ydCgpIHt9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLlBERkRhdGFSYW5nZVRyYW5zcG9ydCA9IFBERkRhdGFSYW5nZVRyYW5zcG9ydDsKICAgICAgICAgICAgICAgIGNsYXNzIFBERkRvY3VtZW50UHJveHkgewogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKHBkZkluZm8sIHRyYW5zcG9ydCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wZGZJbmZvID0gcGRmSW5mbzsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fdHJhbnNwb3J0ID0gdHJhbnNwb3J0OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgYW5ub3RhdGlvblN0b3JhZ2UoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl90cmFuc3BvcnQuYW5ub3RhdGlvblN0b3JhZ2U7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBmaWx0ZXJGYWN0b3J5KCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fdHJhbnNwb3J0LmZpbHRlckZhY3Rvcnk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBudW1QYWdlcygpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX3BkZkluZm8ubnVtUGFnZXM7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBmaW5nZXJwcmludHMoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9wZGZJbmZvLmZpbmdlcnByaW50czsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IGlzUHVyZVhmYSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICgwLCBfdXRpbC5zaGFkb3cpKHRoaXMsICJpc1B1cmVYZmEiLCAhIXRoaXMuX3RyYW5zcG9ydC5faHRtbEZvclhmYSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBhbGxYZmFIdG1sKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fdHJhbnNwb3J0Ll9odG1sRm9yWGZhOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRQYWdlKHBhZ2VOdW1iZXIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX3RyYW5zcG9ydC5nZXRQYWdlKHBhZ2VOdW1iZXIpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRQYWdlSW5kZXgocmVmKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl90cmFuc3BvcnQuZ2V0UGFnZUluZGV4KHJlZik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldERlc3RpbmF0aW9ucygpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX3RyYW5zcG9ydC5nZXREZXN0aW5hdGlvbnMoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0RGVzdGluYXRpb24oaWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX3RyYW5zcG9ydC5nZXREZXN0aW5hdGlvbihpZCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldFBhZ2VMYWJlbHMoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl90cmFuc3BvcnQuZ2V0UGFnZUxhYmVscygpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRQYWdlTGF5b3V0KCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fdHJhbnNwb3J0LmdldFBhZ2VMYXlvdXQoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0UGFnZU1vZGUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl90cmFuc3BvcnQuZ2V0UGFnZU1vZGUoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0Vmlld2VyUHJlZmVyZW5jZXMoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl90cmFuc3BvcnQuZ2V0Vmlld2VyUHJlZmVyZW5jZXMoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0T3BlbkFjdGlvbigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX3RyYW5zcG9ydC5nZXRPcGVuQWN0aW9uKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldEF0dGFjaG1lbnRzKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fdHJhbnNwb3J0LmdldEF0dGFjaG1lbnRzKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldEphdmFTY3JpcHQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl90cmFuc3BvcnQuZ2V0SmF2YVNjcmlwdCgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRKU0FjdGlvbnMoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl90cmFuc3BvcnQuZ2V0RG9jSlNBY3Rpb25zKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldE91dGxpbmUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl90cmFuc3BvcnQuZ2V0T3V0bGluZSgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRPcHRpb25hbENvbnRlbnRDb25maWcoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl90cmFuc3BvcnQuZ2V0T3B0aW9uYWxDb250ZW50Q29uZmlnKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldFBlcm1pc3Npb25zKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fdHJhbnNwb3J0LmdldFBlcm1pc3Npb25zKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldE1ldGFkYXRhKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fdHJhbnNwb3J0LmdldE1ldGFkYXRhKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldE1hcmtJbmZvKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fdHJhbnNwb3J0LmdldE1hcmtJbmZvKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldERhdGEoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl90cmFuc3BvcnQuZ2V0RGF0YSgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzYXZlRG9jdW1lbnQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl90cmFuc3BvcnQuc2F2ZURvY3VtZW50KCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldERvd25sb2FkSW5mbygpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX3RyYW5zcG9ydC5kb3dubG9hZEluZm9DYXBhYmlsaXR5LnByb21pc2U7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNsZWFudXAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBrZWVwTG9hZGVkRm9udHMgPSBhcmd1bWVudHMubGVuZ3RoID4gMCAmJiBhcmd1bWVudHNbMF0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1swXSA6IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fdHJhbnNwb3J0LnN0YXJ0Q2xlYW51cChrZWVwTG9hZGVkRm9udHMgfHwgdGhpcy5pc1B1cmVYZmEpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBkZXN0cm95KCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5sb2FkaW5nVGFzay5kZXN0cm95KCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBsb2FkaW5nUGFyYW1zKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fdHJhbnNwb3J0LmxvYWRpbmdQYXJhbXM7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBsb2FkaW5nVGFzaygpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX3RyYW5zcG9ydC5sb2FkaW5nVGFzazsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0RmllbGRPYmplY3RzKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fdHJhbnNwb3J0LmdldEZpZWxkT2JqZWN0cygpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBoYXNKU0FjdGlvbnMoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl90cmFuc3BvcnQuaGFzSlNBY3Rpb25zKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldENhbGN1bGF0aW9uT3JkZXJJZHMoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl90cmFuc3BvcnQuZ2V0Q2FsY3VsYXRpb25PcmRlcklkcygpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGV4cG9ydHMuUERGRG9jdW1lbnRQcm94eSA9IFBERkRvY3VtZW50UHJveHk7CiAgICAgICAgICAgICAgICB2YXIgX2RlbGF5ZWRDbGVhbnVwVGltZW91dCA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9wZW5kaW5nQ2xlYW51cCA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF90cnlDbGVhbnVwID0gLyojX19QVVJFX18qL25ldyBXZWFrU2V0KCk7CiAgICAgICAgICAgICAgICB2YXIgX2Fib3J0RGVsYXllZENsZWFudXAgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIGNsYXNzIFBERlBhZ2VQcm94eSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IocGFnZUluZGV4LCBwYWdlSW5mbywgdHJhbnNwb3J0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBwZGZCdWcgPSBhcmd1bWVudHMubGVuZ3RoID4gMyAmJiBhcmd1bWVudHNbM10gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1szXSA6IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX2Fib3J0RGVsYXllZENsZWFudXApOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX3RyeUNsZWFudXApOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfZGVsYXllZENsZWFudXBUaW1lb3V0LCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBudWxsCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfcGVuZGluZ0NsZWFudXAsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IGZhbHNlCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wYWdlSW5kZXggPSBwYWdlSW5kZXg7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3BhZ2VJbmZvID0gcGFnZUluZm87CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3RyYW5zcG9ydCA9IHRyYW5zcG9ydDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc3RhdHMgPSBwZGZCdWcgPyBuZXcgX2Rpc3BsYXlfdXRpbHMuU3RhdFRpbWVyKCkgOiBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wZGZCdWcgPSBwZGZCdWc7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29tbW9uT2JqcyA9IHRyYW5zcG9ydC5jb21tb25PYmpzOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm9ianMgPSBuZXcgUERGT2JqZWN0cygpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9tYXliZUNsZWFudXBBZnRlclJlbmRlciA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9pbnRlbnRTdGF0ZXMgPSBuZXcgTWFwKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGVzdHJveWVkID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBwYWdlTnVtYmVyKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fcGFnZUluZGV4ICsgMTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IHJvdGF0ZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX3BhZ2VJbmZvLnJvdGF0ZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IHJlZigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX3BhZ2VJbmZvLnJlZjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IHVzZXJVbml0KCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fcGFnZUluZm8udXNlclVuaXQ7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCB2aWV3KCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fcGFnZUluZm8udmlldzsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0Vmlld3BvcnQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzY2FsZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJvdGF0aW9uID0gdGhpcy5yb3RhdGUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvZmZzZXRYID0gMCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9mZnNldFkgPSAwLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgZG9udEZsaXAgPSBmYWxzZQogICAgICAgICAgICAgICAgICAgICAgICB9ID0gYXJndW1lbnRzLmxlbmd0aCA+IDAgJiYgYXJndW1lbnRzWzBdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMF0gOiB7fTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG5ldyBfZGlzcGxheV91dGlscy5QYWdlVmlld3BvcnQoewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmlld0JveDogdGhpcy52aWV3LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgc2NhbGUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICByb3RhdGlvbiwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9mZnNldFgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvZmZzZXRZLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgZG9udEZsaXAKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldEFubm90YXRpb25zKCkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50ZW50ID0gImRpc3BsYXkiCiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBhcmd1bWVudHMubGVuZ3RoID4gMCAmJiBhcmd1bWVudHNbMF0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1swXSA6IHt9OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpbnRlbnRBcmdzID0gdGhpcy5fdHJhbnNwb3J0LmdldFJlbmRlcmluZ0ludGVudChpbnRlbnQpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fdHJhbnNwb3J0LmdldEFubm90YXRpb25zKHRoaXMuX3BhZ2VJbmRleCwgaW50ZW50QXJncy5yZW5kZXJpbmdJbnRlbnQpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRKU0FjdGlvbnMoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl90cmFuc3BvcnQuZ2V0UGFnZUpTQWN0aW9ucyh0aGlzLl9wYWdlSW5kZXgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgaXNQdXJlWGZhKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gKDAsIF91dGlsLnNoYWRvdykodGhpcywgImlzUHVyZVhmYSIsICEhdGhpcy5fdHJhbnNwb3J0Ll9odG1sRm9yWGZhKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYXN5bmMgZ2V0WGZhKCkgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkX3RyYW5zcG9ydCRfaHRtOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gKChfdGhpcyRfdHJhbnNwb3J0JF9odG0gPSB0aGlzLl90cmFuc3BvcnQuX2h0bWxGb3JYZmEpID09PSBudWxsIHx8IF90aGlzJF90cmFuc3BvcnQkX2h0bSA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3RoaXMkX3RyYW5zcG9ydCRfaHRtLmNoaWxkcmVuW3RoaXMuX3BhZ2VJbmRleF0pIHx8IG51bGw7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlbmRlcihfcmVmMikgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkX3N0YXRzOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FudmFzQ29udGV4dCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZpZXdwb3J0LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50ZW50ID0gImRpc3BsYXkiLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgYW5ub3RhdGlvbk1vZGUgPSBfdXRpbC5Bbm5vdGF0aW9uTW9kZS5FTkFCTEUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cmFuc2Zvcm0gPSBudWxsLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FudmFzRmFjdG9yeSA9IG51bGwsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBiYWNrZ3JvdW5kID0gbnVsbCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9wdGlvbmFsQ29udGVudENvbmZpZ1Byb21pc2UgPSBudWxsLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgYW5ub3RhdGlvbkNhbnZhc01hcCA9IG51bGwsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYWdlQ29sb3JzID0gbnVsbCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHByaW50QW5ub3RhdGlvblN0b3JhZ2UgPSBudWxsCiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBfcmVmMjsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGNhbnZhc0ZhY3RvcnkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfZGlzcGxheV91dGlscy5kZXByZWNhdGVkKSgicmVuZGVyIG5vIGxvbmdlciBhY2NlcHRzIHRoZSBgY2FudmFzRmFjdG9yeWAtb3B0aW9uLCAiICsgInBsZWFzZSBwYXNzIGl0IHRvIHRoZSBgZ2V0RG9jdW1lbnRgLWZ1bmN0aW9uIGluc3RlYWQuIik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgKF90aGlzJF9zdGF0cyA9IHRoaXMuX3N0YXRzKSA9PT0gbnVsbCB8fCBfdGhpcyRfc3RhdHMgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF90aGlzJF9zdGF0cy50aW1lKCJPdmVyYWxsIik7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGludGVudEFyZ3MgPSB0aGlzLl90cmFuc3BvcnQuZ2V0UmVuZGVyaW5nSW50ZW50KGludGVudCwgYW5ub3RhdGlvbk1vZGUsIHByaW50QW5ub3RhdGlvblN0b3JhZ2UpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX3BlbmRpbmdDbGVhbnVwLCBmYWxzZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2Fib3J0RGVsYXllZENsZWFudXAsIF9hYm9ydERlbGF5ZWRDbGVhbnVwMikuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFvcHRpb25hbENvbnRlbnRDb25maWdQcm9taXNlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvcHRpb25hbENvbnRlbnRDb25maWdQcm9taXNlID0gdGhpcy5fdHJhbnNwb3J0LmdldE9wdGlvbmFsQ29udGVudENvbmZpZygpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBpbnRlbnRTdGF0ZSA9IHRoaXMuX2ludGVudFN0YXRlcy5nZXQoaW50ZW50QXJncy5jYWNoZUtleSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghaW50ZW50U3RhdGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludGVudFN0YXRlID0gT2JqZWN0LmNyZWF0ZShudWxsKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2ludGVudFN0YXRlcy5zZXQoaW50ZW50QXJncy5jYWNoZUtleSwgaW50ZW50U3RhdGUpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpbnRlbnRTdGF0ZS5zdHJlYW1SZWFkZXJDYW5jZWxUaW1lb3V0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbGVhclRpbWVvdXQoaW50ZW50U3RhdGUuc3RyZWFtUmVhZGVyQ2FuY2VsVGltZW91dCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnRlbnRTdGF0ZS5zdHJlYW1SZWFkZXJDYW5jZWxUaW1lb3V0ID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpbnRlbnRQcmludCA9ICEhKGludGVudEFyZ3MucmVuZGVyaW5nSW50ZW50ICYgX3V0aWwuUmVuZGVyaW5nSW50ZW50RmxhZy5QUklOVCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghaW50ZW50U3RhdGUuZGlzcGxheVJlYWR5Q2FwYWJpbGl0eSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF90aGlzJF9zdGF0czI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnRlbnRTdGF0ZS5kaXNwbGF5UmVhZHlDYXBhYmlsaXR5ID0gKDAsIF91dGlsLmNyZWF0ZVByb21pc2VDYXBhYmlsaXR5KSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50ZW50U3RhdGUub3BlcmF0b3JMaXN0ID0gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZuQXJyYXk6IFtdLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFyZ3NBcnJheTogW10sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGFzdENodW5rOiBmYWxzZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZXBhcmF0ZUFubm90czogbnVsbAogICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIChfdGhpcyRfc3RhdHMyID0gdGhpcy5fc3RhdHMpID09PSBudWxsIHx8IF90aGlzJF9zdGF0czIgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF90aGlzJF9zdGF0czIudGltZSgiUGFnZSBSZXF1ZXN0Iik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wdW1wT3BlcmF0b3JMaXN0KGludGVudEFyZ3MpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNvbXBsZXRlID0gZXJyb3IgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF90aGlzJF9zdGF0czMsIF90aGlzJF9zdGF0czQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnRlbnRTdGF0ZS5yZW5kZXJUYXNrcy5kZWxldGUoaW50ZXJuYWxSZW5kZXJUYXNrKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl9tYXliZUNsZWFudXBBZnRlclJlbmRlciB8fCBpbnRlbnRQcmludCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfcGVuZGluZ0NsZWFudXAsIHRydWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfdHJ5Q2xlYW51cCwgX3RyeUNsZWFudXAyKS5jYWxsKHRoaXMsICFpbnRlbnRQcmludCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZXJyb3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnRlcm5hbFJlbmRlclRhc2suY2FwYWJpbGl0eS5yZWplY3QoZXJyb3IpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Fib3J0T3BlcmF0b3JMaXN0KHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50ZW50U3RhdGUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlYXNvbjogZXJyb3IgaW5zdGFuY2VvZiBFcnJvciA/IGVycm9yIDogbmV3IEVycm9yKGVycm9yKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnRlcm5hbFJlbmRlclRhc2suY2FwYWJpbGl0eS5yZXNvbHZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAoX3RoaXMkX3N0YXRzMyA9IHRoaXMuX3N0YXRzKSA9PT0gbnVsbCB8fCBfdGhpcyRfc3RhdHMzID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRfc3RhdHMzLnRpbWVFbmQoIlJlbmRlcmluZyIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgKF90aGlzJF9zdGF0czQgPSB0aGlzLl9zdGF0cykgPT09IG51bGwgfHwgX3RoaXMkX3N0YXRzNCA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3RoaXMkX3N0YXRzNC50aW1lRW5kKCJPdmVyYWxsIik7CiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGludGVybmFsUmVuZGVyVGFzayA9IG5ldyBJbnRlcm5hbFJlbmRlclRhc2soewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FsbGJhY2s6IGNvbXBsZXRlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFyYW1zOiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FudmFzQ29udGV4dCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2aWV3cG9ydCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cmFuc2Zvcm0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYmFja2dyb3VuZAogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9ianM6IHRoaXMub2JqcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbW1vbk9ianM6IHRoaXMuY29tbW9uT2JqcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFubm90YXRpb25DYW52YXNNYXAsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvcGVyYXRvckxpc3Q6IGludGVudFN0YXRlLm9wZXJhdG9yTGlzdCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2VJbmRleDogdGhpcy5fcGFnZUluZGV4LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FudmFzRmFjdG9yeTogY2FudmFzRmFjdG9yeSB8fCB0aGlzLl90cmFuc3BvcnQuY2FudmFzRmFjdG9yeSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZpbHRlckZhY3Rvcnk6IHRoaXMuX3RyYW5zcG9ydC5maWx0ZXJGYWN0b3J5LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdXNlUmVxdWVzdEFuaW1hdGlvbkZyYW1lOiAhaW50ZW50UHJpbnQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwZGZCdWc6IHRoaXMuX3BkZkJ1ZywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2VDb2xvcnMKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIChpbnRlbnRTdGF0ZS5yZW5kZXJUYXNrcyB8fD0gbmV3IFNldCgpKS5hZGQoaW50ZXJuYWxSZW5kZXJUYXNrKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmVuZGVyVGFzayA9IGludGVybmFsUmVuZGVyVGFzay50YXNrOwogICAgICAgICAgICAgICAgICAgICAgICBQcm9taXNlLmFsbChbaW50ZW50U3RhdGUuZGlzcGxheVJlYWR5Q2FwYWJpbGl0eS5wcm9taXNlLCBvcHRpb25hbENvbnRlbnRDb25maWdQcm9taXNlXSkudGhlbihfcmVmMyA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkX3N0YXRzNTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBbdHJhbnNwYXJlbmN5LCBvcHRpb25hbENvbnRlbnRDb25maWddID0gX3JlZjM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9wZW5kaW5nQ2xlYW51cCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb21wbGV0ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIChfdGhpcyRfc3RhdHM1ID0gdGhpcy5fc3RhdHMpID09PSBudWxsIHx8IF90aGlzJF9zdGF0czUgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF90aGlzJF9zdGF0czUudGltZSgiUmVuZGVyaW5nIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnRlcm5hbFJlbmRlclRhc2suaW5pdGlhbGl6ZUdyYXBoaWNzKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cmFuc3BhcmVuY3ksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgb3B0aW9uYWxDb250ZW50Q29uZmlnCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludGVybmFsUmVuZGVyVGFzay5vcGVyYXRvckxpc3RDaGFuZ2VkKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0pLmNhdGNoKGNvbXBsZXRlKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHJlbmRlclRhc2s7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldE9wZXJhdG9yTGlzdCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludGVudCA9ICJkaXNwbGF5IiwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFubm90YXRpb25Nb2RlID0gX3V0aWwuQW5ub3RhdGlvbk1vZGUuRU5BQkxFLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJpbnRBbm5vdGF0aW9uU3RvcmFnZSA9IG51bGwKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IGFyZ3VtZW50cy5sZW5ndGggPiAwICYmIGFyZ3VtZW50c1swXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzBdIDoge307CiAgICAgICAgICAgICAgICAgICAgICAgIGZ1bmN0aW9uIG9wZXJhdG9yTGlzdENoYW5nZWQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoaW50ZW50U3RhdGUub3BlcmF0b3JMaXN0Lmxhc3RDaHVuaykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludGVudFN0YXRlLm9wTGlzdFJlYWRDYXBhYmlsaXR5LnJlc29sdmUoaW50ZW50U3RhdGUub3BlcmF0b3JMaXN0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnRlbnRTdGF0ZS5yZW5kZXJUYXNrcy5kZWxldGUob3BMaXN0VGFzayk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaW50ZW50QXJncyA9IHRoaXMuX3RyYW5zcG9ydC5nZXRSZW5kZXJpbmdJbnRlbnQoaW50ZW50LCBhbm5vdGF0aW9uTW9kZSwgcHJpbnRBbm5vdGF0aW9uU3RvcmFnZSwgdHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBpbnRlbnRTdGF0ZSA9IHRoaXMuX2ludGVudFN0YXRlcy5nZXQoaW50ZW50QXJncy5jYWNoZUtleSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghaW50ZW50U3RhdGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludGVudFN0YXRlID0gT2JqZWN0LmNyZWF0ZShudWxsKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2ludGVudFN0YXRlcy5zZXQoaW50ZW50QXJncy5jYWNoZUtleSwgaW50ZW50U3RhdGUpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBvcExpc3RUYXNrOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWludGVudFN0YXRlLm9wTGlzdFJlYWRDYXBhYmlsaXR5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkX3N0YXRzNjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9wTGlzdFRhc2sgPSBPYmplY3QuY3JlYXRlKG51bGwpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgb3BMaXN0VGFzay5vcGVyYXRvckxpc3RDaGFuZ2VkID0gb3BlcmF0b3JMaXN0Q2hhbmdlZDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludGVudFN0YXRlLm9wTGlzdFJlYWRDYXBhYmlsaXR5ID0gKDAsIF91dGlsLmNyZWF0ZVByb21pc2VDYXBhYmlsaXR5KSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgKGludGVudFN0YXRlLnJlbmRlclRhc2tzIHx8PSBuZXcgU2V0KCkpLmFkZChvcExpc3RUYXNrKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludGVudFN0YXRlLm9wZXJhdG9yTGlzdCA9IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmbkFycmF5OiBbXSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhcmdzQXJyYXk6IFtdLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxhc3RDaHVuazogZmFsc2UsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VwYXJhdGVBbm5vdHM6IG51bGwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAoX3RoaXMkX3N0YXRzNiA9IHRoaXMuX3N0YXRzKSA9PT0gbnVsbCB8fCBfdGhpcyRfc3RhdHM2ID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRfc3RhdHM2LnRpbWUoIlBhZ2UgUmVxdWVzdCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcHVtcE9wZXJhdG9yTGlzdChpbnRlbnRBcmdzKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gaW50ZW50U3RhdGUub3BMaXN0UmVhZENhcGFiaWxpdHkucHJvbWlzZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RyZWFtVGV4dENvbnRlbnQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkaXNhYmxlQ29tYmluZVRleHRJdGVtcyA9IGZhbHNlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaW5jbHVkZU1hcmtlZENvbnRlbnQgPSBmYWxzZQogICAgICAgICAgICAgICAgICAgICAgICB9ID0gYXJndW1lbnRzLmxlbmd0aCA+IDAgJiYgYXJndW1lbnRzWzBdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMF0gOiB7fTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgVEVYVF9DT05URU5UX0NIVU5LX1NJWkUgPSAxMDA7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl90cmFuc3BvcnQubWVzc2FnZUhhbmRsZXIuc2VuZFdpdGhTdHJlYW0oIkdldFRleHRDb250ZW50IiwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFnZUluZGV4OiB0aGlzLl9wYWdlSW5kZXgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb21iaW5lVGV4dEl0ZW1zOiBkaXNhYmxlQ29tYmluZVRleHRJdGVtcyAhPT0gdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGluY2x1ZGVNYXJrZWRDb250ZW50OiBpbmNsdWRlTWFya2VkQ29udGVudCA9PT0gdHJ1ZQogICAgICAgICAgICAgICAgICAgICAgICB9LCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoaWdoV2F0ZXJNYXJrOiBURVhUX0NPTlRFTlRfQ0hVTktfU0laRSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNpemUodGV4dENvbnRlbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGV4dENvbnRlbnQuaXRlbXMubGVuZ3RoOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0VGV4dENvbnRlbnQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBwYXJhbXMgPSBhcmd1bWVudHMubGVuZ3RoID4gMCAmJiBhcmd1bWVudHNbMF0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1swXSA6IHt9OwogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fdHJhbnNwb3J0Ll9odG1sRm9yWGZhKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5nZXRYZmEoKS50aGVuKHhmYSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF94ZmFfdGV4dC5YZmFUZXh0LnRleHRDb250ZW50KHhmYSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByZWFkYWJsZVN0cmVhbSA9IHRoaXMuc3RyZWFtVGV4dENvbnRlbnQocGFyYW1zKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG5ldyBQcm9taXNlKGZ1bmN0aW9uIChyZXNvbHZlLCByZWplY3QpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZ1bmN0aW9uIHB1bXAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVhZGVyLnJlYWQoKS50aGVuKGZ1bmN0aW9uIChfcmVmNCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkb25lCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBfcmVmNDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGRvbmUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlc29sdmUodGV4dENvbnRlbnQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIE9iamVjdC5hc3NpZ24odGV4dENvbnRlbnQuc3R5bGVzLCB2YWx1ZS5zdHlsZXMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0ZXh0Q29udGVudC5pdGVtcy5wdXNoKC4uLnZhbHVlLml0ZW1zKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcHVtcCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sIHJlamVjdCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByZWFkZXIgPSByZWFkYWJsZVN0cmVhbS5nZXRSZWFkZXIoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHRleHRDb250ZW50ID0gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGl0ZW1zOiBbXSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHlsZXM6IE9iamVjdC5jcmVhdGUobnVsbCkKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwdW1wKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRTdHJ1Y3RUcmVlKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fdHJhbnNwb3J0LmdldFN0cnVjdFRyZWUodGhpcy5fcGFnZUluZGV4KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX2Rlc3Ryb3koKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGVzdHJveWVkID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgd2FpdE9uID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgaW50ZW50U3RhdGUgb2YgdGhpcy5faW50ZW50U3RhdGVzLnZhbHVlcygpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9hYm9ydE9wZXJhdG9yTGlzdCh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50ZW50U3RhdGUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVhc29uOiBuZXcgRXJyb3IoIlBhZ2Ugd2FzIGRlc3Ryb3llZC4iKSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3JjZTogdHJ1ZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoaW50ZW50U3RhdGUub3BMaXN0UmVhZENhcGFiaWxpdHkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgaW50ZXJuYWxSZW5kZXJUYXNrIG9mIGludGVudFN0YXRlLnJlbmRlclRhc2tzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgd2FpdE9uLnB1c2goaW50ZXJuYWxSZW5kZXJUYXNrLmNvbXBsZXRlZCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50ZXJuYWxSZW5kZXJUYXNrLmNhbmNlbCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMub2Jqcy5jbGVhcigpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX3BlbmRpbmdDbGVhbnVwLCBmYWxzZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2Fib3J0RGVsYXllZENsZWFudXAsIF9hYm9ydERlbGF5ZWRDbGVhbnVwMikuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFByb21pc2UuYWxsKHdhaXRPbik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNsZWFudXAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCByZXNldFN0YXRzID0gYXJndW1lbnRzLmxlbmd0aCA+IDAgJiYgYXJndW1lbnRzWzBdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMF0gOiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9wZW5kaW5nQ2xlYW51cCwgdHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN1Y2Nlc3MgPSBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF90cnlDbGVhbnVwLCBfdHJ5Q2xlYW51cDIpLmNhbGwodGhpcywgZmFsc2UpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAocmVzZXRTdGF0cyAmJiBzdWNjZXNzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9zdGF0cyAmJj0gbmV3IF9kaXNwbGF5X3V0aWxzLlN0YXRUaW1lcigpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBzdWNjZXNzOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfc3RhcnRSZW5kZXJQYWdlKHRyYW5zcGFyZW5jeSwgY2FjaGVLZXkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF90aGlzJF9zdGF0czcsIF9pbnRlbnRTdGF0ZSRkaXNwbGF5UjsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaW50ZW50U3RhdGUgPSB0aGlzLl9pbnRlbnRTdGF0ZXMuZ2V0KGNhY2hlS2V5KTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFpbnRlbnRTdGF0ZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIChfdGhpcyRfc3RhdHM3ID0gdGhpcy5fc3RhdHMpID09PSBudWxsIHx8IF90aGlzJF9zdGF0czcgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF90aGlzJF9zdGF0czcudGltZUVuZCgiUGFnZSBSZXF1ZXN0Iik7CiAgICAgICAgICAgICAgICAgICAgICAgIChfaW50ZW50U3RhdGUkZGlzcGxheVIgPSBpbnRlbnRTdGF0ZS5kaXNwbGF5UmVhZHlDYXBhYmlsaXR5KSA9PT0gbnVsbCB8fCBfaW50ZW50U3RhdGUkZGlzcGxheVIgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF9pbnRlbnRTdGF0ZSRkaXNwbGF5Ui5yZXNvbHZlKHRyYW5zcGFyZW5jeSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9yZW5kZXJQYWdlQ2h1bmsob3BlcmF0b3JMaXN0Q2h1bmssIGludGVudFN0YXRlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBpaSA9IG9wZXJhdG9yTGlzdENodW5rLmxlbmd0aDsgaSA8IGlpOyBpKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludGVudFN0YXRlLm9wZXJhdG9yTGlzdC5mbkFycmF5LnB1c2gob3BlcmF0b3JMaXN0Q2h1bmsuZm5BcnJheVtpXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnRlbnRTdGF0ZS5vcGVyYXRvckxpc3QuYXJnc0FycmF5LnB1c2gob3BlcmF0b3JMaXN0Q2h1bmsuYXJnc0FycmF5W2ldKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpbnRlbnRTdGF0ZS5vcGVyYXRvckxpc3QubGFzdENodW5rID0gb3BlcmF0b3JMaXN0Q2h1bmsubGFzdENodW5rOwogICAgICAgICAgICAgICAgICAgICAgICBpbnRlbnRTdGF0ZS5vcGVyYXRvckxpc3Quc2VwYXJhdGVBbm5vdHMgPSBvcGVyYXRvckxpc3RDaHVuay5zZXBhcmF0ZUFubm90czsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBpbnRlcm5hbFJlbmRlclRhc2sgb2YgaW50ZW50U3RhdGUucmVuZGVyVGFza3MpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludGVybmFsUmVuZGVyVGFzay5vcGVyYXRvckxpc3RDaGFuZ2VkKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG9wZXJhdG9yTGlzdENodW5rLmxhc3RDaHVuaykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfdHJ5Q2xlYW51cCwgX3RyeUNsZWFudXAyKS5jYWxsKHRoaXMsIHRydWUpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9wdW1wT3BlcmF0b3JMaXN0KF9yZWY1KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZW5kZXJpbmdJbnRlbnQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYWNoZUtleSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFubm90YXRpb25TdG9yYWdlTWFwCiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBfcmVmNTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmVhZGFibGVTdHJlYW0gPSB0aGlzLl90cmFuc3BvcnQubWVzc2FnZUhhbmRsZXIuc2VuZFdpdGhTdHJlYW0oIkdldE9wZXJhdG9yTGlzdCIsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2VJbmRleDogdGhpcy5fcGFnZUluZGV4LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50ZW50OiByZW5kZXJpbmdJbnRlbnQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYWNoZUtleSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFubm90YXRpb25TdG9yYWdlOiBhbm5vdGF0aW9uU3RvcmFnZU1hcAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmVhZGVyID0gcmVhZGFibGVTdHJlYW0uZ2V0UmVhZGVyKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGludGVudFN0YXRlID0gdGhpcy5faW50ZW50U3RhdGVzLmdldChjYWNoZUtleSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGludGVudFN0YXRlLnN0cmVhbVJlYWRlciA9IHJlYWRlcjsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcHVtcCA9ICgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlYWRlci5yZWFkKCkudGhlbihfcmVmNiA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRvbmUKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9ID0gX3JlZjY7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGRvbmUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50ZW50U3RhdGUuc3RyZWFtUmVhZGVyID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fdHJhbnNwb3J0LmRlc3Ryb3llZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlbmRlclBhZ2VDaHVuayh2YWx1ZSwgaW50ZW50U3RhdGUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHB1bXAoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sIHJlYXNvbiA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50ZW50U3RhdGUuc3RyZWFtUmVhZGVyID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fdHJhbnNwb3J0LmRlc3Ryb3llZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpbnRlbnRTdGF0ZS5vcGVyYXRvckxpc3QpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50ZW50U3RhdGUub3BlcmF0b3JMaXN0Lmxhc3RDaHVuayA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgaW50ZXJuYWxSZW5kZXJUYXNrIG9mIGludGVudFN0YXRlLnJlbmRlclRhc2tzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnRlcm5hbFJlbmRlclRhc2sub3BlcmF0b3JMaXN0Q2hhbmdlZCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3RyeUNsZWFudXAsIF90cnlDbGVhbnVwMikuY2FsbCh0aGlzLCB0cnVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGludGVudFN0YXRlLmRpc3BsYXlSZWFkeUNhcGFiaWxpdHkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50ZW50U3RhdGUuZGlzcGxheVJlYWR5Q2FwYWJpbGl0eS5yZWplY3QocmVhc29uKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGludGVudFN0YXRlLm9wTGlzdFJlYWRDYXBhYmlsaXR5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludGVudFN0YXRlLm9wTGlzdFJlYWRDYXBhYmlsaXR5LnJlamVjdChyZWFzb24pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IHJlYXNvbjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgcHVtcCgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfYWJvcnRPcGVyYXRvckxpc3QoX3JlZjcpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludGVudFN0YXRlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVhc29uLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yY2UgPSBmYWxzZQogICAgICAgICAgICAgICAgICAgICAgICB9ID0gX3JlZjc7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghaW50ZW50U3RhdGUuc3RyZWFtUmVhZGVyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGludGVudFN0YXRlLnN0cmVhbVJlYWRlckNhbmNlbFRpbWVvdXQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsZWFyVGltZW91dChpbnRlbnRTdGF0ZS5zdHJlYW1SZWFkZXJDYW5jZWxUaW1lb3V0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludGVudFN0YXRlLnN0cmVhbVJlYWRlckNhbmNlbFRpbWVvdXQgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghZm9yY2UpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpbnRlbnRTdGF0ZS5yZW5kZXJUYXNrcy5zaXplID4gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChyZWFzb24gaW5zdGFuY2VvZiBfZGlzcGxheV91dGlscy5SZW5kZXJpbmdDYW5jZWxsZWRFeGNlcHRpb24pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgZGVsYXkgPSBSRU5ERVJJTkdfQ0FOQ0VMTEVEX1RJTUVPVVQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHJlYXNvbi5leHRyYURlbGF5ID4gMCAmJiByZWFzb24uZXh0cmFEZWxheSA8IDEwMDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVsYXkgKz0gcmVhc29uLmV4dHJhRGVsYXk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludGVudFN0YXRlLnN0cmVhbVJlYWRlckNhbmNlbFRpbWVvdXQgPSBzZXRUaW1lb3V0KCgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50ZW50U3RhdGUuc3RyZWFtUmVhZGVyQ2FuY2VsVGltZW91dCA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Fib3J0T3BlcmF0b3JMaXN0KHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludGVudFN0YXRlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVhc29uLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yY2U6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSwgZGVsYXkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpbnRlbnRTdGF0ZS5zdHJlYW1SZWFkZXIuY2FuY2VsKG5ldyBfdXRpbC5BYm9ydEV4Y2VwdGlvbihyZWFzb24ubWVzc2FnZSkpLmNhdGNoKCgpID0+IHt9KTsKICAgICAgICAgICAgICAgICAgICAgICAgaW50ZW50U3RhdGUuc3RyZWFtUmVhZGVyID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuX3RyYW5zcG9ydC5kZXN0cm95ZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IFtjdXJDYWNoZUtleSwgY3VySW50ZW50U3RhdGVdIG9mIHRoaXMuX2ludGVudFN0YXRlcykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGN1ckludGVudFN0YXRlID09PSBpbnRlbnRTdGF0ZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2ludGVudFN0YXRlcy5kZWxldGUoY3VyQ2FjaGVLZXkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2xlYW51cCgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgc3RhdHMoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9zdGF0czsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLlBERlBhZ2VQcm94eSA9IFBERlBhZ2VQcm94eTsKICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF90cnlDbGVhbnVwMigpIHsKICAgICAgICAgICAgICAgICAgICBsZXQgZGVsYXllZCA9IGFyZ3VtZW50cy5sZW5ndGggPiAwICYmIGFyZ3VtZW50c1swXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzBdIDogZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfYWJvcnREZWxheWVkQ2xlYW51cCwgX2Fib3J0RGVsYXllZENsZWFudXAyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgIGlmICghX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9wZW5kaW5nQ2xlYW51cCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBpZiAoZGVsYXllZCkgewogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX2RlbGF5ZWRDbGVhbnVwVGltZW91dCwgc2V0VGltZW91dCgoKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX2RlbGF5ZWRDbGVhbnVwVGltZW91dCwgbnVsbCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF90cnlDbGVhbnVwLCBfdHJ5Q2xlYW51cDIpLmNhbGwodGhpcywgZmFsc2UpOwogICAgICAgICAgICAgICAgICAgICAgICB9LCBERUxBWUVEX0NMRUFOVVBfVElNRU9VVCkpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICByZW5kZXJUYXNrcywKICAgICAgICAgICAgICAgICAgICAgICAgb3BlcmF0b3JMaXN0CiAgICAgICAgICAgICAgICAgICAgfSBvZiB0aGlzLl9pbnRlbnRTdGF0ZXMudmFsdWVzKCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHJlbmRlclRhc2tzLnNpemUgPiAwIHx8ICFvcGVyYXRvckxpc3QubGFzdENodW5rKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdGhpcy5faW50ZW50U3RhdGVzLmNsZWFyKCk7CiAgICAgICAgICAgICAgICAgICAgdGhpcy5vYmpzLmNsZWFyKCk7CiAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9wZW5kaW5nQ2xlYW51cCwgZmFsc2UpOwogICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX2Fib3J0RGVsYXllZENsZWFudXAyKCkgewogICAgICAgICAgICAgICAgICAgIGlmIChfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2RlbGF5ZWRDbGVhbnVwVGltZW91dCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY2xlYXJUaW1lb3V0KF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZGVsYXllZENsZWFudXBUaW1lb3V0KSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfZGVsYXllZENsZWFudXBUaW1lb3V0LCBudWxsKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBMb29wYmFja1BvcnQgewogICAgICAgICAgICAgICAgICAgICNsaXN0ZW5lcnMgPSBuZXcgU2V0KCk7CiAgICAgICAgICAgICAgICAgICAgI2RlZmVycmVkID0gUHJvbWlzZS5yZXNvbHZlKCk7CiAgICAgICAgICAgICAgICAgICAgcG9zdE1lc3NhZ2Uob2JqLCB0cmFuc2ZlcikgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBldmVudCA9IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRhdGE6IHN0cnVjdHVyZWRDbG9uZShvYmosIHRyYW5zZmVyID8gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRyYW5zZmVyCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IDogbnVsbCkKICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy4jZGVmZXJyZWQudGhlbigoKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGxpc3RlbmVyIG9mIHRoaXMuI2xpc3RlbmVycykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxpc3RlbmVyLmNhbGwodGhpcywgZXZlbnQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYWRkRXZlbnRMaXN0ZW5lcihuYW1lLCBsaXN0ZW5lcikgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLiNsaXN0ZW5lcnMuYWRkKGxpc3RlbmVyKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmVtb3ZlRXZlbnRMaXN0ZW5lcihuYW1lLCBsaXN0ZW5lcikgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLiNsaXN0ZW5lcnMuZGVsZXRlKGxpc3RlbmVyKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdGVybWluYXRlKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLiNsaXN0ZW5lcnMuY2xlYXIoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLkxvb3BiYWNrUG9ydCA9IExvb3BiYWNrUG9ydDsKICAgICAgICAgICAgICAgIGNvbnN0IFBERldvcmtlclV0aWwgPSB7CiAgICAgICAgICAgICAgICAgICAgaXNXb3JrZXJEaXNhYmxlZDogZmFsc2UsCiAgICAgICAgICAgICAgICAgICAgZmFsbGJhY2tXb3JrZXJTcmM6IG51bGwsCiAgICAgICAgICAgICAgICAgICAgZmFrZVdvcmtlcklkOiAwCiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgZXhwb3J0cy5QREZXb3JrZXJVdGlsID0gUERGV29ya2VyVXRpbDsKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICBpZiAoX2lzX25vZGUuaXNOb2RlSlMgJiYgdHlwZW9mIHJlcXVpcmUgPT09ICJmdW5jdGlvbiIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgUERGV29ya2VyVXRpbC5pc1dvcmtlckRpc2FibGVkID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgUERGV29ya2VyVXRpbC5mYWxsYmFja1dvcmtlclNyYyA9ICIuL3BkZi53b3JrZXIuanMiOwogICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAodHlwZW9mIGRvY3VtZW50ID09PSAib2JqZWN0IikgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX2RvY3VtZW50LCBfZG9jdW1lbnQkY3VycmVudFNjcmk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHBkZmpzRmlsZVBhdGggPSAoX2RvY3VtZW50ID0gZG9jdW1lbnQpID09PSBudWxsIHx8IF9kb2N1bWVudCA9PT0gdm9pZCAwID8gdm9pZCAwIDogKF9kb2N1bWVudCRjdXJyZW50U2NyaSA9IF9kb2N1bWVudC5jdXJyZW50U2NyaXB0KSA9PT0gbnVsbCB8fCBfZG9jdW1lbnQkY3VycmVudFNjcmkgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF9kb2N1bWVudCRjdXJyZW50U2NyaS5zcmM7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChwZGZqc0ZpbGVQYXRoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBQREZXb3JrZXJVdGlsLmZhbGxiYWNrV29ya2VyU3JjID0gcGRmanNGaWxlUGF0aC5yZXBsYWNlKC8oXC4oPzptaW5cLik/anMpKFw/LiopPyQvaSwgIi53b3JrZXIkMSQyIik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgUERGV29ya2VyVXRpbC5pc1NhbWVPcmlnaW4gPSBmdW5jdGlvbiAoYmFzZVVybCwgb3RoZXJVcmwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGJhc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBiYXNlID0gbmV3IFVSTChiYXNlVXJsKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghYmFzZS5vcmlnaW4gfHwgYmFzZS5vcmlnaW4gPT09ICJudWxsIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG90aGVyID0gbmV3IFVSTChvdGhlclVybCwgYmFzZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBiYXNlLm9yaWdpbiA9PT0gb3RoZXIub3JpZ2luOwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgUERGV29ya2VyVXRpbC5jcmVhdGVDRE5XcmFwcGVyID0gZnVuY3Rpb24gKHVybCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB3cmFwcGVyID0gYGltcG9ydFNjcmlwdHMoIiR7dXJsfSIpO2A7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBVUkwuY3JlYXRlT2JqZWN0VVJMKG5ldyBCbG9iKFt3cmFwcGVyXSkpOwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBQREZXb3JrZXIgewogICAgICAgICAgICAgICAgICAgIHN0YXRpYyAjd29ya2VyUG9ydHMgPSBuZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKCkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgbmFtZSA9IG51bGwsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwb3J0ID0gbnVsbCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZlcmJvc2l0eSA9ICgwLCBfdXRpbC5nZXRWZXJib3NpdHlMZXZlbCkoKQogICAgICAgICAgICAgICAgICAgICAgICB9ID0gYXJndW1lbnRzLmxlbmd0aCA+IDAgJiYgYXJndW1lbnRzWzBdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMF0gOiB7fTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHBvcnQgJiYgUERGV29ya2VyLiN3b3JrZXJQb3J0cy5oYXMocG9ydCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcigiQ2Fubm90IHVzZSBtb3JlIHRoYW4gb25lIFBERldvcmtlciBwZXIgcG9ydC4iKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm5hbWUgPSBuYW1lOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRlc3Ryb3llZCA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnZlcmJvc2l0eSA9IHZlcmJvc2l0eTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVhZHlDYXBhYmlsaXR5ID0gKDAsIF91dGlsLmNyZWF0ZVByb21pc2VDYXBhYmlsaXR5KSgpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wb3J0ID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fd2ViV29ya2VyID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fbWVzc2FnZUhhbmRsZXIgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAocG9ydCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgUERGV29ya2VyLiN3b3JrZXJQb3J0cy5zZXQocG9ydCwgdGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9pbml0aWFsaXplRnJvbVBvcnQocG9ydCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5faW5pdGlhbGl6ZSgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgcHJvbWlzZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX3JlYWR5Q2FwYWJpbGl0eS5wcm9taXNlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgcG9ydCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX3BvcnQ7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBtZXNzYWdlSGFuZGxlcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX21lc3NhZ2VIYW5kbGVyOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfaW5pdGlhbGl6ZUZyb21Qb3J0KHBvcnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcG9ydCA9IHBvcnQ7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX21lc3NhZ2VIYW5kbGVyID0gbmV3IF9tZXNzYWdlX2hhbmRsZXIuTWVzc2FnZUhhbmRsZXIoIm1haW4iLCAid29ya2VyIiwgcG9ydCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX21lc3NhZ2VIYW5kbGVyLm9uKCJyZWFkeSIsIGZ1bmN0aW9uICgpIHt9KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVhZHlDYXBhYmlsaXR5LnJlc29sdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fbWVzc2FnZUhhbmRsZXIuc2VuZCgiY29uZmlndXJlIiwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmVyYm9zaXR5OiB0aGlzLnZlcmJvc2l0eQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX2luaXRpYWxpemUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghUERGV29ya2VyVXRpbC5pc1dvcmtlckRpc2FibGVkICYmICFQREZXb3JrZXIuX21haW5UaHJlYWRXb3JrZXJNZXNzYWdlSGFuZGxlcikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB3b3JrZXJTcmMKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBQREZXb3JrZXI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghUERGV29ya2VyVXRpbC5pc1NhbWVPcmlnaW4od2luZG93LmxvY2F0aW9uLmhyZWYsIHdvcmtlclNyYykpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgd29ya2VyU3JjID0gUERGV29ya2VyVXRpbC5jcmVhdGVDRE5XcmFwcGVyKG5ldyBVUkwod29ya2VyU3JjLCB3aW5kb3cubG9jYXRpb24pLmhyZWYpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB3b3JrZXIgPSBuZXcgV29ya2VyKHdvcmtlclNyYyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbWVzc2FnZUhhbmRsZXIgPSBuZXcgX21lc3NhZ2VfaGFuZGxlci5NZXNzYWdlSGFuZGxlcigibWFpbiIsICJ3b3JrZXIiLCB3b3JrZXIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHRlcm1pbmF0ZUVhcmx5ID0gKCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB3b3JrZXIucmVtb3ZlRXZlbnRMaXN0ZW5lcigiZXJyb3IiLCBvbldvcmtlckVycm9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbWVzc2FnZUhhbmRsZXIuZGVzdHJveSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB3b3JrZXIudGVybWluYXRlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmRlc3Ryb3llZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVhZHlDYXBhYmlsaXR5LnJlamVjdChuZXcgRXJyb3IoIldvcmtlciB3YXMgZGVzdHJveWVkIikpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc2V0dXBGYWtlV29ya2VyKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG9uV29ya2VyRXJyb3IgPSAoKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5fd2ViV29ya2VyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0ZXJtaW5hdGVFYXJseSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB3b3JrZXIuYWRkRXZlbnRMaXN0ZW5lcigiZXJyb3IiLCBvbldvcmtlckVycm9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtZXNzYWdlSGFuZGxlci5vbigidGVzdCIsIGRhdGEgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB3b3JrZXIucmVtb3ZlRXZlbnRMaXN0ZW5lcigiZXJyb3IiLCBvbldvcmtlckVycm9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuZGVzdHJveWVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0ZXJtaW5hdGVFYXJseSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChkYXRhKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9tZXNzYWdlSGFuZGxlciA9IG1lc3NhZ2VIYW5kbGVyOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcG9ydCA9IHdvcmtlcjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3dlYldvcmtlciA9IHdvcmtlcjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlYWR5Q2FwYWJpbGl0eS5yZXNvbHZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtZXNzYWdlSGFuZGxlci5zZW5kKCJjb25maWd1cmUiLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmVyYm9zaXR5OiB0aGlzLnZlcmJvc2l0eQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9zZXR1cEZha2VXb3JrZXIoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1lc3NhZ2VIYW5kbGVyLmRlc3Ryb3koKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdvcmtlci50ZXJtaW5hdGUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1lc3NhZ2VIYW5kbGVyLm9uKCJyZWFkeSIsIGRhdGEgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB3b3JrZXIucmVtb3ZlRXZlbnRMaXN0ZW5lcigiZXJyb3IiLCBvbldvcmtlckVycm9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuZGVzdHJveWVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0ZXJtaW5hdGVFYXJseSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZW5kVGVzdCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIChlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9zZXR1cEZha2VXb3JrZXIoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHNlbmRUZXN0ID0gKCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB0ZXN0T2JqID0gbmV3IFVpbnQ4QXJyYXkoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbWVzc2FnZUhhbmRsZXIuc2VuZCgidGVzdCIsIHRlc3RPYmosIFt0ZXN0T2JqLmJ1ZmZlcl0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VuZFRlc3QoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIChlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLmluZm8pKCJUaGUgd29ya2VyIGhhcyBiZWVuIGRpc2FibGVkLiIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3NldHVwRmFrZVdvcmtlcigpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfc2V0dXBGYWtlV29ya2VyKCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIVBERldvcmtlclV0aWwuaXNXb3JrZXJEaXNhYmxlZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKCJTZXR0aW5nIHVwIGZha2Ugd29ya2VyLiIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgUERGV29ya2VyVXRpbC5pc1dvcmtlckRpc2FibGVkID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBQREZXb3JrZXIuX3NldHVwRmFrZVdvcmtlckdsb2JhbC50aGVuKFdvcmtlck1lc3NhZ2VIYW5kbGVyID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmRlc3Ryb3llZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlYWR5Q2FwYWJpbGl0eS5yZWplY3QobmV3IEVycm9yKCJXb3JrZXIgd2FzIGRlc3Ryb3llZCIpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwb3J0ID0gbmV3IExvb3BiYWNrUG9ydCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcG9ydCA9IHBvcnQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpZCA9IGBmYWtlJHtQREZXb3JrZXJVdGlsLmZha2VXb3JrZXJJZCsrfWA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB3b3JrZXJIYW5kbGVyID0gbmV3IF9tZXNzYWdlX2hhbmRsZXIuTWVzc2FnZUhhbmRsZXIoaWQgKyAiX3dvcmtlciIsIGlkLCBwb3J0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIFdvcmtlck1lc3NhZ2VIYW5kbGVyLnNldHVwKHdvcmtlckhhbmRsZXIsIHBvcnQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbWVzc2FnZUhhbmRsZXIgPSBuZXcgX21lc3NhZ2VfaGFuZGxlci5NZXNzYWdlSGFuZGxlcihpZCwgaWQgKyAiX3dvcmtlciIsIHBvcnQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fbWVzc2FnZUhhbmRsZXIgPSBtZXNzYWdlSGFuZGxlcjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlYWR5Q2FwYWJpbGl0eS5yZXNvbHZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtZXNzYWdlSGFuZGxlci5zZW5kKCJjb25maWd1cmUiLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmVyYm9zaXR5OiB0aGlzLnZlcmJvc2l0eQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0pLmNhdGNoKHJlYXNvbiA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yZWFkeUNhcGFiaWxpdHkucmVqZWN0KG5ldyBFcnJvcihgU2V0dGluZyB1cCBmYWtlIHdvcmtlciBmYWlsZWQ6ICIke3JlYXNvbi5tZXNzYWdlfSIuYCkpOwogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZGVzdHJveSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kZXN0cm95ZWQgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fd2ViV29ya2VyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl93ZWJXb3JrZXIudGVybWluYXRlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl93ZWJXb3JrZXIgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIFBERldvcmtlci4jd29ya2VyUG9ydHMuZGVsZXRlKHRoaXMuX3BvcnQpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wb3J0ID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuX21lc3NhZ2VIYW5kbGVyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9tZXNzYWdlSGFuZGxlci5kZXN0cm95KCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9tZXNzYWdlSGFuZGxlciA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIGZyb21Qb3J0KHBhcmFtcykgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIShwYXJhbXMgIT09IG51bGwgJiYgcGFyYW1zICE9PSB2b2lkIDAgJiYgcGFyYW1zLnBvcnQpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoIlBERldvcmtlci5mcm9tUG9ydCAtIGludmFsaWQgbWV0aG9kIHNpZ25hdHVyZS4iKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy4jd29ya2VyUG9ydHMuaGFzKHBhcmFtcy5wb3J0KSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuI3dvcmtlclBvcnRzLmdldChwYXJhbXMucG9ydCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG5ldyBQREZXb3JrZXIocGFyYW1zKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIGdldCB3b3JrZXJTcmMoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChfd29ya2VyX29wdGlvbnMuR2xvYmFsV29ya2VyT3B0aW9ucy53b3JrZXJTcmMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBfd29ya2VyX29wdGlvbnMuR2xvYmFsV29ya2VyT3B0aW9ucy53b3JrZXJTcmM7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKFBERldvcmtlclV0aWwuZmFsbGJhY2tXb3JrZXJTcmMgIT09IG51bGwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghX2lzX25vZGUuaXNOb2RlSlMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX2Rpc3BsYXlfdXRpbHMuZGVwcmVjYXRlZCkoJ05vICJHbG9iYWxXb3JrZXJPcHRpb25zLndvcmtlclNyYyIgc3BlY2lmaWVkLicpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFBERldvcmtlclV0aWwuZmFsbGJhY2tXb3JrZXJTcmM7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCdObyAiR2xvYmFsV29ya2VyT3B0aW9ucy53b3JrZXJTcmMiIHNwZWNpZmllZC4nKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIGdldCBfbWFpblRocmVhZFdvcmtlck1lc3NhZ2VIYW5kbGVyKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF9nbG9iYWxUaGlzJHBkZmpzV29yazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAoKF9nbG9iYWxUaGlzJHBkZmpzV29yayA9IGdsb2JhbFRoaXMucGRmanNXb3JrZXIpID09PSBudWxsIHx8IF9nbG9iYWxUaGlzJHBkZmpzV29yayA9PT0gdm9pZCAwID8gdm9pZCAwIDogX2dsb2JhbFRoaXMkcGRmanNXb3JrLldvcmtlck1lc3NhZ2VIYW5kbGVyKSB8fCBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIChleCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIGdldCBfc2V0dXBGYWtlV29ya2VyR2xvYmFsKCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBsb2FkZXIgPSBhc3luYyAoKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBtYWluV29ya2VyTWVzc2FnZUhhbmRsZXIgPSB0aGlzLl9tYWluVGhyZWFkV29ya2VyTWVzc2FnZUhhbmRsZXI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAobWFpbldvcmtlck1lc3NhZ2VIYW5kbGVyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG1haW5Xb3JrZXJNZXNzYWdlSGFuZGxlcjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChfaXNfbm9kZS5pc05vZGVKUyAmJiB0eXBlb2YgcmVxdWlyZSA9PT0gImZ1bmN0aW9uIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHdvcmtlciA9IGV2YWwoInJlcXVpcmUiKSh0aGlzLndvcmtlclNyYyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHdvcmtlci5Xb3JrZXJNZXNzYWdlSGFuZGxlcjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGF3YWl0ICgwLCBfZGlzcGxheV91dGlscy5sb2FkU2NyaXB0KSh0aGlzLndvcmtlclNyYyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gd2luZG93LnBkZmpzV29ya2VyLldvcmtlck1lc3NhZ2VIYW5kbGVyOwogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gKDAsIF91dGlsLnNoYWRvdykodGhpcywgIl9zZXR1cEZha2VXb3JrZXJHbG9iYWwiLCBsb2FkZXIoKSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5QREZXb3JrZXIgPSBQREZXb3JrZXI7CiAgICAgICAgICAgICAgICB2YXIgX21ldGhvZFByb21pc2VzID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX3BhZ2VDYWNoZSA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9wYWdlUHJvbWlzZXMgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfY2FjaGVTaW1wbGVNZXRob2QgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIGNsYXNzIFdvcmtlclRyYW5zcG9ydCB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IobWVzc2FnZUhhbmRsZXIsIGxvYWRpbmdUYXNrLCBuZXR3b3JrU3RyZWFtLCBwYXJhbXMsIGZhY3RvcnkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEluaXRTcGVjKHRoaXMsIF9jYWNoZVNpbXBsZU1ldGhvZCk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9tZXRob2RQcm9taXNlcywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogbmV3IE1hcCgpCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfcGFnZUNhY2hlLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBuZXcgTWFwKCkKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9wYWdlUHJvbWlzZXMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IG5ldyBNYXAoKQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5tZXNzYWdlSGFuZGxlciA9IG1lc3NhZ2VIYW5kbGVyOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmxvYWRpbmdUYXNrID0gbG9hZGluZ1Rhc2s7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29tbW9uT2JqcyA9IG5ldyBQREZPYmplY3RzKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZm9udExvYWRlciA9IG5ldyBfZm9udF9sb2FkZXIuRm9udExvYWRlcih7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvd25lckRvY3VtZW50OiBwYXJhbXMub3duZXJEb2N1bWVudCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0eWxlRWxlbWVudDogcGFyYW1zLnN0eWxlRWxlbWVudAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcGFyYW1zID0gcGFyYW1zOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbnZhc0ZhY3RvcnkgPSBmYWN0b3J5LmNhbnZhc0ZhY3Rvcnk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZmlsdGVyRmFjdG9yeSA9IGZhY3RvcnkuZmlsdGVyRmFjdG9yeTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jTWFwUmVhZGVyRmFjdG9yeSA9IGZhY3RvcnkuY01hcFJlYWRlckZhY3Rvcnk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc3RhbmRhcmRGb250RGF0YUZhY3RvcnkgPSBmYWN0b3J5LnN0YW5kYXJkRm9udERhdGFGYWN0b3J5OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRlc3Ryb3llZCA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRlc3Ryb3lDYXBhYmlsaXR5ID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcGFzc3dvcmRDYXBhYmlsaXR5ID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fbmV0d29ya1N0cmVhbSA9IG5ldHdvcmtTdHJlYW07CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Z1bGxSZWFkZXIgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9sYXN0UHJvZ3Jlc3MgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRvd25sb2FkSW5mb0NhcGFiaWxpdHkgPSAoMCwgX3V0aWwuY3JlYXRlUHJvbWlzZUNhcGFiaWxpdHkpKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0dXBNZXNzYWdlSGFuZGxlcigpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgYW5ub3RhdGlvblN0b3JhZ2UoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAoMCwgX3V0aWwuc2hhZG93KSh0aGlzLCAiYW5ub3RhdGlvblN0b3JhZ2UiLCBuZXcgX2Fubm90YXRpb25fc3RvcmFnZS5Bbm5vdGF0aW9uU3RvcmFnZSgpKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0UmVuZGVyaW5nSW50ZW50KGludGVudCkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgYW5ub3RhdGlvbk1vZGUgPSBhcmd1bWVudHMubGVuZ3RoID4gMSAmJiBhcmd1bWVudHNbMV0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1sxXSA6IF91dGlsLkFubm90YXRpb25Nb2RlLkVOQUJMRTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHByaW50QW5ub3RhdGlvblN0b3JhZ2UgPSBhcmd1bWVudHMubGVuZ3RoID4gMiAmJiBhcmd1bWVudHNbMl0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1syXSA6IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBpc09wTGlzdCA9IGFyZ3VtZW50cy5sZW5ndGggPiAzICYmIGFyZ3VtZW50c1szXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzNdIDogZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCByZW5kZXJpbmdJbnRlbnQgPSBfdXRpbC5SZW5kZXJpbmdJbnRlbnRGbGFnLkRJU1BMQVk7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBhbm5vdGF0aW9uTWFwID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgc3dpdGNoIChpbnRlbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgImFueSI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVuZGVyaW5nSW50ZW50ID0gX3V0aWwuUmVuZGVyaW5nSW50ZW50RmxhZy5BTlk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJkaXNwbGF5IjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgInByaW50IjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZW5kZXJpbmdJbnRlbnQgPSBfdXRpbC5SZW5kZXJpbmdJbnRlbnRGbGFnLlBSSU5UOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYGdldFJlbmRlcmluZ0ludGVudCAtIGludmFsaWQgaW50ZW50OiAke2ludGVudH1gKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBzd2l0Y2ggKGFubm90YXRpb25Nb2RlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLkFubm90YXRpb25Nb2RlLkRJU0FCTEU6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVuZGVyaW5nSW50ZW50ICs9IF91dGlsLlJlbmRlcmluZ0ludGVudEZsYWcuQU5OT1RBVElPTlNfRElTQUJMRTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuQW5ub3RhdGlvbk1vZGUuRU5BQkxFOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uTW9kZS5FTkFCTEVfRk9STVM6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVuZGVyaW5nSW50ZW50ICs9IF91dGlsLlJlbmRlcmluZ0ludGVudEZsYWcuQU5OT1RBVElPTlNfRk9STVM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLkFubm90YXRpb25Nb2RlLkVOQUJMRV9TVE9SQUdFOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlbmRlcmluZ0ludGVudCArPSBfdXRpbC5SZW5kZXJpbmdJbnRlbnRGbGFnLkFOTk9UQVRJT05TX1NUT1JBR0U7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYW5ub3RhdGlvblN0b3JhZ2UgPSByZW5kZXJpbmdJbnRlbnQgJiBfdXRpbC5SZW5kZXJpbmdJbnRlbnRGbGFnLlBSSU5UICYmIHByaW50QW5ub3RhdGlvblN0b3JhZ2UgaW5zdGFuY2VvZiBfYW5ub3RhdGlvbl9zdG9yYWdlLlByaW50QW5ub3RhdGlvblN0b3JhZ2UgPyBwcmludEFubm90YXRpb25TdG9yYWdlIDogdGhpcy5hbm5vdGF0aW9uU3RvcmFnZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhbm5vdGF0aW9uTWFwID0gYW5ub3RhdGlvblN0b3JhZ2Uuc2VyaWFsaXphYmxlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYGdldFJlbmRlcmluZ0ludGVudCAtIGludmFsaWQgYW5ub3RhdGlvbk1vZGU6ICR7YW5ub3RhdGlvbk1vZGV9YCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGlzT3BMaXN0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZW5kZXJpbmdJbnRlbnQgKz0gX3V0aWwuUmVuZGVyaW5nSW50ZW50RmxhZy5PUExJU1Q7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlbmRlcmluZ0ludGVudCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhY2hlS2V5OiBgJHtyZW5kZXJpbmdJbnRlbnR9XyR7X2Fubm90YXRpb25fc3RvcmFnZS5Bbm5vdGF0aW9uU3RvcmFnZS5nZXRIYXNoKGFubm90YXRpb25NYXApfWAsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhbm5vdGF0aW9uU3RvcmFnZU1hcDogYW5ub3RhdGlvbk1hcAogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBkZXN0cm95KCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5kZXN0cm95Q2FwYWJpbGl0eSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuZGVzdHJveUNhcGFiaWxpdHkucHJvbWlzZTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRlc3Ryb3llZCA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGVzdHJveUNhcGFiaWxpdHkgPSAoMCwgX3V0aWwuY3JlYXRlUHJvbWlzZUNhcGFiaWxpdHkpKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl9wYXNzd29yZENhcGFiaWxpdHkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3Bhc3N3b3JkQ2FwYWJpbGl0eS5yZWplY3QobmV3IEVycm9yKCJXb3JrZXIgd2FzIGRlc3Ryb3llZCBkdXJpbmcgb25QYXNzd29yZCBjYWxsYmFjayIpKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB3YWl0T24gPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBwYWdlIG9mIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfcGFnZUNhY2hlKS52YWx1ZXMoKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd2FpdE9uLnB1c2gocGFnZS5fZGVzdHJveSgpKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX3BhZ2VDYWNoZSkuY2xlYXIoKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9wYWdlUHJvbWlzZXMpLmNsZWFyKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmhhc093blByb3BlcnR5KCJhbm5vdGF0aW9uU3RvcmFnZSIpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmFubm90YXRpb25TdG9yYWdlLnJlc2V0TW9kaWZpZWQoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB0ZXJtaW5hdGVkID0gdGhpcy5tZXNzYWdlSGFuZGxlci5zZW5kV2l0aFByb21pc2UoIlRlcm1pbmF0ZSIsIG51bGwpOwogICAgICAgICAgICAgICAgICAgICAgICB3YWl0T24ucHVzaCh0ZXJtaW5hdGVkKTsKICAgICAgICAgICAgICAgICAgICAgICAgUHJvbWlzZS5hbGwod2FpdE9uKS50aGVuKCgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29tbW9uT2Jqcy5jbGVhcigpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5mb250TG9hZGVyLmNsZWFyKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX21ldGhvZFByb21pc2VzKS5jbGVhcigpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5maWx0ZXJGYWN0b3J5LmRlc3Ryb3koKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl9uZXR3b3JrU3RyZWFtKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fbmV0d29ya1N0cmVhbS5jYW5jZWxBbGxSZXF1ZXN0cyhuZXcgX3V0aWwuQWJvcnRFeGNlcHRpb24oIldvcmtlciB3YXMgdGVybWluYXRlZC4iKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5tZXNzYWdlSGFuZGxlcikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubWVzc2FnZUhhbmRsZXIuZGVzdHJveSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubWVzc2FnZUhhbmRsZXIgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kZXN0cm95Q2FwYWJpbGl0eS5yZXNvbHZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0sIHRoaXMuZGVzdHJveUNhcGFiaWxpdHkucmVqZWN0KTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuZGVzdHJveUNhcGFiaWxpdHkucHJvbWlzZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2V0dXBNZXNzYWdlSGFuZGxlcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgbWVzc2FnZUhhbmRsZXIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsb2FkaW5nVGFzawogICAgICAgICAgICAgICAgICAgICAgICB9ID0gdGhpczsKICAgICAgICAgICAgICAgICAgICAgICAgbWVzc2FnZUhhbmRsZXIub24oIkdldFJlYWRlciIsIChkYXRhLCBzaW5rKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwuYXNzZXJ0KSh0aGlzLl9uZXR3b3JrU3RyZWFtLCAiR2V0UmVhZGVyIC0gbm8gYElQREZTdHJlYW1gIGluc3RhbmNlIGF2YWlsYWJsZS4iKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Z1bGxSZWFkZXIgPSB0aGlzLl9uZXR3b3JrU3RyZWFtLmdldEZ1bGxSZWFkZXIoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Z1bGxSZWFkZXIub25Qcm9ncmVzcyA9IGV2dCA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fbGFzdFByb2dyZXNzID0gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsb2FkZWQ6IGV2dC5sb2FkZWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRvdGFsOiBldnQudG90YWwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNpbmsub25QdWxsID0gKCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Z1bGxSZWFkZXIucmVhZCgpLnRoZW4oZnVuY3Rpb24gKF9yZWY4KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRvbmUKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSA9IF9yZWY4OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZG9uZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2luay5jbG9zZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC5hc3NlcnQpKHZhbHVlIGluc3RhbmNlb2YgQXJyYXlCdWZmZXIsICJHZXRSZWFkZXIgLSBleHBlY3RlZCBhbiBBcnJheUJ1ZmZlci4iKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2luay5lbnF1ZXVlKG5ldyBVaW50OEFycmF5KHZhbHVlKSwgMSwgW3ZhbHVlXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSkuY2F0Y2gocmVhc29uID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2luay5lcnJvcihyZWFzb24pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNpbmsub25DYW5jZWwgPSByZWFzb24gPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Z1bGxSZWFkZXIuY2FuY2VsKHJlYXNvbik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2luay5yZWFkeS5jYXRjaChyZWFkeVJlYXNvbiA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmRlc3Ryb3llZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IHJlYWR5UmVhc29uOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIG1lc3NhZ2VIYW5kbGVyLm9uKCJSZWFkZXJIZWFkZXJzUmVhZHkiLCBkYXRhID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGhlYWRlcnNDYXBhYmlsaXR5ID0gKDAsIF91dGlsLmNyZWF0ZVByb21pc2VDYXBhYmlsaXR5KSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZnVsbFJlYWRlciA9IHRoaXMuX2Z1bGxSZWFkZXI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmdWxsUmVhZGVyLmhlYWRlcnNSZWFkeS50aGVuKCgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWZ1bGxSZWFkZXIuaXNTdHJlYW1pbmdTdXBwb3J0ZWQgfHwgIWZ1bGxSZWFkZXIuaXNSYW5nZVN1cHBvcnRlZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fbGFzdFByb2dyZXNzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgX2xvYWRpbmdUYXNrJG9uUHJvZ3JlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKF9sb2FkaW5nVGFzayRvblByb2dyZSA9IGxvYWRpbmdUYXNrLm9uUHJvZ3Jlc3MpID09PSBudWxsIHx8IF9sb2FkaW5nVGFzayRvblByb2dyZSA9PT0gdm9pZCAwID8gdm9pZCAwIDogX2xvYWRpbmdUYXNrJG9uUHJvZ3JlLmNhbGwobG9hZGluZ1Rhc2ssIHRoaXMuX2xhc3RQcm9ncmVzcyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZnVsbFJlYWRlci5vblByb2dyZXNzID0gZXZ0ID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfbG9hZGluZ1Rhc2skb25Qcm9ncmUyOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKF9sb2FkaW5nVGFzayRvblByb2dyZTIgPSBsb2FkaW5nVGFzay5vblByb2dyZXNzKSA9PT0gbnVsbCB8fCBfbG9hZGluZ1Rhc2skb25Qcm9ncmUyID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfbG9hZGluZ1Rhc2skb25Qcm9ncmUyLmNhbGwobG9hZGluZ1Rhc2ssIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsb2FkZWQ6IGV2dC5sb2FkZWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdG90YWw6IGV2dC50b3RhbAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGhlYWRlcnNDYXBhYmlsaXR5LnJlc29sdmUoewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc1N0cmVhbWluZ1N1cHBvcnRlZDogZnVsbFJlYWRlci5pc1N0cmVhbWluZ1N1cHBvcnRlZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNSYW5nZVN1cHBvcnRlZDogZnVsbFJlYWRlci5pc1JhbmdlU3VwcG9ydGVkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250ZW50TGVuZ3RoOiBmdWxsUmVhZGVyLmNvbnRlbnRMZW5ndGgKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sIGhlYWRlcnNDYXBhYmlsaXR5LnJlamVjdCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gaGVhZGVyc0NhcGFiaWxpdHkucHJvbWlzZTsKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIG1lc3NhZ2VIYW5kbGVyLm9uKCJHZXRSYW5nZVJlYWRlciIsIChkYXRhLCBzaW5rKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwuYXNzZXJ0KSh0aGlzLl9uZXR3b3JrU3RyZWFtLCAiR2V0UmFuZ2VSZWFkZXIgLSBubyBgSVBERlN0cmVhbWAgaW5zdGFuY2UgYXZhaWxhYmxlLiIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmFuZ2VSZWFkZXIgPSB0aGlzLl9uZXR3b3JrU3RyZWFtLmdldFJhbmdlUmVhZGVyKGRhdGEuYmVnaW4sIGRhdGEuZW5kKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghcmFuZ2VSZWFkZXIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzaW5rLmNsb3NlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgc2luay5vblB1bGwgPSAoKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmFuZ2VSZWFkZXIucmVhZCgpLnRoZW4oZnVuY3Rpb24gKF9yZWY5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRvbmUKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSA9IF9yZWY5OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZG9uZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2luay5jbG9zZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC5hc3NlcnQpKHZhbHVlIGluc3RhbmNlb2YgQXJyYXlCdWZmZXIsICJHZXRSYW5nZVJlYWRlciAtIGV4cGVjdGVkIGFuIEFycmF5QnVmZmVyLiIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzaW5rLmVucXVldWUobmV3IFVpbnQ4QXJyYXkodmFsdWUpLCAxLCBbdmFsdWVdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KS5jYXRjaChyZWFzb24gPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzaW5rLmVycm9yKHJlYXNvbik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgc2luay5vbkNhbmNlbCA9IHJlYXNvbiA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmFuZ2VSZWFkZXIuY2FuY2VsKHJlYXNvbik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2luay5yZWFkeS5jYXRjaChyZWFkeVJlYXNvbiA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmRlc3Ryb3llZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IHJlYWR5UmVhc29uOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIG1lc3NhZ2VIYW5kbGVyLm9uKCJHZXREb2MiLCBfcmVmMTAgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwZGZJbmZvCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9ID0gX3JlZjEwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fbnVtUGFnZXMgPSBwZGZJbmZvLm51bVBhZ2VzOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5faHRtbEZvclhmYSA9IHBkZkluZm8uaHRtbEZvclhmYTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlbGV0ZSBwZGZJbmZvLmh0bWxGb3JYZmE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsb2FkaW5nVGFzay5fY2FwYWJpbGl0eS5yZXNvbHZlKG5ldyBQREZEb2N1bWVudFByb3h5KHBkZkluZm8sIHRoaXMpKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIG1lc3NhZ2VIYW5kbGVyLm9uKCJEb2NFeGNlcHRpb24iLCBmdW5jdGlvbiAoZXgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCByZWFzb247CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzd2l0Y2ggKGV4Lm5hbWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJQYXNzd29yZEV4Y2VwdGlvbiI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlYXNvbiA9IG5ldyBfdXRpbC5QYXNzd29yZEV4Y2VwdGlvbihleC5tZXNzYWdlLCBleC5jb2RlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiSW52YWxpZFBERkV4Y2VwdGlvbiI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlYXNvbiA9IG5ldyBfdXRpbC5JbnZhbGlkUERGRXhjZXB0aW9uKGV4Lm1lc3NhZ2UpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJNaXNzaW5nUERGRXhjZXB0aW9uIjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVhc29uID0gbmV3IF91dGlsLk1pc3NpbmdQREZFeGNlcHRpb24oZXgubWVzc2FnZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgIlVuZXhwZWN0ZWRSZXNwb25zZUV4Y2VwdGlvbiI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlYXNvbiA9IG5ldyBfdXRpbC5VbmV4cGVjdGVkUmVzcG9uc2VFeGNlcHRpb24oZXgubWVzc2FnZSwgZXguc3RhdHVzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiVW5rbm93bkVycm9yRXhjZXB0aW9uIjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVhc29uID0gbmV3IF91dGlsLlVua25vd25FcnJvckV4Y2VwdGlvbihleC5tZXNzYWdlLCBleC5kZXRhaWxzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLnVucmVhY2hhYmxlKSgiRG9jRXhjZXB0aW9uIC0gZXhwZWN0ZWQgYSB2YWxpZCBFcnJvci4iKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxvYWRpbmdUYXNrLl9jYXBhYmlsaXR5LnJlamVjdChyZWFzb24pOwogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgbWVzc2FnZUhhbmRsZXIub24oIlBhc3N3b3JkUmVxdWVzdCIsIGV4Y2VwdGlvbiA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wYXNzd29yZENhcGFiaWxpdHkgPSAoMCwgX3V0aWwuY3JlYXRlUHJvbWlzZUNhcGFiaWxpdHkpKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAobG9hZGluZ1Rhc2sub25QYXNzd29yZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHVwZGF0ZVBhc3N3b3JkID0gcGFzc3dvcmQgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAocGFzc3dvcmQgaW5zdGFuY2VvZiBFcnJvcikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcGFzc3dvcmRDYXBhYmlsaXR5LnJlamVjdChwYXNzd29yZCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wYXNzd29yZENhcGFiaWxpdHkucmVzb2x2ZSh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFzc3dvcmQKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsb2FkaW5nVGFzay5vblBhc3N3b3JkKHVwZGF0ZVBhc3N3b3JkLCBleGNlcHRpb24uY29kZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZXgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcGFzc3dvcmRDYXBhYmlsaXR5LnJlamVjdChleCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wYXNzd29yZENhcGFiaWxpdHkucmVqZWN0KG5ldyBfdXRpbC5QYXNzd29yZEV4Y2VwdGlvbihleGNlcHRpb24ubWVzc2FnZSwgZXhjZXB0aW9uLmNvZGUpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9wYXNzd29yZENhcGFiaWxpdHkucHJvbWlzZTsKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIG1lc3NhZ2VIYW5kbGVyLm9uKCJEYXRhTG9hZGVkIiwgZGF0YSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgX2xvYWRpbmdUYXNrJG9uUHJvZ3JlMzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIChfbG9hZGluZ1Rhc2skb25Qcm9ncmUzID0gbG9hZGluZ1Rhc2sub25Qcm9ncmVzcykgPT09IG51bGwgfHwgX2xvYWRpbmdUYXNrJG9uUHJvZ3JlMyA9PT0gdm9pZCAwID8gdm9pZCAwIDogX2xvYWRpbmdUYXNrJG9uUHJvZ3JlMy5jYWxsKGxvYWRpbmdUYXNrLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbG9hZGVkOiBkYXRhLmxlbmd0aCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0b3RhbDogZGF0YS5sZW5ndGgKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kb3dubG9hZEluZm9DYXBhYmlsaXR5LnJlc29sdmUoZGF0YSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBtZXNzYWdlSGFuZGxlci5vbigiU3RhcnRSZW5kZXJQYWdlIiwgZGF0YSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5kZXN0cm95ZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwYWdlID0gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9wYWdlQ2FjaGUpLmdldChkYXRhLnBhZ2VJbmRleCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYWdlLl9zdGFydFJlbmRlclBhZ2UoZGF0YS50cmFuc3BhcmVuY3ksIGRhdGEuY2FjaGVLZXkpOwogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgbWVzc2FnZUhhbmRsZXIub24oImNvbW1vbm9iaiIsIF9yZWYxMSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgX2dsb2JhbFRoaXMkRm9udEluc3BlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IFtpZCwgdHlwZSwgZXhwb3J0ZWREYXRhXSA9IF9yZWYxMTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmRlc3Ryb3llZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmNvbW1vbk9ianMuaGFzKGlkKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN3aXRjaCAodHlwZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgIkZvbnQiOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwYXJhbXMgPSB0aGlzLl9wYXJhbXM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICgiZXJyb3IiIGluIGV4cG9ydGVkRGF0YSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZXhwb3J0ZWRFcnJvciA9IGV4cG9ydGVkRGF0YS5lcnJvcjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgRXJyb3IgZHVyaW5nIGZvbnQgbG9hZGluZzogJHtleHBvcnRlZEVycm9yfWApOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb21tb25PYmpzLnJlc29sdmUoaWQsIGV4cG9ydGVkRXJyb3IpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaW5zcGVjdEZvbnQgPSBwYXJhbXMucGRmQnVnICYmIChfZ2xvYmFsVGhpcyRGb250SW5zcGUgPSBnbG9iYWxUaGlzLkZvbnRJbnNwZWN0b3IpICE9PSBudWxsICYmIF9nbG9iYWxUaGlzJEZvbnRJbnNwZSAhPT0gdm9pZCAwICYmIF9nbG9iYWxUaGlzJEZvbnRJbnNwZS5lbmFibGVkID8gKGZvbnQsIHVybCkgPT4gZ2xvYmFsVGhpcy5Gb250SW5zcGVjdG9yLmZvbnRBZGRlZChmb250LCB1cmwpIDogbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZm9udCA9IG5ldyBfZm9udF9sb2FkZXIuRm9udEZhY2VPYmplY3QoZXhwb3J0ZWREYXRhLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc0V2YWxTdXBwb3J0ZWQ6IHBhcmFtcy5pc0V2YWxTdXBwb3J0ZWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkaXNhYmxlRm9udEZhY2U6IHBhcmFtcy5kaXNhYmxlRm9udEZhY2UsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZ25vcmVFcnJvcnM6IHBhcmFtcy5pZ25vcmVFcnJvcnMsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnNwZWN0Rm9udAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5mb250TG9hZGVyLmJpbmQoZm9udCkuY2F0Y2gocmVhc29uID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBtZXNzYWdlSGFuZGxlci5zZW5kV2l0aFByb21pc2UoIkZvbnRGYWxsYmFjayIsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pLmZpbmFsbHkoKCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFwYXJhbXMuZm9udEV4dHJhUHJvcGVydGllcyAmJiBmb250LmRhdGEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb250LmRhdGEgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb21tb25PYmpzLnJlc29sdmUoaWQsIGZvbnQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiRm9udFBhdGgiOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgIkltYWdlIjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJQYXR0ZXJuIjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb21tb25PYmpzLnJlc29sdmUoaWQsIGV4cG9ydGVkRGF0YSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcihgR290IHVua25vd24gY29tbW9uIG9iamVjdCB0eXBlICR7dHlwZX1gKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIG1lc3NhZ2VIYW5kbGVyLm9uKCJvYmoiLCBfcmVmMTIgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IFtpZCwgcGFnZUluZGV4LCB0eXBlLCBpbWFnZURhdGFdID0gX3JlZjEyOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuZGVzdHJveWVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcGFnZVByb3h5ID0gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9wYWdlQ2FjaGUpLmdldChwYWdlSW5kZXgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHBhZ2VQcm94eS5vYmpzLmhhcyhpZCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzd2l0Y2ggKHR5cGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJJbWFnZSI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2VQcm94eS5vYmpzLnJlc29sdmUoaWQsIGltYWdlRGF0YSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpbWFnZURhdGEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBsZW5ndGg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoaW1hZ2VEYXRhLmJpdG1hcCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgd2lkdGgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGhlaWdodAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBpbWFnZURhdGE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGVuZ3RoID0gd2lkdGggKiBoZWlnaHQgKiA0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgX2ltYWdlRGF0YSRkYXRhOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxlbmd0aCA9ICgoX2ltYWdlRGF0YSRkYXRhID0gaW1hZ2VEYXRhLmRhdGEpID09PSBudWxsIHx8IF9pbWFnZURhdGEkZGF0YSA9PT0gdm9pZCAwID8gdm9pZCAwIDogX2ltYWdlRGF0YSRkYXRhLmxlbmd0aCkgfHwgMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChsZW5ndGggPiBfdXRpbC5NQVhfSU1BR0VfU0laRV9UT19DQUNIRSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2VQcm94eS5fbWF5YmVDbGVhbnVwQWZ0ZXJSZW5kZXIgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgIlBhdHRlcm4iOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYWdlUHJveHkub2Jqcy5yZXNvbHZlKGlkLCBpbWFnZURhdGEpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoYEdvdCB1bmtub3duIG9iamVjdCB0eXBlICR7dHlwZX1gKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIG1lc3NhZ2VIYW5kbGVyLm9uKCJEb2NQcm9ncmVzcyIsIGRhdGEgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF9sb2FkaW5nVGFzayRvblByb2dyZTQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5kZXN0cm95ZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAoX2xvYWRpbmdUYXNrJG9uUHJvZ3JlNCA9IGxvYWRpbmdUYXNrLm9uUHJvZ3Jlc3MpID09PSBudWxsIHx8IF9sb2FkaW5nVGFzayRvblByb2dyZTQgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF9sb2FkaW5nVGFzayRvblByb2dyZTQuY2FsbChsb2FkaW5nVGFzaywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxvYWRlZDogZGF0YS5sb2FkZWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdG90YWw6IGRhdGEudG90YWwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgbWVzc2FnZUhhbmRsZXIub24oIkZldGNoQnVpbHRJbkNNYXAiLCBkYXRhID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmRlc3Ryb3llZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBQcm9taXNlLnJlamVjdChuZXcgRXJyb3IoIldvcmtlciB3YXMgZGVzdHJveWVkLiIpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5jTWFwUmVhZGVyRmFjdG9yeSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBQcm9taXNlLnJlamVjdChuZXcgRXJyb3IoIkNNYXBSZWFkZXJGYWN0b3J5IG5vdCBpbml0aWFsaXplZCwgc2VlIHRoZSBgdXNlV29ya2VyRmV0Y2hgIHBhcmFtZXRlci4iKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5jTWFwUmVhZGVyRmFjdG9yeS5mZXRjaChkYXRhKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIG1lc3NhZ2VIYW5kbGVyLm9uKCJGZXRjaFN0YW5kYXJkRm9udERhdGEiLCBkYXRhID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmRlc3Ryb3llZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBQcm9taXNlLnJlamVjdChuZXcgRXJyb3IoIldvcmtlciB3YXMgZGVzdHJveWVkLiIpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5zdGFuZGFyZEZvbnREYXRhRmFjdG9yeSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBQcm9taXNlLnJlamVjdChuZXcgRXJyb3IoIlN0YW5kYXJkRm9udERhdGFGYWN0b3J5IG5vdCBpbml0aWFsaXplZCwgc2VlIHRoZSBgdXNlV29ya2VyRmV0Y2hgIHBhcmFtZXRlci4iKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5zdGFuZGFyZEZvbnREYXRhRmFjdG9yeS5mZXRjaChkYXRhKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldERhdGEoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLm1lc3NhZ2VIYW5kbGVyLnNlbmRXaXRoUHJvbWlzZSgiR2V0RGF0YSIsIG51bGwpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzYXZlRG9jdW1lbnQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRfZnVsbFJlYWRlcjsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuYW5ub3RhdGlvblN0b3JhZ2Uuc2l6ZSA8PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoInNhdmVEb2N1bWVudCBjYWxsZWQgd2hpbGUgYGFubm90YXRpb25TdG9yYWdlYCBpcyBlbXB0eSwgIiArICJwbGVhc2UgdXNlIHRoZSBnZXREYXRhLW1ldGhvZCBpbnN0ZWFkLiIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLm1lc3NhZ2VIYW5kbGVyLnNlbmRXaXRoUHJvbWlzZSgiU2F2ZURvY3VtZW50IiwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNQdXJlWGZhOiAhIXRoaXMuX2h0bWxGb3JYZmEsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBudW1QYWdlczogdGhpcy5fbnVtUGFnZXMsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhbm5vdGF0aW9uU3RvcmFnZTogdGhpcy5hbm5vdGF0aW9uU3RvcmFnZS5zZXJpYWxpemFibGUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmaWxlbmFtZTogKChfdGhpcyRfZnVsbFJlYWRlciA9IHRoaXMuX2Z1bGxSZWFkZXIpID09PSBudWxsIHx8IF90aGlzJF9mdWxsUmVhZGVyID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRfZnVsbFJlYWRlci5maWxlbmFtZSkgPz8gbnVsbAogICAgICAgICAgICAgICAgICAgICAgICB9KS5maW5hbGx5KCgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYW5ub3RhdGlvblN0b3JhZ2UucmVzZXRNb2RpZmllZCgpOwogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0UGFnZShwYWdlTnVtYmVyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghTnVtYmVyLmlzSW50ZWdlcihwYWdlTnVtYmVyKSB8fCBwYWdlTnVtYmVyIDw9IDAgfHwgcGFnZU51bWJlciA+IHRoaXMuX251bVBhZ2VzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gUHJvbWlzZS5yZWplY3QobmV3IEVycm9yKCJJbnZhbGlkIHBhZ2UgcmVxdWVzdC4iKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcGFnZUluZGV4ID0gcGFnZU51bWJlciAtIDEsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYWNoZWRQcm9taXNlID0gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9wYWdlUHJvbWlzZXMpLmdldChwYWdlSW5kZXgpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoY2FjaGVkUHJvbWlzZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGNhY2hlZFByb21pc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcHJvbWlzZSA9IHRoaXMubWVzc2FnZUhhbmRsZXIuc2VuZFdpdGhQcm9taXNlKCJHZXRQYWdlIiwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFnZUluZGV4CiAgICAgICAgICAgICAgICAgICAgICAgIH0pLnRoZW4ocGFnZUluZm8gPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuZGVzdHJveWVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCJUcmFuc3BvcnQgZGVzdHJveWVkIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwYWdlID0gbmV3IFBERlBhZ2VQcm94eShwYWdlSW5kZXgsIHBhZ2VJbmZvLCB0aGlzLCB0aGlzLl9wYXJhbXMucGRmQnVnKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfcGFnZUNhY2hlKS5zZXQocGFnZUluZGV4LCBwYWdlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBwYWdlOwogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9wYWdlUHJvbWlzZXMpLnNldChwYWdlSW5kZXgsIHByb21pc2UpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gcHJvbWlzZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0UGFnZUluZGV4KHJlZikgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIHJlZiAhPT0gIm9iamVjdCIgfHwgcmVmID09PSBudWxsIHx8ICFOdW1iZXIuaXNJbnRlZ2VyKHJlZi5udW0pIHx8IHJlZi5udW0gPCAwIHx8ICFOdW1iZXIuaXNJbnRlZ2VyKHJlZi5nZW4pIHx8IHJlZi5nZW4gPCAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gUHJvbWlzZS5yZWplY3QobmV3IEVycm9yKCJJbnZhbGlkIHBhZ2VJbmRleCByZXF1ZXN0LiIpKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5tZXNzYWdlSGFuZGxlci5zZW5kV2l0aFByb21pc2UoIkdldFBhZ2VJbmRleCIsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG51bTogcmVmLm51bSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdlbjogcmVmLmdlbgogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0QW5ub3RhdGlvbnMocGFnZUluZGV4LCBpbnRlbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMubWVzc2FnZUhhbmRsZXIuc2VuZFdpdGhQcm9taXNlKCJHZXRBbm5vdGF0aW9ucyIsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2VJbmRleCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludGVudAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0RmllbGRPYmplY3RzKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfY2FjaGVTaW1wbGVNZXRob2QsIF9jYWNoZVNpbXBsZU1ldGhvZDIpLmNhbGwodGhpcywgIkdldEZpZWxkT2JqZWN0cyIpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBoYXNKU0FjdGlvbnMoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9jYWNoZVNpbXBsZU1ldGhvZCwgX2NhY2hlU2ltcGxlTWV0aG9kMikuY2FsbCh0aGlzLCAiSGFzSlNBY3Rpb25zIik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldENhbGN1bGF0aW9uT3JkZXJJZHMoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLm1lc3NhZ2VIYW5kbGVyLnNlbmRXaXRoUHJvbWlzZSgiR2V0Q2FsY3VsYXRpb25PcmRlcklkcyIsIG51bGwpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXREZXN0aW5hdGlvbnMoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLm1lc3NhZ2VIYW5kbGVyLnNlbmRXaXRoUHJvbWlzZSgiR2V0RGVzdGluYXRpb25zIiwgbnVsbCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldERlc3RpbmF0aW9uKGlkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0eXBlb2YgaWQgIT09ICJzdHJpbmciKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gUHJvbWlzZS5yZWplY3QobmV3IEVycm9yKCJJbnZhbGlkIGRlc3RpbmF0aW9uIHJlcXVlc3QuIikpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLm1lc3NhZ2VIYW5kbGVyLnNlbmRXaXRoUHJvbWlzZSgiR2V0RGVzdGluYXRpb24iLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0UGFnZUxhYmVscygpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMubWVzc2FnZUhhbmRsZXIuc2VuZFdpdGhQcm9taXNlKCJHZXRQYWdlTGFiZWxzIiwgbnVsbCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldFBhZ2VMYXlvdXQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLm1lc3NhZ2VIYW5kbGVyLnNlbmRXaXRoUHJvbWlzZSgiR2V0UGFnZUxheW91dCIsIG51bGwpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRQYWdlTW9kZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMubWVzc2FnZUhhbmRsZXIuc2VuZFdpdGhQcm9taXNlKCJHZXRQYWdlTW9kZSIsIG51bGwpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRWaWV3ZXJQcmVmZXJlbmNlcygpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMubWVzc2FnZUhhbmRsZXIuc2VuZFdpdGhQcm9taXNlKCJHZXRWaWV3ZXJQcmVmZXJlbmNlcyIsIG51bGwpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRPcGVuQWN0aW9uKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5tZXNzYWdlSGFuZGxlci5zZW5kV2l0aFByb21pc2UoIkdldE9wZW5BY3Rpb24iLCBudWxsKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0QXR0YWNobWVudHMoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLm1lc3NhZ2VIYW5kbGVyLnNlbmRXaXRoUHJvbWlzZSgiR2V0QXR0YWNobWVudHMiLCBudWxsKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0SmF2YVNjcmlwdCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMubWVzc2FnZUhhbmRsZXIuc2VuZFdpdGhQcm9taXNlKCJHZXRKYXZhU2NyaXB0IiwgbnVsbCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldERvY0pTQWN0aW9ucygpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMubWVzc2FnZUhhbmRsZXIuc2VuZFdpdGhQcm9taXNlKCJHZXREb2NKU0FjdGlvbnMiLCBudWxsKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0UGFnZUpTQWN0aW9ucyhwYWdlSW5kZXgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMubWVzc2FnZUhhbmRsZXIuc2VuZFdpdGhQcm9taXNlKCJHZXRQYWdlSlNBY3Rpb25zIiwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFnZUluZGV4CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRTdHJ1Y3RUcmVlKHBhZ2VJbmRleCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5tZXNzYWdlSGFuZGxlci5zZW5kV2l0aFByb21pc2UoIkdldFN0cnVjdFRyZWUiLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYWdlSW5kZXgKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldE91dGxpbmUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLm1lc3NhZ2VIYW5kbGVyLnNlbmRXaXRoUHJvbWlzZSgiR2V0T3V0bGluZSIsIG51bGwpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRPcHRpb25hbENvbnRlbnRDb25maWcoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLm1lc3NhZ2VIYW5kbGVyLnNlbmRXaXRoUHJvbWlzZSgiR2V0T3B0aW9uYWxDb250ZW50Q29uZmlnIiwgbnVsbCkudGhlbihyZXN1bHRzID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgX29wdGlvbmFsX2NvbnRlbnRfY29uZmlnLk9wdGlvbmFsQ29udGVudENvbmZpZyhyZXN1bHRzKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldFBlcm1pc3Npb25zKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5tZXNzYWdlSGFuZGxlci5zZW5kV2l0aFByb21pc2UoIkdldFBlcm1pc3Npb25zIiwgbnVsbCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldE1ldGFkYXRhKCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBuYW1lID0gIkdldE1ldGFkYXRhIiwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhY2hlZFByb21pc2UgPSBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX21ldGhvZFByb21pc2VzKS5nZXQobmFtZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjYWNoZWRQcm9taXNlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gY2FjaGVkUHJvbWlzZTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwcm9taXNlID0gdGhpcy5tZXNzYWdlSGFuZGxlci5zZW5kV2l0aFByb21pc2UobmFtZSwgbnVsbCkudGhlbihyZXN1bHRzID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRfZnVsbFJlYWRlcjIsIF90aGlzJF9mdWxsUmVhZGVyMzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW5mbzogcmVzdWx0c1swXSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtZXRhZGF0YTogcmVzdWx0c1sxXSA/IG5ldyBfbWV0YWRhdGEuTWV0YWRhdGEocmVzdWx0c1sxXSkgOiBudWxsLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRlbnREaXNwb3NpdGlvbkZpbGVuYW1lOiAoKF90aGlzJF9mdWxsUmVhZGVyMiA9IHRoaXMuX2Z1bGxSZWFkZXIpID09PSBudWxsIHx8IF90aGlzJF9mdWxsUmVhZGVyMiA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3RoaXMkX2Z1bGxSZWFkZXIyLmZpbGVuYW1lKSA/PyBudWxsLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRlbnRMZW5ndGg6ICgoX3RoaXMkX2Z1bGxSZWFkZXIzID0gdGhpcy5fZnVsbFJlYWRlcikgPT09IG51bGwgfHwgX3RoaXMkX2Z1bGxSZWFkZXIzID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRfZnVsbFJlYWRlcjMuY29udGVudExlbmd0aCkgPz8gbnVsbAogICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfbWV0aG9kUHJvbWlzZXMpLnNldChuYW1lLCBwcm9taXNlKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHByb21pc2U7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldE1hcmtJbmZvKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5tZXNzYWdlSGFuZGxlci5zZW5kV2l0aFByb21pc2UoIkdldE1hcmtJbmZvIiwgbnVsbCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGFzeW5jIHN0YXJ0Q2xlYW51cCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGtlZXBMb2FkZWRGb250cyA9IGFyZ3VtZW50cy5sZW5ndGggPiAwICYmIGFyZ3VtZW50c1swXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzBdIDogZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmRlc3Ryb3llZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGF3YWl0IHRoaXMubWVzc2FnZUhhbmRsZXIuc2VuZFdpdGhQcm9taXNlKCJDbGVhbnVwIiwgbnVsbCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgcGFnZSBvZiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX3BhZ2VDYWNoZSkudmFsdWVzKCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNsZWFudXBTdWNjZXNzZnVsID0gcGFnZS5jbGVhbnVwKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWNsZWFudXBTdWNjZXNzZnVsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKGBzdGFydENsZWFudXA6IFBhZ2UgJHtwYWdlLnBhZ2VOdW1iZXJ9IGlzIGN1cnJlbnRseSByZW5kZXJpbmcuYCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb21tb25PYmpzLmNsZWFyKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICgha2VlcExvYWRlZEZvbnRzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmZvbnRMb2FkZXIuY2xlYXIoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX21ldGhvZFByb21pc2VzKS5jbGVhcigpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmZpbHRlckZhY3RvcnkuZGVzdHJveSh0cnVlKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IGxvYWRpbmdQYXJhbXMoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRpc2FibGVBdXRvRmV0Y2gsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbmFibGVYZmEKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IHRoaXMuX3BhcmFtczsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICgwLCBfdXRpbC5zaGFkb3cpKHRoaXMsICJsb2FkaW5nUGFyYW1zIiwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGlzYWJsZUF1dG9GZXRjaCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVuYWJsZVhmYQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfY2FjaGVTaW1wbGVNZXRob2QyKG5hbWUpIHsKICAgICAgICAgICAgICAgICAgICBsZXQgZGF0YSA9IGFyZ3VtZW50cy5sZW5ndGggPiAxICYmIGFyZ3VtZW50c1sxXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzFdIDogbnVsbDsKICAgICAgICAgICAgICAgICAgICBjb25zdCBjYWNoZWRQcm9taXNlID0gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9tZXRob2RQcm9taXNlcykuZ2V0KG5hbWUpOwogICAgICAgICAgICAgICAgICAgIGlmIChjYWNoZWRQcm9taXNlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBjYWNoZWRQcm9taXNlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjb25zdCBwcm9taXNlID0gdGhpcy5tZXNzYWdlSGFuZGxlci5zZW5kV2l0aFByb21pc2UobmFtZSwgZGF0YSk7CiAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9tZXRob2RQcm9taXNlcykuc2V0KG5hbWUsIHByb21pc2UpOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBwcm9taXNlOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgdmFyIF9vYmpzID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2Vuc3VyZU9iaiA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgY2xhc3MgUERGT2JqZWN0cyB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfZW5zdXJlT2JqKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX29ianMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IE9iamVjdC5jcmVhdGUobnVsbCkKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldChvYmpJZCkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgY2FsbGJhY2sgPSBhcmd1bWVudHMubGVuZ3RoID4gMSAmJiBhcmd1bWVudHNbMV0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1sxXSA6IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjYWxsYmFjaykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgb2JqID0gX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfZW5zdXJlT2JqLCBfZW5zdXJlT2JqMikuY2FsbCh0aGlzLCBvYmpJZCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvYmouY2FwYWJpbGl0eS5wcm9taXNlLnRoZW4oKCkgPT4gY2FsbGJhY2sob2JqLmRhdGEpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG9iaiA9IF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfb2Jqcylbb2JqSWRdOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIShvYmogIT09IG51bGwgJiYgb2JqICE9PSB2b2lkIDAgJiYgb2JqLmNhcGFiaWxpdHkuc2V0dGxlZCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcihgUmVxdWVzdGluZyBvYmplY3QgdGhhdCBpc24ndCByZXNvbHZlZCB5ZXQgJHtvYmpJZH0uYCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG9iai5kYXRhOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBoYXMob2JqSWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgb2JqID0gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9vYmpzKVtvYmpJZF07CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAob2JqID09PSBudWxsIHx8IG9iaiA9PT0gdm9pZCAwID8gdm9pZCAwIDogb2JqLmNhcGFiaWxpdHkuc2V0dGxlZCkgfHwgZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlc29sdmUob2JqSWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGRhdGEgPSBhcmd1bWVudHMubGVuZ3RoID4gMSAmJiBhcmd1bWVudHNbMV0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1sxXSA6IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG9iaiA9IF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2Vuc3VyZU9iaiwgX2Vuc3VyZU9iajIpLmNhbGwodGhpcywgb2JqSWQpOwogICAgICAgICAgICAgICAgICAgICAgICBvYmouZGF0YSA9IGRhdGE7CiAgICAgICAgICAgICAgICAgICAgICAgIG9iai5jYXBhYmlsaXR5LnJlc29sdmUoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY2xlYXIoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3Qgb2JqSWQgaW4gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9vYmpzKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF9kYXRhJGJpdG1hcDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkYXRhCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9ID0gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9vYmpzKVtvYmpJZF07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkYXRhID09PSBudWxsIHx8IGRhdGEgPT09IHZvaWQgMCA/IHZvaWQgMCA6IChfZGF0YSRiaXRtYXAgPSBkYXRhLmJpdG1hcCkgPT09IG51bGwgfHwgX2RhdGEkYml0bWFwID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfZGF0YSRiaXRtYXAuY2xvc2UoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX29ianMsIE9iamVjdC5jcmVhdGUobnVsbCkpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9lbnN1cmVPYmoyKG9iaklkKSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3Qgb2JqID0gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9vYmpzKVtvYmpJZF07CiAgICAgICAgICAgICAgICAgICAgaWYgKG9iaikgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gb2JqOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9vYmpzKVtvYmpJZF0gPSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNhcGFiaWxpdHk6ICgwLCBfdXRpbC5jcmVhdGVQcm9taXNlQ2FwYWJpbGl0eSkoKSwKICAgICAgICAgICAgICAgICAgICAgICAgZGF0YTogbnVsbAogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBSZW5kZXJUYXNrIHsKICAgICAgICAgICAgICAgICAgICAjaW50ZXJuYWxSZW5kZXJUYXNrID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcihpbnRlcm5hbFJlbmRlclRhc2spIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy4jaW50ZXJuYWxSZW5kZXJUYXNrID0gaW50ZXJuYWxSZW5kZXJUYXNrOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm9uQ29udGludWUgPSBudWxsOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgcHJvbWlzZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuI2ludGVybmFsUmVuZGVyVGFzay5jYXBhYmlsaXR5LnByb21pc2U7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNhbmNlbCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGV4dHJhRGVsYXkgPSBhcmd1bWVudHMubGVuZ3RoID4gMCAmJiBhcmd1bWVudHNbMF0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1swXSA6IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuI2ludGVybmFsUmVuZGVyVGFzay5jYW5jZWwobnVsbCwgZXh0cmFEZWxheSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBzZXBhcmF0ZUFubm90cygpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VwYXJhdGVBbm5vdHMKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IHRoaXMuI2ludGVybmFsUmVuZGVyVGFzay5vcGVyYXRvckxpc3Q7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghc2VwYXJhdGVBbm5vdHMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhbm5vdGF0aW9uQ2FudmFzTWFwCiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSB0aGlzLiNpbnRlcm5hbFJlbmRlclRhc2s7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBzZXBhcmF0ZUFubm90cy5mb3JtIHx8IHNlcGFyYXRlQW5ub3RzLmNhbnZhcyAmJiAoYW5ub3RhdGlvbkNhbnZhc01hcCA9PT0gbnVsbCB8fCBhbm5vdGF0aW9uQ2FudmFzTWFwID09PSB2b2lkIDAgPyB2b2lkIDAgOiBhbm5vdGF0aW9uQ2FudmFzTWFwLnNpemUpID4gMDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLlJlbmRlclRhc2sgPSBSZW5kZXJUYXNrOwogICAgICAgICAgICAgICAgY2xhc3MgSW50ZXJuYWxSZW5kZXJUYXNrIHsKICAgICAgICAgICAgICAgICAgICBzdGF0aWMgI2NhbnZhc0luVXNlID0gbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcihfcmVmMTMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhbGxiYWNrLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFyYW1zLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgb2JqcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbW1vbk9ianMsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhbm5vdGF0aW9uQ2FudmFzTWFwLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgb3BlcmF0b3JMaXN0LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFnZUluZGV4LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FudmFzRmFjdG9yeSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZpbHRlckZhY3RvcnksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB1c2VSZXF1ZXN0QW5pbWF0aW9uRnJhbWUgPSBmYWxzZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBkZkJ1ZyA9IGZhbHNlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFnZUNvbG9ycyA9IG51bGwKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IF9yZWYxMzsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jYWxsYmFjayA9IGNhbGxiYWNrOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBhcmFtcyA9IHBhcmFtczsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5vYmpzID0gb2JqczsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb21tb25PYmpzID0gY29tbW9uT2JqczsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5hbm5vdGF0aW9uQ2FudmFzTWFwID0gYW5ub3RhdGlvbkNhbnZhc01hcDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5vcGVyYXRvckxpc3RJZHggPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm9wZXJhdG9yTGlzdCA9IG9wZXJhdG9yTGlzdDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcGFnZUluZGV4ID0gcGFnZUluZGV4OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbnZhc0ZhY3RvcnkgPSBjYW52YXNGYWN0b3J5OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmZpbHRlckZhY3RvcnkgPSBmaWx0ZXJGYWN0b3J5OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wZGZCdWcgPSBwZGZCdWc7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGFnZUNvbG9ycyA9IHBhZ2VDb2xvcnM7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucnVubmluZyA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmdyYXBoaWNzUmVhZHlDYWxsYmFjayA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZ3JhcGhpY3NSZWFkeSA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl91c2VSZXF1ZXN0QW5pbWF0aW9uRnJhbWUgPSB1c2VSZXF1ZXN0QW5pbWF0aW9uRnJhbWUgPT09IHRydWUgJiYgdHlwZW9mIHdpbmRvdyAhPT0gInVuZGVmaW5lZCI7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2FuY2VsbGVkID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2FwYWJpbGl0eSA9ICgwLCBfdXRpbC5jcmVhdGVQcm9taXNlQ2FwYWJpbGl0eSkoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy50YXNrID0gbmV3IFJlbmRlclRhc2sodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NhbmNlbEJvdW5kID0gdGhpcy5jYW5jZWwuYmluZCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fY29udGludWVCb3VuZCA9IHRoaXMuX2NvbnRpbnVlLmJpbmQodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3NjaGVkdWxlTmV4dEJvdW5kID0gdGhpcy5fc2NoZWR1bGVOZXh0LmJpbmQodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX25leHRCb3VuZCA9IHRoaXMuX25leHQuYmluZCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fY2FudmFzID0gcGFyYW1zLmNhbnZhc0NvbnRleHQuY2FudmFzOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgY29tcGxldGVkKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5jYXBhYmlsaXR5LnByb21pc2UuY2F0Y2goZnVuY3Rpb24gKCkge30pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBpbml0aWFsaXplR3JhcGhpY3MoX3JlZjE0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfZ2xvYmFsVGhpcyRTdGVwcGVyTWEsIF90aGlzJGdyYXBoaWNzUmVhZHlDYTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRyYW5zcGFyZW5jeSA9IGZhbHNlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgb3B0aW9uYWxDb250ZW50Q29uZmlnCiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBfcmVmMTQ7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmNhbmNlbGxlZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl9jYW52YXMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChJbnRlcm5hbFJlbmRlclRhc2suI2NhbnZhc0luVXNlLmhhcyh0aGlzLl9jYW52YXMpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCJDYW5ub3QgdXNlIHRoZSBzYW1lIGNhbnZhcyBkdXJpbmcgbXVsdGlwbGUgcmVuZGVyKCkgb3BlcmF0aW9ucy4gIiArICJVc2UgZGlmZmVyZW50IGNhbnZhcyBvciBlbnN1cmUgcHJldmlvdXMgb3BlcmF0aW9ucyB3ZXJlICIgKyAiY2FuY2VsbGVkIG9yIGNvbXBsZXRlZC4iKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIEludGVybmFsUmVuZGVyVGFzay4jY2FudmFzSW5Vc2UuYWRkKHRoaXMuX2NhbnZhcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuX3BkZkJ1ZyAmJiAoX2dsb2JhbFRoaXMkU3RlcHBlck1hID0gZ2xvYmFsVGhpcy5TdGVwcGVyTWFuYWdlcikgIT09IG51bGwgJiYgX2dsb2JhbFRoaXMkU3RlcHBlck1hICE9PSB2b2lkIDAgJiYgX2dsb2JhbFRoaXMkU3RlcHBlck1hLmVuYWJsZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc3RlcHBlciA9IGdsb2JhbFRoaXMuU3RlcHBlck1hbmFnZXIuY3JlYXRlKHRoaXMuX3BhZ2VJbmRleCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnN0ZXBwZXIuaW5pdCh0aGlzLm9wZXJhdG9yTGlzdCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnN0ZXBwZXIubmV4dEJyZWFrUG9pbnQgPSB0aGlzLnN0ZXBwZXIuZ2V0TmV4dEJyZWFrUG9pbnQoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYW52YXNDb250ZXh0LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmlld3BvcnQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cmFuc2Zvcm0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBiYWNrZ3JvdW5kCiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSB0aGlzLnBhcmFtczsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5nZnggPSBuZXcgX2NhbnZhcy5DYW52YXNHcmFwaGljcyhjYW52YXNDb250ZXh0LCB0aGlzLmNvbW1vbk9ianMsIHRoaXMub2JqcywgdGhpcy5jYW52YXNGYWN0b3J5LCB0aGlzLmZpbHRlckZhY3RvcnksIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9wdGlvbmFsQ29udGVudENvbmZpZwogICAgICAgICAgICAgICAgICAgICAgICB9LCB0aGlzLmFubm90YXRpb25DYW52YXNNYXApOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmdmeC5iZWdpbkRyYXdpbmcoewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJhbnNmb3JtLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmlld3BvcnQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cmFuc3BhcmVuY3ksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBiYWNrZ3JvdW5kCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm9wZXJhdG9yTGlzdElkeCA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZ3JhcGhpY3NSZWFkeSA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIChfdGhpcyRncmFwaGljc1JlYWR5Q2EgPSB0aGlzLmdyYXBoaWNzUmVhZHlDYWxsYmFjaykgPT09IG51bGwgfHwgX3RoaXMkZ3JhcGhpY3NSZWFkeUNhID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRncmFwaGljc1JlYWR5Q2EuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY2FuY2VsKCkgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkZ2Z4OwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgZXJyb3IgPSBhcmd1bWVudHMubGVuZ3RoID4gMCAmJiBhcmd1bWVudHNbMF0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1swXSA6IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBleHRyYURlbGF5ID0gYXJndW1lbnRzLmxlbmd0aCA+IDEgJiYgYXJndW1lbnRzWzFdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMV0gOiAwOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnJ1bm5pbmcgPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jYW5jZWxsZWQgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAoX3RoaXMkZ2Z4ID0gdGhpcy5nZngpID09PSBudWxsIHx8IF90aGlzJGdmeCA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3RoaXMkZ2Z4LmVuZERyYXdpbmcodGhpcy5wYWdlQ29sb3JzKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuX2NhbnZhcykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgSW50ZXJuYWxSZW5kZXJUYXNrLiNjYW52YXNJblVzZS5kZWxldGUodGhpcy5fY2FudmFzKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbGxiYWNrKGVycm9yIHx8IG5ldyBfZGlzcGxheV91dGlscy5SZW5kZXJpbmdDYW5jZWxsZWRFeGNlcHRpb24oYFJlbmRlcmluZyBjYW5jZWxsZWQsIHBhZ2UgJHt0aGlzLl9wYWdlSW5kZXggKyAxfWAsICJjYW52YXMiLCBleHRyYURlbGF5KSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIG9wZXJhdG9yTGlzdENoYW5nZWQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRzdGVwcGVyOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuZ3JhcGhpY3NSZWFkeSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLmdyYXBoaWNzUmVhZHlDYWxsYmFjaykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZ3JhcGhpY3NSZWFkeUNhbGxiYWNrID0gdGhpcy5fY29udGludWVCb3VuZDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAoX3RoaXMkc3RlcHBlciA9IHRoaXMuc3RlcHBlcikgPT09IG51bGwgfHwgX3RoaXMkc3RlcHBlciA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3RoaXMkc3RlcHBlci51cGRhdGVPcGVyYXRvckxpc3QodGhpcy5vcGVyYXRvckxpc3QpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5ydW5uaW5nKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fY29udGludWUoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX2NvbnRpbnVlKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnJ1bm5pbmcgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5jYW5jZWxsZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy50YXNrLm9uQ29udGludWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudGFzay5vbkNvbnRpbnVlKHRoaXMuX3NjaGVkdWxlTmV4dEJvdW5kKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3NjaGVkdWxlTmV4dCgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9zY2hlZHVsZU5leHQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl91c2VSZXF1ZXN0QW5pbWF0aW9uRnJhbWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdpbmRvdy5yZXF1ZXN0QW5pbWF0aW9uRnJhbWUoKCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX25leHRCb3VuZCgpLmNhdGNoKHRoaXMuX2NhbmNlbEJvdW5kKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgUHJvbWlzZS5yZXNvbHZlKCkudGhlbih0aGlzLl9uZXh0Qm91bmQpLmNhdGNoKHRoaXMuX2NhbmNlbEJvdW5kKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBhc3luYyBfbmV4dCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuY2FuY2VsbGVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5vcGVyYXRvckxpc3RJZHggPSB0aGlzLmdmeC5leGVjdXRlT3BlcmF0b3JMaXN0KHRoaXMub3BlcmF0b3JMaXN0LCB0aGlzLm9wZXJhdG9yTGlzdElkeCwgdGhpcy5fY29udGludWVCb3VuZCwgdGhpcy5zdGVwcGVyKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMub3BlcmF0b3JMaXN0SWR4ID09PSB0aGlzLm9wZXJhdG9yTGlzdC5hcmdzQXJyYXkubGVuZ3RoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnJ1bm5pbmcgPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLm9wZXJhdG9yTGlzdC5sYXN0Q2h1bmspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmdmeC5lbmREcmF3aW5nKHRoaXMucGFnZUNvbG9ycyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuX2NhbnZhcykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBJbnRlcm5hbFJlbmRlclRhc2suI2NhbnZhc0luVXNlLmRlbGV0ZSh0aGlzLl9jYW52YXMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbGxiYWNrKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjb25zdCB2ZXJzaW9uID0gJzMuNS4xMjInOwogICAgICAgICAgICAgICAgZXhwb3J0cy52ZXJzaW9uID0gdmVyc2lvbjsKICAgICAgICAgICAgICAgIGNvbnN0IGJ1aWxkID0gJzYyMjQ2NWRjMic7CiAgICAgICAgICAgICAgICBleHBvcnRzLmJ1aWxkID0gYnVpbGQ7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDEzOSAqLwogICAgICAgICAgICAvKioqLyAoKF9fdW51c2VkX3dlYnBhY2tfbW9kdWxlLCBleHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKCiAgICAgICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIl9fZXNNb2R1bGUiLCAoewogICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0cnVlCiAgICAgICAgICAgICAgICB9KSk7CiAgICAgICAgICAgICAgICBleHBvcnRzLlByaW50QW5ub3RhdGlvblN0b3JhZ2UgPSBleHBvcnRzLkFubm90YXRpb25TdG9yYWdlID0gdm9pZCAwOwogICAgICAgICAgICAgICAgdmFyIF91dGlsID0gX193X3BkZmpzX3JlcXVpcmVfXygxKTsKICAgICAgICAgICAgICAgIHZhciBfZWRpdG9yID0gX193X3BkZmpzX3JlcXVpcmVfXygx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IiBwcml2YXRlIGZpZWxkIG9uIG5vbi1pbnN0YW5jZSIpOyB9IHJldHVybiBwcml2YXRlTWFwLmdldChyZWNlaXZlcik7IH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9jbGFzc0FwcGx5RGVzY3JpcHRvckdldChyZWNlaXZlciwgZGVzY3JpcHRvcikgeyBpZiAoZGVzY3JpcHRvci5nZXQpIHsgcmV0dXJuIGRlc2NyaXB0b3IuZ2V0LmNhbGwocmVjZWl2ZXIpOyB9IHJldHVybiBkZXNjcmlwdG9yLnZhbHVlOyB9CiAgICAgICAgICAgICAgICB2YXIgX21vZGlmaWVkID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX3N0b3JhZ2UgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfc2V0TW9kaWZpZWQgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIGNsYXNzIEFubm90YXRpb25TdG9yYWdlIHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEluaXRTcGVjKHRoaXMsIF9zZXRNb2RpZmllZCk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9tb2RpZmllZCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogZmFsc2UKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9zdG9yYWdlLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBuZXcgTWFwKCkKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMub25TZXRNb2RpZmllZCA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMub25SZXNldE1vZGlmaWVkID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5vbkFubm90YXRpb25FZGl0b3IgPSBudWxsOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRWYWx1ZShrZXksIGRlZmF1bHRWYWx1ZSkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB2YWx1ZSA9IF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfc3RvcmFnZSkuZ2V0KGtleSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh2YWx1ZSA9PT0gdW5kZWZpbmVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZGVmYXVsdFZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBPYmplY3QuYXNzaWduKGRlZmF1bHRWYWx1ZSwgdmFsdWUpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRSYXdWYWx1ZShrZXkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfc3RvcmFnZSkuZ2V0KGtleSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlbW92ZShrZXkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9zdG9yYWdlKS5kZWxldGUoa2V5KTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfc3RvcmFnZSkuc2l6ZSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5yZXNldE1vZGlmaWVkKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHR5cGVvZiB0aGlzLm9uQW5ub3RhdGlvbkVkaXRvciA9PT0gImZ1bmN0aW9uIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCB2YWx1ZSBvZiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX3N0b3JhZ2UpLnZhbHVlcygpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHZhbHVlIGluc3RhbmNlb2YgX2VkaXRvci5Bbm5vdGF0aW9uRWRpdG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm9uQW5ub3RhdGlvbkVkaXRvcihudWxsKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzZXRWYWx1ZShrZXksIHZhbHVlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG9iaiA9IF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfc3RvcmFnZSkuZ2V0KGtleSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBtb2RpZmllZCA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAob2JqICE9PSB1bmRlZmluZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgW2VudHJ5LCB2YWxdIG9mIE9iamVjdC5lbnRyaWVzKHZhbHVlKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChvYmpbZW50cnldICE9PSB2YWwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbW9kaWZpZWQgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvYmpbZW50cnldID0gdmFsOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1vZGlmaWVkID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfc3RvcmFnZSkuc2V0KGtleSwgdmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChtb2RpZmllZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfc2V0TW9kaWZpZWQsIF9zZXRNb2RpZmllZDIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHZhbHVlIGluc3RhbmNlb2YgX2VkaXRvci5Bbm5vdGF0aW9uRWRpdG9yICYmIHR5cGVvZiB0aGlzLm9uQW5ub3RhdGlvbkVkaXRvciA9PT0gImZ1bmN0aW9uIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5vbkFubm90YXRpb25FZGl0b3IodmFsdWUuY29uc3RydWN0b3IuX3R5cGUpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGhhcyhrZXkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfc3RvcmFnZSkuaGFzKGtleSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldEFsbCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfc3RvcmFnZSkuc2l6ZSA+IDAgPyAoMCwgX3V0aWwub2JqZWN0RnJvbU1hcCkoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9zdG9yYWdlKSkgOiBudWxsOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzZXRBbGwob2JqKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgW2tleSwgdmFsXSBvZiBPYmplY3QuZW50cmllcyhvYmopKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNldFZhbHVlKGtleSwgdmFsKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgc2l6ZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfc3RvcmFnZSkuc2l6ZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmVzZXRNb2RpZmllZCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfbW9kaWZpZWQpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX21vZGlmaWVkLCBmYWxzZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIHRoaXMub25SZXNldE1vZGlmaWVkID09PSAiZnVuY3Rpb24iKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5vblJlc2V0TW9kaWZpZWQoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgcHJpbnQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgUHJpbnRBbm5vdGF0aW9uU3RvcmFnZSh0aGlzKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IHNlcmlhbGl6YWJsZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfc3RvcmFnZSkuc2l6ZSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2xvbmUgPSBuZXcgTWFwKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgW2tleSwgdmFsXSBvZiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX3N0b3JhZ2UpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzZXJpYWxpemVkID0gdmFsIGluc3RhbmNlb2YgX2VkaXRvci5Bbm5vdGF0aW9uRWRpdG9yID8gdmFsLnNlcmlhbGl6ZSgpIDogdmFsOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHNlcmlhbGl6ZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZS5zZXQoa2V5LCBzZXJpYWxpemVkKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gY2xvbmU7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBnZXRIYXNoKG1hcCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIW1hcCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICIiOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGhhc2ggPSBuZXcgX211cm11cmhhc2guTXVybXVySGFzaDNfNjQoKTsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBba2V5LCB2YWxdIG9mIG1hcCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaGFzaC51cGRhdGUoYCR7a2V5fToke0pTT04uc3RyaW5naWZ5KHZhbCl9YCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGhhc2guaGV4ZGlnZXN0KCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5Bbm5vdGF0aW9uU3RvcmFnZSA9IEFubm90YXRpb25TdG9yYWdlOwogICAgICAgICAgICAgICAgZnVuY3Rpb24gX3NldE1vZGlmaWVkMigpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoIV9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfbW9kaWZpZWQpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfbW9kaWZpZWQsIHRydWUpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIHRoaXMub25TZXRNb2RpZmllZCA9PT0gImZ1bmN0aW9uIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5vblNldE1vZGlmaWVkKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBQcmludEFubm90YXRpb25TdG9yYWdlIGV4dGVuZHMgQW5ub3RhdGlvblN0b3JhZ2UgewogICAgICAgICAgICAgICAgICAgICNzZXJpYWxpemFibGUgPSBudWxsOwogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKHBhcmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICBzdXBlcigpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLiNzZXJpYWxpemFibGUgPSBzdHJ1Y3R1cmVkQ2xvbmUocGFyZW50LnNlcmlhbGl6YWJsZSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBwcmludCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLnVucmVhY2hhYmxlKSgiU2hvdWxkIG5vdCBjYWxsIFByaW50QW5ub3RhdGlvblN0b3JhZ2UucHJpbnQiKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IHNlcmlhbGl6YWJsZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuI3NlcmlhbGl6YWJsZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLlByaW50QW5ub3RhdGlvblN0b3JhZ2UgPSBQcmludEFubm90YXRpb25TdG9yYWdlOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxNDAgKi8KICAgICAgICAgICAgLyoqKi8gKChfX3VudXNlZF93ZWJwYWNrX21vZHVsZSwgZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgICJ1c2Ugc3RyaWN0IjsKCgogICAgICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJfX2VzTW9kdWxlIiwgKHsKICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdHJ1ZQogICAgICAgICAgICAgICAgfSkpOwogICAgICAgICAgICAgICAgZXhwb3J0cy5Bbm5vdGF0aW9uRWRpdG9yID0gdm9pZCAwOwogICAgICAgICAgICAgICAgdmFyIF90b29scyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTQxKTsKICAgICAgICAgICAgICAgIHZhciBfdXRpbCA9IF9fd19wZGZqc19yZXF1aXJlX18oMSk7CiAgICAgICAgICAgICAgICBjbGFzcyBBbm5vdGF0aW9uRWRpdG9yIHsKICAgICAgICAgICAgICAgICAgICAjYm91bmRGb2N1c2luID0gdGhpcy5mb2N1c2luLmJpbmQodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgI2JvdW5kRm9jdXNvdXQgPSB0aGlzLmZvY3Vzb3V0LmJpbmQodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgI2hhc0JlZW5TZWxlY3RlZCA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICNpc0VkaXRpbmcgPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAjaXNJbkVkaXRNb2RlID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgX3VpTWFuYWdlciA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgI3pJbmRleCA9IEFubm90YXRpb25FZGl0b3IuX3pJbmRleCsrOwogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBfY29sb3JNYW5hZ2VyID0gbmV3IF90b29scy5Db2xvck1hbmFnZXIoKTsKICAgICAgICAgICAgICAgICAgICBzdGF0aWMgX3pJbmRleCA9IDE7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IocGFyYW1ldGVycykgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5jb25zdHJ1Y3RvciA9PT0gQW5ub3RhdGlvbkVkaXRvcikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLnVucmVhY2hhYmxlKSgiQ2Fubm90IGluaXRpYWxpemUgQW5ub3RhdGlvbkVkaXRvci4iKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBhcmVudCA9IHBhcmFtZXRlcnMucGFyZW50OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmlkID0gcGFyYW1ldGVycy5pZDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy53aWR0aCA9IHRoaXMuaGVpZ2h0ID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wYWdlSW5kZXggPSBwYXJhbWV0ZXJzLnBhcmVudC5wYWdlSW5kZXg7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubmFtZSA9IHBhcmFtZXRlcnMubmFtZTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXYgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl91aU1hbmFnZXIgPSBwYXJhbWV0ZXJzLnVpTWFuYWdlcjsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcm90YXRpb24sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICByYXdEaW1zOiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFnZVdpZHRoLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2VIZWlnaHQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFnZVgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFnZVkKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfSA9IHRoaXMucGFyZW50LnZpZXdwb3J0OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnJvdGF0aW9uID0gcm90YXRpb247CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGFnZURpbWVuc2lvbnMgPSBbcGFnZVdpZHRoLCBwYWdlSGVpZ2h0XTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wYWdlVHJhbnNsYXRpb24gPSBbcGFnZVgsIHBhZ2VZXTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgW3dpZHRoLCBoZWlnaHRdID0gdGhpcy5wYXJlbnREaW1lbnNpb25zOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnggPSBwYXJhbWV0ZXJzLnggLyB3aWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy55ID0gcGFyYW1ldGVycy55IC8gaGVpZ2h0OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmlzQXR0YWNoZWRUb0RPTSA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzdGF0aWMgZ2V0IF9kZWZhdWx0TGluZUNvbG9yKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gKDAsIF91dGlsLnNoYWRvdykodGhpcywgIl9kZWZhdWx0TGluZUNvbG9yIiwgdGhpcy5fY29sb3JNYW5hZ2VyLmdldEhleENvZGUoIkNhbnZhc1RleHQiKSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGFkZENvbW1hbmRzKHBhcmFtcykgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl91aU1hbmFnZXIuYWRkQ29tbWFuZHMocGFyYW1zKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IGN1cnJlbnRMYXllcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX3VpTWFuYWdlci5jdXJyZW50TGF5ZXI7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNldEluQmFja2dyb3VuZCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXYuc3R5bGUuekluZGV4ID0gMDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2V0SW5Gb3JlZ3JvdW5kKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdi5zdHlsZS56SW5kZXggPSB0aGlzLiN6SW5kZXg7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNldFBhcmVudChwYXJlbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHBhcmVudCAhPT0gbnVsbCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wYWdlSW5kZXggPSBwYXJlbnQucGFnZUluZGV4OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wYWdlRGltZW5zaW9ucyA9IHBhcmVudC5wYWdlRGltZW5zaW9uczsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBhcmVudCA9IHBhcmVudDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZm9jdXNpbihldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuI2hhc0JlZW5TZWxlY3RlZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wYXJlbnQuc2V0U2VsZWN0ZWQodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLiNoYXNCZWVuU2VsZWN0ZWQgPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBmb2N1c291dChldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkcGFyZW50OwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuaXNBdHRhY2hlZFRvRE9NKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdGFyZ2V0ID0gZXZlbnQucmVsYXRlZFRhcmdldDsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRhcmdldCAhPT0gbnVsbCAmJiB0YXJnZXQgIT09IHZvaWQgMCAmJiB0YXJnZXQuY2xvc2VzdChgIyR7dGhpcy5pZH1gKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGV2ZW50LnByZXZlbnREZWZhdWx0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghKChfdGhpcyRwYXJlbnQgPSB0aGlzLnBhcmVudCkgIT09IG51bGwgJiYgX3RoaXMkcGFyZW50ICE9PSB2b2lkIDAgJiYgX3RoaXMkcGFyZW50LmlzTXVsdGlwbGVTZWxlY3Rpb24pKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbW1pdE9yUmVtb3ZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY29tbWl0T3JSZW1vdmUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmlzRW1wdHkoKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5yZW1vdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29tbWl0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY29tbWl0KCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmFkZFRvQW5ub3RhdGlvblN0b3JhZ2UoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYWRkVG9Bbm5vdGF0aW9uU3RvcmFnZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fdWlNYW5hZ2VyLmFkZFRvQW5ub3RhdGlvblN0b3JhZ2UodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGRyYWdzdGFydChldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByZWN0ID0gdGhpcy5wYXJlbnQuZGl2LmdldEJvdW5kaW5nQ2xpZW50UmVjdCgpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnN0YXJ0WCA9IGV2ZW50LmNsaWVudFggLSByZWN0Lng7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc3RhcnRZID0gZXZlbnQuY2xpZW50WSAtIHJlY3QueTsKICAgICAgICAgICAgICAgICAgICAgICAgZXZlbnQuZGF0YVRyYW5zZmVyLnNldERhdGEoInRleHQvcGxhaW4iLCB0aGlzLmlkKTsKICAgICAgICAgICAgICAgICAgICAgICAgZXZlbnQuZGF0YVRyYW5zZmVyLmVmZmVjdEFsbG93ZWQgPSAibW92ZSI7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNldEF0KHgsIHksIHR4LCB0eSkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBbd2lkdGgsIGhlaWdodF0gPSB0aGlzLnBhcmVudERpbWVuc2lvbnM7CiAgICAgICAgICAgICAgICAgICAgICAgIFt0eCwgdHldID0gdGhpcy5zY3JlZW5Ub1BhZ2VUcmFuc2xhdGlvbih0eCwgdHkpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnggPSAoeCArIHR4KSAvIHdpZHRoOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnkgPSAoeSArIHR5KSAvIGhlaWdodDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXYuc3R5bGUubGVmdCA9IGAkezEwMCAqIHRoaXMueH0lYDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXYuc3R5bGUudG9wID0gYCR7MTAwICogdGhpcy55fSVgOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB0cmFuc2xhdGUoeCwgeSkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBbd2lkdGgsIGhlaWdodF0gPSB0aGlzLnBhcmVudERpbWVuc2lvbnM7CiAgICAgICAgICAgICAgICAgICAgICAgIFt4LCB5XSA9IHRoaXMuc2NyZWVuVG9QYWdlVHJhbnNsYXRpb24oeCwgeSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMueCArPSB4IC8gd2lkdGg7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMueSArPSB5IC8gaGVpZ2h0OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdi5zdHlsZS5sZWZ0ID0gYCR7MTAwICogdGhpcy54fSVgOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdi5zdHlsZS50b3AgPSBgJHsxMDAgKiB0aGlzLnl9JWA7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNjcmVlblRvUGFnZVRyYW5zbGF0aW9uKHgsIHkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3dpdGNoICh0aGlzLnBhcmVudFJvdGF0aW9uKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIDkwOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbeSwgLXhdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAxODA6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFsteCwgLXldOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAyNzA6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFsteSwgeF07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbeCwgeV07CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IHBhcmVudFNjYWxlKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fdWlNYW5hZ2VyLnZpZXdQYXJhbWV0ZXJzLnJlYWxTY2FsZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IHBhcmVudFJvdGF0aW9uKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fdWlNYW5hZ2VyLnZpZXdQYXJhbWV0ZXJzLnJvdGF0aW9uOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgcGFyZW50RGltZW5zaW9ucygpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVhbFNjYWxlCiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSB0aGlzLl91aU1hbmFnZXIudmlld1BhcmFtZXRlcnM7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IFtwYWdlV2lkdGgsIHBhZ2VIZWlnaHRdID0gdGhpcy5wYWdlRGltZW5zaW9uczsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFtwYWdlV2lkdGggKiByZWFsU2NhbGUsIHBhZ2VIZWlnaHQgKiByZWFsU2NhbGVdOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzZXREaW1zKHdpZHRoLCBoZWlnaHQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgW3BhcmVudFdpZHRoLCBwYXJlbnRIZWlnaHRdID0gdGhpcy5wYXJlbnREaW1lbnNpb25zOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdi5zdHlsZS53aWR0aCA9IGAkezEwMCAqIHdpZHRoIC8gcGFyZW50V2lkdGh9JWA7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LnN0eWxlLmhlaWdodCA9IGAkezEwMCAqIGhlaWdodCAvIHBhcmVudEhlaWdodH0lYDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZml4RGltcygpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3R5bGUKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IHRoaXMuZGl2OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoZWlnaHQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3aWR0aAogICAgICAgICAgICAgICAgICAgICAgICB9ID0gc3R5bGU7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHdpZHRoUGVyY2VudCA9IHdpZHRoLmVuZHNXaXRoKCIlIik7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGhlaWdodFBlcmNlbnQgPSBoZWlnaHQuZW5kc1dpdGgoIiUiKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHdpZHRoUGVyY2VudCAmJiBoZWlnaHRQZXJjZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgW3BhcmVudFdpZHRoLCBwYXJlbnRIZWlnaHRdID0gdGhpcy5wYXJlbnREaW1lbnNpb25zOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXdpZHRoUGVyY2VudCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3R5bGUud2lkdGggPSBgJHsxMDAgKiBwYXJzZUZsb2F0KHdpZHRoKSAvIHBhcmVudFdpZHRofSVgOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghaGVpZ2h0UGVyY2VudCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3R5bGUuaGVpZ2h0ID0gYCR7MTAwICogcGFyc2VGbG9hdChoZWlnaHQpIC8gcGFyZW50SGVpZ2h0fSVgOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldEluaXRpYWxUcmFuc2xhdGlvbigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFswLCAwXTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmVuZGVyKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdiA9IGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoImRpdiIpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdi5zZXRBdHRyaWJ1dGUoImRhdGEtZWRpdG9yLXJvdGF0aW9uIiwgKDM2MCAtIHRoaXMucm90YXRpb24pICUgMzYwKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXYuY2xhc3NOYW1lID0gdGhpcy5uYW1lOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdi5zZXRBdHRyaWJ1dGUoImlkIiwgdGhpcy5pZCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LnNldEF0dHJpYnV0ZSgidGFiSW5kZXgiLCAwKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRJbkZvcmVncm91bmQoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXYuYWRkRXZlbnRMaXN0ZW5lcigiZm9jdXNpbiIsIHRoaXMuI2JvdW5kRm9jdXNpbik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LmFkZEV2ZW50TGlzdGVuZXIoImZvY3Vzb3V0IiwgdGhpcy4jYm91bmRGb2N1c291dCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IFt0eCwgdHldID0gdGhpcy5nZXRJbml0aWFsVHJhbnNsYXRpb24oKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy50cmFuc2xhdGUodHgsIHR5KTsKICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF90b29scy5iaW5kRXZlbnRzKSh0aGlzLCB0aGlzLmRpdiwgWyJkcmFnc3RhcnQiLCAicG9pbnRlcmRvd24iXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLmRpdjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcG9pbnRlcmRvd24oZXZlbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNNYWMKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IF91dGlsLkZlYXR1cmVUZXN0LnBsYXRmb3JtOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZXZlbnQuYnV0dG9uICE9PSAwIHx8IGV2ZW50LmN0cmxLZXkgJiYgaXNNYWMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGV2ZW50LnByZXZlbnREZWZhdWx0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGV2ZW50LmN0cmxLZXkgJiYgIWlzTWFjIHx8IGV2ZW50LnNoaWZ0S2V5IHx8IGV2ZW50Lm1ldGFLZXkgJiYgaXNNYWMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGFyZW50LnRvZ2dsZVNlbGVjdGVkKHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wYXJlbnQuc2V0U2VsZWN0ZWQodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy4jaGFzQmVlblNlbGVjdGVkID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0UmVjdCh0eCwgdHkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2NhbGUgPSB0aGlzLnBhcmVudFNjYWxlOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBbcGFnZVdpZHRoLCBwYWdlSGVpZ2h0XSA9IHRoaXMucGFnZURpbWVuc2lvbnM7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IFtwYWdlWCwgcGFnZVldID0gdGhpcy5wYWdlVHJhbnNsYXRpb247CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHNoaWZ0WCA9IHR4IC8gc2NhbGU7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHNoaWZ0WSA9IHR5IC8gc2NhbGU7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHggPSB0aGlzLnggKiBwYWdlV2lkdGg7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHkgPSB0aGlzLnkgKiBwYWdlSGVpZ2h0OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB3aWR0aCA9IHRoaXMud2lkdGggKiBwYWdlV2lkdGg7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGhlaWdodCA9IHRoaXMuaGVpZ2h0ICogcGFnZUhlaWdodDsKICAgICAgICAgICAgICAgICAgICAgICAgc3dpdGNoICh0aGlzLnJvdGF0aW9uKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIDA6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFt4ICsgc2hpZnRYICsgcGFnZVgsIHBhZ2VIZWlnaHQgLSB5IC0gc2hpZnRZIC0gaGVpZ2h0ICsgcGFnZVksIHggKyBzaGlmdFggKyB3aWR0aCArIHBhZ2VYLCBwYWdlSGVpZ2h0IC0geSAtIHNoaWZ0WSArIHBhZ2VZXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgOTA6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFt4ICsgc2hpZnRZICsgcGFnZVgsIHBhZ2VIZWlnaHQgLSB5ICsgc2hpZnRYICsgcGFnZVksIHggKyBzaGlmdFkgKyBoZWlnaHQgKyBwYWdlWCwgcGFnZUhlaWdodCAtIHkgKyBzaGlmdFggKyB3aWR0aCArIHBhZ2VZXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgMTgwOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbeCAtIHNoaWZ0WCAtIHdpZHRoICsgcGFnZVgsIHBhZ2VIZWlnaHQgLSB5ICsgc2hpZnRZICsgcGFnZVksIHggLSBzaGlmdFggKyBwYWdlWCwgcGFnZUhlaWdodCAtIHkgKyBzaGlmdFkgKyBoZWlnaHQgKyBwYWdlWV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIDI3MDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gW3ggLSBzaGlmdFkgLSBoZWlnaHQgKyBwYWdlWCwgcGFnZUhlaWdodCAtIHkgLSBzaGlmdFggLSB3aWR0aCArIHBhZ2VZLCB4IC0gc2hpZnRZICsgcGFnZVgsIHBhZ2VIZWlnaHQgLSB5IC0gc2hpZnRYICsgcGFnZVldOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoIkludmFsaWQgcm90YXRpb24iKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRSZWN0SW5DdXJyZW50Q29vcmRzKHJlY3QsIHBhZ2VIZWlnaHQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgW3gxLCB5MSwgeDIsIHkyXSA9IHJlY3Q7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHdpZHRoID0geDIgLSB4MTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaGVpZ2h0ID0geTIgLSB5MTsKICAgICAgICAgICAgICAgICAgICAgICAgc3dpdGNoICh0aGlzLnJvdGF0aW9uKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIDA6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFt4MSwgcGFnZUhlaWdodCAtIHkyLCB3aWR0aCwgaGVpZ2h0XTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgOTA6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFt4MSwgcGFnZUhlaWdodCAtIHkxLCBoZWlnaHQsIHdpZHRoXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgMTgwOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbeDIsIHBhZ2VIZWlnaHQgLSB5MSwgd2lkdGgsIGhlaWdodF07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIDI3MDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gW3gyLCBwYWdlSGVpZ2h0IC0geTIsIGhlaWdodCwgd2lkdGhdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoIkludmFsaWQgcm90YXRpb24iKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBvbmNlQWRkZWQoKSB7fQogICAgICAgICAgICAgICAgICAgIGlzRW1wdHkoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZW5hYmxlRWRpdE1vZGUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuI2lzSW5FZGl0TW9kZSA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGRpc2FibGVFZGl0TW9kZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy4jaXNJbkVkaXRNb2RlID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlzSW5FZGl0TW9kZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuI2lzSW5FZGl0TW9kZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2hvdWxkR2V0S2V5Ym9hcmRFdmVudHMoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgbmVlZHNUb0JlUmVidWlsdCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuZGl2ICYmICF0aGlzLmlzQXR0YWNoZWRUb0RPTTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmVidWlsZCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF90aGlzJGRpdjsKICAgICAgICAgICAgICAgICAgICAgICAgKF90aGlzJGRpdiA9IHRoaXMuZGl2KSA9PT0gbnVsbCB8fCBfdGhpcyRkaXYgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF90aGlzJGRpdi5hZGRFdmVudExpc3RlbmVyKCJmb2N1c2luIiwgdGhpcy4jYm91bmRGb2N1c2luKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2VyaWFsaXplKCkgewogICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwudW5yZWFjaGFibGUpKCJBbiBlZGl0b3IgbXVzdCBiZSBzZXJpYWxpemFibGUiKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIGRlc2VyaWFsaXplKGRhdGEsIHBhcmVudCwgdWlNYW5hZ2VyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGVkaXRvciA9IG5ldyB0aGlzLnByb3RvdHlwZS5jb25zdHJ1Y3Rvcih7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYXJlbnQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZDogcGFyZW50LmdldE5leHRJZCgpLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdWlNYW5hZ2VyCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3Iucm90YXRpb24gPSBkYXRhLnJvdGF0aW9uOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBbcGFnZVdpZHRoLCBwYWdlSGVpZ2h0XSA9IGVkaXRvci5wYWdlRGltZW5zaW9uczsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgW3gsIHksIHdpZHRoLCBoZWlnaHRdID0gZWRpdG9yLmdldFJlY3RJbkN1cnJlbnRDb29yZHMoZGF0YS5yZWN0LCBwYWdlSGVpZ2h0KTsKICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9yLnggPSB4IC8gcGFnZVdpZHRoOwogICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3IueSA9IHkgLyBwYWdlSGVpZ2h0OwogICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3Iud2lkdGggPSB3aWR0aCAvIHBhZ2VXaWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9yLmhlaWdodCA9IGhlaWdodCAvIHBhZ2VIZWlnaHQ7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBlZGl0b3I7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlbW92ZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXYucmVtb3ZlRXZlbnRMaXN0ZW5lcigiZm9jdXNpbiIsIHRoaXMuI2JvdW5kRm9jdXNpbik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LnJlbW92ZUV2ZW50TGlzdGVuZXIoImZvY3Vzb3V0IiwgdGhpcy4jYm91bmRGb2N1c291dCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5pc0VtcHR5KCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29tbWl0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wYXJlbnQucmVtb3ZlKHRoaXMpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzZWxlY3QoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRkaXYyOwogICAgICAgICAgICAgICAgICAgICAgICAoX3RoaXMkZGl2MiA9IHRoaXMuZGl2KSA9PT0gbnVsbCB8fCBfdGhpcyRkaXYyID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRkaXYyLmNsYXNzTGlzdC5hZGQoInNlbGVjdGVkRWRpdG9yIik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHVuc2VsZWN0KCkgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkZGl2MzsKICAgICAgICAgICAgICAgICAgICAgICAgKF90aGlzJGRpdjMgPSB0aGlzLmRpdikgPT09IG51bGwgfHwgX3RoaXMkZGl2MyA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3RoaXMkZGl2My5jbGFzc0xpc3QucmVtb3ZlKCJzZWxlY3RlZEVkaXRvciIpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB1cGRhdGVQYXJhbXModHlwZSwgdmFsdWUpIHt9CiAgICAgICAgICAgICAgICAgICAgZGlzYWJsZUVkaXRpbmcoKSB7fQogICAgICAgICAgICAgICAgICAgIGVuYWJsZUVkaXRpbmcoKSB7fQogICAgICAgICAgICAgICAgICAgIGdldCBwcm9wZXJ0aWVzVG9VcGRhdGUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB7fTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IGNvbnRlbnREaXYoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLmRpdjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IGlzRWRpdGluZygpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuI2lzRWRpdGluZzsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2V0IGlzRWRpdGluZyh2YWx1ZSkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLiNpc0VkaXRpbmcgPSB2YWx1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHZhbHVlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBhcmVudC5zZXRTZWxlY3RlZCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGFyZW50LnNldEFjdGl2ZUVkaXRvcih0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGFyZW50LnNldEFjdGl2ZUVkaXRvcihudWxsKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGV4cG9ydHMuQW5ub3RhdGlvbkVkaXRvciA9IEFubm90YXRpb25FZGl0b3I7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDE0MSAqLwogICAgICAgICAgICAvKioqLyAoKF9fdW51c2VkX3dlYnBhY2tfbW9kdWxlLCBleHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKCiAgICAgICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIl9fZXNNb2R1bGUiLCAoewogICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0cnVlCiAgICAgICAgICAgICAgICB9KSk7CiAgICAgICAgICAgICAgICBleHBvcnRzLktleWJvYXJkTWFuYWdlciA9IGV4cG9ydHMuQ29tbWFuZE1hbmFnZXIgPSBleHBvcnRzLkNvbG9yTWFuYWdlciA9IGV4cG9ydHMuQW5ub3RhdGlvbkVkaXRvclVJTWFuYWdlciA9IHZvaWQgMDsKICAgICAgICAgICAgICAgIGV4cG9ydHMuYmluZEV2ZW50cyA9IGJpbmRFdmVudHM7CiAgICAgICAgICAgICAgICBleHBvcnRzLm9wYWNpdHlUb0hleCA9IG9wYWNpdHlUb0hleDsKICAgICAgICAgICAgICAgIHZhciBfdXRpbCA9IF9fd19wZGZqc19yZXF1aXJlX18oMSk7CiAgICAgICAgICAgICAgICB2YXIgX2Rpc3BsYXlfdXRpbHMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE0Mik7CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfZGVmaW5lUHJvcGVydHkob2JqLCBrZXksIHZhbHVlKSB7IGtleSA9IF90b1Byb3BlcnR5S2V5KGtleSk7IGlmIChrZXkgaW4gb2JqKSB7IE9iamVjdC5kZWZpbmVQcm9wZXJ0eShvYmosIGtleSwgeyB2YWx1ZTogdmFsdWUsIGVudW1lcmFibGU6IHRydWUsIGNvbmZpZ3VyYWJsZTogdHJ1ZSwgd3JpdGFibGU6IHRydWUgfSk7IH0gZWxzZSB7IG9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GNvbnN0IG5hbWUgb2YgbmFtZXMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5hZGRFdmVudExpc3RlbmVyKG5hbWUsIG9ialtuYW1lXS5iaW5kKG9iaikpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIG9wYWNpdHlUb0hleChvcGFjaXR5KSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIE1hdGgucm91bmQoTWF0aC5taW4oMjU1LCBNYXRoLm1heCgxLCAyNTUgKiBvcGFjaXR5KSkpLnRvU3RyaW5nKDE2KS5wYWRTdGFydCgyLCAiMCIpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY2xhc3MgSWRNYW5hZ2VyIHsKICAgICAgICAgICAgICAgICAgICAjaWQgPSAwOwogICAgICAgICAgICAgICAgICAgIGdldElkKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gYCR7X3V0aWwuQW5ub3RhdGlvbkVkaXRvclByZWZpeH0ke3RoaXMuI2lkKyt9YDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBDb21tYW5kTWFuYWdlciB7CiAgICAgICAgICAgICAgICAgICAgI2NvbW1hbmRzID0gW107CiAgICAgICAgICAgICAgICAgICAgI2xvY2tlZCA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICNtYXhTaXplOwogICAgICAgICAgICAgICAgICAgICNwb3NpdGlvbiA9IC0xOwogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKCkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgbWF4U2l6ZSA9IGFyZ3VtZW50cy5sZW5ndGggPiAwICYmIGFyZ3VtZW50c1swXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzBdIDogMTI4OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLiNtYXhTaXplID0gbWF4U2l6ZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYWRkKF9yZWYpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNtZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVuZG8sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtdXN0RXhlYywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHR5cGUgPSBOYU4sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvdmVyd3JpdGVJZlNhbWVUeXBlID0gZmFsc2UsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBrZWVwVW5kbyA9IGZhbHNlCiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBfcmVmOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAobXVzdEV4ZWMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNtZCgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLiNsb2NrZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzYXZlID0gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY21kLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdW5kbywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHR5cGUKICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuI3Bvc2l0aW9uID09PSAtMSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuI2NvbW1hbmRzLmxlbmd0aCA+IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLiNjb21tYW5kcy5sZW5ndGggPSAwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy4jcG9zaXRpb24gPSAwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy4jY29tbWFuZHMucHVzaChzYXZlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAob3ZlcndyaXRlSWZTYW1lVHlwZSAmJiB0aGlzLiNjb21tYW5kc1t0aGlzLiNwb3NpdGlvbl0udHlwZSA9PT0gdHlwZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGtlZXBVbmRvKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2F2ZS51bmRvID0gdGhpcy4jY29tbWFuZHNbdGhpcy4jcG9zaXRpb25dLnVuZG87CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLiNjb21tYW5kc1t0aGlzLiNwb3NpdGlvbl0gPSBzYXZlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG5leHQgPSB0aGlzLiNwb3NpdGlvbiArIDE7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChuZXh0ID09PSB0aGlzLiNtYXhTaXplKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLiNjb21tYW5kcy5zcGxpY2UoMCwgMSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLiNwb3NpdGlvbiA9IG5leHQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAobmV4dCA8IHRoaXMuI2NvbW1hbmRzLmxlbmd0aCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuI2NvbW1hbmRzLnNwbGljZShuZXh0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLiNjb21tYW5kcy5wdXNoKHNhdmUpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB1bmRvKCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy4jcG9zaXRpb24gPT09IC0xKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy4jbG9ja2VkID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy4jY29tbWFuZHNbdGhpcy4jcG9zaXRpb25dLnVuZG8oKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy4jbG9ja2VkID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuI3Bvc2l0aW9uIC09IDE7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlZG8oKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLiNwb3NpdGlvbiA8IHRoaXMuI2NvbW1hbmRzLmxlbmd0aCAtIDEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuI3Bvc2l0aW9uICs9IDE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLiNsb2NrZWQgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy4jY29tbWFuZHNbdGhpcy4jcG9zaXRpb25dLmNtZCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy4jbG9ja2VkID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaGFzU29tZXRoaW5nVG9VbmRvKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy4jcG9zaXRpb24gIT09IC0xOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBoYXNTb21ldGhpbmdUb1JlZG8oKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLiNwb3NpdGlvbiA8IHRoaXMuI2NvbW1hbmRzLmxlbmd0aCAtIDE7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGRlc3Ryb3koKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuI2NvbW1hbmRzID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLkNvbW1hbmRNYW5hZ2VyID0gQ29tbWFuZE1hbmFnZXI7CiAgICAgICAgICAgICAgICB2YXIgX3NlcmlhbGl6ZSA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgY2xhc3MgS2V5Ym9hcmRNYW5hZ2VyIHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcihjYWxsYmFja3MpIHsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEluaXRTcGVjKHRoaXMsIF9zZXJpYWxpemUpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmJ1ZmZlciA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbGxiYWNrcyA9IG5ldyBNYXAoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5hbGxLZXlzID0gbmV3IFNldCgpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc01hYwogICAgICAgICAgICAgICAgICAgICAgICB9ID0gX3V0aWwuRmVhdHVyZVRlc3QucGxhdGZvcm07CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgW2tleXMsIGNhbGxiYWNrXSBvZiBjYWxsYmFja3MpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3Qga2V5IG9mIGtleXMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpc01hY0tleSA9IGtleS5zdGFydHNXaXRoKCJtYWMrIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGlzTWFjICYmIGlzTWFjS2V5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2FsbGJhY2tzLnNldChrZXkuc2xpY2UoNCksIGNhbGxiYWNrKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5hbGxLZXlzLmFkZChrZXkuc3BsaXQoIisiKS5hdCgtMSkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoIWlzTWFjICYmICFpc01hY0tleSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbGxiYWNrcy5zZXQoa2V5LCBjYWxsYmFjayk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYWxsS2V5cy5hZGQoa2V5LnNwbGl0KCIrIikuYXQoLTEpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZXhlYyhzZWxmLCBldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuYWxsS2V5cy5oYXMoZXZlbnQua2V5KSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNhbGxiYWNrID0gdGhpcy5jYWxsYmFja3MuZ2V0KF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3NlcmlhbGl6ZSwgX3NlcmlhbGl6ZTIpLmNhbGwodGhpcywgZXZlbnQpKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFjYWxsYmFjaykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNhbGxiYWNrLmJpbmQoc2VsZikoKTsKICAgICAgICAgICAgICAgICAgICAgICAgZXZlbnQuc3RvcFByb3BhZ2F0aW9uKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGV2ZW50LnByZXZlbnREZWZhdWx0KCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5LZXlib2FyZE1hbmFnZXIgPSBLZXlib2FyZE1hbmFnZXI7CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfc2VyaWFsaXplMihldmVudCkgewogICAgICAgICAgICAgICAgICAgIGlmIChldmVudC5hbHRLZXkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5idWZmZXIucHVzaCgiYWx0Iik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmIChldmVudC5jdHJsS2V5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYnVmZmVyLnB1c2goImN0cmwiKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaWYgKGV2ZW50Lm1ldGFLZXkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5idWZmZXIucHVzaCgibWV0YSIpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBpZiAoZXZlbnQuc2hpZnRLZXkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5idWZmZXIucHVzaCgic2hpZnQiKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdGhpcy5idWZmZXIucHVzaChldmVudC5rZXkpOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0ciA9IHRoaXMuYnVmZmVyLmpvaW4oIisiKTsKICAgICAgICAgICAgICAgICAgICB0aGlzLmJ1ZmZlci5sZW5ndGggPSAwOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBzdHI7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBDb2xvck1hbmFnZXIgewogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBfY29sb3JzTWFwcGluZyA9IG5ldyBNYXAoW1siQ2FudmFzVGV4dCIsIFswLCAwLCAwXV0sIFsiQ2FudmFzIiwgWzI1NSwgMjU1LCAyNTVdXV0pOwogICAgICAgICAgICAgICAgICAgIGdldCBfY29sb3JzKCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjb2xvcnMgPSBuZXcgTWFwKFtbIkNhbnZhc1RleHQiLCBudWxsXSwgWyJDYW52YXMiLCBudWxsXV0pOwogICAgICAgICAgICAgICAgICAgICAgICAoMCwgX2Rpc3BsYXlfdXRpbHMuZ2V0Q29sb3JWYWx1ZXMpKGNvbG9ycyk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAoMCwgX3V0aWwuc2hhZG93KSh0aGlzLCAiX2NvbG9ycyIsIGNvbG9ycyk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNvbnZlcnQoY29sb3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmdiID0gKDAsIF9kaXNwbGF5X3V0aWxzLmdldFJHQikoY29sb3IpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXdpbmRvdy5tYXRjaE1lZGlhKCIoZm9yY2VkLWNvbG9yczogYWN0aXZlKSIpLm1hdGNoZXMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiByZ2I7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBbbmFtZSwgUkdCXSBvZiB0aGlzLl9jb2xvcnMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChSR0IuZXZlcnkoKHgsIGkpID0+IHggPT09IHJnYltpXSkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gQ29sb3JNYW5hZ2VyLl9jb2xvcnNNYXBwaW5nLmdldChuYW1lKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gcmdiOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRIZXhDb2RlKG5hbWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmdiID0gdGhpcy5fY29sb3JzLmdldChuYW1lKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFyZ2IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuYW1lOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBfdXRpbC5VdGlsLm1ha2VIZXhDb2xvciguLi5yZ2IpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGV4cG9ydHMuQ29sb3JNYW5hZ2VyID0gQ29sb3JNYW5hZ2VyOwogICAgICAgICAgICAgICAgdmFyIF9hY3RpdmVFZGl0b3IgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfYWxsRWRpdG9ycyA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9hbGxMYXllcnMgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfYW5ub3RhdGlvblN0b3JhZ2UgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfY29tbWFuZE1hbmFnZXIgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfY3VycmVudFBhZ2VJbmRleCA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9lZGl0b3JUeXBlcyA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9lZGl0b3JzVG9SZXNjYWxlID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2V2ZW50QnVzID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2lkTWFuYWdlciA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9pc0VuYWJsZWQgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfbW9kZSA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9zZWxlY3RlZEVkaXRvcnMgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfYm91bmRDb3B5ID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2JvdW5kQ3V0ID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2JvdW5kUGFzdGUgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfYm91bmRLZXlkb3duID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2JvdW5kT25FZGl0aW5nQWN0aW9uID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2JvdW5kT25QYWdlQ2hhbmdpbmcgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfYm91bmRPblNjYWxlQ2hhbmdpbmcgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfYm91bmRPblJvdGF0aW9uQ2hhbmdpbmcgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfcHJldmlvdXNTdGF0ZXMgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfY29udGFpbmVyID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2FkZEtleWJvYXJkTWFuYWdlciA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgdmFyIF9yZW1vdmVLZXlib2FyZE1hbmFnZXIgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIHZhciBfYWRkQ29weVBhc3RlTGlzdGVuZXJzID0gLyojX19QVVJFX18qL25ldyBXZWFrU2V0KCk7CiAgICAgICAgICAgICAgICB2YXIgX3JlbW92ZUNvcHlQYXN0ZUxpc3RlbmVycyA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgdmFyIF9kaXNwYXRjaFVwZGF0ZVN0YXRlcyA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgdmFyIF9kaXNwYXRjaFVwZGF0ZVVJID0gLyojX19QVVJFX18qL25ldyBXZWFrU2V0KCk7CiAgICAgICAgICAgICAgICB2YXIgX2VuYWJsZUFsbCA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgdmFyIF9kaXNhYmxlQWxsID0gLyojX19QVVJFX18qL25ldyBXZWFrU2V0KCk7CiAgICAgICAgICAgICAgICB2YXIgX2FkZEVkaXRvclRvTGF5ZXIgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIHZhciBfaXNFbXB0eSA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgdmFyIF9zZWxlY3RFZGl0b3JzID0gLyojX19QVVJFX18qL25ldyBXZWFrU2V0KCk7CiAgICAgICAgICAgICAgICBjbGFzcyBBbm5vdGF0aW9uRWRpdG9yVUlNYW5hZ2VyIHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3Rvcihjb250YWluZXIsIGV2ZW50QnVzLCBhbm5vdGF0aW9uU3RvcmFnZSkgewogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX3NlbGVjdEVkaXRvcnMpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX2lzRW1wdHkpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX2FkZEVkaXRvclRvTGF5ZXIpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX2Rpc2FibGVBbGwpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX2VuYWJsZUFsbCk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfZGlzcGF0Y2hVcGRhdGVVSSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfZGlzcGF0Y2hVcGRhdGVTdGF0ZXMpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX3JlbW92ZUNvcHlQYXN0ZUxpc3RlbmVycyk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfYWRkQ29weVBhc3RlTGlzdGVuZXJzKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEluaXRTcGVjKHRoaXMsIF9yZW1vdmVLZXlib2FyZE1hbmFnZXIpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX2FkZEtleWJvYXJkTWFuYWdlcik7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9hY3RpdmVFZGl0b3IsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IG51bGwKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9hbGxFZGl0b3JzLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBuZXcgTWFwKCkKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9hbGxMYXllcnMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IG5ldyBNYXAoKQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2Fubm90YXRpb25TdG9yYWdlLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBudWxsCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfY29tbWFuZE1hbmFnZXIsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IG5ldyBDb21tYW5kTWFuYWdlcigpCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfY3VycmVudFBhZ2VJbmRleCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogMAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2VkaXRvclR5cGVzLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBudWxsCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfZWRpdG9yc1RvUmVzY2FsZSwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogbmV3IFNldCgpCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfZXZlbnRCdXMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IG51bGwKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9pZE1hbmFnZXIsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IG5ldyBJZE1hbmFnZXIoKQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2lzRW5hYmxlZCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogZmFsc2UKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9tb2RlLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yVHlwZS5OT05FCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfc2VsZWN0ZWRFZGl0b3JzLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBuZXcgU2V0KCkKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9ib3VuZENvcHksIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRoaXMuY29weS5iaW5kKHRoaXMpCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfYm91bmRDdXQsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRoaXMuY3V0LmJpbmQodGhpcykKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9ib3VuZFBhc3RlLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0aGlzLnBhc3RlLmJpbmQodGhpcykKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9ib3VuZEtleWRvd24sIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRoaXMua2V5ZG93bi5iaW5kKHRoaXMpCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfYm91bmRPbkVkaXRpbmdBY3Rpb24sIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRoaXMub25FZGl0aW5nQWN0aW9uLmJpbmQodGhpcykKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9ib3VuZE9uUGFnZUNoYW5naW5nLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0aGlzLm9uUGFnZUNoYW5naW5nLmJpbmQodGhpcykKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9ib3VuZE9uU2NhbGVDaGFuZ2luZywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdGhpcy5vblNjYWxlQ2hhbmdpbmcuYmluZCh0aGlzKQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2JvdW5kT25Sb3RhdGlvbkNoYW5naW5nLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0aGlzLm9uUm90YXRpb25DaGFuZ2luZy5iaW5kKHRoaXMpCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfcHJldmlvdXNTdGF0ZXMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc0VkaXRpbmc6IGZhbHNlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlzRW1wdHk6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaGFzU29tZXRoaW5nVG9VbmRvOiBmYWxzZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBoYXNTb21ldGhpbmdUb1JlZG86IGZhbHNlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGhhc1NlbGVjdGVkRWRpdG9yOiBmYWxzZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2NvbnRhaW5lciwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogbnVsbAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX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ICAgcmVhbFNjYWxlOiBfZGlzcGxheV91dGlscy5QaXhlbHNQZXJJbmNoLlBERl9UT19DU1NfVU5JVFMsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICByb3RhdGlvbjogMAogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBkZXN0cm95KCkgewogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9yZW1vdmVLZXlib2FyZE1hbmFnZXIsIF9yZW1vdmVLZXlib2FyZE1hbmFnZXIyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2V2ZW50QnVzKS5fb2ZmKCJlZGl0aW5nYWN0aW9uIiwgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ib3VuZE9uRWRpdGluZ0FjdGlvbikpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2V2ZW50QnVzKS5fb2ZmKCJwYWdlY2hhbmdpbmciLCBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2JvdW5kT25QYWdlQ2hhbmdpbmcpKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ldmVudEJ1cykuX29mZigic2NhbGVjaGFuZ2luZyIsIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYm91bmRPblNjYWxlQ2hhbmdpbmcpKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ldmVudEJ1cykuX29mZigicm90YXRpb25jaGFuZ2luZyIsIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYm91bmRPblJvdGF0aW9uQ2hhbmdpbmcpKTsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBsYXllciBvZiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2FsbExheWVycykudmFsdWVzKCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxheWVyLmRlc3Ryb3koKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2FsbExheWVycykuY2xlYXIoKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9hbGxFZGl0b3JzKS5jbGVhcigpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2VkaXRvcnNUb1Jlc2NhbGUpLmNsZWFyKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfYWN0aXZlRWRpdG9yLCBudWxsKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9zZWxlY3RlZEVkaXRvcnMpLmNsZWFyKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfY29tbWFuZE1hbmFnZXIpLmRlc3Ryb3koKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgb25QYWdlQ2hhbmdpbmcoX3JlZjIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2VOdW1iZXIKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IF9yZWYyOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX2N1cnJlbnRQYWdlSW5kZXgsIHBhZ2VOdW1iZXIgLSAxKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZm9jdXNNYWluQ29udGFpbmVyKCkgewogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2NvbnRhaW5lcikuZm9jdXMoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYWRkU2hvdWxkUmVzY2FsZShlZGl0b3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9lZGl0b3JzVG9SZXNjYWxlKS5hZGQoZWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmVtb3ZlU2hvdWxkUmVzY2FsZShlZGl0b3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9lZGl0b3JzVG9SZXNjYWxlKS5kZWxldGUoZWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgb25TY2FsZUNoYW5naW5nKF9yZWYzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzY2FsZQogICAgICAgICAgICAgICAgICAgICAgICB9ID0gX3JlZjM7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29tbWl0T3JSZW1vdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy52aWV3UGFyYW1ldGVycy5yZWFsU2NhbGUgPSBzY2FsZSAqIF9kaXNwbGF5X3V0aWxzLlBpeGVsc1BlckluY2guUERGX1RPX0NTU19VTklUUzsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBlZGl0b3Igb2YgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9lZGl0b3JzVG9SZXNjYWxlKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9yLm9uU2NhbGVDaGFuZ2luZygpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIG9uUm90YXRpb25DaGFuZ2luZyhfcmVmNCkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFnZXNSb3RhdGlvbgogICAgICAgICAgICAgICAgICAgICAgICB9ID0gX3JlZjQ7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29tbWl0T3JSZW1vdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy52aWV3UGFyYW1ldGVycy5yb3RhdGlvbiA9IHBhZ2VzUm90YXRpb247CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGFkZFRvQW5ub3RhdGlvblN0b3JhZ2UoZWRpdG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghZWRpdG9yLmlzRW1wdHkoKSAmJiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2Fubm90YXRpb25TdG9yYWdlKSAmJiAhX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9hbm5vdGF0aW9uU3RvcmFnZSkuaGFzKGVkaXRvci5pZCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYW5ub3RhdGlvblN0b3JhZ2UpLnNldFZhbHVlKGVkaXRvci5pZCwgZWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjb3B5KGV2ZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGV2ZW50LnByZXZlbnREZWZhdWx0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2FjdGl2ZUVkaXRvcikpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYWN0aXZlRWRpdG9yKS5jb21taXRPclJlbW92ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5oYXNTZWxlY3Rpb24pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBlZGl0b3JzID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgZWRpdG9yIG9mIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfc2VsZWN0ZWRFZGl0b3JzKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFlZGl0b3IuaXNFbXB0eSgpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9ycy5wdXNoKGVkaXRvci5zZXJpYWxpemUoKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGVkaXRvcnMubGVuZ3RoID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgZXZlbnQuY2xpcGJvYXJkRGF0YS5zZXREYXRhKCJhcHBsaWNhdGlvbi9wZGZqcyIsIEpTT04uc3RyaW5naWZ5KGVkaXRvcnMpKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY3V0KGV2ZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29weShldmVudCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGVsZXRlKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHBhc3RlKGV2ZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGV2ZW50LnByZXZlbnREZWZhdWx0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBkYXRhID0gZXZlbnQuY2xpcGJvYXJkRGF0YS5nZXREYXRhKCJhcHBsaWNhdGlvbi9wZGZqcyIpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWRhdGEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGF0YSA9IEpTT04ucGFyc2UoZGF0YSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGV4KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYHBhc3RlOiAiJHtleC5tZXNzYWdlfSIuYCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFBcnJheS5pc0FycmF5KGRhdGEpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy51bnNlbGVjdEFsbCgpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBsYXllciA9IF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYWxsTGF5ZXJzKS5nZXQoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9jdXJyZW50UGFnZUluZGV4KSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBuZXdFZGl0b3JzID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGVkaXRvciBvZiBkYXRhKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZGVzZXJpYWxpemVkRWRpdG9yID0gbGF5ZXIuZGVzZXJpYWxpemUoZWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWRlc2VyaWFsaXplZEVkaXRvcikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5ld0VkaXRvcnMucHVzaChkZXNlcmlhbGl6ZWRFZGl0b3IpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY21kID0gKCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgZWRpdG9yIG9mIG5ld0VkaXRvcnMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfYWRkRWRpdG9yVG9MYXllciwgX2FkZEVkaXRvclRvTGF5ZXIyKS5jYWxsKHRoaXMsIGVkaXRvcik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3NlbGVjdEVkaXRvcnMsIF9zZWxlY3RFZGl0b3JzMikuY2FsbCh0aGlzLCBuZXdFZGl0b3JzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB1bmRvID0gKCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgZWRpdG9yIG9mIG5ld0VkaXRvcnMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9yLnJlbW92ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmFkZENvbW1hbmRzKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdW5kbywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtdXN0RXhlYzogdHJ1ZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGV4KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYHBhc3RlOiAiJHtleC5tZXNzYWdlfSIuYCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAga2V5ZG93bihldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkZ2V0QWN0aXZlOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoISgoX3RoaXMkZ2V0QWN0aXZlID0gdGhpcy5nZXRBY3RpdmUoKSkgIT09IG51bGwgJiYgX3RoaXMkZ2V0QWN0aXZlICE9PSB2b2lkIDAgJiYgX3RoaXMkZ2V0QWN0aXZlLnNob3VsZEdldEtleWJvYXJkRXZlbnRzKCkpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBBbm5vdGF0aW9uRWRpdG9yVUlNYW5hZ2VyLl9rZXlib2FyZE1hbmFnZXIuZXhlYyh0aGlzLCBldmVudCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgb25FZGl0aW5nQWN0aW9uKGRldGFpbHMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKFsidW5kbyIsICJyZWRvIiwgImRlbGV0ZSIsICJzZWxlY3RBbGwiXS5pbmNsdWRlcyhkZXRhaWxzLm5hbWUpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzW2RldGFpbHMubmFtZV0oKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzZXRFZGl0aW5nU3RhdGUoaXNFZGl0aW5nKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpc0VkaXRpbmcpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2FkZEtleWJvYXJkTWFuYWdlciwgX2FkZEtleWJvYXJkTWFuYWdlcjIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9hZGRDb3B5UGFzdGVMaXN0ZW5lcnMsIF9hZGRDb3B5UGFzdGVMaXN0ZW5lcnMyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfZGlzcGF0Y2hVcGRhdGVTdGF0ZXMsIF9kaXNwYXRjaFVwZGF0ZVN0YXRlczIpLmNhbGwodGhpcywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlzRWRpdGluZzogX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9tb2RlKSAhPT0gX3V0aWwuQW5ub3RhdGlvbkVkaXRvclR5cGUuTk9ORSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc0VtcHR5OiBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9pc0VtcHR5LCBfaXNFbXB0eTIpLmNhbGwodGhpcyksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaGFzU29tZXRoaW5nVG9VbmRvOiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2NvbW1hbmRNYW5hZ2VyKS5oYXNTb21ldGhpbmdUb1VuZG8oKSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBoYXNTb21ldGhpbmdUb1JlZG86IF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfY29tbWFuZE1hbmFnZXIpLmhhc1NvbWV0aGluZ1RvUmVkbygpLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGhhc1NlbGVjdGVkRWRpdG9yOiBmYWxzZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9yZW1vdmVLZXlib2FyZE1hbmFnZXIsIF9yZW1vdmVLZXlib2FyZE1hbmFnZXIyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfcmVtb3ZlQ29weVBhc3RlTGlzdGVuZXJzLCBfcmVtb3ZlQ29weVBhc3RlTGlzdGVuZXJzMikuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2Rpc3BhdGNoVXBkYXRlU3RhdGVzLCBfZGlzcGF0Y2hVcGRhdGVTdGF0ZXMyKS5jYWxsKHRoaXMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc0VkaXRpbmc6IGZhbHNlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZWdpc3RlckVkaXRvclR5cGVzKHR5cGVzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2VkaXRvclR5cGVzKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfZWRpdG9yVHlwZXMsIHR5cGVzKTsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBlZGl0b3JUeXBlIG9mIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZWRpdG9yVHlwZXMpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9kaXNwYXRjaFVwZGF0ZVVJLCBfZGlzcGF0Y2hVcGRhdGVVSTIpLmNhbGwodGhpcywgZWRpdG9yVHlwZS5kZWZhdWx0UHJvcGVydGllc1RvVXBkYXRlKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRJZCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfaWRNYW5hZ2VyKS5nZXRJZCgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgY3VycmVudExheWVyKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9hbGxMYXllcnMpLmdldChfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2N1cnJlbnRQYWdlSW5kZXgpKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IGN1cnJlbnRQYWdlSW5kZXgoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2N1cnJlbnRQYWdlSW5kZXgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBhZGRMYXllcihsYXllcikgewogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2FsbExheWVycykuc2V0KGxheWVyLnBhZ2VJbmRleCwgbGF5ZXIpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9pc0VuYWJsZWQpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsYXllci5lbmFibGUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxheWVyLmRpc2FibGUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZW1vdmVMYXllcihsYXllcikgewogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2FsbExheWVycykuZGVsZXRlKGxheWVyLnBhZ2VJbmRleCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHVwZGF0ZU1vZGUobW9kZSkgewogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX21vZGUsIG1vZGUpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAobW9kZSA9PT0gX3V0aWwuQW5ub3RhdGlvbkVkaXRvclR5cGUuTk9ORSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRFZGl0aW5nU3RhdGUoZmFsc2UpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfZGlzYWJsZUFsbCwgX2Rpc2FibGVBbGwyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRFZGl0aW5nU3RhdGUodHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9lbmFibGVBbGwsIF9lbmFibGVBbGwyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBsYXllciBvZiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2FsbExheWVycykudmFsdWVzKCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsYXllci51cGRhdGVNb2RlKG1vZGUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHVwZGF0ZVRvb2xiYXIobW9kZSkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAobW9kZSA9PT0gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9tb2RlKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZXZlbnRCdXMpLmRpc3BhdGNoKCJzd2l0Y2hhbm5vdGF0aW9uZWRpdG9ybW9kZSIsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNvdXJjZTogdGhpcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1vZGUKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHVwZGF0ZVBhcmFtcyh0eXBlLCB2YWx1ZSkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIV9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZWRpdG9yVHlwZXMpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBlZGl0b3Igb2YgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9zZWxlY3RlZEVkaXRvcnMpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3IudXBkYXRlUGFyYW1zKHR5cGUsIHZhbHVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGVkaXRvclR5cGUgb2YgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9lZGl0b3JUeXBlcykpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvclR5cGUudXBkYXRlRGVmYXVsdFBhcmFtcyh0eXBlLCB2YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0RWRpdG9ycyhwYWdlSW5kZXgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZWRpdG9ycyA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGVkaXRvciBvZiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2FsbEVkaXRvcnMpLnZhbHVlcygpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZWRpdG9yLnBhZ2VJbmRleCA9PT0gcGFnZUluZGV4KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9ycy5wdXNoKGVkaXRvcik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGVkaXRvcnM7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldEVkaXRvcihpZCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9hbGxFZGl0b3JzKS5nZXQoaWQpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBhZGRFZGl0b3IoZWRpdG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYWxsRWRpdG9ycykuc2V0KGVkaXRvci5pZCwgZWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmVtb3ZlRWRpdG9yKGVkaXRvcikgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0MjsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9hbGxFZGl0b3JzKS5kZWxldGUoZWRpdG9yLmlkKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy51bnNlbGVjdChlZGl0b3IpOwogICAgICAgICAgICAgICAgICAgICAgICAoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0MiA9IF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYW5ub3RhdGlvblN0b3JhZ2UpKSA9PT0gbnVsbCB8fCBfY2xhc3NQcml2YXRlRmllbGRHZXQyID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfY2xhc3NQcml2YXRlRmllbGRHZXQyLnJlbW92ZShlZGl0b3IuaWQpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzZXRBY3RpdmVFZGl0b3IoZWRpdG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2FjdGl2ZUVkaXRvcikgPT09IGVkaXRvcikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfYWN0aXZlRWRpdG9yLCBlZGl0b3IpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZWRpdG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9kaXNwYXRjaFVwZGF0ZVVJLCBfZGlzcGF0Y2hVcGRhdGVVSTIpLmNhbGwodGhpcywgZWRpdG9yLnByb3BlcnRpZXNUb1VwZGF0ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdG9nZ2xlU2VsZWN0ZWQoZWRpdG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX3NlbGVjdGVkRWRpdG9ycykuaGFzKGVkaXRvcikpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfc2VsZWN0ZWRFZGl0b3JzKS5kZWxldGUoZWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci51bnNlbGVjdCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfZGlzcGF0Y2hVcGRhdGVTdGF0ZXMsIF9kaXNwYXRjaFVwZGF0ZVN0YXRlczIpLmNhbGwodGhpcywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGhhc1NlbGVjdGVkRWRpdG9yOiB0aGlzLmhhc1NlbGVjdGlvbgogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9zZWxlY3RlZEVkaXRvcnMpLmFkZChlZGl0b3IpOwogICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3Iuc2VsZWN0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2Rpc3BhdGNoVXBkYXRlVUksIF9kaXNwYXRjaFVwZGF0ZVVJMikuY2FsbCh0aGlzLCBlZGl0b3IucHJvcGVydGllc1RvVXBkYXRlKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfZGlzcGF0Y2hVcGRhdGVTdGF0ZXMsIF9kaXNwYXRjaFVwZGF0ZVN0YXRlczIpLmNhbGwodGhpcywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaGFzU2VsZWN0ZWRFZGl0b3I6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNldFNlbGVjdGVkKGVkaXRvcikgewogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGVkIG9mIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfc2VsZWN0ZWRFZGl0b3JzKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGVkICE9PSBlZGl0b3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlZC51bnNlbGVjdCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfc2VsZWN0ZWRFZGl0b3JzKS5jbGVhcigpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX3NlbGVjdGVkRWRpdG9ycykuYWRkKGVkaXRvcik7CiAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci5zZWxlY3QoKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfZGlzcGF0Y2hVcGRhdGVVSSwgX2Rpc3BhdGNoVXBkYXRlVUkyKS5jYWxsKHRoaXMsIGVkaXRvci5wcm9wZXJ0aWVzVG9VcGRhdGUpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9kaXNwYXRjaFVwZGF0ZVN0YXRlcywgX2Rpc3BhdGNoVXBkYXRlU3RhdGVzMikuY2FsbCh0aGlzLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoYXNTZWxlY3RlZEVkaXRvcjogdHJ1ZQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaXNTZWxlY3RlZChlZGl0b3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfc2VsZWN0ZWRFZGl0b3JzKS5oYXMoZWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdW5zZWxlY3QoZWRpdG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci51bnNlbGVjdCgpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX3NlbGVjdGVkRWRpdG9ycykuZGVsZXRlKGVkaXRvcik7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2Rpc3BhdGNoVXBkYXRlU3RhdGVzLCBfZGlzcGF0Y2hVcGRhdGVTdGF0ZXMyKS5jYWxsKHRoaXMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGhhc1NlbGVjdGVkRWRpdG9yOiB0aGlzLmhhc1NlbGVjdGlvbgogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IGhhc1NlbGVjdGlvbigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfc2VsZWN0ZWRFZGl0b3JzKS5zaXplICE9PSAwOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB1bmRvKCkgewogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2NvbW1hbmRNYW5hZ2VyKS51bmRvKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2Rpc3BhdGNoVXBkYXRlU3RhdGVzLCBfZGlzcGF0Y2hVcGRhdGVTdGF0ZXMyKS5jYWxsKHRoaXMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGhhc1NvbWV0aGluZ1RvVW5kbzogX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9jb21tYW5kTWFuYWdlcikuaGFzU29tZXRoaW5nVG9VbmRvKCksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoYXNTb21ldGhpbmdUb1JlZG86IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc0VtcHR5OiBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9pc0VtcHR5LCBfaXNFbXB0eTIpLmNhbGwodGhpcykKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlZG8oKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfY29tbWFuZE1hbmFnZXIpLnJlZG8oKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfZGlzcGF0Y2hVcGRhdGVTdGF0ZXMsIF9kaXNwYXRjaFVwZGF0ZVN0YXRlczIpLmNhbGwodGhpcywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaGFzU29tZXRoaW5nVG9VbmRvOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaGFzU29tZXRoaW5nVG9SZWRvOiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2NvbW1hbmRNYW5hZ2VyKS5oYXNTb21ldGhpbmdUb1JlZG8oKSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlzRW1wdHk6IF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2lzRW1wdHksIF9pc0VtcHR5MikuY2FsbCh0aGlzKQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYWRkQ29tbWFuZHMocGFyYW1zKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfY29tbWFuZE1hbmFnZXIpLmFkZChwYXJhbXMpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9kaXNwYXRjaFVwZGF0ZVN0YXRlcywgX2Rpc3BhdGNoVXBkYXRlU3RhdGVzMikuY2FsbCh0aGlzLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoYXNTb21ldGhpbmdUb1VuZG86IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoYXNTb21ldGhpbmdUb1JlZG86IGZhbHNlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNFbXB0eTogX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfaXNFbXB0eSwgX2lzRW1wdHkyKS5jYWxsKHRoaXMpCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBkZWxldGUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29tbWl0T3JSZW1vdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLmhhc1NlbGVjdGlvbikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGVkaXRvcnMgPSBbLi4uX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9zZWxlY3RlZEVkaXRvcnMpXTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY21kID0gKCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBlZGl0b3Igb2YgZWRpdG9ycykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci5yZW1vdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdW5kbyA9ICgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgZWRpdG9yIG9mIGVkaXRvcnMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9hZGRFZGl0b3JUb0xheWVyLCBfYWRkRWRpdG9yVG9MYXllcjIpLmNhbGwodGhpcywgZWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5hZGRDb21tYW5kcyh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB1bmRvLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgbXVzdEV4ZWM6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNvbW1pdE9yUmVtb3ZlKCkgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0MzsKICAgICAgICAgICAgICAgICAgICAgICAgKF9jbGFzc1ByaXZhdGVGaWVsZEdldDMgPSBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2FjdGl2ZUVkaXRvcikpID09PSBudWxsIHx8IF9jbGFzc1ByaXZhdGVGaWVsZEdldDMgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF9jbGFzc1ByaXZhdGVGaWVsZEdldDMuY29tbWl0T3JSZW1vdmUoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2VsZWN0QWxsKCkgewogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGVkaXRvciBvZiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX3NlbGVjdGVkRWRpdG9ycykpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci5jb21taXQoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9zZWxlY3RFZGl0b3JzLCBfc2VsZWN0RWRpdG9yczIpLmNhbGwodGhpcywgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9hbGxFZGl0b3JzKS52YWx1ZXMoKSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHVuc2VsZWN0QWxsKCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9hY3RpdmVFZGl0b3IpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2FjdGl2ZUVkaXRvcikuY29tbWl0T3JSZW1vdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9zZWxlY3RlZEVkaXRvcnMpLnNpemUgPT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGVkaXRvciBvZiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX3NlbGVjdGVkRWRpdG9ycykpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci51bnNlbGVjdCgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfc2VsZWN0ZWRFZGl0b3JzKS5jbGVhcigpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9kaXNwYXRjaFVwZGF0ZVN0YXRlcywgX2Rpc3BhdGNoVXBkYXRlU3RhdGVzMikuY2FsbCh0aGlzLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoYXNTZWxlY3RlZEVkaXRvcjogZmFsc2UKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlzQWN0aXZlKGVkaXRvcikgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9hY3RpdmVFZGl0b3IpID09PSBlZGl0b3I7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldEFjdGl2ZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYWN0aXZlRWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0TW9kZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfbW9kZSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5Bbm5vdGF0aW9uRWRpdG9yVUlNYW5hZ2VyID0gQW5ub3RhdGlvbkVkaXRvclVJTWFuYWdlcjsKICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9hZGRLZXlib2FyZE1hbmFnZXIyKCkgewogICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfY29udGFpbmVyKS5hZGRFdmVudExpc3RlbmVyKCJrZXlkb3duIiwgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ib3VuZEtleWRvd24pKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9yZW1vdmVLZXlib2FyZE1hbmFnZXIyKCk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UZpZWxkR2V0KHRoaXMsIF9ib3VuZFBhc3RlKSk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfZGlzcGF0Y2hVcGRhdGVTdGF0ZXMyKGRldGFpbHMpIHsKICAgICAgICAgICAgICAgICAgICBjb25zdCBoYXNDaGFuZ2VkID0gT2JqZWN0LmVudHJpZXMoZGV0YWlscykuc29tZShfcmVmNSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBba2V5LCB2YWx1ZV0gPSBfcmVmNTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfcHJldmlvdXNTdGF0ZXMpW2tleV0gIT09IHZhbHVlOwogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIGlmIChoYXNDaGFuZ2VkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZXZlbnRCdXMpLmRpc3BhdGNoKCJhbm5vdGF0aW9uZWRpdG9yc3RhdGVzY2hhbmdlZCIsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNvdXJjZTogdGhpcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRldGFpbHM6IE9iamVjdC5hc3NpZ24oX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9wcmV2aW91c1N0YXRlcyksIGRldGFpbHMpCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9kaXNwYXRjaFVwZGF0ZVVJMihkZXRhaWxzKSB7CiAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ldmVudEJ1cykuZGlzcGF0Y2goImFubm90YXRpb25lZGl0b3JwYXJhbXNjaGFuZ2VkIiwgewogICAgICAgICAgICAgICAgICAgICAgICBzb3VyY2U6IHRoaXMsCiAgICAgICAgICAgICAgICAgICAgICAgIGRldGFpbHMKICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9lbmFibGVBbGwyKCkgewogICAgICAgICAgICAgICAgICAgIGlmICghX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9pc0VuYWJsZWQpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfaXNFbmFibGVkLCB0cnVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBsYXllciBvZiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2FsbExheWVycykudmFsdWVzKCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxheWVyLmVuYWJsZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX2Rpc2FibGVBbGwyKCkgewogICAgICAgICAgICAgICAgICAgIHRoaXMudW5zZWxlY3RBbGwoKTsKICAgICAgICAgICAgICAgICAgICBpZiAoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9pc0VuYWJsZWQpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfaXNFbmFibGVkLCBmYWxzZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgbGF5ZXIgb2YgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9hbGxMYXllcnMpLnZhbHVlcygpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsYXllci5kaXNhYmxlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfYWRkRWRpdG9yVG9MYXllcjIoZWRpdG9yKSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgbGF5ZXIgPSBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2FsbExheWVycykuZ2V0KGVkaXRvci5wYWdlSW5kZXgpOwogICAgICAgICAgICAgICAgICAgIGlmIChsYXllcikgewogICAgICAgICAgICAgICAgICAgICAgICBsYXllci5hZGRPclJlYnVpbGQoZWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmFkZEVkaXRvcihlZGl0b3IpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9pc0VtcHR5MigpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9hbGxFZGl0b3JzKS5zaXplID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBpZiAoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9hbGxFZGl0b3JzKS5zaXplID09PSAxKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgZWRpdG9yIG9mIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYWxsRWRpdG9ycykudmFsdWVzKCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBlZGl0b3IuaXNFbXB0eSgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9zZWxlY3RFZGl0b3JzMihlZGl0b3JzKSB7CiAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9zZWxlY3RlZEVkaXRvcnMpLmNsZWFyKCk7CiAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBlZGl0b3Igb2YgZWRpdG9ycykgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZWRpdG9yLmlzRW1wdHkoKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9zZWxlY3RlZEVkaXRvcnMpLmFkZChlZGl0b3IpOwogICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3Iuc2VsZWN0KCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2Rpc3BhdGNoVXBkYXRlU3RhdGVzLCBfZGlzcGF0Y2hVcGRhdGVTdGF0ZXMyKS5jYWxsKHRoaXMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgaGFzU2VsZWN0ZWRFZGl0b3I6IHRydWUKICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIF9kZWZpbmVQcm9wZXJ0eShBbm5vdGF0aW9uRWRpdG9yVUlNYW5hZ2VyLCAiX2tleWJvYXJkTWFuYWdlciIsIG5ldyBLZXlib2FyZE1hbmFnZXIoW1tbImN0cmwrYSIsICJtYWMrbWV0YSthIl0sIEFubm90YXRpb25FZGl0b3JVSU1hbmFnZXIucHJvdG90eXBlLnNlbGVjdEFsbF0sIFtbImN0cmwreiIsICJtYWMrbWV0YSt6Il0sIEFubm90YXRpb25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KSB7IHRocm93IG5ldyBUeXBlRXJyb3IoImF0dGVtcHRlZCB0byAiICsgYWN0aW9uICsgIiBwcml2YXRlIGZpZWxkIG9uIG5vbi1pbnN0YW5jZSIpOyB9IHJldHVybiBwcml2YXRlTWFwLmdldChyZWNlaXZlcik7IH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9jbGFzc0FwcGx5RGVzY3JpcHRvclNldChyZWNlaXZlciwgZGVzY3JpcHRvciwgdmFsdWUpIHsgaWYgKGRlc2NyaXB0b3Iuc2V0KSB7IGRlc2NyaXB0b3Iuc2V0LmNhbGwocmVjZWl2ZXIsIHZhbHVlKTsgfSBlbHNlIHsgaWYgKCFkZXNjcmlwdG9yLndyaXRhYmxlKSB7IHRocm93IG5ldyBUeXBlRXJyb3IoImF0dGVtcHRlZCB0byBzZXQgcmVhZCBvbmx5IHByaXZhdGUgZmllbGQiKTsgfSBkZXNjcmlwdG9yLnZhbHVlID0gdmFsdWU7IH0gfQogICAgICAgICAgICAgICAgY29uc3QgU1ZHX05TID0gImh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIjsKICAgICAgICAgICAgICAgIGNvbnN0IEFubm90YXRpb25QcmVmaXggPSAicGRmanNfaW50ZXJuYWxfaWRfIjsKICAgICAgICAgICAgICAgIGV4cG9ydHMuQW5ub3RhdGlvblByZWZpeCA9IEFubm90YXRpb25QcmVmaXg7CiAgICAgICAgICAgICAgICBjbGFzcyBQaXhlbHNQZXJJbmNoIHsKICAgICAgICAgICAgICAgICAgICBzdGF0aWMgQ1NTID0gOTYuMDsKICAgICAgICAgICAgICAgICAgICBzdGF0aWMgUERGID0gNzIuMDsKICAgICAgICAgICAgICAgICAgICBzdGF0aWMgUERGX1RPX0NTU19VTklUUyA9IHRoaXMuQ1NTIC8gdGhpcy5QREY7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLlBpeGVsc1BlckluY2ggPSBQaXhlbHNQZXJJbmNoOwogICAgICAgICAgICAgICAgdmFyIF9jYWNoZSA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9kZWZzID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2RvY0lkID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2RvY3VtZW50ID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2hjbUZpbHRlciA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9oY21LZXkgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfaGNtVXJsID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2lkID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2NhY2hlMiA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9kZWZzMiA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9hcHBlbmRGZUZ1bmMgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIGNsYXNzIERPTUZpbHRlckZhY3RvcnkgZXh0ZW5kcyBfYmFzZV9mYWN0b3J5LkJhc2VGaWx0ZXJGYWN0b3J5IHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRvY0lkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgb3duZXJEb2N1bWVudCA9IGdsb2JhbFRoaXMuZG9jdW1lbnQKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IGFyZ3VtZW50cy5sZW5ndGggPiAwICYmIGFyZ3VtZW50c1swXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzBdIDoge307CiAgICAgICAgICAgICAgICAgICAgICAgIHN1cGVyKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfYXBwZW5kRmVGdW5jKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2RlZnMyLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBnZXQ6IF9nZXRfZGVmcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNldDogdm9pZCAwCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfY2FjaGUyLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBnZXQ6IF9nZXRfY2FjaGUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZXQ6IHZvaWQgMAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2NhY2hlLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiB2b2lkIDAKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9kZWZzLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiB2b2lkIDAKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9kb2NJZCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdm9pZCAwCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfZG9jdW1lbnQsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHZvaWQgMAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2hjbUZpbHRlciwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdm9pZCAwCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfaGNtS2V5LCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiB2b2lkIDAKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9oY21VcmwsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHZvaWQgMAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2lkLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiAwCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX2RvY0lkLCBkb2NJZCk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfZG9jdW1lbnQsIG93bmVyRG9jdW1lbnQpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBhZGRGaWx0ZXIobWFwcykgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkaWQsIF90aGlzJGlkMjsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFtYXBzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gIm5vbmUiOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB2YWx1ZSA9IF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfY2FjaGUyKS5nZXQobWFwcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh2YWx1ZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB0YWJsZVIsIHRhYmxlRywgdGFibGVCLCBrZXk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChtYXBzLmxlbmd0aCA9PT0gMSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbWFwUiA9IG1hcHNbMF07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBidWZmZXIgPSBuZXcgQXJyYXkoMjU2KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgMjU2OyBpKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBidWZmZXJbaV0gPSBtYXBSW2ldIC8gMjU1OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAga2V5ID0gdGFibGVSID0gdGFibGVHID0gdGFibGVCID0gYnVmZmVyLmpvaW4oIiwiKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IFttYXBSLCBtYXBHLCBtYXBCXSA9IG1hcHM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBidWZmZXJSID0gbmV3IEFycmF5KDI1Nik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBidWZmZXJHID0gbmV3IEFycmF5KDI1Nik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBidWZmZXJCID0gbmV3IEFycmF5KDI1Nik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IDI1NjsgaSsrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnVmZmVyUltpXSA9IG1hcFJbaV0gLyAyNTU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnVmZmVyR1tpXSA9IG1hcEdbaV0gLyAyNTU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnVmZmVyQltpXSA9IG1hcEJbaV0gLyAyNTU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0YWJsZVIgPSBidWZmZXJSLmpvaW4oIiwiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRhYmxlRyA9IGJ1ZmZlckcuam9pbigiLCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGFibGVCID0gYnVmZmVyQi5qb2luKCIsIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBrZXkgPSBgJHt0YWJsZVJ9JHt0YWJsZUd9JHt0YWJsZUJ9YDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZSA9IF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfY2FjaGUyKS5nZXQoa2V5KTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHZhbHVlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2NhY2hlMikuc2V0KG1hcHMsIHZhbHVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB2YWx1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpZCA9IGBnXyR7X2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9kb2NJZCl9X3RyYW5zZmVyX21hcF8keyhfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX2lkLCAoX3RoaXMkaWQgPSBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2lkKSwgX3RoaXMkaWQyID0gX3RoaXMkaWQrKywgX3RoaXMkaWQpKSwgX3RoaXMkaWQyKX1gOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB1cmwgPSBgdXJsKCMke2lkfSlgOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2NhY2hlMikuc2V0KG1hcHMsIHVybCk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfY2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bGwodGhpcywgZmVDb21wb25lbnRUcmFuc2ZlciwgImZlRnVuY0IiLCB0YWJsZUIpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2RlZnMyKS5hcHBlbmQoZmlsdGVyKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHVybDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYWRkSENNRmlsdGVyKGZnQ29sb3IsIGJnQ29sb3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF9jbGFzc1ByaXZhdGVGaWVsZEdldDI7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGtleSA9IGAke2ZnQ29sb3J9LSR7YmdDb2xvcn1gOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9oY21LZXkpID09PSBrZXkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2hjbVVybCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9oY21LZXksIGtleSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfaGNtVXJsLCAibm9uZSIpOwogICAgICAgICAgICAgICAgICAgICAgICAoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0MiA9IF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfaGNtRmlsdGVyKSkgPT09IG51bGwgfHwgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0MiA9PT0gdm9pZCAwID8gdm9pZCAwIDogX2NsYXNzUHJpdmF0ZUZpZWxkR2V0Mi5yZW1vdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFmZ0NvbG9yIHx8ICFiZ0NvbG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9oY21VcmwpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZGVmczIpLnN0eWxlLmNvbG9yID0gZmdDb2xvcjsKICAgICAgICAgICAgICAgICAgICAgICAgZmdDb2xvciA9IGdldENvbXB1dGVkU3R5bGUoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9kZWZzMikpLmdldFByb3BlcnR5VmFsdWUoImNvbG9yIik7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZnUkdCID0gZ2V0UkdCKGZnQ29sb3IpOwogICAgICAgICAgICAgICAgICAgICAgICBmZ0NvbG9yID0gX3V0aWwuVXRpbC5tYWtlSGV4Q29sb3IoLi4uZmdSR0IpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2RlZnMyKS5zdHlsZS5jb2xvciA9IGJnQ29sb3I7CiAgICAgICAgICAgICAgICAgICAgICAgIGJnQ29sb3IgPSBnZXRDb21wdXRlZFN0eWxlKF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZGVmczIpKS5nZXRQcm9wZXJ0eVZhbHVlKCJjb2xvciIpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBiZ1JHQiA9IGdldFJHQihiZ0NvbG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgYmdDb2xvciA9IF91dGlsLlV0aWwubWFrZUhleENvbG9yKC4uLmJnUkdCKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9kZWZzMikuc3R5bGUuY29sb3IgPSAiIjsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGZnQ29sb3IgPT09ICIjMDAwMDAwIiAmJiBiZ0NvbG9yID09PSAiI2ZmZmZmZiIgfHwgZmdDb2xvciA9PT0gYmdDb2xvcikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfaGNtVXJsKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBtYXAgPSBuZXcgQXJyYXkoMjU2KTsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPD0gMjU1OyBpKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHggPSBpIC8gMjU1OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbWFwW2ldID0geCA8PSAwLjAzOTI4ID8geCAvIDEyLjkyIDogKCh4ICsgMC4wNTUpIC8gMS4wNTUpICoqIDIuNDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB0YWJsZSA9IG1hcC5qb2luKCIsIik7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGlkID0gYGdfJHtfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2RvY0lkKX1faGNtX2ZpbHRlcmA7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZpbHRlciA9IF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfaGNtRmlsdGVyLCBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2RvY3VtZW50KS5jcmVhdGVFbGVtZW50TlMoU1ZHX05TLCAiZmlsdGVyIiwgU1ZHX05TKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGZpbHRlci5zZXRBdHRyaWJ1dGUoImlkIiwgaWQpOwogICAgICAgICAgICAgICAgICAgICAgICBmaWx0ZXIuc2V0QXR0cmlidXRlKCJjb2xvci1pbnRlcnBvbGF0aW9uLWZpbHRlcnMiLCAic1JHQiIpOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgZmVDb21wb25lbnRUcmFuc2ZlciA9IF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZG9jdW1lbnQpLmNyZWF0ZUVsZW1lbnROUyhTVkdfTlMsICJmZUNvbXBvbmVudFRyYW5zZmVyIik7CiAgICAgICAgICAgICAgICAgICAgICAgIGZpbHRlci5hcHBlbmQoZmVDb21wb25lbnRUcmFuc2Zlcik7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2FwcGVuZEZlRnVuYywgX2FwcGVuZEZlRnVuYzIpLmNhbGwodGhpcywgZmVDb21wb25lbnRUcmFuc2ZlciwgImZlRnVuY1IiLCB0YWJsZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2FwcGVuZEZlRnVuYywgX2FwcGVuZEZlRnVuYzIpLmNhbGwodGhpcywgZmVDb21wb25lbnRUcmFuc2ZlciwgImZlRnVuY0ciLCB0YWJsZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2FwcGVuZEZlRnVuYywgX2FwcGVuZEZlRnVuYzIpLmNhbGwodGhpcywgZmVDb21wb25lbnRUcmFuc2ZlciwgImZlRnVuY0IiLCB0YWJsZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZlQ29sb3JNYXRyaXggPSBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2RvY3VtZW50KS5jcmVhdGVFbGVtZW50TlMoU1ZHX05TLCAiZmVDb2xvck1hdHJpeCIpOwogICAgICAgICAgICAgICAgICAgICAgICBmZUNvbG9yTWF0cml4LnNldEF0dHJpYnV0ZSgidHlwZSIsICJtYXRyaXgiKTsKICAgICAgICAgICAgICAgICAgICAgICAgZmVDb2xvck1hdHJpeC5zZXRBdHRyaWJ1dGUoInZhbHVlcyIsICIwLjIxMjYgMC43MTUyIDAuMDcyMiAwIDAgMC4yMTI2IDAuNzE1MiAwLjA3MjIgMCAwIDAuMjEyNiAwLjcxNTIgMC4wNzIyIDAgMCAwIDAgMCAxIDAiKTsKICAgICAgICAgICAgICAgICAgICAgICAgZmlsdGVyLmFwcGVuZChmZUNvbG9yTWF0cml4KTsKICAgICAgICAgICAgICAgICAgICAgICAgZmVDb21wb25lbnRUcmFuc2ZlciA9IF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZG9jdW1lbnQpLmNyZWF0ZUVsZW1lbnROUyhTVkdfTlMsICJmZUNvbXBvbmVudFRyYW5zZmVyIik7CiAgICAgICAgICAgICAgICAgICAgICAgIGZpbHRlci5hcHBlbmQoZmVDb21wb25lbnRUcmFuc2Zlcik7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGdldFN0ZXBzID0gKGMsIG4pID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0YXJ0ID0gZmdSR0JbY10gLyAyNTU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBlbmQgPSBiZ1JHQltjXSAvIDI1NTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGFyciA9IG5ldyBBcnJheShuICsgMSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8PSBuOyBpKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhcnJbaV0gPSBzdGFydCArIGkgLyBuICogKGVuZCAtIHN0YXJ0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBhcnIuam9pbigiLCIpOwogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAg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YmIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfaGNtVXJsKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2RlZnMpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2RlZnMpLnBhcmVudE5vZGUucGFyZW50Tm9kZS5yZW1vdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfZGVmcywgbnVsbCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfY2FjaGUpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2NhY2hlKS5jbGVhcigpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9jYWNoZSwgbnVsbCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9pZCwgMCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5ET01GaWx0ZXJGYWN0b3J5ID0gRE9NRmlsdGVyRmFjdG9yeTsKICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9nZXRfY2FjaGUoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfY2FjaGUpIHx8IF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfY2FjaGUsIG5ldyBNYXAoKSk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfZ2V0X2RlZnMoKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKCFfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2RlZnMpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGRpdiA9IF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZG9jdW1lbnQpLmNyZWF0ZUVsZW1lbnQoImRpdiIpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHlsZQogICAgICAgICAgICAgICAgICAgICAgICB9ID0gZGl2OwogICAgICAgICAgICAgICAgICAgICAgICBzdHlsZS52aXNpYmlsaXR5ID0gImhpZGRlbiI7CiAgICAgICAgICAgICAgICAgICAgICAgIHN0eWxlLmNvbnRhaW4gPSAic3RyaWN0IjsKICAgICAgICAgICAgICAgICAgICAgICAgc3R5bGUud2lkdGggPSBzdHlsZS5oZWlnaHQgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICBzdHlsZS5wb3NpdGlvbiA9ICJhYnNvbHV0ZSI7CiAgICAgICAgICAgICAgICAgICAgICAgIHN0eWxlLnRvcCA9IHN0eWxlLmxlZnQgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICBzdHlsZS56SW5kZXggPSAtMTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3ZnID0gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9kb2N1bWVudCkuY3JlYXRlRWxlbWVudE5TKFNWR19OUywgInN2ZyIpOwogICAgICAgICAgICAgICAgICAgICAgICBzdmcuc2V0QXR0cmlidXRlKCJ3aWR0aCIsIDApOwogICAgICAgICAgICAgICAgICAgICAgICBzdmcuc2V0QXR0cmlidXRlKCJoZWlnaHQiLCAwKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9kZWZzLCBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2RvY3VtZW50KS5jcmVhdGVFbGVtZW50TlMoU1ZHX05TLCAiZGVmcyIpKTsKICAgICAgICAgICAgICAgICAgICAgICAgZGl2LmFwcGVuZChzdmcpOwogICAgICAgICAgICAgICAgICAgICAgICBzdmcuYXBwZW5kKF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZGVmcykpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2RvY3VtZW50KS5ib2R5LmFwcGVuZChkaXYpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9kZWZzKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9hcHBlbmRGZUZ1bmMyKGZlQ29tcG9uZW50VHJhbnNmZXIsIGZ1bmMsIHRhYmxlKSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgZmVGdW5jID0gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9kb2N1bWVudCkuY3JlYXRlRWxlbWVudE5TKFNWR19OUywgZnVuYyk7CiAgICAgICAgICAgICAgICAgICAgZmVGdW5jLnNldEF0dHJpYnV0ZSgidHlwZSIsICJkaXNjcmV0ZSIpOwogICAgICAgICAgICAgICAgICAgIGZlRnVuYy5zZXRBdHRyaWJ1dGUoInRhYmxlVmFsdWVzIiwgdGFibGUpOwogICAgICAgICAgICAgICAgICAgIGZlQ29tcG9uZW50VHJhbnNmZXIuYXBwZW5kKGZlRnVuYyk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBET01DYW52YXNGYWN0b3J5IGV4dGVuZHMgX2Jhc2VfZmFjdG9yeS5CYXNlQ2FudmFzRmFjdG9yeSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvd25lckRvY3VtZW50ID0gZ2xvYmFsVGhpcy5kb2N1bWVudAogICAgICAgICAgICAgICAgICAgICAgICB9ID0gYXJndW1lbnRzLmxlbmd0aCA+IDAgJiYgYXJndW1lbnRzWzBdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMF0gOiB7fTsKICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZG9jdW1lbnQgPSBvd25lckRvY3VtZW50OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfY3JlYXRlQ2FudmFzKHdpZHRoLCBoZWlnaHQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2FudmFzID0gdGhpcy5fZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgiY2FudmFzIik7CiAgICAgICAgICAgICAgICAgICAgICAgIGNhbnZhcy53aWR0aCA9IHdpZHRoOwogICAgICAgICAgICAgICAgICAgICAgICBjYW52YXMuaGVpZ2h0ID0gaGVpZ2h0OwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gY2FudmFzOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGV4cG9ydHMuRE9NQ2FudmFzRmFjdG9yeSA9IERPTUNhbnZhc0ZhY3Rvcnk7CiAgICAgICAgICAgICAgICBhc3luYyBmdW5jdGlvbiBmZXRjaERhdGEodXJsKSB7CiAgICAgICAgICAgICAgICAgICAgbGV0IGFzVHlwZWRBcnJheSA9IGFyZ3VtZW50cy5sZW5ndGggPiAxICYmIGFyZ3VtZW50c1sxXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzFdIDogZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgaWYgKGlzVmFsaWRGZXRjaFVybCh1cmwsIGRvY3VtZW50LmJhc2VVUkkpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHJlc3BvbnNlID0gYXdhaXQgZmV0Y2godXJsKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFyZXNwb25zZS5vaykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKHJlc3BvbnNlLnN0YXR1c1RleHQpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBhc1R5cGVkQXJyYXkgPyBuZXcgVWludDhBcnJheShhd2FpdCByZXNwb25zZS5hcnJheUJ1ZmZlcigpKSA6ICgwLCBfdXRpbC5zdHJpbmdUb0J5dGVzKShhd2FpdCByZXNwb25zZS50ZXh0KCkpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IFByb21pc2UoKHJlc29sdmUsIHJlamVjdCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByZXF1ZXN0ID0gbmV3IFhNTEh0dHBSZXF1ZXN0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJlcXVlc3Qub3BlbigiR0VUIiwgdXJsLCB0cnVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGFzVHlwZWRBcnJheSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVxdWVzdC5yZXNwb25zZVR5cGUgPSAiYXJyYXlidWZmZXIiOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHJlcXVlc3Qub25yZWFkeXN0YXRlY2hhbmdlID0gKCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHJlcXVlc3QucmVhZHlTdGF0ZSAhPT0gWE1MSHR0cFJlcXVlc3QuRE9ORSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChyZXF1ZXN0LnN0YXR1cyA9PT0gMjAwIHx8IHJlcXVlc3Quc3RhdHVzID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGRhdGE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGFzVHlwZWRBcnJheSAmJiByZXF1ZXN0LnJlc3BvbnNlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRhdGEgPSBuZXcgVWludDhBcnJheShyZXF1ZXN0LnJlc3BvbnNlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKCFhc1R5cGVkQXJyYXkgJiYgcmVxdWVzdC5yZXNwb25zZVRleHQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGF0YSA9ICgwLCBfdXRpbC5zdHJpbmdUb0J5dGVzKShyZXF1ZXN0LnJlc3BvbnNlVGV4dCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChkYXRhKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlc29sdmUoZGF0YSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWplY3QobmV3IEVycm9yKHJlcXVlc3Quc3RhdHVzVGV4dCkpOwogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICByZXF1ZXN0LnNlbmQobnVsbCk7CiAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBET01DTWFwUmVhZGVyRmFjdG9yeSBleHRlbmRzIF9iYXNlX2ZhY3RvcnkuQmFzZUNNYXBSZWFkZXJGYWN0b3J5IHsKICAgICAgICAgICAgICAgICAgICBfZmV0Y2hEYXRhKHVybCwgY29tcHJlc3Npb25UeXBlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmZXRjaERhdGEodXJsLCB0aGlzLmlzQ29tcHJlc3NlZCkudGhlbihkYXRhID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY01hcERhdGE6IGRhdGEsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29tcHJlc3Npb25UeXBlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLkRPTUNNYXBSZWFkZXJGYWN0b3J5ID0gRE9NQ01hcFJlYWRlckZhY3Rvcnk7CiAgICAgICAgICAgICAgICBjbGFzcyBET01TdGFuZGFyZEZvbnREYXRhRmFjdG9yeSBleHRlbmRzIF9iYXNlX2ZhY3RvcnkuQmFzZVN0YW5kYXJkRm9udERhdGFGYWN0b3J5IHsKICAgICAgICAgICAgICAgICAgICBfZmV0Y2hEYXRhKHVybCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmV0Y2hEYXRhKHVybCwgdHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5ET01TdGFuZGFyZEZvbnREYXRhRmFjdG9yeSA9IERPTVN0YW5kYXJkRm9udERhdGFGYWN0b3J5OwogICAgICAgICAgICAgICAgY2xhc3MgRE9NU1ZHRmFjdG9yeSBleHRlbmRzIF9iYXNlX2ZhY3RvcnkuQmFzZVNWR0ZhY3RvcnkgewogICAgICAgICAgICAgICAgICAgIF9jcmVhdGVTVkcodHlwZSkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZG9jdW1lbnQuY3JlYXRlRWxlbWVudE5TKFNWR19OUywgdHlwZSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5ET01TVkdGYWN0b3J5ID0gRE9NU1ZHRmFjdG9yeTsKICAgICAgICAgICAgICAgIGNsYXNzIFBhZ2VWaWV3cG9ydCB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IoX3JlZikgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmlld0JveCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNjYWxlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcm90YXRpb24sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvZmZzZXRYID0gMCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9mZnNldFkgPSAwLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgZG9udEZsaXAgPSBmYWxzZQogICAgICAgICAgICAgICAgICAgICAgICB9ID0gX3JlZjsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy52aWV3Qm94ID0gdmlld0JveDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zY2FsZSA9IHNjYWxlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnJvdGF0aW9uID0gcm90YXRpb247CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMub2Zmc2V0WCA9IG9mZnNldFg7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMub2Zmc2V0WSA9IG9mZnNldFk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNlbnRlclggPSAodmlld0JveFsyXSArIHZpZXdCb3hbMF0pIC8gMjsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2VudGVyWSA9ICh2aWV3Qm94WzNdICsgdmlld0JveFsxXSkgLyAyOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgcm90YXRlQSwgcm90YXRlQiwgcm90YXRlQywgcm90YXRlRDsKICAgICAgICAgICAgICAgICAgICAgICAgcm90YXRpb24gJT0gMzYwOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAocm90YXRpb24gPCAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByb3RhdGlvbiArPSAzNjA7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgc3dpdGNoIChyb3RhdGlvbikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAxODA6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcm90YXRlQSA9IC0xOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJvdGF0ZUIgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJvdGF0ZUMgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJvdGF0ZUQgPSAxOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSA5MDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByb3RhdGVBID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByb3RhdGVCID0gMTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByb3RhdGVDID0gMTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByb3RhdGVEID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgMjcwOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJvdGF0ZUEgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJvdGF0ZUIgPSAtMTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByb3RhdGVDID0gLTE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcm90YXRlRCA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIDA6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcm90YXRlQSA9IDE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcm90YXRlQiA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcm90YXRlQyA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcm90YXRlRCA9IC0xOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoIlBhZ2VWaWV3cG9ydDogSW52YWxpZCByb3RhdGlvbiwgbXVzdCBiZSBhIG11bHRpcGxlIG9mIDkwIGRlZ3JlZXMuIik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGRvbnRGbGlwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByb3RhdGVDID0gLXJvdGF0ZUM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByb3RhdGVEID0gLXJvdGF0ZUQ7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgbGV0IG9mZnNldENhbnZhc1gsIG9mZnNldENhbnZhc1k7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB3aWR0aCwgaGVpZ2h0OwogICAgICAgICAgICAgICAgICAgICAgICBpZiAocm90YXRlQSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgb2Zmc2V0Q2FudmFzWCA9IE1hdGguYWJzKGNlbnRlclkgLSB2aWV3Qm94WzFdKSAqIHNjYWxlICsgb2Zmc2V0WDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9mZnNldENhbnZhc1kgPSBNYXRoLmFicyhjZW50ZXJYIC0gdmlld0JveFswXSkgKiBzY2FsZSArIG9mZnNldFk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3aWR0aCA9ICh2aWV3Qm94WzNdIC0gdmlld0JveFsxXSkgKiBzY2FsZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGhlaWdodCA9ICh2aWV3Qm94WzJdIC0gdmlld0JveFswXSkgKiBzY2FsZTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9mZnNldENhbnZhc1ggPSBNYXRoLmFicyhjZW50ZXJYIC0gdmlld0JveFswXSkgKiBzY2FsZSArIG9mZnNldFg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvZmZzZXRDYW52YXNZID0gTWF0aC5hYnMoY2VudGVyWSAtIHZpZXdCb3hbMV0pICogc2NhbGUgKyBvZmZzZXRZOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgd2lkdGggPSAodmlld0JveFsyXSAtIHZpZXdCb3hbMF0pICogc2NhbGU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoZWlnaHQgPSAodmlld0JveFszXSAtIHZpZXdCb3hbMV0pICogc2NhbGU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy50cmFuc2Zvcm0gPSBbcm90YXRlQSAqIHNjYWxlLCByb3RhdGVCICogc2NhbGUsIHJvdGF0ZUMgKiBzY2FsZSwgcm90YXRlRCAqIHNjYWxlLCBvZmZzZXRDYW52YXNYIC0gcm90YXRlQSAqIHNjYWxlICogY2VudGVyWCAtIHJvdGF0ZUMgKiBzY2FsZSAqIGNlbnRlclksIG9mZnNldENhbnZhc1kgLSByb3RhdGVCICogc2NhbGUgKiBjZW50ZXJYIC0gcm90YXRlRCAqIHNjYWxlICogY2VudGVyWV07CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMud2lkdGggPSB3aWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5oZWlnaHQgPSBoZWlnaHQ7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCByYXdEaW1zKCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2aWV3Qm94CiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSB0aGlzOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gKDAsIF91dGlsLnNoYWRvdykodGhpcywgInJhd0RpbXMiLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYWdlV2lkdGg6IHZpZXdCb3hbMl0gLSB2aWV3Qm94WzBdLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFnZUhlaWdodDogdmlld0JveFszXSAtIHZpZXdCb3hbMV0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYWdlWDogdmlld0JveFswXSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2VZOiB2aWV3Qm94WzFdCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjbG9uZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNjYWxlID0gdGhpcy5zY2FsZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJvdGF0aW9uID0gdGhpcy5yb3RhdGlvbiwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9mZnNldFggPSB0aGlzLm9mZnNldFgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvZmZzZXRZID0gdGhpcy5vZmZzZXRZLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgZG9udEZsaXAgPSBmYWxzZQogICAgICAgICAgICAgICAgICAgICAgICB9ID0gYXJndW1lbnRzLmxlbmd0aCA+IDAgJiYgYXJndW1lbnRzWzBdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMF0gOiB7fTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG5ldyBQYWdlVmlld3BvcnQoewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmlld0JveDogdGhpcy52aWV3Qm94LnNsaWNlKCksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzY2FsZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJvdGF0aW9uLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgb2Zmc2V0WCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9mZnNldFksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkb250RmxpcAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY29udmVydFRvVmlld3BvcnRQb2ludCh4LCB5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBfdXRpbC5VdGlsLmFwcGx5VHJhbnNmb3JtKFt4LCB5XSwgdGhpcy50cmFuc2Zvcm0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjb252ZXJ0VG9WaWV3cG9ydFJlY3RhbmdsZShyZWN0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHRvcExlZnQgPSBfdXRpbC5VdGlsLmFwcGx5VHJhbnNmb3JtKFtyZWN0WzBdLCByZWN0WzFdXSwgdGhpcy50cmFuc2Zvcm0pOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBib3R0b21SaWdodCA9IF91dGlsLlV0aWwuYXBwbHlUcmFuc2Zvcm0oW3JlY3RbMl0sIHJlY3RbM11dLCB0aGlzLnRyYW5zZm9ybSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbdG9wTGVmdFswXSwgdG9wTGVmdFsxXSwgYm90dG9tUmlnaHRbMF0sIGJvdHRvbVJpZ2h0WzFdXTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY29udmVydFRvUGRmUG9pbnQoeCwgeSkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gX3V0aWwuVXRpbC5hcHBseUludmVyc2VUcmFuc2Zvcm0oW3gsIHldLCB0aGlzLnRyYW5zZm9ybSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5QYWdlVmlld3BvcnQgPSBQYWdlVmlld3BvcnQ7CiAgICAgICAgICAgICAgICBjbGFzcyBSZW5kZXJpbmdDYW5jZWxsZWRFeGNlcHRpb24gZXh0ZW5kcyBfdXRpbC5CYXNlRXhjZXB0aW9uIHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3Rvcihtc2csIHR5cGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGV4dHJhRGVsYXkgPSBhcmd1bWVudHMubGVuZ3RoID4gMiAmJiBhcmd1bWVudHNbMl0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1syXSA6IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIHN1cGVyKG1zZywgIlJlbmRlcmluZ0NhbmNlbGxlZEV4Y2VwdGlvbiIpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnR5cGUgPSB0eXBlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmV4dHJhRGVsYXkgPSBleHRyYURlbGF5OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGV4cG9ydHMuUmVuZGVyaW5nQ2FuY2VsbGVkRXhjZXB0aW9uID0gUmVuZGVyaW5nQ2FuY2VsbGVkRXhjZXB0aW9uOwogICAgICAgICAgICAgICAgZnVuY3Rpb24gaXNEYXRhU2NoZW1lKHVybCkgewogICAgICAgICAgICAgICAgICAgIGNvbnN0IGlpID0gdXJsLmxlbmd0aDsKICAgICAgICAgICAgICAgICAgICBsZXQgaSA9IDA7CiAgICAgICAgICAgICAgICAgICAgd2hpbGUgKGkgPCBpaSAmJiB1cmxbaV0udHJpbSgpID09PSAiIikgewogICAgICAgICAgICAgICAgICAgICAgICBpKys7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJldHVybiB1cmwuc3Vic3RyaW5nKGksIGkgKyA1KS50b0xvd2VyQ2FzZSgpID09PSAiZGF0YToiOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gaXNQZGZGaWxlKGZpbGVuYW1lKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHR5cGVvZiBmaWxlbmFtZSA9PT0gInN0cmluZyIgJiYgL1wucGRmJC9pLnRlc3QoZmlsZW5hbWUpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gZ2V0RmlsZW5hbWVGcm9tVXJsKHVybCkgewogICAgICAgICAgICAgICAgICAgIGxldCBvbmx5U3RyaXBQYXRoID0gYXJndW1lbnRzLmxlbmd0aCA+IDEgJiYgYXJndW1lbnRzWzFdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMV0gOiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICBpZiAoIW9ubHlTdHJpcFBhdGgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgW3VybF0gPSB1cmwuc3BsaXQoL1sjP10vLCAxKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHVybC5zdWJzdHJpbmcodXJsLmxhc3RJbmRleE9mKCIvIikgKyAxKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGdldFBkZkZpbGVuYW1lRnJvbVVybCh1cmwpIHsKICAgICAgICAgICAgICAgICAgICBsZXQgZGVmYXVsdEZpbGVuYW1lID0gYXJndW1lbnRzLmxlbmd0aCA+IDEgJiYgYXJndW1lbnRzWzFdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMV0gOiAiZG9jdW1lbnQucGRmIjsKICAgICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIHVybCAhPT0gInN0cmluZyIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGRlZmF1bHRGaWxlbmFtZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaWYgKGlzRGF0YVNjaGVtZSh1cmwpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKSgnZ2V0UGRmRmlsZW5hbWVGcm9tVXJsOiBpZ25vcmUgImRhdGE6Ii1VUkwgZm9yIHBlcmZvcm1hbmNlIHJlYXNvbnMuJyk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBkZWZhdWx0RmlsZW5hbWU7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNvbnN0IHJlVVJJID0gL14oPzooPzpbXjpdKzopP1wvXC9bXi9dKyk/KFtePyNdKikoXD9bXiNdKik/KCMuKik/JC87CiAgICAgICAgICAgICAgICAgICAgY29uc3QgcmVGaWxlbmFtZSA9IC9bXi8/Iz1dK1wucGRmXGIoPyEuKlwucGRmXGIpL2k7CiAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3BsaXRVUkkgPSByZVVSSS5leGVjKHVybCk7CiAgICAgICAgICAgICAgICAgICAgbGV0IHN1Z2dlc3RlZEZpbGVuYW1lID0gcmVGaWxlbmFtZS5leGVjKHNwbGl0VVJJWzFdKSB8fCByZUZpbGVuYW1lLmV4ZWMoc3BsaXRVUklbMl0pIHx8IHJlRmlsZW5hbWUuZXhlYyhzcGxpdFVSSVszXSk7CiAgICAgICAgICAgICAgICAgICAgaWYgKHN1Z2dlc3RlZEZpbGVuYW1lKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHN1Z2dlc3RlZEZpbGVuYW1lID0gc3VnZ2VzdGVkRmlsZW5hbWVbMF07CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChzdWdnZXN0ZWRGaWxlbmFtZS5pbmNsdWRlcygiJSIpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN1Z2dlc3RlZEZpbGVuYW1lID0gcmVGaWxlbmFtZS5leGVjKGRlY29kZVVSSUNvbXBvbmVudChzdWdnZXN0ZWRGaWxlbmFtZSkpWzBdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZXgpIHt9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHN1Z2dlc3RlZEZpbGVuYW1lIHx8IGRlZmF1bHRGaWxlbmFtZTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNsYXNzIFN0YXRUaW1lciB7CiAgICAgICAgICAgICAgICAgICAgc3RhcnRlZCA9IE9iamVjdC5jcmVhdGUobnVsbCk7CiAgICAgICAgICAgICAgICAgICAgdGltZXMgPSBbXTsKICAgICAgICAgICAgICAgICAgICB0aW1lKG5hbWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG5hbWUgaW4gdGhpcy5zdGFydGVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYFRpbWVyIGlzIGFscmVhZHkgcnVubmluZyBmb3IgJHtuYW1lfWApOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc3RhcnRlZFtuYW1lXSA9IERhdGUubm93KCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHRpbWVFbmQobmFtZSkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIShuYW1lIGluIHRoaXMuc3RhcnRlZCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgVGltZXIgaGFzIG5vdCBiZWVuIHN0YXJ0ZWQgZm9yICR7bmFtZX1gKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnRpbWVzLnB1c2goewogICAgICAgICAgICAgICAgICAgICAgICAgICAgbmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0YXJ0OiB0aGlzLnN0YXJ0ZWRbbmFtZV0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbmQ6IERhdGUubm93KCkKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGRlbGV0ZSB0aGlzLnN0YXJ0ZWRbbmFtZV07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHRvU3RyaW5nKCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBvdXRCdWYgPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGxvbmdlc3QgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5hbWUKICAgICAgICAgICAgICAgICAgICAgICAgfSBvZiB0aGlzLnRpbWVzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsb25nZXN0ID0gTWF0aC5tYXgobmFtZS5sZW5ndGgsIGxvbmdlc3QpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgbmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0YXJ0LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgZW5kCiAgICAgICAgICAgICAgICAgICAgICAgIH0gb2YgdGhpcy50aW1lcykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgb3V0QnVmLnB1c2goYCR7bmFtZS5wYWRFbmQobG9uZ2VzdCl9ICR7ZW5kIC0gc3RhcnR9bXNcbmApOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBvdXRCdWYuam9pbigiIik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5TdGF0VGltZXIgPSBTdGF0VGltZXI7CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBpc1ZhbGlkRmV0Y2hVcmwodXJsLCBiYXNlVXJsKSB7CiAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJvdG9jb2wKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IGJhc2VVcmwgPyBuZXcgVVJMKHVybCwgYmFzZVVybCkgOiBuZXcgVVJMKHVybCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBwcm90b2NvbCA9PT0gImh0dHA6IiB8fCBwcm90b2NvbCA9PT0gImh0dHBzOiI7CiAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZXgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGxvYWRTY3JpcHQoc3JjKSB7CiAgICAgICAgICAgICAgICAgICAgbGV0IHJlbW92ZVNjcmlwdEVsZW1lbnQgPSBhcmd1bWVudHMubGVuZ3RoID4gMSAmJiBhcmd1bWVudHNbMV0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1sxXSA6IGZhbHNlOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgUHJvbWlzZSgocmVzb2x2ZSwgcmVqZWN0KSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHNjcmlwdCA9IGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoInNjcmlwdCIpOwogICAgICAgICAgICAgICAgICAgICAgICBzY3JpcHQuc3JjID0gc3JjOwogICAgICAgICAgICAgICAgICAgICAgICBzY3JpcHQub25sb2FkID0gZnVuY3Rpb24gKGV2dCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHJlbW92ZVNjcmlwdEVsZW1lbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzY3JpcHQucmVtb3ZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXNvbHZlKGV2dCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgIHNjcmlwdC5vbmVycm9yID0gZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVqZWN0KG5ldyBFcnJvcihgQ2Fubm90IGxvYWQgc2NyaXB0IGF0OiAke3NjcmlwdC5zcmN9YCkpOwogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICAoZG9jdW1lbnQuaGVhZCB8fCBkb2N1bWVudC5kb2N1bWVudEVsZW1lbnQpLmFwcGVuZChzY3JpcHQpOwogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gZGVwcmVjYXRlZChkZXRhaWxzKSB7CiAgICAgICAgICAgICAgICAgICAgY29uc29sZS5sb2coIkRlcHJlY2F0ZWQgQVBJIHVzYWdlOiAiICsgZGV0YWlscyk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBsZXQgcGRmRGF0ZVN0cmluZ1JlZ2V4OwogICAgICAgICAgICAgICAgY2xhc3MgUERGRGF0ZVN0cmluZyB7CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIHRvRGF0ZU9iamVjdChpbnB1dCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWlucHV0IHx8IHR5cGVvZiBpbnB1dCAhPT0gInN0cmluZyIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghcGRmRGF0ZVN0cmluZ1JlZ2V4KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwZGZEYXRlU3RyaW5nUmVnZXggPSBuZXcgUmVnRXhwKCJeRDoiICsgIihcXGR7NH0pIiArICIoXFxkezJ9KT8iICsgIihcXGR7Mn0pPyIgKyAiKFxcZHsyfSk/IiArICIoXFxkezJ9KT8iICsgIihcXGR7Mn0pPyIgKyAiKFtafCt8LV0pPyIgKyAiKFxcZHsyfSk/IiArICInPyIgKyAiKFxcZHsyfSk/IiArICInPyIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG1hdGNoZXMgPSBwZGZEYXRlU3RyaW5nUmVnZXguZXhlYyhpbnB1dCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghbWF0Y2hlcykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgeWVhciA9IHBhcnNlSW50KG1hdGNoZXNbMV0sIDEwKTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IG1vbnRoID0gcGFyc2VJbnQobWF0Y2hlc1syXSwgMTApOwogICAgICAgICAgICAgICAgICAgICAgICBtb250aCA9IG1vbnRoID49IDEgJiYgbW9udGggPD0gMTIgPyBtb250aCAtIDEgOiAwOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgZGF5ID0gcGFyc2VJbnQobWF0Y2hlc1szXSwgMTApOwogICAgICAgICAgICAgICAgICAgICAgICBkYXkgPSBkYXkgPj0gMSAmJiBkYXkgPD0gMzEgPyBkYXkgOiAxOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgaG91ciA9IHBhcnNlSW50KG1hdGNoZXNbNF0sIDEwKTsKICAgICAgICAgICAgICAgICAgICAgICAgaG91ciA9IGhvdXIgPj0gMCAmJiBob3VyIDw9IDIzID8gaG91ciA6IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBtaW51dGUgPSBwYXJzZUludChtYXRjaGVzWzVdLCAxMCk7CiAgICAgICAgICAgICAgICAgICAgICAgIG1pbnV0ZSA9IG1pbnV0ZSA+PSAwICYmIG1pbnV0ZSA8PSA1OSA/IG1pbnV0ZSA6IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBzZWNvbmQgPSBwYXJzZUludChtYXRjaGVzWzZdLCAxMCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHNlY29uZCA9IHNlY29uZCA+PSAwICYmIHNlY29uZCA8PSA1OSA/IHNlY29uZCA6IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHVuaXZlcnNhbFRpbWVSZWxhdGlvbiA9IG1hdGNoZXNbN10gfHwgIloiOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgb2Zmc2V0SG91ciA9IHBhcnNlSW50KG1hdGNoZXNbOF0sIDEwKTsKICAgICAgICAgICAgICAgICAgICAgICAgb2Zmc2V0SG91ciA9IG9mZnNldEhvdXIgPj0gMCAmJiBvZmZzZXRIb3VyIDw9IDIzID8gb2Zmc2V0SG91ciA6IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBvZmZzZXRNaW51dGUgPSBwYXJzZUludChtYXRjaGVzWzldLCAxMCkgfHwgMDsKICAgICAgICAgICAgICAgICAgICAgICAgb2Zmc2V0TWludXRlID0gb2Zmc2V0TWludXRlID49IDAgJiYgb2Zmc2V0TWludXRlIDw9IDU5ID8gb2Zmc2V0TWludXRlIDogMDsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHVuaXZlcnNhbFRpbWVSZWxhdGlvbiA9PT0gIi0iKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBob3VyICs9IG9mZnNldEhvdXI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtaW51dGUgKz0gb2Zmc2V0TWludXRlOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHVuaXZlcnNhbFRpbWVSZWxhdGlvbiA9PT0gIisiKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBob3VyIC09IG9mZnNldEhvdXI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtaW51dGUgLT0gb2Zmc2V0TWludXRlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgRGF0ZShEYXRlLlVUQyh5ZWFyLCBtb250aCwgZGF5LCBob3VyLCBtaW51dGUsIHNlY29uZCkpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGV4cG9ydHMuUERGRGF0ZVN0cmluZyA9IFBERkRhdGVTdHJpbmc7CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBnZXRYZmFQYWdlVmlld3BvcnQoeGZhUGFnZSwgX3JlZjIpIHsKICAgICAgICAgICAgICAgICAgICBsZXQgewogICAgICAgICAgICAgICAgICAgICAgICBzY2FsZSA9IDEsCiAgICAgICAgICAgICAgICAgICAgICAgIHJvdGF0aW9uID0gMAogICAgICAgICAgICAgICAgICAgIH0gPSBfcmVmMjsKICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgIHdpZHRoLAogICAgICAgICAgICAgICAgICAgICAgICBoZWlnaHQKICAgICAgICAgICAgICAgICAgICB9ID0geGZhUGFnZS5hdHRyaWJ1dGVzLnN0eWxlOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHZpZXdCb3ggPSBbMCwgMCwgcGFyc2VJbnQod2lkdGgpLCBwYXJzZUludChoZWlnaHQpXTsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IFBhZ2VWaWV3cG9ydCh7CiAgICAgICAgICAgICAgICAgICAgICAgIHZpZXdCb3gsCiAgICAgICAgICAgICAgICAgICAgICAgIHNjYWxlLAogICAgICAgICAgICAgICAgICAgICAgICByb3RhdGlvbgogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gZ2V0UkdCKGNvbG9yKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKGNvbG9yLnN0YXJ0c1dpdGgoIiMiKSkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjb2xvclJHQiA9IHBhcnNlSW50KGNvbG9yLnNsaWNlKDEpLCAxNik7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbKGNvbG9yUkdCICYgMHhmZjAwMDApID4+IDE2LCAoY29sb3JSR0IgJiAweDAwZmYwMCkgPj4gOCwgY29sb3JSR0IgJiAweDAwMDBmZl07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmIChjb2xvci5zdGFydHNXaXRoKCJyZ2IoIikpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGNvbG9yLnNsaWNlKDQsIC0xKS5zcGxpdCgiLCIpLm1hcCh4ID0+IHBhcnNlSW50KHgpKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaWYgKGNvbG9yLnN0YXJ0c1dpdGgoInJnYmEoIikpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGNvbG9yLnNsaWNlKDUsIC0xKS5zcGxpdCgiLCIpLm1hcCh4ID0+IHBhcnNlSW50KHgpKS5zbGljZSgwLCAzKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKGBOb3QgYSB2YWxpZCBjb2xvciBmb3JtYXQ6ICIke2NvbG9yfSJgKTsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gWzAsIDAsIDBdOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gZ2V0Q29sb3JWYWx1ZXMoY29sb3JzKSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3BhbiA9IGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoInNwYW4iKTsKICAgICAgICAgICAgICAgICAgICBzcGFuLnN0eWxlLnZpc2liaWxpdHkgPSAiaGlkZGVuIjsKICAgICAgICAgICAgICAgICAgICBkb2N1bWVudC5ib2R5LmFwcGVuZChzcGFuKTsKICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IG5hbWUgb2YgY29sb3JzLmtleXMoKSkgewogICAgICAgICAgICAgICAgICAgICAgICBzcGFuLnN0eWxlLmNvbG9yID0gbmFtZTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY29tcHV0ZWRDb2xvciA9IHdpbmRvdy5nZXRDb21wdXRlZFN0eWxlKHNwYW4pLmNvbG9yOwogICAgICAgICAgICAgICAgICAgICAgICBjb2xvcnMuc2V0KG5hbWUsIGdldFJHQihjb21wdXRlZENvbG9yKSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNwYW4ucmVtb3ZlKCk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBnZXRDdXJyZW50VHJhbnNmb3JtKGN0eCkgewogICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgYSwKICAgICAgICAgICAgICAgICAgICAgICAgYiwKICAgICAgICAgICAgICAgICAgICAgICAgYywKICAgICAgICAgICAgICAgICAgICAgICAgZCwKICAgICAgICAgICAgICAgICAgICAgICAgZSwKICAgICAgICAgICAgICAgICAgICAgICAgZgogICAgICAgICAgICAgICAgICAgIH0gPSBjdHguZ2V0VHJhbnNmb3JtKCk7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFthLCBiLCBjLCBkLCBlLCBmXTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGdldEN1cnJlbnRUcmFuc2Zvcm1JbnZlcnNlKGN0eCkgewogICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgYSwKICAgICAgICAgICAgICAgICAgICAgICAgYiwKICAgICAgICAgICAgICAgICAgICAgICAgYywKICAgICAgICAgICAgICAgICAgICAgICAgZCwKICAgICAgICAgICAgICAgICAgICAgICAgZSwKICAgICAgICAgICAgICAgICAgICAgICAgZgogICAgICAgICAgICAgICAgICAgIH0gPSBjdHguZ2V0VHJhbnNmb3JtKCkuaW52ZXJ0U2VsZigpOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBbYSwgYiwgYywgZCwgZSwgZl07CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBzZXRMYXllckRpbWVuc2lvbnMoZGl2LCB2aWV3cG9ydCkgewogICAgICAgICAgICAgICAgICAgIGxldCBtdXN0RmxpcCA9IGFyZ3VtZW50cy5sZW5ndGggPiAyICYmIGFyZ3VtZW50c1syXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzJdIDogZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgbGV0IG11c3RSb3RhdGUgPSBhcmd1bWVudHMubGVuZ3RoID4gMyAmJiBhcmd1bWVudHNbM10gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1szXSA6IHRydWU7CiAgICAgICAgICAgICAgICAgICAgaWYgKHZpZXdwb3J0IGluc3RhbmNlb2YgUGFnZVZpZXdwb3J0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2VXaWR0aCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2VIZWlnaHQKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IHZpZXdwb3J0LnJhd0RpbXM7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0eWxlCiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBkaXY7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHdpZHRoU3RyID0gYGNhbGModmFyKC0tc2NhbGUtZmFjdG9yKSAqICR7cGFnZVdpZHRofXB4KWA7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGhlaWdodFN0ciA9IGBjYWxjKHZhcigtLXNjYWxlLWZhY3RvcikgKiAke3BhZ2VIZWlnaHR9cHgpYDsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFtdXN0RmxpcCB8fCB2aWV3cG9ydC5yb3RhdGlvbiAlIDE4MCA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3R5bGUud2lkdGggPSB3aWR0aFN0cjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0eWxlLmhlaWdodCA9IGhlaWdodFN0cjsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0eWxlLndpZHRoID0gaGVpZ2h0U3RyOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3R5bGUuaGVpZ2h0ID0gd2lkdGhTdHI7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaWYgKG11c3RSb3RhdGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgZGl2LnNldEF0dHJpYnV0ZSgiZGF0YS1tYWluLXJvdGF0aW9uIiwgdmlld3BvcnQucm90YXRpb24pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTQzICovCiAgICAgICAgICAgIC8qKiovICgoX191bnVzZWRfd2VicGFja19tb2R1bGUsIGV4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICAidXNlIHN0cmljdCI7CgoKICAgICAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAiX19lc01vZHVsZSIsICh7CiAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRydWUKICAgICAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuQmFzZVN0YW5kYXJkRm9udERhdGFGYWN0b3J5ID0gZXhwb3J0cy5CYXNlU1ZHRmFjdG9yeSA9IGV4cG9ydHMuQmFzZUZpbHRlckZhY3RvcnkgPSBleHBvcnRzLkJhc2VDYW52YXNGYWN0b3J5ID0gZXhwb3J0cy5CYXNlQ01hcFJlYWRlckZhY3RvcnkgPSB2b2lkIDA7CiAgICAgICAgICAgICAgICB2YXIgX3V0aWwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEpOwogICAgICAgICAgICAgICAgY2xhc3MgQmFzZUZpbHRlckZhY3RvcnkgewogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5jb25zdHJ1Y3RvciA9PT0gQmFzZUZpbHRlckZhY3RvcnkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC51bnJlYWNoYWJsZSkoIkNhbm5vdCBpbml0aWFsaXplIEJhc2VGaWx0ZXJGYWN0b3J5LiIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGFkZEZpbHRlcihtYXBzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAibm9uZSI7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGFkZEhDTUZpbHRlcihmZ0NvbG9yLCBiZ0NvbG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAibm9uZSI7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGRlc3Ryb3koKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBrZWVwSENNID0gYXJndW1lbnRzLmxlbmd0aCA+IDAgJiYgYXJndW1lbnRzWzBdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMF0gOiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLkJhc2VGaWx0ZXJGYWN0b3J5ID0gQmFzZUZpbHRlckZhY3Rvcnk7CiAgICAgICAgICAgICAgICBjbGFzcyBCYXNlQ2FudmFzRmFjdG9yeSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmNvbnN0cnVjdG9yID09PSBCYXNlQ2FudmFzRmFjdG9yeSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLnVucmVhY2hhYmxlKSgiQ2Fubm90IGluaXRpYWxpemUgQmFzZUNhbnZhc0ZhY3RvcnkuIik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY3JlYXRlKHdpZHRoLCBoZWlnaHQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHdpZHRoIDw9IDAgfHwgaGVpZ2h0IDw9IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcigiSW52YWxpZCBjYW52YXMgc2l6ZSIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNhbnZhcyA9IHRoaXMuX2NyZWF0ZUNhbnZhcyh3aWR0aCwgaGVpZ2h0KTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhbnZhcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRleHQ6IGNhbnZhcy5nZXRDb250ZXh0KCIyZCIpCiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlc2V0KGNhbnZhc0FuZENvbnRleHQsIHdpZHRoLCBoZWlnaHQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFjYW52YXNBbmRDb250ZXh0LmNhbnZhcykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCJDYW52YXMgaXMgbm90IHNwZWNpZmllZCIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh3aWR0aCA8PSAwIHx8IGhlaWdodCA8PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoIkludmFsaWQgY2FudmFzIHNpemUiKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjYW52YXNBbmRDb250ZXh0LmNhbnZhcy53aWR0aCA9IHdpZHRoOwogICAgICAgICAgICAgICAgICAgICAgICBjYW52YXNBbmRDb250ZXh0LmNhbnZhcy5oZWlnaHQgPSBoZWlnaHQ7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGRlc3Ryb3koY2FudmFzQW5kQ29udGV4dCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWNhbnZhc0FuZENvbnRleHQuY2FudmFzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoIkNhbnZhcyBpcyBub3Qgc3BlY2lmaWVkIik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY2FudmFzQW5kQ29udGV4dC5jYW52YXMud2lkdGggPSAwOwogICAgICAgICAgICAgICAgICAgICAgICBjYW52YXNBbmRDb250ZXh0LmNhbnZhcy5oZWlnaHQgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICBjYW52YXNBbmRDb250ZXh0LmNhbnZhcyA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIGNhbnZhc0FuZENvbnRleHQuY29udGV4dCA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9jcmVhdGVDYW52YXMod2lkdGgsIGhlaWdodCkgewogICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwudW5yZWFjaGFibGUpKCJBYnN0cmFjdCBtZXRob2QgYF9jcmVhdGVDYW52YXNgIGNhbGxlZC4iKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLkJhc2VDYW52YXNGYWN0b3J5ID0gQmFzZUNhbnZhc0ZhY3Rvcnk7CiAgICAgICAgICAgICAgICBjbGFzcyBCYXNlQ01hcFJlYWRlckZhY3RvcnkgewogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKF9yZWYpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJhc2VVcmwgPSBudWxsLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNDb21wcmVzc2VkID0gdHJ1ZQogICAgICAgICAgICAgICAgICAgICAgICB9ID0gX3JlZjsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuY29uc3RydWN0b3IgPT09IEJhc2VDTWFwUmVhZGVyRmFjdG9yeSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLnVucmVhY2hhYmxlKSgiQ2Fubm90IGluaXRpYWxpemUgQmFzZUNNYXBSZWFkZXJGYWN0b3J5LiIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYmFzZVVybCA9IGJhc2VVcmw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuaXNDb21wcmVzc2VkID0gaXNDb21wcmVzc2VkOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBhc3luYyBmZXRjaChfcmVmMikgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgbmFtZQogICAgICAgICAgICAgICAgICAgICAgICB9ID0gX3JlZjI7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5iYXNlVXJsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoJ1RoZSBDTWFwICJiYXNlVXJsIiBwYXJhbWV0ZXIgbXVzdCBiZSBzcGVjaWZpZWQsIGVuc3VyZSB0aGF0ICcgKyAndGhlICJjTWFwVXJsIiBhbmQgImNNYXBQYWNrZWQiIEFQSSBwYXJhbWV0ZXJzIGFyZSBwcm92aWRlZC4nKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIW5hbWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcigiQ01hcCBuYW1lIG11c3QgYmUgc3BlY2lmaWVkLiIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHVybCA9IHRoaXMuYmFzZVVybCArIG5hbWUgKyAodGhpcy5pc0NvbXByZXNzZWQgPyAiLmJjbWFwIiA6ICIiKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY29tcHJlc3Npb25UeXBlID0gdGhpcy5pc0NvbXByZXNzZWQgPyBfdXRpbC5DTWFwQ29tcHJlc3Npb25UeXBlLkJJTkFSWSA6IF91dGlsLkNNYXBDb21wcmVzc2lvblR5cGUuTk9ORTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX2ZldGNoRGF0YSh1cmwsIGNvbXByZXNzaW9uVHlwZSkuY2F0Y2gocmVhc29uID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcihgVW5hYmxlIHRvIGxvYWQgJHt0aGlzLmlzQ29tcHJlc3NlZCA/ICJiaW5hcnkgIiA6ICIifUNNYXAgYXQ6ICR7dXJsfWApOwogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX2ZldGNoRGF0YSh1cmwsIGNvbXByZXNzaW9uVHlwZSkgewogICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwudW5yZWFjaGFibGUpKCJBYnN0cmFjdCBtZXRob2QgYF9mZXRjaERhdGFgIGNhbGxlZC4iKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLkJhc2VDTWFwUmVhZGVyRmFjdG9yeSA9IEJhc2VDTWFwUmVhZGVyRmFjdG9yeTsKICAgICAgICAgICAgICAgIGNsYXNzIEJhc2VTdGFuZGFyZEZvbnREYXRhRmFjdG9yeSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IoX3JlZjMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJhc2VVcmwgPSBudWxsCiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBfcmVmMzsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuY29uc3RydWN0b3IgPT09IEJhc2VTdGFuZGFyZEZvbnREYXRhRmFjdG9yeSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLnVucmVhY2hhYmxlKSgiQ2Fubm90IGluaXRpYWxpemUgQmFzZVN0YW5kYXJkRm9udERhdGFGYWN0b3J5LiIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYmFzZVVybCA9IGJhc2VVcmw7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGFzeW5jIGZldGNoKF9yZWY0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmaWxlbmFtZQogICAgICAgICAgICAgICAgICAgICAgICB9ID0gX3JlZjQ7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5iYXNlVXJsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoJ1RoZSBzdGFuZGFyZCBmb250ICJiYXNlVXJsIiBwYXJhbWV0ZXIgbXVzdCBiZSBzcGVjaWZpZWQsIGVuc3VyZSB0aGF0ICcgKyAndGhlICJzdGFuZGFyZEZvbnREYXRhVXJsIiBBUEkgcGFyYW1ldGVyIGlzIHByb3ZpZGVkLicpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghZmlsZW5hbWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcigiRm9udCBmaWxlbmFtZSBtdXN0IGJlIHNwZWNpZmllZC4iKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB1cmwgPSBgJHt0aGlzLmJhc2VVcmx9JHtmaWxlbmFtZX1gOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fZmV0Y2hEYXRhKHVybCkuY2F0Y2gocmVhc29uID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcihgVW5hYmxlIHRvIGxvYWQgZm9udCBkYXRhIGF0OiAke3VybH1gKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9mZXRjaERhdGEodXJsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC51bnJlYWNoYWJsZSkoIkFic3RyYWN0IG1ldGhvZCBgX2ZldGNoRGF0YWAgY2FsbGVkLiIpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGV4cG9ydHMuQmFzZVN0YW5kYXJkRm9udERhdGFGYWN0b3J5ID0gQmFzZVN0YW5kYXJkRm9udERhdGFGYWN0b3J5OwogICAgICAgICAgICAgICAgY2xhc3MgQmFzZVNWR0ZhY3RvcnkgewogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5jb25zdHJ1Y3RvciA9PT0gQmFzZVNWR0ZhY3RvcnkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC51bnJlYWNoYWJsZSkoIkNhbm5vdCBpbml0aWFsaXplIEJhc2VTVkdGYWN0b3J5LiIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNyZWF0ZSh3aWR0aCwgaGVpZ2h0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBza2lwRGltZW5zaW9ucyA9IGFyZ3VtZW50cy5sZW5ndGggPiAyICYmIGFyZ3VtZW50c1syXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzJdIDogZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh3aWR0aCA8PSAwIHx8IGhlaWdodCA8PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoIkludmFsaWQgU1ZHIGRpbWVuc2lvbnMiKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzdmcgPSB0aGlzLl9jcmVhdGVTVkcoInN2ZzpzdmciKTsKICAgICAgICAgICAgICAgICAgICAgICAgc3ZnLnNldEF0dHJpYnV0ZSgidmVyc2lvbiIsICIxLjEiKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFza2lwRGltZW5zaW9ucykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3ZnLnNldEF0dHJpYnV0ZSgid2lkdGgiLCBgJHt3aWR0aH1weGApOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3ZnLnNldEF0dHJpYnV0ZSgiaGVpZ2h0IiwgYCR7aGVpZ2h0fXB4YCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgc3ZnLnNldEF0dHJpYnV0ZSgicHJlc2VydmVBc3BlY3RSYXRpbyIsICJub25lIik7CiAgICAgICAgICAgICAgICAgICAgICAgIHN2Zy5zZXRBdHRyaWJ1dGUoInZpZXdCb3giLCBgMCAwICR7d2lkdGh9ICR7aGVpZ2h0fWApOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gc3ZnOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjcmVhdGVFbGVtZW50KHR5cGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHR5cGVvZiB0eXBlICE9PSAic3RyaW5nIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCJJbnZhbGlkIFNWRyBlbGVtZW50IHR5cGUiKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fY3JlYXRlU1ZHKHR5cGUpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfY3JlYXRlU1ZHKHR5cGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLnVucmVhY2hhYmxlKSgiQWJzdHJhY3QgbWV0aG9kIGBfY3JlYXRlU1ZHYCBjYWxsZWQuIik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5CYXNlU1ZHRmFjdG9yeSA9IEJhc2VTVkdGYWN0b3J5OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxNDQgKi8KICAgICAgICAgICAgLyoqKi8gKChfX3VudXNlZF93ZWJwYWNrX21vZHVsZSwgZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgICJ1c2Ugc3RyaWN0IjsKCgogICAgICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJfX2VzTW9kdWxlIiwgKHsKICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdHJ1ZQogICAgICAgICAgICAgICAgfSkpOwogICAgICAgICAgICAgICAgZXhwb3J0cy5NdXJtdXJIYXNoM182NCA9IHZvaWQgMDsKICAgICAgICAgICAgICAgIHZhciBfdXRpbCA9IF9fd19wZGZqc19yZXF1aXJlX18oMSk7CiAgICAgICAgICAgICAgICBjb25zdCBTRUVEID0gMHhjM2QyZTFmMDsKICAgICAgICAgICAgICAgIGNvbnN0IE1BU0tfSElHSCA9IDB4ZmZmZjAwMDA7CiAgICAgICAgICAgICAgICBjb25zdCBNQVNLX0xPVyA9IDB4ZmZmZjsKICAgICAgICAgICAgICAgIGNsYXNzIE11cm11ckhhc2gzXzY0IHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcihzZWVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuaDEgPSBzZWVkID8gc2VlZCAmIDB4ZmZmZmZmZmYgOiBTRUVEOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmgyID0gc2VlZCA/IHNlZWQgJiAweGZmZmZmZmZmIDogU0VFRDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdXBkYXRlKGlucHV0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBkYXRhLCBsZW5ndGg7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0eXBlb2YgaW5wdXQgPT09ICJzdHJpbmciKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkYXRhID0gbmV3IFVpbnQ4QXJyYXkoaW5wdXQubGVuZ3RoICogMik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZW5ndGggPSAwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgaSA9IDAsIGlpID0gaW5wdXQubGVuZ3RoOyBpIDwgaWk7IGkrKykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNvZGUgPSBpbnB1dC5jaGFyQ29kZUF0KGkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjb2RlIDw9IDB4ZmYpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGF0YVtsZW5ndGgrK10gPSBjb2RlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRhdGFbbGVuZ3RoKytdID0gY29kZSA+Pj4gODsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGF0YVtsZW5ndGgrK10gPSBjb2RlICYgMHhmZjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoKDAsIF91dGlsLmlzQXJyYXlCdWZmZXIpKGlucHV0KSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGF0YSA9IGlucHV0LnNsaWNlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZW5ndGggPSBkYXRhLmJ5dGVMZW5ndGg7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoIldyb25nIGRhdGEgZm9ybWF0IGluIE11cm11ckhhc2gzXzY0X3VwZGF0ZS4gIiArICJJbnB1dCBtdXN0IGJlIGEgc3RyaW5nIG9yIGFycmF5LiIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGJsb2NrQ291bnRzID0gbGVuZ3RoID4+IDI7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHRhaWxMZW5ndGggPSBsZW5ndGggLSBibG9ja0NvdW50cyAqIDQ7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGRhdGFVaW50MzIgPSBuZXcgVWludDMyQXJyYXkoZGF0YS5idWZmZXIsIDAsIGJsb2NrQ291bnRzKTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGsxID0gMCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGsyID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGgxID0gdGhpcy5oMSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGgyID0gdGhpcy5oMjsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgQzEgPSAweGNjOWUyZDUxLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgQzIgPSAweDFiODczNTkzOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBDMV9MT1cgPSBDMSAmIE1BU0tfTE9XLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgQzJfTE9XID0gQzIgJiBNQVNLX0xPVzsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBibG9ja0NvdW50czsgaSsrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoaSAmIDEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBrMSA9IGRhdGFVaW50MzJbaV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgazEgPSBrMSAqIEMxICYgTUFTS19ISUdIIHwgazEgKiBDMV9MT1cgJiBNQVNLX0xPVzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBrMSA9IGsxIDw8IDE1IHwgazEgPj4+IDE3OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGsxID0gazEgKiBDMiAmIE1BU0tfSElHSCB8IGsxICogQzJfTE9XICYgTUFTS19MT1c7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaDEgXj0gazE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaDEgPSBoMSA8PCAxMyB8IGgxID4+PiAxOTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBoMSA9IGgxICogNSArIDB4ZTY1NDZiNjQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGsyID0gZGF0YVVpbnQzMltpXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBrMiA9IGsyICogQzEgJiBNQVNLX0hJR0ggfCBrMiAqIEMxX0xPVyAmIE1BU0tfTE9XOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGsyID0gazIgPDwgMTUgfCBrMiA+Pj4gMTc7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgazIgPSBrMiAqIEMyICYgTUFTS19ISUdIIHwgazIgKiBDMl9MT1cgJiBNQVNLX0xPVzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBoMiBePSBrMjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBoMiA9IGgyIDw8IDEzIHwgaDIgPj4+IDE5OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGgyID0gaDIgKiA1ICsgMHhlNjU0NmI2NDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBrMSA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIHN3aXRjaCAodGFpbExlbmd0aCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAzOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGsxIF49IGRhdGFbYmxvY2tDb3VudHMgKiA0ICsgMl0gPDwgMTY7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIDI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgazEgXj0gZGF0YVtibG9ja0NvdW50cyAqIDQgKyAxXSA8PCA4OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAxOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGsxIF49IGRhdGFbYmxvY2tDb3VudHMgKiA0XTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBrMSA9IGsxICogQzEgJiBNQVNLX0hJR0ggfCBrMSAqIEMxX0xPVyAmIE1BU0tfTE9XOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGsxID0gazEgPDwgMTUgfCBrMSA+Pj4gMTc7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgazEgPSBrMSAqIEMyICYgTUFTS19ISUdIIHwgazEgKiBDMl9MT1cgJiBNQVNLX0xPVzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoYmxvY2tDb3VudHMgJiAxKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGgxIF49IGsxOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGgyIF49IGsxOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmgxID0gaDE7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuaDIgPSBoMjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaGV4ZGlnZXN0KCkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgaDEgPSB0aGlzLmgxLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaDIgPSB0aGlzLmgyOwogICAgICAgICAgICAgICAgICAgICAgICBoMSBePSBoMiA+Pj4gMTsKICAgICAgICAgICAgICAgICAgICAgICAgaDEgPSBoMSAqIDB4ZWQ1NThjY2QgJiBNQVNLX0hJR0ggfCBoMSAqIDB4OGNjZCAmIE1BU0tfTE9XOwogICAgICAgICAgICAgICAgICAgICAgICBoMiA9IGgyICogMHhmZjUxYWZkNyAmIE1BU0tfSElHSCB8ICgoaDIgPDwgMTYgfCBoMSA+Pj4gMTYpICogMHhhZmQ3ZWQ1NSAmIE1BU0tfSElHSCkgPj4+IDE2OwogICAgICAgICAgICAgICAgICAgICAgICBoMSBePSBoMiA+Pj4gMTsKICAgICAgICAgICAgICAgICAgICAgICAgaDEgPSBoMSAqIDB4MWE4NWVjNTMgJiBNQVNLX0hJR0ggfCBoMSAqIDB4ZWM1MyAmIE1BU0tfTE9XOwogICAgICAgICAgICAgICAgICAgICAgICBoMiA9IGgyICogMHhjNGNlYjlmZSAmIE1BU0tfSElHSCB8ICgoaDIgPDwgMTYgfCBoMSA+Pj4gMTYpICogMHhiOWZlMWE4NSAmIE1BU0tfSElHSCkgPj4+IDE2OwogICAgICAgICAgICAgICAgICAgICAgICBoMSBePSBoMiA+Pj4gMTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIChoMSA+Pj4gMCkudG9TdHJpbmcoMTYpLnBhZFN0YXJ0KDgsICIwIikgKyAoaDIgPj4+IDApLnRvU3RyaW5nKDE2KS5wYWRTdGFydCg4LCAiMCIpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGV4cG9ydHMuTXVybXVySGFzaDNfNjQgPSBNdXJtdXJIYXNoM182NDsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTQ1ICovCiAgICAgICAgICAgIC8qKiovICgoX191bnVzZWRfd2VicGFja19tb2R1bGUsIGV4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICAidXNlIHN0cmljdCI7CgoKICAgICAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAiX19lc01vZHVsZSIsICh7CiAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRydWUKICAgICAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuRm9udExvYWRlciA9IGV4cG9ydHMuRm9udEZhY2VPYmplY3QgPSB2b2lkIDA7CiAgICAgICAgICAgICAgICB2YXIgX3V0aWwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEpOwogICAgICAgICAgICAgICAgdmFyIF9pc19ub2RlID0gX193X3BkZmpzX3JlcXVpcmVfXygzKTsKICAgICAgICAgICAgICAgIGNsYXNzIEZvbnRMb2FkZXIgewogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKF9yZWYpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG93bmVyRG9jdW1lbnQgPSBnbG9iYWxUaGlzLmRvY3VtZW50LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3R5bGVFbGVtZW50ID0gbnVsbAogICAgICAgICAgICAgICAgICAgICAgICB9ID0gX3JlZjsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZG9jdW1lbnQgPSBvd25lckRvY3VtZW50OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm5hdGl2ZUZvbnRGYWNlcyA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnN0eWxlRWxlbWVudCA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubG9hZGluZ1JlcXVlc3RzID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubG9hZFRlc3RGb250SWQgPSAwOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBhZGROYXRpdmVGb250RmFjZShuYXRpdmVGb250RmFjZSkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm5hdGl2ZUZvbnRGYWNlcy5wdXNoKG5hdGl2ZUZvbnRGYWNlKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZG9jdW1lbnQuZm9udHMuYWRkKG5hdGl2ZUZvbnRGYWNlKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaW5zZXJ0UnVsZShydWxlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5zdHlsZUVsZW1lbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc3R5bGVFbGVtZW50ID0gdGhpcy5fZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgic3R5bGUiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2RvY3VtZW50LmRvY3VtZW50RWxlbWVudC5nZXRFbGVtZW50c0J5VGFnTmFtZSgiaGVhZCIpWzBdLmFwcGVuZCh0aGlzLnN0eWxlRWxlbWVudCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3R5bGVTaGVldCA9IHRoaXMuc3R5bGVFbGVtZW50LnNoZWV0OwogICAgICAgICAgICAgICAgICAgICAgICBzdHlsZVNoZWV0Lmluc2VydFJ1bGUocnVsZSwgc3R5bGVTaGVldC5jc3NSdWxlcy5sZW5ndGgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjbGVhcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBuYXRpdmVGb250RmFjZSBvZiB0aGlzLm5hdGl2ZUZvbnRGYWNlcykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZG9jdW1lbnQuZm9udHMuZGVsZXRlKG5hdGl2ZUZvbnRGYWNlKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm5hdGl2ZUZvbnRGYWNlcy5sZW5ndGggPSAwOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5zdHlsZUVsZW1lbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc3R5bGVFbGVtZW50LnJlbW92ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zdHlsZUVsZW1lbnQgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGFzeW5jIGJpbmQoZm9udCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZm9udC5hdHRhY2hlZCB8fCBmb250Lm1pc3NpbmdGaWxlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgZm9udC5hdHRhY2hlZCA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmlzRm9udExvYWRpbmdBUElTdXBwb3J0ZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG5hdGl2ZUZvbnRGYWNlID0gZm9udC5jcmVhdGVOYXRpdmVGb250RmFjZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG5hdGl2ZUZvbnRGYWNlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5hZGROYXRpdmVGb250RmFjZShuYXRpdmVGb250RmFjZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYXdhaXQgbmF0aXZlRm9udEZhY2UubG9hZGVkOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGV4KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgRmFpbGVkIHRvIGxvYWQgZm9udCAnJHtuYXRpdmVGb250RmFjZS5mYW1pbHl9JzogJyR7ZXh9Jy5gKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9udC5kaXNhYmxlRm9udEZhY2UgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBleDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcnVsZSA9IGZvbnQuY3JlYXRlRm9udEZhY2VSdWxlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChydWxlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmluc2VydFJ1bGUocnVsZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5pc1N5bmNGb250TG9hZGluZ1N1cHBvcnRlZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGF3YWl0IG5ldyBQcm9taXNlKHJlc29sdmUgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHJlcXVlc3QgPSB0aGlzLl9xdWV1ZUxvYWRpbmdDYWxsYmFjayhyZXNvbHZlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wcmVwYXJlRm9udExvYWRFdmVudChmb250LCByZXF1ZXN0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBpc0ZvbnRMb2FkaW5nQVBJU3VwcG9ydGVkKCkgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkX2RvY3VtZW50OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBoYXNGb250cyA9ICEhKChfdGhpcyRfZG9jdW1lbnQgPSB0aGlzLl9kb2N1bWVudCkgIT09IG51bGwgJiYgX3RoaXMkX2RvY3VtZW50ICE9PSB2b2lkIDAgJiYgX3RoaXMkX2RvY3VtZW50LmZvbnRzKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICgwLCBfdXRpbC5zaGFkb3cpKHRoaXMsICJpc0ZvbnRMb2FkaW5nQVBJU3VwcG9ydGVkIiwgaGFzRm9udHMpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgaXNTeW5jRm9udExvYWRpbmdTdXBwb3J0ZWQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBzdXBwb3J0ZWQgPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKF9pc19ub2RlLmlzTm9kZUpTKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdXBwb3J0ZWQgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHR5cGVvZiBuYXZpZ2F0b3IgIT09ICJ1bmRlZmluZWQiICYmIC9Nb3ppbGxhXC81LjAuKj9ydjpcZCsuKj8gR2Vja28vLnRlc3QobmF2aWdhdG9yLnVzZXJBZ2VudCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN1cHBvcnRlZCA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICgwLCBfdXRpbC5zaGFkb3cpKHRoaXMsICJpc1N5bmNGb250TG9hZGluZ1N1cHBvcnRlZCIsIHN1cHBvcnRlZCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9xdWV1ZUxvYWRpbmdDYWxsYmFjayhjYWxsYmFjaykgewogICAgICAgICAgICAgICAgICAgICAgICBmdW5jdGlvbiBjb21wbGV0ZVJlcXVlc3QoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwuYXNzZXJ0KSghcmVxdWVzdC5kb25lLCAiY29tcGxldGVSZXF1ZXN0KCkgY2Fubm90IGJlIGNhbGxlZCB0d2ljZS4iKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlcXVlc3QuZG9uZSA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3aGlsZSAobG9hZGluZ1JlcXVlc3RzLmxlbmd0aCA+IDAgJiYgbG9hZGluZ1JlcXVlc3RzWzBdLmRvbmUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBvdGhlclJlcXVlc3QgPSBsb2FkaW5nUmVxdWVzdHMuc2hpZnQoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZXRUaW1lb3V0KG90aGVyUmVxdWVzdC5jYWxsYmFjaywgMCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgbG9hZGluZ1JlcXVlc3RzCiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSB0aGlzOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByZXF1ZXN0ID0gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZG9uZTogZmFsc2UsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb21wbGV0ZTogY29tcGxldGVSZXF1ZXN0LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FsbGJhY2sKICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgbG9hZGluZ1JlcXVlc3RzLnB1c2gocmVxdWVzdCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiByZXF1ZXN0OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgX2xvYWRUZXN0Rm9udCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdGVzdEZvbnQgPSBhdG9iKCJUMVJVVHdBTEFJQUFBd0F3UTBaR0lESHRaZzRBQUFPWUFBQUFnVVpHVkUxbGt6WndBQUFFSEFBQUFCeEhSRVZHQUJRQSIgKyAiRlFBQUJEZ0FBQUFlVDFNdk1sWU5Zd2tBQUFFZ0FBQUFZR050WVhBQkRRTFVBQUFDTkFBQUFVSm9aV0ZrL3hWRkRRQUEiICsgIkFMd0FBQUEyYUdobFlRZGtBK29BQUFEMEFBQUFKR2h0ZEhnRDZBQUFBQUFFV0FBQUFBWnRZWGh3QUFKUUFBQUFBUmdBIiArICJBQUFHYm1GdFpWam1kSDRBQUFHQUFBQUFzWEJ2YzNUL2hnQX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ICAgICAgICAgICAgICAgcmV0dXJuIGRhdGEuY2hhckNvZGVBdChvZmZzZXQpIDw8IDI0IHwgZGF0YS5jaGFyQ29kZUF0KG9mZnNldCArIDEpIDw8IDE2IHwgZGF0YS5jaGFyQ29kZUF0KG9mZnNldCArIDIpIDw8IDggfCBkYXRhLmNoYXJDb2RlQXQob2Zmc2V0ICsgMykgJiAweGZmOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGZ1bmN0aW9uIHNwbGljZVN0cmluZyhzLCBvZmZzZXQsIHJlbW92ZSwgaW5zZXJ0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjaHVuazEgPSBzLnN1YnN0cmluZygwLCBvZmZzZXQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2h1bmsyID0gcy5zdWJzdHJpbmcob2Zmc2V0ICsgcmVtb3ZlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBjaHVuazEgKyBpbnNlcnQgKyBjaHVuazI7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGksIGlpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjYW52YXMgPSB0aGlzLl9kb2N1bWVudC5jcmVhdGVFbGVtZW50KCJjYW52YXMiKTsKICAgICAgICAgICAgICAgICAgICAgICAgY2FudmFzLndpZHRoID0gMTsKICAgICAgICAgICAgICAgICAgICAgICAgY2FudmFzLmhlaWdodCA9IDE7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGN0eCA9IGNhbnZhcy5nZXRDb250ZXh0KCIyZCIpOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgY2FsbGVkID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgZnVuY3Rpb24gaXNGb250UmVhZHkobmFtZSwgY2FsbGJhY2spIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICgrK2NhbGxlZCA+IDMwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKCJMb2FkIHRlc3QgZm9udCBuZXZlciBsb2FkZWQuIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FsbGJhY2soKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHguZm9udCA9ICIzMHB4ICIgKyBuYW1lOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LmZpbGxUZXh0KCIuIiwgMCwgMjApOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaW1hZ2VEYXRhID0gY3R4LmdldEltYWdlRGF0YSgwLCAwLCAxLCAxKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpbWFnZURhdGEuZGF0YVszXSA+IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYWxsYmFjaygpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNldFRpbWVvdXQoaXNGb250UmVhZHkuYmluZChudWxsLCBuYW1lLCBjYWxsYmFjaykpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGxvYWRUZXN0Rm9udElkID0gYGx0JHtEYXRlLm5vdygpfSR7dGhpcy5sb2FkVGVzdEZvbnRJZCsrfWA7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBkYXRhID0gdGhpcy5fbG9hZFRlc3RGb250OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBDT01NRU5UX09GRlNFVCA9IDk3NjsKICAgICAgICAgICAgICAgICAgICAgICAgZGF0YSA9IHNwbGljZVN0cmluZyhkYXRhLCBDT01NRU5UX09GRlNFVCwgbG9hZFRlc3RGb250SWQubGVuZ3RoLCBsb2FkVGVzdEZvbnRJZCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IENGRl9DSEVDS1NVTV9PRkZTRVQgPSAxNjsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgWFhYWF9WQUxVRSA9IDB4NTg1ODU4NTg7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBjaGVja3N1bSA9IGludDMyKGRhdGEsIENGRl9DSEVDS1NVTV9PRkZTRVQpOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGkgPSAwLCBpaSA9IGxvYWRUZXN0Rm9udElkLmxlbmd0aCAtIDM7IGkgPCBpaTsgaSArPSA0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjaGVja3N1bSA9IGNoZWNrc3VtIC0gWFhYWF9WQUxVRSArIGludDMyKGxvYWRUZXN0Rm9udElkLCBpKSB8IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGkgPCBsb2FkVGVzdEZvbnRJZC5sZW5ndGgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNoZWNrc3VtID0gY2hlY2tzdW0gLSBYWFhYX1ZBTFVFICsgaW50MzIobG9hZFRlc3RGb250SWQgKyAiWFhYIiwgaSkgfCAwOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGRhdGEgPSBzcGxpY2VTdHJpbmcoZGF0YSwgQ0ZGX0NIRUNLU1VNX09GRlNFVCwgNCwgKDAsIF91dGlsLnN0cmluZzMyKShjaGVja3N1bSkpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB1cmwgPSBgdXJsKGRhdGE6Zm9udC9vcGVudHlwZTtiYXNlNjQsJHtidG9hKGRhdGEpfSk7YDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcnVsZSA9IGBAZm9udC1mYWNlIHtmb250LWZhbWlseToiJHtsb2FkVGVzdEZvbnRJZH0iO3NyYzoke3VybH19YDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5pbnNlcnRSdWxlKHJ1bGUpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBkaXYgPSB0aGlzLl9kb2N1bWVudC5jcmVhdGVFbGVtZW50KCJkaXYiKTsKICAgICAgICAgICAgICAgICAgICAgICAgZGl2LnN0eWxlLnZpc2liaWxpdHkgPSAiaGlkZGVuIjsKICAgICAgICAgICAgICAgICAgICAgICAgZGl2LnN0eWxlLndpZHRoID0gZGl2LnN0eWxlLmhlaWdodCA9ICIxMHB4IjsKICAgICAgICAgICAgICAgICAgICAgICAgZGl2LnN0eWxlLnBvc2l0aW9uID0gImFic29sdXRlIjsKICAgICAgICAgICAgICAgICAgICAgICAgZGl2LnN0eWxlLnRvcCA9IGRpdi5zdHlsZS5sZWZ0ID0gIjBweCI7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgbmFtZSBvZiBbZm9udC5sb2FkZWROYW1lLCBsb2FkVGVzdEZvbnRJZF0pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHNwYW4gPSB0aGlzLl9kb2N1bWVudC5jcmVhdGVFbGVtZW50KCJzcGFuIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzcGFuLnRleHRDb250ZW50ID0gIkhpIjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNwYW4uc3R5bGUuZm9udEZhbWlseSA9IG5hbWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkaXYuYXBwZW5kKHNwYW4pOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2RvY3VtZW50LmJvZHkuYXBwZW5kKGRpdik7CiAgICAgICAgICAgICAgICAgICAgICAgIGlzRm9udFJlYWR5KGxvYWRUZXN0Rm9udElkLCAoKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkaXYucmVtb3ZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXF1ZXN0LmNvbXBsZXRlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGV4cG9ydHMuRm9udExvYWRlciA9IEZvbnRMb2FkZXI7CiAgICAgICAgICAgICAgICBjbGFzcyBGb250RmFjZU9iamVjdCB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IodHJhbnNsYXRlZERhdGEsIF9yZWYyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc0V2YWxTdXBwb3J0ZWQgPSB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGlzYWJsZUZvbnRGYWNlID0gZmFsc2UsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZ25vcmVFcnJvcnMgPSBmYWxzZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGluc3BlY3RGb250ID0gbnVsbAogICAgICAgICAgICAgICAgICAgICAgICB9ID0gX3JlZjI7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29tcGlsZWRHbHlwaHMgPSBPYmplY3QuY3JlYXRlKG51bGwpOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGkgaW4gdHJhbnNsYXRlZERhdGEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXNbaV0gPSB0cmFuc2xhdGVkRGF0YVtpXTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmlzRXZhbFN1cHBvcnRlZCA9IGlzRXZhbFN1cHBvcnRlZCAhPT0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGlzYWJsZUZvbnRGYWNlID0gZGlzYWJsZUZvbnRGYWNlID09PSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmlnbm9yZUVycm9ycyA9IGlnbm9yZUVycm9ycyA9PT0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5faW5zcGVjdEZvbnQgPSBpbnNwZWN0Rm9udDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY3JlYXRlTmF0aXZlRm9udEZhY2UoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRfaW5zcGVjdEZvbnQ7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5kYXRhIHx8IHRoaXMuZGlzYWJsZUZvbnRGYWNlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBsZXQgbmF0aXZlRm9udEZhY2U7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5jc3NGb250SW5mbykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgbmF0aXZlRm9udEZhY2UgPSBuZXcgRm9udEZhY2UodGhpcy5sb2FkZWROYW1lLCB0aGlzLmRhdGEsIHt9KTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNzcyA9IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB3ZWlnaHQ6IHRoaXMuY3NzRm9udEluZm8uZm9udFdlaWdodAogICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmNzc0ZvbnRJbmZvLml0YWxpY0FuZ2xlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3NzLnN0eWxlID0gYG9ibGlxdWUgJHt0aGlzLmNzc0ZvbnRJbmZvLml0YWxpY0FuZ2xlfWRlZ2A7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBuYXRpdmVGb250RmFjZSA9IG5ldyBGb250RmFjZSh0aGlzLmNzc0ZvbnRJbmZvLmZvbnRGYW1pbHksIHRoaXMuZGF0YSwgY3NzKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAoX3RoaXMkX2luc3BlY3RGb250ID0gdGhpcy5faW5zcGVjdEZvbnQpID09PSBudWxsIHx8IF90aGlzJF9pbnNwZWN0Rm9udCA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3RoaXMkX2luc3BlY3RGb250LmNhbGwodGhpcywgdGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuYXRpdmVGb250RmFjZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY3JlYXRlRm9udEZhY2VSdWxlKCkgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkX2luc3BlY3RGb250MjsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLmRhdGEgfHwgdGhpcy5kaXNhYmxlRm9udEZhY2UpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGRhdGEgPSAoMCwgX3V0aWwuYnl0ZXNUb1N0cmluZykodGhpcy5kYXRhKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdXJsID0gYHVybChkYXRhOiR7dGhpcy5taW1ldHlwZX07YmFzZTY0LCR7YnRvYShkYXRhKX0pO2A7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBydWxlOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuY3NzRm9udEluZm8pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJ1bGUgPSBgQGZvbnQtZmFjZSB7Zm9udC1mYW1pbHk6IiR7dGhpcy5sb2FkZWROYW1lfSI7c3JjOiR7dXJsfX1gOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGNzcyA9IGBmb250LXdlaWdodDogJHt0aGlzLmNzc0ZvbnRJbmZvLmZvbnRXZWlnaHR9O2A7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5jc3NGb250SW5mby5pdGFsaWNBbmdsZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNzcyArPSBgZm9udC1zdHlsZTogb2JsaXF1ZSAke3RoaXMuY3NzRm9udEluZm8uaXRhbGljQW5nbGV9ZGVnO2A7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBydWxlID0gYEBmb250LWZhY2Uge2ZvbnQtZmFtaWx5OiIke3RoaXMuY3NzRm9udEluZm8uZm9udEZhbWlseX0iOyR7Y3NzfXNyYzoke3VybH19YDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAoX3RoaXMkX2luc3BlY3RGb250MiA9IHRoaXMuX2luc3BlY3RGb250KSA9PT0gbnVsbCB8fCBfdGhpcyRfaW5zcGVjdEZvbnQyID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRfaW5zcGVjdEZvbnQyLmNhbGwodGhpcywgdGhpcywgdXJsKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHJ1bGU7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldFBhdGhHZW5lcmF0b3Iob2JqcywgY2hhcmFjdGVyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmNvbXBpbGVkR2x5cGhzW2NoYXJhY3Rlcl0gIT09IHVuZGVmaW5lZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuY29tcGlsZWRHbHlwaHNbY2hhcmFjdGVyXTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBsZXQgY21kczsKICAgICAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNtZHMgPSBvYmpzLmdldCh0aGlzLmxvYWRlZE5hbWUgKyAiX3BhdGhfIiArIGNoYXJhY3Rlcik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGV4KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuaWdub3JlRXJyb3JzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgZXg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYGdldFBhdGhHZW5lcmF0b3IgLSBpZ25vcmluZyBjaGFyYWN0ZXI6ICIke2V4fSIuYCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5jb21waWxlZEdseXBoc1tjaGFyYWN0ZXJdID0gZnVuY3Rpb24gKGMsIHNpemUpIHt9OwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmlzRXZhbFN1cHBvcnRlZCAmJiBfdXRpbC5GZWF0dXJlVGVzdC5pc0V2YWxTdXBwb3J0ZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGpzQnVmID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGN1cnJlbnQgb2YgY21kcykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGFyZ3MgPSBjdXJyZW50LmFyZ3MgIT09IHVuZGVmaW5lZCA/IGN1cnJlbnQuYXJncy5qb2luKCIsIikgOiAiIjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBqc0J1Zi5wdXNoKCJjLiIsIGN1cnJlbnQuY21kLCAiKCIsIGFyZ3MsICIpO1xuIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5jb21waWxlZEdseXBoc1tjaGFyYWN0ZXJdID0gbmV3IEZ1bmN0aW9uKCJjIiwgInNpemUiLCBqc0J1Zi5qb2luKCIiKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuY29tcGlsZWRHbHlwaHNbY2hhcmFjdGVyXSA9IGZ1bmN0aW9uIChjLCBzaXplKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGN1cnJlbnQgb2YgY21kcykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjdXJyZW50LmNtZCA9PT0gInNjYWxlIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LmFyZ3MgPSBbc2l6ZSwgLXNpemVdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjW2N1cnJlbnQuY21kXS5hcHBseShjLCBjdXJyZW50LmFyZ3MpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGV4cG9ydHMuRm9udEZhY2VPYmplY3QgPSBGb250RmFjZU9iamVjdDsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTQ2ICovCiAgICAgICAgICAgIC8qKiovICgoX191bnVzZWRfd2VicGFja19tb2R1bGUsIGV4c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R3aWNlIG9uIGFuIG9iamVjdCIpOyB9IH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQocmVjZWl2ZXIsIHByaXZhdGVTZXQsIGZuKSB7IGlmICghcHJpdmF0ZVNldC5oYXMocmVjZWl2ZXIpKSB7IHRocm93IG5ldyBUeXBlRXJyb3IoImF0dGVtcHRlZCB0byBnZXQgcHJpdmF0ZSBmaWVsZCBvbiBub24taW5zdGFuY2UiKTsgfSByZXR1cm4gZm47IH0KICAgICAgICAgICAgICAgIGNvbnN0IE1JTl9GT05UX1NJWkUgPSAxNjsKICAgICAgICAgICAgICAgIGNvbnN0IE1BWF9GT05UX1NJWkUgPSAxMDA7CiAgICAgICAgICAgICAgICBjb25zdCBNQVhfR1JPVVBfU0laRSA9IDQwOTY7CiAgICAgICAgICAgICAgICBjb25zdCBFWEVDVVRJT05fVElNRSA9IDE1OwogICAgICAgICAgICAgICAgY29uc3QgRVhFQ1VUSU9OX1NURVBTID0gMTA7CiAgICAgICAgICAgICAgICBjb25zdCBNQVhfU0laRV9UT19DT01QSUxFID0gMTAwMDsKICAgICAgICAgICAgICAgIGNvbnN0IEZVTExfQ0hVTktfSEVJR0hUID0gMTY7CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBtaXJyb3JDb250ZXh0T3BlcmF0aW9ucyhjdHgsIGRlc3RDdHgpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoY3R4Ll9yZW1vdmVNaXJyb3JpbmcpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCJDb250ZXh0IGlzIGFscmVhZHkgZm9yd2FyZGluZyBvcGVyYXRpb25zLiIpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjdHguX19vcmlnaW5hbFNhdmUgPSBjdHguc2F2ZTsKICAgICAgICAgICAgICAgICAgICBjdHguX19vcmlnaW5hbFJlc3RvcmUgPSBjdHgucmVzdG9yZTsKICAgICAgICAgICAgICAgICAgICBjdHguX19vcmlnaW5hbFJvdGF0ZSA9IGN0eC5yb3RhdGU7CiAgICAgICAgICAgICAgICAgICAgY3R4Ll9fb3JpZ2luYWxTY2FsZSA9IGN0eC5zY2FsZTsKICAgICAgICAgICAgICAgICAgICBjdHguX19vcmlnaW5hbFRyYW5zbGF0ZSA9IGN0eC50cmFuc2xhdGU7CiAgICAgICAgICAgICAgICAgICAgY3R4Ll9fb3JpZ2luYWxUcmFuc2Zvcm0gPSBjdHgudHJhbnNmb3JtOwogICAgICAgICAgICAgICAgICAgIGN0eC5fX29yaWdpbmFsU2V0VHJhbnNmb3JtID0gY3R4LnNldFRyYW5zZm9ybTsKICAgICAgICAgICAgICAgICAgICBjdHguX19vcmlnaW5hbFJlc2V0VHJhbnNmb3JtID0gY3R4LnJlc2V0VHJhbnNmb3JtOwogICAgICAgICAgICAgICAgICAgIGN0eC5fX29yaWdpbmFsQ2xpcCA9IGN0eC5jbGlwOwogICAgICAgICAgICAgICAgICAgIGN0eC5fX29yaWdpbmFsTW92ZVRvID0gY3R4Lm1vdmVUbzsKICAgICAgICAgICAgICAgICAgICBjdHguX19vcmlnaW5hbExpbmVUbyA9IGN0eC5saW5lVG87CiAgICAgICAgICAgICAgICAgICAgY3R4Ll9fb3JpZ2luYWxCZXppZXJDdXJ2ZVRvID0gY3R4LmJlemllckN1cnZlVG87CiAgICAgICAgICAgICAgICAgICAgY3R4Ll9fb3JpZ2luYWxSZWN0ID0gY3R4LnJlY3Q7CiAgICAgICAgICAgICAgICAgICAgY3R4Ll9fb3JpZ2luYWxDbG9zZVBhdGggPSBjdHguY2xvc2VQYXRoOwogICAgICAgICAgICAgICAgICAgIGN0eC5fX29yaWdpbmFsQmVnaW5QYXRoID0gY3R4LmJlZ2luUGF0aDsKICAgICAgICAgICAgICAgICAgICBjdHguX3JlbW92ZU1pcnJvcmluZyA9ICgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnNhdmUgPSBjdHguX19vcmlnaW5hbFNhdmU7CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5yZXN0b3JlID0gY3R4Ll9fb3JpZ2luYWxSZXN0b3JlOwogICAgICAgICAgICAgICAgICAgICAgICBjdHgucm90YXRlID0gY3R4Ll9fb3JpZ2luYWxSb3RhdGU7CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5zY2FsZSA9IGN0eC5fX29yaWdpbmFsU2NhbGU7CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eC50cmFuc2xhdGUgPSBjdHguX19vcmlnaW5hbFRyYW5zbGF0ZTsKICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnRyYW5zZm9ybSA9IGN0eC5fX29yaWdpbmFsVHJhbnNmb3JtOwogICAgICAgICAgICAgICAgICAgICAgICBjdHguc2V0VHJhbnNmb3JtID0gY3R4Ll9fb3JpZ2luYWxTZXRUcmFuc2Zvcm07CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5yZXNldFRyYW5zZm9ybSA9IGN0eC5fX29yaWdpbmFsUmVzZXRUcmFuc2Zvcm07CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5jbGlwID0gY3R4Ll9fb3JpZ2luYWxDbGlwOwogICAgICAgICAgICAgICAgICAgICAgICBjdHgubW92ZVRvID0gY3R4Ll9fb3JpZ2luYWxNb3ZlVG87CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5saW5lVG8gPSBjdHguX19vcmlnaW5hbExpbmVUbzsKICAgICAgICAgICAgICAgICAgICAgICAgY3R4LmJlemllckN1cnZlVG8gPSBjdHguX19vcmlnaW5hbEJlemllckN1cnZlVG87CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5yZWN0ID0gY3R4Ll9fb3JpZ2luYWxSZWN0OwogICAgICAgICAgICAgICAgICAgICAgICBjdHguY2xvc2VQYXRoID0gY3R4Ll9fb3JpZ2luYWxDbG9zZVBhdGg7CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5iZWdpblBhdGggPSBjdHguX19vcmlnaW5hbEJlZ2luUGF0aDsKICAgICAgICAgICAgICAgICAgICAgICAgZGVsZXRlIGN0eC5fcmVtb3ZlTWlycm9yaW5nOwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgY3R4LnNhdmUgPSBmdW5jdGlvbiBjdHhTYXZlKCkgewogICAgICAgICAgICAgICAgICAgICAgICBkZXN0Q3R4LnNhdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fX29yaWdpbmFsU2F2ZSgpOwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgY3R4LnJlc3RvcmUgPSBmdW5jdGlvbiBjdHhSZXN0b3JlKCkgewogICAgICAgICAgICAgICAgICAgICAgICBkZXN0Q3R4LnJlc3RvcmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fX29yaWdpbmFsUmVzdG9yZSgpOwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgY3R4LnRyYW5zbGF0ZSA9IGZ1bmN0aW9uIGN0eFRyYW5zbGF0ZSh4LCB5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGRlc3RDdHgudHJhbnNsYXRlKHgsIHkpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9fb3JpZ2luYWxUcmFuc2xhdGUoeCwgeSk7CiAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICBjdHguc2NhbGUgPSBmdW5jdGlvbiBjdHhTY2FsZSh4LCB5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGRlc3RDdHguc2NhbGUoeCwgeSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX19vcmlnaW5hbFNjYWxlKHgsIHkpOwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgY3R4LnRyYW5zZm9ybSA9IGZ1bmN0aW9uIGN0eFRyYW5zZm9ybShhLCBiLCBjLCBkLCBlLCBmKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGRlc3RDdHgudHJhbnNmb3JtKGEsIGIsIGMsIGQsIGUsIGYpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9fb3JpZ2luYWxUcmFuc2Zvcm0oYSwgYiwgYywgZCwgZSwgZik7CiAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICBjdHguc2V0VHJhbnNmb3JtID0gZnVuY3Rpb24gY3R4U2V0VHJhbnNmb3JtKGEsIGIsIGMsIGQsIGUsIGYpIHsKICAgICAgICAgICAgICAgICAgICAgICAgZGVzdEN0eC5zZXRUcmFuc2Zvcm0oYSwgYiwgYywgZCwgZSwgZik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX19vcmlnaW5hbFNldFRyYW5zZm9ybShhLCBiLCBjLCBkLCBlLCBmKTsKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIGN0eC5yZXNldFRyYW5zZm9ybSA9IGZ1bmN0aW9uIGN0eFJlc2V0VHJhbnNmb3JtKCkgewogICAgICAgICAgICAgICAgICAgICAgICBkZXN0Q3R4LnJlc2V0VHJhbnNmb3JtKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX19vcmlnaW5hbFJlc2V0VHJhbnNmb3JtKCk7CiAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICBjdHgucm90YXRlID0gZnVuY3Rpb24gY3R4Um90YXRlKGFuZ2xlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGRlc3RDdHgucm90YXRlKGFuZ2xlKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fX29yaWdpbmFsUm90YXRlKGFuZ2xlKTsKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIGN0eC5jbGlwID0gZnVuY3Rpb24gY3R4Um90YXRlKHJ1bGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgZGVzdEN0eC5jbGlwKHJ1bGUpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9fb3JpZ2luYWxDbGlwKHJ1bGUpOwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgY3R4Lm1vdmVUbyA9IGZ1bmN0aW9uICh4LCB5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGRlc3RDdHgubW92ZVRvKHgsIHkpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9fb3JpZ2luYWxNb3ZlVG8oeCwgeSk7CiAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICBjdHgubGluZVRvID0gZnVuY3Rpb24gKHgsIHkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgZGVzdEN0eC5saW5lVG8oeCwgeSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX19vcmlnaW5hbExpbmVUbyh4LCB5KTsKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIGN0eC5iZXppZXJDdXJ2ZVRvID0gZnVuY3Rpb24gKGNwMXgsIGNwMXksIGNwMngsIGNwMnksIHgsIHkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgZGVzdEN0eC5iZXppZXJDdXJ2ZVRvKGNwMXgsIGNwMXksIGNwMngsIGNwMnksIHgsIHkpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9fb3JpZ2luYWxCZXppZXJDdXJ2ZVRvKGNwMXgsIGNwMXksIGNwMngsIGNwMnksIHgsIHkpOwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgY3R4LnJlY3QgPSBmdW5jdGlvbiAoeCwgeSwgd2lkdGgsIGhlaWdodCkgewogICAgICAgICAgICAgICAgICAgICAgICBkZXN0Q3R4LnJlY3QoeCwgeSwgd2lkdGgsIGhlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX19vcmlnaW5hbFJlY3QoeCwgeSwgd2lkdGgsIGhlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICBjdHguY2xvc2VQYXRoID0gZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgICAgICBkZXN0Q3R4LmNsb3NlUGF0aCgpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9fb3JpZ2luYWxDbG9zZVBhdGgoKTsKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIGN0eC5iZWdpblBhdGggPSBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGRlc3RDdHguYmVnaW5QYXRoKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX19vcmlnaW5hbEJlZ2luUGF0aCgpOwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBDYWNoZWRDYW52YXNlcyB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IoY2FudmFzRmFjdG9yeSkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbnZhc0ZhY3RvcnkgPSBjYW52YXNGYWN0b3J5OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNhY2hlID0gT2JqZWN0LmNyZWF0ZShudWxsKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0Q2FudmFzKGlkLCB3aWR0aCwgaGVpZ2h0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBjYW52YXNFbnRyeTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuY2FjaGVbaWRdICE9PSB1bmRlZmluZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhbnZhc0VudHJ5ID0gdGhpcy5jYWNoZVtpZF07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbnZhc0ZhY3RvcnkucmVzZXQoY2FudmFzRW50cnksIHdpZHRoLCBoZWlnaHQpOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FudmFzRW50cnkgPSB0aGlzLmNhbnZhc0ZhY3RvcnkuY3JlYXRlKHdpZHRoLCBoZWlnaHQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jYWNoZVtpZF0gPSBjYW52YXNFbnRyeTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gY2FudmFzRW50cnk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGRlbGV0ZShpZCkgewogICAgICAgICAgICAgICAgICAgICAgICBkZWxldGUgdGhpcy5jYWNoZVtpZF07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNsZWFyKCkgewogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGlkIGluIHRoaXMuY2FjaGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNhbnZhc0VudHJ5ID0gdGhpcy5jYWNoZVtpZF07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbnZhc0ZhY3RvcnkuZGVzdHJveShjYW52YXNFbnRyeSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWxldGUgdGhpcy5jYWNoZVtpZF07CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBkcmF3SW1hZ2VBdEludGVnZXJDb29yZHMoY3R4LCBzcmNJbWcsIHNyY1gsIHNyY1ksIHNyY1csIHNyY0gsIGRlc3RYLCBkZXN0WSwgZGVzdFcsIGRlc3RIKSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgW2EsIGIsIGMsIGQsIHR4LCB0eV0gPSAoMCwgX2Rpc3BsYXlfdXRpbHMuZ2V0Q3VycmVudFRyYW5zZm9ybSkoY3R4KTsKICAgICAgICAgICAgICAgICAgICBpZiAoYiA9PT0gMCAmJiBjID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHRsWCA9IGRlc3RYICogYSArIHR4OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByVGxYID0gTWF0aC5yb3VuZCh0bFgpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB0bFkgPSBkZXN0WSAqIGQgKyB0eTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgclRsWSA9IE1hdGgucm91bmQodGxZKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYnJYID0gKGRlc3RYICsgZGVzdFcpICogYSArIHR4OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByV2lkdGggPSBNYXRoLmFicyhNYXRoLnJvdW5kKGJyWCkgLSByVGxYKSB8fCAxOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBiclkgPSAoZGVzdFkgKyBkZXN0SCkgKiBkICsgdHk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHJIZWlnaHQgPSBNYXRoLmFicyhNYXRoLnJvdW5kKGJyWSkgLSByVGxZKSB8fCAxOwogICAgICAgICAgICAgICAgICAgICAgICBjdHguc2V0VHJhbnNmb3JtKE1hdGguc2lnbihhKSwgMCwgMCwgTWF0aC5zaWduKGQpLCByVGxYLCByVGxZKTsKICAgICAgICAgICAgICAgICAgICAgICAgY3R4LmRyYXdJbWFnZShzcmNJbWcsIHNyY1gsIHNyY1ksIHNyY1csIHNyY0gsIDAsIDAsIHJXaWR0aCwgckhlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5zZXRUcmFuc2Zvcm0oYSwgYiwgYywgZCwgdHgsIHR5KTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFtyV2lkdGgsIHJIZWlnaHRdOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBpZiAoYSA9PT0gMCAmJiBkID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHRsWCA9IGRlc3RZICogYyArIHR4OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByVGxYID0gTWF0aC5yb3VuZCh0bFgpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB0bFkgPSBkZXN0WCAqIGIgKyB0eTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgclRsWSA9IE1hdGgucm91bmQodGxZKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYnJYID0gKGRlc3RZICsgZGVzdEgpICogYyArIHR4OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByV2lkdGggPSBNYXRoLmFicyhNYXRoLnJvdW5kKGJyWCkgLSByVGxYKSB8fCAxOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBiclkgPSAoZGVzdFggKyBkZXN0VykgKiBiICsgdHk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHJIZWlnaHQgPSBNYXRoLmFicyhNYXRoLnJvdW5kKGJyWSkgLSByVGxZKSB8fCAxOwogICAgICAgICAgICAgICAgICAgICAgICBjdHguc2V0VHJhbnNmb3JtKDAsIE1hdGguc2lnbihiKSwgTWF0aC5zaWduKGMpLCAwLCByVGxYLCByVGxZKTsKICAgICAgICAgICAgICAgICAgICAgICAgY3R4LmRyYXdJbWFnZShzcmNJbWcsIHNyY1gsIHNyY1ksIHNyY1csIHNyY0gsIDAsIDAsIHJIZWlnaHQsIHJXaWR0aCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5zZXRUcmFuc2Zvcm0oYSwgYiwgYywgZCwgdHgsIHR5KTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFtySGVpZ2h0LCByV2lkdGhdOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjdHguZHJhd0ltYWdlKHNyY0ltZywgc3JjWCwgc3JjWSwgc3JjVywgc3JjSCwgZGVzdFgsIGRlc3RZLCBkZXN0VywgZGVzdEgpOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHNjYWxlWCA9IE1hdGguaHlwb3QoYSwgYik7CiAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2NhbGVZID0gTWF0aC5oeXBvdChjLCBkKTsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gW3NjYWxlWCAqIGRlc3RXLCBzY2FsZVkgKiBkZXN0SF07CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBjb21waWxlVHlwZTNHbHlwaChpbWdEYXRhKSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICB3aWR0aCwKICAgICAgICAgICAgICAgICAgICAgICAgaGVpZ2h0CiAgICAgICAgICAgICAgICAgICAgfSA9IGltZ0RhdGE7CiAgICAgICAgICAgICAgICAgICAgaWYgKHdpZHRoID4gTUFYX1NJWkVfVE9fQ09NUElMRSB8fCBoZWlnaHQgPiBNQVhfU0laRV9UT19DT01QSUxFKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjb25zdCBQT0lOVF9UT19QUk9DRVNTX0xJTUlUID0gMTAwMDsKICAgICAgICAgICAgICAgICAgICBjb25zdCBQT0lOVF9UWVBFUyA9IG5ldyBVaW50OEFycmF5KFswLCAyLCA0LCAwLCAxLCAwLCA1LCA0LCA4LCAxMCwgMCwgOCwgMCwgMiwgMSwgMF0pOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHdpZHRoMSA9IHdpZHRoICsgMTsKICAgICAgICAgICAgICAgICAgICBsZXQgcG9pbnRzID0gbmV3IFVpbnQ4QXJyYXkod2lkdGgxICogKGhlaWdodCArIDEpKTsKICAgICAgICAgICAgICAgICAgICBsZXQgaSwgaiwgajA7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgbGluZVNpemUgPSB3aWR0aCArIDcgJiB+NzsKICAgICAgICAgICAgICAgICAgICBsZXQgZGF0YSA9IG5ldyBVaW50OEFycmF5KGxpbmVTaXplICogaGVpZ2h0KSwKICAgICAgICAgICAgICAgICAgICAgICAgcG9zID0gMDsKICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGVsZW0gb2YgaW1nRGF0YS5kYXRhKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBtYXNrID0gMTI4OwogICAgICAgICAgICAgICAgICAgICAgICB3aGlsZSAobWFzayA+IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRhdGFbcG9zKytdID0gZWxlbSAmIG1hc2sgPyAwIDogMjU1OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbWFzayA+Pj0gMTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBsZXQgY291bnQgPSAwOwogICAgICAgICAgICAgICAgICAgIHBvcyA9IDA7CiAgICAgICAgICAgICAgICAgICAgaWYgKGRhdGFbcG9zXSAhPT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICBwb2ludHNbMF0gPSAxOwogICAgICAgICAgICAgICAgICAgICAgICArK2NvdW50OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBmb3IgKGogPSAxOyBqIDwgd2lkdGg7IGorKykgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZGF0YVtwb3NdICE9PSBkYXRhW3BvcyArIDFdKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwb2ludHNbal0gPSBkYXRhW3Bvc10gPyAyIDogMTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICsrY291bnQ7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcG9zKys7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmIChkYXRhW3Bvc10gIT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgcG9pbnRzW2pdID0gMjsKICAgICAgICAgICAgICAgICAgICAgICAgKytjb3VudDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZm9yIChpID0gMTsgaSA8IGhlaWdodDsgaSsrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHBvcyA9IGkgKiBsaW5lU2l6ZTsKICAgICAgICAgICAgICAgICAgICAgICAgajAgPSBpICogd2lkdGgxOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZGF0YVtwb3MgLSBsaW5lU2l6ZV0gIT09IGRhdGFbcG9zXSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcG9pbnRzW2owXSA9IGRhdGFbcG9zXSA/IDEgOiA4OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgKytjb3VudDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBsZXQgc3VtID0gKGRhdGFbcG9zXSA/IDQgOiAwKSArIChkYXRhW3BvcyAtIGxpbmVTaXplXSA/IDggOiAwKTsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChqID0gMTsgaiA8IHdpZHRoOyBqKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN1bSA9IChzdW0gPj4gMikgKyAoZGF0YVtwb3MgKyAxXSA/IDQgOiAwKSArIChkYXRhW3BvcyAtIGxpbmVTaXplICsgMV0gPyA4IDogMCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoUE9JTlRfVFlQRVNbc3VtXSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBvaW50c1tqMCArIGpdID0gUE9JTlRfVFlQRVNbc3VtXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICArK2NvdW50OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgcG9zKys7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGRhdGFbcG9zIC0gbGluZVNpemVdICE9PSBkYXRhW3Bvc10pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBvaW50c1tqMCArIGpdID0gZGF0YVtwb3NdID8gMiA6IDQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICArK2NvdW50OwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjb3VudCA+IFBPSU5UX1RPX1BST0NFU1NfTElNSVQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHBvcyA9IGxpbmVTaXplICogKGhlaWdodCAtIDEpOwogICAgICAgICAgICAgICAgICAgIGowID0gaSAqIHdpZHRoMTsKICAgICAgICAgICAgICAgICAgICBpZiAoZGF0YVtwb3NdICE9PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHBvaW50c1tqMF0gPSA4OwogICAgICAgICAgICAgICAgICAgICAgICArK2NvdW50OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBmb3IgKGogPSAxOyBqIDwgd2lkdGg7IGorKykgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZGF0YVtwb3NdICE9PSBkYXRhW3BvcyArIDFdKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwb2ludHNbajAgKyBqXSA9IGRhdGFbcG9zXSA/IDQgOiA4OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgKytjb3VudDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBwb3MrKzsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaWYgKGRhdGFbcG9zXSAhPT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICBwb2ludHNbajAgKyBqXSA9IDQ7CiAgICAgICAgICAgICAgICAgICAgICAgICsrY291bnQ7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmIChjb3VudCA+IFBPSU5UX1RPX1BST0NFU1NfTElNSVQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0ZXBzID0gbmV3IEludDMyQXJyYXkoWzAsIHdpZHRoMSwgLTEsIDAsIC13aWR0aDEsIDAsIDAsIDAsIDFdKTsKICAgICAgICAgICAgICAgICAgICBjb25zdCBwYXRoID0gbmV3IFBhdGgyRCgpOwogICAgICAgICAgICAgICAgICAgIGZvciAoaSA9IDA7IGNvdW50ICYmIGkgPD0gaGVpZ2h0OyBpKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHAgPSBpICogd2lkdGgxOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBlbmQgPSBwICsgd2lkdGg7CiAgICAgICAgICAgICAgICAgICAgICAgIHdoaWxlIChwIDwgZW5kICYmICFwb2ludHNbcF0pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHArKzsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAocCA9PT0gZW5kKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBwYXRoLm1vdmVUbyhwICUgd2lkdGgxLCBpKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcDAgPSBwOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgdHlwZSA9IHBvaW50c1twXTsKICAgICAgICAgICAgICAgICAgICAgICAgZG8gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3RlcCA9IHN0ZXBzW3R5cGVdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZG8gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHAgKz0gc3RlcDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gd2hpbGUgKCFwb2ludHNbcF0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcHAgPSBwb2ludHNbcF07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAocHAgIT09IDUgJiYgcHAgIT09IDEwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHlwZSA9IHBwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBvaW50c1twXSA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHR5cGUgPSBwcCAmIDB4MzMgKiB0eXBlID4+IDQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcG9pbnRzW3BdICY9IHR5cGUgPj4gMiB8IHR5cGUgPDwgMjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhdGgubGluZVRvKHAgJSB3aWR0aDEsIHAgLyB3aWR0aDEgfCAwKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghcG9pbnRzW3BdKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLS1jb3VudDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfSB3aGlsZSAocDAgIT09IHApOwogICAgICAgICAgICAgICAgICAgICAgICAtLWk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGRhdGEgPSBudWxsOwogICAgICAgICAgICAgICAgICAgIHBvaW50cyA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgZHJhd091dGxpbmUgPSBmdW5jdGlvbiAoYykgewogICAgICAgICAgICAgICAgICAgICAgICBjLnNhdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgYy5zY2FsZSgxIC8gd2lkdGgsIC0xIC8gaGVpZ2h0KTsKICAgICAgICAgICAgICAgICAgICAgICAgYy50cmFuc2xhdGUoMCwgLWhlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGMuZmlsbChwYXRoKTsKICAgICAgICAgICAgICAgICAgICAgICAgYy5iZWdpblBhdGgoKTsKICAgICAgICAgICAgICAgICAgICAgICAgYy5yZXN0b3JlKCk7CiAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gZHJhd091dGxpbmU7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBDYW52YXNFeHRyYVN0YXRlIHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3Rvcih3aWR0aCwgaGVpZ2h0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYWxwaGFJc1NoYXBlID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZm9udFNpemUgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmZvbnRTaXplU2NhbGUgPSAxOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnRleHRNYXRyaXggPSBfdXRpbC5JREVOVElUWV9NQVRSSVg7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudGV4dE1hdHJpeFNjYWxlID0gMTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5mb250TWF0cml4ID0gX3V0aWwuRk9OVF9JREVOVElUWV9NQVRSSVg7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubGVhZGluZyA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMueCA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMueSA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubGluZVggPSAwOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmxpbmVZID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jaGFyU3BhY2luZyA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMud29yZFNwYWNpbmcgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnRleHRIU2NhbGUgPSAxOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnRleHRSZW5kZXJpbmdNb2RlID0gX3V0aWwuVGV4dFJlbmRlcmluZ01vZGUuRklMTDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy50ZXh0UmlzZSA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZmlsbENvbG9yID0gIiMwMDAwMDAiOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnN0cm9rZUNvbG9yID0gIiMwMDAwMDAiOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBhdHRlcm5GaWxsID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZmlsbEFscGhhID0gMTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zdHJva2VBbHBoYSA9IDE7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubGluZVdpZHRoID0gMTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5hY3RpdmVTTWFzayA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudHJhbnNmZXJNYXBzID0gIm5vbmUiOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnN0YXJ0TmV3UGF0aEFuZENsaXBCb3goWzAsIDAsIHdpZHRoLCBoZWlnaHRdKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY2xvbmUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNsb25lID0gT2JqZWN0LmNyZWF0ZSh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmUuY2xpcEJveCA9IHRoaXMuY2xpcEJveC5zbGljZSgpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gY2xvbmU7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNldEN1cnJlbnRQb2ludCh4LCB5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMueCA9IHg7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMueSA9IHk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHVwZGF0ZVBhdGhNaW5NYXgodHJhbnNmb3JtLCB4LCB5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIFt4LCB5XSA9IF91dGlsLlV0aWwuYXBwbHlUcmFuc2Zvcm0oW3gsIHldLCB0cmFuc2Zvcm0pOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm1pblggPSBNYXRoLm1pbih0aGlzLm1pblgsIHgpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm1pblkgPSBNYXRoLm1pbih0aGlzLm1pblksIHkpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm1heFggPSBNYXRoLm1heCh0aGlzLm1heFgsIHgpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm1heFkgPSBNYXRoLm1heCh0aGlzLm1heFksIHkpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB1cGRhdGVSZWN0TWluTWF4KHRyYW5zZm9ybSwgcmVjdCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwMSA9IF91dGlsLlV0aWwuYXBwbHlUcmFuc2Zvcm0ocmVjdCwgdHJhbnNmb3JtKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcDIgPSBfdXRpbC5VdGlsLmFwcGx5VHJhbnNmb3JtKHJlY3Quc2xpY2UoMiksIHRyYW5zZm9ybSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubWluWCA9IE1hdGgubWluKHRoaXMubWluWCwgcDFbMF0sIHAyWzBdKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5taW5ZID0gTWF0aC5taW4odGhpcy5taW5ZLCBwMVsxXSwgcDJbMV0pOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm1heFggPSBNYXRoLm1heCh0aGlzLm1heFgsIHAxWzBdLCBwMlswXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubWF4WSA9IE1hdGgubWF4KHRoaXMubWF4WSwgcDFbMV0sIHAyWzFdKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdXBkYXRlU2NhbGluZ1BhdGhNaW5NYXgodHJhbnNmb3JtLCBtaW5NYXgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgX3V0aWwuVXRpbC5zY2FsZU1pbk1heCh0cmFuc2Zvcm0sIG1pbk1heCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubWluWCA9IE1hdGgubWluKHRoaXMubWluWCwgbWluTWF4WzBdKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5tYXhYID0gTWF0aC5tYXgodGhpcy5tYXhYLCBtaW5NYXhbMV0pOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm1pblkgPSBNYXRoLm1pbih0aGlzLm1pblksIG1pbk1heFsyXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubWF4WSA9IE1hdGgubWF4KHRoaXMubWF4WSwgbWluTWF4WzNdKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdXBkYXRlQ3VydmVQYXRoTWluTWF4KHRyYW5zZm9ybSwgeDAsIHkwLCB4MSwgeTEsIHgyLCB5MiwgeDMsIHkzLCBtaW5NYXgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYm94ID0gX3V0aWwuVXRpbC5iZXppZXJCb3VuZGluZ0JveCh4MCwgeTAsIHgxLCB5MSwgeDIsIHkyLCB4MywgeTMpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAobWluTWF4KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtaW5NYXhbMF0gPSBNYXRoLm1pbihtaW5NYXhbMF0sIGJveFswXSwgYm94WzJdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1pbk1heFsxXSA9IE1hdGgubWF4KG1pbk1heFsxXSwgYm94WzBdLCBib3hbMl0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbWluTWF4WzJdID0gTWF0aC5taW4obWluTWF4WzJdLCBib3hbMV0sIGJveFszXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtaW5NYXhbM10gPSBNYXRoLm1heChtaW5NYXhbM10sIGJveFsxXSwgYm94WzNdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnVwZGF0ZVJlY3RNaW5NYXgodHJhbnNmb3JtLCBib3gpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRQYXRoQm91bmRpbmdCb3goKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBwYXRoVHlwZSA9IGFyZ3VtZW50cy5sZW5ndGggPiAwICYmIGFyZ3VtZW50c1swXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzBdIDogX3BhdHRlcm5faGVscGVyLlBhdGhUeXBlLkZJTEw7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB0cmFuc2Zvcm0gPSBhcmd1bWVudHMubGVuZ3RoID4gMSAmJiBhcmd1bWVudHNbMV0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1sxXSA6IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGJveCA9IFt0aGlzLm1pblgsIHRoaXMubWluWSwgdGhpcy5tYXhYLCB0aGlzLm1heFldOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAocGF0aFR5cGUgPT09IF9wYXR0ZXJuX2hlbHBlci5QYXRoVHlwZS5TVFJPS0UpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdHJhbnNmb3JtKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLnVucmVhY2hhYmxlKSgiU3Ryb2tlIGJvdW5kaW5nIGJveCBtdXN0IGluY2x1ZGUgdHJhbnNmb3JtLiIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2NhbGUgPSBfdXRpbC5VdGlsLnNpbmd1bGFyVmFsdWVEZWNvbXBvc2UyZFNjYWxlKHRyYW5zZm9ybSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB4U3Ryb2tlUGFkID0gc2NhbGVbMF0gKiB0aGlzLmxpbmVXaWR0aCAvIDI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB5U3Ryb2tlUGFkID0gc2NhbGVbMV0gKiB0aGlzLmxpbmVXaWR0aCAvIDI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBib3hbMF0gLT0geFN0cm9rZVBhZDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJveFsxXSAtPSB5U3Ryb2tlUGFkOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgYm94WzJdICs9IHhTdHJva2VQYWQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBib3hbM10gKz0geVN0cm9rZVBhZDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gYm94OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB1cGRhdGVDbGlwRnJvbVBhdGgoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGludGVyc2VjdCA9IF91dGlsLlV0aWwuaW50ZXJzZWN0KHRoaXMuY2xpcEJveCwgdGhpcy5nZXRQYXRoQm91bmRpbmdCb3goKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc3RhcnROZXdQYXRoQW5kQ2xpcEJveChpbnRlcnNlY3QgfHwgWzAsIDAsIDAsIDBdKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaXNFbXB0eUNsaXAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLm1pblggPT09IEluZmluaXR5OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzdGFydE5ld1BhdGhBbmRDbGlwQm94KGJveCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNsaXBCb3ggPSBib3g7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubWluWCA9IEluZmluaXR5OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm1pblkgPSBJbmZpbml0eTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5tYXhYID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5tYXhZID0gMDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0Q2xpcHBlZFBhdGhCb3VuZGluZ0JveCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHBhdGhUeXBlID0gYXJndW1lbnRzLmxlbmd0aCA+IDAgJiYgYXJndW1lbnRzWzBdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMF0gOiBfcGF0dGVybl9oZWxwZXIuUGF0aFR5cGUuRklMTDsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHRyYW5zZm9ybSA9IGFyZ3VtZW50cy5sZW5ndGggPiAxICYmIGFyZ3VtZW50c1sxXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzFdIDogbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF91dGlsLlV0aWwuaW50ZXJzZWN0KHRoaXMuY2xpcEJveCwgdGhpcy5nZXRQYXRoQm91bmRpbmdCb3gocGF0aFR5cGUsIHRyYW5zZm9ybSkpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIHB1dEJpbmFyeUltYWdlRGF0YShjdHgsIGltZ0RhdGEpIHsKICAgICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIEltYWdlRGF0YSAhPT0gInVuZGVmaW5lZCIgJiYgaW1nRGF0YSBpbnN0YW5jZW9mIEltYWdlRGF0YSkgewogICAgICAgICAgICAgICAgICAgICAgICBjdHgucHV0SW1hZ2VEYXRhKGltZ0RhdGEsIDAsIDApOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNvbnN0IGhlaWdodCA9IGltZ0RhdGEuaGVpZ2h0LAogICAgICAgICAgICAgICAgICAgICAgICB3aWR0aCA9IGltZ0RhdGEud2lkdGg7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgcGFydGlhbENodW5rSGVpZ2h0ID0gaGVpZ2h0ICUgRlVMTF9DSFVOS19IRUlHSFQ7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgZnVsbENodW5rcyA9IChoZWlnaHQgLSBwYXJ0aWFsQ2h1bmtIZWlnaHQpIC8gRlVMTF9DSFVOS19IRUlHSFQ7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgdG90YWxDaHVua3MgPSBwYXJ0aWFsQ2h1bmtIZWlnaHQgPT09IDAgPyBmdWxsQ2h1bmtzIDogZnVsbENodW5rcyArIDE7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgY2h1bmtJbWdEYXRhID0gY3R4LmNyZWF0ZUltYWdlRGF0YSh3aWR0aCwgRlVMTF9DSFVOS19IRUlHSFQpOwogICAgICAgICAgICAgICAgICAgIGxldCBzcmNQb3MgPSAwLAogICAgICAgICAgICAgICAgICAgICAgICBkZXN0UG9zOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHNyYyA9IGltZ0RhdGEuZGF0YTsKICAgICAgICAgICAgICAgICAgICBjb25zdCBkZXN0ID0gY2h1bmtJbWdEYXRhLmRhdGE7CiAgICAgICAgICAgICAgICAgICAgbGV0IGksIGosIHRoaXNDaHVua0hlaWdodCwgZWxlbXNJblRoaXNDaHVuazsKICAgICAgICAgICAgICAgICAgICBpZiAoaW1nRGF0YS5raW5kID09PSBfdXRpbC5JbWFnZUtpbmQuR1JBWVNDQUxFXzFCUFApIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3JjTGVuZ3RoID0gc3JjLmJ5dGVMZW5ndGg7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGRlc3QzMiA9IG5ldyBVaW50MzJBcnJheShkZXN0LmJ1ZmZlciwgMCwgZGVzdC5ieXRlTGVuZ3RoID4+IDIpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBkZXN0MzJEYXRhTGVuZ3RoID0gZGVzdDMyLmxlbmd0aDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZnVsbFNyY0RpZmYgPSB3aWR0aCArIDcgPj4gMzsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgd2hpdGUgPSAweGZmZmZmZmZmOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBibGFjayA9IF91dGlsLkZlYXR1cmVUZXN0LmlzTGl0dGxlRW5kaWFuID8gMHhmZjAwMDAwMCA6IDB4MDAwMDAwZmY7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoaSA9IDA7IGkgPCB0b3RhbENodW5rczsgaSsrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzQ2h1bmtIZWlnaHQgPSBpIDwgZnVsbENodW5rcyA/IEZVTExfQ0hVTktfSEVJR0hUIDogcGFydGlhbENodW5rSGVpZ2h0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVzdFBvcyA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGogPSAwOyBqIDwgdGhpc0NodW5rSGVpZ2h0OyBqKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzcmNEaWZmID0gc3JjTGVuZ3RoIC0gc3JjUG9zOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBrID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBrRW5kID0gc3JjRGlmZiA+IGZ1bGxTcmNEaWZmID8gd2lkdGggOiBzcmNEaWZmICogOCAtIDc7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qga0VuZFVucm9sbGVkID0ga0VuZCAmIH43OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBtYXNrID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgc3JjQnl0ZSA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yICg7IGsgPCBrRW5kVW5yb2xsZWQ7IGsgKz0gOCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzcmNCeXRlID0gc3JjW3NyY1BvcysrXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVzdDMyW2Rlc3RQb3MrK10gPSBzcmNCeXRlICYgMTI4ID8gd2hpdGUgOiBibGFjazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVzdDMyW2Rlc3RQb3MrK10gPSBzcmNCeXRlICYgNjQgPyB3aGl0ZSA6IGJsYWNrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXN0MzJbZGVzdFBvcysrXSA9IHNyY0J5dGUgJiAzMiA/IHdoaXRlIDogYmxhY2s7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlc3QzMltkZXN0UG9zKytdID0gc3JjQnl0ZSAmIDE2ID8gd2hpdGUgOiBibGFjazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVzdDMyW2Rlc3RQb3MrK10gPSBzcmNCeXRlICYgOCA/IHdoaXRlIDogYmxhY2s7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlc3QzMltkZXN0UG9zKytdID0gc3JjQnl0ZSAmIDQgPyB3aGl0ZSA6IGJsYWNrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXN0MzJbZGVzdFBvcysrXSA9IHNyY0J5dGUgJiAyID8gd2hpdGUgOiBibGFjazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVzdDMyW2Rlc3RQb3MrK10gPSBzcmNCeXRlICYgMSA/IHdoaXRlIDogYmxhY2s7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoOyBrIDwga0VuZDsgaysrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChtYXNrID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzcmNCeXRlID0gc3JjW3NyY1BvcysrXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1hc2sgPSAxMjg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVzdDMyW2Rlc3RQb3MrK10gPSBzcmNCeXRlICYgbWFzayA/IHdoaXRlIDogYmxhY2s7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1hc2sgPj49IDE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgd2hpbGUgKGRlc3RQb3MgPCBkZXN0MzJEYXRhTGVuZ3RoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVzdDMyW2Rlc3RQb3MrK10gPSAwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnB1dEltYWdlRGF0YShjaHVua0ltZ0RhdGEsIDAsIGkgKiBGVUxMX0NIVU5LX0hFSUdIVCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGltZ0RhdGEua2luZCA9PT0gX3V0aWwuSW1hZ2VLaW5kLlJHQkFfMzJCUFApIHsKICAgICAgICAgICAgICAgICAgICAgICAgaiA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1zSW5UaGlzQ2h1bmsgPSB3aWR0aCAqIEZVTExfQ0hVTktfSEVJR0hUICogNDsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChpID0gMDsgaSA8IGZ1bGxDaHVua3M7IGkrKykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVzdC5zZXQoc3JjLnN1YmFycmF5KHNyY1Bvcywgc3JjUG9zICsgZWxlbXNJblRoaXNDaHVuaykpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3JjUG9zICs9IGVsZW1zSW5UaGlzQ2h1bms7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHgucHV0SW1hZ2VEYXRhKGNodW5rSW1nRGF0YSwgMCwgaik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBqICs9IEZVTExfQ0hVTktfSEVJR0hUOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpIDwgdG90YWxDaHVua3MpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1zSW5UaGlzQ2h1bmsgPSB3aWR0aCAqIHBhcnRpYWxDaHVua0hlaWdodCAqIDQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXN0LnNldChzcmMuc3ViYXJyYXkoc3JjUG9zLCBzcmNQb3MgKyBlbGVtc0luVGhpc0NodW5rKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHgucHV0SW1hZ2VEYXRhKGNodW5rSW1nRGF0YSwgMCwgaik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGltZ0RhdGEua2luZCA9PT0gX3V0aWwuSW1hZ2VLaW5kLlJHQl8yNEJQUCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzQ2h1bmtIZWlnaHQgPSBGVUxMX0NIVU5LX0hFSUdIVDsKICAgICAgICAgICAgICAgICAgICAgICAgZWxlbXNJblRoaXNDaHVuayA9IHdpZHRoICogdGhpc0NodW5rSGVpZ2h0OwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGkgPSAwOyBpIDwgdG90YWxDaHVua3M7IGkrKykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGkgPj0gZnVsbENodW5rcykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXNDaHVua0hlaWdodCA9IHBhcnRpYWxDaHVua0hlaWdodDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbGVtc0luVGhpc0NodW5rID0gd2lkdGggKiB0aGlzQ2h1bmtIZWlnaHQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXN0UG9zID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoaiA9IGVsZW1zSW5UaGlzQ2h1bms7IGotLTspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXN0W2Rlc3RQb3MrK10gPSBzcmNbc3JjUG9zKytdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlc3RbZGVzdFBvcysrXSA9IHNyY1tzcmNQb3MrK107CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVzdFtkZXN0UG9zKytdID0gc3JjW3NyY1BvcysrXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXN0W2Rlc3RQb3MrK10gPSAyNTU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHgucHV0SW1hZ2VEYXRhKGNodW5rSW1nRGF0YSwgMCwgaSAqIEZVTExfQ0hVTktfSEVJR0hUKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcihgYmFkIGltYWdlIGtpbmQ6ICR7aW1nRGF0YS5raW5kfWApOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIHB1dEJpbmFyeUltYWdlTWFzayhjdHgsIGltZ0RhdGEpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoaW1nRGF0YS5iaXRtYXApIHsKICAgICAgICAgICAgICAgICAgICAgICAgY3R4LmRyYXdJbWFnZShpbWdEYXRhLmJpdG1hcCwgMCwgMCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY29uc3QgaGVpZ2h0ID0gaW1nRGF0YS5oZWlnaHQsCiAgICAgICAgICAgICAgICAgICAgICAgIHdpZHRoID0gaW1nRGF0YS53aWR0aDsKICAgICAgICAgICAgICAgICAgICBjb25zdCBwYXJ0aWFsQ2h1bmtIZWlnaHQgPSBoZWlnaHQgJSBGVUxMX0NIVU5LX0hFSUdIVDsKICAgICAgICAgICAgICAgICAgICBjb25zdCBmdWxsQ2h1bmtzID0gKGhlaWdodCAtIHBhcnRpYWxDaHVua0hlaWdodCkgLyBGVUxMX0NIVU5LX0hFSUdIVDsKICAgICAgICAgICAgICAgICAgICBjb25zdCB0b3RhbENodW5rcyA9IHBhcnRpYWxDaHVua0hlaWdodCA9PT0gMCA/IGZ1bGxDaHVua3MgOiBmdWxsQ2h1bmtzICsgMTsKICAgICAgICAgICAgICAgICAgICBjb25zdCBjaHVua0ltZ0RhdGEgPSBjdHguY3JlYXRlSW1hZ2VEYXRhKHdpZHRoLCBGVUxMX0NIVU5LX0hFSUdIVCk7CiAgICAgICAgICAgICAgICAgICAgbGV0IHNyY1BvcyA9IDA7CiAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3JjID0gaW1nRGF0YS5kYXRhOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IGRlc3QgPSBjaHVua0ltZ0RhdGEuZGF0YTsKICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IHRvdGFsQ2h1bmtzOyBpKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdGhpc0NodW5rSGVpZ2h0ID0gaSA8IGZ1bGxDaHVua3MgPyBGVUxMX0NIVU5LX0hFSUdIVCA6IHBhcnRpYWxDaHVua0hlaWdodDsKICAgICAgICAgICAgICAgICAgICAgICAgKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNyY1BvcwogICAgICAgICAgICAgICAgICAgICAgICB9ID0gKDAsIF9pbWFnZV91dGlscy5jb252ZXJ0QmxhY2tBbmRXaGl0ZVRvUkdCQSkoewogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3JjLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3JjUG9zLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVzdCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdpZHRoLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaGVpZ2h0OiB0aGlzQ2h1bmtIZWlnaHQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBub25CbGFja0NvbG9yOiAwCiAgICAgICAgICAgICAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnB1dEltYWdlRGF0YShjaHVua0ltZ0RhdGEsIDAsIGkgKiBGVUxMX0NIVU5LX0hFSUdIVCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gY29weUN0eFN0YXRlKHNvdXJjZUN0eCwgZGVzdEN0eCkgewogICAgICAgICAgICAgICAgICAgIGNvbnN0IHByb3BlcnRpZXMgPSBbInN0cm9rZVN0eWxlIiwgImZpbGxTdHlsZSIsICJmaWxsUnVsZSIsICJnbG9iYWxBbHBoYSIsICJsaW5lV2lkdGgiLCAibGluZUNhcCIsICJsaW5lSm9pbiIsICJtaXRlckxpbWl0IiwgImdsb2JhbENvbXBvc2l0ZU9wZXJhdGlvbiIsICJmb250IiwgImZpbHRlciJdOwogICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgcHJvcGVydHkgb2YgcHJvcGVydGllcykgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoc291cmNlQ3R4W3Byb3BlcnR5XSAhPT0gdW5kZWZpbmVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXN0Q3R4W3Byb3BlcnR5XSA9IHNvdXJjZUN0eFtwcm9wZXJ0eV07CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaWYgKHNvdXJjZUN0eC5zZXRMaW5lRGFzaCAhPT0gdW5kZWZpbmVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGRlc3RDdHguc2V0TGluZURhc2goc291cmNlQ3R4LmdldExpbmVEYXNoKCkpOwogICAgICAgICAgICAgICAgICAgICAgICBkZXN0Q3R4LmxpbmVEYXNoT2Zmc2V0ID0gc291cmNlQ3R4LmxpbmVEYXNoT2Zmc2V0OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIHJlc2V0Q3R4VG9EZWZhdWx0KGN0eCkgewogICAgICAgICAgICAgICAgICAgIGN0eC5zdHJva2VTdHlsZSA9IGN0eC5maWxsU3R5bGUgPSAiIzAwMDAwMCI7CiAgICAgICAgICAgICAgICAgICAgY3R4LmZpbGxSdWxlID0gIm5vbnplcm8iOwogICAgICAgICAgICAgICAgICAgIGN0eC5nbG9iYWxBbHBoYSA9IDE7CiAgICAgICAgICAgICAgICAgICAgY3R4LmxpbmVXaWR0aCA9IDE7CiAgICAgICAgICAgICAgICAgICAgY3R4LmxpbmVDYXAgPSAiYnV0dCI7CiAgICAgICAgICAgICAgICAgICAgY3R4LmxpbmVKb2luID0gIm1pdGVyIjsKICAgICAgICAgICAgICAgICAgICBjdHgubWl0ZXJMaW1pdCA9IDEwOwogICAgICAgICAgICAgICAgICAgIGN0eC5nbG9iYWxDb21wb3NpdGVPcGVyYXRpb24gPSAic291cmNlLW92ZXIiOwogICAgICAgICAgICAgICAgICAgIGN0eC5mb250ID0gIjEwcHggc2Fucy1zZXJpZiI7CiAgICAgICAgICAgICAgICAgICAgaWYgKGN0eC5zZXRMaW5lRGFzaCAhPT0gdW5kZWZpbmVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5zZXRMaW5lRGFzaChbXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5saW5lRGFzaE9mZnNldCA9IDA7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmICghX2lzX25vZGUuaXNOb2RlSlMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY3R4LmZpbHRlciA9ICJub25lIjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBjb21wb3NlU01hc2tCYWNrZHJvcChieXRlcywgcjAsIGcwLCBiMCkgewogICAgICAgICAgICAgICAgICAgIGNvbnN0IGxlbmd0aCA9IGJ5dGVzLmxlbmd0aDsKICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMzsgaSA8IGxlbmd0aDsgaSArPSA0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGFscGhhID0gYnl0ZXNbaV07CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChhbHBoYSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgYnl0ZXNbaSAtIDNdID0gcjA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBieXRlc1tpIC0gMl0gPSBnMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJ5dGVzW2kgLSAxXSA9IGIwOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGFscGhhIDwgMjU1KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBhbHBoYV8gPSAyNTUgLSBhbHBoYTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJ5dGVzW2kgLSAzXSA9IGJ5dGVzW2kgLSAzXSAqIGFscGhhICsgcjAgKiBhbHBoYV8gPj4gODsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJ5dGVzW2kgLSAyXSA9IGJ5dGVzW2kgLSAyXSAqIGFscGhhICsgZzAgKiBhbHBoYV8gPj4gODsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJ5dGVzW2kgLSAxXSA9IGJ5dGVzW2kgLSAxXSAqIGFscGhhICsgYjAgKiBhbHBoYV8gPj4gODsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGNvbXBvc2VTTWFza0FscGhhKG1hc2tEYXRhLCBsYXllckRhdGEsIHRyYW5zZmVyTWFwKSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgbGVuZ3RoID0gbWFza0RhdGEubGVuZ3RoOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHNjYWxlID0gMSAvIDI1NTsKICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMzsgaSA8IGxlbmd0aDsgaSArPSA0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGFscGhhID0gdHJhbnNmZXJNYXAgPyB0cmFuc2Zlck1hcFttYXNrRGF0YVtpXV0gOiBtYXNrRGF0YVtpXTsKICAgICAgICAgICAgICAgICAgICAgICAgbGF5ZXJEYXRhW2ldID0gbGF5ZXJEYXRhW2ldICogYWxwaGEgKiBzY2FsZSB8IDA7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gY29tcG9zZVNNYXNrTHVtaW5vc2l0eShtYXNrRGF0YSwgbGF5ZXJEYXRhLCB0cmFuc2Zlck1hcCkgewogICAgICAgICAgICAgICAgICAgIGNvbnN0IGxlbmd0aCA9IG1hc2tEYXRhLmxlbmd0aDsKICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMzsgaSA8IGxlbmd0aDsgaSArPSA0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHkgPSBtYXNrRGF0YVtpIC0gM10gKiA3NyArIG1hc2tEYXRhW2kgLSAyXSAqIDE1MiArIG1hc2tEYXRhW2kgLSAxXSAqIDI4OwogICAgICAgICAgICAgICAgICAgICAgICBsYXllckRhdGFbaV0gPSB0cmFuc2Zlck1hcCA/IGxheWVyRGF0YVtpXSAqIHRyYW5zZmVyTWFwW3kgPj4gOF0gPj4gOCA6IGxheWVyRGF0YVtpXSAqIHkgPj4gMTY7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gZ2VuZXJpY0NvbXBvc2VTTWFzayhtYXNrQ3R4LCBsYXllckN0eCwgd2lkdGgsIGhlaWdodCwgc3VidHlwZSwgYmFja2Ryb3AsIHRyYW5zZmVyTWFwLCBsYXllck9mZnNldFgsIGxheWVyT2Zmc2V0WSwgbWFza09mZnNldFgsIG1hc2tPZmZzZXRZKSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgaGFzQmFja2Ryb3AgPSAhIWJhY2tkcm9wOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHIwID0gaGFzQmFja2Ryb3AgPyBiYWNrZHJvcFswXSA6IDA7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgZzAgPSBoYXNCYWNrZHJvcCA/IGJhY2tkcm9wWzFdIDogMDsKICAgICAgICAgICAgICAgICAgICBjb25zdCBiMCA9IGhhc0JhY2tkcm9wID8gYmFja2Ryb3BbMl0gOiAwOwogICAgICAgICAgICAgICAgICAgIGxldCBjb21wb3NlRm47CiAgICAgICAgICAgICAgICAgICAgaWYgKHN1YnR5cGUgPT09ICJMdW1pbm9zaXR5IikgewogICAgICAgICAgICAgICAgICAgICAgICBjb21wb3NlRm4gPSBjb21wb3NlU01hc2tMdW1pbm9zaXR5OwogICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbXBvc2VGbiA9IGNvbXBvc2VTTWFza0FscGhhOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjb25zdCBQSVhFTFNfVE9fUFJPQ0VTUyA9IDEwNDg1NzY7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgY2h1bmtTaXplID0gTWF0aC5taW4oaGVpZ2h0LCBNYXRoLmNlaWwoUElYRUxTX1RPX1BST0NFU1MgLyB3aWR0aCkpOwogICAgICAgICAgICAgICAgICAgIGZvciAobGV0IHJvdyA9IDA7IHJvdyA8IGhlaWdodDsgcm93ICs9IGNodW5rU2l6ZSkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjaHVua0hlaWdodCA9IE1hdGgubWluKGNodW5rU2l6ZSwgaGVpZ2h0IC0gcm93KTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbWFza0RhdGEgPSBtYXNrQ3R4LmdldEltYWdlRGF0YShsYXllck9mZnNldFggLSBtYXNrT2Zmc2V0WCwgcm93ICsgKGxheWVyT2Zmc2V0WSAtIG1hc2tPZmZzZXRZKSwgd2lkdGgsIGNodW5rSGVpZ2h0KTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbGF5ZXJEYXRhID0gbGF5ZXJDdHguZ2V0SW1hZ2VEYXRhKGxheWVyT2Zmc2V0WCwgcm93ICsgbGF5ZXJPZmZzZXRZLCB3aWR0aCwgY2h1bmtIZWlnaHQpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoaGFzQmFja2Ryb3ApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbXBvc2VTTWFza0JhY2tkcm9wKG1hc2tEYXRhLmRhdGEsIHIwLCBnMCwgYjApOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbXBvc2VGbihtYXNrRGF0YS5kYXRhLCBsYXllckRhdGEuZGF0YSwgdHJhbnNmZXJNYXApOwogICAgICAgICAgICAgICAgICAgICAgICBsYXllckN0eC5wdXRJbWFnZURhdGEobGF5ZXJEYXRhLCBsYXllck9mZnNldFgsIHJvdyArIGxheWVyT2Zmc2V0WSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gY29tcG9zZVNNYXNrKGN0eCwgc21hc2ssIGxheWVyQ3R4LCBsYXllckJveCkgewogICAgICAgICAgICAgICAgICAgIGNvbnN0IGxheWVyT2Zmc2V0WCA9IGxheWVyQm94WzBdOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IGxheWVyT2Zmc2V0WSA9IGxheWVyQm94WzFdOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IGxheWVyV2lkdGggPSBsYXllckJveFsyXSAtIGxheWVyT2Zmc2V0WDsKICAgICAgICAgICAgICAgICAgICBjb25zdCBsYXllckhlaWdodCA9IGxheWVyQm94WzNdIC0gbGF5ZXJPZmZzZXRZOwogICAgICAgICAgICAgICAgICAgIGlmIChsYXllcldpZHRoID09PSAwIHx8IGxheWVySGVpZ2h0ID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2VuZXJpY0NvbXBvc2VTTWFzayhzbWFzay5jb250ZXh0LCBsYXllckN0eCwgbGF5ZXJXaWR0aCwgbGF5ZXJIZWlnaHQsIHNtYXNrLnN1YnR5cGUsIHNtYXNrLmJhY2tkcm9wLCBzbWFzay50cmFuc2Zlck1hcCwgbGF5ZXJPZmZzZXRYLCBsYXllck9mZnNldFksIHNtYXNrLm9mZnNldFgsIHNtYXNrLm9mZnNldFkpOwogICAgICAgICAgICAgICAgICAgIGN0eC5zYXZlKCk7CiAgICAgICAgICAgICAgICAgICAgY3R4Lmdsb2JhbEFscGhhID0gMTsKICAgICAgICAgICAgICAgICAgICBjdHguZ2xvYmFsQ29tcG9zaXRlT3BlcmF0aW9uID0gInNvdXJjZS1vdmVyIjsKICAgICAgICAgICAgICAgICAgICBjdHguc2V0VHJhbnNmb3JtKDEsIDAsIDAsIDEsIDAsIDApOwogICAgICAgICAgICAgICAgICAgIGN0eC5kcmF3SW1hZ2UobGF5ZXJDdHguY2FudmFzLCAwLCAwKTsKICAgICAgICAgICAgICAgICAgICBjdHgucmVzdG9yZSgpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gZ2V0SW1hZ2VTbW9vdGhpbmdFbmFibGVkKHRyYW5zZm9ybSwgaW50ZXJwb2xhdGUpIHsKICAgICAgICAgICAgICAgICAgICBjb25zdCBzY2FsZSA9IF91dGlsLlV0aWwuc2luZ3VsYXJWYWx1ZURlY29tcG9zZTJkU2NhbGUodHJhbnNmb3JtKTsKICAgICAgICAgICAgICAgICAgICBzY2FsZVswXSA9IE1hdGguZnJvdW5kKHNjYWxlWzBdKTsKICAgICAgICAgICAgICAgICAgICBzY2FsZVsxXSA9IE1hdGguZnJvdW5kKHNjYWxlWzFdKTsKICAgICAgICAgICAgICAgICAgICBjb25zdCBhY3R1YWxTY2FsZSA9IE1hdGguZnJvdW5kKChnbG9iYWxUaGlzLmRldmljZVBpeGVsUmF0aW8gfHwgMSkgKiBfZGlzcGxheV91dGlscy5QaXhlbHNQZXJJbmNoLlBERl9UT19DU1NfVU5JVFMpOwogICAgICAgICAgICAgICAgICAgIGlmIChpbnRlcnBvbGF0ZSAhPT0gdW5kZWZpbmVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBpbnRlcnBvbGF0ZTsKICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHNjYWxlWzBdIDw9IGFjdHVhbFNjYWxlIHx8IHNjYWxlWzFdIDw9IGFjdHVhbFNjYWxlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjb25zdCBMSU5FX0NBUF9TVFlMRVMgPSBbImJ1dHQiLCAicm91bmQiLCAic3F1YXJlIl07CiAgICAgICAgICAgICAgICBjb25zdCBMSU5FX0pPSU5fU1RZTEVTID0gWyJtaXRlciIsICJyb3VuZCIsICJiZXZlbCJdOwogICAgICAgICAgICAgICAgY29uc3QgTk9STUFMX0NMSVAgPSB7fTsKICAgICAgICAgICAgICAgIGNvbnN0IEVPX0NMSVAgPSB7fTsKICAgICAgICAgICAgICAgIHZhciBfcmVzdG9yZUluaXRpYWxTdGF0ZSA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgY2xhc3MgQ2FudmFzR3JhcGhpY3MgewogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKGNhbnZhc0N0eCwgY29tbW9uT2Jqcywgb2JqcywgY2FudmFzRmFjdG9yeSwgZmlsdGVyRmFjdG9yeSwgX3JlZiwgYW5ub3RhdGlvbkNhbnZhc01hcCkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgb3B0aW9uYWxDb250ZW50Q29uZmlnLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgbWFya2VkQ29udGVudFN0YWNrID0gbnVsbAogICAgICAgICAgICAgICAgICAgICAgICB9ID0gX3JlZjsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEluaXRTcGVjKHRoaXMsIF9yZXN0b3JlSW5pdGlhbFN0YXRlKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHggPSBjYW52YXNDdHg7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudCA9IG5ldyBDYW52YXNFeHRyYVN0YXRlKHRoaXMuY3R4LmNhbnZhcy53aWR0aCwgdGhpcy5jdHguY2FudmFzLmhlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc3RhdGVTdGFjayA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBlbmRpbmdDbGlwID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wZW5kaW5nRU9GaWxsID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucmVzID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy54b2JqcyA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29tbW9uT2JqcyA9IGNvbW1vbk9ianM7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMub2JqcyA9IG9ianM7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2FudmFzRmFjdG9yeSA9IGNhbnZhc0ZhY3Rvcnk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZmlsdGVyRmFjdG9yeSA9IGZpbHRlckZhY3Rvcnk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZ3JvdXBTdGFjayA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnByb2Nlc3NpbmdUeXBlMyA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYmFzZVRyYW5zZm9ybSA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYmFzZVRyYW5zZm9ybVN0YWNrID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZ3JvdXBMZXZlbCA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc21hc2tTdGFjayA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNtYXNrQ291bnRlciA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudGVtcFNNYXNrID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zdXNwZW5kZWRDdHggPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRlbnRWaXNpYmxlID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5tYXJrZWRDb250ZW50U3RhY2sgPSBtYXJrZWRDb250ZW50U3RhY2sgfHwgW107CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMub3B0aW9uYWxDb250ZW50Q29uZmlnID0gb3B0aW9uYWxDb250ZW50Q29uZmlnOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNhY2hlZENhbnZhc2VzID0gbmV3IENhY2hlZENhbnZhc2VzKHRoaXMuY2FudmFzRmFjdG9yeSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2FjaGVkUGF0dGVybnMgPSBuZXcgTWFwKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYW5ub3RhdGlvbkNhbnZhc01hcCA9IGFubm90YXRpb25DYW52YXNNYXA7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudmlld3BvcnRTY2FsZSA9IDE7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMub3V0cHV0U2NhbGVYID0gMTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5vdXRwdXRTY2FsZVkgPSAxOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jYWNoZWRTY2FsZUZvclN0cm9raW5nID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fY2FjaGVkR2V0U2luZ2xlUGl4ZWxXaWR0aCA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NhY2hlZEJpdG1hcHNNYXAgPSBuZXcgTWFwKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldE9iamVjdChkYXRhKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBmYWxsYmFjayA9IGFyZ3VtZW50cy5sZW5ndGggPiAxICYmIGFyZ3VtZW50c1sxXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzFdIDogbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHR5cGVvZiBkYXRhID09PSAic3RyaW5nIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGRhdGEuc3RhcnRzV2l0aCgiZ18iKSA/IHRoaXMuY29tbW9uT2Jqcy5nZXQoZGF0YSkgOiB0aGlzLm9ianMuZ2V0KGRhdGEpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxsYmFjazsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYmVnaW5EcmF3aW5nKF9yZWYyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cmFuc2Zvcm0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2aWV3cG9ydCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRyYW5zcGFyZW5jeSA9IGZhbHNlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgYmFja2dyb3VuZCA9IG51bGwKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IF9yZWYyOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB3aWR0aCA9IHRoaXMuY3R4LmNhbnZhcy53aWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaGVpZ2h0ID0gdGhpcy5jdHguY2FudmFzLmhlaWdodDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2F2ZWRGaWxsU3R5bGUgPSB0aGlzLmN0eC5maWxsU3R5bGU7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4LmZpbGxTdHlsZSA9IGJhY2tncm91bmQgfHwgIiNmZmZmZmYiOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN0eC5maWxsUmVjdCgwLCAwLCB3aWR0aCwgaGVpZ2h0KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHguZmlsbFN0eWxlID0gc2F2ZWRGaWxsU3R5bGU7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0cmFuc3BhcmVuY3kpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHRyYW5zcGFyZW50Q2FudmFzID0gdGhpcy5jYWNoZWRDYW52YXNlcy5nZXRDYW52YXMoInRyYW5zcGFyZW50Iiwgd2lkdGgsIGhlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbXBvc2l0ZUN0eCA9IHRoaXMuY3R4OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy50cmFuc3BhcmVudENhbnZhcyA9IHRyYW5zcGFyZW50Q2FudmFzLmNhbnZhczsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4ID0gdHJhbnNwYXJlbnRDYW52YXMuY29udGV4dDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4LnNhdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4LnRyYW5zZm9ybSguLi4oMCwgX2Rpc3BsYXlfdXRpbHMuZ2V0Q3VycmVudFRyYW5zZm9ybSkodGhpcy5jb21wb3NpdGVDdHgpKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN0eC5zYXZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJlc2V0Q3R4VG9EZWZhdWx0KHRoaXMuY3R4KTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRyYW5zZm9ybSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHgudHJhbnNmb3JtKC4uLnRyYW5zZm9ybSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm91dHB1dFNjYWxlWCA9IHRyYW5zZm9ybVswXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMub3V0cHV0U2NhbGVZID0gdHJhbnNmb3JtWzBdOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4LnRyYW5zZm9ybSguLi52aWV3cG9ydC50cmFuc2Zvcm0pOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnZpZXdwb3J0U2NhbGUgPSB2aWV3cG9ydC5zY2FsZTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5iYXNlVHJhbnNmb3JtID0gKDAsIF9kaXNwbGF5X3V0aWxzLmdldEN1cnJlbnRUcmFuc2Zvcm0pKHRoaXMuY3R4KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZXhlY3V0ZU9wZXJhdG9yTGlzdChvcGVyYXRvckxpc3QsIGV4ZWN1dGlvblN0YXJ0SWR4LCBjb250aW51ZUNhbGxiYWNrLCBzdGVwcGVyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGFyZ3NBcnJheSA9IG9wZXJhdG9yTGlzdC5hcmdzQXJyYXk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZuQXJyYXkgPSBvcGVyYXRvckxpc3QuZm5BcnJheTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGkgPSBleGVjdXRpb25TdGFydElkeCB8fCAwOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBhcmdzQXJyYXlMZW4gPSBhcmdzQXJyYXkubGVuZ3RoOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoYXJnc0FycmF5TGVuID09PSBpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gaTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjaHVua09wZXJhdGlvbnMgPSBhcmdzQXJyYXlMZW4gLSBpID4gRVhFQ1VUSU9OX1NURVBTICYmIHR5cGVvZiBjb250aW51ZUNhbGxiYWNrID09PSAiZnVuY3Rpb24iOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBlbmRUaW1lID0gY2h1bmtPcGVyYXRpb25zID8gRGF0ZS5ub3coKSArIEVYRUNVVElPTl9USU1FIDogMDsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHN0ZXBzID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY29tbW9uT2JqcyA9IHRoaXMuY29tbW9uT2JqczsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgb2JqcyA9IHRoaXMub2JqczsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGZuSWQ7CiAgICAgICAgICAgICAgICAgICAgICAgIHdoaWxlICh0cnVlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoc3RlcHBlciAhPT0gdW5kZWZpbmVkICYmIGkgPT09IHN0ZXBwZXIubmV4dEJyZWFrUG9pbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGVwcGVyLmJyZWFrSXQoaSwgY29udGludWVDYWxsYmFjayk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmbklkID0gZm5BcnJheVtpXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChmbklkICE9PSBfdXRpbC5PUFMuZGVwZW5kZW5jeSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXNbZm5JZF0uYXBwbHkodGhpcywgYXJnc0FycmF5W2ldKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBkZXBPYmpJZCBvZiBhcmdzQXJyYXlbaV0pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgb2Jqc1Bvb2wgPSBkZXBPYmpJZC5zdGFydHNXaXRoKCJnXyIpID8gY29tbW9uT2JqcyA6IG9ianM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghb2Jqc1Bvb2wuaGFzKGRlcE9iaklkKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgb2Jqc1Bvb2wuZ2V0KGRlcE9iaklkLCBjb250aW51ZUNhbGxiYWNrKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgaSsrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGkgPT09IGFyZ3NBcnJheUxlbikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGNodW5rT3BlcmF0aW9ucyAmJiArK3N0ZXBzID4gRVhFQ1VUSU9OX1NURVBTKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKERhdGUubm93KCkgPiBlbmRUaW1lKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlQ2FsbGJhY2soKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0ZXBzID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBlbmREcmF3aW5nKCkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgcGFnZUNvbG9ycyA9IGFyZ3VtZW50cy5sZW5ndGggPiAwICYmIGFyZ3VtZW50c1swXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzBdIDogbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfcmVzdG9yZUluaXRpYWxTdGF0ZSwgX3Jlc3RvcmVJbml0aWFsU3RhdGUyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNhY2hlZENhbnZhc2VzLmNsZWFyKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2FjaGVkUGF0dGVybnMuY2xlYXIoKTsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBjYWNoZSBvZiB0aGlzLl9jYWNoZWRCaXRtYXBzTWFwLnZhbHVlcygpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGNhbnZhcyBvZiBjYWNoZS52YWx1ZXMoKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0eXBlb2YgSFRNTENhbnZhc0VsZW1lbnQgIT09ICJ1bmRlZmluZWQiICYmIGNhbnZhcyBpbnN0YW5jZW9mIEhUTUxDYW52YXNFbGVtZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhbnZhcy53aWR0aCA9IGNhbnZhcy5oZWlnaHQgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhY2hlLmNsZWFyKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fY2FjaGVkQml0bWFwc01hcC5jbGVhcigpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAocGFnZUNvbG9ycykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaGNtRmlsdGVySWQgPSB0aGlzLmZpbHRlckZhY3RvcnkuYWRkSENNRmlsdGVyKHBhZ2VDb2xvcnMuZm9yZWdyb3VuZCwgcGFnZUNvbG9ycy5iYWNrZ3JvdW5kKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChoY21GaWx0ZXJJZCAhPT0gIm5vbmUiKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2F2ZWRGaWx0ZXIgPSB0aGlzLmN0eC5maWx0ZXI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHguZmlsdGVyID0gaGNtRmlsdGVySWQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHguZHJhd0ltYWdlKHRoaXMuY3R4LmNhbnZhcywgMCwgMCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHguZmlsdGVyID0gc2F2ZWRGaWx0ZXI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX3NjYWxlSW1hZ2UoaW1nLCBpbnZlcnNlVHJhbnNmb3JtKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHdpZHRoID0gaW1nLndpZHRoOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBoZWlnaHQgPSBpbWcuaGVpZ2h0OwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgd2lkdGhTY2FsZSA9IE1hdGgubWF4KE1hdGguaHlwb3QoaW52ZXJzZVRyYW5zZm9ybVswXSwgaW52ZXJzZVRyYW5zZm9ybVsxXSksIDEpOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgaGVpZ2h0U2NhbGUgPSBNYXRoLm1heChNYXRoLmh5cG90KGludmVyc2VUcmFuc2Zvcm1bMl0sIGludmVyc2VUcmFuc2Zvcm1bM10pLCAxKTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHBhaW50V2lkdGggPSB3aWR0aCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhaW50SGVpZ2h0ID0gaGVpZ2h0OwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgdG1wQ2FudmFzSWQgPSAicHJlc2NhbGUxIjsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHRtcENhbnZhcywgdG1wQ3R4OwogICAgICAgICAgICAgICAgICAgICAgICB3aGlsZSAod2lkdGhTY2FsZSA+IDIgJiYgcGFpbnRXaWR0aCA+IDEgfHwgaGVpZ2h0U2NhbGUgPiAyICYmIHBhaW50SGVpZ2h0ID4gMSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IG5ld1dpZHRoID0gcGFpbnRXaWR0aCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBuZXdIZWlnaHQgPSBwYWludEhlaWdodDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh3aWR0aFNjYWxlID4gMiAmJiBwYWludFdpZHRoID4gMSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5ld1dpZHRoID0gcGFpbnRXaWR0aCA+PSAxNjM4NCA/IE1hdGguZmxvb3IocGFpbnRXaWR0aCAvIDIpIC0gMSB8fCAxIDogTWF0aC5jZWlsKHBhaW50V2lkdGggLyAyKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB3aWR0aFNjYWxlIC89IHBhaW50V2lkdGggLyBuZXdXaWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChoZWlnaHRTY2FsZSA+IDIgJiYgcGFpbnRIZWlnaHQgPiAxKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbmV3SGVpZ2h0ID0gcGFpbnRIZWlnaHQgPj0gMTYzODQgPyBNYXRoLmZsb29yKHBhaW50SGVpZ2h0IC8gMikgLSAxIHx8IDEgOiBNYXRoLmNlaWwocGFpbnRIZWlnaHQpIC8gMjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBoZWlnaHRTY2FsZSAvPSBwYWludEhlaWdodCAvIG5ld0hlaWdodDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRtcENhbnZhcyA9IHRoaXMuY2FjaGVkQ2FudmFzZXMuZ2V0Q2FudmFzKHRtcENhbnZhc0lkLCBuZXdXaWR0aCwgbmV3SGVpZ2h0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRtcEN0eCA9IHRtcENhbnZhcy5jb250ZXh0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdG1wQ3R4LmNsZWFyUmVjdCgwLCAwLCBuZXdXaWR0aCwgbmV3SGVpZ2h0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRtcEN0eC5kcmF3SW1hZ2UoaW1nLCAwLCAwLCBwYWludFdpZHRoLCBwYWludEhlaWdodCwgMCwgMCwgbmV3V2lkdGgsIG5ld0hlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbWcgPSB0bXBDYW52YXMuY2FudmFzOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFpbnRXaWR0aCA9IG5ld1dpZHRoOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFpbnRIZWlnaHQgPSBuZXdIZWlnaHQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0bXBDYW52YXNJZCA9IHRtcENhbnZhc0lkID09PSAicHJlc2NhbGUxIiA/ICJwcmVzY2FsZTIiIDogInByZXNjYWxlMSI7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGltZywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhaW50V2lkdGgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYWludEhlaWdodAogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfY3JlYXRlTWFza0NhbnZhcyhpbWcpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY3R4ID0gdGhpcy5jdHg7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdpZHRoLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaGVpZ2h0CiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBpbWc7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZpbGxDb2xvciA9IHRoaXMuY3VycmVudC5maWxsQ29sb3I7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGlzUGF0dGVybkZpbGwgPSB0aGlzLmN1cnJlbnQucGF0dGVybkZpbGw7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGN1cnJlbnRUcmFuc2Zvcm0gPSAoMCwgX2Rpc3BsYXlfdXRpbHMuZ2V0Q3VycmVudFRyYW5zZm9ybSkoY3R4KTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGNhY2hlLCBjYWNoZUtleSwgc2NhbGVkLCBtYXNrQ2FudmFzOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoKGltZy5iaXRtYXAgfHwgaW1nLmRhdGEpICYmIGltZy5jb3VudCA+IDEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG1haW5LZXkgPSBpbWcuYml0bWFwIHx8IGltZy5kYXRhLmJ1ZmZlcjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhY2hlS2V5ID0gSlNPTi5zdHJpbmdpZnkoaXNQYXR0ZXJuRmlsbCA/IGN1cnJlbnRUcmFuc2Zvcm0gOiBbY3VycmVudFRyYW5zZm9ybS5zbGljZSgwLCA0KSwgZmlsbENvbG9yXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYWNoZSA9IHRoaXMuX2NhY2hlZEJpdG1hcHNNYXAuZ2V0KG1haW5LZXkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFjYWNoZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhY2hlID0gbmV3IE1hcCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NhY2hlZEJpdG1hcHNNYXAuc2V0KG1haW5LZXksIGNhY2hlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNhY2hlZEltYWdlID0gY2FjaGUuZ2V0KGNhY2hlS2V5KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjYWNoZWRJbWFnZSAmJiAhaXNQYXR0ZXJuRmlsbCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG9mZnNldFggPSBNYXRoLnJvdW5kKE1hdGgubWluKGN1cnJlbnRUcmFuc2Zvcm1bMF0sIGN1cnJlbnRUcmFuc2Zvcm1bMl0pICsgY3VycmVudFRyYW5zZm9ybVs0XSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgb2Zmc2V0WSA9IE1hdGgucm91bmQoTWF0aC5taW4oY3VycmVudFRyYW5zZm9ybVsxXSwgY3VycmVudFRyYW5zZm9ybVszXSkgKyBjdXJyZW50VHJhbnNmb3JtWzVdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYW52YXM6IGNhY2hlZEltYWdlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvZmZzZXRYLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvZmZzZXRZCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNjYWxlZCA9IGNhY2hlZEltYWdlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghc2NhbGVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtYXNrQ2FudmFzID0gdGhpcy5jYWNoZWRDYW52YXNlcy5nZXRDYW52YXMoIm1hc2tDYW52YXMiLCB3aWR0aCwgaGVpZ2h0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHB1dEJpbmFyeUltYWdlTWFzayhtYXNrQ2FudmFzLmNvbnRleHQsIGltZyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgbGV0IG1hc2tUb0NhbnZhcyA9IF91dGlsLlV0aWwudHJhbnNmb3JtKGN1cnJlbnRUcmFuc2Zvcm0sIFsxIC8gd2lkdGgsIDAsIDAsIC0xIC8gaGVpZ2h0LCAwLCAwXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIG1hc2tUb0NhbnZhcyA9IF91dGlsLlV0aWwudHJhbnNmb3JtKG1hc2tUb0NhbnZhcywgWzEsIDAsIDAsIDEsIDAsIC1oZWlnaHRdKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY29yZDEgPSBfdXRpbC5VdGlsLmFwcGx5VHJhbnNmb3JtKFswLCAwXSwgbWFza1RvQ2FudmFzKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY29yZDIgPSBfdXRpbC5VdGlsLmFwcGx5VHJhbnNmb3JtKFt3aWR0aCwgaGVpZ2h0XSwgbWFza1RvQ2FudmFzKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmVjdCA9IF91dGlsLlV0aWwubm9ybWFsaXplUmVjdChbY29yZDFbMF0sIGNvcmQxWzFdLCBjb3JkMlswXSwgY29yZDJbMV1dKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZHJhd25XaWR0aCA9IE1hdGgucm91bmQocmVjdFsyXSAtIHJlY3RbMF0pIHx8IDE7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGRyYXduSGVpZ2h0ID0gTWF0aC5yb3VuZChyZWN0WzNdIC0gcmVjdFsxXSkgfHwgMTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZmlsbENhbnZhcyA9IHRoaXMuY2FjaGVkQ2FudmFzZXMuZ2V0Q2FudmFzKCJmaWxsQ2FudmFzIiwgZHJhd25XaWR0aCwgZHJhd25IZWlnaHQpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBmaWxsQ3R4ID0gZmlsbENhbnZhcy5jb250ZXh0OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBvZmZzZXRYID0gTWF0aC5taW4oY29yZDFbMF0sIGNvcmQyWzBdKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgb2Zmc2V0WSA9IE1hdGgubWluKGNvcmQxWzFdLCBjb3JkMlsxXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGZpbGxDdHgudHJhbnNsYXRlKC1vZmZzZXRYLCAtb2Zmc2V0WSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGZpbGxDdHgudHJhbnNmb3JtKC4uLm1hc2tUb0NhbnZhcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghc2NhbGVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzY2FsZWQgPSB0aGlzLl9zY2FsZUltYWdlKG1hc2tDYW52YXMuY2FudmFzLCAoMCwgX2Rpc3BsYXlfdXRpbHMuZ2V0Q3VycmVudFRyYW5zZm9ybUludmVyc2UpKGZpbGxDdHgpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNjYWxlZCA9IHNjYWxlZC5pbWc7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoY2FjaGUgJiYgaXNQYXR0ZXJuRmlsbCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhY2hlLnNldChjYWNoZUtleSwgc2NhbGVkKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBmaWxsQ3R4LmltYWdlU21vb3RoaW5nRW5hYmxlZCA9IGdldEltYWdlU21vb3RoaW5n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AgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FudmFzOiBmaWxsQ2FudmFzLmNhbnZhcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9mZnNldFg6IE1hdGgucm91bmQob2Zmc2V0WCksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvZmZzZXRZOiBNYXRoLnJvdW5kKG9mZnNldFkpCiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNldExpbmVXaWR0aCh3aWR0aCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAod2lkdGggIT09IHRoaXMuY3VycmVudC5saW5lV2lkdGgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NhY2hlZFNjYWxlRm9yU3Ryb2tpbmcgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC5saW5lV2lkdGggPSB3aWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHgubGluZVdpZHRoID0gd2lkdGg7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNldExpbmVDYXAoc3R5bGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHgubGluZUNhcCA9IExJTkVfQ0FQX1NUWUxFU1tzdHlsZV07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNldExpbmVKb2luKHN0eWxlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4LmxpbmVKb2luID0gTElORV9KT0lOX1NUWUxFU1tzdHlsZV07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNldE1pdGVyTGltaXQobGltaXQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHgubWl0ZXJMaW1pdCA9IGxpbWl0OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzZXREYXNoKGRhc2hBcnJheSwgZGFzaFBoYXNlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGN0eCA9IHRoaXMuY3R4OwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoY3R4LnNldExpbmVEYXNoICE9PSB1bmRlZmluZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5zZXRMaW5lRGFzaChkYXNoQXJyYXkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LmxpbmVEYXNoT2Zmc2V0ID0gZGFzaFBoYXNlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNldFJlbmRlcmluZ0ludGVudChpbnRlbnQpIHt9CiAgICAgICAgICAgICAgICAgICAgc2V0RmxhdG5lc3MoZmxhdG5lc3MpIHt9CiAgICAgICAgICAgICAgICAgICAgc2V0R1N0YXRlKHN0YXRlcykgewogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IFtrZXksIHZhbHVlXSBvZiBzdGF0ZXMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN3aXRjaCAoa2V5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiTFciOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNldExpbmVXaWR0aCh2YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgIkxDIjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRMaW5lQ2FwKHZhbHVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiTEoiOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNldExpbmVKb2luKHZhbHVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiTUwiOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNldE1pdGVyTGltaXQodmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJEIjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXREYXNoKHZhbHVlWzBdLCB2YWx1ZVsxXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgIlJJIjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRSZW5kZXJpbmdJbnRlbnQodmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJGTCI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0RmxhdG5lc3ModmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJGb250IjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRGb250KHZhbHVlWzBdLCB2YWx1ZVsxXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgIkNBIjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50LnN0cm9rZUFscGhhID0gdmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgImNhIjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50LmZpbGxBbHBoYSA9IHZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN0eC5nbG9iYWxBbHBoYSA9IHZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJCTSI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4Lmdsb2JhbENvbXBvc2l0ZU9wZXJhdGlvbiA9IHZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJTTWFzayI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC5hY3RpdmVTTWFzayA9IHZhbHVlID8gdGhpcy50ZW1wU01hc2sgOiBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnRlbXBTTWFzayA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2hlY2tTTWFza1N0YXRlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgIlRSIjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHguZmlsdGVyID0gdGhpcy5jdXJyZW50LnRyYW5zZmVyTWFwcyA9IHRoaXMuZmlsdGVyRmFjdG9yeS5hZGRGaWx0ZXIodmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgaW5TTWFza01vZGUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAhIXRoaXMuc3VzcGVuZGVkQ3R4OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjaGVja1NNYXNrU3RhdGUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGluU01hc2tNb2RlID0gdGhpcy5pblNNYXNrTW9kZTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuY3VycmVudC5hY3RpdmVTTWFzayAmJiAhaW5TTWFza01vZGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYmVnaW5TTWFza01vZGUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmICghdGhpcy5jdXJyZW50LmFjdGl2ZVNNYXNrICYmIGluU01hc2tNb2RlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmVuZFNNYXNrTW9kZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGJlZ2luU01hc2tNb2RlKCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5pblNNYXNrTW9kZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCJiZWdpblNNYXNrTW9kZSBjYWxsZWQgd2hpbGUgYWxyZWFkeSBpbiBzbWFzayBtb2RlIik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZHJhd25XaWR0aCA9IHRoaXMuY3R4LmNhbnZhcy53aWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZHJhd25IZWlnaHQgPSB0aGlzLmN0eC5jYW52YXMuaGVpZ2h0OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjYWNoZUlkID0gInNtYXNrR3JvdXBBdCIgKyB0aGlzLmdyb3VwTGV2ZWw7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHNjcmF0Y2hDYW52YXMgPSB0aGlzLmNhY2hlZENhbnZhc2VzLmdldENhbnZhcyhjYWNoZUlkLCBkcmF3bldpZHRoLCBkcmF3bkhlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc3VzcGVuZGVkQ3R4ID0gdGhpcy5jdHg7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4ID0gc2NyYXRjaENhbnZhcy5jb250ZXh0OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjdHggPSB0aGlzLmN0eDsKICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnNldFRyYW5zZm9ybSguLi4oMCwgX2Rpc3BsYXlfdXRpbHMuZ2V0Q3VycmVudFRyYW5zZm9ybSkodGhpcy5zdXNwZW5kZWRDdHgpKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29weUN0eFN0YXRlKHRoaXMuc3VzcGVuZGVkQ3R4LCBjdHgpOwogICAgICAgICAgICAgICAgICAgICAgICBtaXJyb3JDb250ZXh0T3BlcmF0aW9ucyhjdHgsIHRoaXMuc3VzcGVuZGVkQ3R4KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRHU3RhdGUoW1siQk0iLCAic291cmNlLW92ZXIiXSwgWyJjYSIsIDFdLCBbIkNBIiwgMV1dKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZW5kU01hc2tNb2RlKCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuaW5TTWFza01vZGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcigiZW5kU01hc2tNb2RlIGNhbGxlZCB3aGlsZSBub3QgaW4gc21hc2sgbW9kZSIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4Ll9yZW1vdmVNaXJyb3JpbmcoKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29weUN0eFN0YXRlKHRoaXMuY3R4LCB0aGlzLnN1c3BlbmRlZEN0eCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4ID0gdGhpcy5zdXNwZW5kZWRDdHg7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc3VzcGVuZGVkQ3R4ID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY29tcG9zZShkaXJ0eUJveCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuY3VycmVudC5hY3RpdmVTTWFzaykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghZGlydHlCb3gpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRpcnR5Qm94ID0gWzAsIDAsIHRoaXMuY3R4LmNhbnZhcy53aWR0aCwgdGhpcy5jdHguY2FudmFzLmhlaWdodF07CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkaXJ0eUJveFswXSA9IE1hdGguZmxvb3IoZGlydHlCb3hbMF0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGlydHlCb3hbMV0gPSBNYXRoLmZsb29yKGRpcnR5Qm94WzFdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRpcnR5Qm94WzJdID0gTWF0aC5jZWlsKGRpcnR5Qm94WzJdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRpcnR5Qm94WzNdID0gTWF0aC5jZWlsKGRpcnR5Qm94WzNdKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzbWFzayA9IHRoaXMuY3VycmVudC5hY3RpdmVTTWFzazsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3VzcGVuZGVkQ3R4ID0gdGhpcy5zdXNwZW5kZWRDdHg7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbXBvc2VTTWFzayhzdXNwZW5kZWRDdHgsIHNtYXNrLCB0aGlzLmN0eCwgZGlydHlCb3gpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN0eC5zYXZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4LnNldFRyYW5zZm9ybSgxLCAwLCAwLCAxLCAwLCAwKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHguY2xlYXJSZWN0KDAsIDAsIHRoaXMuY3R4LmNhbnZhcy53aWR0aCwgdGhpcy5jdHguY2FudmFzLmhlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4LnJlc3RvcmUoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2F2ZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuaW5TTWFza01vZGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvcHlDdHhTdGF0ZSh0aGlzLmN0eCwgdGhpcy5zdXNwZW5kZWRDdHgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zdXNwZW5kZWRDdHguc2F2ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHguc2F2ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG9sZCA9IHRoaXMuY3VycmVudDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zdGF0ZVN0YWNrLnB1c2gob2xkKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50ID0gb2xkLmNsb25lKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlc3RvcmUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLnN0YXRlU3RhY2subGVuZ3RoID09PSAwICYmIHRoaXMuaW5TTWFza01vZGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZW5kU01hc2tNb2RlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuc3RhdGVTdGFjay5sZW5ndGggIT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudCA9IHRoaXMuc3RhdGVTdGFjay5wb3AoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmluU01hc2tNb2RlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zdXNwZW5kZWRDdHgucmVzdG9yZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvcHlDdHhTdGF0ZSh0aGlzLnN1c3BlbmRlZEN0eCwgdGhpcy5jdHgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN0eC5yZXN0b3JlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNoZWNrU01hc2tTdGF0ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wZW5kaW5nQ2xpcCA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jYWNoZWRTY2FsZUZvclN0cm9raW5nID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NhY2hlZEdldFNpbmdsZVBpeGVsV2lkdGggPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHRyYW5zZm9ybShhLCBiLCBjLCBkLCBlLCBmKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4LnRyYW5zZm9ybShhLCBiLCBjLCBkLCBlLCBmKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fY2FjaGVkU2NhbGVGb3JTdHJva2luZyA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NhY2hlZEdldFNpbmdsZVBpeGVsV2lkdGggPSBudWxsOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RQYXRoKG9wcywgYXJncywgbWluTWF4KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGN0eCA9IHRoaXMuY3R4OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjdXJyZW50ID0gdGhpcy5jdXJyZW50OwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgeCA9IGN1cnJlbnQueCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHkgPSBjdXJyZW50Lnk7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBzdGFydFgsIHN0YXJ0WTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY3VycmVudFRyYW5zZm9ybSA9ICgwLCBfZGlzcGxheV91dGlscy5nZXRDdXJyZW50VHJhbnNmb3JtKShjdHgpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpc1NjYWxpbmdNYXRyaXggPSBjdXJyZW50VHJhbnNmb3JtWzBdID09PSAwICYmIGN1cnJlbnRUcmFuc2Zvcm1bM10gPT09IDAgfHwgY3VycmVudFRyYW5zZm9ybVsxXSA9PT0gMCAmJiBjdXJyZW50VHJhbnNmb3JtWzJdID09PSAwOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBtaW5NYXhGb3JCZXppZXIgPSBpc1NjYWxpbmdNYXRyaXggPyBtaW5NYXguc2xpY2UoMCkgOiBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMCwgaiA9IDAsIGlpID0gb3BzLmxlbmd0aDsgaSA8IGlpOyBpKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN3aXRjaCAob3BzW2ldIHwgMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnJlY3RhbmdsZToKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgeCA9IGFyZ3NbaisrXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgeSA9IGFyZ3NbaisrXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgd2lkdGggPSBhcmdzW2orK107CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGhlaWdodCA9IGFyZ3NbaisrXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgeHcgPSB4ICsgd2lkdGg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHloID0geSArIGhlaWdodDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4Lm1vdmVUbyh4LCB5KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHdpZHRoID09PSAwIHx8IGhlaWdodCA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LmxpbmVUbyh4dywgeWgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LmxpbmVUbyh4dywgeSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHgubGluZVRvKHh3LCB5aCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHgubGluZVRvKHgsIHloKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWlzU2NhbGluZ01hdHJpeCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC51cGRhdGVSZWN0TWluTWF4KGN1cnJlbnRUcmFuc2Zvcm0sIFt4LCB5LCB4dywgeWhdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHguY2xvc2VQYXRoKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLm1vdmVUbzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgeCA9IGFyZ3NbaisrXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgeSA9IGFyZ3NbaisrXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4Lm1vdmVUbyh4LCB5KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFpc1NjYWxpbmdNYXRyaXgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQudXBkYXRlUGF0aE1pbk1heChjdXJyZW50VHJhbnNmb3JtLCB4LCB5KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5saW5lVG86CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHggPSBhcmdzW2orK107CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHkgPSBhcmdzW2orK107CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5saW5lVG8oeCwgeSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghaXNTY2FsaW5nTWF0cml4KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LnVwZGF0ZVBhdGhNaW5NYXgoY3VycmVudFRyYW5zZm9ybSwgeCwgeSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5PUFMuY3VydmVUbzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RhcnRYID0geDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RhcnRZID0geTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgeCA9IGFyZ3NbaiArIDRdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB5ID0gYXJnc1tqICsgNV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5iZXppZXJDdXJ2ZVRvKGFyZ3Nbal0sIGFyZ3NbaiArIDFdLCBhcmdzW2ogKyAyXSwgYXJnc1tqICsgM10sIHgsIHkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LnVwZGF0ZUN1cnZlUGF0aE1pbk1heChjdXJyZW50VHJhbnNmb3JtLCBzdGFydFgsIHN0YXJ0WSwgYXJnc1tqXSwgYXJnc1tqICsgMV0sIGFyZ3NbaiArIDJdLCBhcmdzW2ogKyAzXSwgeCwgeSwgbWluTWF4Rm9yQmV6aWVyKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaiArPSA2OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5jdXJ2ZVRvMjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RhcnRYID0geDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RhcnRZID0geTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LmJlemllckN1cnZlVG8oeCwgeSwgYXJnc1tqXSwgYXJnc1tqICsgMV0sIGFyZ3NbaiArIDJdLCBhcmdzW2ogKyAzXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQudXBkYXRlQ3VydmVQYXRoTWluTWF4KGN1cnJlbnRUcmFuc2Zvcm0sIHN0YXJ0WCwgc3RhcnRZLCB4LCB5LCBhcmdzW2pdLCBhcmdzW2ogKyAxXSwgYXJnc1tqICsgMl0sIGFyZ3NbaiArIDNdLCBtaW5NYXhGb3JCZXppZXIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB4ID0gYXJnc1tqICsgMl07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHkgPSBhcmdzW2ogKyAzXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaiArPSA0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5jdXJ2ZVRvMzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RhcnRYID0geDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RhcnRZID0geTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgeCA9IGFyZ3NbaiArIDJdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB5ID0gYXJnc1tqICsgM107CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5iZXppZXJDdXJ2ZVRvKGFyZ3Nbal0sIGFyZ3NbaiArIDFdLCB4LCB5LCB4LCB5KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC51cGRhdGVDdXJ2ZVBhdGhNaW5NYXgoY3VycmVudFRyYW5zZm9ybSwgc3RhcnRYLCBzdGFydFksIGFyZ3Nbal0sIGFyZ3NbaiArIDFdLCB4LCB5LCB4LCB5LCBtaW5NYXhGb3JCZXppZXIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBqICs9IDQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLmNsb3NlUGF0aDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LmNsb3NlUGF0aCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAoaXNTY2FsaW5nTWF0cml4KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LnVwZGF0ZVNjYWxpbmdQYXRoTWluTWF4KGN1cnJlbnRUcmFuc2Zvcm0sIG1pbk1heEZvckJlemllcik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC5zZXRDdXJyZW50UG9pbnQoeCwgeSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNsb3NlUGF0aCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHguY2xvc2VQYXRoKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0cm9rZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGNvbnN1bWVQYXRoID0gYXJndW1lbnRzLmxlbmd0aCA+IDAgJiYgYXJndW1lbnRzWzBdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMF0gOiB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjdHggPSB0aGlzLmN0eDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3Ryb2tlQ29sb3IgPSB0aGlzLmN1cnJlbnQuc3Ryb2tlQ29sb3I7CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5nbG9iYWxBbHBoYSA9IHRoaXMuY3VycmVudC5zdHJva2VBbHBoYTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuY29udGVudFZpc2libGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0eXBlb2Ygc3Ryb2tlQ29sb3IgPT09ICJvYmplY3QiICYmIHN0cm9rZUNvbG9yICE9PSBudWxsICYmIHN0cm9rZUNvbG9yICE9PSB2b2lkIDAgJiYgc3Ryb2tlQ29sb3IuZ2V0UGF0dGVybikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5zYXZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnN0cm9rZVN0eWxlID0gc3Ryb2tlQ29sb3IuZ2V0UGF0dGVybihjdHgsIHRoaXMsICgwLCBfZGlzcGxheV91dGlscy5nZXRDdXJyZW50VHJhbnNmb3JtSW52ZXJzZSkoY3R4KSwgX3BhdHRlcm5faGVscGVyLlBhdGhUeXBlLlNUUk9LRSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5yZXNjYWxlQW5kU3Ryb2tlKGZhbHNlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHgucmVzdG9yZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnJlc2NhbGVBbmRTdHJva2UodHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGNvbnN1bWVQYXRoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnN1bWVQYXRoKHRoaXMuY3VycmVudC5nZXRDbGlwcGVkUGF0aEJvdW5kaW5nQm94KCkpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5nbG9iYWxBbHBoYSA9IHRoaXMuY3VycmVudC5maWxsQWxwaGE7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNsb3NlU3Ryb2tlKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNsb3NlUGF0aCgpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnN0cm9rZSgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBmaWxsKCkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgY29uc3VtZVBhdGggPSBhcmd1bWVudHMubGVuZ3RoID4gMCAmJiBhcmd1bWVudHNbMF0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1swXSA6IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGN0eCA9IHRoaXMuY3R4OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBmaWxsQ29sb3IgPSB0aGlzLmN1cnJlbnQuZmlsbENvbG9yOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpc1BhdHRlcm5GaWxsID0gdGhpcy5jdXJyZW50LnBhdHRlcm5GaWxsOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgbmVlZFJlc3RvcmUgPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGlzUGF0dGVybkZpbGwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5zYXZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHguZmlsbFN0eWxlID0gZmlsbENvbG9yLmdldFBhdHRlcm4oY3R4LCB0aGlzLCAoMCwgX2Rpc3BsYXlfdXRpbHMuZ2V0Q3VycmVudFRyYW5zZm9ybUludmVyc2UpKGN0eCksIF9wYXR0ZXJuX2hlbHBlci5QYXRoVHlwZS5GSUxMKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5lZWRSZXN0b3JlID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpbnRlcnNlY3QgPSB0aGlzLmN1cnJlbnQuZ2V0Q2xpcHBlZFBhdGhCb3VuZGluZ0JveCgpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5jb250ZW50VmlzaWJsZSAmJiBpbnRlcnNlY3QgIT09IG51bGwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLnBlbmRpbmdFT0ZpbGwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHguZmlsbCgiZXZlbm9kZCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGVuZGluZ0VPRmlsbCA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHguZmlsbCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChuZWVkUmVzdG9yZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnJlc3RvcmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAoY29uc3VtZVBhdGgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29uc3VtZVBhdGgoaW50ZXJzZWN0KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBlb0ZpbGwoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGVuZGluZ0VPRmlsbCA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZmlsbCgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBmaWxsU3Ryb2tlKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmZpbGwoZmFsc2UpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnN0cm9rZShmYWxzZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29uc3VtZVBhdGgoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZW9GaWxsU3Ryb2tlKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBlbmRpbmdFT0ZpbGwgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmZpbGxTdHJva2UoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY2xvc2VGaWxsU3Ryb2tlKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNsb3NlUGF0aCgpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmZpbGxTdHJva2UoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY2xvc2VFT0ZpbGxTdHJva2UoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGVuZGluZ0VPRmlsbCA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2xvc2VQYXRoKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZmlsbFN0cm9rZSgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBlbmRQYXRoKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnN1bWVQYXRoKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNsaXAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGVuZGluZ0NsaXAgPSBOT1JNQUxfQ0xJUDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZW9DbGlwKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBlbmRpbmdDbGlwID0gRU9fQ0xJUDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYmVnaW5UZXh0KCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN1cnJlbnQudGV4dE1hdHJpeCA9IF91dGlsLklERU5USVRZX01BVFJJWDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50LnRleHRNYXRyaXhTY2FsZSA9IDE7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC54ID0gdGhpcy5jdXJyZW50LmxpbmVYID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50LnkgPSB0aGlzLmN1cnJlbnQubGluZVkgPSAwOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBlbmRUZXh0KCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwYXRocyA9IHRoaXMucGVuZGluZ1RleHRQYXRoczsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY3R4ID0gdGhpcy5jdHg7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChwYXRocyA9PT0gdW5kZWZpbmVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHguYmVnaW5QYXRoKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnNhdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgY3R4LmJlZ2luUGF0aCgpOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IHBhdGggb2YgcGF0aHMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5zZXRUcmFuc2Zvcm0oLi4ucGF0aC50cmFuc2Zvcm0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnRyYW5zbGF0ZShwYXRoLngsIHBhdGgueSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYXRoLmFkZFRvUGF0aChjdHgsIHBhdGguZm9udFNpemUpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5yZXN0b3JlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5jbGlwKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5iZWdpblBhdGgoKTsKICAgICAgICAgICAgICAgICAgICAgICAgZGVsZXRlIHRoaXMucGVuZGluZ1RleHRQYXRoczsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2V0Q2hhclNwYWNpbmcoc3BhY2luZykgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN1cnJlbnQuY2hhclNwYWNpbmcgPSBzcGFjaW5nOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzZXRXb3JkU3BhY2luZyhzcGFjaW5nKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC53b3JkU3BhY2luZyA9IHNwYWNpbmc7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNldEhTY2FsZShzY2FsZSkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN1cnJlbnQudGV4dEhTY2FsZSA9IHNjYWxlIC8gMTAwOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzZXRMZWFkaW5nKGxlYWRpbmcpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50LmxlYWRpbmcgPSAtbGVhZGluZzsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2V0Rm9udChmb250UmVmTmFtZSwgc2l6ZSkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBmb250T2JqID0gdGhpcy5jb21tb25PYmpzLmdldChmb250UmVmTmFtZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGN1cnJlbnQgPSB0aGlzLmN1cnJlbnQ7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghZm9udE9iaikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKGBDYW4ndCBmaW5kIGZvbnQgZm9yICR7Zm9udFJlZk5hbWV9YCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC5mb250TWF0cml4ID0gZm9udE9iai5mb250TWF0cml4IHx8IF91dGlsLkZPTlRfSURFTlRJVFlfTUFUUklYOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoY3VycmVudC5mb250TWF0cml4WzBdID09PSAwIHx8IGN1cnJlbnQuZm9udE1hdHJpeFszXSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKCJJbnZhbGlkIGZvbnQgbWF0cml4IGZvciBmb250ICIgKyBmb250UmVmTmFtZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHNpemUgPCAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzaXplID0gLXNpemU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LmZvbnREaXJlY3Rpb24gPSAtMTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQuZm9udERpcmVjdGlvbiA9IDE7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50LmZvbnQgPSBmb250T2JqOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN1cnJlbnQuZm9udFNpemUgPSBzaXplOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZm9udE9iai5pc1R5cGUzRm9udCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG5hbWUgPSBmb250T2JqLmxvYWRlZE5hbWUgfHwgInNhbnMtc2VyaWYiOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgYm9sZCA9ICJub3JtYWwiOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZm9udE9iai5ibGFjaykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgYm9sZCA9ICI5MDAiOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGZvbnRPYmouYm9sZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgYm9sZCA9ICJib2xkIjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpdGFsaWMgPSBmb250T2JqLml0YWxpYyA/ICJpdGFsaWMiIDogIm5vcm1hbCI7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHR5cGVmYWNlID0gYCIke25hbWV9IiwgJHtmb250T2JqLmZhbGxiYWNrTmFtZX1gOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgYnJvd3NlckZvbnRTaXplID0gc2l6ZTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHNpemUgPCBNSU5fRk9OVF9TSVpFKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBicm93c2VyRm9udFNpemUgPSBNSU5fRk9OVF9TSVpFOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHNpemUgPiBNQVhfRk9OVF9TSVpFKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBicm93c2VyRm9udFNpemUgPSBNQVhfRk9OVF9TSVpFOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC5mb250U2l6ZVNjYWxlID0gc2l6ZSAvIGJyb3dzZXJGb250U2l6ZTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHguZm9udCA9IGAke2l0YWxpY30gJHtib2xkfSAke2Jyb3dzZXJGb250U2l6ZX1weCAke3R5cGVmYWNlfWA7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNldFRleHRSZW5kZXJpbmdNb2RlKG1vZGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50LnRleHRSZW5kZXJpbmdNb2RlID0gbW9kZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2V0VGV4dFJpc2UocmlzZSkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN1cnJlbnQudGV4dFJpc2UgPSByaXNlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBtb3ZlVGV4dCh4LCB5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC54ID0gdGhpcy5jdXJyZW50LmxpbmVYICs9IHg7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC55ID0gdGhpcy5jdXJyZW50LmxpbmVZICs9IHk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNldExlYWRpbmdNb3ZlVGV4dCh4LCB5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0TGVhZGluZygteSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubW92ZVRleHQoeCwgeSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNldFRleHRNYXRyaXgoYSwgYiwgYywgZCwgZSwgZikgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN1cnJlbnQudGV4dE1hdHJpeCA9IFthLCBiLCBjLCBkLCBlLCBmXTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50LnRleHRNYXRyaXhTY2FsZSA9IE1hdGguaHlwb3QoYSwgYik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC54ID0gdGhpcy5jdXJyZW50LmxpbmVYID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50LnkgPSB0aGlzLmN1cnJlbnQubGluZVkgPSAwOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBuZXh0TGluZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5tb3ZlVGV4dCgwLCB0aGlzLmN1cnJlbnQubGVhZGluZyk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHBhaW50Q2hhcihjaGFyYWN0ZXIsIHgsIHksIHBhdHRlcm5UcmFuc2Zvcm0pIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY3R4ID0gdGhpcy5jdHg7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGN1cnJlbnQgPSB0aGlzLmN1cnJlbnQ7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZvbnQgPSBjdXJyZW50LmZvbnQ7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHRleHRSZW5kZXJpbmdNb2RlID0gY3VycmVudC50ZXh0UmVuZGVyaW5nTW9kZTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZm9udFNpemUgPSBjdXJyZW50LmZvbnRTaXplIC8gY3VycmVudC5mb250U2l6ZVNjYWxlOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBmaWxsU3Ryb2tlTW9kZSA9IHRleHRSZW5kZXJpbmdNb2RlICYgX3V0aWwuVGV4dFJlbmRlcmluZ01vZGUuRklMTF9TVFJPS0VfTUFTSzsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaXNBZGRUb1BhdGhTZXQgPSAhISh0ZXh0UmVuZGVyaW5nTW9kZSAmIF91dGlsLlRleHRSZW5kZXJpbmdNb2RlLkFERF9UT19QQVRIX0ZMQUcpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwYXR0ZXJuRmlsbCA9IGN1cnJlbnQucGF0dGVybkZpbGwgJiYgIWZvbnQubWlzc2luZ0ZpbGU7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBhZGRUb1BhdGg7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChmb250LmRpc2FibGVGb250RmFjZSB8fCBpc0FkZFRvUGF0aFNldCB8fCBwYXR0ZXJuRmlsbCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgYWRkVG9QYXRoID0gZm9udC5nZXRQYXRoR2VuZXJhdG9yKHRoaXMuY29tbW9uT2JqcywgY2hhcmFjdGVyKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZm9udC5kaXNhYmxlRm9udEZhY2UgfHwgcGF0dGVybkZpbGwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5zYXZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHgudHJhbnNsYXRlKHgsIHkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LmJlZ2luUGF0aCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgYWRkVG9QYXRoKGN0eCwgZm9udFNpemUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHBhdHRlcm5UcmFuc2Zvcm0pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHguc2V0VHJhbnNmb3JtKC4uLnBhdHRlcm5UcmFuc2Zvcm0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGZpbGxTdHJva2VNb2RlID09PSBfdXRpbC5UZXh0UmVuZGVyaW5nTW9kZS5GSUxMIHx8IGZpbGxTdHJva2VNb2RlID09PSBfdXRpbC5UZXh0UmVuZGVyaW5nTW9kZS5GSUxMX1NUUk9LRSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5maWxsKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZmlsbFN0cm9rZU1vZGUgPT09IF91dGlsLlRleHRSZW5kZXJpbmdNb2RlLlNUUk9LRSB8fCBmaWxsU3Ryb2tlTW9kZSA9PT0gX3V0aWwuVGV4dFJlbmRlcmluZ01vZGUuRklMTF9TVFJPS0UpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHguc3Ryb2tlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHgucmVzdG9yZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGZpbGxTdHJva2VNb2RlID09PSBfdXRpbC5UZXh0UmVuZGVyaW5nTW9kZS5GSUxMIHx8IGZpbGxTdHJva2VNb2RlID09PSBfdXRpbC5UZXh0UmVuZGVyaW5nTW9kZS5GSUxMX1NUUk9LRSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5maWxsVGV4dChjaGFyYWN0ZXIsIHgsIHkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGZpbGxTdHJva2VNb2RlID09PSBfdXRpbC5UZXh0UmVuZGVyaW5nTW9kZS5TVFJPS0UgfHwgZmlsbFN0cm9rZU1vZGUgPT09IF91dGlsLlRleHRSZW5kZXJpbmdNb2RlLkZJTExfU1RST0tFKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnN0cm9rZVRleHQoY2hhcmFjdGVyLCB4LCB5KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAoaXNBZGRUb1BhdGhTZXQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHBhdGhzID0gdGhpcy5wZW5kaW5nVGV4dFBhdGhzIHx8ICh0aGlzLnBlbmRpbmdUZXh0UGF0aHMgPSBbXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYXRocy5wdXNoKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cmFuc2Zvcm06ICgwLCBfZGlzcGxheV91dGlscy5nZXRDdXJyZW50VHJhbnNmb3JtKShjdHgpLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgeSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb250U2l6ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhZGRUb1BhdGgKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBpc0ZvbnRTdWJwaXhlbEFBRW5hYmxlZCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGV4dDogY3R4CiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSB0aGlzLmNhY2hlZENhbnZhc2VzLmdldENhbnZhcygiaXNGb250U3VicGl4ZWxBQUVuYWJsZWQiLCAxMCwgMTApOwogICAgICAgICAgICAgICAgICAgICAgICBjdHguc2NhbGUoMS41LCAxKTsKICAgICAgICAgICAgICAgICAgICAgICAgY3R4LmZpbGxUZXh0KCJJIiwgMCwgMTApOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBkYXRhID0gY3R4LmdldEltYWdlRGF0YSgwLCAwLCAxMCwgMTApLmRhdGE7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBlbmFibGVkID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAzOyBpIDwgZGF0YS5sZW5ndGg7IGkgKz0gNCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGRhdGFbaV0gPiAwICYmIGRhdGFbaV0gPCAyNTUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbmFibGVkID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gKDAsIF91dGlsLnNoYWRvdykodGhpcywgImlzRm9udFN1YnBpeGVsQUFFbmFibGVkIiwgZW5hYmxlZCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNob3dUZXh0KGdseXBocykgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjdXJyZW50ID0gdGhpcy5jdXJyZW50OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBmb250ID0gY3VycmVudC5mb250OwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZm9udC5pc1R5cGUzRm9udCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuc2hvd1R5cGUzVGV4dChnbHlwaHMpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZvbnRTaXplID0gY3VycmVudC5mb250U2l6ZTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGZvbnRTaXplID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdW5kZWZpbmVkOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGN0eCA9IHRoaXMuY3R4OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBmb250U2l6ZVNjYWxlID0gY3VycmVudC5mb250U2l6ZVNjYWxlOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjaGFyU3BhY2luZyA9IGN1cnJlbnQuY2hhclNwYWNpbmc7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHdvcmRTcGFjaW5nID0gY3VycmVudC53b3JkU3BhY2luZzsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZm9udERpcmVjdGlvbiA9IGN1cnJlbnQuZm9udERpcmVjdGlvbjsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdGV4dEhTY2FsZSA9IGN1cnJlbnQudGV4dEhTY2FsZSAqIGZvbnREaXJlY3Rpb247CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGdseXBoc0xlbmd0aCA9IGdseXBocy5sZW5ndGg7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHZlcnRpY2FsID0gZm9udC52ZXJ0aWNhbDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3BhY2luZ0RpciA9IHZlcnRpY2FsID8gMSA6IC0xOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBkZWZhdWx0Vk1ldHJpY3MgPSBmb250LmRlZmF1bHRWTWV0cmljczsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgd2lkdGhBZHZhbmNlU2NhbGUgPSBmb250U2l6ZSAqIGN1cnJlbnQuZm9udE1hdHJpeFswXTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2ltcGxlRmlsbFRleHQgPSBjdXJyZW50LnRleHRSZW5kZXJpbmdNb2RlID09PSBfdXRpbC5UZXh0UmVuZGVyaW5nTW9kZS5GSUxMICYmICFmb250LmRpc2FibGVGb250RmFjZSAmJiAhY3VycmVudC5wYXR0ZXJuRmlsbDsKICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnNhdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnRyYW5zZm9ybSguLi5jdXJyZW50LnRleHRNYXRyaXgpOwogICAgICAgICAgICAgICAgICAgICAgICBjdHgudHJhbnNsYXRlKGN1cnJlbnQueCwgY3VycmVudC55ICsgY3VycmVudC50ZXh0UmlzZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChmb250RGlyZWN0aW9uID4gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnNjYWxlKHRleHRIU2NhbGUsIC0xKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5zY2FsZSh0ZXh0SFNjYWxlLCAxKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBsZXQgcGF0dGVyblRyYW5zZm9ybTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGN1cnJlbnQucGF0dGVybkZpbGwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5zYXZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwYXR0ZXJuID0gY3VycmVudC5maWxsQ29sb3IuZ2V0UGF0dGVybihjdHgsIHRoaXMsICgwLCBfZGlzcGxheV91dGlscy5nZXRDdXJyZW50VHJhbnNmb3JtSW52ZXJzZSkoY3R4KSwgX3BhdHRlcm5faGVscGVyLlBhdGhUeXBlLkZJTEwpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGF0dGVyblRyYW5zZm9ybSA9ICgwLCBfZGlzcGxheV91dGlscy5nZXRDdXJyZW50VHJhbnNmb3JtKShjdHgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnJlc3RvcmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5maWxsU3R5bGUgPSBwYXR0ZXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBsaW5lV2lkdGggPSBjdXJyZW50LmxpbmVXaWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2NhbGUgPSBjdXJyZW50LnRleHRNYXRyaXhTY2FsZTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHNjYWxlID09PSAwIHx8IGxpbmVXaWR0aCA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZmlsbFN0cm9rZU1vZGUgPSBjdXJyZW50LnRleHRSZW5kZXJpbmdNb2RlICYgX3V0aWwuVGV4dFJlbmRlcmluZ01vZGUuRklMTF9TVFJPS0VfTUFTSzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChmaWxsU3Ryb2tlTW9kZSA9PT0gX3V0aWwuVGV4dFJlbmRlcmluZ01vZGUuU1RST0tFIHx8IGZpbGxTdHJva2VNb2RlID09PSBfdXRpbC5UZXh0UmVuZGVyaW5nTW9kZS5GSUxMX1NUUk9LRSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxpbmVXaWR0aCA9IHRoaXMuZ2V0U2luZ2xlUGl4ZWxXaWR0aCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGluZVdpZHRoIC89IHNjYWxlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChmb250U2l6ZVNjYWxlICE9PSAxLjApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5zY2FsZShmb250U2l6ZVNjYWxlLCBmb250U2l6ZVNjYWxlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxpbmVXaWR0aCAvPSBmb250U2l6ZVNjYWxlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5saW5lV2lkdGggPSBsaW5lV2lkdGg7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChmb250LmlzSW52YWxpZFBERmpzRm9udCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2hhcnMgPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCB3aWR0aCA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGdseXBoIG9mIGdseXBocykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNoYXJzLnB1c2goZ2x5cGgudW5pY29kZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgd2lkdGggKz0gZ2x5cGgud2lkdGg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHguZmlsbFRleHQoY2hhcnMuam9pbigiIiksIDAsIDApOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC54ICs9IHdpZHRoICogd2lkdGhBZHZhbmNlU2NhbGUgKiB0ZXh0SFNjYWxlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnJlc3RvcmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29tcG9zZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHVuZGVmaW5lZDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBsZXQgeCA9IDAsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGkgPSAwOyBpIDwgZ2x5cGhzTGVuZ3RoOyArK2kpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGdseXBoID0gZ2x5cGhzW2ldOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHR5cGVvZiBnbHlwaCA9PT0gIm51bWJlciIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB4ICs9IHNwYWNpbmdEaXIgKiBnbHlwaCAqIGZvbnRTaXplIC8gMTAwMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCByZXN0b3JlTmVlZGVkID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzcGFjaW5nID0gKGdseXBoLmlzU3BhY2UgPyB3b3JkU3BhY2luZyA6IDApICsgY2hhclNwYWNpbmc7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjaGFyYWN0ZXIgPSBnbHlwaC5mb250Q2hhcjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGFjY2VudCA9IGdseXBoLmFjY2VudDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBzY2FsZWRYLCBzY2FsZWRZOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHdpZHRoID0gZ2x5cGgud2lkdGg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodmVydGljYWwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB2bWV0cmljID0gZ2x5cGgudm1ldHJpYyB8fCBkZWZhdWx0Vk1ldHJpY3M7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdnggPSAtKGdseXBoLnZtZXRyaWMgPyB2bWV0cmljWzFdIDogd2lkdGggKiAwLjUpICogd2lkdGhBZHZhbmNlU2NhbGU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdnkgPSB2bWV0cmljWzJdICogd2lkdGhBZHZhbmNlU2NhbGU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgd2lkdGggPSB2bWV0cmljID8gLXZtZXRyaWNbMF0gOiB3aWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzY2FsZWRYID0gdnggLyBmb250U2l6ZVNjYWxlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNjYWxlZFkgPSAoeCArIHZ5KSAvIGZvbnRTaXplU2NhbGU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNjYWxlZFggPSB4IC8gZm9udFNpemVTY2FsZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzY2FsZWRZID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChmb250LnJlbWVhc3VyZSAmJiB3aWR0aCA+IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBtZWFzdXJlZFdpZHRoID0gY3R4Lm1lYXN1cmVUZXh0KGNoYXJhY3Rlcikud2lkdGggKiAxMDAwIC8gZm9udFNpemUgKiBmb250U2l6ZVNjYWxlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh3aWR0aCA8IG1lYXN1cmVkV2lkdGggJiYgdGhpcy5pc0ZvbnRTdWJwaXhlbEFBRW5hYmxlZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjaGFyYWN0ZXJTY2FsZVggPSB3aWR0aCAvIG1lYXN1cmVkV2lkdGg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlc3RvcmVOZWVkZWQgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHguc2F2ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHguc2NhbGUoY2hhcmFjdGVyU2NhbGVYLCAxKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2NhbGVkWCAvPSBjaGFyYWN0ZXJTY2FsZVg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmICh3aWR0aCAhPT0gbWVhc3VyZWRXaWR0aCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzY2FsZWRYICs9ICh3aWR0aCAtIG1lYXN1cmVkV2lkdGgpIC8gMjAwMCAqIGZvbnRTaXplIC8gZm9udFNpemVTY2FsZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5jb250ZW50VmlzaWJsZSAmJiAoZ2x5cGguaXNJbkZvbnQgfHwgZm9udC5taXNzaW5nRmlsZSkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoc2ltcGxlRmlsbFRleHQgJiYgIWFjY2VudCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHguZmlsbFRleHQoY2hhcmFjdGVyLCBzY2FsZWRYLCBzY2FsZWRZKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBhaW50Q2hhcihjaGFyYWN0ZXIsIHNjYWxlZFgsIHNjYWxlZFksIHBhdHRlcm5UcmFuc2Zvcm0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoYWNjZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzY2FsZWRBY2NlbnRYID0gc2NhbGVkWCArIGZvbnRTaXplICogYWNjZW50Lm9mZnNldC54IC8gZm9udFNpemVTY2FsZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHNjYWxlZEFjY2VudFkgPSBzY2FsZWRZIC0gZm9udFNpemUgKiBhY2NlbnQub2Zmc2V0LnkgLyBmb250U2l6ZVNjYWxlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wYWludENoYXIoYWNjZW50LmZvbnRDaGFyLCBzY2FsZWRBY2NlbnRYLCBzY2FsZWRBY2NlbnRZLCBwYXR0ZXJuVHJhbnNmb3JtKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBjaGFyV2lkdGg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodmVydGljYWwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjaGFyV2lkdGggPSB3aWR0aCAqIHdpZHRoQWR2YW5jZVNjYWxlIC0gc3BhY2luZyAqIGZvbnREaXJlY3Rpb247CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNoYXJXaWR0aCA9IHdpZHRoICogd2lkdGhBZHZhbmNlU2NhbGUgKyBzcGFjaW5nICogZm9udERpcmVjdGlvbjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHggKz0gY2hhcldpZHRoOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHJlc3RvcmVOZWVkZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHgucmVzdG9yZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh2ZXJ0aWNhbCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC55IC09IHg7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LnggKz0geCAqIHRleHRIU2NhbGU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnJlc3RvcmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb21wb3NlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB1bmRlZmluZWQ7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNob3dUeXBlM1RleHQoZ2x5cGhzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGN0eCA9IHRoaXMuY3R4OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjdXJyZW50ID0gdGhpcy5jdXJyZW50OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBmb250ID0gY3VycmVudC5mb250OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBmb250U2l6ZSA9IGN1cnJlbnQuZm9udFNpemU7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZvbnREaXJlY3Rpb24gPSBjdXJyZW50LmZvbnREaXJlY3Rpb247CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHNwYWNpbmdEaXIgPSBmb250LnZlcnRpY2FsID8gMSA6IC0xOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjaGFyU3BhY2luZyA9IGN1cnJlbnQuY2hhclNwYWNpbmc7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHdvcmRTcGFjaW5nID0gY3VycmVudC53b3JkU3BhY2luZzsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdGV4dEhTY2FsZSA9IGN1cnJlbnQudGV4dEhTY2FsZSAqIGZvbnREaXJlY3Rpb247CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZvbnRNYXRyaXggPSBjdXJyZW50LmZvbnRNYXRyaXggfHwgX3V0aWwuRk9OVF9JREVOVElUWV9NQVRSSVg7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGdseXBoc0xlbmd0aCA9IGdseXBocy5sZW5ndGg7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGlzVGV4dEludmlzaWJsZSA9IGN1cnJlbnQudGV4dFJlbmRlcmluZ01vZGUgPT09IF91dGlsLlRleHRSZW5kZXJpbmdNb2RlLklOVklTSUJMRTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGksIGdseXBoLCB3aWR0aCwgc3BhY2luZ0xlbmd0aDsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGlzVGV4dEludmlzaWJsZSB8fCBmb250U2l6ZSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NhY2hlZFNjYWxlRm9yU3Ryb2tpbmcgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jYWNoZWRHZXRTaW5nbGVQaXhlbFdpZHRoID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnNhdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnRyYW5zZm9ybSguLi5jdXJyZW50LnRleHRNYXRyaXgpOwogICAgICAgICAgICAgICAgICAgICAgICBjdHgudHJhbnNsYXRlKGN1cnJlbnQueCwgY3VycmVudC55KTsKICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnNjYWxlKHRleHRIU2NhbGUsIGZvbnREaXJlY3Rpb24pOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGkgPSAwOyBpIDwgZ2x5cGhzTGVuZ3RoOyArK2kpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdseXBoID0gZ2x5cGhzW2ldOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHR5cGVvZiBnbHlwaCA9PT0gIm51bWJlciIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzcGFjaW5nTGVuZ3RoID0gc3BhY2luZ0RpciAqIGdseXBoICogZm9udFNpemUgLyAxMDAwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4LnRyYW5zbGF0ZShzcGFjaW5nTGVuZ3RoLCAwKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LnggKz0gc3BhY2luZ0xlbmd0aCAqIHRleHRIU2NhbGU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzcGFjaW5nID0gKGdseXBoLmlzU3BhY2UgPyB3b3JkU3BhY2luZyA6IDApICsgY2hhclNwYWNpbmc7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBvcGVyYXRvckxpc3QgPSBmb250LmNoYXJQcm9jT3BlcmF0b3JMaXN0W2dseXBoLm9wZXJhdG9yTGlzdElkXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghb3BlcmF0b3JMaXN0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKGBUeXBlMyBjaGFyYWN0ZXIgIiR7Z2x5cGgub3BlcmF0b3JMaXN0SWR9IiBpcyBub3QgYXZhaWxhYmxlLmApOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuY29udGVudFZpc2libGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnByb2Nlc3NpbmdUeXBlMyA9IGdseXBoOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2F2ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5zY2FsZShmb250U2l6ZSwgZm9udFNpemUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC50cmFuc2Zvcm0oLi4uZm9udE1hdHJpeCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5leGVjdXRlT3BlcmF0b3JMaXN0KG9wZXJhdG9yTGlzdCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5yZXN0b3JlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB0cmFuc2Zvcm1lZCA9IF91dGlsLlV0aWwuYXBwbHlUcmFuc2Zvcm0oW2dseXBoLndpZHRoLCAwXSwgZm9udE1hdHJpeCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3aWR0aCA9IHRyYW5zZm9ybWVkWzBdICogZm9udFNpemUgKyBzcGFjaW5nOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnRyYW5zbGF0ZSh3aWR0aCwgMCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LnggKz0gd2lkdGggKiB0ZXh0SFNjYWxlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5yZXN0b3JlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucHJvY2Vzc2luZ1R5cGUzID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2V0Q2hhcldpZHRoKHhXaWR0aCwgeVdpZHRoKSB7fQogICAgICAgICAgICAgICAgICAgIHNldENoYXJXaWR0aEFuZEJvdW5kcyh4V2lkdGgsIHlXaWR0aCwgbGx4LCBsbHksIHVyeCwgdXJ5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4LnJlY3QobGx4LCBsbHksIHVyeCAtIGxseCwgdXJ5IC0gbGx5KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHguY2xpcCgpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmVuZFBhdGgoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0Q29sb3JOX1BhdHRlcm4oSVIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHBhdHRlcm47CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChJUlswXSA9PT0gIlRpbGluZ1BhdHRlcm4iKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjb2xvciA9IElSWzFdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYmFzZVRyYW5zZm9ybSA9IHRoaXMuYmFzZVRyYW5zZm9ybSB8fCAoMCwgX2Rpc3BsYXlfdXRpbHMuZ2V0Q3VycmVudFRyYW5zZm9ybSkodGhpcy5jdHgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2FudmFzR3JhcGhpY3NGYWN0b3J5ID0gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNyZWF0ZUNhbnZhc0dyYXBoaWNzOiBjdHggPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IENhbnZhc0dyYXBoaWNzKGN0eCwgdGhpcy5jb21tb25PYmpzLCB0aGlzLm9ianMsIHRoaXMuY2FudmFzRmFjdG9yeSwgdGhpcy5maWx0ZXJGYWN0b3J5LCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvcHRpb25hbENvbnRlbnRDb25maWc6IHRoaXMub3B0aW9uYWxDb250ZW50Q29uZmlnLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbWFya2VkQ29udGVudFN0YWNrOiB0aGlzLm1hcmtlZENvbnRlbnRTdGFjawogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGF0dGVybiA9IG5ldyBfcGF0dGVybl9oZWxwZXIuVGlsaW5nUGF0dGVybihJUiwgY29sb3IsIHRoaXMuY3R4LCBjYW52YXNHcmFwaGljc0ZhY3RvcnksIGJhc2VUcmFuc2Zvcm0pOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGF0dGVybiA9IHRoaXMuX2dldFBhdHRlcm4oSVJbMV0sIElSWzJdKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gcGF0dGVybjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2V0U3Ryb2tlQ29sb3JOKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN1cnJlbnQuc3Ryb2tlQ29sb3IgPSB0aGlzLmdldENvbG9yTl9QYXR0ZXJuKGFyZ3VtZW50cyk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNldEZpbGxDb2xvck4oKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC5maWxsQ29sb3IgPSB0aGlzLmdldENvbG9yTl9QYXR0ZXJuKGFyZ3VtZW50cyk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC5wYXR0ZXJuRmlsbCA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNldFN0cm9rZVJHQkNvbG9yKHIsIGcsIGIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY29sb3IgPSBfdXRpbC5VdGlsLm1ha2VIZXhDb2xvcihyLCBnLCBiKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHguc3Ryb2tlU3R5bGUgPSBjb2xvcjsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50LnN0cm9rZUNvbG9yID0gY29sb3I7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNldEZpbGxSR0JDb2xvcihyLCBnLCBiKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNvbG9yID0gX3V0aWwuVXRpbC5tYWtlSGV4Q29sb3IociwgZywgYik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4LmZpbGxTdHlsZSA9IGNvbG9yOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN1cnJlbnQuZmlsbENvbG9yID0gY29sb3I7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC5wYXR0ZXJuRmlsbCA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfZ2V0UGF0dGVybihvYmpJZCkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgbWF0cml4ID0gYXJndW1lbnRzLmxlbmd0aCA+IDEgJiYgYXJndW1lbnRzWzFdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMV0gOiBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgcGF0dGVybjsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuY2FjaGVkUGF0dGVybnMuaGFzKG9iaklkKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGF0dGVybiA9IHRoaXMuY2FjaGVkUGF0dGVybnMuZ2V0KG9iaklkKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhdHRlcm4gPSAoMCwgX3BhdHRlcm5faGVscGVyLmdldFNoYWRpbmdQYXR0ZXJuKSh0aGlzLmdldE9iamVjdChvYmpJZCkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jYWNoZWRQYXR0ZXJucy5zZXQob2JqSWQsIHBhdHRlcm4pOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChtYXRyaXgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhdHRlcm4ubWF0cml4ID0gbWF0cml4OwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBwYXR0ZXJuOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzaGFkaW5nRmlsbChvYmpJZCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuY29udGVudFZpc2libGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjdHggPSB0aGlzLmN0eDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zYXZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHBhdHRlcm4gPSB0aGlzLl9nZXRQYXR0ZXJuKG9iaklkKTsKICAgICAgICAgICAgICAgICAgICAgICAgY3R4LmZpbGxTdHlsZSA9IHBhdHRlcm4uZ2V0UGF0dGVybihjdHgsIHRoaXMsICgwLCBfZGlzcGxheV91dGlscy5nZXRDdXJyZW50VHJhbnNmb3JtSW52ZXJzZSkoY3R4KSwgX3BhdHRlcm5faGVscGVyLlBhdGhUeXBlLlNIQURJTkcpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpbnYgPSAoMCwgX2Rpc3BsYXlfdXRpbHMuZ2V0Q3VycmVudFRyYW5zZm9ybUludmVyc2UpKGN0eCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpbnYpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNhbnZhcyA9IGN0eC5jYW52YXM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB3aWR0aCA9IGNhbnZhcy53aWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGhlaWdodCA9IGNhbnZhcy5oZWlnaHQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBibCA9IF91dGlsLlV0aWwuYXBwbHlUcmFuc2Zvcm0oWzAsIDBdLCBpbnYpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYnIgPSBfdXRpbC5VdGlsLmFwcGx5VHJhbnNmb3JtKFswLCBoZWlnaHRdLCBpbnYpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdWwgPSBfdXRpbC5VdGlsLmFwcGx5VHJhbnNmb3JtKFt3aWR0aCwgMF0sIGludik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB1ciA9IF91dGlsLlV0aWwuYXBwbHlUcmFuc2Zvcm0oW3dpZHRoLCBoZWlnaHRdLCBpbnYpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgeDAgPSBNYXRoLm1pbihibFswXSwgYnJbMF0sIHVsWzBdLCB1clswXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB5MCA9IE1hdGgubWluKGJsWzFdLCBiclsxXSwgdWxbMV0sIHVyWzFdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHgxID0gTWF0aC5tYXgoYmxbMF0sIGJyWzBdLCB1bFswXSwgdXJbMF0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgeTEgPSBNYXRoLm1heChibFsxXSwgYnJbMV0sIHVsWzFdLCB1clsxXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN0eC5maWxsUmVjdCh4MCwgeTAsIHgxIC0geDAsIHkxIC0geTApOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHguZmlsbFJlY3QoLTFlMTAsIC0xZTEwLCAyZTEwLCAyZTEwKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbXBvc2UodGhpcy5jdXJyZW50LmdldENsaXBwZWRQYXRoQm91bmRpbmdCb3goKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucmVzdG9yZSgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBiZWdpbklubGluZUltYWdlKCkgewogICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwudW5yZWFjaGFibGUpKCJTaG91bGQgbm90IGNhbGwgYmVnaW5JbmxpbmVJbWFnZSIpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBiZWdpbkltYWdlRGF0YSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLnVucmVhY2hhYmxlKSgiU2hvdWxkIG5vdCBjYWxsIGJlZ2luSW1hZ2VEYXRhIik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHBhaW50Rm9ybVhPYmplY3RCZWdpbihtYXRyaXgsIGJib3gpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLmNvbnRlbnRWaXNpYmxlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zYXZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYmFzZVRyYW5zZm9ybVN0YWNrLnB1c2godGhpcy5iYXNlVHJhbnNmb3JtKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKEFycmF5LmlzQXJyYXkobWF0cml4KSAmJiBtYXRyaXgubGVuZ3RoID09PSA2KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnRyYW5zZm9ybSguLi5tYXRyaXgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYmFzZVRyYW5zZm9ybSA9ICgwLCBfZGlzcGxheV91dGlscy5nZXRDdXJyZW50VHJhbnNmb3JtKSh0aGlzLmN0eCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChiYm94KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB3aWR0aCA9IGJib3hbMl0gLSBiYm94WzBdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaGVpZ2h0ID0gYmJveFszXSAtIGJib3hbMV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN0eC5yZWN0KGJib3hbMF0sIGJib3hbMV0sIHdpZHRoLCBoZWlnaHQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50LnVwZGF0ZVJlY3RNaW5NYXgoKDAsIF9kaXNwbGF5X3V0aWxzLmdldEN1cnJlbnRUcmFuc2Zvcm0pKHRoaXMuY3R4KSwgYmJveCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNsaXAoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZW5kUGF0aCgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHBhaW50Rm9ybVhPYmplY3RFbmQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5jb250ZW50VmlzaWJsZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucmVzdG9yZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmJhc2VUcmFuc2Zvcm0gPSB0aGlzLmJhc2VUcmFuc2Zvcm1TdGFjay5wb3AoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYmVnaW5Hcm91cChncm91cCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuY29udGVudFZpc2libGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNhdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuaW5TTWFza01vZGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZW5kU01hc2tNb2RlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN1cnJlbnQuYWN0aXZlU01hc2sgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGN1cnJlbnRDdHggPSB0aGlzLmN0eDsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFncm91cC5pc29sYXRlZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLmluZm8pKCJUT0RPOiBTdXBwb3J0IG5vbi1pc29sYXRlZCBncm91cHMuIik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGdyb3VwLmtub2Nrb3V0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoIktub2Nrb3V0IGdyb3VwcyBub3Qgc3VwcG9ydGVkLiIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGN1cnJlbnRUcmFuc2Zvcm0gPSAoMCwgX2Rpc3BsYXlfdXRpbHMuZ2V0Q3VycmVudFRyYW5zZm9ybSkoY3VycmVudEN0eCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChncm91cC5tYXRyaXgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnRDdHgudHJhbnNmb3JtKC4uLmdyb3VwLm1hdHJpeCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFncm91cC5iYm94KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoIkJvdW5kaW5nIGJveCBpcyByZXF1aXJlZC4iKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBsZXQgYm91bmRzID0gX3V0aWwuVXRpbC5nZXRBeGlhbEFsaWduZWRCb3VuZGluZ0JveChncm91cC5iYm94LCAoMCwgX2Rpc3BsYXlfdXRpbHMuZ2V0Q3VycmVudFRyYW5zZm9ybSkoY3VycmVudEN0eCkpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjYW52YXNCb3VuZHMgPSBbMCwgMCwgY3VycmVudEN0eC5jYW52YXMud2lkdGgsIGN1cnJlbnRDdHguY2FudmFzLmhlaWdodF07CiAgICAgICAgICAgICAgICAgICAgICAgIGJvdW5kcyA9IF91dGlsLlV0aWwuaW50ZXJzZWN0KGJvdW5kcywgY2FudmFzQm91bmRzKSB8fCBbMCwgMCwgMCwgMF07CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG9mZnNldFggPSBNYXRoLmZsb29yKGJvdW5kc1swXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG9mZnNldFkgPSBNYXRoLmZsb29yKGJvdW5kc1sxXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBkcmF3bldpZHRoID0gTWF0aC5tYXgoTWF0aC5jZWlsKGJvdW5kc1syXSkgLSBvZmZzZXRYLCAxKTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGRyYXduSGVpZ2h0ID0gTWF0aC5tYXgoTWF0aC5jZWlsKGJvdW5kc1szXSkgLSBvZmZzZXRZLCAxKTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHNjYWxlWCA9IDEsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzY2FsZVkgPSAxOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZHJhd25XaWR0aCA+IE1BWF9HUk9VUF9TSVpFKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzY2FsZVggPSBkcmF3bldpZHRoIC8gTUFYX0dST1VQX1NJWkU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkcmF3bldpZHRoID0gTUFYX0dST1VQX1NJWkU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGRyYXduSGVpZ2h0ID4gTUFYX0dST1VQX1NJWkUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNjYWxlWSA9IGRyYXduSGVpZ2h0IC8gTUFYX0dST1VQX1NJWkU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkcmF3bkhlaWdodCA9IE1BWF9HUk9VUF9TSVpFOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC5zdGFydE5ld1BhdGhBbmRDbGlwQm94KFswLCAwLCBkcmF3bldpZHRoLCBkcmF3bkhlaWdodF0pOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgY2FjaGVJZCA9ICJncm91cEF0IiArIHRoaXMuZ3JvdXBMZXZlbDsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGdyb3VwLnNtYXNrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYWNoZUlkICs9ICJfc21hc2tfIiArIHRoaXMuc21hc2tDb3VudGVyKysgJSAyOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHNjcmF0Y2hDYW52YXMgPSB0aGlzLmNhY2hlZENhbnZhc2VzLmdldENhbnZhcyhjYWNoZUlkLCBkcmF3bldpZHRoLCBkcmF3bkhlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGdyb3VwQ3R4ID0gc2NyYXRjaENhbnZhcy5jb250ZXh0OwogICAgICAgICAgICAgICAgICAgICAgICBncm91cEN0eC5zY2FsZSgxIC8gc2NhbGVYLCAxIC8gc2NhbGVZKTsKICAgICAgICAgICAgICAgICAgICAgICAgZ3JvdXBDdHgudHJhbnNsYXRlKC1vZmZzZXRYLCAtb2Zmc2V0WSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGdyb3VwQ3R4LnRyYW5zZm9ybSguLi5jdXJyZW50VHJhbnNmb3JtKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGdyb3VwLnNtYXNrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNtYXNrU3RhY2sucHVzaCh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FudmFzOiBzY3JhdGNoQ2FudmFzLmNhbnZhcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250ZXh0OiBncm91cEN0eCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvZmZzZXRYLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9mZnNldFksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2NhbGVYLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNjYWxlWSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdWJ0eXBlOiBncm91cC5zbWFzay5zdWJ0eXBlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJhY2tkcm9wOiBncm91cC5zbWFzay5iYWNrZHJvcCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cmFuc2Zlck1hcDogZ3JvdXAuc21hc2sudHJhbnNmZXJNYXAgfHwgbnVsbCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGFydFRyYW5zZm9ybUludmVyc2U6IG51bGwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudEN0eC5zZXRUcmFuc2Zvcm0oMSwgMCwgMCwgMSwgMCwgMCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50Q3R4LnRyYW5zbGF0ZShvZmZzZXRYLCBvZmZzZXRZKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnRDdHguc2NhbGUoc2NhbGVYLCBzY2FsZVkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudEN0eC5zYXZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29weUN0eFN0YXRlKGN1cnJlbnRDdHgsIGdyb3VwQ3R4KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHggPSBncm91cEN0eDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRHU3RhdGUoW1siQk0iLCAic291cmNlLW92ZXIiXSwgWyJjYSIsIDFdLCBbIkNBIiwgMV1dKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5ncm91cFN0YWNrLnB1c2goY3VycmVudEN0eCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZ3JvdXBMZXZlbCsrOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBlbmRHcm91cChncm91cCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuY29udGVudFZpc2libGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmdyb3VwTGV2ZWwtLTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZ3JvdXBDdHggPSB0aGlzLmN0eDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY3R4ID0gdGhpcy5ncm91cFN0YWNrLnBvcCgpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN0eCA9IGN0eDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHguaW1hZ2VTbW9vdGhpbmdFbmFibGVkID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChncm91cC5zbWFzaykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy50ZW1wU01hc2sgPSB0aGlzLnNtYXNrU3RhY2sucG9wKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnJlc3RvcmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4LnJlc3RvcmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGN1cnJlbnRNdHggPSAoMCwgX2Rpc3BsYXlfdXRpbHMuZ2V0Q3VycmVudFRyYW5zZm9ybSkodGhpcy5jdHgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5yZXN0b3JlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN0eC5zYXZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN0eC5zZXRUcmFuc2Zvcm0oLi4uY3VycmVudE10eCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBkaXJ0eUJveCA9IF91dGlsLlV0aWwuZ2V0QXhpYWxBbGlnbmVkQm91bmRpbmdCb3goWzAsIDAsIGdyb3VwQ3R4LmNhbnZhcy53aWR0aCwgZ3JvdXBDdHguY2FudmFzLmhlaWdodF0sIGN1cnJlbnRNdHgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHguZHJhd0ltYWdlKGdyb3VwQ3R4LmNhbnZhcywgMCwgMCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN0eC5yZXN0b3JlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbXBvc2UoZGlydHlCb3gpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGJlZ2luQW5ub3RhdGlvbihpZCwgcmVjdCwgdHJhbnNmb3JtLCBtYXRyaXgsIGhhc093bkNhbnZhcykgewogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9yZXN0b3JlSW5pdGlhbFN0YXRlLCBfcmVzdG9yZUluaXRpYWxTdGF0ZTIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJlc2V0Q3R4VG9EZWZhdWx0KHRoaXMuY3R4KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHguc2F2ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNhdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuYmFzZVRyYW5zZm9ybSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHguc2V0VHJhbnNmb3JtKC4uLnRoaXMuYmFzZVRyYW5zZm9ybSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKEFycmF5LmlzQXJyYXkocmVjdCkgJiYgcmVjdC5sZW5ndGggPT09IDQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHdpZHRoID0gcmVjdFsyXSAtIHJlY3RbMF07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBoZWlnaHQgPSByZWN0WzNdIC0gcmVjdFsxXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChoYXNPd25DYW52YXMgJiYgdGhpcy5hbm5vdGF0aW9uQ2FudmFzTWFwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJhbnNmb3JtID0gdHJhbnNmb3JtLnNsaWNlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJhbnNmb3JtWzRdIC09IHJlY3RbMF07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJhbnNmb3JtWzVdIC09IHJlY3RbMV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVjdCA9IHJlY3Quc2xpY2UoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWN0WzBdID0gcmVjdFsxXSA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVjdFsyXSA9IHdpZHRoOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlY3RbM10gPSBoZWlnaHQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgW3NjYWxlWCwgc2NhbGVZXSA9IF91dGlsLlV0aWwuc2luZ3VsYXJWYWx1ZURlY29tcG9zZTJkU2NhbGUoKDAsIF9kaXNwbGF5X3V0aWxzLmdldEN1cnJlbnRUcmFuc2Zvcm0pKHRoaXMuY3R4KSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2aWV3cG9ydFNjYWxlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSA9IHRoaXM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2FudmFzV2lkdGggPSBNYXRoLmNlaWwod2lkdGggKiB0aGlzLm91dHB1dFNjYWxlWCAqIHZpZXdwb3J0U2NhbGUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNhbnZhc0hlaWdodCA9IE1hdGguY2VpbChoZWlnaHQgKiB0aGlzLm91dHB1dFNjYWxlWSAqIHZpZXdwb3J0U2NhbGUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYW5ub3RhdGlvbkNhbnZhcyA9IHRoaXMuY2FudmFzRmFjdG9yeS5jcmVhdGUoY2FudmFzV2lkdGgsIGNhbnZhc0hlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYW52YXMsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRleHQKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9ID0gdGhpcy5hbm5vdGF0aW9uQ2FudmFzOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYW5ub3RhdGlvbkNhbnZhc01hcC5zZXQoaWQsIGNhbnZhcyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5hbm5vdGF0aW9uQ2FudmFzLnNhdmVkQ3R4ID0gdGhpcy5jdHg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHggPSBjb250ZXh0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4LnNldFRyYW5zZm9ybShzY2FsZVgsIDAsIDAsIC1zY2FsZVksIDAsIGhlaWdodCAqIHNjYWxlWSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVzZXRDdHhUb0RlZmF1bHQodGhpcy5jdHgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXNldEN0eFRvRGVmYXVsdCh0aGlzLmN0eCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHgucmVjdChyZWN0WzBdLCByZWN0WzFdLCB3aWR0aCwgaGVpZ2h0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN0eC5jbGlwKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5lbmRQYXRoKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50ID0gbmV3IENhbnZhc0V4dHJhU3RhdGUodGhpcy5jdHguY2FudmFzLndpZHRoLCB0aGlzLmN0eC5jYW52YXMuaGVpZ2h0KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy50cmFuc2Zvcm0oLi4udHJhbnNmb3JtKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy50cmFuc2Zvcm0oLi4ubWF0cml4KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZW5kQW5ub3RhdGlvbigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuYW5ub3RhdGlvbkNhbnZhcykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHggPSB0aGlzLmFubm90YXRpb25DYW52YXMuc2F2ZWRDdHg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWxldGUgdGhpcy5hbm5vdGF0aW9uQ2FudmFzLnNhdmVkQ3R4OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVsZXRlIHRoaXMuYW5ub3RhdGlvbkNhbnZhczsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBwYWludEltYWdlTWFza1hPYmplY3QoaW1nKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5jb250ZW50VmlzaWJsZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNvdW50ID0gaW1nLmNvdW50OwogICAgICAgICAgICAgICAgICAgICAgICBpbWcgPSB0aGlzLmdldE9iamVjdChpbWcuZGF0YSwgaW1nKTsKICAgICAgICAgICAgICAgICAgICAgICAgaW1nLmNvdW50ID0gY291bnQ7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGN0eCA9IHRoaXMuY3R4OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBnbHlwaCA9IHRoaXMucHJvY2Vzc2luZ1R5cGUzOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZ2x5cGgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChnbHlwaC5jb21waWxlZCA9PT0gdW5kZWZpbmVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZ2x5cGguY29tcGlsZWQgPSBjb21waWxlVHlwZTNHbHlwaChpbWcpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGdseXBoLmNvbXBpbGVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZ2x5cGguY29tcGlsZWQoY3R4KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbWFzayA9IHRoaXMuX2NyZWF0ZU1hc2tDYW52YXMoaW1nKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbWFza0NhbnZhcyA9IG1hc2suY2FudmFzOwogICAgICAgICAgICAgICAgICAgICAgICBjdHguc2F2ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICBjdHguc2V0VHJhbnNmb3JtKDEsIDAsIDAsIDEsIDAsIDApOwogICAgICAgICAgICAgICAgICAgICAgICBjdHguZHJhd0ltYWdlKG1hc2tDYW52YXMsIG1hc2sub2Zmc2V0WCwgbWFzay5vZmZzZXRZKTsKICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnJlc3RvcmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb21wb3NlKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHBhaW50SW1hZ2VNYXNrWE9iamVjdFJlcGVhdChpbWcsIHNjYWxlWCkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgc2tld1ggPSBhcmd1bWVudHMubGVuZ3RoID4gMiAmJiBhcmd1bWVudHNbMl0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1syXSA6IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBza2V3WSA9IGFyZ3VtZW50cy5sZW5ndGggPiAzICYmIGFyZ3VtZW50c1szXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzNdIDogMDsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHNjYWxlWSA9IGFyZ3VtZW50cy5sZW5ndGggPiA0ID8gYXJndW1lbnRzWzRdIDogdW5kZWZpbmVkOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgcG9zaXRpb25zID0gYXJndW1lbnRzLmxlbmd0aCA+IDUgPyBhcmd1bWVudHNbNV0gOiB1bmRlZmluZWQ7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5jb250ZW50VmlzaWJsZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGltZyA9IHRoaXMuZ2V0T2JqZWN0KGltZy5kYXRhLCBpbWcpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjdHggPSB0aGlzLmN0eDsKICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnNhdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY3VycmVudFRyYW5zZm9ybSA9ICgwLCBfZGlzcGxheV91dGlscy5nZXRDdXJyZW50VHJhbnNmb3JtKShjdHgpOwogICAgICAgICAgICAgICAgICAgICAgICBjdHgudHJhbnNmb3JtKHNjYWxlWCwgc2tld1gsIHNrZXdZLCBzY2FsZVksIDAsIDApOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBtYXNrID0gdGhpcy5fY3JlYXRlTWFza0NhbnZhcyhpbWcpOwogICAgICAgICAgICAgICAgICAgICAgICBjdHguc2V0VHJhbnNmb3JtKDEsIDAsIDAsIDEsIG1hc2sub2Zmc2V0WCAtIGN1cnJlbnRUcmFuc2Zvcm1bNF0sIG1hc2sub2Zmc2V0WSAtIGN1cnJlbnRUcmFuc2Zvcm1bNV0pOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMCwgaWkgPSBwb3NpdGlvbnMubGVuZ3RoOyBpIDwgaWk7IGkgKz0gMikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdHJhbnMgPSBfdXRpbC5VdGlsLnRyYW5zZm9ybShjdXJyZW50VHJhbnNmb3JtLCBbc2NhbGVYLCBza2V3WCwgc2tld1ksIHNjYWxlWSwgcG9zaXRpb25zW2ldLCBwb3NpdGlvbnNbaSArIDFdXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBbeCwgeV0gPSBfdXRpbC5VdGlsLmFwcGx5VHJhbnNmb3JtKFswLCAwXSwgdHJhbnMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LmRyYXdJbWFnZShtYXNrLmNhbnZhcywgeCwgeSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnJlc3RvcmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb21wb3NlKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHBhaW50SW1hZ2VNYXNrWE9iamVjdEdyb3VwKGltYWdlcykgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuY29udGVudFZpc2libGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjdHggPSB0aGlzLmN0eDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZmlsbENvbG9yID0gdGhpcy5jdXJyZW50LmZpbGxDb2xvcjsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaXNQYXR0ZXJuRmlsbCA9IHRoaXMuY3VycmVudC5wYXR0ZXJuRmlsbDsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBpbWFnZSBvZiBpbWFnZXMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkYXRhLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdpZHRoLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGhlaWdodCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cmFuc2Zvcm0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBpbWFnZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG1hc2tDYW52YXMgPSB0aGlzLmNhY2hlZENhbnZhc2VzLmdldENhbnZhcygibWFza0NhbnZhcyIsIHdpZHRoLCBoZWlnaHQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbWFza0N0eCA9IG1hc2tDYW52YXMuY29udGV4dDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1hc2tDdHguc2F2ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaW1nID0gdGhpcy5nZXRPYmplY3QoZGF0YSwgaW1hZ2UpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcHV0QmluYXJ5SW1hZ2VNYXNrKG1hc2tDdHgsIGltZyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtYXNrQ3R4Lmdsb2JhbENvbXBvc2l0ZU9wZXJhdGlvbiA9ICJzb3VyY2UtaW4iOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbWFza0N0eC5maWxsU3R5bGUgPSBpc1BhdHRlcm5GaWxsID8gZmlsbENvbG9yLmdldFBhdHRlcm4obWFza0N0eCwgdGhpcywgKDAsIF9kaXNwbGF5X3V0aWxzLmdldEN1cnJlbnRUcmFuc2Zvcm1JbnZlcnNlKShjdHgpLCBfcGF0dGVybl9oZWxwZXIuUGF0aFR5cGUuRklMTCkgOiBmaWxsQ29sb3I7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtYXNrQ3R4LmZpbGxSZWN0KDAsIDAsIHdpZHRoLCBoZWlnaHQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbWFza0N0eC5yZXN0b3JlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHguc2F2ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnRyYW5zZm9ybSguLi50cmFuc2Zvcm0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnNjYWxlKDEsIC0xKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRyYXdJbWFnZUF0SW50ZWdlckNvb3JkcyhjdHgsIG1hc2tDYW52YXMuY2FudmFzLCAwLCAwLCB3aWR0aCwgaGVpZ2h0LCAwLCAtMSwgMSwgMSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHgucmVzdG9yZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29tcG9zZSgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBwYWludEltYWdlWE9iamVjdChvYmpJZCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuY29udGVudFZpc2libGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpbWdEYXRhID0gdGhpcy5nZXRPYmplY3Qob2JqSWQpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWltZ0RhdGEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKSgiRGVwZW5kZW50IGltYWdlIGlzbid0IHJlYWR5IHlldCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGFpbnRJbmxpbmVJbWFnZVhPYmplY3QoaW1nRGF0YSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHBhaW50SW1hZ2VYT2JqZWN0UmVwZWF0KG9iaklkLCBzY2FsZVgsIHNjYWxlWSwgcG9zaXRpb25zKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5jb250ZW50VmlzaWJsZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGltZ0RhdGEgPSB0aGlzLmdldE9iamVjdChvYmpJZCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghaW1nRGF0YSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKCJEZXBlbmRlbnQgaW1hZ2UgaXNuJ3QgcmVhZHkgeWV0Iik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgd2lkdGggPSBpbWdEYXRhLndpZHRoOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBoZWlnaHQgPSBpbWdEYXRhLmhlaWdodDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbWFwID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBpaSA9IHBvc2l0aW9ucy5sZW5ndGg7IGkgPCBpaTsgaSArPSAyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtYXAucHVzaCh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJhbnNmb3JtOiBbc2NhbGVYLCAwLCAwLCBzY2FsZVksIHBvc2l0aW9uc1tpXSwgcG9zaXRpb25zW2kgKyAxXV0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgeDogMCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB5OiAwLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHc6IHdpZHRoLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGg6IGhlaWdodAogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wYWludElubGluZUltYWdlWE9iamVjdEdyb3VwKGltZ0RhdGEsIG1hcCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGFwcGx5VHJhbnNmZXJNYXBzVG9DYW52YXMoY3R4KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmN1cnJlbnQudHJhbnNmZXJNYXBzICE9PSAibm9uZSIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5maWx0ZXIgPSB0aGlzLmN1cnJlbnQudHJhbnNmZXJNYXBzOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LmRyYXdJbWFnZShjdHguY2FudmFzLCAwLCAwKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5maWx0ZXIgPSAibm9uZSI7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGN0eC5jYW52YXM7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGFwcGx5VHJhbnNmZXJNYXBzVG9CaXRtYXAoaW1nRGF0YSkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5jdXJyZW50LnRyYW5zZmVyTWFwcyA9PT0gIm5vbmUiKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gaW1nRGF0YS5iaXRtYXA7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgYml0bWFwLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgd2lkdGgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoZWlnaHQKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IGltZ0RhdGE7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHRtcENhbnZhcyA9IHRoaXMuY2FjaGVkQ2FudmFzZXMuZ2V0Q2FudmFzKCJpbmxpbmVJbWFnZSIsIHdpZHRoLCBoZWlnaHQpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB0bXBDdHggPSB0bXBDYW52YXMuY29udGV4dDsKICAgICAgICAgICAgICAgICAgICAgICAgdG1wQ3R4LmZpbHRlciA9IHRoaXMuY3VycmVudC50cmFuc2Zlck1hcHM7CiAgICAgICAgICAgICAgICAgICAgICAgIHRtcEN0eC5kcmF3SW1hZ2UoYml0bWFwLCAwLCAwKTsKICAgICAgICAgICAgICAgICAgICAgICAgdG1wQ3R4LmZpbHRlciA9ICJub25lIjsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRtcENhbnZhcy5jYW52YXM7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHBhaW50SW5saW5lSW1hZ2VYT2JqZWN0KGltZ0RhdGEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLmNvbnRlbnRWaXNpYmxlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgd2lkdGggPSBpbWdEYXRhLndpZHRoOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBoZWlnaHQgPSBpbWdEYXRhLmhlaWdodDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY3R4ID0gdGhpcy5jdHg7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2F2ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIV9pc19ub2RlLmlzTm9kZUpTKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHguZmlsdGVyID0gIm5vbmUiOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5zY2FsZSgxIC8gd2lkdGgsIC0xIC8gaGVpZ2h0KTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGltZ1RvUGFpbnQ7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpbWdEYXRhLmJpdG1hcCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaW1nVG9QYWludCA9IHRoaXMuYXBwbHlUcmFuc2Zlck1hcHNUb0JpdG1hcChpbWdEYXRhKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmICh0eXBlb2YgSFRNTEVsZW1lbnQgPT09ICJmdW5jdGlvbiIgJiYgaW1nRGF0YSBpbnN0YW5jZW9mIEhUTUxFbGVtZW50IHx8ICFpbWdEYXRhLmRhdGEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGltZ1RvUGFpbnQgPSBpbWdEYXRhOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdG1wQ2FudmFzID0gdGhpcy5jYWNoZWRDYW52YXNlcy5nZXRDYW52YXMoImlubGluZUltYWdlIiwgd2lkdGgsIGhlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB0bXBDdHggPSB0bXBDYW52YXMuY29udGV4dDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHB1dEJpbmFyeUltYWdlRGF0YSh0bXBDdHgsIGltZ0RhdGEpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaW1nVG9QYWludCA9IHRoaXMuYXBwbHlUcmFuc2Zlck1hcHNUb0NhbnZhcyh0bXBDdHgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHNjYWxlZCA9IHRoaXMuX3NjYWxlSW1hZ2UoaW1nVG9QYWludCwgKDAsIF9kaXNwbGF5X3V0aWxzLmdldEN1cnJlbnRUcmFuc2Zvcm1JbnZlcnNlKShjdHgpKTsKICAgICAgICAgICAgICAgICAgICAgICAgY3R4LmltYWdlU21vb3RoaW5nRW5hYmxlZCA9IGdldEltYWdlU21vb3RoaW5nRW5hYmxlZCgoMCwgX2Rpc3BsYXlfdXRpbHMuZ2V0Q3VycmVudFRyYW5zZm9ybSkoY3R4KSwgaW1nRGF0YS5pbnRlcnBvbGF0ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGRyYXdJbWFnZUF0SW50ZWdlckNvb3JkcyhjdHgsIHNjYWxlZC5pbWcsIDAsIDAsIHNjYWxlZC5wYWludFdpZHRoLCBzY2FsZWQucGFpbnRIZWlnaHQsIDAsIC1oZWlnaHQsIHdpZHRoLCBoZWlnaHQpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbXBvc2UoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5yZXN0b3JlKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHBhaW50SW5saW5lSW1hZ2VYT2JqZWN0R3JvdXAoaW1nRGF0YSwgbWFwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5jb250ZW50VmlzaWJsZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGN0eCA9IHRoaXMuY3R4OwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgaW1nVG9QYWludDsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGltZ0RhdGEuYml0bWFwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbWdUb1BhaW50ID0gaW1nRGF0YS5iaXRtYXA7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB3ID0gaW1nRGF0YS53aWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGggPSBpbWdEYXRhLmhlaWdodDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHRtcENhbnZhcyA9IHRoaXMuY2FjaGVkQ2FudmFzZXMuZ2V0Q2FudmFzKCJpbmxpbmVJbWFnZSIsIHcsIGgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdG1wQ3R4ID0gdG1wQ2FudmFzLmNvbnRleHQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwdXRCaW5hcnlJbWFnZURhdGEodG1wQ3R4LCBpbWdEYXRhKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGltZ1RvUGFpbnQgPSB0aGlzLmFwcGx5VHJhbnNmZXJNYXBzVG9DYW52YXModG1wQ3R4KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGVudHJ5IG9mIG1hcCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnNhdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC50cmFuc2Zvcm0oLi4uZW50cnkudHJhbnNmb3JtKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5zY2FsZSgxLCAtMSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkcmF3SW1hZ2VBdEludGVnZXJDb29yZHMoY3R4LCBpbWdUb1BhaW50LCBlbnRyeS54LCBlbnRyeS55LCBlbnRyeS53LCBlbnRyeS5oLCAwLCAtMSwgMSwgMSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHgucmVzdG9yZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29tcG9zZSgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBwYWludFNvbGlkQ29sb3JJbWFnZU1hc2soKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5jb250ZW50VmlzaWJsZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4LmZpbGxSZWN0KDAsIDAsIDEsIDEpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbXBvc2UoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgbWFya1BvaW50KHRhZykge30KICAgICAgICAgICAgICAgICAgICBtYXJrUG9pbnRQcm9wcyh0YWcsIHByb3BlcnRpZXMpIHt9CiAgICAgICAgICAgICAgICAgICAgYmVnaW5NYXJrZWRDb250ZW50KHRhZykgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm1hcmtlZENvbnRlbnRTdGFjay5wdXNoKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZpc2libGU6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGJlZ2luTWFya2VkQ29udGVudFByb3BzKHRhZywgcHJvcGVydGllcykgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGFnID09PSAiT0MiKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm1hcmtlZENvbnRlbnRTdGFjay5wdXNoKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2aXNpYmxlOiB0aGlzLm9wdGlvbmFsQ29udGVudENvbmZpZy5pc1Zpc2libGUocHJvcGVydGllcykKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5tYXJrZWRDb250ZW50U3RhY2sucHVzaCh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmlzaWJsZTogdHJ1ZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb250ZW50VmlzaWJsZSA9IHRoaXMuaXNDb250ZW50VmlzaWJsZSgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBlbmRNYXJrZWRDb250ZW50KCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm1hcmtlZENvbnRlbnRTdGFjay5wb3AoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb250ZW50VmlzaWJsZSA9IHRoaXMuaXNDb250ZW50VmlzaWJsZSgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBiZWdpbkNvbXBhdCgpIHt9CiAgICAgICAgICAgICAgICAgICAgZW5kQ29tcGF0KCkge30KICAgICAgICAgICAgICAgICAgICBjb25zdW1lUGF0aChjbGlwQm94KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGlzRW1wdHkgPSB0aGlzLmN1cnJlbnQuaXNFbXB0eUNsaXAoKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMucGVuZGluZ0NsaXApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC51cGRhdGVDbGlwRnJvbVBhdGgoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMucGVuZGluZ0NsaXApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29tcG9zZShjbGlwQm94KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjdHggPSB0aGlzLmN0eDsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMucGVuZGluZ0NsaXApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghaXNFbXB0eSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLnBlbmRpbmdDbGlwID09PSBFT19DTElQKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5jbGlwKCJldmVub2RkIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LmNsaXAoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBlbmRpbmdDbGlwID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN1cnJlbnQuc3RhcnROZXdQYXRoQW5kQ2xpcEJveCh0aGlzLmN1cnJlbnQuY2xpcEJveCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5iZWdpblBhdGgoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0U2luZ2xlUGl4ZWxXaWR0aCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLl9jYWNoZWRHZXRTaW5nbGVQaXhlbFdpZHRoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBtID0gKDAsIF9kaXNwbGF5X3V0aWxzLmdldEN1cnJlbnRUcmFuc2Zvcm0pKHRoaXMuY3R4KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChtWzFdID09PSAwICYmIG1bMl0gPT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jYWNoZWRHZXRTaW5nbGVQaXhlbFdpZHRoID0gMSAvIE1hdGgubWluKE1hdGguYWJzKG1bMF0pLCBNYXRoLmFicyhtWzNdKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGFic0RldCA9IE1hdGguYWJzKG1bMF0gKiBtWzNdIC0gbVsyXSAqIG1bMV0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG5vcm1YID0gTWF0aC5oeXBvdChtWzBdLCBtWzJdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBub3JtWSA9IE1hdGguaHlwb3QobVsxXSwgbVszXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fY2FjaGVkR2V0U2luZ2xlUGl4ZWxXaWR0aCA9IE1hdGgubWF4KG5vcm1YLCBub3JtWSkgLyBhYnNEZXQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX2NhY2hlZEdldFNpbmdsZVBpeGVsV2lkdGg7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldFNjYWxlRm9yU3Ryb2tpbmcoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5fY2FjaGVkU2NhbGVGb3JTdHJva2luZykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxpbmVXaWR0aAogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSA9IHRoaXMuY3VycmVudDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG0gPSAoMCwgX2Rpc3BsYXlfdXRpbHMuZ2V0Q3VycmVudFRyYW5zZm9ybSkodGhpcy5jdHgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHNjYWxlWCwgc2NhbGVZOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG1bMV0gPT09IDAgJiYgbVsyXSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG5vcm1YID0gTWF0aC5hYnMobVswXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgbm9ybVkgPSBNYXRoLmFicyhtWzNdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAobGluZVdpZHRoID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNjYWxlWCA9IDEgLyBub3JtWDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2NhbGVZID0gMSAvIG5vcm1ZOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHNjYWxlZFhMaW5lV2lkdGggPSBub3JtWCAqIGxpbmVXaWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2NhbGVkWUxpbmVXaWR0aCA9IG5vcm1ZICogbGluZVdpZHRoOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzY2FsZVggPSBzY2FsZWRYTGluZVdpZHRoIDwgMSA/IDEgLyBzY2FsZWRYTGluZVdpZHRoIDogMTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2NhbGVZID0gc2NhbGVkWUxpbmVXaWR0aCA8IDEgPyAxIC8gc2NhbGVkWUxpbmVXaWR0aCA6IDE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBhYnNEZXQgPSBNYXRoLmFicyhtWzBdICogbVszXSAtIG1bMl0gKiBtWzFdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBub3JtWCA9IE1hdGguaHlwb3QobVswXSwgbVsxXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgbm9ybVkgPSBNYXRoLmh5cG90KG1bMl0sIG1bM10pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChsaW5lV2lkdGggPT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2NhbGVYID0gbm9ybVkgLyBhYnNEZXQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNjYWxlWSA9IG5vcm1YIC8gYWJzRGV0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGJhc2VBcmVhID0gbGluZVdpZHRoICogYWJzRGV0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzY2FsZVggPSBub3JtWSA+IGJhc2VBcmVhID8gbm9ybVkgLyBiYXNlQXJlYSA6IDE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNjYWxlWSA9IG5vcm1YID4gYmFzZUFyZWEgPyBub3JtWCAvIGJhc2VBcmVhIDogMTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jYWNoZWRTY2FsZUZvclN0cm9raW5nID0gW3NjYWxlWCwgc2NhbGVZXTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fY2FjaGVkU2NhbGVGb3JTdHJva2luZzsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmVzY2FsZUFuZFN0cm9rZShzYXZlUmVzdG9yZSkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHgKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IHRoaXM7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxpbmVXaWR0aAogICAgICAgICAgICAgICAgICAgICAgICB9ID0gdGhpcy5jdXJyZW50OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBbc2NhbGVYLCBzY2FsZVldID0gdGhpcy5nZXRTY2FsZUZvclN0cm9raW5nKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5saW5lV2lkdGggPSBsaW5lV2lkdGggfHwgMTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHNjYWxlWCA9PT0gMSAmJiBzY2FsZVkgPT09IDEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5zdHJva2UoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBsZXQgc2F2ZWRNYXRyaXgsIHNhdmVkRGFzaGVzLCBzYXZlZERhc2hPZmZzZXQ7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChzYXZlUmVzdG9yZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgc2F2ZWRNYXRyaXggPSAoMCwgX2Rpc3BsYXlfdXRpbHMuZ2V0Q3VycmVudFRyYW5zZm9ybSkoY3R4KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNhdmVkRGFzaGVzID0gY3R4LmdldExpbmVEYXNoKCkuc2xpY2UoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNhdmVkRGFzaE9mZnNldCA9IGN0eC5saW5lRGFzaE9mZnNldDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjdHguc2NhbGUoc2NhbGVYLCBzY2FsZVkpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzY2FsZSA9IE1hdGgubWF4KHNjYWxlWCwgc2NhbGVZKTsKICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnNldExpbmVEYXNoKGN0eC5nZXRMaW5lRGFzaCgpLm1hcCh4ID0+IHggLyBzY2FsZSkpOwogICAgICAgICAgICAgICAgICAgICAgICBjdHgubGluZURhc2hPZmZzZXQgLz0gc2NhbGU7CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5zdHJva2UoKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHNhdmVSZXN0b3JlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHguc2V0VHJhbnNmb3JtKC4uLnNhdmVkTWF0cml4KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5zZXRMaW5lRGFzaChzYXZlZERhc2hlcyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHgubGluZURhc2hPZmZzZXQgPSBzYXZlZERhc2hPZmZzZXQ7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaXNDb250ZW50VmlzaWJsZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgaSA9IHRoaXMubWFya2VkQ29udGVudFN0YWNrLmxlbmd0aCAtIDE7IGkgPj0gMDsgaS0tKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMubWFya2VkQ29udGVudFN0YWNrW2ldLnZpc2libGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5DYW52YXNHcmFwaGljcyA9IENhbnZhc0dyYXBoaWNzOwogICAgICAgICAgICAgICAgZnVuY3Rpb24gX3Jlc3RvcmVJbml0aWFsU3RhdGUyKCkgewogICAgICAgICAgICAgICAgICAgIHdoaWxlICh0aGlzLnN0YXRlU3RhY2subGVuZ3RoIHx8IHRoaXMuaW5TTWFza01vZGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5yZXN0b3JlKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4LnJlc3RvcmUoKTsKICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy50cmFuc3BhcmVudENhbnZhcykgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN0eCA9IHRoaXMuY29tcG9zaXRlQ3R4OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN0eC5zYXZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4LnNldFRyYW5zZm9ybSgxLCAwLCAwLCAxLCAwLCAwKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHguZHJhd0ltYWdlKHRoaXMudHJhbnNwYXJlbnRDYW52YXMsIDAsIDApOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN0eC5yZXN0b3JlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudHJhbnNwYXJlbnRDYW52YXMgPSBudWxsOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZvciAoY29uc3Qgb3AgaW4gX3V0aWwuT1BTKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKENhbnZhc0dyYXBoaWNzLnByb3RvdHlwZVtvcF0gIT09IHVuZGVmaW5lZCkgewogICAgICAgICAgICAgICAgICAgICAgICBDYW52YXNHcmFwaGljcy5wcm90b3R5cGVbX3V0aWwuT1BTW29wXV0gPSBDYW52YXNHcmFwaGljcy5wcm90b3R5cGVbb3BdOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTQ3ICovCiAgICAgICAgICAgIC8qKiovICgoX191bnVzZWRfd2VicGFja19tb2R1bGUsIGV4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICAidXNlIHN0cmljdCI7CgoKICAgICAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAiX19lc01vZHVsZSIsICh7CiAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRydWUKICAgICAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuVGlsaW5nUGF0dGVybiA9IGV4cG9ydHMuUGF0aFR5cGUgPSB2b2lkIDA7CiAgICAgICAgICAgICAgICBleHBvcnRzLmdldFNoYWRpbmdQYXR0ZXJuID0gZ2V0U2hhZGluZ1BhdHRlcm47CiAgICAgICAgICAgICAgICB2YXIgX3V0aWwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEpOwogICAgICAgICAgICAgICAgdmFyIF9kaXNwbGF5X3V0aWxzID0gX193X3BkZmpzX3JlcXVpcmVfXygxNDIpOwogICAgICAgICAgICAgICAgY29uc3QgUGF0aFR5cGUgPSB7CiAgICAgICAgICAgICAgICAgICAgRklMTDogIkZpbGwiLAogICAgICAgICAgICAgICAgICAgIFNUUk9LRTogIlN0cm9rZSIsCiAgICAgICAgICAgICAgICAgICAgU0hBRElORzogIlNoYWRpbmciCiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgZXhwb3J0cy5QYXRoVHlwZSA9IFBhdGhUeXBlOwogICAgICAgICAgICAgICAgZnVuY3Rpb24gYXBwbHlCb3VuZGluZ0JveChjdHgsIGJib3gpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoIWJib3gpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjb25zdCB3aWR0aCA9IGJib3hbMl0gLSBiYm94WzBdOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IGhlaWdodCA9IGJib3hbM10gLSBiYm94WzFdOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHJlZ2lvbiA9IG5ldyBQYXRoMkQoKTsKICAgICAgICAgICAgICAgICAgICByZWdpb24ucmVjdChiYm94WzBdLCBiYm94WzFdLCB3aWR0aCwgaGVpZ2h0KTsKICAgICAgICAgICAgICAgICAgICBjdHguY2xpcChyZWdpb24pOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY2xhc3MgQmFzZVNoYWRpbmdQYXR0ZXJuIHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuY29uc3RydWN0b3IgPT09IEJhc2VTaGFkaW5nUGF0dGVybikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLnVucmVhY2hhYmxlKSgiQ2Fubm90IGluaXRpYWxpemUgQmFzZVNoYWRpbmdQYXR0ZXJuLiIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldFBhdHRlcm4oKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC51bnJlYWNoYWJsZSkoIkFic3RyYWN0IG1ldGhvZCBgZ2V0UGF0dGVybmAgY2FsbGVkLiIpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNsYXNzIFJhZGlhbEF4aWFsU2hhZGluZ1BhdHRlcm4gZXh0ZW5kcyBCYXNlU2hhZGluZ1BhdHRlcm4gewogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKElSKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHN1cGVyKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3R5cGUgPSBJUlsxXTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fYmJveCA9IElSWzJdOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jb2xvclN0b3BzID0gSVJbM107CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3AwID0gSVJbNF07CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3AxID0gSVJbNV07CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3IwID0gSVJbNl07CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3IxID0gSVJbN107CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubWF0cml4ID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX2NyZWF0ZUdyYWRpZW50KGN0eCkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgZ3JhZDsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuX3R5cGUgPT09ICJheGlhbCIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdyYWQgPSBjdHguY3JlYXRlTGluZWFyR3JhZGllbnQodGhpcy5fcDBbMF0sIHRoaXMuX3AwWzFdLCB0aGlzLl9wMVswXSwgdGhpcy5fcDFbMV0pOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHRoaXMuX3R5cGUgPT09ICJyYWRpYWwiKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBncmFkID0gY3R4LmNyZWF0ZVJhZGlhbEdyYWRpZW50KHRoaXMuX3AwWzBdLCB0aGlzLl9wMFsxXSwgdGhpcy5fcjAsIHRoaXMuX3AxWzBdLCB0aGlzLl9wMVsxXSwgdGhpcy5fcjEpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgY29sb3JTdG9wIG9mIHRoaXMuX2NvbG9yU3RvcHMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdyYWQuYWRkQ29sb3JTdG9wKGNvbG9yU3RvcFswXSwgY29sb3JTdG9wWzFdKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZ3JhZDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0UGF0dGVybihjdHgsIG93bmVyLCBpbnZlcnNlLCBwYXRoVHlwZSkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgcGF0dGVybjsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHBhdGhUeXBlID09PSBQYXRoVHlwZS5TVFJPS0UgfHwgcGF0aFR5cGUgPT09IFBhdGhUeXBlLkZJTEwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG93bmVyQkJveCA9IG93bmVyLmN1cnJlbnQuZ2V0Q2xpcHBlZFBhdGhCb3VuZGluZ0JveChwYXRoVHlwZSwgKDAsIF9kaXNwbGF5X3V0aWxzLmdldEN1cnJlbnRUcmFuc2Zvcm0pKGN0eCkpIHx8IFswLCAwLCAwLCAwXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHdpZHRoID0gTWF0aC5jZWlsKG93bmVyQkJveFsyXSAtIG93bmVyQkJveFswXSkgfHwgMTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGhlaWdodCA9IE1hdGguY2VpbChvd25lckJCb3hbM10gLSBvd25lckJCb3hbMV0pIHx8IDE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB0bXBDYW52YXMgPSBvd25lci5jYWNoZWRDYW52YXNlcy5nZXRDYW52YXMoInBhdHRlcm4iLCB3aWR0aCwgaGVpZ2h0LCB0cnVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHRtcEN0eCA9IHRtcENhbnZhcy5jb250ZXh0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdG1wQ3R4LmNsZWFyUmVjdCgwLCAwLCB0bXBDdHguY2FudmFzLndpZHRoLCB0bXBDdHguY2FudmFzLmhlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0bXBDdHguYmVnaW5QYXRoKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0bXBDdHgucmVjdCgwLCAwLCB0bXBDdHguY2FudmFzLndpZHRoLCB0bXBDdHguY2FudmFzLmhlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0bXBDdHgudHJhbnNsYXRlKC1vd25lckJCb3hbMF0sIC1vd25lckJCb3hbMV0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaW52ZXJzZSA9IF91dGlsLlV0aWwudHJhbnNmb3JtKGludmVyc2UsIFsxLCAwLCAwLCAxLCBvd25lckJCb3hbMF0sIG93bmVyQkJveFsxXV0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdG1wQ3R4LnRyYW5zZm9ybSguLi5vd25lci5iYXNlVHJhbnNmb3JtKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLm1hdHJpeCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRtcEN0eC50cmFuc2Zvcm0oLi4udGhpcy5tYXRyaXgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgYXBwbHlCb3VuZGluZ0JveCh0bXBDdHgsIHRoaXMuX2Jib3gpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdG1wQ3R4LmZpbGxTdHlsZSA9IHRoaXMuX2NyZWF0ZUdyYWRpZW50KHRtcEN0eCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0bXBDdHguZmlsbCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGF0dGVybiA9IGN0eC5jcmVhdGVQYXR0ZXJuKHRtcENhbnZhcy5jYW52YXMsICJuby1yZXBlYXQiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGRvbU1hdHJpeCA9IG5ldyBET01NYXRyaXgoaW52ZXJzZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYXR0ZXJuLnNldFRyYW5zZm9ybShkb21NYXRyaXgpOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgYXBwbHlCb3VuZGluZ0JveChjdHgsIHRoaXMuX2Jib3gpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGF0dGVybiA9IHRoaXMuX2NyZWF0ZUdyYWRpZW50KGN0eCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHBhdHRlcm47CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gZHJhd1RyaWFuZ2xlKGRhdGEsIGNvbnRleHQsIHAxLCBwMiwgcDMsIGMxLCBjMiwgYzMpIHsKICAgICAgICAgICAgICAgICAgICBjb25zdCBjb29yZHMgPSBjb250ZXh0LmNvb3JkcywKICAgICAgICAgICAgICAgICAgICAgICAgY29sb3JzID0gY29udGV4dC5jb2xvcnM7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgYnl0ZXMgPSBkYXRhLmRhdGEsCiAgICAgICAgICAgICAgICAgICAgICAgIHJvd1NpemUgPSBkYXRhLndpZHRoICogNDsKICAgICAgICAgICAgICAgICAgICBsZXQgdG1wOwogICAgICAgICAgICAgICAgICAgIGlmIChjb29yZHNbcDEgKyAxXSA+IGNvb3Jkc1twMiArIDFdKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRtcCA9IHAxOwogICAgICAgICAgICAgICAgICAgICAgICBwMSA9IHAyOwogICAgICAgICAgICAgICAgICAgICAgICBwMiA9IHRtcDsKICAgICAgICAgICAgICAgICAgICAgICAgdG1wID0gYzE7CiAgICAgICAgICAgICAgICAgICAgICAgIGMxID0gYzI7CiAgICAgICAgICAgICAgICAgICAgICAgIGMyID0gdG1wOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBpZiAoY29vcmRzW3AyICsgMV0gPiBjb29yZHNbcDMgKyAxXSkgewogICAgICAgICAgICAgICAgICAgICAgICB0bXAgPSBwMjsKICAgICAgICAgICAgICAgICAgICAgICAgcDIgPSBwMzsKICAgICAgICAgICAgICAgICAgICAgICAgcDMgPSB0bXA7CiAgICAgICAgICAgICAgICAgICAgICAgIHRtcCA9IGMyOwogICAgICAgICAgICAgICAgICAgICAgICBjMiA9IGMzOwogICAgICAgICAgICAgICAgICAgICAgICBjMyA9IHRtcDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaWYgKGNvb3Jkc1twMSArIDFdID4gY29vcmRzW3AyICsgMV0pIHsKICAgICAgICAgICAgICAgICAgICAgICAgdG1wID0gcDE7CiAgICAgICAgICAgICAgICAgICAgICAgIHAxID0gcDI7CiAgICAgICAgICAgICAgICAgICAgICAgIHAyID0gdG1wOwogICAgICAgICAgICAgICAgICAgICAgICB0bXAgPSBjMTsKICAgICAgICAgICAgICAgICAgICAgICAgYzEgPSBjMjsKICAgICAgICAgICAgICAgICAgICAgICAgYzIgPSB0bXA7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNvbnN0IHgxID0gKGNvb3Jkc1twMV0gKyBjb250ZXh0Lm9mZnNldFgpICogY29udGV4dC5zY2FsZVg7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgeTEgPSAoY29vcmRzW3AxICsgMV0gKyBjb250ZXh0Lm9mZnNldFkpICogY29udGV4dC5zY2FsZVk7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgeDIgPSAoY29vcmRzW3AyXSArIGNvbnRleHQub2Zmc2V0WCkgKiBjb250ZXh0LnNjYWxlWDsKICAgICAgICAgICAgICAgICAgICBjb25zdCB5MiA9IChjb29yZHNbcDIgKyAxXSArIGNvbnRleHQub2Zmc2V0WSkgKiBjb250ZXh0LnNjYWxlWTsKICAgICAgICAgICAgICAgICAgICBjb25zdCB4MyA9IChjb29yZHNbcDNdICsgY29udGV4dC5vZmZzZXRYKSAqIGNvbnRleHQuc2NhbGVYOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHkzID0gKGNvb3Jkc1twMyArIDFdICsgY29udGV4dC5vZmZzZXRZKSAqIGNvbnRleHQuc2NhbGVZOwogICAgICAgICAgICAgICAgICAgIGlmICh5MSA+PSB5MykgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNvbnN0IGMxciA9IGNvbG9yc1tjMV0sCiAgICAgICAgICAgICAgICAgICAgICAgIGMxZyA9IGNvbG9yc1tjMSArIDFdLAogICAgICAgICAgICAgICAgICAgICAgICBjMWIgPSBjb2xvcnNbYzEgKyAyXTsKICAgICAgICAgICAgICAgICAgICBjb25zdCBjMnIgPSBjb2xvcnNbYzJdLAogICAgICAgICAgICAgICAgICAgICAgICBjMmcgPSBjb2xvcnNbYzIgKyAxXSwKICAgICAgICAgICAgICAgICAgICAgICAgYzJiID0gY29sb3JzW2MyICsgMl07CiAgICAgICAgICAgICAgICAgICAgY29uc3QgYzNyID0gY29sb3JzW2MzXSwKICAgICAgICAgICAgICAgICAgICAgICAgYzNnID0gY29sb3JzW2MzICsgMV0sCiAgICAgICAgICAgICAgICAgICAgICAgIGMzYiA9IGNvbG9yc1tjMyArIDJdOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IG1pblkgPSBNYXRoLnJvdW5kKHkxKSwKICAgICAgICAgICAgICAgICAgICAgICAgbWF4WSA9IE1hdGgucm91bmQoeTMpOwogICAgICAgICAgICAgICAgICAgIGxldCB4YSwgY2FyLCBjYWcsIGNhYjsKICAgICAgICAgICAgICAgICAgICBsZXQgeGIsIGNiciwgY2JnLCBjYmI7CiAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgeSA9IG1pblk7IHkgPD0gbWF4WTsgeSsrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh5IDwgeTIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHkgPCB5MSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGsgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBrID0gKHkxIC0geSkgLyAoeTEgLSB5Mik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB4YSA9IHgxIC0gKHgxIC0geDIpICogazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhciA9IGMxciAtIChjMXIgLSBjMnIpICogazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhZyA9IGMxZyAtIChjMWcgLSBjMmcpICogazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhYiA9IGMxYiAtIChjMWIgLSBjMmIpICogazsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHkgPiB5MykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGsgPSAxOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmICh5MiA9PT0geTMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBrID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgayA9ICh5MiAtIHkpIC8gKHkyIC0geTMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgeGEgPSB4MiAtICh4MiAtIHgzKSAqIGs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXIgPSBjMnIgLSAoYzJyIC0gYzNyKSAqIGs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYWcgPSBjMmcgLSAoYzJnIC0gYzNnKSAqIGs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYWIgPSBjMmIgLSAoYzJiIC0gYzNiKSAqIGs7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGs7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh5IDwgeTEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGsgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHkgPiB5MykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgayA9IDE7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBrID0gKHkxIC0geSkgLyAoeTEgLSB5Myk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgeGIgPSB4MSAtICh4MSAtIHgzKSAqIGs7CiAgICAgICAgICAgICAgICAgICAgICAgIGNiciA9IGMxciAtIChjMXIgLSBjM3IpICogazsKICAgICAgICAgICAgICAgICAgICAgICAgY2JnID0gYzFnIC0gKGMxZyAtIGMzZykgKiBrOwogICAgICAgICAgICAgICAgICAgICAgICBjYmIgPSBjMWIgLSAoYzFiIC0gYzNiKSAqIGs7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHgxXyA9IE1hdGgucm91bmQoTWF0aC5taW4oeGEsIHhiKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHgyXyA9IE1hdGgucm91bmQoTWF0aC5tYXgoeGEsIHhiKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBqID0gcm93U2l6ZSAqIHkgKyB4MV8gKiA0OwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCB4ID0geDFfOyB4IDw9IHgyXzsgeCsrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBrID0gKHhhIC0geCkgLyAoeGEgLSB4Yik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoayA8IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBrID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoayA+IDEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBrID0gMTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJ5dGVzW2orK10gPSBjYXIgLSAoY2FyIC0gY2JyKSAqIGsgfCAwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgYnl0ZXNbaisrXSA9IGNhZyAtIChjYWcgLSBjYmcpICogayB8IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBieXRlc1tqKytdID0gY2FiIC0gKGNhYiAtIGNiYikgKiBrIHwgMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJ5dGVzW2orK10gPSAyNTU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBkcmF3RmlndXJlKGRhdGEsIGZpZ3VyZSwgY29udGV4dCkgewogICAgICAgICAgICAgICAgICAgIGNvbnN0IHBzID0gZmlndXJlLmNvb3JkczsKICAgICAgICAgICAgICAgICAgICBjb25zdCBjcyA9IGZpZ3VyZS5jb2xvcnM7CiAgICAgICAgICAgICAgICAgICAgbGV0IGksIGlpOwogICAgICAgICAgICAgICAgICAgIHN3aXRjaCAoZmlndXJlLnR5cGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAibGF0dGljZSI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB2ZXJ0aWNlc1BlclJvdyA9IGZpZ3VyZS52ZXJ0aWNlc1BlclJvdzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHJvd3MgPSBNYXRoLmZsb29yKHBzLmxlbmd0aCAvIHZlcnRpY2VzUGVyUm93KSAtIDE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjb2xzID0gdmVydGljZXNQZXJSb3cgLSAxOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChpID0gMDsgaSA8IHJvd3M7IGkrKykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBxID0gaSAqIHZlcnRpY2VzUGVyUm93OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGogPSAwOyBqIDwgY29sczsgaisrLCBxKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZHJhd1RyaWFuZ2xlKGRhdGEsIGNvbnRleHQsIHBzW3FdLCBwc1txICsgMV0sIHBzW3EgKyB2ZXJ0aWNlc1BlclJvd10sIGNzW3FdLCBjc1txICsgMV0sIGNzW3EgKyB2ZXJ0aWNlc1BlclJvd10pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkcmF3VHJpYW5nbGUoZGF0YSwgY29udGV4dCwgcHNbcSArIHZlcnRpY2VzUGVyUm93ICsgMV0sIHBzW3EgKyAxXSwgcHNbcSArIHZlcnRpY2VzUGVyUm93XSwgY3NbcSArIHZlcnRpY2VzUGVyUm93ICsgMV0sIGNzW3EgKyAxXSwgY3NbcSArIHZlcnRpY2VzUGVyUm93XSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgInRyaWFuZ2xlcyI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGkgPSAwLCBpaSA9IHBzLmxlbmd0aDsgaSA8IGlpOyBpICs9IDMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkcmF3VHJpYW5nbGUoZGF0YSwgY29udGV4dCwgcHNbaV0sIHBzW2kgKyAxXSwgcHNbaSArIDJdLCBjc1tpXSwgY3NbaSArIDFdLCBjc1tpICsgMl0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoImlsbGVnYWwgZmlndXJlIik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY2xhc3MgTWVzaFNoYWRpbmdQYXR0ZXJuIGV4dGVuZHMgQmFzZVNoYWRpbmdQYXR0ZXJuIHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcihJUikgewogICAgICAgICAgICAgICAgICAgICAgICBzdXBlcigpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jb29yZHMgPSBJUlsyXTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fY29sb3JzID0gSVJbM107CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2ZpZ3VyZXMgPSBJUls0XTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fYm91bmRzID0gSVJbNV07CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Jib3ggPSBJUls3XTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fYmFja2dyb3VuZCA9IElSWzhdOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm1hdHJpeCA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9jcmVhdGVNZXNoQ2FudmFzKGNvbWJpbmVkU2NhbGUsIGJhY2tncm91bmRDb2xvciwgY2FjaGVkQ2FudmFzZXMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgRVhQRUNURURfU0NBTEUgPSAxLjE7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IE1BWF9QQVRURVJOX1NJWkUgPSAzMDAwOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBCT1JERVJfU0laRSA9IDI7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG9mZnNldFggPSBNYXRoLmZsb29yKHRoaXMuX2JvdW5kc1swXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG9mZnNldFkgPSBNYXRoLmZsb29yKHRoaXMuX2JvdW5kc1sxXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGJvdW5kc1dpZHRoID0gTWF0aC5jZWlsKHRoaXMuX2JvdW5kc1syXSkgLSBvZmZzZXRYOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBib3VuZHNIZWlnaHQgPSBNYXRoLmNlaWwodGhpcy5fYm91bmRzWzNdKSAtIG9mZnNldFk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHdpZHRoID0gTWF0aC5taW4oTWF0aC5jZWlsKE1hdGguYWJzKGJvdW5kc1dpZHRoICogY29tYmluZWRTY2FsZVswXSAqIEVYUEVDVEVEX1NDQUxFKSksIE1BWF9QQVRURVJOX1NJWkUpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBoZWlnaHQgPSBNYXRoLm1pbihNYXRoLmNlaWwoTWF0aC5hYnMoYm91bmRzSGVpZ2h0ICogY29tYmluZWRTY2FsZVsxXSAqIEVYUEVDVEVEX1NDQUxFKSksIE1BWF9QQVRURVJOX1NJWkUpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzY2FsZVggPSBib3VuZHNXaWR0aCAvIHdpZHRoOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzY2FsZVkgPSBib3VuZHNIZWlnaHQgLyBoZWlnaHQ7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNvbnRleHQgPSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb29yZHM6IHRoaXMuX2Nvb3JkcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbG9yczogdGhpcy5fY29sb3JzLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgb2Zmc2V0WDogLW9mZnNldFgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvZmZzZXRZOiAtb2Zmc2V0WSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNjYWxlWDogMSAvIHNjYWxlWCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNjYWxlWTogMSAvIHNjYWxlWQogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwYWRkZWRXaWR0aCA9IHdpZHRoICsgQk9SREVSX1NJWkUgKiAyOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwYWRkZWRIZWlnaHQgPSBoZWlnaHQgKyBCT1JERVJfU0laRSAqIDI7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHRtcENhbnZhcyA9IGNhY2hlZENhbnZhc2VzLmdldENhbnZhcygibWVzaCIsIHBhZGRlZFdpZHRoLCBwYWRkZWRIZWlnaHQsIGZhbHNlKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdG1wQ3R4ID0gdG1wQ2FudmFzLmNvbnRleHQ7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGRhdGEgPSB0bXBDdHguY3JlYXRlSW1hZ2VEYXRhKHdpZHRoLCBoZWlnaHQpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoYmFja2dyb3VuZENvbG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBieXRlcyA9IGRhdGEuZGF0YTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBpaSA9IGJ5dGVzLmxlbmd0aDsgaSA8IGlpOyBpICs9IDQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBieXRlc1tpXSA9IGJhY2tncm91bmRDb2xvclswXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBieXRlc1tpICsgMV0gPSBiYWNrZ3JvdW5kQ29sb3JbMV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnl0ZXNbaSArIDJdID0gYmFja2dyb3VuZENvbG9yWzJdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJ5dGVzW2kgKyAzXSA9IDI1NTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGZpZ3VyZSBvZiB0aGlzLl9maWd1cmVzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkcmF3RmlndXJlKGRhdGEsIGZpZ3VyZSwgY29udGV4dCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdG1wQ3R4LnB1dEltYWdlRGF0YShkYXRhLCBCT1JERVJfU0laRSwgQk9SREVSX1NJWkUpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjYW52YXMgPSB0bXBDYW52YXMuY2FudmFzOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FudmFzLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgb2Zmc2V0WDogb2Zmc2V0WCAtIEJPUkRFUl9TSVpFICogc2NhbGVYLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgb2Zmc2V0WTogb2Zmc2V0WSAtIEJPUkRFUl9TSVpFICogc2NhbGVZLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgc2NhbGVYLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgc2NhbGVZCiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldFBhdHRlcm4oY3R4LCBvd25lciwgaW52ZXJzZSwgcGF0aFR5cGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgYXBwbHlCb3VuZGluZ0JveChjdHgsIHRoaXMuX2Jib3gpOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgc2NhbGU7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChwYXRoVHlwZSA9PT0gUGF0aFR5cGUuU0hBRElORykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgc2NhbGUgPSBfdXRpbC5VdGlsLnNpbmd1bGFyVmFsdWVEZWNvbXBvc2UyZFNjYWxlKCgwLCBfZGlzcGxheV91dGlscy5nZXRDdXJyZW50VHJhbnNmb3JtKShjdHgpKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNjYWxlID0gX3V0aWwuVXRpbC5zaW5ndWxhclZhbHVlRGVjb21wb3NlMmRTY2FsZShvd25lci5iYXNlVHJhbnNmb3JtKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLm1hdHJpeCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG1hdHJpeFNjYWxlID0gX3V0aWwuVXRpbC5zaW5ndWxhclZhbHVlRGVjb21wb3NlMmRTY2FsZSh0aGlzLm1hdHJpeCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2NhbGUgPSBbc2NhbGVbMF0gKiBtYXRyaXhTY2FsZVswXSwgc2NhbGVbMV0gKiBtYXRyaXhTY2FsZVsxXV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdGVtcG9yYXJ5UGF0dGVybkNhbnZhcyA9IHRoaXMuX2NyZWF0ZU1lc2hDYW52YXMoc2NhbGUsIHBhdGhUeXBlID09PSBQYXRoVHlwZS5TSEFESU5HID8gbnVsbCA6IHRoaXMuX2JhY2tncm91bmQsIG93bmVyLmNhY2hlZENhbnZhc2VzKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHBhdGhUeXBlICE9PSBQYXRoVHlwZS5TSEFESU5HKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHguc2V0VHJhbnNmb3JtKC4uLm93bmVyLmJhc2VUcmFuc2Zvcm0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMubWF0cml4KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnRyYW5zZm9ybSguLi50aGlzLm1hdHJpeCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnRyYW5zbGF0ZSh0ZW1wb3JhcnlQYXR0ZXJuQ2FudmFzLm9mZnNldFgsIHRlbXBvcmFyeVBhdHRlcm5DYW52YXMub2Zmc2V0WSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5zY2FsZSh0ZW1wb3JhcnlQYXR0ZXJuQ2FudmFzLnNjYWxlWCwgdGVtcG9yYXJ5UGF0dGVybkNhbnZhcy5zY2FsZVkpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gY3R4LmNyZWF0ZVBhdHRlcm4odGVtcG9yYXJ5UGF0dGVybkNhbnZhcy5jYW52YXMsICJuby1yZXBlYXQiKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBEdW1teVNoYWRpbmdQYXR0ZXJuIGV4dGVuZHMgQmFzZVNoYWRpbmdQYXR0ZXJuIHsKICAgICAgICAgICAgICAgICAgICBnZXRQYXR0ZXJuKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gImhvdHBpbmsiOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGdldFNoYWRpbmdQYXR0ZXJuKElSKSB7CiAgICAgICAgICAgICAgICAgICAgc3dpdGNoIChJUlswXSkgewogICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJSYWRpYWxBeGlhbCI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IFJhZGlhbEF4aWFsU2hhZGluZ1BhdHRlcm4oSVIpOwogICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJNZXNoIjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgTWVzaFNoYWRpbmdQYXR0ZXJuKElSKTsKICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiRHVtbXkiOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG5ldyBEdW1teVNoYWRpbmdQYXR0ZXJuKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcihgVW5rbm93biBJUiB0eXBlOiAke0lSWzBdfWApOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY29uc3QgUGFpbnRUeXBlID0gewogICAgICAgICAgICAgICAgICAgIENPTE9SRUQ6IDEsCiAgICAgICAgICAgICAgICAgICAgVU5DT0xPUkVEOiAyCiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgY2xhc3MgVGlsaW5nUGF0dGVybiB7CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIGdldCBNQVhfUEFUVEVSTl9TSVpFKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gKDAsIF91dGlsLnNoYWRvdykodGhpcywgIk1BWF9QQVRURVJOX1NJWkUiLCAzMDAwKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IoSVIsIGNvbG9yLCBjdHgsIGNhbnZhc0dyYXBoaWNzRmFjdG9yeSwgYmFzZVRyYW5zZm9ybSkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm9wZXJhdG9yTGlzdCA9IElSWzJdOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm1hdHJpeCA9IElSWzNdIHx8IFsxLCAwLCAwLCAxLCAwLCAwXTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5iYm94ID0gSVJbNF07CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMueHN0ZXAgPSBJUls1XTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy55c3RlcCA9IElSWzZdOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBhaW50VHlwZSA9IElSWzddOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnRpbGluZ1R5cGUgPSBJUls4XTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb2xvciA9IGNvbG9yOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN0eCA9IGN0eDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jYW52YXNHcmFwaGljc0ZhY3RvcnkgPSBjYW52YXNHcmFwaGljc0ZhY3Rvcnk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYmFzZVRyYW5zZm9ybSA9IGJhc2VUcmFuc2Zvcm07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNyZWF0ZVBhdHRlcm5DYW52YXMob3duZXIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgb3BlcmF0b3JMaXN0ID0gdGhpcy5vcGVyYXRvckxpc3Q7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGJib3ggPSB0aGlzLmJib3g7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHhzdGVwID0gdGhpcy54c3RlcDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgeXN0ZXAgPSB0aGlzLnlzdGVwOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwYWludFR5cGUgPSB0aGlzLnBhaW50VHlwZTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdGlsaW5nVHlwZSA9IHRoaXMudGlsaW5nVHlwZTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY29sb3IgPSB0aGlzLmNvbG9yOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjYW52YXNHcmFwaGljc0ZhY3RvcnkgPSB0aGlzLmNhbnZhc0dyYXBoaWNzRmFjdG9yeTsKICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLmluZm8pKCJUaWxpbmdUeXBlOiAiICsgdGlsaW5nVHlwZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHgwID0gYmJveFswXSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHkwID0gYmJveFsxXSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHgxID0gYmJveFsyXSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHkxID0gYmJveFszXTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbWF0cml4U2NhbGUgPSBfdXRpbC5VdGlsLnNpbmd1bGFyVmFsdWVEZWNvbXBvc2UyZFNjYWxlKHRoaXMubWF0cml4KTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY3VyTWF0cml4U2NhbGUgPSBfdXRpbC5VdGlsLnNpbmd1bGFyVmFsdWVEZWNvbXBvc2UyZFNjYWxlKHRoaXMuYmFzZVRyYW5zZm9ybSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNvbWJpbmVkU2NhbGUgPSBbbWF0cml4U2NhbGVbMF0gKiBjdXJNYXRyaXhTY2FsZVswXSwgbWF0cml4U2NhbGVbMV0gKiBjdXJNYXRyaXhTY2FsZVsxXV07CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGRpbXggPSB0aGlzLmdldFNpemVBbmRTY2FsZSh4c3RlcCwgdGhpcy5jdHguY2FudmFzLndpZHRoLCBjb21iaW5lZFNjYWxlWzBdKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZGlteSA9IHRoaXMuZ2V0U2l6ZUFuZFNjYWxlKHlzdGVwLCB0aGlzLmN0eC5jYW52YXMuaGVpZ2h0LCBjb21iaW5lZFNjYWxlWzFdKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdG1wQ2FudmFzID0gb3duZXIuY2FjaGVkQ2FudmFzZXMuZ2V0Q2FudmFzKCJwYXR0ZXJuIiwgZGlteC5zaXplLCBkaW15LnNpemUsIHRydWUpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB0bXBDdHggPSB0bXBDYW52YXMuY29udGV4dDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZ3JhcGhpY3MgPSBjYW52YXNHcmFwaGljc0ZhY3RvcnkuY3JlYXRlQ2FudmFzR3JhcGhpY3ModG1wQ3R4KTsKICAgICAgICAgICAgICAgICAgICAgICAgZ3JhcGhpY3MuZ3JvdXBMZXZlbCA9IG93bmVyLmdyb3VwTGV2ZWw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0RmlsbEFuZFN0cm9rZVN0eWxlVG9Db250ZXh0KGdyYXBoaWNzLCBwYWludFR5cGUsIGNvbG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGFkanVzdGVkWDAgPSB4MDsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGFkanVzdGVkWTAgPSB5MDsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGFkanVzdGVkWDEgPSB4MTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGFkanVzdGVkWTEgPSB5MTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHgwIDwgMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgYWRqdXN0ZWRYMCA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhZGp1c3RlZFgxICs9IE1hdGguYWJzKHgwKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAoeTAgPCAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhZGp1c3RlZFkwID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFkanVzdGVkWTEgKz0gTWF0aC5hYnMoeTApOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRtcEN0eC50cmFuc2xhdGUoLShkaW14LnNjYWxlICogYWRqdXN0ZWRYMCksIC0oZGlteS5zY2FsZSAqIGFkanVzdGVkWTApKTsKICAgICAgICAgICAgICAgICAgICAgICAgZ3JhcGhpY3MudHJhbnNmb3JtKGRpbXguc2NhbGUsIDAsIDAsIGRpbXkuc2NhbGUsIDAsIDApOwogICAgICAgICAgICAgICAgICAgICAgICB0bXBDdHguc2F2ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNsaXBCYm94KGdyYXBoaWNzLCBhZGp1c3RlZFgwLCBhZGp1c3RlZFkwLCBhZGp1c3RlZFgxLCBhZGp1c3RlZFkxKTsKICAgICAgICAgICAgICAgICAgICAgICAgZ3JhcGhpY3MuYmFzZVRyYW5zZm9ybSA9ICgwLCBfZGlzcGxheV91dGlscy5nZXRDdXJyZW50VHJhbnNmb3JtKShncmFwaGljcy5jdHgpOwogICAgICAgICAgICAgICAgICAgICAgICBncmFwaGljcy5leGVjdXRlT3BlcmF0b3JMaXN0KG9wZXJhdG9yTGlzdCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGdyYXBoaWNzLmVuZERyYXdpbmcoKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhbnZhczogdG1wQ2FudmFzLmNhbnZhcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNjYWxlWDogZGlteC5zY2FsZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNjYWxlWTogZGlteS5zY2FsZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9mZnNldFg6IGFkanVzdGVkWDAsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvZmZzZXRZOiBhZGp1c3RlZFkwCiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldFNpemVBbmRTY2FsZShzdGVwLCByZWFsT3V0cHV0U2l6ZSwgc2NhbGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3RlcCA9IE1hdGguYWJzKHN0ZXApOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBtYXhTaXplID0gTWF0aC5tYXgoVGlsaW5nUGF0dGVybi5NQVhfUEFUVEVSTl9TSVpFLCByZWFsT3V0cHV0U2l6ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBzaXplID0gTWF0aC5jZWlsKHN0ZXAgKiBzY2FsZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChzaXplID49IG1heFNpemUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNpemUgPSBtYXhTaXplOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgc2NhbGUgPSBzaXplIC8gc3RlcDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgc2NhbGUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzaXplCiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNsaXBCYm94KGdyYXBoaWNzLCB4MCwgeTAsIHgxLCB5MSkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBiYm94V2lkdGggPSB4MSAtIHgwOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBiYm94SGVpZ2h0ID0geTEgLSB5MDsKICAgICAgICAgICAgICAgICAgICAgICAgZ3JhcGhpY3MuY3R4LnJlY3QoeDAsIHkwLCBiYm94V2lkdGgsIGJib3hIZWlnaHQpOwogICAgICAgICAgICAgICAgICAgICAgICBncmFwaGljcy5jdXJyZW50LnVwZGF0ZVJlY3RNaW5NYXgoKDAsIF9kaXNwbGF5X3V0aWxzLmdldEN1cnJlbnRUcmFuc2Zvcm0pKGdyYXBoaWNzLmN0eCksIFt4MCwgeTAsIHgxLCB5MV0pOwogICAgICAgICAgICAgICAgICAgICAgICBncmFwaGljcy5jbGlwKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGdyYXBoaWNzLmVuZFBhdGgoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2V0RmlsbEFuZFN0cm9rZVN0eWxlVG9Db250ZXh0KGdyYXBoaWNzLCBwYWludFR5cGUsIGNvbG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNvbnRleHQgPSBncmFwaGljcy5jdHgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50ID0gZ3JhcGhpY3MuY3VycmVudDsKICAgICAgICAgICAgICAgICAgICAgICAgc3dpdGNoIChwYWludFR5cGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgUGFpbnRUeXBlLkNPTE9SRUQ6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY3R4ID0gdGhpcy5jdHg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGV4dC5maWxsU3R5bGUgPSBjdHguZmlsbFN0eWxlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRleHQuc3Ryb2tlU3R5bGUgPSBjdHguc3Ryb2tlU3R5bGU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC5maWxsQ29sb3IgPSBjdHguZmlsbFN0eWxlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQuc3Ryb2tlQ29sb3IgPSBjdHguc3Ryb2tlU3R5bGU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIFBhaW50VHlwZS5VTkNPTE9SRUQ6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY3NzQ29sb3IgPSBfdXRpbC5VdGlsLm1ha2VIZXhDb2xvcihjb2xvclswXSwgY29sb3JbMV0sIGNvbG9yWzJdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250ZXh0LmZpbGxTdHlsZSA9IGNzc0NvbG9yOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRleHQuc3Ryb2tlU3R5bGUgPSBjc3NDb2xvcjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LmZpbGxDb2xvciA9IGNzc0NvbG9yOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQuc3Ryb2tlQ29sb3IgPSBjc3NDb2xvcjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKGBVbnN1cHBvcnRlZCBwYWludCB0eXBlOiAke3BhaW50VHlwZX1gKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRQYXR0ZXJuKGN0eCwgb3duZXIsIGludmVyc2UsIHBhdGhUeXBlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBtYXRyaXggPSBpbnZlcnNlOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAocGF0aFR5cGUgIT09IFBhdGhUeXBlLlNIQURJTkcpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1hdHJpeCA9IF91dGlsLlV0aWwudHJhbnNmb3JtKG1hdHJpeCwgb3duZXIuYmFzZVRyYW5zZm9ybSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5tYXRyaXgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtYXRyaXggPSBfdXRpbC5VdGlsLnRyYW5zZm9ybShtYXRyaXgsIHRoaXMubWF0cml4KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB0ZW1wb3JhcnlQYXR0ZXJuQ2FudmFzID0gdGhpcy5jcmVhdGVQYXR0ZXJuQ2FudmFzKG93bmVyKTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGRvbU1hdHJpeCA9IG5ldyBET01NYXRyaXgobWF0cml4KTsKICAgICAgICAgICAgICAgICAgICAgICAgZG9tTWF0cml4ID0gZG9tTWF0cml4LnRyYW5zbGF0ZSh0ZW1wb3JhcnlQYXR0ZXJuQ2FudmFzLm9mZnNldFgsIHRlbXBvcmFyeVBhdHRlcm5DYW52YXMub2Zmc2V0WSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGRvbU1hdHJpeCA9IGRvbU1hdHJpeC5zY2FsZSgxIC8gdGVtcG9yYXJ5UGF0dGVybkNhbnZhcy5zY2FsZVgsIDEgLyB0ZW1wb3JhcnlQYXR0ZXJuQ2FudmFzLnNjYWxlWSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHBhdHRlcm4gPSBjdHguY3JlYXRlUGF0dGVybih0ZW1wb3JhcnlQYXR0ZXJuQ2FudmFzLmNhbnZhcywgInJlcGVhdCIpOwogICAgICAgICAgICAgICAgICAgICAgICBwYXR0ZXJuLnNldFRyYW5zZm9ybShkb21NYXRyaXgpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gcGF0dGVybjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLlRpbGluZ1BhdHRlcm4gPSBUaWxpbmdQYXR0ZXJuOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxNDggKi8KICAgICAgICAgICAgLyoqKi8gKChfX3VudXNlZF93ZWJwYWNrX21vZHVsZSwgZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgICJ1c2Ugc3RyaWN0IjsKCgogICAgICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJfX2VzTW9kdWxlIiwgKHsKICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdHJ1ZQogICAgICAgICAgICAgICAgfSkpOwogICAgICAgICAgICAgICAgZXhwb3J0cy5jb252ZXJ0QmxhY2tBbmRXaGl0ZVRvUkdCQSA9IGNvbnZlcnRCbGFja0FuZFdoaXRlVG9SR0JBOwogICAgICAgICAgICAgICAgZXhwb3J0cy5jb252ZXJ0VG9SR0JBID0gY29udmVydFRvUkdCQTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuZ3JheVRvUkdCQSA9IGdyYXlUb1JHQkE7CiAgICAgICAgICAgICAgICB2YXIgX3V0aWwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEpOwogICAgICAgICAgICAgICAgZnVuY3Rpb24gY29udmVydFRvUkdCQShwYXJhbXMpIHsKICAgICAgICAgICAgICAgICAgICBzd2l0Y2ggKHBhcmFtcy5raW5kKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuSW1hZ2VLaW5kLkdSQVlTQ0FMRV8xQlBQOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGNvbnZlcnRCbGFja0FuZFdoaXRlVG9SR0JBKHBhcmFtcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuSW1hZ2VLaW5kLlJHQl8yNEJQUDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBjb252ZXJ0UkdCVG9SR0JBKHBhcmFtcyk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gY29udmVydEJsYWNrQW5kV2hpdGVUb1JHQkEoX3JlZikgewogICAgICAgICAgICAgICAgICAgIGxldCB7CiAgICAgICAgICAgICAgICAgICAgICAgIHNyYywKICAgICAgICAgICAgICAgICAgICAgICAgc3JjUG9zID0gMCwKICAgICAgICAgICAgICAgICAgICAgICAgZGVzdCwKICAgICAgICAgICAgICAgICAgICAgICAgd2lkdGgsCiAgICAgICAgICAgICAgICAgICAgICAgIGhlaWdodCwKICAgICAgICAgICAgICAgICAgICAgICAgbm9uQmxhY2tDb2xvciA9IDB4ZmZmZmZmZmYsCiAgICAgICAgICAgICAgICAgICAgICAgIGludmVyc2VEZWNvZGUgPSBmYWxzZQogICAgICAgICAgICAgICAgICAgIH0gPSBfcmVmOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IGJsYWNrID0gX3V0aWwuRmVhdHVyZVRlc3QuaXNMaXR0bGVFbmRpYW4gPyAweGZmMDAwMDAwIDogMHgwMDAwMDBmZjsKICAgICAgICAgICAgICAgICAgICBjb25zdCBbemVyb01hcHBpbmcsIG9uZU1hcHBpbmddID0gaW52ZXJzZURlY29kZSA/IFtub25CbGFja0NvbG9yLCBibGFja10gOiBbYmxhY2ssIG5vbkJsYWNrQ29sb3JdOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHdpZHRoSW5Tb3VyY2UgPSB3aWR0aCA+PiAzOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHdpZHRoUmVtYWluZGVyID0gd2lkdGggJiA3OwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHNyY0xlbmd0aCA9IHNyYy5sZW5ndGg7CiAgICAgICAgICAgICAgICAgICAgZGVzdCA9IG5ldyBVaW50MzJBcnJheShkZXN0LmJ1ZmZlcik7CiAgICAgICAgICAgICAgICAgICAgbGV0IGRlc3RQb3MgPSAwOwogICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgaGVpZ2h0OyBpKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBtYXggPSBzcmNQb3MgKyB3aWR0aEluU291cmNlOyBzcmNQb3MgPCBtYXg7IHNyY1BvcysrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBlbGVtID0gc3JjUG9zIDwgc3JjTGVuZ3RoID8gc3JjW3NyY1Bvc10gOiAyNTU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXN0W2Rlc3RQb3MrK10gPSBlbGVtICYgMGIxMDAwMDAwMCA/IG9uZU1hcHBpbmcgOiB6ZXJvTWFwcGluZzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlc3RbZGVzdFBvcysrXSA9IGVsZW0gJiAwYjEwMDAwMDAgPyBvbmVNYXBwaW5nIDogemVyb01hcHBpbmc7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXN0W2Rlc3RQb3MrK10gPSBlbGVtICYgMGIxMDAwMDAgPyBvbmVNYXBwaW5nIDogemVyb01hcHBpbmc7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXN0W2Rlc3RQb3MrK10gPSBlbGVtICYgMGIxMDAwMCA/IG9uZU1hcHBpbmcgOiB6ZXJvTWFwcGluZzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlc3RbZGVzdFBvcysrXSA9IGVsZW0gJiAwYjEwMDAgPyBvbmVNYXBwaW5nIDogemVyb01hcHBpbmc7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXN0W2Rlc3RQb3MrK10gPSBlbGVtICYgMGIxMDAgPyBvbmVNYXBwaW5nIDogemVyb01hcHBpbmc7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXN0W2Rlc3RQb3MrK10gPSBlbGVtICYgMGIxMCA/IG9uZU1hcHBpbmcgOiB6ZXJvTWFwcGluZzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlc3RbZGVzdFBvcysrXSA9IGVsZW0gJiAwYjEgPyBvbmVNYXBwaW5nIDogemVyb01hcHBpbmc7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHdpZHRoUmVtYWluZGVyID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBlbGVtID0gc3JjUG9zIDwgc3JjTGVuZ3RoID8gc3JjW3NyY1BvcysrXSA6IDI1NTsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgaiA9IDA7IGogPCB3aWR0aFJlbWFpbmRlcjsgaisrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXN0W2Rlc3RQb3MrK10gPSBlbGVtICYgMSA8PCA3IC0gaiA/IG9uZU1hcHBpbmcgOiB6ZXJvTWFwcGluZzsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICAgICAgICAgICAgICBzcmNQb3MsCiAgICAgICAgICAgICAgICAgICAgICAgIGRlc3RQb3MKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gY29udmVydFJHQlRvUkdCQShfcmVmMikgewogICAgICAgICAgICAgICAgICAgIGxldCB7CiAgICAgICAgICAgICAgICAgICAgICAgIHNyYywKICAgICAgICAgICAgICAgICAgICAgICAgc3JjUG9zID0gMCwKICAgICAgICAgICAgICAgICAgICAgICAgZGVzdCwKICAgICAgICAgICAgICAgICAgICAgICAgZGVzdFBvcyA9IDAsCiAgICAgICAgICAgICAgICAgICAgICAgIHdpZHRoLAogICAgICAgICAgICAgICAgICAgICAgICBoZWlnaHQKICAgICAgICAgICAgICAgICAgICB9ID0gX3JlZjI7CiAgICAgICAgICAgICAgICAgICAgbGV0IGkgPSAwOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IGxlbjMyID0gc3JjLmxlbmd0aCA+PiAyOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHNyYzMyID0gbmV3IFVpbnQzMkFycmF5KHNyYy5idWZmZXIsIHNyY1BvcywgbGVuMzIpOwogICAgICAgICAgICAgICAgICAgIGlmIChfdXRpbC5GZWF0dXJlVGVzdC5pc0xpdHRsZUVuZGlhbikgewogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKDsgaSA8IGxlbjMyIC0gMjsgaSArPSAzLCBkZXN0UG9zICs9IDQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHMxID0gc3JjMzJbaV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzMiA9IHNyYzMyW2kgKyAxXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHMzID0gc3JjMzJbaSArIDJdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVzdFtkZXN0UG9zXSA9IHMxIHwgMHhmZjAwMDAwMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlc3RbZGVzdFBvcyArIDFdID0gczEgPj4+IDI0IHwgczIgPDwgOCB8IDB4ZmYwMDAwMDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXN0W2Rlc3RQb3MgKyAyXSA9IHMyID4+PiAxNiB8IHMzIDw8IDE2IHwgMHhmZjAwMDAwMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlc3RbZGVzdFBvcyArIDNdID0gczMgPj4+IDggfCAweGZmMDAwMDAwOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGogPSBpICogNCwgamogPSBzcmMubGVuZ3RoOyBqIDwgamo7IGogKz0gMykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVzdFtkZXN0UG9zKytdID0gc3JjW2pdIHwgc3JjW2ogKyAxXSA8PCA4IHwgc3JjW2ogKyAyXSA8PCAxNiB8IDB4ZmYwMDAwMDA7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKDsgaSA8IGxlbjMyIC0gMjsgaSArPSAzLCBkZXN0UG9zICs9IDQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHMxID0gc3JjMzJbaV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzMiA9IHNyYzMyW2kgKyAxXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHMzID0gc3JjMzJbaSArIDJdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVzdFtkZXN0UG9zXSA9IHMxIHwgMHhmZjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlc3RbZGVzdFBvcyArIDFdID0gczEgPDwgMjQgfCBzMiA+Pj4gOCB8IDB4ZmY7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXN0W2Rlc3RQb3MgKyAyXSA9IHMyIDw8IDE2IHwgczMgPj4+IDE2IHwgMHhmZjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlc3RbZGVzdFBvcyArIDNdID0gczMgPDwgOCB8IDB4ZmY7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgaiA9IGkgKiA0LCBqaiA9IHNyYy5sZW5ndGg7IGogPCBqajsgaiArPSAzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXN0W2Rlc3RQb3MrK10gPSBzcmNbal0gPDwgMjQgfCBzcmNbaiArIDFdIDw8IDE2IHwgc3JjW2ogKyAyXSA8PCA4IHwgMHhmZjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICAgICAgICAgICAgICBzcmNQb3MsCiAgICAgICAgICAgICAgICAgICAgICAgIGRlc3RQb3MKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gZ3JheVRvUkdCQShzcmMsIGRlc3QpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoX3V0aWwuRmVhdHVyZVRlc3QuaXNMaXR0bGVFbmRpYW4pIHsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgaSA9IDAsIGlpID0gc3JjLmxlbmd0aDsgaSA8IGlpOyBpKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlc3RbaV0gPSBzcmNbaV0gKiAweDEwMTAxIHwgMHhmZjAwMDAwMDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBpaSA9IHNyYy5sZW5ndGg7IGkgPCBpaTsgaSsrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXN0W2ldID0gc3JjW2ldICogMHgxMDEwMTAwIHwgMHgwMDAwMDBmZjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTQ5ICovCiAgICAgICAgICAgIC8qKiovICgoX191bnVzZWRfd2VicGFja19tb2R1bGUsIGV4cG9ydHMpID0+IHsKCiAgICAgICAgICAgICAgICAidXNlIHN0cmljdCI7CgoKICAgICAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAiX19lc01vZHVsZSIsICh7CiAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRydWUKICAgICAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuR2xvYmFsV29ya2VyT3B0aW9ucyA9IHZvaWQgMDsKICAgICAgICAgICAgICAgIGNvbnN0IEdsb2JhbFdvcmtlck9wdGlvbnMgPSBPYmplY3QuY3JlYXRlKG51bGwpOwogICAgICAgICAgICAgICAgZXhwb3J0cy5HbG9iYWxXb3JrZXJPcHRpb25zID0gR2xvYmFsV29ya2VyT3B0aW9uczsKICAgICAgICAgICAgICAgIEdsb2JhbFdvcmtlck9wdGlvbnMud29ya2VyUG9ydCA9IG51bGw7CiAgICAgICAgICAgICAgICBHbG9iYWxXb3JrZXJPcHRpb25zLndvcmtlclNyYyA9ICIiOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxNTAgKi8KICAgICAgICAgICAgLyoqKi8gKChfX3VudXNlZF93ZWJwYWNrX21vZHVsZSwgZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgICJ1c2Ugc3RyaWN0IjsKCgogICAgICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJfX2VzTW9kdWxlIiwgKHsKICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdHJ1ZQogICAgICAgICAgICAgICAgfSkpOwogICAgICAgICAgICAgICAgZXhwb3J0cy5NZXNzYWdlSGFuZGxlciA9IHZvaWQgMDsKICAgICAgICAgICAgICAgIHZhciBfdXRpbCA9IF9fd19wZGZqc19yZXF1aXJlX18oMSk7CiAgICAgICAgICAgICAgICBjb25zdCBDYWxsYmFja0tpbmQgPSB7CiAgICAgICAgICAgICAgICAgICAgVU5LTk9XTjogMCwKICAgICAgICAgICAgICAgICAgICBEQVRBOiAxLAogICAgICAgICAgICAgICAgICAgIEVSUk9SOiAyCiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgY29uc3QgU3RyZWFtS2luZCA9IHsKICAgICAgICAgICAgICAgICAgICBVTktOT1dOOiAwLAogICAgICAgICAgICAgICAgICAgIENBTkNFTDogMSwKICAgICAgICAgICAgICAgICAgICBDQU5DRUxfQ09NUExFVEU6IDIsCiAgICAgICAgICAgICAgICAgICAgQ0xPU0U6IDMsCiAgICAgICAgICAgICAgICAgICAgRU5RVUVVRTogNCwKICAgICAgICAgICAgICAgICAgICBFUlJPUjogNSwKICAgICAgICAgICAgICAgICAgICBQVUxMOiA2LAogICAgICAgICAgICAgICAgICAgIFBVTExfQ09NUExFVEU6IDcsCiAgICAgICAgICAgICAgICAgICAgU1RBUlRfQ09NUExFVEU6IDgKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBmdW5jdGlvbiB3cmFwUmVhc29uKHJlYXNvbikgewogICAgICAgICAgICAgICAgICAgIGlmICghKHJlYXNvbiBpbnN0YW5jZW9mIEVycm9yIHx8IHR5cGVvZiByZWFzb24gPT09ICJvYmplY3QiICYmIHJlYXNvbiAhPT0gbnVsbCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLnVucmVhY2hhYmxlKSgnd3JhcFJlYXNvbjogRXhwZWN0ZWQgInJlYXNvbiIgdG8gYmUgYSAocG9zc2libHkgY2xvbmVkKSBFcnJvci4nKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3dpdGNoIChyZWFzb24ubmFtZSkgewogICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJBYm9ydEV4Y2VwdGlvbiI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IF91dGlsLkFib3J0RXhjZXB0aW9uKHJlYXNvbi5tZXNzYWdlKTsKICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiTWlzc2luZ1BERkV4Y2VwdGlvbiI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IF91dGlsLk1pc3NpbmdQREZFeGNlcHRpb24ocmVhc29uLm1lc3NhZ2UpOwogICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJQYXNzd29yZEV4Y2VwdGlvbiI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IF91dGlsLlBhc3N3b3JkRXhjZXB0aW9uKHJlYXNvbi5tZXNzYWdlLCByZWFzb24uY29kZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgIlVuZXhwZWN0ZWRSZXNwb25zZUV4Y2VwdGlvbiI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IF91dGlsLlVuZXhwZWN0ZWRSZXNwb25zZUV4Y2VwdGlvbihyZWFzb24ubWVzc2FnZSwgcmVhc29uLnN0YXR1cyk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgIlVua25vd25FcnJvckV4Y2VwdGlvbiI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IF91dGlsLlVua25vd25FcnJvckV4Y2VwdGlvbihyZWFzb24ubWVzc2FnZSwgcmVhc29uLmRldGFpbHMpOwogICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG5ldyBfdXRpbC5Vbmtub3duRXJyb3JFeGNlcHRpb24ocmVhc29uLm1lc3NhZ2UsIHJlYXNvbi50b1N0cmluZygpKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBNZXNzYWdlSGFuZGxlciB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3Ioc291cmNlTmFtZSwgdGFyZ2V0TmFtZSwgY29tT2JqKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc291cmNlTmFtZSA9IHNvdXJjZU5hbWU7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudGFyZ2V0TmFtZSA9IHRhcmdldE5hbWU7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29tT2JqID0gY29tT2JqOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbGxiYWNrSWQgPSAxOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnN0cmVhbUlkID0gMTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zdHJlYW1TaW5rcyA9IE9iamVjdC5jcmVhdGUobnVsbCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc3RyZWFtQ29udHJvbGxlcnMgPSBPYmplY3QuY3JlYXRlKG51bGwpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbGxiYWNrQ2FwYWJpbGl0aWVzID0gT2JqZWN0LmNyZWF0ZShudWxsKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5hY3Rpb25IYW5kbGVyID0gT2JqZWN0LmNyZWF0ZShudWxsKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fb25Db21PYmpPbk1lc3NhZ2UgPSBldmVudCA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBkYXRhID0gZXZlbnQuZGF0YTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChkYXRhLnRhcmdldE5hbWUgIT09IHRoaXMuc291cmNlTmFtZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChkYXRhLnN0cmVhbSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3Byb2Nlc3NTdHJlYW1NZXNzYWdlKGRhdGEpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChkYXRhLmNhbGxiYWNrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2FsbGJhY2tJZCA9IGRhdGEuY2FsbGJhY2tJZDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjYXBhYmlsaXR5ID0gdGhpcy5jYWxsYmFja0NhcGFiaWxpdGllc1tjYWxsYmFja0lkXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWNhcGFiaWxpdHkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKGBDYW5ub3QgcmVzb2x2ZSBjYWxsYmFjayAke2NhbGxiYWNrSWR9YCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlbGV0ZSB0aGlzLmNhbGxiYWNrQ2FwYWJpbGl0aWVzW2NhbGxiYWNrSWRdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChkYXRhLmNhbGxiYWNrID09PSBDYWxsYmFja0tpbmQuREFUQSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXBhYmlsaXR5LnJlc29sdmUoZGF0YS5kYXRhKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGRhdGEuY2FsbGJhY2sgPT09IENhbGxiYWNrS2luZC5FUlJPUikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXBhYmlsaXR5LnJlamVjdCh3cmFwUmVhc29uKGRhdGEucmVhc29uKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCJVbmV4cGVjdGVkIGNhbGxiYWNrIGNhc2UiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYWN0aW9uID0gdGhpcy5hY3Rpb25IYW5kbGVyW2RhdGEuYWN0aW9uXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghYWN0aW9uKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKGBVbmtub3duIGFjdGlvbiBmcm9tIHdvcmtlcjogJHtkYXRhLmFjdGlvbn1gKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChkYXRhLmNhbGxiYWNrSWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjYlNvdXJjZU5hbWUgPSB0aGlzLnNvdXJjZU5hbWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2JUYXJnZXROYW1lID0gZGF0YS5zb3VyY2VOYW1lOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5ldyBQcm9taXNlKGZ1bmN0aW9uIChyZXNvbHZlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlc29sdmUoYWN0aW9uKGRhdGEuZGF0YSkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pLnRoZW4oZnVuY3Rpb24gKHJlc3VsdCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb21PYmoucG9zdE1lc3NhZ2UoewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc291cmNlTmFtZTogY2JTb3VyY2VOYW1lLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGFyZ2V0TmFtZTogY2JUYXJnZXROYW1lLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FsbGJhY2s6IENhbGxiYWNrS2luZC5EQVRBLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FsbGJhY2tJZDogZGF0YS5jYWxsYmFja0lkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGF0YTogcmVzdWx0CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sIGZ1bmN0aW9uIChyZWFzb24pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29tT2JqLnBvc3RNZXNzYWdlKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNvdXJjZU5hbWU6IGNiU291cmNlTmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRhcmdldE5hbWU6IGNiVGFyZ2V0TmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhbGxiYWNrOiBDYWxsYmFja0tpbmQuRVJST1IsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYWxsYmFja0lkOiBkYXRhLmNhbGxiYWNrSWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWFzb246IHdyYXBSZWFzb24ocmVhc29uKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZGF0YS5zdHJlYW1JZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NyZWF0ZVN0cmVhbVNpbmsoZGF0YSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgYWN0aW9uKGRhdGEuZGF0YSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbU9iai5hZGRFdmVudExpc3RlbmVyKCJtZXNzYWdlIiwgdGhpcy5fb25Db21PYmpPbk1lc3NhZ2UpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBvbihhY3Rpb25OYW1lLCBoYW5kbGVyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGFoID0gdGhpcy5hY3Rpb25IYW5kbGVyOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoYWhbYWN0aW9uTmFtZV0pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcihgVGhlcmUgaXMgYWxyZWFkeSBhbiBhY3Rpb25OYW1lIGNhbGxlZCAiJHthY3Rpb25OYW1lfSJgKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBhaFthY3Rpb25OYW1lXSA9IGhhbmRsZXI7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNlbmQoYWN0aW9uTmFtZSwgZGF0YSwgdHJhbnNmZXJzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29tT2JqLnBvc3RNZXNzYWdlKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNvdXJjZU5hbWU6IHRoaXMuc291cmNlTmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRhcmdldE5hbWU6IHRoaXMudGFyZ2V0TmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFjdGlvbjogYWN0aW9uTmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRhdGEKICAgICAgICAgICAgICAgICAgICAgICAgfSwgdHJhbnNmZXJzKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2VuZFdpdGhQcm9taXNlKGFjdGlvbk5hbWUsIGRhdGEsIHRyYW5zZmVycykgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjYWxsYmFja0lkID0gdGhpcy5jYWxsYmFja0lkKys7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNhcGFiaWxpdHkgPSAoMCwgX3V0aWwuY3JlYXRlUHJvbWlzZUNhcGFiaWxpdHkpKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2FsbGJhY2tDYXBhYmlsaXRpZXNbY2FsbGJhY2tJZF0gPSBjYXBhYmlsaXR5OwogICAgICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb21PYmoucG9zdE1lc3NhZ2UoewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNvdXJjZU5hbWU6IHRoaXMuc291cmNlTmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0YXJnZXROYW1lOiB0aGlzLnRhcmdldE5hbWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYWN0aW9uOiBhY3Rpb25OYW1lLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhbGxiYWNrSWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGF0YQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSwgdHJhbnNmZXJzKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZXgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhcGFiaWxpdHkucmVqZWN0KGV4KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gY2FwYWJpbGl0eS5wcm9taXNlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzZW5kV2l0aFN0cmVhbShhY3Rpb25OYW1lLCBkYXRhLCBxdWV1ZWluZ1N0cmF0ZWd5LCB0cmFuc2ZlcnMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3RyZWFtSWQgPSB0aGlzLnN0cmVhbUlkKyssCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzb3VyY2VOYW1lID0gdGhpcy5zb3VyY2VOYW1lLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGFyZ2V0TmFtZSA9IHRoaXMudGFyZ2V0TmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbU9iaiA9IHRoaXMuY29tT2JqOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IFJlYWRhYmxlU3RyZWFtKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0YXJ0OiBjb250cm9sbGVyID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzdGFydENhcGFiaWxpdHkgPSAoMCwgX3V0aWwuY3JlYXRlUHJvbWlzZUNhcGFiaWxpdHkpKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zdHJlYW1Db250cm9sbGVyc1tzdHJlYW1JZF0gPSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRyb2xsZXIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0YXJ0Q2FsbDogc3RhcnRDYXBhYmlsaXR5LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwdWxsQ2FsbDogbnVsbCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FuY2VsQ2FsbDogbnVsbCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNDbG9zZWQ6IGZhbHNlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb21PYmoucG9zdE1lc3NhZ2UoewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzb3VyY2VOYW1lLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0YXJnZXROYW1lLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhY3Rpb246IGFjdGlvbk5hbWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0cmVhbUlkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkYXRhLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXNpcmVkU2l6ZTogY29udHJvbGxlci5kZXNpcmVkU2l6ZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sIHRyYW5zZmVycyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHN0YXJ0Q2FwYWJpbGl0eS5wcm9taXNlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHB1bGw6IGNvbnRyb2xsZXIgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHB1bGxDYXBhYmlsaXR5ID0gKDAsIF91dGlsLmNyZWF0ZVByb21pc2VDYXBhYmlsaXR5KSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc3RyZWFtQ29udHJvbGxlcnNbc3RyZWFtSWRdLnB1bGxDYWxsID0gcHVsbENhcGFiaWxpdHk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29tT2JqLnBvc3RNZXNzYWdlKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc291cmNlTmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGFyZ2V0TmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RyZWFtOiBTdHJlYW1LaW5kLlBVTEwsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0cmVhbUlkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXNpcmVkU2l6ZTogY29udHJvbGxlci5kZXNpcmVkU2l6ZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBwdWxsQ2FwYWJpbGl0eS5wcm9taXNlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhbmNlbDogcmVhc29uID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwuYXNzZXJ0KShyZWFzb24gaW5zdGFuY2VvZiBFcnJvciwgImNhbmNlbCBtdXN0IGhhdmUgYSB2YWxpZCByZWFzb24iKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjYW5jZWxDYXBhYmlsaXR5ID0gKDAsIF91dGlsLmNyZWF0ZVByb21pc2VDYXBhYmlsaXR5KSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc3RyZWFtQ29udHJvbGxlcnNbc3RyZWFtSWRdLmNhbmNlbENhbGwgPSBjYW5jZWxDYXBhYmlsaXR5OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc3RyZWFtQ29udHJvbGxlcnNbc3RyZWFtSWRdLmlzQ2xvc2VkID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb21PYmoucG9zdE1lc3NhZ2UoewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzb3VyY2VOYW1lLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0YXJnZXROYW1lLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHJlYW06IFN0cmVhbUtpbmQuQ0FOQ0VMLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHJlYW1JZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVhc29uOiB3cmFwUmVhc29uKHJlYXNvbikKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gY2FuY2VsQ2FwYWJpbGl0eS5wcm9taXNlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9LCBxdWV1ZWluZ1N0cmF0ZWd5KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX2NyZWF0ZVN0cmVhbVNpbmsoZGF0YSkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzdHJlYW1JZCA9IGRhdGEuc3RyZWFtSWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzb3VyY2VOYW1lID0gdGhpcy5zb3VyY2VOYW1lLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGFyZ2V0TmFtZSA9IGRhdGEuc291cmNlTmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbU9iaiA9IHRoaXMuY29tT2JqOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzZWxmID0gdGhpcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFjdGlvbiA9IHRoaXMuYWN0aW9uSGFuZGxlcltkYXRhLmFjdGlvbl07CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0cmVhbVNpbmsgPSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbnF1ZXVlKGNodW5rKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHNpemUgPSBhcmd1bWVudHMubGVuZ3RoID4gMSAmJiBhcmd1bWVudHNbMV0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1sxXSA6IDE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHRyYW5zZmVycyA9IGFyZ3VtZW50cy5sZW5ndGggPiAyID8gYXJndW1lbnRzWzJdIDogdW5kZWZpbmVkOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmlzQ2FuY2VsbGVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbGFzdERlc2lyZWRTaXplID0gdGhpcy5kZXNpcmVkU2l6ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRlc2lyZWRTaXplIC09IHNpemU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGxhc3REZXNpcmVkU2l6ZSA+IDAgJiYgdGhpcy5kZXNpcmVkU2l6ZSA8PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2lua0NhcGFiaWxpdHkgPSAoMCwgX3V0aWwuY3JlYXRlUHJvbWlzZUNhcGFiaWxpdHkpKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucmVhZHkgPSB0aGlzLnNpbmtDYXBhYmlsaXR5LnByb21pc2U7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbU9iai5wb3N0TWVzc2FnZSh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNvdXJjZU5hbWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRhcmdldE5hbWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0cmVhbTogU3RyZWFtS2luZC5FTlFVRVVFLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHJlYW1JZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2h1bmsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9LCB0cmFuc2ZlcnMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsb3NlKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmlzQ2FuY2VsbGVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5pc0NhbmNlbGxlZCA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29tT2JqLnBvc3RNZXNzYWdlKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc291cmNlTmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGFyZ2V0TmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RyZWFtOiBTdHJlYW1LaW5kLkNMT1NFLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHJlYW1JZAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlbGV0ZSBzZWxmLnN0cmVhbVNpbmtzW3N0cmVhbUlkXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlcnJvcihyZWFzb24pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwuYXNzZXJ0KShyZWFzb24gaW5zdGFuY2VvZiBFcnJvciwgImVycm9yIG11c3QgaGF2ZSBhIHZhbGlkIHJlYXNvbiIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmlzQ2FuY2VsbGVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5pc0NhbmNlbGxlZCA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29tT2JqLnBvc3RNZXNzYWdlKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc291cmNlTmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGFyZ2V0TmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RyZWFtOiBTdHJlYW1LaW5kLkVSUk9SLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHJlYW1JZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVhc29uOiB3cmFwUmVhc29uKHJlYXNvbikKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzaW5rQ2FwYWJpbGl0eTogKDAsIF91dGlsLmNyZWF0ZVByb21pc2VDYXBhYmlsaXR5KSgpLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgb25QdWxsOiBudWxsLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgb25DYW5jZWw6IG51bGwsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc0NhbmNlbGxlZDogZmFsc2UsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXNpcmVkU2l6ZTogZGF0YS5kZXNpcmVkU2l6ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlYWR5OiBudWxsCiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgIHN0cmVhbVNpbmsuc2lua0NhcGFiaWxpdHkucmVzb2x2ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICBzdHJlYW1TaW5rLnJlYWR5ID0gc3RyZWFtU2luay5zaW5rQ2FwYWJpbGl0eS5wcm9taXNlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnN0cmVhbVNpbmtzW3N0cmVhbUlkXSA9IHN0cmVhbVNpbms7CiAgICAgICAgICAgICAgICAgICAgICAgIG5ldyBQcm9taXNlKGZ1bmN0aW9uIChyZXNvbHZlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXNvbHZlKGFjdGlvbihkYXRhLmRhdGEsIHN0cmVhbVNpbmspKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSkudGhlbihmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb21PYmoucG9zdE1lc3NhZ2UoewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNvdXJjZU5hbWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGFyZ2V0TmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHJlYW06IFN0cmVhbUtpbmQuU1RBUlRfQ09NUExFVEUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RyZWFtSWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3VjY2VzczogdHJ1ZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0sIGZ1bmN0aW9uIChyZWFzb24pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbU9iai5wb3N0TWVzc2FnZSh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc291cmNlTmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0YXJnZXROYW1lLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0cmVhbTogU3RyZWFtS2luZC5TVEFSVF9DT01QTEVURSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHJlYW1JZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWFzb246IHdyYXBSZWFzb24ocmVhc29uKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfcHJvY2Vzc1N0cmVhbU1lc3NhZ2UoZGF0YSkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzdHJlYW1JZCA9IGRhdGEuc3RyZWFtSWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzb3VyY2VOYW1lID0gdGhpcy5zb3VyY2VOYW1lLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGFyZ2V0TmFtZSA9IGRhdGEuc291cmNlTmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbU9iaiA9IHRoaXMuY29tT2JqOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzdHJlYW1Db250cm9sbGVyID0gdGhpcy5zdHJlYW1Db250cm9sbGVyc1tzdHJlYW1JZF0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHJlYW1TaW5rID0gdGhpcy5zdHJlYW1TaW5rc1tzdHJlYW1JZF07CiAgICAgICAgICAgICAgICAgICAgICAgIHN3aXRjaCAoZGF0YS5zdHJlYW0pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgU3RyZWFtS2luZC5TVEFSVF9DT01QTEVURToKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZGF0YS5zdWNjZXNzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0cmVhbUNvbnRyb2xsZXIuc3RhcnRDYWxsLnJlc29sdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHJlYW1Db250cm9sbGVyLnN0YXJ0Q2FsbC5yZWplY3Qod3JhcFJlYXNvbihkYXRhLnJlYXNvbikpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgU3RyZWFtS2luZC5QVUxMX0NPTVBMRVRFOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChkYXRhLnN1Y2Nlc3MpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RyZWFtQ29udHJvbGxlci5wdWxsQ2FsbC5yZXNvbHZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RyZWFtQ29udHJvbGxlci5wdWxsQ2FsbC5yZWplY3Qod3JhcFJlYXNvbihkYXRhLnJlYXNvbikpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgU3RyZWFtS2luZC5QVUxMOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghc3RyZWFtU2luaykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb21PYmoucG9zdE1lc3NhZ2UoewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc291cmNlTmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRhcmdldE5hbWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHJlYW06IFN0cmVhbUtpbmQuUFVMTF9DT01QTEVURSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0cmVhbUlkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3VjY2VzczogdHJ1ZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChzdHJlYW1TaW5rLmRlc2lyZWRTaXplIDw9IDAgJiYgZGF0YS5kZXNpcmVkU2l6ZSA+IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RyZWFtU2luay5zaW5rQ2FwYWJpbGl0eS5yZXNvbHZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0cmVhbVNpbmsuZGVzaXJlZFNpemUgPSBkYXRhLmRlc2lyZWRTaXplOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5ldyBQcm9taXNlKGZ1bmN0aW9uIChyZXNvbHZlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlc29sdmUoc3RyZWFtU2luay5vblB1bGwgJiYgc3RyZWFtU2luay5vblB1bGwoKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSkudGhlbihmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbU9iai5wb3N0TWVzc2FnZSh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzb3VyY2VOYW1lLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGFyZ2V0TmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0cmVhbTogU3RyZWFtS2luZC5QVUxMX0NPTVBMRVRFLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RyZWFtSWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdWNjZXNzOiB0cnVlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sIGZ1bmN0aW9uIChyZWFzb24pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29tT2JqLnBvc3RNZXNzYWdlKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNvdXJjZU5hbWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0YXJnZXROYW1lLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RyZWFtOiBTdHJlYW1LaW5kLlBVTExfQ09NUExFVEUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHJlYW1JZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlYXNvbjogd3JhcFJlYXNvbihyZWFzb24pCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBTdHJlYW1LaW5kLkVOUVVFVUU6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLmFzc2VydCkoc3RyZWFtQ29udHJvbGxlciwgImVucXVldWUgc2hvdWxkIGhhdmUgc3RyZWFtIGNvbnRyb2xsZXIiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoc3RyZWFtQ29udHJvbGxlci5pc0Nsb3NlZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RyZWFtQ29udHJvbGxlci5jb250cm9sbGVyLmVucXVldWUoZGF0YS5jaHVuayk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIFN0cmVhbUtpbmQuQ0xPU0U6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLmFzc2VydCkoc3RyZWFtQ29udHJvbGxlciwgImNsb3NlIHNob3VsZCBoYXZlIHN0cmVhbSBjb250cm9sbGVyIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHN0cmVhbUNvbnRyb2xsZXIuaXNDbG9zZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0cmVhbUNvbnRyb2xsZXIuaXNDbG9zZWQgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0cmVhbUNvbnRyb2xsZXIuY29udHJvbGxlci5jbG9zZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2RlbGV0ZVN0cmVhbUNvbnRyb2xsZXIoc3RyZWFtQ29udHJvbGxlciwgc3RyZWFtSWQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBTdHJlYW1LaW5kLkVSUk9SOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC5hc3NlcnQpKHN0cmVhbUNvbnRyb2xsZXIsICJlcnJvciBzaG91bGQgaGF2ZSBzdHJlYW0gY29udHJvbGxlciIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0cmVhbUNvbnRyb2xsZXIuY29udHJvbGxlci5lcnJvcih3cmFwUmVhc29uKGRhdGEucmVhc29uKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZGVsZXRlU3RyZWFtQ29udHJvbGxlcihzdHJlYW1Db250cm9sbGVyLCBzdHJlYW1JZCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIFN0cmVhbUtpbmQuQ0FOQ0VMX0NPTVBMRVRFOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChkYXRhLnN1Y2Nlc3MpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RyZWFtQ29udHJvbGxlci5jYW5jZWxDYWxsLnJlc29sdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHJlYW1Db250cm9sbGVyLmNhbmNlbENhbGwucmVqZWN0KHdyYXBSZWFzb24oZGF0YS5yZWFzb24pKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZGVsZXRlU3RyZWFtQ29udHJvbGxlcihzdHJlYW1Db250cm9sbGVyLCBzdHJlYW1JZCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIFN0cmVhbUtpbmQuQ0FOQ0VMOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghc3RyZWFtU2luaykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbmV3IFByb21pc2UoZnVuY3Rpb24gKHJlc29sdmUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVzb2x2ZShzdHJlYW1TaW5rLm9uQ2FuY2VsICYmIHN0cmVhbVNpbmsub25DYW5jZWwod3JhcFJlYXNvbihkYXRhLnJlYXNvbikpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KS50aGVuKGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29tT2JqLnBvc3RNZXNzYWdlKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNvdXJjZU5hbWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0YXJnZXROYW1lLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RyZWFtOiBTdHJlYW1LaW5kLkNBTkNFTF9DT01QTEVURSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0cmVhbUlkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3VjY2VzczogdHJ1ZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9LCBmdW5jdGlvbiAocmVhc29uKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbU9iai5wb3N0TWVzc2FnZSh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzb3VyY2VOYW1lLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGFyZ2V0TmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0cmVhbTogU3RyZWFtS2luZC5DQU5DRUxfQ09NUExFVEUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHJlYW1JZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlYXNvbjogd3JhcFJlYXNvbihyZWFzb24pCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0cmVhbVNpbmsuc2lua0NhcGFiaWxpdHkucmVqZWN0KHdyYXBSZWFzb24oZGF0YS5yZWFzb24pKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHJlYW1TaW5rLmlzQ2FuY2VsbGVkID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWxldGUgdGhpcy5zdHJlYW1TaW5rc1tzdHJlYW1JZF07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcigiVW5leHBlY3RlZCBzdHJlYW0gY2FzZSIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGFzeW5jIF9kZWxldGVTdHJlYW1Db250cm9sbGVyKHN0cmVhbUNvbnRyb2xsZXIsIHN0cmVhbUlkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGF3YWl0IFByb21pc2UuYWxsU2V0dGxlZChbc3RyZWFtQ29udHJvbGxlci5zdGFydENhbGwgJiYgc3RyZWFtQ29udHJvbGxlci5zdGFydENhbGwucHJvbWlzZSwgc3RyZWFtQ29udHJvbGxlci5wdWxsQ2FsbCAmJiBzdHJlYW1Db250cm9sbGVyLnB1bGxDYWxsLnByb21pc2UsIHN0cmVhbUNvbnRyb2xsZXIuY2FuY2VsQ2FsbCAmJiBzdHJlYW1Db250cm9sbGVyLmNhbmNlbENhbGwucHJvbWlzZV0pOwogICAgICAgICAgICAgICAgICAgICAgICBkZWxldGUgdGhpcy5zdHJlYW1Db250cm9sbGVyc1tzdHJlYW1JZF07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGRlc3Ryb3koKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29tT2JqLnJlbW92ZUV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLCB0aGlzLl9vbkNvbU9iak9uTWVzc2FnZSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5NZXNzYWdlSGFuZGxlciA9IE1lc3NhZ2VIYW5kbGVyOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxNTEgKi8KICAgICAgICAgICAgLyoqKi8gKChfX3VudXNlZF93ZWJwYWNrX21vZHVsZSwgZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgICJ1c2Ugc3RyaWN0IjsKCgogICAgICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJfX2VzTW9kdWxlIiwgKHsKICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdHJ1ZQogICAgICAgICAgICAgICAgfSkpOwogICAgICAgICAgICAgICAgZXhwb3J0cy5NZXRhZGF0YSA9IHZvaWQgMDsKICAgICAgICAgICAgICAgIHZhciBfdXRpbCA9IF9fd19wZGZqc19yZXF1aXJlX18oMSk7CiAgICAgICAgICAgICAgICBjbGFzcyBNZXRhZGF0YSB7CiAgICAgICAgICAgICAgICAgICAgI21ldGFkYXRhTWFwOwogICAgICAgICAgICAgICAgICAgICNkYXRhOwogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKF9yZWYpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhcnNlZERhdGEsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICByYXdEYXRhCiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBfcmVmOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLiNtZXRhZGF0YU1hcCA9IHBhcnNlZERhdGE7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuI2RhdGEgPSByYXdEYXRhOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRSYXcoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLiNkYXRhOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQobmFtZSkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy4jbWV0YWRhdGFNYXAuZ2V0KG5hbWUpID8/IG51bGw7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldEFsbCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICgwLCBfdXRpbC5vYmplY3RGcm9tTWFwKSh0aGlzLiNtZXRhZGF0YU1hcCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGhhcyhuYW1lKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLiNtZXRhZGF0YU1hcC5oYXMobmFtZSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5NZXRhZGF0YSA9IE1ldGFkYXRhOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxNTIgKi8KICAgICAgICAgICAgLyoqKi8gKChfX3VudXNlZF93ZWJwYWNrX21v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ICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuI3Zpc2libGU7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9zZXRWaXNpYmxlKGludGVybmFsLCB2aXNpYmxlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpbnRlcm5hbCAhPT0gSU5URVJOQUwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC51bnJlYWNoYWJsZSkoIkludGVybmFsIG1ldGhvZCBgX3NldFZpc2libGVgIGNhbGxlZC4iKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLiN2aXNpYmxlID0gdmlzaWJsZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB2YXIgX2NhY2hlZEdldEhhc2ggPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfZ3JvdXBzID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2luaXRpYWxIYXNoID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX29yZGVyID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2V2YWx1YXRlVmlzaWJpbGl0eUV4cHJlc3Npb24gPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIGNsYXNzIE9wdGlvbmFsQ29udGVudENvbmZpZyB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IoZGF0YSkgewogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX2V2YWx1YXRlVmlzaWJpbGl0eUV4cHJlc3Npb24pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfY2FjaGVkR2V0SGFzaCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogbnVsbAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2dyb3VwcywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogbmV3IE1hcCgpCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfaW5pdGlhbEhhc2gsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IG51bGwKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9vcmRlciwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogbnVsbAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5uYW1lID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jcmVhdG9yID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGRhdGEgPT09IG51bGwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm5hbWUgPSBkYXRhLm5hbWU7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3JlYXRvciA9IGRhdGEuY3JlYXRvcjsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9vcmRlciwgZGF0YS5vcmRlcik7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgZ3JvdXAgb2YgZGF0YS5ncm91cHMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZ3JvdXBzKS5zZXQoZ3JvdXAuaWQsIG5ldyBPcHRpb25hbENvbnRlbnRHcm91cChncm91cC5uYW1lLCBncm91cC5pbnRlbnQpKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZGF0YS5iYXNlU3RhdGUgPT09ICJPRkYiKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGdyb3VwIG9mIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZ3JvdXBzKS52YWx1ZXMoKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdyb3VwLl9zZXRWaXNpYmxlKElOVEVSTkFMLCBmYWxzZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBvbiBvZiBkYXRhLm9uKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2dyb3VwcykuZ2V0KG9uKS5fc2V0VmlzaWJsZShJTlRFUk5BTCwgdHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBvZmYgb2YgZGF0YS5vZmYpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZ3JvdXBzKS5nZXQob2ZmKS5fc2V0VmlzaWJsZShJTlRFUk5BTCwgZmFsc2UpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfaW5pdGlhbEhhc2gsIHRoaXMuZ2V0SGFzaCgpKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaXNWaXNpYmxlKGdyb3VwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2dyb3Vwcykuc2l6ZSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFncm91cCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKCJPcHRpb25hbCBjb250ZW50IGdyb3VwIG5vdCBkZWZpbmVkLiIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGdyb3VwLnR5cGUgPT09ICJPQ0ciKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIV9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZ3JvdXBzKS5oYXMoZ3JvdXAuaWQpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKGBPcHRpb25hbCBjb250ZW50IGdyb3VwIG5vdCBmb3VuZDogJHtncm91cC5pZH1gKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2dyb3VwcykuZ2V0KGdyb3VwLmlkKS52aXNpYmxlOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGdyb3VwLnR5cGUgPT09ICJPQ01EIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGdyb3VwLmV4cHJlc3Npb24pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfZXZhbHVhdGVWaXNpYmlsaXR5RXhwcmVzc2lvbiwgX2V2YWx1YXRlVmlzaWJpbGl0eUV4cHJlc3Npb24yKS5jYWxsKHRoaXMsIGdyb3VwLmV4cHJlc3Npb24pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFncm91cC5wb2xpY3kgfHwgZ3JvdXAucG9saWN5ID09PSAiQW55T24iKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBpZCBvZiBncm91cC5pZHMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2dyb3VwcykuaGFzKGlkKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKGBPcHRpb25hbCBjb250ZW50IGdyb3VwIG5vdCBmb3VuZDogJHtpZH1gKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2dyb3VwcykuZ2V0KGlkKS52aXNpYmxlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGdyb3VwLnBvbGljeSA9PT0gIkFsbE9uIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgaWQgb2YgZ3JvdXAuaWRzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ncm91cHMpLmhhcyhpZCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgT3B0aW9uYWwgY29udGVudCBncm91cCBub3QgZm91bmQ6ICR7aWR9YCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIV9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZ3JvdXBzKS5nZXQoaWQpLnZpc2libGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoZ3JvdXAucG9saWN5ID09PSAiQW55T2ZmIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgaWQgb2YgZ3JvdXAuaWRzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ncm91cHMpLmhhcyhpZCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgT3B0aW9uYWwgY29udGVudCBncm91cCBub3QgZm91bmQ6ICR7aWR9YCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIV9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZ3JvdXBzKS5nZXQoaWQpLnZpc2libGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoZ3JvdXAucG9saWN5ID09PSAiQWxsT2ZmIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgaWQgb2YgZ3JvdXAuaWRzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ncm91cHMpLmhhcyhpZCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgT3B0aW9uYWwgY29udGVudCBncm91cCBub3QgZm91bmQ6ICR7aWR9YCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ncm91cHMpLmdldChpZCkudmlzaWJsZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKGBVbmtub3duIG9wdGlvbmFsIGNvbnRlbnQgcG9saWN5ICR7Z3JvdXAucG9saWN5fS5gKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgVW5rbm93biBncm91cCB0eXBlICR7Z3JvdXAudHlwZX0uYCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzZXRWaXNpYmlsaXR5KGlkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB2aXNpYmxlID0gYXJndW1lbnRzLmxlbmd0aCA+IDEgJiYgYXJndW1lbnRzWzFdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMV0gOiB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIV9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZ3JvdXBzKS5oYXMoaWQpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYE9wdGlvbmFsIGNvbnRlbnQgZ3JvdXAgbm90IGZvdW5kOiAke2lkfWApOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZ3JvdXBzKS5nZXQoaWQpLl9zZXRWaXNpYmxlKElOVEVSTkFMLCAhIXZpc2libGUpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX2NhY2hlZEdldEhhc2gsIG51bGwpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgaGFzSW5pdGlhbFZpc2liaWxpdHkoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLmdldEhhc2goKSA9PT0gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9pbml0aWFsSGFzaCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldE9yZGVyKCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIV9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZ3JvdXBzKS5zaXplKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9vcmRlcikpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX29yZGVyKS5zbGljZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbLi4uX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ncm91cHMpLmtleXMoKV07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldEdyb3VwcygpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZ3JvdXBzKS5zaXplID4gMCA/ICgwLCBfdXRpbC5vYmplY3RGcm9tTWFwKShfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2dyb3VwcykpIDogbnVsbDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0R3JvdXAoaWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZ3JvdXBzKS5nZXQoaWQpIHx8IG51bGw7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldEhhc2goKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2NhY2hlZEdldEhhc2gpICE9PSBudWxsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9jYWNoZWRHZXRIYXNoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBoYXNoID0gbmV3IF9tdXJtdXJoYXNoLk11cm11ckhhc2gzXzY0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgW2lkLCBncm91cF0gb2YgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ncm91cHMpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoYXNoLnVwZGF0ZShgJHtpZH06JHtncm91cC52aXNpYmxlfWApOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX2NhY2hlZEdldEhhc2gsIGhhc2guaGV4ZGlnZXN0KCkpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGV4cG9ydHMuT3B0aW9uYWxDb250ZW50Q29uZmlnID0gT3B0aW9uYWxDb250ZW50Q29uZmlnOwogICAgICAgICAgICAgICAgZnVuY3Rpb24gX2V2YWx1YXRlVmlzaWJpbGl0eUV4cHJlc3Npb24yKGFycmF5KSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgbGVuZ3RoID0gYXJyYXkubGVuZ3RoOwogICAgICAgICAgICAgICAgICAgIGlmIChsZW5ndGggPCAyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjb25zdCBvcGVyYXRvciA9IGFycmF5WzBdOwogICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAxOyBpIDwgbGVuZ3RoOyBpKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZWxlbWVudCA9IGFycmF5W2ldOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgc3RhdGU7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChBcnJheS5pc0FycmF5KGVsZW1lbnQpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGF0ZSA9IF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2V2YWx1YXRlVmlzaWJpbGl0eUV4cHJlc3Npb24sIF9ldmFsdWF0ZVZpc2liaWxpdHlFeHByZXNzaW9uMikuY2FsbCh0aGlzLCBlbGVtZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2dyb3VwcykuaGFzKGVsZW1lbnQpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGF0ZSA9IF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZ3JvdXBzKS5nZXQoZWxlbWVudCkudmlzaWJsZTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgT3B0aW9uYWwgY29udGVudCBncm91cCBub3QgZm91bmQ6ICR7ZWxlbWVudH1gKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHN3aXRjaCAob3BlcmF0b3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgIkFuZCI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFzdGF0ZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiT3IiOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChzdGF0ZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJOb3QiOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAhc3RhdGU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJldHVybiBvcGVyYXRvciA9PT0gIkFuZCI7CiAgICAgICAgICAgICAgICB9CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDE1MyAqLwogICAgICAgICAgICAvKioqLyAoKF9fdW51c2VkX3dlYnBhY2tfbW9kdWxlLCBleHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKCiAgICAgICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIl9fZXNNb2R1bGUiLCAoewogICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0cnVlCiAgICAgICAgICAgICAgICB9KSk7CiAgICAgICAgICAgICAgICBleHBvcnRzLlBERkRhdGFUcmFuc3BvcnRTdHJlYW0gPSB2b2lkIDA7CiAgICAgICAgICAgICAgICB2YXIgX3V0aWwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEpOwogICAgICAgICAgICAgICAgdmFyIF9kaXNwbGF5X3V0aWxzID0gX193X3BkZmpzX3JlcXVpcmVfXygxNDIpOwogICAgICAgICAgICAgICAgY2xhc3MgUERGRGF0YVRyYW5zcG9ydFN0cmVhbSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IoX3JlZiwgcGRmRGF0YVJhbmdlVHJhbnNwb3J0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZW5ndGgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbml0aWFsRGF0YSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHByb2dyZXNzaXZlRG9uZSA9IGZhbHNlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGVudERpc3Bvc2l0aW9uRmlsZW5hbWUgPSBudWxsLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGlzYWJsZVJhbmdlID0gZmFsc2UsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkaXNhYmxlU3RyZWFtID0gZmFsc2UKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IF9yZWY7CiAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC5hc3NlcnQpKHBkZkRhdGFSYW5nZVRyYW5zcG9ydCwgJ1BERkRhdGFUcmFuc3BvcnRTdHJlYW0gLSBtaXNzaW5nIHJlcXVpcmVkICJwZGZEYXRhUmFuZ2VUcmFuc3BvcnQiIGFyZ3VtZW50LicpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9xdWV1ZWRDaHVua3MgPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcHJvZ3Jlc3NpdmVEb25lID0gcHJvZ3Jlc3NpdmVEb25lOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jb250ZW50RGlzcG9zaXRpb25GaWxlbmFtZSA9IGNvbnRlbnREaXNwb3NpdGlvbkZpbGVuYW1lOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoKGluaXRpYWxEYXRhID09PSBudWxsIHx8IGluaXRpYWxEYXRhID09PSB2b2lkIDAgPyB2b2lkIDAgOiBpbml0aWFsRGF0YS5sZW5ndGgpID4gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYnVmZmVyID0gaW5pdGlhbERhdGEgaW5zdGFuY2VvZiBVaW50OEFycmF5ICYmIGluaXRpYWxEYXRhLmJ5dGVMZW5ndGggPT09IGluaXRpYWxEYXRhLmJ1ZmZlci5ieXRlTGVuZ3RoID8gaW5pdGlhbERhdGEuYnVmZmVyIDogbmV3IFVpbnQ4QXJyYXkoaW5pdGlhbERhdGEpLmJ1ZmZlcjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3F1ZXVlZENodW5rcy5wdXNoKGJ1ZmZlcik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcGRmRGF0YVJhbmdlVHJhbnNwb3J0ID0gcGRmRGF0YVJhbmdlVHJhbnNwb3J0OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9pc1N0cmVhbWluZ1N1cHBvcnRlZCA9ICFkaXNhYmxlU3RyZWFtOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9pc1JhbmdlU3VwcG9ydGVkID0gIWRpc2FibGVSYW5nZTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fY29udGVudExlbmd0aCA9IGxlbmd0aDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZnVsbFJlcXVlc3RSZWFkZXIgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yYW5nZVJlYWRlcnMgPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcGRmRGF0YVJhbmdlVHJhbnNwb3J0LmFkZFJhbmdlTGlzdGVuZXIoKGJlZ2luLCBjaHVuaykgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fb25SZWNlaXZlRGF0YSh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYmVnaW4sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2h1bmsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcGRmRGF0YVJhbmdlVHJhbnNwb3J0LmFkZFByb2dyZXNzTGlzdGVuZXIoKGxvYWRlZCwgdG90YWwpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX29uUHJvZ3Jlc3MoewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxvYWRlZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0b3RhbAogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wZGZEYXRhUmFuZ2VUcmFuc3BvcnQuYWRkUHJvZ3Jlc3NpdmVSZWFkTGlzdGVuZXIoY2h1bmsgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fb25SZWNlaXZlRGF0YSh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2h1bmsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcGRmRGF0YVJhbmdlVHJhbnNwb3J0LmFkZFByb2dyZXNzaXZlRG9uZUxpc3RlbmVyKCgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX29uUHJvZ3Jlc3NpdmVEb25lKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wZGZEYXRhUmFuZ2VUcmFuc3BvcnQudHJhbnNwb3J0UmVhZHkoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX29uUmVjZWl2ZURhdGEoX3JlZjIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJlZ2luLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2h1bmsKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IF9yZWYyOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBidWZmZXIgPSBjaHVuayBpbnN0YW5jZW9mIFVpbnQ4QXJyYXkgJiYgY2h1bmsuYnl0ZUxlbmd0aCA9PT0gY2h1bmsuYnVmZmVyLmJ5dGVMZW5ndGggPyBjaHVuay5idWZmZXIgOiBuZXcgVWludDhBcnJheShjaHVuaykuYnVmZmVyOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoYmVnaW4gPT09IHVuZGVmaW5lZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuX2Z1bGxSZXF1ZXN0UmVhZGVyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZnVsbFJlcXVlc3RSZWFkZXIuX2VucXVldWUoYnVmZmVyKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcXVldWVkQ2h1bmtzLnB1c2goYnVmZmVyKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZvdW5kID0gdGhpcy5fcmFuZ2VSZWFkZXJzLnNvbWUoZnVuY3Rpb24gKHJhbmdlUmVhZGVyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHJhbmdlUmVhZGVyLl9iZWdpbiAhPT0gYmVnaW4pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByYW5nZVJlYWRlci5fZW5xdWV1ZShidWZmZXIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwuYXNzZXJ0KShmb3VuZCwgIl9vblJlY2VpdmVEYX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VJlYWRlcnMkJC5jYWxsKF90aGlzJF9yYW5nZVJlYWRlcnMkLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbG9hZGVkOiBldnQubG9hZGVkCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRfZnVsbFJlcXVlc3RSZWEyLCBfdGhpcyRfZnVsbFJlcXVlc3RSZWEzOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgKF90aGlzJF9mdWxsUmVxdWVzdFJlYTIgPSB0aGlzLl9mdWxsUmVxdWVzdFJlYWRlcikgPT09IG51bGwgfHwgX3RoaXMkX2Z1bGxSZXF1ZXN0UmVhMiA9PT0gdm9pZCAwID8gdm9pZCAwIDogKF90aGlzJF9mdWxsUmVxdWVzdFJlYTMgPSBfdGhpcyRfZnVsbFJlcXVlc3RSZWEyLm9uUHJvZ3Jlc3MpID09PSBudWxsIHx8IF90aGlzJF9mdWxsUmVxdWVzdFJlYTMgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF90aGlzJF9mdWxsUmVxdWVzdFJlYTMuY2FsbChfdGhpcyRfZnVsbFJlcXVlc3RSZWEyLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbG9hZGVkOiBldnQubG9hZGVkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRvdGFsOiBldnQudG90YWwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9vblByb2dyZXNzaXZlRG9uZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF90aGlzJF9mdWxsUmVxdWVzdFJlYTQ7CiAgICAgICAgICAgICAgICAgICAgICAgIChfdGhpcyRfZnVsbFJlcXVlc3RSZWE0ID0gdGhpcy5fZnVsbFJlcXVlc3RSZWFkZXIpID09PSBudWxsIHx8IF90aGlzJF9mdWxsUmVxdWVzdFJlYTQgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF90aGlzJF9mdWxsUmVxdWVzdFJlYTQucHJvZ3Jlc3NpdmVEb25lKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3Byb2dyZXNzaXZlRG9uZSA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9yZW1vdmVSYW5nZVJlYWRlcihyZWFkZXIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaSA9IHRoaXMuX3JhbmdlUmVhZGVycy5pbmRleE9mKHJlYWRlcik7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpID49IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JhbmdlUmVhZGVycy5zcGxpY2UoaSwgMSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0RnVsbFJlYWRlcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLmFzc2VydCkoIXRoaXMuX2Z1bGxSZXF1ZXN0UmVhZGVyLCAiUERGRGF0YVRyYW5zcG9ydFN0cmVhbS5nZXRGdWxsUmVhZGVyIGNhbiBvbmx5IGJlIGNhbGxlZCBvbmNlLiIpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBxdWV1ZWRDaHVua3MgPSB0aGlzLl9xdWV1ZWRDaHVua3M7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3F1ZXVlZENodW5rcyA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgUERGRGF0YVRyYW5zcG9ydFN0cmVhbVJlYWRlcih0aGlzLCBxdWV1ZWRDaHVua3MsIHRoaXMuX3Byb2dyZXNzaXZlRG9uZSwgdGhpcy5fY29udGVudERpc3Bvc2l0aW9uRmlsZW5hbWUpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRSYW5nZVJlYWRlcihiZWdpbiwgZW5kKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChlbmQgPD0gdGhpcy5fcHJvZ3Jlc3NpdmVEYXRhTGVuZ3RoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByZWFkZXIgPSBuZXcgUERGRGF0YVRyYW5zcG9ydFN0cmVhbVJhbmdlUmVhZGVyKHRoaXMsIGJlZ2luLCBlbmQpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wZGZEYXRhUmFuZ2VUcmFuc3BvcnQucmVxdWVzdERhdGFSYW5nZShiZWdpbiwgZW5kKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmFuZ2VSZWFkZXJzLnB1c2gocmVhZGVyKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHJlYWRlcjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY2FuY2VsQWxsUmVxdWVzdHMocmVhc29uKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRfZnVsbFJlcXVlc3RSZWE1OwogICAgICAgICAgICAgICAgICAgICAgICAoX3RoaXMkX2Z1bGxSZXF1ZXN0UmVhNSA9IHRoaXMuX2Z1bGxSZXF1ZXN0UmVhZGVyKSA9PT0gbnVsbCB8fCBfdGhpcyRfZnVsbFJlcXVlc3RSZWE1ID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRfZnVsbFJlcXVlc3RSZWE1LmNhbmNlbChyZWFzb24pOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IHJlYWRlciBvZiB0aGlzLl9yYW5nZVJlYWRlcnMuc2xpY2UoMCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlYWRlci5jYW5jZWwocmVhc29uKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wZGZEYXRhUmFuZ2VUcmFuc3BvcnQuYWJvcnQoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLlBERkRhdGFUcmFuc3BvcnRTdHJlYW0gPSBQREZEYXRhVHJhbnNwb3J0U3RyZWFtOwogICAgICAgICAgICAgICAgY2xhc3MgUERGRGF0YVRyYW5zcG9ydFN0cmVhbVJlYWRlciB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3Ioc3RyZWFtLCBxdWV1ZWRDaHVua3MpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHByb2dyZXNzaXZlRG9uZSA9IGFyZ3VtZW50cy5sZW5ndGggPiAyICYmIGFyZ3VtZW50c1syXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzJdIDogZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBjb250ZW50RGlzcG9zaXRpb25GaWxlbmFtZSA9IGFyZ3VtZW50cy5sZW5ndGggPiAzICYmIGFyZ3VtZW50c1szXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzNdIDogbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc3RyZWFtID0gc3RyZWFtOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9kb25lID0gcHJvZ3Jlc3NpdmVEb25lIHx8IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9maWxlbmFtZSA9ICgwLCBfZGlzcGxheV91dGlscy5pc1BkZkZpbGUpKGNvbnRlbnREaXNwb3NpdGlvbkZpbGVuYW1lKSA/IGNvbnRlbnREaXNwb3NpdGlvbkZpbGVuYW1lIDogbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcXVldWVkQ2h1bmtzID0gcXVldWVkQ2h1bmtzIHx8IFtdOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9sb2FkZWQgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGNodW5rIG9mIHRoaXMuX3F1ZXVlZENodW5rcykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fbG9hZGVkICs9IGNodW5rLmJ5dGVMZW5ndGg7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVxdWVzdHMgPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5faGVhZGVyc1JlYWR5ID0gUHJvbWlzZS5yZXNvbHZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHN0cmVhbS5fZnVsbFJlcXVlc3RSZWFkZXIgPSB0aGlzOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm9uUHJvZ3Jlc3MgPSBudWxsOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfZW5xdWV1ZShjaHVuaykgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fZG9uZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl9yZXF1ZXN0cy5sZW5ndGggPiAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByZXF1ZXN0Q2FwYWJpbGl0eSA9IHRoaXMuX3JlcXVlc3RzLnNoaWZ0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXF1ZXN0Q2FwYWJpbGl0eS5yZXNvbHZlKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogY2h1bmssCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZG9uZTogZmFsc2UKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcXVldWVkQ2h1bmtzLnB1c2goY2h1bmspOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2xvYWRlZCArPSBjaHVuay5ieXRlTGVuZ3RoOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgaGVhZGVyc1JlYWR5KCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5faGVhZGVyc1JlYWR5OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgZmlsZW5hbWUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9maWxlbmFtZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IGlzUmFuZ2VTdXBwb3J0ZWQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9zdHJlYW0uX2lzUmFuZ2VTdXBwb3J0ZWQ7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBpc1N0cmVhbWluZ1N1cHBvcnRlZCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX3N0cmVhbS5faXNTdHJlYW1pbmdTdXBwb3J0ZWQ7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBjb250ZW50TGVuZ3RoKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fc3RyZWFtLl9jb250ZW50TGVuZ3RoOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBhc3luYyByZWFkKCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fcXVldWVkQ2h1bmtzLmxlbmd0aCA+IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNodW5rID0gdGhpcy5fcXVldWVkQ2h1bmtzLnNoaWZ0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBjaHVuaywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkb25lOiBmYWxzZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fZG9uZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdW5kZWZpbmVkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRvbmU6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmVxdWVzdENhcGFiaWxpdHkgPSAoMCwgX3V0aWwuY3JlYXRlUHJvbWlzZUNhcGFiaWxpdHkpKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlcXVlc3RzLnB1c2gocmVxdWVzdENhcGFiaWxpdHkpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gcmVxdWVzdENhcGFiaWxpdHkucHJvbWlzZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY2FuY2VsKHJlYXNvbikgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9kb25lID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCByZXF1ZXN0Q2FwYWJpbGl0eSBvZiB0aGlzLl9yZXF1ZXN0cykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVxdWVzdENhcGFiaWxpdHkucmVzb2x2ZSh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHVuZGVmaW5lZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkb25lOiB0cnVlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yZXF1ZXN0cy5sZW5ndGggPSAwOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBwcm9ncmVzc2l2ZURvbmUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl9kb25lKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZG9uZSA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY2xhc3MgUERGRGF0YVRyYW5zcG9ydFN0cmVhbVJhbmdlUmVhZGVyIHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcihzdHJlYW0sIGJlZ2luLCBlbmQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc3RyZWFtID0gc3RyZWFtOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9iZWdpbiA9IGJlZ2luOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9lbmQgPSBlbmQ7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3F1ZXVlZENodW5rID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVxdWVzdHMgPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZG9uZSA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm9uUHJvZ3Jlc3MgPSBudWxsOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfZW5xdWV1ZShjaHVuaykgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fZG9uZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl9yZXF1ZXN0cy5sZW5ndGggPT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3F1ZXVlZENodW5rID0gY2h1bms7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByZXF1ZXN0c0NhcGFiaWxpdHkgPSB0aGlzLl9yZXF1ZXN0cy5zaGlmdCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVxdWVzdHNDYXBhYmlsaXR5LnJlc29sdmUoewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBjaHVuaywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkb25lOiBmYWxzZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IHJlcXVlc3RDYXBhYmlsaXR5IG9mIHRoaXMuX3JlcXVlc3RzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVxdWVzdENhcGFiaWxpdHkucmVzb2x2ZSh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiB1bmRlZmluZWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRvbmU6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlcXVlc3RzLmxlbmd0aCA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZG9uZSA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3N0cmVhbS5fcmVtb3ZlUmFuZ2VSZWFkZXIodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBpc1N0cmVhbWluZ1N1cHBvcnRlZCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBhc3luYyByZWFkKCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fcXVldWVkQ2h1bmspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNodW5rID0gdGhpcy5fcXVldWVkQ2h1bms7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9xdWV1ZWRDaHVuayA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBjaHVuaywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkb25lOiBmYWxzZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fZG9uZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdW5kZWZpbmVkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRvbmU6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmVxdWVzdENhcGFiaWxpdHkgPSAoMCwgX3V0aWwuY3JlYXRlUHJvbWlzZUNhcGFiaWxpdHkpKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlcXVlc3RzLnB1c2gocmVxdWVzdENhcGFiaWxpdHkpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gcmVxdWVzdENhcGFiaWxpdHkucHJvbWlzZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY2FuY2VsKHJlYXNvbikgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9kb25lID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCByZXF1ZXN0Q2FwYWJpbGl0eSBvZiB0aGlzLl9yZXF1ZXN0cykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVxdWVzdENhcGFiaWxpdHkucmVzb2x2ZSh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHVuZGVmaW5lZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkb25lOiB0cnVlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yZXF1ZXN0cy5sZW5ndGggPSAwOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9zdHJlYW0uX3JlbW92ZVJhbmdlUmVhZGVyKHRoaXMpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTU0ICovCiAgICAgICAgICAgIC8qKiovICgoX191bnVzZWRfd2VicGFja19tb2R1bGUsIGV4cG9ydHMpID0+IHsKCiAgICAgICAgICAgICAgICAidXNlIHN0cmljdCI7CgoKICAgICAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAiX19lc01vZHVsZSIsICh7CiAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRydWUKICAgICAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuWGZhVGV4dCA9IHZvaWQgMDsKICAgICAgICAgICAgICAgIGNsYXNzIFhmYVRleHQgewogICAgICAgICAgICAgICAgICAgIHN0YXRpYyB0ZXh0Q29udGVudCh4ZmEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaXRlbXMgPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgb3V0cHV0ID0gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXRlbXMsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHlsZXM6IE9iamVjdC5jcmVhdGUobnVsbCkKICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgZnVuY3Rpb24gd2Fsayhub2RlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgX25vZGUkYXR0cmlidXRlczsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghbm9kZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBzdHIgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbmFtZSA9IG5vZGUubmFtZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChuYW1lID09PSAiI3RleHQiKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RyID0gbm9kZS52YWx1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoIVhmYVRleHQuc2hvdWxkQnVpbGRUZXh0KG5hbWUpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChub2RlICE9PSBudWxsICYmIG5vZGUgIT09IHZvaWQgMCAmJiAoX25vZGUkYXR0cmlidXRlcyA9IG5vZGUuYXR0cmlidXRlcykgIT09IG51bGwgJiYgX25vZGUkYXR0cmlidXRlcyAhPT0gdm9pZCAwICYmIF9ub2RlJGF0dHJpYnV0ZXMudGV4dENvbnRlbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHIgPSBub2RlLmF0dHJpYnV0ZXMudGV4dENvbnRlbnQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKG5vZGUudmFsdWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHIgPSBub2RlLnZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHN0ciAhPT0gbnVsbCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGl0ZW1zLnB1c2goewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHIKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghbm9kZS5jaGlsZHJlbikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgY2hpbGQgb2Ygbm9kZS5jaGlsZHJlbikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdhbGsoY2hpbGQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHdhbGsoeGZhKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG91dHB1dDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIHNob3VsZEJ1aWxkVGV4dChuYW1lKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAhKG5hbWUgPT09ICJ0ZXh0YXJlYSIgfHwgbmFtZSA9PT0gImlucHV0IiB8fCBuYW1lID09PSAib3B0aW9uIiB8fCBuYW1lID09PSAic2VsZWN0Iik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5YZmFUZXh0ID0gWGZhVGV4dDsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTU1ICovCiAgICAgICAgICAgIC8qKiovICgoX191bnVzZWRfd2VicGFja19tb2R1bGUsIGV4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICAidXNlIHN0cmljdCI7CgoKICAgICAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAiX19lc01vZHVsZSIsICh7CiAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRydWUKICAgICAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuTm9kZVN0YW5kYXJkRm9udERhdGFGYWN0b3J5ID0gZXhwb3J0cy5Ob2RlRmlsdGVyRmFjdG9yeSA9IGV4cG9ydHMuTm9kZUNhbnZhc0ZhY3RvcnkgPSBleHBvcnRzLk5vZGVDTWFwUmVhZGVyRmFjdG9yeSA9IHZvaWQgMDsKICAgICAgICAgICAgICAgIHZhciBfYmFzZV9mYWN0b3J5ID0gX193X3BkZmpzX3JlcXVpcmVfXygxNDMpOwogICAgICAgICAgICAgICAgOwogICAgICAgICAgICAgICAgY29uc3QgZmV0Y2hEYXRhID0gZnVuY3Rpb24gKHVybCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgUHJvbWlzZSgocmVzb2x2ZSwgcmVqZWN0KSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZzID0gcmVxdWlyZSgiZnMiKTsKICAgICAgICAgICAgICAgICAgICAgICAgZnMucmVhZEZpbGUodXJsLCAoZXJyb3IsIGRhdGEpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChlcnJvciB8fCAhZGF0YSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlamVjdChuZXcgRXJyb3IoZXJyb3IpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXNvbHZlKG5ldyBVaW50OEFycmF5KGRhdGEpKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgY2xhc3MgTm9kZUZpbHRlckZhY3RvcnkgZXh0ZW5kcyBfYmFzZV9mYWN0b3J5LkJhc2VGaWx0ZXJGYWN0b3J5IHt9CiAgICAgICAgICAgICAgICBleHBvcnRzLk5vZGVGaWx0ZXJGYWN0b3J5ID0gTm9kZUZpbHRlckZhY3Rvcnk7CiAgICAgICAgICAgICAgICBjbGFzcyBOb2RlQ2FudmFzRmFjdG9yeSBleHRlbmRzIF9iYXNlX2ZhY3RvcnkuQmFzZUNhbnZhc0ZhY3RvcnkgewogICAgICAgICAgICAgICAgICAgIF9jcmVhdGVDYW52YXMod2lkdGgsIGhlaWdodCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBDYW52YXMgPSByZXF1aXJlKCJjYW52YXMiKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIENhbnZhcy5jcmVhdGVDYW52YXMod2lkdGgsIGhlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5Ob2RlQ2FudmFzRmFjdG9yeSA9IE5vZGVDYW52YXNGYWN0b3J5OwogICAgICAgICAgICAgICAgY2xhc3MgTm9kZUNNYXBSZWFkZXJGYWN0b3J5IGV4dGVuZHMgX2Jhc2VfZmFjdG9yeS5CYXNlQ01hcFJlYWRlckZhY3RvcnkgewogICAgICAgICAgICAgICAgICAgIF9mZXRjaERhdGEodXJsLCBjb21wcmVzc2lvblR5cGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZldGNoRGF0YSh1cmwpLnRoZW4oZGF0YSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNNYXBEYXRhOiBkYXRhLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbXByZXNzaW9uVHlwZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5Ob2RlQ01hcFJlYWRlckZhY3RvcnkgPSBOb2RlQ01hcFJlYWRlckZhY3Rvcnk7CiAgICAgICAgICAgICAgICBjbGFzcyBOb2RlU3RhbmRhcmRGb250RGF0YUZhY3RvcnkgZXh0ZW5kcyBfYmFzZV9mYWN0b3J5LkJhc2VTdGFuZGFyZEZvbnREYXRhRmFjdG9yeSB7CiAgICAgICAgICAgICAgICAgICAgX2ZldGNoRGF0YSh1cmwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZldGNoRGF0YSh1cmwpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGV4cG9ydHMuTm9kZVN0YW5kYXJkRm9udERhdGFGYWN0b3J5ID0gTm9kZVN0YW5kYXJkRm9udERhdGFGYWN0b3J5OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxNTYgKi8KICAgICAgICAgICAgLyoqKi8gKChfX3VudXNlZF93ZWJwYWNrX21vZHVsZSwgZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgICJ1c2Ugc3RyaWN0IjsKCgogICAgICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJfX2VzTW9kdWxlIiwgKHsKICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdHJ1ZQogICAgICAgICAgICAgICAgfSkpOwogICAgICAgICAgICAgICAgZXhwb3J0cy5QREZOb2RlU3RyZWFtID0gdm9pZCAwOwogICAgICAgICAgICAgICAgdmFyIF91dGlsID0gX193X3BkZmpzX3JlcXVpcmVfXygxKTsKICAgICAgICAgICAgICAgIHZhciBfbmV0d29ya191dGlscyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTU3KTsKICAgICAgICAgICAgICAgIDsKICAgICAgICAgICAgICAgIGNvbnN0IGZzID0gcmVxdWlyZSgiZnMiKTsKICAgICAgICAgICAgICAgIGNvbnN0IGh0dHAgPSByZXF1aXJlKCJodHRwIik7CiAgICAgICAgICAgICAgICBjb25zdCBodHRwcyA9IHJlcXVpcmUoImh0dHBzIik7CiAgICAgICAgICAgICAgICBjb25zdCB1cmwgPSByZXF1aXJlKCJ1cmwiKTsKICAgICAgICAgICAgICAgIGNvbnN0IGZpbGVVcmlSZWdleCA9IC9eZmlsZTpcL1wvXC9bYS16QS1aXTpcLy87CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBwYXJzZVVybChzb3VyY2VVcmwpIHsKICAgICAgICAgICAgICAgICAgICBjb25zdCBwYXJzZWRVcmwgPSB1cmwucGFyc2Uoc291cmNlVXJsKTsKICAgICAgICAgICAgICAgICAgICBpZiAocGFyc2VkVXJsLnByb3RvY29sID09PSAiZmlsZToiIHx8IHBhcnNlZFVybC5ob3N0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBwYXJzZWRVcmw7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmICgvXlthLXpdOlsvXFxdL2kudGVzdChzb3VyY2VVcmwpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB1cmwucGFyc2UoYGZpbGU6Ly8vJHtzb3VyY2VVcmx9YCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmICghcGFyc2VkVXJsLmhvc3QpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcGFyc2VkVXJsLnByb3RvY29sID0gImZpbGU6IjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHBhcnNlZFVybDsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNsYXNzIFBERk5vZGVTdHJlYW0gewogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKHNvdXJjZSkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNvdXJjZSA9IHNvdXJjZTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy51cmwgPSBwYXJzZVVybChzb3VyY2UudXJsKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5pc0h0dHAgPSB0aGlzLnVybC5wcm90b2NvbCA9PT0gImh0dHA6IiB8fCB0aGlzLnVybC5wcm90b2NvbCA9PT0gImh0dHBzOiI7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuaXNGc1VybCA9IHRoaXMudXJsLnByb3RvY29sID09PSAiZmlsZToiOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmh0dHBIZWFkZXJzID0gdGhpcy5pc0h0dHAgJiYgc291cmNlLmh0dHBIZWFkZXJzIHx8IHt9OwogICAgICAgICAgICAg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VuZCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZW5kIDw9IHRoaXMuX3Byb2dyZXNzaXZlRGF0YUxlbmd0aCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmFuZ2VSZWFkZXIgPSB0aGlzLmlzRnNVcmwgPyBuZXcgUERGTm9kZVN0cmVhbUZzUmFuZ2VSZWFkZXIodGhpcywgc3RhcnQsIGVuZCkgOiBuZXcgUERGTm9kZVN0cmVhbVJhbmdlUmVhZGVyKHRoaXMsIHN0YXJ0LCBlbmQpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yYW5nZVJlcXVlc3RSZWFkZXJzLnB1c2gocmFuZ2VSZWFkZXIpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gcmFuZ2VSZWFkZXI7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNhbmNlbEFsbFJlcXVlc3RzKHJlYXNvbikgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkX2Z1bGxSZXF1ZXN0UmVhMjsKICAgICAgICAgICAgICAgICAgICAgICAgKF90aGlzJF9mdWxsUmVxdWVzdFJlYTIgPSB0aGlzLl9mdWxsUmVxdWVzdFJlYWRlcikgPT09IG51bGwgfHwgX3RoaXMkX2Z1bGxSZXF1ZXN0UmVhMiA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3RoaXMkX2Z1bGxSZXF1ZXN0UmVhMi5jYW5jZWwocmVhc29uKTsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCByZWFkZXIgb2YgdGhpcy5fcmFuZ2VSZXF1ZXN0UmVhZGVycy5zbGljZSgwKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVhZGVyLmNhbmNlbChyZWFzb24pOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5QREZOb2RlU3RyZWFtID0gUERGTm9kZVN0cmVhbTsKICAgICAgICAgICAgICAgIGNsYXNzIEJhc2VGdWxsUmVhZGVyIHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcihzdHJlYW0pIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fdXJsID0gc3RyZWFtLnVybDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZG9uZSA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9zdG9yZWRFcnJvciA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMub25Qcm9ncmVzcyA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHNvdXJjZSA9IHN0cmVhbS5zb3VyY2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NvbnRlbnRMZW5ndGggPSBzb3VyY2UubGVuZ3RoOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9sb2FkZWQgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9maWxlbmFtZSA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Rpc2FibGVSYW5nZSA9IHNvdXJjZS5kaXNhYmxlUmFuZ2UgfHwgZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JhbmdlQ2h1bmtTaXplID0gc291cmNlLnJhbmdlQ2h1bmtTaXplOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuX3JhbmdlQ2h1bmtTaXplICYmICF0aGlzLl9kaXNhYmxlUmFuZ2UpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Rpc2FibGVSYW5nZSA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5faXNTdHJlYW1pbmdTdXBwb3J0ZWQgPSAhc291cmNlLmRpc2FibGVTdHJlYW07CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2lzUmFuZ2VTdXBwb3J0ZWQgPSAhc291cmNlLmRpc2FibGVSYW5nZTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVhZGFibGVTdHJlYW0gPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yZWFkQ2FwYWJpbGl0eSA9ICgwLCBfdXRpbC5jcmVhdGVQcm9taXNlQ2FwYWJpbGl0eSkoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5faGVhZGVyc0NhcGFiaWxpdHkgPSAoMCwgX3V0aWwuY3JlYXRlUHJvbWlzZUNhcGFiaWxpdHkpKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBoZWFkZXJzUmVhZHkoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9oZWFkZXJzQ2FwYWJpbGl0eS5wcm9taXNlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgZmlsZW5hbWUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9maWxlbmFtZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IGNvbnRlbnRMZW5ndGgoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9jb250ZW50TGVuZ3RoOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgaXNSYW5nZVN1cHBvcnRlZCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX2lzUmFuZ2VTdXBwb3J0ZWQ7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBpc1N0cmVhbWluZ1N1cHBvcnRlZCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX2lzU3RyZWFtaW5nU3VwcG9ydGVkOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBhc3luYyByZWFkKCkgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkb25Qcm9ncmVzczsKICAgICAgICAgICAgICAgICAgICAgICAgYXdhaXQgdGhpcy5fcmVhZENhcGFiaWxpdHkucHJvbWlzZTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuX2RvbmUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHVuZGVmaW5lZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkb25lOiB0cnVlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl9zdG9yZWRFcnJvcikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgdGhpcy5fc3RvcmVkRXJyb3I7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2h1bmsgPSB0aGlzLl9yZWFkYWJsZVN0cmVhbS5yZWFkKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjaHVuayA9PT0gbnVsbCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVhZENhcGFiaWxpdHkgPSAoMCwgX3V0aWwuY3JlYXRlUHJvbWlzZUNhcGFiaWxpdHkpKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5yZWFkKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fbG9hZGVkICs9IGNodW5rLmxlbmd0aDsKICAgICAgICAgICAgICAgICAgICAgICAgKF90aGlzJG9uUHJvZ3Jlc3MgPSB0aGlzLm9uUHJvZ3Jlc3MpID09PSBudWxsIHx8IF90aGlzJG9uUHJvZ3Jlc3MgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF90aGlzJG9uUHJvZ3Jlc3MuY2FsbCh0aGlzLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsb2FkZWQ6IHRoaXMuX2xvYWRlZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRvdGFsOiB0aGlzLl9jb250ZW50TGVuZ3RoCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBidWZmZXIgPSBuZXcgVWludDhBcnJheShjaHVuaykuYnVmZmVyOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IGJ1ZmZlciwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRvbmU6IGZhbHNlCiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNhbmNlbChyZWFzb24pIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLl9yZWFkYWJsZVN0cmVhbSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZXJyb3IocmVhc29uKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yZWFkYWJsZVN0cmVhbS5kZXN0cm95KHJlYXNvbik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9lcnJvcihyZWFzb24pIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc3RvcmVkRXJyb3IgPSByZWFzb247CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlYWRDYXBhYmlsaXR5LnJlc29sdmUoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX3NldFJlYWRhYmxlU3RyZWFtKHJlYWRhYmxlU3RyZWFtKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlYWRhYmxlU3RyZWFtID0gcmVhZGFibGVTdHJlYW07CiAgICAgICAgICAgICAgICAgICAgICAgIHJlYWRhYmxlU3RyZWFtLm9uKCJyZWFkYWJsZSIsICgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlYWRDYXBhYmlsaXR5LnJlc29sdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJlYWRhYmxlU3RyZWFtLm9uKCJlbmQiLCAoKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWFkYWJsZVN0cmVhbS5kZXN0cm95KCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9kb25lID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlYWRDYXBhYmlsaXR5LnJlc29sdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJlYWRhYmxlU3RyZWFtLm9uKCJlcnJvciIsIHJlYXNvbiA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9lcnJvcihyZWFzb24pOwogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLl9pc1N0cmVhbWluZ1N1cHBvcnRlZCAmJiB0aGlzLl9pc1JhbmdlU3VwcG9ydGVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9lcnJvcihuZXcgX3V0aWwuQWJvcnRFeGNlcHRpb24oInN0cmVhbWluZyBpcyBkaXNhYmxlZCIpKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fc3RvcmVkRXJyb3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlYWRhYmxlU3RyZWFtLmRlc3Ryb3kodGhpcy5fc3RvcmVkRXJyb3IpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY2xhc3MgQmFzZVJhbmdlUmVhZGVyIHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcihzdHJlYW0pIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fdXJsID0gc3RyZWFtLnVybDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZG9uZSA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9zdG9yZWRFcnJvciA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMub25Qcm9ncmVzcyA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2xvYWRlZCA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlYWRhYmxlU3RyZWFtID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVhZENhcGFiaWxpdHkgPSAoMCwgX3V0aWwuY3JlYXRlUHJvbWlzZUNhcGFiaWxpdHkpKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHNvdXJjZSA9IHN0cmVhbS5zb3VyY2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2lzU3RyZWFtaW5nU3VwcG9ydGVkID0gIXNvdXJjZS5kaXNhYmxlU3RyZWFtOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgaXNTdHJlYW1pbmdTdXBwb3J0ZWQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9pc1N0cmVhbWluZ1N1cHBvcnRlZDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYXN5bmMgcmVhZCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF90aGlzJG9uUHJvZ3Jlc3MyOwogICAgICAgICAgICAgICAgICAgICAgICBhd2FpdCB0aGlzLl9yZWFkQ2FwYWJpbGl0eS5wcm9taXNlOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fZG9uZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdW5kZWZpbmVkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRvbmU6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuX3N0b3JlZEVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyB0aGlzLl9zdG9yZWRFcnJvcjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjaHVuayA9IHRoaXMuX3JlYWRhYmxlU3RyZWFtLnJlYWQoKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGNodW5rID09PSBudWxsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yZWFkQ2FwYWJpbGl0eSA9ICgwLCBfdXRpbC5jcmVhdGVQcm9taXNlQ2FwYWJpbGl0eSkoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLnJlYWQoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9sb2FkZWQgKz0gY2h1bmsubGVuZ3RoOwogICAgICAgICAgICAgICAgICAgICAgICAoX3RoaXMkb25Qcm9ncmVzczIgPSB0aGlzLm9uUHJvZ3Jlc3MpID09PSBudWxsIHx8IF90aGlzJG9uUHJvZ3Jlc3MyID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRvblByb2dyZXNzMi5jYWxsKHRoaXMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxvYWRlZDogdGhpcy5fbG9hZGVkCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBidWZmZXIgPSBuZXcgVWludDhBcnJheShjaHVuaykuYnVmZmVyOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IGJ1ZmZlciwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRvbmU6IGZhbHNlCiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNhbmNlbChyZWFzb24pIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLl9yZWFkYWJsZVN0cmVhbSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZXJyb3IocmVhc29uKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yZWFkYWJsZVN0cmVhbS5kZXN0cm95KHJlYXNvbik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9lcnJvcihyZWFzb24pIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc3RvcmVkRXJyb3IgPSByZWFzb247CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlYWRDYXBhYmlsaXR5LnJlc29sdmUoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX3NldFJlYWRhYmxlU3RyZWFtKHJlYWRhYmxlU3RyZWFtKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlYWRhYmxlU3RyZWFtID0gcmVhZGFibGVTdHJlYW07CiAgICAgICAgICAgICAgICAgICAgICAgIHJlYWRhYmxlU3RyZWFtLm9uKCJyZWFkYWJsZSIsICgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlYWRDYXBhYmlsaXR5LnJlc29sdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJlYWRhYmxlU3RyZWFtLm9uKCJlbmQiLCAoKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWFkYWJsZVN0cmVhbS5kZXN0cm95KCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9kb25lID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlYWRDYXBhYmlsaXR5LnJlc29sdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJlYWRhYmxlU3RyZWFtLm9uKCJlcnJvciIsIHJlYXNvbiA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9lcnJvcihyZWFzb24pOwogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuX3N0b3JlZEVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yZWFkYWJsZVN0cmVhbS5kZXN0cm95KHRoaXMuX3N0b3JlZEVycm9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGNyZWF0ZVJlcXVlc3RPcHRpb25zKHBhcnNlZFVybCwgaGVhZGVycykgewogICAgICAgICAgICAgICAgICAgIHJldHVybiB7CiAgICAgICAgICAgICAgICAgICAgICAgIHByb3RvY29sOiBwYXJzZWRVcmwucHJvdG9jb2wsCiAgICAgICAgICAgICAgICAgICAgICAgIGF1dGg6IHBhcnNlZFVybC5hdXRoLAogICAgICAgICAgICAgICAgICAgICAgICBob3N0OiBwYXJzZWRVcmwuaG9zdG5hbWUsCiAgICAgICAgICAgICAgICAgICAgICAgIHBvcnQ6IHBhcnNlZFVybC5wb3J0LAogICAgICAgICAgICAgICAgICAgICAgICBwYXRoOiBwYXJzZWRVcmwucGF0aCwKICAgICAgICAgICAgICAgICAgICAgICAgbWV0aG9kOiAiR0VUIiwKICAgICAgICAgICAgICAgICAgICAgICAgaGVhZGVycwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBQREZOb2RlU3RyZWFtRnVsbFJlYWRlciBleHRlbmRzIEJhc2VGdWxsUmVhZGVyIHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcihzdHJlYW0pIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIoc3RyZWFtKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaGFuZGxlUmVzcG9uc2UgPSByZXNwb25zZSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAocmVzcG9uc2Uuc3RhdHVzQ29kZSA9PT0gNDA0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZXJyb3IgPSBuZXcgX3V0aWwuTWlzc2luZ1BERkV4Y2VwdGlvbihgTWlzc2luZyBQREYgIiR7dGhpcy5fdXJsfSIuYCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc3RvcmVkRXJyb3IgPSBlcnJvcjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9oZWFkZXJzQ2FwYWJpbGl0eS5yZWplY3QoZXJyb3IpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2hlYWRlcnNDYXBhYmlsaXR5LnJlc29sdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3NldFJlYWRhYmxlU3RyZWFtKHJlc3BvbnNlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGdldFJlc3BvbnNlSGVhZGVyID0gbmFtZSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX3JlYWRhYmxlU3RyZWFtLmhlYWRlcnNbbmFtZS50b0xvd2VyQ2FzZSgpXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYWxsb3dSYW5nZVJlcXVlc3RzLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN1Z2dlc3RlZExlbmd0aAogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSA9ICgwLCBfbmV0d29ya191dGlscy52YWxpZGF0ZVJhbmdlUmVxdWVzdENhcGFiaWxpdGllcykoewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdldFJlc3BvbnNlSGVhZGVyLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlzSHR0cDogc3RyZWFtLmlzSHR0cCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByYW5nZUNodW5rU2l6ZTogdGhpcy5fcmFuZ2VDaHVua1NpemUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGlzYWJsZVJhbmdlOiB0aGlzLl9kaXNhYmxlUmFuZ2UKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5faXNSYW5nZVN1cHBvcnRlZCA9IGFsbG93UmFuZ2VSZXF1ZXN0czsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NvbnRlbnRMZW5ndGggPSBzdWdnZXN0ZWRMZW5ndGggfHwgdGhpcy5fY29udGVudExlbmd0aDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2ZpbGVuYW1lID0gKDAsIF9uZXR3b3JrX3V0aWxzLmV4dHJhY3RGaWxlbmFtZUZyb21IZWFkZXIpKGdldFJlc3BvbnNlSGVhZGVyKTsKICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVxdWVzdCA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl91cmwucHJvdG9jb2wgPT09ICJodHRwOiIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlcXVlc3QgPSBodHRwLnJlcXVlc3QoY3JlYXRlUmVxdWVzdE9wdGlvbnModGhpcy5fdXJsLCBzdHJlYW0uaHR0cEhlYWRlcnMpLCBoYW5kbGVSZXNwb25zZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yZXF1ZXN0ID0gaHR0cHMucmVxdWVzdChjcmVhdGVSZXF1ZXN0T3B0aW9ucyh0aGlzLl91cmwsIHN0cmVhbS5odHRwSGVhZGVycyksIGhhbmRsZVJlc3BvbnNlKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yZXF1ZXN0Lm9uKCJlcnJvciIsIHJlYXNvbiA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9zdG9yZWRFcnJvciA9IHJlYXNvbjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2hlYWRlcnNDYXBhYmlsaXR5LnJlamVjdChyZWFzb24pOwogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVxdWVzdC5lbmQoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBQREZOb2RlU3RyZWFtUmFuZ2VSZWFkZXIgZXh0ZW5kcyBCYXNlUmFuZ2VSZWFkZXIgewogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKHN0cmVhbSwgc3RhcnQsIGVuZCkgewogICAgICAgICAgICAgICAgICAgICAgICBzdXBlcihzdHJlYW0pOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9odHRwSGVhZGVycyA9IHt9OwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IHByb3BlcnR5IGluIHN0cmVhbS5odHRwSGVhZGVycykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdmFsdWUgPSBzdHJlYW0uaHR0cEhlYWRlcnNbcHJvcGVydHldOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHZhbHVlID09PSB1bmRlZmluZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2h0dHBIZWFkZXJzW3Byb3BlcnR5XSA9IHZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2h0dHBIZWFkZXJzLlJhbmdlID0gYGJ5dGVzPSR7c3RhcnR9LSR7ZW5kIC0gMX1gOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBoYW5kbGVSZXNwb25zZSA9IHJlc3BvbnNlID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChyZXNwb25zZS5zdGF0dXNDb2RlID09PSA0MDQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBlcnJvciA9IG5ldyBfdXRpbC5NaXNzaW5nUERGRXhjZXB0aW9uKGBNaXNzaW5nIFBERiAiJHt0aGlzLl91cmx9Ii5gKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9zdG9yZWRFcnJvciA9IGVycm9yOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3NldFJlYWRhYmxlU3RyZWFtKHJlc3BvbnNlKTsKICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVxdWVzdCA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl91cmwucHJvdG9jb2wgPT09ICJodHRwOiIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlcXVlc3QgPSBodHRwLnJlcXVlc3QoY3JlYXRlUmVxdWVzdE9wdGlvbnModGhpcy5fdXJsLCB0aGlzLl9odHRwSGVhZGVycyksIGhhbmRsZVJlc3BvbnNlKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlcXVlc3QgPSBodHRwcy5yZXF1ZXN0KGNyZWF0ZVJlcXVlc3RPcHRpb25zKHRoaXMuX3VybCwgdGhpcy5faHR0cEhlYWRlcnMpLCBoYW5kbGVSZXNwb25zZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVxdWVzdC5vbigiZXJyb3IiLCByZWFzb24gPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc3RvcmVkRXJyb3IgPSByZWFzb247CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yZXF1ZXN0LmVuZCgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNsYXNzIFBERk5vZGVTdHJlYW1Gc0Z1bGxSZWFkZXIgZXh0ZW5kcyBCYXNlRnVsbFJlYWRlciB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3Ioc3RyZWFtKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHN1cGVyKHN0cmVhbSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBwYXRoID0gZGVjb2RlVVJJQ29tcG9uZW50KHRoaXMuX3VybC5wYXRoKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGZpbGVVcmlSZWdleC50ZXN0KHRoaXMuX3VybC5ocmVmKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGF0aCA9IHBhdGgucmVwbGFjZSgvXlwvLywgIiIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGZzLmxzdGF0KHBhdGgsIChlcnJvciwgc3RhdCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGVycm9yLmNvZGUgPT09ICJFTk9FTlQiKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVycm9yID0gbmV3IF91dGlsLk1pc3NpbmdQREZFeGNlcHRpb24oYE1pc3NpbmcgUERGICIke3BhdGh9Ii5gKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc3RvcmVkRXJyb3IgPSBlcnJvcjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9oZWFkZXJzQ2FwYWJpbGl0eS5yZWplY3QoZXJyb3IpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NvbnRlbnRMZW5ndGggPSBzdGF0LnNpemU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9zZXRSZWFkYWJsZVN0cmVhbShmcy5jcmVhdGVSZWFkU3RyZWFtKHBhdGgpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2hlYWRlcnNDYXBhYmlsaXR5LnJlc29sdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY2xhc3MgUERGTm9kZVN0cmVhbUZzUmFuZ2VSZWFkZXIgZXh0ZW5kcyBCYXNlUmFuZ2VSZWFkZXIgewogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKHN0cmVhbSwgc3RhcnQsIGVuZCkgewogICAgICAgICAgICAgICAgICAgICAgICBzdXBlcihzdHJlYW0pOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgcGF0aCA9IGRlY29kZVVSSUNvbXBvbmVudCh0aGlzLl91cmwucGF0aCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChmaWxlVXJpUmVnZXgudGVzdCh0aGlzLl91cmwuaHJlZikpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhdGggPSBwYXRoLnJlcGxhY2UoL15cLy8sICIiKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9zZXRSZWFkYWJsZVN0cmVhbShmcy5jcmVhdGVSZWFkU3RyZWFtKHBhdGgsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0YXJ0LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgZW5kOiBlbmQgLSAxCiAgICAgICAgICAgICAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDE1NyAqLwogICAgICAgICAgICAvKioqLyAoKF9fdW51c2VkX3dlYnBhY2tfbW9kdWxlLCBleHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKCiAgICAgICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIl9fZXNNb2R1bGUiLCAoewogICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0cnVlCiAgICAgICAgICAgICAgICB9KSk7CiAgICAgICAgICAgICAgICBleHBvcnRzLmNyZWF0ZVJlc3BvbnNlU3RhdHVzRXJyb3IgPSBjcmVhdGVSZXNwb25zZVN0YXR1c0Vycm9yOwogICAgICAgICAgICAgICAgZXhwb3J0cy5leHRyYWN0RmlsZW5hbWVGcm9tSGVhZGVyID0gZXh0cmFjdEZpbGVuYW1lRnJvbUhlYWRlcjsKICAgICAgICAgICAgICAgIGV4cG9ydHMudmFsaWRhdGVSYW5nZVJlcXVlc3RDYXBhYmlsaXRpZXMgPSB2YWxpZGF0ZVJhbmdlUmVxdWVzdENhcGFiaWxpdGllczsKICAgICAgICAgICAgICAgIGV4cG9ydHMudmFsaWRhdGVSZXNwb25zZVN0YXR1cyA9IHZhbGlkYXRlUmVzcG9uc2VTdGF0dXM7CiAgICAgICAgICAgICAgICB2YXIgX3V0aWwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEpOwogICAgICAgICAgICAgICAgdmFyIF9jb250ZW50X2Rpc3Bvc2l0aW9uID0gX193X3BkZmpzX3JlcXVpcmVfXygxNTgpOwogICAgICAgICAgICAgICAgdmFyIF9kaXNwbGF5X3V0aWxzID0gX193X3BkZmpzX3JlcXVpcmVfXygxNDIpOwogICAgICAgICAgICAgICAgZnVuY3Rpb24gdmFsaWRhdGVSYW5nZVJlcXVlc3RDYXBhYmlsaXRpZXMoX3JlZikgewogICAgICAgICAgICAgICAgICAgIGxldCB7CiAgICAgICAgICAgICAgICAgICAgICAgIGdldFJlc3BvbnNlSGVhZGVyLAogICAgICAgICAgICAgICAgICAgICAgICBpc0h0dHAsCiAgICAgICAgICAgICAgICAgICAgICAgIHJhbmdlQ2h1bmtTaXplLAogICAgICAgICAgICAgICAgICAgICAgICBkaXNhYmxlUmFuZ2UKICAgICAgICAgICAgICAgICAgICB9ID0gX3JlZjsKICAgICAgICAgICAgICAgICAgICBjb25zdCByZXR1cm5WYWx1ZXMgPSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGFsbG93UmFuZ2VSZXF1ZXN0czogZmFsc2UsCiAgICAgICAgICAgICAgICAgICAgICAgIHN1Z2dlc3RlZExlbmd0aDogdW5kZWZpbmVkCiAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICBjb25zdCBsZW5ndGggPSBwYXJzZUludChnZXRSZXNwb25zZUhlYWRlcigiQ29udGVudC1MZW5ndGgiKSwgMTApOwogICAgICAgICAgICAgICAgICAgIGlmICghTnVtYmVyLmlzSW50ZWdlcihsZW5ndGgpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiByZXR1cm5WYWx1ZXM7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJldHVyblZhbHVlcy5zdWdnZXN0ZWRMZW5ndGggPSBsZW5ndGg7CiAgICAgICAgICAgICAgICAgICAgaWYgKGxlbmd0aCA8PSAyICogcmFuZ2VDaHVua1NpemUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHJldHVyblZhbHVlczsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaWYgKGRpc2FibGVSYW5nZSB8fCAhaXNIdHRwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiByZXR1cm5WYWx1ZXM7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmIChnZXRSZXNwb25zZUhlYWRlcigiQWNjZXB0LVJhbmdlcyIpICE9PSAiYnl0ZXMiKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiByZXR1cm5WYWx1ZXM7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNvbnN0IGNvbnRlbnRFbmNvZGluZyA9IGdldFJlc3BvbnNlSGVhZGVyKCJDb250ZW50LUVuY29kaW5nIikgfHwgImlkZW50aXR5IjsKICAgICAgICAgICAgICAgICAgICBpZiAoY29udGVudEVuY29kaW5nICE9PSAiaWRlbnRpdHkiKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiByZXR1cm5WYWx1ZXM7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJldHVyblZhbHVlcy5hbGxvd1JhbmdlUmVxdWVzdHMgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgIHJldHVybiByZXR1cm5WYWx1ZXM7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBleHRyYWN0RmlsZW5hbWVGcm9tSGVhZGVyKGdldFJlc3BvbnNlSGVhZGVyKSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgY29udGVudERpc3Bvc2l0aW9uID0gZ2V0UmVzcG9uc2VIZWFkZXIoIkNvbnRlbnQtRGlzcG9zaXRpb24iKTsKICAgICAgICAgICAgICAgICAgICBpZiAoY29udGVudERpc3Bvc2l0aW9uKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBmaWxlbmFtZSA9ICgwLCBfY29udGVudF9kaXNwb3NpdGlvbi5nZXRGaWxlbmFtZUZyb21Db250ZW50RGlzcG9zaXRpb25IZWFkZXIpKGNvbnRlbnREaXNwb3NpdGlvbik7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChmaWxlbmFtZS5pbmNsdWRlcygiJSIpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZpbGVuYW1lID0gZGVjb2RlVVJJQ29tcG9uZW50KGZpbGVuYW1lKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGV4KSB7fQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICgoMCwgX2Rpc3BsYXlfdXRpbHMuaXNQZGZGaWxlKShmaWxlbmFtZSkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmaWxlbmFtZTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGNyZWF0ZVJlc3BvbnNlU3RhdHVzRXJyb3Ioc3RhdHVzLCB1cmwpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoc3RhdHVzID09PSA0MDQgfHwgc3RhdHVzID09PSAwICYmIHVybC5zdGFydHNXaXRoKCJmaWxlOiIpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgX3V0aWwuTWlzc2luZ1BERkV4Y2VwdGlvbignTWlzc2luZyBQREYgIicgKyB1cmwgKyAnIi4nKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG5ldyBfdXRpbC5VbmV4cGVjdGVkUmVzcG9uc2VFeGNlcHRpb24oYFVuZXhwZWN0ZWQgc2VydmVyIHJlc3BvbnNlICgke3N0YXR1c30pIHdoaWxlIHJldHJpZXZpbmcgUERGICIke3VybH0iLmAsIHN0YXR1cyk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiB2YWxpZGF0ZVJlc3BvbnNlU3RhdHVzKHN0YXR1cykgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBzdGF0dXMgPT09IDIwMCB8fCBzdGF0dXMgPT09IDIwNjsKICAgICAgICAgICAgICAgIH0KCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTU4ICovCiAgICAgICAgICAgIC8qKiovICgoX191bnVzZWRfd2VicGFja19tb2R1bGUsIGV4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICAidXNlIHN0cmljdCI7CgoKICAgICAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAiX19lc01vZHVsZSIsICh7CiAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRydWUKICAgICAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuZ2V0RmlsZW5hbWVGcm9tQ29udGVudERpc3Bvc2l0aW9uSGVhZGVyID0gZ2V0RmlsZW5hbWVGcm9tQ29udGVudERpc3Bvc2l0aW9uSGVhZGVyOwogICAgICAgICAgICAgICAgdmFyIF91dGlsID0gX193X3BkZmpzX3JlcXVpcmVfXygxKTsKICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGdldEZpbGVuYW1lRnJvbUNvbnRlbnREaXNwb3NpdGlvbkhlYWRlcihjb250ZW50RGlzcG9zaXRpb24pIHsKICAgICAgICAgICAgICAgICAgICBsZXQgbmVlZHNFbmNvZGluZ0ZpeHVwID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICBsZXQgdG1wID0gdG9QYXJhbVJlZ0V4cCgiZmlsZW5hbWVcXCoiLCAiaSIpLmV4ZWMoY29udGVudERpc3Bvc2l0aW9uKTsKICAgICAgICAgICAgICAgICAgICBpZiAodG1wKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRtcCA9IHRtcFsxXTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGZpbGVuYW1lID0gcmZjMjYxNnVucXVvdGUodG1wKTsKICAgICAgICAgICAgICAgICAgICAgICAgZmlsZW5hbWUgPSB1bmVzY2FwZShmaWxlbmFtZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGZpbGVuYW1lID0gcmZjNTk4N2RlY29kZShmaWxlbmFtZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGZpbGVuYW1lID0gcmZjMjA0N2RlY29kZShmaWxlbmFtZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmaXh1cEVuY29kaW5nKGZpbGVuYW1lKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdG1wID0gcmZjMjIzMWdldHBhcmFtKGNvbnRlbnREaXNwb3NpdGlvbik7CiAgICAgICAgICAgICAgICAgICAgaWYgKHRtcCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBmaWxlbmFtZSA9IHJmYzIwNDdkZWNvZGUodG1wKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZpeHVwRW5jb2RpbmcoZmlsZW5hbWUpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB0bXAgPSB0b1BhcmFtUmVnRXhwKCJmaWxlbmFtZSIsICJpIikuZXhlYyhjb250ZW50RGlzcG9zaXRpb24pOwogICAgICAgICAgICAgICAgICAgIGlmICh0bXApIHsKICAgICAgICAgICAgICAgICAgICAgICAgdG1wID0gdG1wWzFdOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgZmlsZW5hbWUgPSByZmMyNjE2dW5xdW90ZSh0bXApOwogICAgICAgICAgICAgICAgICAgICAgICBmaWxlbmFtZSA9IHJmYzIwNDdkZWNvZGUoZmlsZW5hbWUpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZml4dXBFbmNvZGluZyhmaWxlbmFtZSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGZ1bmN0aW9uIHRvUGFyYW1SZWdFeHAoYXR0cmlidXRlUGF0dGVybiwgZmxhZ3MpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG5ldyBSZWdFeHAoIig/Ol58OylcXHMqIiArIGF0dHJpYnV0ZVBhdHRlcm4gKyAiXFxzKj1cXHMqIiArICIoIiArICdbXiI7XFxzXVteO1xcc10qJyArICJ8IiArICciKD86W14iXFxcXF18XFxcXCI/KSsiPycgKyAiKSIsIGZsYWdzKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZnVuY3Rpb24gdGV4dGRlY29kZShlbmNvZGluZywgdmFsdWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGVuY29kaW5nKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIS9eW1x4MDAtXHhGRl0rJC8udGVzdCh2YWx1ZSkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGRlY29kZXIgPSBuZXcgVGV4dERlY29kZXIoZW5jb2RpbmcsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZmF0YWw6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBidWZmZXIgPSAoMCwgX3V0aWwuc3RyaW5nVG9CeXRlcykodmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlID0gZGVjb2Rlci5kZWNvZGUoYnVmZmVyKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBuZWVkc0VuY29kaW5nRml4dXAgPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHt9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHZhbHVlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBmdW5jdGlvbiBmaXh1cEVuY29kaW5nKHZhbHVlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChuZWVkc0VuY29kaW5nRml4dXAgJiYgL1tceDgwLVx4ZmZdLy50ZXN0KHZhbHVlKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWUgPSB0ZXh0ZGVjb2RlKCJ1dGYtOCIsIHZhbHVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChuZWVkc0VuY29kaW5nRml4dXApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZSA9IHRleHRkZWNvZGUoImlzby04ODU5LTEiLCB2YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHZhbHVlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBmdW5jdGlvbiByZmMyMjMxZ2V0cGFyYW0oY29udGVudERpc3Bvc2l0aW9uU3RyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG1hdGNoZXMgPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IG1hdGNoOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpdGVyID0gdG9QYXJhbVJlZ0V4cCgiZmlsZW5hbWVcXCooKD8hMFxcZClcXGQrKShcXCo/KSIsICJpZyIpOwogICAgICAgICAgICAgICAgICAgICAgICB3aGlsZSAoKG1hdGNoID0gaXRlci5leGVjKGNvbnRlbnREaXNwb3NpdGlvblN0cikpICE9PSBudWxsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgWywgbiwgcXVvdCwgcGFydF0gPSBtYXRjaDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG4gPSBwYXJzZUludChuLCAxMCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAobiBpbiBtYXRjaGVzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG4gPT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgbWF0Y2hlc1tuXSA9IFtxdW90LCBwYXJ0XTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwYXJ0cyA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBuID0gMDsgbiA8IG1hdGNoZXMubGVuZ3RoOyArK24pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghKG4gaW4gbWF0Y2hlcykpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBbcXVvdCwgcGFydF0gPSBtYXRjaGVzW25dOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFydCA9IHJmYzI2MTZ1bnF1b3RlKHBhcnQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHF1b3QpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYXJ0ID0gdW5lc2NhcGUocGFydCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG4gPT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFydCA9IHJmYzU5ODdkZWNvZGUocGFydCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFydHMucHVzaChwYXJ0KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gcGFydHMuam9pbigiIik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGZ1bmN0aW9uIHJmYzI2MTZ1bnF1b3RlKHZhbHVlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh2YWx1ZS5zdGFydHNXaXRoKCciJykpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHBhcnRzID0gdmFsdWUuc2xpY2UoMSkuc3BsaXQoJ1xcIicpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBwYXJ0cy5sZW5ndGg7ICsraSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHF1b3RpbmRleCA9IHBhcnRzW2ldLmluZGV4T2YoJyInKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAocXVvdGluZGV4ICE9PSAtMSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYXJ0c1tpXSA9IHBhcnRzW2ldLnNsaWNlKDAsIHF1b3RpbmRleCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhcnRzLmxlbmd0aCA9IGkgKyAxOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYXJ0c1tpXSA9IHBhcnRzW2ldLnJlcGxhY2VBbGwoL1xcKC4pL2csICIkMSIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWUgPSBwYXJ0cy5qb2luKCciJyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHZhbHVlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBmdW5jdGlvbiByZmM1OTg3ZGVjb2RlKGV4dHZhbHVlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGVuY29kaW5nZW5kID0gZXh0dmFsdWUuaW5kZXhPZigiJyIpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZW5jb2RpbmdlbmQgPT09IC0xKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZXh0dmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZW5jb2RpbmcgPSBleHR2YWx1ZS5zbGljZSgwLCBlbmNvZGluZ2VuZCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGxhbmd2YWx1ZSA9IGV4dHZhbHVlLnNsaWNlKGVuY29kaW5nZW5kICsgMSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHZhbHVlID0gbGFuZ3ZhbHVlLnJlcGxhY2UoL15bXiddKicvLCAiIik7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0ZXh0ZGVjb2RlKGVuY29kaW5nLCB2YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGZ1bmN0aW9uIHJmYzIwNDdkZWNvZGUodmFsdWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF2YWx1ZS5zdGFydHNXaXRoKCI9PyIpIHx8IC9bXHgwMC1ceDE5XHg4MC1ceGZmXS8udGVzdCh2YWx1ZSkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB2YWx1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdmFsdWUucmVwbGFjZUFsbCgvPVw/KFtcdy1dKilcPyhbUXFCYl0pXD8oKD86W14/XXxcPyg/IT0pKSopXD89L2csIGZ1bmN0aW9uIChtYXRjaGVzLCBjaGFyc2V0LCBlbmNvZGluZywgdGV4dCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGVuY29kaW5nID09PSAicSIgfHwgZW5jb2RpbmcgPT09ICJRIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRleHQgPSB0ZXh0LnJlcGxhY2VBbGwoIl8iLCAiICIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRleHQgPSB0ZXh0LnJlcGxhY2VBbGwoLz0oWzAtOWEtZkEtRl17Mn0pL2csIGZ1bmN0aW9uIChtYXRjaCwgaGV4KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBTdHJpbmcuZnJvbUNoYXJDb2RlKHBhcnNlSW50KGhleCwgMTYpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGV4dGRlY29kZShjaGFyc2V0LCB0ZXh0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGV4dCA9IGF0b2IodGV4dCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIChlKSB7fQogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRleHRkZWNvZGUoY2hhcnNldCwgdGV4dCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gIiI7CiAgICAgICAgICAgICAgICB9CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDE1OSAqLwogICAgICAgICAgICAvKioqLyAoKF9fdW51c2VkX3dlYnBhY2tfbW9kdWxlLCBleHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKCiAgICAgICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIl9fZXNNb2R1bGUiLCAoewogICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0cnVlCiAgICAgICAgICAgICAgICB9KSk7CiAgICAgICAgICAgICAgICBleHBvcnRzLlBERk5ldHdvcmtTdHJlYW0gPSB2b2lkIDA7CiAgICAgICAgICAgICAgICB2YXIgX3V0aWwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEpOwogICAgICAgICAgICAgICAgdmFyIF9uZXR3b3JrX3V0aWxzID0gX193X3BkZmpzX3JlcXVpcmVfXygxNTcpOwogICAgICAgICAgICAgICAgOwogICAgICAgICAgICAgICAgY29uc3QgT0tfUkVTUE9OU0UgPSAyMDA7CiAgICAgICAgICAgICAgICBjb25zdCBQQVJUSUFMX0NPTlRFTlRfUkVTUE9OU0UgPSAyMDY7CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBnZXRBcnJheUJ1ZmZlcih4aHIpIHsKICAgICAgICAgICAgICAgICAgICBjb25zdCBkYXRhID0geGhyLnJlc3BvbnNlOwogICAgICAgICAgICAgICAgICAgIGlmICh0eXBlb2YgZGF0YSAhPT0gInN0cmluZyIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGRhdGE7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJldHVybiAoMCwgX3V0aWwuc3RyaW5nVG9CeXRlcykoZGF0YSkuYnVmZmVyOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY2xhc3MgTmV0d29ya01hbmFnZXIgewogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKHVybCkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgYXJncyA9IGFyZ3VtZW50cy5sZW5ndGggPiAxICYmIGFyZ3VtZW50c1sxXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzFdIDoge307CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudXJsID0gdXJsOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmlzSHR0cCA9IC9eaHR0cHM/Oi9pLnRlc3QodXJsKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5odHRwSGVhZGVycyA9IHRoaXMuaXNIdHRwICYmIGFyZ3MuaHR0cEhlYWRlcnMgfHwgT2JqZWN0LmNyZWF0ZShudWxsKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy53aXRoQ3JlZGVudGlhbHMgPSBhcmdzLndpdGhDcmVkZW50aWFscyB8fCBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5nZXRYaHIgPSBhcmdzLmdldFhociB8fCBmdW5jdGlvbiBOZXR3b3JrTWFuYWdlcl9nZXRYaHIoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IFhNTEh0dHBSZXF1ZXN0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VyclhocklkID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wZW5kaW5nUmVxdWVzdHMgPSBPYmplY3QuY3JlYXRlKG51bGwpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXF1ZXN0UmFuZ2UoYmVnaW4sIGVuZCwgbGlzdGVuZXJzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGFyZ3MgPSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBiZWdpbiwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVuZAogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IHByb3AgaW4gbGlzdGVuZXJzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhcmdzW3Byb3BdID0gbGlzdGVuZXJzW3Byb3BdOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLnJlcXVlc3QoYXJncyk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlcXVlc3RGdWxsKGxpc3RlbmVycykgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5yZXF1ZXN0KGxpc3RlbmVycyk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlcXVlc3QoYXJncykgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB4aHIgPSB0aGlzLmdldFhocigpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB4aHJJZCA9IHRoaXMuY3VyclhocklkKys7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHBlbmRpbmdSZXF1ZXN0ID0gdGhpcy5wZW5kaW5nUmVxdWVzdHNbeGhySWRdID0gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgeGhyCiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgIHhoci5vcGVuKCJHRVQiLCB0aGlzLnVybCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHhoci53aXRoQ3JlZGVudGlhbHMgPSB0aGlzLndpdGhDcmVkZW50aWFsczsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBwcm9wZXJ0eSBpbiB0aGlzLmh0dHBIZWFkZXJzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB2YWx1ZSA9IHRoaXMuaHR0cEhlYWRlcnNbcHJvcGVydHldOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHZhbHVlID09PSB1bmRlZmluZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHhoci5zZXRSZXF1ZXN0SGVhZGVyKHByb3BlcnR5LCB2YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuaXNIdHRwICYmICJiZWdpbiIgaW4gYXJncyAmJiAiZW5kIiBpbiBhcmdzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB4aHIuc2V0UmVxdWVzdEhlYWRlcigiUmFuZ2UiLCBgYnl0ZXM9JHthcmdzLmJlZ2lufS0ke2FyZ3MuZW5kIC0gMX1gKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBlbmRpbmdSZXF1ZXN0LmV4cGVjdGVkU3RhdHVzID0gUEFSVElBTF9DT05URU5UX1JFU1BPTlNFOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGVuZGluZ1JlcXVlc3QuZXhwZWN0ZWRTdGF0dXMgPSBPS19SRVNQT05TRTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB4aHIucmVzcG9uc2VUeXBlID0gImFycmF5YnVmZmVyIjsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGFyZ3Mub25FcnJvcikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgeGhyLm9uZXJyb3IgPSBmdW5jdGlvbiAoZXZ0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYXJncy5vbkVycm9yKHhoci5zdGF0dXMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB4aHIub25yZWFkeXN0YXRlY2hhbmdlID0gdGhpcy5vblN0YXRlQ2hhbmdlLmJpbmQodGhpcywgeGhySWQpOwogICAgICAgICAgICAgICAgICAgICAgICB4aHIub25wcm9ncmVzcyA9IHRoaXMub25Qcm9ncmVzcy5iaW5kKHRoaXMsIHhocklkKTsKICAgICAgICAgICAgICAgICAgICAgICAgcGVuZGluZ1JlcXVlc3Qub25IZWFkZXJzUmVjZWl2ZWQgPSBhcmdzLm9uSGVhZGVyc1JlY2VpdmVkOwogICAgICAgICAgICAgICAgICAgICAgICBwZW5kaW5nUmVxdWVzdC5vbkRvbmUgPSBhcmdzLm9uRG9uZTsKICAgICAgICAgICAgICAgICAgICAgICAgcGVuZGluZ1JlcXVlc3Qub25FcnJvciA9IGFyZ3Mub25FcnJvcjsKICAgICAgICAgICAgICAgICAgICAgICAgcGVuZGluZ1JlcXVlc3Qub25Qcm9ncmVzcyA9IGFyZ3Mub25Qcm9ncmVzczsKICAgICAgICAgICAgICAgICAgICAgICAgeGhyLnNlbmQobnVsbCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB4aHJJZDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgb25Qcm9ncmVzcyh4aHJJZCwgZXZ0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfcGVuZGluZ1JlcXVlc3Qkb25Qcm87CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHBlbmRpbmdSZXF1ZXN0ID0gdGhpcy5wZW5kaW5nUmVxdWVzdHNbeGhySWRdOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXBlbmRpbmdSZXF1ZXN0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgKF9wZW5kaW5nUmVxdWVzdCRvblBybyA9IHBlbmRpbmdSZXF1ZXN0Lm9uUHJvZ3Jlc3MpID09PSBudWxsIHx8IF9wZW5kaW5nUmVxdWVzdCRvblBybyA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3BlbmRpbmdSZXF1ZXN0JG9uUHJvLmNhbGwocGVuZGluZ1JlcXVlc3QsIGV2dCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIG9uU3RhdGVDaGFuZ2UoeGhySWQsIGV2dCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwZW5kaW5nUmVxdWVzdCA9IHRoaXMucGVuZGluZ1JlcXVlc3RzW3hocklkXTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFwZW5kaW5nUmVxdWVzdCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHhociA9IHBlbmRpbmdSZXF1ZXN0LnhocjsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHhoci5yZWFkeVN0YXRlID49IDIgJiYgcGVuZGluZ1JlcXVlc3Qub25IZWFkZXJzUmVjZWl2ZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBlbmRpbmdSZXF1ZXN0Lm9uSGVhZGVyc1JlY2VpdmVkKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWxldGUgcGVuZGluZ1JlcXVlc3Qub25IZWFkZXJzUmVjZWl2ZWQ7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHhoci5yZWFkeVN0YXRlICE9PSA0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCEoeGhySWQgaW4gdGhpcy5wZW5kaW5nUmVxdWVzdHMpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgZGVsZXRlIHRoaXMucGVuZGluZ1JlcXVlc3RzW3hocklkXTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHhoci5zdGF0dXMgPT09IDAgJiYgdGhpcy5pc0h0dHApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfcGVuZGluZ1JlcXVlc3Qkb25FcnI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAoX3BlbmRpbmdSZXF1ZXN0JG9uRXJyID0gcGVuZGluZ1JlcXVlc3Qub25FcnJvcikgPT09IG51bGwgfHwgX3BlbmRpbmdSZXF1ZXN0JG9uRXJyID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfcGVuZGluZ1JlcXVlc3Qkb25FcnIuY2FsbChwZW5kaW5nUmVxdWVzdCwgeGhyLnN0YXR1cyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgeGhyU3RhdHVzID0geGhyLnN0YXR1cyB8fCBPS19SRVNQT05TRTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgb2tfcmVzcG9uc2Vfb25fcmFuZ2VfcmVxdWVzdCA9IHhoclN0YXR1cyA9PT0gT0tfUkVTUE9OU0UgJiYgcGVuZGluZ1JlcXVlc3QuZXhwZWN0ZWRTdGF0dXMgPT09IFBBUlRJQUxfQ09OVEVOVF9SRVNQT05TRTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFva19yZXNwb25zZV9vbl9yYW5nZV9yZXF1ZXN0ICYmIHhoclN0YXR1cyAhPT0gcGVuZGluZ1JlcXVlc3QuZXhwZWN0ZWRTdGF0dXMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfcGVuZGluZ1JlcXVlc3Qkb25FcnIyOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgKF9wZW5kaW5nUmVxdWVzdCRvbkVycjIgPSBwZW5kaW5nUmVxdWVzdC5vbkVycm9yKSA9PT0gbnVsbCB8fCBfcGVuZGluZ1JlcXVlc3Qkb25FcnIyID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfcGVuZGluZ1JlcXVlc3Qkb25FcnIyLmNhbGwocGVuZGluZ1JlcXVlc3QsIHhoci5zdGF0dXMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNodW5rID0gZ2V0QXJyYXlCdWZmZXIoeGhyKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHhoclN0YXR1cyA9PT0gUEFSVElBTF9DT05URU5UX1JFU1BPTlNFKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByYW5nZUhlYWRlciA9IHhoci5nZXRSZXNwb25zZUhlYWRlcigiQ29udGVudC1SYW5nZSIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbWF0Y2hlcyA9IC9ieXRlcyAoXGQrKS0oXGQrKVwvKFxkKykvLmV4ZWMocmFuZ2VIZWFkZXIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGVuZGluZ1JlcXVlc3Qub25Eb25lKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBiZWdpbjogcGFyc2VJbnQobWF0Y2hlc1sxXSwgMTApLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNodW5rCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChjaHVuaykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGVuZGluZ1JlcXVlc3Qub25Eb25lKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBiZWdpbjogMCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjaHVuawogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3BlbmRpbmdSZXF1ZXN0JG9uRXJyMzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIChfcGVuZGluZ1JlcXVlc3Qkb25FcnIzID0gcGVuZGluZ1JlcXVlc3Qub25FcnJvcikgPT09IG51bGwgfHwgX3BlbmRpbmdSZXF1ZXN0JG9uRXJyMyA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3BlbmRpbmdSZXF1ZXN0JG9uRXJyMy5jYWxsKHBlbmRpbmdSZXF1ZXN0LCB4aHIuc3RhdHVzKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRSZXF1ZXN0WGhyKHhocklkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLnBlbmRpbmdSZXF1ZXN0c1t4aHJJZF0ueGhyOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBpc1BlbmRpbmdSZXF1ZXN0KHhocklkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB4aHJJZCBpbiB0aGlzLnBlbmRpbmdSZXF1ZXN0czsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYWJvcnRSZXF1ZXN0KHhocklkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHhociA9IHRoaXMucGVuZGluZ1JlcXVlc3RzW3hocklkXS54aHI7CiAgICAgICAgICAgICAgICAgICAgICAgIGRlbGV0ZSB0aGlzLnBlbmRpbmdSZXF1ZXN0c1t4aHJJZF07CiAgICAgICAgICAgICAgICAgICAgICAgIHhoci5hYm9ydCgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNsYXNzIFBERk5ldHdvcmtTdHJlYW0gewogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKHNvdXJjZSkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9zb3VyY2UgPSBzb3VyY2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX21hbmFnZXIgPSBuZXcgTmV0d29ya01hbmFnZXIoc291cmNlLnVybCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaHR0cEhlYWRlcnM6IHNvdXJjZS5odHRwSGVhZGVycywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdpdGhDcmVkZW50aWFsczogc291cmNlLndpdGhDcmVkZW50aWFscwogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmFuZ2VDaHVua1NpemUgPSBzb3VyY2UucmFuZ2VDaHVua1NpemU7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Z1bGxSZXF1ZXN0UmVhZGVyID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmFuZ2VSZXF1ZXN0UmVhZGVycyA9IFtdOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfb25SYW5nZVJlcXVlc3RSZWFkZXJDbG9zZWQocmVhZGVyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGkgPSB0aGlzLl9yYW5nZVJlcXVlc3RSZWFkZXJzLmluZGV4T2YocmVhZGVyKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGkgPj0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmFuZ2VSZXF1ZXN0UmVhZGVycy5zcGxpY2UoaSwgMSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0RnVsbFJlYWRlcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLmFzc2VydCkoIXRoaXMuX2Z1bGxSZXF1ZXN0UmVhZGVyLCAiUERGTmV0d29ya1N0cmVhbS5nZXRGdWxsUmVhZGVyIGNhbiBvbmx5IGJlIGNhbGxlZCBvbmNlLiIpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9mdWxsUmVxdWVzdFJlYWRlciA9IG5ldyBQREZOZXR3b3JrU3RyZWFtRnVsbFJlcXVlc3RSZWFkZXIodGhpcy5fbWFuYWdlciwgdGhpcy5fc291cmNlKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX2Z1bGxSZXF1ZXN0UmVhZGVyOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRSYW5nZVJlYWRlcihiZWdpbiwgZW5kKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHJlYWRlciA9IG5ldyBQREZOZXR3b3JrU3RyZWFtUmFuZ2VSZXF1ZXN0UmVhZGVyKHRoaXMuX21hbmFnZXIsIGJlZ2luLCBlbmQpOwogICAgICAgICAgICAgICAgICAgICAgICByZWFkZXIub25DbG9zZWQgPSB0aGlzLl9vblJhbmdlUmVxdWVzdFJlYWRlckNsb3NlZC5iaW5kKHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yYW5nZVJlcXVlc3RSZWFkZXJzLnB1c2gocmVhZGVyKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHJlYWRlcjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY2FuY2VsQWxsUmVxdWVzdHMocmVhc29uKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRfZnVsbFJlcXVlc3RSZWE7CiAgICAgICAgICAgICAgICAgICAgICAgIChfdGhpcyRfZnVsbFJlcXVlc3RSZWEgPSB0aGlzLl9mdWxsUmVxdWVzdFJlYWRlcikgPT09IG51bGwgfHwgX3RoaXMkX2Z1bGxSZXF1ZXN0UmVhID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRfZnVsbFJlcXVlc3RSZWEuY2FuY2VsKHJlYXNvbik7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgcmVhZGVyIG9mIHRoaXMuX3JhbmdlUmVxdWVzdFJlYWRlcnMuc2xpY2UoMCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlYWRlci5jYW5jZWwocmVhc29uKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGV4cG9ydHMuUERGTmV0d29ya1N0cmVhbSA9IFBERk5ldHdvcmtTdHJlYW07CiAgICAgICAgICAgICAgICBjbGFzcyBQREZOZXR3b3JrU3RyZWFtRnVsbFJlcXVlc3RSZWFkZXIgewogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKG1hbmFnZXIsIHNvdXJjZSkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9tYW5hZ2VyID0gbWFuYWdlcjsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYXJncyA9IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9uSGVhZGVyc1JlY2VpdmVkOiB0aGlzLl9vbkhlYWRlcnNSZWNlaXZlZC5iaW5kKHRoaXMpLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgb25Eb25lOiB0aGlzLl9vbkRvbmUuYmluZCh0aGlzKSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9uRXJyb3I6IHRoaXMuX29uRXJyb3IuYmluZCh0aGlzKSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9uUHJvZ3Jlc3M6IHRoaXMuX29uUHJvZ3Jlc3MuYmluZCh0aGlzKQogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl91cmwgPSBzb3VyY2UudXJsOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9mdWxsUmVxdWVzdElkID0gbWFuYWdlci5yZXF1ZXN0RnVsbChhcmdzKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5faGVhZGVyc1JlY2VpdmVkQ2FwYWJpbGl0eSA9ICgwLCBfdXRpbC5jcmVhdGVQcm9taXNlQ2FwYWJpbGl0eSkoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZGlzYWJsZVJhbmdlID0gc291cmNlLmRpc2FibGVSYW5nZSB8fCBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fY29udGVudExlbmd0aCA9IHNvdXJjZS5sZW5ndGg7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JhbmdlQ2h1bmtTaXplID0gc291cmNlLnJhbmdlQ2h1bmtTaXplOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuX3JhbmdlQ2h1bmtTaXplICYmICF0aGlzLl9kaXNhYmxlUmFuZ2UpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Rpc2FibGVSYW5nZSA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5faXNTdHJlYW1pbmdTdXBwb3J0ZWQgPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5faXNSYW5nZVN1cHBvcnRlZCA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jYWNoZWRDaHVua3MgPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVxdWVzdHMgPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZG9uZSA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9zdG9yZWRFcnJvciA9IHVuZGVmaW5lZDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZmlsZW5hbWUgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm9uUHJvZ3Jlc3MgPSBudWxsOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfb25IZWFkZXJzUmVjZWl2ZWQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZ1bGxSZXF1ZXN0WGhySWQgPSB0aGlzLl9mdWxsUmVxdWVzdElkOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBmdWxsUmVxdWVzdFhociA9IHRoaXMuX21hbmFnZXIuZ2V0UmVxdWVzdFhocihmdWxsUmVxdWVzdFhocklkKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZ2V0UmVzcG9uc2VIZWFkZXIgPSBuYW1lID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmdWxsUmVxdWVzdFhoci5nZXRSZXNwb25zZUhlYWRlcihuYW1lKTsKICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgYWxsb3dSYW5nZVJlcXVlc3RzLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3VnZ2VzdGVkTGVuZ3RoCiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSAoMCwgX25ldHdvcmtfdXRpbHMudmFsaWRhdGVSYW5nZVJlcXVlc3RDYXBhYmlsaXRpZXMpKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdldFJlc3BvbnNlSGVhZGVyLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNIdHRwOiB0aGlzLl9tYW5hZ2VyLmlzSHR0cCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJhbmdlQ2h1bmtTaXplOiB0aGlzLl9yYW5nZUNodW5rU2l6ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRpc2FibGVSYW5nZTogdGhpcy5fZGlzYWJsZVJhbmdlCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoYWxsb3dSYW5nZVJlcXVlc3RzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9pc1JhbmdlU3VwcG9ydGVkID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jb250ZW50TGVuZ3RoID0gc3VnZ2VzdGVkTGVuZ3RoIHx8IHRoaXMuX2NvbnRlbnRMZW5ndGg7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2ZpbGVuYW1lID0gKDAsIF9uZXR3b3JrX3V0aWxzLmV4dHJhY3RGaWxlbmFtZUZyb21IZWFkZXIpKGdldFJlc3BvbnNlSGVhZGVyKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuX2lzUmFuZ2VTdXBwb3J0ZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX21hbmFnZXIuYWJvcnRSZXF1ZXN0KGZ1bGxSZXF1ZXN0WGhySWQpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2hlYWRlcnNSZWNlaXZlZENhcGFiaWxpdHkucmVzb2x2ZSgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfb25Eb25lKGRhdGEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGRhdGEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl9yZXF1ZXN0cy5sZW5ndGggPiAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmVxdWVzdENhcGFiaWxpdHkgPSB0aGlzLl9yZXF1ZXN0cy5zaGlmdCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlcXVlc3RDYXBhYmlsaXR5LnJlc29sdmUoewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogZGF0YS5jaHVuaywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZG9uZTogZmFsc2UKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fY2FjaGVkQ2h1bmtzLnB1c2goZGF0YS5jaHVuayk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZG9uZSA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl9jYWNoZWRDaHVua3MubGVuZ3RoID4gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgcmVxdWVzdENhcGFiaWxpdHkgb2YgdGhpcy5fcmVxdWVzdHMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlcXVlc3RDYXBhYmlsaXR5LnJlc29sdmUoewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiB1bmRlZmluZWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZG9uZTogdHJ1ZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVxdWVzdHMubGVuZ3RoID0gMDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX29uRXJyb3Ioc3RhdHVzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3N0b3JlZEVycm9yID0gKDAsIF9uZXR3b3JrX3V0aWxzLmNyZWF0ZVJlc3BvbnNlU3RhdHVzRXJyb3IpKHN0YXR1cywgdGhpcy5fdXJsKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5faGVhZGVyc1JlY2VpdmVkQ2FwYWJpbGl0eS5yZWplY3QodGhpcy5fc3RvcmVkRXJyb3IpOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IHJlcXVlc3RDYXBhYmlsaXR5IG9mIHRoaXMuX3JlcXVlc3RzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXF1ZXN0Q2FwYWJpbGl0eS5yZWplY3QodGhpcy5fc3RvcmVkRXJyb3IpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlcXVlc3RzLmxlbmd0aCA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NhY2hlZENodW5rcy5sZW5ndGggPSAwOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfb25Qcm9ncmVzcyhldnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF90aGlzJG9uUHJvZ3Jlc3M7CiAgICAgICAgICAgICAgICAgICAgICAgIChfdGhpcyRvblByb2dyZXNzID0gdGhpcy5vblByb2dyZXNzKSA9PT0gbnVsbCB8fCBfdGhpcyRvblByb2dyZXNzID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRvblByb2dyZXNzLmNhbGwodGhpcywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgbG9hZGVkOiBldnQubG9hZGVkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdG90YWw6IGV2dC5sZW5ndGhDb21wdXRhYmxlID8gZXZ0LnRvdGFsIDogdGhpcy5fY29udGVudExlbmd0aAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IGZpbGVuYW1lKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fZmlsZW5hbWU7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBpc1JhbmdlU3VwcG9ydGVkKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5faXNSYW5nZVN1cHBvcnRlZDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IGlzU3RyZWFtaW5nU3VwcG9ydGVkKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5faXNTdHJlYW1pbmdTdXBwb3J0ZWQ7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBjb250ZW50TGVuZ3RoKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fY29udGVudExlbmd0aDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IGhlYWRlcnNSZWFkeSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX2hlYWRlcnNSZWNlaXZlZENhcGFiaWxpdHkucHJvbWlzZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYXN5bmMgcmVhZCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuX3N0b3JlZEVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyB0aGlzLl9zdG9yZWRFcnJvcjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fY2FjaGVkQ2h1bmtzLmxlbmd0aCA+IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNodW5rID0gdGhpcy5fY2FjaGVkQ2h1bmtzLnNoaWZ0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBjaHVuaywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkb25lOiBmYWxzZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fZG9uZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdW5kZWZpbmVkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRvbmU6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmVxdWVzdENhcGFiaWxpdHkgPSAoMCwgX3V0aWwuY3JlYXRlUHJvbWlzZUNhcGFiaWxpdHkpKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlcXVlc3RzLnB1c2gocmVxdWVzdENhcGFiaWxpdHkpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gcmVxdWVzdENhcGFiaWxpdHkucHJvbWlzZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY2FuY2VsKHJlYXNvbikgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9kb25lID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5faGVhZGVyc1JlY2VpdmVkQ2FwYWJpbGl0eS5yZWplY3QocmVhc29uKTsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCByZXF1ZXN0Q2FwYWJpbGl0eSBvZiB0aGlzLl9yZXF1ZXN0cykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVxdWVzdENhcGFiaWxpdHkucmVzb2x2ZSh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHVuZGVmaW5lZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkb25lOiB0cnVlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yZXF1ZXN0cy5sZW5ndGggPSAwOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fbWFuYWdlci5pc1BlbmRpbmdSZXF1ZXN0KHRoaXMuX2Z1bGxSZXF1ZXN0SWQpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9tYW5hZ2VyLmFib3J0UmVxdWVzdCh0aGlzLl9mdWxsUmVxdWVzdElkKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9mdWxsUmVxdWVzdFJlYWRlciA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY2xhc3MgUERGTmV0d29ya1N0cmVhbVJhbmdlUmVxdWVzdFJlYWRlciB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IobWFuYWdlciwgYmVnaW4sIGVuZCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9tYW5hZ2VyID0gbWFuYWdlcjsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYXJncyA9IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9uRG9uZTogdGhpcy5fb25Eb25lLmJpbmQodGhpcyksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvbkVycm9yOiB0aGlzLl9vbkVycm9yLmJpbmQodGhpcyksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvblByb2dyZXNzOiB0aGlzLl9vblByb2dyZXNzLmJpbmQodGhpcykKICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fdXJsID0gbWFuYWdlci51cmw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlcXVlc3RJZCA9IG1hbmFnZXIucmVxdWVzdFJhbmdlKGJlZ2luLCBlbmQsIGFyZ3MpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yZXF1ZXN0cyA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9xdWV1ZWRDaHVuayA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2RvbmUgPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc3RvcmVkRXJyb3IgPSB1bmRlZmluZWQ7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMub25Qcm9ncmVzcyA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMub25DbG9zZWQgPSBudWxsOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfY2xvc2UoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRvbkNsb3NlZDsKICAgICAgICAgICAgICAgICAgICAgICAgKF90aGlzJG9uQ2xvc2VkID0gdGhpcy5vbkNsb3NlZCkgPT09IG51bGwgfHwgX3RoaXMkb25DbG9zZWQgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF90aGlzJG9uQ2xvc2VkLmNhbGwodGhpcywgdGhpcyk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9vbkRvbmUoZGF0YSkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjaHVuayA9IGRhdGEuY2h1bms7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl9yZXF1ZXN0cy5sZW5ndGggPiAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByZXF1ZXN0Q2FwYWJpbGl0eSA9IHRoaXMuX3JlcXVlc3RzLnNoaWZ0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXF1ZXN0Q2FwYWJpbGl0eS5yZXNvbHZlKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogY2h1bmssCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZG9uZTogZmFsc2UKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcXVldWVkQ2h1bmsgPSBjaHVuazsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9kb25lID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCByZXF1ZXN0Q2FwYWJpbGl0eSBvZiB0aGlzLl9yZXF1ZXN0cykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVxdWVzdENhcGFiaWxpdHkucmVzb2x2ZSh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHVuZGVmaW5lZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkb25lOiB0cnVlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yZXF1ZXN0cy5sZW5ndGggPSAwOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jbG9zZSgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfb25FcnJvcihzdGF0dXMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc3RvcmVkRXJyb3IgPSAoMCwgX25ldHdvcmtfdXRpbHMuY3JlYXRlUmVzcG9uc2VTdGF0dXNFcnJvcikoc3RhdHVzLCB0aGlzLl91cmwpOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IHJlcXVlc3RDYXBhYmlsaXR5IG9mIHRoaXMuX3JlcXVlc3RzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXF1ZXN0Q2FwYWJpbGl0eS5yZWplY3QodGhpcy5fc3RvcmVkRXJyb3IpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlcXVlc3RzLmxlbmd0aCA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3F1ZXVlZENodW5rID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX29uUHJvZ3Jlc3MoZXZ0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5pc1N0cmVhbWluZ1N1cHBvcnRlZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF90aGlzJG9uUHJvZ3Jlc3MyOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgKF90aGlzJG9uUHJvZ3Jlc3MyID0gdGhpcy5vblByb2dyZXNzKSA9PT0gbnVsbCB8fCBfdGhpcyRvblByb2dyZXNzMiA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3RoaXMkb25Qcm9ncmVzczIuY2FsbCh0aGlzLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbG9hZGVkOiBldnQubG9hZGVkCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgaXNTdHJlYW1pbmdTdXBwb3J0ZWQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYXN5bmMgcmVhZCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuX3N0b3JlZEVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyB0aGlzLl9zdG9yZWRFcnJvcjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fcXVldWVkQ2h1bmsgIT09IG51bGwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNodW5rID0gdGhpcy5fcXVldWVkQ2h1bms7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9xdWV1ZWRDaHVuayA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBjaHVuaywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkb25lOiBmYWxzZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fZG9uZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdW5kZWZpbmVkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRvbmU6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmVxdWVzdENhcGFiaWxpdHkgPSAoMCwgX3V0aWwuY3JlYXRlUHJvbWlzZUNhcGFiaWxpdHkpKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlcXVlc3RzLnB1c2gocmVxdWVzdENhcGFiaWxpdHkpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gcmVxdWVzdENhcGFiaWxpdHkucHJvbWlzZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY2FuY2VsKHJlYXNvbikgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9kb25lID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCByZXF1ZXN0Q2FwYWJpbGl0eSBvZiB0aGlzLl9yZXF1ZXN0cykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVxdWVzdENhcGFiaWxpdHkucmVzb2x2ZSh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHVuZGVmaW5lZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkb25lOiB0cnVlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yZXF1ZXN0cy5sZW5ndGggPSAwOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fbWFuYWdlci5pc1BlbmRpbmdSZXF1ZXN0KHRoaXMuX3JlcXVlc3RJZCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX21hbmFnZXIuYWJvcnRSZXF1ZXN0KHRoaXMuX3JlcXVlc3RJZCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fY2xvc2UoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDE2MCAqLwogICAgICAgICAgICAvKioqLyAoKF9fdW51c2VkX3dlYnBhY2tfbW9kdWxlLCBleHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKCiAgICAgICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIl9fZXNNb2R1bGUiLCAoewogICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0cnVlCiAgICAgICAgICAgICAgICB9KSk7CiAgICAgICAgICAgICAgICBleHBvcnRzLlBERkZldGNoU3RyZWFtID0gdm9pZCAwOwogICAgICAgICAgICAgICAgdmFyIF91dGlsID0gX193X3BkZmpzX3JlcXVpcmVfXygxKTsKICAgICAgICAgICAgICAgIHZhciBfbmV0d29ya191dGlscyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTU3KTsKICAgICAgICAgICAgICAgIDsKICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGNyZWF0ZUZldGNoT3B0aW9ucyhoZWFkZXJzLCB3aXRoQ3JlZGVudGlhbHMsIGFib3J0Q29udHJvbGxlcikgewogICAgICAgICAgICAgICAgICAgIHJldHVybiB7CiAgICAgICAgICAgICAgICAgICAgICAgIG1ldGhvZDogIkdFVCIsCiAgICAgICAgICAgICAgICAgICAgICAgIGhlYWRlcnMsCiAgICAgICAgICAgICAgICAgICAgICAgIHNpZ25hbDogYWJvcnRDb250cm9sbGVyLnNpZ25hbCwKICAgICAgICAgICAgICAgICAgICAgICAgbW9kZTogImNvcnMiLAogICAgICAgICAgICAgICAgICAgICAgICBjcmVkZW50aWFsczogd2l0aENyZWRlbnRpYWxzID8gImluY2x1ZGUiIDogInNhbWUtb3JpZ2luIiwKICAgICAgICAgICAgICAgICAgICAgICAgcmVkaXJlY3Q6ICJmb2xsb3ciCiAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGNyZWF0ZUhlYWRlcnMoaHR0cEhlYWRlcnMpIHsKICAgICAgICAgICAgICAgICAgICBjb25zdCBoZWFkZXJzID0gbmV3IEhlYWRlcnMoKTsKICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IHByb3BlcnR5IGluIGh0dHBIZWFkZXJzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHZhbHVlID0gaHR0cEhlYWRlcnNbcHJvcGVydHldOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAodmFsdWUgPT09IHVuZGVmaW5lZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaGVhZGVycy5hcHBlbmQocHJvcGVydHksIHZhbHVlKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGhlYWRlcnM7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBnZXRBcnJheUJ1ZmZlcih2YWwpIHsKICAgICAgICAgICAgICAgICAgICBpZiAodmFsIGluc3RhbmNlb2YgVWludDhBcnJheSkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdmFsLmJ1ZmZlcjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaWYgKHZhbCBpbnN0YW5jZW9mIEFycmF5QnVmZmVyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB2YWw7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgZ2V0QXJyYXlCdWZmZXIgLSB1bmV4cGVjdGVkIGRhdGEgZm9ybWF0OiAke3ZhbH1gKTsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IFVpbnQ4QXJyYXkodmFsKS5idWZmZXI7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBQREZGZXRjaFN0cmVhbSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3Ioc291cmNlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc291cmNlID0gc291cmNlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmlzSHR0cCA9IC9eaHR0cHM/Oi9pLnRlc3Qoc291cmNlLnVybCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuaHR0cEhlYWRlcnMgPSB0aGlzLmlzSHR0cCAmJiBzb3VyY2UuaHR0cEhlYWRlcnMgfHwge307CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Z1bGxSZXF1ZXN0UmVhZGVyID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmFuZ2VSZXF1ZXN0UmVhZGVycyA9IFtdOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgX3Byb2dyZXNzaXZlRGF0YUxlbmd0aCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF90aGlzJF9mdWxsUmVxdWVzdFJlYTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICgoX3RoaXMkX2Z1bGxSZXF1ZXN0UmVhID0gdGhpcy5fZnVsbFJlcXVlc3RSZWFkZXIpID09PSBudWxsIHx8IF90aGlzJF9mdWxsUmVxdWVzdFJlYSA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3RoaXMkX2Z1bGxSZXF1ZXN0UmVhLl9sb2FkZWQpID8/IDA7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldEZ1bGxSZWFkZXIoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC5hc3NlcnQpKCF0aGlzLl9mdWxsUmVxdWVzdFJlYWRlciwgIlBERkZldGNoU3RyZWFtLmdldEZ1bGxSZWFkZXIgY2FuIG9ubHkgYmUgY2FsbGVkIG9uY2UuIik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Z1bGxSZXF1ZXN0UmVhZGVyID0gbmV3IFBERkZldGNoU3RyZWFtUmVhZGVyKHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fZnVsbFJlcXVlc3RSZWFkZXI7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldFJhbmdlUmVhZGVyKGJlZ2luLCBlbmQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGVuZCA8PSB0aGlzLl9wcm9ncmVzc2l2ZURhdGFMZW5ndGgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHJlYWRlciA9IG5ldyBQREZGZXRjaFN0cmVhbVJhbmdlUmVhZGVyKHRoaXMsIGJlZ2luLCBlbmQpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yYW5nZVJlcXVlc3RSZWFkZXJzLnB1c2gocmVhZGVyKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHJlYWRlcjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY2FuY2VsQWxsUmVxdWVzdHMocmVhc29uKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRfZnVsbFJlcXVlc3RSZWEyOwogICAgICAgICAgICAgICAgICAgICAgICAoX3RoaXMkX2Z1bGxSZXF1ZXN0UmVhMiA9IHRoaXMuX2Z1bGxSZXF1ZXN0UmVhZGVyKSA9PT0gbnVsbCB8fCBfdGhpcyRfZnVsbFJlcXVlc3RSZWEyID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRfZnVsbFJlcXVlc3RSZWEyLmNhbmNlbChyZWFzb24pOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IHJlYWRlciBvZiB0aGlzLl9yYW5nZVJlcXVlc3RSZWFkZXJzLnNsaWNlKDApKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWFkZXIuY2FuY2VsKHJlYXNvbik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLlBERkZldGNoU3RyZWFtID0gUERGRmV0Y2hTdHJlYW07CiAgICAgICAgICAgICAgICBjbGFzcyBQREZGZXRjaFN0cmVhbVJlYWRlciB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3Ioc3RyZWFtKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3N0cmVhbSA9IHN0cmVhbTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVhZGVyID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fbG9hZGVkID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZmlsZW5hbWUgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzb3VyY2UgPSBzdHJlYW0uc291cmNlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl93aXRoQ3JlZGVudGlhbHMgPSBzb3VyY2Uud2l0aENyZWRlbnRpYWxzIHx8IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jb250ZW50TGVuZ3RoID0gc291cmNlLmxlbmd0aDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5faGVhZGVyc0NhcGFiaWxpdHkgPSAoMCwgX3V0aWwuY3JlYXRlUHJvbWlzZUNhcGFiaWxpdHkpKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Rpc2FibGVSYW5nZSA9IHNvdXJjZS5kaXNhYmxlUmFuZ2UgfHwgZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JhbmdlQ2h1bmtTaXplID0gc291cmNlLnJhbmdlQ2h1bmtTaXplOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuX3JhbmdlQ2h1bmtTaXplICYmICF0aGlzLl9kaXNhYmxlUmFuZ2UpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Rpc2FibGVSYW5nZSA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fYWJvcnRDb250cm9sbGVyID0gbmV3IEFib3J0Q29udHJvbGxlcigpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9pc1N0cmVhbWluZ1N1cHBvcnRlZCA9ICFzb3VyY2UuZGlzYWJsZVN0cmVhbTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5faXNSYW5nZVN1cHBvcnRlZCA9ICFzb3VyY2UuZGlzYWJsZVJhbmdlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9oZWFkZXJzID0gY3JlYXRlSGVhZGVycyh0aGlzLl9zdHJlYW0uaHR0cEhlYWRlcnMpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB1cmwgPSBzb3VyY2UudXJsOwogICAgICAgICAgICAgICAgICAgICAgICBmZXRjaCh1cmwsIGNyZWF0ZUZldGNoT3B0aW9ucyh0aGlzLl9oZWFkZXJzLCB0aGlzLl93aXRoQ3JlZGVudGlhbHMsIHRoaXMuX2Fib3J0Q29udHJvbGxlcikpLnRoZW4ocmVzcG9uc2UgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCEoMCwgX25ldHdvcmtfdXRpbHMudmFsaWRhdGVSZXNwb25zZVN0YXR1cykocmVzcG9uc2Uuc3RhdHVzKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93ICgwLCBfbmV0d29ya191dGlscy5jcmVhdGVSZXNwb25zZVN0YXR1c0Vycm9yKShyZXNwb25zZS5zdGF0dXMsIHVybCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yZWFkZXIgPSByZXNwb25zZS5ib2R5LmdldFJlYWRlcigpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5faGVhZGVyc0NhcGFiaWxpdHkucmVzb2x2ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZ2V0UmVzcG9uc2VIZWFkZXIgPSBuYW1lID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gcmVzcG9uc2UuaGVhZGVycy5nZXQobmFtZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFsbG93UmFuZ2VSZXF1ZXN0cywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdWdnZXN0ZWRMZW5ndGgKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gPSAoMCwgX25ldHdvcmtfdXRpbHMudmFsaWRhdGVSYW5nZVJlcXVlc3RDYXBhYmlsaXRpZXMpKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBnZXRSZXNwb25zZUhlYWRlciwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc0h0dHA6IHRoaXMuX3N0cmVhbS5pc0h0dHAsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmFuZ2VDaHVua1NpemU6IHRoaXMuX3JhbmdlQ2h1bmtTaXplLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRpc2FibGVSYW5nZTogdGhpcy5fZGlzYWJsZVJhbmdlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2lzUmFuZ2VTdXBwb3J0ZWQgPSBhbGxvd1JhbmdlUmVxdWVzdHM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jb250ZW50TGVuZ3RoID0gc3VnZ2VzdGVkTGVuZ3RoIHx8IHRoaXMuX2NvbnRlbnRMZW5ndGg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9maWxlbmFtZSA9ICgwLCBfbmV0d29ya191dGlscy5leHRyYWN0RmlsZW5hbWVGcm9tSGVhZGVyKShnZXRSZXNwb25zZUhlYWRlcik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuX2lzU3RyZWFtaW5nU3VwcG9ydGVkICYmIHRoaXMuX2lzUmFuZ2VTdXBwb3J0ZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbmNlbChuZXcgX3V0aWwuQWJvcnRFeGNlcHRpb24oIlN0cmVhbWluZyBpcyBkaXNhYmxlZC4iKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0pLmNhdGNoKHRoaXMuX2hlYWRlcnNDYXBhYmlsaXR5LnJlamVjdCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMub25Qcm9ncmVzcyA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBoZWFkZXJzUmVhZHkoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9oZWFkZXJzQ2FwYWJpbGl0eS5wcm9taXNlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgZmlsZW5hbWUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9maWxlbmFtZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IGNvbnRlbnRMZW5ndGgoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9jb250ZW50TGVuZ3RoOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgaXNSYW5nZVN1cHBvcnRlZCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX2lzUmFuZ2VTdXBwb3J0ZWQ7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBpc1N0cmVhbWluZ1N1cHBvcnRlZCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX2lzU3RyZWFtaW5nU3VwcG9ydGVkOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBhc3luYyByZWFkKCkgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkb25Qcm9ncmVzczsKICAgICAgICAgICAgICAgICAgICAgICAgYXdhaXQgdGhpcy5faGVhZGVyc0NhcGFiaWxpdHkucHJvbWlzZTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkb25lCiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBhd2FpdCB0aGlzLl9yZWFkZXIucmVhZCgpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZG9uZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkb25lCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2xvYWRlZCArPSB2YWx1ZS5ieXRlTGVuZ3RoOwogICAgICAgICAgICAgICAgICAgICAgICAoX3RoaXMkb25Qcm9ncmVzcyA9IHRoaXMub25Qcm9ncmVzcykgPT09IG51bGwgfHwgX3RoaXMkb25Qcm9ncmVzcyA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3RoaXMkb25Qcm9ncmVzcy5jYWxsKHRoaXMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxvYWRlZDogdGhpcy5fbG9hZGVkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdG90YWw6IHRoaXMuX2NvbnRlbnRMZW5ndGgKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogZ2V0QXJyYXlCdWZmZXIodmFsdWUpLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgZG9uZTogZmFsc2UKICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY2FuY2VsKHJlYXNvbikgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkX3JlYWRlcjsKICAgICAgICAgICAgICAgICAgICAgICAgKF90aGlzJF9yZWFkZXIgPSB0aGlzLl9yZWFkZXIpID09PSBudWxsIHx8IF90aGlzJF9yZWFkZXIgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF90aGlzJF9yZWFkZXIuY2FuY2VsKHJlYXNvbik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Fib3J0Q29udHJvbGxlci5hYm9ydCgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNsYXNzIFBERkZldGNoU3RyZWFtUmFuZ2VSZWFkZXIgewogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKHN0cmVhbSwgYmVnaW4sIGVuZCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9zdHJlYW0gPSBzdHJlYW07CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlYWRlciA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2xvYWRlZCA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHNvdXJjZSA9IHN0cmVhbS5zb3VyY2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3dpdGhDcmVkZW50aWFscyA9IHNvdXJjZS53aXRoQ3JlZGVudGlhbHMgfHwgZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlYWRDYXBhYmlsaXR5ID0gKDAsIF91dGlsLmNyZWF0ZVByb21pc2VDYXBhYmlsaXR5KSgpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9pc1N0cmVhbWluZ1N1cHBvcnRlZCA9ICFzb3VyY2UuZGlzYWJsZVN0cmVhbTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fYWJvcnRDb250cm9sbGVyID0gbmV3IEFib3J0Q29udHJvbGxlcigpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9oZWFkZXJzID0gY3JlYXRlSGVhZGVycyh0aGlzLl9zdHJlYW0uaHR0cEhlYWRlcnMpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9oZWFkZXJzLmFwcGVuZCgiUmFuZ2UiLCBgYnl0ZXM9JHtiZWdpbn0tJHtlbmQgLSAxfWApOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB1cmwgPSBzb3VyY2UudXJsOwogICAgICAgICAgICAgICAgICAgICAgICBmZXRjaCh1cmwsIGNyZWF0ZUZldGNoT3B0aW9ucyh0aGlzLl9oZWFkZXJzLCB0aGlzLl93aXRoQ3JlZGVudGlhbHMsIHRoaXMuX2Fib3J0Q29udHJvbGxlcikpLnRoZW4ocmVzcG9uc2UgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCEoMCwgX25ldHdvcmtfdXRpbHMudmFsaWRhdGVSZXNwb25zZVN0YXR1cykocmVzcG9uc2Uuc3RhdHVzKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93ICgwLCBfbmV0d29ya191dGlscy5jcmVhdGVSZXNwb25zZVN0YXR1c0Vycm9yKShyZXNwb25zZS5zdGF0dXMsIHVybCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yZWFkQ2FwYWJpbGl0eS5yZXNvbHZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yZWFkZXIgPSByZXNwb25zZS5ib2R5LmdldFJlYWRlcigpOwogICAgICAgICAgICAgICAgICAgICAgICB9KS5jYXRjaCh0aGlzLl9yZWFkQ2FwYWJpbGl0eS5yZWplY3QpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm9uUHJvZ3Jlc3MgPSBudWxsOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgaXNTdHJlYW1pbmdTdXBwb3J0ZWQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9pc1N0cmVhbWluZ1N1cHBvcnRlZDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYXN5bmMgcmVhZCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF90aGlzJG9uUHJvZ3Jlc3MyOwogICAgICAgICAgICAgICAgICAgICAgICBhd2FpdCB0aGlzLl9yZWFkQ2FwYWJpbGl0eS5wcm9taXNlOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRvbmUKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IGF3YWl0IHRoaXMuX3JlYWRlci5yZWFkKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChkb25lKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRvbmUKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fbG9hZGVkICs9IHZhbHVlLmJ5dGVMZW5ndGg7CiAgICAgICAgICAgICAgICAgICAgICAgIChfdGhpcyRvblByb2dyZXNzMiA9IHRoaXMub25Qcm9ncmVzcykgPT09IG51bGwgfHwgX3RoaXMkb25Qcm9ncmVzczIgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF90aGlzJG9uUHJvZ3Jlc3MyLmNhbGwodGhpcywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgbG9hZGVkOiB0aGlzLl9sb2FkZWQKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogZ2V0QXJyYXlCdWZmZXIodmFsdWUpLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgZG9uZTogZmFsc2UKICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY2FuY2VsKHJlYXNvbikgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkX3JlYWRlcjI7CiAgICAgICAgICAgICAgICAgICAgICAgIChfdGhpcyRfcmVhZGVyMiA9IHRoaXMuX3JlYWRlcikgPT09IG51bGwgfHwgX3RoaXMkX3JlYWRlcjIgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF90aGlzJF9yZWFkZXIyLmNhbmNlbChyZWFzb24pOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9hYm9ydENvbnRyb2xsZXIuYWJvcnQoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDE2MSAqLwogICAgICAgICAgICAvKioqLyAoKF9fdW51c2VkX3dlYnBhY2tfbW9kdWxlLCBleHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKCiAgICAgICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIl9fZXNNb2R1bGUiLCAoewogICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0cnVlCiAgICAgICAgICAgICAgICB9KSk7CiAgICAgICAgICAgICAgICBleHBvcnRzLlRleHRMYXllclJlbmRlclRhc2sgPSB2b2lkIDA7CiAgICAgICAgICAgICAgICBleHBvcnRzLnJlbmRlclRleHRMYXllciA9IHJlbmRlclRleHRMYXllcjsKICAgICAgICAgICAgICAgIGV4cG9ydHMudXBkYXRlVGV4dExheWVyID0gdXBkYXRlVGV4dExheWVyOwogICAgICAgICAgICAgICAgdmFyIF91dGlsID0gX193X3BkZmpzX3JlcXVpcmVfXygxKTsKICAgICAgICAgICAgICAgIHZhciBfZGlzcGxheV91dGlscyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTQyKTsKICAgICAgICAgICAgICAgIGNvbnN0IE1BWF9URVhUX0RJVlNfVE9fUkVOREVSID0gMTAwMDAwOwogICAgICAgICAgICAgICAgY29uc3QgREVGQVVMVF9GT05UX1NJWkUgPSAzMDsKICAgICAgICAgICAgICAgIGNvbnN0IERFRkFVTFRfRk9OVF9BU0NFTlQgPSAwLjg7CiAgICAgICAgICAgICAgICBjb25zdCBhc2NlbnRDYWNoZSA9IG5ldyBNYXAoKTsKICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGdldEN0eChzaXplLCBpc09mZnNjcmVlbkNhbnZhc1N1cHBvcnRlZCkgewogICAgICAgICAgICAgICAgICAgIGxldCBjdHg7CiAgICAgICAgICAgICAgICAgICAgaWYgKGlzT2Zmc2NyZWVuQ2FudmFzU3VwcG9ydGVkICYmIF91dGlsLkZlYXR1cmVUZXN0LmlzT2Zmc2NyZWVuQ2FudmFzU3VwcG9ydGVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eCA9IG5ldyBPZmZzY3JlZW5DYW52YXMoc2l6ZSwgc2l6ZSkuZ2V0Q29udGV4dCgiMmQiLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhbHBoYTogZmFsc2UKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2FudmFzID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgiY2FudmFzIik7CiAgICAgICAgICAgICAgICAgICAgICAgIGNhbnZhcy53aWR0aCA9IGNhbnZhcy5oZWlnaHQgPSBzaXplOwogICAgICAgICAgICAgICAgICAgICAgICBjdHggPSBjYW52YXMuZ2V0Q29udGV4dCgiMmQiLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhbHBoYTogZmFsc2UKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJldHVybiBjdHg7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBnZXRBc2NlbnQoZm9udEZhbWlseSwgaXNPZmZzY3JlZW5DYW52YXNTdXBwb3J0ZWQpIHsKICAgICAgICAgICAgICAgICAgICBjb25zdCBjYWNoZWRBc2NlbnQgPSBhc2NlbnRDYWNoZS5nZXQoZm9udEZhbWlseSk7CiAgICAgICAgICAgICAgICAgICAgaWYgKGNhY2hlZEFzY2VudCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gY2FjaGVkQXNjZW50OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjb25zdCBjdHggPSBnZXRDdHgoREVGQVVMVF9GT05UX1NJWkUsIGlzT2Zmc2NyZWVuQ2FudmFzU3VwcG9ydGVkKTsKICAgICAgICAgICAgICAgICAgICBjdHguZm9udCA9IGAke0RFRkFVTFRfRk9OVF9TSVpFfXB4ICR7Zm9udEZhbWlseX1gOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IG1ldHJpY3MgPSBjdHgubWVhc3VyZVRleHQoIiIpOwogICAgICAgICAgICAgICAgICAgIGxldCBhc2NlbnQgPSBtZXRyaWNzLmZvbnRCb3VuZGluZ0JveEFzY2VudDsKICAgICAgICAgICAgICAgICAgICBsZXQgZGVzY2VudCA9IE1hdGguYWJzKG1ldHJpY3MuZm9udEJvdW5kaW5nQm94RGVzY2VudCk7CiAgICAgICAgICAgICAgICAgICAgaWYgKGFzY2VudCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByYXRpbyA9IGFzY2VudCAvIChhc2NlbnQgKyBkZXNjZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgYXNjZW50Q2FjaGUuc2V0KGZvbnRGYW1pbHksIHJhdGlvKTsKICAgICAgICAgICAgICAgICAgICAgICAgY3R4LmNhbnZhcy53aWR0aCA9IGN0eC5jYW52YXMuaGVpZ2h0ID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHJhdGlvOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjdHguc3Ryb2tlU3R5bGUgPSAicmVkIjsKICAgICAgICAgICAgICAgICAgICBjdHguY2xlYXJSZWN0KDAsIDAsIERFRkFVTFRfRk9OVF9TSVpFLCBERUZBVUxUX0ZPTlRfU0laRSk7CiAgICAgICAgICAgICAgICAgICAgY3R4LnN0cm9rZVRleHQoImciLCAwLCAwKTsKICAgICAgICAgICAgICAgICAgICBsZXQgcGl4ZWxzID0gY3R4LmdldEltYWdlRGF0YSgwLCAwLCBERUZBVUxUX0ZPTlRfU0laRSwgREVGQVVMVF9GT05UX1NJWkUpLmRhdGE7CiAgICAgICAgICAgICAgICAgICAgZGVzY2VudCA9IDA7CiAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgaSA9IHBpeGVscy5sZW5ndGggLSAxIC0gMzsgaSA+PSAwOyBpIC09IDQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHBpeGVsc1tpXSA+IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlc2NlbnQgPSBNYXRoLmNlaWwoaSAvIDQgLyBERUZBVUxUX0ZPTlRfU0laRSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjdHguY2xlYXJSZWN0KDAsIDAsIERFRkFVTFRfRk9OVF9TSVpFLCBERUZBVUxUX0ZPTlRfU0laRSk7CiAgICAgICAgICAgICAgICAgICAgY3R4LnN0cm9rZVRleHQoIkEiLCAwLCBERUZBVUxUX0ZPTlRfU0laRSk7CiAgICAgICAgICAgICAgICAgICAgcGl4ZWxzID0gY3R4LmdldEltYWdlRGF0YSgwLCAwLCBERUZBVUxUX0ZPTlRfU0laRSwgREVGQVVMVF9GT05UX1NJWkUpLmRhdGE7CiAgICAgICAgICAgICAgICAgICAgYXNjZW50ID0gMDsKICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMCwgaWkgPSBwaXhlbHMubGVuZ3RoOyBpIDwgaWk7IGkgKz0gNCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAocGl4ZWxzW2ldID4gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgYXNjZW50ID0gREVGQVVMVF9GT05UX1NJWkUgLSBNYXRoLmZsb29yKGkgLyA0IC8gREVGQVVMVF9GT05UX1NJWkUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY3R4LmNhbnZhcy53aWR0aCA9IGN0eC5jYW52YXMuaGVpZ2h0ID0gMDsKICAgICAgICAgICAgICAgICAgICBpZiAoYXNjZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHJhdGlvID0gYXNjZW50IC8gKGFzY2VudCArIGRlc2NlbnQpOwogICAgICAgICAgICAgICAgICAgICAgICBhc2NlbnRDYWNoZS5zZXQoZm9udEZhbWlseSwgcmF0aW8pOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gcmF0aW87CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGFzY2VudENhY2hlLnNldChmb250RmFtaWx5LCBERUZBVUxUX0ZPTlRfQVNDRU5UKTsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gREVGQVVMVF9GT05UX0FTQ0VOVDsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGFwcGVuZFRleHQodGFzaywgZ2VvbSwgc3R5bGVzKSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgdGV4dERpdiA9IGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoInNwYW4iKTsKICAgICAgICAgICAgICAgICAgICBjb25zdCB0ZXh0RGl2UHJvcGVydGllcyA9IHsKICAgICAgICAgICAgICAgICAgICAgICAgYW5nbGU6IDAsCiAgICAgICAgICAgICAgICAgICAgICAgIGNhbnZhc1dpZHRoOiAwLAogICAgICAgICAgICAgICAgICAgICAgICBoYXNUZXh0OiBnZW9tLnN0ciAhPT0gIiIsCiAgICAgICAgICAgICAgICAgICAgICAgIGhhc0VPTDogZ2VvbS5oYXNFT0wsCiAgICAgICAgICAgICAgICAgICAgICAgIGZvbnRTaXplOiAwCiAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICB0YXNrLl90ZXh0RGl2cy5wdXNoKHRleHREaXYpOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHR4ID0gX3V0aWwuVXRpbC50cmFuc2Zvcm0odGFzay5fdHJhbnNmb3JtLCBnZW9tLnRyYW5zZm9ybSk7CiAgICAgICAgICAgICAgICAgICAgbGV0IGFuZ2xlID0gTWF0aC5hdGFuMih0eFsxXSwgdHhbMF0pOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0eWxlID0gc3R5bGVzW2dlb20uZm9udE5hbWVdOwogICAgICAgICAgICAgICAgICAgIGlmIChzdHlsZS52ZXJ0aWNhbCkgewogICAgICAgICAgICAgICAgICAgICAgICBhbmdsZSArPSBNYXRoLlBJIC8gMjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY29uc3QgZm9udEhlaWdodCA9IE1hdGguaHlwb3QodHhbMl0sIHR4WzNdKTsKICAgICAgICAgICAgICAgICAgICBjb25zdCBmb250QXNjZW50ID0gZm9udEhlaWdodCAqIGdldEFzY2VudChzdHlsZS5mb250RmFtaWx5LCB0YXNrLl9pc09mZnNjcmVlbkNhbnZhc1N1cHBvcnRlZCk7CiAgICAgICAgICAgICAgICAgICAgbGV0IGxlZnQsIHRvcDsKICAgICAgICAgICAgICAgICAgICBpZiAoYW5nbGUgPT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGVmdCA9IHR4WzRdOwogICAgICAgICAgICAgICAgICAgICAgICB0b3AgPSB0eFs1XSAtIGZvbnRBc2NlbnQ7CiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGVmdCA9IHR4WzRdICsgZm9udEFzY2VudCAqIE1hdGguc2luKGFuZ2xlKTsKICAgICAgICAgICAgICAgICAgICAgICAgdG9wID0gdHhbNV0gLSBmb250QXNjZW50ICogTWF0aC5jb3MoYW5nbGUpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjb25zdCBzY2FsZUZhY3RvclN0ciA9ICJjYWxjKHZhcigtLXNjYWxlLWZhY3RvcikqIjsKICAgICAgICAgICAgICAgICAgICBjb25zdCBkaXZTdHlsZSA9IHRleHREaXYuc3R5bGU7CiAgICAgICAgICAgICAgICAgICAgaWYgKHRhc2suX2NvbnRhaW5lciA9PT0gdGFzay5fcm9vdENvbnRhaW5lcikgewogICAgICAgICAgICAgICAgICAgICAgICBkaXZTdHlsZS5sZWZ0ID0gYCR7KDEwMCAqIGxlZnQgLyB0YXNrLl9wYWdlV2lkdGgpLnRvRml4ZWQoMil9JWA7CiAgICAgICAgICAgICAgICAgICAgICAgIGRpdlN0eWxlLnRvcCA9IGAkeygxMDAgKiB0b3AgLyB0YXNrLl9wYWdlSGVpZ2h0KS50b0ZpeGVkKDIpfSVgOwogICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGRpdlN0eWxlLmxlZnQgPSBgJHtzY2FsZUZhY3RvclN0cn0ke2xlZnQudG9GaXhlZCgyKX1weClgOwogICAgICAgICAgICAgICAgICAgICAgICBkaXZTdHlsZS50b3AgPSBgJHtzY2FsZUZhY3RvclN0cn0ke3RvcC50b0ZpeGVkKDIpfXB4KWA7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGRpdlN0eWxlLmZvbnRTaXplID0gYCR7c2NhbGVGYWN0b3JTdHJ9JHtmb250SGVpZ2h0LnRvRml4ZWQoMil9cHgpYDsKICAgICAgICAgICAgICAgICAgICBkaXZTdHlsZS5mb250RmFtaWx5ID0gc3R5bGUuZm9udEZhbWlseTsKICAgICAgICAgICAgICAgICAgICB0ZXh0RGl2UHJvcGVydGllcy5mb250U2l6ZSA9IGZvbnRIZWlnaHQ7CiAgICAgICAgICAgICAgICAgICAgdGV4dERpdi5zZXRBdHRyaWJ1dGUoInJvbGUiLCAicHJlc2VudGF0aW9uIik7CiAgICAgICAgICAgICAgICAgICAgdGV4dERpdi50ZXh0Q29udGVudCA9IGdlb20uc3RyOwogICAgICAgICAgICAgICAgICAgIHRleHREaXYuZGlyID0gZ2VvbS5kaXI7CiAgICAgICAgICAgICAgICAgICAgaWYgKHRhc2suX2ZvbnRJbnNwZWN0b3JFbmFibGVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRleHREaXYuZGF0YXNldC5mb250TmFtZSA9IGdlb20uZm9udE5hbWU7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmIChhbmdsZSAhPT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICB0ZXh0RGl2UHJvcGVydGllcy5hbmdsZSA9IGFuZ2xlICogKDE4MCAvIE1hdGguUEkpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBsZXQgc2hvdWxkU2NhbGVUZXh0ID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgaWYgKGdlb20uc3RyLmxlbmd0aCA+IDEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgc2hvdWxkU2NhbGVUZXh0ID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGdlb20uc3RyICE9PSAiICIgJiYgZ2VvbS50cmFuc2Zvcm1bMF0gIT09IGdlb20udHJhbnNmb3JtWzNdKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGFic1NjYWxlWCA9IE1hdGguYWJzKGdlb20udHJhbnNmb3JtWzBdKSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFic1NjYWxlWSA9IE1hdGguYWJzKGdlb20udHJhbnNmb3JtWzNdKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGFic1NjYWxlWCAhPT0gYWJzU2NhbGVZICYmIE1hdGgubWF4KGFic1NjYWxlWCwgYWJzU2NhbGVZKSAvIE1hdGgubWluKGFic1NjYWxlWCwgYWJzU2NhbGVZKSA+IDEuNSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgc2hvdWxkU2NhbGVUZXh0ID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBpZiAoc2hvdWxkU2NhbGVUZXh0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRleHREaXZQcm9wZXJ0aWVzLmNhbnZhc1dpZHRoID0gc3R5bGUudmVydGljYWwgPyBnZW9tLmhlaWdodCA6IGdlb20ud2lkdGg7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHRhc2suX3RleHREaXZQcm9wZXJ0aWVzLnNldCh0ZXh0RGl2LCB0ZXh0RGl2UHJvcGVydGllcyk7CiAgICAgICAgICAgICAgICAgICAgaWYgKHRhc2suX2lzUmVhZGFibGVTdHJlYW0pIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGFzay5fbGF5b3V0VGV4dCh0ZXh0RGl2KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBsYXlvdXQocGFyYW1zKSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICBkaXYsCiAgICAgICAgICAgICAgICAgICAgICAgIHNjYWxlLAogICAgICAgICAgICAgICAgICAgICAgICBwcm9wZXJ0aWVzLAogICAgICAgICAgICAgICAgICAgICAgICBjdHgsCiAgICAgICAgICAgICAgICAgICAgICAgIHByZXZGb250U2l6ZSwKICAgICAgICAgICAgICAgICAgICAgICAgcHJldkZvbnRGYW1pbHkKICAgICAgICAgICAgICAgICAgICB9ID0gcGFyYW1zOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgc3R5bGUKICAgICAgICAgICAgICAgICAgICB9ID0gZGl2OwogICAgICAgICAgICAgICAgICAgIGxldCB0cmFuc2Zvcm0gPSAiIjsKICAgICAgICAgICAgICAgICAgICBpZiAocHJvcGVydGllcy5jYW52YXNXaWR0aCAhPT0gMCAmJiBwcm9wZXJ0aWVzLmhhc1RleHQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9udEZhbWlseQogICAgICAgICAgICAgICAgICAgICAgICB9ID0gc3R5bGU7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhbnZhc1dpZHRoLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9udFNpemUKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IHByb3BlcnRpZXM7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChwcmV2Rm9udFNpemUgIT09IGZvbnRTaXplIHx8IHByZXZGb250RmFtaWx5ICE9PSBmb250RmFtaWx5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHguZm9udCA9IGAke2ZvbnRTaXplICogc2NhbGV9cHggJHtmb250RmFtaWx5fWA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYXJhbXMucHJldkZvbnRTaXplID0gZm9udFNpemU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYXJhbXMucHJldkZvbnRGYW1pbHkgPSBmb250RmFtaWx5OwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdpZHRoCiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBjdHgubWVhc3VyZVRleHQoZGl2LnRleHRDb250ZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHdpZHRoID4gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJhbnNmb3JtID0gYHNjYWxlWCgke2NhbnZhc1dpZHRoICogc2NhbGUgLyB3aWR0aH0pYDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBpZiAocHJvcGVydGllcy5hbmdsZSAhPT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICB0cmFuc2Zvcm0gPSBgcm90YXRlKCR7cHJvcGVydGllcy5hbmdsZX1kZWcpICR7dHJhbnNmb3JtfWA7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmICh0cmFuc2Zvcm0ubGVuZ3RoID4gMCkgewogICAgICAgICAgICAgICAgICAgICAgICBzdHlsZS50cmFuc2Zvcm0gPSB0cmFuc2Zvcm07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gcmVuZGVyKHRhc2spIHsKICAgICAgICAgICAgICAgICAgICBpZiAodGFzay5fY2FuY2VsZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjb25zdCB0ZXh0RGl2cyA9IHRhc2suX3RleHREaXZzOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IGNhcGFiaWxpdHkgPSB0YXNrLl9jYXBhYmlsaXR5OwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHRleHREaXZzTGVuZ3RoID0gdGV4dERpdnMubGVuZ3RoOwogICAgICAgICAgICAgICAgICAgIGlmICh0ZXh0RGl2c0xlbmd0aCA+IE1BWF9URVhUX0RJVlNfVE9fUkVOREVSKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNhcGFiaWxpdHkucmVzb2x2ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmICghdGFzay5faXNSZWFkYWJsZVN0cmVhbSkgewogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IHRleHREaXYgb2YgdGV4dERpdnMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRhc2suX2xheW91dFRleHQodGV4dERpdik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY2FwYWJpbGl0eS5yZXNvbHZlKCk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBUZXh0TGF5ZXJSZW5kZXJUYXNrIHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcihfcmVmKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfZ2xvYmFsVGhpcyRGb250SW5zcGU7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0ZXh0Q29udGVudFNvdXJjZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRhaW5lciwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZpZXdwb3J0LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGV4dERpdnMsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0ZXh0RGl2UHJvcGVydGllcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRleHRDb250ZW50SXRlbXNTdHIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc09mZnNjcmVlbkNhbnZhc1N1cHBvcnRlZAogICAgICAgICAgICAgICAgICAgICAgICB9ID0gX3JlZjsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fdGV4dENvbnRlbnRTb3VyY2UgPSB0ZXh0Q29udGVudFNvdXJjZTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5faXNSZWFkYWJsZVN0cmVhbSA9IHRleHRDb250ZW50U291cmNlIGluc3RhbmNlb2YgUmVhZGFibGVTdHJlYW07CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NvbnRhaW5lciA9IHRoaXMuX3Jvb3RDb250YWluZXIgPSBjb250YWluZXI7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3RleHREaXZzID0gdGV4dERpdnMgfHwgW107CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3RleHRDb250ZW50SXRlbXNTdHIgPSB0ZXh0Q29udGVudEl0ZW1zU3RyIHx8IFtdOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9pc09mZnNjcmVlbkNhbnZhc1N1cHBvcnRlZCA9IGlzT2Zmc2NyZWVuQ2FudmFzU3VwcG9ydGVkOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9mb250SW5zcGVjdG9yRW5hYmxlZCA9ICEhKChfZ2xvYmFsVGhpcyRGb250SW5zcGUgPSBnbG9iYWxUaGlzLkZvbnRJbnNwZWN0b3IpICE9PSBudWxsICYmIF9nbG9iYWxUaGlzJEZvbnRJbnNwZSAhPT0gdm9pZCAwICYmIF9nbG9iYWxUaGlzJEZvbnRJbnNwZS5lbmFibGVkKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVhZGVyID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fdGV4dERpdlByb3BlcnRpZXMgPSB0ZXh0RGl2UHJvcGVydGllcyB8fCBuZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jYW5jZWxlZCA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jYXBhYmlsaXR5ID0gKDAsIF91dGlsLmNyZWF0ZVByb21pc2VDYXBhYmlsaXR5KSgpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9sYXlvdXRUZXh0UGFyYW1zID0gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJldkZvbnRTaXplOiBudWxsLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJldkZvbnRGYW1pbHk6IG51bGwsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkaXY6IG51bGwsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzY2FsZTogdmlld3BvcnQuc2NhbGUgKiAoZ2xvYmFsVGhpcy5kZXZpY2VQaXhlbFJhdGlvIHx8IDEpLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJvcGVydGllczogbnVsbCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eDogZ2V0Q3R4KDAsIGlzT2Zmc2NyZWVuQ2FudmFzU3VwcG9ydGVkKQogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYWdlV2lkdGgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYWdlSGVpZ2h0LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFnZVgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYWdlWQogICAgICAgICAgICAgICAgICAgICAgICB9ID0gdmlld3BvcnQucmF3RGltczsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fdHJhbnNmb3JtID0gWzEsIDAsIDAsIC0xLCAtcGFnZVgsIHBhZ2VZICsgcGFnZUhlaWdodF07CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3BhZ2VXaWR0aCA9IHBhZ2VXaWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcGFnZUhlaWdodCA9IHBhZ2VIZWlnaHQ7CiAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfZGlzcGxheV91dGlscy5zZXRMYXllckRpbWVuc2lvbnMpKGNvbnRhaW5lciwgdmlld3BvcnQpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jYXBhYmlsaXR5LnByb21pc2UuZmluYWxseSgoKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9sYXlvdXRUZXh0UGFyYW1zID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgfSkuY2F0Y2goKCkgPT4ge30pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgcHJvbWlzZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX2NhcGFiaWxpdHkucHJvbWlzZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY2FuY2VsKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jYW5jZWxlZCA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl9yZWFkZXIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlYWRlci5jYW5jZWwobmV3IF91dGlsLkFib3J0RXhjZXB0aW9uKCJUZXh0TGF5ZXIgdGFzayBjYW5jZWxsZWQuIikpLmNhdGNoKCgpID0+IHt9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlYWRlciA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fY2FwYWJpbGl0eS5yZWplY3QobmV3IF91dGlsLkFib3J0RXhjZXB0aW9uKCJUZXh0TGF5ZXIgdGFzayBjYW5jZWxsZWQuIikpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfcHJvY2Vzc0l0ZW1zKGl0ZW1zLCBzdHlsZUNhY2hlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgaXRlbSBvZiBpdGVtcykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGl0ZW0uc3RyID09PSB1bmRlZmluZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoaXRlbS50eXBlID09PSAiYmVnaW5NYXJrZWRDb250ZW50UHJvcHMiIHx8IGl0ZW0udHlwZSA9PT0gImJlZ2luTWFya2VkQ29udGVudCIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcGFyZW50ID0gdGhpcy5fY29udGFpbmVyOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jb250YWluZXIgPSBkb2N1bWVudC5jcmVhdGVFbGVtZW50KCJzcGFuIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NvbnRhaW5lci5jbGFzc0xpc3QuYWRkKCJtYXJrZWRDb250ZW50Iik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpdGVtLmlkICE9PSBudWxsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jb250YWluZXIuc2V0QXR0cmlidXRlKCJpZCIsIGAke2l0ZW0uaWR9YCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFyZW50LmFwcGVuZCh0aGlzLl9jb250YWluZXIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoaXRlbS50eXBlID09PSAiZW5kTWFya2VkQ29udGVudCIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fY29udGFpbmVyID0gdGhpcy5fY29udGFpbmVyLnBhcmVudE5vZGU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fdGV4dENvbnRlbnRJdGVtc1N0ci5wdXNoKGl0ZW0uc3RyKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFwcGVuZFRleHQodGhpcywgaXRlbSwgc3R5bGVDYWNoZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX2xheW91dFRleHQodGV4dERpdikgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB0ZXh0RGl2UHJvcGVydGllcyA9IHRoaXMuX2xheW91dFRleHRQYXJhbXMucHJvcGVydGllcyA9IHRoaXMuX3RleHREaXZQcm9wZXJ0aWVzLmdldCh0ZXh0RGl2KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fbGF5b3V0VGV4dFBhcmFtcy5kaXYgPSB0ZXh0RGl2OwogICAgICAgICAgICAgICAgICAgICAgICBsYXlvdXQodGhpcy5fbGF5b3V0VGV4dFBhcmFtcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0ZXh0RGl2UHJvcGVydGllcy5oYXNUZXh0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jb250YWluZXIuYXBwZW5kKHRleHREaXYpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0ZXh0RGl2UHJvcGVydGllcy5oYXNFT0wpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGJyID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgiYnIiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyLnNldEF0dHJpYnV0ZSgicm9sZSIsICJwcmVzZW50YXRpb24iKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NvbnRhaW5lci5hcHBlbmQoYnIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9yZW5kZXIoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNhcGFiaWxpdHkgPSAoMCwgX3V0aWwuY3JlYXRlUHJvbWlzZUNhcGFiaWxpdHkpKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBzdHlsZUNhY2hlID0gT2JqZWN0LmNyZWF0ZShudWxsKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuX2lzUmVhZGFibGVTdHJlYW0pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHB1bXAgPSAoKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVhZGVyLnJlYWQoKS50aGVuKF9yZWYyID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZG9uZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9ID0gX3JlZjI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChkb25lKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXBhYmlsaXR5LnJlc29sdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBPYmplY3QuYXNzaWduKHN0eWxlQ2FjaGUsIHZhbHVlLnN0eWxlcyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3Byb2Nlc3NJdGVtcyh2YWx1ZS5pdGVtcywgc3R5bGVDYWNoZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHB1bXAoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9LCBjYXBhYmlsaXR5LnJlamVjdCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVhZGVyID0gdGhpcy5fdGV4dENvbnRlbnRTb3VyY2UuZ2V0UmVhZGVyKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwdW1wKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAodGhpcy5fdGV4dENvbnRlbnRTb3VyY2UpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpdGVtcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHlsZXMKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gPSB0aGlzLl90ZXh0Q29udGVudFNvdXJjZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3Byb2Nlc3NJdGVtcyhpdGVtcywgc3R5bGVzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhcGFiaWxpdHkucmVzb2x2ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCdObyAidGV4dENvbnRlbnRTb3VyY2UiIHBhcmFtZXRlciBzcGVjaWZpZWQuJyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY2FwYWJpbGl0eS5wcm9taXNlLnRoZW4oKCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3R5bGVDYWNoZSA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZW5kZXIodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0sIHRoaXMuX2NhcGFiaWxpdHkucmVqZWN0KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLlRleHRMYXllclJlbmRlclRhc2sgPSBUZXh0TGF5ZXJSZW5kZXJUYXNrOwogICAgICAgICAgICAgICAgZnVuY3Rpb24gcmVuZGVyVGV4dExheWVyKHBhcmFtcykgewogICAgICAgICAgICAgICAgICAgIGlmICghcGFyYW1zLnRleHRDb250ZW50U291cmNlICYmIChwYXJhbXMudGV4dENvbnRlbnQgfHwgcGFyYW1zLnRleHRDb250ZW50U3RyZWFtKSkgewogICAgICAgICAgICAgICAgICAgICAgICAoMCwgX2Rpc3BsYXlfdXRpbHMuZGVwcmVjYXRlZCkoIlRoZSBUZXh0TGF5ZXJSZW5kZXIgYHRleHRDb250ZW50YC9gdGV4dENvbnRlbnRTdHJlYW1gIHBhcmFtZXRlcnMgIiArICJ3aWxsIGJlIHJlbW92ZWQgaW4gdGhlIGZ1dHVyZSwgcGxlYXNlIHVzZSBgdGV4dENvbnRlbnRTb3VyY2VgIGluc3RlYWQuIik7CiAgICAgICAgICAgICAgICAgICAgICAgIHBhcmFtcy50ZXh0Q29udGVudFNvdXJjZSA9IHBhcmFtcy50ZXh0Q29udGVudCB8fCBwYXJhbXMudGV4dENvbnRlbnRTdHJlYW07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgY29udGFpbmVyLAogICAgICAgICAgICAgICAgICAgICAgICB2aWV3cG9ydAogICAgICAgICAgICAgICAgICAgIH0gPSBwYXJhbXM7CiAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3R5bGUgPSBnZXRDb21wdXRlZFN0eWxlKGNvbnRhaW5lcik7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgdmlzaWJpbGl0eSA9IHN0eWxlLmdldFByb3BlcnR5VmFsdWUoInZpc2liaWxpdHkiKTsKICAgICAgICAgICAgICAgICAgICBjb25zdCBzY2FsZUZhY3RvciA9IHBhcnNlRmxvYXQoc3R5bGUuZ2V0UHJvcGVydHlWYWx1ZSgiLS1zY2FsZS1mYWN0b3IiKSk7CiAgICAgICAgICAgICAgICAgICAgaWYgKHZpc2liaWxpdHkgPT09ICJ2aXNpYmxlIiAmJiAoIXNjYWxlRmFjdG9yIHx8IE1hdGguYWJzKHNjYWxlRmFjdG9yIC0gdmlld3BvcnQuc2NhbGUpID4gMWUtMTUpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnNvbGUuZXJyb3IoIlRoZSBgLS1zY2FsZS1mYWN0b3JgIENTUy12YXJpYWJsZSBtdXN0IGJlIHNldCwgIiArICJ0byB0aGUgc2FtZSB2YWx1ZSBhcyBgdmlld3BvcnQuc2NhbGVgLCAiICsgImVpdGhlciBvbiB0aGUgYGNvbnRhaW5lcmAtZWxlbWVudCBpdHNlbGYgb3IgaGlnaGVyIHVwIGluIHRoZSBET00uIik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNvbnN0IHRhc2sgPSBuZXcgVGV4dExheWVyUmVuZGVyVGFzayhwYXJhbXMpOwogICAgICAgICAgICAgICAgICAgIHRhc2suX3JlbmRlcigpOwogICAgICAgICAgICAgICAgICAgIHJldHVybiB0YXNrOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gdXBkYXRlVGV4dExheWVyKF9yZWYzKSB7CiAgICAgICAgICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICAgICAgICAgICAgY29udGFpbmVyLAogICAgICAgICAgICAgICAgICAgICAgICB2aWV3cG9ydCwKICAgICAgICAgICAgICAgICAgICAgICAgdGV4dERpdnMsCiAgICAgICAgICAgICAgICAgICAgICAgIHRleHREaXZQcm9wZXJ0aWVzLAogICAgICAgICAgICAgICAgICAgICAgICBpc09mZnNjcmVlbkNhbnZhc1N1cHBvcnRlZCwKICAgICAgICAgICAgICAgICAgICAgICAgbXVzdFJvdGF0ZSA9IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgIG11c3RSZXNjYWxlID0gdHJ1ZQogICAgICAgICAgICAgICAgICAgIH0gPSBfcmVmMzsKICAgICAgICAgICAgICAgICAgICBpZiAobXVzdFJvdGF0ZSkgewogICAgICAgICAgICAgICAgICAgICAgICAoMCwgX2Rpc3BsYXlfdXRpbHMuc2V0TGF5ZXJEaW1lbnNpb25zKShjb250YWluZXIsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJvdGF0aW9uOiB2aWV3cG9ydC5yb3RhdGlvbgogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaWYgKG11c3RSZXNjYWxlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGN0eCA9IGdldEN0eCgwLCBpc09mZnNjcmVlbkNhbnZhc1N1cHBvcnRlZCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHNjYWxlID0gdmlld3BvcnQuc2NhbGUgKiAoZ2xvYmFsVGhpcy5kZXZpY2VQaXhlbFJhdGlvIHx8IDEpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwYXJhbXMgPSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwcmV2Rm9udFNpemU6IG51bGwsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwcmV2Rm9udEZhbWlseTogbnVsbCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRpdjogbnVsbCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNjYWxlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJvcGVydGllczogbnVsbCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eAogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGRpdiBvZiB0ZXh0RGl2cykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFyYW1zLnByb3BlcnRpZXMgPSB0ZXh0RGl2UHJvcGVydGllcy5nZXQoZGl2KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhcmFtcy5kaXYgPSBkaXY7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsYXlvdXQocGFyYW1zKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTYyICovCiAgICAgICAgICAgIC8qKiovICgoX191bnVzZWRfd2VicGFja19tb2R1bGUsIGV4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+I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hciBfYm91bmRQb2ludGVyZG93biA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9lZGl0b3JzID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2hhZFBvaW50ZXJEb3duID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2lzQ2xlYW5pbmdVcCA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF91aU1hbmFnZXIgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfY2hhbmdlUGFyZW50ID0gLyojX19QVVJFX18qL25ldyBXZWFrU2V0KCk7CiAgICAgICAgICAgICAgICB2YXIgX2NyZWF0ZU5ld0VkaXRvciA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgdmFyIF9jcmVhdGVBbmRBZGROZXdFZGl0b3IgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIHZhciBfY2xlYW51cCA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgY2xhc3MgQW5ub3RhdGlvbkVkaXRvckxheWVyIHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcihvcHRpb25zKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfY2xlYW51cCk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfY3JlYXRlQW5kQWRkTmV3RWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEluaXRTcGVjKHRoaXMsIF9jcmVhdGVOZXdFZGl0b3IpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX2NoYW5nZVBhcmVudCk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9hY2Nlc3NpYmlsaXR5TWFuYWdlciwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdm9pZCAwCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfYWxsb3dDbGljaywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogZmFsc2UKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9ib3VuZFBvaW50ZXJ1cCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdGhpcy5wb2ludGVydXAuYmluZCh0aGlzKQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2JvdW5kUG9pbnRlcmRvd24sIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRoaXMucG9pbnRlcmRvd24uYmluZCh0aGlzKQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2VkaXRvcnMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IG5ldyBNYXAoKQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2hhZFBvaW50ZXJEb3duLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBmYWxzZQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2lzQ2xlYW5pbmdVcCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogZmFsc2UKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF91aU1hbmFnZXIsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHZvaWQgMAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFBbm5vdGF0aW9uRWRpdG9yTGF5ZXIuX2luaXRpYWxpemVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBBbm5vdGF0aW9uRWRpdG9yTGF5ZXIuX2luaXRpYWxpemVkID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9mcmVldGV4dC5GcmVlVGV4dEVkaXRvci5pbml0aWFsaXplKG9wdGlvbnMubDEwbik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfaW5rLklua0VkaXRvci5pbml0aWFsaXplKG9wdGlvbnMubDEwbik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgb3B0aW9ucy51aU1hbmFnZXIucmVnaXN0ZXJFZGl0b3JUeXBlcyhbX2ZyZWV0ZXh0LkZyZWVUZXh0RWRpdG9yLCBfaW5rLklua0VkaXRvcl0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX3VpTWFuYWdlciwgb3B0aW9ucy51aU1hbmFnZXIpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBhZ2VJbmRleCA9IG9wdGlvbnMucGFnZUluZGV4OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdiA9IG9wdGlvbnMuZGl2OwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX2FjY2Vzc2liaWxpdHlNYW5hZ2VyLCBvcHRpb25zLmFjY2Vzc2liaWxpdHlNYW5hZ2VyKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF91aU1hbmFnZXIpLmFkZExheWVyKHRoaXMpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgaXNFbXB0eSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZWRpdG9ycykuc2l6ZSA9PT0gMDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdXBkYXRlVG9vbGJhcihtb2RlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfdWlNYW5hZ2VyKS51cGRhdGVUb29sYmFyKG1vZGUpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB1cGRhdGVNb2RlKCkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgbW9kZSA9IGFyZ3VtZW50cy5sZW5ndGggPiAwICYmIGFyZ3VtZW50c1swXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzBdIDogX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF91aU1hbmFnZXIpLmdldE1vZGUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfY2xlYW51cCwgX2NsZWFudXAyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAobW9kZSA9PT0gX3V0aWwuQW5ub3RhdGlvbkVkaXRvclR5cGUuSU5LKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmFkZElua0VkaXRvcklmTmVlZGVkKGZhbHNlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGlzYWJsZUNsaWNrKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmVuYWJsZUNsaWNrKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF91aU1hbmFnZXIpLnVuc2VsZWN0QWxsKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChtb2RlICE9PSBfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yVHlwZS5OT05FKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdi5jbGFzc0xpc3QudG9nZ2xlKCJmcmVlVGV4dEVkaXRpbmciLCBtb2RlID09PSBfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yVHlwZS5GUkVFVEVYVCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdi5jbGFzc0xpc3QudG9nZ2xlKCJpbmtFZGl0aW5nIiwgbW9kZSA9PT0gX3V0aWwuQW5ub3RhdGlvbkVkaXRvclR5cGUuSU5LKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LmhpZGRlbiA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGFkZElua0VkaXRvcklmTmVlZGVkKGlzQ29tbWl0dGluZykgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWlzQ29tbWl0dGluZyAmJiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX3VpTWFuYWdlcikuZ2V0TW9kZSgpICE9PSBfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yVHlwZS5JTkspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWlzQ29tbWl0dGluZykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBlZGl0b3Igb2YgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9lZGl0b3JzKS52YWx1ZXMoKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChlZGl0b3IuaXNFbXB0eSgpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci5zZXRJbkJhY2tncm91bmQoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBlZGl0b3IgPSBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9jcmVhdGVBbmRBZGROZXdFZGl0b3IsIF9jcmVhdGVBbmRBZGROZXdFZGl0b3IyKS5jYWxsKHRoaXMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9mZnNldFg6IDAsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvZmZzZXRZOiAwCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3Iuc2V0SW5CYWNrZ3JvdW5kKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNldEVkaXRpbmdTdGF0ZShpc0VkaXRpbmcpIHsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF91aU1hbmFnZXIpLnNldEVkaXRpbmdTdGF0ZShpc0VkaXRpbmcpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBhZGRDb21tYW5kcyhwYXJhbXMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF91aU1hbmFnZXIpLmFkZENvbW1hbmRzKHBhcmFtcyk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGVuYWJsZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXYuc3R5bGUucG9pbnRlckV2ZW50cyA9ICJhdXRvIjsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBlZGl0b3Igb2YgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9lZGl0b3JzKS52YWx1ZXMoKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9yLmVuYWJsZUVkaXRpbmcoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBkaXNhYmxlKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdi5zdHlsZS5wb2ludGVyRXZlbnRzID0gIm5vbmUiOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGVkaXRvciBvZiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2VkaXRvcnMpLnZhbHVlcygpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3IuZGlzYWJsZUVkaXRpbmcoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9jbGVhbnVwLCBfY2xlYW51cDIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmlzRW1wdHkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LmhpZGRlbiA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2V0QWN0aXZlRWRpdG9yKGVkaXRvcikgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjdXJyZW50QWN0aXZlID0gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF91aU1hbmFnZXIpLmdldEFjdGl2ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoY3VycmVudEFjdGl2ZSA9PT0gZWRpdG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF91aU1hbmFnZXIpLnNldEFjdGl2ZUVkaXRvcihlZGl0b3IpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBlbmFibGVDbGljaygpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXYuYWRkRXZlbnRMaXN0ZW5lcigicG9pbnRlcmRvd24iLCBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2JvdW5kUG9pbnRlcmRvd24pKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXYuYWRkRXZlbnRMaXN0ZW5lcigicG9pbnRlcnVwIiwgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ib3VuZFBvaW50ZXJ1cCkpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBkaXNhYmxlQ2xpY2soKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LnJlbW92ZUV2ZW50TGlzdGVuZXIoInBvaW50ZXJkb3duIiwgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ib3VuZFBvaW50ZXJkb3duKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LnJlbW92ZUV2ZW50TGlzdGVuZXIoInBvaW50ZXJ1cCIsIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYm91bmRQb2ludGVydXApKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYXR0YWNoKGVkaXRvcikgewogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2VkaXRvcnMpLnNldChlZGl0b3IuaWQsIGVkaXRvcik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGRldGFjaChlZGl0b3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF9jbGFzc1ByaXZhdGVGaWVsZEdldDI7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZWRpdG9ycykuZGVsZXRlKGVkaXRvci5pZCk7CiAgICAgICAgICAgICAgICAgICAgICAgIChfY2xhc3NQcml2YXRlRmllbGRHZXQyID0gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9hY2Nlc3NpYmlsaXR5TWFuYWdlcikpID09PSBudWxsIHx8IF9jbGFzc1ByaXZhdGVGaWVsZEdldDIgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF9jbGFzc1ByaXZhdGVGaWVsZEdldDIucmVtb3ZlUG9pbnRlckluVGV4dExheWVyKGVkaXRvci5jb250ZW50RGl2KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmVtb3ZlKGVkaXRvcikgewogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX3VpTWFuYWdlcikucmVtb3ZlRWRpdG9yKGVkaXRvcik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGV0YWNoKGVkaXRvcik7CiAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci5kaXYuc3R5bGUuZGlzcGxheSA9ICJub25lIjsKICAgICAgICAgICAgICAgICAgICAgICAgc2V0VGltZW91dCgoKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3IuZGl2LnN0eWxlLmRpc3BsYXkgPSAiIjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci5kaXYucmVtb3ZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3IuaXNBdHRhY2hlZFRvRE9NID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZG9jdW1lbnQuYWN0aXZlRWxlbWVudCA9PT0gZG9jdW1lbnQuYm9keSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfdWlNYW5hZ2VyKS5mb2N1c01haW5Db250YWluZXIoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfSwgMCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9pc0NsZWFuaW5nVXApKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmFkZElua0VkaXRvcklmTmVlZGVkKGZhbHNlKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBhZGQoZWRpdG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2NoYW5nZVBhcmVudCwgX2NoYW5nZVBhcmVudDIpLmNhbGwodGhpcywgZWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF91aU1hbmFnZXIpLmFkZEVkaXRvcihlZGl0b3IpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmF0dGFjaChlZGl0b3IpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWVkaXRvci5pc0F0dGFjaGVkVG9ET00pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGRpdiA9IGVkaXRvci5yZW5kZXIoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LmFwcGVuZChkaXYpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9yLmlzQXR0YWNoZWRUb0RPTSA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5tb3ZlRWRpdG9ySW5ET00oZWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9yLm9uY2VBZGRlZCgpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX3VpTWFuYWdlcikuYWRkVG9Bbm5vdGF0aW9uU3RvcmFnZShlZGl0b3IpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBtb3ZlRWRpdG9ySW5ET00oZWRpdG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfY2xhc3NQcml2YXRlRmllbGRHZXQzOwogICAgICAgICAgICAgICAgICAgICAgICAoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0MyA9IF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYWNjZXNzaWJpbGl0eU1hbmFnZXIpKSA9PT0gbnVsbCB8fCBfY2xhc3NQcml2YXRlRmllbGRHZXQzID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfY2xhc3NQcml2YXRlRmllbGRHZXQzLm1vdmVFbGVtZW50SW5ET00odGhpcy5kaXYsIGVkaXRvci5kaXYsIGVkaXRvci5jb250ZW50RGl2LCB0cnVlKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYWRkT3JSZWJ1aWxkKGVkaXRvcikgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZWRpdG9yLm5lZWRzVG9CZVJlYnVpbHQoKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9yLnJlYnVpbGQoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYWRkKGVkaXRvcik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYWRkQU5ld0VkaXRvcihlZGl0b3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY21kID0gKCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5hZGRPclJlYnVpbGQoZWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdW5kbyA9ICgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci5yZW1vdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5hZGRDb21tYW5kcyh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB1bmRvLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgbXVzdEV4ZWM6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGFkZFVuZG9hYmxlRWRpdG9yKGVkaXRvcikgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjbWQgPSAoKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmFkZE9yUmVidWlsZChlZGl0b3IpOwogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB1bmRvID0gKCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9yLnJlbW92ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmFkZENvbW1hbmRzKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNtZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVuZG8sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtdXN0RXhlYzogZmFsc2UKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldE5leHRJZCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfdWlNYW5hZ2VyKS5nZXRJZCgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBkZXNlcmlhbGl6ZShkYXRhKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHN3aXRjaCAoZGF0YS5hbm5vdGF0aW9uVHlwZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yVHlwZS5GUkVFVEVYVDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gX2ZyZWV0ZXh0LkZyZWVUZXh0RWRpdG9yLmRlc2VyaWFsaXplKGRhdGEsIHRoaXMsIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfdWlNYW5hZ2VyKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLkFubm90YXRpb25FZGl0b3JUeXBlLklOSzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gX2luay5JbmtFZGl0b3IuZGVzZXJpYWxpemUoZGF0YSwgdGhpcywgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF91aU1hbmFnZXIpKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2V0U2VsZWN0ZWQoZWRpdG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfdWlNYW5hZ2VyKS5zZXRTZWxlY3RlZChlZGl0b3IpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB0b2dnbGVTZWxlY3RlZChlZGl0b3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF91aU1hbmFnZXIpLnRvZ2dsZVNlbGVjdGVkKGVkaXRvcik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlzU2VsZWN0ZWQoZWRpdG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX3VpTWFuYWdlcikuaXNTZWxlY3RlZChlZGl0b3IpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB1bnNlbGVjdChlZGl0b3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF91aU1hbmFnZXIpLnVuc2VsZWN0KGVkaXRvcik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHBvaW50ZXJ1cChldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc01hYwogICAgICAgICAgICAgICAgICAgICAgICB9ID0gX3V0aWwuRmVhdHVyZVRlc3QucGxhdGZvcm07CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChldmVudC5idXR0b24gIT09IDAgfHwgZXZlbnQuY3RybEtleSAmJiBpc01hYykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChldmVudC50YXJnZXQgIT09IHRoaXMuZGl2KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2hhZFBvaW50ZXJEb3duKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfaGFkUG9pbnRlckRvd24sIGZhbHNlKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2FsbG93Q2xpY2spKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX2FsbG93Q2xpY2ssIHRydWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2NyZWF0ZUFuZEFkZE5ld0VkaXRvciwgX2NyZWF0ZUFuZEFkZE5ld0VkaXRvcjIpLmNhbGwodGhpcywgZXZlbnQpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBwb2ludGVyZG93bihldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc01hYwogICAgICAgICAgICAgICAgICAgICAgICB9ID0gX3V0aWwuRmVhdHVyZVRlc3QucGxhdGZvcm07CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChldmVudC5idXR0b24gIT09IDAgfHwgZXZlbnQuY3RybEtleSAmJiBpc01hYykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChldmVudC50YXJnZXQgIT09IHRoaXMuZGl2KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9oYWRQb2ludGVyRG93biwgdHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGVkaXRvciA9IF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfdWlNYW5hZ2VyKS5nZXRBY3RpdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9hbGxvd0NsaWNrLCAhZWRpdG9yIHx8IGVkaXRvci5pc0VtcHR5KCkpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBkcm9wKGV2ZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGlkID0gZXZlbnQuZGF0YVRyYW5zZmVyLmdldERhdGEoInRleHQvcGxhaW4iKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZWRpdG9yID0gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF91aU1hbmFnZXIpLmdldEVkaXRvcihpZCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghZWRpdG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgZXZlbnQucHJldmVudERlZmF1bHQoKTsKICAgICAgICAgICAgICAgICAgICAgICAgZXZlbnQuZGF0YVRyYW5zZmVyLmRyb3BFZmZlY3QgPSAibW92ZSI7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2NoYW5nZVBhcmVudCwgX2NoYW5nZVBhcmVudDIpLmNhbGwodGhpcywgZWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmVjdCA9IHRoaXMuZGl2LmdldEJvdW5kaW5nQ2xpZW50UmVjdCgpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBlbmRYID0gZXZlbnQuY2xpZW50WCAtIHJlY3QueDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZW5kWSA9IGV2ZW50LmNsaWVudFkgLSByZWN0Lnk7CiAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci50cmFuc2xhdGUoZW5kWCAtIGVkaXRvci5zdGFydFgsIGVuZFkgLSBlZGl0b3Iuc3RhcnRZKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5tb3ZlRWRpdG9ySW5ET00oZWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9yLmRpdi5mb2N1cygpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBkcmFnb3ZlcihldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICBldmVudC5wcmV2ZW50RGVmYXVsdCgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBkZXN0cm95KCkgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0NDsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCgoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0NCA9IF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfdWlNYW5hZ2VyKS5nZXRBY3RpdmUoKSkgPT09IG51bGwgfHwgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0NCA9PT0gdm9pZCAwID8gdm9pZCAwIDogX2NsYXNzUHJpdmF0ZUZpZWxkR2V0NC5wYXJlbnQpID09PSB0aGlzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX3VpTWFuYWdlcikuc2V0QWN0aXZlRWRpdG9yKG51bGwpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgZWRpdG9yIG9mIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZWRpdG9ycykudmFsdWVzKCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfY2xhc3NQcml2YXRlRmllbGRHZXQ1OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgKF9jbGFzc1ByaXZhdGVGaWVsZEdldDUgPSBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2FjY2Vzc2liaWxpdHlNYW5hZ2VyKSkgPT09IG51bGwgfHwgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0NSA9PT0gdm9pZCAwID8gdm9pZCAwIDogX2NsYXNzUHJpdmF0ZUZpZWxkR2V0NS5yZW1vdmVQb2ludGVySW5UZXh0TGF5ZXIoZWRpdG9yLmNvbnRlbnREaXYpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9yLnNldFBhcmVudChudWxsKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci5pc0F0dGFjaGVkVG9ET00gPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci5kaXYucmVtb3ZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXYgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2VkaXRvcnMpLmNsZWFyKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfdWlNYW5hZ2VyKS5yZW1vdmVMYXllcih0aGlzKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmVuZGVyKF9yZWYpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZpZXdwb3J0CiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBfcmVmOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnZpZXdwb3J0ID0gdmlld3BvcnQ7CiAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfZGlzcGxheV91dGlscy5zZXRMYXllckRpbWVuc2lvbnMpKHRoaXMuZGl2LCB2aWV3cG9ydCk7CiAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdG9vbHMuYmluZEV2ZW50cykodGhpcywgdGhpcy5kaXYsIFsiZHJhZ292ZXIiLCAiZHJvcCJdKTsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBlZGl0b3Igb2YgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF91aU1hbmFnZXIpLmdldEVkaXRvcnModGhpcy5wYWdlSW5kZXgpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmFkZChlZGl0b3IpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudXBkYXRlTW9kZSgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB1cGRhdGUoX3JlZjIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZpZXdwb3J0CiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBfcmVmMjsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF91aU1hbmFnZXIpLmNvbW1pdE9yUmVtb3ZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudmlld3BvcnQgPSB2aWV3cG9ydDsKICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF9kaXNwbGF5X3V0aWxzLnNldExheWVyRGltZW5zaW9ucykodGhpcy5kaXYsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJvdGF0aW9uOiB2aWV3cG9ydC5yb3RhdGlvbgogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy51cGRhdGVNb2RlKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBwYWdlRGltZW5zaW9ucygpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFnZVdpZHRoLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFnZUhlaWdodAogICAgICAgICAgICAgICAgICAgICAgICB9ID0gdGhpcy52aWV3cG9ydC5yYXdEaW1zOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gW3BhZ2VXaWR0aCwgcGFnZUhlaWdodF07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5Bbm5vdGF0aW9uRWRpdG9yTGF5ZXIgPSBBbm5vdGF0aW9uRWRpdG9yTGF5ZXI7CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfY2hhbmdlUGFyZW50MihlZGl0b3IpIHsKICAgICAgICAgICAgICAgICAgICB2YXIgX2VkaXRvciRwYXJlbnQ7CiAgICAgICAgICAgICAgICAgICAgaWYgKGVkaXRvci5wYXJlbnQgPT09IHRoaXMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB0aGlzLmF0dGFjaChlZGl0b3IpOwogICAgICAgICAgICAgICAgICAgIChfZWRpdG9yJHBhcmVudCA9IGVkaXRvci5wYXJlbnQpID09PSBudWxsIHx8IF9lZGl0b3IkcGFyZW50ID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfZWRpdG9yJHBhcmVudC5kZXRhY2goZWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICBlZGl0b3Iuc2V0UGFyZW50KHRoaXMpOwogICAgICAgICAgICAgICAgICAgIGlmIChlZGl0b3IuZGl2ICYmIGVkaXRvci5pc0F0dGFjaGVkVG9ET00pIHsKICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9yLmRpdi5yZW1vdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXYuYXBwZW5kKGVkaXRvci5kaXYpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9jcmVhdGVOZXdFZGl0b3IyKHBhcmFtcykgewogICAgICAgICAgICAgICAgICAgIHN3aXRjaCAoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF91aU1hbmFnZXIpLmdldE1vZGUoKSkgewogICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLkFubm90YXRpb25FZGl0b3JUeXBlLkZSRUVURVhUOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG5ldyBfZnJlZXRleHQuRnJlZVRleHRFZGl0b3IocGFyYW1zKTsKICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yVHlwZS5JTks6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IF9pbmsuSW5rRWRpdG9yKHBhcmFtcyk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX2NyZWF0ZUFuZEFkZE5ld0VkaXRvcjIoZXZlbnQpIHsKICAgICAgICAgICAgICAgICAgICBjb25zdCBpZCA9IHRoaXMuZ2V0TmV4dElkKCk7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgZWRpdG9yID0gX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfY3JlYXRlTmV3RWRpdG9yLCBfY3JlYXRlTmV3RWRpdG9yMikuY2FsbCh0aGlzLCB7CiAgICAgICAgICAgICAgICAgICAgICAgIHBhcmVudDogdGhpcywKICAgICAgICAgICAgICAgICAgICAgICAgaWQsCiAgICAgICAgICAgICAgICAgICAgICAgIHg6IGV2ZW50Lm9mZnNldFgsCiAgICAgICAgICAgICAgICAgICAgICAgIHk6IGV2ZW50Lm9mZnNldFksCiAgICAgICAgICAgICAgICAgICAgICAgIHVpTWFuYWdlcjogX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF91aU1hbmFnZXIpCiAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgaWYgKGVkaXRvcikgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmFkZChlZGl0b3IpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gZWRpdG9yOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX2NsZWFudXAyKCkgewogICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfaXNDbGVhbmluZ1VwLCB0cnVlKTsKICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGVkaXRvciBvZiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2VkaXRvcnMpLnZhbHVlcygpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChlZGl0b3IuaXNFbXB0eSgpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3IucmVtb3ZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9pc0NsZWFuaW5nVXAsIGZhbHNlKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIF9kZWZpbmVQcm9wZXJ0eShBbm5vdGF0aW9uRWRpdG9yTGF5ZXIsICJfaW5pdGlhbGl6ZWQiLCBmYWxzZSk7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDE2MyAqLwogICAgICAgICAgICAvKioqLyAoKF9fdW51c2VkX3dlYnBhY2tfbW9kdWxlLCBleHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKCiAgICAgICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIl9fZXNNb2R1bGUiLCAoewogICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0cnVlCiAgICAgICAgICAgICAgICB9KSk7CiAgICAgICAgICAgICAgICBleHBvcnRzLkZyZWVUZXh0RWRpdG9yID0gdm9pZCAwOwogICAgICAgICAgICAgICAgdmFyIF91dGlsID0gX193X3BkZmpzX3JlcXVpcmVfXygxKTsKICAgICAgICAgICAgICAgIHZhciBfdG9vbHMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE0MSk7CiAgICAgICAgICAgICAgICB2YXIgX2VkaXRvciA9IF9fd19wZGZqc19yZXF1aXJlX18oMTQwKTsKICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyhvYmosIHByaXZhdGVTZXQpIHsgX2NoZWNrUHJpdmF0ZVJlZGVjbGFyYXRpb24ob2JqLCBwcml2YXRlU2V0KTsgcHJpdmF0ZVNldC5hZGQob2JqKTsgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX2RlZmluZVByb3BlcnR5KG9iaiwga2V5LCB2YWx1ZSkgeyBrZXkgPSBfdG9Qcm9wZXJ0eUtleShrZXkpOyBpZiAoa2V5IGluIG9iaikgeyBPYmplY3QuZGVmaW5lUHJvcGVydHkob2JqLCBrZXksIHsgdmFsdWU6IHZhbHVlLCBlbnVtZXJhYmxlOiB0cnVlLCBjb25maWd1cmFibGU6IHRydWUsIHdyaXRhYmxlOiB0cnVlIH0pOyB9IGVsc2UgeyBvYmpba2V5XSA9IHZhbHVlOyB9IHJldH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vckRpdktleWRvd24gPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfY29sb3IgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfY29udGVudCA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9lZGl0b3JEaXZJZCA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9oYXNBbHJlYWR5QmVlbkNvbW1pdHRlZCA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9mb250U2l6ZSA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF91cGRhdGVGb250U2l6ZSA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgdmFyIF91cGRhdGVDb2xvciA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgdmFyIF9leHRyYWN0VGV4dCA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgdmFyIF9zZXRFZGl0b3JEaW1lbnNpb25zID0gLyojX19QVVJFX18qL25ldyBXZWFrU2V0KCk7CiAgICAgICAgICAgICAgICBjbGFzcyBGcmVlVGV4dEVkaXRvciBleHRlbmRzIF9lZGl0b3IuQW5ub3RhdGlvbkVkaXRvciB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IocGFyYW1zKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHN1cGVyKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIC4uLnBhcmFtcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5hbWU6ICJmcmVlVGV4dEVkaXRvciIKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfc2V0RWRpdG9yRGltZW5zaW9ucyk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfZXh0cmFjdFRleHQpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX3VwZGF0ZUNvbG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEluaXRTcGVjKHRoaXMsIF91cGRhdGVGb250U2l6ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9ib3VuZEVkaXRvckRpdkJsdXIsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRoaXMuZWRpdG9yRGl2Qmx1ci5iaW5kKHRoaXMpCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfYm91bmRFZGl0b3JEaXZGb2N1cywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdGhpcy5lZGl0b3JEaXZGb2N1cy5iaW5kKHRoaXMpCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfYm91bmRFZGl0b3JEaXZJbnB1dCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdGhpcy5lZGl0b3JEaXZJbnB1dC5iaW5kKHRoaXMpCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfYm91bmRFZGl0b3JEaXZLZXlkb3duLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0aGlzLmVkaXRvckRpdktleWRvd24uYmluZCh0aGlzKQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2NvbG9yLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiB2b2lkIDAKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9jb250ZW50LCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiAiIgogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2VkaXRvckRpdklkLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBgJHt0aGlzLmlkfS1lZGl0b3JgCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfaGFzQWxyZWFkeUJlZW5Db21taXR0ZWQsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IGZhbHNlCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfZm9udFNpemUsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHZvaWQgMAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9jb2xvciwgcGFyYW1zLmNvbG9yIHx8IEZyZWVUZXh0RWRpdG9yLl9kZWZhdWx0Q29sb3IgfHwgX2VkaXRvci5Bbm5vdGF0aW9uRWRpdG9yLl9kZWZhdWx0TGluZUNvbG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9mb250U2l6ZSwgcGFyYW1zLmZvbnRTaXplIHx8IEZyZWVUZXh0RWRpdG9yLl9kZWZhdWx0Rm9udFNpemUpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzdGF0aWMgaW5pdGlhbGl6ZShsMTBuKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2wxMG5Qcm9taXNlID0gbmV3IE1hcChbImZyZWVfdGV4dDJfZGVmYXVsdF9jb250ZW50IiwgImVkaXRvcl9mcmVlX3RleHQyX2FyaWFfbGFiZWwiXS5tYXAoc3RyID0+IFtzdHIsIGwxMG4uZ2V0KHN0cildKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0eWxlID0gZ2V0Q29tcHV0ZWRTdHlsZShkb2N1bWVudC5kb2N1bWVudEVsZW1lbnQpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9pbnRlcm5hbFBhZGRpbmcgPSBwYXJzZUZsb2F0KHN0eWxlLmdldFByb3BlcnR5VmFsdWUoIi0tZnJlZXRleHQtcGFkZGluZyIpKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIHVwZGF0ZURlZmF1bHRQYXJhbXModHlwZSwgdmFsdWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3dpdGNoICh0eXBlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLkFubm90YXRpb25FZGl0b3JQYXJhbXNUeXBlLkZSRUVURVhUX1NJWkU6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgRnJlZVRleHRFZGl0b3IuX2RlZmF1bHRGb250U2l6ZSA9IHZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yUGFyYW1zVHlwZS5GUkVFVEVYVF9DT0xPUjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBGcmVlVGV4dEVkaXRvci5fZGVmYXVsdENvbG9yID0gdmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdXBkYXRlUGFyYW1zKHR5cGUsIHZhbHVlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHN3aXRjaCAodHlwZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yUGFyYW1zVHlwZS5GUkVFVEVYVF9TSVpFOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3VwZGF0ZUZvbnRTaXplLCBfdXBkYXRlRm9udFNpemUyKS5jYWxsKHRoaXMsIHZhbHVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuQW5ub3RhdGlvbkVkaXRvclBhcmFtc1R5cGUuRlJFRVRFWFRfQ09MT1I6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfdXBkYXRlQ29sb3IsIF91cGRhdGVDb2xvcjIpLmNhbGwodGhpcywgdmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBnZXQgZGVmYXVsdFByb3BlcnRpZXNUb1VwZGF0ZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFtbX3V0aWwuQW5ub3RhdGlvbkVkaXRvclBhcmFtc1R5cGUuRlJFRVRFWFRfU0laRSwgRnJlZVRleHRFZGl0b3IuX2RlZmF1bHRGb250U2l6ZV0sIFtfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yUGFyYW1zVHlwZS5GUkVFVEVYVF9DT0xPUiwgRnJlZVRleHRFZGl0b3IuX2RlZmF1bHRDb2xvciB8fCBfZWRpdG9yLkFubm90YXRpb25FZGl0b3IuX2RlZmF1bHRMaW5lQ29sb3JdXTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IHByb3BlcnRpZXNUb1VwZGF0ZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFtbX3V0aWwuQW5ub3RhdGlvbkVkaXRvclBhcmFtc1R5cGUuRlJFRVRFWFRfU0laRSwgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9mb250U2l6ZSldLCBbX3V0aWwuQW5ub3RhdGlvbkVkaXRvclBhcmFtc1R5cGUuRlJFRVRFWFRfQ09MT1IsIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfY29sb3IpXV07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldEluaXRpYWxUcmFuc2xhdGlvbigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2NhbGUgPSB0aGlzLnBhcmVudFNjYWxlOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gWy1GcmVlVGV4dEVkaXRvci5faW50ZXJuYWxQYWRkaW5nICogc2NhbGUsIC0oRnJlZVRleHRFZGl0b3IuX2ludGVybmFsUGFkZGluZyArIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZm9udFNpemUpKSAqIHNjYWxlXTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmVidWlsZCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIucmVidWlsZCgpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5kaXYgPT09IG51bGwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuaXNBdHRhY2hlZFRvRE9NKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBhcmVudC5hZGQodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZW5hYmxlRWRpdE1vZGUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmlzSW5FZGl0TW9kZSgpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wYXJlbnQuc2V0RWRpdGluZ1N0YXRlKGZhbHNlKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wYXJlbnQudXBkYXRlVG9vbGJhcihfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yVHlwZS5GUkVFVEVYVCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHN1cGVyLmVuYWJsZUVkaXRNb2RlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMub3ZlcmxheURpdi5jbGFzc0xpc3QucmVtb3ZlKCJlbmFibGVkIik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZWRpdG9yRGl2LmNvbnRlbnRFZGl0YWJsZSA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LmRyYWdnYWJsZSA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdi5yZW1vdmVBdHRyaWJ1dGUoImFyaWEtYWN0aXZlZGVzY2VuZGFudCIpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmVkaXRvckRpdi5hZGRFdmVudExpc3RlbmVyKCJrZXlkb3duIiwgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ib3VuZEVkaXRvckRpdktleWRvd24pKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5lZGl0b3JEaXYuYWRkRXZlbnRMaXN0ZW5lcigiZm9jdXMiLCBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2JvdW5kRWRpdG9yRGl2Rm9jdXMpKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5lZGl0b3JEaXYuYWRkRXZlbnRMaXN0ZW5lcigiYmx1ciIsIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYm91bmRFZGl0b3JEaXZCbHVyKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZWRpdG9yRGl2LmFkZEV2ZW50TGlzdGVuZXIoImlucHV0IiwgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ib3VuZEVkaXRvckRpdklucHV0KSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGRpc2FibGVFZGl0TW9kZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLmlzSW5FZGl0TW9kZSgpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wYXJlbnQuc2V0RWRpdGluZ1N0YXRlKHRydWUpOwogICAgICAgICAgICAgICAgICAgICAgICBzdXBlci5kaXNhYmxlRWRpdE1vZGUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5vdmVybGF5RGl2LmNsYXNzTGlzdC5hZGQoImVuYWJsZWQiKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5lZGl0b3JEaXYuY29udGVudEVkaXRhYmxlID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LnNldEF0dHJpYnV0ZSgiYXJpYS1hY3RpdmVkZXNjZW5kYW50IiwgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9lZGl0b3JEaXZJZCkpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdi5kcmFnZ2FibGUgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmVkaXRvckRpdi5yZW1vdmVFdmVudExpc3RlbmVyKCJrZXlkb3duIiwgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ib3VuZEVkaXRvckRpdktleWRvd24pKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5lZGl0b3JEaXYucmVtb3ZlRXZlbnRMaXN0ZW5lcigiZm9jdXMiLCBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2JvdW5kRWRpdG9yRGl2Rm9jdXMpKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5lZGl0b3JEaXYucmVtb3ZlRXZlbnRMaXN0ZW5lcigiYmx1ciIsIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYm91bmRFZGl0b3JEaXZCbHVyKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZWRpdG9yRGl2LnJlbW92ZUV2ZW50TGlzdGVuZXIoImlucHV0IiwgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ib3VuZEVkaXRvckRpdklucHV0KSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LmZvY3VzKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHByZXZlbnRTY3JvbGw6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuaXNFZGl0aW5nID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGFyZW50LmRpdi5jbGFzc0xpc3QuYWRkKCJmcmVlVGV4dEVkaXRpbmciKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZm9jdXNpbihldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICBzdXBlci5mb2N1c2luKGV2ZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGV2ZW50LnRhcmdldCAhPT0gdGhpcy5lZGl0b3JEaXYpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZWRpdG9yRGl2LmZvY3VzKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgb25jZUFkZGVkKCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy53aWR0aCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZW5hYmxlRWRpdE1vZGUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5lZGl0b3JEaXYuZm9jdXMoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaXNFbXB0eSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICF0aGlzLmVkaXRvckRpdiB8fCB0aGlzLmVkaXRvckRpdi5pbm5lclRleHQudHJpbSgpID09PSAiIjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmVtb3ZlKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmlzRWRpdGluZyA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBhcmVudC5zZXRFZGl0aW5nU3RhdGUodHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGFyZW50LmRpdi5jbGFzc0xpc3QuYWRkKCJmcmVlVGV4dEVkaXRpbmciKTsKICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIucmVtb3ZlKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNvbW1pdCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLmlzSW5FZGl0TW9kZSgpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIuY29tbWl0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9oYXNBbHJlYWR5QmVlbkNvbW1pdHRlZCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfaGFzQWxyZWFkeUJlZW5Db21taXR0ZWQsIHRydWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wYXJlbnQuYWRkVW5kb2FibGVFZGl0b3IodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXNhYmxlRWRpdE1vZGUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9jb250ZW50LCBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9leHRyYWN0VGV4dCwgX2V4dHJhY3RUZXh0MikuY2FsbCh0aGlzKS50cmltRW5kKCkpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9zZXRFZGl0b3JEaW1lbnNpb25zLCBfc2V0RWRpdG9yRGltZW5zaW9uczIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNob3VsZEdldEtleWJvYXJkRXZlbnRzKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5pc0luRWRpdE1vZGUoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZGJsY2xpY2soZXZlbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5lbmFibGVFZGl0TW9kZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmVkaXRvckRpdi5mb2N1cygpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBrZXlkb3duKGV2ZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChldmVudC50YXJnZXQgPT09IHRoaXMuZGl2ICYmIGV2ZW50LmtleSA9PT0gIkVudGVyIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5lbmFibGVFZGl0TW9kZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5lZGl0b3JEaXYuZm9jdXMoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBlZGl0b3JEaXZLZXlkb3duKGV2ZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIEZyZWVUZXh0RWRpdG9yLl9rZXlib2FyZE1hbmFnZXIuZXhlYyh0aGlzLCBldmVudCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGVkaXRvckRpdkZvY3VzKGV2ZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuaXNFZGl0aW5nID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZWRpdG9yRGl2Qmx1cihldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmlzRWRpdGluZyA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBlZGl0b3JEaXZJbnB1dChldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBhcmVudC5kaXYuY2xhc3NMaXN0LnRvZ2dsZSgiZnJlZVRleHRFZGl0aW5nIiwgdGhpcy5pc0VtcHR5KCkpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBkaXNhYmxlRWRpdGluZygpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5lZGl0b3JEaXYuc2V0QXR0cmlidXRlKCJyb2xlIiwgImNvbW1lbnQiKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5lZGl0b3JEaXYucmVtb3ZlQXR0cmlidXRlKCJhcmlhLW11bHRpbGluZSIpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBlbmFibGVFZGl0aW5nKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmVkaXRvckRpdi5zZXRBdHRyaWJ1dGUoInJvbGUiLCAidGV4dGJveCIpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmVkaXRvckRpdi5zZXRBdHRyaWJ1dGUoImFyaWEtbXVsdGlsaW5lIiwgdHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlbmRlcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuZGl2KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5kaXY7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGJhc2VYLCBiYXNlWTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMud2lkdGgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJhc2VYID0gdGhpcy54OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgYmFzZVkgPSB0aGlzLnk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIucmVuZGVyKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZWRpdG9yRGl2ID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgiZGl2Iik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZWRpdG9yRGl2LmNsYXNzTmFtZSA9ICJpbnRlcm5hbCI7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZWRpdG9yRGl2LnNldEF0dHJpYnV0ZSgiaWQiLCBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2VkaXRvckRpdklkKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZW5hYmxlRWRpdGluZygpOwogICAgICAgICAgICAgICAgICAgICAgICBGcmVlVGV4dEVkaXRvci5fbDEwblByb21pc2UuZ2V0KCJlZGl0b3JfZnJlZV90ZXh0Ml9hcmlhX2xhYmVsIikudGhlbihtc2cgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF90aGlzJGVkaXRvckRpdjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAoX3RoaXMkZWRpdG9yRGl2ID0gdGhpcy5lZGl0b3JEaXYpID09PSBudWxsIHx8IF90aGlzJGVkaXRvckRpdiA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3RoaXMkZWRpdG9yRGl2LnNldEF0dHJpYnV0ZSgiYXJpYS1sYWJlbCIsIG1zZyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBGcmVlVGV4dEVkaXRvci5fbDEwblByb21pc2UuZ2V0KCJmcmVlX3RleHQyX2RlZmF1bHRfY29udGVudCIpLnRoZW4obXNnID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRlZGl0b3JEaXYyOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIChfdGhpcyRlZGl0b3JEaXYyID0gdGhpcy5lZGl0b3JEaXYpID09PSBudWxsIHx8IF90aGlzJGVkaXRvckRpdjIgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF90aGlzJGVkaXRvckRpdjIuc2V0QXR0cmlidXRlKCJkZWZhdWx0LWNvbnRlbnQiLCBtc2cpOwogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5lZGl0b3JEaXYuY29udGVudEVkaXRhYmxlID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3R5bGUKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IHRoaXMuZWRpdG9yRGl2OwogICAgICAgICAgICAgICAgICAgICAgICBzdHlsZS5mb250U2l6ZSA9IGBjYWxjKCR7X2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9mb250U2l6ZSl9cHggKiB2YXIoLS1zY2FsZS1mYWN0b3IpKWA7CiAgICAgICAgICAgICAgICAgICAgICAgIHN0eWxlLmNvbG9yID0gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9jb2xvcik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LmFwcGVuZCh0aGlzLmVkaXRvckRpdik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMub3ZlcmxheURpdiA9IGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoImRpdiIpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm92ZXJsYXlEaXYuY2xhc3NMaXN0LmFkZCgib3ZlcmxheSIsICJlbmFibGVkIik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LmFwcGVuZCh0aGlzLm92ZXJsYXlEaXYpOwogICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3Rvb2xzLmJpbmRFdmVudHMpKHRoaXMsIHRoaXMuZGl2LCBbImRibGNsaWNrIiwgImtleWRvd24iXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLndpZHRoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBbcGFyZW50V2lkdGgsIHBhcmVudEhlaWdodF0gPSB0aGlzLnBhcmVudERpbWVuc2lvbnM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNldEF0KGJhc2VYICogcGFyZW50V2lkdGgsIGJhc2VZICogcGFyZW50SGVpZ2h0LCB0aGlzLndpZHRoICogcGFyZW50V2lkdGgsIHRoaXMuaGVpZ2h0ICogcGFyZW50SGVpZ2h0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgbGluZSBvZiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2NvbnRlbnQpLnNwbGl0KCJcbiIpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZGl2ID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgiZGl2Iik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGl2LmFwcGVuZChsaW5lID8gZG9jdW1lbnQuY3JlYXRlVGV4dE5vZGUobGluZSkgOiBkb2N1bWVudC5jcmVhdGVFbGVtZW50KCJiciIpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmVkaXRvckRpdi5hcHBlbmQoZGl2KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LmRyYWdnYWJsZSA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmVkaXRvckRpdi5jb250ZW50RWRpdGFibGUgPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LmRyYWdnYWJsZSA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5lZGl0b3JEaXYuY29udGVudEVkaXRhYmxlID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5kaXY7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBjb250ZW50RGl2KCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5lZGl0b3JEaXY7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBkZXNlcmlhbGl6ZShkYXRhLCBwYXJlbnQsIHVpTWFuYWdlcikgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBlZGl0b3IgPSBzdXBlci5kZXNlcmlhbGl6ZShkYXRhLCBwYXJlbnQsIHVpTWFuYWdlcik7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldChlZGl0b3IsIF9mb250U2l6ZSwgZGF0YS5mb250U2l6ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldChlZGl0b3IsIF9jb2xvciwgX3V0aWwuVXRpbC5tYWtlSGV4Q29sb3IoLi4uZGF0YS5jb2xvcikpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQoZWRpdG9yLCBfY29udGVudCwgZGF0YS52YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBlZGl0b3I7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNlcmlhbGl6ZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuaXNFbXB0eSgpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwYWRkaW5nID0gRnJlZVRleHRFZGl0b3IuX2ludGVybmFsUGFkZGluZyAqIHRoaXMucGFyZW50U2NhbGU7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHJlY3QgPSB0aGlzLmdldFJlY3QocGFkZGluZywgcGFkZGluZyk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNvbG9yID0gX2VkaXRvci5Bbm5vdGF0aW9uRWRpdG9yLl9jb2xvck1hbmFnZXIuY29udmVydCh0aGlzLmlzQXR0YWNoZWRUb0RPTSA/IGdldENvbXB1dGVkU3R5bGUodGhpcy5lZGl0b3JEaXYpLmNvbG9yIDogX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9jb2xvcikpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgYW5ub3RhdGlvblR5cGU6IF91dGlsLkFubm90YXRpb25FZGl0b3JUeXBlLkZSRUVURVhULAogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29sb3IsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb250U2l6ZTogX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9mb250U2l6ZSksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9jb250ZW50KSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2VJbmRleDogdGhpcy5wYWdlSW5kZXgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWN0LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcm90YXRpb246IHRoaXMucm90YXRpb24KICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLkZyZWVUZXh0RWRpdG9yID0gRnJlZVRleHRFZGl0b3I7CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfdXBkYXRlRm9udFNpemUyKGZvbnRTaXplKSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2V0Rm9udHNpemUgPSBzaXplID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5lZGl0b3JEaXYuc3R5bGUuZm9udFNpemUgPSBgY2FsYygke3NpemV9cHggKiB2YXIoLS1zY2FsZS1mYWN0b3IpKWA7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudHJhbnNsYXRlKDAsIC0oc2l6ZSAtIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZm9udFNpemUpKSAqIHRoaXMucGFyZW50U2NhbGUpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX2ZvbnRTaXplLCBzaXplKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfc2V0RWRpdG9yRGltZW5zaW9ucywgX3NldEVkaXRvckRpbWVuc2lvbnMyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2F2ZWRGb250c2l6ZSA9IF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZm9udFNpemUpOwogICAgICAgICAgICAgICAgICAgIHRoaXMuYWRkQ29tbWFuZHMoewogICAgICAgICAgICAgICAgICAgICAgICBjbWQ6ICgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNldEZvbnRzaXplKGZvbnRTaXplKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgICAgICAgICAgdW5kbzogKCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgc2V0Rm9udHNpemUoc2F2ZWRGb250c2l6ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAgICAgICAgIG11c3RFeGVjOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICB0eXBlOiBfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yUGFyYW1zVHlwZS5GUkVFVEVYVF9TSVpFLAogICAgICAgICAgICAgICAgICAgICAgICBvdmVyd3JpdGVJZlNhbWVUeXBlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICBrZWVwVW5kbzogdHJ1ZQogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX3VwZGF0ZUNvbG9yMihjb2xvcikgewogICAgICAgICAgICAgICAgICAgIGNvbnN0IHNhdmVkQ29sb3IgPSBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2NvbG9yKTsKICAgICAgICAgICAgICAgICAgICB0aGlzLmFkZENvbW1hbmRzKHsKICAgICAgICAgICAgICAgICAgICAgICAgY21kOiAoKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX2NvbG9yLCB0aGlzLmVkaXRvckRpdi5zdHlsZS5jb2xvciA9IGNvbG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgICAgICAgICAgdW5kbzogKCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9jb2xvciwgdGhpcy5lZGl0b3JEaXYuc3R5bGUuY29sb3IgPSBzYXZlZENvbG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgICAgICAgICAgbXVzdEV4ZWM6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgIHR5cGU6IF91dGlsLkFubm90YXRpb25FZGl0b3JQYXJhbXNUeXBlLkZSRUVURVhUX0NPTE9SLAogICAgICAgICAgICAgICAgICAgICAgICBvdmVyd3JpdGVJZlNhbWVUeXBlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICBrZWVwVW5kbzogdHJ1ZQogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX2V4dHJhY3RUZXh0MigpIHsKICAgICAgICAgICAgICAgICAgICBjb25zdCBkaXZzID0gdGhpcy5lZGl0b3JEaXYuZ2V0RWxlbWVudHNCeVRhZ05hbWUoImRpdiIpOwogICAgICAgICAgICAgICAgICAgIGlmIChkaXZzLmxlbmd0aCA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5lZGl0b3JEaXYuaW5uZXJUZXh0OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjb25zdCBidWZmZXIgPSBbXTsKICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGRpdiBvZiBkaXZzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGJ1ZmZlci5wdXNoKGRpdi5pbm5lclRleHQucmVwbGFjZSgvXHJcbj98XG4vLCAiIikpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gYnVmZmVyLmpvaW4oIlxuIik7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfc2V0RWRpdG9yRGltZW5zaW9uczIoKSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgW3BhcmVudFdpZHRoLCBwYXJlbnRIZWlnaHRdID0gdGhpcy5wYXJlbnREaW1lbnNpb25zOwogICAgICAgICAgICAgICAgICAgIGxldCByZWN0OwogICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmlzQXR0YWNoZWRUb0RPTSkgewogICAgICAgICAgICAgICAgICAgICAgICByZWN0ID0gdGhpcy5kaXYuZ2V0Qm91bmRpbmdDbGllbnRSZWN0KCk7CiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudExheWVyLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGl2CiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSB0aGlzOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzYXZlZERpc3BsYXkgPSBkaXYuc3R5bGUuZGlzcGxheTsKICAgICAgICAgICAgICAgICAgICAgICAgZGl2LnN0eWxlLmRpc3BsYXkgPSAiaGlkZGVuIjsKICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudExheWVyLmRpdi5hcHBlbmQodGhpcy5kaXYpOwogICAgICAgICAgICAgICAgICAgICAgICByZWN0ID0gZGl2LmdldEJvdW5kaW5nQ2xpZW50UmVjdCgpOwogICAgICAgICAgICAgICAgICAgICAgICBkaXYucmVtb3ZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGRpdi5zdHlsZS5kaXNwbGF5ID0gc2F2ZWREaXNwbGF5OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB0aGlzLndpZHRoID0gcmVjdC53aWR0aCAvIHBhcmVudFdpZHRoOwogICAgICAgICAgICAgICAgICAgIHRoaXMuaGVpZ2h0ID0gcmVjdC5oZWlnaHQgLyBwYXJlbnRIZWlnaHQ7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBfZGVmaW5lUHJvcGVydHkoRnJlZVRleHRFZGl0b3IsICJfZnJlZVRleHREZWZhdWx0Q29udGVudCIsICIiKTsKICAgICAgICAgICAgICAgIF9kZWZpbmVQcm9wZXJ0eShGcmVlVGV4dEVkaXRvciwgIl9sMTBuUHJvbWlzZSIsIHZvaWQgMCk7CiAgICAgICAgICAgICAgICBfZGVmaW5lUHJvcGVydHkoRnJlZVRleHRFZGl0b3IsICJfaW50ZXJuYWxQYWRkaW5nIiwgMCk7CiAgICAgICAgICAgICAgICBfZGVmaW5lUHJvcGVydHkoRnJlZVRleHRFZGl0b3IsICJfZGVmYXVsdENvbG9yIiwgbnVsbCk7CiAgICAgICAgICAgICAgICBfZGVmaW5lUHJvcGVydHkoRnJlZVRleHRFZGl0b3IsICJfZGVmYXVsdEZvbnRTaXplIiwgMTApOwogICAgICAgICAgICAgICAgX2RlZmluZVByb3BlcnR5KEZyZWVUZXh0RWRpdG9yLCAiX2tleWJvYXJkTWFuYWdlciIsIG5ldyBfdG9vbHMuS2V5Ym9hcmRNYW5hZ2VyKFtbWyJjdHJsK0VudGVyIiwgIm1hYyttZXRhK0VudGVyIiwgIkVzY2FwZSIsICJtYWMrRXNjYXBlIl0sIEZyZWVUZXh0RWRpdG9yLnByb3RvdHlwZS5jb21taXRPclJlbW92ZV1dKSk7CiAgICAgICAgICAgICAgICBfZGVmaW5lUHJvcGVydHkoRnJlZVRleHRFZGl0b3IsICJfdHlwZSIsICJmcmVldGV4dCIpOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxNjQgKi8KICAgICAgICAgICAgLyoqKi8gKChfX3VudXNlZF93ZWJwYWNrX21vZHVsZSwgZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgICJ1c2Ugc3RyaWN0IjsKCgogICAgICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJfX2VzTW9kdWxlIiwgKHsKICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdHJ1ZQogICAgICAgICAgICAgICAgfSkpOwogICAgICAgICAgICAgICAgZXhwb3J0cy5JbmtFZGl0b3IgPSB2b2lkIDA7CiAgICAgICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgImZpdEN1cnZlIiwgKHsKICAgICAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gX3BkZmpzRml0Q3VydmUuZml0Q3VydmU7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfSkpOwogICAgICAgICAgICAgICAgdmFyIF91dGlsID0gX193X3BkZmpzX3JlcXVpcmVfXygxKTsKICAgICAgICAgICAgICAgIHZhciBfZWRpdG9yID0gX193X3BkZmpzX3JlcXVpcmVfXygxNDApOwogICAgICAgICAgICAgICAgdmFyIF9wZGZqc0ZpdEN1cnZlID0gX193X3BkZmpzX3JlcXVpcmVfXygxNjUpOwogICAgICAgICAgICAgICAgdmFyIF90b29scyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTQxKTsKICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9jbGFz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ybGVhdmUgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfYm91bmRDYW52YXNQb2ludGVydXAgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfYm91bmRDYW52YXNQb2ludGVyZG93biA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9kaXNhYmxlRWRpdGluZyA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9pc0NhbnZhc0luaXRpYWxpemVkID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2xhc3RQb2ludCA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9vYnNlcnZlciA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9yZWFsV2lkdGggPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfcmVhbEhlaWdodCA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9yZXF1ZXN0RnJhbWVDYWxsYmFjayA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF91cGRhdGVUaGlja25lc3MgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIHZhciBfdXBkYXRlQ29sb3IgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIHZhciBfdXBkYXRlT3BhY2l0eSA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgdmFyIF9nZXRJbml0aWFsQkJveCA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgdmFyIF9zZXRTdHJva2UgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIHZhciBfc3RhcnREcmF3aW5nID0gLyojX19QVVJFX18qL25ldyBXZWFrU2V0KCk7CiAgICAgICAgICAgICAgICB2YXIgX2RyYXcgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIHZhciBfc3RvcERyYXdpbmcgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIHZhciBfcmVkcmF3ID0gLyojX19QVVJFX18qL25ldyBXZWFrU2V0KCk7CiAgICAgICAgICAgICAgICB2YXIgX2VuZERyYXdpbmcgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIHZhciBfY3JlYXRlQ2FudmFzID0gLyojX19QVVJFX18qL25ldyBXZWFrU2V0KCk7CiAgICAgICAgICAgICAgICB2YXIgX2NyZWF0ZU9ic2VydmVyID0gLyojX19QVVJFX18qL25ldyBXZWFrU2V0KCk7CiAgICAgICAgICAgICAgICB2YXIgX3NldENhbnZhc0RpbXMgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIHZhciBfc2V0U2NhbGVGYWN0b3IgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIHZhciBfdXBkYXRlVHJhbnNmb3JtID0gLyojX19QVVJFX18qL25ldyBXZWFrU2V0KCk7CiAgICAgICAgICAgICAgICB2YXIgX3NlcmlhbGl6ZVBhdGhzID0gLyojX19QVVJFX18qL25ldyBXZWFrU2V0KCk7CiAgICAgICAgICAgICAgICB2YXIgX2V4dHJhY3RQb2ludHNPbkJlemllciA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgdmFyIF9pc0FsbW9zdEZsYXQgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIHZhciBfZ2V0QmJveCA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgdmFyIF9nZXRQYWRkaW5nID0gLyojX19QVVJFX18qL25ldyBXZWFrU2V0KCk7CiAgICAgICAgICAgICAgICB2YXIgX2ZpdFRvQ29udGVudCA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgdmFyIF9zZXRNaW5EaW1zID0gLyojX19QVVJFX18qL25ldyBXZWFrU2V0KCk7CiAgICAgICAgICAgICAgICBjbGFzcyBJbmtFZGl0b3IgZXh0ZW5kcyBfZWRpdG9yLkFubm90YXRpb25FZGl0b3IgewogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKHBhcmFtcykgewogICAgICAgICAgICAgICAgICAgICAgICBzdXBlcih7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAuLi5wYXJhbXMsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBuYW1lOiAiaW5rRWRpdG9yIgogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEluaXRTcGVjKHRoaXMsIF9zZXRNaW5EaW1zKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEluaXRTcGVjKHRoaXMsIF9maXRUb0NvbnRlbnQpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX2dldFBhZGRpbmcpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX2dldEJib3gpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX2lzQWxtb3N0RmxhdCk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfZXh0cmFjdFBvaW50c09uQmV6aWVyKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEluaXRTcGVjKHRoaXMsIF9zZXJpYWxpemVQYXRocyk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfdXBkYXRlVHJhbnNmb3JtKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEluaXRTcGVjKHRoaXMsIF9zZXRTY2FsZUZhY3Rvcik7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfc2V0Q2FudmFzRGltcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfY3JlYXRlT2JzZXJ2ZXIpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX2NyZWF0ZUNhbnZhcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfZW5kRHJhd2luZyk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfcmVkcmF3KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEluaXRTcGVjKHRoaXMsIF9zdG9wRHJhd2luZyk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfZHJhdyk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfc3RhcnREcmF3aW5nKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEluaXRTcGVjKHRoaXMsIF9zZXRTdHJva2UpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX2dldEluaXRpYWxCQm94KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEluaXRTcGVjKHRoaXMsIF91cGRhdGVPcGFjaXR5KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEluaXRTcGVjKHRoaXMsIF91cGRhdGVDb2xvcik7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfdXBkYXRlVGhpY2tuZXNzKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2FzcGVjdFJhdGlvLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiAwCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfYmFzZUhlaWdodCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogMAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2Jhc2VXaWR0aCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogMAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2JvdW5kQ2FudmFzUG9pbnRlcm1vdmUsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRoaXMuY2FudmFzUG9pbnRlcm1vdmUuYmluZCh0aGlzKQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2JvdW5kQ2FudmFzUG9pbnRlcmxlYXZlLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0aGlzLmNhbnZhc1BvaW50ZXJsZWF2ZS5iaW5kKHRoaXMpCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfYm91bmRDYW52YXNQb2ludGVydXAsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRoaXMuY2FudmFzUG9pbnRlcnVwLmJpbmQodGhpcykKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9ib3VuZENhbnZhc1BvaW50ZXJkb3duLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0aGlzLmNhbnZhc1BvaW50ZXJkb3duLmJpbmQodGhpcykKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9kaXNhYmxlRWRpdGluZywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogZmFsc2UKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9pc0NhbnZhc0luaXRpYWxpemVkLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBmYWxzZQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2xhc3RQb2ludCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogbnVsbAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX29ic2VydmVyLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBudWxsCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfcmVhbFdpZHRoLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiAwCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfcmVhbEhlaWdodCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogMAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX3JlcXVlc3RGcmFtZUNhbGxiYWNrLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBudWxsCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbG9yID0gcGFyYW1zLmNvbG9yIHx8IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudGhpY2tuZXNzID0gcGFyYW1zLnRoaWNrbmVzcyB8fCBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm9wYWNpdHkgPSBwYXJhbXMub3BhY2l0eSB8fCBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBhdGhzID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYmV6aWVyUGF0aDJEID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudFBhdGggPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zY2FsZUZhY3RvciA9IDE7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudHJhbnNsYXRpb25YID0gdGhpcy50cmFuc2xhdGlvblkgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnggPSAwOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnkgPSAwOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzdGF0aWMgaW5pdGlhbGl6ZShsMTBuKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2wxMG5Qcm9taXNlID0gbmV3IE1hcChbImVkaXRvcl9pbmtfY2FudmFzX2FyaWFfbGFiZWwiLCAiZWRpdG9yX2luazJfYXJpYV9sYWJlbCJdLm1hcChzdHIgPT4gW3N0ciwgbDEwbi5nZXQoc3RyKV0pKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIHVwZGF0ZURlZmF1bHRQYXJhbXModHlwZSwgdmFsdWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3dpdGNoICh0eXBlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLkFubm90YXRpb25FZGl0b3JQYXJhbXNUeXBlLklOS19USElDS05FU1M6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgSW5rRWRpdG9yLl9kZWZhdWx0VGhpY2tuZXNzID0gdmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLkFubm90YXRpb25FZGl0b3JQYXJhbXNUeXBlLklOS19DT0xPUjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBJbmtFZGl0b3IuX2RlZmF1bHRDb2xvciA9IHZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yUGFyYW1zVHlwZS5JTktfT1BBQ0lUWToKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBJbmtFZGl0b3IuX2RlZmF1bHRPcGFjaXR5ID0gdmFsdWUgLyAxMDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdXBkYXRlUGFyYW1zKHR5cGUsIHZhbHVlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHN3aXRjaCAodHlwZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yUGFyYW1zVHlwZS5JTktfVEhJQ0tORVNTOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3VwZGF0ZVRoaWNrbmVzcywgX3VwZGF0ZVRoaWNrbmVzczIpLmNhbGwodGhpcywgdmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yUGFyYW1zVHlwZS5JTktfQ09MT1I6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfdXBkYXRlQ29sb3IsIF91cGRhdGVDb2xvcjIpLmNhbGwodGhpcywgdmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yUGFyYW1zVHlwZS5JTktfT1BBQ0lUWToKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF91cGRhdGVPcGFjaXR5LCBfdXBkYXRlT3BhY2l0eTIpLmNhbGwodGhpcywgdmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBnZXQgZGVmYXVsdFByb3BlcnRpZXNUb1VwZGF0ZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFtbX3V0aWwuQW5ub3RhdGlvbkVkaXRvclBhcmFtc1R5cGUuSU5LX1RISUNLTkVTUywgSW5rRWRpdG9yLl9kZWZhdWx0VGhpY2tuZXNzXSwgW191dGlsLkFubm90YXRpb25FZGl0b3JQYXJhbXNUeXBlLklOS19DT0xPUiwgSW5rRWRpdG9yLl9kZWZhdWx0Q29sb3IgfHwgX2VkaXRvci5Bbm5vdGF0aW9uRWRpdG9yLl9kZWZhdWx0TGluZUNvbG9yXSwgW191dGlsLkFubm90YXRpb25FZGl0b3JQYXJhbXNUeXBlLklOS19PUEFDSVRZLCBNYXRoLnJvdW5kKElua0VkaXRvci5fZGVmYXVsdE9wYWNpdHkgKiAxMDApXV07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBwcm9wZXJ0aWVzVG9VcGRhdGUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbW191dGlsLkFubm90YXRpb25FZGl0b3JQYXJhbXNUeXBlLklOS19USElDS05FU1MsIHRoaXMudGhpY2tuZXNzIHx8IElua0VkaXRvci5fZGVmYXVsdFRoaWNrbmVzc10sIFtfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yUGFyYW1zVHlwZS5JTktfQ09MT1IsIHRoaXMuY29sb3IgfHwgSW5rRWRpdG9yLl9kZWZhdWx0Q29sb3IgfHwgX2VkaXRvci5Bbm5vdGF0aW9uRWRpdG9yLl9kZWZhdWx0TGluZUNvbG9yXSwgW191dGlsLkFubm90YXRpb25FZGl0b3JQYXJhbXNUeXBlLklOS19PUEFDSVRZLCBNYXRoLnJvdW5kKDEwMCAqICh0aGlzLm9wYWNpdHkgPz8gSW5rRWRpdG9yLl9kZWZhdWx0T3BhY2l0eSkpXV07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlYnVpbGQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHN1cGVyLnJlYnVpbGQoKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuZGl2ID09PSBudWxsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLmNhbnZhcykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfY3JlYXRlQ2FudmFzLCBfY3JlYXRlQ2FudmFzMikuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2NyZWF0ZU9ic2VydmVyLCBfY3JlYXRlT2JzZXJ2ZXIyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5pc0F0dGFjaGVkVG9ET00pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGFyZW50LmFkZCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3NldENhbnZhc0RpbXMsIF9zZXRDYW52YXNEaW1zMikuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9maXRUb0NvbnRlbnQsIF9maXRUb0NvbnRlbnQyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZW1vdmUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmNhbnZhcyA9PT0gbnVsbCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5pc0VtcHR5KCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29tbWl0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jYW52YXMud2lkdGggPSB0aGlzLmNhbnZhcy5oZWlnaHQgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbnZhcy5yZW1vdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jYW52YXMgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX29ic2VydmVyKS5kaXNjb25uZWN0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfb2JzZXJ2ZXIsIG51bGwpOwogICAgICAgICAgICAgICAgICAgICAgICBzdXBlci5yZW1vdmUoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2V0UGFyZW50KHBhcmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMucGFyZW50ICYmIHBhcmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fdWlNYW5hZ2VyLnJlbW92ZVNob3VsZFJlc2NhbGUodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAodGhpcy5wYXJlbnQgJiYgcGFyZW50ID09PSBudWxsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl91aU1hbmFnZXIuYWRkU2hvdWxkUmVzY2FsZSh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBzdXBlci5zZXRQYXJlbnQocGFyZW50KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgb25TY2FsZUNoYW5naW5nKCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBbcGFyZW50V2lkdGgsIHBhcmVudEhlaWdodF0gPSB0aGlzLnBhcmVudERpbWVuc2lvbnM7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHdpZHRoID0gdGhpcy53aWR0aCAqIHBhcmVudFdpZHRoOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBoZWlnaHQgPSB0aGlzLmhlaWdodCAqIHBhcmVudEhlaWdodDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXREaW1lbnNpb25zKHdpZHRoLCBoZWlnaHQpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBlbmFibGVFZGl0TW9kZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZGlzYWJsZUVkaXRpbmcpIHx8IHRoaXMuY2FudmFzID09PSBudWxsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIuZW5hYmxlRWRpdE1vZGUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXYuZHJhZ2dhYmxlID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2FudmFzLmFkZEV2ZW50TGlzdGVuZXIoInBvaW50ZXJkb3duIiwgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ib3VuZENhbnZhc1BvaW50ZXJkb3duKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2FudmFzLmFkZEV2ZW50TGlzdGVuZXIoInBvaW50ZXJ1cCIsIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYm91bmRDYW52YXNQb2ludGVydXApKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZGlzYWJsZUVkaXRNb2RlKCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuaXNJbkVkaXRNb2RlKCkgfHwgdGhpcy5jYW52YXMgPT09IG51bGwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBzdXBlci5kaXNhYmxlRWRpdE1vZGUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXYuZHJhZ2dhYmxlID0gIXRoaXMuaXNFbXB0eSgpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdi5jbGFzc0xpc3QucmVtb3ZlKCJlZGl0aW5nIik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2FudmFzLnJlbW92ZUV2ZW50TGlzdGVuZXIoInBvaW50ZXJkb3duIiwgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ib3VuZENhbnZhc1BvaW50ZXJkb3duKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2FudmFzLnJlbW92ZUV2ZW50TGlzdGVuZXIoInBvaW50ZXJ1cCIsIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYm91bmRDYW52YXNQb2ludGVydXApKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgb25jZUFkZGVkKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdi5kcmFnZ2FibGUgPSAhdGhpcy5pc0VtcHR5KCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlzRW1wdHkoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLnBhdGhzLmxlbmd0aCA9PT0gMCB8fCB0aGlzLnBhdGhzLmxlbmd0aCA9PT0gMSAmJiB0aGlzLnBhdGhzWzBdLmxlbmd0aCA9PT0gMDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY29tbWl0KCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9kaXNhYmxlRWRpdGluZykpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBzdXBlci5jb21taXQoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5pc0VkaXRpbmcgPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXNhYmxlRWRpdE1vZGUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRJbkZvcmVncm91bmQoKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9kaXNhYmxlRWRpdGluZywgdHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LmNsYXNzTGlzdC5hZGQoImRpc2FibGVkIik7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2ZpdFRvQ29udGVudCwgX2ZpdFRvQ29udGVudDIpLmNhbGwodGhpcywgdHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGFyZW50LmFkZElua0VkaXRvcklmTmVlZGVkKHRydWUpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBhcmVudC5tb3ZlRWRpdG9ySW5ET00odGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LmZvY3VzKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHByZXZlbnRTY3JvbGw6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGZvY3VzaW4oZXZlbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIuZm9jdXNpbihldmVudCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZW5hYmxlRWRpdE1vZGUoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY2FudmFzUG9pbnRlcmRvd24oZXZlbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGV2ZW50LmJ1dHRvbiAhPT0gMCB8fCAhdGhpcy5pc0luRWRpdE1vZGUoKSB8fCBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2Rpc2FibGVFZGl0aW5nKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0SW5Gb3JlZ3JvdW5kKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChldmVudC50eXBlICE9PSAibW91c2UiKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdi5mb2N1cygpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGV2ZW50LnN0b3BQcm9wYWdhdGlvbigpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbnZhcy5hZGRFdmVudExpc3RlbmVyKCJwb2ludGVybGVhdmUiLCBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2JvdW5kQ2FudmFzUG9pbnRlcmxlYXZlKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2FudmFzLmFkZEV2ZW50TGlzdGVuZXIoInBvaW50ZXJtb3ZlIiwgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ib3VuZENhbnZhc1BvaW50ZXJtb3ZlKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3N0YXJ0RHJhd2luZywgX3N0YXJ0RHJhd2luZzIpLmNhbGwodGhpcywgZXZlbnQub2Zmc2V0WCwgZXZlbnQub2Zmc2V0WSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNhbnZhc1BvaW50ZXJtb3ZlKGV2ZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGV2ZW50LnN0b3BQcm9wYWdhdGlvbigpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9kcmF3LCBfZHJhdzIpLmNhbGwodGhpcywgZXZlbnQub2Zmc2V0WCwgZXZlbnQub2Zmc2V0WSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNhbnZhc1BvaW50ZXJ1cChldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZXZlbnQuYnV0dG9uICE9PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuaXNJbkVkaXRNb2RlKCkgJiYgdGhpcy5jdXJyZW50UGF0aC5sZW5ndGggIT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGV2ZW50LnN0b3BQcm9wYWdhdGlvbigpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfZW5kRHJhd2luZywgX2VuZERyYXdpbmcyKS5jYWxsKHRoaXMsIGV2ZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0SW5CYWNrZ3JvdW5kKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY2FudmFzUG9pbnRlcmxlYXZlKGV2ZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2VuZERyYXdpbmcsIF9lbmREcmF3aW5nMikuY2FsbCh0aGlzLCBldmVudCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0SW5CYWNrZ3JvdW5kKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlbmRlcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuZGl2KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5kaXY7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGJhc2VYLCBiYXNlWTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMud2lkdGgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJhc2VYID0gdGhpcy54OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgYmFzZVkgPSB0aGlzLnk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIucmVuZGVyKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIElua0VkaXRvci5fbDEwblByb21pc2UuZ2V0KCJlZGl0b3JfaW5rMl9hcmlhX2xhYmVsIikudGhlbihtc2cgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF90aGlzJGRpdjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAoX3RoaXMkZGl2ID0gdGhpcy5kaXYpID09PSBudWxsIHx8IF90aGlzJGRpdiA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3RoaXMkZGl2LnNldEF0dHJpYnV0ZSgiYXJpYS1sYWJlbCIsIG1zZyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBbeCwgeSwgdywgaF0gPSBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9nZXRJbml0aWFsQkJveCwgX2dldEluaXRpYWxCQm94MikuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRBdCh4LCB5LCAwLCAwKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXREaW1zKHcsIGgpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9jcmVhdGVDYW52YXMsIF9jcmVhdGVDYW52YXMyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy53aWR0aCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgW3BhcmVudFdpZHRoLCBwYXJlbnRIZWlnaHRdID0gdGhpcy5wYXJlbnREaW1lbnNpb25zOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRBdChiYXNlWCAqIHBhcmVudFdpZHRoLCBiYXNlWSAqIHBhcmVudEhlaWdodCwgdGhpcy53aWR0aCAqIHBhcmVudFdpZHRoLCB0aGlzLmhlaWdodCAqIHBhcmVudEhlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX2lzQ2FudmFzSW5pdGlhbGl6ZWQsIHRydWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfc2V0Q2FudmFzRGltcywgX3NldENhbnZhc0RpbXMyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXREaW1zKHRoaXMud2lkdGggKiBwYXJlbnRXaWR0aCwgdGhpcy5oZWlnaHQgKiBwYXJlbnRIZWlnaHQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfcmVkcmF3LCBfcmVkcmF3MikuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3NldE1pbkRpbXMsIF9zZXRNaW5EaW1zMikuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LmNsYXNzTGlzdC5hZGQoImRpc2FibGVkIik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdi5jbGFzc0xpc3QuYWRkKCJlZGl0aW5nIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmVuYWJsZUVkaXRNb2RlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfY3JlYXRlT2JzZXJ2ZXIsIF9jcmVhdGVPYnNlcnZlcjIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLmRpdjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2V0RGltZW5zaW9ucyh3aWR0aCwgaGVpZ2h0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHJvdW5kZWRXaWR0aCA9IE1hdGgucm91bmQod2lkdGgpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByb3VuZGVkSGVpZ2h0ID0gTWF0aC5yb3VuZChoZWlnaHQpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9yZWFsV2lkdGgpID09PSByb3VuZGVkV2lkdGggJiYgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9yZWFsSGVpZ2h0KSA9PT0gcm91bmRlZEhlaWdodCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfcmVhbFdpZHRoLCByb3VuZGVkV2lkdGgpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX3JlYWxIZWlnaHQsIHJvdW5kZWRIZWlnaHQpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbnZhcy5zdHlsZS52aXNpYmlsaXR5ID0gImhpZGRlbiI7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2FzcGVjdFJhdGlvKSAmJiBNYXRoLmFicyhfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2FzcGVjdFJhdGlvKSAtIHdpZHRoIC8gaGVpZ2h0KSA+IDFlLTIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGhlaWdodCA9IE1hdGguY2VpbCh3aWR0aCAvIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYXNwZWN0UmF0aW8pKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0RGltcyh3aWR0aCwgaGVpZ2h0KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBbcGFyZW50V2lkdGgsIHBhcmVudEhlaWdodF0gPSB0aGlzLnBhcmVudERpbWVuc2lvbnM7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMud2lkdGggPSB3aWR0aCAvIHBhcmVudFdpZHRoOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmhlaWdodCA9IGhlaWdodCAvIHBhcmVudEhlaWdodDsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZGlzYWJsZUVkaXRpbmcpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9zZXRTY2FsZUZhY3RvciwgX3NldFNjYWxlRmFjdG9yMikuY2FsbCh0aGlzLCB3aWR0aCwgaGVpZ2h0KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9zZXRDYW52YXNEaW1zLCBfc2V0Q2FudmFzRGltczIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3JlZHJhdywgX3JlZHJhdzIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2FudmFzLnN0eWxlLnZpc2liaWxpdHkgPSAidmlzaWJsZSI7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZml4RGltcygpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzdGF0aWMgZGVzZXJpYWxpemUoZGF0YSwgcGFyZW50LCB1aU1hbmFnZXIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZWRpdG9yID0gc3VwZXIuZGVzZXJpYWxpemUoZGF0YSwgcGFyZW50LCB1aU1hbmFnZXIpOwogICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3IudGhpY2tuZXNzID0gZGF0YS50aGlja25lc3M7CiAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci5jb2xvciA9IF91dGlsLlV0aWwubWFrZUhleENvbG9yKC4uLmRhdGEuY29sb3IpOwogICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3Iub3BhY2l0eSA9IGRhdGEub3BhY2l0eTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgW3BhZ2VXaWR0aCwgcGFnZUhlaWdodF0gPSBlZGl0b3IucGFnZURpbWVuc2lvbnM7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHdpZHRoID0gZWRpdG9yLndpZHRoICogcGFnZVdpZHRoOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBoZWlnaHQgPSBlZGl0b3IuaGVpZ2h0ICogcGFnZUhlaWdodDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2NhbGVGYWN0b3IgPSBlZGl0b3IucGFyZW50U2NhbGU7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHBhZGRpbmcgPSBkYXRhLnRoaWNrbmVzcyAvIDI7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldChlZGl0b3IsIF9hc3BlY3RSYXRpbywgd2lkdGggLyBoZWlnaHQpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQoZWRpdG9yLCBfZGlzYWJsZUVkaXRpbmcsIHRydWUpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQoZWRpdG9yLCBfcmVhbFdpZHRoLCBNYXRoLnJvdW5kKHdpZHRoKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldChlZGl0b3IsIF9yZWFsSGVpZ2h0LCBNYXRoLnJvdW5kKGhlaWdodCkpOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJlemllcgogICAgICAgICAgICAgICAgICAgICAgICB9IG9mIGRhdGEucGF0aHMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHBhdGggPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci5wYXRocy5wdXNoKHBhdGgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHAwID0gc2NhbGVGYWN0b3IgKiAoYmV6aWVyWzBdIC0gcGFkZGluZyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgcDEgPSBzY2FsZUZhY3RvciAqIChoZWlnaHQgLSBiZXppZXJbMV0gLSBwYWRkaW5nKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAyLCBpaSA9IGJlemllci5sZW5ndGg7IGkgPCBpaTsgaSArPSA2KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcDEwID0gc2NhbGVGYWN0b3IgKiAoYmV6aWVyW2ldIC0gcGFkZGluZyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcDExID0gc2NhbGVGYWN0b3IgKiAoaGVpZ2h0IC0gYmV6aWVyW2kgKyAxXSAtIHBhZGRpbmcpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHAyMCA9IHNjYWxlRmFjdG9yICogKGJlemllcltpICsgMl0gLSBwYWRkaW5nKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwMjEgPSBzY2FsZUZhY3RvciAqIChoZWlnaHQgLSBiZXppZXJbaSArIDNdIC0gcGFkZGluZyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcDMwID0gc2NhbGVGYWN0b3IgKiAoYmV6aWVyW2kgKyA0XSAtIHBhZGRpbmcpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHAzMSA9IHNjYWxlRmFjdG9yICogKGhlaWdodCAtIGJlemllcltpICsgNV0gLSBwYWRkaW5nKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYXRoLnB1c2goW1twMCwgcDFdLCBbcDEwLCBwMTFdLCBbcDIwLCBwMjFdLCBbcDMwLCBwMzFdXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcDAgPSBwMzA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcDEgPSBwMzE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwYXRoMkQgPSBfY2xhc3NTdGF0aWNQcml2YXRlTWV0aG9kR2V0KHRoaXMsIElua0VkaXRvciwgX2J1aWxkUGF0aDJEKS5jYWxsKHRoaXMsIHBhdGgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9yLmJlemllclBhdGgyRC5wdXNoKHBhdGgyRCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYmJveCA9IF9jbGFzc1ByaXZhdGVNZXRob2RHZXQoZWRpdG9yLCBfZ2V0QmJveCwgX2dldEJib3gyKS5jYWxsKGVkaXRvcik7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldChlZGl0b3IsIF9iYXNlV2lkdGgsIE1hdGgubWF4KFJFU0laRVJfU0laRSwgYmJveFsyXSAtIGJib3hbMF0pKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KGVkaXRvciwgX2Jhc2VIZWlnaHQsIE1hdGgubWF4KFJFU0laRVJfU0laRSwgYmJveFszXSAtIGJib3hbMV0pKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldChlZGl0b3IsIF9zZXRTY2FsZUZhY3RvciwgX3NldFNjYWxlRmFjdG9yMikuY2FsbChlZGl0b3IsIHdpZHRoLCBoZWlnaHQpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZWRpdG9yOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzZXJpYWxpemUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmlzRW1wdHkoKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmVjdCA9IHRoaXMuZ2V0UmVjdCgwLCAwKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaGVpZ2h0ID0gdGhpcy5yb3RhdGlvbiAlIDE4MCA9PT0gMCA/IHJlY3RbM10gLSByZWN0WzFdIDogcmVjdFsyXSAtIHJlY3RbMF07CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNvbG9yID0gX2VkaXRvci5Bbm5vdGF0aW9uRWRpdG9yLl9jb2xvck1hbmFnZXIuY29udmVydCh0aGlzLmN0eC5zdHJva2VTdHlsZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhbm5vdGF0aW9uVHlwZTogX3V0aWwuQW5ub3RhdGlvbkVkaXRvclR5cGUuSU5LLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29sb3IsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlja25lc3M6IHRoaXMudGhpY2tuZXNzLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgb3BhY2l0eTogdGhpcy5vcGFjaXR5LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGF0aHM6IF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3NlcmlhbGl6ZVBhdGhzLCBfc2VyaWFsaXplUGF0aHMyKS5jYWxsKHRoaXMsIHRoaXMuc2NhbGVGYWN0b3IgLyB0aGlzLnBhcmVudFNjYWxlLCB0aGlzLnRyYW5zbGF0aW9uWCwgdGhpcy50cmFuc2xhdGlvblksIGhlaWdodCksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYWdlSW5kZXg6IHRoaXMucGFnZUluZGV4LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVjdCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJvdGF0aW9uOiB0aGlzLnJvdGF0aW9uCiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5JbmtFZGl0b3IgPSBJbmtFZGl0b3I7CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfdXBkYXRlVGhpY2tuZXNzMih0aGlja25lc3MpIHsKICAgICAgICAgICAgICAgICAgICBjb25zdCBzYXZlZFRoaWNrbmVzcyA9IHRoaXMudGhpY2tuZXNzOwogICAgICAgICAgICAgICAgICAgIHRoaXMuYWRkQ29tbWFuZHMoewogICAgICAgICAgICAgICAgICAgICAgICBjbWQ6ICgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudGhpY2tuZXNzID0gdGhpY2tuZXNzOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfZml0VG9Db250ZW50LCBfZml0VG9Db250ZW50MikuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgICAgICAgICAgdW5kbzogKCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy50aGlja25lc3MgPSBzYXZlZFRoaWNrbmVzczsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2ZpdFRvQ29udGVudCwgX2ZpdFRvQ29udGVudDIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAgICAgICAgIG11c3RFeGVjOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICB0eXBlOiBfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yUGFyYW1zVHlwZS5JTktfVEhJQ0tORVNTLAogICAgICAgICAgICAgICAgICAgICAgICBvdmVyd3JpdGVJZlNhbWVUeXBlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICBrZWVwVW5kbzogdHJ1ZQogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX3VwZGF0ZUNvbG9yMihjb2xvcikgewogICAgICAgICAgICAgICAgICAgIGNvbnN0IHNhdmVkQ29sb3IgPSB0aGlzLmNvbG9yOwogICAgICAgICAgICAgICAgICAgIHRoaXMuYWRkQ29tbWFuZHMoewogICAgICAgICAgICAgICAgICAgICAgICBjbWQ6ICgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29sb3IgPSBjb2xvcjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3JlZHJhdywgX3JlZHJhdzIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAgICAgICAgIHVuZG86ICgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29sb3IgPSBzYXZlZENvbG9yOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfcmVkcmF3LCBfcmVkcmF3MikuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgICAgICAgICAgbXVzdEV4ZWM6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgIHR5cGU6IF91dGlsLkFubm90YXRpb25FZGl0b3JQYXJhbXNUeXBlLklOS19DT0xPUiwKICAgICAgICAgICAgICAgICAgICAgICAgb3ZlcndyaXRlSWZTYW1lVHlwZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAga2VlcFVuZG86IHRydWUKICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF91cGRhdGVPcGFjaXR5MihvcGFjaXR5KSB7CiAgICAgICAgICAgICAgICAgICAgb3BhY2l0eSAvPSAxMDA7CiAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2F2ZWRPcGFjaXR5ID0gdGhpcy5vcGFjaXR5OwogICAgICAgICAgICAgICAgICAgIHRoaXMuYWRkQ29tbWFuZHMoewogICAgICAgICAgICAgICAgICAgICAgICBjbWQ6ICgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMub3BhY2l0eSA9IG9wYWNpdHk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9yZWRyYXcsIF9yZWRyYXcyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgICAgICAgICB1bmRvOiAoKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm9wYWNpdHkgPSBzYXZlZE9wYWNpdHk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9yZWRyYXcsIF9yZWRyYXcyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgICAgICAgICBtdXN0RXhlYzogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgdHlwZTogX3V0aWwuQW5ub3RhdGlvbkVkaXRvclBhcmFtc1R5cGUuSU5LX09QQUNJVFksCiAgICAgICAgICAgICAgICAgICAgICAgIG92ZXJ3cml0ZUlmU2FtZVR5cGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgIGtlZXBVbmRvOiB0cnVlCiAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfZ2V0SW5pdGlhbEJCb3gyKCkgewogICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgcGFyZW50Um90YXRpb24sCiAgICAgICAgICAgICAgICAgICAgICAgIHBhcmVudERpbWVuc2lvbnM6IFt3aWR0aCwgaGVpZ2h0XQogICAgICAgICAgICAgICAgICAgIH0gPSB0aGlzOwogICAgICAgICAgICAgICAgICAgIHN3aXRjaCAocGFyZW50Um90YXRpb24pIHsKICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSA5MDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbMCwgaGVpZ2h0LCBoZWlnaHQsIHdpZHRoXTsKICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAxODA6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gW3dpZHRoLCBoZWlnaHQsIHdpZHRoLCBoZWlnaHRdOwogICAgICAgICAgICAgICAgICAgICAgICBjYXNlIDI3MDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbd2lkdGgsIDAsIGhlaWdodCwgd2lkdGhdOwogICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFswLCAwLCB3aWR0aCwgaGVpZ2h0XTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfc2V0U3Ryb2tlMigpIHsKICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eCwKICAgICAgICAgICAgICAgICAgICAgICAgY29sb3IsCiAgICAgICAgICAgICAgICAgICAgICAgIG9wYWNpdHksCiAgICAgICAgICAgICAgICAgICAgICAgIHRoaWNrbmVzcywKICAgICAgICAgICAgICAgICAgICAgICAgcGFyZW50U2NhbGUsCiAgICAgICAgICAgICAgICAgICAgICAgIHNjYWxlRmFjdG9yCiAgICAgICAgICAgICAgICAgICAgfSA9IHRoaXM7CiAgICAgICAgICAgICAgICAgICAgY3R4LmxpbmVXaWR0aCA9IHRoaWNrbmVzcyAqIHBhcmVudFNjYWxlIC8gc2NhbGVGYWN0b3I7CiAgICAgICAgICAgICAgICAgICAgY3R4LmxpbmVDYXAgPSAicm91bmQiOwogICAgICAgICAgICAgICAgICAgIGN0eC5saW5lSm9pbiA9ICJyb3VuZCI7CiAgICAgICAgICAgICAgICAgICAgY3R4Lm1pdGVyTGltaXQgPSAxMDsKICAgICAgICAgICAgICAgICAgICBjdHguc3Ryb2tlU3R5bGUgPSBgJHtjb2xvcn0keygwLCBfdG9vbHMub3BhY2l0eVRvSGV4KShvcGFjaXR5KX1gOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX3N0YXJ0RHJhd2luZzIoeCwgeSkgewogICAgICAgICAgICAgICAgICAgIHRoaXMuaXNFZGl0aW5nID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICBpZiAoIV9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfaXNDYW52YXNJbml0aWFsaXplZCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9pc0NhbnZhc0luaXRpYWxpemVkLCB0cnVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfc2V0Q2FudmFzRGltcywgX3NldENhbnZhc0RpbXMyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnRoaWNrbmVzcyB8fD0gSW5rRWRpdG9yLl9kZWZhdWx0VGhpY2tuZXNzOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbG9yIHx8PSBJbmtFZGl0b3IuX2RlZmF1bHRDb2xvciB8fCBfZWRpdG9yLkFubm90YXRpb25FZGl0b3IuX2RlZmF1bHRMaW5lQ29sb3I7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMub3BhY2l0eSA/Pz0gSW5rRWRpdG9yLl9kZWZhdWx0T3BhY2l0eTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50UGF0aC5wdXNoKFt4LCB5XSk7CiAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9sYXN0UG9pbnQsIG51bGwpOwogICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3NldFN0cm9rZSwgX3NldFN0cm9rZTIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHguYmVnaW5QYXRoKCk7CiAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHgubW92ZVRvKHgsIHkpOwogICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfcmVxdWVzdEZyYW1lQ2FsbGJhY2ssICgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX3JlcXVlc3RGcmFtZUNhbGxiYWNrKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2xhc3RQb2ludCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmlzRW1wdHkoKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4LnNldFRyYW5zZm9ybSgxLCAwLCAwLCAxLCAwLCAwKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN0eC5jbGVhclJlY3QoMCwgMCwgdGhpcy5jYW52YXMud2lkdGgsIHRoaXMuY2FudmFzLmhlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3JlZHJhdywgX3JlZHJhdzIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN0eC5saW5lVG8oLi4uX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9sYXN0UG9pbnQpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfbGFzdFBvaW50LCBudWxsKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4LnN0cm9rZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHdpbmRvdy5yZXF1ZXN0QW5pbWF0aW9uRnJhbWUoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9yZXF1ZXN0RnJhbWVDYWxsYmFjaykpOwogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIHdpbmRvdy5yZXF1ZXN0QW5pbWF0aW9uRnJhbWUoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9yZXF1ZXN0RnJhbWVDYWxsYmFjaykpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX2RyYXcyKHgsIHkpIHsKICAgICAgICAgICAgICAgICAgICBjb25zdCBbbGFzdFgsIGxhc3RZXSA9IHRoaXMuY3VycmVudFBhdGguYXQoLTEpOwogICAgICAgICAgICAgICAgICAgIGlmICh4ID09PSBsYXN0WCAmJiB5ID09PSBsYXN0WSkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudFBhdGgucHVzaChbeCwgeV0pOwogICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfbGFzdFBvaW50LCBbeCwgeV0pOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX3N0b3BEcmF3aW5nMih4LCB5KSB7CiAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHguY2xvc2VQYXRoKCk7CiAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9yZXF1ZXN0RnJhbWVDYWxsYmFjaywgbnVsbCk7CiAgICAgICAgICAgICAgICAgICAgeCA9IE1hdGgubWluKE1hdGgubWF4KHgsIDApLCB0aGlzLmNhbnZhcy53aWR0aCk7CiAgICAgICAgICAgICAgICAgICAgeSA9IE1hdGgubWluKE1hdGgubWF4KHksIDApLCB0aGlzLmNhbnZhcy5oZWlnaHQpOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IFtsYXN0WCwgbGFzdFldID0gdGhpcy5jdXJyZW50UGF0aC5hdCgtMSk7CiAgICAgICAgICAgICAgICAgICAgaWYgKHggIT09IGxhc3RYIHx8IHkgIT09IGxhc3RZKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudFBhdGgucHVzaChbeCwgeV0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBsZXQgYmV6aWVyOwogICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmN1cnJlbnRQYXRoLmxlbmd0aCAhPT0gMSkgewogICAgICAgICAgICAgICAgICAgICAgICBiZXppZXIgPSAoMCwgX3BkZmpzRml0Q3VydmUuZml0Q3VydmUpKHRoaXMuY3VycmVudFBhdGgsIDMwLCBudWxsKTsKICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB4eSA9IFt4LCB5XTsKICAgICAgICAgICAgICAgICAgICAgICAgYmV6aWVyID0gW1t4eSwgeHkuc2xpY2UoKSwgeHkuc2xpY2UoKSwgeHldXTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY29uc3QgcGF0aDJEID0gX2NsYXNzU3RhdGljUHJpdmF0ZU1ldGhvZEdldChJbmtFZGl0b3IsIElua0VkaXRvciwgX2J1aWxkUGF0aDJEKS5jYWxsKElua0VkaXRvciwgYmV6aWVyKTsKICAgICAgICAgICAgICAgICAgICB0aGlzLmN1cnJlbnRQYXRoLmxlbmd0aCA9IDA7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgY21kID0gKCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBhdGhzLnB1c2goYmV6aWVyKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5iZXppZXJQYXRoMkQucHVzaChwYXRoMkQpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnJlYnVpbGQoKTsKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHVuZG8gPSAoKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGF0aHMucG9wKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYmV6aWVyUGF0aDJELnBvcCgpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5wYXRocy5sZW5ndGggPT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucmVtb3ZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuY2FudmFzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfY3JlYXRlQ2FudmFzLCBfY3JlYXRlQ2FudmFzMikuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9jcmVhdGVPYnNlcnZlciwgX2NyZWF0ZU9ic2VydmVyMikuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2ZpdFRvQ29udGVudCwgX2ZpdFRvQ29udGVudDIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIHRoaXMuYWRkQ29tbWFuZHMoewogICAgICAgICAgICAgICAgICAgICAgICBjbWQsCiAgICAgICAgICAgICAgICAgICAgICAgIHVuZG8sCiAgICAgICAgICAgICAgICAgICAgICAgIG11c3RFeGVjOiB0cnVlCiAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfcmVkcmF3MigpIHsKICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5pc0VtcHR5KCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfdXBkYXRlVHJhbnNmb3JtLCBfdXBkYXRlVHJhbnNmb3JtMikuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9zZXRTdHJva2UsIF9zZXRTdHJva2UyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgY2FudmFzLAogICAgICAgICAgICAgICAgICAgICAgICBjdHgKICAgICAgICAgICAgICAgICAgICB9ID0gdGhpczsKICAgICAgICAgICAgICAgICAgICBjdHguc2V0VHJhbnNmb3JtKDEsIDAsIDAsIDEsIDAsIDApOwogICAgICAgICAgICAgICAgICAgIGN0eC5jbGVhclJlY3QoMCwgMCwgY2FudmFzLndpZHRoLCBjYW52YXMuaGVpZ2h0KTsKICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF91cGRhdGVUcmFuc2Zvcm0sIF91cGRhdGVUcmFuc2Zvcm0yKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgcGF0aCBvZiB0aGlzLmJlemllclBhdGgyRCkgewogICAgICAgICAgICAgICAgICAgICAgICBjdHguc3Ryb2tlKHBhdGgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9lbmREcmF3aW5nMihldmVudCkgewogICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3N0b3BEcmF3aW5nLCBfc3RvcERyYXdpbmcyKS5jYWxsKHRoaXMsIGV2ZW50Lm9mZnNldFgsIGV2ZW50Lm9mZnNldFkpOwogICAgICAgICAgICAgICAgICAgIHRoaXMuY2FudmFzLnJlbW92ZUV2ZW50TGlzdGVuZXIoInBvaW50ZXJsZWF2ZSIsIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYm91bmRDYW52YXNQb2ludGVybGVhdmUpKTsKICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbnZhcy5yZW1vdmVFdmVudExpc3RlbmVyKCJwb2ludGVybW92ZSIsIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYm91bmRDYW52YXNQb2ludGVybW92ZSkpOwogICAgICAgICAgICAgICAgICAgIHRoaXMuYWRkVG9Bbm5vdGF0aW9uU3RvcmFnZSgpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX2NyZWF0ZUNhbnZhczIoKSB7CiAgICAgICAgICAgICAgICAgICAgdGhpcy5jYW52YXMgPSBkb2N1bWVudC5jcmVhdGVFbGVtZW50KCJjYW52YXMiKTsKICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbnZhcy53aWR0aCA9IHRoaXMuY2FudmFzLmhlaWdodCA9IDA7CiAgICAgICAgICAgICAgICAgICAgdGhpcy5jYW52YXMuY2xhc3NOYW1lID0gImlua0VkaXRvckNhbnZhcyI7CiAgICAgICAgICAgICAgICAgICAgSW5rRWRpdG9yLl9sMTBuUHJvbWlzZS5nZXQoImVkaXRvcl9pbmtfY2FudmFzX2FyaWFfbGFiZWwiKS50aGVuKG1zZyA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRjYW52YXM7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAoX3RoaXMkY2FudmFzID0gdGhpcy5jYW52YXMpID09PSBudWxsIHx8IF90aGlzJGNhbnZhcyA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3RoaXMkY2FudmFzLnNldEF0dHJpYnV0ZSgiYXJpYS1sYWJlbCIsIG1zZyk7CiAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXYuYXBwZW5kKHRoaXMuY2FudmFzKTsKICAgICAgICAgICAgICAgICAgICB0aGlzLmN0eCA9IHRoaXMuY2FudmFzLmdldENvbnRleHQoIjJkIik7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfY3JlYXRlT2JzZXJ2ZXIyKCkgewogICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfb2JzZXJ2ZXIsIG5ldyBSZXNpemVPYnNlcnZlcihlbnRyaWVzID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmVjdCA9IGVudHJpZXNbMF0uY29udGVudFJlY3Q7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChyZWN0LndpZHRoICYmIHJlY3QuaGVpZ2h0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNldERpbWVuc2lvbnMocmVjdC53aWR0aCwgcmVjdC5oZWlnaHQpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfSkpOwogICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfb2JzZXJ2ZXIpLm9ic2VydmUodGhpcy5kaXYpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX3NldENhbnZhc0RpbXMyKCkgewogICAgICAgICAgICAgICAgICAgIGlmICghX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9pc0NhbnZhc0luaXRpYWxpemVkKSkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNvbnN0IFtwYXJlbnRXaWR0aCwgcGFyZW50SGVpZ2h0XSA9IHRoaXMucGFyZW50RGltZW5zaW9uczsKICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbnZhcy53aWR0aCA9IE1hdGguY2VpbCh0aGlzLndpZHRoICogcGFyZW50V2lkdGgpOwogICAgICAgICAgICAgICAgICAgIHRoaXMuY2FudmFzLmhlaWdodCA9IE1hdGguY2VpbCh0aGlzLmhlaWdodCAq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HRoaXMudHJhbnNsYXRpb25YICogdGhpcy5zY2FsZUZhY3RvciArIHBhZGRpbmcsIHRoaXMudHJhbnNsYXRpb25ZICogdGhpcy5zY2FsZUZhY3RvciArIHBhZGRpbmcpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX2J1aWxkUGF0aDJEKGJlemllcikgewogICAgICAgICAgICAgICAgICAgIGNvbnN0IHBhdGgyRCA9IG5ldyBQYXRoMkQoKTsKICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMCwgaWkgPSBiZXppZXIubGVuZ3RoOyBpIDwgaWk7IGkrKykgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBbZmlyc3QsIGNvbnRyb2wxLCBjb250cm9sMiwgc2Vjb25kXSA9IGJlemllcltpXTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGkgPT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhdGgyRC5tb3ZlVG8oLi4uZmlyc3QpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHBhdGgyRC5iZXppZXJDdXJ2ZVRvKGNvbnRyb2wxWzBdLCBjb250cm9sMVsxXSwgY29udHJvbDJbMF0sIGNvbnRyb2wyWzFdLCBzZWNvbmRbMF0sIHNlY29uZFsxXSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJldHVybiBwYXRoMkQ7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfc2VyaWFsaXplUGF0aHMyKHMsIHR4LCB0eSwgaCkgewogICAgICAgICAgICAgICAgICAgIGNvbnN0IE5VTUJFUl9PRl9QT0lOVFNfT05fQkVaSUVSX0NVUlZFID0gNDsKICAgICAgICAgICAgICAgICAgICBjb25zdCBwYXRocyA9IFtdOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHBhZGRpbmcgPSB0aGlzLnRoaWNrbmVzcyAvIDI7CiAgICAgICAgICAgICAgICAgICAgbGV0IGJ1ZmZlciwgcG9pbnRzOwogICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgYmV6aWVyIG9mIHRoaXMucGF0aHMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgYnVmZmVyID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgIHBvaW50cyA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMCwgaWkgPSBiZXppZXIubGVuZ3RoOyBpIDwgaWk7IGkrKykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgW2ZpcnN0LCBjb250cm9sMSwgY29udHJvbDIsIHNlY29uZF0gPSBiZXppZXJbaV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwMTAgPSBzICogKGZpcnN0WzBdICsgdHgpICsgcGFkZGluZzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHAxMSA9IGggLSBzICogKGZpcnN0WzFdICsgdHkpIC0gcGFkZGluZzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHAyMCA9IHMgKiAoY29udHJvbDFbMF0gKyB0eCkgKyBwYWRkaW5nOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcDIxID0gaCAtIHMgKiAoY29udHJvbDFbMV0gKyB0eSkgLSBwYWRkaW5nOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcDMwID0gcyAqIChjb250cm9sMlswXSArIHR4KSArIHBhZGRpbmc7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwMzEgPSBoIC0gcyAqIChjb250cm9sMlsxXSArIHR5KSAtIHBhZGRpbmc7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwNDAgPSBzICogKHNlY29uZFswXSArIHR4KSArIHBhZGRpbmc7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwNDEgPSBoIC0gcyAqIChzZWNvbmRbMV0gKyB0eSkgLSBwYWRkaW5nOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGkgPT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBidWZmZXIucHVzaChwMTAsIHAxMSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcG9pbnRzLnB1c2gocDEwLCBwMTEpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgYnVmZmVyLnB1c2gocDIwLCBwMjEsIHAzMCwgcDMxLCBwNDAsIHA0MSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9leHRyYWN0UG9pbnRzT25CZXppZXIsIF9leHRyYWN0UG9pbnRzT25CZXppZXIyKS5jYWxsKHRoaXMsIHAxMCwgcDExLCBwMjAsIHAyMSwgcDMwLCBwMzEsIHA0MCwgcDQxLCBOVU1CRVJfT0ZfUE9JTlRTX09OX0JFWklFUl9DVVJWRSwgcG9pbnRzKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBwYXRocy5wdXNoKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJlemllcjogYnVmZmVyLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcG9pbnRzCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gcGF0aHM7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfZXh0cmFjdFBvaW50c09uQmV6aWVyMihwMTAsIHAxMSwgcDIwLCBwMjEsIHAzMCwgcDMxLCBwNDAsIHA0MSwgbiwgcG9pbnRzKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2lzQWxtb3N0RmxhdCwgX2lzQWxtb3N0RmxhdDIpLmNhbGwodGhpcywgcDEwLCBwMTEsIHAyMCwgcDIxLCBwMzAsIHAzMSwgcDQwLCBwNDEpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHBvaW50cy5wdXNoKHA0MCwgcDQxKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMTsgaSA8IG4gLSAxOyBpKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdCA9IGkgLyBuOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBtdCA9IDEgLSB0OwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgcTEwID0gdCAqIHAxMCArIG10ICogcDIwOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgcTExID0gdCAqIHAxMSArIG10ICogcDIxOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgcTIwID0gdCAqIHAyMCArIG10ICogcDMwOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgcTIxID0gdCAqIHAyMSArIG10ICogcDMxOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBxMzAgPSB0ICogcDMwICsgbXQgKiBwNDA7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHEzMSA9IHQgKiBwMzEgKyBtdCAqIHA0MTsKICAgICAgICAgICAgICAgICAgICAgICAgcTEwID0gdCAqIHExMCArIG10ICogcTIwOwogICAgICAgICAgICAgICAgICAgICAgICBxMTEgPSB0ICogcTExICsgbXQgKiBxMjE7CiAgICAgICAgICAgICAgICAgICAgICAgIHEyMCA9IHQgKiBxMjAgKyBtdCAqIHEzMDsKICAgICAgICAgICAgICAgICAgICAgICAgcTIxID0gdCAqIHEyMSArIG10ICogcTMxOwogICAgICAgICAgICAgICAgICAgICAgICBxMTAgPSB0ICogcTEwICsgbXQgKiBxMjA7CiAgICAgICAgICAgICAgICAgICAgICAgIHExMSA9IHQgKiBxMTEgKyBtdCAqIHEyMTsKICAgICAgICAgICAgICAgICAgICAgICAgcG9pbnRzLnB1c2gocTEwLCBxMTEpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBwb2ludHMucHVzaChwNDAsIHA0MSk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfaXNBbG1vc3RGbGF0MihwMTAsIHAxMSwgcDIwLCBwMjEsIHAzMCwgcDMxLCBwNDAsIHA0MSkgewogICAgICAgICAgICAgICAgICAgIGNvbnN0IHRvbCA9IDEwOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IGF4ID0gKDMgKiBwMjAgLSAyICogcDEwIC0gcDQwKSAqKiAyOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IGF5ID0gKDMgKiBwMjEgLSAyICogcDExIC0gcDQxKSAqKiAyOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IGJ4ID0gKDMgKiBwMzAgLSBwMTAgLSAyICogcDQwKSAqKiAyOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IGJ5ID0gKDMgKiBwMzEgLSBwMTEgLSAyICogcDQxKSAqKiAyOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBNYXRoLm1heChheCwgYngpICsgTWF0aC5tYXgoYXksIGJ5KSA8PSB0b2w7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfZ2V0QmJveDIoKSB7CiAgICAgICAgICAgICAgICAgICAgbGV0IHhNaW4gPSBJbmZpbml0eTsKICAgICAgICAgICAgICAgICAgICBsZXQgeE1heCA9IC1JbmZpbml0eTsKICAgICAgICAgICAgICAgICAgICBsZXQgeU1pbiA9IEluZmluaXR5OwogICAgICAgICAgICAgICAgICAgIGxldCB5TWF4ID0gLUluZmluaXR5OwogICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgcGF0aCBvZiB0aGlzLnBhdGhzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgW2ZpcnN0LCBjb250cm9sMSwgY29udHJvbDIsIHNlY29uZF0gb2YgcGF0aCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYmJveCA9IF91dGlsLlV0aWwuYmV6aWVyQm91bmRpbmdCb3goLi4uZmlyc3QsIC4uLmNvbnRyb2wxLCAuLi5jb250cm9sMiwgLi4uc2Vjb25kKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHhNaW4gPSBNYXRoLm1pbih4TWluLCBiYm94WzBdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHlNaW4gPSBNYXRoLm1pbih5TWluLCBiYm94WzFdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHhNYXggPSBNYXRoLm1heCh4TWF4LCBiYm94WzJdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHlNYXggPSBNYXRoLm1heCh5TWF4LCBiYm94WzNdKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gW3hNaW4sIHlNaW4sIHhNYXgsIHlNYXhdOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX2dldFBhZGRpbmcyKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2Rpc2FibGVFZGl0aW5nKSA/IE1hdGguY2VpbCh0aGlzLnRoaWNrbmVzcyAqIHRoaXMucGFyZW50U2NhbGUpIDogMDsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9maXRUb0NvbnRlbnQyKCkgewogICAgICAgICAgICAgICAgICAgIGxldCBmaXJzdFRpbWUgPSBhcmd1bWVudHMubGVuZ3RoID4gMCAmJiBhcmd1bWVudHNbMF0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1swXSA6IGZhbHNlOwogICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmlzRW1wdHkoKSkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmICghX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9kaXNhYmxlRWRpdGluZykpIHsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfcmVkcmF3LCBfcmVkcmF3MikuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjb25zdCBiYm94ID0gX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfZ2V0QmJveCwgX2dldEJib3gyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHBhZGRpbmcgPSBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9nZXRQYWRkaW5nLCBfZ2V0UGFkZGluZzIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9iYXNlV2lkdGgsIE1hdGgubWF4KFJFU0laRVJfU0laRSwgYmJveFsyXSAtIGJib3hbMF0pKTsKICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX2Jhc2VIZWlnaHQsIE1hdGgubWF4KFJFU0laRVJfU0laRSwgYmJveFszXSAtIGJib3hbMV0pKTsKICAgICAgICAgICAgICAgICAgICBjb25zdCB3aWR0aCA9IE1hdGguY2VpbChwYWRkaW5nICsgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9iYXNlV2lkdGgpICogdGhpcy5zY2FsZUZhY3Rvcik7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgaGVpZ2h0ID0gTWF0aC5jZWlsKHBhZGRpbmcgKyBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2Jhc2VIZWlnaHQpICogdGhpcy5zY2FsZUZhY3Rvcik7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgW3BhcmVudFdpZHRoLCBwYXJlbnRIZWlnaHRdID0gdGhpcy5wYXJlbnREaW1lbnNpb25zOwogICAgICAgICAgICAgICAgICAgIHRoaXMud2lkdGggPSB3aWR0aCAvIHBhcmVudFdpZHRoOwogICAgICAgICAgICAgICAgICAgIHRoaXMuaGVpZ2h0ID0gaGVpZ2h0IC8gcGFyZW50SGVpZ2h0OwogICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfYXNwZWN0UmF0aW8sIHdpZHRoIC8gaGVpZ2h0KTsKICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9zZXRNaW5EaW1zLCBfc2V0TWluRGltczIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgcHJldlRyYW5zbGF0aW9uWCA9IHRoaXMudHJhbnNsYXRpb25YOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHByZXZUcmFuc2xhdGlvblkgPSB0aGlzLnRyYW5zbGF0aW9uWTsKICAgICAgICAgICAgICAgICAgICB0aGlzLnRyYW5zbGF0aW9uWCA9IC1iYm94WzBdOwogICAgICAgICAgICAgICAgICAgIHRoaXMudHJhbnNsYXRpb25ZID0gLWJib3hbMV07CiAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfc2V0Q2FudmFzRGltcywgX3NldENhbnZhc0RpbXMyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3JlZHJhdywgX3JlZHJhdzIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9yZWFsV2lkdGgsIHdpZHRoKTsKICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX3JlYWxIZWlnaHQsIGhlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXREaW1zKHdpZHRoLCBoZWlnaHQpOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHVuc2NhbGVkUGFkZGluZyA9IGZpcnN0VGltZSA/IHBhZGRpbmcgLyB0aGlzLnNjYWxlRmFjdG9yIC8gMiA6IDA7CiAgICAgICAgICAgICAgICAgICAgdGhpcy50cmFuc2xhdGUocHJldlRyYW5zbGF0aW9uWCAtIHRoaXMudHJhbnNsYXRpb25YIC0gdW5zY2FsZWRQYWRkaW5nLCBwcmV2VHJhbnNsYXRpb25ZIC0gdGhpcy50cmFuc2xhdGlvblkgLSB1bnNjYWxlZFBhZGRpbmcpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX3NldE1pbkRpbXMyKCkgewogICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgc3R5bGUKICAgICAgICAgICAgICAgICAgICB9ID0gdGhpcy5kaXY7CiAgICAgICAgICAgICAgICAgICAgaWYgKF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYXNwZWN0UmF0aW8pID49IDEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3R5bGUubWluSGVpZ2h0ID0gYCR7UkVTSVpFUl9TSVpFfXB4YDsKICAgICAgICAgICAgICAgICAgICAgICAgc3R5bGUubWluV2lkdGggPSBgJHtNYXRoLnJvdW5kKF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYXNwZWN0UmF0aW8pICogUkVTSVpFUl9TSVpFKX1weGA7CiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3R5bGUubWluV2lkdGggPSBgJHtSRVNJWkVSX1NJWkV9cHhgOwogICAgICAgICAgICAgICAgICAgICAgICBzdHlsZS5taW5IZWlnaHQgPSBgJHtNYXRoLnJvdW5kKFJFU0laRVJfU0laRSAvIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYXNwZWN0UmF0aW8pKX1weGA7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgX2RlZmluZVByb3BlcnR5KElua0VkaXRvciwgIl9kZWZhdWx0Q29sb3IiLCBudWxsKTsKICAgICAgICAgICAgICAgIF9kZWZpbmVQcm9wZXJ0eShJbmtFZGl0b3IsICJfZGVmYXVsdE9wYWNpdHkiLCAxKTsKICAgICAgICAgICAgICAgIF9kZWZpbmVQcm9wZXJ0eShJbmtFZGl0b3IsICJfZGVmYXVsdFRoaWNrbmVzcyIsIDEpOwogICAgICAgICAgICAgICAgX2RlZmluZVByb3BlcnR5KElua0VkaXRvciwgIl9sMTBuUHJvbWlzZSIsIHZvaWQgMCk7CiAgICAgICAgICAgICAgICBfZGVmaW5lUHJvcGVydHkoSW5rRWRpdG9yLCAiX3R5cGUiLCAiaW5rIik7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDE2NSAqLwogICAgICAgICAgICAvKioqLyAoKF9fdW51c2VkX3dlYnBhY2tfbW9kdWxlLCBleHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKCiAgICAgICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIl9fZXNNb2R1bGUiLCAoewogICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0cnVlCiAgICAgICAgICAgICAgICB9KSk7CiAgICAgICAgICAgICAgICBleHBvcnRzLmZpdEN1cnZlID0gdm9pZCAwOwogICAgICAgICAgICAgICAgY29uc3QgZml0Q3VydmUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE2Nik7CiAgICAgICAgICAgICAgICBleHBvcnRzLmZpdEN1cnZlID0gZml0Q3VydmU7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDE2NiAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSkgPT4gewoKICAgICAgICAgICAgICAgICJ1c2Ugc3RyaWN0IjsKCgogICAgICAgICAgICAgICAgZnVuY3Rpb24gZml0Q3VydmUocG9pbnRzLCBtYXhFcnJvciwgcHJvZ3Jlc3NDYWxsYmFjaykgewogICAgICAgICAgICAgICAgICAgIGlmICghQXJyYXkuaXNBcnJheShwb2ludHMpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBUeXBlRXJyb3IoIkZpcnN0IGFyZ3VtZW50IHNob3VsZCBiZSBhbiBhcnJheSIpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBwb2ludHMuZm9yRWFjaChwb2ludCA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghQXJyYXkuaXNBcnJheShwb2ludCkgfHwgcG9pbnQuc29tZShpdGVtID0+IHR5cGVvZiBpdGVtICE9PSAnbnVtYmVyJykgfHwgcG9pbnQubGVuZ3RoICE9PSBwb2ludHNbMF0ubGVuZ3RoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBFcnJvcigiRWFjaCBwb2ludCBzaG91bGQgYmUgYW4gYXJyYXkgb2YgbnVtYmVycy4gRWFjaCBwb2ludCBzaG91bGQgaGF2ZSB0aGUgc2FtZSBhbW91bnQgb2YgbnVtYmVycy4iKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIHBvaW50cyA9IHBvaW50cy5maWx0ZXIoKHBvaW50LCBpKSA9PiBpID09PSAwIHx8ICFwb2ludC5ldmVyeSgodmFsLCBqKSA9PiB2YWwgPT09IHBvaW50c1tpIC0gMV1bal0pKTsKICAgICAgICAgICAgICAgICAgICBpZiAocG9pbnRzLmxlbmd0aCA8IDIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFtdOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjb25zdCBsZW4gPSBwb2ludHMubGVuZ3RoOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IGxlZnRUYW5nZW50ID0gY3JlYXRlVGFuZ2VudChwb2ludHNbMV0sIHBvaW50c1swXSk7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgcmlnaHRUYW5nZW50ID0gY3JlYXRlVGFuZ2VudChwb2ludHNbbGVuIC0gMl0sIHBvaW50c1tsZW4gLSAxXSk7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZpdEN1YmljKHBvaW50cywgbGVmdFRhbmdlbnQsIHJpZ2h0VGFuZ2VudCwgbWF4RXJyb3IsIHByb2dyZXNzQ2FsbGJhY2spOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gZml0Q3ViaWMocG9pbnRzLCBsZWZ0VGFuZ2VudCwgcmlnaHRUYW5nZW50LCBlcnJvciwgcHJvZ3Jlc3NDYWxsYmFjaykgewogICAgICAgICAgICAgICAgICAgIGNvbnN0IE1heEl0ZXJhdGlvbnMgPSAyMDsKICAgICAgICAgICAgICAgICAgICB2YXIgYmV6Q3VydmUsIHUsIHVQcmltZSwgbWF4RXJyb3IsIHByZXZFcnIsIHNwbGl0UG9pbnQsIHByZXZTcGxpdCwgY2VudGVyVmVjdG9yLCB0b0NlbnRlclRhbmdlbnQsIGZyb21DZW50ZXJUYW5nZW50LCBiZXppZXJzLCBkaXN0LCBpOwogICAgICAgICAgICAgICAgICAgIGlmIChwb2ludHMubGVuZ3RoID09PSAyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGRpc3QgPSBtYXRocy52ZWN0b3JMZW4obWF0aHMuc3VidHJhY3QocG9pbnRzWzBdLCBwb2ludHNbMV0pKSAvIDMuMDsKICAgICAgICAgICAgICAgICAgICAgICAgYmV6Q3VydmUgPSBbcG9pbnRzWzBdLCBtYXRocy5hZGRBcnJheXMocG9pbnRzWzBdLCBtYXRocy5tdWxJdGVtcyhsZWZ0VGFuZ2VudCwgZGlzdCkpLCBtYXRocy5hZGRBcnJheXMocG9pbnRzWzFdLCBtYXRocy5tdWxJdGVtcyhyaWdodFRhbmdlbnQsIGRpc3QpKSwgcG9pbnRzWzFdXTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFtiZXpDdXJ2ZV07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHUgPSBjaG9yZExlbmd0aFBhcmFtZXRlcml6ZShwb2ludHMpOwogICAgICAgICAgICAgICAgICAgIFtiZXpDdXJ2ZSwgbWF4RXJyb3IsIHNwbGl0UG9pbnRdID0gZ2VuZXJhdGVBbmRSZXBvcnQocG9pbnRzLCB1LCB1LCBsZWZ0VGFuZ2VudCwgcmlnaHRUYW5nZW50LCBwcm9ncmVzc0NhbGxiYWNrKTsKICAgICAgICAgICAgICAgICAgICBpZiAobWF4RXJyb3IgPT09IDAgfHwgbWF4RXJyb3IgPCBlcnJvcikgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gW2JlekN1cnZlXTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaWYgKG1heEVycm9yIDwgZXJyb3IgKiBlcnJvcikgewogICAgICAgICAgICAgICAgICAgICAgICB1UHJpbWUgPSB1OwogICAgICAgICAgICAgICAgICAgICAgICBwcmV2RXJyID0gbWF4RXJyb3I7CiAgICAgICAgICAgICAgICAgICAgICAgIHByZXZTcGxpdCA9IHNwbGl0UG9pbnQ7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoaSA9IDA7IGkgPCBNYXhJdGVyYXRpb25zOyBpKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVQcmltZSA9IHJlcGFyYW1ldGVyaXplKGJlekN1cnZlLCBwb2ludHMsIHVQcmltZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBbYmV6Q3VydmUsIG1heEVycm9yLCBzcGxpdFBvaW50XSA9IGdlbmVyYXRlQW5kUmVwb3J0KHBvaW50cywgdSwgdVByaW1lLCBsZWZ0VGFuZ2VudCwgcmlnaHRUYW5nZW50LCBwcm9ncmVzc0NhbGxiYWNrKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChtYXhFcnJvciA8IGVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFtiZXpDdXJ2ZV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHNwbGl0UG9pbnQgPT09IHByZXZTcGxpdCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBlcnJDaGFuZ2UgPSBtYXhFcnJvciAvIHByZXZFcnI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGVyckNoYW5nZSA+IC45OTk5ICYmIGVyckNoYW5nZSA8IDEuMDAwMSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwcmV2RXJyID0gbWF4RXJyb3I7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwcmV2U3BsaXQgPSBzcGxpdFBvaW50OwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGJlemllcnMgPSBbXTsKICAgICAgICAgICAgICAgICAgICBjZW50ZXJWZWN0b3IgPSBtYXRocy5zdWJ0cmFjdChwb2ludHNbc3BsaXRQb2ludCAtIDFdLCBwb2ludHNbc3BsaXRQb2ludCArIDFdKTsKICAgICAgICAgICAgICAgICAgICBpZiAoY2VudGVyVmVjdG9yLmV2ZXJ5KHZhbCA9PiB2YWwgPT09IDApKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNlbnRlclZlY3RvciA9IG1hdGhzLnN1YnRyYWN0KHBvaW50c1tzcGxpdFBvaW50IC0gMV0sIHBvaW50c1tzcGxpdFBvaW50XSk7CiAgICAgICAgICAgICAgICAgICAgICAgIFtjZW50ZXJWZWN0b3JbMF0sIGNlbnRlclZlY3RvclsxXV0gPSBbLWNlbnRlclZlY3RvclsxXSwgY2VudGVyVmVjdG9yWzBdXTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdG9DZW50ZXJUYW5nZW50ID0gbWF0aHMubm9ybWFsaXplKGNlbnRlclZlY3Rvcik7CiAgICAgICAgICAgICAgICAgICAgZnJvbUNlbnRlclRhbmdlbnQgPSBtYXRocy5tdWxJdGVtcyh0b0NlbnRlclRhbmdlbnQsIC0xKTsKICAgICAgICAgICAgICAgICAgICBiZXppZXJzID0gYmV6aWVycy5jb25jYXQoZml0Q3ViaWMocG9pbnRzLnNsaWNlKDAsIHNwbGl0UG9pbnQgKyAxKSwgbGVmdFRhbmdlbnQsIHRvQ2VudGVyVGFuZ2VudCwgZXJyb3IsIHByb2dyZXNzQ2FsbGJhY2spKTsKICAgICAgICAgICAgICAgICAgICBiZXppZXJzID0gYmV6aWVycy5jb25jYXQoZml0Q3ViaWMocG9pbnRzLnNsaWNlKHNwbGl0UG9pbnQpLCBmcm9tQ2VudGVyVGFuZ2VudCwgcmlnaHRUYW5nZW50LCBlcnJvciwgcHJvZ3Jlc3NDYWxsYmFjaykpOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBiZXppZXJzOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgOwogICAgICAgICAgICAgICAgZnVuY3Rpb24gZ2VuZXJhdGVBbmRSZXBvcnQocG9pbnRzLCBwYXJhbXNPcmlnLCBwYXJhbXNQcmltZSwgbGVmdFRhbmdlbnQsIHJpZ2h0VGFuZ2VudCwgcHJvZ3Jlc3NDYWxsYmFjaykgewogICAgICAgICAgICAgICAgICAgIHZhciBiZXpDdXJ2ZSwgbWF4RXJyb3IsIHNwbGl0UG9pbnQ7CiAgICAgICAgICAgICAgICAgICAgYmV6Q3VydmUgPSBnZW5lcmF0ZUJlemllcihwb2ludHMsIHBhcmFtc1ByaW1lLCBsZWZ0VGFuZ2VudCwgcmlnaHRUYW5nZW50LCBwcm9ncmVzc0NhbGxiYWNrKTsKICAgICAgICAgICAgICAgICAgICBbbWF4RXJyb3IsIHNwbGl0UG9pbnRdID0gY29tcHV0ZU1heEVycm9yKHBvaW50cywgYmV6Q3VydmUsIHBhcmFtc09yaWcpOwogICAgICAgICAgICAgICAgICAgIGlmIChwcm9ncmVzc0NhbGxiYWNrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHByb2dyZXNzQ2FsbGJhY2soewogICAgICAgICAgICAgICAgICAgICAgICAgICAgYmV6OiBiZXpDdXJ2ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBvaW50czogcG9pbnRzLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFyYW1zOiBwYXJhbXNPcmlnLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgbWF4RXJyOiBtYXhFcnJvciwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1heFBvaW50OiBzcGxpdFBvaW50CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gW2JlekN1cnZlLCBtYXhFcnJvciwgc3BsaXRQb2ludF07CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBnZW5lcmF0ZUJlemllcihwb2ludHMsIHBhcmFtZXRlcnMsIGxlZnRUYW5nZW50LCByaWdodFRhbmdlbnQpIHsKICAgICAgICAgICAgICAgICAgICB2YXIgYmV6Q3VydmUsCiAgICAgICAgICAgICAgICAgICAgICAgIEEsCiAgICAgICAgICAgICAgICAgICAgICAgIGEsCiAgICAgICAgICAgICAgICAgICAgICAgIEMsCiAgICAgICAgICAgICAgICAgICAgICAgIFgsCiAgICAgICAgICAgICAgICAgICAgICAgIGRldF9DMF9DMSwKICAgICAgICAgICAgICAgICAgICAgICAgZGV0X0MwX1gsCiAgICAgICAgICAgICAgICAgICAgICAgIGRldF9YX0MxLAogICAgICAgICAgICAgICAgICAgICAgICBhbHBoYV9sLAogICAgICAgICAgICAgICAgICAgICAgICBhbHBoYV9yLAogICAgICAgICAgICAgICAgICAgICAgICBlcHNpbG9uLAogICAgICAgICAgICAgICAgICAgICAgICBzZWdMZW5ndGgsCiAgICAgICAgICAgICAgICAgICAgICAgIGksCiAgICAgICAgICAgICAgICAgICAgICAgIGxlbiwKICAgICAgICAgICAgICAgICAgICAgICAgdG1wLAogICAgICAgICAgICAgICAgICAgICAgICB1LAogICAgICAgICAgICAgICAgICAgICAgICB1eCwKICAgICAgICAgICAgICAgICAgICAgICAgZmlyc3RQb2ludCA9IHBvaW50c1swXSwKICAgICAgICAgICAgICAgICAgICAgICAgbGFzdFBvaW50ID0gcG9pbnRzW3BvaW50cy5sZW5ndGggLSAxXTsKICAgICAgICAgICAgICAgICAgICBiZXpDdXJ2ZSA9IFtmaXJzdFBvaW50LCBudWxsLCBudWxsLCBsYXN0UG9pbnRdOwogICAgICAgICAgICAgICAgICAgIEEgPSBtYXRocy56ZXJvc19YeDJ4MihwYXJhbWV0ZXJzLmxlbmd0aCk7CiAgICAgICAgICAgICAgICAgICAgZm9yIChpID0gMCwgbGVuID0gcGFyYW1ldGVycy5sZW5ndGg7IGkgPCBsZW47IGkrKykgewogICAgICAgICAgICAgICAgICAgICAgICB1ID0gcGFyYW1ldGVyc1tpXTsKICAgICAgICAgICAgICAgICAgICAgICAgdXggPSAxIC0gdTsKICAgICAgICAgICAgICAgICAgICAgICAgYSA9IEFbaV07CiAgICAgICAgICAgICAgICAgICAgICAgIGFbMF0gPSBtYXRocy5tdWxJdGVtcyhsZWZ0VGFuZ2VudCwgMyAqIHUgKiAodXggKiB1eCkpOwogICAgICAgICAgICAgICAgICAgICAgICBhWzFdID0gbWF0aHMubXVsSXRlbXMocmlnaHRUYW5nZW50LCAzICogdXggKiAodSAqIHUpKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgQyA9IFtbMCwgMF0sIFswLCAwXV07CiAgICAgICAgICAgICAgICAgICAgWCA9IFswLCAwXTsKICAgICAgICAgICAgICAgICAgICBmb3IgKGkgPSAwLCBsZW4gPSBwb2ludHMubGVuZ3RoOyBpIDwgbGVuOyBpKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgdSA9IHBhcmFtZXRlcnNbaV07CiAgICAgICAgICAgICAgICAgICAgICAgIGEgPSBBW2ldOwogICAgICAgICAgICAgICAgICAgICAgICBDWzBdWzBdICs9IG1hdGhzLmRvdChhWzBdLCBhWzBdKTsKICAgICAgICAgICAgICAgICAgICAgICAgQ1swXVsxXSArPSBtYXRocy5kb3QoYVswXSwgYVsxXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIENbMV1bMF0gKz0gbWF0aHMuZG90KGFbMF0sIGFbMV0pOwogICAgICAgICAgICAgICAgICAgICAgICBDWzFdWzFdICs9IG1hdGhzLmRvdChhWzFdLCBhWzFdKTsKICAgICAgICAgICAgICAgICAgICAgICAgdG1wID0gbWF0aHMuc3VidHJhY3QocG9pbnRzW2ldLCBiZXppZXIucShbZmlyc3RQb2ludCwgZmlyc3RQb2ludCwgbGFzdFBvaW50LCBsYXN0UG9pbnRdLCB1KSk7CiAgICAgICAgICAgICAgICAgICAgICAgIFhbMF0gKz0gbWF0aHMuZG90KGFbMF0sIHRtcCk7CiAgICAgICAgICAgICAgICAgICAgICAgIFhbMV0gKz0gbWF0aHMuZG90KGFbMV0sIHRtcCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGRldF9DMF9DMSA9IENbMF1bMF0gKiBDWzFdWzFdIC0gQ1sxXVswXSAqIENbMF1bMV07CiAgICAgICAgICAgICAgICAgICAgZGV0X0MwX1ggPSBDWzBdWzBdICogWFsxXSAtIENbMV1bMF0gKiBYWzBdOwogICAgICAgICAgICAgICAgICAgIGRldF9YX0MxID0gWFswXSAqIENbMV1bMV0gLSBYWzFdICogQ1swXVsxXTsKICAgICAgICAgICAgICAgICAgICBhbHBoYV9sID0gZGV0X0MwX0MxID09PSAwID8gMCA6IGRldF9YX0MxIC8gZGV0X0MwX0MxOwogICAgICAgICAgICAgICAgICAgIGFscGhhX3IgPSBkZXRfQzBfQzEgPT09IDAgPyAwIDogZGV0X0MwX1ggLyBkZXRfQzBfQzE7CiAgICAgICAgICAgICAgICAgICAgc2VnTGVuZ3RoID0gbWF0aHMudmVjdG9yTGVuKG1hdGhzLnN1YnRyYWN0KGZpcnN0UG9pbnQsIGxhc3RQb2ludCkpOwogICAgICAgICAgICAgICAgICAgIGVwc2lsb24gPSAxLjBlLTYgKiBzZWdMZW5ndGg7CiAgICAgICAgICAgICAgICAgICAgaWYgKGFscGhhX2wgPCBlcHNpbG9uIHx8IGFscGhhX3IgPCBlcHNpbG9uKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGJlekN1cnZlWzFdID0gbWF0aHMuYWRkQXJyYXlzKGZpcnN0UG9pbnQsIG1hdGhzLm11bEl0ZW1zKGxlZnRUYW5nZW50LCBzZWdMZW5ndGggLyAzLjApKTsKICAgICAgICAgICAgICAgICAgICAgICAgYmV6Q3VydmVbMl0gPSBtYXRocy5hZGRBcnJheXMobGFzdFBvaW50LCBtYXRocy5tdWxJdGVtcyhyaWdodFRhbmdlbnQsIHNlZ0xlbmd0aCAvIDMuMCkpOwogICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGJlekN1cnZlWzFdID0gbWF0aHMuYWRkQXJyYXlzKGZpcnN0UG9pbnQsIG1hdGhzLm11bEl0ZW1zKGxlZnRUYW5nZW50LCBhbHBoYV9sKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGJlekN1cnZlWzJdID0gbWF0aHMuYWRkQXJyYXlzKGxhc3RQb2ludCwgbWF0aHMubXVsSXRlbXMocmlnaHRUYW5nZW50LCBhbHBoYV9yKSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJldHVybiBiZXpDdXJ2ZTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIDsKICAgICAgICAgICAgICAgIGZ1bmN0aW9uIHJlcGFyYW1ldGVyaXplKGJlemllciwgcG9pbnRzLCBwYXJhbWV0ZXJzKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHBhcmFtZXRlcnMubWFwKChwLCBpKSA9PiBuZXd0b25SYXBoc29uUm9vdEZpbmQoYmV6aWVyLCBwb2ludHNbaV0sIHApKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIDsKICAgICAgICAgICAgICAgIGZ1bmN0aW9uIG5ld3RvblJhcGhzb25Sb290RmluZChiZXosIHBvaW50LCB1KSB7CiAgICAgICAgICAgICAgICAgICAgdmFyIGQgPSBtYXRocy5zdWJ0cmFjdChiZXppZXIucShiZXosIHUpLCBwb2ludCksCiAgICAgICAgICAgICAgICAgICAgICAgIHFwcmltZSA9IGJlemllci5xcHJpbWUoYmV6LCB1KSwKICAgICAgICAgICAgICAgICAgICAgICAgbnVtZXJhdG9yID0gbWF0aHMubXVsTWF0cml4KGQsIHFwcmltZSksCiAgICAgICAgICAgICAgICAgICAgICAgIGRlbm9taW5hdG9yID0gbWF0aHMuc3VtKG1hdGhzLnNxdWFyZUl0ZW1zKHFwcmltZSkpICsgMiAqIG1hdGhzLm11bE1hdHJpeChkLCBiZXppZXIucXByaW1lcHJpbWUoYmV6LCB1KSk7CiAgICAgICAgICAgICAgICAgICAgaWYgKGRlbm9taW5hdG9yID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB1OwogICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB1IC0gbnVtZXJhdG9yIC8gZGVub21pbmF0b3I7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgOwogICAgICAgICAgICAgICAgZnVuY3Rpb24gY2hvcmRMZW5ndGhQYXJhbWV0ZXJpemUocG9pbnRzKSB7CiAgICAgICAgICAgICAgICAgICAgdmFyIHUgPSBbXSwKICAgICAgICAgICAgICAgICAgICAgICAgY3VyclUsCiAgICAgICAgICAgICAgICAgICAgICAgIHByZXZVLAogICAgICAgICAgICAgICAgICAgICAgICBwcmV2UDsKICAgICAgICAgICAgICAgICAgICBwb2ludHMuZm9yRWFjaCgocCwgaSkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICBjdXJyVSA9IGkgPyBwcmV2VSArIG1hdGhzLnZlY3RvckxlbihtYXRocy5zdWJ0cmFjdChwLCBwcmV2UCkpIDogMDsKICAgICAgICAgICAgICAgICAgICAgICAgdS5wdXNoKGN1cnJVKTsKICAgICAgICAgICAgICAgICAgICAgICAgcHJldlUgPSBjdXJyVTsKICAgICAgICAgICAgICAgICAgICAgICAgcHJldlAgPSBwOwogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIHUgPSB1Lm1hcCh4ID0+IHggLyBwcmV2VSk7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHU7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICA7CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBjb21wdXRlTWF4RXJyb3IocG9pbnRzLCBiZXosIHBhcmFtZXRlcnMpIHsKICAgICAgICAgICAgICAgICAgICB2YXIgZGlzdCwgbWF4RGlzdCwgc3BsaXRQb2ludCwgdiwgaSwgY291bnQsIHBvaW50LCB0OwogICAgICAgICAgICAgICAgICAgIG1heERpc3QgPSAwOwogICAgICAgICAgICAgICAgICAgIHNwbGl0UG9pbnQgPSBNYXRoLmZsb29yKHBvaW50cy5sZW5ndGggLyAyKTsKICAgICAgICAgICAgICAgICAgICBjb25zdCB0X2Rpc3RNYXAgPSBtYXBUdG9SZWxhdGl2ZURpc3RhbmNlcyhiZXosIDEwKTsKICAgICAgICAgICAgICAgICAgICBmb3IgKGkgPSAwLCBjb3VudCA9IHBvaW50cy5sZW5ndGg7IGkgPCBjb3VudDsgaSsrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHBvaW50ID0gcG9pbnRzW2ldOwogICAgICAgICAgICAgICAgICAgICAgICB0ID0gZmluZF90KGJleiwgcGFyYW1ldGVyc1tpXSwgdF9kaXN0TWFwLCAxMCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHYgPSBtYXRocy5zdWJ0cmFjdChiZXppZXIucShiZXosIHQpLCBwb2ludCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGRpc3QgPSB2WzBdICogdlswXSArIHZbMV0gKiB2WzFdOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZGlzdCA+IG1heERpc3QpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1heERpc3QgPSBkaXN0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3BsaXRQb2ludCA9IGk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFttYXhEaXN0LCBzcGxpdFBvaW50XTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIDsKICAgICAgICAgICAgICAgIHZhciBtYXBUdG9SZWxhdGl2ZURpc3RhbmNlcyA9IGZ1bmN0aW9uIChiZXosIEJfcGFydHMpIHsKICAgICAgICAgICAgICAgICAgICB2YXIgQl90X2N1cnI7CiAgICAgICAgICAgICAgICAgICAgdmFyIEJfdF9kaXN0ID0gWzBdOwogICAgICAgICAgICAgICAgICAgIHZhciBCX3RfcHJldiA9IGJlelswXTsKICAgICAgICAgICAgICAgICAgICB2YXIgc3VtTGVuID0gMDsKICAgICAgICAgICAgICAgICAgICBmb3IgKHZhciBpID0gMTsgaSA8PSBCX3BhcnRzOyBpKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgQl90X2N1cnIgPSBiZXppZXIucShiZXosIGkgLyBCX3BhcnRzKTsKICAgICAgICAgICAgICAgICAgICAgICAgc3VtTGVuICs9IG1hdGhzLnZlY3RvckxlbihtYXRocy5zdWJ0cmFjdChCX3RfY3VyciwgQl90X3ByZXYpKTsKICAgICAgICAgICAgICAgICAgICAgICAgQl90X2Rpc3QucHVzaChzdW1MZW4pOwogICAgICAgICAgICAgICAgICAgICAgICBCX3RfcHJldiA9IEJfdF9jdXJyOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBCX3RfZGlzdCA9IEJfdF9kaXN0Lm1hcCh4ID0+IHggLyBzdW1MZW4pOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBCX3RfZGlzdDsKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBmaW5kX3QoYmV6LCBwYXJhbSwgdF9kaXN0TWFwLCBCX3BhcnRzKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKHBhcmFtIDwgMCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gMDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaWYgKHBhcmFtID4gMSkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gMTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdmFyIGxlbk1heCwgbGVuTWluLCB0TWF4LCB0TWluLCB0OwogICAgICAgICAgICAgICAgICAgIGZvciAodmFyIGkgPSAxOyBpIDw9IEJfcGFydHM7IGkrKykgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAocGFyYW0gPD0gdF9kaXN0TWFwW2ldKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0TWluID0gKGkgLSAxKSAvIEJfcGFydHM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0TWF4ID0gaSAvIEJfcGFydHM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZW5NaW4gPSB0X2Rpc3RNYXBbaSAtIDFdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGVuTWF4ID0gdF9kaXN0TWFwW2ldOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdCA9IChwYXJhbSAtIGxlbk1pbikgLyAobGVuTWF4IC0gbGVuTWluKSAqICh0TWF4IC0gdE1pbikgKyB0TWluOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHQ7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBjcmVhdGVUYW5nZW50KHBvaW50QSwgcG9pbnRCKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG1hdGhzLm5vcm1hbGl6ZShtYXRocy5zdWJ0cmFjdChwb2ludEEsIHBvaW50QikpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY2xhc3MgbWF0aHMgewogICAgICAgICAgICAgICAgICAgIHN0YXRpYyB6ZXJvc19YeDJ4Mih4KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciB6cyA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICB3aGlsZSAoeC0tKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB6cy5wdXNoKFswLCAwXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHpzOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzdGF0aWMgbXVsSXRlbXMoaXRlbXMsIG11bHRpcGxpZXIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGl0ZW1zLm1hcCh4ID0+IHggKiBtdWx0aXBsaWVyKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIG11bE1hdHJpeChtMSwgbTIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG0xLnJlZHVjZSgoc3VtLCB4MSwgaSkgPT4gc3VtICsgeDEgKiBtMltpXSwgMCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBzdWJ0cmFjdChhcnIxLCBhcnIyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBhcnIxLm1hcCgoeDEsIGkpID0+IHgxIC0gYXJyMltpXSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBhZGRBcnJheXMoYXJyMSwgYXJyMikgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gYXJyMS5tYXAoKHgxLCBpKSA9PiB4MSArIGFycjJbaV0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzdGF0aWMgYWRkSXRlbXMoaXRlbXMsIGFkZGl0aW9uKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBpdGVtcy5tYXAoeCA9PiB4ICsgYWRkaXRpb24pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzdGF0aWMgc3VtKGl0ZW1zKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBpdGVtcy5yZWR1Y2UoKHN1bSwgeCkgPT4gc3VtICsgeCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBkb3QobTEsIG0yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBtYXRocy5tdWxNYXRyaXgobTEsIG0yKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIHZlY3Rvckxlbih2KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBNYXRoLmh5cG90KC4uLnYpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzdGF0aWMgZGl2SXRlbXMoaXRlbXMsIGRpdmlzb3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGl0ZW1zLm1hcCh4ID0+IHggLyBkaXZpc29yKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIHNxdWFyZUl0ZW1zKGl0ZW1zKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBpdGVtcy5tYXAoeCA9PiB4ICogeCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBub3JtYWxpemUodikgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5kaXZJdGVtcyh2LCB0aGlzLnZlY3Rvckxlbih2KSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY2xhc3MgYmV6aWVyIHsKICAgICAgICAgICAgICAgICAgICBzdGF0aWMgcShjdHJsUG9seSwgdCkgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgdHggPSAxLjAgLSB0OwogICAgICAgICAgICAgICAgICAgICAgICB2YXIgcEEgPSBtYXRocy5tdWxJdGVtcyhjdHJsUG9seVswXSwgdHggKiB0eCAqIHR4KSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBCID0gbWF0aHMubXVsSXRlbXMoY3RybFBvbHlbMV0sIDMgKiB0eCAqIHR4ICogdCksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwQyA9IG1hdGhzLm11bEl0ZW1zKGN0cmxQb2x5WzJdLCAzICogdHggKiB0ICogdCksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwRCA9IG1hdGhzLm11bEl0ZW1zKGN0cmxQb2x5WzNdLCB0ICogdCAqIHQpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbWF0aHMuYWRkQXJyYXlzKG1hdGhzLmFkZEFycmF5cyhwQSwgcEIpLCBtYXRocy5hZGRBcnJheXMocEMsIHBEKSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBxcHJpbWUoY3RybFBvbHksIHQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHR4ID0gMS4wIC0gdDsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHBBID0gbWF0aHMubXVsSXRlbXMobWF0aHMuc3VidHJhY3QoY3RybFBvbHlbMV0sIGN0cmxQb2x5WzBdKSwgMyAqIHR4ICogdHgpLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcEIgPSBtYXRocy5tdWxJdGVtcyhtYXRocy5zdWJ0cmFjdChjdHJsUG9seVsyXSwgY3RybFBvbHlbMV0pLCA2ICogdHggKiB0KSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBDID0gbWF0aHMubXVsSXRlbXMobWF0aHMuc3VidHJhY3QoY3RybFBvbHlbM10sIGN0cmxQb2x5WzJdKSwgMyAqIHQgKiB0KTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG1hdGhzLmFkZEFycmF5cyhtYXRocy5hZGRBcnJheXMocEEsIHBCKSwgcEMpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzdGF0aWMgcXByaW1lcHJpbWUoY3RybFBvbHksIHQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG1hdGhzLmFkZEFycmF5cyhtYXRocy5tdWxJdGVtcyhtYXRocy5hZGRBcnJheXMobWF0aHMuc3VidHJhY3QoY3RybFBvbHlbMl0sIG1hdGhzLm11bEl0ZW1zKGN0cmxQb2x5WzFdLCAyKSksIGN0cmxQb2x5WzBdKSwgNiAqICgxLjAgLSB0KSksIG1hdGhzLm11bEl0ZW1zKG1hdGhzLmFkZEFycmF5cyhtYXRocy5zdWJ0cmFjdChjdHJsUG9seVszXSwgbWF0aHMubXVsSXRlbXMoY3RybFBvbHlbMl0sIDIpKSwgY3RybFBvbHlbMV0pLCA2ICogdCkpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZml0Q3VydmU7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cy5maXRDdWJpYyA9IGZpdEN1YmljOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMuY3JlYXRlVGFuZ2VudCA9IGNyZWF0ZVRhbmdlbnQ7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDE2NyAqLwogICAgICAgICAgICAvKioqLyAoKF9fdW51c2VkX3dlYnBhY2tfbW9kdWxlLCBleHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKCiAgICAgICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIl9fZXNNb2R1bGUiLCAoewogICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0cnVlCiAgICAgICAgICAgICAgICB9KSk7CiAgICAgICAgICAgICAgICBleHBvcnRzLkFubm90YXRpb25MYXllciA9IHZvaWQgMDsKICAgICAgICAgICAgICAgIHZhciBfdXRpbCA9IF9fd19wZGZqc19yZXF1aXJlX18oMSk7CiAgICAgICAgICAgICAgICB2YXIgX2Rpc3BsYXlfdXRpbHM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bGxlY3Rpb24uaGFzKG9iaikpIHsgdGhyb3cgbmV3IFR5cGVFcnJvcigiQ2Fubm90IGluaXRpYWxpemUgdGhlIHNhbWUgcHJpdmF0ZSBlbGVtZW50cyB0d2ljZSBvbiBhbiBvYmplY3QiKTsgfSB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHJlY2VpdmVyLCBwcml2YXRlU2V0LCBmbikgeyBpZiAoIXByaXZhdGVTZXQuaGFzKHJlY2VpdmVyKSkgeyB0aHJvdyBuZXcgVHlwZUVycm9yKCJhdHRlbXB0ZWQgdG8gZ2V0IHByaXZhdGUgZmllbGQgb24gbm9uLWluc3RhbmNlIik7IH0gcmV0dXJuIGZuOyB9CiAgICAgICAgICAgICAgICBjb25zdCBERUZBVUxUX1RBQl9JTkRFWCA9IDEwMDA7CiAgICAgICAgICAgICAgICBjb25zdCBERUZBVUxUX0ZPTlRfU0laRSA9IDk7CiAgICAgICAgICAgICAgICBjb25zdCBHZXRFbGVtZW50c0J5TmFtZVNldCA9IG5ldyBXZWFrU2V0KCk7CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBnZXRSZWN0RGltcyhyZWN0KSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHsKICAgICAgICAgICAgICAgICAgICAgICAgd2lkdGg6IHJlY3RbMl0gLSByZWN0WzBdLAogICAgICAgICAgICAgICAgICAgICAgICBoZWlnaHQ6IHJlY3RbM10gLSByZWN0WzFdCiAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNsYXNzIEFubm90YXRpb25FbGVtZW50RmFjdG9yeSB7CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIGNyZWF0ZShwYXJhbWV0ZXJzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN1YnR5cGUgPSBwYXJhbWV0ZXJzLmRhdGEuYW5ub3RhdGlvblR5cGU7CiAgICAgICAgICAgICAgICAgICAgICAgIHN3aXRjaCAoc3VidHlwZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uVHlwZS5MSU5LOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgTGlua0Fubm90YXRpb25FbGVtZW50KHBhcmFtZXRlcnMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uVHlwZS5URVhUOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgVGV4dEFubm90YXRpb25FbGVtZW50KHBhcmFtZXRlcnMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uVHlwZS5XSURHRVQ6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZmllbGRUeXBlID0gcGFyYW1ldGVycy5kYXRhLmZpZWxkVHlwZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzd2l0Y2ggKGZpZWxkVHlwZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJUeCI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IFRleHRXaWRnZXRBbm5vdGF0aW9uRWxlbWVudChwYXJhbWV0ZXJzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiQnRuIjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChwYXJhbWV0ZXJzLmRhdGEucmFkaW9CdXR0b24pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IFJhZGlvQnV0dG9uV2lkZ2V0QW5ub3RhdGlvbkVsZW1lbnQocGFyYW1ldGVycyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHBhcmFtZXRlcnMuZGF0YS5jaGVja0JveCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgQ2hlY2tib3hXaWRnZXRBbm5vdGF0aW9uRWxlbWVudChwYXJhbWV0ZXJzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgUHVzaEJ1dHRvbldpZGdldEFubm90YXRpb25FbGVtZW50KHBhcmFtZXRlcnMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJDaCI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IENob2ljZVdpZGdldEFubm90YXRpb25FbGVtZW50KHBhcmFtZXRlcnMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IFdpZGdldEFubm90YXRpb25FbGVtZW50KHBhcmFtZXRlcnMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uVHlwZS5QT1BVUDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IFBvcHVwQW5ub3RhdGlvbkVsZW1lbnQocGFyYW1ldGVycyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLkFubm90YXRpb25UeXBlLkZSRUVURVhUOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgRnJlZVRleHRBbm5vdGF0aW9uRWxlbWVudChwYXJhbWV0ZXJzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuQW5ub3RhdGlvblR5cGUuTElORToKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IExpbmVBbm5vdGF0aW9uRWxlbWVudChwYXJhbWV0ZXJzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuQW5ub3RhdGlvblR5cGUuU1FVQVJFOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgU3F1YXJlQW5ub3RhdGlvbkVsZW1lbnQocGFyYW1ldGVycyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLkFubm90YXRpb25UeXBlLkNJUkNMRToKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IENpcmNsZUFubm90YXRpb25FbGVtZW50KHBhcmFtZXRlcnMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uVHlwZS5QT0xZTElORToKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IFBvbHlsaW5lQW5ub3RhdGlvbkVsZW1lbnQocGFyYW1ldGVycyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLkFubm90YXRpb25UeXBlLkNBUkVUOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgQ2FyZXRBbm5vdGF0aW9uRWxlbWVudChwYXJhbWV0ZXJzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuQW5ub3RhdGlvblR5cGUuSU5LOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgSW5rQW5ub3RhdGlvbkVsZW1lbnQocGFyYW1ldGVycyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLkFubm90YXRpb25UeXBlLlBPTFlHT046CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG5ldyBQb2x5Z29uQW5ub3RhdGlvbkVsZW1lbnQocGFyYW1ldGVycyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLkFubm90YXRpb25UeXBlLkhJR0hMSUdIVDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IEhpZ2hsaWdodEFubm90YXRpb25FbGVtZW50KHBhcmFtZXRlcnMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uVHlwZS5VTkRFUkxJTkU6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG5ldyBVbmRlcmxpbmVBbm5vdGF0aW9uRWxlbWVudChwYXJhbWV0ZXJzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuQW5ub3RhdGlvblR5cGUuU1FVSUdHTFk6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG5ldyBTcXVpZ2dseUFubm90YXRpb25FbGVtZW50KHBhcmFtZXRlcnMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uVHlwZS5TVFJJS0VPVVQ6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG5ldyBTdHJpa2VPdXRBbm5vdGF0aW9uRWxlbWVudChwYXJhbWV0ZXJzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuQW5ub3RhdGlvblR5cGUuU1RBTVA6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG5ldyBTdGFtcEFubm90YXRpb25FbGVtZW50KHBhcmFtZXRlcnMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uVHlwZS5GSUxFQVRUQUNITUVOVDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IEZpbGVBdHRhY2htZW50QW5ub3RhdGlvbkVsZW1lbnQocGFyYW1ldGVycyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgQW5ub3RhdGlvbkVsZW1lbnQocGFyYW1ldGVycyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBBbm5vdGF0aW9uRWxlbWVudCB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IocGFyYW1ldGVycykgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNSZW5kZXJhYmxlID0gZmFsc2UsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZ25vcmVCb3JkZXIgPSBmYWxzZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNyZWF0ZVF1YWRyaWxhdGVyYWxzID0gZmFsc2UKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IGFyZ3VtZW50cy5sZW5ndGggPiAxICYmIGFyZ3VtZW50c1sxXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzFdIDoge307CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuaXNSZW5kZXJhYmxlID0gaXNSZW5kZXJhYmxlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRhdGEgPSBwYXJhbWV0ZXJzLmRhdGE7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubGF5ZXIgPSBwYXJhbWV0ZXJzLmxheWVyOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBhZ2UgPSBwYXJhbWV0ZXJzLnBhZ2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudmlld3BvcnQgPSBwYXJhbWV0ZXJzLnZpZXdwb3J0OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmxpbmtTZXJ2aWNlID0gcGFyYW1ldGVycy5saW5rU2VydmljZTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kb3dubG9hZE1hbmFnZXIgPSBwYXJhbWV0ZXJzLmRvd25sb2FkTWFuYWdlcjsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5pbWFnZVJlc291cmNlc1BhdGggPSBwYXJhbWV0ZXJzLmltYWdlUmVzb3VyY2VzUGF0aDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5yZW5kZXJGb3JtcyA9IHBhcmFtZXRlcnMucmVuZGVyRm9ybXM7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc3ZnRmFjdG9yeSA9IHBhcmFtZXRlcnMuc3ZnRmFjdG9yeTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5hbm5vdGF0aW9uU3RvcmFnZSA9IHBhcmFtZXRlcnMuYW5ub3RhdGlvblN0b3JhZ2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZW5hYmxlU2NyaXB0aW5nID0gcGFyYW1ldGVycy5lbmFibGVTY3JpcHRpbmc7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuaGFzSlNBY3Rpb25zID0gcGFyYW1ldGVycy5oYXNKU0FjdGlvbnM7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2ZpZWxkT2JqZWN0cyA9IHBhcmFtZXRlcnMuZmllbGRPYmplY3RzOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoaXNSZW5kZXJhYmxlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRhaW5lciA9IHRoaXMuX2NyZWF0ZUNvbnRhaW5lcihpZ25vcmVCb3JkZXIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjcmVhdGVRdWFkcmlsYXRlcmFscykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5xdWFkcmlsYXRlcmFscyA9IHRoaXMuX2NyZWF0ZVF1YWRyaWxhdGVyYWxzKGlnbm9yZUJvcmRlcik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX2NyZWF0ZUNvbnRhaW5lcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGlnbm9yZUJvcmRlciA9IGFyZ3VtZW50cy5sZW5ndGggPiAwICYmIGFyZ3VtZW50c1swXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzBdIDogZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRhdGEsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYWdlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmlld3BvcnQKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IHRoaXM7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNvbnRhaW5lciA9IGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoInNlY3Rpb24iKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29udGFpbmVyLnNldEF0dHJpYnV0ZSgiZGF0YS1hbm5vdGF0aW9uLWlkIiwgZGF0YS5pZCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChkYXRhLm5vUm90YXRlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250YWluZXIuY2xhc3NMaXN0LmFkZCgibm9yb3RhdGUiKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYWdlV2lkdGgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYWdlSGVpZ2h0LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFnZVgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYWdlWQogICAgICAgICAgICAgICAgICAgICAgICB9ID0gdmlld3BvcnQucmF3RGltczsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd2lkdGgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoZWlnaHQKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IGdldFJlY3REaW1zKGRhdGEucmVjdCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHJlY3QgPSBfdXRpbC5VdGlsLm5vcm1hbGl6ZVJlY3QoW2RhdGEucmVjdFswXSwgcGFnZS52aWV3WzNdIC0gZGF0YS5yZWN0WzFdICsgcGFnZS52aWV3WzFdLCBkYXRhLnJlY3RbMl0sIHBhZ2Uudmlld1szXSAtIGRhdGEucmVjdFszXSArIHBhZ2Uudmlld1sxXV0pOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWlnbm9yZUJvcmRlciAmJiBkYXRhLmJvcmRlclN0eWxlLndpZHRoID4gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGFpbmVyLnN0eWxlLmJvcmRlcldpZHRoID0gYCR7ZGF0YS5ib3JkZXJTdHlsZS53aWR0aH1weGA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBob3Jpem9udGFsUmFkaXVzID0gZGF0YS5ib3JkZXJTdHlsZS5ob3Jpem9udGFsQ29ybmVyUmFkaXVzOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdmVydGljYWxSYWRpdXMgPSBkYXRhLmJvcmRlclN0eWxlLnZlcnRpY2FsQ29ybmVyUmFkaXVzOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGhvcml6b250YWxSYWRpdXMgPiAwIHx8IHZlcnRpY2FsUmFkaXVzID4gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHJhZGl1cyA9IGBjYWxjKCR7aG9yaXpvbnRhbFJhZGl1c31weCAqIHZhcigtLXNjYWxlLWZhY3RvcikpIC8gY2FsYygke3ZlcnRpY2FsUmFkaXVzfXB4ICogdmFyKC0tc2NhbGUtZmFjdG9yKSlgOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRhaW5lci5zdHlsZS5ib3JkZXJSYWRpdXMgPSByYWRpdXM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHRoaXMgaW5zdGFuY2VvZiBSYWRpb0J1dHRvbldpZGdldEFubm90YXRpb25FbGVtZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmFkaXVzID0gYGNhbGMoJHt3aWR0aH1weCAqIHZhcigtLXNjYWxlLWZhY3RvcikpIC8gY2FsYygke2hlaWdodH1weCAqIHZhcigtLXNjYWxlLWZhY3RvcikpYDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250YWluZXIuc3R5bGUuYm9yZGVyUmFkaXVzID0gcmFkaXVzOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3dpdGNoIChkYXRhLmJvcmRlclN0eWxlLnN0eWxlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uQm9yZGVyU3R5bGVUeXBlLlNPTElEOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250YWluZXIuc3R5bGUuYm9yZGVyU3R5bGUgPSAic29saWQiOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLkFubm90YXRpb25Cb3JkZXJTdHlsZVR5cGUuREFTSEVEOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250YWluZXIuc3R5bGUuYm9yZGVyU3R5bGUgPSAiZGFzaGVkIjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uQm9yZGVyU3R5bGVUeXBlLkJFVkVMRUQ6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKSgiVW5pbXBsZW1lbnRlZCBib3JkZXIgc3R5bGU6IGJldmVsZWQiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uQm9yZGVyU3R5bGVUeXBlLklOU0VUOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoIlVuaW1wbGVtZW50ZWQgYm9yZGVyIHN0eWxlOiBpbnNldCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLkFubm90YXRpb25Cb3JkZXJTdHlsZVR5cGUuVU5ERVJMSU5FOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250YWluZXIuc3R5bGUuYm9yZGVyQm90dG9tU3R5bGUgPSAic29saWQiOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGJvcmRlckNvbG9yID0gZGF0YS5ib3JkZXJDb2xvciB8fCBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGJvcmRlckNvbG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGFpbmVyLnN0eWxlLmJvcmRlckNvbG9yID0gX3V0aWwuVXRpbC5tYWtlSGV4Q29sb3IoYm9yZGVyQ29sb3JbMF0gfCAwLCBib3JkZXJDb2xvclsxXSB8IDAsIGJvcmRlckNvbG9yWzJdIHwgMCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRhaW5lci5zdHlsZS5ib3JkZXJXaWR0aCA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29udGFpbmVyLnN0eWxlLmxlZnQgPSBgJHsxMDAgKiAocmVjdFswXSAtIHBhZ2VYKSAvIHBhZ2VXaWR0aH0lYDsKICAgICAgICAgICAgICAgICAgICAgICAgY29udGFpbmVyLnN0eWxlLnRvcCA9IGAkezEwMCAqIChyZWN0WzFdIC0gcGFnZVkpIC8gcGFnZUhlaWdodH0lYDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcm90YXRpb24KICAgICAgICAgICAgICAgICAgICAgICAgfSA9IGRhdGE7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChkYXRhLmhhc093bkNhbnZhcyB8fCByb3RhdGlvbiA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGFpbmVyLnN0eWxlLndpZHRoID0gYCR7MTAwICogd2lkdGggLyBwYWdlV2lkdGh9JWA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250YWluZXIuc3R5bGUuaGVpZ2h0ID0gYCR7MTAwICogaGVpZ2h0IC8gcGFnZUhlaWdodH0lYDsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0Um90YXRpb24ocm90YXRpb24sIGNvbnRhaW5lcik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGNvbnRhaW5lcjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2V0Um90YXRpb24oYW5nbGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGNvbnRhaW5lciA9IGFyZ3VtZW50cy5sZW5ndGggPiAxICYmIGFyZ3VtZW50c1sxXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzFdIDogdGhpcy5jb250YWluZXI7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2VXaWR0aCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2VIZWlnaHQKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IHRoaXMudmlld3BvcnQucmF3RGltczsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd2lkdGgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoZWlnaHQKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IGdldFJlY3REaW1zKHRoaXMuZGF0YS5yZWN0KTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGVsZW1lbnRXaWR0aCwgZWxlbWVudEhlaWdodDsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGFuZ2xlICUgMTgwID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50V2lkdGggPSAxMDAgKiB3aWR0aCAvIHBhZ2VXaWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1lbnRIZWlnaHQgPSAxMDAgKiBoZWlnaHQgLyBwYWdlSGVpZ2h0OwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudFdpZHRoID0gMTAwICogaGVpZ2h0IC8gcGFnZVdpZHRoOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudEhlaWdodCA9IDEwMCAqIHdpZHRoIC8gcGFnZUhlaWdodDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb250YWluZXIuc3R5bGUud2lkdGggPSBgJHtlbGVtZW50V2lkdGh9JWA7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRhaW5lci5zdHlsZS5oZWlnaHQgPSBgJHtlbGVtZW50SGVpZ2h0fSVgOwogICAgICAgICAgICAgICAgICAgICAgICBjb250YWluZXIuc2V0QXR0cmlidXRlKCJkYXRhLW1haW4tcm90YXRpb24iLCAoMzYwIC0gYW5nbGUpICUgMzYwKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IF9jb21tb25BY3Rpb25zKCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzZXRDb2xvciA9IChqc05hbWUsIHN0eWxlTmFtZSwgZXZlbnQpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNvbG9yID0gZXZlbnQuZGV0YWlsW2pzTmFtZV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBldmVudC50YXJnZXQuc3R5bGVbc3R5bGVOYW1lXSA9IF9zY3JpcHRpbmdfdXRpbHMuQ29sb3JDb252ZXJ0ZXJzW2Ake2NvbG9yWzBdfV9IVE1MYF0oY29sb3Iuc2xpY2UoMSkpOwogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gKDAsIF91dGlsLnNoYWRvdykodGhpcywgIl9jb21tb25BY3Rpb25zIiwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGlzcGxheTogZXZlbnQgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGhpZGRlbiA9IGV2ZW50LmRldGFpbC5kaXNwbGF5ICUgMiA9PT0gMTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRhaW5lci5zdHlsZS52aXNpYmlsaXR5ID0gaGlkZGVuID8gImhpZGRlbiIgOiAidmlzaWJsZSI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5hbm5vdGF0aW9uU3RvcmFnZS5zZXRWYWx1ZSh0aGlzLmRhdGEuaWQsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaGlkZGVuLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwcmludDogZXZlbnQuZGV0YWlsLmRpc3BsYXkgPT09IDAgfHwgZXZlbnQuZGV0YWlsLmRpc3BsYXkgPT09IDMKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwcmludDogZXZlbnQgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYW5ub3RhdGlvblN0b3JhZ2Uuc2V0VmFsdWUodGhpcy5kYXRhLmlkLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHByaW50OiBldmVudC5kZXRhaWwucHJpbnQKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoaWRkZW46IGV2ZW50ID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRhaW5lci5zdHlsZS52aXNpYmlsaXR5ID0gZXZlbnQuZGV0YWlsLmhpZGRlbiA/ICJoaWRkZW4iIDogInZpc2libGUiOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYW5ub3RhdGlvblN0b3JhZ2Uuc2V0VmFsdWUodGhpcy5kYXRhLmlkLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGhpZGRlbjogZXZlbnQuZGV0YWlsLmhpZGRlbgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvY3VzOiBldmVudCA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2V0VGltZW91dCgoKSA9PiBldmVudC50YXJnZXQuZm9jdXMoewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwcmV2ZW50U2Nyb2xsOiBmYWxzZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pLCAwKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB1c2VyTmFtZTogZXZlbnQgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGV2ZW50LnRhcmdldC50aXRsZSA9IGV2ZW50LmRldGFpbC51c2VyTmFtZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWFkb25seTogZXZlbnQgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChldmVudC5kZXRhaWwucmVhZG9ubHkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZXZlbnQudGFyZ2V0LnNldEF0dHJpYnV0ZSgicmVhZG9ubHkiLCAiIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZXZlbnQudGFyZ2V0LnJlbW92ZUF0dHJpYnV0ZSgicmVhZG9ubHkiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVxdWlyZWQ6IGV2ZW50ID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9zZXRSZXF1aXJlZChldmVudC50YXJnZXQsIGV2ZW50LmRldGFpbC5yZXF1aXJlZCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgYmdDb2xvcjogZXZlbnQgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNldENvbG9yKCJiZ0NvbG9yIiwgImJhY2tncm91bmRDb2xvciIsIGV2ZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmaWxsQ29sb3I6IGV2ZW50ID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZXRDb2xvcigiZmlsbENvbG9yIiwgImJhY2tncm91bmRDb2xvciIsIGV2ZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmZ0NvbG9yOiBldmVudCA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2V0Q29sb3IoImZnQ29sb3IiLCAiY29sb3IiLCBldmVudCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGV4dENvbG9yOiBldmVudCA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2V0Q29sb3IoInRleHRDb2xvciIsICJjb2xvciIsIGV2ZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBib3JkZXJDb2xvcjogZXZlbnQgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNldENvbG9yKCJib3JkZXJDb2xvciIsICJib3JkZXJDb2xvciIsIGV2ZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHJva2VDb2xvcjogZXZlbnQgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNldENvbG9yKCJzdHJva2VDb2xvciIsICJib3JkZXJDb2xvciIsIGV2ZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICByb3RhdGlvbjogZXZlbnQgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGFuZ2xlID0gZXZlbnQuZGV0YWlsLnJvdGF0aW9uOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0Um90YXRpb24oYW5nbGUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYW5ub3RhdGlvblN0b3JhZ2Uuc2V0VmFsdWUodGhpcy5kYXRhLmlkLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJvdGF0aW9uOiBhbmdsZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX2Rpc3BhdGNoRXZlbnRGcm9tU2FuZGJveChhY3Rpb25zLCBqc0V2ZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNvbW1vbkFjdGlvbnMgPSB0aGlzLl9jb21tb25BY3Rpb25zOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IG5hbWUgb2YgT2JqZWN0LmtleXMoanNFdmVudC5kZXRhaWwpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBhY3Rpb24gPSBhY3Rpb25zW25hbWVdIHx8IGNvbW1vbkFjdGlvbnNbbmFtZV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhY3Rpb24gPT09IG51bGwgfHwgYWN0aW9uID09PSB2b2lkIDAgPyB2b2lkIDAgOiBhY3Rpb24oanNFdmVudCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX3NldERlZmF1bHRQcm9wZXJ0aWVzRnJvbUpTKGVsZW1lbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLmVuYWJsZVNjcmlwdGluZykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0b3JlZERhdGEgPSB0aGlzLmFubm90YXRpb25TdG9yYWdlLmdldFJhd1ZhbHVlKHRoaXMuZGF0YS5pZCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghc3RvcmVkRGF0YSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNvbW1vbkFjdGlvbnMgPSB0aGlzLl9jb21tb25BY3Rpb25zOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IFthY3Rpb25OYW1lLCBkZXRhaWxdIG9mIE9iamVjdC5lbnRyaWVzKHN0b3JlZERhdGEpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBhY3Rpb24gPSBjb21tb25BY3Rpb25zW2FjdGlvbk5hbWVdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGFjdGlvbikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGV2ZW50UHJveHkgPSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRldGFpbDogewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgW2FjdGlvbk5hbWVdOiBkZXRhaWwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGFyZ2V0OiBlbGVtZW50CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhY3Rpb24oZXZlbnRQcm94eSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVsZXRlIHN0b3JlZERhdGFbYWN0aW9uTmFtZV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX2NyZWF0ZVF1YWRyaWxhdGVyYWxzKCkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgaWdub3JlQm9yZGVyID0gYXJndW1lbnRzLmxlbmd0aCA+IDAgJiYgYXJndW1lbnRzWzBdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMF0gOiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLmRhdGEucXVhZFBvaW50cykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcXVhZHJpbGF0ZXJhbHMgPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2F2ZWRSZWN0ID0gdGhpcy5kYXRhLnJlY3Q7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgcXVhZFBvaW50IG9mIHRoaXMuZGF0YS5xdWFkUG9pbnRzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRhdGEucmVjdCA9IFtxdWFkUG9pbnRbMl0ueCwgcXVhZFBvaW50WzJdLnksIHF1YWRQb2ludFsxXS54LCBxdWFkUG9pbnRbMV0ueV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBxdWFkcmlsYXRlcmFscy5wdXNoKHRoaXMuX2NyZWF0ZUNvbnRhaW5lcihpZ25vcmVCb3JkZXIpKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRhdGEucmVjdCA9IHNhdmVkUmVjdDsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHF1YWRyaWxhdGVyYWxzOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfY3JlYXRlUG9wdXAodHJpZ2dlciwgZGF0YSkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgY29udGFpbmVyID0gdGhpcy5jb250YWluZXI7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLnF1YWRyaWxhdGVyYWxzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cmlnZ2VyID0gdHJpZ2dlciB8fCB0aGlzLnF1YWRyaWxhdGVyYWxzOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGFpbmVyID0gdGhpcy5xdWFkcmlsYXRlcmFsc1swXTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRyaWdnZXIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRyaWdnZXIgPSBkb2N1bWVudC5jcmVhdGVFbGVtZW50KCJkaXYiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRyaWdnZXIuY2xhc3NMaXN0LmFkZCgicG9wdXBUcmlnZ2VyQXJlYSIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGFpbmVyLmFwcGVuZCh0cmlnZ2VyKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwb3B1cEVsZW1lbnQgPSBuZXcgUG9wdXBFbGVtZW50KHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRhaW5lciwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRyaWdnZXIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb2xvcjogZGF0YS5jb2xvciwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRpdGxlT2JqOiBkYXRhLnRpdGxlT2JqLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgbW9kaWZpY2F0aW9uRGF0ZTogZGF0YS5tb2RpZmljYXRpb25EYXRlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGVudHNPYmo6IGRhdGEuY29udGVudHNPYmosCiAgICAgICAgICAgICAgICAgICAgICAgICAgICByaWNoVGV4dDogZGF0YS5yaWNoVGV4dCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGhpZGVXcmFwcGVyOiB0cnVlCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwb3B1cCA9IHBvcHVwRWxlbWVudC5yZW5kZXIoKTsKICAgICAgICAgICAgICAgICAgICAgICAgcG9wdXAuc3R5bGUubGVmdCA9ICIxMDAlIjsKICAgICAgICAgICAgICAgICAgICAgICAgY29udGFpbmVyLmFwcGVuZChwb3B1cCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9yZW5kZXJRdWFkcmlsYXRlcmFscyhjbGFzc05hbWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBxdWFkcmlsYXRlcmFsIG9mIHRoaXMucXVhZHJpbGF0ZXJhbHMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHF1YWRyaWxhdGVyYWwuY2xhc3NMaXN0LmFkZChjbGFzc05hbWUpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLnF1YWRyaWxhdGVyYWxzOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZW5kZXIoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC51bnJlYWNoYWJsZSkoIkFic3RyYWN0IG1ldGhvZCBgQW5ub3RhdGlvbkVsZW1lbnQucmVuZGVyYCBjYWxsZWQiKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX2dldEVsZW1lbnRzQnlOYW1lKG5hbWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHNraXBJZCA9IGFyZ3VtZW50cy5sZW5ndGggPiAxICYmIGFyZ3VtZW50c1sxXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzFdIDogbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZmllbGRzID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl9maWVsZE9iamVjdHMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZpZWxkT2JqID0gdGhpcy5fZmllbGRPYmplY3RzW25hbWVdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGZpZWxkT2JqKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2UsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBleHBvcnRWYWx1ZXMKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IG9mIGZpZWxkT2JqKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChwYWdlID09PSAtMSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGlkID09PSBza2lwSWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGV4cG9ydFZhbHVlID0gdHlwZW9mIGV4cG9ydFZhbHVlcyA9PT0gInN0cmluZyIgPyBleHBvcnRWYWx1ZXMgOiBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBkb21FbGVtZW50ID0gZG9jdW1lbnQucXVlcnlTZWxlY3RvcihgW2RhdGEtZWxlbWVudC1pZD0iJHtpZH0iXWApOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZG9tRWxlbWVudCAmJiAhR2V0RWxlbWVudHNCeU5hbWVTZXQuaGFzKGRvbUVsZW1lbnQpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYF9nZXRFbGVtZW50c0J5TmFtZSAtIGVsZW1lbnQgbm90IGFsbG93ZWQ6ICR7aWR9YCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmaWVsZHMucHVzaCh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGV4cG9ydFZhbHVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZG9tRWxlbWVudAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmllbGRzOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgZG9tRWxlbWVudCBvZiBkb2N1bWVudC5nZXRFbGVtZW50c0J5TmFtZShuYW1lKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGV4cG9ydFZhbHVlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9ID0gZG9tRWxlbWVudDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGlkID0gZG9tRWxlbWVudC5nZXRBdHRyaWJ1dGUoImRhdGEtZWxlbWVudC1pZCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGlkID09PSBza2lwSWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghR2V0RWxlbWVudHNCeU5hbWVTZXQuaGFzKGRvbUVsZW1lbnQpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmaWVsZHMucHVzaCh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZXhwb3J0VmFsdWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZG9tRWxlbWVudAogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZpZWxkczsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB2YXIgX3NldEludGVybmFsTGluayA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgdmFyIF9iaW5kU2V0T0NHU3RhdGUgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIGNsYXNzIExpbmtBbm5vdGF0aW9uRWxlbWVudCBleHRlbmRzIEFubm90YXRpb25FbGVtZW50IHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcihwYXJhbWV0ZXJzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBvcHRpb25zID0gYXJndW1lbnRzLmxlbmd0aCA+IDEgJiYgYXJndW1lbnRzWzFdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMV0gOiBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICBzdXBlcihwYXJhbWV0ZXJzLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc1JlbmRlcmFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZ25vcmVCb3JkZXI6ICEhKG9wdGlvbnMgIT09IG51bGwgJiYgb3B0aW9ucyAhPT0gdm9pZCAwICYmIG9wdGlvbnMuaWdub3JlQm9yZGVyKSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNyZWF0ZVF1YWRyaWxhdGVyYWxzOiB0cnVlCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX2JpbmRTZXRPQ0dTdGF0ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfc2V0SW50ZXJuYWxMaW5rKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5pc1Rvb2x0aXBPbmx5ID0gcGFyYW1ldGVycy5kYXRhLmlzVG9vbHRpcE9ubHk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlbmRlcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGF0YSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxpbmtTZXJ2aWNlCiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSB0aGlzOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBsaW5rID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgiYSIpOwogICAgICAgICAgICAgICAgICAgICAgICBsaW5rLnNldEF0dHJpYnV0ZSgiZGF0YS1lbGVtZW50LWlkIiwgZGF0YS5pZCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBpc0JvdW5kID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChkYXRhLnVybCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGlua1NlcnZpY2UuYWRkTGlua0F0dHJpYnV0ZXMobGluaywgZGF0YS51cmwsIGRhdGEubmV3V2luZG93KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlzQm91bmQgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGRhdGEuYWN0aW9uKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9iaW5kTmFtZWRBY3Rpb24obGluaywgZGF0YS5hY3Rpb24pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNCb3VuZCA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoZGF0YS5hdHRhY2htZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9iaW5kQXR0YWNobWVudChsaW5rLCBkYXRhLmF0dGFjaG1lbnQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNCb3VuZCA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoZGF0YS5zZXRPQ0dTdGF0ZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfYmluZFNldE9DR1N0YXRlLCBfYmluZFNldE9DR1N0YXRlMikuY2FsbCh0aGlzLCBsaW5rLCBkYXRhLnNldE9DR1N0YXRlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlzQm91bmQgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGRhdGEuZGVzdCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fYmluZExpbmsobGluaywgZGF0YS5kZXN0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlzQm91bmQgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGRhdGEuYWN0aW9ucyAmJiAoZGF0YS5hY3Rpb25zLkFjdGlvbiB8fCBkYXRhLmFjdGlvbnNbIk1vdXNlIFVwIl0gfHwgZGF0YS5hY3Rpb25zWyJNb3VzZSBEb3duIl0pICYmIHRoaXMuZW5hYmxlU2NyaXB0aW5nICYmIHRoaXMuaGFzSlNBY3Rpb25zKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fYmluZEpTQWN0aW9uKGxpbmssIGRhdGEpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlzQm91bmQgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGRhdGEucmVzZXRGb3JtKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fYmluZFJlc2V0Rm9ybUFjdGlvbihsaW5rLCBkYXRhLnJlc2V0Rm9ybSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNCb3VuZCA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHRoaXMuaXNUb29sdGlwT25seSAmJiAhaXNCb3VuZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2JpbmRMaW5rKGxpbmssICIiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc0JvdW5kID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5xdWFkcmlsYXRlcmFscykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX3JlbmRlclF1YWRyaWxhdGVyYWxzKCJsaW5rQW5ub3RhdGlvbiIpLm1hcCgocXVhZHJpbGF0ZXJhbCwgaW5kZXgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBsaW5rRWxlbWVudCA9IGluZGV4ID09PSAwID8gbGluayA6IGxpbmsuY2xvbmVOb2RlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcXVhZHJpbGF0ZXJhbC5hcHBlbmQobGlua0VsZW1lbnQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBxdWFkcmlsYXRlcmFsOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb250YWluZXIuY2xhc3NMaXN0LmFkZCgibGlua0Fubm90YXRpb24iKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGlzQm91bmQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGFpbmVyLmFwcGVuZChsaW5rKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5jb250YWluZXI7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9iaW5kTGluayhsaW5rLCBkZXN0aW5hdGlvbikgewogICAgICAgICAgICAgICAgICAgICAgICBsaW5rLmhyZWYgPSB0aGlzLmxpbmtTZXJ2aWNlLmdldERlc3RpbmF0aW9uSGFzaChkZXN0aW5hdGlvbik7CiAgICAgICAgICAgICAgICAgICAgICAgIGxpbmsub25jbGljayA9ICgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChkZXN0aW5hdGlvbikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubGlua1NlcnZpY2UuZ29Ub0Rlc3RpbmF0aW9uKGRlc3RpbmF0aW9uKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGRlc3RpbmF0aW9uIHx8IGRlc3RpbmF0aW9uID09PSAiIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfc2V0SW50ZXJuYWxMaW5rLCBfc2V0SW50ZXJuYWxMaW5rMikuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfYmluZE5hbWVkQWN0aW9uKGxpbmssIGFjdGlvbikgewogICAgICAgICAgICAgICAgICAgICAgICBsaW5rLmhyZWYgPSB0aGlzLmxpbmtTZXJ2aWNlLmdldEFuY2hvclVybCgiIik7CiAgICAgICAgICAgICAgICAgICAgICAgIGxpbmsub25jbGljayA9ICgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubGlua1NlcnZpY2UuZXhlY3V0ZU5hbWVkQWN0aW9uKGFjdGlvbik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3NldEludGVybmFsTGluaywgX3NldEludGVybmFsTGluazIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9iaW5kQXR0YWNobWVudChsaW5rLCBhdHRhY2htZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxpbmsuaHJlZiA9IHRoaXMubGlua1NlcnZpY2UuZ2V0QW5jaG9yVXJsKCIiKTsKICAgICAgICAgICAgICAgICAgICAgICAgbGluay5vbmNsaWNrID0gKCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF90aGlzJGRvd25sb2FkTWFuYWdlcjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIChfdGhpcyRkb3dubG9hZE1hbmFnZXIgPSB0aGlzLmRvd25sb2FkTWFuYWdlcikgPT09IG51bGwgfHwgX3RoaXMkZG93bmxvYWRNYW5hZ2VyID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRkb3dubG9hZE1hbmFnZXIub3Blbk9yRG93bmxvYWREYXRhKHRoaXMuY29udGFpbmVyLCBhdHRhY2htZW50LmNvbnRlbnQsIGF0dGFjaG1lbnQuZmlsZW5hbWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9zZXRJbnRlcm5hbExpbmssIF9zZXRJbnRlcm5hbExpbmsyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfYmluZEpTQWN0aW9uKGxpbmssIGRhdGEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGluay5ocmVmID0gdGhpcy5saW5rU2VydmljZS5nZXRBbmNob3JVcmwoIiIpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBtYXAgPSBuZXcgTWFwKFtbIkFjdGlvbiIsICJvbmNsaWNrIl0sIFsiTW91c2UgVXAiLCAib25tb3VzZXVwIl0sIFsiTW91c2UgRG93biIsICJvbm1vdXNlZG93biJdXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgbmFtZSBvZiBPYmplY3Qua2V5cyhkYXRhLmFjdGlvbnMpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBqc05hbWUgPSBtYXAuZ2V0KG5hbWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFqc05hbWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxpbmtbanNOYW1lXSA9ICgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkbGlua1NlcnZpY2UkZXZlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIChfdGhpcyRsaW5rU2VydmljZSRldmUgPSB0aGlzLmxpbmtTZXJ2aWNlLmV2ZW50QnVzKSA9PT0gbnVsbCB8fCBfdGhpcyRsaW5rU2VydmljZSRldmUgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF90aGlzJGxpbmtTZXJ2aWNlJGV2ZS5kaXNwYXRjaCgiZGlzcGF0Y2hldmVudGluc2FuZGJveCIsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc291cmNlOiB0aGlzLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXRhaWw6IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlkOiBkYXRhLmlkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbmFtZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWxpbmsub25jbGljaykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGluay5vbmNsaWNrID0gKCkgPT4gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfc2V0SW50ZXJuYWxMaW5rLCBfc2V0SW50ZXJuYWxMaW5rMikuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX2JpbmRSZXNldEZvcm1BY3Rpb24obGluaywgcmVzZXRGb3JtKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG90aGVyQ2xpY2tBY3Rpb24gPSBsaW5rLm9uY2xpY2s7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghb3RoZXJDbGlja0FjdGlvbikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGluay5ocmVmID0gdGhpcy5saW5rU2VydmljZS5nZXRBbmNob3JVcmwoIiIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3NldEludGVybmFsTGluaywgX3NldEludGVybmFsTGluazIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5fZmllbGRPYmplY3RzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYF9iaW5kUmVzZXRGb3JtQWN0aW9uIC0gInJlc2V0Rm9ybSIgYWN0aW9uIG5vdCBzdXBwb3J0ZWQsIGAgKyAiZW5zdXJlIHRoYXQgdGhlIGBmaWVsZE9iamVjdHNgIHBhcmFtZXRlciBpcyBwcm92aWRlZC4iKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghb3RoZXJDbGlja0FjdGlvbikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxpbmsub25jbGljayA9ICgpID0+IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGxpbmsub25jbGljayA9ICgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG90aGVyQ2xpY2tBY3Rpb24gPT09IG51bGwgfHwgb3RoZXJDbGlja0FjdGlvbiA9PT0gdm9pZCAwID8gdm9pZCAwIDogb3RoZXJDbGlja0FjdGlvbigpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZpZWxkczogcmVzZXRGb3JtRmllbGRzLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlZnM6IHJlc2V0Rm9ybVJlZnMsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW5jbHVkZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSA9IHJlc2V0Rm9ybTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGFsbEZpZWxkcyA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHJlc2V0Rm9ybUZpZWxkcy5sZW5ndGggIT09IDAgfHwgcmVzZXRGb3JtUmVmcy5sZW5ndGggIT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBmaWVsZElkcyA9IG5ldyBTZXQocmVzZXRGb3JtUmVmcyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBmaWVsZE5hbWUgb2YgcmVzZXRGb3JtRmllbGRzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZpZWxkcyA9IHRoaXMuX2ZpZWxkT2JqZWN0c1tmaWVsZE5hbWVdIHx8IFtdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlkCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gb2YgZmllbGRzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmaWVsZElkcy5hZGQoaWQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgZmllbGRzIG9mIE9iamVjdC52YWx1ZXModGhpcy5fZmllbGRPYmplY3RzKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGZpZWxkIG9mIGZpZWxkcykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGZpZWxkSWRzLmhhcyhmaWVsZC5pZCkgPT09IGluY2x1ZGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhbGxGaWVsZHMucHVzaChmaWVsZCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgZmllbGRzIG9mIE9iamVjdC52YWx1ZXModGhpcy5fZmllbGRPYmplY3RzKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhbGxGaWVsZHMucHVzaCguLi5maWVsZHMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0b3JhZ2UgPSB0aGlzLmFubm90YXRpb25TdG9yYWdlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYWxsSWRzID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGZpZWxkIG9mIGFsbEZpZWxkcykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWQKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9ID0gZmllbGQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYWxsSWRzLnB1c2goaWQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN3aXRjaCAoZmllbGQudHlwZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJ0ZXh0IjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdmFsdWUgPSBmaWVsZC5kZWZhdWx0VmFsdWUgfHwgIiI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdG9yYWdlLnNldFZhbHVlKGlkLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWUKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiY2hlY2tib3giOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJyYWRpb2J1dHRvbiI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHZhbHVlID0gZmllbGQuZGVmYXVsdFZhbHVlID09PSBmaWVsZC5leHBvcnRWYWx1ZXM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdG9yYWdlLnNldFZhbHVlKGlkLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWUKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiY29tYm9ib3giOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJsaXN0Ym94IjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdmFsdWUgPSBmaWVsZC5kZWZhdWx0VmFsdWUgfHwgIiI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdG9yYWdlLnNldFZhbHVlKGlkLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWUKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBkb21FbGVtZW50ID0gZG9jdW1lbnQucXVlcnlTZWxlY3RvcihgW2RhdGEtZWxlbWVudC1pZD0iJHtpZH0iXWApOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghZG9tRWxlbWVudCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKCFHZXRFbGVtZW50c0J5TmFtZVNldC5oYXMoZG9tRWxlbWVudCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKGBfYmluZFJlc2V0Rm9ybUFjdGlvbiAtIGVsZW1lbnQgbm90IGFsbG93ZWQ6ICR7aWR9YCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkb21FbGVtZW50LmRpc3BhdGNoRXZlbnQobmV3IEV2ZW50KCJyZXNldGZvcm0iKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5lbmFibGVTY3JpcHRpbmcpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkbGlua1NlcnZpY2UkZXZlMjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoX3RoaXMkbGlua1NlcnZpY2UkZXZlMiA9IHRoaXMubGlua1NlcnZpY2UuZXZlbnRCdXMpID09PSBudWxsIHx8IF90aGlzJGxpbmtTZXJ2aWNlJGV2ZTIgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF90aGlzJGxpbmtTZXJ2aWNlJGV2ZTIuZGlzcGF0Y2goImRpc3BhdGNoZXZlbnRpbnNhbmRib3giLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNvdXJjZTogdGhpcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGV0YWlsOiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZDogImFwcCIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZHM6IGFsbElkcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5hbWU6ICJSZXNldEZvcm0iCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfc2V0SW50ZXJuYWxMaW5rMigpIHsKICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRhaW5lci5zZXRBdHRyaWJ1dGUoImRhdGEtaW50ZXJuYWwtbGluayIsICIiKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9iaW5kU2V0T0NHU3RhdGUyKGxpbmssIGFjdGlvbikgewogICAgICAgICAgICAgICAgICAgIGxpbmsuaHJlZiA9IHRoaXMubGlua1NlcnZpY2UuZ2V0QW5jaG9yVXJsKCIiKTsKICAgICAgICAgICAgICAgICAgICBsaW5rLm9uY2xpY2sgPSAoKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubGlua1NlcnZpY2UuZXhlY3V0ZVNldE9DR1N0YXRlKGFjdGlvbik7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3NldEludGVybmFsTGluaywgX3NldEludGVybmFsTGluazIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBUZXh0QW5ub3RhdGlvbkVsZW1lbnQgZXh0ZW5kcyBBbm5vdGF0aW9uRWxlbWVudCB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IocGFyYW1ldGVycykgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3BhcmFtZXRlcnMkZGF0YSR0aXRsLCBfcGFyYW1ldGVycyRkYXRhJGNvbnQsIF9wYXJhbWV0ZXJzJGRhdGEkcmljaDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaXNSZW5kZXJhYmxlID0gISEocGFyYW1ldGVycy5kYXRhLmhhc1BvcHVwIHx8IChfcGFyYW1ldGVycyRkYXRhJHRpdGwgPSBwYXJhbWV0ZXJzLmRhdGEudGl0bGVPYmopICE9PSBudWxsICYmIF9wYXJhbWV0ZXJzJGRhdGEkdGl0bCAhPT0gdm9pZCAwICYmIF9wYXJhbWV0ZXJzJGRhdGEkdGl0bC5zdHIgfHwgKF9wYXJhbWV0ZXJzJGRhdGEkY29udCA9IHBhcmFtZXRlcnMuZGF0YS5jb250ZW50c09iaikgIT09IG51bGwgJiYgX3BhcmFtZXRlcnMkZGF0YSRjb250ICE9PSB2b2lkIDAgJiYgX3BhcmFtZXRlcnMkZGF0YSRjb250LnN0ciB8fCAoX3BhcmFtZXRlcnMkZGF0YSRyaWNoID0gcGFyYW1ldGVycy5kYXRhLnJpY2hUZXh0KSAhPT0gbnVsbCAmJiBfcGFyYW1ldGVycyRkYXRhJHJpY2ggIT09IHZvaWQgMCAmJiBfcGFyYW1ldGVycyRkYXRhJHJpY2guc3RyKTsKICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIocGFyYW1ldGVycywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNSZW5kZXJhYmxlCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZW5kZXIoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGFpbmVyLmNsYXNzTGlzdC5hZGQoInRleHRBbm5vdGF0aW9uIik7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGltYWdlID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgiaW1nIik7CiAgICAgICAgICAgICAgICAgICAgICAgIGltYWdlLnNyYyA9IHRoaXMuaW1hZ2VSZXNvdXJjZXNQYXRoICsgImFubm90YXRpb24tIiArIHRoaXMuZGF0YS5uYW1lLnRvTG93ZXJDYXNlKCkgKyAiLnN2ZyI7CiAgICAgICAgICAgICAgICAgICAgICAgIGltYWdlLmFsdCA9ICJbe3t0eXBlfX0gQW5ub3RhdGlvbl0iOwogICAgICAgICAgICAgICAgICAgICAgICBpbWFnZS5kYXRhc2V0LmwxMG5JZCA9ICJ0ZXh0X2Fubm90YXRpb25fdHlwZSI7CiAgICAgICAgICAgICAgICAgICAgICAgIGltYWdlLmRhdGFzZXQubDEwbkFyZ3MgPSBKU09OLnN0cmluZ2lmeSh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0eXBlOiB0aGlzLmRhdGEubmFtZQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLmRhdGEuaGFzUG9wdXApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NyZWF0ZVBvcHVwKGltYWdlLCB0aGlzLmRhdGEpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGFpbmVyLmFwcGVuZChpbWFnZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLmNvbnRhaW5lcjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBXaWRnZXRBbm5vdGF0aW9uRWxlbWVudCBleHRlbmRzIEFubm90YXRpb25FbGVtZW50IHsKICAgICAgICAgICAgICAgICAgICByZW5kZXIoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmRhdGEuYWx0ZXJuYXRpdmVUZXh0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRhaW5lci50aXRsZSA9IHRoaXMuZGF0YS5hbHRlcm5hdGl2ZVRleHQ7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuY29udGFpbmVyOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfZ2V0S2V5TW9kaWZpZXIoZXZlbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNXaW4sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc01hYwogICAgICAgICAgICAgICAgICAgICAgICB9ID0gX3V0aWwuRmVhdHVyZVRlc3QucGxhdGZvcm07CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBpc1dpbiAmJiBldmVudC5jdHJsS2V5IHx8IGlzTWFjICYmIGV2ZW50Lm1ldGFLZXk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9zZXRFdmVudExpc3RlbmVyKGVsZW1lbnQsIGJhc2VOYW1lLCBldmVudE5hbWUsIHZhbHVlR2V0dGVyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChiYXNlTmFtZS5pbmNsdWRlcygibW91c2UiKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5hZGRFdmVudExpc3RlbmVyKGJhc2VOYW1lLCBldmVudCA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF90aGlzJGxpbmtTZXJ2aWNlJGV2ZTM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKF90aGlzJGxpbmtTZXJ2aWNlJGV2ZTMgPSB0aGlzLmxpbmtTZXJ2aWNlLmV2ZW50QnVzKSA9PT0gbnVsbCB8fCBfdGhpcyRsaW5rU2VydmljZSRldmUzID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRsaW5rU2VydmljZSRldmUzLmRpc3BhdGNoKCJkaXNwYXRjaGV2ZW50aW5zYW5kYm94IiwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzb3VyY2U6IHRoaXMsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRldGFpbDogewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWQ6IHRoaXMuZGF0YS5pZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5hbWU6IGV2ZW50TmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiB2YWx1ZUdldHRlcihldmVudCksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzaGlmdDogZXZlbnQuc2hpZnRLZXksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtb2RpZmllcjogdGhpcy5fZ2V0S2V5TW9kaWZpZXIoZXZlbnQpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5hZGRFdmVudExpc3RlbmVyKGJhc2VOYW1lLCBldmVudCA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF90aGlzJGxpbmtTZXJ2aWNlJGV2ZTQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKF90aGlzJGxpbmtTZXJ2aWNlJGV2ZTQgPSB0aGlzLmxpbmtTZXJ2aWNlLmV2ZW50QnVzKSA9PT0gbnVsbCB8fCBfdGhpcyRsaW5rU2VydmljZSRldmU0ID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRsaW5rU2VydmljZSRldmU0LmRpc3BhdGNoKCJkaXNwYXRjaGV2ZW50aW5zYW5kYm94IiwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzb3VyY2U6IHRoaXMsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRldGFpbDogewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWQ6IHRoaXMuZGF0YS5pZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5hbWU6IGV2ZW50TmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiB2YWx1ZUdldHRlcihldmVudCkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX3NldEV2ZW50TGlzdGVuZXJzKGVsZW1lbnQsIG5hbWVzLCBnZXR0ZXIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBbYmFzZU5hbWUsIGV2ZW50TmFtZV0gb2YgbmFtZXMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRkYXRhJGFjdGlvbnM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZXZlbnROYW1lID09PSAiQWN0aW9uIiB8fCAoX3RoaXMkZGF0YSRhY3Rpb25zID0gdGhpcy5kYXRhLmFjdGlvbnMpICE9PSBudWxsICYmIF90aGlzJGRhdGEkYWN0aW9ucyAhPT0gdm9pZCAwICYmIF90aGlzJGRhdGEkYWN0aW9uc1tldmVudE5hbWVdKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc2V0RXZlbnRMaXN0ZW5lcihlbGVtZW50LCBiYXNlTmFtZSwgZXZlbnROYW1lLCBnZXR0ZXIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9zZXRCYWNrZ3JvdW5kQ29sb3IoZWxlbWVudCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjb2xvciA9IHRoaXMuZGF0YS5iYWNrZ3JvdW5kQ29sb3IgfHwgbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5zdHlsZS5iYWNrZ3JvdW5kQ29sb3IgPSBjb2xvciA9PT0gbnVsbCA/ICJ0cmFuc3BhcmVudCIgOiBfdXRpbC5VdGlsLm1ha2VIZXhDb2xvcihjb2xvclswXSwgY29sb3JbMV0sIGNvbG9yWzJdKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX3NldFRleHRTdHlsZShlbGVtZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IFRFWFRfQUxJR05NRU5UID0gWyJsZWZ0IiwgImNlbnRlciIsICJyaWdodCJdOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb250Q29sb3IKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IHRoaXMuZGF0YS5kZWZhdWx0QXBwZWFyYW5jZURhdGE7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZvbnRTaXplID0gdGhpcy5kYXRhLmRlZmF1bHRBcHBlYXJhbmNlRGF0YS5mb250U2l6ZSB8fCBERUZBVUxUX0ZPTlRfU0laRTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3R5bGUgPSBlbGVtZW50LnN0eWxlOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgY29tcHV0ZWRGb250U2l6ZTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgQk9SREVSX1NJWkUgPSAyOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByb3VuZFRvT25lRGVjaW1hbCA9IHggPT4gTWF0aC5yb3VuZCgxMCAqIHgpIC8gMTA7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmRhdGEubXVsdGlMaW5lKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBoZWlnaHQgPSBNYXRoLmFicyh0aGlzLmRhdGEucmVjdFszXSAtIHRoaXMuZGF0YS5yZWN0WzFdIC0gQk9SREVSX1NJWkUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbnVtYmVyT2ZMaW5lcyA9IE1hdGgucm91bmQoaGVpZ2h0IC8gKF91dGlsLkxJTkVfRkFDVE9SICogZm9udFNpemUpKSB8fCAxOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbGluZUhlaWdodCA9IGhlaWdodCAvIG51bWJlck9mTGluZXM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb21wdXRlZEZvbnRTaXplID0gTWF0aC5taW4oZm9udFNpemUsIHJvdW5kVG9PbmVEZWNpbWFsKGxpbmVIZWlnaHQgLyBfdXRpbC5MSU5FX0ZBQ1RPUikpOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaGVpZ2h0ID0gTWF0aC5hYnModGhpcy5kYXRhLnJlY3RbM10gLSB0aGlzLmRhdGEucmVjdFsxXSAtIEJPUkRFUl9TSVpFKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbXB1dGVkRm9udFNpemUgPSBNYXRoLm1pbihmb250U2l6ZSwgcm91bmRUb09uZURlY2ltYWwoaGVpZ2h0IC8gX3V0aWwuTElORV9GQUNUT1IpKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBzdHlsZS5mb250U2l6ZSA9IGBjYWxjKCR7Y29tcHV0ZWRGb250U2l6ZX1weCAqIHZhcigtLXNjYWxlLWZhY3RvcikpYDsKICAgICAgICAgICAgICAgICAgICAgICAgc3R5bGUuY29sb3IgPSBfdXRpbC5VdGlsLm1ha2VIZXhDb2xvcihmb250Q29sb3JbMF0sIGZvbnRDb2xvclsxXSwgZm9udENvbG9yWzJdKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuZGF0YS50ZXh0QWxpZ25tZW50ICE9PSBudWxsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHlsZS50ZXh0QWxpZ24gPSBURVhUX0FMSUdOTUVOVFt0aGlzLmRhdGEudGV4dEFsaWdubWVudF07CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX3NldFJlcXVpcmVkKGVsZW1lbnQsIGlzUmVxdWlyZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGlzUmVxdWlyZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1lbnQuc2V0QXR0cmlidXRlKCJyZXF1aXJlZCIsIHRydWUpOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5yZW1vdmVBdHRyaWJ1dGUoInJlcXVpcmVkIik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5zZXRBdHRyaWJ1dGUoImFyaWEtcmVxdWlyZWQiLCBpc1JlcXVpcmVkKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBUZXh0V2lkZ2V0QW5ub3RhdGlvbkVsZW1lbnQgZXh0ZW5kcyBXaWRnZXRBbm5vdGF0aW9uRWxlbWVudCB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IocGFyYW1ldGVycykgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpc1JlbmRlcmFibGUgPSBwYXJhbWV0ZXJzLnJlbmRlckZvcm1zIHx8ICFwYXJhbWV0ZXJzLmRhdGEuaGFzQXBwZWFyYW5jZSAmJiAhIXBhcmFtZXRlcnMuZGF0YS5maWVsZFZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICBzdXBlcihwYXJhbWV0ZXJzLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc1JlbmRlcmFibGUKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNldFByb3BlcnR5T25TaWJsaW5ncyhiYXNlLCBrZXksIHZhbHVlLCBrZXlJblN0b3JhZ2UpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3RvcmFnZSA9IHRoaXMuYW5ub3RhdGlvblN0b3JhZ2U7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgZWxlbWVudCBvZiB0aGlzLl9nZXRFbGVtZW50c0J5TmFtZShiYXNlLm5hbWUsIGJhc2UuaWQpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZWxlbWVudC5kb21FbGVtZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5kb21FbGVtZW50W2tleV0gPSB2YWx1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0b3JhZ2Uuc2V0VmFsdWUoZWxlbWVudC5pZCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFtrZXlJblN0b3JhZ2VdOiB2YWx1ZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmVuZGVyKCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzdG9yYWdlID0gdGhpcy5hbm5vdGF0aW9uU3RvcmFnZTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaWQgPSB0aGlzLmRhdGEuaWQ7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGFpbmVyLmNsYXNzTGlzdC5hZGQoInRleHRXaWRnZXRBbm5vdGF0aW9uIik7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBlbGVtZW50ID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMucmVuZGVyRm9ybXMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0b3JlZERhdGEgPSBzdG9yYWdlLmdldFZhbHVlKGlkLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRoaXMuZGF0YS5maWVsZFZhbHVlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCB0ZXh0Q29udGVudCA9IHN0b3JlZERhdGEuZm9ybWF0dGVkVmFsdWUgfHwgc3RvcmVkRGF0YS52YWx1ZSB8fCAiIjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG1heExlbiA9IHN0b3JhZ2UuZ2V0VmFsdWUoaWQsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjaGFyTGltaXQ6IHRoaXMuZGF0YS5tYXhMZW4KICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pLmNoYXJMaW1pdDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChtYXhMZW4gJiYgdGV4dENvbnRlbnQubGVuZ3RoID4gbWF4TGVuKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGV4dENvbnRlbnQgPSB0ZXh0Q29udGVudC5zbGljZSgwLCBtYXhMZW4pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZWxlbWVudERhdGEgPSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdXNlclZhbHVlOiB0ZXh0Q29udGVudCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3JtYXR0ZWRWYWx1ZTogbnVsbCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsYXN0Q29tbWl0dGVkVmFsdWU6IG51bGwsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29tbWl0S2V5OiAxCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuZGF0YS5tdWx0aUxpbmUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50ID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgidGV4dGFyZWEiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50LnRleHRDb250ZW50ID0gdGV4dENvbnRlbnQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuZGF0YS5kb05vdFNjcm9sbCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50LnN0eWxlLm92ZXJmbG93WSA9ICJoaWRkZW4iOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudCA9IGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoImlucHV0Iik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC50eXBlID0gInRleHQiOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1lbnQuc2V0QXR0cmlidXRlKCJ2YWx1ZSIsIHRleHRDb250ZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5kYXRhLmRvTm90U2Nyb2xsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1lbnQuc3R5bGUub3ZlcmZsb3dYID0gImhpZGRlbiI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgR2V0RWxlbWVudHNCeU5hbWVTZXQuYWRkKGVsZW1lbnQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5zZXRBdHRyaWJ1dGUoImRhdGEtZWxlbWVudC1pZCIsIGlkKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1lbnQuZGlzYWJsZWQgPSB0aGlzLmRhdGEucmVhZE9ubHk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50Lm5hbWUgPSB0aGlzLmRhdGEuZmllbGROYW1lOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC50YWJJbmRleCA9IERFRkFVTFRfVEFCX0lOREVYOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc2V0UmVxdWlyZWQoZWxlbWVudCwgdGhpcy5kYXRhLnJlcXVpcmVkKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChtYXhMZW4pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50Lm1heExlbmd0aCA9IG1heExlbjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1lbnQuYWRkRXZlbnRMaXN0ZW5lcigiaW5wdXQiLCBldmVudCA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RvcmFnZS5zZXRWYWx1ZShpZCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogZXZlbnQudGFyZ2V0LnZhbHVlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRQcm9wZXJ0eU9uU2libGluZ3MoZWxlbWVudCwgInZhbHVlIiwgZXZlbnQudGFyZ2V0LnZhbHVlLCAidmFsdWUiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5hZGRFdmVudExpc3RlbmVyKCJyZXNldGZvcm0iLCBldmVudCA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZGVmYXVsdFZhbHVlID0gdGhpcy5kYXRhLmRlZmF1bHRGaWVsZFZhbHVlID8/ICIiOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1lbnQudmFsdWUgPSBlbGVtZW50RGF0YS51c2VyVmFsdWUgPSBkZWZhdWx0VmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudERhdGEuZm9ybWF0dGVkVmFsdWUgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgYmx1ckxpc3RlbmVyID0gZXZlbnQgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9ybWF0dGVkVmFsdWUKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9ID0gZWxlbWVudERhdGE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGZvcm1hdHRlZFZhbHVlICE9PSBudWxsICYmIGZvcm1hdHRlZFZhbHVlICE9PSB1bmRlZmluZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZXZlbnQudGFyZ2V0LnZhbHVlID0gZm9ybWF0dGVkVmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGV2ZW50LnRhcmdldC5zY3JvbGxMZWZ0ID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5lbmFibGVTY3JpcHRpbmcgJiYgdGhpcy5oYXNKU0FjdGlvbnMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkZGF0YSRhY3Rpb25zMjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50LmFkZEV2ZW50TGlzdGVuZXIoImZvY3VzIiwgZXZlbnQgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0YXJnZXQKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSA9IGV2ZW50OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZWxlbWVudERhdGEudXNlclZhbHVlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0YXJnZXQudmFsdWUgPSBlbGVtZW50RGF0YS51c2VyVmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudERhdGEubGFzdENvbW1pdHRlZFZhbHVlID0gdGFyZ2V0LnZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50RGF0YS5jb21taXRLZXkgPSAxOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1lbnQuYWRkRXZlbnRMaXN0ZW5lcigidXBkYXRlZnJvbXNhbmRib3giLCBqc0V2ZW50ID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYWN0aW9ucyA9IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlKGV2ZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudERhdGEudXNlclZhbHVlID0gZXZlbnQuZGV0YWlsLnZhbHVlID8/ICIiOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0b3JhZ2Uuc2V0VmFsdWUoaWQsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IGVsZW1lbnREYXRhLnVzZXJWYWx1ZS50b1N0cmluZygpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZXZlbnQudGFyZ2V0LnZhbHVlID0gZWxlbWVudERhdGEudXNlclZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvcm1hdHRlZFZhbHVlKGV2ZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3JtYXR0ZWRWYWx1ZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBldmVudC5kZXRhaWw7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudERhdGEuZm9ybWF0dGVkVmFsdWUgPSBmb3JtYXR0ZWRWYWx1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZm9ybWF0dGVkVmFsdWUgIT09IG51bGwgJiYgZm9ybWF0dGVkVmFsdWUgIT09IHVuZGVmaW5lZCAmJiBldmVudC50YXJnZXQgIT09IGRvY3VtZW50LmFjdGl2ZUVsZW1lbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZXZlbnQudGFyZ2V0LnZhbHVlID0gZm9ybWF0dGVkVmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0b3JhZ2Uuc2V0VmFsdWUoaWQsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9ybWF0dGVkVmFsdWUKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZWxSYW5nZShldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGV2ZW50LnRhcmdldC5zZXRTZWxlY3Rpb25SYW5nZSguLi5ldmVudC5kZXRhaWwuc2VsUmFuZ2UpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNoYXJMaW1pdDogZXZlbnQgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRsaW5rU2VydmljZSRldmU1OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2hhckxpbWl0CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSA9IGV2ZW50LmRldGFpbDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRhcmdldAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBldmVudDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoY2hhckxpbWl0ID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRhcmdldC5yZW1vdmVBdHRyaWJ1dGUoIm1heExlbmd0aCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRhcmdldC5zZXRBdHRyaWJ1dGUoIm1heExlbmd0aCIsIGNoYXJMaW1pdCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHZhbHVlID0gZWxlbWVudERhdGEudXNlclZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdmFsdWUgfHwgdmFsdWUubGVuZ3RoIDw9IGNoYXJMaW1pdCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlID0gdmFsdWUuc2xpY2UoMCwgY2hhckxpbWl0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0YXJnZXQudmFsdWUgPSBlbGVtZW50RGF0YS51c2VyVmFsdWUgPSB2YWx1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdG9yYWdlLnNldFZhbHVlKGlkLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKF90aGlzJGxpbmtTZXJ2aWNlJGV2ZTUgPSB0aGlzLmxpbmtTZXJ2aWNlLmV2ZW50QnVzKSA9PT0gbnVsbCB8fCBfdGhpcyRsaW5rU2VydmljZSRldmU1ID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRsaW5rU2VydmljZSRldmU1LmRpc3BhdGNoKCJkaXNwYXRjaGV2ZW50aW5zYW5kYm94IiwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzb3VyY2U6IHRoaXMsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRldGFpbDogewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBuYW1lOiAiS2V5c3Ryb2tlIiwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgd2lsbENvbW1pdDogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbW1pdEtleTogMSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbFN0YXJ0OiB0YXJnZXQuc2VsZWN0aW9uU3RhcnQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZWxFbmQ6IHRhcmdldC5zZWxlY3Rpb25FbmQKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9kaXNwYXRjaEV2ZW50RnJvbVNhbmRib3goYWN0aW9ucywganNFdmVudCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5hZGRFdmVudExpc3RlbmVyKCJrZXlkb3duIiwgZXZlbnQgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkbGlua1NlcnZpY2UkZXZlNjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudERhdGEuY29tbWl0S2V5ID0gMTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGNvbW1pdEtleSA9IC0xOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZXZlbnQua2V5ID09PSAiRXNjYXBlIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29tbWl0S2V5ID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChldmVudC5rZXkgPT09ICJFbnRlciIgJiYgIXRoaXMuZGF0YS5tdWx0aUxpbmUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbW1pdEtleSA9IDI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoZXZlbnQua2V5ID09PSAiVGFiIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudERhdGEuY29tbWl0S2V5ID0gMzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoY29tbWl0S2V5ID09PSAtMSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBldmVudC50YXJnZXQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChlbGVtZW50RGF0YS5sYXN0Q29tbWl0dGVkVmFsdWUgPT09IHZhbHVlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudERhdGEubGFzdENvbW1pdHRlZFZhbHVlID0gdmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1lbnREYXRhLnVzZXJWYWx1ZSA9IHZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoX3RoaXMkbGlua1NlcnZpY2UkZXZlNiA9IHRoaXMubGlua1NlcnZpY2UuZXZlbnRCdXMpID09PSBudWxsIHx8IF90aGlzJGxpbmtTZXJ2aWNlJGV2ZTYgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF90aGlzJGxpbmtTZXJ2aWNlJGV2ZTYuZGlzcGF0Y2goImRpc3BhdGNoZXZlbnRpbnNhbmRib3giLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzb3VyY2U6IHRoaXMsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXRhaWw6IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBuYW1lOiAiS2V5c3Ryb2tlIiwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB3aWxsQ29tbWl0OiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbW1pdEtleSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZWxTdGFydDogZXZlbnQudGFyZ2V0LnNlbGVjdGlvblN0YXJ0LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbEVuZDogZXZlbnQudGFyZ2V0LnNlbGVjdGlvbkVuZAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBfYmx1ckxpc3RlbmVyID0gYmx1ckxpc3RlbmVyOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJsdXJMaXN0ZW5lciA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5hZGRFdmVudExpc3RlbmVyKCJibHVyIiwgZXZlbnQgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWV2ZW50LnJlbGF0ZWRUYXJnZXQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9ID0gZXZlbnQudGFyZ2V0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50RGF0YS51c2VyVmFsdWUgPSB2YWx1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGVsZW1lbnREYXRhLmxhc3RDb21taXR0ZWRWYWx1ZSAhPT0gdmFsdWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRsaW5rU2VydmljZSRldmU3OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKF90aGlzJGxpbmtTZXJ2aWNlJGV2ZTcgPSB0aGlzLmxpbmtTZXJ2aWNlLmV2ZW50QnVzKSA9PT0gbnVsbCB8fCBfdGhpcyRsaW5rU2VydmljZSRldmU3ID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRsaW5rU2VydmljZSRldmU3LmRpc3BhdGNoKCJkaXNwYXRjaGV2ZW50aW5zYW5kYm94IiwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNvdXJjZTogdGhpcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXRhaWw6IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5hbWU6ICJLZXlzdHJva2UiLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgd2lsbENvbW1pdDogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29tbWl0S2V5OiBlbGVtZW50RGF0YS5jb21taXRLZXksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbFN0YXJ0OiBldmVudC50YXJnZXQuc2VsZWN0aW9uU3RhcnQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbEVuZDogZXZlbnQudGFyZ2V0LnNlbGVjdGlvbkVuZAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9ibHVyTGlzdGVuZXIoZXZlbnQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICgoX3RoaXMkZGF0YSRhY3Rpb25zMiA9IHRoaXMuZGF0YS5hY3Rpb25zKSAhPT0gbnVsbCAmJiBfdGhpcyRkYXRhJGFjdGlvbnMyICE9PSB2b2lkIDAgJiYgX3RoaXMkZGF0YSRhY3Rpb25zMi5LZXlzdHJva2UpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5hZGRFdmVudExpc3RlbmVyKCJiZWZvcmVpbnB1dCIsIGV2ZW50ID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRsaW5rU2VydmljZSRldmU4OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudERhdGEubGFzdENvbW1pdHRlZFZhbHVlID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkYXRhLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRhcmdldAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSA9IGV2ZW50OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbGVjdGlvblN0YXJ0LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbGVjdGlvbkVuZAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSA9IHRhcmdldDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBzZWxTdGFydCA9IHNlbGVjdGlvblN0YXJ0LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbEVuZCA9IHNlbGVjdGlvbkVuZDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN3aXRjaCAoZXZlbnQuaW5wdXRUeXBlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiZGVsZXRlV29yZEJhY2t3YXJkIjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG1hdGNoID0gdmFsdWUuc3Vic3RyaW5nKDAsIHNlbGVjdGlvblN0YXJ0KS5tYXRjaCgvXHcqW15cd10qJC8pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAobWF0Y2gpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbFN0YXJ0IC09IG1hdGNoWzBdLmxlbmd0aDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiZGVsZXRlV29yZEZvcndhcmQiOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbWF0Y2ggPSB2YWx1ZS5zdWJzdHJpbmcoc2VsZWN0aW9uU3RhcnQpLm1hdGNoKC9eW15cd10qXHcqLyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChtYXRjaCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VsRW5kICs9IG1hdGNoWzBdLmxlbmd0aDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiZGVsZXRlQ29udGVudEJhY2t3YXJkIjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHNlbGVjdGlvblN0YXJ0ID09PSBzZWxlY3Rpb25FbmQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbFN0YXJ0IC09IDE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiZGVsZXRlQ29udGVudEZvcndhcmQiOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoc2VsZWN0aW9uU3RhcnQgPT09IHNlbGVjdGlvbkVuZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VsRW5kICs9IDE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBldmVudC5wcmV2ZW50RGVmYXVsdCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKF90aGlzJGxpbmtTZXJ2aWNlJGV2ZTggPSB0aGlzLmxpbmtTZXJ2aWNlLmV2ZW50QnVzKSA9PT0gbnVsbCB8fCBfdGhpcyRsaW5rU2VydmljZSRldmU4ID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRsaW5rU2VydmljZSRldmU4LmRpc3BhdGNoKCJkaXNwYXRjaGV2ZW50aW5zYW5kYm94IiwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNvdXJjZTogdGhpcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXRhaWw6IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5hbWU6ICJLZXlzdHJva2UiLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2hhbmdlOiBkYXRhIHx8ICIiLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB3aWxsQ29tbWl0OiBmYWxzZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VsU3RhcnQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbEVuZAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc2V0RXZlbnRMaXN0ZW5lcnMoZWxlbWVudCwgW1siZm9jdXMiLCAiRm9jdXMiXSwgWyJibHVyIiwgIkJsdXIiXSwgWyJtb3VzZWRvd24iLCAiTW91c2UgRG93biJdLCBbIm1vdXNlZW50ZXIiLCAiTW91c2UgRW50ZXIiXSwgWyJtb3VzZWxlYXZlIiwgIk1vdXNlIEV4aXQiXSwgWyJtb3VzZXVwIiwgIk1vdXNlIFVwIl1dLCBldmVudCA9PiBldmVudC50YXJnZXQudmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGJsdXJMaXN0ZW5lcikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1lbnQuYWRkRXZlbnRMaXN0ZW5lcigiYmx1ciIsIGJsdXJMaXN0ZW5lcik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5kYXRhLmNvbWIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBmaWVsZFdpZHRoID0gdGhpcy5kYXRhLnJlY3RbMl0gLSB0aGlzLmRhdGEucmVjdFswXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjb21iV2lkdGggPSBmaWVsZFdpZHRoIC8gbWF4TGVuOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1lbnQuY2xhc3NMaXN0LmFkZCgiY29tYiIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1lbnQuc3R5bGUubGV0dGVyU3BhY2luZyA9IGBjYWxjKCR7Y29tYldpZHRofXB4ICogdmFyKC0tc2NhbGUtZmFjdG9yKSAtIDFjaClgOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudCA9IGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoImRpdiIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC50ZXh0Q29udGVudCA9IHRoaXMuZGF0YS5maWVsZFZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5zdHlsZS52ZXJ0aWNhbEFsaWduID0gIm1pZGRsZSI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50LnN0eWxlLmRpc3BsYXkgPSAidGFibGUtY2VsbCI7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc2V0VGV4dFN0eWxlKGVsZW1lbnQpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9zZXRCYWNrZ3JvdW5kQ29sb3IoZWxlbWVudCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3NldERlZmF1bHRQcm9wZXJ0aWVzRnJvbUpTKGVsZW1lbnQpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRhaW5lci5hcHBlbmQoZWxlbWVudCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLmNvbnRhaW5lcjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBDaGVja2JveFdpZGdldEFubm90YXRpb25FbGVtZW50IGV4dGVuZHMgV2lkZ2V0QW5ub3RhdGlvbkVsZW1lbnQgewogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKHBhcmFtZXRlcnMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIocGFyYW1ldGVycywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNSZW5kZXJhYmxlOiBwYXJhbWV0ZXJzLnJlbmRlckZvcm1zCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZW5kZXIoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0b3JhZ2UgPSB0aGlzLmFubm90YXRpb25TdG9yYWdlOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBkYXRhID0gdGhpcy5kYXRhOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpZCA9IGRhdGEuaWQ7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB2YWx1ZSA9IHN0b3JhZ2UuZ2V0VmFsdWUoaWQsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBkYXRhLmV4cG9ydFZhbHVlID09PSBkYXRhLmZpZWxkVmFsdWUKICAgICAgICAgICAgICAgICAgICAgICAgfSkudmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0eXBlb2YgdmFsdWUgPT09ICJzdHJpbmciKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZSA9IHZhbHVlICE9PSAiT2ZmIjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0b3JhZ2Uuc2V0VmFsdWUoaWQsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb250YWluZXIuY2xhc3NMaXN0LmFkZCgiYnV0dG9uV2lkZ2V0QW5ub3RhdGlvbiIsICJjaGVja0JveCIpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBlbGVtZW50ID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgiaW5wdXQiKTsKICAgICAgICAgICAgICAgICAgICAgICAgR2V0RWxlbWVudHNCeU5hbWVTZXQuYWRkKGVsZW1lbnQpOwogICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50LnNldEF0dHJpYnV0ZSgiZGF0YS1lbGVtZW50LWlkIiwgaWQpOwogICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50LmRpc2FibGVkID0gZGF0YS5yZWFkT25seTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc2V0UmVxdWlyZWQoZWxlbWVudCwgdGhpcy5kYXRhLnJlcXVpcmVkKTsKICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC50eXBlID0gImNoZWNrYm94IjsKICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5uYW1lID0gZGF0YS5maWVsZE5hbWU7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh2YWx1ZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5zZXRBdHRyaWJ1dGUoImNoZWNrZWQiLCB0cnVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50LnNldEF0dHJpYnV0ZSgiZXhwb3J0VmFsdWUiLCBkYXRhLmV4cG9ydFZhbHVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC50YWJJbmRleCA9IERFRkFVTFRfVEFCX0lOREVYOwogICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50LmFkZEV2ZW50TGlzdGVuZXIoImNoYW5nZSIsIGV2ZW50ID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBuYW1lLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNoZWNrZWQKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBldmVudC50YXJnZXQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGNoZWNrYm94IG9mIHRoaXMuX2dldEVsZW1lbnRzQnlOYW1lKG5hbWUsIGlkKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGN1ckNoZWNrZWQgPSBjaGVja2VkICYmIGNoZWNrYm94LmV4cG9ydFZhbHVlID09PSBkYXRhLmV4cG9ydFZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjaGVja2JveC5kb21FbGVtZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNoZWNrYm94LmRvbUVsZW1lbnQuY2hlY2tlZCA9IGN1ckNoZWNrZWQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0b3JhZ2Uuc2V0VmFsdWUoY2hlY2tib3guaWQsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IGN1ckNoZWNrZWQKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0b3JhZ2Uuc2V0VmFsdWUoaWQsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogY2hlY2tlZAogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50LmFkZEV2ZW50TGlzdGVuZXIoInJlc2V0Zm9ybSIsIGV2ZW50ID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGRlZmF1bHRWYWx1ZSA9IGRhdGEuZGVmYXVsdEZpZWxkVmFsdWUgfHwgIk9mZiI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBldmVudC50YXJnZXQuY2hlY2tlZCA9IGRlZmF1bHRWYWx1ZSA9PT0gZGF0YS5leHBvcnRWYWx1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmVuYWJsZVNjcmlwdGluZyAmJiB0aGlzLmhhc0pTQWN0aW9ucykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5hZGRFdmVudExpc3RlbmVyKCJ1cGRhdGVmcm9tc2FuZGJveCIsIGpzRXZlbnQgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGFjdGlvbnMgPSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlKGV2ZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBldmVudC50YXJnZXQuY2hlY2tlZCA9IGV2ZW50LmRldGFpbC52YWx1ZSAhPT0gIk9mZiI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdG9yYWdlLnNldFZhbHVlKGlkLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IGV2ZW50LnRhcmdldC5jaGVja2VkCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZGlzcGF0Y2hFdmVudEZyb21TYW5kYm94KGFjdGlvbnMsIGpzRXZlbnQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9zZXRFdmVudExpc3RlbmVycyhlbGVtZW50LCBbWyJjaGFuZ2UiLCAiVmFsaWRhdGUiXSwgWyJjaGFuZ2UiLCAiQWN0aW9uIl0sIFsiZm9jdXMiLCAiRm9jdXMiXSwgWyJibHVyIiwgIkJsdXIiXSwgWyJtb3VzZWRvd24iLCAiTW91c2UgRG93biJdLCBbIm1vdXNlZW50ZXIiLCAiTW91c2UgRW50ZXIiXSwgWyJtb3VzZWxlYXZlIiwgIk1vdXNlIEV4aXQiXSwgWyJtb3VzZXVwIiwgIk1vdXNlIFVwIl1dLCBldmVudCA9PiBldmVudC50YXJnZXQuY2hlY2tlZCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc2V0QmFja2dyb3VuZENvbG9yKGVsZW1lbnQpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9zZXREZWZhdWx0UHJvcGVydGllc0Zyb21KUyhlbGVtZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb250YWluZXIuYXBwZW5kKGVsZW1lbnQpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5jb250YWluZXI7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY2xhc3MgUmFkaW9CdXR0b25XaWRnZXRBbm5vdGF0aW9uRWxlbWVudCBleHRlbmRzIFdpZGdldEFubm90YXRpb25FbGVtZW50IHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcihwYXJhbWV0ZXJzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHN1cGVyKHBhcmFtZXRlcnMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlzUmVuZGVyYWJsZTogcGFyYW1ldGVycy5yZW5kZXJGb3JtcwogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmVuZGVyKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRhaW5lci5jbGFzc0xpc3QuYWRkKCJidXR0b25XaWRnZXRBbm5vdGF0aW9uIiwgInJhZGlvQnV0dG9uIik7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0b3JhZ2UgPSB0aGlzLmFubm90YXRpb25TdG9yYWdlOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBkYXRhID0gdGhpcy5kYXRhOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpZCA9IGRhdGEuaWQ7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB2YWx1ZSA9IHN0b3JhZ2UuZ2V0VmFsdWUoaWQsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBkYXRhLmZpZWxkVmFsdWUgPT09IGRhdGEuYnV0dG9uVmFsdWUKICAgICAgICAgICAgICAgICAgICAgICAgfSkudmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0eXBlb2YgdmFsdWUgPT09ICJzdHJpbmciKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZSA9IHZhbHVlICE9PSBkYXRhLmJ1dHRvblZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RvcmFnZS5zZXRWYWx1ZShpZCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBlbGVtZW50ID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgiaW5wdXQiKTsKICAgICAgICAgICAgICAgICAgICAgICAgR2V0RWxlbWVudHNCeU5hbWVTZXQuYWRkKGVsZW1lbnQpOwogICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50LnNldEF0dHJpYnV0ZSgiZGF0YS1lbGVtZW50LWlkIiwgaWQpOwogICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50LmRpc2FibGVkID0gZGF0YS5yZWFkT25seTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc2V0UmVxdWlyZWQoZWxlbWVudCwgdGhpcy5kYXRhLnJlcXVpcmVkKTsKICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC50eXBlID0gInJhZGlvIjsKICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5uYW1lID0gZGF0YS5maWVsZE5hbWU7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh2YWx1ZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5zZXRBdHRyaWJ1dGUoImNoZWNrZWQiLCB0cnVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50LnRhYkluZGV4ID0gREVGQVVMVF9UQUJfSU5ERVg7CiAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1lbnQuYWRkRXZlbnRMaXN0ZW5lcigiY2hhbmdlIiwgZXZlbnQgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5hbWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2hlY2tlZAogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSA9IGV2ZW50LnRhcmdldDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgcmFkaW8gb2YgdGhpcy5fZ2V0RWxlbWVudHNCeU5hbWUobmFtZSwgaWQpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RvcmFnZS5zZXRWYWx1ZShyYWRpby5pZCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogZmFsc2UKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0b3JhZ2Uuc2V0VmFsdWUoaWQsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogY2hlY2tlZAogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50LmFkZEV2ZW50TGlzdGVuZXIoInJlc2V0Zm9ybSIsIGV2ZW50ID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGRlZmF1bHRWYWx1ZSA9IGRhdGEuZGVmYXVsdEZpZWxkVmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBldmVudC50YXJnZXQuY2hlY2tlZCA9IGRlZmF1bHRWYWx1ZSAhPT0gbnVsbCAmJiBkZWZhdWx0VmFsdWUgIT09IHVuZGVmaW5lZCAmJiBkZWZhdWx0VmFsdWUgPT09IGRhdGEuYnV0dG9uVmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5lbmFibGVTY3JpcHRpbmcgJiYgdGhpcy5oYXNKU0FjdGlvbnMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHBkZkJ1dHRvblZhbHVlID0gZGF0YS5idXR0b25WYWx1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1lbnQuYWRkRXZlbnRMaXN0ZW5lcigidXBkYXRlZnJvbXNhbmRib3giLCBqc0V2ZW50ID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBhY3Rpb25zID0gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogZXZlbnQgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2hlY2tlZCA9IHBkZkJ1dHRvblZhbHVlID09PSBldmVudC5kZXRhaWwudmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IHJhZGlvIG9mIHRoaXMuX2dldEVsZW1lbnRzQnlOYW1lKGV2ZW50LnRhcmdldC5uYW1lKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGN1ckNoZWNrZWQgPSBjaGVja2VkICYmIHJhZGlvLmlkID09PSBpZDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAocmFkaW8uZG9tRWxlbWVudCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByYWRpby5kb21FbGVtZW50LmNoZWNrZWQgPSBjdXJDaGVja2VkOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdG9yYWdlLnNldFZhbHVlKHJhZGlvLmlkLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBjdXJDaGVja2VkCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Rpc3BhdGNoRXZlbnRGcm9tU2FuZGJveChhY3Rpb25zLCBqc0V2ZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc2V0RXZlbnRMaXN0ZW5lcnMoZWxlbWVudCwgW1siY2hhbmdlIiwgIlZhbGlkYXRlIl0sIFsiY2hhbmdlIiwgIkFjdGlvbiJdLCBbImZvY3VzIiwgIkZvY3VzIl0sIFsiYmx1ciIsICJCbHVyIl0sIFsibW91c2Vkb3duIiwgIk1vdXNlIERvd24iXSwgWyJtb3VzZWVudGVyIiwgIk1vdXNlIEVudGVyIl0sIFsibW91c2VsZWF2ZSIsICJNb3VzZSBFeGl0Il0sIFsibW91c2V1cCIsICJNb3VzZSBVcCJdXSwgZXZlbnQgPT4gZXZlbnQudGFyZ2V0LmNoZWNrZWQpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3NldEJhY2tncm91bmRDb2xvcihlbGVtZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc2V0RGVmYXVsdFByb3BlcnRpZXNGcm9tSlMoZWxlbWVudCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGFpbmVyLmFwcGVuZChlbGVtZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuY29udGFpbmVyOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNsYXNzIFB1c2hCdXR0b25XaWRnZXRBbm5vdGF0aW9uRWxlbWVudCBleHRlbmRzIExpbmtBbm5vdGF0aW9uRWxlbWVudCB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IocGFyYW1ldGVycykgewogICAgICAgICAgICAgICAgICAgICAgICBzdXBlcihwYXJhbWV0ZXJzLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZ25vcmVCb3JkZXI6IHBhcmFtZXRlcnMuZGF0YS5oYXNBcHBlYXJhbmNlCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZW5kZXIoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNvbnRhaW5lciA9IHN1cGVyLnJlbmRlcigpOwogICAgICAgICAgICAgICAgICAgICAgICBjb250YWluZXIuY2xhc3NMaXN0LmFkZCgiYnV0dG9uV2lkZ2V0QW5ub3RhdGlvbiIsICJwdXNoQnV0dG9uIik7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmRhdGEuYWx0ZXJuYXRpdmVUZXh0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250YWluZXIudGl0bGUgPSB0aGlzLmRhdGEuYWx0ZXJuYXRpdmVUZXh0OwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGxpbmtFbGVtZW50ID0gY29udGFpbmVyLmxhc3RDaGlsZDsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuZW5hYmxlU2NyaXB0aW5nICYmIHRoaXMuaGFzSlNBY3Rpb25zICYmIGxpbmtFbGVtZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9zZXREZWZhdWx0UHJvcGVydGllc0Zyb21KUyhsaW5rRWxlbWVudCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsaW5rRWxlbWVudC5hZGRFdmVudExpc3RlbmVyKCJ1cGRhdGVmcm9tc2FuZGJveCIsIGpzRXZlbnQgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Rpc3BhdGNoRXZlbnRGcm9tU2FuZGJveCh7fSwganNFdmVudCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gY29udGFpbmVyOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNsYXNzIENob2ljZVdpZGdldEFubm90YXRpb25FbGVtZW50IGV4dGVuZHMgV2lkZ2V0QW5ub3RhdGlvbkVsZW1lbnQgewogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKHBhcmFtZXRlcnMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIocGFyYW1ldGVycywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNSZW5kZXJhYmxlOiBwYXJhbWV0ZXJzLnJlbmRlckZvcm1zCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZW5kZXIoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGFpbmVyLmNsYXNzTGlzdC5hZGQoImNob2ljZVdpZGdldEFubm90YXRpb24iKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3RvcmFnZSA9IHRoaXMuYW5ub3RhdGlvblN0b3JhZ2U7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGlkID0gdGhpcy5kYXRhLmlkOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzdG9yZWREYXRhID0gc3RvcmFnZS5nZXRWYWx1ZShpZCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRoaXMuZGF0YS5maWVsZFZhbHVlCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzZWxlY3RFbGVtZW50ID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgic2VsZWN0Iik7CiAgICAgICAgICAgICAgICAgICAgICAgIEdldEVsZW1lbnRzQnlOYW1lU2V0LmFkZChzZWxlY3RFbGVtZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgc2VsZWN0RWxlbWVudC5zZXRBdHRyaWJ1dGUoImRhdGEtZWxlbWVudC1pZCIsIGlkKTsKICAgICAgICAgICAgICAgICAgICAgICAgc2VsZWN0RWxlbWVudC5kaXNhYmxlZCA9IHRoaXMuZGF0YS5yZWFkT25seTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc2V0UmVxdWlyZWQoc2VsZWN0RWxlbWVudCwgdGhpcy5kYXRhLnJlcXVpcmVkKTsKICAgICAgICAgICAgICAgICAgICAgICAgc2VsZWN0RWxlbWVudC5uYW1lID0gdGhpcy5kYXRhLmZpZWxkTmFtZTsKICAgICAgICAgICAgICAgICAgICAgICAgc2VsZWN0RWxlbWVudC50YWJJbmRleCA9IERFRkFVTFRfVEFCX0lOREVYOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgYWRkQW5FbXB0eUVudHJ5ID0gdGhpcy5kYXRhLmNvbWJvICYmIHRoaXMuZGF0YS5vcHRpb25zLmxlbmd0aCA+IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5kYXRhLmNvbWJvKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZWxlY3RFbGVtZW50LnNpemUgPSB0aGlzLmRhdGEub3B0aW9ucy5sZW5ndGg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5kYXRhLm11bHRpU2VsZWN0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VsZWN0RWxlbWVudC5tdWx0aXBsZSA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgc2VsZWN0RWxlbWVudC5hZGRFdmVudExpc3RlbmVyKCJyZXNldGZvcm0iLCBldmVudCA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBkZWZhdWx0VmFsdWUgPSB0aGlzLmRhdGEuZGVmYXVsdEZpZWxkVmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IG9wdGlvbiBvZiBzZWxlY3RFbGVtZW50Lm9wdGlvbnMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvcHRpb24uc2VsZWN0ZWQgPSBvcHRpb24udmFsdWUgPT09IGRlZmF1bHRWYWx1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3Qgb3B0aW9uIG9mIHRoaXMuZGF0YS5vcHRpb25zKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBvcHRpb25FbGVtZW50ID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgib3B0aW9uIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvcHRpb25FbGVtZW50LnRleHRDb250ZW50ID0gb3B0aW9uLmRpc3BsYXlWYWx1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9wdGlvbkVsZW1lbnQudmFsdWUgPSBvcHRpb24uZXhwb3J0VmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoc3RvcmVkRGF0YS52YWx1ZS5pbmNsdWRlcyhvcHRpb24uZXhwb3J0VmFsdWUpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgb3B0aW9uRWxlbWVudC5zZXRBdHRyaWJ1dGUoInNlbGVjdGVkIiwgdHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYWRkQW5FbXB0eUVudHJ5ID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZWxlY3RFbGVtZW50LmFwcGVuZChvcHRpb25FbGVtZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBsZXQgcmVtb3ZlRW1wdHlFbnRyeSA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChhZGRBbkVtcHR5RW50cnkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG5vbmVPcHRpb25FbGVtZW50ID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgib3B0aW9uIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBub25lT3B0aW9uRWxlbWVudC52YWx1ZSA9ICIgIjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5vbmVPcHRpb25FbGVtZW50LnNldEF0dHJpYnV0ZSgiaGlkZGVuIiwgdHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBub25lT3B0aW9uRWxlbWVudC5zZXRBdHRyaWJ1dGUoInNlbGVjdGVkIiwgdHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZWxlY3RFbGVtZW50LnByZXBlbmQobm9uZU9wdGlvbkVsZW1lbnQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVtb3ZlRW1wdHlFbnRyeSA9ICgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBub25lT3B0aW9uRWxlbWVudC5yZW1vdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZWxlY3RFbGVtZW50LnJlbW92ZUV2ZW50TGlzdGVuZXIoImlucHV0IiwgcmVtb3ZlRW1wdHlFbnRyeSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVtb3ZlRW1wdHlFbnRyeSA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VsZWN0RWxlbWVudC5hZGRFdmVudExpc3RlbmVyKCJpbnB1dCIsIHJlbW92ZUVtcHR5RW50cnkpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGdldFZhbHVlID0gaXNFeHBvcnQgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbmFtZSA9IGlzRXhwb3J0ID8gInZhbHVlIiA6ICJ0ZXh0Q29udGVudCI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgb3B0aW9ucywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtdWx0aXBsZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSA9IHNlbGVjdEVsZW1lbnQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIW11bHRpcGxlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG9wdGlvbnMuc2VsZWN0ZWRJbmRleCA9PT0gLTEgPyBudWxsIDogb3B0aW9uc1tvcHRpb25zLnNlbGVjdGVkSW5kZXhdW25hbWVdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIEFycmF5LnByb3RvdHlwZS5maWx0ZXIuY2FsbChvcHRpb25zLCBvcHRpb24gPT4gb3B0aW9uLnNlbGVjdGVkKS5tYXAob3B0aW9uID0+IG9wdGlvbltuYW1lXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBzZWxlY3RlZFZhbHVlcyA9IGdldFZhbHVlKGZhbHNlKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZ2V0SXRlbXMgPSBldmVudCA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBvcHRpb25zID0gZXZlbnQudGFyZ2V0Lm9wdGlvbnM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gQXJyYXkucHJvdG90eXBlLm1hcC5jYWxsKG9wdGlvbnMsIG9wdGlvbiA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGlzcGxheVZhbHVlOiBvcHRpb24udGV4dENvbnRlbnQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGV4cG9ydFZhbHVlOiBvcHRpb24udmFsdWUKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmVuYWJsZVNjcmlwdGluZyAmJiB0aGlzLmhhc0pTQWN0aW9ucykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VsZWN0RWxlbWVudC5hZGRFdmVudExpc3RlbmVyKCJ1cGRhdGVmcm9tc2FuZGJveCIsIGpzRXZlbnQgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGFjdGlvbnMgPSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlKGV2ZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3JlbW92ZUVtcHR5RW50cnk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoX3JlbW92ZUVtcHR5RW50cnkgPSByZW1vdmVFbXB0eUVudHJ5KSA9PT0gbnVsbCB8fCBfcmVtb3ZlRW1wdHlFbnRyeSA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3JlbW92ZUVtcHR5RW50cnkoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHZhbHVlID0gZXZlbnQuZGV0YWlsLnZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdmFsdWVzID0gbmV3IFNldChBcnJheS5pc0FycmF5KHZhbHVlKSA/IHZhbHVlIDogW3ZhbHVlXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IG9wdGlvbiBvZiBzZWxlY3RFbGVtZW50Lm9wdGlvbnMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvcHRpb24uc2VsZWN0ZWQgPSB2YWx1ZXMuaGFzKG9wdGlvbi52YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdG9yYWdlLnNldFZhbHVlKGlkLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IGdldFZhbHVlKHRydWUpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbGVjdGVkVmFsdWVzID0gZ2V0VmFsdWUoZmFsc2UpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtdWx0aXBsZVNlbGVjdGlvbihldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VsZWN0RWxlbWVudC5tdWx0aXBsZSA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlbW92ZShldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgb3B0aW9ucyA9IHNlbGVjdEVsZW1lbnQub3B0aW9uczsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGluZGV4ID0gZXZlbnQuZGV0YWlsLnJlbW92ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9wdGlvbnNbaW5kZXhdLnNlbGVjdGVkID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZWxlY3RFbGVtZW50LnJlbW92ZShpbmRleCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAob3B0aW9ucy5sZW5ndGggPiAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaSA9IEFycmF5LnByb3RvdHlwZS5maW5kSW5kZXguY2FsbChvcHRpb25zLCBvcHRpb24gPT4gb3B0aW9uLnNlbGVjdGVkKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoaSA9PT0gLTEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgb3B0aW9uc1swXS5zZWxlY3RlZCA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RvcmFnZS5zZXRWYWx1ZShpZCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBnZXRWYWx1ZSh0cnVlKSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpdGVtczogZ2V0SXRlbXMoZXZlbnQpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbGVjdGVkVmFsdWVzID0gZ2V0VmFsdWUoZmFsc2UpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbGVhcihldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgd2hpbGUgKHNlbGVjdEVsZW1lbnQubGVuZ3RoICE9PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VsZWN0RWxlbWVudC5yZW1vdmUoMCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdG9yYWdlLnNldFZhbHVlKGlkLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IG51bGwsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaXRlbXM6IFtdCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbGVjdGVkVmFsdWVzID0gZ2V0VmFsdWUoZmFsc2UpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnNlcnQoZXZlbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbmRleCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkaXNwbGF5VmFsdWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZXhwb3J0VmFsdWUKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBldmVudC5kZXRhaWwuaW5zZXJ0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2VsZWN0Q2hpbGQgPSBzZWxlY3RFbGVtZW50LmNoaWxkcmVuW2luZGV4XTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG9wdGlvbkVsZW1lbnQgPSBkb2N1bWVudC5jcmVhdGVFbGVtZW50KCJvcHRpb24iKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9wdGlvbkVsZW1lbnQudGV4dENvbnRlbnQgPSBkaXNwbGF5VmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvcHRpb25FbGVtZW50LnZhbHVlID0gZXhwb3J0VmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoc2VsZWN0Q2hpbGQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZWxlY3RDaGlsZC5iZWZvcmUob3B0aW9uRWxlbWVudCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbGVjdEVsZW1lbnQuYXBwZW5kKG9wdGlvbkVsZW1lbnQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RvcmFnZS5zZXRWYWx1ZShpZCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBnZXRWYWx1ZSh0cnVlKSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpdGVtczogZ2V0SXRlbXMoZXZlbnQpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbGVjdGVkVmFsdWVzID0gZ2V0VmFsdWUoZmFsc2UpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpdGVtcyhldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGl0ZW1zCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9ID0gZXZlbnQuZGV0YWlsOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgd2hpbGUgKHNlbGVjdEVsZW1lbnQubGVuZ3RoICE9PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VsZWN0RWxlbWVudC5yZW1vdmUoMCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGl0ZW0gb2YgaXRlbXMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRpc3BsYXlWYWx1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZXhwb3J0VmFsdWUKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9ID0gaXRlbTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBvcHRpb25FbGVtZW50ID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgib3B0aW9uIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgb3B0aW9uRWxlbWVudC50ZXh0Q29udGVudCA9IGRpc3BsYXlWYWx1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvcHRpb25FbGVtZW50LnZhbHVlID0gZXhwb3J0VmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VsZWN0RWxlbWVudC5hcHBlbmQob3B0aW9uRWxlbWVudCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoc2VsZWN0RWxlbWVudC5vcHRpb25zLmxlbmd0aCA+IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZWxlY3RFbGVtZW50Lm9wdGlvbnNbMF0uc2VsZWN0ZWQgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RvcmFnZS5zZXRWYWx1ZShpZCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBnZXRWYWx1ZSh0cnVlKSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpdGVtczogZ2V0SXRlbXMoZXZlbnQpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbGVjdGVkVmFsdWVzID0gZ2V0VmFsdWUoZmFsc2UpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbmRpY2VzKGV2ZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpbmRpY2VzID0gbmV3IFNldChldmVudC5kZXRhaWwuaW5kaWNlcyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IG9wdGlvbiBvZiBldmVudC50YXJnZXQub3B0aW9ucykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9wdGlvbi5zZWxlY3RlZCA9IGluZGljZXMuaGFzKG9wdGlvbi5pbmRleCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdG9yYWdlLnNldFZhbHVlKGlkLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IGdldFZhbHVlKHRydWUpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbGVjdGVkVmFsdWVzID0gZ2V0VmFsdWUoZmFsc2UpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlZGl0YWJsZShldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZXZlbnQudGFyZ2V0LmRpc2FibGVkID0gIWV2ZW50LmRldGFpbC5lZGl0YWJsZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZGlzcGF0Y2hFdmVudEZyb21TYW5kYm94KGFjdGlvbnMsIGpzRXZlbnQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZWxlY3RFbGVtZW50LmFkZEV2ZW50TGlzdGVuZXIoImlucHV0IiwgZXZlbnQgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRsaW5rU2VydmljZSRldmU5OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGV4cG9ydFZhbHVlID0gZ2V0VmFsdWUodHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RvcmFnZS5zZXRWYWx1ZShpZCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogZXhwb3J0VmFsdWUKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBldmVudC5wcmV2ZW50RGVmYXVsdCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIChfdGhpcyRsaW5rU2VydmljZSRldmU5ID0gdGhpcy5saW5rU2VydmljZS5ldmVudEJ1cykgPT09IG51bGwgfHwgX3RoaXMkbGlua1NlcnZpY2UkZXZlOSA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3RoaXMkbGlua1NlcnZpY2UkZXZlOS5kaXNwYXRjaCgiZGlzcGF0Y2hldmVudGluc2FuZGJveCIsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc291cmNlOiB0aGlzLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXRhaWw6IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbmFtZTogIktleXN0cm9rZSIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogc2VsZWN0ZWRWYWx1ZXMsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjaGFuZ2VFeDogZXhwb3J0VmFsdWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB3aWxsQ29tbWl0OiBmYWxzZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbW1pdEtleTogMSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGtleURvd246IGZhbHNlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc2V0RXZlbnRMaXN0ZW5lcnMoc2VsZWN0RWxlbWVudCwgW1siZm9jdXMiLCAiRm9jdXMiXSwgWyJibHVyIiwgIkJsdXIiXSwgWyJtb3VzZWRvd24iLCAiTW91c2UgRG93biJdLCBbIm1vdXNlZW50ZXIiLCAiTW91c2UgRW50ZXIiXSwgWyJtb3VzZWxlYXZlIiwgIk1vdXNlIEV4aXQiXSwgWyJtb3VzZXVwIiwgIk1vdXNlIFVwIl0sIFsiaW5wdXQiLCAiQWN0aW9uIl0sIFsiaW5wdXQiLCAiVmFsaWRhdGUiXV0sIGV2ZW50ID0+IGV2ZW50LnRhcmdldC52YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZWxlY3RFbGVtZW50LmFkZEV2ZW50TGlzdGVuZXIoImlucHV0IiwgZnVuY3Rpb24gKGV2ZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RvcmFnZS5zZXRWYWx1ZShpZCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogZ2V0VmFsdWUodHJ1ZSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmRhdGEuY29tYm8pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3NldFRleHRTdHlsZShzZWxlY3RFbGVtZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHt9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3NldEJhY2tncm91bmRDb2xvcihzZWxlY3RFbGVtZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc2V0RGVmYXVsdFByb3BlcnRpZXNGcm9tSlMoc2VsZWN0RWxlbWVudCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGFpbmVyLmFwcGVuZChzZWxlY3RFbGVtZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuY29udGFpbmVyOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNsYXNzIFBvcHVwQW5ub3RhdGlvbkVsZW1lbnQgZXh0ZW5kcyBBbm5vdGF0aW9uRWxlbWVudCB7CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIElHTk9SRV9UWVBFUyA9IG5ldyBTZXQoWyJMaW5lIiwgIlNxdWFyZSIsICJDaXJjbGUiLCAiUG9seUxpbmUiLCAiUG9seWdvbiIsICJJbmsiXSk7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IocGFyYW1ldGVycykgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX2RhdGEkdGl0bGVPYmosIF9kYXRhJGNvbnRlbnRzT2JqLCBfZGF0YSRyaWNoVGV4dDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGF0YQogICAgICAgICAgICAgICAgICAgICAgICB9ID0gcGFyYW1ldGVyczsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaXNSZW5kZXJhYmxlID0gIVBvcHVwQW5ub3RhdGlvbkVsZW1lbnQuSUdOT1JFX1RZUEVTLmhhcyhkYXRhLnBhcmVudFR5cGUpICYmICEhKChfZGF0YSR0aXRsZU9iaiA9IGRhdGEudGl0bGVPYmopICE9PSBudWxsICYmIF9kYXRhJHRpdGxlT2JqICE9PSB2b2lkIDAgJiYgX2RhdGEkdGl0bGVPYmouc3RyIHx8IChfZGF0YSRjb250ZW50c09iaiA9IGRhdGEuY29udGVudHNPYmopICE9PSBudWxsICYmIF9kYXRhJGNvbnRlbnRzT2JqICE9PSB2b2lkIDAgJiYgX2RhdGEkY29udGVudHNPYmouc3RyIHx8IChfZGF0YSRyaWNoVGV4dCA9IGRhdGEucmljaFRleHQpICE9PSBudWxsICYmIF9kYXRhJHJpY2hUZXh0ICE9PSB2b2lkIDAgJiYgX2RhdGEkcmljaFRleHQuc3RyKTsKICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIocGFyYW1ldGVycywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNSZW5kZXJhYmxlCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZW5kZXIoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGFpbmVyLmNsYXNzTGlzdC5hZGQoInBvcHVwQW5ub3RhdGlvbiIpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwYXJlbnRFbGVtZW50cyA9IHRoaXMubGF5ZXIucXVlcnlTZWxlY3RvckFsbChgW2RhdGEtYW5ub3RhdGlvbi1pZD0iJHt0aGlzLmRhdGEucGFyZW50SWR9Il1gKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHBhcmVudEVsZW1lbnRzLmxlbmd0aCA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuY29udGFpbmVyOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHBvcHVwID0gbmV3IFBvcHVwRWxlbWVudCh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250YWluZXI6IHRoaXMuY29udGFpbmVyLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJpZ2dlcjogQXJyYXkuZnJvbShwYXJlbnRFbGVtZW50cyksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb2xvcjogdGhpcy5kYXRhLmNvbG9yLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGl0bGVPYmo6IHRoaXMuZGF0YS50aXRsZU9iaiwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1vZGlmaWNhdGlvbkRhdGU6IHRoaXMuZGF0YS5tb2RpZmljYXRpb25EYXRlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGVudHNPYmo6IHRoaXMuZGF0YS5jb250ZW50c09iaiwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJpY2hUZXh0OiB0aGlzLmRhdGEucmljaFRleHQKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHBhZ2UgPSB0aGlzLnBhZ2U7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHJlY3QgPSBfdXRpbC5VdGlsLm5vcm1hbGl6ZVJlY3QoW3RoaXMuZGF0YS5wYXJlbnRSZWN0WzBdLCBwYWdlLnZpZXdbM10gLSB0aGlzLmRhdGEucGFyZW50UmVjdFsxXSArIHBhZ2Uudmlld1sxXSwgdGhpcy5kYXRhLnBhcmVudFJlY3RbMl0sIHBhZ2Uudmlld1szXSAtIHRoaXMuZGF0YS5wYXJlbnRSZWN0WzNdICsgcGFnZS52aWV3WzFdXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHBvcHVwTGVmdCA9IHJlY3RbMF0gKyB0aGlzLmRhdGEucGFyZW50UmVjdFsyXSAtIHRoaXMuZGF0YS5wYXJlbnRSZWN0WzBdOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwb3B1cFRvcCA9IHJlY3RbMV07CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2VXaWR0aCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2VIZWlnaHQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYWdlWCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2VZCiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSB0aGlzLnZpZXdwb3J0LnJhd0RpbXM7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGFpbmVyLnN0eWxlLmxlZnQgPSBgJHsxMDAgKiAocG9wdXBMZWZ0IC0gcGFnZVgpIC8gcGFnZVdpZHRofSVgOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRhaW5lci5zdHlsZS50b3AgPSBgJHsxMDAgKiAocG9wdXBUb3AgLSBwYWdlWSkgLyBwYWdlSGVpZ2h0fSVgOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRhaW5lci5hcHBlbmQocG9wdXAucmVuZGVyKCkpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5jb250YWluZXI7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY2xhc3MgUG9wdXBFbGVtZW50IHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcihwYXJhbWV0ZXJzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGFpbmVyID0gcGFyYW1ldGVycy5jb250YWluZXI7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudHJpZ2dlciA9IHBhcmFtZXRlcnMudHJpZ2dlcjsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb2xvciA9IHBhcmFtZXRlcnMuY29sb3I7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudGl0bGVPYmogPSBwYXJhbWV0ZXJzLnRpdGxlT2JqOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm1vZGlmaWNhdGlvbkRhdGUgPSBwYXJhbWV0ZXJzLm1vZGlmaWNhdGlvbkRhdGU7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGVudHNPYmogPSBwYXJhbWV0ZXJzLmNvbnRlbnRzT2JqOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnJpY2hUZXh0ID0gcGFyYW1ldGVycy5yaWNoVGV4dDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5oaWRlV3JhcHBlciA9IHBhcmFtZXRlcnMuaGlkZVdyYXBwZXIgfHwgZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGlubmVkID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlbmRlcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF90aGlzJHJpY2hUZXh0LCBfdGhpcyRjb250ZW50c09iajsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgQkFDS0dST1VORF9FTkxJR0hUID0gMC43OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB3cmFwcGVyID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgiZGl2Iik7CiAgICAgICAgICAgICAgICAgICAgICAgIHdyYXBwZXIuY2xhc3NMaXN0LmFkZCgicG9wdXBXcmFwcGVyIik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuaGlkZUVsZW1lbnQgPSB0aGlzLmhpZGVXcmFwcGVyID8gd3JhcHBlciA6IHRoaXMuY29udGFpbmVyOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmhpZGVFbGVtZW50LmhpZGRlbiA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHBvcHVwID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgiZGl2Iik7CiAgICAgICAgICAgICAgICAgICAgICAgIHBvcHVwLmNsYXNzTGlzdC5hZGQoInBvcHVwIik7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNvbG9yID0gdGhpcy5jb2xvcjsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGNvbG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByID0gQkFDS0dST1VORF9FTkxJR0hUICogKDI1NSAtIGNvbG9yWzBdKSArIGNvbG9yWzBdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZyA9IEJBQ0tHUk9VTkRfRU5MSUdIVCAqICgyNTUgLSBjb2xvclsxXSkgKyBjb2xvclsxXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGIgPSBCQUNLR1JPVU5EX0VOTElHSFQgKiAoMjU1IC0gY29sb3JbMl0pICsgY29sb3JbMl07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwb3B1cC5zdHlsZS5iYWNrZ3JvdW5kQ29sb3IgPSBfdXRpbC5VdGlsLm1ha2VIZXhDb2xvcihyIHwgMCwgZyB8IDAsIGIgfCAwKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB0aXRsZSA9IGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoImgxIik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRpdGxlLmRpciA9IHRoaXMudGl0bGVPYmouZGlyOwogICAgICAgICAgICAgICAgICAgICAgICB0aXRsZS50ZXh0Q29udGVudCA9IHRoaXMudGl0bGVPYmouc3RyOwogICAgICAgICAgICAgICAgICAgICAgICBwb3B1cC5hcHBlbmQodGl0bGUpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBkYXRlT2JqZWN0ID0gX2Rpc3BsYXlfdXRpbHMuUERGRGF0ZVN0cmluZy50b0RhdGVPYmplY3QodGhpcy5tb2RpZmljYXRpb25EYXRlKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGRhdGVPYmplY3QpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG1vZGlmaWNhdGlvbkRhdGUgPSBkb2N1bWVudC5jcmVhdGVFbGVtZW50KCJzcGFuIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtb2RpZmljYXRpb25EYXRlLmNsYXNzTGlzdC5hZGQoInBvcHVwRGF0ZSIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbW9kaWZpY2F0aW9uRGF0ZS50ZXh0Q29udGVudCA9ICJ7e2RhdGV9fSwge3t0aW1lfX0iOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbW9kaWZpY2F0aW9uRGF0ZS5kYXRhc2V0LmwxMG5JZCA9ICJhbm5vdGF0aW9uX2RhdGVfc3RyaW5nIjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1vZGlmaWNhdGlvbkRhdGUuZGF0YXNldC5sMTBuQXJncyA9IEpTT04uc3RyaW5naWZ5KHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkYXRlOiBkYXRlT2JqZWN0LnRvTG9jYWxlRGF0ZVN0cmluZygpLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRpbWU6IGRhdGVPYmplY3QudG9Mb2NhbGVUaW1lU3RyaW5nKCkKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcG9wdXAuYXBwZW5kKG1vZGlmaWNhdGlvbkRhdGUpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICgoX3RoaXMkcmljaFRleHQgPSB0aGlzLnJpY2hUZXh0KSAhPT0gbnVsbCAmJiBfdGhpcyRyaWNoVGV4dCAhPT0gdm9pZCAwICYmIF90aGlzJHJpY2hUZXh0LnN0ciAmJiAoISgoX3RoaXMkY29udGVudHNPYmogPSB0aGlzLmNvbnRlbnRzT2JqKSAhPT0gbnVsbCAmJiBfdGhpcyRjb250ZW50c09iaiAhPT0gdm9pZCAwICYmIF90aGlzJGNvbnRlbnRzT2JqLnN0cikgfHwgdGhpcy5jb250ZW50c09iai5zdHIgPT09IHRoaXMucmljaFRleHQuc3RyKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgX3hmYV9sYXllci5YZmFMYXllci5yZW5kZXIoewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHhmYUh0bWw6IHRoaXMucmljaFRleHQuaHRtbCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnRlbnQ6ICJyaWNoVGV4dCIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGl2OiBwb3B1cAogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwb3B1cC5sYXN0Q2hpbGQuY2xhc3NMaXN0LmFkZCgicmljaFRleHQiLCAicG9wdXBDb250ZW50Iik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjb250ZW50cyA9IHRoaXMuX2Zvcm1hdENvbnRlbnRzKHRoaXMuY29udGVudHNPYmopOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcG9wdXAuYXBwZW5kKGNvbnRlbnRzKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIUFycmF5LmlzQXJyYXkodGhpcy50cmlnZ2VyKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy50cmlnZ2VyID0gW3RoaXMudHJpZ2dlcl07CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBlbGVtZW50IG9mIHRoaXMudHJpZ2dlcikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5hZGRFdmVudExpc3RlbmVyKCJjbGljayIsIHRoaXMuX3RvZ2dsZS5iaW5kKHRoaXMpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1lbnQuYWRkRXZlbnRMaXN0ZW5lcigibW91c2VvdmVyIiwgdGhpcy5fc2hvdy5iaW5kKHRoaXMsIGZhbHNlKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50LmFkZEV2ZW50TGlzdGVuZXIoIm1vdXNlb3V0IiwgdGhpcy5faGlkZS5iaW5kKHRoaXMsIGZhbHNlKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcG9wdXAuYWRkRXZlbnRMaXN0ZW5lcigiY2xpY2siLCB0aGlzLl9oaWRlLmJpbmQodGhpcywgdHJ1ZSkpOwogICAgICAgICAgICAgICAgICAgICAgICB3cmFwcGVyLmFwcGVuZChwb3B1cCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB3cmFwcGVyOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfZm9ybWF0Q29udGVudHMoX3JlZikgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RyLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGlyCiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBfcmVmOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgicCIpOwogICAgICAgICAgICAgICAgICAgICAgICBwLmNsYXNzTGlzdC5hZGQoInBvcHVwQ29udGVudCIpOwogICAgICAgICAgICAgICAgICAgICAgICBwLmRpciA9IGRpcjsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbGluZXMgPSBzdHIuc3BsaXQoLyg/OlxyXG4/fFxuKS8pOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMCwgaWkgPSBsaW5lcy5sZW5ndGg7IGkgPCBpaTsgKytpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBsaW5lID0gbGluZXNbaV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwLmFwcGVuZChkb2N1bWVudC5jcmVhdGVUZXh0Tm9kZShsaW5lKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoaSA8IGlpIC0gMSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHAuYXBwZW5kKGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoImJyIikpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBwOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfdG9nZ2xlKCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5waW5uZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2hpZGUodHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9zaG93KHRydWUpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9zaG93KCkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgcGluID0gYXJndW1lbnRzLmxlbmd0aCA+IDAgJiYgYXJndW1lbnRzWzBdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMF0gOiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHBpbikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5waW5uZWQgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmhpZGVFbGVtZW50LmhpZGRlbikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5oaWRlRWxlbWVudC5oaWRkZW4gPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGFpbmVyLnN0eWxlLnpJbmRleCA9IHBhcnNlSW50KHRoaXMuY29udGFpbmVyLnN0eWxlLnpJbmRleCkgKyAxMDAwOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9oaWRlKCkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgdW5waW4gPSBhcmd1bWVudHMubGVuZ3RoID4gMCAmJiBhcmd1bWVudHNbMF0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1swXSA6IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh1bnBpbikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5waW5uZWQgPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuaGlkZUVsZW1lbnQuaGlkZGVuICYmICF0aGlzLnBpbm5lZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5oaWRlRWxlbWVudC5oaWRkZW4gPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb250YWluZXIuc3R5bGUuekluZGV4ID0gcGFyc2VJbnQodGhpcy5jb250YWluZXIuc3R5bGUuekluZGV4KSAtIDEwMDA7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBGcmVlVGV4dEFubm90YXRpb25FbGVtZW50IGV4dGVuZHMgQW5ub3RhdGlvbkVsZW1lbnQgewogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKHBhcmFtZXRlcnMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF9wYXJhbWV0ZXJzJGRhdGEkdGl0bDIsIF9wYXJhbWV0ZXJzJGRhdGEkY29udDIsIF9wYXJhbWV0ZXJzJGRhdGEkcmljaDI7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGlzUmVuZGVyYWJsZSA9ICEhKHBhcmFtZXRlcnMuZGF0YS5oYXNQb3B1cCB8fCAoX3BhcmFtZXRlcnMkZGF0YSR0aXRsMiA9IHBhcmFtZXRlcnMuZGF0YS50aXRsZU9iaikgIT09IG51bGwgJiYgX3BhcmFtZXRlcnMkZGF0YSR0aXRsMiAhPT0gdm9pZCAwICYmIF9wYXJhbWV0ZXJzJGRhdGEkdGl0bDIuc3RyIHx8IChfcGFyYW1ldGVycyRkYXRhJGNvbnQyID0gcGFyYW1ldGVycy5kYXRhLmNvbnRlbnRzT2JqKSAhPT0gbnVsbCAmJiBfcGFyYW1ldGVycyRkYXRhJGNvbnQyICE9PSB2b2lkIDAgJiYgX3BhcmFtZXRlcnMkZGF0YSRjb250Mi5zdHIgfHwgKF9wYXJhbWV0ZXJzJGRhdGEkcmljaDIgPSBwYXJhbWV0ZXJzLmRhdGEucmljaFRleHQpICE9PSBudWxsICYmIF9wYXJhbWV0ZXJzJGRhdGEkcmljaDIgIT09IHZvaWQgMCAmJiBfcGFyYW1ldGVycyRkYXRhJHJpY2gyLnN0cik7CiAgICAgICAgICAgICAgICAgICAgICAgIHN1cGVyKHBhcmFtZXRlcnMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlzUmVuZGVyYWJsZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlnbm9yZUJvcmRlcjogdHJ1ZQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy50ZXh0Q29udGVudCA9IHBhcmFtZXRlcnMuZGF0YS50ZXh0Q29udGVudDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmVuZGVyKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRhaW5lci5jbGFzc0xpc3QuYWRkKCJmcmVlVGV4dEFubm90YXRpb24iKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMudGV4dENvbnRlbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNvbnRlbnQgPSBkb2N1bWVudC5jcmVhdGVFbGVtZW50KCJkaXYiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRlbnQuY2xhc3NMaXN0LmFkZCgiYW5ub3RhdGlvblRleHRDb250ZW50Iik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250ZW50LnNldEF0dHJpYnV0ZSgicm9sZSIsICJjb21tZW50Iik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGxpbmUgb2YgdGhpcy50ZXh0Q29udGVudCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGxpbmVTcGFuID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgic3BhbiIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxpbmVTcGFuLnRleHRDb250ZW50ID0gbGluZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250ZW50LmFwcGVuZChsaW5lU3Bhbik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRhaW5lci5hcHBlbmQoY29udGVudCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLmRhdGEuaGFzUG9wdXApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NyZWF0ZVBvcHVwKG51bGwsIHRoaXMuZGF0YSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuY29udGFpbmVyOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNsYXNzIExpbmVBbm5vdGF0aW9uRWxlbWVudCBleHRlbmRzIEFubm90YXRpb25FbGVtZW50IHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcihwYXJhbWV0ZXJzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfcGFyYW1ldGVycyRkYXRhJHRpdGwzLCBfcGFyYW1ldGVycyRkYXRhJGNvbnQzLCBfcGFyYW1ldGVycyRkYXRhJHJpY2gzOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpc1JlbmRlcmFibGUgPSAhIShwYXJhbWV0ZXJzLmRhdGEuaGFzUG9wdXAgfHwgKF9wYXJhbWV0ZXJzJGRhdGEkdGl0bDMgPSBwYXJhbWV0ZXJzLmRhdGEudGl0bGVPYmopICE9PSBudWxsICYmIF9wYXJhbWV0ZXJzJGRhdGEkdGl0bDMgIT09IHZvaWQgMCAmJiBfcGFyYW1ldGVycyRkYXRhJHRpdGwzLnN0ciB8fCAoX3BhcmFtZXRlcnMkZGF0YSRjb250MyA9IHBhcmFtZXRlcnMuZGF0YS5jb250ZW50c09iaikgIT09IG51bGwgJiYgX3BhcmFtZXRlcnMkZGF0YSRjb250MyAhPT0gdm9pZCAwICYmIF9wYXJhbWV0ZXJzJGRhdGEkY29udDMuc3RyIHx8IChfcGFyYW1ldGVycyRkYXRhJHJpY2gzID0gcGFyYW1ldGVycy5kYXRhLnJpY2hUZXh0KSAhPT0gbnVsbCAmJiBfcGFyYW1ldGVycyRkYXRhJHJpY2gzICE9PSB2b2lkIDAgJiYgX3BhcmFtZXRlcnMkZGF0YSRyaWNoMy5zdHIpOwogICAgICAgICAgICAgICAgICAgICAgICBzdXBlcihwYXJhbWV0ZXJzLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc1JlbmRlcmFibGUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZ25vcmVCb3JkZXI6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlbmRlcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb250YWluZXIuY2xhc3NMaXN0LmFkZCgibGluZUFubm90YXRpb24iKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZGF0YSA9IHRoaXMuZGF0YTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd2lkdGgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoZWlnaHQKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IGdldFJlY3REaW1zKGRhdGEucmVjdCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN2ZyA9IHRoaXMuc3ZnRmFjdG9yeS5jcmVhdGUod2lkdGgsIGhlaWdodCwgdHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGxpbmUgPSB0aGlzLnN2Z0ZhY3RvcnkuY3JlYXRlRWxlbWVudCgic3ZnOmxpbmUiKTsKICAgICAgICAgICAgICAgICAgICAgICAgbGluZS5zZXRBdHRyaWJ1dGUoIngxIiwgZGF0YS5yZWN0WzJdIC0gZGF0YS5saW5lQ29vcmRpbmF0ZXNbMF0pOwogICAgICAgICAgICAgICAgICAgICAgICBsaW5lLnNldEF0dHJpYnV0ZSgieTEiLCBkYXRhLnJlY3RbM10gLSBkYXRhLmxpbmVDb29yZGluYXRlc1sxXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGxpbmUuc2V0QXR0cmlidXRlKCJ4MiIsIGRhdGEucmVjdFsyXSAtIGRhdGEubGluZUNvb3JkaW5hdGVzWzJdKTsKICAgICAgICAgICAgICAgICAgICAgICAgbGluZS5zZXRBdHRyaWJ1dGUoInkyIiwgZGF0YS5yZWN0WzNdIC0gZGF0YS5saW5lQ29vcmRpbmF0ZXNbM10pOwogICAgICAgICAgICAgICAgICAgICAgICBsaW5lLnNldEF0dHJpYnV0ZSgic3Ryb2tlLXdpZHRoIiwgZGF0YS5ib3JkZXJTdHlsZS53aWR0aCB8fCAxKTsKICAgICAgICAgICAgICAgICAgICAgICAgbGluZS5zZXRBdHRyaWJ1dGUoInN0cm9rZSIsICJ0cmFuc3BhcmVudCIpOwogICAgICAgICAgICAgICAgICAgICAgICBsaW5lLnNldEF0dHJpYnV0ZSgiZmlsbCIsICJ0cmFuc3BhcmVudCIpOwogICAgICAgICAgICAgICAgICAgICAgICBzdmcuYXBwZW5kKGxp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JpY2g0ICE9PSB2b2lkIDAgJiYgX3BhcmFtZXRlcnMkZGF0YSRyaWNoNC5zdHIpOwogICAgICAgICAgICAgICAgICAgICAgICBzdXBlcihwYXJhbWV0ZXJzLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc1JlbmRlcmFibGUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZ25vcmVCb3JkZXI6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlbmRlcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb250YWluZXIuY2xhc3NMaXN0LmFkZCgic3F1YXJlQW5ub3RhdGlvbiIpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBkYXRhID0gdGhpcy5kYXRhOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3aWR0aCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGhlaWdodAogICAgICAgICAgICAgICAgICAgICAgICB9ID0gZ2V0UmVjdERpbXMoZGF0YS5yZWN0KTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3ZnID0gdGhpcy5zdmdGYWN0b3J5LmNyZWF0ZSh3aWR0aCwgaGVpZ2h0LCB0cnVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYm9yZGVyV2lkdGggPSBkYXRhLmJvcmRlclN0eWxlLndpZHRoOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzcXVhcmUgPSB0aGlzLnN2Z0ZhY3RvcnkuY3JlYXRlRWxlbWVudCgic3ZnOnJlY3QiKTsKICAgICAgICAgICAgICAgICAgICAgICAgc3F1YXJlLnNldEF0dHJpYnV0ZSgieCIsIGJvcmRlcldpZHRoIC8gMik7CiAgICAgICAgICAgICAgICAgICAgICAgIHNxdWFyZS5zZXRBdHRyaWJ1dGUoInkiLCBib3JkZXJXaWR0aCAvIDIpOwogICAgICAgICAgICAgICAgICAgICAgICBzcXVhcmUuc2V0QXR0cmlidXRlKCJ3aWR0aCIsIHdpZHRoIC0gYm9yZGVyV2lkdGgpOwogICAgICAgICAgICAgICAgICAgICAgICBzcXVhcmUuc2V0QXR0cmlidXRlKCJoZWlnaHQiLCBoZWlnaHQgLSBib3JkZXJXaWR0aCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHNxdWFyZS5zZXRBdHRyaWJ1dGUoInN0cm9rZS13aWR0aCIsIGJvcmRlcldpZHRoIHx8IDEpOwogICAgICAgICAgICAgICAgICAgICAgICBzcXVhcmUuc2V0QXR0cmlidXRlKCJzdHJva2UiLCAidHJhbnNwYXJlbnQiKTsKICAgICAgICAgICAgICAgICAgICAgICAgc3F1YXJlLnNldEF0dHJpYnV0ZSgiZmlsbCIsICJ0cmFuc3BhcmVudCIpOwogICAgICAgICAgICAgICAgICAgICAgICBzdmcuYXBwZW5kKHNxdWFyZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGFpbmVyLmFwcGVuZChzdmcpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jcmVhdGVQb3B1cChzcXVhcmUsIGRhdGEpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5jb250YWluZXI7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY2xhc3MgQ2lyY2xlQW5ub3RhdGlvbkVsZW1lbnQgZXh0ZW5kcyBBbm5vdGF0aW9uRWxlbWVudCB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IocGFyYW1ldGVycykgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3BhcmFtZXRlcnMkZGF0YSR0aXRsNSwgX3BhcmFtZXRlcnMkZGF0YSRjb250NSwgX3BhcmFtZXRlcnMkZGF0YSRyaWNoNTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaXNSZW5kZXJhYmxlID0gISEocGFyYW1ldGVycy5kYXRhLmhhc1BvcHVwIHx8IChfcGFyYW1ldGVycyRkYXRhJHRpdGw1ID0gcGFyYW1ldGVycy5kYXRhLnRpdGxlT2JqKSAhPT0gbnVsbCAmJiBfcGFyYW1ldGVycyRkYXRhJHRpdGw1ICE9PSB2b2lkIDAgJiYgX3BhcmFtZXRlcnMkZGF0YSR0aXRsNS5zdHIgfHwgKF9wYXJhbWV0ZXJzJGRhdGEkY29udDUgPSBwYXJhbWV0ZXJzLmRhdGEuY29udGVudHNPYmopICE9PSBudWxsICYmIF9wYXJhbWV0ZXJzJGRhdGEkY29udDUgIT09IHZvaWQgMCAmJiBfcGFyYW1ldGVycyRkYXRhJGNvbnQ1LnN0ciB8fCAoX3BhcmFtZXRlcnMkZGF0YSRyaWNoNSA9IHBhcmFtZXRlcnMuZGF0YS5yaWNoVGV4dCkgIT09IG51bGwgJiYgX3BhcmFtZXRlcnMkZGF0YSRyaWNoNSAhPT0gdm9pZCAwICYmIF9wYXJhbWV0ZXJzJGRhdGEkcmljaDUuc3RyKTsKICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIocGFyYW1ldGVycywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNSZW5kZXJhYmxlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWdub3JlQm9yZGVyOiB0cnVlCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZW5kZXIoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGFpbmVyLmNsYXNzTGlzdC5hZGQoImNpcmNsZUFubm90YXRpb24iKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZGF0YSA9IHRoaXMuZGF0YTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd2lkdGgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoZWlnaHQKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IGdldFJlY3REaW1zKGRhdGEucmVjdCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN2ZyA9IHRoaXMuc3ZnRmFjdG9yeS5jcmVhdGUod2lkdGgsIGhlaWdodCwgdHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGJvcmRlcldpZHRoID0gZGF0YS5ib3JkZXJTdHlsZS53aWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2lyY2xlID0gdGhpcy5zdmdGYWN0b3J5LmNyZWF0ZUVsZW1lbnQoInN2ZzplbGxpcHNlIik7CiAgICAgICAgICAgICAgICAgICAgICAgIGNpcmNsZS5zZXRBdHRyaWJ1dGUoImN4Iiwgd2lkdGggLyAyKTsKICAgICAgICAgICAgICAgICAgICAgICAgY2lyY2xlLnNldEF0dHJpYnV0ZSgiY3kiLCBoZWlnaHQgLyAyKTsKICAgICAgICAgICAgICAgICAgICAgICAgY2lyY2xlLnNldEF0dHJpYnV0ZSgicngiLCB3aWR0aCAvIDIgLSBib3JkZXJXaWR0aCAvIDIpOwogICAgICAgICAgICAgICAgICAgICAgICBjaXJjbGUuc2V0QXR0cmlidXRlKCJyeSIsIGhlaWdodCAvIDIgLSBib3JkZXJXaWR0aCAvIDIpOwogICAgICAgICAgICAgICAgICAgICAgICBjaXJjbGUuc2V0QXR0cmlidXRlKCJzdHJva2Utd2lkdGgiLCBib3JkZXJXaWR0aCB8fCAxKTsKICAgICAgICAgICAgICAgICAgICAgICAgY2lyY2xlLnNldEF0dHJpYnV0ZSgic3Ryb2tlIiwgInRyYW5zcGFyZW50Iik7CiAgICAgICAgICAgICAgICAgICAgICAgIGNpcmNsZS5zZXRBdHRyaWJ1dGUoImZpbGwiLCAidHJhbnNwYXJlbnQiKTsKICAgICAgICAgICAgICAgICAgICAgICAgc3ZnLmFwcGVuZChjaXJjbGUpOwogIC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yaWNoNiAhPT0gdm9pZCAwICYmIF9wYXJhbWV0ZXJzJGRhdGEkcmljaDYuc3RyKTsKICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIocGFyYW1ldGVycywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNSZW5kZXJhYmxlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWdub3JlQm9yZGVyOiB0cnVlCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRhaW5lckNsYXNzTmFtZSA9ICJwb2x5bGluZUFubm90YXRpb24iOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnN2Z0VsZW1lbnROYW1lID0gInN2Zzpwb2x5bGluZSI7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlbmRlcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb250YWluZXIuY2xhc3NMaXN0LmFkZCh0aGlzLmNvbnRhaW5lckNsYXNzTmFtZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGRhdGEgPSB0aGlzLmRhdGE7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdpZHRoLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaGVpZ2h0CiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBnZXRSZWN0RGltcyhkYXRhLnJlY3QpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzdmcgPSB0aGlzLnN2Z0ZhY3RvcnkuY3JlYXRlKHdpZHRoLCBoZWlnaHQsIHRydWUpOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgcG9pbnRzID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgY29vcmRpbmF0ZSBvZiBkYXRhLnZlcnRpY2VzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB4ID0gY29vcmRpbmF0ZS54IC0gZGF0YS5yZWN0WzBdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgeSA9IGRhdGEucmVjdFszXSAtIGNvb3JkaW5hdGUueTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBvaW50cy5wdXNoKHggKyAiLCIgKyB5KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBwb2ludHMgPSBwb2ludHMuam9pbigiICIpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwb2x5bGluZSA9IHRoaXMuc3ZnRmFjdG9yeS5jcmVhdGVFbGVtZW50KHRoaXMuc3ZnRWxlbWVudE5hbWUpOwogICAgICAgICAgICAgICAgICAgICAgICBwb2x5bGluZS5zZXRBdHRyaWJ1dGUoInBvaW50cyIsIHBvaW50cyk7CiAgICAgICAgICAgICAgICAgICAgICAgIHBvbHlsaW5lLnNldEF0dHJpYnV0ZSgic3Ryb2tlLXdpZHRoIiwgZGF0YS5ib3JkZXJTdHlsZS53aWR0aCB8fCAxKTsKICAgICAgICAgICAgICAgICAgICAgICAgcG9seWxpbmUuc2V0QXR0cmlidXRlKCJzdHJva2UiLCAidHJhbnNwYXJlbnQiKTsKICAgICAgICAgICAgICAgICAgICAgICAgcG9seWxpbmUuc2V0QXR0cmlidXRlKCJmaWxsIiwgInRyYW5zcGFyZW50Iik7CiAgICAgICAgICAgICAgICAgICAgICAgIHN2Zy5hcHBlbmQocG9seWxpbmUpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRhaW5lci5hcHBlbmQoc3ZnKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fY3JlYXRlUG9wdXAocG9seWxpbmUsIGRhdGEpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5jb250YWluZXI7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY2xhc3MgUG9seWdvbkFubm90YXRpb25FbGVtZW50IGV4dGVuZHMgUG9seWxpbmVBbm5vdGF0aW9uRWxlbWVudCB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IocGFyYW1ldGVycykgewogICAgICAgICAgICAgICAgICAgICAgICBzdXBlcihwYXJhbWV0ZXJzKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb250YWluZXJDbGFzc05hbWUgPSAicG9seWdvbkFubm90YXRpb24iOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnN2Z0VsZW1lbnROYW1lID0gInN2Zzpwb2x5Z29uIjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBDYXJldEFubm90YXRpb25FbGVtZW50IGV4dGVuZHMgQW5ub3RhdGlvbkVsZW1lbnQgewogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKHBhcmFtZXRlcnMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF9wYXJhbWV0ZXJzJGRhdGEkdGl0bDcsIF9wYXJhbWV0ZXJzJGRhdGEkY29udDcsIF9wYXJhbWV0ZXJzJGRhdGEkcmljaDc7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGlzUmVuZGVyYWJsZSA9ICEhKHBhcmFtZXRlcnMuZGF0YS5oYXNQb3B1cCB8fCAoX3BhcmFtZXRlcnMkZGF0YSR0aXRsNyA9IHBhcmFtZXRlcnMuZGF0YS50aXRsZU9iaikgIT09IG51bGwgJiYgX3BhcmFtZXRlcnMkZGF0YSR0aXRsNyAhPT0gdm9pZCAwICYmIF9wYXJhbWV0ZXJzJGRhdGEkdGl0bDcuc3RyIHx8IChfcGFyYW1ldGVycyRkYXRhJGNvbnQ3ID0gcGFyYW1ldGVycy5kYXRhLmNvbnRlbnRzT2JqKSAhPT0gbnVsbCAmJiBfcGFyYW1ldGVycyRkYXRhJGNvbnQ3ICE9PSB2b2lkIDAgJiYgX3BhcmFtZXRlcnMkZGF0YSRjb250Ny5zdHIgfHwgKF9wYXJhbWV0ZXJzJGRhdGEkcmljaDcgPSBwYXJhbWV0ZXJzLmRhdGEucmljaFRleHQpICE9PSBudWxsICYmIF9wYXJhbWV0ZXJzJGRhdGEkcmljaDcgIT09IHZvaWQgMCAmJiBfcGFyYW1ldGVycyRkYXRhJHJpY2g3LnN0cik7CiAgICAgICAgICAgICAgICAgICAgICAgIHN1cGVyKHBhcmFtZXRlcnMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlzUmVuZGVyYWJsZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlnbm9yZUJvcmRlcjogdHJ1ZQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmVuZGVyKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRhaW5lci5jbGFzc0xpc3QuYWRkKCJjYXJldEFubm90YXRpb24iKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLmRhdGEuaGFzUG9wdXApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NyZWF0ZVBvcHVwKG51bGwsIHRoaXMuZGF0YSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuY29udGFpbmVyOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNsYXNzIElua0Fubm90YXRpb25FbGVtZW50IGV4dGVuZHMgQW5ub3RhdGlvbkVsZW1lbnQgewogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKHBhcmFtZXRlcnMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF9wYXJhbWV0ZXJzJGRhdGEkdGl0bDgsIF9wYXJhbWV0ZXJzJGRhdGEkY29udDgsI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ewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRhaW5lci5jbGFzc0xpc3QuYWRkKHRoaXMuY29udGFpbmVyQ2xhc3NOYW1lKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZGF0YSA9IHRoaXMuZGF0YTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd2lkdGgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoZWlnaHQKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IGdldFJlY3REaW1zKGRhdGEucmVjdCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN2ZyA9IHRoaXMuc3ZnRmFjdG9yeS5jcmVhdGUod2lkdGgsIGhlaWdodCwgdHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgaW5rTGlzdCBvZiBkYXRhLmlua0xpc3RzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgcG9pbnRzID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGNvb3JkaW5hdGUgb2YgaW5rTGlzdCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHggPSBjb29yZGluYXRlLnggLSBkYXRhLnJlY3RbMF07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgeSA9IGRhdGEucmVjdFszXSAtIGNvb3JkaW5hdGUueTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwb2ludHMucHVzaChgJHt4fSwke3l9YCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwb2ludHMgPSBwb2ludHMuam9pbigiICIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcG9seWxpbmUgPSB0aGlzLnN2Z0ZhY3RvcnkuY3JlYXRlRWxlbWVudCh0aGlzLnN2Z0VsZW1lbnROYW1lKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBvbHlsaW5lLnNldEF0dHJpYnV0ZSgicG9pbnRzIiwgcG9pbnRzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBvbHlsaW5lLnNldEF0dHJpYnV0ZSgic3Ryb2tlLXdpZHRoIiwgZGF0YS5ib3JkZXJTdHlsZS53aWR0aCB8fCAxKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBvbHlsaW5lLnNldEF0dHJpYnV0ZSgic3Ryb2tlIiwgInRyYW5zcGFyZW50Iik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwb2x5bGluZS5zZXRBdHRyaWJ1dGUoImZpbGwiLCAidHJhbnNwYXJlbnQiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NyZWF0ZVBvcHVwKHBvbHlsaW5lLCBkYXRhKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN2Zy5hcHBlbmQocG9seWxpbmUpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGFpbmVyLmFwcGVuZChzdmcpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5jb250YWluZXI7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY2xhc3MgSGlnaGxpZ2h0QW5ub3RhdGlvbkVsZW1lbnQgZXh0ZW5kcyBBbm5vdGF0aW9uRWxlbWVudCB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IocGFyYW1ldGVycykgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3BhcmFtZXRlcnMkZGF0YSR0aXRsOSwgX3BhcmFtZXRlcnMkZGF0YSRjb250OSwgX3BhcmFtZXRlcnMkZGF0YSRyaWNoOTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaXNSZW5kZXJhYmxlID0gISEocGFyYW1ldGVycy5kYXRhLmhhc1BvcHVwIHx8IChfcGFyYW1ldGVycyRkYXRhJHRpdGw5ID0gcGFyYW1ldGVycy5kYXRhLnRpdGxlT2JqKSAhPT0gbnVsbCAmJiBfcGFyYW1ldGVycyRkYXRhJHRpdGw5ICE9PSB2b2lkIDAgJiYgX3BhcmFtZXRlcnMkZGF0YSR0aXRsOS5zdHIgfHwgKF9wYXJhbWV0ZXJzJGRhdGEkY29udDkgPSBwYXJhbWV0ZXJzLmRhdGEuY29udGVudHNPYmopICE9PSBudWxsICYmIF9wYXJhbWV0ZXJzJGRhdGEkY29udDkgIT09IHZvaWQgMCAmJiBfcGFyYW1ldGVycyRkYXRhJGNvbnQ5LnN0ciB8fCAoX3BhcmFtZXRlcnMkZGF0YSRyaWNoOSA9IHBhcmFtZXRlcnMuZGF0YS5yaWNoVGV4dCkgIT09IG51bGwgJiYgX3BhcmFtZXRlcnMkZGF0YSRyaWNoOSAhPT0gdm9pZCAwICYmIF9wYXJhbWV0ZXJzJGRhdGEkcmljaDkuc3RyKTsKICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIocGFyYW1ldGVycywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNSZW5kZXJhYmxlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWdub3JlQm9yZGVyOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3JlYXRlUXVhZHJpbGF0ZXJhbHM6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlbmRlcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLmRhdGEuaGFzUG9wdXApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NyZWF0ZVBvcHVwKG51bGwsIHRoaXMuZGF0YSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMucXVhZHJpbGF0ZXJhbHMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9yZW5kZXJRdWFkcmlsYXRlcmFscygiaGlnaGxpZ2h0QW5ub3RhdGlvbiIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGFpbmVyLmNsYXNzTGlzdC5hZGQoImhpZ2hsaWdodEFubm90YXRpb24iKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuY29udGFpbmVyOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNsYXNzIFVuZGVybGluZUFubm90YXRpb25FbGVtZW50IGV4dGVuZHMgQW5ub3RhdGlvbkVsZW1lbnQgewogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKHBhcmFtZXRlcnMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF9wYXJhbWV0ZXJzJGRhdGEkdGl0bDEwLCBfcGFyYW1ldGVycyRkYXRhJGNvbnQxMCwgX3BhcmFtZXRlcnMkZGF0YSRyaWNoMTA7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGlzUmVuZGVyYWJsZSA9ICEhKHBhcmFtZXRlcnMuZGF0YS5oYXNQb3B1cCB8fCAoX3BhcmFtZXRlcnMkZGF0YSR0aXRsMTAgPSBwYXJhbWV0ZXJzLmRhdGEudGl0bGVPYmopICE9PSBudWxsICYmIF9wYXJhbWV0ZXJzJGRhdGEkdGl0bDEwICE9PSB2b2lkIDAgJiYgX3BhcmFtZXRlcnMkZGF0YSR0aXRsMTAuc3RyIHx8IChfcGFyYW1ldGVycyRkYXRhJGNvbnQxMCA9IHBhcmFtZXRlcnMuZGF0YS5jb250ZW50c09iaikgIT09IG51bGwgJiYgX3BhcmFtZXRlcnMkZGF0YSRjb250MTAgIT09IHZvaWQgMCAmJiBfcGFyYW1ldGVycyRkYXRhJGNvbnQxMC5zdHIgfHwgKF9wYXJhbWV0ZXJzJGRhdGEkcmljaDEwID0gcGFyYW1ldGVycy5kYXRhLnJpY2hUZXh0KSAhPT0gbnVsbCAmJiBfcGFyYW1ldGVycyRkYXRhJHJpY2gxMCAhPT0gdm9pZCAwICYmIF9wYXJhbWV0ZXJzJGRhdGEkcmljaDEwLnN0cik7CiAgICAgICAgICAgICAgICAgICAgICAgIHN1cGVyKHBhcmFtZXRlcnMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlzUmVuZGVyYWJsZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlnbm9yZUJvcmRlcjogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNyZWF0ZVF1YWRyaWxhdGVyYWxzOiB0cnVlCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZW5kZXIoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5kYXRhLmhhc1BvcHVwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jcmVhdGVQb3B1cChudWxsLCB0aGlzLmRhdGEpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLnF1YWRyaWxhdGVyYWxzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fcmVuZGVyUXVhZHJpbGF0ZXJhbHMoInVuZGVybGluZUFubm90YXRpb24iKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRhaW5lci5jbGFzc0xpc3QuYWRkKCJ1bmRlcmxpbmVBbm5vdGF0aW9uIik7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLmNvbnRhaW5lcjsKICAgIC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gICAgICAgICAgICAgICAgICAgICAgIGlnbm9yZUJvcmRlcjogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNyZWF0ZVF1YWRyaWxhdGVyYWxzOiB0cnVlCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZW5kZXIoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5kYXRhLmhhc1BvcHVwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jcmVhdGVQb3B1cChudWxsLCB0aGlzLmRhdGEpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLnF1YWRyaWxhdGVyYWxzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fcmVuZGVyUXVhZHJpbGF0ZXJhbHMoInNxdWlnZ2x5QW5ub3RhdGlvbiIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGFpbmVyLmNsYXNzTGlzdC5hZGQoInNxdWlnZ2x5QW5ub3RhdGlvbiIpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5jb250YWluZXI7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY2xhc3MgU3RyaWtlT3V0QW5ub3RhdGlvbkVsZW1lbnQgZXh0ZW5kcyBBbm5vdGF0aW9uRWxlbWVudCB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IocGFyYW1ldGVycykgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3BhcmFtZXRlcnMkZGF0YSR0aXRsMTIsIF9wYXJhbWV0ZXJzJGRhdGEkY29udDEyLCBfcGFyYW1ldGVycyRkYXRhJHJpY2gxMjsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaXNSZW5kZXJhYmxlID0gISEocGFyYW1ldGVycy5kYXRhLmhhc1BvcHVwIHx8IChfcGFyYW1ldGVycyRkYXRhJHRpdGwxMiA9IHBhcmFtZXRlcnMuZGF0YS50aXRsZU9iaikgIT09IG51bGwgJiYgX3BhcmFtZXRlcnMkZGF0YSR0aXRsMTIgIT09IHZvaWQgMCAmJiBfcGFyYW1ldGVycyRkYXRhJHRpdGwxMi5zdHIgfHwgKF9wYXJhbWV0ZXJzJGRhdGEkY29udDEyID0gcGFyYW1ldGVycy5kYXRhLmNvbnRlbnRzT2JqKSAhPT0gbnVsbCAmJiBfcGFyYW1ldGVycyRkYXRhJGNvbnQxMiAhPT0gdm9pZCAwICYmIF9wYXJhbWV0ZXJzJGRhdGEkY29udDEyLnN0ciB8fCAoX3BhcmFtZXRlcnMkZGF0YSRyaWNoMTIgPSBwYXJhbWV0ZXJzLmRhdGEucmljaFRleHQpICE9PSBudWxsICYmIF9wYXJhbWV0ZXJzJGRhdGEkcmljaDEyICE9PSB2b2lkIDAgJiYgX3BhcmFtZXRlcnMkZGF0YSRyaWNoMTIuc3RyKTsKICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIocGFyYW1ldGVycywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNSZW5kZXJhYmxlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWdub3JlQm9yZGVyOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3JlYXRlUXVhZHJpbGF0ZXJhbHM6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlbmRlcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLmRhdGEuaGFzUG9wdXApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NyZWF0ZVBvcHVwKG51bGwsIHRoaXMuZGF0YSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMucXVhZHJpbGF0ZXJhbHMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9yZW5kZXJRdWFkcmlsYXRlcmFscygic3RyaWtlb3V0QW5ub3RhdGlvbiIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGFpbmVyLmNsYXNzTGlzdC5hZGQoInN0cmlrZW91dEFubm90YXRpb24iKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuY29udGFpbmVyOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNsYXNzIFN0YW1wQW5ub3RhdGlvbkVsZW1lbnQgZXh0ZW5kcyBBbm5vdGF0aW9uRWxlbWVudCB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IocGFyYW1ldGVycykgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3BhcmFtZXRlcnMkZGF0YSR0aXRsMTMsIF9wYXJhbWV0ZXJzJGRhdGEkY29udDEzLCBfcGFyYW1ldGVycyRkYXRhJHJpY2gxMzsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaXNSZW5kZXJhYmxlID0gISEocGFyYW1ldGVycy5kYXRhLmhhc1BvcHVwIHx8IChfcGFyYW1ldGVycyRkYXRhJHRpdGwxMyA9IHBhcmFtZXRlcnMuZGF0YS50aXRsZU9iaikgIT09IG51bGwgJiYgX3BhcmFtZXRlcnMkZGF0YSR0aXRsMTMgIT09IHZvaWQgMCAmJiBfcGFyYW1ldGVycyRkYXRhJHRpdGwxMy5zdHIgfHwgKF9wYXJhbWV0ZXJzJGRhdGEkY29udDEzID0gcGFyYW1ldGVycy5kYXRhLmNvbnRlbnRzT2JqKSAhPT0gbnVsbCAmJiBfcGFyYW1ldGVycyRkYXRhJGNvbnQxMyAhPT0gdm9pZCAwICYmIF9wYXJhbWV0ZXJzJGRhdGEkY29udDEzLnN0ciB8fCAoX3BhcmFtZXRlcnMkZGF0YSRyaWNoMTMgPSBwYXJhbWV0ZXJzLmRhdGEucmljaFRleHQpICE9PSBudWxsICYmIF9wYXJhbWV0ZXJzJGRhdGEkcmljaDEzICE9PSB2b2lkIDAgJiYgX3BhcmFtZXRlcnMkZGF0YSRyaWNoMTMuc3RyKTsKICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIocGFyYW1ldGVycywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNSZW5kZXJhYmxlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWdub3JlQm9yZGVyOiB0cnVlCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZW5kZXIoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGFpbmVyLmNsYXNzTGlzdC5hZGQoInN0YW1wQW5ub3RhdGlvbiIpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuZGF0YS5oYXNQb3B1cCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fY3JlYXRlUG9wdXAobnVsbCwgdGhpcy5kYXRhKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5jb250YWluZXI7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY2xhc3MgRmlsZUF0dGFjaG1lbnRBbm5vdGF0aW9uRWxlbWVudCBleHRlbmRzIEFubm90YXRpb25FbGVtZW50IHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcihwYXJhbWV0ZXJzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRsaW5rU2VydmljZSRldmUxMDsKICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIocGFyYW1ldGVycywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNSZW5kZXJhYmxlOiB0cnVlCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmaWxlbmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRlbnQKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IHRoaXMuZGF0YS5maWxlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmZpbGVuYW1lID0gKDAsIF9kaXNwbGF5X3V0aWxzLmdldEZpbGVuYW1lRnJvbVVybCkoZmlsZW5hbWUsIHRydWUpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRlbnQgPSBjb250ZW50OwogICAgICAgICAgICAgICAgICAgICAgICAoX3RoaXMkbGlua1NlcnZpY2UkZXZlMTAgPSB0aGlzLmxpbmtTZXJ2aWNlLmV2ZW50QnVzKSA9PT0gbnVsbCB8fCBfdGhpcyRsaW5rU2VydmljZSRldmUxMCA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3RoaXMkbGlua1NlcnZpY2UkZXZlMTAuZGlzcGF0Y2goImZpbGVhdHRhY2htZW50YW5ub3RhdGlvbiIsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNvdXJjZTogdGhpcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZpbGVuYW1lLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGVudAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmVuZGVyKCkgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkZGF0YSR0aXRsZU9iaiwgX3RoaXMkZGF0YSRjb250ZW50c09iOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRhaW5lci5jbGFzc0xpc3QuYWRkKCJmaWxlQXR0YWNobWVudEFubm90YXRpb24iKTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHRyaWdnZXI7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmRhdGEuaGFzQXBwZWFyYW5jZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJpZ2dlciA9IGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoImRpdiIpOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJpZ2dlciA9IGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoImltZyIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJpZ2dlci5zcmMgPSBgJHt0aGlzLmltYWdlUmVzb3VyY2VzUGF0aH1hbm5vdGF0aW9uLSR7L3BhcGVyY2xpcC9pLnRlc3QodGhpcy5kYXRhLm5hbWUpID8gInBhcGVyY2xpcCIgOiAicHVzaHBpbiJ9LnN2Z2A7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdHJpZ2dlci5jbGFzc0xpc3QuYWRkKCJwb3B1cFRyaWdnZXJBcmVhIik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRyaWdnZXIuYWRkRXZlbnRMaXN0ZW5lcigiZGJsY2xpY2siLCB0aGlzLl9kb3dubG9hZC5iaW5kKHRoaXMpKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLmRhdGEuaGFzUG9wdXAgJiYgKChfdGhpcyRkYXRhJHRpdGxlT2JqID0gdGhpcy5kYXRhLnRpdGxlT2JqKSAhPT0gbnVsbCAmJiBfdGhpcyRkYXRhJHRpdGxlT2JqICE9PSB2b2lkIDAgJiYgX3RoaXMkZGF0YSR0aXRsZU9iai5zdHIgfHwgKF90aGlzJGRhdGEkY29udGVudHNPYiA9IHRoaXMuZGF0YS5jb250ZW50c09iaikgIT09IG51bGwgJiYgX3RoaXMkZGF0YSRjb250ZW50c09iICE9PSB2b2lkIDAgJiYgX3RoaXMkZGF0YSRjb250ZW50c09iLnN0ciB8fCB0aGlzLmRhdGEucmljaFRleHQpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jcmVhdGVQb3B1cCh0cmlnZ2VyLCB0aGlzLmRhdGEpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGFpbmVyLmFwcGVuZCh0cmlnZ2VyKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuY29udGFpbmVyOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfZG93bmxvYWQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRkb3dubG9hZE1hbmFnZXIyOwogICAgICAgICAgICAgICAgICAgICAgICAoX3RoaXMkZG93bmxvYWRNYW5hZ2VyMiA9IHRoaXMuZG93bmxvYWRNYW5hZ2VyKSA9PT0gbnVsbCB8fCBfdGhpcyRkb3dubG9hZE1hbmFnZXIyID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRkb3dubG9hZE1hbmFnZXIyLm9wZW5PckRvd25sb2FkRGF0YSh0aGlzLmNvbnRhaW5lciwgdGhpcy5jb250ZW50LCB0aGlzLmZpbGVuYW1lKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBBbm5vdGF0aW9uTGF5ZXIgewogICAgICAgICAgICAgICAgICAgIHN0YXRpYyByZW5kZXIocGFyYW1zKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFubm90YXRpb25zLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGl2LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmlld3BvcnQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhY2Nlc3NpYmlsaXR5TWFuYWdlcgogICAgICAgICAgICAgICAgICAgICAgICB9ID0gcGFyYW1zOwogICAgICAgICAgICAgICAgICAgICAgICAoMCwgX2Rpc3BsYXlfdXRpbHMuc2V0TGF5ZXJEaW1lbnNpb25zKShkaXYsIHZpZXdwb3J0KTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZWxlbWVudFBhcmFtcyA9IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRhdGE6IG51bGwsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsYXllcjogZGl2LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFnZTogcGFyYW1zLnBhZ2UsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2aWV3cG9ydCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxpbmtTZXJ2aWNlOiBwYXJhbXMubGlua1NlcnZpY2UsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkb3dubG9hZE1hbmFnZXI6IHBhcmFtcy5kb3dubG9hZE1hbmFnZXIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbWFnZVJlc291cmNlc1BhdGg6IHBhcmFtcy5pbWFnZVJlc291cmNlc1BhdGggfHwgIiIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZW5kZXJGb3JtczogcGFyYW1zLnJlbmRlckZvcm1zICE9PSBmYWxzZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN2Z0ZhY3Rvcnk6IG5ldyBfZGlzcGxheV91dGlscy5ET01TVkdGYWN0b3J5KCksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhbm5vdGF0aW9uU3RvcmFnZTogcGFyYW1zLmFubm90YXRpb25TdG9yYWdlIHx8IG5ldyBfYW5ub3RhdGlvbl9zdG9yYWdlLkFubm90YXRpb25TdG9yYWdlKCksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbmFibGVTY3JpcHRpbmc6IHBhcmFtcy5lbmFibGVTY3JpcHRpbmcgPT09IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoYXNKU0FjdGlvbnM6IHBhcmFtcy5oYXNKU0FjdGlvbnMsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmaWVsZE9iamVjdHM6IHBhcmFtcy5maWVsZE9iamVjdHMKICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHpJbmRleCA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgZGF0YSBvZiBhbm5vdGF0aW9ucykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGRhdGEubm9IVE1MKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZGF0YS5hbm5vdGF0aW9uVHlwZSAhPT0gX3V0aWwuQW5ub3RhdGlvblR5cGUuUE9QVVApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdpZHRoLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBoZWlnaHQKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9ID0gZ2V0UmVjdERpbXMoZGF0YS5yZWN0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAod2lkdGggPD0gMCB8fCBoZWlnaHQgPD0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50UGFyYW1zLmRhdGEgPSBkYXRhOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZWxlbWVudCA9IEFubm90YXRpb25FbGVtZW50RmFjdG9yeS5jcmVhdGUoZWxlbWVudFBhcmFtcyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWVsZW1lbnQuaXNSZW5kZXJhYmxlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByZW5kZXJlZCA9IGVsZW1lbnQucmVuZGVyKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZGF0YS5oaWRkZW4pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZW5kZXJlZC5zdHlsZS52aXNpYmlsaXR5ID0gImhpZGRlbiI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoQXJyYXkuaXNBcnJheShyZW5kZXJlZCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IHJlbmRlcmVkRWxlbWVudCBvZiByZW5kZXJlZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZW5kZXJlZEVsZW1lbnQuc3R5bGUuekluZGV4ID0gekluZGV4Kys7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1N0YXRpY1ByaXZhdGVNZXRob2RHZXQoQW5ub3RhdGlvbkxheWVyLCBBbm5vdGF0aW9uTGF5ZXIsIF9hcHBlbmRFbGVtZW50KS5jYWxsKEFubm90YXRpb25MYXllciwgcmVuZGVyZWRFbGVtZW50LCBkYXRhLmlkLCBkaXYsIGFjY2Vzc2liaWxpdHlNYW5hZ2VyKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlbmRlcmVkLnN0eWxlLnpJbmRleCA9IHpJbmRleCsrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChlbGVtZW50IGluc3RhbmNlb2YgUG9wdXBBbm5vdGF0aW9uRWxlbWVudCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkaXYucHJlcGVuZChyZW5kZXJlZCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzU3RhdGljUHJpdmF0ZU1ldGhvZEdldChBbm5vdGF0aW9uTGF5ZXIsIEFubm90YXRpb25MYXllciwgX2FwcGVuZEVsZW1lbnQpLmNhbGwoQW5ub3RhdGlvbkxheWVyLCByZW5kZXJlZCwgZGF0YS5pZCwgZGl2LCBhY2Nlc3NpYmlsaXR5TWFuYWdlcik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1N0YXRpY1ByaXZhdGVNZXRob2RHZXQodGhpcywgQW5ub3RhdGlvbkxheWVyLCBfc2V0QW5ub3RhdGlvbkNhbnZhc01hcCkuY2FsbCh0aGlzLCBkaXYsIHBhcmFtcy5hbm5vdGF0aW9uQ2FudmFzTWFwKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIHVwZGF0ZShwYXJhbXMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgYW5ub3RhdGlvbkNhbnZhc01hcCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRpdiwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZpZXdwb3J0CiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBwYXJhbXM7CiAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfZGlzcGxheV91dGlscy5zZXRMYXllckRpbWVuc2lvbnMpKGRpdiwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcm90YXRpb246IHZpZXdwb3J0LnJvdGF0aW9uCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NTdGF0aWNQcml2YXRlTWV0aG9kR2V0KHRoaXMsIEFubm90YXRpb25MYXllciwgX3NldEFubm90YXRpb25DYW52YXNNYXApLmNhbGwodGhpcywgZGl2LCBhbm5vdGF0aW9uQ2FudmFzTWFwKTsKICAgICAgICAgICAgICAgICAgICAgICAgZGl2LmhpZGRlbiA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGV4cG9ydHMuQW5ub3RhdGlvbkxheWVyID0gQW5ub3RhdGlvbkxheWVyOwogICAgICAgICAgICAgICAgZnVuY3Rpb24gX2FwcGVuZEVsZW1lbnQoZWxlbWVudCwgaWQsIGRpdiwgYWNjZXNzaWJpbGl0eU1hbmFnZXIpIHsKICAgICAgICAgICAgICAgICAgICBjb25zdCBjb250ZW50RWxlbWVudCA9IGVsZW1lbnQuZmlyc3RDaGlsZCB8fCBlbGVtZW50OwogICAgICAgICAgICAgICAgICAgIGNvbnRlbnRFbGVtZW50LmlkID0gYCR7X2Rpc3BsYXlfdXRpbHMuQW5ub3RhdGlvblByZWZpeH0ke2lkfWA7CiAgICAgICAgICAgICAgICAgICAgZGl2LmFwcGVuZChlbGVtZW50KTsKICAgICAgICAgICAgICAgICAgICBhY2Nlc3NpYmlsaXR5TWFuYWdlciA9PT0gbnVsbCB8fCBhY2Nlc3NpYmlsaXR5TWFuYWdlciA9PT0gdm9pZCAwID8gdm9pZCAwIDogYWNjZXNzaWJpbGl0eU1hbmFnZXIubW92ZUVsZW1lbnRJbkRPTShkaXYsIGVsZW1lbnQsIGNvbnRlbnRFbGVtZW50LCBmYWxzZSk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfc2V0QW5ub3RhdGlvbkNhbnZhc01hcChkaXYsIGFubm90YXRpb25DYW52YXNNYXApIHsKICAgICAgICAgICAgICAgICAgICBpZiAoIWFubm90YXRpb25DYW52YXNNYXApIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IFtpZCwgY2FudmFzXSBvZiBhbm5vdGF0aW9uQ2FudmFzTWFwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGVsZW1lbnQgPSBkaXYucXVlcnlTZWxlY3RvcihgW2RhdGEtYW5ub3RhdGlvbi1pZD0iJHtpZH0iXWApOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWVsZW1lbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZpcnN0Q2hpbGQKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IGVsZW1lbnQ7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghZmlyc3RDaGlsZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5hcHBlbmQoY2FudmFzKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChmaXJzdENoaWxkLm5vZGVOYW1lID09PSAiQ0FOVkFTIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZmlyc3RDaGlsZC5yZXBsYWNlV2l0aChjYW52YXMpOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZmlyc3RDaGlsZC5iZWZvcmUoY2FudmFzKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBhbm5vdGF0aW9uQ2FudmFzTWFwLmNsZWFyKCk7CiAgICAgICAgICAgICAgICB9CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDE2OCAqLwogICAgICAgICAgICAvKioqLyAoKF9fdW51c2VkX3dlYnBhY2tfbW9kdWxlLCBleHBvcnRzKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKCiAgICAgICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIl9fZXNNb2R1bGUiLCAoewogICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0cnVlCiAgICAgICAgICAgICAgICB9KSk7CiAgICAgICAgICAgICAgICBleHBvcnRzLkNvbG9yQ29udmVydGVycyA9IHZvaWQgMDsKICAgICAgICAgICAgICAgIGZ1bmN0aW9uIG1ha2VDb2xvckNvbXAobikgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBNYXRoLmZsb29yKE1hdGgubWF4KDAsIE1hdGgubWluKDEsIG4pKSAqIDI1NSkudG9TdHJpbmcoMTYpLnBhZFN0YXJ0KDIsICIwIik7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBDb2xvckNvbnZlcnRlcnMgewogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBDTVlLX0coX3JlZikgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgW2MsIHksIG0sIGtdID0gX3JlZjsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFsiRyIsIDEgLSBNYXRoLm1pbigxLCAwLjMgKiBjICsgMC41OSAqIG0gKyAwLjExICogeSArIGspXTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIEdfQ01ZSyhfcmVmMikgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgW2ddID0gX3JlZjI7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbIkNNWUsiLCAwLCAwLCAwLCAxIC0gZ107CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBHX1JHQihfcmVmMykgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgW2ddID0gX3JlZjM7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbIlJHQiIsIGcsIGcsIGddOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzdGF0aWMgR19IVE1MKF9yZWY0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBbZ10gPSBfcmVmNDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgRyA9IG1ha2VDb2xvckNvbXAoZyk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBgIyR7R30ke0d9JHtHfWA7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBSR0JfRyhfcmVmNSkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgW3IsIGcsIGJdID0gX3JlZjU7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbIkciLCAwLjMgKiByICsgMC41OSAqIGcgKyAwLjExICogYl07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBSR0JfSFRNTChfcmVmNikgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgW3IsIGcsIGJdID0gX3JlZjY7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IFIgPSBtYWtlQ29sb3JDb21wKHIpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBHID0gbWFrZUNvbG9yQ29tcChnKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgQiA9IG1ha2VDb2xvckNvbXAoYik7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBgIyR7Un0ke0d9JHtCfWA7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBUX0hUTUwoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAiIzAwMDAwMDAwIjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIENNWUtfUkdCKF9yZWY3KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBbYywgeSwgbSwga10gPSBfcmVmNzsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFsiUkdCIiwgMSAtIE1hdGgubWluKDEsIGMgKyBrKSwgMSAtIE1hdGgubWluKDEsIG0gKyBrKSwgMSAtIE1hdGgubWluKDEsIHkgKyBrKV07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBDTVlLX0hUTUwoY29tcG9uZW50cykgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByZ2IgPSB0aGlzLkNNWUtfUkdCKGNvbXBvbmVudHMpLnNsaWNlKDEpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5SR0JfSFRNTChyZ2IpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzdGF0aWMgUkdCX0NNWUsoX3JlZjgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IFtyLCBnLCBiXSA9IF9yZWY4OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjID0gMSAtIHI7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG0gPSAxIC0gZzsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgeSA9IDEgLSBiOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBrID0gTWF0aC5taW4oYywgbSwgeSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbIkNNWUsiLCBjLCBtLCB5LCBrXTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLkNvbG9yQ29udmVydGVycyA9IENvbG9yQ29udmVydGVyczsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTY5ICovCiAgICAgICAgICAgIC8qKiovICgoX191bnVzZWRfd2VicGFja19tb2R1bGUsIGV4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICAidXNlIHN0cmljdCI7CgoKICAgICAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAiX19lc01vZHVsZSIsICh7CiAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRydWUKICAgICAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuWGZhTGF5ZXIgPSB2b2lkIDA7CiAgICAgICAgICAgICAgICB2YXIgX3hmYV90ZXh0ID0gX193X3BkZmpzX3JlcXVpcmVfXygxNTQpOwogICAgICAgICAgICAgICAgY2xhc3MgWGZhTGF5ZXIgewogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBzZXR1cFN0b3JhZ2UoaHRtbCwgaWQsIGVsZW1lbnQsIHN0b3JhZ2UsIGludGVudCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzdG9yZWREYXRhID0gc3RvcmFnZS5nZXRWYWx1ZShpZCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IG51bGwKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHN3aXRjaCAoZWxlbWVudC5uYW1lKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJ0ZXh0YXJlYSI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHN0b3JlZERhdGEudmFsdWUgIT09IG51bGwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaHRtbC50ZXh0Q29udGVudCA9IHN0b3JlZERhdGEudmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpbnRlbnQgPT09ICJwcmludCIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGh0bWwuYWRkRXZlbnRMaXN0ZW5lcigiaW5wdXQiLCBldmVudCA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0b3JhZ2Uuc2V0VmFsdWUoaWQsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBldmVudC50YXJnZXQudmFsdWUKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJpbnB1dCI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGVsZW1lbnQuYXR0cmlidXRlcy50eXBlID09PSAicmFkaW8iIHx8IGVsZW1lbnQuYXR0cmlidXRlcy50eXBlID09PSAiY2hlY2tib3giKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChzdG9yZWREYXRhLnZhbHVlID09PSBlbGVtZW50LmF0dHJpYnV0ZXMueGZhT24pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGh0bWwuc2V0QXR0cmlidXRlKCJjaGVja2VkIiwgdHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoc3RvcmVkRGF0YS52YWx1ZSA9PT0gZWxlbWVudC5hdHRyaWJ1dGVzLnhmYU9mZikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaHRtbC5yZW1vdmVBdHRyaWJ1dGUoImNoZWNrZWQiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoaW50ZW50ID09PSAicHJpbnQiKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBodG1sLmFkZEV2ZW50TGlzdGVuZXIoImNoYW5nZSIsIGV2ZW50ID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0b3JhZ2Uuc2V0VmFsdWUoaWQsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogZXZlbnQudGFyZ2V0LmNoZWNrZWQgPyBldmVudC50YXJnZXQuZ2V0QXR0cmlidXRlKCJ4ZmFPbiIpIDogZXZlbnQudGFyZ2V0LmdldEF0dHJpYnV0ZSgieGZhT2ZmIikKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoc3RvcmVkRGF0YS52YWx1ZSAhPT0gbnVsbCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaHRtbC5zZXRBdHRyaWJ1dGUoInZhbHVlIiwgc3RvcmVkRGF0YS52YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGludGVudCA9PT0gInByaW50IikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaHRtbC5hZGRFdmVudExpc3RlbmVyKCJpbnB1dCIsIGV2ZW50ID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0b3JhZ2Uuc2V0VmFsdWUoaWQsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogZXZlbnQudGFyZ2V0LnZhbHVlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAic2VsZWN0IjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoc3RvcmVkRGF0YS52YWx1ZSAhPT0gbnVsbCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IG9wdGlvbiBvZiBlbGVtZW50LmNoaWxkcmVuKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAob3B0aW9uLmF0dHJpYnV0ZXMudmFsdWUgPT09IHN0b3JlZERhdGEudmFsdWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvcHRpb24uYXR0cmlidXRlcy5zZWxlY3RlZCA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaHRtbC5hZGRFdmVudExpc3RlbmVyKCJpbnB1dCIsIGV2ZW50ID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgb3B0aW9ucyA9IGV2ZW50LnRhcmdldC5vcHRpb25zOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB2YWx1ZSA9IG9wdGlvbnMuc2VsZWN0ZWRJbmRleCA9PT0gLTEgPyAiIiA6IG9wdGlvbnNbb3B0aW9ucy5zZWxlY3RlZEluZGV4XS52YWx1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RvcmFnZS5zZXRWYWx1ZShpZCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWUKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIHNldEF0dHJpYnV0ZXMoX3JlZikgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaHRtbCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1lbnQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdG9yYWdlID0gbnVsbCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludGVudCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxpbmtTZXJ2aWNlCiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBfcmVmOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhdHRyaWJ1dGVzCiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBlbGVtZW50OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpc0hUTUxBbmNob3JFbGVtZW50ID0gaHRtbCBpbnN0YW5jZW9mIEhUTUxBbmNob3JFbGVtZW50OwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoYXR0cmlidXRlcy50eXBlID09PSAicmFkaW8iKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhdHRyaWJ1dGVzLm5hbWUgPSBgJHthdHRyaWJ1dGVzLm5hbWV9LSR7aW50ZW50fWA7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBba2V5LCB2YWx1ZV0gb2YgT2JqZWN0LmVudHJpZXMoYXR0cmlidXRlcykpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh2YWx1ZSA9PT0gbnVsbCB8fCB2YWx1ZSA9PT0gdW5kZWZpbmVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzd2l0Y2ggKGtleSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgImNsYXNzIjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHZhbHVlLmxlbmd0aCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaHRtbC5zZXRBdHRyaWJ1dGUoa2V5LCB2YWx1ZS5qb2luKCIgIikpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgImRhdGFJZCI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgImlkIjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaHRtbC5zZXRBdHRyaWJ1dGUoImRhdGEtZWxlbWVudC1pZCIsIHZhbHVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAic3R5bGUiOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBPYmplY3QuYXNzaWduKGh0bWwuc3R5bGUsIHZhbHVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAidGV4dENvbnRlbnQiOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBodG1sLnRleHRDb250ZW50ID0gdmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghaXNIVE1MQW5jaG9yRWxlbWVudCB8fCBrZXkgIT09ICJocmVmIiAmJiBrZXkgIT09ICJuZXdXaW5kb3ciKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBodG1sLnNldEF0dHJpYnV0ZShrZXksIHZhbHVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpc0hUTUxBbmNob3JFbGVtZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsaW5rU2VydmljZS5hZGRMaW5rQXR0cmlidXRlcyhodG1sLCBhdHRyaWJ1dGVzLmhyZWYsIGF0dHJpYnV0ZXMubmV3V2luZG93KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAoc3RvcmFnZSAmJiBhdHRyaWJ1dGVzLmRhdGFJZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXR1cFN0b3JhZ2UoaHRtbCwgYXR0cmlidXRlcy5kYXRhSWQsIGVsZW1lbnQsIHN0b3JhZ2UpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyByZW5kZXIocGFyYW1ldGVycykgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzdG9yYWdlID0gcGFyYW1ldGVycy5hbm5vdGF0aW9uU3RvcmFnZTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbGlua1NlcnZpY2UgPSBwYXJhbWV0ZXJzLmxpbmtTZXJ2aWNlOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByb290ID0gcGFyYW1ldGVycy54ZmFIdG1sOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpbnRlbnQgPSBwYXJhbWV0ZXJzLmludGVudCB8fCAiZGlzcGxheSI7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHJvb3RIdG1sID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudChyb290Lm5hbWUpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAocm9vdC5hdHRyaWJ1dGVzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNldEF0dHJpYnV0ZXMoewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGh0bWw6IHJvb3RIdG1sLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1lbnQ6IHJvb3QsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50ZW50LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxpbmtTZXJ2aWNlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzdGFjayA9IFtbcm9vdCwgLTEsIHJvb3RIdG1sXV07CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHJvb3REaXYgPSBwYXJhbWV0ZXJzLmRpdjsKICAgICAgICAgICAgICAgICAgICAgICAgcm9vdERpdi5hcHBlbmQocm9vdEh0bWwpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAocGFyYW1ldGVycy52aWV3cG9ydCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdHJhbnNmb3JtID0gYG1hdHJpeCgke3BhcmFtZXRlcnMudmlld3BvcnQudHJhbnNmb3JtLmpvaW4oIiwiKX0pYDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJvb3REaXYuc3R5bGUudHJhbnNmb3JtID0gdHJhbnNmb3JtOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpbnRlbnQgIT09ICJyaWNoVGV4dCIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJvb3REaXYuc2V0QXR0cmlidXRlKCJjbGFzcyIsICJ4ZmFMYXllciB4ZmFGb250Iik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdGV4dERpdnMgPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgd2hpbGUgKHN0YWNrLmxlbmd0aCA+IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfY2hpbGQkYXR0cmlidXRlczsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IFtwYXJlbnQsIGksIGh0bWxdID0gc3RhY2suYXQoLTEpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGkgKyAxID09PSBwYXJlbnQuY2hpbGRyZW4ubGVuZ3RoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RhY2sucG9wKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjaGlsZCA9IHBhcmVudC5jaGlsZHJlblsrK3N0YWNrLmF0KC0xKVsxXV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoY2hpbGQgPT09IG51bGwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBuYW1lCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9ID0gY2hpbGQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAobmFtZSA9PT0gIiN0ZXh0IikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG5vZGUgPSBkb2N1bWVudC5jcmVhdGVUZXh0Tm9kZShjaGlsZC52YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGV4dERpdnMucHVzaChub2RlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBodG1sLmFwcGVuZChub2RlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBjaGlsZEh0bWw7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoY2hpbGQgIT09IG51bGwgJiYgY2hpbGQgIT09IHZvaWQgMCAmJiAoX2NoaWxkJGF0dHJpYnV0ZXMgPSBjaGlsZC5hdHRyaWJ1dGVzKSAhPT0gbnVsbCAmJiBfY2hpbGQkYXR0cmlidXRlcyAhPT0gdm9pZCAwICYmIF9jaGlsZCRhdHRyaWJ1dGVzLnhtbG5zKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2hpbGRIdG1sID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudE5TKGNoaWxkLmF0dHJpYnV0ZXMueG1sbnMsIG5hbWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjaGlsZEh0bWwgPSBkb2N1bWVudC5jcmVhdGVFbGVtZW50KG5hbWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgaHRtbC5hcHBlbmQoY2hpbGRIdG1sKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjaGlsZC5hdHRyaWJ1dGVzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRBdHRyaWJ1dGVzKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaHRtbDogY2hpbGRIdG1sLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50OiBjaGlsZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RvcmFnZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50ZW50LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsaW5rU2VydmljZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGNoaWxkLmNoaWxkcmVuICYmIGNoaWxkLmNoaWxkcmVuLmxlbmd0aCA+IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGFjay5wdXNoKFtjaGlsZCwgLTEsIGNoaWxkSHRtbF0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChjaGlsZC52YWx1ZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG5vZGUgPSBkb2N1bWVudC5jcmVhdGVUZXh0Tm9kZShjaGlsZC52YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKF94ZmFfdGV4dC5YZmFUZXh0LnNob3VsZEJ1aWxkVGV4dChuYW1lKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0ZXh0RGl2cy5wdXNoKG5vZGUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjaGlsZEh0bWwuYXBwZW5kKG5vZGUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgZWwgb2Ygcm9vdERpdi5xdWVyeVNlbGVjdG9yQWxsKCIueGZhTm9uSW50ZXJhY3RpdmUgaW5wdXQsIC54ZmFOb25JbnRlcmFjdGl2ZSB0ZXh0YXJlYSIpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbC5zZXRBdHRyaWJ1dGUoInJlYWRPbmx5IiwgdHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRleHREaXZzCiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyB1cGRhdGUocGFyYW1ldGVycykgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB0cmFuc2Zvcm0gPSBgbWF0cml4KCR7cGFyYW1ldGVycy52aWV3cG9ydC50cmFuc2Zvcm0uam9pbigiLCIpfSlgOwogICAgICAgICAgICAgICAgICAgICAgICBwYXJhbWV0ZXJzLmRpdi5zdHlsZS50cmFuc2Zvcm0gPSB0cmFuc2Zvcm07CiAgICAgICAgICAgICAgICAgICAgICAgIHBhcmFtZXRlcnMuZGl2LmhpZGRlbiA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGV4cG9ydHMuWGZhTGF5ZXIgPSBYZmFMYXllcjsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTcwICovCiAgICAgICAgICAgIC8qKiovICgoX191bnVzZWRfd2VicGFja19tb2R1bGUsIGV4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICAidXNlIHN0cmljdCI7CgoKICAgICAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAiX19lc01vZHVsZSIsICh7CiAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRydWUKICAgICAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuU1ZHR3JhcGhpY3MgPSB2b2lkIDA7CiAgICAgICAgICAgICAgICB2YXIgX2Rpc3BsYXlfdXRpbHMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE0Mik7CiAgICAgICAgICAgICAgICB2YXIgX3V0aWwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEpOwogICAgICAgICAgICAgICAgdmFyIF9pc19ub2RlID0gX193X3BkZmpzX3JlcXVpcmVfXygzKTsKICAgICAgICAgICAgICAgIGxldCBTVkdHcmFwaGljcyA9IGNsYXNzIHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLnVucmVhY2hhYmxlKSgiTm90IGltcGxlbWVudGVkOiBTVkdHcmFwaGljcyIpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBleHBvcnRzLlNWR0dyYXBoaWNzID0gU1ZHR3JhcGhpY3M7CiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgU1ZHX0RFRkFVTFRTID0gewogICAgICAgICAgICAgICAgICAgICAgICBmb250U3R5bGU6ICJub3JtYWwiLAogICAgICAgICAgICAgICAgICAgICAgICBmb250V2VpZ2h0OiAibm9ybWFsIiwKICAgICAgICAgICAgICAgICAgICAgICAgZmlsbENvbG9yOiAiIzAwMDAwMCIKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIGNvbnN0IFhNTF9OUyA9ICJodHRwOi8vd3d3LnczLm9yZy9YTUwvMTk5OC9uYW1lc3BhY2UiOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IFhMSU5LX05TID0gImh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IExJTkVfQ0FQX1NUWUxFUyA9IFsiYnV0dCIsICJyb3VuZCIsICJzcXVhcmUiXTsKICAgICAgICAgICAgICAgICAgICBjb25zdCBMSU5FX0pPSU5fU1RZTEVTID0gWyJtaXRlciIsICJyb3VuZCIsICJiZXZlbCJdOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IGNyZWF0ZU9iamVjdFVSTCA9IGZ1bmN0aW9uIChkYXRhKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBjb250ZW50VHlwZSA9IGFyZ3VtZW50cy5sZW5ndGggPiAxICYmIGFyZ3VtZW50c1sxXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzFdIDogIiI7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBmb3JjZURhdGFTY2hlbWEgPSBhcmd1bWVudHMubGVuZ3RoID4gMiAmJiBhcmd1bWVudHNbMl0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1syXSA6IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoVVJMLmNyZWF0ZU9iamVjdFVSTCAmJiB0eXBlb2YgQmxvYiAhPT0gInVuZGVmaW5lZCIgJiYgIWZvcmNlRGF0YVNjaGVtYSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFVSTC5jcmVhdGVPYmplY3RVUkwobmV3IEJsb2IoW2RhdGFdLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHlwZTogY29udGVudFR5cGUKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBkaWdpdHMgPSAiQUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMjM0NTY3ODkrLz0iOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgYnVmZmVyID0gYGRhdGE6JHtjb250ZW50VHlwZX07YmFzZTY0LGA7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBpaSA9IGRhdGEubGVuZ3RoOyBpIDwgaWk7IGkgKz0gMykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYjEgPSBkYXRhW2ldICYgMHhmZjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGIyID0gZGF0YVtpICsgMV0gJiAweGZmOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYjMgPSBkYXRhW2kgKyAyXSAmIDB4ZmY7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBkMSA9IGIxID4+IDIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZDIgPSAoYjEgJiAzKSA8PCA0IHwgYjIgPj4gNDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGQzID0gaSArIDEgPCBpaSA/IChiMiAmIDB4ZikgPDwgMiB8IGIzID4+IDYgOiA2NDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGQ0ID0gaSArIDIgPCBpaSA/IGIzICYgMHgzZiA6IDY0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgYnVmZmVyICs9IGRpZ2l0c1tkMV0gKyBkaWdpdHNbZDJdICsgZGlnaXRzW2QzXSArIGRpZ2l0c1tkNF07CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGJ1ZmZlcjsKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIGNvbnN0IGNvbnZlcnRJbWdEYXRhVG9QbmcgPSBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IFBOR19IRUFERVIgPSBuZXcgVWludDhBcnJheShbMHg4OSwgMHg1MCwgMHg0ZSwgMHg0NywgMHgwZCwgMHgwYSwgMHgxYSwgMHgwYV0pOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBDSFVOS19XUkFQUEVSX1NJWkUgPSAxMjsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY3JjVGFibGUgPSBuZXcgSW50MzJBcnJheSgyNTYpOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IDI1NjsgaSsrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgYyA9IGk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBoID0gMDsgaCA8IDg7IGgrKykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjICYgMSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjID0gMHhlZGI4ODMyMCBeIGMgPj4gMSAmIDB4N2ZmZmZmZmY7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYyA9IGMgPj4gMSAmIDB4N2ZmZmZmZmY7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3JjVGFibGVbaV0gPSBjOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGNyYzMyKGRhdGEsIHN0YXJ0LCBlbmQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBjcmMgPSAtMTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSBzdGFydDsgaSA8IGVuZDsgaSsrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYSA9IChjcmMgXiBkYXRhW2ldKSAmIDB4ZmY7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYiA9IGNyY1RhYmxlW2FdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNyYyA9IGNyYyA+Pj4gOCBeIGI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gY3JjIF4gLTE7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgZnVuY3Rpb24gd3JpdGVQbmdDaHVuayh0eXBlLCBib2R5LCBkYXRhLCBvZmZzZXQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBwID0gb2Zmc2V0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbGVuID0gYm9keS5sZW5ndGg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkYXRhW3BdID0gbGVuID4+IDI0ICYgMHhmZjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRhdGFbcCArIDFdID0gbGVuID4+IDE2ICYgMHhmZjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRhdGFbcCArIDJdID0gbGVuID4+IDggJiAweGZmOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGF0YVtwICsgM10gPSBsZW4gJiAweGZmOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcCArPSA0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGF0YVtwXSA9IHR5cGUuY2hhckNvZGVBdCgwKSAmIDB4ZmY7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkYXRhW3AgKyAxXSA9IHR5cGUuY2hhckNvZGVBdCgxKSAmIDB4ZmY7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkYXRhW3AgKyAyXSA9IHR5cGUuY2hhckNvZGVBdCgyKSAmIDB4ZmY7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkYXRhW3AgKyAzXSA9IHR5cGUuY2hhckNvZGVBdCgzKSAmIDB4ZmY7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwICs9IDQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkYXRhLnNldChib2R5LCBwKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHAgKz0gYm9keS5sZW5ndGg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjcmMgPSBjcmMzMihkYXRhLCBvZmZzZXQgKyA0LCBwKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRhdGFbcF0gPSBjcmMgPj4gMjQgJiAweGZmOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGF0YVtwICsgMV0gPSBjcmMgPj4gMTYgJiAweGZmOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGF0YVtwICsgMl0gPSBjcmMgPj4gOCAmIDB4ZmY7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkYXRhW3AgKyAzXSA9IGNyYyAmIDB4ZmY7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgZnVuY3Rpb24gYWRsZXIzMihkYXRhLCBzdGFydCwgZW5kKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgYSA9IDE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgYiA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gc3RhcnQ7IGkgPCBlbmQ7ICsraSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGEgPSAoYSArIChkYXRhW2ldICYgMHhmZikpICUgNjU1MjE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYiA9IChiICsgYSkgJSA2NTUyMTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBiIDw8IDE2IHwgYTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBmdW5jdGlvbiBkZWZsYXRlU3luYyhsaXRlcmFscykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFfaXNfbm9kZS5pc05vZGVKUykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBkZWZsYXRlU3luY1VuY29tcHJlc3NlZChsaXRlcmFscyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBpbnB1dDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAocGFyc2VJbnQocHJvY2Vzcy52ZXJzaW9ucy5ub2RlKSA+PSA4KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlucHV0ID0gbGl0ZXJhbHM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW5wdXQgPSBCdWZmZXIuZnJvbShsaXRlcmFscyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG91dHB1dCA9IHJlcXVpcmUoInpsaWIiKS5kZWZsYXRlU3luYyhpbnB1dCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXZlbDogOQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBvdXRwdXQgaW5zdGFuY2VvZiBVaW50OEFycmF5ID8gb3V0cHV0IDogbmV3IFVpbnQ4QXJyYXkob3V0cHV0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoIk5vdCBjb21wcmVzc2luZyBQTkcgYmVjYXVzZSB6bGliLmRlZmxhdGVTeW5jIGlzIHVuYXZhaWxhYmxlOiAiICsgZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZGVmbGF0ZVN5bmNVbmNvbXByZXNzZWQobGl0ZXJhbHMpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGRlZmxhdGVTeW5jVW5jb21wcmVzc2VkKGxpdGVyYWxzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgbGVuID0gbGl0ZXJhbHMubGVuZ3RoOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbWF4QmxvY2tMZW5ndGggPSAweGZmZmY7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBkZWZsYXRlQmxvY2tzID0gTWF0aC5jZWlsKGxlbiAvIG1heEJsb2NrTGVuZ3RoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGlkYXQgPSBuZXcgVWludDhBcnJheSgyICsgbGVuICsgZGVmbGF0ZUJsb2NrcyAqIDUgKyA0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBwaSA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZGF0W3BpKytdID0gMHg3ODsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlkYXRbcGkrK10gPSAweDljOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHBvcyA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3aGlsZSAobGVuID4gbWF4QmxvY2tMZW5ndGgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZGF0W3BpKytdID0gMHgwMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZGF0W3BpKytdID0gMHhmZjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZGF0W3BpKytdID0gMHhmZjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZGF0W3BpKytdID0gMHgwMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZGF0W3BpKytdID0gMHgwMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZGF0LnNldChsaXRlcmFscy5zdWJhcnJheShwb3MsIHBvcyArIG1heEJsb2NrTGVuZ3RoKSwgcGkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBpICs9IG1heEJsb2NrTGVuZ3RoOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBvcyArPSBtYXhCbG9ja0xlbmd0aDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZW4gLT0gbWF4QmxvY2tMZW5ndGg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZGF0W3BpKytdID0gMHgwMTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlkYXRbcGkrK10gPSBsZW4gJiAweGZmOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWRhdFtwaSsrXSA9IGxlbiA+PiA4ICYgMHhmZjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlkYXRbcGkrK10gPSB+bGVuICYgMHhmZmZmICYgMHhmZjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlkYXRbcGkrK10gPSAofmxlbiAmIDB4ZmZmZikgPj4gOCAmIDB4ZmY7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZGF0LnNldChsaXRlcmFscy5zdWJhcnJheShwb3MpLCBwaSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwaSArPSBsaXRlcmFscy5sZW5ndGggLSBwb3M7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBhZGxlciA9IGFkbGVyMzIobGl0ZXJhbHMsIDAsIGxpdGVyYWxzLmxlbmd0aCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZGF0W3BpKytdID0gYWRsZXIgPj4gMjQgJiAweGZmOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWRhdFtwaSsrXSA9IGFkbGVyID4+IDE2ICYgMHhmZjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlkYXRbcGkrK10gPSBhZGxlciA+PiA4ICYgMHhmZjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlkYXRbcGkrK10gPSBhZGxlciAmIDB4ZmY7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gaWRhdDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBmdW5jdGlvbiBlbmNvZGUoaW1nRGF0YSwga2luZCwgZm9yY2VEYXRhU2NoZW1hLCBpc01hc2spIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHdpZHRoID0gaW1nRGF0YS53aWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGhlaWdodCA9IGltZ0RhdGEuaGVpZ2h0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGJpdERlcHRoLCBjb2xvclR5cGUsIGxpbmVTaXplOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYnl0ZXMgPSBpbWdEYXRhLmRhdGE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzd2l0Y2ggKGtpbmQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLkltYWdlS2luZC5HUkFZU0NBTEVfMUJQUDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29sb3JUeXBlID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYml0RGVwdGggPSAxOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsaW5lU2l6ZSA9IHdpZHRoICsgNyA+PiAzOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLkltYWdlS2luZC5SR0JfMjRCUFA6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbG9yVHlwZSA9IDI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJpdERlcHRoID0gODsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGluZVNpemUgPSB3aWR0aCAqIDM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuSW1hZ2VLaW5kLlJHQkFfMzJCUFA6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbG9yVHlwZSA9IDY7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJpdERlcHRoID0gODsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGluZVNpemUgPSB3aWR0aCAqIDQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcigiaW52YWxpZCBmb3JtYXQiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGxpdGVyYWxzID0gbmV3IFVpbnQ4QXJyYXkoKDEgKyBsaW5lU2l6ZSkgKiBoZWlnaHQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IG9mZnNldExpdGVyYWxzID0gMCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvZmZzZXRCeXRlcyA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCB5ID0gMDsgeSA8IGhlaWdodDsgKyt5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGl0ZXJhbHNbb2Zmc2V0TGl0ZXJhbHMrK10gPSAwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxpdGVyYWxzLnNldChieXRlcy5zdWJhcnJheShvZmZzZXRCeXRlcywgb2Zmc2V0Qnl0ZXMgKyBsaW5lU2l6ZSksIG9mZnNldExpdGVyYWxzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvZmZzZXRCeXRlcyArPSBsaW5lU2l6ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvZmZzZXRMaXRlcmFscyArPSBsaW5lU2l6ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChraW5kID09PSBfdXRpbC5JbWFnZUtpbmQuR1JBWVNDQUxFXzFCUFAgJiYgaXNNYXNrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgb2Zmc2V0TGl0ZXJhbHMgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAobGV0IHkgPSAwOyB5IDwgaGVpZ2h0OyB5KyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgb2Zmc2V0TGl0ZXJhbHMrKzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBsaW5lU2l6ZTsgaSsrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsaXRlcmFsc1tvZmZzZXRMaXRlcmFscysrXSBePSAweGZmOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaWhkciA9IG5ldyBVaW50OEFycmF5KFt3aWR0aCA+PiAyNCAmIDB4ZmYsIHdpZHRoID4+IDE2ICYgMHhmZiwgd2lkdGggPj4gOCAmIDB4ZmYsIHdpZHRoICYgMHhmZiwgaGVpZ2h0ID4+IDI0ICYgMHhmZiwgaGVpZ2h0ID4+IDE2ICYgMHhmZiwgaGVpZ2h0ID4+IDggJiAweGZmLCBoZWlnaHQgJiAweGZmLCBiaXREZXB0aCwgY29sb3JUeXBlLCAweDAwLCAweDAwLCAweDAwXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpZGF0ID0gZGVmbGF0ZVN5bmMobGl0ZXJhbHMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcG5nTGVuZ3RoID0gUE5HX0hFQURFUi5sZW5ndGggKyBDSFVOS19XUkFQUEVSX1NJWkUgKiAzICsgaWhkci5sZW5ndGggKyBpZGF0Lmxlbmd0aDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGRhdGEgPSBuZXcgVWludDhBcnJheShwbmdMZW5ndGgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IG9mZnNldCA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkYXRhLnNldChQTkdfSEVBREVSLCBvZmZzZXQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgb2Zmc2V0ICs9IFBOR19IRUFERVIubGVuZ3RoOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGVQbmdDaHVuaygiSUhEUiIsIGloZHIsIGRhdGEsIG9mZnNldCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvZmZzZXQgKz0gQ0hVTktfV1JBUFBFUl9TSVpFICsgaWhkci5sZW5ndGg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0ZVBuZ0NodW5rKCJJREFUQSIsIGlkYXQsIGRhdGEsIG9mZnNldCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvZmZzZXQgKz0gQ0hVTktfV1JBUFBFUl9TSVpFICsgaWRhdC5sZW5ndGg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0ZVBuZ0NodW5rKCJJRU5EIiwgbmV3IFVpbnQ4QXJyYXkoMCksIGRhdGEsIG9mZnNldCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gY3JlYXRlT2JqZWN0VVJMKGRhdGEsICJpbWFnZS9wbmciLCBmb3JjZURhdGFTY2hlbWEpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmdW5jdGlvbiBjb252ZXJ0SW1nRGF0YVRvUG5nKGltZ0RhdGEsIGZvcmNlRGF0YVNjaGVtYSwgaXNNYXNrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBraW5kID0gaW1nRGF0YS5raW5kID09PSB1bmRlZmluZWQgPyBfdXRpbC5JbWFnZUtpbmQuR1JBWVNDQUxFXzFCUFAgOiBpbWdEYXRhLmtpbmQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZW5jb2RlKGltZ0RhdGEsIGtpbmQsIGZvcmNlRGF0YVNjaGVtYSwgaXNNYXNrKTsKICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICB9KCk7CiAgICAgICAgICAgICAgICAgICAgY2xhc3MgU1ZHRXh0cmFTdGF0ZSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5mb250U2l6ZVNjYWxlID0gMTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZm9udFdlaWdodCA9IFNWR19ERUZBVUxUUy5mb250V2VpZ2h0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5mb250U2l6ZSA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnRleHRNYXRyaXggPSBfdXRpbC5JREVOVElUWV9NQVRSSVg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmZvbnRNYXRyaXggPSBfdXRpbC5GT05UX0lERU5USVRZX01BVFJJWDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubGVhZGluZyA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnRleHRSZW5kZXJpbmdNb2RlID0gX3V0aWwuVGV4dFJlbmRlcmluZ01vZGUuRklMTDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudGV4dE1hdHJpeFNjYWxlID0gMTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMueCA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnkgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5saW5lWCA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmxpbmVZID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2hhclNwYWNpbmcgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy53b3JkU3BhY2luZyA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnRleHRIU2NhbGUgPSAxOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy50ZXh0UmlzZSA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmZpbGxDb2xvciA9IFNWR19ERUZBVUxUUy5maWxsQ29sb3I7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnN0cm9rZUNvbG9yID0gIiMwMDAwMDAiOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5maWxsQWxwaGEgPSAxOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zdHJva2VBbHBoYSA9IDE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmxpbmVXaWR0aCA9IDE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmxpbmVKb2luID0gIiI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmxpbmVDYXAgPSAiIjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubWl0ZXJMaW1pdCA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRhc2hBcnJheSA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kYXNoUGhhc2UgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kZXBlbmRlbmNpZXMgPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYWN0aXZlQ2xpcFVybCA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNsaXBHcm91cCA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm1hc2tJZCA9ICIiOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNsb25lKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIE9iamVjdC5jcmVhdGUodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgc2V0Q3VycmVudFBvaW50KHgsIHkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMueCA9IHg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnkgPSB5OwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGZ1bmN0aW9uIG9wTGlzdFRvVHJlZShvcExpc3QpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IG9wVHJlZSA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB0bXAgPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBvcExpc3RFbGVtZW50IG9mIG9wTGlzdCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG9wTGlzdEVsZW1lbnQuZm4gPT09ICJzYXZlIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9wVHJlZS5wdXNoKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm5JZDogOTIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZuOiAiZ3JvdXAiLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpdGVtczogW10KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0bXAucHVzaChvcFRyZWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9wVHJlZSA9IG9wVHJlZS5hdCgtMSkuaXRlbXM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAob3BMaXN0RWxlbWVudC5mbiA9PT0gInJlc3RvcmUiKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgb3BUcmVlID0gdG1wLnBvcCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvcFRyZWUucHVzaChvcExpc3RFbGVtZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gb3BUcmVlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBmdW5jdGlvbiBwZih2YWx1ZSkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoTnVtYmVyLmlzSW50ZWdlcih2YWx1ZSkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB2YWx1ZS50b1N0cmluZygpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHMgPSB2YWx1ZS50b0ZpeGVkKDEwKTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGkgPSBzLmxlbmd0aCAtIDE7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChzW2ldICE9PSAiMCIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBzOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGRvIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGktLTsKICAgICAgICAgICAgICAgICAgICAgICAgfSB3aGlsZSAoc1tpXSA9PT0gIjAiKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHMuc3Vic3RyaW5nKDAsIHNbaV0gPT09ICIuIiA/IGkgOiBpICsgMSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGZ1bmN0aW9uIHBtKG0pIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG1bNF0gPT09IDAgJiYgbVs1XSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG1bMV0gPT09IDAgJiYgbVsyXSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChtWzBdID09PSAxICYmIG1bM10gPT09IDEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICIiOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gYHNjYWxlKCR7cGYobVswXSl9ICR7cGYobVszXSl9KWA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAobVswXSA9PT0gbVszXSAmJiBtWzFdID09PSAtbVsyXSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGEgPSBNYXRoLmFjb3MobVswXSkgKiAxODAgLyBNYXRoLlBJOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBgcm90YXRlKCR7cGYoYSl9KWA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAobVswXSA9PT0gMSAmJiBtWzFdID09PSAwICYmIG1bMl0gPT09IDAgJiYgbVszXSA9PT0gMSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBgdHJhbnNsYXRlKCR7cGYobVs0XSl9ICR7cGYobVs1XSl9KWA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGBtYXRyaXgoJHtwZihtWzBdKX0gJHtwZihtWzFdKX0gJHtwZihtWzJdKX0gJHtwZihtWzNdKX0gJHtwZihtWzRdKX0gYCArIGAke3BmKG1bNV0pfSlgOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBsZXQgY2xpcENvdW50ID0gMDsKICAgICAgICAgICAgICAgICAgICBsZXQgbWFza0NvdW50ID0gMDsKICAgICAgICAgICAgICAgICAgICBsZXQgc2hhZGluZ0NvdW50ID0gMDsKICAgICAgICAgICAgICAgICAgICBleHBvcnRzLlNWR0dyYXBoaWNzID0gU1ZHR3JhcGhpY3MgPSBjbGFzcyB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKGNvbW1vbk9ianMsIG9ianMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBmb3JjZURhdGFTY2hlbWEgPSBhcmd1bWVudHMubGVuZ3RoID4gMiAmJiBhcmd1bWVudHNbMl0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1syXSA6IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF9kaXNwbGF5X3V0aWxzLmRlcHJlY2F0ZWQpKCJUaGUgU1ZHIGJhY2stZW5kIGlzIG5vIGxvbmdlciBtYWludGFpbmVkIGFuZCAqbWF5KiBiZSByZW1vdmVkIGluIHRoZSBmdXR1cmUuIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnN2Z0ZhY3RvcnkgPSBuZXcgX2Rpc3BsYXlfdXRpbHMuRE9NU1ZHRmFjdG9yeSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50ID0gbmV3IFNWR0V4dHJhU3RhdGUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudHJhbnNmb3JtTWF0cml4ID0gX3V0aWwuSURFTlRJVFlfTUFUUklYOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy50cmFuc2Zvcm1TdGFjayA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5leHRyYVN0YWNrID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbW1vbk9ianMgPSBjb21tb25PYmpzOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5vYmpzID0gb2JqczsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGVuZGluZ0NsaXAgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wZW5kaW5nRU9GaWxsID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmVtYmVkRm9udHMgPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZW1iZWRkZWRGb250cyA9IE9iamVjdC5jcmVhdGUobnVsbCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNzc1N0eWxlID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZm9yY2VEYXRhU2NoZW1hID0gISFmb3JjZURhdGFTY2hlbWE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9vcGVyYXRvcklkTWFwcGluZyA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBvcCBpbiBfdXRpbC5PUFMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9vcGVyYXRvcklkTWFwcGluZ1tfdXRpbC5PUFNbb3BdXSA9IG9wOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGdldE9iamVjdChkYXRhKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgZmFsbGJhY2sgPSBhcmd1bWVudHMubGVuZ3RoID4gMSAmJiBhcmd1bWVudHNbMV0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1sxXSA6IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIGRhdGEgPT09ICJzdHJpbmciKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGRhdGEuc3RhcnRzV2l0aCgiZ18iKSA/IHRoaXMuY29tbW9uT2Jqcy5nZXQoZGF0YSkgOiB0aGlzLm9ianMuZ2V0KGRhdGEpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbGxiYWNrOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHNhdmUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnRyYW5zZm9ybVN0YWNrLnB1c2godGhpcy50cmFuc2Zvcm1NYXRyaXgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgb2xkID0gdGhpcy5jdXJyZW50OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5leHRyYVN0YWNrLnB1c2gob2xkKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudCA9IG9sZC5jbG9uZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHJlc3RvcmUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnRyYW5zZm9ybU1hdHJpeCA9IHRoaXMudHJhbnNmb3JtU3RhY2sucG9wKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN1cnJlbnQgPSB0aGlzLmV4dHJhU3RhY2sucG9wKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBlbmRpbmdDbGlwID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudGdycCA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgZ3JvdXAoaXRlbXMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2F2ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5leGVjdXRlT3BUcmVlKGl0ZW1zKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucmVzdG9yZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGxvYWREZXBlbmRlbmNpZXMob3BlcmF0b3JMaXN0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBmbkFycmF5ID0gb3BlcmF0b3JMaXN0LmZuQXJyYXk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBhcmdzQXJyYXkgPSBvcGVyYXRvckxpc3QuYXJnc0FycmF5OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgaSA9IDAsIGlpID0gZm5BcnJheS5sZW5ndGg7IGkgPCBpaTsgaSsrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGZuQXJyYXlbaV0gIT09IF91dGlsLk9QUy5kZXBlbmRlbmN5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IG9iaiBvZiBhcmdzQXJyYXlbaV0pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgb2Jqc1Bvb2wgPSBvYmouc3RhcnRzV2l0aCgiZ18iKSA/IHRoaXMuY29tbW9uT2JqcyA6IHRoaXMub2JqczsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcHJvbWlzZSA9IG5ldyBQcm9taXNlKHJlc29sdmUgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgb2Jqc1Bvb2wuZ2V0KG9iaiwgcmVzb2x2ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN1cnJlbnQuZGVwZW5kZW5jaWVzLnB1c2gocHJvbWlzZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFByb21pc2UuYWxsKHRoaXMuY3VycmVudC5kZXBlbmRlbmNpZXMpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRyYW5zZm9ybShhLCBiLCBjLCBkLCBlLCBmKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB0cmFuc2Zvcm1NYXRyaXggPSBbYSwgYiwgYywgZCwgZSwgZl07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnRyYW5zZm9ybU1hdHJpeCA9IF91dGlsLlV0aWwudHJhbnNmb3JtKHRoaXMudHJhbnNmb3JtTWF0cml4LCB0cmFuc2Zvcm1NYXRyaXgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy50Z3JwID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBnZXRTVkcob3BlcmF0b3JMaXN0LCB2aWV3cG9ydCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy52aWV3cG9ydCA9IHZpZXdwb3J0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3ZnRWxlbWVudCA9IHRoaXMuX2luaXRpYWxpemUodmlld3BvcnQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMubG9hZERlcGVuZGVuY2llcyhvcGVyYXRvckxpc3QpLnRoZW4oKCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudHJhbnNmb3JtTWF0cml4ID0gX3V0aWwuSURFTlRJVFlfTUFUUklYOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZXhlY3V0ZU9wVHJlZSh0aGlzLmNvbnZlcnRPcExpc3Qob3BlcmF0b3JMaXN0KSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHN2Z0VsZW1lbnQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb252ZXJ0T3BMaXN0KG9wZXJhdG9yTGlzdCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgb3BlcmF0b3JJZE1hcHBpbmcgPSB0aGlzLl9vcGVyYXRvcklkTWFwcGluZzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGFyZ3NBcnJheSA9IG9wZXJhdG9yTGlzdC5hcmdzQXJyYXk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBmbkFycmF5ID0gb3BlcmF0b3JMaXN0LmZuQXJyYXk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBvcExpc3QgPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBpaSA9IGZuQXJyYXkubGVuZ3RoOyBpIDwgaWk7IGkrKykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZuSWQgPSBmbkFycmF5W2ldOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9wTGlzdC5wdXNoKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm5JZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm46IG9wZXJhdG9ySWRNYXBwaW5nW2ZuSWRdLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhcmdzOiBhcmdzQXJyYXlbaV0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBvcExpc3RUb1RyZWUob3BMaXN0KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBleGVjdXRlT3BUcmVlKG9wVHJlZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBvcFRyZWVFbGVtZW50IG9mIG9wVHJlZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZuID0gb3BUcmVlRWxlbWVudC5mbjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBmbklkID0gb3BUcmVlRWxlbWVudC5mbklkOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGFyZ3MgPSBvcFRyZWVFbGVtZW50LmFyZ3M7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3dpdGNoIChmbklkIHwgMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5iZWdpblRleHQ6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmJlZ2luVGV4dCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLmRlcGVuZGVuY3k6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5PUFMuc2V0TGVhZGluZzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0TGVhZGluZyhhcmdzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5zZXRMZWFkaW5nTW92ZVRleHQ6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNldExlYWRpbmdNb3ZlVGV4dChhcmdzWzBdLCBhcmdzWzFdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5zZXRGb250OgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRGb250KGFyZ3MpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnNob3dUZXh0OgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zaG93VGV4dChhcmdzWzBdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5zaG93U3BhY2VkVGV4dDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2hvd1RleHQoYXJnc1swXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5PUFMuZW5kVGV4dDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZW5kVGV4dCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLm1vdmVUZXh0OgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5tb3ZlVGV4dChhcmdzWzBdLCBhcmdzWzFdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5zZXRDaGFyU3BhY2luZzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0Q2hhclNwYWNpbmcoYXJnc1swXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5PUFMuc2V0V29yZFNwYWNpbmc6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNldFdvcmRTcGFjaW5nKGFyZ3NbMF0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnNldEhTY2FsZToKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0SFNjYWxlKGFyZ3NbMF0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnNldFRleHRNYXRyaXg6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNldFRleHRNYXRyaXgoYXJnc1swXSwgYXJnc1sxXSwgYXJnc1syXSwgYXJnc1szXSwgYXJnc1s0XSwgYXJnc1s1XSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5PUFMuc2V0VGV4dFJpc2U6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNldFRleHRSaXNlKGFyZ3NbMF0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnNldFRleHRSZW5kZXJpbmdNb2RlOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRUZXh0UmVuZGVyaW5nTW9kZShhcmdzWzBdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5zZXRMaW5lV2lkdGg6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNldExpbmVXaWR0aChhcmdzWzBdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5zZXRMaW5lSm9pbjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0TGluZUpvaW4oYXJnc1swXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5PUFMuc2V0TGluZUNhcDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0TGluZUNhcChhcmdzWzBdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5zZXRNaXRlckxpbWl0OgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRNaXRlckxpbWl0KGFyZ3NbMF0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnNldEZpbGxSR0JDb2xvcjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0RmlsbFJHQkNvbG9yKGFyZ3NbMF0sIGFyZ3NbMV0sIGFyZ3NbMl0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnNldFN0cm9rZVJHQkNvbG9yOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRTdHJva2VSR0JDb2xvcihhcmdzWzBdLCBhcmdzWzFdLCBhcmdzWzJdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5zZXRTdHJva2VDb2xvck46CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNldFN0cm9rZUNvbG9yTihhcmdzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5zZXRGaWxsQ29sb3JOOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRGaWxsQ29sb3JOKGFyZ3MpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnNoYWRpbmdGaWxsOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zaGFkaW5nRmlsbChhcmdzWzBdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5zZXREYXNoOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXREYXNoKGFyZ3NbMF0sIGFyZ3NbMV0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnNldFJlbmRlcmluZ0ludGVudDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0UmVuZGVyaW5nSW50ZW50KGFyZ3NbMF0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnNldEZsYXRuZXNzOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRGbGF0bmVzcyhhcmdzWzBdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5zZXRHU3RhdGU6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNldEdTdGF0ZShhcmdzWzBdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5maWxsOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5maWxsKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5PUFMuZW9GaWxsOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5lb0ZpbGwoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5zdHJva2U6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnN0cm9rZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLmZpbGxTdHJva2U6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmZpbGxTdHJva2UoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5lb0ZpbGxTdHJva2U6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmVvRmlsbFN0cm9rZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLmNsaXA6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNsaXAoIm5vbnplcm8iKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5lb0NsaXA6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNsaXAoImV2ZW5vZGQiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5wYWludFNvbGlkQ29sb3JJbWFnZU1hc2s6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBhaW50U29saWRDb2xvckltYWdlTWFzaygpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnBhaW50SW1hZ2VYT2JqZWN0OgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wYWludEltYWdlWE9iamVjdChhcmdzWzBdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5wYWludElubGluZUltYWdlWE9iamVjdDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGFpbnRJbmxpbmVJbWFnZVhPYmplY3QoYXJnc1swXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5PUFMucGFpbnRJbWFnZU1hc2tYT2JqZWN0OgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wYWludEltYWdlTWFza1hPYmplY3QoYXJnc1swXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5PUFMucGFpbnRGb3JtWE9iamVjdEJlZ2luOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wYWludEZvcm1YT2JqZWN0QmVnaW4oYXJnc1swXSwgYXJnc1sxXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5PUFMucGFpbnRGb3JtWE9iamVjdEVuZDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGFpbnRGb3JtWE9iamVjdEVuZCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLmNsb3NlUGF0aDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2xvc2VQYXRoKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5PUFMuY2xvc2VTdHJva2U6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNsb3NlU3Ryb2tlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5PUFMuY2xvc2VGaWxsU3Ryb2tlOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jbG9zZUZpbGxTdHJva2UoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5jbG9zZUVPRmlsbFN0cm9rZToKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2xvc2VFT0ZpbGxTdHJva2UoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5uZXh0TGluZToKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubmV4dExpbmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy50cmFuc2Zvcm06CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnRyYW5zZm9ybShhcmdzWzBdLCBhcmdzWzFdLCBhcmdzWzJdLCBhcmdzWzNdLCBhcmdzWzRdLCBhcmdzWzVdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5jb25zdHJ1Y3RQYXRoOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb25zdHJ1Y3RQYXRoKGFyZ3NbMF0sIGFyZ3NbMV0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLmVuZFBhdGg6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmVuZFBhdGgoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIDkyOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5ncm91cChvcFRyZWVFbGVtZW50Lml0ZW1zKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKGBVbmltcGxlbWVudGVkIG9wZXJhdG9yICR7Zm59YCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgc2V0V29yZFNwYWNpbmcod29yZFNwYWNpbmcpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC53b3JkU3BhY2luZyA9IHdvcmRTcGFjaW5nOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHNldENoYXJTcGFjaW5nKGNoYXJTcGFjaW5nKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN1cnJlbnQuY2hhclNwYWNpbmcgPSBjaGFyU3BhY2luZzsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBuZXh0TGluZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubW92ZVRleHQoMCwgdGhpcy5jdXJyZW50LmxlYWRpbmcpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHNldFRleHRNYXRyaXgoYSwgYiwgYywgZCwgZSwgZikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY3VycmVudCA9IHRoaXMuY3VycmVudDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQudGV4dE1hdHJpeCA9IGN1cnJlbnQubGluZU1hdHJpeCA9IFthLCBiLCBjLCBkLCBlLCBmXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQudGV4dE1hdHJpeFNjYWxlID0gTWF0aC5oeXBvdChhLCBiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQueCA9IGN1cnJlbnQubGluZVggPSAwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC55ID0gY3VycmVudC5saW5lWSA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50Lnhjb29yZHMgPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQueWNvb3JkcyA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC50c3BhbiA9IHRoaXMuc3ZnRmFjdG9yeS5jcmVhdGVFbGVtZW50KCJzdmc6dHNwYW4iKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQudHNwYW4uc2V0QXR0cmlidXRlTlMobnVsbCwgImZvbnQtZmFtaWx5IiwgY3VycmVudC5mb250RmFtaWx5KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQudHNwYW4uc2V0QXR0cmlidXRlTlMobnVsbCwgImZvbnQtc2l6ZSIsIGAke3BmKGN1cnJlbnQuZm9udFNpemUpfXB4YCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LnRzcGFuLnNldEF0dHJpYnV0ZU5TKG51bGwsICJ5IiwgcGYoLWN1cnJlbnQueSkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC50eHRFbGVtZW50ID0gdGhpcy5zdmdGYWN0b3J5LmNyZWF0ZUVsZW1lbnQoInN2Zzp0ZXh0Iik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LnR4dEVsZW1lbnQuYXBwZW5kKGN1cnJlbnQudHNwYW4pOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGJlZ2luVGV4dCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGN1cnJlbnQgPSB0aGlzLmN1cnJlbnQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LnggPSBjdXJyZW50LmxpbmVYID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQueSA9IGN1cnJlbnQubGluZVkgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC50ZXh0TWF0cml4ID0gX3V0aWwuSURFTlRJVFlfTUFUUklYOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC5saW5lTWF0cml4ID0gX3V0aWwuSURFTlRJVFlfTUFUUklYOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC50ZXh0TWF0cml4U2NhbGUgPSAxOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC50c3BhbiA9IHRoaXMuc3ZnRmFjdG9yeS5jcmVhdGVFbGVtZW50KCJzdmc6dHNwYW4iKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQudHh0RWxlbWVudCA9IHRoaXMuc3ZnRmFjdG9yeS5jcmVhdGVFbGVtZW50KCJzdmc6dGV4dCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC50eHRncnAgPSB0aGlzLnN2Z0ZhY3RvcnkuY3JlYXRlRWxlbWVudCgic3ZnOmciKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQueGNvb3JkcyA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC55Y29vcmRzID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgbW92ZVRleHQoeCwgeSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY3VycmVudCA9IHRoaXMuY3VycmVudDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQueCA9IGN1cnJlbnQubGluZVggKz0geDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQueSA9IGN1cnJlbnQubGluZVkgKz0geTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQueGNvb3JkcyA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC55Y29vcmRzID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LnRzcGFuID0gdGhpcy5zdmdGYWN0b3J5LmNyZWF0ZUVsZW1lbnQoInN2Zzp0c3BhbiIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC50c3Bhbi5zZXRBdHRyaWJ1dGVOUyhudWxsLCAiZm9udC1mYW1pbHkiLCBjdXJyZW50LmZvbnRGYW1pbHkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC50c3Bhbi5zZXRBdHRyaWJ1dGVOUyhudWxsLCAiZm9udC1zaXplIiwgYCR7cGYoY3VycmVudC5mb250U2l6ZSl9cHhgKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQudHNwYW4uc2V0QXR0cmlidXRlTlMobnVsbCwgInkiLCBwZigtY3VycmVudC55KSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgc2hvd1RleHQoZ2x5cGhzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjdXJyZW50ID0gdGhpcy5jdXJyZW50OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZm9udCA9IGN1cnJlbnQuZm9udDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZvbnRTaXplID0gY3VycmVudC5mb250U2l6ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChmb250U2l6ZSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZvbnRTaXplU2NhbGUgPSBjdXJyZW50LmZvbnRTaXplU2NhbGU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjaGFyU3BhY2luZyA9IGN1cnJlbnQuY2hhclNwYWNpbmc7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB3b3JkU3BhY2luZyA9IGN1cnJlbnQud29yZFNwYWNpbmc7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBmb250RGlyZWN0aW9uID0gY3VycmVudC5mb250RGlyZWN0aW9uOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdGV4dEhTY2FsZSA9IGN1cnJlbnQudGV4dEhTY2FsZSAqIGZvbnREaXJlY3Rpb247CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB2ZXJ0aWNhbCA9IGZvbnQudmVydGljYWw7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzcGFjaW5nRGlyID0gdmVydGljYWwgPyAxIDogLTE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBkZWZhdWx0Vk1ldHJpY3MgPSBmb250LmRlZmF1bHRWTWV0cmljczsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHdpZHRoQWR2YW5jZVNjYWxlID0gZm9udFNpemUgKiBjdXJyZW50LmZvbnRNYXRyaXhbMF07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgeCA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGdseXBoIG9mIGdseXBocykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChnbHlwaCA9PT0gbnVsbCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB4ICs9IGZvbnREaXJlY3Rpb24gKiB3b3JkU3BhY2luZzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmICh0eXBlb2YgZ2x5cGggPT09ICJudW1iZXIiKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHggKz0gc3BhY2luZ0RpciAqIGdseXBoICogZm9udFNpemUgLyAxMDAwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3BhY2luZyA9IChnbHlwaC5pc1NwYWNlID8gd29yZFNwYWNpbmcgOiAwKSArIGNoYXJTcGFjaW5nOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNoYXJhY3RlciA9IGdseXBoLmZvbnRDaGFyOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBzY2FsZWRYLCBzY2FsZWRZOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCB3aWR0aCA9IGdseXBoLndpZHRoOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh2ZXJ0aWNhbCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgdng7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHZtZXRyaWMgPSBnbHlwaC52bWV0cmljIHx8IGRlZmF1bHRWTWV0cmljczsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdnggPSBnbHlwaC52bWV0cmljID8gdm1ldHJpY1sxXSA6IHdpZHRoICogMC41OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2eCA9IC12eCAqIHdpZHRoQWR2YW5jZVNjYWxlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB2eSA9IHZtZXRyaWNbMl0gKiB3aWR0aEFkdmFuY2VTY2FsZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgd2lkdGggPSB2bWV0cmljID8gLXZtZXRyaWNbMF0gOiB3aWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2NhbGVkWCA9IHZ4IC8gZm9udFNpemVTY2FsZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2NhbGVkWSA9ICh4ICsgdnkpIC8gZm9udFNpemVTY2FsZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzY2FsZWRYID0geCAvIGZvbnRTaXplU2NhbGU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNjYWxlZFkgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZ2x5cGguaXNJbkZvbnQgfHwgZm9udC5taXNzaW5nRmlsZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50Lnhjb29yZHMucHVzaChjdXJyZW50LnggKyBzY2FsZWRYKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHZlcnRpY2FsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50Lnljb29yZHMucHVzaCgtY3VycmVudC55ICsgc2NhbGVkWSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC50c3Bhbi50ZXh0Q29udGVudCArPSBjaGFyYWN0ZXI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHt9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGNoYXJXaWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodmVydGljYWwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2hhcldpZHRoID0gd2lkdGggKiB3aWR0aEFkdmFuY2VTY2FsZSAtIHNwYWNpbmcgKiBmb250RGlyZWN0aW9uOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNoYXJXaWR0aCA9IHdpZHRoICogd2lkdGhBZHZhbmNlU2NhbGUgKyBzcGFjaW5nICogZm9udERpcmVjdGlvbjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgeCArPSBjaGFyV2lkdGg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LnRzcGFuLnNldEF0dHJpYnV0ZU5TKG51bGwsICJ4IiwgY3VycmVudC54Y29vcmRzLm1hcChwZikuam9pbigiICIpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh2ZXJ0aWNhbCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQudHNwYW4uc2V0QXR0cmlidXRlTlMobnVsbCwgInkiLCBjdXJyZW50Lnljb29yZHMubWFwKHBmKS5qb2luKCIgIikpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LnRzcGFuLnNldEF0dHJpYnV0ZU5TKG51bGwsICJ5IiwgcGYoLWN1cnJlbnQueSkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHZlcnRpY2FsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC55IC09IHg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQueCArPSB4ICogdGV4dEhTY2FsZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQudHNwYW4uc2V0QXR0cmlidXRlTlMobnVsbCwgImZvbnQtZmFtaWx5IiwgY3VycmVudC5mb250RmFtaWx5KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQudHNwYW4uc2V0QXR0cmlidXRlTlMobnVsbCwgImZvbnQtc2l6ZSIsIGAke3BmKGN1cnJlbnQuZm9udFNpemUpfXB4YCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoY3VycmVudC5mb250U3R5bGUgIT09IFNWR19ERUZBVUxUUy5mb250U3R5bGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LnRzcGFuLnNldEF0dHJpYnV0ZU5TKG51bGwsICJmb250LXN0eWxlIiwgY3VycmVudC5mb250U3R5bGUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGN1cnJlbnQuZm9udFdlaWdodCAhPT0gU1ZHX0RFRkFVTFRTLmZvbnRXZWlnaHQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LnRzcGFuLnNldEF0dHJpYnV0ZU5TKG51bGwsICJmb250LXdlaWdodCIsIGN1cnJlbnQuZm9udFdlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBmaWxsU3Ryb2tlTW9kZSA9IGN1cnJlbnQudGV4dFJlbmRlcmluZ01vZGUgJiBfdXRpbC5UZXh0UmVuZGVyaW5nTW9kZS5GSUxMX1NUUk9LRV9NQVNLOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGZpbGxTdHJva2VNb2RlID09PSBfdXRpbC5UZXh0UmVuZGVyaW5nTW9kZS5GSUxMIHx8IGZpbGxTdHJva2VNb2RlID09PSBfdXRpbC5UZXh0UmVuZGVyaW5nTW9kZS5GSUxMX1NUUk9LRSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjdXJyZW50LmZpbGxDb2xvciAhPT0gU1ZHX0RFRkFVTFRTLmZpbGxDb2xvcikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LnRzcGFuLnNldEF0dHJpYnV0ZU5TKG51bGwsICJmaWxsIiwgY3VycmVudC5maWxsQ29sb3IpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoY3VycmVudC5maWxsQWxwaGEgPCAxKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQudHNwYW4uc2V0QXR0cmlidXRlTlMobnVsbCwgImZpbGwtb3BhY2l0eSIsIGN1cnJlbnQuZmlsbEFscGhhKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGN1cnJlbnQudGV4dFJlbmRlcmluZ01vZGUgPT09IF91dGlsLlRleHRSZW5kZXJpbmdNb2RlLkFERF9UT19QQVRIKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC50c3Bhbi5zZXRBdHRyaWJ1dGVOUyhudWxsLCAiZmlsbCIsICJ0cmFuc3BhcmVudCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LnRzcGFuLnNldEF0dHJpYnV0ZU5TKG51bGwsICJmaWxsIiwgIm5vbmUiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChmaWxsU3Ryb2tlTW9kZSA9PT0gX3V0aWwuVGV4dFJlbmRlcmluZ01vZGUuU1RST0tFIHx8IGZpbGxTdHJva2VNb2RlID09PSBfdXRpbC5UZXh0UmVuZGVyaW5nTW9kZS5GSUxMX1NUUk9LRSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGxpbmVXaWR0aFNjYWxlID0gMSAvIChjdXJyZW50LnRleHRNYXRyaXhTY2FsZSB8fCAxKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9zZXRTdHJva2VBdHRyaWJ1dGVzKGN1cnJlbnQudHNwYW4sIGxpbmVXaWR0aFNjYWxlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCB0ZXh0TWF0cml4ID0gY3VycmVudC50ZXh0TWF0cml4OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGN1cnJlbnQudGV4dFJpc2UgIT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0ZXh0TWF0cml4ID0gdGV4dE1hdHJpeC5zbGljZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRleHRNYXRyaXhbNV0gKz0gY3VycmVudC50ZXh0UmlzZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQudHh0RWxlbWVudC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAidHJhbnNmb3JtIiwgYCR7cG0odGV4dE1hdHJpeCl9IHNjYWxlKCR7cGYodGV4dEhTY2FsZSl9LCAtMSlgKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQudHh0RWxlbWVudC5zZXRBdHRyaWJ1dGVOUyhYTUxfTlMsICJ4bWw6c3BhY2UiLCAicHJlc2VydmUiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQudHh0RWxlbWVudC5hcHBlbmQoY3VycmVudC50c3Bhbik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LnR4dGdycC5hcHBlbmQoY3VycmVudC50eHRFbGVtZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Vuc3VyZVRyYW5zZm9ybUdyb3VwKCkuYXBwZW5kKGN1cnJlbnQudHh0RWxlbWVudCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgc2V0TGVhZGluZ01vdmVUZXh0KHgsIHkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0TGVhZGluZygteSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm1vdmVUZXh0KHgsIHkpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGFkZEZvbnRTdHlsZShmb250T2JqKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWZvbnRPYmouZGF0YSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcigiYWRkRm9udFN0eWxlOiBObyBmb250IGRhdGEgYXZhaWxhYmxlLCAiICsgJ2Vuc3VyZSB0aGF0IHRoZSAiZm9udEV4dHJhUHJvcGVydGllcyIgQVBJIHBhcmFtZXRlciBpcyBzZXQuJyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuY3NzU3R5bGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNzc1N0eWxlID0gdGhpcy5zdmdGYWN0b3J5LmNyZWF0ZUVsZW1lbnQoInN2ZzpzdHlsZSIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3NzU3R5bGUuc2V0QXR0cmlidXRlTlMobnVsbCwgInR5cGUiLCAidGV4dC9jc3MiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRlZnMuYXBwZW5kKHRoaXMuY3NzU3R5bGUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdXJsID0gY3JlYXRlT2JqZWN0VVJMKGZvbnRPYmouZGF0YSwgZm9udE9iai5taW1ldHlwZSwgdGhpcy5mb3JjZURhdGFTY2hlbWEpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jc3NTdHlsZS50ZXh0Q29udGVudCArPSBgQGZvbnQtZmFjZSB7IGZvbnQtZmFtaWx5OiAiJHtmb250T2JqLmxvYWRlZE5hbWV9IjtgICsgYCBzcmM6IHVybCgke3VybH0pOyB9XG5gOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHNldEZvbnQoZGV0YWlscykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY3VycmVudCA9IHRoaXMuY3VycmVudDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZvbnRPYmogPSB0aGlzLmNvbW1vbk9ianMuZ2V0KGRldGFpbHNbMF0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHNpemUgPSBkZXRhaWxzWzFdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC5mb250ID0gZm9udE9iajsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmVtYmVkRm9udHMgJiYgIWZvbnRPYmoubWlzc2luZ0ZpbGUgJiYgIXRoaXMuZW1iZWRkZWRGb250c1tmb250T2JqLmxvYWRlZE5hbWVdKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5hZGRGb250U3R5bGUoZm9udE9iaik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5lbWJlZGRlZEZvbnRzW2ZvbnRPYmoubG9hZGVkTmFtZV0gPSBmb250T2JqOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC5mb250TWF0cml4ID0gZm9udE9iai5mb250TWF0cml4IHx8IF91dGlsLkZPTlRfSURFTlRJVFlfTUFUUklYOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGJvbGQgPSAibm9ybWFsIjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChmb250T2JqLmJsYWNrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYm9sZCA9ICI5MDAiOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChmb250T2JqLmJvbGQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBib2xkID0gImJvbGQiOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaXRhbGljID0gZm9udE9iai5pdGFsaWMgPyAiaXRhbGljIiA6ICJub3JtYWwiOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHNpemUgPCAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2l6ZSA9IC1zaXplOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQuZm9udERpcmVjdGlvbiA9IC0xOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LmZvbnREaXJlY3Rpb24gPSAxOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC5mb250U2l6ZSA9IHNpemU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LmZvbnRGYW1pbHkgPSBmb250T2JqLmxvYWRlZE5hbWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LmZvbnRXZWlnaHQgPSBib2xkOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC5mb250U3R5bGUgPSBpdGFsaWM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LnRzcGFuID0gdGhpcy5zdmdGYWN0b3J5LmNyZWF0ZUVsZW1lbnQoInN2Zzp0c3BhbiIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC50c3Bhbi5zZXRBdHRyaWJ1dGVOUyhudWxsLCAieSIsIHBmKC1jdXJyZW50LnkpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQueGNvb3JkcyA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC55Y29vcmRzID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgZW5kVGV4dCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfY3VycmVudCR0eHRFbGVtZW50OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY3VycmVudCA9IHRoaXMuY3VycmVudDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjdXJyZW50LnRleHRSZW5kZXJpbmdNb2RlICYgX3V0aWwuVGV4dFJlbmRlcmluZ01vZGUuQUREX1RPX1BBVEhfRkxBRyAmJiAoX2N1cnJlbnQkdHh0RWxlbWVudCA9IGN1cnJlbnQudHh0RWxlbWVudCkgIT09IG51bGwgJiYgX2N1cnJlbnQkdHh0RWxlbWVudCAhPT0gdm9pZCAwICYmIF9jdXJyZW50JHR4dEVsZW1lbnQuaGFzQ2hpbGROb2RlcygpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC5lbGVtZW50ID0gY3VycmVudC50eHRFbGVtZW50OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2xpcCgibm9uemVybyIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZW5kUGF0aCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHNldExpbmVXaWR0aCh3aWR0aCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHdpZHRoID4gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC5saW5lV2lkdGggPSB3aWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBzZXRMaW5lQ2FwKHN0eWxlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN1cnJlbnQubGluZUNhcCA9IExJTkVfQ0FQX1NUWUxFU1tzdHlsZV07CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgc2V0TGluZUpvaW4oc3R5bGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC5saW5lSm9pbiA9IExJTkVfSk9JTl9TVFlMRVNbc3R5bGVdOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHNldE1pdGVyTGltaXQobGltaXQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC5taXRlckxpbWl0ID0gbGltaXQ7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgc2V0U3Ryb2tlQWxwaGEoc3Ryb2tlQWxwaGEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC5zdHJva2VBbHBoYSA9IHN0cm9rZUFscGhhOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHNldFN0cm9rZVJHQkNvbG9yKHIsIGcsIGIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC5zdHJva2VDb2xvciA9IF91dGlsLlV0aWwubWFrZUhleENvbG9yKHIsIGcsIGIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHNldEZpbGxBbHBoYShmaWxsQWxwaGEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC5maWxsQWxwaGEgPSBmaWxsQWxwaGE7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgc2V0RmlsbFJHQkNvbG9yKHIsIGcsIGIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC5maWxsQ29sb3IgPSBfdXRpbC5VdGlsLm1ha2VIZXhDb2xvcihyLCBnLCBiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC50c3BhbiA9IHRoaXMuc3ZnRmFjdG9yeS5jcmVhdGVFbGVtZW50KCJzdmc6dHNwYW4iKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC54Y29vcmRzID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN1cnJlbnQueWNvb3JkcyA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHNldFN0cm9rZUNvbG9yTihhcmdzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN1cnJlbnQuc3Ryb2tlQ29sb3IgPSB0aGlzLl9tYWtlQ29sb3JOX1BhdHRlcm4oYXJncyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgc2V0RmlsbENvbG9yTihhcmdzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN1cnJlbnQuZmlsbENvbG9yID0gdGhpcy5fbWFrZUNvbG9yTl9QYXR0ZXJuKGFyZ3MpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHNoYWRpbmdGaWxsKGFyZ3MpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHdpZHRoID0gdGhpcy52aWV3cG9ydC53aWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGhlaWdodCA9IHRoaXMudmlld3BvcnQuaGVpZ2h0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaW52ID0gX3V0aWwuVXRpbC5pbnZlcnNlVHJhbnNmb3JtKHRoaXMudHJhbnNmb3JtTWF0cml4KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGJsID0gX3V0aWwuVXRpbC5hcHBseVRyYW5zZm9ybShbMCwgMF0sIGludik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBiciA9IF91dGlsLlV0aWwuYXBwbHlUcmFuc2Zvcm0oWzAsIGhlaWdodF0sIGludik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB1bCA9IF91dGlsLlV0aWwuYXBwbHlUcmFuc2Zvcm0oW3dpZHRoLCAwXSwgaW52KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHVyID0gX3V0aWwuVXRpbC5hcHBseVRyYW5zZm9ybShbd2lkdGgsIGhlaWdodF0sIGludik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB4MCA9IE1hdGgubWluKGJsWzBdLCBiclswXSwgdWxbMF0sIHVyWzBdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHkwID0gTWF0aC5taW4oYmxbMV0sIGJyWzFdLCB1bFsxXSwgdXJbMV0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgeDEgPSBNYXRoLm1heChibFswXSwgYnJbMF0sIHVsWzBdLCB1clswXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB5MSA9IE1hdGgubWF4KGJsWzFdLCBiclsxXSwgdWxbMV0sIHVyWzFdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHJlY3QgPSB0aGlzLnN2Z0ZhY3RvcnkuY3JlYXRlRWxlbWVudCgic3ZnOnJlY3QiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlY3Quc2V0QXR0cmlidXRlTlMobnVsbCwgIngiLCB4MCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWN0LnNldEF0dHJpYnV0ZU5TKG51bGwsICJ5IiwgeTApOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVjdC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAid2lkdGgiLCB4MSAtIHgwKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlY3Quc2V0QXR0cmlidXRlTlMobnVsbCwgImhlaWdodCIsIHkxIC0geTApOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVjdC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAiZmlsbCIsIHRoaXMuX21ha2VTaGFkaW5nUGF0dGVybihhcmdzKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5jdXJyZW50LmZpbGxBbHBoYSA8IDEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWN0LnNldEF0dHJpYnV0ZU5TKG51bGwsICJmaWxsLW9wYWNpdHkiLCB0aGlzLmN1cnJlbnQuZmlsbEFscGhhKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Vuc3VyZVRyYW5zZm9ybUdyb3VwKCkuYXBwZW5kKHJlY3QpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIF9tYWtlQ29sb3JOX1BhdHRlcm4oYXJncykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGFyZ3NbMF0gPT09ICJUaWxpbmdQYXR0ZXJuIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9tYWtlVGlsaW5nUGF0dGVybihhcmdzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9tYWtlU2hhZGluZ1BhdHRlcm4oYXJncyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgX21ha2VUaWxpbmdQYXR0ZXJuKGFyZ3MpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNvbG9yID0gYXJnc1sxXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG9wZXJhdG9yTGlzdCA9IGFyZ3NbMl07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBtYXRyaXggPSBhcmdzWzNdIHx8IF91dGlsLklERU5USVRZX01BVFJJWDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IFt4MCwgeTAsIHgxLCB5MV0gPSBhcmdzWzRdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgeHN0ZXAgPSBhcmdzWzVdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgeXN0ZXAgPSBhcmdzWzZdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcGFpbnRUeXBlID0gYXJnc1s3XTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHRpbGluZ0lkID0gYHNoYWRpbmcke3NoYWRpbmdDb3VudCsrfWA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBbdHgwLCB0eTAsIHR4MSwgdHkxXSA9IF91dGlsLlV0aWwubm9ybWFsaXplUmVjdChbLi4uX3V0aWwuVXRpbC5hcHBseVRyYW5zZm9ybShbeDAsIHkwXSwgbWF0cml4KSwgLi4uX3V0aWwuVXRpbC5hcHBseVRyYW5zZm9ybShbeDEsIHkxXSwgbWF0cml4KV0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgW3hzY2FsZSwgeXNjYWxlXSA9IF91dGlsLlV0aWwuc2luZ3VsYXJWYWx1ZURlY29tcG9zZTJkU2NhbGUobWF0cml4KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHR4c3RlcCA9IHhzdGVwICogeHNjYWxlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdHlzdGVwID0geXN0ZXAgKiB5c2NhbGU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB0aWxpbmcgPSB0aGlzLnN2Z0ZhY3RvcnkuY3JlYXRlRWxlbWVudCgic3ZnOnBhdHRlcm4iKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRpbGluZy5zZXRBdHRyaWJ1dGVOUyhudWxsLCAiaWQiLCB0aWxpbmdJZCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aWxpbmcuc2V0QXR0cmlidXRlTlMobnVsbCwgInBhdHRlcm5Vbml0cyIsICJ1c2VyU3BhY2VPblVzZSIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGlsaW5nLnNldEF0dHJpYnV0ZU5TKG51bGwsICJ3aWR0aCIsIHR4c3RlcCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aWxpbmcuc2V0QXR0cmlidXRlTlMobnVsbCwgImhlaWdodCIsIHR5c3RlcCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aWxpbmcuc2V0QXR0cmlidXRlTlMobnVsbCwgIngiLCBgJHt0eDB9YCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aWxpbmcuc2V0QXR0cmlidXRlTlMobnVsbCwgInkiLCBgJHt0eTB9YCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzdmcgPSB0aGlzLnN2ZzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHRyYW5zZm9ybU1hdHJpeCA9IHRoaXMudHJhbnNmb3JtTWF0cml4OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZmlsbENvbG9yID0gdGhpcy5jdXJyZW50LmZpbGxDb2xvcjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0cm9rZUNvbG9yID0gdGhpcy5jdXJyZW50LnN0cm9rZUNvbG9yOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYmJveCA9IHRoaXMuc3ZnRmFjdG9yeS5jcmVhdGUodHgxIC0gdHgwLCB0eTEgLSB0eTApOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zdmcgPSBiYm94OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy50cmFuc2Zvcm1NYXRyaXggPSBtYXRyaXg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAocGFpbnRUeXBlID09PSAyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY3NzQ29sb3IgPSBfdXRpbC5VdGlsLm1ha2VIZXhDb2xvciguLi5jb2xvcik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50LmZpbGxDb2xvciA9IGNzc0NvbG9yOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC5zdHJva2VDb2xvciA9IGNzc0NvbG9yOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5leGVjdXRlT3BUcmVlKHRoaXMuY29udmVydE9wTGlzdChvcGVyYXRvckxpc3QpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc3ZnID0gc3ZnOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy50cmFuc2Zvcm1NYXRyaXggPSB0cmFuc2Zvcm1NYXRyaXg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN1cnJlbnQuZmlsbENvbG9yID0gZmlsbENvbG9yOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50LnN0cm9rZUNvbG9yID0gc3Ryb2tlQ29sb3I7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aWxpbmcuYXBwZW5kKGJib3guY2hpbGROb2Rlc1swXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRlZnMuYXBwZW5kKHRpbGluZyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gYHVybCgjJHt0aWxpbmdJZH0pYDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBfbWFrZVNoYWRpbmdQYXR0ZXJuKGFyZ3MpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0eXBlb2YgYXJncyA9PT0gInN0cmluZyIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhcmdzID0gdGhpcy5vYmpzLmdldChhcmdzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN3aXRjaCAoYXJnc1swXSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgIlJhZGlhbEF4aWFsIjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2hhZGluZ0lkID0gYHNoYWRpbmcke3NoYWRpbmdDb3VudCsrfWA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNvbG9yU3RvcHMgPSBhcmdzWzNdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgZ3JhZGllbnQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN3aXRjaCAoYXJnc1sxXSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiYXhpYWwiOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHBvaW50MCA9IGFyZ3NbNF07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcG9pbnQxID0gYXJnc1s1XTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBncmFkaWVudCA9IHRoaXMuc3ZnRmFjdG9yeS5jcmVhdGVFbGVtZW50KCJzdmc6bGluZWFyR3JhZGllbnQiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBncmFkaWVudC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAiaWQiLCBzaGFkaW5nSWQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdyYWRpZW50LnNldEF0dHJpYnV0ZU5TKG51bGwsICJncmFkaWVudFVuaXRzIiwgInVzZXJTcGFjZU9uVXNlIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZ3JhZGllbnQuc2V0QXR0cmlidXRlTlMobnVsbCwgIngxIiwgcG9pbnQwWzBdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBncmFkaWVudC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAieTEiLCBwb2ludDBbMV0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdyYWRpZW50LnNldEF0dHJpYnV0ZU5TKG51bGwsICJ4MiIsIHBvaW50MVswXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZ3JhZGllbnQuc2V0QXR0cmlidXRlTlMobnVsbCwgInkyIiwgcG9pbnQxWzFdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgInJhZGlhbCI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZm9jYWxQb2ludCA9IGFyZ3NbNF07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2lyY2xlUG9pbnQgPSBhcmdzWzVdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZvY2FsUmFkaXVzID0gYXJnc1s2XTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjaXJjbGVSYWRpdXMgPSBhcmdzWzddOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdyYWRpZW50ID0gdGhpcy5zdmdGYWN0b3J5LmNyZWF0ZUVsZW1lbnQoInN2ZzpyYWRpYWxHcmFkaWVudCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdyYWRpZW50LnNldEF0dHJpYnV0ZU5TKG51bGwsICJpZCIsIHNoYWRpbmdJZCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZ3JhZGllbnQuc2V0QXR0cmlidXRlTlMobnVsbCwgImdyYWRpZW50VW5pdHMiLCAidXNlclNwYWNlT25Vc2UiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBncmFkaWVudC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAiY3giLCBjaXJjbGVQb2ludFswXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZ3JhZGllbnQuc2V0QXR0cmlidXRlTlMobnVsbCwgImN5IiwgY2lyY2xlUG9pbnRbMV0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdyYWRpZW50LnNldEF0dHJpYnV0ZU5TKG51bGwsICJyIiwgY2lyY2xlUmFkaXVzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBncmFkaWVudC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAiZngiLCBmb2NhbFBvaW50WzBdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBncmFkaWVudC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAiZnkiLCBmb2NhbFBvaW50WzFdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBncmFkaWVudC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAiZnIiLCBmb2NhbFJhZGl1cyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcihgVW5rbm93biBSYWRpYWxBeGlhbCB0eXBlOiAke2FyZ3NbMV19YCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBjb2xvclN0b3Agb2YgY29sb3JTdG9wcykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3RvcCA9IHRoaXMuc3ZnRmFjdG9yeS5jcmVhdGVFbGVtZW50KCJzdmc6c3RvcCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RvcC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAib2Zmc2V0IiwgY29sb3JTdG9wWzBdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0b3Auc2V0QXR0cmlidXRlTlMobnVsbCwgInN0b3AtY29sb3IiLCBjb2xvclN0b3BbMV0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZ3JhZGllbnQuYXBwZW5kKHN0b3ApOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGVmcy5hcHBlbmQoZ3JhZGllbnQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gYHVybCgjJHtzaGFkaW5nSWR9KWA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiTWVzaCI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKSgiVW5pbXBsZW1lbnRlZCBwYXR0ZXJuIE1lc2giKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiRHVtbXkiOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gImhvdHBpbmsiOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcihgVW5rbm93biBJUiB0eXBlOiAke2FyZ3NbMF19YCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgc2V0RGFzaChkYXNoQXJyYXksIGRhc2hQaGFzZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50LmRhc2hBcnJheSA9IGRhc2hBcnJheTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC5kYXNoUGhhc2UgPSBkYXNoUGhhc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0UGF0aChvcHMsIGFyZ3MpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGN1cnJlbnQgPSB0aGlzLmN1cnJlbnQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgeCA9IGN1cnJlbnQueCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB5ID0gY3VycmVudC55OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGQgPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBqID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3Qgb3Agb2Ygb3BzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3dpdGNoIChvcCB8IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5PUFMucmVjdGFuZ2xlOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgeCA9IGFyZ3NbaisrXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHkgPSBhcmdzW2orK107CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB3aWR0aCA9IGFyZ3NbaisrXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGhlaWdodCA9IGFyZ3NbaisrXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHh3ID0geCArIHdpZHRoOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgeWggPSB5ICsgaGVpZ2h0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZC5wdXNoKCJNIiwgcGYoeCksIHBmKHkpLCAiTCIsIHBmKHh3KSwgcGYoeSksICJMIiwgcGYoeHcpLCBwZih5aCksICJMIiwgcGYoeCksIHBmKHloKSwgIloiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5tb3ZlVG86CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB4ID0gYXJnc1tqKytdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgeSA9IGFyZ3NbaisrXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGQucHVzaCgiTSIsIHBmKHgpLCBwZih5KSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5PUFMubGluZVRvOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgeCA9IGFyZ3NbaisrXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHkgPSBhcmdzW2orK107CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkLnB1c2goIkwiLCBwZih4KSwgcGYoeSkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLmN1cnZlVG86CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB4ID0gYXJnc1tqICsgNF07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB5ID0gYXJnc1tqICsgNV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkLnB1c2goIkMiLCBwZihhcmdzW2pdKSwgcGYoYXJnc1tqICsgMV0pLCBwZihhcmdzW2ogKyAyXSksIHBmKGFyZ3NbaiArIDNdKSwgcGYoeCksIHBmKHkpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGogKz0gNjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5jdXJ2ZVRvMjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGQucHVzaCgiQyIsIHBmKHgpLCBwZih5KSwgcGYoYXJnc1tqXSksIHBmKGFyZ3NbaiArIDFdKSwgcGYoYXJnc1tqICsgMl0pLCBwZihhcmdzW2ogKyAzXSkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgeCA9IGFyZ3NbaiArIDJdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgeSA9IGFyZ3NbaiArIDNdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaiArPSA0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLmN1cnZlVG8zOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgeCA9IGFyZ3NbaiArIDJdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgeSA9IGFyZ3NbaiArIDNdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZC5wdXNoKCJDIiwgcGYoYXJnc1tqXSksIHBmKGFyZ3NbaiArIDFdKSwgcGYoeCksIHBmKHkpLCBwZih4KSwgcGYoeSkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaiArPSA0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLmNsb3NlUGF0aDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGQucHVzaCgiWiIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgZCA9IGQuam9pbigiICIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGN1cnJlbnQucGF0aCAmJiBvcHMubGVuZ3RoID4gMCAmJiBvcHNbMF0gIT09IF91dGlsLk9QUy5yZWN0YW5nbGUgJiYgb3BzWzBdICE9PSBfdXRpbC5PUFMubW92ZVRvKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZCA9IGN1cnJlbnQucGF0aC5nZXRBdHRyaWJ1dGVOUyhudWxsLCAiZCIpICsgZDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC5wYXRoID0gdGhpcy5zdmdGYWN0b3J5LmNyZWF0ZUVsZW1lbnQoInN2ZzpwYXRoIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZW5zdXJlVHJhbnNmb3JtR3JvdXAoKS5hcHBlbmQoY3VycmVudC5wYXRoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQucGF0aC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAiZCIsIGQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC5wYXRoLnNldEF0dHJpYnV0ZU5TKG51bGwsICJmaWxsIiwgIm5vbmUiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQuZWxlbWVudCA9IGN1cnJlbnQucGF0aDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQuc2V0Q3VycmVudFBvaW50KHgsIHkpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGVuZFBhdGgoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjdXJyZW50ID0gdGhpcy5jdXJyZW50OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC5wYXRoID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5wZW5kaW5nQ2xpcCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghY3VycmVudC5lbGVtZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wZW5kaW5nQ2xpcCA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2xpcElkID0gYGNsaXBwYXRoJHtjbGlwQ291bnQrK31gOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2xpcFBhdGggPSB0aGlzLnN2Z0ZhY3RvcnkuY3JlYXRlRWxlbWVudCgic3ZnOmNsaXBQYXRoIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbGlwUGF0aC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAiaWQiLCBjbGlwSWQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xpcFBhdGguc2V0QXR0cmlidXRlTlMobnVsbCwgInRyYW5zZm9ybSIsIHBtKHRoaXMudHJhbnNmb3JtTWF0cml4KSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjbGlwRWxlbWVudCA9IGN1cnJlbnQuZWxlbWVudC5jbG9uZU5vZGUodHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5wZW5kaW5nQ2xpcCA9PT0gImV2ZW5vZGQiKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xpcEVsZW1lbnQuc2V0QXR0cmlidXRlTlMobnVsbCwgImNsaXAtcnVsZSIsICJldmVub2RkIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsaXBFbGVtZW50LnNldEF0dHJpYnV0ZU5TKG51bGwsICJjbGlwLXJ1bGUiLCAibm9uemVybyIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wZW5kaW5nQ2xpcCA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbGlwUGF0aC5hcHBlbmQoY2xpcEVsZW1lbnQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kZWZzLmFwcGVuZChjbGlwUGF0aCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoY3VycmVudC5hY3RpdmVDbGlwVXJsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC5jbGlwR3JvdXAgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgcHJldiBvZiB0aGlzLmV4dHJhU3RhY2spIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJldi5jbGlwR3JvdXAgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbGlwUGF0aC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAiY2xpcC1wYXRoIiwgY3VycmVudC5hY3RpdmVDbGlwVXJsKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQuYWN0aXZlQ2xpcFVybCA9IGB1cmwoIyR7Y2xpcElkfSlgOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy50Z3JwID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjbGlwKHR5cGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGVuZGluZ0NsaXAgPSB0eXBlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNsb3NlUGF0aCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGN1cnJlbnQgPSB0aGlzLmN1cnJlbnQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoY3VycmVudC5wYXRoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZCA9IGAke2N1cnJlbnQucGF0aC5nZXRBdHRyaWJ1dGVOUyhudWxsLCAiZCIpfVpgOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQucGF0aC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAiZCIsIGQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHNldExlYWRpbmcobGVhZGluZykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50LmxlYWRpbmcgPSAtbGVhZGluZzsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBzZXRUZXh0UmlzZSh0ZXh0UmlzZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50LnRleHRSaXNlID0gdGV4dFJpc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgc2V0VGV4dFJlbmRlcmluZ01vZGUodGV4dFJlbmRlcmluZ01vZGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC50ZXh0UmVuZGVyaW5nTW9kZSA9IHRleHRSZW5kZXJpbmdNb2RlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHNldEhTY2FsZShzY2FsZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50LnRleHRIU2NhbGUgPSBzY2FsZSAvIDEwMDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBzZXRSZW5kZXJpbmdJbnRlbnQoaW50ZW50KSB7fQogICAgICAgICAgICAgICAgICAgICAgICBzZXRGbGF0bmVzcyhmbGF0bmVzcykge30KICAgICAgICAgICAgICAgICAgICAgICAgc2V0R1N0YXRlKHN0YXRlcykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBba2V5LCB2YWx1ZV0gb2Ygc3RhdGVzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3dpdGNoIChrZXkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiTFciOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRMaW5lV2lkdGgodmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgIkxDIjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0TGluZUNhcCh2YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiTEoiOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRMaW5lSm9pbih2YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiTUwiOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRNaXRlckxpbWl0KHZhbHVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJEIjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0RGFzaCh2YWx1ZVswXSwgdmFsdWVbMV0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgIlJJIjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0UmVuZGVyaW5nSW50ZW50KHZhbHVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJGTCI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNldEZsYXRuZXNzKHZhbHVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJGb250IjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0Rm9udCh2YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiQ0EiOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRTdHJva2VBbHBoYSh2YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiY2EiOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRGaWxsQWxwaGEodmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYFVuaW1wbGVtZW50ZWQgZ3JhcGhpYyBzdGF0ZSBvcGVyYXRvciAke2tleX1gKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBmaWxsKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY3VycmVudCA9IHRoaXMuY3VycmVudDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjdXJyZW50LmVsZW1lbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LmVsZW1lbnQuc2V0QXR0cmlidXRlTlMobnVsbCwgImZpbGwiLCBjdXJyZW50LmZpbGxDb2xvcik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC5lbGVtZW50LnNldEF0dHJpYnV0ZU5TKG51bGwsICJmaWxsLW9wYWNpdHkiLCBjdXJyZW50LmZpbGxBbHBoYSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5lbmRQYXRoKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgc3Ryb2tlKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY3VycmVudCA9IHRoaXMuY3VycmVudDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjdXJyZW50LmVsZW1lbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9zZXRTdHJva2VBdHRyaWJ1dGVzKGN1cnJlbnQuZWxlbWVudCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC5lbGVtZW50LnNldEF0dHJpYnV0ZU5TKG51bGwsICJmaWxsIiwgIm5vbmUiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmVuZFBhdGgoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBfc2V0U3Ryb2tlQXR0cmlidXRlcyhlbGVtZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgbGluZVdpZHRoU2NhbGUgPSBhcmd1bWVudHMubGVuZ3RoID4gMSAmJiBhcmd1bWVudHNbMV0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1sxXSA6IDE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjdXJyZW50ID0gdGhpcy5jdXJyZW50OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGRhc2hBcnJheSA9IGN1cnJlbnQuZGFzaEFycmF5OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGxpbmVXaWR0aFNjYWxlICE9PSAxICYmIGRhc2hBcnJheS5sZW5ndGggPiAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGFzaEFycmF5ID0gZGFzaEFycmF5Lm1hcChmdW5jdGlvbiAodmFsdWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGxpbmVXaWR0aFNjYWxlICogdmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50LnNldEF0dHJpYnV0ZU5TKG51bGwsICJzdHJva2UiLCBjdXJyZW50LnN0cm9rZUNvbG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1lbnQuc2V0QXR0cmlidXRlTlMobnVsbCwgInN0cm9rZS1vcGFjaXR5IiwgY3VycmVudC5zdHJva2VBbHBoYSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50LnNldEF0dHJpYnV0ZU5TKG51bGwsICJzdHJva2UtbWl0ZXJsaW1pdCIsIHBmKGN1cnJlbnQubWl0ZXJMaW1pdCkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAic3Ryb2tlLWxpbmVjYXAiLCBjdXJyZW50LmxpbmVDYXApOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAic3Ryb2tlLWxpbmVqb2luIiwgY3VycmVudC5saW5lSm9pbik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50LnNldEF0dHJpYnV0ZU5TKG51bGwsICJzdHJva2Utd2lkdGgiLCBwZihsaW5lV2lkdGhTY2FsZSAqIGN1cnJlbnQubGluZVdpZHRoKSArICJweCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAic3Ryb2tlLWRhc2hhcnJheSIsIGRhc2hBcnJheS5tYXAocGYpLmpvaW4oIiAiKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50LnNldEF0dHJpYnV0ZU5TKG51bGwsICJzdHJva2UtZGFzaG9mZnNldCIsIHBmKGxpbmVXaWR0aFNjYWxlICogY3VycmVudC5kYXNoUGhhc2UpICsgInB4Iik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgZW9GaWxsKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF90aGlzJGN1cnJlbnQkZWxlbWVudDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIChfdGhpcyRjdXJyZW50JGVsZW1lbnQgPSB0aGlzLmN1cnJlbnQuZWxlbWVudCkgPT09IG51bGwgfHwgX3RoaXMkY3VycmVudCRlbGVtZW50ID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRjdXJyZW50JGVsZW1lbnQuc2V0QXR0cmlidXRlTlMobnVsbCwgImZpbGwtcnVsZSIsICJldmVub2RkIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmZpbGwoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBmaWxsU3Ryb2tlKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zdHJva2UoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZmlsbCgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGVvRmlsbFN0cm9rZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRjdXJyZW50JGVsZW1lbnQyOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgKF90aGlzJGN1cnJlbnQkZWxlbWVudDIgPSB0aGlzLmN1cnJlbnQuZWxlbWVudCkgPT09IG51bGwgfHwgX3RoaXMkY3VycmVudCRlbGVtZW50MiA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3RoaXMkY3VycmVudCRlbGVtZW50Mi5zZXRBdHRyaWJ1dGVOUyhudWxsLCAiZmlsbC1ydWxlIiwgImV2ZW5vZGQiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZmlsbFN0cm9rZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNsb3NlU3Ryb2tlKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jbG9zZVBhdGgoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc3Ryb2tlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY2xvc2VGaWxsU3Ryb2tlKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jbG9zZVBhdGgoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZmlsbFN0cm9rZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNsb3NlRU9GaWxsU3Ryb2tlKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jbG9zZVBhdGgoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZW9GaWxsU3Ryb2tlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcGFpbnRTb2xpZENvbG9ySW1hZ2VNYXNrKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmVjdCA9IHRoaXMuc3ZnRmFjdG9yeS5jcmVhdGVFbGVtZW50KCJzdmc6cmVjdCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVjdC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAieCIsICIwIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWN0LnNldEF0dHJpYnV0ZU5TKG51bGwsICJ5IiwgIjAiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlY3Quc2V0QXR0cmlidXRlTlMobnVsbCwgIndpZHRoIiwgIjFweCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVjdC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAiaGVpZ2h0IiwgIjFweCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVjdC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAiZmlsbCIsIHRoaXMuY3VycmVudC5maWxsQ29sb3IpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZW5zdXJlVHJhbnNmb3JtR3JvdXAoKS5hcHBlbmQocmVjdCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcGFpbnRJbWFnZVhPYmplY3Qob2JqSWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGltZ0RhdGEgPSB0aGlzLmdldE9iamVjdChvYmpJZCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWltZ0RhdGEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYERlcGVuZGVudCBpbWFnZSB3aXRoIG9iamVjdCBJRCAke29iaklkfSBpcyBub3QgcmVhZHkgeWV0YCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wYWludElubGluZUltYWdlWE9iamVjdChpbWdEYXRhKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBwYWludElubGluZUltYWdlWE9iamVjdChpbWdEYXRhLCBtYXNrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB3aWR0aCA9IGltZ0RhdGEud2lkdGg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBoZWlnaHQgPSBpbWdEYXRhLmhlaWdodDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGltZ1NyYyA9IGNvbnZlcnRJbWdEYXRhVG9QbmcoaW1nRGF0YSwgdGhpcy5mb3JjZURhdGFTY2hlbWEsICEhbWFzayk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjbGlwcmVjdCA9IHRoaXMuc3ZnRmFjdG9yeS5jcmVhdGVFbGVtZW50KCJzdmc6cmVjdCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xpcHJlY3Quc2V0QXR0cmlidXRlTlMobnVsbCwgIngiLCAiMCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xpcHJlY3Quc2V0QXR0cmlidXRlTlMobnVsbCwgInkiLCAiMCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xpcHJlY3Quc2V0QXR0cmlidXRlTlMobnVsbCwgIndpZHRoIiwgcGYod2lkdGgpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsaXByZWN0LnNldEF0dHJpYnV0ZU5TKG51bGwsICJoZWlnaHQiLCBwZihoZWlnaHQpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC5lbGVtZW50ID0gY2xpcHJlY3Q7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNsaXAoIm5vbnplcm8iKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGltZ0VsID0gdGhpcy5zdmdGYWN0b3J5LmNyZWF0ZUVsZW1lbnQoInN2ZzppbWFnZSIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaW1nRWwuc2V0QXR0cmlidXRlTlMoWExJTktfTlMsICJ4bGluazpocmVmIiwgaW1nU3JjKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGltZ0VsLnNldEF0dHJpYnV0ZU5TKG51bGwsICJ4IiwgIjAiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGltZ0VsLnNldEF0dHJpYnV0ZU5TKG51bGwsICJ5IiwgcGYoLWhlaWdodCkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaW1nRWwuc2V0QXR0cmlidXRlTlMobnVsbCwgIndpZHRoIiwgcGYod2lkdGgpICsgInB4Iik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbWdFbC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAiaGVpZ2h0IiwgcGYoaGVpZ2h0KSArICJweCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaW1nRWwuc2V0QXR0cmlidXRlTlMobnVsbCwgInRyYW5zZm9ybSIsIGBzY2FsZSgke3BmKDEgLyB3aWR0aCl9ICR7cGYoLTEgLyBoZWlnaHQpfSlgKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChtYXNrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbWFzay5hcHBlbmQoaW1nRWwpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9lbnN1cmVUcmFuc2Zvcm1Hcm91cCgpLmFwcGVuZChpbWdFbCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcGFpbnRJbWFnZU1hc2tYT2JqZWN0KGltZykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaW1nRGF0YSA9IHRoaXMuZ2V0T2JqZWN0KGltZy5kYXRhLCBpbWcpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGltZ0RhdGEuYml0bWFwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKCJwYWludEltYWdlTWFza1hPYmplY3Q6IEltYWdlQml0bWFwIHN1cHBvcnQgaXMgbm90IGltcGxlbWVudGVkLCAiICsgImVuc3VyZSB0aGF0IHRoZSBgaXNPZmZzY3JlZW5DYW52YXNTdXBwb3J0ZWRgIEFQSSBwYXJhbWV0ZXIgaXMgZGlzYWJsZWQuIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY3VycmVudCA9IHRoaXMuY3VycmVudDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHdpZHRoID0gaW1nRGF0YS53aWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGhlaWdodCA9IGltZ0RhdGEuaGVpZ2h0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZmlsbENvbG9yID0gY3VycmVudC5maWxsQ29sb3I7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50Lm1hc2tJZCA9IGBtYXNrJHttYXNrQ291bnQrK31gOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbWFzayA9IHRoaXMuc3ZnRmFjdG9yeS5jcmVhdGVFbGVtZW50KCJzdmc6bWFzayIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbWFzay5zZXRBdHRyaWJ1dGVOUyhudWxsLCAiaWQiLCBjdXJyZW50Lm1hc2tJZCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByZWN0ID0gdGhpcy5zdmdGYWN0b3J5LmNyZWF0ZUVsZW1lbnQoInN2ZzpyZWN0Iik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWN0LnNldEF0dHJpYnV0ZU5TKG51bGwsICJ4IiwgIjAiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlY3Quc2V0QXR0cmlidXRlTlMobnVsbCwgInkiLCAiMCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVjdC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAid2lkdGgiLCBwZih3aWR0aCkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVjdC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAiaGVpZ2h0IiwgcGYoaGVpZ2h0KSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWN0LnNldEF0dHJpYnV0ZU5TKG51bGwsICJmaWxsIiwgZmlsbENvbG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlY3Quc2V0QXR0cmlidXRlTlMobnVsbCwgIm1hc2siLCBgdXJsKCMke2N1cnJlbnQubWFza0lkfSlgKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGVmcy5hcHBlbmQobWFzayk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9lbnN1cmVUcmFuc2Zvcm1Hcm91cCgpLmFwcGVuZChyZWN0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGFpbnRJbmxpbmVJbWFnZVhPYmplY3QoaW1nRGF0YSwgbWFzayk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcGFpbnRGb3JtWE9iamVjdEJlZ2luKG1hdHJpeCwgYmJveCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKEFycmF5LmlzQXJyYXkobWF0cml4KSAmJiBtYXRyaXgubGVuZ3RoID09PSA2KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy50cmFuc2Zvcm0obWF0cml4WzBdLCBtYXRyaXhbMV0sIG1hdHJpeFsyXSwgbWF0cml4WzNdLCBtYXRyaXhbNF0sIG1hdHJpeFs1XSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoYmJveCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHdpZHRoID0gYmJveFsyXSAtIGJib3hbMF07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaGVpZ2h0ID0gYmJveFszXSAtIGJib3hbMV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2xpcHJlY3QgPSB0aGlzLnN2Z0ZhY3RvcnkuY3JlYXRlRWxlbWVudCgic3ZnOnJlY3QiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbGlwcmVjdC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAieCIsIGJib3hbMF0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsaXByZWN0LnNldEF0dHJpYnV0ZU5TKG51bGwsICJ5IiwgYmJveFsxXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xpcHJlY3Quc2V0QXR0cmlidXRlTlMobnVsbCwgIndpZHRoIiwgcGYod2lkdGgpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbGlwcmVjdC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAiaGVpZ2h0IiwgcGYoaGVpZ2h0KSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50LmVsZW1lbnQgPSBjbGlwcmVjdDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNsaXAoIm5vbnplcm8iKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmVuZFBhdGgoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBwYWludEZvcm1YT2JqZWN0RW5kKCkge30KICAgICAgICAgICAgICAgICAgICAgICAgX2luaXRpYWxpemUodmlld3BvcnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN2ZyA9IHRoaXMuc3ZnRmFjdG9yeS5jcmVhdGUodmlld3BvcnQud2lkdGgsIHZpZXdwb3J0LmhlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBkZWZpbml0aW9ucyA9IHRoaXMuc3ZnRmFjdG9yeS5jcmVhdGVFbGVtZW50KCJzdmc6ZGVmcyIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3ZnLmFwcGVuZChkZWZpbml0aW9ucyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRlZnMgPSBkZWZpbml0aW9uczsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHJvb3RHcm91cCA9IHRoaXMuc3ZnRmFjdG9yeS5jcmVhdGVFbGVtZW50KCJzdmc6ZyIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcm9vdEdyb3VwLnNldEF0dHJpYnV0ZU5TKG51bGwsICJ0cmFuc2Zvcm0iLCBwbSh2aWV3cG9ydC50cmFuc2Zvcm0pKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN2Zy5hcHBlbmQocm9vdEdyb3VwKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc3ZnID0gcm9vdEdyb3VwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHN2ZzsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBfZW5zdXJlQ2xpcEdyb3VwKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLmN1cnJlbnQuY2xpcEdyb3VwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2xpcEdyb3VwID0gdGhpcy5zdmdGYWN0b3J5LmNyZWF0ZUVsZW1lbnQoInN2ZzpnIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xpcEdyb3VwLnNldEF0dHJpYnV0ZU5TKG51bGwsICJjbGlwLXBhdGgiLCB0aGlzLmN1cnJlbnQuYWN0aXZlQ2xpcFVybCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zdmcuYXBwZW5kKGNsaXBHcm91cCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50LmNsaXBHcm91cCA9IGNsaXBHcm91cDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLmN1cnJlbnQuY2xpcEdyb3VwOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIF9lbnN1cmVUcmFuc2Zvcm1Hcm91cCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy50Z3JwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy50Z3JwID0gdGhpcy5zdmdGYWN0b3J5LmNyZWF0ZUVsZW1lbnQoInN2ZzpnIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy50Z3JwLnNldEF0dHJpYnV0ZU5TKG51bGwsICJ0cmFuc2Zvcm0iLCBwbSh0aGlzLnRyYW5zZm9ybU1hdHJpeCkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmN1cnJlbnQuYWN0aXZlQ2xpcFVybCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9lbnN1cmVDbGlwR3JvdXAoKS5hcHBlbmQodGhpcy50Z3JwKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnN2Zy5hcHBlbmQodGhpcy50Z3JwKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy50Z3JwOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIH0KCiAgICAgICAgICAgICAgICAvKioqLyB9KQogICAgICAgICAgICAvKioqKioqLyAJXSk7CiAgICAgICAgLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KICAgICAgICAvKioqKioqLyAJLy8gVGhlIG1vZHVsZSBjYWNoZQogICAgICAgIC8qKioqKiovIAl2YXIgX193ZWJwYWNrX21vZHVsZV9jYWNoZV9fID0ge307CiAgICAgICAgLyoqKioqKi8KICAgICAgICAvKioqKioqLyAJLy8gVGhlIHJlcXVpcmUgZnVuY3Rpb24KICAgICAgICAvKioqKioqLyAJZnVuY3Rpb24gX193X3BkZmpzX3JlcXVpcmVfXyhtb2R1bGVJZCkgewogICAgICAgICAgICAvKioqKioqLyAJCS8vIENoZWNrIGlmIG1vZHVsZSBpcyBpbiBjYWNoZQogICAgICAgICAgICAvKioqKioqLyAJCXZhciBjYWNoZWRNb2R1bGUgPSBfX3dlYnBhY2tfbW9kdWxlX2NhY2hlX19bbW9kdWxlSWRdOwogICAgICAgICAgICAvKioqKioqLyAJCWlmIChjYWNoZWRNb2R1bGUgIT09IHVuZGVmaW5lZCkgewogICAgICAgICAgICAgICAgLyoqKioqKi8gCQkJcmV0dXJuIGNhY2hlZE1vZHVsZS5leHBvcnRzOwogICAgICAgICAgICAgICAgLyoqKioqKi8gCQl9CiAgICAgICAgICAgIC8qKioqKiovIAkJLy8gQ3JlYXRlIGEgbmV3IG1vZHVsZSAoYW5kIHB1dCBpdCBpbnRvIHRoZSBjYWNoZSkKICAgICAgICAgICAgLyoqKioqKi8gCQl2YXIgbW9kdWxlID0gX193ZWJwYWNrX21vZHVsZV9jYWNoZV9fW21vZHVsZUlkXSA9IHsKICAgICAgICAgICAgICAgIC8qKioqKiovIAkJCS8vIG5vIG1vZHVsZS5pZCBuZWVkZWQKICAgICAgICAgICAgICAgIC8qKioqKiovIAkJCS8vIG5vIG1vZHVsZS5sb2FkZWQgbmVlZGVkCiAgICAgICAgICAgICAgICAvKioqKioqLyAJCQlleHBvcnRzOiB7fQogICAgICAgICAgICAgICAgLyoqKioqKi8gCQl9OwogICAgICAgICAgICAvKioqKioqLwogICAgICAgICAgICAvKioqKioqLyAJCS8vIEV4ZWN1dGUgdGhlIG1vZHVsZSBmdW5jdGlvbgogICAgICAgICAgICAvKioqKioqLyAJCV9fd2VicGFja19tb2R1bGVzX19bbW9kdWxlSWRdKG1vZHVsZSwgbW9kdWxlLmV4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pOwogICAgICAgICAgICAvKioqKioqLwogICAgICAgICAgICAvKioqKioqLyAJCS8vIFJldHVybiB0aGUgZXhwb3J0cyBvZiB0aGUgbW9kdWxlCiAgICAgICAgICAgIC8qKioqKiovIAkJcmV0dXJuIG1vZHVsZS5leHBvcnRzOwogICAgICAgICAgICAvKioqKioqLyAJfQogICAgICAgIC8qKioqKiovCiAgICAgICAgLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KICAgICAgICB2YXIgX193ZWJwYWNrX2V4cG9ydHNfXyA9IHt9OwovLyBUaGlzIGVudHJ5IG5lZWQgdG8gYmUgd3JhcHBlZCBpbiBhbiBJSUZFIGJlY2F1c2UgaXQgbmVlZCB0byBiZSBpbiBzdHJpY3QgbW9kZS4KICAgICAgICAoKCkgPT4gewogICAgICAgICAgICAidXNlIHN0cmljdCI7CiAgICAgICAgICAgIHZhciBleHBvcnRzID0gX193ZWJwYWNrX2V4cG9ydHNfXzsKCgogICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIl9fZXNNb2R1bGUiLCAoewogICAgICAgICAgICAgICAgdmFsdWU6IHRydWUKICAgICAgICAgICAgfSkpOwogICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIkFib3J0RXhjZXB0aW9uIiwgKHsKICAgICAgICAgICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgICAgICAgICBnZXQ6IGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gX3V0aWwuQWJvcnRFeGNlcHRpb247CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJBbm5vdGF0aW9uRWRpdG9yTGF5ZXIiLCAoewogICAgICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBfYW5ub3RhdGlvbl9lZGl0b3JfbGF5ZXIuQW5ub3RhdGlvbkVkaXRvckxheWVyOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9KSk7CiAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAiQW5ub3RhdGlvbkVkaXRvclBhcmFtc1R5cGUiLCAoewogICAgICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yUGFyYW1zVHlwZTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfSkpOwogICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIkFubm90YXRpb25FZGl0b3JUeXBlIiwgKHsKICAgICAgICAgICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgICAgICAgICBnZXQ6IGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gX3V0aWwuQW5ub3RhdGlvbkVkaXRvclR5cGU7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJBbm5vdGF0aW9uRWRpdG9yVUlNYW5hZ2VyIiwgKHsKICAgICAgICAgICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgICAgICAgICBnZXQ6IGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gX3Rvb2xzLkFubm90YXRpb25FZGl0b3JVSU1hbmFnZXI7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJBbm5vdGF0aW9uTGF5ZXIiLCAoewogICAgICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBfYW5ub3RhdGlvbl9sYXllci5Bbm5vdGF0aW9uTGF5ZXI7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJBbm5vdGF0aW9uTW9kZSIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF91dGlsLkFubm90YXRpb25Nb2RlOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9KSk7CiAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAiQ01hcENvbXByZXNzaW9uVHlwZSIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF91dGlsLkNNYXBDb21wcmVzc2lvblR5cGU7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJGZWF0dXJlVGVzdCIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF91dGlsLkZlYXR1cmVUZXN0OwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9KSk7CiAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAiR2xvYmFsV29ya2VyT3B0aW9ucyIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF93b3JrZXJfb3B0aW9ucy5HbG9iYWxXb3JrZXJPcHRpb25zOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9KSk7CiAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAiSW52YWxpZFBERkV4Y2VwdGlvbiIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF91dGlsLkludmFsaWRQREZFeGNlcHRpb247CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJNaXNzaW5nUERGRXhjZXB0aW9uIiwgKHsKICAgICAgICAgICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgICAgICAgICBnZXQ6IGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gX3V0aWwuTWlzc2luZ1BERkV4Y2VwdGlvbjsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfSkpOwogICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIk9QUyIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF91dGlsLk9QUzsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfSkpOwogICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIlBERkRhdGFSYW5nZVRyYW5zcG9ydCIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9hcGkuUERGRGF0YVJhbmdlVHJhbnNwb3J0OwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9KSk7CiAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAiUERGRGF0ZVN0cmluZyIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9kaXNwbGF5X3V0aWxzLlBERkRhdGVTdHJpbmc7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJQREZXb3JrZXIiLCAoewogICAgICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBfYXBpLlBERldvcmtlcjsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfSkpOwogICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIlBhc3N3b3JkUmVzcG9uc2VzIiwgKHsKICAgICAgICAgICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgICAgICAgICBnZXQ6IGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gX3V0aWwuUGFzc3dvcmRSZXNwb25zZXM7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJQZXJtaXNzaW9uRmxhZyIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF91dGlsLlBlcm1pc3Npb25GbGFnOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9KSk7CiAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAiUGl4ZWxzUGVySW5jaCIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9kaXNwbGF5X3V0aWxzLlBpeGVsc1BlckluY2g7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJSZW5kZXJpbmdDYW5jZWxsZWRFeGNlcHRpb24iLCAoewogICAgICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBfZGlzcGxheV91dGlscy5SZW5kZXJpbmdDYW5jZWxsZWRFeGNlcHRpb247CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJTVkdHcmFwaGljcyIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9zdmcuU1ZHR3JhcGhpY3M7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJVbmV4cGVjdGVkUmVzcG9uc2VFeGNlcHRpb24iLCAoewogICAgICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBfdXRpbC5VbmV4cGVjdGVkUmVzcG9uc2VFeGNlcHRpb247CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJVdGlsIiwgKHsKICAgICAgICAgICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgICAgICAgICBnZXQ6IGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gX3V0aWwuVXRpbDsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfSkpOwogICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIlZlcmJvc2l0eUxldmVsIiwgKHsKICAgICAgICAgICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgICAgICAgICBnZXQ6IGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gX3V0aWwuVmVyYm9zaXR5TGV2ZWw7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJYZmFMYXllciIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF94ZmFfbGF5ZXIuWGZhTGF5ZXI7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJidWlsZCIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9hcGkuYnVpbGQ7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJjcmVhdGVQcm9taXNlQ2FwYWJpbGl0eSIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF91dGlsLmNyZWF0ZVByb21pc2VDYXBhYmlsaXR5OwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9KSk7CiAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAiY3JlYXRlVmFsaWRBYnNvbHV0ZVVybCIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF91dGlsLmNyZWF0ZVZhbGlkQWJzb2x1dGVVcmw7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJnZXREb2N1bWVudCIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9hcGkuZ2V0RG9jdW1lbnQ7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJnZXRGaWxlbmFtZUZyb21VcmwiLCAoewogICAgICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBfZGlzcGxheV91dGlscy5nZXRGaWxlbmFtZUZyb21Vcmw7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJnZXRQZGZGaWxlbmFtZUZyb21VcmwiLCAoewogICAgICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBfZGlzcGxheV91dGlscy5nZXRQZGZGaWxlbmFtZUZyb21Vcmw7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJnZXRYZmFQYWdlVmlld3BvcnQiLCAoewogICAgICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBfZGlzcGxheV91dGlscy5nZXRYZmFQYWdlVmlld3BvcnQ7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJpc0RhdGFTY2hlbWUiLCAoewogICAgICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBfZGlzcGxheV91dGlscy5pc0RhdGFTY2hlbWU7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJpc1BkZkZpbGUiLCAoewogICAgICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBfZGlzcGxheV91dGlscy5pc1BkZkZpbGU7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJsb2FkU2NyaXB0IiwgKHsKICAgICAgICAgICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgICAgICAgICBnZXQ6IGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gX2Rpc3BsYXlfdXRpbHMubG9hZFNjcmlwdDsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfSkpOwogICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgInJlbmRlclRleHRMYXllciIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF90ZXh0X2xheWVyLnJlbmRlclRleHRMYXllcjsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfSkpOwogICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgInNldExheWVyRGltZW5zaW9ucyIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9kaXNwbGF5X3V0aWxzLnNldExheWVyRGltZW5zaW9uczsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfSkpOwogICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgInNoYWRvdyIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF91dGlsLnNoYWRvdzsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfSkpOwogICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgInVwZGF0ZVRleHRMYXllciIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF90ZXh0X2xheWVyLnVwZGF0ZVRleHRMYXllcjsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfSkpOwogICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgInZlcnNpb24iLCAoewogICAgICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBfYXBpLnZlcnNpb247CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgdmFyIF91dGlsID0gX193X3BkZmpzX3JlcXVpcmVfXygxKTsKICAgICAgICAgICAgdmFyIF9hcGkgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEzOCk7CiAgICAgICAgICAgIHZhciBfZGlzcGxheV91dGlscyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTQyKTsKICAgICAgICAgICAgdmFyIF90ZXh0X2xheWVyID0gX193X3BkZmpzX3JlcXVpcmVfXygxNjEpOwogICAgICAgICAgICB2YXIgX2Fubm90YXRpb25fZWRpdG9yX2xheWVyID0gX193X3BkZmpzX3JlcXVpcmVfXygxNjIpOwogICAgICAgICAgICB2YXIgX3Rvb2xzID0gX193X3BkZmpzX3JlcXVpcmVfXygxNDEpOwogICAgICAgICAgICB2YXIgX2Fubm90YXRpb25fbGF5ZXIgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE2Nyk7CiAgICAgICAgICAgIHZhciBfd29ya2VyX29wdGlvbnMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE0OSk7CiAgICAgICAgICAgIHZhciBfc3ZnID0gX193X3BkZmpzX3JlcXVpcmVfXygxNzApOwogICAgICAgICAgICB2YXIgX3hmYV9sYXllciA9IF9fd19wZGZqc19yZXF1aXJlX18oMTY5KTsKICAgICAgICAgICAgY29uc3QgcGRmanNWZXJzaW9uID0gJzMuNS4xMjInOwogICAgICAgICAgICBjb25zdCBwZGZqc0J1aWxkID0gJzYyMjQ2NWRjMic7CiAgICAgICAgfSkoKTsKCiAgICAgICAgLyoqKioqKi8gCXJldHVybiBfX3dlYnBhY2tfZXhwb3J0c19fOwogICAgICAgIC8qKioqKiovIH0pKCkKICAgICAgICA7Cn0pOwovLyMgc291cmNlTWFwcGluZ1VSTD1wZGYuanMubWFw",new Promise(((I,C)=>{const A=document.createElement("script");A.src=g,A.onload=function(){I({success:!0})},A.onerror=function(g){C({success:!1,error:g})},document.body.append(A)}))).then((()=>{window.pdfjsLib.GlobalWorkerOptions.workerSrc="data:text/javascript;base64,LyoqCiAqIEBsaWNzdGFydCBUaGUgZm9sbG93aW5nIGlzIHRoZSBlbnRpcmUgbGljZW5zZSBub3RpY2UgZm9yIHRoZQogKiBKYXZhU2NyaXB0IGNvZGUgaW4gdGhpcyBwYWdlCiAqCiAqIENvcHlyaWdodCAyMDIzIE1vemlsbGEgRm91bmRhdGlvbgogKgogKiBMaWNlbnNlZCB1bmRlciB0aGUgQXBhY2hlIExpY2Vuc2UsIFZlcnNpb24gMi4wICh0aGUgIkxpY2Vuc2UiKTsKICogeW91IG1heSBub3QgdXNlIHRoaXMgZmlsZSBleGNlcHQgaW4gY29tcGxpYW5jZSB3aXRoIHRoZSBMaWNlbnNlLgogKiBZb3UgbWF5IG9idGFpbiBhIGNvcHk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ZpbmlzaFdvcmtlclRhc2sodGFzaykpLCBwZGZNYW5hZ2VyLmxvYWRYZmFJbWFnZXMoKV0pOwogICAgICB9CiAgICAgIGNvbnN0IFtudW1QYWdlcywgZmluZ2VycHJpbnRzXSA9IGF3YWl0IFByb21pc2UuYWxsKFtwZGZNYW5hZ2VyLmVuc3VyZURvYygibnVtUGFnZXMiKSwgcGRmTWFuYWdlci5lbnN1cmVEb2MoImZpbmdlcnByaW50cyIpXSk7CiAgICAgIGNvbnN0IGh0bWxGb3JYZmEgPSBpc1B1cmVYZmEgPyBhd2FpdCBwZGZNYW5hZ2VyLmVuc3VyZURvYygiaHRtbEZvclhmYSIpIDogbnVsbDsKICAgICAgcmV0dXJuIHsKICAgICAgICBudW1QYWdlcywKICAgICAgICBmaW5nZXJwcmludHMsCiAgICAgICAgaHRtbEZvclhmYQogICAgICB9OwogICAgfQogICAgZnVuY3Rpb24gZ2V0UGRmTWFuYWdlcihfcmVmKSB7CiAgICAgIGxldCB7CiAgICAgICAgZGF0YSwKICAgICAgICBwYXNzd29yZCwKICAgICAgICBkaXNhYmxlQXV0b0ZldGNoLAogICAgICAgIHJhbmdlQ2h1bmtTaXplLAogICAgICAgIGxlbmd0aCwKICAgICAgICBkb2NCYXNlVXJsLAogICAgICAgIGVuYWJsZVhmYSwKICAgICAgICBldmFsdWF0b3JPcHRpb25zCiAgICAgIH0gPSBfcmVmOwogICAgICBjb25zdCBwZGZNYW5hZ2VyQXJncyA9IHsKICAgICAgICBzb3VyY2U6IG51bGwsCiAgICAgICAgZGlzYWJsZUF1dG9GZXRjaCwKICAgICAgICBkb2NCYXNlVXJsLAogICAgICAgIGRvY0lkLAogICAgICAgIGVuYWJsZVhmYSwKICAgICAgICBldmFsdWF0b3JPcHRpb25zLAogICAgICAgIGhhbmRsZXIsCiAgICAgICAgbGVuZ3RoLAogICAgICAgIHBhc3N3b3JkLAogICAgICAgIHJhbmdlQ2h1bmtTaXplCiAgICAgIH07CiAgICAgIGNvbnN0IHB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gKDAsIF91dGlsLndhcm4pKCJyZXBvcnRlZCBIVFRQIGxlbmd0aCBpcyBkaWZmZXJlbnQgZnJvbSBhY3R1YWwiKTsKICAgICAgICB9CiAgICAgICAgdHJ5IHsKICAgICAgICAgIHBkZk1hbmFnZXJBcmdzLnNvdXJjZSA9IHBkZkZpbGU7CiAgICAgICAgICBuZXdQZGZNYW5hZ2VyID0gbmV3IF9wZGZfbWFuYWdlci5Mb2NhbFBkZk1hbmFnZXIocGRmTWFuYWdlckFyZ3MpOwogICAgICAgICAgcGRmTWFuYWdlckNhcGFiaWxpdHkucmVzb2x2ZShuZXdQZGZNYW5hZ2VyKTsKICAgICAgICB9IGNhdGNoIChleCkgewogICAgICAgICAgcGRmTWFuYWdlckNhcGFiaWxpdHkucmVqZWN0KGV4KTsKICAgICAgICB9CiAgICAgICAgY2FjaGVkQ2h1bmtzID0gW107CiAgICAgIH07CiAgICAgIG5ldyBQcm9taXNlKGZ1bmN0aW9uIChyZXNvbHZlLCByZWplY3QpIHsKICAgICAgICBjb25zdCByZWFkQ2h1bmsgPSBmdW5jdGlvbiAoX3JlZjIpIHsKICAgICAgICAgIGxldCB7CiAgICAgICAgICAgIHZhbHVlLAogICAgICAgICAgICBkb25lCiAgICAgICAgICB9ID0gX3JlZjI7CiAgICAgICAgICB0cnkgewogICAgICAgICAgICBlbnN1cmVOb3RUZXJtaW5hdGVkKCk7CiAgICAgICAgICAgIGlmIChkb25lKSB7CiAgICAgICAgICAgICAgaWYgKCFuZXdQZGZNYW5hZ2VyKSB7CiAgICAgICAgICAgICAgICBmbHVzaENodW5rcygpOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBjYW5jZWxYSFJzID0gbnVsbDsKICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgIH0KICAgICAgICAgICAgbG9hZGVkICs9IHZhbHVlLmJ5dGVMZW5ndGg7CiAgICAgICAgICAgIGlmICghZnVsbFJlcXVlc3QuaXNTdHJlYW1pbmdTdXBwb3J0ZWQpIHsKICAgICAgICAgICAgICBoYW5kbGVyLnNlbmQoIkRvY1Byb2dyZXNzIiwgewogICAgICAgICAgICAgICAgbG9hZGVkLAogICAgICAgICAgICAgICAgdG90YWw6IE1hdGgubWF4KGxvYWRlZCwgZnVsbFJlcXVlc3QuY29udGVudExlbmd0aCB8fCAwKQogICAgICAgICAgICAgIH0pOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmIChuZXdQZGZNYW5hZ2VyKSB7CiAgICAgICAgICAgICAgbmV3UGRmTWFuYWdlci5zZW5kUHJvZ3Jlc3NpdmVEYXRhKHZhbHVlKTsKICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICBjYWNoZWRDaHVua3MucHVzaCh2YWx1ZSk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZnVsbFJlcXVlc3QucmVhZCgpLnRoZW4ocmVhZENodW5rLCByZWplY3QpOwogICAgICAgICAgfSBjYXRjaCAoZSkgewogICAgICAgICAgICByZWplY3QoZSk7CiAgICAgICAgICB9CiAgICAgICAgfTsKICAgICAgICBmdWxsUmVxdWVzdC5yZWFkKCkudGhlbihyZWFkQ2h1bmssIHJlamVjdCk7CiAgICAgIH0pLmNhdGNoKGZ1bmN0aW9uIChlKSB7CiAgICAgICAgcGRmTWFuYWdlckNhcGFiaWxpdHkucmVqZWN0KGUpOwogICAgICAgIGNhbmNlbFhIUnMgPSBudWxsOwogICAgICB9KTsKICAgICAgY2FuY2VsWEhScyA9IGZ1bmN0aW9uIChyZWFzb24pIHsKICAgICAgICBwZGZTdHJlYW0uY2FuY2VsQWxsUmVxdWVzdHMocmVhc29uKTsKICAgICAgfTsKICAgICAgcmV0dXJuIHBkZk1hbmFnZXJDYXBhYmlsaXR5LnByb21pc2U7CiAgICB9CiAgICBmdW5jdGlvbiBzZXR1cERvYyhkYXRhKSB7CiAgICAgIGZ1bmN0aW9uIG9uU3VjY2Vzcyhkb2MpIHsKICAgICAgICBlbnN1cmVOb3RUZXJtaW5hdGVkKCk7CiAgICAgICAgaGFuZGxlci5zZW5kKCJHZXREb2MiLCB7CiAgICAgICAgICBwZGZJbmZvOiBkb2MKICAgICAgICB9KTsKICAgICAgfQogICAgICBmdW5jdGlvbiBvbkZhaWx1cmUoZXgpIHsKICAgICAgICBlbnN1cmVOb3RUZXJtaW5hdGVkKCk7CiAgICAgICAgaWYgKGV4IGluc3RhbmNlb2YgX3V0aWwuUGFzc3dvcmRFeGNlcHRpb24pIHsKICAgICAgICAgIGNvbnN0IHRhc2sgPSBuZXcgV29ya2VyVGFzayhgUGFzc3dvcmRFeGNlcHRpb246IHJlc3BvbnNlICR7ZXguY29kZX1gKTsKICAgICAgICAgIHN0YXJ0V29ya2VyVGFzayh0YXNrKTsKICAgICAgICAgIGhhbmRsZXIuc2VuZFdpdGhQcm9taXNlKCJQYXNzd29yZFJlcXVlc3QiLCBleCkudGhlbihmdW5jdGlvbiAoX3JlZjMpIHsKICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICBwYXNzd29yZAogICAgICAgICAgICB9ID0gX3JlZjM7CiAgICAgICAgICAgIGZpbmlzaFdvcmtlclRhc2sodGFzayk7CiAgICAgICAgICAgIHBkZk1hbmFnZXIudXBkYXRlUGFzc3dvcmQocGFzc3dvcmQpOwogICAgICAgICAgICBwZGZNYW5hZ2VyUmVhZHkoKTsKICAgICAgICAgIH0pLmNhdGNoKGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgZmluaXNoV29ya2VyVGFzayh0YXNrKTsKICAgICAgICAgICAgaGFuZGxlci5zZW5kKCJEb2NFeGNlcHRpb24iLCBleCk7CiAgICAgICAgICB9KTsKICAgICAgICB9IGVsc2UgaWYgKGV4IGluc3RhbmNlb2YgX3V0aWwuSW52YWxpZFBERkV4Y2VwdGlvbiB8fCBleCBpbnN0YW5jZW9mIF91dGlsLk1pc3NpbmdQREZFeGNlcHRpb24gfHwgZXggaW5zdGFuY2VvZiBfdXRpbC5VbmV4cGVjdGVkUmVzcG9uc2VF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sKICAgICAgICAgICAgfSk7CiAgICAgICAgICB9KSk7CiAgICAgICAgfQogICAgICB9CiAgICAgIGlmIChpc1B1cmVYZmEpIHsKICAgICAgICBwcm9taXNlcy5wdXNoKHBkZk1hbmFnZXIuc2VyaWFsaXplWGZhRGF0YShhbm5vdGF0aW9uU3RvcmFnZSkpOwogICAgICB9IGVsc2UgewogICAgICAgIGZvciAobGV0IHBhZ2VJbmRleCA9IDA7IHBhZ2VJbmRleCA8IG51bVBhZ2VzOyBwYWdlSW5kZXgrKykgewogICAgICAgICAgcHJvbWlzZXMucHVzaChwZGZNYW5hZ2VyLmdldFBhZ2UocGFnZUluZGV4KS50aGVuKGZ1bmN0aW9uIChwYWdlKSB7CiAgICAgICAgICAgIGNvbnN0IHRhc2sgPSBuZXcgV29ya2VyVGFzayhgU2F2ZTogcGFnZSAke3BhZ2VJbmRleH1gKTsKICAgICAgICAgICAgcmV0dXJuIHBhZ2Uuc2F2ZShoYW5kbGVyLCB0YXNrLCBhbm5vdGF0aW9uU3RvcmFnZSkuZmluYWxseShmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgZmluaXNoV29ya2VyVGFzayh0YXNrKTsKICAgICAgICAgICAgfSk7CiAgICAgICAgICB9KSk7CiAgICAgICAgfQogICAgICB9CiAgICAgIHJldHVybiBQcm9taXNlLmFsbChwcm9taXNlcykudGhlbihmdW5jdGlvbiAoX3JlZjgpIHsKICAgICAgICBsZXQgW3N0cmVhbSwgYWNyb0Zvcm0sIGFjcm9Gb3JtUmVmLCB4cmVmLCBzdGFydFhSZWYsIC4uLnJlZnNdID0gX3JlZjg7CiAgICAgICAgbGV0IG5ld1JlZnMgPSBbXTsKICAgICAgICBsZXQgeGZhRGF0YSA9IG51bGw7CiAgICAgICAgaWYgKGlzUHVyZVhmYSkgewogICAgICAgICAgeGZhRGF0YSA9IHJlZnNbMF07CiAgICAgICAgICBpZiAoIXhmYURhdGEpIHsKICAgICAgICAgICAgcmV0dXJuIHN0cmVhbS5ieXRlczsKICAgICAgICAgIH0KICAgICAgICB9IGVsc2UgewogICAgICAgICAgbmV3UmVmcyA9IHJlZnMuZmxhdCgyKTsKICAgICAgICAgIGlmIChuZXdSZWZzLmxlbmd0aCA9PT0gMCkgewogICAgICAgICAgICByZXR1cm4gc3RyZWFtLmJ5dGVzOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBjb25zdCBuZWVkQXBwZWFyYW5jZXMgPSBhY3JvRm9ybVJlZiAmJiBhY3JvRm9ybSBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLkRpY3QgJiYgbmV3UmVmcy5zb21lKHJlZiA9PiByZWYubmVlZEFwcGVhcmFuY2VzKTsKICAgICAgICBjb25zdCB4ZmEgPSBhY3JvRm9ybSBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLkRpY3QgJiYgYWNyb0Zvcm0uZ2V0KCJYRkEiKSB8fCBudWxsOwogICAgICAgIGxldCB4ZmFEYXRhc2V0c1JlZiA9IG51bGw7CiAgICAgICAgbGV0IGhhc1hmYURhdGFzZXRzRW50cnkgPSBmYWxzZTsKICAgICAgICBpZiAoQXJyYXkuaXNBcnJheSh4ZmEpKSB7CiAgICAgICAgICBmb3IgKGxldCBpID0gMCwgaWkgPSB4ZmEubGVuZ3RoOyBpIDwgaWk7IGkgKz0gMikgewogICAgICAgICAgICBpZiAoeGZhW2ldID09PSAiZGF0YXNldHMiKSB7CiAgICAgICAgICAgICAgeGZhRGF0YXNldHNSZWYgPSB4ZmFbaSArIDFdOwogICAgICAgICAgICAgIGhhc1hmYURhdGFzZXRzRW50cnkgPSB0cnVlOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICBpZiAoeGZhRGF0YXNldHNSZWYgPT09IG51bGwpIHsKICAgICAgICAgICAgeGZhRGF0YXNldHNSZWYgPSB4cmVmLmdldE5ld1RlbXBvcmFyeVJlZigpOwogICAgICAgICAgfQogICAgICAgIH0gZWxzZSBpZiAoeGZhKSB7CiAgICAgICAgICAoMCwgX3V0aWwud2FybikoIlVuc3VwcG9ydGVkIFhGQSB0eXBlLiIpOwogICAgICAgIH0KICAgICAgICBsZXQgbmV3WHJlZkluZm8gPSBPYmplY3QuY3JlYXRlKG51bGwpOwogICAgICAgIGlmICh4cmVmLnRyYWlsZXIpIHsKICAgICAgICAgIGNvbnN0IGluZm9PYmogPSBPYmplY3QuY3JlYXRlKG51bGwpOwogICAgICAgICAgY29uc3QgeHJlZkluZm8gPSB4cmVmLnRyYWlsZXIuZ2V0KCJJbmZvIikgfHwgbnVsbDsKICAgICAgICAgIGlmICh4cmVmSW5mbyBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLkRpY3QpIHsKICAgICAgICAgICAgeHJlZkluZm8uZm9yRWFjaCgoa2V5LCB2YWx1ZSkgPT4gewogICAgICAgICAgICAgIGlmICh0eXBlb2YgdmFsdWUgPT09ICJzdHJpbmciKSB7CiAgICAgICAgICAgICAgICBpbmZvT2JqW2tleV0gPSAoMCwgX3V0aWwuc3RyaW5nVG9QREZTdHJpbmcpKHZhbHVlKTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pOwogICAgICAgICAgfQogICAgICAgICAgY29uc3QgbGFzdFhSZWZTdHJlYW1Qb3MgPSB4cmVmLmxhc3RYUmVmU3RyZWFtUG9zOwogICAgICAgICAgbmV3WHJlZkluZm8gPSB7CiAgICAgICAgICAgIHJvb3RSZWY6IHhyZWYudHJhaWxlci5nZXRSYXcoIlJvb3QiKSB8fCBudWxsLAogICAgICAgICAgICBlbmNyeXB0UmVmOiB4cmVmLnRyYWlsZXIuZ2V0UmF3KCJFbmNyeXB0IikgfHwgbnVsbCwKICAgICAgICAgICAgbmV3UmVmOiB4cmVmLmdldE5ld1RlbXBvcmFyeVJlZigpLAogICAgICAgICAgICBpbmZvUmVmOiB4cmVmLnRyYWlsZXIuZ2V0UmF3KCJJbmZvIikgfHwgbnVsbCwKICAgICAgICAgICAgaW5mbzogaW5mb09iaiwKICAgICAgICAgICAgZmlsZUlkczogeHJlZi50cmFpbGVyLmdldCgiSUQiKSB8fCBudWxsLAogICAgICAgICAgICBzdGFydFhSZWY6IGxhc3RYUmVmU3RyZWFtUG9zID09PSBudWxsID8gc3RhcnRYUmVmIDogbGFzdFhSZWZTdHJlYW1Qb3MsCiAgICAgICAgICAgIGZpbGVuYW1lCiAgICAgICAgICB9OwogICAgICAgIH0KICAgICAgICB0cnkgewogICAgICAgICAgcmV0dXJuICgwLCBfd3JpdGVyLmluY3JlbWVudGFsVXBkYXRlKSh7CiAgICAgICAgICAgIG9yaWdpbmFsRGF0YTogc3RyZWFtLmJ5dGVzLAogICAgICAgICAgICB4cmVmSW5mbzogbmV3WHJlZkluZm8sCiAgICAgICAgICAgIG5ld1JlZnMsCiAgICAgICAgICAgIHhyZWYsCiAgICAgICAgICAgIGhhc1hmYTogISF4ZmEsCiAgICAgICAgICAgIHhmYURhdGFzZXRzUmVmLAogICAgICAgICAgICBoYXNYZmFEYXRhc2V0c0VudHJ5LAogICAgICAgICAgICBuZWVkQXBwZWFyYW5jZXMsCiAgICAgICAgICAgIGFjcm9Gb3JtUmVmLAogICAgICAgICAgICBhY3JvRm9ybSwKICAgICAgICAgICAgeGZhRGF0YQogICAgICAgICAgfSk7CiAgICAgICAgfSBmaW5hbGx5IHsKICAgICAgICAgIHhyZWYucmVzZXROZXdUZW1wb3JhcnlSZWYoKTsKICAgICAgICB9CiAgICAgIH0pOwogICAgfSk7CiAgICBoYW5kbGVyLm9uKCJHZXRPcGVyYXRvckxpc3QiLCBmdW5jdGlvbiAoZGF0YSwgc2luaykgewogICAgICBjb25zdCBwYWdlSW5kZXggPSBkYXRhLnBhZ2VJbmRleDsKICAgICAgcGRmTWFuYWdlci5nZXRQYWdlKHBhZ2VJbmRleCkudGhlbihmdW5jdGlvbiAocGFnZSkgewogICAgICAgIGNvbnN0IHRhc2sgPSBuZXcgV29ya2VyVGFzayhgR2V0T3BlcmF0b3JMaXN0OiBwYWdlICR7cGFnZUluZGV4fWApOwogICAgICAgIHN0YXJ0V29ya2VyVGFzayh0YXNrKTsKICAgICAgICBjb25zdCBzdGFydCA9IHZlcmJvc2l0eSA+PSBfdXRpbC5WZXJib3NpdHlMZXZlbC5JTkZPUyA/IERhdGUubm93KCkgOiAwOwogICAgICAgIHBhZ2UuZ2V0T3BlcmF0b3JMaXN0KHsKICAgICAgICAgIGhhbmRsZXIsCiAgICAgICAgICBzaW5rLAogICAgICAgICAgdGFzaywKICAgICAgICAgIGludGVudDogZGF0YS5pbnRlbnQsCiAgICAgICAgICBjYWNoZUtleTogZGF0YS5jYWNoZUtleSwKICAgICAgICAgIGFubm90YXRpb25TdG9yYWdlOiBkYXRhLmFubm90YXRpb25TdG9yYWdlCiAgICAgICAgfSkudGhlbihmdW5jdGlvbiAob3BlcmF0b3JMaXN0SW5mbykgewogICAgICAgICAgZmluaXNoV29ya2VyVGFzayh0YXNrKTsKICAgICAgICAgIGlmIChzdGFydCkgewogICAgICAgICAgICAoMCwgX3V0aWwuaW5mbykoYHBhZ2U9JHtwYWdlSW5kZXggKyAxfSAtIGdldE9wZXJhdG9yTGlzdDogdGltZT1gICsgYCR7RGF0ZS5ub3coKSAtIHN0YXJ0fW1zLCBsZW49JHtvcGVyYXRvckxpc3RJbmZvLmxlbmd0aH1gKTsKICAgICAgICAgIH0KICAgICAgICAgIHNpbmsuY2xvc2UoKTsKICAgICAgICB9LCBmdW5jdGlvbiAocmVhc29uKSB7CiAgICAgICAgICBmaW5pc2hXb3JrZXJUYXNrKHRhc2spOwogICAgICAgICAgaWYgKHRhc2sudGVybWluYXRlZCkgewogICAgICAgICAgICByZXR1cm47CiAgICAgICAgICB9CiAgICAgICAgICBzaW5rLmVycm9yKHJlYXNvbik7CiAgICAgICAgfSk7CiAgICAgIH0pOwogICAgfSk7CiAgICBoYW5kbGVyLm9uKCJHZXRUZXh0Q29udGVudCIsIGZ1bmN0aW9uIChkYXRhLCBzaW5rKSB7CiAgICAgIGNvbnN0IHBhZ2VJbmRleCA9IGRhdGEucGFnZUluZGV4OwogICAgICBwZGZNYW5hZ2VyLmdldFBhZ2UocGFnZUluZGV4KS50aGVuKGZ1bmN0aW9uIChwYWdlKSB7CiAgICAgICAgY29uc3QgdGFzayA9IG5ldyBXb3JrZXJUYXNrKCJHZXRUZXh0Q29udGVudDogcGFnZSAiICsgcGFnZUluZGV4KTsKICAgICAgICBzdGFydFdvcmtlclRhc2sodGFzayk7CiAgICAgICAgY29uc3Qgc3RhcnQgPSB2ZXJib3NpdHkgPj0gX3V0aWwuVmVyYm9zaXR5TGV2ZWwuSU5GT1MgPyBEYXRlLm5vdygpIDogMDsKICAgICAgICBwYWdlLmV4dHJhY3RUZXh0Q29udGVudCh7CiAgICAgICAgICBoYW5kbGVyLAogICAgICAgICAgdGFzaywKICAgICAgICAgIHNpbmssCiAgICAgICAgICBpbmNsdWRlTWFya2VkQ29udGVudDogZGF0YS5pbmNsdWRlTWFya2VkQ29udGVudCwKICAgICAgICAgIGNvbWJpbmVUZXh0SXRlbXM6IGRhdGEuY29tYmluZVRleHRJdGVtcwogICAgICAgIH0pLnRoZW4oZnVuY3Rpb24gKCkgewogICAgICAgICAgZmluaXNoV29ya2VyVGFzayh0YXNrKTsKICAgICAgICAgIGlmIChzdGFydCkgewogICAgICAgICAgICAoMCwgX3V0aWwuaW5mbykoYHBhZ2U9JHtwYWdlSW5kZXggKyAxfSAtIGdldFRleHRDb250ZW50OiB0aW1lPWAgKyBgJHtEYXRlLm5vdygpIC0gc3RhcnR9bXNgKTsKICAgICAgICAgIH0KICAgICAgICAgIHNpbmsuY2xvc2UoKTsKICAgICAgICB9LCBmdW5jdGlvbiAocmVhc29uKSB7CiAgICAgICAgICBmaW5pc2hXb3JrZXJUYXNrKHRhc2spOwogICAgICAgICAgaWYgKHRhc2sudGVybWluYXRlZCkgewogICAgICAgICAgICByZXR1cm47CiAgICAgICAgICB9CiAgICAgICAgICBzaW5rLmVycm9yKHJlYXNvbik7CiAgICAgICAgfSk7CiAgICAgIH0pOwog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OwogICAgICB9CiAgICAgIG1pbk1heFswXSAqPSB0cmFuc2Zvcm1bMF07CiAgICAgIG1pbk1heFsxXSAqPSB0cmFuc2Zvcm1bMF07CiAgICAgIGlmICh0cmFuc2Zvcm1bM10gPCAwKSB7CiAgICAgICAgdGVtcCA9IG1pbk1heFsyXTsKICAgICAgICBtaW5NYXhbMl0gPSBtaW5NYXhbM107CiAgICAgICAgbWluTWF4WzNdID0gdGVtcDsKICAgICAgfQogICAgICBtaW5NYXhbMl0gKj0gdHJhbnNmb3JtWzNdOwogICAgICBtaW5NYXhbM10gKj0gdHJhbnNmb3JtWzNdOwogICAgfSBlbHNlIHsKICAgICAgdGVtcCA9IG1pbk1heFswXTsKICAgICAgbWluTWF4WzBdID0gbWluTWF4WzJdOwogICAgICBtaW5NYXhbMl0gPSB0ZW1wOwogICAgICB0ZW1wID0gbWluTWF4WzFdOwogICAgICBtaW5NYXhbMV0gPSBtaW5NYXhbM107CiAgICAgIG1pbk1heFszXSA9IHRlbXA7CiAgICAgIGlmICh0cmFuc2Zvcm1bMV0gPCAwKSB7CiAgICAgICAgdGVtcCA9IG1pbk1heFsyXTsKICAgICAgICBtaW5NYXhbMl0gPSBtaW5NYXhbM107CiAgICAgICAgbWluTWF4WzNdID0gdGVtcDsKICAgICAgfQogICAgICBtaW5NYXhbMl0gKj0gdHJhbnNmb3JtWzFdOwogICAgICBtaW5NYXhbM10gKj0gdHJhbnNmb3JtWzFdOwogICAgICBpZiAodHJhbnNmb3JtWzJdIDwgMCkgewogICAgICAgIHRlbXAgPSBtaW5NYXhbMF07CiAgICAgICAgbWluTWF4WzBdID0gbWluTWF4WzFdOwogICAgICAgIG1pbk1heFsxXSA9IHRlbXA7CiAgICAgIH0KICAgICAgbWluTWF4WzBdICo9IHRyYW5zZm9ybVsyXTsKICAgICAgbWluTWF4WzFdICo9IHRyYW5zZm9ybVsyXTsKICAgIH0KICAgIG1pbk1heFswXSArPSB0cmFuc2Zvcm1bNF07CiAgICBtaW5NYXh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IGNvbnN0IHlIaWdoID0gTWF0aC5taW4oTWF0aC5tYXgocmVjdDFbMV0sIHJlY3QxWzNdKSwgTWF0aC5tYXgocmVjdDJbMV0sIHJlY3QyWzNdKSk7CiAgICBpZiAoeUxvdyA+IHlIaWdoKSB7CiAgICAgIHJldHVybiBudWxsOwogICAgfQogICAgcmV0dXJuIFt4TG93LCB5TG93LCB4SGlnaCwgeUhpZ2hdOwogIH0KICBzdGF0aWMgYmV6aWVyQm91bmRpbmdCb3goeDAsIHkwLCB4MSwgeTEsIHgyLCB5MiwgeDMsIHkzKSB7CiAgICBjb25zdCB0dmFsdWVzID0gW10sCiAgICAgIGJvdW5kcyA9IFtbXSwgW11dOwogICAgbGV0IGEsIGIsIGMsIHQsIHQxLCB0MiwgYjJhYywgc3FydGIyYWM7CiAgICBmb3IgKGxldCBpID0gMDsgaSA8IDI7ICsraSkgewogICAgICBpZiAoaSA9PT0gMCkgewogICAgICAgIGIgPSA2ICogeDAgLSAxMiAqIHgxICsgNiAqIHgyOwogICAgICAgIGEgPSAtMyAqIHgwICsgOSAqIHgxIC0gOSAqIHgyICsgMyAqIHgzOwogICAgICAgIGMgPSAzICogeDEgLSAzICogeDA7CiAgICAgIH0gZWxzZSB7CiAgICAgICAgYiA9IDYgKiB5MCAtIDEyICogeTEgKyA2ICogeTI7CiAgICAgICAgYSA9IC0zICogeTAgKyA5ICogeTEgLSA5ICogeTIgKyAzICogeTM7CiAgICAgICAgYyA9IDMgKiB5MSAtIDMgKiB5MDsKICAgICAgfQogICAgICBpZiAoTWF0aC5hYnMoYSkgPCAxZS0xMikgewogICAgICAgIGlmIChNYXRoLmFicyhiKSA8IDFlLTEyKSB7CiAgICAgICAgICBjb250aW51ZTsKICAgICAgICB9CiAgICAgICAgdCA9IC1jIC8gYjsKICAgICAgICBpZiAoMCA8IHQgJiYgdCA8IDEpIHsKICAgICAgICAgIHR2YWx1ZXMucHVzaCh0KTsKICAgICAgICB9CiAgICAgICAgY29udGludWU7CiAgICAgIH0KICAgICAgYjJhYyA9IGIgKiBiIC0gNCAqIGMgKiBhOwogICAgICBzcXJ0YjJhYyA9IE1hdGguc3FydChiMmFjKTsKICAgICAgaWYgKGIyYWMgPCAwKSB7CiAgICAgICAgY29udGludWU7CiAgICAgIH0KICAgICAgdDEgPSAoLWIgKyBzcXJ0YjJhYykgLyAoMiAqIGEpOwogICAgICBpZiAoMCA8IHQxICYmIHQxIDwgMSkgewogICAgICAgIHR2YWx1ZXMucHVzaCh0MSk7CiAgICAgIH0KICAgICAgdDIgPSAoLWIgLSBzcXJ0YjJhYykgLyAoMiAqIGEpOwogICAgICBpZiAoMCA8IHQyICYmIHQyIDwgMSkgewogICAgICAgIHR2YWx1ZXMucHVzaCh0Mik7CiAgICAgIH0KICAgIH0KICAgIGxldCBqID0gdHZhbHVlcy5sZW5ndGgsCiAgICAgIG10OwogICAgY29uc3QgamxlbiA9IGo7CiAgICB3aGlsZSAoai0tKSB7CiAgICAgIHQgPSB0dmFsdWVzW2pdOwogICAgICBtdCA9IDEgLSB0OwogICAgICBib3VuZHNbMF1bal0gPSBtdCAqIG10ICogbXQgKiB4MCArIDMgKiBtdCAqIG10ICogdCAqIHgxICsgMyAqIG10ICogdCAqIHQgKiB4MiArIHQgKiB0ICogdCAqIHgzOwogICAgICBib3VuZHNbMV1bal0gPSBtdCAqIG10ICogbXQgKiB5MCArIDMgKiBtdCAqIG10ICogdCAqIHkxICsgMyAqIG10ICogdCAqIHQgKiB5MiArIHQgKiB0ICogdCAqIHkzOwogICAgfQogICAgYm91bmRzWzBdW2psZW5dID0geDA7CiAgICBib3VuZHNbMV1bamxlbl0gPSB5MDsKICAgIGJvdW5kc1swXVtqbGVuICsgMV0gPSB4MzsKICAgIGJvdW5kc1sxXVtqbGVuICsgMV0gPSB5MzsKICAgIGJvdW5kc1swXS5sZW5ndGggPSBib3VuZHNbMV0ubGVuZ3RoID0gamxlbiArIDI7CiAgICByZXR1cm4gW01hdGgubWluKC4uLmJvdW5kc1swXSksI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tcHR5IiwgZW1wdHlEaWN0KTsKICB9CiAgc3RhdGljIG1lcmdlKF9yZWYpIHsKICAgIGxldCB7CiAgICAgIHhyZWYsCiAgICAgIGRpY3RBcnJheSwKICAgICAgbWVyZ2VTdWJEaWN0cyA9IGZhbHNlCiAgICB9ID0gX3JlZjsKICAgIGNvbnN0IG1lcmdlZERpY3QgPSBuZXcgRGljdCh4cmVmKSwKICAgICAgcHJvcGVydGllcyA9IG5ldyBNYXAoKTsKICAgIGZvciAoY29uc3QgZGljdCBvZiBkaWN0QXJyYXkpIHsKICAgICAgaWYgKCEoZGljdCBpbnN0YW5jZW9mIERpY3QpKSB7CiAgICAgICAgY29udGludWU7CiAgICAgIH0KICAgICAgZm9yIChjb25zdCBba2V5LCB2YWx1ZV0gb2YgT2JqZWN0LmVudHJpZXMoZGljdC5fbWFwKSkgewogICAgICAgIGxldCBwcm9wZXJ0eSA9IHByb3BlcnRpZXMuZ2V0KGtleSk7CiAgICAgICAgaWYgKHByb3BlcnR5ID09PSB1bmRlZmluZWQpIHsKICAgICAgICAgIHByb3BlcnR5ID0gW107CiAgICAgICAgICBwcm9wZXJ0aWVzLnNldChrZXksIHByb3BlcnR5KTsKICAgICAgICB9IGVsc2UgaWYgKCFtZXJnZVN1YkRpY3RzIHx8ICEodmFsdWUgaW5zdGFuY2VvZiBEaWN0KSkgewogICAgICAgICAgY29udGludWU7CiAgICAgICAgfQogICAgICAgIHByb3BlcnR5LnB1c2godmFsdWUpOwogICAgICB9CiAgICB9CiAgICBmb3IgKGNvbnN0IFtuYW1lLCB2YWx1ZXNdIG9mIHByb3BlcnRpZXMpIHsKICAgICAgaWYgKHZhbHVlcy5sZW5ndGggPT09IDEgfHwgISh2YWx1ZXNbMF0gaW5zdGFuY2VvZiBEaWN0KSkgewogICAgICAgIG1lcmdlZERpY3QuX21hcFtuYW1lXSA9IHZhbHVlc1swXTsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBjb25zdCBzdWJEaWN0ID0gbmV3IERpY3QoeHJlZik7CiAgICAgIGZvciAoY29uc3QgZGljdCBvZiB2YWx1ZXMpIHsKICAgICAgICBmb3IgKGNvbnN0IFtrZXksIHZhbHVlXSBvZiBPYmplY3QuZW50cmllcyhkaWN0Ll9tYXApKSB7CiAgICAgICAgICBpZiAoc3ViRGljdC5fbWFwW2tleV0gPT09IHVuZGVmaW5lZCkgewogICAgICAgICAgICBzdWJEaWN0Ll9tYXBba2V5XSA9IHZhbHVlOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgfQogICAgICBpZiAoc3ViRGljdC5zaXplID4gMCkgewogICAgICAgIG1lcmdlZERpY3QuX21hcFtuYW1lXSA9IHN1YkRpY3Q7CiAgICAgIH0KICAgIH0KICAgIHByb3BlcnRpZXMuY2xlYXIoKTsKICAgIHJldHVybiBtZXJnZWREaWN0LnNpemUgPiAwID8gbWVyZ2VkRGljdCA6IERpY3QuZW1wdHk7CiAgfQp9CmV4cG9ydHMuRGljdCA9IERpY3Q7CmNvbnN0IFJlZiA9IGZ1bmN0aW9uIFJlZkNsb3N1cmUoKSB7CiAgbGV0IHJlZkNhY2hlID0gT2JqZWN0LmNyZWF0ZShudWxsKTsKICBjbGFzcyBSZWYgewogICAgY29uc3RydWN0b3IobnVtLCBnZW4pIHsKICAgICAgdGhpcy5udW0gPSBudW07CiAgICAgIHRoaXMuZ2VuID0gZ2VuOwogICAgfQogICAgdG9TdHJpbmcoKSB7CiAgICAgIGlmICh0aGlzLmdlbiA9PT0gMCkgewogICAgICAgIHJldHVybiBgJHt0aGlzLm51bX1SYDsKICAgICAgfQogICAgICByZXR1cm4gYCR7dGhpcy5udW19UiR7dGhpcy5nZW59YDsKICAgIH0KICAgIHN0YXRpYyBnZXQobnVtLCBnZW4pIHsKICAgICAgY29uc3Qga2V5ID0gZ2VuID09PSAwID8gYCR7bnVtfVJgIDogYCR7bnVtfVIke2dlbn1gOwogICAgICByZXR1cm4gcmVmQ2FjaGVba2V5XSB8fCAocmVmQ2FjaGV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uOwogICAgfQogICAgaWYgKGVuZCA8PSB0aGlzLnByb2dyZXNzaXZlRGF0YUxlbmd0aCkgewogICAgICByZXR1cm47CiAgICB9CiAgICBjb25zdCBiZWdpbkNodW5rID0gTWF0aC5mbG9vcihiZWdpbiAvIHRoaXMuY2h1bmtTaXplKTsKICAgIGlmIChiZWdpbkNodW5rID4gdGhpcy5udW1DaHVua3MpIHsKICAgICAgcmV0dXJuOwogICAgfQogICAgY29uc3QgZW5kQ2h1bmsgPSBNYXRoLm1pbihNYXRoLmZsb29yKChlbmQgLSAxKSAvIHRoaXMuY2h1bmtTaXplKSArIDEsIHRoaXMubnVtQ2h1bmtzKTsKICAgIGZvciAobGV0IGNodW5rID0gYmVnaW5DaHVuazsgY2h1bmsgPCBlbmRDaHVuazsgKytjaHVuaykgewogICAgICBpZiAoIXRoaXMuX2xvYWRlZENodW5rcy5oYXMoY2h1bmspKSB7CiAgICAgICAgdGhyb3cgbmV3IF9jb3JlX3V0aWxzLk1pc3NpbmdEYXRhRXhjZXB0aW9uKGJlZ2luLCBlbmQpOwogICAgICB9CiAgICB9CiAgfQogIG5leHRFbXB0eUNodW5rKGJlZ2luQ2h1bmspIHsKICAgIGNvbnN0IG51bUNodW5rcyA9IHRoaXMubnVtQ2h1bmtzOwogICAgZm9yIChsZXQgaSA9IDA7IGkgPCBudW1DaHVua3M7ICsraSkgewogICAgICBjb25zdCBjaHVuayA9IChiZWdpbkNodW5rICsgaSkgJSBudW1DaHVua3M7CiAgICAgIGlmICghdGhpcy5fbG9hZGVkQ2h1bmtzLmhhcyhjaHVuaykpIHsKICAgICAgICByZXR1cm4gY2h1bms7CiAgICAgIH0KICAgIH0KICAgIHJldHVybiBudWxsOwogIH0KICBoYXNDaHVuayhjaHVuaykgewogICAgcmV0dXJuIHRoaXMuX2xvYWRlZENodW5rcy5oYXMoY2h1bmspOwogIH0KICBnZXRCeXRlKCkgewogICAgY29uc3QgcG9zID0gdGhpcy5wb3M7CiAgICBpZiAocG9zID49IH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0aGlzKTsKICAgIH0KICAgIGxldCBjaHVua3MgPSBbXSwKICAgICAgbG9hZGVkID0gMDsKICAgIHJldHVybiBuZXcgUHJvbWlzZSgocmVzb2x2ZSwgcmVqZWN0KSA9PiB7CiAgICAgIGNvbnN0IHJlYWRDaHVuayA9IF9yZWYgPT4gewogICAgICAgIGxldCB7CiAgICAgICAgICB2YWx1ZSwKICAgICAgICAgIGRvbmUKICAgICAgICB9ID0gX3JlZjsKICAgICAgICB0cnkgewogICAgICAgICAgaWYgKGRvbmUpIHsKICAgICAgICAgICAgY29uc3QgY2h1bmtEYXRhID0gKDAsIF9jb3JlX3V0aWxzLmFycmF5QnVmZmVyc1RvQnl0ZXMpKGNodW5rcyk7CiAgICAgICAgICAgIGNodW5rcyA9IG51bGw7CiAgICAgICAgICAgIHJlc29sdmUoY2h1bmtEYXRhKTsKICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgfQogICAgICAgICAgbG9hZGVkICs9IHZhbHVlLmJ5dGVMZW5ndGg7CiAgICAgICAgICBpZiAocmFuZ2VSZWFkZXIuaXNTdHJlYW1pbmdTdXBwb3J0ZWQpIHsKICAgICAgICAgICAgdGhpcy5vblByb2dyZXNzKHsKICAgICAgICAgICAgICBsb2FkZWQKICAgICAgICAgICAgfSk7CiAgICAgICAgICB9CiAgICAgICAgICBjaHVua3MucHVzaCh2YWx1ZSk7CiAgICAgICAgICByYW5nZVJlYWRlci5yZWFkKCkudGhlbihyZWFkQ2h1bmssIHJlamVjdCk7CiAgICAgICAgfSBjYXRjaCAoZSkgewogICAgICAgICAgcmVqZWN0KGUpOwogICAgICAgIH0KICAgICAgfTsKICAgICAgcmFuZ2VSZWFkZXIucmVhZCgpLnRoZW4ocmVhZENodW5rLCByZWplY3QpOwogICAgfSkudGhlbihkYXRhID0+IHsKICAgICAgaWYgKHRoaXMuYWJvcnRlZCkgewogICAgICAgIHJldHVybjsKICAgICAgfQogICAgICB0aGlzLm9uUmVjZWl2ZURhdGEoewogICAgICAg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ICAgICAgICB9CiAgICAgIH0KICAgIH0KICAgIGNodW5rc1RvUmVxdWVzdC5zb3J0KGZ1bmN0aW9uIChhLCBiKSB7CiAgICAgIHJldHVybiBhIC0gYjsKICAgIH0pOwogICAgcmV0dXJuIHRoaXMuX3JlcXVlc3RDaHVua3MoY2h1bmtzVG9SZXF1ZXN0KTsKICB9CiAgZ3JvdXBDaHVua3MoY2h1bmtzKSB7CiAgICBjb25zdCBncm91cGVkQ2h1bmtzID0gW107CiAgICBsZXQgYmVnaW5DaHVuayA9IC0xOwogICAgbGV0IHByZXZDaHVuayA9IC0xOwogICAgZm9yIChsZXQgaSA9IDAsIGlpID0gY2h1bmtzLmxlbmd0aDsgaSA8IGlpOyArK2kpIHsKICAgICAgY29uc3QgY2h1bmsgPSBjaHVua3NbaV07CiAgICAgIGlmIChiZWdpbkNodW5rIDwgMCkgewogICAgICAgIGJlZ2luQ2h1bmsgPSBjaHVuazsKICAgICAgfQogICAgICBpZiAocHJldkNodW5rID49IDAgJiYgcHJldkNodW5rICsgMSAhPT0gY2h1bmspIHsKICAgICAgICBncm91cGVkQ2h1bmtzLnB1c2goewogICAgICAgICAgYmVnaW5DaHVuaywKICAgICAgICAgIGVuZENodW5rOiBwcmV2Q2h1bmsgKyAxCiAgICAgICAgfSk7CiAgICAgICAgYmVnaW5DaHVuayA9IGNodW5rOwogICAgICB9CiAgICAgIGlmIChpICsgMSA9PT0gY2h1bmtzLmxlbmd0aCkgewogICAgICAgIGdyb3VwZWRDaHVua3MucHVzaCh7CiAgICAgICAgICBiZWdpbkNodW5rLAogICAgICAgICAgZW5kQ2h1bms6IGNodW5rICsgMQogICAgICAgIH0pOwogICAgICB9CiAgICAgIHByZXZDaHVuayA9IGNodW5rOwogICAgfQogICAgcmV0dXJuIGdyb3VwZWRDaHVua3M7CiAgfQogIG9uUHJvZ3Jlc3MoYXJncykgewogICAgdGhpcy5tc2dIYW5kbGVyLnNlbmQoIkRvY1Byb2dyZXNzIiwgewogICAgICBsb2F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iIHRhc2s6ICIke3JlYXNvbn0iLmApOwogICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgfSkpOwogICAgICB9CiAgICAgIHJldHVybiBQcm9taXNlLmFsbChuZXdSZWZzUHJvbWlzZXMpLnRoZW4oZnVuY3Rpb24gKG5ld1JlZnMpIHsKICAgICAgICByZXR1cm4gbmV3UmVmcy5maWx0ZXIobmV3UmVmID0+ICEhbmV3UmVmKTsKICAgICAgfSk7CiAgICB9KTsKICB9CiAgbG9hZFJlc291cmNlcyhrZXlzKSB7CiAgICBpZiAoIXRoaXMucmVzb3VyY2VzUHJvbWlzZSkgewogICAgICB0aGlzLnJlc291cmNlc1Byb21pc2UgPSB0aGlzLnBkZk1hbmFnZXIuZW5zdXJlKHRoaXMsICJyZXNvdXJjZXMiKTsKICAgIH0KICAgIHJldHVybiB0aGlzLnJlc291cmNlc1Byb21pc2UudGhlbigoKSA9PiB7CiAgICAgIGNvbnN0IG9iamVjdExvYWRlciA9IG5ldyBfb2JqZWN0X2xvYWRlci5PYmplY3RMb2FkZXIodGhpcy5yZXNvdXJjZXMsIGtleXMsIHRoaXMueHJlZik7CiAgICAgIHJldHVybiBvYmplY3RMb2FkZXIubG9hZCgpOwogICAgfSk7CiAgfQogIGdldE9wZXJhdG9yTGlzdChfcmVmMikgewogICAgbGV0IHsKICAgICAgaGFuZGxlciwKICAgICAgc2luaywKICAgICAgdGFzaywKICAgICAgaW50ZW50LAogICAgICBjYWNoZUtleSwKICAgICAgYW5ub3RhdGlvblN0b3JhZ2UgPSBudWxsCiAgICB9ID0gX3JlZjI7CiAgICBjb25zdCBjb250ZW50U3RyZWFtUHJvbWlzZSA9IHRoaXMuZ2V0Q29udGVudFN0cmVhbSgpOwogICAgY29uc3QgcmVzb3VyY2VzUHJvbWlzZSA9IHRoaXMubG9hZFJlc291cmNlcyhbIkNvbG9yU3BhY2UiLCAiRXh0R1N0YXRlIiwgIkZvbnQiLCAiUGF0dGVybiIsICJQcm9wZXJ0aWVz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ub3RhdGlvblN0b3JhZ2UpKSB7CiAgICAgICAgICBvcExpc3RQcm9taXNlcy5wdXNoKGFubm90YXRpb24uZ2V0T3BlcmF0b3JMaXN0KHBhcnRpYWxFdmFsdWF0b3IsIHRhc2ssIGludGVudCwgcmVuZGVyRm9ybXMsIGFubm90YXRpb25TdG9yYWdlKS5jYXRjaChmdW5jdGlvbiAocmVhc29uKSB7CiAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKSgiZ2V0T3BlcmF0b3JMaXN0IC0gaWdub3JpbmcgYW5ub3RhdGlvbiBkYXRhIGR1cmluZyAiICsgYCIke3Rhc2submFtZX0iIHRhc2s6ICIke3JlYXNvbn0iLmApOwogICAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICAgIG9wTGlzdDogbnVsbCwKICAgICAgICAgICAgICBzZXBhcmF0ZUZvcm06IGZhbHNlLAogICAgICAgICAgICAgIHNlcGFyYXRlQ2FudmFzOiBmYWxzZQogICAgICAgICAgICB9OwogICAgICAgICAgfSkpOwogICAgICAgIH0KICAgICAgfQogICAgICByZXR1cm4gUHJvbWlzZS5hbGwob3BMaXN0UHJvbWlzZXMpLnRoZW4oZnVuY3Rpb24gKG9wTGlzdHMpIHsKICAgICAgICBsZXQgZm9ybSA9IGZhbHNlLAogICAgICAgICAgY2FudmFzID0gZmFsc2U7CiAgICAgICAgZm9yIChjb25zdCB7CiAgICAgICAgICBvcExpc3QsCiAgICAgICAgICBzZXBhcmF0ZUZvcm0sCiAgICAgICAgICBzZXBhcmF0ZUNhbnZhcwogICAgICAgIH0gb2Ygb3BMaXN0cykgewogICAgICAgICAgcGFnZU9wTGlzdC5hZGRPcExpc3Qob3BMaXN0KTsKICAgICAgICAgIGlmIChzZXBhcmF0ZUZvcm0pIHsKICAgICAgICAgICAgZm9ybSA9IHNlcGFyYXRlRm9ybTsKICAgICAgICAgIH0KICAgICAgICAgIGlmIChzZXBhcmF0ZUNhbnZhcykgewogICAgICAgICAgICBjYW52YXMgPSBzZXBhc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udGVudCAmJiBpc1Zpc2libGUpIHsKICAgICAgICBpZiAoIXBhcnRpYWxFdmFsdWF0b3IpIHsKICAgICAgICAgIHBhcnRpYWxFdmFsdWF0b3IgPSBuZXcgX2V2YWx1YXRvci5QYXJ0aWFsRXZhbHVhdG9yKHsKICAgICAgICAgICAgeHJlZjogdGhpcy54cmVmLAogICAgICAgICAgICBoYW5kbGVyLAogICAgICAgICAgICBwYWdlSW5kZXg6IHRoaXMucGFnZUluZGV4LAogICAgICAgICAgICBpZEZhY3Rvcnk6IHRoaXMuX2xvY2FsSWRGYWN0b3J5LAogICAgICAgICAgICBmb250Q2FjaGU6IHRoaXMuZm9udENhY2hlLAogICAgICAgICAgICBidWlsdEluQ01hcENhY2hlOiB0aGlzLmJ1aWx0SW5DTWFwQ2FjaGUsCiAgICAgICAgICAgIHN0YW5kYXJkRm9udERhdGFDYWNoZTogdGhpcy5zdGFuZGFyZEZvbnREYXRhQ2FjaGUsCiAgICAgICAgICAgIGdsb2JhbEltYWdlQ2FjaGU6IHRoaXMuZ2xvYmFsSW1hZ2VDYWNoZSwKICAgICAgICAgICAgb3B0aW9uczogdGhpcy5ldmFsdWF0b3JPcHRpb25zCiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgICAgdGV4dENvbnRlbnRQcm9taXNlcy5wdXNoKGFubm90YXRpb24uZXh0cmFjdFRleHRDb250ZW50KHBhcnRpYWxFdmFsdWF0b3IsIHRhc2ssIHRoaXMudmlldykuY2F0Y2goZnVuY3Rpb24gKHJlYXNvbikgewogICAgICAgICAgKDAsIF91dGlsLndhcm4pKGBnZXRBbm5vdGF0aW9uc0RhdGEgLSBpZ25vcmluZyB0ZXh0Q29udGVudCBkdXJpbmcgIiR7dGFzay5uYW1lfSIgdGFzazogIiR7cmVhc29ufSIuYCk7CiAgICAgICAgfSkpOwogICAgICB9CiAgICB9CiAgICBhd2FpdCBQcm9taXNlLmFsbCh0ZXh0Q29udGVudFByb21pc2VzKTsKICAgIHJldHVybiBhb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ydGVkQW5ub3RhdGlvbnMgPSBbXTsKICAgICAgICBsZXQgcG9wdXBBbm5vdGF0aW9uczsKICAgICAgICBmb3IgKGNvbnN0IGFubm90YXRpb24gb2YgYW5ub3RhdGlvbnMpIHsKICAgICAgICAgIGlmICghYW5ub3RhdGlvbikgewogICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgIH0KICAgICAgICAgIGlmIChhbm5vdGF0aW9uIGluc3RhbmNlb2YgX2Fubm90YXRpb24uUG9wdXBBbm5vdGF0aW9uKSB7CiAgICAgICAgICAgIGlmICghcG9wdXBBbm5vdGF0aW9ucykgewogICAgICAgICAgICAgIHBvcHVwQW5ub3RhdGlvbnMgPSBbXTsKICAgICAgICAgICAgfQogICAgICAgICAgICBwb3B1cEFubm90YXRpb25zLnB1c2goYW5ub3RhdGlvbik7CiAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgfQogICAgICAgICAgc29ydGVkQW5ub3RhdGlvbnMucHVzaChhbm5vdGF0aW9uKTsKICAgICAgICB9CiAgICAgICAgaWYgKHBvcHVwQW5ub3RhdGlvbnMpIHsKICAgICAgICAgIHNvcnRlZEFubm90YXRpb25zLnB1c2goLi4ucG9wdXBBbm5vdGF0aW9ucyk7CiAgICAgICAgfQogICAgICAgIHJldHVybiBzb3J0ZWRBbm5vdGF0aW9uczsKICAgICAgfSk7CiAgICB9KTsKICAgIHJldHVybiAoMCwgX3V0aWwuc2hhZG93KSh0aGlzLCAiX3BhcnNlZEFubm90YXRpb25zIiwgcGFyc2VkQW5ub3RhdGlvbnMpOwogIH0KICBnZXQganNBY3Rpb25zKCkgewogICAgY29uc3QgYWN0aW9ucyA9ICgwLCBfY29yZV91dGlscy5jb2xsZWN0QWN0aW9ucykodGhpcy54cmVmLCB0aGlzLnBhZ2VEaWN0LCBfdXRpbC5QYWdlQWN0aW9uRXZlbnRUeXBlKTsKICAgIHJldHVybiAoMCwgX3V0aWwuc2hhZG93KSh0aGlzLCAianNBY3Rpb25zIiwgY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ZXJ0eShuYW1lKSkgewogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGNvbnN0IGRhdGEgPSB0aGlzLnhyZWYuZmV0Y2hJZlJlZih4ZmFbaSArIDFdKTsKICAgICAgaWYgKCEoZGF0YSBpbnN0YW5jZW9mIF9iYXNlX3N0cmVhbS5CYXNlU3RyZWFtKSB8fCBkYXRhLmlzRW1wdHkpIHsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBlbnRyaWVzW25hbWVdID0gZGF0YTsKICAgIH0KICAgIHJldHVybiBlbnRyaWVzOwogIH0KICBnZXQgeGZhRGF0YXNldHMoKSB7CiAgICBjb25zdCBzdHJlYW1zID0gdGhpcy5feGZhU3RyZWFtczsKICAgIGlmICghc3RyZWFtcykgewogICAgICByZXR1cm4gKDAsIF91dGlsLnNoYWRvdykodGhpcywgInhmYURhdGFzZXRzIiwgbnVsbCk7CiAgICB9CiAgICBmb3IgKGNvbnN0IGtleSBvZiBbImRhdGFzZXRzIiwgInhkcDp4ZHAiXSkgewogICAgICBjb25zdCBzdHJlYW0gPSBzdHJlYW1zW2tleV07CiAgICAgIGlmICghc3RyZWFtKSB7CiAgICAgICAgY29udGludWU7CiAgICAgIH0KICAgICAgdHJ5IHsKICAgICAgICBjb25zdCBzdHIgPSAoMCwgX3V0aWwuc3RyaW5nVG9VVEY4U3RyaW5nKShzdHJlYW0uZ2V0U3RyaW5nKCkpOwogICAgICAgIGNvbnN0IGRhdGEgPSB7CiAgICAgICAgICBba2V5XTogc3RyCiAgICAgICAgfTsKICAgICAgICByZXR1cm4gKDAsIF91dGlsLnNoYWRvdykodGhpcywgInhmYURhdGFzZXRzIiwgbmV3IF9kYXRhc2V0X3JlYWRlci5EYXRhc2V0UmVhZGVyKGRhdGEpKTsKICAgICAgfSBjYXRjaCAoXykgewogICAgICAgICgwLCBfdXRpbC53YXJuKSgiWEZBIC0gSW52YWxpZCB1dGYtOCBzdHJpbmcuIik7CiAgICAgICAgYnJlYWs7C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b250RGF0YUNhY2hlOiB0aGlzLmNhdGFsb2cuc3RhbmRhcmRGb250RGF0YUNhY2hlLAogICAgICBvcHRpb25zCiAgICB9KTsKICAgIGNvbnN0IG9wZXJhdG9yTGlzdCA9IG5ldyBfb3BlcmF0b3JfbGlzdC5PcGVyYXRvckxpc3QoKTsKICAgIGNvbnN0IHBkZkZvbnRzID0gW107CiAgICBjb25zdCBpbml0aWFsU3RhdGUgPSB7CiAgICAgIGdldCBmb250KCkgewogICAgICAgIHJldHVybiBwZGZGb250cy5hdCgtMSk7CiAgICAgIH0sCiAgICAgIHNldCBmb250KGZvbnQpIHsKICAgICAgICBwZGZGb250cy5wdXNoKGZvbnQpOwogICAgICB9LAogICAgICBjbG9uZSgpIHsKICAgICAgICByZXR1cm4gdGhpczsKICAgICAgfQogICAgfTsKICAgIGNvbnN0IGZvbnRzID0gbmV3IE1hcCgpOwogICAgZm9udFJlcy5mb3JFYWNoKChmb250TmFtZSwgZm9udCkgPT4gewogICAgICBmb250cy5zZXQoZm9udE5hbWUsIGZvbnQpOwogICAgfSk7CiAgICBjb25zdCBwcm9taXNlcyA9IFtdOwogICAgZm9yIChjb25zdCBbZm9udE5hbWUsIGZvbnRdIG9mIGZvbnRzKSB7CiAgICAgIGNvbnN0IGRlc2NyaXB0b3IgPSBmb250LmdldCgiRm9udERlc2NyaXB0b3IiKTsKICAgICAgaWYgKCEoZGVzY3JpcHRvciBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLkRpY3QpKSB7CiAgICAgICAgY29udGludWU7CiAgICAgIH0KICAgICAgbGV0IGZvbnRGYW1pbHkgPSBkZXNjcmlwdG9yLmdldCgiRm9udEZhbWlseSIpOwogICAgICBmb250RmFtaWx5ID0gZm9udEZhbWlseS5yZXBsYWNlQWxsKC9bIF0rKFxkKS9nLCAiJDEiKTsKICAgICAgY29uc3QgZm9udFdlaWdodCA9IGRlc2NyaXB0b3IuZ2V0KCJGb250V2VpZ2h0Iik7CiAgICAgIGNvbnN0IGl0YWxpY0FuZ2xlID0gLWRlc2NyaXB0b3IuZ2V0KCJJdGFsaWNBbmdsZSIpOwogICAgICBjb25zdCBjc3NGb250SW5mbyA9IHsKICAgICAgICBmb250RmFtaWx5LAogICAgICAgIGZvbnRXZWlnaHQsCiAgICAgICAgaXRhbGljQW5nbGUKICAgICAgfTsKICAgICAgaWYgKCEoMCwgX2NvcmVfdXRpbHMudmFsaWRhdGVDU1NGb250KShjc3NGb250SW5mbykpIHsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBwcm9taXNlcy5wdXNoKHBhcnRpYWxFdmFsdWF0b3IuaGFuZGxlU2V0Rm9udChyZXNvdXJjZXMsIFtfcHJpbWl0aXZlcy5OYW1lLmdldChmb250TmFtZSksIDFdLCBudWxsLCBvcGVyYXRvckxpc3QsIHRhc2ssIGluaXRpYWxTdGF0ZSwgbnVsbCwgY3NzRm9udEluZm8pLmNhdGNoKGZ1bmN0aW9uIChyZWFzb24pIHsKICAgICAgICAoMCwgX3V0aWwud2FybikoYGxvYWRYZmFGb250czogIiR7cmVhc29ufSIuYCk7CiAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgIH0pKTsKICAgIH0KICAgIGF3YWl0IFByb21pc2UuYWxsKHByb21pc2VzKTsKICAgIGNvbnN0IG1pc3NpbmdGb250cyA9IHRoaXMueGZhRmFjdG9yeS5zZXRGb250cyhwZGZGb250cyk7CiAgICBpZiAoIW1pc3NpbmdGb250cykgewogICAgICByZXR1cm47CiAgICB9CiAgICBvcHRpb25zLmlnbm9yZUVycm9ycyA9IHRydWU7CiAgICBwcm9taXNlcy5sZW5ndGggPSAwOwogICAgcGRmRm9udHMubGVuZ3RoID0gMDsKICAgIGNvbnN0IHJlYWxseU1pc3NpbmdGb250cyA9IG5ldyBTZXQoKTsKICAgIGZvciAoY29uc3QgbWlzc2luZyBvZiBtaXNzaW5nRm9udHMpIHsKICAgICAgaWYgKCEoMCwgX3hmYV9mb250cy5nZXRYZmFGb250TmFtZSkoYCR7bWlzc2luZ30tUmVndWxhcmApKSB7CiAgICAgICAgcmVhbGx5TWlzc2luZ0ZvbnRzLmFkZChtaXNzaW5nKTsKICAgICAgfQogICAgfQogICAgaWYgKHJlYWxseU1pc3NpbmdGb250cy5zaXplKSB7CiAgICAgIG1pc3NpbmdGb250cy5wdXNoKCJQZGZKUy1GYWxsYmFjayIpOwogICAgfQogICAgZm9yIChjb25zdCBtaXNzaW5nIG9mIG1pc3NpbmdGb250cykgewogICAgICBpZiAocmVhbGx5TWlzc2luZ0ZvbnRzLmhhcyhtaXNzaW5nKSkgewogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGZvciAoY29uc3QgZm9udEluZm8gb2YgW3sKICAgICAgICBuYW1lOiAiUmVndWxhciIsCiAgICAgICAgZm9udFdlaWdodDogNDAwLAogICAgICAgIGl0YWxpY0FuZ2xlOiAwCiAgICAgIH0sIHsKICAgICAgICBuYW1lOiAiQm9sZCIsCiAgICAgICAgZm9udFdlaWdodDogNzAwLAogICAgICAgIGl0YWxpY0FuZ2xlOiAwCiAgICAgIH0sIHsKICAgICAgICBuYW1lOiAiSXRhbGljIiwKICAgICAgICBmb250V2VpZ2h0OiA0MDAsCiAgICAgICAgaXRhbGljQW5nbGU6IDEyCiAgICAgIH0sIHsKICAgICAgICBuYW1lOiAiQm9sZEl0YWxpYyIsCiAgICAgICAgZm9udFdlaWdodDogNzAwLAogICAgICAgIGl0YWxpY0FuZ2xlOiAxMgogICAgICB9XSkgewogICAgICAgIGNvbnN0IG5hbWUgPSBgJHttaXNzaW5nfS0ke2ZvbnRJbmZvLm5hbWV9YDsKICAgICAgICBjb25zdCBkaWN0ID0gKDAsIF94ZmFfZm9udHMuZ2V0WGZhRm9udERpY3QpKG5hbWUpOwogICAgICAgIHByb21pc2VzLnB1c2gocGFydGlhbEV2YWx1YXRvci5oYW5kbGVTZXRGb250KHJlc291cmNlcywgW19wcmltaXRpdmVzLk5hbWUuZ2V0KG5hbWUpLCAxXSwgbnVs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ICBpZiAoIShpbmZvRGljdCBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLkRpY3QpKSB7CiAgICAgIHJldHVybiAoMCwgX3V0aWwuc2hhZG93KSh0aGlzLCAiZG9jdW1lbnRJbmZvIiwgZG9jSW5mbyk7CiAgICB9CiAgICBmb3IgKGNvbnN0IGtleSBvZiBpbmZvRGljdC5nZXRLZXlzKCkpIHsKICAgICAgY29uc3QgdmFsdWUgPSBpbmZvRGljdC5nZXQoa2V5KTsKICAgICAgc3dpdGNoIChrZXkpIHsKICAgICAgICBjYXNlICJUaXRsZSI6CiAgICAgICAgY2FzZSAiQXV0aG9yIjoKICAgICAgICBjYXNlICJTdWJqZWN0IjoKICAgICAgICBjYXNlICJLZXl3b3JkcyI6CiAgICAgICAgY2FzZSAiQ3JlYXRvciI6CiAgICAgICAgY2FzZSAiUHJvZHVjZXIiOgogICAgICAgIGNhc2UgIkNyZWF0aW9uRGF0ZSI6CiAgICAgICAgY2FzZSAiTW9kRGF0ZSI6CiAgICAgICAgICBpZiAodHlwZW9mIHZhbHVlID09PSAic3RyaW5nIikgewogICAgICAgICAgICBkb2NJbmZvW2tleV0gPSAoMCwgX3V0aWwuc3RyaW5nVG9QREZTdHJpbmcpKHZhbHVlKTsKICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJUcmFwcGVkIjoKICAgICAgICAgIGlmICh2YWx1ZSBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLk5hbWUpIHsKICAgICAgICAgICAgZG9jSW5mb1trZXldID0gdmFsdWU7CiAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgZGVmYXVsdDoKICAgICAgICAgIGxldCBjdXN0b21WYWx1ZTsKICAgICAgICAgIHN3aXRjaCAodHlwZW9mIHZhbHVlKSB7CiAgICAgICAgICAgIGNhc2UgInN0cmluZyI6CiAgICAgICAgICAgICAgY3VzdG9tVmFsdWUgPSAoMCwgX3V0aWwuc3RyaW5nVG9QREZTdHJpbmcpKHZhbHVlKTsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSAibnVtYmVyIjoKICAgICAgICAgICAgY2FzZSAiYm9vbGVhbiI6CiAgICAgICAgICAgICAgY3VzdG9tVmFsdWUgPSB2YWx1ZTsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICBpZiAodmFsdWUgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lKSB7CiAgICAgICAgICAgICAgICBjdXN0b21WYWx1ZSA9IHZhbHVlOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgIH0KICAgICAgICAgIGlmIChjdXN0b21WYWx1ZSA9PT0gdW5kZWZpbmVkKSB7CiAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgQmFkIHZhbHVlLCBmb3IgY3VzdG9tIGtleSAiJHtrZXl9IiwgaW4gSW5mbzogJHt2YWx1ZX0uYCk7CiAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgfQogICAgICAgICAgaWYgKCFkb2NJbmZvLkN1c3RvbSkgewogICAgICAgICAgICBkb2NJbmZvLkN1c3RvbSA9IE9iamVjdC5jcmVhdGUobnVsbCk7CiAgICAgICAgICB9CiAgICAgICAgICBkb2NJbmZvLkN1c3RvbVtrZXldID0gY3VzdG9tVmFsdWU7CiAgICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICAoMCwgX3V0aWwud2FybikoYEJhZCB2YWx1ZSwgZm9yIGtleSAiJHtrZXl9IiwgaW4gSW5mbzogJHt2YWx1ZX0uYCk7CiAgICB9CiAgICByZXR1cm4gKDAsIF91dGlsLnNoYWRvdykodGhpcywgImRvY3VtZW50SW5mbyIsIGRvY0luZm8pOwogIH0KICBnZXQgZmluZ2VycHJpbnRzKCkgewogICAgZnVuY3Rpb24gdmFsa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gICB9CiAgICAgIGZvciAoY29uc3QgW3BhZ2VJbmRleCwgW3BhZ2VEaWN0LCByZWZdXSBvZiBwYWdlc1RyZWUpIHsKICAgICAgICBsZXQgcHJvbWlzZTsKICAgICAgICBpZiAocGFnZURpY3QgaW5zdGFuY2VvZiBFcnJvcikgewogICAgICAgICAgcHJvbWlzZSA9IFByb21pc2UucmVqZWN0KHBhZ2VEaWN0KTsKICAgICAgICAgIHByb21pc2UuY2F0Y2goKCkgPT4ge30pOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBwcm9taXNlID0gUHJvbWlzZS5yZXNvbHZlKG5ldyBQYWdlKHsKICAgICAgICAgICAgcGRmTWFuYWdlciwKICAgICAgICAgICAgeHJlZjogdGhpcy54cmVmLAogICAgICAgICAgICBwYWdlSW5kZXgsCiAgICAgICAgICAgIHBhZ2VEaWN0LAogICAgICAgICAgICByZWYsCiAgICAgICAgICAgIGdsb2JhbElkRmFjdG9yeTogdGhpcy5fZ2xvYmFsSWRGYWN0b3J5LAogICAgICAgICAgICBmb250Q2FjaGU6IGNhdGFsb2cuZm9udENhY2hlLAogICAgICAgICAgICBidWlsdEluQ01hcENhY2hlOiBjYXRhbG9nLmJ1aWx0SW5DTWFwQ2FjaGUsCiAgICAgICAgICAgIHN0YW5kYXJkRm9udERhdGFDYWNoZTogY2F0YWxvZy5zdGFuZGFyZEZvbnREYXRhQ2FjaGUsCiAgICAgICAgICAgIGdsb2JhbEltYWdlQ2FjaGU6IGNhdGFsb2cuZ2xvYmFsSW1hZ2VDYWNoZSwKICAgICAgICAgICAgbm9uQmxlbmRNb2Rlc1NldDogY2F0YWxvZy5ub25CbGVuZE1vZGVzU2V0LAogICAgICAgICAgICB4ZmFGYWN0b3J5OiBudWxsCiAgICAgICAgICB9KSk7CiAgICAgICAgfQogICAgICAgIHRoaXMuX3BhZ2VQcm9taXNlcy5zZXQocGFnZUluZGV4LCBwcm9taXNlKTsKICAgICAgfQogICAgICBjYXRhbG9nLnNldEFjdH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qOyBqICs9IDIpIHsKICAgICAgY29uc3QgeCA9IHF1YWRQb2ludHNbal07CiAgICAgIGNvbnN0IHkgPSBxdWFkUG9pbnRzW2ogKyAxXTsKICAgICAgbWluWCA9IE1hdGgubWluKHgsIG1pblgpOwogICAgICBtYXhYID0gTWF0aC5tYXgoeCwgbWF4WCk7CiAgICAgIG1pblkgPSBNYXRoLm1pbih5LCBtaW5ZKTsKICAgICAgbWF4WSA9IE1hdGgubWF4KHksIG1heFkpOwogICAgfQogICAgaWYgKHJlY3QgIT09IG51bGwgJiYgKG1pblggPCByZWN0WzBdIHx8IG1heFggPiByZWN0WzJdIHx8IG1pblkgPCByZWN0WzFdIHx8IG1heFkgPiByZWN0WzNdKSkgewogICAgICByZXR1cm4gbnVsbDsKICAgIH0KICAgIHF1YWRQb2ludHNMaXN0cy5wdXNoKFt7CiAgICAgIHg6IG1pblgsCiAgICAgIHk6IG1heFkKICAgIH0sIHsKICAgICAgeDogbWF4WCwKICAgICAgeTogbWF4WQogICAgfSwgewogICAgICB4OiBtaW5YLAogICAgICB5OiBtaW5ZCiAgICB9LCB7CiAgICAgIHg6IG1heFgsCiAgICAgIHk6IG1pblkKICAgIH1dKTsKICB9CiAgcmV0dXJuIHF1YWRQb2ludHNMaXN0czsKfQpmdW5jdGlvbiBnZXRUcmFuc2Zvcm1NYXRyaXgocmVjdCwgYmJveCwgbWF0cml4KSB7CiAgY29uc3QgW21pblgsIG1pblksIG1heFgsIG1heFldID0gX3V0aWwuVXRpbC5nZXRBeGlhbEFsaWduZWRCb3VuZGluZ0JveChiYm94LCBtYXRyaXgpOwogIGlmIChtaW5YID09PSBtYXhYIHx8IG1pblkgPT09IG1heFkpIHsKICAgIHJldHVybiBbMSwgMCwgMCwgMSwgcmVjdFswXSwgcmVjdFsxXV07CiAgfQogIGNvbnN0IHhSYXRpbyA9IChyZWN0WzJdIC0gcmVjdFswXSkgLyAobWF4WCAtIG1pblgpOwogIGNvbnN0IHlSYXRpbyA9IChyZWN0Wz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3IgKGxldCBpID0gMDsgaSA8IDI7IGkrKykgewogICAgICAgIGNvbnN0IG9iaiA9IGxpbmVFbmRpbmdzW2ldOwogICAgICAgIGlmIChvYmogaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lKSB7CiAgICAgICAgICBzd2l0Y2ggKG9iai5uYW1lKSB7CiAgICAgICAgICAgIGNhc2UgIk5vbmUiOgogICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICBjYXNlICJTcXVhcmUiOgogICAgICAgICAgICBjYXNlICJDaXJjbGUiOgogICAgICAgICAgICBjYXNlICJEaWFtb25kIjoKICAgICAgICAgICAgY2FzZSAiT3BlbkFycm93IjoKICAgICAgICAgICAgY2FzZSAiQ2xvc2VkQXJyb3ciOgogICAgICAgICAgICBjYXNlICJCdXR0IjoKICAgICAgICAgICAgY2FzZSAiUk9wZW5BcnJvdyI6CiAgICAgICAgICAgIGNhc2UgIlJDbG9zZWRBcnJvdyI6CiAgICAgICAgICAgIGNhc2UgIlNsYXNoIjoKICAgICAgICAgICAgICB0aGlzLmxpbmVFbmRpbmdzW2ldID0gb2JqLm5hbWU7CiAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgICgwLCBfdXRpbC53YXJuKShgSWdub3JpbmcgaW52YWxpZCBsaW5lRW5kaW5nOiAke29ian1gKTsKICAgICAgfQogICAgfQogIH0KICBzZXRSb3RhdGlvbihtaykgewogICAgdGhpcy5yb3RhdGlvbiA9IDA7CiAgICBpZiAobWsgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5EaWN0KSB7CiAgICAgIGxldCBhbmdsZSA9IG1rLmdldCgiUiIpIHx8IDA7CiAgICAgIGlmIChOdW1iZXIuaXNJbnRlZ2VyKGFuZ2xlKSAmJiBhbmdsZSAhPT0gMCkgewogICAgICAgIGFuZ2xlICU9IDM2MDsKICAgICAgICBpZiAoYW5nbGUgPCAwKSB7CiAgICAgICAgICBhbmdsZSArP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mZXIgPSBbXTsKICAgIGNvbnN0IHNpbmsgPSB7CiAgICAgIGRlc2lyZWRTaXplOiBNYXRoLkluZmluaXR5LAogICAgICByZWFkeTogdHJ1ZSwKICAgICAgZW5xdWV1ZShjaHVuaywgc2l6ZSkgewogICAgICAgIGZvciAoY29uc3QgaXRlbSBvZiBjaHVuay5pdGVtcykgewogICAgICAgICAgYnVmZmVyLnB1c2goaXRlbS5zdHIpOwogICAgICAgICAgaWYgKGl0ZW0uaGFzRU9MKSB7CiAgICAgICAgICAgIHRleHQucHVzaChidWZmZXIuam9pbigiIikpOwogICAgICAgICAgICBidWZmZXIubGVuZ3RoID0gMDsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0KICAgIH07CiAgICBhd2FpdCBldmFsdWF0b3IuZ2V0VGV4dENvbnRlbnQoewogICAgICBzdHJlYW06IHRoaXMuYXBwZWFyYW5jZSwKICAgICAgdGFzaywKICAgICAgcmVzb3VyY2VzLAogICAgICBpbmNsdWRlTWFya2VkQ29udGVudDogdHJ1ZSwKICAgICAgY29tYmluZVRleHRJdGVtczogdHJ1ZSwKICAgICAgc2luaywKICAgICAgdmlld0JveAogICAgfSk7CiAgICB0aGlzLnJlc2V0KCk7CiAgICBpZiAoYnVmZmVyLmxlbmd0aCkgewogICAgICB0ZXh0LnB1c2goYnVmZmVyLmpvaW4oIiIpKTsKICAgIH0KICAgIGlmICh0ZXh0Lmxlbmd0aCA+IDApIHsKICAgICAgdGhpcy5kYXRhLnRleHRDb250ZW50ID0gdGV4dDsKICAgIH0KICB9CiAgZ2V0RmllbGRPYmplY3QoKSB7CiAgICBpZiAodGhpcy5kYXRhLmtpZElkcykgewogICAgICByZXR1cm4gewogICAgICAgIGlkOiB0aGlzLmRhdGEuaWQsCiAgICAgICAgYWN0aW9uczogdGhpcy5kYXRhLmFjdGlvbnMsCiAgICAgICAgbmFtZTogdGhpcy5kYXRhLmZpZWxkTmFtZSwKICAgICAgICBzdHJva2VDb2xvcjogdGhpcy5kYXRhLmJvcmRlckNvbG9yLAogICAgICAgIGZpbGxDb2xvcjogdGhpcy5kYXRhLmJhY2tncm91bmRDb2xvciwKICAgICAgICB0eXBlOiAiIiwKICAgICAgICBraWRJZHM6IHRoaXMuZGF0YS5raWRJZHMsCiAgICAgICAgcGFnZTogdGhpcy5kYXRhLnBhZ2VJbmRleCwKICAgICAgICByb3RhdGlvbjogdGhpcy5yb3RhdGlvbgogICAgICB9OwogICAgfQogICAgcmV0dXJuIG51bGw7CiAgfQogIHJlc2V0KCkgewogICAgZm9yIChjb25zdCBzdHJlYW0gb2YgdGhpcy5fc3RyZWFtcykgewogICAgICBzdHJlYW0ucmVzZXQoKTsKICAgIH0KICB9CiAgX2NvbnN0cnVjdEZpZWxkTmFtZShkaWN0KSB7CiAgICBpZiAoIWRpY3QuaGFzKCJUIikgJiYgIWRpY3QuaGFzKCJQYXJlbnQiKSkgewogICAgICAoMCwgX3V0aWwud2FybikoIlVua25vd24gZmllbGQgbmFtZSwgZmFsbGluZyBiYWNrIHRvIGVtcHR5IGZpZWxkIG5hbWUuIik7CiAgICAgIHJldHVybiAiIjsKICAgIH0KICAgIGlmICghZGljdC5oYXMoIlBhcmVudCIpKSB7CiAgICAgIHJldHVybiAoMCwgX3V0aWwuc3RyaW5nVG9QREZTdHJpbmcpKGRpY3QuZ2V0KCJUIikpOwogICAgfQogICAgY29uc3QgZmllbGROYW1lID0gW107CiAgICBpZiAoZGljdC5oYXMoIlQiKSkgewogICAgICBmaWVsZE5hbWUudW5zaGlmdCgoMCwgX3V0aWwuc3RyaW5nVG9QREZTdHJpbmcpKGRpY3QuZ2V0KCJUIikpKTsKICAgIH0KICAgIGxldCBsb29wRGljdCA9IGRpY3Q7CiAgICBjb25zdCB2aXNpdGVkID0gbmV3IF9wcmltaXRpdmVzLlJlZlNldCgpOwogICAgaWYgKGRpY3Qub2JqSWQpIHsKICAgICAgdmlzaXRlZC5wdXQoZGljdC5vYmpJZCk7CiAgICB9CiAgICB3aGlsZSAobG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cyA9IHggPT4gTWF0aC5mbG9vcih4ICogMTAwKSAvIDEwMDsKICAgICAgaWYgKGxpbmVDb3VudCA9PT0gLTEpIHsKICAgICAgICBjb25zdCB0ZXh0V2lkdGggPSB0aGlzLl9nZXRUZXh0V2lkdGgodGV4dCwgZm9udCk7CiAgICAgICAgZm9udFNpemUgPSByb3VuZFdpdGhUd29EaWdpdHMoTWF0aC5taW4oaGVpZ2h0IC8gX3V0aWwuTElORV9GQUNUT1IsIHRleHRXaWR0aCA+IHdpZHRoID8gd2lkdGggLyB0ZXh0V2lkdGggOiBJbmZpbml0eSkpOwogICAgICAgIG51bWJlck9mTGluZXMgPSAxOwogICAgICB9IGVsc2UgewogICAgICAgIGNvbnN0IGxpbmVzID0gdGV4dC5zcGxpdCgvXHJcbj98XG4vKTsKICAgICAgICBjb25zdCBjYWNoZWRMaW5lcyA9IFtdOwogICAgICAgIGZvciAoY29uc3QgbGluZSBvZiBsaW5lcykgewogICAgICAgICAgY29uc3QgZW5jb2RlZCA9IGZvbnQuZW5jb2RlU3RyaW5nKGxpbmUpLmpvaW4oIiIpOwogICAgICAgICAgY29uc3QgZ2x5cGhzID0gZm9udC5jaGFyc1RvR2x5cGhzKGVuY29kZWQpOwogICAgICAgICAgY29uc3QgcG9zaXRpb25zID0gZm9udC5nZXRDaGFyUG9zaXRpb25zKGVuY29kZWQpOwogICAgICAgICAgY2FjaGVkTGluZXMucHVzaCh7CiAgICAgICAgICAgIGxpbmU6IGVuY29kZWQsCiAgICAgICAgICAgIGdseXBocywKICAgICAgICAgICAgcG9zaXRpb25zCiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgICAgY29uc3QgaXNUb29CaWcgPSBmc2l6ZSA9PiB7CiAgICAgICAgICBsZXQgdG90YWxIZWlnaHQgPSAwOwogICAgICAgICAgZm9yIChjb25zdCBjYWNoZSBvZiBjYWNoZWRMaW5lcykgewogICAgICAgICAgICBjb25zdCBjaHVua3MgPSB0aGlzLl9zcGxpdExpbmUobnVsbCwgZm9udCwgZnNpemUsIHdpZHRoLCBjYWNoZSk7CiAgICAgICAgICAgIHRvdGFsSGVpZ2h0ICs9IGNodW5rcy5sZW5ndGggKiBmc2l6ZTsKICAgICAgICAgICAgaWYgKHRvdGFsSGVpZ2h0ID4gaGVpZ2h0KSB7CiAgICAgICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICB9OwogICAgICAgIG51bWJlck9mTGluZXMgPSBNYXRoLm1heChudW1iZXJPZkxpbmVzLCBsaW5lQ291bnQpOwogICAgICAgIHdoaWxlICh0cnVlKSB7CiAgICAgICAgICBsaW5lSGVpZ2h0ID0gaGVpZ2h0IC8gbnVtYmVyT2ZMaW5lczsKICAgICAgICAgIGZvbnRTaXplID0gcm91bmRXaXRoVHdvRGlnaXRzKGxpbmVIZWlnaHQgLyBfdXRpbC5MSU5FX0ZBQ1RPUik7CiAgICAgICAgICBpZiAoaXNUb29CaWcoZm9udFNpemUpKSB7CiAgICAgICAgICAgIG51bWJlck9mTGluZXMrKzsKICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICB9CiAgICAgIH0KICAgICAgY29uc3QgewogICAgICAgIGZvbnROYW1lLAogICAgICAgIGZvbnRDb2xvcgogICAgICB9ID0gdGhpcy5kYXRhLmRlZmF1bHRBcHBlYXJhbmNlRGF0YTsKICAgICAgdGhpcy5fZGVmYXVsdEFwcGVhcmFuY2UgPSAoMCwgX2RlZmF1bHRfYXBwZWFyYW5jZS5jcmVhdGVEZWZhdWx0QXBwZWFyYW5jZSkoewogICAgICAgIGZvbnRTaXplLAogICAgICAgIGZvbnROYW1lLAogICAgICAgIGZvbnRDb2xvcgogICAgICB9KTsKICAgIH0KICAgIHJldHVybiBbdGhpcy5fZGVmYXVsdEFwcGVhcmFuY2UsIGZvbnRTaXplLCBoZWlnaHQgLyBudW1iZXJ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rcy5wdXNoKGxpbmUuc3Vic3RyaW5nKHN0YXJ0Q2h1bmssIHN0YXJ0KSk7CiAgICAgICAgICBzdGFydENodW5rID0gc3RhcnQ7CiAgICAgICAgICBjdXJyZW50V2lkdGggPSBnbHlwaFdpZHRoOwogICAgICAgICAgbGFzdFNwYWNlUG9zSW5TdHJpbmdTdGFydCA9IC0xOwogICAgICAgICAgbGFzdFNwYWNlUG9zID0gLTE7CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIGN1cnJlbnRXaWR0aCArPSBnbHlwaFdpZHRoOwogICAgICAgICAgbGFzdFNwYWNlUG9zSW5TdHJpbmdTdGFydCA9IHN0YXJ0OwogICAgICAgICAgbGFzdFNwYWNlUG9zSW5TdHJpbmdFbmQgPSBlbmQ7CiAgICAgICAgICBsYXN0U3BhY2VQb3MgPSBpOwogICAgICAgIH0KICAgICAgfSBlbHNlIHsKICAgICAgICBpZiAoY3VycmVudFdpZHRoICsgZ2x5cGhXaWR0aCA+IHdpZHRoKSB7CiAgICAgICAgICBpZiAobGFzdFNwYWNlUG9zSW5TdHJpbmdTdGFydCAhPT0gLTEpIHsKICAgICAgICAgICAgY2h1bmtzLnB1c2gobGluZS5zdWJzdHJpbmcoc3RhcnRDaHVuaywgbGFzdFNwYWNlUG9zSW5TdHJpbmdFbmQpKTsKICAgICAgICAgICAgc3RhcnRDaHVuayA9IGxhc3RTcGFjZVBvc0luU3RyaW5nRW5kOwogICAgICAgICAgICBpID0gbGFzdFNwYWNlUG9zICsgMTsKICAgICAgICAgICAgbGFzdFNwYWNlUG9zSW5TdHJpbmdTdGFydCA9IC0xOwogICAgICAgICAgICBjdXJyZW50V2lkdGggPSAwOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgY2h1bmtzLnB1c2gobGluZS5zdWJzdHJpbmcoc3RhcnRDaHVuaywgc3RhcnQpKTsKICAgICAgICAgICAgc3RhcnRDaHVuayA9IHN0YXJ0OwogICAgICAgICAgICBjdXJyZW50V2lkdG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SwKICAgICAgICBwb2ludHNDYWxsYmFjazogKGJ1ZmZlciwgcG9pbnRzKSA9PiB7CiAgICAgICAgICBjb25zdCB4ID0gcG9pbnRzWzJdLnggKyB0aGlzLmJvcmRlclN0eWxlLndpZHRoIC8gMjsKICAgICAgICAgIGNvbnN0IHkgPSBwb2ludHNbMl0ueSArIHRoaXMuYm9yZGVyU3R5bGUud2lkdGggLyAyOwogICAgICAgICAgY29uc3Qgd2lkdGggPSBwb2ludHNbM10ueCAtIHBvaW50c1syXS54IC0gdGhpcy5ib3JkZXJTdHlsZS53aWR0aDsKICAgICAgICAgIGNvbnN0IGhlaWdodCA9IHBvaW50c1sxXS55IC0gcG9pbnRzWzNdLnkgLSB0aGlzLmJvcmRlclN0eWxlLndpZHRoOwogICAgICAgICAgYnVmZmVyLnB1c2goYCR7eH0gJHt5fSAke3dpZHRofSAke2hlaWdodH0gcmVgKTsKICAgICAgICAgIGlmIChmaWxsQ29sb3IpIHsKICAgICAgICAgICAgYnVmZmVyLnB1c2goIkIiKTsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIGJ1ZmZlci5wdXNoKCJTIik7CiAgICAgICAgICB9CiAgICAgICAgICByZXR1cm4gW3BvaW50c1swXS54LCBwb2ludHNbMV0ueCwgcG9pbnRzWzNdLnksIHBvaW50c1sxXS55XTsKICAgICAgICB9CiAgICAgIH0pOwogICAgfQogIH0KfQpjbGFzcyBDaXJjbGVBbm5vdGF0aW9uIGV4dGVuZHMgTWFya3VwQW5ub3RhdGlvbiB7CiAgY29uc3RydWN0b3IocGFyYW1zKSB7CiAgICBzdXBlcihwYXJhbXMpOwogICAgY29uc3QgewogICAgICBkaWN0LAogICAgICB4cmVmCiAgICB9ID0gcGFyYW1zOwogICAgdGhpcy5kYXRhLmFubm90YXRpb25UeXBlID0gX3V0aWwuQW5ub3RhdGlvblR5cGUuQ0lSQ0xFOwogICAgaWYgKCF0aGlzLmFwcGVhcmFuY2UpIHsKICAgICAgY29uc3Qgc3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AgICBjb25zdCBzdHJva2VBbHBoYSA9IGRpY3QuZ2V0KCJDQSIpOwogICAgICBjb25zdCBib3JkZXJXaWR0aCA9IHRoaXMuYm9yZGVyU3R5bGUud2lkdGggfHwgMSwKICAgICAgICBib3JkZXJBZGp1c3QgPSAyICogYm9yZGVyV2lkdGg7CiAgICAgIGNvbnN0IGJib3ggPSBbSW5maW5pdHksIEluZmluaXR5LCAtSW5maW5pdHksIC1JbmZpbml0eV07CiAgICAgIGZvciAoY29uc3QgdmVydGV4IG9mIHRoaXMuZGF0YS52ZXJ0aWNlcykgewogICAgICAgIGJib3hbMF0gPSBNYXRoLm1pbihiYm94WzBdLCB2ZXJ0ZXgueCAtIGJvcmRlckFkanVzdCk7CiAgICAgICAgYmJveFsxXSA9IE1hdGgubWluKGJib3hbMV0sIHZlcnRleC55IC0gYm9yZGVyQWRqdXN0KTsKICAgICAgICBiYm94WzJdID0gTWF0aC5tYXgoYmJveFsyXSwgdmVydGV4LnggKyBib3JkZXJBZGp1c3QpOwogICAgICAgIGJib3hbM10gPSBNYXRoLm1heChiYm94WzNdLCB2ZXJ0ZXgueSArIGJvcmRlckFkanVzdCk7CiAgICAgIH0KICAgICAgaWYgKCFfdXRpbC5VdGlsLmludGVyc2VjdCh0aGlzLnJlY3RhbmdsZSwgYmJveCkpIHsKICAgICAgICB0aGlzLnJlY3RhbmdsZSA9IGJib3g7CiAgICAgIH0KICAgICAgdGhpcy5fc2V0RGVmYXVsdEFwcGVhcmFuY2UoewogICAgICAgIHhyZWYsCiAgICAgICAgZXh0cmE6IGAke2JvcmRlcldpZHRofSB3YCwKICAgICAgICBzdHJva2VDb2xvciwKICAgICAgICBzdHJva2VBbHBoYSwKICAgICAgICBwb2ludHNDYWxsYmFjazogKGJ1ZmZlciwgcG9pbnRzKSA9PiB7CiAgICAgICAgICBjb25zdCB2ZXJ0aWNlcyA9IHRoaXMuZGF0YS52ZXJ0aWNlczsKICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBpaSA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BpbmtMaXN0cykgewogICAgICAgICAgYmJveFswXSA9IE1hdGgubWluKGJib3hbMF0sIHZlcnRleC54IC0gYm9yZGVyQWRqdXN0KTsKICAgICAgICAgIGJib3hbMV0gPSBNYXRoLm1pbihiYm94WzFdLCB2ZXJ0ZXgueSAtIGJvcmRlckFkanVzdCk7CiAgICAgICAgICBiYm94WzJdID0gTWF0aC5tYXgoYmJveFsyXSwgdmVydGV4LnggKyBib3JkZXJBZGp1c3QpOwogICAgICAgICAgYmJveFszXSA9IE1hdGgubWF4KGJib3hbM10sIHZlcnRleC55ICsgYm9yZGVyQWRqdXN0KTsKICAgICAgICB9CiAgICAgIH0KICAgICAgaWYgKCFfdXRpbC5VdGlsLmludGVyc2VjdCh0aGlzLnJlY3RhbmdsZSwgYmJveCkpIHsKICAgICAgICB0aGlzLnJlY3RhbmdsZSA9IGJib3g7CiAgICAgIH0KICAgICAgdGhpcy5fc2V0RGVmYXVsdEFwcGVhcmFuY2UoewogICAgICAgIHhyZWYsCiAgICAgICAgZXh0cmE6IGAke2JvcmRlcldpZHRofSB3YCwKICAgICAgICBzdHJva2VDb2xvciwKICAgICAgICBzdHJva2VBbHBoYSwKICAgICAgICBwb2ludHNDYWxsYmFjazogKGJ1ZmZlciwgcG9pbnRzKSA9PiB7CiAgICAgICAgICBmb3IgKGNvbnN0IGlua0xpc3Qgb2YgdGhpcy5kYXRhLmlua0xpc3RzKSB7CiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBpaSA9IGlua0xpc3QubGVuZ3RoOyBpIDwgaWk7IGkrKykgewogICAgICAgICAgICAgIGJ1ZmZlci5wdXNoKGAke2lua0xpc3RbaV0ueH0gJHtpbmtMaXN0W2ldLnl9ICR7aSA9PT0gMCA/ICJtIiA6ICJsIn1gKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBidWZmZXIucHVzaCgiUyIpOwogICAgICAgICAgfQogICAgICAgICAgcmV0dXJuIFtwb2ludHNbMF0ueCwgcG9pbnRzWzFdLng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yYW1zKSB7CiAgICBjb25zdCB7CiAgICAgIGNvbG9yLAogICAgICByZWN0LAogICAgICByb3RhdGlvbiwKICAgICAgcGF0aHMsCiAgICAgIHRoaWNrbmVzcywKICAgICAgb3BhY2l0eQogICAgfSA9IGFubm90YXRpb247CiAgICBjb25zdCBbeDEsIHkxLCB4MiwgeTJdID0gcmVjdDsKICAgIGxldCB3ID0geDIgLSB4MTsKICAgIGxldCBoID0geTIgLSB5MTsKICAgIGlmIChyb3RhdGlvbiAlIDE4MCAhPT0gMCkgewogICAgICBbdywgaF0gPSBbaCwgd107CiAgICB9CiAgICBjb25zdCBhcHBlYXJhbmNlQnVmZmVyID0gW2Ake3RoaWNrbmVzc30gdyAxIEogMSBqYCwgYCR7KDAsIF9kZWZhdWx0X2FwcGVhcmFuY2UuZ2V0UGRmQ29sb3IpKGNvbG9yLCBmYWxzZSl9YF07CiAgICBpZiAob3BhY2l0eSAhPT0gMSkgewogICAgICBhcHBlYXJhbmNlQnVmZmVyLnB1c2goIi9SMCBncyIpOwogICAgfQogICAgY29uc3QgYnVmZmVyID0gW107CiAgICBmb3IgKGNvbnN0IHsKICAgICAgYmV6aWVyCiAgICB9IG9mIHBhdGhzKSB7CiAgICAgIGJ1ZmZlci5sZW5ndGggPSAwOwogICAgICBidWZmZXIucHVzaChgJHsoMCwgX2NvcmVfdXRpbHMubnVtYmVyVG9TdHJpbmcpKGJlemllclswXSl9ICR7KDAsIF9jb3JlX3V0aWxzLm51bWJlclRvU3RyaW5nKShiZXppZXJbMV0pfSBtYCk7CiAgICAgIGZvciAobGV0IGkgPSAyLCBpaSA9IGJlemllci5sZW5ndGg7IGkgPCBpaTsgaSArPSA2KSB7CiAgICAgICAgY29uc3QgY3VydmUgPSBiZXppZXIuc2xpY2UoaSwgaSArIDYpLm1hcChfY29yZV91dGlscy5udW1iZXJUb1N0cmluZykuam9pbigiICIpOwogICAgICAgIGJ1ZmZlci5wdXNoKGAke2N1cnZlfSBjYCk7CiAgICAgIH0KICA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dGlvbiB7CiAgY29uc3RydWN0b3IocGFyYW1zKSB7CiAgICBzdXBlcihwYXJhbXMpOwogICAgY29uc3QgewogICAgICBkaWN0LAogICAgICB4cmVmCiAgICB9ID0gcGFyYW1zOwogICAgdGhpcy5kYXRhLmFubm90YXRpb25UeXBlID0gX3V0aWwuQW5ub3RhdGlvblR5cGUuU1FVSUdHTFk7CiAgICBjb25zdCBxdWFkUG9pbnRzID0gdGhpcy5kYXRhLnF1YWRQb2ludHMgPSBnZXRRdWFkUG9pbnRzKGRpY3QsIG51bGwpOwogICAgaWYgKHF1YWRQb2ludHMpIHsKICAgICAgaWYgKCF0aGlzLmFwcGVhcmFuY2UpIHsKICAgICAgICBjb25zdCBzdHJva2VDb2xvciA9IHRoaXMuY29sb3IgPyBnZXRQZGZDb2xvckFycmF5KHRoaXMuY29sb3IpIDogWzAsIDAsIDBdOwogICAgICAgIGNvbnN0IHN0cm9rZUFscGhhID0gZGljdC5nZXQoIkNBIik7CiAgICAgICAgdGhpcy5fc2V0RGVmYXVsdEFwcGVhcmFuY2UoewogICAgICAgICAgeHJlZiwKICAgICAgICAgIGV4dHJhOiAiW10gMCBkIDEgdyIsCiAgICAgICAgICBzdHJva2VDb2xvciwKICAgICAgICAgIHN0cm9rZUFscGhhLAogICAgICAgICAgcG9pbnRzQ2FsbGJhY2s6IChidWZmZXIsIHBvaW50cykgPT4gewogICAgICAgICAgICBjb25zdCBkeSA9IChwb2ludHNbMF0ueSAtIHBvaW50c1syXS55KSAvIDY7CiAgICAgICAgICAgIGxldCBzaGlmdCA9IGR5OwogICAgICAgICAgICBsZXQgeCA9IHBvaW50c1syXS54OwogICAgICAgICAgICBjb25zdCB5ID0gcG9pbnRzWzJdLnk7CiAgICAgICAgICAgIGNvbnN0IHhFbmQgPSBwb2ludHNbM10ueDsKICAgICAgICAgICAgYnVmZmVyLnB1c2goYCR7eH0gJHt5ICsgc2hpZnR9IG1gKTsKICAgICAgICAgICAgZG8gewogICAgICAgICAgICAgIHggK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X3V0aWwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDIpOwp2YXIgX2NvbG9yc3BhY2UgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE0OCk7CnZhciBfZXZhbHVhdG9yID0gX193X3BkZmpzX3JlcXVpcmVfXygxNDkpOwp2YXIgX3N0cmVhbSA9IF9fd19wZGZqc19yZXF1aXJlX18oMTQ0KTsKY2xhc3MgRGVmYXVsdEFwcGVhcmFuY2VFdmFsdWF0b3IgZXh0ZW5kcyBfZXZhbHVhdG9yLkV2YWx1YXRvclByZXByb2Nlc3NvciB7CiAgY29uc3RydWN0b3Ioc3RyKSB7CiAgICBzdXBlcihuZXcgX3N0cmVhbS5TdHJpbmdTdHJlYW0oc3RyKSk7CiAgfQogIHBhcnNlKCkgewogICAgY29uc3Qgb3BlcmF0aW9uID0gewogICAgICBmbjogMCwKICAgICAgYXJnczogW10KICAgIH07CiAgICBjb25zdCByZXN1bHQgPSB7CiAgICAgIGZvbnRTaXplOiAwLAogICAgICBmb250TmFtZTogIiIsCiAgICAgIGZvbnRDb2xvcjogbmV3IFVpbnQ4Q2xhbXBlZEFycmF5KDMpCiAgICB9OwogICAgdHJ5IHsKICAgICAgd2hpbGUgKHRydWUpIHsKICAgICAgICBvcGVyYXRpb24uYXJncy5sZW5ndGggPSAwOwogICAgICAgIGlmICghdGhpcy5yZWFkKG9wZXJhdGlvbikpIHsKICAgICAgICAgIGJyZWFrOwogICAgICAgIH0KICAgICAgICBpZiAodGhpcy5zYXZlZFN0YXRlc0RlcHRoICE9PSAwKSB7CiAgICAgICAgICBjb250aW51ZTsKICAgICAgICB9CiAgICAgICAgY29uc3QgewogICAgICAgICAgZm4sCiAgICAgICAgICBhcmdzCiAgICAgICAgfSA9IG9wZXJhdGlvbjsKICAgICAgICBzd2l0Y2ggKGZuIHwgMCkgewogICAgICAgICAgY2FzZSBfdXRpbC5PUFMuc2V0Rm9udDoKICAgICAgICAgICAgY29uc3QgW2ZvbnROYW1lLCBmb250U2l6ZV0gPSBhcmdzOwogICAgICAgICAgICBpZiAoZm9udE5hbWUgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lKSB7CiAgICAgICAgICAgICAgcmVzdWx0LmZvbnROYW1lID0gZm9udE5hbWUubmFtZTsKICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAodHlwZW9mIGZvbnRTaXplID09PSAibnVtYmVyIiAmJiBmb250U2l6ZSA+IDApIHsKICAgICAgICAgICAgICByZXN1bHQuZm9udFNpemUgPSBmb250U2l6ZTsKICAgICAgICAgICAgfQogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnNldEZpbGxSR0JDb2xvcjoKICAgICAgICAgICAgX2NvbG9yc3BhY2UuQ29sb3JTcGFjZS5zaW5nbGV0b25zLnJnYi5nZXRSZ2JJdGVtKGFyZ3MsIDAsIHJlc3VsdC5mb250Q29sb3IsIDApOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnNldEZpbGxHcmF5OgogICAgICAgICAgICBfY29sb3JzcGFjZS5Db2xvclNwYWNlLnNpbmdsZXRvbnMuZ3JheS5nZXRSZ2JJdGVtKGFyZ3MsIDAsIHJlc3VsdC5mb250Q29sb3IsIDApOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnNldEZpbGxDb2xvclNwYWNlOgogICAgICAgICAgICBfY29sb3JzcGFjZS5Db2xvclNwYWNlLnNpbmdsZXRvbnMuY215ay5nZXRSZ2JJdGVtKGFyZ3MsIDAsIHJlc3VsdC5mb250Q29sb3IsIDApOwogICAgICAgICAgICBicmVhazsKICAgICAgICB9CiAgICAgIH0KICAgIH0gY2F0Y2ggKHJlYXNvbikgewogICAgICAoMCwgX3V0aWwud2FybikoYHBhcnNlRGVmYXVsdEFwcGVhcmFuY2UgLSBpZ25vcmluZyBlcnJvcnM6ICIke3JlYXNvbn0iLmApOwogICAgfQogICAgcmV0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RoID0gY3R4Lm1lYXN1cmVUZXh0KGxpbmUpLndpZHRoOwogICAgICBtYXhXaWR0aCA9IE1hdGgubWF4KG1heFdpZHRoLCBsaW5lV2lkdGgpOwogICAgICBmb3IgKGNvbnN0IGNoYXIgb2YgbGluZS5zcGxpdCgiIikpIHsKICAgICAgICBjb25zdCBjb2RlID0gY2hhci5jaGFyQ29kZUF0KDApOwogICAgICAgIGxldCB3aWR0aCA9IHRoaXMud2lkdGhzLmdldChjb2RlKTsKICAgICAgICBpZiAod2lkdGggPT09IHVuZGVmaW5lZCkgewogICAgICAgICAgY29uc3QgbWV0cmljcyA9IGN0eC5tZWFzdXJlVGV4dChjaGFyKTsKICAgICAgICAgIHdpZHRoID0gTWF0aC5jZWlsKG1ldHJpY3Mud2lkdGgpOwogICAgICAgICAgdGhpcy53aWR0aHMuc2V0KGNvZGUsIHdpZHRoKTsKICAgICAgICAgIHRoaXMuZmlyc3RDaGFyID0gTWF0aC5taW4oY29kZSwgdGhpcy5maXJzdENoYXIpOwogICAgICAgICAgdGhpcy5sYXN0Q2hhciA9IE1hdGgubWF4KGNvZGUsIHRoaXMubGFzdENoYXIpOwogICAgICAgIH0KICAgICAgfQogICAgfQogICAgbWF4V2lkdGggKj0gZm9udFNpemUgLyAxMDAwOwogICAgY29uc3QgW3gxLCB5MSwgeDIsIHkyXSA9IHJlY3Q7CiAgICBsZXQgdyA9IHgyIC0geDE7CiAgICBsZXQgaCA9IHkyIC0geTE7CiAgICBpZiAocm90YXRpb24gJSAxODAgIT09IDApIHsKICAgICAgW3csIGhdID0gW2gsIHddOwogICAgfQogICAgbGV0IGhzY2FsZSA9IDE7CiAgICBpZiAobWF4V2lkdGggPiB3KSB7CiAgICAgIGhzY2FsZSA9IHcgLyBtYXhXaWR0aDsKICAgIH0KICAgIGxldCB2c2NhbGUgPSAxOwogICAgY29uc3QgbGluZUhlaWdodCA9IF91dGlsLkxJTkVfRkFDVE9SICogZm9udFNpemU7CiAgICBjb25zdCBsaW5lRG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dXJuIG5ldyBQYXR0ZXJuQ1MobnVsbCk7CiAgICAgICAgZGVmYXVsdDoKICAgICAgICAgIGlmIChyZXNvdXJjZXMgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5EaWN0KSB7CiAgICAgICAgICAgIGNvbnN0IGNvbG9yU3BhY2VzID0gcmVzb3VyY2VzLmdldCgiQ29sb3JTcGFjZSIpOwogICAgICAgICAgICBpZiAoY29sb3JTcGFjZXMgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5EaWN0KSB7CiAgICAgICAgICAgICAgY29uc3QgcmVzb3VyY2VzQ1MgPSBjb2xvclNwYWNlcy5nZXQoY3MubmFtZSk7CiAgICAgICAgICAgICAgaWYgKHJlc291cmNlc0NTKSB7CiAgICAgICAgICAgICAgICBpZiAocmVzb3VyY2VzQ1MgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lKSB7CiAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9wYXJzZShyZXNvdXJjZXNDUywgeHJlZiwgcmVzb3VyY2VzLCBwZGZGdW5jdGlvbkZhY3RvcnkpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY3MgPSByZXNvdXJjZXNDUzsKICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKGBVbnJlY29nbml6ZWQgQ29sb3JTcGFjZTogJHtjcy5uYW1lfWApOwogICAgICB9CiAgICB9CiAgICBpZiAoQXJyYXkuaXNBcnJheShjcykpIHsKICAgICAgY29uc3QgbW9kZSA9IHhyZWYuZmV0Y2hJZlJlZihjc1swXSkubmFtZTsKICAgICAgbGV0IHBhcmFtcywgbnVtQ29tcHMsIGJhc2VDUywgd2hpdGVQb2ludCwgYmxhY2tQb2ludCwgZ2FtbWE7CiAgICAgIHN3aXRjaCAobW9kZSkgewogICAgICAgIGNhc2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b2ludCwgZ2FtbWEsIG1hdHJpeCk7CiAgICAgICAgY2FzZSAiSUNDQmFzZWQiOgogICAgICAgICAgY29uc3Qgc3RyZWFtID0geHJlZi5mZXRjaElmUmVmKGNzWzFdKTsKICAgICAgICAgIGNvbnN0IGRpY3QgPSBzdHJlYW0uZGljdDsKICAgICAgICAgIG51bUNvbXBzID0gZGljdC5nZXQoIk4iKTsKICAgICAgICAgIGNvbnN0IGFsdCA9IGRpY3QuZ2V0KCJBbHRlcm5hdGUiKTsKICAgICAgICAgIGlmIChhbHQpIHsKICAgICAgICAgICAgY29uc3QgYWx0Q1MgPSB0aGlzLl9wYXJzZShhbHQsIHhyZWYsIHJlc291cmNlcywgcGRmRnVuY3Rpb25GYWN0b3J5KTsKICAgICAgICAgICAgaWYgKGFsdENTLm51bUNvbXBzID09PSBudW1Db21wcykgewogICAgICAgICAgICAgIHJldHVybiBhbHRDUzsKICAgICAgICAgICAgfQogICAgICAgICAgICAoMCwgX3V0aWwud2FybikoIklDQ0Jhc2VkIGNvbG9yIHNwYWNlOiBJZ25vcmluZyBpbmNvcnJlY3QgL0FsdGVybmF0ZSBlbnRyeS4iKTsKICAgICAgICAgIH0KICAgICAgICAgIGlmIChudW1Db21wcyA9PT0gMSkgewogICAgICAgICAgICByZXR1cm4gdGhpcy5zaW5nbGV0b25zLmdyYXk7CiAgICAgICAgICB9IGVsc2UgaWYgKG51bUNvbXBzID09PSAzKSB7CiAgICAgICAgICAgIHJldHVybiB0aGlzLnNpbmdsZXRvbnMucmdiOwogICAgICAgICAgfSBlbHNlIGlmIChudW1Db21wcyA9PT0gNCkgewogICAgICAgICAgICByZXR1cm4gdGhpcy5zaW5nbGV0b25zLmNteWs7CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJQYXR0ZXJuIjoKICAgICAgICAgIGJhc2VDUyA9IGNzWzFdIHx8IG51bGw7CiAgICAgICAgICBpZiAoYmFzZUNTKSB7CiAgICAgICAgICAgIGJhc2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GlmdCgpOwogICAgICBjb25zdCBncmFwaGljU3RhdGVzID0gbm9kZS5nZXQoIkV4dEdTdGF0ZSIpOwogICAgICBpZiAoZ3JhcGhpY1N0YXRlcyBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLkRpY3QpIHsKICAgICAgICBmb3IgKGxldCBncmFwaGljU3RhdGUgb2YgZ3JhcGhpY1N0YXRlcy5nZXRSYXdWYWx1ZXMoKSkgewogICAgICAgICAgaWYgKGdyYXBoaWNTdGF0ZSBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLlJlZikgewogICAgICAgICAgICBpZiAocHJvY2Vzc2VkLmhhcyhncmFwaGljU3RhdGUpKSB7CiAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICBncmFwaGljU3RhdGUgPSB4cmVmLmZldGNoKGdyYXBoaWNTdGF0ZSk7CiAgICAgICAgICAgIH0gY2F0Y2ggKGV4KSB7CiAgICAgICAgICAgICAgcHJvY2Vzc2VkLnB1dChncmFwaGljU3RhdGUpOwogICAgICAgICAgICAgICgwLCBfdXRpbC5pbmZvKShgaGFzQmxlbmRNb2RlcyAtIGlnbm9yaW5nIEV4dEdTdGF0ZTogIiR7ZXh9Ii5gKTsKICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgICAgaWYgKCEoZ3JhcGhpY1N0YXRlIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuRGljdCkpIHsKICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICB9CiAgICAgICAgICBpZiAoZ3JhcGhpY1N0YXRlLm9iaklkKSB7CiAgICAgICAgICAgIHByb2Nlc3NlZC5wdXQoZ3JhcGhpY1N0YXRlLm9iaklkKTsKICAgICAgICAgIH0KICAgICAgICAgIGNvbnN0IGJtID0gZ3JhcGhpY1N0YXRlLmdldCgiQk0iKTsKICAgICAgICAgIGlmIChibSBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLk5hbWUpIHsKICAgICAgICAgICAgaWYgKGJtLm5hbWUgIT09ICJOb3JtYWwiKSB7CiAgICAgICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICB9CiAgICAgICAgICBpZiAoYm0gIT09IHVuZGVmaW5lZCAmJiBBcnJheS5pc0FycmF5KGJtKSkgewogICAgICAgICAgICBmb3IgKGNvbnN0IGVsZW1lbnQgb2YgYm0pIHsKICAgICAgICAgICAgICBpZiAoZWxlbWVudCBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLk5hbWUgJiYgZWxlbWVudC5uYW1lICE9PSAiTm9ybWFsIikgewogICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9CiAgICAgIGNvbnN0IHhPYmplY3RzID0gbm9kZS5nZXQoIlhPYmplY3QiKTsKICAgICAgaWYgKCEoeE9iamVjdHMgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5EaWN0KSkgewogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGZvciAobGV0IHhPYmplY3Qgb2YgeE9iamVjdHMuZ2V0UmF3VmFsdWVzKCkpIHsKICAgICAgICBpZiAoeE9iamVjdCBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLlJlZikgewogICAgICAgICAgaWYgKHByb2Nlc3NlZC5oYXMoeE9iamVjdCkpIHsKICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICB9CiAgICAgICAgICB0cnkgewogICAgICAgICAgICB4T2JqZWN0ID0geHJlZi5mZXRjaCh4T2JqZWN0KTsKICAgICAgICAgIH0gY2F0Y2ggKGV4KSB7CiAgICAgICAgICAgIHByb2Nlc3NlZC5wdXQoeE9iamVjdCk7CiAgICAgICAgICAgICgwLCBfdXRpbC5pbmZvKShgaGFzQmxlbmRNb2RlcyAtIGlnbm9yaW5nIFhPYmplY3Q6ICIke2V4fSIuYCk7CiAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZiAoISh4T2JqZWN0IGluc3RhbmNlb2YgX2Jhc2Vfc3RyZWFtLkJhc2VTdHJlYW0pKSB7CiAgICAgICAgICBjb250aW51ZTsKICAgICAgICB9CiAgICAgICAgaWYgKHhPYmplY3QuZGljdC5vYmpJZCkgewogICAgICAgICAgcHJvY2Vzc2VkLnB1dCh4T2JqZWN0LmRpY3Qub2JqSWQpOwogICAgICAgIH0KICAgICAgICBjb25zdCB4UmVzb3VyY2VzID0geE9iamVjdC5kaWN0LmdldCgiUmVzb3VyY2VzIik7CiAgICAgICAgaWYgKCEoeFJlc291cmNlcyBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLkRpY3QpKSB7CiAgICAgICAgICBjb250aW51ZTsKICAgICAgICB9CiAgICAgICAgaWYgKHhSZXNvdXJjZXMub2JqSWQgJiYgcHJvY2Vzc2VkLmhhcyh4UmVzb3VyY2VzLm9iaklkKSkgewogICAgICAgICAgY29udGludWU7CiAgICAgICAgfQogICAgICAgIG5vZGVzLnB1c2goeFJlc291cmNlcyk7CiAgICAgICAgaWYgKHhSZXNvdXJjZXMub2JqSWQpIHsKICAgICAgICAgIHByb2Nlc3NlZC5wdXQoeFJlc291cmNlcy5vYmpJZCk7CiAgICAgICAgfQogICAgICB9CiAgICB9CiAgICBmb3IgKGNvbnN0IHJlZiBvZiBwcm9jZXNzZWQpIHsKICAgICAgbm9uQmxlbmRNb2Rlc1NldC5wdXQocmVmKTsKICAgIH0KICAgIHJldHVybiBmYWxzZTsKICB9CiAgYXN5bmMgZmV0Y2hCdWlsdEluQ01hcChuYW1lKSB7CiAgICBjb25zdCBjYWNoZWREYXRhID0gdGhpcy5idWlsdEluQ01hcENhY2hlLmdldChuYW1lKTsKICAgIGlmIChjYWNoZWREYXRhKSB7CiAgICAgIHJldHVyb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3QgYml0U3RyaWRlTGVuZ3RoID0gdyArIDcgPj4gMzsKICAgICAgY29uc3QgaW1nQXJyYXkgPSBpbWFnZS5nZXRCeXRlcyhiaXRTdHJpZGVMZW5ndGggKiBoKTsKICAgICAgY29uc3QgZGVjb2RlID0gZGljdC5nZXRBcnJheSgiRCIsICJEZWNvZGUiKTsKICAgICAgaWYgKHRoaXMucGFyc2luZ1R5cGUzRm9udCkgewogICAgICAgIGltZ0RhdGEgPSBfaW1hZ2UuUERGSW1hZ2UuY3JlYXRlUmF3TWFzayh7CiAgICAgICAgICBpbWdBcnJheSwKICAgICAgICAgIHdpZHRoOiB3LAogICAgICAgICAgaGVpZ2h0OiBoLAogICAgICAgICAgaW1hZ2VJc0Zyb21EZWNvZGVTdHJlYW06IGltYWdlIGluc3RhbmNlb2YgX2RlY29kZV9zdHJlYW0uRGVjb2RlU3RyZWFtLAogICAgICAgICAgaW52ZXJzZURlY29kZTogISFkZWNvZGUgJiYgZGVjb2RlWzBdID4gMCwKICAgICAgICAgIGludGVycG9sYXRlCiAgICAgICAgfSk7CiAgICAgICAgaW1nRGF0YS5jYWNoZWQgPSAhIWNhY2hlS2V5OwogICAgICAgIGFyZ3MgPSBbaW1nRGF0YV07CiAgICAgICAgb3BlcmF0b3JMaXN0LmFkZEltYWdlT3BzKF91dGlsLk9QUy5wYWludEltYWdlTWFza1hPYmplY3QsIGFyZ3MsIG9wdGlvbmFsQ29udGVudCk7CiAgICAgICAgaWYgKGNhY2hlS2V5KSB7CiAgICAgICAgICBsb2NhbEltYWdlQ2FjaGUuc2V0KGNhY2hlS2V5LCBpbWFnZVJlZiwgewogICAgICAgICAgICBmbjogX3V0aWwuT1BTLnBhaW50SW1hZ2VNYXNrWE9iamVjdCwKICAgICAgICAgICAgYXJncywKICAgICAgICAgICAgb3B0aW9uYWxDb250ZW50CiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuOwogICAgICB9CiAgICAgIGltZ0RhdGEgPSBhd2Fp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ZXBlbmRlbmN5KGxvYWRlZE5hbWUpOwogICAgICAgICAgICAgIGdTdGF0ZU9iai5wdXNoKFtrZXksIFtsb2FkZWROYW1lLCB2YWx1ZVsxXV1dKTsKICAgICAgICAgICAgfSk7CiAgICAgICAgICB9KTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgIkJNIjoKICAgICAgICAgIGdTdGF0ZU9iai5wdXNoKFtrZXksIG5vcm1hbGl6ZUJsZW5kTW9kZSh2YWx1ZSldKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgIlNNYXNrIjoKICAgICAgICAgIGlmICgoMCwgX3ByaW1pdGl2ZXMuaXNOYW1lKSh2YWx1ZSwgIk5vbmUiKSkgewogICAgICAgICAgICBnU3RhdGVPYmoucHVzaChba2V5LCBmYWxzZV0pOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIH0KICAgICAgICAgIGlmICh2YWx1ZSBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLkRpY3QpIHsKICAgICAgICAgICAgaXNTaW1wbGVHU3RhdGUgPSBmYWxzZTsKICAgICAgICAgICAgcHJvbWlzZSA9IHByb21pc2UudGhlbigoKSA9PiB7CiAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuaGFuZGxlU01hc2sodmFsdWUsIHJlc291cmNlcywgb3BlcmF0b3JMaXN0LCB0YXNrLCBzdGF0ZU1hbmFnZXIsIGxvY2FsQ29sb3JTcGFjZUNhY2hlKTsKICAgICAgICAgICAgfSk7CiAgICAgICAgICAgIGdTdGF0ZU9iai5wdXNoKFtrZXksIHRydWVdKTsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKSgiVW5zdXBwb3J0ZWQgU01hc2sgdHlwZSIpOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiVFIiOgogICAgICAgICAgY29uc3QgdHJhbnNmZXJNYXBzID0gdGhpcy5oYW5kbGVUcmFuc2ZlckZ1bmN0aW9uKHZhbHVlKTsKICAgICAgICAgIGdTdGF0ZU9iai5wdXNoKFtrZXksIHRyYW5zZmVyTWFwc10pOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiT1AiOgogICAgICAgIGNhc2UgIm9wIjoKICAgICAgICBjYXNlICJPUE0iOgogICAgICAgIGNhc2UgIkJHIjoKICAgICAgICBjYXNlICJCRzIiOgogICAgICAgIGNhc2UgIlVDUiI6CiAgICAgICAgY2FzZSAiVUNSMiI6CiAgICAgICAgY2FzZSAiVFIyIjoKICAgICAgICBjYXNlICJIVCI6CiAgICAgICAgY2FzZSAiU00iOgogICAgICAgIGNhc2UgIlNBIjoKICAgICAgICBjYXNlICJBSVMiOgogICAgICAgIGNhc2UgIlRLIjoKICAgICAgICAgICgwLCBfdXRpbC5pbmZvKSgiZ3JhcGhpYyBzdGF0ZSBvcGVyYXRvciAiICsga2V5KTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAoMCwgX3V0aWwuaW5mbykoIlVua25vd24gZ3JhcGhpYyBzdGF0ZSBvcGVyYXRvciAiICsga2V5KTsKICAgICAgICAgIGJyZWFrOwogICAgICB9CiAgICB9CiAgICByZXR1cm4gcHJvbWlzZS50aGVuKGZ1bmN0aW9uICgpIHsKICAgICAgaWYgKGdTdGF0ZU9iai5sZW5ndGggPiAwKSB7CiAgICAgICAgb3BlcmF0b3JMaXN0LmFkZE9wKF91dGlsLk9QUy5zZXRHU3RhdGUsIFtnU3RhdGVPYmpdKTsKICAgICAgfQogICAgICBpZiAoaXNTaW1wbGVHU3RhdGUpIHsKICAgICAgICBsb2NhbEdTdGF0ZUNhY2hlLnNldChjYWNoZUtleSwgZ1N0YXRlUmVmLCBnU3RhdGVPYmopOwogICAgICB9CiAgICB9KTsKICB9CiAgbG9hZEZvbnQoZm9udE5hbWUsIGZvbnQsIHJlc291cmNlcykgewogICAgbGV0IGZhbGxiYWNrRm9udERpY3QgPSBhcmd1bWVudHMubGVuZ3RoID4gMyAmJiBhcmd1bWVudHNbM10gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1szXSA6IG51bGw7CiAgICBsZXQgY3NzRm9udEluZm8gPSBhcmd1bWVudHMubGVuZ3RoID4gNCAmJiBhcmd1bWVudHNbNF0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1s0XSA6IG51bGw7CiAgICBjb25zdCBlcnJvckZvbnQgPSBhc3luYyAoKSA9PiB7CiAgICAgIHJldHVybiBuZXcgVHJhbnNsYXRlZEZvbnQoewogICAgICAgIGxvYWRlZE5hbWU6ICJnX2ZvbnRfZXJyb3IiLAogICAgICAgIGZvbnQ6IG5ldyBfZm9udHMuRXJyb3JGb250KGBGb250ICIke2ZvbnROYW1lfSIgaXMgbm90IGF2YWlsYWJsZS5gKSwKICAgICAgICBkaWN0OiBmb250LAogICAgICAgIGV2YWx1YXRvck9wdGlvbnM6IHRoaXMub3B0aW9ucwogICAgICB9KTsKICAgIH07CiAgICBjb25zdCB4cmVmID0gdGhpcy54cmVmOwogICAgbGV0IGZvbnRSZWY7CiAgICBpZiAoZm9udCkgewogICAgICBpZiAoZm9udCBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLlJlZikgewogICAgICAgIGZvbnRSZWYgPSBmb250OwogICAgICB9CiAgICB9IGVsc2UgewogICAgICBjb25zdCBmb250UmVzID0gcmVzb3VyY2VzLmdldCgiRm9udCIpOwogICAgICBpZiAoZm9udFJlcykgewogICAgICAgIGZvbnRSZWYgPSBmb250UmVzLmdldFJhdyhmb250TmFtZSk7CiAgICAgIH0KICAgIH0KICAgIGlmICghZm9udFJlZikgewogICAgICBjb25zdCBwYXJ0aWFsTXNnID0gYEZvbnQgIiR7Zm9udE5hbWUgfHwgZm9udCAmJiBmb250LnRvU3RyaW5nKCl9IiBpcyBub3QgYXZhaWxhYmxlYDsKICAgICAgaWYgKCF0aGlzLm9wdGlvbnMuaWdub3JlRXJyb3JzICYmICF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m9udCkudGhlbih0cmFuc2xhdGVkRm9udCA9PiB7CiAgICAgIGZvbnRDYXBhYmlsaXR5LnJlc29sdmUobmV3IFRyYW5zbGF0ZWRGb250KHsKICAgICAgICBsb2FkZWROYW1lOiBmb250LmxvYWRlZE5hbWUsCiAgICAgICAgZm9udDogdHJhbnNsYXRlZEZvbnQsCiAgICAgICAgZGljdDogZm9udCwKICAgICAgICBldmFsdWF0b3JPcHRpb25zOiB0aGlzLm9wdGlvbnMKICAgICAgfSkpOwogICAgfSkuY2F0Y2gocmVhc29uID0+IHsKICAgICAgKDAsIF91dGlsLndhcm4pKGBsb2FkRm9udCAtIHRyYW5zbGF0ZUZvbnQgZmFpbGVkOiAiJHtyZWFzb259Ii5gKTsKICAgICAgZm9udENhcGFiaWxpdHkucmVzb2x2ZShuZXcgVHJhbnNsYXRlZEZvbnQoewogICAgICAgIGxvYWRlZE5hbWU6IGZvbnQubG9hZGVkTmFtZSwKICAgICAgICBmb250OiBuZXcgX2ZvbnRzLkVycm9yRm9udChyZWFzb24gaW5zdGFuY2VvZiBFcnJvciA/IHJlYXNvbi5tZXNzYWdlIDogcmVhc29uKSwKICAgICAgICBkaWN0OiBmb250LAogICAgICAgIGV2YWx1YXRvck9wdGlvbnM6IHRoaXMub3B0aW9ucwogICAgICB9KSk7CiAgICB9KTsKICAgIHJldHVybiBmb250Q2FwYWJpbGl0eS5wcm9taXNlOwogIH0KICBidWlsZFBhdGgob3BlcmF0b3JMaXN0LCBmbiwgYXJncykgewogICAgbGV0IHBhcnNpbmdUZXh0ID0gYXJndW1lbnRzLmxlbmd0aCA+IDMgJiYgYXJndW1lbnRzWzNdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbM10gOiBmYWxzZTsKICAgIGNvbnN0IGxhc3RJbmRleCA9IG9wZXJhdG9yTGlzdC5sZW5ndGggLSAxOwogICAgaWYgKCFhcmdzKSB7CiAgICAgIGFyZ3MgPSBbXTsKICAgIH0KICAgIGlmIChsYXN0SW5kZXgg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yc2luZ1RleHQpIHsKICAgICAgICBvcGVyYXRvckxpc3QuYWRkT3AoX3V0aWwuT1BTLnJlc3RvcmUsIG51bGwpOwogICAgICB9CiAgICB9IGVsc2UgewogICAgICBjb25zdCBvcEFyZ3MgPSBvcGVyYXRvckxpc3QuYXJnc0FycmF5W2xhc3RJbmRleF07CiAgICAgIG9wQXJnc1swXS5wdXNoKGZuKTsKICAgICAgb3BBcmdzWzFdLnB1c2goLi4uYXJncyk7CiAgICAgIGNvbnN0IG1pbk1heCA9IG9wQXJnc1syXTsKICAgICAgc3dpdGNoIChmbikgewogICAgICAgIGNhc2UgX3V0aWwuT1BTLnJlY3RhbmdsZToKICAgICAgICAgIGNvbnN0IHggPSBhcmdzWzBdICsgYXJnc1syXTsKICAgICAgICAgIGNvbnN0IHkgPSBhcmdzWzFdICsgYXJnc1szXTsKICAgICAgICAgIG1pbk1heFswXSA9IE1hdGgubWluKG1pbk1heFswXSwgYXJnc1swXSwgeCk7CiAgICAgICAgICBtaW5NYXhbMV0gPSBNYXRoLm1heChtaW5NYXhbMV0sIGFyZ3NbMF0sIHgpOwogICAgICAgICAgbWluTWF4WzJdID0gTWF0aC5taW4obWluTWF4WzJdLCBhcmdzWzFdLCB5KTsKICAgICAgICAgIG1pbk1heFszXSA9IE1hdGgubWF4KG1pbk1heFszXSwgYXJnc1sxXSwgeSk7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIF91dGlsLk9QUy5tb3ZlVG86CiAgICAgICAgY2FzZSBfdXRpbC5PUFMubGluZVRvOgogICAgICAgICAgbWluTWF4WzBdID0gTWF0aC5taW4obWluTWF4WzBdLCBhcmdzWzBdKTsKICAgICAgICAgIG1pbk1heFsxXSA9IE1hdGgubWF4KG1pbk1heFsxXSwgYXJnc1swXSk7CiAgICAgICAgICBtaW5NYXhbMl0gPSBNYXRoLm1pbihtaW5NYXhbMl0sIGFyZ3NbMV0pOwogICAgICAgICAgbWluTWF4WzNdID0gTWF0aC5tYXgobWluTWF4WzNdLCBhcmdzWzFdKTsKICAgICAgICAgIGJyZWFrOwogICAgICB9CiAgICB9CiAgfQogIHBhcnNlQ29sb3JTcGFjZShfcmVmNCkgewogICAgbGV0IHsKICAgICAgY3MsCiAgICAgIHJlc291cmNlcywKICAgICAgbG9jYWxDb2xvclNwYWNlQ2FjaGUKICAgIH0gPSBfcmVmNDsKICAgIHJldHVybiBfY29sb3JzcGFjZS5Db2xvclNwYWNlLnBhcnNlQXN5bmMoewogICAgICBjcywKICAgICAgeHJlZjogdGhpcy54cmVmLAogICAgICByZXNvdXJjZXMsCiAgICAgIHBkZkZ1bmN0aW9uRmFjdG9yeTogdGhpcy5fcGRmRnVuY3Rpb25GYWN0b3J5LAogICAgICBsb2NhbENvbG9yU3BhY2VDYWNoZQogICAgfSkuY2F0Y2gocmVhc29uID0+IHsKICAgICAgaWYgKHJlYXNvbiBpbnN0YW5jZW9mIF91dGlsLkFib3J0RXhjZXB0aW9uKSB7CiAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgIH0KICAgICAgaWYgKHRoaXMub3B0aW9ucy5pZ25vcmVFcnJvcnMpIHsKICAgICAgICAoMCwgX3V0aWwud2FybikoYHBhcnNlQ29sb3JTcGFjZSAtIGlnbm9yaW5nIENvbG9yU3BhY2U6ICIke3JlYXNvbn0iLmApOwogICAgICAgIHJldHVybiBudWxsOwogICAgICB9CiAgICAgIHRocm93IHJlYXNvbjsKICAgIH0pOwogIH0KICBwYXJzZVNoYWRpbmcoX3JlZjUpIHsKICAgIGxldCB7CiAgICAgIHNoYWRpbmcsCiAgICAgIHJlc291cmNlcywKICAgICAgbG9jYWxDb2xvclNwYWNlQ2FjaGUsCiAgICAgIGxvY2FsU2hhZGluZ1BhdHRlcm5DYWNoZQogICAgfSA9IF9yZWY1OwogICAgbGV0IGlkID0gbG9jYWxTaGFkaW5nUGF0dGVybkNhY2hlLmdldChzaGFkaW5nKTsKICAgIGlmICghaWQpIHsKICAgICAgdmFyIHNoYWRpbmdGaWxsID0g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KG5lc3RlZFJlc3VsdCk7CiAgICAgICAgdGhpcy5fcGFyc2VWaXNpYmlsaXR5RXhwcmVzc2lvbihvYmplY3QsIG5lc3RpbmdDb3VudGVyLCBuZXN0ZWRSZXN1bHQpOwogICAgICB9IGVsc2UgaWYgKHJhdyBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLlJlZikgewogICAgICAgIGN1cnJlbnRSZXN1bHQucHVzaChyYXcudG9TdHJpbmcoKSk7CiAgICAgIH0KICAgIH0KICB9CiAgYXN5bmMgcGFyc2VNYXJrZWRDb250ZW50UHJvcHMoY29udGVudFByb3BlcnRpZXMsIHJlc291cmNlcykgewogICAgbGV0IG9wdGlvbmFsQ29udGVudDsKICAgIGlmIChjb250ZW50UHJvcGVydGllcyBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLk5hbWUpIHsKICAgICAgY29uc3QgcHJvcGVydGllcyA9IHJlc291cmNlcy5nZXQoIlByb3BlcnRpZXMiKTsKICAgICAgb3B0aW9uYWxDb250ZW50ID0gcHJvcGVydGllcy5nZXQoY29udGVudFByb3BlcnRpZXMubmFtZSk7CiAgICB9IGVsc2UgaWYgKGNvbnRlbnRQcm9wZXJ0aWVzIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuRGljdCkgewogICAgICBvcHRpb25hbENvbnRlbnQgPSBjb250ZW50UHJvcGVydGllczsKICAgIH0gZWxzZSB7CiAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiT3B0aW9uYWwgY29udGVudCBwcm9wZXJ0aWVzIG1hbGZvcm1lZC4iKTsKICAgIH0KICAgIGNvbnN0IG9wdGlvbmFsQ29udGVudFR5cGUgPSBvcHRpb25hbENvbnRlbnQuZ2V0KCJUeXBlIikubmFtZTsKICAgIGlmIChvcHRpb25hbENvbnRlbnRUeXBlID09PSAiT0NHIikgewogICAgICByZXR1cm4gewogICAgICAgIHR5cGU6IG9wdGlvbmFsQ29udGVudFR5cGUsCiAgICAgICAgaWQ6IG9wdGlvbmFsQ29udGVudC5vYmpJZAogICAgICB9OwogICAgfSBlbHNlIGlmIChvcHRpb25hbENvbnRlbnRUeXBlID09PSAiT0NNRCIpIHsKICAgICAgY29uc3QgZXhwcmVzc2lvbiA9IG9wdGlvbmFsQ29udGVudC5nZXQoIlZFIik7CiAgICAgIGlmIChBcnJheS5pc0FycmF5KGV4cHJlc3Npb24pKSB7CiAgICAgICAgY29uc3QgcmVzdWx0ID0gW107CiAgICAgICAgdGhpcy5fcGFyc2VWaXNpYmlsaXR5RXhwcmVzc2lvbihleHByZXNzaW9uLCAwLCByZXN1bHQpOwogICAgICAgIGlmIChyZXN1bHQubGVuZ3RoID4gMCkgewogICAgICAgICAgcmV0dXJuIHsKICAgICAgICAgICAgdHlwZTogIk9DTUQiLAogICAgICAgICAgICBleHByZXNzaW9uOiByZXN1bHQKICAgICAgICAgIH07CiAgICAgICAgfQogICAgICB9CiAgICAgIGNvbnN0IG9wdGlvbmFsQ29udGVudEdyb3VwcyA9IG9wdGlvbmFsQ29udGVudC5nZXQoIk9DR3MiKTsKICAgICAgaWYgKEFycmF5LmlzQXJyYXkob3B0aW9uYWxDb250ZW50R3JvdXBzKSB8fCBvcHRpb25hbENvbnRlbnRHcm91cHMgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5EaWN0KSB7CiAgICAgICAgY29uc3QgZ3JvdXBJZHMgPSBbXTsKICAgICAgICBpZiAoQXJyYXkuaXNBcnJheShvcHRpb25hbENvbnRlbnRHcm91cHMpKSB7CiAgICAgICAgICBmb3IgKGNvbnN0IG9jZyBvZiBvcHRpb25hbENvbnRlbnRHcm91cHMpIHsKICAgICAgICAgICAgZ3JvdXBJZHMucHVzaChvY2cudG9TdHJpbmcoKSk7CiAgICAgICAgICB9CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIGdyb3VwSWRzLnB1c2gob3B0aW9uYWxDb250ZW50R3JvdXBzLm9iaklkKTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIHsKICA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W50WE9iamVjdDoKICAgICAgICAgICAgaXNWYWxpZE5hbWUgPSBhcmdzWzBdIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuTmFtZTsKICAgICAgICAgICAgbmFtZSA9IGFyZ3NbMF0ubmFtZTsKICAgICAgICAgICAgaWYgKGlzVmFsaWROYW1lKSB7CiAgICAgICAgICAgICAgY29uc3QgbG9jYWxJbWFnZSA9IGxvY2FsSW1hZ2VDYWNoZS5nZXRCeU5hbWUobmFtZSk7CiAgICAgICAgICAgICAgaWYgKGxvY2FsSW1hZ2UpIHsKICAgICAgICAgICAgICAgIG9wZXJhdG9yTGlzdC5hZGRJbWFnZU9wcyhsb2NhbEltYWdlLmZuLCBsb2NhbEltYWdlLmFyZ3MsIGxvY2FsSW1hZ2Uub3B0aW9uYWxDb250ZW50KTsKICAgICAgICAgICAgICAgIGluY3JlbWVudENhY2hlZEltYWdlTWFza0NvdW50KGxvY2FsSW1hZ2UpOwogICAgICAgICAgICAgICAgYXJncyA9IG51bGw7CiAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgICAgbmV4dChuZXcgUHJvbWlzZShmdW5jdGlvbiAocmVzb2x2ZVhPYmplY3QsIHJlamVjdFhPYmplY3QpIHsKICAgICAgICAgICAgICBpZiAoIWlzVmFsaWROYW1lKSB7CiAgICAgICAgICAgICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoIlhPYmplY3QgbXVzdCBiZSByZWZlcnJlZCB0byBieSBuYW1lLiIpOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBsZXQgeG9iaiA9IHhvYmpzLmdldFJhdyhuYW1lKTsKICAgICAgICAgICAgICBpZiAoeG9iaiBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLlJlZikgewogICAgICAgICAgICAgICAgY29uc3QgbG9jYWxJbWFnZSA9IGxvY2FsSW1hZ2VDYWNoZS5nZXRCeVJlZih4b2JqKTsKICAgICAgICAgICAgICAgIGlmIChsb2NhbEltYWdlKSB7CiAgICAgICAgICAgICAgICAgIG9wZXJhdG9yTGlzdC5hZGRJbWFnZU9wcyhsb2NhbEltYWdlLmZuLCBsb2NhbEltYWdlLmFyZ3MsIGxvY2FsSW1hZ2Uub3B0aW9uYWxDb250ZW50KTsKICAgICAgICAgICAgICAgICAgaW5jcmVtZW50Q2FjaGVkSW1hZ2VNYXNrQ291bnQobG9jYWxJbWFnZSk7CiAgICAgICAgICAgICAgICAgIHJlc29sdmVYT2JqZWN0KCk7CiAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNvbnN0IGdsb2JhbEltYWdlID0gc2VsZi5nbG9iYWxJbWFnZUNhY2hlLmdldERhdGEoeG9iaiwgc2VsZi5wYWdlSW5kZXgpOwogICAgICAgICAgICAgICAgaWYgKGdsb2JhbEltYWdlKSB7CiAgICAgICAgICAgICAgICAgIG9wZXJhdG9yTGlzdC5hZGREZXBlbmRlbmN5KGdsb2JhbEltYWdlLm9iaklkKTsKICAgICAgICAgICAgICAgICAgb3BlcmF0b3JMaXN0LmFkZEltYWdlT3BzKGdsb2JhbEltYWdlLmZuLCBnbG9iYWxJbWFnZS5hcmdzLCBnbG9iYWxJbWFnZS5vcHRpb25hbENvbnRlbnQpOwogICAgICAgICAgICAgICAgICByZXNvbHZlWE9iamVjdCgpOwogICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB4b2JqID0geHJlZi5mZXRjaCh4b2JqKTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgaWYgKCEoeG9iaiBpbnN0YW5jZW9mIF9iYXNlX3N0cmVhbS5CYXNlU3RyZWFtKSkgewogICAgICAgICAgICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKCJYT2JqZWN0IHNob3VsZCBiZSBhIHN0cmVhbSIpOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBjb25zdCB0eXBlID0geG9iai5kaWN0LmdldCgiU3VidHlwZSIpOwogICAgICAgICAgICAgIGlmICghKHR5cGUgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lKSkgewogICAgICAgICAgICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKCJYT2JqZWN0IHNob3VsZCBoYXZlIGEgTmFtZSBzdWJ0eXBlIik7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIGlmICh0eXBlLm5hbWUgPT09ICJGb3JtIikgewogICAgICAgICAgICAgICAgc3RhdGVNYW5hZ2VyLnNhdmUoKTsKICAgICAgICAgICAgICAgIHNlbGYuYnVpbGRGb3JtWE9iamVjdChyZXNvdXJjZXMsIHhvYmosIG51bGwsIG9wZXJhdG9yTGlzdCwgdGFzaywgc3RhdGVNYW5hZ2VyLnN0YXRlLmNsb25lKCksIGxvY2FsQ29sb3JTcGFjZUNhY2hlKS50aGVuKGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgc3RhdGVNYW5hZ2VyLnJlc3RvcmUoKTsKICAgICAgICAgICAgICAgICAgcmVzb2x2ZVhPYmplY3QoKTsKICAgICAgICAgICAgICAgIH0sIHJlamVjdFhPYmplY3QpOwogICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgIH0gZWxzZSBpZiAodHlwZS5uYW1lID09PSAiSW1hZ2UiKSB7CiAgICAgICAgICAgICAgICBzZWxmLmJ1aWxkUGFpbnRJbWFnZVhPYmplY3QoewogICAgICAgICAgICAgICAgICByZXNvdXJjZXMsCiAgICAgICAgICAgICAgICAgIGltYWdlOiB4b2JqLAogICAgICAgICAgICAgICAgICBvcGVyYXRvckxpc3QsCiAgICAgICAgICAgICAgICAgIGNhY2hlS2V5OiBuYW1lLAogICAgICAgICAgICAgICAgICBsb2NhbEltYWdlQ2FjaGUsCiAgICAgICAgICAgICAgICAgIGxvY2FsQ29sb3JTcGFjZUNhY2hlCiAgICAgICAgICAgICAgICB9KS50aGVuKHJlc29sdmVYT2JqZWN0LCByZWplY3RYT2JqZWN0KTsKICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICB9IGVsc2UgaWYgKHR5cGUubmFtZSA9PT0gIlBTIikgewogICAgICAgICAgICAgICAgKDAsIF91dGlsLmluZm8pKCJJZ25vcmVkIFhPYmplY3Qgc3VidHlwZSBQUyIpOwogICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoYFVuaGFuZGxlZCBYT2JqZWN0IHN1YnR5cGUgJHt0eXBlLm5hbWV9YCk7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIHJlc29sdmVYT2JqZWN0KCk7CiAgICAgICAgICAgIH0pLmNhdGNoKGZ1bmN0aW9uIChyZWFzb24pIHsKICAgICAgICAgICAgICBpZiAocmVhc29uIGluc3RhbmNlb2YgX3V0aWwuQWJvcnRFeGNlcHRpb24pIHsKICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgaWYgKHNlbGYub3B0aW9ucy5pZ25vcmVFcnJvcnMpIHsKICAgICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgZ2V0T3BlcmF0b3JMaXN0IC0gaWdub3JpbmcgWE9iamVjdDogIiR7cmVhc29ufSIuYCk7CiAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIHRocm93IHJlYXNvbjsKICAgICAgICAgICAgfSkpOwogICAgICAgICAgICByZXR1cm47CiAgICAgICAgICBjYXNlIF91dGlsLk9QUy5zZXRGb250OgogICAgICAgICAgICB2YXIgZm9udFNpemUgPSBhcmdzWzFdOwogICAgICAgICAgICBuZXh0KHNlbGYuaGFuZGxlU2V0Rm9udChyZXNvdXJjZXMsIGFyZ3MsIG51bGwsIG9wZXJhdG9yTGlzdCwgdGFzaywgc3RhdGVNYW5hZ2VyLnN0YXRlLCBmYWxsYmFja0ZvbnREaWN0KS50aGVuKGZ1bmN0aW9uIChsb2FkZWROYW1lKSB7CiAgICAgICAgICAgICAgb3BlcmF0b3JMaXN0LmFkZERlcGVuZGVuY3kobG9hZGVkTmFtZSk7CiAgICAgICAgICAgICAgb3BlcmF0b3JMaXN0LmFkZE9wKF91dGlsLk9QUy5zZXRGb250LCBbbG9hZGVkTmFtZSwgZm9udFNpemVdKTsKICAgICAgICAgICAgfSkpOwogICAgICAgICAgICByZXR1cm47CiAgICAgICAgICBjYXNlIF91dGlsLk9QUy5iZWdpblRleHQ6CiAgICAgICAgICAgIHBhcnNpbmdUZXh0ID0gdHJ1ZTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIF91dGlsLk9QUy5lbmRUZXh0OgogICAgICAgICAgICBwYXJzaW5nVGV4dCA9IGZhbHNlOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLmVuZElubGluZUltYWdlOgogICAgICAgICAgICB2YXIgY2FjaGVLZXkgPSBhcmdzWzBdLmNhY2hlS2V5OwogICAgICAgICAgICBpZiAoY2FjaGVLZXkpIHsKICAgICAgICAgICAgICBjb25zdCBsb2NhbEltYWdlID0gbG9jYWxJbWFnZUNhY2hlLmdldEJ5TmFtZShjYWNoZUtleSk7CiAgICAgICAgICAgICAgaWYgKGxvY2FsSW1hZ2UpIHsKICAgICAgICAgICAgICAgIG9wZXJhdG9yTGlzdC5hZGRJbWFnZU9wcyhsb2NhbEltYWdlLmZuLCBsb2NhbEltYWdlLmFyZ3MsIGxvY2FsSW1hZ2Uub3B0aW9uYWxDb250ZW50KTsKICAgICAgICAgICAgICAgIGluY3JlbWVudENhY2hlZEltYWdlTWFza0NvdW50KGxvY2FsSW1hZ2UpOwogICAgICAgICAgICAgICAgYXJncyA9IG51bGw7CiAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgICAgbmV4dChzZWxmLmJ1aWxkUGFpbnRJbWFnZVhPYmplY3QoewogICAgICAgICAgICAgIHJlc291cmNlcywKICAgICAgICAgICAgICBpbWFnZTogYXJnc1swXSwKICAgICAgICAgICAgICBpc0lubGluZTogdHJ1ZSwKICAgICAgICAgICAgICBvcGVyYXRvckxpc3QsCiAgICAgICAgICAgICAgY2FjaGVLZXksCiAgICAgICAgICAgICAgbG9jYWxJbWFnZUNhY2hlLAogICAgICAgICAgICAgIGxvY2FsQ29sb3JTcGFjZUNhY2hlCiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgY2FzZSBfdXRpbC5PUFMuc2hvd1RleHQ6CiAgICAgICAgICAgIGlmICghc3RhdGVNYW5hZ2VyLnN0YXRlLmZvbnQpIHsKICAgICAgICAgICAgICBzZWxmLmVuc3VyZVN0YXRlRm9udChzdGF0ZU1hbmFnZXIuc3RhdGUpOwogICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGFyZ3NbMF0gPSBzZWxmLmhhbmRsZVRleHQoYXJnc1swXSwgc3RhdGVNYW5hZ2VyLnN0YXRlKTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIF91dGlsLk9QUy5zaG93U3BhY2VkVGV4dDoKICAgICAgICAgICAgaWYgKCFzdGF0ZU1hbmFnZXIuc3RhdGUuZm9udCkgewogICAgICAgICAgICAgIHNlbGYuZW5zdXJlU3RhdGVGb250KHN0YXRlTWFuYWdlci5zdGF0ZSk7CiAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgdmFyIGNvbWJpbmVkR2x5cGhzID0gW107CiAgICAgICAgICAgIHZhciBzdGF0ZSA9IHN0YXRlTWFuYWdlci5zdGF0ZTsKICAgICAgICAgICAgZm9yIChjb25zdCBhcnJJdGVtIG9mIGFyZ3NbMF0pIHsKICAgICAgICAgICAgICBpZiAodHlwZW9mIGFyckl0ZW0gPT09ICJzdHJpbmciKSB7CiAgICAgICAgICAgICAgICBjb21iaW5lZEdseXBocy5wdXNoKC4uLnNlbGYuaGFuZGxlVGV4dChhcnJJdGVtLCBzdGF0ZSkpOwogICAgICAgICAgICAgIH0gZWxzZSBpZiAodHlwZW9mIGFyckl0ZW0gPT09ICJudW1iZXIiKSB7CiAgICAgICAgICAgICAgICBjb21iaW5lZEdseXBocy5wdXNoKGFyckl0ZW0pOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgICBhcmdzWzBdID0gY29tYmluZWRHbHlwaHM7CiAgICAgICAgICAgIGZuID0gX3V0aWwuT1BTLnNob3dUZXh0OwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLm5leHRMaW5lU2hvd1RleHQ6CiAgICAgICAgICAgIGlmICghc3RhdGVNYW5hZ2VyLnN0YXRlLmZvbnQpIHsKICAgICAgICAgICAgICBzZWxmLmVuc3VyZVN0YXRlRm9udChzdGF0ZU1hbmFnZXIuc3RhdGUpOwogICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICB9CiAgICAgICAgICAgIG9wZXJhdG9yTGlzdC5hZGRPcChfdXRpbC5PUFMubmV4dExpbmUpOwogICAgICAgICAgICBhcmdzWzBdID0gc2VsZi5oYW5kbGVUZXh0KGFyZ3NbMF0sIHN0YXRlTWFuYWdlci5zdGF0ZSk7CiAgICAgICAgICAgIGZuID0gX3V0aWwuT1BTLnNob3dUZXh0OwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLm5leHRMaW5lU2V0U3BhY2luZ1Nob3dUZXh0OgogICAgICAgICAgICBpZiAoIXN0YXRlTWFuYWdlci5zdGF0ZS5mb250KSB7CiAgICAgICAgICAgICAgc2VsZi5lbnN1cmVTdGF0ZUZvbnQoc3RhdGVNYW5hZ2VyLnN0YXRlKTsKICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgfQogICAgICAgICAgICBvcGVyYXRvckxpc3QuYWRkT3AoX3V0aWwuT1BTLm5leHRMaW5lKTsKICAgICAgICAgICAgb3BlcmF0b3JMaXN0LmFkZE9wKF91dGlsLk9QUy5zZXRXb3JkU3BhY2luZywgW2FyZ3Muc2hpZnQoKV0pOwogICAgICAgICAgICBvcGVyYXRvckxpc3QuYWRkT3AoX3V0aWwuT1BTLnNldENoYXJTcGFjaW5nLCBbYXJncy5zaGlmdCgpXSk7CiAgICAgICAgICAgIGFyZ3NbMF0gPSBzZWxmLmhhbmRsZVRleHQoYXJnc1swXSwgc3RhdGVNYW5hZ2VyLnN0YXRlKTsKICAgICAgICAgICAgZm4gPSBfdXRpbC5PUFMuc2hvd1RleHQ7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSBfdXRpbC5PUFMuc2V0VGV4dFJlbmRlcmluZ01vZGU6CiAgICAgICAgICAgIHN0YXRlTWFuYWdlci5zdGF0ZS50ZXh0UmVuZGVyaW5nTW9kZSA9IGFyZ3NbMF07CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSBfdXRpbC5PUFMuc2V0RmlsbENvbG9yU3BhY2U6CiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBjb25zdCBjYWNoZWRDb2xvclNwYWNlID0gX2NvbG9yc3BhY2UuQ29sb3JTcGFjZS5nZXRDYWNoZWQoYXJnc1swXSwgeHJlZiwgbG9jYWxDb2xvclNwYWNlQ2FjaGUpOwogICAgICAgICAgICAgIGlmIChjYWNoZWRDb2xvclNwYWNlKSB7CiAgICAgICAgICAgICAgICBzdGF0ZU1hbmFnZXIuc3RhdGUuZmlsbENvbG9yU3BhY2UgPSBjYWNoZWRDb2xvclNwYWNlOwogICAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIG5leHQoc2VsZi5wYXJzZUNvbG9yU3BhY2UoewogICAgICAgICAgICAgICAgY3M6IGFyZ3NbMF0sCiAgICAgICAgICAgICAgICByZXNvdXJjZXMsCiAgICAgICAgICAgICAgICBsb2NhbENvbG9yU3BhY2VDYWNoZQogICAgICAgICAgICAgIH0pLnRoZW4oZnVuY3Rpb24gKGNvbG9yU3BhY2UpIHsKICAgICAgICAgICAgICAgIGlmIChjb2xvclNwYWNlKSB7CiAgICAgICAgICAgICAgICAgIHN0YXRlTWFuYWdlci5zdGF0ZS5maWxsQ29sb3JTcGFjZSA9IGNvbG9yU3BhY2U7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgfSkpOwogICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgfQogICAgICAgICAgY2FzZSBfdXRpbC5PUFMuc2V0U3Ryb2tlQ29sb3JTcGFjZToKICAgICAgICAgICAgewogICAgICAgICAgICAgIGNvbnN0IGNhY2hlZENvbG9yU3BhY2UgPSBfY29sb3JzcGFjZS5Db2xvclNwYWNlLmdldENhY2hlZChhcmdzWzBdLCB4cmVmLCBsb2NhbENvbG9yU3BhY2VDYWNoZSk7CiAgICAgICAgICAgICAgaWYgKGNhY2hlZENvbG9yU3BhY2UpIHsKICAgICAgICAgICAgICAgIHN0YXRlTWFuYWdlci5zdGF0ZS5zdHJva2VDb2xvclNwYWNlID0gY2FjaGVkQ29sb3JTcGFjZTsKICAgICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBuZXh0KHNlbGYucGFyc2VDb2xvclNwYWNlKHsKICAgICAgICAgICAgICAgIGNzOiBhcmdzWzBdLAogICAgICAgICAgICAgICAgcmVzb3VyY2VzLAogICAgICAgICAgICAgICAgbG9jYWxDb2xvclNwYWNlQ2FjaGUKICAgICAgICAgICAgICB9KS50aGVuKGZ1bmN0aW9uIChjb2xvclNwYWNlKSB7CiAgICAgICAgICAgICAgICBpZiAoY29sb3JTcGFjZSkgewogICAgICAgICAgICAgICAgICBzdGF0ZU1hbmFnZXIuc3RhdGUuc3Ryb2tlQ29sb3JTcGFjZSA9IGNvbG9yU3BhY2U7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgfSkpOwogICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgfQogICAgICAgICAgY2FzZSBfdXRpbC5PUFMuc2V0RmlsbENvbG9yOgogICAgICAgICAgICBjcyA9IHN0YXRlTWFuYWdlci5zdGF0ZS5maWxsQ29sb3JTcGFjZTsKICAgICAgICAgICAgYXJncyA9IGNzLmdldFJnYihhcmdzLCAwKTsKICAgICAgICAgICAgZm4gPSBfdXRpbC5PUFMuc2V0RmlsbFJHQkNvbG9yOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnNldFN0cm9rZUNvbG9yOgogICAgICAgICAgICBjcyA9IHN0YXRlTWFuYWdlci5zdGF0ZS5zdHJva2VDb2xvclNwYWNlOwogICAgICAgICAgICBhcmdzID0gY3MuZ2V0UmdiKGFyZ3MsIDApOwogICAgICAgICAgICBmbiA9IF91dGlsLk9QUy5zZXRTdHJva2VSR0JDb2xvcjsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIF91dGlsLk9QUy5zZXRGaWxsR3JheToKICAgICAgICAgICAgc3RhdGVNYW5hZ2VyLnN0YXRlLmZpbGxDb2xvclNwYWNlID0gX2NvbG9yc3BhY2UuQ29sb3JTcGFjZS5zaW5nbGV0b25zLmdyYXk7CiAgICAgICAgICAgIGFyZ3MgPSBfY29sb3JzcGFjZS5Db2xvclNwYWNlLnNpbmdsZXRvbnMuZ3JheS5nZXRSZ2IoYXJncywgMCk7CiAgICAgICAgICAgIGZuID0gX3V0aWwuT1BTLnNldEZpbGxSR0JDb2xvcjsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIF91dGlsLk9QUy5zZXRTdHJva2VHcmF5OgogICAgICAgICAgICBzdGF0ZU1hbmFnZXIuc3RhdGUuc3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wYXR0ZXJuSWQgPSBzZWxmLnBhcnNlU2hhZGluZyh7CiAgICAgICAgICAgICAgc2hhZGluZywKICAgICAgICAgICAgICByZXNvdXJjZXMsCiAgICAgICAgICAgICAgbG9jYWxDb2xvclNwYWNlQ2FjaGUsCiAgICAgICAgICAgICAgbG9jYWxTaGFkaW5nUGF0dGVybkNhY2hlCiAgICAgICAgICAgIH0pOwogICAgICAgICAgICBhcmdzID0gW3BhdHRlcm5JZF07CiAgICAgICAgICAgIGZuID0gX3V0aWwuT1BTLnNoYWRpbmdGaWxsOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnNldEdTdGF0ZToKICAgICAgICAgICAgaXNWYWxpZE5hbWUgPSBhcmdzWzBdIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuTmFtZTsKICAgICAgICAgICAgbmFtZSA9IGFyZ3NbMF0ubmFtZTsKICAgICAgICAgICAgaWYgKGlzVmFsaWROYW1lKSB7CiAgICAgICAgICAgICAgY29uc3QgbG9jYWxHU3RhdGVPYmogPSBsb2NhbEdTdGF0ZUNhY2hlLmdldEJ5TmFtZShuYW1lKTsKICAgICAgICAgICAgICBpZiAobG9jYWxHU3RhdGVPYmopIHsKICAgICAgICAgICAgICAgIGlmIChsb2NhbEdTdGF0ZU9iai5sZW5ndGggPiAwKSB7CiAgICAgICAgICAgICAgICAgIG9wZXJhdG9yTGlzdC5hZGRPcChfdXRpbC5PUFMuc2V0R1N0YXRlLCBbbG9jYWxHU3RhdGVPYmpdKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGFyZ3MgPSBudWxsOwogICAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICAgIG5leHQobmV3IFByb21pc2UoZnVuY3Rpb24gKHJlc29sdmVHU3RhdGUsIHJlamVjdEdTdGF0ZSkgewogICAgICAgICAgICAgIGlmICghaXNWYWxpZE5hbWUpIHsKICAgICAgICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiR1N0YXRlIG11c3QgYmUgcmVmZXJyZWQgdG8gYnkgbmFtZS4iKTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgY29uc3QgZXh0R1N0YXRlID0gcmVzb3VyY2VzLmdldCgiRXh0R1N0YXRlIik7CiAgICAgICAgICAgICAgaWYgKCEoZXh0R1N0YXRlIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuRGljdCkpIHsKICAgICAgICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiRXh0R1N0YXRlIHNob3VsZCBiZSBhIGRpY3Rpb25hcnkuIik7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIGNvbnN0IGdTdGF0ZSA9IGV4dEdTdGF0ZS5nZXQobmFtZSk7CiAgICAgICAgICAgICAgaWYgKCEoZ1N0YXRlIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuRGljdCkpIHsKICAgICAgICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiR1N0YXRlIHNob3VsZCBiZSBhIGRpY3Rpb25hcnkuIik7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIHNlbGYuc2V0R1N0YXRlKHsKICAgICAgICAgICAgICAgIHJlc291cmNlcywKICAgICAgICAgICAgICAgIGdTdGF0ZSwKICAgICAgICAgICAgICAgIG9wZXJhdG9yTGlzdCwKICAgICAgICAgICAgICAgIGNhY2hlS2V5OiBuYW1lLAogICAgICAgICAgICAgICAgdGFzaywKICAgICAgICAgICAgICAgIHN0YXRlTWFuYWdlciwKICAgICAgICAgICAgICAgIGxvY2FsR1N0YXRlQ2FjaGUsCiAgICAgICAgICAgICAgICBsb2NhbENvbG9yU3BhY2VDYWNoZQogICAgICAgICAgICAgIH0pLnRoZW4ocmVzb2x2ZUdTdGF0ZSwgcmVqZWN0R1N0YXRlKTsKICAgICAgICAgICAgfSkuY2F0Y2goZnVuY3Rpb24gKHJlYXNvbikgewogICAgICAgICAgICAgIGlmIChyZWFzb24gaW5zdGFuY2VvZiBfdXRpbC5BYm9ydEV4Y2VwdGlvbikgewogICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBpZiAoc2VsZi5vcHRpb25zLmlnbm9yZUVycm9ycykgewogICAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKGBnZXRPcGVyYXRvckxpc3QgLSBpZ25vcmluZyBFeHRHU3RhdGU6ICIke3JlYXNvbn0iLmApOwogICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICB0aHJvdyByZWFzb247CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgY2FzZSBfdXRpbC5PUFMubW92ZVRvOgogICAgICAgICAgY2FzZSBfdXRpbC5PUFMubGluZVRvOgogICAgICAgICAgY2FzZSBfdXRpbC5PUFMuY3VydmVUbzoKICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLmN1cnZlVG8yOgogICAgICAgICAgY2FzZSBfdXRpbC5PUFMuY3VydmVUbzM6CiAgICAgICAgICBjYXNlIF91dGlsLk9QUy5jbG9zZVBhdGg6CiAgICAgICAgICBjYXNlIF91dGlsLk9QUy5yZWN0YW5nbGU6CiAgICAgICAgICAgIHNlbGYuYnVpbGRQYXRoKG9wZXJhdG9yTGlzdCwgZm4sIGFyZ3MsIHBhcnNpbmdUZXh0KTsKICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICBjYXNlIF91dGlsLk9QUy5tYXJrUG9pbnQ6CiAgICAgICAgICBjYXNlIF91dGlsLk9QUy5tYXJrUG9pbnRQcm9wczoKICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLmJlZ2luQ29tcGF0OgogICAgICAgICAgY2FzZSBfdXRpbC5PUFMuZW5kQ29tcGF0OgogICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLmJlZ2luTWFya2VkQ29udGVudFByb3BzOgogICAgICAgICAgICBpZiAoIShhcmdzWzBdIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuTmFtZSkpIHsKICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYEV4cGVjdGVkIG5hbWUgZm9yIGJlZ2luTWFya2VkQ29udGVudFByb3BzIGFyZzA9JHthcmdzWzBdfWApOwogICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmIChhcmdzWzBdLm5hbWUgPT09ICJPQyIpIHsKICAgICAgICAgICAgICBuZXh0KHNlbGYucGFyc2VNYXJrZWRDb250ZW50UHJvcHMoYXJnc1sxXSwgcmVzb3VyY2VzKS50aGVuKGRhdGEgPT4gewogICAgICAgICAgICAgICAgb3BlcmF0b3JMaXN0LmFkZE9wKF91dGlsLk9QUy5iZWdpbk1hcmtlZENvbnRlbnRQcm9wcywgWyJPQyIsIGRhdGFdKTsKICAgICAgICAgICAgICB9KS5jYXRjaChyZWFzb24gPT4gewogICAgICAgICAgICAgICAgaWYgKHJlYXNvbiBpbnN0YW5jZW9mIF91dGlsLkFib3J0RXhjZXB0aW9uKSB7CiAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGlmIChzZWxmLm9wdGlvbnMuaWdub3JlRXJyb3JzKSB7CiAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgZ2V0T3BlcmF0b3JMaXN0IC0gaWdub3JpbmcgYmVnaW5NYXJrZWRDb250ZW50UHJvcHM6ICIke3JlYXNvbn0iLmApOwogICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB0aHJvdyByZWFzb247CiAgICAgICAgICAgICAgfSkpOwogICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgfQogICAgICAgICAgICBhcmdzID0gW2FyZ3NbMF0ubmFtZSwgYXJnc1sxXSBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLkRpY3QgPyBhcmdzWzFdLmdldCgiTUNJRCIpIDogbnVsbF07CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSBfdXRpbC5PUFMuYmVnaW5NYXJrZWRDb250ZW50OgogICAgICAgICAgY2FzZSBfdXRpbC5PUFMuZW5kTWFya2VkQ29udGVudDoKICAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgIGlmIChhcmdzICE9PSBudWxsKSB7CiAgICAgICAgICAgICAgZm9yIChpID0gMCwgaWkgPSBhcmdzLmxlbmd0aDsgaSA8IGlpOyBpKyspIHsKICAgICAgICAgICAgICAgIGlmIChhcmdzW2ldIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuRGljdCkgewogICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgaWYgKGkgPCBpaSkgewogICAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKCJnZXRPcGVyYXRvckxpc3QgLSBpZ25vcmluZyBvcGVyYXRvcjogIiArIGZuKTsKICAgICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBvcGVyYXRvckxpc3QuYWRkT3AoZm4sIGFyZ3MpOwogICAgICB9CiAgICAgIGlmIChzdG9wKSB7CiAgICAgICAgbmV4dChkZWZlcnJlZCk7CiAgICAgICAgcmV0dXJuOwogICAgICB9CiAgICAgIGNsb3NlUGVuZGluZ1Jlc3RvcmVPUFMoKTsKICAgICAgcmVzb2x2ZSgpOwogICAgfSkuY2F0Y2gocmVhc29uID0+IHsKICAgICAgaWYgKHJlYXNvbiBpbnN0YW5jZW9mIF91dGlsLkFib3J0RXhjZXB0aW9uKSB7CiAgICAgICAgcmV0dXJuOwogICAgICB9C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XNlXTsKICAgICAgaWYgKGZvbnQuaXNUeXBlM0ZvbnQgJiYgKHRleHRTdGF0ZS5mb250U2l6ZSA8PSAxIHx8IGZvbnQuaXNDaGFyQkJveCkgJiYgISgwLCBfdXRpbC5pc0FycmF5RXF1YWwpKHRleHRTdGF0ZS5mb250TWF0cml4LCBfdXRpbC5GT05UX0lERU5USVRZX01BVFJJWCkpIHsKICAgICAgICBjb25zdCBnbHlwaEhlaWdodCA9IGZvbnQuYmJveFszXSAtIGZvbnQuYmJveFsxXTsKICAgICAgICBpZiAoZ2x5cGhIZWlnaHQgPiAwKSB7CiAgICAgICAgICB0c21bM10gKj0gZ2x5cGhIZWlnaHQgKiB0ZXh0U3RhdGUuZm9udE1hdHJpeFszXTsKICAgICAgICB9CiAgICAgIH0KICAgICAgcmV0dXJuIF91dGlsLlV0aWwudHJhbnNmb3JtKHRleHRTdGF0ZS5jdG0sIF91dGlsLlV0aWwudHJhbnNmb3JtKHRleHRTdGF0ZS50ZXh0TWF0cml4LCB0c20pKTsKICAgIH0KICAgIGZ1bmN0aW9uIGVuc3VyZVRleHRDb250ZW50SXRlbSgpIHsKICAgICAgaWYgKHRleHRDb250ZW50SXRlbS5pbml0aWFsaXplZCkgewogICAgICAgIHJldHVybiB0ZXh0Q29udGVudEl0ZW07CiAgICAgIH0KICAgICAgY29uc3QgewogICAgICAgIGZvbnQsCiAgICAgICAgbG9hZGVkTmFtZQogICAgICB9ID0gdGV4dFN0YXRlOwogICAgICBpZiAoIXNlZW5TdHlsZXMuaGFzKGxvYWRlZE5hbWUpKSB7CiAgICAgICAgc2VlblN0eWxlcy5hZGQobG9hZGVkTmFtZSk7CiAgICAgICAgdGV4dENvbnRlbnQuc3R5bGVzW2xvYWRlZE5hbWVdID0gewogICAgICAgICAgZm9udEZhbWlseTogZm9udC5mYWxsYmFja05hbWUsCiAgICAgICAgICBhc2NlbnQ6IGZvbnQuYXNjZW50LAogICAgICAgICAgZGVzY2VudDogZm9udC5kZXNjZW50LAogIC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Um90YXRpb24obGFzdFBvc1gsIGxhc3RQb3NZLCB0ZXh0Q29udGVudEl0ZW0ucHJldlRyYW5zZm9ybSk7CiAgICAgIH0KICAgICAgaWYgKHRleHRTdGF0ZS5mb250LnZlcnRpY2FsKSB7CiAgICAgICAgY29uc3QgYWR2YW5jZVkgPSAobGFzdFBvc1kgLSBwb3NZKSAvIHRleHRDb250ZW50SXRlbS50ZXh0QWR2YW5jZVNjYWxlOwogICAgICAgIGNvbnN0IGFkdmFuY2VYID0gcG9zWCAtIGxhc3RQb3NYOwogICAgICAgIGNvbnN0IHRleHRPcmllbnRhdGlvbiA9IE1hdGguc2lnbih0ZXh0Q29udGVudEl0ZW0uaGVpZ2h0KTsKICAgICAgICBpZiAoYWR2YW5jZVkgPCB0ZXh0T3JpZW50YXRpb24gKiB0ZXh0Q29udGVudEl0ZW0ubmVnYXRpdmVTcGFjZU1heCkgewogICAgICAgICAgaWYgKE1hdGguYWJzKGFkdmFuY2VYKSA+IDAuNSAqIHRleHRDb250ZW50SXRlbS53aWR0aCkgewogICAgICAgICAgICBhcHBlbmRFT0woKTsKICAgICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgICB9CiAgICAgICAgICByZXNldExhc3RDaGFycygpOwogICAgICAgICAgZmx1c2hUZXh0Q29udGVudEl0ZW0oKTsKICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgIH0KICAgICAgICBpZiAoTWF0aC5hYnMoYWR2YW5jZVgpID4gdGV4dENvbnRlbnRJdGVtLndpZHRoKSB7CiAgICAgICAgICBhcHBlbmRFT0woKTsKICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgIH0KICAgICAgICBpZiAoYWR2YW5jZVkgPD0gdGV4dE9yaWVudGF0aW9uICogdGV4dENvbnRlbnRJdGVtLm5vdEFTcGFjZSkgewogICAgICAgICAgcmVzZXRMYXN0Q2hhcnMoKTsKICAgICAgICB9CiAgICAgICAgaWYgKGFkdmFuY2VZIDw9IHRleHRPcmllbnRhdGlvbiAqIHRleHRDb250ZW50SXRlbS50cmFja2luZ1NwYWNlTWluKSB7CiAgICAgICAgICB0ZXh0Q29udGVudEl0ZW0uaGVpZ2h0ICs9IGFkdmFuY2VZOwogICAgICAgIH0gZWxzZSBpZiAoIWFkZEZha2VTcGFjZXMoYWR2YW5jZVksIHRleHRDb250ZW50SXRlbS5wcmV2VHJhbnNmb3JtLCB0ZXh0T3JpZW50YXRpb24pKSB7CiAgICAgICAgICBpZiAodGV4dENvbnRlbnRJdGVtLnN0ci5sZW5ndGggPT09IDApIHsKICAgICAgICAgICAgcmVzZXRMYXN0Q2hhcnMoKTsKICAgICAgICAgICAgdGV4dENvbnRlbnQuaXRlbXMucHVzaCh7CiAgICAgICAgICAgICAgc3RyOiAiICIsCiAgICAgICAgICAgICAgZGlyOiAibHRyIiwKICAgICAgICAgICAgICB3aWR0aDogMCwKICAgICAgICAgICAgICBoZWlnaHQ6IE1hdGguYWJzKGFkdmFuY2VZKSwKICAgICAgICAgICAgICB0cmFuc2Zvcm06IHRleHRDb250ZW50SXRlbS5wcmV2VHJhbnNmb3JtLAogICAgICAgICAgICAgIGZvbnROYW1lOiB0ZXh0Q29udGVudEl0ZW0uZm9udE5hbWUsCiAgICAgICAgICAgICAgaGFzRU9MOiBmYWxzZQogICAgICAgICAgICB9KTsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHRleHRDb250ZW50SXRlbS5oZWlnaHQgKz0gYWR2YW5jZVk7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGlmIChNYXRoLmFicyhhZHZhbmNlWCkgPiB0ZXh0Q29udGVudEl0ZW0ud2lkdGggKiBWRVJUSUNBTF9TSElGVF9SQVRJTykgewogICAgICAgICAgZmx1c2hUZXh0Q29udGVudEl0ZW0oKTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgIH0KICAgICAgY29uc3QgYWR2YW5jZVggPSAocG9zWCAtIGxhc3RQb3NYKSAvIHRleHRDb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AgICAgICAgaWYgKHRleHRDb250ZW50SXRlbS5zdHIubGVuZ3RoID09PSAwKSB7CiAgICAgICAgICByZXNldExhc3RDaGFycygpOwogICAgICAgICAgdGV4dENvbnRlbnQuaXRlbXMucHVzaCh7CiAgICAgICAgICAgIHN0cjogIiAiLAogICAgICAgICAgICBkaXI6ICJsdHIiLAogICAgICAgICAgICB3aWR0aDogTWF0aC5hYnMoYWR2YW5jZVgpLAogICAgICAgICAgICBoZWlnaHQ6IDAsCiAgICAgICAgICAgIHRyYW5zZm9ybTogdGV4dENvbnRlbnRJdGVtLnByZXZUcmFuc2Zvcm0sCiAgICAgICAgICAgIGZvbnROYW1lOiB0ZXh0Q29udGVudEl0ZW0uZm9udE5hbWUsCiAgICAgICAgICAgIGhhc0VPTDogZmFsc2UKICAgICAgICAgIH0pOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICB0ZXh0Q29udGVudEl0ZW0ud2lkdGggKz0gYWR2YW5jZVg7CiAgICAgICAgfQogICAgICB9CiAgICAgIGlmIChNYXRoLmFicyhhZHZhbmNlWSkgPiB0ZXh0Q29udGVudEl0ZW0uaGVpZ2h0ICogVkVSVElDQUxfU0hJRlRfUkFUSU8pIHsKICAgICAgICBmbHVzaFRleHRDb250ZW50SXRlbSgpOwogICAgICB9CiAgICAgIHJldHVybiB0cnVlOwogICAgfQogICAgZnVuY3Rpb24gYnVpbGRUZXh0Q29udGVudEl0ZW0oX3JlZjgpIHsKICAgICAgbGV0IHsKICAgICAgICBjaGFycywKICAgICAgICBleHRyYVNwYWNpbmcKICAgICAgfSA9IF9yZWY4OwogICAgICBjb25zdCBmb250ID0gdGV4dFN0YXRlLmZvbnQ7CiAgICAgIGlmICghY2hhcnMpIHsKICAgICAgICBjb25zdCBjaGFyU3BhY2luZyA9IHRleHRTdGF0ZS5jaGFyU3BhY2luZyArIGV4dHJhU3BhY2luZzsKICAgICAgICBpZiAoY2hhclNwYWNpbmcpIHsKICAgICAgICAgIGlmICghZm9udC52ZXJ0aWNhbCkgewogICAgICAgICAgICB0ZXh0U3RhdGUudHJhbnNsYXRlVGV4dE1hdHJpeChjaGFyU3BhY2luZyAqIHRleHRTdGF0ZS50ZXh0SFNjYWxlLCAwKTsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHRleHRTdGF0ZS50cmFuc2xhdGVUZXh0TWF0cml4KDAsIC1jaGFyU3BhY2luZyk7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIHJldHVybjsKICAgICAgfQogICAgICBjb25zdCBnbHlwaHMgPSBmb250LmNoYXJzVG9HbHlwaHMoY2hhcnMpOwogICAgICBjb25zdCBzY2FsZSA9IHRleHRTdGF0ZS5mb250TWF0cml4WzBdICogdGV4dFN0YXRlLmZvbnRTaXplOwogICAgICBmb3IgKGxldCBpID0gMCwgaWkgPSBnbHlwaHMubGVuZ3RoOyBpIDwgaWk7IGkrKykgewogICAgICAgIGNvbnN0IGdseXBoID0gZ2x5cGhzW2ldOwogICAgICAgIGNvbnN0IHsKICAgICAgICAgIGNhdGVnb3J5CiAgICAgICAgfSA9IGdseXBoOwogICAgICAgIGlmIChjYXRlZ29yeS5pc0ludmlzaWJsZUZvcm1hdE1hcmspIHsKICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgIH0KICAgICAgICBsZXQgY2hhclNwYWNpbmcgPSB0ZXh0U3RhdGUuY2hhclNwYWNpbmcgKyAoaSArIDEgPT09IGlpID8gZXh0cmFTcGFjaW5nIDogMCk7CiAgICAgICAgbGV0IGdseXBoV2lkdGggPSBnbHlwaC53aWR0aDsKICAgICAgICBpZiAoZm9udC52ZXJ0aWNhbCkgewogICAgICAgICAgZ2x5cGhXaWR0aCA9IGdseXBoLnZtZXRyaWMgPyBnbHlwaC52bWV0cmljWzBdIDogLWdseXBoV2lkdGg7CiAgICAgICAgfQogICAgICAgIGxldCBzY2FsZWREaW0gPSBnbHlwaFdpZHRoICogc2NhbGU7CiAgICAgICAgaWYgKGNhdGVnb3J5LmlzV2hpdGVzcGFjZSkgewogICAgICAgICAgaWYgKCFmb250LnZlcnRpY2FsKSB7CiAgICAgICAgICAgIGNoYXJTcGFjaW5nICs9IHNjYWxlZERpbSArIHRleHRTdGF0ZS53b3JkU3BhY2luZzsKICAgICAgICAgICAgdGV4dFN0YXRlLnRyYW5zbGF0ZVRleHRNYXRyaXgoY2hhclNwYWNpbmcgKiB0ZXh0U3RhdGUudGV4dEhTY2FsZSwgMCk7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBjaGFyU3BhY2luZyArPSAtc2NhbGVkRGltICsgdGV4dFN0YXRlLndvcmRTcGFjaW5nOwogICAgICAgICAgICB0ZXh0U3RhdGUudHJhbnNsYXRlVGV4dE1hdHJpeCgwLCAtY2hhclNwYWNpbmcpOwogICAgICAgICAgfQogICAgICAgICAgc2F2ZUxhc3RDaGFyKCIgIik7CiAgICAgICAgICBjb250aW51ZTsKICAgICAgICB9CiAgICAgICAgaWYgKCFjYXRlZ29yeS5pc1plcm9XaWR0aERpYWNyaXRpYyAmJiAhY29tcGFyZVdpdGhMYXN0UG9zaXRpb24oKSkgewogICAgICAgICAgY29udGludWU7CiAgICAgICAgfQogICAgICAgIGNvbnN0IHRleHRDaHVuayA9IGVuc3VyZVRleHRDb250ZW50SXRlbSgpOwogICAgICAgIGlmIChjYXRlZ29yeS5pc1plcm9XaWR0aERpYWNyaXRpYykgewogICAgICAgICAgc2NhbGVkRGltID0gMDsKICAgICAgICB9CiAgICAgICAgaWYgKCFmb250LnZlcnRpY2FsKSB7CiAgICAgICAgICBzY2FsZWREaW0gKj0gdGV4dFN0YXRlLnRleHRIU2NhbGU7CiAgICAgICAgICB0ZXh0U3RhdGUudHJhbnNsYXRlVGV4dE1hdHJpeChzY2FsZWREaW0sIDApOwogICAgICAgICAgdGV4dENodW5rLndpZHRoICs9IHNjYWxlZERpbTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgdGV4dFN0YXRlLnRyYW5zbGF0ZVRleHRNYXRyaXgoMCwgc2NhbGVkRGltKTsKICAgICAgICAgIHNjYWxlZERpbSA9IE1hdGguYWJzKHNjYWxlZERpbSk7CiAgICAgICAgICB0ZXh0Q2h1bmsuaGVpZ2h0ICs9IHNjYWxlZERpbTsKICAgICAgICB9CiAgICAgICAgaWYgKHNjYWxlZERpbSkgewogICAgICAgICAgdGV4dENodW5rLnByZXZUcmFuc2Zvcm0gPSBnZXRDdXJyZW50VGV4dFRyYW5zZm9ybSgpOwogICAgICAgIH0KICAgICAgICBjb25zdCBnbHlwaFVuaWNvZGUgPSBnbHlwaC5ub3JtYWxpemVkVW5pY29kZTsKICAgICAgICBpZiAoc2F2ZUxhc3RDaGFyKGdseXBoVW5pY29kZSkpIHsKICAgICAgICAgIHRleHRDaHVuay5zdHIucHVzaCgiICIpOwogICAgICAgIH0KICAgICAgICB0ZXh0Q2h1bmsuc3RyLnB1c2goZ2x5cGhVbmljb2RlKTsKICAgICAgICBpZiAoY2hhclNwYWNpbmcpIHsKICAgICAgICAgIGlmICghZm9udC52ZXJ0aWNhbCkgewogICAgICAgICAgICB0ZXh0U3RhdGUudHJhbnNsYXRlVGV4dE1hdHJpeChjaGFyU3BhY2luZyAqIHRleHRTdGF0ZS50ZXh0SFNjYWxlLCAwKTsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHRleHRTdGF0ZS50cmFuc2xhdGVUZXh0TWF0cml4KDAsIC1jaGFyU3BhY2luZyk7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9CiAgICB9CiAgICBmdW5jdGlvbiBhcHBlbmRFT0woKSB7CiAgICAgIHJlc2V0TGFzdENoYXJzKCk7CiAgICAgIGlmICh0ZXh0Q29udGVudEl0ZW0uaW5pdGlhbGl6ZWQpIHsKICAgICAgICB0ZXh0Q29udGVudEl0ZW0uaGFzRU9MID0gdHJ1ZTsKICAgICAgICBmbHVzaFRleHRDb250ZW50SXRlbSgpOwogICAgICB9IGVsc2UgewogICAgICAgIHRleHRDb250ZW50Lml0ZW1zLnB1c2goewogICAgICAgICAgc3RyOiAiIiwKICAgICAgICAgIGRpcjogImx0ciIsCiAgICAgICAgICB3aWR0aDogMCwKICAgICAgICAgIGhlaWdodDogMCwKICAgICAgICAgIHRyYW5zZm9ybTogZ2V0Q3VycmVudFRleHRUcmFuc2Zvcm0oKSwKICAgICAgICAgIGZvbnROYW1lOiB0ZXh0U3RhdGUubG9hZGVkTmFtZSwKICAgICAgICAgIGhhc0VPTDogdHJ1ZQogICAgICAgIH0pOwogICAgICB9CiAgICB9CiAgICBmdW5jdGlvbiBhZGRGYWtlU3BhY2VzKHdpZHRoLCB0cmFuc2YsIHRleHRPcmllbnRhdGlvbikgewogICAgICBpZiAodGV4dE9yaWVudGF0aW9uICogdGV4dENvbnRlbnRJdGVtLnNwYWNlSW5GbG93TWluIDw9IHdpZHRoICYmIHdpZHRoIDw9IHRleHRPcmllbnRhdGlvbiAqIHRleHRDb250ZW50SXRlbS5zcGFjZUluRmxvd01heCkgewogICAgICAgIGlmICh0ZXh0Q29udGVudEl0ZW0uaW5pdGlhbGl6ZWQpIHsKICAgICAgICAgIHJlc2V0TGFzdENoYXJzKCk7CiAgICAgICAgICB0ZXh0Q29udGVudEl0ZW0uc3RyLnB1c2goIiAiKTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICB9CiAgICAgIGNvbnN0IGZvbnROYW1lID0gdGV4dENvbnRlbnRJdGVtLmZvbnROYW1lOwogICAgICBsZXQgaGVpZ2h0ID0gMDsKICAgICAgaWYgKHRleHRDb250ZW50SXRlbS52ZXJ0aWNhbCkgewogICAgICAgIGhlaWdodCA9IHdpZHRoOwogICAgICAgIHdpZHRoID0gMDsKICAgICAgfQogICAgICBmbHVzaFRleHRDb250ZW50SXRlbSgpOwogICAgICByZXNldExhc3RDaGFycygpOwogICAgICB0ZXh0Q29udGVudC5pdGVtcy5wdXNoKHsKICAgICAgICBzdHI6ICIgIiwKICAgICAgICBkaXI6ICJsdHIiLAogICAgICA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NbMF0gOiBmYWxzZTsKICAgICAgY29uc3QgbGVuZ3RoID0gdGV4dENvbnRlbnQuaXRlbXMubGVuZ3RoOwogICAgICBpZiAobGVuZ3RoID09PSAwKSB7CiAgICAgICAgcmV0dXJuOwogICAgICB9CiAgICAgIGlmIChiYXRjaCAmJiBsZW5ndGggPCBURVhUX0NIVU5LX0JBVENIX1NJWkUpIHsKICAgICAgICByZXR1cm47CiAgICAgIH0KICAgICAgc2luay5lbnF1ZXVlKHRleHRDb250ZW50LCBsZW5ndGgpOwogICAgICB0ZXh0Q29udGVudC5pdGVtcyA9IFtdOwogICAgICB0ZXh0Q29udGVudC5zdHlsZXMgPSBPYmplY3QuY3JlYXRlKG51bGwpOwogICAgfQogICAgY29uc3QgdGltZVNsb3RNYW5hZ2VyID0gbmV3IFRpbWVTbG90TWFuYWdlcigpOwogICAgcmV0dXJuIG5ldyBQcm9taXNlKGZ1bmN0aW9uIHByb21pc2VCb2R5KHJlc29sdmUsIHJlamVjdCkgewogICAgICBjb25zdCBuZXh0ID0gZnVuY3Rpb24gKHByb21pc2UpIHsKICAgICAgICBlbnF1ZXVlQ2h1bmsodHJ1ZSk7CiAgICAgICAgUHJvbWlzZS5hbGwoW3Byb21pc2UsIHNpbmsucmVhZHldKS50aGVuKGZ1bmN0aW9uICgpIHsKICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgIHByb21pc2VCb2R5KHJlc29sdmUsIHJlamVjdCk7CiAgICAgICAgICB9IGNhdGNoIChleCkgewogICAgICAgICAgICByZWplY3QoZXgpOwogICAgICAgICAgfQogICAgICAgIH0sIHJlamVjdCk7CiAgICAgIH07CiAgICAgIHRhc2suZW5zdXJlTm90VGVybWluYXRlZCgpOwogICAgICB0aW1lU2xvdE1hbmFnZXIucmVzZXQoKTsKICAgICAgY29uc3Qgb3BlcmF0aW9uID0ge307CiAgICAgIGxldCBzdG9wLAogICAgICAgIGFyZ3MgPSBbXTsKICAgICAgd2hpbGUgKCEoc3RvcCA9IHRpbWVTbG90TWFuYWdlci5jaGVjaygpKSkgewogICAgICAgIGFyZ3MubGVuZ3RoID0gMDsKICAgICAgICBvcGVyYXRpb24uYXJncyA9IGFyZ3M7CiAgICAgICAgaWYgKCFwcmVwcm9jZXNzb3IucmVhZChvcGVyYXRpb24pKSB7CiAgICAgICAgICBicmVhazsKICAgICAgICB9CiAgICAgICAgdGV4dFN0YXRlID0gc3RhdGVNYW5hZ2VyLnN0YXRlOwogICAgICAgIGNvbnN0IGZuID0gb3BlcmF0aW9uLmZuOwogICAgICAgIGFyZ3MgPSBvcGVyYXRpb24uYXJnczsKICAgICAgICBzd2l0Y2ggKGZuIHwgMCkgewogICAgICAgICAgY2FzZSBfdXRpbC5PUFMuc2V0Rm9udDoKICAgICAgICAgICAgdmFyIGZvbnROYW1lQXJnID0gYXJnc1swXS5uYW1lLAogICAgICAgICAgICAgIGZvbnRTaXplQXJnID0gYXJnc1sxXTsKICAgICAgICAgICAgaWYgKHRleHRTdGF0ZS5mb250ICYmIGZvbnROYW1lQXJnID09PSB0ZXh0U3RhdGUuZm9udE5hbWUgJiYgZm9udFNpemVBcmcgPT09IHRleHRTdGF0ZS5mb250U2l6ZSkgewogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGZsdXNoVGV4dENvbnRlbnRJdGVtKCk7CiAgICAgICAgICAgIHRleHRTdGF0ZS5mb250TmFtZSA9IGZvbnROYW1lQXJnOwogICAgICAgICAgICB0ZXh0U3RhdGUuZm9udFNpemUgPSBmb250U2l6ZUFyZzsKICAgICAgICAgICAgbmV4dChoYW5kbGVTZXRGb250KGZvbnROYW1lQXJnLCBudWxsKSk7CiAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnNldFRleHRSaXNlOgogICAgICAgICAgICB0ZXh0U3RhdGUudGV4dFJpc2UgPSBhcmdzWzBdOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgX3V0aWwuT1BTL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dGV4dFN0YXRlLnNldFRleHRMaW5lTWF0cml4KGFyZ3NbMF0sIGFyZ3NbMV0sIGFyZ3NbMl0sIGFyZ3NbM10sIGFyZ3NbNF0sIGFyZ3NbNV0pOwogICAgICAgICAgICB1cGRhdGVBZHZhbmNlU2NhbGUoKTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIF91dGlsLk9QUy5zZXRDaGFyU3BhY2luZzoKICAgICAgICAgICAgdGV4dFN0YXRlLmNoYXJTcGFjaW5nID0gYXJnc1swXTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIF91dGlsLk9QUy5zZXRXb3JkU3BhY2luZzoKICAgICAgICAgICAgdGV4dFN0YXRlLndvcmRTcGFjaW5nID0gYXJnc1swXTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIF91dGlsLk9QUy5iZWdpblRleHQ6CiAgICAgICAgICAgIHRleHRTdGF0ZS50ZXh0TWF0cml4ID0gX3V0aWwuSURFTlRJVFlfTUFUUklYLnNsaWNlKCk7CiAgICAgICAgICAgIHRleHRTdGF0ZS50ZXh0TGluZU1hdHJpeCA9IF91dGlsLklERU5USVRZX01BVFJJWC5zbGljZSgpOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnNob3dTcGFjZWRUZXh0OgogICAgICAgICAgICBpZiAoIXN0YXRlTWFuYWdlci5zdGF0ZS5mb250KSB7CiAgICAgICAgICAgICAgc2VsZi5lbnN1cmVTdGF0ZUZvbnQoc3RhdGVNYW5hZ2VyLnN0YXRlKTsKICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgfQogICAgICAgICAgICBjb25zdCBzcGFjZUZhY3RvciA9ICh0ZXh0U3RhdGUuZm9udC52ZXJ0aWNhbCA/IDEgOiAtMSkgKiB0ZXh0U3RhdGUuZm9udFNpemUgLyAxMDAwOwogICAgICAgICAgICBjb25zdCBlbGVtZW50cyA9IGFyZ3NbMF07CiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBpaSA9IGVsZW1lbnRzLmxlbmd0aDsgaSA8IGlpIC0gMTsgaSsrKSB7CiAgICAgICAgICAgICAgY29uc3QgaXRlbSA9IGVsZW1lbnRzW2ldOwogICAgICAgICAgICAgIGlmICh0eXBlb2YgaXRlbSA9PT0gInN0cmluZyIpIHsKICAgICAgICAgICAgICAgIHNob3dTcGFjZWRUZXh0QnVmZmVyLnB1c2goaXRlbSk7CiAgICAgICAgICAgICAgfSBlbHNlIGlmICh0eXBlb2YgaXRlbSA9PT0gIm51bWJlciIgJiYgaXRlbSAhPT0gMCkgewogICAgICAgICAgICAgICAgY29uc3Qgc3RyID0gc2hvd1NwYWNlZFRleHRCdWZmZXIuam9pbigiIik7CiAgICAgICAgICAgICAgICBzaG93U3BhY2VkVGV4dEJ1ZmZlci5sZW5ndGggPSAwOwogICAgICAgICAgICAgICAgYnVpbGRUZXh0Q29udGVudEl0ZW0oewogICAgICAgICAgICAgICAgICBjaGFyczogc3RyLAogICAgICAgICAgICAgICAgICBleHRyYVNwYWNpbmc6IGl0ZW0gKiBzcGFjZUZhY3RvcgogICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICAgIGNvbnN0IGl0ZW0gPSBlbGVtZW50cy5hdCgtMSk7CiAgICAgICAgICAgIGlmICh0eXBlb2YgaXRlbSA9PT0gInN0cmluZyIpIHsKICAgICAgICAgICAgICBzaG93U3BhY2VkVGV4dEJ1ZmZlci5wdXNoKGl0ZW0pOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmIChzaG93U3BhY2VkVGV4dEJ1ZmZlci5sZW5ndGggPiAwKSB7CiAgICAgICAgICAgICAgY29uc3Qgc3RyID0gc2hvd1NwYWNlZFRleHRCdWZmZXIuam9pbigiIik7CiAgICAgICAgICAgICAgc2hvd1NwYWNlZFRleHRCdWZmZXIubGVuZ3RoID0gMDsKICAgICAgICAgICAgICBidWlsZFRleHRDb250ZW50SXRlbSh7CiAgICAgICAgICAgICAgICBjaGFyczogc3RyLAogICAgICAgICAgICAgICAgZXh0cmFTcGFjaW5nOiAwCiAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIF91dGlsLk9QUy5zaG93VGV4dDoKICAgICAgICAgICAgaWYgKCFzdGF0ZU1hbmFnZXIuc3RhdGUuZm9udCkgewogICAgICAgICAgICAgIHNlbGYuZW5zdXJlU3RhdGVGb250KHN0YXRlTWFuYWdlci5zdGF0ZSk7CiAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgYnVpbGRUZXh0Q29udGVudEl0ZW0oewogICAgICAgICAgICAgIGNoYXJzOiBhcmdzWzBdLAogICAgICAgICAgICAgIGV4dHJhU3BhY2luZzogMAogICAgICAgICAgICB9KTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIF91dGlsLk9QUy5uZXh0TGluZVNob3dUZXh0OgogICAgICAgICAgICBpZiAoIXN0YXRlTWFuYWdlci5zdGF0ZS5mb250KSB7CiAgICAgICAgICAgICAgc2VsZi5lbnN1cmVTdGF0ZUZvbnQoc3RhdGVNYW5hZ2VyLnN0YXRlKTsKICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgfQogICAgICAgICAgICB0ZXh0U3RhdGUuY2FycmlhZ2VSZXR1cm4oKTsKICAgICAgICAgICAgYnVpbGRUZXh0Q29udGVudEl0ZW0oewogICAgICAgICAgICAgIGNoYXJzOiBhcmdzWzBdLAogICAgICAgICAgICAgIGV4dHJhU3BhY2luZzogMAogICAgICAgICAgICB9KTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIF91dGlsLk9QUy5uZXh0TGluZVNldFNwYWNpbmdTaG93VGV4dDoKICAgICAgICAgICAgaWYgKCFzdGF0ZU1hbmFnZXIuc3RhdGUuZm9udCkgewogICAgICAgICAgICAgIHNlbGYuZW5zdXJlU3RhdGVGb250KHN0YXRlTWFuYWdlci5zdGF0ZSk7CiAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgdGV4dFN0YXRlLndvcmRTcGFjaW5nID0gYXJnc1swXTsKICAgICAgICAgICAgdGV4dFN0YXRlLmNoYXJTcGFjaW5nID0gYXJnc1sxXTsKICAgICAgICAgICAgdGV4dFN0YXRlLmNhcnJpYWdlUmV0dXJuKCk7CiAgICAgICAgICAgIGJ1aWxkVGV4dENvbnRlbnRJdGVtKHsKICAgICAgICAgICAgICBjaGFyczogYXJnc1syXSwKICAgICAgICAgICAgICBleHRyYVNwYWNpbmc6IDAKICAgICAgICAgICAgfSk7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSBfdXRpbC5PUFMucGFpbnRYT2JqZWN0OgogICAgICAgICAgICBmbHVzaFRleHRDb250ZW50SXRlbSgpOwogICAgICAgICAgICBpZiAoIXhvYmpzKSB7CiAgICAgICAgICAgICAgeG9ianMgPSByZXNvdXJjZXMuZ2V0KCJYT2JqZWN0IikgfHwgX3ByaW1pdGl2ZXMuRGljdC5lbXB0eTsKICAgICAgICAgICAgfQogICAgICAgICAgICB2YXIgaXNWYWxpZE5hbWUgPSBhcmdzWzBdIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuTmFtZTsKICAgICAgICAgICAgdmFyIG5hbWUgPSBhcmdzWzBdLm5hbWU7CiAgICAgICAgICAgIGlmIChpc1ZhbGlkTmFtZSAmJiBlbXB0eVhPYmplY3RDYWNoZS5nZXRCeU5hbWUobmFtZSkpIHsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgfQogICAgICAgICAgICBuZXh0KG5ldyBQcm9taXNlKGZ1bmN0aW9uIChyZXNvbHZlWE9iamVjdCwgcmVqZWN0WE9iamVjdCkgewogICAgICAgICAgICAgIGlmICghaXNWYWxpZE5hbWUpIHsKICAgICAgICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiWE9iamVjdCBtdXN0IGJlIHJlZmVycmVkIHRvIGJ5IG5hbWUuIik7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIGxldCB4b2JqID0geG9ianMuZ2V0UmF3KG5hbWUpOwogICAgICAgICAgICAgIGlmICh4b2JqIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuUmVmKSB7CiAgICAgICAgICAgICAgICBpZiAoZW1wdHlYT2JqZWN0Q2FjaGUuZ2V0QnlSZWYoeG9iaikpIHsKICAgICAgICAgICAgICAgICAgcmVzb2x2ZVhPYmplY3QoKTsKICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY29uc3QgZ2xvYmFsSW1hZ2UgPSBzZWxmLmdsb2JhbEltYWdlQ2FjaGUuZ2V0RGF0YSh4b2JqLCBzZWxmLnBhZ2VJbmRleCk7CiAgICAgICAgICAgICAgICBpZiAoZ2xvYmFsSW1hZ2UpIHsKICAgICAgICAgICAgICAgICAgcmVzb2x2ZVhPYmplY3QoKTsKICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgeG9iaiA9IHhyZWYuZmV0Y2goeG9iaik7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIGlmICghKHhvYmogaW5zdGFuY2VvZiBfYmFzZV9zdHJlYW0uQmFzZVN0cmVhbSkpIHsKICAgICAgICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiWE9iamVjdCBzaG91bGQgYmUgYSBzdHJlYW0iKTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgY29uc3QgdHlwZSA9IHhvYmouZGljdC5nZXQoIlN1YnR5cGUiKTsKICAgICAgICAgICAgICBpZiAoISh0eXBlIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuTmFtZSkpIHsKICAgICAgICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiWE9iamVjdCBzaG91bGQgaGF2ZSBhIE5hbWUgc3VidHlwZSIpOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBpZiAodHlwZS5uYW1lICE9PSAiRm9ybSIpIHsKICAgICAgICAgICAgICAgIGVtcHR5WE9iamVjdENhY2hlLnNldChuYW1lLCB4b2JqLmRpY3Qub2JqSWQsIHRydWUpOwogICAgICAgICAgICAgICAgcmVzb2x2ZVhPYmplY3QoKTsKICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgY29uc3QgY3VycmVudFN0YXRlID0gc3RhdGVNYW5hZ2VyLnN0YXRlLmNsb25lKCk7CiAgICAgICAgICAgICAgY29uc3QgeE9ialN0YXRlTWFuYWdlciA9IG5ldyBTdGF0ZU1hbmFnZXIoY3VycmVudFN0YXRlKTsKICAgICAgICAgICAgICBjb25zdCBtYXRyaXggPSB4b2JqLmRpY3QuZ2V0QXJyYXkoIk1hdHJpeCIpOwogICAgICAgICAgICAgIGlmIChBcnJheS5pc0FycmF5KG1hdHJpeCkgJiYgbWF0cml4Lmxlbmd0aCA9PT0gNikgewogICAgICAgICAgICAgICAgeE9ialN0YXRlTWFuYWdlci50cmFuc2Zvcm0obWF0cml4KTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgZW5xdWV1ZUNodW5rKCk7CiAgICAgICAgICAgICAgY29uc3Qgc2lua1dyYXBwZXIgPSB7CiAgICAgICAgICAgICAgICBlbnF1ZXVlSW52b2tlZDogZmFsc2UsCiAgICAgICAgICAgICAgICBlbnF1ZXVlKGNodW5rLCBzaXplKSB7CiAgICAgICAgICAgICAgICAgIHRoaXMuZW5xdWV1ZUludm9rZWQgPSB0cnVlOwogICAgICAgICAgICAgICAgICBzaW5rLmVucXVldWUoY2h1bmssIHNpemUpOwogICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgIGdldCBkZXNpcmVkU2l6ZSgpIHsKICAgICAgICAgICAgICAgICAgcmV0dXJuIHNpbmsuZGVzaXJlZFNpemU7CiAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgZ2V0IHJlYWR5KCkgewogICAgICAgICAgICAgICAgICByZXR1cm4gc2luay5yZWFkeTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgIHNlbGYuZ2V0VGV4dENvbnRlbnQoewogICAgICAgICAgICAgICAgc3RyZWFtOiB4b2JqLAogICAgICAgICAgICAgICAgdGFzaywKICAgICAgICAgICAgICAgIHJlc291cmNlczogeG9iai5kaWN0LmdldCgiUmVzb3VyY2VzIikgfHwgcmVzb3VyY2VzLAogICAgICAgICAgICAgICAgc3RhdGVNYW5hZ2VyOiB4T2JqU3RhdGVNYW5hZ2VyLAogICAgICAgICAgICAgICAgY29tYmluZVRleHRJdGVtcywKICAgICAgICAgICAgICAgIGluY2x1ZGVNYXJrZWRDb250ZW50LAogICAgICAgICAgICAgICAgc2luazogc2lua1dyYXBwZXIsCiAgICAgICAgICAgICAgICBzZWVuU3R5bGVzLAogICAgICAgICAgICAgICAgdmlld0JveCwKICAgICAgICAgICAgICAgIG1hcmtlZENvbnRlbnREYXRhCiAgICAgICAgICAgICAgfSkudGhlbihmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICBpZiAoIXNpbmtXcmFwcGVyLmVucXVldWVJbnZva2VkKSB7CiAgICAgICAgICAgICAgICAgIGVtcHR5WE9iamVjdENhY2hlLnNldChuYW1lLCB4b2JqLmRpY3Qub2JqSWQsIHRydWUpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgcmVzb2x2ZVhPYmplY3QoKTsKICAgICAgICAgICAgICB9LCByZWplY3RYT2JqZWN0KTsKICAgICAgICAgICAgfSkuY2F0Y2goZnVuY3Rpb24gKHJlYXNvbikgewogICAgICAgICAgICAgIGlmIChyZWFzb24gaW5zdGFuY2VvZiBfdXRpbC5BYm9ydEV4Y2VwdGlvbikgewogICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBpZiAoc2VsZi5vcHRpb25zLmlnbm9yZUVycm9ycykgewogICAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKGBnZXRUZXh0Q29udGVudCAtIGlnbm9yaW5nIFhPYmplY3Q6ICIke3JlYXNvbn0iLmApOwogICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICB0aHJvdyByZWFzb247CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgY2FzZSBfdXRpbC5PUFMuc2V0R1N0YXRlOgogICAgICAgICAgICBpc1ZhbGlkTmFtZSA9IGFyZ3NbMF0gaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lOwogICAgICAgICAgICBuYW1lID0gYXJnc1swXS5uYW1lOwogICAgICAgICAgICBpZiAoaXNWYWxpZE5hbWUgJiYgZW1wdHlHU3RhdGVDYWNoZS5nZXRCeU5hbWUobmFtZSkpIHsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgfQogICAgICAgICAgICBuZXh0KG5ldyBQcm9taXNlKGZ1bmN0aW9uIChyZXNvbHZlR1N0YXRlLCByZWplY3RHU3RhdGUpIHsKICAgICAgICAgICAgICBpZiAoIWlzVmFsaWROYW1lKSB7CiAgICAgICAgICAgICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoIkdTdGF0ZSBtdXN0IGJlIHJlZmVycmVkIHRvIGJ5IG5hbWUuIik7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIGNvbnN0IGV4dEdTdGF0ZSA9IHJlc291cmNlcy5nZXQoIkV4dEdTdGF0ZSIpOwogICAgICAgICAgICAgIGlmICghKGV4dEdTdGF0ZSBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLkRpY3QpKSB7CiAgICAgICAgICAgICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoIkV4dEdTdGF0ZSBzaG91bGQgYmUgYSBkaWN0aW9uYXJ5LiIpOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBjb25zdCBnU3RhdGUgPSBleHRHU3RhdGUuZ2V0KG5hbWUpOwogICAgICAgICAgICAgIGlmICghKGdTdGF0ZSBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLkRpY3QpKSB7CiAgICAgICAgICAgICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoIkdTdGF0ZSBzaG91bGQgYmUgYSBkaWN0aW9uYXJ5LiIpOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBjb25zdCBnU3RhdGVGb250ID0gZ1N0YXRlLmdldCgiRm9udCIpOwogICAgICAgICAgICAgIGlmICghZ1N0YXRlRm9udCkgewogICAgICAgICAgICAgICAgZW1wdHlHU3RhdGVDYWNoZS5zZXQobmFtZSwgZ1N0YXRlLm9iaklkLCB0cnVlKTsKICAgICAgICAgICAgICAgIHJlc29sdmVHU3RhdGUoKTsKICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgZmx1c2hUZXh0Q29udGVudEl0ZW0oKTsKICAgICAgICAgICAgICB0ZXh0U3RhdGUuZm9udE5hbWUgPSBudWxsOwogICAgICAgICAgICAgIHRleHRTdGF0ZS5mb250U2l6ZSA9IGdTdGF0ZUZvbnRbMV07CiAgICAgICAgICAgICAgaGFuZGxlU2V0Rm9udChudWxsLCBnU3RhdGVGb250WzBdKS50aGVuKHJlc29sdmVHU3RhdGUsIHJlamVjdEdTdGF0ZSk7CiAgICAgICAgICAgIH0pLmNhdGNoKGZ1bmN0aW9uIChyZWFzb24pIHsKICAgICAgICAgICAgICBpZiAocmVhc29uIGluc3RhbmNlb2YgX3V0aWwuQWJvcnRFeGNlcHRpb24pIHsKICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgaWYgKHNlbGYub3B0aW9ucy5pZ25vcmVFcnJvcnMpIHsKICAgICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgZ2V0VGV4dENvbnRlbnQgLSBpZ25vcmluZyBFeHRHU3RhdGU6ICIke3JlYXNvbn0iLmApOwogICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICB0aHJvdyByZWFzb247CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgY2FzZSBfdXRpbC5PUFMuYmVnaW5NYXJrZWRDb250ZW50OgogICAgICAgICAgICBmbHVzaFRleHRDb250ZW50SXRlbSgpOwogICAgICAgICAgICBpZiAoaW5jbHVkZU1hcmtlZENvbnRlbnQpIHsKICAgICAgICAgICAgICBtYXJrZWRDb250ZW50RGF0YS5sZXZlbCsrOwogICAgICAgICAgICAgIHRleHRDb250ZW50Lml0ZW1zLnB1c2goewogICAgICAgICAgICAgICAgdHlwZTogImJlZ2luTWFya2VkQ29udGVudCIsCiAgICAgICAgICAgICAgICB0YWc6IGFyZ3NbMF0gaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lID8gYXJnc1swXS5uYW1lIDogbnVsbAogICAgICAgICAgICAgIH0pOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSBfdXRpbC5PUFMuYmVnaW5NYXJrZWRDb250ZW50UHJvcHM6CiAgICAgICAgICAgIGZsdXNoVGV4dENvbnRlbnRJdGVtKCk7CiAgICAgICAgICAgIGlmIChpbmNsdWRlTWFya2VkQ29udGVudCkgewogICAgICAgICAgICAgIG1hcmtlZENvbnRlbnREYXRhLmxldmVsKys7CiAgICAgICAgICAgICAgbGV0IG1jaWQgPSBudWxsOwogICAgICAgICAgICAgIGlmIChhcmdzWzFdIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuRGljdCkgewogICAgICAgICAgICAgICAgbWNpZCA9IGFyZ3NbMV0uZ2V0KCJNQ0lEIik7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIHRleHRDb250ZW50Lml0ZW1zLnB1c2goewogICAgICAgICAgICAgICAgdHlwZTogImJlZ2luTWFya2VkQ29udGVudFByb3BzIiwKICAgICAgICAgICAgICAgIGlkOiBOdW1iZXIuaXNJbnRlZ2VyKG1jaWQpID8gYCR7c2VsZi5pZEZhY3RvcnkuZ2V0UGFnZU9iaklkKCl9X21jaWQke21jaWR9YCA6IG51bGwsCiAgICAgICAgICAgICAgICB0YWc6IGFyZ3NbMF0gaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lID8gYXJnc1swXS5uYW1lIDogbnVsbAogICAgICAgICAgICAgIH0pOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSBfdXRpbC5PUFMuZW5kTWFya2VkQ29udGVudDoKICAgICAgICAgICAgZmx1c2hUZXh0Q29udGVudEl0ZW0oKTsKICAgICAgICAgICAgaWYgKGluY2x1ZGVNYXJrZWRDb250ZW50KSB7CiAgICAgICAgICAgICAgaWYgKG1hcmtlZENvbnRlbnREYXRhLmxldmVsID09PSAwKSB7CiAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgbWFya2VkQ29udGVudERhdGEubGV2ZWwtLTsKICAgICAgICAgICAgICB0ZXh0Q29udGVudC5pdGVtcy5wdXNoKHsKICAgICAgICAgICAgICAgIHR5cGU6ICJlbmRNYXJrZWRDb250ZW50IgogICAgICAgICAgICAgIH0pOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgIH0KICAgICAgICBpZiAodGV4dENvbnRlbnQuaXRlbXMubGVuZ3RoID49IHNpbmsuZGVzaXJlZFNpemUpIHsKICAgICAgICAgIHN0b3AgPSB0cnVlOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICB9CiAgICAgIGlmIChzdG9wKSB7CiAgICAgICAgbmV4dChkZWZlcnJlZCk7CiAgICAgICAgcmV0dXJuOwogICAgICB9CiAgICAgIGZsdXNoVGV4dENvbnRlbnRJdGVtKCk7CiAgICAgIGVucXVldWVDaHVuaygpOwogICAgICByZXNvbHZlKCk7CiAgICB9KS5jYXRjaChyZWFzb24gPT4gewogICAgICBpZiAocmVhc29uIGluc3RhbmNlb2YgX3V0aWwuQWJvcnRFeGNlcHRpb24pIHsKICAgICAgICByZXR1cm47CiAgICAgIH0KICAgICAgaWYgKHRoaXMub3B0aW9ucy5pZ25vcmVFcnJvcnMpIHsKICAgICAgICAoMCwgX3V0aWwud2FybikoYGdldFRleHRDb250ZW50IC0gaWdub3JpbmcgZXJyb3JzIGR1cmluZyAiJHt0YXNrLm5hbWV9IiBgICsgYHRhc2s6ICIke3JlYXNvbn0iLmApOwogICAgICAgIGZsdXNoVGV4dENvbnRlbnRJdGVtKCk7CiAgICAgICAgZW5xdWV1ZUNodW5rKCk7CiAgICAgICAgcmV0dXJuOwogICAgICB9CiAgICAgIHRocm93IHJlYXNvbjsKICAgIH0pOwogIH0KICBleHRyYWN0RGF0YVN0cnVjdHVyZXMoZGljdCwgYmFzZURpY3QsIHByb3BlcnRpZXMpIHsKICAgIGNvbnN0IHhyZWYgPSB0aGlzLnhyZWY7CiAgICBsZXQgY2lkVG9HaWRCeXRlczsKICAgIGNvbnN0IHRvVW5pY29kZVByb21pc2UgPSB0aGlzLnJlYWRUb1VuaWNvZGUocHJvcGVydGllcy50b1VuaWNvZGUgfHwgZGljdC5nZXQoIlRvVW5pY29kZSIpIHx8IGJhc2VEaWN0LmdldCgiVG9Vbmljb2RlIikpOwogICAgaWYgKHByb3BlcnRpZXMuY29tcG9zaXRlKSB7CiAgICAgIGNvbnN0IGNpZFN5c3RlbUluZm8gPSBkaWN0LmdldCgiQ0lEU3lzdGVtSW5mbyIpOwogICAgICBpZiAoY2lkU3lzdGVtS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nbHlwaHNVbmljb2RlTWFwID0gKDAsIF9nbHlwaGxpc3QuZ2V0R2x5cGhzVW5pY29kZSkoKTsKICAgIGZvciAoY29uc3QgY2hhcmNvZGUgaW4gZW5jb2RpbmcpIHsKICAgICAgbGV0IGdseXBoTmFtZSA9IGVuY29kaW5nW2NoYXJjb2RlXTsKICAgICAgaWYgKGdseXBoTmFtZSA9PT0gIiIpIHsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBsZXQgdW5pY29kZSA9IGdseXBoc1VuaWNvZGVNYXBbZ2x5cGhOYW1lXTsKICAgICAgaWYgKHVuaWNvZGUgIT09IHVuZGVmaW5lZCkgewogICAgICAgIHRvVW5pY29kZVtjaGFyY29kZV0gPSBTdHJpbmcuZnJvbUNoYXJDb2RlKHVuaWNvZGUpOwogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGxldCBjb2RlID0gMDsKICAgICAgc3dpdGNoIChnbHlwaE5hbWVbMF0pIHsKICAgICAgICBjYXNlICJHIjoKICAgICAgICAgIGlmIChnbHlwaE5hbWUubGVuZ3RoID09PSAzKSB7CiAgICAgICAgICAgIGNvZGUgPSBwYXJzZUludChnbHlwaE5hbWUuc3Vic3RyaW5nKDEpLCAxNik7CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJnIjoKICAgICAgICAgIGlmIChnbHlwaE5hbWUubGVuZ3RoID09PSA1KSB7CiAgICAgICAgICAgIGNvZGUgPSBwYXJzZUludChnbHlwaE5hbWUuc3Vic3RyaW5nKDEpLCAxNik7CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJDIjoKICAgICAgICBjYXNlICJjIjoKICAgICAgICAgIGlmIChnbHlwaE5hbWUubGVuZ3RoID49IDMgJiYgZ2x5cGhOYW1lLmxlbmd0aCA8PSA0KSB7CiAgICAgICAgICAgIGNvbnN0IGNvZGVTdHIgPSBnbHlwaE5hbWUuc3Vic3RyaW5nKDEpOwogICAgICAgICAgICBpZiAoZm9yY2VHbHlwaHMpIHsKICAgICAgICAgICAgICBjb2RlID0gcGFyc2VJbnQoY29kZVN0ciwgMTYpOwogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGNvZGUgPSArY29kZVN0cjsKICAgICAgICAgICAgaWYgKE51bWJlci5pc05hTihjb2RlKSAmJiBOdW1iZXIuaXNJbnRlZ2VyKHBhcnNlSW50KGNvZGVTdHIsIDE2KSkpIHsKICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fc2ltcGxlRm9udFRvVW5pY29kZShwcm9wZXJ0aWVzLCB0cnVlKTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAidSI6CiAgICAgICAgICB1bmljb2RlID0gKDAsIF91bmljb2RlLmdldFVuaWNvZGVGb3JHbHlwaCkoZ2x5cGhOYW1lLCBnbHlwaHNVbmljb2RlTWFwKTsKICAgICAgICAgIGlmICh1bmljb2RlICE9PSAtMSkgewogICAgICAgICAgICBjb2RlID0gdW5pY29kZTsKICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICBzd2l0Y2ggKGdseXBoTmFtZSkgewogICAgICAgICAgICBjYXNlICJmX2giOgogICAgICAgICAgICBjYXNlICJmX3QiOgogICAgICAgICAgICBjYXNlICJUX2giOgogICAgICAgICAgICAgIHRvVW5pY29kZVtjaGFyY29kZV0gPSBnbHlwaE5hbWUucmVwbGFjZUFsbCgiXyIsICIiKTsKICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICB9CiAgICAgIGlmIChjb2RlID4gMCAmJiBjb2RlIDw9IDB4MTBmZmZmICYmIE51bWJlci5pc0ludGVnZXIoY29kZSkpIHsKICAgICAgICBpZiAoYmFzZUVuY29kaW5nTmFtZSAmJiBjb2RlID09PSArY2hhc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5jTWFwLmZvckVhY2goZnVuY3Rpb24gKGNoYXJjb2RlLCBjaWQpIHsKICAgICAgICBpZiAoY2lkID4gMHhmZmZmKSB7CiAgICAgICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoIk1heCBzaXplIG9mIENJRCBpcyA2NSw1MzUiKTsKICAgICAgICB9CiAgICAgICAgY29uc3QgdWNzMiA9IHVjczJDTWFwLmxvb2t1cChjaWQpOwogICAgICAgIGlmICh1Y3MyKSB7CiAgICAgICAgICBidWYubGVuZ3RoID0gMDsKICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBpaSA9IHVjczIubGVuZ3RoOyBpIDwgaWk7IGkgKz0gMikgewogICAgICAgICAgICBidWYucHVzaCgodWNzMi5jaGFyQ29kZUF0KGkpIDw8IDgpICsgdWNzMi5jaGFyQ29kZUF0KGkgKyAxKSk7CiAgICAgICAgICB9CiAgICAgICAgICB0b1VuaWNvZGVbY2hhcmNvZGVdID0gU3RyaW5nLmZyb21DaGFyQ29kZSguLi5idWYpOwogICAgICAgIH0KICAgICAgfSk7CiAgICAgIHJldHVybiBuZXcgX3RvX3VuaWNvZGVfbWFwLlRvVW5pY29kZU1hcCh0b1VuaWNvZGUpOwogICAgfQogICAgcmV0dXJuIG5ldyBfdG9fdW5pY29kZV9tYXAuSWRlbnRpdHlUb1VuaWNvZGVNYXAocHJvcGVydGllcy5maXJzdENoYXIsIHByb3BlcnRpZXMubGFzdENoYXIpOwogIH0KICByZWFkVG9Vbmljb2RlKGNtYXBPYmopIHsKICAgIGlmICghY21hcE9iaikgewogICAgICByZXR1cm4gUHJvbWlzZS5yZXNvbHZlKG51bGwpOwogICAgfQogICAgaWYgKGNtYXBPYmogaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lKSB7CiAgICAgIHJldHVybiBfY21hcC5DTWFwRmFjdG9yeS5jcmVhdGUoewogICAgICAgIGVuY29kaW5nOiBjbWFwT2JqLAogICAgICAgIGZldGNoQnVpbHRJ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y5mcm9tQ29kZVBvaW50KHRva2VuKTsKICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgfQogICAgICAgICAgY29uc3Qgc3RyID0gW107CiAgICAgICAgICBmb3IgKGxldCBrID0gMDsgayA8IHRva2VuLmxlbmd0aDsgayArPSAyKSB7CiAgICAgICAgICAgIGNvbnN0IHcxID0gdG9rZW4uY2hhckNvZGVBdChrKSA8PCA4IHwgdG9rZW4uY2hhckNvZGVBdChrICsgMSk7CiAgICAgICAgICAgIGlmICgodzEgJiAweGY4MDApICE9PSAweGQ4MDApIHsKICAgICAgICAgICAgICBzdHIucHVzaCh3MSk7CiAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgayArPSAyOwogICAgICAgICAgICBjb25zdCB3MiA9IHRva2VuLmNoYXJDb2RlQXQoaykgPDwgOCB8IHRva2VuLmNoYXJDb2RlQXQoayArIDEpOwogICAgICAgICAgICBzdHIucHVzaCgoKHcxICYgMHgzZmYpIDw8IDEwKSArICh3MiAmIDB4M2ZmKSArIDB4MTAwMDApOwogICAgICAgICAgfQogICAgICAgICAgbWFwW2NoYXJDb2RlXSA9IFN0cmluZy5mcm9tQ29kZVBvaW50KC4uLnN0cik7CiAgICAgICAgfSk7CiAgICAgICAgcmV0dXJuIG5ldyBfdG9fdW5pY29kZV9tYXAuVG9Vbmljb2RlTWFwKG1hcCk7CiAgICAgIH0sIHJlYXNvbiA9PiB7CiAgICAgICAgaWYgKHJlYXNvbiBpbnN0YW5jZW9mIF91dGlsLkFib3J0RXhjZXB0aW9uKSB7CiAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICB9CiAgICAgICAgaWYgKHRoaXMub3B0aW9ucy5pZ25vcmVFcnJvcnMpIHsKICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgcmVhZFRvVW5pY29kZSAtIGlnbm9yaW5nIFRvVW5pY29kZSBkYXRhOiAiJHtyZWFzb259Ii5gKTsKICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgIH0KICAgICAgICB0aHJvdyByZWFzb247CiAgICAgIH0pOwogICAgfQogICAgcmV0dXJuIFByb21pc2UucmVzb2x2ZShudWxsKTsKICB9CiAgcmVhZENpZFRvR2lkTWFwKGdseXBoc0RhdGEsIHRvVW5pY29kZSkgewogICAgY29uc3QgcmVzdWx0ID0gW107CiAgICBmb3IgKGxldCBqID0gMCwgamogPSBnbHlwaHNEYXRhLmxlbmd0aDsgaiA8IGpqOyBqKyspIHsKICAgICAgY29uc3QgZ2x5cGhJRCA9IGdseXBoc0RhdGFbaisrXSA8PCA4IHwgZ2x5cGhzRGF0YVtqXTsKICAgICAgY29uc3QgY29kZSA9IGogPj4gMTsKICAgICAgaWYgKGdseXBoSUQgPT09IDAgJiYgIXRvVW5pY29kZS5oYXMoY29kZSkpIHsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICByZXN1bHRbY29kZV0gPSBnbHlwaElEOwogICAgfQogICAgcmV0dXJuIHJlc3VsdDsKICB9CiAgZXh0cmFjdFdpZHRocyhkaWN0LCBkZXNjcmlwdG9yLCBwcm9wZXJ0aWVzKSB7CiAgICBjb25zdCB4cmVmID0gdGhpcy54cmVmOwogICAgbGV0IGdseXBoc1dpZHRocyA9IFtdOwogICAgbGV0IGRlZmF1bHRXaWR0aCA9IDA7CiAgICBjb25zdCBnbHlwaHNWTWV0cmljcyA9IFtdOwogICAgbGV0IGRlZmF1bHRWTWV0cmljczsKICAgIGxldCBpLCBpaSwgaiwgamosIHN0YXJ0LCBjb2RlLCB3aWR0aHM7CiAgICBpZiAocHJvcGVydGllcy5jb21wb3NpdGUpIHsKICAgICAgZGVmYXVsdFdpZHRoID0gZGljdC5oYXMoIkRXIikgPyBkaWN0LmdldCgiRFciKSA6IDEwMDA7CiAgICAgIHdpZHRocyA9IGRpY3QuZ2V0KCJXIik7CiAgICAgIGlmICh3aWR0aHMpIHsKICAgICAgICBmb3IgKGkgPSAwLCBpaSA9IHdpZHRocy5sZW5ndGg7IGkgPCBpaTsgaSsrKSB7CiAgICAgICAgICBzdGFydCA9IHhyZWYuZmV0Y2hJZlJlZih3aWR0aHNbaSsrXSk7CiAgICAgICAgICBjb2RlID0geHJlZi5mZXRjaElmUmVmKHdpZHRoc1tpXSk7CiAgICAgICAgICBpZiAoQXJyYXkuaXNBcnJheShjb2RlKSkgewogICAgICAgICAgICBmb3IgKGogPSAwLCBqaiA9IGNvZGUubGVuZ3RoOyBqIDwgamo7IGorKykgewogICAgICAgICAgICAgIGdseXBoc1dpZHRoc1tzdGFydCsrXSA9IHhyZWYuZmV0Y2hJZlJlZihjb2RlW2pdKTsKICAgICAgICAgICAgfQogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgY29uc3Qgd2lkdGggPSB4cmVmLmZldGNoSWZSZWYod2lkdGhzWysraV0pOwogICAgICAgICAgICBmb3IgKGogPSBzdGFydDsgaiA8PSBjb2RlOyBqKyspIHsKICAgICAgICAgICAgICBnbHlwaHNXaWR0aHNbal0gPSB3aWR0aDsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgIH0KICAgICAgfQogICAgICBpZiAocHJvcGVydGllcy52ZXJ0aWNhbCkgewogICAgICAgIGxldCB2bWV0cmljcyA9IGRpY3QuZ2V0QXJyYXkoIkRXMiIpIHx8IFs4ODAsIC0xMDAwXTsKICAgICAgICBkZWZhdWx0Vk1ldHJpY3MgPSBbdm1ldHJpY3NbMV0sIGRlZmF1bHRXaWR0aCAqIDAuNSwgdm1ldHJpY3NbMF1dOwogICAgICAgIHZtZXRyaWNzID0gZGljdC5nZXQoIlcyIik7CiAgICAgICAgaWYgKHZtZXRyaWNzKSB7CiAgICAgICAgICBmb3IgKGkgPSAwLCBpaSA9IHZtZXRyaWNzLmxlbmd0aDsgaSA8IGlpOyBpKyspIHsKICAgICAgICAgICAgc3RhcnQgPSB4cmVmLmZldGNoSWZSZWYodm1ldHJpY3NbaSsrXSk7CiAgICAgICAgICAgIGNvZGUgPSB4cmVmLmZldGNoSWZSZWYodm1ldHJpY3NbaV0pOwogICAgICAgICAgICBpZiAoQXJyYXkuaXNBcnJheShjb2RlKSkgewogICAgICAgICAgICAgIGZvciAoaiA9IDAsIGpqID0gY29kZS5sZW5ndGg7IGogPCBqajsgaisrKSB7CiAgICAgICAgICAgICAgICBnbHlwaHNWTWV0cmljc1tzdGFydCsrXSA9IFt4cmVmLmZldGNoSWZSZWYoY29kZVtqKytdKSwgeHJlZi5mZXRjaElmUmVmKGNvZGVbaisrXSksIHhyZWYuZmV0Y2hJZlJlZihjb2RlW2pdKV07CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgIGNvbnN0IHZtZXRyaWMgPSBbeHJlZi5mZXRjaElmUmVmKHZtZXRyaWNzWysraV0pLCB4cmVmLmZldGNoSWZSZWYodm1ldHJpY3NbKytpXSksIHhyZWYuZmV0Y2hJZlJlZih2bWV0cmljc1srK2ldKV07CiAgICAgICAgICAgICAgZm9yIChqID0gc3RhcnQ7IGogPD0gY29kZTsgaisrKSB7CiAgICAgICAgICAgICAgICBnbHlwaHNWTWV0cmljc1tqXSA9IHZtZXRyaWM7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9CiAgICB9IGVsc2UgewogICAgICBjb25zdCBmaXJzdENoYXIgPSBwcm9wZXJ0aWVzLmZpcnN0Q2hhcjsKICAgICAgd2lkdGhzID0gZGljdC5nZXQoIldpZHRocyIpOwogICAgICBpZiAod2lkdGhzKSB7CiAgICAgICAgaiA9IGZpcnN0Q2hhcjsKICAgICAgICBmb3IgKGkgPSAwLCBpaSA9IHdpZHRocy5sZW5ndGg7IGkgPCBpaTsgaSsrKSB7CiAgICAgICAgICBnbHlwaHNXaWR0aHNbaisrXSA9IHhyZWYuZmV0Y2hJZlJlZih3aWR0aHNbaV0pOwogICAgICAgIH0KICAgICAgICBkZWZhdWx0V2lkdGggPSBwYXJzZUZsb2F0K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gewogICAgICAgICAgY29uc3Qgd2lkdGhzQnVmID0gW107CiAgICAgICAgICBmb3IgKGNvbnN0IGVudHJ5IG9mIGNvbXBvc2l0ZVdpZHRocykgewogICAgICAgICAgICBpZiAodHlwZW9mIGVudHJ5ID09PSAibnVtYmVyIiB8fCBlbnRyeSBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLlJlZikgewogICAgICAgICAgICAgIHdpZHRoc0J1Zi5wdXNoKGVudHJ5LnRvU3RyaW5nKCkpOwogICAgICAgICAgICB9IGVsc2UgaWYgKEFycmF5LmlzQXJyYXkoZW50cnkpKSB7CiAgICAgICAgICAgICAgY29uc3Qgc3ViV2lkdGhzQnVmID0gW107CiAgICAgICAgICAgICAgZm9yIChjb25zdCBlbGVtZW50IG9mIGVudHJ5KSB7CiAgICAgICAgICAgICAgICBpZiAodHlwZW9mIGVsZW1lbnQgPT09ICJudW1iZXIiIHx8IGVsZW1lbnQgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5SZWYpIHsKICAgICAgICAgICAgICAgICAgc3ViV2lkdGhzQnVmLnB1c2goZWxlbWVudC50b1N0cmluZygpKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgd2lkdGhzQnVmLnB1c2goYFske3N1YldpZHRoc0J1Zi5qb2luKCl9XWApOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICBoYXNoLnVwZGF0ZSh3aWR0aHNCdWYuam9pbigpKTsKICAgICAgICB9CiAgICAgICAgY29uc3QgY2lkVG9HaWRNYXAgPSBkaWN0LmdldFJhdygiQ0lEVG9HSURNYXAiKSB8fCBiYXNlRGljdC5nZXRSYXcoIkNJRFRvR0lETWFwIik7CiAgICAgICAgaWYgKGNpZFRvR2lkTWFwIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuTmFtZSkgewogICAgICAgICAgaGFzaC51cGRhdGUoY2lkVG9HaWRNYXAubmFtZSk7CiAgICAgICAgfSBlbHNlIGlmIChjaWRUb0dpZE1hcCBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLlJlZikgewogICAgICAgICAgaGFzaC51cGRhdGUoY2lkVG9HaWRNYXAudG9TdHJpbmcoKSk7CiAgICAgICAgfSBlbHNlIGlmIChjaWRUb0dpZE1hcCBpbnN0YW5jZW9mIF9iYXNlX3N0cmVhbS5CYXNlU3RyZWFtKSB7CiAgICAgICAgICBoYXNoLnVwZGF0ZShjaWRUb0dpZE1hcC5wZWVrQnl0ZXMoKSk7CiAgICAgICAgfQogICAgICB9CiAgICB9CiAgICByZXR1cm4gewogICAgICBkZXNjcmlwdG9yLAogICAgICBkaWN0LAogICAgICBiYXNlRGljdCwKICAgICAgY29tcG9zaXRlLAogICAgICB0eXBlOiB0eXBlLm5hbWUsCiAgICAgIGZpcnN0Q2hhciwKICAgICAgbGFzdENoYXIsCiAgICAgIHRvVW5pY29kZSwKICAgICAgaGFzaDogaGFzaCA/IGhhc2guaGV4ZGlnZXN0KCkgOiAiIgogICAgfTsKICB9CiAgYXN5bmMgdHJhbnNsYXRlRm9udChfcmVmOSkgewogICAgbGV0IHsKICAgICAgZGVzY3JpcHRvciwKICAgICAgZGljdCwKICAgICAgYmFzZURpY3QsCiAgICAgIGNvbXBvc2l0ZSwKICAgICAgdHlwZSwKICAgICAgZmlyc3RDaGFyLAogICAgICBsYXN0Q2hhciwKICAgICAgdG9Vbmljb2RlLAogICAgICBjc3NGb250SW5mbwogICAgfSA9IF9yZWY5OwogICAgY29uc3QgaXNUeXBlM0ZvbnQgPSB0eXBlID09PSAiVHlwZTMiOwogICAgbGV0IHByb3BlcnRpZXM7CiAgICBpZiAoIWRlc2NyaXB0b3IpIHsKICAgICAgaWYgKGlzVHlwZTNGb250KSB7CiAgICAgICAgZGVzY3JpcHRvciA9IG5ldyBfcHJpbWl0aXZlcy5EaWN0KG51bGwpOwogICAgICAgIGRlc2NyaXB0b3Iuc2V0KCJGb250TmFtZSIsIF9wcmltaXRpdmVzLk5hbWU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ICAgICAgICAgbG9hZGVkTmFtZTogYmFzZURpY3QubG9hZGVkTmFtZSwKICAgICAgICAgIHdpZHRoczogbWV0cmljcy53aWR0aHMsCiAgICAgICAgICBkZWZhdWx0V2lkdGg6IG1ldHJpY3MuZGVmYXVsdFdpZHRoLAogICAgICAgICAgaXNTaW11bGF0ZWRGbGFnczogdHJ1ZSwKICAgICAgICAgIGZsYWdzLAogICAgICAgICAgZmlyc3RDaGFyLAogICAgICAgICAgbGFzdENoYXIsCiAgICAgICAgICB0b1VuaWNvZGUsCiAgICAgICAgICB4SGVpZ2h0OiAwLAogICAgICAgICAgY2FwSGVpZ2h0OiAwLAogICAgICAgICAgaXRhbGljQW5nbGU6IDAsCiAgICAgICAgICBpc1R5cGUzRm9udAogICAgICAgIH07CiAgICAgICAgY29uc3Qgd2lkdGhzID0gZGljdC5nZXQoIldpZHRocyIpOwogICAgICAgIGNvbnN0IHN0YW5kYXJkRm9udE5hbWUgPSAoMCwgX3N0YW5kYXJkX2ZvbnRzLmdldFN0YW5kYXJkRm9udE5hbWUpKGJhc2VGb250TmFtZSk7CiAgICAgICAgbGV0IGZpbGUgPSBudWxsOwogICAgICAgIGlmIChzdGFuZGFyZEZvbnROYW1lKSB7CiAgICAgICAgICBwcm9wZXJ0aWVzLmlzU3RhbmRhcmRGb250ID0gdHJ1ZTsKICAgICAgICAgIGZpbGUgPSBhd2FpdCB0aGlzLmZldGNoU3RhbmRhcmRGb250RGF0YShzdGFuZGFyZEZvbnROYW1lKTsKICAgICAgICAgIHByb3BlcnRpZXMuaXNJbnRlcm5hbEZvbnQgPSAhIWZpbGU7CiAgICAgICAgfQogICAgICAgIHJldHVybiB0aGlzLmV4dHJhY3REYXRhU3RydWN0dXJlcyhkaWN0LCBkaWN0LCBwcm9wZXJ0aWVzKS50aGVuKG5ld1Byb3BlcnRpZXMgPT4gewogICAgICAgICAgaWYgKHdpZHRocykgewogICAgICAgICAgICBjb25zdCBnbHlwaFdpZHRocyA9IFtdOwogICAgICAgICAgICBsZXQgaiA9IGZpcnN0Q2hhcjsKICAgICAgICAgICAgZm9yIChjb25zdCB3aWR0aCBvZiB3aWR0aHMpIHsKICAgICAgICAgICAgICBnbHlwaFdpZHRoc1tqKytdID0gdGhpcy54cmVmLmZldGNoSWZSZWYod2lkdGgpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIG5ld1Byb3BlcnRpZXMud2lkdGhzID0gZ2x5cGhXaWR0aHM7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBuZXdQcm9wZXJ0aWVzLndpZHRocyA9IHRoaXMuYnVpbGRDaGFyQ29kZVRvV2lkdGgobWV0cmljcy53aWR0aHMsIG5ld1Byb3BlcnRpZXMpOwogICAgICAgICAgfQogICAgICAgICAgcmV0dXJuIG5ldyBfZm9udHMuRm9udChiYXNlRm9udE5hbWUsIGZpbGUsIG5ld1Byb3BlcnRpZXMpOwogICAgICAgIH0pOwogICAgICB9CiAgICB9CiAgICBsZXQgZm9udE5hbWUgPSBkZXNjcmlwdG9yLmdldCgiRm9udE5hbWUiKTsKICAgIGxldCBiYXNlRm9udCA9IGRpY3QuZ2V0KCJCYXNlRm9udCIpOwogICAgaWYgKHR5cGVvZiBmb250TmFtZSA9PT0gInN0cmluZyIpIHsKICAgICAgZm9udE5hbWUgPSBfcHJpbWl0aXZlcy5OYW1lLmdldChmb250TmFtZSk7CiAgICB9CiAgICBpZiAodHlwZW9mIGJhc2VGb250ID09PSAic3RyaW5nIikgewogICAgICBiYXNlRm9udCA9IF9wcmltaXRpdmVzLk5hbWUuZ2V0KGJhc2VGb250KTsKICAgIH0KICAgIGlmICghaXNUeXBlM0ZvbnQpIHsKICAgICAgY29uc3QgZm9udE5hbWVTdHIgPSBmb250TmFtZSAmJiBmb250TmFtZS5uYW1lOwogICAgICBjb25zdCBiYXNlRm9udFN0ciA9IGJhc2VGb250ICYmIGJhc2VGb250Lm5hbWU7CiAgICAgIGlmIChmb250TmFtZVN0ciAhPT0gYmFzZUZvbnRTdHI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GVybmFsRm9udCA9ICEhZm9udEZpbGU7CiAgICAgICAgYmFzZURpY3QgPSBkaWN0ID0gKDAsIF94ZmFfZm9udHMuZ2V0WGZhRm9udERpY3QpKGZvbnROYW1lLm5hbWUpOwogICAgICAgIGNvbXBvc2l0ZSA9IHRydWU7CiAgICAgIH0KICAgIH0gZWxzZSBpZiAoIWlzVHlwZTNGb250KSB7CiAgICAgIGNvbnN0IHN0YW5kYXJkRm9udE5hbWUgPSAoMCwgX3N0YW5kYXJkX2ZvbnRzLmdldFN0YW5kYXJkRm9udE5hbWUpKGZvbnROYW1lLm5hbWUpOwogICAgICBpZiAoc3RhbmRhcmRGb250TmFtZSkgewogICAgICAgIGlzU3RhbmRhcmRGb250ID0gdHJ1ZTsKICAgICAgICBmb250RmlsZSA9IGF3YWl0IHRoaXMuZmV0Y2hTdGFuZGFyZEZvbnREYXRhKHN0YW5kYXJkRm9udE5hbWUpOwogICAgICAgIGlzSW50ZXJuYWxGb250ID0gISFmb250RmlsZTsKICAgICAgfQogICAgfQogICAgcHJvcGVydGllcyA9IHsKICAgICAgdHlwZSwKICAgICAgbmFtZTogZm9udE5hbWUubmFtZSwKICAgICAgc3VidHlwZSwKICAgICAgZmlsZTogZm9udEZpbGUsCiAgICAgIGxlbmd0aDEsCiAgICAgIGxlbmd0aDIsCiAgICAgIGxlbmd0aDMsCiAgICAgIGlzU3RhbmRhcmRGb250LAogICAgICBpc0ludGVybmFsRm9udCwKICAgICAgbG9hZGVkTmFtZTogYmFzZURpY3QubG9hZGVkTmFtZSwKICAgICAgY29tcG9zaXRlLAogICAgICBmaXhlZFBpdGNoOiBmYWxzZSwKICAgICAgZm9udE1hdHJpeDogZGljdC5nZXRBcnJheSgiRm9udE1hdHJpeCIpIHx8IF91dGlsLkZPTlRfSURFTlRJVFlfTUFUUklYLAogICAgICBmaXJzdENoYXIsCiAgICAgIGxhc3RDaGFyLAogICAgICB0b1VuaWNvZGUsCiAgICAgIGJib3g6IGRlc2NyaXB0b3IuZ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AgICAgICBjb25zdCBbZ1N0YXRlS2V5XSA9IGdTdGF0ZU9ialtqXTsKICAgICAgICAgICAgc3dpdGNoIChnU3RhdGVLZXkpIHsKICAgICAgICAgICAgICBjYXNlICJUUiI6CiAgICAgICAgICAgICAgY2FzZSAiVFIyIjoKICAgICAgICAgICAgICBjYXNlICJIVCI6CiAgICAgICAgICAgICAgY2FzZSAiQkciOgogICAgICAgICAgICAgIGNhc2UgIkJHMiI6CiAgICAgICAgICAgICAgY2FzZSAiVUNSIjoKICAgICAgICAgICAgICBjYXNlICJVQ1IyIjoKICAgICAgICAgICAgICAgIGdTdGF0ZU9iai5zcGxpY2UoaiwgMSk7CiAgICAgICAgICAgICAgICBqai0tOwogICAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaisrOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgIH0KICAgICAgaSsrOwogICAgfQogIH0KfQpjbGFzcyBTdGF0ZU1hbmFnZXIgewogIGNvbnN0cnVjdG9yKCkgewogICAgbGV0IGluaXRpYWxTdGF0ZSA9IGFyZ3VtZW50cy5sZW5ndGggPiAwICYmIGFyZ3VtZW50c1swXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzBdIDogbmV3IEV2YWxTdGF0ZSgpOwogICAgdGhpcy5zdGF0ZSA9IGluaXRpYWxTdGF0ZTsKICAgIHRoaXMuc3RhdGVTdGFjayA9IFtdOwogIH0KICBzYXZlKCkgewogICAgY29uc3Qgb2xkID0gdGhpcy5zdGF0ZTsKICAgIHRoaXMuc3RhdGVTdGFjay5wdXNoKHRoaXMuc3RhdGUpOwogICAgdGhpcy5zdGF0ZSA9IG9sZC5jbG9uZSgpOwogIH0KICByZXN0b3JlKCkgewogICAgY29uc3QgcHJldiA9IHRoaXMuc3RhdGVTdGFjay5wb3AoKTsKICAgIGlmIChwcmV2KSB7CiAgICAgIHRoaXMuc3RhdGUgPSBwcmV2OwogICAgfQogIH0KICB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REYXNoLAogICAgICAgIG51bUFyZ3M6IDIsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LnJpID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuc2V0UmVuZGVyaW5nSW50ZW50LAogICAgICAgIG51bUFyZ3M6IDEsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LmkgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5zZXRGbGF0bmVzcywKICAgICAgICBudW1BcmdzOiAxLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5ncyA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLnNldEdTdGF0ZSwKICAgICAgICBudW1BcmdzOiAxLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5xID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuc2F2ZSwKICAgICAgICBudW1BcmdzOiAwLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5RID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMucmVzdG9yZSwKICAgICAgICBudW1BcmdzOiAwLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5jbSA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLnRyYW5zZm9ybSwKICAgICAgICBudW1BcmdzOiA2LAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5tID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMubW92ZVRvLAogICAgICAgIG51bUFyZ3M6IDIsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LmwgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5saW5lVG8sCiAgICAgICAgbnVtQXJnczogMiwKICAgICAgICB2YXJpYWJsZUFyZ3M6IGZhbHNlCiAgICAgIH07CiAgICAgIHQuYyA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLmN1cnZlVG8sCiAgICAgICAgbnVtQXJnczogNiwKICAgICAgICB2YXJpYWJsZUFyZ3M6IGZhbHNlCiAgICAgIH07CiAgICAgIHQudiA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLmN1cnZlVG8yLAogICAgICAgIG51bUFyZ3M6IDQsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LnkgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5jdXJ2ZVRvMywKICAgICAgICBudW1BcmdzOiA0LAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5oID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuY2xvc2VQYXRoLAogICAgICAgIG51bUFyZ3M6IDAsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LnJlID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMucmVjdGFuZ2xlLAogICAgICAgIG51bUFyZ3M6IDQsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LlMgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5zdHJva2UsCiAgICAgICAgbnVtQXJnczogMCwKICAgICAgICB2YXJpYWJsZUFyZ3M6IGZhbHNlCiAgICAgIH07CiAgICAgIHQucyA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLmNsb3NlU3Ryb2tlLAogICAgICAgIG51bUFyZ3M6IDAsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LmYgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5maWxsLAogICAgICAgIG51bUFyZ3M6IDAsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LkYgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5maWxsLAogICAgICAgIG51bUFyZ3M6IDAsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0WyJmKiJdID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuZW9GaWxsLAogICAgICAgIG51bUFyZ3M6IDAsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LkIgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5maWxsU3Ryb2tlLAogICAgICAgIG51bUFyZ3M6IDAsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0WyJCKiJdID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuZW9GaWxsU3Ryb2tlLAogICAgICAgIG51bUFyZ3M6IDAsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LmIgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5jbG9zZUZpbGxTdHJva2UsCiAgICAgICAgbnVtQXJnczogMCwKICAgICAgICB2YXJpYWJsZUFyZ3M6IGZhbHNlCiAgICAgIH07CiAgICAgIHRbImIqIl0gPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5jbG9zZUVPRmlsbFN0cm9rZSwKICAgICAgICBudW1BcmdzOiAwLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5uID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuZW5kUGF0aCwKICAgICAgICBudW1BcmdzOiAwLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5XID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuY2xpcCwKICAgICAgICBudW1BcmdzOiAwLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdFsiVyoiXSA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLmVvQ2xpcCwKICAgICAgICBudW1BcmdzOiAwLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5CVCA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLmJlZ2luVGV4dCwKICAgICAgICBudW1BcmdzOiAwLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5FVCA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLmVuZFRleHQsCiAgICAgICAgbnVtQXJnczogMCwKICAgICAgICB2YXJpYWJsZUFyZ3M6IGZhbHNlCiAgICAgIH07CiAgICAgIHQuVGMgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5zZXRDaGFyU3BhY2luZywKICAgICAgICBudW1BcmdzOiAxLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5UdyA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLnNldFdvcmRTcGFjaW5nLAogICAgICAgIG51bUFyZ3M6IDEsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LlR6ID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuc2V0SFNjYWxlLAogICAgICAgIG51bUFyZ3M6IDEsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LlRMID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuc2V0TGVhZGluZywKICAgICAgICBudW1BcmdzOiAxLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5UZiA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLnNldEZvbnQsCiAgICAgICAgbnVtQXJnczogMiwKICAgICAgICB2YXJpYWJsZUFyZ3M6IGZhbHNlCiAgICAgIH07CiAgICAgIHQuVHIgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5zZXRUZXh0UmVuZGVyaW5nTW9kZSwKICAgICAgICBudW1BcmdzOiAxLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5UcyA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLnNldFRleHRSaXNlLAogICAgICAgIG51bUFyZ3M6IDEsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LlRkID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMubW92ZVRleHQsCiAgICAgICAgbnVtQXJnczogMiwKICAgICAgICB2YXJpYWJsZUFyZ3M6IGZhbHNlCiAgICAgIH07CiAgICAgIHQuVEQgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5zZXRMZWFkaW5nTW92ZVRleHQsCiAgICAgICAgbnVtQXJnczogMiwKICAgICAgICB2YXJpYWJsZUFyZ3M6IGZhbHNlCiAgICAgIH07CiAgICAgIHQuVG0gPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5zZXRUZXh0TWF0cml4LAogICAgICAgIG51bUFyZ3M6IDYsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0WyJUKiJdID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMubmV4dExpbmUsCiAgICAgICAgbnVtQXJnczogMCwKICAgICAgICB2YXJpYWJsZUFyZ3M6IGZhbHNlCiAgICAgIH07CiAgICAgIHQuVGogPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5zaG93VGV4dCwKICAgICAgICBudW1BcmdzOiAxLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5USiA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLnNob3dTcGFjZWRUZXh0LAogICAgICAgIG51bUFyZ3M6IDEsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0WyInIl0gPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5uZXh0TGluZVNob3dUZXh0LAogICAgICAgIG51bUFyZ3M6IDEsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0WyciJ10gPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5uZXh0TGluZVNldFNwYWNpbmdTaG93VGV4dCwKICAgICAgICBudW1BcmdzOiAzLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5kMCA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLnNldENoYXJXaWR0aCwKICAgICAgICBudW1BcmdzOiAyLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5kMSA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLnNldENoYXJXaWR0aEFuZEJvdW5kcywKICAgICAgICBudW1BcmdzOiA2LAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5DUyA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLnNldFN0cm9rZUNvbG9yU3BhY2UsCiAgICAgICAgbnVtQXJnczogMSwKICAgICAgICB2YXJpYWJsZUFyZ3M6IGZhbHNlCiAgICAgIH07CiAgICAgIHQuY3MgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5zZXRGaWxsQ29sb3JTcGFjZSwKICAgICAgICBudW1BcmdzOiAxLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5TQyA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLnNldFN0cm9rZUNvbG9yLAogICAgICAgIG51bUFyZ3M6IDQsCiAgICAgICAgdmFyaWFibGVBcmdzOiB0cnVlCiAgICAgIH07CiAgICAgIHQuU0NOID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuc2V0U3Ryb2tlQ29sb3JOLAogICAgICAgIG51bUFyZ3M6IDMzLAogICAgICAgIHZhcmlhYmxlQXJnczogdHJ1ZQogICAgICB9OwogICAgICB0LnNjID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuc2V0RmlsbENvbG9yLAogICAgICAgIG51bUFyZ3M6IDQsCiAgICAgICAgdmFyaWFibGVBcmdzOiB0cnVlCiAgICAgIH07CiAgICAgIHQuc2NuID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuc2V0RmlsbENvbG9yTiwKICAgICAgICBudW1BcmdzOiAzMywKICAgICAgICB2YXJpYWJsZUFyZ3M6IHRydWUKICAgICAgfTsKICAgICAgdC5HID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuc2V0U3Ryb2tlR3JheSwKICAgICAgICBudW1BcmdzOiAxLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5nID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuc2V0RmlsbEdyYXksCiAgICAgICAgbnVtQXJnczogMSwKICAgICAgICB2YXJpYWJsZUFyZ3M6IGZhbHNlCiAgICAgIH07CiAgICAgIHQuUkcgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5zZXRTdHJva2VSR0JDb2xvciwKICAgICAgICBudW1BcmdzOiAzLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5yZyA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLnNldEZpbGxSR0JDb2xvciwKICAgICAgICBudW1BcmdzOiAzLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5LID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuc2V0U3Ryb2tlQ01ZS0NvbG9yLAogICAgICAgIG51bUFyZ3M6IDQsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LmsgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5zZXRGaWxsQ01ZS0NvbG9yLAogICAgICAgIG51bUFyZ3M6IDQsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LnNoID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuc2hhZGluZ0ZpbGwsCiAgICAgICAgbnVtQXJnczogMSwKICAgICAgICB2YXJpYWJsZUFyZ3M6IGZhbHNlCiAgICAgIH07CiAgICAgIHQuQkkgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5iZWdpbklubGluZUltYWdlLAogICAgICAgIG51bUFyZ3M6IDAsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LklEID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuYmVnaW5JbWFnZURhdGEsCiAgICAgICAgbnVtQXJnczogMCwKICAgICAgICB2YXJpYWJsZUFyZ3M6IGZhbHNlCiAgICAgIH07CiAgICAgIHQuRUkgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5lbmRJbmxpbmVJbWFnZSwKICAgICAgICBudW1BcmdzOiAxLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5EbyA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLnBhaW50WE9iamVjdCwKICAgICAgICBudW1BcmdzOiAxLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5NUCA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLm1hcmtQb2ludCwKICAgICAgICBudW1BcmdzOiAxLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5EUCA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLm1hcmtQb2ludFByb3BzLAogICAgICAgIG51bUFyZ3M6IDIsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LkJNQyA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLmJlZ2luTWFya2VkQ29udGVudCwKICAgICAgICBudW1BcmdzOiAxLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5CREMgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5iZWdpbk1hcmtlZENvbnRlbnRQcm9wcywKICAgICAgICBudW1BcmdzOiAyLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5FTUMgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5lbmRNYXJrZWRDb250ZW50LAogICAgICAgIG51bUFyZ3M6IDAsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LkJYID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuYmVnaW5Db21wYXQsCiAgICAgICAgbnVtQXJnczogMCwKICAgICAgICB2YXJpYWJsZUFyZ3M6IGZhbHNlCiAgICAgIH07CiAgICAgIHQuRVggPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5lbmRDb21wYXQsCiAgICAgICAgbnVtQXJnczogMCwKICAgICAgICB2YXJpYWJsZUFyZ3M6IGZhbHNlCiAgICAgIH07CiAgICAgIHQuQk0gPSBudWxsOwogICAgICB0LkJEID0gbnVsbDsKICAgICAgdC50cnVlID0gbnVsbDsKICAgICAgdC5mYSA9IG51bGw7CiAgICAgIHQuZmFsID0gbnVsbDsKICAgICAgdC5mYWxzID0gbnVsbDsKICAgICAgdC5mYWxzZSA9IG51bGw7CiAgICAgIHQubnUgPSBudWxsOwogICAgICB0Lm51bCA9IG51bGw7CiAgICAgIHQubnVsbCA9IG51bGw7CiAgICB9KTsKICAgIHJldHVybiAoMCwgX3V0aWwuc2hhZG93KSh0aGlzLCAib3BNYXAiLCBnZXRPUE1hcCgpKTsKICB9CiAgc3RhdGljIGdldCBNQVhfSU5WQUxJRF9QQVRIX09QUygpIHsKICAgIHJldHVybiAoMCwgX3V0aWwuc2hhZG93KSh0aGlzLCAiTUFYX0lOVkFMSURfUEFUSF9PUFMiLCAxMCk7CiAgfQogIGNvbnN0cnVj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0IGZuID0gb3BTcGVjLmlkOwogICAgICAgIGNvbnN0IG51bUFyZ3MgPSBvcFNwZWMubnVtQXJnczsKICAgICAgICBsZXQgYXJnc0xlbmd0aCA9IGFyZ3MgIT09IG51bGwgPyBhcmdzLmxlbmd0aCA6IDA7CiAgICAgICAgaWYgKCF0aGlzLl9pc1BhdGhPcCkgewogICAgICAgICAgdGhpcy5fbnVtSW52YWxpZFBhdGhPUFMgPSAwOwogICAgICAgIH0KICAgICAgICB0aGlzLl9pc1BhdGhPcCA9IGZuID49IF91dGlsLk9QUy5tb3ZlVG8gJiYgZm4gPD0gX3V0aWwuT1BTLmVuZFBhdGg7CiAgICAgICAgaWYgKCFvcFNwZWMudmFyaWFibGVBcmdzKSB7CiAgICAgICAgICBpZiAoYXJnc0xlbmd0aCAhPT0gbnVtQXJncykgewogICAgICAgICAgICBjb25zdCBub25Qcm9jZXNzZWRBcmdzID0gdGhpcy5ub25Qcm9jZXNzZWRBcmdzOwogICAgICAgICAgICB3aGlsZSAoYXJnc0xlbmd0aCA+IG51bUFyZ3MpIHsKICAgICAgICAgICAgICBub25Qcm9jZXNzZWRBcmdzLnB1c2goYXJncy5zaGlmdCgpKTsKICAgICAgICAgICAgICBhcmdzTGVuZ3RoLS07CiAgICAgICAgICAgIH0KICAgICAgICAgICAgd2hpbGUgKGFyZ3NMZW5ndGggPCBudW1BcmdzICYmIG5vblByb2Nlc3NlZEFyZ3MubGVuZ3RoICE9PSAwKSB7CiAgICAgICAgICAgICAgaWYgKGFyZ3MgPT09IG51bGwpIHsKICAgICAgICAgICAgICAgIGFyZ3MgPSBbXTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgYXJncy51bnNoaWZ0KG5vblByb2Nlc3NlZEFyZ3MucG9wKCkpOwogICAgICAgICAgICAgIGFyZ3NMZW5ndGgrKzsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgICAgaWYgKGFyZ3NMZW5ndGggPCBudW1BcmdzKSB7CiAgICAgICAgICAgIGNvbnN0IHBhcnRpYWxNc2cgPSBgY29tbWFuZCAke2NtZH06IGV4cGVjdGVkICR7bnVtQXJnc30gYXJncywgYCArIGBidXQgcmVjZWl2ZWQgJHthcmdzTGVuZ3RofSBhcmdzLmA7CiAgICAgICAgICAgIGlmICh0aGlzLl9pc1BhdGhPcCAmJiArK3RoaXMuX251bUludmFsaWRQYXRoT1BTID4gRXZhbHVhdG9yUHJlcHJvY2Vzc29yLk1BWF9JTlZBTElEX1BBVEhfT1BTKSB7CiAgICAgICAgICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKGBJbnZhbGlkICR7cGFydGlhbE1zZ31gKTsKICAgICAgICAgICAgfQogICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYFNraXBwaW5nICR7cGFydGlhbE1zZ31gKTsKICAgICAgICAgICAgaWYgKGFyZ3MgIT09IG51bGwpIHsKICAgICAgICAgICAgICBhcmdzLmxlbmd0aCA9IDA7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICB9CiAgICAgICAgfSBlbHNlIGlmIChhcmdzTGVuZ3RoID4gbnVtQXJncykgewogICAgICAgICAgKDAsIF91dGlsLmluZm8pKGBDb21tYW5kICR7Y21kfTogZXhwZWN0ZWQgWzAsICR7bnVtQXJnc31dIGFyZ3MsIGAgKyBgYnV0IHJlY2VpdmVkICR7YXJnc0xlbmd0aH0gYXJncy5gKTsKICAgICAgICB9CiAgICAgICAgdGhpcy5wcmVwcm9jZXNzQ29tbWFuZChmbiwgYXJncyk7CiAgICAgICAgb3BlcmF0aW9uLmZuID0gZm47CiAgICAgICAgb3BlcmF0aW9uLmFyZ3MgPSBhcmdzOwogICAgICAgIHJldHVybiB0cnVlOwogICAgICB9CiAgICAgIGlmIChvYmogPT09IF9wcmltaXRpdmVzLkVPRikgewogICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgfQogICAgICBpZiAob2JqICE9PSBudWxsKSB7CiAgICAgICAgaWYgK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CiAgICAgICAgaWYgKGIgPCAwKSB7CiAgICAgICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoInVuZXhwZWN0ZWQgRU9GIGluIGJjbWFwIik7CiAgICAgICAgfQogICAgICAgIGxhc3QgPSAhKGIgJiAweDgwKTsKICAgICAgICBuID0gbiA8PCA3IHwgYiAmIDB4N2Y7CiAgICAgIH0gd2hpbGUgKCFsYXN0KTsKICAgICAgcmV0dXJuIG47CiAgICB9CiAgICByZWFkU2lnbmVkKCkgewogICAgICBjb25zdCBuID0gdGhpcy5yZWFkTnVtYmVyKCk7CiAgICAgIHJldHVybiBuICYgMSA/IH4obiA+Pj4gMSkgOiBuID4+PiAxOwogICAgfQogICAgcmVhZEhleChudW0sIHNpemUpIHsKICAgICAgbnVtLnNldCh0aGlzLmJ1ZmZlci5zdWJhcnJheSh0aGlzLnBvcywgdGhpcy5wb3MgKyBzaXplICsgMSkpOwogICAgICB0aGlzLnBvcyArPSBzaXplICsgMTsKICAgIH0KICAgIHJlYWRIZXhOdW1iZXIobnVtLCBzaXplKSB7CiAgICAgIGxldCBsYXN0OwogICAgICBjb25zdCBzdGFjayA9IHRoaXMudG1wQnVmOwogICAgICBsZXQgc3AgPSAwOwogICAgICBkbyB7CiAgICAgICAgY29uc3QgYiA9IHRoaXMucmVhZEJ5dGUoKTsKICAgICAgICBpZiAoYiA8IDApIHsKICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigidW5leHBlY3RlZCBFT0YgaW4gYmNtYXAiKTsKICAgICAgICB9CiAgICAgICAgbGFzdCA9ICEoYiAmIDB4ODApOwogICAgICAgIHN0YWNrW3NwKytdID0gYiAmIDB4N2Y7CiAgICAgIH0gd2hpbGUgKCFsYXN0KTsKICAgICAgbGV0IGkgPSBzaXplLAogICAgICAgIGJ1ZmZlciA9IDAsCiAgICAgICAgYnVmZmVyU2l6ZSA9IDA7CiAgICAgIHdoaWxlIChpID49IDApIHsKICAgICAgICB3aGlsZSAoYnVmZmVyU2l6ZSA8IDggJiYgc3RhY2subGVuZ3RoID4gMCkgewogICAgICAgICAgYnVmZmVyIHw9IHN0YWNrWy0tc3BdIDw8IGJ1ZmZlclNpemU7CiAgICAgICAgICBidWZmZXJTaXplICs9IDc7CiAgICAgICAgfQogICAgICAgIG51bVtpXSA9IGJ1ZmZlciAmIDI1NTsKICAgICAgICBpLS07CiAgICAgICAgYnVmZmVyID4+PSA4OwogICAgICAgIGJ1ZmZlclNpemUgLT0gODsKICAgICAgfQogICAgfQogICAgcmVhZEhleFNpZ25lZChudW0sIHNpemUpIHsKICAgICAgdGhpcy5yZWFkSGV4TnVtYmVyKG51bSwgc2l6ZSk7CiAgICAgIGNvbnN0IHNpZ24gPSBudW1bc2l6ZV0gJiAxID8gMjU1IDogMDsKICAgICAgbGV0IGMgPSAwOwogICAgICBmb3IgKGxldCBpID0gMDsgaSA8PSBzaXplOyBpKyspIHsKICAgICAgICBjID0gKGMgJiAxKSA8PCA4IHwgbnVtW2ldOwogICAgICAgIG51bVtpXSA9IGMgPj4gMSBeIHNpZ247CiAgICAgIH0KICAgIH0KICAgIHJlYWRTdHJpbmcoKSB7CiAgICAgIGNvbnN0IGxlbiA9IHRoaXMucmVhZE51bWJlcigpOwogICAgICBsZXQgcyA9ICIiOwogICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGxlbjsgaSsrKSB7CiAgICAgICAgcyArPSBTdHJpbmcuZnJvbUNoYXJDb2RlKHRoaXMucmVhZE51bWJlcigpKTsKICAgICAgfQogICAgICByZXR1cm4gczsKICAgIH0KICB9CiAgY2xhc3MgQmluYXJ5Q01hcFJlYWRlciB7CiAgICBhc3luYyBwcm9jZXNzKGRhdGEsIGNNYXAsIGV4dGVuZCkgewogICAgICBjb25zdCBzdHJlYW0gPSBuZXcgQmluYXJ5Q01hcFN0cmVhbShkYXRhKTsKICAgICAgY29uc3QgaGVhZGVyID0gc3RyZWFtLnJlYWRCeXRlKCk7CiAgICAgIGNNYXAudmVydGljYWwgPSAhIShoZWFkZXIgJiAxKTsKICAgICAgbGV0IHVzZUNNYXAgPSBudWxsOwogICAgICBjb25zdCBzdGFydCA9IG5ldyBVaW50OEFycmF5KE1BWF9OVU1fU0laRSk7CiAgICAgIGNvbnN0IGVuZCA9IG5ldyBVaW50OEFycmF5KE1BWF9OVU1fU0laRSk7CiAgICAgIGNvbnN0IGNoYXIgPSBuZXcgVWludDhBcnJheShNQVhfTlVNX1NJWkUpOwogICAgICBjb25zdCBjaGFyQ29kZSA9IG5ldyBVaW50OEFycmF5KE1BWF9OVU1fU0laRSk7CiAgICAgIGNvbnN0IHRtcCA9IG5ldyBVaW50OEFycmF5KE1BWF9OVU1fU0laRSk7CiAgICAgIGxldCBjb2RlOwogICAgICBsZXQgYjsKICAgICAgd2hpbGUgKChiID0gc3RyZWFtLnJlYWRCeXRlKCkpID49IDApIHsKICAgICAgICBjb25zdCB0eXBlID0gYiA+PiA1OwogICAgICAgIGlmICh0eXBlID09PSA3KSB7CiAgICAgICAgICBzd2l0Y2ggKGIgJiAweDFmKSB7CiAgICAgICAgICAgIGNhc2UgMDoKICAgICAgICAgICAgICBzdHJlYW0ucmVhZFN0cmluZygpOwogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICBjYXNlIDE6CiAgICAgICAgICAgICAgdXNlQ01hcCA9IHN0cmVhbS5yZWFkU3RyaW5nKCk7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICB9CiAgICAgICAgICBjb250aW51ZTsKICAgICAgICB9CiAgICAgICAgY29uc3Qgc2VxdWVuY2UgPSAhIShiICYgMHgxMCk7CiAgICAgICAgY29uc3QgZGF0YVNpemUgPSBiICYgMTU7CiAgICAgICAgaWYgKGRhdGFTaXplICsgMSA+IE1BWF9OVU1fU0laRSkgewogICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCJCaW5hcnlDTWFwUmVhZGVyLnByb2Nlc3M6IEludmFsaWQgZGF0YVNpemUuIik7CiAgICAgICAgfQogICAgICAgIGNvbnN0IHVjczJEYXRhU2l6ZSA9IDE7CiAgICAgICAgY29uc3Qgc3ViaXRlbXNDb3VudCA9IHN0cmVhbS5yZWFkTnVtYmVyKCk7CiAgICAgICAgc3dpdGNoICh0eXBlKSB7CiAgICAgICAgICBjYXNlIDA6CiAgICAgICAgICAgIHN0cmVhbS5yZWFkSGV4KHN0YXJ0LCBkYXRhU2l6ZSk7CiAgICAgICAgICAgIHN0cmVhbS5yZWFkSGV4TnVtYmVyKGVuZCwgZGF0YVNpemUpOwogICAgICAgICAgICBhZGRIZXgoZW5kLCBzdGFydCwgZGF0YVNpemUpOwogICAgICAgICAgICBjTWFwLmFkZENvZGVzcGFjZVJhbmdlKGRhdGFTaXplICsgMSwgaGV4VG9JbnQoc3RhcnQsIGRhdGFTaXplKSwgaGV4VG9JbnQoZW5kLCBkYXRhU2l6ZSkpOwogICAgICAgICAgICBmb3IgKGxldCBpID0gMTsgaSA8IHN1Yml0ZW1zQ291bnQ7IGkrKykgewogICAgICAgICAgICAgIGluY0hleChlbmQsIGRhdGFTaXplKTsKICAgICAgICAgICAgICBzdHJlYW0ucmVhZEhleE51bWJlcihzdGFydCwgZGF0YVNpemUpOwogICAgICAgICAgICAgIGFkZEhleChzdGFydCwgZW5kLCBkYXRhU2l6ZSk7CiAgICAgICAgICAgICAgc3RyZWFtLnJlYWRIZXhOdW1iZXIoZW5kLCBkYXRhU2l6ZSk7CiAgICAgICAgICAgICAgYWRkSGV4KGVuZCwgc3RhcnQsIGRhdGFTaXplKTsKICAgICAgICAgICAgICBjTWFwLmFkZENvZGVzcGFjZVJhbmdlKGRhdGFTaXplICsgMSwgaGV4VG9JbnQoc3RhcnQsIGRhdGFTaXplKSwgaGV4VG9JbnQoZW5kLCBkYXRhU2l6ZSkpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAxOgogICAgICAgICAgICBzdHJlYW0ucmVhZEhleChzdGFydCwgZGF0YVNpemUpOwogICAgICAgICAgICBzdHJlYW0ucmVhZEhleE51bWJlcihlbmQsIGRhdGFTaXplKTsKICAgICAgICAgICAgYWRkSGV4KGVuZCwgc3RhcnQsIGRhdGFTaXplKTsKICAgICAgICAgICAgc3RyZWFtLnJlYWROdW1iZXIoKTsKICAgICAgICAgICAgZm9yIChsZXQgaSA9IDE7IGkgPCBzdWJpdGVtc0NvdW50OyBpKyspIHsKICAgICAgICAgICAgICBpbmNIZXgoZW5kLCBkYXRhU2l6ZSk7CiAgICAgICAgICAgICAgc3RyZWFtLnJlYWRIZXhOdW1iZXIoc3RhcnQsIGRhdGFTaXplKTsKICAgICAgICAgICAgICBhZGRIZXgoc3RhcnQsIGVuZCwgZGF0YVNpemUpOwogICAgICAgICAgICAgIHN0cmVhbS5yZWFkSGV4TnVtYmVyKGVuZCwgZGF0YVNpemUpOwogICAgICAgICAgICAgIGFkZEhleChlbmQsIHN0YXJ0LCBkYXRhU2l6ZSk7CiAgICAgICAgICAgICAgc3RyZWFtLnJlYWROdW1iZXIoKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgMjoKICAgICAgICAgICAgc3RyZWFtLnJlYWRIZXgoY2hhciwgZGF0YVNpemUpOwogICAgICAgICAgICBjb2RlID0gc3RyZWFtLnJlYWROdW1iZXIoKTsKICAgICAgICAgICAgY01hcC5tYXBPbmUoaGV4VG9JbnQoY2hhciwgZGF0YVNpemUpLCBjb2RlKTsKICAgICAgICAgICAgZm9yIChsZXQgaSA9IDE7IGkgPCBzdWJpdGVtc0NvdW50OyBpKyspIHsKICAgICAgICAgICAgICBpbmNIZXgoY2hhciwgZGF0YVNpemUpOwogICAgICAgICAgICAgIGlmICghc2VxdWVuY2UpIHsKICAgICAgICAgICAgICAgIHN0cmVhbS5yZWFkSGV4TnVtYmVyKHRtcCwgZGF0YVNpemUpOwogICAgICAgICAgICAgICAgYWRkSGV4KGNoYXIsIHRtcCwgZGF0YVNpemUpOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBjb2RlID0gc3RyZWFtLnJlYWRTaWduZWQoKSArIChjb2RlICsgMSk7CiAgICAgICAgICAgICAgY01hcC5tYXBPbmUoaGV4VG9JbnQoY2hhciwgZGF0YVNpemUpLCBjb2RlKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgMzoKICAgICAgICAgICAgc3RyZWFtLnJlYWRIZXgoc3RhcnQsIGRhdGFTaXplKTsKICAgICAgICAgICAgc3RyZWFtLnJlYWRIZXhOdW1iZXIoZW5kLCBkYXRhU2l6ZSk7CiAgICAgICAgICAgIGFkZEhleChlbmQsIHN0YXJ0LCBkYXRhU2l6ZSk7CiAgICAgICAgICAgIGNvZGUgPSBzdHJlYW0ucmVhZE51bWJlcigpOwogICAgICAgICAgICBjTWFwLm1hcENpZFJhbmdlKGhleFRvSW50KHN0YXJ0LCBkYXRhU2l6ZSksIGhleFRvSW50KGVuZCwgZGF0YVNpemUpLCBjb2RlKTsKICAgICAgICAgICAgZm9yIChsZXQgaSA9IDE7IGkgPCBzdWJpdGVtc0NvdW50OyBpKyspIHsKICAgICAgICAgICAgICBpbmNIZXgoZW5kLCBkYXRhU2l6ZSk7CiAgICAgICAgICAgICAgaWYgKCFzZXF1ZW5jZSkgewogICAgICAgICAgICAgICAgc3RyZWFtLnJlYWRIZXhOdW1iZXIoc3RhcnQsIGRhdGFTaXplKTsKICAgICAgICAgICAgICAgIGFkZEhleChzdGFydCwgZW5kLCBkYXRhU2l6ZSk7CiAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgIHN0YXJ0LnNldChlbmQpOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBzdHJlYW0ucmVhZEhleE51bWJlcihlbmQsIGRhdGFTaXplKTsKICAgICAgICAgICAgICBhZGRIZXgoZW5kLCBzdGFydCwgZGF0YVNpemUpOwogICAgICAgICAgICAgIGNvZGUgPSBzdHJlYW0ucmVhZE51bWJlcigpOwogICAgICAgICAgICAgIGNNYXAubWFwQ2lkUmFuZ2UoaGV4VG9JbnQoc3RhcnQsIGRhdGFTaXplKSwgaGV4VG9JbnQoZW5kLCBkYXRhU2l6ZSksIGNvZGUpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSA0OgogICAgICAgICAgICBzdHJlYW0ucmVhZEhleChjaGFyLCB1Y3MyRGF0YVNpemUpOwogICAgICAgICAgICBzdHJlYW0ucmVhZEhleChjaGFyQ29kZSwgZGF0YVNpemUpOwogICAgICAgICAgICBjTWFwLm1hcE9uZShoZXhUb0ludChjaGFyLCB1Y3MyRGF0YVNpemUpLCBoZXhUb1N0cihjaGFyQ29kZSwgZGF0YVNpemUpKTsKICAgICAgICAgICAgZm9yIChsZXQgaSA9IDE7IGkgPCBzdWJpdGVtc0NvdW50OyBpKyspIHsKICAgICAgICAgICAgICBpbmNIZXgoY2hhciwgdWNzMkRhdGFTaXplKTsKICAgICAgICAgICAgICBpZiAoIXNlcXVlbmNlKSB7CiAgICAgICAgICAgICAgICBzdHJlYW0ucmVhZEhleE51bWJlcih0bXAsIHVjczJEYXRhU2l6ZSk7CiAgICAgICAgICAgICAgICBhZGRIZXgoY2hhciwgdG1wLCB1Y3MyRGF0YVNpemUpOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBpbmNIZXgoY2hhckNvZGUsIGRhdGFTaXplKTsKICAgICAgICAgICAgICBzdHJlYW0ucmVhZEhleFNpZ25lZCh0bXAsIGRhdGFTaXplKTsKICAgICAgICAgICAgICBhZGRIZXgoY2hhckNvZGUsIHRtcCwgZGF0YVNpemUpOwogICAgICAgICAgICAgIGNNYXAubWFwT25lKGhleFRvSW50KGNoYXIsIHVjczJEYXRhU2l6ZSksIGhleFRvU3RyKGNoYXJDb2RlLCBkYXRhU2l6ZSkpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSA1OgogICAgICAgICAgICBzdHJlYW0ucmVhZEhleChzdGFydCwgdWNzMkRhdGFTaXplKTsKICAgICAgICAgICAgc3RyZWFtLnJlYWRIZXhOdW1iZXIoZW5kLCB1Y3MyRGF0YVNpemUpOwogICAgICAgICAgICBhZGRIZXgoZW5kLCBzdGFydCwgdWNzMkRhdGFTaXplKTsKICAgICAgICAgICAgc3RyZWFtLnJlYWRIZXgoY2hhckNvZGUsIGRhdGFTaXplKTsKICAgICAgICAgICAgY01hcC5tYXBCZlJhbmdlKGhleFRvSW50KHN0YXJ0LCB1Y3MyRGF0YVNpemUpLCBoZXhUb0ludChlbmQsIHVjczJEYXRhU2l6ZSksIGhleFRvU3RyKGNoYXJDb2RlLCBkYXRhU2l6ZSkpOwogICAgICAgICAgICBmb3IgKGxldCBpID0gMTsgaSA8IHN1Yml0ZW1zQ291bnQ7IGkrKykgewogICAgICAgICAgICAgIGluY0hleChlbmQsIHVjczJEYXRhU2l6ZSk7CiAgICAgICAgICAgICAgaWYgKCFzZXF1ZW5jZSkgewogICAgICAgICAgICAgICAgc3RyZWFtLnJlYWRIZXhOdW1iZXIoc3RhcnQsIHVjczJEYXRhU2l6ZSk7CiAgICAgICAgICAgICAgICBhZGRIZXgoc3RhcnQsIGVuZCwgdWNzMkRhdGFTaXplKTsKICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgc3RhcnQuc2V0KGVuZCk7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIHN0cmVhbS5yZWFkSGV4TnVtYmVyKGVuZCwgdWNzMkRhdGFTaXplKTsKICAgICAgICAgICAgICBhZGRIZXgoZW5kLCBzdGFydCwgdWNzMkRhdGFTaXplKTsKICAgICAgICAgICAgICBzdHJlYW0ucmVhZEhleChjaGFyQ29kZSwgZGF0YVNpemUpOwogICAgICAgICAgICAgIGNNYXAubWFwQmZSYW5nZShoZXhUb0ludChzdGFydCwgdWNzMkRhdGFTaXplKSwgaGV4VG9JbnQoZW5kLCB1Y3MyRGF0Y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BsZXhlcikgewogICAgd2hpbGUgKHRydWUpIHsKICAgICAgbGV0IG9iaiA9IGxleGVyLmdldE9iaigpOwogICAgICBpZiAob2JqID09PSBfcHJpbWl0aXZlcy5FT0YpIHsKICAgICAgICBicmVhazsKICAgICAgfQogICAgICBpZiAoKDAsIF9wcmltaXRpdmVzLmlzQ21kKShvYmosICJlbmRiZmNoYXIiKSkgewogICAgICAgIHJldHVybjsKICAgICAgfQogICAgICBleHBlY3RTdHJpbmcob2JqKTsKICAgICAgY29uc3Qgc3JjID0gc3RyVG9JbnQob2JqKTsKICAgICAgb2JqID0gbGV4ZXIuZ2V0T2JqKCk7CiAgICAgIGV4cGVjdFN0cmluZyhvYmopOwogICAgICBjb25zdCBkc3QgPSBvYmo7CiAgICAgIGNNYXAubWFwT25lKHNyYywgZHN0KTsKICAgIH0KICB9CiAgZnVuY3Rpb24gcGFyc2VCZlJhbmdlKGNNYXAsIGxleGVyKSB7CiAgICB3aGlsZSAodHJ1ZSkgewogICAgICBsZXQgb2JqID0gbGV4ZXIuZ2V0T2JqKCk7CiAgICAgIGlmIChvYmogPT09IF9wcmltaXRpdmVzLkVPRikgewogICAgICAgIGJyZWFrOwogICAgICB9CiAgICAgIGlmICgoMCwgX3ByaW1pdGl2ZXMuaXNDbWQpKG9iaiwgImVuZGJmcmFuZ2UiKSkgewogICAgICAgIHJldHVybjsKICAgICAgfQogICAgICBleHBlY3RTdHJpbmcob2JqKTsKICAgICAgY29uc3QgbG93ID0gc3RyVG9JbnQob2JqKTsKICAgICAgb2JqID0gbGV4ZXIuZ2V0T2JqKCk7CiAgICAgIGV4cGVjdFN0cmluZyhvYmopOwogICAgICBjb25zdCBoaWdoID0gc3RyVG9JbnQob2JqKTsKICAgICAgb2JqID0gbGV4ZXIuZ2V0T2JqKCk7CiAgICAgIGlmIChOdW1iZXIuaXNJbnRlZ2VyKG9iaikgfHwgdHlwZW9mIG9iaiA9PT0gInN0cmluZyIpIHsKICAgICAgICBjb25zdCBkc3RMb3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EludChvYmopOwogICAgICBjb25zdCBkc3QgPSBvYmo7CiAgICAgIGNNYXAubWFwT25lKHNyYywgZHN0KTsKICAgIH0KICB9CiAgZnVuY3Rpb24gcGFyc2VDaWRSYW5nZShjTWFwLCBsZXhlcikgewogICAgd2hpbGUgKHRydWUpIHsKICAgICAgbGV0IG9iaiA9IGxleGVyLmdldE9iaigpOwogICAgICBpZiAob2JqID09PSBfcHJpbWl0aXZlcy5FT0YpIHsKICAgICAgICBicmVhazsKICAgICAgfQogICAgICBpZiAoKDAsIF9wcmltaXRpdmVzLmlzQ21kKShvYmosICJlbmRjaWRyYW5nZSIpKSB7CiAgICAgICAgcmV0dXJuOwogICAgICB9CiAgICAgIGV4cGVjdFN0cmluZyhvYmopOwogICAgICBjb25zdCBsb3cgPSBzdHJUb0ludChvYmopOwogICAgICBvYmogPSBsZXhlci5nZXRPYmooKTsKICAgICAgZXhwZWN0U3RyaW5nKG9iaik7CiAgICAgIGNvbnN0IGhpZ2ggPSBzdHJUb0ludChvYmopOwogICAgICBvYmogPSBsZXhlci5nZXRPYmooKTsKICAgICAgZXhwZWN0SW50KG9iaik7CiAgICAgIGNvbnN0IGRzdExvdyA9IG9iajsKICAgICAgY01hcC5tYXBDaWRSYW5nZShsb3csIGhpZ2gsIGRzdExvdyk7CiAgICB9CiAgfQogIGZ1bmN0aW9uIHBhcnNlQ29kZXNwYWNlUmFuZ2UoY01hcCwgbGV4ZXIpIHsKICAgIHdoaWxlICh0cnVlKSB7CiAgICAgIGxldCBvYmogPSBsZXhlci5nZXRPYmooKTsKICAgICAgaWYgKG9iaiA9PT0gX3ByaW1pdGl2ZXMuRU9GKSB7CiAgICAgICAgYnJlYWs7CiAgICAgIH0KICAgICAgaWYgKCgwLCBfcHJpbWl0aXZlcy5pc0NtZCkob2JqLCAiZW5kY29kZXNwYWNlcmFuZ2UiKSkgewogICAgICAgIHJldHVybjsKICAgICAgfQogICAgICBpZiAodHlwZW9mIG9iaiAhPT0gInN0cmluZyIpIHs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HNlIGlmIChvYmogaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lKSB7CiAgICAgICAgICBpZiAob2JqLm5hbWUgPT09ICJXTW9kZSIpIHsKICAgICAgICAgICAgcGFyc2VXTW9kZShjTWFwLCBsZXhlcik7CiAgICAgICAgICB9IGVsc2UgaWYgKG9iai5uYW1lID09PSAiQ01hcE5hbWUiKSB7CiAgICAgICAgICAgIHBhcnNlQ01hcE5hbWUoY01hcCwgbGV4ZXIpOwogICAgICAgICAgfQogICAgICAgICAgcHJldmlvdXMgPSBvYmo7CiAgICAgICAgfSBlbHNlIGlmIChvYmogaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5DbWQpIHsKICAgICAgICAgIHN3aXRjaCAob2JqLmNtZCkgewogICAgICAgICAgICBjYXNlICJlbmRjbWFwIjoKICAgICAgICAgICAgICBicmVhayBvYmpMb29wOwogICAgICAgICAgICBjYXNlICJ1c2VjbWFwIjoKICAgICAgICAgICAgICBpZiAocHJldmlvdXMgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lKSB7CiAgICAgICAgICAgICAgICBlbWJlZGRlZFVzZUNNYXAgPSBwcmV2aW91cy5uYW1lOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSAiYmVnaW5jb2Rlc3BhY2VyYW5nZSI6CiAgICAgICAgICAgICAgcGFyc2VDb2Rlc3BhY2VSYW5nZShjTWFwLCBsZXhlcik7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIGNhc2UgImJlZ2luYmZjaGFyIjoKICAgICAgICAgICAgICBwYXJzZUJmQ2hhcihjTWFwLCBsZXhlcik7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIGNhc2UgImJlZ2luY2lkY2hhciI6CiAgICAgICAgICAgICAgcGFyc2VDaWRDaGFyKGNNYXAsIGxleGVyKTsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2Fz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yYXk7CiAgICAgICAgY2FzZSAiPDwiOgogICAgICAgICAgY29uc3QgZGljdCA9IG5ldyBfcHJpbWl0aXZlcy5EaWN0KHRoaXMueHJlZik7CiAgICAgICAgICB3aGlsZSAoISgwLCBfcHJpbWl0aXZlcy5pc0NtZCkodGhpcy5idWYxLCAiPj4iKSAmJiB0aGlzLmJ1ZjEgIT09IF9wcmltaXRpdmVzLkVPRikgewogICAgICAgICAgICBpZiAoISh0aGlzLmJ1ZjEgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lKSkgewogICAgICAgICAgICAgICgwLCBfdXRpbC5pbmZvKSgiTWFsZm9ybWVkIGRpY3Rpb25hcnk6IGtleSBtdXN0IGJlIGEgbmFtZSBvYmplY3QiKTsKICAgICAgICAgICAgICB0aGlzLnNoaWZ0KCk7CiAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgY29uc3Qga2V5ID0gdGhpcy5idWYxLm5hbWU7CiAgICAgICAgICAgIHRoaXMuc2hpZnQoKTsKICAgICAgICAgICAgaWYgKHRoaXMuYnVmMSA9PT0gX3ByaW1pdGl2ZXMuRU9GKSB7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZGljdC5zZXQoa2V5LCB0aGlzLmdldE9iaihjaXBoZXJUcmFuc2Zvcm0pKTsKICAgICAgICAgIH0KICAgICAgICAgIGlmICh0aGlzLmJ1ZjEgPT09IF9wcmltaXRpdmVzLkVPRikgewogICAgICAgICAgICBpZiAodGhpcy5yZWNvdmVyeU1vZGUpIHsKICAgICAgICAgICAgICByZXR1cm4gZGljdDsKICAgICAgICAgICAgfQogICAgICAgICAgICB0aHJvdyBuZXcgX2NvcmVfdXRpbHMuUGFyc2VyRU9GRXhjZXB0aW9uKCJFbmQgb2YgZmlsZSBpbnNpZGUgZGljdGlvbmFyeS4iKTsKICAgICAgICAgIH0KICAgICAgICAgIGlmICgoMCwgX3ByaW1pd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9IHRoaXMubGV4ZXIsCiAgICAgIHN0YXJ0UG9zID0gc3RyZWFtLnBvcywKICAgICAgbiA9IDEwOwogICAgbGV0IHN0YXRlID0gMCwKICAgICAgY2gsCiAgICAgIG1heWJlRUlQb3M7CiAgICB3aGlsZSAoKGNoID0gc3RyZWFtLmdldEJ5dGUoKSkgIT09IC0xKSB7CiAgICAgIGlmIChzdGF0ZSA9PT0gMCkgewogICAgICAgIHN0YXRlID0gY2ggPT09IEUgPyAxIDogMDsKICAgICAgfSBlbHNlIGlmIChzdGF0ZSA9PT0gMSkgewogICAgICAgIHN0YXRlID0gY2ggPT09IEkgPyAyIDogMDsKICAgICAgfSBlbHNlIHsKICAgICAgICBpZiAoY2ggPT09IFNQQUNFIHx8IGNoID09PSBMRiB8fCBjaCA9PT0gQ1IpIHsKICAgICAgICAgIG1heWJlRUlQb3MgPSBzdHJlYW0ucG9zOwogICAgICAgICAgY29uc3QgZm9sbG93aW5nQnl0ZXMgPSBzdHJlYW0ucGVla0J5dGVzKG4pOwogICAgICAgICAgZm9yIChsZXQgaSA9IDAsIGlpID0gZm9sbG93aW5nQnl0ZXMubGVuZ3RoOyBpIDwgaWk7IGkrKykgewogICAgICAgICAgICBjaCA9IGZvbGxvd2luZ0J5dGVzW2ldOwogICAgICAgICAgICBpZiAoY2ggPT09IE5VTCAmJiBmb2xsb3dpbmdCeXRlc1tpICsgMV0gIT09IE5VTCkgewogICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmIChjaCAhPT0gTEYgJiYgY2ggIT09IENSICYmIChjaCA8IFNQQUNFIHx8IGNoID4gMHg3ZikpIHsKICAgICAgICAgICAgICBzdGF0ZSA9IDA7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIGlmIChzdGF0ZSAhPT0gMikgewogICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgIH0KICAgICAgICAgIGlmIChsZXhlci5rbm93bkNvbW1hbmRzKSB7CiAgICAgICAgICAgIGNvbnN0IG5leHRPYmogPSBsZXhlci5wZWVrT2JqKCk7CiAgICAgICAgICAgIGlmIChuZXh0T2JqIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuQ21kICYmICFsZXhlci5rbm93bkNvbW1hbmRzW25leHRPYmouY21kXSkgewogICAgICAgICAgICAgIHN0YXRlID0gMDsKICAgICAgICAgICAgfQogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKCJmaW5kRGVmYXVsdElubGluZVN0cmVhbUVuZCAtIGBsZXhlci5rbm93bkNvbW1hbmRzYCBpcyB1bmRlZmluZWQuIik7CiAgICAgICAgICB9CiAgICAgICAgICBpZiAoc3RhdGUgPT09IDIpIHsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICB9CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIHN0YXRlID0gMDsKICAgICAgICB9CiAgICAgIH0KICAgIH0KICAgIGlmIChjaCA9PT0gLTEpIHsKICAgICAgKDAsIF91dGlsLndhcm4pKCJmaW5kRGVmYXVsdElubGluZVN0cmVhbUVuZDogIiArICJSZWFjaGVkIHRoZSBlbmQgb2YgdGhlIHN0cmVhbSB3aXRob3V0IGZpbmRpbmcgYSB2YWxpZCBFSSBtYXJrZXIiKTsKICAgICAgaWYgKG1heWJlRUlQb3MpIHsKICAgICAgICAoMCwgX3V0aWwud2FybikoJy4uLiB0cnlpbmcgdG8gcmVjb3ZlciBieSB1c2luZyB0aGUgbGFzdCAiRUkiIG9jY3VycmVuY2UuJyk7CiAgICAgICAgc3RyZWFtLnNraXAoLShzdHJlYW0ucG9zIC0gbWF5YmVFSVBvcykpOwogICAgICB9CiAgICB9CiAgICBsZXQgZW5kT2Zmc2V0ID0gNDsKICAgIHN0cmVhbS5za2lwKC1lbmRPZmZzZXQpOwogICAgY2ggPSBzdHJlYW0ucGVla0J5dGUoKTsKICAgIHN0cmVhbS5za2lwKGVuZE9mZnNldCk7CiAgICBpZiAoISgwLCBfY29yZV91dGlscy5pc1doaXRlU3BhY2UpKGNoKSkgewogICAgICBlbmRPZmZzZXQtLTsKICAgIH0KICAgIHJldHVybiBzdHJlYW0ucG9zIC0gZW5kT2Zmc2V0IC0gc3RhcnRQb3M7CiAgfQogIGZpbmREQ1REZWNvZGVJbmxpbmVTdHJlYW1FbmQoc3RyZWFtKSB7CiAgICBjb25zdCBzdGFydFBvcyA9IHN0cmVhbS5wb3M7CiAgICBsZXQgZm91bmRFT0kgPSBmYWxzZSwKICAgICAgYiwKICAgICAgbWFya2VyTGVuZ3RoOwogICAgd2hpbGUgKChiID0gc3RyZWFtLmdldEJ5dGUoKSkgIT09IC0xKSB7CiAgICAgIGlmIChiICE9PSAweGZmKSB7CiAgICAgICAgY29udGludWU7CiAgICAgIH0KICAgICAgc3dpdGNoIChzdHJlYW0uZ2V0Qnl0ZSgpKSB7CiAgICAgICAgY2FzZSAweDAwOgogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAweGZmOgogICAgICAgICAgc3RyZWFtLnNraXAoLTEpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAweGQ5OgogICAgICAgICAgZm91bmRFT0kgPSB0cnVlOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAweGMwOgogICAgICAgIGNhc2UgMHhjMToKICAgICAgICBjYXNlIDB4YzI6CiAgICAgICAgY2FzZSAweGMzOgogICAgICAgIGNhc2UgMHhjNToKICAgICAgICBjYXNlIDB4YzY6CiAgICAgICAgY2FzZSAweGM3OgogICAgICAgIGNhc2UgMHhjOToKICAgICAgICBjYXNlIDB4Y2E6CiAgICAgICAgY2FzZSAweGNiOgogICAgICAgIGNhc2UgMHhjZDoKICAgICAgICBjYXNlIDB4Y2U6CiAgICAgICAgY2FzZSAweGNmOgogICAgICAgIGNhc2UgMHhjNDoKICAgICAgICBjYXNlIDB4Y2M6CiAgICAgICAgY2FzZSAweGRhOgogICAgICAgIGNhc2UgMHhkYjoKICAgICAgICBjYXNlIDB4ZGM6CiAgICAgICAgY2FzZSAweGRkOgogICAgICAgIGNhc2UgMHhkZToKICAgICAgICBjYXNlIDB4ZGY6CiAgICAgICAgY2FzZSAweGUwOgogICAgICAgIGNhc2UgMHhlMToKICAgICAgICBjYXNlIDB4ZTI6CiAgICAgICAgY2FzZSAweGUzOgogICAgICAgIGNhc2UgMHhlNDoKICAgICAgICBjYXNlIDB4ZTU6CiAgICAgICAgY2FzZSAweGU2OgogICAgICAgIGNhc2UgMHhlNzoKICAgICAgICBjYXNlIDB4ZTg6CiAgICAgICAgY2FzZSAweGU5OgogICAgICAgIGNhc2UgMHhlYToKICAgICAgICBjYXNlIDB4ZWI6CiAgICAgICAgY2FzZSAweGVjOgogICAgICAgIGNhc2UgMHhlZDoKICAgICAgICBjYXNlIDB4ZWU6CiAgICAgICAgY2FzZSAweGVmOgogICAgICAgIGNhc2UgMHhmZToKICAgICAgICAgIG1hcmtlckxlbmd0aCA9IHN0cmVhbS5nZXRVaW50MTYoKTsKICAgICAgICAgIGlmIChtYXJrZXJMZW5ndGggPiAyKSB7CiAgICAgICAgICAgIHN0cmVhbS5za2lwKG1hcmtlckxlbmd0aCAtIDIpOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgc3RyZWFtLnNraXAoLTIpOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgIH0KICAgICAgaWYgKGZvdW5kRU9JKSB7CiAgICAgICAgYnJlYWs7CiAgICAgIH0KICAgIH0KICAgIGNvbnN0IGxlbmd0aCA9IHN0cmVhbS5wb3MgLSBzdGFydFBvczsKICAgIGlmIChiID09PSAtMSkgewogICAgICAoMCwgX3V0aWwud2FybikoIklubGluZSBEQ1REZWNvZGUgaW1hZ2Ugc3RyZWFtOiAiICsgIkVPSSBtYXJrZXIgbm90IGZvdW5kLCBzZWFyY2hpbmcgZm9yIC9FSS8gaW5zdGVhZC4iKTsKICAgICA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UgPSBiYXNlVmFsdWUgKiAxMCArIGN1cnJlbnREaWdpdDsKICAgICAgICB9CiAgICAgIH0gZWxzZSBpZiAoY2ggPT09IDB4MmUpIHsKICAgICAgICBpZiAoZGl2aWRlQnkgPT09IDApIHsKICAgICAgICAgIGRpdmlkZUJ5ID0gMTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICB9IGVsc2UgaWYgKGNoID09PSAweDJkKSB7CiAgICAgICAgKDAsIF91dGlsLndhcm4pKCJCYWRseSBmb3JtYXR0ZWQgbnVtYmVyOiBtaW51cyBzaWduIGluIHRoZSBtaWRkbGUiKTsKICAgICAgfSBlbHNlIGlmIChjaCA9PT0gMHg0NSB8fCBjaCA9PT0gMHg2NSkgewogICAgICAgIGNoID0gdGhpcy5wZWVrQ2hhcigpOwogICAgICAgIGlmIChjaCA9PT0gMHgyYiB8fCBjaCA9PT0gMHgyZCkgewogICAgICAgICAgcG93ZXJWYWx1ZVNpZ24gPSBjaCA9PT0gMHgyZCA/IC0xIDogMTsKICAgICAgICAgIHRoaXMubmV4dENoYXIoKTsKICAgICAgICB9IGVsc2UgaWYgKGNoIDwgMHgzMCB8fCBjaCA+IDB4MzkpIHsKICAgICAgICAgIGJyZWFrOwogICAgICAgIH0KICAgICAgICBlTm90YXRpb24gPSB0cnVlOwogICAgICB9IGVsc2UgewogICAgICAgIGJyZWFrOwogICAgICB9CiAgICB9CiAgICBpZiAoZGl2aWRlQnkgIT09IDApIHsKICAgICAgYmFzZVZhbHVlIC89IGRpdmlkZUJ5OwogICAgfQogICAgaWYgKGVOb3RhdGlvbikgewogICAgICBiYXNlVmFsdWUgKj0gMTAgKiogKHBvd2VyVmFsdWVTaWduICogcG93ZXJWYWx1ZSk7CiAgICB9CiAgICByZXR1cm4gc2lnbiAqIGJhc2VWYWx1ZTsKICB9CiAgZ2V0U3RyaW5nKCkgewogICAgbGV0IG51bVBhcmVuID0gMTsKICAgIGxldCBkb25lID0gZmFsc2U7CiAgICBjb25zdCBzdHJCdWYgPSB0aGlzLnN0ckJ1ZjsKICAgIHN0ckJ1Zi5sZW5ndGggPSAwOwogICAgbGV0IGNoID0gdGhpcy5uZXh0Q2hhcigpOwogICAgd2hpbGUgKHRydWUpIHsKICAgICAgbGV0IGNoYXJCdWZmZXJlZCA9IGZhbHNlOwogICAgICBzd2l0Y2ggKGNoIHwgMCkgewogICAgICAgIGNhc2UgLTE6CiAgICAgICAgICAoMCwgX3V0aWwud2FybikoIlVudGVybWluYXRlZCBzdHJpbmciKTsKICAgICAgICAgIGRvbmUgPSB0cnVlOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAweDI4OgogICAgICAgICAgKytudW1QYXJlbjsKICAgICAgICAgIHN0ckJ1Zi5wdXNoKCIoIik7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIDB4Mjk6CiAgICAgICAgICBpZiAoLS1udW1QYXJlbiA9PT0gMCkgewogICAgICAgICAgICB0aGlzLm5leHRDaGFyKCk7CiAgICAgICAgICAgIGRvbmUgPSB0cnVlOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgc3RyQnVmLnB1c2goIikiKTsKICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMHg1YzoKICAgICAgICAgIGNoID0gdGhpcy5uZXh0Q2hhcigpOwogICAgICAgICAgc3dpdGNoIChjaCkgewogICAgICAgICAgICBjYXNlIC0xOgogICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKSgiVW50ZXJtaW5hdGVkIHN0cmluZyIpOwogICAgICAgICAgICAgIGRvbmUgPSB0cnVlOwogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICBjYXNlIDB4NmU6CiAgICAgICAgICAgICAgc3RyQnVmLnB1c2goIlxuIik7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIGNhc2UgMHg3MjoKICAgICAgICAgICAgICBzdHJCdWYucHVzaCgiXHIiKTsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSAweDc0OgogICAgICAgICAgICAgIHN0ckJ1Zi5wdXNoKCJcdCIpOwogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICBjYXNlIDB4NjI6CiAgICAgICAgICAgICAgc3RyQnVmLnB1c2goIlxiIik7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIGNhc2UgMHg2NjoKICAgICAgICAgICAgICBzdHJCdWYucHVzaCgiXGYiKTsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSAweDVjOgogICAgICAgICAgICBjYXNlIDB4Mjg6CiAgICAgICAgICAgIGNhc2UgMHgyOToKICAgICAgICAgICAgICBzdHJCdWYucHVzaChTdHJpbmcuZnJvbUNoYXJDb2RlKGNoKSk7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIGNhc2UgMHgzMDoKICAgICAgICAgICAgY2FzZSAweDMxOgogICAgICAgICAgICBjYXNlIDB4MzI6CiAgICAgICAgICAgIGNhc2UgMHgzMzoKICAgICAgICAgICAgY2FzZSAweDM0OgogICAgICAgICAgICBjYXNlIDB4MzU6CiAgICAgICAgICAgIGNhc2UgMHgzNjoKICAgICAgICAgICAgY2FzZSAweDM3OgogICAgICAgICAgICAgIGxldCB4ID0gY2ggJiAweDBmOwogICAgICAgICAgICAgIGNoID0gdGhpcy5uZXh0Q2hhcigpOwogICAgICAgICAgICAgIGNoYXJCdWZmZXJlZCA9IHRydWU7CiAgICAgICAgICAgICAgaWYgKGNoID49IDB4MzAgJiYgY2ggPD0gMHgzNykgewogICAgICAgICAgICAgICAgeCA9ICh4IDw8IDMpICsgKGNoICYgMHgwZik7CiAgICAgICAgICAgICAgICBjaCA9IHRoaXMubmV4dENoYXIoKTsKICAgICAgICAgICAgICAgIGlmIChjaCA+PSAweDMwICYmIGNoIDw9IDB4MzcpIHsKICAgICAgICAgICAgICAgICAgY2hhckJ1ZmZlcmVkID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgIHggPSAoeCA8PCAzKSArIChjaCAmIDB4MGYpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBzdHJCdWYucHVzaChTdHJpbmcuZnJvbUNoYXJDb2RlKHgpKTsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSAweDBkOgogICAgICAgICAgICAgIGlmICh0aGlzLnBlZWtDaGFyKCkgPT09IDB4MGEpIHsKICAgICAgICAgICAgICAgIHRoaXMubmV4dENoYXIoKTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIGNhc2UgMHgwYToKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICBzdHJCdWYucHVzaChTdHJpbmcuZnJvbUNoYXJDb2RlKGNoKSk7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICBkZWZhdWx0OgogICAgICAgICAgc3RyQnVmLnB1c2goU3RyaW5nLmZyb21DaGFyQ29kZShjaCkpOwogICAgICAgICAgYnJlYWs7CiAgICAgIH0KICAgICAgaWYgKGRvbmUpIHsKICAgICAgICBicmVhazsKICAgICAgfQogICAgICBpZiAoIWNoYXJCdWZmZXJlZCkgewogICAgICAgIGNoID0gdGhpcy5uZXh0Q2hhcigpOwogICAgICB9CiAgICB9CiAgICByZXR1cm4gc3RyQnVmLmpvaW4oIiIpOwogIH0KICBnZXROYW1lKCkgewogICAgbGV0IGNoLCBwcmV2aW91c0NoOwogICAgY29uc3Qgc3RyQnVmID0gdGhpcy5zdHJCdWY7CiAgICBzdHJCdWYubGVuZ3RoID0gMDsKICAgIHdoaWxlICgoY2ggPSB0aGlzLm5leHRDaGFyKCkpID49IDAgJiYgIXNwZWNpYWxDaGFyc1tjaF0pIHsKICAgICAgaWYgKGNoID09PSAweDIzKSB7CiAgICA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pdCwgc2Vjb25kRGlnaXQ7CiAgICB0aGlzLl9oZXhTdHJpbmdOdW1XYXJuID0gMDsKICAgIHdoaWxlICh0cnVlKSB7CiAgICAgIGlmIChjaCA8IDApIHsKICAgICAgICAoMCwgX3V0aWwud2FybikoIlVudGVybWluYXRlZCBoZXggc3RyaW5nIik7CiAgICAgICAgYnJlYWs7CiAgICAgIH0gZWxzZSBpZiAoY2ggPT09IDB4M2UpIHsKICAgICAgICB0aGlzLm5leHRDaGFyKCk7CiAgICAgICAgYnJlYWs7CiAgICAgIH0gZWxzZSBpZiAoc3BlY2lhbENoYXJzW2NoXSA9PT0gMSkgewogICAgICAgIGNoID0gdGhpcy5uZXh0Q2hhcigpOwogICAgICAgIGNvbnRpbnVlOwogICAgICB9IGVsc2UgewogICAgICAgIGlmIChpc0ZpcnN0SGV4KSB7CiAgICAgICAgICBmaXJzdERpZ2l0ID0gdG9IZXhEaWdpdChjaCk7CiAgICAgICAgICBpZiAoZmlyc3REaWdpdCA9PT0gLTEpIHsKICAgICAgICAgICAgdGhpcy5faGV4U3RyaW5nV2FybihjaCk7CiAgICAgICAgICAgIGNoID0gdGhpcy5uZXh0Q2hhcigpOwogICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgIH0KICAgICAgICB9IGVsc2UgewogICAgICAgICAgc2Vjb25kRGlnaXQgPSB0b0hleERpZ2l0KGNoKTsKICAgICAgICAgIGlmIChzZWNvbmREaWdpdCA9PT0gLTEpIHsKICAgICAgICAgICAgdGhpcy5faGV4U3RyaW5nV2FybihjaCk7CiAgICAgICAgICAgIGNoID0gdGhpcy5uZXh0Q2hhcigpOwogICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgIH0KICAgICAgICAgIHN0ckJ1Zi5wdXNoKFN0cmluZy5mcm9tQ2hhckNvZGUoZmlyc3REaWdpdCA8PCA0IHwgc2Vjb25kRGlnaXQpKTsKICAgICAgICB9CiAgICAgICAgaXNGaXJzdEhleCA9ICFpc0ZpcnN0SGV4OwogICAgICAgIGNoID0gdGhpcy5uZXh0Q2hhcigpOwogICAgICB9CiAgICB9CiAgICByZXR1cm4gc3RyQnVmLmpvaW4oIiIpOwogIH0KICBnZXRPYmooKSB7CiAgICBsZXQgY29tbWVudCA9IGZhbHNlOwogICAgbGV0IGNoID0gdGhpcy5jdXJyZW50Q2hhcjsKICAgIHdoaWxlICh0cnVlKSB7CiAgICAgIGlmIChjaCA8IDApIHsKICAgICAgICByZXR1cm4gX3ByaW1pdGl2ZXMuRU9GOwogICAgICB9CiAgICAgIGlmIChjb21tZW50KSB7CiAgICAgICAgaWYgKGNoID09PSAweDBhIHx8IGNoID09PSAweDBkKSB7CiAgICAgICAgICBjb21tZW50ID0gZmFsc2U7CiAgICAgICAgfQogICAgICB9IGVsc2UgaWYgKGNoID09PSAweDI1KSB7CiAgICAgICAgY29tbWVudCA9IHRydWU7CiAgICAgIH0gZWxzZSBpZiAoc3BlY2lhbENoYXJzW2NoXSAhPT0gMSkgewogICAgICAgIGJyZWFrOwogICAgICB9CiAgICAgIGNoID0gdGhpcy5uZXh0Q2hhcigpOwogICAgfQogICAgc3dpdGNoIChjaCB8IDApIHsKICAgICAgY2FzZSAweDMwOgogICAgICBjYXNlIDB4MzE6CiAgICAgIGNhc2UgMHgzMjoKICAgICAgY2FzZSAweDMzOgogICAgICBjYXNlIDB4MzQ6CiAgICAgIGNhc2UgMHgzNToKICAgICAgY2FzZSAweDM2OgogICAgICBjYXNlIDB4Mzc6CiAgICAgIGNhc2UgMHgzODoKICAgICAgY2FzZSAweDM5OgogICAgICBjYXNlIDB4MmI6CiAgICAgIGNhc2UgMHgyZDoKICAgICAgY2FzZSAweDJlOgogICAgICAgIHJldHVybiB0aGlzLmdldE51bWJlcigpOwogICAgICBjYXNlIDB4Mjg6CiAgICAgICAgcmV0dXJuIHRoaXMuZ2V0U3RyaW5nKCk7CiAgICAgIGNhc2UgMHgyZjoKICAgICAgICByZXR1cm4gdGhpcy5nZXROYW1lKCk7CiAgICAgIGNhc2UgMHg1YjoKICAgICAgICB0aGlzLm5leHRDaGFyKCk7CiAgICAgICAgcmV0dXJuIF9wcmltaXRpdmVzLkNtZC5nZXQoIlsiKTsKICAgICAgY2FzZSAweDVkOgogICAgICAgIHRoaXMubmV4dENoYXIoKTsKICAgICAgICByZXR1cm4gX3ByaW1pdGl2ZXMuQ21kLmdldCgiXSIpOwogICAgICBjYXNlIDB4M2M6CiAgICAgICAgY2ggPSB0aGlzLm5leHRDaGFyKCk7CiAgICAgICAgaWYgKGNoID09PSAweDNjKSB7CiAgICAgICAgICB0aGlzLm5leHRDaGFyKCk7CiAgICAgICAgICByZXR1cm4gX3ByaW1pdGl2ZXMuQ21kLmdldCgiPDwiKTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIHRoaXMuZ2V0SGV4U3RyaW5nKCk7CiAgICAgIGNhc2UgMHgzZToKICAgICAgICBjaCA9IHRoaXMubmV4dENoYXIoKTsKICAgICAgICBpZiAoY2ggPT09IDB4M2UpIHsKICAgICAgICAgIHRoaXMubmV4dENoYXIoKTsKICAgICAgICAgIHJldHVybiBfcHJpbWl0aXZlcy5DbWQuZ2V0KCI+PiIpOwogICAgICAgIH0KICAgICAgICByZXR1cm4gX3ByaW1pdGl2ZXMuQ21kLmdldCgiPiIpOwogICAgICBjYXNlIDB4N2I6CiAgICAgICAgdGhpcy5uZXh0Q2hhcigpOwogICAgICAgIHJldHVybiBfcHJpbWl0aXZlcy5DbWQuZ2V0KCJ7Iik7CiAgICAgIGNhc2UgMHg3ZDoKICAgICAgICB0aGlzLm5leHRDaGFyKCk7CiAgICAgICAgcmV0dXJuIF9wcmltaXRpdmVzLkNtZC5nZXQoIn0iKTsKICAgICAgY2FzZSAweDI5OgogICAgICAgIHRoaXMubmV4dENoYXIoKTsKICAgICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoYElsbGVnYWwgY2hhcmFjdGVyOiAke2NofWApOwogICAgfQogICAgbGV0IHN0ciA9IFN0cmluZy5mcm9tQ2hhckNvZGUoY2gpOwogICAgaWYgKGNoIDwgMHgyMCB8fCBjaCA+IDB4N2YpIHsKICAgICAgY29uc3QgbmV4dENoID0gdGhpcy5wZWVrQ2hhcigpOwogICAgICBpZiAobmV4dENoID49IDB4MjAgJiYgbmV4dENoIDw9IDB4N2YpIHsKICAgICAgICB0aGlzLm5leHRDaGFyKCk7CiAgICAgICAgcmV0dXJuIF9wcmltaXRpdmVzLkNtZC5nZXQoc3RyKTsKICAgICAgfQogICAgfQogICAgY29uc3Qga25vd25Db21tYW5kcyA9IHRoaXMua25vd25Db21tYW5kczsKICAgIGxldCBrbm93bkNvbW1hbmRGb3VuZCA9IGtub3duQ29tbWFuZHMgJiYga25vd25Db21tYW5kc1tzdHJdICE9PSB1bmRlZmluZWQ7CiAgICB3aGlsZSAoKGNoID0gdGhpcy5uZXh0Q2hhcigpKSA+PSAwICYmICFzcGVjaWFsQ2hhcnNbY2hdKSB7CiAgICAgIGNvbnN0IHBvc3NpYmxlQ29tbWFuZCA9IHN0ciArIFN0cmluZy5mcm9tQ2hhckNvZGUoY2gpOwogICAgICBpZiAoa25vd25Db21tYW5kRm91bmQgJiYga25vd25Db21tYW5kc1twb3NzaWJsZUNvbW1hbmRdID09PSB1bmRlZmluZWQpIHsKICAgICAgICBicmVhazsKICAgICAgfQogICAgICBpZiAoc3RyLmxlbmd0aCA9PT0gMTI4KSB7CiAgICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKGBDb21tYW5kIHRva2VuIHRvbyBsb25nOiAke3N0ci5sZW5ndGh9YCk7CiAgICAgIH0KICAgICAgc3RyID0gcG9zc2libGVDb21tYW5kOwogICAgICBrbm93bkNvbW1hbmRGb3VuZCA9IGtub3duQ29tbWFuZHMgJiYga25vd25Db21tYW5kc1tzdHJdICE9PSB1bmRlZmluZWQ7CiAgICB9CiAgICBpZiAoc3RyID09PSAidHJ1ZSIpIHsKICAgICAgcmV0dXJuIHRydWU7CiAgICB9CiAgICBpZiAoc3RyID09PSAiZmFsc2UiKSB7CiAgICAgIHJldHVybiBmYWxzZTsKICAgIH0KICAgIGlmIChzdHIgPT09ICJudWxsIikgewogICAgICByZXR1cm4gbnVsbDsKICAgIH0KICAgIGlmIChzdHIgPT09ICJCSSIpIHsKICAgICAgdGhpcy5iZWdpbklubGluZUltYWdlUG9zID0gdGhpcy5zdHJlYW0ucG9zOwogICAgfQogICAgcmV0dXJuIF9wcmltaXRpdmVzLkNtZC5nZXQoc3RyKTsKICB9CiAgcGVla09iaigpIHsKICAgIGNvbnN0IHN0cmVhbVBvcyA9IHRoaXMuc3RyZWFtLnBvcywKICAgICAgY3VycmVudENoYXIgPSB0aGlzLmN1cnJlbnRDaGFyLAogICAgICBiZWdpbklubGluZUltYWdlUG9zID0gdGhpcy5iZWdpbklubGluZUltYWdlUG9zOwogICAgbGV0IG5leHRPYmo7CiAgICB0cnkgewogICAgICBuZXh0T2JqID0gdGhpcy5nZXRPYmooKTsKICAgIH0gY2F0Y2ggKGV4KSB7CiAgICAgIGlmIChleCBpbnN0YW5jZW9mIF9jb3JlX3V0aWxzLk1pc3NpbmdEYXRhRXhjZXB0aW9uKSB7CiAgICAgICAgdGhyb3cgZXg7CiAgICAgIH0KICAgICAgKDAsIF91dGlsLndhcm4pKGBwZWVrT2JqOiAke2V4fWApOwogICAgfQogICAgdGhpcy5zdHJlYW0ucG9zID0gc3RyZWFtUG9zOwogICAgdGhpcy5jdXJyZW50Q2hhciA9IGN1cnJlbnRDaGFyOwogICAgdGhpcy5iZWdpbklubGluZUltYWdlUG9zID0gYmVnaW5JbmxpbmVJbWFnZVBvczsKICAgIHJldHVybiBuZXh0T2JqOwogIH0KICBza2lwVG9OZXh0TGluZSgpIHsKICAgIGxldCBjaCA9IHRoaXMuY3VycmVudENoYXI7CiAgICB3aGlsZSAoY2ggPj0gMCkgewogICAgICBpZiAoY2ggPT09IDB4MGQpIHsKICAgICAgICBjaCA9IHRoaXMubmV4dENoYXIoKTsKICAgICAgICBp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CiAgICAgICAgZm9yIChsZXQgaW5kZXggPSAwOyBpbmRleCA8IGhpbnRzTGVuZ3RoOyBpbmRleCsrKSB7CiAgICAgICAgICBjb25zdCBoaW50ID0gaGludHNbaW5kZXhdOwogICAgICAgICAgaWYgKCEoTnVtYmVyLmlzSW50ZWdlcihoaW50KSAmJiBoaW50ID4gMCkpIHsKICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKGBIaW50ICgke2luZGV4fSkgaW4gdGhlIGxpbmVhcml6YXRpb24gZGljdGlvbmFyeSBpcyBpbnZhbGlkLmApOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICByZXR1cm4gaGludHM7CiAgICAgIH0KICAgICAgdGhyb3cgbmV3IEVycm9yKCJIaW50IGFycmF5IGluIHRoZSBsaW5lYXJpemF0aW9uIGRpY3Rpb25hcnkgaXMgaW52YWxpZC4iKTsKICAgIH0KICAgIGNvbnN0IHBhcnNlciA9IG5ldyBQYXJzZXIoewogICAgICBsZXhlcjogbmV3IExleGVyKHN0cmVhbSksCiAgICAgIHhyZWY6IG51bGwKICAgIH0pOwogICAgY29uc3Qgb2JqMSA9IHBhcnNlci5nZXRPYmooKTsKICAgIGNvbnN0IG9iajIgPSBwYXJzZXIuZ2V0T2JqKCk7CiAgICBjb25zdCBvYmozID0gcGFyc2VyLmdldE9iaigpOwogICAgY29uc3QgbGluRGljdCA9IHBhcnNlci5nZXRPYmooKTsKICAgIGxldCBvYmosIGxlbmd0aDsKICAgIGlmICghKE51bWJlci5pc0ludGVnZXIob2JqMSkgJiYgTnVtYmVyLmlzSW50ZWdlcihvYmoyKSAmJiAoMCwgX3ByaW1pdGl2ZXMuaXNDbWQpKG9iajMsICJvYmoiKSAmJiBsaW5EaWN0IGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuRGljdCAmJiB0eXBlb2YgKG9iaiA9IGxpbkRpY3QuZ2V0KCJMaW5lYXJpemVkIikpID09PSAibnVtYmVyIiAmJiBvYmogPiAwKSkgewogICAgICBy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EJpdHMgPSAwOwogICAgdGhpcy5pbnB1dEJ1ZiA9IDA7CiAgICB0aGlzLm91dHB1dEJpdHMgPSAwOwogICAgdGhpcy5yb3dzRG9uZSA9IGZhbHNlOwogICAgbGV0IGNvZGUxOwogICAgd2hpbGUgKChjb2RlMSA9IHRoaXMuX2xvb2tCaXRzKDEyKSkgPT09IDApIHsKICAgICAgdGhpcy5fZWF0Qml0cygxKTsKICAgIH0KICAgIGlmIChjb2RlMSA9PT0gMSkgewogICAgICB0aGlzLl9lYXRCaXRzKDEyKTsKICAgIH0KICAgIGlmICh0aGlzLmVuY29kaW5nID4gMCkgewogICAgICB0aGlzLm5leHRMaW5lMkQgPSAhdGhpcy5fbG9va0JpdHMoMSk7CiAgICAgIHRoaXMuX2VhdEJpdHMoMSk7CiAgICB9CiAgfQogIHJlYWROZXh0Q2hhcigpIHsKICAgIGlmICh0aGlzLmVvZikgewogICAgICByZXR1cm4gLTE7CiAgICB9CiAgICBjb25zdCByZWZMaW5lID0gdGhpcy5yZWZMaW5lOwogICAgY29uc3QgY29kaW5nTGluZSA9IHRoaXMuY29kaW5nTGluZTsKICAgIGNvbnN0IGNvbHVtbnMgPSB0aGlzLmNvbHVtbnM7CiAgICBsZXQgcmVmUG9zLCBibGFja1BpeGVscywgYml0cywgaTsKICAgIGlmICh0aGlzLm91dHB1dEJpdHMgPT09IDApIHsKICAgICAgaWYgKHRoaXMucm93c0RvbmUpIHsKICAgICAgICB0aGlzLmVvZiA9IHRydWU7CiAgICAgIH0KICAgICAgaWYgKHRoaXMuZW9mKSB7CiAgICAgICAgcmV0dXJuIC0xOwogICAgICB9CiAgICAgIHRoaXMuZXJyID0gZmFsc2U7CiAgICAgIGxldCBjb2RlMSwgY29kZTIsIGNvZGUzOwogICAgICBpZiAodGhpcy5uZXh0TGluZTJEKSB7CiAgICAgICAgZm9yIChpID0gMDsgY29kaW5nTGluZVtpXSA8IGNvbHVtbnM7ICsraSkgewogICAgICAgICAgcmVmTGluZVtpXSA9IGNvZGluZ0xpbmVbaV07CiAgICAgICAgfQogICAgICAgIHJlZkxpbmVbaSsrXSA9IGNvbHVtbnM7CiAgICAgICAgcmVmTGluZVtpXSA9IGNvbHVtbnM7CiAgICAgICAgY29kaW5nTGluZVswXSA9IDA7CiAgICAgICAgdGhpcy5jb2RpbmdQb3MgPSAwOwogICAgICAgIHJlZlBvcyA9IDA7CiAgICAgICAgYmxhY2tQaXhlbHMgPSAwOwogICAgICAgIHdoaWxlIChjb2RpbmdMaW5lW3RoaXMuY29kaW5nUG9zXSA8IGNvbHVtbnMpIHsKICAgICAgICAgIGNvZGUxID0gdGhpcy5fZ2V0VHdvRGltQ29kZSgpOwogICAgICAgICAgc3dpdGNoIChjb2RlMSkgewogICAgICAgICAgICBjYXNlIHR3b0RpbVBhc3M6CiAgICAgICAgICAgICAgdGhpcy5fYWRkUGl4ZWxzKHJlZkxpbmVbcmVmUG9zICsgMV0sIGJsYWNrUGl4ZWxzKTsKICAgICAgICAgICAgICBpZiAocmVmTGluZVtyZWZQb3MgKyAxXSA8IGNvbHVtbnMpIHsKICAgICAgICAgICAgICAgIHJlZlBvcyArPSAyOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSB0d29EaW1Ib3JpejoKICAgICAgICAgICAgICBjb2RlMSA9IGNvZGUyID0gMDsKICAgICAgICAgICAgICBpZiAoYmxhY2tQaXhlbHMpIHsKICAgICAgICAgICAgICAgIGRvIHsKICAgICAgICAgICAgICAgICAgY29kZTEgKz0gY29kZTMgPSB0aGlzLl9nZXRCbGFja0NvZGUoKTsKICAgICAgICAgICAgICAgIH0gd2hpbGUgKGNvZGUzID49IDY0KTsKICAgICAgICAgICAgICAgIGRvIHsKICAgICAgICAgICAgICAgICAgY29kZTIgKz0gY29kZTMgPSB0aGlzLl9nZXRXaGl0ZUNvZGUoKTsKICAgICAgICAgICAgICAgIH0gd2hpbGUgKGNvZGUzID49IDY0KTsKICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgZG8gewogICAgICAgICAgICAgICAgICBjb2RlMSArPSBjb2RlMyA9IHRoaXMuX2dldFdoaXRlQ29kZSgpOwogICAgICAgICAgICAgICAgfSB3aGlsZSAoY29kZTMgPj0gNjQpOwogICAgICAgICAgICAgICAgZG8gewogICAgICAgICAgICAgICAgICBjb2RlMiArPSBjb2RlMyA9IHRoaXMuX2dldEJsYWNrQ29kZSgpOwogICAgICAgICAgICAgICAgfSB3aGlsZSAoY29kZTMgPj0gNjQpOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICB0aGlzLl9hZGRQaXhlbHMoY29kaW5nTGluZVt0aGlzLmNvZGluZ1Bvc10gKyBjb2RlMSwgYmxhY2tQaXhlbHMpOwogICAgICAgICAgICAgIGlmIChjb2RpbmdMaW5lW3RoaXMuY29kaW5nUG9zXSA8IGNvbHVtbnMpIHsKICAgICAgICAgICAgICAgIHRoaXMuX2FkZFBpeGVscyhjb2RpbmdMaW5lW3RoaXMuY29kaW5nUG9zXSArIGNvZGUyLCBibGFja1BpeGVscyBeIDEpOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICB3aGlsZSAocmVmTGluZVtyZWZQb3NdIDw9IGNvZGluZ0xpbmVbdGhpcy5jb2RpbmdQb3NdICYmIHJlZkxpbmVbcmVmUG9zXSA8IGNvbHVtbnMpIHsKICAgICAgICAgICAgICAgIHJlZlBvcyArPSAyOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSB0d29EaW1WZXJ0UjM6CiAgICAgICAgICAgICAgdGhpcy5fYWRkUGl4ZWxzKHJlZkxpbmVbcmVmUG9zXSArIDMsIGJsYWNrUGl4ZWxzKTsKICAgICAgICAgICAgICBibGFja1BpeGVscyBePSAxOwogICAgICAgICAgICAgIGlmIChjb2RpbmdMaW5lW3RoaXMuY29kaW5nUG9zXSA8IGNvbHVtbnMpIHsKICAgICAgICAgICAgICAgICsrcmVmUG9zOwogICAgICAgICAgICAgICAgd2hpbGUgKHJlZkxpbmVbcmVmUG9zXSA8PSBjb2RpbmdMaW5lW3RoaXMuY29kaW5nUG9zXSAmJiByZWZMaW5lW3JlZlBvc10gPCBjb2x1bW5zKSB7CiAgICAgICAgICAgICAgICAgIHJlZlBvcyArPSAyOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSB0d29EaW1WZXJ0UjI6CiAgICAgICAgICAgICAgdGhpcy5fYWRkUGl4ZWxzKHJlZkxpbmVbcmVmUG9zXSArIDIsIGJsYWNrUGl4ZWxzKTsKICAgICAgICAgICAgICBibGFja1BpeGVscyBePSAxOwogICAgICAgICAgICAgIGlmIChjb2RpbmdMaW5lW3RoaXMuY29kaW5nUG9zXSA8IGNvbHVtbnMpIHsKICAgICAgICAgICAgICAgICsrcmVmUG9zOwogICAgICAgICAgICAgICAgd2hpbGUgKHJlZkxpbmVbcmVmUG9zXSA8PSBjb2RpbmdMaW5lW3RoaXMuY29kaW5nUG9zXSAmJiByZWZMaW5lW3JlZlBvc10gPCBjb2x1bW5zKSB7CiAgICAgICAgICAgICAgICAgIHJlZlBvcyArPSAyOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSB0d29EaW1WZXJ0UjE6CiAgICAgICAgICAgICAgdGhpcy5fYWRkUGl4ZWxzKHJlZkxpbmVbcmVmUG9zXSArIDEsIGJsYWNrUGl4ZWxzKTsKICAgICAgICAgICAgICBibGFja1BpeGVscyBePSAxOwogICAgICAgICAgICAgIGlmIChjb2RpbmdMaW5lW3RoaXMuY29kaW5nUG9zXSA8IGNvbHVtbnMpIHsKICAgICAgICAgICAgICAgICsrcmVmUG9zOwogICAgICAgICAgICAgICAgd2hpbGUgKHJlZkxpbmVbcmVmUG9zXSA8PSBjb2RpbmdMaW5lW3RoaXMuY29kaW5nUG9zXSAmJiByZWZMaW5lW3JlZlBvc10gPCBjb2x1bW5zKSB7CiAgICAgICAgICAgICAgICAgIHJlZlBvcyArPSAyOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSB0d29EaW1WZXJ0MDoKICAgICAgICAgICAgICB0aGlzLl9hZGRQaXhlbHMocmVmTGluZVtyZWZQb3NdLCBibGFja1BpeGVscyk7CiAgICAgICAgICAgICAgYmxhY2tQaXhlbHMgXj0gMTsKICAgICAgICAgICAgICBpZiAoY29kaW5nTGluZVt0aGlzLmNvZGluZ1Bvc10gPCBjb2x1bW5zKSB7CiAgICAgICAgICAgICAgICArK3JlZlBvczsKICAgICAgICAgICAgICAgIHdoaWxlIChyZWZMaW5lW3JlZlBvc10gPD0gY29kaW5nTGluZVt0aGlzLmNvZGluZ1Bvc10gJiYgcmVmTGluZVtyZWZQb3NdIDwgY29sdW1ucykgewogICAgICAgICAgICAgICAgICByZWZQb3MgKz0gMjsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIGNhc2UgdHdvRGltVmVydEwzOgogICAgICAgICAgICAgIHRoaXMuX2FkZFBpeGVsc05lZyhyZWZMaW5lW3JlZlBvc10gLSAzLCBibGFja1BpeGVscyk7CiAgICAgICAgICAgICAgYmxhY2tQaXhlbHMgXj0gMTsKICAgICAgICAgICAgICBpZiAoY29kaW5nTGluZVt0aGlzLmNvZGluZ1Bvc10gPCBjb2x1bW5zKSB7CiAgICAgICAgICAgICAgICBpZiAocmVmUG9zID4gMCkgewogICAgICAgICAgICAgICAgICAtLXJlZlBvczsKICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICsrcmVmUG9zOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgd2hpbGUgKHJlZkxpbmVbcmVmUG9zXSA8PSBjb2RpbmdMaW5lW3RoaXMuY29kaW5nUG9zXSAmJiByZWZMaW5lW3JlZlBvc10gPCBjb2x1bW5zKSB7CiAgICAgICAgICAgICAgICAgIHJlZlBvcyArPSAyOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSB0d29EaW1WZXJ0TDI6CiAgICAgICAgICAgICAgdGhpcy5fYWRkUGl4ZWxzTmVnKHJlZkxpbmVbcmVmUG9zXSAtIDIsIGJsYWNrUGl4ZWxzKTsKICAgICAgICAgICAgICBibGFja1BpeGVscyBePSAxOwogICAgICAgICAgICAgIGlmIChjb2RpbmdMaW5lW3RoaXMuY29kaW5nUG9zXSA8IGNvbHVtbnMpIHsKICAgICAgICAgICAgICAgIGlmIChyZWZQb3MgPiAwKSB7CiAgICAgICAgICAgICAgICAgIC0tcmVmUG9zOwogICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgKytyZWZQb3M7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB3aGlsZSAocmVmTGluZVtyZWZQb3NdIDw9IGNvZGluZ0xpbmVbdGhpcy5jb2RpbmdQb3NdICYmIHJlZkxpbmVbcmVmUG9zXSA8IGNvbHVtbnMpIHsKICAgICAgICAgICAgICAgICAgcmVmUG9zICs9IDI7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICBjYXNlIHR3b0RpbVZlcnRMMToKICAgICAgICAgICAgICB0aGlzLl9hZGRQaXhlbHNOZWcocmVmTGluZVtyZWZQb3NdIC0gMSwgYmxhY2tQaXhlbHMpOwogICAgICAgICAgICAgIGJsYWNrUGl4ZWxzIF49IDE7CiAgICAgICAgICAgICAgaWYgKGNvZGluZ0xpbmVbdGhpcy5jb2RpbmdQb3NdIDwgY29sdW1ucykgewogICAgICAgICAgICAgICAgaWYgKHJlZlBvcyA+IDApIHsKICAgICAgICAgICAgICAgICAgLS1yZWZQb3M7CiAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICArK3JlZlBvczsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIHdoaWxlIChyZWZMaW5lW3JlZlBvc10gPD0gY29kaW5nTGluZVt0aGlzLmNvZGluZ1Bvc10gJiYgcmVmTGluZVtyZWZQb3NdIDwgY29sdW1ucykgewogICAgICAgICAgICAgICAgICByZWZQb3MgKz0gMjsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIGNhc2UgY2NpdHRFT0Y6CiAgICAgICAgICAgICAgdGhpcy5fYWRkUGl4ZWxzKGNvbHVtbnMsIDApOwogICAgICAgICAgICAgIHRoaXMuZW9mID0gdHJ1ZTsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICAoMCwgX3V0aWwuaW5mbykoImJhZCAyZCBjb2RlIik7CiAgICAgICAgICAgICAgdGhpcy5fYWRkUGl4ZWxzKGNvbHVtbnMsIDApOwogICAgICAgICAgICAgIHRoaXMuZXJyID0gdHJ1ZTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0gZWxzZSB7CiAgICAgICAgY29kaW5nTGluZVswXSA9IDA7CiAgICAgICAgdGhpcy5jb2RpbmdQb3MgPSAwOwogICAgICAgIGJsYWNrUGl4ZWxzID0gMDsKICAgICAgICB3aGlsZSAoY29kaW5nTGluZVt0aGlzLmNvZGluZ1Bvc10gPCBjb2x1bW5zKSB7CiAgICAgICAgICBjb2RlMSA9IDA7CiAgICAgICAgICBpZiAoYmxhY2tQaXhlbHMpIHsKICAgICAgICAgICAgZG8gewogICAgICAgICAgICAgIGNvZGUxICs9IGNvZGUzID0gdGhpcy5fZ2V0QmxhY2tDb2RlKCk7CiAgICAgICAgICAgIH0gd2hpbGUgKGNvZGUzID49IDY0KTsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIGRvIHsKICAgICAgICAgICAgICBjb2RlMSArPSBjb2RlMyA9IHRoaXMuX2dldFdoaXRlQ29kZSgpOwogICAgICAgICAgICB9IHdoaWxlIChjb2RlMyA+PSA2NCk7CiAgICAgICAgICB9CiAgICAgICAgICB0aGlzLl9hZGRQaXhlbHMoY29kaW5nTGluZVt0aGlzLmNvZGluZ1Bvc10gKyBjb2RlMSwgYmxhY2tQaXhlbHMpOwogICAgICAgICAgYmxhY2tQaXhlbHMgXj0gMTsKICAgICAgICB9CiAgICAgIH0KICAgICAgbGV0IGdvdEVPTCA9IGZhbHNlOwogICAgICBpZiAodGhpcy5ieXRlQWxpZ24pIHsKICAgICAgICB0aGlzLmlucHV0Qml0cyAmPSB+NzsKICAgICAgfQogICAgICBpZiAoIXRoaXMuZW9ibG9jayAmJiB0aGlzLnJvdyA9PT0gdGhpcy5yb3dzIC0gMSkgewogICAgICAgIHRoaXMucm93c0RvbmUgPSB0cnVlOwogICAgICB9IGVsc2UgewogICAgICAgIGNvZGUxID0gdGhpcy5fbG9va0JpdHMoMTIpOwogICAgICAgIGlmICh0aGlzLmVvbGluZSkgewogICAgICAgICAgd2hpbGUgKGNvZGUxICE9PSBjY2l0dEVPRiAmJiBjb2RlMSAhPT0gMSkgewogICAgICAgICAgICB0aGlzLl9lYXRCaXRzKDEpOwogICAgICAgICAgICBjb2RlMSA9IHRoaXMuX2xvb2tCaXRzKDEyKTsKICAgICAgICAgIH0KICAgICAgICB9IGVsc2UgewogICAgICAgICAgd2hpbGUgKGNvZGUxID09PSAwKSB7CiAgICAgICAgICAgIHRoaXMuX2VhdEJpdHMoMSk7CiAgICAgICAgICAgIGNvZGUxID0gdGhpcy5fbG9va0JpdHMoMTIpOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZiAoY29kZTEgPT09IDEpIHsKICAgICAgICAgIHRoaXMuX2VhdEJpdHMoMTIpOwogICAgICAgICAgZ290RU9MID0gdHJ1ZTsKICAgICAgICB9IGVsc2UgaWYgKGNvZGUxID09PSBjY2l0dEVPRikgewogICAgICAgICAgdGhpcy5lb2YgPSB0cnVlOwogICAgICAgIH0KICAgICAgfQogICAgICBpZiAoIXRoaXMuZW9mICYmIHRoaXMuZW5jb2RpbmcgPiAwICYmICF0aGlzLnJvd3NEb25lKSB7CiAgICAgICAgdGhpcy5uZXh0TGluZTJEID0gIXRoaXMuX2xvb2tCaXRzKDEpOwogICAgICAgIHRoaXMuX2VhdEJpdHMoMSk7CiAgICAgIH0KICAgICAgaWYgKHRoaXMuZW9ibG9jayAmJiBnb3RFT0wgJiYgdGhpcy5ieXRlQWxpZ24pIHsKICAgICAgICBjb2RlMSA9IHRoaXMuX2xvb2tCaXRzKDEyKTsKICAgICAgICBpZiAoY29kZTEgPT09IDEpIHsKICAgICAgICAgIHRoaXMuX2VhdEJpdHMoMTIpOwogICAgICAgICAgaWYgKHRoaXMuZW5jb2RpbmcgPiAwKSB7CiAgICAgICAgICAgIHRoaXMuX2xvb2tCaXRzKDEpOwogICAgICAgICAgICB0aGlzLl9lYXRCaXRzKDEpOwogICAgICAgICAgfQogICAgICAgICAgaWYgKHRoaXMuZW5jb2RpbmcgPj0gMCkgewogICAgICAgICAgICBmb3IgKGkgPSAwOyBpIDwgNDsgKytpKSB7CiAgICAgICAgICAgICAgY29kZTEgPSB0aGlzLl9sb29rQml0cygxMik7CiAgICAgICAgICAgICAgaWYgKGNvZGUxICE9PSAxKSB7CiAgICAgICAgICAgICAgICAoMCwgX3V0aWwuaW5mbykoImJhZCBydGMgY29kZTogIiArIGNvZGUxKTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgdGhpcy5fZWF0Qml0cygxMik7CiAgICAgICAgICAgICAgaWYgKHRoaXMuZW5jb2RpbmcgPiAwKSB7CiAgICAgICAgICAgICAgICB0aGlzLl9sb29rQml0cygxKTsKICAgICAgICAgICAgICAgIHRoaXMuX2VhdEJpdHMoMSk7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICB0aGlzLmVvZiA9IHRydWU7CiAgICAgICAgfQogICAgICB9IGVsc2UgaWYgKHRoaXMuZXJyICYmIHRoaXMuZW9saW5lKSB7CiAgICAgICAgd2hpbGUgKHRydWUpIHsKICAgICAgICAgIGNvZGUxID0gdGhpcy5fbG9va0JpdHMoMTMpOwogICAgICAgICAgaWYgKGNvZGUxID09PSBjY2l0dEVPRikgewogICAgICAgICAgICB0aGlzLmVvZiA9IHRydWU7CiAgICAgICAgICAgIHJldHVybiAtMTsKICAgICAgICAgIH0KICAgICAgICAgIGlmIChjb2RlMSA+PiAxID09PSAxKSB7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgfQogICAgICAgICAgdGhpcy5fZWF0Qml0cygxKTsKICAgICAgICB9CiAgICAgICAgdGhpcy5fZWF0Qml0cygxMik7CiAgICAgICAgaWYgKHRoaXMuZW5jb2RpbmcgPiAwKSB7CiAgICAgICAgICB0aGlzLl9lYXRCaXRzKDEpOwogICAgICAgICAgdGhpcy5uZXh0TGluZTJEID0gIShjb2RlMSAmIDEpOwogICAgICAgIH0KICAgICAgfQogICAgICBpZiAoY29kaW5nTGluZVswXSA+IDApIHsKICAgICAgICB0aGlzLm91dHB1dEJpdHMgPSBjb2RpbmdMaW5lW3RoaXMuY29kaW5nUG9zID0gMF07CiAgICAgIH0gZWxzZSB7CiAgICAgICAgdGhpcy5vdXRwdXRCaXRzID0gY29kaW5nTGluZVt0aGlzLmNvZGluZ1BvcyA9IDFdOwogICAgICB9CiAgICAgIHRoaXMucm93Kys7CiAgICB9CiAgICBsZXQgYzsKICAgIGlmICh0aGlzLm91dHB1dEJpdHMgPj0gOCkgewogICAgICBjID0gdGhpcy5jb2RpbmdQb3MgJiAxID8gMCA6IDB4ZmY7CiAgICAgIHRoaXMub3V0cHV0Qml0cyAtPSA4OwogICAgICBpZiAodGhpcy5vdXRwdXRCaXRzID09PSAwICYmIGNvZGluZ0xpbmVbdGhpcy5jb2RpbmdQb3NdIDwgY29sdW1ucykgewogICAgICAgIHRoaXMuY29kaW5nUG9zKys7CiAgICAgICAgdGhpcy5vdXRwdXRCaXRzID0gY29kaW5nTGluZVt0aGlzLmNvZGluZ1Bvc10gLSBjb2RpbmdMaW5lW3RoaXMuY29kaW5nUG9zIC0gMV07CiAgICAgIH0KICAgIH0gZWxzZSB7CiAgICAgIGJpdHMgPSA4OwogICAgICBjID0gMDsKICAgICAgZG8gewogICAgICAgIGlmICh0eXBlb2YgdGhpcy5vdXRwdXRCaXRzICE9PSAibnVtYmVyIikgewogICAgICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKCdJbnZhbGlkIC9DQ0lUVEZheERlY29kZSBkYXRhLCAib3V0cHV0Qml0cyIgbXVzdCBiZSBhIG51bWJlci4nKTsKICAgICAgICB9CiAgICAgICAgaWYgKHRoaXMub3V0cHV0Qml0cyA+IGJpdHMpIHsKICAgICAgICAgIGMgPDw9IGJpdHM7CiAgICAgICAgICBpZiAoISh0aGlzLmNvZGluZ1BvcyAmIDEpKSB7CiAgICAgICAgICAgIGMgfD0gMHhmZiA+PiA4IC0gYml0czsKICAgICAgICAgIH0KICAgICAgICAgIHRoaXMub3V0cHV0Qml0cyAtPSBiaXRzOwogICAgICAgICAgYml0cyA9IDA7CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIGMgPDw9IHRoaXMub3V0cHV0Qml0czsKICAgICAgICAgIGlmICghKHRoaXMuY29kaW5nUG9zICYgMSkpIHsKICAgICAgICAgICAgYyB8PSAweGZmID4+IDggLSB0aGlzLm91dHB1dEJpdHM7CiAgICAgICAgICB9CiAgICAgICAgICBiaXRzIC09IHRoaXMub3V0cHV0Qml0czsKICAgICAgICAgIHRoaXMub3V0cHV0Qml0cyA9IDA7CiAgICAgICAgICBpZiAoY29kaW5nTGluZVt0aGlzLmNvZGluZ1Bvc10gPCBjb2x1bW5zKSB7CiAgICAgICAgICAg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lID09PSBjY2l0dEVPRikgewogICAgICAgIHJldHVybiAxOwogICAgICB9CiAgICAgIGlmIChjb2RlID4+IDUgPT09IDApIHsKICAgICAgICBwID0gd2hpdGVUYWJsZTFbY29kZV07CiAgICAgIH0gZWxzZSB7CiAgICAgICAgcCA9IHdoaXRlVGFibGUyW2NvZGUgPj4gM107CiAgICAgIH0KICAgICAgaWYgKHBbMF0gPiAwKSB7CiAgICAgICAgdGhpcy5fZWF0Qml0cyhwWzBdKTsKICAgICAgICByZXR1cm4gcFsxXTsKICAgICAgfQogICAgfSBlbHNlIHsKICAgICAgbGV0IHJlc3VsdCA9IHRoaXMuX2ZpbmRUYWJsZUNvZGUoMSwgOSwgd2hpdGVUYWJsZTIpOwogICAgICBpZiAocmVzdWx0WzBdKSB7CiAgICAgICAgcmV0dXJuIHJlc3VsdFsxXTsKICAgICAgfQogICAgICByZXN1bHQgPSB0aGlzLl9maW5kVGFibGVDb2RlKDExLCAxMiwgd2hpdGVUYWJsZTEpOwogICAgICBpZiAocmVzdWx0WzBdKSB7CiAgICAgICAgcmV0dXJuIHJlc3VsdFsxXTsKICAgICAgfQogICAgfQogICAgKDAsIF91dGlsLmluZm8pKCJiYWQgd2hpdGUgY29kZSIpOwogICAgdGhpcy5fZWF0Qml0cygxKTsKICAgIHJldHVybiAxOwogIH0KICBfZ2V0QmxhY2tDb2RlKCkgewogICAgbGV0IGNvZGUsIHA7CiAgICBpZiAodGhpcy5lb2Jsb2NrKSB7CiAgICAgIGNvZGUgPSB0aGlzLl9sb29rQml0cygxMyk7CiAgICAgIGlmIChjb2RlID09PSBjY2l0dEVPRikgewogICAgICAgIHJldHVybiAxOwogICAgICB9CiAgICAgIGlmIChjb2RlID4+IDcgPT09IDApIHsKICAgICAgICBwID0gYmxhY2tUYWJsZTFbY29kZV07CiAgICAgIH0gZWxzZSBpZiAoY29kZSA+PiA5ID09PSAwICYmIGNvZGUgPj4gNyAhPT0gMCkgewogICAgICAgIHAgPSBibGFja1RhYmxlMlsoY29kZSA+PiAxKSAtIDY0XTsKICAgICAgfSBlbHNlIHsKICAgICAgICBwID0gYmxhY2tUYWJsZTNbY29kZSA+PiA3XTsKICAgICAgfQogICAgICBpZiAocFswXSA+IDApIHsKICAgICAgICB0aGlzLl9lYXRCaXRzKHBbMF0pOwogICAgICAgIHJldHVybiBwWzFdOwogICAgICB9CiAgICB9IGVsc2UgewogICAgICBsZXQgcmVzdWx0ID0gdGhpcy5fZmluZFRhYmxlQ29kZSgyLCA2LCBibGFja1RhYmxlMyk7CiAgICAgIGlmIChyZXN1bHRbMF0pIHsKICAgICAgICByZXR1cm4gcmVzdWx0WzFdOwogICAgICB9CiAgICAgIHJlc3VsdCA9IHRoaXMuX2ZpbmRUYWJsZUNvZGUoNywgMTIsIGJsYWNrVGFibGUyLCA2NCk7CiAgICAgIGlmIChyZXN1bHRbMF0pIHsKICAgICAgICByZXR1cm4gcmVzdWx0WzFdOwogICAgICB9CiAgICAgIHJlc3VsdCA9IHRoaXMuX2ZpbmRUYWJsZUNvZGUoMTAsIDEzLCBibGFja1RhYmxlMSk7CiAgICAgIGlmIChyZXN1bHRbMF0pIHsKICAgICAgICByZXR1cm4gcmVzdWx0WzFdOwogICAgICB9CiAgICB9CiAgICAoMCwgX3V0aWwuaW5mbykoImJhZCBibGFjayBjb2RlIik7CiAgICB0aGlzLl9lYXRCaXRzKDEpOwogICAgcmV0dXJuIDE7CiAgfQogIF9sb29rQml0cyhuKSB7CiAgICBsZXQgYzsKICAgIHdoaWxlICh0aGlzLmlucHV0Qml0cyA8IG4pIHsKICAgICAgaWYgKChjID0gdGhpcy5zb3VyY2UubmV4dCgpKSA9PT0gLTEpIHsKICAgICAgICBpZiAodGhpcy5pbnB1dEJpdHMgPT09IDApIHsKICAgICAgICAgIHJldHVybiBjY2l0dEVPRjsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIHRoaXMuaW5wdXRCdWYgPDwgbiAtIHRoaXMuaW5wdXRCaXRzICYgMHhmZmZmID4+IDE2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2RlMiA9IGNvZGUyIDw8IDEgfCB0ICYgMTsKICAgICAgICAgICAgdCA+Pj0gMTsKICAgICAgICAgIH0KICAgICAgICAgIGZvciAoaSA9IGNvZGUyOyBpIDwgc2l6ZTsgaSArPSBza2lwKSB7CiAgICAgICAgICAgIGNvZGVzW2ldID0gbGVuIDw8IDE2IHwgdmFsOwogICAgICAgICAgfQogICAgICAgICAgKytjb2RlOwogICAgICAgIH0KICAgICAgfQogICAgfQogICAgcmV0dXJuIFtjb2RlcywgbWF4TGVuXTsKICB9CiAgcmVhZEJsb2NrKCkgewogICAgbGV0IGJ1ZmZlciwgbGVuOwogICAgY29uc3Qgc3RyID0gdGhpcy5zdHI7CiAgICBsZXQgaGRyID0gdGhpcy5nZXRCaXRzKDMpOwogICAgaWYgKGhkciAmIDEpIHsKICAgICAgdGhpcy5lb2YgPSB0cnVlOwogICAgfQogICAgaGRyID4+PSAxOwogICAgaWYgKGhkciA9PT0gMCkgewogICAgICBsZXQgYjsKICAgICAgaWYgKChiID0gc3RyLmdldEJ5dGUoKSkgPT09IC0xKSB7CiAgICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKCJCYWQgYmxvY2sgaGVhZGVyIGluIGZsYXRlIHN0cmVhbSIpOwogICAgICB9CiAgICAgIGxldCBibG9ja0xlbiA9IGI7CiAgICAgIGlmICgoYiA9IHN0ci5nZXRCeXRlKCkpID09PSAtMSkgewogICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiQmFkIGJsb2NrIGhlYWRlciBpbiBmbGF0ZSBzdHJlYW0iKTsKICAgICAgfQogICAgICBibG9ja0xlbiB8PSBiIDw8IDg7CiAgICAgIGlmICgoYiA9IHN0ci5nZXRCeXRlKCkpID09PSAtMSkgewogICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiQmFkIGJsb2NrIGhlYWRlciBpbiBmbGF0ZSBzdHJlYW0iKTsKICAgICAgfQogICAgICBsZXQ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ENvZGUoY29kZUxlbkNvZGVUYWIpOwogICAgICAgIGlmIChjb2RlID09PSAxNikgewogICAgICAgICAgYml0c0xlbmd0aCA9IDI7CiAgICAgICAgICBiaXRzT2Zmc2V0ID0gMzsKICAgICAgICAgIHdoYXQgPSBsZW47CiAgICAgICAgfSBlbHNlIGlmIChjb2RlID09PSAxNykgewogICAgICAgICAgYml0c0xlbmd0aCA9IDM7CiAgICAgICAgICBiaXRzT2Zmc2V0ID0gMzsKICAgICAgICAgIHdoYXQgPSBsZW4gPSAwOwogICAgICAgIH0gZWxzZSBpZiAoY29kZSA9PT0gMTgpIHsKICAgICAgICAgIGJpdHNMZW5ndGggPSA3OwogICAgICAgICAgYml0c09mZnNldCA9IDExOwogICAgICAgICAgd2hhdCA9IGxlbiA9IDA7CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIGNvZGVMZW5ndGhzW2krK10gPSBsZW4gPSBjb2RlOwogICAgICAgICAgY29udGludWU7CiAgICAgICAgfQogICAgICAgIGxldCByZXBlYXRMZW5ndGggPSB0aGlzLmdldEJpdHMoYml0c0xlbmd0aCkgKyBiaXRzT2Zmc2V0OwogICAgICAgIHdoaWxlIChyZXBlYXRMZW5ndGgtLSA+IDApIHsKICAgICAgICAgIGNvZGVMZW5ndGhzW2krK10gPSB3aGF0OwogICAgICAgIH0KICAgICAgfQogICAgICBsaXRDb2RlVGFibGUgPSB0aGlzLmdlbmVyYXRlSHVmZm1hblRhYmxlKGNvZGVMZW5ndGhzLnN1YmFycmF5KDAsIG51bUxpdENvZGVzKSk7CiAgICAgIGRpc3RDb2RlVGFibGUgPSB0aGlzLmdlbmVyYXRlSHVmZm1hblRhYmxlKGNvZGVMZW5ndGhzLnN1YmFycmF5KG51bUxpdENvZGVzLCBjb2RlcykpOwogICAgfSBlbHNlIHsKICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKCJVbmtub3duIGJsb2NrIHR5cGUgaW4gZmxhdGUgc3RyZWFtIik7CiAgICB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OiAtMiwKICB5OiAwCn0sIHsKICB4OiAtMSwKICB5OiAwCn1dLCBbewogIHg6IC0zLAogIHk6IC0xCn0sIHsKICB4OiAtMiwKICB5OiAtMQp9LCB7CiAgeDogLTEsCiAgeTogLTEKfSwgewogIHg6IDAsCiAgeTogLTEKfSwgewogIHg6IDEsCiAgeTogLTEKfSwgewogIHg6IC00LAogIHk6IDAKfSwgewogIHg6IC0zLAogIHk6IDAKfSwgewogIHg6IC0yLAogIHk6IDAKfSwgewogIHg6IC0xLAogIHk6IDAKfV1dOwpjb25zdCBSZWZpbmVtZW50VGVtcGxhdGVzID0gW3sKICBjb2Rpbmc6IFt7CiAgICB4OiAwLAogICAgeTogLTEKICB9LCB7CiAgICB4OiAxLAogICAgeTogLTEKICB9LCB7CiAgICB4OiAtMSwKICAgIHk6IDAKICB9XSwKICByZWZlcmVuY2U6IFt7CiAgICB4OiAwLAogICAgeTogLTEKICB9LCB7CiAgICB4OiAxLAogICAgeTogLTEKICB9LCB7CiAgICB4OiAtMSwKICAgIHk6IDAKICB9LCB7CiAgICB4OiAwLAogICAgeTogMAogIH0sIHsKICAgIHg6IDEsCiAgICB5OiAwCiAgfSwgewogICAgeDogLTEsCiAgICB5OiAxCiAgfSwgewogICAgeDogMCwKICAgIHk6IDEKICB9LCB7CiAgICB4OiAxLAogICAgeTogMQogIH1dCn0sIHsKICBjb2Rpbmc6IFt7CiAgICB4OiAtMSwKICAgIHk6IC0xCiAgfSwgewogICAgeDogMCwKICAgIHk6IC0xCiAgfSwgewogICAgeDogMSwKICAgIHk6IC0xCiAgfSwgewogICAgeDogLTEsCiAgICB5OiAwCiAgfV0sCiAgcmVmZXJlbmNlOiBbewogICAgeDogMCwKICAgIHk6IC0xCiAgfSwgewogICAgeDogLTEsCiAgICB5OiAwCiAgfSwgewogICAgeDogMCwKICAgIHk6IDAKICB9LCB7CiAgICB4OiAxLAogICAgeTogMAogIH0sIHsKICAgIHg6IDAsCiAgICB5OiAxCiAgfSwgewogICAgeD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ogICAgc2hpZnQ7CiAgZm9yIChsZXQgaSA9IDA7IGkgPCBoZWlnaHQ7IGkrKykgewogICAgaWYgKHByZWRpY3Rpb24pIHsKICAgICAgY29uc3Qgc2x0cCA9IGRlY29kZXIucmVhZEJpdChjb250ZXh0cywgcHNldWRvUGl4ZWxDb250ZXh0KTsKICAgICAgbHRwIF49IHNsdHA7CiAgICAgIGlmIChsdHApIHsKICAgICAgICBiaXRtYXAucHVzaChyb3cpOwogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICB9CiAgICByb3cgPSBuZXcgVWludDhBcnJheShyb3cpOwogICAgYml0bWFwLnB1c2gocm93KTsKICAgIGZvciAoaiA9IDA7IGogPCB3aWR0aDsgaisrKSB7CiAgICAgIGlmICh1c2Vza2lwICYmIHNraXBbaV1bal0pIHsKICAgICAgICByb3dbal0gPSAwOwogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGlmIChqID49IHNiYl9sZWZ0ICYmIGogPCBzYmJfcmlnaHQgJiYgaSA+PSBzYmJfdG9wKSB7CiAgICAgICAgY29udGV4dExhYmVsID0gY29udGV4dExhYmVsIDw8IDEgJiByZXVzZU1hc2s7CiAgICAgICAgZm9yIChrID0gMDsgayA8IGNoYW5naW5nRW50cmllc0xlbmd0aDsgaysrKSB7CiAgICAgICAgICBpMCA9IGkgKyBjaGFuZ2luZ1RlbXBsYXRlWVtrXTsKICAgICAgICAgIGowID0gaiArIGNoYW5naW5nVGVtcGxhdGVYW2tdOwogICAgICAgICAgYml0ID0gYml0bWFwW2kwXVtqMF07CiAgICAgICAgICBpZiAoYml0KSB7CiAgICAgICAgICAgIGJpdCA9IGNoYW5naW5nVGVtcGxhdGVCaXRba107CiAgICAgICAgICAgIGNvbnRleHRMYWJlbCB8PSBiaXQ7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9IGVsc2UgewogICAgICAgIGNvbnRleHRMYWJlbCA9IDA7CiAgICAgICAgc2hpZnQgPSB0ZW1wbGF0ZUx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ib2xIZWlnaHQsIHJlZmluZW1lbnRUZW1wbGF0ZUluZGV4LCBzeW1ib2xCaXRtYXAsIChyZHcgPj4gMSkgKyByZHgsIChyZGggPj4gMSkgKyByZHksIGZhbHNlLCByZWZpbmVtZW50QXQsIGRlY29kaW5nQ29udGV4dCk7CiAgICAgIH0KICAgICAgY29uc3Qgb2Zmc2V0VCA9IHQgLSAocmVmZXJlbmNlQ29ybmVyICYgMSA/IDAgOiBzeW1ib2xIZWlnaHQgLSAxKTsKICAgICAgY29uc3Qgb2Zmc2V0UyA9IGN1cnJlbnRTIC0gKHJlZmVyZW5jZUNvcm5lciAmIDIgPyBzeW1ib2xXaWR0aCAtIDEgOiAwKTsKICAgICAgbGV0IHMyLCB0Miwgc3ltYm9sUm93OwogICAgICBpZiAodHJhbnNwb3NlZCkgewogICAgICAgIGZvciAoczIgPSAwOyBzMiA8IHN5bWJvbEhlaWdodDsgczIrKykgewogICAgICAgICAgcm93ID0gYml0bWFwW29mZnNldFMgKyBzMl07CiAgICAgICAgICBpZiAoIXJvdykgewogICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgIH0KICAgICAgICAgIHN5bWJvbFJvdyA9IHN5bWJvbEJpdG1hcFtzMl07CiAgICAgICAgICBjb25zdCBtYXhXaWR0aCA9IE1hdGgubWluKHdpZHRoIC0gb2Zmc2V0VCwgc3ltYm9sV2lkdGgpOwogICAgICAgICAgc3dpdGNoIChjb21iaW5hdGlvbk9wZXJhdG9yKSB7CiAgICAgICAgICAgIGNhc2UgMDoKICAgICAgICAgICAgICBmb3IgKHQyID0gMDsgdDIgPCBtYXhXaWR0aDsgdDIrKykgewogICAgICAgICAgICAgICAgcm93W29mZnNldFQgKyB0Ml0gfD0gc3ltYm9sUm93W3QyXTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIGNhc2UgMjoKICAgICAgICAgICAgICBmb3IgKHQyID0gMDsgdDIgPCBtYXhXaWR0aDsgdDIrKykgewogICAgICAgICAgICAgICAgcm93W29mZnNldFQgKyB0Ml0gXj0gc3ltYm9sUm93W3QyXTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgICAgdGhyb3cgbmV3IEpiaWcyRXJyb3IoYG9wZXJhdG9yICR7Y29tYmluYXRpb25PcGVyYXRvcn0gaXMgbm90IHN1cHBvcnRlZGApOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBjdXJyZW50UyArPSBzeW1ib2xIZWlnaHQgLSAxOwogICAgICB9IGVsc2UgewogICAgICAgIGZvciAodDIgPSAwOyB0MiA8IHN5bWJvbEhlaWdodDsgdDIrKykgewogICAgICAgICAgcm93ID0gYml0bWFwW29mZnNldFQgKyB0Ml07CiAgICAgICAgICBpZiAoIXJvdykgewogICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgIH0KICAgICAgICAgIHN5bWJvbFJvdyA9IHN5bWJvbEJpdG1hcFt0Ml07CiAgICAgICAgICBzd2l0Y2ggKGNvbWJpbmF0aW9uT3BlcmF0b3IpIHsKICAgICAgICAgICAgY2FzZSAwOgogICAgICAgICAgICAgIGZvciAoczIgPSAwOyBzMiA8IHN5bWJvbFdpZHRoOyBzMisrKSB7CiAgICAgICAgICAgICAgICByb3dbb2Zmc2V0UyArIHMyXSB8PSBzeW1ib2xSb3dbczJdOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSAyOgogICAgICAgICAgICAgIGZvciAoczIgPSAwOyBzMiA8IHN5bWJvbFdpZHRoOyBzMisrKSB7CiAgICAgICAgICAgICAgICByb3dbb2Zmc2V0UyArIHMyXSBePSBzeW1ib2xSb3dbczJdOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICB0aHJvdyBuZXcgSmJpZzJFcnJvcihgb3BlcmF0b3IgJHtjb21iaW5hdGlvbk9wZXJhdG9yfSBpcyBub3Qgc3VwcG9ydGVkYCk7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGN1cnJlbnRTICs9IHN5bWJvbFdpZHRoIC0gMTsKICAgICAgfQogICAgICBpKys7CiAgICAgIGNvbnN0IGRlbHRhUyA9IGh1ZmZtYW4gPyBodWZmbWFuVGFibGVzLnRhYmxlRGVsdGFTLmRlY29kZShodWZmbWFuSW5wdXQpIDogZGVjb2RlSW50ZWdlcihjb250ZXh0Q2FjaGUsICJJQURTIiwgZGVjb2Rlcik7CiAgICAgIGlmIChkZWx0YVMgPT09IG51bGwpIHsKICAgICAgICBicmVhazsKICAgICAgfQogICAgICBjdXJyZW50UyArPSBkZWx0YVMgKyBkc09mZnNldDsKICAgIH0gd2hpbGUgKHRydWUpOwogIH0KICByZXR1cm4gYml0bWFwOwp9CmZ1bmN0aW9uIGRlY29kZVBhdHRlcm5EaWN0aW9uYXJ5KG1tciwgcGF0dGVybldpZHRoLCBwYXR0ZXJuSGVpZ2h0LCBtYXhQYXR0ZXJuSW5kZXgsIHRlbXBsYXRlLCBkZWNvZGluZ0NvbnRleHQpIHsKICBjb25zdCBhdCA9IFtdOwogIGlmICghbW1yKSB7CiAgICBhdC5wdXNoKHsKICAgICAgeDogLXBhdHRlcm5XaWR0aCwKICAgICAgeTogMAogICAgfSk7CiAgICBpZiAodGVtcGxhdGUgPT09IDApIHsKICAgICAgYXQucHVzaCh7CiAgICAgICAgeDogLTMsCiAgICAgICAgeTogLTEKICAgICAgfSwgewogICAgICAgIHg6IDIsCiAgICAgICAgeTogLTIKICAgICAgfSwgewogICAgICAgIHg6IC0yLAogICAgICAgIHk6IC0yCiAgICAgIH0pOwogICAgfQogIH0KICBjb25zdCBjb2xsZWN0aXZlV2lkdGggPSAobWF4UGF0dGVybkluZGV4ICsgMSkgKiBwYXR0ZXJuV2lkdGg7CiAgY29uc3QgY29sbGVjdGl2ZUJpdG1hcCA9IGR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yBKYmlnMkVycm9yKGBvcGVyYXRvciAiJHtjb21iaW5hdGlvbk9wZXJhdG9yfSIgaXMgbm90IHN1cHBvcnRlZCBpbiBoYWxmdG9uZSByZWdpb25gKTsKICB9CiAgY29uc3QgcmVnaW9uQml0bWFwID0gW107CiAgbGV0IGksIGosIHJvdzsKICBmb3IgKGkgPSAwOyBpIDwgcmVnaW9uSGVpZ2h0OyBpKyspIHsKICAgIHJvdyA9IG5ldyBVaW50OEFycmF5KHJlZ2lvbldpZHRoKTsKICAgIGlmIChkZWZhdWx0UGl4ZWxWYWx1ZSkgewogICAgICBmb3IgKGogPSAwOyBqIDwgcmVnaW9uV2lkdGg7IGorKykgewogICAgICAgIHJvd1tqXSA9IGRlZmF1bHRQaXhlbFZhbHVlOwogICAgICB9CiAgICB9CiAgICByZWdpb25CaXRtYXAucHVzaChyb3cpOwogIH0KICBjb25zdCBudW1iZXJPZlBhdHRlcm5zID0gcGF0dGVybnMubGVuZ3RoOwogIGNvbnN0IHBhdHRlcm4wID0gcGF0dGVybnNbMF07CiAgY29uc3QgcGF0dGVybldpZHRoID0gcGF0dGVybjBbMF0ubGVuZ3RoLAogICAgcGF0dGVybkhlaWdodCA9IHBhdHRlcm4wLmxlbmd0aDsKICBjb25zdCBiaXRzUGVyVmFsdWUgPSAoMCwgX2NvcmVfdXRpbHMubG9nMikobnVtYmVyT2ZQYXR0ZXJucyk7CiAgY29uc3QgYXQgPSBbXTsKICBpZiAoIW1tcikgewogICAgYXQucHVzaCh7CiAgICAgIHg6IHRlbXBsYXRlIDw9IDEgPyAzIDogMiwKICAgICAgeTogLTEKICAgIH0pOwogICAgaWYgKHRlbXBsYXRlID09PSAwKSB7CiAgICAgIGF0LnB1c2goewogICAgICAgIHg6IC0zLAogICAgICAgIHk6IC0xCiAgICAgIH0sIHsKICAgICAgICB4OiAyLAogICAgICAgIHk6IC0yCiAgICAgIH0sIHsKICAgICAgICB4OiAtMiwKICAgICAgICB5OiAtMgogICAgICB9KTsKICAgI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ICs9IDI7CiAgICAgIGlmICghZGljdGlvbmFyeS5odWZmbWFuKSB7CiAgICAgICAgYXRMZW5ndGggPSBkaWN0aW9uYXJ5LnRlbXBsYXRlID09PSAwID8gNCA6IDE7CiAgICAgICAgYXQgPSBbXTsKICAgICAgICBmb3IgKGkgPSAwOyBpIDwgYXRMZW5ndGg7IGkrKykgewogICAgICAgICAgYXQucHVzaCh7CiAgICAgICAgICAgIHg6ICgwLCBfY29yZV91dGlscy5yZWFkSW50OCkoZGF0YSwgcG9zaXRpb24pLAogICAgICAgICAgICB5OiAoMCwgX2NvcmVfdXRpbHMucmVhZEludDgpKGRhdGEsIHBvc2l0aW9uICsgMSkKICAgICAgICAgIH0pOwogICAgICAgICAgcG9zaXRpb24gKz0gMjsKICAgICAgICB9CiAgICAgICAgZGljdGlvbmFyeS5hdCA9IGF0OwogICAgICB9CiAgICAgIGlmIChkaWN0aW9uYXJ5LnJlZmluZW1lbnQgJiYgIWRpY3Rpb25hcnkucmVmaW5lbWVudFRlbXBsYXRlKSB7CiAgICAgICAgYXQgPSBbXTsKICAgICAgICBmb3IgKGkgPSAwOyBpIDwgMjsgaSsrKSB7CiAgICAgICAgICBhdC5wdXNoKHsKICAgICAgICAgICAgeDogKDAsIF9jb3JlX3V0aWxzLnJlYWRJbnQ4KShkYXRhLCBwb3NpdGlvbiksCiAgICAgICAgICAgIHk6ICgwLCBfY29yZV91dGlscy5yZWFkSW50OCkoZGF0YSwgcG9zaXRpb24gKyAxKQogICAgICAgICAgfSk7CiAgICAgICAgICBwb3NpdGlvbiArPSAyOwogICAgICAgIH0KICAgICAgICBkaWN0aW9uYXJ5LnJlZmluZW1lbnRBdCA9IGF0OwogICAgICB9CiAgICAgIGRpY3Rpb25hcnkubnVtYmVyT2ZFeHBvcnRlZFN5bWJvbHMgPSAoMCwgX2NvcmVfdXRpbHMucmVhZFVpbnQzMikoZGF0YSwgcG9zaXRpb24pOwogICAgICBwb3NpdGlvbiArPSA0OwogICAgICBkaWN0aW9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uSW5mby5oZWlnaHQ7CiAgICBjb25zdCByb3dTaXplID0gcGFnZUluZm8ud2lkdGggKyA3ID4+IDM7CiAgICBjb25zdCBjb21iaW5hdGlvbk9wZXJhdG9yID0gcGFnZUluZm8uY29tYmluYXRpb25PcGVyYXRvck92ZXJyaWRlID8gcmVnaW9uSW5mby5jb21iaW5hdGlvbk9wZXJhdG9yIDogcGFnZUluZm8uY29tYmluYXRpb25PcGVyYXRvcjsKICAgIGNvbnN0IGJ1ZmZlciA9IHRoaXMuYnVmZmVyOwogICAgY29uc3QgbWFzazAgPSAxMjggPj4gKHJlZ2lvbkluZm8ueCAmIDcpOwogICAgbGV0IG9mZnNldDAgPSByZWdpb25JbmZvLnkgKiByb3dTaXplICsgKHJlZ2lvbkluZm8ueCA+PiAzKTsKICAgIGxldCBpLCBqLCBtYXNrLCBvZmZzZXQ7CiAgICBzd2l0Y2ggKGNvbWJpbmF0aW9uT3BlcmF0b3IpIHsKICAgICAgY2FzZSAwOgogICAgICAgIGZvciAoaSA9IDA7IGkgPCBoZWlnaHQ7IGkrKykgewogICAgICAgICAgbWFzayA9IG1hc2swOwogICAgICAgICAgb2Zmc2V0ID0gb2Zmc2V0MDsKICAgICAgICAgIGZvciAoaiA9IDA7IGogPCB3aWR0aDsgaisrKSB7CiAgICAgICAgICAgIGlmIChiaXRtYXBbaV1bal0pIHsKICAgICAgICAgICAgICBidWZmZXJbb2Zmc2V0XSB8PSBtYXNrOwogICAgICAgICAgICB9CiAgICAgICAgICAgIG1hc2sgPj49IDE7CiAgICAgICAgICAgIGlmICghbWFzaykgewogICAgICAgICAgICAgIG1hc2sgPSAxMjg7CiAgICAgICAgICAgICAgb2Zmc2V0Kys7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIG9mZnNldDAgKz0gcm93U2l6ZTsKICAgICAgICB9CiAgICAgICAgYnJlYWs7CiAgICAgIGNhc2UgMjoKICAgICAgICBmb3IgKGkgPSAwOyBpIDwgaGVpZ2h0OyBpKyspIHsKICAgICAgICAgIG1hc2sgPSBtYXNrMDsKICAgICAgICAgIG9mZnNldCA9IG9mZnNldDA7CiAgICAgICAgICBmb3IgKGogPSAwOyBqIDwgd2lkdGg7IGorKykgewogICAgICAgICAgICBpZiAoYml0bWFwW2ldW2pdKSB7CiAgICAgICAgICAgICAgYnVmZmVyW29mZnNldF0gXj0gbWFzazsKICAgICAgICAgICAgfQogICAgICAgICAgICBtYXNrID4+PSAxOwogICAgICAgICAgICBpZiAoIW1hc2spIHsKICAgICAgICAgICAgICBtYXNrID0gMTI4OwogICAgICAgICAgICAgIG9mZnNldCsrOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICBvZmZzZXQwICs9IHJvd1NpemU7CiAgICAgICAgfQogICAgICAgIGJyZWFrOwogICAgICBkZWZhdWx0OgogICAgICAgIHRocm93IG5ldyBKYmlnMkVycm9yKGBvcGVyYXRvciAke2NvbWJpbmF0aW9uT3BlcmF0b3J9IGlzIG5vdCBzdXBwb3J0ZWRgKTsKICAgIH0KICB9CiAgb25JbW1lZGlhdGVHZW5lcmljUmVnaW9uKHJlZ2lvbiwgZGF0YSwgc3RhcnQsIGVuZCkgewogICAgY29uc3QgcmVnaW9uSW5mbyA9IHJlZ2lvbi5pbmZvOwogICAgY29uc3QgZGVjb2RpbmdDb250ZXh0ID0gbmV3IERlY29kaW5nQ29udGV4dChkYXRhLCBzdGFydCwgZW5kKTsKICAgIGNvbnN0IGJpdG1hcCA9IGRlY29kZUJpdG1hcChyZWdpb24ubW1yLCByZWdpb25JbmZvLndpZHRoLCByZWdpb25JbmZvLmhlaWdodCwgcmVnaW9uLnRlbXBsYXRlLCByZWdpb24ucHJlZGljdGlvbiwgbnVsbCwgcmVnaW9uLmF0LCBkZWNvZGluZ0NvbnRleHQpOwogICAgdGhpcy5kcmF3Qml0bWFwKHJlZ2lvbkluZm8sIGJpdG1hcCk7CiAgfQogIG9uSW1tZWRpYXRlTG9zc2xlc3NHZW5lcmljUmVn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wgbnVtYmVyT2ZTeW1ib2xzOykgewogICAgY29uc3QgY29kZUxlbmd0aCA9IHJ1bkNvZGVzVGFibGUuZGVjb2RlKHJlYWRlcik7CiAgICBpZiAoY29kZUxlbmd0aCA+PSAzMikgewogICAgICBsZXQgcmVwZWF0ZWRMZW5ndGgsIG51bWJlck9mUmVwZWF0cywgajsKICAgICAgc3dpdGNoIChjb2RlTGVuZ3RoKSB7CiAgICAgICAgY2FzZSAzMjoKICAgICAgICAgIGlmIChpID09PSAwKSB7CiAgICAgICAgICAgIHRocm93IG5ldyBKYmlnMkVycm9yKCJubyBwcmV2aW91cyB2YWx1ZSBpbiBzeW1ib2wgSUQgdGFibGUiKTsKICAgICAgICAgIH0KICAgICAgICAgIG51bWJlck9mUmVwZWF0cyA9IHJlYWRlci5yZWFkQml0cygyKSArIDM7CiAgICAgICAgICByZXBlYXRlZExlbmd0aCA9IGNvZGVzW2kgLSAxXS5wcmVmaXhMZW5ndGg7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIDMzOgogICAgICAgICAgbnVtYmVyT2ZSZXBlYXRzID0gcmVhZGVyLnJlYWRCaXRzKDMpICsgMzsKICAgICAgICAgIHJlcGVhdGVkTGVuZ3RoID0gMDsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMzQ6CiAgICAgICAgICBudW1iZXJPZlJlcGVhdHMgPSByZWFkZXIucmVhZEJpdHMoNykgKyAxMTsKICAgICAgICAgIHJlcGVhdGVkTGVuZ3RoID0gMDsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICB0aHJvdyBuZXcgSmJpZzJFcnJvcigiaW52YWxpZCBjb2RlIGxlbmd0aCBpbiBzeW1ib2wgSUQgdGFibGUiKTsKICAgICAgfQogICAgICBmb3IgKGogPSAwOyBqIDwgbnVtYmVyT2ZSZXBlYXRzOyBqKyspIHsKICAgICAgICBjb2Rlcy5wdXNoKG5ldyBIdWZmbWFuTGluZShbaSwgc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CiAgICAgIGN4X21wcyA9IGNvbnRleHRzW3Bvc10gJiAxOwogICAgY29uc3QgcWVUYWJsZUljeCA9IFFlVGFibGVbY3hfaW5kZXhdOwogICAgY29uc3QgcWVJY3ggPSBxZVRhYmxlSWN4LnFlOwogICAgbGV0IGQ7CiAgICBsZXQgYSA9IHRoaXMuYSAtIHFlSWN4OwogICAgaWYgKHRoaXMuY2hpZ2ggPCBxZUljeCkgewogICAgICBpZiAoYSA8IHFlSWN4KSB7CiAgICAgICAgYSA9IHFlSWN4OwogICAgICAgIGQgPSBjeF9tcHM7CiAgICAgICAgY3hfaW5kZXggPSBxZVRhYmxlSWN4Lm5tcHM7CiAgICAgIH0gZWxzZSB7CiAgICAgICAgYSA9IHFlSWN4OwogICAgICAgIGQgPSAxIF4gY3hfbXBzOwogICAgICAgIGlmIChxZVRhYmxlSWN4LnN3aXRjaEZsYWcgPT09IDEpIHsKICAgICAgICAgIGN4X21wcyA9IGQ7CiAgICAgICAgfQogICAgICAgIGN4X2luZGV4ID0gcWVUYWJsZUljeC5ubHBzOwogICAgICB9CiAgICB9IGVsc2UgewogICAgICB0aGlzLmNoaWdoIC09IHFlSWN4OwogICAgICBpZiAoKGEgJiAweDgwMDApICE9PSAwKSB7CiAgICAgICAgdGhpcy5hID0gYTsKICAgICAgICByZXR1cm4gY3hfbXBzOwogICAgICB9CiAgICAgIGlmIChhIDwgcWVJY3gpIHsKICAgICAgICBkID0gMSBeIGN4X21wczsKICAgICAgICBpZiAocWVUYWJsZUljeC5zd2l0Y2hGbGFnID09PSAxKSB7CiAgICAgICAgICBjeF9tcHMgPSBkOwogICAgICAgIH0KICAgICAgICBjeF9pbmRleCA9IHFlVGFibGVJY3gubmxwczsKICAgICAgfSBlbHNlIHsKICAgICAgICBkID0gY3hfbXBzOwogICAgICAgIGN4X2luZGV4ID0gcWVUYWJsZUljeC5ubXBzOwogICAgICB9CiAgICB9CiAgICBkbyB7CiAgICAgIGlmICh0aGlzLmN0ID09PSAwKSB7Ci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sZSAobGVuZ3RoID4gMCAmJiAhY29kZUxlbmd0aHNbbGVuZ3RoIC0gMV0pIHsKICAgIGxlbmd0aC0tOwogIH0KICBjb25zdCBjb2RlID0gW3sKICAgIGNoaWxkcmVuOiBbXSwKICAgIGluZGV4OiAwCiAgfV07CiAgbGV0IHAgPSBjb2RlWzBdLAogICAgcTsKICBmb3IgKGkgPSAwOyBpIDwgbGVuZ3RoOyBpKyspIHsKICAgIGZvciAoaiA9IDA7IGogPCBjb2RlTGVuZ3Roc1tpXTsgaisrKSB7CiAgICAgIHAgPSBjb2RlLnBvcCgpOwogICAgICBwLmNoaWxkcmVuW3AuaW5kZXhdID0gdmFsdWVzW2tdOwogICAgICB3aGlsZSAocC5pbmRleCA+IDApIHsKICAgICAgICBwID0gY29kZS5wb3AoKTsKICAgICAgfQogICAgICBwLmluZGV4Kys7CiAgICAgIGNvZGUucHVzaChwKTsKICAgICAgd2hpbGUgKGNvZGUubGVuZ3RoIDw9IGkpIHsKICAgICAgICBjb2RlLnB1c2gocSA9IHsKICAgICAgICAgIGNoaWxkcmVuOiBbXSwKICAgICAgICAgIGluZGV4OiAwCiAgICAgICAgfSk7CiAgICAgICAgcC5jaGlsZHJlbltwLmluZGV4XSA9IHEuY2hpbGRyZW47CiAgICAgICAgcCA9IHE7CiAgICAgIH0KICAgICAgaysrOwogICAgfQogICAgaWYgKGkgKyAxIDwgbGVuZ3RoKSB7CiAgICAgIGNvZGUucHVzaChxID0gewogICAgICAgIGNoaWxkcmVuOiBbXSwKICAgICAgICBpbmRleDogMAogICAgICB9KTsKICAgICAgcC5jaGlsZHJlbltwLmluZGV4XSA9IHEuY2hpbGRyZW47CiAgICAgIHAgPSBxOwogICAgfQogIH0KICByZXR1cm4gY29kZVswXS5jaGlsZHJlbjsKfQpmdW5jdGlvbiBnZXRCbG9ja0J1ZmZlck9mZnNldChjb21wb25lbnQsIHJvdywgY29sKSB7CiAgcmV0dXJuIDY0ICogKChjb21wb25lbnQuYmxvY2tzUGVy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25lbnQuYmxvY2tEYXRhW2Jsb2NrT2Zmc2V0XSA9IGNvbXBvbmVudC5wcmVkICs9IGRpZmY7CiAgICBsZXQgayA9IDE7CiAgICB3aGlsZSAoayA8IDY0KSB7CiAgICAgIGNvbnN0IHJzID0gZGVjb2RlSHVmZm1hbihjb21wb25lbnQuaHVmZm1hblRhYmxlQUMpOwogICAgICBjb25zdCBzID0gcnMgJiAxNSwKICAgICAgICByID0gcnMgPj4gNDsKICAgICAgaWYgKHMgPT09IDApIHsKICAgICAgICBpZiAociA8IDE1KSB7CiAgICAgICAgICBicmVhazsKICAgICAgICB9CiAgICAgICAgayArPSAxNjsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBrICs9IHI7CiAgICAgIGNvbnN0IHogPSBkY3RaaWdaYWdba107CiAgICAgIGNvbXBvbmVudC5ibG9ja0RhdGFbYmxvY2tPZmZzZXQgKyB6XSA9IHJlY2VpdmVBbmRFeHRlbmQocyk7CiAgICAgIGsrKzsKICAgIH0KICB9CiAgZnVuY3Rpb24gZGVjb2RlRENGaXJzdChjb21wb25lbnQsIGJsb2NrT2Zmc2V0KSB7CiAgICBjb25zdCB0ID0gZGVjb2RlSHVmZm1hbihjb21wb25lbnQuaHVmZm1hblRhYmxlREMpOwogICAgY29uc3QgZGlmZiA9IHQgPT09IDAgPyAwIDogcmVjZWl2ZUFuZEV4dGVuZCh0KSA8PCBzdWNjZXNzaXZlOwogICAgY29tcG9uZW50LmJsb2NrRGF0YVtibG9ja09mZnNldF0gPSBjb21wb25lbnQucHJlZCArPSBkaWZmOwogIH0KICBmdW5jdGlvbiBkZWNvZGVEQ1N1Y2Nlc3NpdmUoY29tcG9uZW50LCBibG9ja09mZnNldCkgewogICAgY29tcG9uZW50LmJsb2NrRGF0YVtibG9ja09mZnNldF0gfD0gcmVhZEJpdCgpIDw8IHN1Y2Nlc3NpdmU7CiAgfQogIGxldCBlb2JydW4gPSAwOwogIGZ1bmN0aW9uIGRlY29kZUFDRmlyc3Qo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tdOwogICAgICBjb25zdCBzaWduID0gY29tcG9uZW50LmJsb2NrRGF0YVtvZmZzZXRaXSA8IDAgPyAtMSA6IDE7CiAgICAgIHN3aXRjaCAoc3VjY2Vzc2l2ZUFDU3RhdGUpIHsKICAgICAgICBjYXNlIDA6CiAgICAgICAgICBycyA9IGRlY29kZUh1ZmZtYW4oY29tcG9uZW50Lmh1ZmZtYW5UYWJsZUFDKTsKICAgICAgICAgIHMgPSBycyAmIDE1OwogICAgICAgICAgciA9IHJzID4+IDQ7CiAgICAgICAgICBpZiAocyA9PT0gMCkgewogICAgICAgICAgICBpZiAociA8IDE1KSB7CiAgICAgICAgICAgICAgZW9icnVuID0gcmVjZWl2ZShyKSArICgxIDw8IHIpOwogICAgICAgICAgICAgIHN1Y2Nlc3NpdmVBQ1N0YXRlID0gNDsKICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICByID0gMTY7CiAgICAgICAgICAgICAgc3VjY2Vzc2l2ZUFDU3RhdGUgPSAxOwogICAgICAgICAgICB9CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBpZiAocyAhPT0gMSkgewogICAgICAgICAgICAgIHRocm93IG5ldyBKcGVnRXJyb3IoImludmFsaWQgQUNuIGVuY29kaW5nIik7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgc3VjY2Vzc2l2ZUFDTmV4dFZhbHVlID0gcmVjZWl2ZUFuZEV4dGVuZChzKTsKICAgICAgICAgICAgc3VjY2Vzc2l2ZUFDU3RhdGUgPSByID8gMiA6IDM7CiAgICAgICAgICB9CiAgICAgICAgICBjb250aW51ZTsKICAgICAgICBjYXNlIDE6CiAgICAgICAgY2FzZSAyOgogICAgICAgICAgaWYgKGNvbXBvbmVudC5ibG9ja0RhdGFbb2Zmc2V0Wl0pIHsKICAgICAgICAgICAgY29tcG9uZW50LmJsb2NrRGF0YVtvZmZzZXRaXSArPSBzaWduICogKHJlYWRCaXQoKSA8PCBzdWNjZXNzaXZlKTsKICAgICAgICAg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gPCBtY3VUb1JlYWQ7IG4rKykgewogICAgICAgICAgZm9yIChpID0gMDsgaSA8IGNvbXBvbmVudHNMZW5ndGg7IGkrKykgewogICAgICAgICAgICBjb21wb25lbnQgPSBjb21wb25lbnRzW2ldOwogICAgICAgICAgICBoID0gY29tcG9uZW50Lmg7CiAgICAgICAgICAgIHYgPSBjb21wb25lbnQudjsKICAgICAgICAgICAgZm9yIChqID0gMDsgaiA8IHY7IGorKykgewogICAgICAgICAgICAgIGZvciAoayA9IDA7IGsgPCBoOyBrKyspIHsKICAgICAgICAgICAgICAgIGRlY29kZU1jdShjb21wb25lbnQsIGRlY29kZUZuLCBtY3UsIGosIGspOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgICAgbWN1Kys7CiAgICAgICAgfQogICAgICB9CiAgICB9CiAgICBiaXRzQ291bnQgPSAwOwogICAgZmlsZU1hcmtlciA9IGZpbmROZXh0RmlsZU1hcmtlcihkYXRhLCBvZmZzZXQpOwogICAgaWYgKCFmaWxlTWFya2VyKSB7CiAgICAgIGJyZWFrOwogICAgfQogICAgaWYgKGZpbGVNYXJrZXIuaW52YWxpZCkgewogICAgICBjb25zdCBwYXJ0aWFsTXNnID0gbWN1VG9SZWFkID4gMCA/ICJ1bmV4cGVjdGVkIiA6ICJleGNlc3NpdmUiOwogICAgICAoMCwgX3V0aWwud2FybikoYGRlY29kZVNjYW4gLSAke3BhcnRpYWxNc2d9IE1DVSBkYXRhLCBjdXJyZW50IG1hcmtlciBpczogJHtmaWxlTWFya2VyLmludmFsaWR9YCk7CiAgICAgIG9mZnNldCA9IGZpbGVNYXJrZXIub2Zmc2V0OwogICAgfQogICAgaWYgKGZpbGVNYXJrZXIubWFya2VyID49IDB4ZmZkMCAmJiBmaWxlTWFya2VyLm1hcmtlciA8PSAweGZmZDcpIHsKICAgICAgb2Zmc2V0ICs9IDI7CiAgICB9IGVsc2UgewogICAgICBicmVhazsKICAgIH0KICB9CiAgcmV0dX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iAgICB9IGVsc2UgaWYgKHAxID49IDQwODApIHsKICAgICAgcDEgPSAyNTU7CiAgICB9IGVsc2UgewogICAgICBwMSA+Pj0gNDsKICAgIH0KICAgIGlmIChwMiA8IDE2KSB7CiAgICAgIHAyID0gMDsKICAgIH0gZWxzZSBpZiAocDIgPj0gNDA4MCkgewogICAgICBwMiA9IDI1NTsKICAgIH0gZWxzZSB7CiAgICAgIHAyID4+PSA0OwogICAgfQogICAgaWYgKHAzIDwgMTYpIHsKICAgICAgcDMgPSAwOwogICAgfSBlbHNlIGlmIChwMyA+PSA0MDgwKSB7CiAgICAgIHAzID0gMjU1OwogICAgfSBlbHNlIHsKICAgICAgcDMgPj49IDQ7CiAgICB9CiAgICBpZiAocDQgPCAxNikgewogICAgICBwNCA9IDA7CiAgICB9IGVsc2UgaWYgKHA0ID49IDQwODApIHsKICAgICAgcDQgPSAyNTU7CiAgICB9IGVsc2UgewogICAgICBwNCA+Pj0gNDsKICAgIH0KICAgIGlmIChwNSA8IDE2KSB7CiAgICAgIHA1ID0gMDsKICAgIH0gZWxzZSBpZiAocDUgPj0gNDA4MCkgewogICAgICBwNSA9IDI1NTsKICAgIH0gZWxzZSB7CiAgICAgIHA1ID4+PSA0OwogICAgfQogICAgaWYgKHA2IDwgMTYpIHsKICAgICAgcDYgPSAwOwogICAgfSBlbHNlIGlmIChwNiA+PSA0MDgwKSB7CiAgICAgIHA2ID0gMjU1OwogICAgfSBlbHNlIHsKICAgICAgcDYgPj49IDQ7CiAgICB9CiAgICBpZiAocDcgPCAxNikgewogICAgICBwNyA9IDA7CiAgICB9IGVsc2UgaWYgKHA3ID49IDQwODApIHsKICAgICAgcDcgPSAyNTU7CiAgICB9IGVsc2UgewogICAgICBwNyA+Pj0gNDsKICAgIH0KICAgIGJsb2NrRGF0YVtibG9ja0J1ZmZlck9mZnNldCArIGNvbF0gPSBwMDsKICAgIGJsb2NrRGF0YVtibG9ja0J1ZmZlck9mZnNldCArIGNvbCArIDhdID0gcDE7Ci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ICAgY2FzZSAweGZmZTI6CiAgICAgICAgY2FzZSAweGZmZTM6CiAgICAgICAgY2FzZSAweGZmZTQ6CiAgICAgICAgY2FzZSAweGZmZTU6CiAgICAgICAgY2FzZSAweGZmZTY6CiAgICAgICAgY2FzZSAweGZmZTc6CiAgICAgICAgY2FzZSAweGZmZTg6CiAgICAgICAgY2FzZSAweGZmZTk6CiAgICAgICAgY2FzZSAweGZmZWE6CiAgICAgICAgY2FzZSAweGZmZWI6CiAgICAgICAgY2FzZSAweGZmZWM6CiAgICAgICAgY2FzZSAweGZmZWQ6CiAgICAgICAgY2FzZSAweGZmZWU6CiAgICAgICAgY2FzZSAweGZmZWY6CiAgICAgICAgY2FzZSAweGZmZmU6CiAgICAgICAgICBjb25zdCBhcHBEYXRhID0gcmVhZERhdGFCbG9jaygpOwogICAgICAgICAgaWYgKGZpbGVNYXJrZXIgPT09IDB4ZmZlMCkgewogICAgICAgICAgICBpZiAoYXBwRGF0YVswXSA9PT0gMHg0YSAmJiBhcHBEYXRhWzFdID09PSAweDQ2ICYmIGFwcERhdGFbMl0gPT09IDB4NDkgJiYgYXBwRGF0YVszXSA9PT0gMHg0NiAmJiBhcHBEYXRhWzRdID09PSAwKSB7CiAgICAgICAgICAgICAgamZpZiA9IHsKICAgICAgICAgICAgICAgIHZlcnNpb246IHsKICAgICAgICAgICAgICAgICAgbWFqb3I6IGFwcERhdGFbNV0sCiAgICAgICAgICAgICAgICAgIG1pbm9yOiBhcHBEYXRhWzZdCiAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgZGVuc2l0eVVuaXRzOiBhcHBEYXRhWzddLAogICAgICAgICAgICAgICAgeERlbnNpdHk6IGFwcERhdGFbOF0gPDwgOCB8IGFwcERhdGFbOV0sCiAgICAgICAgICAgICAgICB5RGVuc2l0eTogYXBwRGF0YVsxMF0gPDwgOCB8IGFwcERhdGFbMTFdLAogICAgICAgICAgICAgICAgdGh1bWJXaWR0aDogYXBwRGF0YVsxMl0sCiAgICAgICAgICAgICAgICB0aHVtYkhlaWdodDogYXBwRGF0YVsxM10sCiAgICAgICAgICAgICAgICB0aHVtYkRhdGE6IGFwcERhdGEuc3ViYXJyYXkoMTQsIDE0ICsgMyAqIGFwcERhdGFbMTJdICogYXBwRGF0YVsxM10pCiAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgICAgaWYgKGZpbGVNYXJrZXIgPT09IDB4ZmZlZSkgewogICAgICAgICAgICBpZiAoYXBwRGF0YVswXSA9PT0gMHg0MSAmJiBhcHBEYXRhWzFdID09PSAweDY0ICYmIGFwcERhdGFbMl0gPT09IDB4NmYgJiYgYXBwRGF0YVszXSA9PT0gMHg2MiAmJiBhcHBEYXRhWzRdID09PSAweDY1KSB7CiAgICAgICAgICAgICAgYWRvYmUgPSB7CiAgICAgICAgICAgICAgICB2ZXJzaW9uOiBhcHBEYXRhWzVdIDw8IDggfCBhcHBEYXRhWzZdLAogICAgICAgICAgICAgICAgZmxhZ3MwOiBhcHBEYXRhWzddIDw8IDggfCBhcHBEYXRhWzhdLAogICAgICAgICAgICAgICAgZmxhZ3MxOiBhcHBEYXRhWzldIDw8IDggfCBhcHBEYXRhWzEwXSwKICAgICAgICAgICAgICAgIHRyYW5zZm9ybUNvZGU6IGFwcERhdGFbMTFdCiAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAweGZmZGI6CiAgICAgICAgICBjb25zdCBxdWFudGl6YXRpb25UYWJsZXNMZW5ndGggPSAoMCwgX2NvcmVfdXRpbHMucmVhZFVpbnQxNikoZGF0YSwgb2Zmc2V0KTsKICAgICAgICAgIG9mZnNldCArPSAyOwogICAgICAgICAgY29uc3QgcXVhbnRpemF0aW9uVGFibGVzRW5kID0gcXVhbnRpemF0aW9uVGFibGVzTGVuZ3RoICsgb2Zmc2V0IC0gMjsKICAgICAgICAgIGxldCB6OwogICAgICAgICAgd2hpbGUgKG9mZnNldCA8IHF1YW50aXphdGlvblRhYmxlc0VuZCkgewogICAgICAgICAgICBjb25zdCBxdWFudGl6YXRpb25UYWJsZVNwZWMgPSBkYXRhW29mZnNldCsrXTsKICAgICAgICAgICAgY29uc3QgdGFibGVEYXRhID0gbmV3IFVpbnQxNkFycmF5KDY0KTsKICAgICAgICAgICAgaWYgKHF1YW50aXphdGlvblRhYmxlU3BlYyA+PiA0ID09PSAwKSB7CiAgICAgICAgICAgICAgZm9yIChqID0gMDsgaiA8IDY0OyBqKyspIHsKICAgICAgICAgICAgICAgIHogPSBkY3RaaWdaYWdbal07CiAgICAgICAgICAgICAgICB0YWJsZURhdGFbel0gPSBkYXRhW29mZnNldCsrXTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0gZWxzZSBpZiAocXVhbnRpemF0aW9uVGFibGVTcGVjID4+IDQgPT09IDEpIHsKICAgICAgICAgICAgICBmb3IgKGogPSAwOyBqIDwgNjQ7IGorKykgewogICAgICAgICAgICAgICAgeiA9IGRjdFppZ1phZ1tqXTsKICAgICAgICAgICAgICAgIHRhYmxlRGF0YVt6XSA9ICgwLCBfY29yZV91dGlscy5yZWFkVWludDE2KShkYXRhLCBvZmZzZXQpOwogICAgICAgICAgICAgICAgb2Zmc2V0ICs9IDI7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgIHRocm93IG5ldyBKcGVnRXJyb3IoIkRRVCAtIGludmFsaWQgdGFibGUgc3BlYyIpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIHF1YW50aXphdGlvblRhYmxlc1txdWFudGl6YXRpb25UYWJsZVNwZWMgJiAxNV0gPSB0YWJsZURhdGE7CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIDB4ZmZjMDoKICAgICAgICBjYXNlIDB4ZmZjMToKICAgICAgICBjYXNlIDB4ZmZjMjoKICAgICAgICAgIGlmIChmcmFtZSkgewogICAgICAgICAgICB0aHJvdyBuZXcgSnBlZ0Vycm9yKCJPbmx5IHNpbmdsZSBmcmFtZSBKUEVHcyBzdXBwb3J0ZWQiKTsKICAgICAgICAgIH0KICAgICAgICAgIG9mZnNldCArPSAyOwogICAgICAgICAgZnJhbWUgPSB7fTsKICAgICAgICAgIGZyYW1lLmV4dGVuZGVkID0gZmlsZU1hcmtlciA9PT0gMHhmZmMxOwogICAgICAgICAgZnJhbWUucHJvZ3Jlc3NpdmUgPSBmaWxlTWFya2VyID09PSAweGZmYzI7CiAgICAgICAgICBmcmFtZS5wcmVjaXNpb24gPSBkYXRhW29mZnNldCsrXTsKICAgICAgICAgIGNvbnN0IHNvZlNjYW5MaW5lcyA9ICgwLCBfY29yZV91dGlscy5yZWFkVWludDE2KShkYXRhLCBvZmZzZXQpOwogICAgICAgICAgb2Zmc2V0ICs9IDI7CiAgICAgICAgICBmcmFtZS5zY2FuTGluZXMgPSBkbmxTY2FuTGluZXMgfHwgc29mU2NhbkxpbmVzOwogICAgICAgICAgZnJhbWUuc2FtcGxlc1BlckxpbmUgPSAoMCwgX2NvcmVfdXRpbHMucmVhZFVpbnQxNikoZGF0YSwgb2Zmc2V0KTsKICAgICAgICAgIG9mZnNldCArPSAyOwogICAgICAgICAgZnJhbWUuY29tcG9uZW50cyA9IFtdOwogICAgICAgICAgZnJhbWUuY29tcG9uZW50SWRzID0ge307CiAgICAgICAgICBjb25zdCBjb21wb25lbnRzQ291bnQgPSBkYXRhW29mZnNldCsrXTsKICAgICAgICAgIGxldCBtYXhIID0gMCwKICAgICAgICAgICAgbWF4ViA9IDA7CiAgICAgICAgICBmb3IgKGkgPSAwOyBpIDwgY29tcG9uZW50c0NvdW50OyBpKyspIHsKICAgICAgICAgICAgY29uc3QgY29tcG9uZW50SWQgPSBkYXRhW29mZnNldF07CiAgICAgICAgICAgIGNvbnN0IGggPSBkYXRhW29mZnNldCArIDFdID4+IDQ7CiAgICAgICAgICAgIGNvbnN0IHYgPSBkYXRhW29mZnNldCArIDFdICYgMTU7CiAgICAgICAgICAgIGlmIChtYXhIIDwgaCkgewogICAgICAgICAgICAgIG1heEggPSBoOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmIChtYXhWIDwgdikgewogICAgICAgICAgICAgIG1heFYgPSB2OwogICAgICAgICAgICB9CiAgICAgICAgICAgIGNvbnN0IHFJZCA9IGRhdGFbb2Zmc2V0ICsgMl07CiAgICAgICAgICAgIGwgPSBmcmFtZS5jb21wb25lbnRzLnB1c2goewogICAgICAgICAgICAgIGgsCiAgICAgICAgICAgICAgdiwKICAgICAgICAgICAgICBxdWFudGl6YXRpb25JZDogcUlkLAogICAgICAgICAgICAgIHF1YW50aXphdGlvblRhYmxlOiBudWxsCiAgICAgICAgICAgIH0pOwogICAgICAgICAgICBmcmFtZS5jb21wb25lbnRJZHNbY29tcG9uZW50SWRdID0gbCAtIDE7CiAgICAgICAgICAgIG9mZnNldCArPSAzOwogICAgICAgICAgfQogICAgICAgICAgZnJhbWUubWF4SCA9IG1heEg7CiAgICAgICAgICBmcmFtZS5tYXhWID0gbWF4VjsKICAgICAgICAgIHByZXBhcmVDb21wb25lbnRzKGZyYW1lKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMHhmZmM0OgogICAgICAgICAgY29uc3QgaHVmZm1hbkxlbmd0aCA9ICgwLCBfY29yZV91dGlscy5yZWFkVWludDE2KShkYXRhLCBvZmZzZXQpOwogICAgICAgICAgb2Zmc2V0ICs9IDI7CiAgICAgICAgICBmb3IgKGkgPSAyOyBpIDwgaHVmZm1hbkxlbmd0aDspIHsKICAgICAgICAgICAgY29uc3QgaHVmZm1hblRhYmxlU3BlYyA9IGRhdGFbb2Zmc2V0KytdOwogICAgICAgICAgICBjb25zdCBjb2RlTGVuZ3RocyA9IG5ldyBVaW50OEFycmF5KDE2KTsKICAgICAgICAgICAgbGV0IGNvZGVMZW5ndGhTdW0gPSAwOwogICAgICAgICAgICBmb3IgKGogPSAwOyBqIDwgMTY7IGorKywgb2Zmc2V0KyspIHsKICAgICAgICAgICAgICBjb2RlTGVuZ3RoU3VtICs9IGNvZGVMZW5ndGhzW2pdID0gZGF0YVtvZmZzZXRdOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGNvbnN0IGh1ZmZtYW5WYWx1ZXMgPSBuZXcgVWludDhBcnJheShjb2RlTGVuZ3RoU3VtKTsKICAgICAgICAgICAgZm9yIChqID0gMDsgaiA8IGNvZGVMZW5ndGhTdW07IGorKywgb2Zmc2V0KyspIHsKICAgICAgICAgICAgICBodWZmbWFuVmFsdWVzW2pdID0gZGF0YVtvZmZzZXRdOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGkgKz0gMTcgKyBjb2RlTGVuZ3RoU3VtOwogICAgICAgICAgICAoaHVmZm1hblRhYmxlU3BlYyA+PiA0ID09PSAwID8gaHVmZm1hblRhYmxlc0RDIDogaHVmZm1hblRhYmxlc0FDKVtodWZmbWFuVGFibGVTcGVjICYgMTVdID0gYnVpbGRIdWZmbWFuVGFibGUoY29kZUxlbmd0aHMsIGh1ZmZtYW5WYWx1ZXMpOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAweGZmZGQ6CiAgICAgICAgICBvZmZzZXQgKz0gMjsKICAgICAgICAgIHJlc2V0SW50ZXJ2YWwgPSAoMCwgX2NvcmVfdXRpbHMucmVhZFVpbnQxNikoZGF0YSwgb2Zmc2V0KTsKICAgICAgICAgIG9mZnNldCArPSAyOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAweGZmZGE6CiAgICAgICAgICBjb25zdCBwYXJzZUROTE1hcmtlciA9ICsrbnVtU09TTWFya2VycyA9PT0gMSAmJiAhZG5sU2NhbkxpbmVzOwogICAgICAgICAgb2Zmc2V0ICs9IDI7CiAgICAgICAgICBjb25zdCBzZWxlY3RvcnNDb3VudCA9IGRhdGFbb2Zmc2V0KytdLAogICAgICAgICAgICBjb21wb25lbnRzID0gW107CiAgICAgICAgICBmb3IgKGkgPSAwOyBpIDwgc2VsZWN0b3JzQ291bnQ7IGkrKykgewogICAgICAgICAgICBjb25zdCBpbmRleCA9IGRhdGFbb2Zmc2V0KytdOwogICAgICAgICAgICBjb25zdCBjb21wb25lbnRJbmRleCA9IGZyYW1lLmNvbXBvbmVudElkc1tpbmRleF07CiAgICAgICAgICAgIGNvbnN0IGNvbXBvbmVudCA9IGZyYW1lLmNvbXBvbmVudHNbY29tcG9uZW50SW5kZXhdOwogICAgICAgICAgICBjb21wb25lbnQuaW5kZXggPSBpbmRleDsKICAgICAgICAgICAgY29uc3QgdGFibGVTcGVjID0gZGF0YVtvZmZzZXQrK107CiAgICAgICAgICAgIGNvbXBvbmVudC5odWZmbWFuVGFibGVEQyA9IGh1ZmZtYW5UYWJsZXNEQ1t0YWJsZVNwZWMgPj4gNF07CiAgICAgICAgICAgIGNvbXBvbmVudC5odWZmbWFuVGFibGVBQyA9IGh1ZmZtYW5UYWJsZXNBQ1t0YWJsZVNwZWMgJiAxNV07CiAgICAgICAgICAgIGNvbXBvbmVudHMucHVzaChjb21wb25lbnQpOwogICAgICAgICAgfQogICAgICAgICAgY29uc3Qgc3BlY3RyYWxTdGFydCA9IGRhdGFbb2Zmc2V0KytdLAogICAgICAgICAgICBzcGVjdHJhbEVuZCA9IGRhdGFbb2Zmc2V0KytdLAogICAgICAgICAgICBzdWNjZXNzaXZlQXBwcm94aW1hdGlvbiA9IGRhdGFbb2Zmc2V0KytdOwogICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgY29uc3QgcHJvY2Vzc2VkID0gZGVjb2RlU2NhbihkYXRhLCBvZmZzZXQsIGZyYW1lLCBjb21wb25lbnRzLCByZXNldEludGVydmFsLCBzcGVjdHJhbFN0YXJ0LCBzcGVjdHJhbEVuZCwgc3VjY2Vzc2l2ZUFwcHJveGltYXRpb24gPj4gNCwgc3VjY2Vzc2l2ZUFwcHJveGltYXRpb24gJiAxNSwgcGFyc2VETkxNYXJrZXIpOwogICAgICAgICAgICBvZmZzZXQgKz0gcHJvY2Vzc2VkOwogICAgICAgICAgfSBjYXRjaCAoZXgpIHsKICAgICAgICAgICAgaWYgKGV4IGluc3RhbmNlb2YgRE5MTWFya2VyRXJyb3IpIHsKICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYCR7ZXgubWVzc2FnZX0gLS0gYXR0ZW1wdGluZyB0byByZS1wYXJzZSB0aGUgSlBFRyBpbWFnZS5gKTsKICAgICAgICAgICAgICByZXR1cm4gdGhpcy5wYXJzZShkYXRhLCB7CiAgICAgICAgICAgICAgICBkbmxTY2FuTGluZXM6IGV4LnNjYW5MaW5lcwogICAgICAgICAgICAgIH0pOwogICAgICAgICAgICB9IGVsc2UgaWYgKGV4IGluc3RhbmNlb2YgRU9JTWFya2VyRXJyb3IpIHsKICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYCR7ZXgubWVzc2FnZX0gLS0gaWdub3JpbmcgdGhlIHJlc3Qgb2YgdGhlIGltYWdlIGRhdGEuYCk7CiAgICAgICAgICAgICAgYnJlYWsgbWFya2VyTG9vcDsKICAgICAgICAgICAgfQogICAgICAgICAgICB0aHJvdyBleDsKICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMHhmZmRjOgogICAgICAgICAgb2Zmc2V0ICs9IDQ7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIDB4ZmZmZjoKICAgICAgICAgIGlmIChkYXRhW29mZnNldF0gIT09IDB4ZmYpIHsKICAgICAgICAgICAgb2Zmc2V0LS07CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICBkZWZhdWx0OgogICAgICAgICAgY29uc3QgbmV4dEZpbGVNYXJrZXIgPSBmaW5kTmV4dEZpbGVNYXJrZXIoZGF0YSwgb2Zmc2V0IC0gMiwgb2Zmc2V0IC0gMyk7CiAgICAgICAgICBpZiAobmV4dEZpbGVNYXJrZXIgJiYgbmV4dEZpbGVNYXJrZXIuaW52YWxpZCkgewogICAgICAgICAgICAoMCwgX3V0aWwud2FybikoIkpwZWdJbWFnZS5wYXJzZSAtIHVuZXhwZWN0ZWQgZGF0YSwgY3VycmVudCBtYXJrZXIgaXM6ICIgKyBuZXh0RmlsZU1hcmtlci5pbnZhbGlkKTsKICAgICAgICAgICAgb2Zmc2V0ID0gbmV4dEZpbGVNYXJrZXIub2Zmc2V0OwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIH0KICAgICAgICAgIGlmICghbmV4dEZpbGVNYXJrZXIgfHwgb2Zmc2V0ID49IGRhdGEubGVuZ3RoIC0gMSkgewogICAgICAgICAgICAoMCwgX3V0aWwud2FybikoIkpwZWdJbWFnZS5wYXJzZSAtIHJlYWNoZWQgdGhlIGVuZCBvZiB0aGUgaW1hZ2UgZGF0YSAiICsgIndpdGhvdXQgZmluZGluZyBhbiBFT0kgbWFya2VyICgweEZGRDkpLiIpOwogICAgICAgICAgICBicmVhayBtYXJrZXJMb29wOwogICAgICAgICAgfQogICAgICAgICAgdGhyb3cgbmV3IEpwZWdFcnJvcigiSnBlZ0ltYWdlLnBhcnNlIC0gdW5rbm93biBtYXJrZXI6ICIgKyBmaWxlTWFya2VyLnRvU3RyaW5nKDE2KSk7CiAgICAgIH0KICAgICAgZmlsZU1hcmtlciA9ICgwLCBfY29yZV91dGlscy5yZWFkVWludDE2KShkYXRhLCBvZmZzZXQpOwogICAgICBvZmZzZXQgKz0gMjsKICAgIH0KICAgIHRoaXMud2lkdGggPSBmcmFtZS5zYW1wbGVzUGVyTGluZTsKICAgIHRoaXMuaGVpZ2h0ID0gZnJhbWUuc2NhbkxpbmVzOwogICAgdGhpcy5qZmlmID0gamZpZjsKICAgIHRoaXMuYWRvYmUgPSBhZG9iZTsKICAgIHRoaXMuY29tcG9uZW50cyA9IFtdOwogICAgZm9yIChjb25zdCBjb21wb25lbnQgb2YgZnJhbWUuY29tcG9uZW50cykgewogICAgICBjb25zdCBxdWFudGl6YXRpb25UYWJsZSA9IHF1YW50aXphdGlvblRhYmxlc1tjb21wb25lbnQucXVhbnRpemF0aW9uSWRdOwogICAgICBpZiAocXVhbnRpemF0aW9uVGFibGUpIHsKICAgICAgICBjb21wb25lbnQucXVhbnRpemF0aW9uVGFibGUgPSBxdWFudGl6YXRpb25UYWJsZTsKICAgICAgfQogICAgICB0aGlzLmNvbXBvbmVudHMucHVzaCh7CiAgICAgICAgaW5kZXg6IGNvbXBvbmVudC5pbmRleCwKICAgICAgICBvdXRwdXQ6IGJ1aWxkQ29tcG9uZW50RGF0YShmcmFtZSwgY29tcG9uZW50KSwKICAgICAgICBzY2FsZVg6IGNvbXBvbmVudC5oIC8gZnJhbWUubWF4SCwKICAgICAgICBzY2FsZVk6IGNvbXBvbmVudC52IC8gZnJhbWUubWF4ViwKICAgICAgICBibG9ja3NQZXJMaW5lOiBjb21wb25lbnQuYmxvY2tzUGVyTGluZSwKICAgICAgICBibG9ja3NQZXJDb2x1bW46IGNvbXBvbmVudC5ibG9ja3NQZXJDb2x1bW4KICAgICAgfSk7CiAgICB9CiAgICB0aGlzLm51bUNvbXBvbmVudHMgPSB0aGlzLmNvbXBvbmVudHMubGVuZ3RoOwogICAgcmV0dXJuIHVuZGVmaW5lZDsKICB9CiAgX2dldExpbmVhcml6ZWRCbG9ja0RhdGEod2lkdGgsIGhlaWdodCkgewogICAgbGV0IGlzU291cmNlUERGID0gYXJndW1lbnRzLmxlbmd0aCA+IDIgJiYgYXJndW1lbnRzWzJdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMl0gOiBmYWxzZTsKICAgIGNvbnN0IHNjYWxlWCA9IHRoaXMud2lkdGggLyB3aWR0aCwKICAgICAgc2NhbGVZID0gdGhpcy5oZWlnaHQgLyBoZWlnaHQ7CiAgICBsZXQgY29tcG9uZW50LCBjb21wb25lbnRTY2FsZVgsIGNvbXBvbmVudFNjYWxlWSwgYmxvY2tzUGVyU2NhbmxpbmU7CiAgICBsZXQgeCwgeSwgaSwgaiwgazsKICAgIGxldCBpbmRleDsKICAgIGxldCBvZmZzZXQgPSAwOwogICAgbGV0IG91dHB1dDsKICAgIGNvbnN0IG51bUNvbXBvbmVudHMgPSB0aGlzLmNvbXBvbmVudHMubGVuZ3RoOwogICAgY29uc3QgZGF0YUxlbmd0aCA9IHdpZHRoICogaGVpZ2h0ICogbnVtQ29tcG9uZW50czsKICAgIGNvbnN0IGRhdGEgPSBuZXcgVWludDhDbGFtcGVkQXJyYXkoZGF0YUxlbmd0aCk7CiAgICBjb25zdCB4U2NhbGVCbG9ja09mZnNldCA9IG5ldyBVaW50MzJBcnJheSh3aWR0aCk7CiAgICBjb25zdCBtYXNrM0xTQiA9IDB4ZmZmZmZmZjg7CiAgICBsZXQgbGFzdENvbXBvbmVudFNjYWxlWDsKICAgIGZvciAoaSA9IDA7IGkgPCBudW1Db21wb25lbnRzOyBpKyspIHsKICAgICAgY29tcG9uZW50ID0gdGhpcy5jb21wb25lbnRzW2ldOwogICAgICBjb21wb25lbnRTY2FsZVggPSBjb21wb25lbnQuc2NhbGVYICogc2NhbGVYOwogICAgICBjb21wb25lbnRTY2FsZVkgPSBjb21wb25lbnQuc2NhbGVZICogc2NhbGVZOwogICAgICBvZmZzZXQgPSBpOwogICAgICBvdXRwdXQgPSBjb21wb25lbnQub3V0cHV0OwogICAgICBibG9ja3NQZXJTY2FubGluZSA9IGNvbXBvbmVudC5ibG9ja3NQZXJMaW5lICsgMSA8PCAzOwogICAgICBpZiAoY29tcG9uZW50U2NhbGVYICE9PSBsYXN0Q29tcG9uZW50U2NhbGVYKSB7CiAgICAgICAgZm9yICh4ID0gMDsgeCA8IHdpZHRoOyB4KyspIHsKICAgICAgICAgIGogPSAwIHwgeCAqIGNvbXBvbmVudFNjYWxlWDsKICAgICAgICAgIHhTY2FsZUJsb2NrT2Zmc2V0W3hdID0gKGogJiBtYXNrM0xTQikgPDwgMyB8IGogJiA3OwogICAgICAgIH0KICAgICAgICBsYXN0Q29tcG9uZW50U2NhbGVYID0gY29tcG9uZW50U2NhbGVY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IHsKICAgICAgICBmb3IgKGNvbnN0IGdyYXlDb2xvciBvZiBkYXRhKSB7CiAgICAgICAgICByZ2JhRGF0YVtvZmZzZXQrK10gPSBncmF5Q29sb3I7CiAgICAgICAgICByZ2JhRGF0YVtvZmZzZXQrK10gPSBncmF5Q29sb3I7CiAgICAgICAgICByZ2JhRGF0YVtvZmZzZXQrK10gPSBncmF5Q29sb3I7CiAgICAgICAgfQogICAgICB9CiAgICAgIHJldHVybiByZ2JhRGF0YTsKICAgIH0gZWxzZSBpZiAodGhpcy5udW1Db21wb25lbnRzID09PSAzICYmIHRoaXMuX2lzQ29sb3JDb252ZXJzaW9uTmVlZGVkKSB7CiAgICAgIGlmIChmb3JjZVJHQkEpIHsKICAgICAgICBjb25zdCByZ2JhRGF0YSA9IG5ldyBVaW50OENsYW1wZWRBcnJheShkYXRhLmxlbmd0aCAvIDMgKiA0KTsKICAgICAgICByZXR1cm4gdGhpcy5fY29udmVydFljY1RvUmdiYShkYXRhLCByZ2JhRGF0YSk7CiAgICAgIH0KICAgICAgcmV0dXJuIHRoaXMuX2NvbnZlcnRZY2NUb1JnYihkYXRhKTsKICAgIH0gZWxzZSBpZiAodGhpcy5udW1Db21wb25lbnRzID09PSA0KSB7CiAgICAgIGlmICh0aGlzLl9pc0NvbG9yQ29udmVyc2lvbk5lZWRlZCkgewogICAgICAgIGlmIChmb3JjZVJHQkEpIHsKICAgICAgICAgIHJldHVybiB0aGlzLl9jb252ZXJ0WWNja1RvUmdiYShkYXRhKTsKICAgICAgICB9CiAgICAgICAgaWYgKGZvcmNlUkdCKSB7CiAgICAgICAgICByZXR1cm4gdGhpcy5fY29udmVydFljY2tUb1JnYihkYXRhKTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIHRoaXMuX2NvbnZlcnRZY2NrVG9DbXlrKGRhdGEpOwogICAgICB9IGVsc2UgaWYgKGZvcmNlUkdCQSkgewogICAgICAgIHJldHVybiB0aGlzLl9jb252ZXJ0Q215a1RvUmdiYShkYXR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B9IGVsc2UgewogICAgICBjb25zdCBkYXRhID0gbmV3IFVpbnQ4Q2xhbXBlZEFycmF5KHdpZHRoICogaGVpZ2h0ICogY29tcG9uZW50c0NvdW50KTsKICAgICAgZm9yIChsZXQgayA9IDA7IGsgPCB0aWxlQ291bnQ7IGsrKykgewogICAgICAgIGNvbnN0IHRpbGVDb21wb25lbnRzID0ganB4SW1hZ2UudGlsZXNba107CiAgICAgICAgY29uc3QgdGlsZVdpZHRoID0gdGlsZUNvbXBvbmVudHMud2lkdGg7CiAgICAgICAgY29uc3QgdGlsZUhlaWdodCA9IHRpbGVDb21wb25lbnRzLmhlaWdodDsKICAgICAgICBjb25zdCB0aWxlTGVmdCA9IHRpbGVDb21wb25lbnRzLmxlZnQ7CiAgICAgICAgY29uc3QgdGlsZVRvcCA9IHRpbGVDb21wb25lbnRzLnRvcDsKICAgICAgICBjb25zdCBzcmMgPSB0aWxlQ29tcG9uZW50cy5pdGVtczsKICAgICAgICBsZXQgc3JjUG9zaXRpb24gPSAwOwogICAgICAgIGxldCBkYXRhUG9zaXRpb24gPSAod2lkdGggKiB0aWxlVG9wICsgdGlsZUxlZnQpICogY29tcG9uZW50c0NvdW50OwogICAgICAgIGNvbnN0IGltZ1Jvd1NpemUgPSB3aWR0aCAqIGNvbXBvbmVudHNDb3VudDsKICAgICAgICBjb25zdCB0aWxlUm93U2l6ZSA9IHRpbGVXaWR0aCAqIGNvbXBvbmVudHNDb3VudDsKICAgICAgICBmb3IgKGxldCBqID0gMDsgaiA8IHRpbGVIZWlnaHQ7IGorKykgewogICAgICAgICAgY29uc3Qgcm93Qnl0ZXMgPSBzcmMuc3ViYXJyYXkoc3JjUG9zaXRpb24sIHNyY1Bvc2l0aW9uICsgdGlsZVJvd1NpemUpOwogICAgICAgICAgZGF0YS5zZXQocm93Qnl0ZXMsIGRhdGFQb3NpdGlvbik7CiAgICAgICAgICBzcmNQb3NpdGlvbiArPSB0aWxlUm93U2l6ZTsKICAgICAgICAgIGRhdGFQb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VWludDE2KShkYXRhLCAwKTsKICAgIGlmIChoZWFkID09PSAweGZmNGYpIHsKICAgICAgdGhpcy5wYXJzZUNvZGVzdHJlYW0oZGF0YSwgMCwgZGF0YS5sZW5ndGgpOwogICAgICByZXR1cm47CiAgICB9CiAgICBjb25zdCBsZW5ndGggPSBkYXRhLmxlbmd0aDsKICAgIGxldCBwb3NpdGlvbiA9IDA7CiAgICB3aGlsZSAocG9zaXRpb24gPCBsZW5ndGgpIHsKICAgICAgbGV0IGhlYWRlclNpemUgPSA4OwogICAgICBsZXQgbGJveCA9ICgwLCBfY29yZV91dGlscy5yZWFkVWludDMyKShkYXRhLCBwb3NpdGlvbik7CiAgICAgIGNvbnN0IHRib3ggPSAoMCwgX2NvcmVfdXRpbHMucmVhZFVpbnQzMikoZGF0YSwgcG9zaXRpb24gKyA0KTsKICAgICAgcG9zaXRpb24gKz0gaGVhZGVyU2l6ZTsKICAgICAgaWYgKGxib3ggPT09IDEpIHsKICAgICAgICBsYm94ID0gKDAsIF9jb3JlX3V0aWxzLnJlYWRVaW50MzIpKGRhdGEsIHBvc2l0aW9uKSAqIDQyOTQ5NjcyOTYgKyAoMCwgX2NvcmVfdXRpbHMucmVhZFVpbnQzMikoZGF0YSwgcG9zaXRpb24gKyA0KTsKICAgICAgICBwb3NpdGlvbiArPSA4OwogICAgICAgIGhlYWRlclNpemUgKz0gODsKICAgICAgfQogICAgICBpZiAobGJveCA9PT0gMCkgewogICAgICAgIGxib3ggPSBsZW5ndGggLSBwb3NpdGlvbiArIGhlYWRlclNpemU7CiAgICAgIH0KICAgICAgaWYgKGxib3ggPCBoZWFkZXJTaXplKSB7CiAgICAgICAgdGhyb3cgbmV3IEpweEVycm9yKCJJbnZhbGlkIGJveCBmaWVsZCBzaXplIik7CiAgICAgIH0KICAgICAgY29uc3QgZGF0YUxlbmd0aCA9IGxib3ggLSBoZWFkZXJTaXplOwogICAgICBsZXQganVtcERhdGFMZW5ndGggPSB0cnVlOwogICAgICBzd2l0Y2ggKHRib3gpIHsKICAgICAgICBjYXNlIDB4NmE3MDMyNjg6CiAgICAgICAgICBqdW1wRGF0YUxlbmd0aCA9IGZhbHNlOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAweDYzNmY2YzcyOgogICAgICAgICAgY29uc3QgbWV0aG9kID0gZGF0YVtwb3NpdGlvbl07CiAgICAgICAgICBpZiAobWV0aG9kID09PSAxKSB7CiAgICAgICAgICAgIGNvbnN0IGNvbG9yc3BhY2UgPSAoMCwgX2NvcmVfdXRpbHMucmVhZFVpbnQzMikoZGF0YSwgcG9zaXRpb24gKyAzKTsKICAgICAgICAgICAgc3dpdGNoIChjb2xvcnNwYWNlKSB7CiAgICAgICAgICAgICAgY2FzZSAxNjoKICAgICAgICAgICAgICBjYXNlIDE3OgogICAgICAgICAgICAgIGNhc2UgMTg6CiAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKCJVbmtub3duIGNvbG9yc3BhY2UgIiArIGNvbG9yc3BhY2UpOwogICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0gZWxzZSBpZiAobWV0aG9kID09PSAyKSB7CiAgICAgICAgICAgICgwLCBfdXRpbC5pbmZvKSgiSUNDIHByb2ZpbGUgbm90IHN1cHBvcnRlZCIpOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAweDZhNzAzMjYzOgogICAgICAgICAgdGhpcy5wYXJzZUNvZGVzdHJlYW0oZGF0YSwgcG9zaXRpb24sIHBvc2l0aW9uICsgZGF0YUxlbmd0aCk7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIDB4NmE1MDIwMjA6CiAgICAgICAgICBpZiAoKDAsIF9jb3JlX3V0aWxzLnJlYWRVaW50MzIpKGRhdGEsIHBvc2l0aW9uKSAhPT0gMHgwZDBhODcwYSkgewogICAgICAgICAg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+PiAwOwogICAgICAgIGNvbnN0IFlzaXogPSBzdHJlYW0uZ2V0SW50MzIoKSA+Pj4gMDsKICAgICAgICBjb25zdCBYT3NpeiA9IHN0cmVhbS5nZXRJbnQzMigpID4+PiAwOwogICAgICAgIGNvbnN0IFlPc2l6ID0gc3RyZWFtLmdldEludDMyKCkgPj4+IDA7CiAgICAgICAgc3RyZWFtLnNraXAoMTYpOwogICAgICAgIGNvbnN0IENzaXogPSBzdHJlYW0uZ2V0VWludDE2KCk7CiAgICAgICAgdGhpcy53aWR0aCA9IFhzaXogLSBYT3NpejsKICAgICAgICB0aGlzLmhlaWdodCA9IFlzaXogLSBZT3NpejsKICAgICAgICB0aGlzLmNvbXBvbmVudHNDb3VudCA9IENzaXo7CiAgICAgICAgdGhpcy5iaXRzUGVyQ29tcG9uZW50ID0gODsKICAgICAgICByZXR1cm47CiAgICAgIH0KICAgIH0KICAgIHRocm93IG5ldyBKcHhFcnJvcigiTm8gc2l6ZSBtYXJrZXIgZm91bmQgaW4gSlBYIHN0cmVhbSIpOwogIH0KICBwYXJzZUNvZGVzdHJlYW0oZGF0YSwgc3RhcnQsIGVuZCkgewogICAgY29uc3QgY29udGV4dCA9IHt9OwogICAgbGV0IGRvTm90UmVjb3ZlciA9IGZhbHNlOwogICAgdHJ5IHsKICAgICAgbGV0IHBvc2l0aW9uID0gc3RhcnQ7CiAgICAgIHdoaWxlIChwb3NpdGlvbiArIDEgPCBlbmQpIHsKICAgICAgICBjb25zdCBjb2RlID0gKDAsIF9jb3JlX3V0aWxzLnJlYWRVaW50MTYpKGRhdGEsIHBvc2l0aW9uKTsKICAgICAgICBwb3NpdGlvbiArPSAyOwogICAgICAgIGxldCBsZW5ndGggPSAwLAogICAgICAgICAgaiwKICAgICAgICAgIHNxY2QsCiAgICAgICAgICBzcHFjZHMsCiAgICAgICAgICBzcHFjZFNpemUsCiAgICAgICAgICBzY2FsYXJFeHBvdW5kZWQsCiAgICAgICAgICB0aWxlOwogICAgICAgIHN3aXRjaCAoY29kZSkgewogICAgICAgICAgY2FzZSAweGZmNGY6CiAgICAgICAgICAgIGNvbnRleHQubWFpbkhlYWRlciA9IHRydWU7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAweGZmZDk6CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAweGZmNTE6CiAgICAgICAgICAgIGxlbmd0aCA9ICgwLCBfY29yZV91dGlscy5yZWFkVWludDE2KShkYXRhLCBwb3NpdGlvbik7CiAgICAgICAgICAgIGNvbnN0IHNpeiA9IHt9OwogICAgICAgICAgICBzaXouWHNpeiA9ICgwLCBfY29yZV91dGlscy5yZWFkVWludDMyKShkYXRhLCBwb3NpdGlvbiArIDQpOwogICAgICAgICAgICBzaXouWXNpeiA9ICgwLCBfY29yZV91dGlscy5yZWFkVWludDMyKShkYXRhLCBwb3NpdGlvbiArIDgpOwogICAgICAgICAgICBzaXouWE9zaXogPSAoMCwgX2NvcmVfdXRpbHMucmVhZFVpbnQzMikoZGF0YSwgcG9zaXRpb24gKyAxMik7CiAgICAgICAgICAgIHNpei5ZT3NpeiA9ICgwLCBfY29yZV91dGlscy5yZWFkVWludDMyKShkYXRhLCBwb3NpdGlvbiArIDE2KTsKICAgICAgICAgICAgc2l6LlhUc2l6ID0gKDAsIF9jb3JlX3V0aWxzLnJlYWRVaW50MzIpKGRhdGEsIHBvc2l0aW9uICsgMjApOwogICAgICAgICAgICBzaXouWVRzaXogPSAoMCwgX2NvcmVfdXRpbHMucmVhZFVpbnQzMikoZGF0YSwgcG9zaXRpb24gKyAyNCk7CiAgICAgICAgICAgIHNpei5YVE9zaXogPSAoMCwgX2NvcmVfdXRpbHMucmVhZFVpbnQzMikoZGF0YSwgcG9zaXRpb24gKyAyOCk7CiAgICAgICAgICAgIHNpei5ZVE9zaXogPSAoMCwgX2NvcmVfdXRpbHMucmVhZFVpbnQzMikoZGF0YSwgcG9zaXRpb24gKyAzMik7CiAgICAgICAgICAgIGNvbnN0IGNvbXBvbmVudHNDb3VudCA9ICgwLCBfY29yZV91dGlscy5yZWFkVWludDE2KShkYXRhLCBwb3NpdGlvbiArIDM2KTsKICAgICAgICAgICAgc2l6LkNzaXogPSBjb21wb25lbnRzQ291bnQ7CiAgICAgICAgICAgIGNvbnN0IGNvbXBvbmVudHMgPSBbXTsKICAgICAgICAgICAgaiA9IHBvc2l0aW9uICsgMzg7CiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgY29tcG9uZW50c0NvdW50OyBpKyspIHsKICAgICAgICAgICAgICBjb25zdCBjb21wb25lbnQgPSB7CiAgICAgICAgICAgICAgICBwcmVjaXNpb246IChkYXRhW2pdICYgMHg3ZikgKyAxLAogICAgICAgICAgICAgICAgaXNTaWduZWQ6ICEhKGRhdGFbal0gJiAweDgwKSwKICAgICAgICAgICAgICAgIFhSc2l6OiBkYXRhW2ogKyAxXSwKICAgICAgICAgICAgICAgIFlSc2l6OiBkYXRhW2ogKyAyXQogICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgaiArPSAzOwogICAgICAgICAgICAgIGNhbGN1bGF0ZUNvbXBvbmVudERpbWVuc2lvbnMoY29tcG9uZW50LCBzaXopOwogICAgICAgICAgICAgIGNvbXBvbmVudHMucHVzaChjb21wb25lbnQpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGNvbnRleHQuU0laID0gc2l6OwogICAgICAgICAgICBjb250ZXh0LmNvbXBvbmVudHMgPSBjb21wb25lbnRzOwogICAgICAgICAgICBjYWxjdWxhdGVUaWxlR3JpZHMoY29udGV4dCwgY29tcG9uZW50cyk7CiAgICAgICAgICAgIGNvbnRleHQuUUNDID0gW107CiAgICAgICAgICAgIGNvbnRleHQuQ09DID0gW107CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAweGZmNWM6CiAgICAgICAgICAgIGxlbmd0aCA9ICgwLCBfY29yZV91dGlscy5yZWFkVWludDE2KShkYXRhLCBwb3NpdGlvbik7CiAgICAgICAgICAgIGNvbnN0IHFjZCA9IHt9OwogICAgICAgICAgICBqID0gcG9zaXRpb24gKyAyOwogICAgICAgICAgICBzcWNkID0gZGF0YVtqKytdOwogICAgICAgICAgICBzd2l0Y2ggKHNxY2QgJiAweDFmKSB7CiAgICAgICAgICAgICAgY2FzZSAwOgogICAgICAgICAgICAgICAgc3BxY2RTaXplID0gODsKICAgICAgICAgICAgICAgIHNjYWxhckV4cG91bmRlZCA9IHRydWU7CiAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICBjYXNlIDE6CiAgICAgICAgICAgICAgICBzcHFjZFNpemUgPSAxNjsKICAgICAgICAgICAgICAgIHNjYWxhckV4cG91bmRlZCA9IGZhbHNlOwogICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgY2FzZSAyOgogICAgICAgICAgICAgICAgc3BxY2RTaXplID0gMTY7CiAgICAgICAgICAgICAgICBzY2FsYXJFeHBvdW5kZWQgPSB0cnVlOwogICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcigiSW52YWxpZCBTUWNkIHZhbHVlICIgKyBzcWNkKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBxY2Qubm9RdWFudGl6YXRpb24gPSBzcHFjZFNpemUgPT09IDg7CiAgICAgICAgICAgIHFjZC5zY2FsYXJFeHBvdW5kZWQgPSBzY2FsYXJFeHBvdW5kZWQ7CiAgICAgICAgICAgIHFjZC5ndWFyZEJpdHMgPSBzcWNkID4+IDU7CiAgICAgICAgICAgIHNwcWNkcyA9IFtdOwogICAgICAgICAgICB3aGlsZSAoaiA8IGxlbmd0aCArIHBvc2l0aW9uKSB7CiAgICAgICAgICAgICAgY29uc3Qgc3BxY2QgPSB7fTsKICAgICAgICAgICAgICBpZiAoc3BxY2RTaXplID09PSA4KSB7CiAgICAgICAgICAgICAgICBzcHFjZC5lcHNpbG9uID0gZGF0YVtqKytdID4+IDM7CiAgICAgICAgICAgICAgICBzcHFjZC5tdSA9IDA7CiAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgIHNwcWNkLmVwc2lsb24gPSBkYXRhW2pdID4+IDM7CiAgICAgICAgICAgICAgICBzcHFjZC5tdSA9IChkYXRhW2pdICYgMHg3KSA8PCA4IHwgZGF0YVtqICsgMV07CiAgICAgICAgICAgICAgICBqICs9IDI7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIHNwcWNkcy5wdXNoKHNwcWNkKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBxY2QuU1BxY2RzID0gc3BxY2RzOwogICAgICAgICAgICBpZiAoY29udGV4dC5tYWluSGVhZGVyKSB7CiAgICAgICAgICAgICAgY29udGV4dC5RQ0QgPSBxY2Q7CiAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgY29udGV4dC5jdXJyZW50VGlsZS5RQ0QgPSBxY2Q7CiAgICAgICAgICAgICAgY29udGV4dC5jdXJyZW50VGlsZS5RQ0MgPSBbXTsKICAgICAgICAgICAgfQogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgMHhmZjVkOgogICAgICAgICAgICBsZW5ndGggPSAoMCwgX2NvcmVfdXRpbHMucmVhZFVpbnQxNikoZGF0YSwgcG9zaXRpb24pOwogICAgICAgICAgICBjb25zdCBxY2MgPSB7fTsKICAgICAgICAgICAgaiA9IHBvc2l0aW9uICsgMjsKICAgICAgICAgICAgbGV0IGNxY2M7CiAgICAgICAgICAgIGlmIChjb250ZXh0LlNJWi5Dc2l6IDwgMjU3KSB7CiAgICAgICAgICAgICAgY3FjYyA9IGRhdGFbaisrXTsKICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICBjcWNjID0gKDAsIF9jb3JlX3V0aWxzLnJlYWRVaW50MTYpKGRhdGEsIGopOwogICAgICAgICAgICAgIGogKz0gMjsKICAgICAgICAgICAgfQogICAgICAgICAgICBzcWNkID0gZGF0YVtqKytdOwogICAgICAgICAgICBzd2l0Y2ggKHNxY2QgJiAweDFmKSB7CiAgICAgICAgICAgICAgY2FzZSAwOgogICAgICAgICAgICAgICAgc3BxY2RTaXplID0gODsKICAgICAgICAgICAgICAgIHNjYWxhckV4cG91bmRlZCA9IHRydWU7CiAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICBjYXNlIDE6CiAgICAgICAgICAgICAgICBzcHFjZFNpemUgPSAxNjsKICAgICAgICAgICAgICAgIHNjYWxhckV4cG91bmRlZCA9IGZhbHNlOwogICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgY2FzZSAyOgogICAgICAgICAgICAgICAgc3BxY2RTaXplID0gMTY7CiAgICAgICAgICAgICAgICBzY2FsYXJFeHBvdW5kZWQgPSB0cnVlOwogICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcigiSW52YWxpZCBTUWNkIHZhbHVlICIgKyBzcWNkKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBxY2Mubm9RdWFudGl6YXRpb24gPSBzcHFjZFNpemUgPT09IDg7CiAgICAgICAgICAgIHFjYy5zY2FsYXJFeHBvdW5kZWQgPSBzY2FsYXJFeHBvdW5kZWQ7CiAgICAgICAgICAgIHFjYy5ndWFyZEJpdHMgPSBzcWNkID4+IDU7CiAgICAgICAgICAgIHNwcWNkcyA9IFtdOwogICAgICAgICAgICB3aGlsZSAoaiA8IGxlbmd0aCArIHBvc2l0aW9uKSB7CiAgICAgICAgICAgICAgY29uc3Qgc3BxY2QgPSB7fTsKICAgICAgICAgICAgICBpZiAoc3BxY2RTaXplID09PSA4KSB7CiAgICAgICAgICAgICAgICBzcHFjZC5lcHNpbG9uID0gZGF0YVtqKytdID4+IDM7CiAgICAgICAgICAgICAgICBzcHFjZC5tdSA9IDA7CiAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgIHNwcWNkLmVwc2lsb24gPSBkYXRhW2pdID4+IDM7CiAgICAgICAgICAgICAgICBzcHFjZC5tdSA9IChkYXRhW2pdICYgMHg3KSA8PCA4IHwgZGF0YVtqICsgMV07CiAgICAgICAgICAgICAgICBqICs9IDI7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIHNwcWNkcy5wdXNoKHNwcWNkKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBxY2MuU1BxY2RzID0gc3BxY2RzOwogICAgICAgICAgICBpZiAoY29udGV4dC5tYWluSGVhZGVyKSB7CiAgICAgICAgICAgICAgY29udGV4dC5RQ0NbY3FjY10gPSBxY2M7CiAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgY29udGV4dC5jdXJyZW50VGlsZS5RQ0NbY3FjY10gPSBxY2M7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIDB4ZmY1MjoKICAgICAgICAgICAgbGVuZ3RoID0gKDAsIF9jb3JlX3V0aWxzLnJlYWRVaW50MTYpKGRhdGEsIHBvc2l0aW9uKTsKICAgICAgICAgICAgY29uc3QgY29kID0ge307CiAgICAgICAgICAgIGogPSBwb3NpdGlvbiArIDI7CiAgICAgICAgICAgIGNvbnN0IHNjb2QgPSBkYXRhW2orK107CiAgICAgICAgICAgIGNvZC5lbnRyb3B5Q29kZXJXaXRoQ3VzdG9tUHJlY2luY3RzID0gISEoc2NvZCAmIDEpOwogICAgICAgICAgICBjb2Quc29wTWFya2VyVXNlZCA9ICEhKHNjb2QgJiAyKTsKICAgICAgICAgICAgY29kLmVwaE1hcmtlclVzZWQgPSAhIShzY29kICYgNCk7CiAgICAgICAgICAgIGNvZC5wcm9ncmVzc2lvbk9yZGVyID0gZGF0YVtqKytdOwogICAgICAgICAgICBjb2QubGF5ZXJzQ291bnQgPSAoMCwgX2NvcmVfdXRpbHMucmVhZFVpbnQxNikoZGF0YSwgaik7CiAgICAgICAgICAgIGogKz0gMjsKICAgICAgICAgICAgY29kLm11bHRpcGxlQ29tcG9uZW50VHJhbnNmb3JtID0gZGF0YVtqKytdOwogICAgICAgICAgICBjb2QuZGVjb21wb3NpdGlvbkxldmVsc0NvdW50ID0gZGF0YVtqKytdOwogICAgICAgICAgICBjb2QueGNiID0gKGRhdGFbaisrXSAmIDB4ZikgKyAyOwogICAgICAgICAgICBjb2QueWNiID0gKGRhdGFbaisrXSAmIDB4ZikgKyAyOwogICAgICAgICAgICBjb25zdCBibG9ja1N0eWxlID0gZGF0YVtqKytdOwogICAgICAgICAgICBjb2Quc2VsZWN0aXZlQXJpdGhtZXRpY0NvZGluZ0J5cGFzcyA9ICEhKGJsb2NrU3R5bGUgJiAxKTsKICAgICAgICAgICAgY29kLnJlc2V0Q29udGV4dFByb2JhYmlsaXRpZXMgPSAhIShibG9ja1N0eWxlICYgMik7CiAgICAgICAgICAgIGNvZC50ZXJtaW5hdGlvbk9uRWFjaENvZGluZ1Bhc3MgPSAhIShibG9ja1N0eWxlICYgNCk7CiAgICAgICAgICAgIGNvZC52ZXJ0aWNhbGx5U3RyaXBlID0gISEoYmxvY2tTdHlsZSAmIDgpOwogICAgICAgICAgICBjb2QucHJlZGljdGFibGVUZXJtaW5hdGlvbiA9ICEhKGJsb2NrU3R5bGUgJiAxNik7CiAgICAgICAgICAgIGNvZC5zZWdtZW50YXRpb25TeW1ib2xVc2VkID0gISEoYmxvY2tTdHlsZSAmIDMyKTsKICAgICAgICAgICAgY29kLnJldmVyc2libGVUcmFuc2Zvcm1hdGlvbiA9IGRhdGFbaisrXTsKICAgICAgICAgICAgaWYgKGNvZC5lbnRyb3B5Q29kZXJXaXRoQ3VzdG9tUHJlY2luY3RzKSB7CiAgICAgICAgICAgICAgY29uc3QgcHJlY2luY3RzU2l6ZXMgPSBbXTsKICAgICAgICAgICAgICB3aGlsZSAoaiA8IGxlbmd0aCArIHBvc2l0aW9uKSB7CiAgICAgICAgICAgICAgICBjb25zdCBwcmVjaW5jdHNTaXplID0gZGF0YVtqKytdOwogICAgICAgICAgICAgICAgcHJlY2luY3RzU2l6ZXMucHVzaCh7CiAgICAgICAgICAgICAgICAgIFBQeDogcHJlY2luY3RzU2l6ZSAmIDB4ZiwKICAgICAgICAgICAgICAgICAgUFB5OiBwcmVjaW5jdHNTaXplID4+IDQKICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBjb2QucHJlY2luY3RzU2l6ZXMgPSBwcmVjaW5jdHNTaXplczsKICAgICAgICAgICAgfQogICAgICAgICAgICBjb25zdCB1bnN1cHBvcnRlZCA9IFtdOwogICAgICAgICAgICBpZiAoY29kLnNlbGVjdGl2ZUFyaXRobWV0aWNDb2RpbmdCeXBhc3MpIHsKICAgICAgICAgICAgICB1bnN1cHBvcnRlZC5wdXNoKCJzZWxlY3RpdmVBcml0aG1ldGljQ29kaW5nQnlwYXNzIik7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaWYgKGNvZC50ZXJtaW5hdGlvbk9uRWFjaENvZGluZ1Bhc3MpIHsKICAgICAgICAgICAgICB1bnN1cHBvcnRlZC5wdXNoKCJ0ZXJtaW5hdGlvbk9uRWFjaENvZGluZ1Bhc3MiKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAoY29kLnZlcnRpY2FsbHlTdHJpcGUpIHsKICAgICAgICAgICAgICB1bnN1cHBvcnRlZC5wdXNoKCJ2ZXJ0aWNhbGx5U3RyaXBlIik7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaWYgKGNvZC5wcmVkaWN0YWJsZVRlcm1pbmF0aW9uKSB7CiAgICAgICAgICAgICAgdW5zdXBwb3J0ZWQucHVzaCgicHJlZGljdGFibGVUZXJtaW5hdGlvbiIpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmICh1bnN1cHBvcnRlZC5sZW5ndGggPiAwKSB7CiAgICAgICAgICAgICAgZG9Ob3RSZWNvdmVyID0gdHJ1ZTsKICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYEpQWDogVW5zdXBwb3J0ZWQgQ09EIG9wdGlvbnMgKCR7dW5zdXBwb3J0ZWQuam9pbigiLCAiKX0pLmApOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmIChjb250ZXh0Lm1haW5IZWFkZXIpIHsKICAgICAgICAgICAgICBjb250ZXh0LkNPRCA9IGNvZDsKICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICBjb250ZXh0LmN1cnJlbnRUaWxlLkNPRCA9IGNvZDsKICAgICAgICAgICAgICBjb250ZXh0LmN1cnJlbnRUaWxlLkNPQyA9IFtdOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAweGZmOTA6CiAgICAgICAgICAgIGxlbmd0aCA9ICgwLCBfY29yZV91dGlscy5yZWFkVWludDE2KShkYXRhLCBwb3NpdGlvbik7CiAgICAgICAgICAgIHRpbGUgPSB7fTsKICAgICAgICAgICAgdGlsZS5pbmRleCA9ICgwLCBfY29yZV91dGlscy5yZWFkVWludDE2KShkYXRhLCBwb3NpdGlvbiArIDIpOwogICAgICAgICAgICB0aWxlLmxlbmd0aCA9ICgwLCBfY29yZV91dGlscy5yZWFkVWludDMyKShkYXRhLCBwb3NpdGlvbiArIDQpOwogICAgICAgICAgICB0aWxlLmRhdGFFbmQgPSB0aWxlLmxlbmd0aCArIHBvc2l0aW9uIC0gMjsKICAgICAgICAgICAgdGlsZS5wYXJ0SW5kZXggPSBkYXRhW3Bvc2l0aW9uICsgOF07CiAgICAgICAgICAgIHRpbGUucGFydHNDb3VudCA9IGRhdGFbcG9zaXRpb24gKyA5XTsKICAgICAgICAgICAgY29udGV4dC5tYWluSGVhZGVyID0gZmFsc2U7CiAgICAgICAgICAgIGlmICh0aWxlLnBhcnRJbmRleCA9PT0gMCkgewogICAgICAgICAgICAgIHRpbGUuQ09EID0gY29udGV4dC5DT0Q7CiAgICAgICAgICAgICAgdGlsZS5DT0MgPSBjb250ZXh0LkNPQy5zbGljZSgwKTsKICAgICAgICAgICAgICB0aWxlLlFDRCA9IGNvbnRleHQuUUNEOwogICAgICAgICAgICAgIHRpbGUuUUNDID0gY29udGV4dC5RQ0Muc2xpY2UoMCk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgY29udGV4dC5jdXJyZW50VGlsZSA9IHRpbGU7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAweGZmOTM6CiAgICAgICAgICAgIHRpbGUgPSBjb250ZXh0LmN1cnJlbnRUaWxlOwogICAgICAgICAgICBpZiAodGlsZS5wYXJ0SW5kZXggPT09IDApIHsKICAgICAgICAgICAgICBpbml0aWFsaXplVGlsZShjb250ZXh0LCB0aWxlLmluZGV4KTsKICAgICAgICAgICAgICBidWlsZFBhY2tldHMoY29udGV4dCk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgbGVuZ3RoID0gdGlsZS5kYXRhRW5kIC0gcG9zaXRpb247CiAgICAgICAgICAgIHBhcnNlVGlsZVBhY2tldHMoY29udGV4dCwgZGF0YSwgcG9zaXRpb24sIGxlbmd0aCk7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAweGZmNTM6CiAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKSgiSlBYOiBDb2Rlc3RyZWFtIGNvZGUgMHhGRjUzIChDT0MpIGlzIG5vdCBpbXBsZW1lbnRlZC4iKTsKICAgICAgICAgIGNhc2UgMHhmZjU1OgogICAgICAgICAgY2FzZSAweGZmNTc6CiAgICAgICAgICBjYXNlIDB4ZmY1ODoKICAgICAgICAgIGNhc2UgMHhmZjY0OgogICAgICAgICAgICBsZW5ndGggPSAoMCwgX2NvcmVfdXRpbHMucmVhZFVpbnQxNikoZGF0YSwgcG9zaXRpb24pOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcigiVW5rbm93biBjb2Rlc3RyZWFtIG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YngxICsgY29kZWJsb2NrV2lkdGggLSAxID4+IHhjYl87CiAgY29uc3QgY2J5MSA9IHN1YmJhbmQudGJ5MSArIGNvZGVibG9ja0hlaWdodCAtIDEgPj4geWNiXzsKICBjb25zdCBwcmVjaW5jdFBhcmFtZXRlcnMgPSBzdWJiYW5kLnJlc29sdXRpb24ucHJlY2luY3RQYXJhbWV0ZXJzOwogIGNvbnN0IGNvZGVibG9ja3MgPSBbXTsKICBjb25zdCBwcmVjaW5jdHMgPSBbXTsKICBsZXQgaSwgaiwgY29kZWJsb2NrLCBwcmVjaW5jdE51bWJlcjsKICBmb3IgKGogPSBjYnkwOyBqIDwgY2J5MTsgaisrKSB7CiAgICBmb3IgKGkgPSBjYngwOyBpIDwgY2J4MTsgaSsrKSB7CiAgICAgIGNvZGVibG9jayA9IHsKICAgICAgICBjYng6IGksCiAgICAgICAgY2J5OiBqLAogICAgICAgIHRieDA6IGNvZGVibG9ja1dpZHRoICogaSwKICAgICAgICB0YnkwOiBjb2RlYmxvY2tIZWlnaHQgKiBqLAogICAgICAgIHRieDE6IGNvZGVibG9ja1dpZHRoICogKGkgKyAxKSwKICAgICAgICB0YnkxOiBjb2RlYmxvY2tIZWlnaHQgKiAoaiArIDEpCiAgICAgIH07CiAgICAgIGNvZGVibG9jay50YngwXyA9IE1hdGgubWF4KHN1YmJhbmQudGJ4MCwgY29kZWJsb2NrLnRieDApOwogICAgICBjb2RlYmxvY2sudGJ5MF8gPSBNYXRoLm1heChzdWJiYW5kLnRieTAsIGNvZGVibG9jay50YnkwKTsKICAgICAgY29kZWJsb2NrLnRieDFfID0gTWF0aC5taW4oc3ViYmFuZC50YngxLCBjb2RlYmxvY2sudGJ4MSk7CiAgICAgIGNvZGVibG9jay50YnkxXyA9IE1hdGgubWluKHN1YmJhbmQudGJ5MSwgY29kZWJsb2NrLnRieTEpOwogICAgICBjb25zdCBwaSA9IE1hdGguZmxvb3IoKGNvZGVibG9jay50YngwXyAtIHN1YmJhbmQudGJ4MCkgLyBwcmVjaW5jdFBhcmFtZXRlcnMucHJlY2luY3RXaWR0aEluU3ViYmFuZCk7CiAgICAgIGNvbnN0IHBqID0gTWF0aC5mbG9vcigoY29kZWJsb2NrLnRieTBfIC0gc3ViYmFuZC50YnkwKSAvIHByZWNpbmN0UGFyYW1ldGVycy5wcmVjaW5jdEhlaWdodEluU3ViYmFuZCk7CiAgICAgIHByZWNpbmN0TnVtYmVyID0gcGkgKyBwaiAqIHByZWNpbmN0UGFyYW1ldGVycy5udW1wcmVjaW5jdHN3aWRlOwogICAgICBjb2RlYmxvY2sucHJlY2luY3ROdW1iZXIgPSBwcmVjaW5jdE51bWJlcjsKICAgICAgY29kZWJsb2NrLnN1YmJhbmRUeXBlID0gc3ViYmFuZC50eXBlOwogICAgICBjb2RlYmxvY2suTGJsb2NrID0gMzsKICAgICAgaWYgKGNvZGVibG9jay50YngxXyA8PSBjb2RlYmxvY2sudGJ4MF8gfHwgY29kZWJsb2NrLnRieTFfIDw9IGNvZGVibG9jay50YnkwXykgewogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGNvZGVibG9ja3MucHVzaChjb2RlYmxvY2spOwogICAgICBsZXQgcHJlY2luY3QgPSBwcmVjaW5jdHNbcHJlY2luY3ROdW1iZXJdOwogICAgICBpZiAocHJlY2luY3QgIT09IHVuZGVmaW5lZCkgewogICAgICAgIGlmIChpIDwgcHJlY2luY3QuY2J4TWluKSB7CiAgICAgICAgICBwcmVjaW5jdC5jYnhNaW4gPSBpOwogICAgICAgIH0gZWxzZSBpZiAoaSA+IHByZWNpbmN0LmNieE1heCkgewogICAgICAgICAgcHJlY2luY3QuY2J4TWF4ID0gaTsKICAgICAgICB9CiAgICAgICAgaWYgKGogPCBwcmVjaW5jdC5jYnlNaW4pIHsKICAgICAgICAgIHByZWNpbmN0LmNieE1pbiA9IGo7CiAgICAgICAgfSBlbHNlIGlmIChqID4gcHJlY2luY3QuY2J5TWF4KSB7CiAgICAgICAgICBwcmVjaW5jdC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sKyspIHsKICAgICAgZm9yICg7IHIgPD0gbWF4RGVjb21wb3NpdGlvbkxldmVsc0NvdW50OyByKyspIHsKICAgICAgICBmb3IgKDsgaSA8IGNvbXBvbmVudHNDb3VudDsgaSsrKSB7CiAgICAgICAgICBjb25zdCBjb21wb25lbnQgPSB0aWxlLmNvbXBvbmVudHNbaV07CiAgICAgICAgICBpZiAociA+IGNvbXBvbmVudC5jb2RpbmdTdHlsZVBhcmFtZXRlcnMuZGVjb21wb3NpdGlvbkxldmVsc0NvdW50KSB7CiAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgfQogICAgICAgICAgY29uc3QgcmVzb2x1dGlvbiA9IGNvbXBvbmVudC5yZXNvbHV0aW9uc1tyXTsKICAgICAgICAgIGNvbnN0IG51bXByZWNpbmN0cyA9IHJlc29sdXRpb24ucHJlY2luY3RQYXJhbWV0ZXJzLm51bXByZWNpbmN0czsKICAgICAgICAgIGZvciAoOyBrIDwgbnVtcHJlY2luY3RzOykgewogICAgICAgICAgICBjb25zdCBwYWNrZXQgPSBjcmVhdGVQYWNrZXQocmVzb2x1dGlvbiwgaywgbCk7CiAgICAgICAgICAgIGsrKzsKICAgICAgICAgICAgcmV0dXJuIHBhY2tldDsKICAgICAgICAgIH0KICAgICAgICAgIGsgPSAwOwogICAgICAgIH0KICAgICAgICBpID0gMDsKICAgICAgfQogICAgICByID0gMDsKICAgIH0KICAgIHRocm93IG5ldyBKcHhFcnJvcigiT3V0IG9mIHBhY2tldHMiKTsKICB9Owp9CmZ1bmN0aW9uIFJlc29sdXRpb25MYXllckNvbXBvbmVudFBvc2l0aW9uSXRlcmF0b3IoY29udGV4dCkgewogIGNvbnN0IHNpeiA9IGNvbnRleHQuU0laOwogIGNvbnN0IHRpbGVJbmRleCA9IGNvbnRleHQuY3VycmVudFRpbGUuaW5kZXg7CiAgY29uc3QgdGlsZSA9IGNvbnRleHQudGlsZXNbdGlsZUluZGV4XTsKICBjb25zdCBsYXllcnNDb3VudCA9IH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gIGZvciAoOyBrIDwgbnVtcHJlY2luY3RzOykgewogICAgICAgICAgICBjb25zdCBwYWNrZXQgPSBjcmVhdGVQYWNrZXQocmVzb2x1dGlvbiwgaywgbCk7CiAgICAgICAgICAgIGsrKzsKICAgICAgICAgICAgcmV0dXJuIHBhY2tldDsKICAgICAgICAgIH0KICAgICAgICAgIGsgPSAwOwogICAgICAgIH0KICAgICAgICBpID0gMDsKICAgICAgfQogICAgICBsID0gMDsKICAgIH0KICAgIHRocm93IG5ldyBKcHhFcnJvcigiT3V0IG9mIHBhY2tldHMiKTsKICB9Owp9CmZ1bmN0aW9uIFJlc29sdXRpb25Qb3NpdGlvbkNvbXBvbmVudExheWVySXRlcmF0b3IoY29udGV4dCkgewogIGNvbnN0IHNpeiA9IGNvbnRleHQuU0laOwogIGNvbnN0IHRpbGVJbmRleCA9IGNvbnRleHQuY3VycmVudFRpbGUuaW5kZXg7CiAgY29uc3QgdGlsZSA9IGNvbnRleHQudGlsZXNbdGlsZUluZGV4XTsKICBjb25zdCBsYXllcnNDb3VudCA9IHRpbGUuY29kaW5nU3R5bGVEZWZhdWx0UGFyYW1ldGVycy5sYXllcnNDb3VudDsKICBjb25zdCBjb21wb25lbnRzQ291bnQgPSBzaXouQ3NpejsKICBsZXQgbCwgciwgYywgcDsKICBsZXQgbWF4RGVjb21wb3NpdGlvbkxldmVsc0NvdW50ID0gMDsKICBmb3IgKGMgPSAwOyBjIDwgY29tcG9uZW50c0NvdW50OyBjKyspIHsKICAgIGNvbnN0IGNvbXBvbmVudCA9IHRpbGUuY29tcG9uZW50c1tjXTsKICAgIG1heERlY29tcG9zaXRpb25MZXZlbHNDb3VudCA9IE1hdGgubWF4KG1heERlY29tcG9zaXRpb25MZXZlbHNDb3VudCwgY29tcG9uZW50LmNvZGluZ1N0eWxlUGFyYW1ldGVycy5kZWNvbXBvc2l0aW9uTGV2ZWxzQ291bnQpOwogIH0KICBjb25zdCBtYXhOdW1QcmVjaW5jdHNJbkxldmVsID0gbm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vbnN0IHJlc29sdXRpb24gPSBjb21wb25lbnQucmVzb2x1dGlvbnNbcl07CiAgICAgICAgICBjb25zdCBudW1wcmVjaW5jdHMgPSByZXNvbHV0aW9uLnByZWNpbmN0UGFyYW1ldGVycy5udW1wcmVjaW5jdHM7CiAgICAgICAgICBpZiAocCA+PSBudW1wcmVjaW5jdHMpIHsKICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICB9CiAgICAgICAgICBmb3IgKDsgbCA8IGxheWVyc0NvdW50OykgewogICAgICAgICAgICBjb25zdCBwYWNrZXQgPSBjcmVhdGVQYWNrZXQocmVzb2x1dGlvbiwgcCwgbCk7CiAgICAgICAgICAgIGwrKzsKICAgICAgICAgICAgcmV0dXJuIHBhY2tldDsKICAgICAgICAgIH0KICAgICAgICAgIGwgPSAwOwogICAgICAgIH0KICAgICAgICBjID0gMDsKICAgICAgfQogICAgICBwID0gMDsKICAgIH0KICAgIHRocm93IG5ldyBKcHhFcnJvcigiT3V0IG9mIHBhY2tldHMiKTsKICB9Owp9CmZ1bmN0aW9uIFBvc2l0aW9uQ29tcG9uZW50UmVzb2x1dGlvbkxheWVySXRlcmF0b3IoY29udGV4dCkgewogIGNvbnN0IHNpeiA9IGNvbnRleHQuU0laOwogIGNvbnN0IHRpbGVJbmRleCA9IGNvbnRleHQuY3VycmVudFRpbGUuaW5kZXg7CiAgY29uc3QgdGlsZSA9IGNvbnRleHQudGlsZXNbdGlsZUluZGV4XTsKICBjb25zdCBsYXllcnNDb3VudCA9IHRpbGUuY29kaW5nU3R5bGVEZWZhdWx0UGFyYW1ldGVycy5sYXllcnNDb3VudDsKICBjb25zdCBjb21wb25lbnRzQ291bnQgPSBzaXouQ3NpejsKICBjb25zdCBwcmVjaW5jdHNTaXplcyA9IGdldFByZWNpbmN0U2l6ZXNJbkltYWdlU2NhbGUodGlsZSk7CiAgY29uc3QgcHJlY2luY3RzSXRlcmF0aW9uU2l6ZXMgPSBwcmVjaW5jdHNTaXplczsKICBsZXQgbCA9IDAsCiAgICByID0gMCwKICAgIGMgPSAwLAogICAgcHggPSAwLAogICAgcHkgPSAwOwogIHRoaXMubmV4dFBhY2tldCA9IGZ1bmN0aW9uIEpweEltYWdlX25leHRQYWNrZXQoKSB7CiAgICBmb3IgKDsgcHkgPCBwcmVjaW5jdHNJdGVyYXRpb25TaXplcy5tYXhOdW1IaWdoOyBweSsrKSB7CiAgICAgIGZvciAoOyBweCA8IHByZWNpbmN0c0l0ZXJhdGlvblNpemVzLm1heE51bVdpZGU7IHB4KyspIHsKICAgICAgICBmb3IgKDsgYyA8IGNvbXBvbmVudHNDb3VudDsgYysrKSB7CiAgICAgICAgICBjb25zdCBjb21wb25lbnQgPSB0aWxlLmNvbXBvbmVudHNbY107CiAgICAgICAgICBjb25zdCBkZWNvbXBvc2l0aW9uTGV2ZWxzQ291bnQgPSBjb21wb25lbnQuY29kaW5nU3R5bGVQYXJhbWV0ZXJzLmRlY29tcG9zaXRpb25MZXZlbHNDb3VudDsKICAgICAgICAgIGZvciAoOyByIDw9IGRlY29tcG9zaXRpb25MZXZlbHNDb3VudDsgcisrKSB7CiAgICAgICAgICAgIGNvbnN0IHJlc29sdXRpb24gPSBjb21wb25lbnQucmVzb2x1dGlvbnNbcl07CiAgICAgICAgICAgIGNvbnN0IHNpemVJbkltYWdlU2NhbGUgPSBwcmVjaW5jdHNTaXplcy5jb21wb25lbnRzW2NdLnJlc29sdXRpb25zW3JdOwogICAgICAgICAgICBjb25zdCBrID0gZ2V0UHJlY2luY3RJbmRleElmRXhpc3QocHgsIHB5LCBzaXplSW5JbWFnZVNjYWxlLCBwcmVjaW5jdHNJdGVyYXRpb25TaXplcywgcmVzb2x1dGlvbik7CiAgICAgICAgICAgIGlmIChrID09PSBudWxsKSB7CiAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZm9yICg7IGwgPCBsYXllcnNDb3VudDspIHsKICAgICAgICAgICAgICBjb25zdCBwYWNrZXQgPSBjcmVhdGVQYWNrZXQocmVzb2x1dGlvbiwgaywgbCk7CiAgICAgICAgICAgICAgbCsrOwogICAgICAgICAgICAgIHJldHVybiBwYWNrZXQ7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgbCA9IDA7CiAgICAgICAgICB9CiAgICAgICAgICByID0gMDsKICAgICAgICB9CiAgICAgICAgYyA9IDA7CiAgICAgIH0KICAgICAgcHggPSAwOwogICAgfQogICAgdGhyb3cgbmV3IEpweEVycm9yKCJPdXQgb2YgcGFja2V0cyIpOwogIH07Cn0KZnVuY3Rpb24gQ29tcG9uZW50UG9zaXRpb25SZXNvbHV0aW9uTGF5ZXJJdGVyYXRvcihjb250ZXh0KSB7CiAgY29uc3Qgc2l6ID0gY29udGV4dC5TSVo7CiAgY29uc3QgdGlsZUluZGV4ID0gY29udGV4dC5jdXJyZW50VGlsZS5pbmRleDsKICBjb25zdCB0aWxlID0gY29udGV4dC50aWxlc1t0aWxlSW5kZXhdOwogIGNvbnN0IGxheWVyc0NvdW50ID0gdGlsZS5jb2RpbmdTdHlsZURlZmF1bHRQYXJhbWV0ZXJzLmxheWVyc0NvdW50OwogIGNvbnN0IGNvbXBvbmVudHNDb3VudCA9IHNpei5Dc2l6OwogIGNvbnN0IHByZWNpbmN0c1NpemVzID0gZ2V0UHJlY2luY3RTaXplc0luSW1hZ2VTY2FsZSh0aWxlKTsKICBsZXQgbCA9IDAsCiAgICByID0gMCwKICAgIGMgPSAwLAogICAgcHggPSAwLAogICAgcHkgPSAwOwogIHRoaXMubmV4dFBhY2tldCA9IGZ1bmN0aW9uIEpweEltYWdlX25leHRQYWNrZXQoKSB7CiAgICBmb3IgKDsgYyA8IGNvbXBvbmVudHNDb3VudDsgKytjKSB7CiAgICAgIGNvbnN0IGNvbXBvbmVudCA9IHRpbGUuY29tcG9uZW50c1tjXTsKICAgICAgY29uc3QgcHJlY2luY3RzSXRlcmF0aW9uU2l6ZXMgPSBwcmVjaW5jdHNTaXplcy5jb21wb25lbnRzW2NdOwogICAgICBjb25zdCBkZWNvbXBvc2l0aW9uTGV2ZWxzQ291bnQgPSBjb21wb25lbnQuY29kaW5nU3R5bGVQYXJhbWV0ZXJzLmRlY29tcG9zaXRpb25MZXZlbHNDb3VudDsKICAgICAgZm9yICg7IHB5IDwgcHJlY2luY3RzSXRlcmF0aW9uU2l6ZXMubWF4TnVtSGlnaDsgcHkrKykgewogICAgICAgIGZvciAoOyBweCA8IHByZWNpbmN0c0l0ZXJhdGlvblNpemVzLm1heE51bVdpZGU7IHB4KyspIHsKICAgICAgICAgIGZvciAoOyByIDw9IGRlY29tcG9zaXRpb25MZXZlbHNDb3VudDsgcisrKSB7CiAgICAgICAgICAgIGNvbnN0IHJlc29sdXRpb24gPSBjb21wb25lbnQucmVzb2x1dGlvbnNbcl07CiAgICAgICAgICAgIGNvbnN0IHNpemVJbkltYWdlU2NhbGUgPSBwcmVjaW5jdHNJdGVyYXRpb25TaXplcy5yZXNvbHV0aW9uc1tyXTsKICAgICAgICAgICAgY29uc3QgayA9IGdldFByZWNpbmN0SW5kZXhJZkV4aXN0KHB4LCBweSwgc2l6ZUluSW1hZ2VTY2FsZSwgcHJlY2luY3RzSXRlcmF0aW9uU2l6ZXMsIHJlc29sdXRpb24pOwogICAgICAgICAgICBpZiAoayA9PT0gbnVsbCkgewogICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGZvciAoOyBsIDwgbGF5ZXJzQ291bnQ7KSB7CiAgICAgICAgICAgICAgY29uc3QgcGFja2V0ID0gY3JlYXRlUGFja2V0KHJlc29sdXRpb24sIGssIGwpOwogICAgICAgICAgICAgIGwrKzsKICAgICAgICAgICAgICByZXR1cm4gcGFja2V0OwogICAgICAgICAgICB9CiAgICAgICAgICAgIGwgPSAwOwogICAgICAgICAgfQogICAgICAgICAgciA9IDA7CiAgICAgICAgfQogICAgICAgIHB4ID0gMDsKICAgICAgfQogICAgICBweSA9IDA7CiAgICB9CiAgICB0aHJvdyBuZXcgS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KGxldCBjID0gMDsgYyA8IGNvbXBvbmVudHNDb3VudDsgYysrKSB7CiAgICBjb25zdCBjb21wb25lbnQgPSB0aWxlLmNvbXBvbmVudHNbY107CiAgICBjb25zdCBkZWNvbXBvc2l0aW9uTGV2ZWxzQ291bnQgPSBjb21wb25lbnQuY29kaW5nU3R5bGVQYXJhbWV0ZXJzLmRlY29tcG9zaXRpb25MZXZlbHNDb3VudDsKICAgIGNvbnN0IHNpemVQZXJSZXNvbHV0aW9uID0gbmV3IEFycmF5KGRlY29tcG9zaXRpb25MZXZlbHNDb3VudCArIDEpOwogICAgbGV0IG1pbldpZHRoQ3VycmVudENvbXBvbmVudCA9IE51bWJlci5NQVhfVkFMVUU7CiAgICBsZXQgbWluSGVpZ2h0Q3VycmVudENvbXBvbmVudCA9IE51bWJlci5NQVhfVkFMVUU7CiAgICBsZXQgbWF4TnVtV2lkZUN1cnJlbnRDb21wb25lbnQgPSAwOwogICAgbGV0IG1heE51bUhpZ2hDdXJyZW50Q29tcG9uZW50ID0gMDsKICAgIGxldCBzY2FsZSA9IDE7CiAgICBmb3IgKGxldCByID0gZGVjb21wb3NpdGlvbkxldmVsc0NvdW50OyByID49IDA7IC0tcikgewogICAgICBjb25zdCByZXNvbHV0aW9uID0gY29tcG9uZW50LnJlc29sdXRpb25zW3JdOwogICAgICBjb25zdCB3aWR0aEN1cnJlbnRSZXNvbHV0aW9uID0gc2NhbGUgKiByZXNvbHV0aW9uLnByZWNpbmN0UGFyYW1ldGVycy5wcmVjaW5jdFdpZHRoOwogICAgICBjb25zdCBoZWlnaHRDdXJyZW50UmVzb2x1dGlvbiA9IHNjYWxlICogcmVzb2x1dGlvbi5wcmVjaW5jdFBhcmFtZXRlcnMucHJlY2luY3RIZWlnaHQ7CiAgICAgIG1pbldpZHRoQ3VycmVudENvbXBvbmVudCA9IE1hdGgubWluKG1pbldpZHRoQ3VycmVudENvbXBvbmVudCwgd2lkdGhDdXJyZW50UmVzb2x1dGlvbik7CiAgICAgIG1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gICAgIG1pbkhlaWdodDogbWluSGVpZ2h0Q3VycmVudENvbXBvbmVudCwKICAgICAgbWF4TnVtV2lkZTogbWF4TnVtV2lkZUN1cnJlbnRDb21wb25lbnQsCiAgICAgIG1heE51bUhpZ2g6IG1heE51bUhpZ2hDdXJyZW50Q29tcG9uZW50CiAgICB9OwogIH0KICByZXR1cm4gewogICAgY29tcG9uZW50czogc2l6ZVBlckNvbXBvbmVudCwKICAgIG1pbldpZHRoLAogICAgbWluSGVpZ2h0LAogICAgbWF4TnVtV2lkZSwKICAgIG1heE51bUhpZ2gKICB9Owp9CmZ1bmN0aW9uIGJ1aWxkUGFja2V0cyhjb250ZXh0KSB7CiAgY29uc3Qgc2l6ID0gY29udGV4dC5TSVo7CiAgY29uc3QgdGlsZUluZGV4ID0gY29udGV4dC5jdXJyZW50VGlsZS5pbmRleDsKICBjb25zdCB0aWxlID0gY29udGV4dC50aWxlc1t0aWxlSW5kZXhdOwogIGNvbnN0IGNvbXBvbmVudHNDb3VudCA9IHNpei5Dc2l6OwogIGZvciAobGV0IGMgPSAwOyBjIDwgY29tcG9uZW50c0NvdW50OyBjKyspIHsKICAgIGNvbnN0IGNvbXBvbmVudCA9IHRpbGUuY29tcG9uZW50c1tjXTsKICAgIGNvbnN0IGRlY29tcG9zaXRpb25MZXZlbHNDb3VudCA9IGNvbXBvbmVudC5jb2RpbmdTdHlsZVBhcmFtZXRlcnMuZGVjb21wb3NpdGlvbkxldmVsc0NvdW50OwogICAgY29uc3QgcmVzb2x1dGlvbnMgPSBbXTsKICAgIGNvbnN0IHN1YmJhbmRzID0gW107CiAgICBmb3IgKGxldCByID0gMDsgciA8PSBkZWNvbXBvc2l0aW9uTGV2ZWxzQ291bnQ7IHIrKykgewogICAgICBjb25zdCBibG9ja3NEaW1lbnNpb25zID0gZ2V0QmxvY2tzRGltZW5zaW9ucyhjb250ZXh0LCBjb21wb25lbnQsIHIpOwogICAgICBjb25zdCByZXNvbHV0aW9uID0ge307CiAgICAgIGNv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wogICAgICAgIHN1YmJhbmRzLnB1c2goc3ViYmFuZCk7CiAgICAgICAgcmVzb2x1dGlvbi5zdWJiYW5kcyA9IFtzdWJiYW5kXTsKICAgICAgfSBlbHNlIHsKICAgICAgICBjb25zdCBic2NhbGUgPSAxIDw8IGRlY29tcG9zaXRpb25MZXZlbHNDb3VudCAtIHIgKyAxOwogICAgICAgIGNvbnN0IHJlc29sdXRpb25TdWJiYW5kcyA9IFtdOwogICAgICAgIHN1YmJhbmQgPSB7fTsKICAgICAgICBzdWJiYW5kLnR5cGUgPSAiSEwiOwogICAgICAgIHN1YmJhbmQudGJ4MCA9IE1hdGguY2VpbChjb21wb25lbnQudGN4MCAvIGJzY2FsZSAtIDAuNSk7CiAgICAgICAgc3ViYmFuZC50YnkwID0gTWF0aC5jZWlsKGNvbXBvbmVudC50Y3kwIC8gYnNjYWxlKTsKICAgICAgICBzdWJiYW5kLnRieDEgPSBNYXRoLmNlaWwoY29tcG9uZW50LnRjeDEgLyBic2NhbGUgLSAwLjUpOwogICAgICAgIHN1YmJhbmQudGJ5MSA9IE1hdGguY2VpbChjb21wb25lbnQudGN5MSAvIGJzY2FsZSk7CiAgICAgICAgc3ViYmFuZC5yZXNvbHV0aW9uID0gcmVzb2x1dGlvbjsKICAgICAgICBidWlsZENvZGVibG9ja3MoY29udGV4dCwgc3ViYmFuZCwgYmxvY2tzRGltZW5zaW9ucyk7CiAgICAgICAgc3ViYmFuZHMucHVzaChzdWJiYW5kKTsKICAgICAgICByZXNvbHV0aW9uU3ViYmFuZHMucHVzaChzdWJiYW5kKTsKICAgICAgICBzdWJiYW5kID0ge307CiAgICAgICAgc3ViYmFuZC50eXBlID0gIkxIIjsKICAgICAgICBzdWJiYW5kLnRieDAgPSBNYXRoLmNlaWwoY29tcG9uZW50LnRjeDAgLyBic2NhbGUpOwogICAgICAgIHN1YmJhbmQudGJ5MCA9IE1hdGguY2VpbChjb21wb25lbnQudGN5MCAvIGJzY2FsZSAtIDAuNSk7CiAgICAg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AgICAgICAgcHJlY2luY3QgPSBjb2RlYmxvY2sucHJlY2luY3Q7CiAgICAgICAgbGV0IGluY2x1c2lvblRyZWU7CiAgICAgICAgaWYgKHByZWNpbmN0LmluY2x1c2lvblRyZWUgIT09IHVuZGVmaW5lZCkgewogICAgICAgICAgaW5jbHVzaW9uVHJlZSA9IHByZWNpbmN0LmluY2x1c2lvblRyZWU7CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIGNvbnN0IHdpZHRoID0gcHJlY2luY3QuY2J4TWF4IC0gcHJlY2luY3QuY2J4TWluICsgMTsKICAgICAgICAgIGNvbnN0IGhlaWdodCA9IHByZWNpbmN0LmNieU1heCAtIHByZWNpbmN0LmNieU1pbiArIDE7CiAgICAgICAgICBpbmNsdXNpb25UcmVlID0gbmV3IEluY2x1c2lvblRyZWUod2lkdGgsIGhlaWdodCwgbGF5ZXJOdW1iZXIpOwogICAgICAgICAgemVyb0JpdFBsYW5lc1RyZWUgPSBuZXcgVGFnVHJlZSh3aWR0aCwgaGVpZ2h0KTsKICAgICAgICAgIHByZWNpbmN0LmluY2x1c2lvblRyZWUgPSBpbmNsdXNpb25UcmVlOwogICAgICAgICAgcHJlY2luY3QuemVyb0JpdFBsYW5lc1RyZWUgPSB6ZXJvQml0UGxhbmVzVHJlZTsKICAgICAgICAgIGZvciAobGV0IGwgPSAwOyBsIDwgbGF5ZXJOdW1iZXI7IGwrKykgewogICAgICAgICAgICBpZiAocmVhZEJpdHMoMSkgIT09IDApIHsKICAgICAgICAgICAgICB0aHJvdyBuZXcgSnB4RXJyb3IoIkludmFsaWQgdGFnIHRyZWUiKTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZiAoaW5jbHVzaW9uVHJlZS5yZXNldChjb2RlYmxvY2tDb2x1bW4sIGNvZGVibG9ja1JvdywgbGF5ZXJOdW1iZXIpKSB7CiAgICAgICAgICB3aGlsZSAodHJ1ZSkgewogICAgICAgICAgICBpZiAocmVhZEJpdHMoMSkpIHsKICAgICAgICAgICAgICB2YWx1ZVJlYWR5ID0gIWluY2x1c2lvblRyZWUubmV4dExldmVsKCk7CiAgICAgICAgICAgICAgaWYgKHZhbHVlUmVhZHkpIHsKICAgICAgICAgICAgICAgIGNvZGVibG9jay5pbmNsdWRlZCA9IHRydWU7CiAgICAgICAgICAgICAgICBjb2RlYmxvY2tJbmNsdWRlZCA9IGZpcnN0VGltZUluY2x1c2lvbiA9IHRydWU7CiAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgaW5jbHVzaW9uVHJlZS5pbmNyZW1lbnRWYWx1ZShsYXllck51bWJlcik7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0KICAgICAgaWYgKCFjb2RlYmxvY2tJbmNsdWRlZCkgewogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGlmIChmaXJzdFRpbWVJbmNsdXNpb24pIHsKICAgICAgICB6ZXJvQml0UGxhbmVzVHJlZSA9IHByZWNpbmN0Lnplcm9CaXRQbGFuZXNUcmVlOwogICAgICAgIHplcm9CaXRQbGFuZXNUcmVlLnJlc2V0KGNvZGVibG9ja0NvbHVtbiwgY29kZWJsb2NrUm93KTsKICAgICAgICB3aGlsZSAodHJ1ZSkgewogICAgICAgICAgaWYgKHJlYWRCaXRzKDEpKSB7CiAgICAgICAgICAgIHZhbHVlUmVhZHkgPSAhemVyb0JpdFBsYW5lc1RyZWUubmV4dExldmVsKCk7CiAgICAgICAgICAgIGlmICh2YWx1ZVJlYWR5KSB7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHplcm9CaXRQbGFuZXNUcmVlLmluY3JlbWVudFZhbHVlKCk7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGNvZGVibG9jay56ZXJvQml0UGxhbmVzID0gemVyb0JpdFBsYW5lc1RyZWUudmFsdWU7CiAgICAgIH0KICAgICAgY29uc3QgY29kaW5ncGFzc2VzID0gcmVhZENvZGluZ3Bhc3NlcygpOwogICAgICB3aGlsZSAocmVhZEJpdHMoMSkpIHsKICAgICAgICBjb2RlYmxvY2suTGJsb2NrKys7CiAgICAgIH0KICAgICAgY29uc3QgY29kaW5ncGFzc2VzTG9nMiA9ICgwLCBfY29yZV91dGlscy5sb2cyKShjb2RpbmdwYXNzZXMpOwogICAgICBjb25zdCBiaXRzID0gKGNvZGluZ3Bhc3NlcyA8IDEgPDwgY29kaW5ncGFzc2VzTG9nMiA/IGNvZGluZ3Bhc3Nlc0xvZzIgLSAxIDogY29kaW5ncGFzc2VzTG9nMikgKyBjb2RlYmxvY2suTGJsb2NrOwogICAgICBjb25zdCBjb2RlZERhdGFMZW5ndGggPSByZWFkQml0cyhiaXRzKTsKICAgICAgcXVldWUucHVzaCh7CiAgICAgICAgY29kZWJsb2NrLAogICAgICAgIGNvZGluZ3Bhc3NlcywKICAgICAgICBkYXRhTGVuZ3RoOiBjb2RlZERhdGFMZW5ndGgKICAgICAgfSk7CiAgICB9CiAgICBhbGlnblRvQnl0ZSgpOwogICAgaWYgKGVwaE1hcmtlclVzZWQpIHsKICAgICAgc2tpcE1hcmtlcklmRXF1YWwoMHg5Mik7CiAgICB9CiAgICB3aGlsZSAocXVldWUubGVuZ3RoID4gMCkgewogICAgICBjb25zdCBwYWNrZXRJdGVtID0gcXVldWUuc2hpZnQoKTsKICAgICAgY29kZWJsb2NrID0gcGFja2V0SXRlbS5jb2RlYmxvY2s7CiAgICAgIGlmIChjb2RlYmxvY2suZGF0YSA9PT0gdW5kZWZpbmVkKSB7CiAgICAgICAgY29kZWJsb2NrLmRhdGEgPSBbXTsKICAgICAgfQogICAgICBjb2RlYmxvY2suZGF0YS5wdXNoKHsKICAgICAgICBkYXRhLAogICAgICAgIHN0YXJ0OiBvZ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iAgICAgIHBvc2l0aW9uICs9IGNodW5rLmxlbmd0aDsKICAgIH0KICAgIGNvbnN0IGRlY29kZXIgPSBuZXcgX2FyaXRobWV0aWNfZGVjb2Rlci5Bcml0aG1ldGljRGVjb2RlcihlbmNvZGVkRGF0YSwgMCwgdG90YWxMZW5ndGgpOwogICAgYml0TW9kZWwuc2V0RGVjb2RlcihkZWNvZGVyKTsKICAgIGZvciAoaiA9IDA7IGogPCBjb2RpbmdwYXNzZXM7IGorKykgewogICAgICBzd2l0Y2ggKGN1cnJlbnRDb2RpbmdwYXNzVHlwZSkgewogICAgICAgIGNhc2UgMDoKICAgICAgICAgIGJpdE1vZGVsLnJ1blNpZ25pZmljYW5jZVByb3BhZ2F0aW9uUGFzcygpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAxOgogICAgICAgICAgYml0TW9kZWwucnVuTWFnbml0dWRlUmVmaW5lbWVudFBhc3MoKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMjoKICAgICAgICAgIGJpdE1vZGVsLnJ1bkNsZWFudXBQYXNzKCk7CiAgICAgICAgICBpZiAoc2VnbWVudGF0aW9uU3ltYm9sVXNlZCkgewogICAgICAgICAgICBiaXRNb2RlbC5jaGVja1NlZ21lbnRhdGlvblN5bWJvbCgpOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgIH0KICAgICAgaWYgKHJlc2V0Q29udGV4dFByb2JhYmlsaXRpZXMpIHsKICAgICAgICBiaXRNb2RlbC5yZXNldCgpOwogICAgICB9CiAgICAgIGN1cnJlbnRDb2RpbmdwYXNzVHlwZSA9IChjdXJyZW50Q29kaW5ncGFzc1R5cGUgKyAxKSAlIDM7CiAgICB9CiAgICBsZXQgb2Zmc2V0ID0gY29kZWJsb2NrLnRieDBfIC0geDAgKyAoY29kZWJsb2NrLnRieTBfIC0geTApICogd2lkdGg7CiAgICBjb25zdCBzaWduID0gYml0TW9kZWwuY29lZmZpY2VudHNTaWduOwogICAgY29uc3QgbWFnbml0dWRlID0gYml0TW9kZWwuY29lZmZpY2VudHNNYWduaXR1ZGU7CiAgICBjb25zdCBiaXRzRGVjb2RlZCA9IGJpdE1vZGVsLmJpdHNEZWNvZGVkOwogICAgY29uc3QgbWFnbml0dWRlQ29ycmVjdGlvbiA9IHJldmVyc2libGUgPyAwIDogMC41OwogICAgbGV0IGssIG4sIG5iOwogICAgcG9zaXRpb24gPSAwOwogICAgY29uc3QgaW50ZXJsZWF2ZSA9IHN1YmJhbmQudHlwZSAhPT0gIkxMIjsKICAgIGZvciAoaiA9IDA7IGogPCBibG9ja0hlaWdodDsgaisrKSB7CiAgICAgIGNvbnN0IHJvdyA9IG9mZnNldCAvIHdpZHRoIHwgMDsKICAgICAgY29uc3QgbGV2ZWxPZmZzZXQgPSAyICogcm93ICogKGxldmVsV2lkdGggLSB3aWR0aCkgKyByaWdodCArIGJvdHRvbTsKICAgICAgZm9yIChrID0gMDsgayA8IGJsb2NrV2lkdGg7IGsrKykgewogICAgICAgIG4gPSBtYWduaXR1ZGVbcG9zaXRpb25dOwogICAgICAgIGlmIChuICE9PSAwKSB7CiAgICAgICAgICBuID0gKG4gKyBtYWduaXR1ZGVDb3JyZWN0aW9uKSAqIGRlbHRhOwogICAgICAgICAgaWYgKHNpZ25bcG9zaXRpb25dICE9PSAwKSB7CiAgICAgICAgICAgIG4gPSAtbjsKICAgICAgICAgIH0KICAgICAgICAgIG5iID0gYml0c0RlY29kZWRbcG9zaXRpb25dOwogICAgICAgICAgY29uc3QgcG9zID0gaW50ZXJsZWF2ZSA/IGxldmVsT2Zmc2V0ICsgKG9mZnNldCA8PCAxKSA6IG9mZnNldDsKICAgICAgICAgIGlmIChyZXZlcnNpYmxlICYmIG5iID49IG1iKSB7CiAgICAgICAgICAgIGNvZWZmaWNpZW50c1twb3NdID0gbjsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIGNvZWZmaWNpZW50c1twb3NdID0gbiAqICgxIDw8IG1iIC0g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IC0gKHkyICsgeTEgPj4gMik7CiAgICAgICAgICBvdXRbcG9zKytdID0gZyArIHkyID4+IHNoaWZ0OwogICAgICAgICAgb3V0W3BvcysrXSA9IGcgPj4gc2hpZnQ7CiAgICAgICAgICBvdXRbcG9zKytdID0gZyArIHkxID4+IHNoaWZ0OwogICAgICAgIH0KICAgICAgfQogICAgICBpZiAoZm91ckNvbXBvbmVudHMpIHsKICAgICAgICBmb3IgKGogPSAwLCBwb3MgPSAzOyBqIDwgamo7IGorKywgcG9zICs9IDQpIHsKICAgICAgICAgIG91dFtwb3NdID0geTNpdGVtc1tqXSArIG9mZnNldCA+PiBzaGlmdDsKICAgICAgICB9CiAgICAgIH0KICAgIH0gZWxzZSB7CiAgICAgIGZvciAobGV0IGMgPSAwOyBjIDwgY29tcG9uZW50c0NvdW50OyBjKyspIHsKICAgICAgICBjb25zdCBpdGVtcyA9IHRyYW5zZm9ybWVkVGlsZXNbY10uaXRlbXM7CiAgICAgICAgc2hpZnQgPSBjb21wb25lbnRzW2NdLnByZWNpc2lvbiAtIDg7CiAgICAgICAgb2Zmc2V0ID0gKDEyOCA8PCBzaGlmdCkgKyAwLjU7CiAgICAgICAgZm9yIChwb3MgPSBjLCBqID0gMCwgamogPSBpdGVtcy5sZW5ndGg7IGogPCBqajsgaisrKSB7CiAgICAgICAgICBvdXRbcG9zXSA9IGl0ZW1zW2pdICsgb2Zmc2V0ID4+IHNoaWZ0OwogICAgICAgICAgcG9zICs9IGNvbXBvbmVudHNDb3VudDsKICAgICAgICB9CiAgICAgIH0KICAgIH0KICAgIHJlc3VsdEltYWdlcy5wdXNoKHJlc3VsdCk7CiAgfQogIHJldHVybiByZXN1bHRJbWFnZXM7Cn0KZnVuY3Rpb24gaW5pdGlhbGl6ZVRpbGUoY29udGV4dCwgdGlsZUluZGV4KSB7CiAgY29uc3Qgc2l6ID0gY29udGV4dC5TSVo7CiAgY29uc3QgY29tcG9uZW50c0NvdW50ID0gc2l6LkNzaXo7CiAgY29uc3Q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kdGggPSBNYXRoLmNlaWwod2lkdGggLyAyKTsKICAgICAgaGVpZ2h0ID0gTWF0aC5jZWlsKGhlaWdodCAvIDIpOwogICAgfQogIH0KICByZXNldChpLCBqKSB7CiAgICBsZXQgY3VycmVudExldmVsID0gMCwKICAgICAgdmFsdWUgPSAwLAogICAgICBsZXZlbDsKICAgIHdoaWxlIChjdXJyZW50TGV2ZWwgPCB0aGlzLmxldmVscy5sZW5ndGgpIHsKICAgICAgbGV2ZWwgPSB0aGlzLmxldmVsc1tjdXJyZW50TGV2ZWxdOwogICAgICBjb25zdCBpbmRleCA9IGkgKyBqICogbGV2ZWwud2lkdGg7CiAgICAgIGlmIChsZXZlbC5pdGVtc1tpbmRleF0gIT09IHVuZGVmaW5lZCkgewogICAgICAgIHZhbHVlID0gbGV2ZWwuaXRlbXNbaW5kZXhdOwogICAgICAgIGJyZWFrOwogICAgICB9CiAgICAgIGxldmVsLmluZGV4ID0gaW5kZXg7CiAgICAgIGkgPj49IDE7CiAgICAgIGogPj49IDE7CiAgICAgIGN1cnJlbnRMZXZlbCsrOwogICAgfQogICAgY3VycmVudExldmVsLS07CiAgICBsZXZlbCA9IHRoaXMubGV2ZWxzW2N1cnJlbnRMZXZlbF07CiAgICBsZXZlbC5pdGVtc1tsZXZlbC5pbmRleF0gPSB2YWx1ZTsKICAgIHRoaXMuY3VycmVudExldmVsID0gY3VycmVudExldmVsOwogICAgZGVsZXRlIHRoaXMudmFsdWU7CiAgfQogIGluY3JlbWVudFZhbHVlKCkgewogICAgY29uc3QgbGV2ZWwgPSB0aGlzLmxldmVsc1t0aGlzLmN1cnJlbnRMZXZlbF07CiAgICBsZXZlbC5pdGVtc1tsZXZlbC5pbmRleF0rKzsKICB9CiAgbmV4dExldmVsKCkgewogICAgbGV0IGN1cnJlbnRMZXZlbCA9IHRoaXMuY3VycmVudExldmVsOwogICAgbGV0IGxldmVsID0gdGhpcy5sZXZlbHNbY3VycmVudExldmVsXTsKICAgIGNvbnN0IHZhbHVl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ICBpZiAoc3ViYmFuZCA9PT0gIkhIIikgewogICAgICAgIGNvbnRleHRMYWJlbFRhYmxlID0gSEhDb250ZXh0TGFiZWw7CiAgICAgIH0gZWxzZSBpZiAoc3ViYmFuZCA9PT0gIkhMIikgewogICAgICAgIGNvbnRleHRMYWJlbFRhYmxlID0gSExDb250ZXh0TGFiZWw7CiAgICAgIH0gZWxzZSB7CiAgICAgICAgY29udGV4dExhYmVsVGFibGUgPSBMTEFuZExIQ29udGV4dHNMYWJlbDsKICAgICAgfQogICAgICB0aGlzLmNvbnRleHRMYWJlbFRhYmxlID0gY29udGV4dExhYmVsVGFibGU7CiAgICAgIGNvbnN0IGNvZWZmaWNpZW50Q291bnQgPSB3aWR0aCAqIGhlaWdodDsKICAgICAgdGhpcy5uZWlnaGJvcnNTaWduaWZpY2FuY2UgPSBuZXcgVWludDhBcnJheShjb2VmZmljaWVudENvdW50KTsKICAgICAgdGhpcy5jb2VmZmljZW50c1NpZ24gPSBuZXcgVWludDhBcnJheShjb2VmZmljaWVudENvdW50KTsKICAgICAgbGV0IGNvZWZmaWNlbnRzTWFnbml0dWRlOwogICAgICBpZiAobWIgPiAxNCkgewogICAgICAgIGNvZWZmaWNlbnRzTWFnbml0dWRlID0gbmV3IFVpbnQzMkFycmF5KGNvZWZmaWNpZW50Q291bnQpOwogICAgICB9IGVsc2UgaWYgKG1iID4gNikgewogICAgICAgIGNvZWZmaWNlbnRzTWFnbml0dWRlID0gbmV3IFVpbnQxNkFycmF5KGNvZWZmaWNpZW50Q291bnQpOwogICAgICB9IGVsc2UgewogICAgICAgIGNvZWZmaWNlbnRzTWFnbml0dWRlID0gbmV3IFVpbnQ4QXJyYXkoY29lZmZpY2llbnRDb3VudCk7CiAgICAgIH0KICAgICAgdGhpcy5jb2VmZmljZW50c01hZ25pdHVkZSA9IGNvZWZmaWNlbnRzTWFnbml0dWRlOwogICAgICB0aGlzLnByb2Nlc3NpbmdGbGFncyA9IG5ldyBVaW50OEFycmF5KGNvZWZm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aW5kZXggLSB3aWR0aDsKICAgICAgICBpZiAobGVmdCkgewogICAgICAgICAgbmVpZ2hib3JzU2lnbmlmaWNhbmNlW2kgLSAxXSArPSAweDEwOwogICAgICAgIH0KICAgICAgICBpZiAocmlnaHQpIHsKICAgICAgICAgIG5laWdoYm9yc1NpZ25pZmljYW5jZVtpICsgMV0gKz0gMHgxMDsKICAgICAgICB9CiAgICAgICAgbmVpZ2hib3JzU2lnbmlmaWNhbmNlW2ldICs9IDB4MDQ7CiAgICAgIH0KICAgICAgaWYgKHJvdyArIDEgPCBoZWlnaHQpIHsKICAgICAgICBpID0gaW5kZXggKyB3aWR0aDsKICAgICAgICBpZiAobGVmdCkgewogICAgICAgICAgbmVpZ2hib3JzU2lnbmlmaWNhbmNlW2kgLSAxXSArPSAweDEwOwogICAgICAgIH0KICAgICAgICBpZiAocmlnaHQpIHsKICAgICAgICAgIG5laWdoYm9yc1NpZ25pZmljYW5jZVtpICsgMV0gKz0gMHgxMDsKICAgICAgICB9CiAgICAgICAgbmVpZ2hib3JzU2lnbmlmaWNhbmNlW2ldICs9IDB4MDQ7CiAgICAgIH0KICAgICAgaWYgKGxlZnQpIHsKICAgICAgICBuZWlnaGJvcnNTaWduaWZpY2FuY2VbaW5kZXggLSAxXSArPSAweDAxOwogICAgICB9CiAgICAgIGlmIChyaWdodCkgewogICAgICAgIG5laWdoYm9yc1NpZ25pZmljYW5jZVtpbmRleCArIDFdICs9IDB4MDE7CiAgICAgIH0KICAgICAgbmVpZ2hib3JzU2lnbmlmaWNhbmNlW2luZGV4XSB8PSAweDgwOwogICAgfQogICAgcnVuU2lnbmlmaWNhbmNlUHJvcGFnYXRpb25QYXNzKCkgewogICAgICBjb25zdCBkZWNvZGVyID0gdGhpcy5kZWNvZGVyOwogICAgICBjb25zdCB3aWR0aCA9IHRoaXMud2lkdGgsCiAgICAgICAgaGVpZ2h0ID0gdGhpcy5oZWlnaHQ7CiAgICAgIGNvbnN0IGNvZWZmaWNlbnRzTWFnbml0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lmaWNhbmNlW2luZGV4XSkgewogICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGNvbnN0IGNvbnRleHRMYWJlbCA9IGxhYmVsc1tuZWlnaGJvcnNTaWduaWZpY2FuY2VbaW5kZXhdXTsKICAgICAgICAgICAgY29uc3QgZGVjaXNpb24gPSBkZWNvZGVyLnJlYWRCaXQoY29udGV4dHMsIGNvbnRleHRMYWJlbCk7CiAgICAgICAgICAgIGlmIChkZWNpc2lvbikgewogICAgICAgICAgICAgIGNvbnN0IHNpZ24gPSB0aGlzLmRlY29kZVNpZ25CaXQoaSwgaiwgaW5kZXgpOwogICAgICAgICAgICAgIGNvZWZmaWNlbnRzU2lnbltpbmRleF0gPSBzaWduOwogICAgICAgICAgICAgIGNvZWZmaWNlbnRzTWFnbml0dWRlW2luZGV4XSA9IDE7CiAgICAgICAgICAgICAgdGhpcy5zZXROZWlnaGJvcnNTaWduaWZpY2FuY2UoaSwgaiwgaW5kZXgpOwogICAgICAgICAgICAgIHByb2Nlc3NpbmdGbGFnc1tpbmRleF0gfD0gZmlyc3RNYWduaXR1ZGVCaXRNYXNrOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGJpdHNEZWNvZGVkW2luZGV4XSsrOwogICAgICAgICAgICBwcm9jZXNzaW5nRmxhZ3NbaW5kZXhdIHw9IHByb2Nlc3NlZE1hc2s7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9CiAgICB9CiAgICBkZWNvZGVTaWduQml0KHJvdywgY29sdW1uLCBpbmRleCkgewogICAgICBjb25zdCB3aWR0aCA9IHRoaXMud2lkdGgsCiAgICAgICAgaGVpZ2h0ID0gdGhpcy5oZWlnaHQ7CiAgICAgIGNvbnN0IGNvZWZmaWNlbnRzTWFnbml0dWRlID0gdGhpcy5jb2VmZmljZW50c01hZ25pdHVkZTsKICAgICAgY29uc3QgY29lZmZpY2VudHNTaWduID0gdGhpcy5jb2VmZmljZW50c1NpZ247CiAgIC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AgICAgc2lnbjEgPSBjb2VmZmljZW50c1NpZ25baW5kZXggKyB3aWR0aF07CiAgICAgICAgaWYgKHNpZ25pZmljYW5jZTEpIHsKICAgICAgICAgIHNpZ24wID0gY29lZmZpY2VudHNTaWduW2luZGV4IC0gd2lkdGhdOwogICAgICAgICAgY29udHJpYnV0aW9uID0gMSAtIHNpZ24xIC0gc2lnbjAgKyBob3Jpem9udGFsQ29udHJpYnV0aW9uOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBjb250cmlidXRpb24gPSAxIC0gc2lnbjEgLSBzaWduMSArIGhvcml6b250YWxDb250cmlidXRpb247CiAgICAgICAgfQogICAgICB9IGVsc2UgaWYgKHNpZ25pZmljYW5jZTEpIHsKICAgICAgICBzaWduMCA9IGNvZWZmaWNlbnRzU2lnbltpbmRleCAtIHdpZHRoXTsKICAgICAgICBjb250cmlidXRpb24gPSAxIC0gc2lnbjAgLSBzaWduMCArIGhvcml6b250YWxDb250cmlidXRpb247CiAgICAgIH0gZWxzZSB7CiAgICAgICAgY29udHJpYnV0aW9uID0gaG9yaXpvbnRhbENvbnRyaWJ1dGlvbjsKICAgICAgfQogICAgICBpZiAoY29udHJpYnV0aW9uID49IDApIHsKICAgICAgICBjb250ZXh0TGFiZWwgPSA5ICsgY29udHJpYnV0aW9uOwogICAgICAgIGRlY29kZWQgPSB0aGlzLmRlY29kZXIucmVhZEJpdCh0aGlzLmNvbnRleHRzLCBjb250ZXh0TGFiZWwpOwogICAgICB9IGVsc2UgewogICAgICAgIGNvbnRleHRMYWJlbCA9IDkgLSBjb250cmlidXRpb247CiAgICAgICAgZGVjb2RlZCA9IHRoaXMuZGVjb2Rlci5yZWFkQml0KHRoaXMuY29udGV4dHMsIGNvbnRleHRMYWJlbCkgXiAxOwogICAgICB9CiAgICAgIHJldHVybiBkZWNvZGVkOwogICAgfQogICAgcnVuTWFnbml0dWRlUmVmaW5lbWVudFBhc3MoKSB7CiAgICAgIGNvbnN0IGRlY29kZXIgPSB0a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51ZTsKICAgICAgICAgICAgfQogICAgICAgICAgICBsZXQgY29udGV4dExhYmVsID0gMTY7CiAgICAgICAgICAgIGlmICgocHJvY2Vzc2luZ0ZsYWdzW2luZGV4XSAmIGZpcnN0TWFnbml0dWRlQml0TWFzaykgIT09IDApIHsKICAgICAgICAgICAgICBwcm9jZXNzaW5nRmxhZ3NbaW5kZXhdIF49IGZpcnN0TWFnbml0dWRlQml0TWFzazsKICAgICAgICAgICAgICBjb25zdCBzaWduaWZpY2FuY2UgPSBuZWlnaGJvcnNTaWduaWZpY2FuY2VbaW5kZXhdICYgMTI3OwogICAgICAgICAgICAgIGNvbnRleHRMYWJlbCA9IHNpZ25pZmljYW5jZSA9PT0gMCA/IDE1IDogMTQ7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgY29uc3QgYml0ID0gZGVjb2Rlci5yZWFkQml0KGNvbnRleHRzLCBjb250ZXh0TGFiZWwpOwogICAgICAgICAgICBjb2VmZmljZW50c01hZ25pdHVkZVtpbmRleF0gPSBjb2VmZmljZW50c01hZ25pdHVkZVtpbmRleF0gPDwgMSB8IGJpdDsKICAgICAgICAgICAgYml0c0RlY29kZWRbaW5kZXhdKys7CiAgICAgICAgICAgIHByb2Nlc3NpbmdGbGFnc1tpbmRleF0gfD0gcHJvY2Vzc2VkTWFzazsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0KICAgIH0KICAgIHJ1bkNsZWFudXBQYXNzKCkgewogICAgICBjb25zdCBkZWNvZGVyID0gdGhpcy5kZWNvZGVyOwogICAgICBjb25zdCB3aWR0aCA9IHRoaXMud2lkdGgsCiAgICAgICAgaGVpZ2h0ID0gdGhpcy5oZWlnaHQ7CiAgICAgIGNvbnN0IG5laWdoYm9yc1NpZ25pZmljYW5jZSA9IHRoaXMubmVpZ2hib3JzU2lnbmlmaWNhbmNlOwogICAgICBjb25zdCBjb2VmZmljZW50c01hZ25pdHVkZSA9IHRoaXMuY29lZmZpY2VudHNNYWduaXR1ZGU7CiAgIC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dvUm93c0Rvd25dID09PSAwICYmIHByb2Nlc3NpbmdGbGFnc1tpbmRleDAgKyB0aHJlZVJvd3NEb3duXSA9PT0gMCAmJiBuZWlnaGJvcnNTaWduaWZpY2FuY2VbaW5kZXgwXSA9PT0gMCAmJiBuZWlnaGJvcnNTaWduaWZpY2FuY2VbaW5kZXgwICsgb25lUm93RG93bl0gPT09IDAgJiYgbmVpZ2hib3JzU2lnbmlmaWNhbmNlW2luZGV4MCArIHR3b1Jvd3NEb3duXSA9PT0gMCAmJiBuZWlnaGJvcnNTaWduaWZpY2FuY2VbaW5kZXgwICsgdGhyZWVSb3dzRG93bl0gPT09IDA7CiAgICAgICAgICBsZXQgaTEgPSAwLAogICAgICAgICAgICBpbmRleCA9IGluZGV4MDsKICAgICAgICAgIGxldCBpID0gaTAsCiAgICAgICAgICAgIHNpZ247CiAgICAgICAgICBpZiAoYWxsRW1wdHkpIHsKICAgICAgICAgICAgY29uc3QgaGFzU2lnbmlmaWNhbnRDb2VmZmljZW50ID0gZGVjb2Rlci5yZWFkQml0KGNvbnRleHRzLCBSVU5MRU5HVEhfQ09OVEVYVCk7CiAgICAgICAgICAgIGlmICghaGFzU2lnbmlmaWNhbnRDb2VmZmljZW50KSB7CiAgICAgICAgICAgICAgYml0c0RlY29kZWRbaW5kZXgwXSsrOwogICAgICAgICAgICAgIGJpdHNEZWNvZGVkW2luZGV4MCArIG9uZVJvd0Rvd25dKys7CiAgICAgICAgICAgICAgYml0c0RlY29kZWRbaW5kZXgwICsgdHdvUm93c0Rvd25dKys7CiAgICAgICAgICAgICAgYml0c0RlY29kZWRbaW5kZXgwICsgdGhyZWVSb3dzRG93bl0rKzsKICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgfQogICAgICAgICAgICBpMSA9IGRlY29kZXIucmVhZEJpdChjb250ZXh0cywgVU5JRk9STV9DT05URVhUKSA8PCAxIHwgZGVjb2Rlci5yZWFkQml0KGNvbnRleHRzLCBVTklGT1JNX0NPTlRFWFQpOwogICAgICAgICAgICBpZiAoaTEgIT09IDApIHsKICAgICAgICAgICAgICBpID0gaTAgKyBpMTsKICAgICAgICAgICAgICBpbmRleCArPSBpMSAqIHdpZHRoOwogICAgICAgICAgICB9CiAgICAgICAgICAgIHNpZ24gPSB0aGlzLmRlY29kZVNpZ25CaXQoaSwgaiwgaW5kZXgpOwogICAgICAgICAgICBjb2VmZmljZW50c1NpZ25baW5kZXhdID0gc2lnbjsKICAgICAgICAgICAgY29lZmZpY2VudHNNYWduaXR1ZGVbaW5kZXhdID0gMTsKICAgICAgICAgICAgdGhpcy5zZXROZWlnaGJvcnNTaWduaWZpY2FuY2UoaSwgaiwgaW5kZXgpOwogICAgICAgICAgICBwcm9jZXNzaW5nRmxhZ3NbaW5kZXhdIHw9IGZpcnN0TWFnbml0dWRlQml0TWFzazsKICAgICAgICAgICAgaW5kZXggPSBpbmRleDA7CiAgICAgICAgICAgIGZvciAobGV0IGkyID0gaTA7IGkyIDw9IGk7IGkyKyssIGluZGV4ICs9IHdpZHRoKSB7CiAgICAgICAgICAgICAgYml0c0RlY29kZWRbaW5kZXhdKys7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaTErKzsKICAgICAgICAgIH0KICAgICAgICAgIGZvciAoaSA9IGkwICsgaTE7IGkgPCBpTmV4dDsgaSsrLCBpbmRleCArPSB3aWR0aCkgewogICAgICAgICAgICBpZiAoY29lZmZpY2VudHNNYWduaXR1ZGVbaW5kZXhdIHx8IChwcm9jZXNzaW5nRmxhZ3NbaW5kZXhdICYgcHJvY2Vzc2VkTWFzaykgIT09IDApIHsKICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgfQogICAgICAgICAgICBjb25zdCBjb250ZXh0TGFiZWwgPSBsYWJlbHNbbmVpZ2hib3JzU2lnbmlmaWNhbmNlW2luZGV4XV07CiAgICAgICAgICAgIGNvbnN0IGRlY2lzaW9uID0gZGVjb2Rlci5yZWFkQml0KGNvbnRleHRzLCBjb250ZXh0TGFiZWwpOwogICAgICAgICAgICBpZiAoZGVjaXNpb24gPT09IDEpIHsKICAgICAgICAgICAgICBzaWduID0gdGhpcy5kZWNvZGVTaWduQml0KGksIGosIGluZGV4KTsKICAgICAgICAgICAgICBjb2VmZmljZW50c1NpZ25baW5kZXhdID0gc2lnbjsKICAgICAgICAgICAgICBjb2VmZmljZW50c01hZ25pdHVkZVtpbmRleF0gPSAxOwogICAgICAgICAgICAgIHRoaXMuc2V0TmVpZ2hib3JzU2lnbmlmaWNhbmNlKGksIGosIGluZGV4KTsKICAgICAgICAgICAgICBwcm9jZXNzaW5nRmxhZ3NbaW5kZXhdIHw9IGZpcnN0TWFnbml0dWRlQml0TWFzazsKICAgICAgICAgICAgfQogICAgICAgICAgICBiaXRzRGVjb2RlZFtpbmRleF0rKzsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0KICAgIH0KICAgIGNoZWNrU2VnbWVudGF0aW9uU3ltYm9sKCkgewogICAgICBjb25zdCBkZWNvZGVyID0gdGhpcy5kZWNvZGVyOwogICAgICBjb25zdCBjb250ZXh0cyA9IHRoaXMuY29udGV4dHM7CiAgICAgIGNvbnN0IHN5bWJvbCA9IGRlY29kZXIucmVhZEJpdChjb250ZXh0cywgVU5JRk9STV9DT05URVhUKSA8PCAzIHwgZGVjb2Rlci5yZWFkQml0KGNvbnRleHRzLCBVTklGT1JNX0NPTlRFWFQpIDw8IDIgfCBkZWNvZGVyLnJlYWRCaXQoY29udGV4dHMsIFVOSUZPUk1fQ09OVEVYVCkgPDwgMSB8IGRlY29kZXIucmVhZEJpdChjb250ZXh0cywgVU5JRk9STV9DT05URVhUKTsKICAgICAgaWYgKHN5bWJvbCAhPT0gMHhhKSB7CiAgICAgICAgdGhyb3cgbmV3IEpweEVycm9yKCJJbnZhbGlkIHNlZ21lbnRhdGlvbiBzeW1ib2wiKTsKICAgICAgfQogICAgfQogIH0KICByZXR1cm4gQml0TW9kZWw7Cn0oKTsKY2xhc3MgVHJhbnNmb3JtIHsK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jk2MTsKICAgIGNvbnN0IGdhbW1hID0gMC44ODI5MTEwNzU1MzA5MzQ7CiAgICBjb25zdCBkZWx0YSA9IDAuNDQzNTA2ODUyMDQzOTcxOwogICAgY29uc3QgSyA9IDEuMjMwMTc0MTA0OTE0MDAxOwogICAgY29uc3QgS18gPSAxIC8gSzsKICAgIGogPSBvZmZzZXQgLSAzOwogICAgZm9yIChuID0gbGVuICsgNDsgbi0tOyBqICs9IDIpIHsKICAgICAgeFtqXSAqPSBLXzsKICAgIH0KICAgIGogPSBvZmZzZXQgLSAyOwogICAgY3VycmVudCA9IGRlbHRhICogeFtqIC0gMV07CiAgICBmb3IgKG4gPSBsZW4gKyAzOyBuLS07IGogKz0gMikgewogICAgICBuZXh0ID0gZGVsdGEgKiB4W2ogKyAxXTsKICAgICAgeFtqXSA9IEsgKiB4W2pdIC0gY3VycmVudCAtIG5leHQ7CiAgICAgIGlmIChuLS0pIHsKICAgICAgICBqICs9IDI7CiAgICAgICAgY3VycmVudCA9IGRlbHRhICogeFtqICsgMV07CiAgICAgICAgeFtqXSA9IEsgKiB4W2pdIC0gY3VycmVudCAtIG5leHQ7CiAgICAgIH0gZWxzZSB7CiAgICAgICAgYnJlYWs7CiAgICAgIH0KICAgIH0KICAgIGogPSBvZmZzZXQgLSAxOwogICAgY3VycmVudCA9IGdhbW1hICogeFtqIC0gMV07CiAgICBmb3IgKG4gPSBsZW4gKyAyOyBuLS07IGogKz0gMikgewogICAgICBuZXh0ID0gZ2FtbWEgKiB4W2ogKyAxXTsKICAgICAgeFtqXSAtPSBjdXJyZW50ICsgbmV4dDsKICAgICAgaWYgKG4tLSkgewogICAgICAgIGogKz0gMjsKICAgICAgICBjdXJyZW50ID0gZ2FtbWEgKiB4W2ogKyAxXTsKICAgICAgICB4W2pdIC09IGN1cnJlbnQgKyBuZXh0OwogICAgICB9IGVsc2UgewogICAgICAgIGJyZWFrOwogICAgICB9CiAgICB9CiAgICBqID0gb2Zmc2V0OwogICAgY3VycmVudCA9IGJldGEgKiB4W2ogLSAxXTsKICAgIGZvciAobiA9IGxlbiArIDE7IG4tLTsgaiArPSAyKSB7CiAgICAgIG5leHQgPSBiZXRhICogeFtqICsgMV07CiAgICAgIHhbal0gLT0gY3VycmVudCArIG5leHQ7CiAgICAgIGlmIChuLS0pIHsKICAgICAgICBqICs9IDI7CiAgICAgICAgY3VycmVudCA9IGJldGEgKiB4W2ogKyAxXTsKICAgICAgICB4W2pdIC09IGN1cnJlbnQgKyBuZXh0OwogICAgICB9IGVsc2UgewogICAgICAgIGJyZWFrOwogICAgICB9CiAgICB9CiAgICBpZiAobGVuICE9PSAwKSB7CiAgICAgIGogPSBvZmZzZXQgKyAxOwogICAgICBjdXJyZW50ID0gYWxwaGEgKiB4W2ogLSAxXTsKICAgICAgZm9yIChuID0gbGVuOyBuLS07IGogKz0gMikgewogICAgICAgIG5leHQgPSBhbHBoYSAqIHhbaiArIDFdOwogICAgICAgIHhbal0gLT0gY3VycmVudCArIG5leHQ7CiAgICAgICAgaWYgKG4tLSkgewogICAgICAgICAgaiArPSAyOwogICAgICAgICAgY3VycmVudCA9IGFscGhhICogeFtqICsgMV07CiAgICAgICAgICB4W2pdIC09IGN1cnJlbnQgKyBuZXh0OwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBicmVhazsKICAgICAgICB9CiAgICAgIH0KICAgIH0KICB9Cn0KY2xhc3MgUmV2ZXJzaWJsZVRyYW5zZm9ybSBleHRlbmRzIFRyYW5zZm9ybSB7CiAgZmlsdGVyKHgsIG9mZnNldCwgbGVuZ3RoKSB7CiAgICBjb25zdCBsZW4gPSBsZW5ndGggPj4gMTsKICAgIG9mZnNldCB8PSAwOwogICAgbGV0IGosIG47CiAgICBmb3IgKGogPSBvZmZzZXQsIG4gPSBsZW4gKyAxOyBuLS07IGogKz0gMikgewogICAgICB4W2pdIC09IHhbaiAtIDFdICsgeFtqICsgMV0gKyAyID4+IDI7CiAgICB9CiAgICBmb3IgKGogPSBvZmZzZXQgKyAxL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dHMoY29kZUxlbmd0aCk7CiAgICAgIGNvbnN0IGhhc1ByZXYgPSBjdXJyZW50U2VxdWVuY2VMZW5ndGggPiAwOwogICAgICBpZiAoY29kZSA8IDI1NikgewogICAgICAgIGN1cnJlbnRTZXF1ZW5jZVswXSA9IGNvZGU7CiAgICAgICAgY3VycmVudFNlcXVlbmNlTGVuZ3RoID0gMTsKICAgICAgfSBlbHNlIGlmIChjb2RlID49IDI1OCkgewogICAgICAgIGlmIChjb2RlIDwgbmV4dENvZGUpIHsKICAgICAgICAgIGN1cnJlbnRTZXF1ZW5jZUxlbmd0aCA9IGRpY3Rpb25hcnlMZW5ndGhzW2NvZGVdOwogICAgICAgICAgZm9yIChqID0gY3VycmVudFNlcXVlbmNlTGVuZ3RoIC0gMSwgcSA9IGNvZGU7IGogPj0gMDsgai0tKSB7CiAgICAgICAgICAgIGN1cnJlbnRTZXF1ZW5jZVtqXSA9IGRpY3Rpb25hcnlWYWx1ZXNbcV07CiAgICAgICAgICAgIHEgPSBkaWN0aW9uYXJ5UHJldkNvZGVzW3FdOwogICAgICAgICAgfQogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBjdXJyZW50U2VxdWVuY2VbY3VycmVudFNlcXVlbmNlTGVuZ3RoKytdID0gY3VycmVudFNlcXVlbmNlWzBdOwogICAgICAgIH0KICAgICAgfSBlbHNlIGlmIChjb2RlID09PSAyNTYpIHsKICAgICAgICBjb2RlTGVuZ3RoID0gOTsKICAgICAgICBuZXh0Q29kZSA9IDI1ODsKICAgICAgICBjdXJyZW50U2VxdWVuY2VMZW5ndGggPSAwOwogICAgICAgIGNvbnRpbnVlOwogICAgICB9IGVsc2UgewogICAgICAgIHRoaXMuZW9mID0gdHJ1ZTsKICAgICAgICBkZWxldGUgdGhpcy5sendTdGF0ZTsKICAgICAgICBicmVhazsKICAgICAgfQogICAgICBpZiAoaGFzUHJldikgewogICAgICAgIGRpY3Rpb25hcnlQcmV2Q29kZXNbbmV4dENvZGVdID0gcHJldkNv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XJQaXhlbCA9IGNvbG9ycyAqIDI7CiAgICAgIGZvciAoaSA9IDA7IGkgPCBieXRlc1BlclBpeGVsOyArK2kpIHsKICAgICAgICBidWZmZXJbcG9zKytdID0gcmF3Qnl0ZXNbaV07CiAgICAgIH0KICAgICAgZm9yICg7IGkgPCByb3dCeXRlczsgaSArPSAyKSB7CiAgICAgICAgY29uc3Qgc3VtID0gKChyYXdCeXRlc1tpXSAmIDB4ZmYpIDw8IDgpICsgKHJhd0J5dGVzW2kgKyAxXSAmIDB4ZmYpICsgKChidWZmZXJbcG9zIC0gYnl0ZXNQZXJQaXhlbF0gJiAweGZmKSA8PCA4KSArIChidWZmZXJbcG9zIC0gYnl0ZXNQZXJQaXhlbCArIDFdICYgMHhmZik7CiAgICAgICAgYnVmZmVyW3BvcysrXSA9IHN1bSA+PiA4ICYgMHhmZjsKICAgICAgICBidWZmZXJbcG9zKytdID0gc3VtICYgMHhmZjsKICAgICAgfQogICAgfSBlbHNlIHsKICAgICAgY29uc3QgY29tcEFycmF5ID0gbmV3IFVpbnQ4QXJyYXkoY29sb3JzICsgMSk7CiAgICAgIGNvbnN0IGJpdE1hc2sgPSAoMSA8PCBiaXRzKSAtIDE7CiAgICAgIGxldCBqID0gMCwKICAgICAgICBrID0gYnVmZmVyTGVuZ3RoOwogICAgICBjb25zdCBjb2x1bW5zID0gdGhpcy5jb2x1bW5zOwogICAgICBmb3IgKGkgPSAwOyBpIDwgY29sdW1uczsgKytpKSB7CiAgICAgICAgZm9yIChsZXQga2sgPSAwOyBrayA8IGNvbG9yczsgKytraykgewogICAgICAgICAgaWYgKGluYml0cyA8IGJpdHMpIHsKICAgICAgICAgICAgaW5idWYgPSBpbmJ1ZiA8PCA4IHwgcmF3Qnl0ZXNbaisrXSAmIDB4ZmY7CiAgICAgICAgICAgIGluYml0cyArPSA4OwogICAgICAgICAgfQogICAgICAgICAgY29tcEFycmF5W2trXSA9IGNvbXBBcnJheVtra10gKyAoaW5idWYgPj4gaW5iaXRzI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vd0J5dGVzLCBidWZmZXJMZW5ndGgpOwogICAgaWYgKHByZXZSb3cubGVuZ3RoID09PSAwKSB7CiAgICAgIHByZXZSb3cgPSBuZXcgVWludDhBcnJheShyb3dCeXRlcyk7CiAgICB9CiAgICBsZXQgaSwKICAgICAgaiA9IGJ1ZmZlckxlbmd0aCwKICAgICAgdXAsCiAgICAgIGM7CiAgICBzd2l0Y2ggKHByZWRpY3RvcikgewogICAgICBjYXNlIDA6CiAgICAgICAgZm9yIChpID0gMDsgaSA8IHJvd0J5dGVzOyArK2kpIHsKICAgICAgICAgIGJ1ZmZlcltqKytdID0gcmF3Qnl0ZXNbaV07CiAgICAgICAgfQogICAgICAgIGJyZWFrOwogICAgICBjYXNlIDE6CiAgICAgICAgZm9yIChpID0gMDsgaSA8IHBpeEJ5dGVzOyArK2kpIHsKICAgICAgICAgIGJ1ZmZlcltqKytdID0gcmF3Qnl0ZXNbaV07CiAgICAgICAgfQogICAgICAgIGZvciAoOyBpIDwgcm93Qnl0ZXM7ICsraSkgewogICAgICAgICAgYnVmZmVyW2pdID0gYnVmZmVyW2ogLSBwaXhCeXRlc10gKyByYXdCeXRlc1tpXSAmIDB4ZmY7CiAgICAgICAgICBqKys7CiAgICAgICAgfQogICAgICAgIGJyZWFrOwogICAgICBjYXNlIDI6CiAgICAgICAgZm9yIChpID0gMDsgaSA8IHJvd0J5dGVzOyArK2kpIHsKICAgICAgICAgIGJ1ZmZlcltqKytdID0gcHJldlJvd1tpXSArIHJhd0J5dGVzW2ldICYgMHhmZjsKICAgICAgICB9CiAgICAgICAgYnJlYWs7CiAgICAgIGNhc2UgMzoKICAgICAgICBmb3IgKGkgPSAwOyBpIDwgcGl4Qnl0ZXM7ICsraSkgewogICAgICAgICAgYnVmZmVyW2orK10gPSAocHJldlJvd1tpXSA+PiAxKSArIHJhd0J5dGVzW2ldOwogICAgICAgIH0KICAgICAgICBmb3IgKDsgaSA8IHJvd0J5dGVzOyArK2kpIHsKICAgICAgICAgIGJ1ZmZlcltqXSA9IChwcmV2Um93W2ldICsgYnVmZmVyW2ogLSBwaXhCeXRlc10gPj4gMSkgKyByYXdCeXRlc1tpXSAmIDB4ZmY7CiAgICAgICAgICBqKys7CiAgICAgICAgfQogICAgICAgIGJyZWFrOwogICAgICBjYXNlIDQ6CiAgICAgICAgZm9yIChpID0gMDsgaSA8IHBpeEJ5dGVzOyArK2kpIHsKICAgICAgICAgIHVwID0gcHJldlJvd1tpXTsKICAgICAgICAgIGMgPSByYXdCeXRlc1tpXTsKICAgICAgICAgIGJ1ZmZlcltqKytdID0gdXAgKyBjOwogICAgICAgIH0KICAgICAgICBmb3IgKDsgaSA8IHJvd0J5dGVzOyArK2kpIHsKICAgICAgICAgIHVwID0gcHJldlJvd1tpXTsKICAgICAgICAgIGNvbnN0IHVwTGVmdCA9IHByZXZSb3dbaSAtIHBpeEJ5dGVzXTsKICAgICAgICAgIGNvbnN0IGxlZnQgPSBidWZmZXJbaiAtIHBpeEJ5dGVzXTsKICAgICAgICAgIGNvbnN0IHAgPSBsZWZ0ICsgdXAgLSB1cExlZnQ7CiAgICAgICAgICBsZXQgcGEgPSBwIC0gbGVmdDsKICAgICAgICAgIGlmIChwYSA8IDApIHsKICAgICAgICAgICAgcGEgPSAtcGE7CiAgICAgICAgICB9CiAgICAgICAgICBsZXQgcGIgPSBwIC0gdXA7CiAgICAgICAgICBpZiAocGIgPCAwKSB7CiAgICAgICAgICAgIHBiID0gLXBiOwogICAgICAgICAgfQogICAgICAgICAgbGV0IHBjID0gcCAtIHVwTGVmdDsKICAgICAgICAgIGlmIChwYyA8IDApIHsKICAgICAgICAgICAgcGMgPSAtcGM7CiAgICAgICAgICB9CiAgICAgICAgICBjID0gcmF3Qnl0ZXNbaV07CiAgICAgICAgICBpZiAocGEgPD0gcGIgJiYgcGEgPD0gcGMpIHsKICAgICAgICAgICAgYnVmZmVyW2orK10gPSBsZWZ0ICsgYzsKICAgICAgICAgIH0gZWxzZSBpZiAocGIgPD0gcGMpIHsKIC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ogICAgICBpZiAoY2lkVG9HaWRNYXApIHsKICAgICAgICBmb3IgKGNvbnN0IGNoYXJDb2RlIGluIG1hcCkgewogICAgICAgICAgY29uc3QgY2lkID0gbWFwW2NoYXJDb2RlXTsKICAgICAgICAgIGlmIChjaWRUb0dpZE1hcFtjaWRdICE9PSB1bmRlZmluZWQpIHsKICAgICAgICAgICAgbWFwWytjaGFyQ29kZV0gPSBjaWRUb0dpZE1hcFtjaWRdOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZiAoY2lkVG9HaWRNYXAubGVuZ3RoICE9PSB0aGlzLnRvVW5pY29kZS5sZW5ndGggJiYgcHJvcGVydGllcy5oYXNJbmNsdWRlZFRvVW5pY29kZU1hcCAmJiB0aGlzLnRvVW5pY29kZSBpbnN0YW5jZW9mIF90b191bmljb2RlX21hcC5JZGVudGl0eVRvVW5pY29kZU1hcCkgewogICAgICAgICAgdGhpcy50b1VuaWNvZGUuZm9yRWFjaChmdW5jdGlvbiAoY2hhckNvZGUsIHVuaWNvZGVDaGFyQ29kZSkgewogICAgICAgICAgICBjb25zdCBjaWQgPSBtYXBbY2hhckNvZGVdOwogICAgICAgICAgICBpZiAoY2lkVG9HaWRNYXBbY2lkXSA9PT0gdW5kZWZpbmVkKSB7CiAgICAgICAgICAgICAgbWFwWytjaGFyQ29kZV0gPSB1bmljb2RlQ2hhckNvZGU7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0pOwogICAgICAgIH0KICAgICAgfQogICAgICBpZiAoISh0aGlzLnRvVW5pY29kZSBpbnN0YW5jZW9mIF90b191bmljb2RlX21hcC5JZGVudGl0eVRvVW5pY29kZU1hcCkpIHsKICAgICAgICB0aGlzLnRvVW5pY29kZS5mb3JFYWNoKGZ1bmN0aW9uIChjaGFyQ29kZSwgdW5pY29kZUNoYXJDb2RlKSB7CiAgICAgICAgICBtYXBbK2NoYXJDb2RlXSA9IHVuaWNvZGVDaGFyQ29kZTsKICAgICAgICB9KTsKICAgICAgfQogICAgIC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AgICAgIGlmICghVkFMSURfVEFCTEVTLmluY2x1ZGVzKHRhYmxlLnRhZykpIHsKICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgIH0KICAgICAgICBpZiAodGFibGUubGVuZ3RoID09PSAwKSB7CiAgICAgICAgICBjb250aW51ZTsKICAgICAgICB9CiAgICAgICAgdGFibGVzW3RhYmxlLnRhZ10gPSB0YWJsZTsKICAgICAgfQogICAgICByZXR1cm4gdGFibGVzOwogICAgfQogICAgZnVuY3Rpb24gcmVhZFRhYmxlRW50cnkoZmlsZSkgewogICAgICBjb25zdCB0YWcgPSBmaWxlLmdldFN0cmluZyg0KTsKICAgICAgY29uc3QgY2hlY2tzdW0gPSBmaWxlLmdldEludDMyKCkgPj4+IDA7CiAgICAgIGNvbnN0IG9mZnNldCA9IGZpbGUuZ2V0SW50MzIoKSA+Pj4gMDsKICAgICAgY29uc3QgbGVuZ3RoID0gZmlsZS5nZXRJbnQzMigpID4+PiAwOwogICAgICBjb25zdCBwcmV2aW91c1Bvc2l0aW9uID0gZmlsZS5wb3M7CiAgICAgIGZpbGUucG9zID0gZmlsZS5zdGFydCB8fCAwOwogICAgICBmaWxlLnNraXAob2Zmc2V0KTsKICAgICAgY29uc3QgZGF0YSA9IGZpbGUuZ2V0Qnl0ZXMobGVuZ3RoKTsKICAgICAgZmlsZS5wb3MgPSBwcmV2aW91c1Bvc2l0aW9uOwogICAgICBpZiAodGFnID09PSAiaGVhZCIpIHsKICAgICAgICBkYXRhWzhdID0gZGF0YVs5XSA9IGRhdGFbMTBdID0gZGF0YVsxMV0gPSAwOwogICAgICAgIGRhdGFbMTddIHw9IDB4MjA7CiAgICAgIH0KICAgICAgcmV0dXJuIHsKICAgICAgICB0YWcsCiAgICAgICAgY2hlY2tzdW0sCiAgICAgICAgbGVuZ3RoLAogICAgICAgIG9mZnNldCwKICAgICAgICBkYXRhCiAgICAgIH07CiAgICB9CiAgICBmdW5jdGlvbiByZWFkT3BlblR5cGVIZWFkZXIodHRmKSB7CiAgICAgIHJldHVybiB7CiAgICAgICAgdmVyc2lvbjogdHRmLmdldFN0cmluZyg0KSwKICAgICAgICBudW1UYWJsZXM6IHR0Zi5nZXRVaW50MTYoKSwKICAgICAgICBzZWFyY2hSYW5nZTogdHRmLmdldFVpbnQxNigpLAogICAgICAgIGVudHJ5U2VsZWN0b3I6IHR0Zi5nZXRVaW50MTYoKSwKICAgICAgICByYW5nZVNoaWZ0OiB0dGYuZ2V0VWludDE2KCkKICAgICAgfTsKICAgIH0KICAgIGZ1bmN0aW9uIHJlYWRUcnVlVHlwZUNvbGxlY3Rpb25IZWFkZXIodHRjKSB7CiAgICAgIGNvbnN0IHR0Y1RhZyA9IHR0Yy5nZXRTdHJpbmcoNCk7CiAgICAgICgwLCBfdXRpbC5hc3NlcnQpKHR0Y1RhZyA9PT0gInR0Y2YiLCAiTXVzdCBiZSBhIFRydWVUeXBlIENvbGxlY3Rpb24gZm9udC4iKTsKICAgICAgY29uc3QgbWFqb3JWZXJzaW9uID0gdHRjLmdldFVpbnQxNigpOwogICAgICBjb25zdCBtaW5vclZlcnNpb24gPSB0dGMuZ2V0VWludDE2KCk7CiAgICAgIGNvbnN0IG51bUZvbnRzID0gdHRjLmdldEludDMyKCkgPj4+IDA7CiAgICAgIGNvbnN0IG9mZnNldFRhYmxlID0gW107CiAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgbnVtRm9udHM7IGkrKykgewogICAgICAgIG9mZnNldFRhYmxlLnB1c2godHRjLmdldEludDMyKCkgPj4+IDApOwogICAgICB9CiAgICAgIGNvbnN0IGhlYWRlciA9IHsKICAgICAgICB0dGNUYWcsCiAgICAgICAgbWFqb3JWZXJzaW9uLAogICAgICAgIG1pbm9yVmVyc2lvbiwKICAgICAgICBudW1Gb250cywKICAgICAgICBvZmZzZXRUYWJsZQogICAgICB9OwogICAgICBzd2l0Y2ggKG1ham9yVmVyc2lvbikgewogICAgICAgIGNhc2UgMToKICAgICAgICAgIHJldHVybiBoZWFkZXI7Ci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b3IoJ1RydWVUeXBlIENvbGxlY3Rpb24gZm9udCBtdXN0IGNvbnRhaW4gYSAibmFtZSIgdGFibGUuJyk7CiAgICAgICAgfQogICAgICAgIGNvbnN0IFtuYW1lVGFibGVdID0gcmVhZE5hbWVUYWJsZShwb3RlbnRpYWxUYWJsZXMubmFtZSk7CiAgICAgICAgZm9yIChsZXQgaiA9IDAsIGpqID0gbmFtZVRhYmxlLmxlbmd0aDsgaiA8IGpqOyBqKyspIHsKICAgICAgICAgIGZvciAobGV0IGsgPSAwLCBrayA9IG5hbWVUYWJsZVtqXS5sZW5ndGg7IGsgPCBrazsgaysrKSB7CiAgICAgICAgICAgIGNvbnN0IG5hbWVFbnRyeSA9IG5hbWVUYWJsZVtqXVtrXSAmJiBuYW1lVGFibGVbal1ba10ucmVwbGFjZUFsbCgvXHMvZywgIiIpOwogICAgICAgICAgICBpZiAoIW5hbWVFbnRyeSkgewogICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmIChuYW1lRW50cnkgPT09IGZvbnROYW1lKSB7CiAgICAgICAgICAgICAgcmV0dXJuIHsKICAgICAgICAgICAgICAgIGhlYWRlcjogcG90ZW50aWFsSGVhZGVyLAogICAgICAgICAgICAgICAgdGFibGVzOiBwb3RlbnRpYWxUYWJsZXMKICAgICAgICAgICAgICB9OwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmIChmb250TmFtZVBhcnRzLmxlbmd0aCA8IDIpIHsKICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgfQogICAgICAgICAgICBmb3IgKGNvbnN0IHBhcnQgb2YgZm9udE5hbWVQYXJ0cykgewogICAgICAgICAgICAgIGlmIChuYW1lRW50cnkgPT09IHBhcnQpIHsKICAgICAgICAgICAgICAgIGZhbGxiYWNrRGF0YSA9IHsKICAgICAgICAgICAgICAgICAgbmFtZTogcGFydCwKICAgICAgICAgICAgICAgICAgaGVhZGVyOiBwb3RlbnRpYWxIZWFkZXIsCiAgICAgICAgICAgICAgICAgIHRhYmxlczogcG90ZW50aWFsVGFibGVzCiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgIH0KICAgICAgfQogICAgICBpZiAoZmFsbGJhY2tEYXRhKSB7CiAgICAgICAgKDAsIF91dGlsLndhcm4pKGBUcnVlVHlwZSBDb2xsZWN0aW9uIGRvZXMgbm90IGNvbnRhaW4gIiR7Zm9udE5hbWV9IiBmb250LCBgICsgYGZhbGxpbmcgYmFjayB0byAiJHtmYWxsYmFja0RhdGEubmFtZX0iIGZvbnQgaW5zdGVhZC5gKTsKICAgICAgICByZXR1cm4gewogICAgICAgICAgaGVhZGVyOiBmYWxsYmFja0RhdGEuaGVhZGVyLAogICAgICAgICAgdGFibGVzOiBmYWxsYmFja0RhdGEudGFibGVzCiAgICAgICAgfTsKICAgICAgfQogICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoYFRydWVUeXBlIENvbGxlY3Rpb24gZG9lcyBub3QgY29udGFpbiAiJHtmb250TmFtZX0iIGZvbnQuYCk7CiAgICB9CiAgICBmdW5jdGlvbiByZWFkQ21hcFRhYmxlKGNtYXAsIGZpbGUsIGlzU3ltYm9saWNGb250LCBoYXNFbmNvZGluZykgewogICAgICBpZiAoIWNtYXApIHsKICAgICAgICAoMCwgX3V0aWwud2FybikoIk5vIGNtYXAgdGFibGUgYXZhaWxhYmxlLiIpOwogICAgICAgIHJldHVybiB7CiAgICAgICAgICBwbGF0Zm9ybUlkOiAtMSwKICAgICAgICAgIGVuY29kaW5nSWQ6IC0xLAogICAgICAgICAgbWFwcGluZ3M6IFtdLAogICAgICAgICAgaGFzU2hvcnRDbWFwOiBmYWxzZQogICAgICAgIH07CiAgICAgIH0KICAgICAgbGV0IHNlZ21lbnQ7CiAgICAgIGxldCBzdGFydCA9IChmaWxlLnN0YXJ0IHx8IDApICsgY21hcC5vZmZzZXQ7CiA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ghaXNTeW1ib2xpY0ZvbnQpIHsKICAgICAgICAgICAgY2FuQnJlYWsgPSB0cnVlOwogICAgICAgICAgfQogICAgICAgIH0gZWxzZSBpZiAoaXNTeW1ib2xpY0ZvbnQgJiYgcGxhdGZvcm1JZCA9PT0gMyAmJiBlbmNvZGluZ0lkID09PSAwKSB7CiAgICAgICAgICB1c2VUYWJsZSA9IHRydWU7CiAgICAgICAgICBsZXQgY29ycmVjdGx5U29ydGVkID0gdHJ1ZTsKICAgICAgICAgIGlmIChpIDwgbnVtVGFibGVzIC0gMSkgewogICAgICAgICAgICBjb25zdCBuZXh0Qnl0ZXMgPSBmaWxlLnBlZWtCeXRlcygyKSwKICAgICAgICAgICAgICBuZXh0UGxhdGZvcm1JZCA9IGludDE2KG5leHRCeXRlc1swXSwgbmV4dEJ5dGVzWzFdKTsKICAgICAgICAgICAgaWYgKG5leHRQbGF0Zm9ybUlkIDwgcGxhdGZvcm1JZCkgewogICAgICAgICAgICAgIGNvcnJlY3RseVNvcnRlZCA9IGZhbHNlOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICBpZiAoY29ycmVjdGx5U29ydGVkKSB7CiAgICAgICAgICAgIGNhbkJyZWFrID0gdHJ1ZTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgaWYgKHVzZVRhYmxlKSB7CiAgICAgICAgICBwb3RlbnRpYWxUYWJsZSA9IHsKICAgICAgICAgICAgcGxhdGZvcm1JZCwKICAgICAgICAgICAgZW5jb2RpbmdJZCwKICAgICAgICAgICAgb2Zmc2V0CiAgICAgICAgICB9OwogICAgICAgIH0KICAgICAgICBpZiAoY2FuQnJlYWspIHsKICAgICAgICAgIGJyZWFrOwogICAgICAgIH0KICAgICAgfQogICAgICBpZiAocG90ZW50aWFsVGFibGUpIHsKICAgICAgICBmaWxlLnBvcyA9IHN0YXJ0ICsgcG90ZW50aWFsVGFibGUub2Zmc2V0OwogICAgICB9CiAgICAgIGlmICghcG90ZW50aWFsVGFibGUgfHwgZmlsZS5wZWVrQnl0ZSgpID09PSAtMSkgewogICAgICAgICgwLCBfdXRpbC53YXJuKSgiQ291bGQgbm90IGZpbmQgYSBwcmVmZXJyZWQgY21hcCB0YWJsZS4iKTsKICAgICAgICByZXR1cm4gewogICAgICAgICAgcGxhdGZvcm1JZDogLTEsCiAgICAgICAgICBlbmNvZGluZ0lkOiAtMSwKICAgICAgICAgIG1hcHBpbmdzOiBbXSwKICAgICAgICAgIGhhc1Nob3J0Q21hcDogZmFsc2UKICAgICAgICB9OwogICAgICB9CiAgICAgIGNvbnN0IGZvcm1hdCA9IGZpbGUuZ2V0VWludDE2KCk7CiAgICAgIGxldCBoYXNTaG9ydENtYXAgPSBmYWxzZTsKICAgICAgY29uc3QgbWFwcGluZ3MgPSBbXTsKICAgICAgbGV0IGosIGdseXBoSWQ7CiAgICAgIGlmIChmb3JtYXQgPT09IDApIHsKICAgICAgICBmaWxlLnNraXAoMiArIDIpOwogICAgICAgIGZvciAoaiA9IDA7IGogPCAyNTY7IGorKykgewogICAgICAgICAgY29uc3QgaW5kZXggPSBmaWxlLmdldEJ5dGUoKTsKICAgICAgICAgIGlmICghaW5kZXgpIHsKICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICB9CiAgICAgICAgICBtYXBwaW5ncy5wdXNoKHsKICAgICAgICAgICAgY2hhckNvZGU6IGosCiAgICAgICAgICAgIGdseXBoSWQ6IGluZGV4CiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgICAgaGFzU2hvcnRDbWFwID0gdHJ1ZTsKICAgICAgfSBlbHNlIGlmIChmb3JtYXQgPT09IDIpIHsKICAgICAgICBmaWxlLnNraXAoMiArIDIpOwogICAgICAgIGNvbnN0IHN1YkhlYWRlcktleXMgPSBbXTsKICAgICAgICBsZXQgbWF4U3ViSGVhZGVyS2V5ID0gMDsKICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IDI1NjsgaSsrKSB7CiAgICAgICAgICBjb25zdCBzdWJIZWFkZXJLZXkgPSBmaWxlLmdldFVpbnQxNigpID4+IDM7CiAgICAgICAgICBzdWJIZWFkZXJLZXlzLnB1c2goc3ViSGVhZGVyS2V5KTsKICAgICAgICAgIG1heFN1YkhlYWRlcktleSA9IE1hdGgubWF4KHN1YkhlYWRlcktleSwgbWF4U3ViSGVhZGVyS2V5KTsKICAgICAgICB9CiAgICAgICAgY29uc3Qgc3ViSGVhZGVycyA9IFtdOwogICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDw9IG1heFN1YkhlYWRlcktleTsgaSsrKSB7CiAgICAgICAgICBzdWJIZWFkZXJzLnB1c2goewogICAgICAgICAgICBmaXJzdENvZGU6IGZpbGUuZ2V0VWludDE2KCksCiAgICAgICAgICAgIGVudHJ5Q291bnQ6IGZpbGUuZ2V0VWludDE2KCksCiAgICAgICAgICAgIGlkRGVsdGE6IHNpZ25lZEludDE2KGZpbGUuZ2V0Qnl0ZSgpLCBmaWxlLmdldEJ5dGUoKSksCiAgICAgICAgICAgIGlkUmFuZ2VQb3M6IGZpbGUucG9zICsgZmlsZS5nZXRVaW50MTYoKQogICAgICAgICAgfSk7CiAgICAgICAgfQogICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgMjU2OyBpKyspIHsKICAgICAgICAgIGlmIChzdWJIZWFkZXJLZXlzW2ldID09PSAwKSB7CiAgICAgICAgICAgIGZpbGUucG9zID0gc3ViSGVhZGVyc1swXS5pZFJhbmdlUG9zICsgMiAqIGk7CiAgICAgICAgICAgIGdseXBoSWQgPSBmaWxlLmdldFVpbnQxNigpOwogICAgICAgICAgICBtYXBwaW5ncy5wdXNoKHsKICAgICAgICAgICAgICBjaGFyQ29kZTogaSwKICAgICAgICAgICAgICBnbHlwaElkCiAgICAgICAgICAgIH0pOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgY29uc3QgcyA9IHN1YkhlYWRlcnNbc3ViSGVhZGVyS2V5c1tpXV07CiAgICAgICAgICAgIGZvciAoaiA9IDA7IGogPCBzLmVudHJ5Q291bnQ7IGorKykgewogICAgICAgICAgICAgIGNvbnN0IGNoYXJDb2RlID0gKGkgPDwgOCkgKyBqICsgcy5maXJzdENvZGU7CiAgICAgICAgICAgICAgZmlsZS5wb3MgPSBzLmlkUmFuZ2VQb3MgKyAyICogajsKICAgICAgICAgICAgICBnbHlwaElkID0gZmlsZS5nZXRVaW50MTYoKTsKICAgICAgICAgICAgICBpZiAoZ2x5cGhJZCAhPT0gMCkgewogICAgICAgICAgICAgICAgZ2x5cGhJZCA9IChnbHlwaElkICsgcy5pZERlbHRhKSAlIDY1NTM2OwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBtYXBwaW5ncy5wdXNoKHsKICAgICAgICAgICAgICAgIGNoYXJDb2RlLAogICAgICAgICAgICAgICAgZ2x5cGhJZAogICAgICAgICAgICAgIH0pOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9IGVsc2UgaWYgKGZvcm1hdCA9PT0gNCkgewogICAgICAgIGZpbGUuc2tpcCgyICsgMik7CiAgICAgICAgY29uc3Qgc2VnQ291bnQgPSBmaWxlLmdldFVpbnQxNigpID4+IDE7CiAgICAgICAgZmlsZS5za2lwKDYpOwogICAgICAgIGNvbnN0IHNlZ21lbnRzID0gW107CiAgICAgICAgbGV0IHNlZ0luZGV4OwogICAgICAgIGZvciAoc2VnSW5kZXggPSAwOyBzZWdJbmRleCA8IHNlZ0NvdW50OyBzZWdJbmRleCsrKSB7CiAgICAgICAgICBzZWdtZW50cy5wdXNoKHsKICAgICAgICAgICAgZW5kOiBmaWxlLmdldFVpbnQxNigpCiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgICAgZmlsZS5za2lwKDIpOwogICAgICAgIGZvciAoc2VnSW5kZXggPSAwOyBzZWdJbmRleCA8IHNlZ0NvdW50OyBzZWdJbmRleCsrKSB7CiAgICAgICAgICBzZWdtZW50c1tzZWdJbmRleF0uc3RhcnQgPSBmaWxlLmdldFVpbnQxNigpOwogICAgICAgIH0KICAgICAgICBmb3IgKHNlZ0luZGV4ID0gMDsgc2VnSW5kZXggPCBzZWdDb3VudDsgc2VnSW5kZXgrKykgewogICAgICAgICAgc2VnbWVudHNbc2VnSW5kZXhdLmRlbHRhID0gZmlsZS5nZXRVaW50MTYoKTsKICAgICAgICB9CiAgICAgICAgbGV0IG9mZnNldHNDb3VudCA9IDAsCiAgICAgICAgICBvZmZzZXRJbmRleDsKICAgICAgICBmb3IgKHNlZ0luZGV4ID0gMDsgc2VnSW5kZXggPCBzZWdDb3VudDsgc2VnSW5kZXgrKykgewogICAgICAgICAgc2VnbWVudCA9IHNlZ21lbnRzW3NlZ0luZGV4XTsKICAgICAgICAgIGNvbnN0IHJhbmdlT2Zmc2V0ID0gZmlsZS5nZXRVaW50MTYoKTsKICAgICAgICAgIGlmICghcmFuZ2VPZmZzZXQpIHsKICAgICAgICAgICAgc2VnbWVudC5vZmZzZXRJbmRleCA9IC0xOwogICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgIH0KICAgICAgICAgIG9mZnNldEluZGV4ID0gKHJhbmdlT2Zmc2V0ID4+IDEpIC0gKHNlZ0NvdW50IC0gc2VnSW5kZXgpOwogICAgICAgICAgc2VnbWVudC5vZmZzZXRJbmRleCA9IG9mZnNldEluZGV4OwogICAgICAgICAgb2Zmc2V0c0NvdW50ID0gTWF0aC5tYXgob2Zmc2V0c0NvdW50LCBvZmZzZXRJbmRleCArIHNlZ21lbnQuZW5kIC0gc2VnbWVudC5zdGFydCArIDEpOwogICAgICAgIH0KICAgICAgICBjb25zdCBvZmZzZXRzID0gW107CiAgICAgICAgZm9yIChqID0gMDsgaiA8IG9mZnNldHNDb3VudDsgaisrKSB7CiAgICAgICAgICBvZmZzZXRzLnB1c2goZmlsZS5nZXRVaW50MTYoKSk7CiAgICAgICAgfQogICAgICAgIGZvciAoc2VnSW5kZXggPSAwOyBzZWdJbmRleCA8IHNlZ0NvdW50OyBzZWdJbmRleCsrKSB7CiAgICAgICAgICBzZWdtZW50ID0gc2VnbWVudHNbc2VnSW5kZXhdOwogICAgICAgICAgc3RhcnQgPSBzZWdtZW50LnN0YXJ0OwogICAgICAgICAgY29uc3QgZW5kID0gc2VnbWVudC5lbmQ7CiAgICAgICAgICBjb25zdCBkZWx0YSA9IHNlZ21lbnQuZGVsdGE7CiAgICAgICAgICBvZmZzZXRJbmRleCA9IHNlZ21lbnQub2Zmc2V0SW5kZXg7CiAgICAgICAgICBmb3IgKGogPSBzdGFydDsgaiA8PSBlbmQ7IGorKykgewogICAgICAgICAgICBpZiAoaiA9PT0gMHhmZmZmKSB7CiAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZ2x5cGhJZCA9IG9mZnNldEluZGV4IDwgMCA/IGogOiBvZmZzZXRzW29mZnNldEluZGV4ICsgaiAtIHN0YXJ0XTsKICAgICAgICAgICAgZ2x5cGhJZCA9IGdseXBoSWQgKyBkZWx0YSAmIDB4ZmZmZjsKICAgICAgICAgICAgbWFwcGluZ3MucHVzaCh7CiAgICAgICAgICAgICAgY2hhckNvZGU6IGosCiAgICAgICAgICAgICAgZ2x5cGhJZAogICAgICAgICAgICB9KTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0gZWxzZSBpZiAoZm9ybWF0ID09PSA2KSB7CiAgICAgICAgZmlsZS5za2lwKDIgKyAyKTsKICAgICAgICBjb25zdCBmaXJzdENvZGUgPSBmaWxlLmdldFVpbnQxNigpOwogICAgICAgIGNvbnN0IGVudHJ5Q291bnQgPSBmaWxlLmdldFVpbnQxNigpOwogICAgICAgIGZvciAoaiA9IDA7IGogPCBlbnRyeUNvdW50OyBqKyspIHsKICAgICAgICAgIGdseXBoSWQgPSBmaWxlLmdldFVpbnQxNigpOwogICAgICAgICAgY29uc3QgY2hhckNvZGUgPSBmaXJzdENvZGUgKyBqOwogICAgICAgICAgbWFwcGluZ3MucHVzaCh7CiAgICAgICAgICAgIGNoYXJDb2RlLAogICAgICAgICAgICBnbHlwaElkCiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgIH0gZWxzZSBpZiAoZm9ybWF0ID09PSAxMikgewogICAgICAgIGZpbGUuc2tpcCgyICsgNCArIDQpOwogICAgICAgIGNvbnN0IG5Hcm91cHMgPSBmaWxlLmdldEludDMyKCkgPj4+IDA7CiAgICAgICAgZm9yIChqID0gMDsgaiA8IG5Hcm91cHM7IGorKykgewogICAgICAgICAgY29uc3Qgc3RhcnRDaGFyQ29kZSA9IGZpbGUuZ2V0SW50MzIoKSA+Pj4gMDsKICAgICAgICAgIGNvbnN0IGVuZENoYXJDb2RlID0gZmlsZS5nZXRJbnQzMigpID4+PiAwOwogICAgICAgICAgbGV0IGdseXBoQ29kZSA9IGZpbGUuZ2V0SW50MzIoKSA+Pj4gMDsKICAgICAgICAgIGZvciAobGV0IGNoYXJDb2RlID0gc3RhcnRDaGFyQ29kZTsgY2hhckNvZGUgPD0gZW5kQ2hhckNvZGU7IGNoYXJDb2RlKyspIHsKICAgICAgICAgICAgbWFwcGluZ3MucHVzaCh7CiAgICAgICAgICAgICAgY2hhckNvZGUsCiAgICAgICAgICAgICAgZ2x5cGhJZDogZ2x5cGhDb2RlKysKICAgICAgICAgICAgfSk7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9IGVsc2UgewogICAgICAgICgwLCBfdXRpbC53YXJuKSgiY21hcCB0YWJsZSBoYXMgdW5zdXBwb3J0ZWQgZm9ybWF0OiAiICsgZm9ybWF0KTsKICAgICAgICByZXR1cm4gewogICAgICAgICAgcGxhdGZvcm1JZDogLTEsCiAgICAgICAgICBlbmNvZGluZ0lkOiAtMSwKICAgICAgICAgIG1hcHBpbmdzOiBbXSwKICAgICAgICAgIGhhc1Nob3J0Q21hcDogZmFsc2UKICAgICAgICB9OwogICAgICB9CiAgICAgIG1hcHBpbmdzLnNvcnQoZnVuY3Rpb24gKGEsIGIpIHsKICAgICAgICByZXR1cm4gYS5jaGFyQ29kZSAtIGIuY2hh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mc2V0ID0gZmlsZS5nZXRVaW50MTYoKTsKICAgICAgZmlsZS5wb3MgKz0gODsKICAgICAgZmlsZS5wb3MgKz0gMjsKICAgICAgbGV0IG51bU9mTWV0cmljcyA9IGZpbGUuZ2V0VWludDE2KCk7CiAgICAgIGlmIChjYXJldE9mZnNldCAhPT0gMCkgewogICAgICAgIGNvbnN0IG1hY1N0eWxlID0gaW50MTYoaGVhZFRhYmxlLmRhdGFbNDRdLCBoZWFkVGFibGUuZGF0YVs0NV0pOwogICAgICAgIGlmICghKG1hY1N0eWxlICYgMikpIHsKICAgICAgICAgIGhlYWRlci5kYXRhWzIyXSA9IDA7CiAgICAgICAgICBoZWFkZXIuZGF0YVsyM10gPSAwOwogICAgICAgIH0KICAgICAgfQogICAgICBpZiAobnVtT2ZNZXRyaWNzID4gbnVtR2x5cGhzKSB7CiAgICAgICAgKDAsIF91dGlsLmluZm8pKGBUaGUgbnVtT2ZNZXRyaWNzICgke251bU9mTWV0cmljc30pIHNob3VsZCBub3QgYmUgYCArIGBncmVhdGVyIHRoYW4gdGhlIG51bUdseXBocyAoJHtudW1HbHlwaHN9KS5gKTsKICAgICAgICBudW1PZk1ldHJpY3MgPSBudW1HbHlwaHM7CiAgICAgICAgaGVhZGVyLmRhdGFbMzRdID0gKG51bU9mTWV0cmljcyAmIDB4ZmYwMCkgPj4gODsKICAgICAgICBoZWFkZXIuZGF0YVszNV0gPSBudW1PZk1ldHJpY3MgJiAweDAwZmY7CiAgICAgIH0KICAgICAgY29uc3QgbnVtT2ZTaWRlYmVhcmluZ3MgPSBudW1HbHlwaHMgLSBudW1PZk1ldHJpY3M7CiAgICAgIGNvbnN0IG51bU1pc3NpbmcgPSBudW1PZlNpZGViZWFyaW5ncyAtIChtZXRyaWNzLmxlbmd0aCAtIG51bU9mTWV0cmljcyAqIDQgPj4gMSk7CiAgICAgIGlmIChudW1NaXNzaW5nID4gMCkgewogICAgICAgIGNvbnN0IGVudHJpZXMgPSBuZXcgVWludDhBcnJheShtZXRyaWNzLmxlbmd0aCArIG51bU1pc3NpbmcgKiAyKTsKICAgICAgICBlbnRyaWVzLnNldChtZXRyaWNzLmRhdGEpOwogICAgICAgIGlmIChkdXBGaXJzdEVudHJ5KSB7CiAgICAgICAgICBlbnRyaWVzW21ldHJpY3MubGVuZ3RoXSA9IG1ldHJpY3MuZGF0YVsyXTsKICAgICAgICAgIGVudHJpZXNbbWV0cmljcy5sZW5ndGggKyAxXSA9IG1ldHJpY3MuZGF0YVszXTsKICAgICAgICB9CiAgICAgICAgbWV0cmljcy5kYXRhID0gZW50cmllczsKICAgICAgfQogICAgfQogICAgZnVuY3Rpb24gc2FuaXRpemVHbHlwaChzb3VyY2UsIHNvdXJjZVN0YXJ0LCBzb3VyY2VFbmQsIGRlc3QsIGRlc3RTdGFydCwgaGludHNWYWxpZCkgewogICAgICBjb25zdCBnbHlwaFByb2ZpbGUgPSB7CiAgICAgICAgbGVuZ3RoOiAwLAogICAgICAgIHNpemVPZkluc3RydWN0aW9uczogMAogICAgICB9OwogICAgICBpZiAoc291cmNlRW5kIC0gc291cmNlU3RhcnQgPD0gMTIpIHsKICAgICAgICByZXR1cm4gZ2x5cGhQcm9maWxlOwogICAgICB9CiAgICAgIGNvbnN0IGdseWYgPSBzb3VyY2Uuc3ViYXJyYXkoc291cmNlU3RhcnQsIHNvdXJjZUVuZCk7CiAgICAgIGxldCBjb250b3Vyc0NvdW50ID0gc2lnbmVkSW50MTYoZ2x5ZlswXSwgZ2x5ZlsxXSk7CiAgICAgIGlmIChjb250b3Vyc0NvdW50IDwgMCkgewogICAgICAgIGNvbnRvdXJzQ291bnQgPSAtMTsKICAgICAgICB3cml0ZVNpZ25lZEludDE2KGdseWYsIDAsIGNvbnRvdXJzQ291bnQpOwogICAgICAgIGRlc3Quc2V0KGdseWYsIGRlc3RTdGFydCk7CiAgICAgICAgZ2x5cGhQcm9maWxlLmxlbmd0aCA9IGdseWYubGVuZ3RoOwogICAgICAgIHJldHVybiBnbHlwaFByb2ZpbGU7CiAgICAgIH0KICAgICAgbGV0IGksCiAgICAgICAgaiA9IDEwLAogICAgICAgIGZsYWdzQ291bnQgPSAwOwogICAgICBmb3IgKGkgPSAwOyBpIDwgY29udG91cnNDb3VudDsgaSsrKSB7CiAgICAgICAgY29uc3QgZW5kUG9pbnQgPSBnbHlmW2pdIDw8IDggfCBnbHlmW2ogKyAxXTsKICAgICAgICBmbGFnc0NvdW50ID0gZW5kUG9pbnQgKyAxOwogICAgICAgIGogKz0gMjsKICAgICAgfQogICAgICBjb25zdCBpbnN0cnVjdGlvbnNTdGFydCA9IGo7CiAgICAgIGNvbnN0IGluc3RydWN0aW9uc0xlbmd0aCA9IGdseWZbal0gPDwgOCB8IGdseWZbaiArIDFdOwogICAgICBnbHlwaFByb2ZpbGUuc2l6ZU9mSW5zdHJ1Y3Rpb25zID0gaW5zdHJ1Y3Rpb25zTGVuZ3RoOwogICAgICBqICs9IDIgKyBpbnN0cnVjdGlvbnNMZW5ndGg7CiAgICAgIGNvbnN0IGluc3RydWN0aW9uc0VuZCA9IGo7CiAgICAgIGxldCBjb29yZGluYXRlc0xlbmd0aCA9IDA7CiAgICAgIGZvciAoaSA9IDA7IGkgPCBmbGFnc0NvdW50OyBpKyspIHsKICAgICAgICBjb25zdCBmbGFnID0gZ2x5ZltqKytdOwogICAgICAgIGlmIChmbGFnICYgMHhjMCkgewogICAgICAgICAgZ2x5ZltqIC0gMV0gPSBmbGFnICYgMHgzZjsKICAgICAgICB9CiAgICAgICAgbGV0IHhMZW5ndGggPSAyOwogICAgICAgIGlmIChmbGFnICYgMikgewogICAgICAgICAgeExlbmd0aCA9IDE7CiAgICAgICAgfSBlbHNlIGlmIChmbGFnICYgMTYpIHsKICAgICAgICAgIHhMZW5ndGggPSAwOwogICAgICAgIH0KICAgICAgICBsZXQgeUxlbmd0aCA9IDI7CiAgICAgICAgaWYgKGZsYWcgJiA0KSB7CiAgICAgICAgICB5TGVuZ3RoID0gMTsKICAgICAgICB9IGVsc2Uga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CArIDFdID0gdmFsdWUgPj4gMSAmIDB4ZmY7CiAgICAgICAgfTsKICAgICAgfQogICAgICBjb25zdCBudW1HbHlwaHNPdXQgPSBkdXBGaXJzdEVudHJ5ID8gbnVtR2x5cGhzICsgMSA6IG51bUdseXBoczsKICAgICAgY29uc3QgbG9jYURhdGFTaXplID0gaXRlbVNpemUgKiAoMSArIG51bUdseXBoc091dCk7CiAgICAgIGNvbnN0IGxvY2FEYXRhID0gbmV3IFVpbnQ4QXJyYXkobG9jYURhdGFTaXplKTsKICAgICAgbG9jYURhdGEuc2V0KGxvY2EuZGF0YS5zdWJhcnJheSgwLCBsb2NhRGF0YVNpemUpKTsKICAgICAgbG9jYS5kYXRhID0gbG9jYURhdGE7CiAgICAgIGNvbnN0IG9sZEdseWZEYXRhID0gZ2x5Zi5kYXRhOwogICAgICBjb25zdCBvbGRHbHlmRGF0YUxlbmd0aCA9IG9sZEdseWZEYXRhLmxlbmd0aDsKICAgICAgY29uc3QgbmV3R2x5ZkRhdGEgPSBuZXcgVWludDhBcnJheShvbGRHbHlmRGF0YUxlbmd0aCk7CiAgICAgIGxldCBpLCBqOwogICAgICBjb25zdCBsb2NhRW50cmllcyA9IFtdOwogICAgICBmb3IgKGkgPSAwLCBqID0gMDsgaSA8IG51bUdseXBocyArIDE7IGkrKywgaiArPSBpdGVtU2l6ZSkgewogICAgICAgIGxldCBvZmZzZXQgPSBpdGVtRGVjb2RlKGxvY2FEYXRhLCBqKTsKICAgICAgICBpZiAob2Zmc2V0ID4gb2xkR2x5ZkRhdGFMZW5ndGgpIHsKICAgICAgICAgIG9mZnNldCA9IG9sZEdseWZEYXRhTGVuZ3RoOwogICAgICAgIH0KICAgICAgICBsb2NhRW50cmllcy5wdXNoKHsKICAgICAgICAgIGluZGV4OiBpLAogICAgICAgICAgb2Zmc2V0LAogICAgICAgICAgZW5kT2Zmc2V0OiAwCiAgICAgICAgfSk7CiAgICAgIH0KICAgICAgbG9jYUVudHJpZXMuc29ydCgoYSwgYikgPT4gewogICAgICAgIHJldHVybiBhLm9mZnNldCAtIGIub2Zmc2V0OwogICAgICB9KTsKICAgICAgZm9yIChpID0gMDsgaSA8IG51bUdseXBoczsgaSsrKSB7CiAgICAgICAgbG9jYUVudHJpZXNbaV0uZW5kT2Zmc2V0ID0gbG9jYUVudHJpZXNbaSArIDFdLm9mZnNldDsKICAgICAgfQogICAgICBsb2NhRW50cmllcy5zb3J0KChhLCBiKSA9PiB7CiAgICAgICAgcmV0dXJuIGEuaW5kZXggLSBiLmluZGV4OwogICAgICB9KTsKICAgICAgZm9yIChpID0gMDsgaSA8IG51bUdseXBoczsgaSsrKSB7CiAgICAgICAgY29uc3QgewogICAgICAgICAgb2Zmc2V0LAogICAgICAgICAgZW5kT2Zmc2V0CiAgICAgICAgfSA9IGxvY2FFbnRyaWVzW2ldOwogICAgICAgIGlmIChvZmZzZXQgIT09IDAgfHwgZW5kT2Zmc2V0ICE9PSAwKSB7CiAgICAgICAgICBicmVhazsKICAgICAgICB9CiAgICAgICAgY29uc3QgbmV4dE9mZnNldCA9IGxvY2FFbnRyaWVzW2kgKyAxXS5vZmZzZXQ7CiAgICAgICAgaWYgKG5leHRPZmZzZXQgPT09IDApIHsKICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgIH0KICAgICAgICBsb2NhRW50cmllc1tpXS5lbmRPZmZzZXQgPSBuZXh0T2Zmc2V0OwogICAgICAgIGJyZWFrOwogICAgICB9CiAgICAgIGNvbnN0IG1pc3NpbmdHbHlwaHMgPSBPYmplY3QuY3JlYXRlKG51bGwpOwogICAgICBsZXQgd3JpdGVPZmZzZXQgPSAwOwogICAgICBpdGVtRW5jb2RlKGxvY2FEYXRhLCAwLCB3cml0ZU9mZnNldCk7CiAgICAgIGZvciAoaSA9IDAsIGogPSBpdGVtU2l6ZTsgaSA8IG51bUdseXBoczsgaSsrLCBqICs9IGl0ZW1TaXplKSB7CiAgICAgICAgY29uc3QgZ2x5cGhQcm9maWxlID0gc2FuaXRpemVHbHl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udC5wb3MgPSBzdGFydDsKICAgICAgY29uc3QgbGVuZ3RoID0gcG9zdC5sZW5ndGgsCiAgICAgICAgZW5kID0gc3RhcnQgKyBsZW5ndGg7CiAgICAgIGNvbnN0IHZlcnNpb24gPSBmb250LmdldEludDMyKCk7CiAgICAgIGZvbnQuc2tpcCgyOCk7CiAgICAgIGxldCBnbHlwaE5hbWVzOwogICAgICBsZXQgdmFsaWQgPSB0cnVlOwogICAgICBsZXQgaTsKICAgICAgc3dpdGNoICh2ZXJzaW9uKSB7CiAgICAgICAgY2FzZSAweDAwMDEwMDAwOgogICAgICAgICAgZ2x5cGhOYW1lcyA9IF9mb250c191dGlscy5NYWNTdGFuZGFyZEdseXBoT3JkZXJpbmc7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIDB4MDAwMjAwMDA6CiAgICAgICAgICBjb25zdCBudW1HbHlwaHMgPSBmb250LmdldFVpbnQxNigpOwogICAgICAgICAgaWYgKG51bUdseXBocyAhPT0gbWF4cE51bUdseXBocykgewogICAgICAgICAgICB2YWxpZCA9IGZhbHNlOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIH0KICAgICAgICAgIGNvbnN0IGdseXBoTmFtZUluZGV4ZXMgPSBbXTsKICAgICAgICAgIGZvciAoaSA9IDA7IGkgPCBudW1HbHlwaHM7ICsraSkgewogICAgICAgICAgICBjb25zdCBpbmRleCA9IGZvbnQuZ2V0VWludDE2KCk7CiAgICAgICAgICAgIGlmIChpbmRleCA+PSAzMjc2OCkgewogICAgICAgICAgICAgIHZhbGlkID0gZmFsc2U7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZ2x5cGhOYW1lSW5kZXhlcy5wdXNoKGluZGV4KTsKICAgICAgICAgIH0KICAgICAgICAgIGlmICghdmFsaWQpIHsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICB9CiAgICAgICAgICBjb25zdCBjdXN0b21OYW1lcyA9IFtdLAogICAgICAgICAgICBzdHJCdWYgPSBbXTsKICAgICAgICAgIHdoaWxlIChmb250LnBvcyA8IGVuZCkgewogICAgICAgICAgICBjb25zdCBzdHJpbmdMZW5ndGggPSBmb250LmdldEJ5dGUoKTsKICAgICAgICAgICAgc3RyQnVmLmxlbmd0aCA9IHN0cmluZ0xlbmd0aDsKICAgICAgICAgICAgZm9yIChpID0gMDsgaSA8IHN0cmluZ0xlbmd0aDsgKytpKSB7CiAgICAgICAgICAgICAgc3RyQnVmW2ldID0gU3RyaW5nLmZyb21DaGFyQ29kZShmb250LmdldEJ5dGUoKSk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgY3VzdG9tTmFtZXMucHVzaChzdHJCdWYuam9pbigiIikpOwogICAgICAgICAgfQogICAgICAgICAgZ2x5cGhOYW1lcyA9IFtdOwogICAgICAgICAgZm9yIChpID0gMDsgaSA8IG51bUdseXBoczsgKytpKSB7CiAgICAgICAgICAgIGNvbnN0IGogPSBnbHlwaE5hbWVJbmRleGVzW2ldOwogICAgICAgICAgICBpZiAoaiA8IDI1OCkgewogICAgICAgICAgICAgIGdseXBoTmFtZXMucHVzaChfZm9udHNfdXRpbHMuTWFjU3RhbmRhcmRHbHlwaE9yZGVyaW5nW2pdKTsKICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgfQogICAgICAgICAgICBnbHlwaE5hbWVzLnB1c2goY3VzdG9tTmFtZXNbaiAtIDI1OF0pOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAweDAwMDMwMDAwOgogICAgICAgICAgYnJlYWs7CiAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICgwLCBfdXRpbC53YXJuKSgiVW5rbm93bi91bnN1cHBvcnRlZCBwb3N0IHRhYmxlIHZlcnNpb24gIiArIHZlcnNpb24pOwogICAgICAgICAgdmFsaWQgPSBmYWxzZTsKICAgICAgICAgIGlmIChwcm9wZXJ0aWVzT2JqLmRlZmF1bHRFbmNvZGluZykgewogICAgICAgICAgICBnbHlwaE5hbWVzID0gcHJvcGVydGllc09iai5kZWZhdWx0RW5jb2Rpbmc7CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgfQogICAgICBwcm9wZXJ0aWVzT2JqLmdseXBoTmFtZXMgPSBnbHlwaE5hbWVzOwogICAgICByZXR1cm4gdmFsaWQ7CiAgICB9CiAgICBmdW5jdGlvbiByZWFkTmFtZVRhYmxlKG5hbWVUYWJsZSkgewogICAgICBjb25zdCBzdGFydCA9IChmb250LnN0YXJ0IHx8IDApICsgbmFtZVRhYmxlLm9mZnNldDsKICAgICAgZm9udC5wb3MgPSBzdGFydDsKICAgICAgY29uc3QgbmFtZXMgPSBbW10sIFtdXSwKICAgICAgICByZWNvcmRzID0gW107CiAgICAgIGNvbnN0IGxlbmd0aCA9IG5hbWVUYWJsZS5sZW5ndGgsCiAgICAgICAgZW5kID0gc3RhcnQgKyBsZW5ndGg7CiAgICAgIGNvbnN0IGZvcm1hdCA9IGZvbnQuZ2V0VWludDE2KCk7CiAgICAgIGNvbnN0IEZPUk1BVF8wX0hFQURFUl9MRU5HVEggPSA2OwogICAgICBpZiAoZm9ybWF0ICE9PSAwIHx8IGxlbmd0aCA8IEZPUk1BVF8wX0hFQURFUl9MRU5HVEgpIHsKICAgICAgICByZXR1cm4gW25hbWVzLCByZWNvcmRzXTsKICAgICAgfQogICAgICBjb25zdCBudW1SZWNvcmRzID0gZm9udC5nZXRVaW50MTYoKTsKICAgICAgY29uc3Qgc3RyaW5nc1N0YXJ0ID0gZm9udC5nZXRVaW50MTYoKTsKICAgICAgY29uc3QgTkFNRV9SRUNPUkRfTEVOR1RIID0gMTI7CiAgICAgIGxldCBpLCBpaTsKICAgICAgZm9yIChpID0gMDsgaSA8IG51bVJlY29yZHMgJiYgZm9udC5wb3MgKyBOQU1FX1JFQ09SRF9MRU5HVEggPD0gZW5kOyBpKyspIHsKICAgICAgICBjb25zdCByID0gewogICAgICAgICAgcGxhdGZvcm06IGZvbnQuZ2V0VWludDE2KCksCiAgICAgICAgICBlbmNvZGluZzogZm9udC5nZXRVaW50MTYoKSwKICAgICAgICAgIGxhbmd1YWdlOiBmb250LmdldFVpbnQxNigpLAogICAgICAgICAgbmFtZTogZm9udC5nZXRVaW50MTYoKSwKICAgICAgICAgIGxlbmd0aDogZm9udC5nZXRVaW50MTYoKSwKICAgICAgICAgIG9mZnNldDogZm9udC5nZXRVaW50MTYoKQogICAgICAgIH07CiAgICAgICAgaWYgKGlzTWFjTmFtZVJlY29yZChyKSB8fCBpc1dpbk5hbWVSZWNvcmQocikpIHsKICAgICAgICAgIHJlY29yZHMucHVzaChyKTsKICAgICAgICB9CiAgICAgIH0KICAgICAgZm9yIChpID0gMCwgaWkgPSByZWNvcmRzLmxlbmd0aDsgaSA8IGlpOyBpKyspIHsKICAgICAgICBjb25zdCByZWNvcmQgPSByZWNvcmRzW2ldOwogICAgICAgIGlmIChyZWNvcmQubGVuZ3RoIDw9IDApIHsKICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgIH0KICAgICAgICBjb25zdCBwb3MgPSBzdGFydCArIHN0cmluZ3NTdGFydCArIHJlY29yZC5vZmZzZXQ7CiAgICAgICAgaWYgKHBvcyArIHJlY29yZC5sZW5ndGggPiBlbmQpIHsKICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgIH0KICAgICAgICBmb250LnBvcyA9IHBvczsKICAgICAgICBjb25zdCBuYW1lSW5kZXggPSByZWNvcmQubmFtZTsKICAgICAgICBpZiAocmVjb3JkLmVuY29kaW5nKSB7CiAgICAgICAgICBsZXQgc3RyID0gIiI7CiAgICAgICAgICBmb3IgKGxldCBqID0gMCwgamogPSByZWNvcmQubGVuZ3RoOyBqIDwgamo7IGogKz0gMikgewogICAgICAgICAgICBzdHIgKz0gU3RyaW5nLmZyb21DaGFyQ29kZShmb250LmdldFVpbnQxNigpKTsKICAgICAgICAgIH0KICAgICAgICAgIG5hbWVzWzFdW25hbWVJbmRleF0gPSBzdHI7CiAgICAg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gPSAwLAogICAgICAgIGosCiAgICAgICAgbiwKICAgICAgICBiLAogICAgICAgIGZ1bmNJZCwKICAgICAgICBwYywKICAgICAgICBsYXN0RW5kZiA9IDAsCiAgICAgICAgbGFzdERlZmYgPSAwOwogICAgICBjb25zdCBzdGFjayA9IFtdOwogICAgICBjb25zdCBjYWxsc3RhY2sgPSBbXTsKICAgICAgY29uc3QgZnVuY3Rpb25zQ2FsbGVkID0gW107CiAgICAgIGxldCB0b29Db21wbGV4VG9Gb2xsb3dGdW5jdGlvbnMgPSB0dENvbnRleHQudG9vQ29tcGxleFRvRm9sbG93RnVuY3Rpb25zOwogICAgICBsZXQgaW5GREVGID0gZmFsc2UsCiAgICAgICAgaWZMZXZlbCA9IDAsCiAgICAgICAgaW5FTFNFID0gMDsKICAgICAgZm9yIChsZXQgaWkgPSBkYXRhLmxlbmd0aDsgaSA8IGlpOykgewogICAgICAgIGNvbnN0IG9wID0gZGF0YVtpKytdOwogICAgICAgIGlmIChvcCA9PT0gMHg0MCkgewogICAgICAgICAgbiA9IGRhdGFbaSsrXTsKICAgICAgICAgIGlmIChpbkZERUYgfHwgaW5FTFNFKSB7CiAgICAgICAgICAgIGkgKz0gbjsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIGZvciAoaiA9IDA7IGogPCBuOyBqKyspIHsKICAgICAgICAgICAgICBzdGFjay5wdXNoKGRhdGFbaSsrXSk7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICB9IGVsc2UgaWYgKG9wID09PSAweDQxKSB7CiAgICAgICAgICBuID0gZGF0YVtpKytdOwogICAgICAgICAgaWYgKGluRkRFRiB8fCBpbkVMU0UpIHsKICAgICAgICAgICAgaSArPSBuICogMjsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIGZvciAoaiA9IDA7IGogPCBuOyBqKyspIHsKICAgICAgICAgICAgICBiID0gZGF0YVtpKytdOwogICAgICAgICAgICAgIHN0YWNrLnB1c2goYiA8PCA4IHwgZGF0YVtpKytdKTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgIH0gZWxzZSBpZiAoKG9wICYgMHhmOCkgPT09IDB4YjApIHsKICAgICAgICAgIG4gPSBvcCAtIDB4YjAgKyAxOwogICAgICAgICAgaWYgKGluRkRFRiB8fCBpbkVMU0UpIHsKICAgICAgICAgICAgaSArPSBuOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgZm9yIChqID0gMDsgaiA8IG47IGorKykgewogICAgICAgICAgICAgIHN0YWNrLnB1c2goZGF0YVtpKytdKTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgIH0gZWxzZSBpZiAoKG9wICYgMHhmOCkgPT09IDB4YjgpIHsKICAgICAgICAgIG4gPSBvcCAtIDB4YjggKyAxOwogICAgICAgICAgaWYgKGluRkRFRiB8fCBpbkVMU0UpIHsKICAgICAgICAgICAgaSArPSBuICogMjsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIGZvciAoaiA9IDA7IGogPCBuOyBqKyspIHsKICAgICAgICAgICAgICBiID0gZGF0YVtpKytdOwogICAgICAgICAgICAgIHN0YWNrLnB1c2goYiA8PCA4IHwgZGF0YVtpKytdKTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgIH0gZWxzZSBpZiAob3AgPT09IDB4MmIgJiYgIXRvb0NvbXBsZXhUb0ZvbGxvd0Z1bmN0aW9ucykgewogICAgICAgICAgaWYgKCFpbkZERUYgJiYgIWluRUxTRSkgewogICAgICAgICAgICBmdW5jSWQgPSBzdGFjay5hdCgtMSk7CiAgICAgICAgICAgIGlmIChpc05hTihmdW5jSWQpKSB7CiAgICAgICAgICAgICAgKDAsIF91dGlsLmluZm8pKCJUVDogQ0FMTCBlbXB0eSBzdGFjayAob3IgaW52YWxpZCBlbnRyeSkuIik7CiAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgdHRDb250ZXh0LmZ1bmN0aW9uc1VzZWRbZnVuY0lkXSA9IHRydWU7CiAgICAgICAgICAgICAgaWYgKGZ1bmNJZCBpbiB0dENvbnRleHQuZnVuY3Rpb25zU3RhY2tEZWx0YXMpIHsKICAgICAgICAgICAgICAgIGNvbnN0IG5ld1N0YWNrTGVuZ3RoID0gc3RhY2subGVuZ3RoICsgdHRDb250ZXh0LmZ1bmN0aW9uc1N0YWNrRGVsdGFzW2Z1bmNJZF07CiAgICAgICAgICAgICAgICBpZiAobmV3U3RhY2tMZW5ndGggPCAwKSB7CiAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKSgiVFQ6IENBTEwgaW52YWxpZCBmdW5jdGlvbnMgc3RhY2sgZGVsdGEuIik7CiAgICAgICAgICAgICAgICAgIHR0Q29udGV4dC5oaW50c1ZhbGlkID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIHN0YWNrLmxlbmd0aCA9IG5ld1N0YWNrTGVuZ3RoOwogICAgICAgICAgICAgIH0gZWxzZSBpZiAoZnVuY0lkIGluIHR0Q29udGV4dC5mdW5jdGlvbnNEZWZpbmVkICYmICFmdW5jdGlvbnNDYWxsZWQuaW5jbHVkZXMoZnVuY0lkKSkgewogICAgICAgICAgICAgICAgY2FsbHN0YWNrLnB1c2goewogICAgICAgICAgICAgICAgICBkYXRhLAogICAgICAgICAgICAgICAgICBpLAogICAgICAgICAgICAgICAgICBzdGFja1RvcDogc3RhY2subGVuZ3RoIC0gMQogICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICBmdW5jdGlvbnNDYWxsZWQucHVzaChmdW5jSWQpOwogICAgICAgICAgICAgICAgcGMgPSB0dENvbnRleHQuZnVuY3Rpb25zRGVmaW5lZFtmdW5jSWRdOwogICAgICAgICAgICAgICAgaWYgKCFwYykgewogICAgICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoIlRUOiBDQUxMIG5vbi1leGlzdGVudCBmdW5jdGlvbiIpOwogICAgICAgICAgICAgICAgICB0dENvbnRleHQuaGludHNWYWxpZCA9IGZhbHNlOwogICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBkYXRhID0gcGMuZGF0YTsKICAgICAgICAgICAgICAgIGkgPSBwYy5pOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgIH0gZWxzZSBpZiAob3AgPT09IDB4MmMgJiYgIXRvb0NvbXBsZXhUb0ZvbGxvd0Z1bmN0aW9ucykgewogICAgICAgICAgaWYgKGluRkRFRiB8fCBpbkVMU0UpIHsKICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKCJUVDogbmVzdGVkIEZERUZzIG5vdCBhbGxvd2VkIik7CiAgICAgICAgICAgIHRvb0NvbXBsZXhUb0ZvbGxvd0Z1bmN0aW9ucyA9IHRydWU7CiAgICAgICAgICB9CiAgICAgICAgICBpbkZERUYgPSB0cnVlOwogICAgICAgICAgbGFzdERlZmYgPSBpOwogICAgICAgICAgZnVuY0lkID0gc3RhY2sucG9wKCk7CiAgICAgICAgICB0dENvbnRleHQuZnVuY3Rpb25zRGVmaW5lZFtmdW5jSWRdID0gewogICAgICAgICAgICBkYXRhLAogICAgICAgICAgICBpCiAgICAgICAgICB9OwogICAgICAgIH0gZWxzZSBpZiAob3AgPT09IDB4MmQpIHsKICAgICAgICAgIGlmIChpbkZERUYpIHsKICAgICAgICAgICAgaW5GREVGID0gZmFsc2U7CiAgICAgICAgICAgIGxhc3RFbmRmID0gaTsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHBjID0gY2FsbHN0YWNrLnBvcCgpOwogICAgICAgICAgICBpZiAoIXBjKSB7CiAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKCJUVDogRU5ERiBiYWQgc3RhY2siKTsKICAgICAgICAgICAgICB0dENvbnRleHQuaGludHNWYWxpZCA9IGZhbHNlOwogICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgfQogICAgICAgICAgICBmdW5jSWQgPSBmdW5jdGlvbnNDYWxsZWQucG9wKCk7CiAgICAgICAgICAgIGRhdGEgPSBwYy5kYXRhOwogICAgICAgICAgICBpID0gcGMuaTsKICAgICAgICAgICAgdHRDb250ZXh0LmZ1bmN0aW9uc1N0YWNrRGVsdGFzW2Z1bmNJZF0gPSBzdGFjay5sZW5ndGggLSBwYy5zdGFja1RvcDsKICAgICAgICAgIH0KICAgICAgICB9IGVsc2UgaWYgKG9wID09PSAweDg5KSB7CiAgICAgICAgICBpZiAoaW5GREVGIHx8IGluRUxTRSkgewogICAgICAgICAgICAoMCwgX3V0aWwud2FybikoIlRUOiBuZXN0ZWQgSURFRnMgbm90IGFsbG93ZWQiKTsKICAgICAgICAgICAgdG9vQ29tcGxleFRvRm9sbG93RnVuY3Rpb25zID0gdHJ1ZTsKICAgICAgICAgIH0KICAgICAgICAgIGluRkRFRiA9IHRydWU7CiAgICAgICAgICBsYXN0RGVmZiA9IGk7CiAgICAgICAgfSBlbHNlIGlmIChvcCA9PT0gMHg1OCkgewogICAgICAgICAgKytpZkxldmVsOwogICAgICAgIH0gZWxzZSBpZiAob3AgPT09IDB4MWIpIHsKICAgICAgICAgIGluRUxTRSA9IGlmTGV2ZWw7CiAgICAgICAgfSBlbHNlIGlmIChvcCA9PT0gMHg1OSkgewogICAgICAgICAgaWYgKGluRUxTRSA9PT0gaWZMZXZlbCkgewogICAgICAgICAgICBpbkVMU0UgPSAwOwogICAgICAgICAgfQogICAgICAgICAgLS1pZkxldmVsOwogICAgICAgIH0gZWxzZSBpZiAob3AgPT09IDB4MWMpIHsKICAgICAgICAgIGlmICghaW5GREVGICYmICFpbkVMU0UpIHsKICAgICAgICAgICAgY29uc3Qgb2Zmc2V0ID0gc3RhY2suYXQoLTEpOwogICAgICAgICAgICBpZiAob2Zmc2V0ID4gMCkgewogICAgICAgICAgICAgIGkgKz0gb2Zmc2V0IC0gMTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZiAoIWluRkRFRiAmJiAhaW5FTFNFKSB7CiAgICAgICAgICBsZXQgc3RhY2tEZWx0YSA9IDA7CiAgICAgICAgICBpZiAob3AgPD0gMHg4ZSkgewogICAgICAgICAgICBzdGFja0RlbHRhID0gVFRPcHNTdGFja0RlbHRhc1tvcF07CiAgICAgICAgICB9IGVsc2UgaWYgKG9wID49IDB4YzAgJiYgb3AgPD0gMHhkZikgewogICAgICAgICAgICBzdGFja0RlbHRhID0gLTE7CiAgICAgICAgICB9IGVsc2UgaWYgKG9wID49IDB4ZTApIHsKICAgICAgICAgICAgc3RhY2tEZWx0YSA9IC0yOwogICAgICAgICAgfQogICAgICAgICAgaWYgKG9wID49IDB4NzEgJiYgb3AgPD0gMHg3NSkgewogICAgICAgICAgICBuID0gc3RhY2sucG9wKCk7CiAgICAgICAgICAgIGlmICghaXNOYU4obikpIHsKICAgICAgICAgICAgICBzdGFja0RlbHRhID0gLW4gKiAyOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICB3aGlsZSAoc3RhY2tEZWx0YSA8IDAgJiYgc3RhY2subGVuZ3RoID4gMCkgewogICAgICAgICAgICBzdGFjay5wb3AoKTsKICAgICAgICAgICAgc3RhY2tEZWx0YSsrOwogICAgICAgICAgfQogICAgICAgICAgd2hpbGUgKHN0YWNrRGVsdGEgPiAwKSB7CiAgICAgICAgICAgIHN0YWNrLnB1c2goTmFOKTsKICAgICAgICAgICAgc3RhY2tEZWx0YS0tOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgfQogICAgICB0dENvbnRleHQudG9vQ29tcGxleFRvRm9sbG93RnVuY3Rpb25zID0gdG9vQ29tcGxleFRvRm9sbG93RnVuY3Rpb25zOwogICAgICBjb25zdCBjb250ZW50ID0gW2RhdGFdOwogICAgICBpZiAoaSA+IGRhdGEubGVuZ3RoKSB7CiAgICAgICAgY29udGVudC5wdXNoKG5ldyBVaW50OEFycmF5KGkgLSBkYXRhLmxlbmd0aCkpOwogICAgICB9CiAgICAgIGlmIChsYXN0RGVmZiA+IGxhc3RFbmRmKSB7CiAgICAgICAgKDAsIF91dGlsLndhcm4pKCJUVDogY29tcGxlbWVudGluZyBhIG1pc3NpbmcgZnVuY3Rpb24gdGFpbCIpOwogICAgICAgIGNvbnRlbnQucHVzaChuZXcgVWludDhBcnJheShbMHgyMiwgMHgyZF0pKTsKICAgICAgfQogICAgICBmb2xkVFRUYWJsZSh0YWJsZSwgY29udGVudCk7CiAgICB9CiAgICBmdW5jdGlvbiBjaGVja0ludmFsaWRGdW5jdGlvbnModHRDb250ZXh0LCBtYXhGdW5jdGlvbkRlZnMpIHsKICAgICAgaWYgKHR0Q29udGV4dC50b29Db21wbGV4VG9Gb2xsb3dGdW5jdGlvbnMpIHsKICAgICAgICByZXR1cm47CiAgICAgIH0KICAgICAgaWYgKHR0Q29udGV4dC5mdW5jdGlvbnNEZWZpbmVkLmxlbmd0aCA+IG1heEZ1bmN0aW9uRGVmcykgewogICAgICAgICgwLCBfdXRpbC53YXJuKSgiVFQ6IG1vcmUgZnVuY3Rpb25zIGRlZmluZWQgdGhhbiBleHBlY3RlZCIpOwogICAgICAgIHR0Q29udGV4dC5oaW50c1ZhbGlkID0gZmFsc2U7CiAgICAgICAgcmV0dXJuOwogICAgICB9CiAgICAgIGZvciAobGV0IGogPSAwLCBqaiA9IHR0Q29udGV4dC5mdW5jdGlvbnNVc2VkLmxlbmd0aDsgaiA8IGpqOyBqKyspIHsKICAgICAgICBpZiAoaiA+IG1heEZ1bmN0aW9uRGVmcykgewogICAgICAgICAgKDAsIF91dGlsLndhcm4pKCJUVDogaW52YWxpZCBmdW5jdGlvbiBpZDogIiArIGopOwogICAgICAgICAgdHRDb250ZXh0LmhpbnRzVmFsaWQgPSBmYWxzZTsKICAgICAgICAgIHJldHVybjsKICAgICAgICB9CiAgICAgICAgaWYgKHR0Q29udGV4dC5mdW5jdGlvbnNVc2VkW2pdICYmICF0dENvbnRleHQuZnVuY3Rpb25zRGVmaW5lZFtqXSkgewogICAgICAgICAgKDAsIF91dGlsLndhcm4pKCJUVDogdW5kZWZpbmVkIGZ1bmN0aW9uOiAiICsgaik7CiAgICAgICAgICB0dENvbnRleHQuaGludHNWYWxpZCA9IGZhbHNlOwogICAgICAgICAgcmV0dXJuOwogICAgICAgIH0KICAgICAgfQogICAgfQogICAgZnVuY3Rpb24gZm9sZFRUVGFibGUodGFibGUsIGNvbnRlbnQpIHsKICAgICAgaWYgKGNvbnRlbnQubGVuZ3RoID4gMSkgewogICAgICAgIGxldCBuZXdMZW5ndGggPSAwOwogICAgICAgIGxldCBqLCBqajsKICAgICAgICBmb3IgKGogPSAwLCBqaiA9IGNvbnRlbnQubGVuZ3RoOyBqIDwgamo7IGorKykgewogICAgICAgICAgbmV3TGVuZ3RoICs9IGNvbnRlbnRbal0ubGVuZ3RoOwogICAgICAgIH0KICAgICAgICBuZXdMZW5ndGggPSBuZXdMZW5ndGggKyAzICYgfjM7CiAgICAgICAgY29uc3QgcmVzdWx0ID0gbmV3IFVpbnQ4QXJyYXkobmV3TGVuZ3RoKTsKICAgICAgICBsZXQgcG9zID0gMDsKICAgICAgICBmb3IgKGogPSAwLCBqaiA9IGNvbnRlbnQubGVuZ3RoOyBqIDwgamo7IGorKykgewogICAgICAgICAgcmVzdWx0LnNldChjb250ZW50W2pdLCBwb3MpOwogICAgICAgICAgcG9zICs9IGNvbnRlbnRbal0ubGVuZ3RoOwogICAgICAgIH0KICAgICAgICB0YWJsZS5kYXRhID0gcmVzdWx0OwogICAgICAgIHRhYmxlLmxlbmd0aCA9IG5ld0xlbmd0aDsKICAgICAgfQogICAgfQogICAgZnVuY3Rpb24gc2FuaXRpemVUVFByb2dyYW1zKGZwZ20sIHByZXAsIGN2dCwgbWF4RnVuY3Rpb25EZWZzKSB7CiAgICAgIGNvbnN0IHR0Q29udGV4dCA9IHsKICAgICAgICBmdW5jdGlvbnNEZWZpbmVkOiBbXSwKICAg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HsKICAgICAgaWYgKCF0YWJsZXMubG9jYSkgewogICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcignUmVxdWlyZWQgImxvY2EiIHRhYmxlIGlzIG5vdCBmb3VuZCcpOwogICAgICB9CiAgICAgIGlmICghdGFibGVzLmdseWYpIHsKICAgICAgICAoMCwgX3V0aWwud2FybikoJ1JlcXVpcmVkICJnbHlmIiB0YWJsZSBpcyBub3QgZm91bmQgLS0gdHJ5aW5nIHRvIHJlY292ZXIuJyk7CiAgICAgICAgdGFibGVzLmdseWYgPSB7CiAgICAgICAgICB0YWc6ICJnbHlmIiwKICAgICAgICAgIGRhdGE6IG5ldyBVaW50OEFycmF5KDApCiAgICAgICAgfTsKICAgICAgfQogICAgICB0aGlzLmlzT3BlblR5cGUgPSBmYWxzZTsKICAgIH0KICAgIGlmICghdGFibGVzLm1heHApIHsKICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKCdSZXF1aXJlZCAibWF4cCIgdGFibGUgaXMgbm90IGZvdW5kJyk7CiAgICB9CiAgICBmb250LnBvcyA9IChmb250LnN0YXJ0IHx8IDApICsgdGFibGVzLm1heHAub2Zmc2V0OwogICAgY29uc3QgdmVyc2lvbiA9IGZvbnQuZ2V0SW50MzIoKTsKICAgIGNvbnN0IG51bUdseXBocyA9IGZvbnQuZ2V0VWludDE2KCk7CiAgICBpZiAocHJvcGVydGllcy5zY2FsZUZhY3RvcnMgJiYgcHJvcGVydGllcy5zY2FsZUZhY3RvcnMubGVuZ3RoID09PSBudW1HbHlwaHMgJiYgaXNUcnVlVHlwZSkgewogICAgICBjb25zdCB7CiAgICAgICAgc2NhbGVGYWN0b3JzCiAgICAgIH0gPSBwcm9wZXJ0aWVzOwogICAgICBjb25zdCBpc0dseXBoTG9jYXRpb25zTG9uZyA9IGludDE2KHRhYmxlcy5oZWFkLmRhdGFbNTBdLCB0YWJsZXMuaGVhZC5kYXRhWzUxXSk7CiAgICAgIGNvbnN0IG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aV0gKiBzaWduZWRJbnQxNihtZXRyaWNzW2ogKyAyXSwgbWV0cmljc1tqICsgM10pKTsKICAgICAgICB3cml0ZVNpZ25lZEludDE2KG1ldHJpY3MsIGogKyAyLCBsc2IpOwogICAgICB9CiAgICB9CiAgICBsZXQgbnVtR2x5cGhzT3V0ID0gbnVtR2x5cGhzICsgMTsKICAgIGxldCBkdXBGaXJzdEVudHJ5ID0gdHJ1ZTsKICAgIGlmIChudW1HbHlwaHNPdXQgPiAweGZmZmYpIHsKICAgICAgZHVwRmlyc3RFbnRyeSA9IGZhbHNlOwogICAgICBudW1HbHlwaHNPdXQgPSBudW1HbHlwaHM7CiAgICAgICgwLCBfdXRpbC53YXJuKSgiTm90IGVub3VnaCBzcGFjZSBpbiBnbHlmcyB0byBkdXBsaWNhdGUgZmlyc3QgZ2x5cGguIik7CiAgICB9CiAgICBsZXQgbWF4RnVuY3Rpb25EZWZzID0gMDsKICAgIGxldCBtYXhTaXplT2ZJbnN0cnVjdGlvbnMgPSAwOwogICAgaWYgKHZlcnNpb24gPj0gMHgwMDAxMDAwMCAmJiB0YWJsZXMubWF4cC5sZW5ndGggPj0gMjIpIHsKICAgICAgZm9udC5wb3MgKz0gODsKICAgICAgY29uc3QgbWF4Wm9uZXMgPSBmb250LmdldFVpbnQxNigpOwogICAgICBpZiAobWF4Wm9uZXMgPiAyKSB7CiAgICAgICAgdGFibGVzLm1heHAuZGF0YVsxNF0gPSAwOwogICAgICAgIHRhYmxlcy5tYXhwLmRhdGFbMTVdID0gMjsKICAgICAgfQogICAgICBmb250LnBvcyArPSA0OwogICAgICBtYXhGdW5jdGlvbkRlZnMgPSBmb250LmdldFVpbnQxNigpOwogICAgICBmb250LnBvcyArPSA0OwogICAgICBtYXhTaXplT2ZJbnN0cnVjdGlvbnMgPSBmb250LmdldFVpbnQxNigpOwogICAgfQogICAgdGFibGVzLm1heHAuZGF0YVs0XSA9IG51bUdseXBoc091dCA+PiA4OwogICAgdGFibGVzLm1heHAuZGF0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lKTsKICAgICAgICAgIH0KICAgICAgICAgIGlmICh1bmljb2RlT3JDaGFyQ29kZSA9PT0gdW5kZWZpbmVkKSB7CiAgICAgICAgICAgIGlmICghcHJvcGVydGllcy5nbHlwaE5hbWVzICYmIHByb3BlcnRpZXMuaGFzSW5jbHVkZWRUb1VuaWNvZGVNYXAgJiYgISh0aGlzLnRvVW5pY29kZSBpbnN0YW5jZW9mIF90b191bmljb2RlX21hcC5JZGVudGl0eVRvVW5pY29kZU1hcCkpIHsKICAgICAgICAgICAgICBjb25zdCB1bmljb2RlID0gdGhpcy50b1VuaWNvZGUuZ2V0KGNoYXJDb2RlKTsKICAgICAgICAgICAgICBpZiAodW5pY29kZSkgewogICAgICAgICAgICAgICAgdW5pY29kZU9yQ2hhckNvZGUgPSB1bmljb2RlLmNvZGVQb2ludEF0KDApOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAodW5pY29kZU9yQ2hhckNvZGUgPT09IHVuZGVmaW5lZCkgewogICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICBmb3IgKGNvbnN0IG1hcHBpbmcgb2YgY21hcE1hcHBpbmdzKSB7CiAgICAgICAgICAgIGlmIChtYXBwaW5nLmNoYXJDb2RlICE9PSB1bmljb2RlT3JDaGFyQ29kZSkgewogICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGNoYXJDb2RlVG9HbHlwaElkW2NoYXJDb2RlXSA9IG1hcHBpbmcuZ2x5cGhJZDsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9IGVsc2UgaWYgKGNtYXBQbGF0Zm9ybUlkID09PSAwKSB7CiAgICAgICAgZm9yIChjb25zdCBtYXBwaW5nIG9mIGNtYXBNYXBwaW5ncykgewogICAgICAgICAgY2hhckNvZGVUb0dseXBoSWRbbWFwcGluZy5jaGFyQ29k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oZ2x5cGhJZCkpIHsKICAgICAgICAgICAgY2hhckNvZGVUb0dseXBoSWRbaV0gPSBnbHlwaElkOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgfQogICAgfQogICAgaWYgKGNoYXJDb2RlVG9HbHlwaElkLmxlbmd0aCA9PT0gMCkgewogICAgICBjaGFyQ29kZVRvR2x5cGhJZFswXSA9IDA7CiAgICB9CiAgICBsZXQgZ2x5cGhaZXJvSWQgPSBudW1HbHlwaHNPdXQgLSAxOwogICAgaWYgKCFkdXBGaXJzdEVudHJ5KSB7CiAgICAgIGdseXBoWmVyb0lkID0gMDsKICAgIH0KICAgIGlmICghcHJvcGVydGllcy5jc3NGb250SW5mbykgewogICAgICBjb25zdCBuZXdNYXBwaW5nID0gYWRqdXN0TWFwcGluZyhjaGFyQ29kZVRvR2x5cGhJZCwgaGFzR2x5cGgsIGdseXBoWmVyb0lkLCB0aGlzLnRvVW5pY29kZSk7CiAgICAgIHRoaXMudG9Gb250Q2hhciA9IG5ld01hcHBpbmcudG9Gb250Q2hhcjsKICAgICAgdGFibGVzLmNtYXAgPSB7CiAgICAgICAgdGFnOiAiY21hcCIsCiAgICAgICAgZGF0YTogY3JlYXRlQ21hcFRhYmxlKG5ld01hcHBpbmcuY2hhckNvZGVUb0dseXBoSWQsIG5ld01hcHBpbmcudG9Vbmljb2RlRXh0cmFNYXAsIG51bUdseXBoc091dCkKICAgICAgfTsKICAgICAgaWYgKCF0YWJsZXNbIk9TLzIiXSB8fCAhdmFsaWRhdGVPUzJUYWJsZSh0YWJsZXNbIk9TLzIiXSwgZm9udCkpIHsKICAgICAgICB0YWJsZXNbIk9TLzIiXSA9IHsKICAgICAgICAgIHRhZzogIk9TLzIiLAogICAgICAgICAgZGF0YTogY3JlYXRlT1MyVGFibGUocHJvcGVydGllcywgbmV3TWFwcGluZy5jaGFyQ29kZVRvR2x5cGhJZCwgbWV0cmljc092ZXJyaWRlKQogICAgICAgIH07CiAgICAgIH0KICAgIH0KICAgIGlm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dFRydWVUeXBlVG9Vbmljb2RlKHByb3BlcnRpZXMsIHRoaXMuaXNTeW1ib2xpY0ZvbnQsIG5hbWVSZWNvcmRzKTsKICAgICAgfQogICAgfQogICAgY29uc3QgYnVpbGRlciA9IG5ldyBfb3BlbnR5cGVfZmlsZV9idWlsZGVyLk9wZW5UeXBlRmlsZUJ1aWxkZXIoaGVhZGVyLnZlcnNpb24pOwogICAgZm9yIChjb25zdCB0YWJsZVRhZyBpbiB0YWJsZXMpIHsKICAgICAgYnVpbGRlci5hZGRUYWJsZSh0YWJsZVRhZywgdGFibGVzW3RhYmxlVGFnXS5kYXRhKTsKICAgIH0KICAgIHJldHVybiBidWlsZGVyLnRvQXJyYXkoKTsKICB9CiAgY29udmVydChmb250TmFtZSwgZm9udCwgcHJvcGVydGllcykgewogICAgcHJvcGVydGllcy5maXhlZFBpdGNoID0gZmFsc2U7CiAgICBpZiAocHJvcGVydGllcy5idWlsdEluRW5jb2RpbmcpIHsKICAgICAgYWRqdXN0VHlwZTFUb1VuaWNvZGUocHJvcGVydGllcywgcHJvcGVydGllcy5idWlsdEluRW5jb2RpbmcpOwogICAgfQogICAgbGV0IGdseXBoWmVyb0lkID0gMTsKICAgIGlmIChmb250IGluc3RhbmNlb2YgX2NmZl9mb250LkNGRkZvbnQpIHsKICAgICAgZ2x5cGhaZXJvSWQgPSBmb250Lm51bUdseXBocyAtIDE7CiAgICB9CiAgICBjb25zdCBtYXBwaW5nID0gZm9udC5nZXRHbHlwaE1hcHBpbmcocHJvcGVydGllcyk7CiAgICBsZXQgbmV3TWFwcGluZyA9IG51bGw7CiAgICBsZXQgbmV3Q2hhckNvZGVUb0dseXBoSWQgPSBtYXBwaW5nOwogICAgbGV0IHRvVW5pY29kZUV4dHJhTWFwID0gbnVsbDsKICAgIGlmICghcHJvcGVydGllcy5jc3NGb250SW5mbykgewogICAgICBuZXdNYXBwaW5nID0gYWRqdXN0TWFwcGluZyhtYXBwaW5nLCBmb250Lmhhc0dseXBoSWQuYmluZChmb250KSwgZ2x5cGhaZXJvSWQsIHRoaXMudG9Vbmljb2RlKTsKICAgICAgdGhpcy50b0ZvbnRDaGFyID0gbmV3TWFwcGluZy50b0ZvbnRDaGFyOwogICAgICBuZXdDaGFyQ29kZVRvR2x5cGhJZCA9IG5ld01hcHBpbmcuY2hhckNvZGVUb0dseXBoSWQ7CiAgICAgIHRvVW5pY29kZUV4dHJhTWFwID0gbmV3TWFwcGluZy50b1VuaWNvZGVFeHRyYU1hcDsKICAgIH0KICAgIGNvbnN0IG51bUdseXBocyA9IGZvbnQubnVtR2x5cGhzOwogICAgZnVuY3Rpb24gZ2V0Q2hhckNvZGVzKGNoYXJDb2RlVG9HbHlwaElkLCBnbHlwaElkKSB7CiAgICAgIGxldCBjaGFyQ29kZXMgPSBudWxsOwogICAgICBmb3IgKGNvbnN0IGNoYXJDb2RlIGluIGNoYXJDb2RlVG9HbHlwaElkKSB7CiAgICAgICAgaWYgKGdseXBoSWQgPT09IGNoYXJDb2RlVG9HbHlwaElkW2NoYXJDb2RlXSkgewogICAgICAgICAgaWYgKCFjaGFyQ29kZXMpIHsKICAgICAgICAgICAgY2hhckNvZGVzID0gW107CiAgICAgICAgICB9CiAgICAgICAgICBjaGFyQ29kZXMucHVzaChjaGFyQ29kZSB8IDApOwogICAgICAgIH0KICAgICAgfQogICAgICByZXR1cm4gY2hhckNvZGVzOwogICAgfQogICAgZnVuY3Rpb24gY3JlYXRlQ2hhckNvZGUoY2hhckNvZGVUb0dseXBoSWQsIGdseXBoSWQpIHsKICAgICAgZm9yIChjb25zdCBjaGFyQ29kZSBpbiBjaGFyQ29kZVRvR2x5cGhJZCkgewogICAgICAgIGlmIChnbHlwaElkID09PSBjaGFyQ29kZVRvR2x5cGhJZFtjaGFyQ29kZV0pIHsKICAgICAgICAgIHJldHVybiBjaGFyQ29kZSB8IDA7CiAgICAgICAgfQogICAgICB9CiAgICAgIG5ld01hcHBpbmcuY2hhckNvZGVUb0dseXBoSWRbbmV3TWFwcG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aWVzLmRlc2NlbnQpICsgIlx4MDBceDAwIiArICJceEZGXHhGRiIgKyAiXHgwMFx4MDAiICsgIlx4MDBceDAwIiArICJceDAwXHgwMCIgKyBzYWZlU3RyaW5nMTYocHJvcGVydGllcy5jYXBIZWlnaHQpICsgc2FmZVN0cmluZzE2KE1hdGgudGFuKHByb3BlcnRpZXMuaXRhbGljQW5nbGUpICogcHJvcGVydGllcy54SGVpZ2h0KSArICJceDAwXHgwMCIgKyAiXHgwMFx4MDAiICsgIlx4MDBceDAwIiArICJceDAwXHgwMCIgKyAiXHgwMFx4MDAiICsgIlx4MDBceDAwIiArIHN0cmluZzE2KG51bUdseXBocykpOwogICAgYnVpbGRlci5hZGRUYWJsZSgiaG10eCIsIGZ1bmN0aW9uIGZvbnRGaWVsZHNIbXR4KCkgewogICAgICBjb25zdCBjaGFyc3RyaW5ncyA9IGZvbnQuY2hhcnN0cmluZ3M7CiAgICAgIGNvbnN0IGNmZldpZHRocyA9IGZvbnQuY2ZmID8gZm9udC5jZmYud2lkdGhzIDogbnVsbDsKICAgICAgbGV0IGhtdHggPSAiXHgwMFx4MDBceDAwXHgwMCI7CiAgICAgIGZvciAobGV0IGkgPSAxLCBpaSA9IG51bUdseXBoczsgaSA8IGlpOyBpKyspIHsKICAgICAgICBsZXQgd2lkdGggPSAwOwogICAgICAgIGlmIChjaGFyc3RyaW5ncykgewogICAgICAgICAgY29uc3QgY2hhcnN0cmluZyA9IGNoYXJzdHJpbmdzW2kgLSAxXTsKICAgICAgICAgIHdpZHRoID0gIndpZHRoIiBpbiBjaGFyc3RyaW5nID8gY2hhcnN0cmluZy53aWR0aCA6IDA7CiAgICAgICAgfSBlbHNlIGlmIChjZmZXaWR0aHMpIHsKICAgICAgICAgIHdpZHRoID0gTWF0aC5jZWlsKGNmZldpZHRoc1tpXSB8fCAwKTsKICAgICAgICB9CiAgICAgICAgaG10eCArPSBzdHJpbmcxNih3aWR0aCkgKyBzdHJpbmcxNigwKTsKICAgICAgfQogICAg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fZ2x5cGhDYWNoZVtjaGFyY29kZV0gPSBnbHlwaDsKICB9CiAgY2hhcnNUb0dseXBocyhjaGFycykgewogICAgbGV0IGdseXBocyA9IHRoaXMuX2NoYXJzQ2FjaGVbY2hhcnNdOwogICAgaWYgKGdseXBocykgewogICAgICByZXR1cm4gZ2x5cGhzOwogICAgfQogICAgZ2x5cGhzID0gW107CiAgICBpZiAodGhpcy5jTWFwKSB7CiAgICAgIGNvbnN0IGMgPSBPYmplY3QuY3JlYXRlKG51bGwpLAogICAgICAgIGlpID0gY2hhcnMubGVuZ3RoOwogICAgICBsZXQgaSA9IDA7CiAgICAgIHdoaWxlIChpIDwgaWkpIHsKICAgICAgICB0aGlzLmNNYXAucmVhZENoYXJDb2RlKGNoYXJzLCBpLCBjKTsKICAgICAgICBjb25zdCB7CiAgICAgICAgICBjaGFyY29kZSwKICAgICAgICAgIGxlbmd0aAogICAgICAgIH0gPSBjOwogICAgICAgIGkgKz0gbGVuZ3RoOwogICAgICAgIGNvbnN0IGdseXBoID0gdGhpcy5fY2hhclRvR2x5cGgoY2hhcmNvZGUsIGxlbmd0aCA9PT0gMSAmJiBjaGFycy5jaGFyQ29kZUF0KGkgLSAxKSA9PT0gMHgyMCk7CiAgICAgICAgZ2x5cGhzLnB1c2goZ2x5cGgpOwogICAgICB9CiAgICB9IGVsc2UgewogICAgICBmb3IgKGxldCBpID0gMCwgaWkgPSBjaGFycy5sZW5ndGg7IGkgPCBpaTsgKytpKSB7CiAgICAgICAgY29uc3QgY2hhcmNvZGUgPSBjaGFycy5jaGFyQ29kZUF0KGkpOwogICAgICAgIGNvbnN0IGdseXBoID0gdGhpcy5fY2hhclRvR2x5cGgoY2hhcmNvZGUsIGNoYXJjb2RlID09PSAweDIwKTsKICAgICAgICBnbHlwaHMucHVzaChnbHlwaCk7CiAgICAgIH0KICAgIH0KICAgIHJldHVybiB0aGlzLl9jaGFyc0NhY2hlW2NoYXJzXSA9IGdseXBoczsKICB9CiAgZ2V0Q2hhclBvc2l0aW9ucyhjaGFycykgewogICAgY29uc3QgcG9zaXRpb25zID0gW107CiAgICBpZiAodGhpcy5jTWFwKSB7CiAgICAgIGNvbnN0IGMgPSBPYmplY3QuY3JlYXRlKG51bGwpOwogICAgICBsZXQgaSA9IDA7CiAgICAgIHdoaWxlIChpIDwgY2hhcnMubGVuZ3RoKSB7CiAgICAgICAgdGhpcy5jTWFwLnJlYWRDaGFyQ29kZShjaGFycywgaSwgYyk7CiAgICAgICAgY29uc3QgbGVuZ3RoID0gYy5sZW5ndGg7CiAgICAgICAgcG9zaXRpb25zLnB1c2goW2ksIGkgKyBsZW5ndGhdKTsKICAgICAgICBpICs9IGxlbmd0aDsKICAgICAgfQogICAgfSBlbHNlIHsKICAgICAgZm9yIChsZXQgaSA9IDAsIGlpID0gY2hhcnMubGVuZ3RoOyBpIDwgaWk7ICsraSkgewogICAgICAgIHBvc2l0aW9ucy5wdXNoKFtpLCBpICsgMV0pOwogICAgICB9CiAgICB9CiAgICByZXR1cm4gcG9zaXRpb25zOwogIH0KICBnZXQgZ2x5cGhDYWNoZVZhbHVlcygpIHsKICAgIHJldHVybiBPYmplY3QudmFsdWVzKHRoaXMuX2dseXBoQ2FjaGUpOwogIH0KICBlbmNvZGVTdHJpbmcoc3RyKSB7CiAgICBjb25zdCBidWZmZXJzID0gW107CiAgICBjb25zdCBjdXJyZW50QnVmID0gW107CiAgICBjb25zdCBoYXNDdXJyZW50QnVmRXJyb3JzID0gKCkgPT4gYnVmZmVycy5sZW5ndGggJSAyID09PSAxOwogICAgY29uc3QgZ2V0Q2hhckNvZGUgPSB0aGlzLnRvVW5pY29kZSBpbnN0YW5jZW9mIF90b191bmljb2RlX21hcC5JZGVudGl0eVRvVW5pY29kZU1hcCA/IHVuaWNvZGUgPT4gdGhpcy50b1VuaWNvZGUuY2hhckNvZGVPZih1bmljb2RlKSA6IHVuaWNvZGUgPT4gdGhpcy50b1VuaWNvZGUuY2hhckNvZGVPZihTdHJpbmcuZnJvbUNvZGVQb2ludCh1bmljb2RlKSk7CiAgICBmb3IgKGxldCBpID0gMCwgaWkgPSBzdHIubGVuZ3RoOyBpIDwgaWk7IGkrKykgewogICAgICBjb25zdCB1bmljb2RlID0gc3RyLmNvZGVQb2ludEF0KGkpOwogICAgICBpZiAodW5pY29kZSA+IDB4ZDdmZiAmJiAodW5pY29kZSA8IDB4ZTAwMCB8fCB1bmljb2RlID4gMHhmZmZkKSkgewogICAgICAgIGkrKzsKICAgICAgfQogICAgICBpZiAodGhpcy50b1VuaWNvZGUpIHsKICAgICAgICBjb25zdCBjaGFyQ29kZSA9IGdldENoYXJDb2RlKHVuaWNvZGUpOwogICAgICAgIGlmIChjaGFyQ29kZSAhPT0gLTEpIHsKICAgICAgICAgIGlmIChoYXNDdXJyZW50QnVmRXJyb3JzKCkpIHsKICAgICAgICAgICAgYnVmZmVycy5wdXNoKGN1cnJlbnRCdWYuam9pbigiIikpOwogICAgICAgICAgICBjdXJyZW50QnVmLmxlbmd0aCA9IDA7CiAgICAgICAgICB9CiAgICAgICAgICBjb25zdCBjaGFyQ29kZUxlbmd0aCA9IHRoaXMuY01hcCA/IHRoaXMuY01hcC5nZXRDaGFyQ29kZUxlbmd0aChjaGFyQ29kZSkgOiAxOwogICAgICAgICAgZm9yIChsZXQgaiA9IGNoYXJDb2RlTGVuZ3RoIC0gMTsgaiA+PSAwOyBqLS0pIHsKICAgICAgICAgICAgY3VycmVudEJ1Zi5wdXNoKFN0cmluZy5mcm9tQ2hhckNvZGUoY2hhckNvZGUgPj4gOCAqIGogJiAweGZmKSk7CiAgICAgICAgICB9CiAgICAgICAgICBjb250aW51ZTsKICAgICAgICB9CiAgICAgIH0KICAgICAgaWYgKCFoYXNDdXJyZW50QnVmRXJyb3JzKCkpIHsKICAgICAgICBidWZmZXJzLnB1c2goY3VycmVudEJ1Zi5qb2luKCIiKSk7CiAgICAgICAgY3VycmVudEJ1Zi5sZW5ndGggPSAwOwogICAgICB9CiAgICAgIGN1cnJlbnRCdWYucH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ZhbHVlIC0gMjQ3KSAqIDI1NiArIGRpY3RbcG9zKytdICsgMTA4OwogICAgICB9IGVsc2UgaWYgKHZhbHVlID49IDI1MSAmJiB2YWx1ZSA8PSAyNTQpIHsKICAgICAgICByZXR1cm4gLSgodmFsdWUgLSAyNTEpICogMjU2KSAtIGRpY3RbcG9zKytdIC0gMTA4OwogICAgICB9CiAgICAgICgwLCBfdXRpbC53YXJuKSgnQ0ZGUGFyc2VyX3BhcnNlRGljdDogIicgKyB2YWx1ZSArICciIGlzIGEgcmVzZXJ2ZWQgY29tbWFuZC4nKTsKICAgICAgcmV0dXJuIE5hTjsKICAgIH0KICAgIGZ1bmN0aW9uIHBhcnNlRmxvYXRPcGVyYW5kKCkgewogICAgICBsZXQgc3RyID0gIiI7CiAgICAgIGNvbnN0IGVvZiA9IDE1OwogICAgICBjb25zdCBsb29rdXAgPSBbIjAiLCAiMSIsICIyIiwgIjMiLCAiNCIsICI1IiwgIjYiLCAiNyIsICI4IiwgIjkiLCAiLiIsICJFIiwgIkUtIiwgbnVsbCwgIi0iXTsKICAgICAgY29uc3QgbGVuZ3RoID0gZGljdC5sZW5ndGg7CiAgICAgIHdoaWxlIChwb3MgPCBsZW5ndGgpIHsKICAgICAgICBjb25zdCBiID0gZGljdFtwb3MrK107CiAgICAgICAgY29uc3QgYjEgPSBiID4+IDQ7CiAgICAgICAgY29uc3QgYjIgPSBiICYgMTU7CiAgICAgICAgaWYgKGIxID09PSBlb2YpIHsKICAgICAgICAgIGJyZWFrOwogICAgICAgIH0KICAgICAgICBzdHIgKz0gbG9va3VwW2IxXTsKICAgICAgICBpZiAoYjIgPT09IGVvZikgewogICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICAgIHN0ciArPSBsb29rdXBbYjJdOwogICAgICB9CiAgICAgIHJldHVybiBwYXJzZUZsb2F0KHN0cik7CiAgICB9CiAgICBsZXQgb3BlcmFuZHMgPSBbXTsKICAgIGNvbnN0IGVudHJpZXMgPSBbXTsKICAgIHBvcyA9IDA7CiAgICBjb25zdCBlbmQgPSBkaWN0Lmxlbmd0aDsKICAgIHdoaWxlIChwb3MgPCBlbmQpIHsKICAgICAgbGV0IGIgPSBkaWN0W3Bvc107CiAgICAgIGlmIChiIDw9IDIxKSB7CiAgICAgICAgaWYgKGIgPT09IDEyKSB7CiAgICAgICAgICBiID0gYiA8PCA4IHwgZGljdFsrK3Bvc107CiAgICAgICAgfQogICAgICAgIGVudHJpZXMucHVzaChbYiwgb3BlcmFuZHNdKTsKICAgICAgICBvcGVyYW5kcyA9IFtdOwogICAgICAgICsrcG9zOwogICAgICB9IGVsc2UgewogICAgICAgIG9wZXJhbmRzLnB1c2gocGFyc2VPcGVyYW5kKCkpOwogICAgICB9CiAgICB9CiAgICByZXR1cm4gZW50cmllczsKICB9CiAgcGFyc2VJbmRleChwb3MpIHsKICAgIGNvbnN0IGNmZkluZGV4ID0gbmV3IENGRkluZGV4KCk7CiAgICBjb25zdCBieXRlcyA9IHRoaXMuYnl0ZXM7CiAgICBjb25zdCBjb3VudCA9IGJ5dGVzW3BvcysrXSA8PCA4IHwgYnl0ZXNbcG9zKytdOwogICAgY29uc3Qgb2Zmc2V0cyA9IFtdOwogICAgbGV0IGVuZCA9IHBvczsKICAgIGxldCBpLCBpaTsKICAgIGlmIChjb3VudCAhPT0gMCkgewogICAgICBjb25zdCBvZmZzZXRTaXplID0gYnl0ZXNbcG9zKytdOwogICAgICBjb25zdCBzdGFydFBvcyA9IHBvcyArIChjb3VudCArIDEpICogb2Zmc2V0U2l6ZSAtIDE7CiAgICAgIGZvciAoaSA9IDAsIGlpID0gY291bnQgKyAxOyBpIDwgaWk7ICsraSkgewogICAgICAgIGxldCBvZmZzZXQgPSAwOwogICAgICAgIGZvciAobGV0IGogPSAwOyBqIDwgb2Zmc2V0U2l6ZTsgKytqKSB7CiAgICAgICAgICBvZmZzZXQgPDw9IDg7CiAgICAgICAgICBvZmZzZXQgKz0gYnl0ZXNbcG9zKytdOwogICAgICAgIH0KIC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T0gMTkgfHwgdmFsdWUgPT09IDIwKSB7CiAgICAgICAgc3RhdGUuaGludHMgKz0gc3RhY2tTaXplID4+IDE7CiAgICAgICAgaiArPSBzdGF0ZS5oaW50cyArIDcgPj4gMzsKICAgICAgICBzdGFja1NpemUgJT0gMjsKICAgICAgICB2YWxpZGF0aW9uQ29tbWFuZCA9IENoYXJzdHJpbmdWYWxpZGF0aW9uRGF0YVt2YWx1ZV07CiAgICAgIH0gZWxzZSBpZiAodmFsdWUgPT09IDEwIHx8IHZhbHVlID09PSAyOSkgewogICAgICAgIGxldCBzdWJyc0luZGV4OwogICAgICAgIGlmICh2YWx1ZSA9PT0gMTApIHsKICAgICAgICAgIHN1YnJzSW5kZXggPSBsb2NhbFN1YnJJbmRleDsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgc3VicnNJbmRleCA9IGdsb2JhbFN1YnJJbmRleDsKICAgICAgICB9CiAgICAgICAgaWYgKCFzdWJyc0luZGV4KSB7CiAgICAgICAgICB2YWxpZGF0aW9uQ29tbWFuZCA9IENoYXJzdHJpbmdWYWxpZGF0aW9uRGF0YVt2YWx1ZV07CiAgICAgICAgICAoMCwgX3V0aWwud2FybikoIk1pc3Npbmcgc3VicnNJbmRleCBmb3IgIiArIHZhbGlkYXRpb25Db21tYW5kLmlkKTsKICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICB9CiAgICAgICAgbGV0IGJpYXMgPSAzMjc2ODsKICAgICAgICBpZiAoc3VicnNJbmRleC5jb3VudCA8IDEyNDApIHsKICAgICAgICAgIGJpYXMgPSAxMDc7CiAgICAgICAgfSBlbHNlIGlmIChzdWJyc0luZGV4LmNvdW50IDwgMzM5MDApIHsKICAgICAgICAgIGJpYXMgPSAxMTMxOwogICAgICAgIH0KICAgICAgICBjb25zdCBzdWJyTnVtYmVyID0gc3RhY2tbLS1zdGFja1NpemVdICsgYmlhczsKICAgICAgICBpZiAoc3Vick51bWJlciA8IDAgfHwgc3Vick51bWJlciA+PSBzdWJyc0luZGV4LmNvdW50IHx8IGlzTmFOKHN1YnJOdW1iZXIpKSB7CiAgICAgICAgICB2YWxpZGF0aW9uQ29tbWFuZCA9IENoYXJzdHJpbmdWYWxpZGF0aW9uRGF0YVt2YWx1ZV07CiAgICAgICAgICAoMCwgX3V0aWwud2FybikoIk91dCBvZiBib3VuZHMgc3VickluZGV4IGZvciAiICsgdmFsaWRhdGlvbkNvbW1hbmQuaWQpOwogICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgIH0KICAgICAgICBzdGF0ZS5zdGFja1NpemUgPSBzdGFja1NpemU7CiAgICAgICAgc3RhdGUuY2FsbERlcHRoKys7CiAgICAgICAgY29uc3QgdmFsaWQgPSB0aGlzLnBhcnNlQ2hhclN0cmluZyhzdGF0ZSwgc3VicnNJbmRleC5nZXQoc3Vick51bWJlciksIGxvY2FsU3VickluZGV4LCBnbG9iYWxTdWJySW5kZXgpOwogICAgICAgIGlmICghdmFsaWQpIHsKICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICB9CiAgICAgICAgc3RhdGUuY2FsbERlcHRoLS07CiAgICAgICAgc3RhY2tTaXplID0gc3RhdGUuc3RhY2tTaXplOwogICAgICAgIGNvbnRpbnVlOwogICAgICB9IGVsc2UgaWYgKHZhbHVlID09PSAxMSkgewogICAgICAgIHN0YXRlLnN0YWNrU2l6ZSA9IHN0YWNrU2l6ZTsKICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgfSBlbHNlIGlmICh2YWx1ZSA9PT0gMCAmJiBqID09PSBkYXRhLmxlbmd0aCkgewogICAgICAgIGRhdGFbaiAtIDFdID0gMTQ7CiAgICAgICAgdmFsaWRhdGlvbkNvbW1hbmQgPSBDaGFyc3RyaW5nVmFsaWRhdGlvbkRhdGFbMTRdOwogICAgICB9IGVsc2UgaWYgKHZhbHVlID09PSA5KSB7CiAgICAgICAgZGF0YS5jb3B5V2l0aGluKGogLSAxLCBqLCAtMSk7CiAgICAgICAgaiAtPSAxOwogICAgICAgIGxlbmd0aCAtPSAxOwogICAgICAgIGNvbnRpbnVlOwogICAgICB9IGVsc2UgewogICAgICAgIHZhbGlkYXRpb25Db21tYW5kID0gQ2hhcnN0cmluZ1ZhbGlkYXRpb25EYXRhW3ZhbHVlXTsKICAgICAgfQogICAgICBpZiAodmFsaWRhdGlvbkNvbW1hbmQpIHsKICAgICAgICBpZiAodmFsaWRhdGlvbkNvbW1hbmQuc3RlbSkgewogICAgICAgICAgc3RhdGUuaGludHMgKz0gc3RhY2tTaXplID4+IDE7CiAgICAgICAgICBpZiAodmFsdWUgPT09IDMgfHwgdmFsdWUgPT09IDIzKSB7CiAgICAgICAgICAgIHN0YXRlLmhhc1ZTdGVtcyA9IHRydWU7CiAgICAgICAgICB9IGVsc2UgaWYgKHN0YXRlLmhhc1ZTdGVtcyAmJiAodmFsdWUgPT09IDEgfHwgdmFsdWUgPT09IDE4KSkgewogICAgICAgICAgICAoMCwgX3V0aWwud2FybikoIkNGRiBzdGVtIGhpbnRzIGFyZSBpbiB3cm9uZyBvcmRlciIpOwogICAgICAgICAgICBkYXRhW2ogLSAxXSA9IHZhbHVlID09PSAxID8gMyA6IDIzOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZiAoIm1pbiIgaW4gdmFsaWRhdGlvbkNvbW1hbmQpIHsKICAgICAgICAgIGlmICghc3RhdGUudW5kZWZTdGFjayAmJiBzdGFja1NpemUgPCB2YWxpZGF0aW9uQ29tbWFuZC5taW4pIHsKICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKCJOb3QgZW5vdWdoIHBhcmFtZXRlcnMgZm9yICIgKyB2YWxpZGF0aW9uQ29tbWFuZC5pZCArICI7IGFjdHVhbDogIiArIHN0YWNrU2l6ZSArICIsIGV4cGVjdGVkOiAiICsgdmFsaWRhdGlvbkNvbW1hbmQubWluKTsKICAgICAgICAgICAgaWYgKHN0YWNrU2l6ZSA9PT0gMCkgewogICAgICAgICAgICAgIGRhdGFbaiAtIDFdID0gMTQ7CiAgICAgICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZiAoc3RhdGUuZmlyc3RTdGFja0NsZWFyaW5nICYmIHZhbGlkYXRpb25Db21tYW5kLnN0YWNrQ2xlYXJpbmcpIHsKICAgICAgICAgIHN0YXRlLmZpcnN0U3RhY2tDbGVhcmluZyA9IGZhbHNlOwogICAgICAgICAgc3RhY2tTaXplIC09IHZhbGlkYXRpb25Db21tYW5kLm1pbjsKICAgICAgICAgIGlmIChzdGFja1NpemUgPj0gMiAmJiB2YWxpZGF0aW9uQ29tbWFuZC5zdGVtKSB7CiAgICAgICAgICAgIHN0YWNrU2l6ZSAlPSAyOwogICAgICAgICAgfSBlbHNlIGlmIChzdGFja1NpemUgPiAxKSB7CiAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKSgiRm91bmQgdG9vIG1hbnkgcGFyYW1ldGVycyBmb3Igc3RhY2stY2xlYXJpbmcgY29tbWFuZCIpOwogICAgICAgICAgfQogICAgICAgICAgaWYgKHN0YWNrU2l6ZSA+IDApIHsKICAgICAgICAgICAgc3RhdGUud2lkdGggPSBzdGFja1tzdGFja1NpemUgLSAxXTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgaWYgKCJzdGFja0RlbHRhIiBpbiB2YWxpZGF0aW9uQ29tbWFuZCkgewogICAgICAgICAgaWYgKCJzdGFja0ZuIiBpbiB2YWxpZGF0aW9uQ29tbWFuZCkgewogICAgICAgICAgICB2YWxpZGF0aW9uQ29tbWFuZC5zdGFja0ZuKHN0YWNrLCBzdGFja1NpemUpOwogICAgICAgICAgfQogICAgICAgICAgc3RhY2tTaXplICs9IHZhbGlkYXRpb25Db21tYW5kLnN0YWNrRGVsdGE7CiAgICAgICAgfSBlbHNlIGlmICh2YWxpZGF0aW9uQ29tbWFuZC5zdGFja0NsZWFyaW5nKSB7CiAg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BbXSwKICAgICAgICB1bmRlZlN0YWNrOiB0cnVlLAogICAgICAgIGhpbnRzOiAwLAogICAgICAgIGZpcnN0U3RhY2tDbGVhcmluZzogdHJ1ZSwKICAgICAgICBzZWFjOiBudWxsLAogICAgICAgIHdpZHRoOiBudWxsLAogICAgICAgIGhhc1ZTdGVtczogZmFsc2UKICAgICAgfTsKICAgICAgbGV0IHZhbGlkID0gdHJ1ZTsKICAgICAgbGV0IGxvY2FsU3ViclRvVXNlID0gbnVsbDsKICAgICAgbGV0IHByaXZhdGVEaWN0VG9Vc2UgPSBwcml2YXRlRGljdDsKICAgICAgaWYgKGZkU2VsZWN0ICYmIGZkQXJyYXkubGVuZ3RoKSB7CiAgICAgICAgY29uc3QgZmRJbmRleCA9IGZkU2VsZWN0LmdldEZESW5kZXgoaSk7CiAgICAgICAgaWYgKGZkSW5kZXggPT09IC0xKSB7CiAgICAgICAgICAoMCwgX3V0aWwud2FybikoIkdseXBoIGluZGV4IGlzIG5vdCBpbiBmZCBzZWxlY3QuIik7CiAgICAgICAgICB2YWxpZCA9IGZhbHNlOwogICAgICAgIH0KICAgICAgICBpZiAoZmRJbmRleCA+PSBmZEFycmF5Lmxlbmd0aCkgewogICAgICAgICAgKDAsIF91dGlsLndhcm4pKCJJbnZhbGlkIGZkIGluZGV4IGZvciBnbHlwaCBpbmRleC4iKTsKICAgICAgICAgIHZhbGlkID0gZmFsc2U7CiAgICAgICAgfQogICAgICAgIGlmICh2YWxpZCkgewogICAgICAgICAgcHJpdmF0ZURpY3RUb1VzZSA9IGZkQXJyYXlbZmRJbmRleF0ucHJpdmF0ZURpY3Q7CiAgICAgICAgICBsb2NhbFN1YnJUb1VzZSA9IHByaXZhdGVEaWN0VG9Vc2Uuc3VicnNJbmRleDsKICAgICAgICB9CiAgICAgIH0gZWxzZSBpZiAobG9jYWxTdWJySW5kZXgpIHsKICAgICAgICBsb2NhbFN1YnJUb1VzZSA9IGxvY2FsU3VickluZGV4OwogICAgICB9CiAgICAgIG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0ZXNbcG9zKytdOwogICAgICAgICAgY291bnQgPSBieXRlc1twb3MrK10gPDwgOCB8IGJ5dGVzW3BvcysrXTsKICAgICAgICAgIGZvciAoaSA9IDA7IGkgPD0gY291bnQ7IGkrKykgewogICAgICAgICAgICBjaGFyc2V0LnB1c2goY2lkID8gaWQrKyA6IHN0cmluZ3MuZ2V0KGlkKyspKTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgYnJlYWs7CiAgICAgIGRlZmF1bHQ6CiAgICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKCJVbmtub3duIGNoYXJzZXQgZm9ybWF0Iik7CiAgICB9CiAgICBjb25zdCBlbmQgPSBwb3M7CiAgICBjb25zdCByYXcgPSBieXRlcy5zdWJhcnJheShzdGFydCwgZW5kKTsKICAgIHJldHVybiBuZXcgQ0ZGQ2hhcnNldChmYWxzZSwgZm9ybWF0LCBjaGFyc2V0LCByYXcpOwogIH0KICBwYXJzZUVuY29kaW5nKHBvcywgcHJvcGVydGllcywgc3RyaW5ncywgY2hhcnNldCkgewogICAgY29uc3QgZW5jb2RpbmcgPSBPYmplY3QuY3JlYXRlKG51bGwpOwogICAgY29uc3QgYnl0ZXMgPSB0aGlzLmJ5dGVzOwogICAgbGV0IHByZWRlZmluZWQgPSBmYWxzZTsKICAgIGxldCBmb3JtYXQsIGksIGlpOwogICAgbGV0IHJhdyA9IG51bGw7CiAgICBmdW5jdGlvbiByZWFkU3VwcGxlbWVudCgpIHsKICAgICAgY29uc3Qgc3VwcGxlbWVudHNDb3VudCA9IGJ5dGVzW3BvcysrXTsKICAgICAgZm9yIChpID0gMDsgaSA8IHN1cHBsZW1lbnRzQ291bnQ7IGkrKykgewogICAgICAgIGNvbnN0IGNvZGUgPSBieXRlc1twb3MrK107CiAgICAgICAgY29uc3Qgc2lkID0gKGJ5dGVzW3BvcysrXSA8PCA4KSArIChieXRlc1twb3MrK10gJiAweGZmKTsKICAgICAgICBlbmNvZGluZ1tjb2RlXSA9IGNoYXJzZXQuaW5kZXhPZihzdHJpbmdzLmdldChzaWQpKTsKICAgICAgfQogICAgfQogICAgaWYgKHBvcyA9PT0gMCB8fCBwb3MgPT09IDEpIHsKICAgICAgcHJlZGVmaW5lZCA9IHRydWU7CiAgICAgIGZvcm1hdCA9IHBvczsKICAgICAgY29uc3QgYmFzZUVuY29kaW5nID0gcG9zID8gX2VuY29kaW5ncy5FeHBlcnRFbmNvZGluZyA6IF9lbmNvZGluZ3MuU3RhbmRhcmRFbmNvZGluZzsKICAgICAgZm9yIChpID0gMCwgaWkgPSBjaGFyc2V0Lmxlbmd0aDsgaSA8IGlpOyBpKyspIHsKICAgICAgICBjb25zdCBpbmRleCA9IGJhc2VFbmNvZGluZy5pbmRleE9mKGNoYXJzZXRbaV0pOwogICAgICAgIGlmIChpbmRleCAhPT0gLTEpIHsKICAgICAgICAgIGVuY29kaW5nW2luZGV4XSA9IGk7CiAgICAgICAgfQogICAgICB9CiAgICB9IGVsc2UgewogICAgICBjb25zdCBkYXRhU3RhcnQgPSBwb3M7CiAgICAgIGZvcm1hdCA9IGJ5dGVzW3BvcysrXTsKICAgICAgc3dpdGNoIChmb3JtYXQgJiAweDdmKSB7CiAgICAgICAgY2FzZSAwOgogICAgICAgICAgY29uc3QgZ2x5cGhzQ291bnQgPSBieXRlc1twb3MrK107CiAgICAgICAgICBmb3IgKGkgPSAxOyBpIDw9IGdseXBoc0NvdW50OyBpKyspIHsKICAgICAgICAgICAgZW5jb2RpbmdbYnl0ZXNbcG9zKytdXSA9IGk7CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIDE6CiAgICAgICAgICBjb25zdCByYW5nZXNDb3VudCA9IGJ5dGVzW3BvcysrXTsKICAgICAgICAgIGxldCBnaWQgPSAxOwogICAgICAgICAgZm9yIChpID0gMDsgaSA8IHJhbmdlc0NvdW50OyBpKyspIHsKICAgICAgICAgICAgY29uc3Qgc3RhcnQgPSBieXRlc1twb3MrK107CiAgICAgICAgICAgIGNvbnN0IGxlZnQgPSBieXRlc1twb3MrK107CiAgICAgICAgICAgIGZvciAobGV0IGogPSBzdGFydDsgaiA8PSBzdGFydCArIGxlZnQ7IGorKykgewogICAgICAgICAgICAgIGVuY29kaW5nW2pdID0gZ2lkKys7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoYFVua25vd24gZW5jb2RpbmcgZm9ybWF0OiAke2Zvcm1hdH0gaW4gQ0ZGYCk7CiAgICAgIH0KICAgICAgY29uc3QgZGF0YUVuZCA9IHBvczsKICAgICAgaWYgKGZvcm1hdCAmIDB4ODApIHsKICAgICAgICBieXRlc1tkYXRhU3RhcnRdICY9IDB4N2Y7CiAgICAgICAgcmVhZFN1cHBsZW1lbnQoKTsKICAgICAgfQogICAgICByYXcgPSBieXRlcy5zdWJhcnJheShkYXRhU3RhcnQsIGRhdGFFbmQpOwogICAgfQogICAgZm9ybWF0ICY9IDB4N2Y7CiAgICByZXR1cm4gbmV3IENGRkVuY29kaW5nKHByZWRlZmluZWQsIGZvcm1hdCwgZW5jb2RpbmcsIHJhdyk7CiAgfQogIHBhcnNlRkRTZWxlY3QocG9zLCBsZW5ndGgpIHsKICAgIGNvbnN0IGJ5dGVzID0gdGhpcy5ieXRlczsKICAgIGNvbnN0IGZvcm1hdCA9IGJ5dGVzW3BvcysrXTsKICAgIGNvbnN0IGZkU2VsZWN0ID0gW107CiAgICBsZXQgaTsKICAgIHN3aXRjaCAoZm9ybWF0KSB7CiAgICAgIGNhc2UgMDoKICAgICAgICBmb3IgKGkgPSAwOyBpIDwgbGVuZ3RoOyArK2kpIHsKICAgICAgICAgIGNvbnN0IGlkID0gYnl0ZXNbcG9zKytdOwogICAgICAgICAgZmRTZWxlY3QucHVzaChpZCk7CiAgICAgICAgfQogICAgICAgIGJyZWFrOwogICAgIC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kgewogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGxldCB2YWx1ZXMgPSBkaWN0LnZhbHVlc1trZXldOwogICAgICBsZXQgdHlwZXMgPSBkaWN0LnR5cGVzW2tleV07CiAgICAgIGlmICghQXJyYXkuaXNBcnJheSh0eXBlcykpIHsKICAgICAgICB0eXBlcyA9IFt0eXBlc107CiAgICAgIH0KICAgICAgaWYgKCFBcnJheS5pc0FycmF5KHZhbHVlcykpIHsKICAgICAgICB2YWx1ZXMgPSBbdmFsdWVzXTsKICAgICAgfQogICAgICBpZiAodmFsdWVzLmxlbmd0aCA9PT0gMCkgewogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGZvciAobGV0IGogPSAwLCBqaiA9IHR5cGVzLmxlbmd0aDsgaiA8IGpqOyArK2opIHsKICAgICAgICBjb25zdCB0eXBlID0gdHlwZXNbal07CiAgICAgICAgY29uc3QgdmFsdWUgPSB2YWx1ZXNbal07CiAgICAgICAgc3dpdGNoICh0eXBlKSB7CiAgICAgICAgICBjYXNlICJudW0iOgogICAgICAgICAgY2FzZSAic2lkIjoKICAgICAgICAgICAgb3V0LnB1c2goLi4udGhpcy5lbmNvZGVOdW1iZXIodmFsdWUpKTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlICJvZmZzZXQiOgogICAgICAgICAgICBjb25zdCBuYW1lID0gZGljdC5rZXlUb05hbWVNYXBba2V5XTsKICAgICAgICAgICAgaWYgKCFvZmZzZXRUcmFja2VyLmlzVHJhY2tpbmcobmFtZSkpIHsKICAgICAgICAgICAgICBvZmZzZXRUcmFja2VyLnRyYWNrKG5hbWUsIG91dC5sZW5ndGgpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIG91dC5wdXNoKDB4MWQsIDAsIDAsIDAsIDApOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgImFycmF5IjoKICAgICAgICAgIGNhc2UgImRlbHRhIjoKICAgICAgICAgICAgb3V0LnB1c2goLi4udGhpcy5lbmNvZGVOdW1iZXIodmFsdWUpKTsKICAgICAgICAgICAgZm9yIChsZXQgayA9IDEsIGtrID0gdmFsdWVzLmxlbmd0aDsgayA8IGtrOyArK2spIHsKICAgICAgICAgICAgICBvdXQucHVzaCguLi50aGlzLmVuY29kZU51bWJlcih2YWx1ZXNba10pKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcihgVW5rbm93biBkYXRhIHR5cGUgb2YgJHt0eXBlfWApOwogICAgICAgIH0KICAgICAgfQogICAgICBvdXQucHVzaCguLi5kaWN0Lm9wY29kZXNba2V5XSk7CiAgICB9CiAgICByZXR1cm4gb3V0OwogIH0KICBjb21waWxlU3RyaW5nSW5kZXgoc3RyaW5ncykgewogICAgY29uc3Qgc3RyaW5nSW5kZXggPSBuZXcgQ0ZGSW5kZXgoKTsKICAgIGZvciAoY29uc3Qgc3RyaW5nIG9mIHN0cmluZ3MpIHsKICAgICAgc3RyaW5nSW5kZXguYWRkKCgwLCBfdXRpbC5zdHJpbmdUb0J5dGVzKShzdHJpbmcpKTsKICAgIH0KICAgIHJldHVybiB0aGlzLmNvbXBpbGVJbmRleChzdHJpbmdJbmRleCk7CiAgfQogIGNvbXBpbGVHbG9iYWxTdWJySW5kZXgoKSB7CiAgICBjb25zdCBnbG9iYWxTdWJySW5kZXggPSB0aGlzLmNmZi5nbG9iYWxTdWJySW5kZXg7CiAgICB0aGlzLm91dC53cml0ZUJ5dGVBcnJheSh0aGlzLmNvbXBpbGVJbmRleChnbG9iYWxTdWJySW5kZXgpKTsKICB9CiAgY29tcGlsZUNoYXJTdHJpbmdzKGNoYXJTdHJpbmdzKSB7CiAgICBjb25zdCBjaGFyU3RyaW5nc0luZGV4ID0gbmV3IENGRkluZGV4KCk7CiAgICBmb3IgKGxldCBpID0gMDsgaSA8IGNoYXJTdHJpbmdzLmNvdW50OyBpKyspIHsKICAgICAgY29uc3QgZ2x5cGggPSBjaGFyU3RyaW5ncy5nZXQoaSk7CiAgICAgIGlmIChnbHlwaC5sZW5ndGggPT09IDApIHsKICAgICAgICBjaGFyU3RyaW5nc0luZGV4LmFkZChuZXcgVWludDhBcnJheShbMHg4YiwgMHgwZV0pKTsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBjaGFyU3RyaW5nc0luZGV4LmFkZChnbHlwaCk7CiAgICB9CiAgICByZXR1cm4gdGhpcy5jb21waWxlSW5kZXgoY2hhclN0cmluZ3NJbmRleCk7CiAgfQogIGNvbXBpbGVDaGFyc2V0KGNoYXJzZXQsIG51bUdseXBocywgc3RyaW5ncywgaXNDSURGb250KSB7CiAgICBsZXQgb3V0OwogICAgY29uc3QgbnVtR2x5cGhzTGVzc05vdERlZiA9IG51bUdseXBocyAtIDE7CiAgICBpZiAoaXNDSURGb250KSB7CiAgICAgIG91dCA9IG5ldyBVaW50OEFycmF5KFsyLCAwLCAwLCBudW1HbHlwaHNMZXNzTm90RGVmID4+IDggJiAweGZmLCBudW1HbHlwaHNMZXNzTm90RGVmICYgMHhmZl0pOwogICAgfSBlbHNlIHsKICAgICAgY29uc3QgbGVuZ3RoID0gMSArIG51bUdseXBoc0xlc3NOb3REZWYgKiAyOwogICAgICBvdXQgPSBuZXcgVWludDhBcnJheShsZW5ndGgpOwogICAgICBvdXRbMF0gPSAwOwogICAgICBsZXQgY2hhcnNldEluZGV4ID0gMDsKICAgICAgY29uc3QgbnVtQ2hhcnNldHMgPSBjaGFyc2V0LmNoYXJzZXQubGVuZ3RoOwogICAgICBsZXQgd2FybmVkID0gZmFsc2U7CiAgICAgIGZvciAobGV0IGkgPSAxOyBpIDwgb3V0Lmxlbmd0aDsgaSArPSAyKSB7CiAgICAgICAgbGV0IHNpZCA9IDA7CiAgICAgICAgaWYgKGNoYXJzZXRJbmRleCA8IG51bUNoYXJzZXRzKSB7CiAgICAgICAgICBjb25zdCBuYW1lID0gY2hhcnNldC5jaGFyc2V0W2NoYXJzZXRJbmRleCsrXTsKICAgICAgICAgIHNpZCA9IHN0cmluZ3MuZ2V0U0lEKG5hbWUpOwogICAgICAgICAgaWYgKHNpZCA9PT0gLTEpIHsKICAgICAgICAgICAgc2lkID0gMDsKICAgICAgICAgICAgaWYgKCF3YXJuZWQpIHsKICAgICAgICAgICAgICB3YXJuZWQgPSB0cnVlOwogICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgQ291bGRuJ3QgZmluZCAke25hbWV9IGluIENGRiBzdHJpbmdzYCk7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgb3V0W2ldID0gc2lkID4+IDggJiAweGZmOwogICAgICAgIG91dFtpICsgMV0gPSBzaWQgJiAweGZmOwogICAgICB9CiAgICB9CiAgICByZXR1cm4gdGhpcy5jb21waWxlVHlwZWRBcnJheShvdXQpOwogIH0KICBjb21waWxlRW5jb2RpbmcoZW5jb2RpbmcpIHsKICAgIHJldHVybiB0aGlzLmNvbXBpbGVUeXBlZEFycmF5KGVuY29kaW5nLnJhdyk7CiAgfQogIGNvbXBpbGVGRFNlbGVjdChmZFNlbGVjdCkgewogICAgY29uc3QgZm9ybWF0ID0gZmRTZWxlY3QuZm9ybWF0OwogICAgbGV0IG91dCwgaTsKICAgIHN3aXRjaCAoZm9ybWF0KSB7CiAgICAgIGNhc2UgMDoKICAgICAgICBvdXQgPSBuZXcgVWludDhBcnJheSgxICsgZmRTZWxlY3QuZmRTZWxlY3QubGVuZ3RoKTsKICAgICAgICBvdXRbMF0gPSBmb3JtYXQ7CiAgICAgICAgZm9yIChpID0gMDsgaSA8IGZkU2VsZWN0LmZkU2VsZWN0Lmxlbmd0aDsgaSsrKSB7CiAgICAgICAgICBvdXRbaSArIDFdID0gZmRTZWxlY3QuZmRTZWxlY3RbaV07CiAgICAgICAgfQogICAgICAgIGJyZWFrOwogICAgICBjYXNlIDM6CiAgICAgICAgY29uc3Qgc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YiIsCiAgMHgwMzE0LAogICJjb21tYXJldmVyc2VkbW9kIiwKICAweDAyYmQsCiAgImNvbW1hc21hbGwiLAogIDB4ZmU1MCwKICAiY29tbWFzdXBlcmlvciIsCiAgMHhmNmUyLAogICJjb21tYXR1cm5lZGFib3ZlY21iIiwKICAweDAzMTIsCiAgImNvbW1hdHVybmVkbW9kIiwKICAweDAyYmIsCiAgImNvbXBhc3MiLAogIDB4MjYzYywKICAiY29uZ3J1ZW50IiwKICAweDIyNDUsCiAgImNvbnRvdXJpbnRlZ3JhbCIsCiAgMHgyMjJlLAogICJjb250cm9sIiwKICAweDIzMDMsCiAgImNvbnRyb2xBQ0siLAogIDB4MDAwNiwKICAiY29udHJvbEJFTCIsCiAgMHgwMDA3LAogICJjb250cm9sQlMiLAogIDB4MDAwOCwKICAiY29udHJvbENBTiIsCiAgMHgwMDE4LAogICJjb250cm9sQ1IiLAogIDB4MDAwZCwKICAiY29udHJvbERDMSIsCiAgMHgwMDExLAogICJjb250cm9sREMyIiwKICAweDAwMTIsCiAgImNvbnRyb2xEQzMiLAogIDB4MDAxMywKICAiY29udHJvbERDNCIsCiAgMHgwMDE0LAogICJjb250cm9sREVMIiwKICAweDAwN2YsCiAgImNvbnRyb2xETEUiLAogIDB4MDAxMCwKICAiY29udHJvbEVNIiwKICAweDAwMTksCiAgImNvbnRyb2xFTlEiLAogIDB4MDAwNSwKICAiY29udHJvbEVPVCIsCiAgMHgwMDA0LAogICJjb250cm9sRVNDIiwKICAweDAwMWIsCiAgImNvbnRyb2xFVEIiLAogIDB4MDAxNywKICAiY29udHJvbEVUWCIsCiAgMHgwMDAzLAogICJjb250cm9sRkYiLAogIDB4MDAwYywKICAiY29udHJvbEZTIiwKICAweDAwMWMsCiAgImNvbnRyb2xHUyIsCiAgMHgwMDFkLAogICJjb250cm9sSFQiLAogIDB4MDAwOSwKICAiY29udHJvbExGIiwKICAweDAwMGEsCiAgImNvbnRyb2xOQUsiLAogIDB4MDAxNSwKICAiY29udHJ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4MGE4NywKICAiaWd1cm11a2hpIiwKICAweDBhMDcsCiAgImloaXJhZ2FuYSIsCiAgMHgzMDQ0LAogICJpaG9va2Fib3ZlIiwKICAweDFlYzksCiAgImlpYmVuZ2FsaSIsCiAgMHgwOTg4LAogICJpaWN5cmlsbGljIiwKICAweDA0MzgsCiAgImlpZGV2YSIsCiAgMHgwOTA4LAogICJpaWd1amFyYXRpIiwKICAweDBhODgsCiAgImlpZ3VybXVraGkiLAogIDB4MGEwOCwKICAiaWltYXRyYWd1cm11a2hpIiwKICAweDBhNDAsCiAgImlpbnZlcnRlZGJyZXZlIiwKICAweDAyMGIsCiAgImlpc2hvcnRjeXJpbGxpYyIsCiAgMHgwNDM5LAogICJpaXZvd2Vsc2lnbmJlbmdhbGkiLAogIDB4MDljMCwKICAiaWl2b3dlbHNpZ25kZXZhIiwKICAweDA5NDAsCiAgImlpdm93ZWxzaWduZ3VqYXJhdGkiLAogIDB4MGFjMCwKICAiaWoiLAogIDB4MDEzMywKICAiaWthdGFrYW5hIiwKICAweDMwYTQsCiAgImlrYXRha2FuYWhhbGZ3aWR0aCIsCiAgMHhmZjcyLAogICJpa29yZWFuIiwKICAweDMxNjMsCiAgImlsZGUiLAogIDB4MDJkYywKICAiaWx1eWhlYnJldyIsCiAgMHgwNWFjLAogICJpbWFjcm9uIiwKICAweDAxMmIsCiAgImltYWNyb25jeXJpbGxpYyIsCiAgMHgwNGUzLAogICJpbWFnZW9yYXBwcm94aW1hdGVseWVxdWFsIiwKICAweDIyNTMsCiAgImltYXRyYWd1cm11a2hpIiwKICAweDBhM2YsCiAgImltb25vc3BhY2UiLAogIDB4ZmY0OSwKICAiaW5jcmVtZW50IiwKICAweDIyMDYsCiAgImluZmluaXR5IiwKICAweDIyMWUsCiAgImluaWFybWVuaWFuIiwKICAweDA1NmIsCiAgImludGVncmFsIiwKICAweDIyMmIsCiAgImludGVncmFsYm90dG9tIiwKICAweDIzMjEsCiAgImludGVncmFsYnQiLAogIDB4MjMyMSwK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bmRldmEiLAogIDB4MDkzZiwKICAiaXZvd2Vsc2lnbmd1amFyYXRpIiwKICAweDBhYmYsCiAgIml6aGl0c2FjeXJpbGxpYyIsCiAgMHgwNDc1LAogICJpemhpdHNhZGJsZ3JhdmVjeXJpbGxpYyIsCiAgMHgwNDc3LAogICJqIiwKICAweDAwNmEsCiAgImphYXJtZW5pYW4iLAogIDB4MDU3MSwKICAiamFiZW5nYWxpIiwKICAweDA5OWMsCiAgImphZGV2YSIsCiAgMHgwOTFjLAogICJqYWd1amFyYXRpIiwKICAweDBhOWMsCiAgImphZ3VybXVraGkiLAogIDB4MGExYywKICAiamJvcG9tb2ZvIiwKICAweDMxMTAsCiAgImpjYXJvbiIsCiAgMHgwMWYwLAogICJqY2lyY2xlIiwKICAweDI0ZDksCiAgImpjaXJjdW1mbGV4IiwKICAweDAxMzUsCiAgImpjcm9zc2VkdGFpbCIsCiAgMHgwMjlkLAogICJqZG90bGVzc3N0cm9rZSIsCiAgMHgwMjVmLAogICJqZWN5cmlsbGljIiwKICAweDA0NTgsCiAgImplZW1hcmFiaWMiLAogIDB4MDYyYywKICAiamVlbWZpbmFsYXJhYmljIiwKICAweGZlOWUsCiAgImplZW1pbml0aWFsYXJhYmljIiwKICAweGZlOWYsCiAgImplZW1tZWRpYWxhcmFiaWMiLAogIDB4ZmVhMCwKICAiamVoYXJhYmljIiwKICAweDA2OTgsCiAgImplaGZpbmFsYXJhYmljIiwKICAweGZiOGIsCiAgImpoYWJlbmdhbGkiLAogIDB4MDk5ZCwKICAiamhhZGV2YSIsCiAgMHgwOTFkLAogICJqaGFndWphcmF0aSIsCiAgMHgwYTlkLAogICJqaGFndXJtdWtoaSIsCiAgMHgwYTFkLAogICJqaGVoYXJtZW5pYW4iLAogIDB4MDU3YiwKICAiamlzIiwKICAweDMwMDQsCiAgImptb25vc3BhY2UiLAogIDB4ZmY0YSwKICAianBhcmVuIiwKICAweDI0YTUsCiAgImpzdXBlcmlvciIsCiAgMHgwMmIyLAogICJr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gMHhmZWE2LAogICJraGFoaW5pdGlhbGFyYWJpYyIsCiAgMHhmZWE3LAogICJraGFobWVkaWFsYXJhYmljIiwKICAweGZlYTgsCiAgImtoZWljb3B0aWMiLAogIDB4MDNlNywKICAia2hoYWRldmEiLAogIDB4MDk1OSwKICAia2hoYWd1cm11a2hpIiwKICAweDBhNTksCiAgImtoaWV1a2hhY2lyY2xla29yZWFuIiwKICAweDMyNzgsCiAgImtoaWV1a2hhcGFyZW5rb3JlYW4iLAogIDB4MzIxOCwKICAia2hpZXVraGNpcmNsZWtvcmVhbiIsCiAgMHgzMjZhLAogICJraGlldWtoa29yZWFuIiwKICAweDMxNGIsCiAgImtoaWV1a2hwYXJlbmtvcmVhbiIsCiAgMHgzMjBhLAogICJraG9raGFpdGhhaSIsCiAgMHgwZTAyLAogICJraG9raG9udGhhaSIsCiAgMHgwZTA1LAogICJraG9raHVhdHRoYWkiLAogIDB4MGUwMywKICAia2hva2h3YWl0aGFpIiwKICAweDBlMDQsCiAgImtob211dHRoYWkiLAogIDB4MGU1YiwKICAia2hvb2siLAogIDB4MDE5OSwKICAia2hvcmFraGFuZ3RoYWkiLAogIDB4MGUwNiwKICAia2h6c3F1YXJlIiwKICAweDMzOTEsCiAgImtpaGlyYWdhbmEiLAogIDB4MzA0ZCwKICAia2lrYXRha2FuYSIsCiAgMHgzMGFkLAogICJraWthdGFrYW5haGFsZndpZHRoIiwKICAweGZmNzcsCiAgImtpcm9ndXJhbXVzcXVhcmUiLAogIDB4MzMxNSwKICAia2lyb21lZXRvcnVzcXVhcmUiLAogIDB4MzMxNiwKICAia2lyb3NxdWFyZSIsCiAgMHgzMzE0LAogICJraXllb2thY2lyY2xla29yZWFuIiwKICAweDMyNmUsCiAgImtpeWVva2FwYXJlbmtvcmVhbiIsCiAgMHgzMjBlLAogICJraXllb2tjaXJjbGVrb3JlYW4iLAogIDB4MzI2MCwKICAia2l5ZW9ra29yZWFuIiwKICAweDMxMzEsCiAgImtpeWVva3BhcmVua29yZ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MjIwMiwKICAicGFzZXFoZWJyZXciLAogIDB4MDVjMCwKICAicGFzaHRhaGVicmV3IiwKICAweDA1OTksCiAgInBhc3F1YXJlIiwKICAweDMzYTksCiAgInBhdGFoIiwKICAweDA1YjcsCiAgInBhdGFoMTEiLAogIDB4MDViNywKICAicGF0YWgxZCIsCiAgMHgwNWI3LAogICJwYXRhaDJhIiwKICAweDA1YjcsCiAgInBhdGFoaGVicmV3IiwKICAweDA1YjcsCiAgInBhdGFobmFycm93aGVicmV3IiwKICAweDA1YjcsCiAgInBhdGFocXVhcnRlcmhlYnJldyIsCiAgMHgwNWI3LAogICJwYXRhaHdpZGVoZWJyZXciLAogIDB4MDViNywKICAicGF6ZXJoZWJyZXciLAogIDB4MDVhMSwKICAicGJvcG9tb2ZvIiwKICAweDMxMDYsCiAgInBjaXJjbGUiLAogIDB4MjRkZiwKICAicGRvdGFjY2VudCIsCiAgMHgxZTU3LAogICJwZSIsCiAgMHgwNWU0LAogICJwZWN5cmlsbGljIiwKICAweDA0M2YsCiAgInBlZGFnZXNoIiwKICAweGZiNDQsCiAgInBlZGFnZXNoaGVicmV3IiwKICAweGZiNDQsCiAgInBlZXppc3F1YXJlIiwKICAweDMzM2IsCiAgInBlZmluYWxkYWdlc2hoZWJyZXciLAogIDB4ZmI0MywKICAicGVoYXJhYmljIiwKICAweDA2N2UsCiAgInBlaGFybWVuaWFuIiwKICAweDA1N2EsCiAgInBlaGVicmV3IiwKICAweDA1ZTQsCiAgInBlaGZpbmFsYXJhYmljIiwKICAweGZiNTcsCiAgInBlaGluaXRpYWxhcmFiaWMiLAogIDB4ZmI1OCwKICAicGVoaXJhZ2FuYSIsCiAgMHgzMDdhLAogICJwZWhtZWRpYWxhcmFiaWMiLAogIDB4ZmI1OSwKICAicGVrYXRha2FuYSIsCiAgMHgzMGRhLAogICJwZW1pZGRsZWhvb2tjeXJpbGxpYyIsCiAgMHgwNGE3LAogICJwZXJhZmVoZWJyZXciLAogIDB4ZmI0ZSwKICAicG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NhLAogICJwaGlzeW1ib2xncmVlayIsCiAgMHgwM2Q1LAogICJwaG9vayIsCiAgMHgwMWE1LAogICJwaG9waGFudGhhaSIsCiAgMHgwZTFlLAogICJwaG9waHVuZ3RoYWkiLAogIDB4MGUxYywKICAicGhvc2FtcGhhb3RoYWkiLAogIDB4MGUyMCwKICAicGkiLAogIDB4MDNjMCwKICAicGlldXBhY2lyY2xla29yZWFuIiwKICAweDMyNzMsCiAgInBpZXVwYXBhcmVua29yZWFuIiwKICAweDMyMTMsCiAgInBpZXVwY2lldWNrb3JlYW4iLAogIDB4MzE3NiwKICAicGlldXBjaXJjbGVrb3JlYW4iLAogIDB4MzI2NSwKICAicGlldXBraXllb2trb3JlYW4iLAogIDB4MzE3MiwKICAicGlldXBrb3JlYW4iLAogIDB4MzE0MiwKICAicGlldXBwYXJlbmtvcmVhbiIsCiAgMHgzMjA1LAogICJwaWV1cHNpb3NraXllb2trb3JlYW4iLAogIDB4MzE3NCwKICAicGlldXBzaW9za29yZWFuIiwKICAweDMxNDQsCiAgInBpZXVwc2lvc3Rpa2V1dGtvcmVhbiIsCiAgMHgzMTc1LAogICJwaWV1cHRoaWV1dGhrb3JlYW4iLAogIDB4MzE3NywKICAicGlldXB0aWtldXRrb3JlYW4iLAogIDB4MzE3MywKICAicGloaXJhZ2FuYSIsCiAgMHgzMDc0LAogICJwaWthdGFrYW5hIiwKICAweDMwZDQsCiAgInBpc3ltYm9sZ3JlZWsiLAogIDB4MDNkNiwKICAicGl3cmFybWVuaWFuIiwKICAweDA1ODMsCiAgInBsdXMiLAogIDB4MDAyYiwKICAicGx1c2JlbG93Y21iIiwKICAweDAzMWYsCiAgInBsdXNjaXJjbGUiLAogIDB4MjI5NSwKICAicGx1c21pbnVzIiwKICAweDAwYjEsCiAgInBsdXNtb2QiLAogIDB4MDJkNiwKICAicGx1c21vbm9zcGFjZSIsCiAgMHhmZjBiLAogICJwbHVzc21hbGwiLAogIDB4ZmU2MiwKICAicGx1c3N1cGVyaW9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HgzMGQ3LAogICJwdnNxdWFyZSIsCiAgMHgzM2I0LAogICJwd3NxdWFyZSIsCiAgMHgzM2JhLAogICJxIiwKICAweDAwNzEsCiAgInFhZGV2YSIsCiAgMHgwOTU4LAogICJxYWRtYWhlYnJldyIsCiAgMHgwNWE4LAogICJxYWZhcmFiaWMiLAogIDB4MDY0MiwKICAicWFmZmluYWxhcmFiaWMiLAogIDB4ZmVkNiwKICAicWFmaW5pdGlhbGFyYWJpYyIsCiAgMHhmZWQ3LAogICJxYWZtZWRpYWxhcmFiaWMiLAogIDB4ZmVkOCwKICAicWFtYXRzIiwKICAweDA1YjgsCiAgInFhbWF0czEwIiwKICAweDA1YjgsCiAgInFhbWF0czFhIiwKICAweDA1YjgsCiAgInFhbWF0czFjIiwKICAweDA1YjgsCiAgInFhbWF0czI3IiwKICAweDA1YjgsCiAgInFhbWF0czI5IiwKICAweDA1YjgsCiAgInFhbWF0czMzIiwKICAweDA1YjgsCiAgInFhbWF0c2RlIiwKICAweDA1YjgsCiAgInFhbWF0c2hlYnJldyIsCiAgMHgwNWI4LAogICJxYW1hdHNuYXJyb3doZWJyZXciLAogIDB4MDViOCwKICAicWFtYXRzcWF0YW5oZWJyZXciLAogIDB4MDViOCwKICAicWFtYXRzcWF0YW5uYXJyb3doZWJyZXciLAogIDB4MDViOCwKICAicWFtYXRzcWF0YW5xdWFydGVyaGVicmV3IiwKICAweDA1YjgsCiAgInFhbWF0c3FhdGFud2lkZWhlYnJldyIsCiAgMHgwNWI4LAogICJxYW1hdHNxdWFydGVyaGVicmV3IiwKICAweDA1YjgsCiAgInFhbWF0c3dpZGVoZWJyZXciLAogIDB4MDViOCwKICAicWFybmV5cGFyYWhlYnJldyIsCiAgMHgwNTlmLAogICJxYm9wb21vZm8iLAogIDB4MzExMSwKICAicWNpcmNsZSIsCiAgMHgyNGUwLAogICJxaG9vayIsCiAgMHgwMmEwLAogICJxbW9ub3NwYWNlIiwKICAweGZmNTEsCiAgInFvZiIsCiAgMHgwN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2xlIiwKICAweDI0ZTEsCiAgInJjb21tYWFjY2VudCIsCiAgMHgwMTU3LAogICJyZGJsZ3JhdmUiLAogIDB4MDIxMSwKICAicmRvdGFjY2VudCIsCiAgMHgxZTU5LAogICJyZG90YmVsb3ciLAogIDB4MWU1YiwKICAicmRvdGJlbG93bWFjcm9uIiwKICAweDFlNWQsCiAgInJlZmVyZW5jZW1hcmsiLAogIDB4MjAzYiwKICAicmVmbGV4c3Vic2V0IiwKICAweDIyODYsCiAgInJlZmxleHN1cGVyc2V0IiwKICAweDIyODcsCiAgInJlZ2lzdGVyZWQiLAogIDB4MDBhZSwKICAicmVnaXN0ZXJzYW5zIiwKICAweGY4ZTgsCiAgInJlZ2lzdGVyc2VyaWYiLAogIDB4ZjZkYSwKICAicmVoYXJhYmljIiwKICAweDA2MzEsCiAgInJlaGFybWVuaWFuIiwKICAweDA1ODAsCiAgInJlaGZpbmFsYXJhYmljIiwKICAweGZlYWUsCiAgInJlaGlyYWdhbmEiLAogIDB4MzA4YywKICAicmVrYXRha2FuYSIsCiAgMHgzMGVjLAogICJyZWthdGFrYW5haGFsZndpZHRoIiwKICAweGZmOWEsCiAgInJlc2giLAogIDB4MDVlOCwKICAicmVzaGRhZ2VzaGhlYnJldyIsCiAgMHhmYjQ4LAogICJyZXNoaGVicmV3IiwKICAweDA1ZTgsCiAgInJldmVyc2VkdGlsZGUiLAogIDB4MjIzZCwKICAicmV2aWFoZWJyZXciLAogIDB4MDU5NywKICAicmV2aWFtdWdyYXNoaGVicmV3IiwKICAweDA1OTcsCiAgInJldmxvZ2ljYWxub3QiLAogIDB4MjMxMCwKICAicmZpc2hob29rIiwKICAweDAyN2UsCiAgInJmaXNoaG9va3JldmVyc2VkIiwKICAweDAyN2YsCiAgInJoYWJlbmdhbGkiLAogIDB4MDlkZCwKICAicmhhZGV2YSIsCiAgMHgwOTVkLAogICJyaG8iLAogIDB4MDNjMSwKICAicmhvb2siLAogIDB4MDI3ZCwKICAicmhvb2t0dXJuZWQ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ib3BvbW9mbyIsCiAgMHgzMTE5LAogICJzY2Fyb24iLAogIDB4MDE2MSwKICAic2Nhcm9uZG90YWNjZW50IiwKICAweDFlNjcsCiAgInNjZWRpbGxhIiwKICAweDAxNWYsCiAgInNjaHdhIiwKICAweDAyNTksCiAgInNjaHdhY3lyaWxsaWMiLAogIDB4MDRkOSwKICAic2Nod2FkaWVyZXNpc2N5cmlsbGljIiwKICAweDA0ZGIsCiAgInNjaHdhaG9vayIsCiAgMHgwMjVhLAogICJzY2lyY2xlIiwKICAweDI0ZTIsCiAgInNjaXJjdW1mbGV4IiwKICAweDAxNWQsCiAgInNjb21tYWFjY2VudCIsCiAgMHgwMjE5LAogICJzZG90YWNjZW50IiwKICAweDFlNjEsCiAgInNkb3RiZWxvdyIsCiAgMHgxZTYzLAogICJzZG90YmVsb3dkb3RhY2NlbnQiLAogIDB4MWU2OSwKICAic2VhZ3VsbGJlbG93Y21iIiwKICAweDAzM2MsCiAgInNlY29uZCIsCiAgMHgyMDMzLAogICJzZWNvbmR0b25lY2hpbmVzZSIsCiAgMHgwMmNhLAogICJzZWN0aW9uIiwKICAweDAwYTcsCiAgInNlZW5hcmFiaWMiLAogIDB4MDYzMywKICAic2VlbmZpbmFsYXJhYmljIiwKICAweGZlYjIsCiAgInNlZW5pbml0aWFsYXJhYmljIiwKICAweGZlYjMsCiAgInNlZW5tZWRpYWxhcmFiaWMiLAogIDB4ZmViNCwKICAic2Vnb2wiLAogIDB4MDViNiwKICAic2Vnb2wxMyIsCiAgMHgwNWI2LAogICJzZWdvbDFmIiwKICAweDA1YjYsCiAgInNlZ29sMmMiLAogIDB4MDViNiwKICAic2Vnb2xoZWJyZXciLAogIDB4MDViNiwKICAic2Vnb2xuYXJyb3doZWJyZXciLAogIDB4MDViNiwKICAic2Vnb2xxdWFydGVyaGVicmV3IiwKICAweDA1YjYsCiAgInNlZ29sdGFoZWJyZXciLAogIDB4MDU5MiwKICAic2Vnb2x3aWRlaGVicmV3IiwKICAweDA1YjY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bmZpbmFsYXJhYmljIiwKICAweGZlYjYsCiAgInNoZWVuaW5pdGlhbGFyYWJpYyIsCiAgMHhmZWI3LAogICJzaGVlbm1lZGlhbGFyYWJpYyIsCiAgMHhmZWI4LAogICJzaGVpY29wdGljIiwKICAweDAzZTMsCiAgInNoZXFlbCIsCiAgMHgyMGFhLAogICJzaGVxZWxoZWJyZXciLAogIDB4MjBhYSwKICAic2hldmEiLAogIDB4MDViMCwKICAic2hldmExMTUiLAogIDB4MDViMCwKICAic2hldmExNSIsCiAgMHgwNWIwLAogICJzaGV2YTIyIiwKICAweDA1YjAsCiAgInNoZXZhMmUiLAogIDB4MDViMCwKICAic2hldmFoZWJyZXciLAogIDB4MDViMCwKICAic2hldmFuYXJyb3doZWJyZXciLAogIDB4MDViMCwKICAic2hldmFxdWFydGVyaGVicmV3IiwKICAweDA1YjAsCiAgInNoZXZhd2lkZWhlYnJldyIsCiAgMHgwNWIwLAogICJzaGhhY3lyaWxsaWMiLAogIDB4MDRiYiwKICAic2hpbWFjb3B0aWMiLAogIDB4MDNlZCwKICAic2hpbiIsCiAgMHgwNWU5LAogICJzaGluZGFnZXNoIiwKICAweGZiNDksCiAgInNoaW5kYWdlc2hoZWJyZXciLAogIDB4ZmI0OSwKICAic2hpbmRhZ2VzaHNoaW5kb3QiLAogIDB4ZmIyYywKICAic2hpbmRhZ2VzaHNoaW5kb3RoZWJyZXciLAogIDB4ZmIyYywKICAic2hpbmRhZ2VzaHNpbmRvdCIsCiAgMHhmYjJkLAogICJzaGluZGFnZXNoc2luZG90aGVicmV3IiwKICAweGZiMmQsCiAgInNoaW5kb3RoZWJyZXciLAogIDB4MDVjMSwKICAic2hpbmhlYnJldyIsCiAgMHgwNWU5LAogICJzaGluc2hpbmRvdCIsCiAgMHhmYjJhLAogICJzaGluc2hpbmRvdGhlYnJldyIsCiAgMHhmYjJhLAogICJzaGluc2luZG90IiwKICAweGZiMmIsCiAgInNoaW5zaW5kb3RoZWJyZXciLAogIDB4ZmIyY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InRoZWhhcmFiaWMiLAogIDB4MDYyYiwKICAidGhlaGZpbmFsYXJhYmljIiwKICAweGZlOWEsCiAgInRoZWhpbml0aWFsYXJhYmljIiwKICAweGZlOWIsCiAgInRoZWhtZWRpYWxhcmFiaWMiLAogIDB4ZmU5YywKICAidGhlcmVleGlzdHMiLAogIDB4MjIwMywKICAidGhlcmVmb3JlIiwKICAweDIyMzQsCiAgInRoZXRhIiwKICAweDAzYjgsCiAgInRoZXRhMSIsCiAgMHgwM2QxLAogICJ0aGV0YXN5bWJvbGdyZWVrIiwKICAweDAzZDEsCiAgInRoaWV1dGhhY2lyY2xla29yZWFuIiwKICAweDMyNzksCiAgInRoaWV1dGhhcGFyZW5rb3JlYW4iLAogIDB4MzIxOSwKICAidGhpZXV0aGNpcmNsZWtvcmVhbiIsCiAgMHgzMjZiLAogICJ0aGlldXRoa29yZWFuIiwKICAweDMxNGMsCiAgInRoaWV1dGhwYXJlbmtvcmVhbiIsCiAgMHgzMjBiLAogICJ0aGlydGVlbmNpcmNsZSIsCiAgMHgyNDZjLAogICJ0aGlydGVlbnBhcmVuIiwKICAweDI0ODAsCiAgInRoaXJ0ZWVucGVyaW9kIiwKICAweDI0OTQsCiAgInRob25hbmdtb250aG90aGFpIiwKICAweDBlMTEsCiAgInRob29rIiwKICAweDAxYWQsCiAgInRob3BodXRoYW90aGFpIiwKICAweDBlMTIsCiAgInRob3JuIiwKICAweDAwZmUsCiAgInRob3RoYWhhbnRoYWkiLAogIDB4MGUxNywKICAidGhvdGhhbnRoYWkiLAogIDB4MGUxMCwKICAidGhvdGhvbmd0aGFpIiwKICAweDBlMTgsCiAgInRob3RodW5ndGhhaSIsCiAgMHgwZTE2LAogICJ0aG91c2FuZGN5cmlsbGljIiwKICAweDA0ODIsCiAgInRob3VzYW5kc3NlcGFyYXRvcmFyYWJpYyIsCiAgMHgwNjZjLAogICJ0aG91c2FuZHNzZXBhcmF0b3JwZXJzaWFuIiwKICAweDA2NmMsCiAgInRocmVlIiwK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AgMHgyNzE0LAogICJhMjEiLAogIDB4MjcxNSwKICAiYTIyIiwKICAweDI3MTYsCiAgImEyMyIsCiAgMHgyNzE3LAogICJhMjQiLAogIDB4MjcxOCwKICAiYTI1IiwKICAweDI3MTksCiAgImEyNiIsCiAgMHgyNzFhLAogICJhMjciLAogIDB4MjcxYiwKICAiYTI4IiwKICAweDI3MWMsCiAgImE2IiwKICAweDI3MWQsCiAgImE3IiwKICAweDI3MWUsCiAgImE4IiwKICAweDI3MWYsCiAgImE5IiwKICAweDI3MjAsCiAgImExMCIsCiAgMHgyNzIxLAogICJhMjkiLAogIDB4MjcyMiwKICAiYTMwIiwKICAweDI3MjMsCiAgImEzMSIsCiAgMHgyNzI0LAogICJhMzIiLAogIDB4MjcyNSwKICAiYTMzIiwKICAweDI3MjYsCiAgImEzNCIsCiAgMHgyNzI3LAogICJhMzUiLAogIDB4MjYwNSwKICAiYTM2IiwKICAweDI3MjksCiAgImEzNyIsCiAgMHgyNzJhLAogICJhMzgiLAogIDB4MjcyYiwKICAiYTM5IiwKICAweDI3MmMsCiAgImE0MCIsCiAgMHgyNzJkLAogICJhNDEiLAogIDB4MjcyZSwKICAiYTQyIiwKICAweDI3MmYsCiAgImE0MyIsCiAgMHgyNzMwLAogICJhNDQiLAogIDB4MjczMSwKICAiYTQ1IiwKICAweDI3MzIsCiAgImE0NiIsCiAgMHgyNzMzLAogICJhNDciLAogIDB4MjczNCwKICAiYTQ4IiwKICAweDI3MzUsCiAgImE0OSIsCiAgMHgyNzM2LAogICJhNTAiLAogIDB4MjczNywKICAiYTUxIiwKICAweDI3MzgsCiAgImE1MiIsCiAgMHgyNzM5LAogICJhNTMiLAogIDB4MjczYSwKICAiYTU0IiwKICAweDI3M2IsCiAgImE1NSIsCiAgMHgyNzNjLAogICJhNTYiLAogIDB4MjczZCwKICAiYTU3IiwKICAweDI3M2UsCiAgImE1OCIsCiAgMHgyNzNmLAogICJhNTkiLAogIDB4Mjc0MCwKICAiYTYwIiwKICAweDI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NjUiLAogIDB4Mjc5OSwKICAiYTE5MiIsCiAgMHgyNzlhLAogICJhMTY2IiwKICAweDI3OWIsCiAgImExNjciLAogIDB4Mjc5YywKICAiYTE2OCIsCiAgMHgyNzlkLAogICJhMTY5IiwKICAweDI3OWUsCiAgImExNzAiLAogIDB4Mjc5ZiwKICAiYTE3MSIsCiAgMHgyN2EwLAogICJhMTcyIiwKICAweDI3YTEsCiAgImExNzMiLAogIDB4MjdhMiwKICAiYTE2MiIsCiAgMHgyN2EzLAogICJhMTc0IiwKICAweDI3YTQsCiAgImExNzUiLAogIDB4MjdhNSwKICAiYTE3NiIsCiAgMHgyN2E2LAogICJhMTc3IiwKICAweDI3YTcsCiAgImExNzgiLAogIDB4MjdhOCwKICAiYTE3OSIsCiAgMHgyN2E5LAogICJhMTkzIiwKICAweDI3YWEsCiAgImExODAiLAogIDB4MjdhYiwKICAiYTE5OSIsCiAgMHgyN2FjLAogICJhMTgxIiwKICAweDI3YWQsCiAgImEyMDAiLAogIDB4MjdhZSwKICAiYTE4MiIsCiAgMHgyN2FmLAogICJhMjAxIiwKICAweDI3YjEsCiAgImExODMiLAogIDB4MjdiMiwKICAiYTE4NCIsCiAgMHgyN2IzLAogICJhMTk3IiwKICAweDI3YjQsCiAgImExODUiLAogIDB4MjdiNSwKICAiYTE5NCIsCiAgMHgyN2I2LAogICJhMTk4IiwKICAweDI3YjcsCiAgImExODYiLAogIDB4MjdiOCwKICAiYTE5NSIsCiAgMHgyN2I5LAogICJhMTg3IiwKICAweDI3YmEsCiAgImExODgiLAogIDB4MjdiYiwKICAiYTE4OSIsCiAgMHgyN2JjLAogICJhMTkwIiwKICAweDI3YmQsCiAgImExOTEiLAogIDB4MjdiZSwKICAiYTg5IiwKICAweDI3NjgsCiAgImE5MCIsCiAgMHgyNzY5LAogICJhOTMiLAogIDB4Mjc2YSwKICAiYTk0IiwKICAweDI3NmIsCiAgImE5MSIsCiAgMHgyNzZjLAogICJhOTIiLAogIDB4Mjc2ZCwKICA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LAogICJcdTAyQkNcdTAwNkUiLAogICJcdTAxN0YiLAogICJcdTAwNzMiLAogICJcdTAxQzQiLAogICJcdTAwNDRcdTAxN0QiLAogICJcdTAxQzUiLAogICJcdTAwNDRcdTAxN0UiLAogICJcdTAxQzYiLAogICJcdTAwNjRcdTAxN0UiLAogICJcdTAxQzciLAogICJcdTAwNENcdTAwNEEiLAogICJcdTAxQzgiLAogICJcdTAwNENcdTAwNkEiLAogICJcdTAxQzkiLAogICJcdTAwNkNcdTAwNkEiLAogICJcdTAxQ0EiLAogICJcdTAwNEVcdTAwNEEiLAogICJcdTAxQ0IiLAogICJcdTAwNEVcdTAwNkEiLAogICJcdTAxQ0MiLAogICJcdTAwNkVcdTAwNkEiLAogICJcdTAxRjEiLAogICJcdTAwNDRcdTAwNUEiLAogICJcdTAxRjIiLAogICJcdTAwNDRcdTAwN0EiLAogICJcdTAxRjMiLAogICJcdTAwNjRcdTAwN0EiLAogICJcdTAyRDgiLAogICJcdTAwMjBcdTAzMDYiLAogICJcdTAyRDkiLAogICJcdTAwMjBcdTAzMDciLAogICJcdTAyREEiLAogICJcdTAwMjBcdTAzMEEiLAogICJcdTAyREIiLAogICJcdTAwMjBcdTAzMjgiLAogICJcdTAyREMiLAogICJcdTAwMjBcdTAzMDMiLAogICJcdTAyREQiLAogICJcdTAwMjBcdTAzMEIiLAogICJcdTAzN0EiLAogICJcdTAwMjBcdTAzNDUiLAogICJcdTAzODQiLAogICJcdTAwMjBcdTAzMDEiLAogICJcdTAzRDAiLAogICJcdTAzQjIiLAogICJcdTAzRDEiLAogICJcdTAzQjgiLAogICJcdTAzRDIiLAogICJcdTAzQTUiLAogICJcdTAzRDUiLAogICJcdTAzQzYiLAogICJcdTAzRDYiLAogICJcdTAzQzAiLAogICJcdTAzRjAiLAogICJcdTAzQkEiLAogICJcdTAzRjEiLAogICJcdTAzQzEiLAogICJcdTAzRjIiLAogICJcdTAzQzIiLAogICJcdTAzRjQiLAogICJcdTAzOTgiLAogICJcdTAzRjUiLAogICJcdTAzQjUiLAogICJcdTAzRjkiLAogICJcdTAzQTMiLAogICJcdTA1ODciLAogICJcdTA1NjVcdTA1ODIiLAogICJcdTA2NzUiLAogICJcdTA2MjdcdTA2NzQiLAogICJcdTA2NzYiLAogICJcdTA2NDhcdTA2NzQiLAogICJcdTA2NzciLAogICJcdTA2QzdcdTA2NzQiLAogICJcdTA2NzgiLAogICJcdTA2NEFcdTA2NzQiLAogICJcdTBFMzMiLAogICJcdTBFNERcdTBFMzIiLAogICJcdTBFQjMiLAogICJcdTBFQ0RcdTBFQjIiLAogICJcdTBFREMiLAogICJcdTBFQUJcdTBFOTkiLAogICJcdTBFREQiLAogICJcdTBFQUJcdTBFQTEiLAogICJcdTBGNzciLAogICJcdTBGQjJcdTBGODEiLAogICJcdTBGNzkiLAogICJcdTBGQjNcdTBGODEiLAogICJcdTFFOUEiLAogICJcdTAwNjFcdTAyQkUiLAogICJcdTFGQkQiLAogICJcdTAwMjBcdTAzMTMiLAogICJcdTFGQkYiLAogICJcdTAwMjBcdTAzMTMiLAogICJcdTFGQzAiLAogICJcdTAwMjBcdTAzNDIiLAogICJcdTFGRkUiLAogICJcdTAwMjBcdTAzMTQiLAogICJcdTIwMDIiLAogICJcdTAwMjAiLAogICJcdTIwMDMiLAogICJcdTAwMjAiLAogICJcdTIwMDQiLAogICJcdTAwMjAiLAogICJcdTIwMDUiLAogICJcdTAwMjAiLAogICJcdTIwMDYiLAogICJcdTAwMjAiLAogICJcdTIwMDgiLAogICJcdTAwMjAiLAogICJcdTIwMDkiLAogICJcdTAwMjAiLAogICJcdTIwMEEiLAogICJcdTAwMjAiLAogICJcdTIwMTciLAogICJcdTAwMjBcdTAzMzMiLAogICJcdTIwMjQiLAogICJcdTAwMkUiLAogICJcdTIwMjUiLAogICJcdTAwMkVcdTAwMkUiLAogICJcdTIwMjYiLAogICJcdTAwMkVcdTAwMkVcdTAwMkUiLAogICJcdTIwMzMiLAogICJcdTIwMzJcdTIwMzIiLAogICJcdTIwMzQiLAogICJcdTIwMzJcdTIwMzJcdTIwMzIiLAogICJcdTIwMzYiLAogICJcdTIwMzVcdTIwMzUiLAogICJcdTIwMzciLAogICJcdTIwMzVcdTIwMzVcdTIwMzUiLAogICJcdTIwM0MiLAogICJcdTAwMjFcdTAwMjEiLAogICJcdTIwM0UiLAogICJcdTAwMjBcdTAzMDUiLAogICJcdTIwNDciLAogICJcdTAwM0ZcdTAwM0YiLAogICJcdTIwNDgiLAogICJcdTAwM0ZcdTAwMjEiLAogICJcdTIwNDkiLAogICJcdTAwMjFcdTAwM0YiLAogICJcdTIwNTciLAogICJcdTIwMzJcdTIwMzJcdTIwMzJcdTIwMzIiLAogICJcdTIwNUYiLAogICJcdTAwMjAiLAogICJcdTIwQTgiLAogICJcdTAwNTJcdTAwNzMiLAogICJcdTIxMDAiLAogICJcdTAwNjFcdTAwMkZcdTAwNjMiLAogICJcdTIxMDEiLAogICJcdTAwNjFcdTAwMkZcdTAwNzMiLAogICJcdTIxMDMiLAogICJcdTAwQjBcdTAwNDMiLAogICJcdTIxMDUiLAogICJcdTAwNjNcdTAwMkZcdTAwNkYiLAogICJcdTIxMDYiLAogICJcdTAwNjNcdTAwMkZcdTAwNzUiLAogICJcdTIxMDciLAogICJcdTAxOTAiLAogICJcdTIxMDkiLAogICJcdTAwQjBcdTAwNDYiLAogICJcdTIxMTYiLAogICJcdTAwNEVcdTAwNkYiLAogICJcdTIxMjEiLAogICJcdTAwNTRcdTAwNDVcdTAwNEMiLAogICJcdTIxMzUiLAogICJcdTA1RDAiLAogICJcdTIxMzYiLAogICJcdTA1RDEiLAogICJcdTIxMzciLAogICJcdTA1RDIiLAogICJcdTIxMzgiLAogICJcdTA1RDMiLAogICJcdTIxM0IiLAogICJcdTAwNDZcdTAwNDFcdTAwNTgiLAogICJcdTIxNjAiLAogICJcdTAwNDkiLAogICJcdTIxNjEiLAogICJcdTAwNDlcdTAwNDkiLAogICJcdTIxNjIiLAogICJcdTAwNDlcdTAwNDlcdTAwNDkiLAogICJcdTIxNjMiLAogICJcdTAwNDlcdTAwNTYiLAogICJcdTIxNjQiLAogICJcdTAwNTYiLAogICJcdTIxNjUiLAogICJcdTAwNTZcdTAwNDkiLAogICJcdTIxNjYiLAogICJcdTAwNTZcdTAwNDlcdTAwNDkiLAogICJcdTIxNjciLAogICJcdTAwNTZcdTAwNDlcdTAwNDlcdTAwNDkiLAogICJcdTIxNjgiLAogICJcdTAwNDlcdTAwNTgiLAogICJcdTIxNjkiLAogICJcdTAwNTgiLAogICJcdTIxNkEiLAogICJcdTAwNThcdTAwNDkiLAogICJcdTIxNkIiLAogICJcdTAwNThcdTAwNDlcdTAwNDkiLAogICJcdTIxNkMiLAogICJcdTAwNEMiLAogICJcdTIxNkQiLAogICJcdTAwNDMiLAogICJcdTIxNkUiLAogICJcdTAwNDQiLAogICJcdTIxNkYiLAogICJcdTAwNEQiLAogICJcdTIxNzAiLAogICJcdTAwNjkiLAogICJcdTIxNzEiLAogICJcdTAwNjlcdTAwNjkiLAogICJcdTIxNzIiLAogICJcdTAwNjlcdTAwNjlcdTAwNjkiLAogICJcdTIxNzMiLAogICJcdTAwNjlcdTAwNzYiLAogICJcdTIxNzQiLAogICJcdTAwNzYiLAogICJcdTIxNzUiLAogICJcdTAwNzZcdTAwNjkiLAogICJcdTIxNzYiLAogICJcdTAwNzZcdTAwNjlcdTAwNjkiLAogICJcdTIxNzciLAogICJcdTAwNzZcdTAwNjlcdTAwNjlcdTAwNjkiLAogICJcdTIxNzgiLAogICJcdTAwNjlcdTAwNzgiLAogICJcdTIxNzkiLAogICJcdTAwNzgiLAogICJcdTIxN0EiLAogICJcdTAwNzhcdTAwNjkiLAogICJcdTIxN0IiLAogICJcdTAwNzhcdTAwNjlcdTAwNjkiLAogICJcdTIxN0MiLAogICJcdTAwNkMiLAogICJcdTIxN0QiLAogICJcdTAwNjMiLAogICJcdTIxN0UiLAogICJcdTAwNjQiLAogICJcdTIxN0YiLAogICJcdTAwNkQiLAogICJcd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ICJcdTJBMEMiLAogICJcdTIyMkJcdTIyMkJcdTIyMkJcdTIyMkIiLAogICJcdTJBNzQiLAogICJcdTAwM0FcdTAwM0FcdTAwM0QiLAogICJcdTJBNzUiLAogICJcdTAwM0RcdTAwM0QiLAogICJcdTJBNzYiLAogICJcdTAwM0RcdTAwM0RcdTAwM0QiLAogICJcdTJFOUYiLAogICJcdTZCQ0QiLAogICJcdTJFRjMiLAogICJcdTlGOUYiLAogICJcdTJGMDAiLAogICJcdTRFMDAiLAogICJcdTJGMDEiLAogICJcdTRFMjgiLAogICJcdTJGMDIiLAogICJcdTRFMzYiLAogICJcdTJGMDMiLAogICJcdTRFM0YiLAogICJcdTJGMDQiLAogICJcdTRFNTkiLAogICJcdTJGMDUiLAogICJcdTRFODUiLAogICJcdTJGMDYiLAogICJcdTRFOEMiLAogICJcdTJGMDciLAogICJcdTRFQTAiLAogICJcdTJGMDgiLAogICJcdTRFQkEiLAogICJcdTJGMDkiLAogICJcdTUxM0YiLAogICJcdTJGMEEiLAogICJcdTUxNjUiLAogICJcdTJGMEIiLAogICJcdTUxNkIiLAogICJcdTJGMEMiLAogICJcdTUxODIiLAogICJcdTJGMEQiLAogICJcdTUxOTYiLAogICJcdTJGMEUiLAogICJcdTUxQUIiLAogICJcdTJGMEYiLAogICJcdTUxRTAiLAogICJcdTJGMTAiLAogICJcdTUxRjUiLAogICJcdTJGMTEiLAogICJcdTUyMDAiLAogICJcdTJGMTIiLAogICJcdTUyOUIiLAogICJcdTJGMTMiLAogICJcdTUyRjkiLAogICJcdTJGMTQiLAogICJcdTUzMTUiLAogICJcdTJGMTUiLAogICJcdTUzMUEiLAogICJcdTJGMTYiLAogICJcdTUzMzgiLAogICJcdTJGMTciLAogICJcdTUzNDEiLAogICJcdTJGMTgiLAogICJcdTUzNUMiLAogICJcdTJGMTkiLAogICJcdTUzNjkiLAogICJcdTJGMUEiLAogICJcdTUzODIiLAogICJcdTJGMUIiLAogICJcdTUzQjYiLAogICJcdTJGMUMiLAogICJcdTUzQzgiLAogICJcdTJGMUQiLAogICJcdTUzRTMiLAogICJcdTJGMUUiLAogICJcdTU2RDciLAogICJcdTJGMUYiLAogICJcdTU3MUYiLAogICJcdTJGMjAiLAogICJcdTU4RUIiLAogICJcdTJGMjEiLAogICJcdTU5MDIiLAogICJcdTJGMjIiLAogICJcdTU5MEEiLAogICJcdTJGMjMiLAogICJcdTU5MTUiLAogICJcdTJGMjQiLAogICJcdTU5MjciLAogICJcdTJGMjUiLAogICJcdTU5NzMiLAogICJcdTJGMjYiLAogICJcdTVCNTAiLAogICJcdTJGMjciLAogICJcdTVCODAiLAogICJcdTJGMjgiLAogICJcdTVCRjgiLAogICJcdTJGMjkiLAogICJcdTVDMEYiLAogICJcdTJGMkEiLAogICJcdTVDMjIiLAogICJcdTJGMkIiLAogICJcdTVDMzgiLAogICJcdTJGMkMiLAogICJcdTVDNkUiLAogICJcdTJGMkQiLAogICJcdTVDNzEiLAogICJcdTJGMkUiLAogICJcdTVEREIiLAogICJcdTJGMkYiLAogICJcdTVERTUiLAogICJcdTJGMzAiLAogICJcdTVERjEiLAogICJcdTJGMzEiLAogICJcdTVERkUiLAogICJcdTJGMzIiLAogICJcdTVFNzIiLAogICJcdTJGMzMiLAogICJcdTVFN0EiLAogICJcdTJGMzQiLAogICJcdTVFN0YiLAogICJcdTJGMzUiLAogICJcdTVFRjQiLAogICJcdTJGMzYiLAogICJcdTVFRkUiLAogICJcdTJGMzciLAogICJcdTVGMEIiLAogICJcdTJGMzgiLAogICJcdTVGMTMiLAogICJcdTJGMzkiLAogICJcdTVGNTAiLAogICJcdTJGM0EiLAogICJcdTVGNjEiLAogICJcdTJGM0IiLAogICJcdTVGNzMiLAogICJcdTJGM0MiLAogICJcdTVGQzMiLAogICJcdTJGM0QiLAogICJcdTYyMDgiLAogICJcdTJGM0UiLAogICJcdTYyMzYiLAogICJcdTJGM0YiLAogICJcdTYyNEIiLAogICJcdTJGNDAiLAogICJcdTY1MkYiLAogICJcdTJGNDEiLAogICJcdTY1MzQiLAogICJcdTJGNDIiLAogICJcdTY1ODciLAogICJcdTJGNDMiLAogICJcdTY1OTciLAogICJcdTJGNDQiLAogICJcdTY1QTQiLAogICJcdTJGNDUiLAogICJcdTY1QjkiLAogICJcdTJGNDYiLAogICJcdTY1RTAiLAogICJcdTJGNDciLAogICJcdTY1RTUiLAogICJcdTJGNDgiLAogICJcdTY2RjAiLAogICJcdTJGNDkiLAogICJcdTY3MDgiLAogICJcdTJGNEEiLAogICJcdTY3MjgiLAogICJcdTJGNEIiLAogICJcdTZCMjAiLAogICJcdTJGNEMiLAogICJcdTZCNjIiLAogICJcdTJGNEQiLAogICJcdTZCNzkiLAogICJcdTJGNEUiLAogICJcdTZCQjMiLAogICJcdTJGNEYiLAogICJcdTZCQ0IiLAogICJcdTJGNTAiLAogICJcdTZCRDQiLAogICJcdTJGNTEiLAogICJcdTZCREIiLAogICJcdTJGNTIiLAogICJcdTZDMEYiLAogICJcdTJGNTMiLAogICJcdTZDMTQiLAogICJcdTJGNTQiLAogICJcdTZDMzQiLAogICJcdTJGNTUiLAogICJcdTcwNkIiLAogICJcdTJGNTYiLAogICJcdTcyMkEiLAogICJcdTJGNTciLAogICJcdTcyMzYiLAogICJcdTJGNTgiLAogICJcdTcyM0IiLAogICJcdTJGNTkiLAogICJcdTcyM0YiLAogICJcdTJGNUEiLAogICJcdTcyNDciLAogICJcdTJGNUIiLAogICJcdTcyNTkiLAogICJcdTJGNUMiLAogICJcdTcyNUIiLAogICJcdTJGNUQiLAogICJcdTcyQUMiLAogICJcdTJGNUUiLAogICJcdTczODQiLAogICJcdTJGNUYiLAogICJcdTczODkiLAogICJcdTJGNjAiLAogICJcdTc0REMiLAogICJcdTJGNjEiLAogICJcdTc0RTYiLAogICJcdTJGNjIiLAogICJcdTc1MTgiLAogICJcdTJGNjMiLAogICJcdTc1MUYiLAogICJcdTJGNjQiLAogICJcdTc1MjgiLAogICJcdTJGNjUiLAogICJcdTc1MzAiLAogICJcdTJGNjYiLAogICJcdTc1OEIiLAogICJcdTJGNjciLAogICJcdTc1OTIiLAogICJcdTJGNjgiLAogICJcdTc2NzYiLAogICJcdTJGNjkiLAogICJcdTc2N0QiLAogICJcdTJGNkEiLAogICJcdTc2QUUiLAogICJcdTJGNkIiLAogICJcdTc2QkYiLAogICJcdTJGNkMiLAogICJcdTc2RUUiLAogICJcdTJGNkQiLAogICJcdTc3REIiLAogICJcdTJGNkUiLAogICJcdTc3RTIiLAogICJcdTJGNkYiLAogICJcdTc3RjMiLAogICJcdTJGNzAiLAogICJcdTc5M0EiLAogICJcdTJGNzEiLAogICJcdTc5QjgiLAogICJcdTJGNzIiLAogICJcdTc5QkUiLAogICJcdTJGNzMiLAogICJcdTdBNzQiLAogICJcdTJGNzQiLAogICJcdTdBQ0IiLAogICJcdTJGNzUiLAogICJcdTdBRjkiLAogICJcdTJGNzYiLAogICJcdTdDNzMiLAogICJcdTJGNzciLAogICJcdTdDRjgiLAogICJcdTJGNzgiLAogICJcdTdGMzYiLAogICJcdTJGNzkiLAogICJcdTdGNTEiLAogICJcdTJGN0EiLAogICJcdTdGOEEiLAogICJcdTJGN0IiLAogICJcdTdGQkQiLAogICJcdTJGN0MiLAogICJcdTgwMDEiLAogICJcdTJGN0QiLAogICJcdTgwMEMiLAogICJcdTJGN0UiLAogICJcdTgwMTIiLAogICJcdTJGN0YiLAogICJcdTgwMzMiLAogICJcdTJGODAiLAogICJcdTgwN0YiLAogICJcdTJGODEiLAogICJcdTgwODkiLAogICJcdTJGODIiLAogICJcdTgxRTMiLAogICJcdTJGODMiLAogICJcdTgxRUEiLAogICJcdTJGODQiLAogICJcdTgxRjMiLAogICJcdTJGODUiLAogICJcdTgxRkMiLAogICJcdTJGODYiLAogICJcdTgyMEMiLAogICJcdTJGODciLAogICJcdTgyMUIiLAogICJcdTJGODgiLAogICJcdTgyMUYiLAogICJcdTJGODkiLAogICJcdTgyNkUiLAogICJcdTJGOEEiLAogICJcdTgyNzIiLAogICJcdTJGOEIiLAogICJcdTgyNzgiLAogICJcdTJGOEMiLAogICJcdTg2NEQiLAogICJcdTJGOEQiLAogICJcdTg2NkIiLAogICJcdTJGOEUiLAogICJcdTg4NDAiLAogICJcdTJGOEYiLAogICJcdTg4NEMiLAogICJcdTJGOTAiLAogICJcdTg4NjMiLAogICJcdTJGOTEiLAogICJcdTg5N0UiLAogICJcdTJGOTIiLAogICJcdTg5OEIiLAogICJcdTJGOTMiLAogICJcdTg5RDIiLAogICJcdTJGOTQiLAogICJcdThBMDAiLAogICJcdTJGOTUiLAogICJcdThDMzciLAogICJcdTJGOTYiLAogICJcdThDNDYiLAogICJcdTJGOTciLAogICJcdThDNTUiLAogICJcdTJGOTgiLAogICJcdThDNzgiLAogICJcdTJGOTkiLAogICJcdThDOUQiLAogICJcdTJGOUEiLAogICJcdThENjQiLAogICJcdTJGOUIiLAogICJcdThENzAiLAogICJcdTJGOUMiLAogICJcdThEQjMiLAogICJcdTJGOUQiLAogICJcdThFQUIiLAogICJcdTJGOUUiLAogICJcdThFQ0EiLAogICJcdTJGOUYiLAogICJcdThGOUIiLAogICJcdTJGQTAiLAogICJcdThGQjAiLAogICJcdTJGQTEiLAogICJcdThGQjUiLAogICJcdTJGQTIiLAogICJcdTkwOTEiLAogICJcdTJGQTMiLAogICJcdTkxNDkiLAogICJcdTJGQTQiLAogICJcdTkxQzYiLAogICJcdTJGQTUiLAogICJcdTkxQ0MiLAogICJcdTJGQTYiLAogICJcdTkxRDEiLAogICJcdTJGQTciLAogICJcdTk1NzciLAogICJcdTJGQTgiLAogICJcdTk1ODAiLAogICJcdTJGQTkiLAogICJcdTk2MUMiLAogICJcdTJGQUEiLAogICJcdTk2QjYiLAogICJcdTJGQUIiLAogICJcdTk2QjkiLAogICJcdTJGQUMiLAogICJcdTk2RTgiLAogICJcdTJGQUQiLAogICJcdTk3NTEiLAogICJcdTJGQUUiLAogICJcdTk3NUUiLAogICJcdTJGQUYiLAogICJcdTk3NjIiLAogICJcdTJGQjAiLAogICJcdTk3NjkiLAogICJcdTJGQjEiLAogICJcdTk3Q0IiLAogICJcdTJGQjIiLAogICJcdTk3RUQiLAogICJcdTJGQjMiLAogICJcdTk3RjMiLAogICJcdTJGQjQiLAogICJcdTk4MDEiLAogICJcdTJGQjUiLAogICJcdTk4QTgiLAogICJcdTJGQjYiLAogICJcdTk4REIiLAogICJcdTJGQjciLAogICJcdTk4REYiLAogICJcdTJGQjgiLAogICJcdTk5OTYiLAogICJcdTJGQjkiLAogICJcdTk5OTkiLAogICJcdTJGQkEiLAogICJcdTk5QUMiLAogICJcdTJGQkIiLAogICJcdTlBQTgiLAogICJcdTJGQkMiLAogICJcdTlBRDgiLAogICJcdTJGQkQiLAogICJcdTlBREYiLAogICJcdTJGQkUiLAogICJcdTlCMjUiLAogICJcdTJGQkYiLAogICJcdTlCMkYiLAogICJcdTJGQzAiLAogICJcdTlCMzIiLAogICJcdTJGQzEiLAogICJcdTlCM0MiLAogICJcdTJGQzIiLAogICJcdTlCNUEiLAogICJcdTJGQzMiLAogICJcdTlDRTUiLAogICJcdTJGQzQiLAogICJcdTlFNzUiLAogICJcdTJGQzUiLAogICJcdTlFN0YiLAogICJcdTJGQzYiLAogICJcdTlFQTUiLAogICJcdTJGQzciLAogICJcdTlFQkIiLAogICJcdTJGQzgiLAogICJcdTlFQzMiLAogICJcdTJGQzkiLAogICJcdTlFQ0QiLAogICJcdTJGQ0EiLAogICJcdTlFRDEiLAogICJcdTJGQ0IiLAogICJcdTlFRjkiLAogICJcdTJGQ0MiLAogICJcdTlFRkQiLAogICJcdTJGQ0QiLAogICJcdTlGMEUiLAogICJcdTJGQ0UiLAogICJcdTlGMTMiLAogICJcdTJGQ0YiLAogICJcdTlGMjAiLAogICJcdTJGRDAiLAogICJcdTlGM0IiLAogICJcdTJGRDEiLAogICJcdTlGNEEiLAogICJcdTJGRDIiLAogICJcdTlGNTIiLAogICJcdTJGRDMiLAogICJcdTlGOEQiLAogICJcdTJGRDQiLAogICJcdTlGOUMiLAogICJcdTJGRDUiLAogICJcdTlGQTAiLAogICJcdTMwMzYiLAogICJcdTMwMTIiLAogICJcdTMwMzgiLAogICJcdTUzNDEiLAogICJcdTMwMzkiLAogICJcdTUzNDQiLAogICJcdTMwM0EiLAogICJcdTUzNDUiLAogICJcdTMwOUIiLAogICJcdTAwMjBcdTMwOTkiLAogICJcdTMwOUMiLAogICJcdTAwMjBcdTMwOUEiLAogICJcdTMxMzEiLAogICJcdTExMDAiLAogICJcdTMxMzIiLAogICJcdTExMDEiLAogICJcdTMxMzMiLAogICJcdTExQUEiLAogICJcdTMxMzQiLAogICJcdTExMDIiLAogICJcdTMxMzUiLAogICJcdTExQUMiLAogICJcdTMxMzYiLAogICJcdTExQUQiLAogICJcdTMxMzciLAogICJcdTExMDMiLAogICJcdTMxMzgiLAogICJcdTExMDQiLAogICJcdTMxMzkiLAogICJcdTExMDUiLAogICJcdTMxM0EiLAogICJcdTExQjAiLAogICJcdTMxM0IiLAogICJcdTExQjEiLAogICJcdTMxM0MiLAogICJcdTExQjIiLAogICJcdTMxM0QiLAogICJcdTExQjMiLAogICJcdTMxM0UiLAogICJcdTExQjQiLAogICJcdTMxM0YiLAogICJcdTExQjUiLAogICJcdTMxNDAiLAogICJcdTExMUEiLAogICJcdTMxNDEiLAogICJcdTExMDYiLAogICJcdTMxNDIiLAogICJcdTExMDciLAogICJcdTMxNDMiLAogICJcdTExMDgiLAogICJcdTMxNDQiLAogICJcdTExMjEiLAogICJcdTMxNDUiLAogICJcdTExMDkiLAogICJcdTMxNDYiLAogICJcdTExMEEiLAogICJcdTMxNDciLAogICJcdTExMEIiLAogICJcdTMxNDgiLAogICJcdTExMEMiLAogICJcdTMxNDkiLAogICJcdTExMEQiLAogICJcdTMxNEEiLAogICJcdTExMEUiLAogICJcdTMxNEIiLAogICJcdTExMEYiLAogICJcdTMxNEMiLAogICJcdTExMTAiLAogICJcdTMxNEQiLAogICJcdTExMTEiLAogICJcdTMxNEUiLAogICJcdTExMTIiLAogICJcdTMxNEYiLAogICJcdTExNjEiLAogICJcdTMxNTAiLAogICJcdTExNjIiLAogICJcdTMxNTEiLAogICJcdTExNjMiLAogICJcdTMxNTIiLAogICJcdTExNjQiLAogICJcdTMxNTMiLAogICJcdTExNjUiLAogICJcdTMxNTQiLAogICJcdTExNjYiLAogICJcdTMxNTUiLAogICJcdTExNjciLAogICJcdTMxNTYiLAogICJcdTExNjgiLAogICJcdTMxNTciLAogICJcdTExNjkiLAogICJcdTMxNTgiLAogICJcdTExNkEiLAogICJcdTMxNTkiLAogICJcdTExNkIiLAogICJcdTMxNUEiLAogICJcdTExNkMiLAogICJcdTMxNUIiLAogICJcdTExNkQiLAogICJcdTMxNUMiLAogICJcdTExNkUiLAogICJcdTMxNUQiLAogICJcdTExNkYiLAogICJcdTMxNUUiLAogICJcdTExNzAiLAogICJcdTMxNUYiLAogICJcdTExNzEiLAogICJcdTMxNjAiLAogICJcdTExNzIiLAogICJcdTMxNjEiLAogICJcdTExNzMiLAogICJcdTMxNjIiLAogICJcdTExNzQiLAogICJcdTMxNjMiLAogICJcdTExNzUiLAogICJcdTMxNjQiLAogICJcdTExNjAiLAogICJcdTMxNjUiLAogICJcdTExMTQiLAogICJcdTMxNjYiLAogICJcdTExMTUiLAogICJcdTMxNjciLAogICJcdTExQzciLAogICJcdTMxNjgiLAogICJcdTExQzgiLAogICJcdTMxNjkiLAogICJcdTExQ0MiLAogICJcdTMxNkEiLAogICJcdTExQ0UiLAogICJcdTMxNkIiLAogICJcdTExRDMiLAogICJcdTMxNkMiLAogICJcdTExRDciLAogICJcdTMxNkQiLAogICJcdTExRDkiLAogICJcdTMxNkUiLAogICJcdTExMUMiLAogICJcdTMxNkYiLAogICJcdTExREQiLAogICJcdTMxNzAiLAogICJcdTExREYiLAogICJcdTMxNzEiLAogICJcdTExMUQiLAogICJcdTMxNzIiLAogICJcdTExMUUiLAogICJcdTMxNzMiLAogICJcdTExMjAiLAogICJcdTMxNzQiLAogICJcdTExMjIiLAogICJcdTMxNzUiLAogICJcdTExMjMiLAogICJcdTMxNzYiLAogICJcdTExMjciLAogICJcdTMxNzciLAogICJcdTExMjkiLAogICJcdTMxNzgiLAogICJcdTExMkIiLAogICJcdTMxNzkiLAogICJcdTExMkMiLAogICJcdTMxN0EiLAogICJcdTExMkQiLAogICJcdTMxN0IiLAogICJcdTExMkUiLAogICJcdTMxN0MiLAogICJcdTExMkYiLAogICJcdTMxN0QiLAogICJcdTExMzIiLAogICJcdTMxN0UiLAogICJcdTExMzYiLAogICJcdTMxN0YiLAogICJcdTExNDAiLAogICJcdTMxODAiLAogICJcdTExNDciLAogICJcdTMxODEiLAogICJcdTExNEMiLAogICJcdTMxODIiLAogICJcdTExRjEiLAogICJcdTMxODMiLAogICJcdTExRjIiLAogICJcdTMxODQiLAogICJcdTExNTciLAogICJcdTMxODUiLAogICJcdTExNTgiLAogICJcdTMxODYiLAogICJcdTExNTkiLAogICJcdTMxODciLAogICJcdTExODQiLAogICJcdTMxODgiLAogICJcdTExODUiLAogICJcdTMxODkiLAogICJcdTExODgiLAogICJcdTMxOEEiLAogICJcdTExOTEiLAogICJcdTMxOEIiLAogICJcdTExOTIiLAogICJcdTMxOEMiLAogICJcdTExOTQiLAogICJcdTMxOEQiLAogICJcdTExOUUiLAogICJcdTMxOEUiLAogICJcdTExQTEiLAogICJcdTMyMDAiLAogICJcdTAwMjhcdTExMDBcdTAwMjkiLAogICJcdTMyMDEiLAogICJcdTAwMjhcdTExMDJcdTAwMjkiLAogICJcdTMyMDIiLAogICJcdTAwMjhcdTExMDNcdTAwMjkiLAogICJcdTMyMDMiLAogICJcdTAwMjhcdTExMDVcdTAwMjkiLAogICJcdTMyMDQiLAogICJcdTAwMjhcdTExMDZcdTAwMjkiLAogICJcdTMyMDUiLAogICJcdTAwMjhcdTExMDdcdTAwMjkiLAogICJcdTMyMDYiLAogICJcdTAwMjhcdTExMDlcdTAwMjkiLAogICJcdTMyMDciLAogICJcdTAwMjhcdTExMEJcdTAwMjkiLAogICJcdTMyMDgiLAogICJcdTAwMjhcdTExMENcdTAwMjkiLAogICJcdTMyMDkiLAogICJcdTAwMjhcdTExMEVcdTAwMjkiLAogICJcdTMyMEEiLAogICJcdTAwMjhcdTExMEZcdTAwMjkiLAogICJcdTMyMEIiLAogICJcdTAwMjhcdTExMTBcdTAwMjkiLAogICJcdTMyMEMiLAogICJcdTAwMjhcdTExMTFcdTAwMjkiLAogICJcdTMyMEQiLAogICJcdTAwMjhcdTExMTJcdTAwMjkiLAogICJcdTMyMEUiLAogICJcdTAwMjhcdTExMDBcdTExNjFcdTAwMjkiLAogICJcdTMyMEYiLAogICJcdTAwMjhcdTExMDJcdTExNjFcdTAwMjkiLAogICJcdTMyMTAiLAogICJcdTAwMjhcdTExMDNcdTExNjFcdTAwMjkiLAogICJcdTMyMTEiLAogICJcdTAwMjhcdTExMDVcdTExNjFcdTAwMjkiLAogICJcdTMyMTIiLAogICJcdTAwMjhcdTExMDZcdTExNjFcdTAwMjkiLAogICJcdTMyMTMiLAogICJcdTAwMjhcdTExMDdcdTExNjFcdTAwMjkiLAogICJcdTMyMTQiLAogICJcdTAwMjhcdTExMDlcdTExNjFcdTAwMjkiLAogICJcdTMyMTUiLAogICJcdTAwMjhcdTExMEJcdTExNjFcdTAwMjkiLAogICJcdTMyMTYiLAogICJcdTAwMjhcdTExMENcdTExNjFcdTAwMjkiLAogICJcdTMyMTciLAogICJcdTAwMjhcdTExMEVcdTExNjFcdTAwMjkiLAogICJcdTMyMTgiLAogICJcdTAwMjhcdTExMEZcdTExNjFcdTAwMjkiLAogICJcdTMyMTkiLAogICJcdTAwMjhcdTExMTBcdTExNjFcdTAwMjkiLAogICJcdTMyMUEiLAogICJcdTAwMjhcdTExMTFcdTExNjFcdTAwMjkiLAogICJcdTMyMUIiLAogICJcdTAwMjhcdTExMTJcdTExNjFcdTAwMjkiLAogICJcdTMyMUMiLAogICJcdTAwMjhcdTExMENcdTExNkVcdTAwMjkiLAogICJcdTMyMUQiLAogICJcdTAwMjhcdTExMEJcdTExNjlcdTExMENcdTExNjVcdTExQUJcdTAwMjkiLAogICJcdTMyMUUiLAogICJcdTAwMjhcdTExMEJcdTExNjlcdTExMTJcdTExNkVcdTAwMjkiLAogICJcdTMyMjAiLAogICJcdTAwMjhcdTRFMDBcdTAwMjkiLAogICJcdTMyMjEiLAogICJcdTAwMjhcdTRFOENcdTAwMjkiLAogICJcdTMyMjIiLAogICJcdTAwMjhcdTRFMDlcdTAwMjkiLAogICJcdTMyMjMiLAogICJcdTAwMjhcdTU2REJcdTAwMjkiLAogICJcdTMyMjQiLAogICJcdTAwMjhcdTRFOTRcdTAwMjkiLAogICJcdTMyMjUiLAogICJcdTAwMjhcdTUxNkRcdTAwMjkiLAogICJcdTMyMjYiLAogICJcdTAwMjhcdTRFMDNcdTAwMjkiLAogICJcdTMyMjciLAogICJcdTAwMjhcdTUxNkJcdTAwMjkiLAogICJcdTMyMjgiLAogICJcdTAwMjhcdTRFNURcdTAwMjkiLAogICJcdTMyMjkiLAogICJcdTAwMjhcdTUzNDFcdTAwMjkiLAogICJcdTMyMkEiLAogICJcdTAwMjhcdTY3MDhcdTAwMjkiLAogICJcdTMyMkIiLAogICJcdTAwMjhcdTcwNkJcdTAwMjkiLAogICJcdTMyMkMiLAogICJcdTAwMjhcdTZDMzRcdTAwMjkiLAogICJcdTMyMkQiLAogICJcdTAwMjhcdTY3MjhcdTAwMjkiLAogICJcdTMyMkUiLAogICJcdTAwMjhcdTkxRDFcdTAwMjkiLAogICJcdTMyMkYiLAogICJcdTAwMjhcdTU3MUZcdTAwMjkiLAogICJcdTMyMzAiLAogICJcdTAwMjhcdTY1RTVcdTAwMjkiLAogICJcdTMyMzEiLAogICJcdTAwMjhcdTY4MkFcdTAwMjkiLAogICJcdTMyMzIiLAogICJcdTAwMjhcdTY3MDlcdTAwMjkiLAogICJcdTMyMzMiLAogICJcdTAwMjhcdTc5M0VcdTAwMjkiLAogICJcdTMyMzQiLAogICJcdTAwMjhcdTU0MERcdTAwMjkiLAogICJcdTMyMzUiLAogICJcdTAwMjhcdTcyNzlcdTAwMjkiLAogICJcdTMyMzYiLAogICJcdTAwMjhcdThDQTFcdTAwMjkiLAogICJcdTMyMzciLAogICJcdTAwMjhcdTc5NURcdTAwMjkiLAogICJcdTMyMzgiLAogICJcdTAwMjhcdTUyQjRcdTAwMjkiLAogICJcdTMyMzkiLAogICJcdTAwMjhcdTRFRTNcdTAwMjkiLAogICJcdTMyM0EiLAogICJcdTAwMjhcdTU0N0NcdTAwMjkiLAogICJcdTMyM0IiLAogICJcdTAwMjhcdTVCNjZcdTAwMjkiLAogICJcdTMyM0MiLAogICJcdTAwMjhcdTc2RTNcdTAwMjkiLAogICJcdTMyM0QiLAogICJcdTAwMjhcdTRGMDFcdTAwMjkiLAogICJcdTMyM0UiLAogICJcdTAwMjhcdThDQzdcdTAwMjkiLAogICJcdTMyM0YiLAogICJcdTAwMjhcdTUzNTRcdTAwMjkiLAogICJcdTMyNDAiLAogICJcdTAwMjhcdTc5NkRcdTAwMjkiLAogICJcdTMyNDEiLAogICJcdTAwMjhcdTRGMTFcdTAwMjkiLAogICJcdTMyNDIiLAogICJcdTAwMjhcdTgxRUFcdTAwMjkiLAogICJcdTMyNDMiLAogICJcdTAwMjhcdTgxRjNcdTAwMjkiLAogICJcdTMyQzAiLAogICJcdTAwMzFcdTY3MDgiLAogICJcdTMyQzEiLAogICJcdTAwMzJcdTY3MDgiLAogICJcdTMyQzIiLAogICJcdTAwMzNcdTY3MDgiLAogICJcdTMyQzMiLAogICJcdTAwMzRcdTY3MDgiLAogICJcdTMyQzQiLAogICJcdTAwMzVcdTY3MDgiLAogICJcdTMyQzUiLAogICJcdTAwMzZcdTY3MDgiLAogICJcdTMyQzYiLAogICJcdTAwMzdcdTY3MDgiLAogICJcdTMyQzciLAogICJcdTAwMzhcdTY3MDgiLAogICJcdTMyQzgiLAogICJcdTAwMzlcdTY3MDgiLAogICJcdTMyQzkiLAogICJcdTAwMzFcdTAwMzBcdTY3MDgi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LAogICJcdTMzRjciLAogICJcdTAwMzJcdTAwMzRcdTY1RTUiLAogICJcdTMzRjgiLAogICJcdTAwMzJcdTAwMzVcdTY1RTUiLAogICJcdTMzRjkiLAogICJcdTAwMzJcdTAwMzZcdTY1RTUiLAogICJcdTMzRkEiLAogICJcdTAwMzJcdTAwMzdcdTY1RTUiLAogICJcdTMzRkIiLAogICJcdTAwMzJcdTAwMzhcdTY1RTUiLAogICJcdTMzRkMiLAogICJcdTAwMzJcdTAwMzlcdTY1RTUiLAogICJcdTMzRkQiLAogICJcdTAwMzNcdTAwMzBcdTY1RTUiLAogICJcdTMzRkUiLAogICJcdTAwMzNcdTAwMzFcdTY1RTUiLAogICJcdUZCMDAiLAogICJcdTAwNjZcdTAwNjYiLAogICJcdUZCMDEiLAogICJcdTAwNjZcdTAwNjkiLAogICJcdUZCMDIiLAogICJcdTAwNjZcdTAwNkMiLAogICJcdUZCMDMiLAogICJcdTAwNjZcdTAwNjZcdTAwNjkiLAogICJcdUZCMDQiLAogICJcdTAwNjZcdTAwNjZcdTAwNkMiLAogICJcdUZCMDUiLAogICJcdTAxN0ZcdTAwNzQiLAogICJcdUZCMDYiLAogICJcdTAwNzNcdTAwNzQiLAogICJcdUZCMTMiLAogICJcdTA1NzRcdTA1NzYiLAogICJcdUZCMTQiLAogICJcdTA1NzRcdTA1NjUiLAogICJcdUZCMTUiLAogICJcdTA1NzRcdTA1NkIiLAogICJcdUZCMTYiLAogICJcdTA1N0VcdTA1NzYiLAogICJcdUZCMTciLAogICJcdTA1NzRcdTA1NkQiLAogICJcdUZCNEYiLAogICJcdTA1RDBcdTA1REMiLAogICJcdUZCNTAiLAogICJcdTA2NzEiLAogICJcdUZCNTEiLAogICJcdTA2NzEiLAogICJcdUZCNTIiLAogICJcdTA2N0IiLAogICJcdUZCNTMiLAogICJcdTA2N0IiLAogICJcdUZCNTQiLAogICJcdTA2N0IiLAogICJcdUZCNTUiLAogICJcdTA2N0IiLAogICJcdUZCNTYiLAogICJcdTA2N0UiLAogICJcdUZCNTciLAogICJcdTA2N0UiLAogICJcdUZCNTgiLAogICJcdTA2N0UiLAogICJcdUZCNTkiLAogICJcdTA2N0UiLAogICJcdUZCNUEiLAogICJcdTA2ODAiLAogICJcdUZCNUIiLAogICJcdTA2ODAiLAogICJcdUZCNUMiLAogICJcdTA2ODAiLAogICJcdUZCNUQiLAogICJcdTA2ODAiLAogICJcdUZCNUUiLAogICJcdTA2N0EiLAogICJcdUZCNUYiLAogICJcdTA2N0EiLAogICJcdUZCNjAiLAogICJcdTA2N0EiLAogICJcdUZCNjEiLAogICJcdTA2N0EiLAogICJcdUZCNjIiLAogICJcdTA2N0YiLAogICJcdUZCNjMiLAogICJcdTA2N0YiLAogICJcdUZCNjQiLAogICJcdTA2N0YiLAogICJcdUZCNjUiLAogICJcdTA2N0YiLAogICJcdUZCNjYiLAogICJcdTA2NzkiLAogICJcdUZCNjciLAogICJcdTA2NzkiLAogICJcdUZCNjgiLAogICJcdTA2NzkiLAogICJcdUZCNjkiLAogICJcdTA2NzkiLAogICJcdUZCNkEiLAogICJcdTA2QTQiLAogICJcdUZCNkIiLAogICJcdTA2QTQiLAogICJcdUZCNkMiLAogICJcdTA2QTQiLAogICJcdUZCNkQiLAogICJcdTA2QTQiLAogICJcdUZCNkUiLAogICJcdTA2QTYiLAogICJcdUZCNkYiLAogICJcdTA2QTYiLAogICJcdUZCNzAiLAogICJcdTA2QTYiLAogICJcdUZCNzEiLAogICJcdTA2QTYiLAogICJcdUZCNzIiLAogICJcdTA2ODQiLAogICJcdUZCNzMiLAogICJcdTA2ODQiLAogICJcdUZCNzQiLAogICJcdTA2ODQiLAogICJcdUZCNzUiLAogICJcdTA2ODQiLAogICJcdUZCNzYiLAogICJcdTA2ODMiLAogICJcdUZCNzciLAogICJcdTA2ODMiLAogICJcdUZCNzgiLAogICJcdTA2ODMiLAogICJcdUZCNzkiLAogICJcdTA2ODMiLAogICJcdUZCN0EiLAogICJcdTA2ODYiLAogICJcdUZCN0IiLAogICJcdTA2ODYiLAogICJcdUZCN0MiLAogICJcdTA2ODYiLAogICJcdUZCN0QiLAogICJcdTA2ODYiLAogICJcdUZCN0UiLAogICJcdTA2ODciLAogICJcdUZCN0YiLAogICJcdTA2ODciLAogICJcdUZCODAiLAogICJcdTA2ODciLAogICJcdUZCODEiLAogICJcdTA2ODciLAogICJcdUZCODIiLAogICJcdTA2OEQiLAogICJcdUZCODMiLAogICJcdTA2OEQiLAogICJcdUZCODQiLAogICJcdTA2OEMiLAogICJcdUZCODUiLAogICJcdTA2OEMiLAogICJcdUZCODYiLAogICJcdTA2OEUiLAogICJcdUZCODciLAogICJcdTA2OEUiLAogICJcdUZCODgiLAogICJcdTA2ODgiLAogICJcdUZCODkiLAogICJcdTA2ODgiLAogICJcdUZCOEEiLAogICJcdTA2OTgiLAogICJcdUZCOEIiLAogICJcdTA2OTgiLAogICJcdUZCOEMiLAogICJcdTA2OTEiLAogICJcdUZCOEQiLAogICJcdTA2OTEiLAogICJcdUZCOEUiLAogICJcdTA2QTkiLAogICJcdUZCOEYiLAogICJcdTA2QTkiLAogICJcdUZCOTAiLAogICJcdTA2QTkiLAogICJcdUZCOTEiLAogICJcdTA2QTkiLAogICJcdUZCOTIiLAogICJcdTA2QUYiLAogICJcdUZCOTMiLAogICJcdTA2QUYiLAogICJcdUZCOTQiLAogICJcdTA2QUYiLAogICJcdUZCOTUiLAogICJcdTA2QUYiLAogICJcdUZCOTYiLAogICJcdTA2QjMiLAogICJcdUZCOTciLAogICJcdTA2QjMiLAogICJcdUZCOTgiLAogICJcdTA2QjMiLAogICJcdUZCOTkiLAogICJcdTA2QjMiLAogICJcdUZCOUEiLAogICJcdTA2QjEiLAogICJcdUZCOUIiLAogICJcdTA2QjEiLAogICJcdUZCOUMiLAogICJcdTA2QjEiLAogICJcdUZCOUQiLAogICJcdTA2QjEiLAogICJcdUZCOUUiLAogICJcdTA2QkEiLAogICJcdUZCOUYiLAogICJcdTA2QkEiLAogICJcdUZCQTAiLAogICJcdTA2QkIiLAogICJcdUZCQTEiLAogICJcdTA2QkIiLAogICJcdUZCQTIiLAogICJcdTA2QkIiLAogICJcdUZCQTMiLAogICJcdTA2QkIiLAogICJcdUZCQTQiLAogICJcdTA2QzAiLAogICJcdUZCQTUiLAogICJcdTA2QzAiLAogICJcdUZCQTYiLAogICJcdTA2QzEiLAogICJcdUZCQTciLAogICJcdTA2QzEiLAogICJcdUZCQTgiLAogICJcdTA2QzEiLAogICJcdUZCQTkiLAogICJcdTA2QzEiLAogICJcdUZCQUEiLAogICJcdTA2QkUiLAogICJcdUZCQUIiLAogICJcdTA2QkUiLAogICJcdUZCQUMiLAogICJcdTA2QkUiLAogICJcdUZCQUQiLAogICJcdTA2QkUiLAogICJcdUZCQUUiLAogICJcdTA2RDIiLAogICJcdUZCQUYiLAogICJcdTA2RDIiLAogICJcdUZCQjAiLAogICJcdTA2RDMiLAogICJcdUZCQjEiLAogICJcdTA2RDMiLAogICJcdUZCRDMiLAogICJcdTA2QUQiLAogICJcdUZCRDQiLAogICJcdTA2QUQiLAogICJcdUZCRDUiLAogICJcdTA2QUQiLAogICJcdUZCRDYiLAogICJcdTA2QUQiLAogICJcdUZCRDciLAogICJcdTA2QzciLAogICJcdUZCRDgiLAogICJcdTA2QzciLAogICJcdUZCRDkiLAogICJcdTA2QzYiLAogICJcdUZCREEiLAogICJcdTA2QzYiLAogICJcdUZCREIiLAogICJcdTA2QzgiLAogICJcdUZCREMiLAogICJcdTA2QzgiLAogICJcdUZCREQiLAogICJcdTA2NzciLAogICJcdUZCREUiLAogICJcdTA2Q0IiLAogICJcdUZCREYiLAogICJcdTA2Q0IiLAogICJcdUZCRTAiLAogICJcdTA2QzUiLAogICJcdUZCRTEiLAogICJcdTA2QzUiLAogICJcdUZCRTIiLAogICJcdTA2QzkiLAogICJcdUZCRTMiLAogICJcdTA2QzkiLAogICJcdUZCRTQiLAogICJcdTA2RDAiLAogICJcdUZCRTUiLAogICJcdTA2RDAiLAogICJcdUZCRTYiLAogICJcdTA2RDAiLAogICJcdUZCRTciLAogICJcdTA2RDAiLAogICJcdUZCRTgiLAogICJcdTA2NDkiLAogICJcdUZCRTkiLAogICJcdTA2NDkiLAogICJcdUZCRUEiLAogICJcdTA2MjZcdTA2MjciLAogICJcdUZCRUIiLAogICJcdTA2MjZcdTA2MjciLAogICJcdUZCRUMiLAogICJcdTA2MjZcdTA2RDUiLAogICJcdUZCRUQiLAogICJcdTA2MjZcdTA2RDUiLAogICJcdUZCRUUiLAogICJcdTA2MjZcdTA2NDgiLAogICJcdUZCRUYiLAogICJcdTA2MjZcdTA2NDgiLAogICJcdUZCRjAiLAogICJcdTA2MjZcdTA2QzciLAogICJcdUZCRjEiLAogICJcdTA2MjZcdTA2QzciLAogICJcdUZCRjIiLAogICJcdTA2MjZcdTA2QzYiLAogICJcdUZCRjMiLAogICJcdTA2MjZcdTA2QzYiLAogICJcdUZCRjQiLAogICJcdTA2MjZcdTA2QzgiLAogICJcdUZCRjUiLAogICJcdTA2MjZcdTA2QzgiLAogICJcdUZCRjYiLAogICJcdTA2MjZcdTA2RDAiLAogICJcdUZCRjciLAogICJcdTA2MjZcdTA2RDAiLAogICJcdUZCRjgiLAogICJcdTA2MjZcdTA2RDAiLAogICJcdUZCRjkiLAogICJcdTA2MjZcdTA2NDkiLAogICJcdUZCRkEiLAogICJcdTA2MjZcdTA2NDkiLAogICJcdUZCRkIiLAogICJcdTA2MjZcdTA2NDkiLAogICJcdUZCRkMiLAogICJcdTA2Q0MiLAogICJcdUZCRkQiLAogICJcdTA2Q0MiLAogICJcdUZCRkUiLAogICJcdTA2Q0MiLAogICJcdUZCRkYiLAogICJcdTA2Q0MiLAogICJcdUZDMDAiLAogICJcdTA2MjZcdTA2MkMiLAogICJcdUZDMDEiLAogICJcdTA2MjZcdTA2MkQiLAogICJcdUZDMDIiLAogICJcdTA2MjZcdTA2NDUiLAogICJcdUZDMDMiLAogICJcdTA2MjZcdTA2NDkiLAogICJcdUZDMDQiLAogICJcdTA2MjZcdTA2NEEiLAogICJcdUZDMDUiLAogICJcdTA2MjhcdTA2MkMiLAogICJcdUZDMDYiLAogICJcdTA2MjhcdTA2MkQiLAogICJcdUZDMDciLAogICJcdTA2MjhcdTA2MkUiLAogICJcdUZDMDgiLAogICJcdTA2MjhcdTA2NDUiLAogICJcdUZDMDkiLAogICJcdTA2MjhcdTA2NDkiLAogICJcdUZDMEEiLAogICJcdTA2MjhcdTA2NEEiLAogICJcdUZDMEIiLAogICJcdTA2MkFcdTA2MkMiLAogICJcdUZDMEMiLAogICJcdTA2MkFcdTA2MkQiLAogICJcdUZDMEQiLAogICJcdTA2MkFcdTA2MkUiLAogICJcdUZDMEUiLAogICJcdTA2MkFcdTA2NDUiLAogICJcdUZDMEYiLAogICJcdTA2MkFcdTA2NDkiLAogICJcdUZDMTAiLAogICJcdTA2MkFcdTA2NEEiLAogICJcdUZDMTEiLAogICJcdTA2MkJcdTA2MkMiLAogICJcdUZDMTIiLAogICJcdTA2MkJcdTA2NDUiLAogICJcdUZDMTMiLAogICJcdTA2MkJcdTA2NDkiLAogICJcdUZDMTQiLAogICJcdTA2MkJcdTA2NEEiLAogICJcdUZDMTUiLAogICJcdTA2MkNcdTA2MkQiLAogICJcdUZDMTYiLAogICJcdTA2MkNcdTA2NDUiLAogICJcdUZDMTciLAogICJcdTA2MkRcdTA2MkMiLAogICJcdUZDMTgiLAogICJcdTA2MkRcdTA2NDUiLAogICJcdUZDMTkiLAogICJcdTA2MkVcdTA2MkMiLAogICJcdUZDMUEiLAogICJcdTA2MkVcdTA2MkQiLAogICJcdUZDMUIiLAogICJcdTA2MkVcdTA2NDUiLAogICJcdUZDMUMiLAogICJcdTA2MzNcdTA2MkMiLAogICJcdUZDMUQiLAogICJcdTA2MzNcdTA2MkQiLAogICJcdUZDMUUiLAogICJcdTA2MzNcdTA2MkUiLAogICJcdUZDMUYiLAogICJcdTA2MzNcdTA2NDUiLAogICJcdUZDMjAiLAogICJcdTA2MzVcdTA2MkQiLAogICJcdUZDMjEiLAogICJcdTA2MzVcdTA2NDUiLAogICJcdUZDMjIiLAogICJcdTA2MzZcdTA2MkMiLAogICJcdUZDMjMiLAogICJcdTA2MzZcdTA2MkQiLAogICJcdUZDMjQiLAogICJcdTA2MzZcdTA2MkUiLAogICJcdUZDMjUiLAogICJcdTA2MzZcdTA2NDUiLAogICJcdUZDMjYiLAogICJcdTA2MzdcdTA2MkQiLAogICJcdUZDMjciLAogICJcdTA2MzdcdTA2NDUiLAogICJcdUZDMjgiLAogICJcdTA2MzhcdTA2NDUiLAogICJcdUZDMjkiLAogICJcdTA2MzlcdTA2MkMiLAogICJcdUZDMkEiLAogICJcdTA2MzlcdTA2NDUiLAogICJcdUZDMkIiLAogICJcdTA2M0FcdTA2MkMiLAogICJcdUZDMkMiLAogICJcdTA2M0FcdTA2NDUiLAogICJcdUZDMkQiLAogICJcdTA2NDFcdTA2MkMiLAogICJcdUZDMkUiLAogICJcdTA2NDFcdTA2MkQiLAogICJcdUZDMkYiLAogICJcdTA2NDFcdTA2MkUiLAogICJcdUZDMzAiLAogICJcdTA2NDFcdTA2NDUiLAogICJcdUZDMzEiLAogICJcdTA2NDFcdTA2NDkiLAogICJcdUZDMzIiLAogICJcdTA2NDFcdTA2NEEiLAogICJcdUZDMzMiLAogICJcdTA2NDJcdTA2MkQiLAogICJcdUZDMzQiLAogICJcdTA2NDJcdTA2NDUiLAogICJcdUZDMzUiLAogICJcdTA2NDJcdTA2NDkiLAogICJcdUZDMzYiLAogICJcdTA2NDJcdTA2NEEiLAogICJcdUZDMzciLAogICJcdTA2NDNcdTA2MjciLAogICJcdUZDMzgiLAogICJcdTA2NDNcdTA2MkMiLAogICJcdUZDMzkiLAogICJcdTA2NDNcdTA2MkQiLAogICJcdUZDM0EiLAogICJcdTA2NDNcdTA2MkUiLAogICJcdUZDM0IiLAogICJcdTA2NDNcdTA2NDQiLAogICJcdUZDM0MiLAogICJcdTA2NDNcdTA2NDUiLAogICJcdUZDM0QiLAogICJcdTA2NDNcdTA2NDkiLAogICJcdUZDM0UiLAogICJcdTA2NDNcdTA2NEEiLAogICJcdUZDM0YiLAogICJcdTA2NDRcdTA2MkMiLAogICJcdUZDNDAiLAogICJcdTA2NDRcdTA2MkQiLAogICJcdUZDNDEiLAogICJcdTA2NDRcdTA2MkUiLAogICJcdUZDNDIiLAogICJcdTA2NDRcdTA2NDUiLAogICJcdUZDNDMiLAogICJcdTA2NDRcdTA2NDkiLAogICJcdUZDNDQiLAogICJcdTA2NDRcdTA2NEEiLAogICJcdUZDNDUiLAogICJcdTA2NDVcdTA2MkMiLAogICJcdUZDNDYiLAogICJcdTA2NDVcdTA2MkQiLAogICJcdUZDNDciLAogICJcdTA2NDVcdTA2MkUiLAogICJcdUZDNDgiLAogICJcdTA2NDVcdTA2NDUiLAogICJcdUZDNDkiLAogICJcdTA2NDVcdTA2NDkiLAogICJcdUZDNEEiLAogICJcdTA2NDVcdTA2NEEiLAogICJcdUZDNEIiLAogICJcdTA2NDZcdTA2MkMiLAogICJcdUZDNEMiLAogICJcdTA2NDZcdTA2MkQiLAogICJcdUZDNEQiLAogICJcdTA2NDZcdTA2MkUiLAogICJcdUZDNEUiLAogICJcdTA2NDZcdTA2NDUiLAogICJcdUZDNEYiLAogICJcdTA2NDZcdTA2NDkiLAogICJcdUZDNTAiLAogICJcdTA2NDZcdTA2NEEiLAogICJcdUZDNTEiLAogICJcdTA2NDdcdTA2MkMiLAogICJcdUZDNTIiLAogICJcdTA2NDdcdTA2NDUiLAogICJcdUZDNTMiLAogICJcdTA2NDdcdTA2NDkiLAogICJcdUZDNTQiLAogICJcdTA2NDdcdTA2NEEiLAogICJcdUZDNTUiLAogICJcdTA2NEFcdTA2MkMiLAogICJcdUZDNTYiLAogICJcdTA2NEFcdTA2MkQiLAogICJcdUZDNTciLAogICJcdTA2NEFcdTA2MkUiLAogICJcdUZDNTgiLAogICJcdTA2NEFcdTA2NDUiLAogICJcdUZDNTkiLAogICJcdTA2NEFcdTA2NDkiLAogICJcdUZDNUEiLAogICJcdTA2NEFcdTA2NEEiLAogICJcdUZDNUIiLAogICJcdTA2MzBcdTA2NzAiLAogICJcdUZDNUMiLAogICJcdTA2MzFcdTA2NzAiLAogICJcdUZDNUQiLAogICJcdTA2NDlcdTA2NzAiLAogICJcdUZDNUUiLAogICJcdTAwMjBcdTA2NENcdTA2NTEiLAogICJcdUZDNUYiLAogICJcdTAwMjBcdTA2NERcdTA2NTEiLAogICJcdUZDNjAiLAogICJcdTAwMjBcdTA2NEVcdTA2NTEiLAogICJcdUZDNjEiLAogICJcdTAwMjBcdTA2NEZcdTA2NTEiLAogICJcdUZDNjIiLAogICJcdTAwMjBcdTA2NTBcdTA2NTEiLAogICJcdUZDNjMiLAogICJcdTAwMjBcdTA2NTFcdTA2NzAiLAogICJcdUZDNjQiLAogICJcdTA2MjZcdTA2MzEiLAogICJcdUZDNjUiLAogICJcdTA2MjZcdTA2MzIiLAogICJcdUZDNjYiLAogICJcdTA2MjZcdTA2NDUiLAogICJcdUZDNjciLAogICJcdTA2MjZcdTA2NDYiLAogICJcdUZDNjgiLAogICJcdTA2MjZcdTA2NDkiLAogICJcdUZDNjkiLAogICJcdTA2MjZcdTA2NEEiLAogICJcdUZDNkEiLAogICJcdTA2MjhcdTA2MzEiLAogICJcdUZDNkIiLAogICJcdTA2MjhcdTA2MzIiLAogICJcdUZDNkMiLAogICJcdTA2MjhcdTA2NDUiLAogICJcdUZDNkQiLAogICJcdTA2MjhcdTA2NDYiLAogICJcdUZDNkUiLAogICJcdTA2MjhcdTA2NDkiLAogICJcdUZDNkYiLAogICJcdTA2MjhcdTA2NEEiLAogICJcdUZDNzAiLAogICJcdTA2MkFcdTA2MzEiLAogICJcdUZDNzEiLAogICJcdTA2MkFcdTA2MzIiLAogICJcdUZDNzIiLAogICJcdTA2MkFcdTA2NDUiLAogICJcdUZDNzMiLAogICJcdTA2MkFcdTA2NDYiLAogICJcdUZDNzQiLAogICJcdTA2MkFcdTA2NDkiLAogICJcdUZDNzUiLAogICJcdTA2MkFcdTA2NEEiLAogICJcdUZDNzYiLAogICJcdTA2MkJcdTA2MzEiLAogICJcdUZDNzciLAogICJcdTA2MkJcdTA2MzIiLAogICJcdUZDNzgiLAogICJcdTA2MkJcdTA2NDUiLAogICJcdUZDNzkiLAogICJcdTA2MkJcdTA2NDYiLAogICJcdUZDN0EiLAogICJcdTA2MkJcdTA2NDkiLAogICJcdUZDN0IiLAogICJcdTA2MkJcdTA2NEEiLAogICJcdUZDN0MiLAogICJcdTA2NDFcdTA2NDkiLAogICJcdUZDN0QiLAogICJcdTA2NDFcdTA2NEEiLAogICJcdUZDN0UiLAogICJcdTA2NDJcdTA2NDkiLAogICJcdUZDN0YiLAogICJcdTA2NDJcdTA2NEEiLAogICJcdUZDODAiLAogICJcdTA2NDNcdTA2MjciLAogICJcdUZDODEiLAogICJcdTA2NDNcdTA2NDQiLAogICJcdUZDODIiLAogICJcdTA2NDNcdTA2NDUiLAogICJcdUZDODMiLAogICJcdTA2NDNcdTA2NDkiLAogICJcdUZDODQiLAogICJcdTA2NDNcdTA2NEEiLAogICJcdUZDODUiLAogICJcdTA2NDRcdTA2NDUiLAogICJcdUZDODYiLAogICJcdTA2NDRcdTA2NDkiLAogICJcdUZDODciLAogICJcdTA2NDRcdTA2NEEiLAogICJcdUZDODgiLAogICJcdTA2NDVcdTA2MjciLAogICJcdUZDODkiLAogICJcdTA2NDVcdTA2NDUiLAogICJcdUZDOEEiLAogICJcdTA2NDZcdTA2MzEiLAogICJcdUZDOEIiLAogICJcdTA2NDZcdTA2MzIiLAogICJcdUZDOEMiLAogICJcdTA2NDZcdTA2NDUiLAogICJcdUZDOEQiLAogICJcdTA2NDZcdTA2NDYiLAogICJcdUZDOEUiLAogICJcdTA2NDZcdTA2NDkiLAogICJcdUZDOEYiLAogICJcdTA2NDZcdTA2NEEiLAogICJcdUZDOTAiLAogICJcdTA2NDlcdTA2NzAiLAogICJcdUZDOTEiLAogICJcdTA2NEFcdTA2MzEiLAogICJcdUZDOTIiLAogICJcdTA2NEFcdTA2MzIiLAogICJcdUZDOTMiLAogICJcdTA2NEFcdTA2NDUiLAogICJcdUZDOTQiLAogICJcdTA2NEFcdTA2NDYiLAogICJcdUZDOTUiLAogICJcdTA2NEFcdTA2NDkiLAogICJcdUZDOTYiLAogICJcdTA2NEFcdTA2NEEiLAogICJcdUZDOTciLAogICJcdTA2MjZcdTA2MkMiLAogICJcdUZDOTgiLAogICJcdTA2MjZcdTA2MkQiLAogICJcdUZDOTkiLAogICJcdTA2MjZcdTA2MkUiLAogICJcdUZDOUEiLAogICJcdTA2MjZcdTA2NDUiLAogICJcdUZDOUIiLAogICJcdTA2MjZcdTA2NDciLAogICJcdUZDOUMiLAogICJcdTA2MjhcdTA2MkMiLAogICJcdUZDOUQiLAogICJcdTA2MjhcdTA2MkQiLAogICJcdUZDOUUiLAogICJcdTA2MjhcdTA2MkUiLAogICJcdUZDOUYiLAogICJcdTA2MjhcdTA2NDUiLAogICJcdUZDQTAiLAogICJcdTA2MjhcdTA2NDciLAogICJcdUZDQTEiLAogICJcdTA2MkFcdTA2MkMiLAogICJcdUZDQTIiLAogICJcdTA2MkFcdTA2MkQiLAogICJcdUZDQTMiLAogICJcdTA2MkFcdTA2MkUiLAogICJcdUZDQTQiLAogICJcdTA2MkFcdTA2NDUiLAogICJcdUZDQTUiLAogICJcdTA2MkFcdTA2NDciLAogICJcdUZDQTYiLAogICJcdTA2MkJcdTA2NDUiLAogICJcdUZDQTciLAogICJcdTA2MkNcdTA2MkQiLAogICJcdUZDQTgiLAogICJcdTA2MkNcdTA2NDUiLAogICJcdUZDQTkiLAogICJcdTA2MkRcdTA2MkMiLAogICJcdUZDQUEiLAogICJcdTA2MkRcdTA2NDUiLAogICJcdUZDQUIiLAogICJcdTA2MkVcdTA2MkMiLAogICJcdUZDQUMiLAogICJcdTA2MkVcdTA2NDUiLAogICJcdUZDQUQiLAogICJcdTA2MzNcdTA2MkMiLAogICJcdUZDQUUiLAogICJcdTA2MzNcdTA2MkQiLAogICJcdUZDQUYiLAogICJcdTA2MzNcdTA2MkUiLAogICJcdUZDQjAiLAogICJcdTA2MzNcdTA2NDUiLAogICJcdUZDQjEiLAogICJcdTA2MzVcdTA2MkQiLAogICJcdUZDQjIiLAogICJcdTA2MzVcdTA2MkUiLAogICJcdUZDQjMiLAogICJcdTA2MzVcdTA2NDUiLAogICJcdUZDQjQiLAogICJcdTA2MzZcdTA2MkMiLAogICJcdUZDQjUiLAogICJcdTA2MzZcdTA2MkQiLAogICJcdUZDQjYiLAogICJcdTA2MzZcdTA2MkUiLAogICJcdUZDQjciLAogICJcdTA2MzZcdTA2NDUiLAogICJcdUZDQjgiLAogICJcdTA2MzdcdTA2MkQiLAogICJcdUZDQjkiLAogICJcdTA2MzhcdTA2NDUiLAogICJcdUZDQkEiLAogICJcdTA2MzlcdTA2MkMiLAogICJcdUZDQkIiLAogICJcdTA2MzlcdTA2NDUiLAogICJcdUZDQkMiLAogICJcdTA2M0FcdTA2MkMiLAogICJcdUZDQkQiLAogICJcdTA2M0FcdTA2NDUiLAogICJcdUZDQkUiLAogICJcdTA2NDFcdTA2MkMiLAogICJcdUZDQkYiLAogICJcdTA2NDFcdTA2MkQiLAogICJcdUZDQzAiLAogICJcdTA2NDFcdTA2MkUiLAogICJcdUZDQzEiLAogICJcdTA2NDFcdTA2NDUiLAogICJcdUZDQzIiLAogICJcdTA2NDJcdTA2MkQiLAogICJcdUZDQzMiLAogICJcdTA2NDJcdTA2NDUiLAogICJcdUZDQzQiLAogICJcdTA2NDNcdTA2MkMiLAogICJcdUZDQzUiLAogICJcdTA2NDNcdTA2MkQiLAogICJcdUZDQzYiLAogICJcdTA2NDNcdTA2MkUiLAogICJcdUZDQzciLAogICJcdTA2NDNcdTA2NDQiLAogICJcdUZDQzgiLAogICJcdTA2NDNcdTA2NDUiLAogICJcdUZDQzkiLAogICJcdTA2NDRcdTA2MkMiLAogICJcdUZDQ0EiLAogICJcdTA2NDRcdTA2MkQiLAogICJcdUZDQ0IiLAogICJcdTA2NDRcdTA2MkUiLAogICJcdUZDQ0MiLAogICJcdTA2NDRcdTA2NDUiLAogICJcdUZDQ0QiLAogICJcdTA2NDRcdTA2NDciLAogICJcdUZDQ0UiLAogICJcdTA2NDVcdTA2MkMiLAogICJcdUZDQ0YiLAogICJcdTA2NDVcdTA2MkQiLAogICJcdUZDRDAiLAogICJcdTA2NDVcdTA2MkUiLAogICJcdUZDRDEiLAogICJcdTA2NDVcdTA2NDUiLAogICJcdUZDRDIiLAogICJcdTA2NDZcdTA2MkMiLAogICJcdUZDRDMiLAogICJcdTA2NDZcdTA2MkQiLAogICJcdUZDRDQiLAogICJcdTA2NDZcdTA2MkUiLAogICJcdUZDRDUiLAogICJcdTA2NDZcdTA2NDUiLAogICJcdUZDRDYiLAogICJcdTA2NDZcdTA2NDciLAogICJcdUZDRDciLAogICJcdTA2NDdcdTA2MkMiLAogICJcdUZDRDgiLAogICJcdTA2NDdcdTA2NDUiLAogICJcdUZDRDkiLAogICJcdTA2NDdcdTA2NzAiLAogICJcdUZDREEiLAogICJcdTA2NEFcdTA2MkMiLAogICJcdUZDREIiLAogICJcdTA2NEFcdTA2MkQiLAogICJcdUZDREMiLAogICJcdTA2NEFcdTA2MkUiLAogICJcdUZDREQiLAogICJcdTA2NEFcdTA2NDUiLAogICJcdUZDREUiLAogICJcdTA2NEFcdTA2NDciLAogICJcdUZDREYiLAogICJcdTA2MjZcdTA2NDUiLAogICJcdUZDRTAiLAogICJcdTA2MjZcdTA2NDciLAogICJcdUZDRTEiLAogICJcdTA2MjhcdTA2NDUiLAogICJcdUZDRTIiLAogICJcdTA2MjhcdTA2NDciLAogICJcdUZDRTMiLAogICJcdTA2MkFcdTA2NDUiLAogICJcdUZDRTQiLAogICJcdTA2MkFcdTA2NDciLAogICJcdUZDRTUiLAogICJcdTA2MkJcdTA2NDUiLAogICJcdUZDRTYiLAogICJcdTA2MkJcdTA2NDciLAogICJcdUZDRTciLAogICJcdTA2MzNcdTA2NDUiLAogICJcdUZDRTgiLAogICJcdTA2MzNcdTA2NDciLAogICJcdUZDRTkiLAogICJcdTA2MzRcdTA2NDUiLAogICJcdUZDRUEiLAogICJcdTA2MzRcdTA2NDciLAogICJcdUZDRUIiLAogICJcdTA2NDNcdTA2NDQiLAogICJcdUZDRUMiLAogICJcdTA2NDNcdTA2NDUiLAogICJcdUZDRUQiLAogICJcdTA2NDRcdTA2NDUiLAogICJcdUZDRUUiLAogICJcdTA2NDZcdTA2NDUiLAogICJcdUZDRUYiLAogICJcdTA2NDZcdTA2NDciLAogICJcdUZDRjAiLAogICJcdTA2NEFcdTA2NDUiLAogICJcdUZDRjEiLAogICJcdTA2NEFcdTA2NDciLAogICJcdUZDRjIiLAogICJcdTA2NDBcdTA2NEVcdTA2NTEiLAogICJcdUZDRjMiLAogICJcdTA2NDBcdTA2NEZcdTA2NTEiLAogICJcdUZDRjQiLAogICJcdTA2NDBcdTA2NTBcdTA2NTEiLAogICJcdUZDRjUiLAogICJcdTA2MzdcdTA2NDkiLAogICJcdUZDRjYiLAogICJcdTA2MzdcdTA2NEEiLAogICJcdUZDRjciLAogICJcdTA2MzlcdTA2NDkiLAogICJcdUZDRjgiLAogICJcdTA2MzlcdTA2NEEiLAogICJcdUZDRjkiLAogICJcdTA2M0FcdTA2NDkiLAogICJcdUZDRkEiLAogICJcdTA2M0FcdTA2NEEiLAogICJcdUZDRkIiLAogICJcdTA2MzNcdTA2NDkiLAogICJcdUZDRkMiLAogICJcdTA2MzNcdTA2NEEiLAogICJcdUZDRkQiLAogICJcdTA2MzRcdTA2NDkiLAogICJcdUZDRkUiLAogICJcdTA2MzRcdTA2NEEiLAogICJcdUZDRkYiLAogICJcdTA2MkRcdTA2NDkiLAogICJcdUZEMDAiLAogICJcdTA2MkRcdTA2NEEiLAogICJcdUZEMDEiLAogICJcdTA2MkNcdTA2NDkiLAogICJcdUZEMDIiLAogICJcdTA2MkNcdTA2NEEiLAogICJcdUZEMDMiLAogICJcdTA2MkVcdTA2NDkiLAogICJcdUZEMDQiLAogICJcdTA2MkVcdTA2NEEiLAogICJcdUZEMDUiLAogICJcdTA2MzVcdTA2NDkiLAogICJcdUZEMDYiLAogICJcdTA2MzVcdTA2NEEiLAogICJcdUZEMDciLAogICJcdTA2MzZcdTA2NDkiLAogICJcdUZEMDgiLAogICJcdTA2MzZcdTA2NEEiLAogICJcdUZEMDkiLAogICJcdTA2MzRcdTA2MkMiLAogICJcdUZEMEEiLAogICJcdTA2MzRcdTA2MkQiLAogICJcdUZEMEIiLAogICJcdTA2MzRcdTA2MkUiLAogICJcdUZEMEMiLAogICJcdTA2MzRcdTA2NDUiLAogICJcdUZEMEQiLAogICJcdTA2MzRcdTA2MzEiLAogICJcdUZEMEUiLAogICJcdTA2MzNcdTA2MzEiLAogICJcdUZEMEYiLAogICJcdTA2MzVcdTA2MzEiLAogICJcdUZEMTAiLAogICJcdTA2MzZcdTA2MzEiLAogICJcdUZEMTEiLAogICJcdTA2MzdcdTA2NDkiLAogICJcdUZEMTIiLAogICJcdTA2MzdcdTA2NEEiLAogICJcdUZEMTMiLAogICJcdTA2MzlcdTA2NDkiLAogICJcdUZEMTQiLAogICJcdTA2MzlcdTA2NEEiLAogICJcdUZEMTUiLAogICJcdTA2M0FcdTA2NDkiLAogICJcdUZEMTYiLAogICJcdTA2M0FcdTA2NEEiLAogICJcdUZEMTciLAogICJcdTA2MzNcdTA2NDkiLAogICJcdUZEMTgiLAogICJcdTA2MzNcdTA2NEEiLAogICJcdUZEMTkiLAogICJcdTA2MzRcdTA2NDkiLAogICJcdUZEMUEiLAogICJcdTA2MzRcdTA2NEEiLAogICJcdUZEMUIiLAogICJcdTA2MkRcdTA2NDkiLAogICJcdUZEMUMiLAogICJcdTA2MkRcdTA2NEEiLAogICJcdUZEMUQiLAogICJcdTA2MkNcdTA2NDkiLAogICJcdUZEMUUiLAogICJcdTA2MkNcdTA2NEEiLAogICJcdUZEMUYiLAogICJcdTA2MkVcdTA2NDkiLAogICJcdUZEMjAiLAogICJcdTA2MkVcdTA2NEEiLAogICJcdUZEMjEiLAogICJcdTA2MzVcdTA2NDkiLAogICJcdUZEMjIiLAogICJcdTA2MzVcdTA2NEEiLAogICJcdUZEMjMiLAogICJcdTA2MzZcdTA2NDkiLAogICJcdUZEMjQiLAogICJcdTA2MzZcdTA2NEEiLAogICJcdUZEMjUiLAogICJcdTA2MzRcdTA2MkMiLAogICJcdUZEMjYiLAogICJcdTA2MzRcdTA2MkQiLAogICJcdUZEMjciLAogICJcdTA2MzRcdTA2MkUiLAogICJcdUZEMjgiLAogICJcdTA2MzRcdTA2NDUiLAogICJcdUZEMjkiLAogICJcdTA2MzRcdTA2MzEiLAogICJcdUZEMkEiLAogICJcdTA2MzNcdTA2MzEiLAogICJcdUZEMkIiLAogICJcdTA2MzVcdTA2MzEiLAogICJcdUZEMkMiLAogICJcdTA2MzZcdTA2MzEiLAogICJcdUZEMkQiLAogICJcdTA2MzRcdTA2MkMiLAogICJcdUZEMkUiLAogICJcdTA2MzRcdTA2MkQiLAogICJcdUZEMkYiLAogICJcdTA2MzRcdTA2MkUiLAogICJcdUZEMzAiLAogICJcdTA2MzRcdTA2NDUiLAogICJcdUZEMzEiLAogICJcdTA2MzNcdTA2NDciLAogICJcdUZEMzIiLAogICJcdTA2MzRcdTA2NDciLAogICJcdUZEMzMiLAogICJcdTA2MzdcdTA2NDUiLAogICJcdUZEMzQiLAogICJcdTA2MzNcdTA2MkMiLAogICJcdUZEMzUiLAogICJcdTA2MzNcdTA2MkQiLAogICJcdUZEMzYiLAogICJcdTA2MzNcdTA2MkUiLAogICJcdUZEMzciLAogICJcdTA2MzRcdTA2MkMiLAogICJcdUZEMzgiLAogICJcdTA2MzRcdTA2MkQiLAogICJcdUZEMzkiLAogICJcdTA2MzRcdTA2MkUiLAogICJcdUZEM0EiLAogICJcdTA2MzdcdTA2NDUiLAogICJcdUZEM0IiLAogICJcdTA2MzhcdTA2NDUiLAogICJcdUZEM0MiLAogICJcdTA2MjdcdTA2NEIiLAogICJcdUZEM0QiLAogICJcdTA2MjdcdTA2NEIiLAogICJcdUZENTAiLAogICJcdTA2MkFcdTA2MkNcdTA2NDUiLAogICJcdUZENTEiLAogICJcdTA2MkFcdTA2MkRcdTA2MkMiLAogICJcdUZENTIiLAogICJcdTA2MkFcdTA2MkRcdTA2MkMiLAogICJcdUZENTMiLAogICJcdTA2MkFcdTA2MkRcdTA2NDUiLAogICJcdUZENTQiLAogICJcdTA2MkFcdTA2MkVcdTA2NDUiLAogICJcdUZENTUiLAogICJcdTA2MkFcdTA2NDVcdTA2MkMiLAogICJcdUZENTYiLAogICJcdTA2MkFcdTA2NDVcdTA2MkQiLAogICJcdUZENTciLAogICJcdTA2MkFcdTA2NDVcdTA2MkUiLAogICJcdUZENTgiLAogICJcdTA2MkNcdTA2NDVcdTA2MkQiLAogICJcdUZENTkiLAogICJcdTA2MkNcdTA2NDVcdTA2MkQiLAogICJcdUZENUEiLAogICJcdTA2MkRcdTA2NDVcdTA2NEEiLAogICJcdUZENUIiLAogICJcdTA2MkRcdTA2NDVcdTA2NDkiLAogICJcdUZENUMiLAogICJcdTA2MzNcdTA2MkRcdTA2MkMiLAogICJcdUZENUQiLAogICJcdTA2MzNcdTA2MkNcdTA2MkQiLAogICJcdUZENUUiLAogICJcdTA2MzNcdTA2MkNcdTA2NDkiLAogICJcdUZENUYiLAogICJcdTA2MzNcdTA2NDVcdTA2MkQiLAogICJcdUZENjAiLAogICJcdTA2MzNcdTA2NDVcdTA2MkQiLAogICJcdUZENjEiLAogICJcdTA2MzNcdTA2NDVcdTA2MkMiLAogICJcdUZENjIiLAogICJcdTA2MzNcdTA2NDVcdTA2NDUiLAogICJcdUZENjMiLAogICJcdTA2MzNcdTA2NDVcdTA2NDUiLAogICJcdUZENjQiLAogICJcdTA2MzVcdTA2MkRcdTA2MkQiLAogICJcdUZENjUiLAogICJcdTA2MzVcdTA2MkRcdTA2MkQiLAogICJcdUZENjYiLAogICJcdTA2MzVcdTA2NDVcdTA2NDUiLAogICJcdUZENjciLAogICJcdTA2MzRcdTA2MkRcdTA2NDUiLAogICJcdUZENjgiLAogICJcdTA2MzRcdTA2MkRcdTA2NDUiLAogICJcdUZENjkiLAogICJcdTA2MzRcdTA2MkNcdTA2NEEiLAogICJcdUZENkEiLAogICJcdTA2MzRcdTA2NDVcdTA2MkUiLAogICJcdUZENkIiLAogICJcdTA2MzRcdTA2NDVcdTA2MkUiLAogICJcdUZENkMiLAogICJcdTA2MzRcdTA2NDVcdTA2NDUiLAogICJcdUZENkQiLAogICJcdTA2MzRcdTA2NDVcdTA2NDUiLAogICJcdUZENkUiLAogICJcdTA2MzZcdTA2MkRcdTA2NDkiLAogICJcdUZENkYiLAogICJcdTA2MzZcdTA2MkVcdTA2NDUiLAogICJcdUZENzAiLAogICJcdTA2MzZcdTA2MkVcdTA2NDUiLAogICJcdUZENzEiLAogICJcdTA2MzdcdTA2NDVcdTA2MkQiLAogICJcdUZENzIiLAogICJcdTA2MzdcdTA2NDVcdTA2MkQiLAogICJcdUZENzMiLAogICJcdTA2MzdcdTA2NDVcdTA2NDUiLAogICJcdUZENzQiLAogICJcdTA2MzdcdTA2NDVcdTA2NEEiLAogICJcdUZENzUiLAogICJcdTA2MzlcdTA2MkNcdTA2NDUiLAogICJcdUZENzYiLAogICJcdTA2MzlcdTA2NDVcdTA2NDUiLAogICJcdUZENzciLAogICJcdTA2MzlcdTA2NDVcdTA2NDUiLAogICJcdUZENzgiLAogICJcdTA2MzlcdTA2NDVcdTA2NDkiLAogICJcdUZENzkiLAogICJcdTA2M0FcdTA2NDVcdTA2NDUiLAogICJcdUZEN0EiLAogICJcdTA2M0FcdTA2NDVcdTA2NEEiLAogICJcdUZEN0IiLAogICJcdTA2M0FcdTA2NDVcdTA2NDkiLAogICJcdUZEN0MiLAogICJcdTA2NDFcdTA2MkVcdTA2NDUiLAogICJcdUZEN0QiLAogICJcdTA2NDFcdTA2MkVcdTA2NDUiLAogICJcdUZEN0UiLAogICJcdTA2NDJcdTA2NDVcdTA2MkQiLAogICJcdUZEN0YiLAogICJcdTA2NDJcdTA2NDVcdTA2NDUiLAogICJcdUZEODAiLAogICJcdTA2NDRcdTA2MkRcdTA2NDUiLAogICJcdUZEODEiLAogICJcdTA2NDRcdTA2MkRcdTA2NEEiLAogICJcdUZEODIiLAogICJcdTA2NDRcdTA2MkRcdTA2NDkiLAogICJcdUZEODMiLAogICJcdTA2NDRcdTA2MkNcdTA2MkMiLAogICJcdUZEODQiLAogICJcdTA2NDRcdTA2MkNcdTA2MkMiLAogICJcdUZEODUiLAogICJcdTA2NDRcdTA2MkVcdTA2NDUiLAogICJcdUZEODYiLAogICJcdTA2NDRcdTA2MkVcdTA2NDUiLAogICJcdUZEODciLAogICJcdTA2NDRcdTA2NDVcdTA2MkQiLAogICJcdUZEODgiLAogICJcdTA2NDRcdTA2NDVcdTA2MkQiLAogICJcdUZEODkiLAogICJcdTA2NDVcdTA2MkRcdTA2MkMiLAogICJcdUZEOEEiLAogICJcdTA2NDVcdTA2MkRcdTA2NDUiLAogICJcdUZEOEIiLAogICJcdTA2NDVcdTA2MkRcdTA2NEEiLAogICJcdUZEOEMiLAogICJcdTA2NDVcdTA2MkNcdTA2MkQiLAogICJcdUZEOEQiLAogICJcdTA2NDVcdTA2MkNcdTA2NDUiLAogICJcdUZEOEUiLAogICJcdTA2NDVcdTA2MkVcdTA2MkMiLAogICJcdUZEOEYiLAogICJcdTA2NDVcdTA2MkVcdTA2NDUiLAogICJcdUZEOTIiLAogICJcdTA2NDVcdTA2MkNcdTA2MkUiLAogICJcdUZEOTMiLAogICJcdTA2NDdcdTA2NDVcdTA2MkMiLAogICJcdUZEOTQiLAogICJcdTA2NDdcdTA2NDVcdTA2NDUiLAogICJcdUZEOTUiLAogICJcdTA2NDZcdTA2MkRcdTA2NDUiLAogICJcdUZEOTYiLAogICJcdTA2NDZcdTA2MkRcdTA2NDkiLAogICJcdUZEOTciLAogICJcdTA2NDZcdTA2MkNcdTA2NDUiLAogICJcdUZEOT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A2NEEiLAogICJcdUZEQzciLAogICJcdTA2NDZcdTA2MkNcdTA2NEEiLAogICJcdUZFNDkiLAogICJcdTIwM0UiLAogICJcdUZFNEEiLAogICJcdTIwM0UiLAogICJcdUZFNEIiLAogICJcdTIwM0UiLAogICJcdUZFNEMiLAogICJcdTIwM0UiLAogICJcdUZFNEQiLAogICJcdTAwNUYiLAogICJcdUZFNEUiLAogICJcdTAwNUYiLAogICJcdUZFNEYiLAogICJcdTAwNUYiLAogICJcdUZFODAiLAogICJcdTA2MjEiLAogICJcdUZFODEiLAogICJcdTA2MjIiLAogICJcdUZFODIiLAogICJcdTA2MjIiLAogICJcdUZFODMiLAogICJcdTA2MjMiLAogICJcdUZFODQiLAogICJcdTA2MjMiLAogICJcdUZFODUiLAogICJcdTA2MjQiLAogICJcdUZFODYiLAogICJcdTA2MjQiLAogICJcdUZFODciLAogICJcdTA2MjUiLAogICJcdUZFODgiLAogICJcdTA2MjUiLAogICJcdUZFODkiLAogICJcdTA2MjYiLAogICJcdUZFOEEiLAogICJcdTA2MjYiLAogICJcdUZFOEIiLAogICJcdTA2MjYiLAogICJcdUZFOEMiLAogICJcdTA2MjYiLAogICJcdUZFOEQiLAogICJcdTA2MjciLAogICJcdUZFOEUiLAogICJcdTA2MjciLAogICJcdUZFOEYiLAogICJcdTA2MjgiLAogICJcdUZFOTAiLAogICJcdTA2MjgiLAogICJcdUZFOTEiLAogICJcdTA2MjgiLAogICJcdUZFOTIiLAogICJcdTA2MjgiLAogICJcdUZFOTMiLAogICJcdTA2MjkiLAogICJcdUZFOTQiLAogICJcdTA2MjkiLAogICJcdUZFOTUiLAogICJcdTA2MkEiLAogICJcdUZFOTYiLAogICJcdTA2MkEiLAogICJcdUZFOTciLAogICJcdTA2MkEiLAogICJcdUZFOTgiLAogICJcdTA2MkEiLAogICJcdUZFOTkiLAogICJcdTA2MkIiLAogICJcdUZFOUEiLAogICJcdTA2MkIiLAogICJcdUZFOUIiLAogICJcdTA2MkIiLAogICJcdUZFOUMiLAogICJcdTA2MkIiLAogICJcdUZFOUQiLAogICJcdTA2MkMiLAogICJcdUZFOUUiLAogICJcdTA2MkMiLAogICJcdUZFOUYiLAogICJcdTA2MkMiLAogICJcdUZFQTAiLAogICJcdTA2MkMiLAogICJcdUZFQTEiLAogICJcdTA2MkQiLAogICJcdUZFQTIiLAogICJcdTA2MkQiLAogICJcdUZFQTMiLAogICJcdTA2MkQiLAogICJcdUZFQTQiLAogICJcdTA2MkQiLAogICJcdUZFQTUiLAogICJcdTA2MkUiLAogICJcdUZFQTYiLAogICJcdTA2MkUiLAogICJcdUZFQTciLAogICJcdTA2MkUiLAogICJcdUZFQTgiLAogICJcdTA2MkUiLAogICJcdUZFQTkiLAogICJcdTA2MkYiLAogICJcdUZFQUEiLAogICJcdTA2MkYiLAogICJcdUZFQUIiLAogICJcdTA2MzAiLAogICJcdUZFQUMiLAogICJcdTA2MzAiLAogICJcdUZFQUQiLAogICJcdTA2MzEiLAogICJcdUZFQUUiLAogICJcdTA2MzEiLAogICJcdUZFQUYiLAogICJcdTA2MzIiLAogICJcdUZFQjAiLAogICJcdTA2MzIiLAogICJcdUZFQjEiLAogICJcdTA2MzMiLAogICJcdUZFQjIiLAogICJcdTA2MzMiLAogICJcdUZFQjMiLAogICJcdTA2MzMiLAogICJcdUZFQjQiLAogICJcdTA2MzMiLAogICJcdUZFQjUiLAogICJcdTA2MzQiLAogICJcdUZFQjYiLAogICJcdTA2MzQiLAogICJcdUZFQjciLAogICJcdTA2MzQiLAogICJcdUZFQjgiLAogICJcdTA2MzQiLAogICJcdUZFQjkiLAogICJcdTA2MzUiLAogICJcdUZFQkEiLAogICJcdTA2MzUiLAogICJcdUZFQkIiLAogICJcdTA2MzUiLAogICJcdUZFQkMiLAogICJcdTA2MzUiLAogICJcdUZFQkQiLAogICJcdTA2MzYiLAogICJcdUZFQkUiLAogICJcdTA2MzYiLAogICJcdUZFQkYiLAogICJcdTA2MzYiLAogICJcdUZFQzAiLAogICJcdTA2MzYiLAogICJcdUZFQzEiLAogICJcdTA2MzciLAogICJcdUZFQzIiLAogICJcdTA2MzciLAogICJcdUZFQzMiLAogICJcdTA2MzciLAogICJcdUZFQzQiLAogICJcdTA2MzciLAogICJcdUZFQzUiLAogICJcdTA2MzgiLAogICJcdUZFQzYiLAogICJcdTA2MzgiLAogICJcdUZFQzciLAogICJcdTA2MzgiLAogICJcdUZFQzgiLAogICJcdTA2MzgiLAogICJcdUZFQzkiLAogICJcdTA2MzkiLAogICJcdUZFQ0EiLAogICJcdTA2MzkiLAogICJcdUZFQ0IiLAogICJcdTA2MzkiLAogICJcdUZFQ0MiLAogICJcdTA2MzkiLAogICJcdUZFQ0QiLAogICJcdTA2M0EiLAogICJcdUZFQ0UiLAogICJcdTA2M0EiLAogICJcdUZFQ0YiLAogICJcdTA2M0EiLAogICJcdUZFRDAiLAogICJcdTA2M0EiLAogICJcdUZFRDEiLAogICJcdTA2NDEiLAogICJcdUZFRDIiLAogICJcdTA2NDEiLAogICJcdUZFRDMiLAogICJcdTA2NDEiLAogICJcdUZFRDQiLAogICJcdTA2NDEiLAogICJcdUZFRDUiLAogICJcdTA2NDIiLAogICJcdUZFRDYiLAogICJcdTA2NDIiLAogICJcdUZFRDciLAogICJcdTA2NDIiLAogICJcdUZFRDgiLAogICJcdTA2NDIiLAogICJcdUZFRDkiLAogICJcdTA2NDMiLAogICJcdUZFREEiLAogICJcdTA2NDMiLAogICJcdUZFREIiLAogICJcdTA2NDMiLAogICJcdUZFREMiLAogICJcdTA2NDMiLAogICJcdUZFREQiLAogICJcdTA2NDQiLAogICJcdUZFREUiLAogICJcdTA2NDQiLAogICJcdUZFREYiLAogICJcdTA2NDQiLAogICJcdUZFRTAiLAogICJcdTA2NDQiLAogICJcdUZFRTEiLAogICJcdTA2NDUiLAogICJcdUZFRTIiLAogICJcdTA2NDUiLAogICJcdUZFRTMiLAogICJcdTA2NDUiLAogICJcdUZFRTQiLAogICJcdTA2NDUiLAogICJcdUZFRTUiLAogICJcdTA2NDYiLAogICJcdUZFRTYiLAogICJcdTA2NDYiLAogICJcdUZFRTciLAogICJcdTA2NDYiLAogICJcdUZFRTgiLAogICJcdTA2NDYiLAogICJcdUZFRTkiLAogICJcdTA2NDciLAogICJcdUZFRUEiLAogICJcdTA2NDciLAogICJcdUZFRUIiLAogICJcdTA2NDciLAogICJcdUZFRUMiLAogICJcdTA2NDciLAogICJcdUZFRUQiLAogICJcdTA2NDgiLAogICJcdUZFRUUiLAogICJcdTA2NDgiLAogICJcdUZFRUYiLAogICJcdTA2NDkiLAogICJcdUZFRjAiLAogICJcdTA2NDkiLAogICJcdUZFRjEiLAogICJcdTA2NEEiLAogICJcdUZFRjIiLAogICJcdTA2NEEiLAogICJcdUZFRjMiLAogICJcdTA2NEEiLAogICJcdUZFRjQiLAogICJcdTA2NEEiLAogICJcdUZFRjUiLAogICJcdTA2NDRcdTA2MjIiLAogICJcdUZFRjYiLAogICJcdTA2NDRcdTA2MjIiLAogICJcdUZFRjciLAogICJcdTA2NDRcdTA2MjMiLAogICJcdUZFRjgiLAogICJcdTA2NDRcdTA2MjMiLAogICJcdUZFRjkiLAogICJcdTA2NDRcdTA2MjUiLAogICJcdUZFRkEiLAogICJcdTA2NDRcdTA2MjUiLAogICJcdUZFRkIiLAogICJcdTA2NDRcdTA2MjciLAogICJcdUZFRkMiLAogICJcdTA2NDRcdTA2MjciCiBdOwp9KTsKZnVuY3Rpb24gcmV2ZXJzZUlmUnRsKGNoYXJzKSB7CiBjb25zdCBjaGFyc0xlbmd0aCA9IGNoYXJzLmxlbmd0aDsKIGlmIChjaGFyc0xlbmd0aCA8PSAxIHx8ICFpc1JUTFJhbmdlRm9yKGNoYXJzLmNoYXJDb2RlQXQoMCkpKSB7CiAgcmV0dXJuIGNoYXJzOwogfQogY29uc3QgYnVmID0gW107CiBmb3IgKGxldCBpaSA9IGNoYXJzTGVuZ3RoIC0gMTsgaWkgPj0gMDsgaWktLSkgewogIGJ1Zi5wdXNoKGNoYXJzW2lpX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cGluZygpIHsKICAgIGNvbnN0IGNmZiA9IHRoaXMuY2ZmOwogICAgY29uc3QgcHJvcGVydGllcyA9IHRoaXMucHJvcGVydGllczsKICAgIGNvbnN0IHsKICAgICAgY2lkVG9HaWRNYXAsCiAgICAgIGNNYXAKICAgIH0gPSBwcm9wZXJ0aWVzOwogICAgY29uc3QgY2hhcnNldHMgPSBjZmYuY2hhcnNldC5jaGFyc2V0OwogICAgbGV0IGNoYXJDb2RlVG9HbHlwaElkOwogICAgbGV0IGdseXBoSWQ7CiAgICBpZiAocHJvcGVydGllcy5jb21wb3NpdGUpIHsKICAgICAgbGV0IGludkNpZFRvR2lkTWFwOwogICAgICBpZiAoY2lkVG9HaWRNYXAgJiYgY2lkVG9HaWRNYXAubGVuZ3RoID4gMCkgewogICAgICAgIGludkNpZFRvR2lkTWFwID0gT2JqZWN0LmNyZWF0ZShudWxsKTsKICAgICAgICBmb3IgKGxldCBpID0gMCwgaWkgPSBjaWRUb0dpZE1hcC5sZW5ndGg7IGkgPCBpaTsgaSsrKSB7CiAgICAgICAgICBjb25zdCBnaWQgPSBjaWRUb0dpZE1hcFtpXTsKICAgICAgICAgIGlmIChnaWQgIT09IHVuZGVmaW5lZCkgewogICAgICAgICAgICBpbnZDaWRUb0dpZE1hcFtnaWRdID0gaTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0KICAgICAgY2hhckNvZGVUb0dseXBoSWQgPSBPYmplY3QuY3JlYXRlKG51bGwpOwogICAgICBsZXQgY2hhckNvZGU7CiAgICAgIGlmIChjZmYuaXNDSURGb250KSB7CiAgICAgICAgZm9yIChnbHlwaElkID0gMDsgZ2x5cGhJZCA8IGNoYXJzZXRzLmxlbmd0aDsgZ2x5cGhJZCsrKSB7CiAgICAgICAgICBjb25zdCBjaWQgPSBjaGFyc2V0c1tnbHlwaElkXTsKICAgICAgICAgIGNoYXJDb2RlID0gY01hcC5jaGFyQ29kZU9mKGNpZCk7CiAgICAgICAgICBpZiAoaW52Q2lkV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ogIGZ1bmN0aW9uIHF1YWRyYXRpY0N1cnZlVG8oeGEsIHlhLCB4LCB5KSB7CiAgICBjbWRzLnB1c2goewogICAgICBjbWQ6ICJxdWFkcmF0aWNDdXJ2ZVRvIiwKICAgICAgYXJnczogW3hhLCB5YSwgeCwgeV0KICAgIH0pOwogIH0KICBsZXQgaSA9IDA7CiAgY29uc3QgbnVtYmVyT2ZDb250b3VycyA9IGdldEludDE2KGNvZGUsIGkpOwogIGxldCBmbGFnczsKICBsZXQgeCA9IDAsCiAgICB5ID0gMDsKICBpICs9IDEwOwogIGlmIChudW1iZXJPZkNvbnRvdXJzIDwgMCkgewogICAgZG8gewogICAgICBmbGFncyA9IGdldFVpbnQxNihjb2RlLCBpKTsKICAgICAgY29uc3QgZ2x5cGhJbmRleCA9IGdldFVpbnQxNihjb2RlLCBpICsgMik7CiAgICAgIGkgKz0gNDsKICAgICAgbGV0IGFyZzEsIGFyZzI7CiAgICAgIGlmIChmbGFncyAmIDB4MDEpIHsKICAgICAgICBpZiAoZmxhZ3MgJiAweDAyKSB7CiAgICAgICAgICBhcmcxID0gZ2V0SW50MTYoY29kZSwgaSk7CiAgICAgICAgICBhcmcyID0gZ2V0SW50MTYoY29kZSwgaSArIDIpOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBhcmcxID0gZ2V0VWludDE2KGNvZGUsIGkpOwogICAgICAgICAgYXJnMiA9IGdldFVpbnQxNihjb2RlLCBpICsgMik7CiAgICAgICAgfQogICAgICAgIGkgKz0gNDsKICAgICAgfSBlbHNlIHsKICAgICAgICBpZiAoZmxhZ3MgJiAweDAyKSB7CiAgICAgICAgICBhcmcxID0gZ2V0SW50OChjb2RlLCBpKyspOwogICAgICAgICAgYXJnMiA9IGdldEludDgoY29kZSwgaSsrKTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgYXJnMSA9IGNvZGVbaSsrXTsKICAgICAgICAgIGFyZzIgPSBjb2RlW2krK107CiAgICAgICAgfQogICAgICB9CiAgICAgIGlmIChmbGFncyAmIDB4MDIpIHsKICAgICAgICB4ID0gYXJnMTsKICAgICAgICB5ID0gYXJnMjsKICAgICAgfSBlbHNlIHsKICAgICAgICB4ID0gMDsKICAgICAgICB5ID0gMDsKICAgICAgfQogICAgICBsZXQgc2NhbGVYID0gMSwKICAgICAgICBzY2FsZVkgPSAxLAogICAgICAgIHNjYWxlMDEgPSAwLAogICAgICAgIHNjYWxlMTAgPSAwOwogICAgICBpZiAoZmxhZ3MgJiAweDA4KSB7CiAgICAgICAgc2NhbGVYID0gc2NhbGVZID0gZ2V0RmxvYXQyMTQoY29kZSwgaSk7CiAgICAgICAgaSArPSAyOwogICAgICB9IGVsc2UgaWYgKGZsYWdzICYgMHg0MCkgewogICAgICAgIHNjYWxlWCA9IGdldEZsb2F0MjE0KGNvZGUsIGkpOwogICAgICAgIHNjYWxlWSA9IGdldEZsb2F0MjE0KGNvZGUsIGkgKyAyKTsKICAgICAgICBpICs9IDQ7CiAgICAgIH0gZWxzZSBpZiAoZmxhZ3MgJiAweDgwKSB7CiAgICAgICAgc2NhbGVYID0gZ2V0RmxvYXQyMTQoY29kZSwgaSk7CiAgICAgICAgc2NhbGUwMSA9IGdldEZsb2F0MjE0KGNvZGUsIGkgKyAyKTsKICAgICAgICBzY2FsZTEwID0gZ2V0RmxvYXQyMTQoY29kZSwgaSArIDQpOwogICAgICAgIHNjYWxlWSA9IGdldEZsb2F0MjE0KGNvZGUsIGkgKyA2KTsKICAgICAgICBpICs9IDg7CiAgICAgIH0KICAgICAgY29uc3Qgc3ViZ2x5cGggPSBmb250LmdseXBoc1tnbHlwaEluZGV4XTsKICAgICAgaWYgKHN1YmdseXBoKSB7CiAgICAgICAgY21kcy5wdXNoKHsKICAgICAgICAgIGNtZDogInNhdmUiCiAgICAgICAgfSwgewogICAgICAgICAgY21kOiAidHJhbnNmb3JtIiwKICAgICAgICAgIGFyZ3M6IFtzY2FsZVgsIHNjYWxlMDEsIHNjYWxlMTAsIHNjYWxlWSwgeCwgeV0KICAgICAgICB9KTsKICAgICAgICBpZiAoIShmbGFncyAmIDB4MDIpKSB7fQogICAgICAgIGNvbXBpbGVHbHlmKHN1YmdseXBoLCBjbWRzLCBmb250KTsKICAgICAgICBjbWRzLnB1c2goewogICAgICAgICAgY21kOiAicmVzdG9yZSIKICAgICAgICB9KTsKICAgICAgfQogICAgfSB3aGlsZSAoZmxhZ3MgJiAweDIwKTsKICB9IGVsc2UgewogICAgY29uc3QgZW5kUHRzT2ZDb250b3VycyA9IFtdOwogICAgbGV0IGosIGpqOwogICAgZm9yIChqID0gMDsgaiA8IG51bWJlck9mQ29udG91cnM7IGorKykgewogICAgICBlbmRQdHNPZkNvbnRvdXJzLnB1c2goZ2V0VWludDE2KGNvZGUsIGkpKTsKICAgICAgaSArPSAyOwogICAgfQogICAgY29uc3QgaW5zdHJ1Y3Rpb25MZW5ndGggPSBnZXRVaW50MTYoY29kZSwgaSk7CiAgICBpICs9IDIgKyBpbnN0cnVjdGlvbkxlbmd0aDsKICAgIGNvbnN0IG51bWJlck9mUG9pbnRzID0gZW5kUHRzT2ZDb250b3Vycy5hdCgtMSkgKyAxOwogICAgY29uc3QgcG9pbnRzID0gW107CiAgICB3aGlsZSAocG9pbnRzLmxlbmd0aCA8IG51bWJlck9mUG9pbnRzKSB7CiAgICAgIGZsYWdzID0gY29kZVtpKytdOwogICAgICBsZXQgcmVwZWF0ID0gMTsKICAgICAgaWYgKGZsYWdzICYgMHgwOCkgewogICAgICAgIHJlcGVhdCArPSBjb2RlW2krK107CiAgICAgIH0KICAgICAgd2hpbGUgKHJlcGVhdC0tID4gMCkgewogICAgICAgIHBvaW50cy5wdXNoKHsKICAgICAgICAgIGZsYWdzCiAgICAgICAgfSk7CiAgICAgIH0KICAgIH0KICAgIGZvciAoaiA9IDA7IGogPCBudW1iZXJPZlBvaW50czsgaisrKSB7CiAgICAgIHN3aXRjaCAocG9pbnRzW2pdLmZsYWdzICYgMHgxMikgewogICAgICAgIGNhc2UgMHgwMDoKICAgICAgICAgIHggKz0gZ2V0SW50MTYoY29kZSwgaSk7CiAgICAgICAgICBpICs9IDI7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIDB4MDI6CiAgICAgICAgICB4IC09IGNvZGVbaSsrXTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMHgxMjoKICAgICAgICAgIHggKz0gY29kZVtpKytdOwogICAgICAgICAgYnJlYWs7CiAgICAgIH0KICAgICAgcG9pbnRzW2pdLnggPSB4OwogICAgfQogICAgZm9yIChqID0gMDsgaiA8IG51bWJlck9mUG9pbnRzOyBqKyspIHsKICAgICAgc3dpdGNoIChwb2ludHNbal0uZmxhZ3MgJiAweDI0KSB7CiAgICAgICAgY2FzZSAweDAwOgogICAgICAgICAgeSArPSBnZXRJbnQxNihjb2RlLCBpKTsKICAgICAgICAgIGkgKz0gMjsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMHgwNDoKICAgICAgICAgIHkgLT0gY29kZVtpKytdOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAweDI0OgogICAgICAgICAgeSArPSBjb2RlW2krK107CiAgICAgICAgICBicmVhazsKICAgICAgfQogICAgICBwb2ludHNbal0ueSA9IHk7CiAgICB9CiAgICBsZXQgc3RhcnRQb2ludCA9IDA7CiAgICBmb3IgKGkgPSAwOyBpIDwgbnVtYmVyT2ZDb250b3VyczsgaSsrKSB7CiAgICAgIGNvbnN0IGVuZFBvaW50ID0gZW5kUHRzT2ZDb250b3Vyc1tpXTsKICAgICAgY29uc3QgY29udG91ciA9IHBvaW50cy5zbGljZShzdGFydFBvaW50LCBlbmRQb2ludCArIDEpOwogICAgICBpZiAoY29udG91clswXS5mbGFncyAmIDEpIHsKICAgICAgICBjb250b3VyLnB1c2goY29udG91clswXSk7CiAgICAgIH0gZWxzZSBpZiAoY29udG91ci5hdCgtMSkuZmxhZ3MgJiAxKSB7CiAgICAgICAgY29udG91ci51bnNoaWZ0KGNvbnRvdXIuYXQoLTEpKTsKICAgICAgfSBlbHNlIHsKICAgICAgICBjb25zdCBwID0gewogICAgICAgICAgZmxhZ3M6IDEsCiAgICAgICAgICB4OiAoY29udG91clswXS54ICsgY29udG91ci5hdCgtMSkueCkgLyAyLAogICAgICAgICAgeTogKGNvbnRvdXJbMF0ueSArIGNvbnRvdXIuYXQoLTEpLnkpIC8gMgogICAgICAgIH07CiAgICAgICAgY29udG91ci51bnNoaWZ0KHApOwogICAgICAgIGNvbnRvdXIucHVzaChwKTsKICAgICAgfQogICAgICBtb3ZlVG8oY29udG91clswXS54LCBjb250b3VyWzBdLnkpOwogICAgICBmb3IgKGogPSAxLCBqaiA9IGNvbnRvdXIubGVuZ3RoOyBqIDwgamo7IGorKykgewogICAgICAgIGlmIChjb250b3VyW2pdLmZsYWdzICYgMSkgewogICAgICAgICAgbGluZVRvKGNvbnRvdXJbal0ueCwgY29udG91cltqXS55KTsKICAgICAgICB9IGVsc2UgaWYgKGNvbnRvdXJbaiArIDFdLmZsYWdzICYgMSkgewogICAgICAgICAgcXVhZHJhdGljQ3VydmVUbyhjb250b3VyW2pdLngsIGNvbnRvdXJbal0ueSwgY29udG91cltqICsgMV0ueCwgY29udG91cltqICsgMV0ueSk7CiAgICAgICAgICBqKys7CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIHF1YWRyYXRpY0N1cnZlVG8oY29udG91cltqXS54LCBjb250b3VyW2pdLnksIChjb250b3VyW2pdLnggKyBjb250b3VyW2ogKyAxXS54KSAvIDIsIChjb250b3VyW2pdLnkgKyBjb250b3VyW2ogKyAxXS55KSAvIDIpOwogICAgICAgIH0KICAgICAgfQogICAgICBzdGFydFBvaW50ID0gZW5kUG9pbnQgKyAxOwogICAgfQogIH0KfQpmdW5jdGlvbiBjb21waWxlQ2hhclN0cmluZyhjaGFyU3RyaW5nQ29kZSwgY21kcywgZm9udCwgZ2x5cGhJZCkgewogIGZ1bmN0aW9uIG1vdmVUbyh4LCB5KSB7CiAgICBjbWRzLnB1c2goewogICAgICBjbWQ6ICJtb3ZlVG8iLAogICAgICBhcmdzOiBbeCwgeV0KICAgIH0pOwogIH0KICBmdW5jdGlvbiBsaW5lVG8oeCwgeSkgewogICAgY21kcy5wdXNoKHsKICAgICAgY21kOiAibGluZVRvIiwKICAgICAgYXJnczogW3gsIHldCiAgICB9KTsKICB9CiAgZnVuY3Rpb24gYmV6aWVyQ3VydmVUbyh4MSwgeTEsIHgyLCB5MiwgeCwgeSkgewogICAgY21kcy5wdXNoKHsKICAgICAgY21kOiAiYmV6aWVyQ3VydmVUbyIsCiAgICAgIGFyZ3M6IFt4MSwgeTEsIHgyLCB5MiwgeCwgeV0KICAgIH0pOwogIH0KICBjb25zdCBzdGFjayA9IFtdOwogIGxldCB4ID0gMCwKICAgIHkgPSAwOwogIGxldCBzdGVtcyA9IDA7CiAgZnVuY3Rpb24gcGFyc2UoY29kZSkgewogICAgbGV0IGkgPSAwOwogICAgd2hpbGUgKGkgPCBjb2RlLmxlbmd0aCkgewogICAgICBsZXQgc3RhY2tDbGVhbiA9IGZhbHNlOwogICAgICBsZXQgdiA9IGNvZGVbaSsrXTsKICAgICAgbGV0IHhhLCB4YiwgeWEsIHliLCB5MSwgeTIsIHkzLCBuLCBzdWJyQ29kZTsKICAgICAgc3dpdGNoICh2KSB7CiAgICAgICAgY2FzZSAxOgogICAgICAgICAgc3RlbXMgKz0gc3RhY2subGVuZ3RoID4+IDE7CiAgICAgICAgICBzdGFja0NsZWFuID0gdHJ1ZTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMzoKICAgICAgICAgIHN0ZW1zICs9IHN0YWNrLmxlbmd0aCA+PiAxOwogICAgICAgICAgc3RhY2tDbGVhbiA9IHRydWU7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIDQ6CiAgICAgICAgICB5ICs9IHN0YWNrLnBvcCgpOwogICAgICAgICAgbW92ZVRvKHgsIHkpOwogICAgICAgICAgc3RhY2tDbGVhbiA9IHRydWU7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIDU6CiAgICAgICAgICB3aGlsZSAoc3RhY2subGVuZ3RoID4gMCkgewogICAgICAgICAgICB4ICs9IHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgIHkgKz0gc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgbGluZVRvKHgsIHkpOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSA2OgogICAgICAgICAgd2hpbGUgKHN0YWNrLmxlbmd0aCA+IDApIHsKICAgICAgICAgICAgeCArPSBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICBsaW5lVG8oeCwgeSk7CiAgICAgICAgICAgIGlmIChzdGFjay5sZW5ndGggPT09IDApIHsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgfQogICAgICAgICAgICB5ICs9IHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgIGxpbmVUbyh4LCB5KTsKICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgNzoKICAgICAgICAgIHdoaWxlIChzdGFjay5sZW5ndGggPiAwKSB7CiAgICAgICAgICAgIHkgKz0gc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgbGluZVRvKHgsIHkpOwogICAgICAgICAgICBpZiAoc3RhY2subGVuZ3RoID09PSAwKSB7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgeCArPSBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICBsaW5lVG8oeCwgeSk7CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIDg6CiAgICAgICAgICB3aGlsZSAoc3RhY2subGVuZ3RoID4gMCkgewogICAgICAgICAgICB4YSA9IHggKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICB5YSA9IHkgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICB4YiA9IHhhICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgeWIgPSB5YSArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgIHggPSB4YiArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgIHkgPSB5YiArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgIGJlemllckN1cnZlVG8oeGEsIHlhLCB4YiwgeWIsIHgsIHkpOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAxMDoKICAgICAgICAgIG4gPSBzdGFjay5wb3AoKTsKICAgICAgICAgIHN1YnJDb2RlID0gbnVsbDsKICAgICAgICAgIGlmIChmb250LmlzQ0ZGQ0lERm9udCkgewogICAgICAgICAgICBjb25zdCBmZEluZGV4ID0gZm9udC5mZFNlbGVjdC5nZXRGREluZGV4KGdseXBoSWQpOwogICAgICAgICAgICBpZiAoZmRJbmRleCA+PSAwICYmIGZkSW5kZXggPCBmb250LmZkQXJyYXkubGVuZ3RoKSB7CiAgICAgICAgICAgICAgY29uc3QgZm9udERpY3QgPSBmb250LmZkQXJyYXlbZmRJbmRleF07CiAgICAgICAgICAgICAgbGV0IHN1YnJzOwogICAgICAgICAgICAgIGlmIChmb250RGljdC5wcml2YXRlRGljdCAmJiBmb250RGljdC5wcml2YXRlRGljdC5zdWJyc0luZGV4KSB7CiAgICAgICAgICAgICAgICBzdWJycyA9IGZvbnREaWN0LnByaXZhdGVEaWN0LnN1YnJzSW5kZXgub2JqZWN0czsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgaWYgKHN1YnJzKSB7CiAgICAgICAgICAgICAgICBuICs9IGdldFN1YnJvdXRpbmVCaWFzKHN1YnJzKTsKICAgICAgICAgICAgICAgIHN1YnJDb2RlID0gc3VicnNbbl07CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKSgiSW52YWxpZCBmZCBpbmRleCBmb3IgZ2x5cGggaW5kZXguIik7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHN1YnJDb2RlID0gZm9udC5zdWJyc1tuICsgZm9udC5zdWJyc0JpYXNdOwogICAgICAgICAgfQogICAgICAgICAgaWYgKHN1YnJDb2RlKSB7CiAgICAgICAgICAgIHBhcnNlKHN1YnJDb2RlKTsKICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMTE6CiAgICAgICAgICByZXR1cm47CiAgICAgICAgY2FzZSAxMjoKICAgICAgICAgIHYgPSBjb2RlW2krK107CiAgICAgICAgICBzd2l0Y2ggKHYpIHsKICAgICAgICAgICAgY2FzZSAzNDoKICAgICAgICAgICAgICB4YSA9IHggKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICAgIHhiID0geGEgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICAgIHkxID0geSArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgICAgeCA9IHhiICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgICBiZXppZXJDdXJ2ZVRvKHhhLCB5LCB4YiwgeTEsIHgsIHkxKTsKICAgICAgICAgICAgICB4YSA9IHggKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICAgIHhiID0geGEgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICAgIHggPSB4YiArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgICAgYmV6aWVyQ3VydmVUbyh4YSwgeTEsIHhiLCB5LCB4LCB5KTsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSAzNToKICAgICAgICAgICAgICB4YSA9IHggKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICAgIHlhID0geSArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgICAgeGIgPSB4YSArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgICAgeWIgPSB5YSArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgICAgeCA9IHhiICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgICB5ID0geWIgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICAgIGJlemllckN1cnZlVG8oeGEsIHlhLCB4YiwgeWIsIHgsIHkpOwogICAgICAgICAgICAgIHhhID0geCArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgICAgeWEgPSB5ICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgICB4YiA9IHhhICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgICB5YiA9IHlhICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgICB4ID0geGIgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICAgIHkgPSB5YiArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgICAgYmV6aWVyQ3VydmVUbyh4YSwgeWEsIHhiLCB5YiwgeCwgeSk7CiAgICAgICAgICAgICAgc3RhY2sucG9wKCk7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIGNhc2UgMzY6CiAgICAgICAgICAgICAgeGEgPSB4ICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgICB5MSA9IHkgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICAgIHhiID0geGEgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICAgIHkyID0geTEgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICAgIHggPSB4YiArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgICAgYmV6aWVyQ3VydmVUbyh4YSwgeTEsIHhiLCB5MiwgeCwgeTIpOwogICAgICAgICAgICAgIHhhID0geCArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgICAgeGIgPSB4YSArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgICAgeTMgPSB5MiArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgICAgeCA9IHhiICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgICBiZXppZXJDdXJ2ZVRvKHhhLCB5MiwgeGIsIHkzLCB4LCB5KTsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSAzNzoKICAgICAgICAgICAgICBjb25zdCB4MCA9IHgsCiAgICAgICAgICAgICAgICB5MCA9IHk7CiAgICAgICAgICAgICAgeGEgPSB4ICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgICB5YSA9IHkgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICAgIHhiID0geGEgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICAgIHliID0geWEgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICAgIHggPSB4YiArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgICAgeSA9IHliICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgICBiZXppZXJDdXJ2ZVRvKHhhLCB5YSwgeGIsIHliLCB4LCB5KTsKICAgICAgICAgICAgICB4YSA9IHggKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICAgIHlhID0geSArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgICAgeGIgPSB4YSArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgICAgeWIgPSB5YSArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgICAgeCA9IHhiOwogICAgICAgICAgICAgIHkgPSB5YjsKICAgICAgICAgICAgICBpZiAoTWF0aC5hYnMoeCAtIHgwKSA+IE1hdGguYWJzKHkgLSB5MCkpIHsKICAgICAgICAgICAgICAgIHggKz0gc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgeSArPSBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBiZXppZXJDdXJ2ZVRvKHhhLCB5YSwgeGIsIHliLCB4LCB5KTsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoYHVua25vd24gb3BlcmF0b3I6IDEyICR7dn1gKTsKICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMTQ6CiAgICAgICAgICBpZiAoc3RhY2subGVuZ3RoID49IDQpIHsKICAgICAgICAgICAgY29uc3QgYWNoYXIgPSBzdGFjay5wb3AoKTsKICAgICAgICAgICAgY29uc3QgYmNoYXIgPSBzdGFjay5wb3AoKTsKICAgICAgICAgICAgeSA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgICB4ID0gc3RhY2sucG9wKCk7CiAgICAgICAgICAgIGNtZHMucHVzaCh7CiAgICAgICAgICAgICAgY21kOiAic2F2ZSIKICAgICAgICAgICAgfSwgewogICAgICAgICAgICAgIGNtZDogInRyYW5zbGF0ZSIsCiAgICAgICAgICAgICAgYXJnczogW3gsIHldCiAgICAgICAgICAgIH0pOwogICAgICAgICAgICBsZXQgY21hcCA9IGxvb2t1cENtYXAoZm9udC5jbWFwLCBTdHJpbmcuZnJvbUNoYXJDb2RlKGZvbnQuZ2x5cGhOYW1lTWFwW19lbmNvZGluZ3MuU3RhbmRhcmRFbmNvZGluZ1thY2hhcl1dKSk7CiAgICAgICAgICAgIGNvbXBpbGVDaGFyU3RyaW5nKGZvbnQuZ2x5cGhzW2NtYXAuZ2x5cGhJZF0sIGNtZHMsIGZvbnQsIGNtYXAuZ2x5cGhJZCk7CiAgICAgICAgICAgIGNtZHMucHVzaCh7CiAgICAgICAgICAgICAgY21kOiAicmVzdG9yZSIKICAgICAgICAgICAgfSk7CiAgICAgICAgICAgIGNtYXAgPSBsb29rdXBDbWFwKGZvbnQuY21hcCwgU3RyaW5nLmZyb21DaGFyQ29kZShmb250LmdseXBoTmFtZU1hcFtfZW5jb2RpbmdzLlN0YW5kYXJkRW5jb2RpbmdbYmNoYXJdXSkpOwogICAgICAgICAgICBjb21waWxlQ2hhclN0cmluZyhmb250LmdseXBoc1tjbWFwLmdseXBoSWRdLCBjbWRzLCBmb250LCBjbWFwLmdseXBoSWQpOwogICAgICAgICAgfQogICAgICAgICAgcmV0dXJuOwogICAgICAgIGNhc2UgMTg6CiAgICAgICAgICBzdGVtcyArPSBzdGFjay5sZW5ndGggPj4gMTsKICAgICAgICAgIHN0YWNrQ2xlYW4gPSB0cnVlOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAxOToKICAgICAgICAgIHN0ZW1zICs9IHN0YWNrLmxlbmd0aCA+PiAxOwogICAgICAgICAgaSArPSBzdGVtcyArIDcgPj4gMzsKICAgICAgICAgIHN0YWNrQ2xlYW4gPSB0cnVlOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAyMDoKICAgICAgICAgIHN0ZW1zICs9IHN0YWNrLmxlbmd0aCA+PiAxOwogICAgICAgICAgaSArPSBzdGVtcyArIDcgPj4gMzsKICAgICAgICAgIHN0YWNrQ2xlYW4gPSB0cnVlOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAyMToKICAgICAgICAgIHkgKz0gc3RhY2sucG9wKCk7CiAgICAgICAgICB4ICs9IHN0YWNrLnBvcCgpOwogICAgICAgICAgbW92ZVRvKHgsIHkpOwogICAgICAgICAgc3RhY2tDbGVhbiA9IHRydWU7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIDIyOgogICAgICAgICAgeCArPSBzdGFjay5wb3AoKTsKICAgICAgICAgIG1vdmVUbyh4LCB5KTsKICAgICAgICAgIHN0YWNrQ2xlYW4gPSB0cnVlOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAyMzoKICAgICAgICAgIHN0ZW1zICs9IHN0YWNrLmxlbmd0aCA+PiAxOwogICAgICAgICAgc3RhY2tDbGVhbiA9IHRydWU7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIDI0OgogICAgICAgICAgd2hpbGUgKHN0YWNrLmxlbmd0aCA+IDIpIHsKICAgICAgICAgICAgeGEgPSB4ICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgeWEgPSB5ICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgeGIgPSB4YSArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgIHliID0geWEgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICB4ID0geGIgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICB5ID0geWIgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICBiZXppZXJDdXJ2ZVRvKHhhLCB5YSwgeGIsIHliLCB4LCB5KTsKICAgICAgICAgIH0KICAgICAgICAgIHggKz0gc3RhY2suc2hpZnQoKTsKICAgICAgICAgIHkgKz0gc3RhY2suc2hpZnQoKTsKICAgICAgICAgIGxpbmVUbyh4LCB5KTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMjU6CiAgICAgICAgICB3aGlsZSAoc3RhY2subGVuZ3RoID4gNikgewogICAgICAgICAgICB4ICs9IHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgIHkgKz0gc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgbGluZVRvKHgsIHkpOwogICAgICAgICAgfQogICAgICAgICAgeGEgPSB4ICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgIHlhID0geSArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICB4YiA9IHhhICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgIHliID0geWEgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgeCA9IHhiICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgIHkgPSB5YiArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICBiZXppZXJDdXJ2ZVRvKHhhLCB5YSwgeGIsIHliLCB4LCB5KTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMjY6CiAgICAgICAgICBpZiAoc3RhY2subGVuZ3RoICUgMikgewogICAgICAgICAgICB4ICs9IHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICB9CiAgICAgICAgICB3aGlsZSAoc3RhY2subGVuZ3RoID4gMCkgewogICAgICAgICAgICB4YSA9IHg7CiAgICAgICAgICAgIHlhID0geSArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgIHhiID0geGEgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICB5YiA9IHlhICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgeCA9IHhiOwogICAgICAgICAgICB5ID0geWIgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICBiZXppZXJDdXJ2ZVRvKHhhLCB5YSwgeGIsIHliLCB4LCB5KTsKICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMjc6CiAgICAgICAgICBpZiAoc3RhY2subGVuZ3RoICUgMikgewogICAgICAgICAgICB5ICs9IHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICB9CiAgICAgICAgICB3aGlsZSAoc3RhY2subGVuZ3RoID4gMCkgewogICAgICAgICAgICB4YSA9IHggKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICB5YSA9IHk7CiAgICAgICAgICAgIHhiID0geGEgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICB5YiA9IHlhICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgeCA9IHhiICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgeSA9IHliOwogICAgICAgICAgICBiZXppZXJDdXJ2ZVRvKHhhLCB5YSwgeGIsIHliLCB4LCB5KTsKICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMjg6CiAgICAgICAgICBzdGFjay5wdXNoKChjb2RlW2ldIDw8IDI0IHwgY29kZVtpICsgMV0gPDwgMTYpID4+IDE2KTsKICAgICAgICAgIGkgKz0gMjsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMjk6CiAgICAgICAgICBuID0gc3RhY2sucG9wKCkgKyBmb250LmdzdWJyc0JpYXM7CiAgICAgICAgICBzdWJyQ29kZSA9IGZvbnQuZ3N1YnJzW25dOwogICAgICAgICAgaWYgKHN1YnJDb2RlKSB7CiAgICAgICAgICAgIHBhcnNlKHN1YnJDb2RlKTsKICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMzA6CiAgICAgICAgICB3aGlsZSAoc3RhY2subGVuZ3RoID4gMCkgewogICAgICAgICAgICB4YSA9IHg7CiAgICAgICAgICAgIHlhID0geSArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgIHhiID0geGEgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICB5YiA9IHlhICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgeCA9IHhiICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgeSA9IHliICsgKHN0YWNrLmxlbmd0aCA9PT0gMSA/IHN0YWNrLnNoaWZ0KCkgOiAwKTsKICAgICAgICAgICAgYmV6aWVyQ3VydmVUbyh4YSwgeWEsIHhiLCB5YiwgeCwgeSk7CiAgICAgICAgICAgIGlmIChzdGFjay5sZW5ndGggPT09IDApIHsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgfQogICAgICAgICAgICB4YSA9IHggKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICB5YSA9IHk7CiAgICAgICAgICAgIHhiID0geGEgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICB5YiA9IHlhICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgeSA9IHliICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgeCA9IHhiICsgKHN0YWNrLmxlbmd0aCA9PT0gMSA/IHN0YWNrLnNoaWZ0KCkgOiAwKTsKICAgICAgICAgICAgYmV6aWVyQ3VydmVUbyh4YSwgeWEsIHhiLCB5YiwgeCwgeSk7CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIDMxOgogICAgICAgICAgd2hpbGUgKHN0YWNrLmxlbmd0aCA+IDApIHsKICAgICAgICAgICAgeGEgPSB4ICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgeWEgPSB5OwogICAgICAgICAgICB4YiA9IHhhICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgeWIgPSB5YSArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgIHkgPSB5YiArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgIHggPSB4YiArIChzdGFjay5sZW5ndGggPT09IDEgPyBzdGFjay5zaGlmdCgpIDogMCk7CiAgICAgICAgICAgIGJlemllckN1cnZlVG8oeGEsIHlhLCB4YiwgeWIsIHgsIHkpOwogICAgICAgICAgICBpZiAoc3RhY2subGVuZ3RoID09PSAwKSB7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgeGEgPSB4OwogICAgICAgICAgICB5YSA9IHkgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICB4YiA9IHhhICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgeWIgPSB5YSArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgIHggPSB4YiArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgIHkgPSB5YiArIChzdGFjay5sZW5ndGggPT09IDEgPyBzdGFjay5zaGlmdCgpIDogMCk7CiAgICAgICAgICAgIGJlemllckN1cnZlVG8oeGEsIHlhLCB4YiwgeWIsIHgsIHkpOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgZGVmYXVsdDoKICAgICAgICAgIGlmICh2IDwgMzIpIHsKICAgICAgICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKGB1bmtub3duIG9wZXJhdG9yOiAke3Z9YCk7CiAgICAgICAgICB9CiAgICAgICAgICBpZiAodiA8IDI0NykgewogICAgICAgICAgICBzdGFjay5wdXNoKHYgLSAxMzkpOwogICAgICAgICAgfSBlbHNlIGlmICh2IDwgMjUxKSB7CiAgICAgICAgICAgIHN0YWNrLnB1c2goKHYgLSAyNDcpICogMjU2ICsgY29kZVtpKytdICsgMTA4KTsKICAgICAgICAgIH0gZWxzZSBpZiAodiA8IDI1NSkgewogICAgICAgICAgICBzdGFjay5wdXNoKC0odiAtIDI1MSkgKiAyNTYgLSBjb2RlW2krK10gLSAxMDgpOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgc3RhY2sucHVzaCgoY29kZVtpXSA8PCAyNCB8IGNvZGVbaSArIDFdIDw8IDE2IHwgY29kZVtpICsgMl0gPDwgOCB8IGNvZGVbaSArIDNdKSAvIDY1NTM2KTsKICAgICAgICAgICAgaSArPSA0OwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgIH0KICAgICAgaWYgKHN0YWNrQ2xlYW4pIHsKICAgICAgICBzdGFjay5sZW5ndGggPSAwOwogICAgICB9CiAgICB9CiAgfQogIHBhcnNlKGNoYXJTdHJpbmdDb2RlKTsKfQpjb25zdCBOT09QID0gW107CmNsYXNzIENvbXBpbGVkRm9udCB7CiAgY29uc3RydWN0b3IoZm9udE1hdHJpeCkgewogICAgaWYgKHRoaXMuY29uc3RydWN0b3IgPT09IENvbXBpbGVkRm9udCkgewogICAgICAoMCwgX3V0aWwudW5yZWFjaGFibGUpKCJDYW5ub3QgaW5pdGlhbGl6ZSBDb21waWxlZEZvbnQuIik7CiAgICB9CiAgICB0aGlzLmZvbnRNYXRyaXggPSBmb250TWF0cml4OwogICAgdGhpcy5jb21waWxlZEdseXBocyA9IE9iamVjdC5jcmVhdGUobnVsbCk7CiAgICB0aGlzLmNvbXBpbGVkQ2hhckNvZGVUb0dseXBoSWQgPSBPYmplY3QuY3JlYXRlKG51bGwpOwogIH0KICBnZXRQYXRoSnModW5pY29kZSkgewogICAgY29uc3QgewogICAgICBjaGFyQ29kZSwKICAgICAgZ2x5cGhJZAogICAgfSA9IGxvb2t1cEN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HQudHdvID0gNTU2OwogICAgdC50aHJlZSA9IDU1NjsKICAgIHQuZm91ciA9IDU1NjsKICAgIHQuZml2ZSA9IDU1NjsKICAgIHQuc2l4ID0gNTU2OwogICAgdC5zZXZlbiA9IDU1NjsKICAgIHQuZWlnaHQgPSA1NTY7CiAgICB0Lm5pbmUgPSA1NTY7CiAgICB0LmNvbG9uID0gMjc4OwogICAgdC5zZW1pY29sb24gPSAyNzg7CiAgICB0Lmxlc3MgPSA1ODQ7CiAgICB0LmVxdWFsID0gNTg0OwogICAgdC5ncmVhdGVyID0gNTg0OwogICAgdC5xdWVzdGlvbiA9IDU1NjsKICAgIHQuYXQgPSAxMDE1OwogICAgdC5BID0gNjY3OwogICAgdC5CID0gNjY3OwogICAgdC5DID0gNzIyOwogICAgdC5EID0gNzIyOwogICAgdC5FID0gNjY3OwogICAgdC5GID0gNjExOwogICAgdC5HID0gNzc4OwogICAgdC5IID0gNzIyOwogICAgdC5JID0gMjc4OwogICAgdC5KID0gNTAwOwogICAgdC5LID0gNjY3OwogICAgdC5MID0gNTU2OwogICAgdC5NID0gODMzOwogICAgdC5OID0gNzIyOwogICAgdC5PID0gNzc4OwogICAgdC5QID0gNjY3OwogICAgdC5RID0gNzc4OwogICAgdC5SID0gNzIyOwogICAgdC5TID0gNjY3OwogICAgdC5UID0gNjExOwogICAgdC5VID0gNzIyOwogICAgdC5WID0gNjY3OwogICAgdC5XID0gOTQ0OwogICAgdC5YID0gNjY3OwogICAgdC5ZID0gNjY3OwogICAgdC5aID0gNjExOwogICAgdC5icmFja2V0bGVmdCA9IDI3ODsKICAgIHQuYmFja3NsYXNoID0gMjc4OwogICAgdC5icmFja2V0cmlnaHQgPSAyNzg7CiAgICB0LmFzY2lpY2lyY3VtID0gNDY5OwogICAgdC51bmRlcnNjb3JlID0gNTU2OwogICAgdC5xdW90ZWxlZnQgPSAyMjI7CiAgICB0LmEgPSA1NTY7CiAgICB0LmIgPSA1NTY7CiAgICB0LmMgPSA1MDA7CiAg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Dc3ODsKICAgIHQuUiA9IDcyMjsKICAgIHQuUyA9IDY2NzsKICAgIHQuVCA9IDYxMTsKICAgIHQuVSA9IDcyMjsKICAgIHQuViA9IDY2NzsKICAgIHQuVyA9IDk0NDsKICAgIHQuWCA9IDY2NzsKICAgIHQuWSA9IDY2NzsKICAgIHQuWiA9IDYxMTsKICAgIHQuYnJhY2tldGxlZnQgPSAzMzM7CiAgICB0LmJhY2tzbGFzaCA9IDI3ODsKICAgIHQuYnJhY2tldHJpZ2h0ID0gMzMzOwogICAgdC5hc2NpaWNpcmN1bSA9IDU4NDsKICAgIHQudW5kZXJzY29yZSA9IDU1NjsKICAgIHQucXVvdGVsZWZ0ID0gMjc4OwogICAgdC5hID0gNTU2OwogICAgdC5iID0gNjExOwogICAgdC5jID0gNTU2OwogICAgdC5kID0gNjExOwogICAgdC5lID0gNTU2OwogICAgdC5mID0gMzMzOwogICAgdC5nID0gNjExOwogICAgdC5oID0gNjExOwogICAgdC5pID0gMjc4OwogICAgdC5qID0gMjc4OwogICAgdC5rID0gNTU2OwogICAgdC5sID0gMjc4OwogICAgdC5tID0gODg5OwogICAgdC5uID0gNjExOwogICAgdC5vID0gNjExOwogICAgdC5wID0gNjExOwogICAgdC5xID0gNjExOwogICAgdC5yID0gMzg5OwogICAgdC5zID0gNTU2OwogICAgdC50ID0gMzMzOwogICAgdC51ID0gNjExOwogICAgdC52ID0gNTU2OwogICAgdC53ID0gNzc4OwogICAgdC54ID0gNTU2OwogICAgdC55ID0gNTU2OwogICAgdC56ID0gNTAwOwogICAgdC5icmFjZWxlZnQgPSAzODk7CiAgICB0LmJhciA9IDI4MDsKICAgIHQuYnJhY2VyaWdodCA9IDM4OTsKICAgIHQuYXNjaWl0aWxkZSA9IDU4NDsKICAgIHQuZXhjbGFtZG93biA9IDMzMzsKICAgIHQuY2VudCA9IDU1NjsKICAgIHQuc3RlcmxpbmcgPSA1NTY7CiAgICB0LmZyYWN0aW9uID0gMTY3OwogICAgdC55ZW4gPSA1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9IDUwMDsKICAgIHQuVCA9IDU1NjsKICAgIHQuVSA9IDcyMjsKICAgIHQuViA9IDYxMTsKICAgIHQuVyA9IDgzMzsKICAgIHQuWCA9IDYxMTsKICAgIHQuWSA9IDU1NjsKICAgIHQuWiA9IDU1NjsKICAgIHQuYnJhY2tldGxlZnQgPSAzODk7CiAgICB0LmJhY2tzbGFzaCA9IDI3ODsKICAgIHQuYnJhY2tldHJpZ2h0ID0gMzg5OwogICAgdC5hc2NpaWNpcmN1bSA9IDQyMjsKICAgIHQudW5kZXJzY29yZSA9IDUwMDsKICAgIHQucXVvdGVsZWZ0ID0gMzMzOwogICAgdC5hID0gNTAwOwogICAgdC5iID0gNTAwOwogICAgdC5jID0gNDQ0OwogICAgdC5kID0gNTAwOwogICAgdC5lID0gNDQ0OwogICAgdC5mID0gMjc4OwogICAgdC5nID0gNTAwOwogICAgdC5oID0gNTAwOwogICAgdC5pID0gMjc4OwogICAgdC5qID0gMjc4OwogICAgdC5rID0gNDQ0OwogICAgdC5sID0gMjc4OwogICAgdC5tID0gNzIyOwogICAgdC5uID0gNTAwOwogICAgdC5vID0gNTAwOwogICAgdC5wID0gNTAwOwogICAgdC5xID0gNTAwOwogICAgdC5yID0gMzg5OwogICAgdC5zID0gMzg5OwogICAgdC50ID0gMjc4OwogICAgdC51ID0gNTAwOwogICAgdC52ID0gNDQ0OwogICAgdC53ID0gNjY3OwogICAgdC54ID0gNDQ0OwogICAgdC55ID0gNDQ0OwogICAgdC56ID0gMzg5OwogICAgdC5icmFjZWxlZnQgPSA0MDA7CiAgICB0LmJhciA9IDI3NTsKICAgIHQuYnJhY2VyaWdodCA9IDQwMDsKICAgIHQuYXNjaWl0aWxkZSA9IDU0MTsKICAgIHQuZXhjbGFtZG93biA9IDM4OTsKICAgIHQuY2VudCA9IDUwMDsKICAgIHQuc3RlcmxpbmcgPSA1MDA7CiAgICB0LmZyYWN0aW9uID0gMTY3OwogICAgdC55ZW4gPSA1MDA7CiAgICB0LmZsb3Jpb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gICB0LmE5NSA9IDMzNDsKICAgIHQuYTk2ID0gMzM0OwogICAgdC5hMTAxID0gNzMyOwogICAgdC5hMTAyID0gNTQ0OwogICAgdC5hMTAzID0gNTQ0OwogICAgdC5hMTA0ID0gOTEwOwogICAgdC5hMTA2ID0gNjY3OwogICAgdC5hMTA3ID0gNzYwOwogICAgdC5hMTA4ID0gNzYwOwogICAgdC5hMTEyID0gNzc2OwogICAgdC5hMTExID0gNTk1OwogICAgdC5hMTEwID0gNjk0OwogICAgdC5hMTA5ID0gNjI2OwogICAgdC5hMTIwID0gNzg4OwogICAgdC5hMTIxID0gNzg4OwogICAgdC5hMTIyID0gNzg4OwogICAgdC5hMTIzID0gNzg4OwogICAgdC5hMTI0ID0gNzg4OwogICAgdC5hMTI1ID0gNzg4OwogICAgdC5hMTI2ID0gNzg4OwogICAgdC5hMTI3ID0gNzg4OwogICAgdC5hMTI4ID0gNzg4OwogICAgdC5hMTI5ID0gNzg4OwogICAgdC5hMTMwID0gNzg4OwogICAgdC5hMTMxID0gNzg4OwogICAgdC5hMTMyID0gNzg4OwogICAgdC5hMTMzID0gNzg4OwogICAgdC5hMTM0ID0gNzg4OwogICAgdC5hMTM1ID0gNzg4OwogICAgdC5hMTM2ID0gNzg4OwogICAgdC5hMTM3ID0gNzg4OwogICAgdC5hMTM4ID0gNzg4OwogICAgdC5hMTM5ID0gNzg4OwogICAgdC5hMTQwID0gNzg4OwogICAgdC5hMTQxID0gNzg4OwogICAgdC5hMTQyID0gNzg4OwogICAgdC5hMTQzID0gNzg4OwogICAgdC5hMTQ0ID0gNzg4OwogICAgdC5hMTQ1ID0gNzg4OwogICAgdC5hMTQ2ID0gNzg4OwogICAgdC5hMTQ3ID0gNzg4OwogICAgdC5hMTQ4ID0gNzg4OwogICAgdC5hMTQ5ID0gNzg4OwogICAgdC5hMTUwID0gNzg4OwogICAgdC5hMTUxID0gNzg4OwogICAgdC5hMTUyID0gNzg4OwogICAgdC5hMTUzID0gNzg4OwogICAgdC5h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B0c09mQ29udG91cnNJbmRleCsrOwogICAgICAgIGNvbnRvdXJzLnB1c2gobmV3IENvbnRvdXIoewogICAgICAgICAgZmxhZ3M6IHBvaW50RmxhZ3MsCiAgICAgICAgICB4Q29vcmRpbmF0ZXMsCiAgICAgICAgICB5Q29vcmRpbmF0ZXMKICAgICAgICB9KSk7CiAgICAgICAgeUNvb3JkaW5hdGVzID0gW107CiAgICAgICAgcG9pbnRGbGFncyA9IFtdOwogICAgICB9CiAgICB9CiAgICByZXR1cm4gbmV3IFNpbXBsZUdseXBoKHsKICAgICAgY29udG91cnMsCiAgICAgIGluc3RydWN0aW9ucwogICAgfSk7CiAgfQogIGdldFNpemUoKSB7CiAgICBsZXQgc2l6ZSA9IHRoaXMuY29udG91cnMubGVuZ3RoICogMiArIDIgKyB0aGlzLmluc3RydWN0aW9ucy5sZW5ndGg7CiAgICBsZXQgbGFzdFggPSAwOwogICAgbGV0IGxhc3RZID0gMDsKICAgIGZvciAoY29uc3QgY29udG91ciBvZiB0aGlzLmNvbnRvdXJzKSB7CiAgICAgIHNpemUgKz0gY29udG91ci5mbGFncy5sZW5ndGg7CiAgICAgIGZvciAobGV0IGkgPSAwLCBpaSA9IGNvbnRvdXIueENvb3JkaW5hdGVzLmxlbmd0aDsgaSA8IGlpOyBpKyspIHsKICAgICAgICBjb25zdCB4ID0gY29udG91ci54Q29vcmRpbmF0ZXNbaV07CiAgICAgICAgY29uc3QgeSA9IGNvbnRvdXIueUNvb3JkaW5hdGVzW2ldOwogICAgICAgIGxldCBhYnMgPSBNYXRoLmFicyh4IC0gbGFzdFgpOwogICAgICAgIGlmIChhYnMgPiAyNTUpIHsKICAgICAgICAgIHNpemUgKz0gMjsKICAgICAgICB9IGVsc2UgaWYgKGFicyA+IDApIHsKICAgICAgICAgIHNpemUgKz0gMTsKICAgICAgICB9CiAgICAgICAgbGFzdFggPSB4OwogICAgICAgIGFicyA9IE1hdGguYWJzKHkgLSBsYXN0WSk7CiAgICAgICAgaWYgKGFicyA+IDI1NSkgewogICAgICAgICAgc2l6ZSArPSAyOwogICAgICAgIH0gZWxzZSBpZiAoYWJzID4gMCkgewogICAgICAgICAgc2l6ZSArPSAxOwogICAgICAgIH0KICAgICAgICBsYXN0WSA9IHk7CiAgICAgIH0KICAgIH0KICAgIHJldHVybiBzaXplOwogIH0KICB3cml0ZShwb3MsIGJ1ZikgewogICAgY29uc3Qgc3BvcyA9IHBvczsKICAgIGNvbnN0IHhDb29yZGluYXRlcyA9IFtdOwogICAgY29uc3QgeUNvb3JkaW5hdGVzID0gW107CiAgICBjb25zdCBmbGFncyA9IFtdOwogICAgbGV0IGxhc3RYID0gMDsKICAgIGxldCBsYXN0WSA9IDA7CiAgICBmb3IgKGNvbnN0IGNvbnRvdXIgb2YgdGhpcy5jb250b3VycykgewogICAgICBmb3IgKGxldCBpID0gMCwgaWkgPSBjb250b3VyLnhDb29yZGluYXRlcy5sZW5ndGg7IGkgPCBpaTsgaSsrKSB7CiAgICAgICAgbGV0IGZsYWcgPSBjb250b3VyLmZsYWdzW2ldOwogICAgICAgIGNvbnN0IHggPSBjb250b3VyLnhDb29yZGluYXRlc1tpXTsKICAgICAgICBsZXQgZGVsdGEgPSB4IC0gbGFzdFg7CiAgICAgICAgaWYgKGRlbHRhID09PSAwKSB7CiAgICAgICAgICBmbGFnIHw9IFhfSVNfU0FNRV9PUl9QT1NJVElWRV9YX1NIT1JUX1ZFQ1RPUjsKICAgICAgICAgIHhDb29yZGluYXRlcy5wdXNoKDApOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBjb25zdCBhYnMgPSBNYXRoLmFicyhkZWx0YSk7CiAgICAgICAgICBpZiAoYWJzIDw9IDI1NSkgewogICAgICAgICAgICBmbGFnIHw9IGRlbHRhID49IDAgPyBYX1NIT1JUX1ZFQ1RPUiB8IFhfSVNfU0FNRV9PUl9QT1NJVElWRV9YX1NIT1JUX1ZFQ1RPUiA6IFhfU0hPUlRfVkVDVE9SOwogICAgICAgICAgICB4Q29vcmRpbmF0ZXMucHVzaChhYnMpOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgeENvb3JkaW5hdGVzLnB1c2goZGVsdGEpOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBsYXN0WCA9IHg7CiAgICAgICAgY29uc3QgeSA9IGNvbnRvdXIueUNvb3JkaW5hdGVzW2ldOwogICAgICAgIGRlbHRhID0geSAtIGxhc3RZOwogICAgICAgIGlmIChkZWx0YSA9PT0gMCkgewogICAgICAgICAgZmxhZyB8PSBZX0lTX1NBTUVfT1JfUE9TSVRJVkVfWV9TSE9SVF9WRUNUT1I7CiAgICAgICAgICB5Q29vcmRpbmF0ZXMucHVzaCgwKTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgY29uc3QgYWJzID0gTWF0aC5hYnMoZGVsdGEpOwogICAgICAgICAgaWYgKGFicyA8PSAyNTUpIHsKICAgICAgICAgICAgZmxhZyB8PSBkZWx0YSA+PSAwID8gWV9TSE9SVF9WRUNUT1IgfCBZX0lTX1NBTUVfT1JfUE9TSVRJVkVfWV9TSE9SVF9WRUNUT1IgOiBZX1NIT1JUX1ZFQ1RPUjsKICAgICAgICAgICAgeUNvb3JkaW5hdGVzLnB1c2goYWJzKTsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHlDb29yZGluYXRlcy5wdXNoKGRlbHRhKTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgbGFzdFkgPSB5OwogICAgICAgIGZsYWdzLnB1c2goZmxhZyk7CiAgICAgIH0KICAgICAgYnVmLnNldFVpbnQxNihwb3MsIHhDb29yZGluYXRlcy5sZW5ndGggLSAxKTsKICAgICAgcG9zICs9IDI7CiAgICB9CiAgICBidWYuc2V0VWludDE2KHBvcywgdGhpcy5pbnN0cnVjdGlvbnMubGVuZ3RoKTsKICAgIHBvcyArPSAyOwogICAgaWYgKHRoaXMuaW5zdHJ1Y3Rpb25zLmxlbmd0aCkgewogICAgICBuZXcgVWludDhBcnJ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gcG9zICs9IDQ7CiAgICBpZiAodGhpcy5mbGFncyAmIEFSR18xX0FORF8yX0FSRV9XT1JEUykgewogICAgICBpZiAodGhpcy5mbGFncyAmIEFSR1NfQVJFX1hZX1ZBTFVFUykgewogICAgICAgIGJ1Zi5zZXRJbnQxNihwb3MsIHRoaXMuYXJndW1lbnQxKTsKICAgICAgICBidWYuc2V0SW50MTYocG9zICsgMiwgdGhpcy5hcmd1bWVudDIpOwogICAgICB9IGVsc2UgewogICAgICAgIGJ1Zi5zZXRVaW50MTYocG9zLCB0aGlzLmFyZ3VtZW50MSk7CiAgICAgICAgYnVmLnNldFVpbnQxNihwb3MgKyAyLCB0aGlzLmFyZ3VtZW50Mik7CiAgICAgIH0KICAgICAgcG9zICs9IDQ7CiAgICB9IGVsc2UgewogICAgICBidWYuc2V0VWludDgocG9zLCB0aGlzLmFyZ3VtZW50MSk7CiAgICAgIGJ1Zi5zZXRVaW50OChwb3MgKyAxLCB0aGlzLmFyZ3VtZW50Mik7CiAgICAgIHBvcyArPSAyOwogICAgfQogICAgaWYgKHRoaXMuZmxhZ3MgJiBXRV9IQVZFX0lOU1RSVUNUSU9OUykgewogICAgICBidWYuc2V0VWludDE2KHBvcywgdGhpcy5pbnN0cnVjdGlvbnMubGVuZ3RoKTsKICAgICAgcG9zICs9IDI7CiAgICAgIGlmICh0aGlzLmluc3RydWN0aW9ucy5sZW5ndGgpIHsKICAgICAgICBuZXcgVWludDhBcnJheShidWYuYnVmZmVyLCAwLCBidWYuYnVmZmVyLmJ5dGVMZW5ndGgpLnNldCh0aGlzLmluc3RydWN0aW9ucywgcG9zKTsKICAgICAgICBwb3MgKz0gdGhpcy5pbnN0cnVjdGlvbnMubGVuZ3RoOwogICAgICB9CiAgICB9CiAgICByZXR1cm4gcG9zIC0gc3BvczsKICB9CiAgc2NhbGUoeCwgZmFjdG9yKSB7fQp9CgovKioqLyB9KSwKLyogMTgyICovCi8qKiovICgoX191bnVzZWRfd2VicGFja19tb2R1bGUsIGV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0cHV0ID0gW107CiAgICB0aGlzLnN0YWNrID0gW107CiAgfQogIGNvbnZlcnQoZW5jb2RlZCwgc3VicnMsIHNlYWNBbmFseXNpc0VuYWJsZWQpIHsKICAgIGNvbnN0IGNvdW50ID0gZW5jb2RlZC5sZW5ndGg7CiAgICBsZXQgZXJyb3IgPSBmYWxzZTsKICAgIGxldCB3eCwgc2J4LCBzdWJyTnVtYmVyOwogICAgZm9yIChsZXQgaSA9IDA7IGkgPCBjb3VudDsgaSsrKSB7CiAgICAgIGxldCB2YWx1ZSA9IGVuY29kZWRbaV07CiAgICAgIGlmICh2YWx1ZSA8IDMyKSB7CiAgICAgICAgaWYgKHZhbHVlID09PSAxMikgewogICAgICAgICAgdmFsdWUgPSAodmFsdWUgPDwgOCkgKyBlbmNvZGVkWysraV07CiAgICAgICAgfQogICAgICAgIHN3aXRjaCAodmFsdWUpIHsKICAgICAgICAgIGNhc2UgMToKICAgICAgICAgICAgaWYgKCFISU5USU5HX0VOQUJMRUQpIHsKICAgICAgICAgICAgICB0aGlzLnN0YWNrID0gW107CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZXJyb3IgPSB0aGlzLmV4ZWN1dGVDb21tYW5kKDIsIENPTU1BTkRfTUFQLmhzdGVtKTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIDM6CiAgICAgICAgICAgIGlmICghSElOVElOR19FTkFCTEVEKSB7CiAgICAgICAgICAgICAgdGhpcy5zdGFjayA9IFtdOwogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGVycm9yID0gdGhpcy5leGVjdXRlQ29tbWFuZCgyLCBDT01NQU5EX01BUC52c3RlbSk7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSA0OgogICAgICAgICAgICBpZiAodGhpcy5mbGV4aW5nKSB7CiAgICAgICAgICAgICAgaWYgKHRoaXMuc3RhY2subGVuZ3RoIDwgMSkgewogICAgICAgICAgICAgICAgZXJyb3IgPSB0cnVlOwogICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIGNvbnN0IGR5ID0gdGhpcy5zdGFjay5wb3AoKTsKICAgICAgICAgICAgICB0aGlzLnN0YWNrLnB1c2goMCwgZHkpOwogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGVycm9yID0gdGhpcy5leGVjdXRlQ29tbWFuZCgxLCBDT01NQU5EX01BUC52bW92ZXRvKTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIDU6CiAgICAgICAgICAgIGVycm9yID0gdGhpcy5leGVjdXRlQ29tbWFuZCgyLCBDT01NQU5EX01BUC5ybGluZXRvKTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIDY6CiAgICAgICAgICAgIGVycm9yID0gdGhpcy5leGVjdXRlQ29tbWFuZCgxLCBDT01NQU5EX01BUC5obGluZXRvKTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIDc6CiAgICAgICAgICAgIGVycm9yID0gdGhpcy5leGVjdXRlQ29tbWFuZCgxLCBDT01NQU5EX01BUC52bGluZXRvKTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIDg6CiAgICAgICAgICAgIGVycm9yID0gdGhpcy5leGVjdXRlQ29tbWFuZCg2LCBDT01NQU5EX01BUC5ycmN1cnZldG8pOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgOToKICAgICAgICAgICAgdGhpcy5zdGFjayA9IFtdOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgMTA6CiAgICAgICAgICAgIGlmICh0aGlzLnN0YWNrLmxlbmd0aCA8IDEpIHsKICAgICAgICAgICAgICBlcnJvciA9IHRydWU7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgc3Vick51bWJlciA9IHRoaXMuc3RhY2sucG9wKCk7CiAgICAgICAgICAgIGlmICghc3VicnNbc3Vick51bWJlcl0pIHsKICAgICAgICAgICAgICBlcnJvciA9IHRydWU7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZXJyb3IgPSB0aGlzLmNvbnZlcnQoc3VicnNbc3Vick51bWJlcl0sIHN1YnJzLCBzZWFjQW5hbHlzaXNFbmFibGVkKTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIDExOgogICAgICAgICAgICByZXR1cm4gZXJyb3I7CiAgICAgICAgICBjYXNlIDEzOgogICAgICAgICAgICBpZiAodGhpcy5zdGFjay5sZW5ndGggPCAyKSB7CiAgICAgICAgICAgICAgZXJyb3IgPSB0cnVlOwogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICB9CiAgICAgICAgICAgIHd4ID0gdGhpcy5zdGFjay5wb3AoKTsKICAgICAgICAgICAgc2J4ID0gdGhpcy5zdGFjay5wb3AoKTsKICAgICAgICAgICAgdGhpcy5sc2IgPSBzYng7CiAgICAgICAgICAgIHRoaXMud2lkdGggPSB3eDsKICAgICAgICAgICAgdGhpcy5zdGFjay5wdXNoKHd4LCBzYngpOwogICAgICAgICAgICBlcnJvciA9IHRoaXMuZXhlY3V0ZUNvbW1hbmQoMiwgQ09NTUFORF9NQVAuaG1vdmV0byk7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAxNDoKICAgICAgICAgICAgdGhpcy5vdXRwdXQucHVzaChDT01NQU5EX01BUC5lbmRjaGFyWzBdKTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIDIxOgogICAgICAgICAgICBpZiAodGhpcy5mbGV4aW5nKSB7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZXJyb3IgPSB0aGlzLmV4ZWN1dGVDb21tYW5kKDIsIENPTU1BTkRfTUFQLnJtb3ZldG8pOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgMjI6CiAgICAgICAgICAgIGlmICh0aGlzLmZsZXhpbmcpIHsKICAgICAgICAgICAgICB0aGlzLnN0YWNrLnB1c2goMCk7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZXJyb3IgPSB0aGlzLmV4ZWN1dGVDb21tYW5kKDEsIENPTU1BTkRfTUFQLmhtb3ZldG8pOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgMzA6CiAgICAgICAgICAgIGVycm9yID0gdGhpcy5leGVjdXRlQ29tbWFuZCg0LCBDT01NQU5EX01BUC52aGN1cnZldG8pOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgMzE6CiAgICAgICAgICAgIGVycm9yID0gdGhpcy5leGVjdXRlQ29tbWFuZCg0LCBDT01NQU5EX01BUC5odmN1cnZldG8pOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgKDEyIDw8IDgpICsgMDoKICAgICAgICAgICAgdGhpcy5zdGFjayA9IFtdOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgKDEyIDw8IDgpICsgMToKICAgICAgICAgICAgaWYgKCFISU5USU5HX0VOQUJMRUQpIHsKICAgICAgICAgICAgICB0aGlzLnN0YWNrID0gW107CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZXJyb3IgPSB0aGlzLmV4ZWN1dGVDb21tYW5kKDIsIENPTU1BTkRfTUFQLnZzdGVtKTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlICgxMiA8PCA4KSArIDI6CiAgICAgICAgICAgIGlmICghSElOVElOR19FTkFCTEVEKSB7CiAgICAgICAgICAgICAgdGhpcy5zdGFjayA9IFtdOwogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGVycm9yID0gdGhpcy5leGVjdXRlQ29tbWFuZCgyLCBDT01NQU5EX01BUC5oc3RlbSk7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAoMTIgPDwgOCkgKyA2OgogICAgICAgICAgICBpZiAoc2VhY0FuYWx5c2lzRW5hYmxlZCkgewogICAgICAgICAgICAgIGNvbnN0IGFzYiA9IHRoaXMuc3RhY2suYXQoLTUpOwogICAgICAgICAgICAgIHRoaXMuc2VhYyA9IHRoaXMuc3RhY2suc3BsaWNlKC00LCA0KTsKICAgICAgICAgICAgICB0aGlzLnNlYWNbMF0gKz0gdGhpcy5sc2IgLSBhc2I7CiAgICAgICAgICAgICAgZXJyb3IgPSB0aGlzLmV4ZWN1dGVDb21tYW5kKDAsIENPTU1BTkRfTUFQLmVuZGNoYXIpOwogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgIGVycm9yID0gdGhpcy5leGVjdXRlQ29tbWFuZCg0LCBDT01NQU5EX01BUC5lbmRjaGFyKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgKDEyIDw8IDgpICsgNzoKICAgICAgICAgICAgaWYgKHRoaXMuc3RhY2subGVuZ3RoIDwgNCkgewogICAgICAgICAgICAgIGVycm9yID0gdHJ1ZTsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgfQogICAgICAgICAgICB0aGlzLnN0YWNrLnBvcCgpOwogICAgICAgICAgICB3eCA9IHRoaXMuc3RhY2sucG9wKCk7CiAgICAgICAgICAgIGNvbnN0IHNieSA9IHRoaXMuc3RhY2sucG9wKCk7CiAgICAgICAgICAgIHNieCA9IHRoaXMuc3RhY2sucG9wKCk7CiAgICAgICAgICAgIHRoaXMubHNiID0gc2J4OwogICAgICAgICAgICB0aGlzLndpZHRoID0gd3g7CiAgICAgICAgICAgIHRoaXMuc3RhY2sucHVzaCh3eCwgc2J4LCBzYnkpOwogICAgICAgICAgICBlcnJvciA9IHRoaXMuZXhlY3V0ZUNvbW1hbmQoMywgQ09NTUFORF9NQVAucm1vdmV0byk7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAoMTIgPDwgOCkgKyAxMjoKICAgICAgICAgICAgaWYgKHRoaXMuc3RhY2subGVuZ3RoIDwgMikgewogICAgICAgICAgICAgIGVycm9yID0gdHJ1ZTsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgfQogICAgICAgICAgICBjb25zdCBudW0yID0gdGhpcy5zdGFjay5wb3AoKTsKICAgICAgICAgICAgY29uc3QgbnVtMSA9IHRoaXMuc3RhY2sucG9wKCk7CiAgICAgICAgICAgIHRoaXMuc3RhY2sucHVzaChudW0xIC8gbnVtMik7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAoMTIgPDwgOCkgKyAxNjoKICAgICAgICAgICAgaWYgKHRoaXMuc3RhY2subGVuZ3RoIDwgMikgewogICAgICAgICAgICAgIGVycm9yID0gdHJ1ZTsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgfQogICAgICAgICAgICBzdWJyTnVtYmVyID0gdGhpcy5zdGFjay5wb3AoKTsKICAgICAgICAgICAgY29uc3QgbnVtQXJncyA9IHRoaXMuc3RhY2sucG9wKCk7CiAgICAgICAgICAgIGlmIChzdWJyTnVtYmVyID09PSAwICYmIG51bUFyZ3MgPT09IDMpIHsKICAgICAgICAgICAgICBjb25zdCBmbGV4QXJncyA9IHRoaXMuc3RhY2suc3BsaWNlKC0xNywgMTcpOwogICAgICAgICAgICAgIHRoaXMuc3RhY2sucHVzaChmbGV4QXJnc1syXSArIGZsZXhBcmdzWzBdLCBmbGV4QXJnc1szXSArIGZsZXhBcmdzWzFdLCBmbGV4QXJnc1s0XSwgZmxleEFyZ3NbNV0sIGZsZXhBcmdzWzZdLCBmbGV4QXJnc1s3XSwgZmxleEFyZ3NbOF0sIGZsZXhBcmdzWzldLCBmbGV4QXJnc1sxMF0sIGZsZXhBcmdzWzExXSwgZmxleEFyZ3NbMTJdLCBmbGV4QXJnc1sxM10sIGZsZXhBcmdzWzE0XSk7CiAgICAgICAgICAgICAgZXJyb3IgPSB0aGlzLmV4ZWN1dGVDb21tYW5kKDEzLCBDT01NQU5EX01BUC5mbGV4LCB0cnVlKTsKICAgICAgICAgICAgICB0aGlzLmZsZXhpbmcgPSBmYWxzZTsKICAgICAgICAgICAgICB0aGlzLnN0YWNrLnB1c2goZmxleEFyZ3NbMTVdLCBmbGV4QXJnc1sxNl0pOwogICAgICAgICAgICB9IGVsc2UgaWYgKHN1YnJOdW1iZXIgPT09IDEgJiYgbnVtQXJncyA9PT0gMCkgewogICAgICAgICAgICAgIHRoaXMuZmxleGluZyA9IHRydWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlICgxMiA8PCA4KSArIDE3OgogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgKDEyIDw8IDgpICsgMzM6CiAgICAgICAgICAgIHRoaXMuc3RhY2sgPSBbXTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAoMCwgX3V0aWwud2FybikoJ1Vua25vd24gdHlwZSAxIGNoYXJzdHJpbmcgY29tbWFuZCBvZiAiJyArIHZhbHVlICsgJyInKTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICAgIGlmIChlcnJvcikgewogICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICAgIGNvbnRpbnVlOwogICAgICB9IGVsc2UgaWYgKHZhbHVlIDw9IDI0NikgewogICAgICAgIHZhbHVlIC09IDEzOTsKICAgICAgfSBlbHNlIGlmICh2YWx1ZSA8PSAyNTApIHsKICAgICAgICB2YWx1ZSA9ICh2YWx1ZSAtIDI0NykgKiAyNTYgKyBlbmNvZGVkWysraV0gKyAxMDg7CiAgICAgIH0gZWxzZSBpZiAodmFsdWUgPD0gMjU0KSB7CiAgICAgICAgdmFsdWUgPSAtKCh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BpZiAodG9rZW4gPT09IG51bGwgfHwgdG9rZW4gPT09ICJdIiB8fCB0b2tlbiA9PT0gIn0iKSB7CiAgICAgICAgYnJlYWs7CiAgICAgIH0KICAgICAgYXJyYXkucHVzaChwYXJzZUZsb2F0KHRva2VuIHx8IDApKTsKICAgIH0KICAgIHJldHVybiBhcnJheTsKICB9CiAgcmVhZE51bWJlcigpIHsKICAgIGNvbnN0IHRva2VuID0gdGhpcy5nZXRUb2tlbigpOwogICAgcmV0dXJuIHBhcnNlRmxvYXQodG9rZW4gfHwgMCk7CiAgfQogIHJlYWRJbnQoKSB7CiAgICBjb25zdCB0b2tlbiA9IHRoaXMuZ2V0VG9rZW4oKTsKICAgIHJldHVybiBwYXJzZUludCh0b2tlbiB8fCAwLCAxMCkgfCAwOwogIH0KICByZWFkQm9vbGVhbigpIHsKICAgIGNvbnN0IHRva2VuID0gdGhpcy5nZXRUb2tlbigpOwogICAgcmV0dXJuIHRva2VuID09PSAidHJ1ZSIgPyAxIDogMDsKICB9CiAgbmV4dENoYXIoKSB7CiAgICByZXR1cm4gdGhpcy5jdXJyZW50Q2hhciA9IHRoaXMuc3RyZWFtLmdldEJ5dGUoKTsKICB9CiAgcHJldkNoYXIoKSB7CiAgICB0aGlzLnN0cmVhbS5za2lwKC0yKTsKICAgIHJldHVybiB0aGlzLmN1cnJlbnRDaGFyID0gdGhpcy5zdHJlYW0uZ2V0Qnl0ZSgpOwogIH0KICBnZXRUb2tlbigpIHsKICAgIGxldCBjb21tZW50ID0gZmFsc2U7CiAgICBsZXQgY2ggPSB0aGlzLmN1cnJlbnRDaGFyOwogICAgd2hpbGUgKHRydWUpIHsKICAgICAgaWYgKGNoID09PSAtMSkgewogICAgICAgIHJldHVybiBudWxsOwogICAgICB9CiAgICAgIGlmIChjb21tZW50KSB7CiAgICAgICAgaWYgKGNoID09PSAweDBhIHx8IGNoID09PSAweDBkKSB7CiAgICAgICAgICBjb21tZW50ID0gZmFsc2U7CiAgICAgICAgfQogICAgICB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SwKICAgICAgcHJvcGVydGllczogewogICAgICAgIHByaXZhdGVEYXRhCiAgICAgIH0KICAgIH07CiAgICBsZXQgdG9rZW4sIGxlbmd0aCwgZGF0YSwgbGVuSVY7CiAgICB3aGlsZSAoKHRva2VuID0gdGhpcy5nZXRUb2tlbigpKSAhPT0gbnVsbCkgewogICAgICBpZiAodG9rZW4gIT09ICIvIikgewogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIHRva2VuID0gdGhpcy5nZXRUb2tlbigpOwogICAgICBzd2l0Y2ggKHRva2VuKSB7CiAgICAgICAgY2FzZSAiQ2hhclN0cmluZ3MiOgogICAgICAgICAgdGhpcy5nZXRUb2tlbigpOwogICAgICAgICAgdGhpcy5nZXRUb2tlbigpOwogICAgICAgICAgdGhpcy5nZXRUb2tlbigpOwogICAgICAgICAgdGhpcy5nZXRUb2tlbigpOwogICAgICAgICAgd2hpbGUgKHRydWUpIHsKICAgICAgICAgICAgdG9rZW4gPSB0aGlzLmdldFRva2VuKCk7CiAgICAgICAgICAgIGlmICh0b2tlbiA9PT0gbnVsbCB8fCB0b2tlbiA9PT0gImVuZCIpIHsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAodG9rZW4gIT09ICIvIikgewogICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGNvbnN0IGdseXBoID0gdGhpcy5nZXRUb2tlbigpOwogICAgICAgICAgICBsZW5ndGggPSB0aGlzLnJlYWRJbnQoKTsKICAgICAgICAgICAgdGhpcy5nZXRUb2tlbigpOwogICAgICAgICAgICBkYXRhID0gbGVuZ3RoID4gMCA/IHN0cmVhbS5nZXRCeXRlcyhsZW5ndGgpIDogbmV3IFVpbnQ4QXJyYXkoMCk7CiAgICAgICAgICAgIGxlbklWID0gcHJvZ3JhbS5wcm9wZXJ0aWVzLnByaXZhdGVEYXRhLmxlbklWOwogICAgICAgICAgICBjb25zdCBlbmNvZGVkID0gdGhpcy5yZWFkQ2hhclN0cmluZ3MoZGF0YSwgbGVuSVYpOwogICAgICAgICAgICB0aGlzLm5leHRDaGFyKCk7CiAgICAgICAgICAgIHRva2VuID0gdGhpcy5nZXRUb2tlbigpOwogICAgICAgICAgICBpZiAodG9rZW4gPT09ICJub2FjY2VzcyIpIHsKICAgICAgICAgICAgICB0aGlzLmdldFRva2VuKCk7CiAgICAgICAgICAgIH0gZWxzZSBpZiAodG9rZW4gPT09ICIvIikgewogICAgICAgICAgICAgIHRoaXMucHJldkNoYXIoKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBjaGFyc3RyaW5ncy5wdXNoKHsKICAgICAgICAgICAgICBnbHlwaCwKICAgICAgICAgICAgICBlbmNvZGVkCiAgICAgICAgICAgIH0pOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiU3VicnMiOgogICAgICAgICAgdGhpcy5yZWFkSW50KCk7CiAgICAgICAgICB0aGlzLmdldFRva2VuKCk7CiAgICAgICAgICB3aGlsZSAodGhpcy5nZXRUb2tlbigpID09PSAiZHVwIikgewogICAgICAgICAgICBjb25zdCBpbmRleCA9IHRoaXMucmVhZEludCgpOwogICAgICAgICAgICBsZW5ndGggPSB0aGlzLnJlYWRJbnQoKTsKICAgICAgICAgICAgdGhpcy5nZXRUb2tlbigpOwogICAgICAgICAgICBkYXRhID0gbGVuZ3RoID4gMCA/IHN0cmVhbS5nZXRCeXRlcyhsZW5ndGgpIDogbmV3IFVpbnQ4QXJyYXkoMCk7CiAgICAgICAgICAgIGxlbklWID0gcHJvZ3JhbS5wcm9wZXJ0aWVzLnByaXZhdGVEYXRhLmxlbklWOwogICAgICAgICAgICBjb25zdCBlbmNvZGVkID0gdGhpcy5yZWFkQ2hhclN0cmluZ3MoZGF0YSwgbGVuSVYpOwogICAgICAgICAgICB0aGlzLm5leHRDaGFyKCk7CiAgICAgICAgICAgIHRva2VuID0gdGhpcy5nZXRUb2tlbigpOwogICAgICAgICAgICBpZiAodG9rZW4gPT09ICJub2FjY2VzcyIpIHsKICAgICAgICAgICAgICB0aGlzLmdldFRva2VuKCk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgc3VicnNbaW5kZXhdID0gZW5jb2RlZDsKICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgIkJsdWVWYWx1ZXMiOgogICAgICAgIGNhc2UgIk90aGVyQmx1ZXMiOgogICAgICAgIGNhc2UgIkZhbWlseUJsdWVzIjoKICAgICAgICBjYXNlICJGYW1pbHlPdGhlckJsdWVzIjoKICAgICAgICAgIGNvbnN0IGJsdWVBcnJheSA9IHRoaXMucmVhZE51bWJlckFycmF5KCk7CiAgICAgICAgICBpZiAoYmx1ZUFycmF5Lmxlbmd0aCA+IDAgJiYgYmx1ZUFycmF5Lmxlbmd0aCAlIDIgPT09IDAgJiYgSElOVElOR19FTkFCTEVEKSB7CiAgICAgICAgICAgIHByb2dyYW0ucHJvcGVydGllcy5wcml2YXRlRGF0YVt0b2tlbl0gPSBibHVlQXJyYXk7CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJTdGVtU25hcEgiOgogICAgICAgIGNhc2UgIlN0ZW1TbmFwViI6CiAgICAgICAgICBwcm9ncmFtLnByb3BlcnRpZXMucHJpdmF0ZURhdGFbdG9rZW5dID0gdGhpcy5yZWFkTnVtYmVyQXJyYXkoKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgIlN0ZEhXIjoKICAgICAgICBjYXNlICJTdGRWVyI6CiAgICAgICAgICBwcm9ncmFtLnByb3BlcnRpZXMucHJpdmF0ZURhdGFbdG9rZW5dID0gdGhpcy5yZWFkTnVtYmVyQXJyYXkoKVswXTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgIkJsdWVTaGlmdCI6CiAgICAgICAgY2FzZSAibGVuSVYiOgogICAgICAgIGNhc2UgIkJsdWVGdXp6IjoKICAgICAgICBjYXNlICJCbHVlU2NhbGUiOgogICAgICAgIGNhc2UgIkxhbmd1YWdlR3JvdXAiOgogICAgICAgICAgcHJvZ3JhbS5wcm9wZXJ0aWVzLnByaXZhdGVEYXRhW3Rva2VuXSA9IHRoaXMucmVhZE51bWJlcigpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiRXhwYW5zaW9uRmFjdG9yIjoKICAgICAgICAgIHByb2dyYW0ucHJvcGVydGllcy5wcml2YXRlRGF0YVt0b2tlbl0gPSB0aGlzLnJlYWROdW1iZXIoKSB8fCAwLjA2OwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiRm9yY2VCb2xkIjoKICAgICAgICAgIHByb2dyYW0ucHJvcGVydGllcy5wcml2YXRlRGF0YVt0b2tlbl0gPSB0aGlzLnJlYWRCb29sZWFuKCk7CiAgICAgICAgICBicmVhazsKICAgICAgfQogICAgfQogICAgZm9yIChjb25zdCB7CiAgICAgIGVuY29kZWQsCiAgICAgIGdseXBoCiAgICB9IG9mIGNoYXJzdHJpbmdzKSB7CiAgICAgIGNvbnN0IGNoYXJTdHJpbmcgPSBuZXcgVHlwZTFDaGFyU3RyaW5nKCk7CiAgICAgIGNvbnN0IGVycm9yID0gY2hhclN0cmluZy5jb252ZXJ0KGVuY29kZWQsIHN1YnJzLCB0aGlzLnNlYWNBbmFseXNpc0VuYWJsZWQpOwogICAgICBsZXQgb3V0cHV0ID0gY2hhclN0cmluZy5vdXRwdXQ7CiAgICAgIGlmIChlcnJvcikgewogICAgICAgIG91dHB1dCA9IFsxNF07CiAgICAgIH0KICAgICAgY29uc3QgY2hhclN0cmluZ09iamVjdCA9IHsKICAgICAgICBnbHlwaE5hbWU6IGdseXBoLAogICAgICAgIGNoYXJzdHJpbmc6IG91dHB1dCwKICAgICAgICB3aWR0aDogY2hhclN0cmluZy53aWR0aCwKICAgICAgICBsc2I6IGNoYXJTdHJpbmcubHNiLAogICAgICAgIHNlYWM6IGNoYXJTdHJpbmcuc2VhYwogICAgICB9OwogICAgICBpZiAoZ2x5cGggPT09ICIubm90ZGVmIikgewogICAgICAgIHByb2dyYW0uY2hhcnN0cmluZ3MudW5zaGlmdChjaGFyU3RyaW5nT2JqZWN0KTsKICAgICAgfSBlbHNlIHsKICAgICAgICBwcm9ncmFtLmNoYXJzdHJpbmdzLnB1c2goY2hhclN0cmluZ09iamVjdCk7CiAgICAgIH0KICAgICAgaWYgKHByb3BlcnRpZXMuYnVpbHRJbkVuY29kaW5nKSB7CiAgICAgICAgY29uc3QgaW5kZXggPSBwcm9wZXJ0aWVzLmJ1aWx0SW5FbmNvZGluZy5pbmRleE9mKGdseXBoKTsKICAgICAgICBpZiAoaW5kZXggPiAtMSAmJiBwcm9wZXJ0aWVzLndpZHRoc1tpbmRleF0gPT09IHVuZGVmaW5lZCAmJiBpbmRleCA+PSBwcm9wZXJ0aWVzLmZpcnN0Q2hhciAmJiBpbmRleCA8PSBwcm9wZXJ0aWVzLmxhc3RDaGFyKSB7CiAgICAgICAgICBwcm9wZXJ0aWVzLndpZHRoc1tpbmRleF0gPSBjaGFyU3RyaW5nLndpZHRoOwogICAgICAgIH0KICAgICAgfQogICAgfQogICAgcmV0dXJuIHByb2dyYW07CiAgfQogIGV4dHJhY3RGb250SGVhZGVyKHByb3BlcnRpZXMpIHsKICAgIGxldCB0b2tlbjsKICAgIHdoaWxlICgodG9rZW4gPSB0aGlzLmdldFRva2VuKCkpICE9PSBudWxsKSB7CiAgICAgIGlmICh0b2tlbiAhPT0gIi8iKSB7CiAgICAgICAgY29udGludWU7CiAgICAgIH0KICAgICAgdG9rZW4gPSB0aGlzLmdldFRva2VuKCk7CiAgICAgIHN3aXRjaCAodG9rZW4pIHsKICAgICAgICBjYXNlICJGb250TWF0cml4IjoKICAgICAgICAgIGNvbnN0IG1hdHJpeCA9IHRoaXMucmVhZE51bWJlckFycmF5KCk7CiAgICAgICAgICBwcm9wZXJ0aWVzLmZvbnRNYXRyaXggPSBtYXRyaXg7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJFbmNvZGluZyI6CiAgICAgICAgICBjb25zdCBlbmNvZGluZ0FyZyA9IHRoaXMuZ2V0VG9rZW4oKTsKICAgICAgICAgIGxldCBlbmNvZGluZzsKICAgICAgICAgIGlmICghL15cZCskLy50ZXN0KGVuY29kaW5nQXJnKSkgewogICAgICAgICAgICBlbmNvZGluZyA9ICgwLCBfZW5jb2RpbmdzLmdldEVuY29kaW5nKShlbmNvZGluZ0FyZyk7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBlbmNvZGluZyA9IFtdOwogICAgICAgICAgICBjb25zdCBzaXplID0gcGFyc2VJbnQoZW5jb2RpbmdBcmcsIDEwKSB8IDA7CiAgICAgICAgICAgIHRoaXMuZ2V0VG9rZW4oKTsKICAgICAgICAgICAgZm9yIChsZXQgaiA9IDA7IGogPCBzaXplOyBqKyspIHsKICAgICAgICAgICAgICB0b2tlbiA9IHRoaXMuZ2V0VG9rZW4oKTsKICAgICAgICAgICAgICB3aGlsZSAodG9rZW4gIT09ICJkdXAiICYmIHRva2VuICE9PSAiZGVmIikgewogICAgICAgICAgICAgICAgdG9rZW4gPSB0aGlzLmdldFRva2VuKCk7CiAgICAgICAgICAgICAgICBpZiAodG9rZW4gPT09IG51bGwpIHsKICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBpZiAodG9rZW4gPT09ICJkZWYiKSB7CiAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgY29uc3QgaW5kZXggPSB0aGlzLnJlYWRJbnQoKTsKICAgICAgICAgICAgICB0aGlzLmdldFRva2VuKCk7CiAgICAgICAgICAgICAgY29uc3QgZ2x5cGggPSB0aGlzLmdldFRva2VuKCk7CiAgICAgICAgICAgICAgZW5jb2RpbmdbaW5kZXhdID0gZ2x5cGg7CiAgICAgICAgICAgICAgdGhpcy5nZXRUb2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gYnJlYWs7CiAgICB9CiAgICBpZiAocGF0Y2hNZXNoKSB7CiAgICAgIHRoaXMuX3VwZGF0ZUJvdW5kcygpOwogICAgICBmb3IgKGxldCBpID0gMCwgaWkgPSB0aGlzLmZpZ3VyZXMubGVuZ3RoOyBpIDwgaWk7IGkrKykgewogICAgICAgIHRoaXMuX2J1aWxkRmlndXJlRnJvbVBhdGNoKGkpOwogICAgICB9CiAgICB9CiAgICB0aGlzLl91cGRhdGVCb3VuZHMoKTsKICAgIHRoaXMuX3BhY2tEYXRhKCk7CiAgfQogIF9kZWNvZGVUeXBlNFNoYWRpbmcocmVhZGVyKSB7CiAgICBjb25zdCBjb29yZHMgPSB0aGlzLmNvb3JkczsKICAgIGNvbnN0IGNvbG9ycyA9IHRoaXMuY29sb3JzOwogICAgY29uc3Qgb3BlcmF0b3JzID0gW107CiAgICBjb25zdCBwcyA9IFtdOwogICAgbGV0IHZlcnRpY2VzTGVmdCA9IDA7CiAgICB3aGlsZSAocmVhZGVyLmhhc0RhdGEpIHsKICAgICAgY29uc3QgZiA9IHJlYWRlci5yZWFkRmxhZygpOwogICAgICBjb25zdCBjb29yZCA9IHJlYWRlci5yZWFkQ29vcmRpbmF0ZSgpOwogICAgICBjb25zdCBjb2xvciA9IHJlYWRlci5yZWFkQ29tcG9uZW50cygpOwogICAgICBpZiAodmVydGljZXNMZWZ0ID09PSAwKSB7CiAgICAgICAgaWYgKCEoMCA8PSBmICYmIGYgPD0gMikpIHsKICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiVW5rbm93biB0eXBlNCBmbGFnIik7CiAgICAgICAgfQogICAgICAgIHN3aXRjaCAoZikgewogICAgICAgICAgY2FzZSAwOgogICAgICAgICAgICB2ZXJ0aWNlc0xlZnQgPSAzOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgMToKICAgICAgICAgICAgcHMucHVzaChwcy5hdCgtMiksIHBzLmF0KC0xKSk7CiAgICAgICAgICAgI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vb3JkczogbmV3IEludDMyQXJyYXkocHMpLAogICAgICBjb2xvcnM6IG5ldyBJbnQzMkFycmF5KHBzKSwKICAgICAgdmVydGljZXNQZXJSb3cKICAgIH0pOwogIH0KICBfZGVjb2RlVHlwZTZTaGFkaW5nKHJlYWRlcikgewogICAgY29uc3QgY29vcmRzID0gdGhpcy5jb29yZHM7CiAgICBjb25zdCBjb2xvcnMgPSB0aGlzLmNvbG9yczsKICAgIGNvbnN0IHBzID0gbmV3IEludDMyQXJyYXkoMTYpOwogICAgY29uc3QgY3MgPSBuZXcgSW50MzJBcnJheSg0KTsKICAgIHdoaWxlIChyZWFkZXIuaGFzRGF0YSkgewogICAgICBjb25zdCBmID0gcmVhZGVyLnJlYWRGbGFnKCk7CiAgICAgIGlmICghKDAgPD0gZiAmJiBmIDw9IDMpKSB7CiAgICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKCJVbmtub3duIHR5cGU2IGZsYWciKTsKICAgICAgfQogICAgICBjb25zdCBwaSA9IGNvb3Jkcy5sZW5ndGg7CiAgICAgIGZvciAobGV0IGkgPSAwLCBpaSA9IGYgIT09IDAgPyA4IDogMTI7IGkgPCBpaTsgaSsrKSB7CiAgICAgICAgY29vcmRzLnB1c2gocmVhZGVyLnJlYWRDb29yZGluYXRlKCkpOwogICAgICB9CiAgICAgIGNvbnN0IGNpID0gY29sb3JzLmxlbmd0aDsKICAgICAgZm9yIChsZXQgaSA9IDAsIGlpID0gZiAhPT0gMCA/IDIgOiA0OyBpIDwgaWk7IGkrKykgewogICAgICAgIGNvbG9ycy5wdXNoKHJlYWRlci5yZWFkQ29tcG9uZW50cygpKTsKICAgICAgfQogICAgICBsZXQgdG1wMSwgdG1wMiwgdG1wMywgdG1wNDsKICAgICAgc3dpdGNoIChmKSB7CiAgICAgICAgY2FzZSAwOgogICAgICAgICAgcHNbMTJdID0gcGkgKyAzOwogICAgICAgICAgcHNbMTNdID0gcGkgKyA0OwogICAgICAgICAgcHNbMTRdID0gcGkgKyA1OwogICAgICAgICAgcHNbMTVdID0gcGkgKyA2OwogICAgICAgICAgcHNbOF0gPSBwaSArIDI7CiAgICAgICAgICBwc1sxMV0gPSBwaSArIDc7CiAgICAgICAgICBwc1s0XSA9IHBpICsgMTsKICAgICAgICAgIHBzWzddID0gcGkgKyA4OwogICAgICAgICAgcHNbMF0gPSBwaTsKICAgICAgICAgIHBzWzFdID0gcGkgKyAxMTsKICAgICAgICAgIHBzWzJdID0gcGkgKyAxMDsKICAgICAgICAgIHBzWzNdID0gcGkgKyA5OwogICAgICAgICAgY3NbMl0gPSBjaSArIDE7CiAgICAgICAgICBjc1szXSA9IGNpICsgMjsKICAgICAgICAgIGNzWzBdID0gY2k7CiAgICAgICAgICBjc1sxXSA9IGNpICsgMzsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMToKICAgICAgICAgIHRtcDEgPSBwc1sxMl07CiAgICAgICAgICB0bXAyID0gcHNbMTNdOwogICAgICAgICAgdG1wMyA9IHBzWzE0XTsKICAgICAgICAgIHRtcDQgPSBwc1sxNV07CiAgICAgICAgICBwc1sxMl0gPSB0bXA0OwogICAgICAgICAgcHNbMTNdID0gcGkgKyAwOwogICAgICAgICAgcHNbMTRdID0gcGkgKyAxOwogICAgICAgICAgcHNbMTVdID0gcGkgKyAyOwogICAgICAgICAgcHNbOF0gPSB0bXAzOwogICAgICAgICAgcHNbMTFdID0gcGkgKyAzOwogICAgICAgICAgcHNbNF0gPSB0bXAyOwogICAgICAgICAgcHNbN10gPSBwaSArIDQ7CiAgICAgICAgICBwc1swXSA9IHRtcDE7CiAgICAgICAgICBwc1sxXSA9IHBpICsgNzsKICAgICAgICAgIHBzWzJdID0gcGkgKyA2OwogICAgICAgICAgcHNbM10gPSBwaSArIDU7CiAgICAgICAgICB0bXAxID0gY3NbMl07CiAgICAgICAgICB0bXAyID0gY3NbM107CiAgICAgICAgICBjc1syXSA9IHRtcDI7CiAgICAgICAgICBjc1szXSA9IGNpOwogICAgICAgICAgY3NbMF0gPSB0bXAxOwogICAgICAgICAgY3NbMV0gPSBjaSArIDE7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIDI6CiAgICAgICAgICB0bXAxID0gcHNbMTVdOwogICAgICAgICAgdG1wMiA9IHBzWzExXTsKICAgICAgICAgIHBzWzEyXSA9IHBzWzNdOwogICAgICAgICAgcHNbMTNdID0gcGkgKyAwOwogICAgICAgICAgcHNbMTRdID0gcGkgKyAxOwogICAgICAgICAgcHNbMTVdID0gcGkgKyAyOwogICAgICAgICAgcHNbOF0gPSBwc1s3XTsKICAgICAgICAgIHBzWzExXSA9IHBpICsgMzsKICAgICAgICAgIHBzWzRdID0gdG1wMjsKICAgICAgICAgIHBzWzddID0gcGkgKyA0OwogICAgICAgICAgcHNbMF0gPSB0bXAxOwogICAgICAgICAgcHNbMV0gPSBwaSArIDc7CiAgICAgICAgICBwc1syXSA9IHBpICsgNjsKICAgICAgICAgIHBzWzNdID0gcGkgKyA1OwogICAgICAgICAgdG1wMSA9IGNzWzNdOwogICAgICAgICAgY3NbMl0gPSBjc1sxXTsKICAgICAgICAgIGNzWzNdID0gY2k7CiAgICAgICAgICBjc1swXSA9IHRtcDE7CiAgICAgICAgICBjc1sxXSA9IGNpICsgMTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMzoKICAgICAgICAgIHBzWzEyXSA9IHBzWzBdOwogICAgICAgICAgcHNbMTNdID0gcGkgKyAwOwogICAgICAgICAgcHNbMTRdID0gcGkgKyAxOwogICAgICAgICAgcHNbMTVdID0gcGkgKyAyOwogICAgICAgICAgcHNbOF0gPSBwc1sxXTsKICAgICAgICAgIHBzWzExXSA9IHBpICsgMzsKICAgICAgICAgIHBzWzRdID0gcHNbMl07CiAgICAgICAgICBwc1s3XSA9IHBpICsgNDsKICAgICAgICAgIHBzWzBdID0gcHNbM107CiAgICAgICAgICBwc1sxXSA9IHBpICsgNzsKICAgICAgICAgIHBzWzJdID0gcGkgKyA2OwogICAgICAgICAgcHNbM10gPSBwaSArIDU7CiAgICAgICAgICBjc1syXSA9IGNzWzBdOwogICAgICAgICAgY3NbM10gPSBjaTsKICAgICAgICAgIGNzWzBdID0gY3NbMV07CiAgICAgICAgICBjc1sxXSA9IGNpICsgMTsKICAgICAgICAgIGJyZWFrOwogICAgICB9CiAgICAgIHBzWzVdID0gY29vcmRzLmxlbmd0aDsKICAgICAgY29vcmRzLnB1c2goWygtNCAqIGNvb3Jkc1twc1swXV1bMF0gLSBjb29yZHNbcHNbMTVdXVswXSArIDYgKiAoY29vcmRzW3BzWzRdXVswXSArIGNvb3Jkc1twc1sxXV1bMF0pIC0gMiAqIChjb29yZHNbcHNbMTJdXVswXSArIGNvb3Jkc1twc1szXV1bMF0pICsgMyAqIChjb29yZHNbcHNbMTNdXVswXSArIGNvb3Jkc1twc1s3XV1bMF0pKSAvIDksICgtNCAqIGNvb3Jkc1twc1swXV1bMV0gLSBjb29yZHNbcHNbMTVdXVsxXSArIDYgKiAoY29vcmRzW3BzWzRdXVsxXSArIGNvb3Jkc1twc1sxXV1bMV0pIC0gMiAqIChjb29yZHNbcHNbMTJdXVsxXSArIGNvb3Jkc1twc1szXV1bMV0pICsgMyAqIChjb29yZHNbcHNbMTNdXVsxXSArIGNvb3Jkc1twc1s3XV1bMV0pKSAvIDldKTsKICAgICAgcHNbNl0gPSBjb29yZHMubGVuZ3RoOwogICAgICBjb29yZHMucHVzaChbKC00ICogY29vcmRzW3BzWzNdXVswXSAtIGNvb3Jkc1twc1sxMl1dWzBdICsgNiAqIChjb29yZHNbcHNbMl1dWzBdICsgY29vcmRzW3BzWzddXVswXSkgLSAyICogKGNvb3Jkc1twc1swXV1bMF0gKyBjb29yZHNbcHNbMTVdXVswXSkgKyAzICogKGNvb3Jkc1twc1s0XV1bMF0gKyBjb29yZHNbcHNbMTRdXVswXSkpIC8gOSwgKC00ICogY29vcmRzW3BzWzNdXVsxXSAtIGNvb3Jkc1twc1sxMl1dWzFdICsgNiAqIChjb29y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sgaSsrKSB7CiAgICAgICAgY29sb3JzLnB1c2gocmVhZGVyLnJlYWRDb21wb25lbnRzKCkpOwogICAgICB9CiAgICAgIGxldCB0bXAxLCB0bXAyLCB0bXAzLCB0bXA0OwogICAgICBzd2l0Y2ggKGYpIHsKICAgICAgICBjYXNlIDA6CiAgICAgICAgICBwc1sxMl0gPSBwaSArIDM7CiAgICAgICAgICBwc1sxM10gPSBwaSArIDQ7CiAgICAgICAgICBwc1sxNF0gPSBwaSArIDU7CiAgICAgICAgICBwc1sxNV0gPSBwaSArIDY7CiAgICAgICAgICBwc1s4XSA9IHBpICsgMjsKICAgICAgICAgIHBzWzldID0gcGkgKyAxMzsKICAgICAgICAgIHBzWzEwXSA9IHBpICsgMTQ7CiAgICAgICAgICBwc1sxMV0gPSBwaSArIDc7CiAgICAgICAgICBwc1s0XSA9IHBpICsgMTsKICAgICAgICAgIHBzWzVdID0gcGkgKyAxMjsKICAgICAgICAgIHBzWzZdID0gcGkgKyAxNTsKICAgICAgICAgIHBzWzddID0gcGkgKyA4OwogICAgICAgICAgcHNbMF0gPSBwaTsKICAgICAgICAgIHBzWzFdID0gcGkgKyAxMTsKICAgICAgICAgIHBzWzJdID0gcGkgKyAxMDsKICAgICAgICAgIHBzWzNdID0gcGkgKyA5OwogICAgICAgICAgY3NbMl0gPSBjaSArIDE7CiAgICAgICAgICBjc1szXSA9IGNpICsgMjsKICAgICAgICAgIGNzWzBdID0gY2k7CiAgICAgICAgICBjc1sxXSA9IGNpICsgMzsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMToKICAgICAgICAgIHRtcDEgPSBwc1sxMl07CiAgICAgICAgICB0bXAyID0gcHNbMTNdOwogICAgICAgICAgdG1wMyA9IHBzWzE0XTsKICAgICAgICAgIHRtcDQgPSBwc1sxNV07CiAgICAgICAgICBwc1sxMl0gPSB0bXA0OwogICAgICAgICAgcHNbMTNdID0gcGkgKyAwOwogICAgICAgICAgcHNbMTRdID0gcGkgKyAxOwogICAgICAgICAgcHNbMTVdID0gcGkgKyAyOwogICAgICAgICAgcHNbOF0gPSB0bXAzOwogICAgICAgICAgcHNbOV0gPSBwaSArIDk7CiAgICAgICAgICBwc1sxMF0gPSBwaSArIDEwOwogICAgICAgICAgcHNbMTFdID0gcGkgKyAzOwogICAgICAgICAgcHNbNF0gPSB0bXAyOwogICAgICAgICAgcHNbNV0gPSBwaSArIDg7CiAgICAgICAgICBwc1s2XSA9IHBpICsgMTE7CiAgICAgICAgICBwc1s3XSA9IHBpICsgNDsKICAgICAgICAgIHBzWzBdID0gdG1wMTsKICAgICAgICAgIHBzWzFdID0gcGkgKyA3OwogICAgICAgICAgcHNbMl0gPSBwaSArIDY7CiAgICAgICAgICBwc1szXSA9IHBpICsgNTsKICAgICAgICAgIHRtcDEgPSBjc1syXTsKICAgICAgICAgIHRtcDIgPSBjc1szXTsKICAgICAgICAgIGNzWzJdID0gdG1wMjsKICAgICAgICAgIGNzWzNdID0gY2k7CiAgICAgICAgICBjc1swXSA9IHRtcDE7CiAgICAgICAgICBjc1sxXSA9IGNpICsgMTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMjoKICAgICAgICAgIHRtcDEgPSBwc1sxNV07CiAgICAgICAgICB0bXAyID0gcHNbMTFdOwogICAgICAgICAgcHNbMTJdID0gcHNbM107CiAgICAgICAgICBwc1sxM10gPSBwaSArIDA7CiAgICAgICAgICBwc1sxNF0gPSBwaSArIDE7CiAgICAgICAgICBwc1sxNV0gPSBwaSArIDI7CiAgICAgICAgICBwc1s4XSA9IHBzWzddOwogICAgICAgICAgcHNbOV0gPSBwaSArIDk7CiAgICAgICAgICBwc1sxMF0gPSBwaSArIDEwOwogICAgICAgICAgcHNbMTFdID0gcGkgKyAzOwogICAgICAgICAgcHNbNF0gPSB0bXAyOwogICAgICAgICAgcHNbNV0gPSBwaSArIDg7CiAgICAgICAgICBwc1s2XSA9IHBpICsgMTE7CiAgICAgICAgICBwc1s3XSA9IHBpICsgNDsKICAgICAgICAgIHBzWzBdID0gdG1wMTsKICAgICAgICAgIHBzWzFdID0gcGkgKyA3OwogICAgICAgICAgcHNbMl0gPSBwaSArIDY7CiAgICAgICAgICBwc1szXSA9IHBpICsgNTsKICAgICAgICAgIHRtcDEgPSBjc1szXTsKICAgICAgICAgIGNzWzJdID0gY3NbMV07CiAgICAgICAgICBjc1szXSA9IGNpOwogICAgICAgICAgY3NbMF0gPSB0bXAxOwogICAgICAgICAgY3NbMV0gPSBjaSArIDE7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIDM6CiAgICAgICAgICBwc1sxMl0gPSBwc1swXTsKICAgICAgICAgIHBzWzEzXSA9IHBpICsgMDsKICAgICAgICAgIHBzWzE0XSA9IHBpICsgMTsKICAgICAgICAgIHBzWzE1XSA9IHBpICsgMjsKICAgICAgICAgIHBzWzhdID0gcHNbMV07CiAgICAgICAgICBwc1s5XSA9IHBpICsgOTsKICAgICAgICAgIHBzWzEwXSA9IHBpICsgMTA7CiAgICAgICAgICBwc1sxMV0gPSBwaSArIDM7CiAgICAgICAgICBwc1s0XSA9IHBzWzJdOwogICAgICAgICAgcHNbNV0gPSBwaSArIDg7CiAgICAgICAgICBwc1s2XSA9IHBpICsgMTE7CiAgICAgICAgICBwc1s3XSA9IHBpICsgNDsKICAgICAgICAgIHBzWzBdID0gcHNbM107CiAgICAgICAgICBwc1sxXSA9IHBpICsgNzsKICAgICAgICAgIHBzWzJdID0gcGkgKyA2OwogICAgICAgICAgcHNbM10gPSBwaSArIDU7CiAgICAgICAgICBjc1syXSA9IGNzWzBdOwogICAgICAgICAgY3NbM10gPSBjaTsKICAgICAgICAgIGNzWzBdID0gY3NbMV07CiAgICAgICAgICBjc1sxXSA9IGNpICsgMTsKICAgICAgICAgIGJyZWFrOwogICAgICB9CiAgICAgIHRoaXMuZmlndXJlcy5wdXNoKHsKICAgICAgICB0eXBlOiAicGF0Y2giLAogICAgICAgIGNvb3JkczogbmV3IEludDMyQXJyYXkocHMpLAogICAgIC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2RlQnVmID0gMDsKICAgIGNvbnN0IHNhbXBsZU11bCA9IDEuMCAvICgyLjAgKiogYnBzIC0gMSk7CiAgICBjb25zdCBzdHJCeXRlcyA9IHN0cmVhbS5nZXRCeXRlcygobGVuZ3RoICogYnBzICsgNykgLyA4KTsKICAgIGxldCBzdHJJZHggPSAwOwogICAgZm9yIChpID0gMDsgaSA8IGxlbmd0aDsgaSsrKSB7CiAgICAgIHdoaWxlIChjb2RlU2l6ZSA8IGJwcykgewogICAgICAgIGNvZGVCdWYgPDw9IDg7CiAgICAgICAgY29kZUJ1ZiB8PSBzdHJCeXRlc1tzdHJJZHgrK107CiAgICAgICAgY29kZVNpemUgKz0gODsKICAgICAgfQogICAgICBjb2RlU2l6ZSAtPSBicHM7CiAgICAgIGFycmF5W2ldID0gKGNvZGVCdWYgPj4gY29kZVNpemUpICogc2FtcGxlTXVsOwogICAgICBjb2RlQnVmICY9ICgxIDw8IGNvZGVTaXplKSAtIDE7CiAgICB9CiAgICByZXR1cm4gYXJyYXk7CiAgfQogIHN0YXRpYyBwYXJzZShfcmVmMikgewogICAgbGV0IHsKICAgICAgeHJlZiwKICAgICAgaXNFdmFsU3VwcG9ydGVkLAogICAgICBmbgogICAgfSA9IF9yZWYyOwogICAgY29uc3QgZGljdCA9IGZuLmRpY3QgfHwgZm47CiAgICBjb25zdCB0eXBlTnVtID0gZGljdC5nZXQoIkZ1bmN0aW9uVHlwZSIpOwogICAgc3dpdGNoICh0eXBlTnVtKSB7CiAgICAgIGNhc2UgMDoKICAgICAgICByZXR1cm4gdGhpcy5jb25zdHJ1Y3RTYW1wbGVkKHsKICAgICAgICAgIHhyZWYsCiAgICAgICAgICBpc0V2YWxTdXBwb3J0ZWQsCiAgICAgICAgICBmbiwKICAgICAgICAgIGRpY3QKICAgICAgICB9KTsKICAgICAgY2FzZSAxOgogICAgICAgIGJyZWFrOwogICAgICBjYXNlIDI6CiAgICAgICAgcmV0dXJuIHRoaXMuY29uc3RydWN0SW50ZXJwb2xhdGVkKHsKICAgICAgICAgIHhyZWYsCiAgICAgICAgICBpc0V2YWxTdXBwb3J0ZWQsCiAgICAgICAgICBkaWN0CiAgICAgICAgfSk7CiAgICAgIGNhc2UgMzoKICAgICAgICByZXR1cm4gdGhpcy5jb25zdHJ1Y3RTdGljaGVkKHsKICAgICAgICAgIHhyZWYsCiAgICAgICAgICBpc0V2YWxTdXBwb3J0ZWQsCiAgICAgICAgICBkaWN0CiAgICAgICAgfSk7CiAgICAgIGNhc2UgNDoKICAgICAgICByZXR1cm4gdGhpcy5jb25zdHJ1Y3RQb3N0U2NyaXB0KHsKICAgICAgICAgIHhyZWYsCiAgICAgICAgICBpc0V2YWxTdXBwb3J0ZWQsCiAgICAgICAgICBmbiwKICAgICAgICAgIGRpY3QKICAgICAgICB9KTsKICAgIH0KICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiVW5rbm93biB0eXBlIG9mIGZ1bmN0aW9uIik7CiAgfQogIHN0YXRpYyBwYXJzZUFycmF5KF9yZWYzKSB7CiAgICBsZXQgewogICAgICB4cmVmLAogICAgICBpc0V2YWxTdXBwb3J0ZWQsCiAgICAgIGZuT2JqCiAgICB9ID0gX3JlZjM7CiAgICBpZiAoIUFycmF5LmlzQXJyYXkoZm5PYmopKSB7CiAgICAgIHJldHVybiB0aGlzLnBhcnNlKHsKICAgICAgICB4cmVmLAogICAgICAgIGlzRXZhbFN1cHBvcnRlZCwKICAgICAgICBmbjogZm5PYmoKICAgICAgfSk7CiAgICB9CiAgICBjb25zdCBmbkFycmF5ID0gW107CiAgICBmb3IgKGNvbnN0IGZuIG9mIGZuT2JqKSB7CiAgICAgIGZuQXJyYXkucHVzaCh0aGlzLnBhcnNlKHsKICAgICAgICB4cmVmLAogICAgICAgIGlzRXZhbFN1cHBvcnRlZCwKICAgICAgICBmbjogeHJlZi5mZXRjaElmUmVmKGZuKQogICAgICB9KSk7CiAgICB9CiAgICByZXR1cm4gZnVuY3Rpb24gKHNyYywgc3J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jb25zdCBuMCA9IGUwICsgMSAtIGU7CiAgICAgICAgY29uc3QgbjEgPSBlIC0gZTA7CiAgICAgICAgY29uc3Qgb2Zmc2V0MCA9IGUwICogazsKICAgICAgICBjb25zdCBvZmZzZXQxID0gb2Zmc2V0MCArIGs7CiAgICAgICAgZm9yIChqID0gMDsgaiA8IGN1YmVWZXJ0aWNlczsgaisrKSB7CiAgICAgICAgICBpZiAoaiAmIHBvcykgewogICAgICAgICAgICBjdWJlTltqXSAqPSBuMTsKICAgICAgICAgICAgY3ViZVZlcnRleFtqXSArPSBvZmZzZXQxOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgY3ViZU5bal0gKj0gbjA7CiAgICAgICAgICAgIGN1YmVWZXJ0ZXhbal0gKz0gb2Zmc2V0MDsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgayAqPSBzaXplX2k7CiAgICAgICAgcG9zIDw8PSAxOwogICAgICB9CiAgICAgIGZvciAoaiA9IDA7IGogPCBvdXRwdXRTaXplOyArK2opIHsKICAgICAgICBsZXQgcmogPSAwOwogICAgICAgIGZvciAoaSA9IDA7IGkgPCBjdWJlVmVydGljZXM7IGkrKykgewogICAgICAgICAgcmogKz0gc2FtcGxlc1tjdWJlVmVydGV4W2ldICsgal0gKiBjdWJlTltpXTsKICAgICAgICB9CiAgICAgICAgcmogPSBpbnRlcnBvbGF0ZShyaiwgMCwgMSwgZGVjb2RlW2pdWzBdLCBkZWNvZGVbal1bMV0pOwogICAgICAgIGRlc3RbZGVzdE9mZnNldCArIGpdID0gTWF0aC5taW4oTWF0aC5tYXgocmosIHJhbmdlW2pdWzBdKSwgcmFuZ2Vbal1bMV0pOwogICAgICB9CiAgICB9OwogIH0KICBzdGF0aWMgY29uc3RydWN0SW50ZXJwb2xhdGVkKF9yZWY1KSB7CiAgICBsZXQgewogICAgICB4cmVmLAogICAgICBpc0V2YWxTdXBwb3J0ZWQsCiAgICAgIGRpY3QKICAgIH0gPSBfcmVmNTsKICAg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gIT09IDEpIHsKICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKCJCYWQgZG9tYWluIGZvciBzdGljaGVkIGZ1bmN0aW9uIik7CiAgICB9CiAgICBjb25zdCBmbnMgPSBbXTsKICAgIGZvciAoY29uc3QgZm4gb2YgZGljdC5nZXQoIkZ1bmN0aW9ucyIpKSB7CiAgICAgIGZucy5wdXNoKHRoaXMucGFyc2UoewogICAgICAgIHhyZWYsCiAgICAgICAgaXNFdmFsU3VwcG9ydGVkLAogICAgICAgIGZuOiB4cmVmLmZldGNoSWZSZWYoZm4pCiAgICAgIH0pKTsKICAgIH0KICAgIGNvbnN0IGJvdW5kcyA9IHRvTnVtYmVyQXJyYXkoZGljdC5nZXRBcnJheSgiQm91bmRzIikpOwogICAgY29uc3QgZW5jb2RlID0gdG9OdW1iZXJBcnJheShkaWN0LmdldEFycmF5KCJFbmNvZGUiKSk7CiAgICBjb25zdCB0bXBCdWYgPSBuZXcgRmxvYXQzMkFycmF5KDEpOwogICAgcmV0dXJuIGZ1bmN0aW9uIGNvbnN0cnVjdFN0aWNoZWRGbihzcmMsIHNyY09mZnNldCwgZGVzdCwgZGVzdE9mZnNldCkgewogICAgICBjb25zdCBjbGlwID0gZnVuY3Rpb24gY29uc3RydWN0U3RpY2hlZEZyb21JUkNsaXAodiwgbWluLCBtYXgpIHsKICAgICAgICBpZiAodiA+IG1heCkgewogICAgICAgICAgdiA9IG1heDsKICAgICAgICB9IGVsc2UgaWYgKHYgPCBtaW4pIHsKICAgICAgICAgIHYgPSBtaW47CiAgICAgICAgfQogICAgICAgIHJldHVybiB2OwogICAgICB9OwogICAgICBjb25zdCB2ID0gY2xpcChzcmNbc3JjT2Zmc2V0XSwgZG9tYWluWzBdLCBkb21haW5bMV0pOwogICAgICBjb25zdCBsZW5ndGggPSBib3VuZHMubGVuZ3RoOwogICAgICBsZXQgaTsKICAgICAgZm9yIChpID0gMDsgaSA8IGxlbmd0aDsgKytpKSB7CiAgICAgICAgaWYgKHYgPCBib3VuZHNbaV0pIHsKICAgICAgICAgIGJyZWFrOwogICAgICAgIH0KICAgICAgfQogICAgICBsZXQgZG1pbiA9IGRvbWFpblswXTsKICAgICAgaWYgKGkgPiAwKSB7CiAgICAgICAgZG1pbiA9IGJvdW5kc1tpIC0gMV07CiAgICAgIH0KICAgICAgbGV0IGRtYXggPSBkb21haW5bMV07CiAgICAgIGlmIChpIDwgYm91bmRzLmxlbmd0aCkgewogICAgICAgIGRtYXggPSBib3VuZHNbaV07CiAgICAgIH0KICAgICAgY29uc3Qgcm1pbiA9IGVuY29kZVsyICogaV07CiAgICAgIGNvbnN0IHJtYXggPSBlbmNvZGVbMiAqIGkgKyAxXTsKICAgICAgdG1wQnVmWzBdID0gZG1pbiA9PT0gZG1heCA/IHJtaW4gOiBybWluICsgKHYgLSBkbWluKSAqIChybWF4IC0gcm1pbikgLyAoZG1heCAtIGRtaW4pOwogICAgICBmbnNbaV0odG1wQnVmLCAwLCBkZXN0LCBkZXN0T2Zmc2V0KTsKICAgIH07CiAgfQogIHN0YXRpYyBjb25zdHJ1Y3RQb3N0U2NyaXB0KF9yZWY3KSB7CiAgICBsZXQgewogICAgICB4cmVmLAogICAgICBpc0V2YWxTdXBwb3J0ZWQsCiAgICAgIGZuLAogICAgICBkaWN0CiAgICB9ID0gX3JlZjc7CiAgICBjb25zdCBkb21haW4gPSB0b051bWJlckFycmF5KGRpY3QuZ2V0QXJyYXkoIkRvbWFpbiIpKTsKICAgIGNvbnN0IHJhbmdlID0gdG9OdW1iZXJBcnJheShkaWN0LmdldEFycmF5KCJSYW5nZSIpKTsKICAgIGlmICghZG9tYWluKSB7CiAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiTm8gZG9tYWluLiIpOwogICAgfQogICAgaWYgKCFyYW5nZSkgewogICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoIk5vIHJhbmdlLiIpOwogICAgfQogICAgY29uc3QgbGV4ZX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gewogICAgICBsZXQgaSwgdmFsdWU7CiAgICAgIGxldCBrZXkgPSAiIjsKICAgICAgY29uc3QgaW5wdXQgPSB0bXBCdWY7CiAgICAgIGZvciAoaSA9IDA7IGkgPCBudW1JbnB1dHM7IGkrKykgewogICAgICAgIHZhbHVlID0gc3JjW3NyY09mZnNldCArIGldOwogICAgICAgIGlucHV0W2ldID0gdmFsdWU7CiAgICAgICAga2V5ICs9IHZhbHVlICsgIl8iOwogICAgICB9CiAgICAgIGNvbnN0IGNhY2hlZFZhbHVlID0gY2FjaGVba2V5XTsKICAgICAgaWYgKGNhY2hlZFZhbHVlICE9PSB1bmRlZmluZWQpIHsKICAgICAgICBkZXN0LnNldChjYWNoZWRWYWx1ZSwgZGVzdE9mZnNldCk7CiAgICAgICAgcmV0dXJuOwogICAgICB9CiAgICAgIGNvbnN0IG91dHB1dCA9IG5ldyBGbG9hdDMyQXJyYXkobnVtT3V0cHV0cyk7CiAgICAgIGNvbnN0IHN0YWNrID0gZXZhbHVhdG9yLmV4ZWN1dGUoaW5wdXQpOwogICAgICBjb25zdCBzdGFja0luZGV4ID0gc3RhY2subGVuZ3RoIC0gbnVtT3V0cHV0czsKICAgICAgZm9yIChpID0gMDsgaSA8IG51bU91dHB1dHM7IGkrKykgewogICAgICAgIHZhbHVlID0gc3RhY2tbc3RhY2tJbmRleCArIGldOwogICAgICAgIGxldCBib3VuZCA9IHJhbmdlW2kgKiAyXTsKICAgICAgICBpZiAodmFsdWUgPCBib3VuZCkgewogICAgICAgICAgdmFsdWUgPSBib3VuZDsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgYm91bmQgPSByYW5nZVtpICogMiArIDFdOwogICAgICAgICAgaWYgKHZhbHVlID4gYm91bmQpIHsKICAgICAgICAgICAgdmFsdWUgPSBib3VuZDsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgb3V0cHV0W2ldID0gdmFsdWU7CiAgICAgIH0KICAgICAgaWYgKGNhY2hlX2F2YWlsYWJsZSA+I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ZvciAobGV0IGkgPSBjLCBqID0gcjsgaSA8IGo7IGkrKywgai0tKSB7CiAgICAgIGNvbnN0IHQgPSBzdGFja1tpXTsKICAgICAgc3RhY2tbaV0gPSBzdGFja1tqXTsKICAgICAgc3RhY2tbal0gPSB0OwogICAgfQogIH0KfQpjbGFzcyBQb3N0U2NyaXB0RXZhbHVhdG9yIHsKICBjb25zdHJ1Y3RvcihvcGVyYXRvcnMpIHsKICAgIHRoaXMub3BlcmF0b3JzID0gb3BlcmF0b3JzOwogIH0KICBleGVjdXRlKGluaXRpYWxTdGFjaykgewogICAgY29uc3Qgc3RhY2sgPSBuZXcgUG9zdFNjcmlwdFN0YWNrKGluaXRpYWxTdGFjayk7CiAgICBsZXQgY291bnRlciA9IDA7CiAgICBjb25zdCBvcGVyYXRvcnMgPSB0aGlzLm9wZXJhdG9yczsKICAgIGNvbnN0IGxlbmd0aCA9IG9wZXJhdG9ycy5sZW5ndGg7CiAgICBsZXQgb3BlcmF0b3IsIGEsIGI7CiAgICB3aGlsZSAoY291bnRlciA8IGxlbmd0aCkgewogICAgICBvcGVyYXRvciA9IG9wZXJhdG9yc1tjb3VudGVyKytdOwogICAgICBpZiAodHlwZW9mIG9wZXJhdG9yID09PSAibnVtYmVyIikgewogICAgICAgIHN0YWNrLnB1c2gob3BlcmF0b3IpOwogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIHN3aXRjaCAob3BlcmF0b3IpIHsKICAgICAgICBjYXNlICJqeiI6CiAgICAgICAgICBiID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBhID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBpZiAoIWEpIHsKICAgICAgICAgICAgY291bnRlciA9IGI7CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJqIjoKICAgICAgICAgIGEgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIGNvdW50ZXIgPSBhOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiYWJzIjoKICAgICAgICAgIGEgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIHN0YWNrLnB1c2goTWF0aC5hYnMoYSkpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiYWRkIjoKICAgICAgICAgIGIgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIGEgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIHN0YWNrLnB1c2goYSArIGIpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiYW5kIjoKICAgICAgICAgIGIgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIGEgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIGlmICh0eXBlb2YgYSA9PT0gImJvb2xlYW4iICYmIHR5cGVvZiBiID09PSAiYm9vbGVhbiIpIHsKICAgICAgICAgICAgc3RhY2sucHVzaChhICYmIGIpOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgc3RhY2sucHVzaChhICYgYik7CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJhdGFuIjoKICAgICAgICAgIGIgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIGEgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIGEgPSBNYXRoLmF0YW4yKGEsIGIpIC8gTWF0aC5QSSAqIDE4MDsKICAgICAgICAgIGlmIChhIDwgMCkgewogICAgICAgICAgICBhICs9IDM2MDsKICAgICAgICAgIH0KICAgICAgICAgIHN0YWNrLnB1c2goYSk7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJiaXRzaGlmdCI6CiAgICAgICAgICBiID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBhID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBpZiAoYSA+IDApIHsKICAgICAgICAgICAgc3RhY2sucHVzaChhIDw8IGIpOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgc3RhY2sucHVzaChhID4+IGIpOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiY2VpbGluZyI6CiAgICAgICAgICBhID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBzdGFjay5wdXNoKE1hdGguY2VpbChhKSk7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJjb3B5IjoKICAgICAgICAgIGEgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIHN0YWNrLmNvcHkoYSk7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJjb3MiOgogICAgICAgICAgYSA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgc3RhY2sucHVzaChNYXRoLmNvcyhhICUgMzYwIC8gMTgwICogTWF0aC5QSSkpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiY3ZpIjoKICAgICAgICAgIGEgPSBzdGFjay5wb3AoKSB8IDA7CiAgICAgICAgICBzdGFjay5wdXNoKGEpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiY3ZyIjoKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgImRpdiI6CiAgICAgICAgICBiID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBhID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBzdGFjay5wdXNoKGEgLyBiKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgImR1cCI6CiAgICAgICAgICBzdGFjay5jb3B5KDEpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiZXEiOgogICAgICAgICAgYiA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgYSA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgc3RhY2sucHVzaChhID09PSBiKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgImV4Y2giOgogICAgICAgICAgc3RhY2sucm9sbCgyLCAxKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgImV4cCI6CiAgICAgICAgICBiID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBhID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBzdGFjay5wdXNoKGEgKiogYik7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJmYWxzZSI6CiAgICAgICAgICBzdGFjay5wdXNoKGZhbHNlKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgImZsb29yIjoKICAgICAgICAgIGEgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIHN0YWNrLnB1c2goTWF0aC5mbG9vcihhKSk7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJnZSI6CiAgICAgICAgICBiID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBhID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBzdGFjay5wdXNoKGEgPj0gYik7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJndCI6CiAgICAgICAgICBiID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBhID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBzdGFjay5wdXNoKGEgPiBiKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgImlkaXYiOgogICAgICAgICAgYiA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgYSA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgc3RhY2sucHVzaChhIC8gYiB8IDApOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiaW5kZXgiOgogICAgICAgICAgYSA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgc3RhY2suaW5kZXgoYSk7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJsZSI6CiAgICAgICAgICBiID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBhID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBzdGFjay5wdXNoKGEgPD0gYik7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJsbiI6CiAgICAgICAgICBhID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBzdGFjay5wdXNoKE1hdGgubG9nKGEpKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgImxvZyI6CiAgICAgICAgICBhID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBzdGFjay5wdXNoKE1hdGgubG9nKGEpIC8gTWF0aC5MTjEwKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgImx0IjoKICAgICAgICAgIGIgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIGEgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIHN0YWNrLnB1c2goYSA8IGIpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAibW9kIjoKICAgICAgICAgIGIgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIGEgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIHN0YWNrLnB1c2goYSAlIGIpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAibXVsIjoKICAgICAgICAgIGIgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIGEgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIHN0YWNrLnB1c2goYSAqIGIpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAibmUiOgogICAgICAgICAgYiA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgYSA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgc3RhY2sucHVzaChhICE9PSBiKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgIm5lZyI6CiAgICAgICAgICBhID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBzdGFjay5wdXNoKC1hKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgIm5vdCI6CiAgICAgICAgICBhID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBpZiAodHlwZW9mIGEgPT09ICJib29sZWFuIikgewogICAgICAgICAgICBzdGFjay5wdXNoKCFhKTsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHN0YWNrLnB1c2gofmEpOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAib3IiOgogICAgICAgICAgYiA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgYSA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgaWYgKHR5cGVvZiBhID09PSAiYm9vbGVhbiIgJiYgdHlwZW9mIGIgPT09ICJib29sZWFuIikgewogICAgICAgICAgICBzdGFjay5wdXNoKGEgfHwgYik7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBzdGFjay5wdXNoKGEgfCBiKTsKICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgInBvcCI6CiAgICAgICAgICBzdGFjay5wb3AoKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgInJvbGwiOgogICAgICAgICAgYiA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgYSA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgc3RhY2sucm9sbChhLCBiKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgInJvdW5kIjoKICAgICAgICAgIGEgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIHN0YWNrLnB1c2goTWF0aC5yb3VuZChhKSk7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJzaW4iOgogICAgICAgICAgYSA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgc3RhY2sucHVzaChNYXRoLnNpbihhICUgMzYwIC8gMTgwICogTWF0aC5QSSkpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAic3FydCI6CiAgICAgICAgICBhID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBzdGFjay5wdXNoKE1hdGguc3FydChhKSk7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJzdWIiOgogICAgICAgICAgYiA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgYSA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgc3RhY2sucHVzaChhIC0gYik7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJ0c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vcGVyYXRpb24pIHsKICAgIHRoaXMucGFydHMucHVzaCgiKCIpOwogICAgb3BlcmF0aW9uLmFyZzEudmlzaXQodGhpcyk7CiAgICB0aGlzLnBhcnRzLnB1c2goIiAiLCBvcGVyYXRpb24ub3AsICIgIik7CiAgICBvcGVyYXRpb24uYXJnMi52aXNpdCh0aGlzKTsKICAgIHRoaXMucGFydHMucHVzaCgiKSIpOwogIH0KICB2aXNpdFZhcmlhYmxlRGVmaW5pdGlvbihkZWZpbml0aW9uKSB7CiAgICB0aGlzLnBhcnRzLnB1c2goInZhciAiKTsKICAgIGRlZmluaXRpb24udmFyaWFibGUudmlzaXQodGhpcyk7CiAgICB0aGlzLnBhcnRzLnB1c2goIiA9ICIpOwogICAgZGVmaW5pdGlvbi5hcmcudmlzaXQodGhpcyk7CiAgICB0aGlzLnBhcnRzLnB1c2goIjsiKTsKICB9CiAgdmlzaXRNaW4obWF4KSB7CiAgICB0aGlzLnBhcnRzLnB1c2goIk1hdGgubWluKCIpOwogICAgbWF4LmFyZy52aXNpdCh0aGlzKTsKICAgIHRoaXMucGFydHMucHVzaCgiLCAiLCBtYXgubWF4LCAiKSIpOwogIH0KICB0b1N0cmluZygpIHsKICAgIHJldHVybiB0aGlzLnBhcnRzLmpvaW4oIiIpOwogIH0KfQpmdW5jdGlvbiBidWlsZEFkZE9wZXJhdGlvbihudW0xLCBudW0yKSB7CiAgaWYgKG51bTIudHlwZSA9PT0gImxpdGVyYWwiICYmIG51bTIubnVtYmVyID09PSAwKSB7CiAgICByZXR1cm4gbnVtMTsKICB9CiAgaWYgKG51bTEudHlwZSA9PT0gImxpdGVyYWwiICYmIG51bTEubnVtYmVyID09PSAwKSB7CiAgICByZXR1cm4gbnVtMjsKICB9CiAgaWYgKG51bTIudHlwZSA9PT0gImxpdGVyYWwiICYmIG51bTEudHlwZSA9PT0gImxpdGVyYWwiKSB7CiAgICByZXR1cm4gbmV3IEFzdExpdGVyYWwobnVtMS5udW1iZXIgKyBudW0yLm51b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rpb24gYnVpbGRTdWJPcGVyYXRpb24obnVtMSwgbnVtMikgewogIGlmIChudW0yLnR5cGUgPT09ICJsaXRlcmFsIikgewogICAgaWYgKG51bTIubnVtYmVyID09PSAwKSB7CiAgICAgIHJldHVybiBudW0xOwogICAgfSBlbHNlIGlmIChudW0xLnR5cGUgPT09ICJsaXRlcmFsIikgewogICAgICByZXR1cm4gbmV3IEFzdExpdGVyYWwobnVtMS5udW1iZXIgLSBudW0yLm51bWJlcik7CiAgICB9CiAgfQogIGlmIChudW0yLnR5cGUgPT09ICJiaW5hcnkiICYmIG51bTIub3AgPT09ICItIiAmJiBudW0xLnR5cGUgPT09ICJsaXRlcmFsIiAmJiBudW0xLm51bWJlciA9PT0gMSAmJiBudW0yLmFyZzEudHlwZSA9PT0gImxpdGVyYWwiICYmIG51bTIuYXJnMS5udW1iZXIgPT09IDEpIHsKICAgIHJldHVybiBudW0yLmFyZzI7CiAgfQogIHJldHVybiBuZXcgQXN0QmluYXJ5T3BlcmF0aW9uKCItIiwgbnVtMSwgbnVtMiwgbnVtMS5taW4gLSBudW0yLm1heCwgbnVtMS5tYXggLSBudW0yLm1pbik7Cn0KZnVuY3Rpb24gYnVpbGRNaW5PcGVyYXRpb24obnVtMSwgbWF4KSB7CiAgaWYgKG51bTEubWluID49IG1heCkgewogICAgcmV0dXJuIG5ldyBBc3RMaXRlcmFsKG1heCk7CiAgfSBlbHNlIGlmIChudW0xLm1heCA8PSBtYXgpIHsKICAgIHJldHVybiBudW0xOwogIH0KICByZXR1cm4gbmV3IEFzdE1pbihudW0xLCBtYXgpOwp9CmNsYXNzIFBvc3RTY3JpcHRDb21waWxlciB7CiAgY29tcGlsZShjb2RlLCBkb21haW4sIHJhbmdlKSB7CiAgICBjb25zdCBzdGFjayA9IFtdOwogICAgY29uc3QgaW5zdHJ1Y3Rpb25zID0gW107CiAgICBjb25zdCBpbnB1dFNpemUgPSBkb21haW4ubGVuZ3RoID4+IDEsCiAgICAgIG91dHB1dFNpemUgPSByYW5nZS5sZW5ndGggPj4gMTsKICAgIGxldCBsYXN0UmVnaXN0ZXIgPSAwOwogICAgbGV0IG4sIGo7CiAgICBsZXQgbnVtMSwgbnVtMiwgYXN0MSwgYXN0MiwgdG1wVmFyLCBpdGVtOwogICAgZm9yIChsZXQgaSA9IDA7IGkgPCBpbnB1dFNpemU7IGkrKykgewogICAgICBzdGFjay5wdXNoKG5ldyBBc3RBcmd1bWVudChpLCBkb21haW5baSAqIDJdLCBkb21haW5baSAqIDIgKyAxXSkpOwogICAgfQogICAgZm9yIChsZXQgaSA9IDAsIGlpID0gY29kZS5sZW5ndGg7IGkgPCBpaTsgaSsrKSB7CiAgICAgIGl0ZW0gPSBjb2RlW2ldOwogICAgICBpZiAodHlwZW9mIGl0ZW0gPT09ICJudW1iZXIiKSB7CiAgICAgICAgc3RhY2sucHVzaChuZXcgQXN0TGl0ZXJhbChpdGVtKSk7CiAgICAgICAgY29udGludWU7CiAgICAgIH0KICAgICAgc3dpdGNoIChpdGVtKSB7CiAgICAgICAgY2FzZSAiYWRkIjoKICAgICAgICAgIGlmIChzdGFjay5sZW5ndGggPCAyKSB7CiAgICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgICAgfQogICAgICAgICAgbnVtMiA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgbnVtMSA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgc3RhY2sucHVzaChidWlsZEFkZE9wZXJhdGlvbihudW0xLCBudW0yKSk7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJjdnIiOgogICAgICAgICAgaWYgKHN0YWNrLmxlbmd0aCA8IDEpIHsKICAgICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJtdWwiOgogICAgICAgICAgaWYgKHN0YWNrLmxlbmd0aCA8IDIpIHsKICAgICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgICB9CiAgICAgICAgICBudW0yID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBudW0xID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBzdGFjay5wdXNoKGJ1aWxkTXVsT3BlcmF0aW9uKG51bTEsIG51bTIpKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgInN1YiI6CiAgICAgICAgICBpZiAoc3RhY2subGVuZ3RoIDwgMikgewogICAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICAgIH0KICAgICAgICAgIG51bTIgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIG51bTEgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIHN0YWNrLnB1c2goYnVpbGRTdWJPcGVyYXRpb24obnVtMSwgbnVtMikpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiZXhjaCI6CiAgICAgICAgICBpZiAoc3RhY2subGVuZ3RoIDwgMikgewogICAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICAgIH0KICAgICAgICAgIGFzdDEgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIGFzdDIgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIHN0YWNrLnB1c2goYXN0MSwgYXN0Mik7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJwb3AiOgogICAgICAgICAgaWYgKHN0YWNrLmxlbmd0aCA8IDEpIHsKICAgICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgICB9CiAgICAgICAgICBzdGFjay5wb3AoKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgImluZGV4IjoKICAgICAgICAgIGlmIChzdGFjay5sZW5ndGggPCAxKSB7CiAgICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgICAgfQogICAgICAgICAgbnVtMSA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgaWYgKG51bTEudHlwZSAhPT0gImxpdGVyYWwiKSB7CiAgICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgICAgfQogICAgICAgICAgbiA9IG51bTEubnVtYmVyOwogICAgICAgICAgaWYgKG4gPCAwIHx8ICFOdW1iZXIuaXNJbnRlZ2VyKG4pIHx8IHN0YWNrLmxlbmd0aCA8IG4pIHsKICAgICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgICB9CiAgICAgICAgICBhc3QxID0gc3RhY2tbc3RhY2subGVuZ3RoIC0gbiAtIDFdOwogICAgICAgICAgaWYgKGFzdDEudHlwZSA9PT0gImxpdGVyYWwiIHx8IGFzdDEudHlwZSA9PT0gInZhciIpIHsKICAgICAgICAgICAgc3RhY2sucHVzaChhc3QxKTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICB9CiAgICAgICAgICB0bXBWYXIgPSBuZXcgQXN0VmFyaWFibGUobGFzdFJlZ2lzdGVyKyssIGFzdDEubWluLCBhc3QxLm1heCk7CiAgICAgICAgICBzdGFja1tzdGFjay5sZW5ndGggLSBuIC0gMV0gPSB0bXBWYXI7CiAgICAgICAgICBzdGFjay5wdXNoKHRtcFZhcik7CiAgICAgICAgICBpbnN0cnVjdGlvbnMucHVzaChuZXcgQXN0VmFyaWFibGVEZWZpbml0aW9uKHRtcFZhciwgYXN0MSkpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiZHVwIjoKICAgICAgICAgIGlmIChzdGFjay5sZW5ndGggPCAxKSB7CiAgICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgICAgfQogICAgICAgICAgaWYgKHR5cGVvZiBjb2RlW2kgKyAxXSA9PT0gIm51bWJlciIgJiYgY29kZVtpICsgMl0gPT09ICJndCIgJiYgY29kZVtpICsgM10gPT09IGkgKyA3ICYmIGNvZGVbaSArIDRdID09PSAianoiICYmIGNvZGVbaSArIDVdID09PSAicG9wIiAmJiBjb2RlW2kgKyA2XSA9PT0gY29kZVtpICsgMV0pIHsKICAgICAgICAgICAgbnVtMSA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgICBzdGFjay5wdXNoKGJ1aWxkTWluT3BlcmF0aW9uKG51bTEsIGNvZGVbaSArIDFdKSk7CiAgICAgICAgICAgIGkgKz0gNjsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICB9CiAgICAgICAgICBhc3QxID0gc3RhY2suYXQoLTEpOwogICAgICAgICAgaWYgKGFzdDEudHlwZSA9PT0gImxpdGVyYWwiIHx8IGFzdDEudHlwZSA9PT0gInZhciIpIHsKICAgICAgICAgICAgc3RhY2sucHVzaChhc3QxKTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICB9CiAgICAgICAgICB0bXBWYXIgPSBuZXcgQXN0VmFyaWFibGUobGFzdFJlZ2lzdGVyKyssIGFzdDEubWluLCBhc3QxLm1heCk7CiAgICAgICAgICBzdGFja1tzdGFjay5sZW5ndGggLSAxXSA9IHRtcFZhcjsKICAgICAgICAgIHN0YWNrLnB1c2godG1wVmFyKTsKICAgICAgICAgIGluc3RydWN0aW9ucy5wdXNoKG5ldyBBc3RWYXJpYWJsZURlZmluaXRpb24odG1wVmFyLCBhc3QxKSk7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJyb2xsIjoKICAgICAgICAgIGlmIChzdGFjay5sZW5ndGggPCAyKSB7CiAgICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgICAgfQogICAgICAgICAgbnVtMiA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgbnVtMSA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgaWYgKG51bTIudHlwZSAhPT0gImxpdGVyYWwiIHx8IG51bTEudHlwZSAhPT0gImxpdGVyYWwiKSB7CiAgICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgICAgfQogICAgICAgICAgaiA9IG51bTIubnVtYmVyOwogICAgICAgICAgbiA9IG51bTEubnVtYmVyOwogICAgICAgICAgaWYgKG4gPD0gMCB8fCAhTnVtYmVyLmlzSW50ZWdlcihuKSB8fCAhTnVtYmVyLmlzSW50ZWdlcihqKSB8fCBzdGFjay5sZW5ndGggPCBuKSB7CiAgICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgICAgfQogICAgICAgICAgaiA9IChqICUgbiArIG4pICUgbjsKICAgICAgICAgIGlmIChqID09PSAwKSB7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgfQogICAgICAgICAgc3RhY2sucHVzaCguLi5zdGFjay5zcGxpY2Uoc3RhY2subGVuZ3RoIC0gbiwgbiAtIGopKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgfQogICAgfQogICAgaWYgKHN0YWNrLmxlbmd0aCAhPT0gb3V0cHV0U2l6ZSkgewogICAgICByZXR1cm4gbnVsbDsKICAgIH0KICAgIGNvbnN0IHJlc3VsdCA9IFtdOwogICAgZm9yIChjb25zdCBpbnN0cnVjdGlvbiBvZiBpbnN0cnVjdGlvbnMpIHsKICAgICAgY29uc3Qgc3RhdGVtZW50QnVpbGRlciA9IG5ldyBFeHByZXNzaW9uQnVpbGRlclZpc2l0b3IoKTsKICAgICAgaW5zdHJ1Y3Rpb24udmlzaXQoc3RhdGVtZW50QnVpbGRlcik7CiAgICAgIHJlc3VsdC5wdXNoKHN0YXRlbWVudEJ1aWxkZXIudG9TdHJpbmcoKSk7CiAgICB9CiAgICBmb3IgKGxldCBpID0gMCwgaWkgPSBzdGFjay5sZW5ndGg7IGkgPCBpaTsgaSsrKSB7CiAgICAgIGNvbnN0IGV4cHIgPSBzdGFja1tpXSwKICAgICAgICBzdGF0ZW1lbnRCdWlsZGVyID0gbmV3IEV4cHJlc3Npb25CdWlsZGVyVmlzaXRvcigpOwogICAgICBleHByLnZpc2l0KHN0YXRlbWVudEJ1aWxkZXIpOwogICAgICBjb25zdCBtaW4gPSByYW5nZVtpICogMl0sCiAgICAgICAgbWF4ID0gcmFuZ2VbaSAqIDIgKyAxXTsKICAgICAgY29uc3Qgb3V0ID0gW3N0YXRlbWVudEJ1aWxkZXIudG9TdHJpbmcoKV07CiAgICAgIGlmIChtaW4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pIHsKICAgIGxldCBjb21tZW50ID0gZmFsc2U7CiAgICBsZXQgY2ggPSB0aGlzLmN1cnJlbnRDaGFyOwogICAgd2hpbGUgKHRydWUpIHsKICAgICAgaWYgKGNoIDwgMCkgewogICAgICAgIHJldHVybiBfcHJpbWl0aXZlcy5FT0Y7CiAgICAgIH0KICAgICAgaWYgKGNvbW1lbnQpIHsKICAgICAgICBpZiAoY2ggPT09IDB4MGEgfHwgY2ggPT09IDB4MGQpIHsKICAgICAgICAgIGNvbW1lbnQgPSBmYWxzZTsKICAgICAgICB9CiAgICAgIH0gZWxzZSBpZiAoY2ggPT09IDB4MjUpIHsKICAgICAgICBjb21tZW50ID0gdHJ1ZTsKICAgICAgfSBlbHNlIGlmICghKDAsIF9jb3JlX3V0aWxzLmlzV2hpdGVTcGFjZSkoY2gpKSB7CiAgICAgICAgYnJlYWs7CiAgICAgIH0KICAgICAgY2ggPSB0aGlzLm5leHRDaGFyKCk7CiAgICB9CiAgICBzd2l0Y2ggKGNoIHwgMCkgewogICAgICBjYXNlIDB4MzA6CiAgICAgIGNhc2UgMHgzMToKICAgICAgY2FzZSAweDMyOgogICAgICBjYXNlIDB4MzM6CiAgICAgIGNhc2UgMHgzNDoKICAgICAgY2FzZSAweDM1OgogICAgICBjYXNlIDB4MzY6CiAgICAgIGNhc2UgMHgzNzoKICAgICAgY2FzZSAweDM4OgogICAgICBjYXNlIDB4Mzk6CiAgICAgIGNhc2UgMHgyYjoKICAgICAgY2FzZSAweDJkOgogICAgICBjYXNlIDB4MmU6CiAgICAgICAgcmV0dXJuIG5ldyBQb3N0U2NyaXB0VG9rZW4oUG9zdFNjcmlwdFRva2VuVHlwZXMuTlVNQkVSLCB0aGlzLmdldE51bWJlcigpKTsKICAgICAgY2FzZSAweDdiOgogICAgICAgIHRoaXMubmV4dENoYXIoKTsKICAgICAgICByZXR1cm4gUG9zdFNjcmlwdFRva2VuLkxCUkFDRTsKICAgICAgY2FzZSAweDdkOgogICAgICAgIHRoaXMubm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IiwgIk5TTSIsICJOU00iLCAiTlNNIiwgIk5TTSIsICJOU00iLCAiTlNNIiwgIkFOIiwgIkFOIiwgIkFOIiwgIkFOIiwgIkFOIiwgIkFOIiwgIkFOIiwgIkFOIiwgIkFOIiwgIkFOIiwgIkVUIiwgIkFOIiwgIkFOIiwgIkFMIiwgIkFMIiwgIkFMIiwgIk5TTSIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJOU00iLCAiTlNNIiwgIk5TTSIsICJOU00iLCAiTlNNIiwgIk5TTSIsICJOU00iLCAiQU4iLCAiT04iLCAiTlNNIiwgIk5TTSIsICJOU00iLCAiTlNNIiwgIk5TTSIsICJOU00i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Q1MiICYmICh0eXBlc1tpIC0gMV0gPT09ICJFTiIgfHwgdHlwZXNbaSAtIDFdID09PSAiQU4iKSAmJiB0eXBlc1tpICsgMV0gPT09IHR5cGVzW2kgLSAxXSkgewogICAgICB0eXBlc1tpXSA9IHR5cGVzW2kgLSAxXTsKICAgIH0KICB9CiAgZm9yIChpID0gMDsgaSA8IHN0ckxlbmd0aDsgKytpKSB7CiAgICBpZiAodHlwZXNbaV0gPT09ICJFTiIpIHsKICAgICAgZm9yIChsZXQgaiA9IGkgLSAxOyBqID49IDA7IC0taikgewogICAgICAgIGlmICh0eXBlc1tqXSAhPT0gIkVUIikgewogICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICAgIHR5cGVzW2pdID0gIkVOIjsKICAgICAgfQogICAgICBmb3IgKGxldCBqID0gaSArIDE7IGogPCBzdHJMZW5ndGg7ICsraikgewogICAgICAgIGlmICh0eXBlc1tqXSAhPT0gIkVUIikgewogICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICAgIHR5cGVzW2pdID0gIkVOIjsKICAgICAgfQogICAgfQogIH0KICBmb3IgKGkgPSAwOyBpIDwgc3RyTGVuZ3RoOyArK2kpIHsKICAgIHQgPSB0eXBlc1tpXTsKICAgIGlmICh0ID09PSAiV1MiIHx8IHQgPT09ICJFUyIgfHwgdCA9PT0gIkVUIiB8fCB0ID09PSAiQ1MiKSB7CiAgICAgIHR5cGVzW2ldID0gIk9OIjsKICAgIH0KICB9CiAgbGFzdFR5cGUgPSBzb3I7CiAgZm9yIChpID0gMDsgaSA8IHN0ckxlbmd0aDsgKytpKSB7CiAgICB0ID0gdHlwZXNbaV07CiAgICBpZiAodCA9PT0gIkVOIikgewogICAgICB0eXBlc1tpXSA9IGxhc3RUeXBlID09PSAiTCIgPyAiTCIgOiAiRU4iOwogICAgfSBlbHNlIGlmICh0ID09PSAiUiIgfHwgdCA9PT0gIkwiKSB7CiAgICAgIGxhc3RUeXBlID0gdDsKICAgIH0KICB9CiAgZm9yIChpID0gMDsgaSA8IHN0ckxlbmd0aDsgKytpKSB7CiAgICBpZiAodHlwZXNbaV0gPT09ICJPTiIpIHsKICAgICAgY29uc3QgZW5kID0gZmluZFVuZXF1YWwodHlwZXMsIGkgKyAxLCAiT04iKTsKICAgICAgbGV0IGJlZm9yZSA9IHNvcjsKICAgICAgaWYgKGkgPiAwKSB7CiAgICAgICAgYmVmb3JlID0gdHlwZXNbaSAtIDFdOwogICAgICB9CiAgICAgIGxldCBhZnRlciA9IGVvcjsKICAgICAgaWYgKGVuZCArIDEgPCBzdHJMZW5ndGgpIHsKICAgICAgICBhZnRlciA9IHR5cGVzW2VuZCArIDFdOwogICAgICB9CiAgICAgIGlmIChiZWZvcmUgIT09ICJMIikgewogICAgICAgIGJlZm9yZSA9ICJSIjsKICAgICAgfQogICAgICBpZiAoYWZ0ZXIgIT09ICJMIikgewogICAgICAgIGFmdGVyID0gIlIiOwogICAgICB9CiAgICAgIGlmIChiZWZvcmUgPT09IGFmdGVyKSB7CiAgICAgICAgc2V0VmFsdWVzKHR5cGVzLCBpLCBlbmQsIGJlZm9yZSk7CiAgICAgIH0KICAgICAgaSA9IGVuZCAtIDE7CiAgICB9CiAgfQogIGZvciAoaSA9IDA7IGkgPCBzdHJMZW5ndGg7ICsraSkgewogICAgaWYgKHR5cGVzW2ldID09PSAiT04iKSB7CiAgICAgIHR5cGVzW2ldID0gZTsKICAgIH0KICB9CiAgZm9yIChpID0gMDsgaSA8IHN0ckxlbmd0aDsgKytpKSB7CiAgICB0ID0gdHlwZXNbaV07CiAgICBpZiAoaXNFdmVuKGxldmVsc1tpXSkpIHsKICAgICAgaWYgKHQgPT09ICJSIikgewogICAgICAgIGxldmVsc1tpXSArPSAxOwogICAgICB9IGVsc2UgaWYgKHQgPT09ICJBTiIgfHwgdCA9PT0gIkVOIikgewogICAgICAgIGxldmVsc1tpXSArPSAyOwogICAgICB9CiAgICB9IGVsc2UgewogICAgICBpZiAodCA9PT0gIkwiIHx8IHQg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RhLmRhdGEgPSBudWxsOwogICAgaW1nRGF0YS5iaXRtYXAgPSBiaXRtYXA7CiAgICBpbWdEYXRhLndpZHRoID0gbmV3V2lkdGg7CiAgICBpbWdEYXRhLmhlaWdodCA9IG5ld0hlaWdodDsKICAgIHJldHVybiBpbWdEYXRhOwogIH0KICBfZW5jb2RlQk1QKCkgewogICAgY29uc3QgewogICAgICB3aWR0aCwKICAgICAgaGVpZ2h0LAogICAgICBraW5kCiAgICB9ID0gdGhpcy5faW1nRGF0YTsKICAgIGxldCBkYXRhID0gdGhpcy5faW1nRGF0YS5kYXRhOwogICAgbGV0IGJpdFBlclBpeGVsOwogICAgbGV0IGNvbG9yVGFibGUgPSBuZXcgVWludDhBcnJheSgwKTsKICAgIGxldCBtYXNrVGFibGUgPSBjb2xvclRhYmxlOwogICAgbGV0IGNvbXByZXNzaW9uID0gMDsKICAgIHN3aXRjaCAoa2luZCkgewogICAgICBjYXNlIF91dGlsLkltYWdlS2luZC5HUkFZU0NBTEVfMUJQUDoKICAgICAgICB7CiAgICAgICAgICBiaXRQZXJQaXhlbCA9IDE7CiAgICAgICAgICBjb2xvclRhYmxlID0gbmV3IFVpbnQ4QXJyYXkodGhpcy5faXNNYXNrID8gWzI1NSwgMjU1LCAyNTUsIDI1NSwgMCwgMCwgMCwgMF0gOiBbMCwgMCwgMCwgMCwgMjU1LCAyNTUsIDI1NSwgMjU1XSk7CiAgICAgICAgICBjb25zdCByb3dMZW4gPSB3aWR0aCArIDcgPj4gMzsKICAgICAgICAgIGNvbnN0IHJvd1NpemUgPSByb3dMZW4gKyAzICYgLTQ7CiAgICAgICAgICBpZiAocm93TGVuICE9PSByb3dTaXplKSB7CiAgICAgICAgICAgIGNvbnN0IG5ld0RhdGEgPSBuZXcgVWludDhBcnJheShyb3dTaXplICogaGVpZ2h0KTsKICAgICAgICAgICAgbGV0IGsgPSAwOwogICAgICAgICAgICBmb3IgKGxldCBpID0gMCwgaWkgPSBoZWlnaHQgKiByb3dMZW47IGkgPCBpaTsgaSArPSByb3dMZW4sIGsgKz0gcm93U2l6ZSkgewogICAgICAgICAgICAgIG5ld0RhdGEuc2V0KGRhdGEuc3ViYXJyYXkoaSwgaSArIHJvd0xlbiksIGspOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGRhdGEgPSBuZXdEYXRhOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICBjYXNlIF91dGlsLkltYWdlS2luZC5SR0JfMjRCUFA6CiAgICAgICAgewogICAgICAgICAgYml0UGVyUGl4ZWwgPSAyNDsKICAgICAgICAgIGlmICh3aWR0aCAmIDMpIHsKICAgICAgICAgICAgY29uc3Qgcm93TGVuID0gMyAqIHdpZHRoOwogICAgICAgICAgICBjb25zdCByb3dTaXplID0gcm93TGVuICsgMyAmIC00OwogICAgICAgICAgICBjb25zdCBleHRyYUxlbiA9IHJvd1NpemUgLSByb3dMZW47CiAgICAgICAgICAgIGNvbnN0IG5ld0RhdGEgPSBuZXcgVWludDhBcnJheShyb3dTaXplICogaGVpZ2h0KTsKICAgICAgICAgICAgbGV0IGsgPSAwOwogICAgICAgICAgICBmb3IgKGxldCBpID0gMCwgaWkgPSBoZWlnaHQgKiByb3dMZW47IGkgPCBpaTsgaSArPSByb3dMZW4pIHsKICAgICAgICAgICAgICBjb25zdCByb3cgPSBkYXRhLnN1YmFycmF5KGksIGkgKyByb3dMZW4pOwogICAgICAgICAgICAgIGZvciAobGV0IGogPSAwOyBqIDwgcm93TGVuOyBqICs9IDMpIHsKICAgICAgICAgICAgICAgIG5ld0RhdGFbaysrXSA9IHJvd1tqICsgMl07CiAgICAgICAgICAgICAgICBuZXdEYXRhW2srK10gPSByb3dbaiArIDFdOwogICAgICAgICAgICAgICAgbmV3RGF0YVtrKytdID0gcm93W2pdOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBrICs9IGV4dHJhTGVuOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGRhdGEgPSBuZXdEYXRhOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgZm9yIChsZXQgaSA9IDAsIGlpID0gZGF0YS5sZW5ndGg7IGkgPCBpaTsgaSArPSAzKSB7CiAgICAgICAgICAgICAgY29uc3QgdG1wID0gZGF0YVtpXTsKICAgICAgICAgICAgICBkYXRhW2ldID0gZGF0YVtpICsgMl07CiAgICAgICAgICAgICAgZGF0YVtpICsgMl0gPSB0bXA7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIH0KICAgICAgY2FzZSBfdXRpbC5JbWFnZUtpbmQuUkdCQV8zMkJQUDoKICAgICAgICBiaXRQZXJQaXhlbCA9IDMyOwogICAgICAgIGNvbXByZXNzaW9uID0gMzsKICAgICAgICBtYXNrVGFibGUgPSBuZXcgVWludDhBcnJheSg0ICsgNCArIDQgKyA0ICsgNTIpOwogICAgICAgIGNvbnN0IHZpZXcgPSBuZXcgRGF0YVZpZXcobWFza1RhYmxlLmJ1ZmZlcik7CiAgICAgICAgaWYgKF91dGlsLkZlYXR1cmVUZXN0LmlzTGl0dGxlRW5kaWFuKSB7CiAgICAgICAgICB2aWV3LnNldFVpbnQzMigwLCAweDAwMDAwMGZmLCB0cnVlKTsKICAgICAgICAgIHZpZXcuc2V0VWludDMyKDQsIDB4MDAwMGZmMDAsIHRydWUpOwogICAgICAgICAgdmlldy5zZXRVaW50MzIoOCwgMHgwMGZmMDAwMCwgdHJ1ZSk7CiAgICAgICAgICB2aWV3LnNldFVpbnQzMigxMiwgMHhmZjAwMDAwMCwgdHJ1ZSk7CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIHZpZXcuc2V0VWludDMyKDAsIDB4ZmYwMDAwMDAsIHRydWUpOwogICAgICAgICAgdmlldy5zZXRVaW50MzIoNCwgMHgwMGZmMDAwMCwgdHJ1ZSk7CiAgICAgICAgICB2aWV3LnNldFVpbnQzMig4LCAweDAwMDBmZjAwLCB0cnVlKTsKICAgICAgICAgIHZpZXcu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MildWzBdOwogICAgaWYgKGN1cnJlbnRYICsgaW1nLndpZHRoID4gTUFYX1dJRFRIKSB7CiAgICAgIG1heFggPSBNYXRoLm1heChtYXhYLCBjdXJyZW50WCk7CiAgICAgIGN1cnJlbnRZICs9IG1heExpbmVIZWlnaHQgKyAyICogSU1BR0VfUEFERElORzsKICAgICAgY3VycmVudFggPSAwOwogICAgICBtYXhMaW5lSGVpZ2h0ID0gMDsKICAgIH0KICAgIG1hcC5wdXNoKHsKICAgICAgdHJhbnNmb3JtLAogICAgICB4OiBjdXJyZW50WCwKICAgICAgeTogY3VycmVudFksCiAgICAgIHc6IGltZy53aWR0aCwKICAgICAgaDogaW1nLmhlaWdodAogICAgfSk7CiAgICBjdXJyZW50WCArPSBpbWcud2lkdGggKyAyICogSU1BR0VfUEFERElORzsKICAgIG1heExpbmVIZWlnaHQgPSBNYXRoLm1heChtYXhMaW5lSGVpZ2h0LCBpbWcuaGVpZ2h0KTsKICB9CiAgY29uc3QgaW1nV2lkdGggPSBNYXRoLm1heChtYXhYLCBjdXJyZW50WCkgKyBJTUFHRV9QQURESU5HOwogIGNvbnN0IGltZ0hlaWdodCA9IGN1cnJlbnRZICsgbWF4TGluZUhlaWdodCArIElNQUdFX1BBRERJTkc7CiAgY29uc3QgaW1nRGF0YSA9IG5ldyBVaW50OEFycmF5KGltZ1dpZHRoICogaW1nSGVpZ2h0ICogNCk7CiAgY29uc3QgaW1nUm93U2l6ZSA9IGltZ1dpZHRoIDw8IDI7CiAgZm9yIChsZXQgcSA9IDA7IHEgPCBjb3VudDsgcSsrKSB7CiAgICBjb25zdCBkYXRhID0gYXJnc0FycmF5W2lGaXJzdFBJSVhPICsgKHEgPDwgMildWzBdLmRhdGE7CiAgICBjb25zdCByb3dTaXplID0gbWFwW3FdLncgPDwgMjsKICAgIGxldCBkYXRhT2Zmc2V0ID0gMDsKICAgIGxldCBvZmZzZXQgPSBtYXBbcV0ueCArIG1hcFtxXS55ICogaW1nV2lkdGggPDwgMjsKIC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QgPSBpaTsKICAgICAgcmV0dXJuOwogICAgfQogICAgY29uc3QgY29udGV4dCA9IHRoaXMuY29udGV4dDsKICAgIHdoaWxlIChpIDwgaWkpIHsKICAgICAgaWYgKG1hdGNoKSB7CiAgICAgICAgY29uc3QgaXRlcmF0ZSA9ICgwLCBtYXRjaC5pdGVyYXRlRm4pKGNvbnRleHQsIGkpOwogICAgICAgIGlmIChpdGVyYXRlKSB7CiAgICAgICAgICBpKys7CiAgICAgICAgICBjb250aW51ZTsKICAgICAgICB9CiAgICAgICAgaSA9ICgwLCBtYXRjaC5wcm9jZXNzRm4pKGNvbnRleHQsIGkgKyAxKTsKICAgICAgICBpaSA9IGZuQXJyYXkubGVuZ3RoOwogICAgICAgIG1hdGNoID0gbnVsbDsKICAgICAgICBzdGF0ZSA9IG51bGw7CiAgICAgICAgaWYgKGkgPj0gaWkpIHsKICAgICAgICAgIGJyZWFrOwogICAgICAgIH0KICAgICAgfQogICAgICBzdGF0ZSA9IChzdGF0ZSB8fCBJbml0aWFsU3RhdGUpW2ZuQXJyYXlbaV1dOwogICAgICBpZiAoIXN0YXRlIHx8IEFycmF5LmlzQXJyYXkoc3RhdGUpKSB7CiAgICAgICAgaSsrOwogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGNvbnRleHQuaUN1cnIgPSBpOwogICAgICBpKys7CiAgICAgIGlmIChzdGF0ZS5jaGVja0ZuICYmICEoMCwgc3RhdGUuY2hlY2tGbikoY29udGV4dCkpIHsKICAgICAgICBzdGF0ZSA9IG51bGw7CiAgICAgICAgY29udGludWU7CiAgICAgIH0KICAgICAgbWF0Y2ggPSBzdGF0ZTsKICAgICAgc3RhdGUgPSBudWxsOwogICAgfQogICAgdGhpcy5zdGF0ZSA9IHN0YXRlOwogICAgdGhpcy5tYXRjaCA9IG1hdGNoOwogICAgdGhpcy5sYXN0UHJvY2Vzc2VkID0gaTsKICB9CiAgZmx1c2goKSB7CiAgICB3aGlsZSAodGhpcy5tYXRjaCkgew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B0aGlzLm1hdHRlID0gZGljdC5nZXQoIk1hdHRlIikgfHwgZmFsc2U7CiAgICBsZXQgYml0c1BlckNvbXBvbmVudCA9IGltYWdlLmJpdHNQZXJDb21wb25lbnQ7CiAgICBpZiAoIWJpdHNQZXJDb21wb25lbnQpIHsKICAgICAgYml0c1BlckNvbXBvbmVudCA9IGRpY3QuZ2V0KCJCUEMiLCAiQml0c1BlckNvbXBvbmVudCIpOwogICAgICBpZiAoIWJpdHNQZXJDb21wb25lbnQpIHsKICAgICAgICBpZiAodGhpcy5pbWFnZU1hc2spIHsKICAgICAgICAgIGJpdHNQZXJDb21wb25lbnQgPSAxOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoYEJpdHMgcGVyIGNvbXBvbmVudCBtaXNzaW5nIGluIGltYWdlOiAke3RoaXMuaW1hZ2VNYXNrfWApOwogICAgICAgIH0KICAgICAgfQogICAgfQogICAgdGhpcy5icGMgPSBiaXRzUGVyQ29tcG9uZW50OwogICAgaWYgKCF0aGlzLmltYWdlTWFzaykgewogICAgICBsZXQgY29sb3JTcGFjZSA9IGRpY3QuZ2V0UmF3KCJDUyIpIHx8IGRpY3QuZ2V0UmF3KCJDb2xvclNwYWNlIik7CiAgICAgIGlmICghY29sb3JTcGFjZSkgewogICAgICAgICgwLCBfdXRpbC5pbmZvKSgiSlBYIGltYWdlcyAod2hpY2ggZG8gbm90IHJlcXVpcmUgY29sb3Igc3BhY2VzKSIpOwogICAgICAgIHN3aXRjaCAoaW1hZ2UubnVtQ29tcHMpIHsKICAgICAgICAgIGNhc2UgMToKICAgICAgICAgICAgY29sb3JTcGFjZSA9IF9wcmltaXRpdmVzLk5hbWUuZ2V0KCJEZXZpY2VHcmF5Iik7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAzOgogICAgICAgICAgICBjb2xvclNwYWNlID0gX3ByaW1pdGl2ZXMuTmFtZS5nZXQoIkRldmljZVJHQiIpOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgNDoKICAgICAgICAgICAgY29sb3JTcGFjZSA9IF9wcmltaXRpdmVzLk5hbWUuZ2V0KCJEZXZpY2VDTVlLIik7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKGBKUFggaW1hZ2VzIHdpdGggJHtpbWFnZS5udW1Db21wc30gY29sb3IgY29tcG9uZW50cyBub3Qgc3VwcG9ydGVkLmApOwogICAgICAgIH0KICAgICAgfQogICAgICB0aGlzLmNvbG9yU3BhY2UgPSBfY29sb3JzcGFjZS5Db2xvclNwYWNlLnBhcnNlKHsKICAgICAgICBjczogY29sb3JTcGFjZSwKICAgICAgICB4cmVmLAogICAgICAgIHJlc291cmNlczogaXNJbmxpbmUgPyByZXMgOiBudWxsLAogICAgICAgIHBkZkZ1bmN0aW9uRmFjdG9yeSwKICAgICAgICBsb2NhbENvbG9yU3BhY2VDYWNoZQogICAgICB9KTsKICAgICAgdGhpcy5udW1Db21wcyA9IHRoaXMuY29sb3JTcGFjZS5udW1Db21wczsKICAgIH0KICAgIHRoaXMuZGVjb2RlID0gZGljdC5nZXRBcnJheSgiRCIsICJEZWNvZGUiKTsKICAgIHRoaXMubmVlZHNEZWNvZGUgPSBmYWxzZTsKICAgIGlmICh0aGlzLmRlY29kZSAmJiAodGhpcy5jb2xvclNwYWNlICYmICF0aGlzLmNvbG9yU3BhY2UuaXNEZWZhdWx0RGVjb2RlKHRoaXMuZGVjb2RlLCBiaXRzUGVyQ29tcG9uZW50KSB8fCBpc01hc2sgJiYgIV9jb2xvcnNwYWNlLkNvbG9yU3BhY2UuaXNEZWZhdWx0RGVjb2RlKHRoaXMuZGVjb2RlLCAxKSkpIHsKICAgICAgdGhpcy5uZWVkc0RlY29kZSA9IHRydWU7CiAgICAgIGNvbnN0IG1heCA9ICgxIDw8IGJpdHNQZXJDb21wb25lbnQp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gICAgICgwLCBfdXRpbC53YXJuKSgiSWdub3JpbmcgL01hc2sgaW4gaW1hZ2Ugd2l0aG91dCAvSW1hZ2VNYXNrLiIpOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICB0aGlzLm1hc2sgPSBuZXcgUERGSW1hZ2UoewogICAgICAgICAgICB4cmVmLAogICAgICAgICAgICByZXMsCiAgICAgICAgICAgIGltYWdlOiBtYXNrLAogICAgICAgICAgICBpc0lubGluZSwKICAgICAgICAgICAgaXNNYXNrOiB0cnVlLAogICAgICAgICAgICBwZGZGdW5jdGlvbkZhY3RvcnksCiAgICAgICAgICAgIGxvY2FsQ29sb3JTcGFjZUNhY2hlCiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgIH0gZWxzZSB7CiAgICAgICAgdGhpcy5tYXNrID0gbWFzazsKICAgICAgfQogICAgfQogIH0KICBzdGF0aWMgYXN5bmMgYnVpbGRJbWFnZShfcmVmMikgewogICAgbGV0IHsKICAgICAgeHJlZiwKICAgICAgcmVzLAogICAgICBpbWFnZSwKICAgICAgaXNJbmxpbmUgPSBmYWxzZSwKICAgICAgcGRmRnVuY3Rpb25GYWN0b3J5LAogICAgICBsb2NhbENvbG9yU3BhY2VDYWNoZQogICAgfSA9IF9yZWYyOwogICAgY29uc3QgaW1hZ2VEYXRhID0gaW1hZ2U7CiAgICBsZXQgc21hc2tEYXRhID0gbnVsbDsKICAgIGxldCBtYXNrRGF0YSA9IG51bGw7CiAgICBjb25zdCBzbWFzayA9IGltYWdlLmRpY3QuZ2V0KCJTTWFzayIpOwogICAgY29uc3QgbWFzayA9IGltYWdlLmRpY3QuZ2V0KCJNYXNrIik7CiAgICBpZiAoc21hc2spIHsKICAgICAgaWYgKHNtYXNrIGluc3RhbmNlb2YgX2Jhc2Vfc3RyZWFtLkJhc2VTdHJlYW0pIHsKICAgICAgICBzbWFza0RhdGEgPSBzbWFzazsKICAgICAgfSBlbHNlIHsKICAgICAgICAoMCwgX3V0aWwud2FybikoIlVuc3VwcG9ydGVkIC9TTWFzayBmb3JtYXQuIik7CiAgICAgIH0KICAgIH0gZWxzZSBpZiAobWFzaykgewogICAgICBpZiAobWFzayBpbnN0YW5jZW9mIF9iYXNlX3N0cmVhbS5CYXNlU3RyZWFtIHx8IEFycmF5LmlzQXJyYXkobWFzaykpIHsKICAgICAgICBtYXNrRGF0YSA9IG1hc2s7CiAgICAgIH0gZWxzZSB7CiAgICAgICAgKDAsIF91dGlsLndhcm4pKCJVbnN1cHBvcnRlZCAvTWFzayBmb3JtYXQuIik7CiAgICAgIH0KICAgIH0KICAgIHJldHVybiBuZXcgUERGSW1hZ2UoewogICAgICB4cmVmLAogICAgICByZXMsCiAgICAgIGltYWdlOiBpbWFnZURhdGEsCiAgICAgIGlzSW5saW5lLAogICAgICBzbWFzazogc21hc2tEYXRhLAogICAgICBtYXNrOiBtYXNrRGF0YSwKICAgICAgcGRmRnVuY3Rpb25GYWN0b3J5LAogICAgICBsb2NhbENvbG9yU3BhY2VDYWNoZQogICAgfSk7CiAgfQogIHN0YXRpYyBjcmVhdGVSYXdNYXNrKF9yZWYzKSB7CiAgICBsZXQgewogICAgICBpbWdBcnJheSwKICAgICAgd2lkdGgsCiAgICAgIGhlaWdodCwKICAgICAgaW1hZ2VJc0Zyb21EZWNvZGVTdHJlYW0sCiAgICAgIGludmVyc2VEZWNvZGUsCiAgICAgIGludGVycG9sYXRlCiAgICB9ID0gX3JlZjM7CiAgICBjb25zdCBjb21wdXRlZExlbmd0aCA9ICh3aWR0aCArIDcgPj4gMykgKiBoZWlnaHQ7CiAgICBjb25zdCBhY3R1YWxMZW5ndGggPSBpbWdBcnJheS5ieXRlTGVuZ3RoOwogICAgY29uc3QgaGF2ZUZ1bGxEYXRhID0gY29tcHV0ZWRMZW5ndGggPT09IGFjdHVhbExlbmd0aDsKICAgIGxldCBkYXRhLCBpOwogICAgaWYgKGltYWdlSXNGcm9tRGVjb2RlU3RyZWFtICYmICghaW52ZXJzZURlY29kZSB8fCBoYXZl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WdEYXRhLmRhdGEsCiAgICAgICAgd2lkdGgsCiAgICAgICAgaGVpZ2h0LAogICAgICAgIG5vbkJsYWNrQ29sb3I6IDAsCiAgICAgICAgaW52ZXJzZURlY29kZQogICAgICB9KTsKICAgICAgY3R4LnB1dEltYWdlRGF0YShpbWdEYXRhLCAwLCAwKTsKICAgICAgY29uc3QgYml0bWFwID0gY2FudmFzLnRyYW5zZmVyVG9JbWFnZUJpdG1hcCgpOwogICAgICByZXR1cm4gewogICAgICAgIGRhdGE6IG51bGwsCiAgICAgICAgd2lkdGgsCiAgICAgICAgaGVpZ2h0LAogICAgICAgIGludGVycG9sYXRlLAogICAgICAgIGJpdG1hcAogICAgICB9OwogICAgfQogICAgcmV0dXJuIHRoaXMuY3JlYXRlUmF3TWFzayh7CiAgICAgIGltZ0FycmF5LAogICAgICB3aWR0aCwKICAgICAgaGVpZ2h0LAogICAgICBpbnZlcnNlRGVjb2RlLAogICAgICBpbWFnZUlzRnJvbURlY29kZVN0cmVhbSwKICAgICAgaW50ZXJwb2xhdGUKICAgIH0pOwogIH0KICBnZXQgZHJhd1dpZHRoKCkgewogICAgcmV0dXJuIE1hdGgubWF4KHRoaXMud2lkdGgsIHRoaXMuc21hc2sgJiYgdGhpcy5zbWFzay53aWR0aCB8fCAwLCB0aGlzLm1hc2sgJiYgdGhpcy5tYXNrLndpZHRoIHx8IDApOwogIH0KICBnZXQgZHJhd0hlaWdodCgpIHsKICAgIHJldHVybiBNYXRoLm1heCh0aGlzLmhlaWdodCwgdGhpcy5zbWFzayAmJiB0aGlzLnNtYXNrLmhlaWdodCB8fCAwLCB0aGlzLm1hc2sgJiYgdGhpcy5tYXNrLmhlaWdodCB8fCAwKTsKICB9CiAgZGVjb2RlQnVmZmVyKGJ1ZmZlcikgewogICAgY29uc3QgYnBjID0gdGhpcy5icGM7CiAgICBjb25zdCBudW1Db21wcyA9IHRoaXMubnVtQ29tcHM7CiAgICBjb25zdCBkZWNvZGVBZGRlbmRzID0gdGhpcy5kZWNvZGVBZGRlbmRzOwogICAgY29uc3QgZGVjb2RlQ29lZmZpY2llbnRzID0gdGhpcy5kZWNvZGVDb2VmZmljaWVudHM7CiAgICBjb25zdCBtYXggPSAoMSA8PCBicGMpIC0gMTsKICAgIGxldCBpLCBpaTsKICAgIGlmIChicGMgPT09IDEpIHsKICAgICAgZm9yIChpID0gMCwgaWkgPSBidWZmZXIubGVuZ3RoOyBpIDwgaWk7IGkrKykgewogICAgICAgIGJ1ZmZlcltpXSA9ICshYnVmZmVyW2ldOwogICAgICB9CiAgICAgIHJldHVybjsKICAgIH0KICAgIGxldCBpbmRleCA9IDA7CiAgICBmb3IgKGkgPSAwLCBpaSA9IHRoaXMud2lkdGggKiB0aGlzLmhlaWdodDsgaSA8IGlpOyBpKyspIHsKICAgICAgZm9yIChsZXQgaiA9IDA7IGogPCBudW1Db21wczsgaisrKSB7CiAgICAgICAgYnVmZmVyW2luZGV4XSA9IGRlY29kZUFuZENsYW1wKGJ1ZmZlcltpbmRleF0sIGRlY29kZUFkZGVuZHNbal0sIGRlY29kZUNvZWZmaWNpZW50c1tqXSwgbWF4KTsKICAgICAgICBpbmRleCsrOwogICAgICB9CiAgICB9CiAgfQogIGdldENvbXBvbmVudHMoYnVmZmVyKSB7CiAgICBjb25zdCBicGMgPSB0aGlzLmJwYzsKICAgIGlmIChicGMgPT09IDgpIHsKICAgICAgcmV0dXJuIGJ1ZmZlcjsKICAgIH0KICAgIGNvbnN0IHdpZHRoID0gdGhpcy53aWR0aDsKICAgIGNvbnN0IGhlaWdodCA9IHRoaXMuaGVpZ2h0OwogICAgY29uc3QgbnVtQ29tcHMgPSB0aGlzLm51bUNvbXBzOwogICAgY29uc3QgbGVuZ3RoID0gd2lkdGggKiBoZWlnaHQgKiBudW1Db21wczsKICAgIGxldCBidWZmZXJQb3MgPSAwOwogICAgbGV0IG91dHB1dDsKICAgIGlmIChicGMgPD0gOCkgewogICAgICBvdXRwdXQgPSBuZXcgVWludDhBcnJheShsZW5ndGgpOwogICAgfSBlbHNlIGlmIChicGMgPD0gMTYpIHsKICAgICAgb3V0cHV0ID0gbmV3IFVpbnQxNkFycmF5KGxlbmd0aCk7CiAgICB9IGVsc2UgewogICAgICBvdXRwdXQgPSBuZXcgVWludDMyQXJyYXkobGVuZ3RoKTsKICAgIH0KICAgIGNvbnN0IHJvd0NvbXBzID0gd2lkdGggKiBudW1Db21wczsKICAgIGNvbnN0IG1heCA9ICgxIDw8IGJwYykgLSAxOwogICAgbGV0IGkgPSAwLAogICAgICBpaSwKICAgICAgYnVmOwogICAgaWYgKGJwYyA9PT0gMSkgewogICAgICBsZXQgbWFzaywgbG9vcDFFbmQsIGxvb3AyRW5kOwogICAgICBmb3IgKGxldCBqID0gMDsgaiA8IGhlaWdodDsgaisrKSB7CiAgICAgICAgbG9vcDFFbmQgPSBpICsgKHJvd0NvbXBzICYgfjcpOwogICAgICAgIGxvb3AyRW5kID0gaSArIHJvd0NvbXBzOwogICAgICAgIHdoaWxlIChpIDwgbG9vcDFFbmQpIHsKICAgICAgICAgIGJ1ZiA9IGJ1ZmZlcltidWZmZXJQb3MrK107CiAgICAgICAgICBvdXRwdXRbaV0gPSBidWYgPj4gNyAmIDE7CiAgICAgICAgICBvdXRwdXRbaSArIDFdID0gYnVmID4+IDYgJiAxOwogICAgICAgICAgb3V0cHV0W2kgKyAyXSA9IGJ1ZiA+PiA1ICYgMTsKICAgICAgICAgIG91dHB1dFtpICsgM10gPSBidWYgPj4gNCAmIDE7CiAgICAgICAgICBvdXRwdXRbaSArIDRdID0gYnVmID4+IDMgJiAxOwogICAgICAgICAgb3V0cHV0W2kgKyA1XSA9IGJ1ZiA+PiAyICYgMTsKICAgICAgICAgIG91dHB1dFtpICsgNl0gPSBidWYgPj4gMSAmIDE7CiAgICAgICAgICBvdXRwdXRbaSArIDddID0gYnVmICYgMTsKICAgICAgICAgIGkgKz0gODsKICAgICAgICB9CiAgICAgICAgaWYgKGkgPCBsb29wMkVuZCkgewogICAgICAgICAgYnVmID0gYnVmZmVyW2J1ZmZlclBvcysrXTsKICAgICAgICAgIG1hc2sgPSAxMjg7CiAgICAgICAgICB3aGlsZSAoaSA8IGxvb3AyRW5kKSB7CiAgICAgICAgICAgIG91dHB1dFtpKytdID0gKyEhKGJ1ZiAmIG1hc2spOwogICAgICAgICAgICBtYXNrID4+PSAxOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgfQogICAgfSBlbHNlIHsKICAgICAgbGV0IGJpdHMgPSAwOwogICAgICBidWYgPSAwOwogICAgICBmb3IgKGkgPSAwLCBpaSA9IGxlbmd0aDsgaSA8IGlpOyArK2kpIHsKICAgICAgICBpZiAoaSAlIHJvd0NvbXBzID09PSAwKSB7CiAgICAgICAgICBidWYgPSAwOwogICAgICAgICAgYml0cyA9IDA7CiAgICAgICAgfQogICAgICAgIHdoaWxlIChiaXRzIDwgYnBjKSB7CiAgICAgICAgICBidWYgPSBidWYgPDwgOCB8IGJ1ZmZlcltidWZmZXJQb3MrK107CiAgICAgICAgICBiaXRzICs9IDg7CiAgICAgICAgfQogICAgICAgIGNvbnN0IHJlbWFpbmluZ0JpdHMgPSBiaXRzIC0gYnBjOwogICAgICAgIGxldCB2YWx1ZSA9IGJ1ZiA+PiByZW1haW5pbmdCaXRzOwogICAgICAgIGlmICh2YWx1ZSA8IDApIHsKICAgICAgICAgIHZhbHVlID0gMDsKICAgICAgICB9IGVsc2UgaWYgKHZhbHVlID4gbWF4KSB7CiAgICAgICAgICB2YWx1ZSA9IG1heDsKICAgICAgICB9CiAgICAgICAgb3V0cHV0W2ldID0gdmFsdWU7CiAgICAgICAgYnVmICY9ICgxIDw8IHJlbWFpbmluZ0JpdHMpIC0gMTsKICAgICAgICBiaXRzID0gcmVtYWluaW5nQml0czsKICAgICAgfQogICAgfQogICAgcmV0dXJuIG91dHB1dDsKICB9CiAgZmlsbE9wYWNpdHkocmdiYUJ1Ziwgd2lkdGgsIGhlaWdodCwgYWN0dWFsSGVpZ2h0LCBpbWFnZSkgewogICA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AgICAgICB9CiAgICAgIH0gZWxzZSBpZiAoQXJyYXkuaXNBcnJheShtYXNrKSkgewogICAgICAgIGFscGhhQnVmID0gbmV3IFVpbnQ4Q2xhbXBlZEFycmF5KHdpZHRoICogaGVpZ2h0KTsKICAgICAgICBjb25zdCBudW1Db21wcyA9IHRoaXMubnVtQ29tcHM7CiAgICAgICAgZm9yIChpID0gMCwgaWkgPSB3aWR0aCAqIGhlaWdodDsgaSA8IGlpOyArK2kpIHsKICAgICAgICAgIGxldCBvcGFjaXR5ID0gMDsKICAgICAgICAgIGNvbnN0IGltYWdlT2Zmc2V0ID0gaSAqIG51bUNvbXBzOwogICAgICAgICAgZm9yIChqID0gMDsgaiA8IG51bUNvbXBzOyArK2opIHsKICAgICAgICAgICAgY29uc3QgY29sb3IgPSBpbWFnZVtpbWFnZU9mZnNldCArIGpdOwogICAgICAgICAgICBjb25zdCBtYXNrT2Zmc2V0ID0gaiAqIDI7CiAgICAgICAgICAgIGlmIChjb2xvciA8IG1hc2tbbWFza09mZnNldF0gfHwgY29sb3IgPiBtYXNrW21hc2tPZmZzZXQgKyAxXSkgewogICAgICAgICAgICAgIG9wYWNpdHkgPSAyNTU7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIGFscGhhQnVmW2ldID0gb3BhY2l0eTsKICAgICAgICB9CiAgICAgIH0gZWxzZSB7CiAgICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKCJVbmtub3duIG1hc2sgZm9ybWF0LiIpOwogICAgICB9CiAgICB9CiAgICBpZiAoYWxwaGFCdWYpIHsKICAgICAgZm9yIChpID0gMCwgaiA9IDMsIGlpID0gd2lkdGggKiBhY3R1YWxIZWlnaHQ7IGkgPCBpaTsgKytpLCBqICs9IDQpIHsKICAgICAgICByZ2JhQnVmW2pdID0gYWxwaGFCdWZbaV07CiAgICAgIH0KICAgIH0gZWxzZSB7CiAgICAgIGZvciAoaSA9ID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iAoIWZvcmNlUkdCQSkgewogICAgICBsZXQga2luZDsKICAgICAgaWYgKHRoaXMuY29sb3JTcGFjZS5uYW1lID09PSAiRGV2aWNlR3JheSIgJiYgYnBjID09PSAxKSB7CiAgICAgICAga2luZCA9IF91dGlsLkltYWdlS2luZC5HUkFZU0NBTEVfMUJQUDsKICAgICAgfSBlbHNlIGlmICh0aGlzLmNvbG9yU3BhY2UubmFtZSA9PT0gIkRldmljZVJHQiIgJiYgYnBjID09PSA4ICYmICF0aGlzLm5lZWRzRGVjb2RlKSB7CiAgICAgICAga2luZCA9IF91dGlsLkltYWdlS2luZC5SR0JfMjRCUFA7CiAgICAgIH0KICAgICAgaWYgKGtpbmQgJiYgIXRoaXMuc21hc2sgJiYgIXRoaXMubWFzayAmJiBkcmF3V2lkdGggPT09IG9yaWdpbmFsV2lkdGggJiYgZHJhd0hlaWdodCA9PT0gb3JpZ2luYWxIZWlnaHQpIHsKICAgICAgICBjb25zdCBkYXRhID0gdGhpcy5nZXRJbWFnZUJ5dGVzKG9yaWdpbmFsSGVpZ2h0ICogcm93Qnl0ZXMsIHt9KTsKICAgICAgICBpZiAoaXNPZmZzY3JlZW5DYW52YXNTdXBwb3J0ZWQpIHsKICAgICAgICAgIGlmIChtdXN0QmVSZXNpemVkKSB7CiAgICAgICAgICAgIHJldHVybiBfaW1hZ2VfcmVzaXplci5JbWFnZVJlc2l6ZXIuY3JlYXRlSW1hZ2UoewogICAgICAgICAgICAgIGRhdGEsCiAgICAgICAgICAgICAga2luZCwKICAgICAgICAgICAgICB3aWR0aDogZHJhd1dpZHRoLAogICAgICAgICAgICAgIGhlaWdodDogZHJhd0hlaWdodCwKICAgICAgICAgICAgICBpbnRlcnBvbGF0ZTogdGhpcy5pbnRlcnBvbGF0ZQogICAgICAgICAgICB9LCB0aGlzLm5lZWRzRGVjb2RlKTsKICAgICAgICAgIH0KICAgICAgICAgIHJldHVybiB0aGlzLmNyZWF0ZUJpdG1hcChraW5kLCBvcmlnaW5hbFd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ogICAgICAgICAgICBjYXNlICJEZXZpY2VSR0IiOgogICAgICAgICAgICAgIGltYWdlTGVuZ3RoID0gaW1hZ2VMZW5ndGggLyAzICogNDsKICAgICAgICAgICAgICBpc0hhbmRsZWQgPSB0cnVlOwogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICBjYXNlICJEZXZpY2VDTVlLIjoKICAgICAgICAgICAgICBpc0hhbmRsZWQgPSB0cnVlOwogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgfQogICAgICAgICAgaWYgKGlzSGFuZGxlZCkgewogICAgICAgICAgICBjb25zdCByZ2JhID0gdGhpcy5nZXRJbWFnZUJ5dGVzKGltYWdlTGVuZ3RoLCB7CiAgICAgICAgICAgICAgZHJhd1dpZHRoLAogICAgICAgICAgICAgIGRyYXdIZWlnaHQsCiAgICAgICAgICAgICAgZm9yY2VSR0JBOiB0cnVlCiAgICAgICAgICAgIH0pOwogICAgICAgICAgICByZXR1cm4gdGhpcy5jcmVhdGVCaXRtYXAoX3V0aWwuSW1hZ2VLaW5kLlJHQkFfMzJCUFAsIGRyYXdXaWR0aCwgZHJhd0hlaWdodCwgcmdiYSk7CiAgICAgICAgICB9CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIHN3aXRjaCAodGhpcy5jb2xvclNwYWNlLm5hbWUpIHsKICAgICAgICAgICAgY2FzZSAiRGV2aWNlR3JheSI6CiAgICAgICAgICAgICAgaW1hZ2VMZW5ndGggKj0gMzsKICAgICAgICAgICAgY2FzZSAiRGV2aWNlUkdCIjoKICAgICAgICAgICAgY2FzZSAiRGV2aWNlQ01ZSyI6CiAgICAgICAgICAgICAgaW1nRGF0YS5raW5kID0gX3V0aWwuSW1hZ2VLaW5kLlJHQl8yNEJQUDsKICAgICAgICAgICAgICBpbWdEYXRhLmRhdGEgPSB0aGlzLmdldEltYWdlQnl0ZXMoaW1hZ2VMZW5ndGgsIHsKICAgICAgICAgICAgICAgIGRyYXdXaWR0aCwKICAgICAgICAgICAg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S5zdWJzdHJpbmcoMSksIDEwKSk7CiAgICAgIH0KICAgICAgc3dpdGNoIChlbnRpdHkpIHsKICAgICAgICBjYXNlICJsdCI6CiAgICAgICAgICByZXR1cm4gIjwiOwogICAgICAgIGNhc2UgImd0IjoKICAgICAgICAgIHJldHVybiAiPiI7CiAgICAgICAgY2FzZSAiYW1wIjoKICAgICAgICAgIHJldHVybiAiJiI7CiAgICAgICAgY2FzZSAicXVvdCI6CiAgICAgICAgICByZXR1cm4gJyInOwogICAgICAgIGNhc2UgImFwb3MiOgogICAgICAgICAgcmV0dXJuICInIjsKICAgICAgfQogICAgICByZXR1cm4gdGhpcy5vblJlc29sdmVFbnRpdHkoZW50aXR5KTsKICAgIH0pOwogIH0KICBfcGFyc2VDb250ZW50KHMsIHN0YXJ0KSB7CiAgICBjb25zdCBhdHRyaWJ1dGVzID0gW107CiAgICBsZXQgcG9zID0gc3RhcnQ7CiAgICBmdW5jdGlvbiBza2lwV3MoKSB7CiAgICAgIHdoaWxlIChwb3MgPCBzLmxlbmd0aCAmJiBpc1doaXRlc3BhY2UocywgcG9zKSkgewogICAgICAgICsrcG9zOwogICAgICB9CiAgICB9CiAgICB3aGlsZSAocG9zIDwgcy5sZW5ndGggJiYgIWlzV2hpdGVzcGFjZShzLCBwb3MpICYmIHNbcG9zXSAhPT0gIj4iICYmIHNbcG9zXSAhPT0gIi8iKSB7CiAgICAgICsrcG9zOwogICAgfQogICAgY29uc3QgbmFtZSA9IHMuc3Vic3RyaW5nKHN0YXJ0LCBwb3MpOwogICAgc2tpcFdzKCk7CiAgICB3aGlsZSAocG9zIDwgcy5sZW5ndGggJiYgc1twb3NdICE9PSAiPiIgJiYgc1twb3NdICE9PSAiLyIgJiYgc1twb3NdICE9PSAiPyIpIHsKICAgICAgc2tpcFdzKCk7CiAgICAgIGxldCBhdHRyTmFtZSA9ICIiLAogICAgICAgIGF0dHJWYWx1ZSA9ICIiOwogICAgICB3aGlsZSAocG9zIDwgcy5sZW5ndGggJiYgIWlzV2hpdGVzcGFjZShzLCBwb3MpICYmIHNbcG9zXSAhPT0gIj0iKSB7CiAgICAgICAgYXR0ck5hbWUgKz0gc1twb3NdOwogICAgICAgICsrcG9zOwogICAgICB9CiAgICAgIHNraXBXcygpOwogICAgICBpZiAoc1twb3NdICE9PSAiPSIpIHsKICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgfQogICAgICArK3BvczsKICAgICAgc2tpcFdzKCk7CiAgICAgIGNvbnN0IGF0dHJFbmRDaGFyID0gc1twb3NdOwogICAgICBpZiAoYXR0ckVuZENoYXIgIT09ICciJyAmJiBhdHRyRW5kQ2hhciAhPT0gIiciKSB7CiAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgIH0KICAgICAgY29uc3QgYXR0ckVuZEluZGV4ID0gcy5pbmRleE9mKGF0dHJFbmRDaGFyLCArK3Bvcyk7CiAgICAgIGlmIChhdHRyRW5kSW5kZXggPCAwKSB7CiAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgIH0KICAgICAgYXR0clZhbHVlID0gcy5zdWJzdHJpbmcocG9zLCBhdHRyRW5kSW5kZXgpOwogICAgICBhdHRyaWJ1dGVzLnB1c2goewogICAgICAgIG5hbWU6IGF0dHJOYW1lLAogICAgICAgIHZhbHVlOiB0aGlzLl9yZXNvbHZlRW50aXRpZXMoYXR0clZhbHVlKQogICAgICB9KTsKICAgICAgcG9zID0gYXR0ckVuZEluZGV4ICsgMTsKICAgICAgc2tpcFdzKCk7CiAgICB9CiAgICByZXR1cm4gewogICAgICBuYW1lLAogICAgICBhdHRyaWJ1dGVzLAogICAgICBwYXJzZWQ6IHBvcyAtIHN0YXJ0CiAgICB9OwogIH0KICBfcGFyc2VQcm9jZXNzaW5nSW5zdHJ1Y3Rpb24ocywgc3RhcnQpIHsKICAgIGxldCBwb3MgPSBzdGFydDsKICAgIGZ1bmN0aW9uIHNraXBXcygpIHsKICAgICAgd2hpbGUgKHBvcyA8IHMubGVuZ3RoICYmIGlzV2hpdGVzcGFjZShzLCBwb3MpKSB7CiAgICAgICAgKytwb3M7CiAgICAgIH0KICAgIH0KICAgIHdoaWxlIChwb3MgPCBzLmxlbmd0aCAmJiAhaXNXaGl0ZXNwYWNlKHMsIHBvcykgJiYgc1twb3NdICE9PSAiPiIgJiYgc1twb3NdICE9PSAiPyIgJiYgc1twb3NdICE9PSAiLyIpIHsKICAgICAgKytwb3M7CiAgICB9CiAgICBjb25zdCBuYW1lID0gcy5zdWJzdHJpbmcoc3RhcnQsIHBvcyk7CiAgICBza2lwV3MoKTsKICAgIGNvbnN0IGF0dHJTdGFydCA9IHBvczsKICAgIHdoaWxlIChwb3MgPCBzLmxlbmd0aCAmJiAoc1twb3NdICE9PSAiPyIgfHwgc1twb3MgKyAxXSAhPT0gIj4iKSkgewogICAgICArK3BvczsKICAgIH0KICAgIGNvbnN0IHZhbHVlID0gcy5zdWJzdHJpbmcoYXR0clN0YXJ0LCBwb3MpOwogICAgcmV0dXJuIHsKICAgICAgbmFtZSwKICAgICAgdmFsdWUsCiAgICAgIHBhcnNlZDogcG9zIC0gc3RhcnQKICAgIH07CiAgfQogIHBhcnNlWG1sKHMpIHsKICAgIGxldCBpID0gMDsKICAgIHdoaWxlIChpIDwgcy5sZW5ndGgpIHsKICAgICAgY29uc3QgY2ggPSBzW2ldOwogICAgICBsZXQgaiA9IGk7CiAgICAgIGlmIChjaCA9PT0gIjwiKSB7CiAgICAgICAgKytqOwogICAgICAgIGNvbnN0IGNoMiA9IHNbal07CiAgICAgICAgbGV0IHE7CiAgICAgICAgc3dpdGNoIChjaDIpIHsKICAgICAgICAgIGNhc2UgIi8iOgogICAgICAgICAgICArK2o7CiAgICAgICAgICAgIHEgPSBzLmluZGV4T2YoIj4iLCBqKTsKICAgICAgICAgICAgaWYgKHEgPCAwKSB7CiAgICAgICAgICAgICAgdGhpcy5vbkVycm9yKFhNTFBhcnNlckVycm9yQ29kZS5VbnRlcm1pbmF0ZWRFbGVtZW50KTsKICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgIH0KICAgICAgICAgICAgdGhpcy5vbkVuZEVsZW1lbnQocy5zdWJzdHJpbmcoaiwgcSkpOwogICAgICAgICAgICBqID0gcSArIDE7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAiPyI6CiAgICAgICAgICAgICsrajsKICAgICAgICAgICAgY29uc3QgcGkgPSB0aGlzLl9wYXJzZVByb2Nlc3NpbmdJbnN0cnVjdGlvbihzLCBqKTsKICAgICAgICAgICAgaWYgKHMuc3Vic3RyaW5nKGogKyBwaS5wYXJzZWQsIGogKyBwaS5wYXJzZWQgKyAyKSAhPT0gIj8+IikgewogICAgICAgICAgICAgIHRoaXMub25FcnJvcihYTUxQYXJzZXJFcnJvckNvZGUuVW50ZXJtaW5hdGVkWG1sRGVjbGFyYXRpb24pOwogICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgfQogICAgICAgICAgICB0aGlzLm9uUGkocGkubmFtZSwgcGkudmFsdWUpOwogICAgICAgICAgICBqICs9IHBpLnBhcnNlZCArIDI7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAiISI6CiAgICAgICAgICAgIGlmIChzLnN1YnN0cmluZyhqICsgMSwgaiArIDMpID09PSAiLS0iKSB7CiAgICAgICAgICAgICAgcSA9IHMuaW5kZXhPZigiLS0+IiwgaiArIDMpOwogICAgICAgICAgICAgIGlmIChxIDwgMCkgewogICAgICAgICAgICAgICAgdGhpcy5vbkVycm9yKFhNTFBhcnNlckVycm9yQ29kZS5VbnRlcm1pbmF0ZWRDb21tZW50KTsKICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgdGhpcy5vbkNvbW1lbnQocy5zdWJzdHJpbmcoaiArIDMsIHEpKTsKICAgICAgICAgICAgICBqID0gcSArIDM7CiAgICAgICAgICAgIH0gZWxzZSBpZiAocy5zdWJzdHJpbmcoaiArIDEsIGogKyA4KSA9PT0gIltDREFUQVsiKSB7CiAgICAgICAgICAgICAgcSA9IHMuaW5kZXhPZigiXV0+IiwgaiArIDgpOwogICAgICAgICAgICAgIGlmIChxIDwgMCkgewogICAgICAgICAgICAgICAgdGhpcy5vbkVycm9yKFhNTFBhcnNlckVycm9yQ29kZS5VbnRlcm1pbmF0ZWRDZGF0KTsKICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgdGhpcy5vbkNkYXRhKHMuc3Vic3RyaW5nKGogKyA4LCBxKSk7CiAgICAgICAgICAgICAgaiA9IHEgKyAzOwogICAgICAgICAgICB9IGVsc2UgaWYgKHMuc3Vic3RyaW5nKGogKyAxLCBqICsgOCkgPT09ICJET0NUWVBFIikgewogICAgICAgICAgICAgIGNvbnN0IHEyID0gcy5pbmRleE9mKCJbIiwgaiArIDgpOwogICAgICAgICAgICAgIGxldCBjb21wbGV4RG9jdHlwZSA9IGZhbHNlOwogICAgICAgICAgICAgIHEgPSBzLmluZGV4T2YoIj4iLCBqICsgOCk7CiAgICAgICAgICAgICAgaWYgKHEgPCAwKSB7CiAgICAgICAgICAgICAgICB0aGlzLm9uRXJyb3IoWE1MUGFyc2VyRXJyb3JDb2RlLlVudGVybWluYXRlZERvY3R5cGVEZWNsYXJhdGlvbik7CiAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIGlmIChxMiA+IDAgJiYgcSA+IHEyKSB7CiAgICAgICAgICAgICAgICBxID0gcy5pbmRleE9mKCJdPiIsIGogKyA4KTsKICAgICAgICAgICAgICAgIGlmIChxIDwgMCkgewogICAgICAgICAgICAgICAgICB0aGlzLm9uRXJyb3IoWE1MUGFyc2VyRXJyb3JDb2RlLlVudGVybWluYXRlZERvY3R5cGVEZWNsYXJhdGlvbik7CiAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNvbXBsZXhEb2N0eXBlID0gdHJ1ZTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgY29uc3QgZG9jdHlwZUNvbnRlbnQgPSBzLnN1YnN0cmluZyhqICsgOCwgcSArIChjb21wbGV4RG9jdHlwZSA/IDEgOiAwKSk7CiAgICAgICAgICAgICAgdGhpcy5vbkRvY3R5cGUoZG9jdHlwZUNvbnRlbnQpOwogICAgICAgICAgICAgIGogPSBxICsgKGNvbXBsZXhEb2N0eXBlID8gMiA6IDEpOwogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgIHRoaXMub25FcnJvcihYTUxQYXJzZXJFcnJvckNvZGUuTWFsZm9ybWVkRWxlbWVudCk7CiAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgY29uc3QgY29udGVudCA9IHRoaXMuX3BhcnNlQ29udGVudChzLCBqKTsKICAgICAgICAgICAgaWYgKGNvbnRlbnQgPT09IG51bGwpIHsKICAgICAgICAgICAgICB0aGlzLm9uRXJyb3IoWE1MUGFyc2VyRXJyb3JDb2RlLk1hbGZvcm1lZEVsZW1lbnQpOwogICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgfQogICAgICAgICAgICBsZXQgaXNDbG9zZWQgPSBmYWxzZTsKICAgICAgICAgICAgaWYgKHMuc3Vic3RyaW5nKGogKyBjb250ZW50LnBhcnNlZCwgaiArIGNvbnRlbnQucGFyc2VkICsgMikgPT09ICIvPiIpIHsKICAgICAgICAgICAgICBpc0Nsb3NlZCA9IHRydWU7CiAgICAgICAgICAgIH0gZWxzZSBpZiAocy5zdWJzdHJpbmcoaiArIGNvbnRlbnQucGFyc2VkLCBqICsgY29udGVudC5wYXJzZWQgKyAxKSAhPT0gIj4iKSB7CiAgICAgICAgICAgICAgdGhpcy5vbkVycm9yKFhNTFBhcnNlckVycm9yQ29kZS5VbnRlcm1pbmF0ZWRFbGVtZW50KTsKICAgICAgICAgICAgICByZ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dCBjb21wb25lbnQgPSBwYXRoc1twb3NdOwogICAgY29uc3Qgc3RhY2sgPSBbXTsKICAgIGxldCBub2RlID0gdGhpczsKICAgIHdoaWxlICh0cnVlKSB7CiAgICAgIGlmIChjb21wb25lbnQubmFtZSA9PT0gbm9kZS5ub2RlTmFtZSkgewogICAgICAgIGlmIChjb21wb25lbnQucG9zID09PSAwKSB7CiAgICAgICAgICBjb25zdCByZXMgPSBub2RlLnNlYXJjaE5vZGUocGF0aHMsIHBvcyArIDEpOwogICAgICAgICAgaWYgKHJlcyAhPT0gbnVsbCkgewogICAgICAgICAgICByZXR1cm4gcmVzOwogICAgICAgICAgfQogICAgICAgIH0gZWxzZSBpZiAoc3RhY2subGVuZ3RoID09PSAwKSB7CiAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgY29uc3QgW3BhcmVudF0gPSBzdGFjay5wb3AoKTsKICAgICAgICAgIGxldCBzaWJsaW5nUG9zID0gMDsKICAgICAgICAgIGZvciAoY29uc3QgY2hpbGQgb2YgcGFyZW50LmNoaWxkTm9kZXMpIHsKICAgICAgICAgICAgaWYgKGNvbXBvbmVudC5uYW1lID09PSBjaGlsZC5ub2RlTmFtZSkgewogICAgICAgICAgICAgIGlmIChzaWJsaW5nUG9zID09PSBjb21wb25lbnQucG9zKSB7CiAgICAgICAgICAgICAgICByZXR1cm4gY2hpbGQuc2VhcmNoTm9kZShwYXRocywgcG9zICsgMSk7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIHNpYmxpbmdQb3MrKzsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgICAgcmV0dXJuIG5vZGUuc2VhcmNoTm9kZShwYXRocywgcG9zICsgMSk7CiAgICAgICAgfQogICAgICB9CiAgICAgIGlmIChub2RlLmNoaWxkTm9kZXMgJiYgbm9kZS5jaGlsZE5vZGVzLmxlbmd0aCAhPT0gMCkgewogICAgICAgIHN0YWNrLnB1c2goW25vZGUsIDBdKTsKICAgICAgICBub2RlID0gbm9kZS5jaGlsZE5vZGVzWzBdOwogICAgICB9IGVsc2UgaWYgKHN0YWNrLmxlbmd0aCA9PT0gMCkgewogICAgICAgIHJldHVybiBudWxsOwogICAgICB9IGVsc2UgewogICAgICAgIHdoaWxlIChzdGFjay5sZW5ndGggIT09IDApIHsKICAgICAgICAgIGNvbnN0IFtwYXJlbnQsIGN1cnJlbnRQb3NdID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBjb25zdCBuZXdQb3MgPSBjdXJyZW50UG9zICsgMTsKICAgICAgICAgIGlmIChuZXdQb3MgPCBwYXJlbnQuY2hpbGROb2Rlcy5sZW5ndGgpIHsKICAgICAgICAgICAgc3RhY2sucHVzaChbcGFyZW50LCBuZXdQb3NdKTsKICAgICAgICAgICAgbm9kZSA9IHBhcmVudC5jaGlsZE5vZGVzW25ld1Bvc107CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZiAoc3RhY2subGVuZ3RoID09PSAwKSB7CiAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICB9CiAgICAgIH0KICAgIH0KICB9CiAgZHVtcChidWZmZXIpIHsKICAgIGlmICh0aGlzLm5vZGVOYW1lID09PSAiI3RleHQiKSB7CiAgICAgIGJ1ZmZlci5wdXNoKCgwLCBfY29yZV91dGlscy5lbmNvZGVUb1htbFN0cmluZykodGhpcy5ub2RlVmFsdWUpKTsKICAgICAgcmV0dXJuOwogICAgfQogICAgYnVmZmVyLnB1c2goYDwke3RoaXMubm9kZU5hbWV9YCk7CiAgICBpZiAodGhpcy5hdHRyaWJ1dGVzKSB7CiAgICAgIGZvciAoY29uc3QgYXR0cmlidXRlIG9mIHRoaXMuYXR0cmlidXRlcykgewogICAgICAgIGJ1ZmZlci5wdXNoKGAgJHthdHRyaWJ1dGUubmFtZX09IiR7KDAsIF9jb3JlX3V0aWxzLmVuY29kZVRvWG1sU3RyaW5nKShhdHRyaWJ1dGUudmFsd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SA9IHBhZGRlZFtpXSB8IHBhZGRlZFtpICsgMV0gPDwgOCB8IHBhZGRlZFtpICsgMl0gPDwgMTYgfCBwYWRkZWRbaSArIDNdIDw8IDI0OwogICAgICB9CiAgICAgIGxldCBhID0gaDAsCiAgICAgICAgYiA9IGgxLAogICAgICAgIGMgPSBoMiwKICAgICAgICBkID0gaDMsCiAgICAgICAgZiwKICAgICAgICBnOwogICAgICBmb3IgKGogPSAwOyBqIDwgNjQ7ICsraikgewogICAgICAgIGlmIChqIDwgMTYpIHsKICAgICAgICAgIGYgPSBiICYgYyB8IH5iICYgZDsKICAgICAgICAgIGcgPSBqOwogICAgICAgIH0gZWxzZSBpZiAoaiA8IDMyKSB7CiAgICAgICAgICBmID0gZCAmIGIgfCB+ZCAmIGM7CiAgICAgICAgICBnID0gNSAqIGogKyAxICYgMTU7CiAgICAgICAgfSBlbHNlIGlmIChqIDwgNDgpIHsKICAgICAgICAgIGYgPSBiIF4gYyBeIGQ7CiAgICAgICAgICBnID0gMyAqIGogKyA1ICYgMTU7CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIGYgPSBjIF4gKGIgfCB+ZCk7CiAgICAgICAgICBnID0gNyAqIGogJiAxNTsKICAgICAgICB9CiAgICAgICAgY29uc3QgdG1wID0gZCwKICAgICAgICAgIHJvdGF0ZUFyZyA9IGEgKyBmICsga1tqXSArIHdbZ10gfCAwLAogICAgICAgICAgcm90YXRlID0gcltqXTsKICAgICAgICBkID0gYzsKICAgICAgICBjID0gYjsKICAgICAgICBiID0gYiArIChyb3RhdGVBcmcgPDwgcm90YXRlIHwgcm90YXRlQXJnID4+PiAzMiAtIHJvdGF0ZSkgfCAwOwogICAgICAgIGEgPSB0bXA7CiAgICAgIH0KICAgICAgaDAgPSBoMCArIGEgfCAwOwogICAgICBoMSA9IGgxICsgYiB8IDA7CiAgICAgIGgyID0gaDIgKyBjIHwgMDsKICAgICAgaDMgPSBoMyArIGQgfCAwOwogICAgfQogICAgcmV0dXJuIG5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WduKGg1KTsKICAgICAgZy5hc3NpZ24oaDYpOwogICAgICBoLmFzc2lnbihoNyk7CiAgICAgIGZvciAoaiA9IDA7IGogPCA4MDsgKytqKSB7CiAgICAgICAgdDEuYXNzaWduKGgpOwogICAgICAgIHNpZ21hUHJpbWUodG1wMSwgZSwgdG1wMik7CiAgICAgICAgdDEuYWRkKHRtcDEpOwogICAgICAgIGNoKHRtcDEsIGUsIGYsIGcsIHRtcDIpOwogICAgICAgIHQxLmFkZCh0bXAxKTsKICAgICAgICB0MS5hZGQoa1tqXSk7CiAgICAgICAgdDEuYWRkKHdbal0pOwogICAgICAgIHNpZ21hKHQyLCBhLCB0bXAyKTsKICAgICAgICBtYWoodG1wMSwgYSwgYiwgYywgdG1wMik7CiAgICAgICAgdDIuYWRkKHRtcDEpOwogICAgICAgIHRtcDMgPSBoOwogICAgICAgIGggPSBnOwogICAgICAgIGcgPSBmOwogICAgICAgIGYgPSBlOwogICAgICAgIGQuYWRkKHQxKTsKICAgICAgICBlID0gZDsKICAgICAgICBkID0gYzsKICAgICAgICBjID0gYjsKICAgICAgICBiID0gYTsKICAgICAgICB0bXAzLmFzc2lnbih0MSk7CiAgICAgICAgdG1wMy5hZGQodDIpOwogICAgICAgIGEgPSB0bXAzOwogICAgICB9CiAgICAgIGgwLmFkZChhKTsKICAgICAgaDEuYWRkKGIpOwogICAgICBoMi5hZGQoYyk7CiAgICAgIGgzLmFkZChkKTsKICAgICAgaDQuYWRkKGUpOwogICAgICBoNS5hZGQoZik7CiAgICAgIGg2LmFkZChnKTsKICAgICAgaDcuYWRkKGgpOwogICAgfQogICAgbGV0IHJlc3VsdDsKICAgIGlmICghbW9kZTM4NCkgewogICAgICByZXN1bHQgPSBuZXcgVWludDhBcnJheSg2NCk7CiAgICAgIGgwLmNvcHlUbyhyZXN1bHQsIDApOwogICAgICBoMS5jb3B5VG8ocmVzdWx0LCA4KTsKICAgICAgaDIuY29weVRvKHJlc3VsdCwgMTYpOwogICAgICBoMy5jb3B5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ICAgc3RhdGVbMTNdID0gc3RhdGVbOV07CiAgICAgIHN0YXRlWzldID0gc3RhdGVbNV07CiAgICAgIHN0YXRlWzVdID0gc3RhdGVbMV07CiAgICAgIHN0YXRlWzFdID0gdDsKICAgICAgdCA9IHN0YXRlWzE0XTsKICAgICAgdSA9IHN0YXRlWzEwXTsKICAgICAgc3RhdGVbMTRdID0gc3RhdGVbNl07CiAgICAgIHN0YXRlWzEwXSA9IHN0YXRlWzJdOwogICAgICBzdGF0ZVs2XSA9IHQ7CiAgICAgIHN0YXRlWzJdID0gdTsKICAgICAgdCA9IHN0YXRlWzE1XTsKICAgICAgdSA9IHN0YXRlWzExXTsKICAgICAgdiA9IHN0YXRlWzddOwogICAgICBzdGF0ZVsxNV0gPSBzdGF0ZVszXTsKICAgICAgc3RhdGVbMTFdID0gdDsKICAgICAgc3RhdGVbN10gPSB1OwogICAgICBzdGF0ZVszXSA9IHY7CiAgICAgIGZvciAobGV0IGogPSAwOyBqIDwgMTY7ICsraikgewogICAgICAgIHN0YXRlW2pdID0gdGhpcy5faW52X3Nbc3RhdGVbal1dOwogICAgICB9CiAgICAgIGZvciAobGV0IGogPSAwLCBrID0gaSAqIDE2OyBqIDwgMTY7ICsraiwgKytrKSB7CiAgICAgICAgc3RhdGVbal0gXj0ga2V5W2tdOwogICAgICB9CiAgICAgIGZvciAobGV0IGogPSAwOyBqIDwgMTY7IGogKz0gNCkgewogICAgICAgIGNvbnN0IHMwID0gdGhpcy5fbWl4W3N0YXRlW2pdXTsKICAgICAgICBjb25zdCBzMSA9IHRoaXMuX21peFtzdGF0ZVtqICsgMV1dOwogICAgICAgIGNvbnN0IHMyID0gdGhpcy5fbWl4W3N0YXRlW2ogKyAyXV07CiAgICAgICAgY29uc3QgczMgPSB0aGlzLl9taXhbc3RhdGVbaiArIDNdXTsKICAgICAgICB0ID0gczAgXiBzMSA+Pj4gOCBeIHMxIDw8IDI0IF4gczIgPj4+IDE2IF4gczIgPDwgMTYgXiBzMyA+Pj4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GogPSAwOyBqIDwgMTY7ICsraikgewogICAgICBzdGF0ZVtqXSBePSBrZXlbal07CiAgICB9CiAgICBmb3IgKGxldCBpID0gMTsgaSA8IHRoaXMuX2N5Y2xlc09mUmVwZXRpdGlvbjsgaSsrKSB7CiAgICAgIGZvciAobGV0IGogPSAwOyBqIDwgMTY7ICsraikgewogICAgICAgIHN0YXRlW2pdID0gc1tzdGF0ZVtqXV07CiAgICAgIH0KICAgICAgdiA9IHN0YXRlWzFdOwogICAgICBzdGF0ZVsxXSA9IHN0YXRlWzVdOwogICAgICBzdGF0ZVs1XSA9IHN0YXRlWzldOwogICAgICBzdGF0ZVs5XSA9IHN0YXRlWzEzXTsKICAgICAgc3RhdGVbMTNdID0gdjsKICAgICAgdiA9IHN0YXRlWzJdOwogICAgICB1ID0gc3RhdGVbNl07CiAgICAgIHN0YXRlWzJdID0gc3RhdGVbMTBdOwogICAgICBzdGF0ZVs2XSA9IHN0YXRlWzE0XTsKICAgICAgc3RhdGVbMTBdID0gdjsKICAgICAgc3RhdGVbMTRdID0gdTsKICAgICAgdiA9IHN0YXRlWzNdOwogICAgICB1ID0gc3RhdGVbN107CiAgICAgIHQgPSBzdGF0ZVsxMV07CiAgICAgIHN0YXRlWzNdID0gc3RhdGVbMTVdOwogICAgICBzdGF0ZVs3XSA9IHY7CiAgICAgIHN0YXRlWzExXSA9IHU7CiAgICAgIHN0YXRlWzE1XSA9IHQ7CiAgICAgIGZvciAobGV0IGogPSAwOyBqIDwgMTY7IGogKz0gNCkgewogICAgICAgIGNvbnN0IHMwID0gc3RhdGVbaiArIDBdOwogICAgICAgIGNvbnN0IHMxID0gc3RhdGVbaiArIDFdOwogICAgICAgIGNvbnN0IHMyID0gc3RhdGVbaiArIDJdOwogICAgICAgIGNvbnN0IHMzID0gc3RhdGVbaiArIDNdOwogICAgICAgIHQgPSBzMCBeIHMxIF4gczIgXiBzMzsKICAgICAgICBzdGF0ZVtqICsgMF0gXj0gdCBeIHRoaXMuX21peENvbFtz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CAweDRkLCAweDlhLCAweDJmLCAweDVlLCAweGJjLCAweDYzLCAweGM2LCAweDk3LCAweDM1LCAweDZhLCAweGQ0LCAweGIzLCAweDdkLCAweGZhLCAweGVmLCAweGM1LCAweDkxLCAweDM5LCAweDcyLCAweGU0LCAweGQzLCAweGJkLCAweDYxLCAweGMyLCAweDlmLCAweDI1LCAweDRhLCAweDk0LCAweDMzLCAweDY2LCAweGNjLCAweDgzLCAweDFkLCAweDNhLCAweDc0LCAweGU4LCAweGNiLCAweDhkLCAweDAxLCAweDAyLCAweDA0LCAweDA4LCAweDEwLCAweDIwLCAweDQwLCAweDgwLCAweDFiLCAweDM2LCAweDZjLCAweGQ4LCAweGFiLCAweDRkLCAweDlhLCAweDJmLCAweDVlLCAweGJjLCAweDYzLCAweGM2LCAweDk3LCAweDM1LCAweDZhLCAweGQ0LCAweGIzLCAweDdkLCAweGZhLCAweGVmLCAweGM1LCAweDkxLCAweDM5LCAweDcyLCAweGU0LCAweGQzLCAweGJkLCAweDYxLCAweGMyLCAweDlmLCAweDI1LCAweDRhLCAweDk0LCAweDMzLCAweDY2LCAweGNjLCAweDgzLCAweDFkLCAweDNhLCAweDc0LCAweGU4LCAweGNiLCAweDhkLCAweDAxLCAweDAyLCAweDA0LCAweDA4LCAweDEwLCAweDIwLCAweDQwLCAweDgwLCAweDFiLCAweDM2LCAweDZjLCAweGQ4LCAweGFiLCAweDRkLCAweDlhLCAweDJmLCAweDVlLCAweGJjLCAweDYzLCAweGM2LCAweDk3LCAweDM1LCAweDZhLCAweGQ0LCAweGIzLCAweDdkLCAweGZhLCAweGVmLCAweGM1LCAweDkxLCAweDM5LCAweDcyLCAweGU0LCAweGQzLCAweGJkLCAweDYxLCAweGMyLCAweDlmLCAweDI1LCAweDRhLCAweDk0LCAweDMzLCAweDY2LCAweGNjLCAweDgzLCAweDFkLCAweDNhLCAweDc0LCAweGU4LCAweGNiLCAweDhkLCAweDAxLCAweDAyLCAweDA0LCAweDA4LCAweDEwLCAweDIwLCAweDQwLCAweDgwLCAweDFiLCAweDM2LCAweDZjLCAweGQ4LCAweGFiLCAweDRkLCAweDlhLCAweDJmLCAweDVlLCAweGJjLCAweDYzLCAweGM2LCAweDk3LCAweDM1LCAweDZhLCAweGQ0LCAweGIzLCAweDdkLCAweGZhLCAweGVmLCAweGM1LCAweDkxLCAweDM5LCAweDcyLCAweGU0LCAweGQzLCAweGJkLCAweDYxLCAweGMyLCAweDlmLCAweDI1LCAweDRhLCAweDk0LCAweDMzLCAweDY2LCAweGNjLCAweDgzLCAweDFkLCAweDNhLCAweDc0LCAweGU4LCAweGNiLCAweDhkLCAweDAxLCAweDAyLCAweDA0LCAweDA4LCAweDEwLCAweDIwLCAweDQwLCAweDgwLCAweDFiLCAweDM2LCAweDZjLCAweGQ4LCAweGFiLCAweDRkLCAweDlhLCAweDJmLCAweDVlLCAweGJjLCAweDYzLCAweGM2LCAweDk3LCAweDM1LCAweDZhLCAweGQ0LCAweGIzLCAweDdkLCAweGZhLCAweGVmLCAweGM1LCAweDkxLCAweDM5LCAweDcyLCAweGU0LCAweGQzLCAweGJkLCAweDYxLCAweGMyLCAweDlmLCAweDI1LCAweDRhLCAweDk0LCAweDMzLCAweDY2LCAweGNjLCAweDgzLCAweDFkLCAweDNhLCAweDc0LCAweGU4LCAweGNiLCAweDhkXSk7CiAgICB0aGlzLl9rZXkgPSB0aGlzLl9leHBhbmRLZXkoa2V5KTsKICB9CiAgX2V4cGFuZEtleShjaXBoZXJLZXkpIHsKICAgIGNvbnN0IGIgPSAxNzY7CiAgICBjb25zdCBzID0gdGhpcy5fczsKICAgIGNvbnN0IHJjb24gPSB0aGlzLl9yY29uOwogICAgY29uc3QgcmVzdWx0ID0gbmV3IFVpbnQ4QXJyYXkoYik7CiAgICByZXN1bHQuc2V0KGNpcGhlcktleSk7CiAgICBmb3IgKGxldCBqID0gMTYsIGkgPSAxOyBqIDwgYjsgKytpKSB7CiAgICAgIGxldCB0MSA9IHJlc3VsdFtqIC0gM107CiAgICAgIGxldCB0MiA9IHJlc3VsdFtqIC0gMl07CiAgICAgIGxldCB0MyA9IHJlc3VsdFtqIC0gMV07CiAgICAgIGxldCB0NCA9IHJlc3VsdFtqIC0gNF07CiAgICAgIHQxID0gc1t0MV07CiAgICAgIHQyID0gc1t0Ml07CiAgICAgIHQzID0gc1t0M107CiAgICAgIHQ0ID0gc1t0NF07CiAgICAgIHQxIF49IHJjb25baV07CiAgICAgIGZvciAobGV0IG4gPSAwOyBuIDwgNDsgKytuKSB7CiAgICAgICAgcmVzdWx0W2pdID0gdDEgXj0gcmVzdWx0W2ogLSAxNl07CiAgICAgICAgaisrOwogICAgICAgIHJlc3VsdFtqXSA9IHQyIF49IHJlc3VsdFtqIC0gMTZdOwogICAgICAgIGorKzsKICAgICAgICByZXN1bHRbal0gPSB0MyBePSByZXN1bHRbaiAtIDE2XTsKICAgICAgICBqKys7CiAgICAgICAgcmVzdWx0W2pdID0gdDQgXj0gcmVzdWx0W2ogLSAxNl07CiAgICAgICAgaisrOwogICAgICB9CiAgICB9CiAgICByZXR1cm4gcmVzdWx0OwogIH0KfQpleHBvcnRzLkFFUzEyOENpcGhlciA9IEFFUzEyOENpcGhlcjsKY2xhc3MgQUVTMjU2Q2lwaGVyIGV4dGVuZHMgQUVTQmFzZUNpcGhlciB7CiAgY29uc3RydWN0b3Ioa2V5KSB7CiAgICBzdXBlcigpOwogICAgdGhpcy5fY3ljbGVzT2ZSZXBldGl0aW9uID0gMTQ7CiAgICB0aGlzLl9rZXlTaXplID0gMjI0OwogICAgdGhpcy5fa2V5ID0gdGhpcy5fZXhwYW5kS2V5KGtleSk7CiAgfQogIF9leHBhbmRLZXkoY2lwaGVyS2V5KSB7CiAgICBjb25zdCBiID0gMjQwOwogICAgY29uc3QgcyA9IHRoaXMuX3M7CiAgICBjb25zdCByZXN1bHQgPSBuZXcgVWludDhBcnJheShiKTsKICAgIHJlc3VsdC5zZXQoY2lwaGVyS2V5KTsKICAgIGxldCByID0gMTsKICAgIGxldCB0MSwgdDIsIHQzLCB0NDsKICAgIGZvciAobGV0IGogPSAzMiwgaSA9IDE7IGogPCBiOyArK2kpIHsKICAgICAgaWYgKGogJSAzMiA9PT0gMTYpIHsKICAgICAgICB0MSA9IHNbdDFdOwogICAgICAgIHQyID0gc1t0Ml07CiAgICAgICAgdDMgPSBzW3QzXTsKICAgICAgICB0NCA9IHNbdDRdOwogICAgICB9IGVsc2UgaWYgKGogJSAzMiA9PT0gMCkgewogICAgICAgIHQxID0gcmVzdWx0W2ogLSAzXTsKICAgICAgICB0MiA9IHJlc3VsdFtqIC0gMl07CiAgICAgICAgdDMgPSByZXN1bHRbaiAtIDFdOwogICAgICAgIHQ0ID0gcmVzdWx0W2ogLSA0XTsKICAgICAgICB0MSA9IHNbdDFdOwogICAgICAgIHQyID0gc1t0Ml07CiAgICAgICAgdDMgPSBzW3QzXTsKICAgICAgICB0NCA9IHNbdDRdOwogICAgICAgIHQxIF49IHI7CiAgICAgICAgaWYgKChyIDw8PSAxKSA+PSAyNTYpIHsKICAgICAgICAgIHIgPSAociBeIDB4MWIpICYgMHhmZjsKICAgICAgICB9CiAgICAgIH0KICAgICAgZm9yIChsZXQgbiA9IDA7IG4gPCA0OyArK24pIHsKICAgICAgICByZXN1bHRbal0gPSB0MSBePSByZXN1bHRbaiAtIDMyXTsKICAgICAgICBqKys7CiAgICAgICAgcmVzdWx0W2pdID0gdDIgXj0gcmVzdWx0W2ogLSAzMl07CiAgICAgICAgaisrOwogICAgICAgIHJlc3VsdFtqXSA9IHQzIF49IHJlc3VsdFtqIC0gMzJdOwogICAgICAgIGorKzsKICAgICAgICByZXN1bHRbal0gPSB0NCBePSByZXN1bHRbaiAtIDMyXTsKICAgICAgICBqKys7CiAgICAgIH0KICAgIH0KICAgIHJldHVybiByZXN1bHQ7CiAgfQp9CmV4cG9ydHMuQUVTMjU2Q2lwaGVyID0gQUVTMjU2Q2lwaGVyOwpjbGFzcyBQREYxNyB7CiAgY2hlY2tPd25lclBhc3N3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AwLCBpKSk7CiAgICAgIG4gPSBlbmNyeXB0aW9uS2V5Lmxlbmd0aDsKICAgICAgY29uc3QgZGVyaXZlZEtleSA9IG5ldyBVaW50OEFycmF5KG4pOwogICAgICBmb3IgKGogPSAxOyBqIDw9IDE5OyArK2opIHsKICAgICAgICBmb3IgKGxldCBrID0gMDsgayA8IG47ICsraykgewogICAgICAgICAgZGVyaXZlZEtleVtrXSA9IGVuY3J5cHRpb25LZXlba10gXiBqOwogICAgICAgIH0KICAgICAgICBjaXBoZXIgPSBuZXcgQVJDRm91ckNpcGhlcihkZXJpdmVkS2V5KTsKICAgICAgICBjaGVja0RhdGEgPSBjaXBoZXIuZW5jcnlwdEJsb2NrKGNoZWNrRGF0YSk7CiAgICAgIH0KICAgICAgZm9yIChqID0gMCwgbiA9IGNoZWNrRGF0YS5sZW5ndGg7IGogPCBuOyArK2opIHsKICAgICAgICBpZiAodXNlclBhc3N3b3JkW2pdICE9PSBjaGVja0RhdGFbal0pIHsKICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgIH0KICAgICAgfQogICAgfSBlbHNlIHsKICAgICAgY2lwaGVyID0gbmV3IEFSQ0ZvdXJDaXBoZXIoZW5jcnlwdGlvbktleSk7CiAgICAgIGNoZWNrRGF0YSA9IGNpcGhlci5lbmNyeXB0QmxvY2soZGVmYXVsdFBhc3N3b3JkQnl0ZXMpOwogICAgICBmb3IgKGogPSAwLCBuID0gY2hlY2tEYXRhLmxlbmd0aDsgaiA8IG47ICsraikgewogICAgICAgIGlmICh1c2VyUGFzc3dvcmRbal0gIT09IGNoZWNrRGF0YVtqXSkgewogICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgfQogICAgICB9CiAgICB9CiAgICByZXR1cm4gZW5jcnlwdGlvbktleTsKICB9CiAgZnVuY3Rpb24gZGVjb2RlVXNlclBhc3N3b3JkKHBhc3N3b3JkLCBvd25lclBhc3N3b3JkLCByZXZpc2lvbiwga2V5TGVuZ3RoKSB7CiAgICBjb25z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IlhNTCIpKSB7CiAgICAgICAgICBjb25zdCBkYXRhID0gKDAsIF91dGlsLnN0cmluZ1RvVVRGOFN0cmluZykoc3RyZWFtLmdldFN0cmluZygpKTsKICAgICAgICAgIGlmIChkYXRhKSB7CiAgICAgICAgICAgIG1ldGFkYXRhID0gbmV3IF9tZXRhZGF0YV9wYXJzZXIuTWV0YWRhdGFQYXJzZXIoZGF0YSkuc2VyaWFsaXphYmxlOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgfQogICAgfSBjYXRjaCAoZXgpIHsKICAgICAgaWYgKGV4IGluc3RhbmNlb2YgX2NvcmVfdXRpbHMuTWlzc2luZ0RhdGFFeGNlcHRpb24pIHsKICAgICAgICB0aHJvdyBleDsKICAgICAgfQogICAgICAoMCwgX3V0aWwuaW5mbykoYFNraXBwaW5nIGludmFsaWQgTWV0YWRhdGE6ICIke2V4fSIuYCk7CiAgICB9CiAgICByZXR1cm4gKDAsIF91dGlsLnNoYWRvdykodGhpcywgIm1ldGFkYXRhIiwgbWV0YWRhdGEpOwogIH0KICBnZXQgbWFya0luZm8oKSB7CiAgICBsZXQgbWFya0luZm8gPSBudWxsOwogICAgdHJ5IHsKICAgICAgbWFya0luZm8gPSB0aGlzLl9yZWFkTWFya0luZm8oKTsKICAgIH0gY2F0Y2ggKGV4KSB7CiAgICAgIGlmIChleCBpbnN0YW5jZW9mIF9jb3JlX3V0aWxzLk1pc3NpbmdEYXRhRXhjZXB0aW9uKSB7CiAgICAgICAgdGhyb3cgZXg7CiAgICAgIH0KICAgICAgKDAsIF91dGlsLndhcm4pKCJVbmFibGUgdG8gcmVhZCBtYXJrIGluZm8uIik7CiAgICB9CiAgICByZXR1cm4gKDAsIF91dGlsLnNoYWRvdykodGhpcywgIm1hcmtJbmZvIiwgbWFya0luZm8pOwogIH0KICBfcmVhZE1hcmtJbmZvKCkgewogICAgY29uc3Qgb2JqID0gdGhpcy5fY2F0RGljdC5nZXQoIk1hcmtJbmZvIik7CiAgICBpZiAoIShvYmogaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5EaWN0KSkgewogICAgICByZXR1cm4gbnVsbDsKICAgIH0KICAgIGNvbnN0IG1hcmtJbmZvID0gewogICAgICBNYXJrZWQ6IGZhbHNlLAogICAgICBVc2VyUHJvcGVydGllczogZmFsc2UsCiAgICAgIFN1c3BlY3RzOiBmYWxzZQogICAgfTsKICAgIGZvciAoY29uc3Qga2V5IGluIG1hcmtJbmZvKSB7CiAgICAgIGNvbnN0IHZhbHVlID0gb2JqLmdldChrZXkpOwogICAgICBpZiAodHlwZW9mIHZhbHVlID09PSAiYm9vbGVhbiIpIHsKICAgICAgICBtYXJrSW5mb1trZXldID0gdmFsdWU7CiAgICAgIH0KICAgIH0KICAgIHJldHVybiBtYXJrSW5mbzsKICB9CiAgZ2V0IHN0cnVjdFRyZWVSb290KCkgewogICAgbGV0IHN0cnVjdFRyZWUgPSBudWxsOwogICAgdHJ5IHsKICAgICAgc3RydWN0VHJlZSA9IHRoaXMuX3JlYWRTdHJ1Y3RUcmVlUm9vdCgpOwogICAgfSBjYXRjaCAoZXgpIHsKICAgICAgaWYgKGV4IGluc3RhbmNlb2YgX2NvcmVfdXRpbHMuTWlzc2luZ0RhdGFFeGNlcHRpb24pIHsKICAgICAgICB0aHJvdyBleDsKICAgICAgfQogICAgICAoMCwgX3V0aWwud2FybikoIlVuYWJsZSByZWFkIHRvIHN0cnVjdFRyZWVSb290IGluZm8uIik7CiAgICB9CiAgICByZXR1cm4gKDAsIF91dGlsLnNoYWRvdykodGhpcywgInN0cnVjdFRyZWVSb290Iiwgc3RydWN0VHJlZSk7CiAgfQogIF9yZWFkU3RydWN0VHJlZVJvb3QoKSB7CiAgICBjb25zdCBvYmogPSB0aGlzLl9jYXREaWN0LmdldCgiU3RydWN0VHJlZVJvb3QiKTsKICAgIGlmICghKG9iaiBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLkRpY3QpKSB7CiAgICAgIHJldHVybiBudWxsOwogICAgfQogICAgY29u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JldHVybiBudWxsOwogICAgfQogICAgb2JqID0gb2JqLmdldFJhdygiRmlyc3QiKTsKICAgIGlmICghKG9iaiBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLlJlZikpIHsKICAgICAgcmV0dXJuIG51bGw7CiAgICB9CiAgICBjb25zdCByb290ID0gewogICAgICBpdGVtczogW10KICAgIH07CiAgICBjb25zdCBxdWV1ZSA9IFt7CiAgICAgIG9iaiwKICAgICAgcGFyZW50OiByb290CiAgICB9XTsKICAgIGNvbnN0IHByb2Nlc3NlZCA9IG5ldyBfcHJpbWl0aXZlcy5SZWZTZXQoKTsKICAgIHByb2Nlc3NlZC5wdXQob2JqKTsKICAgIGNvbnN0IHhyZWYgPSB0aGlzLnhyZWYsCiAgICAgIGJsYWNrQ29sb3IgPSBuZXcgVWludDhDbGFtcGVkQXJyYXkoMyk7CiAgICB3aGlsZSAocXVldWUubGVuZ3RoID4gMCkgewogICAgICBjb25zdCBpID0gcXVldWUuc2hpZnQoKTsKICAgICAgY29uc3Qgb3V0bGluZURpY3QgPSB4cmVmLmZldGNoSWZSZWYoaS5vYmopOwogICAgICBpZiAob3V0bGluZURpY3QgPT09IG51bGwpIHsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBpZiAoIW91dGxpbmVEaWN0LmhhcygiVGl0bGUiKSkgewogICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiSW52YWxpZCBvdXRsaW5lIGl0ZW0gZW5jb3VudGVyZWQuIik7CiAgICAgIH0KICAgICAgY29uc3QgZGF0YSA9IHsKICAgICAgICB1cmw6IG51bGwsCiAgICAgICAgZGVzdDogbnVsbCwKICAgICAgICBhY3Rpb246IG51bGwKICAgICAgfTsKICAgICAgQ2F0YWxvZy5wYXJzZURlc3REaWN0aW9uYXJ5KHsKICAgICAgICBkZXN0RGljdDogb3V0bGluZURpY3QsCiAgICAgICAgcmVzdWx0T2JqOiBkYXRhLAogICAgICAgIGRvY0Jhc2VVcmw6IHR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yLmlzSW50ZWdlcihjb3VudCkgPyBjb3VudCA6IHVuZGVmaW5lZCwKICAgICAgICBib2xkOiAhIShmbGFncyAmIDIpLAogICAgICAgIGl0YWxpYzogISEoZmxhZ3MgJiAxKSwKICAgICAgICBpdGVtczogW10KICAgICAgfTsKICAgICAgaS5wYXJlbnQuaXRlbXMucHVzaChvdXRsaW5lSXRlbSk7CiAgICAgIG9iaiA9IG91dGxpbmVEaWN0LmdldFJhdygiRmlyc3QiKTsKICAgICAgaWYgKG9iaiBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLlJlZiAmJiAhcHJvY2Vzc2VkLmhhcyhvYmopKSB7CiAgICAgICAgcXVldWUucHVzaCh7CiAgICAgICAgICBvYmosCiAgICAgICAgICBwYXJlbnQ6IG91dGxpbmVJdGVtCiAgICAgICAgfSk7CiAgICAgICAgcHJvY2Vzc2VkLnB1dChvYmopOwogICAgICB9CiAgICAgIG9iaiA9IG91dGxpbmVEaWN0LmdldFJhdygiTmV4dCIpOwogICAgICBpZiAob2JqIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuUmVmICYmICFwcm9jZXNzZWQuaGFzKG9iaikpIHsKICAgICAgICBxdWV1ZS5wdXNoKHsKICAgICAgICAgIG9iaiwKICAgICAgICAgIHBhcmVudDogaS5wYXJlbnQKICAgICAgICB9KTsKICAgICAgICBwcm9jZXNzZWQucHV0KG9iaik7CiAgICAgIH0KICAgIH0KICAgIHJldHVybiByb290Lml0ZW1zLmxlbmd0aCA+IDAgPyByb290Lml0ZW1zIDogbnVsbDsKICB9CiAgZ2V0IHBlcm1pc3Npb25zKCkgewogICAgbGV0IHBlcm1pc3Npb25zID0gbnVsbDsKICAgIHRyeSB7CiAgICAgIHBlcm1pc3Npb25zID0gdGhpcy5fcmVhZFBlcm1pc3Npb25zKCk7CiAgICB9IGNhdGNoIChleCkgewogICAgICBpZiAoZXggaW5zdGFuY2VvZiBfY29yZV91dGlscy5NaXNzaW5nRGF0YUV4Y2VwdGlvbikgewogICAgICAgIHRocm93IGV4OwogICAgICB9CiAgICAgICgwLCBfdXRpbC53YXJuKSgiVW5hYmxlIHRvIHJlYWQgcGVybWlzc2lvbnMuIik7CiAgICB9CiAgICByZXR1cm4gKDAsIF91dGlsLnNoYWRvdykodGhpcywgInBlcm1pc3Npb25zIiwgcGVybWlzc2lvbnMpOwogIH0KICBfcmVhZFBlcm1pc3Npb25zKCkgewogICAgY29uc3QgZW5jcnlwdCA9IHRoaXMueHJlZi50cmFpbGVyLmdldCgiRW5jcnlwdCIpOwogICAgaWYgKCEoZW5jcnlwdCBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLkRpY3QpKSB7CiAgICAgIHJldHVybiBudWxsOwogICAgfQogICAgbGV0IGZsYWdzID0gZW5jcnlwdC5nZXQoIlAiKTsKICAgIGlmICh0eXBlb2YgZmxhZ3MgIT09ICJudW1iZXIiKSB7CiAgICAgIHJldHVybiBudWxsOwogICAgfQogICAgZmxhZ3MgKz0gMiAqKiAzMjsKICAgIGNvbnN0IHBlcm1pc3Npb25zID0gW107CiAgICBmb3IgKGNvbnN0IGtleSBpbiBfdXRpbC5QZXJtaXNzaW9uRmxhZykgewogICAgICBjb25zdCB2YWx1ZSA9IF91dGlsLlBlcm1pc3Npb25GbGFnW2tleV07CiAgICAgIGlmIChmbGFncyAmIHZhbHVlKSB7CiAgICAgICAgcGVybWlzc2lvbnMucHVzaCh2YWx1ZSk7CiAgICAgIH0KICAgIH0KICAgIHJldHVybiBwZXJtaXNzaW9uczsKICB9CiAgZ2V0IG9wdGlvbmFsQ29udGVudENvbmZpZygpIHsKICAgIGxldCBjb25maWcgPSBudWxsOwogICAgdHJ5IHsKICAgICAgY29uc3QgcHJvcGVydGllcyA9IHRoaXMuX2NhdERpY3QuZ2V0KCJPQ1Byb3BlcnRpZXMiKTsKICAgICAgaWYgKCFwcm9wZXJ0aWVzKSB7CiAgICAgICAgcmV0dXJuICgwLCBfdXRpbC5zaGFkb3cpKHRoaXMsICJvcHRpb25hbENvbnRlbnRDb25maWciLCBudWxsKTsKICAgICAgfQogICAgICBjb25zdCBkZWZhdWx0Q29uZmlnID0gcHJvcGVydGllcy5nZXQoIkQiKTsKICAgICAgaWYgKCFkZWZhdWx0Q29uZmlnKSB7CiAgICAgICAgcmV0dXJuICgwLCBfdXRpbC5zaGFkb3cpKHRoaXMsICJvcHRpb25hbENvbnRlbnRDb25maWciLCBudWxsKTsKICAgICAgfQogICAgICBjb25zdCBncm91cHNEYXRhID0gcHJvcGVydGllcy5nZXQoIk9DR3MiKTsKICAgICAgaWYgKCFBcnJheS5pc0FycmF5KGdyb3Vwc0RhdGEpKSB7CiAgICAgICAgcmV0dXJuICgwLCBfdXRpbC5zaGFkb3cpKHRoaXMsICJvcHRpb25hbENvbnRlbnRDb25maWciLCBudWxsKTsKICAgICAgfQogICAgICBjb25zdCBncm91cHMgPSBbXTsKICAgICAgY29uc3QgZ3JvdXBSZWZzID0gW107CiAgICAgIGZvciAoY29uc3QgZ3JvdXBSZWYgb2YgZ3JvdXBzRGF0YSkgewogICAgICAgIGlmICghKGdyb3VwUmVmIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuUmVmKSkgewogICAgICAgICAgY29udGludWU7CiAgICAgICAgfQogICAgICAgIGdyb3VwUmVmcy5wdXNoKGdyb3VwUmVmKTsKICAgICAgICBjb25zdCBncm91cCA9IHRoaXMueHJlZi5mZXRjaElmUmVmKGdyb3VwUmVmKTsKICAgICAgICBncm91cHMucHVzaCh7CiAgICAgICAgICBpZDogZ3JvdXBSZWYudG9TdHJpbmcoKSwKICAgICAgICAgIG5hbWU6IHR5cGVvZiBncm91cC5nZXQoIk5hbWUiKSA9PT0gInN0cmluZyIgPyAoMCwgX3V0aWwuc3RyaW5nVG9QREZTdHJpbmcpKGdyb3VwLmdldCgiTmFtZSIpKSA6IG51bGwsCiAgICAgICAgICBpbnRlbnQ6IHR5cGVvZiBncm91cC5nZXQoIkludGVudCIpID09PSAic3RyaW5nIiA/ICgwLCBfdXRpbC5zdHJpbmdUb1BERlN0cmluZykoZ3JvdXAuZ2V0KCJJbnRlbnQiKSkgOiBudWxsCiAgICAgICAgfSk7CiAgICAgIH0KICAgICAgY29uZmlnID0gdGhpcy5fcmVhZE9wdGlvbmFsQ29udGVudENvbmZpZyhkZWZhdWx0Q29uZmlnLCBncm91cFJlZnMpOwogICAgICBjb25maWcuZ3JvdXBzID0gZ3JvdXBzOwogICAgfSBjYXRjaCAoZXgpIHsKICAgICAgaWYgKGV4IGluc3RhbmNlb2YgX2NvcmVfdXRpbHMuTWlzc2luZ0RhdGFFeGNlcHRpb24pIHsKICAgICAgICB0aHJvdyBleDsKICAgICAgfQogICAgICAoMCwgX3V0aWwud2FybikoYFVuYWJsZSB0byByZWFkIG9wdGlvbmFsIGNvbnRlbnQgY29uZmlnOiAke2V4fWApOwogICAgfQogICAgcmV0dXJuICgwLCBfdXRpbC5zaGFkb3cpKHRoaXMsICJvcHRpb25hbENvbnRlbnRDb25maWciLCBjb25maWcpOwogIH0KICBfcmVhZE9wdGlvbmFsQ29udGVudENvbmZpZyhjb25maWcsIGNvbnRlbnRHcm91cFJlZnMpIHsKICAgIGZ1bmN0aW9uIHBhcnNlT25PZmYocmVmcykgewogICAgICBjb25zdCBvblBhcnNlZCA9IFtdOwogICAgICBpZiAoQXJyYXkuaXNBcnJheShyZWZzKSkgewogICAgICAgIGZvciAoY29uc3QgdmFsdWUgb2YgcmVmcykgewogICAgICAgICAgaWYgKCEodmFsdWUgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5SZWYpKSB7CiAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgfQogICAgICAgICAgaWYgKGNvbnRlbnRHcm91cFJlZnMuaW5jbHVkZXModmFsdWUpKSB7CiAgICAgICAgICAgIG9uUGFyc2VkLnB1c2godmFsdWUudG9TdHJpbmcoKSk7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9CiAgICAgIHJldHVybiBvblBhcnNlZDsKICAgIH0KICAgIGZ1bmN0aW9uIHBhcnNlT3JkZXIocmVmcykgewogICAgICBsZXQgbmVzdGVkTGV2ZWxzID0gYXJndW1lbnRzLmxlbmd0aCA+IDEgJiYgYXJndW1lbnRzWzFdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMV0gOiAwOwogICAgICBpZiAoIUFycmF5LmlzQXJyYXkocmVmcykpIHsKICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgfQogICAgICBjb25zdCBvcmRlciA9IFtdOwogICAgICBmb3IgKGNvbnN0IHZhbHVlIG9mIHJlZnMpIHsKICAgICAgICBpZiAodmFsdWUgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5SZWYgJiYgY29udGVudEdyb3VwUmVmcy5pbmNsdWRlcyh2YWx1ZSkpIHsKICAgICAgICAgIHBhcnNlZE9yZGVyUmVmcy5wdXQodmFsdWUpOwogICAgICAgICAgb3JkZXIucHVzaCh2YWx1ZS50b1N0cmluZygpKTsKICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgIH0KICAgICAgICBjb25zdCBuZXN0ZWRPcmRlciA9IHBhcnNlTmVzdGVkT3JkZXIodmFsdWUsIG5lc3RlZExldmVscyk7CiAgICAgICAgaWYgKG5lc3RlZE9yZGVyKSB7CiAgICAgICAgICBvcmRlci5wdXNoKG5lc3RlZE9yZGVyKTsKICAgICAgICB9CiAgICAgIH0KICAgICAgaWYgKG5lc3RlZExldmVscyA+IDApIHsKICAgICAgICByZXR1cm4gb3JkZXI7CiAgICAgIH0KICAgICAgY29uc3QgaGlkZGVuR3JvdXBzID0gW107CiAgICAgIGZvciAoY29uc3QgZ3JvdXBSZWYgb2YgY29udGVudEdyb3VwUmVmcykgewogICAgICAgIGlmIChwYXJzZWRPcmRlclJlZnMuaGFzKGdyb3VwUmVmKSkgewogICAgICAgICAgY29udGludWU7CiAgICAgICAgfQogICAgICAgIGhpZGRlbkdyb3Vwcy5wdXNoKGdyb3VwUmVmLnRvU3RyaW5nKCkpOwogICAgICB9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3QuZ2V0KCJQIik7CiAgICAgICAgICBpZiAodHlwZW9mIHAgIT09ICJzdHJpbmciKSB7CiAgICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiSW52YWxpZCBwcmVmaXggaW4gUGFnZUxhYmVsIGRpY3Rpb25hcnkuIik7CiAgICAgICAgICB9CiAgICAgICAgICBwcmVmaXggPSAoMCwgX3V0aWwuc3RyaW5nVG9QREZTdHJpbmcpKHApOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBwcmVmaXggPSAiIjsKICAgICAgICB9CiAgICAgICAgaWYgKGxhYmVsRGljdC5oYXMoIlN0IikpIHsKICAgICAgICAgIGNvbnN0IHN0ID0gbGFiZWxEaWN0LmdldCgiU3QiKTsKICAgICAgICAgIGlmICghKE51bWJlci5pc0ludGVnZXIoc3QpICYmIHN0ID49IDEpKSB7CiAgICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiSW52YWxpZCBzdGFydCBpbiBQYWdlTGFiZWwgZGljdGlvbmFyeS4iKTsKICAgICAgICAgIH0KICAgICAgICAgIGN1cnJlbnRJbmRleCA9IHN0OwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBjdXJyZW50SW5kZXggPSAxOwogICAgICAgIH0KICAgICAgfQogICAgICBzd2l0Y2ggKHN0eWxlKSB7CiAgICAgICAgY2FzZSAiRCI6CiAgICAgICAgICBjdXJyZW50TGFiZWwgPSBjdXJyZW50SW5kZXg7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJSIjoKICAgICAgICBjYXNlICJyIjoKICAgICAgICAgIGN1cnJlbnRMYWJlbCA9ICgwLCBfY29yZV91dGlscy50b1JvbWFuTnVtZXJhbHMpKGN1cnJlbnRJbmRleCwgc3R5bGUgPT09ICJyIik7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJBIjoKICAgICAgICBjYXNlICJhIjoKICAgICAgICAgIGNvbnN0IExJTUlUID0gMj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IHsKICAgICAgcmV0dXJuICgwLCBfdXRpbC5zaGFkb3cpKHRoaXMsICJ2aWV3ZXJQcmVmZXJlbmNlcyIsIG51bGwpOwogICAgfQogICAgbGV0IHByZWZzID0gbnVsbDsKICAgIGZvciAoY29uc3Qga2V5IG9mIG9iai5nZXRLZXlzKCkpIHsKICAgICAgY29uc3QgdmFsdWUgPSBvYmouZ2V0KGtleSk7CiAgICAgIGxldCBwcmVmVmFsdWU7CiAgICAgIHN3aXRjaCAoa2V5KSB7CiAgICAgICAgY2FzZSAiSGlkZVRvb2xiYXIiOgogICAgICAgIGNhc2UgIkhpZGVNZW51YmFyIjoKICAgICAgICBjYXNlICJIaWRlV2luZG93VUkiOgogICAgICAgIGNhc2UgIkZpdFdpbmRvdyI6CiAgICAgICAgY2FzZSAiQ2VudGVyV2luZG93IjoKICAgICAgICBjYXNlICJEaXNwbGF5RG9jVGl0bGUiOgogICAgICAgIGNhc2UgIlBpY2tUcmF5QnlQREZTaXplIjoKICAgICAgICAgIGlmICh0eXBlb2YgdmFsdWUgPT09ICJib29sZWFuIikgewogICAgICAgICAgICBwcmVmVmFsdWUgPSB2YWx1ZTsKICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgIk5vbkZ1bGxTY3JlZW5QYWdlTW9kZSI6CiAgICAgICAgICBpZiAodmFsdWUgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lKSB7CiAgICAgICAgICAgIHN3aXRjaCAodmFsdWUubmFtZSkgewogICAgICAgICAgICAgIGNhc2UgIlVzZU5vbmUiOgogICAgICAgICAgICAgIGNhc2UgIlVzZU91dGxpbmVzIjoKICAgICAgICAgICAgICBjYXNlICJVc2VUaHVtYnMiOgogICAgICAgICAgICAgIGNhc2UgIlVzZU9DIjoKICAgICAgICAgICAgICAgIHByZWZWYWx1ZSA9IHZhbHVlLm5hbWU7CiAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAgICAgcHJlZlZhbHVlID0gIlVzZU5vbmUiOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJEaXJlY3Rpb24iOgogICAgICAgICAgaWYgKHZhbHVlIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuTmFtZSkgewogICAgICAgICAgICBzd2l0Y2ggKHZhbHVlLm5hbWUpIHsKICAgICAgICAgICAgICBjYXNlICJMMlIiOgogICAgICAgICAgICAgIGNhc2UgIlIyTCI6CiAgICAgICAgICAgICAgICBwcmVmVmFsdWUgPSB2YWx1ZS5uYW1lOwogICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICAgIHByZWZWYWx1ZSA9ICJMMlIiOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJWaWV3QXJlYSI6CiAgICAgICAgY2FzZSAiVmlld0NsaXAiOgogICAgICAgIGNhc2UgIlByaW50QXJlYSI6CiAgICAgICAgY2FzZSAiUHJpbnRDbGlwIjoKICAgICAgICAgIGlmICh2YWx1ZSBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLk5hbWUpIHsKICAgICAgICAgICAgc3dpdGNoICh2YWx1ZS5uYW1lKSB7CiAgICAgICAgICAgICAgY2FzZSAiTWVkaWFCb3giOgogICAgICAgICAgICAgIGNhc2UgIkNyb3BCb3giOgogICAgICAgICAgICAgIGNhc2UgIkJsZWVkQm94IjoKICAgICAgICAgICAgICBjYXNlICJUcmltQm94IjoKICAgICAgICAgICAgICBjYXNlICJBcnRCb3giOgogICAgICAgICAgICAgICAgcHJlZlZhbHVlID0gdmFsdWUubmFtZTsKICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgICAgICBwcmVmVmFsdWUgPSAiQ3JvcEJveCI7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgIlByaW50U2NhbGluZyI6CiAgICAgICAgICBpZiAodmFsdWUgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lKSB7CiAgICAgICAgICAgIHN3aXRjaCAodmFsdWUubmFtZSkgewogICAgICAgICAgICAgIGNhc2UgIk5vbmUiOgogICAgICAgICAgICAgIGNhc2UgIkFwcERlZmF1bHQiOgogICAgICAgICAgICAgICAgcHJlZlZhbHVlID0gdmFsdWUubmFtZTsKICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgICAgICBwcmVmVmFsdWUgPSAiQXBwRGVmYXVsdCI7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgIkR1cGxleCI6CiAgICAgICAgICBpZiAodmFsdWUgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lKSB7CiAgICAgICAgICAgIHN3aXRjaCAodmFsdWUubmFtZSkgewogICAgICAgICAgICAgIGNhc2UgIlNpbXBsZXgiOgogICAgICAgICAgICAgIGNhc2UgIkR1cGxleEZsaXBTaG9ydEVkZ2UiOgogICAgICAgICAgICAgIGNhc2UgIkR1cGxleEZsaXBMb25nRWRnZSI6CiAgICAgICAgICAgICAgICBwcmVmVmFsdWUgPSB2YWx1ZS5uYW1lOwogICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICAgIHByZWZWYWx1ZSA9ICJOb25lIjsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiUHJpbnRQYWdlUmFuZ2UiOgogICAgICAgICAgaWYgKEFycmF5LmlzQXJyYXkodmFsdWUpICYmIHZhbHVlLmxlbmd0aCAlIDIgPT09IDApIHsKICAgICAgICAgICAgY29uc3QgaXNWYWxpZCA9IHZhbHVlLmV2ZXJ5KChwYWdlLCBpLCBhcnIpID0+IHsKICAgICAgICAgICAgICByZXR1cm4gTnVtYmVyLmlzSW50ZWdlcihwYWdlKSAmJiBwYWdlID4gMCAmJiAoaSA9PT0gMCB8fCBwYWdlID49IGFycltpIC0gMV0pICYmIHBhZ2UgPD0gdGhpcy5udW1QYWdlczsKICAgICAgICAgICAgfSk7CiAgICAgICAgICAgIGlmIChpc1ZhbGlkKSB7CiAgICAgICAgICAgICAgcHJlZlZhbHVlID0gdmFsdWU7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgIk51bUNvcGllcyI6CiAgICAgICAgICBpZiAoTnVtYmVyLmlzSW50ZWdlcih2YWx1ZSkgJiYgdmFsdWUgPiAwKSB7CiAgICAgICAgICAgIHByZWZWYWx1ZSA9IHZhbHVlOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgSWdub3Jpbmcgbm9uLXN0YW5kYXJkIGtleSBpbiBWaWV3ZXJQcmVmZXJlbmNlczogJHtrZXl9LmApOwogICAgICAgICAgY29udGludWU7CiAgICAgIH0KICAgICAgaWYgKHByZWZWYWx1ZSA9PT0gdW5kZWZpbmVkKSB7CiAgICAgICAgKDAsIF91dGlsLndhcm4pKGBCYWQgdmFsdWUsIGZvciBrZXkgIiR7a2V5fSIsIGluIFZpZXdlclByZWZlcmVuY2VzOiAke3ZhbHVlfS5gKTsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBpZiAoIXByZWZzKSB7CiAgICAgICAgcHJlZnMgPSBPYmplY3QuY3JlYXRlKG51bGwpOwogICAgICB9CiAgICAgIHByZWZzW2tleV0gPSBwcmVmVmFsdWU7CiAgICB9CiAgICByZXR1cm4gKDAsIF91dGlsLnNoYWRvdykodGhpcywgInZpZXdlclByZWZlcmVuY2VzIi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AgaWYgKCgwLCBfcHJpbWl0aXZlcy5pc05hbWUpKHR5cGUsICJQYWdlIikgfHwgIW9iai5oYXMoIktpZHMiKSkgewogICAgICAgICAgICBpZiAoIXBhZ2VLaWRzQ291bnRDYWNoZS5oYXMoY3VycmVudE5vZGUpKSB7CiAgICAgICAgICAgICAgcGFnZUtpZHNDb3VudENhY2hlLnB1dChjdXJyZW50Tm9kZSwgMSk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaWYgKCFwYWdlSW5kZXhDYWNoZS5oYXMoY3VycmVudE5vZGUpKSB7CiAgICAgICAgICAgICAgcGFnZUluZGV4Q2FjaGUucHV0KGN1cnJlbnROb2RlLCBjdXJyZW50UGFnZUluZGV4KTsKICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAoY3VycmVudFBhZ2VJbmRleCA9PT0gcGFnZUluZGV4KSB7CiAgICAgICAgICAgICAgcmV0dXJuIFtvYmosIGN1cnJlbnROb2RlXTsKICAgICAgICAgICAgfQogICAgICAgICAgICBjdXJyZW50UGFnZUluZGV4Kys7CiAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBub2Rlc1RvVmlzaXQucHVzaChvYmopOwogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGlmICghKGN1cnJlbnROb2RlIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuRGljdCkpIHsKICAgICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoIlBhZ2UgZGljdGlvbmFyeSBraWQgcmVmZXJlbmNlIHBvaW50cyB0byB3cm9uZyB0eXBlIG9mIG9iamVjdC4iKTsKICAgICAgfQogICAgICBjb25zdCB7CiAgICAgICAgb2JqSWQKICAgICAgfSA9IGN1cnJlbnROb2RlOwogICAgICBsZXQgY291bnQgPSBjdXJyZW50Tm9kZS5nZXRSYXcoIkNvdW50Iik7CiAgICAgIGlmIChjb3VudCBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLlJlZikgewogICAgICAgIGNvdW50ID0gYXdhaXQgeHJlZi5mZXRjaEFzeW5jKGNvdW50KTsKICAgICAgfQogICAgICBpZiAoTnVtYmVyLmlzSW50ZWdlcihjb3VudCkgJiYgY291bnQgPj0gMCkgewogICAgICAgIGlmIChvYmpJZCAmJiAhcGFnZUtpZHNDb3VudENhY2hlLmhhcyhvYmpJZCkpIHsKICAgICAgICAgIHBhZ2VLaWRzQ291bnRDYWNoZS5wdXQob2JqSWQsIGNvdW50KTsKICAgICAgICB9CiAgICAgICAgaWYgKGN1cnJlbnRQYWdlSW5kZXggKyBjb3VudCA8PSBwYWdlSW5kZXgpIHsKICAgICAgICAgIGN1cnJlbnRQYWdlSW5kZXggKz0gY291bnQ7CiAgICAgICAgICBjb250aW51ZTsKICAgICAgICB9CiAgICAgIH0KICAgICAgbGV0IGtpZHMgPSBjdXJyZW50Tm9kZS5nZXRSYXcoIktpZHMiKTsKICAgICAgaWYgKGtpZHMgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5SZWYpIHsKICAgICAgICBraWRzID0gYXdhaXQgeHJlZi5mZXRjaEFzeW5jKGtpZHMpOwogICAgICB9CiAgICAgIGlmICghQXJyYXkuaXNBcnJheShraWRzKSkgewogICAgICAgIGxldCB0eXBlID0gY3VycmVudE5vZGUuZ2V0UmF3KCJUeXBlIik7CiAgICAgICAgaWYgKHR5cGUgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5SZWYpIHsKICAgICAgICAgIHR5cGUgPSBhd2FpdCB4cmVmLmZldGNoQXN5bmModHlwZSk7CiAgICAgICAgfQogICAgICAgIGlmICgoMCwgX3ByaW1pdGl2ZXMuaXNOYW1lKSh0eXBlLCAiUGFnZSIpIHx8ICFjdXJyZW50Tm9kZS5oYXMoIktpZHMiKSkgewogICAgICAgICAgaWYgKGN1cnJlbnRQYWdlSW5kZXggPT09IHBhZ2VJbmRleCkgewogICAgICAgICAgICByZXR1cm4gW2N1cnJlbnROb2RlLCBud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kcwogICAgICB9ID0gcXVldWVJdGVtOwogICAgICBsZXQga2lkcyA9IGN1cnJlbnROb2RlLmdldFJhdygiS2lkcyIpOwogICAgICBpZiAoa2lkcyBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLlJlZikgewogICAgICAgIHRyeSB7CiAgICAgICAgICBraWRzID0gYXdhaXQgeHJlZi5mZXRjaEFzeW5jKGtpZHMpOwogICAgICAgIH0gY2F0Y2ggKGV4KSB7CiAgICAgICAgICBhZGRQYWdlRXJyb3IoZXgpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICB9CiAgICAgIGlmICghQXJyYXkuaXNBcnJheShraWRzKSkgewogICAgICAgIGFkZFBhZ2VFcnJvcihuZXcgX3V0aWwuRm9ybWF0RXJyb3IoIlBhZ2UgZGljdGlvbmFyeSBraWRzIG9iamVjdCBpcyBub3QgYW4gYXJyYXkuIikpOwogICAgICAgIGJyZWFrOwogICAgICB9CiAgICAgIGlmIChwb3NJbktpZHMgPj0ga2lkcy5sZW5ndGgpIHsKICAgICAgICBxdWV1ZS5wb3AoKTsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBjb25zdCBraWRPYmogPSBraWRzW3Bvc0luS2lkc107CiAgICAgIGxldCBvYmo7CiAgICAgIGlmIChraWRPYmogaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5SZWYpIHsKICAgICAgICBpZiAodmlzaXRlZE5vZGVzLmhhcyhraWRPYmopKSB7CiAgICAgICAgICBhZGRQYWdlRXJyb3IobmV3IF91dGlsLkZvcm1hdEVycm9yKCJQYWdlcyB0cmVlIGNvbnRhaW5zIGNpcmN1bGFyIHJlZmVyZW5jZS4iKSk7CiAgICAgICAgICBicmVhazsKICAgICAgICB9CiAgICAgICAgdmlzaXRlZE5vZGVzLnB1dChraWRPYmopOwogICAgICAgIHRyeSB7CiAgICAgICAgICBvYmogPSBhd2FpdCB4cmVmLmZldGNoQXN5bmMoa2lkT2JqKTsKICAgICAgICB9IGNhdGNoIChleCkgewogICAgICAgICAgYWRkUGFnZUVycm9yKGV4KTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIH0KICAgICAgfSBlbHNlIHsKICAgICAgICBvYmogPSBraWRPYmo7CiAgICAgIH0KICAgICAgaWYgKCEob2JqIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuRGljdCkpIHsKICAgICAgICBhZGRQYWdlRXJyb3IobmV3IF91dGlsLkZvcm1hdEVycm9yKCJQYWdlIGRpY3Rpb25hcnkga2lkIHJlZmVyZW5jZSBwb2ludHMgdG8gd3JvbmcgdHlwZSBvZiBvYmplY3QuIikpOwogICAgICAgIGJyZWFrOwogICAgICB9CiAgICAgIGxldCB0eXBlID0gb2JqLmdldFJhdygiVHlwZSIpOwogICAgICBpZiAodHlwZSBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLlJlZikgewogICAgICAgIHRyeSB7CiAgICAgICAgICB0eXBlID0gYXdhaXQgeHJlZi5mZXRjaEFzeW5jKHR5cGUpOwogICAgICAgIH0gY2F0Y2ggKGV4KSB7CiAgICAgICAgICBhZGRQYWdlRXJyb3IoZXgpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICB9CiAgICAgIGlmICgoMCwgX3ByaW1pdGl2ZXMuaXNOYW1lKSh0eXBlLCAiUGFnZSIpIHx8ICFvYmouaGFzKCJLaWRzIikpIHsKICAgICAgICBhZGRQYWdlRGljdChvYmosIGtpZE9iaiBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLlJlZiA/IGtpZE9iaiA6IG51bGwpOwogICAgICB9IGVsc2UgewogICAgICAgIHF1ZXVlLnB1c2goewogICAgICAgICAgY3VycmVudE5vZGU6IG9iaiwKICAgICAgICAgIHBvc0luS2lkczogMAogICAgICAgIH0pOwogICAgICB9CiAgICAgIHF1ZXVlSXRlbS5wb3NJbktpZHMrKzsKICAgIH0KICAgIHJldHVybiBtYXA7CiAgfQogIGdldFBhZ2VJbmRleChwYWdlUmVmKSB7CiAgIC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AgICAgcmV0dXJuIG5vZGUuZ2V0QXN5bmMoIlBhcmVudCIpOwogICAgICB9KS50aGVuKGZ1bmN0aW9uIChwYXJlbnQpIHsKICAgICAgICBpZiAoIXBhcmVudCkgewogICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgfQogICAgICAgIGlmICghKHBhcmVudCBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLkRpY3QpKSB7CiAgICAgICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoIlBhcmVudCBtdXN0IGJlIGEgZGljdGlvbmFyeS4iKTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIHBhcmVudC5nZXRBc3luYygiS2lkcyIpOwogICAgICB9KS50aGVuKGZ1bmN0aW9uIChraWRzKSB7CiAgICAgICAgaWYgKCFraWRzKSB7CiAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICB9CiAgICAgICAgY29uc3Qga2lkUHJvbWlzZXMgPSBbXTsKICAgICAgICBsZXQgZm91bmQgPSBmYWxzZTsKICAgICAgICBmb3IgKGNvbnN0IGtpZCBvZiBraWRzKSB7CiAgICAgICAgICBpZiAoIShraWQgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5SZWYpKSB7CiAgICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiS2lkIG11c3QgYmUgYSByZWZlcmVuY2UuIik7CiAgICAgICAgICB9CiAgICAgICAgICBpZiAoKDAsIF9wcmltaXRpdmVzLmlzUmVmc0VxdWFsKShraWQsIGtpZFJlZikpIHsKICAgICAgICAgICAgZm91bmQgPSB0cnVlOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIH0KICAgICAgICAgIGtpZFByb21pc2VzLnB1c2goeHJlZi5mZXRjaEFzeW5jKGtpZCkudGhlbihmdW5jdGlvbiAob2JqKSB7CiAgICAgICAgICAgIGlmICghKG9iaiBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLkRpY3QpKSB7CiAgICAgICAgICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKCJLaWQgbm9kZSBtdXN0IGJlIGEgZGljdGlvbmFyeS4iKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAob2JqLmhhcygiQ291bnQiKSkgewogICAgICAgICAgICAgIHRvdGFsICs9IG9iai5nZXQoIkNvdW50Iik7CiAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgdG90YWwrKzsKICAgICAgICAgICAgfQogICAgICAgICAgfSkpOwogICAgICAgIH0KICAgICAgICBpZiAoIWZvdW5kKSB7CiAgICAgICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoIktpZCByZWZlcmVuY2Ugbm90IGZvdW5kIGluIHBhcmVudCdzIGtpZHMuIik7CiAgICAgICAgfQogICAgICAgIHJldHVybiBQcm9taXNlLmFsbChraWRQcm9taXNlcykudGhlbihmdW5jdGlvbiAoKSB7CiAgICAgICAgICByZXR1cm4gW3RvdGFsLCBwYXJlbnRSZWZdOwogICAgICAgIH0pOwogICAgICB9KTsKICAgIH0KICAgIGxldCB0b3RhbCA9IDA7CiAgICBjb25zdCBuZXh0ID0gcmVmID0+IHBhZ2VzQmVmb3JlUmVmKHJlZikudGhlbihhcmdzID0+IHsKICAgICAgaWYgKCFhcmdzKSB7CiAgICAgICAgdGhpcy5wYWdlSW5kZXhDYWNoZS5wdXQocGFnZVJlZiwgdG90YWwpOwogICAgICAgIHJldHVybiB0b3RhbDsKICAgICAgfQogICAgICBjb25zdCBbY291bnQsIHBhcmVudFJlZl0gPSBhcmdzOwogICAgICB0b3RhbCArPSBjb3VudDsKICAgICAgcmV0dXJuIG5leHQocGFyZW50UmVmKTsKICAgIH0pOwogICAgcmV0dXJuIG5leHQocGFnZVJlZik7CiAgfQogIGdldCBiYXNlVXJsKCkgewogICAgY29uc3QgdXJpID0gdGhpcy5fY2F0RGljdC5nZXQoIlVSSSIpOwogICAgaWYgKHVyaSBpbnN0YW5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wogICAgICBzd2l0Y2ggKGFjdGlvbk5hbWUpIHsKICAgICAgICBjYXNlICJSZXNldEZvcm0iOgogICAgICAgICAgY29uc3QgZmxhZ3MgPSBhY3Rpb24uZ2V0KCJGbGFncyIpOwogICAgICAgICAgY29uc3QgaW5jbHVkZSA9ICgodHlwZW9mIGZsYWdzID09PSAibnVtYmVyIiA/IGZsYWdzIDogMCkgJiAxKSA9PT0gMDsKICAgICAgICAgIGNvbnN0IGZpZWxkcyA9IFtdOwogICAgICAgICAgY29uc3QgcmVmcyA9IFtdOwogICAgICAgICAgZm9yIChjb25zdCBvYmogb2YgYWN0aW9uLmdldCgiRmllbGRzIikgfHwgW10pIHsKICAgICAgICAgICAgaWYgKG9iaiBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLlJlZikgewogICAgICAgICAgICAgIHJlZnMucHVzaChvYmoudG9TdHJpbmcoKSk7CiAgICAgICAgICAgIH0gZWxzZSBpZiAodHlwZW9mIG9iaiA9PT0gInN0cmluZyIpIHsKICAgICAgICAgICAgICBmaWVsZHMucHVzaCgoMCwgX3V0aWwuc3RyaW5nVG9QREZTdHJpbmcpKG9iaikpOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICByZXN1bHRPYmoucmVzZXRGb3JtID0gewogICAgICAgICAgICBmaWVsZHMsCiAgICAgICAgICAgIHJlZnMsCiAgICAgICAgICAgIGluY2x1ZGUKICAgICAgICAgIH07CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJVUkkiOgogICAgICAgICAgdXJsID0gYWN0aW9uLmdldCgiVVJJIik7CiAgICAgICAgICBpZiAodXJsIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuTmFtZSkgewogICAgICAgICAgICB1cmwgPSAiLyIgKyB1cmwubmFtZTsKICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgIkdvVG8iOgogICAgICAgICAgZGVzdCA9IGFjdGlvbi5nZXQoIkQiKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgIkxhdW5jaCI6CiAgICAgICAgY2FzZSAiR29Ub1IiOgogICAgICAgICAgY29uc3QgdXJsRGljdCA9IGFjdGlvbi5nZXQoIkYiKTsKICAgICAgICAgIGlmICh1cmxEaWN0IGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuRGljdCkgewogICAgICAgICAgICB1cmwgPSB1cmxEaWN0LmdldCgiRiIpIHx8IG51bGw7CiAgICAgICAgICB9IGVsc2UgaWYgKHR5cGVvZiB1cmxEaWN0ID09PSAic3RyaW5nIikgewogICAgICAgICAgICB1cmwgPSB1cmxEaWN0OwogICAgICAgICAgfQogICAgICAgICAgbGV0IHJlbW90ZURlc3QgPSBhY3Rpb24uZ2V0KCJEIik7CiAgICAgICAgICBpZiAocmVtb3RlRGVzdCkgewogICAgICAgICAgICBpZiAocmVtb3RlRGVzdCBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLk5hbWUpIHsKICAgICAgICAgICAgICByZW1vdGVEZXN0ID0gcmVtb3RlRGVzdC5uYW1lOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmICh0eXBlb2YgdXJsID09PSAic3RyaW5nIikgewogICAgICAgICAgICAgIGNvbnN0IGJhc2VVcmwgPSB1cmwuc3BsaXQoIiMiKVswXTsKICAgICAgICAgICAgICBpZiAodHlwZW9mIHJlbW90ZURlc3QgPT09ICJzdHJpbmciKSB7CiAgICAgICAgICAgICAgICB1cmwgPSBiYXNlVXJsICsgIiMiICsgcmVtb3RlRGVzdDsKICAgICAgICAgICAgICB9IGVsc2UgaWYgKEFycmF5LmlzQXJyYXkocmVtb3RlRGVzdCkpIHsKICAgICAgICAgICAgICAgIHVybCA9IGJhc2VVcmwgKyAiIyIgKyBKU09OLnN0cmluZ2lmeShyZW1vdGVEZXN0KTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIGNvbnN0IG5ld1dpbmRvdyA9IGFjdGlvbi5nZXQoIk5ld1dpbmRvdyIpOwogICAgICAgICAgaWYgKHR5cGVvZiBuZXdXaW5kb3cgPT09ICJib29sZWFuIikgewogICAgICAgICAgICByZXN1bHRPYmoubmV3V2luZG93ID0gbmV3V2luZG93OwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiR29Ub0UiOgogICAgICAgICAgY29uc3QgdGFyZ2V0ID0gYWN0aW9uLmdldCgiVCIpOwogICAgICAgICAgbGV0IGF0dGFjaG1lbnQ7CiAgICAgICAgICBpZiAoZG9jQXR0YWNobWVudHMgJiYgdGFyZ2V0IGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuRGljdCkgewogICAgICAgICAgICBjb25zdCByZWxhdGlvbnNoaXAgPSB0YXJnZXQuZ2V0KCJSIik7CiAgICAgICAgICAgIGNvbnN0IG5hbWUgPSB0YXJnZXQuZ2V0KCJOIik7CiAgICAgICAgICAgIGlmICgoMCwgX3ByaW1pdGl2ZXMuaXNOYW1lKShyZWxhdGlvbnNoaXAsICJDIikgJiYgdHlwZW9mIG5hbWUgPT09ICJzdHJpbmciKSB7CiAgICAgICAgICAgICAgYXR0YWNobWVudCA9IGRvY0F0dGFjaG1lbnRzWygwLCBfdXRpbC5zdHJpbmdUb1BERlN0cmluZykobmFtZSldOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICBpZiAoYXR0YWNobWVudCkgewogICAgICAgICAgICByZXN1bHRPYmouYXR0YWNobWVudCA9IGF0dGFjaG1lbnQ7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYHBhcnNlRGVzdERpY3Rpb25hcnkgLSB1bmltcGxlbWVudGVkICJHb1RvRSIgYWN0aW9uLmApOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiTmFtZWQiOgogICAgICAgICAgY29uc3QgbmFtZWRBY3Rpb24gPSBhY3Rpb24uZ2V0KCJOIik7CiAgICAgICAgICBpZiAobmFtZWRBY3Rpb24gaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lKSB7CiAgICAgICAgICAgIHJlc3VsdE9iai5hY3Rpb24gPSBuYW1lZEFjdGlvbi5uYW1lOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiU2V0T0NHU3RhdGUiOgogICAgICAgICAgY29uc3Qgc3RhdGUgPSBhY3Rpb24uZ2V0KCJTdGF0ZSIpOwogICAgICAgICAgY29uc3QgcHJlc2VydmVSQiA9IGFjdGlvbi5nZXQoIlByZXNlcnZlUkIiKTsKICAgICAgICAgIGlmICghQXJyYXkuaXNBcnJheShzdGF0ZSkgfHwgc3RhdGUubGVuZ3RoID09PSAwKSB7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgfQogICAgICAgICAgY29uc3Qgc3RhdGVBcnIgPSBbXTsKICAgICAgICAgIGZvciAoY29uc3QgZWxlbSBvZiBzdGF0ZSkgewogICAgICAgICAgICBpZiAoZWxlbSBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLk5hbWUpIHsKICAgICAgICAgICAgICBzd2l0Y2ggKGVsZW0ubmFtZSkgewogICAgICAgICAgICAgICAgY2FzZSAiT04iOgogICAgICAgICAgICAgICAgY2FzZSAiT0ZGIjoKICAgICAgICAgICAgICAgIGNhc2UgIlRvZ2dsZSI6CiAgICAgICAgICAgICAgICAgIHN0YXRlQXJyLnB1c2goZWxlbS5uYW1lKTsKICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9IGVsc2UgaWYgKGVsZW0gaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5SZWYpIHsKICAgICAgICAgICAgICBzdGF0ZUFyci5wdXNoKGVsZW0udG9TdHJpbmcoKSk7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIGlmIChzdGF0ZUFyci5sZW5ndGggIT09IHN0YXRlLmxlbmd0aCkgewogICAgICAgICAgICBicmVhazsKICAgICAgICAgIH0KICAgICAgICAgIHJlc3VsdE9iai5zZXRPQ0dTdGF0ZSA9IHsKICAgICAgICAgICAgc3RhdGU6IHN0YXRlQXJyLAogICAgICAgICAgICBwcmVzZXJ2ZVJCOiB0eXBlb2YgcHJlc2VydmVSQiA9PT0gImJvb2xlYW4iID8gcHJlc2VydmVSQiA6IHRydWUKICAgICAgICAgIH07CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJKYXZhU2NyaXB0IjoKICAgICAgICAgIGNvbnN0IGpzQWN0aW9uID0gYWN0aW9uLmdldCgiSlMiKTsKICAgICAgICAgIGxldCBqczsKICAgICAgICAgIGlmIChqc0FjdGlvbiBpbnN0YW5jZW9mIF9iYXNlX3N0cmVhbS5CYXNlU3RyZWFtKSB7CiAgICAgICAgICAgIGpzID0ganNBY3Rpb24uZ2V0U3RyaW5nKCk7CiAgICAgICAgICB9IGVsc2UgaWYgKHR5cGVvZiBqc0FjdGlvbiA9PT0gInN0cmluZyIpIHsKICAgICAgICAgICAganMgPSBqc0FjdGlvbjsKICAgICAgICAgIH0KICAgICAgICAgIGNvbnN0IGpzVVJMID0ganMgJiYgKDAsIF9jb3JlX3V0aWxzLnJlY292ZXJKc1VSTCkoKDAsIF91dGlsLnN0cmluZ1RvUERGU3RyaW5nKShqcykpOwogICAgICAgICAgaWYgKGpzVVJMKSB7CiAgICAgICAgICAgIHVybCA9IGpzVVJMLnVybDsKICAgICAgICAgICAgcmVzdWx0T2JqLm5ld1dpbmRvdyA9IGpzVVJMLm5ld1dpbmRvdzsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICB9CiAgICAgICAgZGVmYXVsdDoKICAgICAgICAgIGlmIChhY3Rpb25OYW1lID09PSAiSmF2YVNjcmlwdCIgfHwgYWN0aW9uTmFtZSA9PT0gIlN1Ym1pdEZvcm0iKSB7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgfQogICAgICAgICAgKDAsIF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0KCkpOwogICAgICBpZiAoIShvYmogaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5EaWN0KSkgewogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGlmIChvYmouaGFzKCJLaWRzIikpIHsKICAgICAgICBjb25zdCBraWRzID0gb2JqLmdldCgiS2lkcyIpOwogICAgICAgIGlmICghQXJyYXkuaXNBcnJheShraWRzKSkgewogICAgICAgICAgY29udGludWU7CiAgICAgICAgfQogICAgICAgIGZvciAoY29uc3Qga2lkIG9mIGtpZHMpIHsKICAgICAgICAgIGlmIChwcm9jZXNzZWQuaGFzKGtpZCkpIHsKICAgICAgICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKGBEdXBsaWNhdGUgZW50cnkgaW4gIiR7dGhpcy5fdHlwZX0iIHRyZWUuYCk7CiAgICAgICAgICB9CiAgICAgICAgICBxdWV1ZS5wdXNoKGtpZCk7CiAgICAgICAgICBwcm9jZXNzZWQucHV0KGtpZCk7CiAgICAgICAgfQogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGNvbnN0IGVudHJpZXMgPSBvYmouZ2V0KHRoaXMuX3R5cGUpOwogICAgICBpZiAoIUFycmF5LmlzQXJyYXkoZW50cmllcykpIHsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBmb3IgKGxldCBpID0gMCwgaWkgPSBlbnRyaWVzLmxlbmd0aDsgaSA8IGlpOyBpICs9IDIpIHsKICAgICAgICBtYXAuc2V0KHhyZWYuZmV0Y2hJZlJlZihlbnRyaWVzW2ldKSwgeHJlZi5mZXRjaElmUmVmKGVudHJpZXNbaSArIDFdKSk7CiAgICAgIH0KICAgIH0KICAgIHJldHVybiBtYXA7CiAgfQogIGdldChrZXkpIHsKICAgIGlmICghdGhpcy5yb290KSB7CiAgICAgIHJldHVybiBudWxsOwogICAgfQogICAgY29uc3QgeHJlZiA9IHRoaXMueHJlZjsKICAgIGxldCBraWRzT3JFbnRyaWVzID0geHJlZi5mZXRjaElmUmVmKHRoaXMucm9vdCk7CiAgICBsZXQgbG9vcENvdW50ID0gMDsKICAgIGNvbnN0IE1BWF9MRVZFTFMgPSAxMDsKICAgIHdoaWxlIChraWRzT3JFbnRyaWVzLmhhcygiS2lkcyIpKSB7CiAgICAgIGlmICgrK2xvb3BDb3VudCA+IE1BWF9MRVZFTFMpIHsKICAgICAgICAoMCwgX3V0aWwud2FybikoYFNlYXJjaCBkZXB0aCBsaW1pdCByZWFjaGVkIGZvciAiJHt0aGlzLl90eXBlfSIgdHJlZS5gKTsKICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgfQogICAgICBjb25zdCBraWRzID0ga2lkc09yRW50cmllcy5nZXQoIktpZHMiKTsKICAgICAgaWYgKCFBcnJheS5pc0FycmF5KGtpZHMpKSB7CiAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgIH0KICAgICAgbGV0IGwgPSAwLAogICAgICAgIHIgPSBraWRzLmxlbmd0aCAtIDE7CiAgICAgIHdoaWxlIChsIDw9IHIpIHsKICAgICAgICBjb25zdCBtID0gbCArIHIgPj4gMTsKICAgICAgICBjb25zdCBraWQgPSB4cmVmLmZldGNoSWZSZWYoa2lkc1ttXSk7CiAgICAgICAgY29uc3QgbGltaXRzID0ga2lkLmdldCgiTGltaXRzIik7CiAgICAgICAgaWYgKGtleSA8IHhyZWYuZmV0Y2hJZlJlZihsaW1pdHNbMF0pKSB7CiAgICAgICAgICByID0gbSAtIDE7CiAgICAgICAgfSBlbHNlIGlmIChrZXkgPiB4cmVmLmZldGNoSWZSZWYobGltaXRzWzFdKSkgewogICAgICAgICAgbCA9IG0gKyAxOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBraWRzT3JFbnRyaWVzID0ga2lkOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICB9CiAgICAgIGlmIChsID4gcikgewogICAgICAgIHJldHVybiBudWxsOwogICAgICB9CiAgICB9CiAgICBjb25zdCBlbnRyaWVzID0ga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dKy8sICIiKS5yZXBsYWNlQWxsKC8+XFwzNzZcXDM3NyhbXjxdKykvZywgZnVuY3Rpb24gKGFsbCwgY29kZXMpIHsKICAgICAgY29uc3QgYnl0ZXMgPSBjb2Rlcy5yZXBsYWNlQWxsKC9cXChbMC0zXSkoWzAtN10pKFswLTddKS9nLCBmdW5jdGlvbiAoY29kZSwgZDEsIGQyLCBkMykgewogICAgICAgIHJldHVybiBTdHJpbmcuZnJvbUNoYXJDb2RlKGQxICogNjQgKyBkMiAqIDggKyBkMyAqIDEpOwogICAgICB9KS5yZXBsYWNlQWxsKC8mKGFtcHxhcG9zfGd0fGx0fHF1b3QpOy9nLCBmdW5jdGlvbiAoc3RyLCBuYW1lKSB7CiAgICAgICAgc3dpdGNoIChuYW1lKSB7CiAgICAgICAgICBjYXNlICJhbXAiOgogICAgICAgICAgICByZXR1cm4gIiYiOwogICAgICAgICAgY2FzZSAiYXBvcyI6CiAgICAgICAgICAgIHJldHVybiAiJyI7CiAgICAgICAgICBjYXNlICJndCI6CiAgICAgICAgICAgIHJldHVybiAiPiI7CiAgICAgICAgICBjYXNlICJsdCI6CiAgICAgICAgICAgIHJldHVybiAiPCI7CiAgICAgICAgICBjYXNlICJxdW90IjoKICAgICAgICAgICAgcmV0dXJuICciJzsKICAgICAgICB9CiAgICAgICAgdGhyb3cgbmV3IEVycm9yKGBfcmVwYWlyOiAke25hbWV9IGlzbid0IGRlZmluZWQuYCk7CiAgICAgIH0pOwogICAgICBjb25zdCBjaGFyQnVmID0gWyI+Il07CiAgICAgIGZvciAobGV0IGkgPSAwLCBpaSA9IGJ5dGVzLmxlbmd0aDsgaSA8IGlpOyBpICs9IDIpIHsKICAgICAgICBjb25zdCBjb2RlID0gYnl0ZXMuY2hhckNvZGVBdChpKSAqIDI1NiArIGJ5dGVzLmNoYXJDb2RlQXQoaSArIDEpOwogICAgICAgIGlmIChjb2RlID49IDMyICYmIGNvZGUgPCAxMjcgJiYgY29kZSAhPT0gNjAgJiYgY29kZS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SB7CiAgICAgIHJkZiA9IHJkZi5maXJzdENoaWxkOwogICAgICB3aGlsZSAocmRmICYmIHJkZi5ub2RlTmFtZSAhPT0gInJkZjpyZGYiKSB7CiAgICAgICAgcmRmID0gcmRmLm5leHRTaWJsaW5nOwogICAgICB9CiAgICB9CiAgICBpZiAoIXJkZiB8fCByZGYubm9kZU5hbWUgIT09ICJyZGY6cmRmIiB8fCAhcmRmLmhhc0NoaWxkTm9kZXMoKSkgewogICAgICByZXR1cm47CiAgICB9CiAgICBmb3IgKGNvbnN0IGRlc2Mgb2YgcmRmLmNoaWxkTm9kZXMpIHsKICAgICAgaWYgKGRlc2Mubm9kZU5hbWUgIT09ICJyZGY6ZGVzY3JpcHRpb24iKSB7CiAgICAgICAgY29udGludWU7CiAgICAgIH0KICAgICAgZm9yIChjb25zdCBlbnRyeSBvZiBkZXNjLmNoaWxkTm9kZXMpIHsKICAgICAgICBjb25zdCBuYW1lID0gZW50cnkubm9kZU5hbWU7CiAgICAgICAgc3dpdGNoIChuYW1lKSB7CiAgICAgICAgICBjYXNlICIjdGV4dCI6CiAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgY2FzZSAiZGM6Y3JlYXRvciI6CiAgICAgICAgICBjYXNlICJkYzpzdWJqZWN0IjoKICAgICAgICAgICAgdGhpcy5fcGFyc2VBcnJheShlbnRyeSk7CiAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgIH0KICAgICAgICB0aGlzLl9tZXRhZGF0YU1hcC5zZXQobmFtZSwgZW50cnkudGV4dENvbnRlbnQudHJpbSgpKTsKICAgICAgfQogICAgfQogIH0KICBnZXQgc2VyaWFsaXphYmxlKCkgewogICAgcmV0dXJuIHsKICAgICAgcGFyc2VkRGF0YTogdGhpcy5fbWV0YWRhdGFNYXAsCiAgICAgIHJhd0RhdGE6IHRoaXMuX2RhdGEKICAgIH07CiAgfQp9CmV4cG9ydHMuTWV0YWRhdGFQYXJzZXIgPSBNZXRhZGF0YVBhcnNlcjsK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HRoaXMucmVmU2V0ID0gbnVsbDsKICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgIG1hbmFnZXIKICAgICAgICAgICAgfSA9IHRoaXMueHJlZi5zdHJlYW07CiAgICAgICAgICAgIHJldHVybiBtYW5hZ2VyLnJlcXVlc3RBbGxDaHVua3MoKTsKICAgICAgICAgIH0KICAgICAgICAgIG5vZGVzVG9SZXZpc2l0LnB1c2goY3VycmVudE5vZGUpOwogICAgICAgICAgcGVuZGluZ1JlcXVlc3RzLnB1c2goewogICAgICAgICAgICBiZWdpbjogZXguYmVnaW4sCiAgICAgICAgICAgIGVuZDogZXguZW5kCiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgIH0KICAgICAgaWYgKGN1cnJlbnROb2RlIGluc3RhbmNlb2YgX2Jhc2Vfc3RyZWFtLkJhc2VTdHJlYW0pIHsKICAgICAgICBjb25zdCBiYXNlU3RyZWFtcyA9IGN1cnJlbnROb2RlLmdldEJhc2VTdHJlYW1zKCk7CiAgICAgICAgaWYgKGJhc2VTdHJlYW1zKSB7CiAgICAgICAgICBsZXQgZm91bmRNaXNzaW5nRGF0YSA9IGZhbHNlOwogICAgICAgICAgZm9yIChjb25zdCBzdHJlYW0gb2YgYmFzZVN0cmVhbXMpIHsKICAgICAgICAgICAgaWYgKHN0cmVhbS5pc0RhdGFMb2FkZWQpIHsKICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgfQogICAgICAgICAgICBmb3VuZE1pc3NpbmdEYXRhID0gdHJ1ZTsKICAgICAgICAgICAgcGVuZGluZ1JlcXVlc3RzLnB1c2goewogICAgICAgICAgICAgIGJlZ2luOiBzdHJlYW0uc3RhcnQsCiAgICAgICAgICAgICAgZW5kOiBzdHJlYW0uZW5kCiAgICAgICAgICAgIH0pOwogICAgICAgICAgfQogICAgICAgICAgaWYgKGZvdW5kTWlzc2luZ0RhdGEpIHsKICAgICAgICAgICAgbm9kZXNUb1JldmlzaXQucHVzaChjdXJyZW50Tm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4dEl0ZXJhdGlvbiA9ICgpID0+IHsKICAgICAgICB0cnkgewogICAgICAgICAgY29uc3QgdmFsdWUgPSBpdGVyYXRvci5uZXh0KCk7CiAgICAgICAgICBpZiAodmFsdWUuZG9uZSkgewogICAgICAgICAgICByZXNvbHZlKHZhbHVlLnZhbHVlKTsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHNldFRpbWVvdXQobmV4dEl0ZXJhdGlvbiwgMCk7CiAgICAgICAgICB9CiAgICAgICAgfSBjYXRjaCAoZSkgewogICAgICAgICAgcmVqZWN0KGUpOwogICAgICAgIH0KICAgICAgfTsKICAgICAgc2V0VGltZW91dChuZXh0SXRlcmF0aW9uLCAwKTsKICAgIH0pOwogIH0KICBhc3luYyBfY3JlYXRlUGFnZXMoKSB7CiAgICB0cnkgewogICAgICB0aGlzLnBhZ2VzID0gYXdhaXQgdGhpcy5fY3JlYXRlUGFnZXNIZWxwZXIoKTsKICAgICAgdGhpcy5kaW1zID0gdGhpcy5wYWdlcy5jaGlsZHJlbi5tYXAoYyA9PiB7CiAgICAgICAgY29uc3QgewogICAgICAgICAgd2lkdGgsCiAgICAgICAgICBoZWlnaHQKICAgICAgICB9ID0gYy5hdHRyaWJ1dGVzLnN0eWxlOwogICAgICAgIHJldHVybiBbMCwgMCwgcGFyc2VJbnQod2lkdGgpLCBwYXJzZUludChoZWlnaHQpXTsKICAgICAgfSk7CiAgICB9IGNhdGNoIChlKSB7CiAgICAgICgwLCBfdXRpbC53YXJuKShgWEZBIC0gYW4gZXJyb3Igb2NjdXJyZWQgZHVyaW5nIGxheW91dDogJHtlfWApOwogICAgfQogIH0KICBnZXRCb3VuZGluZ0JveChwYWdlSW5kZXgpIHsKICAgIHJldHVybiB0aGlzLmRpbXNbcGFnZUluZGV4XTsKICB9CiAgYXN5bmMgZ2V0TnVtUGFnZXMoKSB7CiAgICBpZiAoIXRoaXMucGFnZXMpIHsKICAgICAgYXdhaXQgdGhpcy5fY3JlYXRlUGFnZXM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RyZW47CiAgICB0aGlzW19wYXJlbnRdID0gbnVsbDsKICAgIHRoaXNbX2NoaWxkcmVuXSA9IFtdOwogICAgdGhpc1skdWlkXSA9IGAke25hbWV9JHt1aWQrK31gOwogICAgdGhpc1skZ2xvYmFsRGF0YV0gPSBudWxsOwogIH0KICBbJG9uQ2hpbGRdKGNoaWxkKSB7CiAgICBpZiAoIXRoaXNbX2hhc0NoaWxkcmVuXSB8fCAhdGhpc1skb25DaGlsZENoZWNrXShjaGlsZCkpIHsKICAgICAgcmV0dXJuIGZhbHNlOwogICAgfQogICAgY29uc3QgbmFtZSA9IGNoaWxkWyRub2RlTmFtZV07CiAgICBjb25zdCBub2RlID0gdGhpc1tuYW1lXTsKICAgIGlmIChub2RlIGluc3RhbmNlb2YgWEZBT2JqZWN0QXJyYXkpIHsKICAgICAgaWYgKG5vZGUucHVzaChjaGlsZCkpIHsKICAgICAgICB0aGlzWyRhcHBlbmRDaGlsZF0oY2hpbGQpOwogICAgICAgIHJldHVybiB0cnVlOwogICAgICB9CiAgICB9IGVsc2UgewogICAgICBpZiAobm9kZSAhPT0gbnVsbCkgewogICAgICAgIHRoaXNbJHJlbW92ZUNoaWxkXShub2RlKTsKICAgICAgfQogICAgICB0aGlzW25hbWVdID0gY2hpbGQ7CiAgICAgIHRoaXNbJGFwcGVuZENoaWxkXShjaGlsZCk7CiAgICAgIHJldHVybiB0cnVlOwogICAgfQogICAgbGV0IGlkID0gIiI7CiAgICBpZiAodGhpcy5pZCkgewogICAgICBpZCA9IGAgKGlkOiAke3RoaXMuaWR9KWA7CiAgICB9IGVsc2UgaWYgKHRoaXMubmFtZSkgewogICAgICBpZCA9IGAgKG5hbWU6ICR7dGhpcy5uYW1lfSAke3RoaXMuaC52YWx1ZX0pYDsKICAgIH0KICAgICgwLCBfdXRpbC53YXJuKShgWEZBIC0gbm9kZSAiJHt0aGlzWyRub2RlTmFtZV19IiR7aWR9IGhhcyBhbHJlYWR5IGVub3VnaCAiJHtuYW1lfSIhY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Gdsb2JhbERhdGFdOwogICAgfQogIH0KICBbJGlzVHJhbnNwYXJlbnRdKCkgewogICAgcmV0dXJuICF0aGlzLm5hbWU7CiAgfQogIFskbGFzdEF0dHJpYnV0ZV0oKSB7CiAgICByZXR1cm4gIiI7CiAgfQogIFskdGV4dF0oKSB7CiAgICBpZiAodGhpc1tfY2hpbGRyZW5dLmxlbmd0aCA9PT0gMCkgewogICAgICByZXR1cm4gdGhpc1skY29udGVudF07CiAgICB9CiAgICByZXR1cm4gdGhpc1tfY2hpbGRyZW5dLm1hcChjID0+IGNbJHRleHRdKCkpLmpvaW4oIiIpOwogIH0KICBnZXQgW19hdHRyaWJ1dGVOYW1lc10oKSB7CiAgICBjb25zdCBwcm90byA9IE9iamVjdC5nZXRQcm90b3R5cGVPZih0aGlzKTsKICAgIGlmICghcHJvdG8uX2F0dHJpYnV0ZXMpIHsKICAgICAgY29uc3QgYXR0cmlidXRlcyA9IHByb3RvLl9hdHRyaWJ1dGVzID0gbmV3IFNldCgpOwogICAgICBmb3IgKGNvbnN0IG5hbWUgb2YgT2JqZWN0LmdldE93blByb3BlcnR5TmFtZXModGhpcykpIHsKICAgICAgICBpZiAodGhpc1tuYW1lXSA9PT0gbnVsbCB8fCB0aGlzW25hbWVdIGluc3RhbmNlb2YgWEZBT2JqZWN0IHx8IHRoaXNbbmFtZV0gaW5zdGFuY2VvZiBYRkFPYmplY3RBcnJheSkgewogICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICAgIGF0dHJpYnV0ZXMuYWRkKG5hbWUpOwogICAgICB9CiAgICB9CiAgICByZXR1cm4gKDAsIF91dGlsLnNoYWRvdykodGhpcywgX2F0dHJpYnV0ZU5hbWVzLCBwcm90by5fYXR0cmlidXRlcyk7CiAgfQogIFskaXNEZXNjZW5kZW50XShwYXJlbnQpIHsKICAgIGxldCBub2RlID0gdGhpczsKICAgIHdoaWxlIChub2RlKSB7CiAgICAgIGlmIChub2RlID09PSBwYXJlbnQpIHsKICAgICAgIC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mNlb2YgWEZBT2JqZWN0QXJyYXkpIHsKICAgICAgICBmb3IgKGNvbnN0IGNoaWxkIG9mIHZhbHVlW19jaGlsZHJlbl0pIHsKICAgICAgICAgIGNoaWxkW19yZXNvbHZlUHJvdG90eXBlc0hlbHBlcl0oaWRzLCBhbmNlc3RvcnMpOwogICAgICAgIH0KICAgICAgICBmb3IgKGxldCBpID0gdmFsdWVbX2NoaWxkcmVuXS5sZW5ndGgsIGlpID0gcHJvdG9WYWx1ZVtfY2hpbGRyZW5dLmxlbmd0aDsgaSA8IGlpOyBpKyspIHsKICAgICAgICAgIGNvbnN0IGNoaWxkID0gcHJvdG9bX2NoaWxkcmVuXVtpXVskY2xvbmVdKCk7CiAgICAgICAgICBpZiAodmFsdWUucHVzaChjaGlsZCkpIHsKICAgICAgICAgICAgY2hpbGRbX3BhcmVudF0gPSB0aGlzOwogICAgICAgICAgICB0aGlzW19jaGlsZHJlbl0ucHVzaChjaGlsZCk7CiAgICAgICAgICAgIGNoaWxkW19yZXNvbHZlUHJvdG90eXBlc0hlbHBlcl0oaWRzLCBhbmNlc3RvcnMpOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGlmICh2YWx1ZSAhPT0gbnVsbCkgewogICAgICAgIHZhbHVlWyRyZXNvbHZlUHJvdG90eXBlc10oaWRzLCBhbmNlc3RvcnMpOwogICAgICAgIGlmIChwcm90b1ZhbHVlKSB7CiAgICAgICAgICB2YWx1ZVtfYXBwbHlQcm90b3R5cGVdKHByb3RvVmFsdWUsIGlkcywgYW5jZXN0b3JzKTsKICAgICAgICB9CiAgICAgICAgY29udGludWU7CiAgICAgIH0KICAgICAgaWYgKHByb3RvVmFsdWUgIT09IG51bGwpIHsKICAgICAgICBjb25zdCBjaGlsZCA9IHByb3RvVmFsdWVbJGNsb25lXSgpOwogICAgICAgIGNoaWxkW19wYXJ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J1dGVOYW1lc10uaGFzKG5hbWUpKSB7CiAgICAgICAgY2xvbmVbbmFtZV0gPSBYRkFPYmplY3RbX2Nsb25lQXR0cmlidXRlXSh0aGlzW25hbWVdKTsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBjb25zdCB2YWx1ZSA9IHRoaXNbbmFtZV07CiAgICAgIGlmICh2YWx1ZSBpbnN0YW5jZW9mIFhGQU9iamVjdEFycmF5KSB7CiAgICAgICAgY2xvbmVbbmFtZV0gPSBuZXcgWEZBT2JqZWN0QXJyYXkodmFsdWVbX21heF0pOwogICAgICB9IGVsc2UgewogICAgICAgIGNsb25lW25hbWVdID0gbnVsbDsKICAgICAgfQogICAgfQogICAgZm9yIChjb25zdCBjaGlsZCBvZiB0aGlzW19jaGlsZHJlbl0pIHsKICAgICAgY29uc3QgbmFtZSA9IGNoaWxkWyRub2RlTmFtZV07CiAgICAgIGNvbnN0IGNsb25lZENoaWxkID0gY2hpbGRbJGNsb25lXSgpOwogICAgICBjbG9uZVtfY2hpbGRyZW5dLnB1c2goY2xvbmVkQ2hpbGQpOwogICAgICBjbG9uZWRDaGlsZFtfcGFyZW50XSA9IGNsb25lOwogICAgICBpZiAoY2xvbmVbbmFtZV0gPT09IG51bGwpIHsKICAgICAgICBjbG9uZVtuYW1lXSA9IGNsb25lZENoaWxkOwogICAgICB9IGVsc2UgewogICAgICAgIGNsb25lW25hbWVdW19jaGlsZHJlbl0ucHVzaChjbG9uZWRDaGlsZCk7CiAgICAgIH0KICAgIH0KICAgIHJldHVybiBjbG9uZTsKICB9CiAgWyRnZXRDaGlsZHJlbl0oKSB7CiAgICBsZXQgbmFtZSA9IGFyZ3VtZW50cy5sZW5ndGggPiAwICYmIGFyZ3VtZW50c1swXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzBdIDogbnVsbDsKICAgIGlmICghbmFtZSkgewogICAgICByZXR1cm4gdGhpc1tfY2hpbGRyZW5dOwogICAgfQogICAgcmV0dXJuIHRoa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AgICBjb25zdCBzcG9zID0gcG9zOwogICAgY29uc3QgY2hhciA9IGV4cHIuY2hhckF0KHBvcysrKTsKICAgIGlmIChjaGFyID09PSAiWyIpIHsKICAgICAgbWF0Y2ggPSBleHByLnNsaWNlKHBvcykubWF0Y2goaW5kZXhQYXR0ZXJuKTsKICAgICAgaWYgKCFtYXRjaCkgewogICAgICAgICgwLCBfdXRpbC53YXJuKSgiWEZBIC0gSW52YWxpZCBpbmRleCBpbiBTT00gZXhwcmVzc2lvbiIpOwogICAgICAgIHJldHVybiBudWxsOwogICAgICB9CiAgICAgIHBhcnNlZC5hdCgtMSkuaW5kZXggPSBwYXJzZUluZGV4KG1hdGNoWzBdKTsKICAgICAgcG9zICs9IG1hdGNoWzBdLmxlbmd0aCArIDE7CiAgICAgIGNvbnRpbnVlOwogICAgfQogICAgbGV0IG9wZXJhdG9yOwogICAgc3dpdGNoIChleHByLmNoYXJBdChwb3MpKSB7CiAgICAgIGNhc2UgIi4iOgogICAgICAgIGlmICghZG90RG90QWxsb3dlZCkgewogICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgfQogICAgICAgIHBvcysrOwogICAgICAgIG9wZXJhdG9yID0gb3BlcmF0b3JzLmRvdERvdDsKICAgICAgICBicmVhazsKICAgICAgY2FzZSAiIyI6CiAgICAgICAgcG9zKys7CiAgICAgICAgb3BlcmF0b3IgPSBvcGVyYXRvcnMuZG90SGFzaDsKICAgICAgICBicmVhazsKICAgICAgY2FzZSAiWyI6CiAgICAgICAgaWYgKG5vRXhwcikgewogICAgICAgICAgKDAsIF91dGlsLndhcm4pKCJYRkEgLSBTT00gZXhwcmVzc2lvbiBjb250YWlucyBhIEZvcm1DYWxjIHN1YmV4cHJlc3Npb24gd2hpY2ggaXMgbm90IHN1cHBvcnRlZCBmb3Igbm93LiIpOwogICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgfQogICAgICAgIG9wZXJhdG9yID0gb3BlcmF0b3JzLmRvdEJyYWNrZXQ7C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FtZSk7CiAgICAgIH0KICAgICAgaWYgKCFjaGlsZHJlbikgewogICAgICAgIHN3aXRjaCAob3BlcmF0b3IpIHsKICAgICAgICAgIGNhc2Ugb3BlcmF0b3JzLmRvdDoKICAgICAgICAgICAgY2hpbGRyZW4gPSBub2RlW194ZmFfb2JqZWN0LiRnZXRDaGlsZHJlbkJ5TmFtZV0obmFtZSwgZmFsc2UpOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2Ugb3BlcmF0b3JzLmRvdERvdDoKICAgICAgICAgICAgY2hpbGRyZW4gPSBub2RlW194ZmFfb2JqZWN0LiRnZXRDaGlsZHJlbkJ5TmFtZV0obmFtZSwgdHJ1ZSk7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSBvcGVyYXRvcnMuZG90SGFzaDoKICAgICAgICAgICAgY2hpbGRyZW4gPSBub2RlW194ZmFfb2JqZWN0LiRnZXRDaGlsZHJlbkJ5Q2xhc3NdKG5hbWUpOwogICAgICAgICAgICBpZiAoY2hpbGRyZW4gaW5zdGFuY2VvZiBfeGZhX29iamVjdC5YRkFPYmplY3RBcnJheSkgewogICAgICAgICAgICAgIGNoaWxkcmVuID0gY2hpbGRyZW4uY2hpbGRyZW47CiAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgY2hpbGRyZW4gPSBbY2hpbGRyZW5dOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICAgIGlmICh1c2VDYWNoZSkgewogICAgICAgICAgY2FjaGVkLnNldChjYWNoZU5hbWUsIGNoaWxkcmVuKTsKICAgICAgICB9CiAgICAgIH0KICAgICAgaWYgKGNoaWxkcmVuLmxlbmd0aCA+IDApIHsKICAgICAgICBub2Rlcy5wdXNoKGNoaWxkcmVuKTsKICAgICAgfQogICAgfQogICAgaWYgKG5vZGVzLmxlbmd0aCA9PT0gMCAmJiAhaXNRdWFsaWZpZWQgJiYgaSA9PT0gMCkgewogICAgICBjb25zdCBwYXJlbnQgPSBjb250YWluZXJbX3hmYV9vYmplY3QuJGdldFBhcmVudF0oKTsKICAgICAgY29udGFpbmVyID0gcGFyZW50OwogICAgICBpZiAoIWNvbnRhaW5lcikgewogICAgICAgIHJldHVybiBudWxsOwogICAgICB9CiAgICAgIGkgPSAtMTsKICAgICAgcm9vdCA9IFtjb250YWluZXJdOwogICAgICBjb250aW51ZTsKICAgIH0KICAgIGlmIChpc0Zpbml0ZShpbmRleCkpIHsKICAgICAgcm9vdCA9IG5vZGVzLmZpbHRlcihub2RlID0+IGluZGV4IDwgbm9kZS5sZW5ndGgpLm1hcChub2RlID0+IG5vZGVbaW5kZXhdKTsKICAgIH0gZWxzZSB7CiAgICAgIHJvb3QgPSBub2Rlcy5mbGF0KCk7CiAgICB9CiAgfQogIGlmIChyb290Lmxlbmd0aCA9PT0gMCkgewogICAgcmV0dXJuIG51bGw7CiAgfQogIHJldHVybiByb290Owp9CmZ1bmN0aW9uIGNyZWF0ZU5vZGVzKHJvb3QsIHBhdGgpIHsKICBsZXQgbm9kZSA9IG51bGw7CiAgZm9yIChjb25zdCB7CiAgICBuYW1lLAogICAgaW5kZXgKICB9IG9mIHBhdGgpIHsKICAgIGZvciAobGV0IGkgPSAwLCBpaSA9ICFpc0Zpbml0ZShpbmRleCkgPyAwIDogaW5kZXg7IGkgPD0gaWk7IGkrKykgewogICAgICBjb25zdCBuc0lkID0gcm9vdFtfeGZhX29iamVjdC4kbmFtZXNwYWNlSWRdID09PSBOU19EQVRBU0VUUyA/IC0xIDogcm9vdFtfeGZhX29iamVjdC4kbmFtZXNwYWNlSWRdOwogICAgICBub2RlID0gbmV3IF94ZmFfb2JqZWN0LlhtbE9iamVjdChuc0lkLCBuYW1lKTsKICAgICAgcm9vdFtfeGZhX29iamVjdC4kYXBwZW5kQ2hpbGRdKG5vZGUpOwogICAgfQogICAgcm9vdCA9IG5vZGU7C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JldHVybiBudWxsOwogIH0KICBfc2V0UHJvcGVydGllcyhmb3JtTm9kZSwgZGF0YU5vZGUpIHsKICAgIGlmICghZm9ybU5vZGUuaGFzT3duUHJvcGVydHkoInNldFByb3BlcnR5IikpIHsKICAgICAgcmV0dXJuOwogICAgfQogICAgZm9yIChjb25zdCB7CiAgICAgIHJlZiwKICAgICAgdGFyZ2V0LAogICAgICBjb25uZWN0aW9uCiAgICB9IG9mIGZvcm1Ob2RlLnNldFByb3BlcnR5LmNoaWxkcmVuKSB7CiAgICAgIGlmIChjb25uZWN0aW9uKSB7CiAgICAgICAgY29udGludWU7CiAgICAgIH0KICAgICAgaWYgKCFyZWYpIHsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBjb25zdCBub2RlcyA9ICgwLCBfc29tLnNlYXJjaE5vZGUpKHRoaXMucm9vdCwgZGF0YU5vZGUsIHJlZiwgZmFsc2UsIGZhbHNlKTsKICAgICAgaWYgKCFub2RlcykgewogICAgICAgICgwLCBfdXRpbC53YXJuKShgWEZBIC0gSW52YWxpZCByZWZlcmVuY2U6ICR7cmVmfS5gKTsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBjb25zdCBbbm9kZV0gPSBub2RlczsKICAgICAgaWYgKCFub2RlW194ZmFfb2JqZWN0LiRpc0Rlc2NlbmRlbnRdKHRoaXMuZGF0YSkpIHsKICAgICAgICAoMCwgX3V0aWwud2FybikoYFhGQSAtIEludmFsaWQgbm9kZTogbXVzdCBiZSBhIGRhdGEgbm9kZS5gKTsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBjb25zdCB0YXJnZXROb2RlcyA9ICgwLCBfc29tLnNlYXJjaE5vZGUpKHRoaXMucm9vdCwgZm9ybU5vZGUsIHRhcmdldCwgZmFsc2UsIGZhbHNlKTsKICAgICAgaWYgKCF0YXJnZXROb2RlcykgewogICAgICAgICgwLCBfdXRpbC53YXJuKShgWEZBIC0gSW52YWxpZCB0YXJnZXQ6ICR7dGFy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ICAgIGNhc2UgIm5vbmUiOgogICAgICAgICAgICB0aGlzLl9zZXRBbmRCaW5kKGNoaWxkLCBkYXRhTm9kZSk7CiAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgY2FzZSAiZ2xvYmFsIjoKICAgICAgICAgICAgZ2xvYmFsID0gdHJ1ZTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlICJkYXRhUmVmIjoKICAgICAgICAgICAgaWYgKCFjaGlsZC5iaW5kLnJlZikgewogICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgWEZBIC0gcmVmIGlzIGVtcHR5IGluIG5vZGUgJHtjaGlsZFtfeGZhX29iamVjdC4kbm9kZU5hbWVdfS5gKTsKICAgICAgICAgICAgICB0aGlzLl9zZXRBbmRCaW5kKGNoaWxkLCBkYXRhTm9kZSk7CiAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgcmVmID0gY2hpbGQuYmluZC5yZWY7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICAgIGlmIChjaGlsZC5iaW5kLnBpY3R1cmUpIHsKICAgICAgICAgIHBpY3R1cmUgPSBjaGlsZC5iaW5kLnBpY3R1cmVbX3hmYV9vYmplY3QuJGNvbnRlbnRdOwogICAgICAgIH0KICAgICAgfQogICAgICBjb25zdCBbbWluLCBtYXhdID0gdGhpcy5fZ2V0T2NjdXJJbmZvKGNoaWxkKTsKICAgICAgaWYgKHJlZikgewogICAgICAgIG1hdGNoID0gKDAsIF9zb20uc2VhcmNoTm9kZSkodGhpcy5yb290LCBkYXRhTm9kZSwgcmVmLCB0cnVlLCBmYWxzZSk7CiAgICAgICAgaWYgKG1hdGNoID09PSBudWxsKSB7CiAgICAgICAgICBtYXRjaCA9ICgwLCBfc29tLmNyZWF0ZURhdGFOb2RlKSh0aGlzLmRhdGEsIGRhdGFOb2RlLCByZWYpOwogICAgICAgICAgaWYgKCFtYXRjaCkgewogICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgIH0KICAgICAgICAgIGlmICh0aGlzLl9pc0NvbnN1bWVEYXRhKCkpIHsKICAgICAgICAgICAgbWF0Y2hbX3hmYV9vYmplY3QuJGNvbnN1bWVkXSA9IHRydWU7CiAgICAgICAgICB9CiAgICAgICAgICB0aGlzLl9zZXRBbmRCaW5kKGNoaWxkLCBtYXRjaCk7CiAgICAgICAgICBjb250aW51ZTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgaWYgKHRoaXMuX2lzQ29uc3VtZURhdGEoKSkgewogICAgICAgICAgICBtYXRjaCA9IG1hdGNoLmZpbHRlcihub2RlID0+ICFub2RlW194ZmFfb2JqZWN0LiRjb25zdW1lZF0pOwogICAgICAgICAgfQogICAgICAgICAgaWYgKG1hdGNoLmxlbmd0aCA+IG1heCkgewogICAgICAgICAgICBtYXRjaCA9IG1hdGNoLnNsaWNlKDAsIG1heCk7CiAgICAgICAgICB9IGVsc2UgaWYgKG1hdGNoLmxlbmd0aCA9PT0gMCkgewogICAgICAgICAgICBtYXRjaCA9IG51bGw7CiAgICAgICAgICB9CiAgICAgICAgICBpZiAobWF0Y2ggJiYgdGhpcy5faXNDb25zdW1lRGF0YSgpKSB7CiAgICAgICAgICAgIG1hdGNoLmZvckVhY2gobm9kZSA9PiB7CiAgICAgICAgICAgICAgbm9kZVtfeGZhX29iamVjdC4kY29uc3VtZWRdID0gdHJ1ZTsKICAgICAgICAgICAgfSk7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9IGVsc2UgewogICAgICAgIGlmICghY2hpbGQubmFtZSkgewogICAgICAgICAgdGhpcy5fc2V0QW5kQmluZChjaGlsZCwgZGF0YU5vZGUpOwogICAgICAgICAgY29udGludWU7CiAgICAgICAgfQogICAgICAgIGlmICh0aGlzLl9pc0NvbnN1bWVEYXRhKCkpIHsKICAgICAgICAgIGNvbnN0IG1hdGNoZXMgPS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pb24gaXNSZXF1aXJlZChub2RlKSB7CiAgcmV0dXJuIG5vZGUudmFsaWRhdGUgJiYgbm9kZS52YWxpZGF0ZS5udWxsVGVzdCA9PT0gImVycm9yIjsKfQpmdW5jdGlvbiBzZXRUYWJJbmRleChub2RlKSB7CiAgd2hpbGUgKG5vZGUpIHsKICAgIGlmICghbm9kZS50cmF2ZXJzYWwpIHsKICAgICAgbm9kZVtfeGZhX29iamVjdC4kdGFiSW5kZXhdID0gbm9kZVtfeGZhX29iamVjdC4kZ2V0UGFyZW50XSgpW194ZmFfb2JqZWN0LiR0YWJJbmRleF07CiAgICAgIHJldHVybjsKICAgIH0KICAgIGlmIChub2RlW194ZmFfb2JqZWN0LiR0YWJJbmRleF0pIHsKICAgICAgcmV0dXJuOwogICAgfQogICAgbGV0IG5leHQgPSBudWxsOwogICAgZm9yIChjb25zdCBjaGlsZCBvZiBub2RlLnRyYXZlcnNhbFtfeGZhX29iamVjdC4kZ2V0Q2hpbGRyZW5dKCkpIHsKICAgICAgaWYgKGNoaWxkLm9wZXJhdGlvbiA9PT0gIm5leHQiKSB7CiAgICAgICAgbmV4dCA9IGNoaWxkOwogICAgICAgIGJyZWFrOwogICAgICB9CiAgICB9CiAgICBpZiAoIW5leHQgfHwgIW5leHQucmVmKSB7CiAgICAgIG5vZGVbX3hmYV9vYmplY3QuJHRhYkluZGV4XSA9IG5vZGVbX3hmYV9vYmplY3QuJGdldFBhcmVudF0oKVtfeGZhX29iamVjdC4kdGFiSW5kZXhdOwogICAgICByZXR1cm47CiAgICB9CiAgICBjb25zdCByb290ID0gbm9kZVtfeGZhX29iamVjdC4kZ2V0VGVtcGxhdGVSb290XSgpOwogICAgbm9kZVtfeGZhX29iamVjdC4kdGFiSW5kZXhdID0gKytyb290W194ZmFfb2JqZWN0LiR0YWJJbmRleF07CiAgICBjb25zdCByZWYgPSByb290W194ZmFfb2JqZWN0LiRzZWFyY2hOb2RlXShuZXh0LnJlZiwgbm9kZSk7CiAgICBpZiAoIX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lIiwgInB1c2giXSk7CiAgICB0aGlzLmlkID0gYXR0cmlidXRlcy5pZCB8fCAiIjsKICAgIHRoaXMudXNlID0gYXR0cmlidXRlcy51c2UgfHwgIiI7CiAgICB0aGlzLnVzZWhyZWYgPSBhdHRyaWJ1dGVzLnVzZWhyZWYgfHwgIiI7CiAgICB0aGlzLmV4dHJhcyA9IG51bGw7CiAgfQogIFtfeGZhX29iamVjdC4kdG9IVE1MXShhdmFpbGFibGVTcGFjZSkgewogICAgY29uc3QgcGFyZW50ID0gdGhpc1tfeGZhX29iamVjdC4kZ2V0UGFyZW50XSgpOwogICAgY29uc3QgZ3JhbmRwYSA9IHBhcmVudFtfeGZhX29iamVjdC4kZ2V0UGFyZW50XSgpOwogICAgY29uc3QgaHRtbEJ1dHRvbiA9IHsKICAgICAgbmFtZTogImJ1dHRvbiIsCiAgICAgIGF0dHJpYnV0ZXM6IHsKICAgICAgICBpZDogdGhpc1tfeGZhX29iamVjdC4kdWlkXSwKICAgICAgICBjbGFzczogWyJ4ZmFCdXR0b24iXSwKICAgICAgICBzdHlsZToge30KICAgICAgfSwKICAgICAgY2hpbGRyZW46IFtdCiAgICB9OwogICAgZm9yIChjb25zdCBldmVudCBvZiBncmFuZHBhLmV2ZW50LmNoaWxkcmVuKSB7CiAgICAgIGlmIChldmVudC5hY3Rpdml0eSAhPT0gImNsaWNrIiB8fCAhZXZlbnQuc2NyaXB0KSB7CiAgICAgICAgY29udGludWU7CiAgICAgIH0KICAgICAgY29uc3QganNVUkwgPSAoMCwgX2NvcmVfdXRpbHMucmVjb3ZlckpzVVJMKShldmVudC5zY3JpcHRbX3hmYV9vYmplY3QuJGNvbnRlbnRdKTsKICAgICAgaWYgKCFqc1VSTCkgewogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGNvbnN0IGhyZWYgPSAoMCwgX2h0bWxfdXRpbHMuZml4VVJMKShqc1VSTC51cmwpOwogICAgICBpZiAoIWhyZWYpIHsKICAgICAgICBjb250aW51Z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pbGFibGVTcGFjZTsKICAgICAgc3dpdGNoICh0aGlzLnBsYWNlbWVudCkgewogICAgICAgIGNhc2UgImxlZnQiOgogICAgICAgIGNhc2UgInJpZ2h0IjoKICAgICAgICBjYXNlICJpbmxpbmUiOgogICAgICAgICAgd2lkdGggPSB0aGlzLnJlc2VydmUgPD0gMCA/IHdpZHRoIDogdGhpcy5yZXNlcnZlOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAidG9wIjoKICAgICAgICBjYXNlICJib3R0b20iOgogICAgICAgICAgaGVpZ2h0ID0gdGhpcy5yZXNlcnZlIDw9IDAgPyBoZWlnaHQgOiB0aGlzLnJlc2VydmU7CiAgICAgICAgICBicmVhazsKICAgICAgfQogICAgICB0aGlzW194ZmFfb2JqZWN0LiRleHRyYV0gPSAoMCwgX2h0bWxfdXRpbHMubGF5b3V0Tm9kZSkodGhpcywgewogICAgICAgIHdpZHRoLAogICAgICAgIGhlaWdodAogICAgICB9KTsKICAgIH0KICAgIHJldHVybiB0aGlzW194ZmFfb2JqZWN0LiRleHRyYV07CiAgfQogIFtfeGZhX29iamVjdC4kdG9IVE1MXShhdmFpbGFibGVTcGFjZSkgewogICAgaWYgKCF0aGlzLnZhbHVlKSB7CiAgICAgIHJldHVybiBfdXRpbHMuSFRNTFJlc3VsdC5FTVBUWTsKICAgIH0KICAgIHRoaXNbX3hmYV9vYmplY3QuJHB1c2hQYXJhXSgpOwogICAgY29uc3QgdmFsdWUgPSB0aGlzLnZhbHVlW194ZmFfb2JqZWN0LiR0b0hUTUxdKGF2YWlsYWJsZVNwYWNlKS5odG1sOwogICAgaWYgKCF2YWx1ZSkgewogICAgICB0aGlzW194ZmFfb2JqZWN0LiRwb3BQYXJhXSgpOwogICAgICByZXR1cm4gX3V0aWxzLkhUTUxSZXN1bHQuRU1QVFk7CiAgICB9CiAgICBjb25zdCBzYXZlZFJlc2VydmUgPSB0aGlzLnJlc2VydmU7CiAgICBpZiAodGhpcy5yZXNlcnZlIDw9IDApIHsKICAgICAgY29uc3QgewogICAgICAgIHcsCiAgICAgICAgaAogICAgICB9ID0gdGhpc1tfeGZhX29iamVjdC4kZ2V0RXh0cmFdKGF2YWlsYWJsZVNwYWNlKTsKICAgICAgc3dpdGNoICh0aGlzLnBsYWNlbWVudCkgewogICAgICAgIGNhc2UgImxlZnQiOgogICAgICAgIGNhc2UgInJpZ2h0IjoKICAgICAgICBjYXNlICJpbmxpbmUiOgogICAgICAgICAgdGhpcy5yZXNlcnZlID0gdzsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgInRvcCI6CiAgICAgICAgY2FzZSAiYm90dG9tIjoKICAgICAgICAgIHRoaXMucmVzZXJ2ZSA9IGg7CiAgICAgICAgICBicmVhazsKICAgICAgfQogICAgfQogICAgY29uc3QgY2hpbGRyZW4gPSBbXTsKICAgIGlmICh0eXBlb2YgdmFsdWUgPT09ICJzdHJpbmciKSB7CiAgICAgIGNoaWxkcmVuLnB1c2goewogICAgICAgIG5hbWU6ICIjdGV4dCIsCiAgICAgICAgdmFsdWUKICAgICAgfSk7CiAgICB9IGVsc2UgewogICAgICBjaGlsZHJlbi5wdXNoKHZhbHVlKTsKICAgIH0KICAgIGNvbnN0IHN0eWxlID0gKDAsIF9odG1sX3V0aWxzLnRvU3R5bGUpKHRoaXMsICJmb250IiwgIm1hcmdpbiIsICJ2aXNpYmlsaXR5Iik7CiAgICBzd2l0Y2ggKHRoaXMucGxhY2VtZW50KSB7CiAgICAgIGNhc2UgImxlZnQiOgogICAgICBjYXNlICJyaWdodCI6CiAgICAgICAgaWYgKHRoaXMucmVzZXJ2ZSA+IDApIHsKICAgICAgICAgIHN0eWxlLndpZHRoID0gKDAsIF9odG1sX3V0aWxzLm1lYXN1cmVUb1N0cmluZykodGhpcy5yZXNlcnZlKTsKICAgICAgICB9CiAgICAgICAgYnJlYWs7CiAgICAgIGNhc2UgInRvcCI6CiAgICAgIGNhc2UgImJvdHRvbSI6CiAgICAgICAgaWYgKHRoaXMuc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y2ggKHRoaXMuc3Ryb2tlKSB7CiAgICAgICAgY2FzZSAic29saWQiOgogICAgICAgICAgc3R5bGUuc3R5bGUgPSAic29saWQiOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiZGFzaERvdCI6CiAgICAgICAgICBzdHlsZS5zdHlsZSA9ICJkYXNoZWQiOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiZGFzaERvdERvdCI6CiAgICAgICAgICBzdHlsZS5zdHlsZSA9ICJkYXNoZWQiOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiZGFzaGVkIjoKICAgICAgICAgIHN0eWxlLnN0eWxlID0gImRhc2hlZCI7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJkb3R0ZWQiOgogICAgICAgICAgc3R5bGUuc3R5bGUgPSAiZG90dGVkIjsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgImVtYm9zc2VkIjoKICAgICAgICAgIHN0eWxlLnN0eWxlID0gInJpZGdlIjsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgImV0Y2hlZCI6CiAgICAgICAgICBzdHlsZS5zdHlsZSA9ICJncm9vdmUiOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAibG93ZXJlZCI6CiAgICAgICAgICBzdHlsZS5zdHlsZSA9ICJpbnNldCI7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJyYWlzZWQiOgogICAgICAgICAgc3R5bGUuc3R5bGUgPSAib3V0c2V0IjsKICAgICAgICAgIGJyZWFrOwogICAgICB9CiAgICB9CiAgICByZXR1cm4gc3R5bGU7CiAgfQp9CmNsYXNzIEVuY29kaW5nIGV4dGVuZHMgX3hmYV9vYmplY3QuT3B0aW9uT2JqZWN0IHsKICBjb25zdHJ1Y3RvcihhdHRyaWJ1dGVzKSB7CiAgICBzdXBlcihURU1QTEFURV9OU19JRCwgImVuY29kaW5nIiwgWyJhZGJlLng1MDkucnNhX3N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RoaXMuaCA9PT0gIiIpIHsKICAgICAgbGV0IHdpZHRoID0gbnVsbDsKICAgICAgbGV0IGhlaWdodCA9IG51bGw7CiAgICAgIGxldCB1aVcgPSAwOwogICAgICBsZXQgdWlIID0gMDsKICAgICAgaWYgKHRoaXMudWkuY2hlY2tCdXR0b24pIHsKICAgICAgICB1aVcgPSB1aUggPSB0aGlzLnVpLmNoZWNrQnV0dG9uLnNpemU7CiAgICAgIH0gZWxzZSB7CiAgICAgICAgY29uc3QgewogICAgICAgICAgdywKICAgICAgICAgIGgKICAgICAgICB9ID0gKDAsIF9odG1sX3V0aWxzLmxheW91dE5vZGUpKHRoaXMsIGF2YWlsYWJsZVNwYWNlKTsKICAgICAgICBpZiAodyAhPT0gbnVsbCkgewogICAgICAgICAgdWlXID0gdzsKICAgICAgICAgIHVpSCA9IGg7CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIHVpSCA9ICgwLCBfZm9udHMuZ2V0TWV0cmljcykodGhpcy5mb250LCB0cnVlKS5saW5lTm9HYXA7CiAgICAgICAgfQogICAgICB9CiAgICAgIGJvcmRlckRpbXMgPSBnZXRCb3JkZXJEaW1zKHRoaXMudWlbX3hmYV9vYmplY3QuJGdldEV4dHJhXSgpKTsKICAgICAgdWlXICs9IGJvcmRlckRpbXMudzsKICAgICAgdWlIICs9IGJvcmRlckRpbXMuaDsKICAgICAgaWYgKHRoaXMuY2FwdGlvbikgewogICAgICAgIGNvbnN0IHsKICAgICAgICAgIHcsCiAgICAgICAgICBoLAogICAgICAgICAgaXNCcm9rZW4KICAgICAgICB9ID0gdGhpcy5jYXB0aW9uW194ZmFfb2JqZWN0LiRnZXRFeHRyYV0oYXZhaWxhYmxlU3BhY2UpOwogICAgICAgIGlmIChpc0Jyb2tlbiAmJiB0aGlzW194ZmFfb2JqZWN0LiRnZXRTdWJmb3JtUGFyZW50XSgpW194ZmFfb2JqZWN0LiRpc1RoZXJlTW9yZVdpZHRoXSgpKSB7CiAgICAgICAgICB0aGlzW194ZmFfb2JqZWN0LiRwb3BQYXJhXSgpOwogICAgICAgICAgcmV0dXJuIF91dGlscy5IVE1MUmVzdWx0LkZBSUxVUkU7CiAgICAgICAgfQogICAgICAgIHdpZHRoID0gdzsKICAgICAgICBoZWlnaHQgPSBoOwogICAgICAgIHN3aXRjaCAodGhpcy5jYXB0aW9uLnBsYWNlbWVudCkgewogICAgICAgICAgY2FzZSAibGVmdCI6CiAgICAgICAgICBjYXNlICJyaWdodCI6CiAgICAgICAgICBjYXNlICJpbmxpbmUiOgogICAgICAgICAgICB3aWR0aCArPSB1aVc7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAidG9wIjoKICAgICAgICAgIGNhc2UgImJvdHRvbSI6CiAgICAgICAgICAgIGhlaWdodCArPSB1aUg7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgIH0KICAgICAgfSBlbHNlIHsKICAgICAgICB3aWR0aCA9IHVpVzsKICAgICAgICBoZWlnaHQgPSB1aUg7CiAgICAgIH0KICAgICAgaWYgKHdpZHRoICYmIHRoaXMudyA9PT0gIiIpIHsKICAgICAgICB3aWR0aCArPSBtYXJnaW5IOwogICAgICAgIHRoaXMudyA9IE1hdGgubWluKHRoaXMubWF4VyA8PSAwID8gSW5maW5pdHkgOiB0aGlzLm1heFcsIHRoaXMubWluVyArIDEgPCB3aWR0aCA/IHdpZHRoIDogdGhpcy5taW5XKTsKICAgICAgfQogICAgICBpZiAoaGVpZ2h0ICYmIHRoaXMuaCA9PT0gIiIpIHsKICAgICAgICBoZWlnaHQgKz0gbWFyZ2luVjsKICAgICAgICB0aGlzLmggPSBNYXRoLm1pbih0aGlzLm1heEggPD0gMCA/IEluZmluaXR5IDogdGhpcy5tYXhILCB0aGlzLm1pbkggKyAxIDwgaGVpZ2h0ID8gaGVpZ2h0IDogdGhpcy5taW5IKTsKICAgICAgfQogICAgfQogICAgdGhpc1tfeGZhX29iamVjdC4kcG9wUGFyYV0oKTsKICAgICgwLCBfaHRtbF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dGhpc1tfeGZhX29iamVjdC4kZ2V0UGFyZW50XSgpOwogICAgY29uc3QgZ3JhbmRwYSA9IHBhcmVudFtfeGZhX29iamVjdC4kZ2V0UGFyZW50XSgpOwogICAgY29uc3QgZ2dyYW5kcGEgPSBncmFuZHBhW194ZmFfb2JqZWN0LiRnZXRQYXJlbnRdKCk7CiAgICBjb25zdCBzdHlsZSA9IE9iamVjdC5jcmVhdGUobnVsbCk7CiAgICBsZXQgcHJvcE5hbWUgPSAiY29sb3IiOwogICAgbGV0IGFsdFByb3BOYW1lID0gcHJvcE5hbWU7CiAgICBpZiAocGFyZW50IGluc3RhbmNlb2YgQm9yZGVyKSB7CiAgICAgIHByb3BOYW1lID0gImJhY2tncm91bmQtY29sb3IiOwogICAgICBhbHRQcm9wTmFtZSA9ICJiYWNrZ3JvdW5kIjsKICAgICAgaWYgKGdncmFuZHBhIGluc3RhbmNlb2YgVWkpIHsKICAgICAgICBzdHlsZS5iYWNrZ3JvdW5kQ29sb3IgPSAid2hpdGUiOwogICAgICB9CiAgICB9CiAgICBpZiAocGFyZW50IGluc3RhbmNlb2YgUmVjdGFuZ2xlIHx8IHBhcmVudCBpbnN0YW5jZW9mIEFyYykgewogICAgICBwcm9wTmFtZSA9IGFsdFByb3BOYW1lID0gImZpbGwiOwogICAgICBzdHlsZS5maWxsID0gIndoaXRlIjsKICAgIH0KICAgIGZvciAoY29uc3QgbmFtZSBvZiBPYmplY3QuZ2V0T3duUHJvcGVydHlOYW1lcyh0aGlzKSkgewogICAgICBpZiAobmFtZSA9PT0gImV4dHJhcyIgfHwgbmFtZSA9PT0gImNvbG9yIikgewogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGNvbnN0IG9iaiA9IHRoaXNbbmFtZV07CiAgICAgIGlmICghKG9iaiBpbnN0YW5jZW9mIF94ZmFfb2JqZWN0LlhGQU9iamVjdCkpIHsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBjb25zdCBjb2xvciA9IG9ialt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Xh0IjsKICAgICAgICBzdHlsZS5jb2xvciA9ICJ0cmFuc3BhcmVudCI7CiAgICAgIH0KICAgIH0KICAgIGlmICh0aGlzLmJhc2VsaW5lU2hpZnQpIHsKICAgICAgc3R5bGUudmVydGljYWxBbGlnbiA9ICgwLCBfaHRtbF91dGlscy5tZWFzdXJlVG9TdHJpbmcpKHRoaXMuYmFzZWxpbmVTaGlmdCk7CiAgICB9CiAgICBzdHlsZS5mb250S2VybmluZyA9IHRoaXMua2VybmluZ01vZGUgPT09ICJub25lIiA/ICJub25lIiA6ICJub3JtYWwiOwogICAgc3R5bGUubGV0dGVyU3BhY2luZyA9ICgwLCBfaHRtbF91dGlscy5tZWFzdXJlVG9TdHJpbmcpKHRoaXMubGV0dGVyU3BhY2luZyk7CiAgICBpZiAodGhpcy5saW5lVGhyb3VnaCAhPT0gMCkgewogICAgICBzdHlsZS50ZXh0RGVjb3JhdGlvbiA9ICJsaW5lLXRocm91Z2giOwogICAgICBpZiAodGhpcy5saW5lVGhyb3VnaCA9PT0gMikgewogICAgICAgIHN0eWxlLnRleHREZWNvcmF0aW9uU3R5bGUgPSAiZG91YmxlIjsKICAgICAgfQogICAgfQogICAgaWYgKHRoaXMub3ZlcmxpbmUgIT09IDApIHsKICAgICAgc3R5bGUudGV4dERlY29yYXRpb24gPSAib3ZlcmxpbmUiOwogICAgICBpZiAodGhpcy5vdmVybGluZSA9PT0gMikgewogICAgICAgIHN0eWxlLnRleHREZWNvcmF0aW9uU3R5bGUgPSAiZG91YmxlIjsKICAgICAgfQogICAgfQogICAgc3R5bGUuZm9udFN0eWxlID0gdGhpcy5wb3N0dXJlOwogICAgc3R5bGUuZm9udFNpemUgPSAoMCwgX2h0bWxfdXRpbHMubWVhc3VyZVRvU3RyaW5nKSgwLjk5ICogdGhpcy5zaXplKTsKICAgICgwLCBfaHRtbF91dGlscy5zZXRGb250RmFtaWx5KSh0aGlzLCB0aGlzLCB0aGlzW194ZmFfb2JqZWN0LiRnbG9iYWxEYXR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ZmZlci5sZW5ndGggPiBoZWFkZXIubGVuZ3RoICYmIGhlYWRlci5ldmVyeSgoeCwgaSkgPT4geCA9PT0gYnVmZmVyW2ldKSkgewogICAgICAgICAgdGhpcy5jb250ZW50VHlwZSA9IHR5cGU7CiAgICAgICAgICBicmVhazsKICAgICAgICB9CiAgICAgIH0KICAgICAgaWYgKCF0aGlzLmNvbnRlbnRUeXBlKSB7CiAgICAgICAgcmV0dXJuIF91dGlscy5IVE1MUmVzdWx0LkVNUFRZOwogICAgICB9CiAgICB9CiAgICBjb25zdCBibG9iID0gbmV3IEJsb2IoW2J1ZmZlcl0sIHsKICAgICAgdHlwZTogdGhpcy5jb250ZW50VHlwZQogICAgfSk7CiAgICBsZXQgc3R5bGU7CiAgICBzd2l0Y2ggKHRoaXMuYXNwZWN0KSB7CiAgICAgIGNhc2UgImZpdCI6CiAgICAgIGNhc2UgImFjdHVhbCI6CiAgICAgICAgYnJlYWs7CiAgICAgIGNhc2UgImhlaWdodCI6CiAgICAgICAgc3R5bGUgPSB7CiAgICAgICAgICBoZWlnaHQ6ICIxMDAlIiwKICAgICAgICAgIG9iamVjdEZpdDogImZpbGwiCiAgICAgICAgfTsKICAgICAgICBicmVhazsKICAgICAgY2FzZSAibm9uZSI6CiAgICAgICAgc3R5bGUgPSB7CiAgICAgICAgICB3aWR0aDogIjEwMCUiLAogICAgICAgICAgaGVpZ2h0OiAiMTAwJSIsCiAgICAgICAgICBvYmplY3RGaXQ6ICJmaWxsIgogICAgICAgIH07CiAgICAgICAgYnJlYWs7CiAgICAgIGNhc2UgIndpZHRoIjoKICAgICAgICBzdHlsZSA9IHsKICAgICAgICAgIHdpZHRoOiAiMTAwJSIsCiAgICAgICAgICBvYmplY3RGaXQ6ICJmaWxsIgogICAgICAgIH07CiAgICAgICAgYnJlYWs7CiAgICB9CiAgICBjb25zdCBwYXJlbnQgPSB0aGlzW194ZmFfb2JqZWN0LiRnZXRQYXJlbnRdKCk7CiAgICByZXR1cm4gX3V0aWx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wogICAgfQogICAgc3R5bGUuc3Ryb2tlV2lkdGggPSAoMCwgX2h0bWxfdXRpbHMubWVhc3VyZVRvU3RyaW5nKShlZGdlLnByZXNlbmNlID09PSAidmlzaWJsZSIgPyBlZGdlLnRoaWNrbmVzcyA6IDApOwogICAgc3R5bGUuc3Ryb2tlID0gZWRnZVN0eWxlLmNvbG9yOwogICAgY29uc3QgY29ybmVyID0gdGhpcy5jb3JuZXIuY2hpbGRyZW4ubGVuZ3RoID8gdGhpcy5jb3JuZXIuY2hpbGRyZW5bMF0gOiBuZXcgQ29ybmVyKHt9KTsKICAgIGNvbnN0IGNvcm5lclN0eWxlID0gY29ybmVyW194ZmFfb2JqZWN0LiR0b1N0eWxlXSgpOwogICAgY29uc3QgcmVjdCA9IHsKICAgICAgbmFtZTogInJlY3QiLAogICAgICBhdHRyaWJ1dGVzOiB7CiAgICAgICAgeG1sbnM6IFNWR19OUywKICAgICAgICB3aWR0aDogIjEwMCUiLAogICAgICAgIGhlaWdodDogIjEwMCUiLAogICAgICAgIHg6IDAsCiAgICAgICAgeTogMCwKICAgICAgICByeDogY29ybmVyU3R5bGUucmFkaXVzLAogICAgICAgIHJ5OiBjb3JuZXJTdHlsZS5yYWRpdXMsCiAgICAgICAgc3R5bGUKICAgICAgfQogICAgfTsKICAgIGNvbnN0IHN2ZyA9IHsKICAgICAgbmFtZTogInN2ZyIsCiAgICAgIGNoaWxkcmVuOiBbcmVjdF0sCiAgICAgIGF0dHJpYnV0ZXM6IHsKICAgICAgICB4bWxuczogU1ZHX05TLAogICAgICAgIHN0eWxlOiB7CiAgICAgICAgICBvdmVyZmxvdzogInZpc2libGUiCiAgICAgICAgfSwKICAgICAgICB3aWR0aDogIjEwMCUiLAogICAgICAgIGhlaWdodDogIjEwMCUiCiAgICAgIH0KICAgIH07CiAgICBjb25zdCBwYXJlbnQgPSB0aGlzW194ZmFfb2JqZWN0LiRnZXRQYXJlbnRdKClbX3hmYV9vYmplY3QuJGdldFBhcmVudF0oKTs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LiR0b1BhZ2VzXSgpIHsKICAgIGlmICghdGhpcy5zdWJmb3JtLmNoaWxkcmVuLmxlbmd0aCkgewogICAgICByZXR1cm4gX3V0aWxzLkhUTUxSZXN1bHQuc3VjY2Vzcyh7CiAgICAgICAgbmFtZTogImRpdiIsCiAgICAgICAgY2hpbGRyZW46IFtdCiAgICAgIH0pOwogICAgfQogICAgdGhpc1tfeGZhX29iamVjdC4kZXh0cmFdID0gewogICAgICBvdmVyZmxvd05vZGU6IG51bGwsCiAgICAgIGZpcnN0VW5zcGxpdHRhYmxlOiBudWxsLAogICAgICBjdXJyZW50Q29udGVudEFyZWE6IG51bGwsCiAgICAgIGN1cnJlbnRQYWdlQXJlYTogbnVsbCwKICAgICAgbm9MYXlvdXRGYWlsdXJlOiBmYWxzZSwKICAgICAgcGFnZU51bWJlcjogMSwKICAgICAgcGFnZVBvc2l0aW9uOiAiZmlyc3QiLAogICAgICBvZGRPckV2ZW46ICJvZGQiLAogICAgICBibGFua09yTm90Qmxhbms6ICJub25CbGFuayIsCiAgICAgIHBhcmFTdGFjazogW10KICAgIH07CiAgICBjb25zdCByb290ID0gdGhpcy5zdWJmb3JtLmNoaWxkcmVuWzBdOwogICAgcm9vdC5wYWdlU2V0W194ZmFfb2JqZWN0LiRjbGVhblBhZ2VdKCk7CiAgICBjb25zdCBwYWdlQXJlYXMgPSByb290LnBhZ2VTZXQucGFnZUFyZWEuY2hpbGRyZW47CiAgICBjb25zdCBtYWluSHRtbCA9IHsKICAgICAgbmFtZTogImRpdiIsCiAgICAgIGNoaWxkcmVuOiBbXQogICAgfTsKICAgIGxldCBwYWdlQXJlYSA9IG51bGw7CiAgICBsZXQgYnJlYWtCZWZvcmUgPSBudWxsOwogICAgbGV0IGJyZWFrQmVmb3JlVGFyZ2V0ID0gbnVsbDsKICAgIGlmIChyb290LmJyZWFrQmVmb3JlLmNoaWxkcmVuLmxlbmd0aCA+PSAxKSB7CiAgICAgIGJyZWFrQmVmb3JlID0gcm9vdC5icmV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ZXMuY2xhc3MuaW5jbHVkZXMoInhmYUNvbnRlbnRhcmVhIikpOwogICAgICBoYXNTb21ldGhpbmcgPSBmYWxzZTsKICAgICAgdGhpc1tfeGZhX29iamVjdC4kZXh0cmFdLmZpcnN0VW5zcGxpdHRhYmxlID0gbnVsbDsKICAgICAgdGhpc1tfeGZhX29iamVjdC4kZXh0cmFdLm5vTGF5b3V0RmFpbHVyZSA9IGZhbHNlOwogICAgICBjb25zdCBmbHVzaCA9IGluZGV4ID0+IHsKICAgICAgICBjb25zdCBodG1sID0gcm9vdFtfeGZhX29iamVjdC4kZmx1c2hIVE1MXSgpOwogICAgICAgIGlmIChodG1sKSB7CiAgICAgICAgICBoYXNTb21ldGhpbmcgPSBoYXNTb21ldGhpbmcgfHwgaHRtbC5jaGlsZHJlbiAmJiBodG1sLmNoaWxkcmVuLmxlbmd0aCAhPT0gMDsKICAgICAgICAgIGh0bWxDb250ZW50QXJlYXNbaW5kZXhdLmNoaWxkcmVuLnB1c2goaHRtbCk7CiAgICAgICAgfQogICAgICB9OwogICAgICBmb3IgKGxldCBpID0gc3RhcnRJbmRleCwgaWkgPSBjb250ZW50QXJlYXMubGVuZ3RoOyBpIDwgaWk7IGkrKykgewogICAgICAgIGNvbnN0IGNvbnRlbnRBcmVhID0gdGhpc1tfeGZhX29iamVjdC4kZXh0cmFdLmN1cnJlbnRDb250ZW50QXJlYSA9IGNvbnRlbnRBcmVhc1tpXTsKICAgICAgICBjb25zdCBzcGFjZSA9IHsKICAgICAgICAgIHdpZHRoOiBjb250ZW50QXJlYS53LAogICAgICAgICAgaGVpZ2h0OiBjb250ZW50QXJlYS5oCiAgICAgICAgfTsKICAgICAgICBzdGFydEluZGV4ID0gMDsKICAgICAgICBpZiAobGVhZGVyKSB7CiAgICAgICAgICBodG1sQ29udGVudEFyZWFzW2ldLmNoaWxkcmVuLnB1c2gobGVhZGVyW194ZmFfb2JqZWN0LiR0b0hUTUxdKHNwYWNlKS5odG1sKTsKICAgICAgICAgIGxlYWRlciA9IG51bGw7CiAgICAgICAgfQogICAgICAgIGlmICh0cmFpbGVyKSB7CiAgICAgICAgICBodG1sQ29udGVudEFyZWFzW2ldLmNoaWxkcmVuLnB1c2godHJhaWxlcltfeGZhX29iamVjdC4kdG9IVE1MXShzcGFjZSkuaHRtbCk7CiAgICAgICAgICB0cmFpbGVyID0gbnVsbDsKICAgICAgICB9CiAgICAgICAgY29uc3QgaHRtbCA9IHJvb3RbX3hmYV9vYmplY3QuJHRvSFRNTF0oc3BhY2UpOwogICAgICAgIGlmIChodG1sLnN1Y2Nlc3MpIHsKICAgICAgICAgIGlmIChodG1sLmh0bWwpIHsKICAgICAgICAgICAgaGFzU29tZXRoaW5nID0gaGFzU29tZXRoaW5nIHx8IGh0bWwuaHRtbC5jaGlsZHJlbiAmJiBodG1sLmh0bWwuY2hpbGRyZW4ubGVuZ3RoICE9PSAwOwogICAgICAgICAgICBodG1sQ29udGVudEFyZWFzW2ldLmNoaWxkcmVuLnB1c2goaHRtbC5odG1sKTsKICAgICAgICAgIH0gZWxzZSBpZiAoIWhhc1NvbWV0aGluZyAmJiBtYWluSHRtbC5jaGlsZHJlbi5sZW5ndGggPiAxKSB7CiAgICAgICAgICAgIG1haW5IdG1sLmNoaWxkcmVuLnBvcCgpOwogICAgICAgICAgfQogICAgICAgICAgcmV0dXJuIG1haW5IdG1sOwogICAgICAgIH0KICAgICAgICBpZiAoaHRtbC5pc0JyZWFrKCkpIHsKICAgICAgICAgIGNvbnN0IG5vZGUgPSBodG1sLmJyZWFrTm9kZTsKICAgICAgICAgIGZsdXNoKGkpOwogICAgICAgICAgaWYgKG5vZGUudGFyZ2V0VHlwZSA9PT0gImF1dG8iKSB7CiAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgfQogICAgICAgICAgaWYgKG5vZGUubGVhZGVyKSB7CiAgICAgICAgICAgIGxlYWRlciA9IHRoaXNbX3hmYV9vYmplY3QuJHNlYXJjaE5vZGVdKG5vZGUubGVhZGVyLCBub2RlW194ZmFfb2JqZWN0LiRnZXRQYXJlbnRdKCkpOwogICAgICAgICAgICBsZWFkZXIgPSBsZWFkZXIgPyBsZWFkZXJbMF0gOiBudWxsOwogICAgICAgICAgfQogICAgICAgICAgaWYgKG5vZGUudHJhaWxlcikgewogICAgICAgICAgICB0cmFpbGVyID0gdGhpc1tfeGZhX29iamVjdC4kc2VhcmNoTm9kZV0obm9kZS50cmFpbGVyLCBub2RlW194ZmFfb2JqZWN0LiRnZXRQYXJlbnRdKCkpOwogICAgICAgICAgICB0cmFpbGVyID0gdHJhaWxlciA/IHRyYWlsZXJbMF0gOiBudWxsOwogICAgICAgICAgfQogICAgICAgICAgaWYgKG5vZGUudGFyZ2V0VHlwZSA9PT0gInBhZ2VBcmVhIikgewogICAgICAgICAgICB0YXJnZXRQYWdlQXJlYSA9IG5vZGVbX3hmYV9vYmplY3QuJGV4dHJhXS50YXJnZXQ7CiAgICAgICAgICAgIGkgPSBJbmZpbml0eTsKICAgICAgICAgIH0gZWxzZSBpZiAoIW5vZGVbX3hmYV9vYmplY3QuJGV4dHJhXS50YXJnZXQpIHsKICAgICAgICAgICAgaSA9IG5vZGVbX3hmYV9vYmplY3QuJGV4dHJhXS5pbmRleDsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHRhcmdldFBhZ2VBcmVhID0gbm9kZVtfeGZhX29iamVjdC4kZXh0cmFdLnRhcmdldDsKICAgICAgICAgICAgc3RhcnRJbmRleCA9IG5vZGVbX3hmYV9vYmplY3QuJGV4dHJhXS5pbmRleCArIDE7CiAgICAgICAgICAgIGkgPSBJbmZpbml0eTsKICAgICAgICAgIH0KICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgIH0KICAgICAgICBpZiAodGhpc1tfeGZhX29iamVjdC4kZXh0cmFdLm92ZXJmbG93Tm9kZSkgewogICAgICAgICAgY29uc3Qgbm9kZSA9IHRoaXNbX3hmYV9vYmplY3QuJGV4dHJhXS5vdmVyZmxvd05vZGU7CiAgICAgICAgICB0aGlzW194ZmFfb2JqZWN0LiRleHRyYV0ub3ZlcmZsb3dOb2RlID0gbnVsbDsKICAgICAgICAgIGNvbnN0IG92ZXJmbG93RXh0cmEgPSBub2RlW194ZmFfb2JqZWN0LiRnZXRFeHRyYV0oKTsKICAgICAgICAgIGNvbnN0IHRhcmdldCA9IG92ZXJmbG93RXh0cmEudGFyZ2V0OwogICAgICAgICAgb3ZlcmZsb3dFeHRyYS5hZGRMZWFkZXIgPSBvdmVyZmxvd0V4dHJhLmxlYWRlciAhPT0gbnVsbDsKICAgICAgICAgIG92ZXJmbG93RXh0cmEuYWRkVHJhaWxlciA9IG92ZXJmbG93RXh0cmEudHJhaWxlciAhPT0gbnVsbDsKICAgICAgICAgIGZsdXNoKGkpOwogICAgICAgICAgY29uc3QgY3VycmVudEluZGV4ID0gaTsKICAgICAgICAgIGkgPSBJbmZpbml0eTsKICAgICAgICAgIGlmICh0YXJnZXQgaW5zdGFuY2VvZiBQYWdlQXJlYSkgewogICAgICAgICAgICB0YXJnZXRQYWdlQXJlYSA9IHRhcmdldDsKICAgICAgICAgIH0gZWxzZSBpZiAodGFyZ2V0IGluc3RhbmNlb2YgQ29udGVudEFyZWEpIHsKICAgICAgICAgICAgY29uc3QgaW5kZXggPSBjb250ZW50QXJlYXMuaW5kZXhPZih0YXJnZXQpOwogICAgICAgICAgICBpZiAoaW5kZXggIT09IC0xKSB7CiAgICAgICAgICAgICAgaWYgKGluZGV4ID4gY3VycmVudEluZGV4KSB7CiAgICAgICAgICAgICAgICBpID0gaW5kZXggLSAxOwogICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICBzdGFydEluZGV4ID0gaW5kZXg7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgIHRhcmdldFBhZ2VBcmVhID0gdGFyZ2V0W194ZmFfb2JqZWN0LiRnZXRQYXJlbnRdKCk7CiAgICAgICAgICAgICAgc3RhcnRJbmRleCA9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ICBbX3hmYV9vYmplY3QuJGdldEV4dHJhXSgpIHsKICAgIGlmICh0eXBlb2YgdGhpc1tfeGZhX29iamVjdC4kY29udGVudF0gPT09ICJzdHJpbmciKSB7CiAgICAgIHJldHVybiB0aGlzW194ZmFfb2JqZWN0LiRjb250ZW50XS5zcGxpdCgvW1x1MjAyOVx1MjAyOFxuXS8pLnJlZHVjZSgoYWNjLCBsaW5lKSA9PiB7CiAgICAgICAgaWYgKGxpbmUpIHsKICAgICAgICAgIGFjYy5wdXNoKGxpbmUpOwogICAgICAgIH0KICAgICAgICByZXR1cm4gYWNjOwogICAgICB9LCBbXSkuam9pbigiXG4iKTsKICAgIH0KICAgIHJldHVybiB0aGlzW194ZmFfb2JqZWN0LiRjb250ZW50XVtfeGZhX29iamVjdC4kdGV4dF0oKTsKICB9CiAgW194ZmFfb2JqZWN0LiR0b0hUTUxdKGF2YWlsYWJsZVNwYWNlKSB7CiAgICBpZiAodHlwZW9mIHRoaXNbX3hmYV9vYmplY3QuJGNvbnRlbnRdID09PSAic3RyaW5nIikgewogICAgICBjb25zdCBodG1sID0gdmFsdWVUb0h0bWwodGhpc1tfeGZhX29iamVjdC4kY29udGVudF0pLmh0bWw7CiAgICAgIGlmICh0aGlzW194ZmFfb2JqZWN0LiRjb250ZW50XS5pbmNsdWRlcygiXHUyMDI5IikpIHsKICAgICAgICBodG1sLm5hbWUgPSAiZGl2IjsKICAgICAgICBodG1sLmNoaWxkcmVuID0gW107CiAgICAgICAgdGhpc1tfeGZhX29iamVjdC4kY29udGVudF0uc3BsaXQoIlx1MjAyOSIpLm1hcChwYXJhID0+IHBhcmEuc3BsaXQoL1tcdTIwMjhcbl0vKS5yZWR1Y2UoKGFjYywgbGluZSkgPT4gewogICAgICAgICAgYWNjLnB1c2goewogICAgICAgICAgICBuYW1lOiAic3BhbiIsCiAgICAgICAgICAgIHZhbHVlOiBsaW5lCiAgICAgICAgICB9LCB7CiAgICAgICAgICAgIG5hbWU6ICJiciIKICAgICAgICAgIH0pOwogICAgICAgICAgcmV0dXJuIGFjYzsKICAgICAgICB9LCBbXSkpLmZvckVhY2gobGluZXMgPT4gewogICAgICAgICAgaHRtbC5jaGlsZHJlbi5wdXNoKHsKICAgICAgICAgICAgbmFtZTogInAiLAogICAgICAgICAgICBjaGlsZHJlbjogbGluZXMKICAgICAgICAgIH0pOwogICAgICAgIH0pOwogICAgICB9IGVsc2UgaWYgKC9bXHUyMDI4XG5dLy50ZXN0KHRoaXNbX3hmYV9vYmplY3QuJGNvbnRlbnRdKSkgewogICAgICAgIGh0bWwubmFtZSA9ICJkaXYiOwogICAgICAgIGh0bWwuY2hpbGRyZW4gPSBbXTsKICAgICAgICB0aGlzW194ZmFfb2JqZWN0LiRjb250ZW50XS5zcGxpdCgvW1x1MjAyOFxuXS8pLmZvckVhY2gobGluZSA9PiB7CiAgICAgICAgICBodG1sLmNoaWxkcmVuLnB1c2goewogICAgICAgICAgICBuYW1lOiAic3BhbiIsCiAgICAgICAgICAgIHZhbHVlOiBsaW5lCiAgICAgICAgICB9LCB7CiAgICAgICAgICAgIG5hbWU6ICJiciIKICAgICAgICAgIH0pOwogICAgICAgIH0pOwogICAgICB9CiAgICAgIHJldHVybiBfdXRpbHMuSFRNTFJlc3VsdC5zdWNjZXNzKGh0bWwpOwogICAgfQogICAgcmV0dXJuIHRoaXNbX3hmYV9vYmplY3QuJGNvbnRlbnRdW194ZmFfb2JqZWN0LiR0b0hUTUxdKGF2YWlsYWJsZVNwYWNlKTsKICB9Cn0KZXhwb3J0cy5UZXh0ID0gVGV4dDsKY2xhc3MgVGV4dEVkaXQgZXh0ZW5kcyBfeGZhX29iamVjdC5YRkFPYmplY3QgewogIGNvbnN0cnVjdG9yKGF0dHJpYnV0ZXMpIHsKICAgIHN1cGVyKFRFTVBMQVRFX05TX0lELCAidGV4dEVkaXQiLCB0cnVlKTsKICAgIHRoaXMuYWxsb3dSaWNoVGV4dCA9ICgwLCBfdXRpbHMuZ2V0SW50ZWdlcikoewogICAgICB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c1tfeGZhX29iamVjdC4kZ2V0UGFyZW50XSgpW194ZmFfb2JqZWN0LiRnZXRQYXJlbnRdKCk7CiAgICBpZiAodGhpcy5tdWx0aUxpbmUgPT09ICIiKSB7CiAgICAgIHRoaXMubXVsdGlMaW5lID0gZmllbGQgaW5zdGFuY2VvZiBEcmF3ID8gMSA6IDA7CiAgICB9CiAgICBpZiAodGhpcy5tdWx0aUxpbmUgPT09IDEpIHsKICAgICAgaHRtbCA9IHsKICAgICAgICBuYW1lOiAidGV4dGFyZWEiLAogICAgICAgIGF0dHJpYnV0ZXM6IHsKICAgICAgICAgIGRhdGFJZDogZmllbGRbX3hmYV9vYmplY3QuJGRhdGFdICYmIGZpZWxkW194ZmFfb2JqZWN0LiRkYXRhXVtfeGZhX29iamVjdC4kdWlkXSB8fCBmaWVsZFtfeGZhX29iamVjdC4kdWlkXSwKICAgICAgICAgIGZpZWxkSWQ6IGZpZWxkW194ZmFfb2JqZWN0LiR1aWRdLAogICAgICAgICAgY2xhc3M6IFsieGZhVGV4dGZpZWxkIl0sCiAgICAgICAgICBzdHlsZSwKICAgICAgICAgICJhcmlhLWxhYmVsIjogYXJpYUxhYmVsKGZpZWxkKSwKICAgICAgICAgICJhcmlhLXJlcXVpcmVkIjogZmFsc2UKICAgICAgICB9CiAgICAgIH07CiAgICB9IGVsc2UgewogICAgICBodG1sID0gewogICAgICAgIG5hbWU6ICJpbnB1dCIsCiAgICAgICAgYXR0cmlidXRlczogewogICAgICAgICAgdHlwZTogInRleHQiLAogICAgICAgICAgZGF0YUlkOiBmaWVsZFtfeGZhX29iamVjdC4kZGF0YV0gJiYgZmllbGRbX3hmYV9vYmplY3QuJGRhdGFdW194ZmFfb2JqZWN0LiR1aWRdIHx8IGZpZWxkW194ZmFfb2JqZWN0LiR1aWRdLAogICAgICAgICAgZmllbGRJZDogZmllbGRbX3hmYV9vYmplY3QuJHVpZF0sCiAgICAgICAgICBjbGFzczogWyJ4ZmFUZXh0ZmllbGQiXSwKICAgICA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ldHVybiBuZXcgRW5jcnlwdGlvbk1ldGhvZChhdHRycyk7CiAgfQogIHN0YXRpYyBlbmNyeXB0aW9uTWV0aG9kcyhhdHRycykgewogICAgcmV0dXJuIG5ldyBFbmNyeXB0aW9uTWV0aG9kcyhhdHRycyk7CiAgfQogIHN0YXRpYyBldmVudChhdHRycykgewogICAgcmV0dXJuIG5ldyBFdmVudChhdHRycyk7CiAgfQogIHN0YXRpYyBleERhdGEoYXR0cnMpIHsKICAgIHJldHVybiBuZXcgRXhEYXRhKGF0dHJzKTsKICB9CiAgc3RhdGljIGV4T2JqZWN0KGF0dHJzKSB7CiAgICByZXR1cm4gbmV3IEV4T2JqZWN0KGF0dHJzKTsKICB9CiAgc3RhdGljIGV4Y2xHcm91cChhdHRycykgewogICAgcmV0dXJuIG5ldyBFeGNsR3JvdXAoYXR0cnMpOwogIH0KICBzdGF0aWMgZXhlY3V0ZShhdHRycykgewogICAgcmV0dXJuIG5ldyBFeGVjdXRlKGF0dHJzKTsKICB9CiAgc3RhdGljIGV4dHJhcyhhdHRycykgewogICAgcmV0dXJuIG5ldyBFeHRyYXMoYXR0cnMpOwogIH0KICBzdGF0aWMgZmllbGQoYXR0cnMpIHsKICAgIHJldHVybiBuZXcgRmllbGQoYXR0cnMpOwogIH0KICBzdGF0aWMgZmlsbChhdHRycykgewogICAgcmV0dXJuIG5ldyBGaWxsKGF0dHJzKTsKICB9CiAgc3RhdGljIGZpbHRlcihhdHRycykgewogICAgcmV0dXJuIG5ldyBGaWx0ZXIoYXR0cnMpOwogIH0KICBzdGF0aWMgZmxvYXQoYXR0cnMpIHsKICAgIHJldHVybiBuZXcgRmxvYXQoYXR0cnMpOwogIH0KICBzdGF0aWMgZm9udChhdHRycykgewogICAgcmV0dXJuIG5ldyBGb250KGF0dHJzKTsKICB9CiAgc3RhdGljIGZvcm1hdChhdHRycykgewogICAgcmV0dXJuIG5ldyBGb3JtYXQoYXR0cnMpOwogIH0KICBzdGF0aWMgaGFuZGxlcihhdHR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h0cmEud2lkdGggPSBNYXRoLm1heChleHRyYS53aWR0aCwgZXh0cmEuY3VycmVudFdpZHRoKTsKICAgICAgYnJlYWs7CiAgICBjYXNlICJybC1yb3ciOgogICAgY2FzZSAicm93IjoKICAgICAgewogICAgICAgIGV4dHJhLmNoaWxkcmVuLnB1c2goaHRtbCk7CiAgICAgICAgZXh0cmEud2lkdGggKz0gdzsKICAgICAgICBleHRyYS5oZWlnaHQgPSBNYXRoLm1heChleHRyYS5oZWlnaHQsIGgpOwogICAgICAgIGNvbnN0IGhlaWdodCA9ICgwLCBfaHRtbF91dGlscy5tZWFzdXJlVG9TdHJpbmcpKGV4dHJhLmhlaWdodCk7CiAgICAgICAgZm9yIChjb25zdCBjaGlsZCBvZiBleHRyYS5jaGlsZHJlbikgewogICAgICAgICAgY2hpbGQuYXR0cmlidXRlcy5zdHlsZS5oZWlnaHQgPSBoZWlnaHQ7CiAgICAgICAgfQogICAgICAgIGJyZWFrOwogICAgICB9CiAgICBjYXNlICJ0YWJsZSI6CiAgICAgIHsKICAgICAgICBleHRyYS53aWR0aCA9IE1hdGgubWluKGF2YWlsYWJsZVNwYWNlLndpZHRoLCBNYXRoLm1heChleHRyYS53aWR0aCwgdykpOwogICAgICAgIGV4dHJhLmhlaWdodCArPSBoOwogICAgICAgIGV4dHJhLmNoaWxkcmVuLnB1c2goaHRtbCk7CiAgICAgICAgYnJlYWs7CiAgICAgIH0KICAgIGNhc2UgInRiIjoKICAgICAgewogICAgICAgIGV4dHJhLndpZHRoID0gTWF0aC5taW4oYXZhaWxhYmxlU3BhY2Uud2lkdGgsIE1hdGgubWF4KGV4dHJhLndpZHRoLCB3KSk7CiAgICAgICAgZXh0cmEuaGVpZ2h0ICs9IGg7CiAgICAgICAgZXh0cmEuY2hpbGRyZW4ucHVzaChodG1sKTsKICAgICAgICBicmVhazsKICAgICAgfQogIH0KfQpmdW5jdGlvbiBnZXRBdmFpbGFibGVTcGFjZShub2RlKSB7CiAgY29uc3QgYXZhaWxh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ogICAgICBicmVhazsKICAgIGNhc2UgIm1pZGRsZUxlZnQiOgogICAgICBbY2VudGVyWCwgY2VudGVyWV0gPSBbMCwgaCAvIDJdOwogICAgICBicmVhazsKICAgIGNhc2UgIm1pZGRsZVJpZ2h0IjoKICAgICAgW2NlbnRlclgsIGNlbnRlclldID0gW3csIGggLyAyXTsKICAgICAgYnJlYWs7CiAgICBjYXNlICJ0b3BDZW50ZXIiOgogICAgICBbY2VudGVyWCwgY2VudGVyWV0gPSBbdyAvIDIsIDBdOwogICAgICBicmVhazsKICAgIGNhc2UgInRvcFJpZ2h0IjoKICAgICAgW2NlbnRlclgsIGNlbnRlclldID0gW3csIDBdOwogICAgICBicmVhazsKICB9CiAgbGV0IHgsIHk7CiAgc3dpdGNoIChub2RlLnJvdGF0ZSB8fCAwKSB7CiAgICBjYXNlIDA6CiAgICAgIFt4LCB5XSA9IFstY2VudGVyWCwgLWNlbnRlclldOwogICAgICBicmVhazsKICAgIGNhc2UgOTA6CiAgICAgIFt4LCB5XSA9IFstY2VudGVyWSwgY2VudGVyWF07CiAgICAgIFt3LCBoXSA9IFtoLCAtd107CiAgICAgIGJyZWFrOwogICAgY2FzZSAxODA6CiAgICAgIFt4LCB5XSA9IFtjZW50ZXJYLCBjZW50ZXJZXTsKICAgICAgW3csIGhdID0gWy13LCAtaF07CiAgICAgIGJyZWFrOwogICAgY2FzZSAyNzA6CiAgICAgIFt4LCB5XSA9IFtjZW50ZXJZLCAtY2VudGVyWF07CiAgICAgIFt3LCBoXSA9IFstaCwgd107CiAgICAgIGJyZWFrOwogIH0KICByZXR1cm4gW25vZGUueCArIHggKyBNYXRoLm1pbigwLCB3KSwgbm9kZS55ICsgeSArIE1hdGgubWluKDAsIGgpLCBNYXRoLmFicyh3KSwgTWF0aC5hYnMoaCldOwp9CmZ1bmN0aW9uIGNoZWNrRGltZW5zaW9ucyhub2RlLCBzcGFjZSkgewogIGlmIChub2RlW194ZmFfb2JqZWN0LiRnZXRUZW1wbGF0ZVJ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gcmV0dXJuIHNwYWNlLmhlaWdodCA+IEVSUk9SOwogICAgICAgICAgICB9CiAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgIH0KICAgICAgICAgIHJldHVybiBzcGFjZS53aWR0aCA+IEVSUk9SOwogICAgICAgIH0KICAgICAgICBpZiAobm9kZS53ICE9PSAiIikgewogICAgICAgICAgcmV0dXJuIE1hdGgucm91bmQodyAtIHNwYWNlLndpZHRoKSA8PSBFUlJPUjsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIHNwYWNlLndpZHRoID4gRVJST1I7CiAgICAgIH0KICAgICAgaWYgKG5vZGVbX3hmYV9vYmplY3QuJGdldFRlbXBsYXRlUm9vdF0oKVtfeGZhX29iamVjdC4kZXh0cmFdLm5vTGF5b3V0RmFpbHVyZSkgewogICAgICAgIHJldHVybiB0cnVlOwogICAgICB9CiAgICAgIGlmIChub2RlLmggIT09ICIiICYmIE1hdGgucm91bmQoaCAtIHNwYWNlLmhlaWdodCkgPiBFUlJPUikgewogICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgfQogICAgICBpZiAobm9kZS53ID09PSAiIiB8fCBNYXRoLnJvdW5kKHcgLSBzcGFjZS53aWR0aCkgPD0gRVJST1IpIHsKICAgICAgICByZXR1cm4gc3BhY2UuaGVpZ2h0ID4gRVJST1I7CiAgICAgIH0KICAgICAgaWYgKHBhcmVudFtfeGZhX29iamVjdC4kaXNUaGVyZU1vcmVXaWR0aF0oKSkgewogICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgfQogICAgICByZXR1cm4gc3BhY2UuaGVpZ2h0ID4gRVJST1I7CiAgICBjYXNlICJ0YWJsZSI6CiAgICBjYXNlICJ0YiI6CiAgICAgIGlmIChub2RlW194ZmFfb2JqZWN0LiRnZXRUZW1wbGF0ZVJvb3RdKClbX3hmYV9vYmplY3QuJGV4dHJhXS5ub0xheW91dEZhaWx1cmUpIHsKICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgfQogICAg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dXQgIT09ICJwb3NpdGlvbiIpIHsKICAgICAgcmV0dXJuOwogICAgfQogICAgc3R5bGUucG9zaXRpb24gPSAiYWJzb2x1dGUiOwogICAgc3R5bGUubGVmdCA9IG1lYXN1cmVUb1N0cmluZyhub2RlLngpOwogICAgc3R5bGUudG9wID0gbWVhc3VyZVRvU3RyaW5nKG5vZGUueSk7CiAgfSwKICByb3RhdGUobm9kZSwgc3R5bGUpIHsKICAgIGlmIChub2RlLnJvdGF0ZSkgewogICAgICBpZiAoISgidHJhbnNmb3JtIiBpbiBzdHlsZSkpIHsKICAgICAgICBzdHlsZS50cmFuc2Zvcm0gPSAiIjsKICAgICAgfQogICAgICBzdHlsZS50cmFuc2Zvcm0gKz0gYHJvdGF0ZSgtJHtub2RlLnJvdGF0ZX1kZWcpYDsKICAgICAgc3R5bGUudHJhbnNmb3JtT3JpZ2luID0gInRvcCBsZWZ0IjsKICAgIH0KICB9LAogIHByZXNlbmNlKG5vZGUsIHN0eWxlKSB7CiAgICBzd2l0Y2ggKG5vZGUucHJlc2VuY2UpIHsKICAgICAgY2FzZSAiaW52aXNpYmxlIjoKICAgICAgICBzdHlsZS52aXNpYmlsaXR5ID0gImhpZGRlbiI7CiAgICAgICAgYnJlYWs7CiAgICAgIGNhc2UgImhpZGRlbiI6CiAgICAgIGNhc2UgImluYWN0aXZlIjoKICAgICAgICBzdHlsZS5kaXNwbGF5ID0gIm5vbmUiOwogICAgICAgIGJyZWFrOwogICAgfQogIH0sCiAgaEFsaWduKG5vZGUsIHN0eWxlKSB7CiAgICBpZiAobm9kZVtfeGZhX29iamVjdC4kbm9kZU5hbWVdID09PSAicGFyYSIpIHsKICAgICAgc3dpdGNoIChub2RlLmhBbGlnbikgewogICAgICAgIGNhc2UgImp1c3RpZnlBbGwiOgogICAgICAgICAgc3R5bGUudGV4dEFsaWduID0gImp1c3RpZnktYWxsIjsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgInJhZGl4IjoKICAgICAgICAgIHN0eWxlLnRleHRBbGlnbiA9ICJsZWZ0IjsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICBzdHlsZS50ZXh0QWxpZ24gPSBub2RlLmhBbGlnbjsKICAgICAgfQogICAgfSBlbHNlIHsKICAgICAgc3dpdGNoIChub2RlLmhBbGlnbikgewogICAgICAgIGNhc2UgImxlZnQiOgogICAgICAgICAgc3R5bGUuYWxpZ25TZWxmID0gInN0YXJ0IjsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgImNlbnRlciI6CiAgICAgICAgICBzdHlsZS5hbGlnblNlbGYgPSAiY2VudGVyIjsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgInJpZ2h0IjoKICAgICAgICAgIHN0eWxlLmFsaWduU2VsZiA9ICJlbmQiOwogICAgICAgICAgYnJlYWs7CiAgICAgIH0KICAgIH0KICB9LAogIG1hcmdpbihub2RlLCBzdHlsZSkgewogICAgaWYgKG5vZGUubWFyZ2luKSB7CiAgICAgIHN0eWxlLm1hcmdpbiA9IG5vZGUubWFyZ2luW194ZmFfb2JqZWN0LiR0b1N0eWxlXSgpLm1hcmdpbjsKICAgIH0KICB9Cn07CmZ1bmN0aW9uIHNldE1pbk1heERpbWVuc2lvbnMobm9kZSwgc3R5bGUpIHsKICBjb25zdCBwYXJlbnQgPSBub2RlW194ZmFfb2JqZWN0LiRnZXRTdWJmb3JtUGFyZW50XSgpOwogIGlmIChwYXJlbnQubGF5b3V0ID09PSAicG9zaXRpb24iKSB7CiAgICBpZiAobm9kZS5taW5XID4gMCkgewogICAgICBzdHlsZS5taW5XaWR0aCA9IG1lYXN1cmVUb1N0cmluZyhub2RlLm1pblcpOwogICAgfQogICAgaWYgKG5vZGUubWF4VyA+IDApIHsKICAgICAgc3R5bGUubWF4V2lkdGggPSBtZWFzdXJlVG9TdHJpbmcobm9kZS5tYXhXKTsKICAgIH0KICAgIGlmIChub2RlLm1pbkggPiAwKSB7CiAgICAgI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bWFyZ2luVjsKICAgIH0KICB9CiAgcmV0dXJuIHsKICAgIHc6IHdpZHRoLAogICAgaDogaGVpZ2h0LAogICAgaXNCcm9rZW4KICB9Owp9CmZ1bmN0aW9uIGNvbXB1dGVCYm94KG5vZGUsIGh0bWwsIGF2YWlsYWJsZVNwYWNlKSB7CiAgbGV0IGJib3g7CiAgaWYgKG5vZGUudyAhPT0gIiIgJiYgbm9kZS5oICE9PSAiIikgewogICAgYmJveCA9IFtub2RlLngsIG5vZGUueSwgbm9kZS53LCBub2RlLmhdOwogIH0gZWxzZSB7CiAgICBpZiAoIWF2YWlsYWJsZVNwYWNlKSB7CiAgICAgIHJldHVybiBudWxsOwogICAgfQogICAgbGV0IHdpZHRoID0gbm9kZS53OwogICAgaWYgKHdpZHRoID09PSAiIikgewogICAgICBpZiAobm9kZS5tYXhXID09PSAwKSB7CiAgICAgICAgY29uc3QgcGFyZW50ID0gbm9kZVtfeGZhX29iamVjdC4kZ2V0U3ViZm9ybVBhcmVudF0oKTsKICAgICAgICBpZiAocGFyZW50LmxheW91dCA9PT0gInBvc2l0aW9uIiAmJiBwYXJlbnQudyAhPT0gIiIpIHsKICAgICAgICAgIHdpZHRoID0gMDsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgd2lkdGggPSBub2RlLm1pblc7CiAgICAgICAgfQogICAgICB9IGVsc2UgewogICAgICAgIHdpZHRoID0gTWF0aC5taW4obm9kZS5tYXhXLCBhdmFpbGFibGVTcGFjZS53aWR0aCk7CiAgICAgIH0KICAgICAgaHRtbC5hdHRyaWJ1dGVzLnN0eWxlLndpZHRoID0gbWVhc3VyZVRvU3RyaW5nKHdpZHRoKTsKICAgIH0KICAgIGxldCBoZWlnaHQgPSBub2RlLmg7CiAgICBpZiAoaGVpZ2h0ID09PSAiIikgewogICAgICBpZiAobm9kZS5tYXhIID09PSAwKSB7CiAgICAgICAgY29uc3QgcGFyZW50ID0gbm9kZVtfeGZhX29iamVjdC4kZ2V0U3ViZm9ybVBhcmV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IHcpID0+IGEgKyB3LCAwKTsKICAgIH0KICAgIGlmICghaXNOYU4od2lkdGgpKSB7CiAgICAgIG5vZGUudyA9IHdpZHRoOwogICAgfQogIH0KICBpZiAocGFyZW50LmxheW91dCAmJiBwYXJlbnQubGF5b3V0ICE9PSAicG9zaXRpb24iKSB7CiAgICBub2RlLnggPSBub2RlLnkgPSAwOwogIH0KICBpZiAobm9kZS5sYXlvdXQgPT09ICJ0YWJsZSIpIHsKICAgIGlmIChub2RlLncgPT09ICIiICYmIEFycmF5LmlzQXJyYXkobm9kZS5jb2x1bW5XaWR0aHMpKSB7CiAgICAgIG5vZGUudyA9IG5vZGUuY29sdW1uV2lkdGhzLnJlZHVjZSgoYSwgeCkgPT4gYSArIHgsIDApOwogICAgfQogIH0KfQpmdW5jdGlvbiBsYXlvdXRDbGFzcyhub2RlKSB7CiAgc3dpdGNoIChub2RlLmxheW91dCkgewogICAgY2FzZSAicG9zaXRpb24iOgogICAgICByZXR1cm4gInhmYVBvc2l0aW9uIjsKICAgIGNhc2UgImxyLXRiIjoKICAgICAgcmV0dXJuICJ4ZmFMclRiIjsKICAgIGNhc2UgInJsLXJvdyI6CiAgICAgIHJldHVybiAieGZhUmxSb3ciOwogICAgY2FzZSAicmwtdGIiOgogICAgICByZXR1cm4gInhmYVJsVGIiOwogICAgY2FzZSAicm93IjoKICAgICAgcmV0dXJuICJ4ZmFSb3ciOwogICAgY2FzZSAidGFibGUiOgogICAgICByZXR1cm4gInhmYVRhYmxlIjsKICAgIGNhc2UgInRiIjoKICAgICAgcmV0dXJuICJ4ZmFUYiI7CiAgICBkZWZhdWx0OgogICAgICByZXR1cm4gInhmYVBvc2l0aW9uIjsKICB9Cn0KZnVuY3Rpb24gdG9TdHlsZShub2RlKSB7CiAgY29uc3Qgc3R5bGUgPSBPYmplY3QuY3JlYXRlKG51bGwpOwogIGZvciAodmFyIF9sZW4gPSBhcmd1bWVudHMubGVuZ3RoLCBuYW1lcyA9IG5ldyBBcnJheShfbGVu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CiAgICAgIGNhc2UgInJpZ2h0IjoKICAgICAgICB3aWR0aCA9IGluc2V0c1cgPyBgY2FsYygxMDAlIC0gJHtpbnNldHNXfXB4KWAgOiAiMTAwJSI7CiAgICAgICAgaGVpZ2h0ID0gaW5zZXRzSCA/IGBjYWxjKDEwMCUgLSAke2luc2V0c0h9cHgpYCA6ICIxMDAlIjsKICAgICAgICBicmVhazsKICAgIH0KICAgIGNvbnN0IGNsYXNzTmFtZXMgPSBbInhmYUJvcmRlciJdOwogICAgaWYgKGlzUHJpbnRPbmx5KG5vZGUuYm9yZGVyKSkgewogICAgICBjbGFzc05hbWVzLnB1c2goInhmYVByaW50T25seSIpOwogICAgfQogICAgY29uc3QgYm9yZGVyID0gewogICAgICBuYW1lOiAiZGl2IiwKICAgICAgYXR0cmlidXRlczogewogICAgICAgIGNsYXNzOiBjbGFzc05hbWVzLAogICAgICAgIHN0eWxlOiB7CiAgICAgICAgICB0b3A6IGAke3RvcH1weGAsCiAgICAgICAgICBsZWZ0OiBgJHtsZWZ0fXB4YCwKICAgICAgICAgIHdpZHRoLAogICAgICAgICAgaGVpZ2h0CiAgICAgICAgfQogICAgICB9LAogICAgICBjaGlsZHJlbjogW10KICAgIH07CiAgICBmb3IgKGNvbnN0IGtleSBvZiBbImJvcmRlciIsICJib3JkZXJXaWR0aCIsICJib3JkZXJDb2xvciIsICJib3JkZXJSYWRpdXMiLCAiYm9yZGVyU3R5bGUiXSkgewogICAgICBpZiAoc3R5bGVba2V5XSAhPT0gdW5kZWZpbmVkKSB7CiAgICAgICAgYm9yZGVyLmF0dHJpYnV0ZXMuc3R5bGVba2V5XSA9IHN0eWxlW2tleV07CiAgICAgICAgZGVsZXRlIHN0eWxlW2tleV07CiAgICAgIH0KICAgIH0KICAgIHdyYXBwZXIuY2hpbGRyZW4ucHVzaChib3JkZXIsIGh0bWwpOwogIH0gZWxzZSB7CiAgICB3cmFwcGVyLmNoaWxkcmVuLnB1c2goaHRtbCk7CiAgfQogIGZvciAoY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tZW50cy5sZW5ndGggPiAxICYmIGFyZ3VtZW50c1sxXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzFdIDogbnVsbDsKICAgIGZvciAoY29uc3QgcGRmRm9udCBvZiBwZGZGb250cykgewogICAgICB0aGlzLmFkZFBkZkZvbnQocGRmRm9udCk7CiAgICB9CiAgICBmb3IgKGNvbnN0IHBkZkZvbnQgb2YgdGhpcy5mb250cy52YWx1ZXMoKSkgewogICAgICBpZiAoIXBkZkZvbnQucmVndWxhcikgewogICAgICAgIHBkZkZvbnQucmVndWxhciA9IHBkZkZvbnQuaXRhbGljIHx8IHBkZkZvbnQuYm9sZCB8fCBwZGZGb250LmJvbGRpdGFsaWM7CiAgICAgIH0KICAgIH0KICAgIGlmICghcmVhbGx5TWlzc2luZ0ZvbnRzIHx8IHJlYWxseU1pc3NpbmdGb250cy5zaXplID09PSAwKSB7CiAgICAgIHJldHVybjsKICAgIH0KICAgIGNvbnN0IG15cmlhZCA9IHRoaXMuZm9udHMuZ2V0KCJQZGZKUy1GYWxsYmFjay1QZGZKUy1YRkEiKTsKICAgIGZvciAoY29uc3QgbWlzc2luZyBvZiByZWFsbHlNaXNzaW5nRm9udHMpIHsKICAgICAgdGhpcy5mb250cy5zZXQobWlzc2luZywgbXlyaWFkKTsKICAgIH0KICB9CiAgYWRkUGRmRm9udChwZGZGb250KSB7CiAgICBjb25zdCBjc3NGb250SW5mbyA9IHBkZkZvbnQuY3NzRm9udEluZm87CiAgICBjb25zdCBuYW1lID0gY3NzRm9udEluZm8uZm9udEZhbWlseTsKICAgIGxldCBmb250ID0gdGhpcy5mb250cy5nZXQobmFtZSk7CiAgICBpZiAoIWZvbnQpIHsKICAgICAgZm9udCA9IE9iamVjdC5jcmVhdGUobnVsbCk7CiAgICAgIHRoaXMuZm9udHMuc2V0KG5hbWUsIGZvbnQpOwogICAgICBpZiAoIXRoaXMuZGVmYXVsdEZvbnQpIHsKICAgICAgICB0aGlzLmRlZmF1bHRGb250ID0g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5ndGggPiAxICYmIGFyZ3VtZW50c1sxXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzFdIDogdHJ1ZTsKICAgIGxldCBmb250ID0gdGhpcy5mb250cy5nZXQoZm9udE5hbWUpIHx8IHRoaXMuY2FjaGUuZ2V0KGZvbnROYW1lKTsKICAgIGlmIChmb250KSB7CiAgICAgIHJldHVybiBmb250OwogICAgfQogICAgY29uc3QgcGF0dGVybiA9IC8sfC18X3wgfGJvbGRpdGFsaWN8Ym9sZHxpdGFsaWN8cmVndWxhcnxpdC9naTsKICAgIGxldCBuYW1lID0gZm9udE5hbWUucmVwbGFjZUFsbChwYXR0ZXJuLCAiIik7CiAgICBmb250ID0gdGhpcy5mb250cy5nZXQobmFtZSk7CiAgICBpZiAoZm9udCkgewogICAgICB0aGlzLmNhY2hlLnNldChmb250TmFtZSwgZm9udCk7CiAgICAgIHJldHVybiBmb250OwogICAgfQogICAgbmFtZSA9IG5hbWUudG9Mb3dlckNhc2UoKTsKICAgIGNvbnN0IG1heWJlID0gW107CiAgICBmb3IgKGNvbnN0IFtmYW1pbHksIHBkZkZvbnRdIG9mIHRoaXMuZm9udHMuZW50cmllcygpKSB7CiAgICAgIGlmIChmYW1pbHkucmVwbGFjZUFsbChwYXR0ZXJuLCAiIikudG9Mb3dlckNhc2UoKS5zdGFydHNXaXRoKG5hbWUpKSB7CiAgICAgICAgbWF5YmUucHVzaChwZGZGb250KTsKICAgICAgfQogICAgfQogICAgaWYgKG1heWJlLmxlbmd0aCA9PT0gMCkgewogICAgICBmb3IgKGNvbnN0IFssIHBkZkZvbnRdIG9mIHRoaXMuZm9udHMuZW50cmllcygpKSB7CiAgICAgICAgaWYgKHBkZkZvbnQucmVndWxhci5uYW1lICYmIHBkZkZvbnQucmVndWxhci5uYW1lLnJlcGxhY2VBbGwocGF0dGVybiwgIiIpLnRvTG93ZXJDYXNlKCkuc3RhcnRzV2l0aChuYW1lKSkgewogICAgICAgICAgbWF5YmUucHVzaChwZGZGb250KTsKICAgICAgICB9CiAgICAgIH0KICAgIH0KICAgIGlmIChtYXliZS5sZW5ndGggPT09IDApIHsKICAgICAgbmFtZSA9IG5hbWUucmVwbGFjZUFsbCgvcHNtdHxtdC9naSwgIiIpOwogICAgICBmb3IgKGNvbnN0IFtmYW1pbHksIHBkZkZvbnRdIG9mIHRoaXMuZm9udHMuZW50cmllcygpKSB7CiAgICAgICAgaWYgKGZhbWlseS5yZXBsYWNlQWxsKHBhdHRlcm4sICIiKS50b0xvd2VyQ2FzZSgpLnN0YXJ0c1dpdGgobmFtZSkpIHsKICAgICAgICAgIG1heWJlLnB1c2gocGRmRm9udCk7CiAgICAgICAgfQogICAgICB9CiAgICB9CiAgICBpZiAobWF5YmUubGVuZ3RoID09PSAwKSB7CiAgICAgIGZvciAoY29uc3QgcGRmRm9udCBvZiB0aGlzLmZvbnRzLnZhbHVlcygpKSB7CiAgICAgICAgaWYgKHBkZkZvbnQucmVndWxhci5uYW1lICYmIHBkZkZvbnQucmVndWxhci5uYW1lLnJlcGxhY2VBbGwocGF0dGVybiwgIiIpLnRvTG93ZXJDYXNlKCkuc3RhcnRzV2l0aChuYW1lKSkgewogICAgICAgICAgbWF5YmUucHVzaChwZGZGb250KTsKICAgICAgICB9CiAgICAgIH0KICAgIH0KICAgIGlmIChtYXliZS5sZW5ndGggPj0gMSkgewogICAgICBpZiAobWF5YmUubGVuZ3RoICE9PSAxICYmIG11c3RXYXJuKSB7CiAgICAgICAgKDAsIF91dGlsLndhcm4pKGBYRkEgLSBUb28gbWFueSBjaG9pY2VzIHRvIGd1ZXNzIHRoZSBjb3JyZWN0IGZvbnQ6ICR7Zm9udE5hbWV9YCk7CiAgICAgIH0KICAgICAgdGhpcy5jYWNoZS5zZXQoZm9udE5hbWUsIG1heWJlWzBdKTsKICAgICAgcmV0dXJuIG1heWJlWzBdOwogICAgfQogICAgaWYgKG11c3RXYXJuICYmICF0aGlzLndhcm5lZC5oYXMoZm9udE5hbWUpKSB7CiAgICAgIH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ICBsYXN0U3BhY2VQb3MgPSAtMTsKICAgICAgICBsYXN0U3BhY2VXaWR0aCA9IDA7CiAgICAgICAgaXNGaXJzdExpbmUgPSBmYWxzZTsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBpZiAoaXNTcGFjZSkgewogICAgICAgIGlmIChjdXJyZW50TGluZVdpZHRoICsgZ2x5cGhXaWR0aCA+IG1heFdpZHRoKSB7CiAgICAgICAgICB3aWR0aCA9IE1hdGgubWF4KHdpZHRoLCBjdXJyZW50TGluZVdpZHRoKTsKICAgICAgICAgIGN1cnJlbnRMaW5lV2lkdGggPSAwOwogICAgICAgICAgaGVpZ2h0ICs9IGN1cnJlbnRMaW5lSGVpZ2h0OwogICAgICAgICAgY3VycmVudExpbmVIZWlnaHQgPSBnbHlwaEhlaWdodDsKICAgICAgICAgIGxhc3RTcGFjZVBvcyA9IC0xOwogICAgICAgICAgbGFzdFNwYWNlV2lkdGggPSAwOwogICAgICAgICAgaXNCcm9rZW4gPSB0cnVlOwogICAgICAgICAgaXNGaXJzdExpbmUgPSBmYWxzZTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgY3VycmVudExpbmVIZWlnaHQgPSBNYXRoLm1heChnbHlwaEhlaWdodCwgY3VycmVudExpbmVIZWlnaHQpOwogICAgICAgICAgbGFzdFNwYWNlV2lkdGggPSBjdXJyZW50TGluZVdpZHRoOwogICAgICAgICAgY3VycmVudExpbmVXaWR0aCArPSBnbHlwaFdpZHRoOwogICAgICAgICAgbGFzdFNwYWNlUG9zID0gaTsKICAgICAgICB9CiAgICAgICAgY29udGludWU7CiAgICAgIH0KICAgICAgaWYgKGN1cnJlbnRMaW5lV2lkdGggKyBnbHlwaFdpZHRoID4gbWF4V2lkdGgpIHsKICAgICAgICBoZWlnaHQgKz0gY3VycmVudExpbmVIZWlnaHQ7CiAgICAgICAgY3VycmVudExpbmVIZWlnaHQgPSBnbHlwaEhlaWdodDsKICAgICAgICBpZiAobGFzdFNwYWNlUG9zICE9PSAtMSkgewogICAgICAgICAgaSA9IGxhc3RTcGFjZVBvczsKICAgICAgICAgIHdpZHRoID0gTWF0aC5tYXgod2lkdGgsIGxhc3RTcGFjZVdpZHRoKTsKICAgICAgICAgIGN1cnJlbnRMaW5lV2lkdGggPSAwOwogICAgICAgICAgbGFzdFNwYWNlUG9zID0gLTE7CiAgICAgICAgICBsYXN0U3BhY2VXaWR0aCA9IDA7CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIHdpZHRoID0gTWF0aC5tYXgod2lkdGgsIGN1cnJlbnRMaW5lV2lkdGgpOwogICAgICAgICAgY3VycmVudExpbmVXaWR0aCA9IGdseXBoV2lkdGg7CiAgICAgICAgfQogICAgICAgIGlzQnJva2VuID0gdHJ1ZTsKICAgICAgICBpc0ZpcnN0TGluZSA9IGZhbHNlOwogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGN1cnJlbnRMaW5lV2lkdGggKz0gZ2x5cGhXaWR0aDsKICAgICAgY3VycmVudExpbmVIZWlnaHQgPSBNYXRoLm1heChnbHlwaEhlaWdodCwgY3VycmVudExpbmVIZWlnaHQpOwogICAgfQogICAgd2lkdGggPSBNYXRoLm1heCh3aWR0aCwgY3VycmVudExpbmVXaWR0aCk7CiAgICBoZWlnaHQgKz0gY3VycmVudExpbmVIZWlnaHQgKyB0aGlzLmV4dHJhSGVpZ2h0OwogICAgcmV0dXJuIHsKICAgICAgd2lkdGg6IFdJRFRIX0ZBQ1RPUiAqIHdpZHRoLAogICAgICBoZWlnaHQsCiAgICAgIGlzQnJva2VuCiAgICB9OwogIH0KfQpleHBvcnRzLlRleHRNZWFzdXJlID0gVGV4dE1lYXN1cmU7CgovKioqLyB9KSwKLyogMjIyICovCi8qKiovICgoX191bnVzZWRfd2VicGFja19tb2R1bGUsIGV4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiJ1c2Ugc3RyaWN0IjsKCgpPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb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G5hbWVzcGFjZSA9IG51bGw7CiAgICBsZXQgcHJlZml4ZXMgPSBudWxsOwogICAgY29uc3QgYXR0cmlidXRlT2JqID0gT2JqZWN0LmNyZWF0ZSh7fSk7CiAgICBmb3IgKGNvbnN0IHsKICAgICAgbmFtZSwKICAgICAgdmFsdWUKICAgIH0gb2YgYXR0cmlidXRlcykgewogICAgICBpZiAobmFtZSA9PT0gInhtbG5zIikgewogICAgICAgIGlmICghbmFtZXNwYWNlKSB7CiAgICAgICAgICBuYW1lc3BhY2UgPSB2YWx1ZTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgKDAsIF91dGlsLndhcm4pKGBYRkEgLSBtdWx0aXBsZSBuYW1lc3BhY2UgZGVmaW5pdGlvbiBpbiA8JHt0YWdOYW1lfT5gKTsKICAgICAgICB9CiAgICAgIH0gZWxzZSBpZiAobmFtZS5zdGFydHNXaXRoKCJ4bWxuczoiKSkgewogICAgICAgIGNvbnN0IHByZWZpeCA9IG5hbWUuc3Vic3RyaW5nKCJ4bWxuczoiLmxlbmd0aCk7CiAgICAgICAgaWYgKCFwcmVmaXhlcykgewogICAgICAgICAgcHJlZml4ZXMgPSBbXTsKICAgICAgICB9CiAgICAgICAgcHJlZml4ZXMucHVzaCh7CiAgICAgICAgICBwcmVmaXgsCiAgICAgICAgICB2YWx1ZQogICAgICAgIH0pOwogICAgICB9IGVsc2UgewogICAgICAgIGNvbnN0IGkgPSBuYW1lLmluZGV4T2YoIjoiKTsKICAgICAgICBpZiAoaSA9PT0gLTEpIHsKICAgICAgICAgIGF0dHJpYnV0ZU9ialtuYW1lXSA9IHZhbHVlOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBsZXQgbnNBdHRycyA9IGF0dHJpYnV0ZU9ialtfeGZhX29iamVjdC4kbnNBdHRyaWJ1dGVzXTsKICAgICAgICAgIGlmICghbnNBdHRycykgewogICAgICAgICAgICBuc0F0dHJzID0gYXR0cmlidXRlT2JqW194ZmFfb2JqZWN0LiRuc0F0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bGQoewogICAgICBuc1ByZWZpeCwKICAgICAgbmFtZSwKICAgICAgYXR0cmlidXRlczogYXR0cmlidXRlc09iaiwKICAgICAgbmFtZXNwYWNlLAogICAgICBwcmVmaXhlcwogICAgfSk7CiAgICBub2RlW194ZmFfb2JqZWN0LiRnbG9iYWxEYXRhXSA9IHRoaXMuX2dsb2JhbERhdGE7CiAgICBpZiAoaXNFbXB0eSkgewogICAgICBub2RlW194ZmFfb2JqZWN0LiRmaW5hbGl6ZV0oKTsKICAgICAgaWYgKHRoaXMuX2N1cnJlbnRbX3hmYV9vYmplY3QuJG9uQ2hpbGRdKG5vZGUpKSB7CiAgICAgICAgbm9kZVtfeGZhX29iamVjdC4kc2V0SWRdKHRoaXMuX2lkcyk7CiAgICAgIH0KICAgICAgbm9kZVtfeGZhX29iamVjdC4kY2xlYW5dKHRoaXMuX2J1aWxkZXIpOwogICAgICByZXR1cm47CiAgICB9CiAgICB0aGlzLl9zdGFjay5wdXNoKHRoaXMuX2N1cnJlbnQpOwogICAgdGhpcy5fY3VycmVudCA9IG5vZGU7CiAgfQogIG9uRW5kRWxlbWVudChuYW1lKSB7CiAgICBjb25zdCBub2RlID0gdGhpcy5fY3VycmVudDsKICAgIGlmIChub2RlW194ZmFfb2JqZWN0LiRpc0NEQVRBWG1sXSgpICYmIHR5cGVvZiBub2RlW194ZmFfb2JqZWN0LiRjb250ZW50XSA9PT0gInN0cmluZyIpIHsKICAgICAgY29uc3QgcGFyc2VyID0gbmV3IFhGQVBhcnNlcigpOwogICAgICBwYXJzZXIuX2dsb2JhbERhdGEgPSB0aGlzLl9nbG9iYWxEYXRhOwogICAgICBjb25zdCByb290ID0gcGFyc2VyLnBhcnNlKG5vZGVbX3hmYV9vYmplY3QuJGNvbnRlbnRdKTsKICAgICAgbm9kZVtfeGZhX29iamVjdC4kY29udGVudF0gPSBudWxsOwogICAgICBub2RlW194ZmFfb2JqZWN0LiRvbkNoaWxkXShyb290KTsKICAgIH0KICAgIG5vZGVbX3hm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3N0aWNdKCkpIHsKICAgICAgdGhpcy5fbnNBZ25vc3RpY0xldmVsKys7CiAgICB9CiAgICBpZiAoaGFzTmFtZXNwYWNlRGVmIHx8IHByZWZpeGVzIHx8IG5vZGVbX3hmYV9vYmplY3QuJGlzTnNBZ25vc3RpY10oKSkgewogICAgICBub2RlW194ZmFfb2JqZWN0LiRjbGVhbnVwXSA9IHsKICAgICAgICBoYXNOYW1lc3BhY2U6IGhhc05hbWVzcGFjZURlZiwKICAgICAgICBwcmVmaXhlcywKICAgICAgICBuc0Fnbm9zdGljOiBub2RlW194ZmFfb2JqZWN0LiRpc05zQWdub3N0aWNdKCkKICAgICAgfTsKICAgIH0KICAgIHJldHVybiBub2RlOwogIH0KICBpc05zQWdub3N0aWMoKSB7CiAgICByZXR1cm4gdGhpcy5fbnNBZ25vc3RpY0xldmVsID4gMDsKICB9CiAgX3NlYXJjaE5hbWVzcGFjZShuc05hbWUpIHsKICAgIGxldCBucyA9IHRoaXMuX25hbWVzcGFjZXMuZ2V0KG5zTmFtZSk7CiAgICBpZiAobnMpIHsKICAgICAgcmV0dXJuIG5zOwogICAgfQogICAgZm9yIChjb25zdCBbbmFtZSwgewogICAgICBjaGVjawogICAgfV0gb2YgT2JqZWN0LmVudHJpZXMoX25hbWVzcGFjZXMuTmFtZXNwYWNlSWRzKSkgewogICAgICBpZiAoY2hlY2sobnNOYW1lKSkgewogICAgICAgIG5zID0gX3NldHVwLk5hbWVzcGFjZVNldFVwW25hbWVdOwogICAgICAgIGlmIChucykgewogICAgICAgICAgdGhpcy5fbmFtZXNwYWNlcy5zZXQobnNOYW1lLCBucyk7CiAgICAgICAgICByZXR1cm4gbnM7CiAgICAgICAgfQogICAgICAgIGJyZWFrOwogICAgICB9CiAgICB9CiAgICBucyA9IG5ldyBfdW5rbm93bi5Vbmtub3duTmFtZXNwYWNlKCsrdGhpcy5fbmV4dE5zSWQpOwogICAgdGhpcy5fbmFtZXNwYWNlcy5zZXQobnNOYW1lLCBucyk7CiAgICByZXR1cm4gbnM7CiAgfQogIF9hZGROYW1lc3BhY2VQcmVmaXgocHJlZml4ZXMpIHsKICAgIGZvciAoY29uc3QgewogICAgICBwcmVmaXgsCiAgICAgIHZhbHVlCiAgICB9IG9mIHByZWZpeGVzKSB7CiAgICAgIGNvbnN0IG5hbWVzcGFjZSA9IHRoaXMuX3NlYXJjaE5hbWVzcGFjZSh2YWx1ZSk7CiAgICAgIGxldCBwcmVmaXhTdGFjayA9IHRoaXMuX25hbWVzcGFjZVByZWZpeGVzLmdldChwcmVmaXgpOwogICAgICBpZiAoIXByZWZpeFN0YWNrKSB7CiAgICAgICAgcHJlZml4U3RhY2sgPSBbXTsKICAgICAgICB0aGlzLl9uYW1lc3BhY2VQcmVmaXhlcy5zZXQocHJlZml4LCBwcmVmaXhTdGFjayk7CiAgICAgIH0KICAgICAgcHJlZml4U3RhY2sucHVzaChuYW1lc3BhY2UpOwogICAgfQogIH0KICBfZ2V0TmFtZXNwYWNlVG9Vc2UocHJlZml4KSB7CiAgICBpZiAoIXByZWZpeCkgewogICAgICByZXR1cm4gdGhpcy5fY3VycmVudE5hbWVzcGFjZTsKICAgIH0KICAgIGNvbnN0IHByZWZpeFN0YWNrID0gdGhpcy5fbmFtZXNwYWNlUHJlZml4ZXMuZ2V0KHByZWZpeCk7CiAgICBpZiAocHJlZml4U3RhY2sgJiYgcHJlZml4U3RhY2subGVuZ3RoID4gMCkgewogICAgICByZXR1cm4gcHJlZml4U3RhY2suYXQoLTEpOwogICAgfQogICAgKDAsIF91dGlsLndhcm4pKGBVbmtub3duIG5hbWVzcGFjZSBwcmVmaXg6ICR7cHJlZml4fS5gKTsKICAgIHJldHVybiBudWxsOwogIH0KICBjbGVhbihkYXRhKSB7CiAgICBjb25zdCB7CiAgICAgIGhhc05hbWVzcGFjZSwKICAgICAgcHJlZml4ZXMsCiAgICAgIG5zQWdub3N0aWMKICAgIH0gPSBkYXRhOwogICAgaWYgKGhhc05hbWVzcGFjZSkgewogICAgICB0aG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gc3RyLnJlcGxhY2VBbGwoc3BhY2VzUmVnRXhwLCAiICIpOwogICAgICB9CiAgICB9IGVsc2UgewogICAgICB0aGlzWyRyaWNoVGV4dF0gPSB0cnVlOwogICAgfQogICAgaWYgKHN0cikgewogICAgICB0aGlzW194ZmFfb2JqZWN0LiRjb250ZW50XSArPSBzdHI7CiAgICB9CiAgfQogIFtfeGZhX29iamVjdC4kcHVzaEdseXBoc10obWVhc3VyZSkgewogICAgbGV0IG11c3RQb3AgPSBhcmd1bWVudHMubGVuZ3RoID4gMSAmJiBhcmd1bWVudHNbMV0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1sxXSA6IHRydWU7CiAgICBjb25zdCB4ZmFGb250ID0gT2JqZWN0LmNyZWF0ZShudWxsKTsKICAgIGNvbnN0IG1hcmdpbiA9IHsKICAgICAgdG9wOiBOYU4sCiAgICAgIGJvdHRvbTogTmFOLAogICAgICBsZWZ0OiBOYU4sCiAgICAgIHJpZ2h0OiBOYU4KICAgIH07CiAgICBsZXQgbGluZUhlaWdodCA9IG51bGw7CiAgICBmb3IgKGNvbnN0IFtrZXksIHZhbHVlXSBvZiB0aGlzLnN0eWxlLnNwbGl0KCI7IikubWFwKHMgPT4gcy5zcGxpdCgiOiIsIDIpKSkgewogICAgICBzd2l0Y2ggKGtleSkgewogICAgICAgIGNhc2UgImZvbnQtZmFtaWx5IjoKICAgICAgICAgIHhmYUZvbnQudHlwZWZhY2UgPSAoMCwgX3V0aWxzLnN0cmlwUXVvdGVzKSh2YWx1ZSk7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJmb250LXNpemUiOgogICAgICAgICAgeGZhRm9udC5zaXplID0gKDAsIF91dGlscy5nZXRNZWFzdXJlbWVudCkodmFsdWUpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiZm9udC13ZWlnaHQiOgogICAgICAgICAgeGZhRm9udC53ZWlnaHQgPSB2YWx1ZTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgImZvbnQtc3R5bGUiOgogICAgICAgICAgeGZhRm9udC5wb3N0dXJlID0gdmFsdWU7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJsZXR0ZXItc3BhY2luZyI6CiAgICAgICAgICB4ZmFGb250LmxldHRlclNwYWNpbmcgPSAoMCwgX3V0aWxzLmdldE1lYXN1cmVtZW50KSh2YWx1ZSk7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJtYXJnaW4iOgogICAgICAgICAgY29uc3QgdmFsdWVzID0gdmFsdWUuc3BsaXQoLyBcdC8pLm1hcCh4ID0+ICgwLCBfdXRpbHMuZ2V0TWVhc3VyZW1lbnQpKHgpKTsKICAgICAgICAgIHN3aXRjaCAodmFsdWVzLmxlbmd0aCkgewogICAgICAgICAgICBjYXNlIDE6CiAgICAgICAgICAgICAgbWFyZ2luLnRvcCA9IG1hcmdpbi5ib3R0b20gPSBtYXJnaW4ubGVmdCA9IG1hcmdpbi5yaWdodCA9IHZhbHVlc1swXTsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSAyOgogICAgICAgICAgICAgIG1hcmdpbi50b3AgPSBtYXJnaW4uYm90dG9tID0gdmFsdWVzWzBdOwogICAgICAgICAgICAgIG1hcmdpbi5sZWZ0ID0gbWFyZ2luLnJpZ2h0ID0gdmFsdWVzWzFdOwogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICBjYXNlIDM6CiAgICAgICAgICAgICAgbWFyZ2luLnRvcCA9IHZhbHVlc1swXTsKICAgICAgICAgICAgICBtYXJnaW4uYm90dG9tID0gdmFsdWVzWzJdOwogICAgICAgICAgICAgIG1hcmdpbi5sZWZ0ID0gbWFyZ2luLnJpZ2h0ID0gdmFsdWVzWzFdOwogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICBjYXNlIDQ6CiAgICAgICAgICAgICAgbWFyZ2luLnRvcCA9IHZhbHVlc1swXTsKICAgICAgICAgICAgICBtYXJnaW4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mxlbmd0aCA9PT0gMCkgewogICAgICByZXR1cm4gX3V0aWxzLkhUTUxSZXN1bHQuc3VjY2Vzcyh7CiAgICAgICAgbmFtZTogImRpdiIsCiAgICAgICAgYXR0cmlidXRlczogewogICAgICAgICAgY2xhc3M6IFsieGZhUmljaCJdLAogICAgICAgICAgc3R5bGU6IHt9CiAgICAgICAgfSwKICAgICAgICB2YWx1ZTogdGhpc1tfeGZhX29iamVjdC4kY29udGVudF0gfHwgIiIKICAgICAgfSk7CiAgICB9CiAgICBpZiAoY2hpbGRyZW4ubGVuZ3RoID09PSAxKSB7CiAgICAgIGNvbnN0IGNoaWxkID0gY2hpbGRyZW5bMF07CiAgICAgIGlmIChjaGlsZC5hdHRyaWJ1dGVzICYmIGNoaWxkLmF0dHJpYnV0ZXMuY2xhc3MuaW5jbHVkZXMoInhmYVJpY2giKSkgewogICAgICAgIHJldHVybiBfdXRpbHMuSFRNTFJlc3VsdC5zdWNjZXNzKGNoaWxkKTsKICAgICAgfQogICAgfQogICAgcmV0dXJuIF91dGlscy5IVE1MUmVzdWx0LnN1Y2Nlc3MoewogICAgICBuYW1lOiAiZGl2IiwKICAgICAgYXR0cmlidXRlczogewogICAgICAgIGNsYXNzOiBbInhmYVJpY2giXSwKICAgICAgICBzdHlsZToge30KICAgICAgfSwKICAgICAgY2hpbGRyZW4KICAgIH0pOwogIH0KfQpjbGFzcyBJIGV4dGVuZHMgWGh0bWxPYmplY3QgewogIGNvbnN0cnVjdG9yKGF0dHJpYnV0ZXMpIHsKICAgIHN1cGVyKGF0dHJpYnV0ZXMsICJpIik7CiAgfQogIFtfeGZhX29iamVjdC4kcHVzaEdseXBoc10obWVhc3VyZSkgewogICAgbWVhc3VyZS5wdXNoRm9udCh7CiAgICAgIHBvc3R1cmU6ICJpdGFsaWMiCiAgICB9KTsKICAgIHN1cGVyW194ZmFfb2JqZWN0LiRwdXNoR2x5cGhzXShtZWFzdXJlKTsKICAgIG1lYXN1cmUucG9wRm9udCgpOwogIH0K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AgICAgIGxlbmd0aCA9IGJ1ZmZlci5sZW5ndGg7CiAgICBsZXQgcG9zaXRpb24gPSBzdHJlYW0uc3RhcnQ7CiAgICBjb25zdCB0cmFpbGVycyA9IFtdLAogICAgICB4cmVmU3RtcyA9IFtdOwogICAgd2hpbGUgKHBvc2l0aW9uIDwgbGVuZ3RoKSB7CiAgICAgIGxldCBjaCA9IGJ1ZmZlcltwb3NpdGlvbl07CiAgICAgIGlmIChjaCA9PT0gVEFCIHx8IGNoID09PSBMRiB8fCBjaCA9PT0gQ1IgfHwgY2ggPT09IFNQQUNFKSB7CiAgICAgICAgKytwb3NpdGlvbjsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBpZiAoY2ggPT09IFBFUkNFTlQpIHsKICAgICAgICBkbyB7CiAgICAgICAgICArK3Bvc2l0aW9uOwogICAgICAgICAgaWYgKHBvc2l0aW9uID49IGxlbmd0aCkgewogICAgICAgICAgICBicmVhazsKICAgICAgICAgIH0KICAgICAgICAgIGNoID0gYnVmZmVyW3Bvc2l0aW9uXTsKICAgICAgICB9IHdoaWxlIChjaCAhPT0gTEYgJiYgY2ggIT09IENSKTsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBjb25zdCB0b2tlbiA9IHJlYWRUb2tlbihidWZmZXIsIHBvc2l0aW9uKTsKICAgICAgbGV0IG07CiAgICAgIGlmICh0b2tlbi5zdGFydHNXaXRoKCJ4cmVmIikgJiYgKHRva2VuLmxlbmd0aCA9PT0gNCB8fCAvXHMvLnRlc3QodG9rZW5bNF0pKSkgewogICAgICAgIHBvc2l0aW9uICs9IHNraXBVbnRpbChidWZmZXIsIHBvc2l0aW9uLCB0cmFpbGVyQnl0ZXMpOwogICAgICAgIHRyYWlsZXJzLnB1c2gocG9zaXRpb24pOwogICAgICAgIHBvc2l0aW9uICs9IHNraXBVbnRpbChidWZmZXIsIHBvc2l0aW9uLCBzdGFydHhyZWZCeXRlcyk7CiAgICAgIH0gZWxzZSBpZiAobSA9IG9ialJlZ0V4cC5leGVjKHRva2VuKSkgewogICAgICAgIGNvbnN0IG51bSA9IG1bMV0gfCAwLAogICAgICAgICAgZ2VuID0gbVsyXSB8IDA7CiAgICAgICAgY29uc3Qgc3RhcnRQb3MgPSBwb3NpdGlvbiArIHRva2VuLmxlbmd0aDsKICAgICAgICBsZXQgY29udGVudExlbmd0aCwKICAgICAgICAgIHVwZGF0ZUVudHJpZXMgPSBmYWxzZTsKICAgICAgICBpZiAoIXRoaXMuZW50cmllc1tudW1dKSB7CiAgICAgICAgICB1cGRhdGVFbnRyaWVzID0gdHJ1ZTsKICAgICAgICB9IGVsc2UgaWYgKHRoaXMuZW50cmllc1tudW1dLmdlbiA9PT0gZ2VuKSB7CiAgICAgICAgICB0cnkgewogICAgICAgICAgICBjb25zdCBwYXJzZXIgPSBuZXcgX3BhcnNlci5QYXJzZXIoewogICAgICAgICAgICAgIGxleGVyOiBuZXcgX3BhcnNlci5MZXhlcihzdHJlYW0ubWFrZVN1YlN0cmVhbShzdGFydFBvcykpCiAgICAgICAgICAgIH0pOwogICAgICAgICAgICBwYXJzZXIuZ2V0T2JqKCk7CiAgICAgICAgICAgIHVwZGF0ZUVudHJpZXMgPSB0cnVlOwogICAgICAgICAgfSBjYXRjaCAoZXgpIHsKICAgICAgICAgICAgaWYgKGV4IGluc3RhbmNlb2YgX2NvcmVfdXRpbHMuUGFyc2VyRU9GRXhjZXB0aW9uKSB7CiAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKGBpbmRleE9iamVjdHMgLS0gY2hlY2tpbmcgb2JqZWN0ICgke3Rva2VufSk6ICIke2V4fSIuYCk7CiAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgdXBkYXRlRW50cmllcyA9IHRydWU7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgaWYgKHVwZGF0ZUVudHJpZXMpIHsKICAgICAgICAgIHRoaXMuZW50cmllc1tudW1dID0gewogICAgICAgICAgICBvZmZzZXQ6IHBvc2l0aW9uIC0gc3RyZWFtLnN0YXJ0LAogICAgICAgICAgICBnZW4sCiAgICAgICAgICAgIHVuY29tcHJlc3NlZDogdHJ1ZQogICAgICAgICAgfTsKICAgICAgICB9CiAgICAgICAgZ0VuZG9ialJlZ0V4cC5sYXN0SW5kZXggPSBzdGFydFBvczsKICAgICAgICBjb25zdCBtYXRjaCA9IGdFbmRvYmpSZWdFeHAuZXhlYyhidWZmZXJTdHIpOwogICAgICAgIGlmIChtYXRjaCkgewogICAgICAgICAgY29uc3QgZW5kUG9zID0gZ0VuZG9ialJlZ0V4cC5sYXN0SW5kZXggKyAxOwogICAgICAgICAgY29udGVudExlbmd0aCA9IGVuZFBvcyAtIHBvc2l0aW9uOwogICAgICAgICAgaWYgKG1hdGNoWzFdICE9PSAiZW5kb2JqIikgewogICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYGluZGV4T2JqZWN0czogRm91bmQgIiR7bWF0Y2hbMV19IiBpbnNpZGUgb2YgYW5vdGhlciAib2JqIiwgYCArICdjYXVzZWQgYnkgbWlzc2luZyAiZW5kb2JqIiAtLSB0cnlpbmcgdG8gcmVjb3Zlci4nKTsKICAgICAgICAgICAgY29udGVudExlbmd0aCAtPSBtYXRjaFsxXS5sZW5ndGggKyAxOwogICAgICAgICAgfQogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBjb250ZW50TGVuZ3RoID0gbGVuZ3RoIC0gcG9zaXRpb247CiAgICAgICAgfQogICAgICAgIGNvbnN0IGNvbnRlbnQgPSBidWZmZXIuc3ViYXJyYXkocG9zaXRpb24sIHBvc2l0aW9uICsgY29udGVudExlbmd0aCk7CiAgICAgICAgY29uc3QgeHJlZlRhZ09mZnNldCA9IHNraXBVbnRpbChjb250ZW50LCAwLCB4cmVmQnl0ZXMpOwogICAgICAgIGlmICh4cmVmVGFnT2Zmc2V0IDwgY29udGVudExlbmd0aCAmJiBjb250ZW50W3hyZWZUYWdPZmZzZXQgKyA1XS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ZGljdC5oYXMoIkVuY3J5cHQiKSkgewogICAgICAgIGlzRW5jcnlwdGVkID0gdHJ1ZTsKICAgICAgfQogICAgfQogICAgbGV0IHRyYWlsZXJEaWN0LCB0cmFpbGVyRXJyb3I7CiAgICBmb3IgKGNvbnN0IGRpY3Qgb2YgWy4uLnRyYWlsZXJEaWN0cywgImdlbkZhbGxiYWNrIiwgLi4udHJhaWxlckRpY3RzXSkgewogICAgICBpZiAoZGljdCA9PT0gImdlbkZhbGxiYWNrIikgewogICAgICAgIGlmICghdHJhaWxlckVycm9yKSB7CiAgICAgICAgICBicmVhazsKICAgICAgICB9CiAgICAgICAgdGhpcy5fZ2VuZXJhdGlvbkZhbGxiYWNrID0gdHJ1ZTsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBsZXQgdmFsaWRQYWdlc0RpY3QgPSBmYWxzZTsKICAgICAgdHJ5IHsKICAgICAgICBjb25zdCByb290RGljdCA9IGRpY3QuZ2V0KCJSb290Iik7CiAgICAgICAgaWYgKCEocm9vdERpY3QgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5EaWN0KSkgewogICAgICAgICAgY29udGludWU7CiAgICAgICAgfQogICAgICAgIGNvbnN0IHBhZ2VzRGljdCA9IHJvb3REaWN0LmdldCgiUGFnZXMiKTsKICAgICAgICBpZiAoIShwYWdlc0RpY3QgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5EaWN0KSkgewogICAgICAgICAgY29udGludWU7CiAgICAgICAgfQogICAgICAgIGNvbnN0IHBhZ2VzQ291bnQgPSBwYWdlc0RpY3QuZ2V0KCJDb3VudCIpOwogICAgICAgIGlmIChOdW1iZXIuaXNJbnRlZ2VyKHBhZ2VzQ291bnQpKSB7CiAgICAgICAgICB2YWxpZFBhZ2VzRGljdCA9IHRydWU7CiAgICAgICAgfQogICAgICB9IGNhdGNoIChleCkgewogICAgICAgIHRyYWlsZXJFcnJvciA9IGV4OwogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAg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RPYmooKSkgaW5zdGFuY2VvZiBfYmFzZV9zdHJlYW0uQmFzZVN0cmVhbSkpIHsKICAgICAgICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKCJJbnZhbGlkIFhSZWYgc3RyZWFtIik7CiAgICAgICAgICB9CiAgICAgICAgICBkaWN0ID0gdGhpcy5wcm9jZXNzWFJlZlN0cmVhbShvYmopOwogICAgICAgICAgaWYgKCF0aGlzLnRvcERpY3QpIHsKICAgICAgICAgICAgdGhpcy50b3BEaWN0ID0gZGljdDsKICAgICAgICAgIH0KICAgICAgICAgIGlmICghZGljdCkgewogICAgICAgICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoIkZhaWxlZCB0byByZWFkIFhSZWYgc3RyZWFtIik7CiAgICAgICAgICB9CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiSW52YWxpZCBYUmVmIHN0cmVhbSBoZWFkZXIiKTsKICAgICAgICB9CiAgICAgICAgb2JqID0gZGljdC5nZXQoIlByZXYiKTsKICAgICAgICBpZiAoTnVtYmVyLmlzSW50ZWdlcihvYmopKSB7CiAgICAgICAgICB0aGlzLnN0YXJ0WFJlZlF1ZXVlLnB1c2gob2JqKTsKICAgICAgICB9IGVsc2UgaWYgKG9iaiBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLlJlZikgewogICAgICAgICAgdGhpcy5zdGFydFhSZWZRdWV1ZS5wdXNoKG9iai5udW0pOwogICAgICAgIH0KICAgICAgfSBjYXRjaCAoZSkgewogICAgICAgIGlmIChlIGluc3RhbmNlb2YgX2NvcmVfdXRpbHMuTWlzc2luZ0RhdGFFeGNlcHRpb24pIHsKICAgICAgICAgIHRocm93IGU7CiAgICAgICAgfQogICAgICAgICgwLCBfdXRpbC5pbmZvKSgiKHdoaWxlIHJlYWRpbmcgWFJlZik6ICIgKyBlKTsKICAgICAgfQogICAgICB0aGlzLnN0YX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UiKTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuOwogICAgICB9CiAgICAgIGNvbnN0IGFjdGlvbiA9IHRoaXMuYWN0aW9uSGFuZGxlcltkYXRhLmFjdGlvbl07CiAgICAgIGlmICghYWN0aW9uKSB7CiAgICAgICAgdGhyb3cgbmV3IEVycm9yKGBVbmtub3duIGFjdGlvbiBmcm9tIHdvcmtlcjogJHtkYXRhLmFjdGlvbn1gKTsKICAgICAgfQogICAgICBpZiAoZGF0YS5jYWxsYmFja0lkKSB7CiAgICAgICAgY29uc3QgY2JTb3VyY2VOYW1lID0gdGhpcy5zb3VyY2VOYW1lOwogICAgICAgIGNvbnN0IGNiVGFyZ2V0TmFtZSA9IGRhdGEuc291cmNlTmFtZTsKICAgICAgICBuZXcgUHJvbWlzZShmdW5jdGlvbiAocmVzb2x2ZSkgewogICAgICAgICAgcmVzb2x2ZShhY3Rpb24oZGF0YS5kYXRhKSk7CiAgICAgICAgfSkudGhlbihmdW5jdGlvbiAocmVzdWx0KSB7CiAgICAgICAgICBjb21PYmoucG9zdE1lc3NhZ2UoewogICAgICAgICAgICBzb3VyY2VOYW1lOiBjYlNvdXJjZU5hbWUsCiAgICAgICAgICAgIHRhcmdldE5hbWU6IGNiVGFyZ2V0TmFtZSwKICAgICAgICAgICAgY2FsbGJhY2s6IENhbGxiYWNrS2luZC5EQVRBLAogICAgICAgICAgICBjYWxsYmFja0lkOiBkYXRhLmNhbGxiYWNrSWQsCiAgICAgICAgICAgIGRhdGE6IHJlc3VsdAogICAgICAgICAgfSk7CiAgICAgICAgfSwgZnVuY3Rpb24gKHJlYXNvbikgewogICAgICAgICAgY29tT2JqLnBvc3RNZXNzYWdlKHsKICAgICAgICAgICAgc291cmNlTmFtZTogY2JTb3VyY2VOYW1lLAogICAgICAgICAgICB0YXJnZXROYW1lOiBjYlRhcmdldE5hbWUsCiAgICAgICAgICAgIGNhbGxiYWNrOiBDYWxsYmFja0tpbmQuRVJST1IsCiAgICAgICAgICAgIGNhb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HksCiAgICAgICAgICBwdWxsQ2FsbDogbnVsbCwKICAgICAgICAgIGNhbmNlbENhbGw6IG51bGwsCiAgICAgICAgICBpc0Nsb3NlZDogZmFsc2UKICAgICAgICB9OwogICAgICAgIGNvbU9iai5wb3N0TWVzc2FnZSh7CiAgICAgICAgICBzb3VyY2VOYW1lLAogICAgICAgICAgdGFyZ2V0TmFtZSwKICAgICAgICAgIGFjdGlvbjogYWN0aW9uTmFtZSwKICAgICAgICAgIHN0cmVhbUlkLAogICAgICAgICAgZGF0YSwKICAgICAgICAgIGRlc2lyZWRTaXplOiBjb250cm9sbGVyLmRlc2lyZWRTaXplCiAgICAgICAgfSwgdHJhbnNmZXJzKTsKICAgICAgICByZXR1cm4gc3RhcnRDYXBhYmlsaXR5LnByb21pc2U7CiAgICAgIH0sCiAgICAgIHB1bGw6IGNvbnRyb2xsZXIgPT4gewogICAgICAgIGNvbnN0IHB1bGxDYXBhYmlsaXR5ID0gKDAsIF91dGlsLmNyZWF0ZVByb21pc2VDYXBhYmlsaXR5KSgpOwogICAgICAgIHRoaXMuc3RyZWFtQ29udHJvbGxlcnNbc3RyZWFtSWRdLnB1bGxDYWxsID0gcHVsbENhcGFiaWxpdHk7CiAgICAgICAgY29tT2JqLnBvc3RNZXNzYWdlKHsKICAgICAgICAgIHNvdXJjZU5hbWUsCiAgICAgICAgICB0YXJnZXROYW1lLAogICAgICAgICAgc3RyZWFtOiBTdHJlYW1LaW5kLlBVTEwsCiAgICAgICAgICBzdHJlYW1JZCwKICAgICAgICAgIGRlc2lyZWRTaXplOiBjb250cm9sbGVyLmRlc2lyZWRTaXplCiAgICAgICAgfSk7CiAgICAgICAgcmV0dXJuIHB1bGxDYXBhYmlsaXR5LnByb21pc2U7CiAgICAgIH0sCiAgICAgIGNhbmNlbDogcmVhc29uID0+IHsKICAgICAgICAoMCwgX3V0aWwuYXNzZXJ0KShyZWFzb24gaW5zdGFuY2VvZiBFcnJvciwgImNhbmNlbCBtdXN0IGhhdmUgYSB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yZ3VtZW50c1sxXSA6IDE7CiAgICAgICAgbGV0IHRyYW5zZmVycyA9IGFyZ3VtZW50cy5sZW5ndGggPiAyID8gYXJndW1lbnRzWzJdIDogdW5kZWZpbmVkOwogICAgICAgIGlmICh0aGlzLmlzQ2FuY2VsbGVkKSB7CiAgICAgICAgICByZXR1cm47CiAgICAgICAgfQogICAgICAgIGNvbnN0IGxhc3REZXNpcmVkU2l6ZSA9IHRoaXMuZGVzaXJlZFNpemU7CiAgICAgICAgdGhpcy5kZXNpcmVkU2l6ZSAtPSBzaXplOwogICAgICAgIGlmIChsYXN0RGVzaXJlZFNpemUgPiAwICYmIHRoaXMuZGVzaXJlZFNpemUgPD0gMCkgewogICAgICAgICAgdGhpcy5zaW5rQ2FwYWJpbGl0eSA9ICgwLCBfdXRpbC5jcmVhdGVQcm9taXNlQ2FwYWJpbGl0eSkoKTsKICAgICAgICAgIHRoaXMucmVhZHkgPSB0aGlzLnNpbmtDYXBhYmlsaXR5LnByb21pc2U7CiAgICAgICAgfQogICAgICAgIGNvbU9iai5wb3N0TWVzc2FnZSh7CiAgICAgICAgICBzb3VyY2VOYW1lLAogICAgICAgICAgdGFyZ2V0TmFtZSwKICAgICAgICAgIHN0cmVhbTogU3RyZWFtS2luZC5FTlFVRVVFLAogICAgICAgICAgc3RyZWFtSWQsCiAgICAgICAgICBjaHVuawogICAgICAgIH0sIHRyYW5zZmVycyk7CiAgICAgIH0sCiAgICAgIGNsb3NlKCkgewogICAgICAgIGlmICh0aGlzLmlzQ2FuY2VsbGVkKSB7CiAgICAgICAgICByZXR1cm47CiAgICAgICAgfQogICAgICAgIHRoaXMuaXNDYW5jZWxsZWQgPSB0cnVlOwogICAgICAgIGNvbU9iai5wb3N0TWVzc2FnZSh7CiAgICAgICAgICBzb3VyY2VOYW1lLAogICAgICAgICAgdGFyZ2V0TmFtZSwKICAgICAgICAgIHN0cmVhbTogU3RyZWFtS2luZC5DTE9TRSwKICAgICAgICAgIHN0cmVhbUlkCiAgICA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sbC5yZXNvbHZlKCk7CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIHN0cmVhbUNvbnRyb2xsZXIuc3RhcnRDYWxsLnJlamVjdCh3cmFwUmVhc29uKGRhdGEucmVhc29uKSk7CiAgICAgICAgfQogICAgICAgIGJyZWFrOwogICAgICBjYXNlIFN0cmVhbUtpbmQuUFVMTF9DT01QTEVURToKICAgICAgICBpZiAoZGF0YS5zdWNjZXNzKSB7CiAgICAgICAgICBzdHJlYW1Db250cm9sbGVyLnB1bGxDYWxsLnJlc29sdmUoKTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgc3RyZWFtQ29udHJvbGxlci5wdWxsQ2FsbC5yZWplY3Qod3JhcFJlYXNvbihkYXRhLnJlYXNvbikpOwogICAgICAgIH0KICAgICAgICBicmVhazsKICAgICAgY2FzZSBTdHJlYW1LaW5kLlBVTEw6CiAgICAgICAgaWYgKCFzdHJlYW1TaW5rKSB7CiAgICAgICAgICBjb21PYmoucG9zdE1lc3NhZ2UoewogICAgICAgICAgICBzb3VyY2VOYW1lLAogICAgICAgICAgICB0YXJnZXROYW1lLAogICAgICAgICAgICBzdHJlYW06IFN0cmVhbUtpbmQuUFVMTF9DT01QTEVURSwKICAgICAgICAgICAgc3RyZWFtSWQsCiAgICAgICAgICAgIHN1Y2Nlc3M6IHRydWUKICAgICAgICAgIH0pOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICAgIGlmIChzdHJlYW1TaW5rLmRlc2lyZWRTaXplIDw9IDAgJiYgZGF0YS5kZXNpcmVkU2l6ZSA+IDApIHsKICAgICAgICAgIHN0cmVhbVNpbmsuc2lua0NhcGFiaWxpdHkucmVzb2x2ZSgpOwogICAgICAgIH0KICAgICAgICBzdHJlYW1TaW5rLmRlc2lyZWRTaXplID0gZGF0YS5kZXNpcmVkU2l6ZTsKICAgICAgICBuZXcgUHJvbWlzZShmdW5jdGlvbiAocmVzb2x2ZSkgewogICAgICAgICAgcmVzb2x2ZShzdHJlYW1TaW5rLm9uUHVsbCAmJiBzdHJlYW1TaW5rLm9uUHVsbCgpKTsKICAgICAgICB9KS50aGVuKGZ1bmN0aW9uICgpIHsKICAgICAgICAgIGNvbU9iai5wb3N0TWVzc2FnZSh7CiAgICAgICAgICAgIHNvdXJjZU5hbWUsCiAgICAgICAgICAgIHRhcmdldE5hbWUsCiAgICAgICAgICAgIHN0cmVhbTogU3RyZWFtS2luZC5QVUxMX0NPTVBMRVRFLAogICAgICAgICAgICBzdHJlYW1JZCwKICAgICAgICAgICAgc3VjY2VzczogdHJ1ZQogICAgICAgICAgfSk7CiAgICAgICAgfSwgZnVuY3Rpb24gKHJlYXNvbikgewogICAgICAgICAgY29tT2JqLnBvc3RNZXNzYWdlKHsKICAgICAgICAgICAgc291cmNlTmFtZSwKICAgICAgICAgICAgdGFyZ2V0TmFtZSwKICAgICAgICAgICAgc3RyZWFtOiBTdHJlYW1LaW5kLlBVTExfQ09NUExFVEUsCiAgICAgICAgICAgIHN0cmVhbUlkLAogICAgICAgICAgICByZWFzb246IHdyYXBSZWFzb24ocmVhc29uKQogICAgICAgICAgfSk7CiAgICAgICAgfSk7CiAgICAgICAgYnJlYWs7CiAgICAgIGNhc2UgU3RyZWFtS2luZC5FTlFVRVVFOgogICAgICAgICgwLCBfdXRpbC5hc3NlcnQpKHN0cmVhbUNvbnRyb2xsZXIsICJlbnF1ZXVlIHNob3VsZCBoYXZlIHN0cmVhbSBjb250cm9sbGVyIik7CiAgICAgICAgaWYgKHN0cmVhbUNvbnRyb2xsZXIuaXNDbG9zZWQpIHsKICAgICAgICAgIGJyZWFrOwogICAgICAgIH0KICAgICAgICBzdHJlYW1Db250cm9sbGVyLmNvbnRyb2xsZXIuZW5xdWV1ZShkYXRhLmNodW5rKTsKICAgICAgICBicmVhazsKICAgICAgY2FzZSBTdHJlYW1LaW5kLkNMT1NFOgogICAgICAgICgwLCBfdXRpbC5hc3NlcnQpKHN0cmVhbUNvbnRyb2xsZXIsICJjbG9zZSBzaG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2FzZSBTdHJlYW1LaW5kLkNBTkNFTDoKICAgICAgICBpZiAoIXN0cmVhbVNpbmspIHsKICAgICAgICAgIGJyZWFrOwogICAgICAgIH0KICAgICAgICBuZXcgUHJvbWlzZShmdW5jdGlvbiAocmVzb2x2ZSkgewogICAgICAgICAgcmVzb2x2ZShzdHJlYW1TaW5rLm9uQ2FuY2VsICYmIHN0cmVhbVNpbmsub25DYW5jZWwod3JhcFJlYXNvbihkYXRhLnJlYXNvbikpKTsKICAgICAgICB9KS50aGVuKGZ1bmN0aW9uICgpIHsKICAgICAgICAgIGNvbU9iai5wb3N0TWVzc2FnZSh7CiAgICAgICAgICAgIHNvdXJjZU5hbWUsCiAgICAgICAgICAgIHRhcmdldE5hbWUsCiAgICAgICAgICAgIHN0cmVhbTogU3RyZWFtS2luZC5DQU5DRUxfQ09NUExFVEUsCiAgICAgICAgICAgIHN0cmVhbUlkLAogICAgICAgICAgICBzdWNjZXNzOiB0cnVlCiAgICAgICAgICB9KTsKICAgICAgICB9LCBmdW5jdGlvbiAocmVhc29uKSB7CiAgICAgICAgICBjb21PYmoucG9zdE1lc3NhZ2UoewogICAgICAgICAgICBzb3VyY2VOYW1lLAogICAgICAgICAgICB0YXJnZXROYW1lLAogICAgICAgICAgICBzdHJlYW06IFN0cmVhbUtpbmQuQ0FOQ0VMX0NPTVBMRVRFLAogICAgICAgICAgICBzdHJlYW1JZCwKICAgICAgICAgICAgcmVhc29uOiB3cmFwUmVhc29uKHJlYXNvbikKICAgICAgICAgIH0pOwogICAgICAgIH0pOwogICAgICAgIHN0cmVhbVNpbmsuc2lua0NhcGFiaWxpdHkucmVqZWN0KHdyYXBSZWFzb24oZGF0YS5yZWFzb24pKTsKICAgICAgICBzdHJlYW1TaW5rLmlzQ2FuY2VsbGVkID0gdHJ1ZTsKICAgICAgICBkZWxldGUgdGhpcy5zdHJlYW1TaW5rc1tzdHJlYW1JZF07CiAgICAgICAgYnJlYWs7CiAgICAgIGRlZmF1bHQ6CiAgICAg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19leHBvcnRzX18gPSB7fTsKLy8gVGhpcyBlbnRyeSBuZWVkIHRvIGJlIHdyYXBwZWQgaW4gYW4gSUlGRSBiZWNhdXNlIGl0IG5lZWQgdG8gYmUgaW4gc3RyaWN0IG1vZGUuCigoKSA9PiB7CiJ1c2Ugc3RyaWN0IjsKdmFyIGV4cG9ydHMgPSBfX3dlYnBhY2tfZXhwb3J0c19fOwoKCk9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAiX19lc01vZHVsZSIsICh7CiAgdmFsdWU6IHRydWUKfSkpOwpPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIldvcmtlck1lc3NhZ2VIYW5kbGVyIiwgKHsKICBlbnVtZXJhYmxlOiB0cnVlLAogIGdldDogZnVuY3Rpb24gKCkgewogICAgcmV0dXJuIF93b3JrZXIuV29ya2VyTWVzc2FnZUhhbmRsZXI7CiAgfQp9KSk7CnZhciBfd29ya2VyID0gX193X3BkZmpzX3JlcXVpcmVfXygxKTsKY29uc3QgcGRmanNWZXJzaW9uID0gJzMuNS4xMjInOwpjb25zdCBwZGZqc0J1aWxkID0gJzYyMjQ2NWRjMic7Cn0pKCk7CgovKioqKioqLyAJcmV0dXJuIF9fd2VicGFja19leHBvcnRzX187Ci8qKioqKiovIH0pKCkKOwp9KTsKLy8jIHNvdXJjZU1hcHBpbmdVUkw9cGRmLndvcmtlci5qcy5tYXA=",window.pdfjsLib.getDocument(this.pdf).promise.then((async g=>{this.pdfDoc=g,this.total=g.numPages,this.onLoad&&this.onLoad({success:!0,data:this.pdfDoc});for(let I=1;I<=this.total;I++)await this.getPdfPage(I)}))})).catch((g=>{this.onError&&this.onError({success:!1,data:g,message:g})}))})),C(this,"prevPage",(()=>{this.pageNumber>1?this.pageNumber-=1:this.pageNumber=1,this.getPdfPage(this.pageNumber)})),C(this,"nextPage",(()=>{this.pageNumber{try{if("undefined"!=typeof window){const C=await(g=>new Promise(((I,C)=>{const A=new FileReader;A.readAsDataURL(g),A.onload=()=>{I(A.result)},A.onerror=g=>{C(g)},A.onabort=g=>{C(g)}})))(g);if(C){new jA(C,I).pdfPreview()}}}catch(C){}}},Symbol.toStringTag,{value:"Module"}));var EA={exports:{}}; /** * @license * Lodash * Copyright OpenJS Foundation and other contributors * Released under MIT license * Based on Underscore.js 1.8.3 * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors */!function(g,I){(function(){var C,A="Expected a function",i="__lodash_hash_undefined__",e="__lodash_placeholder__",l=16,t=32,s=64,c=128,d=256,o=1/0,n=9007199254740991,a=NaN,Z=4294967295,b=[["ary",c],["bind",1],["bindKey",2],["curry",8],["curryRight",l],["flip",512],["partial",t],["partialRight",s],["rearg",d]],r="[object Arguments]",m="[object Array]",h="[object Boolean]",G="[object Date]",u="[object Error]",B="[object Function]",w="[object GeneratorFunction]",W="[object Map]",p="[object Number]",V="[object Object]",y="[object Promise]",X="[object RegExp]",Y="[object Set]",R="[object String]",N="[object Symbol]",H="[object WeakMap]",K="[object ArrayBuffer]",F="[object DataView]",M="[object Float32Array]",J="[object Float64Array]",S="[object Int8Array]",f="[object Int16Array]",k="[object Int32Array]",D="[object Uint8Array]",L="[object Uint8ClampedArray]",z="[object Uint16Array]",v="[object Uint32Array]",T=/\b__p \+= '';/g,x=/\b(__p \+=) '' \+/g,U=/(__e\(.*?\)|\b__t\)) \+\n'';/g,Q=/&(?:amp|lt|gt|quot|#39);/g,j=/[&<>"']/g,O=RegExp(Q.source),E=RegExp(j.source),P=/<%-([\s\S]+?)%>/g,_=/<%([\s\S]+?)%>/g,q=/<%=([\s\S]+?)%>/g,$=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,gg=/^\w*$/,Ig=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Cg=/[\\^$.*+?()[\]{}|]/g,Ag=RegExp(Cg.source),ig=/^\s+/,eg=/\s/,lg=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,tg=/\{\n\/\* \[wrapped with (.+)\] \*/,sg=/,? & /,cg=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,dg=/[()=,{}\[\]\/\s]/,og=/\\(\\)?/g,ng=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,ag=/\w*$/,Zg=/^[-+]0x[0-9a-f]+$/i,bg=/^0b[01]+$/i,rg=/^\[object .+?Constructor\]$/,mg=/^0o[0-7]+$/i,hg=/^(?:0|[1-9]\d*)$/,Gg=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,ug=/($^)/,Bg=/['\n\r\u2028\u2029\\]/g,wg="\\ud800-\\udfff",Wg="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff",pg="\\u2700-\\u27bf",Vg="a-z\\xdf-\\xf6\\xf8-\\xff",yg="A-Z\\xc0-\\xd6\\xd8-\\xde",Xg="\\ufe0e\\ufe0f",Yg="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",Rg="['’]",Ng="["+wg+"]",Hg="["+Yg+"]",Kg="["+Wg+"]",Fg="\\d+",Mg="["+pg+"]",Jg="["+Vg+"]",Sg="[^"+wg+Yg+Fg+pg+Vg+yg+"]",fg="\\ud83c[\\udffb-\\udfff]",kg="[^"+wg+"]",Dg="(?:\\ud83c[\\udde6-\\uddff]){2}",Lg="[\\ud800-\\udbff][\\udc00-\\udfff]",zg="["+yg+"]",vg="\\u200d",Tg="(?:"+Jg+"|"+Sg+")",xg="(?:"+zg+"|"+Sg+")",Ug="(?:['’](?:d|ll|m|re|s|t|ve))?",Qg="(?:['’](?:D|LL|M|RE|S|T|VE))?",jg="(?:"+Kg+"|"+fg+")"+"?",Og="["+Xg+"]?",Eg=Og+jg+("(?:"+vg+"(?:"+[kg,Dg,Lg].join("|")+")"+Og+jg+")*"),Pg="(?:"+[Mg,Dg,Lg].join("|")+")"+Eg,_g="(?:"+[kg+Kg+"?",Kg,Dg,Lg,Ng].join("|")+")",qg=RegExp(Rg,"g"),$g=RegExp(Kg,"g"),gI=RegExp(fg+"(?="+fg+")|"+_g+Eg,"g"),II=RegExp([zg+"?"+Jg+"+"+Ug+"(?="+[Hg,zg,"$"].join("|")+")",xg+"+"+Qg+"(?="+[Hg,zg+Tg,"$"].join("|")+")",zg+"?"+Tg+"+"+Ug,zg+"+"+Qg,"\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Fg,Pg].join("|"),"g"),CI=RegExp("["+vg+wg+Wg+Xg+"]"),AI=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,iI=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],eI=-1,lI={};lI[M]=lI[J]=lI[S]=lI[f]=lI[k]=lI[D]=lI[L]=lI[z]=lI[v]=!0,lI[r]=lI[m]=lI[K]=lI[h]=lI[F]=lI[G]=lI[u]=lI[B]=lI[W]=lI[p]=lI[V]=lI[X]=lI[Y]=lI[R]=lI[H]=!1;var tI={};tI[r]=tI[m]=tI[K]=tI[F]=tI[h]=tI[G]=tI[M]=tI[J]=tI[S]=tI[f]=tI[k]=tI[W]=tI[p]=tI[V]=tI[X]=tI[Y]=tI[R]=tI[N]=tI[D]=tI[L]=tI[z]=tI[v]=!0,tI[u]=tI[B]=tI[H]=!1;var sI={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},cI=parseFloat,dI=parseInt,oI="object"==typeof EI&&EI&&EI.Object===Object&&EI,nI="object"==typeof self&&self&&self.Object===Object&&self,aI=oI||nI||Function("return this")(),ZI=I&&!I.nodeType&&I,bI=ZI&&g&&!g.nodeType&&g,rI=bI&&bI.exports===ZI,mI=rI&&oI.process,hI=function(){try{var g=bI&&bI.require&&bI.require("util").types;return g||mI&&mI.binding&&mI.binding("util")}catch(I){}}(),GI=hI&&hI.isArrayBuffer,uI=hI&&hI.isDate,BI=hI&&hI.isMap,wI=hI&&hI.isRegExp,WI=hI&&hI.isSet,pI=hI&&hI.isTypedArray;function VI(g,I,C){switch(C.length){case 0:return g.call(I);case 1:return g.call(I,C[0]);case 2:return g.call(I,C[0],C[1]);case 3:return g.call(I,C[0],C[1],C[2])}return g.apply(I,C)}function yI(g,I,C,A){for(var i=-1,e=null==g?0:g.length;++i-1}function KI(g,I,C){for(var A=-1,i=null==g?0:g.length;++A-1;);return C}function CC(g,I){for(var C=g.length;C--&&zI(I,g[C],0)>-1;);return C}var AC=QI({"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","Ç":"C","ç":"c","Ð":"D","ð":"d","È":"E","É":"E","Ê":"E","Ë":"E","è":"e","é":"e","ê":"e","ë":"e","Ì":"I","Í":"I","Î":"I","Ï":"I","ì":"i","í":"i","î":"i","ï":"i","Ñ":"N","ñ":"n","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","Ù":"U","Ú":"U","Û":"U","Ü":"U","ù":"u","ú":"u","û":"u","ü":"u","Ý":"Y","ý":"y","ÿ":"y","Æ":"Ae","æ":"ae","Þ":"Th","þ":"th","ß":"ss","Ā":"A","Ă":"A","Ą":"A","ā":"a","ă":"a","ą":"a","Ć":"C","Ĉ":"C","Ċ":"C","Č":"C","ć":"c","ĉ":"c","ċ":"c","č":"c","Ď":"D","Đ":"D","ď":"d","đ":"d","Ē":"E","Ĕ":"E","Ė":"E","Ę":"E","Ě":"E","ē":"e","ĕ":"e","ė":"e","ę":"e","ě":"e","Ĝ":"G","Ğ":"G","Ġ":"G","Ģ":"G","ĝ":"g","ğ":"g","ġ":"g","ģ":"g","Ĥ":"H","Ħ":"H","ĥ":"h","ħ":"h","Ĩ":"I","Ī":"I","Ĭ":"I","Į":"I","İ":"I","ĩ":"i","ī":"i","ĭ":"i","į":"i","ı":"i","Ĵ":"J","ĵ":"j","Ķ":"K","ķ":"k","ĸ":"k","Ĺ":"L","Ļ":"L","Ľ":"L","Ŀ":"L","Ł":"L","ĺ":"l","ļ":"l","ľ":"l","ŀ":"l","ł":"l","Ń":"N","Ņ":"N","Ň":"N","Ŋ":"N","ń":"n","ņ":"n","ň":"n","ŋ":"n","Ō":"O","Ŏ":"O","Ő":"O","ō":"o","ŏ":"o","ő":"o","Ŕ":"R","Ŗ":"R","Ř":"R","ŕ":"r","ŗ":"r","ř":"r","Ś":"S","Ŝ":"S","Ş":"S","Š":"S","ś":"s","ŝ":"s","ş":"s","š":"s","Ţ":"T","Ť":"T","Ŧ":"T","ţ":"t","ť":"t","ŧ":"t","Ũ":"U","Ū":"U","Ŭ":"U","Ů":"U","Ű":"U","Ų":"U","ũ":"u","ū":"u","ŭ":"u","ů":"u","ű":"u","ų":"u","Ŵ":"W","ŵ":"w","Ŷ":"Y","ŷ":"y","Ÿ":"Y","Ź":"Z","Ż":"Z","Ž":"Z","ź":"z","ż":"z","ž":"z","IJ":"IJ","ij":"ij","Œ":"Oe","œ":"oe","ʼn":"'n","ſ":"s"}),iC=QI({"&":"&","<":"<",">":">",'"':""","'":"'"});function eC(g){return"\\"+sI[g]}function lC(g){return CI.test(g)}function tC(g){var I=-1,C=Array(g.size);return g.forEach((function(g,A){C[++I]=[A,g]})),C}function sC(g,I){return function(C){return g(I(C))}}function cC(g,I){for(var C=-1,A=g.length,i=0,l=[];++C",""":'"',"'":"'"});var bC=function g(I){var eg,wg=(I=null==I?aI:bC.defaults(aI.Object(),I,bC.pick(aI,iI))).Array,Wg=I.Date,pg=I.Error,Vg=I.Function,yg=I.Math,Xg=I.Object,Yg=I.RegExp,Rg=I.String,Ng=I.TypeError,Hg=wg.prototype,Kg=Vg.prototype,Fg=Xg.prototype,Mg=I["__core-js_shared__"],Jg=Kg.toString,Sg=Fg.hasOwnProperty,fg=0,kg=(eg=/[^.]+$/.exec(Mg&&Mg.keys&&Mg.keys.IE_PROTO||""))?"Symbol(src)_1."+eg:"",Dg=Fg.toString,Lg=Jg.call(Xg),zg=aI._,vg=Yg("^"+Jg.call(Sg).replace(Cg,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Tg=rI?I.Buffer:C,xg=I.Symbol,Ug=I.Uint8Array,Qg=Tg?Tg.allocUnsafe:C,jg=sC(Xg.getPrototypeOf,Xg),Og=Xg.create,Eg=Fg.propertyIsEnumerable,Pg=Hg.splice,_g=xg?xg.isConcatSpreadable:C,gI=xg?xg.iterator:C,CI=xg?xg.toStringTag:C,sI=function(){try{var g=de(Xg,"defineProperty");return g({},"",{}),g}catch(I){}}(),oI=I.clearTimeout!==aI.clearTimeout&&I.clearTimeout,nI=Wg&&Wg.now!==aI.Date.now&&Wg.now,ZI=I.setTimeout!==aI.setTimeout&&I.setTimeout,bI=yg.ceil,mI=yg.floor,hI=Xg.getOwnPropertySymbols,kI=Tg?Tg.isBuffer:C,QI=I.isFinite,EI=Hg.join,rC=sC(Xg.keys,Xg),mC=yg.max,hC=yg.min,GC=Wg.now,uC=I.parseInt,BC=yg.random,wC=Hg.reverse,WC=de(I,"DataView"),pC=de(I,"Map"),VC=de(I,"Promise"),yC=de(I,"Set"),XC=de(I,"WeakMap"),YC=de(Xg,"create"),RC=XC&&new XC,NC={},HC=De(WC),KC=De(pC),FC=De(VC),MC=De(yC),JC=De(XC),SC=xg?xg.prototype:C,fC=SC?SC.valueOf:C,kC=SC?SC.toString:C;function DC(g){if(Ct(g)&&!Ul(g)&&!(g instanceof TC)){if(g instanceof vC)return g;if(Sg.call(g,"__wrapped__"))return Le(g)}return new vC(g)}var LC=function(){function g(){}return function(I){if(!It(I))return{};if(Og)return Og(I);g.prototype=I;var A=new g;return g.prototype=C,A}}();function zC(){}function vC(g,I){this.__wrapped__=g,this.__actions__=[],this.__chain__=!!I,this.__index__=0,this.__values__=C}function TC(g){this.__wrapped__=g,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=Z,this.__views__=[]}function xC(g){var I=-1,C=null==g?0:g.length;for(this.clear();++I=I?g:I)),g}function tA(g,I,A,i,e,l){var t,s=1&I,c=2&I,d=4&I;if(A&&(t=e?A(g,i,e,l):A(g)),t!==C)return t;if(!It(g))return g;var o=Ul(g);if(o){if(t=function(g){var I=g.length,C=new g.constructor(I);I&&"string"==typeof g[0]&&Sg.call(g,"index")&&(C.index=g.index,C.input=g.input);return C}(g),!s)return Yi(g,t)}else{var n=ae(g),a=n==B||n==w;if(El(g))return wi(g,s);if(n==V||n==r||a&&!e){if(t=c||a?{}:be(g),!s)return c?function(g,I){return Ri(g,ne(g),I)}(g,function(g,I){return g&&Ri(I,Ft(I),g)}(t,g)):function(g,I){return Ri(g,oe(g),I)}(g,AA(t,g))}else{if(!tI[n])return e?g:{};t=function(g,I,C){var A=g.constructor;switch(I){case K:return Wi(g);case h:case G:return new A(+g);case F:return function(g,I){var C=I?Wi(g.buffer):g.buffer;return new g.constructor(C,g.byteOffset,g.byteLength)}(g,C);case M:case J:case S:case f:case k:case D:case L:case z:case v:return pi(g,C);case W:return new A;case p:case R:return new A(g);case X:return function(g){var I=new g.constructor(g.source,ag.exec(g));return I.lastIndex=g.lastIndex,I}(g);case Y:return new A;case N:return i=g,fC?Xg(fC.call(i)):{}}var i}(g,n,s)}}l||(l=new OC);var Z=l.get(g);if(Z)return Z;l.set(g,t),tt(g)?g.forEach((function(C){t.add(tA(C,I,A,C,g,l))})):At(g)&&g.forEach((function(C,i){t.set(i,tA(C,I,A,i,g,l))}));var b=o?C:(d?c?Ae:Ce:c?Ft:Kt)(g);return XI(b||g,(function(C,i){b&&(C=g[i=C]),gA(t,i,tA(C,I,A,i,g,l))})),t}function sA(g,I,A){var i=A.length;if(null==g)return!i;for(g=Xg(g);i--;){var e=A[i],l=I[e],t=g[e];if(t===C&&!(e in g)||!l(t))return!1}return!0}function cA(g,I,i){if("function"!=typeof g)throw new Ng(A);return Re((function(){g.apply(C,i)}),I)}function dA(g,I,C,A){var i=-1,e=HI,l=!0,t=g.length,s=[],c=I.length;if(!t)return s;C&&(I=FI(I,qI(C))),A?(e=KI,l=!1):I.length>=200&&(e=gC,l=!1,I=new jC(I));g:for(;++i-1},UC.prototype.set=function(g,I){var C=this.__data__,A=IA(C,g);return A<0?(++this.size,C.push([g,I])):C[A][1]=I,this},QC.prototype.clear=function(){this.size=0,this.__data__={hash:new xC,map:new(pC||UC),string:new xC}},QC.prototype.delete=function(g){var I=se(this,g).delete(g);return this.size-=I?1:0,I},QC.prototype.get=function(g){return se(this,g).get(g)},QC.prototype.has=function(g){return se(this,g).has(g)},QC.prototype.set=function(g,I){var C=se(this,g),A=C.size;return C.set(g,I),this.size+=C.size==A?0:1,this},jC.prototype.add=jC.prototype.push=function(g){return this.__data__.set(g,i),this},jC.prototype.has=function(g){return this.__data__.has(g)},OC.prototype.clear=function(){this.__data__=new UC,this.size=0},OC.prototype.delete=function(g){var I=this.__data__,C=I.delete(g);return this.size=I.size,C},OC.prototype.get=function(g){return this.__data__.get(g)},OC.prototype.has=function(g){return this.__data__.has(g)},OC.prototype.set=function(g,I){var C=this.__data__;if(C instanceof UC){var A=C.__data__;if(!pC||A.length<199)return A.push([g,I]),this.size=++C.size,this;C=this.__data__=new QC(A)}return C.set(g,I),this.size=C.size,this};var oA=Ki(GA),nA=Ki(uA,!0);function aA(g,I){var C=!0;return oA(g,(function(g,A,i){return C=!!I(g,A,i)})),C}function ZA(g,I,A){for(var i=-1,e=g.length;++i0&&C(t)?I>1?rA(t,I-1,C,A,i):MI(i,t):A||(i[i.length]=t)}return i}var mA=Fi(),hA=Fi(!0);function GA(g,I){return g&&mA(g,I,Kt)}function uA(g,I){return g&&hA(g,I,Kt)}function BA(g,I){return NI(I,(function(I){return ql(g[I])}))}function wA(g,I){for(var A=0,i=(I=hi(I,g)).length;null!=g&&AI}function yA(g,I){return null!=g&&Sg.call(g,I)}function XA(g,I){return null!=g&&I in Xg(g)}function YA(g,I,A){for(var i=A?KI:HI,e=g[0].length,l=g.length,t=l,s=wg(l),c=1/0,d=[];t--;){var o=g[t];t&&I&&(o=FI(o,qI(I))),c=hC(o.length,c),s[t]=!A&&(I||e>=120&&o.length>=120)?new jC(t&&o):C}o=g[0];var n=-1,a=s[0];g:for(;++n=t?s:s*("desc"==C[A]?-1:1)}return g.index-I.index}(g,I,C)}))}function xA(g,I,C){for(var A=-1,i=I.length,e={};++A-1;)t!==g&&Pg.call(t,s,1),Pg.call(g,s,1);return g}function QA(g,I){for(var C=g?I.length:0,A=C-1;C--;){var i=I[C];if(C==A||i!==e){var e=i;me(i)?Pg.call(g,i,1):di(g,i)}}return g}function jA(g,I){return g+mI(BC()*(I-g+1))}function OA(g,I){var C="";if(!g||I<1||I>n)return C;do{I%2&&(C+=g),(I=mI(I/2))&&(g+=g)}while(I);return C}function EA(g,I){return Ne(Ve(g,I,is),g+"")}function PA(g){return PC(zt(g))}function _A(g,I){var C=zt(g);return Fe(C,lA(I,0,C.length))}function qA(g,I,A,i){if(!It(g))return g;for(var e=-1,l=(I=hi(I,g)).length,t=l-1,s=g;null!=s&&++ei?0:i+I),(C=C>i?i:C)<0&&(C+=i),i=I>C?0:C-I>>>0,I>>>=0;for(var e=wg(i);++A>>1,l=g[e];null!==l&&!ct(l)&&(C?l<=I:l=200){var c=I?null:Oi(g);if(c)return dC(c);l=!1,i=gC,s=new jC}else s=I?[]:t;g:for(;++A=i?g:Ci(g,I,A)}var Bi=oI||function(g){return aI.clearTimeout(g)};function wi(g,I){if(I)return g.slice();var C=g.length,A=Qg?Qg(C):new g.constructor(C);return g.copy(A),A}function Wi(g){var I=new g.constructor(g.byteLength);return new Ug(I).set(new Ug(g)),I}function pi(g,I){var C=I?Wi(g.buffer):g.buffer;return new g.constructor(C,g.byteOffset,g.length)}function Vi(g,I){if(g!==I){var A=g!==C,i=null===g,e=g==g,l=ct(g),t=I!==C,s=null===I,c=I==I,d=ct(I);if(!s&&!d&&!l&&g>I||l&&t&&c&&!s&&!d||i&&t&&c||!A&&c||!e)return 1;if(!i&&!l&&!d&&g1?A[e-1]:C,t=e>2?A[2]:C;for(l=g.length>3&&"function"==typeof l?(e--,l):C,t&&he(A[0],A[1],t)&&(l=e<3?C:l,e=1),I=Xg(I);++i-1?e[l?I[t]:t]:C}}function ki(g){return Ie((function(I){var i=I.length,e=i,l=vC.prototype.thru;for(g&&I.reverse();e--;){var t=I[e];if("function"!=typeof t)throw new Ng(A);if(l&&!s&&"wrapper"==ee(t))var s=new vC([],!0)}for(e=s?e:i;++e1&&G.reverse(),n&&ds))return!1;var d=l.get(g),o=l.get(I);if(d&&o)return d==I&&o==g;var n=-1,a=!0,Z=2&A?new jC:C;for(l.set(g,I),l.set(I,g);++n-1&&g%1==0&&g1?"& ":"")+I[A],I=I.join(C>2?", ":" "),g.replace(lg,"{\n/* [wrapped with "+I+"] */\n")}(A,function(g,I){return XI(b,(function(C){var A="_."+C[0];I&C[1]&&!HI(g,A)&&g.push(A)})),g.sort()}(function(g){var I=g.match(tg);return I?I[1].split(sg):[]}(A),C)))}function Ke(g){var I=0,A=0;return function(){var i=GC(),e=16-(i-A);if(A=i,e>0){if(++I>=800)return arguments[0]}else I=0;return g.apply(C,arguments)}}function Fe(g,I){var A=-1,i=g.length,e=i-1;for(I=I===C?i:I;++A1?g[I-1]:C;return A="function"==typeof A?(g.pop(),A):C,ll(g,A)}));function al(g){var I=DC(g);return I.__chain__=!0,I}function Zl(g,I){return I(g)}var bl=Ie((function(g){var I=g.length,A=I?g[0]:0,i=this.__wrapped__,e=function(I){return eA(I,g)};return!(I>1||this.__actions__.length)&&i instanceof TC&&me(A)?((i=i.slice(A,+A+(I?1:0))).__actions__.push({func:Zl,args:[e],thisArg:C}),new vC(i,this.__chain__).thru((function(g){return I&&!g.length&&g.push(C),g}))):this.thru(e)}));var rl=Ni((function(g,I,C){Sg.call(g,C)?++g[C]:iA(g,C,1)}));var ml=fi(xe),hl=fi(Ue);function Gl(g,I){return(Ul(g)?XI:oA)(g,te(I,3))}function ul(g,I){return(Ul(g)?YI:nA)(g,te(I,3))}var Bl=Ni((function(g,I,C){Sg.call(g,C)?g[C].push(I):iA(g,C,[I])}));var wl=EA((function(g,I,C){var A=-1,i="function"==typeof I,e=jl(g)?wg(g.length):[];return oA(g,(function(g){e[++A]=i?VI(I,g,C):RA(g,I,C)})),e})),Wl=Ni((function(g,I,C){iA(g,C,I)}));function pl(g,I){return(Ul(g)?FI:kA)(g,te(I,3))}var Vl=Ni((function(g,I,C){g[C?0:1].push(I)}),(function(){return[[],[]]}));var yl=EA((function(g,I){if(null==g)return[];var C=I.length;return C>1&&he(g,I[0],I[1])?I=[]:C>2&&he(I[0],I[1],I[2])&&(I=[I[0]]),TA(g,rA(I,1),[])})),Xl=nI||function(){return aI.Date.now()};function Yl(g,I,A){return I=A?C:I,I=g&&null==I?g.length:I,Pi(g,c,C,C,C,C,I)}function Rl(g,I){var i;if("function"!=typeof I)throw new Ng(A);return g=bt(g),function(){return--g>0&&(i=I.apply(this,arguments)),g<=1&&(I=C),i}}var Nl=EA((function(g,I,C){var A=1;if(C.length){var i=cC(C,le(Nl));A|=t}return Pi(g,A,I,C,i)})),Hl=EA((function(g,I,C){var A=3;if(C.length){var i=cC(C,le(Hl));A|=t}return Pi(I,A,g,C,i)}));function Kl(g,I,i){var e,l,t,s,c,d,o=0,n=!1,a=!1,Z=!0;if("function"!=typeof g)throw new Ng(A);function b(I){var A=e,i=l;return e=l=C,o=I,s=g.apply(i,A)}function r(g){var A=g-d;return d===C||A>=I||A<0||a&&g-o>=t}function m(){var g=Xl();if(r(g))return h(g);c=Re(m,function(g){var C=I-(g-d);return a?hC(C,t-(g-o)):C}(g))}function h(g){return c=C,Z&&e?b(g):(e=l=C,s)}function G(){var g=Xl(),A=r(g);if(e=arguments,l=this,d=g,A){if(c===C)return function(g){return o=g,c=Re(m,I),n?b(g):s}(d);if(a)return Bi(c),c=Re(m,I),b(d)}return c===C&&(c=Re(m,I)),s}return I=mt(I)||0,It(i)&&(n=!!i.leading,t=(a="maxWait"in i)?mC(mt(i.maxWait)||0,I):t,Z="trailing"in i?!!i.trailing:Z),G.cancel=function(){c!==C&&Bi(c),o=0,e=d=l=c=C},G.flush=function(){return c===C?s:h(Xl())},G}var Fl=EA((function(g,I){return cA(g,1,I)})),Ml=EA((function(g,I,C){return cA(g,mt(I)||0,C)}));function Jl(g,I){if("function"!=typeof g||null!=I&&"function"!=typeof I)throw new Ng(A);var C=function(){var A=arguments,i=I?I.apply(this,A):A[0],e=C.cache;if(e.has(i))return e.get(i);var l=g.apply(this,A);return C.cache=e.set(i,l)||e,l};return C.cache=new(Jl.Cache||QC),C}function Sl(g){if("function"!=typeof g)throw new Ng(A);return function(){var I=arguments;switch(I.length){case 0:return!g.call(this);case 1:return!g.call(this,I[0]);case 2:return!g.call(this,I[0],I[1]);case 3:return!g.call(this,I[0],I[1],I[2])}return!g.apply(this,I)}}Jl.Cache=QC;var fl=Gi((function(g,I){var C=(I=1==I.length&&Ul(I[0])?FI(I[0],qI(te())):FI(rA(I,1),qI(te()))).length;return EA((function(A){for(var i=-1,e=hC(A.length,C);++i=I})),xl=NA(function(){return arguments}())?NA:function(g){return Ct(g)&&Sg.call(g,"callee")&&!Eg.call(g,"callee")},Ul=wg.isArray,Ql=GI?qI(GI):function(g){return Ct(g)&&pA(g)==K};function jl(g){return null!=g&>(g.length)&&!ql(g)}function Ol(g){return Ct(g)&&jl(g)}var El=kI||ms,Pl=uI?qI(uI):function(g){return Ct(g)&&pA(g)==G};function _l(g){if(!Ct(g))return!1;var I=pA(g);return I==u||"[object DOMException]"==I||"string"==typeof g.message&&"string"==typeof g.name&&!et(g)}function ql(g){if(!It(g))return!1;var I=pA(g);return I==B||I==w||"[object AsyncFunction]"==I||"[object Proxy]"==I}function $l(g){return"number"==typeof g&&g==bt(g)}function gt(g){return"number"==typeof g&&g>-1&&g%1==0&&g<=n}function It(g){var I=typeof g;return null!=g&&("object"==I||"function"==I)}function Ct(g){return null!=g&&"object"==typeof g}var At=BI?qI(BI):function(g){return Ct(g)&&ae(g)==W};function it(g){return"number"==typeof g||Ct(g)&&pA(g)==p}function et(g){if(!Ct(g)||pA(g)!=V)return!1;var I=jg(g);if(null===I)return!0;var C=Sg.call(I,"constructor")&&I.constructor;return"function"==typeof C&&C instanceof C&&Jg.call(C)==Lg}var lt=wI?qI(wI):function(g){return Ct(g)&&pA(g)==X};var tt=WI?qI(WI):function(g){return Ct(g)&&ae(g)==Y};function st(g){return"string"==typeof g||!Ul(g)&&Ct(g)&&pA(g)==R}function ct(g){return"symbol"==typeof g||Ct(g)&&pA(g)==N}var dt=pI?qI(pI):function(g){return Ct(g)&>(g.length)&&!!lI[pA(g)]};var ot=Ui(fA),nt=Ui((function(g,I){return g<=I}));function at(g){if(!g)return[];if(jl(g))return st(g)?nC(g):Yi(g);if(gI&&g[gI])return function(g){for(var I,C=[];!(I=g.next()).done;)C.push(I.value);return C}(g[gI]());var I=ae(g);return(I==W?tC:I==Y?dC:zt)(g)}function Zt(g){return g?(g=mt(g))===o||g===-1/0?17976931348623157e292*(g<0?-1:1):g==g?g:0:0===g?g:0}function bt(g){var I=Zt(g),C=I%1;return I==I?C?I-C:I:0}function rt(g){return g?lA(bt(g),0,Z):0}function mt(g){if("number"==typeof g)return g;if(ct(g))return a;if(It(g)){var I="function"==typeof g.valueOf?g.valueOf():g;g=It(I)?I+"":I}if("string"!=typeof g)return 0===g?g:+g;g=_I(g);var C=bg.test(g);return C||mg.test(g)?dI(g.slice(2),C?2:8):Zg.test(g)?a:+g}function ht(g){return Ri(g,Ft(g))}function Gt(g){return null==g?"":si(g)}var ut=Hi((function(g,I){if(we(I)||jl(I))Ri(I,Kt(I),g);else for(var C in I)Sg.call(I,C)&&gA(g,C,I[C])})),Bt=Hi((function(g,I){Ri(I,Ft(I),g)})),wt=Hi((function(g,I,C,A){Ri(I,Ft(I),g,A)})),Wt=Hi((function(g,I,C,A){Ri(I,Kt(I),g,A)})),pt=Ie(eA);var Vt=EA((function(g,I){g=Xg(g);var A=-1,i=I.length,e=i>2?I[2]:C;for(e&&he(I[0],I[1],e)&&(i=1);++A1),I})),Ri(g,Ae(g),C),A&&(C=tA(C,7,$i));for(var i=I.length;i--;)di(C,I[i]);return C}));var ft=Ie((function(g,I){return null==g?{}:function(g,I){return xA(g,I,(function(I,C){return Yt(g,C)}))}(g,I)}));function kt(g,I){if(null==g)return{};var C=FI(Ae(g),(function(g){return[g]}));return I=te(I),xA(g,C,(function(g,C){return I(g,C[0])}))}var Dt=Ei(Kt),Lt=Ei(Ft);function zt(g){return null==g?[]:$I(g,Kt(g))}var vt=Ji((function(g,I,C){return I=I.toLowerCase(),g+(C?Tt(I):I)}));function Tt(g){return _t(Gt(g).toLowerCase())}function xt(g){return(g=Gt(g))&&g.replace(Gg,AC).replace($g,"")}var Ut=Ji((function(g,I,C){return g+(C?"-":"")+I.toLowerCase()})),Qt=Ji((function(g,I,C){return g+(C?" ":"")+I.toLowerCase()})),jt=Mi("toLowerCase");var Ot=Ji((function(g,I,C){return g+(C?"_":"")+I.toLowerCase()}));var Et=Ji((function(g,I,C){return g+(C?" ":"")+_t(I)}));var Pt=Ji((function(g,I,C){return g+(C?" ":"")+I.toUpperCase()})),_t=Mi("toUpperCase");function qt(g,I,A){return g=Gt(g),(I=A?C:I)===C?function(g){return AI.test(g)}(g)?function(g){return g.match(II)||[]}(g):function(g){return g.match(cg)||[]}(g):g.match(I)||[]}var $t=EA((function(g,I){try{return VI(g,C,I)}catch(A){return _l(A)?A:new pg(A)}})),gs=Ie((function(g,I){return XI(I,(function(I){I=ke(I),iA(g,I,Nl(g[I],g))})),g}));function Is(g){return function(){return g}}var Cs=ki(),As=ki(!0);function is(g){return g}function es(g){return MA("function"==typeof g?g:tA(g,1))}var ls=EA((function(g,I){return function(C){return RA(C,g,I)}})),ts=EA((function(g,I){return function(C){return RA(g,C,I)}}));function ss(g,I,C){var A=Kt(I),i=BA(I,A);null!=C||It(I)&&(i.length||!A.length)||(C=I,I=g,g=this,i=BA(I,Kt(I)));var e=!(It(C)&&"chain"in C&&!C.chain),l=ql(g);return XI(i,(function(C){var A=I[C];g[C]=A,l&&(g.prototype[C]=function(){var I=this.__chain__;if(e||I){var C=g(this.__wrapped__);return(C.__actions__=Yi(this.__actions__)).push({func:A,args:arguments,thisArg:g}),C.__chain__=I,C}return A.apply(g,MI([this.value()],arguments))})})),g}function cs(){}var ds=vi(FI),os=vi(RI),ns=vi(fI);function as(g){return Ge(g)?UI(ke(g)):function(g){return function(I){return wA(I,g)}}(g)}var Zs=xi(),bs=xi(!0);function rs(){return[]}function ms(){return!1}var hs=zi((function(g,I){return g+I}),0),Gs=ji("ceil"),us=zi((function(g,I){return g/I}),1),Bs=ji("floor");var ws,Ws=zi((function(g,I){return g*I}),1),ps=ji("round"),Vs=zi((function(g,I){return g-I}),0);return DC.after=function(g,I){if("function"!=typeof I)throw new Ng(A);return g=bt(g),function(){if(--g<1)return I.apply(this,arguments)}},DC.ary=Yl,DC.assign=ut,DC.assignIn=Bt,DC.assignInWith=wt,DC.assignWith=Wt,DC.at=pt,DC.before=Rl,DC.bind=Nl,DC.bindAll=gs,DC.bindKey=Hl,DC.castArray=function(){if(!arguments.length)return[];var g=arguments[0];return Ul(g)?g:[g]},DC.chain=al,DC.chunk=function(g,I,A){I=(A?he(g,I,A):I===C)?1:mC(bt(I),0);var i=null==g?0:g.length;if(!i||I<1)return[];for(var e=0,l=0,t=wg(bI(i/I));ee?0:e+A),(i=i===C||i>e?e:bt(i))<0&&(i+=e),i=A>i?0:rt(i);A>>0)?(g=Gt(g))&&("string"==typeof I||null!=I&&!lt(I))&&!(I=si(I))&&lC(g)?ui(nC(g),0,A):g.split(I,A):[]},DC.spread=function(g,I){if("function"!=typeof g)throw new Ng(A);return I=null==I?0:mC(bt(I),0),EA((function(C){var A=C[I],i=ui(C,0,I);return A&&MI(i,A),VI(g,this,i)}))},DC.tail=function(g){var I=null==g?0:g.length;return I?Ci(g,1,I):[]},DC.take=function(g,I,A){return g&&g.length?Ci(g,0,(I=A||I===C?1:bt(I))<0?0:I):[]},DC.takeRight=function(g,I,A){var i=null==g?0:g.length;return i?Ci(g,(I=i-(I=A||I===C?1:bt(I)))<0?0:I,i):[]},DC.takeRightWhile=function(g,I){return g&&g.length?ni(g,te(I,3),!1,!0):[]},DC.takeWhile=function(g,I){return g&&g.length?ni(g,te(I,3)):[]},DC.tap=function(g,I){return I(g),g},DC.throttle=function(g,I,C){var i=!0,e=!0;if("function"!=typeof g)throw new Ng(A);return It(C)&&(i="leading"in C?!!C.leading:i,e="trailing"in C?!!C.trailing:e),Kl(g,I,{leading:i,maxWait:I,trailing:e})},DC.thru=Zl,DC.toArray=at,DC.toPairs=Dt,DC.toPairsIn=Lt,DC.toPath=function(g){return Ul(g)?FI(g,ke):ct(g)?[g]:Yi(fe(Gt(g)))},DC.toPlainObject=ht,DC.transform=function(g,I,C){var A=Ul(g),i=A||El(g)||dt(g);if(I=te(I,4),null==C){var e=g&&g.constructor;C=i?A?new e:[]:It(g)&&ql(e)?LC(jg(g)):{}}return(i?XI:GA)(g,(function(g,A,i){return I(C,g,A,i)})),C},DC.unary=function(g){return Yl(g,1)},DC.union=Cl,DC.unionBy=Al,DC.unionWith=il,DC.uniq=function(g){return g&&g.length?ci(g):[]},DC.uniqBy=function(g,I){return g&&g.length?ci(g,te(I,2)):[]},DC.uniqWith=function(g,I){return I="function"==typeof I?I:C,g&&g.length?ci(g,C,I):[]},DC.unset=function(g,I){return null==g||di(g,I)},DC.unzip=el,DC.unzipWith=ll,DC.update=function(g,I,C){return null==g?g:oi(g,I,mi(C))},DC.updateWith=function(g,I,A,i){return i="function"==typeof i?i:C,null==g?g:oi(g,I,mi(A),i)},DC.values=zt,DC.valuesIn=function(g){return null==g?[]:$I(g,Ft(g))},DC.without=tl,DC.words=qt,DC.wrap=function(g,I){return kl(mi(I),g)},DC.xor=sl,DC.xorBy=cl,DC.xorWith=dl,DC.zip=ol,DC.zipObject=function(g,I){return bi(g||[],I||[],gA)},DC.zipObjectDeep=function(g,I){return bi(g||[],I||[],qA)},DC.zipWith=nl,DC.entries=Dt,DC.entriesIn=Lt,DC.extend=Bt,DC.extendWith=wt,ss(DC,DC),DC.add=hs,DC.attempt=$t,DC.camelCase=vt,DC.capitalize=Tt,DC.ceil=Gs,DC.clamp=function(g,I,A){return A===C&&(A=I,I=C),A!==C&&(A=(A=mt(A))==A?A:0),I!==C&&(I=(I=mt(I))==I?I:0),lA(mt(g),I,A)},DC.clone=function(g){return tA(g,4)},DC.cloneDeep=function(g){return tA(g,5)},DC.cloneDeepWith=function(g,I){return tA(g,5,I="function"==typeof I?I:C)},DC.cloneWith=function(g,I){return tA(g,4,I="function"==typeof I?I:C)},DC.conformsTo=function(g,I){return null==I||sA(g,I,Kt(I))},DC.deburr=xt,DC.defaultTo=function(g,I){return null==g||g!=g?I:g},DC.divide=us,DC.endsWith=function(g,I,A){g=Gt(g),I=si(I);var i=g.length,e=A=A===C?i:lA(bt(A),0,i);return(A-=I.length)>=0&&g.slice(A,e)==I},DC.eq=zl,DC.escape=function(g){return(g=Gt(g))&&E.test(g)?g.replace(j,iC):g},DC.escapeRegExp=function(g){return(g=Gt(g))&&Ag.test(g)?g.replace(Cg,"\\$&"):g},DC.every=function(g,I,A){var i=Ul(g)?RI:aA;return A&&he(g,I,A)&&(I=C),i(g,te(I,3))},DC.find=ml,DC.findIndex=xe,DC.findKey=function(g,I){return DI(g,te(I,3),GA)},DC.findLast=hl,DC.findLastIndex=Ue,DC.findLastKey=function(g,I){return DI(g,te(I,3),uA)},DC.floor=Bs,DC.forEach=Gl,DC.forEachRight=ul,DC.forIn=function(g,I){return null==g?g:mA(g,te(I,3),Ft)},DC.forInRight=function(g,I){return null==g?g:hA(g,te(I,3),Ft)},DC.forOwn=function(g,I){return g&&GA(g,te(I,3))},DC.forOwnRight=function(g,I){return g&&uA(g,te(I,3))},DC.get=Xt,DC.gt=vl,DC.gte=Tl,DC.has=function(g,I){return null!=g&&Ze(g,I,yA)},DC.hasIn=Yt,DC.head=je,DC.identity=is,DC.includes=function(g,I,C,A){g=jl(g)?g:zt(g),C=C&&!A?bt(C):0;var i=g.length;return C<0&&(C=mC(i+C,0)),st(g)?C<=i&&g.indexOf(I,C)>-1:!!i&&zI(g,I,C)>-1},DC.indexOf=function(g,I,C){var A=null==g?0:g.length;if(!A)return-1;var i=null==C?0:bt(C);return i<0&&(i=mC(A+i,0)),zI(g,I,i)},DC.inRange=function(g,I,A){return I=Zt(I),A===C?(A=I,I=0):A=Zt(A),function(g,I,C){return g>=hC(I,C)&&g=-9007199254740991&&g<=n},DC.isSet=tt,DC.isString=st,DC.isSymbol=ct,DC.isTypedArray=dt,DC.isUndefined=function(g){return g===C},DC.isWeakMap=function(g){return Ct(g)&&ae(g)==H},DC.isWeakSet=function(g){return Ct(g)&&"[object WeakSet]"==pA(g)},DC.join=function(g,I){return null==g?"":EI.call(g,I)},DC.kebabCase=Ut,DC.last=_e,DC.lastIndexOf=function(g,I,A){var i=null==g?0:g.length;if(!i)return-1;var e=i;return A!==C&&(e=(e=bt(A))<0?mC(i+e,0):hC(e,i-1)),I==I?function(g,I,C){for(var A=C+1;A--;)if(g[A]===I)return A;return A}(g,I,e):LI(g,TI,e,!0)},DC.lowerCase=Qt,DC.lowerFirst=jt,DC.lt=ot,DC.lte=nt,DC.max=function(g){return g&&g.length?ZA(g,is,VA):C},DC.maxBy=function(g,I){return g&&g.length?ZA(g,te(I,2),VA):C},DC.mean=function(g){return xI(g,is)},DC.meanBy=function(g,I){return xI(g,te(I,2))},DC.min=function(g){return g&&g.length?ZA(g,is,fA):C},DC.minBy=function(g,I){return g&&g.length?ZA(g,te(I,2),fA):C},DC.stubArray=rs,DC.stubFalse=ms,DC.stubObject=function(){return{}},DC.stubString=function(){return""},DC.stubTrue=function(){return!0},DC.multiply=Ws,DC.nth=function(g,I){return g&&g.length?vA(g,bt(I)):C},DC.noConflict=function(){return aI._===this&&(aI._=zg),this},DC.noop=cs,DC.now=Xl,DC.pad=function(g,I,C){g=Gt(g);var A=(I=bt(I))?oC(g):0;if(!I||A>=I)return g;var i=(I-A)/2;return Ti(mI(i),C)+g+Ti(bI(i),C)},DC.padEnd=function(g,I,C){g=Gt(g);var A=(I=bt(I))?oC(g):0;return I&&AI){var i=g;g=I,I=i}if(A||g%1||I%1){var e=BC();return hC(g+e*(I-g+cI("1e-"+((e+"").length-1))),I)}return jA(g,I)},DC.reduce=function(g,I,C){var A=Ul(g)?JI:jI,i=arguments.length<3;return A(g,te(I,4),C,i,oA)},DC.reduceRight=function(g,I,C){var A=Ul(g)?SI:jI,i=arguments.length<3;return A(g,te(I,4),C,i,nA)},DC.repeat=function(g,I,A){return I=(A?he(g,I,A):I===C)?1:bt(I),OA(Gt(g),I)},DC.replace=function(){var g=arguments,I=Gt(g[0]);return g.length<3?I:I.replace(g[1],g[2])},DC.result=function(g,I,A){var i=-1,e=(I=hi(I,g)).length;for(e||(e=1,g=C);++in)return[];var C=Z,A=hC(g,Z);I=te(I),g-=Z;for(var i=PI(A,I);++C=l)return g;var s=A-oC(i);if(s<1)return i;var c=t?ui(t,0,s).join(""):g.slice(0,s);if(e===C)return c+i;if(t&&(s+=c.length-s),lt(e)){if(g.slice(s).search(e)){var d,o=c;for(e.global||(e=Yg(e.source,Gt(ag.exec(e))+"g")),e.lastIndex=0;d=e.exec(o);)var n=d.index;c=c.slice(0,n===C?s:n)}}else if(g.indexOf(si(e),s)!=s){var a=c.lastIndexOf(e);a>-1&&(c=c.slice(0,a))}return c+i},DC.unescape=function(g){return(g=Gt(g))&&O.test(g)?g.replace(Q,ZC):g},DC.uniqueId=function(g){var I=++fg;return Gt(g)+I},DC.upperCase=Pt,DC.upperFirst=_t,DC.each=Gl,DC.eachRight=ul,DC.first=je,ss(DC,(ws={},GA(DC,(function(g,I){Sg.call(DC.prototype,I)||(ws[I]=g)})),ws),{chain:!1}),DC.VERSION="4.17.21",XI(["bind","bindKey","curry","curryRight","partial","partialRight"],(function(g){DC[g].placeholder=DC})),XI(["drop","take"],(function(g,I){TC.prototype[g]=function(A){A=A===C?1:mC(bt(A),0);var i=this.__filtered__&&!I?new TC(this):this.clone();return i.__filtered__?i.__takeCount__=hC(A,i.__takeCount__):i.__views__.push({size:hC(A,Z),type:g+(i.__dir__<0?"Right":"")}),i},TC.prototype[g+"Right"]=function(I){return this.reverse()[g](I).reverse()}})),XI(["filter","map","takeWhile"],(function(g,I){var C=I+1,A=1==C||3==C;TC.prototype[g]=function(g){var I=this.clone();return I.__iteratees__.push({iteratee:te(g,3),type:C}),I.__filtered__=I.__filtered__||A,I}})),XI(["head","last"],(function(g,I){var C="take"+(I?"Right":"");TC.prototype[g]=function(){return this[C](1).value()[0]}})),XI(["initial","tail"],(function(g,I){var C="drop"+(I?"":"Right");TC.prototype[g]=function(){return this.__filtered__?new TC(this):this[C](1)}})),TC.prototype.compact=function(){return this.filter(is)},TC.prototype.find=function(g){return this.filter(g).head()},TC.prototype.findLast=function(g){return this.reverse().find(g)},TC.prototype.invokeMap=EA((function(g,I){return"function"==typeof g?new TC(this):this.map((function(C){return RA(C,g,I)}))})),TC.prototype.reject=function(g){return this.filter(Sl(te(g)))},TC.prototype.slice=function(g,I){g=bt(g);var A=this;return A.__filtered__&&(g>0||I<0)?new TC(A):(g<0?A=A.takeRight(-g):g&&(A=A.drop(g)),I!==C&&(A=(I=bt(I))<0?A.dropRight(-I):A.take(I-g)),A)},TC.prototype.takeRightWhile=function(g){return this.reverse().takeWhile(g).reverse()},TC.prototype.toArray=function(){return this.take(Z)},GA(TC.prototype,(function(g,I){var A=/^(?:filter|find|map|reject)|While$/.test(I),i=/^(?:head|last)$/.test(I),e=DC[i?"take"+("last"==I?"Right":""):I],l=i||/^find/.test(I);e&&(DC.prototype[I]=function(){var I=this.__wrapped__,t=i?[1]:arguments,s=I instanceof TC,c=t[0],d=s||Ul(I),o=function(g){var I=e.apply(DC,MI([g],t));return i&&n?I[0]:I};d&&A&&"function"==typeof c&&1!=c.length&&(s=d=!1);var n=this.__chain__,a=!!this.__actions__.length,Z=l&&!n,b=s&&!a;if(!l&&d){I=b?I:new TC(this);var r=g.apply(I,t);return r.__actions__.push({func:Zl,args:[o],thisArg:C}),new vC(r,n)}return Z&&b?g.apply(this,t):(r=this.thru(o),Z?i?r.value()[0]:r.value():r)})})),XI(["pop","push","shift","sort","splice","unshift"],(function(g){var I=Hg[g],C=/^(?:push|sort|unshift)$/.test(g)?"tap":"thru",A=/^(?:pop|shift)$/.test(g);DC.prototype[g]=function(){var g=arguments;if(A&&!this.__chain__){var i=this.value();return I.apply(Ul(i)?i:[],g)}return this[C]((function(C){return I.apply(Ul(C)?C:[],g)}))}})),GA(TC.prototype,(function(g,I){var C=DC[I];if(C){var A=C.name+"";Sg.call(NC,A)||(NC[A]=[]),NC[A].push({name:I,func:C})}})),NC[Di(C,2).name]=[{name:"wrapper",func:C}],TC.prototype.clone=function(){var g=new TC(this.__wrapped__);return g.__actions__=Yi(this.__actions__),g.__dir__=this.__dir__,g.__filtered__=this.__filtered__,g.__iteratees__=Yi(this.__iteratees__),g.__takeCount__=this.__takeCount__,g.__views__=Yi(this.__views__),g},TC.prototype.reverse=function(){if(this.__filtered__){var g=new TC(this);g.__dir__=-1,g.__filtered__=!0}else(g=this.clone()).__dir__*=-1;return g},TC.prototype.value=function(){var g=this.__wrapped__.value(),I=this.__dir__,C=Ul(g),A=I<0,i=C?g.length:0,e=function(g,I,C){var A=-1,i=C.length;for(;++A=this.__values__.length;return{done:g,value:g?C:this.__values__[this.__index__++]}},DC.prototype.plant=function(g){for(var I,A=this;A instanceof zC;){var i=Le(A);i.__index__=0,i.__values__=C,I?e.__wrapped__=i:I=i;var e=i;A=A.__wrapped__}return e.__wrapped__=g,I},DC.prototype.reverse=function(){var g=this.__wrapped__;if(g instanceof TC){var I=g;return this.__actions__.length&&(I=new TC(this)),(I=I.reverse()).__actions__.push({func:Zl,args:[Il],thisArg:C}),new vC(I,this.__chain__)}return this.thru(Il)},DC.prototype.toJSON=DC.prototype.valueOf=DC.prototype.value=function(){return ai(this.__wrapped__,this.__actions__)},DC.prototype.first=DC.prototype.head,gI&&(DC.prototype[gI]=function(){return this}),DC}();bI?((bI.exports=bC)._=bC,ZI._=bC):aI._=bC}).call(EI)}(EA,EA.exports);var PA=EA.exports;class _A{constructor(g,I=""){"string"==typeof g?(this.el=document.createElement(g),this.el.className=I):this.el=g,this.data={}}data(g,I){return void 0!==I?(this.data[g]=I,this):this.data[g]}on(g,I){const[C,...A]=g.split(".");let i=C;return"mousewheel"===i&&/Firefox/i.test(window.navigator.userAgent)&&(i="DOMMouseScroll"),this.el.addEventListener(i,(g=>{I(g);for(let I=0;I{this.css(I,`${g[I]}px`)})),this;const{offsetTop:I,offsetLeft:C,offsetHeight:A,offsetWidth:i}=this.el;return{top:I,left:C,height:A,width:i}}scroll(g){const{el:I}=this;return void 0!==g&&(void 0!==g.left&&(I.scrollLeft=g.left),void 0!==g.top&&(I.scrollTop=g.top)),{left:I.scrollLeft,top:I.scrollTop}}box(){return this.el.getBoundingClientRect()}parent(){return new _A(this.el.parentNode)}children(...g){return 0===arguments.length?this.el.childNodes:(g.forEach((g=>this.child(g))),this)}removeChild(g){this.el.removeChild(g)}child(g){let I=g;return"string"==typeof g?I=document.createTextNode(g):g instanceof _A&&(I=g.el),this.el.appendChild(I),this}contains(g){return this.el.contains(g)}className(g){return void 0!==g?(this.el.className=g,this):this.el.className}addClass(g){return this.el.classList.add(g),this}hasClass(g){return this.el.classList.contains(g)}removeClass(g){return this.el.classList.remove(g),this}toggle(g="active"){return this.toggleClass(g)}toggleClass(g){return this.el.classList.toggle(g)}active(g=!0,I="active"){return g?this.addClass(I):this.removeClass(I),this}checked(g=!0){return this.active(g,"checked"),this}disabled(g=!0){return g?this.addClass("disabled"):this.removeClass("disabled"),this}attr(g,I){if(void 0!==I)this.el.setAttribute(g,I);else{if("string"==typeof g)return this.el.getAttribute(g);Object.keys(g).forEach((I=>{this.el.setAttribute(I,g[I])}))}return this}removeAttr(g){return this.el.removeAttribute(g),this}html(g){return void 0!==g?(this.el.innerHTML=g,this):this.el.innerHTML}val(g){return void 0!==g?(this.el.value=g,this):this.el.value}focus(){this.el.focus()}cssRemoveKeys(...g){return g.forEach((g=>this.el.style.removeProperty(g))),this}css(g,I){return void 0===I&&"string"!=typeof g?(Object.keys(g).forEach((I=>{this.el.style[I]=g[I]})),this):void 0!==I?(this.el.style[g]=I,this):this.el.style[g]}computedStyle(){return window.getComputedStyle(this.el,null)}show(){return this.css("display","block"),this}hide(){return this.css("display","none"),this}}const qA=(g,I="")=>new _A(g,I),$A=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"];function gi(g){let I="",C=g;for(;C>=$A.length;)C/=$A.length,C-=1,I+=$A[parseInt(C,10)%$A.length];const A=g%$A.length;return I+=$A[A],I}function Ii(g){let I=0;for(let C=0;C="0"&&g.charAt(A)<="9"?C+=g.charAt(A):I+=g.charAt(A);return[Ii(I),parseInt(C,10)-1]}function Ai(g,I){return`${gi(g)}${I+1}`}function ii(g,I,C,A=(()=>!0)){if(0===I&&0===C)return g;const[i,e]=Ci(g);return A(i,e)?Ai(i+I,e+C):g}class ei{constructor(g,I,C,A,i=0,e=0){this.sri=g,this.sci=I,this.eri=C,this.eci=A,this.w=i,this.h=e}set(g,I,C,A){this.sri=g,this.sci=I,this.eri=C,this.eci=A}multiple(){return this.eri-this.sri>0||this.eci-this.sci>0}includes(...g){let[I,C]=[0,0];1===g.length?[C,I]=Ci(g[0]):2===g.length&&([I,C]=g);const{sri:A,sci:i,eri:e,eci:l}=this;return A<=I&&I<=e&&i<=C&&C<=l}each(g,I=(()=>!0)){const{sri:C,sci:A,eri:i,eci:e}=this;for(let l=C;l<=i;l+=1)if(I(l))for(let I=A;I<=e;I+=1)g(l,I)}contains(g){return this.sri<=g.sri&&this.sci<=g.sci&&this.eri>=g.eri&&this.eci>=g.eci}within(g){return this.sri>=g.sri&&this.sci>=g.sci&&this.eri<=g.eri&&this.eci<=g.eci}disjoint(g){return this.sri>g.eri||this.sci>g.eci||g.sri>this.eri||g.sci>this.eci}intersects(g){return this.sri<=g.eri&&this.sci<=g.eci&&g.sri<=this.eri&&g.sci<=this.eci}union(g){const{sri:I,sci:C,eri:A,eci:i}=this;return new ei(g.sriA?g.eri:A,g.eci>i?g.eci:i)}difference(g){const I=[],C=(g,C,A,i)=>{I.push(new ei(g,C,A,i))},{sri:A,sci:i,eri:e,eci:l}=this,t=g.sri-A,s=g.sci-i,c=e-g.eri,d=l-g.eci;return t>0?(C(A,i,g.sri-1,l),c>0?(C(g.eri+1,i,e,l),s>0&&C(g.sri,i,g.eri,g.sci-1),d>0&&C(g.sri,g.eci+1,g.eri,l)):(s>0&&C(g.sri,i,e,g.sci-1),d>0&&C(g.sri,g.eci+1,e,l))):c>0&&(C(g.eri+1,i,e,l),s>0&&C(A,i,g.eri,g.sci-1),d>0&&C(A,g.eci+1,g.eri,l)),s>0?(C(A,i,e,g.sci-1),d>0?(C(A,g.eri+1,e,l),t>0&&C(A,g.sci,g.sri-1,g.eci),c>0&&C(g.sri+1,g.sci,e,g.eci)):(t>0&&C(A,g.sci,g.sri-1,l),c>0&&C(g.sri+1,g.sci,e,l))):d>0&&(C(e,g.eci+1,e,l),t>0&&C(A,i,g.sri-1,g.eci),c>0&&C(g.eri+1,i,e,g.eci)),I}size(){return[this.eri-this.sri+1,this.eci-this.sci+1]}toString(){const{sri:g,sci:I,eri:C,eci:A}=this;let i=Ai(I,g);return this.multiple()&&(i=`${i}:${Ai(A,C)}`),i}clone(){const{sri:g,sci:I,eri:C,eci:A,w:i,h:e}=this;return new ei(g,I,C,A,i,e)}equals(g){return this.eri===g.eri&&this.eci===g.eci&&this.sri===g.sri&&this.sci===g.sci}static valueOf(g){const I=g.split(":"),[C,A]=Ci(I[0]);let[i,e]=[A,C];return I.length>1&&([e,i]=Ci(I[1])),new ei(A,C,i,e)}}let li=class{constructor(){this.range=new ei(0,0,0,0),this.ri=0,this.ci=0}multiple(){return this.range.multiple()}setIndexes(g,I){this.ri=g,this.ci=I}size(){return this.range.size()}};class ti{constructor(){this.x=0,this.y=0,this.ri=0,this.ci=0}}class si{constructor(){this.undoItems=[],this.redoItems=[]}add(g){this.undoItems.push(JSON.stringify(g)),this.redoItems=[]}canUndo(){return this.undoItems.length>0}canRedo(){return this.redoItems.length>0}undo(g,I){const{undoItems:C,redoItems:A}=this;this.canUndo()&&(A.push(JSON.stringify(g)),I(JSON.parse(C.pop())))}redo(g,I){const{undoItems:C,redoItems:A}=this;this.canRedo()&&(C.push(JSON.stringify(g)),I(JSON.parse(A.pop())))}}class ci{constructor(){this.range=null,this.state="clear"}copy(g){return this.range=g,this.state="copy",this}cut(g){return this.range=g,this.state="cut",this}isCopy(){return"copy"===this.state}isCut(){return"cut"===this.state}isClear(){return"clear"===this.state}clear(){this.range=null,this.state="clear"}}class di{constructor(g,I,C){this.ci=g,this.operator=I,this.value=C}set(g,I){this.operator=g,this.value=I}includes(g){const{operator:I,value:C}=this;return"all"===I||"in"===I&&C.includes(g)}vlength(){const{operator:g,value:I}=this;return"in"===g?I.length:0}getData(){const{ci:g,operator:I,value:C}=this;return{ci:g,operator:I,value:C}}}class oi{constructor(g,I){this.ci=g,this.order=I}asc(){return"asc"===this.order}desc(){return"desc"===this.order}}class ni{constructor(){this.ref=null,this.filters=[],this.sort=null}setData({ref:g,filters:I,sort:C}){null!=g&&(this.ref=g,this.filters=I.map((g=>new di(g.ci,g.operator,g.value))),C&&(this.sort=new oi(C.ci,C.order)))}getData(){if(this.active()){const{ref:g,filters:I,sort:C}=this;return{ref:g,filters:I.map((g=>g.getData())),sort:C}}return{}}addFilter(g,I,C){const A=this.getFilter(g);null==A?this.filters.push(new di(g,I,C)):A.set(I,C)}setSort(g,I){this.sort=I?new oi(g,I):null}includes(g,I){return!!this.active()&&this.hrange().includes(g,I)}getSort(g){const{sort:I}=this;return I&&I.ci===g?I:null}getFilter(g){const{filters:I}=this;for(let C=0;C!I.within(g)))}getFirstIncludes(g,I){for(let C=0;CI.intersects(g))))}intersects(g){for(let I=0;I{g.intersects(I)&&(I=g.union(I))})),I}add(g){this.deleteWithin(g),this._.push(g)}shift(g,I,C,A){this._.forEach((i=>{const{sri:e,sci:l,eri:t,eci:s}=i,c=i;"row"===g?e>=I?(c.sri+=C,c.eri+=C):e=I?(c.sci+=C,c.eci+=C):l{const i=A;i.within(g)&&(i.eri+=I,i.sri+=I,i.sci+=C,i.eci+=C)}))}setData(g){return this._=g.map((g=>ei.valueOf(g))),this}getData(){return this._.map((g=>g.toString()))}}const Zi=(g={},...I)=>(I.forEach((I=>{Object.keys(I).forEach((C=>{const A=I[C];"string"==typeof A||"number"==typeof A||"boolean"==typeof A?g[C]=A:"function"!=typeof A&&!Array.isArray(A)&&A instanceof Object?(g[C]=g[C]||{},Zi(g[C],A)):g[C]=A}))})),g);function bi(g){const I=`${g}`;let C=0,A=!1;for(let i=0;i5?t.toFixed(2):t;return t.toFixed(Math.max(A,i))}const mi={cloneDeep:function(g){return JSON.parse(JSON.stringify(g))},merge:(...g)=>Zi({},...g),equals:function g(I,C){const A=Object.keys(I);if(A.length!==Object.keys(C).length)return!1;for(let i=0;ig))=>{let C=0,A=0;return Object.keys(g).forEach((i=>{C+=I(g[i],i),A+=1})),[C,A]},rangeEach:function(g,I,C){for(let A=g;Ai);s+=1)t=e(s),l+=t;return[s,l-t,t]},deleteProperty:function(g,I){const C=g[`${I}`];return delete g[`${I}`],C},numberCalc:ri};class hi{constructor({len:g,height:I}){this._={},this.len=g,this.height=I}getHeight(g){if(this.isHide(g))return 0;const I=this.get(g);return I&&I.height?I.height:this.height}setHeight(g,I){this.getOrNew(g).height=I}unhide(g){let I=g;for(;I>0&&(I-=1,this.isHide(I));)this.setHide(I,!1)}isHide(g){const I=this.get(g);return I&&I.hide}setHide(g,I){const C=this.getOrNew(g);!0===I?C.hide=!0:delete C.hide}setStyle(g,I){this.getOrNew(g).style=I}sumHeight(g,I,C){return mi.rangeSum(g,I,(g=>C&&C.has(g)?0:this.getHeight(g)))}totalHeight(){return this.sumHeight(0,this.len)}get(g){return this._[g]}getOrNew(g){return this._[g]=this._[g]||{cells:{}},this._[g]}getCell(g,I){const C=this.get(g);return void 0!==C&&void 0!==C.cells&&void 0!==C.cells[I]?C.cells[I]:null}getCellMerge(g,I){const C=this.getCell(g,I);return C&&C.merge?C.merge:[0,0]}getCellOrNew(g,I){const C=this.getOrNew(g);return C.cells[I]=C.cells[I]||{},C.cells[I]}setCell(g,I,C,A="all"){const i=this.getOrNew(g);"all"===A?i.cells[I]=C:"text"===A?(i.cells[I]=i.cells[I]||{},i.cells[I].text=C.text):"format"===A&&(i.cells[I]=i.cells[I]||{},i.cells[I].style=C.style,C.merge&&(i.cells[I].merge=C.merge))}setCellText(g,I,C){const A=this.getCellOrNew(g,I);!1!==A.editable&&(A.text=C)}copyPaste(g,I,C,A=!1,i=(()=>{})){const{sri:e,sci:l,eri:t,eci:s}=g,c=I.sri,d=I.sci,o=I.eri,n=I.eci,[a,Z]=g.size(),[b,r]=I.size();let m=!0,h=0;(o0){const{text:g}=B;let C=b-d+(I-c)+2;if(m||(C-=h+1),"="===g[0])B.text=g.replace(/[a-zA-Z]{1,3}\d+/g,(g=>{let[I,A]=[0,0];return e===c?I=C-1:A=C-1,/^\d+$/.test(g)?g:ii(g,I,A)}));else if(a<=1&&Z>1&&(c>t||o1&&(d>s||n{this.eachCells(A,(i=>{let e=parseInt(A,10),l=parseInt(i,10);g.includes(A,i)&&(e=I.sri+(e-g.sri),l=I.sci+(l-g.sci)),C[e]=C[e]||{cells:{}},C[e].cells[l]=this._[A].cells[i]}))})),this._=C}paste(g,I){if(g.length<=0)return;const{sri:C,sci:A}=I;g.forEach(((g,I)=>{const i=C+I;g.forEach(((g,I)=>{const C=A+I;this.setCellText(i,C,g)}))}))}insert(g,I=1){const C={};this.each(((A,i)=>{let e=parseInt(A,10);e>=g&&(e+=I,this.eachCells(A,((C,A)=>{A.text&&"="===A.text[0]&&(A.text=A.text.replace(/[a-zA-Z]{1,3}\d+/g,(C=>ii(C,0,I,((I,C)=>C>=g)))))}))),C[e]=i})),this._=C,this.len+=I}delete(g,I){const C=I-g+1,A={};this.each(((i,e)=>{const l=parseInt(i,10);lI&&(A[l-C]=e,this.eachCells(i,((g,A)=>{A.text&&"="===A.text[0]&&(A.text=A.text.replace(/[a-zA-Z]{1,3}\d+/g,(g=>ii(g,0,-C,((g,C)=>C>I)))))})))})),this._=A,this.len-=C}insertColumn(g,I=1){this.each(((C,A)=>{const i={};this.eachCells(C,((C,A)=>{let e=parseInt(C,10);e>=g&&(e+=I,A.text&&"="===A.text[0]&&(A.text=A.text.replace(/[a-zA-Z]{1,3}\d+/g,(C=>ii(C,I,0,(I=>I>=g)))))),i[e]=A})),A.cells=i}))}deleteColumn(g,I){const C=I-g+1;this.each(((A,i)=>{const e={};this.eachCells(A,((A,i)=>{const l=parseInt(A,10);lI&&(e[l-C]=i,i.text&&"="===i.text[0]&&(i.text=i.text.replace(/[a-zA-Z]{1,3}\d+/g,(g=>ii(g,-C,0,(g=>g>I))))))})),i.cells=e}))}deleteCells(g,I="all"){g.each(((g,C)=>{this.deleteCell(g,C,I)}))}deleteCell(g,I,C="all"){const A=this.get(g);if(null!==A){const i=this.getCell(g,I);null!==i&&!1!==i.editable&&("all"===C?delete A.cells[I]:"text"===C?(i.text&&delete i.text,i.value&&delete i.value):"format"===C?(void 0!==i.style&&delete i.style,i.merge&&delete i.merge):"merge"===C&&i.merge&&delete i.merge)}}maxCell(){const g=Object.keys(this._),I=g[g.length-1],C=this._[I];if(C){const{cells:g}=C,A=Object.keys(g),i=A[A.length-1];return[parseInt(I,10),parseInt(i,10)]}return[0,0]}each(g){Object.entries(this._).forEach((([I,C])=>{g(I,C)}))}eachCells(g,I){this._[g]&&this._[g].cells&&Object.entries(this._[g].cells).forEach((([g,C])=>{I(g,C)}))}setData(g){g.len&&(this.len=g.len,delete g.len),this._=g}getData(){const{len:g}=this;return Object.assign({len:g},this._)}}class Gi{constructor({len:g,width:I,indexWidth:C,minWidth:A}){this._={},this.len=g,this.width=I,this.indexWidth=C,this.minWidth=A}setData(g){g.len&&(this.len=g.len,delete g.len),this._=g}getData(){const{len:g}=this;return Object.assign({len:g},this._)}getWidth(g){if(this.isHide(g))return 0;const I=this._[g];return I&&I.width?I.width:this.width}getOrNew(g){return this._[g]=this._[g]||{},this._[g]}setWidth(g,I){this.getOrNew(g).width=I}unhide(g){let I=g;for(;I>0&&(I-=1,this.isHide(I));)this.setHide(I,!1)}isHide(g){const I=this._[g];return I&&I.hide}setHide(g,I){const C=this.getOrNew(g);!0===I?C.hide=!0:delete C.hide}setStyle(g,I){this.getOrNew(g).style=I}sumWidth(g,I){return mi.rangeSum(g,I,(g=>this.getWidth(g)))}totalWidth(){return this.sumWidth(0,this.len)}}let ui=["en"];const Bi={en:{toolbar:{undo:"Undo",redo:"Redo",print:"Print",paintformat:"Paint format",clearformat:"Clear format",format:"Format",fontName:"Font",fontSize:"Font size",fontBold:"Font bold",fontItalic:"Font italic",underline:"Underline",strike:"Strike",color:"Text color",bgcolor:"Fill color",border:"Borders",merge:"Merge cells",align:"Horizontal align",valign:"Vertical align",textwrap:"Text wrapping",freeze:"Freeze cell",autofilter:"Filter",formula:"Functions",more:"More"},contextmenu:{copy:"Copy",cut:"Cut",paste:"Paste",pasteValue:"Paste values only",pasteFormat:"Paste format only",hide:"Hide",insertRow:"Insert row",insertColumn:"Insert column",deleteSheet:"Delete",deleteRow:"Delete row",deleteColumn:"Delete column",deleteCell:"Delete cell",deleteCellText:"Delete cell text",validation:"Data validations",cellprintable:"Enable export",cellnonprintable:"Disable export",celleditable:"Enable editing",cellnoneditable:"Disable editing"},print:{size:"Paper size",orientation:"Page orientation",orientations:["Landscape","Portrait"]},format:{normal:"Normal",text:"Plain Text",number:"Number",percent:"Percent",rmb:"RMB",usd:"USD",eur:"EUR",date:"Date",time:"Time",datetime:"Date time",duration:"Duration"},formula:{sum:"Sum",average:"Average",max:"Max",min:"Min",_if:"IF",and:"AND",or:"OR",concat:"Concat"},validation:{required:"it must be required",notMatch:"it not match its validation rule",between:"it is between {} and {}",notBetween:"it is not between {} and {}",notIn:"it is not in list",equal:"it equal to {}",notEqual:"it not equal to {}",lessThan:"it less than {}",lessThanEqual:"it less than or equal to {}",greaterThan:"it greater than {}",greaterThanEqual:"it greater than or equal to {}"},error:{pasteForMergedCell:"Unable to do this for merged cells"},calendar:{weeks:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"]},button:{next:"Next",cancel:"Cancel",remove:"Remove",save:"Save",ok:"OK"},sort:{desc:"Sort Z -> A",asc:"Sort A -> Z"},filter:{empty:"empty"},dataValidation:{mode:"Mode",range:"Cell Range",criteria:"Criteria",modeType:{cell:"Cell",column:"Colun",row:"Row"},type:{list:"List",number:"Number",date:"Date",phone:"Phone",email:"Email"},operator:{be:"between",nbe:"not betwwen",lt:"less than",lte:"less than or equal to",gt:"greater than",gte:"greater than or equal to",eq:"equal to",neq:"not equal to"}}}};function wi(g,I){if(I)for(const C of ui){if(!I[C])break;let A=I[C];const i=g.match(/(?:\\.|[^.])+/g);for(let g=0;gWi(g)}function Vi(g,I,C=!1){C?ui=[g]:ui.unshift(g),I&&(Bi[g]=I)}const yi={phone:/^[1-9]\d{10}$/,email:/w+([-+.]w+)*@w+([-.]w+)*.w+([-.]w+)*/};function Xi(g,I,...C){let A="";return g||(A=Wi(`validation.${I}`,...C)),[g,A]}class Yi{constructor(g,I,C,A){this.required=I,this.value=C,this.type=g,this.operator=A,this.message=""}parseValue(g){const{type:I}=this;return"date"===I?new Date(g):"number"===I?Number(g):g}equals(g){let I=this.type===g.type&&this.required===g.required&&this.operator===g.operator;return I&&(I=Array.isArray(this.value)?mi.arrayEquals(this.value,g.value):this.value===g.value),I}values(){return this.value.split(",")}validate(g){const{required:I,operator:C,value:A,type:i}=this;if(I&&/^\s*$/.test(g))return Xi(!1,"required");if(/^\s*$/.test(g))return[!0];if(yi[i]&&!yi[i].test(g))return Xi(!1,"notMatch");if("list"===i)return Xi(this.values().includes(g),"notIn");if(C){const I=this.parseValue(g);if("be"===C){const[g,C]=A;return Xi(I>=this.parseValue(g)&&I<=this.parseValue(C),"between",g,C)}if("nbe"===C){const[g,C]=A;return Xi(Ithis.parseValue(C),"notBetween",g,C)}if("eq"===C)return Xi(I===this.parseValue(A),"equal",A);if("neq"===C)return Xi(I!==this.parseValue(A),"notEqual",A);if("lt"===C)return Xi(Ithis.parseValue(A),"greaterThan",A);if("gte"===C)return Xi(I>=this.parseValue(A),"greaterThanEqual",A)}return[!0]}}class Ri{constructor(g,I,C){this.refs=I,this.mode=g,this.validator=C}includes(g,I){const{refs:C}=this;for(let A=0;A{const A=ei.valueOf(C);if(A.intersects(g)){A.difference(g).forEach((g=>I.push(g.toString())))}else I.push(C)})),this.refs=I}getData(){const{refs:g,mode:I,validator:C}=this,{type:A,required:i,operator:e,value:l}=C;return{refs:g,mode:I,type:A,required:i,operator:e,value:l}}static valueOf({refs:g,mode:I,type:C,required:A,operator:i,value:e}){return new Ri(I,g,new Yi(C,A,e,i))}}class Ni{constructor(){this._=[],this.errors=new Map}getError(g,I){return this.errors.get(`${g}_${I}`)}validate(g,I,C){const A=this.get(g,I),i=`${g}_${I}`,{errors:e}=this;if(null!==A){const[g,I]=A.validator.validate(C);g?e.delete(i):e.set(i,I)}else e.delete(i);return!0}add(g,I,{type:C,required:A,value:i,operator:e}){const l=new Yi(C,A,i,e),t=this.getByValidator(l);null!==t?t.addRef(I):this._.push(new Ri(g,[I],l))}getByValidator(g){for(let I=0;I{I.remove(g)}))}each(g){this._.forEach((I=>g(I)))}getData(){return this._.filter((g=>g.refs.length>0)).map((g=>g.getData()))}setData(g){this._=g.map((g=>Ri.valueOf(g)))}}const Hi={mode:"edit",view:{height:()=>document.documentElement.clientHeight,width:()=>document.documentElement.clientWidth},showGrid:!0,showToolbar:!0,showContextmenu:!0,showBottomBar:!0,row:{len:100,height:25},col:{len:26,width:100,indexWidth:60,minWidth:60},style:{bgcolor:"#ffffff",align:"left",valign:"middle",textwrap:!1,strike:!1,underline:!1,color:"#0a0a0a",font:{name:"Arial",size:10,bold:!1,italic:!1},format:"normal"}},Ki=(g,I)=>Object.prototype.hasOwnProperty.call(g,I);function Fi(g,I,C=(()=>{})){const{merges:A}=this,i=I.clone(),[e,l]=g.size(),[t,s]=I.size();return e>t&&(i.eri=I.sri+e-1),l>s&&(i.eci=I.sci+l-1),!A.intersects(i)||(C(Wi("error.pasteForMergedCell")),!1)}function Mi(g,I,C,A=!1){const{rows:i,merges:e}=this;"all"!==C&&"format"!==C||(i.deleteCells(I,C),e.deleteWithin(I)),i.copyPaste(g,I,C,A,((g,I,C)=>{if(C&&C.merge){const[A,i]=C.merge;if(A<=0&&i<=0)return;e.add(new ei(g,I,g+A,I+i))}}))}function Ji(g,I){const{clipboard:C,rows:A,merges:i}=this;A.cutPaste(g,I),i.move(g,I.sri-g.sri,I.sci-g.sci),C.clear()}function Si(g,I,C){const{styles:A,rows:i}=this,e=i.getCellOrNew(g,I);let l={};void 0!==e.style&&(l=mi.cloneDeep(A[e.style])),l=mi.merge(l,{border:C}),e.style=this.addStyle(l)}function fi({mode:g,style:I,color:C}){const{styles:A,selector:i,rows:e}=this,{sri:l,sci:t,eri:s,eci:c}=i.range,d=!this.isSignleSelected();if(d||"inside"!==g&&"horizontal"!==g&&"vertical"!==g)if("outside"!==g||d){if("none"===g)i.range.each(((g,I)=>{const C=e.getCell(g,I);if(C&&void 0!==C.style){const g=mi.cloneDeep(A[C.style]);delete g.border,C.style=this.addStyle(g)}}));else if("all"===g||"inside"===g||"outside"===g||"horizontal"===g||"vertical"===g){const A=[];for(let i=l;i<=s;i+=1)for(let o=t;o<=c;o+=1){const n=[];for(let g=0;gA.splice(g,1))),o>c)break;const a=e.getCell(i,o);let[Z,b]=[0,0];a&&a.merge&&([Z,b]=a.merge,A.push([i,o,Z,b]));const r=Z>0&&i+Z===s,m=b>0&&o+b===c;let h={};"all"===g?h={bottom:[I,C],top:[I,C],left:[I,C],right:[I,C]}:"inside"===g?(!m&&o0&&Si.call(this,i,o,h),o+=b}}else if("top"===g||"bottom"===g)for(let o=t;o<=c;o+=1)"top"===g&&(Si.call(this,l,o,{top:[I,C]}),o+=e.getCellMerge(l,o)[1]),"bottom"===g&&(Si.call(this,s,o,{bottom:[I,C]}),o+=e.getCellMerge(s,o)[1]);else if("left"===g||"right"===g)for(let o=l;o<=s;o+=1)"left"===g&&(Si.call(this,o,t,{left:[I,C]}),o+=e.getCellMerge(o,t)[0]),"right"===g&&(Si.call(this,o,c,{right:[I,C]}),o+=e.getCellMerge(o,c)[0])}else Si.call(this,l,t,{top:[I,C],bottom:[I,C],left:[I,C],right:[I,C]})}function ki(g,I){const{rows:C}=this,A=this.freezeTotalHeight();let i=C.height;A+C.heightg);l+=1)e.has(l)||(s=C.getHeight(l),t+=s);return t-=s,t<=0?{ri:-1,top:0,height:s}:{ri:l-1,top:t,height:s}}function Di(g,I){const{cols:C}=this,A=this.freezeTotalWidth();let i=C.indexWidth;A+C.indexWidthC.getWidth(g)));return l<=0?{ci:-1,left:0,width:C.indexWidth}:{ci:e-1,left:l,width:t}}class Li{constructor(g,I){this.settings=mi.merge(Hi,I||{}),this.name=g||"sheet",this.freeze=[0,0],this.styles=[],this.merges=new ai,this.rows=new hi(this.settings.row),this.cols=new Gi(this.settings.col),this.validations=new Ni,this.hyperlinks={},this.comments={},this.selector=new li,this.scroll=new ti,this.history=new si,this.clipboard=new ci,this.autoFilter=new ni,this.change=()=>{},this.exceptRowSet=new Set,this.sortedRowMap=new Map,this.unsortedRowMap=new Map}addValidation(g,I,C){this.changeData((()=>{this.validations.add(g,I,C)}))}removeValidation(){const{range:g}=this.selector;this.changeData((()=>{this.validations.remove(g)}))}getSelectedValidator(){const{ri:g,ci:I}=this.selector,C=this.validations.get(g,I);return C?C.validator:null}getSelectedValidation(){const{ri:g,ci:I,range:C}=this.selector,A=this.validations.get(g,I),i={ref:C.toString()};return null!==A&&(i.mode=A.mode,i.validator=A.validator),i}canUndo(){return this.history.canUndo()}canRedo(){return this.history.canRedo()}undo(){this.history.undo(this.getData(),(g=>{this.setData(g)}))}redo(){this.history.redo(this.getData(),(g=>{this.setData(g)}))}copy(){this.clipboard.copy(this.selector.range)}copyToSystemClipboard(){if(void 0===navigator.clipboard)return;let g="";const I=this.rows.getData();for(let C=this.selector.range.sri;C<=this.selector.range.eri;C+=1){if(Ki(I,C)){for(let A=this.selector.range.sci;A<=this.selector.range.eci;A+=1)if(A>this.selector.range.sci&&(g+="\t"),Ki(I[C].cells,A)){const i=String(I[C].cells[A].text);-1===i.indexOf("\n")&&-1===i.indexOf("\t")&&-1===i.indexOf('"')?g+=i:g+=`"${i}"`}}else for(let I=this.selector.range.sci;I<=this.selector.range.eci;I+=1)g+="\t";g+="\n"}navigator.clipboard.writeText(g).then((()=>{}),(g=>{}))}cut(){this.clipboard.cut(this.selector.range)}paste(g="all",I=(()=>{})){const{clipboard:C,selector:A}=this;return!C.isClear()&&(!!Fi.call(this,C.range,A.range,I)&&(this.changeData((()=>{C.isCopy()?Mi.call(this,C.range,A.range,g):C.isCut()&&Ji.call(this,C.range,A.range)})),!0))}pasteFromText(g){const I=g.split("\r\n").map((g=>g.replace(/"/g,"").split("\t")));I.length>0&&(I.length-=1);const{rows:C,selector:A}=this;this.changeData((()=>{C.paste(I,A.range)}))}autofill(g,I,C=(()=>{})){const A=this.selector.range;return!!Fi.call(this,A,g,C)&&(this.changeData((()=>{Mi.call(this,A,g,I,!0)})),!0)}clearClipboard(){this.clipboard.clear()}calSelectedRangeByEnd(g,I){const{selector:C,rows:A,cols:i,merges:e}=this;let{sri:l,sci:t,eri:s,eci:c}=C.range;const d=C.ri,o=C.ci;let[n,a]=[g,I];return g<0&&(n=A.len-1),I<0&&(a=i.len-1),[l,s]=n>d?[d,n]:[n,d],[t,c]=a>o?[o,a]:[a,o],C.range=e.union(new ei(l,t,s,c)),C.range=e.union(C.range),C.range}calSelectedRangeByStart(g,I){const{selector:C,rows:A,cols:i,merges:e}=this;let l=e.getFirstIncludes(g,I);return null===l&&(l=new ei(g,I,g,I),-1===g&&(l.sri=0,l.eri=A.len-1),-1===I&&(l.sci=0,l.eci=i.len-1)),C.range=l,l}setSelectedCellAttr(g,I){this.changeData((()=>{const{selector:C,styles:A,rows:i}=this;if("merge"===g)I?this.merge():this.unmerge();else if("border"===g)fi.call(this,I);else if("formula"===g){const{ri:g,ci:A,range:e}=C;if(C.multiple()){const[A,l]=C.size(),{sri:t,sci:s,eri:c,eci:d}=e;if(A>1)for(let g=s;g<=d;g+=1){i.getCellOrNew(c+1,g).text=`=${I}(${Ai(g,t)}:${Ai(g,c)})`}else if(l>1){i.getCellOrNew(g,d+1).text=`=${I}(${Ai(s,g)}:${Ai(d,g)})`}}else{i.getCellOrNew(g,A).text=`=${I}()`}}else C.range.each(((C,e)=>{const l=i.getCellOrNew(C,e);let t={};if(void 0!==l.style&&(t=mi.cloneDeep(A[l.style])),"format"===g)t.format=I,l.style=this.addStyle(t);else if("font-bold"===g||"font-italic"===g||"font-name"===g||"font-size"===g){const C={};C[g.split("-")[1]]=I,t.font=Object.assign(t.font||{},C),l.style=this.addStyle(t)}else"strike"===g||"textwrap"===g||"underline"===g||"align"===g||"valign"===g||"color"===g||"bgcolor"===g?(t[g]=I,l.style=this.addStyle(t)):l[g]=I}))}))}setSelectedCellText(g,I="input"){const{autoFilter:C,selector:A,rows:i}=this,{ri:e,ci:l}=A;let t=e;this.unsortedRowMap.has(e)&&(t=this.unsortedRowMap.get(e));const s=i.getCell(t,l),c=s?s.text:"";if(this.setCellText(t,l,g,I),C.active()){const I=C.getFilter(l);if(I){const C=I.value.findIndex((g=>g===c));C>=0&&I.value.splice(C,1,g)}}}getSelectedCell(){const{ri:g,ci:I}=this.selector;let C=g;return this.unsortedRowMap.has(g)&&(C=this.unsortedRowMap.get(g)),this.rows.getCell(C,I)}xyInSelectedRect(g,I){const{left:C,top:A,width:i,height:e}=this.getSelectedRect(),l=g-this.cols.indexWidth,t=I-this.rows.height;return l>C&&lA&&t0&&r>c&&(a=c),b>0&&b>d&&(Z=d),{l:c,t:d,left:a,top:Z,height:o,width:n,scroll:I}}getCellRectByXY(g,I){const{scroll:C,merges:A,rows:i,cols:e}=this;let{ri:l,top:t,height:s}=ki.call(this,I,C.y),{ci:c,left:d,width:o}=Di.call(this,g,C.x);if(-1===c&&(o=e.totalWidth()),-1===l&&(s=i.totalHeight()),l>=0||c>=0){const g=A.getFirstIncludes(l,c);g&&(l=g.sri,c=g.sci,({left:d,top:t,width:o,height:s}=this.cellRect(l,c)))}return{ri:l,ci:c,left:d,top:t,width:o,height:s}}isSignleSelected(){const{sri:g,sci:I,eri:C,eci:A}=this.selector.range,i=this.getCell(g,I);if(i&&i.merge){const[e,l]=i.merge;if(g+e===C&&I+l===A)return!0}return!this.selector.multiple()}canUnmerge(){const{sri:g,sci:I,eri:C,eci:A}=this.selector.range,i=this.getCell(g,I);if(i&&i.merge){const[e,l]=i.merge;if(g+e===C&&I+l===A)return!0}return!1}merge(){const{selector:g,rows:I}=this;if(this.isSignleSelected())return;const[C,A]=g.size();if(C>1||A>1){const{sri:i,sci:e}=g.range;this.changeData((()=>{const l=I.getCellOrNew(i,e);l.merge=[C-1,A-1],this.merges.add(g.range),this.rows.deleteCells(g.range),this.rows.setCell(i,e,l)}))}}unmerge(){const{selector:g}=this;if(!this.isSignleSelected())return;const{sri:I,sci:C}=g.range;this.changeData((()=>{this.rows.deleteCell(I,C,"merge"),this.merges.deleteWithin(g.range)}))}canAutofilter(){return!this.autoFilter.active()}autofilter(){const{autoFilter:g,selector:I}=this;this.changeData((()=>{g.active()?(g.clear(),this.exceptRowSet=new Set,this.sortedRowMap=new Map,this.unsortedRowMap=new Map):g.ref=I.range.toString()}))}setAutoFilter(g,I,C,A){const{autoFilter:i}=this;i.addFilter(g,C,A),i.setSort(g,I),this.resetAutoFilter()}resetAutoFilter(){const{autoFilter:g,rows:I}=this;if(!g.active())return;const{sort:C}=g,{rset:A,fset:i}=g.filteredRows(((g,C)=>I.getCell(g,C))),e=Array.from(i),l=Array.from(i);C&&e.sort(((g,I)=>"asc"===C.order?g-I:"desc"===C.order?I-g:0)),this.exceptRowSet=A,this.sortedRowMap=new Map,this.unsortedRowMap=new Map,e.forEach(((g,I)=>{this.sortedRowMap.set(l[I],g),this.unsortedRowMap.set(g,l[I])}))}deleteCell(g="all"){const{selector:I}=this;this.changeData((()=>{this.rows.deleteCells(I.range,g),"all"!==g&&"format"!==g||this.merges.deleteWithin(I.range)}))}insert(g,I=1){this.changeData((()=>{const{sri:C,sci:A}=this.selector.range,{rows:i,merges:e,cols:l}=this;let t=C;"row"===g?i.insert(C,I):"column"===g&&(i.insertColumn(A,I),t=A,l.len+=1),e.shift(g,t,I,((g,I,C,A)=>{const e=i.getCell(g,I);e.merge[0]+=C,e.merge[1]+=A}))}))}delete(g){this.changeData((()=>{const{rows:I,merges:C,selector:A,cols:i}=this,{range:e}=A,{sri:l,sci:t,eri:s,eci:c}=A.range,[d,o]=A.range.size();let n=l,a=d;"row"===g?I.delete(l,s):"column"===g&&(I.deleteColumn(t,c),n=e.sci,a=o,i.len-=1),C.shift(g,n,-a,((g,C,A,i)=>{const e=I.getCell(g,C);e.merge[0]+=A,e.merge[1]+=i,0===e.merge[0]&&0===e.merge[1]&&delete e.merge}))}))}scrollx(g,I){const{scroll:C,freeze:A,cols:i}=this,[,e]=A,[l,t,s]=mi.rangeReduceIf(e,i.len,0,0,g,(g=>i.getWidth(g)));let c=t;g>0&&(c+=s),C.x!==c&&(C.ci=g>0?l:0,C.x=c,I())}scrolly(g,I){const{scroll:C,freeze:A,rows:i}=this,[e]=A,[l,t,s]=mi.rangeReduceIf(e,i.len,0,0,g,(g=>i.getHeight(g)));let c=t;g>0&&(c+=s),C.y!==c&&(C.ri=g>0?l:0,C.y=c,I())}cellRect(g,I){const{rows:C,cols:A}=this,i=A.sumWidth(0,I),e=C.sumHeight(0,g),l=C.getCell(g,I);let t=A.getWidth(I),s=C.getHeight(g);if(null!==l&&l.merge){const[i,e]=l.merge;if(i>0)for(let I=1;I<=i;I+=1)s+=C.getHeight(g+I);if(e>0)for(let g=1;g<=e;g+=1)t+=A.getWidth(I+g)}return{left:i,top:e,width:t,height:s,cell:l}}getCell(g,I){return this.rows.getCell(g,I)}getCellTextOrDefault(g,I){const C=this.getCell(g,I);return C&&C.text?C.text:""}getCellStyle(g,I){const C=this.getCell(g,I);return C&&void 0!==C.style?this.styles[C.style]:null}getCellStyleOrDefault(g,I){const{styles:C,rows:A}=this,i=A.getCell(g,I),e=i&&void 0!==i.style?C[i.style]:{};return mi.merge(this.defaultStyle(),e)}getSelectedCellStyle(){const{ri:g,ci:I}=this.selector;return this.getCellStyleOrDefault(g,I)}setCellText(g,I,C,A){const{rows:i,history:e,validations:l}=this;"finished"===A?(i.setCellText(g,I,""),e.add(this.getData()),i.setCellText(g,I,C)):(i.setCellText(g,I,C),this.change(this.getData())),l.validate(g,I,C)}freezeIsActive(){const[g,I]=this.freeze;return g>0||I>0}setFreeze(g,I){this.changeData((()=>{this.freeze=[g,I]}))}freezeTotalWidth(){return this.cols.sumWidth(0,this.freeze[1])}freezeTotalHeight(){return this.rows.sumHeight(0,this.freeze[0])}setRowHeight(g,I){this.changeData((()=>{this.rows.setHeight(g,I)}))}setColWidth(g,I){this.changeData((()=>{this.cols.setWidth(g,I)}))}viewHeight(){const{view:g,showToolbar:I,showBottomBar:C}=this.settings;let A=g.height();return C&&(A-=41),I&&(A-=41),A}viewWidth(){return this.settings.view.width()}freezeViewRange(){const[g,I]=this.freeze;return new ei(0,0,g-1,I-1,this.freezeTotalWidth(),this.freezeTotalHeight())}contentRange(){const{rows:g,cols:I}=this,[C,A]=g.maxCell(),i=g.sumHeight(0,C+1),e=I.sumWidth(0,A+1);return new ei(0,0,C,A,e,i)}exceptRowTotalHeight(g,I){const{exceptRowSet:C,rows:A}=this,i=Array.from(C);let e=0;return i.forEach((C=>{if(CI){const g=A.getHeight(C);e+=g}})),e}viewRange(){const{scroll:g,rows:I,cols:C,freeze:A,exceptRowSet:i}=this;let{ri:e,ci:l}=g;e<=0&&([e]=A),l<=0&&([,l]=A);let[t,s]=[0,0],[c,d]=[I.len,C.len];for(let o=e;othis.viewHeight()));o+=1);for(let o=l;othis.viewWidth()));o+=1);return new ei(e,l,c,d,t,s)}eachMergesInView(g,I){this.merges.filterIntersects(g).forEach((g=>I(g)))}hideRowsOrCols(){const{rows:g,cols:I,selector:C}=this,[A,i]=C.size(),{sri:e,sci:l,eri:t,eci:s}=C.range;if(A===g.len)for(let c=l;c<=s;c+=1)I.setHide(c,!0);else if(i===I.len)for(let c=e;c<=t;c+=1)g.setHide(c,!0)}unhideRowsOrCols(g,I){this[`${g}s`].unhide(I)}rowEach(g,I,C){let A=0;const{rows:i}=this,e=this.exceptRowSet,l=[...e];let t=0;for(let s=0;s0&&(C(s,A,g),A+=g,A>this.viewHeight()))break}}colEach(g,I,C){let A=0;const{cols:i}=this;for(let e=g;e<=I;e+=1){const g=i.getWidth(e);if(g>0&&(C(e,A,g),A+=g,A>this.viewWidth()))break}}defaultStyle(){return this.settings.style}addStyle(g){const{styles:I}=this;for(let C=0;C{if("merges"===I||"rows"===I||"cols"===I||"validations"===I)this[I].setData(g[I]);else if("freeze"===I){const[C,A]=Ci(g[I]);this.freeze=[A,C]}else"autofilter"===I?this.autoFilter.setData(g[I]):void 0!==g[I]&&(this[I]=g[I])})),this}getData(){const{name:g,freeze:I,styles:C,merges:A,rows:i,cols:e,validations:l,autoFilter:t}=this;return{name:g,freeze:Ai(I[1],I[0]),styles:C,merges:A.getData(),rows:i.getData(),cols:e.getData(),validations:l.getData(),autofilter:t.getData()}}}function zi(g,I,C){g.addEventListener(I,C)}function vi(g,I,C){g.removeEventListener(I,C)}function Ti(g){g.xclickoutside&&(vi(window.document.body,"click",g.xclickoutside),delete g.xclickoutside)}function xi(g,I){g.xclickoutside=C=>{2===C.detail||g.contains(C.target)||(I?I(g):(g.hide(),Ti(g)))},zi(window.document.body,"click",g.xclickoutside)}function Ui(g,I,C){zi(g,"mousemove",I);g.xEvtUp=A=>{vi(g,"mousemove",I),vi(g,"mouseup",g.xEvtUp),C(A)},zi(g,"mouseup",g.xEvtUp)}function Qi(g,I,C,A){let i="";Math.abs(g)>Math.abs(I)?(i=g>0?"right":"left",A(i,g,C)):(i=I>0?"down":"up",A(i,I,C))}const ji="x-spreadsheet";class Oi{constructor(g=!1,I){this.moving=!1,this.vertical=g,this.el=qA("div",`${ji}-resizer ${g?"vertical":"horizontal"}`).children(this.unhideHoverEl=qA("div",`${ji}-resizer-hover`).on("dblclick.stop",(g=>this.mousedblclickHandler(g))).css("position","absolute").hide(),this.hoverEl=qA("div",`${ji}-resizer-hover`).on("mousedown.stop",(g=>this.mousedownHandler(g))),this.lineEl=qA("div",`${ji}-resizer-line`).hide()).hide(),this.cRect=null,this.finishedFn=null,this.minDistance=I,this.unhideFn=()=>{}}showUnhide(g){this.unhideIndex=g,this.unhideHoverEl.show()}hideUnhide(){this.unhideHoverEl.hide()}show(g,I){const{moving:C,vertical:A,hoverEl:i,lineEl:e,el:l,unhideHoverEl:t}=this;if(C)return;this.cRect=g;const{left:s,top:c,width:d,height:o}=g;l.offset({left:A?s+d-5:s,top:A?c:c+o-5}).show(),i.offset({width:A?5:d,height:A?o:5}),e.offset({width:A?0:I.width,height:A?I.height:0}),t.offset({left:A?5-d:s,top:A?c:5-o,width:A?5:d,height:A?o:5})}hide(){this.el.offset({left:0,top:0}).hide(),this.hideUnhide()}mousedblclickHandler(){this.unhideIndex&&this.unhideFn(this.unhideIndex)}mousedownHandler(g){let I=g;const{el:C,lineEl:A,cRect:i,vertical:e,minDistance:l}=this;let t=e?i.width:i.height;A.show(),Ui(window,(g=>{this.moving=!0,null!==I&&1===g.buttons&&(e?(t+=g.movementX,t>l&&C.css("left",`${i.left+t}px`)):(t+=g.movementY,t>l&&C.css("top",`${i.top+t}px`)),I=g)}),(()=>{I=null,A.hide(),this.moving=!1,this.hide(),this.finishedFn&&(t{})).on("scroll.stop",(g=>{const{scrollTop:I,scrollLeft:C}=g.target;this.moveFn&&this.moveFn(this.vertical?I:C,g)}))}move(g){return this.el.scroll(g),this}scroll(){return this.el.scroll()}set(g,I){const C=g-1;if(I>C){const g=this.vertical?"height":"width";this.el.css(g,C-15+"px").show(),this.contentEl.css(this.vertical?"width":"height","1px").css(g,`${I}px`)}else this.el.hide();return this}}let Pi=10;class _i{constructor(g=!1){this.useHideInput=g,this.inputChange=()=>{},this.cornerEl=qA("div",`${ji}-selector-corner`),this.areaEl=qA("div",`${ji}-selector-area`).child(this.cornerEl).hide(),this.clipboardEl=qA("div",`${ji}-selector-clipboard`).hide(),this.autofillEl=qA("div",`${ji}-selector-autofill`).hide(),this.el=qA("div",`${ji}-selector`).css("z-index",`${Pi}`).children(this.areaEl,this.clipboardEl,this.autofillEl).hide(),g&&(this.hideInput=qA("input","").on("compositionend",(g=>{this.inputChange(g.target.value)})),this.el.child(this.hideInputDiv=qA("div","hide-input").child(this.hideInput)),this.el.child(this.hideInputDiv=qA("div","hide-input").child(this.hideInput))),Pi+=1}setOffset(g){return this.el.offset(g).show(),this}hide(){return this.el.hide(),this}setAreaOffset(g){const{left:I,top:C,width:A,height:i}=g,e={width:A-3+.8,height:i-3+.8,left:I-.8,top:C-.8};this.areaEl.offset(e).show(),this.useHideInput&&(this.hideInputDiv.offset(e),this.hideInput.val("").focus())}setClipboardOffset(g){const{left:I,top:C,width:A,height:i}=g;this.clipboardEl.offset({left:I,top:C,width:A-5,height:i-5})}showAutofill(g){const{left:I,top:C,width:A,height:i}=g;this.autofillEl.offset({width:A-3,height:i-3,left:I,top:C}).show()}hideAutofill(){this.autofillEl.hide()}showClipboard(){this.clipboardEl.show()}hideClipboard(){this.clipboardEl.hide()}}function qi(g){const{data:I}=this,{left:C,top:A,width:i,height:e,scroll:l,l:t,t:s}=g,c=I.freezeTotalWidth(),d=I.freezeTotalHeight();let o=C-c;c>t&&(o-=l.x);let n=A-d;return d>s&&(n-=l.y),{left:o,top:n,width:i,height:e}}function $i(g){const{data:I}=this,{left:C,width:A,height:i,l:e,t:l,scroll:t}=g,s=I.freezeTotalWidth();let c=C-s;return s>e&&(c-=t.x),{left:c,top:l,width:A,height:i}}function ge(g){const{data:I}=this,{top:C,width:A,height:i,l:e,t:l,scroll:t}=g,s=I.freezeTotalHeight();let c=C-s;return s>l&&(c-=t.y),{left:e,top:c,width:A,height:i}}function Ie(g){const{br:I}=this;I.setAreaOffset(qi.call(this,g))}function Ce(g){const{tl:I}=this;I.setAreaOffset(g)}function Ae(g){const{t:I}=this;I.setAreaOffset($i.call(this,g))}function ie(g){const{l:I}=this;I.setAreaOffset(ge.call(this,g))}function ee(g){const{l:I}=this;I.setClipboardOffset(ge.call(this,g))}function le(g){const{br:I}=this;I.setClipboardOffset(qi.call(this,g))}function te(g){const{tl:I}=this;I.setClipboardOffset(g)}function se(g){const{t:I}=this;I.setClipboardOffset($i.call(this,g))}function ce(g){Ie.call(this,g),Ce.call(this,g),Ae.call(this,g),ie.call(this,g)}function de(g){le.call(this,g),te.call(this,g),se.call(this,g),ee.call(this,g)}class oe{constructor(g){this.inputChange=()=>{},this.data=g,this.br=new _i(!0),this.t=new _i,this.l=new _i,this.tl=new _i,this.br.inputChange=g=>{this.inputChange(g)},this.br.el.show(),this.offset=null,this.areaOffset=null,this.indexes=null,this.range=null,this.arange=null,this.el=qA("div",`${ji}-selectors`).children(this.tl.el,this.t.el,this.l.el,this.br.el).hide(),this.lastri=-1,this.lastci=-1,Pi+=1}resetData(g){this.data=g,this.range=g.selector.range,this.resetAreaOffset()}hide(){this.el.hide()}resetOffset(){const{data:g,tl:I,t:C,l:A,br:i}=this,e=g.freezeTotalHeight(),l=g.freezeTotalWidth();e>0||l>0?(I.setOffset({width:l,height:e}),C.setOffset({left:l,height:e}),A.setOffset({top:e,width:l}),i.setOffset({left:l,top:e})):(I.hide(),C.hide(),A.hide(),i.setOffset({left:0,top:0}))}resetAreaOffset(){const g=this.data.getSelectedRect(),I=this.data.getClipboardRect();ce.call(this,g),de.call(this,I),this.resetOffset()}resetBRTAreaOffset(){const g=this.data.getSelectedRect(),I=this.data.getClipboardRect();Ie.call(this,g),Ae.call(this,g),le.call(this,I),se.call(this,I),this.resetOffset()}resetBRLAreaOffset(){const g=this.data.getSelectedRect(),I=this.data.getClipboardRect();Ie.call(this,g),ie.call(this,g),le.call(this,I),ee.call(this,I),this.resetOffset()}set(g,I,C=!0){const{data:A}=this,i=A.calSelectedRangeByStart(g,I),{sri:e,sci:l}=i;if(C){let[C,i]=[g,I];g<0&&(C=0),I<0&&(i=0),A.selector.setIndexes(C,i),this.indexes=[C,i]}this.moveIndexes=[e,l],this.range=i,this.resetAreaOffset(),this.el.show()}setEnd(g,I,C=!0){const{data:A,lastri:i,lastci:e}=this;if(C){if(g===i&&I===e)return;this.lastri=g,this.lastci=I}this.range=A.calSelectedRangeByEnd(g,I),ce.call(this,this.data.getSelectedRect())}reset(){const{eri:g,eci:I}=this.data.selector.range;this.setEnd(g,I)}showAutofill(g,I){if(-1===g&&-1===I)return;const{sri:C,sci:A,eri:i,eci:e}=this.range,[l,t]=[g,I],s=C-g,c=i-g,d=e-I;if(A-I>0)this.arange=new ei(C,t,i,A-1);else if(s>0)this.arange=new ei(l,A,C-1,e);else if(d<0)this.arange=new ei(C,e+1,i,t);else{if(!(c<0))return void(this.arange=null);this.arange=new ei(i+1,A,l,e)}if(null!==this.arange){const g=this.data.getRect(this.arange);g.width+=2,g.height+=2;const{br:I,l:C,t:A,tl:i}=this;I.showAutofill(qi.call(this,g)),C.showAutofill(ge.call(this,g)),A.showAutofill($i.call(this,g)),i.showAutofill(g)}}hideAutofill(){["br","l","t","tl"].forEach((g=>{this[g].hideAutofill()}))}showClipboard(){const g=this.data.getClipboardRect();de.call(this,g),["br","l","t","tl"].forEach((g=>{this[g].showClipboard()}))}hideClipboard(){["br","l","t","tl"].forEach((g=>{this[g].hideClipboard()}))}}function ne(g){g.preventDefault(),g.stopPropagation();const{filterItems:I}=this;I.length<=0||(this.itemIndex>=0&&I[this.itemIndex].toggle(),this.itemIndex-=1,this.itemIndex<0&&(this.itemIndex=I.length-1),I[this.itemIndex].toggle())}function ae(g){g.stopPropagation();const{filterItems:I}=this;I.length<=0||(this.itemIndex>=0&&I[this.itemIndex].toggle(),this.itemIndex+=1,this.itemIndex>I.length-1&&(this.itemIndex=0),I[this.itemIndex].toggle())}function Ze(g){g.preventDefault();const{filterItems:I}=this;I.length<=0||(g.stopPropagation(),this.itemIndex<0&&(this.itemIndex=0),I[this.itemIndex].el.click(),this.hide())}function be(g){const{keyCode:I}=g;switch(g.ctrlKey&&g.stopPropagation(),I){case 37:case 39:default:g.stopPropagation();break;case 38:ne.call(this,g);break;case 40:ae.call(this,g);break;case 13:case 9:Ze.call(this,g)}}class re{constructor(g,I,C="200px"){this.filterItems=[],this.items=g,this.el=qA("div",`${ji}-suggest`).css("width",C).hide(),this.itemClick=I,this.itemIndex=-1}setOffset(g){this.el.cssRemoveKeys("top","bottom").offset(g)}hide(){const{el:g}=this;this.filterItems=[],this.itemIndex=-1,g.hide(),Ti(this.el.parent())}setItems(g){this.items=g}search(g){let{items:I}=this;if(/^\s*$/.test(g)||(I=I.filter((I=>(I.key||I).startsWith(g.toUpperCase())))),I=I.map((g=>{let{title:I}=g;I?"function"==typeof I&&(I=I()):I=g;const C=qA("div",`${ji}-item`).child(I).on("click.stop",(()=>{this.itemClick(g),this.hide()}));return g.label&&C.child(qA("div","label").html(g.label)),C})),this.filterItems=I,I.length<=0)return;const{el:C}=this;C.html("").children(...I).show(),xi(C.parent(),(()=>{this.hide()}))}bindInputEvents(g){g.on("keydown",(g=>be.call(this,g)))}}class me extends _A{constructor(g){super("div",`${ji}-icon`),this.iconNameEl=qA("div",`${ji}-icon-img ${g}`),this.child(this.iconNameEl)}setName(g){this.iconNameEl.className(`${ji}-icon-img ${g}`)}}function he(g,I){g.setMonth(g.getMonth()+I)}function Ge(g,I){const C=new Date(g);return C.setDate(I-g.getDay()+1),C}class ue{constructor(g){this.value=g,this.cvalue=new Date(g),this.headerLeftEl=qA("div","calendar-header-left"),this.bodyEl=qA("tbody",""),this.buildAll(),this.el=qA("div","x-spreadsheet-calendar").children(qA("div","calendar-header").children(this.headerLeftEl,qA("div","calendar-header-right").children(qA("a","calendar-prev").on("click.stop",(()=>this.prev())).child(new me("chevron-left")),qA("a","calendar-next").on("click.stop",(()=>this.next())).child(new me("chevron-right")))),qA("table","calendar-body").children(qA("thead","").child(qA("tr","").children(...Wi("calendar.weeks").map((g=>qA("th","cell").child(g))))),this.bodyEl)),this.selectChange=()=>{}}setValue(g){this.value=g,this.cvalue=new Date(g),this.buildAll()}prev(){const{value:g}=this;he(g,-1),this.buildAll()}next(){const{value:g}=this;he(g,1),this.buildAll()}buildAll(){this.buildHeaderLeft(),this.buildBody()}buildHeaderLeft(){const{value:g}=this;this.headerLeftEl.html(`${Wi("calendar.months")[g.getMonth()]} ${g.getFullYear()}`)}buildBody(){const{value:g,cvalue:I,bodyEl:C}=this,A=function(g,I,C){const A=new Date(g,I,1,23,59,59),i=[[],[],[],[],[],[]];for(let e=0;e<6;e+=1)for(let g=0;g<7;g+=1){const l=Ge(A,7*e+g),t=l.getMonth()!==I,s=l.getMonth()===C.getMonth()&&l.getDate()===C.getDate();i[e][g]={d:l,disabled:t,active:s}}return i}(g.getFullYear(),g.getMonth(),I).map((g=>{const I=g.map((g=>{let I="cell";return g.disabled&&(I+=" disabled"),g.active&&(I+=" active"),qA("td","").child(qA("div",I).on("click.stop",(()=>{this.selectChange(g.d)})).child(g.d.getDate().toString()))}));return qA("tr","").children(...I)}));C.html("").children(...A)}}class Be{constructor(){this.calendar=new ue(new Date),this.el=qA("div",`${ji}-datepicker`).child(this.calendar.el).hide()}setValue(g){const{calendar:I}=this;return"string"==typeof g?/^\d{4}-\d{1,2}-\d{1,2}$/.test(g)&&I.setValue(new Date(g.replace(new RegExp("-","g"),"/"))):g instanceof Date&&I.setValue(g),this}change(g){this.calendar.selectChange=I=>{g(I),this.hide()}}show(){this.el.show()}hide(){this.el.hide()}}function we(){const{inputText:g}=this;if(!/^\s*$/.test(g)){const{textlineEl:I,textEl:C,areaOffset:A}=this,i=g.split("\n"),e=Math.max(...i.map((g=>g.length))),l=I.offset().width/g.length,t=(e+1)*l+5,s=this.viewFn().width-A.left-l;let c=i.length;if(t>A.width){let g=t;t>s&&(g=s,c+=parseInt(t/s,10),c+=t%s>0?1:0),C.css("width",`${g}px`)}c*=this.rowHeight,c>A.height&&C.css("height",`${c}px`)}}function We({target:g},I){const{value:C,selectionEnd:A}=g,i=`${C.slice(0,A)}${I}${C.slice(A)}`;g.value=i,g.setSelectionRange(A+1,A+1),this.inputText=i,this.textlineEl.html(i),we.call(this)}function pe(g){const{keyCode:I,altKey:C}=g;13!==I&&9!==I&&g.stopPropagation(),13===I&&C&&(We.call(this,g,"\n"),g.stopPropagation()),13!==I||C||g.preventDefault()}function Ve(g){const I=g.target.value,{suggest:C,textlineEl:A,validator:i}=this,{cell:e}=this;if(null!==e)if("editable"in e&&!0===e.editable||void 0===e.editable){if(this.inputText=I,i)"list"===i.type?C.search(I):C.hide();else{const g=I.lastIndexOf("=");-1!==g?C.search(I.substring(g+1)):C.hide()}A.html(I),we.call(this),this.change("input",I)}else g.target.value=e.text;else{if(this.inputText=I,i)"list"===i.type?C.search(I):C.hide();else{const g=I.lastIndexOf("=");-1!==g?C.search(I.substring(g+1)):C.hide()}A.html(I),we.call(this),this.change("input",I)}}function ye(g){const{el:I}=this.textEl;setTimeout((()=>{I.focus(),I.setSelectionRange(g,g)}),0)}function Xe(g,I){const{textEl:C,textlineEl:A}=this;C.el.blur(),C.val(g),A.html(g),ye.call(this,I)}function Ye(g){const{inputText:I,validator:C}=this;let A=0;if(C&&"list"===C.type)this.inputText=g,A=this.inputText.length;else{const C=I.lastIndexOf("="),i=I.substring(0,C+1);let e=I.substring(C+1);e=-1!==e.indexOf(")")?e.substring(e.indexOf(")")):"",this.inputText=`${i+g.key}(`,A=this.inputText.length,this.inputText+=`)${e}`}Xe.call(this,this.inputText,A)}function Re(){this.suggest.setItems(this.formulas)}class Ne{constructor(g,I,C){this.viewFn=I,this.rowHeight=C,this.formulas=g,this.suggest=new re(g,(g=>{Ye.call(this,g)})),this.datepicker=new Be,this.datepicker.change((g=>{this.setText(function(g){let I=g.getMonth()+1,C=g.getDate();return I<10&&(I=`0${I}`),C<10&&(C=`0${C}`),`${g.getFullYear()}-${I}-${C}`}(g)),this.clear()})),this.areaEl=qA("div",`${ji}-editor-area`).children(this.textEl=qA("textarea","").on("input",(g=>Ve.call(this,g))).on("paste.stop",(()=>{})).on("keydown",(g=>pe.call(this,g))),this.textlineEl=qA("div","textline"),this.suggest.el,this.datepicker.el).on("mousemove.stop",(()=>{})).on("mousedown.stop",(()=>{})),this.el=qA("div",`${ji}-editor`).child(this.areaEl).hide(),this.suggest.bindInputEvents(this.textEl),this.areaOffset=null,this.freeze={w:0,h:0},this.cell=null,this.inputText="",this.change=()=>{}}setFreezeLengths(g,I){this.freeze.w=g,this.freeze.h=I}clear(){""!==this.inputText&&this.change("finished",this.inputText),this.cell=null,this.areaOffset=null,this.inputText="",this.el.hide(),this.textEl.val(""),this.textlineEl.html(""),Re.call(this),this.datepicker.hide()}setOffset(g,I="top"){const{textEl:C,areaEl:A,suggest:i,freeze:e,el:l}=this;if(g){this.areaOffset=g;const{left:t,top:s,width:c,height:d,l:o,t:n}=g,a={left:0,top:0};e.w>o&&e.h>n||(e.wo?a.top=e.h:e.h>n&&(a.left=e.w)),l.offset(a),A.offset({left:t-a.left-.8,top:s-a.top-.8}),C.offset({width:c-9+.8,height:d-3+.8});const Z={left:0};Z[I]=d,i.setOffset(Z),i.hide()}}setCell(g,I){const{el:C,datepicker:A,suggest:i}=this;C.show(),this.cell=g;const e=g&&g.text||"";if(this.setText(e),this.validator=I,I){const{type:g}=I;"date"===g&&(A.show(),/^\s*$/.test(e)||A.setValue(e)),"list"===g&&(i.setItems(I.values()),i.search(""))}}setText(g){this.inputText=g,Xe.call(this,g,g.length),we.call(this)}}class He extends _A{constructor(g,I=""){super("div",`${ji}-button ${I}`),this.child(Wi(`button.${g}`))}}function Ke(){return window.devicePixelRatio||1}function Fe(){return Ke()-.5}function Me(g){return parseInt(g*Ke(),10)}function Je(g){const I=Me(g);return I>0?I-.5:.5}class Se{constructor(g,I,C,A,i=0){this.x=g,this.y=I,this.width=C,this.height=A,this.padding=i,this.bgcolor="#ffffff",this.borderTop=null,this.borderRight=null,this.borderBottom=null,this.borderLeft=null}setBorders({top:g,bottom:I,left:C,right:A}){g&&(this.borderTop=g),A&&(this.borderRight=A),I&&(this.borderBottom=I),C&&(this.borderLeft=C)}innerWidth(){return this.width-2*this.padding-2}innerHeight(){return this.height-2*this.padding-2}textx(g){const{width:I,padding:C}=this;let{x:A}=this;return"left"===g?A+=C:"center"===g?A+=I/2:"right"===g&&(A+=I-C),A}texty(g,I){const{height:C,padding:A}=this;let{y:i}=this;return"top"===g?i+=A:"middle"===g?i+=C/2-I/2:"bottom"===g&&(i+=C-A-I),i}topxys(){const{x:g,y:I,width:C}=this;return[[g,I],[g+C,I]]}rightxys(){const{x:g,y:I,width:C,height:A}=this;return[[g+C,I],[g+C,I+A]]}bottomxys(){const{x:g,y:I,width:C,height:A}=this;return[[g,I+A],[g+C,I+A]]}leftxys(){const{x:g,y:I,height:C}=this;return[[g,I],[g,I+C]]}}function fe(g,I,C,A,i,e,l){const t={x:0,y:0};"underline"===g?t.y="bottom"===i?0:"top"===i?-(e+2):-e/2:"strike"===g&&("bottom"===i?t.y=e/2:"top"===i&&(t.y=-(e/2+2))),"center"===A?t.x=l/2:"right"===A&&(t.x=l),this.line([I-t.x,C-t.y],[I-t.x+l,C-t.y])}class ke{constructor(g,I,C){this.el=g,this.ctx=g.getContext("2d"),this.resize(I,C),this.ctx.scale(Ke(),Ke())}resize(g,I){this.el.style.width=`${g}px`,this.el.style.height=`${I}px`,this.el.width=Me(g),this.el.height=Me(I)}clear(){const{width:g,height:I}=this.el;return this.ctx.clearRect(0,0,g,I),this}attr(g){return Object.assign(this.ctx,g),this}save(){return this.ctx.save(),this.ctx.beginPath(),this}restore(){return this.ctx.restore(),this}beginPath(){return this.ctx.beginPath(),this}translate(g,I){return this.ctx.translate(Me(g),Me(I)),this}scale(g,I){return this.ctx.scale(g,I),this}clearRect(g,I,C,A){return this.ctx.clearRect(g,I,C,A),this}fillRect(g,I,C,A){return this.ctx.fillRect(Me(g)-.5,Me(I)-.5,Me(C),Me(A)),this}fillText(g,I,C){return this.ctx.fillText(g,Me(I),Me(C)),this}text(g,I,C={},A=!0){const{ctx:i}=this,{align:e,valign:l,font:t,color:s,strike:c,underline:d}=C,o=I.textx(e);i.save(),i.beginPath(),this.attr({textAlign:e,textBaseline:l,font:`${t.italic?"italic":""} ${t.bold?"bold":""} ${Me(t.size)}px ${t.name}`,fillStyle:s,strokeStyle:s});const n=`${g}`.split("\n"),a=I.innerWidth(),Z=[];n.forEach((g=>{const I=i.measureText(g).width;if(A&&I>Me(a)){let I={w:0,len:0,start:0};for(let C=0;C=Me(a)&&(Z.push(g.substr(I.start,I.len)),I={w:0,len:0,start:C}),I.len+=1,I.w+=i.measureText(g[C]).width+1;I.len>0&&Z.push(g.substr(I.start,I.len))}else Z.push(g)}));const b=(Z.length-1)*(t.size+2);let r=I.texty(l,b);return Z.forEach((g=>{const I=i.measureText(g).width;this.fillText(g,o,r),c&&fe.call(this,"strike",o,r,e,l,t.size,I),d&&fe.call(this,"underline",o,r,e,l,t.size,I),r+=t.size+2})),i.restore(),this}border(g,I){const{ctx:C}=this;return C.lineWidth=Fe,C.strokeStyle=I,"medium"===g?C.lineWidth=Me(2)-.5:"thick"===g?C.lineWidth=Me(3):"dashed"===g?C.setLineDash([Me(3),Me(2)]):"dotted"===g?C.setLineDash([Me(1),Me(1)]):"double"===g&&C.setLineDash([Me(2),0]),this}line(...g){const{ctx:I}=this;if(g.length>1){I.beginPath();const[C,A]=g[0];I.moveTo(Je(C),Je(A));for(let i=1;i{const[C]=g;let A=g;if('"'===C)return g.substring(1);let i=1;if("-"===C&&(A=g.substring(1),i=-1),A[0]>="0"&&A[0]<="9")return i*Number(A);const[e,l]=Ci(A);return i*I(e,l)},ve=(g,I,C,A=[])=>{if("="===g[0]){const i=(g=>{const I=[],C=[];let A=[],i=0,e="",l=1,t="";for(let c=0;c="a"&&d<="z")A.push(d.toUpperCase());else if(d>="0"&&d<="9"||d>="A"&&d<="Z"||"."===d)A.push(d);else if('"'===d){for(c+=1;'"'!==g.charAt(c);)A.push(g.charAt(c)),c+=1;C.push(`"${A.join("")}`),A=[]}else if("-"===d&&/[+\-*/,(]/.test(t))A.push(d);else{if("("!==d&&A.length>0&&C.push(A.join("")),")"===d){let g=I.pop();if(2===i)try{const[I,A]=Ci(C.pop()),[i,e]=Ci(C.pop());let l=0;for(let g=i;g<=I;g+=1)for(let I=e;I<=A;I+=1)C.push(Ai(g,I)),l+=1;C.push([g,l])}catch(s){}else if(1===i||3===i)3===i&&C.push(e),C.push([g,l]),l=1;else for(;"("!==g&&(C.push(g),!(I.length<=0));)g=I.pop();i=0}else if("="===d||">"===d||"<"===d){const I=g.charAt(c+1);e=d,"="!==I&&"-"!==I||(e+=I,c+=1),i=3}else if(":"===d)i=2;else if(","===d)3===i&&C.push(e),i=1,l+=1;else if("("===d&&A.length>0)I.push(A.join(""));else{if(I.length>0&&("+"===d||"-"===d)){let g=I[I.length-1];if("("!==g&&C.push(I.pop()),"*"===g||"/"===g)for(;I.length>0&&(g=I[I.length-1],"("!==g);)C.push(I.pop())}else if(I.length>0){const g=I[I.length-1];"*"!==g&&"/"!==g||C.push(I.pop())}I.push(d)}A=[]}t=d}}for(A.length>0&&C.push(A.join(""));I.length>0;)C.push(I.pop());return C})(g.substring(1));return i.length<=0?g:((g,I,C,A)=>{const i=[];for(let e=0;e"===t||"<"===t){let g=i.pop();Number.isNaN(g)||(g=Number(g));let I=i.pop();Number.isNaN(I)||(I=Number(I));let C=!1;"="===t?C=I===g:">"===l?C=I>g:">="===l?C=I>=g:"<"===l?C=I="a"&&t<="z"||t>="A"&&t<="Z")&&A.push(l),i.push(ze(l,C)),A.pop()}}return i[0]})(i,I,((g,i)=>ve(C(g,i),I,C,A)),A)}return g},Te={render:ve},xe=[{key:"SUM",title:pi("formula.sum"),render:g=>g.reduce(((g,I)=>ri("+",g,I)),0)},{key:"AVERAGE",title:pi("formula.average"),render:g=>g.reduce(((g,I)=>Number(g)+Number(I)),0)/g.length},{key:"MAX",title:pi("formula.max"),render:g=>Math.max(...g.map((g=>Number(g))))},{key:"MIN",title:pi("formula.min"),render:g=>Math.min(...g.map((g=>Number(g))))},{key:"IF",title:pi("formula._if"),render:([g,I,C])=>g?I:C},{key:"AND",title:pi("formula.and"),render:g=>g.every((g=>g))},{key:"OR",title:pi("formula.or"),render:g=>g.some((g=>g))},{key:"CONCAT",title:pi("formula.concat"),render:g=>g.join("")}],Ue=xe,Qe={};xe.forEach((g=>{Qe[g.key]=g}));const je=g=>g,Oe=g=>{if(/^(-?\d*.?\d*)$/.test(g)){const I=Number(g).toFixed(2).toString(),[C,...A]=I.split("\\.");return[C.replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1,"),...A]}return g},Ee=[{key:"normal",title:pi("format.normal"),type:"string",render:je},{key:"text",title:pi("format.text"),type:"string",render:je},{key:"number",title:pi("format.number"),type:"number",label:"1,000.12",render:Oe},{key:"percent",title:pi("format.percent"),type:"number",label:"10.12%",render:g=>`${g}%`},{key:"rmb",title:pi("format.rmb"),type:"number",label:"¥10.00",render:g=>`¥${Oe(g)}`},{key:"usd",title:pi("format.usd"),type:"number",label:"$10.00",render:g=>`$${Oe(g)}`},{key:"eur",title:pi("format.eur"),type:"number",label:"€10.00",render:g=>`€${Oe(g)}`},{key:"date",title:pi("format.date"),type:"date",label:"26/09/2008",render:je},{key:"time",title:pi("format.time"),type:"date",label:"15:59:00",render:je},{key:"datetime",title:pi("format.datetime"),type:"date",label:"26/09/2008 15:59:00",render:je},{key:"duration",title:pi("format.duration"),type:"date",label:"24:01:00",render:je}],Pe={};Ee.forEach((g=>{Pe[g.key]=g}));const _e=5,qe={fillStyle:"#f4f5f8"},$e={fillStyle:"#fff",lineWidth:Fe,strokeStyle:"#e6e6e6"};function gl(g,I,C,A=0){const{left:i,top:e,width:l,height:t}=g.cellRect(I,C);return new Se(i,e+A,l,t,_e)}function Il(g,I,C,A,i=0){const{sortedRowMap:e,rows:l,cols:t}=I;if(l.isHide(C)||t.isHide(A))return;let s=C;e.has(C)&&(s=e.get(C));const c=I.getCell(s,A);if(null===c)return;let d=!1;"editable"in c&&!1===c.editable&&(d=!0);const o=I.getCellStyleOrDefault(s,A),n=gl(I,C,A,i);n.bgcolor=o.bgcolor,void 0!==o.border&&(n.setBorders(o.border),g.strokeBorders(n)),g.rect(n,(()=>{let i="";i=I.settings.evalPaused?c.text||"":Te.render(c.text||"",Qe,((g,C)=>I.getCellTextOrDefault(C,g))),o.format&&(i=Pe[o.format].render(i));const e=Object.assign({},o.font);e.size=function(g){for(let I=0;I{const i=gl(I,g,A);C.dropdown(i)}))}}function Al(g,I,C,A,i){const{draw:e,data:l}=this;e.save(),e.translate(I,C).translate(A,i);const{exceptRowSet:t}=l,s=l.exceptRowTotalHeight(g.sri,g.eri);e.save(),e.translate(0,-s),g.each(((g,I)=>{Il(e,l,g,I)}),(g=>(g=>{const I=t.has(g);if(I){const I=l.rows.getHeight(g);e.translate(0,-I)}return!I})(g))),e.restore();const c=new Set;e.save(),e.translate(0,-s),l.eachMergesInView(g,(({sri:g,sci:I,eri:C})=>{if(t.has(g)){if(!c.has(g)){c.add(g);const I=l.rows.sumHeight(g,C+1);e.translate(0,-I)}}else Il(e,l,g,I)})),e.restore(),Cl.call(this,g),e.restore()}function il(g,I,C,A){const{draw:i}=this;i.save(),i.attr({fillStyle:"rgba(75, 137, 255, 0.08)"}).fillRect(g,I,C,A),i.restore()}function el(g,I,C,A,i,e){const{draw:l,data:t}=this,s=I.h,c=I.w,d=e+A,o=i+C;l.save(),l.attr(qe),"all"!==g&&"left"!==g||l.fillRect(0,d,C,s),"all"!==g&&"top"!==g||l.fillRect(o,0,c,A);const{sri:n,sci:a,eri:Z,eci:b}=t.selector.range;l.attr({textAlign:"center",textBaseline:"middle",font:`500 ${Me(12)}px Source Sans Pro`,fillStyle:"#585757",lineWidth:Fe(),strokeStyle:"#e6e6e6"}),"all"!==g&&"left"!==g||(t.rowEach(I.sri,I.eri,((g,I,A)=>{const i=d+I,e=g;l.line([0,i],[C,i]),n<=e&&e0&&t.rows.isHide(g-1)&&(l.save(),l.attr({strokeStyle:"#c6c6c6"}),l.line([5,i+5],[C-5,i+5]),l.restore())})),l.line([0,s+d],[C,s+d]),l.line([C,d],[C,s+d])),"all"!==g&&"top"!==g||(t.colEach(I.sci,I.eci,((g,I,C)=>{const i=o+I,e=g;l.line([i,0],[i,A]),a<=e&&e0&&t.cols.isHide(g-1)&&(l.save(),l.attr({strokeStyle:"#c6c6c6"}),l.line([i+5,5],[i+5,A-5]),l.restore())})),l.line([c+o,0],[c+o,A]),l.line([0,A],[c+o,A])),l.restore()}function ll(g,I){const{draw:C}=this;C.save(),C.attr({fillStyle:"#f4f5f8"}).fillRect(0,0,g,I),C.restore()}function tl({sri:g,sci:I,eri:C,eci:A,w:i,h:e},l,t,s,c){const{draw:d,data:o}=this,{settings:n}=o;d.save(),d.attr($e).translate(l+s,t+c),n.showGrid?(o.rowEach(g,C,((I,A,e)=>{I!==g&&d.line([0,A],[i,A]),I===C&&d.line([0,A+e],[i,A+e])})),o.colEach(I,A,((g,C,i)=>{g!==I&&d.line([C,0],[C,e]),g===A&&d.line([C+i,0],[C+i,e])})),d.restore()):d.restore()}function sl(g,I,C,A){const{draw:i,data:e}=this,l=e.viewWidth()-g,t=e.viewHeight()-I;i.save().translate(g,I).attr({strokeStyle:"rgba(75, 137, 255, .6)"}),i.line([0,A],[l,A]),i.line([C,0],[C,t]),i.restore()}class cl{constructor(g,I){this.el=g,this.draw=new ke(g,I.viewWidth(),I.viewHeight()),this.data=I}resetData(g){this.data=g,this.render()}render(){const{data:g}=this,{rows:I,cols:C}=g,A=C.indexWidth,i=I.height;this.draw.resize(g.viewWidth(),g.viewHeight()),this.clear();const e=g.viewRange(),l=g.freezeTotalWidth(),t=g.freezeTotalHeight(),{x:s,y:c}=g.scroll;tl.call(this,e,A,i,l,t),Al.call(this,e,A,i,-s,-c),el.call(this,"all",e,A,i,l,t),ll.call(this,A,i);const[d,o]=g.freeze;if(d>0||o>0){if(d>0){const g=e.clone();g.sri=0,g.eri=d-1,g.h=t,tl.call(this,g,A,i,l,0),Al.call(this,g,A,i,-s,0),el.call(this,"top",g,A,i,l,0)}if(o>0){const g=e.clone();g.sci=0,g.eci=o-1,g.w=l,tl.call(this,g,A,i,0,t),el.call(this,"left",g,A,i,0,t),Al.call(this,g,A,i,0,-c)}const I=g.freezeViewRange();tl.call(this,I,A,i,0,0),el.call(this,"all",I,A,i,0,0),Al.call(this,I,A,i,0,0),sl.call(this,A,i,l,t)}}clear(){this.draw.clear()}}const dl=[["A3",11.69,16.54],["A4",8.27,11.69],["A5",5.83,8.27],["B4",9.84,13.9],["B5",6.93,9.84]],ol=["landscape","portrait"];function nl(g){return parseInt(96*g,10)}function al(g){"cancel"===g?this.el.hide():this.toPrint()}function Zl(g){const{paper:I}=this,{value:C}=g.target,A=dl[C];I.w=nl(A[1]),I.h=nl(A[2]),this.preview()}function bl(g){const{paper:I}=this,{value:C}=g.target,A=ol[C];I.orientation=A,this.preview()}let rl=class{constructor(g){this.paper={w:nl(dl[0][1]),h:nl(dl[0][2]),padding:50,orientation:ol[0],get width(){return"landscape"===this.orientation?this.h:this.w},get height(){return"landscape"===this.orientation?this.w:this.h}},this.data=g,this.el=qA("div",`${ji}-print`).children(qA("div",`${ji}-print-bar`).children(qA("div","-title").child("Print settings"),qA("div","-right").children(qA("div",`${ji}-buttons`).children(new He("cancel").on("click",al.bind(this,"cancel")),new He("next","primary").on("click",al.bind(this,"next"))))),qA("div",`${ji}-print-content`).children(this.contentEl=qA("div","-content"),qA("div","-sider").child(qA("form","").children(qA("fieldset","").children(qA("label","").child(`${Wi("print.size")}`),qA("select","").children(...dl.map(((g,I)=>qA("option","").attr("value",I).child(`${g[0]} ( ${g[1]}''x${g[2]}'' )`)))).on("change",Zl.bind(this))),qA("fieldset","").children(qA("label","").child(`${Wi("print.orientation")}`),qA("select","").children(...ol.map(((g,I)=>qA("option","").attr("value",I).child(`${Wi("print.orientations")[I]}`)))).on("change",bl.bind(this))))))).hide()}resetData(g){this.data=g}preview(){const{data:g,paper:I}=this,{width:C,height:A,padding:i}=I,e=C-2*i,l=A-2*i,t=g.contentRange(),s=parseInt(t.h/l,10)+1,c=e/t.w;let d=i;const o=i;c>1&&(d+=(e-t.w)/2);let n=0,a=0;this.contentEl.html(""),this.canvases=[];const Z={sri:0,sci:0,eri:0,eci:0};for(let b=0;b{Il(b,g,I,C,r)})),b.restore(),Z.sri=Z.eri,Z.sci=Z.eci,a+=i,this.contentEl.child(qA("div",`${ji}-canvas-card-wraper`).child(e.child(s)))}this.el.show()}toPrint(){this.el.hide();const{paper:g}=this,I=qA("iframe","").hide(),{el:C}=I;window.document.body.appendChild(C);const{contentWindow:A}=C,i=A.document,e=document.createElement("style");e.innerHTML=`\n @page { size: ${g.width}px ${g.height}px; };\n canvas {\n page-break-before: auto; \n page-break-after: always;\n image-rendering: pixelated;\n };\n `,i.head.appendChild(e),this.canvases.forEach((g=>{const I=g.cloneNode(!1);I.getContext("2d").drawImage(g,0,0),i.body.appendChild(I)})),A.print()}};const ml=[{key:"copy",title:pi("contextmenu.copy"),label:"Ctrl+C"},{key:"cut",title:pi("contextmenu.cut"),label:"Ctrl+X"},{key:"paste",title:pi("contextmenu.paste"),label:"Ctrl+V"},{key:"paste-value",title:pi("contextmenu.pasteValue"),label:"Ctrl+Shift+V"},{key:"paste-format",title:pi("contextmenu.pasteFormat"),label:"Ctrl+Alt+V"},{key:"divider"},{key:"insert-row",title:pi("contextmenu.insertRow")},{key:"insert-column",title:pi("contextmenu.insertColumn")},{key:"divider"},{key:"delete-row",title:pi("contextmenu.deleteRow")},{key:"delete-column",title:pi("contextmenu.deleteColumn")},{key:"delete-cell-text",title:pi("contextmenu.deleteCellText")},{key:"hide",title:pi("contextmenu.hide")},{key:"divider"},{key:"validation",title:pi("contextmenu.validation")},{key:"divider"},{key:"cell-printable",title:pi("contextmenu.cellprintable")},{key:"cell-non-printable",title:pi("contextmenu.cellnonprintable")},{key:"divider"},{key:"cell-editable",title:pi("contextmenu.celleditable")},{key:"cell-non-editable",title:pi("contextmenu.cellnoneditable")}];function hl(g){return"divider"===g.key?qA("div",`${ji}-item divider`):qA("div",`${ji}-item`).on("click",(()=>{this.itemClick(g.key),this.hide()})).children(g.title(),qA("div","label").child(g.label||""))}function Gl(){return ml.map((g=>hl.call(this,g)))}let ul=class{constructor(g,I=!1){this.menuItems=Gl.call(this),this.el=qA("div",`${ji}-contextmenu`).children(...this.menuItems).hide(),this.viewFn=g,this.itemClick=()=>{},this.isHide=I,this.setMode("range")}setMode(g){const I=this.menuItems[12];"row-col"===g?I.show():I.hide()}hide(){const{el:g}=this;g.hide(),Ti(g)}setPosition(g,I){if(this.isHide)return;const{el:C}=this,{width:A}=C.show().offset(),i=this.viewFn(),e=i.height/2;let l=g;i.width-g<=A&&(l-=A),C.css("left",`${l}px`),I>e?C.css("bottom",i.height-I+"px").css("max-height",`${I}px`).css("top","auto"):C.css("top",`${I}px`).css("max-height",i.height-I+"px").css("bottom","auto"),xi(C)}};class Bl{constructor(g,I,C){this.tip=Wi(`toolbar.${g.replace(/-[a-z]/g,(g=>g[1].toUpperCase()))}`),I&&(this.tip+=` (${I})`),this.tag=g,this.shortcut=I,this.value=C,this.el=this.element(),this.change=()=>{}}element(){const{tip:g}=this;return qA("div",`${ji}-toolbar-btn`).on("mouseenter",(I=>{!function(g,I){if(I.classList.contains("active"))return;const{left:C,top:A,width:i,height:e}=I.getBoundingClientRect(),l=qA("div",`${ji}-tooltip`).html(g).show();document.body.appendChild(l.el);const t=l.box();l.css("left",C+i/2-t.width/2+"px").css("top",`${A+e+2}px`),zi(I,"mouseleave",(()=>{document.body.contains(l.el)&&document.body.removeChild(l.el)})),zi(I,"click",(()=>{document.body.contains(l.el)&&document.body.removeChild(l.el)}))}(g,I.target)})).attr("data-tooltip",g)}setState(){}}class wl extends Bl{dropdown(){}getValue(g){return g}element(){const{tag:g}=this;return this.dd=this.dropdown(),this.dd.change=I=>this.change(g,this.getValue(I)),super.element().child(this.dd)}setState(g){g&&(this.value=g,this.dd.setTitle(g))}}class Wl extends _A{constructor(g,I,C,A,...i){super("div",`${ji}-dropdown ${A}`),this.title=g,this.change=()=>{},this.headerClick=()=>{},"string"==typeof g?this.title=qA("div",`${ji}-dropdown-title`).child(g):C&&this.title.addClass("arrow-left"),this.contentEl=qA("div",`${ji}-dropdown-content`).css("width",I).hide(),this.setContentChildren(...i),this.headerEl=qA("div",`${ji}-dropdown-header`),this.headerEl.on("click",(()=>{"block"!==this.contentEl.css("display")?this.show():this.hide()})).children(this.title,C?qA("div",`${ji}-icon arrow-right`).child(qA("div",`${ji}-icon-img arrow-down`)):""),this.children(this.headerEl,this.contentEl)}setContentChildren(...g){this.contentEl.html(""),g.length>0&&this.contentEl.children(...g)}setTitle(g){this.title.html(g),this.hide()}show(){const{contentEl:g}=this;g.show(),this.parent().active(),xi(this.parent(),(()=>{this.hide()}))}hide(){this.parent().active(!1),this.contentEl.hide(),Ti(this.parent())}}class pl extends Wl{constructor(g,I){super(new me(`align-${I}`),"auto",!0,"bottom-left",...g.map((g=>{return(I=`align-${g}`,qA("div",`${ji}-item`).child(new me(I))).on("click",(()=>{this.setTitle(g),this.change(g)}));var I})))}setTitle(g){this.title.setName(`align-${g}`),this.hide()}}class Vl extends wl{constructor(g){super("align","",g)}dropdown(){const{value:g}=this;return new pl(["left","center","right"],g)}}class yl extends wl{constructor(g){super("valign","",g)}dropdown(){const{value:g}=this;return new pl(["top","middle","bottom"],g)}}class Xl extends Bl{element(){const{tag:g}=this;return super.element().child(new me(g)).on("click",(()=>this.click()))}click(){this.change(this.tag,this.toggle())}setState(g){this.el.active(g)}toggle(){return this.el.toggle()}active(){return this.el.hasClass("active")}}class Yl extends Xl{constructor(){super("autofilter")}setState(){}}class Rl extends Xl{constructor(){super("font-bold","Ctrl+B")}}class Nl extends Xl{constructor(){super("font-italic","Ctrl+I")}}class Hl extends Xl{constructor(){super("strike","Ctrl+U")}}class Kl extends Xl{constructor(){super("underline","Ctrl+U")}}const Fl=["#ffffff","#000100","#e7e5e6","#445569","#5b9cd6","#ed7d31","#a5a5a5","#ffc001","#4371c6","#71ae47"],Ml=[["#f2f2f2","#7f7f7f","#d0cecf","#d5dce4","#deeaf6","#fce5d5","#ededed","#fff2cd","#d9e2f3","#e3efd9"],["#d8d8d8","#595959","#afabac","#adb8ca","#bdd7ee","#f7ccac","#dbdbdb","#ffe59a","#b3c6e7","#c5e0b3"],["#bfbfbf","#3f3f3f","#756f6f","#8596b0","#9cc2e6","#f4b184","#c9c9c9","#fed964","#8eaada","#a7d08c"],["#a5a5a5","#262626","#3a3839","#333f4f","#2e75b5","#c45a10","#7b7b7b","#bf8e01","#2f5596","#538136"],["#7f7f7f","#0c0c0c","#171516","#222a35","#1f4e7a","#843c0a","#525252","#7e6000","#203864","#365624"]],Jl=["#c00000","#fe0000","#fdc101","#ffff01","#93d051","#00b04e","#01b0f1","#0170c1","#012060","#7030a0"];function Sl(g){return qA("td","").child(qA("div",`${ji}-color-palette-cell`).on("click.stop",(()=>this.change(g))).css("background-color",g))}class fl{constructor(){this.el=qA("div",`${ji}-color-palette`),this.change=()=>{};const g=qA("table","").children(qA("tbody","").children(qA("tr",`${ji}-theme-color-placeholders`).children(...Fl.map((g=>Sl.call(this,g)))),...Ml.map((g=>qA("tr",`${ji}-theme-colors`).children(...g.map((g=>Sl.call(this,g)))))),qA("tr",`${ji}-standard-colors`).children(...Jl.map((g=>Sl.call(this,g))))));this.el.child(g)}}class kl extends Wl{constructor(g,I){const C=new me(g).css("height","16px").css("border-bottom",`3px solid ${I}`),A=new fl;A.change=g=>{this.setTitle(g),this.change(g)},super(C,"auto",!1,"bottom-left",A.el)}setTitle(g){this.title.css("border-color",g),this.hide()}}const Dl=[["thin",''],["medium",''],["thick",''],["dashed",''],["dotted",'']];class Ll extends Wl{constructor(g){const I=new me("line-type");let C=0;const A=Dl.map(((I,i)=>qA("div",`${ji}-item state ${g===I[0]?"checked":""}`).on("click",(()=>{A[C].toggle("checked"),A[i].toggle("checked"),C=i,this.hide(),this.change(I)})).child(qA("div",`${ji}-line-type`).html(I[1]))));super(I,"auto",!1,"bottom-left",...A)}}function zl(...g){return qA("table","").child(qA("tbody","").children(...g))}function vl(g){return qA("td","").child(qA("div",`${ji}-border-palette-cell`).child(new me(`border-${g}`)).on("click",(()=>{this.mode=g;const{mode:I,style:C,color:A}=this;this.change({mode:I,style:C,color:A})})))}class Tl{constructor(){this.color="#000",this.style="thin",this.mode="all",this.change=()=>{},this.ddColor=new kl("line-color",this.color),this.ddColor.change=g=>{this.color=g},this.ddType=new Ll(this.style),this.ddType.change=([g])=>{this.style=g},this.el=qA("div",`${ji}-border-palette`);const g=zl(qA("tr","").children(qA("td",`${ji}-border-palette-left`).child(zl(qA("tr","").children(...["all","inside","horizontal","vertical","outside"].map((g=>vl.call(this,g)))),qA("tr","").children(...["left","top","right","bottom","none"].map((g=>vl.call(this,g)))))),qA("td",`${ji}-border-palette-right`).children(qA("div",`${ji}-toolbar-btn`).child(this.ddColor.el),qA("div",`${ji}-toolbar-btn`).child(this.ddType.el))));this.el.child(g)}}class xl extends Wl{constructor(){const g=new me("border-all"),I=new Tl;I.change=g=>{this.change(g),this.hide()},super(g,"auto",!1,"bottom-left",I.el)}}class Ul extends wl{constructor(){super("border")}dropdown(){return new xl}}class Ql extends Bl{element(){return super.element().child(new me(this.tag)).on("click",(()=>this.change(this.tag)))}setState(g){this.el.disabled(g)}}class jl extends Ql{constructor(){super("clearformat")}}class Ol extends Xl{constructor(){super("paintformat")}setState(){}}class El extends wl{constructor(g){super("color",void 0,g)}dropdown(){const{tag:g,value:I}=this;return new kl(g,I)}}class Pl extends wl{constructor(g){super("bgcolor",void 0,g)}dropdown(){const{tag:g,value:I}=this;return new kl(g,I)}}class _l extends Wl{constructor(){super("10","60px",!0,"bottom-left",...Le.map((g=>qA("div",`${ji}-item`).on("click",(()=>{this.setTitle(`${g.pt}`),this.change(g)})).child(`${g.pt}`))))}}let ql=class extends wl{constructor(){super("font-size")}getValue(g){return g.pt}dropdown(){return new _l}};class $l extends Wl{constructor(){const g=De.map((g=>qA("div",`${ji}-item`).on("click",(()=>{this.setTitle(g.title),this.change(g)})).child(g.title)));super(De[0].title,"160px",!0,"bottom-left",...g)}}class gt extends wl{constructor(){super("font-name")}getValue(g){return g.key}dropdown(){return new $l}}class It extends Wl{constructor(){let g=Ee.slice(0);g.splice(2,0,{key:"divider"}),g.splice(8,0,{key:"divider"}),g=g.map((g=>{const I=qA("div",`${ji}-item`);return"divider"===g.key?I.addClass("divider"):(I.child(g.title()).on("click",(()=>{this.setTitle(g.title()),this.change(g)})),g.label&&I.child(qA("div","label").html(g.label))),I})),super("Normal","220px",!0,"bottom-left",...g)}setTitle(g){for(let I=0;IqA("div",`${ji}-item`).on("click",(()=>{this.hide(),this.change(g)})).child(g.key)));super(new me("formula"),"180px",!0,"bottom-left",...g)}}class it extends wl{constructor(){super("formula")}getValue(g){return g.key}dropdown(){return new At}}class et extends Xl{constructor(){super("freeze")}}class lt extends Xl{constructor(){super("merge")}setState(g,I){this.el.active(g).disabled(I)}}class tt extends Ql{constructor(){super("redo","Ctrl+Y")}}class st extends Ql{constructor(){super("undo","Ctrl+Z")}}class ct extends Ql{constructor(){super("print","Ctrl+P")}}class dt extends Xl{constructor(){super("textwrap")}}let ot=class extends Wl{constructor(){const g=new me("ellipsis"),I=qA("div",`${ji}-toolbar-more`);super(g,"auto",!1,"bottom-right",I),this.moreBtns=I,this.contentEl.css("max-width","420px")}};class nt extends wl{constructor(){super("more"),this.el.hide()}dropdown(){return new ot}show(){this.el.show()}hide(){this.el.hide()}}function at(){return qA("div",`${ji}-toolbar-divider`)}function Zt(){this.btns2=[],this.items.forEach((g=>{if(Array.isArray(g))g.forEach((({el:g})=>{const I=g.box(),{marginLeft:C,marginRight:A}=g.computedStyle();this.btns2.push([g,I.width+parseInt(C,10)+parseInt(A,10)])}));else{const I=g.box(),{marginLeft:C,marginRight:A}=g.computedStyle();this.btns2.push([g,I.width+parseInt(C,10)+parseInt(A,10)])}}))}function bt(){const{el:g,btns:I,moreEl:C,btns2:A}=this,{moreBtns:i,contentEl:e}=C.dd;g.css("width",this.widthFn()-60+"px");const l=g.box();let t=160,s=12;const c=[],d=[];A.forEach((([g,I],C)=>{t+=I,C===A.length-1||t0?C.show():C.hide()}class rt{constructor(g,I,C=!1){this.data=g,this.change=()=>{},this.widthFn=I,this.isHide=C;const A=g.defaultStyle();this.items=[[this.undoEl=new st,this.redoEl=new tt,new ct,this.paintformatEl=new Ol,this.clearformatEl=new jl],at(),[this.formatEl=new Ct],at(),[this.fontEl=new gt,this.fontSizeEl=new ql],at(),[this.boldEl=new Rl,this.italicEl=new Nl,this.underlineEl=new Kl,this.strikeEl=new Hl,this.textColorEl=new El(A.color)],at(),[this.fillColorEl=new Pl(A.bgcolor),this.borderEl=new Ul,this.mergeEl=new lt],at(),[this.alignEl=new Vl(A.align),this.valignEl=new yl(A.valign),this.textwrapEl=new dt],at(),[this.freezeEl=new et,this.autofilterEl=new Yl,this.formulaEl=new it,this.moreEl=new nt]],this.el=qA("div",`${ji}-toolbar`),this.btns=qA("div",`${ji}-toolbar-btns`),this.items.forEach((g=>{Array.isArray(g)?g.forEach((g=>{this.btns.child(g.el),g.change=(...g)=>{this.change(...g)}})):this.btns.child(g.el)})),this.el.child(this.btns),C?this.el.hide():(this.reset(),setTimeout((()=>{Zt.call(this),bt.call(this)}),0),zi(window,"resize",(()=>{bt.call(this)})))}paintformatActive(){return this.paintformatEl.active()}paintformatToggle(){this.paintformatEl.toggle()}trigger(g){this[`${g}El`].click()}resetData(g){this.data=g,this.reset()}reset(){if(this.isHide)return;const{data:g}=this,I=g.getSelectedCellStyle();this.undoEl.setState(!g.canUndo()),this.redoEl.setState(!g.canRedo()),this.mergeEl.setState(g.canUnmerge(),!g.selector.multiple()),this.autofilterEl.setState(!g.canAutofilter());const{font:C,format:A}=I;this.formatEl.setState(A),this.fontEl.setState(C.name),this.fontSizeEl.setState(C.size),this.boldEl.setState(C.bold),this.italicEl.setState(C.italic),this.underlineEl.setState(I.underline),this.strikeEl.setState(I.strike),this.textColorEl.setState(I.color),this.fillColorEl.setState(I.bgcolor),this.alignEl.setState(I.align),this.valignEl.setState(I.valign),this.textwrapEl.setState(I.textwrap),this.freezeEl.setState(g.freezeIsActive())}}class mt{constructor(g,I,C="600px"){this.title=g,this.el=qA("div",`${ji}-modal`).css("width",C).children(qA("div",`${ji}-modal-header`).children(new me("close").on("click.stop",(()=>this.hide())),this.title),qA("div",`${ji}-modal-content`).children(...I)).hide()}show(){this.dimmer=qA("div",`${ji}-dimmer active`),document.body.appendChild(this.dimmer.el);const{width:g,height:I}=this.el.show().box(),{clientHeight:C,clientWidth:A}=document.documentElement;this.el.offset({left:(A-g)/2,top:(C-I)/3}),window.xkeydownEsc=g=>{27===g.keyCode&&this.hide()},zi(window,"keydown",window.xkeydownEsc)}hide(){this.el.hide(),document.body.removeChild(this.dimmer.el),vi(window,"keydown",window.xkeydownEsc),delete window.xkeydownEsc}}class ht{constructor(g,I){this.vchange=()=>{},this.el=qA("div",`${ji}-form-input`),this.input=qA("input","").css("width",g).on("input",(g=>this.vchange(g))).attr("placeholder",I),this.el.child(this.input)}focus(){setTimeout((()=>{this.input.el.focus()}),10)}hint(g){this.input.attr("placeholder",g)}val(g){return this.input.val(g)}}class Gt{constructor(g,I,C,A=(g=>g),i=(()=>{})){this.key=g,this.getTitle=A,this.vchange=()=>{},this.el=qA("div",`${ji}-form-select`),this.suggest=new re(I.map((g=>({key:g,title:this.getTitle(g)}))),(g=>{this.itemClick(g.key),i(g.key),this.vchange(g.key)}),C,this.el),this.el.children(this.itemEl=qA("div","input-text").html(this.getTitle(g)),this.suggest.el).on("click",(()=>this.show()))}show(){this.suggest.search("")}itemClick(g){this.key=g,this.itemEl.html(this.getTitle(g))}val(g){return void 0!==g?(this.key=g,this.itemEl.html(this.getTitle(g)),this):this.key}}const ut={number:/(^\d+$)|(^\d+(\.\d{0,4})?$)/,date:/^\d{4}-\d{1,2}-\d{1,2}$/};class Bt{constructor(g,I,C,A){this.label="",this.rule=I,C&&(this.label=qA("label","label").css("width",`${A}px`).html(C)),this.tip=qA("div","tip").child("tip").hide(),this.input=g,this.input.vchange=()=>this.validate(),this.el=qA("div",`${ji}-form-field`).children(this.label,g.el,this.tip)}isShow(){return"none"!==this.el.css("display")}show(){this.el.show()}hide(){return this.el.hide(),this}val(g){return this.input.val(g)}hint(g){this.input.hint(g)}validate(){const{input:g,rule:I,tip:C,el:A}=this,i=g.val();if(I.required&&/^\s*$/.test(i))return C.html(Wi("validation.required")),A.addClass("error"),!1;if(I.type||I.pattern){if(!(I.pattern||ut[I.type]).test(i))return C.html(Wi("validation.notMatch")),A.addClass("error"),!1}return A.removeClass("error"),!0}}class wt extends mt{constructor(){const g=new Bt(new Gt("cell",["cell"],"100%",(g=>Wi(`dataValidation.modeType.${g}`))),{required:!0},`${Wi("dataValidation.range")}:`,100),I=new Bt(new ht("120px","E3 or E3:F12"),{required:!0,pattern:/^([A-Z]{1,2}[1-9]\d*)(:[A-Z]{1,2}[1-9]\d*)?$/}),C=new Bt(new Gt("list",["list","number","date","phone","email"],"100%",(g=>Wi(`dataValidation.type.${g}`)),(g=>this.criteriaSelected(g))),{required:!0},`${Wi("dataValidation.criteria")}:`,100),A=new Bt(new Gt("be",["be","nbe","eq","neq","lt","lte","gt","gte"],"160px",(g=>Wi(`dataValidation.operator.${g}`)),(g=>this.criteriaOperatorSelected(g))),{required:!0}).hide(),i=new Bt(new ht("70px","10"),{required:!0}).hide(),e=new Bt(new ht("70px","100"),{required:!0,type:"number"}).hide(),l=new Bt(new ht("120px","a,b,c"),{required:!0}),t=new Bt(new ht("70px","10"),{required:!0,type:"number"}).hide();super(Wi("contextmenu.validation"),[qA("div",`${ji}-form-fields`).children(g.el,I.el),qA("div",`${ji}-form-fields`).children(C.el,A.el,i.el,e.el,t.el,l.el),qA("div",`${ji}-buttons`).children(new He("cancel").on("click",(()=>this.btnClick("cancel"))),new He("remove").on("click",(()=>this.btnClick("remove"))),new He("save","primary").on("click",(()=>this.btnClick("save"))))]),this.mf=g,this.rf=I,this.cf=C,this.of=A,this.minvf=i,this.maxvf=e,this.vf=t,this.svf=l,this.change=()=>{}}showVf(g){const I="date"===g?"2018-11-12":"10",{vf:C}=this;C.input.hint(I),C.show()}criteriaSelected(g){const{of:I,minvf:C,maxvf:A,vf:i,svf:e}=this;"date"===g||"number"===g?(I.show(),C.rule.type=g,A.rule.type=g,"date"===g?(C.hint("2018-11-12"),A.hint("2019-11-12")):(C.hint("10"),A.hint("100")),C.show(),A.show(),i.hide(),e.hide()):("list"===g?e.show():e.hide(),i.hide(),I.hide(),C.hide(),A.hide())}criteriaOperatorSelected(g){if(!g)return;const{minvf:I,maxvf:C,vf:A}=this;if("be"===g||"nbe"===g)I.show(),C.show(),A.hide();else{const g=this.cf.val();A.rule.type=g,"date"===g?A.hint("2018-11-12"):A.hint("10"),A.show(),I.hide(),C.hide()}}btnClick(g){if("cancel"===g)this.hide();else if("remove"===g)this.change("remove"),this.hide();else if("save"===g){const g=["mf","rf","cf","of","svf","vf","minvf","maxvf"];for(let l=0;lthis.itemClick(g)))}function Vt(g){const{filterbEl:I,filterValues:C}=this;I.html("");Object.keys(g).forEach(((A,i)=>{const e=g[A],l=C.includes(A)?"checked":"";I.child(qA("div",`${ji}-item state ${l}`).on("click.stop",(()=>this.filterClick(i,A))).children(""===A?Wi("filter.empty"):A,qA("div","label").html(`(${e})`)))}))}function yt(){const{filterhEl:g,filterValues:I,values:C}=this;g.html(`${I.length} / ${C.length}`),g.checked(I.length===C.length)}class Xt{constructor(){this.filterbEl=qA("div",`${ji}-body`),this.filterhEl=qA("div",`${ji}-header state`).on("click.stop",(()=>this.filterClick(0,"all"))),this.el=qA("div",`${ji}-sort-filter`).children(this.sortAscEl=pt.call(this,"asc"),this.sortDescEl=pt.call(this,"desc"),Wt("divider"),qA("div",`${ji}-filter`).children(this.filterhEl,this.filterbEl),qA("div",`${ji}-buttons`).children(new He("cancel").on("click",(()=>this.btnClick("cancel"))),new He("ok","primary").on("click",(()=>this.btnClick("ok"))))).hide(),this.ci=null,this.sortDesc=null,this.values=null,this.filterValues=[]}btnClick(g){if("ok"===g){const{ci:g,sort:I,filterValues:C}=this;this.ok&&this.ok(g,I,"in",C)}this.hide()}itemClick(g){this.sort=g;const{sortAscEl:I,sortDescEl:C}=this;I.checked("asc"===g),C.checked("desc"===g)}filterClick(g,I){const{filterbEl:C,filterValues:A,values:i}=this,e=C.children();if("all"===I)e.length===A.length?(this.filterValues=[],e.forEach((g=>qA(g).checked(!1)))):(this.filterValues=Array.from(i),e.forEach((g=>qA(g).checked(!0))));else{qA(e[g]).toggle("checked")?A.push(I):A.splice(A.findIndex((g=>g===I)),1)}yt.call(this)}set(g,I,C,A){this.ci=g;const{sortAscEl:i,sortDescEl:e}=this;null!==A?(this.sort=A.order,i.checked(A.asc()),e.checked(A.desc())):(this.sortDesc=null,i.checked(!1),e.checked(!1)),this.values=Object.keys(I),this.filterValues=C?Array.from(C.value):Object.keys(I),Vt.call(this,I,C),yt.call(this)}setOffset(g){this.el.offset(g).show();let I=1;xi(this.el,(()=>{I<=0&&this.hide(),I-=1}))}show(){this.el.show()}hide(){this.el.hide(),Ti(this.el)}}function Yt(g,I){const C=qA("div",`${ji}-toast`),A=qA("div",`${ji}-dimmer active`);C.children(qA("div",`${ji}-toast-header`).children(new me("close").on("click.stop",(()=>(document.body.removeChild(C.el),void document.body.removeChild(A.el)))),g),qA("div",`${ji}-toast-content`).html(I)),document.body.appendChild(C.el),document.body.appendChild(A.el);const{width:i,height:e}=C.box(),{clientHeight:l,clientWidth:t}=document.documentElement;C.offset({left:(t-i)/2,top:(l-e)/3})}function Rt(g,I){let C;return(...A)=>{const i=this,e=A;C||(C=setTimeout((()=>{C=null,g.apply(i,e)}),I))}}function Nt(){const{data:g,verticalScrollbar:I,horizontalScrollbar:C}=this,{l:A,t:i,left:e,top:l,width:t,height:s}=g.getSelectedRect(),c=this.getTableOffset();if(Math.abs(e)+t>c.width)C.move({left:A+t-c.width});else{const I=g.freezeTotalWidth();ec.height)I.move({top:i+s-c.height-1});else{const C=g.freezeTotalHeight();l0&&(t-=1):"right"===I?(c!==t&&(t=c),t0&&(l-=1):"down"===I?(s!==l&&(l=s),ls.indexWidth&&C>t.height)return A.hide(),void i.hide();const c=e.box(),d=l.getCellRectByXY(g.offsetX,g.offsetY);d.ri>=0&&-1===d.ci?(d.width=s.indexWidth,A.show(d,{width:c.width}),t.isHide(d.ri-1)?A.showUnhide(d.ri):A.hideUnhide()):A.hide(),-1===d.ri&&d.ci>=0?(d.height=t.height,i.show(d,{height:c.height}),s.isHide(d.ci-1)?i.showUnhide(d.ci):i.hideUnhide()):i.hide()}function Mt(g){const{verticalScrollbar:I,horizontalScrollbar:C,data:A}=this,{top:i}=I.scroll(),{left:e}=C.scroll(),{rows:l,cols:t}=A,{deltaY:s,deltaX:c}=g,d=(g,I)=>{let C=g,A=0;do{A=I(C),C+=1}while(A<=0);return A},o=g=>{if(g>0){const g=A.scroll.ri+1;if(gl.getHeight(g)));I.move({top:i+C-1})}}else{const g=A.scroll.ri-1;if(g>=0){const C=d(g,(g=>l.getHeight(g)));I.move({top:0===g?0:i-C})}}},n=Math.abs(s),a=Math.abs(c),Z=Math.max(n,a);/Firefox/i.test(window.navigator.userAgent)&&Rt(o(g.detail),50),Z===a&&Rt((g=>{if(g>0){const g=A.scroll.ci+1;if(gt.getWidth(g)));C.move({left:e+I-1})}}else{const g=A.scroll.ci-1;if(g>=0){const I=d(g,(g=>t.getWidth(g)));C.move({left:0===g?0:e-I})}}})(c),50),Z===n&&Rt(o(s),50)}function Jt(g,I){const{verticalScrollbar:C,horizontalScrollbar:A}=this,{top:i}=C.scroll(),{left:e}=A.scroll();"left"===g||"right"===g?A.move({left:e-I}):"up"!==g&&"down"!==g||C.move({top:i-I})}function St(){const{data:g,verticalScrollbar:I}=this,{height:C}=this.getTableOffset(),A=g.exceptRowTotalHeight(0,-1);I.set(C,g.rows.totalHeight()-A)}function ft(){const{data:g,horizontalScrollbar:I}=this,{width:C}=this.getTableOffset();g&&I.set(C,g.cols.totalWidth())}function kt(){const{selector:g,data:I,editor:C}=this,[A,i]=I.freeze;if(A>0||i>0){const g=I.freezeTotalWidth(),A=I.freezeTotalHeight();C.setFreezeLengths(g,A)}g.resetAreaOffset()}function Dt(){const{tableEl:g,overlayerEl:I,overlayerCEl:C,table:A,toolbar:i,selector:e,el:l}=this,t=this.getTableOffset(),s=this.getRect();g.attr(s),I.offset(s),C.offset(t),l.css("width",`${s.width}px`),St.call(this),ft.call(this),kt.call(this),A.render(),i.reset(),e.reset()}function Lt(){const{data:g,selector:I}=this;g.clearClipboard(),I.hideClipboard()}function zt(){const{data:g,selector:I}=this;g.copy(),g.copyToSystemClipboard(),I.showClipboard()}function vt(){const{data:g,selector:I}=this;g.cut(),I.showClipboard()}function Tt(g,I){const{data:C}=this;if("read"!==C.settings.mode)if(C.paste(g,(g=>Yt("Tip",g))))Dt.call(this);else if(I){const g=I.clipboardData.getData("text/plain");this.data.pasteFromText(g),Dt.call(this)}}function xt(){this.data.hideRowsOrCols(),Dt.call(this)}function Ut(g,I){this.data.unhideRowsOrCols(g,I),Dt.call(this)}function Qt(){const{data:g}=this;g.autofilter(),Dt.call(this)}function jt(){const{toolbar:g}=this;g.paintformatActive()&&(Tt.call(this,"format"),Lt.call(this),g.paintformatToggle())}function Ot(g){const{selector:I,data:C,table:A,sortFilter:i}=this,{offsetX:e,offsetY:l}=g,t=g.target.className===`${ji}-selector-corner`,s=C.getCellRectByXY(e,l),{left:c,top:d,width:o,height:n}=s;let{ri:a,ci:Z}=s;const{autoFilter:b}=C;if(b.includes(a,Z)&&c+o-20C.rows.getCell(g,I)));return i.hide(),i.set(Z,g,b.getFilter(Z),b.getSort(Z)),void i.setOffset({left:c,top:d+n+2})}g.shiftKey||(t?I.showAutofill(a,Z):Ht.call(this,!1,a,Z),Ui(window,(g=>{({ri:a,ci:Z}=C.getCellRectByXY(g.offsetX,g.offsetY)),t?I.showAutofill(a,Z):1!==g.buttons||g.shiftKey||Ht.call(this,!0,a,Z,!0,!0)}),(()=>{t&&I.arange&&"read"!==C.settings.mode&&C.autofill(I.arange,"all",(g=>Yt("Tip",g)))&&A.render(),I.hideAutofill(),jt.call(this)}))),t||1!==g.buttons||g.shiftKey&&Ht.call(this,!0,a,Z)}function Et(){const{editor:g,data:I}=this,C=I.getSelectedRect(),A=this.getTableOffset();let i="top";C.top>A.height/2&&(i="bottom"),g.setOffset(C,i)}function Pt(){const{editor:g,data:I}=this;"read"!==I.settings.mode&&(Et.call(this),g.setCell(I.getSelectedCell(),I.getSelectedValidator()),Lt.call(this))}function _t(g){const{data:I,table:C,selector:A}=this;I.scrolly(g,(()=>{A.resetBRLAreaOffset(),Et.call(this),C.render()}))}function qt(g){const{data:I,table:C,selector:A}=this;I.scrollx(g,(()=>{A.resetBRTAreaOffset(),Et.call(this),C.render()}))}function $t(g,I){const{ri:C}=g,{table:A,selector:i,data:e}=this;e.rows.setHeight(C,I),A.render(),i.resetAreaOffset(),St.call(this),Et.call(this)}function gs(g,I){const{ci:C}=g,{table:A,selector:i,data:e}=this;e.cols.setWidth(C,I),A.render(),i.resetAreaOffset(),ft.call(this),Et.call(this)}function Is(g,I="finished"){const{data:C,table:A}=this;if("read"===C.settings.mode)return;C.setSelectedCellText(g,I);const{ri:i,ci:e}=C.selector;"finished"===I?A.render():this.trigger("cell-edited",g,i,e)}function Cs(g){const{data:I}=this;"read"!==I.settings.mode&&("insert-row"===g?I.insert("row"):"delete-row"===g?I.delete("row"):"insert-column"===g?I.insert("column"):"delete-column"===g?I.delete("column"):"delete-cell"===g?I.deleteCell():"delete-cell-format"===g?I.deleteCell("format"):"delete-cell-text"===g?I.deleteCell("text"):"cell-printable"===g?I.setSelectedCellAttr("printable",!0):"cell-non-printable"===g?I.setSelectedCellAttr("printable",!1):"cell-editable"===g?I.setSelectedCellAttr("editable",!0):"cell-non-editable"===g&&I.setSelectedCellAttr("editable",!1),Lt.call(this),Dt.call(this))}function As(g,I){const{data:C}=this;if("undo"===g)this.undo();else if("redo"===g)this.redo();else if("print"===g)this.print.preview();else if("paintformat"===g)!0===I?zt.call(this):Lt.call(this);else if("clearformat"===g)Cs.call(this,"delete-cell-format");else if("link"===g);else if("chart"===g);else if("autofilter"===g)Qt.call(this);else if("freeze"===g)if(I){const{ri:g,ci:I}=C.selector;this.freeze(g,I)}else this.freeze(0,0);else C.setSelectedCellAttr(g,I),"formula"!==g||C.selector.multiple()||Pt.call(this),Dt.call(this)}function is(g,I,C,A){this.data.setAutoFilter(g,I,C,A),Dt.call(this)}function es(){const{selector:g,overlayerEl:I,rowResizer:C,colResizer:A,verticalScrollbar:i,horizontalScrollbar:e,editor:l,contextMenu:t,toolbar:s,modalValidation:c,sortFilter:d}=this;I.on("mousemove",(g=>{Ft.call(this,g)})).on("mousedown",(g=>{l.clear(),t.hide(),2===g.buttons?(this.data.xyInSelectedRect(g.offsetX,g.offsetY)||Ot.call(this,g),t.setPosition(g.offsetX,g.offsetY),g.stopPropagation()):2===g.detail?Pt.call(this):Ot.call(this,g)})).on("mousewheel.stop",(g=>{Mt.call(this,g)})).on("mouseout",(g=>{const{offsetX:I,offsetY:i}=g;i<=0&&A.hide(),I<=0&&C.hide()})),g.inputChange=g=>{Is.call(this,g,"input"),Pt.call(this)},function(g,{move:I,end:C}){let A=0,i=0;zi(g,"touchstart",(g=>{const{pageX:I,pageY:C}=g.touches[0];A=I,i=C})),zi(g,"touchmove",(g=>{if(!I)return;const{pageX:C,pageY:e}=g.changedTouches[0],l=C-A,t=e-i;(Math.abs(l)>10||Math.abs(t)>10)&&(Qi(l,t,g,I),A=C,i=e),g.preventDefault()})),zi(g,"touchend",(g=>{if(!C)return;const{pageX:I,pageY:e}=g.changedTouches[0];Qi(I-A,e-i,g,C)}))}(I.el,{move:(g,I)=>{Jt.call(this,g,I)}}),s.change=(g,I)=>As.call(this,g,I),d.ok=(g,I,C,A)=>is.call(this,g,I,C,A),C.finishedFn=(g,I)=>{$t.call(this,g,I)},A.finishedFn=(g,I)=>{gs.call(this,g,I)},C.unhideFn=g=>{Ut.call(this,"row",g)},A.unhideFn=g=>{Ut.call(this,"col",g)},i.moveFn=(g,I)=>{_t.call(this,g,I)},e.moveFn=(g,I)=>{qt.call(this,g,I)},l.change=(g,I)=>{Is.call(this,I,g)},c.change=(g,...I)=>{"save"===g?this.data.addValidation(...I):this.data.removeValidation()},t.itemClick=g=>{"validation"===g?c.setValue(this.data.getSelectedValidation()):"copy"===g?zt.call(this):"cut"===g?vt.call(this):"paste"===g?Tt.call(this,"all"):"paste-value"===g?Tt.call(this,"text"):"paste-format"===g?Tt.call(this,"format"):"hide"===g?xt.call(this):Cs.call(this,g)},zi(window,"resize",(()=>{this.reload()})),zi(window,"click",(g=>{this.focusing=I.contains(g.target)})),zi(window,"paste",(g=>{this.focusing&&(Tt.call(this,"all",g),g.preventDefault())})),zi(window,"keydown",(g=>{if(!this.focusing)return;const I=g.keyCode||g.which,{key:C,ctrlKey:A,shiftKey:i,metaKey:e}=g;if(A||e)switch(I){case 90:this.undo(),g.preventDefault();break;case 89:this.redo(),g.preventDefault();break;case 67:zt.call(this),g.preventDefault();break;case 88:vt.call(this),g.preventDefault();break;case 85:s.trigger("underline"),g.preventDefault();break;case 86:break;case 37:Kt.call(this,i,"row-first"),g.preventDefault();break;case 38:Kt.call(this,i,"col-first"),g.preventDefault();break;case 39:Kt.call(this,i,"row-last"),g.preventDefault();break;case 40:Kt.call(this,i,"col-last"),g.preventDefault();break;case 32:Ht.call(this,!1,-1,this.data.selector.ci,!1),g.preventDefault();break;case 66:s.trigger("bold");break;case 73:s.trigger("italic")}else{switch(I){case 32:i&&Ht.call(this,!1,this.data.selector.ri,-1,!1);break;case 27:t.hide(),Lt.call(this);break;case 37:Kt.call(this,i,"left"),g.preventDefault();break;case 38:Kt.call(this,i,"up"),g.preventDefault();break;case 39:Kt.call(this,i,"right"),g.preventDefault();break;case 40:Kt.call(this,i,"down"),g.preventDefault();break;case 9:l.clear(),Kt.call(this,!1,i?"left":"right"),g.preventDefault();break;case 13:l.clear(),Kt.call(this,!1,i?"up":"down"),g.preventDefault();break;case 8:Cs.call(this,"delete-cell-text"),g.preventDefault()}"Delete"===C?(Cs.call(this,"delete-cell-text"),g.preventDefault()):I>=65&&I<=90||I>=48&&I<=57||I>=96&&I<=105||"="===g.key?(Is.call(this,g.key,"input"),Pt.call(this)):113===I&&Pt.call(this)}}))}class ls{constructor(g,I){this.eventMap=function(){const g=new Map;function I(I,C){return g.has(I)&&(()=>{const A=g.get(I);return Array.isArray(A)&&A.push(C)||!1})()||g.set(I,[].concat(C))}function C(I,C){return g.has(I)&&(()=>{const A=g.get(I),i=A.indexOf(C);return i>=0&&A.splice(i,1)&&0===g.get(I).length&&g.delete(I)})()}return{get current(){return g},on:I,once:function(g,A){const i=(...I)=>{A.call(null,...I),C(g,i)};return I(g,i)},fire:function(I,C){return g.has(I)&&(()=>{const A=g.get(I);for(const g of A)g.call(null,...C)})()},removeListener:C,removeAllListeners:function(){g.clear()}}}();const{view:C,showToolbar:A,showContextmenu:i}=I.settings;this.el=qA("div",`${ji}-sheet`),this.toolbar=new rt(I,C.width,!A),this.print=new rl(I),g.children(this.toolbar.el,this.el,this.print.el),this.data=I,this.tableEl=qA("canvas",`${ji}-table`),this.rowResizer=new Oi(!1,I.rows.height),this.colResizer=new Oi(!0,I.cols.minWidth),this.verticalScrollbar=new Ei(!0),this.horizontalScrollbar=new Ei(!1),this.editor=new Ne(Ue,(()=>this.getTableOffset()),I.rows.height),this.modalValidation=new wt,this.contextMenu=new ul((()=>this.getRect()),!i),this.selector=new oe(I),this.overlayerCEl=qA("div",`${ji}-overlayer-content`).children(this.editor.el,this.selector.el),this.overlayerEl=qA("div",`${ji}-overlayer`).child(this.overlayerCEl),this.sortFilter=new Xt,this.el.children(this.tableEl,this.overlayerEl.el,this.rowResizer.el,this.colResizer.el,this.verticalScrollbar.el,this.horizontalScrollbar.el,this.contextMenu.el,this.modalValidation.el,this.sortFilter.el),this.table=new cl(this.tableEl.el,I),es.call(this),Dt.call(this),Ht.call(this,!1,0,0)}on(g,I){return this.eventMap.on(g,I),this}trigger(g,...I){const{eventMap:C}=this;C.fire(g,I)}resetData(g){this.editor.clear(),this.data=g,St.call(this),ft.call(this),this.toolbar.resetData(g),this.print.resetData(g),this.selector.resetData(g),this.table.resetData(g)}loadData(g){return this.data.setData(g),Dt.call(this),this}freeze(g,I){const{data:C}=this;return C.setFreeze(g,I),Dt.call(this),this}undo(){this.data.undo(),Dt.call(this)}redo(){this.data.redo(),Dt.call(this)}reload(){return Dt.call(this),this}getRect(){const{data:g}=this;return{width:g.viewWidth(),height:g.viewHeight()}}getTableOffset(){const{rows:g,cols:I}=this.data,{width:C,height:A}=this.getRect();return{width:C-I.indexWidth,height:A-g.height,left:I.indexWidth,top:g.height}}}class ts extends Wl{constructor(g){super(new me("ellipsis"),"auto",!1,"top-left"),this.contentClick=g}reset(g){const I=g.map(((g,I)=>qA("div",`${ji}-item`).css("width","150px").css("font-weight","normal").on("click",(()=>{this.contentClick(I),this.hide()})).child(g)));this.setContentChildren(...I)}setTitle(){}}const ss=[{key:"delete",title:pi("contextmenu.deleteSheet")}];function cs(g){return qA("div",`${ji}-item`).child(g.title()).on("click",(()=>{this.itemClick(g.key),this.hide()}))}function ds(){return ss.map((g=>cs.call(this,g)))}class os{constructor(){this.el=qA("div",`${ji}-contextmenu`).css("width","160px").children(...ds.call(this)).hide(),this.itemClick=()=>{}}hide(){const{el:g}=this;g.hide(),Ti(g)}setOffset(g){const{el:I}=this;I.offset(g),I.show(),xi(I)}}class ns{constructor(g=(()=>{}),I=(()=>{}),C=(()=>{}),A=(()=>{})){this.swapFunc=I,this.updateFunc=A,this.dataNames=[],this.activeEl=null,this.deleteEl=null,this.items=[],this.moreEl=new ts((g=>{this.clickSwap2(this.items[g])})),this.contextMenu=new os,this.contextMenu.itemClick=C,this.el=qA("div",`${ji}-bottombar`).children(this.contextMenu.el,this.menuEl=qA("ul",`${ji}-menu`).child(qA("li","").children(new me("add").on("click",(()=>{g()})),qA("span","").child(this.moreEl))))}addItem(g,I){this.dataNames.push(g);const C=qA("li",I?"active":"").child(g);C.on("click",(()=>{this.clickSwap2(C)})).on("contextmenu",(g=>{const{offsetLeft:I,offsetHeight:A}=g.target;this.contextMenu.setOffset({left:I,bottom:A+1}),this.deleteEl=C})).on("dblclick",(()=>{const g=C.html(),I=new ht("auto","");I.val(g),I.input.on("blur",(({target:I})=>{const{value:C}=I,A=this.dataNames.findIndex((I=>I===g));this.renameItem(A,C)})),C.html("").child(I.el),I.focus()})),I&&this.clickSwap(C),this.items.push(C),this.menuEl.child(C),this.moreEl.reset(this.dataNames)}renameItem(g,I){this.dataNames.splice(g,1,I),this.moreEl.reset(this.dataNames),this.items[g].html("").child(I),this.updateFunc(g,I)}clear(){this.items.forEach((g=>{this.menuEl.removeChild(g.el)})),this.items=[],this.dataNames=[],this.moreEl.reset(this.dataNames)}deleteItem(){const{activeEl:g,deleteEl:I}=this;if(this.items.length>1){const C=this.items.findIndex((g=>g===I));if(this.items.splice(C,1),this.dataNames.splice(C,1),this.menuEl.removeChild(I.el),this.moreEl.reset(this.dataNames),g===I){const[g]=this.items;return this.activeEl=g,this.activeEl.toggle(),[C,0]}return[C,-1]}return[-1]}clickSwap2(g){const I=this.items.findIndex((I=>I===g));this.clickSwap(g),this.activeEl.toggle(),this.swapFunc(I)}clickSwap(g){null!==this.activeEl&&this.activeEl.toggle(),this.activeEl=g}}class as{constructor(g,I={}){let C=g;this.options={showBottomBar:!0,...I},this.sheetIndex=1,this.datas=[],"string"==typeof g&&(C=document.querySelector(g)),this.bottombar=this.options.showBottomBar?new ns((()=>{const g=this.addSheet();this.sheet.resetData(g)}),(g=>{const I=this.datas[g];this.sheet.resetData(I)}),(()=>{this.deleteSheet()}),((g,I)=>{this.datas[g].name=I})):null,this.data=this.addSheet();const A=qA("div",`${ji}`).on("contextmenu",(g=>g.preventDefault()));C.appendChild(A.el),this.sheet=new ls(A,this.data),null!==this.bottombar&&A.child(this.bottombar.el)}addSheet(g,I=!0){const C=g||`sheet${this.sheetIndex}`,A=new Li(C,this.options);return A.change=(...g)=>{this.sheet.trigger("change",...g)},this.datas.push(A),null!==this.bottombar&&this.bottombar.addItem(C,I),this.sheetIndex+=1,A}deleteSheet(){if(null===this.bottombar)return;const[g,I]=this.bottombar.deleteItem();g>=0&&(this.datas.splice(g,1),I>=0&&this.sheet.resetData(this.datas[I]))}loadData(g){const I=Array.isArray(g)?g:[g];if(null!==this.bottombar&&this.bottombar.clear(),this.datas=[],I.length>0)for(let C=0;Cg.getData()))}cellText(g,I,C,A=0){return this.datas[A].setCellText(g,I,C,"finished"),this}cell(g,I,C=0){return this.datas[C].getCell(g,I)}cellStyle(g,I,C=0){return this.datas[C].getCellStyle(g,I)}reRender(){return this.sheet.table.render(),this}on(g,I){return this.sheet.on(g,I),this}validate(){const{validations:g}=this.data;return g.errors.size<=0}change(g){return this.sheet.on("change",g),this}static locale(g,I){Vi(g,I)}}const Zs=(g,I={})=>new as(g,I);"undefined"!=typeof window&&(window.x_spreadsheet=Zs,window.x_spreadsheet.locale=(g,I)=>Vi(g,I));var bs={exports:{}};!function(g,I){g.exports=function(){function g(I,C,A){function i(l,t){if(!C[l]){if(!I[l]){if(!t&&_I)return _I(l);if(e)return e(l,!0);var s=new Error("Cannot find module '"+l+"'");throw s.code="MODULE_NOT_FOUND",s}var c=C[l]={exports:{}};I[l][0].call(c.exports,(function(g){return i(I[l][1][g]||g)}),c,c.exports,g,I,C,A)}return C[l].exports}for(var e=_I,l=0;l{const e=this.workbook.addWorksheet(I.sheetName),l=I.dateFormats||["YYYY-MM-DD[T]HH:mm:ssZ","YYYY-MM-DD[T]HH:mm:ss","MM-DD-YYYY","YYYY-MM-DD"],s=I.map||function(g){if(""===g)return null;const I=Number(g);if(!Number.isNaN(I)&&I!==1/0)return I;const C=l.reduce(((I,C)=>{if(I)return I;const A=t(g,C,!0);return A.isValid()?A:null}),null);if(C)return new Date(C.valueOf());const A=d[g];return void 0!==A?A:g},c=i.parse(I.parserOptions).on("data",(g=>{e.addRow(g.map(s))})).on("end",(()=>{c.emit("worksheet",e)}));c.on("worksheet",C).on("error",A),g.pipe(c)}))}createInputStream(){throw new Error("`CSV#createInputStream` is deprecated. You should use `CSV#read` instead. This method will be removed in version 5.0. Please follow upgrade instruction: https://github.com/exceljs/exceljs/blob/master/UPGRADE-4.0.md")}write(g,I){return new Promise(((C,A)=>{I=I||{};const e=this.workbook.getWorksheet(I.sheetName||I.sheetId),l=i.format(I.formatterOptions);g.on("finish",(()=>{C()})),l.on("error",A),l.pipe(g);const{dateFormat:s,dateUTC:c}=I,d=I.map||(g=>{if(g){if(g.text||g.hyperlink)return g.hyperlink||g.text||"";if(g.formula||g.result)return g.result||"";if(g instanceof Date)return s?c?t.utc(g).format(s):t(g).format(s):c?t.utc(g).format():t(g).format();if(g.error)return g.error;if("object"==typeof g)return JSON.stringify(g)}return g}),o=void 0===I.includeEmptyRows||I.includeEmptyRows;let n=1;e&&e.eachRow(((g,I)=>{if(o)for(;n++2&&void 0!==arguments[2]?arguments[2]:0;if(this.worksheet=g,I)if("string"==typeof I){const g=A.decodeAddress(I);this.nativeCol=g.col+C,this.nativeColOff=0,this.nativeRow=g.row+C,this.nativeRowOff=0}else void 0!==I.nativeCol?(this.nativeCol=I.nativeCol||0,this.nativeColOff=I.nativeColOff||0,this.nativeRow=I.nativeRow||0,this.nativeRowOff=I.nativeRowOff||0):void 0!==I.col?(this.col=I.col+C,this.row=I.row+C):(this.nativeCol=0,this.nativeColOff=0,this.nativeRow=0,this.nativeRowOff=0);else this.nativeCol=0,this.nativeColOff=0,this.nativeRow=0,this.nativeRowOff=0}static asInstance(g){return g instanceof i||null==g?g:new i(g)}get col(){return this.nativeCol+Math.min(this.colWidth-1,this.nativeColOff)/this.colWidth}set col(g){this.nativeCol=Math.floor(g),this.nativeColOff=Math.floor((g-this.nativeCol)*this.colWidth)}get row(){return this.nativeRow+Math.min(this.rowHeight-1,this.nativeRowOff)/this.rowHeight}set row(g){this.nativeRow=Math.floor(g),this.nativeRowOff=Math.floor((g-this.nativeRow)*this.rowHeight)}get colWidth(){return this.worksheet&&this.worksheet.getColumn(this.nativeCol+1)&&this.worksheet.getColumn(this.nativeCol+1).isCustomWidth?Math.floor(1e4*this.worksheet.getColumn(this.nativeCol+1).width):64e4}get rowHeight(){return this.worksheet&&this.worksheet.getRow(this.nativeRow+1)&&this.worksheet.getRow(this.nativeRow+1).height?Math.floor(1e4*this.worksheet.getRow(this.nativeRow+1).height):18e4}get model(){return{nativeCol:this.nativeCol,nativeColOff:this.nativeColOff,nativeRow:this.nativeRow,nativeRowOff:this.nativeRowOff}}set model(g){this.nativeCol=g.nativeCol,this.nativeColOff=g.nativeColOff,this.nativeRow=g.nativeRow,this.nativeRowOff=g.nativeRowOff}}I.exports=i},{"../utils/col-cache":19}],3:[function(g,I,C){const A=g("../utils/col-cache"),i=g("../utils/under-dash"),e=g("./enums"),{slideFormula:l}=g("../utils/shared-formula"),t=g("./note");class s{constructor(g,I,C){if(!g||!I)throw new Error("A Cell needs a Row");this._row=g,this._column=I,A.validateAddress(C),this._address=C,this._value=B.create(s.Types.Null,this),this.style=this._mergeStyle(g.style,I.style,{}),this._mergeCount=0}get worksheet(){return this._row.worksheet}get workbook(){return this._row.worksheet.workbook}destroy(){delete this.style,delete this._value,delete this._row,delete this._column,delete this._address}get numFmt(){return this.style.numFmt}set numFmt(g){this.style.numFmt=g}get font(){return this.style.font}set font(g){this.style.font=g}get alignment(){return this.style.alignment}set alignment(g){this.style.alignment=g}get border(){return this.style.border}set border(g){this.style.border=g}get fill(){return this.style.fill}set fill(g){this.style.fill=g}get protection(){return this.style.protection}set protection(g){this.style.protection=g}_mergeStyle(g,I,C){const A=g&&g.numFmt||I&&I.numFmt;A&&(C.numFmt=A);const i=g&&g.font||I&&I.font;i&&(C.font=i);const e=g&&g.alignment||I&&I.alignment;e&&(C.alignment=e);const l=g&&g.border||I&&I.border;l&&(C.border=l);const t=g&&g.fill||I&&I.fill;t&&(C.fill=t);const s=g&&g.protection||I&&I.protection;return s&&(C.protection=s),C}get address(){return this._address}get row(){return this._row.number}get col(){return this._column.number}get $col$row(){return`$${this._column.letter}$${this.row}`}get type(){return this._value.type}get effectiveType(){return this._value.effectiveType}toCsvString(){return this._value.toCsvString()}addMergeRef(){this._mergeCount++}releaseMergeRef(){this._mergeCount--}get isMerged(){return this._mergeCount>0||this.type===s.Types.Merge}merge(g,I){this._value.release(),this._value=B.create(s.Types.Merge,this,g),I||(this.style=g.style)}unmerge(){this.type===s.Types.Merge&&(this._value.release(),this._value=B.create(s.Types.Null,this),this.style=this._mergeStyle(this._row.style,this._column.style,{}))}isMergedTo(g){return this._value.type===s.Types.Merge&&this._value.isMergedTo(g)}get master(){return this.type===s.Types.Merge?this._value.master:this}get isHyperlink(){return this._value.type===s.Types.Hyperlink}get hyperlink(){return this._value.hyperlink}get value(){return this._value.value}set value(g){this.type!==s.Types.Merge?(this._value.release(),this._value=B.create(B.getType(g),this,g)):this._value.master.value=g}get note(){return this._comment&&this._comment.note}set note(g){this._comment=new t(g)}get text(){return this._value.toString()}get html(){return i.escapeHtml(this.text)}toString(){return this.text}_upgradeToHyperlink(g){this.type===s.Types.String&&(this._value=B.create(s.Types.Hyperlink,this,{text:this._value.value,hyperlink:g}))}get formula(){return this._value.formula}get result(){return this._value.result}get formulaType(){return this._value.formulaType}get fullAddress(){const{worksheet:g}=this._row;return{sheetName:g.name,address:this.address,row:this.row,col:this.col}}get name(){return this.names[0]}set name(g){this.names=[g]}get names(){return this.workbook.definedNames.getNamesEx(this.fullAddress)}set names(g){const{definedNames:I}=this.workbook;I.removeAllNames(this.fullAddress),g.forEach((g=>{I.addEx(this.fullAddress,g)}))}addName(g){this.workbook.definedNames.addEx(this.fullAddress,g)}removeName(g){this.workbook.definedNames.removeEx(this.fullAddress,g)}removeAllNames(){this.workbook.definedNames.removeAllNames(this.fullAddress)}get _dataValidations(){return this.worksheet.dataValidations}get dataValidation(){return this._dataValidations.find(this.address)}set dataValidation(g){this._dataValidations.add(this.address,g)}get model(){const{model:g}=this._value;return g.style=this.style,this._comment&&(g.comment=this._comment.model),g}set model(g){this._value.release(),this._value=B.create(g.type,this),this._value.model=g,g.comment&&"note"===g.comment.type&&(this._comment=t.fromModel(g.comment)),g.style?this.style=g.style:this.style={}}}s.Types=e.ValueType;class c{constructor(g){this.model={address:g.address,type:s.Types.Null}}get value(){return null}set value(g){}get type(){return s.Types.Null}get effectiveType(){return s.Types.Null}get address(){return this.model.address}set address(g){this.model.address=g}toCsvString(){return""}release(){}toString(){return""}}class d{constructor(g,I){this.model={address:g.address,type:s.Types.Number,value:I}}get value(){return this.model.value}set value(g){this.model.value=g}get type(){return s.Types.Number}get effectiveType(){return s.Types.Number}get address(){return this.model.address}set address(g){this.model.address=g}toCsvString(){return this.model.value.toString()}release(){}toString(){return this.model.value.toString()}}class o{constructor(g,I){this.model={address:g.address,type:s.Types.String,value:I}}get value(){return this.model.value}set value(g){this.model.value=g}get type(){return s.Types.String}get effectiveType(){return s.Types.String}get address(){return this.model.address}set address(g){this.model.address=g}toCsvString(){return`"${this.model.value.replace(/"/g,'""')}"`}release(){}toString(){return this.model.value}}class n{constructor(g,I){this.model={address:g.address,type:s.Types.String,value:I}}get value(){return this.model.value}set value(g){this.model.value=g}toString(){return this.model.value.richText.map((g=>g.text)).join("")}get type(){return s.Types.RichText}get effectiveType(){return s.Types.RichText}get address(){return this.model.address}set address(g){this.model.address=g}toCsvString(){return`"${this.text.replace(/"/g,'""')}"`}release(){}}class a{constructor(g,I){this.model={address:g.address,type:s.Types.Date,value:I}}get value(){return this.model.value}set value(g){this.model.value=g}get type(){return s.Types.Date}get effectiveType(){return s.Types.Date}get address(){return this.model.address}set address(g){this.model.address=g}toCsvString(){return this.model.value.toISOString()}release(){}toString(){return this.model.value.toString()}}class Z{constructor(g,I){this.model={address:g.address,type:s.Types.Hyperlink,text:I?I.text:void 0,hyperlink:I?I.hyperlink:void 0},I&&I.tooltip&&(this.model.tooltip=I.tooltip)}get value(){const g={text:this.model.text,hyperlink:this.model.hyperlink};return this.model.tooltip&&(g.tooltip=this.model.tooltip),g}set value(g){this.model={text:g.text,hyperlink:g.hyperlink},g.tooltip&&(this.model.tooltip=g.tooltip)}get text(){return this.model.text}set text(g){this.model.text=g}get hyperlink(){return this.model.hyperlink}set hyperlink(g){this.model.hyperlink=g}get type(){return s.Types.Hyperlink}get effectiveType(){return s.Types.Hyperlink}get address(){return this.model.address}set address(g){this.model.address=g}toCsvString(){return this.model.hyperlink}release(){}toString(){return this.model.text}}class b{constructor(g,I){this.model={address:g.address,type:s.Types.Merge,master:I?I.address:void 0},this._master=I,I&&I.addMergeRef()}get value(){return this._master.value}set value(g){g instanceof s?(this._master&&this._master.releaseMergeRef(),g.addMergeRef(),this._master=g):this._master.value=g}isMergedTo(g){return g===this._master}get master(){return this._master}get type(){return s.Types.Merge}get effectiveType(){return this._master.effectiveType}get address(){return this.model.address}set address(g){this.model.address=g}toCsvString(){return""}release(){this._master.releaseMergeRef()}toString(){return this.value.toString()}}class r{constructor(g,I){this.cell=g,this.model={address:g.address,type:s.Types.Formula,shareType:I?I.shareType:void 0,ref:I?I.ref:void 0,formula:I?I.formula:void 0,sharedFormula:I?I.sharedFormula:void 0,result:I?I.result:void 0}}_copyModel(g){const I={},C=C=>{const A=g[C];A&&(I[C]=A)};return C("formula"),C("result"),C("ref"),C("shareType"),C("sharedFormula"),I}get value(){return this._copyModel(this.model)}set value(g){this.model=this._copyModel(g)}validate(g){switch(B.getType(g)){case s.Types.Null:case s.Types.String:case s.Types.Number:case s.Types.Date:break;case s.Types.Hyperlink:case s.Types.Formula:default:throw new Error("Cannot process that type of result value")}}get dependencies(){return{ranges:this.formula.match(/([a-zA-Z0-9]+!)?[A-Z]{1,3}\d{1,4}:[A-Z]{1,3}\d{1,4}/g),cells:this.formula.replace(/([a-zA-Z0-9]+!)?[A-Z]{1,3}\d{1,4}:[A-Z]{1,3}\d{1,4}/g,"").match(/([a-zA-Z0-9]+!)?[A-Z]{1,3}\d{1,4}/g)}}get formula(){return this.model.formula||this._getTranslatedFormula()}set formula(g){this.model.formula=g}get formulaType(){return this.model.formula?e.FormulaType.Master:this.model.sharedFormula?e.FormulaType.Shared:e.FormulaType.None}get result(){return this.model.result}set result(g){this.model.result=g}get type(){return s.Types.Formula}get effectiveType(){const g=this.model.result;return null==g?e.ValueType.Null:g instanceof String||"string"==typeof g?e.ValueType.String:"number"==typeof g?e.ValueType.Number:g instanceof Date?e.ValueType.Date:g.text&&g.hyperlink?e.ValueType.Hyperlink:g.formula?e.ValueType.Formula:e.ValueType.Null}get address(){return this.model.address}set address(g){this.model.address=g}_getTranslatedFormula(){if(!this._translatedFormula&&this.model.sharedFormula){const{worksheet:g}=this.cell,I=g.findCell(this.model.sharedFormula);this._translatedFormula=I&&l(I.formula,I.address,this.model.address)}return this._translatedFormula}toCsvString(){return`${this.model.result||""}`}release(){}toString(){return this.model.result?this.model.result.toString():""}}class m{constructor(g,I){this.model={address:g.address,type:s.Types.SharedString,value:I}}get value(){return this.model.value}set value(g){this.model.value=g}get type(){return s.Types.SharedString}get effectiveType(){return s.Types.SharedString}get address(){return this.model.address}set address(g){this.model.address=g}toCsvString(){return this.model.value.toString()}release(){}toString(){return this.model.value.toString()}}class h{constructor(g,I){this.model={address:g.address,type:s.Types.Boolean,value:I}}get value(){return this.model.value}set value(g){this.model.value=g}get type(){return s.Types.Boolean}get effectiveType(){return s.Types.Boolean}get address(){return this.model.address}set address(g){this.model.address=g}toCsvString(){return this.model.value?1:0}release(){}toString(){return this.model.value.toString()}}class G{constructor(g,I){this.model={address:g.address,type:s.Types.Error,value:I}}get value(){return this.model.value}set value(g){this.model.value=g}get type(){return s.Types.Error}get effectiveType(){return s.Types.Error}get address(){return this.model.address}set address(g){this.model.address=g}toCsvString(){return this.toString()}release(){}toString(){return this.model.value.error.toString()}}class u{constructor(g,I){this.model={address:g.address,type:s.Types.String,value:JSON.stringify(I),rawValue:I}}get value(){return this.model.rawValue}set value(g){this.model.rawValue=g,this.model.value=JSON.stringify(g)}get type(){return s.Types.String}get effectiveType(){return s.Types.String}get address(){return this.model.address}set address(g){this.model.address=g}toCsvString(){return this.model.value}release(){}toString(){return this.model.value}}const B={getType:g=>null==g?s.Types.Null:g instanceof String||"string"==typeof g?s.Types.String:"number"==typeof g?s.Types.Number:"boolean"==typeof g?s.Types.Boolean:g instanceof Date?s.Types.Date:g.text&&g.hyperlink?s.Types.Hyperlink:g.formula||g.sharedFormula?s.Types.Formula:g.richText?s.Types.RichText:g.sharedString?s.Types.SharedString:g.error?s.Types.Error:s.Types.JSON,types:[{t:s.Types.Null,f:c},{t:s.Types.Number,f:d},{t:s.Types.String,f:o},{t:s.Types.Date,f:a},{t:s.Types.Hyperlink,f:Z},{t:s.Types.Formula,f:r},{t:s.Types.Merge,f:b},{t:s.Types.JSON,f:u},{t:s.Types.SharedString,f:m},{t:s.Types.RichText,f:n},{t:s.Types.Boolean,f:h},{t:s.Types.Error,f:G}].reduce(((g,I)=>(g[I.t]=I.f,g)),[]),create(g,I,C){const A=this.types[g];if(!A)throw new Error(`Could not create Value of type ${g}`);return new A(I,C)}};I.exports=s},{"../utils/col-cache":19,"../utils/shared-formula":23,"../utils/under-dash":26,"./enums":7,"./note":9}],4:[function(g,I,C){const A=g("../utils/under-dash"),i=g("./enums"),e=g("../utils/col-cache"),l=9;class t{constructor(g,I,C){this._worksheet=g,this._number=I,!1!==C&&(this.defn=C)}get number(){return this._number}get worksheet(){return this._worksheet}get letter(){return e.n2l(this._number)}get isCustomWidth(){return void 0!==this.width&&this.width!==l}get defn(){return{header:this._header,key:this.key,width:this.width,style:this.style,hidden:this.hidden,outlineLevel:this.outlineLevel}}set defn(g){g?(this.key=g.key,this.width=void 0!==g.width?g.width:l,this.outlineLevel=g.outlineLevel,g.style?this.style=g.style:this.style={},this.header=g.header,this._hidden=!!g.hidden):(delete this._header,delete this._key,delete this.width,this.style={},this.outlineLevel=0)}get headers(){return this._header&&this._header instanceof Array?this._header:[this._header]}get header(){return this._header}set header(g){void 0!==g?(this._header=g,this.headers.forEach(((g,I)=>{this._worksheet.getCell(I+1,this.number).value=g}))):this._header=void 0}get key(){return this._key}set key(g){(this._key&&this._worksheet.getColumnKey(this._key))===this&&this._worksheet.deleteColumnKey(this._key),this._key=g,g&&this._worksheet.setColumnKey(this._key,this)}get hidden(){return!!this._hidden}set hidden(g){this._hidden=g}get outlineLevel(){return this._outlineLevel||0}set outlineLevel(g){this._outlineLevel=g}get collapsed(){return!!(this._outlineLevel&&this._outlineLevel>=this._worksheet.properties.outlineLevelCol)}toString(){return JSON.stringify({key:this.key,width:this.width,headers:this.headers.length?this.headers:void 0})}equivalentTo(g){return this.width===g.width&&this.hidden===g.hidden&&this.outlineLevel===g.outlineLevel&&A.isEqual(this.style,g.style)}get isDefault(){if(this.isCustomWidth)return!1;if(this.hidden)return!1;if(this.outlineLevel)return!1;const g=this.style;return!g||!(g.font||g.numFmt||g.alignment||g.border||g.fill||g.protection)}get headerCount(){return this.headers.length}eachCell(g,I){const C=this.number;I||(I=g,g=null),this._worksheet.eachRow(g,((g,A)=>{I(g.getCell(C),A)}))}get values(){const g=[];return this.eachCell(((I,C)=>{I&&I.type!==i.ValueType.Null&&(g[C]=I.value)})),g}set values(g){if(!g)return;const I=this.number;let C=0;g.hasOwnProperty("0")&&(C=1),g.forEach(((g,A)=>{this._worksheet.getCell(A+C,I).value=g}))}_applyStyle(g,I){return this.style[g]=I,this.eachCell((C=>{C[g]=I})),I}get numFmt(){return this.style.numFmt}set numFmt(g){this._applyStyle("numFmt",g)}get font(){return this.style.font}set font(g){this._applyStyle("font",g)}get alignment(){return this.style.alignment}set alignment(g){this._applyStyle("alignment",g)}get protection(){return this.style.protection}set protection(g){this._applyStyle("protection",g)}get border(){return this.style.border}set border(g){this._applyStyle("border",g)}get fill(){return this.style.fill}set fill(g){this._applyStyle("fill",g)}static toModel(g){const I=[];let C=null;return g&&g.forEach(((g,A)=>{g.isDefault?C&&(C=null):C&&g.equivalentTo(C)?C.max=A+1:(C={min:A+1,max:A+1,width:void 0!==g.width?g.width:l,style:g.style,isCustomWidth:g.isCustomWidth,hidden:g.hidden,outlineLevel:g.outlineLevel,collapsed:g.collapsed},I.push(C))})),I.length?I:void 0}static fromModel(g,I){const C=[];let A=1,i=0;for(I=(I=I||[]).sort((function(g,I){return g.min-I.min}));i{I.removeCellEx(g)}))}forEach(g){A.each(this.matrixMap,((I,C)=>{I.forEach((I=>{g(C,I)}))}))}getNames(g){return this.getNamesEx(i.decodeEx(g))}getNamesEx(g){return A.map(this.matrixMap,((I,C)=>I.findCellEx(g)&&C)).filter(Boolean)}_explore(g,I){I.mark=!1;const{sheetName:C}=I,A=new l(I.row,I.col,I.row,I.col,C);let i,e;function t(i,e){const l=g.findCellAt(C,i,I.col);return!(!l||!l.mark||(A[e]=i,l.mark=!1,0))}for(e=I.row-1;t(e,"top");e--);for(e=I.row+1;t(e,"bottom");e++);function s(I,i){const l=[];for(e=A.top;e<=A.bottom;e++){const A=g.findCellAt(C,e,I);if(!A||!A.mark)return!1;l.push(A)}A[i]=I;for(let g=0;g{g.mark=!0})),{name:g,ranges:I.map((g=>g.mark&&this._explore(I,g))).filter(Boolean).map((g=>g.$shortRange))}):{name:g,ranges:[]}}normaliseMatrix(g,I){g.forEachInSheet(I,((g,I,C)=>{g&&(g.row===I&&g.col===C||(g.row=I,g.col=C,g.address=i.n2l(C)+I))}))}spliceRows(g,I,C,i){A.each(this.matrixMap,(A=>{A.spliceRows(g,I,C,i),this.normaliseMatrix(A,g)}))}spliceColumns(g,I,C,i){A.each(this.matrixMap,(A=>{A.spliceColumns(g,I,C,i),this.normaliseMatrix(A,g)}))}get model(){return A.map(this.matrixMap,((g,I)=>this.getRanges(I,g))).filter((g=>g.ranges.length))}set model(g){const I=this.matrixMap={};g.forEach((g=>{const C=I[g.name]=new e;g.ranges.forEach((g=>{t.test(g.split("!").pop()||"")&&C.addCell(g)}))}))}}I.exports=s},{"../utils/cell-matrix":18,"../utils/col-cache":19,"../utils/under-dash":26,"./range":10}],7:[function(g,I,C){I.exports={ValueType:{Null:0,Merge:1,Number:2,String:3,Date:4,Hyperlink:5,Formula:6,SharedString:7,RichText:8,Boolean:9,Error:10},FormulaType:{None:0,Master:1,Shared:2},RelationshipType:{None:0,OfficeDocument:1,Worksheet:2,CalcChain:3,SharedStrings:4,Styles:5,Theme:6,Hyperlink:7},DocumentType:{Xlsx:1},ReadingOrder:{LeftToRight:1,RightToLeft:2},ErrorValue:{NotApplicable:"#N/A",Ref:"#REF!",Name:"#NAME?",DivZero:"#DIV/0!",Null:"#NULL!",Value:"#VALUE!",Num:"#NUM!"}}},{}],8:[function(g,I,C){const A=g("../utils/col-cache"),i=g("./anchor");class e{constructor(g,I){this.worksheet=g,this.model=I}get model(){switch(this.type){case"background":return{type:this.type,imageId:this.imageId};case"image":return{type:this.type,imageId:this.imageId,hyperlinks:this.range.hyperlinks,range:{tl:this.range.tl.model,br:this.range.br&&this.range.br.model,ext:this.range.ext,editAs:this.range.editAs}};default:throw new Error("Invalid Image Type")}}set model(g){let{type:I,imageId:C,range:e,hyperlinks:l}=g;if(this.type=I,this.imageId=C,"image"===I)if("string"==typeof e){const g=A.decode(e);this.range={tl:new i(this.worksheet,{col:g.left,row:g.top},-1),br:new i(this.worksheet,{col:g.right,row:g.bottom},0),editAs:"oneCell"}}else this.range={tl:new i(this.worksheet,e.tl,0),br:e.br&&new i(this.worksheet,e.br,0),ext:e.ext,editAs:e.editAs,hyperlinks:l||e.hyperlinks}}}I.exports=e},{"../utils/col-cache":19,"./anchor":2}],9:[function(g,I,C){const A=g("../utils/under-dash");class i{constructor(g){this.note=g}get model(){let g=null;return g="string"==typeof this.note?{type:"note",note:{texts:[{text:this.note}]}}:{type:"note",note:this.note},A.deepMerge({},i.DEFAULT_CONFIGS,g)}set model(g){const{note:I}=g,{texts:C}=I;1===C.length&&1===Object.keys(C[0]).length?this.note=C[0].text:this.note=I}static fromModel(g){const I=new i;return I.model=g,I}}i.DEFAULT_CONFIGS={note:{margins:{insetmode:"auto",inset:[.13,.13,.25,.25]},protection:{locked:"True",lockText:"True"},editAs:"absolute"}},I.exports=i},{"../utils/under-dash":26}],10:[function(g,I,C){const A=g("../utils/col-cache");class i{constructor(){this.decode(arguments)}setTLBR(g,I,C,i,e){if(arguments.length<4){const i=A.decodeAddress(g),l=A.decodeAddress(I);this.model={top:Math.min(i.row,l.row),left:Math.min(i.col,l.col),bottom:Math.max(i.row,l.row),right:Math.max(i.col,l.col),sheetName:C},this.setTLBR(i.row,i.col,l.row,l.col,e)}else this.model={top:Math.min(g,C),left:Math.min(I,i),bottom:Math.max(g,C),right:Math.max(I,i),sheetName:e}}decode(g){switch(g.length){case 5:this.setTLBR(g[0],g[1],g[2],g[3],g[4]);break;case 4:this.setTLBR(g[0],g[1],g[2],g[3]);break;case 3:this.setTLBR(g[0],g[1],g[2]);break;case 2:this.setTLBR(g[0],g[1]);break;case 1:{const I=g[0];if(I instanceof i)this.model={top:I.model.top,left:I.model.left,bottom:I.model.bottom,right:I.model.right,sheetName:I.sheetName};else if(I instanceof Array)this.decode(I);else if(I.top&&I.left&&I.bottom&&I.right)this.model={top:I.top,left:I.left,bottom:I.bottom,right:I.right,sheetName:I.sheetName};else{const g=A.decodeEx(I);g.top?this.model={top:g.top,left:g.left,bottom:g.bottom,right:g.right,sheetName:g.sheetName}:this.model={top:g.row,left:g.col,bottom:g.row,right:g.col,sheetName:g.sheetName}}break}case 0:this.model={top:0,left:0,bottom:0,right:0};break;default:throw new Error(`Invalid number of arguments to _getDimensions() - ${g.length}`)}}get top(){return this.model.top||1}set top(g){this.model.top=g}get left(){return this.model.left||1}set left(g){this.model.left=g}get bottom(){return this.model.bottom||1}set bottom(g){this.model.bottom=g}get right(){return this.model.right||1}set right(g){this.model.right=g}get sheetName(){return this.model.sheetName}set sheetName(g){this.model.sheetName=g}get _serialisedSheetName(){const{sheetName:g}=this.model;return g?/^[a-zA-Z0-9]*$/.test(g)?`${g}!`:`'${g}'!`:""}expand(g,I,C,A){(!this.model.top||gthis.bottom)&&(this.bottom=C),(!this.model.right||A>this.right)&&(this.right=A)}expandRow(g){if(g){const{dimensions:I,number:C}=g;I&&this.expand(C,I.min,C,I.max)}}expandToAddress(g){const I=A.decodeEx(g);this.expand(I.row,I.col,I.row,I.col)}get tl(){return A.n2l(this.left)+this.top}get $t$l(){return`$${A.n2l(this.left)}$${this.top}`}get br(){return A.n2l(this.right)+this.bottom}get $b$r(){return`$${A.n2l(this.right)}$${this.bottom}`}get range(){return`${this._serialisedSheetName+this.tl}:${this.br}`}get $range(){return`${this._serialisedSheetName+this.$t$l}:${this.$b$r}`}get shortRange(){return this.count>1?this.range:this._serialisedSheetName+this.tl}get $shortRange(){return this.count>1?this.$range:this._serialisedSheetName+this.$t$l}get count(){return(1+this.bottom-this.top)*(1+this.right-this.left)}toString(){return this.range}intersects(g){return!(g.sheetName&&this.sheetName&&g.sheetName!==this.sheetName||g.bottomthis.bottom||g.rightthis.right)}contains(g){const I=A.decodeEx(g);return this.containsEx(I)}containsEx(g){return(!g.sheetName||!this.sheetName||g.sheetName===this.sheetName)&&g.row>=this.top&&g.row<=this.bottom&&g.col>=this.left&&g.col<=this.right}forEachAddress(g){for(let I=this.left;I<=this.right;I++)for(let C=this.top;C<=this.bottom;C++)g(A.encodeAddress(C,I),C,I)}}I.exports=i},{"../utils/col-cache":19}],11:[function(g,I,C){const A=g("../utils/under-dash"),i=g("./enums"),e=g("../utils/col-cache"),l=g("./cell");class t{constructor(g,I){this._worksheet=g,this._number=I,this._cells=[],this.style={},this.outlineLevel=0}get number(){return this._number}get worksheet(){return this._worksheet}commit(){this._worksheet._commitRow(this)}destroy(){delete this._worksheet,delete this._cells,delete this.style}findCell(g){return this._cells[g-1]}getCellEx(g){let I=this._cells[g.col-1];if(!I){const C=this._worksheet.getColumn(g.col);I=new l(this,C,g.address),this._cells[g.col-1]=I}return I}getCell(g){if("string"==typeof g){const I=this._worksheet.getColumnKey(g);g=I?I.number:e.l2n(g)}return this._cells[g-1]||this.getCellEx({address:e.encodeAddress(this._number,g),row:this._number,col:g})}splice(g,I){const C=g+I;for(var A=arguments.length,i=new Array(A>2?A-2:0),e=2;e0)for(s=t;s>=C;s--)c=this._cells[s-1],c?(d=this.getCell(s+l),d.value=c.value,d.style=c.style,d._comment=c._comment):this._cells[s+l-1]=void 0;for(s=0;s{g&&g.type!==i.ValueType.Null&&I(g,C+1)}))}addPageBreak(g,I){const C=this._worksheet,A=Math.max(0,g-1)||0,i=Math.max(0,I-1)||16838,e={id:this._number,max:i,man:1};A&&(e.min=A),C.rowBreaks.push(e)}get values(){const g=[];return this._cells.forEach((I=>{I&&I.type!==i.ValueType.Null&&(g[I.col]=I.value)})),g}set values(g){if(this._cells=[],g)if(g instanceof Array){let I=0;g.hasOwnProperty("0")&&(I=1),g.forEach(((g,C)=>{void 0!==g&&(this.getCellEx({address:e.encodeAddress(this._number,C+I),row:this._number,col:C+I}).value=g)}))}else this._worksheet.eachColumnKey(((I,C)=>{void 0!==g[C]&&(this.getCellEx({address:e.encodeAddress(this._number,I.number),row:this._number,col:I.number}).value=g[C])}))}get hasValues(){return A.some(this._cells,(g=>g&&g.type!==i.ValueType.Null))}get cellCount(){return this._cells.length}get actualCellCount(){let g=0;return this.eachCell((()=>{g++})),g}get dimensions(){let g=0,I=0;return this._cells.forEach((C=>{C&&C.type!==i.ValueType.Null&&((!g||g>C.col)&&(g=C.col),I0?{min:g,max:I}:null}_applyStyle(g,I){return this.style[g]=I,this._cells.forEach((C=>{C&&(C[g]=I)})),I}get numFmt(){return this.style.numFmt}set numFmt(g){this._applyStyle("numFmt",g)}get font(){return this.style.font}set font(g){this._applyStyle("font",g)}get alignment(){return this.style.alignment}set alignment(g){this._applyStyle("alignment",g)}get protection(){return this.style.protection}set protection(g){this._applyStyle("protection",g)}get border(){return this.style.border}set border(g){this._applyStyle("border",g)}get fill(){return this.style.fill}set fill(g){this._applyStyle("fill",g)}get hidden(){return!!this._hidden}set hidden(g){this._hidden=g}get outlineLevel(){return this._outlineLevel||0}set outlineLevel(g){this._outlineLevel=g}get collapsed(){return!!(this._outlineLevel&&this._outlineLevel>=this._worksheet.properties.outlineLevelRow)}get model(){const g=[];let I=0,C=0;return this._cells.forEach((A=>{if(A){const i=A.model;i&&((!I||I>A.col)&&(I=A.col),C{switch(g.type){case l.Types.Merge:break;default:{let C;if(g.address)C=e.decodeAddress(g.address);else if(I){const{row:g}=I,A=I.col+1;C={row:g,col:A,address:e.encodeAddress(g,A),$col$row:`$${e.n2l(A)}$${g}`}}I=C,this.getCellEx(C).model=g;break}}})),g.height?this.height=g.height:delete this.height,this.hidden=g.hidden,this.outlineLevel=g.outlineLevel||0,this.style=g.style&&JSON.parse(JSON.stringify(g.style))||{}}}I.exports=t},{"../utils/col-cache":19,"../utils/under-dash":26,"./cell":3,"./enums":7}],12:[function(g,I,C){const A=g("../utils/col-cache");class i{constructor(g,I,C){this.table=g,this.column=I,this.index=C}_set(g,I){this.table.cacheState(),this.column[g]=I}get name(){return this.column.name}set name(g){this._set("name",g)}get filterButton(){return this.column.filterButton}set filterButton(g){this.column.filterButton=g}get style(){return this.column.style}set style(g){this.column.style=g}get totalsRowLabel(){return this.column.totalsRowLabel}set totalsRowLabel(g){this._set("totalsRowLabel",g)}get totalsRowFunction(){return this.column.totalsRowFunction}set totalsRowFunction(g){this._set("totalsRowFunction",g)}get totalsRowResult(){return this.column.totalsRowResult}set totalsRowResult(g){this._set("totalsRowResult",g)}get totalsRowFormula(){return this.column.totalsRowFormula}set totalsRowFormula(g){this._set("totalsRowFormula",g)}}class e{constructor(g,I){this.worksheet=g,I&&(this.table=I,this.validate(),this.store())}getFormula(g){switch(g.totalsRowFunction){case"none":return null;case"average":return`SUBTOTAL(101,${this.table.name}[${g.name}])`;case"countNums":return`SUBTOTAL(102,${this.table.name}[${g.name}])`;case"count":return`SUBTOTAL(103,${this.table.name}[${g.name}])`;case"max":return`SUBTOTAL(104,${this.table.name}[${g.name}])`;case"min":return`SUBTOTAL(105,${this.table.name}[${g.name}])`;case"stdDev":return`SUBTOTAL(106,${this.table.name}[${g.name}])`;case"var":return`SUBTOTAL(107,${this.table.name}[${g.name}])`;case"sum":return`SUBTOTAL(109,${this.table.name}[${g.name}])`;case"custom":return g.totalsRowFormula;default:throw new Error(`Invalid Totals Row Function: ${g.totalsRowFunction}`)}}get width(){return this.table.columns.length}get height(){return this.table.rows.length}get filterHeight(){return this.height+(this.table.headerRow?1:0)}get tableHeight(){return this.filterHeight+(this.table.totalsRow?1:0)}validate(){const{table:g}=this,I=(g,I,C)=>{void 0===g[I]&&(g[I]=C)};I(g,"headerRow",!0),I(g,"totalsRow",!1),I(g,"style",{}),I(g.style,"theme","TableStyleMedium2"),I(g.style,"showFirstColumn",!1),I(g.style,"showLastColumn",!1),I(g.style,"showRowStripes",!1),I(g.style,"showColumnStripes",!1);const C=(g,I)=>{if(!g)throw new Error(I)};C(g.ref,"Table must have ref"),C(g.columns,"Table must have column definitions"),C(g.rows,"Table must have row definitions"),g.tl=A.decodeAddress(g.ref);const{row:i,col:e}=g.tl;C(i>0,"Table must be on valid row"),C(e>0,"Table must be on valid col");const{width:l,filterHeight:t,tableHeight:s}=this;g.autoFilterRef=A.encode(i,e,i+t-1,e+l-1),g.tableRef=A.encode(i,e,i+s-1,e+l-1),g.columns.forEach(((g,A)=>{C(g.name,`Column ${A} must have a name`),0===A?I(g,"totalsRowLabel","Total"):(I(g,"totalsRowFunction","none"),g.totalsRowFormula=this.getFormula(g))}))}store(){const g=(g,I)=>{I&&Object.keys(I).forEach((C=>{g[C]=I[C]}))},{worksheet:I,table:C}=this,{row:A,col:i}=C.tl;let e=0;if(C.headerRow){const l=I.getRow(A+e++);C.columns.forEach(((I,C)=>{const{style:A,name:e}=I,t=l.getCell(i+C);t.value=e,g(t,A)}))}if(C.rows.forEach((l=>{const t=I.getRow(A+e++);l.forEach(((I,A)=>{const e=t.getCell(i+A);e.value=I,g(e,C.columns[A].style)}))})),C.totalsRow){const l=I.getRow(A+e++);C.columns.forEach(((I,C)=>{const A=l.getCell(i+C);if(0===C)A.value=I.totalsRowLabel;else{const g=this.getFormula(I);A.value=g?{formula:I.totalsRowFormula,result:I.totalsRowResult}:null}g(A,I.style)}))}}load(g){const{table:I}=this,{row:C,col:A}=I.tl;let i=0;if(I.headerRow){const e=g.getRow(C+i++);I.columns.forEach(((g,I)=>{e.getCell(A+I).value=g.name}))}if(I.rows.forEach((I=>{const e=g.getRow(C+i++);I.forEach(((g,I)=>{e.getCell(A+I).value=g}))})),I.totalsRow){const e=g.getRow(C+i++);I.columns.forEach(((g,I)=>{const C=e.getCell(A+I);0===I?C.value=g.totalsRowLabel:this.getFormula(g)&&(C.value={formula:g.totalsRowFormula,result:g.totalsRowResult})}))}}get model(){return this.table}set model(g){this.table=g}cacheState(){this._cache||(this._cache={ref:this.ref,width:this.width,tableHeight:this.tableHeight})}commit(){if(!this._cache)return;this.validate();const g=A.decodeAddress(this._cache.ref);if(this.ref!==this._cache.ref)for(let I=0;I1&&void 0!==arguments[1]?arguments[1]:1;this.cacheState(),this.table.rows.splice(g,I)}getColumn(g){const I=this.table.columns[g];return new i(this,I,g)}addColumn(g,I,C){this.cacheState(),void 0===C?(this.table.columns.push(g),this.table.rows.forEach(((g,C)=>{g.push(I[C])}))):(this.table.columns.splice(C,0,g),this.table.rows.forEach(((g,A)=>{g.splice(C,0,I[A])})))}removeColumns(g){let I=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;this.cacheState(),this.table.columns.splice(g,I),this.table.rows.forEach((C=>{C.splice(g,I)}))}_assign(g,I,C){this.cacheState(),g[I]=C}get ref(){return this.table.ref}set ref(g){this._assign(this.table,"ref",g)}get name(){return this.table.name}set name(g){this.table.name=g}get displayName(){return this.table.displyName||this.table.name}set displayNamename(g){this.table.displayName=g}get headerRow(){return this.table.headerRow}set headerRow(g){this._assign(this.table,"headerRow",g)}get totalsRow(){return this.table.totalsRow}set totalsRow(g){this._assign(this.table,"totalsRow",g)}get theme(){return this.table.style.name}set theme(g){this.table.style.name=g}get showFirstColumn(){return this.table.style.showFirstColumn}set showFirstColumn(g){this.table.style.showFirstColumn=g}get showLastColumn(){return this.table.style.showLastColumn}set showLastColumn(g){this.table.style.showLastColumn=g}get showRowStripes(){return this.table.style.showRowStripes}set showRowStripes(g){this.table.style.showRowStripes=g}get showColumnStripes(){return this.table.style.showColumnStripes}set showColumnStripes(g){this.table.style.showColumnStripes=g}}I.exports=e},{"../utils/col-cache":19}],13:[function(g,I,C){const A=g("./worksheet"),i=g("./defined-names"),e=g("../xlsx/xlsx"),l=g("../csv/csv");class t{constructor(){this.category="",this.company="",this.created=new Date,this.description="",this.keywords="",this.manager="",this.modified=this.created,this.properties={},this.calcProperties={},this._worksheets=[],this.subject="",this.title="",this.views=[],this.media=[],this._definedNames=new i}get xlsx(){return this._xlsx||(this._xlsx=new e(this)),this._xlsx}get csv(){return this._csv||(this._csv=new l(this)),this._csv}get nextId(){for(let g=1;g(I&&I.orderNo)>g?I.orderNo:g),0),e=Object.assign({},I,{id:C,name:g,orderNo:i+1,workbook:this}),l=new A(e);return this._worksheets[C]=l,l}removeWorksheetEx(g){delete this._worksheets[g.id]}removeWorksheet(g){const I=this.getWorksheet(g);I&&I.destroy()}getWorksheet(g){return void 0===g?this._worksheets.find(Boolean):"number"==typeof g?this._worksheets[g]:"string"==typeof g?this._worksheets.find((I=>I&&I.name===g)):void 0}get worksheets(){return this._worksheets.slice(1).sort(((g,I)=>g.orderNo-I.orderNo)).filter(Boolean)}eachSheet(g){this.worksheets.forEach((I=>{g(I,I.id)}))}get definedNames(){return this._definedNames}clearThemes(){this._themes=void 0}addImage(g){const I=this.media.length;return this.media.push(Object.assign({},g,{type:"image"})),I}getImage(g){return this.media[g]}get model(){return{creator:this.creator||"Unknown",lastModifiedBy:this.lastModifiedBy||"Unknown",lastPrinted:this.lastPrinted,created:this.created,modified:this.modified,properties:this.properties,worksheets:this.worksheets.map((g=>g.model)),sheets:this.worksheets.map((g=>g.model)).filter(Boolean),definedNames:this._definedNames.model,views:this.views,company:this.company,manager:this.manager,title:this.title,subject:this.subject,keywords:this.keywords,category:this.category,description:this.description,language:this.language,revision:this.revision,contentStatus:this.contentStatus,themes:this._themes,media:this.media,calcProperties:this.calcProperties}}set model(g){this.creator=g.creator,this.lastModifiedBy=g.lastModifiedBy,this.lastPrinted=g.lastPrinted,this.created=g.created,this.modified=g.modified,this.company=g.company,this.manager=g.manager,this.title=g.title,this.subject=g.subject,this.keywords=g.keywords,this.category=g.category,this.description=g.description,this.language=g.language,this.revision=g.revision,this.contentStatus=g.contentStatus,this.properties=g.properties,this.calcProperties=g.calcProperties,this._worksheets=[],g.worksheets.forEach((I=>{const{id:C,name:i,state:e}=I,l=g.sheets&&g.sheets.findIndex((g=>g.id===C));(this._worksheets[C]=new A({id:C,name:i,orderNo:l,state:e,workbook:this})).model=I})),this._definedNames.model=g.definedNames,this.views=g.views,this._themes=g.themes,this.media=g.media||[]}}I.exports=t},{"../csv/csv":1,"../xlsx/xlsx":144,"./defined-names":6,"./worksheet":14}],14:[function(g,I,C){const A=g("../utils/under-dash"),i=g("../utils/col-cache"),e=g("./range"),l=g("./row"),t=g("./column"),s=g("./enums"),c=g("./image"),d=g("./table"),o=g("./data-validations"),n=g("../utils/encryptor"),{copyStyle:a}=g("../utils/copy-style");class Z{constructor(g){g=g||{},this._workbook=g.workbook,this.id=g.id,this.orderNo=g.orderNo,this.name=g.name,this.state=g.state||"visible",this._rows=[],this._columns=null,this._keys={},this._merges={},this.rowBreaks=[],this.properties=Object.assign({},{defaultRowHeight:15,dyDescent:55,outlineLevelCol:0,outlineLevelRow:0},g.properties),this.pageSetup=Object.assign({},{margins:{left:.7,right:.7,top:.75,bottom:.75,header:.3,footer:.3},orientation:"portrait",horizontalDpi:4294967295,verticalDpi:4294967295,fitToPage:!(!g.pageSetup||!g.pageSetup.fitToWidth&&!g.pageSetup.fitToHeight||g.pageSetup.scale),pageOrder:"downThenOver",blackAndWhite:!1,draft:!1,cellComments:"None",errors:"displayed",scale:100,fitToWidth:1,fitToHeight:1,paperSize:void 0,showRowColHeaders:!1,showGridLines:!1,firstPageNumber:void 0,horizontalCentered:!1,verticalCentered:!1,rowBreaks:null,colBreaks:null},g.pageSetup),this.headerFooter=Object.assign({},{differentFirst:!1,differentOddEven:!1,oddHeader:null,oddFooter:null,evenHeader:null,evenFooter:null,firstHeader:null,firstFooter:null},g.headerFooter),this.dataValidations=new o,this.views=g.views||[],this.autoFilter=g.autoFilter||null,this._media=[],this.sheetProtection=null,this.tables={},this.conditionalFormattings=[]}get name(){return this._name}set name(g){if(void 0===g&&(g=`sheet${this.id}`),this._name!==g){if("string"!=typeof g)throw new Error("The name has to be a string.");if(""===g)throw new Error("The name can't be empty.");if("History"===g)throw new Error('The name "History" is protected. Please use a different name.');if(/[*?:/\\[\]]/.test(g))throw new Error(`Worksheet name ${g} cannot include any of the following characters: * ? : \\ / [ ]`);if(/(^')|('$)/.test(g))throw new Error(`The first or last character of worksheet name cannot be a single quotation mark: ${g}`);if(g&&g.length>31&&(console.warn(`Worksheet name ${g} exceeds 31 chars. This will be truncated`),g=g.substring(0,31)),this._workbook._worksheets.find((I=>I&&I.name.toLowerCase()===g.toLowerCase())))throw new Error(`Worksheet name already exists: ${g}`);this._name=g}}get workbook(){return this._workbook}destroy(){this._workbook.removeWorksheetEx(this)}get dimensions(){const g=new e;return this._rows.forEach((I=>{if(I){const C=I.dimensions;C&&g.expand(I.number,C.min,I.number,C.max)}})),g}get columns(){return this._columns}set columns(g){this._headerRowCount=g.reduce(((g,I)=>{const C=(I.header?1:I.headers&&I.headers.length)||0;return Math.max(g,C)}),0);let I=1;const C=this._columns=[];g.forEach((g=>{const A=new t(this,I++,!1);C.push(A),A.defn=g}))}getColumnKey(g){return this._keys[g]}setColumnKey(g,I){this._keys[g]=I}deleteColumnKey(g){delete this._keys[g]}eachColumnKey(g){A.each(this._keys,g)}getColumn(g){if("string"==typeof g){const I=this._keys[g];if(I)return I;g=i.l2n(g)}if(this._columns||(this._columns=[]),g>this._columns.length){let I=this._columns.length+1;for(;I<=g;)this._columns.push(new t(this,I++))}return this._columns[g-1]}spliceColumns(g,I){const C=this._rows.length;for(var A=arguments.length,i=new Array(A>2?A-2:0),e=2;e0)for(let c=0;c{C.push(g[c]||null)}));const A=this.getRow(c+1);A.splice.apply(A,C)}else this._rows.forEach((C=>{C&&C.splice(g,I)}));const l=i.length-I,t=g+I,s=this._columns.length;if(l<0)for(let c=g+i.length;c<=s;c++)this.getColumn(c).defn=this.getColumn(c-l).defn;else if(l>0)for(let c=s;c>=t;c--)this.getColumn(c+l).defn=this.getColumn(c).defn;for(let c=g;c{g=Math.max(g,I.cellCount)})),g}get actualColumnCount(){const g=[];let I=0;return this.eachRow((C=>{C.eachCell((C=>{let{col:A}=C;g[A]||(g[A]=!0,I++)}))})),I}_commitRow(){}get _lastRowNumber(){const g=this._rows;let I=g.length;for(;I>0&&void 0===g[I-1];)I--;return I}get _nextRow(){return this._lastRowNumber+1}get lastRow(){if(this._rows.length)return this._rows[this._rows.length-1]}findRow(g){return this._rows[g-1]}findRows(g,I){return this._rows.slice(g-1,g-1+I)}get rowCount(){return this._lastRowNumber}get actualRowCount(){let g=0;return this.eachRow((()=>{g++})),g}getRow(g){let I=this._rows[g-1];return I||(I=this._rows[g-1]=new l(this,g)),I}getRows(g,I){if(I<1)return;const C=[];for(let A=g;A1&&void 0!==arguments[1]?arguments[1]:"n";const C=this._nextRow,A=this.getRow(C);return A.values=g,this._setStyleOption(C,"i"===I[0]?I:"n"),A}addRows(g){let I=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"n";const C=[];return g.forEach((g=>{C.push(this.addRow(g,I))})),C}insertRow(g,I){let C=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"n";return this.spliceRows(g,0,I),this._setStyleOption(g,C),this.getRow(g)}insertRows(g,I){let C=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"n";if(this.spliceRows(g,0,...I),"n"!==C)for(let A=0;A1&&void 0!==arguments[1]?arguments[1]:"n";"o"===I[0]&&void 0!==this.findRow(g+1)?this._copyStyle(g+1,g,"+"===I[1]):"i"===I[0]&&void 0!==this.findRow(g-1)&&this._copyStyle(g-1,g,"+"===I[1])}_copyStyle(g,I){let C=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const A=this.getRow(g),i=this.getRow(I);i.style=a(A.style),A.eachCell({includeEmpty:C},((g,I)=>{i.getCell(I).style=a(g.style)})),i.height=A.height}duplicateRow(g,I){let C=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const A=this._rows[g-1],i=new Array(I).fill(A.values);this.spliceRows(g+1,C?0:I,...i);for(let e=0;e{I.getCell(C).style=g.style}))}}spliceRows(g,I){const C=g+I;for(var A=arguments.length,i=new Array(A>2?A-2:0),e=2;e{g.getCell(C).style=I.style})),this._rows[c-1]=void 0}else this._rows[c+t-1]=void 0;else if(t>0)for(c=s;c>=C;c--)if(d=this._rows[c-1],d){const g=this.getRow(c+t);g.values=d.values,g.style=d.style,g.height=d.height,d.eachCell({includeEmpty:!0},((I,C)=>{if(g.getCell(C).style=I.style,"MergeValue"===I._value.constructor.name){const g=this.getRow(I._row._number+l).getCell(C),A=I._value._master,i=this.getRow(A._row._number+l).getCell(A._column._number);g.merge(i)}}))}else this._rows[c+t-1]=void 0;for(c=0;c{g&&g.hasValues&&I(g,g.number)}))}getSheetValues(){const g=[];return this._rows.forEach((I=>{I&&(g[I.number]=I.values)})),g}findCell(g,I){const C=i.getAddress(g,I),A=this._rows[C.row-1];return A?A.findCell(C.col):void 0}getCell(g,I){const C=i.getAddress(g,I);return this.getRow(C.row).getCellEx(C)}mergeCells(){for(var g=arguments.length,I=new Array(g),C=0;C{if(I.intersects(g))throw new Error("Cannot merge already merged cells")}));const C=this.getCell(g.top,g.left);for(let A=g.top;A<=g.bottom;A++)for(let i=g.left;i<=g.right;i++)(A>g.top||i>g.left)&&this.getCell(A,i).merge(C,I);this._merges[C.address]=g}_unMergeMaster(g){const I=this._merges[g.address];if(I){for(let g=I.top;g<=I.bottom;g++)for(let C=I.left;C<=I.right;C++)this.getCell(g,C).unmerge();delete this._merges[g.address]}}get hasMerges(){return A.some(this._merges,Boolean)}unMergeCells(){for(var g=arguments.length,I=new Array(g),C=0;C3&&void 0!==arguments[3]?arguments[3]:"shared";const e=i.decode(g),{top:l,left:t,bottom:s,right:c}=e,d=c-t+1,o=i.encodeAddress(l,t),n="shared"===A;let a;a="function"==typeof C?C:Array.isArray(C)?Array.isArray(C[0])?(g,I)=>C[g-l][I-t]:(g,I)=>C[(g-l)*d+(I-t)]:()=>{};let Z=!0;for(let i=l;i<=s;i++)for(let C=t;C<=c;C++)Z?(this.getCell(i,C).value={shareType:A,formula:I,ref:g,result:a(i,C)},Z=!1):this.getCell(i,C).value=n?{sharedFormula:o,result:a(i,C)}:a(i,C)}addImage(g,I){const C={type:"image",imageId:g,range:I};this._media.push(new c(this,C))}getImages(){return this._media.filter((g=>"image"===g.type))}addBackgroundImage(g){const I={type:"background",imageId:g};this._media.push(new c(this,I))}getBackgroundImageId(){const g=this._media.find((g=>"background"===g.type));return g&&g.imageId}protect(g,I){return new Promise((C=>{this.sheetProtection={sheet:!0},I&&"spinCount"in I&&(I.spinCount=Number.isFinite(I.spinCount)?Math.round(Math.max(0,I.spinCount)):1e5),g&&(this.sheetProtection.algorithmName="SHA-512",this.sheetProtection.saltValue=n.randomBytes(16).toString("base64"),this.sheetProtection.spinCount=I&&"spinCount"in I?I.spinCount:1e5,this.sheetProtection.hashValue=n.convertPasswordToHash(g,"SHA512",this.sheetProtection.saltValue,this.sheetProtection.spinCount)),I&&(this.sheetProtection=Object.assign(this.sheetProtection,I),!g&&"spinCount"in I&&delete this.sheetProtection.spinCount),C()}))}unprotect(){this.sheetProtection=null}addTable(g){const I=new d(this,g);return this.tables[g.name]=I,I}getTable(g){return this.tables[g]}removeTable(g){delete this.tables[g]}getTables(){return Object.values(this.tables)}addConditionalFormatting(g){this.conditionalFormattings.push(g)}removeConditionalFormatting(g){"number"==typeof g?this.conditionalFormattings.splice(g,1):this.conditionalFormattings=g instanceof Function?this.conditionalFormattings.filter(g):[]}get tabColor(){return console.trace("worksheet.tabColor property is now deprecated. Please use worksheet.properties.tabColor"),this.properties.tabColor}set tabColor(g){console.trace("worksheet.tabColor property is now deprecated. Please use worksheet.properties.tabColor"),this.properties.tabColor=g}get model(){const g={id:this.id,name:this.name,dataValidations:this.dataValidations.model,properties:this.properties,state:this.state,pageSetup:this.pageSetup,headerFooter:this.headerFooter,rowBreaks:this.rowBreaks,views:this.views,autoFilter:this.autoFilter,media:this._media.map((g=>g.model)),sheetProtection:this.sheetProtection,tables:Object.values(this.tables).map((g=>g.model)),conditionalFormattings:this.conditionalFormattings};g.cols=t.toModel(this.columns);const I=g.rows=[],C=g.dimensions=new e;return this._rows.forEach((g=>{const A=g&&g.model;A&&(C.expand(A.number,A.min,A.number,A.max),I.push(A))})),g.merges=[],A.each(this._merges,(I=>{g.merges.push(I.range)})),g}_parseRows(g){this._rows=[],g.rows.forEach((g=>{const I=new l(this,g.number);this._rows[I.number-1]=I,I.model=g}))}_parseMergeCells(g){A.each(g.mergeCells,(g=>{this.mergeCellsWithoutStyle(g)}))}set model(g){this.name=g.name,this._columns=t.fromModel(this,g.cols),this._parseRows(g),this._parseMergeCells(g),this.dataValidations=new o(g.dataValidations),this.properties=g.properties,this.pageSetup=g.pageSetup,this.headerFooter=g.headerFooter,this.views=g.views,this.autoFilter=g.autoFilter,this._media=g.media.map((g=>new c(this,g))),this.sheetProtection=g.sheetProtection,this.tables=g.tables.reduce(((g,I)=>{const C=new d;return C.model=I,g[I.name]=C,g}),{}),this.conditionalFormattings=g.conditionalFormattings}}I.exports=Z},{"../utils/col-cache":19,"../utils/copy-style":20,"../utils/encryptor":21,"../utils/under-dash":26,"./column":4,"./data-validations":5,"./enums":7,"./image":8,"./range":10,"./row":11,"./table":12}],15:[function(g,I,C){g("core-js/modules/es.promise"),g("core-js/modules/es.promise.finally"),g("core-js/modules/es.object.assign"),g("core-js/modules/es.object.keys"),g("core-js/modules/es.object.values"),g("core-js/modules/es.symbol"),g("core-js/modules/es.symbol.async-iterator"),g("core-js/modules/es.array.iterator"),g("core-js/modules/es.array.includes"),g("core-js/modules/es.array.find-index"),g("core-js/modules/es.array.find"),g("core-js/modules/es.string.from-code-point"),g("core-js/modules/es.string.includes"),g("core-js/modules/es.number.is-nan"),g("regenerator-runtime/runtime");const A={Workbook:g("./doc/workbook")},i=g("./doc/enums");Object.keys(i).forEach((g=>{A[g]=i[g]})),I.exports=A},{"./doc/enums":7,"./doc/workbook":13,"core-js/modules/es.array.find":359,"core-js/modules/es.array.find-index":358,"core-js/modules/es.array.includes":360,"core-js/modules/es.array.iterator":361,"core-js/modules/es.number.is-nan":363,"core-js/modules/es.object.assign":364,"core-js/modules/es.object.keys":366,"core-js/modules/es.object.values":367,"core-js/modules/es.promise":372,"core-js/modules/es.promise.finally":371,"core-js/modules/es.string.from-code-point":376,"core-js/modules/es.string.includes":377,"core-js/modules/es.symbol":381,"core-js/modules/es.symbol.async-iterator":378,"regenerator-runtime/runtime":492}],16:[function(g,I,C){const A="undefined"==typeof TextDecoder?null:new TextDecoder("utf-8");function i(g){return"string"==typeof g?g:A?A.decode(g):g.toString()}C.bufferToString=i},{}],17:[function(g,I,C){const A="undefined"==typeof TextEncoder?null:new TextEncoder("utf-8"),{Buffer:i}=g("buffer");function e(g){return"string"!=typeof g?g:A?i.from(A.encode(g).buffer):i.from(g)}C.stringToBuffer=e},{buffer:220}],18:[function(g,I,C){const A=g("./under-dash"),i=g("./col-cache");class e{constructor(g){this.template=g,this.sheets={}}addCell(g){this.addCellEx(i.decodeEx(g))}getCell(g){return this.findCellEx(i.decodeEx(g),!0)}findCell(g){return this.findCellEx(i.decodeEx(g),!1)}findCellAt(g,I,C){const A=this.sheets[g],i=A&&A[I];return i&&i[C]}addCellEx(g){if(g.top)for(let I=g.top;I<=g.bottom;I++)for(let C=g.left;C<=g.right;C++)this.getCellAt(g.sheetName,I,C);else this.findCellEx(g,!0)}getCellEx(g){return this.findCellEx(g,!0)}findCellEx(g,I){const C=this.findSheet(g,I),A=this.findSheetRow(C,g,I);return this.findRowCell(A,g,I)}getCellAt(g,I,C){const A=this.sheets[g]||(this.sheets[g]=[]),e=A[I]||(A[I]=[]);return e[C]||(e[C]={sheetName:g,address:i.n2l(C)+I,row:I,col:C})}removeCellEx(g){const I=this.findSheet(g);if(!I)return;const C=this.findSheetRow(I,g);C&&delete C[g.col]}forEachInSheet(g,I){const C=this.sheets[g];C&&C.forEach(((g,C)=>{g&&g.forEach(((g,A)=>{g&&I(g,C,A)}))}))}forEach(g){A.each(this.sheets,((I,C)=>{this.forEachInSheet(C,g)}))}map(g){const I=[];return this.forEach((C=>{I.push(g(C))})),I}findSheet(g,I){const C=g.sheetName;return this.sheets[C]?this.sheets[C]:I?this.sheets[C]=[]:void 0}findSheetRow(g,I,C){const{row:A}=I;return g&&g[A]?g[A]:C?g[A]=[]:void 0}findRowCell(g,I,C){const{col:A}=I;return g&&g[A]?g[A]:C?g[A]=this.template?Object.assign(I,JSON.parse(JSON.stringify(this.template))):I:void 0}spliceRows(g,I,C,A){const i=this.sheets[g];if(i){const g=[];for(let I=0;I{A.splice(I,C,...g)}))}}}I.exports=e},{"./col-cache":19,"./under-dash":26}],19:[function(g,I,C){const A=/^[A-Z]+\d+$/,i={_dictionary:["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"],_l2nFill:0,_l2n:{},_n2l:[],_level:g=>g<=26?1:g<=676?2:3,_fill(g){let I,C,A,i,e,l=1;if(g>=4)throw new Error("Out of bounds. Excel supports columns from 1 to 16384");if(this._l2nFill<1&&g>=1){for(;l<=26;)I=this._dictionary[l-1],this._n2l[l]=I,this._l2n[I]=l,l++;this._l2nFill=1}if(this._l2nFill<2&&g>=2){for(l=27;l<=702;)C=l-27,A=C%26,i=Math.floor(C/26),I=this._dictionary[i]+this._dictionary[A],this._n2l[l]=I,this._l2n[I]=l,l++;this._l2nFill=2}if(this._l2nFill<3&&g>=3){for(l=703;l<=16384;)C=l-703,A=C%26,i=Math.floor(C/26)%26,e=Math.floor(C/676),I=this._dictionary[e]+this._dictionary[i]+this._dictionary[A],this._n2l[l]=I,this._l2n[I]=l,l++;this._l2nFill=3}},l2n(g){if(this._l2n[g]||this._fill(g.length),!this._l2n[g])throw new Error(`Out of bounds. Invalid column letter: ${g}`);return this._l2n[g]},n2l(g){if(g<1||g>16384)throw new Error(`${g} is out of bounds. Excel supports columns from 1 to 16384`);return this._n2l[g]||this._fill(this._level(g)),this._n2l[g]},_hash:{},validateAddress(g){if(!A.test(g))throw new Error(`Invalid Address: ${g}`);return!0},decodeAddress(g){const I=g.length<5&&this._hash[g];if(I)return I;let C=!1,A="",i=0,e=!1,l="",t=0;for(let c,d=0;d=65&&c<=90)C=!0,A+=g[d],i=26*i+c-64;else if(c>=48&&c<=57)e=!0,l+=g[d],t=10*t+c-48;else if(e&&C&&36!==c)break;if(C){if(i>16384)throw new Error(`Out of bounds. Invalid column letter: ${A}`)}else i=void 0;e||(t=void 0);const s={address:g=A+l,col:i,row:t,$col$row:`$${A}$${l}`};return i<=100&&t<=100&&(this._hash[g]=s,this._hash[s.$col$row]=s),s},getAddress(g,I){if(I){const C=this.n2l(I)+g;return this.decodeAddress(C)}return this.decodeAddress(g)},decode(g){const I=g.split(":");if(2===I.length){const g=this.decodeAddress(I[0]),C=this.decodeAddress(I[1]),A={top:Math.min(g.row,C.row),left:Math.min(g.col,C.col),bottom:Math.max(g.row,C.row),right:Math.max(g.col,C.col)};return A.tl=this.n2l(A.left)+A.top,A.br=this.n2l(A.right)+A.bottom,A.dimensions=`${A.tl}:${A.br}`,A}return this.decodeAddress(g)},decodeEx(g){const I=g.match(/(?:(?:(?:'((?:[^']|'')*)')|([^'^ !]*))!)?(.*)/),C=I[1]||I[2],A=I[3],i=A.split(":");if(i.length>1){let g=this.decodeAddress(i[0]),I=this.decodeAddress(i[1]);const A=Math.min(g.row,I.row),e=Math.min(g.col,I.col),l=Math.max(g.row,I.row),t=Math.max(g.col,I.col);return g=this.n2l(e)+A,I=this.n2l(t)+l,{top:A,left:e,bottom:l,right:t,sheetName:C,tl:{address:g,col:e,row:A,$col$row:`$${this.n2l(e)}$${A}`,sheetName:C},br:{address:I,col:t,row:l,$col$row:`$${this.n2l(t)}$${l}`,sheetName:C},dimensions:`${g}:${I}`}}if(A.startsWith("#"))return C?{sheetName:C,error:A}:{error:A};const e=this.decodeAddress(A);return C?{sheetName:C,...e}:e},encodeAddress:(g,I)=>i.n2l(I)+g,encode(){switch(arguments.length){case 2:return i.encodeAddress(arguments[0],arguments[1]);case 4:return`${i.encodeAddress(arguments[0],arguments[1])}:${i.encodeAddress(arguments[2],arguments[3])}`;default:throw new Error("Can only encode with 2 or 4 arguments")}},inRange(g,I){const[C,A,,i,e]=g,[l,t]=I;return l>=C&&l<=i&&t>=A&&t<=e}};I.exports=i},{}],20:[function(g,I,C){const A=(g,I)=>({...g,...I.reduce(((I,C)=>(g[C]&&(I[C]={...g[C]}),I)),{})}),i=function(g,I,C){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[];g[C]&&(I[C]=A(g[C],i))},e=g=>0===Object.keys(g).length,l=g=>{if(!g)return g;if(e(g))return{};const I={...g};return i(g,I,"font",["color"]),i(g,I,"alignment"),i(g,I,"protection"),g.border&&(i(g,I,"border"),i(g.border,I.border,"top",["color"]),i(g.border,I.border,"left",["color"]),i(g.border,I.border,"bottom",["color"]),i(g.border,I.border,"right",["color"]),i(g.border,I.border,"diagonal",["color"])),g.fill&&(i(g,I,"fill",["fgColor","bgColor","center"]),g.fill.stops&&(I.fill.stops=g.fill.stops.map((g=>A(g,["color"]))))),I};C.copyStyle=l},{}],21:[function(g,I,C){(function(C){(function(){const A=g("crypto"),i={hash(g){const I=A.createHash(g);for(var i=arguments.length,e=new Array(i>1?i-1:0),l=1;lA.randomBytes(g)};I.exports=i}).call(this)}).call(this,g("buffer").Buffer)},{buffer:220,crypto:390}],22:[function(g,I,C){const{SaxesParser:A}=g("saxes"),{PassThrough:i}=g("readable-stream"),{bufferToString:e}=g("./browser-buffer-decode");I.exports=async function*(g){g.pipe&&!g[Symbol.asyncIterator]&&(g=g.pipe(new i));const I=new A;let C;I.on("error",(g=>{C=g}));let l=[];I.on("opentag",(g=>l.push({eventType:"opentag",value:g}))),I.on("text",(g=>l.push({eventType:"text",value:g}))),I.on("closetag",(g=>l.push({eventType:"closetag",value:g})));for await(const A of g){if(I.write(e(A)),C)throw C;yield l,l=[]}}},{"./browser-buffer-decode":16,"readable-stream":491,saxes:496}],23:[function(g,I,C){const A=g("./col-cache"),i=/(([a-z_\-0-9]*)!)?([a-z0-9_$]{2,})([(])?/gi,e=/^([$])?([a-z]+)([$])?([1-9][0-9]*)$/i;function l(g,I,C){const l=A.decode(I),t=A.decode(C);return g.replace(i,((g,I,C,i,s)=>{if(s)return g;const c=e.exec(i);if(c){const C=c[1],i=c[2].toUpperCase(),e=c[3],s=c[4];if(i.length>3||3===i.length&&i>"XFD")return g;let d=A.l2n(i),o=parseInt(s,10);return C||(d+=t.col-l.col),e||(o+=t.row-l.row),(I||"")+(C||"")+A.n2l(d)+(e||"")+o}return g}))}I.exports={slideFormula:l}},{"./col-cache":19}],24:[function(g,I,C){(function(C,A){(function(){const i=g("readable-stream"),e=g("./utils"),l=g("./string-buf");class t{constructor(g,I){this._data=g,this._encoding=I}get length(){return this.toBuffer().length}copy(g,I,C,A){return this.toBuffer().copy(g,I,C,A)}toBuffer(){return this._buffer||(this._buffer=A.from(this._data,this._encoding)),this._buffer}}class s{constructor(g){this._data=g}get length(){return this._data.length}copy(g,I,C,A){return this._data._buf.copy(g,I,C,A)}toBuffer(){return this._data.toBuffer()}}class c{constructor(g){this._data=g}get length(){return this._data.length}copy(g,I,C,A){this._data.copy(g,I,C,A)}toBuffer(){return this._data}}class d{constructor(g){this.size=g,this.buffer=A.alloc(g),this.iRead=0,this.iWrite=0}toBuffer(){if(0===this.iRead&&this.iWrite===this.size)return this.buffer;const g=A.alloc(this.iWrite-this.iRead);return this.buffer.copy(g,0,this.iRead,this.iWrite),g}get length(){return this.iWrite-this.iRead}get eod(){return this.iRead===this.iWrite}get full(){return this.iWrite===this.size}read(g){let I;return 0===g?null:void 0===g||g>=this.length?(I=this.toBuffer(),this.iRead=this.iWrite,I):(I=A.alloc(g),this.buffer.copy(I,0,this.iRead,g),this.iRead+=g,I)}write(g,I,C){const A=Math.min(C,this.size-this.iWrite);return g.copy(this.buffer,this.iWrite,I,I+A),this.iWrite+=A,A}}const o=function(g){g=g||{},this.bufSize=g.bufSize||1048576,this.buffers=[],this.batch=g.batch||!1,this.corked=!1,this.inPos=0,this.outPos=0,this.pipes=[],this.paused=!1,this.encoding=null};e.inherits(o,i.Duplex,{toBuffer(){switch(this.buffers.length){case 0:return null;case 1:return this.buffers[0].toBuffer();default:return A.concat(this.buffers.map((g=>g.toBuffer())))}},_getWritableBuffer(){if(this.buffers.length){const g=this.buffers[this.buffers.length-1];if(!g.full)return g}const g=new d(this.bufSize);return this.buffers.push(g),g},async _pipe(g){const I=function(I){return new Promise((C=>{I.write(g.toBuffer(),(()=>{C()}))}))};await Promise.all(this.pipes.map(I))},_writeToBuffers(g){let I=0;const C=g.length;for(;I1;)this._pipe(this.buffers.shift());else this.corked?(this._writeToBuffers(d),C.nextTick(i)):(await this._pipe(d),i());else this.paused||this.emit("data",d.toBuffer()),this._writeToBuffers(d),this.emit("readable");return!0},cork(){this.corked=!0},_flush(){if(this.pipes.length)for(;this.buffers.length;)this._pipe(this.buffers.shift())},uncork(){this.corked=!1,this._flush()},end(g,I,C){const A=g=>{g?C(g):(this._flush(),this.pipes.forEach((g=>{g.end()})),this.emit("finish"))};g?this.write(g,I,A):A()},read(g){let I;if(g){for(I=[];g&&this.buffers.length&&!this.buffers[0].eod;){const C=this.buffers[0],A=C.read(g);g-=A.length,I.push(A),C.eod&&C.full&&this.buffers.shift()}return A.concat(I)}return I=this.buffers.map((g=>g.toBuffer())).filter(Boolean),this.buffers=[],A.concat(I)},setEncoding(g){this.encoding=g},pause(){this.paused=!0},resume(){this.paused=!1},isPaused(){return!!this.paused},pipe(g){this.pipes.push(g),!this.paused&&this.buffers.length&&this.end()},unpipe(g){this.pipes=this.pipes.filter((I=>I!==g))},unshift(){throw new Error("Not Implemented")},wrap(){throw new Error("Not Implemented")}}),I.exports=o}).call(this)}).call(this,g("_process"),g("buffer").Buffer)},{"./string-buf":25,"./utils":27,_process:467,buffer:220,"readable-stream":491}],25:[function(g,I,C){(function(g){(function(){class C{constructor(I){this._buf=g.alloc(I&&I.size||16384),this._encoding=I&&I.encoding||"utf8",this._inPos=0,this._buffer=void 0}get length(){return this._inPos}get capacity(){return this._buf.length}get buffer(){return this._buf}toBuffer(){return this._buffer||(this._buffer=g.alloc(this.length),this._buf.copy(this._buffer,0,0,this.length)),this._buffer}reset(g){g=g||0,this._buffer=void 0,this._inPos=g}_grow(I){let C=2*this._buf.length;for(;C=this._buf.length-4;)this._grow(this._inPos+g.length),I=this._inPos+this._buf.write(g,this._inPos,this._encoding);this._inPos=I}addStringBuf(g){g.length&&(this._buffer=void 0,this.length+g.length>this.capacity&&this._grow(this.length+g.length),g._buf.copy(this._buf,this._inPos,0,g.length),this._inPos+=g.length)}}I.exports=C}).call(this)}).call(this,g("buffer").Buffer)},{buffer:220}],26:[function(g,I,C){const{toString:A}=Object.prototype,i=/["&<>]/,e={each:function(g,I){g&&(Array.isArray(g)?g.forEach(I):Object.keys(g).forEach((C=>{I(g[C],C)})))},some:function(g,I){return!!g&&(Array.isArray(g)?g.some(I):Object.keys(g).some((C=>I(g[C],C))))},every:function(g,I){return!g||(Array.isArray(g)?g.every(I):Object.keys(g).every((C=>I(g[C],C))))},map:function(g,I){return g?Array.isArray(g)?g.map(I):Object.keys(g).map((C=>I(g[C],C))):[]},keyBy:(g,I)=>g.reduce(((g,C)=>(g[C[I]]=C,g)),{}),isEqual:function(g,I){const C=typeof g,A=typeof I,i=Array.isArray(g),l=Array.isArray(I);let t;if(C!==A)return!1;if("object"==typeof g){if(i||l)return!(!i||!l)&&g.length===I.length&&g.every(((g,C)=>{const A=I[C];return e.isEqual(g,A)}));if(null===g||null===I)return g===I;if(t=Object.keys(g),Object.keys(I).length!==t.length)return!1;for(const g of t)if(!I.hasOwnProperty(g))return!1;return e.every(g,((g,C)=>{const A=I[C];return e.isEqual(g,A)}))}return g===I},escapeHtml(g){const I=i.exec(g);if(!I)return g;let C="",A="",e=0,l=I.index;for(;l":A=">";break;default:continue}e!==l&&(C+=g.substring(e,l)),e=l+1,C+=A}return e!==l?C+g.substring(e,l):C},strcmp:(g,I)=>gI?1:0,isUndefined:g=>"[object Undefined]"===A.call(g),isObject:g=>"[object Object]"===A.call(g),deepMerge(){const g=arguments[0]||{},{length:I}=arguments;let C,A,i;function l(I,l){C=g[l],i=Array.isArray(I),e.isObject(I)||i?(i?(i=!1,A=C&&Array.isArray(C)?C:[]):A=C&&e.isObject(C)?C:{},g[l]=e.deepMerge(A,I)):e.isUndefined(I)||(g[l]=I)}for(let t=0;t{Object.defineProperty(g,I,Object.getOwnPropertyDescriptor(C,I))}));const i={constructor:{value:g,enumerable:!1,writable:!1,configurable:!0}};A&&Object.keys(A).forEach((g=>{i[g]=Object.getOwnPropertyDescriptor(A,g)})),g.prototype=Object.create(I.prototype,i)},l=/[<>&'"\x7F\x00-\x08\x0B-\x0C\x0E-\x1F]/,t={nop(){},promiseImmediate:g=>new Promise((I=>{C.setImmediate?A((()=>{I(g)})):setTimeout((()=>{I(g)}),1)})),inherits:e,dateToExcel:(g,I)=>25569+g.getTime()/864e5-(I?1462:0),excelToDate(g,I){const C=Math.round(24*(g-25569+(I?1462:0))*3600*1e3);return new Date(C)},parsePath(g){const I=g.lastIndexOf("/");return{path:g.substring(0,I),name:g.substring(I+1)}},getRelsPath(g){const I=t.parsePath(g);return`${I.path}/_rels/${I.name}.rels`},xmlEncode(g){const I=l.exec(g);if(!I)return g;let C="",A="",i=0,e=I.index;for(;e=11&&13!==I)){A="";break}continue}i!==e&&(C+=g.substring(i,e)),i=e+1,A&&(C+=A)}return i!==e?C+g.substring(i,e):C},xmlDecode:g=>g.replace(/&([a-z]*);/g,(g=>{switch(g){case"<":return"<";case">":return">";case"&":return"&";case"'":return"'";case""":return'"';default:return g}})),validInt(g){const I=parseInt(g,10);return Number.isNaN(I)?0:I},isDateFmt:g=>!!g&&null!==(g=(g=g.replace(/\[[^\]]*]/g,"")).replace(/"[^"]*"/g,"")).match(/[ymdhMsb]+/),fs:{exists:g=>new Promise((I=>{i.access(g,i.constants.F_OK,(g=>{I(!g)}))}))},toIsoDateString:g=>g.toIsoString().subsstr(0,10),parseBoolean:g=>!0===g||"true"===g||1===g||"1"===g};I.exports=t}).call(this)}).call(this,void 0!==EI?EI:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},g("timers").setImmediate)},{fs:216,timers:523}],28:[function(g,I,C){const A=g("./under-dash"),i=g("./utils"),e="<",l=">",t="";function c(g,I,C){g.push(` ${I}="${i.xmlEncode(C.toString())}"`)}function d(g,I){if(I){const C=[];A.each(I,((g,I)=>{void 0!==g&&c(C,I,g)})),g.push(C.join(""))}}class o{constructor(){this._xml=[],this._stack=[],this._rollbacks=[]}get tos(){return this._stack.length?this._stack[this._stack.length-1]:void 0}get cursor(){return this._xml.length}openXml(g){const I=this._xml;I.push("\n")}openNode(g,I){const C=this.tos,A=this._xml;C&&this.open&&A.push(l),this._stack.push(g),A.push(e),A.push(g),d(A,I),this.leaf=!0,this.open=!0}addAttribute(g,I){if(!this.open)throw new Error("Cannot write attributes to node if it is not open");void 0!==I&&c(this._xml,g,I)}addAttributes(g){if(!this.open)throw new Error("Cannot write attributes to node if it is not open");d(this._xml,g)}writeText(g){const I=this._xml;this.open&&(I.push(l),this.open=!1),this.leaf=!1,I.push(i.xmlEncode(g.toString()))}writeXml(g){this.open&&(this._xml.push(l),this.open=!1),this.leaf=!1,this._xml.push(g)}closeNode(){const g=this._stack.pop(),I=this._xml;this.leaf?I.push(s):(I.push(t),I.push(g),I.push(l)),this.open=!1,this.leaf=!1}leafNode(g,I,C){this.openNode(g,I),void 0!==C&&this.writeText(C),this.closeNode()}closeAll(){for(;this._stack.length;)this.closeNode()}addRollback(){return this._rollbacks.push({xml:this._xml.length,stack:this._stack.length,leaf:this.leaf,open:this.open}),this.cursor}commit(){this._rollbacks.pop()}rollback(){const g=this._rollbacks.pop();this._xml.length>g.xml&&this._xml.splice(g.xml,this._xml.length-g.xml),this._stack.length>g.stack&&this._stack.splice(g.stack,this._stack.length-g.stack),this.leaf=g.leaf,this.open=g.open}get xml(){return this.closeAll(),this._xml.join("")}}o.StdDocAttributes={version:"1.0",encoding:"UTF-8",standalone:"yes"},I.exports=o},{"./under-dash":26,"./utils":27}],29:[function(g,I,C){(function(C){(function(){const A=g("events"),i=g("jszip"),e=g("./stream-buf"),{stringToBuffer:l}=g("./browser-buffer-encode");class t extends A.EventEmitter{constructor(g){super(),this.options=Object.assign({type:"nodebuffer",compression:"DEFLATE"},g),this.zip=new i,this.stream=new e}append(g,I){I.hasOwnProperty("base64")&&I.base64?this.zip.file(I.name,g,{base64:!0}):(C.browser&&"string"==typeof g&&(g=l(g)),this.zip.file(I.name,g))}async finalize(){const g=await this.zip.generateAsync(this.options);this.stream.end(g),this.emit("finish")}read(g){return this.stream.read(g)}setEncoding(g){return this.stream.setEncoding(g)}pause(){return this.stream.pause()}resume(){return this.stream.resume()}isPaused(){return this.stream.isPaused()}pipe(g,I){return this.stream.pipe(g,I)}unpipe(g){return this.stream.unpipe(g)}unshift(g){return this.stream.unshift(g)}wrap(g){return this.stream.wrap(g)}}I.exports={ZipWriter:t}}).call(this)}).call(this,g("_process"))},{"./browser-buffer-encode":17,"./stream-buf":24,_process:467,events:422,jszip:441}],30:[function(g,I,C){I.exports={0:{f:"General"},1:{f:"0"},2:{f:"0.00"},3:{f:"#,##0"},4:{f:"#,##0.00"},9:{f:"0%"},10:{f:"0.00%"},11:{f:"0.00E+00"},12:{f:"# ?/?"},13:{f:"# ??/??"},14:{f:"mm-dd-yy"},15:{f:"d-mmm-yy"},16:{f:"d-mmm"},17:{f:"mmm-yy"},18:{f:"h:mm AM/PM"},19:{f:"h:mm:ss AM/PM"},20:{f:"h:mm"},21:{f:"h:mm:ss"},22:{f:'m/d/yy "h":mm'},27:{"zh-tw":"[$-404]e/m/d","zh-cn":'yyyy"年"m"月"',"ja-jp":"[$-411]ge.m.d","ko-kr":'yyyy"年" mm"月" dd"日"'},28:{"zh-tw":'[$-404]e"年"m"月"d"日"',"zh-cn":'m"月"d"日"',"ja-jp":'[$-411]ggge"年"m"月"d"日"',"ko-kr":"mm-dd"},29:{"zh-tw":'[$-404]e"年"m"月"d"日"',"zh-cn":'m"月"d"日"',"ja-jp":'[$-411]ggge"年"m"月"d"日"',"ko-kr":"mm-dd"},30:{"zh-tw":"m/d/yy ","zh-cn":"m-d-yy","ja-jp":"m/d/yy","ko-kr":"mm-dd-yy"},31:{"zh-tw":'yyyy"年"m"月"d"日"',"zh-cn":'yyyy"年"m"月"d"日"',"ja-jp":'yyyy"年"m"月"d"日"',"ko-kr":'yyyy"년" mm"월" dd"일"'},32:{"zh-tw":'hh"時"mm"分"',"zh-cn":'h"时"mm"分"',"ja-jp":'h"時"mm"分"',"ko-kr":'h"시" mm"분"'},33:{"zh-tw":'hh"時"mm"分"ss"秒"',"zh-cn":'h"时"mm"分"ss"秒"',"ja-jp":'h"時"mm"分"ss"秒"',"ko-kr":'h"시" mm"분" ss"초"'},34:{"zh-tw":'上午/下午 hh"時"mm"分"',"zh-cn":'上午/下午 h"时"mm"分"',"ja-jp":'yyyy"年"m"月"',"ko-kr":"yyyy-mm-dd"},35:{"zh-tw":'上午/下午 hh"時"mm"分"ss"秒"',"zh-cn":'上午/下午 h"时"mm"分"ss"秒"',"ja-jp":'m"月"d"日"',"ko-kr":"yyyy-mm-dd"},36:{"zh-tw":"[$-404]e/m/d","zh-cn":'yyyy"年"m"月"',"ja-jp":"[$-411]ge.m.d","ko-kr":'yyyy"年" mm"月" dd"日"'},37:{f:"#,##0 ;(#,##0)"},38:{f:"#,##0 ;[Red](#,##0)"},39:{f:"#,##0.00 ;(#,##0.00)"},40:{f:"#,##0.00 ;[Red](#,##0.00)"},45:{f:"mm:ss"},46:{f:"[h]:mm:ss"},47:{f:"mmss.0"},48:{f:"##0.0E+0"},49:{f:"@"},50:{"zh-tw":"[$-404]e/m/d","zh-cn":'yyyy"年"m"月"',"ja-jp":"[$-411]ge.m.d","ko-kr":'yyyy"年" mm"月" dd"日"'},51:{"zh-tw":'[$-404]e"年"m"月"d"日"',"zh-cn":'m"月"d"日"',"ja-jp":'[$-411]ggge"年"m"月"d"日"',"ko-kr":"mm-dd"},52:{"zh-tw":'上午/下午 hh"時"mm"分"',"zh-cn":'yyyy"年"m"月"',"ja-jp":'yyyy"年"m"月"',"ko-kr":"yyyy-mm-dd"},53:{"zh-tw":'上午/下午 hh"時"mm"分"ss"秒"',"zh-cn":'m"月"d"日"',"ja-jp":'m"月"d"日"',"ko-kr":"yyyy-mm-dd"},54:{"zh-tw":'[$-404]e"年"m"月"d"日"',"zh-cn":'m"月"d"日"',"ja-jp":'[$-411]ggge"年"m"月"d"日"',"ko-kr":"mm-dd"},55:{"zh-tw":'上午/下午 hh"時"mm"分"',"zh-cn":'上午/下午 h"时"mm"分"',"ja-jp":'yyyy"年"m"月"',"ko-kr":"yyyy-mm-dd"},56:{"zh-tw":'上午/下午 hh"時"mm"分"ss"秒"',"zh-cn":'上午/下午 h"时"mm"分"ss"秒"',"ja-jp":'m"月"d"日"',"ko-kr":"yyyy-mm-dd"},57:{"zh-tw":"[$-404]e/m/d","zh-cn":'yyyy"年"m"月"',"ja-jp":"[$-411]ge.m.d","ko-kr":'yyyy"年" mm"月" dd"日"'},58:{"zh-tw":'[$-404]e"年"m"月"d"日"',"zh-cn":'m"月"d"日"',"ja-jp":'[$-411]ggge"年"m"月"d"日"',"ko-kr":"mm-dd"},59:{"th-th":"t0"},60:{"th-th":"t0.00"},61:{"th-th":"t#,##0"},62:{"th-th":"t#,##0.00"},67:{"th-th":"t0%"},68:{"th-th":"t0.00%"},69:{"th-th":"t# ?/?"},70:{"th-th":"t# ??/??"},81:{"th-th":"d/m/bb"}}},{}],31:[function(g,I,C){I.exports={OfficeDocument:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument",Worksheet:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet",CalcChain:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/calcChain",SharedStrings:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings",Styles:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles",Theme:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme",Hyperlink:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink",Image:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",CoreProperties:"http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties",ExtenderProperties:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties",Comments:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments",VmlDrawing:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing",Table:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/table"}},{}],32:[function(g,I,C){const A=g("../../utils/parse-sax"),i=g("../../utils/xml-stream");class e{prepare(){}render(){}parseOpen(g){}parseText(g){}parseClose(g){}reconcile(g,I){}reset(){this.model=null,this.map&&Object.values(this.map).forEach((g=>{g instanceof e?g.reset():g.xform&&g.xform.reset()}))}mergeModel(g){this.model=Object.assign(this.model||{},g)}async parse(g){for await(const I of g)for(const{eventType:g,value:C}of I)if("opentag"===g)this.parseOpen(C);else if("text"===g)this.parseText(C);else if("closetag"===g&&!this.parseClose(C.name))return this.model;return this.model}async parseStream(g){return this.parse(A(g))}get xml(){return this.toXml(this.model)}toXml(g){const I=new i;return this.render(I,g),I.xml}static toAttribute(g,I){let C=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(void 0===g){if(C)return I}else if(C||g!==I)return g.toString()}static toStringAttribute(g,I){let C=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return e.toAttribute(g,I,C)}static toStringValue(g,I){return void 0===g?I:g}static toBoolAttribute(g,I){let C=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(void 0===g){if(C)return I}else if(C||g!==I)return g?"1":"0"}static toBoolValue(g,I){return void 0===g?I:"1"===g}static toIntAttribute(g,I){let C=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return e.toAttribute(g,I,C)}static toIntValue(g,I){return void 0===g?I:parseInt(g,10)}static toFloatAttribute(g,I){let C=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return e.toAttribute(g,I,C)}static toFloatValue(g,I){return void 0===g?I:parseFloat(g)}}I.exports=e},{"../../utils/parse-sax":22,"../../utils/xml-stream":28}],33:[function(g,I,C){const A=g("../base-xform"),i=g("../../../utils/col-cache");class e extends A{render(g,I){g.openNode("definedName",{name:I.name,localSheetId:I.localSheetId}),g.writeText(I.ranges.join(",")),g.closeNode()}parseOpen(g){return"definedName"===g.name&&(this._parsedName=g.attributes.name,this._parsedLocalSheetId=g.attributes.localSheetId,this._parsedText=[],!0)}parseText(g){this._parsedText.push(g)}parseClose(){return this.model={name:this._parsedName,ranges:t(this._parsedText.join(""))},void 0!==this._parsedLocalSheetId&&(this.model.localSheetId=parseInt(this._parsedLocalSheetId,10)),!1}}function l(g){try{return i.decodeEx(g),!0}catch(I){return!1}}function t(g){const I=[];let C=!1,A="";return g.split(",").forEach((g=>{if(!g)return;const i=(g.match(/'/g)||[]).length;if(!i)return void(C?A+=`${g},`:l(g)&&I.push(g));const e=i%2==0;!C&&e&&l(g)?I.push(g):C&&!e?(C=!1,l(A+g)&&I.push(A+g),A=""):(C=!0,A+=`${g},`)})),I}I.exports=e},{"../../../utils/col-cache":19,"../base-xform":32}],34:[function(g,I,C){const A=g("../../../utils/utils"),i=g("../base-xform");class e extends i{render(g,I){g.leafNode("sheet",{sheetId:I.id,name:I.name,state:I.state,"r:id":I.rId})}parseOpen(g){return"sheet"===g.name&&(this.model={name:A.xmlDecode(g.attributes.name),id:parseInt(g.attributes.sheetId,10),state:g.attributes.state,rId:g.attributes["r:id"]},!0)}parseText(){}parseClose(){return!1}}I.exports=e},{"../../../utils/utils":27,"../base-xform":32}],35:[function(g,I,C){const A=g("../base-xform");class i extends A{render(g,I){g.leafNode("calcPr",{calcId:171027,fullCalcOnLoad:I.fullCalcOnLoad?1:void 0})}parseOpen(g){return"calcPr"===g.name&&(this.model={},!0)}parseText(){}parseClose(){return!1}}I.exports=i},{"../base-xform":32}],36:[function(g,I,C){const A=g("../base-xform");class i extends A{render(g,I){g.leafNode("workbookPr",{date1904:I.date1904?1:void 0,defaultThemeVersion:164011,filterPrivacy:1})}parseOpen(g){return"workbookPr"===g.name&&(this.model={date1904:"1"===g.attributes.date1904},!0)}parseText(){}parseClose(){return!1}}I.exports=i},{"../base-xform":32}],37:[function(g,I,C){const A=g("../base-xform");class i extends A{render(g,I){const C={xWindow:I.x||0,yWindow:I.y||0,windowWidth:I.width||12e3,windowHeight:I.height||24e3,firstSheet:I.firstSheet,activeTab:I.activeTab};I.visibility&&"visible"!==I.visibility&&(C.visibility=I.visibility),g.leafNode("workbookView",C)}parseOpen(g){if("workbookView"===g.name){const I=this.model={},C=function(g,C,A){const i=void 0!==C?I[g]=C:A;void 0!==i&&(I[g]=i)},A=function(g,C,A){const i=void 0!==C?I[g]=parseInt(C,10):A;void 0!==i&&(I[g]=i)};return A("x",g.attributes.xWindow,0),A("y",g.attributes.yWindow,0),A("width",g.attributes.windowWidth,25e3),A("height",g.attributes.windowHeight,1e4),C("visibility",g.attributes.visibility,"visible"),A("activeTab",g.attributes.activeTab,void 0),A("firstSheet",g.attributes.firstSheet,void 0),!0}return!1}parseText(){}parseClose(){return!1}}I.exports=i},{"../base-xform":32}],38:[function(g,I,C){const A=g("../../../utils/under-dash"),i=g("../../../utils/col-cache"),e=g("../../../utils/xml-stream"),l=g("../base-xform"),t=g("../static-xform"),s=g("../list-xform"),c=g("./defined-name-xform"),d=g("./sheet-xform"),o=g("./workbook-view-xform"),n=g("./workbook-properties-xform"),a=g("./workbook-calc-properties-xform");class Z extends l{constructor(){super(),this.map={fileVersion:Z.STATIC_XFORMS.fileVersion,workbookPr:new n,bookViews:new s({tag:"bookViews",count:!1,childXform:new o}),sheets:new s({tag:"sheets",count:!1,childXform:new d}),definedNames:new s({tag:"definedNames",count:!1,childXform:new c}),calcPr:new a}}prepare(g){g.sheets=g.worksheets;const I=[];let C=0;g.sheets.forEach((g=>{if(g.pageSetup&&g.pageSetup.printArea&&g.pageSetup.printArea.split("&&").forEach((A=>{const i=A.split(":"),e={name:"_xlnm.Print_Area",ranges:[`'${g.name}'!$${i[0]}:$${i[1]}`],localSheetId:C};I.push(e)})),g.pageSetup&&(g.pageSetup.printTitlesRow||g.pageSetup.printTitlesColumn)){const A=[];if(g.pageSetup.printTitlesColumn){const I=g.pageSetup.printTitlesColumn.split(":");A.push(`'${g.name}'!$${I[0]}:$${I[1]}`)}if(g.pageSetup.printTitlesRow){const I=g.pageSetup.printTitlesRow.split(":");A.push(`'${g.name}'!$${I[0]}:$${I[1]}`)}const i={name:"_xlnm.Print_Titles",ranges:A,localSheetId:C};I.push(i)}C++})),I.length&&(g.definedNames=g.definedNames.concat(I)),(g.media||[]).forEach(((g,I)=>{g.name=g.type+(I+1)}))}render(g,I){g.openXml(e.StdDocAttributes),g.openNode("workbook",Z.WORKBOOK_ATTRIBUTES),this.map.fileVersion.render(g),this.map.workbookPr.render(g,I.properties),this.map.bookViews.render(g,I.views),this.map.sheets.render(g,I.sheets),this.map.definedNames.render(g,I.definedNames),this.map.calcPr.render(g,I.calcProperties),g.closeNode()}parseOpen(g){return this.parser?(this.parser.parseOpen(g),!0):("workbook"===g.name||(this.parser=this.map[g.name],this.parser&&this.parser.parseOpen(g)),!0)}parseText(g){this.parser&&this.parser.parseText(g)}parseClose(g){return this.parser?(this.parser.parseClose(g)||(this.parser=void 0),!0):"workbook"!==g||(this.model={sheets:this.map.sheets.model,properties:this.map.workbookPr.model||{},views:this.map.bookViews.model,calcProperties:{}},this.map.definedNames.model&&(this.model.definedNames=this.map.definedNames.model),!1)}reconcile(g){const I=(g.workbookRels||[]).reduce(((g,I)=>(g[I.Id]=I,g)),{}),C=[];let e,l=0;(g.sheets||[]).forEach((A=>{const i=I[A.rId];i&&(e=g.worksheetHash[`xl/${i.Target.replace(/^(\s|\/xl\/)+/,"")}`],e&&(e.name=A.name,e.id=A.id,e.state=A.state,C[l++]=e))}));const t=[];A.each(g.definedNames,(g=>{if("_xlnm.Print_Area"===g.name){if(e=C[g.localSheetId],e){e.pageSetup||(e.pageSetup={});const I=i.decodeEx(g.ranges[0]);e.pageSetup.printArea=e.pageSetup.printArea?`${e.pageSetup.printArea}&&${I.dimensions}`:I.dimensions}}else if("_xlnm.Print_Titles"===g.name){if(e=C[g.localSheetId],e){e.pageSetup||(e.pageSetup={});const I=g.ranges.join(","),C=/\$/g,A=/\$\d+:\$\d+/,i=I.match(A);if(i&&i.length){const g=i[0];e.pageSetup.printTitlesRow=g.replace(C,"")}const l=/\$[A-Z]+:\$[A-Z]+/,t=I.match(l);if(t&&t.length){const g=t[0];e.pageSetup.printTitlesColumn=g.replace(C,"")}}}else t.push(g)})),g.definedNames=t,g.media.forEach(((g,I)=>{g.index=I}))}}Z.WORKBOOK_ATTRIBUTES={xmlns:"http://schemas.openxmlformats.org/spreadsheetml/2006/main","xmlns:r":"http://schemas.openxmlformats.org/officeDocument/2006/relationships","xmlns:mc":"http://schemas.openxmlformats.org/markup-compatibility/2006","mc:Ignorable":"x15","xmlns:x15":"http://schemas.microsoft.com/office/spreadsheetml/2010/11/main"},Z.STATIC_XFORMS={fileVersion:new t({tag:"fileVersion",$:{appName:"xl",lastEdited:5,lowestEdited:5,rupBuild:9303}})},I.exports=Z},{"../../../utils/col-cache":19,"../../../utils/under-dash":26,"../../../utils/xml-stream":28,"../base-xform":32,"../list-xform":71,"../static-xform":120,"./defined-name-xform":33,"./sheet-xform":34,"./workbook-calc-properties-xform":35,"./workbook-properties-xform":36,"./workbook-view-xform":37}],39:[function(g,I,C){const A=g("../strings/rich-text-xform"),i=g("../../../utils/utils"),e=g("../base-xform"),l=I.exports=function(g){this.model=g};i.inherits(l,e,{get tag(){return"r"},get richTextXform(){return this._richTextXform||(this._richTextXform=new A),this._richTextXform},render(g,I){I=I||this.model,g.openNode("comment",{ref:I.ref,authorId:0}),g.openNode("text"),I&&I.note&&I.note.texts&&I.note.texts.forEach((I=>{this.richTextXform.render(g,I)})),g.closeNode(),g.closeNode()},parseOpen(g){if(this.parser)return this.parser.parseOpen(g),!0;switch(g.name){case"comment":return this.model={type:"note",note:{texts:[]},...g.attributes},!0;case"r":return this.parser=this.richTextXform,this.parser.parseOpen(g),!0;default:return!1}},parseText(g){this.parser&&this.parser.parseText(g)},parseClose(g){switch(g){case"comment":return!1;case"r":return this.model.note.texts.push(this.parser.model),this.parser=void 0,!0;default:return this.parser&&this.parser.parseClose(g),!0}}})},{"../../../utils/utils":27,"../base-xform":32,"../strings/rich-text-xform":122}],40:[function(g,I,C){const A=g("../../../utils/xml-stream"),i=g("../../../utils/utils"),e=g("../base-xform"),l=g("./comment-xform"),t=I.exports=function(){this.map={comment:new l}};i.inherits(t,e,{COMMENTS_ATTRIBUTES:{xmlns:"http://schemas.openxmlformats.org/spreadsheetml/2006/main"}},{render(g,I){I=I||this.model,g.openXml(A.StdDocAttributes),g.openNode("comments",t.COMMENTS_ATTRIBUTES),g.openNode("authors"),g.leafNode("author",null,"Author"),g.closeNode(),g.openNode("commentList"),I.comments.forEach((I=>{this.map.comment.render(g,I)})),g.closeNode(),g.closeNode()},parseOpen(g){if(this.parser)return this.parser.parseOpen(g),!0;switch(g.name){case"commentList":return this.model={comments:[]},!0;case"comment":return this.parser=this.map.comment,this.parser.parseOpen(g),!0;default:return!1}},parseText(g){this.parser&&this.parser.parseText(g)},parseClose(g){switch(g){case"commentList":return!1;case"comment":return this.model.comments.push(this.parser.model),this.parser=void 0,!0;default:return this.parser&&this.parser.parseClose(g),!0}}})},{"../../../utils/utils":27,"../../../utils/xml-stream":28,"../base-xform":32,"./comment-xform":39}],41:[function(g,I,C){const A=g("../../base-xform");class i extends A{constructor(g){super(),this._model=g}get tag(){return this._model&&this._model.tag}render(g,I,C){(I===C[2]||"x:SizeWithCells"===this.tag&&I===C[1])&&g.leafNode(this.tag)}parseOpen(g){return g.name===this.tag&&(this.model={},this.model[this.tag]=!0,!0)}parseText(){}parseClose(){return!1}}I.exports=i},{"../../base-xform":32}],42:[function(g,I,C){const A=g("../../base-xform");class i extends A{constructor(g){super(),this._model=g}get tag(){return this._model&&this._model.tag}render(g,I){g.leafNode(this.tag,null,I)}parseOpen(g){return g.name===this.tag&&(this.text="",!0)}parseText(g){this.text=g}parseClose(){return!1}}I.exports=i},{"../../base-xform":32}],43:[function(g,I,C){const A=g("../base-xform");class i extends A{get tag(){return"x:Anchor"}getAnchorRect(g){const I=Math.floor(g.left),C=Math.floor(68*(g.left-I)),A=Math.floor(g.top),i=Math.floor(18*(g.top-A)),e=Math.floor(g.right),l=Math.floor(68*(g.right-e)),t=Math.floor(g.bottom);return[I,C,A,i,e,l,t,Math.floor(18*(g.bottom-t))]}getDefaultRect(g){const I=g.col,C=6,A=Math.max(g.row-2,0);return[I,C,A,14,I+2,2,A+4,16]}render(g,I){const C=I.anchor?this.getAnchorRect(I.anchor):this.getDefaultRect(I.refAddress);g.leafNode("x:Anchor",null,C.join(", "))}parseOpen(g){return g.name===this.tag&&(this.text="",!0)}parseText(g){this.text=g}parseClose(){return!1}}I.exports=i},{"../base-xform":32}],44:[function(g,I,C){const A=g("../base-xform"),i=g("./vml-anchor-xform"),e=g("./style/vml-protection-xform"),l=g("./style/vml-position-xform"),t=["twoCells","oneCells","absolute"];class s extends A{constructor(){super(),this.map={"x:Anchor":new i,"x:Locked":new e({tag:"x:Locked"}),"x:LockText":new e({tag:"x:LockText"}),"x:SizeWithCells":new l({tag:"x:SizeWithCells"}),"x:MoveWithCells":new l({tag:"x:MoveWithCells"})}}get tag(){return"x:ClientData"}render(g,I){const{protection:C,editAs:A}=I.note;g.openNode(this.tag,{ObjectType:"Note"}),this.map["x:MoveWithCells"].render(g,A,t),this.map["x:SizeWithCells"].render(g,A,t),this.map["x:Anchor"].render(g,I),this.map["x:Locked"].render(g,C.locked),g.leafNode("x:AutoFill",null,"False"),this.map["x:LockText"].render(g,C.lockText),g.leafNode("x:Row",null,I.refAddress.row-1),g.leafNode("x:Column",null,I.refAddress.col-1),g.closeNode()}parseOpen(g){return g.name===this.tag?(this.reset(),this.model={anchor:[],protection:{},editAs:""}):(this.parser=this.map[g.name],this.parser&&this.parser.parseOpen(g)),!0}parseText(g){this.parser&&this.parser.parseText(g)}parseClose(g){return this.parser?(this.parser.parseClose(g)||(this.parser=void 0),!0):g!==this.tag||(this.normalizeModel(),!1)}normalizeModel(){const g=Object.assign({},this.map["x:MoveWithCells"].model,this.map["x:SizeWithCells"].model),I=Object.keys(g).length;this.model.editAs=t[I],this.model.anchor=this.map["x:Anchor"].text,this.model.protection.locked=this.map["x:Locked"].text,this.model.protection.lockText=this.map["x:LockText"].text}}I.exports=s},{"../base-xform":32,"./style/vml-position-xform":41,"./style/vml-protection-xform":42,"./vml-anchor-xform":43}],45:[function(g,I,C){const A=g("../../../utils/xml-stream"),i=g("../base-xform"),e=g("./vml-shape-xform");class l extends i{constructor(){super(),this.map={"v:shape":new e}}get tag(){return"xml"}render(g,I){g.openXml(A.StdDocAttributes),g.openNode(this.tag,l.DRAWING_ATTRIBUTES),g.openNode("o:shapelayout",{"v:ext":"edit"}),g.leafNode("o:idmap",{"v:ext":"edit",data:1}),g.closeNode(),g.openNode("v:shapetype",{id:"_x0000_t202",coordsize:"21600,21600","o:spt":202,path:"m,l,21600r21600,l21600,xe"}),g.leafNode("v:stroke",{joinstyle:"miter"}),g.leafNode("v:path",{gradientshapeok:"t","o:connecttype":"rect"}),g.closeNode(),I.comments.forEach(((I,C)=>{this.map["v:shape"].render(g,I,C)})),g.closeNode()}parseOpen(g){return this.parser?(this.parser.parseOpen(g),!0):(g.name===this.tag?(this.reset(),this.model={comments:[]}):(this.parser=this.map[g.name],this.parser&&this.parser.parseOpen(g)),!0)}parseText(g){this.parser&&this.parser.parseText(g)}parseClose(g){return this.parser?(this.parser.parseClose(g)||(this.model.comments.push(this.parser.model),this.parser=void 0),!0):g!==this.tag}reconcile(g,I){g.anchors.forEach((g=>{g.br?this.map["xdr:twoCellAnchor"].reconcile(g,I):this.map["xdr:oneCellAnchor"].reconcile(g,I)}))}}l.DRAWING_ATTRIBUTES={"xmlns:v":"urn:schemas-microsoft-com:vml","xmlns:o":"urn:schemas-microsoft-com:office:office","xmlns:x":"urn:schemas-microsoft-com:office:excel"},I.exports=l},{"../../../utils/xml-stream":28,"../base-xform":32,"./vml-shape-xform":46}],46:[function(g,I,C){const A=g("../base-xform"),i=g("./vml-textbox-xform"),e=g("./vml-client-data-xform");class l extends A{constructor(){super(),this.map={"v:textbox":new i,"x:ClientData":new e}}get tag(){return"v:shape"}render(g,I,C){g.openNode("v:shape",l.V_SHAPE_ATTRIBUTES(I,C)),g.leafNode("v:fill",{color2:"infoBackground [80]"}),g.leafNode("v:shadow",{color:"none [81]",obscured:"t"}),g.leafNode("v:path",{"o:connecttype":"none"}),this.map["v:textbox"].render(g,I),this.map["x:ClientData"].render(g,I),g.closeNode()}parseOpen(g){return this.parser?(this.parser.parseOpen(g),!0):(g.name===this.tag?(this.reset(),this.model={margins:{insetmode:g.attributes["o:insetmode"]},anchor:"",editAs:"",protection:{}}):(this.parser=this.map[g.name],this.parser&&this.parser.parseOpen(g)),!0)}parseText(g){this.parser&&this.parser.parseText(g)}parseClose(g){return this.parser?(this.parser.parseClose(g)||(this.parser=void 0),!0):g!==this.tag||(this.model.margins.inset=this.map["v:textbox"].model&&this.map["v:textbox"].model.inset,this.model.protection=this.map["x:ClientData"].model&&this.map["x:ClientData"].model.protection,this.model.anchor=this.map["x:ClientData"].model&&this.map["x:ClientData"].model.anchor,this.model.editAs=this.map["x:ClientData"].model&&this.map["x:ClientData"].model.editAs,!1)}}l.V_SHAPE_ATTRIBUTES=(g,I)=>({id:`_x0000_s${1025+I}`,type:"#_x0000_t202",style:"position:absolute; margin-left:105.3pt;margin-top:10.5pt;width:97.8pt;height:59.1pt;z-index:1;visibility:hidden",fillcolor:"infoBackground [80]",strokecolor:"none [81]","o:insetmode":g.note.margins&&g.note.margins.insetmode}),I.exports=l},{"../base-xform":32,"./vml-client-data-xform":44,"./vml-textbox-xform":47}],47:[function(g,I,C){const A=g("../base-xform");class i extends A{get tag(){return"v:textbox"}conversionUnit(g,I,C){return`${parseFloat(g)*I.toFixed(2)}${C}`}reverseConversionUnit(g){return(g||"").split(",").map((g=>Number(parseFloat(this.conversionUnit(parseFloat(g),.1,"")).toFixed(2))))}render(g,I){const C={style:"mso-direction-alt:auto"};if(I&&I.note){let{inset:g}=I.note&&I.note.margins;Array.isArray(g)&&(g=g.map((g=>this.conversionUnit(g,10,"mm"))).join(",")),g&&(C.inset=g)}g.openNode("v:textbox",C),g.leafNode("div",{style:"text-align:left"}),g.closeNode()}parseOpen(g){return g.name!==this.tag||(this.model={inset:this.reverseConversionUnit(g.attributes.inset)},!0)}parseText(){}parseClose(g){return g!==this.tag}}I.exports=i},{"../base-xform":32}],48:[function(g,I,C){const A=g("./base-xform");class i extends A{createNewModel(g){return{}}parseOpen(g){return this.parser=this.parser||this.map[g.name],this.parser?(this.parser.parseOpen(g),!0):g.name===this.tag&&(this.model=this.createNewModel(g),!0)}parseText(g){this.parser&&this.parser.parseText(g)}onParserClose(g,I){this.model[g]=I.model}parseClose(g){return this.parser?(this.parser.parseClose(g)||(this.onParserClose(g,this.parser),this.parser=void 0),!0):g!==this.tag}}I.exports=i},{"./base-xform":32}],49:[function(g,I,C){const A=g("../base-xform");class i extends A{render(g,I){g.openNode("HeadingPairs"),g.openNode("vt:vector",{size:2,baseType:"variant"}),g.openNode("vt:variant"),g.leafNode("vt:lpstr",void 0,"Worksheets"),g.closeNode(),g.openNode("vt:variant"),g.leafNode("vt:i4",void 0,I.length),g.closeNode(),g.closeNode(),g.closeNode()}parseOpen(g){return"HeadingPairs"===g.name}parseText(){}parseClose(g){return"HeadingPairs"!==g}}I.exports=i},{"../base-xform":32}],50:[function(g,I,C){const A=g("../base-xform");class i extends A{render(g,I){g.openNode("TitlesOfParts"),g.openNode("vt:vector",{size:I.length,baseType:"lpstr"}),I.forEach((I=>{g.leafNode("vt:lpstr",void 0,I.name)})),g.closeNode(),g.closeNode()}parseOpen(g){return"TitlesOfParts"===g.name}parseText(){}parseClose(g){return"TitlesOfParts"!==g}}I.exports=i},{"../base-xform":32}],51:[function(g,I,C){const A=g("../../../utils/xml-stream"),i=g("../base-xform"),e=g("../simple/string-xform"),l=g("./app-heading-pairs-xform"),t=g("./app-titles-of-parts-xform");class s extends i{constructor(){super(),this.map={Company:new e({tag:"Company"}),Manager:new e({tag:"Manager"}),HeadingPairs:new l,TitleOfParts:new t}}render(g,I){g.openXml(A.StdDocAttributes),g.openNode("Properties",s.PROPERTY_ATTRIBUTES),g.leafNode("Application",void 0,"Microsoft Excel"),g.leafNode("DocSecurity",void 0,"0"),g.leafNode("ScaleCrop",void 0,"false"),this.map.HeadingPairs.render(g,I.worksheets),this.map.TitleOfParts.render(g,I.worksheets),this.map.Company.render(g,I.company||""),this.map.Manager.render(g,I.manager),g.leafNode("LinksUpToDate",void 0,"false"),g.leafNode("SharedDoc",void 0,"false"),g.leafNode("HyperlinksChanged",void 0,"false"),g.leafNode("AppVersion",void 0,"16.0300"),g.closeNode()}parseOpen(g){return this.parser?(this.parser.parseOpen(g),!0):"Properties"===g.name||(this.parser=this.map[g.name],!!this.parser&&(this.parser.parseOpen(g),!0))}parseText(g){this.parser&&this.parser.parseText(g)}parseClose(g){return this.parser?(this.parser.parseClose(g)||(this.parser=void 0),!0):"Properties"!==g||(this.model={worksheets:this.map.TitleOfParts.model,company:this.map.Company.model,manager:this.map.Manager.model},!1)}}s.DateFormat=function(g){return g.toISOString().replace(/[.]\d{3,6}/,"")},s.DateAttrs={"xsi:type":"dcterms:W3CDTF"},s.PROPERTY_ATTRIBUTES={xmlns:"http://schemas.openxmlformats.org/officeDocument/2006/extended-properties","xmlns:vt":"http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes"},I.exports=s},{"../../../utils/xml-stream":28,"../base-xform":32,"../simple/string-xform":119,"./app-heading-pairs-xform":49,"./app-titles-of-parts-xform":50}],52:[function(g,I,C){const A=g("../../../utils/xml-stream"),i=g("../base-xform");class e extends i{render(g,I){g.openXml(A.StdDocAttributes),g.openNode("Types",e.PROPERTY_ATTRIBUTES);const C={};(I.media||[]).forEach((I=>{if("image"===I.type){const A=I.extension;C[A]||(C[A]=!0,g.leafNode("Default",{Extension:A,ContentType:`image/${A}`}))}})),g.leafNode("Default",{Extension:"rels",ContentType:"application/vnd.openxmlformats-package.relationships+xml"}),g.leafNode("Default",{Extension:"xml",ContentType:"application/xml"}),g.leafNode("Override",{PartName:"/xl/workbook.xml",ContentType:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"}),I.worksheets.forEach((I=>{const C=`/xl/worksheets/sheet${I.id}.xml`;g.leafNode("Override",{PartName:C,ContentType:"application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml"})})),g.leafNode("Override",{PartName:"/xl/theme/theme1.xml",ContentType:"application/vnd.openxmlformats-officedocument.theme+xml"}),g.leafNode("Override",{PartName:"/xl/styles.xml",ContentType:"application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml"}),I.sharedStrings&&I.sharedStrings.count&&g.leafNode("Override",{PartName:"/xl/sharedStrings.xml",ContentType:"application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml"}),I.tables&&I.tables.forEach((I=>{g.leafNode("Override",{PartName:`/xl/tables/${I.target}`,ContentType:"application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml"})})),I.drawings&&I.drawings.forEach((I=>{g.leafNode("Override",{PartName:`/xl/drawings/${I.name}.xml`,ContentType:"application/vnd.openxmlformats-officedocument.drawing+xml"})})),I.commentRefs&&(g.leafNode("Default",{Extension:"vml",ContentType:"application/vnd.openxmlformats-officedocument.vmlDrawing"}),I.commentRefs.forEach((I=>{let{commentName:C}=I;g.leafNode("Override",{PartName:`/xl/${C}.xml`,ContentType:"application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml"})}))),g.leafNode("Override",{PartName:"/docProps/core.xml",ContentType:"application/vnd.openxmlformats-package.core-properties+xml"}),g.leafNode("Override",{PartName:"/docProps/app.xml",ContentType:"application/vnd.openxmlformats-officedocument.extended-properties+xml"}),g.closeNode()}parseOpen(){return!1}parseText(){}parseClose(){return!1}}e.PROPERTY_ATTRIBUTES={xmlns:"http://schemas.openxmlformats.org/package/2006/content-types"},I.exports=e},{"../../../utils/xml-stream":28,"../base-xform":32}],53:[function(g,I,C){const A=g("../../../utils/xml-stream"),i=g("../base-xform"),e=g("../simple/date-xform"),l=g("../simple/string-xform"),t=g("../simple/integer-xform");class s extends i{constructor(){super(),this.map={"dc:creator":new l({tag:"dc:creator"}),"dc:title":new l({tag:"dc:title"}),"dc:subject":new l({tag:"dc:subject"}),"dc:description":new l({tag:"dc:description"}),"dc:identifier":new l({tag:"dc:identifier"}),"dc:language":new l({tag:"dc:language"}),"cp:keywords":new l({tag:"cp:keywords"}),"cp:category":new l({tag:"cp:category"}),"cp:lastModifiedBy":new l({tag:"cp:lastModifiedBy"}),"cp:lastPrinted":new e({tag:"cp:lastPrinted",format:s.DateFormat}),"cp:revision":new t({tag:"cp:revision"}),"cp:version":new l({tag:"cp:version"}),"cp:contentStatus":new l({tag:"cp:contentStatus"}),"cp:contentType":new l({tag:"cp:contentType"}),"dcterms:created":new e({tag:"dcterms:created",attrs:s.DateAttrs,format:s.DateFormat}),"dcterms:modified":new e({tag:"dcterms:modified",attrs:s.DateAttrs,format:s.DateFormat})}}render(g,I){g.openXml(A.StdDocAttributes),g.openNode("cp:coreProperties",s.CORE_PROPERTY_ATTRIBUTES),this.map["dc:creator"].render(g,I.creator),this.map["dc:title"].render(g,I.title),this.map["dc:subject"].render(g,I.subject),this.map["dc:description"].render(g,I.description),this.map["dc:identifier"].render(g,I.identifier),this.map["dc:language"].render(g,I.language),this.map["cp:keywords"].render(g,I.keywords),this.map["cp:category"].render(g,I.category),this.map["cp:lastModifiedBy"].render(g,I.lastModifiedBy),this.map["cp:lastPrinted"].render(g,I.lastPrinted),this.map["cp:revision"].render(g,I.revision),this.map["cp:version"].render(g,I.version),this.map["cp:contentStatus"].render(g,I.contentStatus),this.map["cp:contentType"].render(g,I.contentType),this.map["dcterms:created"].render(g,I.created),this.map["dcterms:modified"].render(g,I.modified),g.closeNode()}parseOpen(g){if(this.parser)return this.parser.parseOpen(g),!0;switch(g.name){case"cp:coreProperties":case"coreProperties":return!0;default:if(this.parser=this.map[g.name],this.parser)return this.parser.parseOpen(g),!0;throw new Error(`Unexpected xml node in parseOpen: ${JSON.stringify(g)}`)}}parseText(g){this.parser&&this.parser.parseText(g)}parseClose(g){if(this.parser)return this.parser.parseClose(g)||(this.parser=void 0),!0;switch(g){case"cp:coreProperties":case"coreProperties":return this.model={creator:this.map["dc:creator"].model,title:this.map["dc:title"].model,subject:this.map["dc:subject"].model,description:this.map["dc:description"].model,identifier:this.map["dc:identifier"].model,language:this.map["dc:language"].model,keywords:this.map["cp:keywords"].model,category:this.map["cp:category"].model,lastModifiedBy:this.map["cp:lastModifiedBy"].model,lastPrinted:this.map["cp:lastPrinted"].model,revision:this.map["cp:revision"].model,contentStatus:this.map["cp:contentStatus"].model,contentType:this.map["cp:contentType"].model,created:this.map["dcterms:created"].model,modified:this.map["dcterms:modified"].model},!1;default:throw new Error(`Unexpected xml node in parseClose: ${g}`)}}}s.DateFormat=function(g){return g.toISOString().replace(/[.]\d{3}/,"")},s.DateAttrs={"xsi:type":"dcterms:W3CDTF"},s.CORE_PROPERTY_ATTRIBUTES={"xmlns:cp":"http://schemas.openxmlformats.org/package/2006/metadata/core-properties","xmlns:dc":"http://purl.org/dc/elements/1.1/","xmlns:dcterms":"http://purl.org/dc/terms/","xmlns:dcmitype":"http://purl.org/dc/dcmitype/","xmlns:xsi":"http://www.w3.org/2001/XMLSchema-instance"},I.exports=s},{"../../../utils/xml-stream":28,"../base-xform":32,"../simple/date-xform":117,"../simple/integer-xform":118,"../simple/string-xform":119}],54:[function(g,I,C){const A=g("../base-xform");class i extends A{render(g,I){g.leafNode("Relationship",I)}parseOpen(g){return"Relationship"===g.name&&(this.model=g.attributes,!0)}parseText(){}parseClose(){return!1}}I.exports=i},{"../base-xform":32}],55:[function(g,I,C){const A=g("../../../utils/xml-stream"),i=g("../base-xform"),e=g("./relationship-xform");class l extends i{constructor(){super(),this.map={Relationship:new e}}render(g,I){I=I||this._values,g.openXml(A.StdDocAttributes),g.openNode("Relationships",l.RELATIONSHIPS_ATTRIBUTES),I.forEach((I=>{this.map.Relationship.render(g,I)})),g.closeNode()}parseOpen(g){if(this.parser)return this.parser.parseOpen(g),!0;if("Relationships"===g.name)return this.model=[],!0;if(this.parser=this.map[g.name],this.parser)return this.parser.parseOpen(g),!0;throw new Error(`Unexpected xml node in parseOpen: ${JSON.stringify(g)}`)}parseText(g){this.parser&&this.parser.parseText(g)}parseClose(g){if(this.parser)return this.parser.parseClose(g)||(this.model.push(this.parser.model),this.parser=void 0),!0;if("Relationships"===g)return!1;throw new Error(`Unexpected xml node in parseClose: ${g}`)}}l.RELATIONSHIPS_ATTRIBUTES={xmlns:"http://schemas.openxmlformats.org/package/2006/relationships"},I.exports=l},{"../../../utils/xml-stream":28,"../base-xform":32,"./relationship-xform":54}],56:[function(g,I,C){const A=g("../base-xform");class i extends A{parseOpen(g){return this.parser?(this.parser.parseOpen(g),!0):(g.name===this.tag?(this.reset(),this.model={range:{editAs:g.attributes.editAs||"oneCell"}}):(this.parser=this.map[g.name],this.parser&&this.parser.parseOpen(g)),!0)}parseText(g){this.parser&&this.parser.parseText(g)}reconcilePicture(g,I){if(g&&g.rId){const C=I.rels[g.rId].Target.match(/.*\/media\/(.+[.][a-zA-Z]{3,4})/);if(C){const g=C[1],A=I.mediaIndex[g];return I.media[A]}}}}I.exports=i},{"../base-xform":32}],57:[function(g,I,C){const A=g("../base-xform"),i=g("./blip-xform");class e extends A{constructor(){super(),this.map={"a:blip":new i}}get tag(){return"xdr:blipFill"}render(g,I){g.openNode(this.tag),this.map["a:blip"].render(g,I),g.openNode("a:stretch"),g.leafNode("a:fillRect"),g.closeNode(),g.closeNode()}parseOpen(g){return this.parser?(this.parser.parseOpen(g),!0):(g.name===this.tag?this.reset():(this.parser=this.map[g.name],this.parser&&this.parser.parseOpen(g)),!0)}parseText(){}parseClose(g){return this.parser?(this.parser.parseClose(g)||(this.parser=void 0),!0):g!==this.tag||(this.model=this.map["a:blip"].model,!1)}}I.exports=e},{"../base-xform":32,"./blip-xform":58}],58:[function(g,I,C){const A=g("../base-xform");class i extends A{get tag(){return"a:blip"}render(g,I){g.leafNode(this.tag,{"xmlns:r":"http://schemas.openxmlformats.org/officeDocument/2006/relationships","r:embed":I.rId,cstate:"print"})}parseOpen(g){return g.name!==this.tag||(this.model={rId:g.attributes["r:embed"]},!0)}parseText(){}parseClose(g){return g!==this.tag}}I.exports=i},{"../base-xform":32}],59:[function(g,I,C){const A=g("../base-xform");class i extends A{get tag(){return"xdr:cNvPicPr"}render(g){g.openNode(this.tag),g.leafNode("a:picLocks",{noChangeAspect:"1"}),g.closeNode()}parseOpen(g){return g.name,this.tag,!0}parseText(){}parseClose(g){return g!==this.tag}}I.exports=i},{"../base-xform":32}],60:[function(g,I,C){const A=g("../base-xform"),i=g("./hlink-click-xform"),e=g("./ext-lst-xform");class l extends A{constructor(){super(),this.map={"a:hlinkClick":new i,"a:extLst":new e}}get tag(){return"xdr:cNvPr"}render(g,I){g.openNode(this.tag,{id:I.index,name:`Picture ${I.index}`}),this.map["a:hlinkClick"].render(g,I),this.map["a:extLst"].render(g,I),g.closeNode()}parseOpen(g){return this.parser?(this.parser.parseOpen(g),!0):(g.name===this.tag?this.reset():(this.parser=this.map[g.name],this.parser&&this.parser.parseOpen(g)),!0)}parseText(){}parseClose(g){return this.parser?(this.parser.parseClose(g)||(this.parser=void 0),!0):g!==this.tag||(this.model=this.map["a:hlinkClick"].model,!1)}}I.exports=l},{"../base-xform":32,"./ext-lst-xform":63,"./hlink-click-xform":65}],61:[function(g,I,C){const A=g("../base-xform"),i=g("../simple/integer-xform");class e extends A{constructor(g){super(),this.tag=g.tag,this.map={"xdr:col":new i({tag:"xdr:col",zero:!0}),"xdr:colOff":new i({tag:"xdr:colOff",zero:!0}),"xdr:row":new i({tag:"xdr:row",zero:!0}),"xdr:rowOff":new i({tag:"xdr:rowOff",zero:!0})}}render(g,I){g.openNode(this.tag),this.map["xdr:col"].render(g,I.nativeCol),this.map["xdr:colOff"].render(g,I.nativeColOff),this.map["xdr:row"].render(g,I.nativeRow),this.map["xdr:rowOff"].render(g,I.nativeRowOff),g.closeNode()}parseOpen(g){return this.parser?(this.parser.parseOpen(g),!0):(g.name===this.tag?this.reset():(this.parser=this.map[g.name],this.parser&&this.parser.parseOpen(g)),!0)}parseText(g){this.parser&&this.parser.parseText(g)}parseClose(g){return this.parser?(this.parser.parseClose(g)||(this.parser=void 0),!0):g!==this.tag||(this.model={nativeCol:this.map["xdr:col"].model,nativeColOff:this.map["xdr:colOff"].model,nativeRow:this.map["xdr:row"].model,nativeRowOff:this.map["xdr:rowOff"].model},!1)}}I.exports=e},{"../base-xform":32,"../simple/integer-xform":118}],62:[function(g,I,C){const A=g("../../../utils/col-cache"),i=g("../../../utils/xml-stream"),e=g("../base-xform"),l=g("./two-cell-anchor-xform"),t=g("./one-cell-anchor-xform");function s(g){return("string"==typeof g.range?A.decode(g.range):g.range).br?"xdr:twoCellAnchor":"xdr:oneCellAnchor"}class c extends e{constructor(){super(),this.map={"xdr:twoCellAnchor":new l,"xdr:oneCellAnchor":new t}}prepare(g){g.anchors.forEach(((g,I)=>{g.anchorType=s(g),this.map[g.anchorType].prepare(g,{index:I})}))}get tag(){return"xdr:wsDr"}render(g,I){g.openXml(i.StdDocAttributes),g.openNode(this.tag,c.DRAWING_ATTRIBUTES),I.anchors.forEach((I=>{this.map[I.anchorType].render(g,I)})),g.closeNode()}parseOpen(g){return this.parser?(this.parser.parseOpen(g),!0):(g.name===this.tag?(this.reset(),this.model={anchors:[]}):(this.parser=this.map[g.name],this.parser&&this.parser.parseOpen(g)),!0)}parseText(g){this.parser&&this.parser.parseText(g)}parseClose(g){return this.parser?(this.parser.parseClose(g)||(this.model.anchors.push(this.parser.model),this.parser=void 0),!0):g!==this.tag}reconcile(g,I){g.anchors.forEach((g=>{g.br?this.map["xdr:twoCellAnchor"].reconcile(g,I):this.map["xdr:oneCellAnchor"].reconcile(g,I)}))}}c.DRAWING_ATTRIBUTES={"xmlns:xdr":"http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing","xmlns:a":"http://schemas.openxmlformats.org/drawingml/2006/main"},I.exports=c},{"../../../utils/col-cache":19,"../../../utils/xml-stream":28,"../base-xform":32,"./one-cell-anchor-xform":67,"./two-cell-anchor-xform":70}],63:[function(g,I,C){const A=g("../base-xform");class i extends A{get tag(){return"a:extLst"}render(g){g.openNode(this.tag),g.openNode("a:ext",{uri:"{FF2B5EF4-FFF2-40B4-BE49-F238E27FC236}"}),g.leafNode("a16:creationId",{"xmlns:a16":"http://schemas.microsoft.com/office/drawing/2014/main",id:"{00000000-0008-0000-0000-000002000000}"}),g.closeNode(),g.closeNode()}parseOpen(g){return g.name,this.tag,!0}parseText(){}parseClose(g){return g!==this.tag}}I.exports=i},{"../base-xform":32}],64:[function(g,I,C){const A=g("../base-xform"),i=9525;class e extends A{constructor(g){super(),this.tag=g.tag,this.map={}}render(g,I){g.openNode(this.tag);const C=Math.floor(I.width*i),A=Math.floor(I.height*i);g.addAttribute("cx",C),g.addAttribute("cy",A),g.closeNode()}parseOpen(g){return g.name===this.tag&&(this.model={width:parseInt(g.attributes.cx||"0",10)/i,height:parseInt(g.attributes.cy||"0",10)/i},!0)}parseText(){}parseClose(){return!1}}I.exports=e},{"../base-xform":32}],65:[function(g,I,C){const A=g("../base-xform");class i extends A{get tag(){return"a:hlinkClick"}render(g,I){I.hyperlinks&&I.hyperlinks.rId&&g.leafNode(this.tag,{"xmlns:r":"http://schemas.openxmlformats.org/officeDocument/2006/relationships","r:id":I.hyperlinks.rId,tooltip:I.hyperlinks.tooltip})}parseOpen(g){return g.name!==this.tag||(this.model={hyperlinks:{rId:g.attributes["r:id"],tooltip:g.attributes.tooltip}},!0)}parseText(){}parseClose(){return!1}}I.exports=i},{"../base-xform":32}],66:[function(g,I,C){const A=g("../base-xform"),i=g("./c-nv-pr-xform"),e=g("./c-nv-pic-pr-xform");class l extends A{constructor(){super(),this.map={"xdr:cNvPr":new i,"xdr:cNvPicPr":new e}}get tag(){return"xdr:nvPicPr"}render(g,I){g.openNode(this.tag),this.map["xdr:cNvPr"].render(g,I),this.map["xdr:cNvPicPr"].render(g,I),g.closeNode()}parseOpen(g){return this.parser?(this.parser.parseOpen(g),!0):(g.name===this.tag?this.reset():(this.parser=this.map[g.name],this.parser&&this.parser.parseOpen(g)),!0)}parseText(){}parseClose(g){return this.parser?(this.parser.parseClose(g)||(this.parser=void 0),!0):g!==this.tag||(this.model=this.map["xdr:cNvPr"].model,!1)}}I.exports=l},{"../base-xform":32,"./c-nv-pic-pr-xform":59,"./c-nv-pr-xform":60}],67:[function(g,I,C){const A=g("./base-cell-anchor-xform"),i=g("../static-xform"),e=g("./cell-position-xform"),l=g("./ext-xform"),t=g("./pic-xform");class s extends A{constructor(){super(),this.map={"xdr:from":new e({tag:"xdr:from"}),"xdr:ext":new l({tag:"xdr:ext"}),"xdr:pic":new t,"xdr:clientData":new i({tag:"xdr:clientData"})}}get tag(){return"xdr:oneCellAnchor"}prepare(g,I){this.map["xdr:pic"].prepare(g.picture,I)}render(g,I){g.openNode(this.tag,{editAs:I.range.editAs||"oneCell"}),this.map["xdr:from"].render(g,I.range.tl),this.map["xdr:ext"].render(g,I.range.ext),this.map["xdr:pic"].render(g,I.picture),this.map["xdr:clientData"].render(g,{}),g.closeNode()}parseClose(g){return this.parser?(this.parser.parseClose(g)||(this.parser=void 0),!0):g!==this.tag||(this.model.range.tl=this.map["xdr:from"].model,this.model.range.ext=this.map["xdr:ext"].model,this.model.picture=this.map["xdr:pic"].model,!1)}reconcile(g,I){g.medium=this.reconcilePicture(g.picture,I)}}I.exports=s},{"../static-xform":120,"./base-cell-anchor-xform":56,"./cell-position-xform":61,"./ext-xform":64,"./pic-xform":68}],68:[function(g,I,C){const A=g("../base-xform"),i=g("../static-xform"),e=g("./blip-fill-xform"),l=g("./nv-pic-pr-xform"),t=g("./sp-pr");class s extends A{constructor(){super(),this.map={"xdr:nvPicPr":new l,"xdr:blipFill":new e,"xdr:spPr":new i(t)}}get tag(){return"xdr:pic"}prepare(g,I){g.index=I.index+1}render(g,I){g.openNode(this.tag),this.map["xdr:nvPicPr"].render(g,I),this.map["xdr:blipFill"].render(g,I),this.map["xdr:spPr"].render(g,I),g.closeNode()}parseOpen(g){return this.parser?(this.parser.parseOpen(g),!0):(g.name===this.tag?this.reset():(this.parser=this.map[g.name],this.parser&&this.parser.parseOpen(g)),!0)}parseText(){}parseClose(g){return this.parser?(this.parser.parseClose(g)||(this.mergeModel(this.parser.model),this.parser=void 0),!0):g!==this.tag}}I.exports=s},{"../base-xform":32,"../static-xform":120,"./blip-fill-xform":57,"./nv-pic-pr-xform":66,"./sp-pr":69}],69:[function(g,I,C){I.exports={tag:"xdr:spPr",c:[{tag:"a:xfrm",c:[{tag:"a:off",$:{x:"0",y:"0"}},{tag:"a:ext",$:{cx:"0",cy:"0"}}]},{tag:"a:prstGeom",$:{prst:"rect"},c:[{tag:"a:avLst"}]}]}},{}],70:[function(g,I,C){const A=g("./base-cell-anchor-xform"),i=g("../static-xform"),e=g("./cell-position-xform"),l=g("./pic-xform");class t extends A{constructor(){super(),this.map={"xdr:from":new e({tag:"xdr:from"}),"xdr:to":new e({tag:"xdr:to"}),"xdr:pic":new l,"xdr:clientData":new i({tag:"xdr:clientData"})}}get tag(){return"xdr:twoCellAnchor"}prepare(g,I){this.map["xdr:pic"].prepare(g.picture,I)}render(g,I){g.openNode(this.tag,{editAs:I.range.editAs||"oneCell"}),this.map["xdr:from"].render(g,I.range.tl),this.map["xdr:to"].render(g,I.range.br),this.map["xdr:pic"].render(g,I.picture),this.map["xdr:clientData"].render(g,{}),g.closeNode()}parseClose(g){return this.parser?(this.parser.parseClose(g)||(this.parser=void 0),!0):g!==this.tag||(this.model.range.tl=this.map["xdr:from"].model,this.model.range.br=this.map["xdr:to"].model,this.model.picture=this.map["xdr:pic"].model,!1)}reconcile(g,I){g.medium=this.reconcilePicture(g.picture,I)}}I.exports=t},{"../static-xform":120,"./base-cell-anchor-xform":56,"./cell-position-xform":61,"./pic-xform":68}],71:[function(g,I,C){const A=g("./base-xform");class i extends A{constructor(g){super(),this.tag=g.tag,this.always=!!g.always,this.count=g.count,this.empty=g.empty,this.$count=g.$count||"count",this.$=g.$,this.childXform=g.childXform,this.maxItems=g.maxItems}prepare(g,I){const{childXform:C}=this;g&&g.forEach(((g,A)=>{I.index=A,C.prepare(g,I)}))}render(g,I){if(this.always||I&&I.length){g.openNode(this.tag,this.$),this.count&&g.addAttribute(this.$count,I&&I.length||0);const{childXform:C}=this;(I||[]).forEach(((I,A)=>{C.render(g,I,A)})),g.closeNode()}else this.empty&&g.leafNode(this.tag)}parseOpen(g){return this.parser?(this.parser.parseOpen(g),!0):g.name===this.tag?(this.model=[],!0):!!this.childXform.parseOpen(g)&&(this.parser=this.childXform,!0)}parseText(g){this.parser&&this.parser.parseText(g)}parseClose(g){if(this.parser){if(!this.parser.parseClose(g)&&(this.model.push(this.parser.model),this.parser=void 0,this.maxItems&&this.model.length>this.maxItems))throw new Error(`Max ${this.childXform.tag} count (${this.maxItems}) exceeded`);return!0}return!1}reconcile(g,I){if(g){const{childXform:C}=this;g.forEach((g=>{C.reconcile(g,I)}))}}}I.exports=i},{"./base-xform":32}],72:[function(g,I,C){const A=g("../../../utils/col-cache"),i=g("../base-xform");class e extends i{get tag(){return"autoFilter"}render(g,I){if(I)if("string"==typeof I)g.leafNode("autoFilter",{ref:I});else{const C=function(g){return"string"==typeof g?g:A.getAddress(g.row,g.column).address},i=C(I.from),e=C(I.to);i&&e&&g.leafNode("autoFilter",{ref:`${i}:${e}`})}}parseOpen(g){"autoFilter"===g.name&&(this.model=g.attributes.ref)}}I.exports=e},{"../../../utils/col-cache":19,"../base-xform":32}],73:[function(g,I,C){const A=g("../../../utils/utils"),i=g("../base-xform"),e=g("../../../doc/range"),l=g("../../../doc/enums"),t=g("../strings/rich-text-xform");function s(g){if(null==g)return l.ValueType.Null;if(g instanceof String||"string"==typeof g)return l.ValueType.String;if("number"==typeof g)return l.ValueType.Number;if("boolean"==typeof g)return l.ValueType.Boolean;if(g instanceof Date)return l.ValueType.Date;if(g.text&&g.hyperlink)return l.ValueType.Hyperlink;if(g.formula)return l.ValueType.Formula;if(g.error)return l.ValueType.Error;throw new Error("I could not understand type of value")}function c(g){return g.type===l.ValueType.Formula?s(g.result):g.type}class d extends i{constructor(){super(),this.richTextXForm=new t}get tag(){return"c"}prepare(g,I){const C=I.styles.addStyleModel(g.style||{},c(g));switch(C&&(g.styleId=C),g.comment&&I.comments.push({...g.comment,ref:g.address}),g.type){case l.ValueType.String:case l.ValueType.RichText:I.sharedStrings&&(g.ssId=I.sharedStrings.add(g.value));break;case l.ValueType.Date:I.date1904&&(g.date1904=!0);break;case l.ValueType.Hyperlink:I.sharedStrings&&void 0!==g.text&&null!==g.text&&(g.ssId=I.sharedStrings.add(g.text)),I.hyperlinks.push({address:g.address,target:g.hyperlink,tooltip:g.tooltip});break;case l.ValueType.Merge:I.merges.add(g);break;case l.ValueType.Formula:if(I.date1904&&(g.date1904=!0),"shared"===g.shareType&&(g.si=I.siFormulae++),g.formula)I.formulae[g.address]=g;else if(g.sharedFormula){const C=I.formulae[g.sharedFormula];if(!C)throw new Error(`Shared Formula master must exist above and or left of clone for cell ${g.address}`);void 0===C.si?(C.shareType="shared",C.si=I.siFormulae++,C.range=new e(C.address,g.address)):C.range&&C.range.expandToAddress(g.address),g.si=C.si}}}renderFormula(g,I){let C=null;switch(I.shareType){case"shared":C={t:"shared",ref:I.ref||I.range.range,si:I.si};break;case"array":C={t:"array",ref:I.ref};break;default:void 0!==I.si&&(C={t:"shared",si:I.si})}switch(s(I.result)){case l.ValueType.Null:g.leafNode("f",C,I.formula);break;case l.ValueType.String:g.addAttribute("t","str"),g.leafNode("f",C,I.formula),g.leafNode("v",null,I.result);break;case l.ValueType.Number:g.leafNode("f",C,I.formula),g.leafNode("v",null,I.result);break;case l.ValueType.Boolean:g.addAttribute("t","b"),g.leafNode("f",C,I.formula),g.leafNode("v",null,I.result?1:0);break;case l.ValueType.Error:g.addAttribute("t","e"),g.leafNode("f",C,I.formula),g.leafNode("v",null,I.result.error);break;case l.ValueType.Date:g.leafNode("f",C,I.formula),g.leafNode("v",null,A.dateToExcel(I.result,I.date1904));break;default:throw new Error("I could not understand type of value")}}render(g,I){if(I.type!==l.ValueType.Null||I.styleId){switch(g.openNode("c"),g.addAttribute("r",I.address),I.styleId&&g.addAttribute("s",I.styleId),I.type){case l.ValueType.Null:break;case l.ValueType.Number:g.leafNode("v",null,I.value);break;case l.ValueType.Boolean:g.addAttribute("t","b"),g.leafNode("v",null,I.value?"1":"0");break;case l.ValueType.Error:g.addAttribute("t","e"),g.leafNode("v",null,I.value.error);break;case l.ValueType.String:case l.ValueType.RichText:void 0!==I.ssId?(g.addAttribute("t","s"),g.leafNode("v",null,I.ssId)):I.value&&I.value.richText?(g.addAttribute("t","inlineStr"),g.openNode("is"),I.value.richText.forEach((I=>{this.richTextXForm.render(g,I)})),g.closeNode("is")):(g.addAttribute("t","str"),g.leafNode("v",null,I.value));break;case l.ValueType.Date:g.leafNode("v",null,A.dateToExcel(I.value,I.date1904));break;case l.ValueType.Hyperlink:void 0!==I.ssId?(g.addAttribute("t","s"),g.leafNode("v",null,I.ssId)):(g.addAttribute("t","str"),g.leafNode("v",null,I.text));break;case l.ValueType.Formula:this.renderFormula(g,I);case l.ValueType.Merge:}g.closeNode()}}parseOpen(g){if(this.parser)return this.parser.parseOpen(g),!0;switch(g.name){case"c":return this.model={address:g.attributes.r},this.t=g.attributes.t,g.attributes.s&&(this.model.styleId=parseInt(g.attributes.s,10)),!0;case"f":return this.currentNode="f",this.model.si=g.attributes.si,this.model.shareType=g.attributes.t,this.model.ref=g.attributes.ref,!0;case"v":return this.currentNode="v",!0;case"t":return this.currentNode="t",!0;case"r":return this.parser=this.richTextXForm,this.parser.parseOpen(g),!0;default:return!1}}parseText(g){if(this.parser)this.parser.parseText(g);else switch(this.currentNode){case"f":this.model.formula=this.model.formula?this.model.formula+g:g;break;case"v":case"t":this.model.value&&this.model.value.richText?this.model.value.richText.text=this.model.value.richText.text?this.model.value.richText.text+g:g:this.model.value=this.model.value?this.model.value+g:g}}parseClose(g){switch(g){case"c":{const{model:g}=this;if(g.formula||g.shareType)g.type=l.ValueType.Formula,g.value&&("str"===this.t?g.result=A.xmlDecode(g.value):"b"===this.t?g.result=0!==parseInt(g.value,10):"e"===this.t?g.result={error:g.value}:g.result=parseFloat(g.value),g.value=void 0);else if(void 0!==g.value)switch(this.t){case"s":g.type=l.ValueType.String,g.value=parseInt(g.value,10);break;case"str":g.type=l.ValueType.String,g.value=A.xmlDecode(g.value);break;case"inlineStr":g.type=l.ValueType.String;break;case"b":g.type=l.ValueType.Boolean,g.value=0!==parseInt(g.value,10);break;case"e":g.type=l.ValueType.Error,g.value={error:g.value};break;default:g.type=l.ValueType.Number,g.value=parseFloat(g.value)}else g.styleId?g.type=l.ValueType.Null:g.type=l.ValueType.Merge;return!1}case"f":case"v":case"is":return this.currentNode=void 0,!0;case"t":return this.parser?(this.parser.parseClose(g),!0):(this.currentNode=void 0,!0);case"r":return this.model.value=this.model.value||{},this.model.value.richText=this.model.value.richText||[],this.model.value.richText.push(this.parser.model),this.parser=void 0,this.currentNode=void 0,!0;default:return!!this.parser&&(this.parser.parseClose(g),!0)}}reconcile(g,I){const C=g.styleId&&I.styles&&I.styles.getStyleModel(g.styleId);switch(C&&(g.style=C),void 0!==g.styleId&&(g.styleId=void 0),g.type){case l.ValueType.String:"number"==typeof g.value&&I.sharedStrings&&(g.value=I.sharedStrings.getString(g.value)),g.value.richText&&(g.type=l.ValueType.RichText);break;case l.ValueType.Number:C&&A.isDateFmt(C.numFmt)&&(g.type=l.ValueType.Date,g.value=A.excelToDate(g.value,I.date1904));break;case l.ValueType.Formula:void 0!==g.result&&C&&A.isDateFmt(C.numFmt)&&(g.result=A.excelToDate(g.result,I.date1904)),"shared"===g.shareType&&(g.ref?I.formulae[g.si]=g.address:(g.sharedFormula=I.formulae[g.si],delete g.shareType),delete g.si)}const i=I.hyperlinkMap[g.address];i&&(g.type===l.ValueType.Formula?(g.text=g.result,g.result=void 0):(g.text=g.value,g.value=void 0),g.type=l.ValueType.Hyperlink,g.hyperlink=i);const e=I.commentsMap&&I.commentsMap[g.address];e&&(g.comment=e)}}I.exports=d},{"../../../doc/enums":7,"../../../doc/range":10,"../../../utils/utils":27,"../base-xform":32,"../strings/rich-text-xform":122}],74:[function(g,I,C){const A=g("../../base-xform");class i extends A{get tag(){return"x14:cfIcon"}render(g,I){g.leafNode(this.tag,{iconSet:I.iconSet,iconId:I.iconId})}parseOpen(g){let{attributes:I}=g;this.model={iconSet:I.iconSet,iconId:A.toIntValue(I.iconId)}}parseClose(g){return g!==this.tag}}I.exports=i},{"../../base-xform":32}],75:[function(g,I,C){const{v4:A}=g("uuid"),i=g("../../base-xform"),e=g("../../composite-xform"),l=g("./databar-ext-xform"),t=g("./icon-set-ext-xform"),s={"3Triangles":!0,"3Stars":!0,"5Boxes":!0};class c extends e{constructor(){super(),this.map={"x14:dataBar":this.databarXform=new l,"x14:iconSet":this.iconSetXform=new t}}get tag(){return"x14:cfRule"}static isExt(g){return"dataBar"===g.type?l.isExt(g):!("iconSet"!==g.type||!g.custom&&!s[g.iconSet])}prepare(g){c.isExt(g)&&(g.x14Id=`{${A()}}`.toUpperCase())}render(g,I){if(c.isExt(I))switch(I.type){case"dataBar":this.renderDataBar(g,I);break;case"iconSet":this.renderIconSet(g,I)}}renderDataBar(g,I){g.openNode(this.tag,{type:"dataBar",id:I.x14Id}),this.databarXform.render(g,I),g.closeNode()}renderIconSet(g,I){g.openNode(this.tag,{type:"iconSet",priority:I.priority,id:I.x14Id||`{${A()}}`}),this.iconSetXform.render(g,I),g.closeNode()}createNewModel(g){let{attributes:I}=g;return{type:I.type,x14Id:I.id,priority:i.toIntValue(I.priority)}}onParserClose(g,I){Object.assign(this.model,I.model)}}I.exports=c},{"../../base-xform":32,"../../composite-xform":48,"./databar-ext-xform":79,"./icon-set-ext-xform":81,uuid:528}],76:[function(g,I,C){const A=g("../../composite-xform"),i=g("./f-ext-xform");class e extends A{constructor(){super(),this.map={"xm:f":this.fExtXform=new i}}get tag(){return"x14:cfvo"}render(g,I){g.openNode(this.tag,{type:I.type}),void 0!==I.value&&this.fExtXform.render(g,I.value),g.closeNode()}createNewModel(g){return{type:g.attributes.type}}onParserClose(g,I){"xm:f"===g&&(this.model.value=I.model?parseFloat(I.model):0)}}I.exports=e},{"../../composite-xform":48,"./f-ext-xform":80}],77:[function(g,I,C){const A=g("../../composite-xform"),i=g("./sqref-ext-xform"),e=g("./cf-rule-ext-xform");class l extends A{constructor(){super(),this.map={"xm:sqref":this.sqRef=new i,"x14:cfRule":this.cfRule=new e}}get tag(){return"x14:conditionalFormatting"}prepare(g,I){g.rules.forEach((g=>{this.cfRule.prepare(g,I)}))}render(g,I){I.rules.some(e.isExt)&&(g.openNode(this.tag,{"xmlns:xm":"http://schemas.microsoft.com/office/excel/2006/main"}),I.rules.filter(e.isExt).forEach((I=>this.cfRule.render(g,I))),this.sqRef.render(g,I.ref),g.closeNode())}createNewModel(){return{rules:[]}}onParserClose(g,I){switch(g){case"xm:sqref":this.model.ref=I.model;break;case"x14:cfRule":this.model.rules.push(I.model)}}}I.exports=l},{"../../composite-xform":48,"./cf-rule-ext-xform":75,"./sqref-ext-xform":82}],78:[function(g,I,C){const A=g("../../composite-xform"),i=g("./cf-rule-ext-xform"),e=g("./conditional-formatting-ext-xform");class l extends A{constructor(){super(),this.map={"x14:conditionalFormatting":this.cfXform=new e}}get tag(){return"x14:conditionalFormattings"}hasContent(g){return void 0===g.hasExtContent&&(g.hasExtContent=g.some((g=>g.rules.some(i.isExt)))),g.hasExtContent}prepare(g,I){g.forEach((g=>{this.cfXform.prepare(g,I)}))}render(g,I){this.hasContent(I)&&(g.openNode(this.tag),I.forEach((I=>this.cfXform.render(g,I))),g.closeNode())}createNewModel(){return[]}onParserClose(g,I){this.model.push(I.model)}}I.exports=l},{"../../composite-xform":48,"./cf-rule-ext-xform":75,"./conditional-formatting-ext-xform":77}],79:[function(g,I,C){const A=g("../../base-xform"),i=g("../../composite-xform"),e=g("../../style/color-xform"),l=g("./cfvo-ext-xform");class t extends i{constructor(){super(),this.map={"x14:cfvo":this.cfvoXform=new l,"x14:borderColor":this.borderColorXform=new e("x14:borderColor"),"x14:negativeBorderColor":this.negativeBorderColorXform=new e("x14:negativeBorderColor"),"x14:negativeFillColor":this.negativeFillColorXform=new e("x14:negativeFillColor"),"x14:axisColor":this.axisColorXform=new e("x14:axisColor")}}static isExt(g){return!g.gradient}get tag(){return"x14:dataBar"}render(g,I){g.openNode(this.tag,{minLength:A.toIntAttribute(I.minLength,0,!0),maxLength:A.toIntAttribute(I.maxLength,100,!0),border:A.toBoolAttribute(I.border,!1),gradient:A.toBoolAttribute(I.gradient,!0),negativeBarColorSameAsPositive:A.toBoolAttribute(I.negativeBarColorSameAsPositive,!0),negativeBarBorderColorSameAsPositive:A.toBoolAttribute(I.negativeBarBorderColorSameAsPositive,!0),axisPosition:A.toAttribute(I.axisPosition,"auto"),direction:A.toAttribute(I.direction,"leftToRight")}),I.cfvo.forEach((I=>{this.cfvoXform.render(g,I)})),this.borderColorXform.render(g,I.borderColor),this.negativeBorderColorXform.render(g,I.negativeBorderColor),this.negativeFillColorXform.render(g,I.negativeFillColor),this.axisColorXform.render(g,I.axisColor),g.closeNode()}createNewModel(g){let{attributes:I}=g;return{cfvo:[],minLength:A.toIntValue(I.minLength,0),maxLength:A.toIntValue(I.maxLength,100),border:A.toBoolValue(I.border,!1),gradient:A.toBoolValue(I.gradient,!0),negativeBarColorSameAsPositive:A.toBoolValue(I.negativeBarColorSameAsPositive,!0),negativeBarBorderColorSameAsPositive:A.toBoolValue(I.negativeBarBorderColorSameAsPositive,!0),axisPosition:A.toStringValue(I.axisPosition,"auto"),direction:A.toStringValue(I.direction,"leftToRight")}}onParserClose(g,I){const[,C]=g.split(":");"cfvo"===C?this.model.cfvo.push(I.model):this.model[C]=I.model}}I.exports=t},{"../../base-xform":32,"../../composite-xform":48,"../../style/color-xform":128,"./cfvo-ext-xform":76}],80:[function(g,I,C){const A=g("../../base-xform");class i extends A{get tag(){return"xm:f"}render(g,I){g.leafNode(this.tag,null,I)}parseOpen(){this.model=""}parseText(g){this.model+=g}parseClose(g){return g!==this.tag}}I.exports=i},{"../../base-xform":32}],81:[function(g,I,C){const A=g("../../base-xform"),i=g("../../composite-xform"),e=g("./cfvo-ext-xform"),l=g("./cf-icon-ext-xform");class t extends i{constructor(){super(),this.map={"x14:cfvo":this.cfvoXform=new e,"x14:cfIcon":this.cfIconXform=new l}}get tag(){return"x14:iconSet"}render(g,I){g.openNode(this.tag,{iconSet:A.toStringAttribute(I.iconSet),reverse:A.toBoolAttribute(I.reverse,!1),showValue:A.toBoolAttribute(I.showValue,!0),custom:A.toBoolAttribute(I.icons,!1)}),I.cfvo.forEach((I=>{this.cfvoXform.render(g,I)})),I.icons&&I.icons.forEach(((I,C)=>{I.iconId=C,this.cfIconXform.render(g,I)})),g.closeNode()}createNewModel(g){let{attributes:I}=g;return{cfvo:[],iconSet:A.toStringValue(I.iconSet,"3TrafficLights"),reverse:A.toBoolValue(I.reverse,!1),showValue:A.toBoolValue(I.showValue,!0)}}onParserClose(g,I){const[,C]=g.split(":");switch(C){case"cfvo":this.model.cfvo.push(I.model);break;case"cfIcon":this.model.icons||(this.model.icons=[]),this.model.icons.push(I.model);break;default:this.model[C]=I.model}}}I.exports=t},{"../../base-xform":32,"../../composite-xform":48,"./cf-icon-ext-xform":74,"./cfvo-ext-xform":76}],82:[function(g,I,C){const A=g("../../base-xform");class i extends A{get tag(){return"xm:sqref"}render(g,I){g.leafNode(this.tag,null,I)}parseOpen(){this.model=""}parseText(g){this.model+=g}parseClose(g){return g!==this.tag}}I.exports=i},{"../../base-xform":32}],83:[function(g,I,C){const A=g("../../base-xform"),i=g("../../composite-xform"),e=g("../../../../doc/range"),l=g("./databar-xform"),t=g("./ext-lst-ref-xform"),s=g("./formula-xform"),c=g("./color-scale-xform"),d=g("./icon-set-xform"),o={"3Triangles":!0,"3Stars":!0,"5Boxes":!0},n=g=>{if(g.formulae&&g.formulae[0])return g.formulae[0];const I=new e(g.ref),{tl:C}=I;switch(g.operator){case"containsText":return`NOT(ISERROR(SEARCH("${g.text}",${C})))`;case"containsBlanks":return`LEN(TRIM(${C}))=0`;case"notContainsBlanks":return`LEN(TRIM(${C}))>0`;case"containsErrors":return`ISERROR(${C})`;case"notContainsErrors":return`NOT(ISERROR(${C}))`;default:return}},a=g=>{if(g.formulae&&g.formulae[0])return g.formulae[0];const I=new e(g.ref),{tl:C}=I;switch(g.timePeriod){case"thisWeek":return`AND(TODAY()-ROUNDDOWN(${C},0)<=WEEKDAY(TODAY())-1,ROUNDDOWN(${C},0)-TODAY()<=7-WEEKDAY(TODAY()))`;case"lastWeek":return`AND(TODAY()-ROUNDDOWN(${C},0)>=(WEEKDAY(TODAY())),TODAY()-ROUNDDOWN(${C},0)<(WEEKDAY(TODAY())+7))`;case"nextWeek":return`AND(ROUNDDOWN(${C},0)-TODAY()>(7-WEEKDAY(TODAY())),ROUNDDOWN(${C},0)-TODAY()<(15-WEEKDAY(TODAY())))`;case"yesterday":return`FLOOR(${C},1)=TODAY()-1`;case"today":return`FLOOR(${C},1)=TODAY()`;case"tomorrow":return`FLOOR(${C},1)=TODAY()+1`;case"last7Days":return`AND(TODAY()-FLOOR(${C},1)<=6,FLOOR(${C},1)<=TODAY())`;case"lastMonth":return`AND(MONTH(${C})=MONTH(EDATE(TODAY(),0-1)),YEAR(${C})=YEAR(EDATE(TODAY(),0-1)))`;case"thisMonth":return`AND(MONTH(${C})=MONTH(TODAY()),YEAR(${C})=YEAR(TODAY()))`;case"nextMonth":return`AND(MONTH(${C})=MONTH(EDATE(TODAY(),0+1)),YEAR(${C})=YEAR(EDATE(TODAY(),0+1)))`;default:return}},Z=g=>{const{type:I,operator:C}=g;switch(I){case"containsText":case"containsBlanks":case"notContainsBlanks":case"containsErrors":case"notContainsErrors":return{type:"containsText",operator:I};default:return{type:I,operator:C}}};class b extends i{constructor(){super(),this.map={dataBar:this.databarXform=new l,extLst:this.extLstRefXform=new t,formula:this.formulaXform=new s,colorScale:this.colorScaleXform=new c,iconSet:this.iconSetXform=new d}}get tag(){return"cfRule"}static isPrimitive(g){return"iconSet"!==g.type||!g.custom&&!o[g.iconSet]}render(g,I){switch(I.type){case"expression":this.renderExpression(g,I);break;case"cellIs":this.renderCellIs(g,I);break;case"top10":this.renderTop10(g,I);break;case"aboveAverage":this.renderAboveAverage(g,I);break;case"dataBar":this.renderDataBar(g,I);break;case"colorScale":this.renderColorScale(g,I);break;case"iconSet":this.renderIconSet(g,I);break;case"containsText":this.renderText(g,I);break;case"timePeriod":this.renderTimePeriod(g,I)}}renderExpression(g,I){g.openNode(this.tag,{type:"expression",dxfId:I.dxfId,priority:I.priority}),this.formulaXform.render(g,I.formulae[0]),g.closeNode()}renderCellIs(g,I){g.openNode(this.tag,{type:"cellIs",dxfId:I.dxfId,priority:I.priority,operator:I.operator}),I.formulae.forEach((I=>{this.formulaXform.render(g,I)})),g.closeNode()}renderTop10(g,I){g.leafNode(this.tag,{type:"top10",dxfId:I.dxfId,priority:I.priority,percent:A.toBoolAttribute(I.percent,!1),bottom:A.toBoolAttribute(I.bottom,!1),rank:A.toIntValue(I.rank,10,!0)})}renderAboveAverage(g,I){g.leafNode(this.tag,{type:"aboveAverage",dxfId:I.dxfId,priority:I.priority,aboveAverage:A.toBoolAttribute(I.aboveAverage,!0)})}renderDataBar(g,I){g.openNode(this.tag,{type:"dataBar",priority:I.priority}),this.databarXform.render(g,I),this.extLstRefXform.render(g,I),g.closeNode()}renderColorScale(g,I){g.openNode(this.tag,{type:"colorScale",priority:I.priority}),this.colorScaleXform.render(g,I),g.closeNode()}renderIconSet(g,I){b.isPrimitive(I)&&(g.openNode(this.tag,{type:"iconSet",priority:I.priority}),this.iconSetXform.render(g,I),g.closeNode())}renderText(g,I){g.openNode(this.tag,{type:I.operator,dxfId:I.dxfId,priority:I.priority,operator:A.toStringAttribute(I.operator,"containsText")});const C=n(I);C&&this.formulaXform.render(g,C),g.closeNode()}renderTimePeriod(g,I){g.openNode(this.tag,{type:"timePeriod",dxfId:I.dxfId,priority:I.priority,timePeriod:I.timePeriod});const C=a(I);C&&this.formulaXform.render(g,C),g.closeNode()}createNewModel(g){let{attributes:I}=g;return{...Z(I),dxfId:A.toIntValue(I.dxfId),priority:A.toIntValue(I.priority),timePeriod:I.timePeriod,percent:A.toBoolValue(I.percent),bottom:A.toBoolValue(I.bottom),rank:A.toIntValue(I.rank),aboveAverage:A.toBoolValue(I.aboveAverage)}}onParserClose(g,I){switch(g){case"dataBar":case"extLst":case"colorScale":case"iconSet":Object.assign(this.model,I.model);break;case"formula":this.model.formulae=this.model.formulae||[],this.model.formulae.push(I.model)}}}I.exports=b},{"../../../../doc/range":10,"../../base-xform":32,"../../composite-xform":48,"./color-scale-xform":85,"./databar-xform":88,"./ext-lst-ref-xform":89,"./formula-xform":90,"./icon-set-xform":91}],84:[function(g,I,C){const A=g("../../base-xform");class i extends A{get tag(){return"cfvo"}render(g,I){g.leafNode(this.tag,{type:I.type,val:I.value})}parseOpen(g){this.model={type:g.attributes.type,value:A.toFloatValue(g.attributes.val)}}parseClose(g){return g!==this.tag}}I.exports=i},{"../../base-xform":32}],85:[function(g,I,C){const A=g("../../composite-xform"),i=g("../../style/color-xform"),e=g("./cfvo-xform");class l extends A{constructor(){super(),this.map={cfvo:this.cfvoXform=new e,color:this.colorXform=new i}}get tag(){return"colorScale"}render(g,I){g.openNode(this.tag),I.cfvo.forEach((I=>{this.cfvoXform.render(g,I)})),I.color.forEach((I=>{this.colorXform.render(g,I)})),g.closeNode()}createNewModel(g){return{cfvo:[],color:[]}}onParserClose(g,I){this.model[g].push(I.model)}}I.exports=l},{"../../composite-xform":48,"../../style/color-xform":128,"./cfvo-xform":84}],86:[function(g,I,C){const A=g("../../composite-xform"),i=g("./cf-rule-xform");class e extends A{constructor(){super(),this.map={cfRule:new i}}get tag(){return"conditionalFormatting"}render(g,I){I.rules.some(i.isPrimitive)&&(g.openNode(this.tag,{sqref:I.ref}),I.rules.forEach((C=>{i.isPrimitive(C)&&(C.ref=I.ref,this.map.cfRule.render(g,C))})),g.closeNode())}createNewModel(g){let{attributes:I}=g;return{ref:I.sqref,rules:[]}}onParserClose(g,I){this.model.rules.push(I.model)}}I.exports=e},{"../../composite-xform":48,"./cf-rule-xform":83}],87:[function(g,I,C){const A=g("../../base-xform"),i=g("./conditional-formatting-xform");class e extends A{constructor(){super(),this.cfXform=new i}get tag(){return"conditionalFormatting"}reset(){this.model=[]}prepare(g,I){let C=g.reduce(((g,I)=>Math.max(g,...I.rules.map((g=>g.priority||0)))),1);g.forEach((g=>{g.rules.forEach((g=>{g.priority||(g.priority=C++),g.style&&(g.dxfId=I.styles.addDxfStyle(g.style))}))}))}render(g,I){I.forEach((I=>{this.cfXform.render(g,I)}))}parseOpen(g){return this.parser?(this.parser.parseOpen(g),!0):"conditionalFormatting"===g.name&&(this.parser=this.cfXform,this.parser.parseOpen(g),!0)}parseText(g){this.parser&&this.parser.parseText(g)}parseClose(g){return!(!this.parser||!this.parser.parseClose(g)&&(this.model.push(this.parser.model),this.parser=void 0,1))}reconcile(g,I){g.forEach((g=>{g.rules.forEach((g=>{void 0!==g.dxfId&&(g.style=I.styles.getDxfStyle(g.dxfId),delete g.dxfId)}))}))}}I.exports=e},{"../../base-xform":32,"./conditional-formatting-xform":86}],88:[function(g,I,C){const A=g("../../composite-xform"),i=g("../../style/color-xform"),e=g("./cfvo-xform");class l extends A{constructor(){super(),this.map={cfvo:this.cfvoXform=new e,color:this.colorXform=new i}}get tag(){return"dataBar"}render(g,I){g.openNode(this.tag),I.cfvo.forEach((I=>{this.cfvoXform.render(g,I)})),this.colorXform.render(g,I.color),g.closeNode()}createNewModel(){return{cfvo:[]}}onParserClose(g,I){switch(g){case"cfvo":this.model.cfvo.push(I.model);break;case"color":this.model.color=I.model}}}I.exports=l},{"../../composite-xform":48,"../../style/color-xform":128,"./cfvo-xform":84}],89:[function(g,I,C){const A=g("../../base-xform"),i=g("../../composite-xform");class e extends A{get tag(){return"x14:id"}render(g,I){g.leafNode(this.tag,null,I)}parseOpen(){this.model=""}parseText(g){this.model+=g}parseClose(g){return g!==this.tag}}class l extends i{constructor(){super(),this.map={"x14:id":this.idXform=new e}}get tag(){return"ext"}render(g,I){g.openNode(this.tag,{uri:"{B025F937-C7B1-47D3-B67F-A62EFF666E3E}","xmlns:x14":"http://schemas.microsoft.com/office/spreadsheetml/2009/9/main"}),this.idXform.render(g,I.x14Id),g.closeNode()}createNewModel(){return{}}onParserClose(g,I){this.model.x14Id=I.model}}class t extends i{constructor(){super(),this.map={ext:new l}}get tag(){return"extLst"}render(g,I){g.openNode(this.tag),this.map.ext.render(g,I),g.closeNode()}createNewModel(){return{}}onParserClose(g,I){Object.assign(this.model,I.model)}}I.exports=t},{"../../base-xform":32,"../../composite-xform":48}],90:[function(g,I,C){const A=g("../../base-xform");class i extends A{get tag(){return"formula"}render(g,I){g.leafNode(this.tag,null,I)}parseOpen(){this.model=""}parseText(g){this.model+=g}parseClose(g){return g!==this.tag}}I.exports=i},{"../../base-xform":32}],91:[function(g,I,C){const A=g("../../base-xform"),i=g("../../composite-xform"),e=g("./cfvo-xform");class l extends i{constructor(){super(),this.map={cfvo:this.cfvoXform=new e}}get tag(){return"iconSet"}render(g,I){g.openNode(this.tag,{iconSet:A.toStringAttribute(I.iconSet,"3TrafficLights"),reverse:A.toBoolAttribute(I.reverse,!1),showValue:A.toBoolAttribute(I.showValue,!0)}),I.cfvo.forEach((I=>{this.cfvoXform.render(g,I)})),g.closeNode()}createNewModel(g){let{attributes:I}=g;return{iconSet:A.toStringValue(I.iconSet,"3TrafficLights"),reverse:A.toBoolValue(I.reverse),showValue:A.toBoolValue(I.showValue),cfvo:[]}}onParserClose(g,I){this.model[g].push(I.model)}}I.exports=l},{"../../base-xform":32,"../../composite-xform":48,"./cfvo-xform":84}],92:[function(g,I,C){const A=g("../../../utils/utils"),i=g("../base-xform");class e extends i{get tag(){return"col"}prepare(g,I){const C=I.styles.addStyleModel(g.style||{});C&&(g.styleId=C)}render(g,I){g.openNode("col"),g.addAttribute("min",I.min),g.addAttribute("max",I.max),I.width&&g.addAttribute("width",I.width),I.styleId&&g.addAttribute("style",I.styleId),I.hidden&&g.addAttribute("hidden","1"),I.bestFit&&g.addAttribute("bestFit","1"),I.outlineLevel&&g.addAttribute("outlineLevel",I.outlineLevel),I.collapsed&&g.addAttribute("collapsed","1"),g.addAttribute("customWidth","1"),g.closeNode()}parseOpen(g){if("col"===g.name){const I=this.model={min:parseInt(g.attributes.min||"0",10),max:parseInt(g.attributes.max||"0",10),width:void 0===g.attributes.width?void 0:parseFloat(g.attributes.width||"0")};return g.attributes.style&&(I.styleId=parseInt(g.attributes.style,10)),A.parseBoolean(g.attributes.hidden)&&(I.hidden=!0),A.parseBoolean(g.attributes.bestFit)&&(I.bestFit=!0),g.attributes.outlineLevel&&(I.outlineLevel=parseInt(g.attributes.outlineLevel,10)),A.parseBoolean(g.attributes.collapsed)&&(I.collapsed=!0),!0}return!1}parseText(){}parseClose(){return!1}reconcile(g,I){g.styleId&&(g.style=I.styles.getStyleModel(g.styleId))}}I.exports=e},{"../../../utils/utils":27,"../base-xform":32}],93:[function(g,I,C){const A=g("../../../utils/under-dash"),i=g("../../../utils/utils"),e=g("../../../utils/col-cache"),l=g("../base-xform"),t=g("../../../doc/range");function s(g,I,C,A){const i=I[C];void 0!==i?g[C]=i:void 0!==A&&(g[C]=A)}function c(g,I,C,A){const e=I[C];void 0!==e&&(g[C]=i.parseBoolean(e))}function d(g){const I=A.map(g,((g,I)=>({address:I,dataValidation:g,marked:!1}))).sort(((g,I)=>A.strcmp(g.address,I.address))),C=A.keyBy(I,"address"),i=(I,C,i)=>{for(let l=0;l{if(!I.marked){const l=e.decodeEx(I.address);if(l.dimensions)return C[l.dimensions].marked=!0,{...I.dataValidation,sqref:I.address};let t=1,s=e.encodeAddress(l.row+t,l.col);for(;g[s]&&A.isEqual(I.dataValidation,g[s]);)t++,s=e.encodeAddress(l.row+t,l.col);let c=1;for(;i(l,t,l.col+c);)c++;for(let g=0;g1||c>1){const g=l.row+(t-1),C=l.col+(c-1);return{...I.dataValidation,sqref:`${I.address}:${e.encodeAddress(g,C)}`}}return{...I.dataValidation,sqref:I.address}}return null})).filter(Boolean)}class o extends l{get tag(){return"dataValidations"}render(g,I){const C=d(I);C.length&&(g.openNode("dataValidations",{count:C.length}),C.forEach((I=>{g.openNode("dataValidation"),"any"!==I.type&&(g.addAttribute("type",I.type),I.operator&&"list"!==I.type&&"between"!==I.operator&&g.addAttribute("operator",I.operator),I.allowBlank&&g.addAttribute("allowBlank","1")),I.showInputMessage&&g.addAttribute("showInputMessage","1"),I.promptTitle&&g.addAttribute("promptTitle",I.promptTitle),I.prompt&&g.addAttribute("prompt",I.prompt),I.showErrorMessage&&g.addAttribute("showErrorMessage","1"),I.errorStyle&&g.addAttribute("errorStyle",I.errorStyle),I.errorTitle&&g.addAttribute("errorTitle",I.errorTitle),I.error&&g.addAttribute("error",I.error),g.addAttribute("sqref",I.sqref),(I.formulae||[]).forEach(((C,A)=>{g.openNode(`formula${A+1}`),"date"===I.type?g.writeText(i.dateToExcel(new Date(C))):g.writeText(C),g.closeNode()})),g.closeNode()})),g.closeNode())}parseOpen(g){switch(g.name){case"dataValidations":return this.model={},!0;case"dataValidation":{this._address=g.attributes.sqref;const I={type:g.attributes.type||"any",formulae:[]};switch(g.attributes.type&&c(I,g.attributes,"allowBlank"),c(I,g.attributes,"showInputMessage"),c(I,g.attributes,"showErrorMessage"),I.type){case"any":case"list":case"custom":break;default:s(I,g.attributes,"operator","between")}return s(I,g.attributes,"promptTitle"),s(I,g.attributes,"prompt"),s(I,g.attributes,"errorStyle"),s(I,g.attributes,"errorTitle"),s(I,g.attributes,"error"),this._dataValidation=I,!0}case"formula1":case"formula2":return this._formula=[],!0;default:return!1}}parseText(g){this._formula&&this._formula.push(g)}parseClose(g){switch(g){case"dataValidations":return!1;case"dataValidation":return this._dataValidation.formulae&&this._dataValidation.formulae.length||(delete this._dataValidation.formulae,delete this._dataValidation.operator),(this._address.split(/\s+/g)||[]).forEach((g=>{g.includes(":")?new t(g).forEachAddress((g=>{this.model[g]=this._dataValidation})):this.model[g]=this._dataValidation})),!0;case"formula1":case"formula2":{let g=this._formula.join("");switch(this._dataValidation.type){case"whole":case"textLength":g=parseInt(g,10);break;case"decimal":g=parseFloat(g);break;case"date":g=i.excelToDate(parseFloat(g))}return this._dataValidation.formulae.push(g),this._formula=void 0,!0}default:return!0}}}I.exports=o},{"../../../doc/range":10,"../../../utils/col-cache":19,"../../../utils/under-dash":26,"../../../utils/utils":27,"../base-xform":32}],94:[function(g,I,C){const A=g("../base-xform");class i extends A{get tag(){return"dimension"}render(g,I){I&&g.leafNode("dimension",{ref:I})}parseOpen(g){return"dimension"===g.name&&(this.model=g.attributes.ref,!0)}parseText(){}parseClose(){return!1}}I.exports=i},{"../base-xform":32}],95:[function(g,I,C){const A=g("../base-xform");class i extends A{get tag(){return"drawing"}render(g,I){I&&g.leafNode(this.tag,{"r:id":I.rId})}parseOpen(g){return g.name===this.tag&&(this.model={rId:g.attributes["r:id"]},!0)}parseText(){}parseClose(){return!1}}I.exports=i},{"../base-xform":32}],96:[function(g,I,C){const A=g("../composite-xform"),i=g("./cf-ext/conditional-formattings-ext-xform");class e extends A{constructor(){super(),this.map={"x14:conditionalFormattings":this.conditionalFormattings=new i}}get tag(){return"ext"}hasContent(g){return this.conditionalFormattings.hasContent(g.conditionalFormattings)}prepare(g,I){this.conditionalFormattings.prepare(g.conditionalFormattings,I)}render(g,I){g.openNode("ext",{uri:"{78C0D931-6437-407d-A8EE-F0AAD7539E65}","xmlns:x14":"http://schemas.microsoft.com/office/spreadsheetml/2009/9/main"}),this.conditionalFormattings.render(g,I.conditionalFormattings),g.closeNode()}createNewModel(){return{}}onParserClose(g,I){this.model[g]=I.model}}class l extends A{constructor(){super(),this.map={ext:this.ext=new e}}get tag(){return"extLst"}prepare(g,I){this.ext.prepare(g,I)}hasContent(g){return this.ext.hasContent(g)}render(g,I){this.hasContent(I)&&(g.openNode("extLst"),this.ext.render(g,I),g.closeNode())}createNewModel(){return{}}onParserClose(g,I){Object.assign(this.model,I.model)}}I.exports=l},{"../composite-xform":48,"./cf-ext/conditional-formattings-ext-xform":78}],97:[function(g,I,C){const A=g("../base-xform");class i extends A{get tag(){return"headerFooter"}render(g,I){if(I){g.addRollback();let C=!1;g.openNode("headerFooter"),I.differentFirst&&(g.addAttribute("differentFirst","1"),C=!0),I.differentOddEven&&(g.addAttribute("differentOddEven","1"),C=!0),I.oddHeader&&"string"==typeof I.oddHeader&&(g.leafNode("oddHeader",null,I.oddHeader),C=!0),I.oddFooter&&"string"==typeof I.oddFooter&&(g.leafNode("oddFooter",null,I.oddFooter),C=!0),I.evenHeader&&"string"==typeof I.evenHeader&&(g.leafNode("evenHeader",null,I.evenHeader),C=!0),I.evenFooter&&"string"==typeof I.evenFooter&&(g.leafNode("evenFooter",null,I.evenFooter),C=!0),I.firstHeader&&"string"==typeof I.firstHeader&&(g.leafNode("firstHeader",null,I.firstHeader),C=!0),I.firstFooter&&"string"==typeof I.firstFooter&&(g.leafNode("firstFooter",null,I.firstFooter),C=!0),C?(g.closeNode(),g.commit()):g.rollback()}}parseOpen(g){switch(g.name){case"headerFooter":return this.model={},g.attributes.differentFirst&&(this.model.differentFirst=1===parseInt(g.attributes.differentFirst,0)),g.attributes.differentOddEven&&(this.model.differentOddEven=1===parseInt(g.attributes.differentOddEven,0)),!0;case"oddHeader":return this.currentNode="oddHeader",!0;case"oddFooter":return this.currentNode="oddFooter",!0;case"evenHeader":return this.currentNode="evenHeader",!0;case"evenFooter":return this.currentNode="evenFooter",!0;case"firstHeader":return this.currentNode="firstHeader",!0;case"firstFooter":return this.currentNode="firstFooter",!0;default:return!1}}parseText(g){switch(this.currentNode){case"oddHeader":this.model.oddHeader=g;break;case"oddFooter":this.model.oddFooter=g;break;case"evenHeader":this.model.evenHeader=g;break;case"evenFooter":this.model.evenFooter=g;break;case"firstHeader":this.model.firstHeader=g;break;case"firstFooter":this.model.firstFooter=g}}parseClose(){switch(this.currentNode){case"oddHeader":case"oddFooter":case"evenHeader":case"evenFooter":case"firstHeader":case"firstFooter":return this.currentNode=void 0,!0;default:return!1}}}I.exports=i},{"../base-xform":32}],98:[function(g,I,C){const A=g("../base-xform");class i extends A{get tag(){return"hyperlink"}render(g,I){this.isInternalLink(I)?g.leafNode("hyperlink",{ref:I.address,"r:id":I.rId,tooltip:I.tooltip,location:I.target}):g.leafNode("hyperlink",{ref:I.address,"r:id":I.rId,tooltip:I.tooltip})}parseOpen(g){return"hyperlink"===g.name&&(this.model={address:g.attributes.ref,rId:g.attributes["r:id"],tooltip:g.attributes.tooltip},g.attributes.location&&(this.model.target=g.attributes.location),!0)}parseText(){}parseClose(){return!1}isInternalLink(g){return g.target&&/^[^!]+![a-zA-Z]+[\d]+$/.test(g.target)}}I.exports=i},{"../base-xform":32}],99:[function(g,I,C){const A=g("../base-xform");class i extends A{get tag(){return"mergeCell"}render(g,I){g.leafNode("mergeCell",{ref:I})}parseOpen(g){return"mergeCell"===g.name&&(this.model=g.attributes.ref,!0)}parseText(){}parseClose(){return!1}}I.exports=i},{"../base-xform":32}],100:[function(g,I,C){const A=g("../../../utils/under-dash"),i=g("../../../doc/range"),e=g("../../../utils/col-cache"),l=g("../../../doc/enums");class t{constructor(){this.merges={}}add(g){if(this.merges[g.master])this.merges[g.master].expandToAddress(g.address);else{const I=`${g.master}:${g.address}`;this.merges[g.master]=new i(I)}}get mergeCells(){return A.map(this.merges,(g=>g.range))}reconcile(g,I){A.each(g,(g=>{const C=e.decode(g);for(let A=C.top;A<=C.bottom;A++){const g=I[A-1];for(let I=C.left;I<=C.right;I++){const i=g.cells[I-1];i?i.type===l.ValueType.Merge&&(i.master=C.tl):g.cells[I]={type:l.ValueType.Null,address:e.encodeAddress(A,I)}}}}))}getMasterAddress(g){const I=this.hash[g];return I&&I.tl}}I.exports=t},{"../../../doc/enums":7,"../../../doc/range":10,"../../../utils/col-cache":19,"../../../utils/under-dash":26}],101:[function(g,I,C){const A=g("../base-xform"),i=g=>void 0!==g;class e extends A{get tag(){return"outlinePr"}render(g,I){return!(!I||!i(I.summaryBelow)&&!i(I.summaryRight)||(g.leafNode(this.tag,{summaryBelow:i(I.summaryBelow)?Number(I.summaryBelow):void 0,summaryRight:i(I.summaryRight)?Number(I.summaryRight):void 0}),0))}parseOpen(g){return g.name===this.tag&&(this.model={summaryBelow:i(g.attributes.summaryBelow)?Boolean(Number(g.attributes.summaryBelow)):void 0,summaryRight:i(g.attributes.summaryRight)?Boolean(Number(g.attributes.summaryRight)):void 0},!0)}parseText(){}parseClose(){return!1}}I.exports=e},{"../base-xform":32}],102:[function(g,I,C){const A=g("../base-xform");class i extends A{get tag(){return"brk"}render(g,I){g.leafNode("brk",I)}parseOpen(g){return"brk"===g.name&&(this.model=g.attributes.ref,!0)}parseText(){}parseClose(){return!1}}I.exports=i},{"../base-xform":32}],103:[function(g,I,C){const A=g("../../../utils/under-dash"),i=g("../base-xform");class e extends i{get tag(){return"pageMargins"}render(g,I){if(I){const C={left:I.left,right:I.right,top:I.top,bottom:I.bottom,header:I.header,footer:I.footer};A.some(C,(g=>void 0!==g))&&g.leafNode(this.tag,C)}}parseOpen(g){return g.name===this.tag&&(this.model={left:parseFloat(g.attributes.left||.7),right:parseFloat(g.attributes.right||.7),top:parseFloat(g.attributes.top||.75),bottom:parseFloat(g.attributes.bottom||.75),header:parseFloat(g.attributes.header||.3),footer:parseFloat(g.attributes.footer||.3)},!0)}parseText(){}parseClose(){return!1}}I.exports=e},{"../../../utils/under-dash":26,"../base-xform":32}],104:[function(g,I,C){const A=g("../base-xform");class i extends A{get tag(){return"pageSetUpPr"}render(g,I){return!(!I||!I.fitToPage||(g.leafNode(this.tag,{fitToPage:I.fitToPage?"1":void 0}),0))}parseOpen(g){return g.name===this.tag&&(this.model={fitToPage:"1"===g.attributes.fitToPage},!0)}parseText(){}parseClose(){return!1}}I.exports=i},{"../base-xform":32}],105:[function(g,I,C){const A=g("../../../utils/under-dash"),i=g("../base-xform");function e(g){return g?"1":void 0}function l(g){if("overThenDown"===g)return g}function t(g){switch(g){case"atEnd":case"asDisplyed":return g;default:return}}function s(g){switch(g){case"dash":case"blank":case"NA":return g;default:return}}function c(g){return void 0!==g?parseInt(g,10):void 0}class d extends i{get tag(){return"pageSetup"}render(g,I){if(I){const C={paperSize:I.paperSize,orientation:I.orientation,horizontalDpi:I.horizontalDpi,verticalDpi:I.verticalDpi,pageOrder:l(I.pageOrder),blackAndWhite:e(I.blackAndWhite),draft:e(I.draft),cellComments:t(I.cellComments),errors:s(I.errors),scale:I.scale,fitToWidth:I.fitToWidth,fitToHeight:I.fitToHeight,firstPageNumber:I.firstPageNumber,useFirstPageNumber:e(I.firstPageNumber),usePrinterDefaults:e(I.usePrinterDefaults),copies:I.copies};A.some(C,(g=>void 0!==g))&&g.leafNode(this.tag,C)}}parseOpen(g){return g.name===this.tag&&(this.model={paperSize:c(g.attributes.paperSize),orientation:g.attributes.orientation||"portrait",horizontalDpi:parseInt(g.attributes.horizontalDpi||"4294967295",10),verticalDpi:parseInt(g.attributes.verticalDpi||"4294967295",10),pageOrder:g.attributes.pageOrder||"downThenOver",blackAndWhite:"1"===g.attributes.blackAndWhite,draft:"1"===g.attributes.draft,cellComments:g.attributes.cellComments||"None",errors:g.attributes.errors||"displayed",scale:parseInt(g.attributes.scale||"100",10),fitToWidth:parseInt(g.attributes.fitToWidth||"1",10),fitToHeight:parseInt(g.attributes.fitToHeight||"1",10),firstPageNumber:parseInt(g.attributes.firstPageNumber||"1",10),useFirstPageNumber:"1"===g.attributes.useFirstPageNumber,usePrinterDefaults:"1"===g.attributes.usePrinterDefaults,copies:parseInt(g.attributes.copies||"1",10)},!0)}parseText(){}parseClose(){return!1}}I.exports=d},{"../../../utils/under-dash":26,"../base-xform":32}],106:[function(g,I,C){const A=g("../base-xform");class i extends A{get tag(){return"picture"}render(g,I){I&&g.leafNode(this.tag,{"r:id":I.rId})}parseOpen(g){return g.name===this.tag&&(this.model={rId:g.attributes["r:id"]},!0)}parseText(){}parseClose(){return!1}}I.exports=i},{"../base-xform":32}],107:[function(g,I,C){const A=g("../../../utils/under-dash"),i=g("../base-xform");function e(g){return g?"1":void 0}class l extends i{get tag(){return"printOptions"}render(g,I){if(I){const C={headings:e(I.showRowColHeaders),gridLines:e(I.showGridLines),horizontalCentered:e(I.horizontalCentered),verticalCentered:e(I.verticalCentered)};A.some(C,(g=>void 0!==g))&&g.leafNode(this.tag,C)}}parseOpen(g){return g.name===this.tag&&(this.model={showRowColHeaders:"1"===g.attributes.headings,showGridLines:"1"===g.attributes.gridLines,horizontalCentered:"1"===g.attributes.horizontalCentered,verticalCentered:"1"===g.attributes.verticalCentered},!0)}parseText(){}parseClose(){return!1}}I.exports=l},{"../../../utils/under-dash":26,"../base-xform":32}],108:[function(g,I,C){const A=g("./page-breaks-xform"),i=g("../list-xform");class e extends i{constructor(){super({tag:"rowBreaks",count:!0,childXform:new A})}render(g,I){if(I&&I.length){g.openNode(this.tag,this.$),this.count&&(g.addAttribute(this.$count,I.length),g.addAttribute("manualBreakCount",I.length));const{childXform:C}=this;I.forEach((I=>{C.render(g,I)})),g.closeNode()}else this.empty&&g.leafNode(this.tag)}}I.exports=e},{"../list-xform":71,"./page-breaks-xform":102}],109:[function(g,I,C){const A=g("../base-xform"),i=g("../../../utils/utils"),e=g("./cell-xform");class l extends A{constructor(g){super(),this.maxItems=g&&g.maxItems,this.map={c:new e}}get tag(){return"row"}prepare(g,I){const C=I.styles.addStyleModel(g.style);C&&(g.styleId=C);const A=this.map.c;g.cells.forEach((g=>{A.prepare(g,I)}))}render(g,I,C){g.openNode("row"),g.addAttribute("r",I.number),I.height&&(g.addAttribute("ht",I.height),g.addAttribute("customHeight","1")),I.hidden&&g.addAttribute("hidden","1"),I.min>0&&I.max>0&&I.min<=I.max&&g.addAttribute("spans",`${I.min}:${I.max}`),I.styleId&&(g.addAttribute("s",I.styleId),g.addAttribute("customFormat","1")),g.addAttribute("x14ac:dyDescent","0.25"),I.outlineLevel&&g.addAttribute("outlineLevel",I.outlineLevel),I.collapsed&&g.addAttribute("collapsed","1");const A=this.map.c;I.cells.forEach((I=>{A.render(g,I,C)})),g.closeNode()}parseOpen(g){if(this.parser)return this.parser.parseOpen(g),!0;if("row"===g.name){this.numRowsSeen+=1;const I=g.attributes.spans?g.attributes.spans.split(":").map((g=>parseInt(g,10))):[void 0,void 0],C=this.model={number:parseInt(g.attributes.r,10),min:I[0],max:I[1],cells:[]};return g.attributes.s&&(C.styleId=parseInt(g.attributes.s,10)),i.parseBoolean(g.attributes.hidden)&&(C.hidden=!0),i.parseBoolean(g.attributes.bestFit)&&(C.bestFit=!0),g.attributes.ht&&(C.height=parseFloat(g.attributes.ht)),g.attributes.outlineLevel&&(C.outlineLevel=parseInt(g.attributes.outlineLevel,10)),i.parseBoolean(g.attributes.collapsed)&&(C.collapsed=!0),!0}return this.parser=this.map[g.name],!!this.parser&&(this.parser.parseOpen(g),!0)}parseText(g){this.parser&&this.parser.parseText(g)}parseClose(g){if(this.parser){if(!this.parser.parseClose(g)){if(this.model.cells.push(this.parser.model),this.maxItems&&this.model.cells.length>this.maxItems)throw new Error(`Max column count (${this.maxItems}) exceeded`);this.parser=void 0}return!0}return!1}reconcile(g,I){g.style=g.styleId?I.styles.getStyleModel(g.styleId):{},void 0!==g.styleId&&(g.styleId=void 0);const C=this.map.c;g.cells.forEach((g=>{C.reconcile(g,I)}))}}I.exports=l},{"../../../utils/utils":27,"../base-xform":32,"./cell-xform":73}],110:[function(g,I,C){const A=g("../../../utils/under-dash"),i=g("../base-xform");class e extends i{get tag(){return"sheetFormatPr"}render(g,I){if(I){const C={defaultRowHeight:I.defaultRowHeight,outlineLevelRow:I.outlineLevelRow,outlineLevelCol:I.outlineLevelCol,"x14ac:dyDescent":I.dyDescent};I.defaultColWidth&&(C.defaultColWidth=I.defaultColWidth),I.defaultRowHeight&&15===I.defaultRowHeight||(C.customHeight="1"),A.some(C,(g=>void 0!==g))&&g.leafNode("sheetFormatPr",C)}}parseOpen(g){return"sheetFormatPr"===g.name&&(this.model={defaultRowHeight:parseFloat(g.attributes.defaultRowHeight||"0"),dyDescent:parseFloat(g.attributes["x14ac:dyDescent"]||"0"),outlineLevelRow:parseInt(g.attributes.outlineLevelRow||"0",10),outlineLevelCol:parseInt(g.attributes.outlineLevelCol||"0",10)},g.attributes.defaultColWidth&&(this.model.defaultColWidth=parseFloat(g.attributes.defaultColWidth)),!0)}parseText(){}parseClose(){return!1}}I.exports=e},{"../../../utils/under-dash":26,"../base-xform":32}],111:[function(g,I,C){const A=g("../base-xform"),i=g("../style/color-xform"),e=g("./page-setup-properties-xform"),l=g("./outline-properties-xform");class t extends A{constructor(){super(),this.map={tabColor:new i("tabColor"),pageSetUpPr:new e,outlinePr:new l}}get tag(){return"sheetPr"}render(g,I){if(I){g.addRollback(),g.openNode("sheetPr");let C=!1;C=this.map.tabColor.render(g,I.tabColor)||C,C=this.map.pageSetUpPr.render(g,I.pageSetup)||C,C=this.map.outlinePr.render(g,I.outlineProperties)||C,C?(g.closeNode(),g.commit()):g.rollback()}}parseOpen(g){return this.parser?(this.parser.parseOpen(g),!0):g.name===this.tag?(this.reset(),!0):!!this.map[g.name]&&(this.parser=this.map[g.name],this.parser.parseOpen(g),!0)}parseText(g){return!!this.parser&&(this.parser.parseText(g),!0)}parseClose(g){return this.parser?(this.parser.parseClose(g)||(this.parser=void 0),!0):(this.map.tabColor.model||this.map.pageSetUpPr.model||this.map.outlinePr.model?(this.model={},this.map.tabColor.model&&(this.model.tabColor=this.map.tabColor.model),this.map.pageSetUpPr.model&&(this.model.pageSetup=this.map.pageSetUpPr.model),this.map.outlinePr.model&&(this.model.outlineProperties=this.map.outlinePr.model)):this.model=null,!1)}}I.exports=t},{"../base-xform":32,"../style/color-xform":128,"./outline-properties-xform":101,"./page-setup-properties-xform":104}],112:[function(g,I,C){const A=g("../../../utils/under-dash"),i=g("../base-xform");function e(g,I){return g?I:void 0}function l(g,I){return g===I||void 0}class t extends i{get tag(){return"sheetProtection"}render(g,I){if(I){const C={sheet:e(I.sheet,"1"),selectLockedCells:!1===I.selectLockedCells?"1":void 0,selectUnlockedCells:!1===I.selectUnlockedCells?"1":void 0,formatCells:e(I.formatCells,"0"),formatColumns:e(I.formatColumns,"0"),formatRows:e(I.formatRows,"0"),insertColumns:e(I.insertColumns,"0"),insertRows:e(I.insertRows,"0"),insertHyperlinks:e(I.insertHyperlinks,"0"),deleteColumns:e(I.deleteColumns,"0"),deleteRows:e(I.deleteRows,"0"),sort:e(I.sort,"0"),autoFilter:e(I.autoFilter,"0"),pivotTables:e(I.pivotTables,"0")};I.sheet&&(C.algorithmName=I.algorithmName,C.hashValue=I.hashValue,C.saltValue=I.saltValue,C.spinCount=I.spinCount,C.objects=e(!1===I.objects,"1"),C.scenarios=e(!1===I.scenarios,"1")),A.some(C,(g=>void 0!==g))&&g.leafNode(this.tag,C)}}parseOpen(g){return g.name===this.tag&&(this.model={sheet:l(g.attributes.sheet,"1"),objects:"1"!==g.attributes.objects&&void 0,scenarios:"1"!==g.attributes.scenarios&&void 0,selectLockedCells:"1"!==g.attributes.selectLockedCells&&void 0,selectUnlockedCells:"1"!==g.attributes.selectUnlockedCells&&void 0,formatCells:l(g.attributes.formatCells,"0"),formatColumns:l(g.attributes.formatColumns,"0"),formatRows:l(g.attributes.formatRows,"0"),insertColumns:l(g.attributes.insertColumns,"0"),insertRows:l(g.attributes.insertRows,"0"),insertHyperlinks:l(g.attributes.insertHyperlinks,"0"),deleteColumns:l(g.attributes.deleteColumns,"0"),deleteRows:l(g.attributes.deleteRows,"0"),sort:l(g.attributes.sort,"0"),autoFilter:l(g.attributes.autoFilter,"0"),pivotTables:l(g.attributes.pivotTables,"0")},g.attributes.algorithmName&&(this.model.algorithmName=g.attributes.algorithmName,this.model.hashValue=g.attributes.hashValue,this.model.saltValue=g.attributes.saltValue,this.model.spinCount=parseInt(g.attributes.spinCount,10)),!0)}parseText(){}parseClose(){return!1}}I.exports=t},{"../../../utils/under-dash":26,"../base-xform":32}],113:[function(g,I,C){const A=g("../../../utils/col-cache"),i=g("../base-xform"),e={frozen:"frozen",frozenSplit:"frozen",split:"split"};class l extends i{get tag(){return"sheetView"}prepare(g){switch(g.state){case"frozen":case"split":break;default:g.state="normal"}}render(g,I){g.openNode("sheetView",{workbookViewId:I.workbookViewId||0});const C=function(I,C,A){A&&g.addAttribute(I,C)};let i,e,l,t;switch(C("rightToLeft","1",!0===I.rightToLeft),C("tabSelected","1",I.tabSelected),C("showRuler","0",!1===I.showRuler),C("showRowColHeaders","0",!1===I.showRowColHeaders),C("showGridLines","0",!1===I.showGridLines),C("zoomScale",I.zoomScale,I.zoomScale),C("zoomScaleNormal",I.zoomScaleNormal,I.zoomScaleNormal),C("view",I.style,I.style),I.state){case"frozen":e=I.xSplit||0,l=I.ySplit||0,i=I.topLeftCell||A.getAddress(l+1,e+1).address,t=(I.xSplit&&I.ySplit?"bottomRight":I.xSplit&&"topRight")||"bottomLeft",g.leafNode("pane",{xSplit:I.xSplit||void 0,ySplit:I.ySplit||void 0,topLeftCell:i,activePane:t,state:"frozen"}),g.leafNode("selection",{pane:t,activeCell:I.activeCell,sqref:I.activeCell});break;case"split":"topLeft"===I.activePane&&(I.activePane=void 0),g.leafNode("pane",{xSplit:I.xSplit||void 0,ySplit:I.ySplit||void 0,topLeftCell:I.topLeftCell,activePane:I.activePane}),g.leafNode("selection",{pane:I.activePane,activeCell:I.activeCell,sqref:I.activeCell});break;case"normal":I.activeCell&&g.leafNode("selection",{activeCell:I.activeCell,sqref:I.activeCell})}g.closeNode()}parseOpen(g){switch(g.name){case"sheetView":return this.sheetView={workbookViewId:parseInt(g.attributes.workbookViewId,10),rightToLeft:"1"===g.attributes.rightToLeft,tabSelected:"1"===g.attributes.tabSelected,showRuler:!("0"===g.attributes.showRuler),showRowColHeaders:!("0"===g.attributes.showRowColHeaders),showGridLines:!("0"===g.attributes.showGridLines),zoomScale:parseInt(g.attributes.zoomScale||"100",10),zoomScaleNormal:parseInt(g.attributes.zoomScaleNormal||"100",10),style:g.attributes.view},this.pane=void 0,this.selections={},!0;case"pane":return this.pane={xSplit:parseInt(g.attributes.xSplit||"0",10),ySplit:parseInt(g.attributes.ySplit||"0",10),topLeftCell:g.attributes.topLeftCell,activePane:g.attributes.activePane||"topLeft",state:g.attributes.state},!0;case"selection":{const I=g.attributes.pane||"topLeft";return this.selections[I]={pane:I,activeCell:g.attributes.activeCell},!0}default:return!1}}parseText(){}parseClose(g){let I,C;return"sheetView"!==g||(this.sheetView&&this.pane?(I=this.model={workbookViewId:this.sheetView.workbookViewId,rightToLeft:this.sheetView.rightToLeft,state:e[this.pane.state]||"split",xSplit:this.pane.xSplit,ySplit:this.pane.ySplit,topLeftCell:this.pane.topLeftCell,showRuler:this.sheetView.showRuler,showRowColHeaders:this.sheetView.showRowColHeaders,showGridLines:this.sheetView.showGridLines,zoomScale:this.sheetView.zoomScale,zoomScaleNormal:this.sheetView.zoomScaleNormal},"split"===this.model.state&&(I.activePane=this.pane.activePane),C=this.selections[this.pane.activePane],C&&C.activeCell&&(I.activeCell=C.activeCell),this.sheetView.style&&(I.style=this.sheetView.style)):(I=this.model={workbookViewId:this.sheetView.workbookViewId,rightToLeft:this.sheetView.rightToLeft,state:"normal",showRuler:this.sheetView.showRuler,showRowColHeaders:this.sheetView.showRowColHeaders,showGridLines:this.sheetView.showGridLines,zoomScale:this.sheetView.zoomScale,zoomScaleNormal:this.sheetView.zoomScaleNormal},C=this.selections.topLeft,C&&C.activeCell&&(I.activeCell=C.activeCell),this.sheetView.style&&(I.style=this.sheetView.style)),!1)}reconcile(){}}I.exports=l},{"../../../utils/col-cache":19,"../base-xform":32}],114:[function(g,I,C){const A=g("../base-xform");class i extends A{get tag(){return"tablePart"}render(g,I){I&&g.leafNode(this.tag,{"r:id":I.rId})}parseOpen(g){return g.name===this.tag&&(this.model={rId:g.attributes["r:id"]},!0)}parseText(){}parseClose(){return!1}}I.exports=i},{"../base-xform":32}],115:[function(g,I,C){const A=g("../../../utils/under-dash"),i=g("../../../utils/col-cache"),e=g("../../../utils/xml-stream"),l=g("../../rel-type"),t=g("./merges"),s=g("../base-xform"),c=g("../list-xform"),d=g("./row-xform"),o=g("./col-xform"),n=g("./dimension-xform"),a=g("./hyperlink-xform"),Z=g("./merge-cell-xform"),b=g("./data-validations-xform"),r=g("./sheet-properties-xform"),m=g("./sheet-format-properties-xform"),h=g("./sheet-view-xform"),G=g("./sheet-protection-xform"),u=g("./page-margins-xform"),B=g("./page-setup-xform"),w=g("./print-options-xform"),W=g("./auto-filter-xform"),p=g("./picture-xform"),V=g("./drawing-xform"),y=g("./table-part-xform"),X=g("./row-breaks-xform"),Y=g("./header-footer-xform"),R=g("./cf/conditional-formattings-xform"),N=g("./ext-lst-xform"),H=(g,I)=>{Object.keys(I).forEach((C=>{const A=g[C],i=I[C];void 0===A&&void 0!==i&&(g[C]=i)}))},K=(g,I)=>{if(!I||!I.length)return g;if(!g||!g.length)return I;const C={},A={};return g.forEach((g=>{C[g.ref]=g,g.rules.forEach((g=>{const{x14Id:I}=g;I&&(A[I]=g)}))})),I.forEach((I=>{I.rules.forEach((i=>{const e=A[i.x14Id];e?H(e,i):C[I.ref]?C[I.ref].rules.push(i):g.push({ref:I.ref,rules:[i]})}))})),g};class F extends s{constructor(g){super();const{maxRows:I,maxCols:C,ignoreNodes:A}=g||{};this.ignoreNodes=A||[],this.map={sheetPr:new r,dimension:new n,sheetViews:new c({tag:"sheetViews",count:!1,childXform:new h}),sheetFormatPr:new m,cols:new c({tag:"cols",count:!1,childXform:new o}),sheetData:new c({tag:"sheetData",count:!1,empty:!0,childXform:new d({maxItems:C}),maxItems:I}),autoFilter:new W,mergeCells:new c({tag:"mergeCells",count:!0,childXform:new Z}),rowBreaks:new X,hyperlinks:new c({tag:"hyperlinks",count:!1,childXform:new a}),pageMargins:new u,dataValidations:new b,pageSetup:new B,headerFooter:new Y,printOptions:new w,picture:new p,drawing:new V,sheetProtection:new G,tableParts:new c({tag:"tableParts",count:!0,childXform:new y}),conditionalFormatting:new R,extLst:new N}}prepare(g,I){I.merges=new t,g.hyperlinks=I.hyperlinks=[],g.comments=I.comments=[],I.formulae={},I.siFormulae=0,this.map.cols.prepare(g.cols,I),this.map.sheetData.prepare(g.rows,I),this.map.conditionalFormatting.prepare(g.conditionalFormattings,I),g.mergeCells=I.merges.mergeCells;const C=g.rels=[];function A(g){return`rId${g.length+1}`}if(g.hyperlinks.forEach((g=>{const I=A(C);g.rId=I,C.push({Id:I,Type:l.Hyperlink,Target:g.target,TargetMode:"External"})})),g.comments.length>0){const e={Id:A(C),Type:l.Comments,Target:`../comments${g.id}.xml`};C.push(e);const t={Id:A(C),Type:l.VmlDrawing,Target:`../drawings/vmlDrawing${g.id}.vml`};C.push(t),g.comments.forEach((g=>{g.refAddress=i.decodeAddress(g.ref)})),I.commentRefs.push({commentName:`comments${g.id}`,vmlDrawing:`vmlDrawing${g.id}`})}const e=[];let s;g.media.forEach((i=>{if("background"===i.type){const e=A(C);s=I.media[i.imageId],C.push({Id:e,Type:l.Image,Target:`../media/${s.name}.${s.extension}`}),g.background={rId:e},g.image=I.media[i.imageId]}else if("image"===i.type){let{drawing:t}=g;s=I.media[i.imageId],t||(t=g.drawing={rId:A(C),name:"drawing"+ ++I.drawingsCount,anchors:[],rels:[]},I.drawings.push(t),C.push({Id:t.rId,Type:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing",Target:`../drawings/${t.name}.xml`}));let c=this.preImageId===i.imageId?e[i.imageId]:e[t.rels.length];c||(c=A(t.rels),e[t.rels.length]=c,t.rels.push({Id:c,Type:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",Target:`../media/${s.name}.${s.extension}`}));const d={picture:{rId:c},range:i.range};if(i.hyperlinks&&i.hyperlinks.hyperlink){const g=A(t.rels);e[t.rels.length]=g,d.picture.hyperlinks={tooltip:i.hyperlinks.tooltip,rId:g},t.rels.push({Id:g,Type:l.Hyperlink,Target:i.hyperlinks.hyperlink,TargetMode:"External"})}this.preImageId=i.imageId,t.anchors.push(d)}})),g.tables.forEach((g=>{const i=A(C);g.rId=i,C.push({Id:i,Type:l.Table,Target:`../tables/${g.target}`}),g.columns.forEach((g=>{const{style:C}=g;C&&(g.dxfId=I.styles.addDxfStyle(C))}))})),this.map.extLst.prepare(g,I)}render(g,I){g.openXml(e.StdDocAttributes),g.openNode("worksheet",F.WORKSHEET_ATTRIBUTES);const C=I.properties?{defaultRowHeight:I.properties.defaultRowHeight,dyDescent:I.properties.dyDescent,outlineLevelCol:I.properties.outlineLevelCol,outlineLevelRow:I.properties.outlineLevelRow}:void 0;I.properties&&I.properties.defaultColWidth&&(C.defaultColWidth=I.properties.defaultColWidth);const A={outlineProperties:I.properties&&I.properties.outlineProperties,tabColor:I.properties&&I.properties.tabColor,pageSetup:I.pageSetup&&I.pageSetup.fitToPage?{fitToPage:I.pageSetup.fitToPage}:void 0},i=I.pageSetup&&I.pageSetup.margins,t={showRowColHeaders:I.pageSetup&&I.pageSetup.showRowColHeaders,showGridLines:I.pageSetup&&I.pageSetup.showGridLines,horizontalCentered:I.pageSetup&&I.pageSetup.horizontalCentered,verticalCentered:I.pageSetup&&I.pageSetup.verticalCentered},s=I.sheetProtection;this.map.sheetPr.render(g,A),this.map.dimension.render(g,I.dimensions),this.map.sheetViews.render(g,I.views),this.map.sheetFormatPr.render(g,C),this.map.cols.render(g,I.cols),this.map.sheetData.render(g,I.rows),this.map.sheetProtection.render(g,s),this.map.autoFilter.render(g,I.autoFilter),this.map.mergeCells.render(g,I.mergeCells),this.map.conditionalFormatting.render(g,I.conditionalFormattings),this.map.dataValidations.render(g,I.dataValidations),this.map.hyperlinks.render(g,I.hyperlinks),this.map.printOptions.render(g,t),this.map.pageMargins.render(g,i),this.map.pageSetup.render(g,I.pageSetup),this.map.headerFooter.render(g,I.headerFooter),this.map.rowBreaks.render(g,I.rowBreaks),this.map.drawing.render(g,I.drawing),this.map.picture.render(g,I.background),this.map.tableParts.render(g,I.tables),this.map.extLst.render(g,I),I.rels&&I.rels.forEach((I=>{I.Type===l.VmlDrawing&&g.leafNode("legacyDrawing",{"r:id":I.Id})})),g.closeNode()}parseOpen(g){return this.parser?(this.parser.parseOpen(g),!0):"worksheet"===g.name?(A.each(this.map,(g=>{g.reset()})),!0):(this.map[g.name]&&!this.ignoreNodes.includes(g.name)&&(this.parser=this.map[g.name],this.parser.parseOpen(g)),!0)}parseText(g){this.parser&&this.parser.parseText(g)}parseClose(g){if(this.parser)return this.parser.parseClose(g)||(this.parser=void 0),!0;if("worksheet"===g){const g=this.map.sheetFormatPr.model||{};this.map.sheetPr.model&&this.map.sheetPr.model.tabColor&&(g.tabColor=this.map.sheetPr.model.tabColor),this.map.sheetPr.model&&this.map.sheetPr.model.outlineProperties&&(g.outlineProperties=this.map.sheetPr.model.outlineProperties);const I={fitToPage:this.map.sheetPr.model&&this.map.sheetPr.model.pageSetup&&this.map.sheetPr.model.pageSetup.fitToPage||!1,margins:this.map.pageMargins.model},C=Object.assign(I,this.map.pageSetup.model,this.map.printOptions.model),A=K(this.map.conditionalFormatting.model,this.map.extLst.model&&this.map.extLst.model["x14:conditionalFormattings"]);return this.model={dimensions:this.map.dimension.model,cols:this.map.cols.model,rows:this.map.sheetData.model,mergeCells:this.map.mergeCells.model,hyperlinks:this.map.hyperlinks.model,dataValidations:this.map.dataValidations.model,properties:g,views:this.map.sheetViews.model,pageSetup:C,headerFooter:this.map.headerFooter.model,background:this.map.picture.model,drawing:this.map.drawing.model,tables:this.map.tableParts.model,conditionalFormattings:A},this.map.autoFilter.model&&(this.model.autoFilter=this.map.autoFilter.model),this.map.sheetProtection.model&&(this.model.sheetProtection=this.map.sheetProtection.model),!1}return!0}reconcile(g,I){const C=(g.relationships||[]).reduce(((C,A)=>{if(C[A.Id]=A,A.Type===l.Comments&&(g.comments=I.comments[A.Target].comments),A.Type===l.VmlDrawing&&g.comments&&g.comments.length){const C=I.vmlDrawings[A.Target].comments;g.comments.forEach(((g,I)=>{g.note=Object.assign({},g.note,C[I])}))}return C}),{});if(I.commentsMap=(g.comments||[]).reduce(((g,I)=>(I.ref&&(g[I.ref]=I),g)),{}),I.hyperlinkMap=(g.hyperlinks||[]).reduce(((g,I)=>(I.rId&&(g[I.address]=C[I.rId].Target),g)),{}),I.formulae={},g.rows=g.rows&&g.rows.filter(Boolean)||[],g.rows.forEach((g=>{g.cells=g.cells&&g.cells.filter(Boolean)||[]})),this.map.cols.reconcile(g.cols,I),this.map.sheetData.reconcile(g.rows,I),this.map.conditionalFormatting.reconcile(g.conditionalFormattings,I),g.media=[],g.drawing){const A=C[g.drawing.rId].Target.match(/\/drawings\/([a-zA-Z0-9]+)[.][a-zA-Z]{3,4}$/);if(A){const C=A[1];I.drawings[C].anchors.forEach((I=>{if(I.medium){const C={type:"image",imageId:I.medium.index,range:I.range,hyperlinks:I.picture.hyperlinks};g.media.push(C)}}))}}const A=g.background&&C[g.background.rId];if(A){const C=A.Target.split("/media/")[1],i=I.mediaIndex&&I.mediaIndex[C];void 0!==i&&g.media.push({type:"background",imageId:i})}g.tables=(g.tables||[]).map((g=>{const A=C[g.rId];return I.tables[A.Target]})),delete g.relationships,delete g.hyperlinks,delete g.comments}}F.WORKSHEET_ATTRIBUTES={xmlns:"http://schemas.openxmlformats.org/spreadsheetml/2006/main","xmlns:r":"http://schemas.openxmlformats.org/officeDocument/2006/relationships","xmlns:mc":"http://schemas.openxmlformats.org/markup-compatibility/2006","mc:Ignorable":"x14ac","xmlns:x14ac":"http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac"},I.exports=F},{"../../../utils/col-cache":19,"../../../utils/under-dash":26,"../../../utils/xml-stream":28,"../../rel-type":31,"../base-xform":32,"../list-xform":71,"./auto-filter-xform":72,"./cf/conditional-formattings-xform":87,"./col-xform":92,"./data-validations-xform":93,"./dimension-xform":94,"./drawing-xform":95,"./ext-lst-xform":96,"./header-footer-xform":97,"./hyperlink-xform":98,"./merge-cell-xform":99,"./merges":100,"./page-margins-xform":103,"./page-setup-xform":105,"./picture-xform":106,"./print-options-xform":107,"./row-breaks-xform":108,"./row-xform":109,"./sheet-format-properties-xform":110,"./sheet-properties-xform":111,"./sheet-protection-xform":112,"./sheet-view-xform":113,"./table-part-xform":114}],116:[function(g,I,C){const A=g("../base-xform");class i extends A{constructor(g){super(),this.tag=g.tag,this.attr=g.attr}render(g,I){I&&(g.openNode(this.tag),g.closeNode())}parseOpen(g){g.name===this.tag&&(this.model=!0)}parseText(){}parseClose(){return!1}}I.exports=i},{"../base-xform":32}],117:[function(g,I,C){const A=g("../base-xform");class i extends A{constructor(g){super(),this.tag=g.tag,this.attr=g.attr,this.attrs=g.attrs,this._format=g.format||function(g){try{return Number.isNaN(g.getTime())?"":g.toISOString()}catch(I){return""}},this._parse=g.parse||function(g){return new Date(g)}}render(g,I){I&&(g.openNode(this.tag),this.attrs&&g.addAttributes(this.attrs),this.attr?g.addAttribute(this.attr,this._format(I)):g.writeText(this._format(I)),g.closeNode())}parseOpen(g){g.name===this.tag&&(this.attr?this.model=this._parse(g.attributes[this.attr]):this.text=[])}parseText(g){this.attr||this.text.push(g)}parseClose(){return this.attr||(this.model=this._parse(this.text.join(""))),!1}}I.exports=i},{"../base-xform":32}],118:[function(g,I,C){const A=g("../base-xform");class i extends A{constructor(g){super(),this.tag=g.tag,this.attr=g.attr,this.attrs=g.attrs,this.zero=g.zero}render(g,I){(I||this.zero)&&(g.openNode(this.tag),this.attrs&&g.addAttributes(this.attrs),this.attr?g.addAttribute(this.attr,I):g.writeText(I),g.closeNode())}parseOpen(g){return g.name===this.tag&&(this.attr?this.model=parseInt(g.attributes[this.attr],10):this.text=[],!0)}parseText(g){this.attr||this.text.push(g)}parseClose(){return this.attr||(this.model=parseInt(this.text.join("")||0,10)),!1}}I.exports=i},{"../base-xform":32}],119:[function(g,I,C){const A=g("../base-xform");class i extends A{constructor(g){super(),this.tag=g.tag,this.attr=g.attr,this.attrs=g.attrs}render(g,I){void 0!==I&&(g.openNode(this.tag),this.attrs&&g.addAttributes(this.attrs),this.attr?g.addAttribute(this.attr,I):g.writeText(I),g.closeNode())}parseOpen(g){g.name===this.tag&&(this.attr?this.model=g.attributes[this.attr]:this.text=[])}parseText(g){this.attr||this.text.push(g)}parseClose(){return this.attr||(this.model=this.text.join("")),!1}}I.exports=i},{"../base-xform":32}],120:[function(g,I,C){const A=g("./base-xform"),i=g("../../utils/xml-stream");function e(g,I){g.openNode(I.tag,I.$),I.c&&I.c.forEach((I=>{e(g,I)})),I.t&&g.writeText(I.t),g.closeNode()}class l extends A{constructor(g){super(),this._model=g}render(g){if(!this._xml){const g=new i;e(g,this._model),this._xml=g.xml}g.writeXml(this._xml)}parseOpen(){return!0}parseText(){}parseClose(g){return g!==this._model.tag}}I.exports=l},{"../../utils/xml-stream":28,"./base-xform":32}],121:[function(g,I,C){const A=g("./text-xform"),i=g("./rich-text-xform"),e=g("../base-xform");class l extends e{constructor(){super(),this.map={r:new i,t:new A}}get tag(){return"rPh"}render(g,I){if(g.openNode(this.tag,{sb:I.sb||0,eb:I.eb||0}),I&&I.hasOwnProperty("richText")&&I.richText){const{r:C}=this.map;I.richText.forEach((I=>{C.render(g,I)}))}else I&&this.map.t.render(g,I.text);g.closeNode()}parseOpen(g){const{name:I}=g;return this.parser?(this.parser.parseOpen(g),!0):I===this.tag?(this.model={sb:parseInt(g.attributes.sb,10),eb:parseInt(g.attributes.eb,10)},!0):(this.parser=this.map[I],!!this.parser&&(this.parser.parseOpen(g),!0))}parseText(g){this.parser&&this.parser.parseText(g)}parseClose(g){if(this.parser){if(!this.parser.parseClose(g)){switch(g){case"r":{let g=this.model.richText;g||(g=this.model.richText=[]),g.push(this.parser.model);break}case"t":this.model.text=this.parser.model}this.parser=void 0}return!0}return g!==this.tag}}I.exports=l},{"../base-xform":32,"./rich-text-xform":122,"./text-xform":125}],122:[function(g,I,C){const A=g("./text-xform"),i=g("../style/font-xform"),e=g("../base-xform");class l extends e{constructor(g){super(),this.model=g}get tag(){return"r"}get textXform(){return this._textXform||(this._textXform=new A)}get fontXform(){return this._fontXform||(this._fontXform=new i(l.FONT_OPTIONS))}render(g,I){I=I||this.model,g.openNode("r"),I.font&&this.fontXform.render(g,I.font),this.textXform.render(g,I.text),g.closeNode()}parseOpen(g){if(this.parser)return this.parser.parseOpen(g),!0;switch(g.name){case"r":return this.model={},!0;case"t":return this.parser=this.textXform,this.parser.parseOpen(g),!0;case"rPr":return this.parser=this.fontXform,this.parser.parseOpen(g),!0;default:return!1}}parseText(g){this.parser&&this.parser.parseText(g)}parseClose(g){switch(g){case"r":return!1;case"t":return this.model.text=this.parser.model,this.parser=void 0,!0;case"rPr":return this.model.font=this.parser.model,this.parser=void 0,!0;default:return this.parser&&this.parser.parseClose(g),!0}}}l.FONT_OPTIONS={tagName:"rPr",fontNameTag:"rFont"},I.exports=l},{"../base-xform":32,"../style/font-xform":131,"./text-xform":125}],123:[function(g,I,C){const A=g("./text-xform"),i=g("./rich-text-xform"),e=g("./phonetic-text-xform"),l=g("../base-xform");class t extends l{constructor(g){super(),this.model=g,this.map={r:new i,t:new A,rPh:new e}}get tag(){return"si"}render(g,I){g.openNode(this.tag),I&&I.hasOwnProperty("richText")&&I.richText?I.richText.length?I.richText.forEach((I=>{this.map.r.render(g,I)})):this.map.t.render(g,""):null!=I&&this.map.t.render(g,I),g.closeNode()}parseOpen(g){const{name:I}=g;return this.parser?(this.parser.parseOpen(g),!0):I===this.tag?(this.model={},!0):(this.parser=this.map[I],!!this.parser&&(this.parser.parseOpen(g),!0))}parseText(g){this.parser&&this.parser.parseText(g)}parseClose(g){if(this.parser){if(!this.parser.parseClose(g)){switch(g){case"r":{let g=this.model.richText;g||(g=this.model.richText=[]),g.push(this.parser.model);break}case"t":this.model=this.parser.model}this.parser=void 0}return!0}return g!==this.tag}}I.exports=t},{"../base-xform":32,"./phonetic-text-xform":121,"./rich-text-xform":122,"./text-xform":125}],124:[function(g,I,C){const A=g("../../../utils/xml-stream"),i=g("../base-xform"),e=g("./shared-string-xform");class l extends i{constructor(g){super(),this.model=g||{values:[],count:0},this.hash=Object.create(null),this.rich=Object.create(null)}get sharedStringXform(){return this._sharedStringXform||(this._sharedStringXform=new e)}get values(){return this.model.values}get uniqueCount(){return this.model.values.length}get count(){return this.model.count}getString(g){return this.model.values[g]}add(g){return g.richText?this.addRichText(g):this.addText(g)}addText(g){let I=this.hash[g];return void 0===I&&(I=this.hash[g]=this.model.values.length,this.model.values.push(g)),this.model.count++,I}addRichText(g){const I=this.sharedStringXform.toXml(g);let C=this.rich[I];return void 0===C&&(C=this.rich[I]=this.model.values.length,this.model.values.push(g)),this.model.count++,C}render(g,I){I=I||this._values,g.openXml(A.StdDocAttributes),g.openNode("sst",{xmlns:"http://schemas.openxmlformats.org/spreadsheetml/2006/main",count:I.count,uniqueCount:I.values.length});const C=this.sharedStringXform;I.values.forEach((I=>{C.render(g,I)})),g.closeNode()}parseOpen(g){if(this.parser)return this.parser.parseOpen(g),!0;switch(g.name){case"sst":return!0;case"si":return this.parser=this.sharedStringXform,this.parser.parseOpen(g),!0;default:throw new Error(`Unexpected xml node in parseOpen: ${JSON.stringify(g)}`)}}parseText(g){this.parser&&this.parser.parseText(g)}parseClose(g){if(this.parser)return this.parser.parseClose(g)||(this.model.values.push(this.parser.model),this.model.count++,this.parser=void 0),!0;if("sst"===g)return!1;throw new Error(`Unexpected xml node in parseClose: ${g}`)}}I.exports=l},{"../../../utils/xml-stream":28,"../base-xform":32,"./shared-string-xform":123}],125:[function(g,I,C){const A=g("../base-xform");class i extends A{get tag(){return"t"}render(g,I){g.openNode("t"),/^\s|\n|\s$/.test(I)&&g.addAttribute("xml:space","preserve"),g.writeText(I),g.closeNode()}get model(){return this._text.join("").replace(/_x([0-9A-F]{4})_/g,((g,I)=>String.fromCharCode(parseInt(I,16))))}parseOpen(g){return"t"===g.name&&(this._text=[],!0)}parseText(g){this._text.push(g)}parseClose(){return!1}}I.exports=i},{"../base-xform":32}],126:[function(g,I,C){const A=g("../../../doc/enums"),i=g("../../../utils/utils"),e=g("../base-xform"),l={horizontalValues:["left","center","right","fill","centerContinuous","distributed","justify"].reduce(((g,I)=>(g[I]=!0,g)),{}),horizontal(g){return this.horizontalValues[g]?g:void 0},verticalValues:["top","middle","bottom","distributed","justify"].reduce(((g,I)=>(g[I]=!0,g)),{}),vertical(g){return"middle"===g?"center":this.verticalValues[g]?g:void 0},wrapText:g=>!!g||void 0,shrinkToFit:g=>!!g||void 0,textRotation:g=>"vertical"===g||(g=i.validInt(g))>=-90&&g<=90?g:void 0,indent:g=>(g=i.validInt(g),Math.max(0,g)),readingOrder(g){switch(g){case"ltr":return A.ReadingOrder.LeftToRight;case"rtl":return A.ReadingOrder.RightToLeft;default:return}}},t={toXml(g){if(g=l.textRotation(g)){if("vertical"===g)return 255;const I=Math.round(g);if(I>=0&&I<=90)return I;if(I<0&&I>=-90)return 90-I}},toModel(g){const I=i.validInt(g);if(void 0!==I){if(255===I)return"vertical";if(I>=0&&I<=90)return I;if(I>90&&I<=180)return 90-I}}};class s extends e{get tag(){return"alignment"}render(g,I){g.addRollback(),g.openNode("alignment");let C=!1;function A(I,A){A&&(g.addAttribute(I,A),C=!0)}A("horizontal",l.horizontal(I.horizontal)),A("vertical",l.vertical(I.vertical)),A("wrapText",!!l.wrapText(I.wrapText)&&"1"),A("shrinkToFit",!!l.shrinkToFit(I.shrinkToFit)&&"1"),A("indent",l.indent(I.indent)),A("textRotation",t.toXml(I.textRotation)),A("readingOrder",l.readingOrder(I.readingOrder)),g.closeNode(),C?g.commit():g.rollback()}parseOpen(g){const I={};let C=!1;function A(g,A,i){g&&(I[A]=i,C=!0)}A(g.attributes.horizontal,"horizontal",g.attributes.horizontal),A(g.attributes.vertical,"vertical","center"===g.attributes.vertical?"middle":g.attributes.vertical),A(g.attributes.wrapText,"wrapText",i.parseBoolean(g.attributes.wrapText)),A(g.attributes.shrinkToFit,"shrinkToFit",i.parseBoolean(g.attributes.shrinkToFit)),A(g.attributes.indent,"indent",parseInt(g.attributes.indent,10)),A(g.attributes.textRotation,"textRotation",t.toModel(g.attributes.textRotation)),A(g.attributes.readingOrder,"readingOrder","2"===g.attributes.readingOrder?"rtl":"ltr"),this.model=C?I:null}parseText(){}parseClose(){return!1}}I.exports=s},{"../../../doc/enums":7,"../../../utils/utils":27,"../base-xform":32}],127:[function(g,I,C){const A=g("../base-xform"),i=g("../../../utils/utils"),e=g("./color-xform");class l extends A{constructor(g){super(),this.name=g,this.map={color:new e}}get tag(){return this.name}render(g,I,C){const A=I&&I.color||C||this.defaultColor;g.openNode(this.name),I&&I.style&&(g.addAttribute("style",I.style),A&&this.map.color.render(g,A)),g.closeNode()}parseOpen(g){if(this.parser)return this.parser.parseOpen(g),!0;switch(g.name){case this.name:{const{style:I}=g.attributes;return this.model=I?{style:I}:void 0,!0}case"color":return this.parser=this.map.color,this.parser.parseOpen(g),!0;default:return!1}}parseText(g){this.parser&&this.parser.parseText(g)}parseClose(g){return this.parser?(this.parser.parseClose(g)||(this.parser=void 0),!0):(g===this.name&&this.map.color.model&&(this.model||(this.model={}),this.model.color=this.map.color.model),!1)}validStyle(g){return l.validStyleValues[g]}}l.validStyleValues=["thin","dashed","dotted","dashDot","hair","dashDotDot","slantDashDot","mediumDashed","mediumDashDotDot","mediumDashDot","medium","double","thick"].reduce(((g,I)=>(g[I]=!0,g)),{});class t extends A{constructor(){super(),this.map={top:new l("top"),left:new l("left"),bottom:new l("bottom"),right:new l("right"),diagonal:new l("diagonal")}}render(g,I){const{color:C}=I;function A(A,i){A&&!A.color&&I.color&&(A={...A,color:I.color}),i.render(g,A,C)}g.openNode("border"),I.diagonal&&I.diagonal.style&&(I.diagonal.up&&g.addAttribute("diagonalUp","1"),I.diagonal.down&&g.addAttribute("diagonalDown","1")),A(I.left,this.map.left),A(I.right,this.map.right),A(I.top,this.map.top),A(I.bottom,this.map.bottom),A(I.diagonal,this.map.diagonal),g.closeNode()}parseOpen(g){return this.parser?(this.parser.parseOpen(g),!0):"border"===g.name?(this.reset(),this.diagonalUp=i.parseBoolean(g.attributes.diagonalUp),this.diagonalDown=i.parseBoolean(g.attributes.diagonalDown),!0):(this.parser=this.map[g.name],!!this.parser&&(this.parser.parseOpen(g),!0))}parseText(g){this.parser&&this.parser.parseText(g)}parseClose(g){if(this.parser)return this.parser.parseClose(g)||(this.parser=void 0),!0;if("border"===g){const g=this.model={},I=function(I,C,A){C&&(A&&Object.assign(C,A),g[I]=C)};I("left",this.map.left.model),I("right",this.map.right.model),I("top",this.map.top.model),I("bottom",this.map.bottom.model),I("diagonal",this.map.diagonal.model,{up:this.diagonalUp,down:this.diagonalDown})}return!1}}I.exports=t},{"../../../utils/utils":27,"../base-xform":32,"./color-xform":128}],128:[function(g,I,C){const A=g("../base-xform");class i extends A{constructor(g){super(),this.name=g||"color"}get tag(){return this.name}render(g,I){return!!I&&(g.openNode(this.name),I.argb?g.addAttribute("rgb",I.argb):void 0!==I.theme?(g.addAttribute("theme",I.theme),void 0!==I.tint&&g.addAttribute("tint",I.tint)):void 0!==I.indexed?g.addAttribute("indexed",I.indexed):g.addAttribute("auto","1"),g.closeNode(),!0)}parseOpen(g){return g.name===this.name&&(g.attributes.rgb?this.model={argb:g.attributes.rgb}:g.attributes.theme?(this.model={theme:parseInt(g.attributes.theme,10)},g.attributes.tint&&(this.model.tint=parseFloat(g.attributes.tint))):g.attributes.indexed?this.model={indexed:parseInt(g.attributes.indexed,10)}:this.model=void 0,!0)}parseText(){}parseClose(){return!1}}I.exports=i},{"../base-xform":32}],129:[function(g,I,C){const A=g("../base-xform"),i=g("./alignment-xform"),e=g("./border-xform"),l=g("./fill-xform"),t=g("./font-xform"),s=g("./numfmt-xform"),c=g("./protection-xform");class d extends A{constructor(){super(),this.map={alignment:new i,border:new e,fill:new l,font:new t,numFmt:new s,protection:new c}}get tag(){return"dxf"}render(g,I){if(g.openNode(this.tag),I.font&&this.map.font.render(g,I.font),I.numFmt&&I.numFmtId){const C={id:I.numFmtId,formatCode:I.numFmt};this.map.numFmt.render(g,C)}I.fill&&this.map.fill.render(g,I.fill),I.alignment&&this.map.alignment.render(g,I.alignment),I.border&&this.map.border.render(g,I.border),I.protection&&this.map.protection.render(g,I.protection),g.closeNode()}parseOpen(g){return this.parser?(this.parser.parseOpen(g),!0):g.name===this.tag?(this.reset(),!0):(this.parser=this.map[g.name],this.parser&&this.parser.parseOpen(g),!0)}parseText(g){this.parser&&this.parser.parseText(g)}parseClose(g){return this.parser?(this.parser.parseClose(g)||(this.parser=void 0),!0):g!==this.tag||(this.model={alignment:this.map.alignment.model,border:this.map.border.model,fill:this.map.fill.model,font:this.map.font.model,numFmt:this.map.numFmt.model,protection:this.map.protection.model},!1)}}I.exports=d},{"../base-xform":32,"./alignment-xform":126,"./border-xform":127,"./fill-xform":130,"./font-xform":131,"./numfmt-xform":132,"./protection-xform":133}],130:[function(g,I,C){const A=g("../base-xform"),i=g("./color-xform");class e extends A{constructor(){super(),this.map={color:new i}}get tag(){return"stop"}render(g,I){g.openNode("stop"),g.addAttribute("position",I.position),this.map.color.render(g,I.color),g.closeNode()}parseOpen(g){if(this.parser)return this.parser.parseOpen(g),!0;switch(g.name){case"stop":return this.model={position:parseFloat(g.attributes.position)},!0;case"color":return this.parser=this.map.color,this.parser.parseOpen(g),!0;default:return!1}}parseText(){}parseClose(g){return!!this.parser&&(this.parser.parseClose(g)||(this.model.color=this.parser.model,this.parser=void 0),!0)}}class l extends A{constructor(){super(),this.map={fgColor:new i("fgColor"),bgColor:new i("bgColor")}}get name(){return"pattern"}get tag(){return"patternFill"}render(g,I){g.openNode("patternFill"),g.addAttribute("patternType",I.pattern),I.fgColor&&this.map.fgColor.render(g,I.fgColor),I.bgColor&&this.map.bgColor.render(g,I.bgColor),g.closeNode()}parseOpen(g){return this.parser?(this.parser.parseOpen(g),!0):"patternFill"===g.name?(this.model={type:"pattern",pattern:g.attributes.patternType},!0):(this.parser=this.map[g.name],!!this.parser&&(this.parser.parseOpen(g),!0))}parseText(g){this.parser&&this.parser.parseText(g)}parseClose(g){return!!this.parser&&(this.parser.parseClose(g)||(this.parser.model&&(this.model[g]=this.parser.model),this.parser=void 0),!0)}}class t extends A{constructor(){super(),this.map={stop:new e}}get name(){return"gradient"}get tag(){return"gradientFill"}render(g,I){switch(g.openNode("gradientFill"),I.gradient){case"angle":g.addAttribute("degree",I.degree);break;case"path":g.addAttribute("type","path"),I.center.left&&(g.addAttribute("left",I.center.left),void 0===I.center.right&&g.addAttribute("right",I.center.left)),I.center.right&&g.addAttribute("right",I.center.right),I.center.top&&(g.addAttribute("top",I.center.top),void 0===I.center.bottom&&g.addAttribute("bottom",I.center.top)),I.center.bottom&&g.addAttribute("bottom",I.center.bottom)}const C=this.map.stop;I.stops.forEach((I=>{C.render(g,I)})),g.closeNode()}parseOpen(g){if(this.parser)return this.parser.parseOpen(g),!0;switch(g.name){case"gradientFill":{const I=this.model={stops:[]};return g.attributes.degree?(I.gradient="angle",I.degree=parseInt(g.attributes.degree,10)):"path"===g.attributes.type&&(I.gradient="path",I.center={left:g.attributes.left?parseFloat(g.attributes.left):0,top:g.attributes.top?parseFloat(g.attributes.top):0},g.attributes.right!==g.attributes.left&&(I.center.right=g.attributes.right?parseFloat(g.attributes.right):0),g.attributes.bottom!==g.attributes.top&&(I.center.bottom=g.attributes.bottom?parseFloat(g.attributes.bottom):0)),!0}case"stop":return this.parser=this.map.stop,this.parser.parseOpen(g),!0;default:return!1}}parseText(g){this.parser&&this.parser.parseText(g)}parseClose(g){return!!this.parser&&(this.parser.parseClose(g)||(this.model.stops.push(this.parser.model),this.parser=void 0),!0)}}class s extends A{constructor(){super(),this.map={patternFill:new l,gradientFill:new t}}get tag(){return"fill"}render(g,I){switch(g.addRollback(),g.openNode("fill"),I.type){case"pattern":this.map.patternFill.render(g,I);break;case"gradient":this.map.gradientFill.render(g,I);break;default:return void g.rollback()}g.closeNode(),g.commit()}parseOpen(g){return this.parser?(this.parser.parseOpen(g),!0):"fill"===g.name?(this.model={},!0):(this.parser=this.map[g.name],!!this.parser&&(this.parser.parseOpen(g),!0))}parseText(g){this.parser&&this.parser.parseText(g)}parseClose(g){return!!this.parser&&(this.parser.parseClose(g)||(this.model=this.parser.model,this.model.type=this.parser.name,this.parser=void 0),!0)}validStyle(g){return s.validPatternValues[g]}}s.validPatternValues=["none","solid","darkVertical","darkGray","mediumGray","lightGray","gray125","gray0625","darkHorizontal","darkVertical","darkDown","darkUp","darkGrid","darkTrellis","lightHorizontal","lightVertical","lightDown","lightUp","lightGrid","lightTrellis","lightGrid"].reduce(((g,I)=>(g[I]=!0,g)),{}),s.StopXform=e,s.PatternFillXform=l,s.GradientFillXform=t,I.exports=s},{"../base-xform":32,"./color-xform":128}],131:[function(g,I,C){const A=g("./color-xform"),i=g("../simple/boolean-xform"),e=g("../simple/integer-xform"),l=g("../simple/string-xform"),t=g("./underline-xform"),s=g("../../../utils/under-dash"),c=g("../base-xform");class d extends c{constructor(g){super(),this.options=g||d.OPTIONS,this.map={b:{prop:"bold",xform:new i({tag:"b",attr:"val"})},i:{prop:"italic",xform:new i({tag:"i",attr:"val"})},u:{prop:"underline",xform:new t},charset:{prop:"charset",xform:new e({tag:"charset",attr:"val"})},color:{prop:"color",xform:new A},condense:{prop:"condense",xform:new i({tag:"condense",attr:"val"})},extend:{prop:"extend",xform:new i({tag:"extend",attr:"val"})},family:{prop:"family",xform:new e({tag:"family",attr:"val"})},outline:{prop:"outline",xform:new i({tag:"outline",attr:"val"})},vertAlign:{prop:"vertAlign",xform:new l({tag:"vertAlign",attr:"val"})},scheme:{prop:"scheme",xform:new l({tag:"scheme",attr:"val"})},shadow:{prop:"shadow",xform:new i({tag:"shadow",attr:"val"})},strike:{prop:"strike",xform:new i({tag:"strike",attr:"val"})},sz:{prop:"size",xform:new e({tag:"sz",attr:"val"})}},this.map[this.options.fontNameTag]={prop:"name",xform:new l({tag:this.options.fontNameTag,attr:"val"})}}get tag(){return this.options.tagName}render(g,I){const{map:C}=this;g.openNode(this.options.tagName),s.each(this.map,((A,i)=>{C[i].xform.render(g,I[A.prop])})),g.closeNode()}parseOpen(g){return this.parser?(this.parser.parseOpen(g),!0):this.map[g.name]?(this.parser=this.map[g.name].xform,this.parser.parseOpen(g)):g.name===this.options.tagName&&(this.model={},!0)}parseText(g){this.parser&&this.parser.parseText(g)}parseClose(g){if(this.parser&&!this.parser.parseClose(g)){const I=this.map[g];return this.parser.model&&(this.model[I.prop]=this.parser.model),this.parser=void 0,!0}return g!==this.options.tagName}}d.OPTIONS={tagName:"font",fontNameTag:"name"},I.exports=d},{"../../../utils/under-dash":26,"../base-xform":32,"../simple/boolean-xform":116,"../simple/integer-xform":118,"../simple/string-xform":119,"./color-xform":128,"./underline-xform":136}],132:[function(g,I,C){const A=g("../../../utils/under-dash"),i=g("../../defaultnumformats"),e=g("../base-xform");function l(){const g={};return A.each(i,((I,C)=>{I.f&&(g[I.f]=parseInt(C,10))})),g}const t=l();class s extends e{constructor(g,I){super(),this.id=g,this.formatCode=I}get tag(){return"numFmt"}render(g,I){g.leafNode("numFmt",{numFmtId:I.id,formatCode:I.formatCode})}parseOpen(g){return"numFmt"===g.name&&(this.model={id:parseInt(g.attributes.numFmtId,10),formatCode:g.attributes.formatCode.replace(/[\\](.)/g,"$1")},!0)}parseText(){}parseClose(){return!1}}s.getDefaultFmtId=function(g){return t[g]},s.getDefaultFmtCode=function(g){return i[g]&&i[g].f},I.exports=s},{"../../../utils/under-dash":26,"../../defaultnumformats":30,"../base-xform":32}],133:[function(g,I,C){const A=g("../base-xform"),i={boolean:(g,I)=>void 0===g?I:g};class e extends A{get tag(){return"protection"}render(g,I){g.addRollback(),g.openNode("protection");let C=!1;function A(I,A){void 0!==A&&(g.addAttribute(I,A),C=!0)}A("locked",i.boolean(I.locked,!0)?void 0:"0"),A("hidden",i.boolean(I.hidden,!1)?"1":void 0),g.closeNode(),C?g.commit():g.rollback()}parseOpen(g){const I={locked:!("0"===g.attributes.locked),hidden:"1"===g.attributes.hidden},C=!I.locked||I.hidden;this.model=C?I:null}parseText(){}parseClose(){return!1}}I.exports=e},{"../base-xform":32}],134:[function(g,I,C){const A=g("../base-xform"),i=g("./alignment-xform"),e=g("./protection-xform");class l extends A{constructor(g){super(),this.xfId=!(!g||!g.xfId),this.map={alignment:new i,protection:new e}}get tag(){return"xf"}render(g,I){g.openNode("xf",{numFmtId:I.numFmtId||0,fontId:I.fontId||0,fillId:I.fillId||0,borderId:I.borderId||0}),this.xfId&&g.addAttribute("xfId",I.xfId||0),I.numFmtId&&g.addAttribute("applyNumberFormat","1"),I.fontId&&g.addAttribute("applyFont","1"),I.fillId&&g.addAttribute("applyFill","1"),I.borderId&&g.addAttribute("applyBorder","1"),I.alignment&&g.addAttribute("applyAlignment","1"),I.protection&&g.addAttribute("applyProtection","1"),I.alignment&&this.map.alignment.render(g,I.alignment),I.protection&&this.map.protection.render(g,I.protection),g.closeNode()}parseOpen(g){if(this.parser)return this.parser.parseOpen(g),!0;switch(g.name){case"xf":return this.model={numFmtId:parseInt(g.attributes.numFmtId,10),fontId:parseInt(g.attributes.fontId,10),fillId:parseInt(g.attributes.fillId,10),borderId:parseInt(g.attributes.borderId,10)},this.xfId&&(this.model.xfId=parseInt(g.attributes.xfId,10)),!0;case"alignment":return this.parser=this.map.alignment,this.parser.parseOpen(g),!0;case"protection":return this.parser=this.map.protection,this.parser.parseOpen(g),!0;default:return!1}}parseText(g){this.parser&&this.parser.parseText(g)}parseClose(g){return this.parser?(this.parser.parseClose(g)||(this.map.protection===this.parser?this.model.protection=this.parser.model:this.model.alignment=this.parser.model,this.parser=void 0),!0):"xf"!==g}}I.exports=l},{"../base-xform":32,"./alignment-xform":126,"./protection-xform":133}],135:[function(g,I,C){const A=g("../../../doc/enums"),i=g("../../../utils/xml-stream"),e=g("../base-xform"),l=g("../static-xform"),t=g("../list-xform"),s=g("./font-xform"),c=g("./fill-xform"),d=g("./border-xform"),o=g("./numfmt-xform"),n=g("./style-xform"),a=g("./dxf-xform"),Z=164;class b extends e{constructor(g){super(),this.map={numFmts:new t({tag:"numFmts",count:!0,childXform:new o}),fonts:new t({tag:"fonts",count:!0,childXform:new s,$:{"x14ac:knownFonts":1}}),fills:new t({tag:"fills",count:!0,childXform:new c}),borders:new t({tag:"borders",count:!0,childXform:new d}),cellStyleXfs:new t({tag:"cellStyleXfs",count:!0,childXform:new n}),cellXfs:new t({tag:"cellXfs",count:!0,childXform:new n({xfId:!0})}),dxfs:new t({tag:"dxfs",always:!0,count:!0,childXform:new a}),numFmt:new o,font:new s,fill:new c,border:new d,style:new n({xfId:!0}),cellStyles:b.STATIC_XFORMS.cellStyles,tableStyles:b.STATIC_XFORMS.tableStyles,extLst:b.STATIC_XFORMS.extLst},g&&this.init()}initIndex(){this.index={style:{},numFmt:{},numFmtNextId:164,font:{},border:{},fill:{}}}init(){this.model={styles:[],numFmts:[],fonts:[],borders:[],fills:[],dxfs:[]},this.initIndex(),this._addBorder({}),this._addStyle({numFmtId:0,fontId:0,fillId:0,borderId:0,xfId:0}),this._addFill({type:"pattern",pattern:"none"}),this._addFill({type:"pattern",pattern:"gray125"}),this.weakMap=new WeakMap}render(g,I){I=I||this.model,g.openXml(i.StdDocAttributes),g.openNode("styleSheet",b.STYLESHEET_ATTRIBUTES),this.index?(I.numFmts&&I.numFmts.length&&(g.openNode("numFmts",{count:I.numFmts.length}),I.numFmts.forEach((I=>{g.writeXml(I)})),g.closeNode()),I.fonts.length||this._addFont({size:11,color:{theme:1},name:"Calibri",family:2,scheme:"minor"}),g.openNode("fonts",{count:I.fonts.length,"x14ac:knownFonts":1}),I.fonts.forEach((I=>{g.writeXml(I)})),g.closeNode(),g.openNode("fills",{count:I.fills.length}),I.fills.forEach((I=>{g.writeXml(I)})),g.closeNode(),g.openNode("borders",{count:I.borders.length}),I.borders.forEach((I=>{g.writeXml(I)})),g.closeNode(),this.map.cellStyleXfs.render(g,[{numFmtId:0,fontId:0,fillId:0,borderId:0,xfId:0}]),g.openNode("cellXfs",{count:I.styles.length}),I.styles.forEach((I=>{g.writeXml(I)})),g.closeNode()):(this.map.numFmts.render(g,I.numFmts),this.map.fonts.render(g,I.fonts),this.map.fills.render(g,I.fills),this.map.borders.render(g,I.borders),this.map.cellStyleXfs.render(g,[{numFmtId:0,fontId:0,fillId:0,borderId:0,xfId:0}]),this.map.cellXfs.render(g,I.styles)),b.STATIC_XFORMS.cellStyles.render(g),this.map.dxfs.render(g,I.dxfs),b.STATIC_XFORMS.tableStyles.render(g),b.STATIC_XFORMS.extLst.render(g),g.closeNode()}parseOpen(g){return this.parser?(this.parser.parseOpen(g),!0):"styleSheet"===g.name?(this.initIndex(),!0):(this.parser=this.map[g.name],this.parser&&this.parser.parseOpen(g),!0)}parseText(g){this.parser&&this.parser.parseText(g)}parseClose(g){if(this.parser)return this.parser.parseClose(g)||(this.parser=void 0),!0;if("styleSheet"===g){this.model={};const g=(g,I)=>{I.model&&I.model.length&&(this.model[g]=I.model)};if(g("numFmts",this.map.numFmts),g("fonts",this.map.fonts),g("fills",this.map.fills),g("borders",this.map.borders),g("styles",this.map.cellXfs),g("dxfs",this.map.dxfs),this.index={model:[],numFmt:[]},this.model.numFmts){const g=this.index.numFmt;this.model.numFmts.forEach((I=>{g[I.id]=I.formatCode}))}return!1}return!0}addStyleModel(g,I){if(!g)return 0;if(this.model.fonts.length||this._addFont({size:11,color:{theme:1},name:"Calibri",family:2,scheme:"minor"}),this.weakMap&&this.weakMap.has(g))return this.weakMap.get(g);const C={};if(I=I||A.ValueType.Number,g.numFmt)C.numFmtId=this._addNumFmtStr(g.numFmt);else switch(I){case A.ValueType.Number:C.numFmtId=this._addNumFmtStr("General");break;case A.ValueType.Date:C.numFmtId=this._addNumFmtStr("mm-dd-yy")}g.font&&(C.fontId=this._addFont(g.font)),g.border&&(C.borderId=this._addBorder(g.border)),g.fill&&(C.fillId=this._addFill(g.fill)),g.alignment&&(C.alignment=g.alignment),g.protection&&(C.protection=g.protection);const i=this._addStyle(C);return this.weakMap&&this.weakMap.set(g,i),i}getStyleModel(g){const I=this.model.styles[g];if(!I)return null;let C=this.index.model[g];if(C)return C;if(C=this.index.model[g]={},I.numFmtId){const g=this.index.numFmt[I.numFmtId]||o.getDefaultFmtCode(I.numFmtId);g&&(C.numFmt=g)}function A(g,I,A){if(A||0===A){const i=I[A];i&&(C[g]=i)}}return A("font",this.model.fonts,I.fontId),A("border",this.model.borders,I.borderId),A("fill",this.model.fills,I.fillId),I.alignment&&(C.alignment=I.alignment),I.protection&&(C.protection=I.protection),C}addDxfStyle(g){return g.numFmt&&(g.numFmtId=this._addNumFmtStr(g.numFmt)),this.model.dxfs.push(g),this.model.dxfs.length-1}getDxfStyle(g){return this.model.dxfs[g]}_addStyle(g){const I=this.map.style.toXml(g);let C=this.index.style[I];return void 0===C&&(C=this.index.style[I]=this.model.styles.length,this.model.styles.push(I)),C}_addNumFmtStr(g){let I=o.getDefaultFmtId(g);if(void 0!==I)return I;if(I=this.index.numFmt[g],void 0!==I)return I;I=this.index.numFmt[g]=Z+this.model.numFmts.length;const C=this.map.numFmt.toXml({id:I,formatCode:g});return this.model.numFmts.push(C),I}_addFont(g){const I=this.map.font.toXml(g);let C=this.index.font[I];return void 0===C&&(C=this.index.font[I]=this.model.fonts.length,this.model.fonts.push(I)),C}_addBorder(g){const I=this.map.border.toXml(g);let C=this.index.border[I];return void 0===C&&(C=this.index.border[I]=this.model.borders.length,this.model.borders.push(I)),C}_addFill(g){const I=this.map.fill.toXml(g);let C=this.index.fill[I];return void 0===C&&(C=this.index.fill[I]=this.model.fills.length,this.model.fills.push(I)),C}}b.STYLESHEET_ATTRIBUTES={xmlns:"http://schemas.openxmlformats.org/spreadsheetml/2006/main","xmlns:mc":"http://schemas.openxmlformats.org/markup-compatibility/2006","mc:Ignorable":"x14ac x16r2","xmlns:x14ac":"http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac","xmlns:x16r2":"http://schemas.microsoft.com/office/spreadsheetml/2015/02/main"},b.STATIC_XFORMS={cellStyles:new l({tag:"cellStyles",$:{count:1},c:[{tag:"cellStyle",$:{name:"Normal",xfId:0,builtinId:0}}]}),dxfs:new l({tag:"dxfs",$:{count:0}}),tableStyles:new l({tag:"tableStyles",$:{count:0,defaultTableStyle:"TableStyleMedium2",defaultPivotStyle:"PivotStyleLight16"}}),extLst:new l({tag:"extLst",c:[{tag:"ext",$:{uri:"{EB79DEF2-80B8-43e5-95BD-54CBDDF9020C}","xmlns:x14":"http://schemas.microsoft.com/office/spreadsheetml/2009/9/main"},c:[{tag:"x14:slicerStyles",$:{defaultSlicerStyle:"SlicerStyleLight1"}}]},{tag:"ext",$:{uri:"{9260A510-F301-46a8-8635-F512D64BE5F5}","xmlns:x15":"http://schemas.microsoft.com/office/spreadsheetml/2010/11/main"},c:[{tag:"x15:timelineStyles",$:{defaultTimelineStyle:"TimeSlicerStyleLight1"}}]}]})};class r extends b{constructor(){super(),this.model={styles:[{numFmtId:0,fontId:0,fillId:0,borderId:0,xfId:0}],numFmts:[],fonts:[{size:11,color:{theme:1},name:"Calibri",family:2,scheme:"minor"}],borders:[{}],fills:[{type:"pattern",pattern:"none"},{type:"pattern",pattern:"gray125"}]}}parseStream(g){return g.autodrain(),Promise.resolve()}addStyleModel(g,I){return I===A.ValueType.Date?this.dateStyleId:0}get dateStyleId(){if(!this._dateStyleId){const g={numFmtId:o.getDefaultFmtId("mm-dd-yy")};this._dateStyleId=this.model.styles.length,this.model.styles.push(g)}return this._dateStyleId}getStyleModel(){return{}}}b.Mock=r,I.exports=b},{"../../../doc/enums":7,"../../../utils/xml-stream":28,"../base-xform":32,"../list-xform":71,"../static-xform":120,"./border-xform":127,"./dxf-xform":129,"./fill-xform":130,"./font-xform":131,"./numfmt-xform":132,"./style-xform":134}],136:[function(g,I,C){const A=g("../base-xform");class i extends A{constructor(g){super(),this.model=g}get tag(){return"u"}render(g,I){if(!0===(I=I||this.model))g.leafNode("u");else{const C=i.Attributes[I];C&&g.leafNode("u",C)}}parseOpen(g){"u"===g.name&&(this.model=g.attributes.val||!0)}parseText(){}parseClose(){return!1}}i.Attributes={single:{},double:{val:"double"},singleAccounting:{val:"singleAccounting"},doubleAccounting:{val:"doubleAccounting"}},I.exports=i},{"../base-xform":32}],137:[function(g,I,C){const A=g("../base-xform"),i=g("./filter-column-xform");class e extends A{constructor(){super(),this.map={filterColumn:new i}}get tag(){return"autoFilter"}prepare(g){g.columns.forEach(((g,I)=>{this.map.filterColumn.prepare(g,{index:I})}))}render(g,I){return g.openNode(this.tag,{ref:I.autoFilterRef}),I.columns.forEach((I=>{this.map.filterColumn.render(g,I)})),g.closeNode(),!0}parseOpen(g){if(this.parser)return this.parser.parseOpen(g),!0;if(g.name===this.tag)return this.model={autoFilterRef:g.attributes.ref,columns:[]},!0;if(this.parser=this.map[g.name],this.parser)return this.parseOpen(g),!0;throw new Error(`Unexpected xml node in parseOpen: ${JSON.stringify(g)}`)}parseText(g){this.parser&&this.parser.parseText(g)}parseClose(g){if(this.parser)return this.parser.parseClose(g)||(this.model.columns.push(this.parser.model),this.parser=void 0),!0;if(g===this.tag)return!1;throw new Error(`Unexpected xml node in parseClose: ${g}`)}}I.exports=e},{"../base-xform":32,"./filter-column-xform":139}],138:[function(g,I,C){const A=g("../base-xform");class i extends A{get tag(){return"customFilter"}render(g,I){g.leafNode(this.tag,{val:I.val,operator:I.operator})}parseOpen(g){return g.name===this.tag&&(this.model={val:g.attributes.val,operator:g.attributes.operator},!0)}parseText(){}parseClose(){return!1}}I.exports=i},{"../base-xform":32}],139:[function(g,I,C){const A=g("../base-xform"),i=g("../list-xform"),e=g("./custom-filter-xform"),l=g("./filter-xform");class t extends A{constructor(){super(),this.map={customFilters:new i({tag:"customFilters",count:!1,empty:!0,childXform:new e}),filters:new i({tag:"filters",count:!1,empty:!0,childXform:new l})}}get tag(){return"filterColumn"}prepare(g,I){g.colId=I.index.toString()}render(g,I){return I.customFilters?(g.openNode(this.tag,{colId:I.colId,hiddenButton:I.filterButton?"0":"1"}),this.map.customFilters.render(g,I.customFilters),g.closeNode(),!0):(g.leafNode(this.tag,{colId:I.colId,hiddenButton:I.filterButton?"0":"1"}),!0)}parseOpen(g){if(this.parser)return this.parser.parseOpen(g),!0;const{attributes:I}=g;if(g.name===this.tag)return this.model={filterButton:"0"===I.hiddenButton},!0;if(this.parser=this.map[g.name],this.parser)return this.parseOpen(g),!0;throw new Error(`Unexpected xml node in parseOpen: ${JSON.stringify(g)}`)}parseText(){}parseClose(g){return this.parser?(this.parser.parseClose(g)||(this.parser=void 0),!0):g!==this.tag||(this.model.customFilters=this.map.customFilters.model,!1)}}I.exports=t},{"../base-xform":32,"../list-xform":71,"./custom-filter-xform":138,"./filter-xform":140}],140:[function(g,I,C){const A=g("../base-xform");class i extends A{get tag(){return"filter"}render(g,I){g.leafNode(this.tag,{val:I.val})}parseOpen(g){return g.name===this.tag&&(this.model={val:g.attributes.val},!0)}parseText(){}parseClose(){return!1}}I.exports=i},{"../base-xform":32}],141:[function(g,I,C){const A=g("../base-xform");class i extends A{get tag(){return"tableColumn"}prepare(g,I){g.id=I.index+1}render(g,I){return g.leafNode(this.tag,{id:I.id.toString(),name:I.name,totalsRowLabel:I.totalsRowLabel,totalsRowFunction:I.totalsRowFunction,dxfId:I.dxfId}),!0}parseOpen(g){if(g.name===this.tag){const{attributes:I}=g;return this.model={name:I.name,totalsRowLabel:I.totalsRowLabel,totalsRowFunction:I.totalsRowFunction,dxfId:I.dxfId},!0}return!1}parseText(){}parseClose(){return!1}}I.exports=i},{"../base-xform":32}],142:[function(g,I,C){const A=g("../base-xform");class i extends A{get tag(){return"tableStyleInfo"}render(g,I){return g.leafNode(this.tag,{name:I.theme?I.theme:void 0,showFirstColumn:I.showFirstColumn?"1":"0",showLastColumn:I.showLastColumn?"1":"0",showRowStripes:I.showRowStripes?"1":"0",showColumnStripes:I.showColumnStripes?"1":"0"}),!0}parseOpen(g){if(g.name===this.tag){const{attributes:I}=g;return this.model={theme:I.name?I.name:null,showFirstColumn:"1"===I.showFirstColumn,showLastColumn:"1"===I.showLastColumn,showRowStripes:"1"===I.showRowStripes,showColumnStripes:"1"===I.showColumnStripes},!0}return!1}parseText(){}parseClose(){return!1}}I.exports=i},{"../base-xform":32}],143:[function(g,I,C){const A=g("../../../utils/xml-stream"),i=g("../base-xform"),e=g("../list-xform"),l=g("./auto-filter-xform"),t=g("./table-column-xform"),s=g("./table-style-info-xform");class c extends i{constructor(){super(),this.map={autoFilter:new l,tableColumns:new e({tag:"tableColumns",count:!0,empty:!0,childXform:new t}),tableStyleInfo:new s}}prepare(g,I){this.map.autoFilter.prepare(g),this.map.tableColumns.prepare(g.columns,I)}get tag(){return"table"}render(g,I){g.openXml(A.StdDocAttributes),g.openNode(this.tag,{...c.TABLE_ATTRIBUTES,id:I.id,name:I.name,displayName:I.displayName||I.name,ref:I.tableRef,totalsRowCount:I.totalsRow?"1":void 0,totalsRowShown:I.totalsRow?void 0:"1",headerRowCount:I.headerRow?"1":"0"}),this.map.autoFilter.render(g,I),this.map.tableColumns.render(g,I.columns),this.map.tableStyleInfo.render(g,I.style),g.closeNode()}parseOpen(g){if(this.parser)return this.parser.parseOpen(g),!0;const{name:I,attributes:C}=g;return I===this.tag?(this.reset(),this.model={name:C.name,displayName:C.displayName||C.name,tableRef:C.ref,totalsRow:"1"===C.totalsRowCount,headerRow:"1"===C.headerRowCount}):(this.parser=this.map[g.name],this.parser&&this.parser.parseOpen(g)),!0}parseText(g){this.parser&&this.parser.parseText(g)}parseClose(g){return this.parser?(this.parser.parseClose(g)||(this.parser=void 0),!0):g!==this.tag||(this.model.columns=this.map.tableColumns.model,this.map.autoFilter.model&&(this.model.autoFilterRef=this.map.autoFilter.model.autoFilterRef,this.map.autoFilter.model.columns.forEach(((g,I)=>{this.model.columns[I].filterButton=g.filterButton}))),this.model.style=this.map.tableStyleInfo.model,!1)}reconcile(g,I){g.columns.forEach((g=>{void 0!==g.dxfId&&(g.style=I.styles.getDxfStyle(g.dxfId))}))}}c.TABLE_ATTRIBUTES={xmlns:"http://schemas.openxmlformats.org/spreadsheetml/2006/main","xmlns:mc":"http://schemas.openxmlformats.org/markup-compatibility/2006","mc:Ignorable":"xr xr3","xmlns:xr":"http://schemas.microsoft.com/office/spreadsheetml/2014/revision","xmlns:xr3":"http://schemas.microsoft.com/office/spreadsheetml/2016/revision3"},I.exports=c},{"../../../utils/xml-stream":28,"../base-xform":32,"../list-xform":71,"./auto-filter-xform":137,"./table-column-xform":141,"./table-style-info-xform":142}],144:[function(g,I,C){(function(C,A){(function(){const i=g("fs"),e=g("jszip"),{PassThrough:l}=g("readable-stream"),t=g("../utils/zip-stream"),s=g("../utils/stream-buf"),c=g("../utils/utils"),d=g("../utils/xml-stream"),{bufferToString:o}=g("../utils/browser-buffer-decode"),n=g("./xform/style/styles-xform"),a=g("./xform/core/core-xform"),Z=g("./xform/strings/shared-strings-xform"),b=g("./xform/core/relationships-xform"),r=g("./xform/core/content-types-xform"),m=g("./xform/core/app-xform"),h=g("./xform/book/workbook-xform"),G=g("./xform/sheet/worksheet-xform"),u=g("./xform/drawing/drawing-xform"),B=g("./xform/table/table-xform"),w=g("./xform/comment/comments-xform"),W=g("./xform/comment/vml-notes-xform"),p=g("./xml/theme1");function V(g,I){return new Promise(((C,A)=>{i.readFile(g,I,((g,I)=>{g?A(g):C(I)}))}))}class y{constructor(g){this.workbook=g}async readFile(g,I){if(!(await c.fs.exists(g)))throw new Error(`File not found: ${g}`);const C=i.createReadStream(g);try{const g=await this.read(C,I);return C.close(),g}catch(A){throw C.close(),A}}parseRels(g){return(new b).parseStream(g)}parseWorkbook(g){return(new h).parseStream(g)}parseSharedStrings(g){return(new Z).parseStream(g)}reconcile(g,I){const C=new h,A=new G(I),i=new u,e=new B;C.reconcile(g);const l={media:g.media,mediaIndex:g.mediaIndex};Object.keys(g.drawings).forEach((I=>{const C=g.drawings[I],A=g.drawingRels[I];A&&(l.rels=A.reduce(((g,I)=>(g[I.Id]=I,g)),{}),(C.anchors||[]).forEach((g=>{const I=g.picture&&g.picture.hyperlinks;I&&l.rels[I.rId]&&(I.hyperlink=l.rels[I.rId].Target,delete I.rId)})),i.reconcile(C,l))}));const t={styles:g.styles};Object.values(g.tables).forEach((g=>{e.reconcile(g,t)}));const s={styles:g.styles,sharedStrings:g.sharedStrings,media:g.media,mediaIndex:g.mediaIndex,date1904:g.properties&&g.properties.date1904,drawings:g.drawings,comments:g.comments,tables:g.tables,vmlDrawings:g.vmlDrawings};g.worksheets.forEach((I=>{I.relationships=g.worksheetRels[I.sheetNo],A.reconcile(I,s)})),delete g.worksheetHash,delete g.worksheetRels,delete g.globalRels,delete g.sharedStrings,delete g.workbookRels,delete g.sheetDefs,delete g.styles,delete g.mediaIndex,delete g.drawings,delete g.drawingRels,delete g.vmlDrawings}async _processWorksheetEntry(g,I,C,A,i){const e=new G(A),l=await e.parseStream(g);l.sheetNo=C,I.worksheetHash[i]=l,I.worksheets.push(l)}async _processCommentEntry(g,I,C){const A=new w,i=await A.parseStream(g);I.comments[`../${C}.xml`]=i}async _processTableEntry(g,I,C){const A=new B,i=await A.parseStream(g);I.tables[`../tables/${C}.xml`]=i}async _processWorksheetRelsEntry(g,I,C){const A=new b,i=await A.parseStream(g);I.worksheetRels[C]=i}async _processMediaEntry(g,I,C){const A=C.lastIndexOf(".");if(A>=1){const i=C.substr(A+1),e=C.substr(0,A);await new Promise(((A,l)=>{const t=new s;t.on("finish",(()=>{I.mediaIndex[C]=I.media.length,I.mediaIndex[e]=I.media.length;const g={type:"image",name:e,extension:i,buffer:t.toBuffer()};I.media.push(g),A()})),g.on("error",(g=>{l(g)})),g.pipe(t)}))}}async _processDrawingEntry(g,I,C){const A=new u,i=await A.parseStream(g);I.drawings[C]=i}async _processDrawingRelsEntry(g,I,C){const A=new b,i=await A.parseStream(g);I.drawingRels[C]=i}async _processVmlDrawingEntry(g,I,C){const A=new W,i=await A.parseStream(g);I.vmlDrawings[`../drawings/${C}.vml`]=i}async _processThemeEntry(g,I,C){await new Promise(((A,i)=>{const e=new s;g.on("error",i),e.on("error",i),e.on("finish",(()=>{I.themes[C]=e.read().toString(),A()})),g.pipe(e)}))}createInputStream(){throw new Error("`XLSX#createInputStream` is deprecated. You should use `XLSX#read` instead. This method will be removed in version 5.0. Please follow upgrade instruction: https://github.com/exceljs/exceljs/blob/master/UPGRADE-4.0.md")}async read(g,I){!g[Symbol.asyncIterator]&&g.pipe&&(g=g.pipe(new l));const C=[];for await(const A of g)C.push(A);return this.load(A.concat(C),I)}async load(g,I){let i;i=I&&I.base64?A.from(g.toString(),"base64"):g;const t={worksheets:[],worksheetHash:{},worksheetRels:[],themes:{},media:[],mediaIndex:{},drawings:{},drawingRels:{},comments:{},tables:{},vmlDrawings:{}},s=await e.loadAsync(i);for(const A of Object.values(s.files))if(!A.dir){let g,i=A.name;if("/"===i[0]&&(i=i.substr(1)),i.match(/xl\/media\//)||i.match(/xl\/theme\/([a-zA-Z0-9]+)[.]xml/))g=new l,g.write(await A.async("nodebuffer"));else{let I;g=new l({writableObjectMode:!0,readableObjectMode:!0}),I=C.browser?o(await A.async("nodebuffer")):await A.async("string");const i=16384;for(let C=0;C{if("image"===I.type){const C=`xl/media/${I.name}.${I.extension}`;if(I.filename){const A=await V(I.filename);return g.append(A,{name:C})}if(I.buffer)return g.append(I.buffer,{name:C});if(I.base64){const A=I.base64,i=A.substring(A.indexOf(",")+1);return g.append(i,{name:C,base64:!0})}}throw new Error("Unsupported media")})))}addDrawings(g,I){const C=new u,A=new b;I.worksheets.forEach((I=>{const{drawing:i}=I;if(i){C.prepare(i,{});let I=C.toXml(i);g.append(I,{name:`xl/drawings/${i.name}.xml`}),I=A.toXml(i.rels),g.append(I,{name:`xl/drawings/_rels/${i.name}.xml.rels`})}}))}addTables(g,I){const C=new B;I.worksheets.forEach((I=>{const{tables:A}=I;A.forEach((I=>{C.prepare(I,{});const A=C.toXml(I);g.append(A,{name:`xl/tables/${I.target}`})}))}))}async addContentTypes(g,I){const C=(new r).toXml(I);g.append(C,{name:"[Content_Types].xml"})}async addApp(g,I){const C=(new m).toXml(I);g.append(C,{name:"docProps/app.xml"})}async addCore(g,I){const C=new a;g.append(C.toXml(I),{name:"docProps/core.xml"})}async addThemes(g,I){const C=I.themes||{theme1:p};Object.keys(C).forEach((I=>{const A=C[I],i=`xl/theme/${I}.xml`;g.append(A,{name:i})}))}async addOfficeRels(g){const I=(new b).toXml([{Id:"rId1",Type:y.RelType.OfficeDocument,Target:"xl/workbook.xml"},{Id:"rId2",Type:y.RelType.CoreProperties,Target:"docProps/core.xml"},{Id:"rId3",Type:y.RelType.ExtenderProperties,Target:"docProps/app.xml"}]);g.append(I,{name:"_rels/.rels"})}async addWorkbookRels(g,I){let C=1;const A=[{Id:"rId"+C++,Type:y.RelType.Styles,Target:"styles.xml"},{Id:"rId"+C++,Type:y.RelType.Theme,Target:"theme/theme1.xml"}];I.sharedStrings.count&&A.push({Id:"rId"+C++,Type:y.RelType.SharedStrings,Target:"sharedStrings.xml"}),I.worksheets.forEach((g=>{g.rId="rId"+C++,A.push({Id:g.rId,Type:y.RelType.Worksheet,Target:`worksheets/sheet${g.id}.xml`})}));const i=(new b).toXml(A);g.append(i,{name:"xl/_rels/workbook.xml.rels"})}async addSharedStrings(g,I){I.sharedStrings&&I.sharedStrings.count&&g.append(I.sharedStrings.xml,{name:"xl/sharedStrings.xml"})}async addStyles(g,I){const{xml:C}=I.styles;C&&g.append(C,{name:"xl/styles.xml"})}async addWorkbook(g,I){const C=new h;g.append(C.toXml(I),{name:"xl/workbook.xml"})}async addWorksheets(g,I){const C=new G,A=new b,i=new w,e=new W;I.worksheets.forEach((I=>{let l=new d;C.render(l,I),g.append(l.xml,{name:`xl/worksheets/sheet${I.id}.xml`}),I.rels&&I.rels.length&&(l=new d,A.render(l,I.rels),g.append(l.xml,{name:`xl/worksheets/_rels/sheet${I.id}.xml.rels`})),I.comments.length>0&&(l=new d,i.render(l,I),g.append(l.xml,{name:`xl/comments${I.id}.xml`}),l=new d,e.render(l,I),g.append(l.xml,{name:`xl/drawings/vmlDrawing${I.id}.vml`}))}))}_finalize(g){return new Promise(((I,C)=>{g.on("finish",(()=>{I(this)})),g.on("error",C),g.finalize()}))}prepareModel(g,I){g.creator=g.creator||"ExcelJS",g.lastModifiedBy=g.lastModifiedBy||"ExcelJS",g.created=g.created||new Date,g.modified=g.modified||new Date,g.useSharedStrings=void 0===I.useSharedStrings||I.useSharedStrings,g.useStyles=void 0===I.useStyles||I.useStyles,g.sharedStrings=new Z,g.styles=g.useStyles?new n(!0):new n.Mock;const C=new h,A=new G;C.prepare(g);const i={sharedStrings:g.sharedStrings,styles:g.styles,date1904:g.properties.date1904,drawingsCount:0,media:g.media};i.drawings=g.drawings=[],i.commentRefs=g.commentRefs=[];let e=0;g.tables=[],g.worksheets.forEach((I=>{I.tables.forEach((I=>{e++,I.target=`table${e}.xml`,I.id=e,g.tables.push(I)})),A.prepare(I,i)}))}async write(g,I){I=I||{};const{model:C}=this.workbook,A=new t.ZipWriter(I.zip);return A.pipe(g),this.prepareModel(C,I),await this.addContentTypes(A,C),await this.addOfficeRels(A,C),await this.addWorkbookRels(A,C),await this.addWorksheets(A,C),await this.addSharedStrings(A,C),await this.addDrawings(A,C),await this.addTables(A,C),await Promise.all([this.addThemes(A,C),this.addStyles(A,C)]),await this.addMedia(A,C),await Promise.all([this.addApp(A,C),this.addCore(A,C)]),await this.addWorkbook(A,C),this._finalize(A)}writeFile(g,I){const C=i.createWriteStream(g);return new Promise(((g,A)=>{C.on("finish",(()=>{g()})),C.on("error",(g=>{A(g)})),this.write(C,I).then((()=>{C.end()})).catch((g=>{A(g)}))}))}async writeBuffer(g){const I=new s;return await this.write(I,g),I.read()}}y.RelType=g("./rel-type"),I.exports=y}).call(this)}).call(this,g("_process"),g("buffer").Buffer)},{"../utils/browser-buffer-decode":16,"../utils/stream-buf":24,"../utils/utils":27,"../utils/xml-stream":28,"../utils/zip-stream":29,"./rel-type":31,"./xform/book/workbook-xform":38,"./xform/comment/comments-xform":40,"./xform/comment/vml-notes-xform":45,"./xform/core/app-xform":51,"./xform/core/content-types-xform":52,"./xform/core/core-xform":53,"./xform/core/relationships-xform":55,"./xform/drawing/drawing-xform":62,"./xform/sheet/worksheet-xform":115,"./xform/strings/shared-strings-xform":124,"./xform/style/styles-xform":135,"./xform/table/table-xform":143,"./xml/theme1":145,_process:467,buffer:220,fs:216,jszip:441,"readable-stream":491}],145:[function(g,I,C){I.exports='\n '},{}],146:[function(g,I,C){(function(I){(function(){Object.defineProperty(C,"__esModule",{value:!0}),C.CsvFormatterStream=void 0;const A=g("stream"),i=g("./formatter");class e extends A.Transform{constructor(g){super({writableObjectMode:g.objectMode}),this.hasWrittenBOM=!1,this.formatterOptions=g,this.rowFormatter=new i.RowFormatter(g),this.hasWrittenBOM=!g.writeBOM}transform(g){return this.rowFormatter.rowTransform=g,this}_transform(g,C,A){let i=!1;try{this.hasWrittenBOM||(this.push(this.formatterOptions.BOM),this.hasWrittenBOM=!0),this.rowFormatter.format(g,((g,C)=>g?(i=!0,A(g)):(C&&C.forEach((g=>{this.push(I.from(g,"utf8"))})),i=!0,A())))}catch(e){if(i)throw e;A(e)}}_flush(g){this.rowFormatter.finish(((C,A)=>C?g(C):(A&&A.forEach((g=>{this.push(I.from(g,"utf8"))})),g())))}}C.CsvFormatterStream=e}).call(this)}).call(this,g("buffer").Buffer)},{"./formatter":150,buffer:220,stream:505}],147:[function(g,I,C){Object.defineProperty(C,"__esModule",{value:!0}),C.FormatterOptions=void 0;class A{constructor(){let g=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};var I;this.objectMode=!0,this.delimiter=",",this.rowDelimiter="\n",this.quote='"',this.escape=this.quote,this.quoteColumns=!1,this.quoteHeaders=this.quoteColumns,this.headers=null,this.includeEndRowDelimiter=!1,this.writeBOM=!1,this.BOM="\ufeff",this.alwaysWriteHeaders=!1,Object.assign(this,g||{}),void 0===(null==g?void 0:g.quoteHeaders)&&(this.quoteHeaders=this.quoteColumns),!0===(null==g?void 0:g.quote)?this.quote='"':!1===(null==g?void 0:g.quote)&&(this.quote=""),"string"!=typeof(null==g?void 0:g.escape)&&(this.escape=this.quote),this.shouldWriteHeaders=!!this.headers&&(null===(I=g.writeHeaders)||void 0===I||I),this.headers=Array.isArray(this.headers)?this.headers:null,this.escapedQuote=`${this.escape}${this.quote}`}}C.FormatterOptions=A},{}],148:[function(g,I,C){var A=function(g){return g&&g.__esModule?g:{default:g}};Object.defineProperty(C,"__esModule",{value:!0}),C.FieldFormatter=void 0;const i=A(g("lodash.isboolean")),e=A(g("lodash.isnil")),l=A(g("lodash.escaperegexp"));class t{constructor(g){this._headers=null,this.formatterOptions=g,null!==g.headers&&(this.headers=g.headers),this.REPLACE_REGEXP=new RegExp(g.quote,"g");const I=`[${g.delimiter}${l.default(g.rowDelimiter)}|\r|\n]`;this.ESCAPE_REGEXP=new RegExp(I)}set headers(g){this._headers=g}shouldQuote(g,I){const C=I?this.formatterOptions.quoteHeaders:this.formatterOptions.quoteColumns;return i.default(C)?C:Array.isArray(C)?C[g]:null!==this._headers&&C[this._headers[g]]}format(g,I,C){const A=`${e.default(g)?"":g}`.replace(/\0/g,""),{formatterOptions:i}=this;return""!==i.quote&&-1!==A.indexOf(i.quote)?this.quoteField(A.replace(this.REPLACE_REGEXP,i.escapedQuote)):-1!==A.search(this.ESCAPE_REGEXP)||this.shouldQuote(I,C)?this.quoteField(A):A}quoteField(g){const{quote:I}=this.formatterOptions;return`${I}${g}${I}`}}C.FieldFormatter=t},{"lodash.escaperegexp":442,"lodash.isboolean":444,"lodash.isnil":447}],149:[function(g,I,C){var A=function(g){return g&&g.__esModule?g:{default:g}};Object.defineProperty(C,"__esModule",{value:!0}),C.RowFormatter=void 0;const i=A(g("lodash.isfunction")),e=A(g("lodash.isequal")),l=g("./FieldFormatter"),t=g("../types");class s{constructor(g){this.rowCount=0,this.formatterOptions=g,this.fieldFormatter=new l.FieldFormatter(g),this.headers=g.headers,this.shouldWriteHeaders=g.shouldWriteHeaders,this.hasWrittenHeaders=!1,null!==this.headers&&(this.fieldFormatter.headers=this.headers),g.transform&&(this.rowTransform=g.transform)}static isRowHashArray(g){return!!Array.isArray(g)&&Array.isArray(g[0])&&2===g[0].length}static isRowArray(g){return Array.isArray(g)&&!this.isRowHashArray(g)}static gatherHeaders(g){return s.isRowHashArray(g)?g.map((g=>g[0])):Array.isArray(g)?g:Object.keys(g)}static createTransform(g){return t.isSyncTransform(g)?(I,C)=>{let A=null;try{A=g(I)}catch(i){return C(i)}return C(null,A)}:(I,C)=>{g(I,C)}}set rowTransform(g){if(!i.default(g))throw new TypeError("The transform should be a function");this._rowTransform=s.createTransform(g)}format(g,I){this.callTransformer(g,((C,A)=>{if(C)return I(C);if(!g)return I(null);const i=[];if(A){const{shouldFormatColumns:g,headers:I}=this.checkHeaders(A);if(this.shouldWriteHeaders&&I&&!this.hasWrittenHeaders&&(i.push(this.formatColumns(I,!0)),this.hasWrittenHeaders=!0),g){const g=this.gatherColumns(A);i.push(this.formatColumns(g,!1))}}return I(null,i)}))}finish(g){const I=[];if(this.formatterOptions.alwaysWriteHeaders&&0===this.rowCount){if(!this.headers)return g(new Error("`alwaysWriteHeaders` option is set to true but `headers` option not provided."));I.push(this.formatColumns(this.headers,!0))}return this.formatterOptions.includeEndRowDelimiter&&I.push(this.formatterOptions.rowDelimiter),g(null,I)}checkHeaders(g){if(this.headers)return{shouldFormatColumns:!0,headers:this.headers};const I=s.gatherHeaders(g);return this.headers=I,this.fieldFormatter.headers=I,this.shouldWriteHeaders?{shouldFormatColumns:!e.default(I,g),headers:I}:{shouldFormatColumns:!0,headers:null}}gatherColumns(g){if(null===this.headers)throw new Error("Headers is currently null");return Array.isArray(g)?s.isRowHashArray(g)?this.headers.map(((I,C)=>{const A=g[C];return A?A[1]:""})):s.isRowArray(g)&&!this.shouldWriteHeaders?g:this.headers.map(((I,C)=>g[C])):this.headers.map((I=>g[I]))}callTransformer(g,I){return this._rowTransform?this._rowTransform(g,I):I(null,g)}formatColumns(g,I){const C=g.map(((g,C)=>this.fieldFormatter.format(g,C,I))).join(this.formatterOptions.delimiter),{rowCount:A}=this;return this.rowCount+=1,A?[this.formatterOptions.rowDelimiter,C].join(""):C}}C.RowFormatter=s},{"../types":152,"./FieldFormatter":148,"lodash.isequal":445,"lodash.isfunction":446}],150:[function(g,I,C){Object.defineProperty(C,"__esModule",{value:!0}),C.FieldFormatter=C.RowFormatter=void 0;var A=g("./RowFormatter");Object.defineProperty(C,"RowFormatter",{enumerable:!0,get:function(){return A.RowFormatter}});var i=g("./FieldFormatter");Object.defineProperty(C,"FieldFormatter",{enumerable:!0,get:function(){return i.FieldFormatter}})},{"./FieldFormatter":148,"./RowFormatter":149}],151:[function(g,I,C){(function(I){(function(){var A=Object.create?function(g,I,C,A){void 0===A&&(A=C),Object.defineProperty(g,A,{enumerable:!0,get:function(){return I[C]}})}:function(g,I,C,A){void 0===A&&(A=C),g[A]=I[C]},i=Object.create?function(g,I){Object.defineProperty(g,"default",{enumerable:!0,value:I})}:function(g,I){g.default=I},e=function(g){if(g&&g.__esModule)return g;var I={};if(null!=g)for(var C in g)"default"!==C&&Object.prototype.hasOwnProperty.call(g,C)&&A(I,g,C);return i(I,g),I},l=function(g,I){for(var C in g)"default"===C||Object.prototype.hasOwnProperty.call(I,C)||A(I,g,C)};Object.defineProperty(C,"__esModule",{value:!0}),C.writeToPath=C.writeToString=C.writeToBuffer=C.writeToStream=C.write=C.format=C.FormatterOptions=C.CsvFormatterStream=void 0;const t=g("util"),s=g("stream"),c=e(g("fs")),d=g("./FormatterOptions"),o=g("./CsvFormatterStream");l(g("./types"),C);var n=g("./CsvFormatterStream");Object.defineProperty(C,"CsvFormatterStream",{enumerable:!0,get:function(){return n.CsvFormatterStream}});var a=g("./FormatterOptions");Object.defineProperty(C,"FormatterOptions",{enumerable:!0,get:function(){return a.FormatterOptions}}),C.format=g=>new o.CsvFormatterStream(new d.FormatterOptions(g)),C.write=(g,I)=>{const A=C.format(I),i=t.promisify(((g,I)=>{A.write(g,void 0,I)}));return g.reduce(((g,I)=>g.then((()=>i(I)))),Promise.resolve()).then((()=>A.end())).catch((g=>{A.emit("error",g)})),A},C.writeToStream=(g,I,A)=>C.write(I,A).pipe(g),C.writeToBuffer=function(g){let A=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const i=[],e=new s.Writable({write(g,I,C){i.push(g),C()}});return new Promise(((l,t)=>{e.on("error",t).on("finish",(()=>l(I.concat(i)))),C.write(g,A).pipe(e)}))},C.writeToString=(g,I)=>C.writeToBuffer(g,I).then((g=>g.toString())),C.writeToPath=(g,I,A)=>{const i=c.createWriteStream(g,{encoding:"utf8"});return C.write(I,A).pipe(i)}}).call(this)}).call(this,g("buffer").Buffer)},{"./CsvFormatterStream":146,"./FormatterOptions":147,"./types":152,buffer:220,fs:216,stream:505,util:527}],152:[function(g,I,C){Object.defineProperty(C,"__esModule",{value:!0}),C.isSyncTransform=void 0,C.isSyncTransform=g=>1===g.length},{}],153:[function(g,I,C){(function(I){(function(){Object.defineProperty(C,"__esModule",{value:!0}),C.CsvParserStream=void 0;const A=g("string_decoder"),i=g("stream"),e=g("./transforms"),l=g("./parser");class t extends i.Transform{constructor(g){super({objectMode:g.objectMode}),this.lines="",this.rowCount=0,this.parsedRowCount=0,this.parsedLineCount=0,this.endEmitted=!1,this.headersEmitted=!1,this.parserOptions=g,this.parser=new l.Parser(g),this.headerTransformer=new e.HeaderTransformer(g),this.decoder=new A.StringDecoder(g.encoding),this.rowTransformerValidator=new e.RowTransformerValidator}get hasHitRowLimit(){return this.parserOptions.limitRows&&this.rowCount>=this.parserOptions.maxRows}get shouldEmitRows(){return this.parsedRowCount>this.parserOptions.skipRows}get shouldSkipLine(){return this.parsedLineCount<=this.parserOptions.skipLines}transform(g){return this.rowTransformerValidator.rowTransform=g,this}validate(g){return this.rowTransformerValidator.rowValidator=g,this}emit(g){if("end"===g)return this.endEmitted||(this.endEmitted=!0,super.emit("end",this.rowCount)),!1;for(var I=arguments.length,C=new Array(I>1?I-1:0),A=1;A{const l=g=>g?C(g):e%100!=0?i(e+1):void I((()=>i(e+1)));if(this.checkAndEmitHeaders(),e>=A||this.hasHitRowLimit)return C();if(this.parsedLineCount+=1,this.shouldSkipLine)return l();const t=g[e];this.rowCount+=1,this.parsedRowCount+=1;const s=this.rowCount;return this.transformRow(t,((g,I)=>{if(g)return this.rowCount-=1,l(g);if(!I)return l(new Error("expected transform result"));if(I.isValid){if(I.row)return this.pushRow(I.row,l)}else this.emit("data-invalid",I.row,s,I.reason);return l()}))};i(0)}transformRow(g,I){try{this.headerTransformer.transform(g,((C,A)=>C?I(C):A?A.isValid?A.row?this.shouldEmitRows?this.rowTransformerValidator.transformAndValidate(A.row,I):this.skipRow(I):(this.rowCount-=1,this.parsedRowCount-=1,I(null,{row:null,isValid:!0})):this.shouldEmitRows?I(null,{isValid:!1,row:g}):this.skipRow(I):I(new Error("Expected result from header transform"))))}catch(C){I(C)}}checkAndEmitHeaders(){!this.headersEmitted&&this.headerTransformer.headers&&(this.headersEmitted=!0,this.emit("headers",this.headerTransformer.headers))}skipRow(g){return this.rowCount-=1,g(null,{row:null,isValid:!0})}pushRow(g,I){try{this.parserOptions.objectMode?this.push(g):this.push(JSON.stringify(g)),I()}catch(C){I(C)}}static wrapDoneCallback(g){let I=!1;return function(C){if(C){if(I)throw C;return I=!0,void g(C)}for(var A=arguments.length,i=new Array(A>1?A-1:0),e=1;e1)throw new Error("delimiter option must be one character long");this.escapedDelimiter=i.default(this.delimiter),this.escapeChar=null!==(I=this.escape)&&void 0!==I?I:this.quote,this.supportsComments=!e.default(this.comment),this.NEXT_TOKEN_REGEXP=new RegExp(`([^\\s]|\\r\\n|\\n|\\r|${this.escapedDelimiter})`),this.maxRows>0&&(this.limitRows=!0)}}C.ParserOptions=l},{"lodash.escaperegexp":442,"lodash.isnil":447}],155:[function(g,I,C){var A=Object.create?function(g,I,C,A){void 0===A&&(A=C),Object.defineProperty(g,A,{enumerable:!0,get:function(){return I[C]}})}:function(g,I,C,A){void 0===A&&(A=C),g[A]=I[C]},i=Object.create?function(g,I){Object.defineProperty(g,"default",{enumerable:!0,value:I})}:function(g,I){g.default=I},e=function(g){if(g&&g.__esModule)return g;var I={};if(null!=g)for(var C in g)"default"!==C&&Object.prototype.hasOwnProperty.call(g,C)&&A(I,g,C);return i(I,g),I},l=function(g,I){for(var C in g)"default"===C||Object.prototype.hasOwnProperty.call(I,C)||A(I,g,C)};Object.defineProperty(C,"__esModule",{value:!0}),C.parseString=C.parseFile=C.parseStream=C.parse=C.ParserOptions=C.CsvParserStream=void 0;const t=e(g("fs")),s=g("stream"),c=g("./ParserOptions"),d=g("./CsvParserStream");l(g("./types"),C);var o=g("./CsvParserStream");Object.defineProperty(C,"CsvParserStream",{enumerable:!0,get:function(){return o.CsvParserStream}});var n=g("./ParserOptions");Object.defineProperty(C,"ParserOptions",{enumerable:!0,get:function(){return n.ParserOptions}}),C.parse=g=>new d.CsvParserStream(new c.ParserOptions(g)),C.parseStream=(g,I)=>g.pipe(new d.CsvParserStream(new c.ParserOptions(I))),C.parseFile=function(g){let I=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return t.createReadStream(g).pipe(new d.CsvParserStream(new c.ParserOptions(I)))},C.parseString=(g,I)=>{const C=new s.Readable;return C.push(g),C.push(null),C.pipe(new d.CsvParserStream(new c.ParserOptions(I)))}},{"./CsvParserStream":153,"./ParserOptions":154,"./types":169,fs:216,stream:505}],156:[function(g,I,C){Object.defineProperty(C,"__esModule",{value:!0}),C.Parser=void 0;const A=g("./Scanner"),i=g("./RowParser"),e=g("./Token");class l{constructor(g){this.parserOptions=g,this.rowParser=new i.RowParser(this.parserOptions)}static removeBOM(g){return g&&65279===g.charCodeAt(0)?g.slice(1):g}parse(g,I){const C=new A.Scanner({line:l.removeBOM(g),parserOptions:this.parserOptions,hasMoreData:I});return this.parserOptions.supportsComments?this.parseWithComments(C):this.parseWithoutComments(C)}parseWithoutComments(g){const I=[];let C=!0;for(;C;)C=this.parseRow(g,I);return{line:g.line,rows:I}}parseWithComments(g){const{parserOptions:I}=this,C=[];for(let A=g.nextCharacterToken;null!==A;A=g.nextCharacterToken)if(e.Token.isTokenComment(A,I)){if(null===g.advancePastLine())return{line:g.lineFromCursor,rows:C};if(!g.hasMoreCharacters)return{line:g.lineFromCursor,rows:C};g.truncateToCursor()}else if(!this.parseRow(g,C))break;return{line:g.line,rows:C}}parseRow(g,I){if(!g.nextNonSpaceToken)return!1;const C=this.rowParser.parse(g);return null!==C&&(this.parserOptions.ignoreEmpty&&i.RowParser.isEmptyRow(C)||I.push(C),!0)}}C.Parser=l},{"./RowParser":157,"./Scanner":158,"./Token":159}],157:[function(g,I,C){Object.defineProperty(C,"__esModule",{value:!0}),C.RowParser=void 0;const A=g("./column"),i=g("./Token"),e="";class l{constructor(g){this.parserOptions=g,this.columnParser=new A.ColumnParser(g)}static isEmptyRow(g){return g.join(e).replace(/\s+/g,e)===e}parse(g){const{parserOptions:I}=this,{hasMoreData:C}=g,A=g,e=[];let l=this.getStartToken(A,e);for(;l;){if(i.Token.isTokenRowDelimiter(l))return A.advancePastToken(l),!A.hasMoreCharacters&&i.Token.isTokenCarriageReturn(l,I)&&C?null:(A.truncateToCursor(),e);if(!this.shouldSkipColumnParse(A,l,e)){const g=this.columnParser.parse(A);if(null===g)return null;e.push(g)}l=A.nextNonSpaceToken}return C?null:(A.truncateToCursor(),e)}getStartToken(g,I){const C=g.nextNonSpaceToken;return null!==C&&i.Token.isTokenDelimiter(C,this.parserOptions)?(I.push(""),g.nextNonSpaceToken):C}shouldSkipColumnParse(g,I,C){const{parserOptions:A}=this;if(i.Token.isTokenDelimiter(I,A)){g.advancePastToken(I);const e=g.nextCharacterToken;if(!g.hasMoreCharacters||null!==e&&i.Token.isTokenRowDelimiter(e))return C.push(""),!0;if(null!==e&&i.Token.isTokenDelimiter(e,A))return C.push(""),!0}return!1}}C.RowParser=l},{"./Token":159,"./column":164}],158:[function(g,I,C){Object.defineProperty(C,"__esModule",{value:!0}),C.Scanner=void 0;const A=g("./Token"),i=/((?:\r\n)|\n|\r)/;class e{constructor(g){this.cursor=0,this.line=g.line,this.lineLength=this.line.length,this.parserOptions=g.parserOptions,this.hasMoreData=g.hasMoreData,this.cursor=g.cursor||0}get hasMoreCharacters(){return this.lineLength>this.cursor}get nextNonSpaceToken(){const{lineFromCursor:g}=this,I=this.parserOptions.NEXT_TOKEN_REGEXP;if(-1===g.search(I))return null;const C=I.exec(g);if(null==C)return null;const i=C[1],e=this.cursor+(C.index||0);return new A.Token({token:i,startCursor:e,endCursor:e+i.length-1})}get nextCharacterToken(){const{cursor:g,lineLength:I}=this;return I<=g?null:new A.Token({token:this.line[g],startCursor:g,endCursor:g})}get lineFromCursor(){return this.line.substr(this.cursor)}advancePastLine(){const g=i.exec(this.lineFromCursor);return g?(this.cursor+=(g.index||0)+g[0].length,this):this.hasMoreData?null:(this.cursor=this.lineLength,this)}advanceTo(g){return this.cursor=g,this}advanceToToken(g){return this.cursor=g.startCursor,this}advancePastToken(g){return this.cursor=g.endCursor+1,this}truncateToCursor(){return this.line=this.lineFromCursor,this.lineLength=this.line.length,this.cursor=0,this}}C.Scanner=e},{"./Token":159}],159:[function(g,I,C){Object.defineProperty(C,"__esModule",{value:!0}),C.Token=void 0;class A{constructor(g){this.token=g.token,this.startCursor=g.startCursor,this.endCursor=g.endCursor}static isTokenRowDelimiter(g){const I=g.token;return"\r"===I||"\n"===I||"\r\n"===I}static isTokenCarriageReturn(g,I){return g.token===I.carriageReturn}static isTokenComment(g,I){return I.supportsComments&&!!g&&g.token===I.comment}static isTokenEscapeCharacter(g,I){return g.token===I.escapeChar}static isTokenQuote(g,I){return g.token===I.quote}static isTokenDelimiter(g,I){return g.token===I.delimiter}}C.Token=A},{}],160:[function(g,I,C){Object.defineProperty(C,"__esModule",{value:!0}),C.ColumnFormatter=void 0;class A{constructor(g){g.trim?this.format=g=>g.trim():g.ltrim?this.format=g=>g.trimLeft():g.rtrim?this.format=g=>g.trimRight():this.format=g=>g}}C.ColumnFormatter=A},{}],161:[function(g,I,C){Object.defineProperty(C,"__esModule",{value:!0}),C.ColumnParser=void 0;const A=g("./NonQuotedColumnParser"),i=g("./QuotedColumnParser"),e=g("../Token");class l{constructor(g){this.parserOptions=g,this.quotedColumnParser=new i.QuotedColumnParser(g),this.nonQuotedColumnParser=new A.NonQuotedColumnParser(g)}parse(g){const{nextNonSpaceToken:I}=g;return null!==I&&e.Token.isTokenQuote(I,this.parserOptions)?(g.advanceToToken(I),this.quotedColumnParser.parse(g)):this.nonQuotedColumnParser.parse(g)}}C.ColumnParser=l},{"../Token":159,"./NonQuotedColumnParser":162,"./QuotedColumnParser":163}],162:[function(g,I,C){Object.defineProperty(C,"__esModule",{value:!0}),C.NonQuotedColumnParser=void 0;const A=g("./ColumnFormatter"),i=g("../Token");class e{constructor(g){this.parserOptions=g,this.columnFormatter=new A.ColumnFormatter(g)}parse(g){if(!g.hasMoreCharacters)return null;const{parserOptions:I}=this,C=[];let A=g.nextCharacterToken;for(;A&&!i.Token.isTokenDelimiter(A,I)&&!i.Token.isTokenRowDelimiter(A);A=g.nextCharacterToken)C.push(A.token),g.advancePastToken(A);return this.columnFormatter.format(C.join(""))}}C.NonQuotedColumnParser=e},{"../Token":159,"./ColumnFormatter":160}],163:[function(g,I,C){Object.defineProperty(C,"__esModule",{value:!0}),C.QuotedColumnParser=void 0;const A=g("./ColumnFormatter"),i=g("../Token");class e{constructor(g){this.parserOptions=g,this.columnFormatter=new A.ColumnFormatter(g)}parse(g){if(!g.hasMoreCharacters)return null;const I=g.cursor,{foundClosingQuote:C,col:A}=this.gatherDataBetweenQuotes(g);if(!C){if(g.advanceTo(I),!g.hasMoreData)throw new Error(`Parse Error: missing closing: '${this.parserOptions.quote||""}' in line: at '${g.lineFromCursor.replace(/[\r\n]/g,"\\n'")}'`);return null}return this.checkForMalformedColumn(g),A}gatherDataBetweenQuotes(g){const{parserOptions:I}=this;let C=!1,A=!1;const e=[];let l=g.nextCharacterToken;for(;!A&&null!==l;l=g.nextCharacterToken){const t=i.Token.isTokenQuote(l,I);if(!C&&t)C=!0;else if(C)if(i.Token.isTokenEscapeCharacter(l,I)){g.advancePastToken(l);const C=g.nextCharacterToken;null!==C&&(i.Token.isTokenQuote(C,I)||i.Token.isTokenEscapeCharacter(C,I))?(e.push(C.token),l=C):t?A=!0:e.push(l.token)}else t?A=!0:e.push(l.token);g.advancePastToken(l)}return{col:this.columnFormatter.format(e.join("")),foundClosingQuote:A}}checkForMalformedColumn(g){const{parserOptions:I}=this,{nextNonSpaceToken:C}=g;if(C){const A=i.Token.isTokenDelimiter(C,I),e=i.Token.isTokenRowDelimiter(C);if(!A&&!e){const A=g.lineFromCursor.substr(0,10).replace(/[\r\n]/g,"\\n'");throw new Error(`Parse Error: expected: '${I.escapedDelimiter}' OR new line got: '${C.token}'. at '${A}`)}g.advanceToToken(C)}else g.hasMoreData||g.advancePastLine()}}C.QuotedColumnParser=e},{"../Token":159,"./ColumnFormatter":160}],164:[function(g,I,C){Object.defineProperty(C,"__esModule",{value:!0}),C.ColumnFormatter=C.QuotedColumnParser=C.NonQuotedColumnParser=C.ColumnParser=void 0;var A=g("./ColumnParser");Object.defineProperty(C,"ColumnParser",{enumerable:!0,get:function(){return A.ColumnParser}});var i=g("./NonQuotedColumnParser");Object.defineProperty(C,"NonQuotedColumnParser",{enumerable:!0,get:function(){return i.NonQuotedColumnParser}});var e=g("./QuotedColumnParser");Object.defineProperty(C,"QuotedColumnParser",{enumerable:!0,get:function(){return e.QuotedColumnParser}});var l=g("./ColumnFormatter");Object.defineProperty(C,"ColumnFormatter",{enumerable:!0,get:function(){return l.ColumnFormatter}})},{"./ColumnFormatter":160,"./ColumnParser":161,"./NonQuotedColumnParser":162,"./QuotedColumnParser":163}],165:[function(g,I,C){Object.defineProperty(C,"__esModule",{value:!0}),C.QuotedColumnParser=C.NonQuotedColumnParser=C.ColumnParser=C.Token=C.Scanner=C.RowParser=C.Parser=void 0;var A=g("./Parser");Object.defineProperty(C,"Parser",{enumerable:!0,get:function(){return A.Parser}});var i=g("./RowParser");Object.defineProperty(C,"RowParser",{enumerable:!0,get:function(){return i.RowParser}});var e=g("./Scanner");Object.defineProperty(C,"Scanner",{enumerable:!0,get:function(){return e.Scanner}});var l=g("./Token");Object.defineProperty(C,"Token",{enumerable:!0,get:function(){return l.Token}});var t=g("./column");Object.defineProperty(C,"ColumnParser",{enumerable:!0,get:function(){return t.ColumnParser}}),Object.defineProperty(C,"NonQuotedColumnParser",{enumerable:!0,get:function(){return t.NonQuotedColumnParser}}),Object.defineProperty(C,"QuotedColumnParser",{enumerable:!0,get:function(){return t.QuotedColumnParser}})},{"./Parser":156,"./RowParser":157,"./Scanner":158,"./Token":159,"./column":164}],166:[function(g,I,C){var A=function(g){return g&&g.__esModule?g:{default:g}};Object.defineProperty(C,"__esModule",{value:!0}),C.HeaderTransformer=void 0;const i=A(g("lodash.isundefined")),e=A(g("lodash.isfunction")),l=A(g("lodash.uniq")),t=A(g("lodash.groupby"));class s{constructor(g){this.headers=null,this.receivedHeaders=!1,this.shouldUseFirstRow=!1,this.processedFirstRow=!1,this.headersLength=0,this.parserOptions=g,!0===g.headers?this.shouldUseFirstRow=!0:Array.isArray(g.headers)?this.setHeaders(g.headers):e.default(g.headers)&&(this.headersTransform=g.headers)}transform(g,I){return this.shouldMapRow(g)?I(null,this.processRow(g)):I(null,{row:null,isValid:!0})}shouldMapRow(g){const{parserOptions:I}=this;if(!this.headersTransform&&I.renameHeaders&&!this.processedFirstRow){if(!this.receivedHeaders)throw new Error("Error renaming headers: new headers must be provided in an array");return this.processedFirstRow=!0,!1}if(!this.receivedHeaders&&Array.isArray(g)){if(this.headersTransform)this.setHeaders(this.headersTransform(g));else{if(!this.shouldUseFirstRow)return!0;this.setHeaders(g)}return!1}return!0}processRow(g){if(!this.headers)return{row:g,isValid:!0};const{parserOptions:I}=this;if(!I.discardUnmappedColumns&&g.length>this.headersLength){if(!I.strictColumnHandling)throw new Error(`Unexpected Error: column header mismatch expected: ${this.headersLength} columns got: ${g.length}`);return{row:g,isValid:!1,reason:`Column header mismatch expected: ${this.headersLength} columns got: ${g.length}`}}return I.strictColumnHandling&&g.length!!g));if(l.default(C).length!==C.length){const g=t.default(C),I=Object.keys(g).filter((I=>g[I].length>1));throw new Error(`Duplicate headers found ${JSON.stringify(I)}`)}this.headers=g,this.receivedHeaders=!0,this.headersLength=(null===(I=this.headers)||void 0===I?void 0:I.length)||0}}C.HeaderTransformer=s},{"lodash.groupby":443,"lodash.isfunction":446,"lodash.isundefined":448,"lodash.uniq":449}],167:[function(g,I,C){var A=function(g){return g&&g.__esModule?g:{default:g}};Object.defineProperty(C,"__esModule",{value:!0}),C.RowTransformerValidator=void 0;const i=A(g("lodash.isfunction")),e=g("../types");class l{constructor(){this._rowTransform=null,this._rowValidator=null}static createTransform(g){return e.isSyncTransform(g)?(I,C)=>{let A=null;try{A=g(I)}catch(i){return C(i)}return C(null,A)}:g}static createValidator(g){return e.isSyncValidate(g)?(I,C)=>{C(null,{row:I,isValid:g(I)})}:(I,C)=>{g(I,((g,A,i)=>g?C(g):C(null,A?{row:I,isValid:A,reason:i}:{row:I,isValid:!1,reason:i})))}}set rowTransform(g){if(!i.default(g))throw new TypeError("The transform should be a function");this._rowTransform=l.createTransform(g)}set rowValidator(g){if(!i.default(g))throw new TypeError("The validate should be a function");this._rowValidator=l.createValidator(g)}transformAndValidate(g,I){return this.callTransformer(g,((g,C)=>g?I(g):C?this.callValidator(C,((g,A)=>g?I(g):A&&!A.isValid?I(null,{row:C,isValid:!1,reason:A.reason}):I(null,{row:C,isValid:!0}))):I(null,{row:null,isValid:!0})))}callTransformer(g,I){return this._rowTransform?this._rowTransform(g,I):I(null,g)}callValidator(g,I){return this._rowValidator?this._rowValidator(g,I):I(null,{row:g,isValid:!0})}}C.RowTransformerValidator=l},{"../types":169,"lodash.isfunction":446}],168:[function(g,I,C){Object.defineProperty(C,"__esModule",{value:!0}),C.HeaderTransformer=C.RowTransformerValidator=void 0;var A=g("./RowTransformerValidator");Object.defineProperty(C,"RowTransformerValidator",{enumerable:!0,get:function(){return A.RowTransformerValidator}});var i=g("./HeaderTransformer");Object.defineProperty(C,"HeaderTransformer",{enumerable:!0,get:function(){return i.HeaderTransformer}})},{"./HeaderTransformer":166,"./RowTransformerValidator":167}],169:[function(g,I,C){Object.defineProperty(C,"__esModule",{value:!0}),C.isSyncValidate=C.isSyncTransform=void 0,C.isSyncTransform=g=>1===g.length,C.isSyncValidate=g=>1===g.length},{}],170:[function(g,I,C){const A=C;A.bignum=g("bn.js"),A.define=g("./asn1/api").define,A.base=g("./asn1/base"),A.constants=g("./asn1/constants"),A.decoders=g("./asn1/decoders"),A.encoders=g("./asn1/encoders")},{"./asn1/api":171,"./asn1/base":173,"./asn1/constants":177,"./asn1/decoders":179,"./asn1/encoders":182,"bn.js":184}],171:[function(g,I,C){const A=g("./encoders"),i=g("./decoders"),e=g("inherits");function l(g,I){this.name=g,this.body=I,this.decoders={},this.encoders={}}C.define=function(g,I){return new l(g,I)},l.prototype._createNamed=function(g){const I=this.name;function C(g){this._initNamed(g,I)}return e(C,g),C.prototype._initNamed=function(I,C){g.call(this,I,C)},new C(this)},l.prototype._getDecoder=function(g){return g=g||"der",this.decoders.hasOwnProperty(g)||(this.decoders[g]=this._createNamed(i[g])),this.decoders[g]},l.prototype.decode=function(g,I,C){return this._getDecoder(I).decode(g,C)},l.prototype._getEncoder=function(g){return g=g||"der",this.encoders.hasOwnProperty(g)||(this.encoders[g]=this._createNamed(A[g])),this.encoders[g]},l.prototype.encode=function(g,I,C){return this._getEncoder(I).encode(g,C)}},{"./decoders":179,"./encoders":182,inherits:440}],172:[function(g,I,C){const A=g("inherits"),i=g("../base/reporter").Reporter,e=g("safer-buffer").Buffer;function l(g,I){i.call(this,I),e.isBuffer(g)?(this.base=g,this.offset=0,this.length=g.length):this.error("Input not Buffer")}function t(g,I){if(Array.isArray(g))this.length=0,this.value=g.map((function(g){return t.isEncoderBuffer(g)||(g=new t(g,I)),this.length+=g.length,g}),this);else if("number"==typeof g){if(!(0<=g&&g<=255))return I.error("non-byte EncoderBuffer value");this.value=g,this.length=1}else if("string"==typeof g)this.value=g,this.length=e.byteLength(g);else{if(!e.isBuffer(g))return I.error("Unsupported type: "+typeof g);this.value=g,this.length=g.length}}A(l,i),C.DecoderBuffer=l,l.isDecoderBuffer=function(g){return g instanceof l||"object"==typeof g&&e.isBuffer(g.base)&&"DecoderBuffer"===g.constructor.name&&"number"==typeof g.offset&&"number"==typeof g.length&&"function"==typeof g.save&&"function"==typeof g.restore&&"function"==typeof g.isEmpty&&"function"==typeof g.readUInt8&&"function"==typeof g.skip&&"function"==typeof g.raw},l.prototype.save=function(){return{offset:this.offset,reporter:i.prototype.save.call(this)}},l.prototype.restore=function(g){const I=new l(this.base);return I.offset=g.offset,I.length=this.offset,this.offset=g.offset,i.prototype.restore.call(this,g.reporter),I},l.prototype.isEmpty=function(){return this.offset===this.length},l.prototype.readUInt8=function(g){return this.offset+1<=this.length?this.base.readUInt8(this.offset++,!0):this.error(g||"DecoderBuffer overrun")},l.prototype.skip=function(g,I){if(!(this.offset+g<=this.length))return this.error(I||"DecoderBuffer overrun");const C=new l(this.base);return C._reporterState=this._reporterState,C.offset=this.offset,C.length=this.offset+g,this.offset+=g,C},l.prototype.raw=function(g){return this.base.slice(g?g.offset:this.offset,this.length)},C.EncoderBuffer=t,t.isEncoderBuffer=function(g){return g instanceof t||"object"==typeof g&&"EncoderBuffer"===g.constructor.name&&"number"==typeof g.length&&"function"==typeof g.join},t.prototype.join=function(g,I){return g||(g=e.alloc(this.length)),I||(I=0),0===this.length||(Array.isArray(this.value)?this.value.forEach((function(C){C.join(g,I),I+=C.length})):("number"==typeof this.value?g[I]=this.value:"string"==typeof this.value?g.write(this.value,I):e.isBuffer(this.value)&&this.value.copy(g,I),I+=this.length)),g}},{"../base/reporter":175,inherits:440,"safer-buffer":495}],173:[function(g,I,C){const A=C;A.Reporter=g("./reporter").Reporter,A.DecoderBuffer=g("./buffer").DecoderBuffer,A.EncoderBuffer=g("./buffer").EncoderBuffer,A.Node=g("./node")},{"./buffer":172,"./node":174,"./reporter":175}],174:[function(g,I,C){const A=g("../base/reporter").Reporter,i=g("../base/buffer").EncoderBuffer,e=g("../base/buffer").DecoderBuffer,l=g("minimalistic-assert"),t=["seq","seqof","set","setof","objid","bool","gentime","utctime","null_","enum","int","objDesc","bitstr","bmpstr","charstr","genstr","graphstr","ia5str","iso646str","numstr","octstr","printstr","t61str","unistr","utf8str","videostr"],s=["key","obj","use","optional","explicit","implicit","def","choice","any","contains"].concat(t),c=["_peekTag","_decodeTag","_use","_decodeStr","_decodeObjid","_decodeTime","_decodeNull","_decodeInt","_decodeBool","_decodeList","_encodeComposite","_encodeStr","_encodeObjid","_encodeTime","_encodeNull","_encodeInt","_encodeBool"];function d(g,I,C){const A={};this._baseState=A,A.name=C,A.enc=g,A.parent=I||null,A.children=null,A.tag=null,A.args=null,A.reverseArgs=null,A.choice=null,A.optional=!1,A.any=!1,A.obj=!1,A.use=null,A.useDecoder=null,A.key=null,A.default=null,A.explicit=null,A.implicit=null,A.contains=null,A.parent||(A.children=[],this._wrap())}I.exports=d;const o=["enc","parent","children","tag","args","reverseArgs","choice","optional","any","obj","use","alteredUse","key","default","explicit","implicit","contains"];d.prototype.clone=function(){const g=this._baseState,I={};o.forEach((function(C){I[C]=g[C]}));const C=new this.constructor(I.parent);return C._baseState=I,C},d.prototype._wrap=function(){const g=this._baseState;s.forEach((function(I){this[I]=function(){const C=new this.constructor(this);return g.children.push(C),C[I].apply(C,arguments)}}),this)},d.prototype._init=function(g){const I=this._baseState;l(null===I.parent),g.call(this),I.children=I.children.filter((function(g){return g._baseState.parent===this}),this),l.equal(I.children.length,1,"Root node can have only one child")},d.prototype._useArgs=function(g){const I=this._baseState,C=g.filter((function(g){return g instanceof this.constructor}),this);g=g.filter((function(g){return!(g instanceof this.constructor)}),this),0!==C.length&&(l(null===I.children),I.children=C,C.forEach((function(g){g._baseState.parent=this}),this)),0!==g.length&&(l(null===I.args),I.args=g,I.reverseArgs=g.map((function(g){if("object"!=typeof g||g.constructor!==Object)return g;const I={};return Object.keys(g).forEach((function(C){C==(0|C)&&(C|=0);const A=g[C];I[A]=C})),I})))},c.forEach((function(g){d.prototype[g]=function(){const I=this._baseState;throw new Error(g+" not implemented for encoding: "+I.enc)}})),t.forEach((function(g){d.prototype[g]=function(){const I=this._baseState,C=Array.prototype.slice.call(arguments);return l(null===I.tag),I.tag=g,this._useArgs(C),this}})),d.prototype.use=function(g){l(g);const I=this._baseState;return l(null===I.use),I.use=g,this},d.prototype.optional=function(){return this._baseState.optional=!0,this},d.prototype.def=function(g){const I=this._baseState;return l(null===I.default),I.default=g,I.optional=!0,this},d.prototype.explicit=function(g){const I=this._baseState;return l(null===I.explicit&&null===I.implicit),I.explicit=g,this},d.prototype.implicit=function(g){const I=this._baseState;return l(null===I.explicit&&null===I.implicit),I.implicit=g,this},d.prototype.obj=function(){const g=this._baseState,I=Array.prototype.slice.call(arguments);return g.obj=!0,0!==I.length&&this._useArgs(I),this},d.prototype.key=function(g){const I=this._baseState;return l(null===I.key),I.key=g,this},d.prototype.any=function(){return this._baseState.any=!0,this},d.prototype.choice=function(g){const I=this._baseState;return l(null===I.choice),I.choice=g,this._useArgs(Object.keys(g).map((function(I){return g[I]}))),this},d.prototype.contains=function(g){const I=this._baseState;return l(null===I.use),I.contains=g,this},d.prototype._decode=function(g,I){const C=this._baseState;if(null===C.parent)return g.wrapResult(C.children[0]._decode(g,I));let A,i=C.default,l=!0,t=null;if(null!==C.key&&(t=g.enterKey(C.key)),C.optional){let A=null;if(null!==C.explicit?A=C.explicit:null!==C.implicit?A=C.implicit:null!==C.tag&&(A=C.tag),null!==A||C.any){if(l=this._peekTag(g,A,C.any),g.isError(l))return l}else{const A=g.save();try{null===C.choice?this._decodeGeneric(C.tag,g,I):this._decodeChoice(g,I),l=!0}catch(s){l=!1}g.restore(A)}}if(C.obj&&l&&(A=g.enterObject()),l){if(null!==C.explicit){const I=this._decodeTag(g,C.explicit);if(g.isError(I))return I;g=I}const A=g.offset;if(null===C.use&&null===C.choice){let I;C.any&&(I=g.save());const A=this._decodeTag(g,null!==C.implicit?C.implicit:C.tag,C.any);if(g.isError(A))return A;C.any?i=g.raw(I):g=A}if(I&&I.track&&null!==C.tag&&I.track(g.path(),A,g.length,"tagged"),I&&I.track&&null!==C.tag&&I.track(g.path(),g.offset,g.length,"content"),C.any||(i=null===C.choice?this._decodeGeneric(C.tag,g,I):this._decodeChoice(g,I)),g.isError(i))return i;if(C.any||null!==C.choice||null===C.children||C.children.forEach((function(C){C._decode(g,I)})),C.contains&&("octstr"===C.tag||"bitstr"===C.tag)){const A=new e(i);i=this._getUse(C.contains,g._reporterState.obj)._decode(A,I)}}return C.obj&&l&&(i=g.leaveObject(A)),null===C.key||null===i&&!0!==l?null!==t&&g.exitKey(t):g.leaveKey(t,C.key,i),i},d.prototype._decodeGeneric=function(g,I,C){const A=this._baseState;return"seq"===g||"set"===g?null:"seqof"===g||"setof"===g?this._decodeList(I,g,A.args[0],C):/str$/.test(g)?this._decodeStr(I,g,C):"objid"===g&&A.args?this._decodeObjid(I,A.args[0],A.args[1],C):"objid"===g?this._decodeObjid(I,null,null,C):"gentime"===g||"utctime"===g?this._decodeTime(I,g,C):"null_"===g?this._decodeNull(I,C):"bool"===g?this._decodeBool(I,C):"objDesc"===g?this._decodeStr(I,g,C):"int"===g||"enum"===g?this._decodeInt(I,A.args&&A.args[0],C):null!==A.use?this._getUse(A.use,I._reporterState.obj)._decode(I,C):I.error("unknown tag: "+g)},d.prototype._getUse=function(g,I){const C=this._baseState;return C.useDecoder=this._use(g,I),l(null===C.useDecoder._baseState.parent),C.useDecoder=C.useDecoder._baseState.children[0],C.implicit!==C.useDecoder._baseState.implicit&&(C.useDecoder=C.useDecoder.clone(),C.useDecoder._baseState.implicit=C.implicit),C.useDecoder},d.prototype._decodeChoice=function(g,I){const C=this._baseState;let A=null,i=!1;return Object.keys(C.choice).some((function(e){const l=g.save(),t=C.choice[e];try{const C=t._decode(g,I);if(g.isError(C))return!1;A={type:e,value:C},i=!0}catch(s){return g.restore(l),!1}return!0}),this),i?A:g.error("Choice not matched")},d.prototype._createEncoderBuffer=function(g){return new i(g,this.reporter)},d.prototype._encode=function(g,I,C){const A=this._baseState;if(null!==A.default&&A.default===g)return;const i=this._encodeValue(g,I,C);return void 0===i||this._skipDefault(i,I,C)?void 0:i},d.prototype._encodeValue=function(g,I,C){const i=this._baseState;if(null===i.parent)return i.children[0]._encode(g,I||new A);let e=null;if(this.reporter=I,i.optional&&void 0===g){if(null===i.default)return;g=i.default}let l=null,t=!1;if(i.any)e=this._createEncoderBuffer(g);else if(i.choice)e=this._encodeChoice(g,I);else if(i.contains)l=this._getUse(i.contains,C)._encode(g,I),t=!0;else if(i.children)l=i.children.map((function(C){if("null_"===C._baseState.tag)return C._encode(null,I,g);if(null===C._baseState.key)return I.error("Child should have a key");const A=I.enterKey(C._baseState.key);if("object"!=typeof g)return I.error("Child expected, but input is not object");const i=C._encode(g[C._baseState.key],I,g);return I.leaveKey(A),i}),this).filter((function(g){return g})),l=this._createEncoderBuffer(l);else if("seqof"===i.tag||"setof"===i.tag){if(!i.args||1!==i.args.length)return I.error("Too many args for : "+i.tag);if(!Array.isArray(g))return I.error("seqof/setof, but data is not Array");const C=this.clone();C._baseState.implicit=null,l=this._createEncoderBuffer(g.map((function(C){const A=this._baseState;return this._getUse(A.args[0],g)._encode(C,I)}),C))}else null!==i.use?e=this._getUse(i.use,C)._encode(g,I):(l=this._encodePrimitive(i.tag,g),t=!0);if(!i.any&&null===i.choice){const g=null!==i.implicit?i.implicit:i.tag,C=null===i.implicit?"universal":"context";null===g?null===i.use&&I.error("Tag could be omitted only for .use()"):null===i.use&&(e=this._encodeComposite(g,t,C,l))}return null!==i.explicit&&(e=this._encodeComposite(i.explicit,!1,"context",e)),e},d.prototype._encodeChoice=function(g,I){const C=this._baseState,A=C.choice[g.type];return A||l(!1,g.type+" not found in "+JSON.stringify(Object.keys(C.choice))),A._encode(g.value,I)},d.prototype._encodePrimitive=function(g,I){const C=this._baseState;if(/str$/.test(g))return this._encodeStr(I,g);if("objid"===g&&C.args)return this._encodeObjid(I,C.reverseArgs[0],C.args[1]);if("objid"===g)return this._encodeObjid(I,null,null);if("gentime"===g||"utctime"===g)return this._encodeTime(I,g);if("null_"===g)return this._encodeNull();if("int"===g||"enum"===g)return this._encodeInt(I,C.args&&C.reverseArgs[0]);if("bool"===g)return this._encodeBool(I);if("objDesc"===g)return this._encodeStr(I,g);throw new Error("Unsupported tag: "+g)},d.prototype._isNumstr=function(g){return/^[0-9 ]*$/.test(g)},d.prototype._isPrintstr=function(g){return/^[A-Za-z0-9 '()+,-./:=?]*$/.test(g)}},{"../base/buffer":172,"../base/reporter":175,"minimalistic-assert":453}],175:[function(g,I,C){const A=g("inherits");function i(g){this._reporterState={obj:null,path:[],options:g||{},errors:[]}}function e(g,I){this.path=g,this.rethrow(I)}C.Reporter=i,i.prototype.isError=function(g){return g instanceof e},i.prototype.save=function(){const g=this._reporterState;return{obj:g.obj,pathLen:g.path.length}},i.prototype.restore=function(g){const I=this._reporterState;I.obj=g.obj,I.path=I.path.slice(0,g.pathLen)},i.prototype.enterKey=function(g){return this._reporterState.path.push(g)},i.prototype.exitKey=function(g){const I=this._reporterState;I.path=I.path.slice(0,g-1)},i.prototype.leaveKey=function(g,I,C){const A=this._reporterState;this.exitKey(g),null!==A.obj&&(A.obj[I]=C)},i.prototype.path=function(){return this._reporterState.path.join("/")},i.prototype.enterObject=function(){const g=this._reporterState,I=g.obj;return g.obj={},I},i.prototype.leaveObject=function(g){const I=this._reporterState,C=I.obj;return I.obj=g,C},i.prototype.error=function(g){let I;const C=this._reporterState,A=g instanceof e;if(I=A?g:new e(C.path.map((function(g){return"["+JSON.stringify(g)+"]"})).join(""),g.message||g,g.stack),!C.options.partial)throw I;return A||C.errors.push(I),I},i.prototype.wrapResult=function(g){const I=this._reporterState;return I.options.partial?{result:this.isError(g)?null:g,errors:I.errors}:g},A(e,Error),e.prototype.rethrow=function(g){if(this.message=g+" at: "+(this.path||"(shallow)"),Error.captureStackTrace&&Error.captureStackTrace(this,e),!this.stack)try{throw new Error(this.message)}catch(I){this.stack=I.stack}return this}},{inherits:440}],176:[function(g,I,C){function A(g){const I={};return Object.keys(g).forEach((function(C){(0|C)==C&&(C|=0);const A=g[C];I[A]=C})),I}C.tagClass={0:"universal",1:"application",2:"context",3:"private"},C.tagClassByName=A(C.tagClass),C.tag={0:"end",1:"bool",2:"int",3:"bitstr",4:"octstr",5:"null_",6:"objid",7:"objDesc",8:"external",9:"real",10:"enum",11:"embed",12:"utf8str",13:"relativeOid",16:"seq",17:"set",18:"numstr",19:"printstr",20:"t61str",21:"videostr",22:"ia5str",23:"utctime",24:"gentime",25:"graphstr",26:"iso646str",27:"genstr",28:"unistr",29:"charstr",30:"bmpstr"},C.tagByName=A(C.tag)},{}],177:[function(g,I,C){const A=C;A._reverse=function(g){const I={};return Object.keys(g).forEach((function(C){(0|C)==C&&(C|=0);const A=g[C];I[A]=C})),I},A.der=g("./der")},{"./der":176}],178:[function(g,I,C){const A=g("inherits"),i=g("bn.js"),e=g("../base/buffer").DecoderBuffer,l=g("../base/node"),t=g("../constants/der");function s(g){this.enc="der",this.name=g.name,this.entity=g,this.tree=new c,this.tree._init(g.body)}function c(g){l.call(this,"der",g)}function d(g,I){let C=g.readUInt8(I);if(g.isError(C))return C;const A=t.tagClass[C>>6],i=!(32&C);if(31&~C)C&=31;else{let A=C;for(C=0;!(128&~A);){if(A=g.readUInt8(I),g.isError(A))return A;C<<=7,C|=127&A}}return{cls:A,primitive:i,tag:C,tagStr:t.tag[C]}}function o(g,I,C){let A=g.readUInt8(C);if(g.isError(A))return A;if(!I&&128===A)return null;if(!(128&A))return A;const i=127&A;if(i>4)return g.error("length octect is too long");A=0;for(let e=0;e=31?A.error("Multi-octet tag encoding unsupported"):(I||(i|=32),i|=l.tagClassByName[C||"universal"]<<6,i)}I.exports=t,t.prototype.encode=function(g,I){return this.tree._encode(g,I).join()},A(s,e),s.prototype._encodeComposite=function(g,I,C,A){const e=d(g,I,C,this.reporter);if(A.length<128){const g=i.alloc(2);return g[0]=e,g[1]=A.length,this._createEncoderBuffer([g,A])}let l=1;for(let i=A.length;i>=256;i>>=8)l++;const t=i.alloc(2+l);t[0]=e,t[1]=128|l;for(let i=1+l,s=A.length;s>0;i--,s>>=8)t[i]=255&s;return this._createEncoderBuffer([t,A])},s.prototype._encodeStr=function(g,I){if("bitstr"===I)return this._createEncoderBuffer([0|g.unused,g.data]);if("bmpstr"===I){const I=i.alloc(2*g.length);for(let C=0;C=40)return this.reporter.error("Second objid identifier OOB");g.splice(0,2,40*g[0]+g[1])}let A=0;for(let i=0;i=128;I>>=7)A++}const e=i.alloc(A);let l=e.length-1;for(let i=g.length-1;i>=0;i--){let I=g[i];for(e[l--]=127&I;(I>>=7)>0;)e[l--]=128|127&I}return this._createEncoderBuffer(e)},s.prototype._encodeTime=function(g,I){let C;const A=new Date(g);return"gentime"===I?C=[c(A.getUTCFullYear()),c(A.getUTCMonth()+1),c(A.getUTCDate()),c(A.getUTCHours()),c(A.getUTCMinutes()),c(A.getUTCSeconds()),"Z"].join(""):"utctime"===I?C=[c(A.getUTCFullYear()%100),c(A.getUTCMonth()+1),c(A.getUTCDate()),c(A.getUTCHours()),c(A.getUTCMinutes()),c(A.getUTCSeconds()),"Z"].join(""):this.reporter.error("Encoding "+I+" time is not supported yet"),this._encodeStr(C,"octstr")},s.prototype._encodeNull=function(){return this._createEncoderBuffer("")},s.prototype._encodeInt=function(g,I){if("string"==typeof g){if(!I)return this.reporter.error("String int or enum given, but no values map");if(!I.hasOwnProperty(g))return this.reporter.error("Values map doesn't contain: "+JSON.stringify(g));g=I[g]}if("number"!=typeof g&&!i.isBuffer(g)){const I=g.toArray();!g.sign&&128&I[0]&&I.unshift(0),g=i.from(I)}if(i.isBuffer(g)){let I=g.length;0===g.length&&I++;const C=i.alloc(I);return g.copy(C),0===g.length&&(C[0]=0),this._createEncoderBuffer(C)}if(g<128)return this._createEncoderBuffer(g);if(g<256)return this._createEncoderBuffer([0,g]);let C=1;for(let i=g;i>=256;i>>=8)C++;const A=new Array(C);for(let i=A.length-1;i>=0;i--)A[i]=255&g,g>>=8;return 128&A[0]&&A.unshift(0),this._createEncoderBuffer(i.from(A))},s.prototype._encodeBool=function(g){return this._createEncoderBuffer(g?255:0)},s.prototype._use=function(g,I){return"function"==typeof g&&(g=g(I)),g._getEncoder("der").tree},s.prototype._skipDefault=function(g,I,C){const A=this._baseState;let i;if(null===A.default)return!1;const e=g.join();if(void 0===A.defaultBuffer&&(A.defaultBuffer=this._encodeValue(A.default,I,C).join()),e.length!==A.defaultBuffer.length)return!1;for(i=0;i=65&&C<=70?C-55:C>=97&&C<=102?C-87:C-48&15}function s(g,I,C){var A=t(g,C);return C-1>=I&&(A|=t(g,C-1)<<4),A}function c(g,I,C,A){for(var i=0,e=Math.min(g.length,C),l=I;l=49?t-49+10:t>=17?t-17+10:t}return i}e.isBN=function(g){return g instanceof e||null!==g&&"object"==typeof g&&g.constructor.wordSize===e.wordSize&&Array.isArray(g.words)},e.max=function(g,I){return g.cmp(I)>0?g:I},e.min=function(g,I){return g.cmp(I)<0?g:I},e.prototype._init=function(g,I,C){if("number"==typeof g)return this._initNumber(g,I,C);if("object"==typeof g)return this._initArray(g,I,C);"hex"===I&&(I=16),A(I===(0|I)&&I>=2&&I<=36);var i=0;"-"===(g=g.toString().replace(/\s+/g,""))[0]&&(i++,this.negative=1),i=0;i-=3)l=g[i]|g[i-1]<<8|g[i-2]<<16,this.words[e]|=l<>>26-t&67108863,(t+=24)>=26&&(t-=26,e++);else if("le"===C)for(i=0,e=0;i>>26-t&67108863,(t+=24)>=26&&(t-=26,e++);return this.strip()},e.prototype._parseHex=function(g,I,C){this.length=Math.ceil((g.length-I)/6),this.words=new Array(this.length);for(var A=0;A=I;A-=2)i=s(g,I,A)<=18?(e-=18,l+=1,this.words[l]|=i>>>26):e+=8;else for(A=(g.length-I)%2==0?I+1:I;A=18?(e-=18,l+=1,this.words[l]|=i>>>26):e+=8;this.strip()},e.prototype._parseBase=function(g,I,C){this.words=[0],this.length=1;for(var A=0,i=1;i<=67108863;i*=I)A++;A--,i=i/I|0;for(var e=g.length-C,l=e%A,t=Math.min(e,e-l)+C,s=0,d=C;d1&&0===this.words[this.length-1];)this.length--;return this._normSign()},e.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},e.prototype.inspect=function(){return(this.red?""};var d=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],o=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],n=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function a(g){for(var I=new Array(g.bitLength()),C=0;C>>i}return I}function Z(g,I,C){C.negative=I.negative^g.negative;var A=g.length+I.length|0;C.length=A,A=A-1|0;var i=0|g.words[0],e=0|I.words[0],l=i*e,t=67108863&l,s=l/67108864|0;C.words[0]=t;for(var c=1;c>>26,o=67108863&s,n=Math.min(c,I.length-1),a=Math.max(0,c-g.length+1);a<=n;a++){var Z=c-a|0;d+=(l=(i=0|g.words[Z])*(e=0|I.words[a])+o)/67108864|0,o=67108863&l}C.words[c]=0|o,s=0|d}return 0!==s?C.words[c]=0|s:C.length--,C.strip()}e.prototype.toString=function(g,I){var C;if(I=0|I||1,16===(g=g||10)||"hex"===g){C="";for(var i=0,e=0,l=0;l>>24-i&16777215)||l!==this.length-1?d[6-s.length]+s+C:s+C,(i+=2)>=26&&(i-=26,l--)}for(0!==e&&(C=e.toString(16)+C);C.length%I!=0;)C="0"+C;return 0!==this.negative&&(C="-"+C),C}if(g===(0|g)&&g>=2&&g<=36){var c=o[g],a=n[g];C="";var Z=this.clone();for(Z.negative=0;!Z.isZero();){var b=Z.modn(a).toString(g);C=(Z=Z.idivn(a)).isZero()?b+C:d[c-b.length]+b+C}for(this.isZero()&&(C="0"+C);C.length%I!=0;)C="0"+C;return 0!==this.negative&&(C="-"+C),C}A(!1,"Base should be between 2 and 36")},e.prototype.toNumber=function(){var g=this.words[0];return 2===this.length?g+=67108864*this.words[1]:3===this.length&&1===this.words[2]?g+=4503599627370496+67108864*this.words[1]:this.length>2&&A(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-g:g},e.prototype.toJSON=function(){return this.toString(16)},e.prototype.toBuffer=function(g,I){return A(void 0!==l),this.toArrayLike(l,g,I)},e.prototype.toArray=function(g,I){return this.toArrayLike(Array,g,I)},e.prototype.toArrayLike=function(g,I,C){var i=this.byteLength(),e=C||Math.max(1,i);A(i<=e,"byte array longer than desired length"),A(e>0,"Requested array length <= 0"),this.strip();var l,t,s="le"===I,c=new g(e),d=this.clone();if(s){for(t=0;!d.isZero();t++)l=d.andln(255),d.iushrn(8),c[t]=l;for(;t=4096&&(C+=13,I>>>=13),I>=64&&(C+=7,I>>>=7),I>=8&&(C+=4,I>>>=4),I>=2&&(C+=2,I>>>=2),C+I},e.prototype._zeroBits=function(g){if(0===g)return 26;var I=g,C=0;return 8191&I||(C+=13,I>>>=13),127&I||(C+=7,I>>>=7),15&I||(C+=4,I>>>=4),3&I||(C+=2,I>>>=2),1&I||C++,C},e.prototype.bitLength=function(){var g=this.words[this.length-1],I=this._countBits(g);return 26*(this.length-1)+I},e.prototype.zeroBits=function(){if(this.isZero())return 0;for(var g=0,I=0;Ig.length?this.clone().ior(g):g.clone().ior(this)},e.prototype.uor=function(g){return this.length>g.length?this.clone().iuor(g):g.clone().iuor(this)},e.prototype.iuand=function(g){var I;I=this.length>g.length?g:this;for(var C=0;Cg.length?this.clone().iand(g):g.clone().iand(this)},e.prototype.uand=function(g){return this.length>g.length?this.clone().iuand(g):g.clone().iuand(this)},e.prototype.iuxor=function(g){var I,C;this.length>g.length?(I=this,C=g):(I=g,C=this);for(var A=0;Ag.length?this.clone().ixor(g):g.clone().ixor(this)},e.prototype.uxor=function(g){return this.length>g.length?this.clone().iuxor(g):g.clone().iuxor(this)},e.prototype.inotn=function(g){A("number"==typeof g&&g>=0);var I=0|Math.ceil(g/26),C=g%26;this._expand(I),C>0&&I--;for(var i=0;i0&&(this.words[i]=~this.words[i]&67108863>>26-C),this.strip()},e.prototype.notn=function(g){return this.clone().inotn(g)},e.prototype.setn=function(g,I){A("number"==typeof g&&g>=0);var C=g/26|0,i=g%26;return this._expand(C+1),this.words[C]=I?this.words[C]|1<g.length?(C=this,A=g):(C=g,A=this);for(var i=0,e=0;e>>26;for(;0!==i&&e>>26;if(this.length=C.length,0!==i)this.words[this.length]=i,this.length++;else if(C!==this)for(;eg.length?this.clone().iadd(g):g.clone().iadd(this)},e.prototype.isub=function(g){if(0!==g.negative){g.negative=0;var I=this.iadd(g);return g.negative=1,I._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(g),this.negative=1,this._normSign();var C,A,i=this.cmp(g);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(C=this,A=g):(C=g,A=this);for(var e=0,l=0;l>26,this.words[l]=67108863&I;for(;0!==e&&l>26,this.words[l]=67108863&I;if(0===e&&l>>13,a=0|l[1],Z=8191&a,b=a>>>13,r=0|l[2],m=8191&r,h=r>>>13,G=0|l[3],u=8191&G,B=G>>>13,w=0|l[4],W=8191&w,p=w>>>13,V=0|l[5],y=8191&V,X=V>>>13,Y=0|l[6],R=8191&Y,N=Y>>>13,H=0|l[7],K=8191&H,F=H>>>13,M=0|l[8],J=8191&M,S=M>>>13,f=0|l[9],k=8191&f,D=f>>>13,L=0|t[0],z=8191&L,v=L>>>13,T=0|t[1],x=8191&T,U=T>>>13,Q=0|t[2],j=8191&Q,O=Q>>>13,E=0|t[3],P=8191&E,_=E>>>13,q=0|t[4],$=8191&q,gg=q>>>13,Ig=0|t[5],Cg=8191&Ig,Ag=Ig>>>13,ig=0|t[6],eg=8191&ig,lg=ig>>>13,tg=0|t[7],sg=8191&tg,cg=tg>>>13,dg=0|t[8],og=8191&dg,ng=dg>>>13,ag=0|t[9],Zg=8191&ag,bg=ag>>>13;C.negative=g.negative^I.negative,C.length=19;var rg=(c+(A=Math.imul(o,z))|0)+((8191&(i=(i=Math.imul(o,v))+Math.imul(n,z)|0))<<13)|0;c=((e=Math.imul(n,v))+(i>>>13)|0)+(rg>>>26)|0,rg&=67108863,A=Math.imul(Z,z),i=(i=Math.imul(Z,v))+Math.imul(b,z)|0,e=Math.imul(b,v);var mg=(c+(A=A+Math.imul(o,x)|0)|0)+((8191&(i=(i=i+Math.imul(o,U)|0)+Math.imul(n,x)|0))<<13)|0;c=((e=e+Math.imul(n,U)|0)+(i>>>13)|0)+(mg>>>26)|0,mg&=67108863,A=Math.imul(m,z),i=(i=Math.imul(m,v))+Math.imul(h,z)|0,e=Math.imul(h,v),A=A+Math.imul(Z,x)|0,i=(i=i+Math.imul(Z,U)|0)+Math.imul(b,x)|0,e=e+Math.imul(b,U)|0;var hg=(c+(A=A+Math.imul(o,j)|0)|0)+((8191&(i=(i=i+Math.imul(o,O)|0)+Math.imul(n,j)|0))<<13)|0;c=((e=e+Math.imul(n,O)|0)+(i>>>13)|0)+(hg>>>26)|0,hg&=67108863,A=Math.imul(u,z),i=(i=Math.imul(u,v))+Math.imul(B,z)|0,e=Math.imul(B,v),A=A+Math.imul(m,x)|0,i=(i=i+Math.imul(m,U)|0)+Math.imul(h,x)|0,e=e+Math.imul(h,U)|0,A=A+Math.imul(Z,j)|0,i=(i=i+Math.imul(Z,O)|0)+Math.imul(b,j)|0,e=e+Math.imul(b,O)|0;var Gg=(c+(A=A+Math.imul(o,P)|0)|0)+((8191&(i=(i=i+Math.imul(o,_)|0)+Math.imul(n,P)|0))<<13)|0;c=((e=e+Math.imul(n,_)|0)+(i>>>13)|0)+(Gg>>>26)|0,Gg&=67108863,A=Math.imul(W,z),i=(i=Math.imul(W,v))+Math.imul(p,z)|0,e=Math.imul(p,v),A=A+Math.imul(u,x)|0,i=(i=i+Math.imul(u,U)|0)+Math.imul(B,x)|0,e=e+Math.imul(B,U)|0,A=A+Math.imul(m,j)|0,i=(i=i+Math.imul(m,O)|0)+Math.imul(h,j)|0,e=e+Math.imul(h,O)|0,A=A+Math.imul(Z,P)|0,i=(i=i+Math.imul(Z,_)|0)+Math.imul(b,P)|0,e=e+Math.imul(b,_)|0;var ug=(c+(A=A+Math.imul(o,$)|0)|0)+((8191&(i=(i=i+Math.imul(o,gg)|0)+Math.imul(n,$)|0))<<13)|0;c=((e=e+Math.imul(n,gg)|0)+(i>>>13)|0)+(ug>>>26)|0,ug&=67108863,A=Math.imul(y,z),i=(i=Math.imul(y,v))+Math.imul(X,z)|0,e=Math.imul(X,v),A=A+Math.imul(W,x)|0,i=(i=i+Math.imul(W,U)|0)+Math.imul(p,x)|0,e=e+Math.imul(p,U)|0,A=A+Math.imul(u,j)|0,i=(i=i+Math.imul(u,O)|0)+Math.imul(B,j)|0,e=e+Math.imul(B,O)|0,A=A+Math.imul(m,P)|0,i=(i=i+Math.imul(m,_)|0)+Math.imul(h,P)|0,e=e+Math.imul(h,_)|0,A=A+Math.imul(Z,$)|0,i=(i=i+Math.imul(Z,gg)|0)+Math.imul(b,$)|0,e=e+Math.imul(b,gg)|0;var Bg=(c+(A=A+Math.imul(o,Cg)|0)|0)+((8191&(i=(i=i+Math.imul(o,Ag)|0)+Math.imul(n,Cg)|0))<<13)|0;c=((e=e+Math.imul(n,Ag)|0)+(i>>>13)|0)+(Bg>>>26)|0,Bg&=67108863,A=Math.imul(R,z),i=(i=Math.imul(R,v))+Math.imul(N,z)|0,e=Math.imul(N,v),A=A+Math.imul(y,x)|0,i=(i=i+Math.imul(y,U)|0)+Math.imul(X,x)|0,e=e+Math.imul(X,U)|0,A=A+Math.imul(W,j)|0,i=(i=i+Math.imul(W,O)|0)+Math.imul(p,j)|0,e=e+Math.imul(p,O)|0,A=A+Math.imul(u,P)|0,i=(i=i+Math.imul(u,_)|0)+Math.imul(B,P)|0,e=e+Math.imul(B,_)|0,A=A+Math.imul(m,$)|0,i=(i=i+Math.imul(m,gg)|0)+Math.imul(h,$)|0,e=e+Math.imul(h,gg)|0,A=A+Math.imul(Z,Cg)|0,i=(i=i+Math.imul(Z,Ag)|0)+Math.imul(b,Cg)|0,e=e+Math.imul(b,Ag)|0;var wg=(c+(A=A+Math.imul(o,eg)|0)|0)+((8191&(i=(i=i+Math.imul(o,lg)|0)+Math.imul(n,eg)|0))<<13)|0;c=((e=e+Math.imul(n,lg)|0)+(i>>>13)|0)+(wg>>>26)|0,wg&=67108863,A=Math.imul(K,z),i=(i=Math.imul(K,v))+Math.imul(F,z)|0,e=Math.imul(F,v),A=A+Math.imul(R,x)|0,i=(i=i+Math.imul(R,U)|0)+Math.imul(N,x)|0,e=e+Math.imul(N,U)|0,A=A+Math.imul(y,j)|0,i=(i=i+Math.imul(y,O)|0)+Math.imul(X,j)|0,e=e+Math.imul(X,O)|0,A=A+Math.imul(W,P)|0,i=(i=i+Math.imul(W,_)|0)+Math.imul(p,P)|0,e=e+Math.imul(p,_)|0,A=A+Math.imul(u,$)|0,i=(i=i+Math.imul(u,gg)|0)+Math.imul(B,$)|0,e=e+Math.imul(B,gg)|0,A=A+Math.imul(m,Cg)|0,i=(i=i+Math.imul(m,Ag)|0)+Math.imul(h,Cg)|0,e=e+Math.imul(h,Ag)|0,A=A+Math.imul(Z,eg)|0,i=(i=i+Math.imul(Z,lg)|0)+Math.imul(b,eg)|0,e=e+Math.imul(b,lg)|0;var Wg=(c+(A=A+Math.imul(o,sg)|0)|0)+((8191&(i=(i=i+Math.imul(o,cg)|0)+Math.imul(n,sg)|0))<<13)|0;c=((e=e+Math.imul(n,cg)|0)+(i>>>13)|0)+(Wg>>>26)|0,Wg&=67108863,A=Math.imul(J,z),i=(i=Math.imul(J,v))+Math.imul(S,z)|0,e=Math.imul(S,v),A=A+Math.imul(K,x)|0,i=(i=i+Math.imul(K,U)|0)+Math.imul(F,x)|0,e=e+Math.imul(F,U)|0,A=A+Math.imul(R,j)|0,i=(i=i+Math.imul(R,O)|0)+Math.imul(N,j)|0,e=e+Math.imul(N,O)|0,A=A+Math.imul(y,P)|0,i=(i=i+Math.imul(y,_)|0)+Math.imul(X,P)|0,e=e+Math.imul(X,_)|0,A=A+Math.imul(W,$)|0,i=(i=i+Math.imul(W,gg)|0)+Math.imul(p,$)|0,e=e+Math.imul(p,gg)|0,A=A+Math.imul(u,Cg)|0,i=(i=i+Math.imul(u,Ag)|0)+Math.imul(B,Cg)|0,e=e+Math.imul(B,Ag)|0,A=A+Math.imul(m,eg)|0,i=(i=i+Math.imul(m,lg)|0)+Math.imul(h,eg)|0,e=e+Math.imul(h,lg)|0,A=A+Math.imul(Z,sg)|0,i=(i=i+Math.imul(Z,cg)|0)+Math.imul(b,sg)|0,e=e+Math.imul(b,cg)|0;var pg=(c+(A=A+Math.imul(o,og)|0)|0)+((8191&(i=(i=i+Math.imul(o,ng)|0)+Math.imul(n,og)|0))<<13)|0;c=((e=e+Math.imul(n,ng)|0)+(i>>>13)|0)+(pg>>>26)|0,pg&=67108863,A=Math.imul(k,z),i=(i=Math.imul(k,v))+Math.imul(D,z)|0,e=Math.imul(D,v),A=A+Math.imul(J,x)|0,i=(i=i+Math.imul(J,U)|0)+Math.imul(S,x)|0,e=e+Math.imul(S,U)|0,A=A+Math.imul(K,j)|0,i=(i=i+Math.imul(K,O)|0)+Math.imul(F,j)|0,e=e+Math.imul(F,O)|0,A=A+Math.imul(R,P)|0,i=(i=i+Math.imul(R,_)|0)+Math.imul(N,P)|0,e=e+Math.imul(N,_)|0,A=A+Math.imul(y,$)|0,i=(i=i+Math.imul(y,gg)|0)+Math.imul(X,$)|0,e=e+Math.imul(X,gg)|0,A=A+Math.imul(W,Cg)|0,i=(i=i+Math.imul(W,Ag)|0)+Math.imul(p,Cg)|0,e=e+Math.imul(p,Ag)|0,A=A+Math.imul(u,eg)|0,i=(i=i+Math.imul(u,lg)|0)+Math.imul(B,eg)|0,e=e+Math.imul(B,lg)|0,A=A+Math.imul(m,sg)|0,i=(i=i+Math.imul(m,cg)|0)+Math.imul(h,sg)|0,e=e+Math.imul(h,cg)|0,A=A+Math.imul(Z,og)|0,i=(i=i+Math.imul(Z,ng)|0)+Math.imul(b,og)|0,e=e+Math.imul(b,ng)|0;var Vg=(c+(A=A+Math.imul(o,Zg)|0)|0)+((8191&(i=(i=i+Math.imul(o,bg)|0)+Math.imul(n,Zg)|0))<<13)|0;c=((e=e+Math.imul(n,bg)|0)+(i>>>13)|0)+(Vg>>>26)|0,Vg&=67108863,A=Math.imul(k,x),i=(i=Math.imul(k,U))+Math.imul(D,x)|0,e=Math.imul(D,U),A=A+Math.imul(J,j)|0,i=(i=i+Math.imul(J,O)|0)+Math.imul(S,j)|0,e=e+Math.imul(S,O)|0,A=A+Math.imul(K,P)|0,i=(i=i+Math.imul(K,_)|0)+Math.imul(F,P)|0,e=e+Math.imul(F,_)|0,A=A+Math.imul(R,$)|0,i=(i=i+Math.imul(R,gg)|0)+Math.imul(N,$)|0,e=e+Math.imul(N,gg)|0,A=A+Math.imul(y,Cg)|0,i=(i=i+Math.imul(y,Ag)|0)+Math.imul(X,Cg)|0,e=e+Math.imul(X,Ag)|0,A=A+Math.imul(W,eg)|0,i=(i=i+Math.imul(W,lg)|0)+Math.imul(p,eg)|0,e=e+Math.imul(p,lg)|0,A=A+Math.imul(u,sg)|0,i=(i=i+Math.imul(u,cg)|0)+Math.imul(B,sg)|0,e=e+Math.imul(B,cg)|0,A=A+Math.imul(m,og)|0,i=(i=i+Math.imul(m,ng)|0)+Math.imul(h,og)|0,e=e+Math.imul(h,ng)|0;var yg=(c+(A=A+Math.imul(Z,Zg)|0)|0)+((8191&(i=(i=i+Math.imul(Z,bg)|0)+Math.imul(b,Zg)|0))<<13)|0;c=((e=e+Math.imul(b,bg)|0)+(i>>>13)|0)+(yg>>>26)|0,yg&=67108863,A=Math.imul(k,j),i=(i=Math.imul(k,O))+Math.imul(D,j)|0,e=Math.imul(D,O),A=A+Math.imul(J,P)|0,i=(i=i+Math.imul(J,_)|0)+Math.imul(S,P)|0,e=e+Math.imul(S,_)|0,A=A+Math.imul(K,$)|0,i=(i=i+Math.imul(K,gg)|0)+Math.imul(F,$)|0,e=e+Math.imul(F,gg)|0,A=A+Math.imul(R,Cg)|0,i=(i=i+Math.imul(R,Ag)|0)+Math.imul(N,Cg)|0,e=e+Math.imul(N,Ag)|0,A=A+Math.imul(y,eg)|0,i=(i=i+Math.imul(y,lg)|0)+Math.imul(X,eg)|0,e=e+Math.imul(X,lg)|0,A=A+Math.imul(W,sg)|0,i=(i=i+Math.imul(W,cg)|0)+Math.imul(p,sg)|0,e=e+Math.imul(p,cg)|0,A=A+Math.imul(u,og)|0,i=(i=i+Math.imul(u,ng)|0)+Math.imul(B,og)|0,e=e+Math.imul(B,ng)|0;var Xg=(c+(A=A+Math.imul(m,Zg)|0)|0)+((8191&(i=(i=i+Math.imul(m,bg)|0)+Math.imul(h,Zg)|0))<<13)|0;c=((e=e+Math.imul(h,bg)|0)+(i>>>13)|0)+(Xg>>>26)|0,Xg&=67108863,A=Math.imul(k,P),i=(i=Math.imul(k,_))+Math.imul(D,P)|0,e=Math.imul(D,_),A=A+Math.imul(J,$)|0,i=(i=i+Math.imul(J,gg)|0)+Math.imul(S,$)|0,e=e+Math.imul(S,gg)|0,A=A+Math.imul(K,Cg)|0,i=(i=i+Math.imul(K,Ag)|0)+Math.imul(F,Cg)|0,e=e+Math.imul(F,Ag)|0,A=A+Math.imul(R,eg)|0,i=(i=i+Math.imul(R,lg)|0)+Math.imul(N,eg)|0,e=e+Math.imul(N,lg)|0,A=A+Math.imul(y,sg)|0,i=(i=i+Math.imul(y,cg)|0)+Math.imul(X,sg)|0,e=e+Math.imul(X,cg)|0,A=A+Math.imul(W,og)|0,i=(i=i+Math.imul(W,ng)|0)+Math.imul(p,og)|0,e=e+Math.imul(p,ng)|0;var Yg=(c+(A=A+Math.imul(u,Zg)|0)|0)+((8191&(i=(i=i+Math.imul(u,bg)|0)+Math.imul(B,Zg)|0))<<13)|0;c=((e=e+Math.imul(B,bg)|0)+(i>>>13)|0)+(Yg>>>26)|0,Yg&=67108863,A=Math.imul(k,$),i=(i=Math.imul(k,gg))+Math.imul(D,$)|0,e=Math.imul(D,gg),A=A+Math.imul(J,Cg)|0,i=(i=i+Math.imul(J,Ag)|0)+Math.imul(S,Cg)|0,e=e+Math.imul(S,Ag)|0,A=A+Math.imul(K,eg)|0,i=(i=i+Math.imul(K,lg)|0)+Math.imul(F,eg)|0,e=e+Math.imul(F,lg)|0,A=A+Math.imul(R,sg)|0,i=(i=i+Math.imul(R,cg)|0)+Math.imul(N,sg)|0,e=e+Math.imul(N,cg)|0,A=A+Math.imul(y,og)|0,i=(i=i+Math.imul(y,ng)|0)+Math.imul(X,og)|0,e=e+Math.imul(X,ng)|0;var Rg=(c+(A=A+Math.imul(W,Zg)|0)|0)+((8191&(i=(i=i+Math.imul(W,bg)|0)+Math.imul(p,Zg)|0))<<13)|0;c=((e=e+Math.imul(p,bg)|0)+(i>>>13)|0)+(Rg>>>26)|0,Rg&=67108863,A=Math.imul(k,Cg),i=(i=Math.imul(k,Ag))+Math.imul(D,Cg)|0,e=Math.imul(D,Ag),A=A+Math.imul(J,eg)|0,i=(i=i+Math.imul(J,lg)|0)+Math.imul(S,eg)|0,e=e+Math.imul(S,lg)|0,A=A+Math.imul(K,sg)|0,i=(i=i+Math.imul(K,cg)|0)+Math.imul(F,sg)|0,e=e+Math.imul(F,cg)|0,A=A+Math.imul(R,og)|0,i=(i=i+Math.imul(R,ng)|0)+Math.imul(N,og)|0,e=e+Math.imul(N,ng)|0;var Ng=(c+(A=A+Math.imul(y,Zg)|0)|0)+((8191&(i=(i=i+Math.imul(y,bg)|0)+Math.imul(X,Zg)|0))<<13)|0;c=((e=e+Math.imul(X,bg)|0)+(i>>>13)|0)+(Ng>>>26)|0,Ng&=67108863,A=Math.imul(k,eg),i=(i=Math.imul(k,lg))+Math.imul(D,eg)|0,e=Math.imul(D,lg),A=A+Math.imul(J,sg)|0,i=(i=i+Math.imul(J,cg)|0)+Math.imul(S,sg)|0,e=e+Math.imul(S,cg)|0,A=A+Math.imul(K,og)|0,i=(i=i+Math.imul(K,ng)|0)+Math.imul(F,og)|0,e=e+Math.imul(F,ng)|0;var Hg=(c+(A=A+Math.imul(R,Zg)|0)|0)+((8191&(i=(i=i+Math.imul(R,bg)|0)+Math.imul(N,Zg)|0))<<13)|0;c=((e=e+Math.imul(N,bg)|0)+(i>>>13)|0)+(Hg>>>26)|0,Hg&=67108863,A=Math.imul(k,sg),i=(i=Math.imul(k,cg))+Math.imul(D,sg)|0,e=Math.imul(D,cg),A=A+Math.imul(J,og)|0,i=(i=i+Math.imul(J,ng)|0)+Math.imul(S,og)|0,e=e+Math.imul(S,ng)|0;var Kg=(c+(A=A+Math.imul(K,Zg)|0)|0)+((8191&(i=(i=i+Math.imul(K,bg)|0)+Math.imul(F,Zg)|0))<<13)|0;c=((e=e+Math.imul(F,bg)|0)+(i>>>13)|0)+(Kg>>>26)|0,Kg&=67108863,A=Math.imul(k,og),i=(i=Math.imul(k,ng))+Math.imul(D,og)|0,e=Math.imul(D,ng);var Fg=(c+(A=A+Math.imul(J,Zg)|0)|0)+((8191&(i=(i=i+Math.imul(J,bg)|0)+Math.imul(S,Zg)|0))<<13)|0;c=((e=e+Math.imul(S,bg)|0)+(i>>>13)|0)+(Fg>>>26)|0,Fg&=67108863;var Mg=(c+(A=Math.imul(k,Zg))|0)+((8191&(i=(i=Math.imul(k,bg))+Math.imul(D,Zg)|0))<<13)|0;return c=((e=Math.imul(D,bg))+(i>>>13)|0)+(Mg>>>26)|0,Mg&=67108863,s[0]=rg,s[1]=mg,s[2]=hg,s[3]=Gg,s[4]=ug,s[5]=Bg,s[6]=wg,s[7]=Wg,s[8]=pg,s[9]=Vg,s[10]=yg,s[11]=Xg,s[12]=Yg,s[13]=Rg,s[14]=Ng,s[15]=Hg,s[16]=Kg,s[17]=Fg,s[18]=Mg,0!==c&&(s[19]=c,C.length++),C};function r(g,I,C){C.negative=I.negative^g.negative,C.length=g.length+I.length;for(var A=0,i=0,e=0;e>>26)|0)>>>26,l&=67108863}C.words[e]=t,A=l,l=i}return 0!==A?C.words[e]=A:C.length--,C.strip()}function m(g,I,C){return(new h).mulp(g,I,C)}function h(g,I){this.x=g,this.y=I}Math.imul||(b=Z),e.prototype.mulTo=function(g,I){var C=this.length+g.length;return 10===this.length&&10===g.length?b(this,g,I):C<63?Z(this,g,I):C<1024?r(this,g,I):m(this,g,I)},h.prototype.makeRBT=function(g){for(var I=new Array(g),C=e.prototype._countBits(g)-1,A=0;A>=1;return A},h.prototype.permute=function(g,I,C,A,i,e){for(var l=0;l>>=1)i++;return 1<>>=13,C[2*l+1]=8191&e,e>>>=13;for(l=2*I;l>=26,I+=i/67108864|0,I+=e>>>26,this.words[C]=67108863&e}return 0!==I&&(this.words[C]=I,this.length++),this},e.prototype.muln=function(g){return this.clone().imuln(g)},e.prototype.sqr=function(){return this.mul(this)},e.prototype.isqr=function(){return this.imul(this.clone())},e.prototype.pow=function(g){var I=a(g);if(0===I.length)return new e(1);for(var C=this,A=0;A=0);var I,C=g%26,i=(g-C)/26,e=67108863>>>26-C<<26-C;if(0!==C){var l=0;for(I=0;I>>26-C}l&&(this.words[I]=l,this.length++)}if(0!==i){for(I=this.length-1;I>=0;I--)this.words[I+i]=this.words[I];for(I=0;I=0),i=I?(I-I%26)/26:0;var e=g%26,l=Math.min((g-e)/26,this.length),t=67108863^67108863>>>e<l)for(this.length-=l,c=0;c=0&&(0!==d||c>=i);c--){var o=0|this.words[c];this.words[c]=d<<26-e|o>>>e,d=o&t}return s&&0!==d&&(s.words[s.length++]=d),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},e.prototype.ishrn=function(g,I,C){return A(0===this.negative),this.iushrn(g,I,C)},e.prototype.shln=function(g){return this.clone().ishln(g)},e.prototype.ushln=function(g){return this.clone().iushln(g)},e.prototype.shrn=function(g){return this.clone().ishrn(g)},e.prototype.ushrn=function(g){return this.clone().iushrn(g)},e.prototype.testn=function(g){A("number"==typeof g&&g>=0);var I=g%26,C=(g-I)/26,i=1<=0);var I=g%26,C=(g-I)/26;if(A(0===this.negative,"imaskn works only with positive numbers"),this.length<=C)return this;if(0!==I&&C++,this.length=Math.min(C,this.length),0!==I){var i=67108863^67108863>>>I<=67108864;I++)this.words[I]-=67108864,I===this.length-1?this.words[I+1]=1:this.words[I+1]++;return this.length=Math.max(this.length,I+1),this},e.prototype.isubn=function(g){if(A("number"==typeof g),A(g<67108864),g<0)return this.iaddn(-g);if(0!==this.negative)return this.negative=0,this.iaddn(g),this.negative=1,this;if(this.words[0]-=g,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var I=0;I>26)-(s/67108864|0),this.words[i+C]=67108863&e}for(;i>26,this.words[i+C]=67108863&e;if(0===t)return this.strip();for(A(-1===t),t=0,i=0;i>26,this.words[i]=67108863&e;return this.negative=1,this.strip()},e.prototype._wordDiv=function(g,I){var C=this.length-g.length,A=this.clone(),i=g,l=0|i.words[i.length-1];0!=(C=26-this._countBits(l))&&(i=i.ushln(C),A.iushln(C),l=0|i.words[i.length-1]);var t,s=A.length-i.length;if("mod"!==I){(t=new e(null)).length=s+1,t.words=new Array(t.length);for(var c=0;c=0;o--){var n=67108864*(0|A.words[i.length+o])+(0|A.words[i.length+o-1]);for(n=Math.min(n/l|0,67108863),A._ishlnsubmul(i,n,o);0!==A.negative;)n--,A.negative=0,A._ishlnsubmul(i,1,o),A.isZero()||(A.negative^=1);t&&(t.words[o]=n)}return t&&t.strip(),A.strip(),"div"!==I&&0!==C&&A.iushrn(C),{div:t||null,mod:A}},e.prototype.divmod=function(g,I,C){return A(!g.isZero()),this.isZero()?{div:new e(0),mod:new e(0)}:0!==this.negative&&0===g.negative?(t=this.neg().divmod(g,I),"mod"!==I&&(i=t.div.neg()),"div"!==I&&(l=t.mod.neg(),C&&0!==l.negative&&l.iadd(g)),{div:i,mod:l}):0===this.negative&&0!==g.negative?(t=this.divmod(g.neg(),I),"mod"!==I&&(i=t.div.neg()),{div:i,mod:t.mod}):this.negative&g.negative?(t=this.neg().divmod(g.neg(),I),"div"!==I&&(l=t.mod.neg(),C&&0!==l.negative&&l.isub(g)),{div:t.div,mod:l}):g.length>this.length||this.cmp(g)<0?{div:new e(0),mod:this}:1===g.length?"div"===I?{div:this.divn(g.words[0]),mod:null}:"mod"===I?{div:null,mod:new e(this.modn(g.words[0]))}:{div:this.divn(g.words[0]),mod:new e(this.modn(g.words[0]))}:this._wordDiv(g,I);var i,l,t},e.prototype.div=function(g){return this.divmod(g,"div",!1).div},e.prototype.mod=function(g){return this.divmod(g,"mod",!1).mod},e.prototype.umod=function(g){return this.divmod(g,"mod",!0).mod},e.prototype.divRound=function(g){var I=this.divmod(g);if(I.mod.isZero())return I.div;var C=0!==I.div.negative?I.mod.isub(g):I.mod,A=g.ushrn(1),i=g.andln(1),e=C.cmp(A);return e<0||1===i&&0===e?I.div:0!==I.div.negative?I.div.isubn(1):I.div.iaddn(1)},e.prototype.modn=function(g){A(g<=67108863);for(var I=(1<<26)%g,C=0,i=this.length-1;i>=0;i--)C=(I*C+(0|this.words[i]))%g;return C},e.prototype.idivn=function(g){A(g<=67108863);for(var I=0,C=this.length-1;C>=0;C--){var i=(0|this.words[C])+67108864*I;this.words[C]=i/g|0,I=i%g}return this.strip()},e.prototype.divn=function(g){return this.clone().idivn(g)},e.prototype.egcd=function(g){A(0===g.negative),A(!g.isZero());var I=this,C=g.clone();I=0!==I.negative?I.umod(g):I.clone();for(var i=new e(1),l=new e(0),t=new e(0),s=new e(1),c=0;I.isEven()&&C.isEven();)I.iushrn(1),C.iushrn(1),++c;for(var d=C.clone(),o=I.clone();!I.isZero();){for(var n=0,a=1;!(I.words[0]&a)&&n<26;++n,a<<=1);if(n>0)for(I.iushrn(n);n-- >0;)(i.isOdd()||l.isOdd())&&(i.iadd(d),l.isub(o)),i.iushrn(1),l.iushrn(1);for(var Z=0,b=1;!(C.words[0]&b)&&Z<26;++Z,b<<=1);if(Z>0)for(C.iushrn(Z);Z-- >0;)(t.isOdd()||s.isOdd())&&(t.iadd(d),s.isub(o)),t.iushrn(1),s.iushrn(1);I.cmp(C)>=0?(I.isub(C),i.isub(t),l.isub(s)):(C.isub(I),t.isub(i),s.isub(l))}return{a:t,b:s,gcd:C.iushln(c)}},e.prototype._invmp=function(g){A(0===g.negative),A(!g.isZero());var I=this,C=g.clone();I=0!==I.negative?I.umod(g):I.clone();for(var i,l=new e(1),t=new e(0),s=C.clone();I.cmpn(1)>0&&C.cmpn(1)>0;){for(var c=0,d=1;!(I.words[0]&d)&&c<26;++c,d<<=1);if(c>0)for(I.iushrn(c);c-- >0;)l.isOdd()&&l.iadd(s),l.iushrn(1);for(var o=0,n=1;!(C.words[0]&n)&&o<26;++o,n<<=1);if(o>0)for(C.iushrn(o);o-- >0;)t.isOdd()&&t.iadd(s),t.iushrn(1);I.cmp(C)>=0?(I.isub(C),l.isub(t)):(C.isub(I),t.isub(l))}return(i=0===I.cmpn(1)?l:t).cmpn(0)<0&&i.iadd(g),i},e.prototype.gcd=function(g){if(this.isZero())return g.abs();if(g.isZero())return this.abs();var I=this.clone(),C=g.clone();I.negative=0,C.negative=0;for(var A=0;I.isEven()&&C.isEven();A++)I.iushrn(1),C.iushrn(1);for(;;){for(;I.isEven();)I.iushrn(1);for(;C.isEven();)C.iushrn(1);var i=I.cmp(C);if(i<0){var e=I;I=C,C=e}else if(0===i||0===C.cmpn(1))break;I.isub(C)}return C.iushln(A)},e.prototype.invm=function(g){return this.egcd(g).a.umod(g)},e.prototype.isEven=function(){return!(1&this.words[0])},e.prototype.isOdd=function(){return!(1&~this.words[0])},e.prototype.andln=function(g){return this.words[0]&g},e.prototype.bincn=function(g){A("number"==typeof g);var I=g%26,C=(g-I)/26,i=1<>>26,t&=67108863,this.words[l]=t}return 0!==e&&(this.words[l]=e,this.length++),this},e.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},e.prototype.cmpn=function(g){var I,C=g<0;if(0!==this.negative&&!C)return-1;if(0===this.negative&&C)return 1;if(this.strip(),this.length>1)I=1;else{C&&(g=-g),A(g<=67108863,"Number is too big");var i=0|this.words[0];I=i===g?0:ig.length)return 1;if(this.length=0;C--){var A=0|this.words[C],i=0|g.words[C];if(A!==i){Ai&&(I=1);break}}return I},e.prototype.gtn=function(g){return 1===this.cmpn(g)},e.prototype.gt=function(g){return 1===this.cmp(g)},e.prototype.gten=function(g){return this.cmpn(g)>=0},e.prototype.gte=function(g){return this.cmp(g)>=0},e.prototype.ltn=function(g){return-1===this.cmpn(g)},e.prototype.lt=function(g){return-1===this.cmp(g)},e.prototype.lten=function(g){return this.cmpn(g)<=0},e.prototype.lte=function(g){return this.cmp(g)<=0},e.prototype.eqn=function(g){return 0===this.cmpn(g)},e.prototype.eq=function(g){return 0===this.cmp(g)},e.red=function(g){return new V(g)},e.prototype.toRed=function(g){return A(!this.red,"Already a number in reduction context"),A(0===this.negative,"red works only with positives"),g.convertTo(this)._forceRed(g)},e.prototype.fromRed=function(){return A(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},e.prototype._forceRed=function(g){return this.red=g,this},e.prototype.forceRed=function(g){return A(!this.red,"Already a number in reduction context"),this._forceRed(g)},e.prototype.redAdd=function(g){return A(this.red,"redAdd works only with red numbers"),this.red.add(this,g)},e.prototype.redIAdd=function(g){return A(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,g)},e.prototype.redSub=function(g){return A(this.red,"redSub works only with red numbers"),this.red.sub(this,g)},e.prototype.redISub=function(g){return A(this.red,"redISub works only with red numbers"),this.red.isub(this,g)},e.prototype.redShl=function(g){return A(this.red,"redShl works only with red numbers"),this.red.shl(this,g)},e.prototype.redMul=function(g){return A(this.red,"redMul works only with red numbers"),this.red._verify2(this,g),this.red.mul(this,g)},e.prototype.redIMul=function(g){return A(this.red,"redMul works only with red numbers"),this.red._verify2(this,g),this.red.imul(this,g)},e.prototype.redSqr=function(){return A(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},e.prototype.redISqr=function(){return A(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},e.prototype.redSqrt=function(){return A(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},e.prototype.redInvm=function(){return A(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},e.prototype.redNeg=function(){return A(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},e.prototype.redPow=function(g){return A(this.red&&!g.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,g)};var G={k256:null,p224:null,p192:null,p25519:null};function u(g,I){this.name=g,this.p=new e(I,16),this.n=this.p.bitLength(),this.k=new e(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function B(){u.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function w(){u.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function W(){u.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function p(){u.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function V(g){if("string"==typeof g){var I=e._prime(g);this.m=I.p,this.prime=I}else A(g.gtn(1),"modulus must be greater than 1"),this.m=g,this.prime=null}function y(g){V.call(this,g),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new e(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}u.prototype._tmp=function(){var g=new e(null);return g.words=new Array(Math.ceil(this.n/13)),g},u.prototype.ireduce=function(g){var I,C=g;do{this.split(C,this.tmp),I=(C=(C=this.imulK(C)).iadd(this.tmp)).bitLength()}while(I>this.n);var A=I0?C.isub(this.p):void 0!==C.strip?C.strip():C._strip(),C},u.prototype.split=function(g,I){g.iushrn(this.n,0,I)},u.prototype.imulK=function(g){return g.imul(this.k)},i(B,u),B.prototype.split=function(g,I){for(var C=4194303,A=Math.min(g.length,9),i=0;i>>22,e=l}e>>>=22,g.words[i-10]=e,0===e&&g.length>10?g.length-=10:g.length-=9},B.prototype.imulK=function(g){g.words[g.length]=0,g.words[g.length+1]=0,g.length+=2;for(var I=0,C=0;C>>=26,g.words[C]=i,I=A}return 0!==I&&(g.words[g.length++]=I),g},e._prime=function(g){if(G[g])return G[g];var I;if("k256"===g)I=new B;else if("p224"===g)I=new w;else if("p192"===g)I=new W;else{if("p25519"!==g)throw new Error("Unknown prime "+g);I=new p}return G[g]=I,I},V.prototype._verify1=function(g){A(0===g.negative,"red works only with positives"),A(g.red,"red works only with red numbers")},V.prototype._verify2=function(g,I){A(!(g.negative|I.negative),"red works only with positives"),A(g.red&&g.red===I.red,"red works only with red numbers")},V.prototype.imod=function(g){return this.prime?this.prime.ireduce(g)._forceRed(this):g.umod(this.m)._forceRed(this)},V.prototype.neg=function(g){return g.isZero()?g.clone():this.m.sub(g)._forceRed(this)},V.prototype.add=function(g,I){this._verify2(g,I);var C=g.add(I);return C.cmp(this.m)>=0&&C.isub(this.m),C._forceRed(this)},V.prototype.iadd=function(g,I){this._verify2(g,I);var C=g.iadd(I);return C.cmp(this.m)>=0&&C.isub(this.m),C},V.prototype.sub=function(g,I){this._verify2(g,I);var C=g.sub(I);return C.cmpn(0)<0&&C.iadd(this.m),C._forceRed(this)},V.prototype.isub=function(g,I){this._verify2(g,I);var C=g.isub(I);return C.cmpn(0)<0&&C.iadd(this.m),C},V.prototype.shl=function(g,I){return this._verify1(g),this.imod(g.ushln(I))},V.prototype.imul=function(g,I){return this._verify2(g,I),this.imod(g.imul(I))},V.prototype.mul=function(g,I){return this._verify2(g,I),this.imod(g.mul(I))},V.prototype.isqr=function(g){return this.imul(g,g.clone())},V.prototype.sqr=function(g){return this.mul(g,g)},V.prototype.sqrt=function(g){if(g.isZero())return g.clone();var I=this.m.andln(3);if(A(I%2==1),3===I){var C=this.m.add(new e(1)).iushrn(2);return this.pow(g,C)}for(var i=this.m.subn(1),l=0;!i.isZero()&&0===i.andln(1);)l++,i.iushrn(1);A(!i.isZero());var t=new e(1).toRed(this),s=t.redNeg(),c=this.m.subn(1).iushrn(1),d=this.m.bitLength();for(d=new e(2*d*d).toRed(this);0!==this.pow(d,c).cmp(s);)d.redIAdd(s);for(var o=this.pow(d,i),n=this.pow(g,i.addn(1).iushrn(1)),a=this.pow(g,i),Z=l;0!==a.cmp(t);){for(var b=a,r=0;0!==b.cmp(t);r++)b=b.redSqr();A(r=0;i--){for(var d=I.words[i],o=c-1;o>=0;o--){var n=d>>o&1;l!==A[0]&&(l=this.sqr(l)),0!==n||0!==t?(t<<=1,t|=n,(++s===C||0===i&&0===o)&&(l=this.mul(l,A[t]),s=0,t=0)):s=0}c=26}return l},V.prototype.convertTo=function(g){var I=g.umod(this.m);return I===g?I.clone():I},V.prototype.convertFrom=function(g){var I=g.clone();return I.red=null,I},e.mont=function(g){return new y(g)},i(y,V),y.prototype.convertTo=function(g){return this.imod(g.ushln(this.shift))},y.prototype.convertFrom=function(g){var I=this.imod(g.mul(this.rinv));return I.red=null,I},y.prototype.imul=function(g,I){if(g.isZero()||I.isZero())return g.words[0]=0,g.length=1,g;var C=g.imul(I),A=C.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=C.isub(A).iushrn(this.shift),e=i;return i.cmp(this.m)>=0?e=i.isub(this.m):i.cmpn(0)<0&&(e=i.iadd(this.m)),e._forceRed(this)},y.prototype.mul=function(g,I){if(g.isZero()||I.isZero())return new e(0)._forceRed(this);var C=g.mul(I),A=C.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=C.isub(A).iushrn(this.shift),l=i;return i.cmp(this.m)>=0?l=i.isub(this.m):i.cmpn(0)<0&&(l=i.iadd(this.m)),l._forceRed(this)},y.prototype.invm=function(g){return this.imod(g._invmp(this.m).mul(this.r2))._forceRed(this)}}(void 0===I||I,void 0)},{buffer:188}],185:[function(g,I,C){C.byteLength=d,C.toByteArray=n,C.fromByteArray=b;for(var A=[],i=[],e="undefined"!=typeof Uint8Array?Uint8Array:Array,l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0,s=l.length;t0)throw new Error("Invalid string. Length must be a multiple of 4");var C=g.indexOf("=");return-1===C&&(C=I),[C,C===I?0:4-C%4]}function d(g){var I=c(g),C=I[0],A=I[1];return 3*(C+A)/4-A}function o(g,I,C){return 3*(I+C)/4-C}function n(g){var I,C,A=c(g),l=A[0],t=A[1],s=new e(o(g,l,t)),d=0,n=t>0?l-4:l;for(C=0;C>16&255,s[d++]=I>>8&255,s[d++]=255&I;return 2===t&&(I=i[g.charCodeAt(C)]<<2|i[g.charCodeAt(C+1)]>>4,s[d++]=255&I),1===t&&(I=i[g.charCodeAt(C)]<<10|i[g.charCodeAt(C+1)]<<4|i[g.charCodeAt(C+2)]>>2,s[d++]=I>>8&255,s[d++]=255&I),s}function a(g){return A[g>>18&63]+A[g>>12&63]+A[g>>6&63]+A[63&g]}function Z(g,I,C){for(var A,i=[],e=I;es?s:t+l));return 1===i?(I=g[C-1],e.push(A[I>>2]+A[I<<4&63]+"==")):2===i&&(I=(g[C-2]<<8)+g[C-1],e.push(A[I>>10]+A[I>>4&63]+A[I<<2&63]+"=")),e.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},{}],186:[function(g,I,C){!function(I,C){function A(g,I){if(!g)throw new Error(I||"Assertion failed")}function i(g,I){g.super_=I;var C=function(){};C.prototype=I.prototype,g.prototype=new C,g.prototype.constructor=g}function e(g,I,C){if(e.isBN(g))return g;this.negative=0,this.words=null,this.length=0,this.red=null,null!==g&&("le"!==I&&"be"!==I||(C=I,I=10),this._init(g||0,I||10,C||"be"))}var l;"object"==typeof I?I.exports=e:C.BN=e,e.BN=e,e.wordSize=26;try{l="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:g("buffer").Buffer}catch(R){}function t(g,I){var C=g.charCodeAt(I);return C>=48&&C<=57?C-48:C>=65&&C<=70?C-55:C>=97&&C<=102?C-87:void A(!1,"Invalid character in "+g)}function s(g,I,C){var A=t(g,C);return C-1>=I&&(A|=t(g,C-1)<<4),A}function c(g,I,C,i){for(var e=0,l=0,t=Math.min(g.length,C),s=I;s=49?c-49+10:c>=17?c-17+10:c,A(c>=0&&l0?g:I},e.min=function(g,I){return g.cmp(I)<0?g:I},e.prototype._init=function(g,I,C){if("number"==typeof g)return this._initNumber(g,I,C);if("object"==typeof g)return this._initArray(g,I,C);"hex"===I&&(I=16),A(I===(0|I)&&I>=2&&I<=36);var i=0;"-"===(g=g.toString().replace(/\s+/g,""))[0]&&(i++,this.negative=1),i=0;i-=3)l=g[i]|g[i-1]<<8|g[i-2]<<16,this.words[e]|=l<>>26-t&67108863,(t+=24)>=26&&(t-=26,e++);else if("le"===C)for(i=0,e=0;i>>26-t&67108863,(t+=24)>=26&&(t-=26,e++);return this._strip()},e.prototype._parseHex=function(g,I,C){this.length=Math.ceil((g.length-I)/6),this.words=new Array(this.length);for(var A=0;A=I;A-=2)i=s(g,I,A)<=18?(e-=18,l+=1,this.words[l]|=i>>>26):e+=8;else for(A=(g.length-I)%2==0?I+1:I;A=18?(e-=18,l+=1,this.words[l]|=i>>>26):e+=8;this._strip()},e.prototype._parseBase=function(g,I,C){this.words=[0],this.length=1;for(var A=0,i=1;i<=67108863;i*=I)A++;A--,i=i/I|0;for(var e=g.length-C,l=e%A,t=Math.min(e,e-l)+C,s=0,d=C;d1&&0===this.words[this.length-1];)this.length--;return this._normSign()},e.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},"undefined"!=typeof Symbol&&"function"==typeof Symbol.for)try{e.prototype[Symbol.for("nodejs.util.inspect.custom")]=o}catch(R){e.prototype.inspect=o}else e.prototype.inspect=o;function o(){return(this.red?""}var n=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],a=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],Z=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];e.prototype.toString=function(g,I){var C;if(I=0|I||1,16===(g=g||10)||"hex"===g){C="";for(var i=0,e=0,l=0;l>>24-i&16777215,(i+=2)>=26&&(i-=26,l--),C=0!==e||l!==this.length-1?n[6-s.length]+s+C:s+C}for(0!==e&&(C=e.toString(16)+C);C.length%I!=0;)C="0"+C;return 0!==this.negative&&(C="-"+C),C}if(g===(0|g)&&g>=2&&g<=36){var c=a[g],d=Z[g];C="";var o=this.clone();for(o.negative=0;!o.isZero();){var b=o.modrn(d).toString(g);C=(o=o.idivn(d)).isZero()?b+C:n[c-b.length]+b+C}for(this.isZero()&&(C="0"+C);C.length%I!=0;)C="0"+C;return 0!==this.negative&&(C="-"+C),C}A(!1,"Base should be between 2 and 36")},e.prototype.toNumber=function(){var g=this.words[0];return 2===this.length?g+=67108864*this.words[1]:3===this.length&&1===this.words[2]?g+=4503599627370496+67108864*this.words[1]:this.length>2&&A(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-g:g},e.prototype.toJSON=function(){return this.toString(16,2)},l&&(e.prototype.toBuffer=function(g,I){return this.toArrayLike(l,g,I)}),e.prototype.toArray=function(g,I){return this.toArrayLike(Array,g,I)};var b=function(g,I){return g.allocUnsafe?g.allocUnsafe(I):new g(I)};function r(g){for(var I=new Array(g.bitLength()),C=0;C>>i&1}return I}function m(g,I,C){C.negative=I.negative^g.negative;var A=g.length+I.length|0;C.length=A,A=A-1|0;var i=0|g.words[0],e=0|I.words[0],l=i*e,t=67108863&l,s=l/67108864|0;C.words[0]=t;for(var c=1;c>>26,o=67108863&s,n=Math.min(c,I.length-1),a=Math.max(0,c-g.length+1);a<=n;a++){var Z=c-a|0;d+=(l=(i=0|g.words[Z])*(e=0|I.words[a])+o)/67108864|0,o=67108863&l}C.words[c]=0|o,s=0|d}return 0!==s?C.words[c]=0|s:C.length--,C._strip()}e.prototype.toArrayLike=function(g,I,C){this._strip();var i=this.byteLength(),e=C||Math.max(1,i);A(i<=e,"byte array longer than desired length"),A(e>0,"Requested array length <= 0");var l=b(g,e);return this["_toArrayLike"+("le"===I?"LE":"BE")](l,i),l},e.prototype._toArrayLikeLE=function(g,I){for(var C=0,A=0,i=0,e=0;i>8&255),C>16&255),6===e?(C>24&255),A=0,e=0):(A=l>>>24,e+=2)}if(C=0&&(g[C--]=l>>8&255),C>=0&&(g[C--]=l>>16&255),6===e?(C>=0&&(g[C--]=l>>24&255),A=0,e=0):(A=l>>>24,e+=2)}if(C>=0)for(g[C--]=A;C>=0;)g[C--]=0},Math.clz32?e.prototype._countBits=function(g){return 32-Math.clz32(g)}:e.prototype._countBits=function(g){var I=g,C=0;return I>=4096&&(C+=13,I>>>=13),I>=64&&(C+=7,I>>>=7),I>=8&&(C+=4,I>>>=4),I>=2&&(C+=2,I>>>=2),C+I},e.prototype._zeroBits=function(g){if(0===g)return 26;var I=g,C=0;return 8191&I||(C+=13,I>>>=13),127&I||(C+=7,I>>>=7),15&I||(C+=4,I>>>=4),3&I||(C+=2,I>>>=2),1&I||C++,C},e.prototype.bitLength=function(){var g=this.words[this.length-1],I=this._countBits(g);return 26*(this.length-1)+I},e.prototype.zeroBits=function(){if(this.isZero())return 0;for(var g=0,I=0;Ig.length?this.clone().ior(g):g.clone().ior(this)},e.prototype.uor=function(g){return this.length>g.length?this.clone().iuor(g):g.clone().iuor(this)},e.prototype.iuand=function(g){var I;I=this.length>g.length?g:this;for(var C=0;Cg.length?this.clone().iand(g):g.clone().iand(this)},e.prototype.uand=function(g){return this.length>g.length?this.clone().iuand(g):g.clone().iuand(this)},e.prototype.iuxor=function(g){var I,C;this.length>g.length?(I=this,C=g):(I=g,C=this);for(var A=0;Ag.length?this.clone().ixor(g):g.clone().ixor(this)},e.prototype.uxor=function(g){return this.length>g.length?this.clone().iuxor(g):g.clone().iuxor(this)},e.prototype.inotn=function(g){A("number"==typeof g&&g>=0);var I=0|Math.ceil(g/26),C=g%26;this._expand(I),C>0&&I--;for(var i=0;i0&&(this.words[i]=~this.words[i]&67108863>>26-C),this._strip()},e.prototype.notn=function(g){return this.clone().inotn(g)},e.prototype.setn=function(g,I){A("number"==typeof g&&g>=0);var C=g/26|0,i=g%26;return this._expand(C+1),this.words[C]=I?this.words[C]|1<g.length?(C=this,A=g):(C=g,A=this);for(var i=0,e=0;e>>26;for(;0!==i&&e>>26;if(this.length=C.length,0!==i)this.words[this.length]=i,this.length++;else if(C!==this)for(;eg.length?this.clone().iadd(g):g.clone().iadd(this)},e.prototype.isub=function(g){if(0!==g.negative){g.negative=0;var I=this.iadd(g);return g.negative=1,I._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(g),this.negative=1,this._normSign();var C,A,i=this.cmp(g);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(C=this,A=g):(C=g,A=this);for(var e=0,l=0;l>26,this.words[l]=67108863&I;for(;0!==e&&l>26,this.words[l]=67108863&I;if(0===e&&l>>13,a=0|l[1],Z=8191&a,b=a>>>13,r=0|l[2],m=8191&r,h=r>>>13,G=0|l[3],u=8191&G,B=G>>>13,w=0|l[4],W=8191&w,p=w>>>13,V=0|l[5],y=8191&V,X=V>>>13,Y=0|l[6],R=8191&Y,N=Y>>>13,H=0|l[7],K=8191&H,F=H>>>13,M=0|l[8],J=8191&M,S=M>>>13,f=0|l[9],k=8191&f,D=f>>>13,L=0|t[0],z=8191&L,v=L>>>13,T=0|t[1],x=8191&T,U=T>>>13,Q=0|t[2],j=8191&Q,O=Q>>>13,E=0|t[3],P=8191&E,_=E>>>13,q=0|t[4],$=8191&q,gg=q>>>13,Ig=0|t[5],Cg=8191&Ig,Ag=Ig>>>13,ig=0|t[6],eg=8191&ig,lg=ig>>>13,tg=0|t[7],sg=8191&tg,cg=tg>>>13,dg=0|t[8],og=8191&dg,ng=dg>>>13,ag=0|t[9],Zg=8191&ag,bg=ag>>>13;C.negative=g.negative^I.negative,C.length=19;var rg=(c+(A=Math.imul(o,z))|0)+((8191&(i=(i=Math.imul(o,v))+Math.imul(n,z)|0))<<13)|0;c=((e=Math.imul(n,v))+(i>>>13)|0)+(rg>>>26)|0,rg&=67108863,A=Math.imul(Z,z),i=(i=Math.imul(Z,v))+Math.imul(b,z)|0,e=Math.imul(b,v);var mg=(c+(A=A+Math.imul(o,x)|0)|0)+((8191&(i=(i=i+Math.imul(o,U)|0)+Math.imul(n,x)|0))<<13)|0;c=((e=e+Math.imul(n,U)|0)+(i>>>13)|0)+(mg>>>26)|0,mg&=67108863,A=Math.imul(m,z),i=(i=Math.imul(m,v))+Math.imul(h,z)|0,e=Math.imul(h,v),A=A+Math.imul(Z,x)|0,i=(i=i+Math.imul(Z,U)|0)+Math.imul(b,x)|0,e=e+Math.imul(b,U)|0;var hg=(c+(A=A+Math.imul(o,j)|0)|0)+((8191&(i=(i=i+Math.imul(o,O)|0)+Math.imul(n,j)|0))<<13)|0;c=((e=e+Math.imul(n,O)|0)+(i>>>13)|0)+(hg>>>26)|0,hg&=67108863,A=Math.imul(u,z),i=(i=Math.imul(u,v))+Math.imul(B,z)|0,e=Math.imul(B,v),A=A+Math.imul(m,x)|0,i=(i=i+Math.imul(m,U)|0)+Math.imul(h,x)|0,e=e+Math.imul(h,U)|0,A=A+Math.imul(Z,j)|0,i=(i=i+Math.imul(Z,O)|0)+Math.imul(b,j)|0,e=e+Math.imul(b,O)|0;var Gg=(c+(A=A+Math.imul(o,P)|0)|0)+((8191&(i=(i=i+Math.imul(o,_)|0)+Math.imul(n,P)|0))<<13)|0;c=((e=e+Math.imul(n,_)|0)+(i>>>13)|0)+(Gg>>>26)|0,Gg&=67108863,A=Math.imul(W,z),i=(i=Math.imul(W,v))+Math.imul(p,z)|0,e=Math.imul(p,v),A=A+Math.imul(u,x)|0,i=(i=i+Math.imul(u,U)|0)+Math.imul(B,x)|0,e=e+Math.imul(B,U)|0,A=A+Math.imul(m,j)|0,i=(i=i+Math.imul(m,O)|0)+Math.imul(h,j)|0,e=e+Math.imul(h,O)|0,A=A+Math.imul(Z,P)|0,i=(i=i+Math.imul(Z,_)|0)+Math.imul(b,P)|0,e=e+Math.imul(b,_)|0;var ug=(c+(A=A+Math.imul(o,$)|0)|0)+((8191&(i=(i=i+Math.imul(o,gg)|0)+Math.imul(n,$)|0))<<13)|0;c=((e=e+Math.imul(n,gg)|0)+(i>>>13)|0)+(ug>>>26)|0,ug&=67108863,A=Math.imul(y,z),i=(i=Math.imul(y,v))+Math.imul(X,z)|0,e=Math.imul(X,v),A=A+Math.imul(W,x)|0,i=(i=i+Math.imul(W,U)|0)+Math.imul(p,x)|0,e=e+Math.imul(p,U)|0,A=A+Math.imul(u,j)|0,i=(i=i+Math.imul(u,O)|0)+Math.imul(B,j)|0,e=e+Math.imul(B,O)|0,A=A+Math.imul(m,P)|0,i=(i=i+Math.imul(m,_)|0)+Math.imul(h,P)|0,e=e+Math.imul(h,_)|0,A=A+Math.imul(Z,$)|0,i=(i=i+Math.imul(Z,gg)|0)+Math.imul(b,$)|0,e=e+Math.imul(b,gg)|0;var Bg=(c+(A=A+Math.imul(o,Cg)|0)|0)+((8191&(i=(i=i+Math.imul(o,Ag)|0)+Math.imul(n,Cg)|0))<<13)|0;c=((e=e+Math.imul(n,Ag)|0)+(i>>>13)|0)+(Bg>>>26)|0,Bg&=67108863,A=Math.imul(R,z),i=(i=Math.imul(R,v))+Math.imul(N,z)|0,e=Math.imul(N,v),A=A+Math.imul(y,x)|0,i=(i=i+Math.imul(y,U)|0)+Math.imul(X,x)|0,e=e+Math.imul(X,U)|0,A=A+Math.imul(W,j)|0,i=(i=i+Math.imul(W,O)|0)+Math.imul(p,j)|0,e=e+Math.imul(p,O)|0,A=A+Math.imul(u,P)|0,i=(i=i+Math.imul(u,_)|0)+Math.imul(B,P)|0,e=e+Math.imul(B,_)|0,A=A+Math.imul(m,$)|0,i=(i=i+Math.imul(m,gg)|0)+Math.imul(h,$)|0,e=e+Math.imul(h,gg)|0,A=A+Math.imul(Z,Cg)|0,i=(i=i+Math.imul(Z,Ag)|0)+Math.imul(b,Cg)|0,e=e+Math.imul(b,Ag)|0;var wg=(c+(A=A+Math.imul(o,eg)|0)|0)+((8191&(i=(i=i+Math.imul(o,lg)|0)+Math.imul(n,eg)|0))<<13)|0;c=((e=e+Math.imul(n,lg)|0)+(i>>>13)|0)+(wg>>>26)|0,wg&=67108863,A=Math.imul(K,z),i=(i=Math.imul(K,v))+Math.imul(F,z)|0,e=Math.imul(F,v),A=A+Math.imul(R,x)|0,i=(i=i+Math.imul(R,U)|0)+Math.imul(N,x)|0,e=e+Math.imul(N,U)|0,A=A+Math.imul(y,j)|0,i=(i=i+Math.imul(y,O)|0)+Math.imul(X,j)|0,e=e+Math.imul(X,O)|0,A=A+Math.imul(W,P)|0,i=(i=i+Math.imul(W,_)|0)+Math.imul(p,P)|0,e=e+Math.imul(p,_)|0,A=A+Math.imul(u,$)|0,i=(i=i+Math.imul(u,gg)|0)+Math.imul(B,$)|0,e=e+Math.imul(B,gg)|0,A=A+Math.imul(m,Cg)|0,i=(i=i+Math.imul(m,Ag)|0)+Math.imul(h,Cg)|0,e=e+Math.imul(h,Ag)|0,A=A+Math.imul(Z,eg)|0,i=(i=i+Math.imul(Z,lg)|0)+Math.imul(b,eg)|0,e=e+Math.imul(b,lg)|0;var Wg=(c+(A=A+Math.imul(o,sg)|0)|0)+((8191&(i=(i=i+Math.imul(o,cg)|0)+Math.imul(n,sg)|0))<<13)|0;c=((e=e+Math.imul(n,cg)|0)+(i>>>13)|0)+(Wg>>>26)|0,Wg&=67108863,A=Math.imul(J,z),i=(i=Math.imul(J,v))+Math.imul(S,z)|0,e=Math.imul(S,v),A=A+Math.imul(K,x)|0,i=(i=i+Math.imul(K,U)|0)+Math.imul(F,x)|0,e=e+Math.imul(F,U)|0,A=A+Math.imul(R,j)|0,i=(i=i+Math.imul(R,O)|0)+Math.imul(N,j)|0,e=e+Math.imul(N,O)|0,A=A+Math.imul(y,P)|0,i=(i=i+Math.imul(y,_)|0)+Math.imul(X,P)|0,e=e+Math.imul(X,_)|0,A=A+Math.imul(W,$)|0,i=(i=i+Math.imul(W,gg)|0)+Math.imul(p,$)|0,e=e+Math.imul(p,gg)|0,A=A+Math.imul(u,Cg)|0,i=(i=i+Math.imul(u,Ag)|0)+Math.imul(B,Cg)|0,e=e+Math.imul(B,Ag)|0,A=A+Math.imul(m,eg)|0,i=(i=i+Math.imul(m,lg)|0)+Math.imul(h,eg)|0,e=e+Math.imul(h,lg)|0,A=A+Math.imul(Z,sg)|0,i=(i=i+Math.imul(Z,cg)|0)+Math.imul(b,sg)|0,e=e+Math.imul(b,cg)|0;var pg=(c+(A=A+Math.imul(o,og)|0)|0)+((8191&(i=(i=i+Math.imul(o,ng)|0)+Math.imul(n,og)|0))<<13)|0;c=((e=e+Math.imul(n,ng)|0)+(i>>>13)|0)+(pg>>>26)|0,pg&=67108863,A=Math.imul(k,z),i=(i=Math.imul(k,v))+Math.imul(D,z)|0,e=Math.imul(D,v),A=A+Math.imul(J,x)|0,i=(i=i+Math.imul(J,U)|0)+Math.imul(S,x)|0,e=e+Math.imul(S,U)|0,A=A+Math.imul(K,j)|0,i=(i=i+Math.imul(K,O)|0)+Math.imul(F,j)|0,e=e+Math.imul(F,O)|0,A=A+Math.imul(R,P)|0,i=(i=i+Math.imul(R,_)|0)+Math.imul(N,P)|0,e=e+Math.imul(N,_)|0,A=A+Math.imul(y,$)|0,i=(i=i+Math.imul(y,gg)|0)+Math.imul(X,$)|0,e=e+Math.imul(X,gg)|0,A=A+Math.imul(W,Cg)|0,i=(i=i+Math.imul(W,Ag)|0)+Math.imul(p,Cg)|0,e=e+Math.imul(p,Ag)|0,A=A+Math.imul(u,eg)|0,i=(i=i+Math.imul(u,lg)|0)+Math.imul(B,eg)|0,e=e+Math.imul(B,lg)|0,A=A+Math.imul(m,sg)|0,i=(i=i+Math.imul(m,cg)|0)+Math.imul(h,sg)|0,e=e+Math.imul(h,cg)|0,A=A+Math.imul(Z,og)|0,i=(i=i+Math.imul(Z,ng)|0)+Math.imul(b,og)|0,e=e+Math.imul(b,ng)|0;var Vg=(c+(A=A+Math.imul(o,Zg)|0)|0)+((8191&(i=(i=i+Math.imul(o,bg)|0)+Math.imul(n,Zg)|0))<<13)|0;c=((e=e+Math.imul(n,bg)|0)+(i>>>13)|0)+(Vg>>>26)|0,Vg&=67108863,A=Math.imul(k,x),i=(i=Math.imul(k,U))+Math.imul(D,x)|0,e=Math.imul(D,U),A=A+Math.imul(J,j)|0,i=(i=i+Math.imul(J,O)|0)+Math.imul(S,j)|0,e=e+Math.imul(S,O)|0,A=A+Math.imul(K,P)|0,i=(i=i+Math.imul(K,_)|0)+Math.imul(F,P)|0,e=e+Math.imul(F,_)|0,A=A+Math.imul(R,$)|0,i=(i=i+Math.imul(R,gg)|0)+Math.imul(N,$)|0,e=e+Math.imul(N,gg)|0,A=A+Math.imul(y,Cg)|0,i=(i=i+Math.imul(y,Ag)|0)+Math.imul(X,Cg)|0,e=e+Math.imul(X,Ag)|0,A=A+Math.imul(W,eg)|0,i=(i=i+Math.imul(W,lg)|0)+Math.imul(p,eg)|0,e=e+Math.imul(p,lg)|0,A=A+Math.imul(u,sg)|0,i=(i=i+Math.imul(u,cg)|0)+Math.imul(B,sg)|0,e=e+Math.imul(B,cg)|0,A=A+Math.imul(m,og)|0,i=(i=i+Math.imul(m,ng)|0)+Math.imul(h,og)|0,e=e+Math.imul(h,ng)|0;var yg=(c+(A=A+Math.imul(Z,Zg)|0)|0)+((8191&(i=(i=i+Math.imul(Z,bg)|0)+Math.imul(b,Zg)|0))<<13)|0;c=((e=e+Math.imul(b,bg)|0)+(i>>>13)|0)+(yg>>>26)|0,yg&=67108863,A=Math.imul(k,j),i=(i=Math.imul(k,O))+Math.imul(D,j)|0,e=Math.imul(D,O),A=A+Math.imul(J,P)|0,i=(i=i+Math.imul(J,_)|0)+Math.imul(S,P)|0,e=e+Math.imul(S,_)|0,A=A+Math.imul(K,$)|0,i=(i=i+Math.imul(K,gg)|0)+Math.imul(F,$)|0,e=e+Math.imul(F,gg)|0,A=A+Math.imul(R,Cg)|0,i=(i=i+Math.imul(R,Ag)|0)+Math.imul(N,Cg)|0,e=e+Math.imul(N,Ag)|0,A=A+Math.imul(y,eg)|0,i=(i=i+Math.imul(y,lg)|0)+Math.imul(X,eg)|0,e=e+Math.imul(X,lg)|0,A=A+Math.imul(W,sg)|0,i=(i=i+Math.imul(W,cg)|0)+Math.imul(p,sg)|0,e=e+Math.imul(p,cg)|0,A=A+Math.imul(u,og)|0,i=(i=i+Math.imul(u,ng)|0)+Math.imul(B,og)|0,e=e+Math.imul(B,ng)|0;var Xg=(c+(A=A+Math.imul(m,Zg)|0)|0)+((8191&(i=(i=i+Math.imul(m,bg)|0)+Math.imul(h,Zg)|0))<<13)|0;c=((e=e+Math.imul(h,bg)|0)+(i>>>13)|0)+(Xg>>>26)|0,Xg&=67108863,A=Math.imul(k,P),i=(i=Math.imul(k,_))+Math.imul(D,P)|0,e=Math.imul(D,_),A=A+Math.imul(J,$)|0,i=(i=i+Math.imul(J,gg)|0)+Math.imul(S,$)|0,e=e+Math.imul(S,gg)|0,A=A+Math.imul(K,Cg)|0,i=(i=i+Math.imul(K,Ag)|0)+Math.imul(F,Cg)|0,e=e+Math.imul(F,Ag)|0,A=A+Math.imul(R,eg)|0,i=(i=i+Math.imul(R,lg)|0)+Math.imul(N,eg)|0,e=e+Math.imul(N,lg)|0,A=A+Math.imul(y,sg)|0,i=(i=i+Math.imul(y,cg)|0)+Math.imul(X,sg)|0,e=e+Math.imul(X,cg)|0,A=A+Math.imul(W,og)|0,i=(i=i+Math.imul(W,ng)|0)+Math.imul(p,og)|0,e=e+Math.imul(p,ng)|0;var Yg=(c+(A=A+Math.imul(u,Zg)|0)|0)+((8191&(i=(i=i+Math.imul(u,bg)|0)+Math.imul(B,Zg)|0))<<13)|0;c=((e=e+Math.imul(B,bg)|0)+(i>>>13)|0)+(Yg>>>26)|0,Yg&=67108863,A=Math.imul(k,$),i=(i=Math.imul(k,gg))+Math.imul(D,$)|0,e=Math.imul(D,gg),A=A+Math.imul(J,Cg)|0,i=(i=i+Math.imul(J,Ag)|0)+Math.imul(S,Cg)|0,e=e+Math.imul(S,Ag)|0,A=A+Math.imul(K,eg)|0,i=(i=i+Math.imul(K,lg)|0)+Math.imul(F,eg)|0,e=e+Math.imul(F,lg)|0,A=A+Math.imul(R,sg)|0,i=(i=i+Math.imul(R,cg)|0)+Math.imul(N,sg)|0,e=e+Math.imul(N,cg)|0,A=A+Math.imul(y,og)|0,i=(i=i+Math.imul(y,ng)|0)+Math.imul(X,og)|0,e=e+Math.imul(X,ng)|0;var Rg=(c+(A=A+Math.imul(W,Zg)|0)|0)+((8191&(i=(i=i+Math.imul(W,bg)|0)+Math.imul(p,Zg)|0))<<13)|0;c=((e=e+Math.imul(p,bg)|0)+(i>>>13)|0)+(Rg>>>26)|0,Rg&=67108863,A=Math.imul(k,Cg),i=(i=Math.imul(k,Ag))+Math.imul(D,Cg)|0,e=Math.imul(D,Ag),A=A+Math.imul(J,eg)|0,i=(i=i+Math.imul(J,lg)|0)+Math.imul(S,eg)|0,e=e+Math.imul(S,lg)|0,A=A+Math.imul(K,sg)|0,i=(i=i+Math.imul(K,cg)|0)+Math.imul(F,sg)|0,e=e+Math.imul(F,cg)|0,A=A+Math.imul(R,og)|0,i=(i=i+Math.imul(R,ng)|0)+Math.imul(N,og)|0,e=e+Math.imul(N,ng)|0;var Ng=(c+(A=A+Math.imul(y,Zg)|0)|0)+((8191&(i=(i=i+Math.imul(y,bg)|0)+Math.imul(X,Zg)|0))<<13)|0;c=((e=e+Math.imul(X,bg)|0)+(i>>>13)|0)+(Ng>>>26)|0,Ng&=67108863,A=Math.imul(k,eg),i=(i=Math.imul(k,lg))+Math.imul(D,eg)|0,e=Math.imul(D,lg),A=A+Math.imul(J,sg)|0,i=(i=i+Math.imul(J,cg)|0)+Math.imul(S,sg)|0,e=e+Math.imul(S,cg)|0,A=A+Math.imul(K,og)|0,i=(i=i+Math.imul(K,ng)|0)+Math.imul(F,og)|0,e=e+Math.imul(F,ng)|0;var Hg=(c+(A=A+Math.imul(R,Zg)|0)|0)+((8191&(i=(i=i+Math.imul(R,bg)|0)+Math.imul(N,Zg)|0))<<13)|0;c=((e=e+Math.imul(N,bg)|0)+(i>>>13)|0)+(Hg>>>26)|0,Hg&=67108863,A=Math.imul(k,sg),i=(i=Math.imul(k,cg))+Math.imul(D,sg)|0,e=Math.imul(D,cg),A=A+Math.imul(J,og)|0,i=(i=i+Math.imul(J,ng)|0)+Math.imul(S,og)|0,e=e+Math.imul(S,ng)|0;var Kg=(c+(A=A+Math.imul(K,Zg)|0)|0)+((8191&(i=(i=i+Math.imul(K,bg)|0)+Math.imul(F,Zg)|0))<<13)|0;c=((e=e+Math.imul(F,bg)|0)+(i>>>13)|0)+(Kg>>>26)|0,Kg&=67108863,A=Math.imul(k,og),i=(i=Math.imul(k,ng))+Math.imul(D,og)|0,e=Math.imul(D,ng);var Fg=(c+(A=A+Math.imul(J,Zg)|0)|0)+((8191&(i=(i=i+Math.imul(J,bg)|0)+Math.imul(S,Zg)|0))<<13)|0;c=((e=e+Math.imul(S,bg)|0)+(i>>>13)|0)+(Fg>>>26)|0,Fg&=67108863;var Mg=(c+(A=Math.imul(k,Zg))|0)+((8191&(i=(i=Math.imul(k,bg))+Math.imul(D,Zg)|0))<<13)|0;return c=((e=Math.imul(D,bg))+(i>>>13)|0)+(Mg>>>26)|0,Mg&=67108863,s[0]=rg,s[1]=mg,s[2]=hg,s[3]=Gg,s[4]=ug,s[5]=Bg,s[6]=wg,s[7]=Wg,s[8]=pg,s[9]=Vg,s[10]=yg,s[11]=Xg,s[12]=Yg,s[13]=Rg,s[14]=Ng,s[15]=Hg,s[16]=Kg,s[17]=Fg,s[18]=Mg,0!==c&&(s[19]=c,C.length++),C};function G(g,I,C){C.negative=I.negative^g.negative,C.length=g.length+I.length;for(var A=0,i=0,e=0;e>>26)|0)>>>26,l&=67108863}C.words[e]=t,A=l,l=i}return 0!==A?C.words[e]=A:C.length--,C._strip()}function u(g,I,C){return G(g,I,C)}Math.imul||(h=m),e.prototype.mulTo=function(g,I){var C=this.length+g.length;return 10===this.length&&10===g.length?h(this,g,I):C<63?m(this,g,I):C<1024?G(this,g,I):u(this,g,I)},e.prototype.mul=function(g){var I=new e(null);return I.words=new Array(this.length+g.length),this.mulTo(g,I)},e.prototype.mulf=function(g){var I=new e(null);return I.words=new Array(this.length+g.length),u(this,g,I)},e.prototype.imul=function(g){return this.clone().mulTo(g,this)},e.prototype.imuln=function(g){var I=g<0;I&&(g=-g),A("number"==typeof g),A(g<67108864);for(var C=0,i=0;i>=26,C+=e/67108864|0,C+=l>>>26,this.words[i]=67108863&l}return 0!==C&&(this.words[i]=C,this.length++),I?this.ineg():this},e.prototype.muln=function(g){return this.clone().imuln(g)},e.prototype.sqr=function(){return this.mul(this)},e.prototype.isqr=function(){return this.imul(this.clone())},e.prototype.pow=function(g){var I=r(g);if(0===I.length)return new e(1);for(var C=this,A=0;A=0);var I,C=g%26,i=(g-C)/26,e=67108863>>>26-C<<26-C;if(0!==C){var l=0;for(I=0;I>>26-C}l&&(this.words[I]=l,this.length++)}if(0!==i){for(I=this.length-1;I>=0;I--)this.words[I+i]=this.words[I];for(I=0;I=0),i=I?(I-I%26)/26:0;var e=g%26,l=Math.min((g-e)/26,this.length),t=67108863^67108863>>>e<l)for(this.length-=l,c=0;c=0&&(0!==d||c>=i);c--){var o=0|this.words[c];this.words[c]=d<<26-e|o>>>e,d=o&t}return s&&0!==d&&(s.words[s.length++]=d),0===this.length&&(this.words[0]=0,this.length=1),this._strip()},e.prototype.ishrn=function(g,I,C){return A(0===this.negative),this.iushrn(g,I,C)},e.prototype.shln=function(g){return this.clone().ishln(g)},e.prototype.ushln=function(g){return this.clone().iushln(g)},e.prototype.shrn=function(g){return this.clone().ishrn(g)},e.prototype.ushrn=function(g){return this.clone().iushrn(g)},e.prototype.testn=function(g){A("number"==typeof g&&g>=0);var I=g%26,C=(g-I)/26,i=1<=0);var I=g%26,C=(g-I)/26;if(A(0===this.negative,"imaskn works only with positive numbers"),this.length<=C)return this;if(0!==I&&C++,this.length=Math.min(C,this.length),0!==I){var i=67108863^67108863>>>I<=67108864;I++)this.words[I]-=67108864,I===this.length-1?this.words[I+1]=1:this.words[I+1]++;return this.length=Math.max(this.length,I+1),this},e.prototype.isubn=function(g){if(A("number"==typeof g),A(g<67108864),g<0)return this.iaddn(-g);if(0!==this.negative)return this.negative=0,this.iaddn(g),this.negative=1,this;if(this.words[0]-=g,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var I=0;I>26)-(s/67108864|0),this.words[i+C]=67108863&e}for(;i>26,this.words[i+C]=67108863&e;if(0===t)return this._strip();for(A(-1===t),t=0,i=0;i>26,this.words[i]=67108863&e;return this.negative=1,this._strip()},e.prototype._wordDiv=function(g,I){var C=this.length-g.length,A=this.clone(),i=g,l=0|i.words[i.length-1];0!=(C=26-this._countBits(l))&&(i=i.ushln(C),A.iushln(C),l=0|i.words[i.length-1]);var t,s=A.length-i.length;if("mod"!==I){(t=new e(null)).length=s+1,t.words=new Array(t.length);for(var c=0;c=0;o--){var n=67108864*(0|A.words[i.length+o])+(0|A.words[i.length+o-1]);for(n=Math.min(n/l|0,67108863),A._ishlnsubmul(i,n,o);0!==A.negative;)n--,A.negative=0,A._ishlnsubmul(i,1,o),A.isZero()||(A.negative^=1);t&&(t.words[o]=n)}return t&&t._strip(),A._strip(),"div"!==I&&0!==C&&A.iushrn(C),{div:t||null,mod:A}},e.prototype.divmod=function(g,I,C){return A(!g.isZero()),this.isZero()?{div:new e(0),mod:new e(0)}:0!==this.negative&&0===g.negative?(t=this.neg().divmod(g,I),"mod"!==I&&(i=t.div.neg()),"div"!==I&&(l=t.mod.neg(),C&&0!==l.negative&&l.iadd(g)),{div:i,mod:l}):0===this.negative&&0!==g.negative?(t=this.divmod(g.neg(),I),"mod"!==I&&(i=t.div.neg()),{div:i,mod:t.mod}):this.negative&g.negative?(t=this.neg().divmod(g.neg(),I),"div"!==I&&(l=t.mod.neg(),C&&0!==l.negative&&l.isub(g)),{div:t.div,mod:l}):g.length>this.length||this.cmp(g)<0?{div:new e(0),mod:this}:1===g.length?"div"===I?{div:this.divn(g.words[0]),mod:null}:"mod"===I?{div:null,mod:new e(this.modrn(g.words[0]))}:{div:this.divn(g.words[0]),mod:new e(this.modrn(g.words[0]))}:this._wordDiv(g,I);var i,l,t},e.prototype.div=function(g){return this.divmod(g,"div",!1).div},e.prototype.mod=function(g){return this.divmod(g,"mod",!1).mod},e.prototype.umod=function(g){return this.divmod(g,"mod",!0).mod},e.prototype.divRound=function(g){var I=this.divmod(g);if(I.mod.isZero())return I.div;var C=0!==I.div.negative?I.mod.isub(g):I.mod,A=g.ushrn(1),i=g.andln(1),e=C.cmp(A);return e<0||1===i&&0===e?I.div:0!==I.div.negative?I.div.isubn(1):I.div.iaddn(1)},e.prototype.modrn=function(g){var I=g<0;I&&(g=-g),A(g<=67108863);for(var C=(1<<26)%g,i=0,e=this.length-1;e>=0;e--)i=(C*i+(0|this.words[e]))%g;return I?-i:i},e.prototype.modn=function(g){return this.modrn(g)},e.prototype.idivn=function(g){var I=g<0;I&&(g=-g),A(g<=67108863);for(var C=0,i=this.length-1;i>=0;i--){var e=(0|this.words[i])+67108864*C;this.words[i]=e/g|0,C=e%g}return this._strip(),I?this.ineg():this},e.prototype.divn=function(g){return this.clone().idivn(g)},e.prototype.egcd=function(g){A(0===g.negative),A(!g.isZero());var I=this,C=g.clone();I=0!==I.negative?I.umod(g):I.clone();for(var i=new e(1),l=new e(0),t=new e(0),s=new e(1),c=0;I.isEven()&&C.isEven();)I.iushrn(1),C.iushrn(1),++c;for(var d=C.clone(),o=I.clone();!I.isZero();){for(var n=0,a=1;!(I.words[0]&a)&&n<26;++n,a<<=1);if(n>0)for(I.iushrn(n);n-- >0;)(i.isOdd()||l.isOdd())&&(i.iadd(d),l.isub(o)),i.iushrn(1),l.iushrn(1);for(var Z=0,b=1;!(C.words[0]&b)&&Z<26;++Z,b<<=1);if(Z>0)for(C.iushrn(Z);Z-- >0;)(t.isOdd()||s.isOdd())&&(t.iadd(d),s.isub(o)),t.iushrn(1),s.iushrn(1);I.cmp(C)>=0?(I.isub(C),i.isub(t),l.isub(s)):(C.isub(I),t.isub(i),s.isub(l))}return{a:t,b:s,gcd:C.iushln(c)}},e.prototype._invmp=function(g){A(0===g.negative),A(!g.isZero());var I=this,C=g.clone();I=0!==I.negative?I.umod(g):I.clone();for(var i,l=new e(1),t=new e(0),s=C.clone();I.cmpn(1)>0&&C.cmpn(1)>0;){for(var c=0,d=1;!(I.words[0]&d)&&c<26;++c,d<<=1);if(c>0)for(I.iushrn(c);c-- >0;)l.isOdd()&&l.iadd(s),l.iushrn(1);for(var o=0,n=1;!(C.words[0]&n)&&o<26;++o,n<<=1);if(o>0)for(C.iushrn(o);o-- >0;)t.isOdd()&&t.iadd(s),t.iushrn(1);I.cmp(C)>=0?(I.isub(C),l.isub(t)):(C.isub(I),t.isub(l))}return(i=0===I.cmpn(1)?l:t).cmpn(0)<0&&i.iadd(g),i},e.prototype.gcd=function(g){if(this.isZero())return g.abs();if(g.isZero())return this.abs();var I=this.clone(),C=g.clone();I.negative=0,C.negative=0;for(var A=0;I.isEven()&&C.isEven();A++)I.iushrn(1),C.iushrn(1);for(;;){for(;I.isEven();)I.iushrn(1);for(;C.isEven();)C.iushrn(1);var i=I.cmp(C);if(i<0){var e=I;I=C,C=e}else if(0===i||0===C.cmpn(1))break;I.isub(C)}return C.iushln(A)},e.prototype.invm=function(g){return this.egcd(g).a.umod(g)},e.prototype.isEven=function(){return!(1&this.words[0])},e.prototype.isOdd=function(){return!(1&~this.words[0])},e.prototype.andln=function(g){return this.words[0]&g},e.prototype.bincn=function(g){A("number"==typeof g);var I=g%26,C=(g-I)/26,i=1<>>26,t&=67108863,this.words[l]=t}return 0!==e&&(this.words[l]=e,this.length++),this},e.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},e.prototype.cmpn=function(g){var I,C=g<0;if(0!==this.negative&&!C)return-1;if(0===this.negative&&C)return 1;if(this._strip(),this.length>1)I=1;else{C&&(g=-g),A(g<=67108863,"Number is too big");var i=0|this.words[0];I=i===g?0:ig.length)return 1;if(this.length=0;C--){var A=0|this.words[C],i=0|g.words[C];if(A!==i){Ai&&(I=1);break}}return I},e.prototype.gtn=function(g){return 1===this.cmpn(g)},e.prototype.gt=function(g){return 1===this.cmp(g)},e.prototype.gten=function(g){return this.cmpn(g)>=0},e.prototype.gte=function(g){return this.cmp(g)>=0},e.prototype.ltn=function(g){return-1===this.cmpn(g)},e.prototype.lt=function(g){return-1===this.cmp(g)},e.prototype.lten=function(g){return this.cmpn(g)<=0},e.prototype.lte=function(g){return this.cmp(g)<=0},e.prototype.eqn=function(g){return 0===this.cmpn(g)},e.prototype.eq=function(g){return 0===this.cmp(g)},e.red=function(g){return new X(g)},e.prototype.toRed=function(g){return A(!this.red,"Already a number in reduction context"),A(0===this.negative,"red works only with positives"),g.convertTo(this)._forceRed(g)},e.prototype.fromRed=function(){return A(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},e.prototype._forceRed=function(g){return this.red=g,this},e.prototype.forceRed=function(g){return A(!this.red,"Already a number in reduction context"),this._forceRed(g)},e.prototype.redAdd=function(g){return A(this.red,"redAdd works only with red numbers"),this.red.add(this,g)},e.prototype.redIAdd=function(g){return A(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,g)},e.prototype.redSub=function(g){return A(this.red,"redSub works only with red numbers"),this.red.sub(this,g)},e.prototype.redISub=function(g){return A(this.red,"redISub works only with red numbers"),this.red.isub(this,g)},e.prototype.redShl=function(g){return A(this.red,"redShl works only with red numbers"),this.red.shl(this,g)},e.prototype.redMul=function(g){return A(this.red,"redMul works only with red numbers"),this.red._verify2(this,g),this.red.mul(this,g)},e.prototype.redIMul=function(g){return A(this.red,"redMul works only with red numbers"),this.red._verify2(this,g),this.red.imul(this,g)},e.prototype.redSqr=function(){return A(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},e.prototype.redISqr=function(){return A(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},e.prototype.redSqrt=function(){return A(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},e.prototype.redInvm=function(){return A(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},e.prototype.redNeg=function(){return A(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},e.prototype.redPow=function(g){return A(this.red&&!g.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,g)};var B={k256:null,p224:null,p192:null,p25519:null};function w(g,I){this.name=g,this.p=new e(I,16),this.n=this.p.bitLength(),this.k=new e(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function W(){w.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function p(){w.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function V(){w.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function y(){w.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function X(g){if("string"==typeof g){var I=e._prime(g);this.m=I.p,this.prime=I}else A(g.gtn(1),"modulus must be greater than 1"),this.m=g,this.prime=null}function Y(g){X.call(this,g),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new e(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}w.prototype._tmp=function(){var g=new e(null);return g.words=new Array(Math.ceil(this.n/13)),g},w.prototype.ireduce=function(g){var I,C=g;do{this.split(C,this.tmp),I=(C=(C=this.imulK(C)).iadd(this.tmp)).bitLength()}while(I>this.n);var A=I0?C.isub(this.p):void 0!==C.strip?C.strip():C._strip(),C},w.prototype.split=function(g,I){g.iushrn(this.n,0,I)},w.prototype.imulK=function(g){return g.imul(this.k)},i(W,w),W.prototype.split=function(g,I){for(var C=4194303,A=Math.min(g.length,9),i=0;i>>22,e=l}e>>>=22,g.words[i-10]=e,0===e&&g.length>10?g.length-=10:g.length-=9},W.prototype.imulK=function(g){g.words[g.length]=0,g.words[g.length+1]=0,g.length+=2;for(var I=0,C=0;C>>=26,g.words[C]=i,I=A}return 0!==I&&(g.words[g.length++]=I),g},e._prime=function(g){if(B[g])return B[g];var I;if("k256"===g)I=new W;else if("p224"===g)I=new p;else if("p192"===g)I=new V;else{if("p25519"!==g)throw new Error("Unknown prime "+g);I=new y}return B[g]=I,I},X.prototype._verify1=function(g){A(0===g.negative,"red works only with positives"),A(g.red,"red works only with red numbers")},X.prototype._verify2=function(g,I){A(!(g.negative|I.negative),"red works only with positives"),A(g.red&&g.red===I.red,"red works only with red numbers")},X.prototype.imod=function(g){return this.prime?this.prime.ireduce(g)._forceRed(this):(d(g,g.umod(this.m)._forceRed(this)),g)},X.prototype.neg=function(g){return g.isZero()?g.clone():this.m.sub(g)._forceRed(this)},X.prototype.add=function(g,I){this._verify2(g,I);var C=g.add(I);return C.cmp(this.m)>=0&&C.isub(this.m),C._forceRed(this)},X.prototype.iadd=function(g,I){this._verify2(g,I);var C=g.iadd(I);return C.cmp(this.m)>=0&&C.isub(this.m),C},X.prototype.sub=function(g,I){this._verify2(g,I);var C=g.sub(I);return C.cmpn(0)<0&&C.iadd(this.m),C._forceRed(this)},X.prototype.isub=function(g,I){this._verify2(g,I);var C=g.isub(I);return C.cmpn(0)<0&&C.iadd(this.m),C},X.prototype.shl=function(g,I){return this._verify1(g),this.imod(g.ushln(I))},X.prototype.imul=function(g,I){return this._verify2(g,I),this.imod(g.imul(I))},X.prototype.mul=function(g,I){return this._verify2(g,I),this.imod(g.mul(I))},X.prototype.isqr=function(g){return this.imul(g,g.clone())},X.prototype.sqr=function(g){return this.mul(g,g)},X.prototype.sqrt=function(g){if(g.isZero())return g.clone();var I=this.m.andln(3);if(A(I%2==1),3===I){var C=this.m.add(new e(1)).iushrn(2);return this.pow(g,C)}for(var i=this.m.subn(1),l=0;!i.isZero()&&0===i.andln(1);)l++,i.iushrn(1);A(!i.isZero());var t=new e(1).toRed(this),s=t.redNeg(),c=this.m.subn(1).iushrn(1),d=this.m.bitLength();for(d=new e(2*d*d).toRed(this);0!==this.pow(d,c).cmp(s);)d.redIAdd(s);for(var o=this.pow(d,i),n=this.pow(g,i.addn(1).iushrn(1)),a=this.pow(g,i),Z=l;0!==a.cmp(t);){for(var b=a,r=0;0!==b.cmp(t);r++)b=b.redSqr();A(r=0;i--){for(var d=I.words[i],o=c-1;o>=0;o--){var n=d>>o&1;l!==A[0]&&(l=this.sqr(l)),0!==n||0!==t?(t<<=1,t|=n,(++s===C||0===i&&0===o)&&(l=this.mul(l,A[t]),s=0,t=0)):s=0}c=26}return l},X.prototype.convertTo=function(g){var I=g.umod(this.m);return I===g?I.clone():I},X.prototype.convertFrom=function(g){var I=g.clone();return I.red=null,I},e.mont=function(g){return new Y(g)},i(Y,X),Y.prototype.convertTo=function(g){return this.imod(g.ushln(this.shift))},Y.prototype.convertFrom=function(g){var I=this.imod(g.mul(this.rinv));return I.red=null,I},Y.prototype.imul=function(g,I){if(g.isZero()||I.isZero())return g.words[0]=0,g.length=1,g;var C=g.imul(I),A=C.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=C.isub(A).iushrn(this.shift),e=i;return i.cmp(this.m)>=0?e=i.isub(this.m):i.cmpn(0)<0&&(e=i.iadd(this.m)),e._forceRed(this)},Y.prototype.mul=function(g,I){if(g.isZero()||I.isZero())return new e(0)._forceRed(this);var C=g.mul(I),A=C.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=C.isub(A).iushrn(this.shift),l=i;return i.cmp(this.m)>=0?l=i.isub(this.m):i.cmpn(0)<0&&(l=i.iadd(this.m)),l._forceRed(this)},Y.prototype.invm=function(g){return this.imod(g._invmp(this.m).mul(this.r2))._forceRed(this)}}(void 0===I||I,void 0)},{buffer:188}],187:[function(g,I,C){var A;function i(g){this.rand=g}if(I.exports=function(g){return A||(A=new i(null)),A.generate(g)},I.exports.Rand=i,i.prototype.generate=function(g){return this._rand(g)},i.prototype._rand=function(g){if(this.rand.getBytes)return this.rand.getBytes(g);for(var I=new Uint8Array(g),C=0;C>>24]^d[Z>>>16&255]^o[b>>>8&255]^n[255&r]^I[m++],l=c[Z>>>24]^d[b>>>16&255]^o[r>>>8&255]^n[255&a]^I[m++],t=c[b>>>24]^d[r>>>16&255]^o[a>>>8&255]^n[255&Z]^I[m++],s=c[r>>>24]^d[a>>>16&255]^o[Z>>>8&255]^n[255&b]^I[m++],a=e,Z=l,b=t,r=s;return e=(A[a>>>24]<<24|A[Z>>>16&255]<<16|A[b>>>8&255]<<8|A[255&r])^I[m++],l=(A[Z>>>24]<<24|A[b>>>16&255]<<16|A[r>>>8&255]<<8|A[255&a])^I[m++],t=(A[b>>>24]<<24|A[r>>>16&255]<<16|A[a>>>8&255]<<8|A[255&Z])^I[m++],s=(A[r>>>24]<<24|A[a>>>16&255]<<16|A[Z>>>8&255]<<8|A[255&b])^I[m++],[e>>>=0,l>>>=0,t>>>=0,s>>>=0]}var t=[0,1,2,4,8,16,32,64,128,27,54],s=function(){for(var g=new Array(256),I=0;I<256;I++)g[I]=I<128?I<<1:I<<1^283;for(var C=[],A=[],i=[[],[],[],[]],e=[[],[],[],[]],l=0,t=0,s=0;s<256;++s){var c=t^t<<1^t<<2^t<<3^t<<4;c=c>>>8^255&c^99,C[l]=c,A[c]=l;var d=g[l],o=g[d],n=g[o],a=257*g[c]^16843008*c;i[0][l]=a<<24|a>>>8,i[1][l]=a<<16|a>>>16,i[2][l]=a<<8|a>>>24,i[3][l]=a,a=16843009*n^65537*o^257*d^16843008*l,e[0][c]=a<<24|a>>>8,e[1][c]=a<<16|a>>>16,e[2][c]=a<<8|a>>>24,e[3][c]=a,0===l?l=t=1:(l=d^g[g[g[n^d]]],t^=g[g[t]])}return{SBOX:C,INV_SBOX:A,SUB_MIX:i,INV_SUB_MIX:e}}();function c(g){this._key=i(g),this._reset()}c.blockSize=16,c.keySize=32,c.prototype.blockSize=c.blockSize,c.prototype.keySize=c.keySize,c.prototype._reset=function(){for(var g=this._key,I=g.length,C=I+6,A=4*(C+1),i=[],e=0;e>>24,l=s.SBOX[l>>>24]<<24|s.SBOX[l>>>16&255]<<16|s.SBOX[l>>>8&255]<<8|s.SBOX[255&l],l^=t[e/I|0]<<24):I>6&&e%I==4&&(l=s.SBOX[l>>>24]<<24|s.SBOX[l>>>16&255]<<16|s.SBOX[l>>>8&255]<<8|s.SBOX[255&l]),i[e]=i[e-I]^l}for(var c=[],d=0;d>>24]]^s.INV_SUB_MIX[1][s.SBOX[n>>>16&255]]^s.INV_SUB_MIX[2][s.SBOX[n>>>8&255]]^s.INV_SUB_MIX[3][s.SBOX[255&n]]}this._nRounds=C,this._keySchedule=i,this._invKeySchedule=c},c.prototype.encryptBlockRaw=function(g){return l(g=i(g),this._keySchedule,s.SUB_MIX,s.SBOX,this._nRounds)},c.prototype.encryptBlock=function(g){var I=this.encryptBlockRaw(g),C=A.allocUnsafe(16);return C.writeUInt32BE(I[0],0),C.writeUInt32BE(I[1],4),C.writeUInt32BE(I[2],8),C.writeUInt32BE(I[3],12),C},c.prototype.decryptBlock=function(g){var I=(g=i(g))[1];g[1]=g[3],g[3]=I;var C=l(g,this._invKeySchedule,s.INV_SUB_MIX,s.INV_SBOX,this._nRounds),e=A.allocUnsafe(16);return e.writeUInt32BE(C[0],0),e.writeUInt32BE(C[3],4),e.writeUInt32BE(C[2],8),e.writeUInt32BE(C[1],12),e},c.prototype.scrub=function(){e(this._keySchedule),e(this._invKeySchedule),e(this._key)},I.exports.AES=c},{"safe-buffer":494}],190:[function(g,I,C){var A=g("./aes"),i=g("safe-buffer").Buffer,e=g("cipher-base"),l=g("inherits"),t=g("./ghash"),s=g("buffer-xor"),c=g("./incr32");function d(g,I){var C=0;g.length!==I.length&&C++;for(var A=Math.min(g.length,I.length),i=0;i16)throw new Error("unable to decrypt data");for(var C=-1;++C16)return I=this.cache.slice(0,16),this.cache=this.cache.slice(16),I}else if(this.cache.length>=16)return I=this.cache.slice(0,16),this.cache=this.cache.slice(16),I;return null},o.prototype.flush=function(){if(this.cache.length)return this.cache},C.createDecipher=Z,C.createDecipheriv=a},{"./aes":189,"./authCipher":190,"./modes":202,"./streamCipher":205,"cipher-base":221,evp_bytestokey:423,inherits:440,"safe-buffer":494}],193:[function(g,I,C){var A=g("./modes"),i=g("./authCipher"),e=g("safe-buffer").Buffer,l=g("./streamCipher"),t=g("cipher-base"),s=g("./aes"),c=g("evp_bytestokey");function d(g,I,C){t.call(this),this._cache=new n,this._cipher=new s.AES(I),this._prev=e.from(C),this._mode=g,this._autopadding=!0}g("inherits")(d,t),d.prototype._update=function(g){var I,C;this._cache.add(g);for(var A=[];I=this._cache.get();)C=this._mode.encrypt(this,I),A.push(C);return e.concat(A)};var o=e.alloc(16,16);function n(){this.cache=e.allocUnsafe(0)}function a(g,I,C){var t=A[g.toLowerCase()];if(!t)throw new TypeError("invalid suite type");if("string"==typeof I&&(I=e.from(I)),I.length!==t.key/8)throw new TypeError("invalid key length "+I.length);if("string"==typeof C&&(C=e.from(C)),"GCM"!==t.mode&&C.length!==t.iv)throw new TypeError("invalid iv length "+C.length);return"stream"===t.type?new l(t.module,I,C):"auth"===t.type?new i(t.module,I,C):new d(t.module,I,C)}function Z(g,I){var C=A[g.toLowerCase()];if(!C)throw new TypeError("invalid suite type");var i=c(I,!1,C.key,C.iv);return a(g,i.key,i.iv)}d.prototype._final=function(){var g=this._cache.flush();if(this._autopadding)return g=this._mode.encrypt(this,g),this._cipher.scrub(),g;if(!g.equals(o))throw this._cipher.scrub(),new Error("data not multiple of block length")},d.prototype.setAutoPadding=function(g){return this._autopadding=!!g,this},n.prototype.add=function(g){this.cache=e.concat([this.cache,g])},n.prototype.get=function(){if(this.cache.length>15){var g=this.cache.slice(0,16);return this.cache=this.cache.slice(16),g}return null},n.prototype.flush=function(){for(var g=16-this.cache.length,I=e.allocUnsafe(g),C=-1;++C>>0,0),I.writeUInt32BE(g[1]>>>0,4),I.writeUInt32BE(g[2]>>>0,8),I.writeUInt32BE(g[3]>>>0,12),I}function t(g){this.h=g,this.state=A.alloc(16,0),this.cache=A.allocUnsafe(0)}t.prototype.ghash=function(g){for(var I=-1;++I0;g--)C[g]=C[g]>>>1|(1&C[g-1])<<31;C[0]=C[0]>>>1,I&&(C[0]=C[0]^225<<24)}this.state=l(A)},t.prototype.update=function(g){var I;for(this.cache=A.concat([this.cache,g]);this.cache.length>=16;)I=this.cache.slice(0,16),this.cache=this.cache.slice(16),this.ghash(I)},t.prototype.final=function(g,I){return this.cache.length&&this.ghash(A.concat([this.cache,i],16)),this.ghash(l([0,g,0,I])),this.state},I.exports=t},{"safe-buffer":494}],195:[function(g,I,C){function A(g){for(var I,C=g.length;C--;){if(255!==(I=g.readUInt8(C))){I++,g.writeUInt8(I,C);break}g.writeUInt8(0,C)}}I.exports=A},{}],196:[function(g,I,C){var A=g("buffer-xor");C.encrypt=function(g,I){var C=A(I,g._prev);return g._prev=g._cipher.encryptBlock(C),g._prev},C.decrypt=function(g,I){var C=g._prev;g._prev=I;var i=g._cipher.decryptBlock(I);return A(i,C)}},{"buffer-xor":219}],197:[function(g,I,C){var A=g("safe-buffer").Buffer,i=g("buffer-xor");function e(g,I,C){var e=I.length,l=i(I,g._cache);return g._cache=g._cache.slice(e),g._prev=A.concat([g._prev,C?I:l]),l}C.encrypt=function(g,I,C){for(var i,l=A.allocUnsafe(0);I.length;){if(0===g._cache.length&&(g._cache=g._cipher.encryptBlock(g._prev),g._prev=A.allocUnsafe(0)),!(g._cache.length<=I.length)){l=A.concat([l,e(g,I,C)]);break}i=g._cache.length,l=A.concat([l,e(g,I.slice(0,i),C)]),I=I.slice(i)}return l}},{"buffer-xor":219,"safe-buffer":494}],198:[function(g,I,C){var A=g("safe-buffer").Buffer;function i(g,I,C){for(var A,i,l=-1,t=8,s=0;++l>l%8,g._prev=e(g._prev,C?A:i);return s}function e(g,I){var C=g.length,i=-1,e=A.allocUnsafe(g.length);for(g=A.concat([g,A.from([I])]);++i>7;return e}C.encrypt=function(g,I,C){for(var e=I.length,l=A.allocUnsafe(e),t=-1;++t=0||!I.umod(g.prime1)||!I.umod(g.prime2));return I}function t(g,I){var i=e(I),l=I.modulus.byteLength(),t=new A(g).mul(i.blinder).umod(I.modulus),s=t.toRed(A.mont(I.prime1)),c=t.toRed(A.mont(I.prime2)),d=I.coefficient,o=I.prime1,n=I.prime2,a=s.redPow(I.exponent1).fromRed(),Z=c.redPow(I.exponent2).fromRed(),b=a.isub(Z).imul(d).umod(o).imul(n);return Z.iadd(b).imul(i.unblinder).umod(I.modulus).toArrayLike(C,"be",l)}t.getr=l,I.exports=t}).call(this)}).call(this,g("buffer").Buffer)},{"bn.js":186,buffer:220,randombytes:475}],210:[function(g,I,C){I.exports=g("./browser/algorithms.json")},{"./browser/algorithms.json":211}],211:[function(g,I,C){I.exports={sha224WithRSAEncryption:{sign:"rsa",hash:"sha224",id:"302d300d06096086480165030402040500041c"},"RSA-SHA224":{sign:"ecdsa/rsa",hash:"sha224",id:"302d300d06096086480165030402040500041c"},sha256WithRSAEncryption:{sign:"rsa",hash:"sha256",id:"3031300d060960864801650304020105000420"},"RSA-SHA256":{sign:"ecdsa/rsa",hash:"sha256",id:"3031300d060960864801650304020105000420"},sha384WithRSAEncryption:{sign:"rsa",hash:"sha384",id:"3041300d060960864801650304020205000430"},"RSA-SHA384":{sign:"ecdsa/rsa",hash:"sha384",id:"3041300d060960864801650304020205000430"},sha512WithRSAEncryption:{sign:"rsa",hash:"sha512",id:"3051300d060960864801650304020305000440"},"RSA-SHA512":{sign:"ecdsa/rsa",hash:"sha512",id:"3051300d060960864801650304020305000440"},"RSA-SHA1":{sign:"rsa",hash:"sha1",id:"3021300906052b0e03021a05000414"},"ecdsa-with-SHA1":{sign:"ecdsa",hash:"sha1",id:""},sha256:{sign:"ecdsa",hash:"sha256",id:""},sha224:{sign:"ecdsa",hash:"sha224",id:""},sha384:{sign:"ecdsa",hash:"sha384",id:""},sha512:{sign:"ecdsa",hash:"sha512",id:""},"DSA-SHA":{sign:"dsa",hash:"sha1",id:""},"DSA-SHA1":{sign:"dsa",hash:"sha1",id:""},DSA:{sign:"dsa",hash:"sha1",id:""},"DSA-WITH-SHA224":{sign:"dsa",hash:"sha224",id:""},"DSA-SHA224":{sign:"dsa",hash:"sha224",id:""},"DSA-WITH-SHA256":{sign:"dsa",hash:"sha256",id:""},"DSA-SHA256":{sign:"dsa",hash:"sha256",id:""},"DSA-WITH-SHA384":{sign:"dsa",hash:"sha384",id:""},"DSA-SHA384":{sign:"dsa",hash:"sha384",id:""},"DSA-WITH-SHA512":{sign:"dsa",hash:"sha512",id:""},"DSA-SHA512":{sign:"dsa",hash:"sha512",id:""},"DSA-RIPEMD160":{sign:"dsa",hash:"rmd160",id:""},ripemd160WithRSA:{sign:"rsa",hash:"rmd160",id:"3021300906052b2403020105000414"},"RSA-RIPEMD160":{sign:"rsa",hash:"rmd160",id:"3021300906052b2403020105000414"},md5WithRSAEncryption:{sign:"rsa",hash:"md5",id:"3020300c06082a864886f70d020505000410"},"RSA-MD5":{sign:"rsa",hash:"md5",id:"3020300c06082a864886f70d020505000410"}}},{}],212:[function(g,I,C){I.exports={"1.3.132.0.10":"secp256k1","1.3.132.0.33":"p224","1.2.840.10045.3.1.1":"p192","1.2.840.10045.3.1.7":"p256","1.3.132.0.34":"p384","1.3.132.0.35":"p521"}},{}],213:[function(g,I,C){var A=g("safe-buffer").Buffer,i=g("create-hash"),e=g("readable-stream"),l=g("inherits"),t=g("./sign"),s=g("./verify"),c=g("./algorithms.json");function d(g){e.Writable.call(this);var I=c[g];if(!I)throw new Error("Unknown message digest");this._hashType=I.hash,this._hash=i(I.hash),this._tag=I.id,this._signType=I.sign}function o(g){e.Writable.call(this);var I=c[g];if(!I)throw new Error("Unknown message digest");this._hash=i(I.hash),this._tag=I.id,this._signType=I.sign}function n(g){return new d(g)}function a(g){return new o(g)}Object.keys(c).forEach((function(g){c[g].id=A.from(c[g].id,"hex"),c[g.toLowerCase()]=c[g]})),l(d,e.Writable),d.prototype._write=function(g,I,C){this._hash.update(g),C()},d.prototype.update=function(g,I){return"string"==typeof g&&(g=A.from(g,I)),this._hash.update(g),this},d.prototype.sign=function(g,I){this.end();var C=this._hash.digest(),A=t(C,g,this._hashType,this._signType,this._tag);return I?A.toString(I):A},l(o,e.Writable),o.prototype._write=function(g,I,C){this._hash.update(g),C()},o.prototype.update=function(g,I){return"string"==typeof g&&(g=A.from(g,I)),this._hash.update(g),this},o.prototype.verify=function(g,I,C){"string"==typeof I&&(I=A.from(I,C)),this.end();var i=this._hash.digest();return s(I,i,g,this._signType,this._tag)},I.exports={Sign:n,Verify:a,createSign:n,createVerify:a}},{"./algorithms.json":211,"./sign":214,"./verify":215,"create-hash":386,inherits:440,"readable-stream":491,"safe-buffer":494}],214:[function(g,I,C){var A=g("safe-buffer").Buffer,i=g("create-hmac"),e=g("browserify-rsa"),l=g("elliptic").ec,t=g("bn.js"),s=g("parse-asn1"),c=g("./curves.json");function d(g,I,C,i,l){var t=s(I);if(t.curve){if("ecdsa"!==i&&"ecdsa/rsa"!==i)throw new Error("wrong private key type");return o(g,t)}if("dsa"===t.type){if("dsa"!==i)throw new Error("wrong private key type");return n(g,t,C)}if("rsa"!==i&&"ecdsa/rsa"!==i)throw new Error("wrong private key type");g=A.concat([l,g]);for(var c=t.modulus.byteLength(),d=[0,1];g.length+d.length+10&&C.ishrn(A),C}function r(g,I){g=(g=b(g,I)).mod(I);var C=A.from(g.toArray());if(C.length=I)throw new Error("invalid sig")}I.exports=s},{"./curves.json":212,"bn.js":186,elliptic:405,"parse-asn1":459,"safe-buffer":494}],216:[function(g,I,C){},{}],217:[function(g,I,C){var A=g("buffer"),i=A.Buffer;function e(g,I){for(var C in g)I[C]=g[C]}function l(g,I,C){return i(g,I,C)}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?I.exports=A:(e(A,C),C.Buffer=l),e(i,l),l.from=function(g,I,C){if("number"==typeof g)throw new TypeError("Argument must not be a number");return i(g,I,C)},l.alloc=function(g,I,C){if("number"!=typeof g)throw new TypeError("Argument must be a number");var A=i(g);return void 0!==I?"string"==typeof C?A.fill(I,C):A.fill(I):A.fill(0),A},l.allocUnsafe=function(g){if("number"!=typeof g)throw new TypeError("Argument must be a number");return i(g)},l.allocUnsafeSlow=function(g){if("number"!=typeof g)throw new TypeError("Argument must be a number");return A.SlowBuffer(g)}},{buffer:220}],218:[function(g,I,C){var A=g("safe-buffer").Buffer,i=A.isEncoding||function(g){switch((g=""+g)&&g.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function e(g){if(!g)return"utf8";for(var I;;)switch(g){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return g;default:if(I)return;g=(""+g).toLowerCase(),I=!0}}function l(g){var I=e(g);if("string"!=typeof I&&(A.isEncoding===i||!i(g)))throw new Error("Unknown encoding: "+g);return I||g}function t(g){var I;switch(this.encoding=l(g),this.encoding){case"utf16le":this.text=Z,this.end=b,I=4;break;case"utf8":this.fillLast=o,I=4;break;case"base64":this.text=r,this.end=m,I=3;break;default:return this.write=h,void(this.end=G)}this.lastNeed=0,this.lastTotal=0,this.lastChar=A.allocUnsafe(I)}function s(g){return g<=127?0:g>>5==6?2:g>>4==14?3:g>>3==30?4:g>>6==2?-1:-2}function c(g,I,C){var A=I.length-1;if(A=0?(i>0&&(g.lastNeed=i-1),i):--A=0?(i>0&&(g.lastNeed=i-2),i):--A=0?(i>0&&(2===i?i=0:g.lastNeed=i-3),i):0}function d(g,I,C){if(128!=(192&I[0]))return g.lastNeed=0,"�";if(g.lastNeed>1&&I.length>1){if(128!=(192&I[1]))return g.lastNeed=1,"�";if(g.lastNeed>2&&I.length>2&&128!=(192&I[2]))return g.lastNeed=2,"�"}}function o(g){var I=this.lastTotal-this.lastNeed,C=d(this,g);return void 0!==C?C:this.lastNeed<=g.length?(g.copy(this.lastChar,I,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(g.copy(this.lastChar,I,0,g.length),void(this.lastNeed-=g.length))}function n(g,I){var C=c(this,g,I);if(!this.lastNeed)return g.toString("utf8",I);this.lastTotal=C;var A=g.length-(C-this.lastNeed);return g.copy(this.lastChar,0,A),g.toString("utf8",I,A)}function a(g){var I=g&&g.length?this.write(g):"";return this.lastNeed?I+"�":I}function Z(g,I){if((g.length-I)%2==0){var C=g.toString("utf16le",I);if(C){var A=C.charCodeAt(C.length-1);if(A>=55296&&A<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=g[g.length-2],this.lastChar[1]=g[g.length-1],C.slice(0,-1)}return C}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=g[g.length-1],g.toString("utf16le",I,g.length-1)}function b(g){var I=g&&g.length?this.write(g):"";if(this.lastNeed){var C=this.lastTotal-this.lastNeed;return I+this.lastChar.toString("utf16le",0,C)}return I}function r(g,I){var C=(g.length-I)%3;return 0===C?g.toString("base64",I):(this.lastNeed=3-C,this.lastTotal=3,1===C?this.lastChar[0]=g[g.length-1]:(this.lastChar[0]=g[g.length-2],this.lastChar[1]=g[g.length-1]),g.toString("base64",I,g.length-C))}function m(g){var I=g&&g.length?this.write(g):"";return this.lastNeed?I+this.lastChar.toString("base64",0,3-this.lastNeed):I}function h(g){return g.toString(this.encoding)}function G(g){return g&&g.length?this.write(g):""}C.StringDecoder=t,t.prototype.write=function(g){if(0===g.length)return"";var I,C;if(this.lastNeed){if(void 0===(I=this.fillLast(g)))return"";C=this.lastNeed,this.lastNeed=0}else C=0;return Ci)throw new RangeError('The value "'+g+'" is invalid for option "size"');var I=new Uint8Array(g);return I.__proto__=t.prototype,I}function t(g,I,C){if("number"==typeof g){if("string"==typeof I)throw new TypeError('The "string" argument must be of type string. Received type number');return o(g)}return s(g,I,C)}function s(g,I,C){if("string"==typeof g)return n(g,I);if(ArrayBuffer.isView(g))return a(g);if(null==g)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof g);if(P(g,ArrayBuffer)||g&&P(g.buffer,ArrayBuffer))return Z(g,I,C);if("number"==typeof g)throw new TypeError('The "value" argument must not be of type number. Received type number');var A=g.valueOf&&g.valueOf();if(null!=A&&A!==g)return t.from(A,I,C);var i=b(g);if(i)return i;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof g[Symbol.toPrimitive])return t.from(g[Symbol.toPrimitive]("string"),I,C);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof g)}function c(g){if("number"!=typeof g)throw new TypeError('"size" argument must be of type number');if(g<0)throw new RangeError('The value "'+g+'" is invalid for option "size"')}function d(g,I,C){return c(g),g<=0?l(g):void 0!==I?"string"==typeof C?l(g).fill(I,C):l(g).fill(I):l(g)}function o(g){return c(g),l(g<0?0:0|r(g))}function n(g,I){if("string"==typeof I&&""!==I||(I="utf8"),!t.isEncoding(I))throw new TypeError("Unknown encoding: "+I);var C=0|h(g,I),A=l(C),i=A.write(g,I);return i!==C&&(A=A.slice(0,i)),A}function a(g){for(var I=g.length<0?0:0|r(g.length),C=l(I),A=0;A=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return 0|g}function m(g){return+g!=g&&(g=0),t.alloc(+g)}function h(g,I){if(t.isBuffer(g))return g.length;if(ArrayBuffer.isView(g)||P(g,ArrayBuffer))return g.byteLength;if("string"!=typeof g)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof g);var C=g.length,A=arguments.length>2&&!0===arguments[2];if(!A&&0===C)return 0;for(var i=!1;;)switch(I){case"ascii":case"latin1":case"binary":return C;case"utf8":case"utf-8":return U(g).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*C;case"hex":return C>>>1;case"base64":return O(g).length;default:if(i)return A?-1:U(g).length;I=(""+I).toLowerCase(),i=!0}}function G(g,I,C){var A=!1;if((void 0===I||I<0)&&(I=0),I>this.length)return"";if((void 0===C||C>this.length)&&(C=this.length),C<=0)return"";if((C>>>=0)<=(I>>>=0))return"";for(g||(g="utf8");;)switch(g){case"hex":return J(this,I,C);case"utf8":case"utf-8":return N(this,I,C);case"ascii":return F(this,I,C);case"latin1":case"binary":return M(this,I,C);case"base64":return R(this,I,C);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return S(this,I,C);default:if(A)throw new TypeError("Unknown encoding: "+g);g=(g+"").toLowerCase(),A=!0}}function u(g,I,C){var A=g[I];g[I]=g[C],g[C]=A}function B(g,I,C,A,i){if(0===g.length)return-1;if("string"==typeof C?(A=C,C=0):C>2147483647?C=2147483647:C<-2147483648&&(C=-2147483648),_(C=+C)&&(C=i?0:g.length-1),C<0&&(C=g.length+C),C>=g.length){if(i)return-1;C=g.length-1}else if(C<0){if(!i)return-1;C=0}if("string"==typeof I&&(I=t.from(I,A)),t.isBuffer(I))return 0===I.length?-1:w(g,I,C,A,i);if("number"==typeof I)return I&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(g,I,C):Uint8Array.prototype.lastIndexOf.call(g,I,C):w(g,[I],C,A,i);throw new TypeError("val must be string, number or Buffer")}function w(g,I,C,A,i){var e,l=1,t=g.length,s=I.length;if(void 0!==A&&("ucs2"===(A=String(A).toLowerCase())||"ucs-2"===A||"utf16le"===A||"utf-16le"===A)){if(g.length<2||I.length<2)return-1;l=2,t/=2,s/=2,C/=2}function c(g,I){return 1===l?g[I]:g.readUInt16BE(I*l)}if(i){var d=-1;for(e=C;et&&(C=t-s),e=C;e>=0;e--){for(var o=!0,n=0;ni&&(A=i):A=i;var e=I.length;A>e/2&&(A=e/2);for(var l=0;l239?4:c>223?3:c>191?2:1;if(i+o<=C)switch(o){case 1:c<128&&(d=c);break;case 2:128==(192&(e=g[i+1]))&&(s=(31&c)<<6|63&e)>127&&(d=s);break;case 3:e=g[i+1],l=g[i+2],128==(192&e)&&128==(192&l)&&(s=(15&c)<<12|(63&e)<<6|63&l)>2047&&(s<55296||s>57343)&&(d=s);break;case 4:e=g[i+1],l=g[i+2],t=g[i+3],128==(192&e)&&128==(192&l)&&128==(192&t)&&(s=(15&c)<<18|(63&e)<<12|(63&l)<<6|63&t)>65535&&s<1114112&&(d=s)}null===d?(d=65533,o=1):d>65535&&(d-=65536,A.push(d>>>10&1023|55296),d=56320|1023&d),A.push(d),i+=o}return K(A)}C.kMaxLength=i,t.TYPED_ARRAY_SUPPORT=e(),t.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(t.prototype,"parent",{enumerable:!0,get:function(){if(t.isBuffer(this))return this.buffer}}),Object.defineProperty(t.prototype,"offset",{enumerable:!0,get:function(){if(t.isBuffer(this))return this.byteOffset}}),"undefined"!=typeof Symbol&&null!=Symbol.species&&t[Symbol.species]===t&&Object.defineProperty(t,Symbol.species,{value:null,configurable:!0,enumerable:!1,writable:!1}),t.poolSize=8192,t.from=function(g,I,C){return s(g,I,C)},t.prototype.__proto__=Uint8Array.prototype,t.__proto__=Uint8Array,t.alloc=function(g,I,C){return d(g,I,C)},t.allocUnsafe=function(g){return o(g)},t.allocUnsafeSlow=function(g){return o(g)},t.isBuffer=function(g){return null!=g&&!0===g._isBuffer&&g!==t.prototype},t.compare=function(g,I){if(P(g,Uint8Array)&&(g=t.from(g,g.offset,g.byteLength)),P(I,Uint8Array)&&(I=t.from(I,I.offset,I.byteLength)),!t.isBuffer(g)||!t.isBuffer(I))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(g===I)return 0;for(var C=g.length,A=I.length,i=0,e=Math.min(C,A);iI&&(g+=" ... "),""},t.prototype.compare=function(g,I,C,A,i){if(P(g,Uint8Array)&&(g=t.from(g,g.offset,g.byteLength)),!t.isBuffer(g))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof g);if(void 0===I&&(I=0),void 0===C&&(C=g?g.length:0),void 0===A&&(A=0),void 0===i&&(i=this.length),I<0||C>g.length||A<0||i>this.length)throw new RangeError("out of range index");if(A>=i&&I>=C)return 0;if(A>=i)return-1;if(I>=C)return 1;if(this===g)return 0;for(var e=(i>>>=0)-(A>>>=0),l=(C>>>=0)-(I>>>=0),s=Math.min(e,l),c=this.slice(A,i),d=g.slice(I,C),o=0;o>>=0,isFinite(C)?(C>>>=0,void 0===A&&(A="utf8")):(A=C,C=void 0)}var i=this.length-I;if((void 0===C||C>i)&&(C=i),g.length>0&&(C<0||I<0)||I>this.length)throw new RangeError("Attempt to write outside buffer bounds");A||(A="utf8");for(var e=!1;;)switch(A){case"hex":return W(this,g,I,C);case"utf8":case"utf-8":return p(this,g,I,C);case"ascii":return V(this,g,I,C);case"latin1":case"binary":return y(this,g,I,C);case"base64":return X(this,g,I,C);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Y(this,g,I,C);default:if(e)throw new TypeError("Unknown encoding: "+A);A=(""+A).toLowerCase(),e=!0}},t.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var H=4096;function K(g){var I=g.length;if(I<=H)return String.fromCharCode.apply(String,g);for(var C="",A=0;AA)&&(C=A);for(var i="",e=I;eC)throw new RangeError("Trying to access beyond buffer length")}function k(g,I,C,A,i,e){if(!t.isBuffer(g))throw new TypeError('"buffer" argument must be a Buffer instance');if(I>i||Ig.length)throw new RangeError("Index out of range")}function D(g,I,C,A,i,e){if(C+A>g.length)throw new RangeError("Index out of range");if(C<0)throw new RangeError("Index out of range")}function L(g,I,C,i,e){return I=+I,C>>>=0,e||D(g,I,C,4),A.write(g,I,C,i,23,4),C+4}function z(g,I,C,i,e){return I=+I,C>>>=0,e||D(g,I,C,8),A.write(g,I,C,i,52,8),C+8}t.prototype.slice=function(g,I){var C=this.length;(g=~~g)<0?(g+=C)<0&&(g=0):g>C&&(g=C),(I=void 0===I?C:~~I)<0?(I+=C)<0&&(I=0):I>C&&(I=C),I>>=0,I>>>=0,C||f(g,I,this.length);for(var A=this[g],i=1,e=0;++e>>=0,I>>>=0,C||f(g,I,this.length);for(var A=this[g+--I],i=1;I>0&&(i*=256);)A+=this[g+--I]*i;return A},t.prototype.readUInt8=function(g,I){return g>>>=0,I||f(g,1,this.length),this[g]},t.prototype.readUInt16LE=function(g,I){return g>>>=0,I||f(g,2,this.length),this[g]|this[g+1]<<8},t.prototype.readUInt16BE=function(g,I){return g>>>=0,I||f(g,2,this.length),this[g]<<8|this[g+1]},t.prototype.readUInt32LE=function(g,I){return g>>>=0,I||f(g,4,this.length),(this[g]|this[g+1]<<8|this[g+2]<<16)+16777216*this[g+3]},t.prototype.readUInt32BE=function(g,I){return g>>>=0,I||f(g,4,this.length),16777216*this[g]+(this[g+1]<<16|this[g+2]<<8|this[g+3])},t.prototype.readIntLE=function(g,I,C){g>>>=0,I>>>=0,C||f(g,I,this.length);for(var A=this[g],i=1,e=0;++e=(i*=128)&&(A-=Math.pow(2,8*I)),A},t.prototype.readIntBE=function(g,I,C){g>>>=0,I>>>=0,C||f(g,I,this.length);for(var A=I,i=1,e=this[g+--A];A>0&&(i*=256);)e+=this[g+--A]*i;return e>=(i*=128)&&(e-=Math.pow(2,8*I)),e},t.prototype.readInt8=function(g,I){return g>>>=0,I||f(g,1,this.length),128&this[g]?-1*(255-this[g]+1):this[g]},t.prototype.readInt16LE=function(g,I){g>>>=0,I||f(g,2,this.length);var C=this[g]|this[g+1]<<8;return 32768&C?4294901760|C:C},t.prototype.readInt16BE=function(g,I){g>>>=0,I||f(g,2,this.length);var C=this[g+1]|this[g]<<8;return 32768&C?4294901760|C:C},t.prototype.readInt32LE=function(g,I){return g>>>=0,I||f(g,4,this.length),this[g]|this[g+1]<<8|this[g+2]<<16|this[g+3]<<24},t.prototype.readInt32BE=function(g,I){return g>>>=0,I||f(g,4,this.length),this[g]<<24|this[g+1]<<16|this[g+2]<<8|this[g+3]},t.prototype.readFloatLE=function(g,I){return g>>>=0,I||f(g,4,this.length),A.read(this,g,!0,23,4)},t.prototype.readFloatBE=function(g,I){return g>>>=0,I||f(g,4,this.length),A.read(this,g,!1,23,4)},t.prototype.readDoubleLE=function(g,I){return g>>>=0,I||f(g,8,this.length),A.read(this,g,!0,52,8)},t.prototype.readDoubleBE=function(g,I){return g>>>=0,I||f(g,8,this.length),A.read(this,g,!1,52,8)},t.prototype.writeUIntLE=function(g,I,C,A){g=+g,I>>>=0,C>>>=0,A||k(this,g,I,C,Math.pow(2,8*C)-1,0);var i=1,e=0;for(this[I]=255&g;++e>>=0,C>>>=0,A||k(this,g,I,C,Math.pow(2,8*C)-1,0);var i=C-1,e=1;for(this[I+i]=255&g;--i>=0&&(e*=256);)this[I+i]=g/e&255;return I+C},t.prototype.writeUInt8=function(g,I,C){return g=+g,I>>>=0,C||k(this,g,I,1,255,0),this[I]=255&g,I+1},t.prototype.writeUInt16LE=function(g,I,C){return g=+g,I>>>=0,C||k(this,g,I,2,65535,0),this[I]=255&g,this[I+1]=g>>>8,I+2},t.prototype.writeUInt16BE=function(g,I,C){return g=+g,I>>>=0,C||k(this,g,I,2,65535,0),this[I]=g>>>8,this[I+1]=255&g,I+2},t.prototype.writeUInt32LE=function(g,I,C){return g=+g,I>>>=0,C||k(this,g,I,4,4294967295,0),this[I+3]=g>>>24,this[I+2]=g>>>16,this[I+1]=g>>>8,this[I]=255&g,I+4},t.prototype.writeUInt32BE=function(g,I,C){return g=+g,I>>>=0,C||k(this,g,I,4,4294967295,0),this[I]=g>>>24,this[I+1]=g>>>16,this[I+2]=g>>>8,this[I+3]=255&g,I+4},t.prototype.writeIntLE=function(g,I,C,A){if(g=+g,I>>>=0,!A){var i=Math.pow(2,8*C-1);k(this,g,I,C,i-1,-i)}var e=0,l=1,t=0;for(this[I]=255&g;++e>>=0,!A){var i=Math.pow(2,8*C-1);k(this,g,I,C,i-1,-i)}var e=C-1,l=1,t=0;for(this[I+e]=255&g;--e>=0&&(l*=256);)g<0&&0===t&&0!==this[I+e+1]&&(t=1),this[I+e]=(g/l|0)-t&255;return I+C},t.prototype.writeInt8=function(g,I,C){return g=+g,I>>>=0,C||k(this,g,I,1,127,-128),g<0&&(g=255+g+1),this[I]=255&g,I+1},t.prototype.writeInt16LE=function(g,I,C){return g=+g,I>>>=0,C||k(this,g,I,2,32767,-32768),this[I]=255&g,this[I+1]=g>>>8,I+2},t.prototype.writeInt16BE=function(g,I,C){return g=+g,I>>>=0,C||k(this,g,I,2,32767,-32768),this[I]=g>>>8,this[I+1]=255&g,I+2},t.prototype.writeInt32LE=function(g,I,C){return g=+g,I>>>=0,C||k(this,g,I,4,2147483647,-2147483648),this[I]=255&g,this[I+1]=g>>>8,this[I+2]=g>>>16,this[I+3]=g>>>24,I+4},t.prototype.writeInt32BE=function(g,I,C){return g=+g,I>>>=0,C||k(this,g,I,4,2147483647,-2147483648),g<0&&(g=4294967295+g+1),this[I]=g>>>24,this[I+1]=g>>>16,this[I+2]=g>>>8,this[I+3]=255&g,I+4},t.prototype.writeFloatLE=function(g,I,C){return L(this,g,I,!0,C)},t.prototype.writeFloatBE=function(g,I,C){return L(this,g,I,!1,C)},t.prototype.writeDoubleLE=function(g,I,C){return z(this,g,I,!0,C)},t.prototype.writeDoubleBE=function(g,I,C){return z(this,g,I,!1,C)},t.prototype.copy=function(g,I,C,A){if(!t.isBuffer(g))throw new TypeError("argument should be a Buffer");if(C||(C=0),A||0===A||(A=this.length),I>=g.length&&(I=g.length),I||(I=0),A>0&&A=this.length)throw new RangeError("Index out of range");if(A<0)throw new RangeError("sourceEnd out of bounds");A>this.length&&(A=this.length),g.length-I=0;--e)g[e+I]=this[e+C];else Uint8Array.prototype.set.call(g,this.subarray(C,A),I);return i},t.prototype.fill=function(g,I,C,A){if("string"==typeof g){if("string"==typeof I?(A=I,I=0,C=this.length):"string"==typeof C&&(A=C,C=this.length),void 0!==A&&"string"!=typeof A)throw new TypeError("encoding must be a string");if("string"==typeof A&&!t.isEncoding(A))throw new TypeError("Unknown encoding: "+A);if(1===g.length){var i=g.charCodeAt(0);("utf8"===A&&i<128||"latin1"===A)&&(g=i)}}else"number"==typeof g&&(g&=255);if(I<0||this.length>>=0,C=void 0===C?this.length:C>>>0,g||(g=0),"number"==typeof g)for(e=I;e55295&&C<57344){if(!i){if(C>56319){(I-=3)>-1&&e.push(239,191,189);continue}if(l+1===A){(I-=3)>-1&&e.push(239,191,189);continue}i=C;continue}if(C<56320){(I-=3)>-1&&e.push(239,191,189),i=C;continue}C=65536+(i-55296<<10|C-56320)}else i&&(I-=3)>-1&&e.push(239,191,189);if(i=null,C<128){if((I-=1)<0)break;e.push(C)}else if(C<2048){if((I-=2)<0)break;e.push(C>>6|192,63&C|128)}else if(C<65536){if((I-=3)<0)break;e.push(C>>12|224,C>>6&63|128,63&C|128)}else{if(!(C<1114112))throw new Error("Invalid code point");if((I-=4)<0)break;e.push(C>>18|240,C>>12&63|128,C>>6&63|128,63&C|128)}}return e}function Q(g){for(var I=[],C=0;C>8,i=C%256,e.push(i),e.push(A);return e}function O(g){return I.toByteArray(T(g))}function E(g,I,C,A){for(var i=0;i=I.length||i>=g.length);++i)I[i+C]=g[i];return i}function P(g,I){return g instanceof I||null!=g&&null!=g.constructor&&null!=g.constructor.name&&g.constructor.name===I.name}function _(g){return g!=g}}).call(this)}).call(this,g("buffer").Buffer)},{"base64-js":185,buffer:220,ieee754:439}],221:[function(g,I,C){var A=g("safe-buffer").Buffer,i=g("stream").Transform,e=g("string_decoder").StringDecoder;function l(g){i.call(this),this.hashMode="string"==typeof g,this.hashMode?this[g]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}g("inherits")(l,i),l.prototype.update=function(g,I,C){"string"==typeof g&&(g=A.from(g,I));var i=this._update(g);return this.hashMode?this:(C&&(i=this._toString(i,C)),i)},l.prototype.setAutoPadding=function(){},l.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")},l.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")},l.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")},l.prototype._transform=function(g,I,C){var A;try{this.hashMode?this._update(g):this.push(this._update(g))}catch(i){A=i}finally{C(A)}},l.prototype._flush=function(g){var I;try{this.push(this.__final())}catch(C){I=C}g(I)},l.prototype._finalOrDigest=function(g){var I=this.__final()||A.alloc(0);return g&&(I=this._toString(I,g,!0)),I},l.prototype._toString=function(g,I,C){if(this._decoder||(this._decoder=new e(I),this._encoding=I),this._encoding!==I)throw new Error("can't switch encodings");var A=this._decoder.write(g);return C&&(A+=this._decoder.end()),A},I.exports=l},{inherits:440,"safe-buffer":494,stream:505,string_decoder:218}],222:[function(g,I,C){var A=g("../internals/is-callable"),i=g("../internals/try-to-string"),e=TypeError;I.exports=function(g){if(A(g))return g;throw new e(i(g)+" is not a function")}},{"../internals/is-callable":285,"../internals/try-to-string":349}],223:[function(g,I,C){var A=g("../internals/is-constructor"),i=g("../internals/try-to-string"),e=TypeError;I.exports=function(g){if(A(g))return g;throw new e(i(g)+" is not a constructor")}},{"../internals/is-constructor":286,"../internals/try-to-string":349}],224:[function(g,I,C){var A=g("../internals/is-callable"),i=String,e=TypeError;I.exports=function(g){if("object"==typeof g||A(g))return g;throw new e("Can't set "+i(g)+" as a prototype")}},{"../internals/is-callable":285}],225:[function(g,I,C){var A=g("../internals/well-known-symbol"),i=g("../internals/object-create"),e=g("../internals/object-define-property").f,l=A("unscopables"),t=Array.prototype;void 0===t[l]&&e(t,l,{configurable:!0,value:i(null)}),I.exports=function(g){t[l][g]=!0}},{"../internals/object-create":306,"../internals/object-define-property":308,"../internals/well-known-symbol":357}],226:[function(g,I,C){var A=g("../internals/object-is-prototype-of"),i=TypeError;I.exports=function(g,I){if(A(I,g))return g;throw new i("Incorrect invocation")}},{"../internals/object-is-prototype-of":314}],227:[function(g,I,C){var A=g("../internals/is-object"),i=String,e=TypeError;I.exports=function(g){if(A(g))return g;throw new e(i(g)+" is not an object")}},{"../internals/is-object":289}],228:[function(g,I,C){var A=g("../internals/to-indexed-object"),i=g("../internals/to-absolute-index"),e=g("../internals/length-of-array-like"),l=function(g){return function(I,C,l){var t,s=A(I),c=e(s),d=i(l,c);if(g&&C!=C){for(;c>d;)if((t=s[d++])!=t)return!0}else for(;c>d;d++)if((g||d in s)&&s[d]===C)return g||d||0;return!g&&-1}};I.exports={includes:l(!0),indexOf:l(!1)}},{"../internals/length-of-array-like":299,"../internals/to-absolute-index":340,"../internals/to-indexed-object":341}],229:[function(g,I,C){var A=g("../internals/function-bind-context"),i=g("../internals/function-uncurry-this"),e=g("../internals/indexed-object"),l=g("../internals/to-object"),t=g("../internals/length-of-array-like"),s=g("../internals/array-species-create"),c=i([].push),d=function(g){var I=1===g,C=2===g,i=3===g,d=4===g,o=6===g,n=7===g,a=5===g||o;return function(Z,b,r,m){for(var h,G,u=l(Z),B=e(u),w=A(b,r),W=t(B),p=0,V=m||s,y=I?V(Z,W):C||n?V(Z,0):void 0;W>p;p++)if((a||p in B)&&(G=w(h=B[p],p,u),g))if(I)y[p]=G;else if(G)switch(g){case 3:return!0;case 5:return h;case 6:return p;case 2:c(y,h)}else switch(g){case 4:return!1;case 7:c(y,h)}return o?-1:i||d?d:y}};I.exports={forEach:d(0),map:d(1),filter:d(2),some:d(3),every:d(4),find:d(5),findIndex:d(6),filterReject:d(7)}},{"../internals/array-species-create":233,"../internals/function-bind-context":262,"../internals/function-uncurry-this":268,"../internals/indexed-object":280,"../internals/length-of-array-like":299,"../internals/to-object":344}],230:[function(g,I,C){var A=g("../internals/to-absolute-index"),i=g("../internals/length-of-array-like"),e=g("../internals/create-property"),l=Array,t=Math.max;I.exports=function(g,I,C){for(var s=i(g),c=A(I,s),d=A(void 0===C?s:C,s),o=l(t(d-c,0)),n=0;c0&&A[0]<4?1:+(A[0]+A[1])),!i&&l&&(!(A=l.match(/Edge\/(\d+)/))||A[1]>=74)&&(A=l.match(/Chrome\/(\d+)/))&&(i=+A[1]),I.exports=i},{"../internals/engine-user-agent":256,"../internals/global":274}],258:[function(g,I,C){I.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]},{}],259:[function(g,I,C){var A=g("../internals/global"),i=g("../internals/object-get-own-property-descriptor").f,e=g("../internals/create-non-enumerable-property"),l=g("../internals/define-built-in"),t=g("../internals/define-global-property"),s=g("../internals/copy-constructor-properties"),c=g("../internals/is-forced");I.exports=function(g,I){var C,d,o,n,a,Z=g.target,b=g.global,r=g.stat;if(C=b?A:r?A[Z]||t(Z,{}):(A[Z]||{}).prototype)for(d in I){if(n=I[d],o=g.dontCallGetSet?(a=i(C,d))&&a.value:C[d],!c(b?d:Z+(r?".":"#")+d,g.forced)&&void 0!==o){if(typeof n==typeof o)continue;s(n,o)}(g.sham||o&&o.sham)&&e(n,"sham",!0),l(C,d,n,g)}}},{"../internals/copy-constructor-properties":237,"../internals/create-non-enumerable-property":241,"../internals/define-built-in":245,"../internals/define-global-property":246,"../internals/global":274,"../internals/is-forced":287,"../internals/object-get-own-property-descriptor":309}],260:[function(g,I,C){I.exports=function(g){try{return!!g()}catch(I){return!0}}},{}],261:[function(g,I,C){var A=g("../internals/function-bind-native"),i=Function.prototype,e=i.apply,l=i.call;I.exports="object"==typeof Reflect&&Reflect.apply||(A?l.bind(e):function(){return l.apply(e,arguments)})},{"../internals/function-bind-native":263}],262:[function(g,I,C){var A=g("../internals/function-uncurry-this-clause"),i=g("../internals/a-callable"),e=g("../internals/function-bind-native"),l=A(A.bind);I.exports=function(g,I){return i(g),void 0===I?g:e?l(g,I):function(){return g.apply(I,arguments)}}},{"../internals/a-callable":222,"../internals/function-bind-native":263,"../internals/function-uncurry-this-clause":267}],263:[function(g,I,C){var A=g("../internals/fails");I.exports=!A((function(){var g=function(){}.bind();return"function"!=typeof g||g.hasOwnProperty("prototype")}))},{"../internals/fails":260}],264:[function(g,I,C){var A=g("../internals/function-bind-native"),i=Function.prototype.call;I.exports=A?i.bind(i):function(){return i.apply(i,arguments)}},{"../internals/function-bind-native":263}],265:[function(g,I,C){var A=g("../internals/descriptors"),i=g("../internals/has-own-property"),e=Function.prototype,l=A&&Object.getOwnPropertyDescriptor,t=i(e,"name"),s=t&&"something"===function(){}.name,c=t&&(!A||A&&l(e,"name").configurable);I.exports={EXISTS:t,PROPER:s,CONFIGURABLE:c}},{"../internals/descriptors":247,"../internals/has-own-property":275}],266:[function(g,I,C){var A=g("../internals/function-uncurry-this"),i=g("../internals/a-callable");I.exports=function(g,I,C){try{return A(i(Object.getOwnPropertyDescriptor(g,I)[C]))}catch(e){}}},{"../internals/a-callable":222,"../internals/function-uncurry-this":268}],267:[function(g,I,C){var A=g("../internals/classof-raw"),i=g("../internals/function-uncurry-this");I.exports=function(g){if("Function"===A(g))return i(g)}},{"../internals/classof-raw":235,"../internals/function-uncurry-this":268}],268:[function(g,I,C){var A=g("../internals/function-bind-native"),i=Function.prototype,e=i.call,l=A&&i.bind.bind(e,e);I.exports=A?l:function(g){return function(){return e.apply(g,arguments)}}},{"../internals/function-bind-native":263}],269:[function(g,I,C){var A=g("../internals/global"),i=g("../internals/is-callable"),e=function(g){return i(g)?g:void 0};I.exports=function(g,I){return arguments.length<2?e(A[g]):A[g]&&A[g][I]}},{"../internals/global":274,"../internals/is-callable":285}],270:[function(g,I,C){var A=g("../internals/classof"),i=g("../internals/get-method"),e=g("../internals/is-null-or-undefined"),l=g("../internals/iterators"),t=g("../internals/well-known-symbol")("iterator");I.exports=function(g){if(!e(g))return i(g,t)||i(g,"@@iterator")||l[A(g)]}},{"../internals/classof":236,"../internals/get-method":273,"../internals/is-null-or-undefined":288,"../internals/iterators":298,"../internals/well-known-symbol":357}],271:[function(g,I,C){var A=g("../internals/function-call"),i=g("../internals/a-callable"),e=g("../internals/an-object"),l=g("../internals/try-to-string"),t=g("../internals/get-iterator-method"),s=TypeError;I.exports=function(g,I){var C=arguments.length<2?t(g):I;if(i(C))return e(A(C,g));throw new s(l(g)+" is not iterable")}},{"../internals/a-callable":222,"../internals/an-object":227,"../internals/function-call":264,"../internals/get-iterator-method":270,"../internals/try-to-string":349}],272:[function(g,I,C){var A=g("../internals/function-uncurry-this"),i=g("../internals/is-array"),e=g("../internals/is-callable"),l=g("../internals/classof-raw"),t=g("../internals/to-string"),s=A([].push);I.exports=function(g){if(e(g))return g;if(i(g)){for(var I=g.length,C=[],A=0;Ah;h++)if((u=N(g[h]))&&c(b,u))return u;return new Z(!1)}r=d(g,m)}for(B=V?g.next:r.next;!(w=i(B,r)).done;){try{u=N(w.value)}catch(H){n(r,"throw",H)}if("object"==typeof u&&u&&c(b,u))return u}return new Z(!1)}},{"../internals/an-object":227,"../internals/function-bind-context":262,"../internals/function-call":264,"../internals/get-iterator":271,"../internals/get-iterator-method":270,"../internals/is-array-iterator-method":283,"../internals/iterator-close":294,"../internals/length-of-array-like":299,"../internals/object-is-prototype-of":314,"../internals/try-to-string":349}],294:[function(g,I,C){var A=g("../internals/function-call"),i=g("../internals/an-object"),e=g("../internals/get-method");I.exports=function(g,I,C){var l,t;i(g);try{if(!(l=e(g,"return"))){if("throw"===I)throw C;return C}l=A(l,g)}catch(s){t=!0,l=s}if("throw"===I)throw C;if(t)throw l;return i(l),C}},{"../internals/an-object":227,"../internals/function-call":264,"../internals/get-method":273}],295:[function(g,I,C){var A=g("../internals/iterators-core").IteratorPrototype,i=g("../internals/object-create"),e=g("../internals/create-property-descriptor"),l=g("../internals/set-to-string-tag"),t=g("../internals/iterators"),s=function(){return this};I.exports=function(g,I,C,c){var d=I+" Iterator";return g.prototype=i(A,{next:e(+!c,C)}),l(g,d,!1,!0),t[d]=s,g}},{"../internals/create-property-descriptor":242,"../internals/iterators":298,"../internals/iterators-core":297,"../internals/object-create":306,"../internals/set-to-string-tag":331}],296:[function(g,I,C){var A=g("../internals/export"),i=g("../internals/function-call"),e=g("../internals/is-pure"),l=g("../internals/function-name"),t=g("../internals/is-callable"),s=g("../internals/iterator-create-constructor"),c=g("../internals/object-get-prototype-of"),d=g("../internals/object-set-prototype-of"),o=g("../internals/set-to-string-tag"),n=g("../internals/create-non-enumerable-property"),a=g("../internals/define-built-in"),Z=g("../internals/well-known-symbol"),b=g("../internals/iterators"),r=g("../internals/iterators-core"),m=l.PROPER,h=l.CONFIGURABLE,G=r.IteratorPrototype,u=r.BUGGY_SAFARI_ITERATORS,B=Z("iterator"),w="keys",W="values",p="entries",V=function(){return this};I.exports=function(g,I,C,l,Z,r,y){s(C,I,l);var X,Y,R,N=function(g){if(g===Z&&J)return J;if(!u&&g&&g in F)return F[g];switch(g){case w:case W:case p:return function(){return new C(this,g)}}return function(){return new C(this)}},H=I+" Iterator",K=!1,F=g.prototype,M=F[B]||F["@@iterator"]||Z&&F[Z],J=!u&&M||N(Z),S="Array"===I&&F.entries||M;if(S&&(X=c(S.call(new g)))!==Object.prototype&&X.next&&(e||c(X)===G||(d?d(X,G):t(X[B])||a(X,B,V)),o(X,H,!0,!0),e&&(b[H]=V)),m&&Z===W&&M&&M.name!==W&&(!e&&h?n(F,"name",W):(K=!0,J=function(){return i(M,this)})),Z)if(Y={values:N(W),keys:r?J:N(w),entries:N(p)},y)for(R in Y)(u||K||!(R in F))&&a(F,R,Y[R]);else A({target:I,proto:!0,forced:u||K},Y);return e&&!y||F[B]===J||a(F,B,J,{name:Z}),b[I]=J,Y}},{"../internals/create-non-enumerable-property":241,"../internals/define-built-in":245,"../internals/export":259,"../internals/function-call":264,"../internals/function-name":265,"../internals/is-callable":285,"../internals/is-pure":290,"../internals/iterator-create-constructor":295,"../internals/iterators":298,"../internals/iterators-core":297,"../internals/object-get-prototype-of":313,"../internals/object-set-prototype-of":318,"../internals/set-to-string-tag":331,"../internals/well-known-symbol":357}],297:[function(g,I,C){var A,i,e,l=g("../internals/fails"),t=g("../internals/is-callable"),s=g("../internals/is-object"),c=g("../internals/object-create"),d=g("../internals/object-get-prototype-of"),o=g("../internals/define-built-in"),n=g("../internals/well-known-symbol"),a=g("../internals/is-pure"),Z=n("iterator"),b=!1;[].keys&&("next"in(e=[].keys())?(i=d(d(e)))!==Object.prototype&&(A=i):b=!0),!s(A)||l((function(){var g={};return A[Z].call(g)!==g}))?A={}:a&&(A=c(A)),t(A[Z])||o(A,Z,(function(){return this})),I.exports={IteratorPrototype:A,BUGGY_SAFARI_ITERATORS:b}},{"../internals/define-built-in":245,"../internals/fails":260,"../internals/is-callable":285,"../internals/is-object":289,"../internals/is-pure":290,"../internals/object-create":306,"../internals/object-get-prototype-of":313,"../internals/well-known-symbol":357}],298:[function(g,I,C){arguments[4][276][0].apply(C,arguments)},{dup:276}],299:[function(g,I,C){var A=g("../internals/to-length");I.exports=function(g){return A(g.length)}},{"../internals/to-length":343}],300:[function(g,I,C){var A=g("../internals/function-uncurry-this"),i=g("../internals/fails"),e=g("../internals/is-callable"),l=g("../internals/has-own-property"),t=g("../internals/descriptors"),s=g("../internals/function-name").CONFIGURABLE,c=g("../internals/inspect-source"),d=g("../internals/internal-state"),o=d.enforce,n=d.get,a=String,Z=Object.defineProperty,b=A("".slice),r=A("".replace),m=A([].join),h=t&&!i((function(){return 8!==Z((function(){}),"length",{value:8}).length})),G=String(String).split("String"),u=I.exports=function(g,I,C){"Symbol("===b(a(I),0,7)&&(I="["+r(a(I),/^Symbol\(([^)]*)\)/,"$1")+"]"),C&&C.getter&&(I="get "+I),C&&C.setter&&(I="set "+I),(!l(g,"name")||s&&g.name!==I)&&(t?Z(g,"name",{value:I,configurable:!0}):g.name=I),h&&C&&l(C,"arity")&&g.length!==C.arity&&Z(g,"length",{value:C.arity});try{C&&l(C,"constructor")&&C.constructor?t&&Z(g,"prototype",{writable:!1}):g.prototype&&(g.prototype=void 0)}catch(i){}var A=o(g);return l(A,"source")||(A.source=m(G,"string"==typeof I?I:"")),g};Function.prototype.toString=u((function(){return e(this)&&n(this).source||c(this)}),"toString")},{"../internals/descriptors":247,"../internals/fails":260,"../internals/function-name":265,"../internals/function-uncurry-this":268,"../internals/has-own-property":275,"../internals/inspect-source":281,"../internals/internal-state":282,"../internals/is-callable":285}],301:[function(g,I,C){var A=Math.ceil,i=Math.floor;I.exports=Math.trunc||function(g){var I=+g;return(I>0?i:A)(I)}},{}],302:[function(g,I,C){var A,i,e,l,t,s=g("../internals/global"),c=g("../internals/function-bind-context"),d=g("../internals/object-get-own-property-descriptor").f,o=g("../internals/task").set,n=g("../internals/queue"),a=g("../internals/engine-is-ios"),Z=g("../internals/engine-is-ios-pebble"),b=g("../internals/engine-is-webos-webkit"),r=g("../internals/engine-is-node"),m=s.MutationObserver||s.WebKitMutationObserver,h=s.document,G=s.process,u=s.Promise,B=d(s,"queueMicrotask"),w=B&&B.value;if(!w){var W=new n,p=function(){var g,I;for(r&&(g=G.domain)&&g.exit();I=W.get();)try{I()}catch(C){throw W.head&&A(),C}g&&g.enter()};a||r||b||!m||!h?!Z&&u&&u.resolve?((l=u.resolve(void 0)).constructor=u,t=c(l.then,l),A=function(){t(p)}):r?A=function(){G.nextTick(p)}:(o=c(o,s),A=function(){o(p)}):(i=!0,e=h.createTextNode(""),new m(p).observe(e,{characterData:!0}),A=function(){e.data=i=!i}),w=function(g){W.head||A(),W.add(g)}}I.exports=w},{"../internals/engine-is-ios":253,"../internals/engine-is-ios-pebble":252,"../internals/engine-is-node":254,"../internals/engine-is-webos-webkit":255,"../internals/function-bind-context":262,"../internals/global":274,"../internals/object-get-own-property-descriptor":309,"../internals/queue":328,"../internals/task":339}],303:[function(g,I,C){var A=g("../internals/a-callable"),i=TypeError,e=function(g){var I,C;this.promise=new g((function(g,A){if(void 0!==I||void 0!==C)throw new i("Bad Promise constructor");I=g,C=A})),this.resolve=A(I),this.reject=A(C)};I.exports.f=function(g){return new e(g)}},{"../internals/a-callable":222}],304:[function(g,I,C){var A=g("../internals/is-regexp"),i=TypeError;I.exports=function(g){if(A(g))throw new i("The method doesn't accept regular expressions");return g}},{"../internals/is-regexp":291}],305:[function(g,I,C){var A=g("../internals/descriptors"),i=g("../internals/function-uncurry-this"),e=g("../internals/function-call"),l=g("../internals/fails"),t=g("../internals/object-keys"),s=g("../internals/object-get-own-property-symbols"),c=g("../internals/object-property-is-enumerable"),d=g("../internals/to-object"),o=g("../internals/indexed-object"),n=Object.assign,a=Object.defineProperty,Z=i([].concat);I.exports=!n||l((function(){if(A&&1!==n({b:1},n(a({},"a",{enumerable:!0,get:function(){a(this,"b",{value:3,enumerable:!1})}}),{b:2})).b)return!0;var g={},I={},C=Symbol("assign detection"),i="abcdefghijklmnopqrst";return g[C]=7,i.split("").forEach((function(g){I[g]=g})),7!==n({},g)[C]||t(n({},I)).join("")!==i}))?function(g,I){for(var C=d(g),i=arguments.length,l=1,n=s.f,a=c.f;i>l;)for(var b,r=o(arguments[l++]),m=n?Z(t(r),n(r)):t(r),h=m.length,G=0;h>G;)b=m[G++],A&&!e(a,r,b)||(C[b]=r[b]);return C}:n},{"../internals/descriptors":247,"../internals/fails":260,"../internals/function-call":264,"../internals/function-uncurry-this":268,"../internals/indexed-object":280,"../internals/object-get-own-property-symbols":312,"../internals/object-keys":316,"../internals/object-property-is-enumerable":317,"../internals/to-object":344}],306:[function(g,I,C){var A,i=g("../internals/an-object"),e=g("../internals/object-define-properties"),l=g("../internals/enum-bug-keys"),t=g("../internals/hidden-keys"),s=g("../internals/html"),c=g("../internals/document-create-element"),d=g("../internals/shared-key"),o=">",n="<",a="prototype",Z="script",b=d("IE_PROTO"),r=function(){},m=function(g){return n+Z+o+g+n+"/"+Z+o},h=function(g){g.write(m("")),g.close();var I=g.parentWindow.Object;return g=null,I},G=function(){var g,I=c("iframe"),C="java"+Z+":";return I.style.display="none",s.appendChild(I),I.src=String(C),(g=I.contentWindow.document).open(),g.write(m("document.F=Object")),g.close(),g.F},u=function(){try{A=new ActiveXObject("htmlfile")}catch(I){}u="undefined"!=typeof document?document.domain&&A?h(A):G():h(A);for(var g=l.length;g--;)delete u[a][l[g]];return u()};t[b]=!0,I.exports=Object.create||function(g,I){var C;return null!==g?(r[a]=i(g),C=new r,r[a]=null,C[b]=g):C=u(),void 0===I?C:e.f(C,I)}},{"../internals/an-object":227,"../internals/document-create-element":249,"../internals/enum-bug-keys":258,"../internals/hidden-keys":276,"../internals/html":278,"../internals/object-define-properties":307,"../internals/shared-key":332}],307:[function(g,I,C){var A=g("../internals/descriptors"),i=g("../internals/v8-prototype-define-bug"),e=g("../internals/object-define-property"),l=g("../internals/an-object"),t=g("../internals/to-indexed-object"),s=g("../internals/object-keys");C.f=A&&!i?Object.defineProperties:function(g,I){l(g);for(var C,A=t(I),i=s(I),c=i.length,d=0;c>d;)e.f(g,C=i[d++],A[C]);return g}},{"../internals/an-object":227,"../internals/descriptors":247,"../internals/object-define-property":308,"../internals/object-keys":316,"../internals/to-indexed-object":341,"../internals/v8-prototype-define-bug":352}],308:[function(g,I,C){var A=g("../internals/descriptors"),i=g("../internals/ie8-dom-define"),e=g("../internals/v8-prototype-define-bug"),l=g("../internals/an-object"),t=g("../internals/to-property-key"),s=TypeError,c=Object.defineProperty,d=Object.getOwnPropertyDescriptor,o="enumerable",n="configurable",a="writable";C.f=A?e?function(g,I,C){if(l(g),I=t(I),l(C),"function"==typeof g&&"prototype"===I&&"value"in C&&a in C&&!C[a]){var A=d(g,I);A&&A[a]&&(g[I]=C.value,C={configurable:n in C?C[n]:A[n],enumerable:o in C?C[o]:A[o],writable:!1})}return c(g,I,C)}:c:function(g,I,C){if(l(g),I=t(I),l(C),i)try{return c(g,I,C)}catch(A){}if("get"in C||"set"in C)throw new s("Accessors not supported");return"value"in C&&(g[I]=C.value),g}},{"../internals/an-object":227,"../internals/descriptors":247,"../internals/ie8-dom-define":279,"../internals/to-property-key":346,"../internals/v8-prototype-define-bug":352}],309:[function(g,I,C){var A=g("../internals/descriptors"),i=g("../internals/function-call"),e=g("../internals/object-property-is-enumerable"),l=g("../internals/create-property-descriptor"),t=g("../internals/to-indexed-object"),s=g("../internals/to-property-key"),c=g("../internals/has-own-property"),d=g("../internals/ie8-dom-define"),o=Object.getOwnPropertyDescriptor;C.f=A?o:function(g,I){if(g=t(g),I=s(I),d)try{return o(g,I)}catch(C){}if(c(g,I))return l(!i(e.f,g,I),g[I])}},{"../internals/create-property-descriptor":242,"../internals/descriptors":247,"../internals/function-call":264,"../internals/has-own-property":275,"../internals/ie8-dom-define":279,"../internals/object-property-is-enumerable":317,"../internals/to-indexed-object":341,"../internals/to-property-key":346}],310:[function(g,I,C){var A=g("../internals/classof-raw"),i=g("../internals/to-indexed-object"),e=g("../internals/object-get-own-property-names").f,l=g("../internals/array-slice-simple"),t="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[],s=function(g){try{return e(g)}catch(I){return l(t)}};I.exports.f=function(g){return t&&"Window"===A(g)?s(g):e(i(g))}},{"../internals/array-slice-simple":230,"../internals/classof-raw":235,"../internals/object-get-own-property-names":311,"../internals/to-indexed-object":341}],311:[function(g,I,C){var A=g("../internals/object-keys-internal"),i=g("../internals/enum-bug-keys").concat("length","prototype");C.f=Object.getOwnPropertyNames||function(g){return A(g,i)}},{"../internals/enum-bug-keys":258,"../internals/object-keys-internal":315}],312:[function(g,I,C){C.f=Object.getOwnPropertySymbols},{}],313:[function(g,I,C){var A=g("../internals/has-own-property"),i=g("../internals/is-callable"),e=g("../internals/to-object"),l=g("../internals/shared-key"),t=g("../internals/correct-prototype-getter"),s=l("IE_PROTO"),c=Object,d=c.prototype;I.exports=t?c.getPrototypeOf:function(g){var I=e(g);if(A(I,s))return I[s];var C=I.constructor;return i(C)&&I instanceof C?C.prototype:I instanceof c?d:null}},{"../internals/correct-prototype-getter":239,"../internals/has-own-property":275,"../internals/is-callable":285,"../internals/shared-key":332,"../internals/to-object":344}],314:[function(g,I,C){var A=g("../internals/function-uncurry-this");I.exports=A({}.isPrototypeOf)},{"../internals/function-uncurry-this":268}],315:[function(g,I,C){var A=g("../internals/function-uncurry-this"),i=g("../internals/has-own-property"),e=g("../internals/to-indexed-object"),l=g("../internals/array-includes").indexOf,t=g("../internals/hidden-keys"),s=A([].push);I.exports=function(g,I){var C,A=e(g),c=0,d=[];for(C in A)!i(t,C)&&i(A,C)&&s(d,C);for(;I.length>c;)i(A,C=I[c++])&&(~l(d,C)||s(d,C));return d}},{"../internals/array-includes":228,"../internals/function-uncurry-this":268,"../internals/has-own-property":275,"../internals/hidden-keys":276,"../internals/to-indexed-object":341}],316:[function(g,I,C){var A=g("../internals/object-keys-internal"),i=g("../internals/enum-bug-keys");I.exports=Object.keys||function(g){return A(g,i)}},{"../internals/enum-bug-keys":258,"../internals/object-keys-internal":315}],317:[function(g,I,C){var A={}.propertyIsEnumerable,i=Object.getOwnPropertyDescriptor,e=i&&!A.call({1:2},1);C.f=e?function(g){var I=i(this,g);return!!I&&I.enumerable}:A},{}],318:[function(g,I,C){var A=g("../internals/function-uncurry-this-accessor"),i=g("../internals/an-object"),e=g("../internals/a-possible-prototype");I.exports=Object.setPrototypeOf||("__proto__"in{}?function(){var g,I=!1,C={};try{(g=A(Object.prototype,"__proto__","set"))(C,[]),I=C instanceof Array}catch(l){}return function(C,A){return i(C),e(A),I?g(C,A):C.__proto__=A,C}}():void 0)},{"../internals/a-possible-prototype":224,"../internals/an-object":227,"../internals/function-uncurry-this-accessor":266}],319:[function(g,I,C){var A=g("../internals/descriptors"),i=g("../internals/fails"),e=g("../internals/function-uncurry-this"),l=g("../internals/object-get-prototype-of"),t=g("../internals/object-keys"),s=g("../internals/to-indexed-object"),c=e(g("../internals/object-property-is-enumerable").f),d=e([].push),o=A&&i((function(){var g=Object.create(null);return g[2]=2,!c(g,2)})),n=function(g){return function(I){for(var C,i=s(I),e=t(i),n=o&&null===l(i),a=e.length,Z=0,b=[];a>Z;)C=e[Z++],A&&!(n?C in i:c(i,C))||d(b,g?[C,i[C]]:i[C]);return b}};I.exports={entries:n(!0),values:n(!1)}},{"../internals/descriptors":247,"../internals/fails":260,"../internals/function-uncurry-this":268,"../internals/object-get-prototype-of":313,"../internals/object-keys":316,"../internals/object-property-is-enumerable":317,"../internals/to-indexed-object":341}],320:[function(g,I,C){var A=g("../internals/function-call"),i=g("../internals/is-callable"),e=g("../internals/is-object"),l=TypeError;I.exports=function(g,I){var C,t;if("string"===I&&i(C=g.toString)&&!e(t=A(C,g)))return t;if(i(C=g.valueOf)&&!e(t=A(C,g)))return t;if("string"!==I&&i(C=g.toString)&&!e(t=A(C,g)))return t;throw new l("Can't convert object to primitive value")}},{"../internals/function-call":264,"../internals/is-callable":285,"../internals/is-object":289}],321:[function(g,I,C){var A=g("../internals/get-built-in"),i=g("../internals/function-uncurry-this"),e=g("../internals/object-get-own-property-names"),l=g("../internals/object-get-own-property-symbols"),t=g("../internals/an-object"),s=i([].concat);I.exports=A("Reflect","ownKeys")||function(g){var I=e.f(t(g)),C=l.f;return C?s(I,C(g)):I}},{"../internals/an-object":227,"../internals/function-uncurry-this":268,"../internals/get-built-in":269,"../internals/object-get-own-property-names":311,"../internals/object-get-own-property-symbols":312}],322:[function(g,I,C){var A=g("../internals/global");I.exports=A},{"../internals/global":274}],323:[function(g,I,C){I.exports=function(g){try{return{error:!1,value:g()}}catch(I){return{error:!0,value:I}}}},{}],324:[function(g,I,C){var A=g("../internals/global"),i=g("../internals/promise-native-constructor"),e=g("../internals/is-callable"),l=g("../internals/is-forced"),t=g("../internals/inspect-source"),s=g("../internals/well-known-symbol"),c=g("../internals/engine-is-browser"),d=g("../internals/engine-is-deno"),o=g("../internals/is-pure"),n=g("../internals/engine-v8-version"),a=i&&i.prototype,Z=s("species"),b=!1,r=e(A.PromiseRejectionEvent),m=l("Promise",(function(){var g=t(i),I=g!==String(i);if(!I&&66===n)return!0;if(o&&(!a.catch||!a.finally))return!0;if(!n||n<51||!/native code/.test(g)){var C=new i((function(g){g(1)})),A=function(g){g((function(){}),(function(){}))};if((C.constructor={})[Z]=A,!(b=C.then((function(){}))instanceof A))return!0}return!I&&(c||d)&&!r}));I.exports={CONSTRUCTOR:m,REJECTION_EVENT:r,SUBCLASSING:b}},{"../internals/engine-is-browser":250,"../internals/engine-is-deno":251,"../internals/engine-v8-version":257,"../internals/global":274,"../internals/inspect-source":281,"../internals/is-callable":285,"../internals/is-forced":287,"../internals/is-pure":290,"../internals/promise-native-constructor":325,"../internals/well-known-symbol":357}],325:[function(g,I,C){var A=g("../internals/global");I.exports=A.Promise},{"../internals/global":274}],326:[function(g,I,C){var A=g("../internals/an-object"),i=g("../internals/is-object"),e=g("../internals/new-promise-capability");I.exports=function(g,I){if(A(g),i(I)&&I.constructor===g)return I;var C=e.f(g);return(0,C.resolve)(I),C.promise}},{"../internals/an-object":227,"../internals/is-object":289,"../internals/new-promise-capability":303}],327:[function(g,I,C){var A=g("../internals/promise-native-constructor"),i=g("../internals/check-correctness-of-iteration"),e=g("../internals/promise-constructor-detection").CONSTRUCTOR;I.exports=e||!i((function(g){A.all(g).then(void 0,(function(){}))}))},{"../internals/check-correctness-of-iteration":234,"../internals/promise-constructor-detection":324,"../internals/promise-native-constructor":325}],328:[function(g,I,C){var A=function(){this.head=null,this.tail=null};A.prototype={add:function(g){var I={item:g,next:null},C=this.tail;C?C.next=I:this.head=I,this.tail=I},get:function(){var g=this.head;if(g)return null===(this.head=g.next)&&(this.tail=null),g.item}},I.exports=A},{}],329:[function(g,I,C){var A=g("../internals/is-null-or-undefined"),i=TypeError;I.exports=function(g){if(A(g))throw new i("Can't call method on "+g);return g}},{"../internals/is-null-or-undefined":288}],330:[function(g,I,C){var A=g("../internals/get-built-in"),i=g("../internals/define-built-in-accessor"),e=g("../internals/well-known-symbol"),l=g("../internals/descriptors"),t=e("species");I.exports=function(g){var I=A(g);l&&I&&!I[t]&&i(I,t,{configurable:!0,get:function(){return this}})}},{"../internals/define-built-in-accessor":244,"../internals/descriptors":247,"../internals/get-built-in":269,"../internals/well-known-symbol":357}],331:[function(g,I,C){var A=g("../internals/object-define-property").f,i=g("../internals/has-own-property"),e=g("../internals/well-known-symbol")("toStringTag");I.exports=function(g,I,C){g&&!C&&(g=g.prototype),g&&!i(g,e)&&A(g,e,{configurable:!0,value:I})}},{"../internals/has-own-property":275,"../internals/object-define-property":308,"../internals/well-known-symbol":357}],332:[function(g,I,C){var A=g("../internals/shared"),i=g("../internals/uid"),e=A("keys");I.exports=function(g){return e[g]||(e[g]=i(g))}},{"../internals/shared":334,"../internals/uid":350}],333:[function(g,I,C){var A=g("../internals/global"),i=g("../internals/define-global-property"),e="__core-js_shared__",l=A[e]||i(e,{});I.exports=l},{"../internals/define-global-property":246,"../internals/global":274}],334:[function(g,I,C){var A=g("../internals/is-pure"),i=g("../internals/shared-store");(I.exports=function(g,I){return i[g]||(i[g]=void 0!==I?I:{})})("versions",[]).push({version:"3.33.0",mode:A?"pure":"global",copyright:"© 2014-2023 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.33.0/LICENSE",source:"https://github.com/zloirock/core-js"})},{"../internals/is-pure":290,"../internals/shared-store":333}],335:[function(g,I,C){var A=g("../internals/an-object"),i=g("../internals/a-constructor"),e=g("../internals/is-null-or-undefined"),l=g("../internals/well-known-symbol")("species");I.exports=function(g,I){var C,t=A(g).constructor;return void 0===t||e(C=A(t)[l])?I:i(C)}},{"../internals/a-constructor":223,"../internals/an-object":227,"../internals/is-null-or-undefined":288,"../internals/well-known-symbol":357}],336:[function(g,I,C){var A=g("../internals/engine-v8-version"),i=g("../internals/fails"),e=g("../internals/global").String;I.exports=!!Object.getOwnPropertySymbols&&!i((function(){var g=Symbol("symbol detection");return!e(g)||!(Object(g)instanceof Symbol)||!Symbol.sham&&A&&A<41}))},{"../internals/engine-v8-version":257,"../internals/fails":260,"../internals/global":274}],337:[function(g,I,C){var A=g("../internals/function-call"),i=g("../internals/get-built-in"),e=g("../internals/well-known-symbol"),l=g("../internals/define-built-in");I.exports=function(){var g=i("Symbol"),I=g&&g.prototype,C=I&&I.valueOf,t=e("toPrimitive");I&&!I[t]&&l(I,t,(function(g){return A(C,this)}),{arity:1})}},{"../internals/define-built-in":245,"../internals/function-call":264,"../internals/get-built-in":269,"../internals/well-known-symbol":357}],338:[function(g,I,C){var A=g("../internals/symbol-constructor-detection");I.exports=A&&!!Symbol.for&&!!Symbol.keyFor},{"../internals/symbol-constructor-detection":336}],339:[function(g,I,C){var A,i,e,l,t=g("../internals/global"),s=g("../internals/function-apply"),c=g("../internals/function-bind-context"),d=g("../internals/is-callable"),o=g("../internals/has-own-property"),n=g("../internals/fails"),a=g("../internals/html"),Z=g("../internals/array-slice"),b=g("../internals/document-create-element"),r=g("../internals/validate-arguments-length"),m=g("../internals/engine-is-ios"),h=g("../internals/engine-is-node"),G=t.setImmediate,u=t.clearImmediate,B=t.process,w=t.Dispatch,W=t.Function,p=t.MessageChannel,V=t.String,y=0,X={},Y="onreadystatechange";n((function(){A=t.location}));var R=function(g){if(o(X,g)){var I=X[g];delete X[g],I()}},N=function(g){return function(){R(g)}},H=function(g){R(g.data)},K=function(g){t.postMessage(V(g),A.protocol+"//"+A.host)};G&&u||(G=function(g){r(arguments.length,1);var I=d(g)?g:W(g),C=Z(arguments,1);return X[++y]=function(){s(I,void 0,C)},i(y),y},u=function(g){delete X[g]},h?i=function(g){B.nextTick(N(g))}:w&&w.now?i=function(g){w.now(N(g))}:p&&!m?(l=(e=new p).port2,e.port1.onmessage=H,i=c(l.postMessage,l)):t.addEventListener&&d(t.postMessage)&&!t.importScripts&&A&&"file:"!==A.protocol&&!n(K)?(i=K,t.addEventListener("message",H,!1)):i=Y in b("script")?function(g){a.appendChild(b("script"))[Y]=function(){a.removeChild(this),R(g)}}:function(g){setTimeout(N(g),0)}),I.exports={set:G,clear:u}},{"../internals/array-slice":231,"../internals/document-create-element":249,"../internals/engine-is-ios":253,"../internals/engine-is-node":254,"../internals/fails":260,"../internals/function-apply":261,"../internals/function-bind-context":262,"../internals/global":274,"../internals/has-own-property":275,"../internals/html":278,"../internals/is-callable":285,"../internals/validate-arguments-length":353}],340:[function(g,I,C){var A=g("../internals/to-integer-or-infinity"),i=Math.max,e=Math.min;I.exports=function(g,I){var C=A(g);return C<0?i(C+I,0):e(C,I)}},{"../internals/to-integer-or-infinity":342}],341:[function(g,I,C){var A=g("../internals/indexed-object"),i=g("../internals/require-object-coercible");I.exports=function(g){return A(i(g))}},{"../internals/indexed-object":280,"../internals/require-object-coercible":329}],342:[function(g,I,C){var A=g("../internals/math-trunc");I.exports=function(g){var I=+g;return I!=I||0===I?0:A(I)}},{"../internals/math-trunc":301}],343:[function(g,I,C){var A=g("../internals/to-integer-or-infinity"),i=Math.min;I.exports=function(g){return g>0?i(A(g),9007199254740991):0}},{"../internals/to-integer-or-infinity":342}],344:[function(g,I,C){var A=g("../internals/require-object-coercible"),i=Object;I.exports=function(g){return i(A(g))}},{"../internals/require-object-coercible":329}],345:[function(g,I,C){var A=g("../internals/function-call"),i=g("../internals/is-object"),e=g("../internals/is-symbol"),l=g("../internals/get-method"),t=g("../internals/ordinary-to-primitive"),s=g("../internals/well-known-symbol"),c=TypeError,d=s("toPrimitive");I.exports=function(g,I){if(!i(g)||e(g))return g;var C,s=l(g,d);if(s){if(void 0===I&&(I="default"),C=A(s,g,I),!i(C)||e(C))return C;throw new c("Can't convert object to primitive value")}return void 0===I&&(I="number"),t(g,I)}},{"../internals/function-call":264,"../internals/get-method":273,"../internals/is-object":289,"../internals/is-symbol":292,"../internals/ordinary-to-primitive":320,"../internals/well-known-symbol":357}],346:[function(g,I,C){var A=g("../internals/to-primitive"),i=g("../internals/is-symbol");I.exports=function(g){var I=A(g,"string");return i(I)?I:I+""}},{"../internals/is-symbol":292,"../internals/to-primitive":345}],347:[function(g,I,C){var A={};A[g("../internals/well-known-symbol")("toStringTag")]="z",I.exports="[object z]"===String(A)},{"../internals/well-known-symbol":357}],348:[function(g,I,C){var A=g("../internals/classof"),i=String;I.exports=function(g){if("Symbol"===A(g))throw new TypeError("Cannot convert a Symbol value to a string");return i(g)}},{"../internals/classof":236}],349:[function(g,I,C){var A=String;I.exports=function(g){try{return A(g)}catch(I){return"Object"}}},{}],350:[function(g,I,C){var A=g("../internals/function-uncurry-this"),i=0,e=Math.random(),l=A(1..toString);I.exports=function(g){return"Symbol("+(void 0===g?"":g)+")_"+l(++i+e,36)}},{"../internals/function-uncurry-this":268}],351:[function(g,I,C){var A=g("../internals/symbol-constructor-detection");I.exports=A&&!Symbol.sham&&"symbol"==typeof Symbol.iterator},{"../internals/symbol-constructor-detection":336}],352:[function(g,I,C){var A=g("../internals/descriptors"),i=g("../internals/fails");I.exports=A&&i((function(){return 42!==Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype}))},{"../internals/descriptors":247,"../internals/fails":260}],353:[function(g,I,C){var A=TypeError;I.exports=function(g,I){if(g1?arguments[1]:void 0)}}),e(l)},{"../internals/add-to-unscopables":225,"../internals/array-iteration":229,"../internals/export":259}],359:[function(g,I,C){var A=g("../internals/export"),i=g("../internals/array-iteration").find,e=g("../internals/add-to-unscopables"),l="find",t=!0;l in[]&&Array(1)[l]((function(){t=!1})),A({target:"Array",proto:!0,forced:t},{find:function(g){return i(this,g,arguments.length>1?arguments[1]:void 0)}}),e(l)},{"../internals/add-to-unscopables":225,"../internals/array-iteration":229,"../internals/export":259}],360:[function(g,I,C){var A=g("../internals/export"),i=g("../internals/array-includes").includes,e=g("../internals/fails"),l=g("../internals/add-to-unscopables");A({target:"Array",proto:!0,forced:e((function(){return!Array(1).includes()}))},{includes:function(g){return i(this,g,arguments.length>1?arguments[1]:void 0)}}),l("includes")},{"../internals/add-to-unscopables":225,"../internals/array-includes":228,"../internals/export":259,"../internals/fails":260}],361:[function(g,I,C){var A=g("../internals/to-indexed-object"),i=g("../internals/add-to-unscopables"),e=g("../internals/iterators"),l=g("../internals/internal-state"),t=g("../internals/object-define-property").f,s=g("../internals/iterator-define"),c=g("../internals/create-iter-result-object"),d=g("../internals/is-pure"),o=g("../internals/descriptors"),n="Array Iterator",a=l.set,Z=l.getterFor(n);I.exports=s(Array,"Array",(function(g,I){a(this,{type:n,target:A(g),index:0,kind:I})}),(function(){var g=Z(this),I=g.target,C=g.kind,A=g.index++;if(!I||A>=I.length)return g.target=void 0,c(void 0,!0);switch(C){case"keys":return c(A,!1);case"values":return c(I[A],!1)}return c([A,I[A]],!1)}),"values");var b=e.Arguments=e.Array;if(i("keys"),i("values"),i("entries"),!d&&o&&"values"!==b.name)try{t(b,"name",{value:"values"})}catch(r){}},{"../internals/add-to-unscopables":225,"../internals/create-iter-result-object":240,"../internals/descriptors":247,"../internals/internal-state":282,"../internals/is-pure":290,"../internals/iterator-define":296,"../internals/iterators":298,"../internals/object-define-property":308,"../internals/to-indexed-object":341}],362:[function(g,I,C){var A=g("../internals/export"),i=g("../internals/get-built-in"),e=g("../internals/function-apply"),l=g("../internals/function-call"),t=g("../internals/function-uncurry-this"),s=g("../internals/fails"),c=g("../internals/is-callable"),d=g("../internals/is-symbol"),o=g("../internals/array-slice"),n=g("../internals/get-json-replacer-function"),a=g("../internals/symbol-constructor-detection"),Z=String,b=i("JSON","stringify"),r=t(/./.exec),m=t("".charAt),h=t("".charCodeAt),G=t("".replace),u=t(1..toString),B=/[\uD800-\uDFFF]/g,w=/^[\uD800-\uDBFF]$/,W=/^[\uDC00-\uDFFF]$/,p=!a||s((function(){var g=i("Symbol")("stringify detection");return"[null]"!==b([g])||"{}"!==b({a:g})||"{}"!==b(Object(g))})),V=s((function(){return'"\\udf06\\ud834"'!==b("\udf06\ud834")||'"\\udead"'!==b("\udead")})),y=function(g,I){var C=o(arguments),A=n(I);if(c(A)||void 0!==g&&!d(g))return C[1]=function(g,I){if(c(A)&&(I=l(A,this,Z(g),I)),!d(I))return I},e(b,null,C)},X=function(g,I,C){var A=m(C,I-1),i=m(C,I+1);return r(w,g)&&!r(W,i)||r(W,g)&&!r(w,A)?"\\u"+u(h(g,0),16):g};b&&A({target:"JSON",stat:!0,arity:3,forced:p||V},{stringify:function(g,I,C){var A=o(arguments),i=e(p?y:b,null,A);return V&&"string"==typeof i?G(i,B,X):i}})},{"../internals/array-slice":231,"../internals/export":259,"../internals/fails":260,"../internals/function-apply":261,"../internals/function-call":264,"../internals/function-uncurry-this":268,"../internals/get-built-in":269,"../internals/get-json-replacer-function":272,"../internals/is-callable":285,"../internals/is-symbol":292,"../internals/symbol-constructor-detection":336}],363:[function(g,I,C){g("../internals/export")({target:"Number",stat:!0},{isNaN:function(g){return g!=g}})},{"../internals/export":259}],364:[function(g,I,C){var A=g("../internals/export"),i=g("../internals/object-assign");A({target:"Object",stat:!0,arity:2,forced:Object.assign!==i},{assign:i})},{"../internals/export":259,"../internals/object-assign":305}],365:[function(g,I,C){var A=g("../internals/export"),i=g("../internals/symbol-constructor-detection"),e=g("../internals/fails"),l=g("../internals/object-get-own-property-symbols"),t=g("../internals/to-object");A({target:"Object",stat:!0,forced:!i||e((function(){l.f(1)}))},{getOwnPropertySymbols:function(g){var I=l.f;return I?I(t(g)):[]}})},{"../internals/export":259,"../internals/fails":260,"../internals/object-get-own-property-symbols":312,"../internals/symbol-constructor-detection":336,"../internals/to-object":344}],366:[function(g,I,C){var A=g("../internals/export"),i=g("../internals/to-object"),e=g("../internals/object-keys");A({target:"Object",stat:!0,forced:g("../internals/fails")((function(){e(1)}))},{keys:function(g){return e(i(g))}})},{"../internals/export":259,"../internals/fails":260,"../internals/object-keys":316,"../internals/to-object":344}],367:[function(g,I,C){var A=g("../internals/export"),i=g("../internals/object-to-array").values;A({target:"Object",stat:!0},{values:function(g){return i(g)}})},{"../internals/export":259,"../internals/object-to-array":319}],368:[function(g,I,C){var A=g("../internals/export"),i=g("../internals/function-call"),e=g("../internals/a-callable"),l=g("../internals/new-promise-capability"),t=g("../internals/perform"),s=g("../internals/iterate");A({target:"Promise",stat:!0,forced:g("../internals/promise-statics-incorrect-iteration")},{all:function(g){var I=this,C=l.f(I),A=C.resolve,c=C.reject,d=t((function(){var C=e(I.resolve),l=[],t=0,d=1;s(g,(function(g){var e=t++,s=!1;d++,i(C,I,g).then((function(g){s||(s=!0,l[e]=g,--d||A(l))}),c)})),--d||A(l)}));return d.error&&c(d.value),C.promise}})},{"../internals/a-callable":222,"../internals/export":259,"../internals/function-call":264,"../internals/iterate":293,"../internals/new-promise-capability":303,"../internals/perform":323,"../internals/promise-statics-incorrect-iteration":327}],369:[function(g,I,C){var A=g("../internals/export"),i=g("../internals/is-pure"),e=g("../internals/promise-constructor-detection").CONSTRUCTOR,l=g("../internals/promise-native-constructor"),t=g("../internals/get-built-in"),s=g("../internals/is-callable"),c=g("../internals/define-built-in"),d=l&&l.prototype;if(A({target:"Promise",proto:!0,forced:e,real:!0},{catch:function(g){return this.then(void 0,g)}}),!i&&s(l)){var o=t("Promise").prototype.catch;d.catch!==o&&c(d,"catch",o,{unsafe:!0})}},{"../internals/define-built-in":245,"../internals/export":259,"../internals/get-built-in":269,"../internals/is-callable":285,"../internals/is-pure":290,"../internals/promise-constructor-detection":324,"../internals/promise-native-constructor":325}],370:[function(g,I,C){var A,i,e,l,t=g("../internals/export"),s=g("../internals/is-pure"),c=g("../internals/engine-is-node"),d=g("../internals/global"),o=g("../internals/function-call"),n=g("../internals/define-built-in"),a=g("../internals/object-set-prototype-of"),Z=g("../internals/set-to-string-tag"),b=g("../internals/set-species"),r=g("../internals/a-callable"),m=g("../internals/is-callable"),h=g("../internals/is-object"),G=g("../internals/an-instance"),u=g("../internals/species-constructor"),B=g("../internals/task").set,w=g("../internals/microtask"),W=g("../internals/host-report-errors"),p=g("../internals/perform"),V=g("../internals/queue"),y=g("../internals/internal-state"),X=g("../internals/promise-native-constructor"),Y=g("../internals/promise-constructor-detection"),R=g("../internals/new-promise-capability"),N="Promise",H=Y.CONSTRUCTOR,K=Y.REJECTION_EVENT,F=Y.SUBCLASSING,M=y.getterFor(N),J=y.set,S=X&&X.prototype,f=X,k=S,D=d.TypeError,L=d.document,z=d.process,v=R.f,T=v,x=!!(L&&L.createEvent&&d.dispatchEvent),U="unhandledrejection",Q="rejectionhandled",j=0,O=1,E=2,P=1,_=2,q=function(g){var I;return!(!h(g)||!m(I=g.then))&&I},$=function(g,I){var C,A,i,e=I.value,l=I.state===O,t=l?g.ok:g.fail,s=g.resolve,c=g.reject,d=g.domain;try{t?(l||(I.rejection===_&&ig(I),I.rejection=P),!0===t?C=e:(d&&d.enter(),C=t(e),d&&(d.exit(),i=!0)),C===g.promise?c(new D("Promise-chain cycle")):(A=q(C))?o(A,C,s,c):s(C)):c(e)}catch(n){d&&!i&&d.exit(),c(n)}},gg=function(g,I){g.notified||(g.notified=!0,w((function(){for(var C,A=g.reactions;C=A.get();)$(C,g);g.notified=!1,I&&!g.rejection&&Cg(g)})))},Ig=function(g,I,C){var A,i;x?((A=L.createEvent("Event")).promise=I,A.reason=C,A.initEvent(g,!1,!0),d.dispatchEvent(A)):A={promise:I,reason:C},!K&&(i=d["on"+g])?i(A):g===U&&W("Unhandled promise rejection",C)},Cg=function(g){o(B,d,(function(){var I,C=g.facade,A=g.value;if(Ag(g)&&(I=p((function(){c?z.emit("unhandledRejection",A,C):Ig(U,C,A)})),g.rejection=c||Ag(g)?_:P,I.error))throw I.value}))},Ag=function(g){return g.rejection!==P&&!g.parent},ig=function(g){o(B,d,(function(){var I=g.facade;c?z.emit("rejectionHandled",I):Ig(Q,I,g.value)}))},eg=function(g,I,C){return function(A){g(I,A,C)}},lg=function(g,I,C){g.done||(g.done=!0,C&&(g=C),g.value=I,g.state=E,gg(g,!0))},tg=function(g,I,C){if(!g.done){g.done=!0,C&&(g=C);try{if(g.facade===I)throw new D("Promise can't be resolved itself");var A=q(I);A?w((function(){var C={done:!1};try{o(A,I,eg(tg,C,g),eg(lg,C,g))}catch(i){lg(C,i,g)}})):(g.value=I,g.state=O,gg(g,!1))}catch(i){lg({done:!1},i,g)}}};if(H&&(k=(f=function(g){G(this,k),r(g),o(A,this);var I=M(this);try{g(eg(tg,I),eg(lg,I))}catch(C){lg(I,C)}}).prototype,(A=function(g){J(this,{type:N,done:!1,notified:!1,parent:!1,reactions:new V,rejection:!1,state:j,value:void 0})}).prototype=n(k,"then",(function(g,I){var C=M(this),A=v(u(this,f));return C.parent=!0,A.ok=!m(g)||g,A.fail=m(I)&&I,A.domain=c?z.domain:void 0,C.state===j?C.reactions.add(A):w((function(){$(A,C)})),A.promise})),i=function(){var g=new A,I=M(g);this.promise=g,this.resolve=eg(tg,I),this.reject=eg(lg,I)},R.f=v=function(g){return g===f||g===e?new i(g):T(g)},!s&&m(X)&&S!==Object.prototype)){l=S.then,F||n(S,"then",(function(g,I){var C=this;return new f((function(g,I){o(l,C,g,I)})).then(g,I)}),{unsafe:!0});try{delete S.constructor}catch(sg){}a&&a(S,k)}t({global:!0,constructor:!0,wrap:!0,forced:H},{Promise:f}),Z(f,N,!1,!0),b(N)},{"../internals/a-callable":222,"../internals/an-instance":226,"../internals/define-built-in":245,"../internals/engine-is-node":254,"../internals/export":259,"../internals/function-call":264,"../internals/global":274,"../internals/host-report-errors":277,"../internals/internal-state":282,"../internals/is-callable":285,"../internals/is-object":289,"../internals/is-pure":290,"../internals/microtask":302,"../internals/new-promise-capability":303,"../internals/object-set-prototype-of":318,"../internals/perform":323,"../internals/promise-constructor-detection":324,"../internals/promise-native-constructor":325,"../internals/queue":328,"../internals/set-species":330,"../internals/set-to-string-tag":331,"../internals/species-constructor":335,"../internals/task":339}],371:[function(g,I,C){var A=g("../internals/export"),i=g("../internals/is-pure"),e=g("../internals/promise-native-constructor"),l=g("../internals/fails"),t=g("../internals/get-built-in"),s=g("../internals/is-callable"),c=g("../internals/species-constructor"),d=g("../internals/promise-resolve"),o=g("../internals/define-built-in"),n=e&&e.prototype;if(A({target:"Promise",proto:!0,real:!0,forced:!!e&&l((function(){n.finally.call({then:function(){}},(function(){}))}))},{finally:function(g){var I=c(this,t("Promise")),C=s(g);return this.then(C?function(C){return d(I,g()).then((function(){return C}))}:g,C?function(C){return d(I,g()).then((function(){throw C}))}:g)}}),!i&&s(e)){var a=t("Promise").prototype.finally;n.finally!==a&&o(n,"finally",a,{unsafe:!0})}},{"../internals/define-built-in":245,"../internals/export":259,"../internals/fails":260,"../internals/get-built-in":269,"../internals/is-callable":285,"../internals/is-pure":290,"../internals/promise-native-constructor":325,"../internals/promise-resolve":326,"../internals/species-constructor":335}],372:[function(g,I,C){g("../modules/es.promise.constructor"),g("../modules/es.promise.all"),g("../modules/es.promise.catch"),g("../modules/es.promise.race"),g("../modules/es.promise.reject"),g("../modules/es.promise.resolve")},{"../modules/es.promise.all":368,"../modules/es.promise.catch":369,"../modules/es.promise.constructor":370,"../modules/es.promise.race":373,"../modules/es.promise.reject":374,"../modules/es.promise.resolve":375}],373:[function(g,I,C){var A=g("../internals/export"),i=g("../internals/function-call"),e=g("../internals/a-callable"),l=g("../internals/new-promise-capability"),t=g("../internals/perform"),s=g("../internals/iterate");A({target:"Promise",stat:!0,forced:g("../internals/promise-statics-incorrect-iteration")},{race:function(g){var I=this,C=l.f(I),A=C.reject,c=t((function(){var l=e(I.resolve);s(g,(function(g){i(l,I,g).then(C.resolve,A)}))}));return c.error&&A(c.value),C.promise}})},{"../internals/a-callable":222,"../internals/export":259,"../internals/function-call":264,"../internals/iterate":293,"../internals/new-promise-capability":303,"../internals/perform":323,"../internals/promise-statics-incorrect-iteration":327}],374:[function(g,I,C){var A=g("../internals/export"),i=g("../internals/function-call"),e=g("../internals/new-promise-capability");A({target:"Promise",stat:!0,forced:g("../internals/promise-constructor-detection").CONSTRUCTOR},{reject:function(g){var I=e.f(this);return i(I.reject,void 0,g),I.promise}})},{"../internals/export":259,"../internals/function-call":264,"../internals/new-promise-capability":303,"../internals/promise-constructor-detection":324}],375:[function(g,I,C){var A=g("../internals/export"),i=g("../internals/get-built-in"),e=g("../internals/is-pure"),l=g("../internals/promise-native-constructor"),t=g("../internals/promise-constructor-detection").CONSTRUCTOR,s=g("../internals/promise-resolve"),c=i("Promise"),d=e&&!t;A({target:"Promise",stat:!0,forced:e||t},{resolve:function(g){return s(d&&this===c?l:this,g)}})},{"../internals/export":259,"../internals/get-built-in":269,"../internals/is-pure":290,"../internals/promise-constructor-detection":324,"../internals/promise-native-constructor":325,"../internals/promise-resolve":326}],376:[function(g,I,C){var A=g("../internals/export"),i=g("../internals/function-uncurry-this"),e=g("../internals/to-absolute-index"),l=RangeError,t=String.fromCharCode,s=String.fromCodePoint,c=i([].join);A({target:"String",stat:!0,arity:1,forced:!!s&&1!==s.length},{fromCodePoint:function(g){for(var I,C=[],A=arguments.length,i=0;A>i;){if(I=+arguments[i++],e(I,1114111)!==I)throw new l(I+" is not a valid code point");C[i]=I<65536?t(I):t(55296+((I-=65536)>>10),I%1024+56320)}return c(C,"")}})},{"../internals/export":259,"../internals/function-uncurry-this":268,"../internals/to-absolute-index":340}],377:[function(g,I,C){var A=g("../internals/export"),i=g("../internals/function-uncurry-this"),e=g("../internals/not-a-regexp"),l=g("../internals/require-object-coercible"),t=g("../internals/to-string"),s=g("../internals/correct-is-regexp-logic"),c=i("".indexOf);A({target:"String",proto:!0,forced:!s("includes")},{includes:function(g){return!!~c(t(l(this)),t(e(g)),arguments.length>1?arguments[1]:void 0)}})},{"../internals/correct-is-regexp-logic":238,"../internals/export":259,"../internals/function-uncurry-this":268,"../internals/not-a-regexp":304,"../internals/require-object-coercible":329,"../internals/to-string":348}],378:[function(g,I,C){g("../internals/well-known-symbol-define")("asyncIterator")},{"../internals/well-known-symbol-define":355}],379:[function(g,I,C){var A=g("../internals/export"),i=g("../internals/global"),e=g("../internals/function-call"),l=g("../internals/function-uncurry-this"),t=g("../internals/is-pure"),s=g("../internals/descriptors"),c=g("../internals/symbol-constructor-detection"),d=g("../internals/fails"),o=g("../internals/has-own-property"),n=g("../internals/object-is-prototype-of"),a=g("../internals/an-object"),Z=g("../internals/to-indexed-object"),b=g("../internals/to-property-key"),r=g("../internals/to-string"),m=g("../internals/create-property-descriptor"),h=g("../internals/object-create"),G=g("../internals/object-keys"),u=g("../internals/object-get-own-property-names"),B=g("../internals/object-get-own-property-names-external"),w=g("../internals/object-get-own-property-symbols"),W=g("../internals/object-get-own-property-descriptor"),p=g("../internals/object-define-property"),V=g("../internals/object-define-properties"),y=g("../internals/object-property-is-enumerable"),X=g("../internals/define-built-in"),Y=g("../internals/define-built-in-accessor"),R=g("../internals/shared"),N=g("../internals/shared-key"),H=g("../internals/hidden-keys"),K=g("../internals/uid"),F=g("../internals/well-known-symbol"),M=g("../internals/well-known-symbol-wrapped"),J=g("../internals/well-known-symbol-define"),S=g("../internals/symbol-define-to-primitive"),f=g("../internals/set-to-string-tag"),k=g("../internals/internal-state"),D=g("../internals/array-iteration").forEach,L=N("hidden"),z="Symbol",v="prototype",T=k.set,x=k.getterFor(z),U=Object[v],Q=i.Symbol,j=Q&&Q[v],O=i.RangeError,E=i.TypeError,P=i.QObject,_=W.f,q=p.f,$=B.f,gg=y.f,Ig=l([].push),Cg=R("symbols"),Ag=R("op-symbols"),ig=R("wks"),eg=!P||!P[v]||!P[v].findChild,lg=function(g,I,C){var A=_(U,I);A&&delete U[I],q(g,I,C),A&&g!==U&&q(U,I,A)},tg=s&&d((function(){return 7!==h(q({},"a",{get:function(){return q(this,"a",{value:7}).a}})).a}))?lg:q,sg=function(g,I){var C=Cg[g]=h(j);return T(C,{type:z,tag:g,description:I}),s||(C.description=I),C},cg=function(g,I,C){g===U&&cg(Ag,I,C),a(g);var A=b(I);return a(C),o(Cg,A)?(C.enumerable?(o(g,L)&&g[L][A]&&(g[L][A]=!1),C=h(C,{enumerable:m(0,!1)})):(o(g,L)||q(g,L,m(1,{})),g[L][A]=!0),tg(g,A,C)):q(g,A,C)},dg=function(g,I){a(g);var C=Z(I),A=G(C).concat(bg(C));return D(A,(function(I){s&&!e(ng,C,I)||cg(g,I,C[I])})),g},og=function(g,I){return void 0===I?h(g):dg(h(g),I)},ng=function(g){var I=b(g),C=e(gg,this,I);return!(this===U&&o(Cg,I)&&!o(Ag,I))&&(!(C||!o(this,I)||!o(Cg,I)||o(this,L)&&this[L][I])||C)},ag=function(g,I){var C=Z(g),A=b(I);if(C!==U||!o(Cg,A)||o(Ag,A)){var i=_(C,A);return!i||!o(Cg,A)||o(C,L)&&C[L][A]||(i.enumerable=!0),i}},Zg=function(g){var I=$(Z(g)),C=[];return D(I,(function(g){o(Cg,g)||o(H,g)||Ig(C,g)})),C},bg=function(g){var I=g===U,C=$(I?Ag:Z(g)),A=[];return D(C,(function(g){!o(Cg,g)||I&&!o(U,g)||Ig(A,Cg[g])})),A};c||(Q=function(){if(n(j,this))throw new E("Symbol is not a constructor");var g=arguments.length&&void 0!==arguments[0]?r(arguments[0]):void 0,I=K(g),C=function(g){this===U&&e(C,Ag,g),o(this,L)&&o(this[L],I)&&(this[L][I]=!1);var A=m(1,g);try{tg(this,I,A)}catch(i){if(!(i instanceof O))throw i;lg(this,I,A)}};return s&&eg&&tg(U,I,{configurable:!0,set:C}),sg(I,g)},X(j=Q[v],"toString",(function(){return x(this).tag})),X(Q,"withoutSetter",(function(g){return sg(K(g),g)})),y.f=ng,p.f=cg,V.f=dg,W.f=ag,u.f=B.f=Zg,w.f=bg,M.f=function(g){return sg(F(g),g)},s&&(Y(j,"description",{configurable:!0,get:function(){return x(this).description}}),t||X(U,"propertyIsEnumerable",ng,{unsafe:!0}))),A({global:!0,constructor:!0,wrap:!0,forced:!c,sham:!c},{Symbol:Q}),D(G(ig),(function(g){J(g)})),A({target:z,stat:!0,forced:!c},{useSetter:function(){eg=!0},useSimple:function(){eg=!1}}),A({target:"Object",stat:!0,forced:!c,sham:!s},{create:og,defineProperty:cg,defineProperties:dg,getOwnPropertyDescriptor:ag}),A({target:"Object",stat:!0,forced:!c},{getOwnPropertyNames:Zg}),S(),f(Q,z),H[L]=!0},{"../internals/an-object":227,"../internals/array-iteration":229,"../internals/create-property-descriptor":242,"../internals/define-built-in":245,"../internals/define-built-in-accessor":244,"../internals/descriptors":247,"../internals/export":259,"../internals/fails":260,"../internals/function-call":264,"../internals/function-uncurry-this":268,"../internals/global":274,"../internals/has-own-property":275,"../internals/hidden-keys":276,"../internals/internal-state":282,"../internals/is-pure":290,"../internals/object-create":306,"../internals/object-define-properties":307,"../internals/object-define-property":308,"../internals/object-get-own-property-descriptor":309,"../internals/object-get-own-property-names":311,"../internals/object-get-own-property-names-external":310,"../internals/object-get-own-property-symbols":312,"../internals/object-is-prototype-of":314,"../internals/object-keys":316,"../internals/object-property-is-enumerable":317,"../internals/set-to-string-tag":331,"../internals/shared":334,"../internals/shared-key":332,"../internals/symbol-constructor-detection":336,"../internals/symbol-define-to-primitive":337,"../internals/to-indexed-object":341,"../internals/to-property-key":346,"../internals/to-string":348,"../internals/uid":350,"../internals/well-known-symbol":357,"../internals/well-known-symbol-define":355,"../internals/well-known-symbol-wrapped":356}],380:[function(g,I,C){var A=g("../internals/export"),i=g("../internals/get-built-in"),e=g("../internals/has-own-property"),l=g("../internals/to-string"),t=g("../internals/shared"),s=g("../internals/symbol-registry-detection"),c=t("string-to-symbol-registry"),d=t("symbol-to-string-registry");A({target:"Symbol",stat:!0,forced:!s},{for:function(g){var I=l(g);if(e(c,I))return c[I];var C=i("Symbol")(I);return c[I]=C,d[C]=I,C}})},{"../internals/export":259,"../internals/get-built-in":269,"../internals/has-own-property":275,"../internals/shared":334,"../internals/symbol-registry-detection":338,"../internals/to-string":348}],381:[function(g,I,C){g("../modules/es.symbol.constructor"),g("../modules/es.symbol.for"),g("../modules/es.symbol.key-for"),g("../modules/es.json.stringify"),g("../modules/es.object.get-own-property-symbols")},{"../modules/es.json.stringify":362,"../modules/es.object.get-own-property-symbols":365,"../modules/es.symbol.constructor":379,"../modules/es.symbol.for":380,"../modules/es.symbol.key-for":382}],382:[function(g,I,C){var A=g("../internals/export"),i=g("../internals/has-own-property"),e=g("../internals/is-symbol"),l=g("../internals/try-to-string"),t=g("../internals/shared"),s=g("../internals/symbol-registry-detection"),c=t("symbol-to-string-registry");A({target:"Symbol",stat:!0,forced:!s},{keyFor:function(g){if(!e(g))throw new TypeError(l(g)+" is not a symbol");if(i(c,g))return c[g]}})},{"../internals/export":259,"../internals/has-own-property":275,"../internals/is-symbol":292,"../internals/shared":334,"../internals/symbol-registry-detection":338,"../internals/try-to-string":349}],383:[function(g,I,C){function A(g){return Array.isArray?Array.isArray(g):"[object Array]"===m(g)}function i(g){return"boolean"==typeof g}function e(g){return null===g}function l(g){return null==g}function t(g){return"number"==typeof g}function s(g){return"string"==typeof g}function c(g){return"symbol"==typeof g}function d(g){return void 0===g}function o(g){return"[object RegExp]"===m(g)}function n(g){return"object"==typeof g&&null!==g}function a(g){return"[object Date]"===m(g)}function Z(g){return"[object Error]"===m(g)||g instanceof Error}function b(g){return"function"==typeof g}function r(g){return null===g||"boolean"==typeof g||"number"==typeof g||"string"==typeof g||"symbol"==typeof g||void 0===g}function m(g){return Object.prototype.toString.call(g)}C.isArray=A,C.isBoolean=i,C.isNull=e,C.isNullOrUndefined=l,C.isNumber=t,C.isString=s,C.isSymbol=c,C.isUndefined=d,C.isRegExp=o,C.isObject=n,C.isDate=a,C.isError=Z,C.isFunction=b,C.isPrimitive=r,C.isBuffer=g("buffer").Buffer.isBuffer},{buffer:220}],384:[function(g,I,C){(function(C){(function(){var A=g("elliptic"),i=g("bn.js");I.exports=function(g){return new l(g)};var e={secp256k1:{name:"secp256k1",byteLength:32},secp224r1:{name:"p224",byteLength:28},prime256v1:{name:"p256",byteLength:32},prime192v1:{name:"p192",byteLength:24},ed25519:{name:"ed25519",byteLength:32},secp384r1:{name:"p384",byteLength:48},secp521r1:{name:"p521",byteLength:66}};function l(g){this.curveType=e[g],this.curveType||(this.curveType={name:g}),this.curve=new A.ec(this.curveType.name),this.keys=void 0}function t(g,I,A){Array.isArray(g)||(g=g.toArray());var i=new C(g);if(A&&i.lengthC?I=("rmd160"===g?new s:c(g)).update(I).digest():I.lengtht?I=g(I):I.length=I?g:""+Array(I+1-A.length).join(C)+g},h={s:m,z:function(g){var I=-g.utcOffset(),C=Math.abs(I),A=Math.floor(C/60),i=C%60;return(I<=0?"+":"-")+m(A,2,"0")+":"+m(i,2,"0")},m:function g(I,C){if(I.date()1)return g(l[0])}else{var t=I.name;u[t]=I,i=t}return!A&&i&&(G=i),i||!A&&G},p=function(g,I){if(w(g))return g.clone();var C="object"==typeof I?I:{};return C.date=g,C.args=arguments,new y(C)},V=h;V.l=W,V.i=w,V.w=function(g,I){return p(g,{locale:I.$L,utc:I.$u,x:I.$x,$offset:I.$offset})};var y=function(){function r(g){this.$L=W(g.locale,null,!0),this.parse(g),this.$x=this.$x||g.x||{},this[B]=!0}var m=r.prototype;return m.parse=function(g){this.$d=function(g){var I=g.date,C=g.utc;if(null===I)return new Date(NaN);if(V.u(I))return new Date;if(I instanceof Date)return new Date(I);if("string"==typeof I&&!/Z$/i.test(I)){var A=I.match(Z);if(A){var i=A[2]-1||0,e=(A[7]||"0").substring(0,3);return C?new Date(Date.UTC(A[1],i,A[3]||1,A[4]||0,A[5]||0,A[6]||0,e)):new Date(A[1],i,A[3]||1,A[4]||0,A[5]||0,A[6]||0,e)}}return new Date(I)}(g),this.init()},m.init=function(){var g=this.$d;this.$y=g.getFullYear(),this.$M=g.getMonth(),this.$D=g.getDate(),this.$W=g.getDay(),this.$H=g.getHours(),this.$m=g.getMinutes(),this.$s=g.getSeconds(),this.$ms=g.getMilliseconds()},m.$utils=function(){return V},m.isValid=function(){return!(this.$d.toString()===a)},m.isSame=function(g,I){var C=p(g);return this.startOf(I)<=C&&C<=this.endOf(I)},m.isAfter=function(g,I){return p(g)68?1900:2e3)},t=function(g){return function(I){this[g]=+I}},s=[/[+-]\d\d:?(\d\d)?|Z/,function(g){(this.zone||(this.zone={})).offset=function(g){if(!g)return 0;if("Z"===g)return 0;var I=g.match(/([+-]|\d\d)/g),C=60*I[1]+(+I[2]||0);return 0===C?0:"+"===I[0]?-C:C}(g)}],c=function(g){var I=e[g];return I&&(I.indexOf?I:I.s.concat(I.f))},d=function(g,I){var C,A=e.meridiem;if(A){for(var i=1;i<=24;i+=1)if(g.indexOf(A(i,0,I))>-1){C=i>12;break}}else C=g===(I?"pm":"PM");return C},o={A:[i,function(g){this.afternoon=d(g,!1)}],a:[i,function(g){this.afternoon=d(g,!0)}],S:[/\d/,function(g){this.milliseconds=100*+g}],SS:[C,function(g){this.milliseconds=10*+g}],SSS:[/\d{3}/,function(g){this.milliseconds=+g}],s:[A,t("seconds")],ss:[A,t("seconds")],m:[A,t("minutes")],mm:[A,t("minutes")],H:[A,t("hours")],h:[A,t("hours")],HH:[A,t("hours")],hh:[A,t("hours")],D:[A,t("day")],DD:[C,t("day")],Do:[i,function(g){var I=e.ordinal,C=g.match(/\d+/);if(this.day=C[0],I)for(var A=1;A<=31;A+=1)I(A).replace(/\[|\]/g,"")===g&&(this.day=A)}],M:[A,t("month")],MM:[C,t("month")],MMM:[i,function(g){var I=c("months"),C=(c("monthsShort")||I.map((function(g){return g.slice(0,3)}))).indexOf(g)+1;if(C<1)throw new Error;this.month=C%12||C}],MMMM:[i,function(g){var I=c("months").indexOf(g)+1;if(I<1)throw new Error;this.month=I%12||I}],Y:[/[+-]?\d+/,t("year")],YY:[C,function(g){this.year=l(g)}],YYYY:[/\d{4}/,t("year")],Z:s,ZZ:s};function n(C){var A,i;A=C,i=e&&e.formats;for(var l=(C=A.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g,(function(I,C,A){var e=A&&A.toUpperCase();return C||i[A]||g[A]||i[e].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,(function(g,I,C){return I||C.slice(1)}))}))).match(I),t=l.length,s=0;s-1)return new Date(("X"===I?1e3:1)*g);var A=n(I)(g),i=A.year,e=A.month,l=A.day,t=A.hours,s=A.minutes,c=A.seconds,d=A.milliseconds,o=A.zone,a=new Date,Z=l||(i||e?1:a.getDate()),b=i||a.getFullYear(),r=0;i&&!e||(r=e>0?e-1:a.getMonth());var m=t||0,h=s||0,G=c||0,u=d||0;return o?new Date(Date.UTC(b,r,Z,m,h,G,u+60*o.offset*1e3)):C?new Date(Date.UTC(b,r,Z,m,h,G,u)):new Date(b,r,Z,m,h,G,u)}catch(B){return new Date("")}}(I,t,A),this.init(),o&&!0!==o&&(this.$L=this.locale(o).$L),d&&I!=this.format(t)&&(this.$d=new Date("")),e={}}else if(t instanceof Array)for(var a=t.length,Z=1;Z<=a;Z+=1){l[1]=t[Z-1];var b=C.apply(this,l);if(b.isValid()){this.$d=b.$d,this.$L=b.$L,this.init();break}Z===a&&(this.$d=new Date(""))}else i.call(this,g)}}},"object"==typeof C&&void 0!==I?I.exports=i():(A="undefined"!=typeof globalThis?globalThis:A||self).dayjs_plugin_customParseFormat=i()},{}],393:[function(g,I,C){var A,i;A=void 0,i=function(){var g="minute",I=/[+-]\d\d(?::?\d\d)?/g,C=/([+-]|\d\d)/g;return function(A,i,e){var l=i.prototype;e.utc=function(g){return new i({date:g,utc:!0,args:arguments})},l.utc=function(I){var C=e(this.toDate(),{locale:this.$L,utc:!0});return I?C.add(this.utcOffset(),g):C},l.local=function(){return e(this.toDate(),{locale:this.$L,utc:!1})};var t=l.parse;l.parse=function(g){g.utc&&(this.$u=!0),this.$utils().u(g.$offset)||(this.$offset=g.$offset),t.call(this,g)};var s=l.init;l.init=function(){if(this.$u){var g=this.$d;this.$y=g.getUTCFullYear(),this.$M=g.getUTCMonth(),this.$D=g.getUTCDate(),this.$W=g.getUTCDay(),this.$H=g.getUTCHours(),this.$m=g.getUTCMinutes(),this.$s=g.getUTCSeconds(),this.$ms=g.getUTCMilliseconds()}else s.call(this)};var c=l.utcOffset;l.utcOffset=function(A,i){var e=this.$utils().u;if(e(A))return this.$u?0:e(this.$offset)?c.call(this):this.$offset;if("string"==typeof A&&null===(A=function(g){void 0===g&&(g="");var A=g.match(I);if(!A)return null;var i=(""+A[0]).match(C)||["-",0,0],e=i[0],l=60*+i[1]+ +i[2];return 0===l?0:"+"===e?l:-l}(A)))return this;var l=Math.abs(A)<=16?60*A:A,t=this;if(i)return t.$offset=l,t.$u=0===A,t;if(0!==A){var s=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();(t=this.local().add(l+s,g)).$offset=l,t.$x.$localOffset=s}else t=this.utc();return t};var d=l.format;l.format=function(g){var I=g||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return d.call(this,I)},l.valueOf=function(){var g=this.$utils().u(this.$offset)?0:this.$offset+(this.$x.$localOffset||this.$d.getTimezoneOffset());return this.$d.valueOf()-6e4*g},l.isUTC=function(){return!!this.$u},l.toISOString=function(){return this.toDate().toISOString()},l.toString=function(){return this.toDate().toUTCString()};var o=l.toDate;l.toDate=function(g){return"s"===g&&this.$offset?e(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():o.call(this)};var n=l.diff;l.diff=function(g,I,C){if(g&&this.$u===g.$u)return n.call(this,g,I,C);var A=this.local(),i=e(g).local();return n.call(A,i,I,C)}}},"object"==typeof C&&void 0!==I?I.exports=i():(A="undefined"!=typeof globalThis?globalThis:A||self).dayjs_plugin_utc=i()},{}],394:[function(g,I,C){C.utils=g("./des/utils"),C.Cipher=g("./des/cipher"),C.DES=g("./des/des"),C.CBC=g("./des/cbc"),C.EDE=g("./des/ede")},{"./des/cbc":395,"./des/cipher":396,"./des/des":397,"./des/ede":398,"./des/utils":399}],395:[function(g,I,C){var A=g("minimalistic-assert"),i=g("inherits"),e={};function l(g){A.equal(g.length,8,"Invalid IV length"),this.iv=new Array(8);for(var I=0;I0;A--)I+=this._buffer(g,I),C+=this._flushBuffer(i,C);return I+=this._buffer(g,I),i},i.prototype.final=function(g){var I,C;return g&&(I=this.update(g)),C="encrypt"===this.type?this._finalEncrypt():this._finalDecrypt(),I?I.concat(C):C},i.prototype._pad=function(g,I){if(0===I)return!1;for(;I>>1];C=e.r28shl(C,t),i=e.r28shl(i,t),e.pc2(C,i,g.keys,l)}},s.prototype._update=function(g,I,C,A){var i=this._desState,l=e.readUInt32BE(g,I),t=e.readUInt32BE(g,I+4);e.ip(l,t,i.tmp,0),l=i.tmp[0],t=i.tmp[1],"encrypt"===this.type?this._encrypt(i,l,t,i.tmp,0):this._decrypt(i,l,t,i.tmp,0),l=i.tmp[0],t=i.tmp[1],e.writeUInt32BE(C,l,A),e.writeUInt32BE(C,t,A+4)},s.prototype._pad=function(g,I){if(!1===this.padding)return!1;for(var C=g.length-I,A=I;A>>0,l=n}e.rip(t,l,A,i)},s.prototype._decrypt=function(g,I,C,A,i){for(var l=C,t=I,s=g.keys.length-2;s>=0;s-=2){var c=g.keys[s],d=g.keys[s+1];e.expand(l,g.tmp,0),c^=g.tmp[0],d^=g.tmp[1];var o=e.substitute(c,d),n=l;l=(t^e.permute(o))>>>0,t=n}e.rip(l,t,A,i)}},{"./cipher":396,"./utils":399,inherits:440,"minimalistic-assert":453}],398:[function(g,I,C){var A=g("minimalistic-assert"),i=g("inherits"),e=g("./cipher"),l=g("./des");function t(g,I){A.equal(I.length,24,"Invalid key length");var C=I.slice(0,8),i=I.slice(8,16),e=I.slice(16,24);this.ciphers="encrypt"===g?[l.create({type:"encrypt",key:C}),l.create({type:"decrypt",key:i}),l.create({type:"encrypt",key:e})]:[l.create({type:"decrypt",key:e}),l.create({type:"encrypt",key:i}),l.create({type:"decrypt",key:C})]}function s(g){e.call(this,g);var I=new t(this.type,this.options.key);this._edeState=I}i(s,e),I.exports=s,s.create=function(g){return new s(g)},s.prototype._update=function(g,I,C,A){var i=this._edeState;i.ciphers[0]._update(g,I,C,A),i.ciphers[1]._update(C,A,C,A),i.ciphers[2]._update(C,A,C,A)},s.prototype._pad=l.prototype._pad,s.prototype._unpad=l.prototype._unpad},{"./cipher":396,"./des":397,inherits:440,"minimalistic-assert":453}],399:[function(g,I,C){C.readUInt32BE=function(g,I){return(g[0+I]<<24|g[1+I]<<16|g[2+I]<<8|g[3+I])>>>0},C.writeUInt32BE=function(g,I,C){g[0+C]=I>>>24,g[1+C]=I>>>16&255,g[2+C]=I>>>8&255,g[3+C]=255&I},C.ip=function(g,I,C,A){for(var i=0,e=0,l=6;l>=0;l-=2){for(var t=0;t<=24;t+=8)i<<=1,i|=I>>>t+l&1;for(t=0;t<=24;t+=8)i<<=1,i|=g>>>t+l&1}for(l=6;l>=0;l-=2){for(t=1;t<=25;t+=8)e<<=1,e|=I>>>t+l&1;for(t=1;t<=25;t+=8)e<<=1,e|=g>>>t+l&1}C[A+0]=i>>>0,C[A+1]=e>>>0},C.rip=function(g,I,C,A){for(var i=0,e=0,l=0;l<4;l++)for(var t=24;t>=0;t-=8)i<<=1,i|=I>>>t+l&1,i<<=1,i|=g>>>t+l&1;for(l=4;l<8;l++)for(t=24;t>=0;t-=8)e<<=1,e|=I>>>t+l&1,e<<=1,e|=g>>>t+l&1;C[A+0]=i>>>0,C[A+1]=e>>>0},C.pc1=function(g,I,C,A){for(var i=0,e=0,l=7;l>=5;l--){for(var t=0;t<=24;t+=8)i<<=1,i|=I>>t+l&1;for(t=0;t<=24;t+=8)i<<=1,i|=g>>t+l&1}for(t=0;t<=24;t+=8)i<<=1,i|=I>>t+l&1;for(l=1;l<=3;l++){for(t=0;t<=24;t+=8)e<<=1,e|=I>>t+l&1;for(t=0;t<=24;t+=8)e<<=1,e|=g>>t+l&1}for(t=0;t<=24;t+=8)e<<=1,e|=g>>t+l&1;C[A+0]=i>>>0,C[A+1]=e>>>0},C.r28shl=function(g,I){return g<>>28-I};var A=[14,11,17,4,27,23,25,0,13,22,7,18,5,9,16,24,2,20,12,21,1,8,15,26,15,4,25,19,9,1,26,16,5,11,23,8,12,7,17,0,22,3,10,14,6,20,27,24];C.pc2=function(g,I,C,i){for(var e=0,l=0,t=A.length>>>1,s=0;s>>A[s]&1;for(s=t;s>>A[s]&1;C[i+0]=e>>>0,C[i+1]=l>>>0},C.expand=function(g,I,C){var A=0,i=0;A=(1&g)<<5|g>>>27;for(var e=23;e>=15;e-=4)A<<=6,A|=g>>>e&63;for(e=11;e>=3;e-=4)i|=g>>>e&63,i<<=6;i|=(31&g)<<1|g>>>31,I[C+0]=A>>>0,I[C+1]=i>>>0};var i=[14,0,4,15,13,7,1,4,2,14,15,2,11,13,8,1,3,10,10,6,6,12,12,11,5,9,9,5,0,3,7,8,4,15,1,12,14,8,8,2,13,4,6,9,2,1,11,7,15,5,12,11,9,3,7,14,3,10,10,0,5,6,0,13,15,3,1,13,8,4,14,7,6,15,11,2,3,8,4,14,9,12,7,0,2,1,13,10,12,6,0,9,5,11,10,5,0,13,14,8,7,10,11,1,10,3,4,15,13,4,1,2,5,11,8,6,12,7,6,12,9,0,3,5,2,14,15,9,10,13,0,7,9,0,14,9,6,3,3,4,15,6,5,10,1,2,13,8,12,5,7,14,11,12,4,11,2,15,8,1,13,1,6,10,4,13,9,0,8,6,15,9,3,8,0,7,11,4,1,15,2,14,12,3,5,11,10,5,14,2,7,12,7,13,13,8,14,11,3,5,0,6,6,15,9,0,10,3,1,4,2,7,8,2,5,12,11,1,12,10,4,14,15,9,10,3,6,15,9,0,0,6,12,10,11,1,7,13,13,8,15,9,1,4,3,5,14,11,5,12,2,7,8,2,4,14,2,14,12,11,4,2,1,12,7,4,10,7,11,13,6,1,8,5,5,0,3,15,15,10,13,3,0,9,14,8,9,6,4,11,2,8,1,12,11,7,10,1,13,14,7,2,8,13,15,6,9,15,12,0,5,9,6,10,3,4,0,5,14,3,12,10,1,15,10,4,15,2,9,7,2,12,6,9,8,5,0,6,13,1,3,13,4,14,14,0,7,11,5,3,11,8,9,4,14,3,15,2,5,12,2,9,8,5,12,15,3,10,7,11,0,14,4,1,10,7,1,6,13,0,11,8,6,13,4,13,11,0,2,11,14,7,15,4,0,9,8,1,13,10,3,14,12,3,9,5,7,12,5,2,10,15,6,8,1,6,1,6,4,11,11,13,13,8,12,1,3,4,7,10,14,7,10,9,15,5,6,0,8,15,0,14,5,2,9,3,2,12,13,1,2,15,8,13,4,8,6,10,15,3,11,7,1,4,10,12,9,5,3,6,14,11,5,0,0,14,12,9,7,2,7,2,11,1,4,14,1,7,9,4,12,10,14,8,2,13,0,15,6,12,10,9,13,0,15,3,3,5,5,6,8,11];C.substitute=function(g,I){for(var C=0,A=0;A<4;A++)C<<=4,C|=i[64*A+(g>>>18-6*A&63)];for(A=0;A<4;A++)C<<=4,C|=i[256+64*A+(I>>>18-6*A&63)];return C>>>0};var e=[16,25,12,11,3,20,4,15,31,17,9,6,27,14,1,22,30,24,8,18,0,5,29,23,13,19,2,26,10,21,28,7];C.permute=function(g){for(var I=0,C=0;C>>e[C]&1;return I>>>0},C.padSplit=function(g,I,C){for(var A=g.toString(2);A.lengthg;)C.ishrn(1);if(C.isEven()&&C.iadd(t),C.testn(1)||C.iadd(s),I.cmp(s)){if(!I.cmp(c))for(;C.mod(d).cmp(o);)C.iadd(a)}else for(;C.mod(e).cmp(n);)C.iadd(a);if(r(Z=C.shrn(1))&&r(C)&&m(Z)&&m(C)&&l.test(Z)&&l.test(C))return C}}},{"bn.js":404,"miller-rabin":451,randombytes:475}],403:[function(g,I,C){I.exports={modp1:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a63a3620ffffffffffffffff"},modp2:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece65381ffffffffffffffff"},modp5:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca237327ffffffffffffffff"},modp14:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aacaa68ffffffffffffffff"},modp15:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a93ad2caffffffffffffffff"},modp16:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c934063199ffffffffffffffff"},modp17:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dcc4024ffffffffffffffff"},modp18:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dbe115974a3926f12fee5e438777cb6a932df8cd8bec4d073b931ba3bc832b68d9dd300741fa7bf8afc47ed2576f6936ba424663aab639c5ae4f5683423b4742bf1c978238f16cbe39d652de3fdb8befc848ad922222e04a4037c0713eb57a81a23f0c73473fc646cea306b4bcbc8862f8385ddfa9d4b7fa2c087e879683303ed5bdd3a062b3cf5b3a278a66d2a13f83f44f82ddf310ee074ab6a364597e899a0255dc164f31cc50846851df9ab48195ded7ea1b1d510bd7ee74d73faf36bc31ecfa268359046f4eb879f924009438b481c6cd7889a002ed5ee382bc9190da6fc026e479558e4475677e9aa9e3050e2765694dfc81f56e880b96e7160c980dd98edd3dfffffffffffffffff"}}},{}],404:[function(g,I,C){arguments[4][184][0].apply(C,arguments)},{buffer:188,dup:184}],405:[function(g,I,C){var A=C;A.version=g("../package.json").version,A.utils=g("./elliptic/utils"),A.rand=g("brorand"),A.curve=g("./elliptic/curve"),A.curves=g("./elliptic/curves"),A.ec=g("./elliptic/ec"),A.eddsa=g("./elliptic/eddsa")},{"../package.json":421,"./elliptic/curve":408,"./elliptic/curves":411,"./elliptic/ec":412,"./elliptic/eddsa":415,"./elliptic/utils":419,brorand:187}],406:[function(g,I,C){var A=g("bn.js"),i=g("../utils"),e=i.getNAF,l=i.getJSF,t=i.assert;function s(g,I){this.type=g,this.p=new A(I.p,16),this.red=I.prime?A.red(I.prime):A.mont(this.p),this.zero=new A(0).toRed(this.red),this.one=new A(1).toRed(this.red),this.two=new A(2).toRed(this.red),this.n=I.n&&new A(I.n,16),this.g=I.g&&this.pointFromJSON(I.g,I.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var C=this.n&&this.p.div(this.n);!C||C.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}function c(g,I){this.curve=g,this.type=I,this.precomputed=null}I.exports=s,s.prototype.point=function(){throw new Error("Not implemented")},s.prototype.validate=function(){throw new Error("Not implemented")},s.prototype._fixedNafMul=function(g,I){t(g.precomputed);var C=g._getDoubles(),A=e(I,1,this._bitLength),i=(1<=l;d--)s=(s<<1)+A[d];c.push(s)}for(var o=this.jpoint(null,null,null),n=this.jpoint(null,null,null),a=i;a>0;a--){for(l=0;l=0;c--){for(var d=0;c>=0&&0===l[c];c--)d++;if(c>=0&&d++,s=s.dblp(d),c<0)break;var o=l[c];t(0!==o),s="affine"===g.type?o>0?s.mixedAdd(i[o-1>>1]):s.mixedAdd(i[-o-1>>1].neg()):o>0?s.add(i[o-1>>1]):s.add(i[-o-1>>1].neg())}return"affine"===g.type?s.toP():s},s.prototype._wnafMulAdd=function(g,I,C,A,i){var t,s,c,d=this._wnafT1,o=this._wnafT2,n=this._wnafT3,a=0;for(t=0;t=1;t-=2){var b=t-1,r=t;if(1===d[b]&&1===d[r]){var m=[I[b],null,null,I[r]];0===I[b].y.cmp(I[r].y)?(m[1]=I[b].add(I[r]),m[2]=I[b].toJ().mixedAdd(I[r].neg())):0===I[b].y.cmp(I[r].y.redNeg())?(m[1]=I[b].toJ().mixedAdd(I[r]),m[2]=I[b].add(I[r].neg())):(m[1]=I[b].toJ().mixedAdd(I[r]),m[2]=I[b].toJ().mixedAdd(I[r].neg()));var h=[-3,-1,-5,-7,0,7,5,1,3],G=l(C[b],C[r]);for(a=Math.max(G[0].length,a),n[b]=new Array(a),n[r]=new Array(a),s=0;s=0;t--){for(var p=0;t>=0;){var V=!0;for(s=0;s=0&&p++,w=w.dblp(p),t<0)break;for(s=0;s0?c=o[s][y-1>>1]:y<0&&(c=o[s][-y-1>>1].neg()),w="affine"===c.type?w.mixedAdd(c):w.add(c))}}for(t=0;t=Math.ceil((g.bitLength()+1)/I.step)},c.prototype._getDoubles=function(g,I){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var C=[this],A=this,i=0;i":""},c.prototype.isInfinity=function(){return 0===this.x.cmpn(0)&&(0===this.y.cmp(this.z)||this.zOne&&0===this.y.cmp(this.curve.c))},c.prototype._extDbl=function(){var g=this.x.redSqr(),I=this.y.redSqr(),C=this.z.redSqr();C=C.redIAdd(C);var A=this.curve._mulA(g),i=this.x.redAdd(this.y).redSqr().redISub(g).redISub(I),e=A.redAdd(I),l=e.redSub(C),t=A.redSub(I),s=i.redMul(l),c=e.redMul(t),d=i.redMul(t),o=l.redMul(e);return this.curve.point(s,c,o,d)},c.prototype._projDbl=function(){var g,I,C,A,i,e,l=this.x.redAdd(this.y).redSqr(),t=this.x.redSqr(),s=this.y.redSqr();if(this.curve.twisted){var c=(A=this.curve._mulA(t)).redAdd(s);this.zOne?(g=l.redSub(t).redSub(s).redMul(c.redSub(this.curve.two)),I=c.redMul(A.redSub(s)),C=c.redSqr().redSub(c).redSub(c)):(i=this.z.redSqr(),e=c.redSub(i).redISub(i),g=l.redSub(t).redISub(s).redMul(e),I=c.redMul(A.redSub(s)),C=c.redMul(e))}else A=t.redAdd(s),i=this.curve._mulC(this.z).redSqr(),e=A.redSub(i).redSub(i),g=this.curve._mulC(l.redISub(A)).redMul(e),I=this.curve._mulC(A).redMul(t.redISub(s)),C=A.redMul(e);return this.curve.point(g,I,C)},c.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},c.prototype._extAdd=function(g){var I=this.y.redSub(this.x).redMul(g.y.redSub(g.x)),C=this.y.redAdd(this.x).redMul(g.y.redAdd(g.x)),A=this.t.redMul(this.curve.dd).redMul(g.t),i=this.z.redMul(g.z.redAdd(g.z)),e=C.redSub(I),l=i.redSub(A),t=i.redAdd(A),s=C.redAdd(I),c=e.redMul(l),d=t.redMul(s),o=e.redMul(s),n=l.redMul(t);return this.curve.point(c,d,n,o)},c.prototype._projAdd=function(g){var I,C,A=this.z.redMul(g.z),i=A.redSqr(),e=this.x.redMul(g.x),l=this.y.redMul(g.y),t=this.curve.d.redMul(e).redMul(l),s=i.redSub(t),c=i.redAdd(t),d=this.x.redAdd(this.y).redMul(g.x.redAdd(g.y)).redISub(e).redISub(l),o=A.redMul(s).redMul(d);return this.curve.twisted?(I=A.redMul(c).redMul(l.redSub(this.curve._mulA(e))),C=s.redMul(c)):(I=A.redMul(c).redMul(l.redSub(e)),C=this.curve._mulC(s).redMul(c)),this.curve.point(o,I,C)},c.prototype.add=function(g){return this.isInfinity()?g:g.isInfinity()?this:this.curve.extended?this._extAdd(g):this._projAdd(g)},c.prototype.mul=function(g){return this._hasDoubles(g)?this.curve._fixedNafMul(this,g):this.curve._wnafMul(this,g)},c.prototype.mulAdd=function(g,I,C){return this.curve._wnafMulAdd(1,[this,I],[g,C],2,!1)},c.prototype.jmulAdd=function(g,I,C){return this.curve._wnafMulAdd(1,[this,I],[g,C],2,!0)},c.prototype.normalize=function(){if(this.zOne)return this;var g=this.z.redInvm();return this.x=this.x.redMul(g),this.y=this.y.redMul(g),this.t&&(this.t=this.t.redMul(g)),this.z=this.curve.one,this.zOne=!0,this},c.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},c.prototype.getX=function(){return this.normalize(),this.x.fromRed()},c.prototype.getY=function(){return this.normalize(),this.y.fromRed()},c.prototype.eq=function(g){return this===g||0===this.getX().cmp(g.getX())&&0===this.getY().cmp(g.getY())},c.prototype.eqXToP=function(g){var I=g.toRed(this.curve.red).redMul(this.z);if(0===this.x.cmp(I))return!0;for(var C=g.clone(),A=this.curve.redN.redMul(this.z);;){if(C.iadd(this.curve.n),C.cmp(this.curve.p)>=0)return!1;if(I.redIAdd(A),0===this.x.cmp(I))return!0}},c.prototype.toP=c.prototype.normalize,c.prototype.mixedAdd=c.prototype.add},{"../utils":419,"./base":406,"bn.js":420,inherits:440}],408:[function(g,I,C){var A=C;A.base=g("./base"),A.short=g("./short"),A.mont=g("./mont"),A.edwards=g("./edwards")},{"./base":406,"./edwards":407,"./mont":409,"./short":410}],409:[function(g,I,C){var A=g("bn.js"),i=g("inherits"),e=g("./base"),l=g("../utils");function t(g){e.call(this,"mont",g),this.a=new A(g.a,16).toRed(this.red),this.b=new A(g.b,16).toRed(this.red),this.i4=new A(4).toRed(this.red).redInvm(),this.two=new A(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}function s(g,I,C){e.BasePoint.call(this,g,"projective"),null===I&&null===C?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new A(I,16),this.z=new A(C,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}i(t,e),I.exports=t,t.prototype.validate=function(g){var I=g.normalize().x,C=I.redSqr(),A=C.redMul(I).redAdd(C.redMul(this.a)).redAdd(I);return 0===A.redSqrt().redSqr().cmp(A)},i(s,e.BasePoint),t.prototype.decodePoint=function(g,I){return this.point(l.toArray(g,I),1)},t.prototype.point=function(g,I){return new s(this,g,I)},t.prototype.pointFromJSON=function(g){return s.fromJSON(this,g)},s.prototype.precompute=function(){},s.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())},s.fromJSON=function(g,I){return new s(g,I[0],I[1]||g.one)},s.prototype.inspect=function(){return this.isInfinity()?"":""},s.prototype.isInfinity=function(){return 0===this.z.cmpn(0)},s.prototype.dbl=function(){var g=this.x.redAdd(this.z).redSqr(),I=this.x.redSub(this.z).redSqr(),C=g.redSub(I),A=g.redMul(I),i=C.redMul(I.redAdd(this.curve.a24.redMul(C)));return this.curve.point(A,i)},s.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},s.prototype.diffAdd=function(g,I){var C=this.x.redAdd(this.z),A=this.x.redSub(this.z),i=g.x.redAdd(g.z),e=g.x.redSub(g.z).redMul(C),l=i.redMul(A),t=I.z.redMul(e.redAdd(l).redSqr()),s=I.x.redMul(e.redISub(l).redSqr());return this.curve.point(t,s)},s.prototype.mul=function(g){for(var I=g.clone(),C=this,A=this.curve.point(null,null),i=this,e=[];0!==I.cmpn(0);I.iushrn(1))e.push(I.andln(1));for(var l=e.length-1;l>=0;l--)0===e[l]?(C=C.diffAdd(A,i),A=A.dbl()):(A=C.diffAdd(A,i),C=C.dbl());return A},s.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},s.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")},s.prototype.eq=function(g){return 0===this.getX().cmp(g.getX())},s.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},s.prototype.getX=function(){return this.normalize(),this.x.fromRed()}},{"../utils":419,"./base":406,"bn.js":420,inherits:440}],410:[function(g,I,C){var A=g("../utils"),i=g("bn.js"),e=g("inherits"),l=g("./base"),t=A.assert;function s(g){l.call(this,"short",g),this.a=new i(g.a,16).toRed(this.red),this.b=new i(g.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=0===this.a.fromRed().cmpn(0),this.threeA=0===this.a.fromRed().sub(this.p).cmpn(-3),this.endo=this._getEndomorphism(g),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}function c(g,I,C,A){l.BasePoint.call(this,g,"affine"),null===I&&null===C?(this.x=null,this.y=null,this.inf=!0):(this.x=new i(I,16),this.y=new i(C,16),A&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}function d(g,I,C,A){l.BasePoint.call(this,g,"jacobian"),null===I&&null===C&&null===A?(this.x=this.curve.one,this.y=this.curve.one,this.z=new i(0)):(this.x=new i(I,16),this.y=new i(C,16),this.z=new i(A,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}e(s,l),I.exports=s,s.prototype._getEndomorphism=function(g){if(this.zeroA&&this.g&&this.n&&1===this.p.modn(3)){var I,C;if(g.beta)I=new i(g.beta,16).toRed(this.red);else{var A=this._getEndoRoots(this.p);I=(I=A[0].cmp(A[1])<0?A[0]:A[1]).toRed(this.red)}if(g.lambda)C=new i(g.lambda,16);else{var e=this._getEndoRoots(this.n);0===this.g.mul(e[0]).x.cmp(this.g.x.redMul(I))?C=e[0]:(C=e[1],t(0===this.g.mul(C).x.cmp(this.g.x.redMul(I))))}return{beta:I,lambda:C,basis:g.basis?g.basis.map((function(g){return{a:new i(g.a,16),b:new i(g.b,16)}})):this._getEndoBasis(C)}}},s.prototype._getEndoRoots=function(g){var I=g===this.p?this.red:i.mont(g),C=new i(2).toRed(I).redInvm(),A=C.redNeg(),e=new i(3).toRed(I).redNeg().redSqrt().redMul(C);return[A.redAdd(e).fromRed(),A.redSub(e).fromRed()]},s.prototype._getEndoBasis=function(g){for(var I,C,A,e,l,t,s,c,d,o=this.n.ushrn(Math.floor(this.n.bitLength()/2)),n=g,a=this.n.clone(),Z=new i(1),b=new i(0),r=new i(0),m=new i(1),h=0;0!==n.cmpn(0);){var G=a.div(n);c=a.sub(G.mul(n)),d=r.sub(G.mul(Z));var u=m.sub(G.mul(b));if(!A&&c.cmp(o)<0)I=s.neg(),C=Z,A=c.neg(),e=d;else if(A&&2==++h)break;s=c,a=n,n=c,r=Z,Z=d,m=b,b=u}l=c.neg(),t=d;var B=A.sqr().add(e.sqr());return l.sqr().add(t.sqr()).cmp(B)>=0&&(l=I,t=C),A.negative&&(A=A.neg(),e=e.neg()),l.negative&&(l=l.neg(),t=t.neg()),[{a:A,b:e},{a:l,b:t}]},s.prototype._endoSplit=function(g){var I=this.endo.basis,C=I[0],A=I[1],i=A.b.mul(g).divRound(this.n),e=C.b.neg().mul(g).divRound(this.n),l=i.mul(C.a),t=e.mul(A.a),s=i.mul(C.b),c=e.mul(A.b);return{k1:g.sub(l).sub(t),k2:s.add(c).neg()}},s.prototype.pointFromX=function(g,I){(g=new i(g,16)).red||(g=g.toRed(this.red));var C=g.redSqr().redMul(g).redIAdd(g.redMul(this.a)).redIAdd(this.b),A=C.redSqrt();if(0!==A.redSqr().redSub(C).cmp(this.zero))throw new Error("invalid point");var e=A.fromRed().isOdd();return(I&&!e||!I&&e)&&(A=A.redNeg()),this.point(g,A)},s.prototype.validate=function(g){if(g.inf)return!0;var I=g.x,C=g.y,A=this.a.redMul(I),i=I.redSqr().redMul(I).redIAdd(A).redIAdd(this.b);return 0===C.redSqr().redISub(i).cmpn(0)},s.prototype._endoWnafMulAdd=function(g,I,C){for(var A=this._endoWnafT1,i=this._endoWnafT2,e=0;e":""},c.prototype.isInfinity=function(){return this.inf},c.prototype.add=function(g){if(this.inf)return g;if(g.inf)return this;if(this.eq(g))return this.dbl();if(this.neg().eq(g))return this.curve.point(null,null);if(0===this.x.cmp(g.x))return this.curve.point(null,null);var I=this.y.redSub(g.y);0!==I.cmpn(0)&&(I=I.redMul(this.x.redSub(g.x).redInvm()));var C=I.redSqr().redISub(this.x).redISub(g.x),A=I.redMul(this.x.redSub(C)).redISub(this.y);return this.curve.point(C,A)},c.prototype.dbl=function(){if(this.inf)return this;var g=this.y.redAdd(this.y);if(0===g.cmpn(0))return this.curve.point(null,null);var I=this.curve.a,C=this.x.redSqr(),A=g.redInvm(),i=C.redAdd(C).redIAdd(C).redIAdd(I).redMul(A),e=i.redSqr().redISub(this.x.redAdd(this.x)),l=i.redMul(this.x.redSub(e)).redISub(this.y);return this.curve.point(e,l)},c.prototype.getX=function(){return this.x.fromRed()},c.prototype.getY=function(){return this.y.fromRed()},c.prototype.mul=function(g){return g=new i(g,16),this.isInfinity()?this:this._hasDoubles(g)?this.curve._fixedNafMul(this,g):this.curve.endo?this.curve._endoWnafMulAdd([this],[g]):this.curve._wnafMul(this,g)},c.prototype.mulAdd=function(g,I,C){var A=[this,I],i=[g,C];return this.curve.endo?this.curve._endoWnafMulAdd(A,i):this.curve._wnafMulAdd(1,A,i,2)},c.prototype.jmulAdd=function(g,I,C){var A=[this,I],i=[g,C];return this.curve.endo?this.curve._endoWnafMulAdd(A,i,!0):this.curve._wnafMulAdd(1,A,i,2,!0)},c.prototype.eq=function(g){return this===g||this.inf===g.inf&&(this.inf||0===this.x.cmp(g.x)&&0===this.y.cmp(g.y))},c.prototype.neg=function(g){if(this.inf)return this;var I=this.curve.point(this.x,this.y.redNeg());if(g&&this.precomputed){var C=this.precomputed,A=function(g){return g.neg()};I.precomputed={naf:C.naf&&{wnd:C.naf.wnd,points:C.naf.points.map(A)},doubles:C.doubles&&{step:C.doubles.step,points:C.doubles.points.map(A)}}}return I},c.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},e(d,l.BasePoint),s.prototype.jpoint=function(g,I,C){return new d(this,g,I,C)},d.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var g=this.z.redInvm(),I=g.redSqr(),C=this.x.redMul(I),A=this.y.redMul(I).redMul(g);return this.curve.point(C,A)},d.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},d.prototype.add=function(g){if(this.isInfinity())return g;if(g.isInfinity())return this;var I=g.z.redSqr(),C=this.z.redSqr(),A=this.x.redMul(I),i=g.x.redMul(C),e=this.y.redMul(I.redMul(g.z)),l=g.y.redMul(C.redMul(this.z)),t=A.redSub(i),s=e.redSub(l);if(0===t.cmpn(0))return 0!==s.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var c=t.redSqr(),d=c.redMul(t),o=A.redMul(c),n=s.redSqr().redIAdd(d).redISub(o).redISub(o),a=s.redMul(o.redISub(n)).redISub(e.redMul(d)),Z=this.z.redMul(g.z).redMul(t);return this.curve.jpoint(n,a,Z)},d.prototype.mixedAdd=function(g){if(this.isInfinity())return g.toJ();if(g.isInfinity())return this;var I=this.z.redSqr(),C=this.x,A=g.x.redMul(I),i=this.y,e=g.y.redMul(I).redMul(this.z),l=C.redSub(A),t=i.redSub(e);if(0===l.cmpn(0))return 0!==t.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var s=l.redSqr(),c=s.redMul(l),d=C.redMul(s),o=t.redSqr().redIAdd(c).redISub(d).redISub(d),n=t.redMul(d.redISub(o)).redISub(i.redMul(c)),a=this.z.redMul(l);return this.curve.jpoint(o,n,a)},d.prototype.dblp=function(g){if(0===g)return this;if(this.isInfinity())return this;if(!g)return this.dbl();var I;if(this.curve.zeroA||this.curve.threeA){var C=this;for(I=0;I=0)return!1;if(C.redIAdd(i),0===this.x.cmp(C))return!0}},d.prototype.inspect=function(){return this.isInfinity()?"":""},d.prototype.isInfinity=function(){return 0===this.z.cmpn(0)}},{"../utils":419,"./base":406,"bn.js":420,inherits:440}],411:[function(g,I,C){var A,i=C,e=g("hash.js"),l=g("./curve"),t=g("./utils").assert;function s(g){"short"===g.type?this.curve=new l.short(g):"edwards"===g.type?this.curve=new l.edwards(g):this.curve=new l.mont(g),this.g=this.curve.g,this.n=this.curve.n,this.hash=g.hash,t(this.g.validate(),"Invalid curve"),t(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function c(g,I){Object.defineProperty(i,g,{configurable:!0,enumerable:!0,get:function(){var C=new s(I);return Object.defineProperty(i,g,{configurable:!0,enumerable:!0,value:C}),C}})}i.PresetCurve=s,c("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:e.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),c("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:e.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),c("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:e.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),c("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:e.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),c("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:e.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),c("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:e.sha256,gRed:!1,g:["9"]}),c("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:e.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});try{A=g("./precomputed/secp256k1")}catch(d){A=void 0}c("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:e.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",A]})},{"./curve":408,"./precomputed/secp256k1":418,"./utils":419,"hash.js":426}],412:[function(g,I,C){var A=g("bn.js"),i=g("hmac-drbg"),e=g("../utils"),l=g("../curves"),t=g("brorand"),s=e.assert,c=g("./key"),d=g("./signature");function o(g){if(!(this instanceof o))return new o(g);"string"==typeof g&&(s(Object.prototype.hasOwnProperty.call(l,g),"Unknown curve "+g),g=l[g]),g instanceof l.PresetCurve&&(g={curve:g}),this.curve=g.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=g.curve.g,this.g.precompute(g.curve.n.bitLength()+1),this.hash=g.hash||g.curve.hash}I.exports=o,o.prototype.keyPair=function(g){return new c(this,g)},o.prototype.keyFromPrivate=function(g,I){return c.fromPrivate(this,g,I)},o.prototype.keyFromPublic=function(g,I){return c.fromPublic(this,g,I)},o.prototype.genKeyPair=function(g){g||(g={});for(var I=new i({hash:this.hash,pers:g.pers,persEnc:g.persEnc||"utf8",entropy:g.entropy||t(this.hash.hmacStrength),entropyEnc:g.entropy&&g.entropyEnc||"utf8",nonce:this.n.toArray()}),C=this.n.byteLength(),e=this.n.sub(new A(2));;){var l=new A(I.generate(C));if(!(l.cmp(e)>0))return l.iaddn(1),this.keyFromPrivate(l)}},o.prototype._truncateToN=function(g,I){var C=8*g.byteLength()-this.n.bitLength();return C>0&&(g=g.ushrn(C)),!I&&g.cmp(this.n)>=0?g.sub(this.n):g},o.prototype.sign=function(g,I,C,e){"object"==typeof C&&(e=C,C=null),e||(e={}),I=this.keyFromPrivate(I,C),g=this._truncateToN(new A(g,16));for(var l=this.n.byteLength(),t=I.getPrivate().toArray("be",l),s=g.toArray("be",l),c=new i({hash:this.hash,entropy:t,nonce:s,pers:e.pers,persEnc:e.persEnc||"utf8"}),o=this.n.sub(new A(1)),n=0;;n++){var a=e.k?e.k(n):new A(c.generate(this.n.byteLength()));if(!((a=this._truncateToN(a,!0)).cmpn(1)<=0||a.cmp(o)>=0)){var Z=this.g.mul(a);if(!Z.isInfinity()){var b=Z.getX(),r=b.umod(this.n);if(0!==r.cmpn(0)){var m=a.invm(this.n).mul(r.mul(I.getPrivate()).iadd(g));if(0!==(m=m.umod(this.n)).cmpn(0)){var h=(Z.getY().isOdd()?1:0)|(0!==b.cmp(r)?2:0);return e.canonical&&m.cmp(this.nh)>0&&(m=this.n.sub(m),h^=1),new d({r:r,s:m,recoveryParam:h})}}}}}},o.prototype.verify=function(g,I,C,i){g=this._truncateToN(new A(g,16)),C=this.keyFromPublic(C,i);var e=(I=new d(I,"hex")).r,l=I.s;if(e.cmpn(1)<0||e.cmp(this.n)>=0)return!1;if(l.cmpn(1)<0||l.cmp(this.n)>=0)return!1;var t,s=l.invm(this.n),c=s.mul(g).umod(this.n),o=s.mul(e).umod(this.n);return this.curve._maxwellTrick?!(t=this.g.jmulAdd(c,C.getPublic(),o)).isInfinity()&&t.eqXToP(e):!(t=this.g.mulAdd(c,C.getPublic(),o)).isInfinity()&&0===t.getX().umod(this.n).cmp(e)},o.prototype.recoverPubKey=function(g,I,C,i){s((3&C)===C,"The recovery param is more than two bits"),I=new d(I,i);var e=this.n,l=new A(g),t=I.r,c=I.s,o=1&C,n=C>>1;if(t.cmp(this.curve.p.umod(this.curve.n))>=0&&n)throw new Error("Unable to find sencond key candinate");t=n?this.curve.pointFromX(t.add(this.curve.n),o):this.curve.pointFromX(t,o);var a=I.r.invm(e),Z=e.sub(l).mul(a).umod(e),b=c.mul(a).umod(e);return this.g.mulAdd(Z,t,b)},o.prototype.getKeyRecoveryParam=function(g,I,C,A){if(null!==(I=new d(I,A)).recoveryParam)return I.recoveryParam;for(var i=0;i<4;i++){var e;try{e=this.recoverPubKey(g,I,i)}catch(l){continue}if(e.eq(C))return i}throw new Error("Unable to find valid recovery factor")}},{"../curves":411,"../utils":419,"./key":413,"./signature":414,"bn.js":420,brorand:187,"hmac-drbg":438}],413:[function(g,I,C){var A=g("bn.js"),i=g("../utils").assert;function e(g,I){this.ec=g,this.priv=null,this.pub=null,I.priv&&this._importPrivate(I.priv,I.privEnc),I.pub&&this._importPublic(I.pub,I.pubEnc)}I.exports=e,e.fromPublic=function(g,I,C){return I instanceof e?I:new e(g,{pub:I,pubEnc:C})},e.fromPrivate=function(g,I,C){return I instanceof e?I:new e(g,{priv:I,privEnc:C})},e.prototype.validate=function(){var g=this.getPublic();return g.isInfinity()?{result:!1,reason:"Invalid public key"}:g.validate()?g.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}},e.prototype.getPublic=function(g,I){return"string"==typeof g&&(I=g,g=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),I?this.pub.encode(I,g):this.pub},e.prototype.getPrivate=function(g){return"hex"===g?this.priv.toString(16,2):this.priv},e.prototype._importPrivate=function(g,I){this.priv=new A(g,I||16),this.priv=this.priv.umod(this.ec.curve.n)},e.prototype._importPublic=function(g,I){if(g.x||g.y)return"mont"===this.ec.curve.type?i(g.x,"Need x coordinate"):"short"!==this.ec.curve.type&&"edwards"!==this.ec.curve.type||i(g.x&&g.y,"Need both x and y coordinate"),void(this.pub=this.ec.curve.point(g.x,g.y));this.pub=this.ec.curve.decodePoint(g,I)},e.prototype.derive=function(g){return g.validate()||i(g.validate(),"public point not validated"),g.mul(this.priv).getX()},e.prototype.sign=function(g,I,C){return this.ec.sign(g,this,I,C)},e.prototype.verify=function(g,I){return this.ec.verify(g,I,this)},e.prototype.inspect=function(){return""}},{"../utils":419,"bn.js":420}],414:[function(g,I,C){var A=g("bn.js"),i=g("../utils"),e=i.assert;function l(g,I){if(g instanceof l)return g;this._importDER(g,I)||(e(g.r&&g.s,"Signature without r or s"),this.r=new A(g.r,16),this.s=new A(g.s,16),void 0===g.recoveryParam?this.recoveryParam=null:this.recoveryParam=g.recoveryParam)}function t(){this.place=0}function s(g,I){var C=g[I.place++];if(!(128&C))return C;var A=15&C;if(0===A||A>4)return!1;for(var i=0,e=0,l=I.place;e>>=0;return!(i<=127)&&(I.place=l,i)}function c(g){for(var I=0,C=g.length-1;!g[I]&&!(128&g[I+1])&&I>>3);for(g.push(128|C);--C;)g.push(I>>>(C<<3)&255);g.push(I)}}I.exports=l,l.prototype._importDER=function(g,I){g=i.toArray(g,I);var C=new t;if(48!==g[C.place++])return!1;var e=s(g,C);if(!1===e)return!1;if(e+C.place!==g.length)return!1;if(2!==g[C.place++])return!1;var l=s(g,C);if(!1===l)return!1;var c=g.slice(C.place,l+C.place);if(C.place+=l,2!==g[C.place++])return!1;var d=s(g,C);if(!1===d)return!1;if(g.length!==d+C.place)return!1;var o=g.slice(C.place,d+C.place);if(0===c[0]){if(!(128&c[1]))return!1;c=c.slice(1)}if(0===o[0]){if(!(128&o[1]))return!1;o=o.slice(1)}return this.r=new A(c),this.s=new A(o),this.recoveryParam=null,!0},l.prototype.toDER=function(g){var I=this.r.toArray(),C=this.s.toArray();for(128&I[0]&&(I=[0].concat(I)),128&C[0]&&(C=[0].concat(C)),I=c(I),C=c(C);!(C[0]||128&C[1]);)C=C.slice(1);var A=[2];d(A,I.length),(A=A.concat(I)).push(2),d(A,C.length);var e=A.concat(C),l=[48];return d(l,e.length),l=l.concat(e),i.encode(l,g)}},{"../utils":419,"bn.js":420}],415:[function(g,I,C){var A=g("hash.js"),i=g("../curves"),e=g("../utils"),l=e.assert,t=e.parseBytes,s=g("./key"),c=g("./signature");function d(g){if(l("ed25519"===g,"only tested with ed25519 so far"),!(this instanceof d))return new d(g);g=i[g].curve,this.curve=g,this.g=g.g,this.g.precompute(g.n.bitLength()+1),this.pointClass=g.point().constructor,this.encodingLength=Math.ceil(g.n.bitLength()/8),this.hash=A.sha512}I.exports=d,d.prototype.sign=function(g,I){g=t(g);var C=this.keyFromSecret(I),A=this.hashInt(C.messagePrefix(),g),i=this.g.mul(A),e=this.encodePoint(i),l=this.hashInt(e,C.pubBytes(),g).mul(C.priv()),s=A.add(l).umod(this.curve.n);return this.makeSignature({R:i,S:s,Rencoded:e})},d.prototype.verify=function(g,I,C){g=t(g),I=this.makeSignature(I);var A=this.keyFromPublic(C),i=this.hashInt(I.Rencoded(),A.pubBytes(),g),e=this.g.mul(I.S());return I.R().add(A.pub().mul(i)).eq(e)},d.prototype.hashInt=function(){for(var g=this.hash(),I=0;I(i>>1)-1?(i>>1)-s:s,e.isubn(t)):t=0,A[l]=t,e.iushrn(1)}return A}function s(g,I){var C=[[],[]];g=g.clone(),I=I.clone();for(var A,i=0,e=0;g.cmpn(-i)>0||I.cmpn(-e)>0;){var l,t,s=g.andln(3)+i&3,c=I.andln(3)+e&3;3===s&&(s=-1),3===c&&(c=-1),l=1&s?3!=(A=g.andln(7)+i&7)&&5!==A||2!==c?s:-s:0,C[0].push(l),t=1&c?3!=(A=I.andln(7)+e&7)&&5!==A||2!==s?c:-c:0,C[1].push(t),2*i===l+1&&(i=1-i),2*e===t+1&&(e=1-e),g.iushrn(1),I.iushrn(1)}return C}function c(g,I,C){var A="_"+I;g.prototype[I]=function(){return void 0!==this[A]?this[A]:this[A]=C.call(this)}}function d(g){return"string"==typeof g?A.toArray(g,"hex"):g}function o(g){return new i(g,"hex","le")}A.assert=e,A.toArray=l.toArray,A.zero2=l.zero2,A.toHex=l.toHex,A.encode=l.encode,A.getNAF=t,A.getJSF=s,A.cachedProperty=c,A.parseBytes=d,A.intFromLE=o},{"bn.js":420,"minimalistic-assert":453,"minimalistic-crypto-utils":454}],420:[function(g,I,C){arguments[4][184][0].apply(C,arguments)},{buffer:188,dup:184}],421:[function(g,I,C){I.exports={name:"elliptic",version:"6.5.4",description:"EC cryptography",main:"lib/elliptic.js",files:["lib"],scripts:{lint:"eslint lib test","lint:fix":"npm run lint -- --fix",unit:"istanbul test _mocha --reporter=spec test/index.js",test:"npm run lint && npm run unit",version:"grunt dist && git add dist/"},repository:{type:"git",url:"git@github.com:indutny/elliptic"},keywords:["EC","Elliptic","curve","Cryptography"],author:"Fedor Indutny ",license:"MIT",bugs:{url:"https://github.com/indutny/elliptic/issues"},homepage:"https://github.com/indutny/elliptic",devDependencies:{brfs:"^2.0.2",coveralls:"^3.1.0",eslint:"^7.6.0",grunt:"^1.2.1","grunt-browserify":"^5.3.0","grunt-cli":"^1.3.2","grunt-contrib-connect":"^3.0.0","grunt-contrib-copy":"^1.0.0","grunt-contrib-uglify":"^5.0.0","grunt-mocha-istanbul":"^5.0.2","grunt-saucelabs":"^9.0.1",istanbul:"^0.4.5",mocha:"^8.0.1"},dependencies:{"bn.js":"^4.11.9",brorand:"^1.1.0","hash.js":"^1.0.0","hmac-drbg":"^1.0.1",inherits:"^2.0.4","minimalistic-assert":"^1.0.1","minimalistic-crypto-utils":"^1.0.1"}}},{}],422:[function(g,I,C){var A=Object.create||p,i=Object.keys||V,e=Function.prototype.bind||y;function l(){this._events&&Object.prototype.hasOwnProperty.call(this,"_events")||(this._events=A(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0}I.exports=l,l.EventEmitter=l,l.prototype._events=void 0,l.prototype._maxListeners=void 0;var t,s=10;try{var c={};Object.defineProperty&&Object.defineProperty(c,"x",{value:0}),t=0===c.x}catch(X){t=!1}function d(g){return void 0===g._maxListeners?l.defaultMaxListeners:g._maxListeners}function o(g,I,C){if(I)g.call(C);else for(var A=g.length,i=w(g,A),e=0;e0&&t.length>e){t.warned=!0;var s=new Error("Possible EventEmitter memory leak detected. "+t.length+' "'+String(I)+'" listeners added. Use emitter.setMaxListeners() to increase limit.');s.name="MaxListenersExceededWarning",s.emitter=g,s.type=I,s.count=t.length,"object"==typeof console&&console.warn&&console.warn("%s: %s",s.name,s.message)}}else t=l[I]=C,++g._eventsCount;return g}function m(){if(!this.fired)switch(this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length){case 0:return this.listener.call(this.target);case 1:return this.listener.call(this.target,arguments[0]);case 2:return this.listener.call(this.target,arguments[0],arguments[1]);case 3:return this.listener.call(this.target,arguments[0],arguments[1],arguments[2]);default:for(var g=new Array(arguments.length),I=0;I1&&(I=arguments[1]),I instanceof Error)throw I;var s=new Error('Unhandled "error" event. ('+I+")");throw s.context=I,s}if(!(C=l[g]))return!1;var c="function"==typeof C;switch(A=arguments.length){case 1:o(C,c,this);break;case 2:n(C,c,this,arguments[1]);break;case 3:a(C,c,this,arguments[1],arguments[2]);break;case 4:Z(C,c,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(A-1),e=1;e=0;l--)if(C[l]===I||C[l].listener===I){t=C[l].listener,e=l;break}if(e<0)return this;0===e?C.shift():B(C,e),1===C.length&&(i[g]=C[0]),i.removeListener&&this.emit("removeListener",g,t||I)}return this},l.prototype.removeAllListeners=function(g){var I,C,e;if(!(C=this._events))return this;if(!C.removeListener)return 0===arguments.length?(this._events=A(null),this._eventsCount=0):C[g]&&(0==--this._eventsCount?this._events=A(null):delete C[g]),this;if(0===arguments.length){var l,t=i(C);for(e=0;e=0;e--)this.removeListener(g,I[e]);return this},l.prototype.listeners=function(g){return G(this,g,!0)},l.prototype.rawListeners=function(g){return G(this,g,!1)},l.listenerCount=function(g,I){return"function"==typeof g.listenerCount?g.listenerCount(I):u.call(g,I)},l.prototype.listenerCount=u,l.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]}},{}],423:[function(g,I,C){var A=g("safe-buffer").Buffer,i=g("md5.js");function e(g,I,C,e){if(A.isBuffer(g)||(g=A.from(g,"binary")),I&&(A.isBuffer(I)||(I=A.from(I,"binary")),8!==I.length))throw new RangeError("salt should be Buffer with 8 byte length");for(var l=C/8,t=A.alloc(l),s=A.alloc(e||0),c=A.alloc(0);l>0||e>0;){var d=new i;d.update(c),d.update(g),I&&d.update(I),c=d.digest();var o=0;if(l>0){var n=t.length-l;o=Math.min(l,c.length),c.copy(t,n,0,o),l-=o}if(o0){var a=s.length-e,Z=Math.min(e,c.length-o);c.copy(s,a,o,o+Z),e-=Z}}return c.fill(0),{key:t,iv:s}}I.exports=e},{"md5.js":450,"safe-buffer":494}],424:[function(g,I,C){Object.defineProperty(C,"__esModule",{value:!0}),C.CsvParserStream=C.ParserOptions=C.parseFile=C.parseStream=C.parseString=C.parse=C.FormatterOptions=C.CsvFormatterStream=C.writeToPath=C.writeToString=C.writeToBuffer=C.writeToStream=C.write=C.format=void 0;var A=g("@fast-csv/format");Object.defineProperty(C,"format",{enumerable:!0,get:function(){return A.format}}),Object.defineProperty(C,"write",{enumerable:!0,get:function(){return A.write}}),Object.defineProperty(C,"writeToStream",{enumerable:!0,get:function(){return A.writeToStream}}),Object.defineProperty(C,"writeToBuffer",{enumerable:!0,get:function(){return A.writeToBuffer}}),Object.defineProperty(C,"writeToString",{enumerable:!0,get:function(){return A.writeToString}}),Object.defineProperty(C,"writeToPath",{enumerable:!0,get:function(){return A.writeToPath}}),Object.defineProperty(C,"CsvFormatterStream",{enumerable:!0,get:function(){return A.CsvFormatterStream}}),Object.defineProperty(C,"FormatterOptions",{enumerable:!0,get:function(){return A.FormatterOptions}});var i=g("@fast-csv/parse");Object.defineProperty(C,"parse",{enumerable:!0,get:function(){return i.parse}}),Object.defineProperty(C,"parseString",{enumerable:!0,get:function(){return i.parseString}}),Object.defineProperty(C,"parseStream",{enumerable:!0,get:function(){return i.parseStream}}),Object.defineProperty(C,"parseFile",{enumerable:!0,get:function(){return i.parseFile}}),Object.defineProperty(C,"ParserOptions",{enumerable:!0,get:function(){return i.ParserOptions}}),Object.defineProperty(C,"CsvParserStream",{enumerable:!0,get:function(){return i.CsvParserStream}})},{"@fast-csv/format":151,"@fast-csv/parse":155}],425:[function(g,I,C){var A=g("safe-buffer").Buffer,i=g("readable-stream").Transform;function e(g,I){if(!A.isBuffer(g)&&"string"!=typeof g)throw new TypeError(I+" must be a string or a buffer")}function l(g){i.call(this),this._block=A.allocUnsafe(g),this._blockSize=g,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}g("inherits")(l,i),l.prototype._transform=function(g,I,C){var A=null;try{this.update(g,I)}catch(i){A=i}C(A)},l.prototype._flush=function(g){var I=null;try{this.push(this.digest())}catch(C){I=C}g(I)},l.prototype.update=function(g,I){if(e(g,"Data"),this._finalized)throw new Error("Digest already called");A.isBuffer(g)||(g=A.from(g,I));for(var C=this._block,i=0;this._blockOffset+g.length-i>=this._blockSize;){for(var l=this._blockOffset;l0;++t)this._length[t]+=s,(s=this._length[t]/4294967296|0)>0&&(this._length[t]-=4294967296*s);return this},l.prototype._update=function(){throw new Error("_update is not implemented")},l.prototype.digest=function(g){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var I=this._digest();void 0!==g&&(I=I.toString(g)),this._block.fill(0),this._blockOffset=0;for(var C=0;C<4;++C)this._length[C]=0;return I},l.prototype._digest=function(){throw new Error("_digest is not implemented")},I.exports=l},{inherits:440,"readable-stream":491,"safe-buffer":494}],426:[function(g,I,C){var A=C;A.utils=g("./hash/utils"),A.common=g("./hash/common"),A.sha=g("./hash/sha"),A.ripemd=g("./hash/ripemd"),A.hmac=g("./hash/hmac"),A.sha1=A.sha.sha1,A.sha256=A.sha.sha256,A.sha224=A.sha.sha224,A.sha384=A.sha.sha384,A.sha512=A.sha.sha512,A.ripemd160=A.ripemd.ripemd160},{"./hash/common":427,"./hash/hmac":428,"./hash/ripemd":429,"./hash/sha":430,"./hash/utils":437}],427:[function(g,I,C){var A=g("./utils"),i=g("minimalistic-assert");function e(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}C.BlockHash=e,e.prototype.update=function(g,I){if(g=A.toArray(g,I),this.pending?this.pending=this.pending.concat(g):this.pending=g,this.pendingTotal+=g.length,this.pending.length>=this._delta8){var C=(g=this.pending).length%this._delta8;this.pending=g.slice(g.length-C,g.length),0===this.pending.length&&(this.pending=null),g=A.join32(g,0,g.length-C,this.endian);for(var i=0;i>>24&255,A[i++]=g>>>16&255,A[i++]=g>>>8&255,A[i++]=255&g}else for(A[i++]=255&g,A[i++]=g>>>8&255,A[i++]=g>>>16&255,A[i++]=g>>>24&255,A[i++]=0,A[i++]=0,A[i++]=0,A[i++]=0,e=8;ethis.blockSize&&(g=(new this.Hash).update(g).digest()),i(g.length<=this.blockSize);for(var I=g.length;I>>3}function o(g){return A(g,17)^A(g,19)^g>>>10}C.ft_1=i,C.ch32=e,C.maj32=l,C.p32=t,C.s0_256=s,C.s1_256=c,C.g0_256=d,C.g1_256=o},{"../utils":437}],437:[function(g,I,C){var A=g("minimalistic-assert"),i=g("inherits");function e(g,I){return 55296==(64512&g.charCodeAt(I))&&!(I<0||I+1>=g.length)&&56320==(64512&g.charCodeAt(I+1))}function l(g,I){if(Array.isArray(g))return g.slice();if(!g)return[];var C=[];if("string"==typeof g)if(I){if("hex"===I)for((g=g.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(g="0"+g),i=0;i>6|192,C[A++]=63&l|128):e(g,i)?(l=65536+((1023&l)<<10)+(1023&g.charCodeAt(++i)),C[A++]=l>>18|240,C[A++]=l>>12&63|128,C[A++]=l>>6&63|128,C[A++]=63&l|128):(C[A++]=l>>12|224,C[A++]=l>>6&63|128,C[A++]=63&l|128)}else for(i=0;i>>24|g>>>8&65280|g<<8&16711680|(255&g)<<24)>>>0}function c(g,I){for(var C="",A=0;A>>0}return l}function a(g,I){for(var C=new Array(4*g.length),A=0,i=0;A>>24,C[i+1]=e>>>16&255,C[i+2]=e>>>8&255,C[i+3]=255&e):(C[i+3]=e>>>24,C[i+2]=e>>>16&255,C[i+1]=e>>>8&255,C[i]=255&e)}return C}function Z(g,I){return g>>>I|g<<32-I}function b(g,I){return g<>>32-I}function r(g,I){return g+I>>>0}function m(g,I,C){return g+I+C>>>0}function h(g,I,C,A){return g+I+C+A>>>0}function G(g,I,C,A,i){return g+I+C+A+i>>>0}function u(g,I,C,A){var i=g[I],e=A+g[I+1]>>>0,l=(e>>0,g[I+1]=e}function B(g,I,C,A){return(I+A>>>0>>0}function w(g,I,C,A){return I+A>>>0}function W(g,I,C,A,i,e,l,t){var s=0,c=I;return s+=(c=c+A>>>0)>>0)>>0)>>0}function p(g,I,C,A,i,e,l,t){return I+A+e+t>>>0}function V(g,I,C,A,i,e,l,t,s,c){var d=0,o=I;return d+=(o=o+A>>>0)>>0)>>0)>>0)>>0}function y(g,I,C,A,i,e,l,t,s,c){return I+A+e+t+c>>>0}function X(g,I,C){return(I<<32-C|g>>>C)>>>0}function Y(g,I,C){return(g<<32-C|I>>>C)>>>0}function R(g,I,C){return g>>>C}function N(g,I,C){return(g<<32-C|I>>>C)>>>0}C.inherits=i,C.toArray=l,C.toHex=t,C.htonl=s,C.toHex32=c,C.zero2=d,C.zero8=o,C.join32=n,C.split32=a,C.rotr32=Z,C.rotl32=b,C.sum32=r,C.sum32_3=m,C.sum32_4=h,C.sum32_5=G,C.sum64=u,C.sum64_hi=B,C.sum64_lo=w,C.sum64_4_hi=W,C.sum64_4_lo=p,C.sum64_5_hi=V,C.sum64_5_lo=y,C.rotr64_hi=X,C.rotr64_lo=Y,C.shr64_hi=R,C.shr64_lo=N},{inherits:440,"minimalistic-assert":453}],438:[function(g,I,C){var A=g("hash.js"),i=g("minimalistic-crypto-utils"),e=g("minimalistic-assert");function l(g){if(!(this instanceof l))return new l(g);this.hash=g.hash,this.predResist=!!g.predResist,this.outLen=this.hash.outSize,this.minEntropy=g.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var I=i.toArray(g.entropy,g.entropyEnc||"hex"),C=i.toArray(g.nonce,g.nonceEnc||"hex"),A=i.toArray(g.pers,g.persEnc||"hex");e(I.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(I,C,A)}I.exports=l,l.prototype._init=function(g,I,C){var A=g.concat(I).concat(C);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var i=0;i=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(g.concat(C||[])),this._reseed=1},l.prototype.generate=function(g,I,C,A){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!=typeof I&&(A=C,C=I,I=null),C&&(C=i.toArray(C,A||"hex"),this._update(C));for(var e=[];e.length */ C.read=function(g,I,C,A,i){var e,l,t=8*i-A-1,s=(1<>1,d=-7,o=C?i-1:0,n=C?-1:1,a=g[I+o];for(o+=n,e=a&(1<<-d)-1,a>>=-d,d+=t;d>0;e=256*e+g[I+o],o+=n,d-=8);for(l=e&(1<<-d)-1,e>>=-d,d+=A;d>0;l=256*l+g[I+o],o+=n,d-=8);if(0===e)e=1-c;else{if(e===s)return l?NaN:1/0*(a?-1:1);l+=Math.pow(2,A),e-=c}return(a?-1:1)*l*Math.pow(2,e-A)},C.write=function(g,I,C,A,i,e){var l,t,s,c=8*e-i-1,d=(1<>1,n=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,a=A?0:e-1,Z=A?1:-1,b=I<0||0===I&&1/I<0?1:0;for(I=Math.abs(I),isNaN(I)||I===1/0?(t=isNaN(I)?1:0,l=d):(l=Math.floor(Math.log(I)/Math.LN2),I*(s=Math.pow(2,-l))<1&&(l--,s*=2),(I+=l+o>=1?n/s:n*Math.pow(2,1-o))*s>=2&&(l++,s/=2),l+o>=d?(t=0,l=d):l+o>=1?(t=(I*s-1)*Math.pow(2,i),l+=o):(t=I*Math.pow(2,o-1)*Math.pow(2,i),l=0));i>=8;g[C+a]=255&t,a+=Z,t/=256,i-=8);for(l=l<0;g[C+a]=255&l,a+=Z,l/=256,c-=8);g[C+a-Z]|=128*b}},{}],440:[function(g,I,C){"function"==typeof Object.create?I.exports=function(g,I){I&&(g.super_=I,g.prototype=Object.create(I.prototype,{constructor:{value:g,enumerable:!1,writable:!0,configurable:!0}}))}:I.exports=function(g,I){if(I){g.super_=I;var C=function(){};C.prototype=I.prototype,g.prototype=new C,g.prototype.constructor=g}}},{}],441:[function(g,I,C){(function(A,i,e,l,t,s,c,d){(function(){ /*! JSZip v3.10.1 - A JavaScript class for generating and reading zip files (c) 2009-2016 Stuart Knightley Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip/main/LICENSE.markdown. JSZip uses the library pako released under the MIT license : https://github.com/nodeca/pako/blob/main/LICENSE */ !function(g){"object"==typeof C&&void 0!==I?I.exports=g():("undefined"!=typeof window?window:void 0!==i?i:"undefined"!=typeof self?self:this).JSZip=g()}((function(){return function I(C,A,i){function e(t,s){if(!A[t]){if(!C[t]){var c="function"==typeof g&&g;if(!s&&c)return c(t,!0);if(l)return l(t,!0);var d=new Error("Cannot find module '"+t+"'");throw d.code="MODULE_NOT_FOUND",d}var o=A[t]={exports:{}};C[t][0].call(o.exports,(function(g){return e(C[t][1][g]||g)}),o,o.exports,I,C,A,i)}return A[t].exports}for(var l="function"==typeof g&&g,t=0;t>2,t=(3&I)<<4|C>>4,s=1>6:64,c=2>4,C=(15&l)<<4|(t=e.indexOf(g.charAt(c++)))>>2,A=(3&t)<<6|(s=e.indexOf(g.charAt(c++))),n[d++]=I,64!==t&&(n[d++]=C),64!==s&&(n[d++]=A);return n}},{"./support":30,"./utils":32}],2:[function(g,I,C){var A=g("./external"),i=g("./stream/DataWorker"),e=g("./stream/Crc32Probe"),l=g("./stream/DataLengthProbe");function t(g,I,C,A,i){this.compressedSize=g,this.uncompressedSize=I,this.crc32=C,this.compression=A,this.compressedContent=i}t.prototype={getContentWorker:function(){var g=new i(A.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new l("data_length")),I=this;return g.on("end",(function(){if(this.streamInfo.data_length!==I.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")})),g},getCompressedWorker:function(){return new i(A.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},t.createWorkerFrom=function(g,I,C){return g.pipe(new e).pipe(new l("uncompressedSize")).pipe(I.compressWorker(C)).pipe(new l("compressedSize")).withStreamInfo("compression",I)},I.exports=t},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(g,I,C){var A=g("./stream/GenericWorker");C.STORE={magic:"\0\0",compressWorker:function(){return new A("STORE compression")},uncompressWorker:function(){return new A("STORE decompression")}},C.DEFLATE=g("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(g,I,C){var A=g("./utils"),i=function(){for(var g,I=[],C=0;C<256;C++){g=C;for(var A=0;A<8;A++)g=1&g?3988292384^g>>>1:g>>>1;I[C]=g}return I}();I.exports=function(g,I){return void 0!==g&&g.length?"string"!==A.getTypeOf(g)?function(g,I,C,A){var e=i,l=A+C;g^=-1;for(var t=A;t>>8^e[255&(g^I[t])];return~g}(0|I,g,g.length,0):function(g,I,C,A){var e=i,l=A+C;g^=-1;for(var t=A;t>>8^e[255&(g^I.charCodeAt(t))];return~g}(0|I,g,g.length,0):0}},{"./utils":32}],5:[function(g,I,C){C.base64=!1,C.binary=!1,C.dir=!1,C.createFolders=!0,C.date=null,C.compression=null,C.compressionOptions=null,C.comment=null,C.unixPermissions=null,C.dosPermissions=null},{}],6:[function(g,I,C){var A=null;A="undefined"!=typeof Promise?Promise:g("lie"),I.exports={Promise:A}},{lie:37}],7:[function(g,I,C){var A="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Uint32Array,i=g("pako"),e=g("./utils"),l=g("./stream/GenericWorker"),t=A?"uint8array":"array";function s(g,I){l.call(this,"FlateWorker/"+g),this._pako=null,this._pakoAction=g,this._pakoOptions=I,this.meta={}}C.magic="\b\0",e.inherits(s,l),s.prototype.processChunk=function(g){this.meta=g.meta,null===this._pako&&this._createPako(),this._pako.push(e.transformTo(t,g.data),!1)},s.prototype.flush=function(){l.prototype.flush.call(this),null===this._pako&&this._createPako(),this._pako.push([],!0)},s.prototype.cleanUp=function(){l.prototype.cleanUp.call(this),this._pako=null},s.prototype._createPako=function(){this._pako=new i[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var g=this;this._pako.onData=function(I){g.push({data:I,meta:g.meta})}},C.compressWorker=function(g){return new s("Deflate",g)},C.uncompressWorker=function(){return new s("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(g,I,C){function A(g,I){var C,A="";for(C=0;C>>=8;return A}function i(g,I,C,i,l,d){var o,n,a=g.file,Z=g.compression,b=d!==t.utf8encode,r=e.transformTo("string",d(a.name)),m=e.transformTo("string",t.utf8encode(a.name)),h=a.comment,G=e.transformTo("string",d(h)),u=e.transformTo("string",t.utf8encode(h)),B=m.length!==a.name.length,w=u.length!==h.length,W="",p="",V="",y=a.dir,X=a.date,Y={crc32:0,compressedSize:0,uncompressedSize:0};I&&!C||(Y.crc32=g.crc32,Y.compressedSize=g.compressedSize,Y.uncompressedSize=g.uncompressedSize);var R=0;I&&(R|=8),b||!B&&!w||(R|=2048);var N,H,K,F=0,M=0;y&&(F|=16),"UNIX"===l?(M=798,F|=(N=a.unixPermissions,H=y,K=N,N||(K=H?16893:33204),(65535&K)<<16)):(M=20,F|=function(g){return 63&(g||0)}(a.dosPermissions)),o=X.getUTCHours(),o<<=6,o|=X.getUTCMinutes(),o<<=5,o|=X.getUTCSeconds()/2,n=X.getUTCFullYear()-1980,n<<=4,n|=X.getUTCMonth()+1,n<<=5,n|=X.getUTCDate(),B&&(p=A(1,1)+A(s(r),4)+m,W+="up"+A(p.length,2)+p),w&&(V=A(1,1)+A(s(G),4)+u,W+="uc"+A(V.length,2)+V);var J="";return J+="\n\0",J+=A(R,2),J+=Z.magic,J+=A(o,2),J+=A(n,2),J+=A(Y.crc32,4),J+=A(Y.compressedSize,4),J+=A(Y.uncompressedSize,4),J+=A(r.length,2),J+=A(W.length,2),{fileRecord:c.LOCAL_FILE_HEADER+J+r+W,dirRecord:c.CENTRAL_FILE_HEADER+A(M,2)+J+A(G.length,2)+"\0\0\0\0"+A(F,4)+A(i,4)+r+W+G}}var e=g("../utils"),l=g("../stream/GenericWorker"),t=g("../utf8"),s=g("../crc32"),c=g("../signature");function d(g,I,C,A){l.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=I,this.zipPlatform=C,this.encodeFileName=A,this.streamFiles=g,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}e.inherits(d,l),d.prototype.push=function(g){var I=g.meta.percent||0,C=this.entriesCount,A=this._sources.length;this.accumulate?this.contentBuffer.push(g):(this.bytesWritten+=g.data.length,l.prototype.push.call(this,{data:g.data,meta:{currentFile:this.currentFile,percent:C?(I+100*(C-A-1))/C:100}}))},d.prototype.openedSource=function(g){this.currentSourceOffset=this.bytesWritten,this.currentFile=g.file.name;var I=this.streamFiles&&!g.file.dir;if(I){var C=i(g,I,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:C.fileRecord,meta:{percent:0}})}else this.accumulate=!0},d.prototype.closedSource=function(g){this.accumulate=!1;var I,C=this.streamFiles&&!g.file.dir,e=i(g,C,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(e.dirRecord),C)this.push({data:(I=g,c.DATA_DESCRIPTOR+A(I.crc32,4)+A(I.compressedSize,4)+A(I.uncompressedSize,4)),meta:{percent:100}});else for(this.push({data:e.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},d.prototype.flush=function(){for(var g=this.bytesWritten,I=0;I=this.index;I--)C=(C<<8)+this.byteAt(I);return this.index+=g,C},readString:function(g){return A.transformTo("string",this.readData(g))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var g=this.readInt(4);return new Date(Date.UTC(1980+(g>>25&127),(g>>21&15)-1,g>>16&31,g>>11&31,g>>5&63,(31&g)<<1))}},I.exports=i},{"../utils":32}],19:[function(g,I,C){var A=g("./Uint8ArrayReader");function i(g){A.call(this,g)}g("../utils").inherits(i,A),i.prototype.readData=function(g){this.checkOffset(g);var I=this.data.slice(this.zero+this.index,this.zero+this.index+g);return this.index+=g,I},I.exports=i},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(g,I,C){var A=g("./DataReader");function i(g){A.call(this,g)}g("../utils").inherits(i,A),i.prototype.byteAt=function(g){return this.data.charCodeAt(this.zero+g)},i.prototype.lastIndexOfSignature=function(g){return this.data.lastIndexOf(g)-this.zero},i.prototype.readAndCheckSignature=function(g){return g===this.readData(4)},i.prototype.readData=function(g){this.checkOffset(g);var I=this.data.slice(this.zero+this.index,this.zero+this.index+g);return this.index+=g,I},I.exports=i},{"../utils":32,"./DataReader":18}],21:[function(g,I,C){var A=g("./ArrayReader");function i(g){A.call(this,g)}g("../utils").inherits(i,A),i.prototype.readData=function(g){if(this.checkOffset(g),0===g)return new Uint8Array(0);var I=this.data.subarray(this.zero+this.index,this.zero+this.index+g);return this.index+=g,I},I.exports=i},{"../utils":32,"./ArrayReader":17}],22:[function(g,I,C){var A=g("../utils"),i=g("../support"),e=g("./ArrayReader"),l=g("./StringReader"),t=g("./NodeBufferReader"),s=g("./Uint8ArrayReader");I.exports=function(g){var I=A.getTypeOf(g);return A.checkSupport(I),"string"!==I||i.uint8array?"nodebuffer"===I?new t(g):i.uint8array?new s(A.transformTo("uint8array",g)):new e(A.transformTo("array",g)):new l(g)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(g,I,C){C.LOCAL_FILE_HEADER="PK",C.CENTRAL_FILE_HEADER="PK",C.CENTRAL_DIRECTORY_END="PK",C.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK",C.ZIP64_CENTRAL_DIRECTORY_END="PK",C.DATA_DESCRIPTOR="PK\b"},{}],24:[function(g,I,C){var A=g("./GenericWorker"),i=g("../utils");function e(g){A.call(this,"ConvertWorker to "+g),this.destType=g}i.inherits(e,A),e.prototype.processChunk=function(g){this.push({data:i.transformTo(this.destType,g.data),meta:g.meta})},I.exports=e},{"../utils":32,"./GenericWorker":28}],25:[function(g,I,C){var A=g("./GenericWorker"),i=g("../crc32");function e(){A.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}g("../utils").inherits(e,A),e.prototype.processChunk=function(g){this.streamInfo.crc32=i(g.data,this.streamInfo.crc32||0),this.push(g)},I.exports=e},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(g,I,C){var A=g("../utils"),i=g("./GenericWorker");function e(g){i.call(this,"DataLengthProbe for "+g),this.propName=g,this.withStreamInfo(g,0)}A.inherits(e,i),e.prototype.processChunk=function(g){if(g){var I=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=I+g.data.length}i.prototype.processChunk.call(this,g)},I.exports=e},{"../utils":32,"./GenericWorker":28}],27:[function(g,I,C){var A=g("../utils"),i=g("./GenericWorker");function e(g){i.call(this,"DataWorker");var I=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,g.then((function(g){I.dataIsReady=!0,I.data=g,I.max=g&&g.length||0,I.type=A.getTypeOf(g),I.isPaused||I._tickAndRepeat()}),(function(g){I.error(g)}))}A.inherits(e,i),e.prototype.cleanUp=function(){i.prototype.cleanUp.call(this),this.data=null},e.prototype.resume=function(){return!!i.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,A.delay(this._tickAndRepeat,[],this)),!0)},e.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(A.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},e.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var g=null,I=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":g=this.data.substring(this.index,I);break;case"uint8array":g=this.data.subarray(this.index,I);break;case"array":case"nodebuffer":g=this.data.slice(this.index,I)}return this.index=I,this.push({data:g,meta:{percent:this.max?this.index/this.max*100:0}})},I.exports=e},{"../utils":32,"./GenericWorker":28}],28:[function(g,I,C){function A(g){this.name=g||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}A.prototype={push:function(g){this.emit("data",g)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(g){this.emit("error",g)}return!0},error:function(g){return!this.isFinished&&(this.isPaused?this.generatedError=g:(this.isFinished=!0,this.emit("error",g),this.previous&&this.previous.error(g),this.cleanUp()),!0)},on:function(g,I){return this._listeners[g].push(I),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(g,I){if(this._listeners[g])for(var C=0;C "+g:g}},I.exports=A},{}],29:[function(g,I,C){var A=g("../utils"),i=g("./ConvertWorker"),l=g("./GenericWorker"),t=g("../base64"),s=g("../support"),c=g("../external"),d=null;if(s.nodestream)try{d=g("../nodejs/NodejsStreamOutputAdapter")}catch(a){}function o(g,I){return new c.Promise((function(C,i){var l=[],s=g._internalType,c=g._outputType,d=g._mimeType;g.on("data",(function(g,C){l.push(g),I&&I(C)})).on("error",(function(g){l=[],i(g)})).on("end",(function(){try{var g=function(g,I,C){switch(g){case"blob":return A.newBlob(A.transformTo("arraybuffer",I),C);case"base64":return t.encode(I);default:return A.transformTo(g,I)}}(c,function(g,I){var C,A=0,i=null,l=0;for(C=0;C>>6:(C<65536?I[l++]=224|C>>>12:(I[l++]=240|C>>>18,I[l++]=128|C>>>12&63),I[l++]=128|C>>>6&63),I[l++]=128|63&C);return I}(g)},C.utf8decode=function(g){return i.nodebuffer?A.transformTo("nodebuffer",g).toString("utf-8"):function(g){var I,C,i,e,l=g.length,s=new Array(2*l);for(I=C=0;I>10&1023,s[C++]=56320|1023&i)}return s.length!==C&&(s.subarray?s=s.subarray(0,C):s.length=C),A.applyFromCharCode(s)}(g=A.transformTo(i.uint8array?"uint8array":"array",g))},A.inherits(c,l),c.prototype.processChunk=function(g){var I=A.transformTo(i.uint8array?"uint8array":"array",g.data);if(this.leftOver&&this.leftOver.length){if(i.uint8array){var e=I;(I=new Uint8Array(e.length+this.leftOver.length)).set(this.leftOver,0),I.set(e,this.leftOver.length)}else I=this.leftOver.concat(I);this.leftOver=null}var l=function(g,I){var C;for((I=I||g.length)>g.length&&(I=g.length),C=I-1;0<=C&&128==(192&g[C]);)C--;return C<0||0===C?I:C+t[g[C]]>I?C:I}(I),s=I;l!==I.length&&(i.uint8array?(s=I.subarray(0,l),this.leftOver=I.subarray(l,I.length)):(s=I.slice(0,l),this.leftOver=I.slice(l,I.length))),this.push({data:C.utf8decode(s),meta:g.meta})},c.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:C.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},C.Utf8DecodeWorker=c,A.inherits(d,l),d.prototype.processChunk=function(g){this.push({data:C.utf8encode(g.data),meta:g.meta})},C.Utf8EncodeWorker=d},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(g,I,C){var A=g("./support"),i=g("./base64"),e=g("./nodejsUtils"),l=g("./external");function t(g){return g}function s(g,I){for(var C=0;C>8;this.dir=!!(16&this.externalFileAttributes),0==g&&(this.dosPermissions=63&this.externalFileAttributes),3==g&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||"/"!==this.fileNameStr.slice(-1)||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var g=A(this.extraFields[1].value);this.uncompressedSize===i.MAX_VALUE_32BITS&&(this.uncompressedSize=g.readInt(8)),this.compressedSize===i.MAX_VALUE_32BITS&&(this.compressedSize=g.readInt(8)),this.localHeaderOffset===i.MAX_VALUE_32BITS&&(this.localHeaderOffset=g.readInt(8)),this.diskNumberStart===i.MAX_VALUE_32BITS&&(this.diskNumberStart=g.readInt(4))}},readExtraFields:function(g){var I,C,A,i=g.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});g.index+4>>6:(C<65536?I[l++]=224|C>>>12:(I[l++]=240|C>>>18,I[l++]=128|C>>>12&63),I[l++]=128|C>>>6&63),I[l++]=128|63&C);return I},C.buf2binstring=function(g){return s(g,g.length)},C.binstring2buf=function(g){for(var I=new A.Buf8(g.length),C=0,i=I.length;C>10&1023,c[A++]=56320|1023&i)}return s(c,A)},C.utf8border=function(g,I){var C;for((I=I||g.length)>g.length&&(I=g.length),C=I-1;0<=C&&128==(192&g[C]);)C--;return C<0||0===C?I:C+l[g[C]]>I?C:I}},{"./common":41}],43:[function(g,I,C){I.exports=function(g,I,C,A){for(var i=65535&g,e=g>>>16&65535,l=0;0!==C;){for(C-=l=2e3>>1:g>>>1;I[C]=g}return I}();I.exports=function(g,I,C,i){var e=A,l=i+C;g^=-1;for(var t=i;t>>8^e[255&(g^I[t])];return~g}},{}],46:[function(g,I,C){var A,i=g("../utils/common"),e=g("./trees"),l=g("./adler32"),t=g("./crc32"),s=g("./messages"),c=0,d=4,o=0,n=-2,a=-1,Z=4,b=2,r=8,m=9,h=286,G=30,u=19,B=2*h+1,w=15,W=3,p=258,V=p+W+1,y=42,X=113,Y=1,R=2,N=3,H=4;function K(g,I){return g.msg=s[I],I}function F(g){return(g<<1)-(4g.avail_out&&(C=g.avail_out),0!==C&&(i.arraySet(g.output,I.pending_buf,I.pending_out,C,g.next_out),g.next_out+=C,I.pending_out+=C,g.total_out+=C,g.avail_out-=C,I.pending-=C,0===I.pending&&(I.pending_out=0))}function S(g,I){e._tr_flush_block(g,0<=g.block_start?g.block_start:-1,g.strstart-g.block_start,I),g.block_start=g.strstart,J(g.strm)}function f(g,I){g.pending_buf[g.pending++]=I}function k(g,I){g.pending_buf[g.pending++]=I>>>8&255,g.pending_buf[g.pending++]=255&I}function D(g,I){var C,A,i=g.max_chain_length,e=g.strstart,l=g.prev_length,t=g.nice_match,s=g.strstart>g.w_size-V?g.strstart-(g.w_size-V):0,c=g.window,d=g.w_mask,o=g.prev,n=g.strstart+p,a=c[e+l-1],Z=c[e+l];g.prev_length>=g.good_match&&(i>>=2),t>g.lookahead&&(t=g.lookahead);do{if(c[(C=I)+l]===Z&&c[C+l-1]===a&&c[C]===c[e]&&c[++C]===c[e+1]){e+=2,C++;do{}while(c[++e]===c[++C]&&c[++e]===c[++C]&&c[++e]===c[++C]&&c[++e]===c[++C]&&c[++e]===c[++C]&&c[++e]===c[++C]&&c[++e]===c[++C]&&c[++e]===c[++C]&&es&&0!=--i);return l<=g.lookahead?l:g.lookahead}function L(g){var I,C,A,e,s,c,d,o,n,a,Z=g.w_size;do{if(e=g.window_size-g.lookahead-g.strstart,g.strstart>=Z+(Z-V)){for(i.arraySet(g.window,g.window,Z,Z,0),g.match_start-=Z,g.strstart-=Z,g.block_start-=Z,I=C=g.hash_size;A=g.head[--I],g.head[I]=Z<=A?A-Z:0,--C;);for(I=C=Z;A=g.prev[--I],g.prev[I]=Z<=A?A-Z:0,--C;);e+=Z}if(0===g.strm.avail_in)break;if(c=g.strm,d=g.window,o=g.strstart+g.lookahead,a=void 0,(n=e)<(a=c.avail_in)&&(a=n),C=0===a?0:(c.avail_in-=a,i.arraySet(d,c.input,c.next_in,a,o),1===c.state.wrap?c.adler=l(c.adler,d,a,o):2===c.state.wrap&&(c.adler=t(c.adler,d,a,o)),c.next_in+=a,c.total_in+=a,a),g.lookahead+=C,g.lookahead+g.insert>=W)for(s=g.strstart-g.insert,g.ins_h=g.window[s],g.ins_h=(g.ins_h<=W&&(g.ins_h=(g.ins_h<=W)if(A=e._tr_tally(g,g.strstart-g.match_start,g.match_length-W),g.lookahead-=g.match_length,g.match_length<=g.max_lazy_match&&g.lookahead>=W){for(g.match_length--;g.strstart++,g.ins_h=(g.ins_h<=W&&(g.ins_h=(g.ins_h<=W&&g.match_length<=g.prev_length){for(i=g.strstart+g.lookahead-W,A=e._tr_tally(g,g.strstart-1-g.prev_match,g.prev_length-W),g.lookahead-=g.prev_length-1,g.prev_length-=2;++g.strstart<=i&&(g.ins_h=(g.ins_h<g.pending_buf_size-5&&(C=g.pending_buf_size-5);;){if(g.lookahead<=1){if(L(g),0===g.lookahead&&I===c)return Y;if(0===g.lookahead)break}g.strstart+=g.lookahead,g.lookahead=0;var A=g.block_start+C;if((0===g.strstart||g.strstart>=A)&&(g.lookahead=g.strstart-A,g.strstart=A,S(g,!1),0===g.strm.avail_out))return Y;if(g.strstart-g.block_start>=g.w_size-V&&(S(g,!1),0===g.strm.avail_out))return Y}return g.insert=0,I===d?(S(g,!0),0===g.strm.avail_out?N:H):(g.strstart>g.block_start&&(S(g,!1),g.strm.avail_out),Y)})),new T(4,4,8,4,z),new T(4,5,16,8,z),new T(4,6,32,32,z),new T(4,4,16,16,v),new T(8,16,32,32,v),new T(8,16,128,128,v),new T(8,32,128,256,v),new T(32,128,258,1024,v),new T(32,258,258,4096,v)],C.deflateInit=function(g,I){return j(g,I,r,15,8,0)},C.deflateInit2=j,C.deflateReset=Q,C.deflateResetKeep=U,C.deflateSetHeader=function(g,I){return g&&g.state?2!==g.state.wrap?n:(g.state.gzhead=I,o):n},C.deflate=function(g,I){var C,i,l,s;if(!g||!g.state||5>8&255),f(i,i.gzhead.time>>16&255),f(i,i.gzhead.time>>24&255),f(i,9===i.level?2:2<=i.strategy||i.level<2?4:0),f(i,255&i.gzhead.os),i.gzhead.extra&&i.gzhead.extra.length&&(f(i,255&i.gzhead.extra.length),f(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(g.adler=t(g.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=69):(f(i,0),f(i,0),f(i,0),f(i,0),f(i,0),f(i,9===i.level?2:2<=i.strategy||i.level<2?4:0),f(i,3),i.status=X);else{var a=r+(i.w_bits-8<<4)<<8;a|=(2<=i.strategy||i.level<2?0:i.level<6?1:6===i.level?2:3)<<6,0!==i.strstart&&(a|=32),a+=31-a%31,i.status=X,k(i,a),0!==i.strstart&&(k(i,g.adler>>>16),k(i,65535&g.adler)),g.adler=1}if(69===i.status)if(i.gzhead.extra){for(l=i.pending;i.gzindex<(65535&i.gzhead.extra.length)&&(i.pending!==i.pending_buf_size||(i.gzhead.hcrc&&i.pending>l&&(g.adler=t(g.adler,i.pending_buf,i.pending-l,l)),J(g),l=i.pending,i.pending!==i.pending_buf_size));)f(i,255&i.gzhead.extra[i.gzindex]),i.gzindex++;i.gzhead.hcrc&&i.pending>l&&(g.adler=t(g.adler,i.pending_buf,i.pending-l,l)),i.gzindex===i.gzhead.extra.length&&(i.gzindex=0,i.status=73)}else i.status=73;if(73===i.status)if(i.gzhead.name){l=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>l&&(g.adler=t(g.adler,i.pending_buf,i.pending-l,l)),J(g),l=i.pending,i.pending===i.pending_buf_size)){s=1;break}s=i.gzindexl&&(g.adler=t(g.adler,i.pending_buf,i.pending-l,l)),0===s&&(i.gzindex=0,i.status=91)}else i.status=91;if(91===i.status)if(i.gzhead.comment){l=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>l&&(g.adler=t(g.adler,i.pending_buf,i.pending-l,l)),J(g),l=i.pending,i.pending===i.pending_buf_size)){s=1;break}s=i.gzindexl&&(g.adler=t(g.adler,i.pending_buf,i.pending-l,l)),0===s&&(i.status=103)}else i.status=103;if(103===i.status&&(i.gzhead.hcrc?(i.pending+2>i.pending_buf_size&&J(g),i.pending+2<=i.pending_buf_size&&(f(i,255&g.adler),f(i,g.adler>>8&255),g.adler=0,i.status=X)):i.status=X),0!==i.pending){if(J(g),0===g.avail_out)return i.last_flush=-1,o}else if(0===g.avail_in&&F(I)<=F(C)&&I!==d)return K(g,-5);if(666===i.status&&0!==g.avail_in)return K(g,-5);if(0!==g.avail_in||0!==i.lookahead||I!==c&&666!==i.status){var Z=2===i.strategy?function(g,I){for(var C;;){if(0===g.lookahead&&(L(g),0===g.lookahead)){if(I===c)return Y;break}if(g.match_length=0,C=e._tr_tally(g,0,g.window[g.strstart]),g.lookahead--,g.strstart++,C&&(S(g,!1),0===g.strm.avail_out))return Y}return g.insert=0,I===d?(S(g,!0),0===g.strm.avail_out?N:H):g.last_lit&&(S(g,!1),0===g.strm.avail_out)?Y:R}(i,I):3===i.strategy?function(g,I){for(var C,A,i,l,t=g.window;;){if(g.lookahead<=p){if(L(g),g.lookahead<=p&&I===c)return Y;if(0===g.lookahead)break}if(g.match_length=0,g.lookahead>=W&&0g.lookahead&&(g.match_length=g.lookahead)}if(g.match_length>=W?(C=e._tr_tally(g,1,g.match_length-W),g.lookahead-=g.match_length,g.strstart+=g.match_length,g.match_length=0):(C=e._tr_tally(g,0,g.window[g.strstart]),g.lookahead--,g.strstart++),C&&(S(g,!1),0===g.strm.avail_out))return Y}return g.insert=0,I===d?(S(g,!0),0===g.strm.avail_out?N:H):g.last_lit&&(S(g,!1),0===g.strm.avail_out)?Y:R}(i,I):A[i.level].func(i,I);if(Z!==N&&Z!==H||(i.status=666),Z===Y||Z===N)return 0===g.avail_out&&(i.last_flush=-1),o;if(Z===R&&(1===I?e._tr_align(i):5!==I&&(e._tr_stored_block(i,0,0,!1),3===I&&(M(i.head),0===i.lookahead&&(i.strstart=0,i.block_start=0,i.insert=0))),J(g),0===g.avail_out))return i.last_flush=-1,o}return I!==d?o:i.wrap<=0?1:(2===i.wrap?(f(i,255&g.adler),f(i,g.adler>>8&255),f(i,g.adler>>16&255),f(i,g.adler>>24&255),f(i,255&g.total_in),f(i,g.total_in>>8&255),f(i,g.total_in>>16&255),f(i,g.total_in>>24&255)):(k(i,g.adler>>>16),k(i,65535&g.adler)),J(g),0=C.w_size&&(0===t&&(M(C.head),C.strstart=0,C.block_start=0,C.insert=0),a=new i.Buf8(C.w_size),i.arraySet(a,I,Z-C.w_size,C.w_size,0),I=a,Z=C.w_size),s=g.avail_in,c=g.next_in,d=g.input,g.avail_in=Z,g.next_in=0,g.input=I,L(C);C.lookahead>=W;){for(A=C.strstart,e=C.lookahead-(W-1);C.ins_h=(C.ins_h<>>=u=G>>>24,Z-=u,0==(u=G>>>16&255))y[e++]=65535&G;else{if(!(16&u)){if(!(64&u)){G=b[(65535&G)+(a&(1<>>=u,Z-=u),Z<15&&(a+=V[A++]<>>=u=G>>>24,Z-=u,!(16&(u=G>>>16&255))){if(!(64&u)){G=r[(65535&G)+(a&(1<>>=u,Z-=u,(u=e-l)>3,a&=(1<<(Z-=B<<3))-1,g.next_in=A,g.next_out=e,g.avail_in=A>>24&255)+(g>>>8&65280)+((65280&g)<<8)+((255&g)<<24)}function r(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new A.Buf16(320),this.work=new A.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function m(g){var I;return g&&g.state?(I=g.state,g.total_in=g.total_out=I.total=0,g.msg="",I.wrap&&(g.adler=1&I.wrap),I.mode=n,I.last=0,I.havedict=0,I.dmax=32768,I.head=null,I.hold=0,I.bits=0,I.lencode=I.lendyn=new A.Buf32(a),I.distcode=I.distdyn=new A.Buf32(Z),I.sane=1,I.back=-1,d):o}function h(g){var I;return g&&g.state?((I=g.state).wsize=0,I.whave=0,I.wnext=0,m(g)):o}function G(g,I){var C,A;return g&&g.state?(A=g.state,I<0?(C=0,I=-I):(C=1+(I>>4),I<48&&(I&=15)),I&&(I<8||15=l.wsize?(A.arraySet(l.window,I,C-l.wsize,l.wsize,0),l.wnext=0,l.whave=l.wsize):(i<(e=l.wsize-l.wnext)&&(e=i),A.arraySet(l.window,I,C-i,e,l.wnext),(i-=e)?(A.arraySet(l.window,I,C-i,i,0),l.wnext=i,l.whave=l.wsize):(l.wnext+=e,l.wnext===l.wsize&&(l.wnext=0),l.whave>>8&255,C.check=e(C.check,L,2,0),B=u=0,C.mode=2;break}if(C.flags=0,C.head&&(C.head.done=!1),!(1&C.wrap)||(((255&u)<<8)+(u>>8))%31){g.msg="incorrect header check",C.mode=30;break}if(8!=(15&u)){g.msg="unknown compression method",C.mode=30;break}if(B-=4,J=8+(15&(u>>>=4)),0===C.wbits)C.wbits=J;else if(J>C.wbits){g.msg="invalid window size",C.mode=30;break}C.dmax=1<>8&1),512&C.flags&&(L[0]=255&u,L[1]=u>>>8&255,C.check=e(C.check,L,2,0)),B=u=0,C.mode=3;case 3:for(;B<32;){if(0===h)break g;h--,u+=a[r++]<>>8&255,L[2]=u>>>16&255,L[3]=u>>>24&255,C.check=e(C.check,L,4,0)),B=u=0,C.mode=4;case 4:for(;B<16;){if(0===h)break g;h--,u+=a[r++]<>8),512&C.flags&&(L[0]=255&u,L[1]=u>>>8&255,C.check=e(C.check,L,2,0)),B=u=0,C.mode=5;case 5:if(1024&C.flags){for(;B<16;){if(0===h)break g;h--,u+=a[r++]<>>8&255,C.check=e(C.check,L,2,0)),B=u=0}else C.head&&(C.head.extra=null);C.mode=6;case 6:if(1024&C.flags&&(h<(y=C.length)&&(y=h),y&&(C.head&&(J=C.head.extra_len-C.length,C.head.extra||(C.head.extra=new Array(C.head.extra_len)),A.arraySet(C.head.extra,a,r,y,J)),512&C.flags&&(C.check=e(C.check,a,y,r)),h-=y,r+=y,C.length-=y),C.length))break g;C.length=0,C.mode=7;case 7:if(2048&C.flags){if(0===h)break g;for(y=0;J=a[r+y++],C.head&&J&&C.length<65536&&(C.head.name+=String.fromCharCode(J)),J&&y>9&1,C.head.done=!0),g.adler=C.check=0,C.mode=12;break;case 10:for(;B<32;){if(0===h)break g;h--,u+=a[r++]<>>=7&B,B-=7&B,C.mode=27;break}for(;B<3;){if(0===h)break g;h--,u+=a[r++]<>>=1)){case 0:C.mode=14;break;case 1:if(p(C),C.mode=20,6!==I)break;u>>>=2,B-=2;break g;case 2:C.mode=17;break;case 3:g.msg="invalid block type",C.mode=30}u>>>=2,B-=2;break;case 14:for(u>>>=7&B,B-=7&B;B<32;){if(0===h)break g;h--,u+=a[r++]<>>16^65535)){g.msg="invalid stored block lengths",C.mode=30;break}if(C.length=65535&u,B=u=0,C.mode=15,6===I)break g;case 15:C.mode=16;case 16:if(y=C.length){if(h>>=5,B-=5,C.ndist=1+(31&u),u>>>=5,B-=5,C.ncode=4+(15&u),u>>>=4,B-=4,286>>=3,B-=3}for(;C.have<19;)C.lens[z[C.have++]]=0;if(C.lencode=C.lendyn,C.lenbits=7,f={bits:C.lenbits},S=t(0,C.lens,0,19,C.lencode,0,C.work,f),C.lenbits=f.bits,S){g.msg="invalid code lengths set",C.mode=30;break}C.have=0,C.mode=19;case 19:for(;C.have>>16&255,H=65535&D,!((R=D>>>24)<=B);){if(0===h)break g;h--,u+=a[r++]<>>=R,B-=R,C.lens[C.have++]=H;else{if(16===H){for(k=R+2;B>>=R,B-=R,0===C.have){g.msg="invalid bit length repeat",C.mode=30;break}J=C.lens[C.have-1],y=3+(3&u),u>>>=2,B-=2}else if(17===H){for(k=R+3;B>>=R)),u>>>=3,B-=3}else{for(k=R+7;B>>=R)),u>>>=7,B-=7}if(C.have+y>C.nlen+C.ndist){g.msg="invalid bit length repeat",C.mode=30;break}for(;y--;)C.lens[C.have++]=J}}if(30===C.mode)break;if(0===C.lens[256]){g.msg="invalid code -- missing end-of-block",C.mode=30;break}if(C.lenbits=9,f={bits:C.lenbits},S=t(s,C.lens,0,C.nlen,C.lencode,0,C.work,f),C.lenbits=f.bits,S){g.msg="invalid literal/lengths set",C.mode=30;break}if(C.distbits=6,C.distcode=C.distdyn,f={bits:C.distbits},S=t(c,C.lens,C.nlen,C.ndist,C.distcode,0,C.work,f),C.distbits=f.bits,S){g.msg="invalid distances set",C.mode=30;break}if(C.mode=20,6===I)break g;case 20:C.mode=21;case 21:if(6<=h&&258<=G){g.next_out=m,g.avail_out=G,g.next_in=r,g.avail_in=h,C.hold=u,C.bits=B,l(g,W),m=g.next_out,Z=g.output,G=g.avail_out,r=g.next_in,a=g.input,h=g.avail_in,u=C.hold,B=C.bits,12===C.mode&&(C.back=-1);break}for(C.back=0;N=(D=C.lencode[u&(1<>>16&255,H=65535&D,!((R=D>>>24)<=B);){if(0===h)break g;h--,u+=a[r++]<>K)])>>>16&255,H=65535&D,!(K+(R=D>>>24)<=B);){if(0===h)break g;h--,u+=a[r++]<>>=K,B-=K,C.back+=K}if(u>>>=R,B-=R,C.back+=R,C.length=H,0===N){C.mode=26;break}if(32&N){C.back=-1,C.mode=12;break}if(64&N){g.msg="invalid literal/length code",C.mode=30;break}C.extra=15&N,C.mode=22;case 22:if(C.extra){for(k=C.extra;B>>=C.extra,B-=C.extra,C.back+=C.extra}C.was=C.length,C.mode=23;case 23:for(;N=(D=C.distcode[u&(1<>>16&255,H=65535&D,!((R=D>>>24)<=B);){if(0===h)break g;h--,u+=a[r++]<>K)])>>>16&255,H=65535&D,!(K+(R=D>>>24)<=B);){if(0===h)break g;h--,u+=a[r++]<>>=K,B-=K,C.back+=K}if(u>>>=R,B-=R,C.back+=R,64&N){g.msg="invalid distance code",C.mode=30;break}C.offset=H,C.extra=15&N,C.mode=24;case 24:if(C.extra){for(k=C.extra;B>>=C.extra,B-=C.extra,C.back+=C.extra}if(C.offset>C.dmax){g.msg="invalid distance too far back",C.mode=30;break}C.mode=25;case 25:if(0===G)break g;if(y=W-G,C.offset>y){if((y=C.offset-y)>C.whave&&C.sane){g.msg="invalid distance too far back",C.mode=30;break}X=y>C.wnext?(y-=C.wnext,C.wsize-y):C.wnext-y,y>C.length&&(y=C.length),Y=C.window}else Y=Z,X=m-C.offset,y=C.length;for(Gh?(u=f[k+o[p]],F[M+o[p]]):(u=96,0),a=1<>R)+(Z-=a)]=G<<24|u<<16|B,0!==Z;);for(a=1<>=1;if(0!==a?(K&=a-1,K+=a):K=0,p++,0==--J[W]){if(W===y)break;W=I[C+o[p]]}if(X>>7)]}function f(g,I){g.pending_buf[g.pending++]=255&I,g.pending_buf[g.pending++]=I>>>8&255}function k(g,I,C){g.bi_valid>b-C?(g.bi_buf|=I<>b-g.bi_valid,g.bi_valid+=C-b):(g.bi_buf|=I<>>=1,C<<=1,0<--I;);return C>>>1}function z(g,I,C){var A,i,e=new Array(Z+1),l=0;for(A=1;A<=Z;A++)e[A]=l=l+C[A-1]<<1;for(i=0;i<=I;i++){var t=g[2*i+1];0!==t&&(g[2*i]=L(e[t]++,t))}}function v(g){var I;for(I=0;I>1;1<=C;C--)U(g,e,C);for(i=s;C=g.heap[1],g.heap[1]=g.heap[g.heap_len--],U(g,e,1),A=g.heap[1],g.heap[--g.heap_max]=C,g.heap[--g.heap_max]=A,e[2*i]=e[2*C]+e[2*A],g.depth[i]=(g.depth[C]>=g.depth[A]?g.depth[C]:g.depth[A])+1,e[2*C+1]=e[2*A+1]=i,g.heap[1]=i++,U(g,e,1),2<=g.heap_len;);g.heap[--g.heap_max]=g.heap[1],function(g,I){var C,A,i,e,l,t,s=I.dyn_tree,c=I.max_code,d=I.stat_desc.static_tree,o=I.stat_desc.has_stree,n=I.stat_desc.extra_bits,b=I.stat_desc.extra_base,r=I.stat_desc.max_length,m=0;for(e=0;e<=Z;e++)g.bl_count[e]=0;for(s[2*g.heap[g.heap_max]+1]=0,C=g.heap_max+1;C>=7;A>>=1)if(1&C&&0!==g.dyn_ltree[2*I])return i;if(0!==g.dyn_ltree[18]||0!==g.dyn_ltree[20]||0!==g.dyn_ltree[26])return e;for(I=32;I>>3,(t=g.static_len+3+7>>>3)<=l&&(l=t)):l=t=C+5,C+4<=l&&-1!==I?_(g,I,C,A):4===g.strategy||t===l?(k(g,2+(A?1:0),3),Q(g,V,y)):(k(g,4+(A?1:0),3),function(g,I,C,A){var i;for(k(g,I-257,5),k(g,C-1,5),k(g,A-4,4),i=0;i>>8&255,g.pending_buf[g.d_buf+2*g.last_lit+1]=255&I,g.pending_buf[g.l_buf+g.last_lit]=255&C,g.last_lit++,0===I?g.dyn_ltree[2*C]++:(g.matches++,I--,g.dyn_ltree[2*(Y[C]+c+1)]++,g.dyn_dtree[2*S(I)]++),g.last_lit===g.lit_bufsize-1},C._tr_align=function(g){var I;k(g,2,3),D(g,m,V),16===(I=g).bi_valid?(f(I,I.bi_buf),I.bi_buf=0,I.bi_valid=0):8<=I.bi_valid&&(I.pending_buf[I.pending++]=255&I.bi_buf,I.bi_buf>>=8,I.bi_valid-=8)}},{"../utils/common":41}],53:[function(g,I,C){I.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(g,I,C){(function(g){!function(g,I){if(!g.setImmediate){var C,i,e,l,t=1,s={},c=!1,d=g.document,o=Object.getPrototypeOf&&Object.getPrototypeOf(g);o=o&&o.setTimeout?o:g,C="[object process]"==={}.toString.call(g.process)?function(g){A.nextTick((function(){a(g)}))}:function(){if(g.postMessage&&!g.importScripts){var I=!0,C=g.onmessage;return g.onmessage=function(){I=!1},g.postMessage("","*"),g.onmessage=C,I}}()?(l="setImmediate$"+Math.random()+"$",g.addEventListener?g.addEventListener("message",Z,!1):g.attachEvent("onmessage",Z),function(I){g.postMessage(l+I,"*")}):g.MessageChannel?((e=new MessageChannel).port1.onmessage=function(g){a(g.data)},function(g){e.port2.postMessage(g)}):d&&"onreadystatechange"in d.createElement("script")?(i=d.documentElement,function(g){var I=d.createElement("script");I.onreadystatechange=function(){a(g),I.onreadystatechange=null,i.removeChild(I),I=null},i.appendChild(I)}):function(g){setTimeout(a,0,g)},o.setImmediate=function(g){"function"!=typeof g&&(g=new Function(""+g));for(var I=new Array(arguments.length-1),A=0;A-1}function Eg(g,I){var C=this.__data__,A=nI(C,g);return A<0?C.push([g,I]):C[A][1]=I,this}function Pg(g){var I=-1,C=g?g.length:0;for(this.clear();++Ic))return!1;var o=e.get(g);if(o&&e.get(I))return o==I;var n=-1,a=!0,Z=i&l?new CI:void 0;for(e.set(g,I),e.set(I,g);++n-1&&g%1==0&&g-1&&g%1==0&&g<=c}function sC(g){var I=typeof g;return!!g&&("object"==I||"function"==I)}function cC(g){return!!g&&"object"==typeof g}function dC(g){return"symbol"==typeof g||cC(g)&&mg.call(g)==p}var oC=q?Ag(q):pI;function nC(g){return null==g?"":NI(g)}function aC(g,I,C){var A=null==g?void 0:mI(g,I);return void 0===A?C:A}function ZC(g,I){return null!=g&&vI(g,I,GI)}function bC(g){return iC(g)?oI(g):yI(g)}function rC(g){return g}function mC(g){return xI(g)?Ig(_I(g)):RI(g)}I.exports=$I}).call(this)}).call(this,void 0!==EI?EI:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],444:[function(g,I,C){var A="[object Boolean]",i=Object.prototype.toString;function e(g){return!0===g||!1===g||l(g)&&i.call(g)==A}function l(g){return!!g&&"object"==typeof g}I.exports=e},{}],445:[function(g,I,C){(function(g){(function(){var A=200,i="__lodash_hash_undefined__",e=1,l=2,t=9007199254740991,s="[object Arguments]",c="[object Array]",d="[object AsyncFunction]",o="[object Boolean]",n="[object Date]",a="[object Error]",Z="[object Function]",b="[object GeneratorFunction]",r="[object Map]",m="[object Number]",h="[object Null]",G="[object Object]",u="[object Promise]",B="[object Proxy]",w="[object RegExp]",W="[object Set]",p="[object String]",V="[object Symbol]",y="[object Undefined]",X="[object WeakMap]",Y="[object ArrayBuffer]",R="[object DataView]",N="[object Float64Array]",H="[object Int8Array]",K="[object Int16Array]",F="[object Int32Array]",M="[object Uint8Array]",J="[object Uint8ClampedArray]",S="[object Uint16Array]",f="[object Uint32Array]",k=/[\\^$.*+?()[\]{}|]/g,D=/^\[object .+?Constructor\]$/,L=/^(?:0|[1-9]\d*)$/,z={};z["[object Float32Array]"]=z[N]=z[H]=z[K]=z[F]=z[M]=z[J]=z[S]=z[f]=!0,z[s]=z[c]=z[Y]=z[o]=z[R]=z[n]=z[a]=z[Z]=z[r]=z[m]=z[G]=z[w]=z[W]=z[p]=z[X]=!1;var v="object"==typeof g&&g&&g.Object===Object&&g,T="object"==typeof self&&self&&self.Object===Object&&self,x=v||T||Function("return this")(),U="object"==typeof C&&C&&!C.nodeType&&C,Q=U&&"object"==typeof I&&I&&!I.nodeType&&I,j=Q&&Q.exports===U,O=j&&v.process,E=function(){try{return O&&O.binding&&O.binding("util")}catch(g){}}(),P=E&&E.isTypedArray;function _(g,I){for(var C=-1,A=null==g?0:g.length,i=0,e=[];++C-1}function Pg(g,I){var C=this.__data__,A=aI(C,g);return A<0?(++this.size,C.push([g,I])):C[A][1]=I,this}function _g(g){var I=-1,C=null==g?0:g.length;for(this.clear();++Ic))return!1;var o=t.get(g);if(o&&t.get(I))return o==I;var n=-1,a=!0,Z=C&l?new AI:void 0;for(t.set(g,I),t.set(I,g);++n-1&&g%1==0&&g-1&&g%1==0&&g<=t}function UI(g){var I=typeof g;return null!=g&&("object"==I||"function"==I)}function QI(g){return null!=g&&"object"==typeof g}var jI=P?Ig(P):uI;function OI(g){return LI(g)?nI(g):BI(g)}function EI(){return[]}function PI(){return!1}I.exports=vI}).call(this)}).call(this,void 0!==EI?EI:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],446:[function(g,I,C){(function(g){(function(){var C="[object AsyncFunction]",A="[object Function]",i="[object GeneratorFunction]",e="[object Null]",l="[object Proxy]",t="[object Undefined]",s="object"==typeof g&&g&&g.Object===Object&&g,c="object"==typeof self&&self&&self.Object===Object&&self,d=s||c||Function("return this")(),o=Object.prototype,n=o.hasOwnProperty,a=o.toString,Z=d.Symbol,b=Z?Z.toStringTag:void 0;function r(g){return null==g?void 0===g?t:e:b&&b in Object(g)?m(g):h(g)}function m(g){var I=n.call(g,b),C=g[b];try{g[b]=void 0;var A=!0}catch(e){}var i=a.call(g);return A&&(I?g[b]=C:delete g[b]),i}function h(g){return a.call(g)}function G(g){if(!u(g))return!1;var I=r(g);return I==A||I==i||I==C||I==l}function u(g){var I=typeof g;return null!=g&&("object"==I||"function"==I)}I.exports=G}).call(this)}).call(this,void 0!==EI?EI:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],447:[function(g,I,C){function A(g){return null==g}I.exports=A},{}],448:[function(g,I,C){function A(g){return void 0===g}I.exports=A},{}],449:[function(g,I,C){(function(g){(function(){var C=200,A="__lodash_hash_undefined__",i=1/0,e="[object Function]",l="[object GeneratorFunction]",t=/[\\^$.*+?()[\]{}|]/g,s=/^\[object .+?Constructor\]$/,c="object"==typeof g&&g&&g.Object===Object&&g,d="object"==typeof self&&self&&self.Object===Object&&self,o=c||d||Function("return this")();function n(g,I){return!(!g||!g.length)&&Z(g,I,0)>-1}function a(g,I,C,A){for(var i=g.length,e=C+-1;++e-1}function U(g,I){var C=this.__data__,A=Ig(C,g);return A<0?C.push([g,I]):C[A][1]=I,this}function Q(g){var I=-1,C=g?g.length:0;for(this.clear();++I=C){var d=ig(g);if(d)return G(d);t=!1,e=r,c=new q}else c=s;g:for(;++i>>32-I}function c(g,I,C,A,i,e,l){return s(g+(I&C|~I&A)+i+e|0,l)+I|0}function d(g,I,C,A,i,e,l){return s(g+(I&A|C&~A)+i+e|0,l)+I|0}function o(g,I,C,A,i,e,l){return s(g+(I^C^A)+i+e|0,l)+I|0}function n(g,I,C,A,i,e,l){return s(g+(C^(I|~A))+i+e|0,l)+I|0}A(t,i),t.prototype._update=function(){for(var g=l,I=0;I<16;++I)g[I]=this._block.readInt32LE(4*I);var C=this._a,A=this._b,i=this._c,e=this._d;C=c(C,A,i,e,g[0],3614090360,7),e=c(e,C,A,i,g[1],3905402710,12),i=c(i,e,C,A,g[2],606105819,17),A=c(A,i,e,C,g[3],3250441966,22),C=c(C,A,i,e,g[4],4118548399,7),e=c(e,C,A,i,g[5],1200080426,12),i=c(i,e,C,A,g[6],2821735955,17),A=c(A,i,e,C,g[7],4249261313,22),C=c(C,A,i,e,g[8],1770035416,7),e=c(e,C,A,i,g[9],2336552879,12),i=c(i,e,C,A,g[10],4294925233,17),A=c(A,i,e,C,g[11],2304563134,22),C=c(C,A,i,e,g[12],1804603682,7),e=c(e,C,A,i,g[13],4254626195,12),i=c(i,e,C,A,g[14],2792965006,17),C=d(C,A=c(A,i,e,C,g[15],1236535329,22),i,e,g[1],4129170786,5),e=d(e,C,A,i,g[6],3225465664,9),i=d(i,e,C,A,g[11],643717713,14),A=d(A,i,e,C,g[0],3921069994,20),C=d(C,A,i,e,g[5],3593408605,5),e=d(e,C,A,i,g[10],38016083,9),i=d(i,e,C,A,g[15],3634488961,14),A=d(A,i,e,C,g[4],3889429448,20),C=d(C,A,i,e,g[9],568446438,5),e=d(e,C,A,i,g[14],3275163606,9),i=d(i,e,C,A,g[3],4107603335,14),A=d(A,i,e,C,g[8],1163531501,20),C=d(C,A,i,e,g[13],2850285829,5),e=d(e,C,A,i,g[2],4243563512,9),i=d(i,e,C,A,g[7],1735328473,14),C=o(C,A=d(A,i,e,C,g[12],2368359562,20),i,e,g[5],4294588738,4),e=o(e,C,A,i,g[8],2272392833,11),i=o(i,e,C,A,g[11],1839030562,16),A=o(A,i,e,C,g[14],4259657740,23),C=o(C,A,i,e,g[1],2763975236,4),e=o(e,C,A,i,g[4],1272893353,11),i=o(i,e,C,A,g[7],4139469664,16),A=o(A,i,e,C,g[10],3200236656,23),C=o(C,A,i,e,g[13],681279174,4),e=o(e,C,A,i,g[0],3936430074,11),i=o(i,e,C,A,g[3],3572445317,16),A=o(A,i,e,C,g[6],76029189,23),C=o(C,A,i,e,g[9],3654602809,4),e=o(e,C,A,i,g[12],3873151461,11),i=o(i,e,C,A,g[15],530742520,16),C=n(C,A=o(A,i,e,C,g[2],3299628645,23),i,e,g[0],4096336452,6),e=n(e,C,A,i,g[7],1126891415,10),i=n(i,e,C,A,g[14],2878612391,15),A=n(A,i,e,C,g[5],4237533241,21),C=n(C,A,i,e,g[12],1700485571,6),e=n(e,C,A,i,g[3],2399980690,10),i=n(i,e,C,A,g[10],4293915773,15),A=n(A,i,e,C,g[1],2240044497,21),C=n(C,A,i,e,g[8],1873313359,6),e=n(e,C,A,i,g[15],4264355552,10),i=n(i,e,C,A,g[6],2734768916,15),A=n(A,i,e,C,g[13],1309151649,21),C=n(C,A,i,e,g[4],4149444226,6),e=n(e,C,A,i,g[11],3174756917,10),i=n(i,e,C,A,g[2],718787259,15),A=n(A,i,e,C,g[9],3951481745,21),this._a=this._a+C|0,this._b=this._b+A|0,this._c=this._c+i|0,this._d=this._d+e|0},t.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var g=e.allocUnsafe(16);return g.writeInt32LE(this._a,0),g.writeInt32LE(this._b,4),g.writeInt32LE(this._c,8),g.writeInt32LE(this._d,12),g},I.exports=t},{"hash-base":425,inherits:440,"safe-buffer":494}],451:[function(g,I,C){var A=g("bn.js"),i=g("brorand");function e(g){this.rand=g||new i.Rand}I.exports=e,e.create=function(g){return new e(g)},e.prototype._randbelow=function(g){var I=g.bitLength(),C=Math.ceil(I/8);do{var i=new A(this.rand.generate(C))}while(i.cmp(g)>=0);return i},e.prototype._randrange=function(g,I){var C=I.sub(g);return g.add(this._randbelow(C))},e.prototype.test=function(g,I,C){var i=g.bitLength(),e=A.mont(g),l=new A(1).toRed(e);I||(I=Math.max(1,i/48|0));for(var t=g.subn(1),s=0;!t.testn(s);s++);for(var c=g.shrn(s),d=t.toRed(e),o=!0;I>0;I--){var n=this._randrange(new A(2),t);C&&C(n);var a=n.toRed(e).redPow(c);if(0!==a.cmp(l)&&0!==a.cmp(d)){for(var Z=1;Z0;I--){var d=this._randrange(new A(2),l),o=g.gcd(d);if(0!==o.cmpn(1))return o;var n=d.toRed(i).redPow(s);if(0!==n.cmp(e)&&0!==n.cmp(c)){for(var a=1;a>8,l=255&i;e?C.push(e,l):C.push(l)}return C}function e(g){return 1===g.length?"0"+g:g}function l(g){for(var I="",C=0;C=6?"utf-8":"binary":"utf-8",I.exports=A}).call(this)}).call(this,g("_process"),void 0!==EI?EI:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{_process:467}],463:[function(g,I,C){var A=Math.pow(2,30)-1;I.exports=function(g,I){if("number"!=typeof g)throw new TypeError("Iterations not a number");if(g<0)throw new TypeError("Bad iterations");if("number"!=typeof I)throw new TypeError("Key length not a number");if(I<0||I>A||I!=I)throw new TypeError("Bad key length")}},{}],464:[function(g,I,C){var A=g("create-hash/md5"),i=g("ripemd160"),e=g("sha.js"),l=g("safe-buffer").Buffer,t=g("./precondition"),s=g("./default-encoding"),c=g("./to-buffer"),d=l.alloc(128),o={md5:16,sha1:20,sha224:28,sha256:32,sha384:48,sha512:64,rmd160:20,ripemd160:20};function n(g,I,C){var A=a(g),i="sha512"===g||"sha384"===g?128:64;I.length>i?I=A(I):I.length1)for(var C=1;C=I.length){e++;break}var l=I.slice(2,i-1);if(("0002"!==A.toString("hex")&&!C||"0001"!==A.toString("hex")&&C)&&e++,l.length<8&&e++,e)throw new Error("decryption error");return I.slice(i)}function a(g,I){g=d.from(g),I=d.from(I);var C=0,A=g.length;g.length!==I.length&&(C++,A=Math.min(g.length,I.length));for(var i=-1;++ia||new l(I).cmp(s.modulus)>=0)throw new Error("decryption error");e=C?c(new l(I),s):t(I,s);var Z=d.alloc(a-e.length);if(e=d.concat([Z,e],a),4===i)return o(s,e);if(1===i)return n(s,e,C);if(3===i)return e;throw new Error("unknown padding")}},{"./mgf":469,"./withPublic":473,"./xor":474,"bn.js":470,"browserify-rsa":209,"create-hash":386,"parse-asn1":459,"safe-buffer":494}],472:[function(g,I,C){var A=g("parse-asn1"),i=g("randombytes"),e=g("create-hash"),l=g("./mgf"),t=g("./xor"),s=g("bn.js"),c=g("./withPublic"),d=g("browserify-rsa"),o=g("safe-buffer").Buffer;function n(g,I){var C=g.modulus.byteLength(),A=I.length,c=e("sha1").update(o.alloc(0)).digest(),d=c.length,n=2*d;if(A>C-n-2)throw new Error("message too long");var a=o.alloc(C-A-n-2),Z=C-d-1,b=i(d),r=t(o.concat([c,a,o.alloc(1,1),I],Z),l(b,Z)),m=t(b,l(r,d));return new s(o.concat([o.alloc(1),m,r],C))}function a(g,I,C){var A,i=I.length,e=g.modulus.byteLength();if(i>e-11)throw new Error("message too long");return A=C?o.alloc(e-i-3,255):Z(e-i-3),new s(o.concat([o.from([0,C?1:2]),A,o.alloc(1),I],e))}function Z(g){for(var I,C=o.allocUnsafe(g),A=0,e=i(2*g),l=0;A=0)throw new Error("data too long for modulus")}return C?d(e,l):c(e,l)}},{"./mgf":469,"./withPublic":473,"./xor":474,"bn.js":470,"browserify-rsa":209,"create-hash":386,"parse-asn1":459,randombytes:475,"safe-buffer":494}],473:[function(g,I,C){var A=g("bn.js"),i=g("safe-buffer").Buffer;function e(g,I){return i.from(g.toRed(A.mont(I.modulus)).redPow(new A(I.publicExponent)).fromRed().toArray())}I.exports=e},{"bn.js":470,"safe-buffer":494}],474:[function(g,I,C){I.exports=function(g,I){for(var C=g.length,A=-1;++Ae)throw new RangeError("requested too many random bytes");var A=t.allocUnsafe(g);if(g>0)if(g>i)for(var l=0;ld||g<0)throw new TypeError("offset must be a uint32");if(g>s||g>I)throw new RangeError("offset out of range")}function n(g,I,C){if("number"!=typeof g||g!=g)throw new TypeError("size must be a number");if(g>d||g<0)throw new TypeError("size must be a uint32");if(g+I>C||g>s)throw new RangeError("buffer too small")}function a(g,I,C,i){if(!(t.isBuffer(g)||g instanceof A.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');if("function"==typeof I)i=I,I=0,C=g.length;else if("function"==typeof C)i=C,C=g.length-I;else if("function"!=typeof i)throw new TypeError('"cb" argument must be a function');return o(I,g.length),n(C,I,g.length),Z(g,I,C,i)}function Z(g,C,A,i){if(I.browser){var e=g.buffer,t=new Uint8Array(e,C,A);return c.getRandomValues(t),i?void I.nextTick((function(){i(null,g)})):g}if(!i)return l(A).copy(g,C),g;l(A,(function(I,A){if(I)return i(I);A.copy(g,C),i(null,g)}))}function b(g,I,C){if(void 0===I&&(I=0),!(t.isBuffer(g)||g instanceof A.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');return o(I,g.length),void 0===C&&(C=g.length-I),n(C,I,g.length),Z(g,I,C)}c&&c.getRandomValues||!I.browser?(C.randomFill=a,C.randomFillSync=b):(C.randomFill=i,C.randomFillSync=i)}).call(this)}).call(this,g("_process"),void 0!==EI?EI:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{_process:467,randombytes:475,"safe-buffer":494}],477:[function(g,I,C){function A(g,I){g.prototype=Object.create(I.prototype),g.prototype.constructor=g,g.__proto__=I}var i={};function e(g,I,C){function e(g,C,A){return"string"==typeof I?I:I(g,C,A)}C||(C=Error);var l=function(g){function I(I,C,A){return g.call(this,e(I,C,A))||this}return A(I,g),I}(C);l.prototype.name=C.name,l.prototype.code=g,i[g]=l}function l(g,I){if(Array.isArray(g)){var C=g.length;return g=g.map((function(g){return String(g)})),C>2?"one of ".concat(I," ").concat(g.slice(0,C-1).join(", "),", or ")+g[C-1]:2===C?"one of ".concat(I," ").concat(g[0]," or ").concat(g[1]):"of ".concat(I," ").concat(g[0])}return"of ".concat(I," ").concat(String(g))}function t(g,I,C){return g.substr(0,I.length)===I}function s(g,I,C){return(void 0===C||C>g.length)&&(C=g.length),g.substring(C-I.length,C)===I}function c(g,I,C){return"number"!=typeof C&&(C=0),!(C+I.length>g.length)&&-1!==g.indexOf(I,C)}e("ERR_INVALID_OPT_VALUE",(function(g,I){return'The value "'+I+'" is invalid for option "'+g+'"'}),TypeError),e("ERR_INVALID_ARG_TYPE",(function(g,I,C){var A,i;if("string"==typeof I&&t(I,"not ")?(A="must not be",I=I.replace(/^not /,"")):A="must be",s(g," argument"))i="The ".concat(g," ").concat(A," ").concat(l(I,"type"));else{var e=c(g,".")?"property":"argument";i='The "'.concat(g,'" ').concat(e," ").concat(A," ").concat(l(I,"type"))}return i+=". Received type ".concat(typeof C)}),TypeError),e("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),e("ERR_METHOD_NOT_IMPLEMENTED",(function(g){return"The "+g+" method is not implemented"})),e("ERR_STREAM_PREMATURE_CLOSE","Premature close"),e("ERR_STREAM_DESTROYED",(function(g){return"Cannot call "+g+" after a stream was destroyed"})),e("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),e("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),e("ERR_STREAM_WRITE_AFTER_END","write after end"),e("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),e("ERR_UNKNOWN_ENCODING",(function(g){return"Unknown encoding: "+g}),TypeError),e("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),I.exports.codes=i},{}],478:[function(g,I,C){(function(C){(function(){var A=Object.keys||function(g){var I=[];for(var C in g)I.push(C);return I};I.exports=c;var i=g("./_stream_readable"),e=g("./_stream_writable");g("inherits")(c,i);for(var l=A(e.prototype),t=0;t0)if("string"==typeof I||l.objectMode||Object.getPrototypeOf(I)===t.prototype||(I=c(I)),A)l.endEmitted?p(g,new W):N(g,l,I,!0);else if(l.ended)p(g,new B);else{if(l.destroyed)return!1;l.reading=!1,l.decoder&&!C?(I=l.decoder.write(I),l.objectMode||0!==I.length?N(g,l,I,!1):k(g,l)):N(g,l,I,!1)}else A||(l.reading=!1,k(g,l));return!l.ended&&(l.length=K?g=K:(g--,g|=g>>>1,g|=g>>>2,g|=g>>>4,g|=g>>>8,g|=g>>>16,g++),g}function M(g,I){return g<=0||0===I.length&&I.ended?0:I.objectMode?1:g!=g?I.flowing&&I.length?I.buffer.head.data.length:I.length:(g>I.highWaterMark&&(I.highWaterMark=F(g)),g<=I.length?g:I.ended?I.length:(I.needReadable=!0,0))}function J(g,I){if(o("onEofChunk"),!I.ended){if(I.decoder){var C=I.decoder.end();C&&C.length&&(I.buffer.push(C),I.length+=I.objectMode?1:C.length)}I.ended=!0,I.sync?S(g):(I.needReadable=!1,I.emittedReadable||(I.emittedReadable=!0,f(g)))}}function S(g){var I=g._readableState;o("emitReadable",I.needReadable,I.emittedReadable),I.needReadable=!1,I.emittedReadable||(o("emitReadable",I.flowing),I.emittedReadable=!0,C.nextTick(f,g))}function f(g){var I=g._readableState;o("emitReadable_",I.destroyed,I.length,I.ended),I.destroyed||!I.length&&!I.ended||(g.emit("readable"),I.emittedReadable=!1),I.needReadable=!I.flowing&&!I.ended&&I.length<=I.highWaterMark,U(g)}function k(g,I){I.readingMore||(I.readingMore=!0,C.nextTick(D,g,I))}function D(g,I){for(;!I.reading&&!I.ended&&(I.length0,I.resumeScheduled&&!I.paused?I.flowing=!0:g.listenerCount("data")>0&&g.resume()}function v(g){o("readable nexttick read 0"),g.read(0)}function T(g,I){I.resumeScheduled||(I.resumeScheduled=!0,C.nextTick(x,g,I))}function x(g,I){o("resume",I.reading),I.reading||g.read(0),I.resumeScheduled=!1,g.emit("resume"),U(g),I.flowing&&!I.reading&&g.read(0)}function U(g){var I=g._readableState;for(o("flow",I.flowing);I.flowing&&null!==g.read(););}function Q(g,I){return 0===I.length?null:(I.objectMode?C=I.buffer.shift():!g||g>=I.length?(C=I.decoder?I.buffer.join(""):1===I.buffer.length?I.buffer.first():I.buffer.concat(I.length),I.buffer.clear()):C=I.buffer.consume(g,I.decoder),C);var C}function j(g){var I=g._readableState;o("endReadable",I.endEmitted),I.endEmitted||(I.ended=!0,C.nextTick(O,I,g))}function O(g,I){if(o("endReadableNT",g.endEmitted,g.length),!g.endEmitted&&0===g.length&&(g.endEmitted=!0,I.readable=!1,I.emit("end"),g.autoDestroy)){var C=I._writableState;(!C||C.autoDestroy&&C.finished)&&I.destroy()}}function E(g,I){for(var C=0,A=g.length;C=I.highWaterMark:I.length>0)||I.ended))return o("read: emitReadable",I.length,I.ended),0===I.length&&I.ended?j(this):S(this),null;if(0===(g=M(g,I))&&I.ended)return 0===I.length&&j(this),null;var A,i=I.needReadable;return o("need readable",i),(0===I.length||I.length-g0?Q(g,I):null)?(I.needReadable=I.length<=I.highWaterMark,g=0):(I.length-=g,I.awaitDrain=0),0===I.length&&(I.ended||(I.needReadable=!0),C!==g&&I.ended&&j(this)),null!==A&&this.emit("data",A),A},Y.prototype._read=function(g){p(this,new w("_read()"))},Y.prototype.pipe=function(g,I){var A=this,i=this._readableState;switch(i.pipesCount){case 0:i.pipes=g;break;case 1:i.pipes=[i.pipes,g];break;default:i.pipes.push(g)}i.pipesCount+=1,o("pipe count=%d opts=%j",i.pipesCount,I);var l=I&&!1===I.end||g===C.stdout||g===C.stderr?m:s;function t(g,I){o("onunpipe"),g===A&&I&&!1===I.hasUnpiped&&(I.hasUnpiped=!0,n())}function s(){o("onend"),g.end()}i.endEmitted?C.nextTick(l):A.once("end",l),g.on("unpipe",t);var c=L(A);g.on("drain",c);var d=!1;function n(){o("cleanup"),g.removeListener("close",b),g.removeListener("finish",r),g.removeListener("drain",c),g.removeListener("error",Z),g.removeListener("unpipe",t),A.removeListener("end",s),A.removeListener("end",m),A.removeListener("data",a),d=!0,!i.awaitDrain||g._writableState&&!g._writableState.needDrain||c()}function a(I){o("ondata");var C=g.write(I);o("dest.write",C),!1===C&&((1===i.pipesCount&&i.pipes===g||i.pipesCount>1&&-1!==E(i.pipes,g))&&!d&&(o("false write response, pause",i.awaitDrain),i.awaitDrain++),A.pause())}function Z(I){o("onerror",I),m(),g.removeListener("error",Z),0===e(g,"error")&&p(g,I)}function b(){g.removeListener("finish",r),m()}function r(){o("onfinish"),g.removeListener("close",b),m()}function m(){o("unpipe"),A.unpipe(g)}return A.on("data",a),y(g,"error",Z),g.once("close",b),g.once("finish",r),g.emit("pipe",A),i.flowing||(o("pipe resume"),A.resume()),g},Y.prototype.unpipe=function(g){var I=this._readableState,C={hasUnpiped:!1};if(0===I.pipesCount)return this;if(1===I.pipesCount)return g&&g!==I.pipes||(g||(g=I.pipes),I.pipes=null,I.pipesCount=0,I.flowing=!1,g&&g.emit("unpipe",this,C)),this;if(!g){var A=I.pipes,i=I.pipesCount;I.pipes=null,I.pipesCount=0,I.flowing=!1;for(var e=0;e0,!1!==i.flowing&&this.resume()):"readable"===g&&(i.endEmitted||i.readableListening||(i.readableListening=i.needReadable=!0,i.flowing=!1,i.emittedReadable=!1,o("on readable",i.length,i.reading),i.length?S(this):i.reading||C.nextTick(v,this))),A},Y.prototype.addListener=Y.prototype.on,Y.prototype.removeListener=function(g,I){var A=l.prototype.removeListener.call(this,g,I);return"readable"===g&&C.nextTick(z,this),A},Y.prototype.removeAllListeners=function(g){var I=l.prototype.removeAllListeners.apply(this,arguments);return"readable"!==g&&void 0!==g||C.nextTick(z,this),I},Y.prototype.resume=function(){var g=this._readableState;return g.flowing||(o("resume"),g.flowing=!g.readableListening,T(this,g)),g.paused=!1,this},Y.prototype.pause=function(){return o("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(o("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},Y.prototype.wrap=function(g){var I=this,C=this._readableState,A=!1;for(var i in g.on("end",(function(){if(o("wrapped end"),C.decoder&&!C.ended){var g=C.decoder.end();g&&g.length&&I.push(g)}I.push(null)})),g.on("data",(function(i){o("wrapped data"),C.decoder&&(i=C.decoder.write(i)),C.objectMode&&null==i||(C.objectMode||i&&i.length)&&(I.push(i)||(A=!0,g.pause()))})),g)void 0===this[i]&&"function"==typeof g[i]&&(this[i]=function(I){return function(){return g[I].apply(g,arguments)}}(i));for(var e=0;e-1))throw new W(g);return this._writableState.defaultEncoding=g,this},Object.defineProperty(X.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(X.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),X.prototype._write=function(g,I,C){C(new m("_write()"))},X.prototype._writev=null,X.prototype.end=function(g,I,C){var A=this._writableState;return"function"==typeof g?(C=g,g=null,I=null):"function"==typeof I&&(C=I,I=null),null!=g&&this.write(g,I),A.corked&&(A.corked=1,this.uncork()),A.ending||T(this,A,C),this},Object.defineProperty(X.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(X.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(g){this._writableState&&(this._writableState.destroyed=g)}}),X.prototype.destroy=a.destroy,X.prototype._undestroy=a.undestroy,X.prototype._destroy=function(g,I){I(g)}}).call(this)}).call(this,g("_process"),void 0!==EI?EI:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../errors":477,"./_stream_duplex":478,"./internal/streams/destroy":485,"./internal/streams/state":489,"./internal/streams/stream":490,_process:467,buffer:220,inherits:440,"util-deprecate":524}],483:[function(g,I,C){(function(C){(function(){var A;function i(g,I,C){return(I=e(I))in g?Object.defineProperty(g,I,{value:C,enumerable:!0,configurable:!0,writable:!0}):g[I]=C,g}function e(g){var I=l(g,"string");return"symbol"==typeof I?I:String(I)}function l(g,I){if("object"!=typeof g||null===g)return g;var C=g[Symbol.toPrimitive];if(void 0!==C){var A=C.call(g,I||"default");if("object"!=typeof A)return A;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===I?String:Number)(g)}var t=g("./end-of-stream"),s=Symbol("lastResolve"),c=Symbol("lastReject"),d=Symbol("error"),o=Symbol("ended"),n=Symbol("lastPromise"),a=Symbol("handlePromise"),Z=Symbol("stream");function b(g,I){return{value:g,done:I}}function r(g){var I=g[s];if(null!==I){var C=g[Z].read();null!==C&&(g[n]=null,g[s]=null,g[c]=null,I(b(C,!1)))}}function m(g){C.nextTick(r,g)}function h(g,I){return function(C,A){g.then((function(){I[o]?C(b(void 0,!0)):I[a](C,A)}),A)}}var G=Object.getPrototypeOf((function(){})),u=Object.setPrototypeOf((i(A={get stream(){return this[Z]},next:function(){var g=this,I=this[d];if(null!==I)return Promise.reject(I);if(this[o])return Promise.resolve(b(void 0,!0));if(this[Z].destroyed)return new Promise((function(I,A){C.nextTick((function(){g[d]?A(g[d]):I(b(void 0,!0))}))}));var A,i=this[n];if(i)A=new Promise(h(i,this));else{var e=this[Z].read();if(null!==e)return Promise.resolve(b(e,!1));A=new Promise(this[a])}return this[n]=A,A}},Symbol.asyncIterator,(function(){return this})),i(A,"return",(function(){var g=this;return new Promise((function(I,C){g[Z].destroy(null,(function(g){g?C(g):I(b(void 0,!0))}))}))})),A),G),B=function(g){var I,C=Object.create(u,(i(I={},Z,{value:g,writable:!0}),i(I,s,{value:null,writable:!0}),i(I,c,{value:null,writable:!0}),i(I,d,{value:null,writable:!0}),i(I,o,{value:g._readableState.endEmitted,writable:!0}),i(I,a,{value:function(g,I){var A=C[Z].read();A?(C[n]=null,C[s]=null,C[c]=null,g(b(A,!1))):(C[s]=g,C[c]=I)},writable:!0}),I));return C[n]=null,t(g,(function(g){if(g&&"ERR_STREAM_PREMATURE_CLOSE"!==g.code){var I=C[c];return null!==I&&(C[n]=null,C[s]=null,C[c]=null,I(g)),void(C[d]=g)}var A=C[s];null!==A&&(C[n]=null,C[s]=null,C[c]=null,A(b(void 0,!0))),C[o]=!0})),g.on("readable",m.bind(null,C)),C};I.exports=B}).call(this)}).call(this,g("_process"))},{"./end-of-stream":486,_process:467}],484:[function(g,I,C){function A(g,I){var C=Object.keys(g);if(Object.getOwnPropertySymbols){var A=Object.getOwnPropertySymbols(g);I&&(A=A.filter((function(I){return Object.getOwnPropertyDescriptor(g,I).enumerable}))),C.push.apply(C,A)}return C}function i(g){for(var I=1;I0?this.tail.next=I:this.head=I,this.tail=I,++this.length}},{key:"unshift",value:function(g){var I={data:g,next:this.head};0===this.length&&(this.tail=I),this.head=I,++this.length}},{key:"shift",value:function(){if(0!==this.length){var g=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,g}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(g){if(0===this.length)return"";for(var I=this.head,C=""+I.data;I=I.next;)C+=g+I.data;return C}},{key:"concat",value:function(g){if(0===this.length)return o.alloc(0);for(var I=o.allocUnsafe(g>>>0),C=this.head,A=0;C;)Z(C.data,I,A),A+=C.data.length,C=C.next;return I}},{key:"consume",value:function(g,I){var C;return gi.length?i.length:g;if(e===i.length?A+=i:A+=i.slice(0,g),0==(g-=e)){e===i.length?(++C,I.next?this.head=I.next:this.head=this.tail=null):(this.head=I,I.data=i.slice(e));break}++C}return this.length-=C,A}},{key:"_getBuffer",value:function(g){var I=o.allocUnsafe(g),C=this.head,A=1;for(C.data.copy(I),g-=C.data.length;C=C.next;){var i=C.data,e=g>i.length?i.length:g;if(i.copy(I,I.length-g,0,e),0==(g-=e)){e===i.length?(++A,C.next?this.head=C.next:this.head=this.tail=null):(this.head=C,C.data=i.slice(e));break}++A}return this.length-=A,I}},{key:a,value:function(g,I){return n(this,i(i({},I),{},{depth:0,customInspect:!1}))}}]),g}()},{buffer:220,util:188}],485:[function(g,I,C){(function(g){(function(){function C(I,C){var e=this,t=this._readableState&&this._readableState.destroyed,s=this._writableState&&this._writableState.destroyed;return t||s?(C?C(I):I&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,g.nextTick(l,this,I)):g.nextTick(l,this,I)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(I||null,(function(I){!C&&I?e._writableState?e._writableState.errorEmitted?g.nextTick(i,e):(e._writableState.errorEmitted=!0,g.nextTick(A,e,I)):g.nextTick(A,e,I):C?(g.nextTick(i,e),C(I)):g.nextTick(i,e)})),this)}function A(g,I){l(g,I),i(g)}function i(g){g._writableState&&!g._writableState.emitClose||g._readableState&&!g._readableState.emitClose||g.emit("close")}function e(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}function l(g,I){g.emit("error",I)}function t(g,I){var C=g._readableState,A=g._writableState;C&&C.autoDestroy||A&&A.autoDestroy?g.destroy(I):g.emit("error",I)}I.exports={destroy:C,undestroy:e,errorOrDestroy:t}}).call(this)}).call(this,g("_process"))},{_process:467}],486:[function(g,I,C){var A=g("../../../errors").codes.ERR_STREAM_PREMATURE_CLOSE;function i(g){var I=!1;return function(){if(!I){I=!0;for(var C=arguments.length,A=new Array(C),i=0;i0,(function(g){A||(A=g),g&&e.forEach(o),l||(e.forEach(o),i(A))}))}));return I.reduce(n)}I.exports=Z},{"../../../errors":477,"./end-of-stream":486}],489:[function(g,I,C){var A=g("../../../errors").codes.ERR_INVALID_OPT_VALUE;function i(g,I,C){return null!=g.highWaterMark?g.highWaterMark:I?g[C]:null}function e(g,I,C,e){var l=i(I,e,C);if(null!=l){if(!isFinite(l)||Math.floor(l)!==l||l<0)throw new A(e?C:"highWaterMark",l);return Math.floor(l)}return g.objectMode?16:16384}I.exports={getHighWaterMark:e}},{"../../../errors":477}],490:[function(g,I,C){I.exports=g("events").EventEmitter},{events:422}],491:[function(g,I,C){(C=I.exports=g("./lib/_stream_readable.js")).Stream=C,C.Readable=C,C.Writable=g("./lib/_stream_writable.js"),C.Duplex=g("./lib/_stream_duplex.js"),C.Transform=g("./lib/_stream_transform.js"),C.PassThrough=g("./lib/_stream_passthrough.js"),C.finished=g("./lib/internal/streams/end-of-stream.js"),C.pipeline=g("./lib/internal/streams/pipeline.js")},{"./lib/_stream_duplex.js":478,"./lib/_stream_passthrough.js":479,"./lib/_stream_readable.js":480,"./lib/_stream_transform.js":481,"./lib/_stream_writable.js":482,"./lib/internal/streams/end-of-stream.js":486,"./lib/internal/streams/pipeline.js":488}],492:[function(g,I,C){var A=function(g){var I,C=Object.prototype,A=C.hasOwnProperty,i=Object.defineProperty||function(g,I,C){g[I]=C.value},e="function"==typeof Symbol?Symbol:{},l=e.iterator||"@@iterator",t=e.asyncIterator||"@@asyncIterator",s=e.toStringTag||"@@toStringTag";function c(g,I,C){return Object.defineProperty(g,I,{value:C,enumerable:!0,configurable:!0,writable:!0}),g[I]}try{c({},"")}catch(F){c=function(g,I,C){return g[I]=C}}function d(g,I,C,A){var e=I&&I.prototype instanceof m?I:m,l=Object.create(e.prototype),t=new N(A||[]);return i(l,"_invoke",{value:y(g,C,t)}),l}function o(g,I,C){try{return{type:"normal",arg:g.call(I,C)}}catch(F){return{type:"throw",arg:F}}}g.wrap=d;var n="suspendedStart",a="suspendedYield",Z="executing",b="completed",r={};function m(){}function h(){}function G(){}var u={};c(u,l,(function(){return this}));var B=Object.getPrototypeOf,w=B&&B(B(H([])));w&&w!==C&&A.call(w,l)&&(u=w);var W=G.prototype=m.prototype=Object.create(u);function p(g){["next","throw","return"].forEach((function(I){c(g,I,(function(g){return this._invoke(I,g)}))}))}function V(g,I){function C(i,e,l,t){var s=o(g[i],g,e);if("throw"!==s.type){var c=s.arg,d=c.value;return d&&"object"==typeof d&&A.call(d,"__await")?I.resolve(d.__await).then((function(g){C("next",g,l,t)}),(function(g){C("throw",g,l,t)})):I.resolve(d).then((function(g){c.value=g,l(c)}),(function(g){return C("throw",g,l,t)}))}t(s.arg)}var e;function l(g,A){function i(){return new I((function(I,i){C(g,A,I,i)}))}return e=e?e.then(i,i):i()}i(this,"_invoke",{value:l})}function y(g,I,C){var A=n;return function(i,e){if(A===Z)throw new Error("Generator is already running");if(A===b){if("throw"===i)throw e;return K()}for(C.method=i,C.arg=e;;){var l=C.delegate;if(l){var t=X(l,C);if(t){if(t===r)continue;return t}}if("next"===C.method)C.sent=C._sent=C.arg;else if("throw"===C.method){if(A===n)throw A=b,C.arg;C.dispatchException(C.arg)}else"return"===C.method&&C.abrupt("return",C.arg);A=Z;var s=o(g,I,C);if("normal"===s.type){if(A=C.done?b:a,s.arg===r)continue;return{value:s.arg,done:C.done}}"throw"===s.type&&(A=b,C.method="throw",C.arg=s.arg)}}}function X(g,C){var A=C.method,i=g.iterator[A];if(i===I)return C.delegate=null,"throw"===A&&g.iterator.return&&(C.method="return",C.arg=I,X(g,C),"throw"===C.method)||"return"!==A&&(C.method="throw",C.arg=new TypeError("The iterator does not provide a '"+A+"' method")),r;var e=o(i,g.iterator,C.arg);if("throw"===e.type)return C.method="throw",C.arg=e.arg,C.delegate=null,r;var l=e.arg;return l?l.done?(C[g.resultName]=l.value,C.next=g.nextLoc,"return"!==C.method&&(C.method="next",C.arg=I),C.delegate=null,r):l:(C.method="throw",C.arg=new TypeError("iterator result is not an object"),C.delegate=null,r)}function Y(g){var I={tryLoc:g[0]};1 in g&&(I.catchLoc=g[1]),2 in g&&(I.finallyLoc=g[2],I.afterLoc=g[3]),this.tryEntries.push(I)}function R(g){var I=g.completion||{};I.type="normal",delete I.arg,g.completion=I}function N(g){this.tryEntries=[{tryLoc:"root"}],g.forEach(Y,this),this.reset(!0)}function H(g){if(g){var C=g[l];if(C)return C.call(g);if("function"==typeof g.next)return g;if(!isNaN(g.length)){var i=-1,e=function C(){for(;++i=0;--e){var l=this.tryEntries[e],t=l.completion;if("root"===l.tryLoc)return i("end");if(l.tryLoc<=this.prev){var s=A.call(l,"catchLoc"),c=A.call(l,"finallyLoc");if(s&&c){if(this.prev=0;--C){var i=this.tryEntries[C];if(i.tryLoc<=this.prev&&A.call(i,"finallyLoc")&&this.prev=0;--I){var C=this.tryEntries[I];if(C.finallyLoc===g)return this.complete(C.completion,C.afterLoc),R(C),r}},catch:function(g){for(var I=this.tryEntries.length-1;I>=0;--I){var C=this.tryEntries[I];if(C.tryLoc===g){var A=C.completion;if("throw"===A.type){var i=A.arg;R(C)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(g,C,A){return this.delegate={iterator:H(g),resultName:C,nextLoc:A},"next"===this.method&&(this.arg=I),r}},g}("object"==typeof I?I.exports:{});try{regeneratorRuntime=A}catch(i){"object"==typeof globalThis?globalThis.regeneratorRuntime=A:Function("r","regeneratorRuntime = r")(A)}},{}],493:[function(g,I,C){var A=g("buffer").Buffer,i=g("inherits"),e=g("hash-base"),l=new Array(16),t=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],s=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],c=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],d=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11],o=[0,1518500249,1859775393,2400959708,2840853838],n=[1352829926,1548603684,1836072691,2053994217,0];function a(){e.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}function Z(g,I){return g<>>32-I}function b(g,I,C,A,i,e,l,t){return Z(g+(I^C^A)+e+l|0,t)+i|0}function r(g,I,C,A,i,e,l,t){return Z(g+(I&C|~I&A)+e+l|0,t)+i|0}function m(g,I,C,A,i,e,l,t){return Z(g+((I|~C)^A)+e+l|0,t)+i|0}function h(g,I,C,A,i,e,l,t){return Z(g+(I&A|C&~A)+e+l|0,t)+i|0}function G(g,I,C,A,i,e,l,t){return Z(g+(I^(C|~A))+e+l|0,t)+i|0}i(a,e),a.prototype._update=function(){for(var g=l,I=0;I<16;++I)g[I]=this._block.readInt32LE(4*I);for(var C=0|this._a,A=0|this._b,i=0|this._c,e=0|this._d,a=0|this._e,u=0|this._a,B=0|this._b,w=0|this._c,W=0|this._d,p=0|this._e,V=0;V<80;V+=1){var y,X;V<16?(y=b(C,A,i,e,a,g[t[V]],o[0],c[V]),X=G(u,B,w,W,p,g[s[V]],n[0],d[V])):V<32?(y=r(C,A,i,e,a,g[t[V]],o[1],c[V]),X=h(u,B,w,W,p,g[s[V]],n[1],d[V])):V<48?(y=m(C,A,i,e,a,g[t[V]],o[2],c[V]),X=m(u,B,w,W,p,g[s[V]],n[2],d[V])):V<64?(y=h(C,A,i,e,a,g[t[V]],o[3],c[V]),X=r(u,B,w,W,p,g[s[V]],n[3],d[V])):(y=G(C,A,i,e,a,g[t[V]],o[4],c[V]),X=b(u,B,w,W,p,g[s[V]],n[4],d[V])),C=a,a=e,e=Z(i,10),i=A,A=y,u=p,p=W,W=Z(w,10),w=B,B=X}var Y=this._b+i+W|0;this._b=this._c+e+p|0,this._c=this._d+a+u|0,this._d=this._e+C+B|0,this._e=this._a+A+w|0,this._a=Y},a.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var g=A.alloc?A.alloc(20):new A(20);return g.writeInt32LE(this._a,0),g.writeInt32LE(this._b,4),g.writeInt32LE(this._c,8),g.writeInt32LE(this._d,12),g.writeInt32LE(this._e,16),g},I.exports=a},{buffer:220,"hash-base":425,inherits:440}],494:[function(g,I,C){ /*! safe-buffer. MIT License. Feross Aboukhadijeh */ var A=g("buffer"),i=A.Buffer;function e(g,I){for(var C in g)I[C]=g[C]}function l(g,I,C){return i(g,I,C)}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?I.exports=A:(e(A,C),C.Buffer=l),l.prototype=Object.create(i.prototype),e(i,l),l.from=function(g,I,C){if("number"==typeof g)throw new TypeError("Argument must not be a number");return i(g,I,C)},l.alloc=function(g,I,C){if("number"!=typeof g)throw new TypeError("Argument must be a number");var A=i(g);return void 0!==I?"string"==typeof C?A.fill(I,C):A.fill(I):A.fill(0),A},l.allocUnsafe=function(g){if("number"!=typeof g)throw new TypeError("Argument must be a number");return i(g)},l.allocUnsafeSlow=function(g){if("number"!=typeof g)throw new TypeError("Argument must be a number");return A.SlowBuffer(g)}},{buffer:220}],495:[function(g,I,C){(function(C){(function(){var A,i=g("buffer"),e=i.Buffer,l={};for(A in i)i.hasOwnProperty(A)&&"SlowBuffer"!==A&&"Buffer"!==A&&(l[A]=i[A]);var t=l.Buffer={};for(A in e)e.hasOwnProperty(A)&&"allocUnsafe"!==A&&"allocUnsafeSlow"!==A&&(t[A]=e[A]);if(l.Buffer.prototype=e.prototype,t.from&&t.from!==Uint8Array.from||(t.from=function(g,I,C){if("number"==typeof g)throw new TypeError('The "value" argument must not be of type number. Received type '+typeof g);if(g&&void 0===g.length)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof g);return e(g,I,C)}),t.alloc||(t.alloc=function(g,I,C){if("number"!=typeof g)throw new TypeError('The "size" argument must be of type number. Received type '+typeof g);if(g<0||g>=2*(1<<30))throw new RangeError('The value "'+g+'" is invalid for option "size"');var A=e(g);return I&&0!==I.length?"string"==typeof C?A.fill(I,C):A.fill(I):A.fill(0),A}),!l.kStringMaxLength)try{l.kStringMaxLength=C.binding("buffer").kStringMaxLength}catch(s){}l.constants||(l.constants={MAX_LENGTH:l.kMaxLength},l.kStringMaxLength&&(l.constants.MAX_STRING_LENGTH=l.kStringMaxLength)),I.exports=l}).call(this)}).call(this,g("_process"))},{_process:467,buffer:220}],496:[function(g,I,C){Object.defineProperty(C,"__esModule",{value:!0});const A=g("xmlchars/xml/1.0/ed5"),i=g("xmlchars/xml/1.1/ed2"),e=g("xmlchars/xmlns/1.0/ed3");var l=A.isS,t=A.isChar,s=A.isNameStartChar,c=A.isNameChar,d=A.S_LIST,o=A.NAME_RE,n=i.isChar,a=e.isNCNameStartChar,Z=e.isNCNameChar,b=e.NC_NAME_RE;const r="http://www.w3.org/XML/1998/namespace",m="http://www.w3.org/2000/xmlns/",h={__proto__:null,xml:r,xmlns:m},G={__proto__:null,amp:"&",gt:">",lt:"<",quot:'"',apos:"'"},u=-1,B=-2,w=0,W=1,p=2,V=3,y=4,X=5,Y=6,R=7,N=8,H=9,K=10,F=11,M=12,J=13,S=14,f=15,k=16,D=17,L=18,z=19,v=20,T=21,x=22,U=23,Q=24,j=25,O=26,E=27,P=28,_=29,q=30,$=31,gg=32,Ig=33,Cg=34,Ag=35,ig=36,eg=37,lg=38,tg=39,sg=40,cg=41,dg=42,og=43,ng=44,ag=9,Zg=10,bg=13,rg=32,mg=33,hg=34,Gg=38,ug=39,Bg=45,wg=47,Wg=59,pg=60,Vg=61,yg=62,Xg=63,Yg=91,Rg=93,Ng=133,Hg=8232,Kg=g=>g===hg||g===ug,Fg=[hg,ug],Mg=[...Fg,Yg,yg],Jg=[...Fg,pg,Rg],Sg=[Vg,Xg,...d],fg=[...d,yg,Gg,pg];function kg(g,I,C){switch(I){case"xml":C!==r&&g.fail(`xml prefix must be bound to ${r}.`);break;case"xmlns":C!==m&&g.fail(`xmlns prefix must be bound to ${m}.`)}switch(C){case m:g.fail(""===I?`the default namespace may not be set to ${C}.`:`may not assign a prefix (even "xmlns") to the URI ${m}.`);break;case r:switch(I){case"xml":break;case"":g.fail(`the default namespace may not be set to ${C}.`);break;default:g.fail("may not assign the xml namespace to another prefix.")}}}function Dg(g,I){for(const C of Object.keys(I))kg(g,C,I[C])}const Lg=g=>b.test(g),zg=g=>o.test(g),vg=0,Tg=1,xg=2;C.EVENTS=["xmldecl","text","processinginstruction","doctype","comment","opentagstart","attribute","opentag","closetag","cdata","error","end","ready"];const Ug={xmldecl:"xmldeclHandler",text:"textHandler",processinginstruction:"piHandler",doctype:"doctypeHandler",comment:"commentHandler",opentagstart:"openTagStartHandler",attribute:"attributeHandler",opentag:"openTagHandler",closetag:"closeTagHandler",cdata:"cdataHandler",error:"errorHandler",end:"endHandler",ready:"readyHandler"};class Qg{constructor(g){this.opt=null!=g?g:{},this.fragmentOpt=!!this.opt.fragment;const I=this.xmlnsOpt=!!this.opt.xmlns;if(this.trackPosition=!1!==this.opt.position,this.fileName=this.opt.fileName,I){this.nameStartCheck=a,this.nameCheck=Z,this.isName=Lg,this.processAttribs=this.processAttribsNS,this.pushAttrib=this.pushAttribNS,this.ns=Object.assign({__proto__:null},h);const g=this.opt.additionalNamespaces;null!=g&&(Dg(this,g),Object.assign(this.ns,g))}else this.nameStartCheck=s,this.nameCheck=c,this.isName=zg,this.processAttribs=this.processAttribsPlain,this.pushAttrib=this.pushAttribPlain;this.stateTable=[this.sBegin,this.sBeginWhitespace,this.sDoctype,this.sDoctypeQuote,this.sDTD,this.sDTDQuoted,this.sDTDOpenWaka,this.sDTDOpenWakaBang,this.sDTDComment,this.sDTDCommentEnding,this.sDTDCommentEnded,this.sDTDPI,this.sDTDPIEnding,this.sText,this.sEntity,this.sOpenWaka,this.sOpenWakaBang,this.sComment,this.sCommentEnding,this.sCommentEnded,this.sCData,this.sCDataEnding,this.sCDataEnding2,this.sPIFirstChar,this.sPIRest,this.sPIBody,this.sPIEnding,this.sXMLDeclNameStart,this.sXMLDeclName,this.sXMLDeclEq,this.sXMLDeclValueStart,this.sXMLDeclValue,this.sXMLDeclSeparator,this.sXMLDeclEnding,this.sOpenTag,this.sOpenTagSlash,this.sAttrib,this.sAttribName,this.sAttribNameSawWhite,this.sAttribValue,this.sAttribValueQuoted,this.sAttribValueClosed,this.sAttribValueUnquoted,this.sCloseTag,this.sCloseTagSawWhite],this._init()}get closed(){return this._closed}_init(){var g;this.openWakaBang="",this.text="",this.name="",this.piTarget="",this.entity="",this.q=null,this.tags=[],this.tag=null,this.topNS=null,this.chunk="",this.chunkPosition=0,this.i=0,this.prevI=0,this.carriedFromPrevious=void 0,this.forbiddenState=vg,this.attribList=[];const{fragmentOpt:I}=this;this.state=I?J:w,this.reportedTextBeforeRoot=this.reportedTextAfterRoot=this.closedRoot=this.sawRoot=I,this.xmlDeclPossible=!I,this.xmlDeclExpects=["version"],this.entityReturnState=void 0;let{defaultXMLVersion:C}=this.opt;if(void 0===C){if(!0===this.opt.forceXMLVersion)throw new Error("forceXMLVersion set but defaultXMLVersion is not set");C="1.0"}this.setXMLVersion(C),this.positionAtNewLine=0,this.doctype=!1,this._closed=!1,this.xmlDecl={version:void 0,encoding:void 0,standalone:void 0},this.line=1,this.column=0,this.ENTITIES=Object.create(G),null===(g=this.readyHandler)||void 0===g||g.call(this)}get position(){return this.chunkPosition+this.i}get columnIndex(){return this.position-this.positionAtNewLine}on(g,I){this[Ug[g]]=I}off(g){this[Ug[g]]=void 0}makeError(g){var I;let C=null!==(I=this.fileName)&&void 0!==I?I:"";return this.trackPosition&&(C.length>0&&(C+=":"),C+=`${this.line}:${this.column}`),C.length>0&&(C+=": "),new Error(C+g)}fail(g){const I=this.makeError(g),C=this.errorHandler;if(void 0===C)throw I;return C(I),this}write(g){if(this.closed)return this.fail("cannot write after close; assign an onready handler.");let I=!1;null===g?(I=!0,g=""):"object"==typeof g&&(g=g.toString()),void 0!==this.carriedFromPrevious&&(g=`${this.carriedFromPrevious}${g}`,this.carriedFromPrevious=void 0);let C=g.length;const A=g.charCodeAt(C-1);!I&&(A===bg||A>=55296&&A<=56319)&&(this.carriedFromPrevious=g[C-1],C--,g=g.slice(0,C));const{stateTable:i}=this;for(this.chunk=g,this.i=0;this.i=g.length)return u;const C=g.charCodeAt(I);if(this.column++,C<55296){if(C>=rg||C===ag)return C;switch(C){case Zg:return this.line++,this.column=0,this.positionAtNewLine=this.position,Zg;case bg:return g.charCodeAt(I+1)===Zg&&(this.i=I+2),this.line++,this.column=0,this.positionAtNewLine=this.position,B;default:return this.fail("disallowed character."),C}}if(C>56319)return C>=57344&&C<=65533||this.fail("disallowed character."),C;const A=65536+1024*(C-55296)+(g.charCodeAt(I+1)-56320);return this.i=I+2,A>1114111&&this.fail("disallowed character."),A}getCode11(){const{chunk:g,i:I}=this;if(this.prevI=I,this.i=I+1,I>=g.length)return u;const C=g.charCodeAt(I);if(this.column++,C<55296){if(C>31&&C<127||C>159&&C!==Hg||C===ag)return C;switch(C){case Zg:return this.line++,this.column=0,this.positionAtNewLine=this.position,Zg;case bg:{const C=g.charCodeAt(I+1);C!==Zg&&C!==Ng||(this.i=I+2)}case Ng:case Hg:return this.line++,this.column=0,this.positionAtNewLine=this.position,B;default:return this.fail("disallowed character."),C}}if(C>56319)return C>=57344&&C<=65533||this.fail("disallowed character."),C;const A=65536+1024*(C-55296)+(g.charCodeAt(I+1)-56320);return this.i=I+2,A>1114111&&this.fail("disallowed character."),A}getCodeNorm(){const g=this.getCode();return g===B?Zg:g}unget(){this.i=this.prevI,this.column--}captureTo(g){let{i:I}=this;const{chunk:C}=this;for(;;){const A=this.getCode(),i=A===B,e=i?Zg:A;if(e===u||g.includes(e))return this.text+=C.slice(I,this.prevI),e;i&&(this.text+=`${C.slice(I,this.prevI)}\n`,I=this.i)}}captureToChar(g){let{i:I}=this;const{chunk:C}=this;for(;;){let A=this.getCode();switch(A){case B:this.text+=`${C.slice(I,this.prevI)}\n`,I=this.i,A=Zg;break;case u:return this.text+=C.slice(I),!1}if(A===g)return this.text+=C.slice(I,this.prevI),!0}}captureNameChars(){const{chunk:g,i:I}=this;for(;;){const C=this.getCode();if(C===u)return this.name+=g.slice(I),u;if(!c(C))return this.name+=g.slice(I,this.prevI),C===B?Zg:C}}skipSpaces(){for(;;){const g=this.getCodeNorm();if(g===u||!l(g))return g}}setXMLVersion(g){this.currentXMLVersion=g,"1.0"===g?(this.isChar=t,this.getCode=this.getCode10):(this.isChar=n,this.getCode=this.getCode11)}sBegin(){65279===this.chunk.charCodeAt(0)&&(this.i++,this.column++),this.state=W}sBeginWhitespace(){const g=this.i,I=this.skipSpaces();switch(this.prevI!==g&&(this.xmlDeclPossible=!1),I){case pg:if(this.state=f,0!==this.text.length)throw new Error("no-empty text at start");break;case u:break;default:this.unget(),this.state=J,this.xmlDeclPossible=!1}}sDoctype(){var g;const I=this.captureTo(Mg);switch(I){case yg:null===(g=this.doctypeHandler)||void 0===g||g.call(this,this.text),this.text="",this.state=J,this.doctype=!0;break;case u:break;default:this.text+=String.fromCodePoint(I),I===Yg?this.state=y:Kg(I)&&(this.state=V,this.q=I)}}sDoctypeQuote(){const g=this.q;this.captureToChar(g)&&(this.text+=String.fromCodePoint(g),this.q=null,this.state=p)}sDTD(){const g=this.captureTo(Jg);g!==u&&(this.text+=String.fromCodePoint(g),g===Rg?this.state=p:g===pg?this.state=Y:Kg(g)&&(this.state=X,this.q=g))}sDTDQuoted(){const g=this.q;this.captureToChar(g)&&(this.text+=String.fromCodePoint(g),this.state=y,this.q=null)}sDTDOpenWaka(){const g=this.getCodeNorm();switch(this.text+=String.fromCodePoint(g),g){case mg:this.state=R,this.openWakaBang="";break;case Xg:this.state=F;break;default:this.state=y}}sDTDOpenWakaBang(){const g=String.fromCodePoint(this.getCodeNorm()),I=this.openWakaBang+=g;this.text+=g,"-"!==I&&(this.state="--"===I?N:y,this.openWakaBang="")}sDTDComment(){this.captureToChar(Bg)&&(this.text+="-",this.state=H)}sDTDCommentEnding(){const g=this.getCodeNorm();this.text+=String.fromCodePoint(g),this.state=g===Bg?K:N}sDTDCommentEnded(){const g=this.getCodeNorm();this.text+=String.fromCodePoint(g),g===yg?this.state=y:(this.fail("malformed comment."),this.state=N)}sDTDPI(){this.captureToChar(Xg)&&(this.text+="?",this.state=M)}sDTDPIEnding(){const g=this.getCodeNorm();this.text+=String.fromCodePoint(g),g===yg&&(this.state=y)}sText(){0!==this.tags.length?this.handleTextInRoot():this.handleTextOutsideRoot()}sEntity(){let{i:g}=this;const{chunk:I}=this;g:for(;;)switch(this.getCode()){case B:this.entity+=`${I.slice(g,this.prevI)}\n`,g=this.i;break;case Wg:{const{entityReturnState:C}=this,A=this.entity+I.slice(g,this.prevI);let i;this.state=C,""===A?(this.fail("empty entity name."),i="&;"):(i=this.parseEntity(A),this.entity=""),C===J&&void 0===this.textHandler||(this.text+=i);break g}case u:this.entity+=I.slice(g);break g}}sOpenWaka(){const g=this.getCode();if(s(g))this.state=Cg,this.unget(),this.xmlDeclPossible=!1;else switch(g){case wg:this.state=og,this.xmlDeclPossible=!1;break;case mg:this.state=k,this.openWakaBang="",this.xmlDeclPossible=!1;break;case Xg:this.state=U;break;default:this.fail("disallowed character in tag name"),this.state=J,this.xmlDeclPossible=!1}}sOpenWakaBang(){switch(this.openWakaBang+=String.fromCodePoint(this.getCodeNorm()),this.openWakaBang){case"[CDATA[":this.sawRoot||this.reportedTextBeforeRoot||(this.fail("text data outside of root node."),this.reportedTextBeforeRoot=!0),this.closedRoot&&!this.reportedTextAfterRoot&&(this.fail("text data outside of root node."),this.reportedTextAfterRoot=!0),this.state=v,this.openWakaBang="";break;case"--":this.state=D,this.openWakaBang="";break;case"DOCTYPE":this.state=p,(this.doctype||this.sawRoot)&&this.fail("inappropriately located doctype declaration."),this.openWakaBang="";break;default:this.openWakaBang.length>=7&&this.fail("incorrect syntax.")}}sComment(){this.captureToChar(Bg)&&(this.state=L)}sCommentEnding(){var g;const I=this.getCodeNorm();I===Bg?(this.state=z,null===(g=this.commentHandler)||void 0===g||g.call(this,this.text),this.text=""):(this.text+=`-${String.fromCodePoint(I)}`,this.state=D)}sCommentEnded(){const g=this.getCodeNorm();g!==yg?(this.fail("malformed comment."),this.text+=`--${String.fromCodePoint(g)}`,this.state=D):this.state=J}sCData(){this.captureToChar(Rg)&&(this.state=T)}sCDataEnding(){const g=this.getCodeNorm();g===Rg?this.state=x:(this.text+=`]${String.fromCodePoint(g)}`,this.state=v)}sCDataEnding2(){var g;const I=this.getCodeNorm();switch(I){case yg:null===(g=this.cdataHandler)||void 0===g||g.call(this,this.text),this.text="",this.state=J;break;case Rg:this.text+="]";break;default:this.text+=`]]${String.fromCodePoint(I)}`,this.state=v}}sPIFirstChar(){const g=this.getCodeNorm();this.nameStartCheck(g)?(this.piTarget+=String.fromCodePoint(g),this.state=Q):g===Xg||l(g)?(this.fail("processing instruction without a target."),this.state=g===Xg?O:j):(this.fail("disallowed character in processing instruction name."),this.piTarget+=String.fromCodePoint(g),this.state=Q)}sPIRest(){const{chunk:g,i:I}=this;for(;;){const C=this.getCodeNorm();if(C===u)return void(this.piTarget+=g.slice(I));if(!this.nameCheck(C)){this.piTarget+=g.slice(I,this.prevI);const A=C===Xg;A||l(C)?"xml"===this.piTarget?(this.xmlDeclPossible||this.fail("an XML declaration must be at the start of the document."),this.state=A?Ig:E):this.state=A?O:j:(this.fail("disallowed character in processing instruction name."),this.piTarget+=String.fromCodePoint(C));break}}}sPIBody(){if(0===this.text.length){const g=this.getCodeNorm();g===Xg?this.state=O:l(g)||(this.text=String.fromCodePoint(g))}else this.captureToChar(Xg)&&(this.state=O)}sPIEnding(){var g;const I=this.getCodeNorm();if(I===yg){const{piTarget:I}=this;"xml"===I.toLowerCase()&&this.fail("the XML declaration must appear at the start of the document."),null===(g=this.piHandler)||void 0===g||g.call(this,{target:I,body:this.text}),this.piTarget=this.text="",this.state=J}else I===Xg?this.text+="?":(this.text+=`?${String.fromCodePoint(I)}`,this.state=j);this.xmlDeclPossible=!1}sXMLDeclNameStart(){const g=this.skipSpaces();g!==Xg?g!==u&&(this.state=P,this.name=String.fromCodePoint(g)):this.state=Ig}sXMLDeclName(){const g=this.captureTo(Sg);if(g===Xg)return this.state=Ig,this.name+=this.text,this.text="",void this.fail("XML declaration is incomplete.");if(l(g)||g===Vg){if(this.name+=this.text,this.text="",!this.xmlDeclExpects.includes(this.name))switch(this.name.length){case 0:this.fail("did not expect any more name/value pairs.");break;case 1:this.fail(`expected the name ${this.xmlDeclExpects[0]}.`);break;default:this.fail(`expected one of ${this.xmlDeclExpects.join(", ")}`)}this.state=g===Vg?q:_}}sXMLDeclEq(){const g=this.getCodeNorm();if(g===Xg)return this.state=Ig,void this.fail("XML declaration is incomplete.");l(g)||(g!==Vg&&this.fail("value required."),this.state=q)}sXMLDeclValueStart(){const g=this.getCodeNorm();if(g===Xg)return this.state=Ig,void this.fail("XML declaration is incomplete.");l(g)||(Kg(g)?this.q=g:(this.fail("value must be quoted."),this.q=rg),this.state=$)}sXMLDeclValue(){const g=this.captureTo([this.q,Xg]);if(g===Xg)return this.state=Ig,this.text="",void this.fail("XML declaration is incomplete.");if(g===u)return;const I=this.text;switch(this.text="",this.name){case"version":{this.xmlDeclExpects=["encoding","standalone"];const g=I;this.xmlDecl.version=g,/^1\.[0-9]+$/.test(g)?this.opt.forceXMLVersion||this.setXMLVersion(g):this.fail("version number must match /^1\\.[0-9]+$/.");break}case"encoding":/^[A-Za-z][A-Za-z0-9._-]*$/.test(I)||this.fail("encoding value must match \t/^[A-Za-z0-9][A-Za-z0-9._-]*$/."),this.xmlDeclExpects=["standalone"],this.xmlDecl.encoding=I;break;case"standalone":"yes"!==I&&"no"!==I&&this.fail('standalone value must match "yes" or "no".'),this.xmlDeclExpects=[],this.xmlDecl.standalone=I}this.name="",this.state=gg}sXMLDeclSeparator(){const g=this.getCodeNorm();g!==Xg?(l(g)||(this.fail("whitespace required."),this.unget()),this.state=E):this.state=Ig}sXMLDeclEnding(){var g;this.getCodeNorm()===yg?("xml"!==this.piTarget?this.fail("processing instructions are not allowed before root."):"version"!==this.name&&this.xmlDeclExpects.includes("version")&&this.fail("XML declaration must contain a version."),null===(g=this.xmldeclHandler)||void 0===g||g.call(this,this.xmlDecl),this.name="",this.piTarget=this.text="",this.state=J):this.fail("The character ? is disallowed anywhere in XML declarations."),this.xmlDeclPossible=!1}sOpenTag(){var g;const I=this.captureNameChars();if(I===u)return;const C=this.tag={name:this.name,attributes:Object.create(null)};switch(this.name="",this.xmlnsOpt&&(this.topNS=C.ns=Object.create(null)),null===(g=this.openTagStartHandler)||void 0===g||g.call(this,C),this.sawRoot=!0,!this.fragmentOpt&&this.closedRoot&&this.fail("documents may contain only one root."),I){case yg:this.openTag();break;case wg:this.state=Ag;break;default:l(I)||this.fail("disallowed character in tag name."),this.state=ig}}sOpenTagSlash(){this.getCode()===yg?this.openSelfClosingTag():(this.fail("forward-slash in opening tag not followed by >."),this.state=ig)}sAttrib(){const g=this.skipSpaces();g!==u&&(s(g)?(this.unget(),this.state=eg):g===yg?this.openTag():g===wg?this.state=Ag:this.fail("disallowed character in attribute name."))}sAttribName(){const g=this.captureNameChars();g===Vg?this.state=tg:l(g)?this.state=lg:g===yg?(this.fail("attribute without value."),this.pushAttrib(this.name,this.name),this.name=this.text="",this.openTag()):g!==u&&this.fail("disallowed character in attribute name.")}sAttribNameSawWhite(){const g=this.skipSpaces();switch(g){case u:return;case Vg:this.state=tg;break;default:this.fail("attribute without value."),this.text="",this.name="",g===yg?this.openTag():s(g)?(this.unget(),this.state=eg):(this.fail("disallowed character in attribute name."),this.state=ig)}}sAttribValue(){const g=this.getCodeNorm();Kg(g)?(this.q=g,this.state=sg):l(g)||(this.fail("unquoted attribute value."),this.state=dg,this.unget())}sAttribValueQuoted(){const{q:g,chunk:I}=this;let{i:C}=this;for(;;)switch(this.getCode()){case g:return this.pushAttrib(this.name,this.text+I.slice(C,this.prevI)),this.name=this.text="",this.q=null,void(this.state=cg);case Gg:return this.text+=I.slice(C,this.prevI),this.state=S,void(this.entityReturnState=sg);case Zg:case B:case ag:this.text+=`${I.slice(C,this.prevI)} `,C=this.i;break;case pg:return this.text+=I.slice(C,this.prevI),void this.fail("disallowed character.");case u:return void(this.text+=I.slice(C))}}sAttribValueClosed(){const g=this.getCodeNorm();l(g)?this.state=ig:g===yg?this.openTag():g===wg?this.state=Ag:s(g)?(this.fail("no whitespace between attributes."),this.unget(),this.state=eg):this.fail("disallowed character in attribute name.")}sAttribValueUnquoted(){const g=this.captureTo(fg);switch(g){case Gg:this.state=S,this.entityReturnState=dg;break;case pg:this.fail("disallowed character.");break;case u:break;default:this.text.includes("]]>")&&this.fail('the string "]]>" is disallowed in char data.'),this.pushAttrib(this.name,this.text),this.name=this.text="",g===yg?this.openTag():this.state=ig}}sCloseTag(){const g=this.captureNameChars();g===yg?this.closeTag():l(g)?this.state=ng:g!==u&&this.fail("disallowed character in closing tag.")}sCloseTagSawWhite(){switch(this.skipSpaces()){case yg:this.closeTag();break;case u:break;default:this.fail("disallowed character in closing tag.")}}handleTextInRoot(){let{i:g,forbiddenState:I}=this;const{chunk:C,textHandler:A}=this;g:for(;;)switch(this.getCode()){case pg:if(this.state=f,void 0!==A){const{text:I}=this,i=C.slice(g,this.prevI);0!==I.length?(A(I+i),this.text=""):0!==i.length&&A(i)}I=vg;break g;case Gg:this.state=S,this.entityReturnState=J,void 0!==A&&(this.text+=C.slice(g,this.prevI)),I=vg;break g;case Rg:switch(I){case vg:I=Tg;break;case Tg:I=xg;break;case xg:break;default:throw new Error("impossible state")}break;case yg:I===xg&&this.fail('the string "]]>" is disallowed in char data.'),I=vg;break;case B:void 0!==A&&(this.text+=`${C.slice(g,this.prevI)}\n`),g=this.i,I=vg;break;case u:void 0!==A&&(this.text+=C.slice(g));break g;default:I=vg}this.forbiddenState=I}handleTextOutsideRoot(){let{i:g}=this;const{chunk:I,textHandler:C}=this;let A=!1;g:for(;;){const i=this.getCode();switch(i){case pg:if(this.state=f,void 0!==C){const{text:A}=this,i=I.slice(g,this.prevI);0!==A.length?(C(A+i),this.text=""):0!==i.length&&C(i)}break g;case Gg:this.state=S,this.entityReturnState=J,void 0!==C&&(this.text+=I.slice(g,this.prevI)),A=!0;break g;case B:void 0!==C&&(this.text+=`${I.slice(g,this.prevI)}\n`),g=this.i;break;case u:void 0!==C&&(this.text+=I.slice(g));break g;default:l(i)||(A=!0)}}A&&(this.sawRoot||this.reportedTextBeforeRoot||(this.fail("text data outside of root node."),this.reportedTextBeforeRoot=!0),this.closedRoot&&!this.reportedTextAfterRoot&&(this.fail("text data outside of root node."),this.reportedTextAfterRoot=!0))}pushAttribNS(g,I){var C;const{prefix:A,local:i}=this.qname(g),e={name:g,prefix:A,local:i,value:I};if(this.attribList.push(e),null===(C=this.attributeHandler)||void 0===C||C.call(this,e),"xmlns"===A){const g=I.trim();"1.0"===this.currentXMLVersion&&""===g&&this.fail("invalid attempt to undefine prefix in XML 1.0"),this.topNS[i]=g,kg(this,i,g)}else if("xmlns"===g){const g=I.trim();this.topNS[""]=g,kg(this,"",g)}}pushAttribPlain(g,I){var C;const A={name:g,value:I};this.attribList.push(A),null===(C=this.attributeHandler)||void 0===C||C.call(this,A)}end(){var g,I;this.sawRoot||this.fail("document must contain a root element.");const{tags:C}=this;for(;C.length>0;){const g=C.pop();this.fail(`unclosed tag: ${g.name}`)}this.state!==w&&this.state!==J&&this.fail("unexpected end.");const{text:A}=this;return 0!==A.length&&(null===(g=this.textHandler)||void 0===g||g.call(this,A),this.text=""),this._closed=!0,null===(I=this.endHandler)||void 0===I||I.call(this),this._init(),this}resolve(g){var I,C;let A=this.topNS[g];if(void 0!==A)return A;const{tags:i}=this;for(let e=i.length-1;e>=0;e--)if(A=i[e].ns[g],void 0!==A)return A;return A=this.ns[g],void 0!==A?A:null===(C=(I=this.opt).resolvePrefix)||void 0===C?void 0:C.call(I,g)}qname(g){const I=g.indexOf(":");if(-1===I)return{prefix:"",local:g};const C=g.slice(I+1),A=g.slice(0,I);return(""===A||""===C||C.includes(":"))&&this.fail(`malformed name: ${g}.`),{prefix:A,local:C}}processAttribsNS(){var g;const{attribList:I}=this,C=this.tag;{const{prefix:I,local:A}=this.qname(C.name);C.prefix=I,C.local=A;const i=C.uri=null!==(g=this.resolve(I))&&void 0!==g?g:"";""!==I&&("xmlns"===I&&this.fail('tags may not have "xmlns" as prefix.'),""===i&&(this.fail(`unbound namespace prefix: ${JSON.stringify(I)}.`),C.uri=I))}if(0===I.length)return;const{attributes:A}=C,i=new Set;for(const e of I){const{name:g,prefix:I,local:C}=e;let l,t;""===I?(l="xmlns"===g?m:"",t=g):(l=this.resolve(I),void 0===l&&(this.fail(`unbound namespace prefix: ${JSON.stringify(I)}.`),l=I),t=`{${l}}${C}`),i.has(t)&&this.fail(`duplicate attribute: ${t}.`),i.add(t),e.uri=l,A[g]=e}this.attribList=[]}processAttribsPlain(){const{attribList:g}=this,I=this.tag.attributes;for(const{name:C,value:A}of g)void 0!==I[C]&&this.fail(`duplicate attribute: ${C}.`),I[C]=A;this.attribList=[]}openTag(){var g;this.processAttribs();const{tags:I}=this,C=this.tag;C.isSelfClosing=!1,null===(g=this.openTagHandler)||void 0===g||g.call(this,C),I.push(C),this.state=J,this.name=""}openSelfClosingTag(){var g,I,C;this.processAttribs();const{tags:A}=this,i=this.tag;i.isSelfClosing=!0,null===(g=this.openTagHandler)||void 0===g||g.call(this,i),null===(I=this.closeTagHandler)||void 0===I||I.call(this,i),null===(this.tag=null!==(C=A[A.length-1])&&void 0!==C?C:null)&&(this.closedRoot=!0),this.state=J,this.name=""}closeTag(){const{tags:g,name:I}=this;if(this.state=J,this.name="",""===I)return this.fail("weird empty close tag."),void(this.text+="");const C=this.closeTagHandler;let A=g.length;for(;A-- >0;){const A=this.tag=g.pop();if(this.topNS=A.ns,null==C||C(A),A.name===I)break;this.fail("unexpected close tag.")}0===A?this.closedRoot=!0:A<0&&(this.fail(`unmatched closing tag: ${I}.`),this.text+=``)}parseEntity(g){if("#"!==g[0]){const I=this.ENTITIES[g];return void 0!==I?I:(this.fail(this.isName(g)?"undefined entity.":"disallowed character in entity name."),`&${g};`)}let I=NaN;return"x"===g[1]&&/^#x[0-9a-f]+$/i.test(g)?I=parseInt(g.slice(2),16):/^#[0-9]+$/.test(g)&&(I=parseInt(g.slice(1),10)),this.isChar(I)?String.fromCodePoint(I):(this.fail("malformed character entity."),`&${g};`)}}C.SaxesParser=Qg},{"xmlchars/xml/1.0/ed5":543,"xmlchars/xml/1.1/ed2":544,"xmlchars/xmlns/1.0/ed3":545}],497:[function(g,I,C){var A=g("safe-buffer").Buffer;function i(g,I){this._block=A.alloc(g),this._finalSize=I,this._blockSize=g,this._len=0}i.prototype.update=function(g,I){"string"==typeof g&&(I=I||"utf8",g=A.from(g,I));for(var C=this._block,i=this._blockSize,e=g.length,l=this._len,t=0;t=this._finalSize&&(this._update(this._block),this._block.fill(0));var C=8*this._len;if(C<=4294967295)this._block.writeUInt32BE(C,this._blockSize-4);else{var A=(4294967295&C)>>>0,i=(C-A)/4294967296;this._block.writeUInt32BE(i,this._blockSize-8),this._block.writeUInt32BE(A,this._blockSize-4)}this._update(this._block);var e=this._hash();return g?e.toString(g):e},i.prototype._update=function(){throw new Error("_update must be implemented by subclass")},I.exports=i},{"safe-buffer":494}],498:[function(g,I,C){var A=I.exports=function(g){g=g.toLowerCase();var I=A[g];if(!I)throw new Error(g+" is not supported (we accept pull requests)");return new I};A.sha=g("./sha"),A.sha1=g("./sha1"),A.sha224=g("./sha224"),A.sha256=g("./sha256"),A.sha384=g("./sha384"),A.sha512=g("./sha512")},{"./sha":499,"./sha1":500,"./sha224":501,"./sha256":502,"./sha384":503,"./sha512":504}],499:[function(g,I,C){var A=g("inherits"),i=g("./hash"),e=g("safe-buffer").Buffer,l=[1518500249,1859775393,-1894007588,-899497514],t=new Array(80);function s(){this.init(),this._w=t,i.call(this,64,56)}function c(g){return g<<5|g>>>27}function d(g){return g<<30|g>>>2}function o(g,I,C,A){return 0===g?I&C|~I&A:2===g?I&C|I&A|C&A:I^C^A}A(s,i),s.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},s.prototype._update=function(g){for(var I=this._w,C=0|this._a,A=0|this._b,i=0|this._c,e=0|this._d,t=0|this._e,s=0;s<16;++s)I[s]=g.readInt32BE(4*s);for(;s<80;++s)I[s]=I[s-3]^I[s-8]^I[s-14]^I[s-16];for(var n=0;n<80;++n){var a=~~(n/20),Z=c(C)+o(a,A,i,e)+t+I[n]+l[a]|0;t=e,e=i,i=d(A),A=C,C=Z}this._a=C+this._a|0,this._b=A+this._b|0,this._c=i+this._c|0,this._d=e+this._d|0,this._e=t+this._e|0},s.prototype._hash=function(){var g=e.allocUnsafe(20);return g.writeInt32BE(0|this._a,0),g.writeInt32BE(0|this._b,4),g.writeInt32BE(0|this._c,8),g.writeInt32BE(0|this._d,12),g.writeInt32BE(0|this._e,16),g},I.exports=s},{"./hash":497,inherits:440,"safe-buffer":494}],500:[function(g,I,C){var A=g("inherits"),i=g("./hash"),e=g("safe-buffer").Buffer,l=[1518500249,1859775393,-1894007588,-899497514],t=new Array(80);function s(){this.init(),this._w=t,i.call(this,64,56)}function c(g){return g<<1|g>>>31}function d(g){return g<<5|g>>>27}function o(g){return g<<30|g>>>2}function n(g,I,C,A){return 0===g?I&C|~I&A:2===g?I&C|I&A|C&A:I^C^A}A(s,i),s.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},s.prototype._update=function(g){for(var I=this._w,C=0|this._a,A=0|this._b,i=0|this._c,e=0|this._d,t=0|this._e,s=0;s<16;++s)I[s]=g.readInt32BE(4*s);for(;s<80;++s)I[s]=c(I[s-3]^I[s-8]^I[s-14]^I[s-16]);for(var a=0;a<80;++a){var Z=~~(a/20),b=d(C)+n(Z,A,i,e)+t+I[a]+l[Z]|0;t=e,e=i,i=o(A),A=C,C=b}this._a=C+this._a|0,this._b=A+this._b|0,this._c=i+this._c|0,this._d=e+this._d|0,this._e=t+this._e|0},s.prototype._hash=function(){var g=e.allocUnsafe(20);return g.writeInt32BE(0|this._a,0),g.writeInt32BE(0|this._b,4),g.writeInt32BE(0|this._c,8),g.writeInt32BE(0|this._d,12),g.writeInt32BE(0|this._e,16),g},I.exports=s},{"./hash":497,inherits:440,"safe-buffer":494}],501:[function(g,I,C){var A=g("inherits"),i=g("./sha256"),e=g("./hash"),l=g("safe-buffer").Buffer,t=new Array(64);function s(){this.init(),this._w=t,e.call(this,64,56)}A(s,i),s.prototype.init=function(){return this._a=3238371032,this._b=914150663,this._c=812702999,this._d=4144912697,this._e=4290775857,this._f=1750603025,this._g=1694076839,this._h=3204075428,this},s.prototype._hash=function(){var g=l.allocUnsafe(28);return g.writeInt32BE(this._a,0),g.writeInt32BE(this._b,4),g.writeInt32BE(this._c,8),g.writeInt32BE(this._d,12),g.writeInt32BE(this._e,16),g.writeInt32BE(this._f,20),g.writeInt32BE(this._g,24),g},I.exports=s},{"./hash":497,"./sha256":502,inherits:440,"safe-buffer":494}],502:[function(g,I,C){var A=g("inherits"),i=g("./hash"),e=g("safe-buffer").Buffer,l=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],t=new Array(64);function s(){this.init(),this._w=t,i.call(this,64,56)}function c(g,I,C){return C^g&(I^C)}function d(g,I,C){return g&I|C&(g|I)}function o(g){return(g>>>2|g<<30)^(g>>>13|g<<19)^(g>>>22|g<<10)}function n(g){return(g>>>6|g<<26)^(g>>>11|g<<21)^(g>>>25|g<<7)}function a(g){return(g>>>7|g<<25)^(g>>>18|g<<14)^g>>>3}function Z(g){return(g>>>17|g<<15)^(g>>>19|g<<13)^g>>>10}A(s,i),s.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this},s.prototype._update=function(g){for(var I=this._w,C=0|this._a,A=0|this._b,i=0|this._c,e=0|this._d,t=0|this._e,s=0|this._f,b=0|this._g,r=0|this._h,m=0;m<16;++m)I[m]=g.readInt32BE(4*m);for(;m<64;++m)I[m]=Z(I[m-2])+I[m-7]+a(I[m-15])+I[m-16]|0;for(var h=0;h<64;++h){var G=r+n(t)+c(t,s,b)+l[h]+I[h]|0,u=o(C)+d(C,A,i)|0;r=b,b=s,s=t,t=e+G|0,e=i,i=A,A=C,C=G+u|0}this._a=C+this._a|0,this._b=A+this._b|0,this._c=i+this._c|0,this._d=e+this._d|0,this._e=t+this._e|0,this._f=s+this._f|0,this._g=b+this._g|0,this._h=r+this._h|0},s.prototype._hash=function(){var g=e.allocUnsafe(32);return g.writeInt32BE(this._a,0),g.writeInt32BE(this._b,4),g.writeInt32BE(this._c,8),g.writeInt32BE(this._d,12),g.writeInt32BE(this._e,16),g.writeInt32BE(this._f,20),g.writeInt32BE(this._g,24),g.writeInt32BE(this._h,28),g},I.exports=s},{"./hash":497,inherits:440,"safe-buffer":494}],503:[function(g,I,C){var A=g("inherits"),i=g("./sha512"),e=g("./hash"),l=g("safe-buffer").Buffer,t=new Array(160);function s(){this.init(),this._w=t,e.call(this,128,112)}A(s,i),s.prototype.init=function(){return this._ah=3418070365,this._bh=1654270250,this._ch=2438529370,this._dh=355462360,this._eh=1731405415,this._fh=2394180231,this._gh=3675008525,this._hh=1203062813,this._al=3238371032,this._bl=914150663,this._cl=812702999,this._dl=4144912697,this._el=4290775857,this._fl=1750603025,this._gl=1694076839,this._hl=3204075428,this},s.prototype._hash=function(){var g=l.allocUnsafe(48);function I(I,C,A){g.writeInt32BE(I,A),g.writeInt32BE(C,A+4)}return I(this._ah,this._al,0),I(this._bh,this._bl,8),I(this._ch,this._cl,16),I(this._dh,this._dl,24),I(this._eh,this._el,32),I(this._fh,this._fl,40),g},I.exports=s},{"./hash":497,"./sha512":504,inherits:440,"safe-buffer":494}],504:[function(g,I,C){var A=g("inherits"),i=g("./hash"),e=g("safe-buffer").Buffer,l=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],t=new Array(160);function s(){this.init(),this._w=t,i.call(this,128,112)}function c(g,I,C){return C^g&(I^C)}function d(g,I,C){return g&I|C&(g|I)}function o(g,I){return(g>>>28|I<<4)^(I>>>2|g<<30)^(I>>>7|g<<25)}function n(g,I){return(g>>>14|I<<18)^(g>>>18|I<<14)^(I>>>9|g<<23)}function a(g,I){return(g>>>1|I<<31)^(g>>>8|I<<24)^g>>>7}function Z(g,I){return(g>>>1|I<<31)^(g>>>8|I<<24)^(g>>>7|I<<25)}function b(g,I){return(g>>>19|I<<13)^(I>>>29|g<<3)^g>>>6}function r(g,I){return(g>>>19|I<<13)^(I>>>29|g<<3)^(g>>>6|I<<26)}function m(g,I){return g>>>0>>0?1:0}A(s,i),s.prototype.init=function(){return this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this},s.prototype._update=function(g){for(var I=this._w,C=0|this._ah,A=0|this._bh,i=0|this._ch,e=0|this._dh,t=0|this._eh,s=0|this._fh,h=0|this._gh,G=0|this._hh,u=0|this._al,B=0|this._bl,w=0|this._cl,W=0|this._dl,p=0|this._el,V=0|this._fl,y=0|this._gl,X=0|this._hl,Y=0;Y<32;Y+=2)I[Y]=g.readInt32BE(4*Y),I[Y+1]=g.readInt32BE(4*Y+4);for(;Y<160;Y+=2){var R=I[Y-30],N=I[Y-30+1],H=a(R,N),K=Z(N,R),F=b(R=I[Y-4],N=I[Y-4+1]),M=r(N,R),J=I[Y-14],S=I[Y-14+1],f=I[Y-32],k=I[Y-32+1],D=K+S|0,L=H+J+m(D,K)|0;L=(L=L+F+m(D=D+M|0,M)|0)+f+m(D=D+k|0,k)|0,I[Y]=L,I[Y+1]=D}for(var z=0;z<160;z+=2){L=I[z],D=I[z+1];var v=d(C,A,i),T=d(u,B,w),x=o(C,u),U=o(u,C),Q=n(t,p),j=n(p,t),O=l[z],E=l[z+1],P=c(t,s,h),_=c(p,V,y),q=X+j|0,$=G+Q+m(q,X)|0;$=($=($=$+P+m(q=q+_|0,_)|0)+O+m(q=q+E|0,E)|0)+L+m(q=q+D|0,D)|0;var gg=U+T|0,Ig=x+v+m(gg,U)|0;G=h,X=y,h=s,y=V,s=t,V=p,t=e+$+m(p=W+q|0,W)|0,e=i,W=w,i=A,w=B,A=C,B=u,C=$+Ig+m(u=q+gg|0,q)|0}this._al=this._al+u|0,this._bl=this._bl+B|0,this._cl=this._cl+w|0,this._dl=this._dl+W|0,this._el=this._el+p|0,this._fl=this._fl+V|0,this._gl=this._gl+y|0,this._hl=this._hl+X|0,this._ah=this._ah+C+m(this._al,u)|0,this._bh=this._bh+A+m(this._bl,B)|0,this._ch=this._ch+i+m(this._cl,w)|0,this._dh=this._dh+e+m(this._dl,W)|0,this._eh=this._eh+t+m(this._el,p)|0,this._fh=this._fh+s+m(this._fl,V)|0,this._gh=this._gh+h+m(this._gl,y)|0,this._hh=this._hh+G+m(this._hl,X)|0},s.prototype._hash=function(){var g=e.allocUnsafe(64);function I(I,C,A){g.writeInt32BE(I,A),g.writeInt32BE(C,A+4)}return I(this._ah,this._al,0),I(this._bh,this._bl,8),I(this._ch,this._cl,16),I(this._dh,this._dl,24),I(this._eh,this._el,32),I(this._fh,this._fl,40),I(this._gh,this._gl,48),I(this._hh,this._hl,56),g},I.exports=s},{"./hash":497,inherits:440,"safe-buffer":494}],505:[function(g,I,C){I.exports=i;var A=g("events").EventEmitter;function i(){A.call(this)}g("inherits")(i,A),i.Readable=g("readable-stream/readable.js"),i.Writable=g("readable-stream/writable.js"),i.Duplex=g("readable-stream/duplex.js"),i.Transform=g("readable-stream/transform.js"),i.PassThrough=g("readable-stream/passthrough.js"),i.Stream=i,i.prototype.pipe=function(g,I){var C=this;function i(I){g.writable&&!1===g.write(I)&&C.pause&&C.pause()}function e(){C.readable&&C.resume&&C.resume()}C.on("data",i),g.on("drain",e),g._isStdio||I&&!1===I.end||(C.on("end",t),C.on("close",s));var l=!1;function t(){l||(l=!0,g.end())}function s(){l||(l=!0,"function"==typeof g.destroy&&g.destroy())}function c(g){if(d(),0===A.listenerCount(this,"error"))throw g}function d(){C.removeListener("data",i),g.removeListener("drain",e),C.removeListener("end",t),C.removeListener("close",s),C.removeListener("error",c),g.removeListener("error",c),C.removeListener("end",d),C.removeListener("close",d),g.removeListener("close",d)}return C.on("error",c),g.on("error",c),C.on("end",d),C.on("close",d),g.on("close",d),g.emit("pipe",C),g}},{events:422,inherits:440,"readable-stream/duplex.js":507,"readable-stream/passthrough.js":516,"readable-stream/readable.js":517,"readable-stream/transform.js":518,"readable-stream/writable.js":519}],506:[function(g,I,C){var A={}.toString;I.exports=Array.isArray||function(g){return"[object Array]"==A.call(g)}},{}],507:[function(g,I,C){I.exports=g("./lib/_stream_duplex.js")},{"./lib/_stream_duplex.js":508}],508:[function(g,I,C){var A=g("process-nextick-args"),i=Object.keys||function(g){var I=[];for(var C in g)I.push(C);return I};I.exports=o;var e=Object.create(g("core-util-is"));e.inherits=g("inherits");var l=g("./_stream_readable"),t=g("./_stream_writable");e.inherits(o,l);for(var s=i(t.prototype),c=0;c0?("string"==typeof I||l.objectMode||Object.getPrototypeOf(I)===c.prototype||(I=o(I)),A?l.endEmitted?g.emit("error",new Error("stream.unshift() after end event")):p(g,l,I,!0):l.ended?g.emit("error",new Error("stream.push() after EOF")):(l.reading=!1,l.decoder&&!C?(I=l.decoder.write(I),l.objectMode||0!==I.length?p(g,l,I,!1):F(g,l)):p(g,l,I,!1))):A||(l.reading=!1)),y(l)}function p(g,I,C,A){I.flowing&&0===I.length&&!I.sync?(g.emit("data",C),g.read(0)):(I.length+=I.objectMode?1:C.length,A?I.buffer.unshift(C):I.buffer.push(C),I.needReadable&&H(g)),F(g,I)}function V(g,I){var C;return n(I)||"string"==typeof I||void 0===I||g.objectMode||(C=new TypeError("Invalid non-string/buffer chunk")),C}function y(g){return!g.ended&&(g.needReadable||g.length=X?g=X:(g--,g|=g>>>1,g|=g>>>2,g|=g>>>4,g|=g>>>8,g|=g>>>16,g++),g}function R(g,I){return g<=0||0===I.length&&I.ended?0:I.objectMode?1:g!=g?I.flowing&&I.length?I.buffer.head.data.length:I.length:(g>I.highWaterMark&&(I.highWaterMark=Y(g)),g<=I.length?g:I.ended?I.length:(I.needReadable=!0,0))}function N(g,I){if(!I.ended){if(I.decoder){var C=I.decoder.end();C&&C.length&&(I.buffer.push(C),I.length+=I.objectMode?1:C.length)}I.ended=!0,H(g)}}function H(g){var I=g._readableState;I.needReadable=!1,I.emittedReadable||(b("emitReadable",I.flowing),I.emittedReadable=!0,I.sync?i.nextTick(K,g):K(g))}function K(g){b("emit readable"),g.emit("readable"),D(g)}function F(g,I){I.readingMore||(I.readingMore=!0,i.nextTick(M,g,I))}function M(g,I){for(var C=I.length;!I.reading&&!I.flowing&&!I.ended&&I.length=I.length?(C=I.decoder?I.buffer.join(""):1===I.buffer.length?I.buffer.head.data:I.buffer.concat(I.length),I.buffer.clear()):C=z(g,I.buffer,I.decoder),C);var C}function z(g,I,C){var A;return ge.length?e.length:g;if(l===e.length?i+=e:i+=e.slice(0,g),0==(g-=l)){l===e.length?(++A,C.next?I.head=C.next:I.head=I.tail=null):(I.head=C,C.data=e.slice(l));break}++A}return I.length-=A,i}function T(g,I){var C=c.allocUnsafe(g),A=I.head,i=1;for(A.data.copy(C),g-=A.data.length;A=A.next;){var e=A.data,l=g>e.length?e.length:g;if(e.copy(C,C.length-g,0,l),0==(g-=l)){l===e.length?(++i,A.next?I.head=A.next:I.head=I.tail=null):(I.head=A,A.data=e.slice(l));break}++i}return I.length-=i,C}function x(g){var I=g._readableState;if(I.length>0)throw new Error('"endReadable()" called on non-empty stream');I.endEmitted||(I.ended=!0,i.nextTick(U,I,g))}function U(g,I){g.endEmitted||0!==g.length||(g.endEmitted=!0,I.readable=!1,I.emit("end"))}function Q(g,I){for(var C=0,A=g.length;C=I.highWaterMark||I.ended))return b("read: emitReadable",I.length,I.ended),0===I.length&&I.ended?x(this):H(this),null;if(0===(g=R(g,I))&&I.ended)return 0===I.length&&x(this),null;var A,i=I.needReadable;return b("need readable",i),(0===I.length||I.length-g0?L(g,I):null)?(I.needReadable=!0,g=0):I.length-=g,0===I.length&&(I.ended||(I.needReadable=!0),C!==g&&I.ended&&x(this)),null!==A&&this.emit("data",A),A},w.prototype._read=function(g){this.emit("error",new Error("_read() is not implemented"))},w.prototype.pipe=function(g,I){var A=this,e=this._readableState;switch(e.pipesCount){case 0:e.pipes=g;break;case 1:e.pipes=[e.pipes,g];break;default:e.pipes.push(g)}e.pipesCount+=1,b("pipe count=%d opts=%j",e.pipesCount,I);var l=I&&!1===I.end||g===C.stdout||g===C.stderr?G:c;function s(g,I){b("onunpipe"),g===A&&I&&!1===I.hasUnpiped&&(I.hasUnpiped=!0,n())}function c(){b("onend"),g.end()}e.endEmitted?i.nextTick(l):A.once("end",l),g.on("unpipe",s);var d=J(A);g.on("drain",d);var o=!1;function n(){b("cleanup"),g.removeListener("close",m),g.removeListener("finish",h),g.removeListener("drain",d),g.removeListener("error",r),g.removeListener("unpipe",s),A.removeListener("end",c),A.removeListener("end",G),A.removeListener("data",Z),o=!0,!e.awaitDrain||g._writableState&&!g._writableState.needDrain||d()}var a=!1;function Z(I){b("ondata"),a=!1,!1!==g.write(I)||a||((1===e.pipesCount&&e.pipes===g||e.pipesCount>1&&-1!==Q(e.pipes,g))&&!o&&(b("false write response, pause",e.awaitDrain),e.awaitDrain++,a=!0),A.pause())}function r(I){b("onerror",I),G(),g.removeListener("error",r),0===t(g,"error")&&g.emit("error",I)}function m(){g.removeListener("finish",h),G()}function h(){b("onfinish"),g.removeListener("close",m),G()}function G(){b("unpipe"),A.unpipe(g)}return A.on("data",Z),u(g,"error",r),g.once("close",m),g.once("finish",h),g.emit("pipe",A),e.flowing||(b("pipe resume"),A.resume()),g},w.prototype.unpipe=function(g){var I=this._readableState,C={hasUnpiped:!1};if(0===I.pipesCount)return this;if(1===I.pipesCount)return g&&g!==I.pipes||(g||(g=I.pipes),I.pipes=null,I.pipesCount=0,I.flowing=!1,g&&g.emit("unpipe",this,C)),this;if(!g){var A=I.pipes,i=I.pipesCount;I.pipes=null,I.pipesCount=0,I.flowing=!1;for(var e=0;e-1?i:e.nextTick;u.WritableState=G;var c=Object.create(g("core-util-is"));c.inherits=g("inherits");var d={deprecate:g("util-deprecate")},o=g("./internal/streams/stream"),n=g("safe-buffer").Buffer,a=(void 0!==A?A:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{}).Uint8Array||function(){};function Z(g){return n.from(g)}function b(g){return n.isBuffer(g)||g instanceof a}var r,m=g("./internal/streams/destroy");function h(){}function G(I,C){t=t||g("./_stream_duplex"),I=I||{};var A=C instanceof t;this.objectMode=!!I.objectMode,A&&(this.objectMode=this.objectMode||!!I.writableObjectMode);var i=I.highWaterMark,e=I.writableHighWaterMark,s=this.objectMode?16:16384;this.highWaterMark=i||0===i?i:A&&(e||0===e)?e:s,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var c=!1===I.decodeStrings;this.decodeStrings=!c,this.defaultEncoding=I.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(g){Y(C,g)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new l(this)}function u(I){if(t=t||g("./_stream_duplex"),!(r.call(u,this)||this instanceof t))return new u(I);this._writableState=new G(I,this),this.writable=!0,I&&("function"==typeof I.write&&(this._write=I.write),"function"==typeof I.writev&&(this._writev=I.writev),"function"==typeof I.destroy&&(this._destroy=I.destroy),"function"==typeof I.final&&(this._final=I.final)),o.call(this)}function B(g,I){var C=new Error("write after end");g.emit("error",C),e.nextTick(I,C)}function w(g,I,C,A){var i=!0,l=!1;return null===C?l=new TypeError("May not write null values to stream"):"string"==typeof C||void 0===C||I.objectMode||(l=new TypeError("Invalid non-string/buffer chunk")),l&&(g.emit("error",l),e.nextTick(A,l),i=!1),i}function W(g,I,C){return g.objectMode||!1===g.decodeStrings||"string"!=typeof I||(I=n.from(I,C)),I}function p(g,I,C,A,i,e){if(!C){var l=W(I,A,i);A!==l&&(C=!0,i="buffer",A=l)}var t=I.objectMode?1:A.length;I.length+=t;var s=I.length-1))throw new TypeError("Unknown encoding: "+g);return this._writableState.defaultEncoding=g,this},Object.defineProperty(u.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),u.prototype._write=function(g,I,C){C(new Error("_write() is not implemented"))},u.prototype._writev=null,u.prototype.end=function(g,I,C){var A=this._writableState;"function"==typeof g?(C=g,g=null,I=null):"function"==typeof I&&(C=I,I=null),null!=g&&this.write(g,I),A.corked&&(A.corked=1,this.uncork()),A.ending||S(this,A,C)},Object.defineProperty(u.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(g){this._writableState&&(this._writableState.destroyed=g)}}),u.prototype.destroy=m.destroy,u.prototype._undestroy=m.undestroy,u.prototype._destroy=function(g,I){this.end(),I(g)}}).call(this)}).call(this,g("_process"),void 0!==EI?EI:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},g("timers").setImmediate)},{"./_stream_duplex":508,"./internal/streams/destroy":514,"./internal/streams/stream":515,_process:467,"core-util-is":383,inherits:440,"process-nextick-args":466,"safe-buffer":520,timers:523,"util-deprecate":524}],513:[function(g,I,C){function A(g,I){if(!(g instanceof I))throw new TypeError("Cannot call a class as a function")}var i=g("safe-buffer").Buffer,e=g("util");function l(g,I,C){g.copy(I,C)}I.exports=function(){function g(){A(this,g),this.head=null,this.tail=null,this.length=0}return g.prototype.push=function(g){var I={data:g,next:null};this.length>0?this.tail.next=I:this.head=I,this.tail=I,++this.length},g.prototype.unshift=function(g){var I={data:g,next:this.head};0===this.length&&(this.tail=I),this.head=I,++this.length},g.prototype.shift=function(){if(0!==this.length){var g=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,g}},g.prototype.clear=function(){this.head=this.tail=null,this.length=0},g.prototype.join=function(g){if(0===this.length)return"";for(var I=this.head,C=""+I.data;I=I.next;)C+=g+I.data;return C},g.prototype.concat=function(g){if(0===this.length)return i.alloc(0);for(var I=i.allocUnsafe(g>>>0),C=this.head,A=0;C;)l(C.data,I,A),A+=C.data.length,C=C.next;return I},g}(),e&&e.inspect&&e.inspect.custom&&(I.exports.prototype[e.inspect.custom]=function(){var g=e.inspect({length:this.length});return this.constructor.name+" "+g})},{"safe-buffer":520,util:188}],514:[function(g,I,C){var A=g("process-nextick-args");function i(g,I){var C=this,i=this._readableState&&this._readableState.destroyed,e=this._writableState&&this._writableState.destroyed;return i||e?(I?I(g):g&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,A.nextTick(l,this,g)):A.nextTick(l,this,g)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(g||null,(function(g){!I&&g?C._writableState?C._writableState.errorEmitted||(C._writableState.errorEmitted=!0,A.nextTick(l,C,g)):A.nextTick(l,C,g):I&&I(g)})),this)}function e(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}function l(g,I){g.emit("error",I)}I.exports={destroy:i,undestroy:e}},{"process-nextick-args":466}],515:[function(g,I,C){arguments[4][490][0].apply(C,arguments)},{dup:490,events:422}],516:[function(g,I,C){I.exports=g("./readable").PassThrough},{"./readable":517}],517:[function(g,I,C){(C=I.exports=g("./lib/_stream_readable.js")).Stream=C,C.Readable=C,C.Writable=g("./lib/_stream_writable.js"),C.Duplex=g("./lib/_stream_duplex.js"),C.Transform=g("./lib/_stream_transform.js"),C.PassThrough=g("./lib/_stream_passthrough.js")},{"./lib/_stream_duplex.js":508,"./lib/_stream_passthrough.js":509,"./lib/_stream_readable.js":510,"./lib/_stream_transform.js":511,"./lib/_stream_writable.js":512}],518:[function(g,I,C){I.exports=g("./readable").Transform},{"./readable":517}],519:[function(g,I,C){I.exports=g("./lib/_stream_writable.js")},{"./lib/_stream_writable.js":512}],520:[function(g,I,C){arguments[4][217][0].apply(C,arguments)},{buffer:220,dup:217}],521:[function(g,I,C){arguments[4][218][0].apply(C,arguments)},{dup:218,"safe-buffer":520}],522:[function(g,I,C){arguments[4][218][0].apply(C,arguments)},{dup:218,"safe-buffer":494}],523:[function(g,I,C){(function(I,A){(function(){var i=g("process/browser.js").nextTick,e=Function.prototype.apply,l=Array.prototype.slice,t={},s=0;function c(g,I){this._id=g,this._clearFn=I}C.setTimeout=function(){return new c(e.call(setTimeout,window,arguments),clearTimeout)},C.setInterval=function(){return new c(e.call(setInterval,window,arguments),clearInterval)},C.clearTimeout=C.clearInterval=function(g){g.close()},c.prototype.unref=c.prototype.ref=function(){},c.prototype.close=function(){this._clearFn.call(window,this._id)},C.enroll=function(g,I){clearTimeout(g._idleTimeoutId),g._idleTimeout=I},C.unenroll=function(g){clearTimeout(g._idleTimeoutId),g._idleTimeout=-1},C._unrefActive=C.active=function(g){clearTimeout(g._idleTimeoutId);var I=g._idleTimeout;I>=0&&(g._idleTimeoutId=setTimeout((function(){g._onTimeout&&g._onTimeout()}),I))},C.setImmediate="function"==typeof I?I:function(g){var I=s++,A=!(arguments.length<2)&&l.call(arguments,1);return t[I]=!0,i((function(){t[I]&&(A?g.apply(null,A):g.call(null),C.clearImmediate(I))})),I},C.clearImmediate="function"==typeof A?A:function(g){delete t[g]}}).call(this)}).call(this,g("timers").setImmediate,g("timers").clearImmediate)},{"process/browser.js":467,timers:523}],524:[function(g,I,C){(function(g){(function(){function C(g,I){if(A("noDeprecation"))return g;var C=!1;function i(){if(!C){if(A("throwDeprecation"))throw new Error(I);A("traceDeprecation")?console.trace(I):console.warn(I),C=!0}return g.apply(this,arguments)}return i}function A(I){try{if(!g.localStorage)return!1}catch(A){return!1}var C=g.localStorage[I];return null!=C&&"true"===String(C).toLowerCase()}I.exports=C}).call(this)}).call(this,void 0!==EI?EI:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],525:[function(g,I,C){"function"==typeof Object.create?I.exports=function(g,I){g.super_=I,g.prototype=Object.create(I.prototype,{constructor:{value:g,enumerable:!1,writable:!0,configurable:!0}})}:I.exports=function(g,I){g.super_=I;var C=function(){};C.prototype=I.prototype,g.prototype=new C,g.prototype.constructor=g}},{}],526:[function(g,I,C){I.exports=function(g){return g&&"object"==typeof g&&"function"==typeof g.copy&&"function"==typeof g.fill&&"function"==typeof g.readUInt8}},{}],527:[function(g,I,C){(function(I,A){(function(){var i=/%[sdj%]/g;C.format=function(g){if(!w(g)){for(var I=[],C=0;C=e)return g;switch(g){case"%s":return String(A[C++]);case"%d":return Number(A[C++]);case"%j":try{return JSON.stringify(A[C++])}catch(I){return"[Circular]"}default:return g}})),s=A[C];C=3&&(A.depth=arguments[2]),arguments.length>=4&&(A.colors=arguments[3]),h(I)?A.showHidden=I:I&&C._extend(A,I),p(A.showHidden)&&(A.showHidden=!1),p(A.depth)&&(A.depth=2),p(A.colors)&&(A.colors=!1),p(A.customInspect)&&(A.customInspect=!0),A.colors&&(A.stylize=s),o(A,g,A.depth)}function s(g,I){var C=t.styles[I];return C?"["+t.colors[C][0]+"m"+g+"["+t.colors[C][1]+"m":g}function c(g,I){return g}function d(g){var I={};return g.forEach((function(g,C){I[g]=!0})),I}function o(g,I,A){if(g.customInspect&&I&&R(I.inspect)&&I.inspect!==C.inspect&&(!I.constructor||I.constructor.prototype!==I)){var i=I.inspect(A,g);return w(i)||(i=o(g,i,A)),i}var e=n(g,I);if(e)return e;var l=Object.keys(I),t=d(l);if(g.showHidden&&(l=Object.getOwnPropertyNames(I)),Y(I)&&(l.indexOf("message")>=0||l.indexOf("description")>=0))return a(I);if(0===l.length){if(R(I)){var s=I.name?": "+I.name:"";return g.stylize("[Function"+s+"]","special")}if(V(I))return g.stylize(RegExp.prototype.toString.call(I),"regexp");if(X(I))return g.stylize(Date.prototype.toString.call(I),"date");if(Y(I))return a(I)}var c,h="",G=!1,u=["{","}"];return m(I)&&(G=!0,u=["[","]"]),R(I)&&(h=" [Function"+(I.name?": "+I.name:"")+"]"),V(I)&&(h=" "+RegExp.prototype.toString.call(I)),X(I)&&(h=" "+Date.prototype.toUTCString.call(I)),Y(I)&&(h=" "+a(I)),0!==l.length||G&&0!=I.length?A<0?V(I)?g.stylize(RegExp.prototype.toString.call(I),"regexp"):g.stylize("[Object]","special"):(g.seen.push(I),c=G?Z(g,I,A,t,l):l.map((function(C){return b(g,I,A,t,C,G)})),g.seen.pop(),r(c,h,u)):u[0]+h+u[1]}function n(g,I){if(p(I))return g.stylize("undefined","undefined");if(w(I)){var C="'"+JSON.stringify(I).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return g.stylize(C,"string")}return B(I)?g.stylize(""+I,"number"):h(I)?g.stylize(""+I,"boolean"):G(I)?g.stylize("null","null"):void 0}function a(g){return"["+Error.prototype.toString.call(g)+"]"}function Z(g,I,C,A,i){for(var e=[],l=0,t=I.length;l-1&&(t=e?t.split("\n").map((function(g){return" "+g})).join("\n").substr(2):"\n"+t.split("\n").map((function(g){return" "+g})).join("\n")):t=g.stylize("[Circular]","special")),p(l)){if(e&&i.match(/^\d+$/))return t;(l=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(l=l.substr(1,l.length-2),l=g.stylize(l,"name")):(l=l.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),l=g.stylize(l,"string"))}return l+": "+t}function r(g,I,C){return g.reduce((function(g,I){return I.indexOf("\n"),g+I.replace(/\u001b\[\d\d?m/g,"").length+1}),0)>60?C[0]+(""===I?"":I+"\n ")+" "+g.join(",\n ")+" "+C[1]:C[0]+I+" "+g.join(", ")+" "+C[1]}function m(g){return Array.isArray(g)}function h(g){return"boolean"==typeof g}function G(g){return null===g}function u(g){return null==g}function B(g){return"number"==typeof g}function w(g){return"string"==typeof g}function W(g){return"symbol"==typeof g}function p(g){return void 0===g}function V(g){return y(g)&&"[object RegExp]"===H(g)}function y(g){return"object"==typeof g&&null!==g}function X(g){return y(g)&&"[object Date]"===H(g)}function Y(g){return y(g)&&("[object Error]"===H(g)||g instanceof Error)}function R(g){return"function"==typeof g}function N(g){return null===g||"boolean"==typeof g||"number"==typeof g||"string"==typeof g||"symbol"==typeof g||void 0===g}function H(g){return Object.prototype.toString.call(g)}function K(g){return g<10?"0"+g.toString(10):g.toString(10)}C.debuglog=function(g){if(p(e)&&(e=I.env.NODE_DEBUG||""),g=g.toUpperCase(),!l[g])if(new RegExp("\\b"+g+"\\b","i").test(e)){var A=I.pid;l[g]=function(){var I=C.format.apply(C,arguments);console.error("%s %d: %s",g,A,I)}}else l[g]=function(){};return l[g]},C.inspect=t,t.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},t.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},C.isArray=m,C.isBoolean=h,C.isNull=G,C.isNullOrUndefined=u,C.isNumber=B,C.isString=w,C.isSymbol=W,C.isUndefined=p,C.isRegExp=V,C.isObject=y,C.isDate=X,C.isError=Y,C.isFunction=R,C.isPrimitive=N,C.isBuffer=g("./support/isBuffer");var F=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function M(){var g=new Date,I=[K(g.getHours()),K(g.getMinutes()),K(g.getSeconds())].join(":");return[g.getDate(),F[g.getMonth()],I].join(" ")}function J(g,I){return Object.prototype.hasOwnProperty.call(g,I)}C.log=function(){console.log("%s - %s",M(),C.format.apply(C,arguments))},C.inherits=g("inherits"),C._extend=function(g,I){if(!I||!y(I))return g;for(var C=Object.keys(I),A=C.length;A--;)g[C[A]]=I[C[A]];return g}}).call(this)}).call(this,g("_process"),void 0!==EI?EI:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./support/isBuffer":526,_process:467,inherits:525}],528:[function(g,I,C){Object.defineProperty(C,"__esModule",{value:!0}),Object.defineProperty(C,"v1",{enumerable:!0,get:function(){return A.default}}),Object.defineProperty(C,"v3",{enumerable:!0,get:function(){return i.default}}),Object.defineProperty(C,"v4",{enumerable:!0,get:function(){return e.default}}),Object.defineProperty(C,"v5",{enumerable:!0,get:function(){return l.default}}),Object.defineProperty(C,"NIL",{enumerable:!0,get:function(){return t.default}}),Object.defineProperty(C,"version",{enumerable:!0,get:function(){return s.default}}),Object.defineProperty(C,"validate",{enumerable:!0,get:function(){return c.default}}),Object.defineProperty(C,"stringify",{enumerable:!0,get:function(){return d.default}}),Object.defineProperty(C,"parse",{enumerable:!0,get:function(){return o.default}});var A=n(g("./v1.js")),i=n(g("./v3.js")),e=n(g("./v4.js")),l=n(g("./v5.js")),t=n(g("./nil.js")),s=n(g("./version.js")),c=n(g("./validate.js")),d=n(g("./stringify.js")),o=n(g("./parse.js"));function n(g){return g&&g.__esModule?g:{default:g}}},{"./nil.js":530,"./parse.js":531,"./stringify.js":535,"./v1.js":536,"./v3.js":537,"./v4.js":539,"./v5.js":540,"./validate.js":541,"./version.js":542}],529:[function(g,I,C){function A(g){if("string"==typeof g){const I=unescape(encodeURIComponent(g));g=new Uint8Array(I.length);for(let C=0;C>5]>>>i%32&255,e=parseInt(A.charAt(C>>>4&15)+A.charAt(15&C),16);I.push(e)}return I}function e(g){return 14+(g+64>>>9<<4)+1}function l(g,I){g[I>>5]|=128<>5]|=(255&g[A/8])<>16)+(I>>16)+(C>>16)<<16|65535&C}function c(g,I){return g<>>32-I}function d(g,I,C,A,i,e){return s(c(s(s(I,g),s(A,e)),i),C)}function o(g,I,C,A,i,e,l){return d(I&C|~I&A,g,I,i,e,l)}function n(g,I,C,A,i,e,l){return d(I&A|C&~A,g,I,i,e,l)}function a(g,I,C,A,i,e,l){return d(I^C^A,g,I,i,e,l)}function Z(g,I,C,A,i,e,l){return d(C^(I|~A),g,I,i,e,l)}Object.defineProperty(C,"__esModule",{value:!0}),C.default=void 0;var b=A;C.default=b},{}],530:[function(g,I,C){Object.defineProperty(C,"__esModule",{value:!0}),C.default=void 0;var A="00000000-0000-0000-0000-000000000000";C.default=A},{}],531:[function(g,I,C){Object.defineProperty(C,"__esModule",{value:!0}),C.default=void 0;var A=i(g("./validate.js"));function i(g){return g&&g.__esModule?g:{default:g}}function e(g){if(!(0,A.default)(g))throw TypeError("Invalid UUID");let I;const C=new Uint8Array(16);return C[0]=(I=parseInt(g.slice(0,8),16))>>>24,C[1]=I>>>16&255,C[2]=I>>>8&255,C[3]=255&I,C[4]=(I=parseInt(g.slice(9,13),16))>>>8,C[5]=255&I,C[6]=(I=parseInt(g.slice(14,18),16))>>>8,C[7]=255&I,C[8]=(I=parseInt(g.slice(19,23),16))>>>8,C[9]=255&I,C[10]=(I=parseInt(g.slice(24,36),16))/1099511627776&255,C[11]=I/4294967296&255,C[12]=I>>>24&255,C[13]=I>>>16&255,C[14]=I>>>8&255,C[15]=255&I,C}var l=e;C.default=l},{"./validate.js":541}],532:[function(g,I,C){Object.defineProperty(C,"__esModule",{value:!0}),C.default=void 0;var A=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;C.default=A},{}],533:[function(g,I,C){let A;Object.defineProperty(C,"__esModule",{value:!0}),C.default=e;const i=new Uint8Array(16);function e(){if(!A&&(A="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto),!A))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return A(i)}},{}],534:[function(g,I,C){function A(g,I,C,A){switch(g){case 0:return I&C^~I&A;case 1:case 3:return I^C^A;case 2:return I&C^I&A^C&A}}function i(g,I){return g<>>32-I}function e(g){const I=[1518500249,1859775393,2400959708,3395469782],C=[1732584193,4023233417,2562383102,271733878,3285377520];if("string"==typeof g){const I=unescape(encodeURIComponent(g));g=[];for(let C=0;C>>0;o=d,d=c,c=i(l,30)>>>0,l=e,e=s}C[0]=C[0]+e>>>0,C[1]=C[1]+l>>>0,C[2]=C[2]+c>>>0,C[3]=C[3]+d>>>0,C[4]=C[4]+o>>>0}return[C[0]>>24&255,C[0]>>16&255,C[0]>>8&255,255&C[0],C[1]>>24&255,C[1]>>16&255,C[1]>>8&255,255&C[1],C[2]>>24&255,C[2]>>16&255,C[2]>>8&255,255&C[2],C[3]>>24&255,C[3]>>16&255,C[3]>>8&255,255&C[3],C[4]>>24&255,C[4]>>16&255,C[4]>>8&255,255&C[4]]}Object.defineProperty(C,"__esModule",{value:!0}),C.default=void 0;var l=e;C.default=l},{}],535:[function(g,I,C){Object.defineProperty(C,"__esModule",{value:!0}),C.default=void 0;var A=i(g("./validate.js"));function i(g){return g&&g.__esModule?g:{default:g}}const e=[];for(let s=0;s<256;++s)e.push((s+256).toString(16).substr(1));function l(g){let I=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;const C=(e[g[I+0]]+e[g[I+1]]+e[g[I+2]]+e[g[I+3]]+"-"+e[g[I+4]]+e[g[I+5]]+"-"+e[g[I+6]]+e[g[I+7]]+"-"+e[g[I+8]]+e[g[I+9]]+"-"+e[g[I+10]]+e[g[I+11]]+e[g[I+12]]+e[g[I+13]]+e[g[I+14]]+e[g[I+15]]).toLowerCase();if(!(0,A.default)(C))throw TypeError("Stringified UUID is invalid");return C}var t=l;C.default=t},{"./validate.js":541}],536:[function(g,I,C){Object.defineProperty(C,"__esModule",{value:!0}),C.default=void 0;var A=e(g("./rng.js")),i=e(g("./stringify.js"));function e(g){return g&&g.__esModule?g:{default:g}}let l,t,s=0,c=0;function d(g,I,C){let e=I&&C||0;const d=I||new Array(16);let o=(g=g||{}).node||l,n=void 0!==g.clockseq?g.clockseq:t;if(null==o||null==n){const I=g.random||(g.rng||A.default)();null==o&&(o=l=[1|I[0],I[1],I[2],I[3],I[4],I[5]]),null==n&&(n=t=16383&(I[6]<<8|I[7]))}let a=void 0!==g.msecs?g.msecs:Date.now(),Z=void 0!==g.nsecs?g.nsecs:c+1;const b=a-s+(Z-c)/1e4;if(b<0&&void 0===g.clockseq&&(n=n+1&16383),(b<0||a>s)&&void 0===g.nsecs&&(Z=0),Z>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");s=a,c=Z,t=n,a+=122192928e5;const r=(1e4*(268435455&a)+Z)%4294967296;d[e++]=r>>>24&255,d[e++]=r>>>16&255,d[e++]=r>>>8&255,d[e++]=255&r;const m=a/4294967296*1e4&268435455;d[e++]=m>>>8&255,d[e++]=255&m,d[e++]=m>>>24&15|16,d[e++]=m>>>16&255,d[e++]=n>>>8|128,d[e++]=255&n;for(let A=0;A<6;++A)d[e+A]=o[A];return I||(0,i.default)(d)}var o=d;C.default=o},{"./rng.js":533,"./stringify.js":535}],537:[function(g,I,C){Object.defineProperty(C,"__esModule",{value:!0}),C.default=void 0;var A=e(g("./v35.js")),i=e(g("./md5.js"));function e(g){return g&&g.__esModule?g:{default:g}}var l=(0,A.default)("v3",48,i.default);C.default=l},{"./md5.js":529,"./v35.js":538}],538:[function(g,I,C){Object.defineProperty(C,"__esModule",{value:!0}),C.default=c,C.URL=C.DNS=void 0;var A=e(g("./stringify.js")),i=e(g("./parse.js"));function e(g){return g&&g.__esModule?g:{default:g}}function l(g){g=unescape(encodeURIComponent(g));const I=[];for(let C=0;C=l&&g<=55295||g===i||g===e||g===A||g>=57344&&g<=65533||g>=65536&&g<=1114111}function s(g){return g===l||g===i||g===e||g===A}function c(g){return g>=65&&g<=90||g>=97&&g<=122||58===g||95===g||8204===g||8205===g||g>=192&&g<=214||g>=216&&g<=246||g>=248&&g<=767||g>=880&&g<=893||g>=895&&g<=8191||g>=8304&&g<=8591||g>=11264&&g<=12271||g>=12289&&g<=55295||g>=63744&&g<=64975||g>=65008&&g<=65533||g>=65536&&g<=983039}function d(g){return c(g)||g>=48&&g<=57||45===g||46===g||183===g||g>=768&&g<=879||g>=8255&&g<=8256}C.S_LIST=[l,i,e,A],C.isChar=t,C.isS=s,C.isNameStartChar=c,C.isNameChar=d},{}],544:[function(g,I,C){ /** * Character classes and associated utilities for the 2nd edition of XML 1.1. * * @author Louis-Dominique Dubeau * @license MIT * @copyright Louis-Dominique Dubeau */ Object.defineProperty(C,"__esModule",{value:!0}),C.CHAR="-퟿-�𐀀-􏿿",C.RESTRICTED_CHAR="-\b\v\f--„†-Ÿ",C.S=" \t\r\n",C.NAME_START_CHAR=":A-Z_a-zÀ-ÖØ-öø-˿Ͱ-ͽͿ-῿‌‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-�𐀀-󯿿",C.NAME_CHAR="-"+C.NAME_START_CHAR+".0-9·̀-ͯ‿-⁀",C.CHAR_RE=new RegExp("^["+C.CHAR+"]$","u"),C.RESTRICTED_CHAR_RE=new RegExp("^["+C.RESTRICTED_CHAR+"]$","u"),C.S_RE=new RegExp("^["+C.S+"]+$","u"),C.NAME_START_CHAR_RE=new RegExp("^["+C.NAME_START_CHAR+"]$","u"),C.NAME_CHAR_RE=new RegExp("^["+C.NAME_CHAR+"]$","u"),C.NAME_RE=new RegExp("^["+C.NAME_START_CHAR+"]["+C.NAME_CHAR+"]*$","u"),C.NMTOKEN_RE=new RegExp("^["+C.NAME_CHAR+"]+$","u");var A=9,i=10,e=13,l=32;function t(g){return g>=1&&g<=55295||g>=57344&&g<=65533||g>=65536&&g<=1114111}function s(g){return g>=1&&g<=8||11===g||12===g||g>=14&&g<=31||g>=127&&g<=132||g>=134&&g<=159}function c(g){return 9===g||10===g||13===g||g>31&&g<127||133===g||g>159&&g<=55295||g>=57344&&g<=65533||g>=65536&&g<=1114111}function d(g){return g===l||g===i||g===e||g===A}function o(g){return g>=65&&g<=90||g>=97&&g<=122||58===g||95===g||8204===g||8205===g||g>=192&&g<=214||g>=216&&g<=246||g>=248&&g<=767||g>=880&&g<=893||g>=895&&g<=8191||g>=8304&&g<=8591||g>=11264&&g<=12271||g>=12289&&g<=55295||g>=63744&&g<=64975||g>=65008&&g<=65533||g>=65536&&g<=983039}function n(g){return o(g)||g>=48&&g<=57||45===g||46===g||183===g||g>=768&&g<=879||g>=8255&&g<=8256}C.S_LIST=[l,i,e,A],C.isChar=t,C.isRestrictedChar=s,C.isCharAndNotRestricted=c,C.isS=d,C.isNameStartChar=o,C.isNameChar=n},{}],545:[function(g,I,C){function A(g){return g>=65&&g<=90||95===g||g>=97&&g<=122||g>=192&&g<=214||g>=216&&g<=246||g>=248&&g<=767||g>=880&&g<=893||g>=895&&g<=8191||g>=8204&&g<=8205||g>=8304&&g<=8591||g>=11264&&g<=12271||g>=12289&&g<=55295||g>=63744&&g<=64975||g>=65008&&g<=65533||g>=65536&&g<=983039}function i(g){return A(g)||45===g||46===g||g>=48&&g<=57||183===g||g>=768&&g<=879||g>=8255&&g<=8256} /** * Character class utilities for XML NS 1.0 edition 3. * * @author Louis-Dominique Dubeau * @license MIT * @copyright Louis-Dominique Dubeau */ Object.defineProperty(C,"__esModule",{value:!0}),C.NC_NAME_START_CHAR="A-Z_a-zÀ-ÖØ-öø-˿Ͱ-ͽͿ-῿‌-‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-�𐀀-󯿿",C.NC_NAME_CHAR="-"+C.NC_NAME_START_CHAR+".0-9·̀-ͯ‿-⁀",C.NC_NAME_START_CHAR_RE=new RegExp("^["+C.NC_NAME_START_CHAR+"]$","u"),C.NC_NAME_CHAR_RE=new RegExp("^["+C.NC_NAME_CHAR+"]$","u"),C.NC_NAME_RE=new RegExp("^["+C.NC_NAME_START_CHAR+"]["+C.NC_NAME_CHAR+"]*$","u"),C.isNCNameStartChar=A,C.isNCNameChar=i},{}]},{},[15])(15)}(bs);var rs=bs.exports;function ms(g){return(ms="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(g){return typeof g}:function(g){return g&&"function"==typeof Symbol&&g.constructor===Symbol&&g!==Symbol.prototype?"symbol":typeof g})(g)}var hs=/^\s+/,Gs=/\s+$/;function us(g,I){if(I=I||{},(g=g||"")instanceof us)return g;if(!(this instanceof us))return new us(g,I);var C=function(g){var I={r:0,g:0,b:0},C=1,A=null,i=null,e=null,l=!1,t=!1;"string"==typeof g&&(g=function(g){g=g.replace(hs,"").replace(Gs,"").toLowerCase();var I,C=!1;if(fs[g])g=fs[g],C=!0;else if("transparent"==g)return{r:0,g:0,b:0,a:0,format:"name"};if(I=Ps.rgb.exec(g))return{r:I[1],g:I[2],b:I[3]};if(I=Ps.rgba.exec(g))return{r:I[1],g:I[2],b:I[3],a:I[4]};if(I=Ps.hsl.exec(g))return{h:I[1],s:I[2],l:I[3]};if(I=Ps.hsla.exec(g))return{h:I[1],s:I[2],l:I[3],a:I[4]};if(I=Ps.hsv.exec(g))return{h:I[1],s:I[2],v:I[3]};if(I=Ps.hsva.exec(g))return{h:I[1],s:I[2],v:I[3],a:I[4]};if(I=Ps.hex8.exec(g))return{r:vs(I[1]),g:vs(I[2]),b:vs(I[3]),a:Qs(I[4]),format:C?"name":"hex8"};if(I=Ps.hex6.exec(g))return{r:vs(I[1]),g:vs(I[2]),b:vs(I[3]),format:C?"name":"hex"};if(I=Ps.hex4.exec(g))return{r:vs(I[1]+""+I[1]),g:vs(I[2]+""+I[2]),b:vs(I[3]+""+I[3]),a:Qs(I[4]+""+I[4]),format:C?"name":"hex8"};if(I=Ps.hex3.exec(g))return{r:vs(I[1]+""+I[1]),g:vs(I[2]+""+I[2]),b:vs(I[3]+""+I[3]),format:C?"name":"hex"};return!1}(g));"object"==ms(g)&&(_s(g.r)&&_s(g.g)&&_s(g.b)?(s=g.r,c=g.g,d=g.b,I={r:255*Ls(s,255),g:255*Ls(c,255),b:255*Ls(d,255)},l=!0,t="%"===String(g.r).substr(-1)?"prgb":"rgb"):_s(g.h)&&_s(g.s)&&_s(g.v)?(A=xs(g.s),i=xs(g.v),I=function(g,I,C){g=6*Ls(g,360),I=Ls(I,100),C=Ls(C,100);var A=Math.floor(g),i=g-A,e=C*(1-I),l=C*(1-i*I),t=C*(1-(1-i)*I),s=A%6,c=[C,l,e,e,t,C][s],d=[t,C,C,l,e,e][s],o=[e,e,t,C,C,l][s];return{r:255*c,g:255*d,b:255*o}}(g.h,A,i),l=!0,t="hsv"):_s(g.h)&&_s(g.s)&&_s(g.l)&&(A=xs(g.s),e=xs(g.l),I=function(g,I,C){var A,i,e;function l(g,I,C){return C<0&&(C+=1),C>1&&(C-=1),C<1/6?g+6*(I-g)*C:C<.5?I:C<2/3?g+(I-g)*(2/3-C)*6:g}if(g=Ls(g,360),I=Ls(I,100),C=Ls(C,100),0===I)A=i=e=C;else{var t=C<.5?C*(1+I):C+I-C*I,s=2*C-t;A=l(s,t,g+1/3),i=l(s,t,g),e=l(s,t,g-1/3)}return{r:255*A,g:255*i,b:255*e}}(g.h,A,e),l=!0,t="hsl"),g.hasOwnProperty("a")&&(C=g.a));var s,c,d;return C=Ds(C),{ok:l,format:g.format||t,r:Math.min(255,Math.max(I.r,0)),g:Math.min(255,Math.max(I.g,0)),b:Math.min(255,Math.max(I.b,0)),a:C}}(g);this._originalInput=g,this._r=C.r,this._g=C.g,this._b=C.b,this._a=C.a,this._roundA=Math.round(100*this._a)/100,this._format=I.format||C.format,this._gradientType=I.gradientType,this._r<1&&(this._r=Math.round(this._r)),this._g<1&&(this._g=Math.round(this._g)),this._b<1&&(this._b=Math.round(this._b)),this._ok=C.ok}function Bs(g,I,C){g=Ls(g,255),I=Ls(I,255),C=Ls(C,255);var A,i,e=Math.max(g,I,C),l=Math.min(g,I,C),t=(e+l)/2;if(e==l)A=i=0;else{var s=e-l;switch(i=t>.5?s/(2-e-l):s/(e+l),e){case g:A=(I-C)/s+(I>1)+720)%360;--I;)A.h=(A.h+i)%360,e.push(us(A));return e}function Ss(g,I){I=I||6;for(var C=us(g).toHsv(),A=C.h,i=C.s,e=C.v,l=[],t=1/I;I--;)l.push(us({h:A,s:i,v:e})),e=(e+t)%1;return l}us.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var g=this.toRgb();return(299*g.r+587*g.g+114*g.b)/1e3},getLuminance:function(){var g,I,C,A=this.toRgb();return g=A.r/255,I=A.g/255,C=A.b/255,.2126*(g<=.03928?g/12.92:Math.pow((g+.055)/1.055,2.4))+.7152*(I<=.03928?I/12.92:Math.pow((I+.055)/1.055,2.4))+.0722*(C<=.03928?C/12.92:Math.pow((C+.055)/1.055,2.4))},setAlpha:function(g){return this._a=Ds(g),this._roundA=Math.round(100*this._a)/100,this},toHsv:function(){var g=ws(this._r,this._g,this._b);return{h:360*g.h,s:g.s,v:g.v,a:this._a}},toHsvString:function(){var g=ws(this._r,this._g,this._b),I=Math.round(360*g.h),C=Math.round(100*g.s),A=Math.round(100*g.v);return 1==this._a?"hsv("+I+", "+C+"%, "+A+"%)":"hsva("+I+", "+C+"%, "+A+"%, "+this._roundA+")"},toHsl:function(){var g=Bs(this._r,this._g,this._b);return{h:360*g.h,s:g.s,l:g.l,a:this._a}},toHslString:function(){var g=Bs(this._r,this._g,this._b),I=Math.round(360*g.h),C=Math.round(100*g.s),A=Math.round(100*g.l);return 1==this._a?"hsl("+I+", "+C+"%, "+A+"%)":"hsla("+I+", "+C+"%, "+A+"%, "+this._roundA+")"},toHex:function(g){return Ws(this._r,this._g,this._b,g)},toHexString:function(g){return"#"+this.toHex(g)},toHex8:function(g){return function(g,I,C,A,i){var e=[Ts(Math.round(g).toString(16)),Ts(Math.round(I).toString(16)),Ts(Math.round(C).toString(16)),Ts(Us(A))];if(i&&e[0].charAt(0)==e[0].charAt(1)&&e[1].charAt(0)==e[1].charAt(1)&&e[2].charAt(0)==e[2].charAt(1)&&e[3].charAt(0)==e[3].charAt(1))return e[0].charAt(0)+e[1].charAt(0)+e[2].charAt(0)+e[3].charAt(0);return e.join("")}(this._r,this._g,this._b,this._a,g)},toHex8String:function(g){return"#"+this.toHex8(g)},toRgb:function(){return{r:Math.round(this._r),g:Math.round(this._g),b:Math.round(this._b),a:this._a}},toRgbString:function(){return 1==this._a?"rgb("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+")":"rgba("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:Math.round(100*Ls(this._r,255))+"%",g:Math.round(100*Ls(this._g,255))+"%",b:Math.round(100*Ls(this._b,255))+"%",a:this._a}},toPercentageRgbString:function(){return 1==this._a?"rgb("+Math.round(100*Ls(this._r,255))+"%, "+Math.round(100*Ls(this._g,255))+"%, "+Math.round(100*Ls(this._b,255))+"%)":"rgba("+Math.round(100*Ls(this._r,255))+"%, "+Math.round(100*Ls(this._g,255))+"%, "+Math.round(100*Ls(this._b,255))+"%, "+this._roundA+")"},toName:function(){return 0===this._a?"transparent":!(this._a<1)&&(ks[Ws(this._r,this._g,this._b,!0)]||!1)},toFilter:function(g){var I="#"+ps(this._r,this._g,this._b,this._a),C=I,A=this._gradientType?"GradientType = 1, ":"";if(g){var i=us(g);C="#"+ps(i._r,i._g,i._b,i._a)}return"progid:DXImageTransform.Microsoft.gradient("+A+"startColorstr="+I+",endColorstr="+C+")"},toString:function(g){var I=!!g;g=g||this._format;var C=!1,A=this._a<1&&this._a>=0;return I||!A||"hex"!==g&&"hex6"!==g&&"hex3"!==g&&"hex4"!==g&&"hex8"!==g&&"name"!==g?("rgb"===g&&(C=this.toRgbString()),"prgb"===g&&(C=this.toPercentageRgbString()),"hex"!==g&&"hex6"!==g||(C=this.toHexString()),"hex3"===g&&(C=this.toHexString(!0)),"hex4"===g&&(C=this.toHex8String(!0)),"hex8"===g&&(C=this.toHex8String()),"name"===g&&(C=this.toName()),"hsl"===g&&(C=this.toHslString()),"hsv"===g&&(C=this.toHsvString()),C||this.toHexString()):"name"===g&&0===this._a?this.toName():this.toRgbString()},clone:function(){return us(this.toString())},_applyModification:function(g,I){var C=g.apply(null,[this].concat([].slice.call(I)));return this._r=C._r,this._g=C._g,this._b=C._b,this.setAlpha(C._a),this},lighten:function(){return this._applyModification(Ys,arguments)},brighten:function(){return this._applyModification(Rs,arguments)},darken:function(){return this._applyModification(Ns,arguments)},desaturate:function(){return this._applyModification(Vs,arguments)},saturate:function(){return this._applyModification(ys,arguments)},greyscale:function(){return this._applyModification(Xs,arguments)},spin:function(){return this._applyModification(Hs,arguments)},_applyCombination:function(g,I){return g.apply(null,[this].concat([].slice.call(I)))},analogous:function(){return this._applyCombination(Js,arguments)},complement:function(){return this._applyCombination(Ks,arguments)},monochromatic:function(){return this._applyCombination(Ss,arguments)},splitcomplement:function(){return this._applyCombination(Ms,arguments)},triad:function(){return this._applyCombination(Fs,[3])},tetrad:function(){return this._applyCombination(Fs,[4])}},us.fromRatio=function(g,I){if("object"==ms(g)){var C={};for(var A in g)g.hasOwnProperty(A)&&(C[A]="a"===A?g[A]:xs(g[A]));g=C}return us(g,I)},us.equals=function(g,I){return!(!g||!I)&&us(g).toRgbString()==us(I).toRgbString()},us.random=function(){return us.fromRatio({r:Math.random(),g:Math.random(),b:Math.random()})},us.mix=function(g,I,C){C=0===C?0:C||50;var A=us(g).toRgb(),i=us(I).toRgb(),e=C/100;return us({r:(i.r-A.r)*e+A.r,g:(i.g-A.g)*e+A.g,b:(i.b-A.b)*e+A.b,a:(i.a-A.a)*e+A.a})},us.readability=function(g,I){var C=us(g),A=us(I);return(Math.max(C.getLuminance(),A.getLuminance())+.05)/(Math.min(C.getLuminance(),A.getLuminance())+.05)},us.isReadable=function(g,I,C){var A,i,e=us.readability(g,I);switch(i=!1,(A=function(g){var I,C;I=((g=g||{level:"AA",size:"small"}).level||"AA").toUpperCase(),C=(g.size||"small").toLowerCase(),"AA"!==I&&"AAA"!==I&&(I="AA");"small"!==C&&"large"!==C&&(C="small");return{level:I,size:C}}(C)).level+A.size){case"AAsmall":case"AAAlarge":i=e>=4.5;break;case"AAlarge":i=e>=3;break;case"AAAsmall":i=e>=7}return i},us.mostReadable=function(g,I,C){var A,i,e,l,t=null,s=0;i=(C=C||{}).includeFallbackColors,e=C.level,l=C.size;for(var c=0;cs&&(s=A,t=us(I[c]));return us.isReadable(g,t,{level:e,size:l})||!i?t:(C.includeFallbackColors=!1,us.mostReadable(g,["#fff","#000"],C))};var fs=us.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},ks=us.hexNames=function(g){var I={};for(var C in g)g.hasOwnProperty(C)&&(I[g[C]]=C);return I}(fs);function Ds(g){return g=parseFloat(g),(isNaN(g)||g<0||g>1)&&(g=1),g}function Ls(g,I){(function(g){return"string"==typeof g&&-1!=g.indexOf(".")&&1===parseFloat(g)})(g)&&(g="100%");var C=function(g){return"string"==typeof g&&-1!=g.indexOf("%")}(g);return g=Math.min(I,Math.max(0,parseFloat(g))),C&&(g=parseInt(g*I,10)/100),Math.abs(g-I)<1e-6?1:g%I/parseFloat(I)}function zs(g){return Math.min(1,Math.max(0,g))}function vs(g){return parseInt(g,16)}function Ts(g){return 1==g.length?"0"+g:""+g}function xs(g){return g<=1&&(g=100*g+"%"),g}function Us(g){return Math.round(255*parseFloat(g)).toString(16)}function Qs(g){return vs(g)/255}var js,Os,Es,Ps=(Os="[\\s|\\(]+("+(js="(?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?)")+")[,|\\s]+("+js+")[,|\\s]+("+js+")\\s*\\)?",Es="[\\s|\\(]+("+js+")[,|\\s]+("+js+")[,|\\s]+("+js+")[,|\\s]+("+js+")\\s*\\)?",{CSS_UNIT:new RegExp(js),rgb:new RegExp("rgb"+Os),rgba:new RegExp("rgba"+Es),hsl:new RegExp("hsl"+Os),hsla:new RegExp("hsla"+Es),hsv:new RegExp("hsv"+Os),hsva:new RegExp("hsva"+Es),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/});function _s(g){return!!Ps.CSS_UNIT.exec(g)}const qs=["#FFFFFF","#000000","#BFBFBF","#323232","#4472C4","#ED7D31","#A5A5A5","#FFC000","#5B9BD5","#71AD47"],$s=["#000000","#FFFFFF","#FF0000","#00FF00","#0000FF","#FFFF00","#FF00FF","#00FFFF","#000000","#FFFFFF","#FF0000","#00FF00","#0000FF","#FFFF00","#FF00FF","#00FFFF","#800000","#008000","#000080","#808000","#800080","#008080","#C0C0C0","#808080","#9999FF","#993366","#FFFFCC","#CCFFFF","#660066","#FF8080","#0066CC","#CCCCFF","#000080","#FF00FF","#FFFF00","#00FFFF","#800080","#800000","#008080","#0000FF","#00CCFF","#CCFFFF","#CCFFCC","#FFFF99","#99CCFF","#FF99CC","#CC99FF","#FFCC99","#3366FF","#33CCCC","#99CC00","#FFCC00","#FF9900","#FF6600","#666699","#969696","#003366","#339966","#003300","#333300","#993300","#993366","#333399","#333333","#FFFFFF"],gc=80;function Ic(g){if("object"==typeof g)return"#000000";if(/^#?[a-f\d]{6}$/i.test(g))return g.startsWith("#")?g:"#"+g;g=g.trim().toLowerCase();const I={};try{const C=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(g)||"";return I.r=parseInt(C[2],16),I.g=parseInt(C[3],16),I.b=parseInt(C[4],16),I.a=parseInt(C[1],16)/255,us(`rgba(${I.r}, ${I.g}, ${I.b}, ${I.a})`).toHexString()}catch(C){console.warn(C)}}function Cc(g,I){return g>9?"#C7C9CC":void 0===I?qs[g]:I>0?function(g,I){const C=fI(g)||[];for(let A=0;A<3;A++)C[A]=Math.floor((255-Number(C[A]))*I+Number(C[A]));return LI(C[0],C[1],C[2])}(qs[g],I):kI(qs[g],Math.abs(I))}function Ac(g,I){const C=[];return g.eachSheet((g=>{const A={name:g.name,styles:[],rows:{},cols:{},merges:[],media:[]},i=[];for(const I in g._merges){A.merges.push(g._merges[I].shortRange);const C={};C.startAddress=g._merges[I].tl,C.endAddress=g._merges[I].br,C.YRange=g._merges[I].model.bottom-g._merges[I].model.top,C.XRange=g._merges[I].model.right-g._merges[I].model.left,i.push(C)}!function(g,I,C){for(let A=0;A<(g.columns||[]).length;A++)I.cols[A.toString()]={},g.columns[A].width?I.cols[A.toString()].width=6*g.columns[A].width+(C.widthOffset||0):I.cols[A.toString()].width=gc+(C.widthOffset||0);I.cols.len=Math.max(Object.keys(I.cols).length,C.minColLength||0)}(g,A,I),(g._rows||[]).forEach(((g,C)=>{A.rows[C]={cells:{}},g.height?A.rows[C].height=g.height+(I.heightOffset||0):A.rows[C].height=24+(I.heightOffset||0),(g._cells||[]).forEach(((g,I)=>{A.rows[C].cells[I]={};const e=PA.find(i,(function(I){return I.startAddress===g._address}));e&&g.master.address!==e.startAddress||(e&&(A.rows[C].cells[I].merge=[e.YRange,e.XRange]),A.rows[C].cells[I].text=function(g){const{numFmt:I,value:C,type:A}=g;switch(A){case 2:try{if(g.style.numFmt){if(g.style.numFmt.endsWith("%")){const I=g.style.numFmt.match(/\.(\d+)%/);return I?(100*Number(C)).toFixed(I[1].length)+"%":100*Number(C)+"%"}if(/0(?:\.0+)?/.test(g.style.numFmt)){if(0===Number(C)&&g.style.numFmt.startsWith("_"))return"-";let I=g.style.numFmt.match(/0\.(0+)(_|;|$)/);I=I?I[1].length:0;let A=Number(C).toFixed(I)+"";if(g.style.numFmt.includes("#,##")){A=A.split(".");const g=A[0].split("").reverse(),I=[];for(let C=0;C{const A=g.style.border[C];let i="#000000";"string"==typeof A.color?i=A.color:A.color&&(A.color.argb?i=Ic(A.color.argb)||"":Object.prototype.hasOwnProperty.call(A.color,"theme")?i=Cc(A.color.theme,A.color.tint):A.color.indexed&&(i=$s[A.color.indexed])),I[C]=[A.style||"thin",i]})),g.style.border2={...g.style.border},g.style.border=I}return g.style}(g)),A.rows[C].cells[I].style=A.styles.length-1)}))})),A._media&&(A.media=A._media),A.rows.len=Math.max(Object.keys(A.rows).length,100),C.push(A)})),{workbookData:C,workbookSource:g,medias:g.media||[]}}let ic=[];function ec(g,I,C,A){C&&C._media.length&&C._media.forEach((i=>{const{imageId:e,range:l,type:t}=i;if("image"===t){const i=function(g,I,C){var A,i,e,l,t,s,c,d,o,n,a,Z,b,r;const{tl:m={},br:h={}}=I,{nativeCol:G,nativeColOff:u,nativeRow:B,nativeRowOff:w}=m;let W=lc,p=tc;for(let F=0;F{if(ic[g])return C(ic[g]);const{buffer:i,extension:e}=I.buffer,l=new Blob([i],{type:"image/"+e}),t=URL.createObjectURL(l),s=new Image;s.src=t,s.onload=function(){C(s),ic[g]=s},s.onerror=function(g){A(g)}}))})(I,C).then((I=>{let C=0,i=0,e=I.width,l=I.height,t=A.x,s=A.y,c=A.width,d=A.height;const o=c/e,n=d/l;if(t{}))}(g,e,I[e],i)}}))}const lc=60,tc=25,sc=80,cc=24,dc=window.devicePixelRatio;function oc(){ic=[]}function nc(g){if(g){const I=g.querySelectorAll("input");for(const g of I)g&&!g.readOnly&&(g.readOnly=!0)}}const ac={minColLength:20};class Zc{constructor(g,I={}){C(this,"container"),C(this,"options",{}),C(this,"wrapper"),C(this,"wrapperMain"),C(this,"xs"),C(this,"sheetIndex"),C(this,"mediasSource"),C(this,"workbookDataSource"),C(this,"ctx"),C(this,"fileData"),C(this,"observer"),C(this,"offset"),this.container=g,this.options={...ac,...I},this.sheetIndex=1,this.mediasSource={},this.workbookDataSource={_worksheets:[]},this.createWrapper(),this.initSpreadsheet(),this.hack()}createWrapper(){this.wrapper=document.createElement("div"),this.wrapper.className="r-preview-excel-main",this.container.appendChild(this.wrapper)}async initSpreadsheet(){var g;if(!this.wrapper&&"undefined"!=typeof window)return;if(this.xs=new as(this.wrapper,{mode:"read",showToolbar:!1,showContextmenu:this.options.showContextmenu||!1,view:{height:()=>this.wrapper&&this.wrapper.clientHeight||300,width:()=>this.wrapper&&this.wrapper.clientWidth||1200},row:{height:24,len:100},col:{len:26,width:80,indexWidth:60,minWidth:60}}).loadData({}),!this.xs)return;if(this.xs.bottombar){const g=this.xs.bottombar.swapFunc;this.xs.bottombar.swapFunc=I=>{var C;g.call(null==(C=this.xs)?void 0:C.bottombar,I),this.sheetIndex=I+1,setTimeout((()=>{var g,I;(null==(g=this.xs)?void 0:g.reRender)&&(null==(I=this.xs)||I.reRender()),this.mediasSource&&this.ctx&&this.offset&&ec(this.ctx,this.mediasSource,this.workbookDataSource._worksheets[this.sheetIndex],this.offset)}))}}if(null==(g=this.xs.sheet)?void 0:g.editor){const g=this.xs.sheet.editor.clear;this.xs.sheet.editor.clear=(...I)=>{var C,A;g.apply(null==(A=null==(C=this.xs)?void 0:C.sheet)?void 0:A.editor,I),setTimeout((()=>{this.ctx&&this.mediasSource&&this.offset&&ec(this.ctx,this.mediasSource,this.workbookDataSource._worksheets[this.sheetIndex],this.offset)}))};const I=this.xs.sheet.editor.setOffset;this.xs.sheet.editor.setOffset=(...g)=>{var C,A;I.apply(null==(A=null==(C=this.xs)?void 0:C.sheet)?void 0:A.editor,g),g.length>1&&(this.offset=g.shift()),this.ctx&&this.mediasSource&&this.offset&&ec(this.ctx,this.mediasSource,this.workbookDataSource._worksheets[this.sheetIndex],this.offset)}}const I=this.wrapper&&this.wrapper.querySelector("canvas");I&&(this.ctx=I.getContext("2d"))}renderExcel(g,I,C){return this.fileData=g,function(g){try{return(new rs.Workbook).xlsx.load(g)}catch(I){return console.warn(I),Promise.reject(I)}}(g).then((g=>{var A;if(!g._worksheets||0===g._worksheets.length)throw I&&I({success:!1,data:null,message:"未获取到数据,可能文件格式不正确或文件已损坏"}),new Error("未获取到数据,可能文件格式不正确或文件已损坏");const{workbookData:i,medias:e,workbookSource:l}=Ac(g,this.options);this.mediasSource=e,this.workbookDataSource=l,this.offset=void 0,this.sheetIndex=1,oc(),null==(A=this.xs)||A.loadData(i),this.ctx&&this.mediasSource&&this.offset&&ec(this.ctx,this.mediasSource,this.workbookDataSource._worksheets[this.sheetIndex],this.offset),C&&C({success:!0,data:g})})).catch((g=>{var C;return this.mediasSource=[],this.workbookDataSource={_worksheets:[]},oc(),null==(C=this.xs)||C.loadData({}),I&&I({success:!1,message:"未获取到数据,可能文件格式不正确或文件已损坏"}),Promise.reject(g)}))}hack(){if(!this.wrapper)return;const g=PA.debounce(nc,200).bind(this,this.wrapper);this.observer=new MutationObserver(g);this.observer.observe(this.wrapper,{attributes:!0,childList:!0,subtree:!0}),g()}}const bc=Object.freeze(Object.defineProperty({__proto__:null,renderExcel:(g,I)=>{const{dom:C,onError:A,onLoad:i}=I;if(!C)return Promise.reject();const e=new Zc(C);return new Promise(((I,C)=>{const A=new FileReader;A.readAsArrayBuffer(g),A.onload=()=>{A.result?I(null==A?void 0:A.result):C()}})).then((g=>{e.renderExcel(g,A,i)}))}},Symbol.toStringTag,{value:"Module"}));g.button=M,g.checkbox=Hg,g.colorpicker=_g,g.content=Tg,g.icon=D,g.image=z,g.input=x,g.loading=gI,g.message=O,g.modal=pg,g.player=wg,g.popover=Lg,g.preview=$,g.progress=Yg,g.radar=og,g.select=rg,g.skeleton=Ig,g.tab=eg,g.tabpane=Ag,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})}));
"+g+""+g+""+g+"
"+g+"